From fdeea341ed1bae670382e45eb731db1b5838ad21 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 11 Mar 1998 21:11:04 +0000 Subject: "For I have laboured mightily on Luke's code, and hath broken all I saw" - the book of Jeremy, chapter 1 :-). So here is the mega-merge of the NTDOM branch server code. It doesn't include the new client side pieces, we'll look at that later. This should give the same functionality, server wise, as the NTDOM branch does, only merged into the main branch. Any fixes to domain controler functionality should be added to the main branch, not the NTDOM branch. This code compiles without warnings on gcc2.8, but will need further testing before we are sure all the working functionality of the NTDOM server branch has been correctly carried over. I hereby declare the server side of the NTDOM branch dead (and all who sail in her :-). Jeremy. (This used to be commit 118ba4d77a33248e762a2cf843fb7cbc906ee6e7) --- source3/rpc_server/srv_lsa.c | 444 ++++++++++++ source3/rpc_server/srv_lsa_hnd.c | 316 +++++++++ source3/rpc_server/srv_netlog.c | 832 +++++++++++++++++++++++ source3/rpc_server/srv_pipe_hnd.c | 315 +++++++++ source3/rpc_server/srv_reg.c | 240 +++++++ source3/rpc_server/srv_samr.c | 1352 +++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_srvsvc.c | 1015 ++++++++++++++++++++++++++++ source3/rpc_server/srv_util.c | 477 +++++++++++++ source3/rpc_server/srv_wkssvc.c | 113 ++++ 9 files changed, 5104 insertions(+) create mode 100644 source3/rpc_server/srv_lsa.c create mode 100644 source3/rpc_server/srv_lsa_hnd.c create mode 100644 source3/rpc_server/srv_netlog.c create mode 100644 source3/rpc_server/srv_pipe_hnd.c create mode 100644 source3/rpc_server/srv_reg.c create mode 100644 source3/rpc_server/srv_samr.c create mode 100644 source3/rpc_server/srv_srvsvc.c create mode 100644 source3/rpc_server/srv_util.c create mode 100644 source3/rpc_server/srv_wkssvc.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c new file mode 100644 index 0000000000..60b74cf599 --- /dev/null +++ b/source3/rpc_server/srv_lsa.c @@ -0,0 +1,444 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + + +/*************************************************************************** +lsa_reply_open_policy + ***************************************************************************/ +static void lsa_reply_open_policy(prs_struct *rdata) +{ + int i; + LSA_R_OPEN_POL r_o; + + /* set up the LSA QUERY INFO response */ + bzero(&(r_o.pol.data), POL_HND_SIZE); + for (i = 4; i < POL_HND_SIZE; i++) + { + r_o.pol.data[i] = i; + } + r_o.status = 0x0; + + /* store the response in the SMB stream */ + lsa_io_r_open_pol("", &r_o, rdata, 0); +} + +/*************************************************************************** +make_dom_query + ***************************************************************************/ +static void make_dom_query(DOM_QUERY *d_q, char *dom_name, char *dom_sid) +{ + int domlen = strlen(dom_name); + + d_q->uni_dom_max_len = domlen * 2; + d_q->uni_dom_str_len = domlen * 2; + + d_q->buffer_dom_name = 4; /* domain buffer pointer */ + d_q->buffer_dom_sid = 2; /* domain sid pointer */ + + /* this string is supposed to be character short */ + make_unistr2(&(d_q->uni_domain_name), dom_name, domlen); + + make_dom_sid2(&(d_q->dom_sid), dom_sid); +} + +/*************************************************************************** +lsa_reply_query_info + ***************************************************************************/ +static void lsa_reply_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM *q_e, + prs_struct *rdata, + uint32 enum_context, char *dom_name, char *dom_sid) +{ + LSA_R_ENUM_TRUST_DOM r_e; + + /* set up the LSA QUERY INFO response */ + make_r_enum_trust_dom(&r_e, enum_context, dom_name, dom_sid, + dom_name != NULL ? 0x0 : 0x80000000 | NT_STATUS_UNABLE_TO_FREE_VM); + + /* store the response in the SMB stream */ + lsa_io_r_enum_trust_dom("", &r_e, rdata, 0); +} + +/*************************************************************************** +lsa_reply_query_info + ***************************************************************************/ +static void lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, + char *dom_name, char *dom_sid) +{ + LSA_R_QUERY_INFO r_q; + + /* set up the LSA QUERY INFO response */ + + r_q.undoc_buffer = 0x22000000; /* bizarre */ + r_q.info_class = q_q->info_class; + + make_dom_query(&r_q.dom.id5, dom_name, dom_sid); + + r_q.status = 0x0; + + /* store the response in the SMB stream */ + lsa_io_r_query("", &r_q, rdata, 0); +} + +/*************************************************************************** +make_dom_ref + + pretty much hard-coded choice of "other" sids, unfortunately... + + ***************************************************************************/ +static void make_dom_ref(DOM_R_REF *ref, + char *dom_name, char *dom_sid, + char *other_sid1, char *other_sid2, char *other_sid3) +{ + int len_dom_name = strlen(dom_name); + int len_other_sid1 = strlen(other_sid1); + int len_other_sid2 = strlen(other_sid2); + int len_other_sid3 = strlen(other_sid3); + + ref->undoc_buffer = 1; + ref->num_ref_doms_1 = 4; + ref->buffer_dom_name = 1; + ref->max_entries = 32; + ref->num_ref_doms_2 = 4; + + make_uni_hdr2(&(ref->hdr_dom_name ), len_dom_name , len_dom_name , 0); + make_uni_hdr2(&(ref->hdr_ref_dom[0]), len_other_sid1, len_other_sid1, 0); + make_uni_hdr2(&(ref->hdr_ref_dom[1]), len_other_sid2, len_other_sid2, 0); + make_uni_hdr2(&(ref->hdr_ref_dom[2]), len_other_sid3, len_other_sid3, 0); + + if (dom_name != NULL) + { + make_unistr(&(ref->uni_dom_name), dom_name); + } + + make_dom_sid2(&(ref->ref_dom[0]), dom_sid ); + make_dom_sid2(&(ref->ref_dom[1]), other_sid1); + make_dom_sid2(&(ref->ref_dom[2]), other_sid2); + make_dom_sid2(&(ref->ref_dom[3]), other_sid3); +} + +/*************************************************************************** +make_reply_lookup_rids + ***************************************************************************/ +static void make_reply_lookup_rids(LSA_R_LOOKUP_RIDS *r_l, + int num_entries, uint32 dom_rids[MAX_LOOKUP_SIDS], + char *dom_name, char *dom_sid, + char *other_sid1, char *other_sid2, char *other_sid3) +{ + int i; + + make_dom_ref(&(r_l->dom_ref), dom_name, dom_sid, + other_sid1, other_sid2, other_sid3); + + r_l->num_entries = num_entries; + r_l->undoc_buffer = 1; + r_l->num_entries2 = num_entries; + + for (i = 0; i < num_entries; i++) + { + make_dom_rid2(&(r_l->dom_rid[i]), dom_rids[i]); + } + + r_l->num_entries3 = num_entries; +} + +/*************************************************************************** +make_lsa_trans_names + ***************************************************************************/ +static void make_lsa_trans_names(LSA_TRANS_NAME_ENUM *trn, + int num_entries, DOM_SID2 sid[MAX_LOOKUP_SIDS], + uint32 *total) +{ + uint32 status = 0x0; + int i; + (*total) = 0; + + for (i = 0; i < num_entries; i++) + { + uint32 rid = 0xffffffff; + uint8 num_auths = sid[i].sid.num_auths; + fstring name; + uint32 type; + + trn->ptr_name[i] = 0; + trn->ptr_name[(*total)] = 0; + + /* find the rid to look up */ + if (num_auths != 0) + { + rid = sid[i].sid.sub_auths[num_auths-1]; + + status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + + status = (status != 0x0) ? lookup_user_name (rid, name, &type) : status; + status = (status != 0x0) ? lookup_group_name(rid, name, &type) : status; + status = (status != 0x0) ? lookup_alias_name(rid, name, &type) : status; + } + + if (status == 0x0) + { + trn->ptr_name[i] = 1; + make_lsa_trans_name(&(trn->name[(*total)]), type, name, (*total)); + (*total)++; + } + } + + trn->num_entries = (*total); + trn->ptr_trans_names = 1; + trn->num_entries2 = (*total); +} + +/*************************************************************************** +make_reply_lookup_sids + ***************************************************************************/ +static void make_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, + DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *names, + uint32 mapped_count, uint32 status) +{ + r_l->dom_ref = ref; + r_l->names = names; + r_l->mapped_count = mapped_count; + r_l->status = status; +} + +/*************************************************************************** +lsa_reply_lookup_sids + ***************************************************************************/ +static void lsa_reply_lookup_sids(prs_struct *rdata, + int num_entries, DOM_SID2 sid[MAX_LOOKUP_SIDS], + char *dom_name, char *dom_sid, + char *other_sid1, char *other_sid2, char *other_sid3) +{ + LSA_R_LOOKUP_SIDS r_l; + DOM_R_REF ref; + LSA_TRANS_NAME_ENUM names; + uint32 mapped_count = 0; + + /* set up the LSA Lookup SIDs response */ + make_dom_ref(&ref, dom_name, dom_sid, other_sid1, other_sid2, other_sid3); + make_lsa_trans_names(&names, num_entries, sid, &mapped_count); + make_reply_lookup_sids(&r_l, &ref, &names, mapped_count, 0x0); + + /* store the response in the SMB stream */ + lsa_io_r_lookup_sids("", &r_l, rdata, 0); +} + +/*************************************************************************** +lsa_reply_lookup_rids + ***************************************************************************/ +static void lsa_reply_lookup_rids(prs_struct *rdata, + int num_entries, uint32 dom_rids[MAX_LOOKUP_SIDS], + char *dom_name, char *dom_sid, + char *other_sid1, char *other_sid2, char *other_sid3) +{ + LSA_R_LOOKUP_RIDS r_l; + + /* set up the LSA Lookup RIDs response */ + make_reply_lookup_rids(&r_l, num_entries, dom_rids, + dom_name, dom_sid, other_sid1, other_sid2, other_sid3); + r_l.status = 0x0; + + /* store the response in the SMB stream */ + lsa_io_r_lookup_rids("", &r_l, rdata, 0); +} + +/*************************************************************************** +api_lsa_open_policy + ***************************************************************************/ +static void api_lsa_open_policy( int uid, prs_struct *data, + prs_struct *rdata ) +{ + LSA_Q_OPEN_POL q_o; + + /* grab the server, object attributes and desired access flag...*/ + lsa_io_q_open_pol("", &q_o, data, 0); + + /* lkclXXXX having decoded it, ignore all fields in the open policy! */ + + /* return a 20 byte policy handle */ + lsa_reply_open_policy(rdata); +} + +/*************************************************************************** +api_lsa_enum_trust_dom + ***************************************************************************/ +static void api_lsa_enum_trust_dom( int uid, prs_struct *data, + prs_struct *rdata ) +{ + LSA_Q_ENUM_TRUST_DOM q_e; + + /* grab the enum trust domain context etc. */ + lsa_io_q_enum_trust_dom("", &q_e, data, 0); + + /* construct reply. return status is always 0x0 */ + lsa_reply_enum_trust_dom(&q_e, rdata, + 0, NULL, NULL); +} + +/*************************************************************************** +api_lsa_query_info + ***************************************************************************/ +static void api_lsa_query_info( int uid, prs_struct *data, + prs_struct *rdata ) +{ + LSA_Q_QUERY_INFO q_i; + pstring dom_name; + pstring dom_sid; + + /* grab the info class and policy handle */ + lsa_io_q_query("", &q_i, data, 0); + + pstrcpy(dom_name, lp_workgroup()); + pstrcpy(dom_sid , lp_domain_sid()); + + /* construct reply. return status is always 0x0 */ + lsa_reply_query_info(&q_i, rdata, dom_name, dom_sid); +} + +/*************************************************************************** +api_lsa_lookup_sids + ***************************************************************************/ +static void api_lsa_lookup_sids( int uid, prs_struct *data, + prs_struct *rdata ) +{ + LSA_Q_LOOKUP_SIDS q_l; + pstring dom_name; + pstring dom_sid; + + /* grab the info class and policy handle */ + lsa_io_q_lookup_sids("", &q_l, data, 0); + + pstrcpy(dom_name, lp_workgroup()); + pstrcpy(dom_sid , lp_domain_sid()); + + /* construct reply. return status is always 0x0 */ + lsa_reply_lookup_sids(rdata, + q_l.sids.num_entries, q_l.sids.sid, /* SIDs */ + dom_name, dom_sid, /* domain name, domain SID */ + "S-1-1", "S-1-3", "S-1-5"); /* the three other SIDs */ +} + +/*************************************************************************** +api_lsa_lookup_names + ***************************************************************************/ +static void api_lsa_lookup_names( int uid, prs_struct *data, + prs_struct *rdata ) +{ + int i; + LSA_Q_LOOKUP_RIDS q_l; + pstring dom_name; + pstring dom_sid; + uint32 dom_rids[MAX_LOOKUP_SIDS]; + uint32 dummy_g_rid; + + /* grab the info class and policy handle */ + lsa_io_q_lookup_rids("", &q_l, data, 0); + + pstrcpy(dom_name, lp_workgroup()); + pstrcpy(dom_sid , lp_domain_sid()); + + /* convert received RIDs to strings, so we can do them. */ + for (i = 0; i < q_l.num_entries; i++) + { + char *user_name = unistr2(q_l.lookup_name[i].str.buffer); + if (!name_to_rid(user_name, &dom_rids[i], &dummy_g_rid)) + { + /* WHOOPS! we should really do something about this... */ + dom_rids[i] = 0; + } + } + + /* construct reply. return status is always 0x0 */ + lsa_reply_lookup_rids(rdata, + q_l.num_entries, dom_rids, /* text-converted SIDs */ + dom_name, dom_sid, /* domain name, domain SID */ + "S-1-1", "S-1-3", "S-1-5"); /* the three other SIDs */ +} + +/*************************************************************************** + api_lsa_close + ***************************************************************************/ +static void api_lsa_close( int uid, prs_struct *data, + prs_struct *rdata) +{ + /* XXXX this is NOT good */ + char *q = mem_data(&(rdata->data), rdata->offset); + + SIVAL(q, 0, 0); q += 4; + SIVAL(q, 0, 0); q += 4; + SIVAL(q, 0, 0); q += 4; + SIVAL(q, 0, 0); q += 4; + SIVAL(q, 0, 0); q += 4; + SIVAL(q, 0, 0); q += 4; + + rdata->offset += 24; +} + +/*************************************************************************** + api_lsa_open_secret + ***************************************************************************/ +static void api_lsa_open_secret( int uid, prs_struct *data, + prs_struct *rdata) +{ + /* XXXX this is NOT good */ + char *q = mem_data(&(rdata->data), rdata->offset); + + SIVAL(q, 0, 0); q += 4; + SIVAL(q, 0, 0); q += 4; + SIVAL(q, 0, 0); q += 4; + SIVAL(q, 0, 0); q += 4; + SIVAL(q, 0, 0); q += 4; + SIVAL(q, 0, 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND); q += 4; + + rdata->offset += 24; +} + +/*************************************************************************** + \PIPE\ntlsa commands + ***************************************************************************/ +static struct api_struct api_lsa_cmds[] = +{ + { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy }, + { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info }, + { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom }, + { "LSA_CLOSE" , LSA_CLOSE , api_lsa_close }, + { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret }, + { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids }, + { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names }, + { NULL , 0 , NULL } +}; + +/*************************************************************************** + api_ntLsarpcTNP + ***************************************************************************/ +BOOL api_ntlsa_rpc(pipes_struct *p, prs_struct *data) +{ + return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds, data); +} + diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c new file mode 100644 index 0000000000..c8eabf35b4 --- /dev/null +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -0,0 +1,316 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include "includes.h" + + +extern int DEBUGLEVEL; + +#ifndef MAX_OPEN_POLS +#define MAX_OPEN_POLS 50 +#endif + +struct reg_info +{ + /* for use by \PIPE\winreg */ + fstring name; /* name of registry key */ +}; + +struct samr_info +{ + /* for use by the \PIPE\samr policy */ + DOM_SID sid; + uint32 rid; /* relative id associated with the pol_hnd */ + uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ +}; + +static struct +{ + BOOL open; + POLICY_HND pol_hnd; + + union + { + struct samr_info samr; + struct reg_info reg; + + } dev; + +} Policy[MAX_OPEN_POLS]; + + +#define VALID_POL(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_POLS)) +#define OPEN_POL(pnum) (VALID_POL(pnum) && Policy[pnum].open) + +/**************************************************************************** + create a unique policy handle +****************************************************************************/ +void create_pol_hnd(POLICY_HND *hnd) +{ + static uint32 pol_hnd_low = 0; + static uint32 pol_hnd_high = 0; + + if (hnd == NULL) return; + + /* i severely doubt that pol_hnd_high will ever be non-zero... */ + pol_hnd_low++; + if (pol_hnd_low == 0) pol_hnd_high++; + + SIVAL(hnd->data, 0 , 0x0); /* first bit must be null */ + SIVAL(hnd->data, 4 , pol_hnd_low ); /* second bit is incrementing */ + SIVAL(hnd->data, 8 , pol_hnd_high); /* second bit is incrementing */ + SIVAL(hnd->data, 12, time(NULL)); /* something random */ + SIVAL(hnd->data, 16, getpid()); /* something more random */ +} + +/**************************************************************************** + initialise policy handle states... +****************************************************************************/ +void init_lsa_policy_hnd(void) +{ + int i; + for (i = 0; i < MAX_OPEN_POLS; i++) + { + Policy[i].open = False; + } + + return; +} + +/**************************************************************************** + find first available policy slot. creates a policy handle for you. +****************************************************************************/ +BOOL open_lsa_policy_hnd(POLICY_HND *hnd) +{ + int i; + + for (i = 0; i < MAX_OPEN_POLS; i++) + { + if (!Policy[i].open) + { + Policy[i].open = True; + + create_pol_hnd(hnd); + memcpy(&(Policy[i].pol_hnd), hnd, sizeof(*hnd)); + + DEBUG(4,("Opened policy hnd[%x] ", i)); + dump_data(4, hnd->data, sizeof(hnd->data)); + + return True; + } + } + + /* i love obscure error messages. */ +#if TERRY_PRATCHET_INTERESTING_TIMES + DEBUG(1,("+++ OUT OF CHEESE ERROR +++ REDO FROM START ... @?!*@@\n")); +#else + DEBUG(1,("ERROR - open_lsa_policy_hnd: out of Policy Handles!\n")); +#endif + + return False; +} + +/**************************************************************************** + find policy index by handle +****************************************************************************/ +int find_lsa_policy_by_hnd(POLICY_HND *hnd) +{ + int i; + + for (i = 0; i < MAX_OPEN_POLS; i++) + { + if (memcmp(&(Policy[i].pol_hnd), hnd, sizeof(*hnd)) == 0) + { + DEBUG(4,("Found policy hnd[%x] ", i)); + dump_data(4, hnd->data, sizeof(hnd->data)); + + return i; + } + } + + DEBUG(4,("Policy not found: ")); + dump_data(4, hnd->data, sizeof(hnd->data)); + + return -1; +} + +/**************************************************************************** + set samr rid +****************************************************************************/ +BOOL set_lsa_policy_samr_rid(POLICY_HND *hnd, uint32 rid) +{ + int pnum = find_lsa_policy_by_hnd(hnd); + + if (OPEN_POL(pnum)) + { + DEBUG(3,("%s Setting policy device rid=%x pnum=%x\n", + timestring(), rid, pnum)); + + Policy[pnum].dev.samr.rid = rid; + return True; + } + else + { + DEBUG(3,("%s Error setting policy rid=%x (pnum=%x)\n", + timestring(), rid, pnum)); + return False; + } +} + +/**************************************************************************** + set samr pol status. absolutely no idea what this is. +****************************************************************************/ +BOOL set_lsa_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status) +{ + int pnum = find_lsa_policy_by_hnd(hnd); + + if (OPEN_POL(pnum)) + { + DEBUG(3,("%s Setting policy status=%x pnum=%x\n", + timestring(), pol_status, pnum)); + + Policy[pnum].dev.samr.status = pol_status; + return True; + } + else + { + DEBUG(3,("%s Error setting policy status=%x (pnum=%x)\n", + timestring(), pol_status, pnum)); + return False; + } +} + +/**************************************************************************** + set samr sid +****************************************************************************/ +BOOL set_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) +{ + int pnum = find_lsa_policy_by_hnd(hnd); + + if (OPEN_POL(pnum)) + { + DEBUG(3,("%s Setting policy sid=%s pnum=%x\n", + timestring(), dom_sid_to_string(sid), pnum)); + + memcpy(&(Policy[pnum].dev.samr.sid), sid, sizeof(*sid)); + return True; + } + else + { + DEBUG(3,("%s Error setting policy sid=%s (pnum=%x)\n", + timestring(), dom_sid_to_string(sid), pnum)); + return False; + } +} + +/**************************************************************************** + set samr rid +****************************************************************************/ +uint32 get_lsa_policy_samr_rid(POLICY_HND *hnd) +{ + int pnum = find_lsa_policy_by_hnd(hnd); + + if (OPEN_POL(pnum)) + { + uint32 rid = Policy[pnum].dev.samr.rid; + DEBUG(3,("%s Getting policy device rid=%x pnum=%x\n", + timestring(), rid, pnum)); + + return rid; + } + else + { + DEBUG(3,("%s Error getting policy (pnum=%x)\n", + timestring(), pnum)); + return 0xffffffff; + } +} + +/**************************************************************************** + set reg name +****************************************************************************/ +BOOL set_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) +{ + int pnum = find_lsa_policy_by_hnd(hnd); + + if (OPEN_POL(pnum)) + { + DEBUG(3,("%s Setting policy pnum=%x name=%s\n", + timestring(), pnum, name)); + + fstrcpy(Policy[pnum].dev.reg.name, name); + return True; + } + else + { + DEBUG(3,("%s Error setting policy (pnum=%x) name=%s\n", + timestring(), pnum, name)); + return False; + } +} + +/**************************************************************************** + get reg name +****************************************************************************/ +BOOL get_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) +{ + int pnum = find_lsa_policy_by_hnd(hnd); + + if (OPEN_POL(pnum)) + { + fstrcpy(name, Policy[pnum].dev.reg.name); + + DEBUG(3,("%s Getting policy pnum=%x name=%s\n", + timestring(), pnum, name)); + + return True; + } + else + { + DEBUG(3,("%s Error getting policy (pnum=%x)\n", + timestring(), pnum)); + return False; + } +} + +/**************************************************************************** + close an lsa policy +****************************************************************************/ +BOOL close_lsa_policy_hnd(POLICY_HND *hnd) +{ + int pnum = find_lsa_policy_by_hnd(hnd); + + if (OPEN_POL(pnum)) + { + DEBUG(3,("%s Closed policy name pnum=%x\n", timestring(), pnum)); + Policy[pnum].open = False; + return True; + } + else + { + DEBUG(3,("%s Error closing policy pnum=%x\n", timestring(), pnum)); + return False; + } +} + diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c new file mode 100644 index 0000000000..94d6faa992 --- /dev/null +++ b/source3/rpc_server/srv_netlog.c @@ -0,0 +1,832 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + +extern BOOL sam_logon_in_ssb; +extern pstring samlogon_user; + + + +/************************************************************************* + make_net_r_req_chal: + *************************************************************************/ +static void make_net_r_req_chal(NET_R_REQ_CHAL *r_c, + DOM_CHAL *srv_chal, int status) +{ + DEBUG(6,("make_net_r_req_chal: %d\n", __LINE__)); + memcpy(r_c->srv_chal.data, srv_chal->data, sizeof(srv_chal->data)); + r_c->status = status; +} + +/************************************************************************* + net_reply_req_chal: + *************************************************************************/ +static void net_reply_req_chal(NET_Q_REQ_CHAL *q_c, prs_struct *rdata, + DOM_CHAL *srv_chal, uint32 srv_time) +{ + NET_R_REQ_CHAL r_c; + + DEBUG(6,("net_reply_req_chal: %d\n", __LINE__)); + + /* set up the LSA REQUEST CHALLENGE response */ + make_net_r_req_chal(&r_c, srv_chal, srv_time); + + /* store the response in the SMB stream */ + net_io_r_req_chal("", &r_c, rdata, 0); + + DEBUG(6,("net_reply_req_chal: %d\n", __LINE__)); + +} + +/************************************************************************* + net_reply_logon_ctrl2: + *************************************************************************/ +static void net_reply_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, prs_struct *rdata, + uint32 flags, uint32 pdc_status, uint32 logon_attempts, + uint32 tc_status, char *trust_domain_name) +{ + NET_R_LOGON_CTRL2 r_l; + + DEBUG(6,("net_reply_logon_ctrl2: %d\n", __LINE__)); + + /* set up the Logon Control2 response */ + make_r_logon_ctrl2(&r_l, q_l->query_level, + flags, pdc_status, logon_attempts, + tc_status, trust_domain_name); + + /* store the response in the SMB stream */ + net_io_r_logon_ctrl2("", &r_l, rdata, 0); + + DEBUG(6,("net_reply_logon_ctrl2: %d\n", __LINE__)); + +} + +/************************************************************************* + net_reply_trust_dom_list: + *************************************************************************/ +static void net_reply_trust_dom_list(NET_Q_TRUST_DOM_LIST *q_t, prs_struct *rdata, + uint32 num_trust_domains, char *trust_domain_name) +{ + NET_R_TRUST_DOM_LIST r_t; + + DEBUG(6,("net_reply_trust_dom_list: %d\n", __LINE__)); + + /* set up the Trusted Domain List response */ + make_r_trust_dom(&r_t, num_trust_domains, trust_domain_name); + + /* store the response in the SMB stream */ + net_io_r_trust_dom("", &r_t, rdata, 0); + + DEBUG(6,("net_reply_trust_dom_listlogon_ctrl2: %d\n", __LINE__)); + +} + +/************************************************************************* + make_net_r_auth_2: + *************************************************************************/ +static void make_net_r_auth_2(NET_R_AUTH_2 *r_a, + DOM_CHAL *resp_cred, NEG_FLAGS *flgs, int status) +{ + memcpy( r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); + memcpy(&(r_a->srv_flgs) , flgs , sizeof(r_a->srv_flgs)); + r_a->status = status; +} + +/************************************************************************* + net_reply_auth_2: + *************************************************************************/ +static void net_reply_auth_2(NET_Q_AUTH_2 *q_a, prs_struct *rdata, + DOM_CHAL *resp_cred, int status) +{ + NET_R_AUTH_2 r_a; + + /* set up the LSA AUTH 2 response */ + + make_net_r_auth_2(&r_a, resp_cred, &(q_a->clnt_flgs), status); + + /* store the response in the SMB stream */ + net_io_r_auth_2("", &r_a, rdata, 0); + +} + +/*********************************************************************************** + make_net_r_srv_pwset: + ***********************************************************************************/ +static void make_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, + DOM_CRED *srv_cred, int status) +{ + DEBUG(5,("make_net_r_srv_pwset: %d\n", __LINE__)); + + memcpy(&(r_s->srv_cred), srv_cred, sizeof(r_s->srv_cred)); + r_s->status = status; + + DEBUG(5,("make_net_r_srv_pwset: %d\n", __LINE__)); +} + +/************************************************************************* + net_reply_srv_pwset: + *************************************************************************/ +static void net_reply_srv_pwset(NET_Q_SRV_PWSET *q_s, prs_struct *rdata, + DOM_CRED *srv_cred, int status) +{ + NET_R_SRV_PWSET r_s; + + DEBUG(5,("net_srv_pwset: %d\n", __LINE__)); + + /* set up the LSA Server Password Set response */ + make_net_r_srv_pwset(&r_s, srv_cred, status); + + /* store the response in the SMB stream */ + net_io_r_srv_pwset("", &r_s, rdata, 0); + + DEBUG(5,("net_srv_pwset: %d\n", __LINE__)); + +} + +/************************************************************************* + net_reply_sam_logon: + *************************************************************************/ +static void net_reply_sam_logon(NET_Q_SAM_LOGON *q_s, prs_struct *rdata, + DOM_CRED *srv_cred, NET_USER_INFO_3 *user_info, + uint32 status) +{ + NET_R_SAM_LOGON r_s; + + /* XXXX maybe we want to say 'no', reject the client's credentials */ + r_s.buffer_creds = 1; /* yes, we have valid server credentials */ + memcpy(&(r_s.srv_creds), srv_cred, sizeof(r_s.srv_creds)); + + /* store the user information, if there is any. */ + r_s.user = user_info; + if (status == 0x0 && user_info != NULL && user_info->ptr_user_info != 0) + { + r_s.switch_value = 3; /* indicates type of validation user info */ + } + else + { + r_s.switch_value = 0; /* indicates no info */ + } + + r_s.status = status; + r_s.auth_resp = 1; /* authoritative response */ + + /* store the response in the SMB stream */ + net_io_r_sam_logon("", &r_s, rdata, 0); + +} + + +/************************************************************************* + net_reply_sam_logoff: + *************************************************************************/ +static void net_reply_sam_logoff(NET_Q_SAM_LOGOFF *q_s, prs_struct *rdata, + DOM_CRED *srv_cred, + uint32 status) +{ + NET_R_SAM_LOGOFF r_s; + + /* XXXX maybe we want to say 'no', reject the client's credentials */ + r_s.buffer_creds = 1; /* yes, we have valid server credentials */ + memcpy(&(r_s.srv_creds), srv_cred, sizeof(r_s.srv_creds)); + + r_s.status = status; + + /* store the response in the SMB stream */ + net_io_r_sam_logoff("", &r_s, rdata, 0); + +} + +/****************************************************************** + gets a machine password entry. checks access rights of the host. + ******************************************************************/ +static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) +{ + struct smb_passwd *smb_pass; + + if (!allow_access(lp_domain_hostsdeny(), lp_domain_hostsallow(), + client_name(), client_addr())) + { + DEBUG(0,("get_md4pw: Workstation %s denied access to domain\n", mach_acct)); + return False; + } + + become_root(True); + smb_pass = get_smbpwd_entry(mach_acct, 0); + unbecome_root(True); + + if (smb_pass != NULL) + { + memcpy(md4pw, smb_pass->smb_nt_passwd, 16); + dump_data(5, md4pw, 16); + + return True; + } + DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); + return False; +} + +/************************************************************************* + api_net_req_chal: + *************************************************************************/ +static void api_net_req_chal( int uid, + prs_struct *data, + prs_struct *rdata) +{ + NET_Q_REQ_CHAL q_r; + uint32 status = 0x0; + + fstring mach_acct; + fstring mach_name; + + user_struct *vuser; + + DEBUG(5,("api_net_req_chal(%d): vuid %d\n", __LINE__, uid)); + + if ((vuser = get_valid_user_struct(uid)) == NULL) return; + + /* grab the challenge... */ + net_io_q_req_chal("", &q_r, data, 0); + + fstrcpy(mach_acct, unistrn2(q_r.uni_logon_clnt.buffer, + q_r.uni_logon_clnt.uni_str_len)); + + fstrcpy(mach_name, mach_acct); + strlower(mach_name); + + strcat(mach_acct, "$"); + + if (get_md4pw(vuser->dc.md4pw, mach_name, mach_acct)) + { + /* copy the client credentials */ + memcpy(vuser->dc.clnt_chal.data , q_r.clnt_chal.data, sizeof(q_r.clnt_chal.data)); + memcpy(vuser->dc.clnt_cred.challenge.data, q_r.clnt_chal.data, sizeof(q_r.clnt_chal.data)); + + /* create a server challenge for the client */ + /* PAXX: set these to random values. */ + /* lkcl: paul, you mentioned that it doesn't really matter much */ + SIVAL(vuser->dc.srv_chal.data, 0, 0x11111111); + SIVAL(vuser->dc.srv_chal.data, 4, 0x11111111); + memcpy(vuser->dc.srv_cred.challenge.data, vuser->dc.srv_chal.data, 8); + + bzero(vuser->dc.sess_key, sizeof(vuser->dc.sess_key)); + + /* from client / server challenges and md4 password, generate sess key */ + cred_session_key(&(vuser->dc.clnt_chal), &(vuser->dc.srv_chal), + vuser->dc.md4pw, vuser->dc.sess_key); + } + else + { + /* lkclXXXX take a guess at a good error message to return :-) */ + status = 0xC0000000 | NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT; + } + + /* construct reply. */ + net_reply_req_chal(&q_r, rdata, + &(vuser->dc.srv_chal), status); + +} + +/************************************************************************* + api_net_auth_2: + *************************************************************************/ +static void api_net_auth_2( int uid, + prs_struct *data, + prs_struct *rdata) +{ + NET_Q_AUTH_2 q_a; + uint32 status = 0x0; + + DOM_CHAL srv_cred; + UTIME srv_time; + + user_struct *vuser; + + if ((vuser = get_valid_user_struct(uid)) == NULL) return; + + srv_time.time = 0; + + /* grab the challenge... */ + net_io_q_auth_2("", &q_a, data, 0); + + /* check that the client credentials are valid */ + if (cred_assert(&(q_a.clnt_chal), vuser->dc.sess_key, + &(vuser->dc.clnt_cred.challenge), srv_time)) + { + + /* create server challenge for inclusion in the reply */ + cred_create(vuser->dc.sess_key, &(vuser->dc.srv_cred.challenge), srv_time, &srv_cred); + + /* copy the received client credentials for use next time */ + memcpy(vuser->dc.clnt_cred.challenge.data, &(q_a.clnt_chal.data), sizeof(q_a.clnt_chal.data)); + memcpy(vuser->dc.srv_cred.challenge.data, &(q_a.clnt_chal.data), sizeof(q_a.clnt_chal.data)); + } + else + { + status = NT_STATUS_ACCESS_DENIED | 0xC0000000; + } + + /* construct reply. */ + net_reply_auth_2(&q_a, rdata, &srv_cred, status); +} + + +/************************************************************************* + api_net_srv_pwset: + *************************************************************************/ +static void api_net_srv_pwset( int uid, + prs_struct *data, + prs_struct *rdata) +{ + NET_Q_SRV_PWSET q_a; + uint32 status = NT_STATUS_WRONG_PASSWORD|0xC0000000; + DOM_CRED srv_cred; +#ifdef ALLOW_SRV_PWSET + pstring mach_acct; + struct smb_passwd *smb_pass; + BOOL ret; +#endif + user_struct *vuser; + + if ((vuser = get_valid_user_struct(uid)) == NULL) return; + + /* grab the challenge and encrypted password ... */ + net_io_q_srv_pwset("", &q_a, data, 0); + + /* checks and updates credentials. creates reply credentials */ + if (deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), + &(q_a.clnt_id.cred), &srv_cred)) + { + memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); + + DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); + +#ifdef ALLOW_SRV_PWSET + + pstrcpy(mach_acct, unistrn2(q_a.clnt_id.login.uni_acct_name.buffer, + q_a.clnt_id.login.uni_acct_name.uni_str_len)); + + DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); + + become_root(True); + smb_pass = get_smbpwd_entry(mach_acct, 0); + unbecome_root(True); + + if (smb_pass != NULL) + { + unsigned char pwd[16]; + uint8 mode = 2; + + memcpy(pwd, q_a.pwd, 16); + + if (obfuscate_pwd(pwd, vuser->dc.sess_key, mode)) + { + /* 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; + + become_root(True); + ret = mod_smbpwd_entry(smb_pass); + unbecome_root(True); + + if (ret) + { + /* hooray! */ + status = 0x0; + } + } + } + + DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); +#else + DEBUG(5,("api_net_srv_pwset: server password set being denied\n")); +#endif + + } + else + { + /* lkclXXXX take a guess at a sensible error code to return... */ + status = 0xC0000000 | NT_STATUS_NETWORK_CREDENTIAL_CONFLICT; + } + + /* construct reply. always indicate failure. nt keeps going... */ + net_reply_srv_pwset(&q_a, rdata, + &srv_cred, status); +} + + +/************************************************************************* + api_net_sam_logoff: + *************************************************************************/ +static void api_net_sam_logoff( int uid, + prs_struct *data, + prs_struct *rdata) +{ + NET_Q_SAM_LOGOFF q_l; + NET_ID_INFO_CTR ctr; + + DOM_CRED srv_cred; + + user_struct *vuser; + + if ((vuser = get_valid_user_struct(uid)) == NULL) return; + + /* the DOM_ID_INFO_1 structure is a bit big. plus we might want to + dynamically allocate it inside net_io_q_sam_logon, at some point */ + q_l.sam_id.ctr = &ctr; + + /* grab the challenge... */ + net_io_q_sam_logoff("", &q_l, data, 0); + + /* checks and updates credentials. creates reply credentials */ + deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), + &(q_l.sam_id.client.cred), &srv_cred); + memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); + + /* construct reply. always indicate success */ + net_reply_sam_logoff(&q_l, rdata, + &srv_cred, + 0x0); +} + +/************************************************************************* + net_login_interactive: + *************************************************************************/ +static uint32 net_login_interactive(NET_ID_INFO_1 *id1, + struct smb_passwd *smb_pass, + user_struct *vuser) +{ + uint32 status = 0x0; + +#ifdef USE_ARCFOUR + extern void arcfour(uint8 key[16], uint8 out[16], uint8 in[16]); + char nt_pwd[16]; + char lm_pwd[16]; + unsigned char arc4_key[16]; + memset(arc4_key, 0, 16); + memcpy(arc4_key, vuser->dc.sess_key, 8); + + arcfour(arc4_key, lm_pwd, id1->arc4_lm_owf.data); + arcfour(arc4_key, nt_pwd, id1->arc4_nt_owf.data); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("arcfour decrypt of lm owf password:")); + dump_data(100, lm_pwd, 16); + + DEBUG(100,("arcfour decrypt of nt owf password:")); + 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 = 0xC0000000 | NT_STATUS_WRONG_PASSWORD; + } +#else +/* sorry. have to assume that the password is always ok. + this _is_ ok, because the LSA SAM Logon is nothing to do + with SMB connections to shares. + */ +DEBUG(3,("SAM Logon. Password not being checked\n")); +#endif + + return status; +} + +/************************************************************************* + net_login_network: + *************************************************************************/ +static uint32 net_login_network(NET_ID_INFO_2 *id2, + struct smb_passwd *smb_pass, + user_struct *vuser) +{ + if ((id2->lm_chal_resp.str_str_len == 24 || + id2->lm_chal_resp.str_str_len == 0) && + id2->nt_chal_resp.str_str_len == 24 && + (((smb_pass->smb_nt_passwd != NULL) && + smb_password_check(id2->nt_chal_resp.buffer, smb_pass->smb_nt_passwd, + id2->lm_chal)) || + smb_password_check(id2->lm_chal_resp.buffer, smb_pass->smb_passwd, + id2->lm_chal))) + { + return 0x0; + } + return 0xC0000000 | NT_STATUS_WRONG_PASSWORD; +} + +/************************************************************************* + api_net_sam_logon: + *************************************************************************/ +static void api_net_sam_logon( int uid, + prs_struct *data, + prs_struct *rdata) +{ + NET_Q_SAM_LOGON q_l; + NET_ID_INFO_CTR ctr; + NET_USER_INFO_3 usr_info; + uint32 status = 0x0; + DOM_CRED srv_cred; + struct smb_passwd *smb_pass = NULL; + UNISTR2 *uni_samlogon_user = NULL; + + user_struct *vuser = NULL; + + if ((vuser = get_valid_user_struct(uid)) == NULL) return; + + q_l.sam_id.ctr = &ctr; + + net_io_q_sam_logon("", &q_l, data, 0); + + /* checks and updates credentials. creates reply credentials */ + if (!deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), + &(q_l.sam_id.client.cred), &srv_cred)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + else + { + memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); + } + + /* find the username */ + + if (status == 0x0) + { + switch (q_l.sam_id.logon_level) + { + case 1: + { + uni_samlogon_user = &(q_l.sam_id.ctr->auth.id1.uni_user_name); + pstrcpy(samlogon_user, unistrn2(uni_samlogon_user->buffer, + uni_samlogon_user->uni_str_len)); + + DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. User:[%s]\n", + lp_workgroup(), samlogon_user)); + break; + } + case 2: + { + uni_samlogon_user = &(q_l.sam_id.ctr->auth.id2.uni_user_name); + pstrcpy(samlogon_user, unistrn2(uni_samlogon_user->buffer, + uni_samlogon_user->uni_str_len)); + + DEBUG(3,("SAM Logon (Network). Domain:[%s]. User:[%s]\n", + lp_workgroup(), samlogon_user)); + break; + } + default: + { + DEBUG(2,("SAM Logon: unsupported switch value\n")); + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + break; + } + } + } + + /* check username exists */ + + if (status == 0x0) + { + pstrcpy(samlogon_user, unistrn2(uni_samlogon_user->buffer, + uni_samlogon_user->uni_str_len)); + + become_root(True); + smb_pass = get_smbpwd_entry(samlogon_user, 0); + unbecome_root(True); + + if (smb_pass == NULL) + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + } + } + + /* validate password. */ + + if (status == 0x0) + { + switch (q_l.sam_id.logon_level) + { + case 1: + { + /* interactive login. passwords arcfour'd with session key */ + status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, + smb_pass, vuser); + break; + } + case 2: + { + /* network login. lm challenge and 24 byte responses */ + status = net_login_network(&q_l.sam_id.ctr->auth.id2, + smb_pass, vuser); + break; + } + } + } + + /* 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 :-) */ + + if (status == 0x0) + { + DOM_GID gids[LSA_MAX_GROUPS]; + int num_gids = 0; + NTTIME dummy_time; + pstring logon_script; + pstring profile_path; + pstring home_dir; + pstring home_drive; + pstring my_name; + pstring my_workgroup; + pstring domain_groups; + pstring dom_sid; + pstring other_sids; + extern pstring myname; + 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; + + get_myname(myname, NULL); + + /* 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(logon_script, lp_logon_script ()); + pstrcpy(profile_path, lp_logon_path ()); + pstrcpy(dom_sid , lp_domain_sid ()); + pstrcpy(other_sids , lp_domain_other_sids()); + pstrcpy(my_workgroup, lp_workgroup ()); + + pstrcpy(home_drive , lp_logon_drive ()); + pstrcpy(home_dir , lp_logon_home ()); + + pstrcpy(my_name , myname ); + strupper(my_name); + + get_domain_user_groups(domain_groups, samlogon_user); + + num_gids = make_dom_gids(domain_groups, gids); + + sam_logon_in_ssb = False; + + if (name_to_rid(samlogon_user, &r_uid, &r_gid)) + { + make_net_user_info3(&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 */ + + samlogon_user , /* user_name */ + vuser->real_name, /* full_name */ + logon_script , /* logon_script */ + profile_path , /* profile_path */ + home_dir , /* home_dir */ + home_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 */ + + dom_sid, /* char *dom_sid */ + other_sids); /* char *other_sids */ + } + else + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + } + } + + net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status); +} + + +/************************************************************************* + api_net_trust_dom_list: + *************************************************************************/ +static void api_net_trust_dom_list( int uid, + prs_struct *data, + prs_struct *rdata) +{ + NET_Q_TRUST_DOM_LIST q_t; + + char *trusted_domain = "test_domain"; + + DEBUG(6,("api_net_trust_dom_list: %d\n", __LINE__)); + + /* grab the lsa trusted domain list query... */ + net_io_q_trust_dom("", &q_t, data, 0); + + /* construct reply. */ + net_reply_trust_dom_list(&q_t, rdata, + 1, trusted_domain); + + DEBUG(6,("api_net_trust_dom_list: %d\n", __LINE__)); +} + + +/************************************************************************* + error messages cropping up when using nltest.exe... + *************************************************************************/ +#define ERROR_NO_SUCH_DOMAIN 0x54b +#define ERROR_NO_LOGON_SERVERS 0x51f + +/************************************************************************* + api_net_logon_ctrl2: + *************************************************************************/ +static void api_net_logon_ctrl2( int uid, + prs_struct *data, + prs_struct *rdata) +{ + NET_Q_LOGON_CTRL2 q_l; + + /* lkclXXXX - guess what - absolutely no idea what these are! */ + uint32 flags = 0x0; + uint32 pdc_connection_status = 0x0; + uint32 logon_attempts = 0x0; + uint32 tc_status = ERROR_NO_LOGON_SERVERS; + char *trusted_domain = "test_domain"; + + DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__)); + + /* grab the lsa netlogon ctrl2 query... */ + net_io_q_logon_ctrl2("", &q_l, data, 0); + + /* construct reply. */ + net_reply_logon_ctrl2(&q_l, rdata, + flags, pdc_connection_status, logon_attempts, + tc_status, trusted_domain); + + DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__)); +} + +/******************************************************************* + array of \PIPE\NETLOGON operations + ********************************************************************/ +static struct api_struct api_net_cmds [] = +{ + { "NET_REQCHAL" , NET_REQCHAL , api_net_req_chal }, + { "NET_AUTH2" , NET_AUTH2 , api_net_auth_2 }, + { "NET_SRVPWSET" , NET_SRVPWSET , api_net_srv_pwset }, + { "NET_SAMLOGON" , NET_SAMLOGON , api_net_sam_logon }, + { "NET_SAMLOGOFF" , NET_SAMLOGOFF , api_net_sam_logoff }, + { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 }, + { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, + { NULL , 0 , NULL } +}; + +/******************************************************************* + receives a netlogon pipe and responds. + ********************************************************************/ +BOOL api_netlog_rpc(pipes_struct *p, prs_struct *data) +{ + return api_rpcTNP(p, "api_netlog_rpc", api_net_cmds, data); +} diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c new file mode 100644 index 0000000000..e4893fee89 --- /dev/null +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -0,0 +1,315 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include "includes.h" + + +#define PIPE "\\PIPE\\" +#define PIPELEN strlen(PIPE) + +extern int DEBUGLEVEL; +static int chain_pnum = -1; + +#ifndef MAX_OPEN_PIPES +#define MAX_OPEN_PIPES 50 +#endif + +#define PIPE_HANDLE_OFFSET 0x800 + +pipes_struct Pipes[MAX_OPEN_PIPES]; + +#define P_OPEN(p) ((p)->open) +#define P_OK(p,c) (P_OPEN(p) && (c)==((p)->cnum)) +#define VALID_PNUM(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PIPES)) +#define OPEN_PNUM(pnum) (VALID_PNUM(pnum) && P_OPEN(&(Pipes[pnum]))) +#define PNUM_OK(pnum,c) (OPEN_PNUM(pnum) && (c)==Pipes[pnum].cnum) + + +/**************************************************************************** + reset pipe chain handle number +****************************************************************************/ +void reset_chain_pnum(void) +{ + chain_pnum = -1; +} + +/**************************************************************************** + sets chain pipe-file handle +****************************************************************************/ +void set_chain_pnum(int new_pnum) +{ + chain_pnum = new_pnum; +} + +/**************************************************************************** + initialise pipe handle states... +****************************************************************************/ +void init_rpc_pipe_hnd(void) +{ + int i; + /* we start at 1 here for an obscure reason I can't now remember, + but I think is important :-) */ + for (i = 1; i < MAX_OPEN_PIPES; i++) + { + Pipes[i].open = False; + Pipes[i].name[0] = 0; + Pipes[i].pipe_srv_name[0] = 0; + + Pipes[i].rhdr.data = NULL; + Pipes[i].rdata.data = NULL; + Pipes[i].rhdr.offset = 0; + Pipes[i].rdata.offset = 0; + + Pipes[i].max_rdata_len = 0; + Pipes[i].hdr_offsets = 0; + } + + return; +} + +/**************************************************************************** + find first available file slot +****************************************************************************/ +int open_rpc_pipe_hnd(char *pipe_name, int cnum, uint16 vuid) +{ + int i; + /* we start at 1 here for an obscure reason I can't now remember, + but I think is important :-) */ + for (i = 1; i < MAX_OPEN_PIPES; i++) + { + if (!Pipes[i].open) + { + Pipes[i].open = True; + Pipes[i].device_state = 0; + Pipes[i].cnum = cnum; + Pipes[i].uid = vuid; + + Pipes[i].rhdr.data = NULL; + Pipes[i].rdata.data = NULL; + Pipes[i].rhdr.offset = 0; + Pipes[i].rdata.offset = 0; + + Pipes[i].max_rdata_len = 0; + Pipes[i].hdr_offsets = 0; + + fstrcpy(Pipes[i].name, pipe_name); + + DEBUG(4,("Opened pipe %s with handle %x\n", + pipe_name, i + PIPE_HANDLE_OFFSET)); + + set_chain_pnum(i); + + return(i); + } + } + + DEBUG(1,("ERROR! Out of pipe structures - perhaps increase MAX_OPEN_PIPES?\n")); + + return(-1); +} + +/**************************************************************************** + reads data from a pipe. + + headers are interspersed with the data at regular intervals. by the time + this function is called, the start of the data could possibly have been + read by an SMBtrans (max_rdata_len != 0). + + calling create_rpc_request() here is a fudge. the data should already + have been prepared into arrays of headers + data stream sections. + + ****************************************************************************/ +int read_pipe(uint16 pnum, char *data, uint32 pos, int n) +{ + int data_pos = pos; + pipes_struct *p = &Pipes[pnum - PIPE_HANDLE_OFFSET]; + DEBUG(6,("read_pipe: %x", pnum)); + + if (VALID_PNUM(pnum - PIPE_HANDLE_OFFSET)) + { + DEBUG(6,("name: %s cnum: %d open: %s data_pos: %lx len: %lx", + p->name, + p->cnum, + BOOLSTR(p->open), + data_pos, n)); + } + + if (OPEN_PNUM(pnum - PIPE_HANDLE_OFFSET)) + { + int num; + int len; + uint32 rpc_frag_pos; + + DEBUG(6,("OK\n")); + + if (p->rhdr.data == NULL || p->rhdr.data->data == NULL || + p->rhdr.data->data_used == 0) + { + return 0; + } + + /* the read request starts from where the SMBtrans2 left off. */ + data_pos += p->max_rdata_len; + + /* headers accumulate an offset */ + data_pos -= p->hdr_offsets; + + len = mem_buf_len(p->rhdr.data); + num = len - (int)data_pos; + + if (num > n) num = n; + + if (!IS_BITS_SET_ALL(p->hdr.flags, RPC_FLG_LAST)) + { + rpc_frag_pos = data_pos % p->hdr.frag_len; + + if (rpc_frag_pos == 0) + { + /* create and copy in a new header. */ + create_rpc_reply(p, data_pos, p->rdata.offset); + mem_buf_copy(data, p->rhdr.data, 0, 0x18); + + /* make room in data stream for header */ + p->hdr_offsets += 0x18; + } + } + + if (num > 0) + { + mem_buf_copy(data, p->rhdr.data, data_pos, num); + return num; + } + + return 0; + + } + else + { + DEBUG(6,("NOT\n")); + return -1; + } +} + +/**************************************************************************** + gets the name of a pipe +****************************************************************************/ +BOOL get_rpc_pipe(int pnum, pipes_struct **p) +{ + DEBUG(6,("get_rpc_pipe: ")); + + /* mapping is PIPE_HANDLE_OFFSET up... */ + + if (VALID_PNUM(pnum - PIPE_HANDLE_OFFSET)) + { + DEBUG(6,("name: %s cnum: %d open: %s ", + Pipes[pnum - PIPE_HANDLE_OFFSET].name, + Pipes[pnum - PIPE_HANDLE_OFFSET].cnum, + BOOLSTR(Pipes[pnum - PIPE_HANDLE_OFFSET].open))); + } + if (OPEN_PNUM(pnum - PIPE_HANDLE_OFFSET)) + { + DEBUG(6,("OK\n")); + (*p) = &(Pipes[pnum - PIPE_HANDLE_OFFSET]); + return True; + } + else + { + DEBUG(6,("NOT\n")); + return False; + } +} + +/**************************************************************************** + gets the name of a pipe +****************************************************************************/ +char *get_rpc_pipe_hnd_name(int pnum) +{ + pipes_struct *p = NULL; + get_rpc_pipe(pnum, &p); + return p != NULL ? p->name : NULL; +} + +/**************************************************************************** + set device state on a pipe. exactly what this is for is unknown... +****************************************************************************/ +BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state) +{ + if (p == NULL) return False; + + if (P_OPEN(p)) + { + DEBUG(3,("%s Setting pipe device state=%x on pipe (name=%s cnum=%d)\n", + timestring(), device_state, p->name, p->cnum)); + + p->device_state = device_state; + + return True; + } + else + { + DEBUG(3,("%s Error setting pipe device state=%x (name=%s cnum=%d)\n", + timestring(), device_state, p->name, p->cnum)); + return False; + } +} + +/**************************************************************************** + close an rpc pipe +****************************************************************************/ +BOOL close_rpc_pipe_hnd(int pnum, int cnum) +{ + pipes_struct *p = NULL; + get_rpc_pipe(pnum, &p); + /* mapping is PIPE_HANDLE_OFFSET up... */ + + if (p != NULL && P_OK(p, cnum)) + { + DEBUG(3,("%s Closed pipe name %s pnum=%x cnum=%d\n", + timestring(),Pipes[pnum-PIPE_HANDLE_OFFSET].name, pnum,cnum)); + + p->open = False; + + p->rdata.offset = 0; + p->rhdr.offset = 0; + mem_buf_free(&(p->rdata.data)); + mem_buf_free(&(p->rhdr .data)); + + return True; + } + else + { + DEBUG(3,("%s Error closing pipe pnum=%x cnum=%d\n", + timestring(),pnum, cnum)); + return False; + } +} + +/**************************************************************************** + close an rpc pipe +****************************************************************************/ +int get_rpc_pipe_num(char *buf, int where) +{ + return (chain_pnum != -1 ? chain_pnum : SVAL(buf,where)); +} + diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c new file mode 100644 index 0000000000..fa856f6983 --- /dev/null +++ b/source3/rpc_server/srv_reg.c @@ -0,0 +1,240 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + + +/******************************************************************* + reg_reply_unknown_1 + ********************************************************************/ +static void reg_reply_close(REG_Q_CLOSE *q_r, + prs_struct *rdata) +{ + REG_R_CLOSE r_u; + + /* set up the REG unknown_1 response */ + bzero(&(r_u.pol.data), POL_HND_SIZE); + + /* close the policy handle */ + if (close_lsa_policy_hnd(&(q_r->pol))) + { + r_u.status = 0; + } + else + { + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_INVALID; + } + + DEBUG(5,("reg_unknown_1: %d\n", __LINE__)); + + /* store the response in the SMB stream */ + reg_io_r_close("", &r_u, rdata, 0); + + DEBUG(5,("reg_unknown_1: %d\n", __LINE__)); +} + +/******************************************************************* + api_reg_close + ********************************************************************/ +static void api_reg_close( int uid, prs_struct *data, + prs_struct *rdata ) +{ + REG_Q_CLOSE q_r; + + /* grab the reg unknown 1 */ + reg_io_q_close("", &q_r, data, 0); + + /* construct reply. always indicate success */ + reg_reply_close(&q_r, rdata); +} + + +/******************************************************************* + reg_reply_open + ********************************************************************/ +static void reg_reply_open(REG_Q_OPEN_POLICY *q_r, + prs_struct *rdata) +{ + REG_R_OPEN_POLICY r_u; + + r_u.status = 0x0; + /* get a (unique) handle. open a policy on it. */ + if (r_u.status == 0x0 && !open_lsa_policy_hnd(&(r_u.pol))) + { + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + DEBUG(5,("reg_open: %d\n", __LINE__)); + + /* store the response in the SMB stream */ + reg_io_r_open_policy("", &r_u, rdata, 0); + + DEBUG(5,("reg_open: %d\n", __LINE__)); +} + +/******************************************************************* + api_reg_open + ********************************************************************/ +static void api_reg_open( int uid, prs_struct *data, + prs_struct *rdata ) +{ + REG_Q_OPEN_POLICY q_u; + + /* grab the reg open */ + reg_io_q_open_policy("", &q_u, data, 0); + + /* construct reply. always indicate success */ + reg_reply_open(&q_u, rdata); +} + + +/******************************************************************* + reg_reply_open_entry + ********************************************************************/ +static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, + prs_struct *rdata) +{ + uint32 status = 0; + POLICY_HND pol; + REG_R_OPEN_ENTRY r_u; + fstring name; + + DEBUG(5,("reg_open_entry: %d\n", __LINE__)); + + if (status == 0 && find_lsa_policy_by_hnd(&(q_u->pol)) == -1) + { + status = 0xC000000 | NT_STATUS_INVALID_HANDLE; + } + + if (status == 0x0 && !open_lsa_policy_hnd(&pol)) + { + status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ + } + + fstrcpy(name, unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len)); + + if (status == 0x0) + { + DEBUG(5,("reg_open_entry: %s\n", name)); + /* lkcl XXXX do a check on the name, here */ + } + + if (status == 0x0 && !set_lsa_policy_reg_name(&pol, name)) + { + status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ + } + + make_reg_r_open_entry(&r_u, &pol, status); + + /* store the response in the SMB stream */ + reg_io_r_open_entry("", &r_u, rdata, 0); + + DEBUG(5,("reg_open_entry: %d\n", __LINE__)); +} + +/******************************************************************* + api_reg_open_entry + ********************************************************************/ +static void api_reg_open_entry( int uid, prs_struct *data, + prs_struct *rdata ) +{ + REG_Q_OPEN_ENTRY q_u; + + /* grab the reg open entry */ + reg_io_q_open_entry("", &q_u, data, 0); + + /* construct reply. */ + reg_reply_open_entry(&q_u, rdata); +} + + +/******************************************************************* + reg_reply_info + ********************************************************************/ +static void reg_reply_info(REG_Q_INFO *q_u, + prs_struct *rdata) +{ + uint32 status = 0; + + REG_R_INFO r_u; + + DEBUG(5,("reg_info: %d\n", __LINE__)); + + if (status == 0 && find_lsa_policy_by_hnd(&(q_u->pol)) == -1) + { + status = 0xC000000 | NT_STATUS_INVALID_HANDLE; + } + + if (status == 0) + { + } + + make_reg_r_info(&r_u, 1, "LanmanNT", 0x12, 0x12, status); + + /* store the response in the SMB stream */ + reg_io_r_info("", &r_u, rdata, 0); + + DEBUG(5,("reg_open_entry: %d\n", __LINE__)); +} + +/******************************************************************* + api_reg_info + ********************************************************************/ +static void api_reg_info( int uid, prs_struct *data, + prs_struct *rdata ) +{ + REG_Q_INFO q_u; + + /* grab the reg unknown 0x11*/ + reg_io_q_info("", &q_u, data, 0); + + /* construct reply. always indicate success */ + reg_reply_info(&q_u, rdata); +} + + +/******************************************************************* + array of \PIPE\reg operations + ********************************************************************/ +static struct api_struct api_reg_cmds[] = +{ + { "REG_CLOSE" , REG_CLOSE , api_reg_close }, + { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, + { "REG_OPEN" , REG_OPEN_POLICY , api_reg_open }, + { "REG_INFO" , REG_INFO , api_reg_info }, + { NULL, 0 , NULL } +}; + +/******************************************************************* + receives a reg pipe and responds. + ********************************************************************/ +BOOL api_reg_rpc(pipes_struct *p, prs_struct *data) +{ + return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds, data); +} + diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c new file mode 100644 index 0000000000..02c8cb0ffe --- /dev/null +++ b/source3/rpc_server/srv_samr.c @@ -0,0 +1,1352 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + +extern BOOL sam_logon_in_ssb; +extern pstring samlogon_user; +extern rid_name domain_group_rids[]; +extern rid_name domain_alias_rids[]; + +/******************************************************************* + This next function should be replaced with something that + dynamically returns the correct user info..... JRA. + ********************************************************************/ + +static BOOL get_smbpwd_entries(SAM_USER_INFO_21 *pw_buf, + int *total_entries, int *num_entries, + int max_num_entries, + uint16 acb_mask) +{ + FILE *fp = NULL; + struct smb_passwd *pwd = NULL; + + (*num_entries) = 0; + (*total_entries) = 0; + + if (pw_buf == NULL) return False; + + fp = startsmbpwent(False); + if (!fp) + { + DEBUG(0, ("get_smbpwd_entries: Unable to open SMB password file.\n")); + return False; + } + + while (((pwd = getsmbpwent(fp)) != NULL) && (*num_entries) < max_num_entries) + { + int user_name_len = strlen(pwd->smb_name); + make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len); + make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len, + user_name_len, 1); + pw_buf[(*num_entries)].user_rid = pwd->smb_userid; + bzero( pw_buf[(*num_entries)].nt_pwd , 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); + } + + pw_buf[(*num_entries)].acb_info = (uint16)pwd->acct_ctrl; + + DEBUG(5, ("get_smbpwd_entries: idx: %d user %s, uid %d, acb %x", + (*num_entries), pwd->smb_name, pwd->smb_userid, pwd->acct_ctrl)); + + if (acb_mask == 0 || IS_BITS_SET_SOME(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)++; + } + + endsmbpwent(fp); + + return (*num_entries) > 0; +} + +/******************************************************************* + samr_reply_unknown_1 + ********************************************************************/ +static void samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, + prs_struct *rdata) +{ + SAMR_R_CLOSE_HND r_u; + + /* set up the SAMR unknown_1 response */ + bzero(&(r_u.pol.data), POL_HND_SIZE); + + /* close the policy handle */ + if (close_lsa_policy_hnd(&(q_u->pol))) + { + r_u.status = 0; + } + else + { + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_INVALID; + } + + DEBUG(5,("samr_reply_close_hnd: %d\n", __LINE__)); + + /* store the response in the SMB stream */ + samr_io_r_close_hnd("", &r_u, rdata, 0); + + DEBUG(5,("samr_reply_close_hnd: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_close_hnd + ********************************************************************/ +static void api_samr_close_hnd( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_CLOSE_HND q_u; + + /* grab the samr unknown 1 */ + samr_io_q_close_hnd("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_close_hnd(&q_u, rdata); +} + + +/******************************************************************* + samr_reply_open_domain + ********************************************************************/ +static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, + prs_struct *rdata) +{ + SAMR_R_OPEN_DOMAIN r_u; + BOOL pol_open = False; + int pol_idx; + + r_u.status = 0x0; + + /* find the connection policy handle. */ + if (r_u.status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->connect_pol))) == -1)) + { + r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + /* get a (unique) handle. open a policy on it. */ + if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.domain_pol)))) + { + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + /* associate the domain SID with the (unique) handle. */ + if (r_u.status == 0x0 && !set_lsa_policy_samr_sid(&(r_u.domain_pol), &(q_u->dom_sid.sid))) + { + /* oh, whoops. don't know what error message to return, here */ + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + if (r_u.status != 0 && pol_open) + { + close_lsa_policy_hnd(&(r_u.domain_pol)); + } + + DEBUG(5,("samr_open_domain: %d\n", __LINE__)); + + /* store the response in the SMB stream */ + samr_io_r_open_domain("", &r_u, rdata, 0); + + DEBUG(5,("samr_open_domain: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_open_domain + ********************************************************************/ +static void api_samr_open_domain( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_OPEN_DOMAIN q_u; + + /* grab the samr open */ + samr_io_q_open_domain("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_open_domain(&q_u, rdata); +} + + +/******************************************************************* + samr_reply_unknown_3 + ********************************************************************/ +static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, + prs_struct *rdata) +{ + SAMR_R_UNKNOWN_3 r_u; + DOM_SID3 sid[MAX_SAM_SIDS]; + fstring user_sid; + fstring user_rid; + int pol_idx; + uint32 rid; + uint32 status; + + status = 0x0; + + /* find the policy handle. open a policy on it. */ + if (status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->user_pol))) == -1)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + /* find the user's rid */ + if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->user_pol))) == 0xffffffff) + { + status = NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + if (status == 0x0) + { + strcpy(user_sid, lp_domain_sid()); + sprintf(user_rid, "-%x", rid); + strcat(user_sid, user_rid); + + /* maybe need another 1 or 2 (S-1-5-20-0x220 and S-1-5-20-0x224) */ + /* these two are DOMAIN_ADMIN and DOMAIN_ACCT_OP group RIDs */ + make_dom_sid3(&(sid[0]), 0x035b, 0x0002, "S-1-1"); + make_dom_sid3(&(sid[1]), 0x0044, 0x0002, user_sid); + } + + make_samr_r_unknown_3(&r_u, + 0x0001, 0x8004, + 0x00000014, 0x0002, 0x0070, + 2, sid, status); + + DEBUG(5,("samr_unknown_3: %d\n", __LINE__)); + + /* store the response in the SMB stream */ + samr_io_r_unknown_3("", &r_u, rdata, 0); + + DEBUG(5,("samr_unknown_3: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_unknown_3 + ********************************************************************/ +static void api_samr_unknown_3( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_UNKNOWN_3 q_u; + + /* grab the samr open */ + samr_io_q_unknown_3("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_unknown_3(&q_u, rdata); +} + + +/******************************************************************* + samr_reply_enum_dom_users + ********************************************************************/ +static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, + prs_struct *rdata) +{ + SAMR_R_ENUM_DOM_USERS r_e; + SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; + int num_entries; + int total_entries; + int pol_idx; + BOOL got_pwds; + + r_e.status = 0x0; + r_e.total_num_entries = 0; + + /* find the policy handle. open a policy on it. */ + if (r_e.status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1)) + { + r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + DEBUG(5,("samr_reply_enum_dom_users: %d\n", __LINE__)); + + become_root(True); + got_pwds = get_smbpwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, q_u->acb_mask); + unbecome_root(True); + + make_samr_r_enum_dom_users(&r_e, total_entries, + q_u->unknown_0, num_entries, + pass, r_e.status); + + /* store the response in the SMB stream */ + samr_io_r_enum_dom_users("", &r_e, rdata, 0); + + DEBUG(5,("samr_enum_dom_users: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_enum_dom_users + ********************************************************************/ +static void api_samr_enum_dom_users( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_ENUM_DOM_USERS q_e; + + /* grab the samr open */ + samr_io_q_enum_dom_users("", &q_e, data, 0); + + /* construct reply. */ + samr_reply_enum_dom_users(&q_e, rdata); +} + + +/******************************************************************* + samr_reply_enum_dom_groups + ********************************************************************/ +static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, + prs_struct *rdata) +{ + SAMR_R_ENUM_DOM_GROUPS r_e; + SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; + int num_entries; + int pol_idx; + BOOL got_grps; + char *dummy_group = "Domain Admins"; + + r_e.status = 0x0; + r_e.num_entries = 0; + + /* find the policy handle. open a policy on it. */ + if (r_e.status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1)) + { + r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); + + got_grps = True; + num_entries = 1; + make_unistr2(&(pass[0].uni_user_name), dummy_group, strlen(dummy_group)); + pass[0].user_rid = DOMAIN_GROUP_RID_ADMINS; + + if (r_e.status == 0 && got_grps) + { + make_samr_r_enum_dom_groups(&r_e, q_u->start_idx, num_entries, pass, r_e.status); + } + + /* store the response in the SMB stream */ + samr_io_r_enum_dom_groups("", &r_e, rdata, 0); + + DEBUG(5,("samr_enum_dom_groups: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_enum_dom_groups + ********************************************************************/ +static void api_samr_enum_dom_groups( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_ENUM_DOM_GROUPS q_e; + + /* grab the samr open */ + samr_io_q_enum_dom_groups("", &q_e, data, 0); + + /* construct reply. */ + samr_reply_enum_dom_groups(&q_e, rdata); +} + + +/******************************************************************* + samr_reply_enum_dom_aliases + ********************************************************************/ +static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, + prs_struct *rdata) +{ + SAMR_R_ENUM_DOM_ALIASES r_e; + SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; + int num_entries; + int pol_idx; + BOOL got_aliases; + char *dummy_alias = "admins"; + + r_e.status = 0x0; + r_e.num_entries = 0; + + /* find the policy handle. open a policy on it. */ + if (r_e.status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1)) + { + r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + DEBUG(5,("samr_reply_enum_dom_aliases: %d\n", __LINE__)); + + got_aliases = True; + num_entries = 1; + make_unistr2(&(pass[0].uni_user_name), dummy_alias, strlen(dummy_alias)); + pass[0].user_rid = DOMAIN_ALIAS_RID_ADMINS; + + if (r_e.status == 0 && got_aliases) + { + make_samr_r_enum_dom_aliases(&r_e, num_entries, pass, r_e.status); + } + + /* store the response in the SMB stream */ + samr_io_r_enum_dom_aliases("", &r_e, rdata, 0); + + DEBUG(5,("samr_enum_dom_aliases: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_enum_dom_aliases + ********************************************************************/ +static void api_samr_enum_dom_aliases( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_ENUM_DOM_ALIASES q_e; + + /* grab the samr open */ + samr_io_q_enum_dom_aliases("", &q_e, data, 0); + + /* construct reply. */ + samr_reply_enum_dom_aliases(&q_e, rdata); +} + + +/******************************************************************* + samr_reply_query_dispinfo + ********************************************************************/ +static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, + prs_struct *rdata) +{ + SAMR_R_QUERY_DISPINFO r_e; + SAM_INFO_CTR ctr; + SAM_INFO_1 info1; + SAM_INFO_2 info2; + SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; + int num_entries; + int total_entries; + int pol_idx; + BOOL got_pwds; + uint16 switch_level = 0x0; + + r_e.status = 0x0; + + /* find the policy handle. open a policy on it. */ + if (r_e.status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1)) + { + r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + DEBUG(5,("samr_reply_query_dispinfo: %d\n", __LINE__)); + + become_root(True); + + got_pwds = get_smbpwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); + + unbecome_root(True); + + switch (q_u->switch_level) + { + case 0x1: + { + /* query disp info is for users */ + make_sam_info_1(&info1, ACB_NORMAL, + q_u->start_idx, num_entries, pass); + + ctr.sam.info1 = &info1; + switch_level = 0x1; + + break; + } + case 0x2: + { + /* query disp info is for servers */ + make_sam_info_2(&info2, ACB_WSTRUST, + q_u->start_idx, num_entries, pass); + + ctr.sam.info2 = &info2; + switch_level = 0x2; + + break; + } + } + + if (r_e.status == 0 && got_pwds) + { + make_samr_r_query_dispinfo(&r_e, switch_level, &ctr, r_e.status); + } + + /* store the response in the SMB stream */ + samr_io_r_query_dispinfo("", &r_e, rdata, 0); + + DEBUG(5,("samr_query_dispinfo: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_query_dispinfo + ********************************************************************/ +static void api_samr_query_dispinfo( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_QUERY_DISPINFO q_e; + + /* grab the samr open */ + samr_io_q_query_dispinfo("", &q_e, data, 0); + + /* construct reply. */ + samr_reply_query_dispinfo(&q_e, rdata); +} + + +/******************************************************************* + samr_reply_query_aliasinfo + ********************************************************************/ +static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, + prs_struct *rdata) +{ + SAMR_R_QUERY_ALIASINFO r_e; + int pol_idx; + BOOL got_alias; + + r_e.status = 0x0; + r_e.ptr = 0; + + /* find the policy handle. open a policy on it. */ + if (r_e.status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1)) + { + r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + DEBUG(5,("samr_reply_query_aliasinfo: %d\n", __LINE__)); + + if (r_e.status == 0x0) + { + if (q_u->switch_level != 3) + { + r_e.status = NT_STATUS_INVALID_INFO_CLASS; + } + } + + if (r_e.status == 0x0) + { + got_alias = True; + } + + make_samr_r_query_aliasinfo(&r_e, q_u->switch_level, + "", + r_e.status); + + /* store the response in the SMB stream */ + samr_io_r_query_aliasinfo("", &r_e, rdata, 0); + + DEBUG(5,("samr_query_aliasinfo: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_query_aliasinfo + ********************************************************************/ +static void api_samr_query_aliasinfo( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_QUERY_ALIASINFO q_e; + + /* grab the samr open */ + samr_io_q_query_aliasinfo("", &q_e, data, 0); + + /* construct reply. */ + samr_reply_query_aliasinfo(&q_e, rdata); +} + + +/******************************************************************* + samr_reply_lookup_ids + ********************************************************************/ +static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, + prs_struct *rdata) +{ + uint32 rid[MAX_SAM_ENTRIES]; + uint32 status = 0; + int num_rids = q_u->num_sids1; + + SAMR_R_LOOKUP_IDS r_u; + + DEBUG(5,("samr_lookup_ids: %d\n", __LINE__)); + + if (num_rids > MAX_SAM_ENTRIES) + { + num_rids = MAX_SAM_ENTRIES; + DEBUG(5,("samr_lookup_ids: truncating entries to %d\n", num_rids)); + } + +#if 0 + int i; + for (i = 0; i < num_rids && status == 0; i++) + { + struct smb_passwd *smb_pass; + fstring user_name; + + fstrcpy(user_name, unistrn2(q_u->uni_user_name[i].buffer, + q_u->uni_user_name[i].uni_str_len)); + + /* find the user account */ + become_root(True); + smb_pass = get_smbpwd_entry(user_name, 0); + unbecome_root(True); + + if (smb_pass == NULL) + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + rid[i] = 0; + } + else + { + /* lkclXXXX SHOULD use name_to_rid() here! */ + rid[i] = smb_pass->smb_userid; + } + } +#endif + + num_rids = 1; + rid[0] = DOMAIN_ALIAS_RID_USERS; + + make_samr_r_lookup_ids(&r_u, num_rids, rid, status); + + /* store the response in the SMB stream */ + samr_io_r_lookup_ids("", &r_u, rdata, 0); + + DEBUG(5,("samr_lookup_ids: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_lookup_ids + ********************************************************************/ +static void api_samr_lookup_ids( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_LOOKUP_IDS q_u; + + /* grab the samr 0x10 */ + samr_io_q_lookup_ids("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_lookup_ids(&q_u, rdata); +} + +/******************************************************************* + samr_reply_lookup_names + ********************************************************************/ +static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, + prs_struct *rdata) +{ + uint32 rid[MAX_SAM_ENTRIES]; + uint32 status = 0; + int i; + int num_rids = q_u->num_rids1; + + SAMR_R_LOOKUP_NAMES r_u; + + DEBUG(5,("samr_lookup_names: %d\n", __LINE__)); + + if (num_rids > MAX_SAM_ENTRIES) + { + num_rids = MAX_SAM_ENTRIES; + DEBUG(5,("samr_lookup_names: truncating entries to %d\n", num_rids)); + } + + for (i = 0; i < num_rids && status == 0; i++) + { + fstring name; + + status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + + fstrcpy(name, unistrn2(q_u->uni_user_name[i].buffer, q_u->uni_user_name[i].uni_str_len)); + + status = (status != 0x0) ? lookup_user_rid (name, &(rid[i])) : status; + status = (status != 0x0) ? lookup_group_rid(name, &(rid[i])) : status; + status = (status != 0x0) ? lookup_alias_rid(name, &(rid[i])) : status; + } + + make_samr_r_lookup_names(&r_u, num_rids, rid, status); + + /* store the response in the SMB stream */ + samr_io_r_lookup_names("", &r_u, rdata, 0); + + DEBUG(5,("samr_lookup_names: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_lookup_names + ********************************************************************/ +static void api_samr_lookup_names( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_LOOKUP_NAMES q_u; + + /* grab the samr lookup names */ + samr_io_q_lookup_names("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_lookup_names(&q_u, rdata); +} + + +/******************************************************************* + samr_reply_unknown_12 + ********************************************************************/ +static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, + prs_struct *rdata) +{ + fstring group_names[MAX_SAM_ENTRIES]; + uint32 group_attrs[MAX_SAM_ENTRIES]; + uint32 status = 0; + int num_gids = q_u->num_gids1; + uint32 pol_idx; + + SAMR_R_UNKNOWN_12 r_u; + + DEBUG(5,("samr_unknown_12: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + if (status == 0x0) + { + int i; + if (num_gids > MAX_SAM_ENTRIES) + { + num_gids = MAX_SAM_ENTRIES; + DEBUG(5,("samr_unknown_12: truncating entries to %d\n", num_gids)); + } + + for (i = 0; i < num_gids && status == 0; i++) + { + fstrcpy(group_names[i], "dummy group"); + group_attrs[i] = 0x2; + } + } + + make_samr_r_unknown_12(&r_u, num_gids, group_names, group_attrs, status); + + /* store the response in the SMB stream */ + samr_io_r_unknown_12("", &r_u, rdata, 0); + + DEBUG(5,("samr_unknown_12: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_unknown_12 + ********************************************************************/ +static void api_samr_unknown_12( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_UNKNOWN_12 q_u; + + /* grab the samr lookup names */ + samr_io_q_unknown_12("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_unknown_12(&q_u, rdata); +} + + +/******************************************************************* + samr_reply_open_user + ********************************************************************/ +static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, + prs_struct *rdata, + int status) +{ + SAMR_R_OPEN_USER r_u; + struct smb_passwd *smb_pass; + int pol_idx; + BOOL pol_open = False; + + /* set up the SAMR open_user response */ + bzero(&(r_u.user_pol.data), POL_HND_SIZE); + + r_u.status = 0x0; + + /* find the policy handle. open a policy on it. */ + if (r_u.status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->domain_pol))) == -1)) + { + r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + /* get a (unique) handle. open a policy on it. */ + if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.user_pol)))) + { + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + become_root(True); + smb_pass = get_smbpwd_entry(NULL, q_u->user_rid); + unbecome_root(True); + + /* check that the RID exists in our domain. */ + if (r_u.status == 0x0 && smb_pass == NULL) + { + r_u.status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + } + + /* associate the RID with the (unique) handle. */ + if (r_u.status == 0x0 && !set_lsa_policy_samr_rid(&(r_u.user_pol), q_u->user_rid)) + { + /* oh, whoops. don't know what error message to return, here */ + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + if (r_u.status != 0 && pol_open) + { + close_lsa_policy_hnd(&(r_u.user_pol)); + } + + DEBUG(5,("samr_open_user: %d\n", __LINE__)); + + /* store the response in the SMB stream */ + samr_io_r_open_user("", &r_u, rdata, 0); + + DEBUG(5,("samr_open_user: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_open_user + ********************************************************************/ +static void api_samr_open_user( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_OPEN_USER q_u; + + /* grab the samr unknown 22 */ + samr_io_q_open_user("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_open_user(&q_u, rdata, 0x0); +} + + +/************************************************************************* + get_user_info_21 + *************************************************************************/ +static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) +{ + NTTIME dummy_time; + + pstring logon_script; + pstring profile_path; + pstring home_drive; + pstring home_dir; + pstring description; + pstring workstations; + pstring full_name; + pstring munged_dialin; + pstring unknown_str; + + uint32 r_uid; + uint32 r_gid; + + LOGON_HRS hrs; + int i; + + struct smb_passwd *smb_pass; + + become_root(True); + smb_pass = get_smbpwd_entry(NULL, rid); + unbecome_root(True); + + if (smb_pass == NULL) + { + return False; + } + + DEBUG(3,("User:[%s]\n", smb_pass->smb_name)); + + dummy_time.low = 0xffffffff; + dummy_time.high = 0x7fffffff; + + pstrcpy(samlogon_user, smb_pass->smb_name); + + if (samlogon_user[strlen(samlogon_user)-1] != '$') + { + if (!name_to_rid(samlogon_user, &r_uid, &r_gid)) + { + return False; + } + + /* 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(full_name , ""); + pstrcpy(logon_script , lp_logon_script ()); + pstrcpy(profile_path , lp_logon_path ()); + pstrcpy(home_drive , lp_logon_drive ()); + pstrcpy(home_dir , lp_logon_home ()); + pstrcpy(description , ""); + pstrcpy(workstations , ""); + pstrcpy(unknown_str , ""); + pstrcpy(munged_dialin, ""); + + sam_logon_in_ssb = False; + } + else + { + r_uid = smb_pass->smb_userid; + r_gid = DOMAIN_GROUP_RID_USERS; + + pstrcpy(samlogon_user, smb_pass->smb_name); + + pstrcpy(full_name , ""); + pstrcpy(logon_script , ""); + pstrcpy(profile_path , ""); + pstrcpy(home_drive , ""); + pstrcpy(home_dir , ""); + pstrcpy(description , ""); + pstrcpy(workstations , ""); + pstrcpy(unknown_str , ""); + pstrcpy(munged_dialin, ""); + } + + hrs.len = 21; + for (i = 0; i < hrs.len; i++) + { + hrs.hours[i] = 0xff; + } + make_sam_user_info21(id21, + + &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 */ + + samlogon_user, /* user_name */ + full_name, /* full_name */ + home_dir, /* home_dir */ + home_drive, /* dir_drive */ + logon_script, /* logon_script */ + profile_path, /* profile_path */ + description, /* description */ + workstations, /* workstations user can log in from */ + unknown_str, /* don't know, yet */ + munged_dialin, /* dialin info. contains dialin path and tel no */ + + r_uid, /* RID user_id */ + r_gid, /* RID group_id */ + smb_pass->acct_ctrl, + + 0x00ffffff, /* unknown_3 */ + 168, /* divisions per week */ + &hrs, /* logon hours */ + 0x00020000, + 0x000004ec); + + return True; +} + +/******************************************************************* + samr_reply_query_userinfo + ********************************************************************/ +static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, + prs_struct *rdata) +{ + SAMR_R_QUERY_USERINFO r_u; +#if 0 + SAM_USER_INFO_11 id11; +#endif + SAM_USER_INFO_21 id21; + void *info = NULL; + + uint32 status = 0x0; + uint32 rid; + int obj_idx; + + DEBUG(5,("samr_reply_query_userinfo: %d\n", __LINE__)); + + /* search for the handle */ + if (status == 0x0 && (obj_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1) + { + status = NT_STATUS_INVALID_HANDLE; + } + + /* find the user's rid */ + if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->pol))) == 0xffffffff) + { + status = NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + /* ok! user info levels (there are lots: see MSDEV help), off we go... */ + if (status == 0x0) + { + switch (q_u->switch_value) + { +#if 0 +/* whoops - got this wrong. i think. or don't understand what's happening. */ + case 0x11: + { + NTTIME expire; + info = (void*)&id11; + + expire.low = 0xffffffff; + expire.high = 0x7fffffff; + + make_sam_user_info11(&id11, &expire, "BROOKFIELDS$", 0x03ef, 0x201, 0x0080); + + break; + } +#endif + case 21: + { + info = (void*)&id21; + status = get_user_info_21(&id21, rid) ? 0 : NT_STATUS_NO_SUCH_USER; + + break; + } + + default: + { + status = NT_STATUS_INVALID_INFO_CLASS; + + break; + } + } + } + + make_samr_r_query_userinfo(&r_u, q_u->switch_value, info, status); + + /* store the response in the SMB stream */ + samr_io_r_query_userinfo("", &r_u, rdata, 0); + + DEBUG(5,("samr_reply_query_userinfo: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_query_userinfo + ********************************************************************/ +static void api_samr_query_userinfo( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_QUERY_USERINFO q_u; + + /* grab the samr unknown 24 */ + samr_io_q_query_userinfo("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_query_userinfo(&q_u, rdata); +} + + +/******************************************************************* + samr_reply_query_usergroups + ********************************************************************/ +static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, + prs_struct *rdata) +{ + SAMR_R_QUERY_USERGROUPS r_u; + uint32 status = 0x0; + + struct smb_passwd *smb_pass; + DOM_GID gids[LSA_MAX_GROUPS]; + int num_groups = 0; + int pol_idx; + uint32 rid; + + DEBUG(5,("samr_query_usergroups: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + /* find the user's rid */ + if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->pol))) == 0xffffffff) + { + status = NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + if (status == 0x0) + { + become_root(True); + smb_pass = get_smbpwd_entry(NULL, rid); + unbecome_root(True); + + if (smb_pass == NULL) + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + } + } + + if (status == 0x0) + { + pstring groups; + get_domain_user_groups(groups, smb_pass->smb_name); + num_groups = make_dom_gids(groups, gids); + } + + /* construct the response. lkclXXXX: gids are not copied! */ + make_samr_r_query_usergroups(&r_u, num_groups, gids, status); + + /* store the response in the SMB stream */ + samr_io_r_query_usergroups("", &r_u, rdata, 0); + + DEBUG(5,("samr_query_usergroups: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_query_usergroups + ********************************************************************/ +static void api_samr_query_usergroups( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_QUERY_USERGROUPS q_u; + /* grab the samr unknown 32 */ + samr_io_q_query_usergroups("", &q_u, data, 0); + + /* construct reply. */ + samr_reply_query_usergroups(&q_u, rdata); +} + + +/******************************************************************* + samr_reply_unknown_32 + ********************************************************************/ +static void samr_reply_unknown_32(SAMR_Q_UNKNOWN_32 *q_u, + prs_struct *rdata, + int status) +{ + int i; + SAMR_R_UNKNOWN_32 r_u; + + /* set up the SAMR unknown_32 response */ + bzero(&(r_u.pol.data), POL_HND_SIZE); + if (status == 0) + { + for (i = 4; i < POL_HND_SIZE; i++) + { + r_u.pol.data[i] = i+1; + } + } + + make_dom_rid4(&(r_u.rid4), 0x0030, 0, 0); + r_u.status = status; + + DEBUG(5,("samr_unknown_32: %d\n", __LINE__)); + + /* store the response in the SMB stream */ + samr_io_r_unknown_32("", &r_u, rdata, 0); + + DEBUG(5,("samr_unknown_32: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_unknown_32 + ********************************************************************/ +static void api_samr_unknown_32( int uid, prs_struct *data, prs_struct *rdata) +{ + uint32 status = 0; + struct smb_passwd *smb_pass; + fstring mach_acct; + + SAMR_Q_UNKNOWN_32 q_u; + + /* grab the samr unknown 32 */ + samr_io_q_unknown_32("", &q_u, data, 0); + + /* 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, unistrn2(q_u.uni_mach_acct.buffer, + q_u.uni_mach_acct.uni_str_len)); + + become_root(True); + smb_pass = get_smbpwd_entry(mach_acct, 0); + unbecome_root(True); + + if (smb_pass != NULL) + { + /* machine account exists: say so */ + status = 0xC0000000 | NT_STATUS_USER_EXISTS; + } + else + { + /* this could cause trouble... */ + status = 0; + } + + /* construct reply. */ + samr_reply_unknown_32(&q_u, rdata, status); +} + + +/******************************************************************* + samr_reply_connect + ********************************************************************/ +static void samr_reply_connect(SAMR_Q_CONNECT *q_u, + prs_struct *rdata) +{ + SAMR_R_CONNECT r_u; + BOOL pol_open = False; + + /* set up the SAMR connect response */ + + r_u.status = 0x0; + /* get a (unique) handle. open a policy on it. */ + if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.connect_pol)))) + { + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + /* associate the domain SID with the (unique) handle. */ + if (r_u.status == 0x0 && !set_lsa_policy_samr_pol_status(&(r_u.connect_pol), q_u->unknown_0)) + { + /* oh, whoops. don't know what error message to return, here */ + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + if (r_u.status != 0 && pol_open) + { + close_lsa_policy_hnd(&(r_u.connect_pol)); + } + + DEBUG(5,("samr_connect: %d\n", __LINE__)); + + /* store the response in the SMB stream */ + samr_io_r_connect("", &r_u, rdata, 0); + + DEBUG(5,("samr_connect: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_connect + ********************************************************************/ +static void api_samr_connect( int uid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_CONNECT q_u; + + /* grab the samr open policy */ + samr_io_q_connect("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_connect(&q_u, rdata); +} + +/******************************************************************* + samr_reply_open_alias + ********************************************************************/ +static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, + prs_struct *rdata) +{ + SAMR_R_OPEN_ALIAS r_u; + BOOL pol_open = False; + + /* set up the SAMR open_alias response */ + + r_u.status = 0x0; + /* get a (unique) handle. open a policy on it. */ + if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.pol)))) + { + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + /* associate a RID with the (unique) handle. */ + if (r_u.status == 0x0 && !set_lsa_policy_samr_rid(&(r_u.pol), q_u->rid_alias)) + { + /* oh, whoops. don't know what error message to return, here */ + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + if (r_u.status != 0 && pol_open) + { + close_lsa_policy_hnd(&(r_u.pol)); + } + + DEBUG(5,("samr_open_alias: %d\n", __LINE__)); + + /* store the response in the SMB stream */ + samr_io_r_open_alias("", &r_u, rdata, 0); + + DEBUG(5,("samr_open_alias: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_open_alias + ********************************************************************/ +static void api_samr_open_alias( int uid, prs_struct *data, prs_struct *rdata) + +{ + SAMR_Q_OPEN_ALIAS q_u; + + /* grab the samr open policy */ + samr_io_q_open_alias("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_open_alias(&q_u, rdata); +} + +/******************************************************************* + array of \PIPE\samr operations + ********************************************************************/ +static struct api_struct api_samr_cmds [] = +{ + { "SAMR_CLOSE_HND" , SAMR_CLOSE_HND , api_samr_close_hnd }, + { "SAMR_CONNECT" , SAMR_CONNECT , api_samr_connect }, + { "SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users }, + { "SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, + { "SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, + { "SAMR_LOOKUP_IDS" , SAMR_LOOKUP_IDS , api_samr_lookup_ids }, + { "SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, + { "SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, + { "SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, + { "SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, + { "SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, + { "SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, + { "SAMR_0x32" , 0x32 , api_samr_unknown_32 }, + { "SAMR_UNKNOWN_12" , SAMR_UNKNOWN_12 , api_samr_unknown_12 }, + { "SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, + { "SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, + { "SAMR_UNKNOWN_3" , SAMR_UNKNOWN_3 , api_samr_unknown_3 }, + { NULL , 0 , NULL } +}; + +/******************************************************************* + receives a samr pipe and responds. + ********************************************************************/ +BOOL api_samr_rpc(pipes_struct *p, prs_struct *data) +{ + return api_rpcTNP(p, "api_samr_rpc", api_samr_cmds, data); +} + diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c new file mode 100644 index 0000000000..285ea89657 --- /dev/null +++ b/source3/rpc_server/srv_srvsvc.c @@ -0,0 +1,1015 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + + +/******************************************************************* + fill in a share info level 1 structure. + + this function breaks the rule that i'd like to be in place, namely + it doesn't receive its data as arguments: it has to call lp_xxxx() + functions itself. yuck. + + see ipc.c:fill_share_info() + + ********************************************************************/ +static void make_srv_share_1_info(SH_INFO_1 *sh1, + SH_INFO_1_STR *str1, int snum) +{ + int len_net_name; + pstring net_name; + pstring remark; + uint32 type; + + pstrcpy(net_name, lp_servicename(snum)); + strupper(net_name); + pstrcpy(remark , lp_comment (snum)); + len_net_name = strlen(net_name); + + /* work out the share type */ + type = STYPE_DISKTREE; + + if (lp_print_ok(snum)) type = STYPE_PRINTQ; + if (strequal("IPC$", net_name)) type = STYPE_IPC; + if (net_name[len_net_name] == '$') type |= STYPE_HIDDEN; + + make_srv_share_info1 (sh1 , net_name, type, remark); + make_srv_share_info1_str(str1, net_name, remark); +} + +/******************************************************************* + fill in a share info level 1 structure. + + this function breaks the rule that i'd like to be in place, namely + it doesn't receive its data as arguments: it has to call lp_xxxx() + functions itself. yuck. + + ********************************************************************/ +static void make_srv_share_info_1(SRV_SHARE_INFO_1 *sh1, uint32 *snum, uint32 *svcs) +{ + uint32 num_entries = 0; + (*svcs) = lp_numservices(); + + if (sh1 == NULL) + { + (*snum) = 0; + return; + } + + DEBUG(5,("make_srv_share_1_sh1\n")); + + for (; (*snum) < (*svcs) && num_entries < MAX_SHARE_ENTRIES; (*snum)++) + { + if (lp_browseable((*snum)) && lp_snum_ok((*snum))) + { + make_srv_share_1_info(&(sh1->info_1 [num_entries]), + &(sh1->info_1_str[num_entries]), (*snum)); + + /* move on to creating next share */ + num_entries++; + } + } + + sh1->num_entries_read = num_entries; + sh1->ptr_share_info = num_entries > 0 ? 1 : 0; + sh1->num_entries_read2 = num_entries; + + if ((*snum) >= (*svcs)) + { + (*snum) = 0; + } +} + +/******************************************************************* + fill in a share info level 2 structure. + + this function breaks the rule that i'd like to be in place, namely + it doesn't receive its data as arguments: it has to call lp_xxxx() + functions itself. yuck. + + see ipc.c:fill_share_info() + + ********************************************************************/ +static void make_srv_share_2_info(SH_INFO_2 *sh2, + SH_INFO_2_STR *str2, int snum) +{ + int len_net_name; + pstring net_name; + pstring remark; + pstring path; + pstring passwd; + uint32 type; + + pstrcpy(net_name, lp_servicename(snum)); + pstrcpy(remark , lp_comment (snum)); + pstrcpy(path , lp_pathname (snum)); + pstrcpy(passwd , ""); + len_net_name = strlen(net_name); + + /* work out the share type */ + type = STYPE_DISKTREE; + + if (lp_print_ok(snum)) type = STYPE_PRINTQ; + if (strequal("IPC$", net_name)) type = STYPE_IPC; + if (net_name[len_net_name] == '$') type |= STYPE_HIDDEN; + + make_srv_share_info2 (sh2 , net_name, type, remark, 0, 0xffffffff, 1, path, passwd); + make_srv_share_info2_str(str2, net_name, remark, path, passwd); +} + +/******************************************************************* + fill in a share info level 2 structure. + + this function breaks the rule that i'd like to be in place, namely + it doesn't receive its data as arguments: it has to call lp_xxxx() + functions itself. yuck. + + ********************************************************************/ +static void make_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, uint32 *snum, uint32 *svcs) +{ + uint32 num_entries = 0; + (*svcs) = lp_numservices(); + + if (sh2 == NULL) + { + (*snum) = 0; + return; + } + + DEBUG(5,("make_srv_share_2_sh1\n")); + + for (; (*snum) < (*svcs) && num_entries < MAX_SHARE_ENTRIES; (*snum)++) + { + if (lp_browseable((*snum)) && lp_snum_ok((*snum))) + { + make_srv_share_2_info(&(sh2->info_2 [num_entries]), + &(sh2->info_2_str[num_entries]), (*snum)); + + /* move on to creating next share */ + num_entries++; + } + } + + sh2->num_entries_read = num_entries; + sh2->ptr_share_info = num_entries > 0 ? 1 : 0; + sh2->num_entries_read2 = num_entries; + + if ((*snum) >= (*svcs)) + { + (*snum) = 0; + } +} + +/******************************************************************* + makes a SRV_R_NET_SHARE_ENUM structure. +********************************************************************/ +static uint32 make_srv_share_info_ctr(SRV_SHARE_INFO_CTR *ctr, + int switch_value, uint32 *resume_hnd, uint32 *total_entries) +{ + uint32 status = 0x0; + DEBUG(5,("make_srv_share_info_ctr: %d\n", __LINE__)); + + ctr->switch_value = switch_value; + + switch (switch_value) + { + case 1: + { + make_srv_share_info_1(&(ctr->share.info1), resume_hnd, total_entries); + ctr->ptr_share_ctr = 1; + break; + } + case 2: + { + make_srv_share_info_2(&(ctr->share.info2), resume_hnd, total_entries); + ctr->ptr_share_ctr = 2; + break; + } + default: + { + DEBUG(5,("make_srv_share_info_ctr: unsupported switch value %d\n", + switch_value)); + (*resume_hnd = 0); + (*total_entries) = 0; + ctr->ptr_share_ctr = 0; + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + break; + } + } + + return status; +} + +/******************************************************************* + makes a SRV_R_NET_SHARE_ENUM structure. +********************************************************************/ +static void make_srv_r_net_share_enum(SRV_R_NET_SHARE_ENUM *r_n, + uint32 resume_hnd, int share_level, int switch_value) +{ + DEBUG(5,("make_srv_r_net_share_enum: %d\n", __LINE__)); + + r_n->share_level = share_level; + if (share_level == 0) + { + r_n->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + } + else + { + r_n->status = make_srv_share_info_ctr(r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries)); + } + if (r_n->status != 0x0) + { + resume_hnd = 0; + } + make_enum_hnd(&(r_n->enum_hnd), resume_hnd); +} + +/******************************************************************* +net share enum +********************************************************************/ +static void srv_reply_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n, + prs_struct *rdata) +{ + SRV_R_NET_SHARE_ENUM r_n; + SRV_SHARE_INFO_CTR ctr; + + r_n.ctr = &ctr; + + DEBUG(5,("srv_net_share_enum: %d\n", __LINE__)); + + /* set up the */ + make_srv_r_net_share_enum(&r_n, + get_enum_hnd(&q_n->enum_hnd), + q_n->share_level, + q_n->ctr->switch_value); + + /* store the response in the SMB stream */ + srv_io_r_net_share_enum("", &r_n, rdata, 0); + + DEBUG(5,("srv_net_share_enum: %d\n", __LINE__)); +} + +/******************************************************************* + fill in a sess info level 1 structure. + + this function breaks the rule that i'd like to be in place, namely + it doesn't receive its data as arguments: it has to call lp_xxxx() + functions itself. yuck. + + ********************************************************************/ +static void make_srv_sess_0_info(SESS_INFO_0 *se0, SESS_INFO_0_STR *str0, + char *name) +{ + make_srv_sess_info0 (se0 , name); + make_srv_sess_info0_str(str0, name); +} + +/******************************************************************* + fill in a sess info level 0 structure. + + this function breaks the rule that i'd like to be in place, namely + it doesn't receive its data as arguments: it has to call lp_xxxx() + functions itself. yuck. + + ********************************************************************/ +static void make_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot) +{ + uint32 num_entries = 0; + (*stot) = 1; + + if (ss0 == NULL) + { + (*snum) = 0; + return; + } + + DEBUG(5,("make_srv_sess_0_ss0\n")); + + if (snum) + { + for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) + { + make_srv_sess_0_info(&(ss0->info_0 [num_entries]), + &(ss0->info_0_str[num_entries]), "MACHINE"); + + /* move on to creating next session */ + /* move on to creating next sess */ + num_entries++; + } + + ss0->num_entries_read = num_entries; + ss0->ptr_sess_info = num_entries > 0 ? 1 : 0; + ss0->num_entries_read2 = num_entries; + + if ((*snum) >= (*stot)) + { + (*snum) = 0; + } + } + else + { + ss0->num_entries_read = 0; + ss0->ptr_sess_info = 0; + ss0->num_entries_read2 = 0; + } +} + +/******************************************************************* + fill in a sess info level 1 structure. + + this function breaks the rule that i'd like to be in place, namely + it doesn't receive its data as arguments: it has to call lp_xxxx() + functions itself. yuck. + + ********************************************************************/ +static void make_srv_sess_1_info(SESS_INFO_1 *se1, SESS_INFO_1_STR *str1, + char *name, char *user, + uint32 num_opens, + uint32 open_time, uint32 idle_time, + uint32 usr_flgs) +{ + make_srv_sess_info1 (se1 , name, user, num_opens, open_time, idle_time, usr_flgs); + make_srv_sess_info1_str(str1, name, user); +} + +/******************************************************************* + fill in a sess info level 1 structure. + + this function breaks the rule that i'd like to be in place, namely + it doesn't receive its data as arguments: it has to call lp_xxxx() + functions itself. yuck. + + ********************************************************************/ +static void make_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot) +{ + uint32 num_entries = 0; + (*stot) = 1; + + if (ss1 == NULL) + { + (*snum) = 0; + return; + } + + DEBUG(5,("make_srv_sess_1_ss1\n")); + + if (snum) + { + for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) + { + make_srv_sess_1_info(&(ss1->info_1 [num_entries]), + &(ss1->info_1_str[num_entries]), + "MACHINE", "dummy_user", 1, 10, 5, 0); + + /* move on to creating next session */ + /* move on to creating next sess */ + num_entries++; + } + + ss1->num_entries_read = num_entries; + ss1->ptr_sess_info = num_entries > 0 ? 1 : 0; + ss1->num_entries_read2 = num_entries; + + if ((*snum) >= (*stot)) + { + (*snum) = 0; + } + } + else + { + ss1->num_entries_read = 0; + ss1->ptr_sess_info = 0; + ss1->num_entries_read2 = 0; + + (*stot) = 0; + } +} + +/******************************************************************* + makes a SRV_R_NET_SESS_ENUM structure. +********************************************************************/ +static uint32 make_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, + int switch_value, uint32 *resume_hnd, uint32 *total_entries) +{ + uint32 status = 0x0; + DEBUG(5,("make_srv_sess_info_ctr: %d\n", __LINE__)); + + ctr->switch_value = switch_value; + + switch (switch_value) + { + case 0: + { + make_srv_sess_info_0(&(ctr->sess.info0), resume_hnd, total_entries); + ctr->ptr_sess_ctr = 1; + break; + } + case 1: + { + make_srv_sess_info_1(&(ctr->sess.info1), resume_hnd, total_entries); + ctr->ptr_sess_ctr = 1; + break; + } + default: + { + DEBUG(5,("make_srv_sess_info_ctr: unsupported switch value %d\n", + switch_value)); + (*resume_hnd) = 0; + (*total_entries) = 0; + ctr->ptr_sess_ctr = 0; + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + break; + } + } + + return status; +} + +/******************************************************************* + makes a SRV_R_NET_SESS_ENUM structure. +********************************************************************/ +static void make_srv_r_net_sess_enum(SRV_R_NET_SESS_ENUM *r_n, + uint32 resume_hnd, int sess_level, int switch_value) +{ + DEBUG(5,("make_srv_r_net_sess_enum: %d\n", __LINE__)); + + r_n->sess_level = sess_level; + if (sess_level == -1) + { + r_n->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + } + else + { + r_n->status = make_srv_sess_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); + } + if (r_n->status != 0x0) + { + resume_hnd = 0; + } + make_enum_hnd(&(r_n->enum_hnd), resume_hnd); +} + +/******************************************************************* +net sess enum +********************************************************************/ +static void srv_reply_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n, + prs_struct *rdata) +{ + SRV_R_NET_SESS_ENUM r_n; + SRV_SESS_INFO_CTR ctr; + + r_n.ctr = &ctr; + + DEBUG(5,("srv_net_sess_enum: %d\n", __LINE__)); + + /* set up the */ + make_srv_r_net_sess_enum(&r_n, + get_enum_hnd(&q_n->enum_hnd), + q_n->sess_level, + q_n->ctr->switch_value); + + /* store the response in the SMB stream */ + srv_io_r_net_sess_enum("", &r_n, rdata, 0); + + DEBUG(5,("srv_net_sess_enum: %d\n", __LINE__)); +} + +/******************************************************************* + fill in a conn info level 0 structure. + + this function breaks the rule that i'd like to be in place, namely + it doesn't receive its data as arguments: it has to call lp_xxxx() + functions itself. yuck. + + ********************************************************************/ +static void make_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *stot) +{ + uint32 num_entries = 0; + (*stot) = 1; + + if (ss0 == NULL) + { + (*snum) = 0; + return; + } + + DEBUG(5,("make_srv_conn_0_ss0\n")); + + if (snum) + { + for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) + { + make_srv_conn_info0(&(ss0->info_0 [num_entries]), (*stot)); + + /* move on to creating next connection */ + /* move on to creating next conn */ + num_entries++; + } + + ss0->num_entries_read = num_entries; + ss0->ptr_conn_info = num_entries > 0 ? 1 : 0; + ss0->num_entries_read2 = num_entries; + + + + if ((*snum) >= (*stot)) + { + (*snum) = 0; + } + } + else + { + ss0->num_entries_read = 0; + ss0->ptr_conn_info = 0; + ss0->num_entries_read2 = 0; + + (*stot) = 0; + } +} + +/******************************************************************* + fill in a conn info level 1 structure. + + this function breaks the rule that i'd like to be in place, namely + it doesn't receive its data as arguments: it has to call lp_xxxx() + functions itself. yuck. + + ********************************************************************/ +static void make_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1, + uint32 id, uint32 type, + uint32 num_opens, uint32 num_users, uint32 open_time, + char *usr_name, char *net_name) +{ + make_srv_conn_info1 (se1 , id, type, num_opens, num_users, open_time, usr_name, net_name); + make_srv_conn_info1_str(str1, usr_name, net_name); +} + +/******************************************************************* + fill in a conn info level 1 structure. + + this function breaks the rule that i'd like to be in place, namely + it doesn't receive its data as arguments: it has to call lp_xxxx() + functions itself. yuck. + + ********************************************************************/ +static void make_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *stot) +{ + uint32 num_entries = 0; + (*stot) = 1; + + if (ss1 == NULL) + { + (*snum) = 0; + return; + } + + DEBUG(5,("make_srv_conn_1_ss1\n")); + + if (snum) + { + for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) + { + make_srv_conn_1_info(&(ss1->info_1 [num_entries]), + &(ss1->info_1_str[num_entries]), + (*stot), 0x3, 1, 1, 3,"dummy_user", "IPC$"); + + /* move on to creating next connection */ + /* move on to creating next conn */ + num_entries++; + } + + ss1->num_entries_read = num_entries; + ss1->ptr_conn_info = num_entries > 0 ? 1 : 0; + ss1->num_entries_read2 = num_entries; + + + if ((*snum) >= (*stot)) + { + (*snum) = 0; + } + } + else + { + ss1->num_entries_read = 0; + ss1->ptr_conn_info = 0; + ss1->num_entries_read2 = 0; + + (*stot) = 0; + } +} + +/******************************************************************* + makes a SRV_R_NET_CONN_ENUM structure. +********************************************************************/ +static uint32 make_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, + int switch_value, uint32 *resume_hnd, uint32 *total_entries) +{ + uint32 status = 0x0; + DEBUG(5,("make_srv_conn_info_ctr: %d\n", __LINE__)); + + ctr->switch_value = switch_value; + + switch (switch_value) + { + case 0: + { + make_srv_conn_info_0(&(ctr->conn.info0), resume_hnd, total_entries); + ctr->ptr_conn_ctr = 1; + break; + } + case 1: + { + make_srv_conn_info_1(&(ctr->conn.info1), resume_hnd, total_entries); + ctr->ptr_conn_ctr = 1; + break; + } + default: + { + DEBUG(5,("make_srv_conn_info_ctr: unsupported switch value %d\n", + switch_value)); + (*resume_hnd = 0); + (*total_entries) = 0; + ctr->ptr_conn_ctr = 0; + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + break; + } + } + + return status; +} + +/******************************************************************* + makes a SRV_R_NET_CONN_ENUM structure. +********************************************************************/ +static void make_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, + uint32 resume_hnd, int conn_level, int switch_value) +{ + DEBUG(5,("make_srv_r_net_conn_enum: %d\n", __LINE__)); + + r_n->conn_level = conn_level; + if (conn_level == -1) + { + r_n->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + } + else + { + r_n->status = make_srv_conn_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); + } + if (r_n->status != 0x0) + { + resume_hnd = 0; + } + make_enum_hnd(&(r_n->enum_hnd), resume_hnd); +} + +/******************************************************************* +net conn enum +********************************************************************/ +static void srv_reply_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n, + prs_struct *rdata) +{ + SRV_R_NET_CONN_ENUM r_n; + SRV_CONN_INFO_CTR ctr; + + r_n.ctr = &ctr; + + DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); + + /* set up the */ + make_srv_r_net_conn_enum(&r_n, + get_enum_hnd(&q_n->enum_hnd), + q_n->conn_level, + q_n->ctr->switch_value); + + /* store the response in the SMB stream */ + srv_io_r_net_conn_enum("", &r_n, rdata, 0); + + DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); +} + +/******************************************************************* + fill in a file info level 3 structure. + ********************************************************************/ +static void make_srv_file_3_info(FILE_INFO_3 *fl3, FILE_INFO_3_STR *str3, + uint32 fnum, uint32 perms, uint32 num_locks, + char *path_name, char *user_name) +{ + make_srv_file_info3 (fl3 , fnum, perms, num_locks, path_name, user_name); + make_srv_file_info3_str(str3, path_name, user_name); +} + +/******************************************************************* + fill in a file info level 3 structure. + + this function breaks the rule that i'd like to be in place, namely + it doesn't receive its data as arguments: it has to call lp_xxxx() + functions itself. yuck. + + ********************************************************************/ +static void make_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *ftot) +{ + uint32 num_entries = 0; + (*ftot) = 1; + + if (fl3 == NULL) + { + (*fnum) = 0; + return; + } + + DEBUG(5,("make_srv_file_3_fl3\n")); + + for (; (*fnum) < (*ftot) && num_entries < MAX_FILE_ENTRIES; (*fnum)++) + { + make_srv_file_3_info(&(fl3->info_3 [num_entries]), + &(fl3->info_3_str[num_entries]), + (*fnum), 0x35, 0, "\\PIPE\\samr", "dummy user"); + + /* move on to creating next file */ + num_entries++; + } + + fl3->num_entries_read = num_entries; + fl3->ptr_file_info = num_entries > 0 ? 1 : 0; + fl3->num_entries_read2 = num_entries; + + if ((*fnum) >= (*ftot)) + { + (*fnum) = 0; + } +} + +/******************************************************************* + makes a SRV_R_NET_FILE_ENUM structure. +********************************************************************/ +static uint32 make_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, + int switch_value, uint32 *resume_hnd, uint32 *total_entries) +{ + uint32 status = 0x0; + DEBUG(5,("make_srv_file_info_ctr: %d\n", __LINE__)); + + ctr->switch_value = switch_value; + + switch (switch_value) + { + case 3: + { + make_srv_file_info_3(&(ctr->file.info3), resume_hnd, total_entries); + ctr->ptr_file_ctr = 1; + break; + } + default: + { + DEBUG(5,("make_srv_file_info_ctr: unsupported switch value %d\n", + switch_value)); + (*resume_hnd = 0); + (*total_entries) = 0; + ctr->ptr_file_ctr = 0; + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + break; + } + } + + return status; +} + +/******************************************************************* + makes a SRV_R_NET_FILE_ENUM structure. +********************************************************************/ +static void make_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n, + uint32 resume_hnd, int file_level, int switch_value) +{ + DEBUG(5,("make_srv_r_net_file_enum: %d\n", __LINE__)); + + r_n->file_level = file_level; + if (file_level == 0) + { + r_n->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + } + else + { + r_n->status = make_srv_file_info_ctr(r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries)); + } + if (r_n->status != 0x0) + { + resume_hnd = 0; + } + make_enum_hnd(&(r_n->enum_hnd), resume_hnd); +} + +/******************************************************************* +net file enum +********************************************************************/ +static void srv_reply_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n, + prs_struct *rdata) +{ + SRV_R_NET_FILE_ENUM r_n; + SRV_FILE_INFO_CTR ctr; + + r_n.ctr = &ctr; + + DEBUG(5,("srv_net_file_enum: %d\n", __LINE__)); + + /* set up the */ + make_srv_r_net_file_enum(&r_n, + get_enum_hnd(&q_n->enum_hnd), + q_n->file_level, + q_n->ctr->switch_value); + + /* store the response in the SMB stream */ + srv_io_r_net_file_enum("", &r_n, rdata, 0); + + DEBUG(5,("srv_net_file_enum: %d\n", __LINE__)); +} + +/******************************************************************* +net server get info +********************************************************************/ +static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, + prs_struct *rdata) +{ + SRV_R_NET_SRV_GET_INFO r_n; + uint32 status = 0x0; + SRV_INFO_CTR ctr; + + extern pstring myname; + get_myname(myname,NULL); + + DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); + + switch (q_n->switch_value) + { + case 102: + { + make_srv_info_102(&ctr.srv.sv102, + 500, myname, lp_serverstring(), + 5, 4, /* major/minor version - NT 5.4 :-) */ + 0x4100b, /* browsing stuff SV_TYPE_XXXX */ + 0xffffffff, /* users */ + 0xf, /* disc */ + 0, /* hidden */ + 240, /* announce */ + 3000, /* announce delta */ + 100000, /* licenses */ + "c:\\"); /* user path */ + break; + } + case 101: + { + make_srv_info_101(&ctr.srv.sv101, + 500, myname, + 5, 4, /* major/minor version - NT 5.4 :-) */ + 0x4100b, /* browsing stuff SV_TYPE_XXXX */ + lp_serverstring()); + break; + } + default: + { + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + break; + } + } + + /* set up the net server get info structure */ + make_srv_r_net_srv_get_info(&r_n, q_n->switch_value, &ctr, status); + + /* store the response in the SMB stream */ + srv_io_r_net_srv_get_info("", &r_n, rdata, 0); + + DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); +} + +/******************************************************************* +********************************************************************/ +static void api_srv_net_srv_get_info( int uid, prs_struct *data, + prs_struct *rdata ) +{ + SRV_Q_NET_SRV_GET_INFO q_n; + + /* grab the net server get info */ + srv_io_q_net_srv_get_info("", &q_n, data, 0); + + /* construct reply. always indicate success */ + srv_reply_net_srv_get_info(&q_n, rdata); +} + + +/******************************************************************* +********************************************************************/ +static void api_srv_net_file_enum( int uid, prs_struct *data, + prs_struct *rdata ) +{ + SRV_Q_NET_FILE_ENUM q_n; + SRV_FILE_INFO_CTR ctr; + + q_n.ctr = &ctr; + + /* grab the net file enum */ + srv_io_q_net_file_enum("", &q_n, data, 0); + + /* construct reply. always indicate success */ + srv_reply_net_file_enum(&q_n, rdata); +} + + +/******************************************************************* +********************************************************************/ +static void api_srv_net_conn_enum( int uid, prs_struct *data, + prs_struct *rdata ) +{ + SRV_Q_NET_CONN_ENUM q_n; + SRV_CONN_INFO_CTR ctr; + + q_n.ctr = &ctr; + + /* grab the net server get enum */ + srv_io_q_net_conn_enum("", &q_n, data, 0); + + /* construct reply. always indicate success */ + srv_reply_net_conn_enum(&q_n, rdata); +} + + +/******************************************************************* +********************************************************************/ +static void api_srv_net_sess_enum( int uid, prs_struct *data, + prs_struct *rdata ) +{ + SRV_Q_NET_SESS_ENUM q_n; + SRV_SESS_INFO_CTR ctr; + + q_n.ctr = &ctr; + + /* grab the net server get enum */ + srv_io_q_net_sess_enum("", &q_n, data, 0); + + /* construct reply. always indicate success */ + srv_reply_net_sess_enum(&q_n, rdata); +} + + +/******************************************************************* +********************************************************************/ +static void api_srv_net_share_enum( int uid, prs_struct *data, + prs_struct *rdata ) +{ + SRV_Q_NET_SHARE_ENUM q_n; + SRV_SHARE_INFO_CTR ctr; + + q_n.ctr = &ctr; + + /* grab the net server get enum */ + srv_io_q_net_share_enum("", &q_n, data, 0); + + /* construct reply. always indicate success */ + srv_reply_net_share_enum(&q_n, rdata); +} + + +/******************************************************************* +\PIPE\srvsvc commands +********************************************************************/ +struct api_struct api_srv_cmds[] = +{ + { "SRV_NETCONNENUM" , SRV_NETCONNENUM , api_srv_net_conn_enum }, + { "SRV_NETSESSENUM" , SRV_NETSESSENUM , api_srv_net_sess_enum }, + { "SRV_NETSHAREENUM" , SRV_NETSHAREENUM , api_srv_net_share_enum }, + { "SRV_NETFILEENUM" , SRV_NETFILEENUM , api_srv_net_file_enum }, + { "SRV_NET_SRV_GET_INFO", SRV_NET_SRV_GET_INFO, api_srv_net_srv_get_info }, + { NULL , 0 , NULL } +}; + +/******************************************************************* +receives a srvsvc pipe and responds. +********************************************************************/ +BOOL api_srvsvc_rpc(pipes_struct *p, prs_struct *data) +{ + return api_rpcTNP(p, "api_srvsvc_rpc", api_srv_cmds, data); +} + diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c new file mode 100644 index 0000000000..7be259029a --- /dev/null +++ b/source3/rpc_server/srv_util.c @@ -0,0 +1,477 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1998 + * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, + * Copyright (C) Paul Ashton 1997-1998. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* this module apparently provides an implementation of DCE/RPC over a + * named pipe (IPC$ connection using SMBtrans). details of DCE/RPC + * documentation are available (in on-line form) from the X-Open group. + * + * this module should provide a level of abstraction between SMB + * and DCE/RPC, while minimising the amount of mallocs, unnecessary + * data copies, and network traffic. + * + * in this version, which takes a "let's learn what's going on and + * get something running" approach, there is additional network + * traffic generated, but the code should be easier to understand... + * + * ... if you read the docs. or stare at packets for weeks on end. + * + */ + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + +/* array lookup of well-known RID aliases. the purpose of these escapes me.. */ +/* XXXX this structure should not have the well-known RID groups added to it, + i.e the DOMAIN_GROUP_RID_ADMIN/USER/GUEST. */ +rid_name domain_alias_rids[] = +{ + { DOMAIN_ALIAS_RID_ADMINS , "admins" }, + { DOMAIN_ALIAS_RID_USERS , "users" }, + { DOMAIN_ALIAS_RID_GUESTS , "guests" }, + { DOMAIN_ALIAS_RID_POWER_USERS , "power_users" }, + + { DOMAIN_ALIAS_RID_ACCOUNT_OPS , "account_ops" }, + { DOMAIN_ALIAS_RID_SYSTEM_OPS , "system_ops" }, + { DOMAIN_ALIAS_RID_PRINT_OPS , "print_ops" }, + { DOMAIN_ALIAS_RID_BACKUP_OPS , "backup_ops" }, + { DOMAIN_ALIAS_RID_REPLICATOR , "replicator" }, + { 0 , NULL } +}; + +/* array lookup of well-known Domain RID groups. */ +rid_name domain_group_rids[] = +{ + { DOMAIN_GROUP_RID_ADMINS , "domain admins" }, + { DOMAIN_GROUP_RID_USERS , "domain users" }, + { DOMAIN_GROUP_RID_GUESTS , "domain guests" }, + { 0 , NULL } +}; + + + +int make_dom_gids(char *gids_str, DOM_GID *gids) +{ + char *ptr; + pstring s2; + int count; + + DEBUG(4,("make_dom_gids: %s\n", gids_str)); + + if (gids_str == NULL || *gids_str == 0) return 0; + + for (count = 0, ptr = gids_str; next_token(&ptr, s2, NULL) && count < LSA_MAX_GROUPS; count++) + { + /* the entries are of the form GID/ATTR, ATTR being optional.*/ + char *attr; + uint32 rid = 0; + int i; + + attr = strchr(s2,'/'); + if (attr) *attr++ = 0; + if (!attr || !*attr) attr = "7"; /* default value for attribute is 7 */ + + /* look up the RID string and see if we can turn it into a rid number */ + for (i = 0; domain_alias_rids[i].name != NULL; i++) + { + if (strequal(domain_alias_rids[i].name, s2)) + { + rid = domain_alias_rids[i].rid; + break; + } + } + + if (rid == 0) rid = atoi(s2); + + if (rid == 0) + { + DEBUG(1,("make_dom_gids: unknown well-known alias RID %s/%s\n", + s2, attr)); + count--; + } + else + { + gids[count].g_rid = rid; + gids[count].attr = atoi(attr); + + DEBUG(5,("group id: %d attr: %d\n", + gids[count].g_rid, + gids[count].attr)); + } + } + + return count; +} + +/******************************************************************* + gets a domain user's groups + ********************************************************************/ +void get_domain_user_groups(char *domain_groups, char *user) +{ + pstring tmp; + + if (domain_groups == NULL || user == NULL) return; + + /* any additional groups this user is in. e.g power users */ + pstrcpy(domain_groups, lp_domain_groups()); + + /* can only be a user or a guest. cannot be guest _and_ admin */ + if (user_in_list(user, lp_domain_guest_users())) + { + sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_GUESTS); + strcat(domain_groups, tmp); + + DEBUG(3,("domain guest access %s granted\n", tmp)); + } + else + { + sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_USERS); + strcat(domain_groups, tmp); + + DEBUG(3,("domain user access %s granted\n", tmp)); + + if (user_in_list(user, lp_domain_admin_users())) + { + sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_ADMINS); + strcat(domain_groups, tmp); + + DEBUG(3,("domain admin access %s granted\n", tmp)); + } + } +} + + +/******************************************************************* + turns a DCE/RPC request into a DCE/RPC reply + + this is where the data really should be split up into an array of + headers and data sections. + + ********************************************************************/ +BOOL create_rpc_reply(pipes_struct *p, + uint32 data_start, uint32 data_end) +{ + mem_buf_init(&(p->rhdr.data), 0); + mem_alloc_data(p->rhdr.data, 0x18); + + p->rhdr.align = 4; + p->rhdr.io = False; + + p->hdr_rr.alloc_hint = data_end - data_start; /* calculate remaining data to be sent */ + p->hdr.pkt_type = RPC_RESPONSE; /* mark header as an rpc response */ + + /* set up rpc header (fragmentation issues) */ + if (data_start == 0) + { + p->hdr.flags = RPC_FLG_FIRST; + } + else + { + p->hdr.flags = 0; + } + + if (p->hdr_rr.alloc_hint + 0x18 <= p->hdr_ba.bba.max_tsize) + { + p->hdr.flags |= RPC_FLG_LAST; + p->hdr.frag_len = p->hdr_rr.alloc_hint + 0x18; + } + else + { + p->hdr.frag_len = p->hdr_ba.bba.max_tsize; + } + + p->rhdr.data->offset.start = 0; + p->rhdr.data->offset.end = 0x18; + + /* store the header in the data stream */ + p->rhdr.offset = 0; + smb_io_rpc_hdr ("hdr", &(p->hdr ), &(p->rhdr), 0); + smb_io_rpc_hdr_rr("rr" , &(p->hdr_rr), &(p->rhdr), 0); + + return p->rhdr.data != NULL && p->rhdr.offset == 0x18; +} + + +/******************************************************************* + receives a netlogon pipe and responds. + ********************************************************************/ +static BOOL api_rpc_command(pipes_struct *p, + char *rpc_name, struct api_struct *api_rpc_cmds, + prs_struct *data) +{ + int fn_num; + DEBUG(4,("api_rpc_command: %s op 0x%x - ", rpc_name, p->hdr_rr.opnum)); + + for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) + { + if (api_rpc_cmds[fn_num].opnum == p->hdr_rr.opnum && api_rpc_cmds[fn_num].fn != NULL) + { + DEBUG(3,("api_rpc_command: %s\n", api_rpc_cmds[fn_num].name)); + break; + } + } + + if (api_rpc_cmds[fn_num].name == NULL) + { + DEBUG(4, ("unknown\n")); + return False; + } + + /* start off with 1024 bytes, and a large safety margin too */ + mem_buf_init(&(p->rdata.data), SAFETY_MARGIN); + mem_alloc_data(p->rdata.data, 1024); + + p->rdata.io = False; + p->rdata.align = 4; + + p->rdata.data->offset.start = 0; + p->rdata.data->offset.end = 0xffffffff; + + /* do the actual command */ + p->rdata.offset = 0; + api_rpc_cmds[fn_num].fn(p->uid, data, &(p->rdata)); + + if (p->rdata.data == NULL || p->rdata.offset == 0) + { + mem_free_data(p->rdata.data); + return False; + } + + mem_realloc_data(p->rdata.data, p->rdata.offset); + + DEBUG(10,("called %s\n", rpc_name)); + + return True; +} + + +/******************************************************************* + receives a netlogon pipe and responds. + ********************************************************************/ +BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds, + prs_struct *data) +{ + if (data == NULL || data->data == NULL) + { + DEBUG(2,("%s: NULL data received\n", rpc_name)); + return False; + } + + /* read the rpc header */ + smb_io_rpc_hdr_rr("", &(p->hdr_rr), data, 0); + + /* interpret the command */ + if (!api_rpc_command(p, rpc_name, api_rpc_cmds, data)) + { + return False; + } + + /* create the rpc header */ + if (!create_rpc_reply(p, 0, p->rdata.offset)) + { + return False; + } + + /* set up the data chain */ + p->rhdr.data->offset.start = 0; + p->rhdr.data->offset.end = p->rhdr.offset; + p->rhdr.data->next = p->rdata.data; + + p->rdata.data->offset.start = p->rhdr.data->offset.end; + p->rdata.data->offset.end = p->rhdr.data->offset.end + p->rdata.offset; + p->rdata.data->next = NULL; + + return True; +} + +extern rid_name domain_group_rids[]; + +/******************************************************************* + lookup_group_name + ********************************************************************/ +uint32 lookup_group_name(uint32 rid, char *group_name, uint32 *type) +{ + int i = 0; + (*type) = SID_NAME_DOM_GRP; + + while (domain_group_rids[i].rid != rid && domain_group_rids[i].rid != 0) + { + i++; + } + + if (domain_group_rids[i].rid != 0) + { + fstrcpy(group_name, domain_group_rids[i].name); + return 0x0; + } + + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +extern rid_name domain_alias_rids[]; + +/******************************************************************* + lookup_alias_name + ********************************************************************/ +uint32 lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) +{ + int i = 0; + (*type) = SID_NAME_WKN_GRP; + + while (domain_alias_rids[i].rid != rid && domain_alias_rids[i].rid != 0) + { + i++; + } + + if (domain_alias_rids[i].rid != 0) + { + fstrcpy(alias_name, domain_alias_rids[i].name); + return 0x0; + } + + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_user_name + ********************************************************************/ +uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) +{ + struct smb_passwd *smb_pass; + (*type) = SID_NAME_USER; + + /* find the user account */ + become_root(True); + smb_pass = get_smbpwd_entry(NULL, rid); /* lkclXXXX SHOULD use rid mapping here! */ + unbecome_root(True); + + if (smb_pass != NULL) + { + fstrcpy(user_name, smb_pass->smb_name); + return 0x0; + } + + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_group_rid + ********************************************************************/ +uint32 lookup_group_rid(char *group_name, uint32 *rid) +{ + char *grp_name; + int i = -1; /* start do loop at -1 */ + + do /* find, if it exists, a group rid for the group name*/ + { + i++; + (*rid) = domain_group_rids[i].rid; + grp_name = domain_group_rids[i].name; + + } while (grp_name != NULL && !strequal(grp_name, group_name)); + + return (grp_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_alias_rid + ********************************************************************/ +uint32 lookup_alias_rid(char *alias_name, uint32 *rid) +{ + char *als_name; + int i = -1; /* start do loop at -1 */ + + do /* find, if it exists, a alias rid for the alias name*/ + { + i++; + (*rid) = domain_alias_rids[i].rid; + als_name = domain_alias_rids[i].name; + + } while (als_name != NULL && !strequal(als_name, alias_name)); + + return (als_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_user_rid + ********************************************************************/ +uint32 lookup_user_rid(char *user_name, uint32 *rid) +{ + struct smb_passwd *smb_pass; + (*rid) = 0; + + /* find the user account */ + become_root(True); + smb_pass = get_smbpwd_entry(user_name, 0); + unbecome_root(True); + + if (smb_pass != NULL) + { + /* lkclXXXX SHOULD use name_to_rid() here! */ + (*rid) = smb_pass->smb_userid; + return 0x0; + } + + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + Group and User RID username mapping function + ********************************************************************/ +BOOL name_to_rid(char *user_name, uint32 *u_rid, uint32 *g_rid) +{ + struct passwd *pw = Get_Pwnam(user_name, False); + + if (u_rid == NULL || g_rid == NULL || user_name == NULL) + { + return False; + } + + if (!pw) + { + DEBUG(1,("Username %s is invalid on this system\n", user_name)); + return False; + } + + if (user_in_list(user_name, lp_domain_guest_users())) + { + *u_rid = DOMAIN_USER_RID_GUEST; + } + else if (user_in_list(user_name, lp_domain_admin_users())) + { + *u_rid = DOMAIN_USER_RID_ADMIN; + } + else + { + /* turn the unix UID into a Domain RID. this is what the posix + sub-system does (adds 1000 to the uid) */ + *u_rid = (uint32)(pw->pw_uid + 1000); + } + + /* absolutely no idea what to do about the unix GID to Domain RID mapping */ + *g_rid = (uint32)(pw->pw_gid + 1000); + + return True; +} diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c new file mode 100644 index 0000000000..3dd273f784 --- /dev/null +++ b/source3/rpc_server/srv_wkssvc.c @@ -0,0 +1,113 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + + +/******************************************************************* + create_wks_info_100 + ********************************************************************/ +static void create_wks_info_100(WKS_INFO_100 *inf) +{ + extern pstring myname; + pstring my_name; + pstring domain; + + DEBUG(5,("create_wks_info_100: %d\n", __LINE__)); + + get_myname(myname, NULL); + pstrcpy (my_name, myname); + strupper(my_name); + + pstrcpy (domain , lp_workgroup()); + strupper(domain); + + make_wks_info_100(inf, + 0x000001f4, /* platform id info */ + lp_major_announce_version(), + lp_minor_announce_version(), + my_name, domain); +} + +/******************************************************************* + wks_reply_query_info + + only supports info level 100 at the moment. + + ********************************************************************/ +static void wks_reply_query_info(WKS_Q_QUERY_INFO *q_u, + prs_struct *rdata, + int status) +{ + WKS_R_QUERY_INFO r_u; + WKS_INFO_100 wks100; + + DEBUG(5,("wks_query_info: %d\n", __LINE__)); + + create_wks_info_100(&wks100); + make_wks_r_query_info(&r_u, q_u->switch_value, &wks100, status); + + /* store the response in the SMB stream */ + wks_io_r_query_info("", &r_u, rdata, 0); + + DEBUG(5,("wks_query_info: %d\n", __LINE__)); +} + +/******************************************************************* + api_wks_query_info + ********************************************************************/ +static void api_wks_query_info( int uid, prs_struct *data, + prs_struct *rdata ) +{ + WKS_Q_QUERY_INFO q_u; + + /* grab the net share enum */ + wks_io_q_query_info("", &q_u, data, 0); + + /* construct reply. always indicate success */ + wks_reply_query_info(&q_u, rdata, 0x0); +} + + +/******************************************************************* + \PIPE\wkssvc commands + ********************************************************************/ +struct api_struct api_wks_cmds[] = +{ + { "WKS_Q_QUERY_INFO", WKS_QUERY_INFO, api_wks_query_info }, + { NULL , 0 , NULL } +}; + +/******************************************************************* + receives a wkssvc pipe and responds. + ********************************************************************/ +BOOL api_wkssvc_rpc(pipes_struct *p, prs_struct *data) +{ + return api_rpcTNP(p, "api_wkssvc_rpc", api_wks_cmds, data); +} + -- cgit From f996885676f041437430bfd5843a3000611b0923 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 17 Mar 1998 12:31:43 +0000 Subject: this isn't a big commit, it just looks like it :-) I needed the client_name() and client_addr() functions in swat so I could tell who was connecting from where. The problem was that these functions didn't take a file descriptor parameter they just used the global "Client". So I needed to change all calls to pass a parameter ... lots of files. (This used to be commit a776058900a727591bd7b69debdaa25c0e31d693) --- source3/rpc_server/srv_netlog.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 94d6faa992..f85330fd3c 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -227,10 +227,11 @@ static void net_reply_sam_logoff(NET_Q_SAM_LOGOFF *q_s, prs_struct *rdata, ******************************************************************/ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) { - struct smb_passwd *smb_pass; + struct smb_passwd *smb_pass; + extern int Client; if (!allow_access(lp_domain_hostsdeny(), lp_domain_hostsallow(), - client_name(), client_addr())) + client_name(Client), client_addr(Client))) { DEBUG(0,("get_md4pw: Workstation %s denied access to domain\n", mach_acct)); return False; -- cgit From 5d7c8375e4ffb017ef0f9eed7e619e533b3e8d12 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 24 Mar 1998 00:37:53 +0000 Subject: clientgen.c ipc.c smbpasswd.c: Fixes for warnings (from Herb). quotas.c: Linux quota fix. util.c: Ensure smb_read_error is zero in all calls that can set it. lib/rpc/include/rpc_misc.h lib/rpc/include/rpc_netlogon.h lib/rpc/parse/parse_misc.c lib/rpc/parse/parse_net.c lib/rpc/server/srv_netlog.c : Modify Luke's code to call SamOEMhash(). Jeremy. (This used to be commit 7f749708383b8b36c3f23a5fbc5cbdf39bc8e555) --- source3/rpc_server/srv_netlog.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index f85330fd3c..d7a1b9e421 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -485,22 +485,22 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, { uint32 status = 0x0; -#ifdef USE_ARCFOUR - extern void arcfour(uint8 key[16], uint8 out[16], uint8 in[16]); char nt_pwd[16]; char lm_pwd[16]; - unsigned char arc4_key[16]; - memset(arc4_key, 0, 16); - memcpy(arc4_key, vuser->dc.sess_key, 8); + unsigned char key[16]; + memset(key, 0, 16); + memcpy(key, vuser->dc.sess_key, 8); - arcfour(arc4_key, lm_pwd, id1->arc4_lm_owf.data); - arcfour(arc4_key, nt_pwd, id1->arc4_nt_owf.data); + memcpy(lm_pwd, id1->lm_owf.data, 16); + memcpy(nt_pwd, id1->nt_owf.data, 16); + SamOEMhash(lm_pwd, key, False); + SamOEMhash(nt_pwd, key, False); #ifdef DEBUG_PASSWORD - DEBUG(100,("arcfour decrypt of lm owf password:")); + DEBUG(100,("decrypt of lm owf password:")); dump_data(100, lm_pwd, 16); - DEBUG(100,("arcfour decrypt of nt owf password:")); + DEBUG(100,("decrypt of nt owf password:")); dump_data(100, nt_pwd, 16); #endif @@ -509,13 +509,6 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, { status = 0xC0000000 | NT_STATUS_WRONG_PASSWORD; } -#else -/* sorry. have to assume that the password is always ok. - this _is_ ok, because the LSA SAM Logon is nothing to do - with SMB connections to shares. - */ -DEBUG(3,("SAM Logon. Password not being checked\n")); -#endif return status; } -- cgit From 10fe54befa10b283269001fdf779b9938c9a3a2c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 31 Mar 1998 20:55:14 +0000 Subject: includes.h: Added semaphore fix for HPUX10.x server.c trans2.c: Added oplock deadlock bug fix. lib/rpc/server/srv_netlog.c: Made code that changes machine account password the default. Jeremy. (This used to be commit 3b56fbc11e9d1cb7d4930d9782238c2610cac30d) --- source3/rpc_server/srv_netlog.c | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index d7a1b9e421..cb3616e4af 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -367,11 +367,9 @@ static void api_net_srv_pwset( int uid, NET_Q_SRV_PWSET q_a; uint32 status = NT_STATUS_WRONG_PASSWORD|0xC0000000; DOM_CRED srv_cred; -#ifdef ALLOW_SRV_PWSET - pstring mach_acct; + pstring mach_acct; struct smb_passwd *smb_pass; BOOL ret; -#endif user_struct *vuser; if ((vuser = get_valid_user_struct(uid)) == NULL) return; @@ -387,8 +385,6 @@ static void api_net_srv_pwset( int uid, DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); -#ifdef ALLOW_SRV_PWSET - pstrcpy(mach_acct, unistrn2(q_a.clnt_id.login.uni_acct_name.buffer, q_a.clnt_id.login.uni_acct_name.uni_str_len)); @@ -401,33 +397,26 @@ static void api_net_srv_pwset( int uid, if (smb_pass != NULL) { unsigned char pwd[16]; - uint8 mode = 2; memcpy(pwd, q_a.pwd, 16); - if (obfuscate_pwd(pwd, vuser->dc.sess_key, mode)) + /* 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; + + become_root(True); + ret = mod_smbpwd_entry(smb_pass); + unbecome_root(True); + + if (ret) { - /* 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; - - become_root(True); - ret = mod_smbpwd_entry(smb_pass); - unbecome_root(True); - - if (ret) - { - /* hooray! */ - status = 0x0; - } + /* hooray! */ + status = 0x0; } } DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); -#else - DEBUG(5,("api_net_srv_pwset: server password set being denied\n")); -#endif } else -- cgit From c6db9717f66944a1321fa4093c0b136963785c0e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 1 Apr 1998 19:12:35 +0000 Subject: Rolling back machine password change code - this doesn't work (yet). Jeremy. (This used to be commit 66affb3dc301d71565d789c06f105da3bb1d65b3) --- source3/rpc_server/srv_netlog.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index cb3616e4af..d7a1b9e421 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -367,9 +367,11 @@ static void api_net_srv_pwset( int uid, NET_Q_SRV_PWSET q_a; uint32 status = NT_STATUS_WRONG_PASSWORD|0xC0000000; DOM_CRED srv_cred; - pstring mach_acct; +#ifdef ALLOW_SRV_PWSET + pstring mach_acct; struct smb_passwd *smb_pass; BOOL ret; +#endif user_struct *vuser; if ((vuser = get_valid_user_struct(uid)) == NULL) return; @@ -385,6 +387,8 @@ static void api_net_srv_pwset( int uid, DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); +#ifdef ALLOW_SRV_PWSET + pstrcpy(mach_acct, unistrn2(q_a.clnt_id.login.uni_acct_name.buffer, q_a.clnt_id.login.uni_acct_name.uni_str_len)); @@ -397,26 +401,33 @@ static void api_net_srv_pwset( int uid, if (smb_pass != NULL) { unsigned char pwd[16]; + uint8 mode = 2; memcpy(pwd, q_a.pwd, 16); - /* 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; - - become_root(True); - ret = mod_smbpwd_entry(smb_pass); - unbecome_root(True); - - if (ret) + if (obfuscate_pwd(pwd, vuser->dc.sess_key, mode)) { - /* hooray! */ - status = 0x0; + /* 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; + + become_root(True); + ret = mod_smbpwd_entry(smb_pass); + unbecome_root(True); + + if (ret) + { + /* hooray! */ + status = 0x0; + } } } DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); +#else + DEBUG(5,("api_net_srv_pwset: server password set being denied\n")); +#endif } else -- cgit From 92e2ecc3b56cdf07739773b5173a361bc78e5b50 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 1 Apr 1998 21:31:06 +0000 Subject: cli_login.c : start to create the calls needed for client-side of "network" logins, which will be used for domain version of pass-through authentication. unfortunately, none of this code is called in the main branch, because smbclient BRANCH_NTDOM code isn't in use, yet! srv_netlog.c : fixed a problem with static net_login_network() which was being stubborn: the if() statement looked horrendous, so i split it into two if() statements, one to deal with the lm password; the other to deal with the nt password. the smb_password_check() functions should _not_ be called here, in case we decide to disable lm hashes for security reasons, just like nt does. so, we now get a response to the SAM_LOGON "network" call, but the connection is still dropped. a trace is needed from an nt server, which is why i started on the client-side code. see above, which is why i'm calling it a day :-) (This used to be commit 2c29a7d9cf2d8b35e4b6e37e5d24caa91af3a9be) --- source3/rpc_server/srv_netlog.c | 59 ++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index d7a1b9e421..1b66b8061f 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -488,11 +488,13 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, char nt_pwd[16]; char lm_pwd[16]; unsigned char key[16]; + memset(key, 0, 16); memcpy(key, vuser->dc.sess_key, 8); - memcpy(lm_pwd, id1->lm_owf.data, 16); - memcpy(nt_pwd, id1->nt_owf.data, 16); + memcpy(lm_pwd, id1->lm_owf.data, 16); + memcpy(nt_pwd, id1->nt_owf.data, 16); + SamOEMhash(lm_pwd, key, False); SamOEMhash(nt_pwd, key, False); @@ -520,17 +522,40 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, struct smb_passwd *smb_pass, user_struct *vuser) { - if ((id2->lm_chal_resp.str_str_len == 24 || - id2->lm_chal_resp.str_str_len == 0) && - id2->nt_chal_resp.str_str_len == 24 && - (((smb_pass->smb_nt_passwd != NULL) && - smb_password_check(id2->nt_chal_resp.buffer, smb_pass->smb_nt_passwd, - id2->lm_chal)) || - smb_password_check(id2->lm_chal_resp.buffer, smb_pass->smb_passwd, - id2->lm_chal))) + DEBUG(5,("net_login_network: lm_len: %d nt_len: %d\n", + id2->lm_chal_resp.str_str_len, + id2->nt_chal_resp.str_str_len)); + + /* check the lm password, first. */ + /* lkclXXXX this is not a good place to put disabling of LM hashes in. + if that is to be done, first move this entire function into a + library routine that calls the two smb_password_check() functions. + if disabling LM hashes (which nt can do for security reasons) then + an attempt should be made to disable them everywhere (which nt does + not do, for various security-hole reasons). + */ + + if (id2->lm_chal_resp.str_str_len == 24 && + smb_password_check(id2->lm_chal_resp.buffer, + smb_pass->smb_passwd, + id2->lm_chal)) + { + return 0x0; + } + + /* now check the nt password, if it exists */ + + if (id2->nt_chal_resp.str_str_len == 24 && + smb_pass->smb_nt_passwd != NULL && + smb_password_check(id2->nt_chal_resp.buffer, + smb_pass->smb_nt_passwd, + id2->lm_chal)) { return 0x0; } + + /* oops! neither password check succeeded */ + return 0xC0000000 | NT_STATUS_WRONG_PASSWORD; } @@ -577,21 +602,17 @@ static void api_net_sam_logon( int uid, case 1: { uni_samlogon_user = &(q_l.sam_id.ctr->auth.id1.uni_user_name); - pstrcpy(samlogon_user, unistrn2(uni_samlogon_user->buffer, - uni_samlogon_user->uni_str_len)); - DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. User:[%s]\n", - lp_workgroup(), samlogon_user)); + DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", + lp_workgroup())); break; } case 2: { uni_samlogon_user = &(q_l.sam_id.ctr->auth.id2.uni_user_name); - pstrcpy(samlogon_user, unistrn2(uni_samlogon_user->buffer, - uni_samlogon_user->uni_str_len)); - DEBUG(3,("SAM Logon (Network). Domain:[%s]. User:[%s]\n", - lp_workgroup(), samlogon_user)); + DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", + lp_workgroup())); break; } default: @@ -610,6 +631,8 @@ static void api_net_sam_logon( int uid, pstrcpy(samlogon_user, unistrn2(uni_samlogon_user->buffer, uni_samlogon_user->uni_str_len)); + DEBUG(3,("User:[%s]\n", samlogon_user)); + become_root(True); smb_pass = get_smbpwd_entry(samlogon_user, 0); unbecome_root(True); -- cgit From 77e4dd247863d02c30240a318f6cd8f82916e30d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 2 Apr 1998 01:07:53 +0000 Subject: Changed code to check NT password *first* - if it exists. The NT password is a higher quality password, and should always be looked at before the LM password, if available (sorry, Luke, just a minor change, the other changes you made were fine :-). Jeremy. (This used to be commit c1367bf5336485ceafd7125f608dc923ecebd32d) --- source3/rpc_server/srv_netlog.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 1b66b8061f..a08ea2395b 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -526,7 +526,20 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, id2->lm_chal_resp.str_str_len, id2->nt_chal_resp.str_str_len)); - /* check the lm password, first. */ + /* 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->nt_chal_resp.str_str_len == 24 && + smb_pass->smb_nt_passwd != NULL) + { + if(smb_password_check(id2->nt_chal_resp.buffer, + smb_pass->smb_nt_passwd, + id2->lm_chal)) + return 0x0; + else + return 0xC0000000 | NT_STATUS_WRONG_PASSWORD; + } + /* lkclXXXX this is not a good place to put disabling of LM hashes in. if that is to be done, first move this entire function into a library routine that calls the two smb_password_check() functions. @@ -543,16 +556,6 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, return 0x0; } - /* now check the nt password, if it exists */ - - if (id2->nt_chal_resp.str_str_len == 24 && - smb_pass->smb_nt_passwd != NULL && - smb_password_check(id2->nt_chal_resp.buffer, - smb_pass->smb_nt_passwd, - id2->lm_chal)) - { - return 0x0; - } /* oops! neither password check succeeded */ -- cgit From e300c0346ff92035ff9568b55b34469193e29769 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 10 Apr 1998 18:21:16 +0000 Subject: includes.h: Moved HPUX undefine of SEMMSL to where it actually does something. ipc.c: Added Luke's debug statement. locking_slow.c: Added FTRUNCATE_NEEDS_ROOT code for broken systems that need it (not sure what these are yet). membuffer.c ntdomain.h proto.h lib/rpc/include/rpc_dce.h lib/rpc/include/rpc_srvsvc.h lib/rpc/parse/parse_prs.c lib/rpc/parse/parse_rpc.c lib/rpc/server/srv_pipe_hnd.c lib/rpc/server/srv_util.c: Re-merge of Luke's NTDOM changes 'cos he's a lazy git with carpel tunnel syndrome :-). Jeremy. (This used to be commit 52e3966fbcf7b5fbdbc7cbe9ac0b453ab5bf3217) --- source3/rpc_server/srv_pipe_hnd.c | 26 +++++++++++++++++++++----- source3/rpc_server/srv_util.c | 17 ++++++++++------- 2 files changed, 31 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index e4893fee89..a371e48bfd 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -157,9 +157,10 @@ int read_pipe(uint16 pnum, char *data, uint32 pos, int n) if (OPEN_PNUM(pnum - PIPE_HANDLE_OFFSET)) { - int num; - int len; - uint32 rpc_frag_pos; + int num = 0; + int len = 0; + uint32 hdr_num = 0; + uint32 rpc_frag_pos = 0; DEBUG(6,("OK\n")); @@ -169,9 +170,14 @@ int read_pipe(uint16 pnum, char *data, uint32 pos, int n) return 0; } + DEBUG(6,("read_pipe: p: %p max_rdata_len: %d data_pos: %d num: %d\n", + p, p->max_rdata_len, data_pos, num)); + /* the read request starts from where the SMBtrans2 left off. */ data_pos += p->max_rdata_len; + rpc_frag_pos = data_pos % p->hdr.frag_len; + /* headers accumulate an offset */ data_pos -= p->hdr_offsets; @@ -182,22 +188,32 @@ int read_pipe(uint16 pnum, char *data, uint32 pos, int n) if (!IS_BITS_SET_ALL(p->hdr.flags, RPC_FLG_LAST)) { - rpc_frag_pos = data_pos % p->hdr.frag_len; + DEBUG(5,("read_pipe: hdr_offsets: %d rpc_frag_pos: %d frag_len: %d\n", + p->hdr_offsets, rpc_frag_pos, p->hdr.frag_len)); if (rpc_frag_pos == 0) { + /* this is subtracted from the total data bytes, later */ + hdr_num = 0x18; + /* create and copy in a new header. */ create_rpc_reply(p, data_pos, p->rdata.offset); mem_buf_copy(data, p->rhdr.data, 0, 0x18); /* make room in data stream for header */ p->hdr_offsets += 0x18; + data += 0x18; + + DEBUG(6,("read_pipe: hdr_offsets: %d\n", p->hdr_offsets)); } } if (num > 0) { - mem_buf_copy(data, p->rhdr.data, data_pos, num); + DEBUG(6,("read_pipe: adjusted data_pos: %d num: %d\n", + data_pos, num - hdr_num)); + mem_buf_copy(data, p->rhdr.data, data_pos, num - hdr_num); + return num; } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 7be259029a..3f4d66eab2 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -173,13 +173,16 @@ void get_domain_user_groups(char *domain_groups, char *user) BOOL create_rpc_reply(pipes_struct *p, uint32 data_start, uint32 data_end) { + DEBUG(5,("create_rpc_reply: data_start: %d data_end: %d max_tsize: %d\n", + data_start, data_end, p->hdr_ba.bba.max_tsize)); + mem_buf_init(&(p->rhdr.data), 0); mem_alloc_data(p->rhdr.data, 0x18); p->rhdr.align = 4; p->rhdr.io = False; - p->hdr_rr.alloc_hint = data_end - data_start; /* calculate remaining data to be sent */ + p->hdr_resp.alloc_hint = data_end - data_start; /* calculate remaining data to be sent */ p->hdr.pkt_type = RPC_RESPONSE; /* mark header as an rpc response */ /* set up rpc header (fragmentation issues) */ @@ -192,10 +195,10 @@ BOOL create_rpc_reply(pipes_struct *p, p->hdr.flags = 0; } - if (p->hdr_rr.alloc_hint + 0x18 <= p->hdr_ba.bba.max_tsize) + if (p->hdr_resp.alloc_hint + 0x18 <= p->hdr_ba.bba.max_tsize) { p->hdr.flags |= RPC_FLG_LAST; - p->hdr.frag_len = p->hdr_rr.alloc_hint + 0x18; + p->hdr.frag_len = p->hdr_resp.alloc_hint + 0x18; } else { @@ -208,7 +211,7 @@ BOOL create_rpc_reply(pipes_struct *p, /* store the header in the data stream */ p->rhdr.offset = 0; smb_io_rpc_hdr ("hdr", &(p->hdr ), &(p->rhdr), 0); - smb_io_rpc_hdr_rr("rr" , &(p->hdr_rr), &(p->rhdr), 0); + smb_io_rpc_hdr_resp("resp", &(p->hdr_resp), &(p->rhdr), 0); return p->rhdr.data != NULL && p->rhdr.offset == 0x18; } @@ -222,11 +225,11 @@ static BOOL api_rpc_command(pipes_struct *p, prs_struct *data) { int fn_num; - DEBUG(4,("api_rpc_command: %s op 0x%x - ", rpc_name, p->hdr_rr.opnum)); + DEBUG(4,("api_rpc_command: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) { - if (api_rpc_cmds[fn_num].opnum == p->hdr_rr.opnum && api_rpc_cmds[fn_num].fn != NULL) + if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) { DEBUG(3,("api_rpc_command: %s\n", api_rpc_cmds[fn_num].name)); break; @@ -280,7 +283,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds } /* read the rpc header */ - smb_io_rpc_hdr_rr("", &(p->hdr_rr), data, 0); + smb_io_rpc_hdr_req("req", &(p->hdr_req), data, 0); /* interpret the command */ if (!api_rpc_command(p, rpc_name, api_rpc_cmds, data)) -- cgit From 2a53d6f7077de596265a3e73e79827392054142c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 14 Apr 1998 00:41:59 +0000 Subject: Modified interfaces to getting smb password entries from get_smbpwd_entry (now an internal function to smbpass.c) to a more UNIX-like : getsmbpwnam() - get entry by name. getsmbpwuid() - get entry by uid. Changed the type returned by the smbpasswd enumeration functions to be a void * so that people don't come to depend on it being a FILE *. These abstractions should make it much easier to replace the smbpasswd file with a better backend in future. Other files changed are to match the above changes. Jeremy. (This used to be commit 1161cfb7f2b0d5a6d3e2b524a14a6f325ce70efb) --- source3/rpc_server/srv_netlog.c | 4 ++-- source3/rpc_server/srv_samr.c | 18 +++++++++--------- source3/rpc_server/srv_util.c | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index a08ea2395b..3912ad7938 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -238,7 +238,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) } become_root(True); - smb_pass = get_smbpwd_entry(mach_acct, 0); + smb_pass = getsmbpwnam(mach_acct); unbecome_root(True); if (smb_pass != NULL) @@ -637,7 +637,7 @@ static void api_net_sam_logon( int uid, DEBUG(3,("User:[%s]\n", samlogon_user)); become_root(True); - smb_pass = get_smbpwd_entry(samlogon_user, 0); + smb_pass = getsmbpwnam(samlogon_user); unbecome_root(True); if (smb_pass == NULL) diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 02c8cb0ffe..162d9c45d0 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -43,7 +43,7 @@ static BOOL get_smbpwd_entries(SAM_USER_INFO_21 *pw_buf, int max_num_entries, uint16 acb_mask) { - FILE *fp = NULL; + void *vp = NULL; struct smb_passwd *pwd = NULL; (*num_entries) = 0; @@ -51,14 +51,14 @@ static BOOL get_smbpwd_entries(SAM_USER_INFO_21 *pw_buf, if (pw_buf == NULL) return False; - fp = startsmbpwent(False); - if (!fp) + vp = startsmbpwent(False); + if (!vp) { DEBUG(0, ("get_smbpwd_entries: Unable to open SMB password file.\n")); return False; } - while (((pwd = getsmbpwent(fp)) != NULL) && (*num_entries) < max_num_entries) + while (((pwd = getsmbpwent(vp)) != NULL) && (*num_entries) < max_num_entries) { int user_name_len = strlen(pwd->smb_name); make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len); @@ -91,7 +91,7 @@ static BOOL get_smbpwd_entries(SAM_USER_INFO_21 *pw_buf, (*total_entries)++; } - endsmbpwent(fp); + endsmbpwent(vp); return (*num_entries) > 0; } @@ -806,7 +806,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, } become_root(True); - smb_pass = get_smbpwd_entry(NULL, q_u->user_rid); + smb_pass = getsmbpwuid(q_u->user_rid); unbecome_root(True); /* check that the RID exists in our domain. */ @@ -877,7 +877,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) struct smb_passwd *smb_pass; become_root(True); - smb_pass = get_smbpwd_entry(NULL, rid); + smb_pass = getsmbpwuid(rid); unbecome_root(True); if (smb_pass == NULL) @@ -1095,7 +1095,7 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, if (status == 0x0) { become_root(True); - smb_pass = get_smbpwd_entry(NULL, rid); + smb_pass = getsmbpwuid(rid); unbecome_root(True); if (smb_pass == NULL) @@ -1191,7 +1191,7 @@ static void api_samr_unknown_32( int uid, prs_struct *data, prs_struct *rdata) q_u.uni_mach_acct.uni_str_len)); become_root(True); - smb_pass = get_smbpwd_entry(mach_acct, 0); + smb_pass = getsmbpwnam(mach_acct); unbecome_root(True); if (smb_pass != NULL) diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 3f4d66eab2..868cf3a4ac 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -367,7 +367,7 @@ uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) /* find the user account */ become_root(True); - smb_pass = get_smbpwd_entry(NULL, rid); /* lkclXXXX SHOULD use rid mapping here! */ + smb_pass = getsmbpwuid(rid); /* lkclXXXX SHOULD use rid mapping here! */ unbecome_root(True); if (smb_pass != NULL) @@ -427,7 +427,7 @@ uint32 lookup_user_rid(char *user_name, uint32 *rid) /* find the user account */ become_root(True); - smb_pass = get_smbpwd_entry(user_name, 0); + smb_pass = getsmbpwnam(user_name); unbecome_root(True); if (smb_pass != NULL) -- cgit From 373d7c62577c13e1a85043844953a8d779858432 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 17 Apr 1998 19:29:51 +0000 Subject: Changing of machine passwords now works !!!!!! smbdes.c: Added cred_hash3. smbpasswd.c: Fixes for adding a machine account (needs more work). lib/rpc/server/srv_netlog.c: Turn on the machine password changing code by default (calls cred_hash3). Jeremy. (This used to be commit 50aa513b969c6e41911aeee8207b065f93af0beb) --- source3/rpc_server/srv_netlog.c | 58 ++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 3912ad7938..b87ecfc646 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -367,11 +367,9 @@ static void api_net_srv_pwset( int uid, NET_Q_SRV_PWSET q_a; uint32 status = NT_STATUS_WRONG_PASSWORD|0xC0000000; DOM_CRED srv_cred; -#ifdef ALLOW_SRV_PWSET pstring mach_acct; struct smb_passwd *smb_pass; BOOL ret; -#endif user_struct *vuser; if ((vuser = get_valid_user_struct(uid)) == NULL) return; @@ -387,47 +385,44 @@ static void api_net_srv_pwset( int uid, DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); -#ifdef ALLOW_SRV_PWSET - pstrcpy(mach_acct, unistrn2(q_a.clnt_id.login.uni_acct_name.buffer, q_a.clnt_id.login.uni_acct_name.uni_str_len)); DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); become_root(True); - smb_pass = get_smbpwd_entry(mach_acct, 0); + smb_pass = getsmbpwnam(mach_acct); unbecome_root(True); if (smb_pass != NULL) { - unsigned char pwd[16]; - uint8 mode = 2; + unsigned char pwd[16]; + int i; - memcpy(pwd, q_a.pwd, 16); + DEBUG(0,("Server password set : new given value was :\n")); + for(i = 0; i < 16; i++) + DEBUG(0,("%02X ", q_a.pwd[i])); + DEBUG(0,("\n")); - if (obfuscate_pwd(pwd, vuser->dc.sess_key, mode)) - { - /* 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; - - become_root(True); - ret = mod_smbpwd_entry(smb_pass); - unbecome_root(True); - - if (ret) - { - /* hooray! */ - status = 0x0; - } - } - } + cred_hash3( pwd, q_a.pwd, vuser->dc.sess_key); + + /* 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; + + become_root(True); + ret = mod_smbpwd_entry(smb_pass); + unbecome_root(True); + + if (ret) + { + /* hooray! */ + status = 0x0; + } + } DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); -#else - DEBUG(5,("api_net_srv_pwset: server password set being denied\n")); -#endif } else @@ -436,9 +431,8 @@ static void api_net_srv_pwset( int uid, status = 0xC0000000 | NT_STATUS_NETWORK_CREDENTIAL_CONFLICT; } - /* construct reply. always indicate failure. nt keeps going... */ - net_reply_srv_pwset(&q_a, rdata, - &srv_cred, status); + /* Construct reply. */ + net_reply_srv_pwset(&q_a, rdata, &srv_cred, status); } -- cgit From 6733e2b36e00ccbe8df363651ecc98ba42d53cee Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 18 Apr 1998 02:00:39 +0000 Subject: includes.h: Added John's redhat fix for QSORT_CAST. smbpass.c: Added lock depth code so calls to pw_file_lock() can be nested. Fixed codedump problems in add_smbpwd_entry(). smbpasswd.c: Removed all the code that manipulated the password file directly. Now *all* smbpasswd file changes are done through the interfaces defined in smbpass.c This should make the life of people adding alternate backend databases *much* easier. lib/rpc/server/srv_netlog.c: Removed debug messages used to debug machine password changing. Jeremy. (This used to be commit c9f61be08f3691a6421734d8b026a295d9cbd6ba) --- source3/rpc_server/srv_netlog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index b87ecfc646..c8386d4724 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -399,10 +399,10 @@ static void api_net_srv_pwset( int uid, unsigned char pwd[16]; int i; - DEBUG(0,("Server password set : new given value was :\n")); + DEBUG(100,("Server password set : new given value was :\n")); for(i = 0; i < 16; i++) - DEBUG(0,("%02X ", q_a.pwd[i])); - DEBUG(0,("\n")); + DEBUG(100,("%02X ", q_a.pwd[i])); + DEBUG(100,("\n")); cred_hash3( pwd, q_a.pwd, vuser->dc.sess_key); -- cgit From 2beb8f3cb5437cb2b214c9be0c919c1b3988a857 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 20 Apr 1998 23:57:29 +0000 Subject: genrand.c: Improved filename based random seed generation. lib/rpc/server/srv_netlog.c: Changed to use generate_random_buffer(). Jeremy. (This used to be commit 093d060a06d75c6ee5b1329d524334f4db97cba6) --- source3/rpc_server/srv_netlog.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index c8386d4724..cbe35e5202 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -289,10 +289,9 @@ static void api_net_req_chal( int uid, memcpy(vuser->dc.clnt_cred.challenge.data, q_r.clnt_chal.data, sizeof(q_r.clnt_chal.data)); /* create a server challenge for the client */ - /* PAXX: set these to random values. */ - /* lkcl: paul, you mentioned that it doesn't really matter much */ - SIVAL(vuser->dc.srv_chal.data, 0, 0x11111111); - SIVAL(vuser->dc.srv_chal.data, 4, 0x11111111); + /* Set these to random values. */ + generate_random_buffer(vuser->dc.srv_chal.data, 8, False); + memcpy(vuser->dc.srv_cred.challenge.data, vuser->dc.srv_chal.data, 8); bzero(vuser->dc.sess_key, sizeof(vuser->dc.sess_key)); -- cgit From 76d3bc36a5ce13d2a7bd08f9c18b2cfd0ab0210f Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 21 Apr 1998 02:36:37 +0000 Subject: put server-side long dce/rpc code in main branch. (This used to be commit 2e1a08b28c1c0c9ea988a09067cd149926f25c69) --- source3/rpc_server/srv_pipe_hnd.c | 89 +++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 28 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index a371e48bfd..7ab2b3aec6 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -81,8 +81,10 @@ void init_rpc_pipe_hnd(void) Pipes[i].rhdr.offset = 0; Pipes[i].rdata.offset = 0; - Pipes[i].max_rdata_len = 0; - Pipes[i].hdr_offsets = 0; + Pipes[i].file_offset = 0; + Pipes[i].hdr_offsets = 0; + Pipes[i].frag_len_left = 0; + Pipes[i].next_frag_start = 0; } return; @@ -110,8 +112,10 @@ int open_rpc_pipe_hnd(char *pipe_name, int cnum, uint16 vuid) Pipes[i].rhdr.offset = 0; Pipes[i].rdata.offset = 0; - Pipes[i].max_rdata_len = 0; - Pipes[i].hdr_offsets = 0; + Pipes[i].file_offset = 0; + Pipes[i].hdr_offsets = 0; + Pipes[i].frag_len_left = 0; + Pipes[i].next_frag_start = 0; fstrcpy(Pipes[i].name, pipe_name); @@ -134,7 +138,7 @@ int open_rpc_pipe_hnd(char *pipe_name, int cnum, uint16 vuid) headers are interspersed with the data at regular intervals. by the time this function is called, the start of the data could possibly have been - read by an SMBtrans (max_rdata_len != 0). + read by an SMBtrans (file_offset != 0). calling create_rpc_request() here is a fudge. the data should already have been prepared into arrays of headers + data stream sections. @@ -142,13 +146,14 @@ int open_rpc_pipe_hnd(char *pipe_name, int cnum, uint16 vuid) ****************************************************************************/ int read_pipe(uint16 pnum, char *data, uint32 pos, int n) { - int data_pos = pos; + int data_hdr_pos; + int data_pos; pipes_struct *p = &Pipes[pnum - PIPE_HANDLE_OFFSET]; DEBUG(6,("read_pipe: %x", pnum)); if (VALID_PNUM(pnum - PIPE_HANDLE_OFFSET)) { - DEBUG(6,("name: %s cnum: %d open: %s data_pos: %lx len: %lx", + DEBUG(6,("name: %s cnum: %d open: %s data_pos: %d len: %d", p->name, p->cnum, BOOLSTR(p->open), @@ -160,7 +165,6 @@ int read_pipe(uint16 pnum, char *data, uint32 pos, int n) int num = 0; int len = 0; uint32 hdr_num = 0; - uint32 rpc_frag_pos = 0; DEBUG(6,("OK\n")); @@ -170,29 +174,38 @@ int read_pipe(uint16 pnum, char *data, uint32 pos, int n) return 0; } - DEBUG(6,("read_pipe: p: %p max_rdata_len: %d data_pos: %d num: %d\n", - p, p->max_rdata_len, data_pos, num)); + DEBUG(6,("read_pipe: p: %p file_offset: %d file_pos: %d\n", + p, p->file_offset, n)); + DEBUG(6,("read_pipe: frag_len_left: %d next_frag_start: %d\n", + p->frag_len_left, p->next_frag_start)); /* the read request starts from where the SMBtrans2 left off. */ - data_pos += p->max_rdata_len; - - rpc_frag_pos = data_pos % p->hdr.frag_len; - - /* headers accumulate an offset */ - data_pos -= p->hdr_offsets; + data_pos = p->file_offset - p->hdr_offsets; + data_hdr_pos = p->file_offset; len = mem_buf_len(p->rhdr.data); num = len - (int)data_pos; + DEBUG(6,("read_pipe: len: %d num: %d n: %d\n", len, num, n)); + if (num > n) num = n; + if (num <= 0) + { + DEBUG(5,("read_pipe: 0 or -ve data length\n")); + return 0; + } if (!IS_BITS_SET_ALL(p->hdr.flags, RPC_FLG_LAST)) { - DEBUG(5,("read_pipe: hdr_offsets: %d rpc_frag_pos: %d frag_len: %d\n", - p->hdr_offsets, rpc_frag_pos, p->hdr.frag_len)); + /* intermediate fragment - possibility of another header */ + + DEBUG(5,("read_pipe: frag_len: %d data_pos: %d data_hdr_pos: %d\n", + p->hdr.frag_len, data_pos, data_hdr_pos)); - if (rpc_frag_pos == 0) + if (data_hdr_pos == p->next_frag_start) { + DEBUG(6,("read_pipe: next fragment header\n")); + /* this is subtracted from the total data bytes, later */ hdr_num = 0x18; @@ -200,24 +213,44 @@ int read_pipe(uint16 pnum, char *data, uint32 pos, int n) create_rpc_reply(p, data_pos, p->rdata.offset); mem_buf_copy(data, p->rhdr.data, 0, 0x18); - /* make room in data stream for header */ - p->hdr_offsets += 0x18; data += 0x18; + p->frag_len_left = p->hdr.frag_len; + p->next_frag_start += p->hdr.frag_len; + p->hdr_offsets += 0x18; - DEBUG(6,("read_pipe: hdr_offsets: %d\n", p->hdr_offsets)); + /*DEBUG(6,("read_pipe: hdr_offsets: %d\n", p->hdr_offsets));*/ } } - if (num > 0) + if (num < hdr_num) { - DEBUG(6,("read_pipe: adjusted data_pos: %d num: %d\n", - data_pos, num - hdr_num)); - mem_buf_copy(data, p->rhdr.data, data_pos, num - hdr_num); + DEBUG(5,("read_pipe: warning - data read only part of a header\n")); + } + + DEBUG(6,("read_pipe: adjusted data_pos: %d num-hdr_num: %d\n", + data_pos, num - hdr_num)); + mem_buf_copy(data, p->rhdr.data, data_pos, num - hdr_num); + + data_pos += num; + data_hdr_pos += num; + + if (hdr_num == 0x18 && num == 0x18) + { + DEBUG(6,("read_pipe: just header read\n")); - return num; + /* advance to the next fragment */ + p->frag_len_left -= 0x18; } + else if (data_hdr_pos == p->next_frag_start) + { + DEBUG(6,("read_pipe: next fragment expected\n")); + + /* advance to the next fragment */ + } + + p->file_offset += num; - return 0; + return num; } else -- cgit From da4e61efad7c7c18595bec32dbb21a2045dadd2e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 22 Apr 1998 17:59:44 +0000 Subject: Fixed bug found by Gerald Carter where global myname was being overwritten incorrectly. Jeremy. (This used to be commit a3e7cf1b8a2fc950d41f5f2d5318cf88874165cd) --- source3/rpc_server/srv_netlog.c | 2 -- source3/rpc_server/srv_srvsvc.c | 1 - source3/rpc_server/srv_wkssvc.c | 1 - 3 files changed, 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index cbe35e5202..83e590a14b 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -693,8 +693,6 @@ static void api_net_sam_logon( int uid, dummy_time.low = 0xffffffff; dummy_time.high = 0x7fffffff; - get_myname(myname, NULL); - /* 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; diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 285ea89657..236b70dc82 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -859,7 +859,6 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, SRV_INFO_CTR ctr; extern pstring myname; - get_myname(myname,NULL); DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 3dd273f784..8a8647d0a9 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -40,7 +40,6 @@ static void create_wks_info_100(WKS_INFO_100 *inf) DEBUG(5,("create_wks_info_100: %d\n", __LINE__)); - get_myname(myname, NULL); pstrcpy (my_name, myname); strupper(my_name); -- cgit From 30675f81f60bab24f47758baab8316d4467709ef Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 23 Apr 1998 22:59:19 +0000 Subject: Makefile: Added nterr.c into the mix. clientgen.c: Added nt_error as an entry in the struct client_state. password.c: Open the netlogon pipe. smb.h: Added nt_error as an entry in the struct client_state. lib/rpc/parse/parse_net.c: Added comments on net logon. lib/rpc/server/srv_netlog.c: Added comments on net logon. Jeremy. (This used to be commit 899a9f0dce50c73e03c8da2ebe920957491c8ad7) --- source3/rpc_server/srv_netlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 83e590a14b..eb4dfb4a26 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -647,7 +647,7 @@ static void api_net_sam_logon( int uid, { case 1: { - /* interactive login. passwords arcfour'd with session key */ + /* interactive login. */ status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, smb_pass, vuser); break; -- cgit From 9189005f7f884123d29c8f27db73687b68c80bb9 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 24 Apr 1998 21:01:08 +0000 Subject: ABOUT time. dce/rpc long packet format now works, server-side. turns out that [it can be deduced that] microsoft ignores the SMBreadX offset, and goes by the SMBreadX length only. this makes for a lot simpler code, in both client and server. (This used to be commit a8b641c027c8cce179455ac1f6fd0322a8ab017d) --- source3/rpc_server/srv_pipe_hnd.c | 2 - source3/rpc_server/srv_util.c | 93 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 90 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 7ab2b3aec6..95aa46fd9a 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -244,8 +244,6 @@ int read_pipe(uint16 pnum, char *data, uint32 pos, int n) else if (data_hdr_pos == p->next_frag_start) { DEBUG(6,("read_pipe: next fragment expected\n")); - - /* advance to the next fragment */ } p->file_offset += num; diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 868cf3a4ac..90a811e490 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -61,6 +61,14 @@ rid_name domain_alias_rids[] = { 0 , NULL } }; +/* array lookup of well-known Domain RID users. */ +rid_name domain_user_rids[] = +{ + { DOMAIN_USER_RID_ADMIN , "Administrator" }, + { DOMAIN_USER_RID_GUEST , "Guest" }, + { 0 , NULL } +}; + /* array lookup of well-known Domain RID groups. */ rid_name domain_group_rids[] = { @@ -297,6 +305,9 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds return False; } + p->frag_len_left = p->hdr.frag_len - p->file_offset; + p->next_frag_start = p->hdr.frag_len; + /* set up the data chain */ p->rhdr.data->offset.start = 0; p->rhdr.data->offset.end = p->rhdr.offset; @@ -319,6 +330,8 @@ uint32 lookup_group_name(uint32 rid, char *group_name, uint32 *type) int i = 0; (*type) = SID_NAME_DOM_GRP; + DEBUG(5,("lookup_group_name: rid: %d", rid)); + while (domain_group_rids[i].rid != rid && domain_group_rids[i].rid != 0) { i++; @@ -327,9 +340,11 @@ uint32 lookup_group_name(uint32 rid, char *group_name, uint32 *type) if (domain_group_rids[i].rid != 0) { fstrcpy(group_name, domain_group_rids[i].name); + DEBUG(5,(" = %s\n", group_name)); return 0x0; } + DEBUG(5,(" none mapped\n")); return 0xC0000000 | NT_STATUS_NONE_MAPPED; } @@ -343,6 +358,8 @@ uint32 lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) int i = 0; (*type) = SID_NAME_WKN_GRP; + DEBUG(5,("lookup_alias_name: rid: %d", rid)); + while (domain_alias_rids[i].rid != rid && domain_alias_rids[i].rid != 0) { i++; @@ -351,9 +368,11 @@ uint32 lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) if (domain_alias_rids[i].rid != 0) { fstrcpy(alias_name, domain_alias_rids[i].name); + DEBUG(5,(" = %s\n", alias_name)); return 0x0; } + DEBUG(5,(" none mapped\n")); return 0xC0000000 | NT_STATUS_NONE_MAPPED; } @@ -363,9 +382,30 @@ uint32 lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) { struct smb_passwd *smb_pass; + uint32 unix_uid; + int i = 0; (*type) = SID_NAME_USER; - /* find the user account */ + DEBUG(5,("lookup_user_name: rid: %d", rid)); + + /* look up the well-known domain user rids first */ + while (domain_user_rids[i].rid != rid && domain_user_rids[i].rid != 0) + { + i++; + } + + if (domain_user_rids[i].rid != 0) + { + fstrcpy(user_name, domain_user_rids[i].name); + DEBUG(5,(" = %s\n", user_name)); + return 0x0; + } + + DEBUG(5,(" uid: %d", unix_uid)); + + unix_uid = uid_to_user_rid(rid); + + /* ok, it's a user. find the user account */ become_root(True); smb_pass = getsmbpwuid(rid); /* lkclXXXX SHOULD use rid mapping here! */ unbecome_root(True); @@ -373,9 +413,11 @@ uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) if (smb_pass != NULL) { fstrcpy(user_name, smb_pass->smb_name); + DEBUG(5,(" = %s\n", user_name)); return 0x0; } + DEBUG(5,(" none mapped\n")); return 0xC0000000 | NT_STATUS_NONE_MAPPED; } @@ -470,11 +512,56 @@ BOOL name_to_rid(char *user_name, uint32 *u_rid, uint32 *g_rid) { /* turn the unix UID into a Domain RID. this is what the posix sub-system does (adds 1000 to the uid) */ - *u_rid = (uint32)(pw->pw_uid + 1000); + *u_rid = uid_to_user_rid(pw->pw_uid); } /* absolutely no idea what to do about the unix GID to Domain RID mapping */ - *g_rid = (uint32)(pw->pw_gid + 1000); + *g_rid = gid_to_group_rid(pw->pw_gid); return True; } + +/******************************************************************* + XXXX THIS FUNCTION SHOULD NOT BE HERE: IT SHOULD BE A STATIC FUNCTION + INSIDE smbpass.c + + converts NT User RID to a UNIX uid. + ********************************************************************/ +uid_t user_rid_to_uid(uint32 u_rid) +{ + return (uid_t)(u_rid - 1000); +} + +/******************************************************************* + XXXX THIS FUNCTION SHOULD NOT BE HERE: IT SHOULD BE A STATIC FUNCTION + INSIDE smbpass.c + + converts NT Group RID to a UNIX uid. + ********************************************************************/ +uid_t group_rid_to_uid(uint32 u_gid) +{ + return (uid_t)(u_gid - 1000); +} + +/******************************************************************* + XXXX THIS FUNCTION SHOULD NOT BE HERE: IT SHOULD BE A STATIC FUNCTION + INSIDE smbpass.c + + converts UNIX uid to an NT User RID. + ********************************************************************/ +uint32 uid_to_user_rid(uint32 uid) +{ + return (uint32)(uid + 1000); +} + +/******************************************************************* + XXXX THIS FUNCTION SHOULD NOT BE HERE: IT SHOULD BE A STATIC FUNCTION + INSIDE smbpass.c + + converts NT Group RID to a UNIX uid. + ********************************************************************/ +uint32 gid_to_group_rid(uint32 gid) +{ + return (uint32)(gid + 1000); +} + -- cgit From e7ac86607c80912e55ac7179b100cea22749c16f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 25 Apr 1998 01:12:08 +0000 Subject: This looks like a big change but really isn't. It is changing the global variables "myname" and "myworkgroup" to "global_myname" and "global_myworkgroup" respectively. This is to make it very explicit when we are messing with a global (don't ask - it makes the domain client code much clearer :-). Jeremy. (This used to be commit 866406bfe399cf757c8275093dacd5ce4843afa0) --- source3/rpc_server/srv_netlog.c | 6 ++---- source3/rpc_server/srv_srvsvc.c | 7 +++---- source3/rpc_server/srv_wkssvc.c | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index eb4dfb4a26..6aa1cd707e 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -30,8 +30,7 @@ extern int DEBUGLEVEL; extern BOOL sam_logon_in_ssb; extern pstring samlogon_user; - - +extern pstring global_myname; /************************************************************************* make_net_r_req_chal: @@ -683,7 +682,6 @@ static void api_net_sam_logon( int uid, pstring domain_groups; pstring dom_sid; pstring other_sids; - extern pstring myname; uint32 r_uid; uint32 r_gid; @@ -706,7 +704,7 @@ static void api_net_sam_logon( int uid, pstrcpy(home_drive , lp_logon_drive ()); pstrcpy(home_dir , lp_logon_home ()); - pstrcpy(my_name , myname ); + pstrcpy(my_name , global_myname ); strupper(my_name); get_domain_user_groups(domain_groups, samlogon_user); diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 236b70dc82..d06e2ac660 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -27,7 +27,7 @@ #include "nterr.h" extern int DEBUGLEVEL; - +extern pstring global_myname; /******************************************************************* fill in a share info level 1 structure. @@ -858,7 +858,6 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, uint32 status = 0x0; SRV_INFO_CTR ctr; - extern pstring myname; DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); @@ -867,7 +866,7 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, case 102: { make_srv_info_102(&ctr.srv.sv102, - 500, myname, lp_serverstring(), + 500, global_myname, lp_serverstring(), 5, 4, /* major/minor version - NT 5.4 :-) */ 0x4100b, /* browsing stuff SV_TYPE_XXXX */ 0xffffffff, /* users */ @@ -882,7 +881,7 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, case 101: { make_srv_info_101(&ctr.srv.sv101, - 500, myname, + 500, global_myname, 5, 4, /* major/minor version - NT 5.4 :-) */ 0x4100b, /* browsing stuff SV_TYPE_XXXX */ lp_serverstring()); diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 8a8647d0a9..5bea006b2c 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -27,6 +27,7 @@ #include "nterr.h" extern int DEBUGLEVEL; +extern pstring global_myname; /******************************************************************* @@ -34,13 +35,12 @@ extern int DEBUGLEVEL; ********************************************************************/ static void create_wks_info_100(WKS_INFO_100 *inf) { - extern pstring myname; pstring my_name; pstring domain; DEBUG(5,("create_wks_info_100: %d\n", __LINE__)); - pstrcpy (my_name, myname); + pstrcpy (my_name, global_myname); strupper(my_name); pstrcpy (domain , lp_workgroup()); -- cgit From d3832506b2583130c4f4ba4b3edeabca987b7cbb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 29 Apr 1998 00:02:57 +0000 Subject: This is the checkin that adds the security=domain functionality. WARNING - so far this has only been tested against a Samba PDC (still waiting for IS to add me the machine accounts :-). Still missing is the code in smbpasswd that will add a machine account password and change it on the domain controller, but this is not hard, and I will check it in soon. Jeremy. (This used to be commit 17b94a7084621b3f0106dd4d3386f05cdfc56d19) --- source3/rpc_server/srv_netlog.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 6aa1cd707e..1f76d545f6 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -383,14 +383,14 @@ static void api_net_srv_pwset( int uid, DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); - pstrcpy(mach_acct, unistrn2(q_a.clnt_id.login.uni_acct_name.buffer, - q_a.clnt_id.login.uni_acct_name.uni_str_len)); + pstrcpy(mach_acct, unistrn2(q_a.clnt_id.login.uni_acct_name.buffer, + q_a.clnt_id.login.uni_acct_name.uni_str_len)); - DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); + DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); - become_root(True); - smb_pass = getsmbpwnam(mach_acct); - unbecome_root(True); + become_root(True); + smb_pass = getsmbpwnam(mach_acct); + unbecome_root(True); if (smb_pass != NULL) { @@ -402,7 +402,7 @@ static void api_net_srv_pwset( int uid, DEBUG(100,("%02X ", q_a.pwd[i])); DEBUG(100,("\n")); - cred_hash3( pwd, q_a.pwd, vuser->dc.sess_key); + cred_hash3( pwd, q_a.pwd, vuser->dc.sess_key, 1); /* lies! nt and lm passwords are _not_ the same: don't care */ smb_pass->smb_passwd = pwd; @@ -515,13 +515,13 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, user_struct *vuser) { DEBUG(5,("net_login_network: lm_len: %d nt_len: %d\n", - id2->lm_chal_resp.str_str_len, - id2->nt_chal_resp.str_str_len)); + id2->hdr_lm_chal_resp.str_str_len, + id2->hdr_nt_chal_resp.str_str_len)); /* 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->nt_chal_resp.str_str_len == 24 && + if (id2->hdr_nt_chal_resp.str_str_len == 24 && smb_pass->smb_nt_passwd != NULL) { if(smb_password_check(id2->nt_chal_resp.buffer, @@ -540,7 +540,7 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, not do, for various security-hole reasons). */ - if (id2->lm_chal_resp.str_str_len == 24 && + if (id2->hdr_lm_chal_resp.str_str_len == 24 && smb_password_check(id2->lm_chal_resp.buffer, smb_pass->smb_passwd, id2->lm_chal)) -- cgit From 90177708aaf5bf17d689979701b5f0156b8a2fa4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 29 Apr 1998 22:27:26 +0000 Subject: Makefile: Added files to smbpasswd.c. loadparm.c: Patch from tim@quiknet.com for static string problems. server.c: Setup global_myname. smbpass.c: Fix up locking. Add machine_password_delete() call. smbpasswd.c: Added provisional code to add to a domain. lib/rpc/client/cli_login.c: Fixed incorrect cred_hash3 call when setting machine password. lib/rpc/server/srv_netlog.c: Fixed incorrect cred_hash3 call when setting machine password. Jeremy. (This used to be commit 6a7164233e3bf9d6bb57c44a53204068e454ae5c) --- source3/rpc_server/srv_netlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 1f76d545f6..743e4477a6 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -402,7 +402,7 @@ static void api_net_srv_pwset( int uid, DEBUG(100,("%02X ", q_a.pwd[i])); DEBUG(100,("\n")); - cred_hash3( pwd, q_a.pwd, vuser->dc.sess_key, 1); + cred_hash3( pwd, q_a.pwd, vuser->dc.sess_key, 0); /* lies! nt and lm passwords are _not_ the same: don't care */ smb_pass->smb_passwd = pwd; -- cgit From 3eae1e3f8e53c51f638b1b381085f29feea1c517 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 30 Apr 1998 01:39:22 +0000 Subject: Added patch from Bruce Tenison to allow encrypted passwords to be stored over time, allowing a smbpasswd file migration. Adds new parameter "update encrypted". Will also add to 1.9.18 branch. Docs update to follow. Jeremy. (This used to be commit 5d3e874d780d595415cc27a7f5945fc2e694c3ac) --- source3/rpc_server/srv_netlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 743e4477a6..6229d5ea0b 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -410,7 +410,7 @@ static void api_net_srv_pwset( int uid, smb_pass->acct_ctrl = ACB_WSTRUST; become_root(True); - ret = mod_smbpwd_entry(smb_pass); + ret = mod_smbpwd_entry(smb_pass,False); unbecome_root(True); if (ret) -- cgit From f601e6e0484d77d2c43eab05f80bccf28c9055aa Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 5 May 1998 09:04:49 +0000 Subject: patches from jean francois: couple of minor bugs (This used to be commit 532b3956c66eda1b7e787b1c6906bcf574f66216) --- source3/rpc_server/srv_util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 90a811e490..898269dc4a 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -401,9 +401,8 @@ uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) return 0x0; } - DEBUG(5,(" uid: %d", unix_uid)); - unix_uid = uid_to_user_rid(rid); + DEBUG(5,(" uid: %d", unix_uid)); /* ok, it's a user. find the user account */ become_root(True); -- cgit From 4ff2a51c1571c38412ea0a890eb0ab6d57085a78 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 6 May 1998 12:11:35 +0000 Subject: compiler warning for unimportant uninitialised variable (This used to be commit 81bf26309248b63cc7e167170a8b384c11126ded) --- source3/rpc_server/srv_pipe_hnd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 95aa46fd9a..8abfb54c8f 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -146,18 +146,16 @@ int open_rpc_pipe_hnd(char *pipe_name, int cnum, uint16 vuid) ****************************************************************************/ int read_pipe(uint16 pnum, char *data, uint32 pos, int n) { - int data_hdr_pos; - int data_pos; pipes_struct *p = &Pipes[pnum - PIPE_HANDLE_OFFSET]; DEBUG(6,("read_pipe: %x", pnum)); if (VALID_PNUM(pnum - PIPE_HANDLE_OFFSET)) { - DEBUG(6,("name: %s cnum: %d open: %s data_pos: %d len: %d", + DEBUG(6,("name: %s cnum: %d open: %s pos: %d len: %d", p->name, p->cnum, BOOLSTR(p->open), - data_pos, n)); + pos, n)); } if (OPEN_PNUM(pnum - PIPE_HANDLE_OFFSET)) @@ -165,6 +163,8 @@ int read_pipe(uint16 pnum, char *data, uint32 pos, int n) int num = 0; int len = 0; uint32 hdr_num = 0; + int data_hdr_pos; + int data_pos; DEBUG(6,("OK\n")); -- cgit From 5fa8775d9758254f6f4784a0e34c9b5b8bf18bdb Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 6 May 1998 17:43:44 +0000 Subject: jean-francois micouleau's well-alpha code for ldap password database stuff! he's going to hate me for checking this in so early, but... (This used to be commit ad9ba0a1cbac5c4e6cbcbcadefe8f1df72231f74) --- source3/rpc_server/srv_ldap_helpers.c | 162 ++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_samr.c | 126 +++++++++++++++----------- 2 files changed, 236 insertions(+), 52 deletions(-) create mode 100644 source3/rpc_server/srv_ldap_helpers.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ldap_helpers.c b/source3/rpc_server/srv_ldap_helpers.c new file mode 100644 index 0000000000..d1c091c6c9 --- /dev/null +++ b/source3/rpc_server/srv_ldap_helpers.c @@ -0,0 +1,162 @@ +#ifdef USE_LDAP + +#include "includes.h" +#include "lber.h" +#include "ldap.h" + +extern int DEBUGLEVEL; + +/******************************************************************* + find a user or a machine return a smbpass struct. +******************************************************************/ +static void make_ldap_sam_user_info_21(LDAP *ldap_struct, LDAPMessage *entry, SAM_USER_INFO_21 *user) +{ + pstring cn; + pstring fullname; + pstring home_dir; + pstring dir_drive; + pstring logon_script; + pstring profile_path; + pstring acct_desc; + pstring workstations; + pstring temp; + + if (ldap_check_user(ldap_struct, entry)==True) + { + get_single_attribute(ldap_struct, entry, "cn", cn); + get_single_attribute(ldap_struct, entry, "userFullName", fullname); + get_single_attribute(ldap_struct, entry, "homeDirectory", home_dir); + get_single_attribute(ldap_struct, entry, "homeDrive", dir_drive); + get_single_attribute(ldap_struct, entry, "scriptPath", logon_script); + get_single_attribute(ldap_struct, entry, "profilePath", profile_path); + get_single_attribute(ldap_struct, entry, "comment", acct_desc); + get_single_attribute(ldap_struct, entry, "userWorkstations", workstations); + + get_single_attribute(ldap_struct, entry, "rid", temp); + user->user_rid=atoi(temp); + get_single_attribute(ldap_struct, entry, "primaryGroupID", temp); + user->group_rid=atoi(temp); + get_single_attribute(ldap_struct, entry, "controlAccessRights", temp); + user->acb_info=atoi(temp); + + make_unistr2(&(user->uni_user_name), cn, strlen(cn)); + make_uni_hdr(&(user->hdr_user_name), strlen(cn), strlen(cn), 1); + make_unistr2(&(user->uni_full_name), fullname, strlen(fullname)); + make_uni_hdr(&(user->hdr_full_name), strlen(fullname), strlen(fullname), 1); + make_unistr2(&(user->uni_home_dir), home_dir, strlen(home_dir)); + make_uni_hdr(&(user->hdr_home_dir), strlen(home_dir), strlen(home_dir), 1); + make_unistr2(&(user->uni_dir_drive), dir_drive, strlen(dir_drive)); + make_uni_hdr(&(user->hdr_dir_drive), strlen(dir_drive), strlen(dir_drive), 1); + make_unistr2(&(user->uni_logon_script), logon_script, strlen(logon_script)); + make_uni_hdr(&(user->hdr_logon_script), strlen(logon_script), strlen(logon_script), 1); + make_unistr2(&(user->uni_profile_path), profile_path, strlen(profile_path)); + make_uni_hdr(&(user->hdr_profile_path), strlen(profile_path), strlen(profile_path), 1); + make_unistr2(&(user->uni_acct_desc), acct_desc, strlen(acct_desc)); + make_uni_hdr(&(user->hdr_acct_desc), strlen(acct_desc), strlen(acct_desc), 1); + make_unistr2(&(user->uni_workstations), workstations, strlen(workstations)); + make_uni_hdr(&(user->hdr_workstations), strlen(workstations), strlen(workstations), 1); + } +} + +/******************************************************************* + find a user or a machine return a smbpass struct. +******************************************************************/ +BOOL get_ldap_entries(SAM_USER_INFO_21 *pw_buf, + int *total_entries, int *num_entries, + int max_num_entries, + uint16 acb_mask, int switch_level) +{ + LDAP *ldap_struct; + LDAPMessage *result; + LDAPMessage *entry; + + int scope = LDAP_SCOPE_ONELEVEL; + int rc; + + char filter[256]; + + (*num_entries) = 0; + (*total_entries) = 0; + + if (!ldap_open_connection(&ldap_struct)) /* open a connection to the server */ + return (False); + + if (!ldap_connect_system(ldap_struct)) /* connect as system account */ + return (False); + + + /* when the class is known the search is much faster */ + switch (switch_level) + { + case 1: strcpy(filter, "objectclass=sambaAccount"); + break; + case 2: strcpy(filter, "objectclass=sambaMachine"); + break; + default: strcpy(filter, "(|(objectclass=sambaMachine)(objectclass=sambaAccount))"); + break; + } + + rc=ldap_search_s(ldap_struct, lp_ldap_suffix(), scope, filter, NULL, 0, &result); + + DEBUG(2,("%d entries in the base!\n", ldap_count_entries(ldap_struct, result) )); + + for ( entry = ldap_first_entry(ldap_struct, result); + (entry != NULL) && (*num_entries) < max_num_entries; + entry = ldap_next_entry(ldap_struct, entry) ) + { + make_ldap_sam_user_info_21(ldap_struct, entry, &(pw_buf[(*num_entries)]) ); + + if (acb_mask == 0 || IS_BITS_SET_SOME(pw_buf[(*num_entries)].acb_info, 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)++; + } + + ldap_msgfree(result); + ldap_unbind(ldap_struct); + return (*num_entries) > 0; +} + +BOOL ldap_get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) +{ + LDAP *ldap_struct; + LDAPMessage *result; + LDAPMessage *entry; + + if (!ldap_open_connection(&ldap_struct)) + return (False); + if (!ldap_connect_system(ldap_struct)) + return (False); + + if (!ldap_search_one_user_by_uid(ldap_struct, rid, &result)) + return (False); + + if (ldap_count_entries(ldap_struct, result) == 0) + { + DEBUG(2,("%s: Non existant user!\n", timestring() )); + return (False); + } + + if (ldap_count_entries(ldap_struct, result) > 1) + { + DEBUG(2,("%s: Strange %d users in the base!\n", + timestring(), ldap_count_entries(ldap_struct, result) )); + } + /* take the first and unique entry */ + entry=ldap_first_entry(ldap_struct, result); + + make_ldap_sam_user_info_21(ldap_struct, entry, id21); + + ldap_msgfree(result); + ldap_unbind(ldap_struct); + return(True); +} + +#endif diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 162d9c45d0..aa240ad3c6 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -45,55 +45,55 @@ static BOOL get_smbpwd_entries(SAM_USER_INFO_21 *pw_buf, { void *vp = NULL; struct smb_passwd *pwd = NULL; - - (*num_entries) = 0; - (*total_entries) = 0; - - if (pw_buf == NULL) return False; - - vp = startsmbpwent(False); - if (!vp) - { - DEBUG(0, ("get_smbpwd_entries: Unable to open SMB password file.\n")); - return False; - } - - while (((pwd = getsmbpwent(vp)) != NULL) && (*num_entries) < max_num_entries) - { - int user_name_len = strlen(pwd->smb_name); - make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len); - make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len, - user_name_len, 1); - pw_buf[(*num_entries)].user_rid = pwd->smb_userid; - bzero( pw_buf[(*num_entries)].nt_pwd , 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); - } - - pw_buf[(*num_entries)].acb_info = (uint16)pwd->acct_ctrl; - - DEBUG(5, ("get_smbpwd_entries: idx: %d user %s, uid %d, acb %x", - (*num_entries), pwd->smb_name, pwd->smb_userid, pwd->acct_ctrl)); - - if (acb_mask == 0 || IS_BITS_SET_SOME(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)++; - } - - endsmbpwent(vp); - - return (*num_entries) > 0; + + (*num_entries) = 0; + (*total_entries) = 0; + + if (pw_buf == NULL) return False; + + vp = startsmbpwent(False); + if (!vp) + { + DEBUG(0, ("get_smbpwd_entries: Unable to open SMB password file.\n")); + return False; + } + + while (((pwd = getsmbpwent(vp)) != NULL) && (*num_entries) < max_num_entries) + { + int user_name_len = strlen(pwd->smb_name); + make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len-1); + make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len-1, + user_name_len-1, 1); + pw_buf[(*num_entries)].user_rid = pwd->smb_userid; + bzero( pw_buf[(*num_entries)].nt_pwd , 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); + } + + pw_buf[(*num_entries)].acb_info = (uint16)pwd->acct_ctrl; + + DEBUG(5, ("get_smbpwd_entries: idx: %d user %s, uid %d, acb %x", + (*num_entries), pwd->smb_name, pwd->smb_userid, pwd->acct_ctrl)); + + if (acb_mask == 0 || IS_BITS_SET_SOME(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)++; + } + + endsmbpwent(vp); + + return (*num_entries) > 0; } /******************************************************************* @@ -463,33 +463,52 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, DEBUG(5,("samr_reply_query_dispinfo: %d\n", __LINE__)); +#ifndef USE_LDAP become_root(True); got_pwds = get_smbpwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); unbecome_root(True); +#endif switch (q_u->switch_level) { case 0x1: { + /* query disp info is for users */ + switch_level = 0x1; +#ifdef USE_LDAP + got_pwds = get_ldap_entries(pass, + &total_entries, + &num_entries, + MAX_SAM_ENTRIES, + 0, + switch_level); +#endif make_sam_info_1(&info1, ACB_NORMAL, q_u->start_idx, num_entries, pass); ctr.sam.info1 = &info1; - switch_level = 0x1; break; } case 0x2: { /* query disp info is for servers */ + switch_level = 0x2; +#ifdef USE_LDAP + got_pwds = get_ldap_entries(pass, + &total_entries, + &num_entries, + MAX_SAM_ENTRIES, + 0, + switch_level); +#endif make_sam_info_2(&info2, ACB_WSTRUST, q_u->start_idx, num_entries, pass); ctr.sam.info2 = &info2; - switch_level = 0x2; break; } @@ -1025,8 +1044,11 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, case 21: { info = (void*)&id21; +#ifdef USE_LDAP + status = ldap_get_user_info_21(&id21, rid) ? 0 : NT_STATUS_NO_SUCH_USER; +#else status = get_user_info_21(&id21, rid) ? 0 : NT_STATUS_NO_SUCH_USER; - +#endif break; } -- cgit From b54509045d7186fc0526d91bcf429659cba8be1d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 6 May 1998 18:14:02 +0000 Subject: loadparm.c: Added #ifdef USE_LDAP around ldap code. server.c: Moved %U, %G and %N into standard_sub() from standard_sub_basic() as only smbd knows about usernames. Also fixes problem with calling standard_sub_basic() from loadparm.c. smbpass.c: Partial tidyup of machine_password_lock() code - not finished yet. util.c: Moved %U, %G and %N into standard_sub() from standard_sub_basic() as only smbd knows about usernames. Also fixes problem with calling standard_sub_basic() from loadparm.c. lib/rpc/server/srv_ldap_helpers.c: Added #ifdef USE_LDAP around ldap code. lib/rpc/server/srv_samr.c: Added #ifdef USE_LDAP around ldap code. Jeremy. (This used to be commit 446b98ca071170fc950bad86ad96b58308a5b75c) --- source3/rpc_server/srv_ldap_helpers.c | 3 +++ source3/rpc_server/srv_samr.c | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ldap_helpers.c b/source3/rpc_server/srv_ldap_helpers.c index d1c091c6c9..945c06ad27 100644 --- a/source3/rpc_server/srv_ldap_helpers.c +++ b/source3/rpc_server/srv_ldap_helpers.c @@ -159,4 +159,7 @@ BOOL ldap_get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) return(True); } +#else /* USE_LDAP */ +/* this keeps fussy compilers happy */ +void ldap_helper_dummy(void) {} #endif diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index aa240ad3c6..353da9bd29 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -469,7 +469,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, got_pwds = get_smbpwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); unbecome_root(True); -#endif +#endif /* USE_LDAP */ switch (q_u->switch_level) { @@ -485,7 +485,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, MAX_SAM_ENTRIES, 0, switch_level); -#endif +#endif /* USE_DLAP */ make_sam_info_1(&info1, ACB_NORMAL, q_u->start_idx, num_entries, pass); @@ -504,7 +504,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, MAX_SAM_ENTRIES, 0, switch_level); -#endif +#endif /* USE_LDAP */ make_sam_info_2(&info2, ACB_WSTRUST, q_u->start_idx, num_entries, pass); @@ -1046,9 +1046,9 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, info = (void*)&id21; #ifdef USE_LDAP status = ldap_get_user_info_21(&id21, rid) ? 0 : NT_STATUS_NO_SUCH_USER; -#else +#else /* USE_LDAP */ status = get_user_info_21(&id21, rid) ? 0 : NT_STATUS_NO_SUCH_USER; -#endif +#endif /* USE_LDAP */ break; } -- cgit From 346abceb277e3354214599cc3c0f9bac6d44dfc8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 6 May 1998 18:45:57 +0000 Subject: smbpass.c: Fixed machine_passwd_lock() problems. password.c: Fixed machine_passwd_lock() problems. lib/rpc/server/srv_ldap_helpers.c: Oops - broke proto.h with dummy function. Fixed now. Jeremy. (This used to be commit d28427f21fff49da6b38c24625e3e2dae49a9713) --- source3/rpc_server/srv_ldap_helpers.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ldap_helpers.c b/source3/rpc_server/srv_ldap_helpers.c index 945c06ad27..66674f4773 100644 --- a/source3/rpc_server/srv_ldap_helpers.c +++ b/source3/rpc_server/srv_ldap_helpers.c @@ -161,5 +161,6 @@ BOOL ldap_get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) #else /* USE_LDAP */ /* this keeps fussy compilers happy */ -void ldap_helper_dummy(void) {} -#endif +void ldap_helper_dummy(void) +{} +#endif /* USE_LDAP */ -- cgit From d8d9f7723337c267a8740750fe19a6387cfbb1f6 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 7 May 1998 18:19:05 +0000 Subject: created "passdb.c" which is an interface point to (at present) either smbpasswd or ldap passwd, at compile-time (-DUSE_LDAP). _none_ of the functions in ldap.c or smbpass.c should be called directly: only those in passdb.c should be used. -DUSE_LDAP is unlikely to compile at the moment. (This used to be commit 57b01ad4ffb14ebd600d4e66602b54ed987f6106) --- source3/rpc_server/srv_netlog.c | 60 +++++++++++++++++++++-------------------- source3/rpc_server/srv_samr.c | 26 +++++++++--------- source3/rpc_server/srv_util.c | 4 +-- 3 files changed, 46 insertions(+), 44 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 6229d5ea0b..76dd5dd74d 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -237,7 +237,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) } become_root(True); - smb_pass = getsmbpwnam(mach_acct); + smb_pass = getsampwnam(mach_acct); unbecome_root(True); if (smb_pass != NULL) @@ -377,48 +377,50 @@ static void api_net_srv_pwset( int uid, /* checks and updates credentials. creates reply credentials */ if (deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), - &(q_a.clnt_id.cred), &srv_cred)) + &(q_a.clnt_id.cred), &srv_cred)) { memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); - pstrcpy(mach_acct, unistrn2(q_a.clnt_id.login.uni_acct_name.buffer, - q_a.clnt_id.login.uni_acct_name.uni_str_len)); + pstrcpy(mach_acct, unistrn2(q_a.clnt_id.login.uni_acct_name.buffer, + q_a.clnt_id.login.uni_acct_name.uni_str_len)); - DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); + DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); - become_root(True); - smb_pass = getsmbpwnam(mach_acct); - unbecome_root(True); + become_root(True); + smb_pass = getsampwnam(mach_acct); + unbecome_root(True); if (smb_pass != NULL) { - unsigned char pwd[16]; - int i; + unsigned char pwd[16]; + int i; - DEBUG(100,("Server password set : new given value was :\n")); - for(i = 0; i < 16; i++) - DEBUG(100,("%02X ", q_a.pwd[i])); - DEBUG(100,("\n")); + DEBUG(100,("Server password set : new given value was :\n")); + for(i = 0; i < 16; i++) + { + DEBUG(100,("%02X ", q_a.pwd[i])); + } + DEBUG(100,("\n")); - cred_hash3( pwd, q_a.pwd, vuser->dc.sess_key, 0); + cred_hash3( pwd, q_a.pwd, vuser->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; + /* 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; - become_root(True); - ret = mod_smbpwd_entry(smb_pass,False); - unbecome_root(True); + become_root(True); + ret = mod_sampwd_entry(smb_pass,False); + unbecome_root(True); - if (ret) - { - /* hooray! */ - status = 0x0; - } - } + if (ret) + { + /* hooray! */ + status = 0x0; + } + } DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); @@ -629,7 +631,7 @@ static void api_net_sam_logon( int uid, DEBUG(3,("User:[%s]\n", samlogon_user)); become_root(True); - smb_pass = getsmbpwnam(samlogon_user); + smb_pass = getsampwnam(samlogon_user); unbecome_root(True); if (smb_pass == NULL) diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 353da9bd29..c8c483ac31 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -38,7 +38,7 @@ extern rid_name domain_alias_rids[]; dynamically returns the correct user info..... JRA. ********************************************************************/ -static BOOL get_smbpwd_entries(SAM_USER_INFO_21 *pw_buf, +static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int *total_entries, int *num_entries, int max_num_entries, uint16 acb_mask) @@ -51,14 +51,14 @@ static BOOL get_smbpwd_entries(SAM_USER_INFO_21 *pw_buf, if (pw_buf == NULL) return False; - vp = startsmbpwent(False); + vp = startsampwent(False); if (!vp) { - DEBUG(0, ("get_smbpwd_entries: Unable to open SMB password file.\n")); + DEBUG(0, ("get_sampwd_entries: Unable to open SMB password file.\n")); return False; } - while (((pwd = getsmbpwent(vp)) != NULL) && (*num_entries) < max_num_entries) + while (((pwd = getsampwent(vp)) != NULL) && (*num_entries) < max_num_entries) { int user_name_len = strlen(pwd->smb_name); make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len-1); @@ -75,7 +75,7 @@ static BOOL get_smbpwd_entries(SAM_USER_INFO_21 *pw_buf, pw_buf[(*num_entries)].acb_info = (uint16)pwd->acct_ctrl; - DEBUG(5, ("get_smbpwd_entries: idx: %d user %s, uid %d, acb %x", + DEBUG(5, ("get_sampwd_entries: idx: %d user %s, uid %d, acb %x", (*num_entries), pwd->smb_name, pwd->smb_userid, pwd->acct_ctrl)); if (acb_mask == 0 || IS_BITS_SET_SOME(pwd->acct_ctrl, acb_mask)) @@ -91,7 +91,7 @@ static BOOL get_smbpwd_entries(SAM_USER_INFO_21 *pw_buf, (*total_entries)++; } - endsmbpwent(vp); + endsampwent(vp); return (*num_entries) > 0; } @@ -295,7 +295,7 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, DEBUG(5,("samr_reply_enum_dom_users: %d\n", __LINE__)); become_root(True); - got_pwds = get_smbpwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, q_u->acb_mask); + got_pwds = get_sampwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, q_u->acb_mask); unbecome_root(True); make_samr_r_enum_dom_users(&r_e, total_entries, @@ -466,7 +466,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, #ifndef USE_LDAP become_root(True); - got_pwds = get_smbpwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); + got_pwds = get_sampwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); unbecome_root(True); #endif /* USE_LDAP */ @@ -633,7 +633,7 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, /* find the user account */ become_root(True); - smb_pass = get_smbpwd_entry(user_name, 0); + smb_pass = get_sampwd_entry(user_name, 0); unbecome_root(True); if (smb_pass == NULL) @@ -825,7 +825,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, } become_root(True); - smb_pass = getsmbpwuid(q_u->user_rid); + smb_pass = getsampwuid(q_u->user_rid); unbecome_root(True); /* check that the RID exists in our domain. */ @@ -896,7 +896,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) struct smb_passwd *smb_pass; become_root(True); - smb_pass = getsmbpwuid(rid); + smb_pass = getsampwuid(rid); unbecome_root(True); if (smb_pass == NULL) @@ -1117,7 +1117,7 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, if (status == 0x0) { become_root(True); - smb_pass = getsmbpwuid(rid); + smb_pass = getsampwuid(rid); unbecome_root(True); if (smb_pass == NULL) @@ -1213,7 +1213,7 @@ static void api_samr_unknown_32( int uid, prs_struct *data, prs_struct *rdata) q_u.uni_mach_acct.uni_str_len)); become_root(True); - smb_pass = getsmbpwnam(mach_acct); + smb_pass = getsampwnam(mach_acct); unbecome_root(True); if (smb_pass != NULL) diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 898269dc4a..a84dbb43ef 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -406,7 +406,7 @@ uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) /* ok, it's a user. find the user account */ become_root(True); - smb_pass = getsmbpwuid(rid); /* lkclXXXX SHOULD use rid mapping here! */ + smb_pass = getsampwuid(rid); /* lkclXXXX SHOULD use rid mapping here! */ unbecome_root(True); if (smb_pass != NULL) @@ -468,7 +468,7 @@ uint32 lookup_user_rid(char *user_name, uint32 *rid) /* find the user account */ become_root(True); - smb_pass = getsmbpwnam(user_name); + smb_pass = getsampwnam(user_name); unbecome_root(True); if (smb_pass != NULL) -- cgit From 3dfc0c847240ac7e12c39f4ed9c31a888949ade1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 May 1998 06:38:36 +0000 Subject: changed to use slprintf() instead of sprintf() just about everywhere. I've implemented slprintf() as a bounds checked sprintf() using mprotect() and a non-writeable page. This should prevent any sprintf based security holes. (This used to be commit ee09e9dadb69aaba5a751dd20ccc6d587d841bd6) --- source3/rpc_server/srv_lsa_hnd.c | 6 +++--- source3/rpc_server/srv_netlog.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index c8eabf35b4..1d1341d16e 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -115,7 +115,7 @@ BOOL open_lsa_policy_hnd(POLICY_HND *hnd) memcpy(&(Policy[i].pol_hnd), hnd, sizeof(*hnd)); DEBUG(4,("Opened policy hnd[%x] ", i)); - dump_data(4, hnd->data, sizeof(hnd->data)); + dump_data(4, (char *)hnd->data, sizeof(hnd->data)); return True; } @@ -143,14 +143,14 @@ int find_lsa_policy_by_hnd(POLICY_HND *hnd) if (memcmp(&(Policy[i].pol_hnd), hnd, sizeof(*hnd)) == 0) { DEBUG(4,("Found policy hnd[%x] ", i)); - dump_data(4, hnd->data, sizeof(hnd->data)); + dump_data(4, (char *)hnd->data, sizeof(hnd->data)); return i; } } DEBUG(4,("Policy not found: ")); - dump_data(4, hnd->data, sizeof(hnd->data)); + dump_data(4, (char *)hnd->data, sizeof(hnd->data)); return -1; } diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 76dd5dd74d..28c44a57b7 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -281,7 +281,7 @@ static void api_net_req_chal( int uid, strcat(mach_acct, "$"); - if (get_md4pw(vuser->dc.md4pw, mach_name, mach_acct)) + if (get_md4pw((char *)vuser->dc.md4pw, mach_name, mach_acct)) { /* copy the client credentials */ memcpy(vuser->dc.clnt_chal.data , q_r.clnt_chal.data, sizeof(q_r.clnt_chal.data)); @@ -297,7 +297,7 @@ static void api_net_req_chal( int uid, /* from client / server challenges and md4 password, generate sess key */ cred_session_key(&(vuser->dc.clnt_chal), &(vuser->dc.srv_chal), - vuser->dc.md4pw, vuser->dc.sess_key); + (char *)vuser->dc.md4pw, vuser->dc.sess_key); } else { @@ -489,8 +489,8 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, memcpy(lm_pwd, id1->lm_owf.data, 16); memcpy(nt_pwd, id1->nt_owf.data, 16); - SamOEMhash(lm_pwd, key, False); - SamOEMhash(nt_pwd, key, False); + SamOEMhash((uchar *)lm_pwd, key, False); + SamOEMhash((uchar *)nt_pwd, key, False); #ifdef DEBUG_PASSWORD DEBUG(100,("decrypt of lm owf password:")); @@ -526,7 +526,7 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, if (id2->hdr_nt_chal_resp.str_str_len == 24 && smb_pass->smb_nt_passwd != NULL) { - if(smb_password_check(id2->nt_chal_resp.buffer, + if(smb_password_check((char *)id2->nt_chal_resp.buffer, smb_pass->smb_nt_passwd, id2->lm_chal)) return 0x0; @@ -543,7 +543,7 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, */ if (id2->hdr_lm_chal_resp.str_str_len == 24 && - smb_password_check(id2->lm_chal_resp.buffer, + smb_password_check((char *)id2->lm_chal_resp.buffer, smb_pass->smb_passwd, id2->lm_chal)) { -- cgit From f004d84f683673b7cb167320e3e78a3fcefdfd07 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 11 May 1998 15:56:01 +0000 Subject: ldap back-end database development Makefile: created PASSBD_OBJ group includes.h: added #ifdef USE_LDAP to #include headers ldap.c: - renamed "_machine" to "_trust" everywhere. - added sam_passwd support routines - removed get_ldappwd_entry function: replaced with get_sampwd_entry - removed getldappwnam/uid: replaced with getsampwnam/uid - other messing about bits which are probably going to annoy the hell out of jean-francois (sorry!) mkproto.awk: - added stuff to wrap ldap.c protos with #ifdef USE_LDAP - added uid_t and gid_t return results to the prototype generation passdb.c: - created getsam21pwent, add_sam21pwd_entry, mod_sam21pwd_entry. - modified getsampwnam/uid and created getsam21pwnam/rid functions to replace the local get_smbpwd_entry() and get_ldappwd_entry() functions, which jeremy didn't like anyway because they were dual-purpose. - added utility routines which are or may be useful to all the password database routines. password.c: - renamed "machine_" to "trust_" everywhere. smbpass.c: - removed get_smbpwd_entry function: replaced it with get_sampwd_entry functions in passdb.c - moved code that decoded acct_ctrl into passdb.c - moved encode_acct_ctrl into passdb.c - removed getsmbpwnam/uid: replaced with getsampwnam/uid - renamed "machine_" to "trust_" everywhere. smbpasswd.c: - renamed "machine_" to "trust_" everywhere. util.c: - moved gethexpwd function into passdb.c lib/rpc/server/srv_util.c: - moved user_rid_to_uid, group_rid_to_rid etc etc into passdb.c (This used to be commit 673ab50c4c2c25db355d90efde3a6bfbb4d8369e) --- source3/rpc_server/srv_util.c | 164 ++++++++++-------------------------------- 1 file changed, 38 insertions(+), 126 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index a84dbb43ef..210a3f55e2 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -79,7 +79,6 @@ rid_name domain_group_rids[] = }; - int make_dom_gids(char *gids_str, DOM_GID *gids) { char *ptr; @@ -133,44 +132,6 @@ int make_dom_gids(char *gids_str, DOM_GID *gids) return count; } -/******************************************************************* - gets a domain user's groups - ********************************************************************/ -void get_domain_user_groups(char *domain_groups, char *user) -{ - pstring tmp; - - if (domain_groups == NULL || user == NULL) return; - - /* any additional groups this user is in. e.g power users */ - pstrcpy(domain_groups, lp_domain_groups()); - - /* can only be a user or a guest. cannot be guest _and_ admin */ - if (user_in_list(user, lp_domain_guest_users())) - { - sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_GUESTS); - strcat(domain_groups, tmp); - - DEBUG(3,("domain guest access %s granted\n", tmp)); - } - else - { - sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_USERS); - strcat(domain_groups, tmp); - - DEBUG(3,("domain user access %s granted\n", tmp)); - - if (user_in_list(user, lp_domain_admin_users())) - { - sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_ADMINS); - strcat(domain_groups, tmp); - - DEBUG(3,("domain admin access %s granted\n", tmp)); - } - } -} - - /******************************************************************* turns a DCE/RPC request into a DCE/RPC reply @@ -320,7 +281,44 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds return True; } -extern rid_name domain_group_rids[]; + +/******************************************************************* + gets a domain user's groups + ********************************************************************/ +void get_domain_user_groups(char *domain_groups, char *user) +{ + pstring tmp; + + if (domain_groups == NULL || user == NULL) return; + + /* any additional groups this user is in. e.g power users */ + pstrcpy(domain_groups, lp_domain_groups()); + + /* can only be a user or a guest. cannot be guest _and_ admin */ + if (user_in_list(user, lp_domain_guest_users())) + { + sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_GUESTS); + strcat(domain_groups, tmp); + + DEBUG(3,("domain guest access %s granted\n", tmp)); + } + else + { + sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_USERS); + strcat(domain_groups, tmp); + + DEBUG(3,("domain user access %s granted\n", tmp)); + + if (user_in_list(user, lp_domain_admin_users())) + { + sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_ADMINS); + strcat(domain_groups, tmp); + + DEBUG(3,("domain admin access %s granted\n", tmp)); + } + } +} + /******************************************************************* lookup_group_name @@ -348,8 +346,6 @@ uint32 lookup_group_name(uint32 rid, char *group_name, uint32 *type) return 0xC0000000 | NT_STATUS_NONE_MAPPED; } -extern rid_name domain_alias_rids[]; - /******************************************************************* lookup_alias_name ********************************************************************/ @@ -480,87 +476,3 @@ uint32 lookup_user_rid(char *user_name, uint32 *rid) return 0xC0000000 | NT_STATUS_NONE_MAPPED; } - -/******************************************************************* - Group and User RID username mapping function - ********************************************************************/ -BOOL name_to_rid(char *user_name, uint32 *u_rid, uint32 *g_rid) -{ - struct passwd *pw = Get_Pwnam(user_name, False); - - if (u_rid == NULL || g_rid == NULL || user_name == NULL) - { - return False; - } - - if (!pw) - { - DEBUG(1,("Username %s is invalid on this system\n", user_name)); - return False; - } - - if (user_in_list(user_name, lp_domain_guest_users())) - { - *u_rid = DOMAIN_USER_RID_GUEST; - } - else if (user_in_list(user_name, lp_domain_admin_users())) - { - *u_rid = DOMAIN_USER_RID_ADMIN; - } - else - { - /* turn the unix UID into a Domain RID. this is what the posix - sub-system does (adds 1000 to the uid) */ - *u_rid = uid_to_user_rid(pw->pw_uid); - } - - /* absolutely no idea what to do about the unix GID to Domain RID mapping */ - *g_rid = gid_to_group_rid(pw->pw_gid); - - return True; -} - -/******************************************************************* - XXXX THIS FUNCTION SHOULD NOT BE HERE: IT SHOULD BE A STATIC FUNCTION - INSIDE smbpass.c - - converts NT User RID to a UNIX uid. - ********************************************************************/ -uid_t user_rid_to_uid(uint32 u_rid) -{ - return (uid_t)(u_rid - 1000); -} - -/******************************************************************* - XXXX THIS FUNCTION SHOULD NOT BE HERE: IT SHOULD BE A STATIC FUNCTION - INSIDE smbpass.c - - converts NT Group RID to a UNIX uid. - ********************************************************************/ -uid_t group_rid_to_uid(uint32 u_gid) -{ - return (uid_t)(u_gid - 1000); -} - -/******************************************************************* - XXXX THIS FUNCTION SHOULD NOT BE HERE: IT SHOULD BE A STATIC FUNCTION - INSIDE smbpass.c - - converts UNIX uid to an NT User RID. - ********************************************************************/ -uint32 uid_to_user_rid(uint32 uid) -{ - return (uint32)(uid + 1000); -} - -/******************************************************************* - XXXX THIS FUNCTION SHOULD NOT BE HERE: IT SHOULD BE A STATIC FUNCTION - INSIDE smbpass.c - - converts NT Group RID to a UNIX uid. - ********************************************************************/ -uint32 gid_to_group_rid(uint32 gid) -{ - return (uint32)(gid + 1000); -} - -- cgit From 9141acecdcebd9276107a500435e3d4545020056 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 11 May 1998 18:03:01 +0000 Subject: password back-end database support ldap.c : - added getldap21pwent() function passdb.c : - getsam21pwent() no longer a stub: calls ldap21 or smb21 smbpass.c : - added getsmb21pwent() function (he he :-) lib/rpc/server/srv_samr.c : - removed "specific" calls to ldap functions; replaced with call to get_sampwd_entries instead (which is unfinished). - rewrote get_user_info_21 function to call getsam21pwrid. (This used to be commit c760ebbf127796427c4602aae61952df938c6def) --- source3/rpc_server/srv_samr.c | 133 +++++++++--------------------------------- 1 file changed, 28 insertions(+), 105 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index c8c483ac31..20cdc30bab 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -463,13 +463,9 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, DEBUG(5,("samr_reply_query_dispinfo: %d\n", __LINE__)); -#ifndef USE_LDAP become_root(True); - got_pwds = get_sampwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); - unbecome_root(True); -#endif /* USE_LDAP */ switch (q_u->switch_level) { @@ -478,14 +474,6 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, /* query disp info is for users */ switch_level = 0x1; -#ifdef USE_LDAP - got_pwds = get_ldap_entries(pass, - &total_entries, - &num_entries, - MAX_SAM_ENTRIES, - 0, - switch_level); -#endif /* USE_DLAP */ make_sam_info_1(&info1, ACB_NORMAL, q_u->start_idx, num_entries, pass); @@ -497,14 +485,6 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, { /* query disp info is for servers */ switch_level = 0x2; -#ifdef USE_LDAP - got_pwds = get_ldap_entries(pass, - &total_entries, - &num_entries, - MAX_SAM_ENTRIES, - 0, - switch_level); -#endif /* USE_LDAP */ make_sam_info_2(&info2, ACB_WSTRUST, q_u->start_idx, num_entries, pass); @@ -876,87 +856,34 @@ static void api_samr_open_user( int uid, prs_struct *data, prs_struct *rdata) static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) { NTTIME dummy_time; - - pstring logon_script; - pstring profile_path; - pstring home_drive; - pstring home_dir; - pstring description; - pstring workstations; - pstring full_name; - pstring munged_dialin; - pstring unknown_str; - - uint32 r_uid; - uint32 r_gid; + struct sam_passwd *sam_pass; LOGON_HRS hrs; int i; - struct smb_passwd *smb_pass; - become_root(True); - smb_pass = getsampwuid(rid); + sam_pass = getsam21pwrid(rid); unbecome_root(True); - if (smb_pass == NULL) + if (sam_pass == NULL) { return False; } - DEBUG(3,("User:[%s]\n", smb_pass->smb_name)); + DEBUG(3,("User:[%s]\n", sam_pass->smb_name)); dummy_time.low = 0xffffffff; dummy_time.high = 0x7fffffff; - pstrcpy(samlogon_user, smb_pass->smb_name); - - if (samlogon_user[strlen(samlogon_user)-1] != '$') - { - if (!name_to_rid(samlogon_user, &r_uid, &r_gid)) - { - return False; - } - - /* 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(full_name , ""); - pstrcpy(logon_script , lp_logon_script ()); - pstrcpy(profile_path , lp_logon_path ()); - pstrcpy(home_drive , lp_logon_drive ()); - pstrcpy(home_dir , lp_logon_home ()); - pstrcpy(description , ""); - pstrcpy(workstations , ""); - pstrcpy(unknown_str , ""); - pstrcpy(munged_dialin, ""); - - sam_logon_in_ssb = False; - } - else - { - r_uid = smb_pass->smb_userid; - r_gid = DOMAIN_GROUP_RID_USERS; - - pstrcpy(samlogon_user, smb_pass->smb_name); - - pstrcpy(full_name , ""); - pstrcpy(logon_script , ""); - pstrcpy(profile_path , ""); - pstrcpy(home_drive , ""); - pstrcpy(home_dir , ""); - pstrcpy(description , ""); - pstrcpy(workstations , ""); - pstrcpy(unknown_str , ""); - pstrcpy(munged_dialin, ""); - } + DEBUG(0,("get_user_info_21 - TODO: convert unix times to NTTIMEs\n")); - hrs.len = 21; + /* create a LOGON_HRS structure */ + hrs.len = sam_pass->hours_len; for (i = 0; i < hrs.len; i++) { - hrs.hours[i] = 0xff; + hrs.hours[i] = sam_pass->hours[i]; } + make_sam_user_info21(id21, &dummy_time, /* logon_time */ @@ -966,26 +893,26 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) &dummy_time, /* pass_can_change_time */ &dummy_time, /* pass_must_change_time */ - samlogon_user, /* user_name */ - full_name, /* full_name */ - home_dir, /* home_dir */ - home_drive, /* dir_drive */ - logon_script, /* logon_script */ - profile_path, /* profile_path */ - description, /* description */ - workstations, /* workstations user can log in from */ - unknown_str, /* don't know, yet */ - munged_dialin, /* dialin info. contains dialin path and tel no */ - - r_uid, /* RID user_id */ - r_gid, /* RID group_id */ - smb_pass->acct_ctrl, - - 0x00ffffff, /* unknown_3 */ - 168, /* divisions per week */ + 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 */ + + sam_pass->user_rid, /* RID user_id */ + sam_pass->group_rid, /* RID group_id */ + sam_pass->acct_ctrl, + + sam_pass->unknown_3, /* unknown_3 */ + sam_pass->logon_divs, /* divisions per week */ &hrs, /* logon hours */ - 0x00020000, - 0x000004ec); + sam_pass->unknown_5, + sam_pass->unknown_6); return True; } @@ -1044,11 +971,7 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, case 21: { info = (void*)&id21; -#ifdef USE_LDAP - status = ldap_get_user_info_21(&id21, rid) ? 0 : NT_STATUS_NO_SUCH_USER; -#else /* USE_LDAP */ status = get_user_info_21(&id21, rid) ? 0 : NT_STATUS_NO_SUCH_USER; -#endif /* USE_LDAP */ break; } -- cgit From f888868f46a5418bac9ab528497136c152895305 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 12 May 1998 00:55:32 +0000 Subject: This is a security audit change of the main source. It removed all ocurrences of the following functions : sprintf strcpy strcat The replacements are slprintf, safe_strcpy and safe_strcat. It should not be possible to use code in Samba that uses sprintf, strcpy or strcat, only the safe_equivalents. Once Andrew has fixed the slprintf implementation then this code will be moved back to the 1.9.18 code stream. Jeremy. (This used to be commit 2d774454005f0b54e5684cf618da7060594dfcbb) --- source3/rpc_server/srv_netlog.c | 2 +- source3/rpc_server/srv_samr.c | 6 +++--- source3/rpc_server/srv_util.c | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 28c44a57b7..958f0bf14d 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -279,7 +279,7 @@ static void api_net_req_chal( int uid, fstrcpy(mach_name, mach_acct); strlower(mach_name); - strcat(mach_acct, "$"); + fstrcat(mach_acct, "$"); if (get_md4pw((char *)vuser->dc.md4pw, mach_name, mach_acct)) { diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 20cdc30bab..6f834e454a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -231,9 +231,9 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, if (status == 0x0) { - strcpy(user_sid, lp_domain_sid()); - sprintf(user_rid, "-%x", rid); - strcat(user_sid, user_rid); + fstrcpy(user_sid, lp_domain_sid()); + slprintf(user_rid, sizeof(user_rid) - 1, "-%x", rid); + fstrcat(user_sid, user_rid); /* maybe need another 1 or 2 (S-1-5-20-0x220 and S-1-5-20-0x224) */ /* these two are DOMAIN_ADMIN and DOMAIN_ACCT_OP group RIDs */ diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 210a3f55e2..e842e3b9f9 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -297,22 +297,22 @@ void get_domain_user_groups(char *domain_groups, char *user) /* can only be a user or a guest. cannot be guest _and_ admin */ if (user_in_list(user, lp_domain_guest_users())) { - sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_GUESTS); - strcat(domain_groups, tmp); + slprintf(tmp, sizeof(tmp) - 1, " %ld/7 ", DOMAIN_GROUP_RID_GUESTS); + pstrcat(domain_groups, tmp); DEBUG(3,("domain guest access %s granted\n", tmp)); } else { - sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_USERS); - strcat(domain_groups, tmp); + slprintf(tmp, sizeof(tmp) -1, " %ld/7 ", DOMAIN_GROUP_RID_USERS); + pstrcat(domain_groups, tmp); DEBUG(3,("domain user access %s granted\n", tmp)); if (user_in_list(user, lp_domain_admin_users())) { - sprintf(tmp, " %ld/7 ", DOMAIN_GROUP_RID_ADMINS); - strcat(domain_groups, tmp); + slprintf(tmp, sizeof(tmp) - 1, " %ld/7 ", DOMAIN_GROUP_RID_ADMINS); + pstrcat(domain_groups, tmp); DEBUG(3,("domain admin access %s granted\n", tmp)); } -- cgit From 9118b8508bfa8bba323eb8960e23053c924cc414 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 12 May 1998 14:01:56 +0000 Subject: retired this file: it's not actually needed now that passdb.c provides the interface point. (This used to be commit 27ba6fafc90d8de7107f39c848f1f34b021ed0a0) --- source3/rpc_server/srv_ldap_helpers.c | 152 ---------------------------------- 1 file changed, 152 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ldap_helpers.c b/source3/rpc_server/srv_ldap_helpers.c index 66674f4773..fb2442789c 100644 --- a/source3/rpc_server/srv_ldap_helpers.c +++ b/source3/rpc_server/srv_ldap_helpers.c @@ -6,158 +6,6 @@ extern int DEBUGLEVEL; -/******************************************************************* - find a user or a machine return a smbpass struct. -******************************************************************/ -static void make_ldap_sam_user_info_21(LDAP *ldap_struct, LDAPMessage *entry, SAM_USER_INFO_21 *user) -{ - pstring cn; - pstring fullname; - pstring home_dir; - pstring dir_drive; - pstring logon_script; - pstring profile_path; - pstring acct_desc; - pstring workstations; - pstring temp; - - if (ldap_check_user(ldap_struct, entry)==True) - { - get_single_attribute(ldap_struct, entry, "cn", cn); - get_single_attribute(ldap_struct, entry, "userFullName", fullname); - get_single_attribute(ldap_struct, entry, "homeDirectory", home_dir); - get_single_attribute(ldap_struct, entry, "homeDrive", dir_drive); - get_single_attribute(ldap_struct, entry, "scriptPath", logon_script); - get_single_attribute(ldap_struct, entry, "profilePath", profile_path); - get_single_attribute(ldap_struct, entry, "comment", acct_desc); - get_single_attribute(ldap_struct, entry, "userWorkstations", workstations); - - get_single_attribute(ldap_struct, entry, "rid", temp); - user->user_rid=atoi(temp); - get_single_attribute(ldap_struct, entry, "primaryGroupID", temp); - user->group_rid=atoi(temp); - get_single_attribute(ldap_struct, entry, "controlAccessRights", temp); - user->acb_info=atoi(temp); - - make_unistr2(&(user->uni_user_name), cn, strlen(cn)); - make_uni_hdr(&(user->hdr_user_name), strlen(cn), strlen(cn), 1); - make_unistr2(&(user->uni_full_name), fullname, strlen(fullname)); - make_uni_hdr(&(user->hdr_full_name), strlen(fullname), strlen(fullname), 1); - make_unistr2(&(user->uni_home_dir), home_dir, strlen(home_dir)); - make_uni_hdr(&(user->hdr_home_dir), strlen(home_dir), strlen(home_dir), 1); - make_unistr2(&(user->uni_dir_drive), dir_drive, strlen(dir_drive)); - make_uni_hdr(&(user->hdr_dir_drive), strlen(dir_drive), strlen(dir_drive), 1); - make_unistr2(&(user->uni_logon_script), logon_script, strlen(logon_script)); - make_uni_hdr(&(user->hdr_logon_script), strlen(logon_script), strlen(logon_script), 1); - make_unistr2(&(user->uni_profile_path), profile_path, strlen(profile_path)); - make_uni_hdr(&(user->hdr_profile_path), strlen(profile_path), strlen(profile_path), 1); - make_unistr2(&(user->uni_acct_desc), acct_desc, strlen(acct_desc)); - make_uni_hdr(&(user->hdr_acct_desc), strlen(acct_desc), strlen(acct_desc), 1); - make_unistr2(&(user->uni_workstations), workstations, strlen(workstations)); - make_uni_hdr(&(user->hdr_workstations), strlen(workstations), strlen(workstations), 1); - } -} - -/******************************************************************* - find a user or a machine return a smbpass struct. -******************************************************************/ -BOOL get_ldap_entries(SAM_USER_INFO_21 *pw_buf, - int *total_entries, int *num_entries, - int max_num_entries, - uint16 acb_mask, int switch_level) -{ - LDAP *ldap_struct; - LDAPMessage *result; - LDAPMessage *entry; - - int scope = LDAP_SCOPE_ONELEVEL; - int rc; - - char filter[256]; - - (*num_entries) = 0; - (*total_entries) = 0; - - if (!ldap_open_connection(&ldap_struct)) /* open a connection to the server */ - return (False); - - if (!ldap_connect_system(ldap_struct)) /* connect as system account */ - return (False); - - - /* when the class is known the search is much faster */ - switch (switch_level) - { - case 1: strcpy(filter, "objectclass=sambaAccount"); - break; - case 2: strcpy(filter, "objectclass=sambaMachine"); - break; - default: strcpy(filter, "(|(objectclass=sambaMachine)(objectclass=sambaAccount))"); - break; - } - - rc=ldap_search_s(ldap_struct, lp_ldap_suffix(), scope, filter, NULL, 0, &result); - - DEBUG(2,("%d entries in the base!\n", ldap_count_entries(ldap_struct, result) )); - - for ( entry = ldap_first_entry(ldap_struct, result); - (entry != NULL) && (*num_entries) < max_num_entries; - entry = ldap_next_entry(ldap_struct, entry) ) - { - make_ldap_sam_user_info_21(ldap_struct, entry, &(pw_buf[(*num_entries)]) ); - - if (acb_mask == 0 || IS_BITS_SET_SOME(pw_buf[(*num_entries)].acb_info, 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)++; - } - - ldap_msgfree(result); - ldap_unbind(ldap_struct); - return (*num_entries) > 0; -} - -BOOL ldap_get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) -{ - LDAP *ldap_struct; - LDAPMessage *result; - LDAPMessage *entry; - - if (!ldap_open_connection(&ldap_struct)) - return (False); - if (!ldap_connect_system(ldap_struct)) - return (False); - - if (!ldap_search_one_user_by_uid(ldap_struct, rid, &result)) - return (False); - - if (ldap_count_entries(ldap_struct, result) == 0) - { - DEBUG(2,("%s: Non existant user!\n", timestring() )); - return (False); - } - - if (ldap_count_entries(ldap_struct, result) > 1) - { - DEBUG(2,("%s: Strange %d users in the base!\n", - timestring(), ldap_count_entries(ldap_struct, result) )); - } - /* take the first and unique entry */ - entry=ldap_first_entry(ldap_struct, result); - - make_ldap_sam_user_info_21(ldap_struct, entry, id21); - - ldap_msgfree(result); - ldap_unbind(ldap_struct); - return(True); -} #else /* USE_LDAP */ /* this keeps fussy compilers happy */ -- cgit From a4276507e43487f47445eab11d4ac1b080b3270e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 14 May 1998 01:30:40 +0000 Subject: chgpasswd.c: Added comments to #ifdefs ipc.c: Caused samba password changing not to be done if UNIX password changing requested and not successful. util.c: Added string_to_sid() and sid_to_string() functions. lib/rpc/client/cli_samr.c: lib/rpc/include/rpc_misc.h: lib/rpc/parse/parse_lsa.c: lib/rpc/parse/parse_misc.c: lib/rpc/parse/parse_net.c: lib/rpc/parse/parse_samr.c: lib/rpc/server/srv_lsa.c: lib/rpc/server/srv_lsa_hnd.c: lib/rpc/server/srv_netlog.c: lib/rpc/server/srv_samr.c: lib/rpc/server/srv_util.c: Changes so that instead of passing SIDs around as char *, they are converted to DOM_SID at the earliest opportunity, and passed around as that. Also added dynamic memory allocation of group sids. Preparing to auto-generate machine sid. Jeremy. (This used to be commit 134d6fa79c1b6b9505a2c84ba9bfb91dd3be76e5) --- source3/rpc_server/srv_lsa.c | 75 ++++---- source3/rpc_server/srv_lsa_hnd.c | 29 +-- source3/rpc_server/srv_netlog.c | 402 ++++++++++++++++++++------------------- source3/rpc_server/srv_samr.c | 7 +- source3/rpc_server/srv_util.c | 117 +++++++----- 5 files changed, 338 insertions(+), 292 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 60b74cf599..df4b95db9e 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -6,7 +6,8 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. - * + * Copyright (C) Jeremy Allison 1998. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -52,7 +53,7 @@ static void lsa_reply_open_policy(prs_struct *rdata) /*************************************************************************** make_dom_query ***************************************************************************/ -static void make_dom_query(DOM_QUERY *d_q, char *dom_name, char *dom_sid) +static void make_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) { int domlen = strlen(dom_name); @@ -73,7 +74,7 @@ lsa_reply_query_info ***************************************************************************/ static void lsa_reply_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM *q_e, prs_struct *rdata, - uint32 enum_context, char *dom_name, char *dom_sid) + uint32 enum_context, char *dom_name, DOM_SID *dom_sid) { LSA_R_ENUM_TRUST_DOM r_e; @@ -89,7 +90,7 @@ static void lsa_reply_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM *q_e, lsa_reply_query_info ***************************************************************************/ static void lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, - char *dom_name, char *dom_sid) + char *dom_name, DOM_SID *dom_sid) { LSA_R_QUERY_INFO r_q; @@ -112,14 +113,10 @@ make_dom_ref pretty much hard-coded choice of "other" sids, unfortunately... ***************************************************************************/ -static void make_dom_ref(DOM_R_REF *ref, - char *dom_name, char *dom_sid, - char *other_sid1, char *other_sid2, char *other_sid3) +static void make_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid, + DOM_SID *other_sid1, DOM_SID *other_sid2, DOM_SID *other_sid3) { int len_dom_name = strlen(dom_name); - int len_other_sid1 = strlen(other_sid1); - int len_other_sid2 = strlen(other_sid2); - int len_other_sid3 = strlen(other_sid3); ref->undoc_buffer = 1; ref->num_ref_doms_1 = 4; @@ -128,9 +125,9 @@ static void make_dom_ref(DOM_R_REF *ref, ref->num_ref_doms_2 = 4; make_uni_hdr2(&(ref->hdr_dom_name ), len_dom_name , len_dom_name , 0); - make_uni_hdr2(&(ref->hdr_ref_dom[0]), len_other_sid1, len_other_sid1, 0); - make_uni_hdr2(&(ref->hdr_ref_dom[1]), len_other_sid2, len_other_sid2, 0); - make_uni_hdr2(&(ref->hdr_ref_dom[2]), len_other_sid3, len_other_sid3, 0); + make_uni_hdr2(&(ref->hdr_ref_dom[0]), sizeof(DOM_SID), sizeof(DOM_SID), 0); + make_uni_hdr2(&(ref->hdr_ref_dom[1]), sizeof(DOM_SID), sizeof(DOM_SID), 0); + make_uni_hdr2(&(ref->hdr_ref_dom[2]), sizeof(DOM_SID), sizeof(DOM_SID), 0); if (dom_name != NULL) { @@ -148,8 +145,8 @@ make_reply_lookup_rids ***************************************************************************/ static void make_reply_lookup_rids(LSA_R_LOOKUP_RIDS *r_l, int num_entries, uint32 dom_rids[MAX_LOOKUP_SIDS], - char *dom_name, char *dom_sid, - char *other_sid1, char *other_sid2, char *other_sid3) + char *dom_name, DOM_SID *dom_sid, + DOM_SID *other_sid1, DOM_SID *other_sid2, DOM_SID *other_sid3) { int i; @@ -232,8 +229,8 @@ lsa_reply_lookup_sids ***************************************************************************/ static void lsa_reply_lookup_sids(prs_struct *rdata, int num_entries, DOM_SID2 sid[MAX_LOOKUP_SIDS], - char *dom_name, char *dom_sid, - char *other_sid1, char *other_sid2, char *other_sid3) + char *dom_name, DOM_SID *dom_sid, + DOM_SID *other_sid1, DOM_SID *other_sid2, DOM_SID *other_sid3) { LSA_R_LOOKUP_SIDS r_l; DOM_R_REF ref; @@ -254,8 +251,8 @@ lsa_reply_lookup_rids ***************************************************************************/ static void lsa_reply_lookup_rids(prs_struct *rdata, int num_entries, uint32 dom_rids[MAX_LOOKUP_SIDS], - char *dom_name, char *dom_sid, - char *other_sid1, char *other_sid2, char *other_sid3) + char *dom_name, DOM_SID *dom_sid, + DOM_SID *other_sid1, DOM_SID *other_sid2, DOM_SID *other_sid3) { LSA_R_LOOKUP_RIDS r_l; @@ -309,16 +306,16 @@ static void api_lsa_query_info( int uid, prs_struct *data, { LSA_Q_QUERY_INFO q_i; pstring dom_name; - pstring dom_sid; + DOM_SID dom_sid; /* grab the info class and policy handle */ lsa_io_q_query("", &q_i, data, 0); pstrcpy(dom_name, lp_workgroup()); - pstrcpy(dom_sid , lp_domain_sid()); + string_to_sid(&dom_sid, lp_domain_sid()); /* construct reply. return status is always 0x0 */ - lsa_reply_query_info(&q_i, rdata, dom_name, dom_sid); + lsa_reply_query_info(&q_i, rdata, dom_name, &dom_sid); } /*************************************************************************** @@ -329,19 +326,26 @@ static void api_lsa_lookup_sids( int uid, prs_struct *data, { LSA_Q_LOOKUP_SIDS q_l; pstring dom_name; - pstring dom_sid; + DOM_SID dom_sid; + DOM_SID sid_S_1_1; + DOM_SID sid_S_1_3; + DOM_SID sid_S_1_5; /* grab the info class and policy handle */ lsa_io_q_lookup_sids("", &q_l, data, 0); pstrcpy(dom_name, lp_workgroup()); - pstrcpy(dom_sid , lp_domain_sid()); + + string_to_sid(&dom_sid , lp_domain_sid()); + string_to_sid(&sid_S_1_1, "S-1-1"); + string_to_sid(&sid_S_1_3, "S-1-3"); + string_to_sid(&sid_S_1_5, "S-1-5"); /* construct reply. return status is always 0x0 */ lsa_reply_lookup_sids(rdata, - q_l.sids.num_entries, q_l.sids.sid, /* SIDs */ - dom_name, dom_sid, /* domain name, domain SID */ - "S-1-1", "S-1-3", "S-1-5"); /* the three other SIDs */ + q_l.sids.num_entries, q_l.sids.sid, /* SIDs */ + dom_name, &dom_sid, /* domain name, domain SID */ + &sid_S_1_1, &sid_S_1_3, &sid_S_1_5); /* the three other SIDs */ } /*************************************************************************** @@ -353,7 +357,10 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, int i; LSA_Q_LOOKUP_RIDS q_l; pstring dom_name; - pstring dom_sid; + DOM_SID dom_sid; + DOM_SID sid_S_1_1; + DOM_SID sid_S_1_3; + DOM_SID sid_S_1_5; uint32 dom_rids[MAX_LOOKUP_SIDS]; uint32 dummy_g_rid; @@ -361,7 +368,11 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, lsa_io_q_lookup_rids("", &q_l, data, 0); pstrcpy(dom_name, lp_workgroup()); - pstrcpy(dom_sid , lp_domain_sid()); + + string_to_sid(&dom_sid , lp_domain_sid()); + string_to_sid(&sid_S_1_1, "S-1-1"); + string_to_sid(&sid_S_1_3, "S-1-3"); + string_to_sid(&sid_S_1_5, "S-1-5"); /* convert received RIDs to strings, so we can do them. */ for (i = 0; i < q_l.num_entries; i++) @@ -376,9 +387,9 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, /* construct reply. return status is always 0x0 */ lsa_reply_lookup_rids(rdata, - q_l.num_entries, dom_rids, /* text-converted SIDs */ - dom_name, dom_sid, /* domain name, domain SID */ - "S-1-1", "S-1-3", "S-1-5"); /* the three other SIDs */ + q_l.num_entries, dom_rids, /* text-converted SIDs */ + dom_name, &dom_sid, /* domain name, domain SID */ + &sid_S_1_1, &sid_S_1_3, &sid_S_1_5); /* the three other SIDs */ } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 1d1341d16e..91844ee8a2 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -206,22 +206,23 @@ BOOL set_lsa_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status) ****************************************************************************/ BOOL set_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) { - int pnum = find_lsa_policy_by_hnd(hnd); + pstring sidstr; + int pnum = find_lsa_policy_by_hnd(hnd); - if (OPEN_POL(pnum)) - { - DEBUG(3,("%s Setting policy sid=%s pnum=%x\n", - timestring(), dom_sid_to_string(sid), pnum)); + if (OPEN_POL(pnum)) + { + DEBUG(3,("%s Setting policy sid=%s pnum=%x\n", + timestring(), sid_to_string(sidstr, sid), pnum)); - memcpy(&(Policy[pnum].dev.samr.sid), sid, sizeof(*sid)); - return True; - } - else - { - DEBUG(3,("%s Error setting policy sid=%s (pnum=%x)\n", - timestring(), dom_sid_to_string(sid), pnum)); - return False; - } + memcpy(&(Policy[pnum].dev.samr.sid), sid, sizeof(*sid)); + return True; + } + else + { + DEBUG(3,("%s Error setting policy sid=%s (pnum=%x)\n", + timestring(), sid_to_string(sidstr, sid), pnum)); + return False; + } } /**************************************************************************** diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 958f0bf14d..edc2d859df 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -6,7 +6,8 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. - * + * Copyright (C) Jeremy Allison 1998. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -563,200 +564,213 @@ static void api_net_sam_logon( int uid, prs_struct *data, prs_struct *rdata) { - NET_Q_SAM_LOGON q_l; - NET_ID_INFO_CTR ctr; - NET_USER_INFO_3 usr_info; - uint32 status = 0x0; - DOM_CRED srv_cred; - struct smb_passwd *smb_pass = NULL; - UNISTR2 *uni_samlogon_user = NULL; - - user_struct *vuser = NULL; - - if ((vuser = get_valid_user_struct(uid)) == NULL) return; - - q_l.sam_id.ctr = &ctr; - - net_io_q_sam_logon("", &q_l, data, 0); - - /* checks and updates credentials. creates reply credentials */ - if (!deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), - &(q_l.sam_id.client.cred), &srv_cred)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - else - { - memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); - } - - /* find the username */ - - if (status == 0x0) - { - switch (q_l.sam_id.logon_level) - { - case 1: - { - uni_samlogon_user = &(q_l.sam_id.ctr->auth.id1.uni_user_name); - - DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", - lp_workgroup())); - break; - } - case 2: - { - uni_samlogon_user = &(q_l.sam_id.ctr->auth.id2.uni_user_name); - - DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", - lp_workgroup())); - break; - } - default: - { - DEBUG(2,("SAM Logon: unsupported switch value\n")); - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; - break; - } - } - } - - /* check username exists */ - - if (status == 0x0) - { - pstrcpy(samlogon_user, unistrn2(uni_samlogon_user->buffer, - uni_samlogon_user->uni_str_len)); - - DEBUG(3,("User:[%s]\n", samlogon_user)); - - become_root(True); - smb_pass = getsampwnam(samlogon_user); - unbecome_root(True); - - if (smb_pass == NULL) - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - } - } - - /* validate password. */ - - if (status == 0x0) - { - switch (q_l.sam_id.logon_level) - { - case 1: - { - /* interactive login. */ - status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, - smb_pass, vuser); - break; - } - case 2: - { - /* network login. lm challenge and 24 byte responses */ - status = net_login_network(&q_l.sam_id.ctr->auth.id2, - smb_pass, vuser); - break; - } - } - } + NET_Q_SAM_LOGON q_l; + NET_ID_INFO_CTR ctr; + NET_USER_INFO_3 usr_info; + uint32 status = 0x0; + DOM_CRED srv_cred; + struct smb_passwd *smb_pass = NULL; + UNISTR2 *uni_samlogon_user = NULL; + + user_struct *vuser = NULL; + + if ((vuser = get_valid_user_struct(uid)) == NULL) + return; + + q_l.sam_id.ctr = &ctr; + + net_io_q_sam_logon("", &q_l, data, 0); + + /* checks and updates credentials. creates reply credentials */ + if (!deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), + &(q_l.sam_id.client.cred), &srv_cred)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + else + { + memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); + } + + /* find the username */ + + if (status == 0) + { + switch (q_l.sam_id.logon_level) + { + case INTERACTIVE_LOGON_TYPE: + { + uni_samlogon_user = &(q_l.sam_id.ctr->auth.id1.uni_user_name); + + DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); + break; + } + case NET_LOGON_TYPE: + { + uni_samlogon_user = &(q_l.sam_id.ctr->auth.id2.uni_user_name); + + DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); + break; + } + default: + { + DEBUG(2,("SAM Logon: unsupported switch value\n")); + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + break; + } + } /* end switch */ + } /* end if status == 0 */ + + /* check username exists */ + + if (status == 0) + { + pstrcpy(samlogon_user, unistrn2(uni_samlogon_user->buffer, + uni_samlogon_user->uni_str_len)); + + DEBUG(3,("User:[%s]\n", samlogon_user)); + + become_root(True); + smb_pass = getsampwnam(samlogon_user); + unbecome_root(True); + + if (smb_pass == NULL) + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + } + } + + /* validate password. */ + + if (status == 0) + { + switch (q_l.sam_id.logon_level) + { + case INTERACTIVE_LOGON_TYPE: + { + /* interactive login. */ + status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, smb_pass, vuser); + break; + } + case NET_LOGON_TYPE: + { + /* network login. lm challenge and 24 byte responses */ + status = net_login_network(&q_l.sam_id.ctr->auth.id2, smb_pass, vuser); + break; + } + } + } - /* 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 :-) */ - - if (status == 0x0) - { - DOM_GID gids[LSA_MAX_GROUPS]; - int num_gids = 0; - NTTIME dummy_time; - pstring logon_script; - pstring profile_path; - pstring home_dir; - pstring home_drive; - pstring my_name; - pstring my_workgroup; - pstring domain_groups; - pstring dom_sid; - pstring other_sids; - 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; - - /* 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(logon_script, lp_logon_script ()); - pstrcpy(profile_path, lp_logon_path ()); - pstrcpy(dom_sid , lp_domain_sid ()); - pstrcpy(other_sids , lp_domain_other_sids()); - pstrcpy(my_workgroup, lp_workgroup ()); - - pstrcpy(home_drive , lp_logon_drive ()); - pstrcpy(home_dir , lp_logon_home ()); - - pstrcpy(my_name , global_myname ); - strupper(my_name); - - get_domain_user_groups(domain_groups, samlogon_user); - - num_gids = make_dom_gids(domain_groups, gids); - - sam_logon_in_ssb = False; - - if (name_to_rid(samlogon_user, &r_uid, &r_gid)) - { - make_net_user_info3(&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 */ - - samlogon_user , /* user_name */ - vuser->real_name, /* full_name */ - logon_script , /* logon_script */ - profile_path , /* profile_path */ - home_dir , /* home_dir */ - home_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 */ - - dom_sid, /* char *dom_sid */ - other_sids); /* char *other_sids */ - } - else - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - } - } - - net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status); + /* 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 :-) */ + + if (status == 0) + { + DOM_GID *gids = NULL; + int num_gids = 0; + NTTIME dummy_time; + pstring logon_script; + pstring profile_path; + pstring home_dir; + pstring home_drive; + pstring my_name; + pstring my_workgroup; + pstring domain_groups; + DOM_SID dom_sid; + char *other_sids; + 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; + + /* 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(logon_script, lp_logon_script()); + pstrcpy(profile_path, lp_logon_path()); + string_to_sid(&dom_sid, lp_domain_sid()); + + pstrcpy(other_sids, lp_domain_other_sids()); + pstrcpy(my_workgroup, lp_workgroup()); + + pstrcpy(home_drive, lp_logon_drive()); + pstrcpy(home_dir, lp_logon_home()); + + pstrcpy(my_name, global_myname); + strupper(my_name); + + /* + * This is the point at which we get the group + * database - we should be getting the gid_t list + * from /etc/group and then turning the uids into + * rids and then into machine sids for this user. + * JRA. + */ + + get_domain_user_groups(domain_groups, samlogon_user); + + /* + * make_dom_gids allocates the gids array. JRA. + */ + gids = NULL; + num_gids = make_dom_gids(domain_groups, &gids); + + sam_logon_in_ssb = False; + + if (name_to_rid(samlogon_user, &r_uid, &r_gid)) + { + make_net_user_info3(&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 */ + + samlogon_user , /* user_name */ + vuser->real_name, /* full_name */ + logon_script , /* logon_script */ + profile_path , /* profile_path */ + home_dir , /* home_dir */ + home_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 */ + + &dom_sid, /* DOM_SID *dom_sid */ + other_sids); /* char *other_sids */ + } + else + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + } + + /* Free any allocated groups array. */ + if(gids) + free((char *)gids); + } + + net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status); } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 6f834e454a..8070336f87 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1018,7 +1018,7 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, uint32 status = 0x0; struct smb_passwd *smb_pass; - DOM_GID gids[LSA_MAX_GROUPS]; + DOM_GID *gids = NULL; int num_groups = 0; int pol_idx; uint32 rid; @@ -1053,7 +1053,8 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, { pstring groups; get_domain_user_groups(groups, smb_pass->smb_name); - num_groups = make_dom_gids(groups, gids); + gids = NULL; + num_groups = make_dom_gids(groups, &gids); } /* construct the response. lkclXXXX: gids are not copied! */ @@ -1062,6 +1063,8 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, /* store the response in the SMB stream */ samr_io_r_query_usergroups("", &r_u, rdata, 0); + if(gids) + free((char *)gids); DEBUG(5,("samr_query_usergroups: %d\n", __LINE__)); } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index e842e3b9f9..204a9eac8e 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -79,57 +79,74 @@ rid_name domain_group_rids[] = }; -int make_dom_gids(char *gids_str, DOM_GID *gids) +int make_dom_gids(char *gids_str, DOM_GID **ppgids) { - char *ptr; - pstring s2; - int count; - - DEBUG(4,("make_dom_gids: %s\n", gids_str)); - - if (gids_str == NULL || *gids_str == 0) return 0; - - for (count = 0, ptr = gids_str; next_token(&ptr, s2, NULL) && count < LSA_MAX_GROUPS; count++) - { - /* the entries are of the form GID/ATTR, ATTR being optional.*/ - char *attr; - uint32 rid = 0; - int i; - - attr = strchr(s2,'/'); - if (attr) *attr++ = 0; - if (!attr || !*attr) attr = "7"; /* default value for attribute is 7 */ - - /* look up the RID string and see if we can turn it into a rid number */ - for (i = 0; domain_alias_rids[i].name != NULL; i++) - { - if (strequal(domain_alias_rids[i].name, s2)) - { - rid = domain_alias_rids[i].rid; - break; - } - } - - if (rid == 0) rid = atoi(s2); - - if (rid == 0) - { - DEBUG(1,("make_dom_gids: unknown well-known alias RID %s/%s\n", - s2, attr)); - count--; - } - else - { - gids[count].g_rid = rid; - gids[count].attr = atoi(attr); - - DEBUG(5,("group id: %d attr: %d\n", - gids[count].g_rid, - gids[count].attr)); - } - } - - return count; + char *ptr; + pstring s2; + int count; + DOM_GID *gids; + + *ppgids = NULL; + + DEBUG(4,("make_dom_gids: %s\n", gids_str)); + + if (gids_str == NULL || *gids_str == 0) + return 0; + + for (count = 0, ptr = gids_str; next_token(&ptr, s2, NULL); count++) + ; + + gids = (DOM_GID *)malloc( sizeof(DOM_GID) * count ); + if(!gids) + { + DEBUG(0,("make_dom_gids: malloc fail !\n")); + return 0; + } + + for (count = 0, ptr = gids_str; next_token(&ptr, s2, NULL) && + count < LSA_MAX_GROUPS; count++) + { + /* the entries are of the form GID/ATTR, ATTR being optional.*/ + char *attr; + uint32 rid = 0; + int i; + + attr = strchr(s2,'/'); + if (attr) + *attr++ = 0; + + if (!attr || !*attr) + attr = "7"; /* default value for attribute is 7 */ + + /* look up the RID string and see if we can turn it into a rid number */ + for (i = 0; domain_alias_rids[i].name != NULL; i++) + { + if (strequal(domain_alias_rids[i].name, s2)) + { + rid = domain_alias_rids[i].rid; + break; + } + } + + if (rid == 0) + rid = atoi(s2); + + if (rid == 0) + { + DEBUG(1,("make_dom_gids: unknown well-known alias RID %s/%s\n", s2, attr)); + count--; + } + else + { + gids[count].g_rid = rid; + gids[count].attr = atoi(attr); + + DEBUG(5,("group id: %d attr: %d\n", gids[count].g_rid, gids[count].attr)); + } + } + + *ppgids = gids; + return count; } /******************************************************************* -- cgit From 05a8202b48291b46befedad345b546d1a54c29c2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 14 May 1998 03:32:21 +0000 Subject: Fixed dce/rpc to use global_machine_sid (auto generated in server.c if not present in smb.conf). Jeremy. (This used to be commit e7c1100390b714bf2f489a9032156b0c9272e403) --- source3/rpc_server/srv_lsa.c | 14 ++++---------- source3/rpc_server/srv_netlog.c | 5 ++--- source3/rpc_server/srv_samr.c | 4 +++- 3 files changed, 9 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index df4b95db9e..930b607770 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -28,7 +28,7 @@ #include "nterr.h" extern int DEBUGLEVEL; - +extern DOM_SID global_machine_sid; /*************************************************************************** lsa_reply_open_policy @@ -306,16 +306,14 @@ static void api_lsa_query_info( int uid, prs_struct *data, { LSA_Q_QUERY_INFO q_i; pstring dom_name; - DOM_SID dom_sid; /* grab the info class and policy handle */ lsa_io_q_query("", &q_i, data, 0); pstrcpy(dom_name, lp_workgroup()); - string_to_sid(&dom_sid, lp_domain_sid()); /* construct reply. return status is always 0x0 */ - lsa_reply_query_info(&q_i, rdata, dom_name, &dom_sid); + lsa_reply_query_info(&q_i, rdata, dom_name, &global_machine_sid); } /*************************************************************************** @@ -326,7 +324,6 @@ static void api_lsa_lookup_sids( int uid, prs_struct *data, { LSA_Q_LOOKUP_SIDS q_l; pstring dom_name; - DOM_SID dom_sid; DOM_SID sid_S_1_1; DOM_SID sid_S_1_3; DOM_SID sid_S_1_5; @@ -336,7 +333,6 @@ static void api_lsa_lookup_sids( int uid, prs_struct *data, pstrcpy(dom_name, lp_workgroup()); - string_to_sid(&dom_sid , lp_domain_sid()); string_to_sid(&sid_S_1_1, "S-1-1"); string_to_sid(&sid_S_1_3, "S-1-3"); string_to_sid(&sid_S_1_5, "S-1-5"); @@ -344,7 +340,7 @@ static void api_lsa_lookup_sids( int uid, prs_struct *data, /* construct reply. return status is always 0x0 */ lsa_reply_lookup_sids(rdata, q_l.sids.num_entries, q_l.sids.sid, /* SIDs */ - dom_name, &dom_sid, /* domain name, domain SID */ + dom_name, &global_machine_sid, /* domain name, domain SID */ &sid_S_1_1, &sid_S_1_3, &sid_S_1_5); /* the three other SIDs */ } @@ -357,7 +353,6 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, int i; LSA_Q_LOOKUP_RIDS q_l; pstring dom_name; - DOM_SID dom_sid; DOM_SID sid_S_1_1; DOM_SID sid_S_1_3; DOM_SID sid_S_1_5; @@ -369,7 +364,6 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, pstrcpy(dom_name, lp_workgroup()); - string_to_sid(&dom_sid , lp_domain_sid()); string_to_sid(&sid_S_1_1, "S-1-1"); string_to_sid(&sid_S_1_3, "S-1-3"); string_to_sid(&sid_S_1_5, "S-1-5"); @@ -388,7 +382,7 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, /* construct reply. return status is always 0x0 */ lsa_reply_lookup_rids(rdata, q_l.num_entries, dom_rids, /* text-converted SIDs */ - dom_name, &dom_sid, /* domain name, domain SID */ + dom_name, &global_machine_sid, /* domain name, domain SID */ &sid_S_1_1, &sid_S_1_3, &sid_S_1_5); /* the three other SIDs */ } diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index edc2d859df..23625b96ef 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -32,6 +32,7 @@ extern int DEBUGLEVEL; extern BOOL sam_logon_in_ssb; extern pstring samlogon_user; extern pstring global_myname; +extern DOM_SID global_machine_sid; /************************************************************************* make_net_r_req_chal: @@ -680,7 +681,6 @@ static void api_net_sam_logon( int uid, pstring my_name; pstring my_workgroup; pstring domain_groups; - DOM_SID dom_sid; char *other_sids; uint32 r_uid; uint32 r_gid; @@ -697,7 +697,6 @@ static void api_net_sam_logon( int uid, pstrcpy(logon_script, lp_logon_script()); pstrcpy(profile_path, lp_logon_path()); - string_to_sid(&dom_sid, lp_domain_sid()); pstrcpy(other_sids, lp_domain_other_sids()); pstrcpy(my_workgroup, lp_workgroup()); @@ -757,7 +756,7 @@ static void api_net_sam_logon( int uid, my_name , /* char *logon_srv */ my_workgroup, /* char *logon_dom */ - &dom_sid, /* DOM_SID *dom_sid */ + &global_machine_sid, /* DOM_SID *dom_sid */ other_sids); /* char *other_sids */ } else diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 8070336f87..88217f73aa 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -30,6 +30,8 @@ extern int DEBUGLEVEL; extern BOOL sam_logon_in_ssb; extern pstring samlogon_user; +extern DOM_SID global_machine_sid; + extern rid_name domain_group_rids[]; extern rid_name domain_alias_rids[]; @@ -231,7 +233,7 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, if (status == 0x0) { - fstrcpy(user_sid, lp_domain_sid()); + sid_to_string(user_sid, &global_machine_sid); slprintf(user_rid, sizeof(user_rid) - 1, "-%x", rid); fstrcat(user_sid, user_rid); -- cgit From f8a4273407f2983bb05a76e914d4f532bbd5004e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 14 May 1998 21:10:49 +0000 Subject: passdb.c server.c: Moved generate_machine_sid() into passdb.c for Jean-Francois (who might want an LDAP version). Changed locking to free exclusive lock as soon as possible to prevent contention. lib/rpc/parse/parse_samr.c lib/rpc/server/srv_samr.c: Changed last SID-as-string manipulation function to use DOM_SID structure. Jeremy. (This used to be commit 3b8f5aef57b4f37265c0403385053085f0df6f18) --- source3/rpc_server/srv_samr.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 88217f73aa..821ae75c11 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -211,8 +211,6 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, { SAMR_R_UNKNOWN_3 r_u; DOM_SID3 sid[MAX_SAM_SIDS]; - fstring user_sid; - fstring user_rid; int pol_idx; uint32 rid; uint32 status; @@ -233,14 +231,21 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, if (status == 0x0) { - sid_to_string(user_sid, &global_machine_sid); - slprintf(user_rid, sizeof(user_rid) - 1, "-%x", rid); - fstrcat(user_sid, user_rid); + DOM_SID user_sid; + DOM_SID other_sid; + + user_sid = global_machine_sid; + /* + * Add the user RID. + */ + user_sid.sub_auths[user_sid.num_auths++] = rid; + + string_to_sid(&other_sid, "S-1-1"); /* maybe need another 1 or 2 (S-1-5-20-0x220 and S-1-5-20-0x224) */ /* these two are DOMAIN_ADMIN and DOMAIN_ACCT_OP group RIDs */ - make_dom_sid3(&(sid[0]), 0x035b, 0x0002, "S-1-1"); - make_dom_sid3(&(sid[1]), 0x0044, 0x0002, user_sid); + make_dom_sid3(&(sid[0]), 0x035b, 0x0002, &other_sid); + make_dom_sid3(&(sid[1]), 0x0044, 0x0002, &user_sid); } make_samr_r_unknown_3(&r_u, -- cgit From 5e1313d184bb7edc56d33178ce424c82695a996c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 15 May 1998 22:29:42 +0000 Subject: Fix from "Gerald W. Carter" , we were copying from a parameter into an unitialized variable (doh !). Jeremy. (This used to be commit a3a0dc14c2f9f703963ade67f30dd6c40bbe7144) --- source3/rpc_server/srv_netlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 23625b96ef..73992faf5d 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -681,7 +681,7 @@ static void api_net_sam_logon( int uid, pstring my_name; pstring my_workgroup; pstring domain_groups; - char *other_sids; + pstring other_sids; uint32 r_uid; uint32 r_gid; -- cgit From 39f3c0c25a289b0b255e104a0a0aaade557c84f4 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 18 May 1998 12:27:04 +0000 Subject: - renamed some of the passdb.c functions: they have a prefix pdb_ on them - split smbpass.c "password file lock" routines into smbpassfile.c: moved trust account routines into smbpassfile.c as well (This used to be commit 3e48b4eb113cc5e1c6794d7ac699fd9ac47c654a) --- source3/rpc_server/srv_lsa.c | 2 +- source3/rpc_server/srv_netlog.c | 2 +- source3/rpc_server/srv_util.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 930b607770..ff4b6bf4b6 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -372,7 +372,7 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, for (i = 0; i < q_l.num_entries; i++) { char *user_name = unistr2(q_l.lookup_name[i].str.buffer); - if (!name_to_rid(user_name, &dom_rids[i], &dummy_g_rid)) + if (!pdb_name_to_rid(user_name, &dom_rids[i], &dummy_g_rid)) { /* WHOOPS! we should really do something about this... */ dom_rids[i] = 0; diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 73992faf5d..e5ae3959b9 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -725,7 +725,7 @@ static void api_net_sam_logon( int uid, sam_logon_in_ssb = False; - if (name_to_rid(samlogon_user, &r_uid, &r_gid)) + if (pdb_name_to_rid(samlogon_user, &r_uid, &r_gid)) { make_net_user_info3(&usr_info, &dummy_time, /* logon_time */ diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 204a9eac8e..632c508343 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -414,7 +414,7 @@ uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) return 0x0; } - unix_uid = uid_to_user_rid(rid); + unix_uid = pdb_uid_to_user_rid(rid); DEBUG(5,(" uid: %d", unix_uid)); /* ok, it's a user. find the user account */ -- cgit From ffab54750f0eec202895670dd9293ee4aa3eb475 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 18 May 1998 21:30:57 +0000 Subject: chgpasswd.c: Changed back to getsmb... from getsam... ldap.c: Stoped dummy_function being prototyped. loadparm.c: Fixed slprintf sizes. nisppass.c: Fixed safe_strcpy sizes. nmbd_processlogon.c: Changed back to getsmb... from getsam... nttrans.c: Just a dump of new code. passdb.c: Moved stuff around a lot - stopped any lookups by rid. This needs to be indirected through a function table (soon). password.c: Changed back to getsmb... from getsam... reply.c: Changed back to getsmb... from getsam... slprintf.c: Fixed prototype problems. smb.h: Fixed prototype problems. smbpass.c: Changed to getsmbfile.... smbpasswd.c: Changed back to getsmb... from getsam... lib/rpc/server/srv_netlog.c: Changed back to getsmb... from getsam... lib/rpc/server/srv_samr.c: Fixed rid lookup - use uid or gid lookup. lib/rpc/server/srv_util.c: Changed back to getsmb... from getsam... Jeremy. (This used to be commit 7d332b2493d2089d09521250fc9b72d8953307c0) --- source3/rpc_server/srv_netlog.c | 8 +++---- source3/rpc_server/srv_samr.c | 48 ++++++++++++++++++++++++++++++----------- source3/rpc_server/srv_util.c | 4 ++-- 3 files changed, 42 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index e5ae3959b9..c81a8244d9 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -239,7 +239,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) } become_root(True); - smb_pass = getsampwnam(mach_acct); + smb_pass = getsmbpwnam(mach_acct); unbecome_root(True); if (smb_pass != NULL) @@ -391,7 +391,7 @@ static void api_net_srv_pwset( int uid, DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); become_root(True); - smb_pass = getsampwnam(mach_acct); + smb_pass = getsmbpwnam(mach_acct); unbecome_root(True); if (smb_pass != NULL) @@ -414,7 +414,7 @@ static void api_net_srv_pwset( int uid, smb_pass->acct_ctrl = ACB_WSTRUST; become_root(True); - ret = mod_sampwd_entry(smb_pass,False); + ret = mod_smbpwd_entry(smb_pass,False); unbecome_root(True); if (ret) @@ -632,7 +632,7 @@ static void api_net_sam_logon( int uid, DEBUG(3,("User:[%s]\n", samlogon_user)); become_root(True); - smb_pass = getsampwnam(samlogon_user); + smb_pass = getsmbpwnam(samlogon_user); unbecome_root(True); if (smb_pass == NULL) diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 821ae75c11..adc16fa5c8 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -53,14 +53,14 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, if (pw_buf == NULL) return False; - vp = startsampwent(False); + vp = startsmbpwent(False); if (!vp) { - DEBUG(0, ("get_sampwd_entries: Unable to open SMB password file.\n")); + DEBUG(0, ("get_sampwd_entries: Unable to open SMB password database.\n")); return False; } - while (((pwd = getsampwent(vp)) != NULL) && (*num_entries) < max_num_entries) + while (((pwd = getsmbpwent(vp)) != NULL) && (*num_entries) < max_num_entries) { int user_name_len = strlen(pwd->smb_name); make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len-1); @@ -77,7 +77,7 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, pw_buf[(*num_entries)].acb_info = (uint16)pwd->acct_ctrl; - DEBUG(5, ("get_sampwd_entries: idx: %d user %s, uid %d, acb %x", + DEBUG(5, ("get_smbpwd_entries: idx: %d user %s, uid %d, acb %x", (*num_entries), pwd->smb_name, pwd->smb_userid, pwd->acct_ctrl)); if (acb_mask == 0 || IS_BITS_SET_SOME(pwd->acct_ctrl, acb_mask)) @@ -93,7 +93,7 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, (*total_entries)++; } - endsampwent(vp); + endsmbpwent(vp); return (*num_entries) > 0; } @@ -812,7 +812,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, } become_root(True); - smb_pass = getsampwuid(q_u->user_rid); + smb_pass = getsmbpwuid(q_u->user_rid); unbecome_root(True); /* check that the RID exists in our domain. */ @@ -864,13 +864,37 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) { NTTIME dummy_time; struct sam_passwd *sam_pass; - LOGON_HRS hrs; int i; - become_root(True); - sam_pass = getsam21pwrid(rid); - unbecome_root(True); + /* + * Convert from rid to either a uid or gid as soon as + * possible. JRA. + */ + + if(pdb_rid_is_user(rid)) + { + uint32 uid = pdb_user_rid_to_uid(rid); + become_root(True); + sam_pass = getsam21pwuid(uid); + unbecome_root(True); + } + else + { + struct group *grent; + uint32 gid; + gid = pdb_group_rid_to_gid(rid); + if((grent = getgrgid(gid)) == NULL) + { + DEBUG(0,("get_user_info_21: Unable to get group info.\n")); + return False; + } + /* TODO - at this point we need to convert from + a UNIX struct group into a user info 21 structure. + Punt for now. JRA. + */ + return False; + } if (sam_pass == NULL) { @@ -1047,7 +1071,7 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, if (status == 0x0) { become_root(True); - smb_pass = getsampwuid(rid); + smb_pass = getsmbpwuid(rid); unbecome_root(True); if (smb_pass == NULL) @@ -1146,7 +1170,7 @@ static void api_samr_unknown_32( int uid, prs_struct *data, prs_struct *rdata) q_u.uni_mach_acct.uni_str_len)); become_root(True); - smb_pass = getsampwnam(mach_acct); + smb_pass = getsmbpwnam(mach_acct); unbecome_root(True); if (smb_pass != NULL) diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 632c508343..15c06d18bd 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -419,7 +419,7 @@ uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) /* ok, it's a user. find the user account */ become_root(True); - smb_pass = getsampwuid(rid); /* lkclXXXX SHOULD use rid mapping here! */ + smb_pass = getsmbpwuid(rid); /* lkclXXXX SHOULD use rid mapping here! */ unbecome_root(True); if (smb_pass != NULL) @@ -481,7 +481,7 @@ uint32 lookup_user_rid(char *user_name, uint32 *rid) /* find the user account */ become_root(True); - smb_pass = getsampwnam(user_name); + smb_pass = getsmbpwnam(user_name); unbecome_root(True); if (smb_pass != NULL) -- cgit From 0a36b8d8a959c18c670a7e41e3f5a728f3ea88c3 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 19 May 1998 17:48:40 +0000 Subject: ldap.c : - added support for some of the new passdb_ops functions. - removed functions that are supported "indirectly" through passdb.c nisppass.c : - modified make_nisname_from_xxx() functions to take a "file" arg. - turned getnisp21pwuid() into getnisp21pwrid(). getnisp21pwuid() functionality is available through "indirect" support in passdb.c - removed functions that are supported "indirectly" through passdb.c - added support for some of the new passdb_ops functions. passdb.c : - created getsam21pwrid() function to go alongside getsam21pwuid. it is not expected that getsam21pwuid ever be used, certainly not from the lib/rpc code. - created getsamdisprid() and getsamdispent(). these are primarily for support of SamrQueryDisplayInfo, however given that they [struct sam_disp_info] return username, rid and fullname, there may be further instances where these functions will be useful. - added support where either the get/add/mod-smb or get/add/mod-sam21 functions are optional. this can be done very easily by checking whether the struct passdb_ops table functions are NULL or not. documented this capability in the notes at the top of the module. - where unix uid was referenced, use uid_t. - where unix gid was referenced, use gid_t. smb.h : - added sam_disp_info functions to passdb_ops. - added getsam21pwrid() function. smbpass.c : - added reference to iterate_getsam21pwrid(). lib/rpc/server/srv_samr.c : - removed group rid code added to get_user_info_21() code: this had been added in the wrong place. the client / server should already know whether it wants to do a lookup by user rid or by group rid. the test of whether the rid is a user or group rid has been left in because this may become useful consistency-check code. - converted back to getsam21pwrid() not getsam21pwuid(pdb_user_rid_to_uid()). this is because the unix uid to user rid mapping can be non-monotonic in some password database systems, and monotonic in others. imposing the restriction by converting immediately from rid to uid at this point is inadviseable, and will place this potential restriction on _all_ password database systems, not just some which, for whatever reason, do not support user rids. it should be up to the individual password database writer to convert from user rid to unix uid, should that module not support rids. lib/rpc/server/srv_util.c : - got lookup_user_name() to call getsamdisprid() not getsmbpwuid(). a bug was introduced (or at least the bug already there was not fixed) whereby the nt user rid was converted to a unix uid, and then not used. (This used to be commit 0193dd21c3c44e0611add742c6f92b92474de6b8) --- source3/rpc_server/srv_samr.c | 38 +++++++++----------------------------- source3/rpc_server/srv_util.c | 12 ++++-------- 2 files changed, 13 insertions(+), 37 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index adc16fa5c8..d1503a762e 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -860,41 +860,21 @@ static void api_samr_open_user( int uid, prs_struct *data, prs_struct *rdata) /************************************************************************* get_user_info_21 *************************************************************************/ -static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) +static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) { NTTIME dummy_time; struct sam_passwd *sam_pass; LOGON_HRS hrs; int i; - /* - * Convert from rid to either a uid or gid as soon as - * possible. JRA. - */ - - if(pdb_rid_is_user(rid)) - { - uint32 uid = pdb_user_rid_to_uid(rid); - become_root(True); - sam_pass = getsam21pwuid(uid); - unbecome_root(True); - } - else - { - struct group *grent; - uint32 gid; - gid = pdb_group_rid_to_gid(rid); - if((grent = getgrgid(gid)) == NULL) - { - DEBUG(0,("get_user_info_21: Unable to get group info.\n")); - return False; - } - /* TODO - at this point we need to convert from - a UNIX struct group into a user info 21 structure. - Punt for now. JRA. - */ - return False; - } + if (!pdb_rid_is_user(user_rid)) + { + return False; + } + + become_root(True); + sam_pass = getsam21pwrid(user_rid); + unbecome_root(True); if (sam_pass == NULL) { diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 15c06d18bd..fca37db717 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -394,8 +394,7 @@ uint32 lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) ********************************************************************/ uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) { - struct smb_passwd *smb_pass; - uint32 unix_uid; + struct sam_disp_info *disp_info; int i = 0; (*type) = SID_NAME_USER; @@ -414,17 +413,14 @@ uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) return 0x0; } - unix_uid = pdb_uid_to_user_rid(rid); - DEBUG(5,(" uid: %d", unix_uid)); - /* ok, it's a user. find the user account */ become_root(True); - smb_pass = getsmbpwuid(rid); /* lkclXXXX SHOULD use rid mapping here! */ + disp_info = getsamdisprid(rid); unbecome_root(True); - if (smb_pass != NULL) + if (disp_info != NULL) { - fstrcpy(user_name, smb_pass->smb_name); + fstrcpy(user_name, disp_info->smb_name); DEBUG(5,(" = %s\n", user_name)); return 0x0; } -- cgit From 9c99863642d295e8b674c9c8b5eeda95bfc4d094 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 20 May 1998 13:17:26 +0000 Subject: dce/rpc net time command from jean-francois. does not support timezones (This used to be commit 8e11d542eebe076d74ab264e22b87f7aed9bbe8f) --- source3/rpc_server/srv_srvsvc.c | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index d06e2ac660..fedc7089e3 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -989,6 +989,59 @@ static void api_srv_net_share_enum( int uid, prs_struct *data, srv_reply_net_share_enum(&q_n, rdata); } +/******************************************************************* +time of day +********************************************************************/ +static void srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n, + prs_struct *rdata) +{ + SRV_R_NET_REMOTE_TOD r_n; + TIME_OF_DAY_INFO tod; + struct tm *t; + time_t unixdate = time(NULL); + + r_n.tod = &tod; + r_n.ptr_srv_tod = 0x1; + r_n.status = 0x0; + + DEBUG(5,("srv_reply_net_remote_tod: %d\n", __LINE__)); + + t = LocalTime(&unixdate); + + /* set up the */ + make_time_of_day_info(&tod, + unixdate, + 0, + t->tm_hour, + t->tm_min, + t->tm_sec, + 0, + TimeDiff(unixdate)/60, + 10000, + t->tm_mday, + t->tm_mon + 1, + 1900+t->tm_year, + t->tm_wday); + + /* store the response in the SMB stream */ + srv_io_r_net_remote_tod("", &r_n, rdata, 0); + + DEBUG(5,("srv_reply_net_remote_tod: %d\n", __LINE__)); +} +/******************************************************************* +********************************************************************/ +static void api_srv_net_remote_tod( int uid, prs_struct *data, + prs_struct *rdata ) +{ + SRV_Q_NET_REMOTE_TOD q_n; + + /* grab the net server get enum */ + srv_io_q_net_remote_tod("", &q_n, data, 0); + + /* construct reply. always indicate success */ + srv_reply_net_remote_tod(&q_n, rdata); +} + /******************************************************************* \PIPE\srvsvc commands @@ -1000,6 +1053,7 @@ struct api_struct api_srv_cmds[] = { "SRV_NETSHAREENUM" , SRV_NETSHAREENUM , api_srv_net_share_enum }, { "SRV_NETFILEENUM" , SRV_NETFILEENUM , api_srv_net_file_enum }, { "SRV_NET_SRV_GET_INFO", SRV_NET_SRV_GET_INFO, api_srv_net_srv_get_info }, + { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, { NULL , 0 , NULL } }; -- cgit From 1defdd071827e015c6f32ff16ac3ec312264aede Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 21 May 1998 11:54:40 +0000 Subject: jean-francois calling the right function for the "net t.o.d" dce/rpc support does gmtime() not LocalTime() now. (This used to be commit 64559e72f3028917059dbcafd0b3425266f7d567) --- source3/rpc_server/srv_srvsvc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index fedc7089e3..1089f385d7 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -1006,7 +1006,7 @@ static void srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n, DEBUG(5,("srv_reply_net_remote_tod: %d\n", __LINE__)); - t = LocalTime(&unixdate); + t = gmtime(&unixdate); /* set up the */ make_time_of_day_info(&tod, -- cgit From cf76b415a34534f574664e1fc1f8f1f8e6511c95 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 21 May 1998 12:18:52 +0000 Subject: fixed signed / unsigned warnings spotted by tim winders. also fixed unnecessary "address of" warnings. (This used to be commit ed0afe1e186ce53046e70d8a92103d4f59a2eed2) --- source3/rpc_server/srv_samr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index d1503a762e..d0304d0dd6 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -107,7 +107,7 @@ static void samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, SAMR_R_CLOSE_HND r_u; /* set up the SAMR unknown_1 response */ - bzero(&(r_u.pol.data), POL_HND_SIZE); + bzero(r_u.pol.data, POL_HND_SIZE); /* close the policy handle */ if (close_lsa_policy_hnd(&(q_u->pol))) @@ -795,7 +795,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, BOOL pol_open = False; /* set up the SAMR open_user response */ - bzero(&(r_u.user_pol.data), POL_HND_SIZE); + bzero(r_u.user_pol.data, POL_HND_SIZE); r_u.status = 0x0; @@ -1105,7 +1105,7 @@ static void samr_reply_unknown_32(SAMR_Q_UNKNOWN_32 *q_u, SAMR_R_UNKNOWN_32 r_u; /* set up the SAMR unknown_32 response */ - bzero(&(r_u.pol.data), POL_HND_SIZE); + bzero(r_u.pol.data, POL_HND_SIZE); if (status == 0) { for (i = 4; i < POL_HND_SIZE; i++) -- cgit From 684edc9fcd73d9c2059d018c4b5eb599888cfd8b Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 24 May 1998 13:36:43 +0000 Subject: - created pdb_sethexpwd(), to be called from all pwd apis that need to store passwords in ascii format - dealt with lots of signed/unsigned char thingies spotted by Tim Winders. (This used to be commit bd825f1ef15c4bf12aeba945f8bfdc7fd0e14d25) --- source3/rpc_server/srv_netlog.c | 4 ++-- source3/rpc_server/srv_reg.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index c81a8244d9..821945b757 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -344,8 +344,8 @@ static void api_net_auth_2( int uid, cred_create(vuser->dc.sess_key, &(vuser->dc.srv_cred.challenge), srv_time, &srv_cred); /* copy the received client credentials for use next time */ - memcpy(vuser->dc.clnt_cred.challenge.data, &(q_a.clnt_chal.data), sizeof(q_a.clnt_chal.data)); - memcpy(vuser->dc.srv_cred.challenge.data, &(q_a.clnt_chal.data), sizeof(q_a.clnt_chal.data)); + memcpy(vuser->dc.clnt_cred.challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); + memcpy(vuser->dc.srv_cred .challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); } else { diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index fa856f6983..3f9cdc20f4 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -38,7 +38,7 @@ static void reg_reply_close(REG_Q_CLOSE *q_r, REG_R_CLOSE r_u; /* set up the REG unknown_1 response */ - bzero(&(r_u.pol.data), POL_HND_SIZE); + bzero(r_u.pol.data, POL_HND_SIZE); /* close the policy handle */ if (close_lsa_policy_hnd(&(q_r->pol))) -- cgit From 6a19bf582f2ebe6bab015f37aca98eade239db61 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 24 May 1998 17:47:49 +0000 Subject: more warnings, from Tim Winders (This used to be commit eb157d6da4719b415a1f5202364aa77f2596bc03) --- source3/rpc_server/srv_lsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index ff4b6bf4b6..e723b532b1 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -39,7 +39,7 @@ static void lsa_reply_open_policy(prs_struct *rdata) LSA_R_OPEN_POL r_o; /* set up the LSA QUERY INFO response */ - bzero(&(r_o.pol.data), POL_HND_SIZE); + bzero(r_o.pol.data, POL_HND_SIZE); for (i = 4; i < POL_HND_SIZE; i++) { r_o.pol.data[i] = i; -- cgit From 59e2992139774762456826f6667e73f2b39828d8 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 4 Jun 1998 15:24:20 +0000 Subject: added "domain admin group" and "domain guest group" parameters. this is because "domain admin users" and "domain guest users" was overloaded. incorrectly. (This used to be commit 04b824007263ac4879c7282a2d230deaac7d2c7b) --- source3/rpc_server/srv_util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index fca37db717..64f2e7a0d9 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -312,26 +312,26 @@ void get_domain_user_groups(char *domain_groups, char *user) pstrcpy(domain_groups, lp_domain_groups()); /* can only be a user or a guest. cannot be guest _and_ admin */ - if (user_in_list(user, lp_domain_guest_users())) + if (user_in_list(user, lp_domain_guest_group())) { slprintf(tmp, sizeof(tmp) - 1, " %ld/7 ", DOMAIN_GROUP_RID_GUESTS); pstrcat(domain_groups, tmp); - DEBUG(3,("domain guest access %s granted\n", tmp)); + DEBUG(3,("domain guest group access %s granted\n", tmp)); } else { slprintf(tmp, sizeof(tmp) -1, " %ld/7 ", DOMAIN_GROUP_RID_USERS); pstrcat(domain_groups, tmp); - DEBUG(3,("domain user access %s granted\n", tmp)); + DEBUG(3,("domain group access %s granted\n", tmp)); - if (user_in_list(user, lp_domain_admin_users())) + if (user_in_list(user, lp_domain_admin_group())) { slprintf(tmp, sizeof(tmp) - 1, " %ld/7 ", DOMAIN_GROUP_RID_ADMINS); pstrcat(domain_groups, tmp); - DEBUG(3,("domain admin access %s granted\n", tmp)); + DEBUG(3,("domain admin group access %s granted\n", tmp)); } } } -- cgit From 88d88f5d0d23c8c849739b9441872734c0431c99 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 5 Jun 1998 20:46:05 +0000 Subject: loadparm.c: Did it ! Changed defaults for 'case preserve' and 'short case preserve'. Also removed 'domain allow/deny' parameters. shmem_sysv.c: Added strerror code so I can see why sysV calls are failing. lib/rpc/server/srv_netlog.c: Removed code that used 'domain allow/deny' parameters - replaced with a comment so I will remember to fix this later. Jeremy. (This used to be commit 5f46c7c4b11a75f1ffbd806cde915b4bf28232db) --- source3/rpc_server/srv_netlog.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 821945b757..0679e876e2 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -229,7 +229,16 @@ static void net_reply_sam_logoff(NET_Q_SAM_LOGOFF *q_s, prs_struct *rdata, static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) { struct smb_passwd *smb_pass; - extern int Client; + +#if 0 + /* + * Currently this code is redundent as we already have a filter + * by hostname list. What this code really needs to do is to + * get a hosts allowed/hosts denied list from the SAM database + * on a per user basis, and make the access decision there. + * I will leave this code here for now as a reminder to implement + * this at a later date. JRA. + */ if (!allow_access(lp_domain_hostsdeny(), lp_domain_hostsallow(), client_name(Client), client_addr(Client))) @@ -237,6 +246,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) DEBUG(0,("get_md4pw: Workstation %s denied access to domain\n", mach_acct)); return False; } +#endif /* 0 */ become_root(True); smb_pass = getsmbpwnam(mach_acct); -- cgit From e85295d9241bcdad3723898ab8ad88d8f11d5f28 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 9 Jun 1998 02:26:26 +0000 Subject: loadparm.c: Removed 'domain other sids' parameter. lib/rpc/include/rpc_lsa.h: Changed #defines for RPC calls - moved some, made LSA_LOOKUPNAMES correct. lib/rpc/include/rpc_misc.h: Changed DOMAIN_ALIAS_xxx to BUILTIN_ALIAS_xxx. Changed bitmasks for uid to rid to be 1 bit. lib/rpc/parse/parse_misc.c: Changed make_unistr2 to put length as given, max length as one more. lib/rpc/server/srv_netlog.c: Removed 'domain other sids' parameter. lib/rpc/server/srv_samr.c: Changed DOMAIN_ALIAS_xxx to BUILTIN_ALIAS_xxx. lib/rpc/server/srv_util.c: Changed DOMAIN_ALIAS_xxx to BUILTIN_ALIAS_xxx. Jeremy. (This used to be commit 34c91840a3d8c252715dc2f749b7a3b171a5b74f) --- source3/rpc_server/srv_netlog.c | 4 +--- source3/rpc_server/srv_samr.c | 4 ++-- source3/rpc_server/srv_util.c | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 0679e876e2..38481cd2d3 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -691,7 +691,6 @@ static void api_net_sam_logon( int uid, pstring my_name; pstring my_workgroup; pstring domain_groups; - pstring other_sids; uint32 r_uid; uint32 r_gid; @@ -708,7 +707,6 @@ static void api_net_sam_logon( int uid, pstrcpy(logon_script, lp_logon_script()); pstrcpy(profile_path, lp_logon_path()); - pstrcpy(other_sids, lp_domain_other_sids()); pstrcpy(my_workgroup, lp_workgroup()); pstrcpy(home_drive, lp_logon_drive()); @@ -767,7 +765,7 @@ static void api_net_sam_logon( int uid, my_workgroup, /* char *logon_dom */ &global_machine_sid, /* DOM_SID *dom_sid */ - other_sids); /* char *other_sids */ + NULL); /* char *other_sids */ } else { diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index d0304d0dd6..5ca37f4b83 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -414,7 +414,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, got_aliases = True; num_entries = 1; make_unistr2(&(pass[0].uni_user_name), dummy_alias, strlen(dummy_alias)); - pass[0].user_rid = DOMAIN_ALIAS_RID_ADMINS; + pass[0].user_rid = BUILTIN_ALIAS_RID_ADMINS; if (r_e.status == 0 && got_aliases) { @@ -637,7 +637,7 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, #endif num_rids = 1; - rid[0] = DOMAIN_ALIAS_RID_USERS; + rid[0] = BUILTIN_ALIAS_RID_USERS; make_samr_r_lookup_ids(&r_u, num_rids, rid, status); diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 64f2e7a0d9..1ccd14c813 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -48,16 +48,16 @@ extern int DEBUGLEVEL; i.e the DOMAIN_GROUP_RID_ADMIN/USER/GUEST. */ rid_name domain_alias_rids[] = { - { DOMAIN_ALIAS_RID_ADMINS , "admins" }, - { DOMAIN_ALIAS_RID_USERS , "users" }, - { DOMAIN_ALIAS_RID_GUESTS , "guests" }, - { DOMAIN_ALIAS_RID_POWER_USERS , "power_users" }, - - { DOMAIN_ALIAS_RID_ACCOUNT_OPS , "account_ops" }, - { DOMAIN_ALIAS_RID_SYSTEM_OPS , "system_ops" }, - { DOMAIN_ALIAS_RID_PRINT_OPS , "print_ops" }, - { DOMAIN_ALIAS_RID_BACKUP_OPS , "backup_ops" }, - { DOMAIN_ALIAS_RID_REPLICATOR , "replicator" }, + { BUILTIN_ALIAS_RID_ADMINS , "admins" }, + { BUILTIN_ALIAS_RID_USERS , "users" }, + { BUILTIN_ALIAS_RID_GUESTS , "guests" }, + { BUILTIN_ALIAS_RID_POWER_USERS , "power_users" }, + + { BUILTIN_ALIAS_RID_ACCOUNT_OPS , "account_ops" }, + { BUILTIN_ALIAS_RID_SYSTEM_OPS , "system_ops" }, + { BUILTIN_ALIAS_RID_PRINT_OPS , "print_ops" }, + { BUILTIN_ALIAS_RID_BACKUP_OPS , "backup_ops" }, + { BUILTIN_ALIAS_RID_REPLICATOR , "replicator" }, { 0 , NULL } }; -- cgit From 72bf410b6e9b85f8fbff7f6175661829bef35f62 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 10 Jun 1998 19:45:13 +0000 Subject: De-coupled the mapping of a Windows to UNIX username from the Get_Pwnam username case conversion wrapper. It is now (very) explicit where we are mapping between an incoming Windows username, and when we are doing a UNIX password entry lookup, which may change the case of the given username. This makes things *much* clearer (IMHO:-) and will ease the adding of the 'groupname map' parameter, and the addition of the special 'jeremy' mode for Samba where unix users will not be needed. (We must think of a better name for it :-). Jeremy. (This used to be commit fb6ed81844e7cb6049749e43ac9b4adfaf4ca2de) --- source3/rpc_server/srv_lsa.c | 13 ++++++++++++- source3/rpc_server/srv_netlog.c | 10 ++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index e723b532b1..43f463a8ab 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -371,7 +371,18 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, /* convert received RIDs to strings, so we can do them. */ for (i = 0; i < q_l.num_entries; i++) { - char *user_name = unistr2(q_l.lookup_name[i].str.buffer); + fstring user_name; + fstrcpy(user_name, unistr2(q_l.lookup_name[i].str.buffer)); + /* + * Map to the UNIX username. + */ + map_username(user_name); + + /* + * Do any case conversions. + */ + (void)Get_Pwnam(user_name, True); + if (!pdb_name_to_rid(user_name, &dom_rids[i], &dummy_g_rid)) { /* WHOOPS! we should really do something about this... */ diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 38481cd2d3..8bcf1682bc 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -641,6 +641,16 @@ static void api_net_sam_logon( int uid, DEBUG(3,("User:[%s]\n", samlogon_user)); + /* + * Convert to a UNIX username. + */ + map_username(samlogon_user); + + /* + * Do any case conversions. + */ + (void)Get_Pwnam(samlogon_user, True); + become_root(True); smb_pass = getsmbpwnam(samlogon_user); unbecome_root(True); -- cgit From 9a735eb7e25d8bf6c5be7775d89436034ea6be8a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 12 Jun 1998 03:08:23 +0000 Subject: ipc.c: map_username is now a BOOL function. reply.c: map_username is now a BOOL function. server.c: Added capability to do map_username on service names when looking for a home directory. That's what the original code would do. lib/rpc/server/srv_util.c: Changed domain_ to builtin_ for BUILTIN aliases. username.c: Work in progress on groupname map parameter. Jeremy (This used to be commit fa95fae5eed95aff64f0a01825477610a101bbc7) --- source3/rpc_server/srv_util.c | 52 ++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 1ccd14c813..e05a964c9f 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -43,21 +43,23 @@ extern int DEBUGLEVEL; -/* array lookup of well-known RID aliases. the purpose of these escapes me.. */ -/* XXXX this structure should not have the well-known RID groups added to it, - i.e the DOMAIN_GROUP_RID_ADMIN/USER/GUEST. */ -rid_name domain_alias_rids[] = +/* + * A list of the rids of well known BUILTIN and Domain users + * and groups. + */ + +rid_name builtin_alias_rids[] = { - { BUILTIN_ALIAS_RID_ADMINS , "admins" }, - { BUILTIN_ALIAS_RID_USERS , "users" }, - { BUILTIN_ALIAS_RID_GUESTS , "guests" }, - { BUILTIN_ALIAS_RID_POWER_USERS , "power_users" }, - - { BUILTIN_ALIAS_RID_ACCOUNT_OPS , "account_ops" }, - { BUILTIN_ALIAS_RID_SYSTEM_OPS , "system_ops" }, - { BUILTIN_ALIAS_RID_PRINT_OPS , "print_ops" }, - { BUILTIN_ALIAS_RID_BACKUP_OPS , "backup_ops" }, - { BUILTIN_ALIAS_RID_REPLICATOR , "replicator" }, + { BUILTIN_ALIAS_RID_ADMINS , "Administrators" }, + { BUILTIN_ALIAS_RID_USERS , "Users" }, + { BUILTIN_ALIAS_RID_GUESTS , "Guests" }, + { BUILTIN_ALIAS_RID_POWER_USERS , "Power Users" }, + + { BUILTIN_ALIAS_RID_ACCOUNT_OPS , "Account Operators" }, + { BUILTIN_ALIAS_RID_SYSTEM_OPS , "System Operators" }, + { BUILTIN_ALIAS_RID_PRINT_OPS , "Print Operators" }, + { BUILTIN_ALIAS_RID_BACKUP_OPS , "Backup Operators" }, + { BUILTIN_ALIAS_RID_REPLICATOR , "Replicator" }, { 0 , NULL } }; @@ -72,9 +74,9 @@ rid_name domain_user_rids[] = /* array lookup of well-known Domain RID groups. */ rid_name domain_group_rids[] = { - { DOMAIN_GROUP_RID_ADMINS , "domain admins" }, - { DOMAIN_GROUP_RID_USERS , "domain users" }, - { DOMAIN_GROUP_RID_GUESTS , "domain guests" }, + { DOMAIN_GROUP_RID_ADMINS , "Domain Admins" }, + { DOMAIN_GROUP_RID_USERS , "Domain Users" }, + { DOMAIN_GROUP_RID_GUESTS , "Domain Guests" }, { 0 , NULL } }; @@ -119,11 +121,11 @@ int make_dom_gids(char *gids_str, DOM_GID **ppgids) attr = "7"; /* default value for attribute is 7 */ /* look up the RID string and see if we can turn it into a rid number */ - for (i = 0; domain_alias_rids[i].name != NULL; i++) + for (i = 0; builtin_alias_rids[i].name != NULL; i++) { - if (strequal(domain_alias_rids[i].name, s2)) + if (strequal(builtin_alias_rids[i].name, s2)) { - rid = domain_alias_rids[i].rid; + rid = builtin_alias_rids[i].rid; break; } } @@ -373,14 +375,14 @@ uint32 lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) DEBUG(5,("lookup_alias_name: rid: %d", rid)); - while (domain_alias_rids[i].rid != rid && domain_alias_rids[i].rid != 0) + while (builtin_alias_rids[i].rid != rid && builtin_alias_rids[i].rid != 0) { i++; } - if (domain_alias_rids[i].rid != 0) + if (builtin_alias_rids[i].rid != 0) { - fstrcpy(alias_name, domain_alias_rids[i].name); + fstrcpy(alias_name, builtin_alias_rids[i].name); DEBUG(5,(" = %s\n", alias_name)); return 0x0; } @@ -459,8 +461,8 @@ uint32 lookup_alias_rid(char *alias_name, uint32 *rid) do /* find, if it exists, a alias rid for the alias name*/ { i++; - (*rid) = domain_alias_rids[i].rid; - als_name = domain_alias_rids[i].name; + (*rid) = builtin_alias_rids[i].rid; + als_name = builtin_alias_rids[i].name; } while (als_name != NULL && !strequal(als_name, alias_name)); -- cgit From 5b5eb35c91ec400a25f6e6cf3eec421bd9560d50 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 13 Jun 1998 03:04:00 +0000 Subject: Makefile: Added ubi_sLinkList.o as the groupname.o file needs it. Added groupname.o includes.h: Added ubi_sLinkList.h include. loadparm.c: Added groupname map parameter. password.c: Fix HPUX big_crypt. username.c: New user_in_list() code. Moved groupname map code to groupname.c lib/rpc/server/srv_util.c: Added lookup_wellknown_sid_from_name(). New groupname map stuff. Note that nothing currently uses this but at compiles ok. Jeremy. (This used to be commit beef636a4d772457816ef068c62ea965d07131f6) --- source3/rpc_server/srv_util.c | 87 +++++++++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 24 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index e05a964c9f..c316661146 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -42,44 +42,83 @@ #include "nterr.h" extern int DEBUGLEVEL; +extern DOM_SID global_machine_sid; /* * A list of the rids of well known BUILTIN and Domain users * and groups. */ -rid_name builtin_alias_rids[] = -{ - { BUILTIN_ALIAS_RID_ADMINS , "Administrators" }, - { BUILTIN_ALIAS_RID_USERS , "Users" }, - { BUILTIN_ALIAS_RID_GUESTS , "Guests" }, - { BUILTIN_ALIAS_RID_POWER_USERS , "Power Users" }, - - { BUILTIN_ALIAS_RID_ACCOUNT_OPS , "Account Operators" }, - { BUILTIN_ALIAS_RID_SYSTEM_OPS , "System Operators" }, - { BUILTIN_ALIAS_RID_PRINT_OPS , "Print Operators" }, - { BUILTIN_ALIAS_RID_BACKUP_OPS , "Backup Operators" }, - { BUILTIN_ALIAS_RID_REPLICATOR , "Replicator" }, - { 0 , NULL } +rid_name builtin_alias_rids[] = +{ + { BUILTIN_ALIAS_RID_ADMINS , "Administrators" }, + { BUILTIN_ALIAS_RID_USERS , "Users" }, + { BUILTIN_ALIAS_RID_GUESTS , "Guests" }, + { BUILTIN_ALIAS_RID_POWER_USERS , "Power Users" }, + + { BUILTIN_ALIAS_RID_ACCOUNT_OPS , "Account Operators" }, + { BUILTIN_ALIAS_RID_SYSTEM_OPS , "System Operators" }, + { BUILTIN_ALIAS_RID_PRINT_OPS , "Print Operators" }, + { BUILTIN_ALIAS_RID_BACKUP_OPS , "Backup Operators" }, + { BUILTIN_ALIAS_RID_REPLICATOR , "Replicator" }, + { 0 , NULL } }; /* array lookup of well-known Domain RID users. */ -rid_name domain_user_rids[] = -{ - { DOMAIN_USER_RID_ADMIN , "Administrator" }, - { DOMAIN_USER_RID_GUEST , "Guest" }, - { 0 , NULL } +rid_name domain_user_rids[] = +{ + { DOMAIN_USER_RID_ADMIN , "Administrator" }, + { DOMAIN_USER_RID_GUEST , "Guest" }, + { 0 , NULL } }; /* array lookup of well-known Domain RID groups. */ -rid_name domain_group_rids[] = -{ - { DOMAIN_GROUP_RID_ADMINS , "Domain Admins" }, - { DOMAIN_GROUP_RID_USERS , "Domain Users" }, - { DOMAIN_GROUP_RID_GUESTS , "Domain Guests" }, - { 0 , NULL } +rid_name domain_group_rids[] = +{ + { DOMAIN_GROUP_RID_ADMINS , "Domain Admins" }, + { DOMAIN_GROUP_RID_USERS , "Domain Users" }, + { DOMAIN_GROUP_RID_GUESTS , "Domain Guests" }, + { 0 , NULL } }; +/************************************************************************** + Check if a name matches any of the well known SID values. +***************************************************************************/ + +BOOL lookup_wellknown_sid_from_name(char *windows_name, DOM_SID *psid) +{ + rid_name *rnp; + int i; + + for( i = 0; builtin_alias_rids[i].name != NULL; i++) { + rnp = &builtin_alias_rids[i]; + if(strequal(rnp->name, windows_name)) { + string_to_sid( psid, "S-1-5-32" ); + psid->sub_auths[psid->num_auths++] = rnp->rid; + return True; + } + } + + for( i = 0; domain_user_rids[i].name != NULL; i++ ) { + rnp = &domain_user_rids[i]; + if(strequal(rnp->name, windows_name)) { + *psid = global_machine_sid; + psid->sub_auths[psid->num_auths++] = rnp->rid; + return True; + } + } + + for( i = 0; domain_group_rids[i].name != NULL; i++ ) { + rnp = &domain_group_rids[i]; + if(strequal(rnp->name, windows_name)) { + *psid = global_machine_sid; + psid->sub_auths[psid->num_auths++] = rnp->rid; + return True; + } + } + + return False; +} int make_dom_gids(char *gids_str, DOM_GID **ppgids) { -- cgit From 06e42fa8659483495055eb3aab1982ebf3d0efa3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 29 Jun 1998 22:50:49 +0000 Subject: nmbd_elections.c: Removed force elections code to bring into line with 1.9.18. nmbd_namelistdb.c: Added comment for Chris. nmbd_subnetdb.c: Went back to Chris's comparison code as with the make_nmb_name change it all works now. lib/rpc/server/srv_netlog.c: Ensure we return 'account disabled' for disabled accounts, rather than crashing. Jeremy. (This used to be commit 4ab3d1682789319965a55edb37212b7671a743bb) --- source3/rpc_server/srv_netlog.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 8bcf1682bc..cb22cfddf0 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -252,7 +252,8 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) smb_pass = getsmbpwnam(mach_acct); unbecome_root(True); - if (smb_pass != NULL) + 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); @@ -656,9 +657,9 @@ static void api_net_sam_logon( int uid, unbecome_root(True); if (smb_pass == NULL) - { status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - } + else if (smb_pass->acct_ctrl & ACB_DISABLED) + status = 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED; } /* validate password. */ -- cgit From 8d42ee0f2c8cdd8d9f41e5e245999a9a6d44523f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 29 Jul 1998 03:15:02 +0000 Subject: some merge cleanups (This used to be commit 1d655b7c64231b0aec0548bb90fc3dcc3f37791c) --- source3/rpc_server/dummy.in | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 source3/rpc_server/dummy.in (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/dummy.in b/source3/rpc_server/dummy.in new file mode 100644 index 0000000000..e69de29bb2 -- cgit From 87bcd5502c105921b48f9654d1c4f6d14ed9e9f6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 9 Aug 1998 11:25:49 +0000 Subject: added ignore rules for the dummy files (This used to be commit 687f76a17d6d3ebd33b4d9a848deef56f3c1f56a) --- source3/rpc_server/.cvsignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 source3/rpc_server/.cvsignore (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/.cvsignore b/source3/rpc_server/.cvsignore new file mode 100644 index 0000000000..421376db9e --- /dev/null +++ b/source3/rpc_server/.cvsignore @@ -0,0 +1 @@ +dummy -- cgit From b9623ab59e813131b1ed3f51616a46e719d59c21 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 14 Aug 1998 17:38:29 +0000 Subject: this is the bug change to using connection_struct* instead of cnum. Connections[] is now a local array in server.c I might have broken something with this change. In particular the oplock code is suspect and some .dll files aren't being oplocked when I expected them to be. I'll look at it after I've got some sleep. (This used to be commit c7ee025ead4a85b6fa44a832047b878451845fb6) --- source3/rpc_server/srv_pipe_hnd.c | 117 ++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 61 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 8abfb54c8f..d792a16426 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -40,7 +40,7 @@ static int chain_pnum = -1; pipes_struct Pipes[MAX_OPEN_PIPES]; #define P_OPEN(p) ((p)->open) -#define P_OK(p,c) (P_OPEN(p) && (c)==((p)->cnum)) +#define P_OK(p,c) (P_OPEN(p) && (c)==((p)->conn)) #define VALID_PNUM(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PIPES)) #define OPEN_PNUM(pnum) (VALID_PNUM(pnum) && P_OPEN(&(Pipes[pnum]))) #define PNUM_OK(pnum,c) (OPEN_PNUM(pnum) && (c)==Pipes[pnum].cnum) @@ -93,44 +93,43 @@ void init_rpc_pipe_hnd(void) /**************************************************************************** find first available file slot ****************************************************************************/ -int open_rpc_pipe_hnd(char *pipe_name, int cnum, uint16 vuid) +int open_rpc_pipe_hnd(char *pipe_name, connection_struct *conn, uint16 vuid) { int i; /* we start at 1 here for an obscure reason I can't now remember, but I think is important :-) */ - for (i = 1; i < MAX_OPEN_PIPES; i++) - { - if (!Pipes[i].open) - { - Pipes[i].open = True; - Pipes[i].device_state = 0; - Pipes[i].cnum = cnum; - Pipes[i].uid = vuid; - - Pipes[i].rhdr.data = NULL; - Pipes[i].rdata.data = NULL; - Pipes[i].rhdr.offset = 0; - Pipes[i].rdata.offset = 0; - - Pipes[i].file_offset = 0; - Pipes[i].hdr_offsets = 0; - Pipes[i].frag_len_left = 0; - Pipes[i].next_frag_start = 0; - - fstrcpy(Pipes[i].name, pipe_name); - - DEBUG(4,("Opened pipe %s with handle %x\n", - pipe_name, i + PIPE_HANDLE_OFFSET)); - - set_chain_pnum(i); - - return(i); - } + for (i = 1; i < MAX_OPEN_PIPES; i++) { + if (!Pipes[i].open) break; } - DEBUG(1,("ERROR! Out of pipe structures - perhaps increase MAX_OPEN_PIPES?\n")); + if (i == MAX_OPEN_PIPES) { + DEBUG(1,("ERROR! Out of pipe structures\n")); + return(-1); + } - return(-1); + Pipes[i].open = True; + Pipes[i].device_state = 0; + Pipes[i].conn = conn; + Pipes[i].uid = vuid; + + Pipes[i].rhdr.data = NULL; + Pipes[i].rdata.data = NULL; + Pipes[i].rhdr.offset = 0; + Pipes[i].rdata.offset = 0; + + Pipes[i].file_offset = 0; + Pipes[i].hdr_offsets = 0; + Pipes[i].frag_len_left = 0; + Pipes[i].next_frag_start = 0; + + fstrcpy(Pipes[i].name, pipe_name); + + DEBUG(4,("Opened pipe %s with handle %x\n", + pipe_name, i + PIPE_HANDLE_OFFSET)); + + set_chain_pnum(i); + + return(i); } /**************************************************************************** @@ -151,9 +150,8 @@ int read_pipe(uint16 pnum, char *data, uint32 pos, int n) if (VALID_PNUM(pnum - PIPE_HANDLE_OFFSET)) { - DEBUG(6,("name: %s cnum: %d open: %s pos: %d len: %d", + DEBUG(6,("name: %s open: %s pos: %d len: %d", p->name, - p->cnum, BOOLSTR(p->open), pos, n)); } @@ -269,9 +267,8 @@ BOOL get_rpc_pipe(int pnum, pipes_struct **p) if (VALID_PNUM(pnum - PIPE_HANDLE_OFFSET)) { - DEBUG(6,("name: %s cnum: %d open: %s ", + DEBUG(6,("name: %s open: %s ", Pipes[pnum - PIPE_HANDLE_OFFSET].name, - Pipes[pnum - PIPE_HANDLE_OFFSET].cnum, BOOLSTR(Pipes[pnum - PIPE_HANDLE_OFFSET].open))); } if (OPEN_PNUM(pnum - PIPE_HANDLE_OFFSET)) @@ -306,8 +303,8 @@ BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state) if (P_OPEN(p)) { - DEBUG(3,("%s Setting pipe device state=%x on pipe (name=%s cnum=%d)\n", - timestring(), device_state, p->name, p->cnum)); + DEBUG(3,("%s Setting pipe device state=%x on pipe (name=%s)\n", + timestring(), device_state, p->name)); p->device_state = device_state; @@ -315,8 +312,8 @@ BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state) } else { - DEBUG(3,("%s Error setting pipe device state=%x (name=%s cnum=%d)\n", - timestring(), device_state, p->name, p->cnum)); + DEBUG(3,("%s Error setting pipe device state=%x (name=%s)\n", + timestring(), device_state, p->name)); return False; } } @@ -324,32 +321,30 @@ BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state) /**************************************************************************** close an rpc pipe ****************************************************************************/ -BOOL close_rpc_pipe_hnd(int pnum, int cnum) +BOOL close_rpc_pipe_hnd(int pnum, connection_struct *conn) { pipes_struct *p = NULL; get_rpc_pipe(pnum, &p); - /* mapping is PIPE_HANDLE_OFFSET up... */ + /* mapping is PIPE_HANDLE_OFFSET up... */ - if (p != NULL && P_OK(p, cnum)) - { - DEBUG(3,("%s Closed pipe name %s pnum=%x cnum=%d\n", - timestring(),Pipes[pnum-PIPE_HANDLE_OFFSET].name, pnum,cnum)); + if (p != NULL && P_OK(p, conn)) { + DEBUG(3,("%s Closed pipe name %s pnum=%x\n", + timestring(),Pipes[pnum-PIPE_HANDLE_OFFSET].name, + pnum)); - p->open = False; - - p->rdata.offset = 0; - p->rhdr.offset = 0; - mem_buf_free(&(p->rdata.data)); - mem_buf_free(&(p->rhdr .data)); - - return True; - } - else - { - DEBUG(3,("%s Error closing pipe pnum=%x cnum=%d\n", - timestring(),pnum, cnum)); - return False; - } + p->open = False; + + p->rdata.offset = 0; + p->rhdr.offset = 0; + mem_buf_free(&(p->rdata.data)); + mem_buf_free(&(p->rhdr .data)); + + return True; + } else { + DEBUG(3,("%s Error closing pipe pnum=%x\n", + timestring(),pnum)); + return False; + } } /**************************************************************************** -- cgit From 127655cc888ac40332d4e8e5b94aab03f5120aae Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 15 Aug 1998 07:27:34 +0000 Subject: this checkin gets rid of the global Files[] array and makes it local in files.c it should now be faily easy to expand the default MAX_OPEN_FILES to many thousands. (This used to be commit b088c804f98908eb02f05ab2f2e8a61691a0a582) --- source3/rpc_server/srv_pipe_hnd.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index d792a16426..bd29578f0e 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -35,8 +35,6 @@ static int chain_pnum = -1; #define MAX_OPEN_PIPES 50 #endif -#define PIPE_HANDLE_OFFSET 0x800 - pipes_struct Pipes[MAX_OPEN_PIPES]; #define P_OPEN(p) ((p)->open) -- cgit From f2d538a105a61ce6d2852700fc328e15ac158827 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Aug 1998 03:06:20 +0000 Subject: some cleanups from the conversion of Pipes[] to a linked list. I also removed most cases where a pnum is used and substituted a pipes_struct*. in files.c I added a offset of 0x1000 to all file handles on the wire. This makes it much less likely that bad parsing will give us the wrong field. (This used to be commit 8bc2627ff28d340db65bfa017daca2dc291d5ef7) --- source3/rpc_server/srv_pipe_hnd.c | 432 ++++++++++++++++++-------------------- 1 file changed, 210 insertions(+), 222 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index bd29578f0e..dfc4eeba5f 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -28,36 +28,34 @@ #define PIPE "\\PIPE\\" #define PIPELEN strlen(PIPE) +/* this must be larger than the sum of the open files and directories */ +#define PIPE_HANDLE_OFFSET 0x7000 + extern int DEBUGLEVEL; -static int chain_pnum = -1; +static pipes_struct *chain_p; +static int pipes_open; #ifndef MAX_OPEN_PIPES -#define MAX_OPEN_PIPES 50 +#define MAX_OPEN_PIPES 64 #endif -pipes_struct Pipes[MAX_OPEN_PIPES]; - -#define P_OPEN(p) ((p)->open) -#define P_OK(p,c) (P_OPEN(p) && (c)==((p)->conn)) -#define VALID_PNUM(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PIPES)) -#define OPEN_PNUM(pnum) (VALID_PNUM(pnum) && P_OPEN(&(Pipes[pnum]))) -#define PNUM_OK(pnum,c) (OPEN_PNUM(pnum) && (c)==Pipes[pnum].cnum) - +static pipes_struct *Pipes; +static struct bitmap *bmap; /**************************************************************************** reset pipe chain handle number ****************************************************************************/ -void reset_chain_pnum(void) +void reset_chain_p(void) { - chain_pnum = -1; + chain_p = NULL; } /**************************************************************************** sets chain pipe-file handle ****************************************************************************/ -void set_chain_pnum(int new_pnum) +void set_chain_p(pipes_struct *new_p) { - chain_pnum = new_pnum; + chain_p = new_p; } /**************************************************************************** @@ -65,71 +63,85 @@ void set_chain_pnum(int new_pnum) ****************************************************************************/ void init_rpc_pipe_hnd(void) { - int i; - /* we start at 1 here for an obscure reason I can't now remember, - but I think is important :-) */ - for (i = 1; i < MAX_OPEN_PIPES; i++) - { - Pipes[i].open = False; - Pipes[i].name[0] = 0; - Pipes[i].pipe_srv_name[0] = 0; - - Pipes[i].rhdr.data = NULL; - Pipes[i].rdata.data = NULL; - Pipes[i].rhdr.offset = 0; - Pipes[i].rdata.offset = 0; - - Pipes[i].file_offset = 0; - Pipes[i].hdr_offsets = 0; - Pipes[i].frag_len_left = 0; - Pipes[i].next_frag_start = 0; + bmap = bitmap_allocate(MAX_OPEN_PIPES); + if (!bmap) { + exit_server("out of memory in init_rpc_pipe_hnd\n"); } - - return; } + /**************************************************************************** find first available file slot ****************************************************************************/ -int open_rpc_pipe_hnd(char *pipe_name, connection_struct *conn, uint16 vuid) +pipes_struct *open_rpc_pipe_p(char *pipe_name, + connection_struct *conn, uint16 vuid) { int i; - /* we start at 1 here for an obscure reason I can't now remember, - but I think is important :-) */ - for (i = 1; i < MAX_OPEN_PIPES; i++) { - if (!Pipes[i].open) break; + pipes_struct *p; + static int next_pipe; + + /* not repeating pipe numbers makes it easier to track things in + log files and prevents client bugs where pipe numbers are reused + over connection restarts */ + if (next_pipe == 0) { + next_pipe = (getpid() ^ time(NULL)) % MAX_OPEN_PIPES; } - if (i == MAX_OPEN_PIPES) { - DEBUG(1,("ERROR! Out of pipe structures\n")); - return(-1); + i = bitmap_find(bmap, next_pipe); + + if (i == -1) { + DEBUG(0,("ERROR! Out of pipe structures\n")); + return NULL; + } + + next_pipe = (i+1) % MAX_OPEN_PIPES; + + p = (pipes_struct *)malloc(sizeof(*p)); + if (!p) return NULL; + + /* hook into the front of the list */ + if (!Pipes) { + Pipes = p; + } else { + Pipes->prev = p; + p->next = Pipes; + Pipes = p; } - Pipes[i].open = True; - Pipes[i].device_state = 0; - Pipes[i].conn = conn; - Pipes[i].uid = vuid; + bitmap_set(bmap, i); + i += PIPE_HANDLE_OFFSET; + + pipes_open++; + + memset(p, 0, sizeof(*p)); + p->pnum = i; + + p->open = True; + p->device_state = 0; + p->conn = conn; + p->uid = vuid; - Pipes[i].rhdr.data = NULL; - Pipes[i].rdata.data = NULL; - Pipes[i].rhdr.offset = 0; - Pipes[i].rdata.offset = 0; + p->rhdr.data = NULL; + p->rdata.data = NULL; + p->rhdr.offset = 0; + p->rdata.offset = 0; - Pipes[i].file_offset = 0; - Pipes[i].hdr_offsets = 0; - Pipes[i].frag_len_left = 0; - Pipes[i].next_frag_start = 0; + p->file_offset = 0; + p->hdr_offsets = 0; + p->frag_len_left = 0; + p->next_frag_start = 0; - fstrcpy(Pipes[i].name, pipe_name); + fstrcpy(p->name, pipe_name); - DEBUG(4,("Opened pipe %s with handle %x\n", - pipe_name, i + PIPE_HANDLE_OFFSET)); + DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n", + pipe_name, i, pipes_open)); - set_chain_pnum(i); + set_chain_p(p); - return(i); + return p; } + /**************************************************************************** reads data from a pipe. @@ -141,157 +153,111 @@ int open_rpc_pipe_hnd(char *pipe_name, connection_struct *conn, uint16 vuid) have been prepared into arrays of headers + data stream sections. ****************************************************************************/ -int read_pipe(uint16 pnum, char *data, uint32 pos, int n) +int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) { - pipes_struct *p = &Pipes[pnum - PIPE_HANDLE_OFFSET]; - DEBUG(6,("read_pipe: %x", pnum)); - - if (VALID_PNUM(pnum - PIPE_HANDLE_OFFSET)) - { - DEBUG(6,("name: %s open: %s pos: %d len: %d", - p->name, - BOOLSTR(p->open), - pos, n)); + int num = 0; + int len = 0; + uint32 hdr_num = 0; + int data_hdr_pos; + int data_pos; + + DEBUG(6,("read_pipe: %x", p->pnum)); + + DEBUG(6,("name: %s open: %s pos: %d len: %d", + p->name, + BOOLSTR(p->open), + pos, n)); + + if (!p || !p->open) { + DEBUG(6,("pipe not open\n")); + return -1; } - if (OPEN_PNUM(pnum - PIPE_HANDLE_OFFSET)) - { - int num = 0; - int len = 0; - uint32 hdr_num = 0; - int data_hdr_pos; - int data_pos; - - DEBUG(6,("OK\n")); - - if (p->rhdr.data == NULL || p->rhdr.data->data == NULL || - p->rhdr.data->data_used == 0) - { - return 0; - } - - DEBUG(6,("read_pipe: p: %p file_offset: %d file_pos: %d\n", - p, p->file_offset, n)); - DEBUG(6,("read_pipe: frag_len_left: %d next_frag_start: %d\n", - p->frag_len_left, p->next_frag_start)); - - /* the read request starts from where the SMBtrans2 left off. */ - data_pos = p->file_offset - p->hdr_offsets; - data_hdr_pos = p->file_offset; - - len = mem_buf_len(p->rhdr.data); - num = len - (int)data_pos; - - DEBUG(6,("read_pipe: len: %d num: %d n: %d\n", len, num, n)); - if (num > n) num = n; - if (num <= 0) - { - DEBUG(5,("read_pipe: 0 or -ve data length\n")); - return 0; - } - - if (!IS_BITS_SET_ALL(p->hdr.flags, RPC_FLG_LAST)) - { - /* intermediate fragment - possibility of another header */ - - DEBUG(5,("read_pipe: frag_len: %d data_pos: %d data_hdr_pos: %d\n", - p->hdr.frag_len, data_pos, data_hdr_pos)); - - if (data_hdr_pos == p->next_frag_start) - { - DEBUG(6,("read_pipe: next fragment header\n")); - - /* this is subtracted from the total data bytes, later */ - hdr_num = 0x18; - - /* create and copy in a new header. */ - create_rpc_reply(p, data_pos, p->rdata.offset); - mem_buf_copy(data, p->rhdr.data, 0, 0x18); - - data += 0x18; - p->frag_len_left = p->hdr.frag_len; - p->next_frag_start += p->hdr.frag_len; - p->hdr_offsets += 0x18; - - /*DEBUG(6,("read_pipe: hdr_offsets: %d\n", p->hdr_offsets));*/ - } - } - - if (num < hdr_num) - { - DEBUG(5,("read_pipe: warning - data read only part of a header\n")); - } - - DEBUG(6,("read_pipe: adjusted data_pos: %d num-hdr_num: %d\n", - data_pos, num - hdr_num)); - mem_buf_copy(data, p->rhdr.data, data_pos, num - hdr_num); - - data_pos += num; - data_hdr_pos += num; - - if (hdr_num == 0x18 && num == 0x18) - { - DEBUG(6,("read_pipe: just header read\n")); + if (p->rhdr.data == NULL || p->rhdr.data->data == NULL || + p->rhdr.data->data_used == 0) { + return 0; + } - /* advance to the next fragment */ - p->frag_len_left -= 0x18; - } - else if (data_hdr_pos == p->next_frag_start) - { - DEBUG(6,("read_pipe: next fragment expected\n")); - } + DEBUG(6,("read_pipe: p: %p file_offset: %d file_pos: %d\n", + p, p->file_offset, n)); + DEBUG(6,("read_pipe: frag_len_left: %d next_frag_start: %d\n", + p->frag_len_left, p->next_frag_start)); - p->file_offset += num; + /* the read request starts from where the SMBtrans2 left off. */ + data_pos = p->file_offset - p->hdr_offsets; + data_hdr_pos = p->file_offset; - return num; + len = mem_buf_len(p->rhdr.data); + num = len - (int)data_pos; + + DEBUG(6,("read_pipe: len: %d num: %d n: %d\n", len, num, n)); + + if (num > n) num = n; + if (num <= 0) { + DEBUG(5,("read_pipe: 0 or -ve data length\n")); + return 0; + } + if (!IS_BITS_SET_ALL(p->hdr.flags, RPC_FLG_LAST)) { + /* intermediate fragment - possibility of another header */ + + DEBUG(5,("read_pipe: frag_len: %d data_pos: %d data_hdr_pos: %d\n", + p->hdr.frag_len, data_pos, data_hdr_pos)); + + if (data_hdr_pos == p->next_frag_start) { + DEBUG(6,("read_pipe: next fragment header\n")); + + /* this is subtracted from the total data bytes, later */ + hdr_num = 0x18; + + /* create and copy in a new header. */ + create_rpc_reply(p, data_pos, p->rdata.offset); + mem_buf_copy(data, p->rhdr.data, 0, 0x18); + + data += 0x18; + p->frag_len_left = p->hdr.frag_len; + p->next_frag_start += p->hdr.frag_len; + p->hdr_offsets += 0x18; + } + } - else - { - DEBUG(6,("NOT\n")); - return -1; + + if (num < hdr_num) { + DEBUG(5,("read_pipe: warning - data read only part of a header\n")); } -} - -/**************************************************************************** - gets the name of a pipe -****************************************************************************/ -BOOL get_rpc_pipe(int pnum, pipes_struct **p) -{ - DEBUG(6,("get_rpc_pipe: ")); - /* mapping is PIPE_HANDLE_OFFSET up... */ + DEBUG(6,("read_pipe: adjusted data_pos: %d num-hdr_num: %d\n", + data_pos, num - hdr_num)); + mem_buf_copy(data, p->rhdr.data, data_pos, num - hdr_num); + + data_pos += num; + data_hdr_pos += num; + + if (hdr_num == 0x18 && num == 0x18) { + DEBUG(6,("read_pipe: just header read\n")); - if (VALID_PNUM(pnum - PIPE_HANDLE_OFFSET)) - { - DEBUG(6,("name: %s open: %s ", - Pipes[pnum - PIPE_HANDLE_OFFSET].name, - BOOLSTR(Pipes[pnum - PIPE_HANDLE_OFFSET].open))); - } - if (OPEN_PNUM(pnum - PIPE_HANDLE_OFFSET)) - { - DEBUG(6,("OK\n")); - (*p) = &(Pipes[pnum - PIPE_HANDLE_OFFSET]); - return True; - } - else - { - DEBUG(6,("NOT\n")); - return False; + /* advance to the next fragment */ + p->frag_len_left -= 0x18; + } else if (data_hdr_pos == p->next_frag_start) { + DEBUG(6,("read_pipe: next fragment expected\n")); } + + p->file_offset += num; + + return num; } + /**************************************************************************** gets the name of a pipe ****************************************************************************/ -char *get_rpc_pipe_hnd_name(int pnum) +char *get_rpc_pipe_hnd_name(pipes_struct *p) { - pipes_struct *p = NULL; - get_rpc_pipe(pnum, &p); - return p != NULL ? p->name : NULL; + return p?p->name:NULL; } + /**************************************************************************** set device state on a pipe. exactly what this is for is unknown... ****************************************************************************/ @@ -299,57 +265,79 @@ BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state) { if (p == NULL) return False; - if (P_OPEN(p)) - { + if (p->open) { DEBUG(3,("%s Setting pipe device state=%x on pipe (name=%s)\n", timestring(), device_state, p->name)); p->device_state = device_state; - + return True; - } - else - { - DEBUG(3,("%s Error setting pipe device state=%x (name=%s)\n", - timestring(), device_state, p->name)); - return False; - } + } + + DEBUG(3,("%s Error setting pipe device state=%x (name=%s)\n", + timestring(), device_state, p->name)); + return False; } + /**************************************************************************** close an rpc pipe ****************************************************************************/ -BOOL close_rpc_pipe_hnd(int pnum, connection_struct *conn) +BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) { - pipes_struct *p = NULL; - get_rpc_pipe(pnum, &p); - /* mapping is PIPE_HANDLE_OFFSET up... */ - - if (p != NULL && P_OK(p, conn)) { - DEBUG(3,("%s Closed pipe name %s pnum=%x\n", - timestring(),Pipes[pnum-PIPE_HANDLE_OFFSET].name, - pnum)); - - p->open = False; - - p->rdata.offset = 0; - p->rhdr.offset = 0; - mem_buf_free(&(p->rdata.data)); - mem_buf_free(&(p->rhdr .data)); - - return True; - } else { - DEBUG(3,("%s Error closing pipe pnum=%x\n", - timestring(),pnum)); + if (!p) { + DEBUG(0,("Invalid pipe in close_rpc_pipe_hnd\n")); return False; } + + mem_buf_free(&(p->rdata.data)); + mem_buf_free(&(p->rhdr .data)); + + bitmap_clear(bmap, p->pnum - PIPE_HANDLE_OFFSET); + + pipes_open--; + + DEBUG(4,("closed pipe name %s pnum=%x (pipes_open=%d)\n", + p->name, p->pnum, pipes_open)); + + if (p == Pipes) { + Pipes = p->next; + if (Pipes) Pipes->prev = NULL; + } else { + p->prev->next = p->next; + if (p->next) p->next->prev = p->prev; + } + + memset(p, 0, sizeof(*p)); + + free(p); + + return True; } /**************************************************************************** close an rpc pipe ****************************************************************************/ -int get_rpc_pipe_num(char *buf, int where) +pipes_struct *get_rpc_pipe_p(char *buf, int where) { - return (chain_pnum != -1 ? chain_pnum : SVAL(buf,where)); + int pnum = SVAL(buf,where); + + if (chain_p) return chain_p; + + return get_rpc_pipe(pnum); +} + +/**************************************************************************** + close an rpc pipe +****************************************************************************/ +pipes_struct *get_rpc_pipe(int pnum) +{ + pipes_struct *p; + + for (p=Pipes;p;p=p->next) { + if (p->pnum == pnum) return p; + } + + return NULL; } -- cgit From 8978aae69699ccab76fdf95037948b1cc7e7c286 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Aug 1998 03:52:05 +0000 Subject: much cleaner chain pointer handling for both files and pipes. the chain pointer is now stored as a static and is set whenever a handle is created or extracted. This also makes the code less error prone. (This used to be commit 068a862982bea726e8d7b1b4065d510b9840a272) --- source3/rpc_server/srv_pipe_hnd.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index dfc4eeba5f..368bf013a0 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -50,14 +50,6 @@ void reset_chain_p(void) chain_p = NULL; } -/**************************************************************************** - sets chain pipe-file handle -****************************************************************************/ -void set_chain_p(pipes_struct *new_p) -{ - chain_p = new_p; -} - /**************************************************************************** initialise pipe handle states... ****************************************************************************/ @@ -136,7 +128,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n", pipe_name, i, pipes_open)); - set_chain_p(p); + chain_p = p; return p; } @@ -335,7 +327,10 @@ pipes_struct *get_rpc_pipe(int pnum) pipes_struct *p; for (p=Pipes;p;p=p->next) { - if (p->pnum == pnum) return p; + if (p->pnum == pnum) { + chain_p = p; + return p; + } } return NULL; -- cgit From 4a68715c2518a2d3c2eb4282b503c1ef7857b9d0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Aug 1998 04:54:06 +0000 Subject: converted the policy code to use a linked list and bitmap. This saves us a bit of memory. (This used to be commit 27da84b90df1f32e0d07acad04c72065b2005470) --- source3/rpc_server/srv_lsa_hnd.c | 283 ++++++++++++++++++++------------------- 1 file changed, 144 insertions(+), 139 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 91844ee8a2..2fc2c73ea3 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -28,7 +28,7 @@ extern int DEBUGLEVEL; #ifndef MAX_OPEN_POLS -#define MAX_OPEN_POLS 50 +#define MAX_OPEN_POLS 64 #endif struct reg_info @@ -45,23 +45,21 @@ struct samr_info uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ }; -static struct +static struct policy { - BOOL open; - POLICY_HND pol_hnd; + struct policy *next, *prev; + int pnum; + BOOL open; + POLICY_HND pol_hnd; - union - { - struct samr_info samr; - struct reg_info reg; + union { + struct samr_info samr; + struct reg_info reg; + } dev; +} *Policy; - } dev; +static struct bitmap *bmap; -} Policy[MAX_OPEN_POLS]; - - -#define VALID_POL(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_POLS)) -#define OPEN_POL(pnum) (VALID_POL(pnum) && Policy[pnum].open) /**************************************************************************** create a unique policy handle @@ -89,13 +87,10 @@ void create_pol_hnd(POLICY_HND *hnd) ****************************************************************************/ void init_lsa_policy_hnd(void) { - int i; - for (i = 0; i < MAX_OPEN_POLS; i++) - { - Policy[i].open = False; + bmap = bitmap_allocate(MAX_OPEN_POLS); + if (!bmap) { + exit_server("out of memory in init_lsa_policy_hnd\n"); } - - return; } /**************************************************************************** @@ -104,55 +99,75 @@ void init_lsa_policy_hnd(void) BOOL open_lsa_policy_hnd(POLICY_HND *hnd) { int i; + struct policy *p; - for (i = 0; i < MAX_OPEN_POLS; i++) - { - if (!Policy[i].open) - { - Policy[i].open = True; - - create_pol_hnd(hnd); - memcpy(&(Policy[i].pol_hnd), hnd, sizeof(*hnd)); + i = bitmap_find(bmap, 1); - DEBUG(4,("Opened policy hnd[%x] ", i)); - dump_data(4, (char *)hnd->data, sizeof(hnd->data)); + if (i == -1) { + DEBUG(0,("ERROR: out of Policy Handles!\n")); + return False; + } - return True; - } + p = (struct policy *)malloc(sizeof(*p)); + if (!p) { + DEBUG(0,("ERROR: out of memory!\n")); + return False; } - /* i love obscure error messages. */ -#if TERRY_PRATCHET_INTERESTING_TIMES - DEBUG(1,("+++ OUT OF CHEESE ERROR +++ REDO FROM START ... @?!*@@\n")); -#else - DEBUG(1,("ERROR - open_lsa_policy_hnd: out of Policy Handles!\n")); -#endif + memset(p, 0, sizeof(*p)); - return False; + p->open = True; + p->pnum = i; + + create_pol_hnd(hnd); + memcpy(&p->pol_hnd, hnd, sizeof(*hnd)); + + bitmap_set(bmap, i); + + /* hook into the front of the list */ + if (!Policy) { + Policy = p; + } else { + Policy->prev = p; + p->next = Policy; + Policy = p; + } + + DEBUG(4,("Opened policy hnd[%x] ", i)); + dump_data(4, (char *)hnd->data, sizeof(hnd->data)); + + return True; } /**************************************************************************** - find policy index by handle + find policy by handle ****************************************************************************/ -int find_lsa_policy_by_hnd(POLICY_HND *hnd) +static struct policy *find_lsa_policy(POLICY_HND *hnd) { - int i; + struct policy *p; - for (i = 0; i < MAX_OPEN_POLS; i++) - { - if (memcmp(&(Policy[i].pol_hnd), hnd, sizeof(*hnd)) == 0) - { - DEBUG(4,("Found policy hnd[%x] ", i)); + for (p=Policy;p;p=p->next) { + if (memcmp(&p->pol_hnd, hnd, sizeof(*hnd)) == 0) { + DEBUG(4,("Found policy hnd[%x] ", p->pnum)); dump_data(4, (char *)hnd->data, sizeof(hnd->data)); - - return i; + return p; } } DEBUG(4,("Policy not found: ")); dump_data(4, (char *)hnd->data, sizeof(hnd->data)); - return -1; + return NULL; +} + +/**************************************************************************** + find policy index by handle +****************************************************************************/ +int find_lsa_policy_by_hnd(POLICY_HND *hnd) +{ + struct policy *p = find_lsa_policy(hnd); + + return p?p->pnum:-1; } /**************************************************************************** @@ -160,45 +175,39 @@ int find_lsa_policy_by_hnd(POLICY_HND *hnd) ****************************************************************************/ BOOL set_lsa_policy_samr_rid(POLICY_HND *hnd, uint32 rid) { - int pnum = find_lsa_policy_by_hnd(hnd); + struct policy *p = find_lsa_policy(hnd); - if (OPEN_POL(pnum)) - { - DEBUG(3,("%s Setting policy device rid=%x pnum=%x\n", - timestring(), rid, pnum)); + if (p && p->open) { + DEBUG(3,("Setting policy device rid=%x pnum=%x\n", + rid, p->pnum)); - Policy[pnum].dev.samr.rid = rid; + p->dev.samr.rid = rid; return True; } - else - { - DEBUG(3,("%s Error setting policy rid=%x (pnum=%x)\n", - timestring(), rid, pnum)); - return False; - } + + DEBUG(3,("Error setting policy rid=%x\n",rid)); + return False; } + /**************************************************************************** set samr pol status. absolutely no idea what this is. ****************************************************************************/ BOOL set_lsa_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status) { - int pnum = find_lsa_policy_by_hnd(hnd); + struct policy *p = find_lsa_policy(hnd); - if (OPEN_POL(pnum)) - { - DEBUG(3,("%s Setting policy status=%x pnum=%x\n", - timestring(), pol_status, pnum)); + if (p && p->open) { + DEBUG(3,("Setting policy status=%x pnum=%x\n", + pol_status, p->pnum)); - Policy[pnum].dev.samr.status = pol_status; + p->dev.samr.status = pol_status; return True; - } - else - { - DEBUG(3,("%s Error setting policy status=%x (pnum=%x)\n", - timestring(), pol_status, pnum)); - return False; - } + } + + DEBUG(3,("Error setting policy status=%x\n", + pol_status)); + return False; } /**************************************************************************** @@ -206,23 +215,20 @@ BOOL set_lsa_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status) ****************************************************************************/ BOOL set_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) { - pstring sidstr; - int pnum = find_lsa_policy_by_hnd(hnd); - - if (OPEN_POL(pnum)) - { - DEBUG(3,("%s Setting policy sid=%s pnum=%x\n", - timestring(), sid_to_string(sidstr, sid), pnum)); - - memcpy(&(Policy[pnum].dev.samr.sid), sid, sizeof(*sid)); - return True; - } - else - { - DEBUG(3,("%s Error setting policy sid=%s (pnum=%x)\n", - timestring(), sid_to_string(sidstr, sid), pnum)); - return False; - } + pstring sidstr; + struct policy *p = find_lsa_policy(hnd); + + if (p && p->open) { + DEBUG(3,("Setting policy sid=%s pnum=%x\n", + sid_to_string(sidstr, sid), p->pnum)); + + memcpy(&p->dev.samr.sid, sid, sizeof(*sid)); + return True; + } + + DEBUG(3,("Error setting policy sid=%s\n", + sid_to_string(sidstr, sid))); + return False; } /**************************************************************************** @@ -230,22 +236,18 @@ BOOL set_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) ****************************************************************************/ uint32 get_lsa_policy_samr_rid(POLICY_HND *hnd) { - int pnum = find_lsa_policy_by_hnd(hnd); + struct policy *p = find_lsa_policy(hnd); - if (OPEN_POL(pnum)) - { - uint32 rid = Policy[pnum].dev.samr.rid; - DEBUG(3,("%s Getting policy device rid=%x pnum=%x\n", - timestring(), rid, pnum)); + if (p && p->open) { + uint32 rid = p->dev.samr.rid; + DEBUG(3,("Getting policy device rid=%x pnum=%x\n", + rid, p->pnum)); return rid; } - else - { - DEBUG(3,("%s Error getting policy (pnum=%x)\n", - timestring(), pnum)); - return 0xffffffff; - } + + DEBUG(3,("Error getting policy\n")); + return 0xffffffff; } /**************************************************************************** @@ -253,46 +255,38 @@ uint32 get_lsa_policy_samr_rid(POLICY_HND *hnd) ****************************************************************************/ BOOL set_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) { - int pnum = find_lsa_policy_by_hnd(hnd); + struct policy *p = find_lsa_policy(hnd); - if (OPEN_POL(pnum)) - { - DEBUG(3,("%s Setting policy pnum=%x name=%s\n", - timestring(), pnum, name)); + if (p && p->open) { + DEBUG(3,("Setting policy pnum=%x name=%s\n", + p->pnum, name)); - fstrcpy(Policy[pnum].dev.reg.name, name); + fstrcpy(p->dev.reg.name, name); return True; } - else - { - DEBUG(3,("%s Error setting policy (pnum=%x) name=%s\n", - timestring(), pnum, name)); - return False; - } + + DEBUG(3,("Error setting policy name=%s\n", name)); + return False; } /**************************************************************************** get reg name ****************************************************************************/ -BOOL get_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) +BOOL get_lsa_policy_reg_name(POLICY_HND *hnd, char *name) { - int pnum = find_lsa_policy_by_hnd(hnd); + struct policy *p = find_lsa_policy(hnd); - if (OPEN_POL(pnum)) - { - fstrcpy(name, Policy[pnum].dev.reg.name); + if (p && p->open) { + fstrcpy(name, p->dev.reg.name); - DEBUG(3,("%s Getting policy pnum=%x name=%s\n", - timestring(), pnum, name)); + DEBUG(3,("Getting policy pnum=%x name=%s\n", + p->pnum, name)); return True; } - else - { - DEBUG(3,("%s Error getting policy (pnum=%x)\n", - timestring(), pnum)); - return False; - } + + DEBUG(3,("Error getting policy\n")); + return False; } /**************************************************************************** @@ -300,18 +294,29 @@ BOOL get_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) ****************************************************************************/ BOOL close_lsa_policy_hnd(POLICY_HND *hnd) { - int pnum = find_lsa_policy_by_hnd(hnd); + struct policy *p = find_lsa_policy(hnd); - if (OPEN_POL(pnum)) - { - DEBUG(3,("%s Closed policy name pnum=%x\n", timestring(), pnum)); - Policy[pnum].open = False; - return True; - } - else - { - DEBUG(3,("%s Error closing policy pnum=%x\n", timestring(), pnum)); + if (!p) { + DEBUG(3,("Error closing policy\n")); return False; } + + DEBUG(3,("Closed policy name pnum=%x\n", p->pnum)); + + if (p == Policy) { + Policy = p->next; + if (Policy) Policy->prev = NULL; + } else { + p->prev->next = p->next; + if (p->next) p->next->prev = p->prev; + } + + bitmap_clear(bmap, p->pnum); + + memset(p, 0, sizeof(*p)); + + free(p); + + return True; } -- cgit From 72ed7049d88e5296ebec362189e62a384385ad34 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 17 Aug 1998 06:47:53 +0000 Subject: added some optimisation for the case where the number of open files is very large. files.c now promotes a files_struct to the top of the list if it is used when it is more than 10 elements from the top. also moved common linked list code for the 5 sets of linked lists that I've created over the past few days into dlinklist.h (I've explained to Chris why I didn't use the ubiqx code) (This used to be commit 1eb9ae2996b5a243a147f485e7e353d54f820852) --- source3/rpc_server/srv_lsa_hnd.c | 17 ++--------------- source3/rpc_server/srv_pipe_hnd.c | 17 ++--------------- 2 files changed, 4 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 2fc2c73ea3..d65116e646 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -124,14 +124,7 @@ BOOL open_lsa_policy_hnd(POLICY_HND *hnd) bitmap_set(bmap, i); - /* hook into the front of the list */ - if (!Policy) { - Policy = p; - } else { - Policy->prev = p; - p->next = Policy; - Policy = p; - } + DLIST_ADD(Policy, p); DEBUG(4,("Opened policy hnd[%x] ", i)); dump_data(4, (char *)hnd->data, sizeof(hnd->data)); @@ -303,13 +296,7 @@ BOOL close_lsa_policy_hnd(POLICY_HND *hnd) DEBUG(3,("Closed policy name pnum=%x\n", p->pnum)); - if (p == Policy) { - Policy = p->next; - if (Policy) Policy->prev = NULL; - } else { - p->prev->next = p->next; - if (p->next) p->next->prev = p->prev; - } + DLIST_REMOVE(Policy, p); bitmap_clear(bmap, p->pnum); diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 368bf013a0..b030ee0e90 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -91,14 +91,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p = (pipes_struct *)malloc(sizeof(*p)); if (!p) return NULL; - /* hook into the front of the list */ - if (!Pipes) { - Pipes = p; - } else { - Pipes->prev = p; - p->next = Pipes; - Pipes = p; - } + DLIST_ADD(Pipes, p); bitmap_set(bmap, i); i += PIPE_HANDLE_OFFSET; @@ -292,13 +285,7 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) DEBUG(4,("closed pipe name %s pnum=%x (pipes_open=%d)\n", p->name, p->pnum, pipes_open)); - if (p == Pipes) { - Pipes = p->next; - if (Pipes) Pipes->prev = NULL; - } else { - p->prev->next = p->next; - if (p->next) p->next->prev = p->prev; - } + DLIST_REMOVE(Pipes, p); memset(p, 0, sizeof(*p)); -- cgit From 57f1129cdc154c56ae70287999c5961e072b4975 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 21 Aug 1998 09:44:30 +0000 Subject: use ZERO_STRUCT() to initialise lots of structures. Luke, you need to do something similar in the rest of the rpc code. Have fun! (This used to be commit bdd8aaa544780898e20189195d4019b9beb4445c) --- source3/rpc_server/srv_lsa.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 43f463a8ab..da0c11ea7b 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -38,8 +38,10 @@ static void lsa_reply_open_policy(prs_struct *rdata) int i; LSA_R_OPEN_POL r_o; + ZERO_STRUCT(r_o); + /* set up the LSA QUERY INFO response */ - bzero(r_o.pol.data, POL_HND_SIZE); + for (i = 4; i < POL_HND_SIZE; i++) { r_o.pol.data[i] = i; @@ -78,6 +80,8 @@ static void lsa_reply_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM *q_e, { LSA_R_ENUM_TRUST_DOM r_e; + ZERO_STRUCT(r_e); + /* set up the LSA QUERY INFO response */ make_r_enum_trust_dom(&r_e, enum_context, dom_name, dom_sid, dom_name != NULL ? 0x0 : 0x80000000 | NT_STATUS_UNABLE_TO_FREE_VM); @@ -94,6 +98,8 @@ static void lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, { LSA_R_QUERY_INFO r_q; + ZERO_STRUCT(r_q); + /* set up the LSA QUERY INFO response */ r_q.undoc_buffer = 0x22000000; /* bizarre */ @@ -237,6 +243,10 @@ static void lsa_reply_lookup_sids(prs_struct *rdata, LSA_TRANS_NAME_ENUM names; uint32 mapped_count = 0; + ZERO_STRUCT(r_l); + ZERO_STRUCT(ref); + ZERO_STRUCT(names); + /* set up the LSA Lookup SIDs response */ make_dom_ref(&ref, dom_name, dom_sid, other_sid1, other_sid2, other_sid3); make_lsa_trans_names(&names, num_entries, sid, &mapped_count); @@ -256,6 +266,8 @@ static void lsa_reply_lookup_rids(prs_struct *rdata, { LSA_R_LOOKUP_RIDS r_l; + ZERO_STRUCT(r_l); + /* set up the LSA Lookup RIDs response */ make_reply_lookup_rids(&r_l, num_entries, dom_rids, dom_name, dom_sid, other_sid1, other_sid2, other_sid3); @@ -273,6 +285,8 @@ static void api_lsa_open_policy( int uid, prs_struct *data, { LSA_Q_OPEN_POL q_o; + ZERO_STRUCT(q_o); + /* grab the server, object attributes and desired access flag...*/ lsa_io_q_open_pol("", &q_o, data, 0); @@ -290,6 +304,8 @@ static void api_lsa_enum_trust_dom( int uid, prs_struct *data, { LSA_Q_ENUM_TRUST_DOM q_e; + ZERO_STRUCT(q_e); + /* grab the enum trust domain context etc. */ lsa_io_q_enum_trust_dom("", &q_e, data, 0); @@ -307,6 +323,8 @@ static void api_lsa_query_info( int uid, prs_struct *data, LSA_Q_QUERY_INFO q_i; pstring dom_name; + ZERO_STRUCT(q_i); + /* grab the info class and policy handle */ lsa_io_q_query("", &q_i, data, 0); @@ -328,6 +346,11 @@ static void api_lsa_lookup_sids( int uid, prs_struct *data, DOM_SID sid_S_1_3; DOM_SID sid_S_1_5; + ZERO_STRUCT(q_l); + ZERO_STRUCT(sid_S_1_1); + ZERO_STRUCT(sid_S_1_3); + ZERO_STRUCT(sid_S_1_5); + /* grab the info class and policy handle */ lsa_io_q_lookup_sids("", &q_l, data, 0); @@ -359,6 +382,12 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, uint32 dom_rids[MAX_LOOKUP_SIDS]; uint32 dummy_g_rid; + ZERO_STRUCT(q_l); + ZERO_STRUCT(sid_S_1_1); + ZERO_STRUCT(sid_S_1_3); + ZERO_STRUCT(sid_S_1_5); + ZERO_STRUCT(dom_rids); + /* grab the info class and policy handle */ lsa_io_q_lookup_rids("", &q_l, data, 0); -- cgit From 3f3f47b0bd8d089120d267cfad1976db95cd8ebe Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 22 Aug 1998 02:54:21 +0000 Subject: added ASSERT() and ASSERT_ARRAY() macros and sprinkled them liberally in the rpc code. (This used to be commit e6ce1c5b5a9f29d8fcbbd23019186ff5c600e795) --- source3/rpc_server/srv_lsa.c | 8 ++++++++ source3/rpc_server/srv_samr.c | 9 +++++++++ source3/rpc_server/srv_util.c | 3 +++ 3 files changed, 20 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index da0c11ea7b..d2ca2d7a76 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -163,6 +163,8 @@ static void make_reply_lookup_rids(LSA_R_LOOKUP_RIDS *r_l, r_l->undoc_buffer = 1; r_l->num_entries2 = num_entries; + ASSERT_ARRAY(r_l->dom_rid, num_entries); + for (i = 0; i < num_entries; i++) { make_dom_rid2(&(r_l->dom_rid[i]), dom_rids[i]); @@ -182,6 +184,8 @@ static void make_lsa_trans_names(LSA_TRANS_NAME_ENUM *trn, int i; (*total) = 0; + ASSERT(num_entries <= MAX_LOOKUP_SIDS); + for (i = 0; i < num_entries; i++) { uint32 rid = 0xffffffff; @@ -192,6 +196,8 @@ static void make_lsa_trans_names(LSA_TRANS_NAME_ENUM *trn, trn->ptr_name[i] = 0; trn->ptr_name[(*total)] = 0; + ASSERT_ARRAY(sid[i].sid.sub_auths, num_auths); + /* find the rid to look up */ if (num_auths != 0) { @@ -397,6 +403,8 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, string_to_sid(&sid_S_1_3, "S-1-3"); string_to_sid(&sid_S_1_5, "S-1-5"); + ASSERT_ARRAY(q_l.lookup_name, q_l.num_entries); + /* convert received RIDs to strings, so we can do them. */ for (i = 0; i < q_l.num_entries; i++) { diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 5ca37f4b83..b0742d0e34 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -235,6 +235,9 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, DOM_SID other_sid; user_sid = global_machine_sid; + + ASSERT_ARRAY(user_sid.sub_auths, user_sid.num_auths+1); + /* * Add the user RID. */ @@ -610,11 +613,14 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, #if 0 int i; + ASSERT_ARRAY(q_u->uni_user_name, num_rids); + for (i = 0; i < num_rids && status == 0; i++) { struct smb_passwd *smb_pass; fstring user_name; + fstrcpy(user_name, unistrn2(q_u->uni_user_name[i].buffer, q_u->uni_user_name[i].uni_str_len)); @@ -683,6 +689,8 @@ static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, DEBUG(5,("samr_lookup_names: truncating entries to %d\n", num_rids)); } + ASSERT_ARRAY(q_u->uni_user_name, num_rids); + for (i = 0; i < num_rids && status == 0; i++) { fstring name; @@ -890,6 +898,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) /* create a LOGON_HRS structure */ hrs.len = sam_pass->hours_len; + ASSERT_ARRAY(hrs.hours, hrs.len); for (i = 0; i < hrs.len; i++) { hrs.hours[i] = sam_pass->hours[i]; diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index c316661146..80e10a3d3a 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -94,6 +94,7 @@ BOOL lookup_wellknown_sid_from_name(char *windows_name, DOM_SID *psid) rnp = &builtin_alias_rids[i]; if(strequal(rnp->name, windows_name)) { string_to_sid( psid, "S-1-5-32" ); + ASSERT_ARRAY(psid->sub_auths, psid->num_auths+1); psid->sub_auths[psid->num_auths++] = rnp->rid; return True; } @@ -103,6 +104,7 @@ BOOL lookup_wellknown_sid_from_name(char *windows_name, DOM_SID *psid) rnp = &domain_user_rids[i]; if(strequal(rnp->name, windows_name)) { *psid = global_machine_sid; + ASSERT_ARRAY(psid->sub_auths, psid->num_auths+1); psid->sub_auths[psid->num_auths++] = rnp->rid; return True; } @@ -112,6 +114,7 @@ BOOL lookup_wellknown_sid_from_name(char *windows_name, DOM_SID *psid) rnp = &domain_group_rids[i]; if(strequal(rnp->name, windows_name)) { *psid = global_machine_sid; + ASSERT_ARRAY(psid->sub_auths, psid->num_auths+1); psid->sub_auths[psid->num_auths++] = rnp->rid; return True; } -- cgit From 8afc9c80ac11649f06e5517d819dbf201c941acb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 24 Aug 1998 21:49:10 +0000 Subject: Changed ASSERT macros to SMB_ASSERT macros as some systems already have an ASSERT macro defined. Jeremy. (This used to be commit dbe6ad014a8b5dcbf17d7cd9865650c2e040d666) --- source3/rpc_server/srv_lsa.c | 8 ++++---- source3/rpc_server/srv_samr.c | 8 ++++---- source3/rpc_server/srv_util.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index d2ca2d7a76..0675743eee 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -163,7 +163,7 @@ static void make_reply_lookup_rids(LSA_R_LOOKUP_RIDS *r_l, r_l->undoc_buffer = 1; r_l->num_entries2 = num_entries; - ASSERT_ARRAY(r_l->dom_rid, num_entries); + SMB_ASSERT_ARRAY(r_l->dom_rid, num_entries); for (i = 0; i < num_entries; i++) { @@ -184,7 +184,7 @@ static void make_lsa_trans_names(LSA_TRANS_NAME_ENUM *trn, int i; (*total) = 0; - ASSERT(num_entries <= MAX_LOOKUP_SIDS); + SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS); for (i = 0; i < num_entries; i++) { @@ -196,7 +196,7 @@ static void make_lsa_trans_names(LSA_TRANS_NAME_ENUM *trn, trn->ptr_name[i] = 0; trn->ptr_name[(*total)] = 0; - ASSERT_ARRAY(sid[i].sid.sub_auths, num_auths); + SMB_ASSERT_ARRAY(sid[i].sid.sub_auths, num_auths); /* find the rid to look up */ if (num_auths != 0) @@ -403,7 +403,7 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, string_to_sid(&sid_S_1_3, "S-1-3"); string_to_sid(&sid_S_1_5, "S-1-5"); - ASSERT_ARRAY(q_l.lookup_name, q_l.num_entries); + SMB_ASSERT_ARRAY(q_l.lookup_name, q_l.num_entries); /* convert received RIDs to strings, so we can do them. */ for (i = 0; i < q_l.num_entries; i++) diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index b0742d0e34..95b0a413c7 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -236,7 +236,7 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, user_sid = global_machine_sid; - ASSERT_ARRAY(user_sid.sub_auths, user_sid.num_auths+1); + SMB_ASSERT_ARRAY(user_sid.sub_auths, user_sid.num_auths+1); /* * Add the user RID. @@ -613,7 +613,7 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, #if 0 int i; - ASSERT_ARRAY(q_u->uni_user_name, num_rids); + SMB_ASSERT_ARRAY(q_u->uni_user_name, num_rids); for (i = 0; i < num_rids && status == 0; i++) { @@ -689,7 +689,7 @@ static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, DEBUG(5,("samr_lookup_names: truncating entries to %d\n", num_rids)); } - ASSERT_ARRAY(q_u->uni_user_name, num_rids); + SMB_ASSERT_ARRAY(q_u->uni_user_name, num_rids); for (i = 0; i < num_rids && status == 0; i++) { @@ -898,7 +898,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) /* create a LOGON_HRS structure */ hrs.len = sam_pass->hours_len; - ASSERT_ARRAY(hrs.hours, hrs.len); + SMB_ASSERT_ARRAY(hrs.hours, hrs.len); for (i = 0; i < hrs.len; i++) { hrs.hours[i] = sam_pass->hours[i]; diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 80e10a3d3a..6c47db04bf 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -94,7 +94,7 @@ BOOL lookup_wellknown_sid_from_name(char *windows_name, DOM_SID *psid) rnp = &builtin_alias_rids[i]; if(strequal(rnp->name, windows_name)) { string_to_sid( psid, "S-1-5-32" ); - ASSERT_ARRAY(psid->sub_auths, psid->num_auths+1); + SMB_ASSERT_ARRAY(psid->sub_auths, psid->num_auths+1); psid->sub_auths[psid->num_auths++] = rnp->rid; return True; } @@ -104,7 +104,7 @@ BOOL lookup_wellknown_sid_from_name(char *windows_name, DOM_SID *psid) rnp = &domain_user_rids[i]; if(strequal(rnp->name, windows_name)) { *psid = global_machine_sid; - ASSERT_ARRAY(psid->sub_auths, psid->num_auths+1); + SMB_ASSERT_ARRAY(psid->sub_auths, psid->num_auths+1); psid->sub_auths[psid->num_auths++] = rnp->rid; return True; } @@ -114,7 +114,7 @@ BOOL lookup_wellknown_sid_from_name(char *windows_name, DOM_SID *psid) rnp = &domain_group_rids[i]; if(strequal(rnp->name, windows_name)) { *psid = global_machine_sid; - ASSERT_ARRAY(psid->sub_auths, psid->num_auths+1); + SMB_ASSERT_ARRAY(psid->sub_auths, psid->num_auths+1); psid->sub_auths[psid->num_auths++] = rnp->rid; return True; } -- cgit From 520d24c191941289ae1e86bc372cde4908a9fa35 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 26 Aug 1998 03:06:48 +0000 Subject: use a separate ZERO_ARRAY() macro instead of ZERO_STRUCT() for arrays. This prevents (harmless) warnings from some compilers (This used to be commit c2da46d1d0820a86e7f77506563cfe7f67b08fee) --- source3/rpc_server/srv_lsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 0675743eee..35ceeace04 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -392,7 +392,7 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, ZERO_STRUCT(sid_S_1_1); ZERO_STRUCT(sid_S_1_3); ZERO_STRUCT(sid_S_1_5); - ZERO_STRUCT(dom_rids); + ZERO_ARRAY(dom_rids); /* grab the info class and policy handle */ lsa_io_q_lookup_rids("", &q_l, data, 0); -- cgit From 61b5fd6f32e9ccb612df1354a3e3b3bed5f2b808 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 31 Aug 1998 03:11:42 +0000 Subject: bounds check next_token() to prevent possible buffer overflows (This used to be commit 3eade55dc7c842bdc50205c330802d211fae54d3) --- source3/rpc_server/srv_util.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 6c47db04bf..0a7728aa3a 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -137,7 +137,9 @@ int make_dom_gids(char *gids_str, DOM_GID **ppgids) if (gids_str == NULL || *gids_str == 0) return 0; - for (count = 0, ptr = gids_str; next_token(&ptr, s2, NULL); count++) + for (count = 0, ptr = gids_str; + next_token(&ptr, s2, NULL, sizeof(s2)); + count++) ; gids = (DOM_GID *)malloc( sizeof(DOM_GID) * count ); @@ -147,8 +149,10 @@ int make_dom_gids(char *gids_str, DOM_GID **ppgids) return 0; } - for (count = 0, ptr = gids_str; next_token(&ptr, s2, NULL) && - count < LSA_MAX_GROUPS; count++) + for (count = 0, ptr = gids_str; + next_token(&ptr, s2, NULL, sizeof(s2)) && + count < LSA_MAX_GROUPS; + count++) { /* the entries are of the form GID/ATTR, ATTR being optional.*/ char *attr; -- cgit From 33bf29fd24c1dc076055303a0f135c9a47fb9877 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 Sep 1998 16:06:04 +0000 Subject: Fixed uppercasing of share name (pointed out by Jean-Francois). Jeremy. (This used to be commit dcce6b98d847d02148fb2ab15f8430b870e106bd) --- source3/rpc_server/srv_srvsvc.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 1089f385d7..a4ae3fa0ef 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -48,7 +48,6 @@ static void make_srv_share_1_info(SH_INFO_1 *sh1, uint32 type; pstrcpy(net_name, lp_servicename(snum)); - strupper(net_name); pstrcpy(remark , lp_comment (snum)); len_net_name = strlen(net_name); -- cgit From e9ea36e4d2270bd7d32da12ef6d6e2299641582d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 5 Sep 1998 05:07:05 +0000 Subject: tridge the destroyer returns! prompted by the interpret_security() dead code that Jean-Francois pointed out I added a make target "finddead" that finds potentially dead (ie. unused) code. It spat out 304 function names ... I went through these are deleted many of them, making others static (finddead also reports functions that are used only in the local file). in doing this I have almost certainly deleted some useful code. I may have even prevented compilation with some compile options. I apologise. I decided it was better to get rid of this code now and add back the one or two functions that are needed than to keep all this baggage. So, if I have done a bit too much "destroying" then let me know. Keep the swearing to a minimum :) One bit I didn't do is the ubibt code. Chris, can you look at that? Heaps of unused functions there. Can they be made static? (This used to be commit 2204475c87f3024ea8fd1fbd7385b2def617a46f) --- source3/rpc_server/srv_lsa_hnd.c | 22 +------------------- source3/rpc_server/srv_pipe_hnd.c | 9 --------- source3/rpc_server/srv_util.c | 42 --------------------------------------- 3 files changed, 1 insertion(+), 72 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index d65116e646..addedaec90 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -64,7 +64,7 @@ static struct bitmap *bmap; /**************************************************************************** create a unique policy handle ****************************************************************************/ -void create_pol_hnd(POLICY_HND *hnd) +static void create_pol_hnd(POLICY_HND *hnd) { static uint32 pol_hnd_low = 0; static uint32 pol_hnd_high = 0; @@ -262,26 +262,6 @@ BOOL set_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) return False; } -/**************************************************************************** - get reg name -****************************************************************************/ -BOOL get_lsa_policy_reg_name(POLICY_HND *hnd, char *name) -{ - struct policy *p = find_lsa_policy(hnd); - - if (p && p->open) { - fstrcpy(name, p->dev.reg.name); - - DEBUG(3,("Getting policy pnum=%x name=%s\n", - p->pnum, name)); - - return True; - } - - DEBUG(3,("Error getting policy\n")); - return False; -} - /**************************************************************************** close an lsa policy ****************************************************************************/ diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index b030ee0e90..54b9ce1539 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -234,15 +234,6 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) } -/**************************************************************************** - gets the name of a pipe -****************************************************************************/ -char *get_rpc_pipe_hnd_name(pipes_struct *p) -{ - return p?p->name:NULL; -} - - /**************************************************************************** set device state on a pipe. exactly what this is for is unknown... ****************************************************************************/ diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 0a7728aa3a..68a4f79f0b 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -81,48 +81,6 @@ rid_name domain_group_rids[] = { 0 , NULL } }; -/************************************************************************** - Check if a name matches any of the well known SID values. -***************************************************************************/ - -BOOL lookup_wellknown_sid_from_name(char *windows_name, DOM_SID *psid) -{ - rid_name *rnp; - int i; - - for( i = 0; builtin_alias_rids[i].name != NULL; i++) { - rnp = &builtin_alias_rids[i]; - if(strequal(rnp->name, windows_name)) { - string_to_sid( psid, "S-1-5-32" ); - SMB_ASSERT_ARRAY(psid->sub_auths, psid->num_auths+1); - psid->sub_auths[psid->num_auths++] = rnp->rid; - return True; - } - } - - for( i = 0; domain_user_rids[i].name != NULL; i++ ) { - rnp = &domain_user_rids[i]; - if(strequal(rnp->name, windows_name)) { - *psid = global_machine_sid; - SMB_ASSERT_ARRAY(psid->sub_auths, psid->num_auths+1); - psid->sub_auths[psid->num_auths++] = rnp->rid; - return True; - } - } - - for( i = 0; domain_group_rids[i].name != NULL; i++ ) { - rnp = &domain_group_rids[i]; - if(strequal(rnp->name, windows_name)) { - *psid = global_machine_sid; - SMB_ASSERT_ARRAY(psid->sub_auths, psid->num_auths+1); - psid->sub_auths[psid->num_auths++] = rnp->rid; - return True; - } - } - - return False; -} - int make_dom_gids(char *gids_str, DOM_GID **ppgids) { char *ptr; -- cgit From f6044c87c021342d68d614d59bc8dacd32d223b9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 5 Sep 1998 13:24:20 +0000 Subject: some cleanups to use ZERO_STRUCT() and friends (This used to be commit 7b154dc4313324dfad6cf0117b8ce246bf12bf16) --- source3/rpc_server/srv_lsa_hnd.c | 4 ++-- source3/rpc_server/srv_pipe_hnd.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index addedaec90..b1e695360f 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -114,7 +114,7 @@ BOOL open_lsa_policy_hnd(POLICY_HND *hnd) return False; } - memset(p, 0, sizeof(*p)); + ZERO_STRUCTP(p); p->open = True; p->pnum = i; @@ -280,7 +280,7 @@ BOOL close_lsa_policy_hnd(POLICY_HND *hnd) bitmap_clear(bmap, p->pnum); - memset(p, 0, sizeof(*p)); + ZERO_STRUCTP(p); free(p); diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 54b9ce1539..3b743188a3 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -98,7 +98,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, pipes_open++; - memset(p, 0, sizeof(*p)); + ZERO_STRUCTP(p); p->pnum = i; p->open = True; @@ -278,7 +278,7 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) DLIST_REMOVE(Pipes, p); - memset(p, 0, sizeof(*p)); + ZERO_STRUCTP(p); free(p); -- cgit From e649750cb4d2d2577f0577b1d7a87ae4daf8fb6f Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Mon, 21 Sep 1998 09:07:08 +0000 Subject: major autoconf clean-up fix problems in builds with srcdir!=builddir (This used to be commit 1ffc3b807a3f80644c974b454ff5e6f68e89b546) --- source3/rpc_server/dummy.in | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/dummy.in b/source3/rpc_server/dummy.in index e69de29bb2..8b13789179 100644 --- a/source3/rpc_server/dummy.in +++ b/source3/rpc_server/dummy.in @@ -0,0 +1 @@ + -- cgit From 500a474aae49bd1cc8e75481a3b3cd6e79720d89 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 23 Sep 1998 21:49:09 +0000 Subject: nttrans.c: winreg was missing from the list of pipes. advise using the array already defined in... rpc_parse/parse_rpc.c's pipe_names[], but writing code to strip "\PIPE\" from the front when making the check. one location to update when adding new pipes, not two. srv_pipe_hnd.c: moved the ZERO_STRUCT(p) macro to _before_ the DLIST_ADD(Pipes, p) macro. dlinklist.h: added { }s around the code inserted by DLIST_ADD and DLIST_REMOVE macros (This used to be commit 29201d4b9b52652c7a992d0f6b677a09b4c33912) --- source3/rpc_server/srv_pipe_hnd.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 3b743188a3..cf7fc9334e 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -72,6 +72,9 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, pipes_struct *p; static int next_pipe; + DEBUG(4,("Open pipe requested %s (pipes_open=%d)\n", + pipe_name, pipes_open)); + /* not repeating pipe numbers makes it easier to track things in log files and prevents client bugs where pipe numbers are reused over connection restarts */ @@ -88,9 +91,15 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, next_pipe = (i+1) % MAX_OPEN_PIPES; + for (p = Pipes; p; p = p->next) + { + DEBUG(5,("open pipes: name %s pnum=%x\n", p->name, p->pnum)); + } + p = (pipes_struct *)malloc(sizeof(*p)); if (!p) return NULL; + ZERO_STRUCTP(p); DLIST_ADD(Pipes, p); bitmap_set(bmap, i); @@ -98,7 +107,6 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, pipes_open++; - ZERO_STRUCTP(p); p->pnum = i; p->open = True; @@ -123,7 +131,13 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, chain_p = p; - return p; + /* OVERWRITE p as a temp variable, to display all open pipes */ + for (p = Pipes; p; p = p->next) + { + DEBUG(5,("open pipes: name %s pnum=%x\n", p->name, p->pnum)); + } + + return chain_p; } @@ -304,8 +318,18 @@ pipes_struct *get_rpc_pipe(int pnum) { pipes_struct *p; - for (p=Pipes;p;p=p->next) { - if (p->pnum == pnum) { + DEBUG(4,("search for pipe pnum=%x\n", pnum)); + + for (p=Pipes;p;p=p->next) + { + DEBUG(5,("pipe name %s pnum=%x (pipes_open=%d)\n", + p->name, p->pnum, pipes_open)); + } + + for (p=Pipes;p;p=p->next) + { + if (p->pnum == pnum) + { chain_p = p; return p; } -- cgit From f650b65800c6d6c09cc2d59d7afe728fcb819a5f Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 24 Sep 1998 20:02:56 +0000 Subject: this fixes the last of the issues where USRMGR.EXE and SRVMGR.EXE were failing. running these two programs on a samba pdc now work. parse_samr.c: - removed __LINE__ from debug macros. - removed call to SMB_ASSERT_ARRAY() in samr_r_query_usergroups. the DOM_GID array is a malloc'd array (by make_dom_gids) not a static array. srv_samr.c: - replaced all "struct smb_passwd"s with sam_passwds instead. there were uid to rid confusion issues (assumptions that uids were equal to rids). - #if 0'd the pdb_rid_is_user() call which, given the above corrections, would probably work now. srv_util.c: - replaced "struct smb_passwd" with sam_passwd in lookup_user_rid, as assumptions were being made that uids were equal to rids. (This used to be commit 3f98697cd5203fba07518d7c777ba19644e35b45) --- source3/rpc_server/srv_samr.c | 57 +++++++++++++++++++++++++------------------ source3/rpc_server/srv_util.c | 9 +++---- 2 files changed, 37 insertions(+), 29 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 95b0a413c7..2c6e34801a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -46,7 +46,7 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, uint16 acb_mask) { void *vp = NULL; - struct smb_passwd *pwd = NULL; + struct sam_passwd *pwd = NULL; (*num_entries) = 0; (*total_entries) = 0; @@ -60,13 +60,13 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, return False; } - while (((pwd = getsmbpwent(vp)) != NULL) && (*num_entries) < max_num_entries) + while (((pwd = getsam21pwent(vp)) != NULL) && (*num_entries) < max_num_entries) { int user_name_len = strlen(pwd->smb_name); make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len-1); make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len-1, user_name_len-1, 1); - pw_buf[(*num_entries)].user_rid = pwd->smb_userid; + pw_buf[(*num_entries)].user_rid = pwd->user_rid; bzero( pw_buf[(*num_entries)].nt_pwd , 16); /* Now check if the NT compatible password is available. */ @@ -77,8 +77,8 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, pw_buf[(*num_entries)].acb_info = (uint16)pwd->acct_ctrl; - DEBUG(5, ("get_smbpwd_entries: idx: %d user %s, uid %d, acb %x", - (*num_entries), pwd->smb_name, pwd->smb_userid, pwd->acct_ctrl)); + DEBUG(5, ("entry idx: %d user %s, rid 0x%x, acb %x", + (*num_entries), pwd->smb_name, pwd->user_rid, pwd->acct_ctrl)); if (acb_mask == 0 || IS_BITS_SET_SOME(pwd->acct_ctrl, acb_mask)) { @@ -617,27 +617,26 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, for (i = 0; i < num_rids && status == 0; i++) { - struct smb_passwd *smb_pass; + struct sam_passwd *sam_pass; fstring user_name; fstrcpy(user_name, unistrn2(q_u->uni_user_name[i].buffer, - q_u->uni_user_name[i].uni_str_len)); + q_u->uni_user_name[i].uni_str_len)); /* find the user account */ become_root(True); - smb_pass = get_sampwd_entry(user_name, 0); + sam_pass = get_smb21pwd_entry(user_name, 0); unbecome_root(True); - if (smb_pass == NULL) + if (sam_pass == NULL) { status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; rid[i] = 0; } else { - /* lkclXXXX SHOULD use name_to_rid() here! */ - rid[i] = smb_pass->smb_userid; + rid[i] = sam_pass->user_rid; } } #endif @@ -798,7 +797,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, int status) { SAMR_R_OPEN_USER r_u; - struct smb_passwd *smb_pass; + struct sam_passwd *sam_pass; int pol_idx; BOOL pol_open = False; @@ -820,11 +819,11 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, } become_root(True); - smb_pass = getsmbpwuid(q_u->user_rid); + sam_pass = getsam21pwrid(q_u->user_rid); unbecome_root(True); /* check that the RID exists in our domain. */ - if (r_u.status == 0x0 && smb_pass == NULL) + if (r_u.status == 0x0 && sam_pass == NULL) { r_u.status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; } @@ -853,7 +852,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, /******************************************************************* api_samr_open_user ********************************************************************/ -static void api_samr_open_user( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_open_user( int rid, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_USER q_u; @@ -875,10 +874,13 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) LOGON_HRS hrs; int i; +#ifdef DONT_CHECK_THIS_FOR_NOW if (!pdb_rid_is_user(user_rid)) { + DEBUG(4,("RID 0x%x is not a user RID\n", user_rid)); return False; } +#endif become_root(True); sam_pass = getsam21pwrid(user_rid); @@ -886,6 +888,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) if (sam_pass == NULL) { + DEBUG(4,("User 0x%x not found\n", user_rid)); return False; } @@ -968,6 +971,8 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, status = NT_STATUS_OBJECT_TYPE_MISMATCH; } + DEBUG(5,("samr_reply_query_userinfo: rid:0x%x\n", rid)); + /* ok! user info levels (there are lots: see MSDEV help), off we go... */ if (status == 0x0) { @@ -1037,7 +1042,7 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, SAMR_R_QUERY_USERGROUPS r_u; uint32 status = 0x0; - struct smb_passwd *smb_pass; + struct sam_passwd *sam_pass; DOM_GID *gids = NULL; int num_groups = 0; int pol_idx; @@ -1060,10 +1065,10 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, if (status == 0x0) { become_root(True); - smb_pass = getsmbpwuid(rid); + sam_pass = getsam21pwrid(rid); unbecome_root(True); - if (smb_pass == NULL) + if (sam_pass == NULL) { status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; } @@ -1072,7 +1077,7 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, if (status == 0x0) { pstring groups; - get_domain_user_groups(groups, smb_pass->smb_name); + get_domain_user_groups(groups, sam_pass->smb_name); gids = NULL; num_groups = make_dom_gids(groups, &gids); } @@ -1083,8 +1088,11 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, /* store the response in the SMB stream */ samr_io_r_query_usergroups("", &r_u, rdata, 0); - if(gids) - free((char *)gids); + if (gids) + { + free((char *)gids); + } + DEBUG(5,("samr_query_usergroups: %d\n", __LINE__)); } @@ -1141,7 +1149,7 @@ static void samr_reply_unknown_32(SAMR_Q_UNKNOWN_32 *q_u, static void api_samr_unknown_32( int uid, prs_struct *data, prs_struct *rdata) { uint32 status = 0; - struct smb_passwd *smb_pass; + struct sam_passwd *sam_pass; fstring mach_acct; SAMR_Q_UNKNOWN_32 q_u; @@ -1159,10 +1167,10 @@ static void api_samr_unknown_32( int uid, prs_struct *data, prs_struct *rdata) q_u.uni_mach_acct.uni_str_len)); become_root(True); - smb_pass = getsmbpwnam(mach_acct); + sam_pass = getsam21pwnam(mach_acct); unbecome_root(True); - if (smb_pass != NULL) + if (sam_pass != NULL) { /* machine account exists: say so */ status = 0xC0000000 | NT_STATUS_USER_EXISTS; @@ -1170,6 +1178,7 @@ static void api_samr_unknown_32( int uid, prs_struct *data, prs_struct *rdata) else { /* this could cause trouble... */ + DEBUG(0,("trouble!\n")); status = 0; } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 68a4f79f0b..3c0fc9271e 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -478,18 +478,17 @@ uint32 lookup_alias_rid(char *alias_name, uint32 *rid) ********************************************************************/ uint32 lookup_user_rid(char *user_name, uint32 *rid) { - struct smb_passwd *smb_pass; + struct sam_passwd *sam_pass; (*rid) = 0; /* find the user account */ become_root(True); - smb_pass = getsmbpwnam(user_name); + sam_pass = getsam21pwnam(user_name); unbecome_root(True); - if (smb_pass != NULL) + if (sam_pass != NULL) { - /* lkclXXXX SHOULD use name_to_rid() here! */ - (*rid) = smb_pass->smb_userid; + (*rid) = sam_pass->user_rid; return 0x0; } -- cgit From 1ea570da834fa72c88dd35a86fdf68ae5ecbeb19 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Sat, 26 Sep 1998 00:41:20 +0000 Subject: Small update to clitar.c to omit warnings about servers not letting us change the date unless tar_real_noisy is True. Also updated a few places where variables are declared but not set. (This used to be commit b46f1024c939ee9ecb8deb9c844acbd4b5f109c6) --- source3/rpc_server/srv_samr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 2c6e34801a..a5684c8d86 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -954,7 +954,7 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, void *info = NULL; uint32 status = 0x0; - uint32 rid; + uint32 rid = 0x0; int obj_idx; DEBUG(5,("samr_reply_query_userinfo: %d\n", __LINE__)); -- cgit From cf971f88ac188eec353a7fb021744b8076cc4eb7 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Mon, 28 Sep 1998 00:14:36 +0000 Subject: automated generation of .dummy files for each subdirectory; dummy.in files are no longer needed, and new directories will be taken care of automatically, at configure (or config.status --recheck) time (This used to be commit 237a8e5fe62d757c04b8207cbbee4df1470cfe4e) --- source3/rpc_server/dummy.in | 1 - 1 file changed, 1 deletion(-) delete mode 100644 source3/rpc_server/dummy.in (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/dummy.in b/source3/rpc_server/dummy.in deleted file mode 100644 index 8b13789179..0000000000 --- a/source3/rpc_server/dummy.in +++ /dev/null @@ -1 +0,0 @@ - -- cgit From cf3a9741dc7427efb97eff09a3c197a906ce6767 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 28 Sep 1998 21:43:48 +0000 Subject: Changes to test in configure if capabilities are enabled on a system. Changes to get Samba to compile cleanly with the IRIX compiler with the options : -fullwarn -woff 1209,1174 (the -woff options are to turn off warnings about unused function parameters and controlling loop expressions being constants). Split prototype generation as we hit a limit in IRIX nawk. Removed "." code in smbd/filename.c (yet again :-). Jeremy. (This used to be commit e0567433bd72aec17bf5a54cc292701095d25f09) --- source3/rpc_server/srv_samr.c | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index a5684c8d86..c2140db36f 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -151,12 +151,11 @@ static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, { SAMR_R_OPEN_DOMAIN r_u; BOOL pol_open = False; - int pol_idx; r_u.status = 0x0; /* find the connection policy handle. */ - if (r_u.status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->connect_pol))) == -1)) + if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->connect_pol)) == -1)) { r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -211,14 +210,13 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, { SAMR_R_UNKNOWN_3 r_u; DOM_SID3 sid[MAX_SAM_SIDS]; - int pol_idx; uint32 rid; uint32 status; status = 0x0; /* find the policy handle. open a policy on it. */ - if (status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->user_pol))) == -1)) + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->user_pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -290,14 +288,12 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; int num_entries; int total_entries; - int pol_idx; - BOOL got_pwds; r_e.status = 0x0; r_e.total_num_entries = 0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1)) + if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -305,7 +301,7 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, DEBUG(5,("samr_reply_enum_dom_users: %d\n", __LINE__)); become_root(True); - got_pwds = get_sampwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, q_u->acb_mask); + get_sampwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, q_u->acb_mask); unbecome_root(True); make_samr_r_enum_dom_users(&r_e, total_entries, @@ -343,7 +339,6 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_R_ENUM_DOM_GROUPS r_e; SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; int num_entries; - int pol_idx; BOOL got_grps; char *dummy_group = "Domain Admins"; @@ -351,7 +346,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, r_e.num_entries = 0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1)) + if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -399,7 +394,6 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, SAMR_R_ENUM_DOM_ALIASES r_e; SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; int num_entries; - int pol_idx; BOOL got_aliases; char *dummy_alias = "admins"; @@ -407,7 +401,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, r_e.num_entries = 0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1)) + if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -459,14 +453,13 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; int num_entries; int total_entries; - int pol_idx; BOOL got_pwds; uint16 switch_level = 0x0; r_e.status = 0x0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1)) + if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -538,14 +531,12 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, prs_struct *rdata) { SAMR_R_QUERY_ALIASINFO r_e; - int pol_idx; - BOOL got_alias; r_e.status = 0x0; r_e.ptr = 0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1)) + if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -560,11 +551,6 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, } } - if (r_e.status == 0x0) - { - got_alias = True; - } - make_samr_r_query_aliasinfo(&r_e, q_u->switch_level, "", r_e.status); @@ -737,14 +723,13 @@ static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, uint32 group_attrs[MAX_SAM_ENTRIES]; uint32 status = 0; int num_gids = q_u->num_gids1; - uint32 pol_idx; SAMR_R_UNKNOWN_12 r_u; DEBUG(5,("samr_unknown_12: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1)) + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -798,7 +783,6 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, { SAMR_R_OPEN_USER r_u; struct sam_passwd *sam_pass; - int pol_idx; BOOL pol_open = False; /* set up the SAMR open_user response */ @@ -807,7 +791,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, r_u.status = 0x0; /* find the policy handle. open a policy on it. */ - if (r_u.status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->domain_pol))) == -1)) + if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->domain_pol)) == -1)) { r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -955,12 +939,11 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, uint32 status = 0x0; uint32 rid = 0x0; - int obj_idx; DEBUG(5,("samr_reply_query_userinfo: %d\n", __LINE__)); /* search for the handle */ - if (status == 0x0 && (obj_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1) + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { status = NT_STATUS_INVALID_HANDLE; } @@ -1045,13 +1028,12 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, struct sam_passwd *sam_pass; DOM_GID *gids = NULL; int num_groups = 0; - int pol_idx; uint32 rid; DEBUG(5,("samr_query_usergroups: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (status == 0x0 && ((pol_idx = find_lsa_policy_by_hnd(&(q_u->pol))) == -1)) + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } -- cgit From a2d7f765e8500f23c126c7b7cb6bb346adc11641 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Tue, 29 Sep 1998 04:52:17 +0000 Subject: get away with dummy and .dummy files (This used to be commit 90a8a02484a0897b053fd6531b7fec5d23098b6f) --- source3/rpc_server/.cvsignore | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/.cvsignore b/source3/rpc_server/.cvsignore index 421376db9e..e69de29bb2 100644 --- a/source3/rpc_server/.cvsignore +++ b/source3/rpc_server/.cvsignore @@ -1 +0,0 @@ -dummy -- cgit From 9066025a8a4afe1f7f559c455d86fc023792ed17 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 29 Sep 1998 20:24:17 +0000 Subject: Got very strict about the differences and uses of uid_t, gid_t and vuid. Added sys_getgroups() to get around the int * return problem. Set correct datatypes for all uid, gid and vuid variables. Jeremy. (This used to be commit e570db46fc3a78e499523fd342e9a34cebb18998) --- source3/rpc_server/srv_lsa.c | 70 ++++++++++++++++++++++----------------- source3/rpc_server/srv_netlog.c | 30 +++++++++-------- source3/rpc_server/srv_pipe_hnd.c | 2 +- source3/rpc_server/srv_reg.c | 8 ++--- source3/rpc_server/srv_samr.c | 34 +++++++++---------- source3/rpc_server/srv_srvsvc.c | 12 +++---- source3/rpc_server/srv_util.c | 2 +- source3/rpc_server/srv_wkssvc.c | 2 +- 8 files changed, 87 insertions(+), 73 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 35ceeace04..85e10275b8 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -286,7 +286,7 @@ static void lsa_reply_lookup_rids(prs_struct *rdata, /*************************************************************************** api_lsa_open_policy ***************************************************************************/ -static void api_lsa_open_policy( int uid, prs_struct *data, +static void api_lsa_open_policy( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_OPEN_POL q_o; @@ -305,7 +305,7 @@ static void api_lsa_open_policy( int uid, prs_struct *data, /*************************************************************************** api_lsa_enum_trust_dom ***************************************************************************/ -static void api_lsa_enum_trust_dom( int uid, prs_struct *data, +static void api_lsa_enum_trust_dom( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_ENUM_TRUST_DOM q_e; @@ -316,14 +316,13 @@ static void api_lsa_enum_trust_dom( int uid, prs_struct *data, lsa_io_q_enum_trust_dom("", &q_e, data, 0); /* construct reply. return status is always 0x0 */ - lsa_reply_enum_trust_dom(&q_e, rdata, - 0, NULL, NULL); + lsa_reply_enum_trust_dom(&q_e, rdata, 0, NULL, NULL); } /*************************************************************************** api_lsa_query_info ***************************************************************************/ -static void api_lsa_query_info( int uid, prs_struct *data, +static void api_lsa_query_info( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_QUERY_INFO q_i; @@ -343,7 +342,7 @@ static void api_lsa_query_info( int uid, prs_struct *data, /*************************************************************************** api_lsa_lookup_sids ***************************************************************************/ -static void api_lsa_lookup_sids( int uid, prs_struct *data, +static void api_lsa_lookup_sids( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_LOOKUP_SIDS q_l; @@ -363,20 +362,20 @@ static void api_lsa_lookup_sids( int uid, prs_struct *data, pstrcpy(dom_name, lp_workgroup()); string_to_sid(&sid_S_1_1, "S-1-1"); - string_to_sid(&sid_S_1_3, "S-1-3"); - string_to_sid(&sid_S_1_5, "S-1-5"); + string_to_sid(&sid_S_1_3, "S-1-3"); + string_to_sid(&sid_S_1_5, "S-1-5"); /* construct reply. return status is always 0x0 */ - lsa_reply_lookup_sids(rdata, - q_l.sids.num_entries, q_l.sids.sid, /* SIDs */ - dom_name, &global_machine_sid, /* domain name, domain SID */ - &sid_S_1_1, &sid_S_1_3, &sid_S_1_5); /* the three other SIDs */ + lsa_reply_lookup_sids(rdata, + q_l.sids.num_entries, q_l.sids.sid, /* SIDs */ + dom_name, &global_machine_sid, /* domain name, domain SID */ + &sid_S_1_1, &sid_S_1_3, &sid_S_1_5); /* the three other SIDs */ } /*************************************************************************** api_lsa_lookup_names ***************************************************************************/ -static void api_lsa_lookup_names( int uid, prs_struct *data, +static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rdata ) { int i; @@ -400,8 +399,8 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, pstrcpy(dom_name, lp_workgroup()); string_to_sid(&sid_S_1_1, "S-1-1"); - string_to_sid(&sid_S_1_3, "S-1-3"); - string_to_sid(&sid_S_1_5, "S-1-5"); + string_to_sid(&sid_S_1_3, "S-1-3"); + string_to_sid(&sid_S_1_5, "S-1-5"); SMB_ASSERT_ARRAY(q_l.lookup_name, q_l.num_entries); @@ -437,18 +436,24 @@ static void api_lsa_lookup_names( int uid, prs_struct *data, /*************************************************************************** api_lsa_close ***************************************************************************/ -static void api_lsa_close( int uid, prs_struct *data, +static void api_lsa_close( uint16 vuid, prs_struct *data, prs_struct *rdata) { /* XXXX this is NOT good */ char *q = mem_data(&(rdata->data), rdata->offset); - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; rdata->offset += 24; } @@ -456,18 +461,24 @@ static void api_lsa_close( int uid, prs_struct *data, /*************************************************************************** api_lsa_open_secret ***************************************************************************/ -static void api_lsa_open_secret( int uid, prs_struct *data, +static void api_lsa_open_secret( uint16 vuid, prs_struct *data, prs_struct *rdata) { /* XXXX this is NOT good */ char *q = mem_data(&(rdata->data), rdata->offset); - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0); q += 4; - SIVAL(q, 0, 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND); q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0); + q += 4; + SIVAL(q, 0, 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND); + q += 4; rdata->offset += 24; } @@ -494,4 +505,3 @@ BOOL api_ntlsa_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds, data); } - diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index cb22cfddf0..17a534b6f0 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -267,7 +267,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) /************************************************************************* api_net_req_chal: *************************************************************************/ -static void api_net_req_chal( int uid, +static void api_net_req_chal( uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -279,9 +279,10 @@ static void api_net_req_chal( int uid, user_struct *vuser; - DEBUG(5,("api_net_req_chal(%d): vuid %d\n", __LINE__, uid)); + DEBUG(5,("api_net_req_chal(%d): vuid %d\n", __LINE__, (int)vuid)); - if ((vuser = get_valid_user_struct(uid)) == NULL) return; + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return; /* grab the challenge... */ net_io_q_req_chal("", &q_r, data, 0); @@ -327,7 +328,7 @@ static void api_net_req_chal( int uid, /************************************************************************* api_net_auth_2: *************************************************************************/ -static void api_net_auth_2( int uid, +static void api_net_auth_2( uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -339,7 +340,8 @@ static void api_net_auth_2( int uid, user_struct *vuser; - if ((vuser = get_valid_user_struct(uid)) == NULL) return; + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return; srv_time.time = 0; @@ -371,7 +373,7 @@ static void api_net_auth_2( int uid, /************************************************************************* api_net_srv_pwset: *************************************************************************/ -static void api_net_srv_pwset( int uid, +static void api_net_srv_pwset( uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -383,7 +385,8 @@ static void api_net_srv_pwset( int uid, BOOL ret; user_struct *vuser; - if ((vuser = get_valid_user_struct(uid)) == NULL) return; + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return; /* grab the challenge and encrypted password ... */ net_io_q_srv_pwset("", &q_a, data, 0); @@ -452,7 +455,7 @@ static void api_net_srv_pwset( int uid, /************************************************************************* api_net_sam_logoff: *************************************************************************/ -static void api_net_sam_logoff( int uid, +static void api_net_sam_logoff( uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -463,7 +466,8 @@ static void api_net_sam_logoff( int uid, user_struct *vuser; - if ((vuser = get_valid_user_struct(uid)) == NULL) return; + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return; /* the DOM_ID_INFO_1 structure is a bit big. plus we might want to dynamically allocate it inside net_io_q_sam_logon, at some point */ @@ -572,7 +576,7 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, /************************************************************************* api_net_sam_logon: *************************************************************************/ -static void api_net_sam_logon( int uid, +static void api_net_sam_logon( uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -586,7 +590,7 @@ static void api_net_sam_logon( int uid, user_struct *vuser = NULL; - if ((vuser = get_valid_user_struct(uid)) == NULL) + if ((vuser = get_valid_user_struct(vuid)) == NULL) return; q_l.sam_id.ctr = &ctr; @@ -795,7 +799,7 @@ static void api_net_sam_logon( int uid, /************************************************************************* api_net_trust_dom_list: *************************************************************************/ -static void api_net_trust_dom_list( int uid, +static void api_net_trust_dom_list( uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -825,7 +829,7 @@ static void api_net_trust_dom_list( int uid, /************************************************************************* api_net_logon_ctrl2: *************************************************************************/ -static void api_net_logon_ctrl2( int uid, +static void api_net_logon_ctrl2( uint16 vuid, prs_struct *data, prs_struct *rdata) { diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index cf7fc9334e..301510730b 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -112,7 +112,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->open = True; p->device_state = 0; p->conn = conn; - p->uid = vuid; + p->vuid = vuid; p->rhdr.data = NULL; p->rdata.data = NULL; diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 3f9cdc20f4..c153a78ee1 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -61,7 +61,7 @@ static void reg_reply_close(REG_Q_CLOSE *q_r, /******************************************************************* api_reg_close ********************************************************************/ -static void api_reg_close( int uid, prs_struct *data, +static void api_reg_close( uint16 vuid, prs_struct *data, prs_struct *rdata ) { REG_Q_CLOSE q_r; @@ -100,7 +100,7 @@ static void reg_reply_open(REG_Q_OPEN_POLICY *q_r, /******************************************************************* api_reg_open ********************************************************************/ -static void api_reg_open( int uid, prs_struct *data, +static void api_reg_open( uint16 vuid, prs_struct *data, prs_struct *rdata ) { REG_Q_OPEN_POLICY q_u; @@ -160,7 +160,7 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, /******************************************************************* api_reg_open_entry ********************************************************************/ -static void api_reg_open_entry( int uid, prs_struct *data, +static void api_reg_open_entry( uint16 vuid, prs_struct *data, prs_struct *rdata ) { REG_Q_OPEN_ENTRY q_u; @@ -205,7 +205,7 @@ static void reg_reply_info(REG_Q_INFO *q_u, /******************************************************************* api_reg_info ********************************************************************/ -static void api_reg_info( int uid, prs_struct *data, +static void api_reg_info( uint16 vuid, prs_struct *data, prs_struct *rdata ) { REG_Q_INFO q_u; diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index c2140db36f..2516637599 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -131,7 +131,7 @@ static void samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, /******************************************************************* api_samr_close_hnd ********************************************************************/ -static void api_samr_close_hnd( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_close_hnd( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_CLOSE_HND q_u; @@ -190,7 +190,7 @@ static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, /******************************************************************* api_samr_open_domain ********************************************************************/ -static void api_samr_open_domain( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_open_domain( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_DOMAIN q_u; @@ -266,7 +266,7 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, /******************************************************************* api_samr_unknown_3 ********************************************************************/ -static void api_samr_unknown_3( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_unknown_3( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_3 q_u; @@ -318,7 +318,7 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, /******************************************************************* api_samr_enum_dom_users ********************************************************************/ -static void api_samr_enum_dom_users( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_enum_dom_users( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_USERS q_e; @@ -373,7 +373,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, /******************************************************************* api_samr_enum_dom_groups ********************************************************************/ -static void api_samr_enum_dom_groups( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_enum_dom_groups( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_GROUPS q_e; @@ -428,7 +428,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, /******************************************************************* api_samr_enum_dom_aliases ********************************************************************/ -static void api_samr_enum_dom_aliases( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_enum_dom_aliases( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_ALIASES q_e; @@ -512,7 +512,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, /******************************************************************* api_samr_query_dispinfo ********************************************************************/ -static void api_samr_query_dispinfo( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_dispinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_DISPINFO q_e; @@ -565,7 +565,7 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, /******************************************************************* api_samr_query_aliasinfo ********************************************************************/ -static void api_samr_query_aliasinfo( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_aliasinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_ALIASINFO q_e; @@ -642,7 +642,7 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, /******************************************************************* api_samr_lookup_ids ********************************************************************/ -static void api_samr_lookup_ids( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_lookup_ids( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_IDS q_u; @@ -701,7 +701,7 @@ static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, /******************************************************************* api_samr_lookup_names ********************************************************************/ -static void api_samr_lookup_names( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_NAMES q_u; @@ -762,7 +762,7 @@ static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, /******************************************************************* api_samr_unknown_12 ********************************************************************/ -static void api_samr_unknown_12( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_unknown_12( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_12 q_u; @@ -836,7 +836,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, /******************************************************************* api_samr_open_user ********************************************************************/ -static void api_samr_open_user( int rid, prs_struct *data, prs_struct *rdata) +static void api_samr_open_user( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_USER q_u; @@ -1004,7 +1004,7 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, /******************************************************************* api_samr_query_userinfo ********************************************************************/ -static void api_samr_query_userinfo( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_userinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERINFO q_u; @@ -1082,7 +1082,7 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, /******************************************************************* api_samr_query_usergroups ********************************************************************/ -static void api_samr_query_usergroups( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_usergroups( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERGROUPS q_u; /* grab the samr unknown 32 */ @@ -1128,7 +1128,7 @@ static void samr_reply_unknown_32(SAMR_Q_UNKNOWN_32 *q_u, /******************************************************************* api_samr_unknown_32 ********************************************************************/ -static void api_samr_unknown_32( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_unknown_32( uint16 vuid, prs_struct *data, prs_struct *rdata) { uint32 status = 0; struct sam_passwd *sam_pass; @@ -1211,7 +1211,7 @@ static void samr_reply_connect(SAMR_Q_CONNECT *q_u, /******************************************************************* api_samr_connect ********************************************************************/ -static void api_samr_connect( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_connect( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_CONNECT q_u; @@ -1264,7 +1264,7 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, /******************************************************************* api_samr_open_alias ********************************************************************/ -static void api_samr_open_alias( int uid, prs_struct *data, prs_struct *rdata) +static void api_samr_open_alias( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_ALIAS q_u; diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index a4ae3fa0ef..c7aeee9b11 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -904,7 +904,7 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, /******************************************************************* ********************************************************************/ -static void api_srv_net_srv_get_info( int uid, prs_struct *data, +static void api_srv_net_srv_get_info( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SRV_GET_INFO q_n; @@ -919,7 +919,7 @@ static void api_srv_net_srv_get_info( int uid, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_file_enum( int uid, prs_struct *data, +static void api_srv_net_file_enum( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_FILE_ENUM q_n; @@ -937,7 +937,7 @@ static void api_srv_net_file_enum( int uid, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_conn_enum( int uid, prs_struct *data, +static void api_srv_net_conn_enum( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_CONN_ENUM q_n; @@ -955,7 +955,7 @@ static void api_srv_net_conn_enum( int uid, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_sess_enum( int uid, prs_struct *data, +static void api_srv_net_sess_enum( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SESS_ENUM q_n; @@ -973,7 +973,7 @@ static void api_srv_net_sess_enum( int uid, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_share_enum( int uid, prs_struct *data, +static void api_srv_net_share_enum( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SHARE_ENUM q_n; @@ -1029,7 +1029,7 @@ static void srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n, } /******************************************************************* ********************************************************************/ -static void api_srv_net_remote_tod( int uid, prs_struct *data, +static void api_srv_net_remote_tod( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_REMOTE_TOD q_n; diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 3c0fc9271e..fc78c656fd 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -246,7 +246,7 @@ static BOOL api_rpc_command(pipes_struct *p, /* do the actual command */ p->rdata.offset = 0; - api_rpc_cmds[fn_num].fn(p->uid, data, &(p->rdata)); + api_rpc_cmds[fn_num].fn(p->vuid, data, &(p->rdata)); if (p->rdata.data == NULL || p->rdata.offset == 0) { diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 5bea006b2c..acb5cde831 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -80,7 +80,7 @@ static void wks_reply_query_info(WKS_Q_QUERY_INFO *q_u, /******************************************************************* api_wks_query_info ********************************************************************/ -static void api_wks_query_info( int uid, prs_struct *data, +static void api_wks_query_info( uint16 vuid, prs_struct *data, prs_struct *rdata ) { WKS_Q_QUERY_INFO q_u; -- cgit From 5b4d94e20fdb5888da1b71a7b6a30ebede6cb06a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 30 Sep 1998 01:49:24 +0000 Subject: (Finally) implemented "max open files" as a global smb.conf parameter. Sets up the files array correctly - limited by the smb.conf parameter and by the max fd's per process as found by getrlimit(). Jeremy. (This used to be commit eca24bd24352c688cdf48c1ef14adb8ac353468f) --- source3/rpc_server/srv_pipe_hnd.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 301510730b..cb1ec963d9 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -28,9 +28,6 @@ #define PIPE "\\PIPE\\" #define PIPELEN strlen(PIPE) -/* this must be larger than the sum of the open files and directories */ -#define PIPE_HANDLE_OFFSET 0x7000 - extern int DEBUGLEVEL; static pipes_struct *chain_p; static int pipes_open; @@ -42,6 +39,21 @@ static int pipes_open; static pipes_struct *Pipes; static struct bitmap *bmap; +/* this must be larger than the sum of the open files and directories */ +static int pipe_handle_offset; + +/**************************************************************************** + Set the pipe_handle_offset. Called from smbd/files.c +****************************************************************************/ + +void set_pipe_handle_offset(int max_open_files) +{ + if(max_open_files < 0x7000) + pipe_handle_offset = 0x7000; + else + pipe_handle_offset = max_open_files + 10; /* For safety. :-) */ +} + /**************************************************************************** reset pipe chain handle number ****************************************************************************/ @@ -103,7 +115,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, DLIST_ADD(Pipes, p); bitmap_set(bmap, i); - i += PIPE_HANDLE_OFFSET; + i += pipe_handle_offset; pipes_open++; @@ -283,7 +295,7 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) mem_buf_free(&(p->rdata.data)); mem_buf_free(&(p->rhdr .data)); - bitmap_clear(bmap, p->pnum - PIPE_HANDLE_OFFSET); + bitmap_clear(bmap, p->pnum - pipe_handle_offset); pipes_open--; -- cgit From d8f609aeeb9ce70a97193d9e6709b82b78b39c39 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 30 Sep 1998 19:09:57 +0000 Subject: lsa_lookup_sids command added. severe debugging needed on lookup_sids code. added "quality of service" capability to lsa_open_policy code. different lsa_open_policy queries are *not* dealt with in the server code. answers like "0xC000 0022" - access denied - will have to be made to lsa_lookup_sids calls when a "quality of service" request is *not* specified in the lsa_open_policy call. (This used to be commit 299a723d4e55712beb12362dfff3846d82b8516b) --- source3/rpc_server/srv_lsa.c | 145 +++++++++++++++++++++++++------------------ 1 file changed, 85 insertions(+), 60 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 85e10275b8..2e5ebc9e68 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -113,37 +113,38 @@ static void lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, lsa_io_r_query("", &r_q, rdata, 0); } + /*************************************************************************** make_dom_ref - - pretty much hard-coded choice of "other" sids, unfortunately... - ***************************************************************************/ -static void make_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid, - DOM_SID *other_sid1, DOM_SID *other_sid2, DOM_SID *other_sid3) +static void make_dom_ref(DOM_R_REF *ref, int num_domains, + char **dom_names, DOM_SID **dom_sids) + { - int len_dom_name = strlen(dom_name); + int i; - ref->undoc_buffer = 1; - ref->num_ref_doms_1 = 4; - ref->buffer_dom_name = 1; - ref->max_entries = 32; - ref->num_ref_doms_2 = 4; + if (num_domains > MAX_REF_DOMAINS) + { + num_domains = MAX_REF_DOMAINS; + } - make_uni_hdr2(&(ref->hdr_dom_name ), len_dom_name , len_dom_name , 0); - make_uni_hdr2(&(ref->hdr_ref_dom[0]), sizeof(DOM_SID), sizeof(DOM_SID), 0); - make_uni_hdr2(&(ref->hdr_ref_dom[1]), sizeof(DOM_SID), sizeof(DOM_SID), 0); - make_uni_hdr2(&(ref->hdr_ref_dom[2]), sizeof(DOM_SID), sizeof(DOM_SID), 0); + ref->undoc_buffer = 1; + ref->num_ref_doms_1 = num_domains; + ref->undoc_buffer2 = 1; + ref->max_entries = MAX_REF_DOMAINS; + ref->num_ref_doms_2 = num_domains; - if (dom_name != NULL) + for (i = 0; i < num_domains; i++) { - make_unistr(&(ref->uni_dom_name), dom_name); + int len = dom_names[i] != NULL ? strlen(dom_names[i]) : 0; + + make_uni_hdr(&(ref->hdr_ref_dom[i].hdr_dom_name), len, len, len != 0 ? 1 : 0); + ref->hdr_ref_dom[i].ptr_dom_sid = dom_sids[i] != NULL ? 1 : 0; + + make_unistr2 (&(ref->ref_dom[i].uni_dom_name), dom_names[i], len); + make_dom_sid2(&(ref->ref_dom[i].ref_dom ), dom_sids [i]); } - make_dom_sid2(&(ref->ref_dom[0]), dom_sid ); - make_dom_sid2(&(ref->ref_dom[1]), other_sid1); - make_dom_sid2(&(ref->ref_dom[2]), other_sid2); - make_dom_sid2(&(ref->ref_dom[3]), other_sid3); } /*************************************************************************** @@ -151,13 +152,12 @@ make_reply_lookup_rids ***************************************************************************/ static void make_reply_lookup_rids(LSA_R_LOOKUP_RIDS *r_l, int num_entries, uint32 dom_rids[MAX_LOOKUP_SIDS], - char *dom_name, DOM_SID *dom_sid, - DOM_SID *other_sid1, DOM_SID *other_sid2, DOM_SID *other_sid3) + int num_ref_doms, + char **dom_names, DOM_SID **dom_sids) { int i; - make_dom_ref(&(r_l->dom_ref), dom_name, dom_sid, - other_sid1, other_sid2, other_sid3); + make_dom_ref(&(r_l->dom_ref), num_ref_doms, dom_names, dom_sids); r_l->num_entries = num_entries; r_l->undoc_buffer = 1; @@ -193,9 +193,6 @@ static void make_lsa_trans_names(LSA_TRANS_NAME_ENUM *trn, fstring name; uint32 type; - trn->ptr_name[i] = 0; - trn->ptr_name[(*total)] = 0; - SMB_ASSERT_ARRAY(sid[i].sid.sub_auths, num_auths); /* find the rid to look up */ @@ -212,7 +209,6 @@ static void make_lsa_trans_names(LSA_TRANS_NAME_ENUM *trn, if (status == 0x0) { - trn->ptr_name[i] = 1; make_lsa_trans_name(&(trn->name[(*total)]), type, name, (*total)); (*total)++; } @@ -241,8 +237,8 @@ lsa_reply_lookup_sids ***************************************************************************/ static void lsa_reply_lookup_sids(prs_struct *rdata, int num_entries, DOM_SID2 sid[MAX_LOOKUP_SIDS], - char *dom_name, DOM_SID *dom_sid, - DOM_SID *other_sid1, DOM_SID *other_sid2, DOM_SID *other_sid3) + int num_ref_doms, + char **dom_names, DOM_SID **dom_sids) { LSA_R_LOOKUP_SIDS r_l; DOM_R_REF ref; @@ -254,7 +250,7 @@ static void lsa_reply_lookup_sids(prs_struct *rdata, ZERO_STRUCT(names); /* set up the LSA Lookup SIDs response */ - make_dom_ref(&ref, dom_name, dom_sid, other_sid1, other_sid2, other_sid3); + make_dom_ref(&ref, num_ref_doms, dom_names, dom_sids); make_lsa_trans_names(&names, num_entries, sid, &mapped_count); make_reply_lookup_sids(&r_l, &ref, &names, mapped_count, 0x0); @@ -267,8 +263,8 @@ lsa_reply_lookup_rids ***************************************************************************/ static void lsa_reply_lookup_rids(prs_struct *rdata, int num_entries, uint32 dom_rids[MAX_LOOKUP_SIDS], - char *dom_name, DOM_SID *dom_sid, - DOM_SID *other_sid1, DOM_SID *other_sid2, DOM_SID *other_sid3) + int num_ref_doms, + char **dom_names, DOM_SID **dom_sids) { LSA_R_LOOKUP_RIDS r_l; @@ -276,7 +272,7 @@ static void lsa_reply_lookup_rids(prs_struct *rdata, /* set up the LSA Lookup RIDs response */ make_reply_lookup_rids(&r_l, num_entries, dom_rids, - dom_name, dom_sid, other_sid1, other_sid2, other_sid3); + num_ref_doms, dom_names, dom_sids); r_l.status = 0x0; /* store the response in the SMB stream */ @@ -351,6 +347,9 @@ static void api_lsa_lookup_sids( uint16 vuid, prs_struct *data, DOM_SID sid_S_1_3; DOM_SID sid_S_1_5; + DOM_SID *sid_array[4]; + char *dom_names[4]; + ZERO_STRUCT(q_l); ZERO_STRUCT(sid_S_1_1); ZERO_STRUCT(sid_S_1_3); @@ -362,14 +361,25 @@ static void api_lsa_lookup_sids( uint16 vuid, prs_struct *data, pstrcpy(dom_name, lp_workgroup()); string_to_sid(&sid_S_1_1, "S-1-1"); - string_to_sid(&sid_S_1_3, "S-1-3"); - string_to_sid(&sid_S_1_5, "S-1-5"); + string_to_sid(&sid_S_1_3, "S-1-3"); + string_to_sid(&sid_S_1_5, "S-1-5"); + + dom_names[0] = dom_name; + sid_array[0] = &global_machine_sid; + + dom_names[1] = "Everyone"; + sid_array[1] = &sid_S_1_1; + + dom_names[2] = "don't know"; + sid_array[2] = &sid_S_1_3; + + dom_names[3] = "NT AUTHORITY"; + sid_array[3] = &sid_S_1_5; /* construct reply. return status is always 0x0 */ - lsa_reply_lookup_sids(rdata, - q_l.sids.num_entries, q_l.sids.sid, /* SIDs */ - dom_name, &global_machine_sid, /* domain name, domain SID */ - &sid_S_1_1, &sid_S_1_3, &sid_S_1_5); /* the three other SIDs */ + lsa_reply_lookup_sids(rdata, + q_l.sids.num_entries, q_l.sids.sid, /* SIDs */ + 4, dom_names, sid_array); } /*************************************************************************** @@ -381,11 +391,15 @@ static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, int i; LSA_Q_LOOKUP_RIDS q_l; pstring dom_name; + uint32 dom_rids[MAX_LOOKUP_SIDS]; + uint32 dummy_g_rid; + DOM_SID sid_S_1_1; DOM_SID sid_S_1_3; DOM_SID sid_S_1_5; - uint32 dom_rids[MAX_LOOKUP_SIDS]; - uint32 dummy_g_rid; + + DOM_SID *sid_array[4]; + char *dom_names[4]; ZERO_STRUCT(q_l); ZERO_STRUCT(sid_S_1_1); @@ -399,15 +413,27 @@ static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, pstrcpy(dom_name, lp_workgroup()); string_to_sid(&sid_S_1_1, "S-1-1"); - string_to_sid(&sid_S_1_3, "S-1-3"); - string_to_sid(&sid_S_1_5, "S-1-5"); + string_to_sid(&sid_S_1_3, "S-1-3"); + string_to_sid(&sid_S_1_5, "S-1-5"); + + dom_names[0] = dom_name; + sid_array[0] = &global_machine_sid; + + dom_names[1] = "Everyone"; + sid_array[1] = &sid_S_1_1; + + dom_names[2] = "don't know"; + sid_array[2] = &sid_S_1_3; + + dom_names[3] = "NT AUTHORITY"; + sid_array[3] = &sid_S_1_5; SMB_ASSERT_ARRAY(q_l.lookup_name, q_l.num_entries); /* convert received RIDs to strings, so we can do them. */ for (i = 0; i < q_l.num_entries; i++) { - fstring user_name; + fstring user_name; fstrcpy(user_name, unistr2(q_l.lookup_name[i].str.buffer)); /* * Map to the UNIX username. @@ -429,8 +455,7 @@ static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, /* construct reply. return status is always 0x0 */ lsa_reply_lookup_rids(rdata, q_l.num_entries, dom_rids, /* text-converted SIDs */ - dom_name, &global_machine_sid, /* domain name, domain SID */ - &sid_S_1_1, &sid_S_1_3, &sid_S_1_5); /* the three other SIDs */ + 4, dom_names, sid_array); } /*************************************************************************** @@ -443,17 +468,17 @@ static void api_lsa_close( uint16 vuid, prs_struct *data, char *q = mem_data(&(rdata->data), rdata->offset); SIVAL(q, 0, 0); - q += 4; + q += 4; SIVAL(q, 0, 0); - q += 4; + q += 4; SIVAL(q, 0, 0); - q += 4; + q += 4; SIVAL(q, 0, 0); - q += 4; + q += 4; SIVAL(q, 0, 0); - q += 4; + q += 4; SIVAL(q, 0, 0); - q += 4; + q += 4; rdata->offset += 24; } @@ -468,17 +493,17 @@ static void api_lsa_open_secret( uint16 vuid, prs_struct *data, char *q = mem_data(&(rdata->data), rdata->offset); SIVAL(q, 0, 0); - q += 4; + q += 4; SIVAL(q, 0, 0); - q += 4; + q += 4; SIVAL(q, 0, 0); - q += 4; + q += 4; SIVAL(q, 0, 0); - q += 4; + q += 4; SIVAL(q, 0, 0); - q += 4; + q += 4; SIVAL(q, 0, 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND); - q += 4; + q += 4; rdata->offset += 24; } -- cgit From bdbc959a9afd7fab159f235551c25139763af100 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 2 Oct 1998 18:45:07 +0000 Subject: - static function "create_new_hashes" was identical to "nt_lm_owf_gen". create_new_hashes didn't zero the buffer for the md4hash: nt_lm_owf_gen did, because jeremy sorted this out a couple of days ago. call nt_lm_owf_gen instead. - call SMBOWFencrypt from SMBencrypt and SMBNTencrypt. - added #ifdef DEBUG_PASSWORD debug password calls. (This used to be commit a4e7cc3e46b713aa0ae55de74a1c70921bef578d) --- source3/rpc_server/srv_samr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 2516637599..22827f9f5c 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1298,7 +1298,7 @@ static struct api_struct api_samr_cmds [] = { "SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, { "SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, { "SAMR_UNKNOWN_3" , SAMR_UNKNOWN_3 , api_samr_unknown_3 }, - { NULL , 0 , NULL } + { NULL , 0 , NULL } }; /******************************************************************* -- cgit From 2fef8f2e87f61043e3f1a2cf7d1f2a4ff9f119ff Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 7 Oct 1998 15:22:49 +0000 Subject: dce/rpc (This used to be commit 34afa638f6f7bb145ec094510ac58f7a22dfc3aa) --- source3/rpc_server/srv_pipe_hnd.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index cb1ec963d9..e898a8606f 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -153,6 +153,20 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, } +/**************************************************************************** + writes data to a pipe. + ****************************************************************************/ +int write_pipe(pipes_struct *p, char *data, int n) +{ + DEBUG(6,("write_pipe: %x", p->pnum)); + + DEBUG(6,("name: %s open: %s len: %d", + p->name, BOOLSTR(p->open), n)); + + return -1; +} + + /**************************************************************************** reads data from a pipe. -- cgit From 48b31ae44fb2a1961bd738b0b3e7a986259168a2 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 7 Oct 1998 21:42:24 +0000 Subject: dce/rpc (This used to be commit 6677b888bdb45df00646eb7cc13005b9465ff971) --- source3/rpc_server/srv_pipe_hnd.c | 20 ++- source3/rpc_server/srv_util.c | 280 +++++++++++++++++++++++++++++++++++++- 2 files changed, 298 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index e898a8606f..31ca1a7c20 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -155,15 +155,33 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, /**************************************************************************** writes data to a pipe. + + SERIOUSLY ALPHA CODE! ****************************************************************************/ int write_pipe(pipes_struct *p, char *data, int n) { + prs_struct pd; + struct mem_buf data_buf; + DEBUG(6,("write_pipe: %x", p->pnum)); DEBUG(6,("name: %s open: %s len: %d", p->name, BOOLSTR(p->open), n)); - return -1; + dump_data(50, data, n); + + /* fake up a data buffer from the write_pipe data parameters */ + mem_create(&data_buf, data, n, 0, False); + data_buf.offset.start = 0; + data_buf.offset.end = n; + + /* fake up a parsing structure */ + pd.data = &data_buf; + pd.align = 4; + pd.io = True; + pd.offset = 0; + + return rpc_command(p, &pd) ? n : -1; } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index fc78c656fd..520a9cc02a 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -209,6 +209,284 @@ BOOL create_rpc_reply(pipes_struct *p, } +static BOOL api_pipe_ntlmssp(pipes_struct *p, prs_struct *pd) +{ + /* receive a negotiate; send a challenge; receive a response */ + switch (p->auth_verifier.msg_type) + { + case NTLMSSP_NEGOTIATE: + { + smb_io_rpc_auth_ntlmssp_neg("", &p->ntlmssp_neg, pd, 0); + break; + } + case NTLMSSP_AUTH: + { + smb_io_rpc_auth_ntlmssp_resp("", &p->ntlmssp_resp, pd, 0); + break; + } + default: + { + /* NTLMSSP expected: unexpected message type */ + DEBUG(3,("unexpected message type in NTLMSSP %d\n", + p->auth_verifier.msg_type)); + return False; + } + } + + return (pd->offset != 0); +} + +struct api_cmd +{ + char * pipe_clnt_name; + char * pipe_srv_name; + BOOL (*fn) (pipes_struct *, prs_struct *); +}; + +static struct api_cmd api_fd_commands[] = +{ + { "lsarpc", "lsass", api_ntlsa_rpc }, + { "samr", "lsass", api_samr_rpc }, + { "srvsvc", "ntsvcs", api_srvsvc_rpc }, + { "wkssvc", "ntsvcs", api_wkssvc_rpc }, + { "NETLOGON", "lsass", api_netlog_rpc }, + { "winreg", "winreg", api_reg_rpc }, + { NULL, NULL, NULL } +}; + +static BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *pd) +{ + p->ntlmssp_auth = False; + + DEBUG(5,("api_pipe_bind_auth_resp: decode request. %d\n", __LINE__)); + + if (p->hdr.auth_len != 0) + { + /* decode the authentication verifier response */ + smb_io_rpc_hdr_autha("", &p->autha_info, pd, 0); + if (pd->offset == 0) return False; + + p->ntlmssp_auth = p->auth_info.auth_type = 0x0a; + + if (p->ntlmssp_auth) + { + smb_io_rpc_auth_verifier("", &p->auth_verifier, pd, 0); + if (pd->offset == 0) return False; + + p->ntlmssp_auth = strequal(p->auth_verifier.signature, "NTLMSSP"); + } + + if (p->ntlmssp_auth) + { + if (!api_pipe_ntlmssp(p, pd)) return False; + } + } + + return p->ntlmssp_auth; +} + +static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) +{ + uint16 assoc_gid; + fstring ack_pipe_name; + int i = 0; + + p->ntlmssp_auth = False; + + DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); + + for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) + { + if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && + api_fd_commands[i].fn != NULL) + { + DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", + api_fd_commands[i].pipe_clnt_name, + api_fd_commands[i].pipe_srv_name)); + fstrcpy(p->pipe_srv_name, api_fd_commands[i].pipe_srv_name); + break; + } + } + + if (api_fd_commands[i].fn == NULL) return False; + + /* decode the bind request */ + smb_io_rpc_hdr_rb("", &p->hdr_rb, pd, 0); + + if (pd->offset == 0) return False; + + if (p->hdr.auth_len != 0) + { + /* decode the authentication verifier */ + smb_io_rpc_hdr_auth ("", &p->auth_info , pd, 0); + if (pd->offset == 0) return False; + + p->ntlmssp_auth = p->auth_info.auth_type = 0x0a; + + if (p->ntlmssp_auth) + { + smb_io_rpc_auth_verifier("", &p->auth_verifier, pd, 0); + if (pd->offset == 0) return False; + + p->ntlmssp_auth = strequal(p->auth_verifier.signature, "NTLMSSP"); + } + + if (p->ntlmssp_auth) + { + if (!api_pipe_ntlmssp(p, pd)) return False; + } + } + + /* name has to be \PIPE\xxxxx */ + fstrcpy(ack_pipe_name, "\\PIPE\\"); + fstrcat(ack_pipe_name, p->pipe_srv_name); + + DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); + + prs_init(&(p->rdata), 1024, 4, 0, False); + prs_init(&(p->rhdr ), 0x10, 4, 0, False); + prs_init(&(p->rauth), 1024, 4, 0, False); + prs_init(&(p->rverf), 0x08, 4, 0, False); + prs_init(&(p->rntlm), 1024, 4, 0, False); + + /***/ + /*** do the bind ack first ***/ + /***/ + + if (p->ntlmssp_auth) + { + assoc_gid = 0x7a77; + } + else + { + assoc_gid = p->hdr_rb.bba.assoc_gid; + } + + make_rpc_hdr_ba(&p->hdr_ba, + p->hdr_rb.bba.max_tsize, + p->hdr_rb.bba.max_rsize, + assoc_gid, + ack_pipe_name, + 0x1, 0x0, 0x0, + &(p->hdr_rb.transfer)); + + smb_io_rpc_hdr_ba("", &p->hdr_ba, &p->rdata, 0); + mem_realloc_data(p->rdata.data, p->rdata.offset); + + /***/ + /*** now the authentication ***/ + /***/ + + if (p->ntlmssp_auth) + { + uint8 challenge[8]; + generate_random_buffer(challenge, 8, False); + + /*** authentication info ***/ + + make_rpc_hdr_auth(&p->auth_info, + 0x0a, 0x06, 0); + smb_io_rpc_hdr_auth("", &p->auth_info, &p->rverf, 0); + mem_realloc_data(p->rverf.data, p->rverf.offset); + + /*** NTLMSSP verifier ***/ + + make_rpc_auth_verifier(&p->auth_verifier, + "NTLMSSP", NTLMSSP_CHALLENGE); + smb_io_rpc_auth_verifier("", &p->auth_verifier, &p->rauth, 0); + mem_realloc_data(p->rauth.data, p->rauth.offset); + + /* NTLMSSP challenge ***/ + + make_rpc_auth_ntlmssp_chal(&p->ntlmssp_chal, + 0x000082b1, challenge); + smb_io_rpc_auth_ntlmssp_chal("", &p->ntlmssp_chal, &p->rntlm, 0); + mem_realloc_data(p->rntlm.data, p->rntlm.offset); + } + + /***/ + /*** then do the header, now we know the length ***/ + /***/ + + make_rpc_hdr(&p->hdr, RPC_BINDACK, RPC_FLG_FIRST | RPC_FLG_LAST, + p->hdr.call_id, + p->rdata.offset + p->rverf.offset + p->rauth.offset + p->rntlm.offset + 0x10, + p->rauth.offset + p->rntlm.offset); + + smb_io_rpc_hdr("", &p->hdr, &p->rhdr, 0); + mem_realloc_data(p->rhdr.data, p->rdata.offset); + + /***/ + /*** link rpc header, bind acknowledgment and authentication responses ***/ + /***/ + + if (p->ntlmssp_auth) + { + prs_link(NULL , &p->rhdr , &p->rdata); + prs_link(&p->rhdr , &p->rdata, &p->rverf); + prs_link(&p->rdata, &p->rverf, &p->rauth); + prs_link(&p->rverf, &p->rauth, &p->rntlm); + prs_link(&p->rauth, &p->rntlm, NULL ); + } + else + { + prs_link(NULL , &p->rhdr , &p->rdata); + prs_link(&p->rhdr, &p->rdata, NULL ); + } + + return True; +} + +static BOOL api_pipe_request(pipes_struct *p, prs_struct *pd) +{ + int i = 0; + + for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) + { + if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && + api_fd_commands[i].fn != NULL) + { + DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i].pipe_clnt_name)); + return api_fd_commands[i].fn(p, pd); + } + } + return False; +} + +BOOL rpc_command(pipes_struct *p, prs_struct *pd) +{ + BOOL reply = False; + if (pd->data == NULL) return False; + + /* process the rpc header */ + smb_io_rpc_hdr("", &p->hdr, pd, 0); + + if (pd->offset == 0) return False; + + switch (p->hdr.pkt_type) + { + case RPC_BIND : + { + reply = api_pipe_bind_req(p, pd); + break; + } + case RPC_REQUEST: + { + reply = api_pipe_request (p, pd); + break; + } + case RPC_BINDRESP: /* not the real name! */ + { + reply = api_pipe_bind_auth_resp(p, pd); + break; + } + } + + + return reply; +} + + /******************************************************************* receives a netlogon pipe and responds. ********************************************************************/ @@ -256,7 +534,7 @@ static BOOL api_rpc_command(pipes_struct *p, mem_realloc_data(p->rdata.data, p->rdata.offset); - DEBUG(10,("called %s\n", rpc_name)); + DEBUG(10,("called %s\n", rpc_name)); return True; } -- cgit From 6909350ed9b87875ee40191b2e636c6049749195 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 8 Oct 1998 23:57:46 +0000 Subject: dce/rpc (This used to be commit 62fdeef1b79c5c4c9bf0e860881651711bb80b9a) --- source3/rpc_server/srv_pipe_hnd.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 31ca1a7c20..4d5fd3865e 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -211,14 +211,16 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) BOOLSTR(p->open), pos, n)); - if (!p || !p->open) { + if (!p || !p->open) + { DEBUG(6,("pipe not open\n")); return -1; } if (p->rhdr.data == NULL || p->rhdr.data->data == NULL || - p->rhdr.data->data_used == 0) { + p->rhdr.data->data_used == 0) + { return 0; } @@ -237,18 +239,21 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) DEBUG(6,("read_pipe: len: %d num: %d n: %d\n", len, num, n)); if (num > n) num = n; - if (num <= 0) { + if (num <= 0) + { DEBUG(5,("read_pipe: 0 or -ve data length\n")); return 0; } - if (!IS_BITS_SET_ALL(p->hdr.flags, RPC_FLG_LAST)) { + if (!IS_BITS_SET_ALL(p->hdr.flags, RPC_FLG_LAST)) + { /* intermediate fragment - possibility of another header */ DEBUG(5,("read_pipe: frag_len: %d data_pos: %d data_hdr_pos: %d\n", p->hdr.frag_len, data_pos, data_hdr_pos)); - if (data_hdr_pos == p->next_frag_start) { + if (data_hdr_pos == p->next_frag_start) + { DEBUG(6,("read_pipe: next fragment header\n")); /* this is subtracted from the total data bytes, later */ @@ -263,10 +268,10 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) p->next_frag_start += p->hdr.frag_len; p->hdr_offsets += 0x18; } - } - if (num < hdr_num) { + if (num < hdr_num) + { DEBUG(5,("read_pipe: warning - data read only part of a header\n")); } @@ -277,12 +282,15 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) data_pos += num; data_hdr_pos += num; - if (hdr_num == 0x18 && num == 0x18) { + if (hdr_num == 0x18 && num == 0x18) + { DEBUG(6,("read_pipe: just header read\n")); /* advance to the next fragment */ p->frag_len_left -= 0x18; - } else if (data_hdr_pos == p->next_frag_start) { + } + else if (data_hdr_pos == p->next_frag_start) + { DEBUG(6,("read_pipe: next fragment expected\n")); } -- cgit From c09647c3e1faa54e36c383958d9ea6def911f77d Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 14 Oct 1998 07:08:43 +0000 Subject: more warnings... (This used to be commit 8b9c0bad889d4f26987d87c54b4d8bf102af1744) --- source3/rpc_server/srv_util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 520a9cc02a..f9532981e0 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -384,8 +384,7 @@ static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) /*** authentication info ***/ - make_rpc_hdr_auth(&p->auth_info, - 0x0a, 0x06, 0); + make_rpc_hdr_auth(&p->auth_info, 0x0a, 0x06, 0, 1); smb_io_rpc_hdr_auth("", &p->auth_info, &p->rverf, 0); mem_realloc_data(p->rverf.data, p->rverf.offset); -- cgit From a42afcdcc7ab9aa9ed193ae36d3dbb10843447f0 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 15 Oct 1998 05:47:29 +0000 Subject: bug-fixing against: AS/U: it returns dce/rpc "first" and "last" bits _clear_ in a bind/ack response, when they should be set in a (small) packet. they also, in the bind/ack do not set a secondary address string at all, so we can't check against that... Win95: client-side dce/rpc code is a bit odd. it does a "WaitNamedPipeState" and has slightly different pipe-naming (\PIPE\LANMAN is joined by \PIPE\SRVSVC, \PIPE\WINREG etc whereas nt just has \PIPE\LANMAN and \PIPE\). Win95-USRMGR.EXE: added LsaOpenPolicy (renamed existing to LsaOpenPolicy2). added SamrConnect (renamed existing to SamrConnect2). (This used to be commit a7fccd807b938cbb51002ebae8c7a48b40dbb655) --- source3/rpc_server/srv_lsa.c | 42 ++++++++++++++ source3/rpc_server/srv_pipe_hnd.c | 24 ++++++++ source3/rpc_server/srv_samr.c | 115 +++++++++++++++++++++++++++++--------- 3 files changed, 154 insertions(+), 27 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 2e5ebc9e68..93584b5acf 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -30,6 +30,28 @@ extern int DEBUGLEVEL; extern DOM_SID global_machine_sid; +/*************************************************************************** +lsa_reply_open_policy2 + ***************************************************************************/ +static void lsa_reply_open_policy2(prs_struct *rdata) +{ + int i; + LSA_R_OPEN_POL2 r_o; + + ZERO_STRUCT(r_o); + + /* set up the LSA QUERY INFO response */ + + for (i = 4; i < POL_HND_SIZE; i++) + { + r_o.pol.data[i] = i; + } + r_o.status = 0x0; + + /* store the response in the SMB stream */ + lsa_io_r_open_pol2("", &r_o, rdata, 0); +} + /*************************************************************************** lsa_reply_open_policy ***************************************************************************/ @@ -279,6 +301,25 @@ static void lsa_reply_lookup_rids(prs_struct *rdata, lsa_io_r_lookup_rids("", &r_l, rdata, 0); } +/*************************************************************************** +api_lsa_open_policy + ***************************************************************************/ +static void api_lsa_open_policy2( uint16 vuid, prs_struct *data, + prs_struct *rdata ) +{ + LSA_Q_OPEN_POL2 q_o; + + ZERO_STRUCT(q_o); + + /* grab the server, object attributes and desired access flag...*/ + lsa_io_q_open_pol2("", &q_o, data, 0); + + /* lkclXXXX having decoded it, ignore all fields in the open policy! */ + + /* return a 20 byte policy handle */ + lsa_reply_open_policy2(rdata); +} + /*************************************************************************** api_lsa_open_policy ***************************************************************************/ @@ -513,6 +554,7 @@ static void api_lsa_open_secret( uint16 vuid, prs_struct *data, ***************************************************************************/ static struct api_struct api_lsa_cmds[] = { + { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 }, { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy }, { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info }, { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom }, diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 4d5fd3865e..b1aede6166 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -123,6 +123,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->open = True; p->device_state = 0; + p->priority = 0; p->conn = conn; p->vuid = vuid; @@ -300,6 +301,29 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) } +/**************************************************************************** + wait device state on a pipe. exactly what this is for is unknown... +****************************************************************************/ +BOOL wait_rpc_pipe_hnd_state(pipes_struct *p, uint16 priority) +{ + if (p == NULL) return False; + + if (p->open) + { + DEBUG(3,("%s Setting pipe wait state priority=%x on pipe (name=%s)\n", + timestring(), priority, p->name)); + + p->priority = priority; + + return True; + } + + DEBUG(3,("%s Error setting pipe wait state priority=%x (name=%s)\n", + timestring(), priority, p->name)); + return False; +} + + /**************************************************************************** set device state on a pipe. exactly what this is for is unknown... ****************************************************************************/ diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 22827f9f5c..11574be9b3 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -78,7 +78,8 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, pw_buf[(*num_entries)].acb_info = (uint16)pwd->acct_ctrl; DEBUG(5, ("entry idx: %d user %s, rid 0x%x, acb %x", - (*num_entries), pwd->smb_name, pwd->user_rid, pwd->acct_ctrl)); + (*num_entries), pwd->smb_name, + pwd->user_rid, pwd->acct_ctrl)); if (acb_mask == 0 || IS_BITS_SET_SOME(pwd->acct_ctrl, acb_mask)) { @@ -451,49 +452,55 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, SAM_INFO_1 info1; SAM_INFO_2 info2; SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; - int num_entries; - int total_entries; + int num_entries = 0; + int total_entries = 0; BOOL got_pwds; uint16 switch_level = 0x0; + ZERO_STRUCT(r_e); + r_e.status = 0x0; + DEBUG(5,("samr_reply_query_dispinfo: %d\n", __LINE__)); + /* find the policy handle. open a policy on it. */ if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + DEBUG(5,("samr_reply_query_dispinfo: invalid handle\n")); } - DEBUG(5,("samr_reply_query_dispinfo: %d\n", __LINE__)); - - become_root(True); - got_pwds = get_sampwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); - unbecome_root(True); - - switch (q_u->switch_level) + if (r_e.status == 0x0) { - case 0x1: + become_root(True); + got_pwds = get_sampwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); + unbecome_root(True); + + switch (q_u->switch_level) { - - /* query disp info is for users */ - switch_level = 0x1; - make_sam_info_1(&info1, ACB_NORMAL, - q_u->start_idx, num_entries, pass); + case 0x1: + { + + /* query disp info is for users */ + switch_level = 0x1; + make_sam_info_1(&info1, ACB_NORMAL, + q_u->start_idx, num_entries, pass); - ctr.sam.info1 = &info1; + ctr.sam.info1 = &info1; - break; - } - case 0x2: - { - /* query disp info is for servers */ - switch_level = 0x2; - make_sam_info_2(&info2, ACB_WSTRUST, - q_u->start_idx, num_entries, pass); + break; + } + case 0x2: + { + /* query disp info is for servers */ + switch_level = 0x2; + make_sam_info_2(&info2, ACB_WSTRUST, + q_u->start_idx, num_entries, pass); - ctr.sam.info2 = &info2; + ctr.sam.info2 = &info2; - break; + break; + } } } @@ -1169,6 +1176,59 @@ static void api_samr_unknown_32( uint16 vuid, prs_struct *data, prs_struct *rdat } +/******************************************************************* + samr_reply_connect_anon + ********************************************************************/ +static void samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, + prs_struct *rdata) +{ + SAMR_R_CONNECT_ANON r_u; + BOOL pol_open = False; + + /* set up the SAMR connect_anon response */ + + r_u.status = 0x0; + /* get a (unique) handle. open a policy on it. */ + if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.connect_pol)))) + { + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + /* associate the domain SID with the (unique) handle. */ + if (r_u.status == 0x0 && !set_lsa_policy_samr_pol_status(&(r_u.connect_pol), q_u->unknown_0)) + { + /* oh, whoops. don't know what error message to return, here */ + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + if (r_u.status != 0 && pol_open) + { + close_lsa_policy_hnd(&(r_u.connect_pol)); + } + + DEBUG(5,("samr_connect_anon: %d\n", __LINE__)); + + /* store the response in the SMB stream */ + samr_io_r_connect_anon("", &r_u, rdata, 0); + + DEBUG(5,("samr_connect_anon: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_connect_anon + ********************************************************************/ +static void api_samr_connect_anon( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_CONNECT_ANON q_u; + + /* grab the samr open policy */ + samr_io_q_connect_anon("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_connect_anon(&q_u, rdata); +} + /******************************************************************* samr_reply_connect ********************************************************************/ @@ -1283,6 +1343,7 @@ static struct api_struct api_samr_cmds [] = { { "SAMR_CLOSE_HND" , SAMR_CLOSE_HND , api_samr_close_hnd }, { "SAMR_CONNECT" , SAMR_CONNECT , api_samr_connect }, + { "SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon }, { "SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users }, { "SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, { "SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, -- cgit From c9ab92ffe523a7061e97668becf08705db1d744f Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 16 Oct 1998 00:59:22 +0000 Subject: rpcclient ntlogin test (This used to be commit f69cf05ff56dffb313304964d5bf5e5aee2f40a7) --- source3/rpc_server/srv_netlog.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 17a534b6f0..79a659faf8 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -506,6 +506,17 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, memcpy(lm_pwd, id1->lm_owf.data, 16); memcpy(nt_pwd, id1->nt_owf.data, 16); +#ifdef DEBUG_PASSWORD + DEBUG(100,("key:")); + dump_data(100, key, 16); + + DEBUG(100,("lm owf password:")); + dump_data(100, lm_pwd, 16); + + DEBUG(100,("nt owf password:")); + dump_data(100, nt_pwd, 16); +#endif + SamOEMhash((uchar *)lm_pwd, key, False); SamOEMhash((uchar *)nt_pwd, key, False); @@ -518,7 +529,7 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, #endif if (memcmp(smb_pass->smb_passwd , lm_pwd, 16) != 0 && - memcmp(smb_pass->smb_nt_passwd, nt_pwd, 16) != 0) + memcmp(smb_pass->smb_nt_passwd, nt_pwd, 16) != 0) { status = 0xC0000000 | NT_STATUS_WRONG_PASSWORD; } -- cgit From d4a82ea26d5b9501f210a5c441b1ac09c256a187 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 16 Oct 1998 20:07:02 +0000 Subject: rpc client mods (ntlmssp flags) (This used to be commit 16256f86bf451535c7955b8f51a9b88fc33a8e4d) --- source3/rpc_server/srv_pipe_hnd.c | 4 ++-- source3/rpc_server/srv_util.c | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index b1aede6166..27e156943c 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -159,7 +159,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, SERIOUSLY ALPHA CODE! ****************************************************************************/ -int write_pipe(pipes_struct *p, char *data, int n) +ssize_t write_pipe(pipes_struct *p, char *data, size_t n) { prs_struct pd; struct mem_buf data_buf; @@ -182,7 +182,7 @@ int write_pipe(pipes_struct *p, char *data, int n) pd.io = True; pd.offset = 0; - return rpc_command(p, &pd) ? n : -1; + return rpc_command(p, &pd) ? ((ssize_t)n) : -1; } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index f9532981e0..dc0918f1bf 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -208,6 +208,52 @@ BOOL create_rpc_reply(pipes_struct *p, return p->rhdr.data != NULL && p->rhdr.offset == 0x18; } +static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) +{ + uchar lm_owf[24]; + uchar nt_owf[24]; + + DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); + + if (p->ntlmssp_resp.hdr_lm_resp.str_str_len == 0) return False; + if (p->ntlmssp_resp.hdr_nt_resp.str_str_len == 0) return False; + if (p->ntlmssp_resp.hdr_usr .str_str_len == 0) return False; + if (p->ntlmssp_resp.hdr_domain .str_str_len == 0) return False; + if (p->ntlmssp_resp.hdr_wks .str_str_len == 0) return False; + + memset(p->user_name, 0, sizeof(p->user_name)); + memset(p->domain , 0, sizeof(p->domain )); + memset(p->wks , 0, sizeof(p->wks )); + + if (IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_UNICODE)) + { + fstrcpy(p->user_name, unistrn2((uint16*)p->ntlmssp_resp.user , p->ntlmssp_resp.hdr_usr .str_str_len/2)); + fstrcpy(p->domain , unistrn2((uint16*)p->ntlmssp_resp.domain, p->ntlmssp_resp.hdr_domain.str_str_len/2)); + fstrcpy(p->wks , unistrn2((uint16*)p->ntlmssp_resp.wks , p->ntlmssp_resp.hdr_wks .str_str_len/2)); + } + else + { + fstrcpy(p->user_name, p->ntlmssp_resp.user ); + fstrcpy(p->domain , p->ntlmssp_resp.domain); + fstrcpy(p->wks , p->ntlmssp_resp.wks ); + } + + DEBUG(5,("user: %s domain: %s wks: %s\n", p->user_name, p->domain, p->wks)); + + memcpy(lm_owf, p->ntlmssp_resp.lm_resp, sizeof(lm_owf)); + memcpy(nt_owf, p->ntlmssp_resp.nt_resp, sizeof(nt_owf)); + +#ifdef DEBUG_PASSWORD + DEBUG(100,"lm, nt owfs:\n")); + dump_data(100, lm_owf, sizeof(lm_owf)); + dump_data(100, nt_owf, sizeof(nt_owf)); +#endif + return True; +#if 0 + return pass_check_smb(p->user_name, p->domain, + p->ntplssp_chal.challenge, lm_owf, nt_owf); +#endif +} static BOOL api_pipe_ntlmssp(pipes_struct *p, prs_struct *pd) { @@ -222,6 +268,10 @@ static BOOL api_pipe_ntlmssp(pipes_struct *p, prs_struct *pd) case NTLMSSP_AUTH: { smb_io_rpc_auth_ntlmssp_resp("", &p->ntlmssp_resp, pd, 0); + if (!api_pipe_ntlmssp_verify(p)) + { + pd->offset = 0; + } break; } default: -- cgit From 97f0c9d55014db221fdceaaf07318ae9df9688a1 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 16 Oct 1998 21:36:19 +0000 Subject: made pass_check_smb() available for dce/rpc use. (This used to be commit 95e8a910c5d9ba0ef57669fb1256eaa932e0bb09) --- source3/rpc_server/srv_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index dc0918f1bf..76f113374d 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -244,7 +244,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) memcpy(nt_owf, p->ntlmssp_resp.nt_resp, sizeof(nt_owf)); #ifdef DEBUG_PASSWORD - DEBUG(100,"lm, nt owfs:\n")); + DEBUG(100,("lm, nt owfs:\n")); dump_data(100, lm_owf, sizeof(lm_owf)); dump_data(100, nt_owf, sizeof(nt_owf)); #endif -- cgit From a785f8d2c90f3db579c781ca5f722cb5b695fcb4 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 16 Oct 1998 23:40:59 +0000 Subject: dce/rpc (This used to be commit 29434f496c18e816d864060d68f357aea6ef5de8) --- source3/rpc_server/srv_pipe_hnd.c | 3 ++ source3/rpc_server/srv_samr.c | 76 +++++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_util.c | 27 +++++++++++--- 3 files changed, 101 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 27e156943c..d5c99b89c4 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -137,6 +137,9 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->frag_len_left = 0; p->next_frag_start = 0; + p->ntlmssp_validated = False; + p->ntlmssp_auth = False; + fstrcpy(p->name, pipe_name); DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n", diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 11574be9b3..a3d758489c 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -719,6 +719,80 @@ static void api_samr_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rd samr_reply_lookup_names(&q_u, rdata); } +/******************************************************************* + samr_reply_chgpasswd_user + ********************************************************************/ +static void samr_reply_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u, + prs_struct *rdata) +{ + SAMR_R_CHGPASSWD_USER r_u; + uint32 status = 0x0; + fstring user_name; + fstring wks; + + fstrcpy(user_name, unistrn2(q_u->uni_user_name.buffer, q_u->uni_user_name.uni_str_len)); + fstrcpy(wks , unistrn2(q_u->uni_dest_host.buffer, q_u->uni_dest_host.uni_str_len)); + + DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); + + /* oops! */ + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + + make_samr_r_chgpasswd_user(&r_u, status); + + /* store the response in the SMB stream */ + samr_io_r_chgpasswd_user("", &r_u, rdata, 0); + + DEBUG(5,("samr_chgpasswd_user: %d\n", __LINE__)); +} + +/******************************************************************* + api_samr_chgpasswd_user + ********************************************************************/ +static void api_samr_chgpasswd_user( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_CHGPASSWD_USER q_u; + + /* unknown 38 command */ + samr_io_q_chgpasswd_user("", &q_u, data, 0); + + /* construct reply. */ + samr_reply_chgpasswd_user(&q_u, rdata); +} + + +/******************************************************************* + samr_reply_unknown_38 + ********************************************************************/ +static void samr_reply_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, + prs_struct *rdata) +{ + SAMR_R_UNKNOWN_38 r_u; + + DEBUG(5,("samr_unknown_38: %d\n", __LINE__)); + + make_samr_r_unknown_38(&r_u); + + /* store the response in the SMB stream */ + samr_io_r_unknown_38("", &r_u, rdata, 0); + + DEBUG(5,("samr_unknown_38: %d\n", __LINE__)); +} + +/******************************************************************* + api_samr_unknown_38 + ********************************************************************/ +static void api_samr_unknown_38( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_UNKNOWN_38 q_u; + + /* unknown 38 command */ + samr_io_q_unknown_38("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_unknown_38(&q_u, rdata); +} + /******************************************************************* samr_reply_unknown_12 @@ -1356,6 +1430,8 @@ static struct api_struct api_samr_cmds [] = { "SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, { "SAMR_0x32" , 0x32 , api_samr_unknown_32 }, { "SAMR_UNKNOWN_12" , SAMR_UNKNOWN_12 , api_samr_unknown_12 }, + { "SAMR_UNKNOWN_38" , SAMR_UNKNOWN_38 , api_samr_unknown_38 }, + { "SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, { "SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, { "SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, { "SAMR_UNKNOWN_3" , SAMR_UNKNOWN_3 , api_samr_unknown_3 }, diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 76f113374d..93640f3445 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -248,11 +248,12 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) dump_data(100, lm_owf, sizeof(lm_owf)); dump_data(100, nt_owf, sizeof(nt_owf)); #endif - return True; -#if 0 - return pass_check_smb(p->user_name, p->domain, - p->ntplssp_chal.challenge, lm_owf, nt_owf); -#endif + become_root(True); + p->ntlmssp_validated = pass_check_smb(p->user_name, p->domain, + p->ntlmssp_chal.challenge, lm_owf, nt_owf, NULL); + unbecome_root(True); + + return p->ntlmssp_validated; } static BOOL api_pipe_ntlmssp(pipes_struct *p, prs_struct *pd) @@ -486,10 +487,26 @@ static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) return True; } + +static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) +{ + return True; +} + static BOOL api_pipe_request(pipes_struct *p, prs_struct *pd) { int i = 0; + if (p->ntlmssp_auth && p->ntlmssp_validated) + { + if (!api_pipe_auth_process(p)) return False; + + DEBUG(0,("api_pipe_request: **** MUST CALL become_user() HERE **** \n")); +#if 0 + become_user(); +#endif + } + for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && -- cgit From 4e621f638a91e13f65a81f880912c11f77385d0f Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 16 Oct 1998 23:42:09 +0000 Subject: oops. (This used to be commit fc1b7b9e75b029ffa93263766fe297d043c6d1df) --- source3/rpc_server/srv_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 93640f3445..850282b6b5 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -499,7 +499,7 @@ static BOOL api_pipe_request(pipes_struct *p, prs_struct *pd) if (p->ntlmssp_auth && p->ntlmssp_validated) { - if (!api_pipe_auth_process(p)) return False; + if (!api_pipe_auth_process(p, pd)) return False; DEBUG(0,("api_pipe_request: **** MUST CALL become_user() HERE **** \n")); #if 0 -- cgit From fc62d6bf368c950e1e51bc42771cce8b299df42c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 17 Oct 1998 17:41:13 +0000 Subject: Small tidyups for gcc in 'preen' mode.... Jeremy. (This used to be commit 60dc1a4a00a22088d33369588b0d5eb292cf084a) --- source3/rpc_server/srv_ldap_helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ldap_helpers.c b/source3/rpc_server/srv_ldap_helpers.c index fb2442789c..4db841990e 100644 --- a/source3/rpc_server/srv_ldap_helpers.c +++ b/source3/rpc_server/srv_ldap_helpers.c @@ -9,6 +9,6 @@ extern int DEBUGLEVEL; #else /* USE_LDAP */ /* this keeps fussy compilers happy */ -void ldap_helper_dummy(void) -{} + void ldap_helper_dummy(void); + void ldap_helper_dummy(void) {} #endif /* USE_LDAP */ -- cgit From 01de6030843f5f402dee8bf72f564a91ae8437ca Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 19 Oct 1998 17:32:10 +0000 Subject: - dce/rpc code - removed debug info in struni2 and unistr2 (security risk) - rpc_pipe function was getting pointer to data then calling realloc *dur* - password check function, the start of "credential checking", user, wks, domain, pass as the credentials (not just user,pass which is incorrect in a domain context) - cli_write needs to return ssize_t not size_t, because total can be -1 if the write fails. - fixed signed / unsigned warnings (how come i don't get those any more when i compile with gcc???) - nt password change added in smbd. yes, jeremy, i verified that the SMBtrans2 version still works. (This used to be commit fcfb40d2b0fc565ee4f66b3a3761c246366a2ef3) --- source3/rpc_server/srv_ldap_helpers.c | 4 +- source3/rpc_server/srv_samr.c | 8 ++- source3/rpc_server/srv_util.c | 124 ++++++++++++++++++++++++++-------- 3 files changed, 105 insertions(+), 31 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ldap_helpers.c b/source3/rpc_server/srv_ldap_helpers.c index 4db841990e..fb2442789c 100644 --- a/source3/rpc_server/srv_ldap_helpers.c +++ b/source3/rpc_server/srv_ldap_helpers.c @@ -9,6 +9,6 @@ extern int DEBUGLEVEL; #else /* USE_LDAP */ /* this keeps fussy compilers happy */ - void ldap_helper_dummy(void); - void ldap_helper_dummy(void) {} +void ldap_helper_dummy(void) +{} #endif /* USE_LDAP */ diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index a3d758489c..1b159cd65d 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -735,8 +735,12 @@ static void samr_reply_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u, DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); - /* oops! */ - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + if (!pass_oem_change(user_name, + q_u->lm_newpass.pass, q_u->lm_oldhash.hash, + q_u->nt_newpass.pass, q_u->nt_oldhash.hash)) + { + status = 0xC0000000 | NT_STATUS_WRONG_PASSWORD; + } make_samr_r_chgpasswd_user(&r_u, status); diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 850282b6b5..7ddc2da5d1 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -212,6 +212,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) { uchar lm_owf[24]; uchar nt_owf[24]; + struct smb_passwd *smb_pass = NULL; DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); @@ -244,15 +245,29 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) memcpy(nt_owf, p->ntlmssp_resp.nt_resp, sizeof(nt_owf)); #ifdef DEBUG_PASSWORD - DEBUG(100,("lm, nt owfs:\n")); + DEBUG(100,("lm, nt owfs, chal\n")); dump_data(100, lm_owf, sizeof(lm_owf)); dump_data(100, nt_owf, sizeof(nt_owf)); + dump_data(100, p->ntlmssp_chal.challenge, 8); #endif become_root(True); p->ntlmssp_validated = pass_check_smb(p->user_name, p->domain, - p->ntlmssp_chal.challenge, lm_owf, nt_owf, NULL); + p->ntlmssp_chal.challenge, (uchar*)lm_owf, (uchar*)nt_owf, NULL); + smb_pass = getsmbpwnam(p->user_name); unbecome_root(True); + if (p->ntlmssp_validated && smb_pass != NULL && smb_pass->smb_passwd) + { + uchar p24[24]; + NTLMSSPOWFencrypt(smb_pass->smb_passwd, lm_owf, p24); + NTLMSSPhash(p->ntlmssp_hash, p24); + p->ntlmssp_seq_num = 0; + } + else + { + p->ntlmssp_validated = False; + } + return p->ntlmssp_validated; } @@ -307,33 +322,22 @@ static struct api_cmd api_fd_commands[] = static BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *pd) { - p->ntlmssp_auth = False; - DEBUG(5,("api_pipe_bind_auth_resp: decode request. %d\n", __LINE__)); - if (p->hdr.auth_len != 0) - { - /* decode the authentication verifier response */ - smb_io_rpc_hdr_autha("", &p->autha_info, pd, 0); - if (pd->offset == 0) return False; + if (p->hdr.auth_len == 0) return False; - p->ntlmssp_auth = p->auth_info.auth_type = 0x0a; - - if (p->ntlmssp_auth) - { - smb_io_rpc_auth_verifier("", &p->auth_verifier, pd, 0); - if (pd->offset == 0) return False; + /* decode the authentication verifier response */ + smb_io_rpc_hdr_autha("", &p->autha_info, pd, 0); + if (pd->offset == 0) return False; - p->ntlmssp_auth = strequal(p->auth_verifier.signature, "NTLMSSP"); - } + if (!rpc_hdr_auth_chk(&(p->auth_info))) return False; - if (p->ntlmssp_auth) - { - if (!api_pipe_ntlmssp(p, pd)) return False; - } - } + smb_io_rpc_auth_verifier("", &p->auth_verifier, pd, 0); + if (pd->offset == 0) return False; - return p->ntlmssp_auth; + if (!rpc_auth_verifier_chk(&(p->auth_verifier), "NTLMSSP", NTLMSSP_AUTH)) return False; + + return api_pipe_ntlmssp(p, pd); } static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) @@ -490,6 +494,58 @@ static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) { + BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SIGN); + BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SEAL); + int data_len; + int auth_len; + uint32 old_offset; + uint32 crc32; + + auth_len = p->hdr.auth_len; + + if (auth_len != 16 && auth_verify) + { + return False; + } + + data_len = p->hdr.frag_len - auth_len - (auth_verify ? 8 : 0) - 0x18; + + DEBUG(5,("api_pipe_auth_process: sign: %s seal: %s data %d auth %d\n", + BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); + + if (auth_seal) + { + char *data = (uchar*)mem_data(&pd->data, pd->offset); + DEBUG(5,("api_pipe_auth_process: data %d\n", pd->offset)); + NTLMSSPcalc(p->ntlmssp_hash, data, data_len); + crc32 = crc32_calc_buffer(data_len, data); + } + + /*** skip the data, record the offset so we can restore it again */ + old_offset = pd->offset; + + if (auth_seal || auth_verify) + { + pd->offset += data_len; + smb_io_rpc_hdr_auth("hdr_auth", &p->auth_info, pd, 0); + } + + if (auth_verify) + { + char *req_data = (uchar*)mem_data(&pd->data, pd->offset + 4); + DEBUG(5,("api_pipe_auth_process: auth %d\n", pd->offset + 4)); + NTLMSSPcalc(p->ntlmssp_hash, req_data, 12); + smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(p->ntlmssp_chk), pd, 0); + + if (!rpc_auth_ntlmssp_chk(&(p->ntlmssp_chk), crc32, + &(p->ntlmssp_seq_num))) + { + return False; + } + } + + pd->offset = old_offset; + return True; } @@ -538,16 +594,33 @@ BOOL rpc_command(pipes_struct *p, prs_struct *pd) } case RPC_REQUEST: { - reply = api_pipe_request (p, pd); + if (p->ntlmssp_auth && !p->ntlmssp_validated) + { + /* authentication _was_ requested + and it failed. sorry, no deal! + */ + reply = False; + } + else + { + /* read the rpc header */ + smb_io_rpc_hdr_req("req", &(p->hdr_req), pd, 0); + reply = api_pipe_request(p, pd); + } break; } case RPC_BINDRESP: /* not the real name! */ { reply = api_pipe_bind_auth_resp(p, pd); + p->ntlmssp_auth = reply; break; } } + if (!reply) + { + DEBUG(3,("rpc_command: DCE/RPC fault should be sent here\n")); + } return reply; } @@ -618,9 +691,6 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds return False; } - /* read the rpc header */ - smb_io_rpc_hdr_req("req", &(p->hdr_req), data, 0); - /* interpret the command */ if (!api_rpc_command(p, rpc_name, api_rpc_cmds, data)) { -- cgit From 1ebeb54932de01323356e8201d465656b8723d46 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 20 Oct 1998 18:27:49 +0000 Subject: some quite important bug-fixes i missed because i transferred the wrong smb.tgz file from my portable. particularly the call to mem_data followed by a realloc of that data in cli_pipe.c's rpc_read() function. smbd responses now use p->rdata_i which is a faked-up pointer into p->rdata's response data. rdata can be very long; rdata_i is limited to point to no more than max_tsize - 0x18 in length. this will make it an almost trivial task to add the encrypted rpc headers after rdata_i, and mem_buf_copy will cope admirably with rhdr chained to rdata_i chained to auth_verifier etc etc... (This used to be commit 05a297e3a98c14360782af4ad0d851638fb5da9a) --- source3/rpc_server/srv_pipe_hnd.c | 10 ++++------ source3/rpc_server/srv_util.c | 31 +++++++++++++++++++------------ 2 files changed, 23 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index d5c99b89c4..54ecbf707e 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -3,8 +3,8 @@ * Unix SMB/Netbios implementation. * Version 1.9. * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Andrew Tridgell 1992-1998, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -175,7 +175,7 @@ ssize_t write_pipe(pipes_struct *p, char *data, size_t n) dump_data(50, data, n); /* fake up a data buffer from the write_pipe data parameters */ - mem_create(&data_buf, data, n, 0, False); + mem_create(&data_buf, data, 0, n, 0, False); data_buf.offset.start = 0; data_buf.offset.end = n; @@ -196,7 +196,7 @@ ssize_t write_pipe(pipes_struct *p, char *data, size_t n) this function is called, the start of the data could possibly have been read by an SMBtrans (file_offset != 0). - calling create_rpc_request() here is a fudge. the data should already + calling create_rpc_reply() here is a fudge. the data should already have been prepared into arrays of headers + data stream sections. ****************************************************************************/ @@ -268,8 +268,6 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) mem_buf_copy(data, p->rhdr.data, 0, 0x18); data += 0x18; - p->frag_len_left = p->hdr.frag_len; - p->next_frag_start += p->hdr.frag_len; p->hdr_offsets += 0x18; } } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 7ddc2da5d1..59db0bed2c 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -165,6 +165,9 @@ int make_dom_gids(char *gids_str, DOM_GID **ppgids) BOOL create_rpc_reply(pipes_struct *p, uint32 data_start, uint32 data_end) { + char *data; + uint32 data_len; + DEBUG(5,("create_rpc_reply: data_start: %d data_end: %d max_tsize: %d\n", data_start, data_end, p->hdr_ba.bba.max_tsize)); @@ -197,6 +200,8 @@ BOOL create_rpc_reply(pipes_struct *p, p->hdr.frag_len = p->hdr_ba.bba.max_tsize; } + data_len = p->hdr.frag_len; + p->rhdr.data->offset.start = 0; p->rhdr.data->offset.end = 0x18; @@ -205,6 +210,20 @@ BOOL create_rpc_reply(pipes_struct *p, smb_io_rpc_hdr ("hdr", &(p->hdr ), &(p->rhdr), 0); smb_io_rpc_hdr_resp("resp", &(p->hdr_resp), &(p->rhdr), 0); + p->frag_len_left = p->hdr.frag_len - p->file_offset; + p->next_frag_start = p->hdr.frag_len; + + /* don't use rdata: use rdata_i instead, which moves... */ + /* make a pointer to the rdata data. NOT A COPY */ + + prs_init(&p->rdata_i, 0, p->rdata.align, p->rdata.data->margin, p->rdata.io); + data = mem_data(&(p->rdata.data), data_start); + mem_create(p->rdata_i.data, data, data_start, data_len, 0, False); + + /* set up the data chain */ + prs_link(NULL , &p->rhdr , &p->rdata_i); + prs_link(&p->rhdr, &p->rdata_i, NULL ); + return p->rhdr.data != NULL && p->rhdr.offset == 0x18; } @@ -703,18 +722,6 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds return False; } - p->frag_len_left = p->hdr.frag_len - p->file_offset; - p->next_frag_start = p->hdr.frag_len; - - /* set up the data chain */ - p->rhdr.data->offset.start = 0; - p->rhdr.data->offset.end = p->rhdr.offset; - p->rhdr.data->next = p->rdata.data; - - p->rdata.data->offset.start = p->rhdr.data->offset.end; - p->rdata.data->offset.end = p->rhdr.data->offset.end + p->rdata.offset; - p->rdata.data->next = NULL; - return True; } -- cgit From 89087385fe1da642ff80d0558c72817c276f631b Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 20 Oct 1998 22:25:52 +0000 Subject: dce/rpc. bug-fix in ipc.c (introduced today :) (This used to be commit 48ff3e2429964404c8bf33ef625791147913a3c0) --- source3/rpc_server/srv_util.c | 114 ++++++++++++++++++++++++++++++++---------- 1 file changed, 87 insertions(+), 27 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 59db0bed2c..0cb730470e 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -166,18 +166,29 @@ BOOL create_rpc_reply(pipes_struct *p, uint32 data_start, uint32 data_end) { char *data; + BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SIGN); + BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SEAL); uint32 data_len; + uint32 auth_len; DEBUG(5,("create_rpc_reply: data_start: %d data_end: %d max_tsize: %d\n", data_start, data_end, p->hdr_ba.bba.max_tsize)); - mem_buf_init(&(p->rhdr.data), 0); - mem_alloc_data(p->rhdr.data, 0x18); + auth_len = p->hdr.auth_len; - p->rhdr.align = 4; - p->rhdr.io = False; + if (p->ntlmssp_auth) + { + DEBUG(10,("create_rpc_reply: auth\n")); + if (auth_len != 16) + { + return False; + } + } + + prs_init(&p->rhdr , 0x18, 4, 0, False); + prs_init(&p->rauth, 1024, 4, 0, False); + prs_init(&p->rverf, 0x08, 4, 0, False); - p->hdr_resp.alloc_hint = data_end - data_start; /* calculate remaining data to be sent */ p->hdr.pkt_type = RPC_RESPONSE; /* mark header as an rpc response */ /* set up rpc header (fragmentation issues) */ @@ -190,6 +201,8 @@ BOOL create_rpc_reply(pipes_struct *p, p->hdr.flags = 0; } + p->hdr_resp.alloc_hint = data_end - data_start; /* calculate remaining data to be sent */ + if (p->hdr_resp.alloc_hint + 0x18 <= p->hdr_ba.bba.max_tsize) { p->hdr.flags |= RPC_FLG_LAST; @@ -200,30 +213,83 @@ BOOL create_rpc_reply(pipes_struct *p, p->hdr.frag_len = p->hdr_ba.bba.max_tsize; } - data_len = p->hdr.frag_len; + if (p->ntlmssp_auth) + { + p->hdr_resp.alloc_hint -= auth_len - 16; + } + + if (p->ntlmssp_auth) + { + data_len = p->hdr.frag_len - auth_len - (auth_verify ? 8 : 0) - 0x18; + } + else + { + data_len = p->hdr.frag_len; + } p->rhdr.data->offset.start = 0; p->rhdr.data->offset.end = 0x18; /* store the header in the data stream */ - p->rhdr.offset = 0; - smb_io_rpc_hdr ("hdr", &(p->hdr ), &(p->rhdr), 0); + smb_io_rpc_hdr ("hdr" , &(p->hdr ), &(p->rhdr), 0); smb_io_rpc_hdr_resp("resp", &(p->hdr_resp), &(p->rhdr), 0); - p->frag_len_left = p->hdr.frag_len - p->file_offset; - p->next_frag_start = p->hdr.frag_len; - /* don't use rdata: use rdata_i instead, which moves... */ - /* make a pointer to the rdata data. NOT A COPY */ + /* make a pointer to the rdata data, NOT A COPY */ + p->rdata_i.data = NULL; prs_init(&p->rdata_i, 0, p->rdata.align, p->rdata.data->margin, p->rdata.io); data = mem_data(&(p->rdata.data), data_start); - mem_create(p->rdata_i.data, data, data_start, data_len, 0, False); + mem_create(p->rdata_i.data, data, 0, data_len, 0, False); + p->rdata_i.offset = data_len; + + if (auth_len > 0) + { + uint32 crc32; + + DEBUG(5,("create_rpc_reply: sign: %s seal: %s data %d auth %d\n", + BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); + + if (auth_seal) + { + NTLMSSPcalc(p->ntlmssp_hash, data, data_len); + crc32 = crc32_calc_buffer(data_len, data); + } + + if (auth_seal || auth_verify) + { + make_rpc_hdr_auth(&p->auth_info, 0x0a, 0x06, 0x08, (auth_verify ? 1 : 0)); + smb_io_rpc_hdr_auth("hdr_auth", &p->auth_info, &p->rauth, 0); + } + + if (auth_verify) + { + char *auth_data; + make_rpc_auth_ntlmssp_chk(&p->ntlmssp_chk, NTLMSSP_SIGN_VERSION, crc32, p->ntlmssp_seq_num); + smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(p->ntlmssp_chk), &p->rverf, 0); + auth_data = (uchar*)mem_data(&p->rverf.data, 4); + NTLMSSPcalc(p->ntlmssp_hash, auth_data, 12); + } + } /* set up the data chain */ - prs_link(NULL , &p->rhdr , &p->rdata_i); - prs_link(&p->rhdr, &p->rdata_i, NULL ); + if (p->ntlmssp_auth) + { + prs_link(NULL , &p->rhdr , &p->rdata_i); + prs_link(&p->rhdr , &p->rdata_i, &p->rauth ); + prs_link(&p->rdata_i, &p->rauth , &p->rverf ); + prs_link(&p->rauth , &p->rverf , NULL ); + } + else + { + prs_link(NULL , &p->rhdr , &p->rdata_i); + prs_link(&p->rhdr, &p->rdata_i, NULL ); + } + /* indicate to subsequent data reads where we are up to */ + p->frag_len_left = p->hdr.frag_len - p->file_offset; + p->next_frag_start = p->hdr.frag_len; + return p->rhdr.data != NULL && p->rhdr.offset == 0x18; } @@ -271,7 +337,8 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) #endif become_root(True); p->ntlmssp_validated = pass_check_smb(p->user_name, p->domain, - p->ntlmssp_chal.challenge, (uchar*)lm_owf, (uchar*)nt_owf, NULL); + (uchar*)p->ntlmssp_chal.challenge, + (char*)lm_owf, (char*)nt_owf, NULL); smb_pass = getsmbpwnam(p->user_name); unbecome_root(True); @@ -418,7 +485,7 @@ static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); prs_init(&(p->rdata), 1024, 4, 0, False); - prs_init(&(p->rhdr ), 0x10, 4, 0, False); + prs_init(&(p->rhdr ), 0x18, 4, 0, False); prs_init(&(p->rauth), 1024, 4, 0, False); prs_init(&(p->rverf), 0x08, 4, 0, False); prs_init(&(p->rntlm), 1024, 4, 0, False); @@ -561,6 +628,7 @@ static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) { return False; } + p->ntlmssp_seq_num = 0; } pd->offset = old_offset; @@ -671,17 +739,9 @@ static BOOL api_rpc_command(pipes_struct *p, } /* start off with 1024 bytes, and a large safety margin too */ - mem_buf_init(&(p->rdata.data), SAFETY_MARGIN); - mem_alloc_data(p->rdata.data, 1024); - - p->rdata.io = False; - p->rdata.align = 4; - - p->rdata.data->offset.start = 0; - p->rdata.data->offset.end = 0xffffffff; + prs_init(&p->rdata, 1024, 4, SAFETY_MARGIN, False); /* do the actual command */ - p->rdata.offset = 0; api_rpc_cmds[fn_num].fn(p->vuid, data, &(p->rdata)); if (p->rdata.data == NULL || p->rdata.offset == 0) @@ -717,7 +777,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds } /* create the rpc header */ - if (!create_rpc_reply(p, 0, p->rdata.offset)) + if (!create_rpc_reply(p, 0, p->rdata.offset + (p->ntlmssp_auth ? (16 + 16) : 0))) { return False; } -- cgit From d8f0e60195ff8447df9235f60095c4e2bb4561e7 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 20 Oct 1998 22:37:44 +0000 Subject: signed / unsigned warnings (found by herb). how do i switch on these warnings in gcc????? (This used to be commit 39db385a0c47c11adb6bf3bac89c4bb76f675049) --- source3/rpc_server/srv_util.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 0cb730470e..1c57efc3f4 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -252,7 +252,7 @@ BOOL create_rpc_reply(pipes_struct *p, if (auth_seal) { - NTLMSSPcalc(p->ntlmssp_hash, data, data_len); + NTLMSSPcalc(p->ntlmssp_hash, (uchar*)data, data_len); crc32 = crc32_calc_buffer(data_len, data); } @@ -267,8 +267,8 @@ BOOL create_rpc_reply(pipes_struct *p, char *auth_data; make_rpc_auth_ntlmssp_chk(&p->ntlmssp_chk, NTLMSSP_SIGN_VERSION, crc32, p->ntlmssp_seq_num); smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(p->ntlmssp_chk), &p->rverf, 0); - auth_data = (uchar*)mem_data(&p->rverf.data, 4); - NTLMSSPcalc(p->ntlmssp_hash, auth_data, 12); + auth_data = mem_data(&p->rverf.data, 4); + NTLMSSPcalc(p->ntlmssp_hash, (uchar*)auth_data, 12); } } @@ -601,9 +601,9 @@ static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) if (auth_seal) { - char *data = (uchar*)mem_data(&pd->data, pd->offset); + char *data = mem_data(&pd->data, pd->offset); DEBUG(5,("api_pipe_auth_process: data %d\n", pd->offset)); - NTLMSSPcalc(p->ntlmssp_hash, data, data_len); + NTLMSSPcalc(p->ntlmssp_hash, (uchar*)data, data_len); crc32 = crc32_calc_buffer(data_len, data); } @@ -618,9 +618,9 @@ static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) if (auth_verify) { - char *req_data = (uchar*)mem_data(&pd->data, pd->offset + 4); + char *req_data = mem_data(&pd->data, pd->offset + 4); DEBUG(5,("api_pipe_auth_process: auth %d\n", pd->offset + 4)); - NTLMSSPcalc(p->ntlmssp_hash, req_data, 12); + NTLMSSPcalc(p->ntlmssp_hash, (uchar*)req_data, 12); smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(p->ntlmssp_chk), pd, 0); if (!rpc_auth_ntlmssp_chk(&(p->ntlmssp_chk), crc32, -- cgit From 9307940876a6c226969e9169d55c0408cd7ab032 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 21 Oct 1998 01:35:01 +0000 Subject: fixing smbd encrypted rpcs (data lens, alloc hints, sequence nums argh). put unicode strings after SAMLOGON query regardless of whether it's an NT mailslot or a non-NT mailslot, after having observed this behaviour out of NT machines. (This used to be commit c101113ec20ed0ba633e78e4ee45596cdccaf1b5) --- source3/rpc_server/srv_util.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 1c57efc3f4..fde654bcc4 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -215,7 +215,7 @@ BOOL create_rpc_reply(pipes_struct *p, if (p->ntlmssp_auth) { - p->hdr_resp.alloc_hint -= auth_len - 16; + p->hdr_resp.alloc_hint -= auth_len + 8; } if (p->ntlmssp_auth) @@ -252,8 +252,8 @@ BOOL create_rpc_reply(pipes_struct *p, if (auth_seal) { - NTLMSSPcalc(p->ntlmssp_hash, (uchar*)data, data_len); crc32 = crc32_calc_buffer(data_len, data); + NTLMSSPcalc(p->ntlmssp_hash, (uchar*)data, data_len); } if (auth_seal || auth_verify) @@ -265,7 +265,8 @@ BOOL create_rpc_reply(pipes_struct *p, if (auth_verify) { char *auth_data; - make_rpc_auth_ntlmssp_chk(&p->ntlmssp_chk, NTLMSSP_SIGN_VERSION, crc32, p->ntlmssp_seq_num); + p->ntlmssp_seq_num++; + make_rpc_auth_ntlmssp_chk(&p->ntlmssp_chk, NTLMSSP_SIGN_VERSION, crc32, p->ntlmssp_seq_num++); smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(p->ntlmssp_chk), &p->rverf, 0); auth_data = mem_data(&p->rverf.data, 4); NTLMSSPcalc(p->ntlmssp_hash, (uchar*)auth_data, 12); @@ -624,11 +625,10 @@ static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(p->ntlmssp_chk), pd, 0); if (!rpc_auth_ntlmssp_chk(&(p->ntlmssp_chk), crc32, - &(p->ntlmssp_seq_num))) + p->ntlmssp_seq_num)) { return False; } - p->ntlmssp_seq_num = 0; } pd->offset = old_offset; @@ -777,7 +777,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds } /* create the rpc header */ - if (!create_rpc_reply(p, 0, p->rdata.offset + (p->ntlmssp_auth ? (16 + 16) : 0))) + if (!create_rpc_reply(p, 0, p->rdata.offset + (p->ntlmssp_auth ? (16 + 8) : 0))) { return False; } -- cgit From 6e3af45afe237790f1d7cd94ab2b22e1ca772157 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 21 Oct 1998 16:58:34 +0000 Subject: Fixed mainly signed/unsigned issues found by SGI cc in -fullwarn mode. smbd/chgpasswd.c: Fixed (my) stupid bug where I was returning stack based variables. Doh ! smbd/trans2.c: Allows SETFILEINFO as well as QFILEINFO on directory handles. Jeremy. (This used to be commit 0b44d27d0b5cc3948a6c2d78370ccddf1a84cd80) --- source3/rpc_server/srv_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index fde654bcc4..3269ab4e61 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -339,7 +339,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) become_root(True); p->ntlmssp_validated = pass_check_smb(p->user_name, p->domain, (uchar*)p->ntlmssp_chal.challenge, - (char*)lm_owf, (char*)nt_owf, NULL); + lm_owf, nt_owf, NULL); smb_pass = getsmbpwnam(p->user_name); unbecome_root(True); -- cgit From 5b7df7a7529f28c21addf7666bc2106ed2848990 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 21 Oct 1998 18:06:46 +0000 Subject: added "start index" skipping into querydispinfo. (This used to be commit 3e6519da22628ea41025711718ec23b082ef02d0) --- source3/rpc_server/srv_samr.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 1b159cd65d..f82a1f5afe 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -41,6 +41,7 @@ extern rid_name domain_alias_rids[]; ********************************************************************/ static BOOL 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) @@ -62,7 +63,18 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, while (((pwd = getsam21pwent(vp)) != NULL) && (*num_entries) < max_num_entries) { - int user_name_len = strlen(pwd->smb_name); + int user_name_len; + + if (start_idx > 0) + { + /* skip the requested number of entries. + not very efficient, but hey... + */ + start_idx--; + continue; + } + + user_name_len = strlen(pwd->smb_name); make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len-1); make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len-1, user_name_len-1, 1); @@ -302,7 +314,7 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, DEBUG(5,("samr_reply_enum_dom_users: %d\n", __LINE__)); become_root(True); - get_sampwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, q_u->acb_mask); + get_sampwd_entries(pass, 0, &total_entries, &num_entries, MAX_SAM_ENTRIES, q_u->acb_mask); unbecome_root(True); make_samr_r_enum_dom_users(&r_e, total_entries, @@ -473,7 +485,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, if (r_e.status == 0x0) { become_root(True); - got_pwds = get_sampwd_entries(pass, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); + got_pwds = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); unbecome_root(True); switch (q_u->switch_level) @@ -943,13 +955,11 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) LOGON_HRS hrs; int i; -#ifdef DONT_CHECK_THIS_FOR_NOW if (!pdb_rid_is_user(user_rid)) { DEBUG(4,("RID 0x%x is not a user RID\n", user_rid)); return False; } -#endif become_root(True); sam_pass = getsam21pwrid(user_rid); -- cgit From 21e107fd42eb953affac28239588458c6c0ee323 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 21 Oct 1998 21:11:16 +0000 Subject: the next dialog: user-groups. it's not very sensible what appears, but hey: it appears! (This used to be commit 399035098f212e976cc0000a215e0705ebe78c05) --- source3/rpc_server/srv_samr.c | 186 ++++++++++++++++++++++++++++++++++++++---- source3/rpc_server/srv_util.c | 2 +- 2 files changed, 173 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index f82a1f5afe..06ed6603b3 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -30,6 +30,8 @@ extern int DEBUGLEVEL; extern BOOL sam_logon_in_ssb; extern pstring samlogon_user; +extern pstring global_myworkgroup; +extern pstring global_myname; extern DOM_SID global_machine_sid; extern rid_name domain_group_rids[]; @@ -215,6 +217,54 @@ static void api_samr_open_domain( uint16 vuid, prs_struct *data, prs_struct *rda } +/******************************************************************* + samr_reply_unknown_2c + ********************************************************************/ +static void samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, + prs_struct *rdata) +{ + SAMR_R_UNKNOWN_2C r_u; + uint32 status = 0x0; + uint32 rid; + + /* find the policy handle. open a policy on it. */ + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->user_pol)) == -1)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + /* find the user's rid */ + if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->user_pol))) == 0xffffffff) + { + status = NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + make_samr_r_unknown_2c(&r_u, status); + + DEBUG(5,("samr_unknown_2c: %d\n", __LINE__)); + + /* store the response in the SMB stream */ + samr_io_r_unknown_2c("", &r_u, rdata, 0); + + DEBUG(5,("samr_unknown_2c: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_unknown_2c + ********************************************************************/ +static void api_samr_unknown_2c( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_UNKNOWN_2C q_u; + + /* grab the samr open */ + samr_io_q_unknown_2c("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_unknown_2c(&q_u, rdata); +} + + /******************************************************************* samr_reply_unknown_3 ********************************************************************/ @@ -242,24 +292,24 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, if (status == 0x0) { - DOM_SID user_sid; - DOM_SID other_sid; + DOM_SID user_sid; + DOM_SID everyone_sid; - user_sid = global_machine_sid; + user_sid = global_machine_sid; - SMB_ASSERT_ARRAY(user_sid.sub_auths, user_sid.num_auths+1); + SMB_ASSERT_ARRAY(user_sid.sub_auths, user_sid.num_auths+1); - /* - * Add the user RID. - */ - user_sid.sub_auths[user_sid.num_auths++] = rid; - - string_to_sid(&other_sid, "S-1-1"); + /* + * Add the user RID. + */ + user_sid.sub_auths[user_sid.num_auths++] = rid; + + string_to_sid(&everyone_sid, "S-1-1"); - /* maybe need another 1 or 2 (S-1-5-20-0x220 and S-1-5-20-0x224) */ - /* these two are DOMAIN_ADMIN and DOMAIN_ACCT_OP group RIDs */ - make_dom_sid3(&(sid[0]), 0x035b, 0x0002, &other_sid); - make_dom_sid3(&(sid[1]), 0x0044, 0x0002, &user_sid); + /* maybe need another 1 or 2 (S-1-5-20-0x220 and S-1-5-20-0x224) */ + /* these two are DOMAIN_ADMIN and DOMAIN_ACCT_OP group RIDs */ + make_dom_sid3(&(sid[0]), 0x035b, 0x0002, &everyone_sid); + make_dom_sid3(&(sid[1]), 0x0044, 0x0002, &user_sid); } make_samr_r_unknown_3(&r_u, @@ -945,6 +995,36 @@ static void api_samr_open_user( uint16 vuid, prs_struct *data, prs_struct *rdata } +/************************************************************************* + get_user_info_10 + *************************************************************************/ +static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) +{ + struct smb_passwd *smb_pass; + + if (!pdb_rid_is_user(user_rid)) + { + DEBUG(4,("RID 0x%x is not a user RID\n", user_rid)); + return False; + } + + become_root(True); + smb_pass = getsmbpwrid(user_rid); + unbecome_root(True); + + if (smb_pass == NULL) + { + DEBUG(4,("User 0x%x not found\n", user_rid)); + return False; + } + + DEBUG(3,("User:[%s]\n", smb_pass->smb_name)); + + make_sam_user_info10(id10, smb_pass->acct_ctrl); + + return True; +} + /************************************************************************* get_user_info_21 *************************************************************************/ @@ -1029,6 +1109,7 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, #if 0 SAM_USER_INFO_11 id11; #endif + SAM_USER_INFO_10 id10; SAM_USER_INFO_21 id21; void *info = NULL; @@ -1056,6 +1137,12 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, { switch (q_u->switch_value) { + case 0x10: + { + info = (void*)&id10; + status = get_user_info_10(&id10, rid) ? 0 : NT_STATUS_NO_SUCH_USER; + break; + } #if 0 /* whoops - got this wrong. i think. or don't understand what's happening. */ case 0x11: @@ -1188,6 +1275,75 @@ static void api_samr_query_usergroups( uint16 vuid, prs_struct *data, prs_struct } +/******************************************************************* + samr_reply_unknown_8 + ********************************************************************/ +static void samr_reply_unknown_8(SAMR_Q_UNKNOWN_8 *q_u, + prs_struct *rdata) +{ + SAMR_R_UNKNOWN_8 r_u; + SAM_UNK_CTR ctr; + uint16 switch_value = 0x0; + uint32 status = 0x0; + + ZERO_STRUCT(r_u); + ZERO_STRUCT(ctr); + + r_u.ctr = &ctr; + + DEBUG(5,("samr_reply_unknown_8: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->domain_pol)) == -1)) + { + r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + DEBUG(5,("samr_reply_unknown_8: invalid handle\n")); + } + + if (status == 0x0) + { + switch (q_u->switch_value) + { + case 0x02: + { + switch_value = 0x2; + make_unk_info2(&ctr.info.inf2, global_myworkgroup, global_myname); + + break; + } + default: + { + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + break; + } + } + } + + make_samr_r_unknown_8(&r_u, switch_value, &ctr, status); + + /* store the response in the SMB stream */ + samr_io_r_unknown_8("", &r_u, rdata, 0); + + DEBUG(5,("samr_unknown_8: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_unknown_8 + ********************************************************************/ +static void api_samr_unknown_8( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_UNKNOWN_8 q_e; + + /* grab the samr unknown 8 command */ + samr_io_q_unknown_8("", &q_e, data, 0); + + /* construct reply. */ + samr_reply_unknown_8(&q_e, rdata); +} + + + /******************************************************************* samr_reply_unknown_32 ********************************************************************/ @@ -1439,6 +1595,7 @@ static struct api_struct api_samr_cmds [] = { "SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, { "SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, { "SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, + { "SAMR_UNKNOWN_8" , SAMR_UNKNOWN_8 , api_samr_unknown_8 }, { "SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, { "SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, { "SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, @@ -1449,6 +1606,7 @@ static struct api_struct api_samr_cmds [] = { "SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, { "SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, { "SAMR_UNKNOWN_3" , SAMR_UNKNOWN_3 , api_samr_unknown_3 }, + { "SAMR_UNKNOWN_2C" , SAMR_UNKNOWN_2C , api_samr_unknown_2c }, { NULL , 0 , NULL } }; diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 3269ab4e61..4756d2f338 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -224,7 +224,7 @@ BOOL create_rpc_reply(pipes_struct *p, } else { - data_len = p->hdr.frag_len; + data_len = p->hdr.frag_len - 0x18; } p->rhdr.data->offset.start = 0; -- cgit From eadc5b8c6ecdd6892647d391e1976b2c708d1ea0 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 21 Oct 1998 22:36:26 +0000 Subject: domain aliases added a bit better: does local aliases if you query for sid S-1-5-20 and does (nothing at the moment) if you query for your own sid. (This used to be commit da40f26f4b2f7ce286076b4e39dffd76aa2ef8e6) --- source3/rpc_server/srv_lsa.c | 8 ++--- source3/rpc_server/srv_lsa_hnd.c | 23 +++++++++++++- source3/rpc_server/srv_netlog.c | 4 +-- source3/rpc_server/srv_samr.c | 68 +++++++++++++++++++++++++--------------- source3/rpc_server/srv_util.c | 1 - 5 files changed, 70 insertions(+), 34 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 93584b5acf..a355f0b311 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -28,7 +28,7 @@ #include "nterr.h" extern int DEBUGLEVEL; -extern DOM_SID global_machine_sid; +extern DOM_SID global_sam_sid; /*************************************************************************** lsa_reply_open_policy2 @@ -373,7 +373,7 @@ static void api_lsa_query_info( uint16 vuid, prs_struct *data, pstrcpy(dom_name, lp_workgroup()); /* construct reply. return status is always 0x0 */ - lsa_reply_query_info(&q_i, rdata, dom_name, &global_machine_sid); + lsa_reply_query_info(&q_i, rdata, dom_name, &global_sam_sid); } /*************************************************************************** @@ -406,7 +406,7 @@ static void api_lsa_lookup_sids( uint16 vuid, prs_struct *data, string_to_sid(&sid_S_1_5, "S-1-5"); dom_names[0] = dom_name; - sid_array[0] = &global_machine_sid; + sid_array[0] = &global_sam_sid; dom_names[1] = "Everyone"; sid_array[1] = &sid_S_1_1; @@ -458,7 +458,7 @@ static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, string_to_sid(&sid_S_1_5, "S-1-5"); dom_names[0] = dom_name; - sid_array[0] = &global_machine_sid; + sid_array[0] = &global_sam_sid; dom_names[1] = "Everyone"; sid_array[1] = &sid_S_1_1; diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index b1e695360f..b807c40604 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -225,7 +225,28 @@ BOOL set_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) } /**************************************************************************** - set samr rid + get samr sid +****************************************************************************/ +BOOL get_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) +{ + struct policy *p = find_lsa_policy(hnd); + + if (p != NULL && p->open) + { + pstring sidstr; + memcpy(sid, &p->dev.samr.sid, sizeof(*sid)); + DEBUG(3,("Getting policy sid=%s pnum=%x\n", + sid_to_string(sidstr, sid), p->pnum)); + + return True; + } + + DEBUG(3,("Error getting policy\n")); + return False; +} + +/**************************************************************************** + get samr rid ****************************************************************************/ uint32 get_lsa_policy_samr_rid(POLICY_HND *hnd) { diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 79a659faf8..4228eab3e0 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -32,7 +32,7 @@ extern int DEBUGLEVEL; extern BOOL sam_logon_in_ssb; extern pstring samlogon_user; extern pstring global_myname; -extern DOM_SID global_machine_sid; +extern DOM_SID global_sam_sid; /************************************************************************* make_net_r_req_chal: @@ -790,7 +790,7 @@ static void api_net_sam_logon( uint16 vuid, my_name , /* char *logon_srv */ my_workgroup, /* char *logon_dom */ - &global_machine_sid, /* DOM_SID *dom_sid */ + &global_sam_sid, /* DOM_SID *dom_sid */ NULL); /* char *other_sids */ } else diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 06ed6603b3..9a37f76121 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -32,10 +32,11 @@ extern BOOL sam_logon_in_ssb; extern pstring samlogon_user; extern pstring global_myworkgroup; extern pstring global_myname; -extern DOM_SID global_machine_sid; +extern DOM_SID global_sam_sid; extern rid_name domain_group_rids[]; extern rid_name domain_alias_rids[]; +extern rid_name builtin_alias_rids[]; /******************************************************************* This next function should be replaced with something that @@ -295,7 +296,7 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, DOM_SID user_sid; DOM_SID everyone_sid; - user_sid = global_machine_sid; + user_sid = global_sam_sid; SMB_ASSERT_ARRAY(user_sid.sub_auths, user_sid.num_auths+1); @@ -457,29 +458,44 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, SAMR_R_ENUM_DOM_ALIASES r_e; SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; int num_entries; - BOOL got_aliases; - char *dummy_alias = "admins"; + DOM_SID sid; + fstring sid_str; + fstring sam_sid_str; r_e.status = 0x0; r_e.num_entries = 0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &sid)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } - DEBUG(5,("samr_reply_enum_dom_aliases: %d\n", __LINE__)); + sid_to_string(sid_str, &sid); + sid_to_string(sam_sid_str, &global_sam_sid); - got_aliases = True; - num_entries = 1; - make_unistr2(&(pass[0].uni_user_name), dummy_alias, strlen(dummy_alias)); - pass[0].user_rid = BUILTIN_ALIAS_RID_ADMINS; + DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", sid_str)); - if (r_e.status == 0 && got_aliases) + /* well-known aliases */ + if (strequal(sid_str, "S-1-5-20")) { - make_samr_r_enum_dom_aliases(&r_e, num_entries, pass, r_e.status); + char *name; + while (num_entries < MAX_SAM_ENTRIES && ((name = builtin_alias_rids[num_entries].name) != NULL)) + { + make_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)); + pass[num_entries].user_rid = builtin_alias_rids[num_entries].rid; + num_entries++; + } } + else if (strequal(sid_str, sam_sid_str)) + { + /* local aliases */ + /* oops! there's no code to deal with this */ + DEBUG(3,("samr_reply_enum_dom_aliases: enum of aliases in our domain not supported yet\n")); + num_entries = 0; + } + + make_samr_r_enum_dom_aliases(&r_e, num_entries, pass, r_e.status); /* store the response in the SMB stream */ samr_io_r_enum_dom_aliases("", &r_e, rdata, 0); @@ -1276,12 +1292,12 @@ static void api_samr_query_usergroups( uint16 vuid, prs_struct *data, prs_struct /******************************************************************* - samr_reply_unknown_8 + samr_reply_query_dom_info ********************************************************************/ -static void samr_reply_unknown_8(SAMR_Q_UNKNOWN_8 *q_u, +static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, prs_struct *rdata) { - SAMR_R_UNKNOWN_8 r_u; + SAMR_R_QUERY_DOMAIN_INFO r_u; SAM_UNK_CTR ctr; uint16 switch_value = 0x0; uint32 status = 0x0; @@ -1291,13 +1307,13 @@ static void samr_reply_unknown_8(SAMR_Q_UNKNOWN_8 *q_u, r_u.ctr = &ctr; - DEBUG(5,("samr_reply_unknown_8: %d\n", __LINE__)); + DEBUG(5,("samr_reply_query_dom_info: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->domain_pol)) == -1)) { r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - DEBUG(5,("samr_reply_unknown_8: invalid handle\n")); + DEBUG(5,("samr_reply_query_dom_info: invalid handle\n")); } if (status == 0x0) @@ -1319,27 +1335,27 @@ static void samr_reply_unknown_8(SAMR_Q_UNKNOWN_8 *q_u, } } - make_samr_r_unknown_8(&r_u, switch_value, &ctr, status); + make_samr_r_query_dom_info(&r_u, switch_value, &ctr, status); /* store the response in the SMB stream */ - samr_io_r_unknown_8("", &r_u, rdata, 0); + samr_io_r_query_dom_info("", &r_u, rdata, 0); - DEBUG(5,("samr_unknown_8: %d\n", __LINE__)); + DEBUG(5,("samr_query_dom_info: %d\n", __LINE__)); } /******************************************************************* - api_samr_unknown_8 + api_samr_query_dom_info ********************************************************************/ -static void api_samr_unknown_8( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_dom_info( uint16 vuid, prs_struct *data, prs_struct *rdata) { - SAMR_Q_UNKNOWN_8 q_e; + SAMR_Q_QUERY_DOMAIN_INFO q_e; /* grab the samr unknown 8 command */ - samr_io_q_unknown_8("", &q_e, data, 0); + samr_io_q_query_dom_info("", &q_e, data, 0); /* construct reply. */ - samr_reply_unknown_8(&q_e, rdata); + samr_reply_query_dom_info(&q_e, rdata); } @@ -1595,7 +1611,7 @@ static struct api_struct api_samr_cmds [] = { "SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, { "SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, { "SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, - { "SAMR_UNKNOWN_8" , SAMR_UNKNOWN_8 , api_samr_unknown_8 }, + { "SAMR_QUERY_DOMAIN_INFO", SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, { "SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, { "SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, { "SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 4756d2f338..b3557c7768 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -42,7 +42,6 @@ #include "nterr.h" extern int DEBUGLEVEL; -extern DOM_SID global_machine_sid; /* * A list of the rids of well known BUILTIN and Domain users -- cgit From 1ee499385c1ea0b4add82d3d4513ea997d048af1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 Oct 1998 16:55:03 +0000 Subject: libsmb/smbdes.c: #ifdef'ed out code prior to removal. rpc_client/cli_pipe.c: Inlined code removed from smbdes.c rpc_server/srv_samr.c: Fixed unused variable warning. rpc_server/srv_util.c: Inlined code removed from smbdes.c Luke - the above changes are the first part of the changes you and I discussed as being neccessary at the CIFS conference. *PLEASE REVIEW THESE CHANGES* - make sure I haven't broken any of the authenticated DCE/RPC code. smbd/nttrans.c: Fixed to allow NT5.0beta2 to use Samba shares with NT SMB support. smbd/open.c: Fixed mkdir when called from nttrans calls. smbd/server.c: Set correct size for strcpy of global_myworkgroup. Jeremy. (This used to be commit d891421d16ff80998dee429227bd391455f9d1a1) --- source3/rpc_server/srv_samr.c | 3 +-- source3/rpc_server/srv_util.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 9a37f76121..e9204e065f 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -226,7 +226,6 @@ static void samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, { SAMR_R_UNKNOWN_2C r_u; uint32 status = 0x0; - uint32 rid; /* find the policy handle. open a policy on it. */ if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->user_pol)) == -1)) @@ -235,7 +234,7 @@ static void samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, } /* find the user's rid */ - if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->user_pol))) == 0xffffffff) + if ((status == 0x0) && (get_lsa_policy_samr_rid(&(q_u->user_pol)) == 0xffffffff)) { status = NT_STATUS_OBJECT_TYPE_MISMATCH; } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index b3557c7768..51df42cdff 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -346,7 +346,37 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) { uchar p24[24]; NTLMSSPOWFencrypt(smb_pass->smb_passwd, lm_owf, p24); - NTLMSSPhash(p->ntlmssp_hash, p24); + { + unsigned char j = 0; + int ind; + + unsigned char k2[8]; + + memcpy(k2, p24, 5); + k2[5] = 0xe5; + k2[6] = 0x38; + k2[7] = 0xb0; + + for (ind = 0; ind < 256; ind++) + { + p->ntlmssp_hash[ind] = (unsigned char)ind; + } + + for( ind = 0; ind < 256; ind++) + { + unsigned char tc; + + j += (p->ntlmssp_hash[ind] + k2[ind%8]); + + tc = p->ntlmssp_hash[ind]; + p->ntlmssp_hash[ind] = p->ntlmssp_hash[j]; + p->ntlmssp_hash[j] = tc; + } + + p->ntlmssp_hash[256] = 0; + p->ntlmssp_hash[257] = 0; + } +/* NTLMSSPhash(p->ntlmssp_hash, p24); */ p->ntlmssp_seq_num = 0; } else -- cgit From cbd0b2ccf9519bcada58567b88987e134563058d Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 22 Oct 1998 18:15:23 +0000 Subject: bug fix in lsa_trans_names. well-known aliases S-1-5-20 is actually S-1-5-0x20 but sid_to_string does decimal not hexadecimal oops. (This used to be commit 4d830e243650729344a2d1b238075e787802ff8b) --- source3/rpc_server/srv_lsa.c | 4 +++- source3/rpc_server/srv_samr.c | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index a355f0b311..b813301dda 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -231,7 +231,9 @@ static void make_lsa_trans_names(LSA_TRANS_NAME_ENUM *trn, if (status == 0x0) { - make_lsa_trans_name(&(trn->name[(*total)]), type, name, (*total)); + make_lsa_trans_name(&(trn->name [(*total)]), + &(trn->uni_name[(*total)]), + type, name, (*total)); (*total)++; } } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index e9204e065f..3a656b5a3b 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -306,7 +306,7 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, string_to_sid(&everyone_sid, "S-1-1"); - /* maybe need another 1 or 2 (S-1-5-20-0x220 and S-1-5-20-0x224) */ + /* maybe need another 1 or 2 (S-1-5-0x20-0x220 and S-1-5-20-0x224) */ /* these two are DOMAIN_ADMIN and DOMAIN_ACCT_OP group RIDs */ make_dom_sid3(&(sid[0]), 0x035b, 0x0002, &everyone_sid); make_dom_sid3(&(sid[1]), 0x0044, 0x0002, &user_sid); @@ -456,7 +456,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, { SAMR_R_ENUM_DOM_ALIASES r_e; SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; - int num_entries; + int num_entries = 0; DOM_SID sid; fstring sid_str; fstring sam_sid_str; @@ -476,7 +476,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", sid_str)); /* well-known aliases */ - if (strequal(sid_str, "S-1-5-20")) + if (strequal(sid_str, "S-1-5-32")) { char *name; while (num_entries < MAX_SAM_ENTRIES && ((name = builtin_alias_rids[num_entries].name) != NULL)) -- cgit From 80f920181f8d2d58bd3b341aac57de0c71e21374 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 Oct 1998 18:51:16 +0000 Subject: server/srv_samr.c smbd/ipc.c: Changed global_myworkgroup back to fstring (as it is everywhere else). smbwrapper/smbsh.c: For IRIX n32 binaries, set _RLDN32_LIST not _RLD32_LIST. Exec users preferred shell is SHELL environment variable is set. tests/fcntl_lock.c: Added sys/types.h for systems that need this. Jeremy. (This used to be commit 50413d0d819d4f13e760ca8439c5bdde0898d63e) --- source3/rpc_server/srv_samr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 3a656b5a3b..74d06d1bca 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -30,7 +30,7 @@ extern int DEBUGLEVEL; extern BOOL sam_logon_in_ssb; extern pstring samlogon_user; -extern pstring global_myworkgroup; +extern fstring global_myworkgroup; extern pstring global_myname; extern DOM_SID global_sam_sid; -- cgit From a9d1a8996324cd5344bc5579c4556632c59ef3e2 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 23 Oct 1998 17:22:21 +0000 Subject: set netlogon negotiation flags to 0x1ff, not to what the client requests. this is 0x4000 01ff on NT4 SP4, and 0x0000 01ff on pre-NT4 SP4. (This used to be commit 59cf9c00d91f9706d58c3d3000842eccb9d272fc) --- source3/rpc_server/srv_lsa.c | 19 ++++++++++--------- source3/rpc_server/srv_netlog.c | 5 ++++- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index b813301dda..8f22f8f574 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -478,15 +478,16 @@ static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, { fstring user_name; fstrcpy(user_name, unistr2(q_l.lookup_name[i].str.buffer)); - /* - * Map to the UNIX username. - */ - map_username(user_name); - - /* - * Do any case conversions. - */ - (void)Get_Pwnam(user_name, True); + + /* + * Map to the UNIX username. + */ + map_username(user_name); + + /* + * Do any case conversions. + */ + (void)Get_Pwnam(user_name, True); if (!pdb_name_to_rid(user_name, &dom_rids[i], &dummy_g_rid)) { diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 4228eab3e0..de3eaf9bd9 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -126,10 +126,13 @@ static void net_reply_auth_2(NET_Q_AUTH_2 *q_a, prs_struct *rdata, DOM_CHAL *resp_cred, int status) { NET_R_AUTH_2 r_a; + NEG_FLAGS srv_flgs; + + srv_flgs.neg_flags = 0x000001ff; /* set up the LSA AUTH 2 response */ - make_net_r_auth_2(&r_a, resp_cred, &(q_a->clnt_flgs), status); + make_net_r_auth_2(&r_a, resp_cred, &srv_flgs, status); /* store the response in the SMB stream */ net_io_r_auth_2("", &r_a, rdata, 0); -- cgit From 528c3d3e682ce85d8b041a1396e59f5229716e71 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 27 Oct 1998 15:03:47 +0000 Subject: amazing. the improvements to NT continue, evidence for which shows up now as "RPC fault" if the UNIHDR structure lengths do not exactly match up to the length of the data stream. so, all versions of samba prior to this one have an off-by-one bug in unicode string lengths. all versions of NT prior to NT 5 beta 2 could possibly have buffer problems when receiving badly formatted UNICODE strings. (This used to be commit 161eb6f511e161b63c1fa90a08c562fcf208344a) --- source3/rpc_server/srv_samr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 74d06d1bca..034e4dd336 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -418,7 +418,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, got_grps = True; num_entries = 1; - make_unistr2(&(pass[0].uni_user_name), dummy_group, strlen(dummy_group)); + make_unistr2(&(pass[0].uni_user_name), dummy_group, strlen(dummy_group)-1); pass[0].user_rid = DOMAIN_GROUP_RID_ADMINS; if (r_e.status == 0 && got_grps) @@ -481,7 +481,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, char *name; while (num_entries < MAX_SAM_ENTRIES && ((name = builtin_alias_rids[num_entries].name) != NULL)) { - make_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)); + make_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)-1); pass[num_entries].user_rid = builtin_alias_rids[num_entries].rid; num_entries++; } -- cgit From 53abed10e7ce1b1af0c7e099a6aa9744277545c5 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 6 Nov 1998 18:46:42 +0000 Subject: grumble, grumble off-by-one unicode string fixes, gonna stuff my other tree with cvs clashes when i cvs update on the group code grumble grumble (This used to be commit f8b229d187cea2e3820d71697346fc9f0cd8bf88) --- source3/rpc_server/srv_samr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 034e4dd336..323298ef7a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -78,9 +78,9 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, } user_name_len = strlen(pwd->smb_name); - make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len-1); - make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len-1, - user_name_len-1, 1); + make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len); + make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len, + user_name_len, 1); pw_buf[(*num_entries)].user_rid = pwd->user_rid; bzero( pw_buf[(*num_entries)].nt_pwd , 16); @@ -418,7 +418,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, got_grps = True; num_entries = 1; - make_unistr2(&(pass[0].uni_user_name), dummy_group, strlen(dummy_group)-1); + make_unistr2(&(pass[0].uni_user_name), dummy_group, strlen(dummy_group)); pass[0].user_rid = DOMAIN_GROUP_RID_ADMINS; if (r_e.status == 0 && got_grps) @@ -481,7 +481,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, char *name; while (num_entries < MAX_SAM_ENTRIES && ((name = builtin_alias_rids[num_entries].name) != NULL)) { - make_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)-1); + make_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)); pass[num_entries].user_rid = builtin_alias_rids[num_entries].rid; num_entries++; } -- cgit From e4f974c611c179a5e7827ec8325e01811db6540b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Nov 1998 20:33:37 +0000 Subject: Makefile.in: Removed rpc_server/srv_ldap_helpers.c per J.F.'s instructions. client/client.c: client/clitar.c: include/client.h: smbwrapper/smbw_dir.c: smbwrapper/smbw_stat.c: smbwrapper/smbw.c: lib/util.c: Converted all use of 'mode' to uint16. smbd/quotas.c: Fixed stupid comment bug I put in there :-(. printing/printing.c: Fix from J.F. to new code. Jeremy. (This used to be commit bacd3e9d2036a804e73644a28fc498f229c8446c) --- source3/rpc_server/srv_ldap_helpers.c | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 source3/rpc_server/srv_ldap_helpers.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ldap_helpers.c b/source3/rpc_server/srv_ldap_helpers.c deleted file mode 100644 index fb2442789c..0000000000 --- a/source3/rpc_server/srv_ldap_helpers.c +++ /dev/null @@ -1,14 +0,0 @@ -#ifdef USE_LDAP - -#include "includes.h" -#include "lber.h" -#include "ldap.h" - -extern int DEBUGLEVEL; - - -#else /* USE_LDAP */ -/* this keeps fussy compilers happy */ -void ldap_helper_dummy(void) -{} -#endif /* USE_LDAP */ -- cgit From 1e1c2ec93c204e6fd3ebba6dfb11e4fbc136e10c Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 10 Nov 1998 19:05:00 +0000 Subject: rpcclient registry commands. (This used to be commit 36fcb4a6e643a05d06a2a273d74318fee7f2c647) --- source3/rpc_server/srv_lsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 8f22f8f574..5e6e101883 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -189,7 +189,7 @@ static void make_reply_lookup_rids(LSA_R_LOOKUP_RIDS *r_l, for (i = 0; i < num_entries; i++) { - make_dom_rid2(&(r_l->dom_rid[i]), dom_rids[i]); + make_dom_rid2(&(r_l->dom_rid[i]), dom_rids[i], 0x01); } r_l->num_entries3 = num_entries; -- cgit From 07eb9133efc76b141b963fce0e157d7fbbdd939f Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 11 Nov 1998 00:36:15 +0000 Subject: - renamed open_policy to open_hklm. - renamed open_unk_4 to open_hku - fixed createkey issue spotted by phil cox (This used to be commit 7df85b956787f02d022b34ef8cfc13fc967ae89c) --- source3/rpc_server/srv_reg.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index c153a78ee1..33ccae3f93 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -77,10 +77,10 @@ static void api_reg_close( uint16 vuid, prs_struct *data, /******************************************************************* reg_reply_open ********************************************************************/ -static void reg_reply_open(REG_Q_OPEN_POLICY *q_r, +static void reg_reply_open(REG_Q_OPEN_HKLM *q_r, prs_struct *rdata) { - REG_R_OPEN_POLICY r_u; + REG_R_OPEN_HKLM r_u; r_u.status = 0x0; /* get a (unique) handle. open a policy on it. */ @@ -92,7 +92,7 @@ static void reg_reply_open(REG_Q_OPEN_POLICY *q_r, DEBUG(5,("reg_open: %d\n", __LINE__)); /* store the response in the SMB stream */ - reg_io_r_open_policy("", &r_u, rdata, 0); + reg_io_r_open_hklm("", &r_u, rdata, 0); DEBUG(5,("reg_open: %d\n", __LINE__)); } @@ -103,10 +103,10 @@ static void reg_reply_open(REG_Q_OPEN_POLICY *q_r, static void api_reg_open( uint16 vuid, prs_struct *data, prs_struct *rdata ) { - REG_Q_OPEN_POLICY q_u; + REG_Q_OPEN_HKLM q_u; /* grab the reg open */ - reg_io_q_open_policy("", &q_u, data, 0); + reg_io_q_open_hklm("", &q_u, data, 0); /* construct reply. always indicate success */ reg_reply_open(&q_u, rdata); @@ -225,9 +225,9 @@ static struct api_struct api_reg_cmds[] = { { "REG_CLOSE" , REG_CLOSE , api_reg_close }, { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, - { "REG_OPEN" , REG_OPEN_POLICY , api_reg_open }, + { "REG_OPEN" , REG_OPEN_HKLM , api_reg_open }, { "REG_INFO" , REG_INFO , api_reg_info }, - { NULL, 0 , NULL } + { NULL, 0 , NULL } }; /******************************************************************* -- cgit From f49b994aeb987ac87c3c49f35ae1e05a7004f75d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 11 Nov 1998 23:25:51 +0000 Subject: rpc_server/srv_netlog.c: Fixed crash bug with ACB_PWNOTREQ. script/makeyodldocs.sh: Added code to make text docs for non-man page YODL docs. web/cgi.c web/swat.c: SGI compiler warnings fixed. Jeremy. (This used to be commit 80e0f7e1071f032c5004aecb01a91d1397e6a161) --- source3/rpc_server/srv_netlog.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index de3eaf9bd9..f93d09b3ba 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -544,8 +544,7 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, net_login_network: *************************************************************************/ static uint32 net_login_network(NET_ID_INFO_2 *id2, - struct smb_passwd *smb_pass, - user_struct *vuser) + struct smb_passwd *smb_pass) { DEBUG(5,("net_login_network: lm_len: %d nt_len: %d\n", id2->hdr_lm_chal_resp.str_str_len, @@ -674,15 +673,17 @@ static void api_net_sam_logon( uint16 vuid, smb_pass = getsmbpwnam(samlogon_user); unbecome_root(True); - if (smb_pass == NULL) + if (smb_pass->acct_ctrl & ACB_PWNOTREQ) + status = 0; + else if (smb_pass == NULL) status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; else if (smb_pass->acct_ctrl & ACB_DISABLED) status = 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED; } - /* validate password. */ + /* Validate password - if required. */ - if (status == 0) + if ((status == 0) && !(smb_pass->acct_ctrl & ACB_PWNOTREQ)) { switch (q_l.sam_id.logon_level) { @@ -695,7 +696,7 @@ static void api_net_sam_logon( uint16 vuid, case NET_LOGON_TYPE: { /* network login. lm challenge and 24 byte responses */ - status = net_login_network(&q_l.sam_id.ctr->auth.id2, smb_pass, vuser); + status = net_login_network(&q_l.sam_id.ctr->auth.id2, smb_pass); break; } } -- cgit From 10a9addc222b29acdcfe6afed0597dd17551fa5c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 12 Nov 1998 04:17:54 +0000 Subject: Moved some code (NTLMSSPcalc) out of smbdes and inline for paranioa resons and my own piece of mind... Jeremy. (This used to be commit 45131501f23ce1eec2f23fe2c1060cd5a2736ec9) --- source3/rpc_server/srv_util.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 51df42cdff..161f845af3 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -154,6 +154,33 @@ int make_dom_gids(char *gids_str, DOM_GID **ppgids) return count; } +static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) +{ + unsigned char *hash = p->ntlmssp_hash; + unsigned char index_i = hash[256]; + unsigned char index_j = hash[257]; + int ind; + + for( ind = 0; ind < len; ind++) + { + unsigned char tc; + unsigned char t; + + index_i++; + index_j += hash[index_i]; + + tc = hash[index_i]; + hash[index_i] = hash[index_j]; + hash[index_j] = tc; + + t = hash[index_i] + hash[index_j]; + data[ind] = data[ind] ^ hash[t]; + } + + hash[256] = index_i; + hash[257] = index_j; +} + /******************************************************************* turns a DCE/RPC request into a DCE/RPC reply @@ -252,7 +279,7 @@ BOOL create_rpc_reply(pipes_struct *p, if (auth_seal) { crc32 = crc32_calc_buffer(data_len, data); - NTLMSSPcalc(p->ntlmssp_hash, (uchar*)data, data_len); + NTLMSSPcalc_p(p, (uchar*)data, data_len); } if (auth_seal || auth_verify) @@ -268,7 +295,7 @@ BOOL create_rpc_reply(pipes_struct *p, make_rpc_auth_ntlmssp_chk(&p->ntlmssp_chk, NTLMSSP_SIGN_VERSION, crc32, p->ntlmssp_seq_num++); smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(p->ntlmssp_chk), &p->rverf, 0); auth_data = mem_data(&p->rverf.data, 4); - NTLMSSPcalc(p->ntlmssp_hash, (uchar*)auth_data, 12); + NTLMSSPcalc_p(p, (uchar*)auth_data, 12); } } @@ -633,7 +660,7 @@ static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) { char *data = mem_data(&pd->data, pd->offset); DEBUG(5,("api_pipe_auth_process: data %d\n", pd->offset)); - NTLMSSPcalc(p->ntlmssp_hash, (uchar*)data, data_len); + NTLMSSPcalc_p(p, (uchar*)data, data_len); crc32 = crc32_calc_buffer(data_len, data); } @@ -650,7 +677,7 @@ static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) { char *req_data = mem_data(&pd->data, pd->offset + 4); DEBUG(5,("api_pipe_auth_process: auth %d\n", pd->offset + 4)); - NTLMSSPcalc(p->ntlmssp_hash, (uchar*)req_data, 12); + NTLMSSPcalc_p(p, (uchar*)req_data, 12); smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(p->ntlmssp_chk), pd, 0); if (!rpc_auth_ntlmssp_chk(&(p->ntlmssp_chk), crc32, -- cgit From 5b863af4c0179f0bee17e77690d99a54cc762531 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 12 Nov 1998 16:07:00 +0000 Subject: cleaning up conflicts between group code not yet committed and changes from yesterday by me, jeremy and andrew. jeremy, your ACB_PWNOTREQ mod would have caused a crash if the user didn't exist (first check should be for smb_pass != NULL) (This used to be commit cbac0f165d351ba9497c222e55e453d781376e58) --- source3/rpc_server/srv_lookup.c | 710 ++++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_netlog.c | 6 +- source3/rpc_server/srv_pipe.c | 731 ++++++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_sid.c | 484 ++++++++++++++++++++++++++ source3/rpc_server/srv_util.c | 687 ------------------------------------- 5 files changed, 1928 insertions(+), 690 deletions(-) create mode 100644 source3/rpc_server/srv_lookup.c create mode 100644 source3/rpc_server/srv_pipe.c create mode 100644 source3/rpc_server/srv_sid.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c new file mode 100644 index 0000000000..e6df9933bf --- /dev/null +++ b/source3/rpc_server/srv_lookup.c @@ -0,0 +1,710 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1998 + * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, + * Copyright (C) Paul Ashton 1997-1998. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * + * + + this module provides nt user / nt rid lookup functions. + users, local groups, domain groups. + + no unix / samba functions should be called in this module: + it should purely provide a gateway to the password database API, + the local group database API or the domain group database API, + but first checking built-in rids. + + did i say rids? oops, what about "S-1-1" the "Everyone" group + and other such well-known sids... + + speed is not of the essence: no particular optimisation is in place. + + * + * + */ + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + +extern fstring global_sam_name; +extern DOM_SID global_sam_sid; +extern DOM_SID global_sid_S_1_5_20; + +/* + * A list of the rids of well known BUILTIN and Domain users + * and groups. + */ + +rid_name builtin_alias_rids[] = +{ + { BUILTIN_ALIAS_RID_ADMINS , "Administrators" }, + { BUILTIN_ALIAS_RID_USERS , "Users" }, + { BUILTIN_ALIAS_RID_GUESTS , "Guests" }, + { BUILTIN_ALIAS_RID_POWER_USERS , "Power Users" }, + + { BUILTIN_ALIAS_RID_ACCOUNT_OPS , "Account Operators" }, + { BUILTIN_ALIAS_RID_SYSTEM_OPS , "System Operators" }, + { BUILTIN_ALIAS_RID_PRINT_OPS , "Print Operators" }, + { BUILTIN_ALIAS_RID_BACKUP_OPS , "Backup Operators" }, + { BUILTIN_ALIAS_RID_REPLICATOR , "Replicator" }, + { 0 , NULL } +}; + +/* array lookup of well-known Domain RID users. */ +rid_name domain_user_rids[] = +{ + { DOMAIN_USER_RID_ADMIN , "Administrator" }, + { DOMAIN_USER_RID_GUEST , "Guest" }, + { 0 , NULL } +}; + +/* array lookup of well-known Domain RID groups. */ +rid_name domain_group_rids[] = +{ + { DOMAIN_GROUP_RID_ADMINS , "Domain Admins" }, + { DOMAIN_GROUP_RID_USERS , "Domain Users" }, + { DOMAIN_GROUP_RID_GUESTS , "Domain Guests" }, + { 0 , NULL } +}; + + +int make_dom_gids(DOMAIN_GRP *mem, int num_members, DOM_GID **ppgids) +{ + int count; + int i; + DOM_GID *gids = NULL; + + *ppgids = NULL; + + DEBUG(4,("make_dom_gids: %d\n", num_members)); + + if (mem == NULL || num_members == 0) + { + return 0; + } + + for (i = 0, count = 0; i < num_members && count < LSA_MAX_GROUPS; i++) + { + uint32 status; + + uint32 rid; + uint8 type; + + uint8 attr = mem[count].attr; + char *name = mem[count].name; + + become_root(True); + status = lookup_grp_rid(name, &rid, &type); + unbecome_root(True); + + if (status == 0x0) + { + gids = (DOM_GID *)Realloc( gids, sizeof(DOM_GID) * (count+1) ); + + if (gids == NULL) + { + DEBUG(0,("make_dom_gids: Realloc fail !\n")); + return 0; + } + + gids[count].g_rid = rid; + gids[count].attr = attr; + + DEBUG(5,("group name: %s rid: %d attr: %d\n", + name, rid, attr)); + count++; + } + else + { + DEBUG(1,("make_dom_gids: unknown group name %s\n", name)); + } + } + + *ppgids = gids; + return count; +} + +/******************************************************************* + gets a domain user's groups + ********************************************************************/ +int get_domain_user_groups(DOMAIN_GRP_MEMBER **grp_members, uint32 group_rid) +{ + DOMAIN_GRP *grp; + int num_mem; + + if (grp_members == NULL) return 0; + + grp = getgrouprid(group_rid, grp_members, &num_mem); + + if (grp == NULL) + { + return 0; + } + + return num_mem; +} + + +/******************************************************************* + lookup_builtin_names + ********************************************************************/ +uint32 lookup_builtin_names(uint32 rid, char *name, uint8 *type) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + + status = (status != 0x0) ? lookup_wk_user_name (rid, name, type) : status; + status = (status != 0x0) ? lookup_wk_group_name(rid, name, type) : status; + status = (status != 0x0) ? lookup_wk_alias_name(rid, name, type) : status; + + return status; +} + + +/******************************************************************* + lookup_added_name - names that have been added to the SAM database by admins. + ********************************************************************/ +uint32 lookup_added_name(uint32 rid, char *name, uint8 *type) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + + status = (status != 0x0) ? lookup_user_name (rid, name, type) : status; + status = (status != 0x0) ? lookup_group_name(rid, name, type) : status; + status = (status != 0x0) ? lookup_alias_name(rid, name, type) : status; + + return status; +} + + +/******************************************************************* + lookup_name + ********************************************************************/ +uint32 lookup_name(uint32 rid, char *name, uint8 *type) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + + status = (status != 0x0) ? lookup_builtin_names(rid, name, type) : status; + status = (status != 0x0) ? lookup_added_name (rid, name, type) : status; + + return status; +} + + +/******************************************************************* + lookup_wk_group_name + ********************************************************************/ +uint32 lookup_wk_group_name(uint32 rid, char *group_name, uint8 *type) +{ + int i = 0; + (*type) = SID_NAME_WKN_GRP; + + DEBUG(5,("lookup_wk_group_name: rid: %d", rid)); + + while (domain_group_rids[i].rid != rid && domain_group_rids[i].rid != 0) + { + i++; + } + + if (domain_group_rids[i].rid != 0) + { + fstrcpy(group_name, domain_group_rids[i].name); + DEBUG(5,(" = %s\n", group_name)); + return 0x0; + } + + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_group_name + ********************************************************************/ +uint32 lookup_group_name(uint32 rid, char *group_name, uint8 *type) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + DOM_SID sid; + + DEBUG(5,("lookup_group_name: rid: 0x%x", rid)); + + sid_copy (&sid, &global_sam_sid); + sid_append_rid(&sid, rid); + + (*type) = SID_NAME_DOM_GRP; + + if (map_group_sid_to_name(&sid, group_name, NULL)) + { + status = 0x0; + } + + if (status == 0x0) + { + DEBUG(5,(" = %s\n", group_name)); + } + else + { + DEBUG(5,(" none mapped\n")); + } + + return status; +} + +/******************************************************************* + lookup_wk_alias_name + ********************************************************************/ +uint32 lookup_wk_alias_name(uint32 rid, char *alias_name, uint8 *type) +{ + int i = 0; + (*type) = SID_NAME_ALIAS; + + DEBUG(5,("lookup_wk_alias_name: rid: %d", rid)); + + while (builtin_alias_rids[i].rid != rid && builtin_alias_rids[i].rid != 0) + { + i++; + } + + if (builtin_alias_rids[i].rid != 0) + { + fstrcpy(alias_name, builtin_alias_rids[i].name); + DEBUG(5,(" = %s\n", alias_name)); + return 0x0; + } + + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_alias_name + ********************************************************************/ +uint32 lookup_alias_name(uint32 rid, char *alias_name, uint8 *type) +{ + (*type) = SID_NAME_ALIAS; + + DEBUG(2,("lookup_alias_name: rid: %d\n", rid)); + DEBUG(2,(" NOT IMPLEMENTED\n")); + + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup well-known user name + ********************************************************************/ +uint32 lookup_wk_user_name(uint32 rid, char *user_name, uint8 *type) +{ + int i = 0; + (*type) = SID_NAME_USER; + + DEBUG(5,("lookup_wk_user_name: rid: %d", rid)); + + /* look up the well-known domain user rids first */ + while (domain_user_rids[i].rid != rid && domain_user_rids[i].rid != 0) + { + i++; + } + + if (domain_user_rids[i].rid != 0) + { + fstrcpy(user_name, domain_user_rids[i].name); + DEBUG(5,(" = %s\n", user_name)); + return 0x0; + } + + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup user name + ********************************************************************/ +uint32 lookup_user_name(uint32 rid, char *user_name, uint8 *type) +{ + struct sam_disp_info *disp_info; + (*type) = SID_NAME_USER; + + DEBUG(5,("lookup_user_name: rid: %d", rid)); + + /* find the user account */ + become_root(True); + disp_info = getsamdisprid(rid); + unbecome_root(True); + + if (disp_info != NULL) + { + fstrcpy(user_name, disp_info->smb_name); + DEBUG(5,(" = %s\n", user_name)); + return 0x0; + } + + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_group_rid + ********************************************************************/ +uint32 lookup_group_rid(char *group_name, uint32 *rid, uint8 *type) +{ + DOM_SID sid; + + (*rid) = 0; + (*type) = SID_NAME_DOM_GRP; + + DEBUG(5,("lookup_group_rid: name: %s", group_name)); + + if (map_group_name_to_sid(group_name, &sid) && + sid_split_rid(&sid, rid) && + sid_equal(&sid, &global_sam_sid)) + { + DEBUG(5,(" = 0x%x\n", (*rid))); + return 0x0; + } + + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_wk_group_rid + ********************************************************************/ +uint32 lookup_wk_group_rid(char *group_name, uint32 *rid, uint8 *type) +{ + char *grp_name; + int i = -1; /* start do loop at -1 */ + (*rid) = 0; + (*type) = SID_NAME_WKN_GRP; + + do /* find, if it exists, a group rid for the group name */ + { + i++; + (*rid) = domain_group_rids[i].rid; + grp_name = domain_group_rids[i].name; + + } while (grp_name != NULL && !strequal(grp_name, group_name)); + + return (grp_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_alias_sid + ********************************************************************/ +uint32 lookup_alias_sid(char *alias_name, DOM_SID *sid, uint8 *type) +{ + (*type) = SID_NAME_ALIAS; + + DEBUG(5,("lookup_alias_rid: name: %s", alias_name)); + + if (map_alias_name_to_sid(alias_name, sid)) + { + fstring sid_str; + sid_to_string(sid_str, sid); + DEBUG(5,(" = %s\n", sid_str)); + return 0x0; + } + + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_alias_rid + ********************************************************************/ +uint32 lookup_alias_rid(char *alias_name, uint32 *rid, uint8 *type) +{ + DOM_SID sid; + + (*rid) = 0; + (*type) = SID_NAME_ALIAS; + + DEBUG(5,("lookup_alias_rid: name: %s", alias_name)); + + if (map_alias_name_to_sid(alias_name, &sid) && + sid_split_rid(&sid, rid) && + sid_equal(&sid, &global_sam_sid)) + { + DEBUG(5,(" = 0x%x\n", (*rid))); + return 0x0; + } + + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_wk_alias_sid + ********************************************************************/ +uint32 lookup_wk_alias_sid(char *alias_name, DOM_SID *sid, uint8 *type) +{ + char *als_name; + int i = 0; + uint32 rid; + (*type) = SID_NAME_ALIAS; + + do /* find, if it exists, a alias rid for the alias name*/ + { + rid = builtin_alias_rids[i].rid; + als_name = builtin_alias_rids[i].name; + + i++; + + if (strequal(als_name, alias_name)) + { + sid_copy(sid, &global_sid_S_1_5_20); + sid_append_rid(sid, rid); + + return 0x0; + } + + } while (als_name != NULL); + + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_wk_alias_rid + ********************************************************************/ +uint32 lookup_wk_alias_rid(char *alias_name, uint32 *rid, uint8 *type) +{ + char *als_name; + int i = -1; /* start do loop at -1 */ + (*rid) = 0; + (*type) = SID_NAME_ALIAS; + + do /* find, if it exists, a alias rid for the alias name*/ + { + i++; + (*rid) = builtin_alias_rids[i].rid; + als_name = builtin_alias_rids[i].name; + + } while (als_name != NULL && !strequal(als_name, alias_name)); + + return (als_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_sid + ********************************************************************/ +uint32 lookup_sid(char *name, DOM_SID *sid, uint8 *type) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + fstring domain; + fstring user; + + split_domain_name(name, domain, user); + + if (!strequal(domain, global_sam_name)) + { + DEBUG(0,("lookup_sid: remote domain %s not supported\n", domain)); + return status; + } + + status = (status != 0x0) ? lookup_wk_alias_sid(user, sid, type) : status; + status = (status != 0x0) ? lookup_alias_sid (user, sid, type) : status; +#if 0 + status = (status != 0x0) ? lookup_domain_sid (user, sid, type) : status; +#endif + + return status; +} + +/******************************************************************* + lookup_added_user_rid + ********************************************************************/ +uint32 lookup_added_user_rids(char *user_name, + uint32 *usr_rid, uint32 *grp_rid) +{ + struct sam_passwd *sam_pass; + (*usr_rid) = 0; + (*grp_rid) = 0; + + /* find the user account */ + become_root(True); + sam_pass = getsam21pwnam(user_name); + unbecome_root(True); + + if (sam_pass != NULL) + { + (*usr_rid) = sam_pass->user_rid ; + (*grp_rid) = sam_pass->group_rid; + return 0x0; + } + + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_added_user_rid + ********************************************************************/ +uint32 lookup_added_user_rid(char *user_name, uint32 *rid, uint8 *type) +{ + struct sam_passwd *sam_pass; + (*rid) = 0; + (*type) = SID_NAME_USER; + + /* find the user account */ + become_root(True); + sam_pass = getsam21pwnam(user_name); + unbecome_root(True); + + if (sam_pass != NULL) + { + (*rid) = sam_pass->user_rid; + return 0x0; + } + + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_wk_user_rid + ********************************************************************/ +uint32 lookup_wk_user_rid(char *user_name, uint32 *rid, uint8 *type) +{ + char *usr_name; + int i = -1; /* start do loop at -1 */ + (*rid) = 0; + (*type) = SID_NAME_USER; + + do /* find, if it exists, a alias rid for the alias name*/ + { + i++; + (*rid) = domain_user_rids[i].rid; + usr_name = domain_user_rids[i].name; + + } while (usr_name != NULL && !strequal(usr_name, user_name)); + + return (usr_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_added_grp_rid + ********************************************************************/ +uint32 lookup_added_grp_rid(char *name, uint32 *rid, uint8 *type) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + + status = (status != 0x0) ? lookup_group_rid(name, rid, type) : status; + status = (status != 0x0) ? lookup_alias_rid(name, rid, type) : status; + + return status; +} + +/******************************************************************* + lookup_builtin_grp_rid + ********************************************************************/ +uint32 lookup_builtin_grp_rid(char *name, uint32 *rid, uint8 *type) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + + status = (status != 0x0) ? lookup_wk_group_rid(name, rid, type) : status; + status = (status != 0x0) ? lookup_wk_alias_rid(name, rid, type) : status; + + return status; +} + +/******************************************************************* + lookup_grp_rid + ********************************************************************/ +uint32 lookup_grp_rid(char *name, uint32 *rid, uint8 *type) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + + status = (status != 0x0) ? lookup_builtin_grp_rid(name, rid, type) : status; + status = (status != 0x0) ? lookup_added_grp_rid (name, rid, type) : status; + + return status; +} + +/******************************************************************* + lookup_user_rid + ********************************************************************/ +uint32 lookup_user_rid(char *name, uint32 *rid, uint8 *type) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + + status = (status != 0x0) ? lookup_wk_user_rid (name, rid, type) : status; + status = (status != 0x0) ? lookup_added_user_rid(name, rid, type) : status; + + return status; +} + +/******************************************************************* + lookup_rid + ********************************************************************/ +uint32 lookup_rid(char *name, uint32 *rid, uint8 *type) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + + status = (status != 0x0) ? lookup_user_rid(name, rid, type) : status; + status = (status != 0x0) ? lookup_grp_rid (name, rid, type) : status; + + return status; +} + +/******************************************************************* + lookup_user_rids + ********************************************************************/ +uint32 lookup_user_rids(char *name, uint32 *usr_rid, uint32 *grp_rid) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + uint8 type; + + /* + * try an ordinary user lookup + */ + + status = lookup_added_user_rids(name, usr_rid, grp_rid); + if (status == 0) + { + return status; + } + + /* + * hm. must be a well-known user, in a well-known group. + */ + + status = lookup_wk_user_rid(name, usr_rid, &type); + if (status != 0 || type != SID_NAME_USER) + { + return status; /* ok, maybe not! */ + } + if (type != SID_NAME_USER) + { + return 0xC0000000 | NT_STATUS_NONE_MAPPED; /* users only... */ + } + + /* + * ok, got the user rid: now try the group rid + */ + + status = lookup_builtin_grp_rid(name, grp_rid, &type); + if (type == SID_NAME_DOM_GRP || + type == SID_NAME_ALIAS || + type == SID_NAME_WKN_GRP) + { + status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + } + + return status; +} diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index f93d09b3ba..04118800e2 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -673,10 +673,10 @@ static void api_net_sam_logon( uint16 vuid, smb_pass = getsmbpwnam(samlogon_user); unbecome_root(True); - if (smb_pass->acct_ctrl & ACB_PWNOTREQ) - status = 0; - else if (smb_pass == NULL) + if (smb_pass == NULL) status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + else if (smb_pass->acct_ctrl & ACB_PWNOTREQ) + status = 0; else if (smb_pass->acct_ctrl & ACB_DISABLED) status = 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c new file mode 100644 index 0000000000..94a7ebc838 --- /dev/null +++ b/source3/rpc_server/srv_pipe.c @@ -0,0 +1,731 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1998 + * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, + * Copyright (C) Paul Ashton 1997-1998. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* this module apparently provides an implementation of DCE/RPC over a + * named pipe (IPC$ connection using SMBtrans). details of DCE/RPC + * documentation are available (in on-line form) from the X-Open group. + * + * this module should provide a level of abstraction between SMB + * and DCE/RPC, while minimising the amount of mallocs, unnecessary + * data copies, and network traffic. + * + * in this version, which takes a "let's learn what's going on and + * get something running" approach, there is additional network + * traffic generated, but the code should be easier to understand... + * + * ... if you read the docs. or stare at packets for weeks on end. + * + */ + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + +static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) +{ + unsigned char *hash = p->ntlmssp_hash; + unsigned char index_i = hash[256]; + unsigned char index_j = hash[257]; + int ind; + + for( ind = 0; ind < len; ind++) + { + unsigned char tc; + unsigned char t; + + index_i++; + index_j += hash[index_i]; + + tc = hash[index_i]; + hash[index_i] = hash[index_j]; + hash[index_j] = tc; + + t = hash[index_i] + hash[index_j]; + data[ind] = data[ind] ^ hash[t]; + } + + hash[256] = index_i; + hash[257] = index_j; +} + +/******************************************************************* + turns a DCE/RPC request into a DCE/RPC reply + + this is where the data really should be split up into an array of + headers and data sections. + + ********************************************************************/ +BOOL create_rpc_reply(pipes_struct *p, + uint32 data_start, uint32 data_end) +{ + char *data; + BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SIGN); + BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SEAL); + uint32 data_len; + uint32 auth_len; + + DEBUG(5,("create_rpc_reply: data_start: %d data_end: %d max_tsize: %d\n", + data_start, data_end, p->hdr_ba.bba.max_tsize)); + + auth_len = p->hdr.auth_len; + + if (p->ntlmssp_auth) + { + DEBUG(10,("create_rpc_reply: auth\n")); + if (auth_len != 16) + { + return False; + } + } + + prs_init(&p->rhdr , 0x18, 4, 0, False); + prs_init(&p->rauth, 1024, 4, 0, False); + prs_init(&p->rverf, 0x08, 4, 0, False); + + p->hdr.pkt_type = RPC_RESPONSE; /* mark header as an rpc response */ + + /* set up rpc header (fragmentation issues) */ + if (data_start == 0) + { + p->hdr.flags = RPC_FLG_FIRST; + } + else + { + p->hdr.flags = 0; + } + + p->hdr_resp.alloc_hint = data_end - data_start; /* calculate remaining data to be sent */ + + if (p->hdr_resp.alloc_hint + 0x18 <= p->hdr_ba.bba.max_tsize) + { + p->hdr.flags |= RPC_FLG_LAST; + p->hdr.frag_len = p->hdr_resp.alloc_hint + 0x18; + } + else + { + p->hdr.frag_len = p->hdr_ba.bba.max_tsize; + } + + if (p->ntlmssp_auth) + { + p->hdr_resp.alloc_hint -= auth_len + 8; + } + + if (p->ntlmssp_auth) + { + data_len = p->hdr.frag_len - auth_len - (auth_verify ? 8 : 0) - 0x18; + } + else + { + data_len = p->hdr.frag_len - 0x18; + } + + p->rhdr.data->offset.start = 0; + p->rhdr.data->offset.end = 0x18; + + /* store the header in the data stream */ + smb_io_rpc_hdr ("hdr" , &(p->hdr ), &(p->rhdr), 0); + smb_io_rpc_hdr_resp("resp", &(p->hdr_resp), &(p->rhdr), 0); + + /* don't use rdata: use rdata_i instead, which moves... */ + /* make a pointer to the rdata data, NOT A COPY */ + + p->rdata_i.data = NULL; + prs_init(&p->rdata_i, 0, p->rdata.align, p->rdata.data->margin, p->rdata.io); + data = mem_data(&(p->rdata.data), data_start); + mem_create(p->rdata_i.data, data, 0, data_len, 0, False); + p->rdata_i.offset = data_len; + + if (auth_len > 0) + { + uint32 crc32; + + DEBUG(5,("create_rpc_reply: sign: %s seal: %s data %d auth %d\n", + BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); + + if (auth_seal) + { + crc32 = crc32_calc_buffer(data_len, data); + NTLMSSPcalc_p(p, (uchar*)data, data_len); + } + + if (auth_seal || auth_verify) + { + make_rpc_hdr_auth(&p->auth_info, 0x0a, 0x06, 0x08, (auth_verify ? 1 : 0)); + smb_io_rpc_hdr_auth("hdr_auth", &p->auth_info, &p->rauth, 0); + } + + if (auth_verify) + { + char *auth_data; + p->ntlmssp_seq_num++; + make_rpc_auth_ntlmssp_chk(&p->ntlmssp_chk, NTLMSSP_SIGN_VERSION, crc32, p->ntlmssp_seq_num++); + smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(p->ntlmssp_chk), &p->rverf, 0); + auth_data = mem_data(&p->rverf.data, 4); + NTLMSSPcalc_p(p, (uchar*)auth_data, 12); + } + } + + /* set up the data chain */ + if (p->ntlmssp_auth) + { + prs_link(NULL , &p->rhdr , &p->rdata_i); + prs_link(&p->rhdr , &p->rdata_i, &p->rauth ); + prs_link(&p->rdata_i, &p->rauth , &p->rverf ); + prs_link(&p->rauth , &p->rverf , NULL ); + } + else + { + prs_link(NULL , &p->rhdr , &p->rdata_i); + prs_link(&p->rhdr, &p->rdata_i, NULL ); + } + + /* indicate to subsequent data reads where we are up to */ + p->frag_len_left = p->hdr.frag_len - p->file_offset; + p->next_frag_start = p->hdr.frag_len; + + return p->rhdr.data != NULL && p->rhdr.offset == 0x18; +} + +static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) +{ + uchar lm_owf[24]; + uchar nt_owf[24]; + struct smb_passwd *smb_pass = NULL; + + DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); + + if (p->ntlmssp_resp.hdr_lm_resp.str_str_len == 0) return False; + if (p->ntlmssp_resp.hdr_nt_resp.str_str_len == 0) return False; + if (p->ntlmssp_resp.hdr_usr .str_str_len == 0) return False; + if (p->ntlmssp_resp.hdr_domain .str_str_len == 0) return False; + if (p->ntlmssp_resp.hdr_wks .str_str_len == 0) return False; + + memset(p->user_name, 0, sizeof(p->user_name)); + memset(p->domain , 0, sizeof(p->domain )); + memset(p->wks , 0, sizeof(p->wks )); + + if (IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_UNICODE)) + { + fstrcpy(p->user_name, unistrn2((uint16*)p->ntlmssp_resp.user , p->ntlmssp_resp.hdr_usr .str_str_len/2)); + fstrcpy(p->domain , unistrn2((uint16*)p->ntlmssp_resp.domain, p->ntlmssp_resp.hdr_domain.str_str_len/2)); + fstrcpy(p->wks , unistrn2((uint16*)p->ntlmssp_resp.wks , p->ntlmssp_resp.hdr_wks .str_str_len/2)); + } + else + { + fstrcpy(p->user_name, p->ntlmssp_resp.user ); + fstrcpy(p->domain , p->ntlmssp_resp.domain); + fstrcpy(p->wks , p->ntlmssp_resp.wks ); + } + + DEBUG(5,("user: %s domain: %s wks: %s\n", p->user_name, p->domain, p->wks)); + + memcpy(lm_owf, p->ntlmssp_resp.lm_resp, sizeof(lm_owf)); + memcpy(nt_owf, p->ntlmssp_resp.nt_resp, sizeof(nt_owf)); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("lm, nt owfs, chal\n")); + dump_data(100, lm_owf, sizeof(lm_owf)); + dump_data(100, nt_owf, sizeof(nt_owf)); + dump_data(100, p->ntlmssp_chal.challenge, 8); +#endif + become_root(True); + p->ntlmssp_validated = pass_check_smb(p->user_name, p->domain, + (uchar*)p->ntlmssp_chal.challenge, + lm_owf, nt_owf, NULL); + smb_pass = getsmbpwnam(p->user_name); + unbecome_root(True); + + if (p->ntlmssp_validated && smb_pass != NULL && smb_pass->smb_passwd) + { + uchar p24[24]; + NTLMSSPOWFencrypt(smb_pass->smb_passwd, lm_owf, p24); + { + unsigned char j = 0; + int ind; + + unsigned char k2[8]; + + memcpy(k2, p24, 5); + k2[5] = 0xe5; + k2[6] = 0x38; + k2[7] = 0xb0; + + for (ind = 0; ind < 256; ind++) + { + p->ntlmssp_hash[ind] = (unsigned char)ind; + } + + for( ind = 0; ind < 256; ind++) + { + unsigned char tc; + + j += (p->ntlmssp_hash[ind] + k2[ind%8]); + + tc = p->ntlmssp_hash[ind]; + p->ntlmssp_hash[ind] = p->ntlmssp_hash[j]; + p->ntlmssp_hash[j] = tc; + } + + p->ntlmssp_hash[256] = 0; + p->ntlmssp_hash[257] = 0; + } +/* NTLMSSPhash(p->ntlmssp_hash, p24); */ + p->ntlmssp_seq_num = 0; + } + else + { + p->ntlmssp_validated = False; + } + + return p->ntlmssp_validated; +} + +static BOOL api_pipe_ntlmssp(pipes_struct *p, prs_struct *pd) +{ + /* receive a negotiate; send a challenge; receive a response */ + switch (p->auth_verifier.msg_type) + { + case NTLMSSP_NEGOTIATE: + { + smb_io_rpc_auth_ntlmssp_neg("", &p->ntlmssp_neg, pd, 0); + break; + } + case NTLMSSP_AUTH: + { + smb_io_rpc_auth_ntlmssp_resp("", &p->ntlmssp_resp, pd, 0); + if (!api_pipe_ntlmssp_verify(p)) + { + pd->offset = 0; + } + break; + } + default: + { + /* NTLMSSP expected: unexpected message type */ + DEBUG(3,("unexpected message type in NTLMSSP %d\n", + p->auth_verifier.msg_type)); + return False; + } + } + + return (pd->offset != 0); +} + +struct api_cmd +{ + char * pipe_clnt_name; + char * pipe_srv_name; + BOOL (*fn) (pipes_struct *, prs_struct *); +}; + +static struct api_cmd api_fd_commands[] = +{ + { "lsarpc", "lsass", api_ntlsa_rpc }, + { "samr", "lsass", api_samr_rpc }, + { "srvsvc", "ntsvcs", api_srvsvc_rpc }, + { "wkssvc", "ntsvcs", api_wkssvc_rpc }, + { "NETLOGON", "lsass", api_netlog_rpc }, + { "winreg", "winreg", api_reg_rpc }, + { NULL, NULL, NULL } +}; + +static BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *pd) +{ + DEBUG(5,("api_pipe_bind_auth_resp: decode request. %d\n", __LINE__)); + + if (p->hdr.auth_len == 0) return False; + + /* decode the authentication verifier response */ + smb_io_rpc_hdr_autha("", &p->autha_info, pd, 0); + if (pd->offset == 0) return False; + + if (!rpc_hdr_auth_chk(&(p->auth_info))) return False; + + smb_io_rpc_auth_verifier("", &p->auth_verifier, pd, 0); + if (pd->offset == 0) return False; + + if (!rpc_auth_verifier_chk(&(p->auth_verifier), "NTLMSSP", NTLMSSP_AUTH)) return False; + + return api_pipe_ntlmssp(p, pd); +} + +static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) +{ + uint16 assoc_gid; + fstring ack_pipe_name; + int i = 0; + + p->ntlmssp_auth = False; + + DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); + + for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) + { + if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && + api_fd_commands[i].fn != NULL) + { + DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", + api_fd_commands[i].pipe_clnt_name, + api_fd_commands[i].pipe_srv_name)); + fstrcpy(p->pipe_srv_name, api_fd_commands[i].pipe_srv_name); + break; + } + } + + if (api_fd_commands[i].fn == NULL) return False; + + /* decode the bind request */ + smb_io_rpc_hdr_rb("", &p->hdr_rb, pd, 0); + + if (pd->offset == 0) return False; + + if (p->hdr.auth_len != 0) + { + /* decode the authentication verifier */ + smb_io_rpc_hdr_auth ("", &p->auth_info , pd, 0); + if (pd->offset == 0) return False; + + p->ntlmssp_auth = p->auth_info.auth_type = 0x0a; + + if (p->ntlmssp_auth) + { + smb_io_rpc_auth_verifier("", &p->auth_verifier, pd, 0); + if (pd->offset == 0) return False; + + p->ntlmssp_auth = strequal(p->auth_verifier.signature, "NTLMSSP"); + } + + if (p->ntlmssp_auth) + { + if (!api_pipe_ntlmssp(p, pd)) return False; + } + } + + /* name has to be \PIPE\xxxxx */ + fstrcpy(ack_pipe_name, "\\PIPE\\"); + fstrcat(ack_pipe_name, p->pipe_srv_name); + + DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); + + prs_init(&(p->rdata), 1024, 4, 0, False); + prs_init(&(p->rhdr ), 0x18, 4, 0, False); + prs_init(&(p->rauth), 1024, 4, 0, False); + prs_init(&(p->rverf), 0x08, 4, 0, False); + prs_init(&(p->rntlm), 1024, 4, 0, False); + + /***/ + /*** do the bind ack first ***/ + /***/ + + if (p->ntlmssp_auth) + { + assoc_gid = 0x7a77; + } + else + { + assoc_gid = p->hdr_rb.bba.assoc_gid; + } + + make_rpc_hdr_ba(&p->hdr_ba, + p->hdr_rb.bba.max_tsize, + p->hdr_rb.bba.max_rsize, + assoc_gid, + ack_pipe_name, + 0x1, 0x0, 0x0, + &(p->hdr_rb.transfer)); + + smb_io_rpc_hdr_ba("", &p->hdr_ba, &p->rdata, 0); + mem_realloc_data(p->rdata.data, p->rdata.offset); + + /***/ + /*** now the authentication ***/ + /***/ + + if (p->ntlmssp_auth) + { + uint8 challenge[8]; + generate_random_buffer(challenge, 8, False); + + /*** authentication info ***/ + + make_rpc_hdr_auth(&p->auth_info, 0x0a, 0x06, 0, 1); + smb_io_rpc_hdr_auth("", &p->auth_info, &p->rverf, 0); + mem_realloc_data(p->rverf.data, p->rverf.offset); + + /*** NTLMSSP verifier ***/ + + make_rpc_auth_verifier(&p->auth_verifier, + "NTLMSSP", NTLMSSP_CHALLENGE); + smb_io_rpc_auth_verifier("", &p->auth_verifier, &p->rauth, 0); + mem_realloc_data(p->rauth.data, p->rauth.offset); + + /* NTLMSSP challenge ***/ + + make_rpc_auth_ntlmssp_chal(&p->ntlmssp_chal, + 0x000082b1, challenge); + smb_io_rpc_auth_ntlmssp_chal("", &p->ntlmssp_chal, &p->rntlm, 0); + mem_realloc_data(p->rntlm.data, p->rntlm.offset); + } + + /***/ + /*** then do the header, now we know the length ***/ + /***/ + + make_rpc_hdr(&p->hdr, RPC_BINDACK, RPC_FLG_FIRST | RPC_FLG_LAST, + p->hdr.call_id, + p->rdata.offset + p->rverf.offset + p->rauth.offset + p->rntlm.offset + 0x10, + p->rauth.offset + p->rntlm.offset); + + smb_io_rpc_hdr("", &p->hdr, &p->rhdr, 0); + mem_realloc_data(p->rhdr.data, p->rdata.offset); + + /***/ + /*** link rpc header, bind acknowledgment and authentication responses ***/ + /***/ + + if (p->ntlmssp_auth) + { + prs_link(NULL , &p->rhdr , &p->rdata); + prs_link(&p->rhdr , &p->rdata, &p->rverf); + prs_link(&p->rdata, &p->rverf, &p->rauth); + prs_link(&p->rverf, &p->rauth, &p->rntlm); + prs_link(&p->rauth, &p->rntlm, NULL ); + } + else + { + prs_link(NULL , &p->rhdr , &p->rdata); + prs_link(&p->rhdr, &p->rdata, NULL ); + } + + return True; +} + + +static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) +{ + BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SIGN); + BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SEAL); + int data_len; + int auth_len; + uint32 old_offset; + uint32 crc32; + + auth_len = p->hdr.auth_len; + + if (auth_len != 16 && auth_verify) + { + return False; + } + + data_len = p->hdr.frag_len - auth_len - (auth_verify ? 8 : 0) - 0x18; + + DEBUG(5,("api_pipe_auth_process: sign: %s seal: %s data %d auth %d\n", + BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); + + if (auth_seal) + { + char *data = mem_data(&pd->data, pd->offset); + DEBUG(5,("api_pipe_auth_process: data %d\n", pd->offset)); + NTLMSSPcalc_p(p, (uchar*)data, data_len); + crc32 = crc32_calc_buffer(data_len, data); + } + + /*** skip the data, record the offset so we can restore it again */ + old_offset = pd->offset; + + if (auth_seal || auth_verify) + { + pd->offset += data_len; + smb_io_rpc_hdr_auth("hdr_auth", &p->auth_info, pd, 0); + } + + if (auth_verify) + { + char *req_data = mem_data(&pd->data, pd->offset + 4); + DEBUG(5,("api_pipe_auth_process: auth %d\n", pd->offset + 4)); + NTLMSSPcalc_p(p, (uchar*)req_data, 12); + smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(p->ntlmssp_chk), pd, 0); + + if (!rpc_auth_ntlmssp_chk(&(p->ntlmssp_chk), crc32, + p->ntlmssp_seq_num)) + { + return False; + } + } + + pd->offset = old_offset; + + return True; +} + +static BOOL api_pipe_request(pipes_struct *p, prs_struct *pd) +{ + int i = 0; + + if (p->ntlmssp_auth && p->ntlmssp_validated) + { + if (!api_pipe_auth_process(p, pd)) return False; + + DEBUG(0,("api_pipe_request: **** MUST CALL become_user() HERE **** \n")); +#if 0 + become_user(); +#endif + } + + for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) + { + if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && + api_fd_commands[i].fn != NULL) + { + DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i].pipe_clnt_name)); + return api_fd_commands[i].fn(p, pd); + } + } + return False; +} + +BOOL rpc_command(pipes_struct *p, prs_struct *pd) +{ + BOOL reply = False; + if (pd->data == NULL) return False; + + /* process the rpc header */ + smb_io_rpc_hdr("", &p->hdr, pd, 0); + + if (pd->offset == 0) return False; + + switch (p->hdr.pkt_type) + { + case RPC_BIND : + { + reply = api_pipe_bind_req(p, pd); + break; + } + case RPC_REQUEST: + { + if (p->ntlmssp_auth && !p->ntlmssp_validated) + { + /* authentication _was_ requested + and it failed. sorry, no deal! + */ + reply = False; + } + else + { + /* read the rpc header */ + smb_io_rpc_hdr_req("req", &(p->hdr_req), pd, 0); + reply = api_pipe_request(p, pd); + } + break; + } + case RPC_BINDRESP: /* not the real name! */ + { + reply = api_pipe_bind_auth_resp(p, pd); + p->ntlmssp_auth = reply; + break; + } + } + + if (!reply) + { + DEBUG(3,("rpc_command: DCE/RPC fault should be sent here\n")); + } + + return reply; +} + + +/******************************************************************* + receives a netlogon pipe and responds. + ********************************************************************/ +static BOOL api_rpc_command(pipes_struct *p, + char *rpc_name, struct api_struct *api_rpc_cmds, + prs_struct *data) +{ + int fn_num; + DEBUG(4,("api_rpc_command: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); + + for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) + { + if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) + { + DEBUG(3,("api_rpc_command: %s\n", api_rpc_cmds[fn_num].name)); + break; + } + } + + if (api_rpc_cmds[fn_num].name == NULL) + { + DEBUG(4, ("unknown\n")); + return False; + } + + /* start off with 1024 bytes, and a large safety margin too */ + prs_init(&p->rdata, 1024, 4, SAFETY_MARGIN, False); + + /* do the actual command */ + api_rpc_cmds[fn_num].fn(p->vuid, data, &(p->rdata)); + + if (p->rdata.data == NULL || p->rdata.offset == 0) + { + mem_free_data(p->rdata.data); + return False; + } + + mem_realloc_data(p->rdata.data, p->rdata.offset); + + DEBUG(10,("called %s\n", rpc_name)); + + return True; +} + + +/******************************************************************* + receives a netlogon pipe and responds. + ********************************************************************/ +BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds, + prs_struct *data) +{ + if (data == NULL || data->data == NULL) + { + DEBUG(2,("%s: NULL data received\n", rpc_name)); + return False; + } + + /* interpret the command */ + if (!api_rpc_command(p, rpc_name, api_rpc_cmds, data)) + { + return False; + } + + /* create the rpc header */ + if (!create_rpc_reply(p, 0, p->rdata.offset + (p->ntlmssp_auth ? (16 + 8) : 0))) + { + return False; + } + + return True; +} diff --git a/source3/rpc_server/srv_sid.c b/source3/rpc_server/srv_sid.c new file mode 100644 index 0000000000..b80902dbaa --- /dev/null +++ b/source3/rpc_server/srv_sid.c @@ -0,0 +1,484 @@ +/* + Unix SMB/Netbios implementation. + Version 1.9. + Samba utility functions + Copyright (C) Andrew Tridgell 1992-1998 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + + +extern int DEBUGLEVEL; +extern pstring scope; +extern pstring global_myname; + +/* + * This is set on startup - it defines the SID for this + * machine, and therefore the SAM database for which it is + * responsible. + */ + +DOM_SID global_sam_sid; + +/* + * This is the name associated with the SAM database for + * which this machine is responsible. In the case of a PDC + * or PDC, this name is the same as the workgroup. In the + * case of "security = domain" mode, this is the same as + * the name of the server (global_myname). + */ + +fstring global_sam_name; + +/* + * This is obtained on startup - it defines the SID for which + * this machine is a member. It is therefore only set, and + * used, in "security = domain" mode. + */ + +DOM_SID global_member_sid; + +/* + * note the lack of a "global_member_name" - this is because + * this is the same as "global_myworkgroup". + */ + +/* + * some useful sids + */ + +DOM_SID global_sid_S_1_5_20; /* local well-known domain */ +DOM_SID global_sid_S_1_1; /* everyone */ +DOM_SID global_sid_S_1_3; /* */ +DOM_SID global_sid_S_1_5; /* NT Authority */ + +extern pstring global_myworkgroup; +/* extern fstring global_member_dom_name; */ + +static struct sid_name_map_info +{ + DOM_SID *sid; + char *name; + +} +sid_name_map[] = +{ + { &global_sid_S_1_5_20, "BUILTIN" }, + { &global_sid_S_1_1 , "Everyone" }, + { &global_sid_S_1_3 , "don't know" }, + { &global_sid_S_1_5 , "NT Authority" }, + { &global_sam_sid , global_sam_name }, + { &global_member_sid , global_myworkgroup }, + { NULL , NULL } +}; + +/**************************************************************************** + Read the machine SID from a file. +****************************************************************************/ + +static BOOL read_sid_from_file(int fd, char *sid_file) +{ + fstring fline; + + memset(fline, '\0', sizeof(fline)); + + if (read(fd, fline, sizeof(fline) -1 ) < 0) { + DEBUG(0,("unable to read file %s. Error was %s\n", + sid_file, strerror(errno) )); + return False; + } + + /* + * Convert to the machine SID. + */ + + fline[sizeof(fline)-1] = '\0'; + if (!string_to_sid( &global_sam_sid, fline)) { + DEBUG(0,("unable to generate machine SID.\n")); + return False; + } + + return True; +} + +/**************************************************************************** + Generate the global machine sid. Look for the MACHINE.SID file first, if + not found then look in smb.conf and use it to create the MACHINE.SID file. +****************************************************************************/ +BOOL get_member_domain_sid(void) +{ + POLICY_HND pol; + fstring srv_name; + struct cli_state cli; + BOOL res = True; + DOM_SID sid3; + DOM_SID sid5; + fstring dom3; + fstring dom5; + + if (!cli_connect_serverlist(&cli, lp_passwordserver())) + { + DEBUG(0,("get_member_domain_sid: unable to initialize client connection.\n")); + return False; + } + + /* + * Ok - we have an anonymous connection to the IPC$ share. + * Now start the NT Domain stuff :-). + */ + + fstrcpy(dom3, ""); + fstrcpy(dom5, ""); + ZERO_STRUCT(sid3); + ZERO_STRUCT(sid5); + + fstrcpy(srv_name, "\\\\"); + fstrcat(srv_name, global_myname); + strupper(srv_name); + + /* open LSARPC session. */ + res = res ? cli_nt_session_open(&cli, PIPE_LSARPC) : False; + + /* lookup domain controller; receive a policy handle */ + res = res ? do_lsa_open_policy(&cli, srv_name, &pol, False) : False; + + /* send client info query, level 3. receive domain name and sid */ + res = res ? do_lsa_query_info_pol(&cli, &pol, 3, dom3, &sid3) : False; + + /* send client info query, level 5. receive domain name and sid */ + res = res ? do_lsa_query_info_pol(&cli, &pol, 5, dom5, &sid5) : False; + + /* close policy handle */ + res = res ? do_lsa_close(&cli, &pol) : False; + + /* close the session */ + cli_nt_session_close(&cli); + cli_ulogoff(&cli); + cli_shutdown(&cli); + + if (res) + { + pstring sid; + DEBUG(5,("LSA Query Info Policy\n")); + sid_to_string(sid, &sid3); + DEBUG(5,("Domain Member - Domain: %s SID: %s\n", dom3, sid)); + sid_to_string(sid, &sid5); + DEBUG(5,("Domain Controller - Domain: %s SID: %s\n", dom5, sid)); + + if (!strequal(dom3, global_myworkgroup) || + !strequal(dom5, global_myworkgroup)) + { + DEBUG(0,("get_member_domain_sid: %s is a DC for %s not %s\n", + cli.desthost, dom5, global_myworkgroup)); + res = False; + } + } + else + { + DEBUG(5,("lsa query info failed\n")); + } + if (!res) + { + DEBUG(0,("get_member_domain_sid: unable to obtain Domain member SID\n")); + } + else + { + /* this is a _lot_ of trouble to go to for just this info: */ + global_member_sid = sid5; + } + + return res; +} + +/**************************************************************************** + creates some useful well known sids +****************************************************************************/ +void generate_wellknown_sids(void) +{ + string_to_sid(&global_sid_S_1_5_20, "S-1-5-32"); + string_to_sid(&global_sid_S_1_1 , "S-1-1" ); + string_to_sid(&global_sid_S_1_3 , "S-1-3" ); + string_to_sid(&global_sid_S_1_5 , "S-1-5" ); +} + +/**************************************************************************** + Generate the global machine sid. Look for the MACHINE.SID file first, if + not found then look in smb.conf and use it to create the MACHINE.SID file. +****************************************************************************/ +BOOL generate_sam_sid(void) +{ + int fd; + int i; + char *p; + pstring sid_file; + fstring sid_string; + SMB_STRUCT_STAT st; + uchar raw_sid_data[12]; + + pstrcpy(sid_file, lp_smb_passwd_file()); + p = strrchr(sid_file, '/'); + if (p != NULL) { + *++p = '\0'; + } + + if (!directory_exist(sid_file, NULL)) { + if (dos_mkdir(sid_file, 0700) != 0) { + DEBUG(0,("can't create private directory %s : %s\n", + sid_file, strerror(errno))); + return False; + } + } + + pstrcat(sid_file, "MACHINE.SID"); + + if ((fd = open(sid_file, O_RDWR | O_CREAT, 0644)) == -1) { + DEBUG(0,("unable to open or create file %s. Error was %s\n", + sid_file, strerror(errno) )); + return False; + } + + /* + * Check if the file contains data. + */ + + if (sys_fstat( fd, &st) < 0) { + DEBUG(0,("unable to stat file %s. Error was %s\n", + sid_file, strerror(errno) )); + close(fd); + return False; + } + + if (st.st_size > 0) { + /* + * We have a valid SID - read it. + */ + if (!read_sid_from_file( fd, sid_file)) { + DEBUG(0,("unable to read file %s. Error was %s\n", + sid_file, strerror(errno) )); + close(fd); + return False; + } + close(fd); + return True; + } + + /* + * Generate the new sid data & turn it into a string. + */ + generate_random_buffer( raw_sid_data, 12, True); + + fstrcpy( sid_string, "S-1-5-21"); + for( i = 0; i < 3; i++) { + fstring tmp_string; + slprintf( tmp_string, sizeof(tmp_string) - 1, "-%u", IVAL(raw_sid_data, i*4)); + fstrcat( sid_string, tmp_string); + } + + fstrcat(sid_string, "\n"); + + /* + * Ensure our new SID is valid. + */ + + if (!string_to_sid( &global_sam_sid, sid_string)) { + DEBUG(0,("unable to generate machine SID.\n")); + return False; + } + + /* + * Do an exclusive blocking lock on the file. + */ + + if (!do_file_lock( fd, 60, F_WRLCK)) { + DEBUG(0,("unable to lock file %s. Error was %s\n", + sid_file, strerror(errno) )); + close(fd); + return False; + } + + /* + * At this point we have a blocking lock on the SID + * file - check if in the meantime someone else wrote + * SID data into the file. If so - they were here first, + * use their data. + */ + + if (sys_fstat( fd, &st) < 0) { + DEBUG(0,("unable to stat file %s. Error was %s\n", + sid_file, strerror(errno) )); + close(fd); + return False; + } + + if (st.st_size > 0) { + /* + * Unlock as soon as possible to reduce + * contention on the exclusive lock. + */ + do_file_lock( fd, 60, F_UNLCK); + + /* + * We have a valid SID - read it. + */ + + if (!read_sid_from_file( fd, sid_file)) { + DEBUG(0,("unable to read file %s. Error was %s\n", + sid_file, strerror(errno) )); + close(fd); + return False; + } + close(fd); + return True; + } + + /* + * The file is still empty and we have an exlusive lock on it. + * Write out out SID data into the file. + */ + + if (fchmod(fd, 0644) < 0) { + DEBUG(0,("unable to set correct permissions on file %s. \ +Error was %s\n", sid_file, strerror(errno) )); + close(fd); + return False; + } + + if (write( fd, sid_string, strlen(sid_string)) != strlen(sid_string)) { + DEBUG(0,("unable to write file %s. Error was %s\n", + sid_file, strerror(errno) )); + close(fd); + return False; + } + + /* + * Unlock & exit. + */ + + do_file_lock( fd, 60, F_UNLCK); + close(fd); + return True; +} + +/************************************************************************** + turns a domain name into a SID. + + *** side-effect: if the domain name is NULL, it is set to our domain *** + +***************************************************************************/ +BOOL map_domain_name_to_sid(DOM_SID *sid, char **nt_domain) +{ + fstring sid_str; + sid_to_string(sid_str, sid); + DEBUG(5,("map_domain_name_to_sid: %s\n", sid_str)); + + if (nt_domain == NULL) + { + *sid = global_sam_sid; + return True; + } + + if ((*nt_domain) == NULL) + { + DEBUG(5,("map_domain_name_to_sid: overriding NULL name to %s\n", + global_sam_name)); + (*nt_domain) = strdup(global_sam_name); + *sid = global_sam_sid; + return True; + } + + if (strequal((*nt_domain), global_sam_name)) + { + *sid = global_sam_sid; + return True; + } + + DEBUG(0,("map_domain_name_to_sid: mapping to %s NOT IMPLEMENTED\n", + (*nt_domain))); + return False; +} + +/************************************************************************** + turns a domain SID into a name. + +***************************************************************************/ +BOOL map_domain_sid_to_name(DOM_SID *sid, char *nt_domain) +{ + fstring sid_str; + int i = 0; + sid_to_string(sid_str, sid); + + DEBUG(5,("map_domain_sid_to_name: %s\n", sid_str)); + + if (nt_domain == NULL) + { + return False; + } + + while (sid_name_map[i].sid != NULL) + { + sid_to_string(sid_str, sid_name_map[i].sid); + DEBUG(5,("compare: %s\n", sid_str)); + if (sid_equal(sid_name_map[i].sid, sid)) + { + fstrcpy(nt_domain, sid_name_map[i].name); + DEBUG(5,("found %s\n", nt_domain)); + return True; + } + i++; + } + + DEBUG(0,("map_domain_sid_to_name: mapping NOT IMPLEMENTED\n")); + + return False; +} + +/************************************************************************** + splits a name of format \DOMAIN\name into its two components. + sets the DOMAIN name to global_sam_name if it has not been specified. +***************************************************************************/ +BOOL split_domain_name(char *fullname, char *domain, char *name) +{ + fstring full_name; + char *p; + + if (fullname == NULL || domain == NULL || name == NULL) + { + return False; + } + + if (fullname[0] == '\\') + { + fullname++; + } + fstrcpy(full_name, fullname); + p = strchr(full_name+1, '\\'); + + if (p == NULL) + { + *p = 0; + fstrcpy(domain, full_name); + fstrcpy(name, p+1); + } + else + { + fstrcpy(domain, global_sam_name); + fstrcpy(name, full_name); + } + + DEBUG(5,("name '%s' split into '\\%s\\%s'\n", fullname, domain, name)); + return True; +} diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 161f845af3..097ab92d76 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -154,693 +154,6 @@ int make_dom_gids(char *gids_str, DOM_GID **ppgids) return count; } -static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) -{ - unsigned char *hash = p->ntlmssp_hash; - unsigned char index_i = hash[256]; - unsigned char index_j = hash[257]; - int ind; - - for( ind = 0; ind < len; ind++) - { - unsigned char tc; - unsigned char t; - - index_i++; - index_j += hash[index_i]; - - tc = hash[index_i]; - hash[index_i] = hash[index_j]; - hash[index_j] = tc; - - t = hash[index_i] + hash[index_j]; - data[ind] = data[ind] ^ hash[t]; - } - - hash[256] = index_i; - hash[257] = index_j; -} - -/******************************************************************* - turns a DCE/RPC request into a DCE/RPC reply - - this is where the data really should be split up into an array of - headers and data sections. - - ********************************************************************/ -BOOL create_rpc_reply(pipes_struct *p, - uint32 data_start, uint32 data_end) -{ - char *data; - BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SIGN); - BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SEAL); - uint32 data_len; - uint32 auth_len; - - DEBUG(5,("create_rpc_reply: data_start: %d data_end: %d max_tsize: %d\n", - data_start, data_end, p->hdr_ba.bba.max_tsize)); - - auth_len = p->hdr.auth_len; - - if (p->ntlmssp_auth) - { - DEBUG(10,("create_rpc_reply: auth\n")); - if (auth_len != 16) - { - return False; - } - } - - prs_init(&p->rhdr , 0x18, 4, 0, False); - prs_init(&p->rauth, 1024, 4, 0, False); - prs_init(&p->rverf, 0x08, 4, 0, False); - - p->hdr.pkt_type = RPC_RESPONSE; /* mark header as an rpc response */ - - /* set up rpc header (fragmentation issues) */ - if (data_start == 0) - { - p->hdr.flags = RPC_FLG_FIRST; - } - else - { - p->hdr.flags = 0; - } - - p->hdr_resp.alloc_hint = data_end - data_start; /* calculate remaining data to be sent */ - - if (p->hdr_resp.alloc_hint + 0x18 <= p->hdr_ba.bba.max_tsize) - { - p->hdr.flags |= RPC_FLG_LAST; - p->hdr.frag_len = p->hdr_resp.alloc_hint + 0x18; - } - else - { - p->hdr.frag_len = p->hdr_ba.bba.max_tsize; - } - - if (p->ntlmssp_auth) - { - p->hdr_resp.alloc_hint -= auth_len + 8; - } - - if (p->ntlmssp_auth) - { - data_len = p->hdr.frag_len - auth_len - (auth_verify ? 8 : 0) - 0x18; - } - else - { - data_len = p->hdr.frag_len - 0x18; - } - - p->rhdr.data->offset.start = 0; - p->rhdr.data->offset.end = 0x18; - - /* store the header in the data stream */ - smb_io_rpc_hdr ("hdr" , &(p->hdr ), &(p->rhdr), 0); - smb_io_rpc_hdr_resp("resp", &(p->hdr_resp), &(p->rhdr), 0); - - /* don't use rdata: use rdata_i instead, which moves... */ - /* make a pointer to the rdata data, NOT A COPY */ - - p->rdata_i.data = NULL; - prs_init(&p->rdata_i, 0, p->rdata.align, p->rdata.data->margin, p->rdata.io); - data = mem_data(&(p->rdata.data), data_start); - mem_create(p->rdata_i.data, data, 0, data_len, 0, False); - p->rdata_i.offset = data_len; - - if (auth_len > 0) - { - uint32 crc32; - - DEBUG(5,("create_rpc_reply: sign: %s seal: %s data %d auth %d\n", - BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); - - if (auth_seal) - { - crc32 = crc32_calc_buffer(data_len, data); - NTLMSSPcalc_p(p, (uchar*)data, data_len); - } - - if (auth_seal || auth_verify) - { - make_rpc_hdr_auth(&p->auth_info, 0x0a, 0x06, 0x08, (auth_verify ? 1 : 0)); - smb_io_rpc_hdr_auth("hdr_auth", &p->auth_info, &p->rauth, 0); - } - - if (auth_verify) - { - char *auth_data; - p->ntlmssp_seq_num++; - make_rpc_auth_ntlmssp_chk(&p->ntlmssp_chk, NTLMSSP_SIGN_VERSION, crc32, p->ntlmssp_seq_num++); - smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(p->ntlmssp_chk), &p->rverf, 0); - auth_data = mem_data(&p->rverf.data, 4); - NTLMSSPcalc_p(p, (uchar*)auth_data, 12); - } - } - - /* set up the data chain */ - if (p->ntlmssp_auth) - { - prs_link(NULL , &p->rhdr , &p->rdata_i); - prs_link(&p->rhdr , &p->rdata_i, &p->rauth ); - prs_link(&p->rdata_i, &p->rauth , &p->rverf ); - prs_link(&p->rauth , &p->rverf , NULL ); - } - else - { - prs_link(NULL , &p->rhdr , &p->rdata_i); - prs_link(&p->rhdr, &p->rdata_i, NULL ); - } - - /* indicate to subsequent data reads where we are up to */ - p->frag_len_left = p->hdr.frag_len - p->file_offset; - p->next_frag_start = p->hdr.frag_len; - - return p->rhdr.data != NULL && p->rhdr.offset == 0x18; -} - -static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) -{ - uchar lm_owf[24]; - uchar nt_owf[24]; - struct smb_passwd *smb_pass = NULL; - - DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); - - if (p->ntlmssp_resp.hdr_lm_resp.str_str_len == 0) return False; - if (p->ntlmssp_resp.hdr_nt_resp.str_str_len == 0) return False; - if (p->ntlmssp_resp.hdr_usr .str_str_len == 0) return False; - if (p->ntlmssp_resp.hdr_domain .str_str_len == 0) return False; - if (p->ntlmssp_resp.hdr_wks .str_str_len == 0) return False; - - memset(p->user_name, 0, sizeof(p->user_name)); - memset(p->domain , 0, sizeof(p->domain )); - memset(p->wks , 0, sizeof(p->wks )); - - if (IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_UNICODE)) - { - fstrcpy(p->user_name, unistrn2((uint16*)p->ntlmssp_resp.user , p->ntlmssp_resp.hdr_usr .str_str_len/2)); - fstrcpy(p->domain , unistrn2((uint16*)p->ntlmssp_resp.domain, p->ntlmssp_resp.hdr_domain.str_str_len/2)); - fstrcpy(p->wks , unistrn2((uint16*)p->ntlmssp_resp.wks , p->ntlmssp_resp.hdr_wks .str_str_len/2)); - } - else - { - fstrcpy(p->user_name, p->ntlmssp_resp.user ); - fstrcpy(p->domain , p->ntlmssp_resp.domain); - fstrcpy(p->wks , p->ntlmssp_resp.wks ); - } - - DEBUG(5,("user: %s domain: %s wks: %s\n", p->user_name, p->domain, p->wks)); - - memcpy(lm_owf, p->ntlmssp_resp.lm_resp, sizeof(lm_owf)); - memcpy(nt_owf, p->ntlmssp_resp.nt_resp, sizeof(nt_owf)); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("lm, nt owfs, chal\n")); - dump_data(100, lm_owf, sizeof(lm_owf)); - dump_data(100, nt_owf, sizeof(nt_owf)); - dump_data(100, p->ntlmssp_chal.challenge, 8); -#endif - become_root(True); - p->ntlmssp_validated = pass_check_smb(p->user_name, p->domain, - (uchar*)p->ntlmssp_chal.challenge, - lm_owf, nt_owf, NULL); - smb_pass = getsmbpwnam(p->user_name); - unbecome_root(True); - - if (p->ntlmssp_validated && smb_pass != NULL && smb_pass->smb_passwd) - { - uchar p24[24]; - NTLMSSPOWFencrypt(smb_pass->smb_passwd, lm_owf, p24); - { - unsigned char j = 0; - int ind; - - unsigned char k2[8]; - - memcpy(k2, p24, 5); - k2[5] = 0xe5; - k2[6] = 0x38; - k2[7] = 0xb0; - - for (ind = 0; ind < 256; ind++) - { - p->ntlmssp_hash[ind] = (unsigned char)ind; - } - - for( ind = 0; ind < 256; ind++) - { - unsigned char tc; - - j += (p->ntlmssp_hash[ind] + k2[ind%8]); - - tc = p->ntlmssp_hash[ind]; - p->ntlmssp_hash[ind] = p->ntlmssp_hash[j]; - p->ntlmssp_hash[j] = tc; - } - - p->ntlmssp_hash[256] = 0; - p->ntlmssp_hash[257] = 0; - } -/* NTLMSSPhash(p->ntlmssp_hash, p24); */ - p->ntlmssp_seq_num = 0; - } - else - { - p->ntlmssp_validated = False; - } - - return p->ntlmssp_validated; -} - -static BOOL api_pipe_ntlmssp(pipes_struct *p, prs_struct *pd) -{ - /* receive a negotiate; send a challenge; receive a response */ - switch (p->auth_verifier.msg_type) - { - case NTLMSSP_NEGOTIATE: - { - smb_io_rpc_auth_ntlmssp_neg("", &p->ntlmssp_neg, pd, 0); - break; - } - case NTLMSSP_AUTH: - { - smb_io_rpc_auth_ntlmssp_resp("", &p->ntlmssp_resp, pd, 0); - if (!api_pipe_ntlmssp_verify(p)) - { - pd->offset = 0; - } - break; - } - default: - { - /* NTLMSSP expected: unexpected message type */ - DEBUG(3,("unexpected message type in NTLMSSP %d\n", - p->auth_verifier.msg_type)); - return False; - } - } - - return (pd->offset != 0); -} - -struct api_cmd -{ - char * pipe_clnt_name; - char * pipe_srv_name; - BOOL (*fn) (pipes_struct *, prs_struct *); -}; - -static struct api_cmd api_fd_commands[] = -{ - { "lsarpc", "lsass", api_ntlsa_rpc }, - { "samr", "lsass", api_samr_rpc }, - { "srvsvc", "ntsvcs", api_srvsvc_rpc }, - { "wkssvc", "ntsvcs", api_wkssvc_rpc }, - { "NETLOGON", "lsass", api_netlog_rpc }, - { "winreg", "winreg", api_reg_rpc }, - { NULL, NULL, NULL } -}; - -static BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *pd) -{ - DEBUG(5,("api_pipe_bind_auth_resp: decode request. %d\n", __LINE__)); - - if (p->hdr.auth_len == 0) return False; - - /* decode the authentication verifier response */ - smb_io_rpc_hdr_autha("", &p->autha_info, pd, 0); - if (pd->offset == 0) return False; - - if (!rpc_hdr_auth_chk(&(p->auth_info))) return False; - - smb_io_rpc_auth_verifier("", &p->auth_verifier, pd, 0); - if (pd->offset == 0) return False; - - if (!rpc_auth_verifier_chk(&(p->auth_verifier), "NTLMSSP", NTLMSSP_AUTH)) return False; - - return api_pipe_ntlmssp(p, pd); -} - -static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) -{ - uint16 assoc_gid; - fstring ack_pipe_name; - int i = 0; - - p->ntlmssp_auth = False; - - DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); - - for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) - { - if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && - api_fd_commands[i].fn != NULL) - { - DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", - api_fd_commands[i].pipe_clnt_name, - api_fd_commands[i].pipe_srv_name)); - fstrcpy(p->pipe_srv_name, api_fd_commands[i].pipe_srv_name); - break; - } - } - - if (api_fd_commands[i].fn == NULL) return False; - - /* decode the bind request */ - smb_io_rpc_hdr_rb("", &p->hdr_rb, pd, 0); - - if (pd->offset == 0) return False; - - if (p->hdr.auth_len != 0) - { - /* decode the authentication verifier */ - smb_io_rpc_hdr_auth ("", &p->auth_info , pd, 0); - if (pd->offset == 0) return False; - - p->ntlmssp_auth = p->auth_info.auth_type = 0x0a; - - if (p->ntlmssp_auth) - { - smb_io_rpc_auth_verifier("", &p->auth_verifier, pd, 0); - if (pd->offset == 0) return False; - - p->ntlmssp_auth = strequal(p->auth_verifier.signature, "NTLMSSP"); - } - - if (p->ntlmssp_auth) - { - if (!api_pipe_ntlmssp(p, pd)) return False; - } - } - - /* name has to be \PIPE\xxxxx */ - fstrcpy(ack_pipe_name, "\\PIPE\\"); - fstrcat(ack_pipe_name, p->pipe_srv_name); - - DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); - - prs_init(&(p->rdata), 1024, 4, 0, False); - prs_init(&(p->rhdr ), 0x18, 4, 0, False); - prs_init(&(p->rauth), 1024, 4, 0, False); - prs_init(&(p->rverf), 0x08, 4, 0, False); - prs_init(&(p->rntlm), 1024, 4, 0, False); - - /***/ - /*** do the bind ack first ***/ - /***/ - - if (p->ntlmssp_auth) - { - assoc_gid = 0x7a77; - } - else - { - assoc_gid = p->hdr_rb.bba.assoc_gid; - } - - make_rpc_hdr_ba(&p->hdr_ba, - p->hdr_rb.bba.max_tsize, - p->hdr_rb.bba.max_rsize, - assoc_gid, - ack_pipe_name, - 0x1, 0x0, 0x0, - &(p->hdr_rb.transfer)); - - smb_io_rpc_hdr_ba("", &p->hdr_ba, &p->rdata, 0); - mem_realloc_data(p->rdata.data, p->rdata.offset); - - /***/ - /*** now the authentication ***/ - /***/ - - if (p->ntlmssp_auth) - { - uint8 challenge[8]; - generate_random_buffer(challenge, 8, False); - - /*** authentication info ***/ - - make_rpc_hdr_auth(&p->auth_info, 0x0a, 0x06, 0, 1); - smb_io_rpc_hdr_auth("", &p->auth_info, &p->rverf, 0); - mem_realloc_data(p->rverf.data, p->rverf.offset); - - /*** NTLMSSP verifier ***/ - - make_rpc_auth_verifier(&p->auth_verifier, - "NTLMSSP", NTLMSSP_CHALLENGE); - smb_io_rpc_auth_verifier("", &p->auth_verifier, &p->rauth, 0); - mem_realloc_data(p->rauth.data, p->rauth.offset); - - /* NTLMSSP challenge ***/ - - make_rpc_auth_ntlmssp_chal(&p->ntlmssp_chal, - 0x000082b1, challenge); - smb_io_rpc_auth_ntlmssp_chal("", &p->ntlmssp_chal, &p->rntlm, 0); - mem_realloc_data(p->rntlm.data, p->rntlm.offset); - } - - /***/ - /*** then do the header, now we know the length ***/ - /***/ - - make_rpc_hdr(&p->hdr, RPC_BINDACK, RPC_FLG_FIRST | RPC_FLG_LAST, - p->hdr.call_id, - p->rdata.offset + p->rverf.offset + p->rauth.offset + p->rntlm.offset + 0x10, - p->rauth.offset + p->rntlm.offset); - - smb_io_rpc_hdr("", &p->hdr, &p->rhdr, 0); - mem_realloc_data(p->rhdr.data, p->rdata.offset); - - /***/ - /*** link rpc header, bind acknowledgment and authentication responses ***/ - /***/ - - if (p->ntlmssp_auth) - { - prs_link(NULL , &p->rhdr , &p->rdata); - prs_link(&p->rhdr , &p->rdata, &p->rverf); - prs_link(&p->rdata, &p->rverf, &p->rauth); - prs_link(&p->rverf, &p->rauth, &p->rntlm); - prs_link(&p->rauth, &p->rntlm, NULL ); - } - else - { - prs_link(NULL , &p->rhdr , &p->rdata); - prs_link(&p->rhdr, &p->rdata, NULL ); - } - - return True; -} - - -static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) -{ - BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SIGN); - BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SEAL); - int data_len; - int auth_len; - uint32 old_offset; - uint32 crc32; - - auth_len = p->hdr.auth_len; - - if (auth_len != 16 && auth_verify) - { - return False; - } - - data_len = p->hdr.frag_len - auth_len - (auth_verify ? 8 : 0) - 0x18; - - DEBUG(5,("api_pipe_auth_process: sign: %s seal: %s data %d auth %d\n", - BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); - - if (auth_seal) - { - char *data = mem_data(&pd->data, pd->offset); - DEBUG(5,("api_pipe_auth_process: data %d\n", pd->offset)); - NTLMSSPcalc_p(p, (uchar*)data, data_len); - crc32 = crc32_calc_buffer(data_len, data); - } - - /*** skip the data, record the offset so we can restore it again */ - old_offset = pd->offset; - - if (auth_seal || auth_verify) - { - pd->offset += data_len; - smb_io_rpc_hdr_auth("hdr_auth", &p->auth_info, pd, 0); - } - - if (auth_verify) - { - char *req_data = mem_data(&pd->data, pd->offset + 4); - DEBUG(5,("api_pipe_auth_process: auth %d\n", pd->offset + 4)); - NTLMSSPcalc_p(p, (uchar*)req_data, 12); - smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(p->ntlmssp_chk), pd, 0); - - if (!rpc_auth_ntlmssp_chk(&(p->ntlmssp_chk), crc32, - p->ntlmssp_seq_num)) - { - return False; - } - } - - pd->offset = old_offset; - - return True; -} - -static BOOL api_pipe_request(pipes_struct *p, prs_struct *pd) -{ - int i = 0; - - if (p->ntlmssp_auth && p->ntlmssp_validated) - { - if (!api_pipe_auth_process(p, pd)) return False; - - DEBUG(0,("api_pipe_request: **** MUST CALL become_user() HERE **** \n")); -#if 0 - become_user(); -#endif - } - - for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) - { - if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && - api_fd_commands[i].fn != NULL) - { - DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i].pipe_clnt_name)); - return api_fd_commands[i].fn(p, pd); - } - } - return False; -} - -BOOL rpc_command(pipes_struct *p, prs_struct *pd) -{ - BOOL reply = False; - if (pd->data == NULL) return False; - - /* process the rpc header */ - smb_io_rpc_hdr("", &p->hdr, pd, 0); - - if (pd->offset == 0) return False; - - switch (p->hdr.pkt_type) - { - case RPC_BIND : - { - reply = api_pipe_bind_req(p, pd); - break; - } - case RPC_REQUEST: - { - if (p->ntlmssp_auth && !p->ntlmssp_validated) - { - /* authentication _was_ requested - and it failed. sorry, no deal! - */ - reply = False; - } - else - { - /* read the rpc header */ - smb_io_rpc_hdr_req("req", &(p->hdr_req), pd, 0); - reply = api_pipe_request(p, pd); - } - break; - } - case RPC_BINDRESP: /* not the real name! */ - { - reply = api_pipe_bind_auth_resp(p, pd); - p->ntlmssp_auth = reply; - break; - } - } - - if (!reply) - { - DEBUG(3,("rpc_command: DCE/RPC fault should be sent here\n")); - } - - return reply; -} - - -/******************************************************************* - receives a netlogon pipe and responds. - ********************************************************************/ -static BOOL api_rpc_command(pipes_struct *p, - char *rpc_name, struct api_struct *api_rpc_cmds, - prs_struct *data) -{ - int fn_num; - DEBUG(4,("api_rpc_command: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); - - for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) - { - if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) - { - DEBUG(3,("api_rpc_command: %s\n", api_rpc_cmds[fn_num].name)); - break; - } - } - - if (api_rpc_cmds[fn_num].name == NULL) - { - DEBUG(4, ("unknown\n")); - return False; - } - - /* start off with 1024 bytes, and a large safety margin too */ - prs_init(&p->rdata, 1024, 4, SAFETY_MARGIN, False); - - /* do the actual command */ - api_rpc_cmds[fn_num].fn(p->vuid, data, &(p->rdata)); - - if (p->rdata.data == NULL || p->rdata.offset == 0) - { - mem_free_data(p->rdata.data); - return False; - } - - mem_realloc_data(p->rdata.data, p->rdata.offset); - - DEBUG(10,("called %s\n", rpc_name)); - - return True; -} - - -/******************************************************************* - receives a netlogon pipe and responds. - ********************************************************************/ -BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds, - prs_struct *data) -{ - if (data == NULL || data->data == NULL) - { - DEBUG(2,("%s: NULL data received\n", rpc_name)); - return False; - } - - /* interpret the command */ - if (!api_rpc_command(p, rpc_name, api_rpc_cmds, data)) - { - return False; - } - - /* create the rpc header */ - if (!create_rpc_reply(p, 0, p->rdata.offset + (p->ntlmssp_auth ? (16 + 8) : 0))) - { - return False; - } - - return True; -} - /******************************************************************* gets a domain user's groups -- cgit From 597c5a6caa871b724ee1337f14467950b0707b34 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 12 Nov 1998 19:21:20 +0000 Subject: jean-f. sent me some S-1-3-0,1,2,3 SIDs and names. S-1-3 doesn't exist. security descriptor testing. hey wow, you can get a SD then send it back! (This used to be commit 7466c3113ef8f8a89b8496efadfeb611c9f3e069) --- source3/rpc_server/srv_sid.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_sid.c b/source3/rpc_server/srv_sid.c index b80902dbaa..29cc1c936c 100644 --- a/source3/rpc_server/srv_sid.c +++ b/source3/rpc_server/srv_sid.c @@ -63,8 +63,11 @@ DOM_SID global_member_sid; DOM_SID global_sid_S_1_5_20; /* local well-known domain */ DOM_SID global_sid_S_1_1; /* everyone */ -DOM_SID global_sid_S_1_3; /* */ DOM_SID global_sid_S_1_5; /* NT Authority */ +DOM_SID global_sid_S_1_3_0; /* Creator owner */ +DOM_SID global_sid_S_1_3_1; /* Creator group */ +DOM_SID global_sid_S_1_3_2; /* Creator owner server */ +DOM_SID global_sid_S_1_3_3; /* Creator group server */ extern pstring global_myworkgroup; /* extern fstring global_member_dom_name; */ @@ -79,7 +82,10 @@ sid_name_map[] = { { &global_sid_S_1_5_20, "BUILTIN" }, { &global_sid_S_1_1 , "Everyone" }, - { &global_sid_S_1_3 , "don't know" }, + { &global_sid_S_1_3_0 , "Creator Owner" }, + { &global_sid_S_1_3_1 , "Creator Group" }, + { &global_sid_S_1_3_2 , "Creator Owner Server" }, + { &global_sid_S_1_3_3 , "Creator Group Server" }, { &global_sid_S_1_5 , "NT Authority" }, { &global_sam_sid , global_sam_name }, { &global_member_sid , global_myworkgroup }, @@ -211,7 +217,10 @@ void generate_wellknown_sids(void) { string_to_sid(&global_sid_S_1_5_20, "S-1-5-32"); string_to_sid(&global_sid_S_1_1 , "S-1-1" ); - string_to_sid(&global_sid_S_1_3 , "S-1-3" ); + string_to_sid(&global_sid_S_1_3_0 , "S-1-3-0" ); + string_to_sid(&global_sid_S_1_3_1 , "S-1-3-1" ); + string_to_sid(&global_sid_S_1_3_2 , "S-1-3-2" ); + string_to_sid(&global_sid_S_1_3_3 , "S-1-3-3" ); string_to_sid(&global_sid_S_1_5 , "S-1-5" ); } -- cgit From 8fc1504ff8204dd1ca735f31c769f6dadf0f88cb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 13 Nov 1998 21:41:01 +0000 Subject: Makefile.in configure configure.in include/config.h.in: Changes for DGUX and UNIXWARE. groupdb/aliasdb.c groupdb/aliasfile.c groupdb/groupfile.c: Don't use snprinf, use slprintf. include/includes.h: Fix YP problem. include/smb.h: Fix ZERO_STRUCTP. lib/util_sock.c: Added strerror() in debugs. passdb/ldap.c: Don't use snprinf, use slprintf. rpc_client/cli_lsarpc.c rpc_client/cli_pipe.c rpc_parse/parse_sec.c rpc_server/srv_pipe.c: Don't use snprinf, use slprintf. script/installman.sh: DGUX changes. smbd/open.c smbd/oplock.c: Fixed gcc warnings. web/swat.c: Changes USER to SWAT_USER. (This used to be commit 4c2b5a00983501e5d4aad1456ba8b5ab0dfd9b4c) --- source3/rpc_server/srv_pipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 94a7ebc838..1ad4cb6b9e 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -160,7 +160,7 @@ BOOL create_rpc_reply(pipes_struct *p, if (auth_len > 0) { - uint32 crc32; + uint32 crc32 = 0; DEBUG(5,("create_rpc_reply: sign: %s seal: %s data %d auth %d\n", BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); @@ -531,7 +531,7 @@ static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) int data_len; int auth_len; uint32 old_offset; - uint32 crc32; + uint32 crc32 = 0; auth_len = p->hdr.auth_len; -- cgit From 74d539f5573a3ed3ff1b96c54752a389da4c3e14 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 17 Nov 1998 16:19:04 +0000 Subject: - group database API. oops and oh dear, the threat has been carried out: the pre-alpha "domain group" etc parameters have disappeared. - interactive debug detection - re-added mem_man (andrew's memory management, detects memory corruption) - american spellings of "initialise" replaced with english spelling of "initialise". - started on "lookup_name()" and "lookup_sid()" functions. proper ones. - moved lots of functions around. created some modules of commonly used code. e.g the password file locking code, which is used in groupfile.c and aliasfile.c and smbpass.c - moved RID_TYPE_MASK up another bit. this is really unfortunate, but there is no other "fast" way to identify users from groups from aliases. i do not believe that this code saves us anything (the multipliers) and puts us at a disadvantage (reduces the useable rid space). the designers of NT aren't silly: if they can get away with a user- interface-speed LsaLookupNames / LsaLookupSids, then so can we. i spoke with isaac at the cifs conference, the only time for example that they do a security context check is on file create. certainly not on individual file reads / writes, which would drastically hit their performance and ours, too. - renamed myworkgroup to global_sam_name, amongst other things, when used in the rpc code. there is also a global_member_name, as we are always responsible for a SAM database, the scope of which is limited by the role of the machine (e.g if a member of a workgroup, your SAM is for _local_ logins only, and its name is the name of your server. you even still have a SID. see LsaQueryInfoPolicy, levels 3 and 5). - updated functionality of groupname.c to be able to cope with names like DOMAIN\group and SERVER\alias. used this code to be able to do aliases as well as groups. this code may actually be better off being used in username mapping, too. - created a connect to serverlist function in clientgen.c and used it in password.c - initialisation in server.c depends on the role of the server. well, it does now. - rpctorture. smbtorture. EXERCISE EXTREME CAUTION. (This used to be commit 0d21e1e6090b933f396c764af535ca3388a562db) --- source3/rpc_server/srv_lsa.c | 271 ++++++++++++------------- source3/rpc_server/srv_lsa_hnd.c | 4 +- source3/rpc_server/srv_netlog.c | 416 +++++++++++++++++++-------------------- source3/rpc_server/srv_samr.c | 262 +++++++++++++++++------- source3/rpc_server/srv_util.c | 323 +----------------------------- 5 files changed, 538 insertions(+), 738 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 5e6e101883..51b6e8d25b 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -29,6 +29,12 @@ extern int DEBUGLEVEL; extern DOM_SID global_sam_sid; +extern fstring global_sam_name; +extern DOM_SID global_member_sid; +extern fstring global_myworkgroup; +extern DOM_SID global_sid_S_1_1; +extern DOM_SID global_sid_S_1_3; +extern DOM_SID global_sid_S_1_5; /*************************************************************************** lsa_reply_open_policy2 @@ -84,8 +90,8 @@ static void make_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) d_q->uni_dom_max_len = domlen * 2; d_q->uni_dom_str_len = domlen * 2; - d_q->buffer_dom_name = 4; /* domain buffer pointer */ - d_q->buffer_dom_sid = 2; /* domain sid pointer */ + d_q->buffer_dom_name = domlen != 0 ? 1 : 0; /* domain buffer pointer */ + d_q->buffer_dom_sid = dom_sid != NULL ? 1 : 0; /* domain sid pointer */ /* this string is supposed to be character short */ make_unistr2(&(d_q->uni_domain_name), dom_name, domlen); @@ -137,50 +143,70 @@ static void lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, /*************************************************************************** -make_dom_ref +make_dom_ref - adds a domain if it's not already in, returns the index ***************************************************************************/ -static void make_dom_ref(DOM_R_REF *ref, int num_domains, - char **dom_names, DOM_SID **dom_sids) +static int make_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) { - int i; + int num = 0; + int len; - if (num_domains > MAX_REF_DOMAINS) + if (dom_name != NULL) { - num_domains = MAX_REF_DOMAINS; + for (num = 0; num < ref->num_ref_doms_1; num++) + { + fstring domname; + fstrcpy(domname, unistr2_to_str(&ref->ref_dom[num].uni_dom_name)); + if (strequal(domname, dom_name)) + { + return num; + } + } + + } + else + { + num = ref->num_ref_doms_1; + } + + if (num >= MAX_REF_DOMAINS) + { + /* index not found, already at maximum domain limit */ + return -1; } ref->undoc_buffer = 1; - ref->num_ref_doms_1 = num_domains; + ref->num_ref_doms_1 = num+1; ref->undoc_buffer2 = 1; ref->max_entries = MAX_REF_DOMAINS; - ref->num_ref_doms_2 = num_domains; + ref->num_ref_doms_2 = num+1; - for (i = 0; i < num_domains; i++) - { - int len = dom_names[i] != NULL ? strlen(dom_names[i]) : 0; + len = dom_name != NULL ? strlen(dom_name) : 0; - make_uni_hdr(&(ref->hdr_ref_dom[i].hdr_dom_name), len, len, len != 0 ? 1 : 0); - ref->hdr_ref_dom[i].ptr_dom_sid = dom_sids[i] != NULL ? 1 : 0; + make_uni_hdr(&(ref->hdr_ref_dom[num].hdr_dom_name), len, len, len != 0 ? 1 : 0); + ref->hdr_ref_dom[num].ptr_dom_sid = dom_sid != NULL ? 1 : 0; - make_unistr2 (&(ref->ref_dom[i].uni_dom_name), dom_names[i], len); - make_dom_sid2(&(ref->ref_dom[i].ref_dom ), dom_sids [i]); - } + make_unistr2 (&(ref->ref_dom[num].uni_dom_name), dom_name, len); + make_dom_sid2(&(ref->ref_dom[num].ref_dom ), dom_sid ); + return num; } /*************************************************************************** make_reply_lookup_rids ***************************************************************************/ static void make_reply_lookup_rids(LSA_R_LOOKUP_RIDS *r_l, - int num_entries, uint32 dom_rids[MAX_LOOKUP_SIDS], - int num_ref_doms, - char **dom_names, DOM_SID **dom_sids) + int num_entries, + uint32 dom_rids[MAX_LOOKUP_SIDS], + uint8 dom_types[MAX_LOOKUP_SIDS]) { int i; - make_dom_ref(&(r_l->dom_ref), num_ref_doms, dom_names, dom_sids); + r_l->num_entries = 0; + r_l->undoc_buffer = 0; + r_l->num_entries2 = 0; +#if 0 r_l->num_entries = num_entries; r_l->undoc_buffer = 1; r_l->num_entries2 = num_entries; @@ -189,58 +215,85 @@ static void make_reply_lookup_rids(LSA_R_LOOKUP_RIDS *r_l, for (i = 0; i < num_entries; i++) { - make_dom_rid2(&(r_l->dom_rid[i]), dom_rids[i], 0x01); + make_dom_ref(&(r_l->dom_ref), dom_name, dom_sid); + make_dom_rid2(&(r_l->dom_rid[i]), dom_rids[i], dom_types[i]); } r_l->num_entries3 = num_entries; +#endif } /*************************************************************************** make_lsa_trans_names ***************************************************************************/ -static void make_lsa_trans_names(LSA_TRANS_NAME_ENUM *trn, +static void make_lsa_trans_names(DOM_R_REF *ref, + LSA_TRANS_NAME_ENUM *trn, int num_entries, DOM_SID2 sid[MAX_LOOKUP_SIDS], - uint32 *total) + uint32 *mapped_count) { - uint32 status = 0x0; int i; - (*total) = 0; + int total = 0; + (*mapped_count) = 0; SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS); for (i = 0; i < num_entries; i++) { + uint32 status = 0x0; + DOM_SID find_sid = sid[i].sid; + DOM_SID tmp = sid[i].sid; uint32 rid = 0xffffffff; - uint8 num_auths = sid[i].sid.num_auths; + int dom_idx = -1; fstring name; - uint32 type; + fstring dom_name; + uint8 sid_name_use = 0; - SMB_ASSERT_ARRAY(sid[i].sid.sub_auths, num_auths); + memset(dom_name, 0, sizeof(dom_name)); + memset(name , 0, sizeof(name )); - /* find the rid to look up */ - if (num_auths != 0) + if (map_domain_sid_to_name(&find_sid, dom_name)) + { + sid_name_use = SID_NAME_DOMAIN; + dom_idx = make_dom_ref(ref, dom_name, &find_sid); + } + else if (sid_split_rid (&find_sid, &rid) && + map_domain_sid_to_name(&find_sid, dom_name)) + { + if (sid_equal(&find_sid, &global_sam_sid)) + { + status = lookup_name(&tmp, name, &sid_name_use); + } + else + { + status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + } + } + else { - rid = sid[i].sid.sub_auths[num_auths-1]; - status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - - status = (status != 0x0) ? lookup_user_name (rid, name, &type) : status; - status = (status != 0x0) ? lookup_group_name(rid, name, &type) : status; - status = (status != 0x0) ? lookup_alias_name(rid, name, &type) : status; } + dom_idx = make_dom_ref(ref, dom_name, &find_sid); + if (status == 0x0) { - make_lsa_trans_name(&(trn->name [(*total)]), - &(trn->uni_name[(*total)]), - type, name, (*total)); - (*total)++; + (*mapped_count)++; + } + else + { + snprintf(name, sizeof(name), "%08x", rid); + sid_name_use = SID_NAME_UNKNOWN; + } + make_lsa_trans_name(&(trn->name [total]), + &(trn->uni_name[total]), + sid_name_use, name, dom_idx); + total++; } - trn->num_entries = (*total); + trn->num_entries = total; trn->ptr_trans_names = 1; - trn->num_entries2 = (*total); + trn->num_entries2 = total; } /*************************************************************************** @@ -260,9 +313,7 @@ static void make_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, lsa_reply_lookup_sids ***************************************************************************/ static void lsa_reply_lookup_sids(prs_struct *rdata, - int num_entries, DOM_SID2 sid[MAX_LOOKUP_SIDS], - int num_ref_doms, - char **dom_names, DOM_SID **dom_sids) + DOM_SID2 *sid, int num_entries) { LSA_R_LOOKUP_SIDS r_l; DOM_R_REF ref; @@ -274,8 +325,7 @@ static void lsa_reply_lookup_sids(prs_struct *rdata, ZERO_STRUCT(names); /* set up the LSA Lookup SIDs response */ - make_dom_ref(&ref, num_ref_doms, dom_names, dom_sids); - make_lsa_trans_names(&names, num_entries, sid, &mapped_count); + make_lsa_trans_names(&ref, &names, num_entries, sid, &mapped_count); make_reply_lookup_sids(&r_l, &ref, &names, mapped_count, 0x0); /* store the response in the SMB stream */ @@ -286,17 +336,17 @@ static void lsa_reply_lookup_sids(prs_struct *rdata, lsa_reply_lookup_rids ***************************************************************************/ static void lsa_reply_lookup_rids(prs_struct *rdata, - int num_entries, uint32 dom_rids[MAX_LOOKUP_SIDS], - int num_ref_doms, - char **dom_names, DOM_SID **dom_sids) + int num_entries, + uint32 dom_rids[MAX_LOOKUP_SIDS], + uint8 dom_types[MAX_LOOKUP_SIDS]) { LSA_R_LOOKUP_RIDS r_l; ZERO_STRUCT(r_l); /* set up the LSA Lookup RIDs response */ - make_reply_lookup_rids(&r_l, num_entries, dom_rids, - num_ref_doms, dom_names, dom_sids); + make_reply_lookup_rids(&r_l, num_entries, dom_rids, dom_types); + r_l.status = 0x0; /* store the response in the SMB stream */ @@ -365,17 +415,39 @@ static void api_lsa_query_info( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_QUERY_INFO q_i; - pstring dom_name; + fstring name; + DOM_SID *sid = NULL; + memset(name, 0, sizeof(name)); ZERO_STRUCT(q_i); /* grab the info class and policy handle */ lsa_io_q_query("", &q_i, data, 0); - pstrcpy(dom_name, lp_workgroup()); + switch (q_i.info_class) + { + case 0x03: + { + fstrcpy(name, global_myworkgroup); + sid = &global_member_sid; + break; + } + case 0x05: + { + fstrcpy(name, global_sam_name); + sid = &global_sam_sid; + break; + } + default: + { + DEBUG(5,("unknown info level in Lsa Query: %d\n", + q_i.info_class)); + break; + } + } /* construct reply. return status is always 0x0 */ - lsa_reply_query_info(&q_i, rdata, dom_name, &global_sam_sid); + lsa_reply_query_info(&q_i, rdata, name, sid); } /*************************************************************************** @@ -385,44 +457,13 @@ static void api_lsa_lookup_sids( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_LOOKUP_SIDS q_l; - pstring dom_name; - DOM_SID sid_S_1_1; - DOM_SID sid_S_1_3; - DOM_SID sid_S_1_5; - - DOM_SID *sid_array[4]; - char *dom_names[4]; - ZERO_STRUCT(q_l); - ZERO_STRUCT(sid_S_1_1); - ZERO_STRUCT(sid_S_1_3); - ZERO_STRUCT(sid_S_1_5); /* grab the info class and policy handle */ lsa_io_q_lookup_sids("", &q_l, data, 0); - pstrcpy(dom_name, lp_workgroup()); - - string_to_sid(&sid_S_1_1, "S-1-1"); - string_to_sid(&sid_S_1_3, "S-1-3"); - string_to_sid(&sid_S_1_5, "S-1-5"); - - dom_names[0] = dom_name; - sid_array[0] = &global_sam_sid; - - dom_names[1] = "Everyone"; - sid_array[1] = &sid_S_1_1; - - dom_names[2] = "don't know"; - sid_array[2] = &sid_S_1_3; - - dom_names[3] = "NT AUTHORITY"; - sid_array[3] = &sid_S_1_5; - /* construct reply. return status is always 0x0 */ - lsa_reply_lookup_sids(rdata, - q_l.sids.num_entries, q_l.sids.sid, /* SIDs */ - 4, dom_names, sid_array); + lsa_reply_lookup_sids(rdata, q_l.sids.sid, q_l.sids.num_entries); } /*************************************************************************** @@ -433,63 +474,24 @@ static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, { int i; LSA_Q_LOOKUP_RIDS q_l; - pstring dom_name; uint32 dom_rids[MAX_LOOKUP_SIDS]; - uint32 dummy_g_rid; - - DOM_SID sid_S_1_1; - DOM_SID sid_S_1_3; - DOM_SID sid_S_1_5; - - DOM_SID *sid_array[4]; - char *dom_names[4]; + uint8 dom_types[MAX_LOOKUP_SIDS]; ZERO_STRUCT(q_l); - ZERO_STRUCT(sid_S_1_1); - ZERO_STRUCT(sid_S_1_3); - ZERO_STRUCT(sid_S_1_5); ZERO_ARRAY(dom_rids); /* grab the info class and policy handle */ lsa_io_q_lookup_rids("", &q_l, data, 0); - pstrcpy(dom_name, lp_workgroup()); - - string_to_sid(&sid_S_1_1, "S-1-1"); - string_to_sid(&sid_S_1_3, "S-1-3"); - string_to_sid(&sid_S_1_5, "S-1-5"); - - dom_names[0] = dom_name; - sid_array[0] = &global_sam_sid; - - dom_names[1] = "Everyone"; - sid_array[1] = &sid_S_1_1; - - dom_names[2] = "don't know"; - sid_array[2] = &sid_S_1_3; - - dom_names[3] = "NT AUTHORITY"; - sid_array[3] = &sid_S_1_5; - SMB_ASSERT_ARRAY(q_l.lookup_name, q_l.num_entries); /* convert received RIDs to strings, so we can do them. */ for (i = 0; i < q_l.num_entries; i++) { - fstring user_name; - fstrcpy(user_name, unistr2(q_l.lookup_name[i].str.buffer)); - - /* - * Map to the UNIX username. - */ - map_username(user_name); - - /* - * Do any case conversions. - */ - (void)Get_Pwnam(user_name, True); + fstring name; + fstrcpy(name, unistr2(q_l.lookup_name[i].str.buffer)); - if (!pdb_name_to_rid(user_name, &dom_rids[i], &dummy_g_rid)) + if (lookup_rid(name, &dom_rids[i], &dom_types[i])) { /* WHOOPS! we should really do something about this... */ dom_rids[i] = 0; @@ -498,8 +500,9 @@ static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, /* construct reply. return status is always 0x0 */ lsa_reply_lookup_rids(rdata, - q_l.num_entries, dom_rids, /* text-converted SIDs */ - 4, dom_names, sid_array); + q_l.num_entries, + dom_rids, /* text-converted SIDs */ + dom_types); /* SID_NAME_USE types */ } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index b807c40604..dabc5520ff 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -290,7 +290,8 @@ BOOL close_lsa_policy_hnd(POLICY_HND *hnd) { struct policy *p = find_lsa_policy(hnd); - if (!p) { + if (!p) + { DEBUG(3,("Error closing policy\n")); return False; } @@ -302,6 +303,7 @@ BOOL close_lsa_policy_hnd(POLICY_HND *hnd) bitmap_clear(bmap, p->pnum); ZERO_STRUCTP(p); + ZERO_STRUCTP(hnd); free(p); diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 04118800e2..77b17dca2f 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -1,4 +1,3 @@ - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -544,7 +543,8 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, net_login_network: *************************************************************************/ static uint32 net_login_network(NET_ID_INFO_2 *id2, - struct smb_passwd *smb_pass) + struct smb_passwd *smb_pass, + user_struct *vuser) { DEBUG(5,("net_login_network: lm_len: %d nt_len: %d\n", id2->hdr_lm_chal_resp.str_str_len, @@ -593,221 +593,213 @@ static void api_net_sam_logon( uint16 vuid, prs_struct *data, prs_struct *rdata) { - NET_Q_SAM_LOGON q_l; - NET_ID_INFO_CTR ctr; - NET_USER_INFO_3 usr_info; - uint32 status = 0x0; - DOM_CRED srv_cred; - struct smb_passwd *smb_pass = NULL; - UNISTR2 *uni_samlogon_user = NULL; - - user_struct *vuser = NULL; - - if ((vuser = get_valid_user_struct(vuid)) == NULL) - return; - - q_l.sam_id.ctr = &ctr; - - net_io_q_sam_logon("", &q_l, data, 0); - - /* checks and updates credentials. creates reply credentials */ - if (!deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), - &(q_l.sam_id.client.cred), &srv_cred)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - else - { - memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); - } - - /* find the username */ - - if (status == 0) - { - switch (q_l.sam_id.logon_level) - { - case INTERACTIVE_LOGON_TYPE: - { - uni_samlogon_user = &(q_l.sam_id.ctr->auth.id1.uni_user_name); - - DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); - break; - } - case NET_LOGON_TYPE: - { - uni_samlogon_user = &(q_l.sam_id.ctr->auth.id2.uni_user_name); - - DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); - break; - } - default: - { - DEBUG(2,("SAM Logon: unsupported switch value\n")); - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; - break; - } - } /* end switch */ - } /* end if status == 0 */ - - /* check username exists */ - - if (status == 0) - { - pstrcpy(samlogon_user, unistrn2(uni_samlogon_user->buffer, - uni_samlogon_user->uni_str_len)); - - DEBUG(3,("User:[%s]\n", samlogon_user)); + NET_Q_SAM_LOGON q_l; + NET_ID_INFO_CTR ctr; + NET_USER_INFO_3 usr_info; + uint32 status = 0x0; + DOM_CRED srv_cred; + struct smb_passwd *smb_pass = NULL; + UNISTR2 *uni_samlogon_user = NULL; - /* - * Convert to a UNIX username. - */ - map_username(samlogon_user); + user_struct *vuser = NULL; - /* - * Do any case conversions. - */ - (void)Get_Pwnam(samlogon_user, True); - - become_root(True); - smb_pass = getsmbpwnam(samlogon_user); - unbecome_root(True); - - if (smb_pass == NULL) - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - else if (smb_pass->acct_ctrl & ACB_PWNOTREQ) - status = 0; - else if (smb_pass->acct_ctrl & ACB_DISABLED) - status = 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED; - } - - /* Validate password - if required. */ - - if ((status == 0) && !(smb_pass->acct_ctrl & ACB_PWNOTREQ)) - { - switch (q_l.sam_id.logon_level) - { - case INTERACTIVE_LOGON_TYPE: - { - /* interactive login. */ - status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, smb_pass, vuser); - break; - } - case NET_LOGON_TYPE: - { - /* network login. lm challenge and 24 byte responses */ - status = net_login_network(&q_l.sam_id.ctr->auth.id2, smb_pass); - break; - } - } - } - - /* 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 :-) */ - - if (status == 0) - { - DOM_GID *gids = NULL; - int num_gids = 0; - NTTIME dummy_time; - pstring logon_script; - pstring profile_path; - pstring home_dir; - pstring home_drive; - 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; - - /* 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(logon_script, lp_logon_script()); - pstrcpy(profile_path, lp_logon_path()); - - pstrcpy(my_workgroup, lp_workgroup()); - - pstrcpy(home_drive, lp_logon_drive()); - pstrcpy(home_dir, lp_logon_home()); - - pstrcpy(my_name, global_myname); - strupper(my_name); + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return; - /* - * This is the point at which we get the group - * database - we should be getting the gid_t list - * from /etc/group and then turning the uids into - * rids and then into machine sids for this user. - * JRA. - */ + q_l.sam_id.ctr = &ctr; - get_domain_user_groups(domain_groups, samlogon_user); + net_io_q_sam_logon("", &q_l, data, 0); - /* - * make_dom_gids allocates the gids array. JRA. - */ - gids = NULL; - num_gids = make_dom_gids(domain_groups, &gids); - - sam_logon_in_ssb = False; - - if (pdb_name_to_rid(samlogon_user, &r_uid, &r_gid)) - { - make_net_user_info3(&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 */ - - samlogon_user , /* user_name */ - vuser->real_name, /* full_name */ - logon_script , /* logon_script */ - profile_path , /* profile_path */ - home_dir , /* home_dir */ - home_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 - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - } - - /* Free any allocated groups array. */ - if(gids) - free((char *)gids); - } - - net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status); + /* checks and updates credentials. creates reply credentials */ + if (!deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), + &(q_l.sam_id.client.cred), &srv_cred)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + else + { + memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); + } + + /* find the username */ + + if (status == 0) + { + switch (q_l.sam_id.logon_level) + { + case INTERACTIVE_LOGON_TYPE: + { + uni_samlogon_user = &(q_l.sam_id.ctr->auth.id1.uni_user_name); + + DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); + break; + } + case NET_LOGON_TYPE: + { + uni_samlogon_user = &(q_l.sam_id.ctr->auth.id2.uni_user_name); + + DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); + break; + } + default: + { + DEBUG(2,("SAM Logon: unsupported switch value\n")); + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + break; + } + } /* end switch */ + } /* end if status == 0 */ + + /* check username exists */ + + if (status == 0) + { + pstrcpy(samlogon_user, unistrn2(uni_samlogon_user->buffer, + uni_samlogon_user->uni_str_len)); + + DEBUG(3,("User:[%s]\n", samlogon_user)); + + /* + * Convert to a UNIX username. + */ + map_username(samlogon_user); + + /* + * Do any case conversions. + */ + (void)Get_Pwnam(samlogon_user, True); + + become_root(True); + smb_pass = getsmbpwnam(samlogon_user); + unbecome_root(True); + + if (smb_pass == NULL) + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + } + else if (IS_BITS_SET_ALL(smb_pass->acct_ctrl, ACB_DISABLED) && + IS_BITS_CLR_ALL(smb_pass->acct_ctrl, ACB_PWNOTREQ)) + { + status = 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED; + } + } + + /* validate password - if required */ + + if (status == 0 && !(IS_BITS_SET_ALL(smb_pass->acct_ctrl, ACB_PWNOTREQ))) + { + switch (q_l.sam_id.logon_level) + { + case INTERACTIVE_LOGON_TYPE: + { + /* interactive login. */ + status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, smb_pass, vuser); + break; + } + case NET_LOGON_TYPE: + { + /* network login. lm challenge and 24 byte responses */ + status = net_login_network(&q_l.sam_id.ctr->auth.id2, smb_pass, vuser); + break; + } + } + } + + /* 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 :-) */ + + if (status == 0) + { + DOM_GID *gids = NULL; + int num_gids = 0; + NTTIME dummy_time; + pstring logon_script; + pstring profile_path; + pstring home_dir; + pstring home_drive; + pstring my_name; + pstring my_workgroup; + DOMAIN_GRP *grp_mem; + 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; + + /* 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(logon_script, lp_logon_script()); + pstrcpy(profile_path, lp_logon_path()); + + pstrcpy(my_workgroup, lp_workgroup()); + + pstrcpy(home_drive, lp_logon_drive()); + pstrcpy(home_dir, lp_logon_home()); + pstrcpy(my_name, global_myname); + strupper(my_name); + + status = lookup_user_rids(samlogon_user, &r_uid, &r_gid); + status = status == 0 ? getusergroupsnam(samlogon_user, &grp_mem, &num_gids) : 0xC0000000 | NT_STATUS_INVALID_PRIMARY_GROUP; + + if (status == 0x0) + { + gids = NULL; + num_gids = make_dom_gids(grp_mem, num_gids, &gids); + + make_net_user_info3(&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 */ + + samlogon_user , /* user_name */ + vuser->real_name, /* full_name */ + logon_script , /* logon_script */ + profile_path , /* profile_path */ + home_dir , /* home_dir */ + home_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 + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + } + + /* Free any allocated groups array. */ + if (gids) + { + free((char *)gids); + } + } + + net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status); } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 323298ef7a..b70a71b5c0 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -30,9 +30,11 @@ extern int DEBUGLEVEL; extern BOOL sam_logon_in_ssb; extern pstring samlogon_user; -extern fstring global_myworkgroup; +extern fstring global_sam_name; extern pstring global_myname; extern DOM_SID global_sam_sid; +extern DOM_SID global_sid_S_1_1; +extern DOM_SID global_sid_S_1_5_20; extern rid_name domain_group_rids[]; extern rid_name domain_alias_rids[]; @@ -79,8 +81,8 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, user_name_len = strlen(pwd->smb_name); make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len); - make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len, - user_name_len, 1); + make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len-1, + user_name_len-1, 1); pw_buf[(*num_entries)].user_rid = pwd->user_rid; bzero( pw_buf[(*num_entries)].nt_pwd , 16); @@ -292,24 +294,21 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, if (status == 0x0) { - DOM_SID user_sid; - DOM_SID everyone_sid; + DOM_SID usr_sid; - user_sid = global_sam_sid; + usr_sid = global_sam_sid; - SMB_ASSERT_ARRAY(user_sid.sub_auths, user_sid.num_auths+1); + SMB_ASSERT_ARRAY(usr_sid.sub_auths, usr_sid.num_auths+1); /* * Add the user RID. */ - user_sid.sub_auths[user_sid.num_auths++] = rid; + sid_append_rid(&usr_sid, rid); - string_to_sid(&everyone_sid, "S-1-1"); - - /* maybe need another 1 or 2 (S-1-5-0x20-0x220 and S-1-5-20-0x224) */ - /* these two are DOMAIN_ADMIN and DOMAIN_ACCT_OP group RIDs */ - make_dom_sid3(&(sid[0]), 0x035b, 0x0002, &everyone_sid); - make_dom_sid3(&(sid[1]), 0x0044, 0x0002, &user_sid); + /* maybe need another 1 or 2 (S-1-5-0x20-0x220 and S-1-5-20-0x224) */ + /* these two are DOMAIN_ADMIN and DOMAIN_ACCT_OP group RIDs */ + make_dom_sid3(&(sid[0]), 0x035b, 0x0002, &global_sid_S_1_1); + make_dom_sid3(&(sid[1]), 0x0044, 0x0002, &usr_sid); } make_samr_r_unknown_3(&r_u, @@ -400,37 +399,92 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, prs_struct *rdata) { SAMR_R_ENUM_DOM_GROUPS r_e; - SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; - int num_entries; + DOMAIN_GRP *grps = NULL; + int num_entries = 0; BOOL got_grps; - char *dummy_group = "Domain Admins"; + DOM_SID sid; + fstring sid_str; r_e.status = 0x0; r_e.num_entries = 0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &sid)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } - DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); + sid_to_string(sid_str, &sid); + + DEBUG(5,("samr_reply_enum_dom_groups: sid %s\n", sid_str)); + + /* well-known groups */ + if (sid_equal(&sid, &global_sid_S_1_5_20)) + { + char *name; + got_grps = True; + + while (num_entries < MAX_SAM_ENTRIES && ((name = domain_group_rids[num_entries].name) != NULL)) + { + DOMAIN_GRP tmp_grp; + + fstrcpy(tmp_grp.name , name); + fstrcpy(tmp_grp.comment, ""); + tmp_grp.rid = domain_group_rids[num_entries].rid; + tmp_grp.attr = 0x7; + + if (!add_domain_group(&grps, &num_entries, &tmp_grp)) + { + r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; + break; + } + } + } + else if (sid_equal(&sid, &global_sam_sid)) + { + BOOL ret; + char *name; + got_grps = True; + + while (num_entries < MAX_SAM_ENTRIES && ((name = domain_group_rids[num_entries].name) != NULL)) + { + DOMAIN_GRP tmp_grp; + + fstrcpy(tmp_grp.name , name); + fstrcpy(tmp_grp.comment, ""); + tmp_grp.rid = domain_group_rids[num_entries].rid; + tmp_grp.attr = 0x7; - got_grps = True; - num_entries = 1; - make_unistr2(&(pass[0].uni_user_name), dummy_group, strlen(dummy_group)); - pass[0].user_rid = DOMAIN_GROUP_RID_ADMINS; + if (!add_domain_group(&grps, &num_entries, &tmp_grp)) + { + r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; + break; + } + } + + become_root(True); + ret = enumdomgroups(&grps, &num_entries); + unbecome_root(True); + if (!ret) + { + r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; + } + } if (r_e.status == 0 && got_grps) { - make_samr_r_enum_dom_groups(&r_e, q_u->start_idx, num_entries, pass, r_e.status); + make_samr_r_enum_dom_groups(&r_e, q_u->start_idx, num_entries, grps, r_e.status); } /* store the response in the SMB stream */ samr_io_r_enum_dom_groups("", &r_e, rdata, 0); - DEBUG(5,("samr_enum_dom_groups: %d\n", __LINE__)); + if (grps != NULL) + { + free(grps); + } + DEBUG(5,("samr_enum_dom_groups: %d\n", __LINE__)); } /******************************************************************* @@ -455,11 +509,10 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, prs_struct *rdata) { SAMR_R_ENUM_DOM_ALIASES r_e; - SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; + LOCAL_GRP *alss = NULL; int num_entries = 0; DOM_SID sid; fstring sid_str; - fstring sam_sid_str; r_e.status = 0x0; r_e.num_entries = 0; @@ -471,34 +524,57 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, } sid_to_string(sid_str, &sid); - sid_to_string(sam_sid_str, &global_sam_sid); DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", sid_str)); /* well-known aliases */ - if (strequal(sid_str, "S-1-5-32")) + if (sid_equal(&sid, &global_sid_S_1_5_20)) { char *name; - while (num_entries < MAX_SAM_ENTRIES && ((name = builtin_alias_rids[num_entries].name) != NULL)) + + while ((name = builtin_alias_rids[num_entries].name) != NULL) { - make_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)); - pass[num_entries].user_rid = builtin_alias_rids[num_entries].rid; - num_entries++; + LOCAL_GRP tmp_als; + + fstrcpy(tmp_als.name , name); + fstrcpy(tmp_als.comment, ""); + tmp_als.rid = builtin_alias_rids[num_entries].rid; + + if (!add_domain_alias(&alss, &num_entries, &tmp_als)) + { + r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; + break; + } } } - else if (strequal(sid_str, sam_sid_str)) + else if (sid_equal(&sid, &global_sam_sid)) { + BOOL ret; /* local aliases */ - /* oops! there's no code to deal with this */ - DEBUG(3,("samr_reply_enum_dom_aliases: enum of aliases in our domain not supported yet\n")); num_entries = 0; + + become_root(True); + ret = enumdomaliases(&alss, &num_entries); + unbecome_root(True); + if (!ret) + { + r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; + } } - make_samr_r_enum_dom_aliases(&r_e, num_entries, pass, r_e.status); + if (r_e.status == 0x0) + { + make_samr_r_enum_dom_aliases(&r_e, num_entries, alss, r_e.status); + } /* store the response in the SMB stream */ samr_io_r_enum_dom_aliases("", &r_e, rdata, 0); + if (alss != NULL) + { + free(alss); + } + DEBUG(5,("samr_enum_dom_aliases: %d\n", __LINE__)); } @@ -669,50 +745,92 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, { uint32 rid[MAX_SAM_ENTRIES]; uint32 status = 0; - int num_rids = q_u->num_sids1; + int num_rids = 0; + int i; + struct sam_passwd *sam_pass; + DOM_SID usr_sid; + DOM_SID dom_sid; + uint32 user_rid; + fstring sam_sid_str; + fstring dom_sid_str; + fstring usr_sid_str; SAMR_R_LOOKUP_IDS r_u; DEBUG(5,("samr_lookup_ids: %d\n", __LINE__)); + /* find the policy handle. open a policy on it. */ + if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &dom_sid)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + else + { + sid_to_string(dom_sid_str, &dom_sid ); + sid_to_string(sam_sid_str, &global_sam_sid); + } + if (num_rids > MAX_SAM_ENTRIES) { num_rids = MAX_SAM_ENTRIES; DEBUG(5,("samr_lookup_ids: truncating entries to %d\n", num_rids)); } -#if 0 - int i; - SMB_ASSERT_ARRAY(q_u->uni_user_name, num_rids); - - for (i = 0; i < num_rids && status == 0; i++) + if (status == 0x0) { - struct sam_passwd *sam_pass; - fstring user_name; - + usr_sid = q_u->sid[0].sid; + sid_split_rid(&usr_sid, &user_rid); + sid_to_string(usr_sid_str, &usr_sid); - fstrcpy(user_name, unistrn2(q_u->uni_user_name[i].buffer, - q_u->uni_user_name[i].uni_str_len)); + } + if (status == 0x0) + { /* find the user account */ become_root(True); - sam_pass = get_smb21pwd_entry(user_name, 0); + sam_pass = getsam21pwrid(user_rid); unbecome_root(True); if (sam_pass == NULL) { status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - rid[i] = 0; + num_rids = 0; + } + } + + if (status == 0x0) + { + if (sid_equal(&dom_sid, &global_sid_S_1_5_20)) + { + DEBUG(5,("lookup on S-1-5-20\n")); + } + else if (sid_equal(&dom_sid, &usr_sid)) + { + DOMAIN_GRP *mem_grp = NULL; + BOOL ret; + + DEBUG(5,("lookup on Domain SID\n")); + + become_root(True); + ret = getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_rids); + unbecome_root(True); + + num_rids = MIN(num_rids, MAX_SAM_ENTRIES); + + if (mem_grp != NULL) + { + for (i = 0; i < num_rids; i++) + { + rid[i] = mem_grp[i].rid; + } + free(mem_grp); + } } else { - rid[i] = sam_pass->user_rid; + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; } } -#endif - - num_rids = 1; - rid[0] = BUILTIN_ALIAS_RID_USERS; make_samr_r_lookup_ids(&r_u, num_rids, rid, status); @@ -743,7 +861,8 @@ static void api_samr_lookup_ids( uint16 vuid, prs_struct *data, prs_struct *rdat static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, prs_struct *rdata) { - uint32 rid[MAX_SAM_ENTRIES]; + uint32 rid [MAX_SAM_ENTRIES]; + uint8 type[MAX_SAM_ENTRIES]; uint32 status = 0; int i; int num_rids = q_u->num_rids1; @@ -763,17 +882,12 @@ static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, for (i = 0; i < num_rids && status == 0; i++) { fstring name; - - status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - fstrcpy(name, unistrn2(q_u->uni_user_name[i].buffer, q_u->uni_user_name[i].uni_str_len)); - status = (status != 0x0) ? lookup_user_rid (name, &(rid[i])) : status; - status = (status != 0x0) ? lookup_group_rid(name, &(rid[i])) : status; - status = (status != 0x0) ? lookup_alias_rid(name, &(rid[i])) : status; + status = lookup_rid(name, &(rid[i]), &(type[i])); } - make_samr_r_lookup_names(&r_u, num_rids, rid, status); + make_samr_r_lookup_names(&r_u, num_rids, rid, type, status); /* store the response in the SMB stream */ samr_io_r_lookup_names("", &r_u, rdata, 0); @@ -1017,7 +1131,7 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) { struct smb_passwd *smb_pass; - if (!pdb_rid_is_user(user_rid)) + if (!pwdb_rid_is_user(user_rid)) { DEBUG(4,("RID 0x%x is not a user RID\n", user_rid)); return False; @@ -1050,7 +1164,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) LOGON_HRS hrs; int i; - if (!pdb_rid_is_user(user_rid)) + if (!pwdb_rid_is_user(user_rid)) { DEBUG(4,("RID 0x%x is not a user RID\n", user_rid)); return False; @@ -1255,10 +1369,20 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, if (status == 0x0) { - pstring groups; - get_domain_user_groups(groups, sam_pass->smb_name); + DOMAIN_GRP *mem_grp = NULL; + BOOL ret; + + become_root(True); + ret = getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_groups); + unbecome_root(True); + gids = NULL; - num_groups = make_dom_gids(groups, &gids); + num_groups = make_dom_gids(mem_grp, num_groups, &gids); + + if (mem_grp != NULL) + { + free(mem_grp); + } } /* construct the response. lkclXXXX: gids are not copied! */ @@ -1322,7 +1446,7 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, case 0x02: { switch_value = 0x2; - make_unk_info2(&ctr.info.inf2, global_myworkgroup, global_myname); + make_unk_info2(&ctr.info.inf2, global_sam_name, global_myname); break; } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 097ab92d76..25dceb41a0 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -22,325 +22,4 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* this module apparently provides an implementation of DCE/RPC over a - * named pipe (IPC$ connection using SMBtrans). details of DCE/RPC - * documentation are available (in on-line form) from the X-Open group. - * - * this module should provide a level of abstraction between SMB - * and DCE/RPC, while minimising the amount of mallocs, unnecessary - * data copies, and network traffic. - * - * in this version, which takes a "let's learn what's going on and - * get something running" approach, there is additional network - * traffic generated, but the code should be easier to understand... - * - * ... if you read the docs. or stare at packets for weeks on end. - * - */ - -#include "includes.h" -#include "nterr.h" - -extern int DEBUGLEVEL; - -/* - * A list of the rids of well known BUILTIN and Domain users - * and groups. - */ - -rid_name builtin_alias_rids[] = -{ - { BUILTIN_ALIAS_RID_ADMINS , "Administrators" }, - { BUILTIN_ALIAS_RID_USERS , "Users" }, - { BUILTIN_ALIAS_RID_GUESTS , "Guests" }, - { BUILTIN_ALIAS_RID_POWER_USERS , "Power Users" }, - - { BUILTIN_ALIAS_RID_ACCOUNT_OPS , "Account Operators" }, - { BUILTIN_ALIAS_RID_SYSTEM_OPS , "System Operators" }, - { BUILTIN_ALIAS_RID_PRINT_OPS , "Print Operators" }, - { BUILTIN_ALIAS_RID_BACKUP_OPS , "Backup Operators" }, - { BUILTIN_ALIAS_RID_REPLICATOR , "Replicator" }, - { 0 , NULL } -}; - -/* array lookup of well-known Domain RID users. */ -rid_name domain_user_rids[] = -{ - { DOMAIN_USER_RID_ADMIN , "Administrator" }, - { DOMAIN_USER_RID_GUEST , "Guest" }, - { 0 , NULL } -}; - -/* array lookup of well-known Domain RID groups. */ -rid_name domain_group_rids[] = -{ - { DOMAIN_GROUP_RID_ADMINS , "Domain Admins" }, - { DOMAIN_GROUP_RID_USERS , "Domain Users" }, - { DOMAIN_GROUP_RID_GUESTS , "Domain Guests" }, - { 0 , NULL } -}; - -int make_dom_gids(char *gids_str, DOM_GID **ppgids) -{ - char *ptr; - pstring s2; - int count; - DOM_GID *gids; - - *ppgids = NULL; - - DEBUG(4,("make_dom_gids: %s\n", gids_str)); - - if (gids_str == NULL || *gids_str == 0) - return 0; - - for (count = 0, ptr = gids_str; - next_token(&ptr, s2, NULL, sizeof(s2)); - count++) - ; - - gids = (DOM_GID *)malloc( sizeof(DOM_GID) * count ); - if(!gids) - { - DEBUG(0,("make_dom_gids: malloc fail !\n")); - return 0; - } - - for (count = 0, ptr = gids_str; - next_token(&ptr, s2, NULL, sizeof(s2)) && - count < LSA_MAX_GROUPS; - count++) - { - /* the entries are of the form GID/ATTR, ATTR being optional.*/ - char *attr; - uint32 rid = 0; - int i; - - attr = strchr(s2,'/'); - if (attr) - *attr++ = 0; - - if (!attr || !*attr) - attr = "7"; /* default value for attribute is 7 */ - - /* look up the RID string and see if we can turn it into a rid number */ - for (i = 0; builtin_alias_rids[i].name != NULL; i++) - { - if (strequal(builtin_alias_rids[i].name, s2)) - { - rid = builtin_alias_rids[i].rid; - break; - } - } - - if (rid == 0) - rid = atoi(s2); - - if (rid == 0) - { - DEBUG(1,("make_dom_gids: unknown well-known alias RID %s/%s\n", s2, attr)); - count--; - } - else - { - gids[count].g_rid = rid; - gids[count].attr = atoi(attr); - - DEBUG(5,("group id: %d attr: %d\n", gids[count].g_rid, gids[count].attr)); - } - } - - *ppgids = gids; - return count; -} - - -/******************************************************************* - gets a domain user's groups - ********************************************************************/ -void get_domain_user_groups(char *domain_groups, char *user) -{ - pstring tmp; - - if (domain_groups == NULL || user == NULL) return; - - /* any additional groups this user is in. e.g power users */ - pstrcpy(domain_groups, lp_domain_groups()); - - /* can only be a user or a guest. cannot be guest _and_ admin */ - if (user_in_list(user, lp_domain_guest_group())) - { - slprintf(tmp, sizeof(tmp) - 1, " %ld/7 ", DOMAIN_GROUP_RID_GUESTS); - pstrcat(domain_groups, tmp); - - DEBUG(3,("domain guest group access %s granted\n", tmp)); - } - else - { - slprintf(tmp, sizeof(tmp) -1, " %ld/7 ", DOMAIN_GROUP_RID_USERS); - pstrcat(domain_groups, tmp); - - DEBUG(3,("domain group access %s granted\n", tmp)); - - if (user_in_list(user, lp_domain_admin_group())) - { - slprintf(tmp, sizeof(tmp) - 1, " %ld/7 ", DOMAIN_GROUP_RID_ADMINS); - pstrcat(domain_groups, tmp); - - DEBUG(3,("domain admin group access %s granted\n", tmp)); - } - } -} - - -/******************************************************************* - lookup_group_name - ********************************************************************/ -uint32 lookup_group_name(uint32 rid, char *group_name, uint32 *type) -{ - int i = 0; - (*type) = SID_NAME_DOM_GRP; - - DEBUG(5,("lookup_group_name: rid: %d", rid)); - - while (domain_group_rids[i].rid != rid && domain_group_rids[i].rid != 0) - { - i++; - } - - if (domain_group_rids[i].rid != 0) - { - fstrcpy(group_name, domain_group_rids[i].name); - DEBUG(5,(" = %s\n", group_name)); - return 0x0; - } - - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_alias_name - ********************************************************************/ -uint32 lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) -{ - int i = 0; - (*type) = SID_NAME_WKN_GRP; - - DEBUG(5,("lookup_alias_name: rid: %d", rid)); - - while (builtin_alias_rids[i].rid != rid && builtin_alias_rids[i].rid != 0) - { - i++; - } - - if (builtin_alias_rids[i].rid != 0) - { - fstrcpy(alias_name, builtin_alias_rids[i].name); - DEBUG(5,(" = %s\n", alias_name)); - return 0x0; - } - - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_user_name - ********************************************************************/ -uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) -{ - struct sam_disp_info *disp_info; - int i = 0; - (*type) = SID_NAME_USER; - - DEBUG(5,("lookup_user_name: rid: %d", rid)); - - /* look up the well-known domain user rids first */ - while (domain_user_rids[i].rid != rid && domain_user_rids[i].rid != 0) - { - i++; - } - - if (domain_user_rids[i].rid != 0) - { - fstrcpy(user_name, domain_user_rids[i].name); - DEBUG(5,(" = %s\n", user_name)); - return 0x0; - } - - /* ok, it's a user. find the user account */ - become_root(True); - disp_info = getsamdisprid(rid); - unbecome_root(True); - - if (disp_info != NULL) - { - fstrcpy(user_name, disp_info->smb_name); - DEBUG(5,(" = %s\n", user_name)); - return 0x0; - } - - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_group_rid - ********************************************************************/ -uint32 lookup_group_rid(char *group_name, uint32 *rid) -{ - char *grp_name; - int i = -1; /* start do loop at -1 */ - - do /* find, if it exists, a group rid for the group name*/ - { - i++; - (*rid) = domain_group_rids[i].rid; - grp_name = domain_group_rids[i].name; - - } while (grp_name != NULL && !strequal(grp_name, group_name)); - - return (grp_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_alias_rid - ********************************************************************/ -uint32 lookup_alias_rid(char *alias_name, uint32 *rid) -{ - char *als_name; - int i = -1; /* start do loop at -1 */ - - do /* find, if it exists, a alias rid for the alias name*/ - { - i++; - (*rid) = builtin_alias_rids[i].rid; - als_name = builtin_alias_rids[i].name; - - } while (als_name != NULL && !strequal(als_name, alias_name)); - - return (als_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_user_rid - ********************************************************************/ -uint32 lookup_user_rid(char *user_name, uint32 *rid) -{ - struct sam_passwd *sam_pass; - (*rid) = 0; - - /* find the user account */ - become_root(True); - sam_pass = getsam21pwnam(user_name); - unbecome_root(True); - - if (sam_pass != NULL) - { - (*rid) = sam_pass->user_rid; - return 0x0; - } - - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} +/* retired module */ -- cgit From 5ae9b412351804929eda2ed9070c21d5a9bcf024 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 17 Nov 1998 18:01:43 +0000 Subject: make_uni_hdr() reverted accidentally with a -1 on username length (This used to be commit 7da1b0bb511e6c5e44ab83759914134cf91f6f78) --- source3/rpc_server/srv_samr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index b70a71b5c0..68c51a860a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -81,8 +81,8 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, user_name_len = strlen(pwd->smb_name); make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len); - make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len-1, - user_name_len-1, 1); + make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len, + user_name_len, 1); pw_buf[(*num_entries)].user_rid = pwd->user_rid; bzero( pw_buf[(*num_entries)].nt_pwd , 16); -- cgit From 4e8eaa6bafb3bd4237b5644eca0a4ac0ca289e8d Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 17 Nov 1998 18:50:14 +0000 Subject: somehow this file got missed in the groupdb commit. (This used to be commit 06da8e49f1cf5d6b954f586f6720ade1c5b8de74) --- source3/rpc_server/srv_lookup.c | 123 ++++++++++++++++++++++++++++------------ 1 file changed, 88 insertions(+), 35 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index e6df9933bf..4f09360d93 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -170,13 +170,13 @@ int get_domain_user_groups(DOMAIN_GRP_MEMBER **grp_members, uint32 group_rid) /******************************************************************* lookup_builtin_names ********************************************************************/ -uint32 lookup_builtin_names(uint32 rid, char *name, uint8 *type) +uint32 lookup_builtin_names(DOM_SID *sid, char *name, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_wk_user_name (rid, name, type) : status; - status = (status != 0x0) ? lookup_wk_group_name(rid, name, type) : status; - status = (status != 0x0) ? lookup_wk_alias_name(rid, name, type) : status; + status = (status != 0x0) ? lookup_wk_user_name (sid, name, type) : status; + status = (status != 0x0) ? lookup_wk_group_name(sid, name, type) : status; + status = (status != 0x0) ? lookup_wk_alias_name(sid, name, type) : status; return status; } @@ -185,13 +185,13 @@ uint32 lookup_builtin_names(uint32 rid, char *name, uint8 *type) /******************************************************************* lookup_added_name - names that have been added to the SAM database by admins. ********************************************************************/ -uint32 lookup_added_name(uint32 rid, char *name, uint8 *type) +uint32 lookup_added_name(DOM_SID *sid, char *name, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_user_name (rid, name, type) : status; - status = (status != 0x0) ? lookup_group_name(rid, name, type) : status; - status = (status != 0x0) ? lookup_alias_name(rid, name, type) : status; + status = (status != 0x0) ? lookup_user_name (sid, name, type) : status; + status = (status != 0x0) ? lookup_group_name(sid, name, type) : status; + status = (status != 0x0) ? lookup_alias_name(sid, name, type) : status; return status; } @@ -200,12 +200,12 @@ uint32 lookup_added_name(uint32 rid, char *name, uint8 *type) /******************************************************************* lookup_name ********************************************************************/ -uint32 lookup_name(uint32 rid, char *name, uint8 *type) +uint32 lookup_name(DOM_SID *sid, char *name, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_builtin_names(rid, name, type) : status; - status = (status != 0x0) ? lookup_added_name (rid, name, type) : status; + status = (status != 0x0) ? lookup_builtin_names(sid, name, type) : status; + status = (status != 0x0) ? lookup_added_name (sid, name, type) : status; return status; } @@ -214,11 +214,22 @@ uint32 lookup_name(uint32 rid, char *name, uint8 *type) /******************************************************************* lookup_wk_group_name ********************************************************************/ -uint32 lookup_wk_group_name(uint32 rid, char *group_name, uint8 *type) +uint32 lookup_wk_group_name(DOM_SID *sid, char *group_name, uint8 *type) { int i = 0; + uint32 rid; + DOM_SID tmp; + (*type) = SID_NAME_WKN_GRP; + sid_copy(&tmp, sid); + sid_split_rid(&tmp, &rid); + + if (!sid_equal(&global_sid_S_1_5_20, &tmp)) + { + return 0xC0000000 | NT_STATUS_NONE_MAPPED; + } + DEBUG(5,("lookup_wk_group_name: rid: %d", rid)); while (domain_group_rids[i].rid != rid && domain_group_rids[i].rid != 0) @@ -240,19 +251,25 @@ uint32 lookup_wk_group_name(uint32 rid, char *group_name, uint8 *type) /******************************************************************* lookup_group_name ********************************************************************/ -uint32 lookup_group_name(uint32 rid, char *group_name, uint8 *type) +uint32 lookup_group_name(DOM_SID *sid, char *group_name, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - DOM_SID sid; + uint32 rid; + DOM_SID tmp; - DEBUG(5,("lookup_group_name: rid: 0x%x", rid)); + (*type) = SID_NAME_DOM_GRP; - sid_copy (&sid, &global_sam_sid); - sid_append_rid(&sid, rid); + sid_copy(&tmp, sid); + sid_split_rid(&tmp, &rid); - (*type) = SID_NAME_DOM_GRP; + if (!sid_equal(&global_sid_S_1_5_20, &tmp)) + { + return status; + } + + DEBUG(5,("lookup_group_name: rid: 0x%x", rid)); - if (map_group_sid_to_name(&sid, group_name, NULL)) + if (map_group_sid_to_name(sid, group_name, NULL)) { status = 0x0; } @@ -272,11 +289,22 @@ uint32 lookup_group_name(uint32 rid, char *group_name, uint8 *type) /******************************************************************* lookup_wk_alias_name ********************************************************************/ -uint32 lookup_wk_alias_name(uint32 rid, char *alias_name, uint8 *type) +uint32 lookup_wk_alias_name(DOM_SID *sid, char *alias_name, uint8 *type) { int i = 0; + uint32 rid; + DOM_SID tmp; + (*type) = SID_NAME_ALIAS; + sid_copy(&tmp, sid); + sid_split_rid(&tmp, &rid); + + if (!sid_equal(&global_sid_S_1_5_20, &tmp)) + { + return 0xC0000000 | NT_STATUS_NONE_MAPPED; + } + DEBUG(5,("lookup_wk_alias_name: rid: %d", rid)); while (builtin_alias_rids[i].rid != rid && builtin_alias_rids[i].rid != 0) @@ -298,11 +326,14 @@ uint32 lookup_wk_alias_name(uint32 rid, char *alias_name, uint8 *type) /******************************************************************* lookup_alias_name ********************************************************************/ -uint32 lookup_alias_name(uint32 rid, char *alias_name, uint8 *type) +uint32 lookup_alias_name(DOM_SID *sid, char *alias_name, uint8 *type) { + fstring sid_str; (*type) = SID_NAME_ALIAS; - DEBUG(2,("lookup_alias_name: rid: %d\n", rid)); + sid_to_string(sid_str, sid); + + DEBUG(2,("lookup_alias_name: sid: %d\n", sid_str)); DEBUG(2,(" NOT IMPLEMENTED\n")); return 0xC0000000 | NT_STATUS_NONE_MAPPED; @@ -311,11 +342,22 @@ uint32 lookup_alias_name(uint32 rid, char *alias_name, uint8 *type) /******************************************************************* lookup well-known user name ********************************************************************/ -uint32 lookup_wk_user_name(uint32 rid, char *user_name, uint8 *type) +uint32 lookup_wk_user_name(DOM_SID *sid, char *user_name, uint8 *type) { int i = 0; + uint32 rid; + DOM_SID tmp; + (*type) = SID_NAME_USER; + sid_copy(&tmp, sid); + sid_split_rid(&tmp, &rid); + + if (!sid_equal(&global_sid_S_1_5_20, &tmp)) + { + return 0xC0000000 | NT_STATUS_NONE_MAPPED; + } + DEBUG(5,("lookup_wk_user_name: rid: %d", rid)); /* look up the well-known domain user rids first */ @@ -338,26 +380,37 @@ uint32 lookup_wk_user_name(uint32 rid, char *user_name, uint8 *type) /******************************************************************* lookup user name ********************************************************************/ -uint32 lookup_user_name(uint32 rid, char *user_name, uint8 *type) +uint32 lookup_user_name(DOM_SID *sid, char *user_name, uint8 *type) { struct sam_disp_info *disp_info; - (*type) = SID_NAME_USER; + uint32 rid; + DOM_SID tmp; - DEBUG(5,("lookup_user_name: rid: %d", rid)); + (*type) = SID_NAME_USER; - /* find the user account */ - become_root(True); - disp_info = getsamdisprid(rid); - unbecome_root(True); + sid_copy(&tmp, sid); + sid_split_rid(&tmp, &rid); - if (disp_info != NULL) + if (sid_equal(&global_sam_sid, &tmp)) { - fstrcpy(user_name, disp_info->smb_name); - DEBUG(5,(" = %s\n", user_name)); - return 0x0; + DEBUG(5,("lookup_user_name in SAM %s: rid: %d", + global_sam_name, rid)); + + /* find the user account */ + become_root(True); + disp_info = getsamdisprid(rid); + unbecome_root(True); + + if (disp_info != NULL) + { + fstrcpy(user_name, disp_info->smb_name); + DEBUG(5,(" = %s\n", user_name)); + return 0x0; + } + + DEBUG(5,(" none mapped\n")); } - DEBUG(5,(" none mapped\n")); return 0xC0000000 | NT_STATUS_NONE_MAPPED; } -- cgit From bb5bea4e195eaf5776284c027d667812b7365b56 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 17 Nov 1998 19:32:06 +0000 Subject: lookup_alias_name() %s not %d for sid_str (This used to be commit 2a98135bbc759ab334d76cce98ea673871445db1) --- source3/rpc_server/srv_lookup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index 4f09360d93..6ed7a5b0e9 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -333,7 +333,7 @@ uint32 lookup_alias_name(DOM_SID *sid, char *alias_name, uint8 *type) sid_to_string(sid_str, sid); - DEBUG(2,("lookup_alias_name: sid: %d\n", sid_str)); + DEBUG(2,("lookup_alias_name: sid: %s\n", sid_str)); DEBUG(2,(" NOT IMPLEMENTED\n")); return 0xC0000000 | NT_STATUS_NONE_MAPPED; -- cgit From 768761820e8d7481c586c4e0ab4ac7cb36d18c4b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 17 Nov 1998 20:50:07 +0000 Subject: Added the same open()/fopen()/creat()/mmap() -> sys_XXX calls. Tidied up some of the mess (no other word for it). Still doesn't compile cleanly. There are calls with incorrect parameters that don't seem to be doing the right thing. This code still needs surgery :-(. Jeremy. (This used to be commit 18ff93a9abbf68ee8c59c0af3e57c63e4a015dac) --- source3/rpc_server/srv_samr.c | 6 ++---- source3/rpc_server/srv_sid.c | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 68c51a860a..7b970d27d2 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -807,12 +807,11 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, else if (sid_equal(&dom_sid, &usr_sid)) { DOMAIN_GRP *mem_grp = NULL; - BOOL ret; DEBUG(5,("lookup on Domain SID\n")); become_root(True); - ret = getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_rids); + getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_rids); unbecome_root(True); num_rids = MIN(num_rids, MAX_SAM_ENTRIES); @@ -1370,10 +1369,9 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, if (status == 0x0) { DOMAIN_GRP *mem_grp = NULL; - BOOL ret; become_root(True); - ret = getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_groups); + getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_groups); unbecome_root(True); gids = NULL; diff --git a/source3/rpc_server/srv_sid.c b/source3/rpc_server/srv_sid.c index 29cc1c936c..6428e965f7 100644 --- a/source3/rpc_server/srv_sid.c +++ b/source3/rpc_server/srv_sid.c @@ -69,7 +69,7 @@ DOM_SID global_sid_S_1_3_1; /* Creator group */ DOM_SID global_sid_S_1_3_2; /* Creator owner server */ DOM_SID global_sid_S_1_3_3; /* Creator group server */ -extern pstring global_myworkgroup; +extern fstring global_myworkgroup; /* extern fstring global_member_dom_name; */ static struct sid_name_map_info @@ -254,7 +254,7 @@ BOOL generate_sam_sid(void) pstrcat(sid_file, "MACHINE.SID"); - if ((fd = open(sid_file, O_RDWR | O_CREAT, 0644)) == -1) { + if ((fd = sys_open(sid_file, O_RDWR | O_CREAT, 0644)) == -1) { DEBUG(0,("unable to open or create file %s. Error was %s\n", sid_file, strerror(errno) )); return False; -- cgit From 4cee58780cb15fe5889b9dd0dc34459512d75062 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 23 Nov 1998 21:51:05 +0000 Subject: unix instance of group database API (This used to be commit e76f593b3572ac881f1aa1fb3326d8b7169b0078) --- source3/rpc_server/srv_lookup.c | 338 ++++++++++++++++++++-------------------- source3/rpc_server/srv_lsa.c | 34 ++-- source3/rpc_server/srv_samr.c | 44 ++++-- source3/rpc_server/srv_sid.c | 65 +++++--- 4 files changed, 263 insertions(+), 218 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index 6ed7a5b0e9..9981ce0371 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -110,16 +110,19 @@ int make_dom_gids(DOMAIN_GRP *mem, int num_members, DOM_GID **ppgids) uint32 status; uint32 rid; + DOM_SID sid; uint8 type; uint8 attr = mem[count].attr; char *name = mem[count].name; become_root(True); - status = lookup_grp_rid(name, &rid, &type); + status = lookup_group_name(name, &sid, &type); unbecome_root(True); - if (status == 0x0) + sid_split_rid(&sid, &rid); + + if (status == 0x0 && sid_equal(&sid, &global_sam_sid)) { gids = (DOM_GID *)Realloc( gids, sizeof(DOM_GID) * (count+1) ); @@ -168,53 +171,53 @@ int get_domain_user_groups(DOMAIN_GRP_MEMBER **grp_members, uint32 group_rid) /******************************************************************* - lookup_builtin_names + lookup_builtin_sid ********************************************************************/ -uint32 lookup_builtin_names(DOM_SID *sid, char *name, uint8 *type) +uint32 lookup_builtin_sid(DOM_SID *sid, char *name, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_wk_user_name (sid, name, type) : status; - status = (status != 0x0) ? lookup_wk_group_name(sid, name, type) : status; - status = (status != 0x0) ? lookup_wk_alias_name(sid, name, type) : status; + status = (status != 0x0) ? lookup_wk_user_sid (sid, name, type) : status; + status = (status != 0x0) ? lookup_wk_group_sid(sid, name, type) : status; + status = (status != 0x0) ? lookup_wk_alias_sid(sid, name, type) : status; return status; } /******************************************************************* - lookup_added_name - names that have been added to the SAM database by admins. + lookup_added_sid - names that have been added to the SAM database by admins. ********************************************************************/ -uint32 lookup_added_name(DOM_SID *sid, char *name, uint8 *type) +uint32 lookup_added_sid(DOM_SID *sid, char *name, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_user_name (sid, name, type) : status; - status = (status != 0x0) ? lookup_group_name(sid, name, type) : status; - status = (status != 0x0) ? lookup_alias_name(sid, name, type) : status; + status = (status != 0x0) ? lookup_user_sid (sid, name, type) : status; + status = (status != 0x0) ? lookup_group_sid(sid, name, type) : status; + status = (status != 0x0) ? lookup_alias_sid(sid, name, type) : status; return status; } /******************************************************************* - lookup_name + lookup_sid ********************************************************************/ -uint32 lookup_name(DOM_SID *sid, char *name, uint8 *type) +uint32 lookup_sid(DOM_SID *sid, char *name, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_builtin_names(sid, name, type) : status; - status = (status != 0x0) ? lookup_added_name (sid, name, type) : status; + status = (status != 0x0) ? lookup_builtin_sid(sid, name, type) : status; + status = (status != 0x0) ? lookup_added_sid (sid, name, type) : status; return status; } /******************************************************************* - lookup_wk_group_name + lookup_wk_group_sid ********************************************************************/ -uint32 lookup_wk_group_name(DOM_SID *sid, char *group_name, uint8 *type) +uint32 lookup_wk_group_sid(DOM_SID *sid, char *group_name, uint8 *type) { int i = 0; uint32 rid; @@ -230,7 +233,7 @@ uint32 lookup_wk_group_name(DOM_SID *sid, char *group_name, uint8 *type) return 0xC0000000 | NT_STATUS_NONE_MAPPED; } - DEBUG(5,("lookup_wk_group_name: rid: %d", rid)); + DEBUG(5,("lookup_wk_group_sid: rid: %d", rid)); while (domain_group_rids[i].rid != rid && domain_group_rids[i].rid != 0) { @@ -249,47 +252,47 @@ uint32 lookup_wk_group_name(DOM_SID *sid, char *group_name, uint8 *type) } /******************************************************************* - lookup_group_name + lookup_group_sid ********************************************************************/ -uint32 lookup_group_name(DOM_SID *sid, char *group_name, uint8 *type) +uint32 lookup_group_sid(DOM_SID *sid, char *group_name, uint8 *type) { - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + pstring sid_str; uint32 rid; DOM_SID tmp; + DOMAIN_GRP *grp = NULL; + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; (*type) = SID_NAME_DOM_GRP; + sid_to_string(sid_str, sid); + DEBUG(5,("lookup_group_sid: sid: %s", sid_str)); + sid_copy(&tmp, sid); sid_split_rid(&tmp, &rid); - if (!sid_equal(&global_sid_S_1_5_20, &tmp)) + if (!sid_equal(&global_sam_sid, &tmp)) { - return status; + DEBUG(5,("not our SID\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; } - DEBUG(5,("lookup_group_name: rid: 0x%x", rid)); - - if (map_group_sid_to_name(sid, group_name, NULL)) - { - status = 0x0; - } + grp = getgrouprid(rid, NULL, NULL); - if (status == 0x0) + if (grp != NULL) { + fstrcpy(group_name, grp->name); DEBUG(5,(" = %s\n", group_name)); - } - else - { - DEBUG(5,(" none mapped\n")); + return 0x0; } + DEBUG(5,(" none mapped\n")); return status; } /******************************************************************* - lookup_wk_alias_name + lookup_wk_alias_sid ********************************************************************/ -uint32 lookup_wk_alias_name(DOM_SID *sid, char *alias_name, uint8 *type) +uint32 lookup_wk_alias_sid(DOM_SID *sid, char *alias_name, uint8 *type) { int i = 0; uint32 rid; @@ -305,7 +308,7 @@ uint32 lookup_wk_alias_name(DOM_SID *sid, char *alias_name, uint8 *type) return 0xC0000000 | NT_STATUS_NONE_MAPPED; } - DEBUG(5,("lookup_wk_alias_name: rid: %d", rid)); + DEBUG(5,("lookup_wk_alias_sid: rid: %d", rid)); while (builtin_alias_rids[i].rid != rid && builtin_alias_rids[i].rid != 0) { @@ -324,25 +327,47 @@ uint32 lookup_wk_alias_name(DOM_SID *sid, char *alias_name, uint8 *type) } /******************************************************************* - lookup_alias_name + lookup_alias_sid ********************************************************************/ -uint32 lookup_alias_name(DOM_SID *sid, char *alias_name, uint8 *type) +uint32 lookup_alias_sid(DOM_SID *sid, char *alias_name, uint8 *type) { - fstring sid_str; + pstring sid_str; + uint32 rid; + DOM_SID tmp; + LOCAL_GRP *als = NULL; + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + (*type) = SID_NAME_ALIAS; sid_to_string(sid_str, sid); + DEBUG(5,("lookup_alias_sid: sid: %s", sid_str)); - DEBUG(2,("lookup_alias_name: sid: %s\n", sid_str)); - DEBUG(2,(" NOT IMPLEMENTED\n")); + sid_copy(&tmp, sid); + sid_split_rid(&tmp, &rid); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + if (!sid_equal(&global_sam_sid, &tmp)) + { + DEBUG(5,("not our SID\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; + } + + als = getaliasrid(rid, NULL, NULL); + + if (als != NULL) + { + fstrcpy(alias_name, als->name); + DEBUG(5,(" = %s\n", alias_name)); + return 0x0; + } + + DEBUG(5,(" none mapped\n")); + return status; } /******************************************************************* lookup well-known user name ********************************************************************/ -uint32 lookup_wk_user_name(DOM_SID *sid, char *user_name, uint8 *type) +uint32 lookup_wk_user_sid(DOM_SID *sid, char *user_name, uint8 *type) { int i = 0; uint32 rid; @@ -358,7 +383,7 @@ uint32 lookup_wk_user_name(DOM_SID *sid, char *user_name, uint8 *type) return 0xC0000000 | NT_STATUS_NONE_MAPPED; } - DEBUG(5,("lookup_wk_user_name: rid: %d", rid)); + DEBUG(5,("lookup_wk_user_sid: rid: %d", rid)); /* look up the well-known domain user rids first */ while (domain_user_rids[i].rid != rid && domain_user_rids[i].rid != 0) @@ -380,7 +405,7 @@ uint32 lookup_wk_user_name(DOM_SID *sid, char *user_name, uint8 *type) /******************************************************************* lookup user name ********************************************************************/ -uint32 lookup_user_name(DOM_SID *sid, char *user_name, uint8 *type) +uint32 lookup_user_sid(DOM_SID *sid, char *user_name, uint8 *type) { struct sam_disp_info *disp_info; uint32 rid; @@ -393,7 +418,7 @@ uint32 lookup_user_name(DOM_SID *sid, char *user_name, uint8 *type) if (sid_equal(&global_sam_sid, &tmp)) { - DEBUG(5,("lookup_user_name in SAM %s: rid: %d", + DEBUG(5,("lookup_user_sid in SAM %s: rid: %d", global_sam_name, rid)); /* find the user account */ @@ -417,20 +442,21 @@ uint32 lookup_user_name(DOM_SID *sid, char *user_name, uint8 *type) /******************************************************************* lookup_group_rid ********************************************************************/ -uint32 lookup_group_rid(char *group_name, uint32 *rid, uint8 *type) +uint32 lookup_group_name(char *grp_name, DOM_SID *sid, uint8 *type) { - DOM_SID sid; - - (*rid) = 0; + DOMAIN_GRP *grp = NULL; (*type) = SID_NAME_DOM_GRP; - DEBUG(5,("lookup_group_rid: name: %s", group_name)); + DEBUG(5,("lookup_group_name: name: %s", grp_name)); - if (map_group_name_to_sid(group_name, &sid) && - sid_split_rid(&sid, rid) && - sid_equal(&sid, &global_sam_sid)) + grp = getgroupnam(grp_name, NULL, NULL); + + if (grp != NULL) { - DEBUG(5,(" = 0x%x\n", (*rid))); + sid_copy(sid, &global_sam_sid); + sid_append_rid(sid, grp->rid); + + DEBUG(5,(" = 0x%x\n", grp->rid)); return 0x0; } @@ -439,64 +465,52 @@ uint32 lookup_group_rid(char *group_name, uint32 *rid, uint8 *type) } /******************************************************************* - lookup_wk_group_rid + lookup_wk_group_name ********************************************************************/ -uint32 lookup_wk_group_rid(char *group_name, uint32 *rid, uint8 *type) +uint32 lookup_wk_group_name(char *group_name, DOM_SID *sid, uint8 *type) { char *grp_name; int i = -1; /* start do loop at -1 */ - (*rid) = 0; + uint32 rid; (*type) = SID_NAME_WKN_GRP; do /* find, if it exists, a group rid for the group name */ { i++; - (*rid) = domain_group_rids[i].rid; + rid = domain_group_rids[i].rid; grp_name = domain_group_rids[i].name; - } while (grp_name != NULL && !strequal(grp_name, group_name)); - - return (grp_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_alias_sid - ********************************************************************/ -uint32 lookup_alias_sid(char *alias_name, DOM_SID *sid, uint8 *type) -{ - (*type) = SID_NAME_ALIAS; - - DEBUG(5,("lookup_alias_rid: name: %s", alias_name)); + if (strequal(grp_name, group_name)) + { + sid_copy(sid, &global_sam_sid); + sid_append_rid(sid, rid); - if (map_alias_name_to_sid(alias_name, sid)) - { - fstring sid_str; - sid_to_string(sid_str, sid); - DEBUG(5,(" = %s\n", sid_str)); - return 0x0; - } + return 0x0; + } + + } while (grp_name != NULL); - DEBUG(5,(" none mapped\n")); return 0xC0000000 | NT_STATUS_NONE_MAPPED; } /******************************************************************* - lookup_alias_rid + lookup_alias_name ********************************************************************/ -uint32 lookup_alias_rid(char *alias_name, uint32 *rid, uint8 *type) +uint32 lookup_alias_name(char *als_name, DOM_SID *sid, uint8 *type) { - DOM_SID sid; - - (*rid) = 0; + LOCAL_GRP *als = NULL; (*type) = SID_NAME_ALIAS; - DEBUG(5,("lookup_alias_rid: name: %s", alias_name)); + DEBUG(5,("lookup_alias_name: name: %s", als_name)); - if (map_alias_name_to_sid(alias_name, &sid) && - sid_split_rid(&sid, rid) && - sid_equal(&sid, &global_sam_sid)) + als = getaliasnam(als_name, NULL, NULL); + + if (als != NULL) { - DEBUG(5,(" = 0x%x\n", (*rid))); + sid_copy(sid, &global_sam_sid); + sid_append_rid(sid, als->rid); + + DEBUG(5,(" = 0x%x\n", als->rid)); return 0x0; } @@ -505,9 +519,9 @@ uint32 lookup_alias_rid(char *alias_name, uint32 *rid, uint8 *type) } /******************************************************************* - lookup_wk_alias_sid + lookup_wk_alias_name ********************************************************************/ -uint32 lookup_wk_alias_sid(char *alias_name, DOM_SID *sid, uint8 *type) +uint32 lookup_wk_alias_name(char *alias_name, DOM_SID *sid, uint8 *type) { char *als_name; int i = 0; @@ -534,53 +548,6 @@ uint32 lookup_wk_alias_sid(char *alias_name, DOM_SID *sid, uint8 *type) return 0xC0000000 | NT_STATUS_NONE_MAPPED; } -/******************************************************************* - lookup_wk_alias_rid - ********************************************************************/ -uint32 lookup_wk_alias_rid(char *alias_name, uint32 *rid, uint8 *type) -{ - char *als_name; - int i = -1; /* start do loop at -1 */ - (*rid) = 0; - (*type) = SID_NAME_ALIAS; - - do /* find, if it exists, a alias rid for the alias name*/ - { - i++; - (*rid) = builtin_alias_rids[i].rid; - als_name = builtin_alias_rids[i].name; - - } while (als_name != NULL && !strequal(als_name, alias_name)); - - return (als_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_sid - ********************************************************************/ -uint32 lookup_sid(char *name, DOM_SID *sid, uint8 *type) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - fstring domain; - fstring user; - - split_domain_name(name, domain, user); - - if (!strequal(domain, global_sam_name)) - { - DEBUG(0,("lookup_sid: remote domain %s not supported\n", domain)); - return status; - } - - status = (status != 0x0) ? lookup_wk_alias_sid(user, sid, type) : status; - status = (status != 0x0) ? lookup_alias_sid (user, sid, type) : status; -#if 0 - status = (status != 0x0) ? lookup_domain_sid (user, sid, type) : status; -#endif - - return status; -} - /******************************************************************* lookup_added_user_rid ********************************************************************/ @@ -607,12 +574,11 @@ uint32 lookup_added_user_rids(char *user_name, } /******************************************************************* - lookup_added_user_rid + lookup_added_user_name ********************************************************************/ -uint32 lookup_added_user_rid(char *user_name, uint32 *rid, uint8 *type) +uint32 lookup_added_user_name(char *user_name, DOM_SID *sid, uint8 *type) { struct sam_passwd *sam_pass; - (*rid) = 0; (*type) = SID_NAME_USER; /* find the user account */ @@ -622,7 +588,9 @@ uint32 lookup_added_user_rid(char *user_name, uint32 *rid, uint8 *type) if (sam_pass != NULL) { - (*rid) = sam_pass->user_rid; + sid_copy(sid, &global_sam_sid); + sid_append_rid(sid, sam_pass->user_rid); + return 0x0; } @@ -630,87 +598,107 @@ uint32 lookup_added_user_rid(char *user_name, uint32 *rid, uint8 *type) } /******************************************************************* - lookup_wk_user_rid + lookup_wk_user_name ********************************************************************/ -uint32 lookup_wk_user_rid(char *user_name, uint32 *rid, uint8 *type) +uint32 lookup_wk_user_name(char *user_name, DOM_SID *sid, uint8 *type) { char *usr_name; int i = -1; /* start do loop at -1 */ - (*rid) = 0; (*type) = SID_NAME_USER; do /* find, if it exists, a alias rid for the alias name*/ { i++; - (*rid) = domain_user_rids[i].rid; usr_name = domain_user_rids[i].name; } while (usr_name != NULL && !strequal(usr_name, user_name)); - return (usr_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; + if (usr_name != NULL) + { + sid_copy(sid, &global_sid_S_1_5_20); + sid_append_rid(sid, domain_user_rids[i].rid); + return 0; + } + + return 0xC0000000 | NT_STATUS_NONE_MAPPED; } /******************************************************************* - lookup_added_grp_rid + lookup_added_grp_name ********************************************************************/ -uint32 lookup_added_grp_rid(char *name, uint32 *rid, uint8 *type) +uint32 lookup_added_grp_name(char *name, DOM_SID *sid, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_group_rid(name, rid, type) : status; - status = (status != 0x0) ? lookup_alias_rid(name, rid, type) : status; + status = (status != 0x0) ? lookup_group_name(name, sid, type) : status; + status = (status != 0x0) ? lookup_alias_name(name, sid, type) : status; return status; } /******************************************************************* - lookup_builtin_grp_rid + lookup_builtin_grp_name ********************************************************************/ -uint32 lookup_builtin_grp_rid(char *name, uint32 *rid, uint8 *type) +uint32 lookup_builtin_grp_name(char *name, DOM_SID *sid, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_wk_group_rid(name, rid, type) : status; - status = (status != 0x0) ? lookup_wk_alias_rid(name, rid, type) : status; + status = (status != 0x0) ? lookup_wk_group_name(name, sid, type) : status; + status = (status != 0x0) ? lookup_wk_alias_name(name, sid, type) : status; return status; } /******************************************************************* - lookup_grp_rid + lookup_grp_name ********************************************************************/ -uint32 lookup_grp_rid(char *name, uint32 *rid, uint8 *type) +uint32 lookup_grp_name(char *name, DOM_SID *sid, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_builtin_grp_rid(name, rid, type) : status; - status = (status != 0x0) ? lookup_added_grp_rid (name, rid, type) : status; + status = (status != 0x0) ? lookup_builtin_grp_name(name, sid, type) : status; + status = (status != 0x0) ? lookup_added_grp_name (name, sid, type) : status; return status; } /******************************************************************* - lookup_user_rid + lookup_user_name ********************************************************************/ -uint32 lookup_user_rid(char *name, uint32 *rid, uint8 *type) +uint32 lookup_user_name(char *name, DOM_SID *sid, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_wk_user_rid (name, rid, type) : status; - status = (status != 0x0) ? lookup_added_user_rid(name, rid, type) : status; + status = (status != 0x0) ? lookup_wk_user_name (name, sid, type) : status; + status = (status != 0x0) ? lookup_added_user_name(name, sid, type) : status; return status; } /******************************************************************* - lookup_rid + lookup_name ********************************************************************/ -uint32 lookup_rid(char *name, uint32 *rid, uint8 *type) +uint32 lookup_name(char *name, DOM_SID *sid, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + fstring domain; + fstring user; + + split_domain_name(name, domain, user); + + if (!strequal(domain, global_sam_name)) + { + DEBUG(0,("lookup_name: remote domain %s not supported\n", domain)); + return status; + } - status = (status != 0x0) ? lookup_user_rid(name, rid, type) : status; - status = (status != 0x0) ? lookup_grp_rid (name, rid, type) : status; + status = (status != 0x0) ? lookup_wk_alias_name(user, sid, type) : status; + status = (status != 0x0) ? lookup_alias_name (user, sid, type) : status; + status = (status != 0x0) ? lookup_user_name (name, sid, type) : status; + status = (status != 0x0) ? lookup_grp_name (name, sid, type) : status; +#if 0 + status = (status != 0x0) ? lookup_domain_name (user, sid, type) : status; +#endif return status; } @@ -722,6 +710,7 @@ uint32 lookup_user_rids(char *name, uint32 *usr_rid, uint32 *grp_rid) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; uint8 type; + DOM_SID sid; /* * try an ordinary user lookup @@ -737,11 +726,14 @@ uint32 lookup_user_rids(char *name, uint32 *usr_rid, uint32 *grp_rid) * hm. must be a well-known user, in a well-known group. */ - status = lookup_wk_user_rid(name, usr_rid, &type); + status = lookup_wk_user_name(name, &sid, &type); + sid_split_rid(&sid, usr_rid); + if (status != 0 || type != SID_NAME_USER) { return status; /* ok, maybe not! */ } + if (type != SID_NAME_USER) { return 0xC0000000 | NT_STATUS_NONE_MAPPED; /* users only... */ @@ -751,7 +743,9 @@ uint32 lookup_user_rids(char *name, uint32 *usr_rid, uint32 *grp_rid) * ok, got the user rid: now try the group rid */ - status = lookup_builtin_grp_rid(name, grp_rid, &type); + status = lookup_builtin_grp_name(name, &sid, &type); + sid_split_rid(&sid, usr_rid); + if (type == SID_NAME_DOM_GRP || type == SID_NAME_ALIAS || type == SID_NAME_WKN_GRP) diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 51b6e8d25b..8c9db172d2 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -85,6 +85,7 @@ make_dom_query ***************************************************************************/ static void make_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) { + fstring sid_str; int domlen = strlen(dom_name); d_q->uni_dom_max_len = domlen * 2; @@ -96,6 +97,7 @@ static void make_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) /* this string is supposed to be character short */ make_unistr2(&(d_q->uni_domain_name), dom_name, domlen); + sid_to_string(sid_str, dom_sid); make_dom_sid2(&(d_q->dom_sid), dom_sid); } @@ -197,8 +199,8 @@ make_reply_lookup_rids ***************************************************************************/ static void make_reply_lookup_rids(LSA_R_LOOKUP_RIDS *r_l, int num_entries, - uint32 dom_rids[MAX_LOOKUP_SIDS], - uint8 dom_types[MAX_LOOKUP_SIDS]) + DOM_SID dom_sids [MAX_LOOKUP_SIDS], + uint8 dom_types[MAX_LOOKUP_SIDS]) { int i; @@ -215,8 +217,11 @@ static void make_reply_lookup_rids(LSA_R_LOOKUP_RIDS *r_l, for (i = 0; i < num_entries; i++) { + DOM_SID sid = dom_sids[i]; + uint32 rid; + sid_split_rid(&sid, &rid); make_dom_ref(&(r_l->dom_ref), dom_name, dom_sid); - make_dom_rid2(&(r_l->dom_rid[i]), dom_rids[i], dom_types[i]); + make_dom_rid2(&(r_l->dom_rid[i]), rid, dom_types[i]); } r_l->num_entries3 = num_entries; @@ -241,7 +246,7 @@ static void make_lsa_trans_names(DOM_R_REF *ref, { uint32 status = 0x0; DOM_SID find_sid = sid[i].sid; - DOM_SID tmp = sid[i].sid; + DOM_SID tmp_sid = sid[i].sid; uint32 rid = 0xffffffff; int dom_idx = -1; fstring name; @@ -261,7 +266,7 @@ static void make_lsa_trans_names(DOM_R_REF *ref, { if (sid_equal(&find_sid, &global_sam_sid)) { - status = lookup_name(&tmp, name, &sid_name_use); + status = lookup_sid(&tmp_sid, name, &sid_name_use); } else { @@ -337,15 +342,15 @@ lsa_reply_lookup_rids ***************************************************************************/ static void lsa_reply_lookup_rids(prs_struct *rdata, int num_entries, - uint32 dom_rids[MAX_LOOKUP_SIDS], - uint8 dom_types[MAX_LOOKUP_SIDS]) + DOM_SID dom_sids [MAX_LOOKUP_SIDS], + uint8 dom_types[MAX_LOOKUP_SIDS]) { LSA_R_LOOKUP_RIDS r_l; ZERO_STRUCT(r_l); /* set up the LSA Lookup RIDs response */ - make_reply_lookup_rids(&r_l, num_entries, dom_rids, dom_types); + make_reply_lookup_rids(&r_l, num_entries, dom_sids, dom_types); r_l.status = 0x0; @@ -474,11 +479,11 @@ static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, { int i; LSA_Q_LOOKUP_RIDS q_l; - uint32 dom_rids[MAX_LOOKUP_SIDS]; - uint8 dom_types[MAX_LOOKUP_SIDS]; + DOM_SID dom_sids [MAX_LOOKUP_SIDS]; + uint8 dom_types[MAX_LOOKUP_SIDS]; ZERO_STRUCT(q_l); - ZERO_ARRAY(dom_rids); + ZERO_ARRAY(dom_sids); /* grab the info class and policy handle */ lsa_io_q_lookup_rids("", &q_l, data, 0); @@ -491,17 +496,16 @@ static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, fstring name; fstrcpy(name, unistr2(q_l.lookup_name[i].str.buffer)); - if (lookup_rid(name, &dom_rids[i], &dom_types[i])) + if (!lookup_name(name, &dom_sids[i], &dom_types[i])) { - /* WHOOPS! we should really do something about this... */ - dom_rids[i] = 0; + dom_types[i] = SID_NAME_UNKNOWN; } } /* construct reply. return status is always 0x0 */ lsa_reply_lookup_rids(rdata, q_l.num_entries, - dom_rids, /* text-converted SIDs */ + dom_sids, /* text-converted SIDs */ dom_types); /* SID_NAME_USE types */ } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 7b970d27d2..7e725f3599 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -444,15 +444,20 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, { BOOL ret; char *name; + int i; got_grps = True; - while (num_entries < MAX_SAM_ENTRIES && ((name = domain_group_rids[num_entries].name) != NULL)) + become_root(True); + ret = enumdomgroups(&grps, &num_entries); + unbecome_root(True); + + while (num_entries < MAX_SAM_ENTRIES && ((name = domain_group_rids[i].name) != NULL)) { DOMAIN_GRP tmp_grp; fstrcpy(tmp_grp.name , name); fstrcpy(tmp_grp.comment, ""); - tmp_grp.rid = domain_group_rids[num_entries].rid; + tmp_grp.rid = domain_group_rids[i].rid; tmp_grp.attr = 0x7; if (!add_domain_group(&grps, &num_entries, &tmp_grp)) @@ -460,11 +465,10 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; break; } + + i++; } - become_root(True); - ret = enumdomgroups(&grps, &num_entries); - unbecome_root(True); if (!ret) { r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; @@ -807,11 +811,12 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, else if (sid_equal(&dom_sid, &usr_sid)) { DOMAIN_GRP *mem_grp = NULL; + BOOL ret; DEBUG(5,("lookup on Domain SID\n")); become_root(True); - getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_rids); + ret = getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_rids); unbecome_root(True); num_rids = MIN(num_rids, MAX_SAM_ENTRIES); @@ -880,10 +885,19 @@ static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, for (i = 0; i < num_rids && status == 0; i++) { + DOM_SID sid; fstring name; fstrcpy(name, unistrn2(q_u->uni_user_name[i].buffer, q_u->uni_user_name[i].uni_str_len)); - status = lookup_rid(name, &(rid[i]), &(type[i])); + status = lookup_name(name, &sid, &(type[i])); + if (status == 0x0) + { + sid_split_rid(&sid, &rid[i]); + } + else + { + type[i] = SID_NAME_UNKNOWN; + } } make_samr_r_lookup_names(&r_u, num_rids, rid, type, status); @@ -995,9 +1009,10 @@ static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, prs_struct *rdata) { fstring group_names[MAX_SAM_ENTRIES]; - uint32 group_attrs[MAX_SAM_ENTRIES]; + uint8 group_attrs[MAX_SAM_ENTRIES]; uint32 status = 0; int num_gids = q_u->num_gids1; + DOM_SID pol_sid; SAMR_R_UNKNOWN_12 r_u; @@ -1009,6 +1024,11 @@ static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } + if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &pol_sid)) + { + status = NT_STATUS_OBJECT_TYPE_MISMATCH; + } + if (status == 0x0) { int i; @@ -1020,7 +1040,10 @@ static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, for (i = 0; i < num_gids && status == 0; i++) { - fstrcpy(group_names[i], "dummy group"); + DOM_SID sid; + sid_copy(&sid, &pol_sid); + sid_append_rid(&sid, q_u->gid[i]); + lookup_sid(&sid, group_names[i], &group_attrs[i]); group_attrs[i] = 0x2; } } @@ -1369,9 +1392,10 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, if (status == 0x0) { DOMAIN_GRP *mem_grp = NULL; + BOOL ret; become_root(True); - getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_groups); + ret = getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_groups); unbecome_root(True); gids = NULL; diff --git a/source3/rpc_server/srv_sid.c b/source3/rpc_server/srv_sid.c index 6428e965f7..a8a94204c1 100644 --- a/source3/rpc_server/srv_sid.c +++ b/source3/rpc_server/srv_sid.c @@ -63,13 +63,10 @@ DOM_SID global_member_sid; DOM_SID global_sid_S_1_5_20; /* local well-known domain */ DOM_SID global_sid_S_1_1; /* everyone */ +DOM_SID global_sid_S_1_3; /* */ DOM_SID global_sid_S_1_5; /* NT Authority */ -DOM_SID global_sid_S_1_3_0; /* Creator owner */ -DOM_SID global_sid_S_1_3_1; /* Creator group */ -DOM_SID global_sid_S_1_3_2; /* Creator owner server */ -DOM_SID global_sid_S_1_3_3; /* Creator group server */ -extern fstring global_myworkgroup; +extern pstring global_myworkgroup; /* extern fstring global_member_dom_name; */ static struct sid_name_map_info @@ -82,10 +79,7 @@ sid_name_map[] = { { &global_sid_S_1_5_20, "BUILTIN" }, { &global_sid_S_1_1 , "Everyone" }, - { &global_sid_S_1_3_0 , "Creator Owner" }, - { &global_sid_S_1_3_1 , "Creator Group" }, - { &global_sid_S_1_3_2 , "Creator Owner Server" }, - { &global_sid_S_1_3_3 , "Creator Group Server" }, + { &global_sid_S_1_3 , "don't know" }, { &global_sid_S_1_5 , "NT Authority" }, { &global_sam_sid , global_sam_name }, { &global_member_sid , global_myworkgroup }, @@ -99,6 +93,7 @@ sid_name_map[] = static BOOL read_sid_from_file(int fd, char *sid_file) { fstring fline; + fstring sid_str; memset(fline, '\0', sizeof(fline)); @@ -118,12 +113,43 @@ static BOOL read_sid_from_file(int fd, char *sid_file) return False; } + sid_to_string(sid_str, &global_sam_sid); + DEBUG(5,("read_sid_from_file: sid %s\n", sid_str)); + return True; } /**************************************************************************** - Generate the global machine sid. Look for the MACHINE.SID file first, if - not found then look in smb.conf and use it to create the MACHINE.SID file. + sets up the name associated with the SAM database for which we are responsible +****************************************************************************/ +void get_sam_domain_name(void) +{ + switch (lp_server_role()) + { + case ROLE_DOMAIN_PDC: + case ROLE_DOMAIN_BDC: + { + /* we are PDC (or BDC) for a Domain */ + fstrcpy(global_sam_name, lp_workgroup()); + break; + } + case ROLE_DOMAIN_MEMBER: + { + /* we are a "PDC", but FOR LOCAL SAM DATABASE ONLY */ + fstrcpy(global_sam_name, global_myname); + break; + } + default: + { + /* no domain role, probably due to "security = share" */ + memset(global_sam_name, 0, sizeof(global_sam_name)); + break; + } + } +} + +/**************************************************************************** + obtain the sid from the PDC. do some verification along the way... ****************************************************************************/ BOOL get_member_domain_sid(void) { @@ -138,7 +164,7 @@ BOOL get_member_domain_sid(void) if (!cli_connect_serverlist(&cli, lp_passwordserver())) { - DEBUG(0,("get_member_domain_sid: unable to initialize client connection.\n")); + DEBUG(0,("get_member_domain_sid: unable to initialise client connection.\n")); return False; } @@ -179,11 +205,11 @@ BOOL get_member_domain_sid(void) if (res) { pstring sid; - DEBUG(5,("LSA Query Info Policy\n")); + DEBUG(2,("LSA Query Info Policy\n")); sid_to_string(sid, &sid3); - DEBUG(5,("Domain Member - Domain: %s SID: %s\n", dom3, sid)); + DEBUG(2,("Domain Member - Domain: %s SID: %s\n", dom3, sid)); sid_to_string(sid, &sid5); - DEBUG(5,("Domain Controller - Domain: %s SID: %s\n", dom5, sid)); + DEBUG(2,("Domain Controller - Domain: %s SID: %s\n", dom5, sid)); if (!strequal(dom3, global_myworkgroup) || !strequal(dom5, global_myworkgroup)) @@ -195,7 +221,7 @@ BOOL get_member_domain_sid(void) } else { - DEBUG(5,("lsa query info failed\n")); + DEBUG(1,("lsa query info failed\n")); } if (!res) { @@ -217,10 +243,7 @@ void generate_wellknown_sids(void) { string_to_sid(&global_sid_S_1_5_20, "S-1-5-32"); string_to_sid(&global_sid_S_1_1 , "S-1-1" ); - string_to_sid(&global_sid_S_1_3_0 , "S-1-3-0" ); - string_to_sid(&global_sid_S_1_3_1 , "S-1-3-1" ); - string_to_sid(&global_sid_S_1_3_2 , "S-1-3-2" ); - string_to_sid(&global_sid_S_1_3_3 , "S-1-3-3" ); + string_to_sid(&global_sid_S_1_3 , "S-1-3" ); string_to_sid(&global_sid_S_1_5 , "S-1-5" ); } @@ -476,7 +499,7 @@ BOOL split_domain_name(char *fullname, char *domain, char *name) fstrcpy(full_name, fullname); p = strchr(full_name+1, '\\'); - if (p == NULL) + if (p != NULL) { *p = 0; fstrcpy(domain, full_name); -- cgit From 83e41392b6f9d389ecbe2be2aabbfda961a0027e Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 23 Nov 1998 23:44:09 +0000 Subject: uninitialised counter (This used to be commit 403f53d696d17f34dd1afc035a72eda792dd20ea) --- source3/rpc_server/srv_samr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 7e725f3599..5718887906 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -444,7 +444,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, { BOOL ret; char *name; - int i; + int i = 0; got_grps = True; become_root(True); -- cgit From c9b2f20efcb9cd2e93f29928442e9a61360fa5a0 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 25 Nov 1998 14:54:23 +0000 Subject: fixing domain join and domain login problems (This used to be commit 90a24664318da97a6e8cfe4622a8573c0e3cbe5e) --- source3/rpc_server/srv_netlog.c | 6 +----- source3/rpc_server/srv_sid.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 77b17dca2f..9fa3ed79cc 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -748,7 +748,7 @@ static void api_net_sam_logon( uint16 vuid, strupper(my_name); status = lookup_user_rids(samlogon_user, &r_uid, &r_gid); - status = status == 0 ? getusergroupsnam(samlogon_user, &grp_mem, &num_gids) : 0xC0000000 | NT_STATUS_INVALID_PRIMARY_GROUP; + status = getusergroupsnam(samlogon_user, &grp_mem, &num_gids) ? 0 : 0xC0000000 | NT_STATUS_INVALID_PRIMARY_GROUP; if (status == 0x0) { @@ -787,10 +787,6 @@ static void api_net_sam_logon( uint16 vuid, &global_sam_sid, /* DOM_SID *dom_sid */ NULL); /* char *other_sids */ } - else - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - } /* Free any allocated groups array. */ if (gids) diff --git a/source3/rpc_server/srv_sid.c b/source3/rpc_server/srv_sid.c index a8a94204c1..216fab657f 100644 --- a/source3/rpc_server/srv_sid.c +++ b/source3/rpc_server/srv_sid.c @@ -162,6 +162,25 @@ BOOL get_member_domain_sid(void) fstring dom3; fstring dom5; + switch (lp_server_role()) + { + case ROLE_DOMAIN_NONE: + { + ZERO_STRUCT(global_member_sid); + return True; + } + case ROLE_DOMAIN_PDC: + { + sid_copy(&global_member_sid, &global_sam_sid); + return True; + } + default: + { + /* member or BDC, we're going for connection to PDC */ + break; + } + } + if (!cli_connect_serverlist(&cli, lp_passwordserver())) { DEBUG(0,("get_member_domain_sid: unable to initialise client connection.\n")); -- cgit From 59d4087160ba41aac724722dc29c4b6e4e3b69b0 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 25 Nov 1998 19:57:04 +0000 Subject: LsaLookupNames client call (first used as lookupnames command in rpcclient). (This used to be commit 68342a29a892e515cf2b22d759476d61944bcd59) --- source3/rpc_server/srv_lsa.c | 24 ++++++++++++------------ source3/rpc_server/srv_sid.c | 14 ++++++++++---- 2 files changed, 22 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 8c9db172d2..abbe4ccd93 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -195,9 +195,9 @@ static int make_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) } /*************************************************************************** -make_reply_lookup_rids +make_reply_lookup_names ***************************************************************************/ -static void make_reply_lookup_rids(LSA_R_LOOKUP_RIDS *r_l, +static void make_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, int num_entries, DOM_SID dom_sids [MAX_LOOKUP_SIDS], uint8 dom_types[MAX_LOOKUP_SIDS]) @@ -338,24 +338,24 @@ static void lsa_reply_lookup_sids(prs_struct *rdata, } /*************************************************************************** -lsa_reply_lookup_rids +lsa_reply_lookup_names ***************************************************************************/ -static void lsa_reply_lookup_rids(prs_struct *rdata, +static void lsa_reply_lookup_names(prs_struct *rdata, int num_entries, DOM_SID dom_sids [MAX_LOOKUP_SIDS], uint8 dom_types[MAX_LOOKUP_SIDS]) { - LSA_R_LOOKUP_RIDS r_l; + LSA_R_LOOKUP_NAMES r_l; ZERO_STRUCT(r_l); /* set up the LSA Lookup RIDs response */ - make_reply_lookup_rids(&r_l, num_entries, dom_sids, dom_types); + make_reply_lookup_names(&r_l, num_entries, dom_sids, dom_types); r_l.status = 0x0; /* store the response in the SMB stream */ - lsa_io_r_lookup_rids("", &r_l, rdata, 0); + lsa_io_r_lookup_names("", &r_l, rdata, 0); } /*************************************************************************** @@ -478,7 +478,7 @@ static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rdata ) { int i; - LSA_Q_LOOKUP_RIDS q_l; + LSA_Q_LOOKUP_NAMES q_l; DOM_SID dom_sids [MAX_LOOKUP_SIDS]; uint8 dom_types[MAX_LOOKUP_SIDS]; @@ -486,15 +486,15 @@ static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, ZERO_ARRAY(dom_sids); /* grab the info class and policy handle */ - lsa_io_q_lookup_rids("", &q_l, data, 0); + lsa_io_q_lookup_names("", &q_l, data, 0); - SMB_ASSERT_ARRAY(q_l.lookup_name, q_l.num_entries); + SMB_ASSERT_ARRAY(q_l.uni_name, q_l.num_entries); /* convert received RIDs to strings, so we can do them. */ for (i = 0; i < q_l.num_entries; i++) { fstring name; - fstrcpy(name, unistr2(q_l.lookup_name[i].str.buffer)); + fstrcpy(name, unistr2_to_str(&q_l.uni_name[i])); if (!lookup_name(name, &dom_sids[i], &dom_types[i])) { @@ -503,7 +503,7 @@ static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, } /* construct reply. return status is always 0x0 */ - lsa_reply_lookup_rids(rdata, + lsa_reply_lookup_names(rdata, q_l.num_entries, dom_sids, /* text-converted SIDs */ dom_types); /* SID_NAME_USE types */ diff --git a/source3/rpc_server/srv_sid.c b/source3/rpc_server/srv_sid.c index 216fab657f..0317bb32f5 100644 --- a/source3/rpc_server/srv_sid.c +++ b/source3/rpc_server/srv_sid.c @@ -432,10 +432,6 @@ Error was %s\n", sid_file, strerror(errno) )); ***************************************************************************/ BOOL map_domain_name_to_sid(DOM_SID *sid, char **nt_domain) { - fstring sid_str; - sid_to_string(sid_str, sid); - DEBUG(5,("map_domain_name_to_sid: %s\n", sid_str)); - if (nt_domain == NULL) { *sid = global_sam_sid; @@ -451,6 +447,16 @@ BOOL map_domain_name_to_sid(DOM_SID *sid, char **nt_domain) return True; } + if ((*nt_domain)[0] == 0) + { + DEBUG(5,("map_domain_name_to_sid: overriding blank name to %s\n", + global_sam_name)); + free(*nt_domain); + (*nt_domain) = strdup(global_sam_name); + *sid = global_sam_sid; + return True; + } + if (strequal((*nt_domain), global_sam_name)) { *sid = global_sam_sid; -- cgit From bfc38ff872446e0ad365c22327c779e72a81bef9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 25 Nov 1998 21:17:20 +0000 Subject: Makefile.in: Added maintainer mode fixes. aclocal.m4: Added AC_LIBTESTFUNC. configure.in: Fixed -lsecurity -lsec problems. client.c: dos_ fixes. groupdb/aliasunix.c: Dead code removal. include/includes.h: Added default PRINTCAP_NAME. lib/genrand.c: dos_ fixes. lib/replace.c: Added strtoul. lib/system.c: dos_ fixes. lib/util.c: dos_ fixes. lib/util_sid.c: Signed/unsigned fixes. lib/util_str.c: removed bad const. locking/locking_slow.c: dos_ fixes. printing/printing.c: dos_ fixes. rpc_server/srv_samr.c: Dead code removal. rpc_server/srv_sid.c: global_myworkgroup defined with wrong size AGAIN ! smbd/dir.c: dos_ fixes. smbd/open.c: dos_ fixes. smbd/oplock.c: dos_ fixes. smbd/reply.c smbd/server.c smbd/service.c smbd/uid.c: dos_ fixes. Jeremy. (This used to be commit 6acb4b68f68d516e2ac3c47e500f5600d653435e) --- source3/rpc_server/srv_samr.c | 6 ++---- source3/rpc_server/srv_sid.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 5718887906..e3f2a57a95 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -811,12 +811,11 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, else if (sid_equal(&dom_sid, &usr_sid)) { DOMAIN_GRP *mem_grp = NULL; - BOOL ret; DEBUG(5,("lookup on Domain SID\n")); become_root(True); - ret = getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_rids); + getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_rids); unbecome_root(True); num_rids = MIN(num_rids, MAX_SAM_ENTRIES); @@ -1392,10 +1391,9 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, if (status == 0x0) { DOMAIN_GRP *mem_grp = NULL; - BOOL ret; become_root(True); - ret = getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_groups); + getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_groups); unbecome_root(True); gids = NULL; diff --git a/source3/rpc_server/srv_sid.c b/source3/rpc_server/srv_sid.c index 0317bb32f5..f112b8a9ce 100644 --- a/source3/rpc_server/srv_sid.c +++ b/source3/rpc_server/srv_sid.c @@ -66,7 +66,7 @@ DOM_SID global_sid_S_1_1; /* everyone */ DOM_SID global_sid_S_1_3; /* */ DOM_SID global_sid_S_1_5; /* NT Authority */ -extern pstring global_myworkgroup; +extern fstring global_myworkgroup; /* extern fstring global_member_dom_name; */ static struct sid_name_map_info -- cgit From 9a0cb06b240f3d772b53a6acc4804ccd9cbc4072 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 25 Nov 1998 23:11:25 +0000 Subject: fixing group database issues (This used to be commit 591c63e3e1e3201ddcd7582585b652fb848d80ca) --- source3/rpc_server/srv_netlog.c | 22 +++++++++++++--------- source3/rpc_server/srv_sid.c | 6 +++--- 2 files changed, 16 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 9fa3ed79cc..7fbd43c38e 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -600,6 +600,7 @@ static void api_net_sam_logon( uint16 vuid, DOM_CRED srv_cred; struct smb_passwd *smb_pass = NULL; UNISTR2 *uni_samlogon_user = NULL; + fstring nt_username; user_struct *vuser = NULL; @@ -654,23 +655,23 @@ static void api_net_sam_logon( uint16 vuid, if (status == 0) { - pstrcpy(samlogon_user, unistrn2(uni_samlogon_user->buffer, - uni_samlogon_user->uni_str_len)); + pstrcpy(nt_username, unistrn2(uni_samlogon_user->buffer, + uni_samlogon_user->uni_str_len)); - DEBUG(3,("User:[%s]\n", samlogon_user)); + DEBUG(3,("User:[%s]\n", nt_username)); /* * Convert to a UNIX username. */ - map_username(samlogon_user); + map_username(nt_username); /* * Do any case conversions. */ - (void)Get_Pwnam(samlogon_user, True); + (void)Get_Pwnam(nt_username, True); become_root(True); - smb_pass = getsmbpwnam(samlogon_user); + smb_pass = getsmbpwnam(nt_username); unbecome_root(True); if (smb_pass == NULL) @@ -736,6 +737,7 @@ static void api_net_sam_logon( uint16 vuid, /* 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); pstrcpy(logon_script, lp_logon_script()); pstrcpy(profile_path, lp_logon_path()); @@ -747,8 +749,10 @@ static void api_net_sam_logon( uint16 vuid, pstrcpy(my_name, global_myname); strupper(my_name); - status = lookup_user_rids(samlogon_user, &r_uid, &r_gid); - status = getusergroupsnam(samlogon_user, &grp_mem, &num_gids) ? 0 : 0xC0000000 | NT_STATUS_INVALID_PRIMARY_GROUP; + status = lookup_user_rids(nt_username, &r_uid, &r_gid); + status = getusergroupsnam(nt_username, &grp_mem, &num_gids) ? 0 : 0xC0000000 | NT_STATUS_INVALID_PRIMARY_GROUP; + + sam_logon_in_ssb = False; if (status == 0x0) { @@ -763,7 +767,7 @@ static void api_net_sam_logon( uint16 vuid, &dummy_time, /* pass_can_change_time */ &dummy_time, /* pass_must_change_time */ - samlogon_user , /* user_name */ + nt_username , /* user_name */ vuser->real_name, /* full_name */ logon_script , /* logon_script */ profile_path , /* profile_path */ diff --git a/source3/rpc_server/srv_sid.c b/source3/rpc_server/srv_sid.c index f112b8a9ce..a428a7f068 100644 --- a/source3/rpc_server/srv_sid.c +++ b/source3/rpc_server/srv_sid.c @@ -443,7 +443,7 @@ BOOL map_domain_name_to_sid(DOM_SID *sid, char **nt_domain) DEBUG(5,("map_domain_name_to_sid: overriding NULL name to %s\n", global_sam_name)); (*nt_domain) = strdup(global_sam_name); - *sid = global_sam_sid; + sid_copy(sid, &global_sam_sid); return True; } @@ -453,13 +453,13 @@ BOOL map_domain_name_to_sid(DOM_SID *sid, char **nt_domain) global_sam_name)); free(*nt_domain); (*nt_domain) = strdup(global_sam_name); - *sid = global_sam_sid; + sid_copy(sid, &global_sam_sid); return True; } if (strequal((*nt_domain), global_sam_name)) { - *sid = global_sam_sid; + sid_copy(sid, &global_sam_sid); return True; } -- cgit From 5ebcdbae9b0eb05570613bd939af9fc827920a29 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 25 Nov 1998 23:54:30 +0000 Subject: yeehaah got users to be included in S-1-5-xxx-yyy-zzz's local groups. now need search capability on S-1-5-20, which will need argh, a "group database API" on S-1-5-20, and the ability to add BUILTIN\Admins etc to "local group map" argh. (This used to be commit a24f6eb00ba7486479cbcf7fadf5456521c56179) --- source3/rpc_server/srv_samr.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index e3f2a57a95..ff782a7248 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -742,9 +742,9 @@ static void api_samr_query_aliasinfo( uint16 vuid, prs_struct *data, prs_struct /******************************************************************* - samr_reply_lookup_ids + samr_reply_query_useraliases ********************************************************************/ -static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, +static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, prs_struct *rdata) { uint32 rid[MAX_SAM_ENTRIES]; @@ -759,9 +759,9 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, fstring dom_sid_str; fstring usr_sid_str; - SAMR_R_LOOKUP_IDS r_u; + SAMR_R_QUERY_USERALIASES r_u; - DEBUG(5,("samr_lookup_ids: %d\n", __LINE__)); + DEBUG(5,("samr_query_useraliases: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &dom_sid)) @@ -777,7 +777,7 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, if (num_rids > MAX_SAM_ENTRIES) { num_rids = MAX_SAM_ENTRIES; - DEBUG(5,("samr_lookup_ids: truncating entries to %d\n", num_rids)); + DEBUG(5,("samr_query_useraliases: truncating entries to %d\n", num_rids)); } if (status == 0x0) @@ -806,16 +806,16 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, { if (sid_equal(&dom_sid, &global_sid_S_1_5_20)) { - DEBUG(5,("lookup on S-1-5-20\n")); + DEBUG(10,("lookup on S-1-5-20\n")); } else if (sid_equal(&dom_sid, &usr_sid)) { - DOMAIN_GRP *mem_grp = NULL; + LOCAL_GRP *mem_grp = NULL; - DEBUG(5,("lookup on Domain SID\n")); + DEBUG(10,("lookup on Domain SID\n")); become_root(True); - getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_rids); + getuseraliasnam(sam_pass->smb_name, &mem_grp, &num_rids); unbecome_root(True); num_rids = MIN(num_rids, MAX_SAM_ENTRIES); @@ -835,27 +835,27 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, } } - make_samr_r_lookup_ids(&r_u, num_rids, rid, status); + make_samr_r_query_useraliases(&r_u, num_rids, rid, status); /* store the response in the SMB stream */ - samr_io_r_lookup_ids("", &r_u, rdata, 0); + samr_io_r_query_useraliases("", &r_u, rdata, 0); - DEBUG(5,("samr_lookup_ids: %d\n", __LINE__)); + DEBUG(5,("samr_query_useraliases: %d\n", __LINE__)); } /******************************************************************* - api_samr_lookup_ids + api_samr_query_useraliases ********************************************************************/ -static void api_samr_lookup_ids( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_useraliases( uint16 vuid, prs_struct *data, prs_struct *rdata) { - SAMR_Q_LOOKUP_IDS q_u; + SAMR_Q_QUERY_USERALIASES q_u; /* grab the samr 0x10 */ - samr_io_q_lookup_ids("", &q_u, data, 0); + samr_io_q_query_useraliases("", &q_u, data, 0); /* construct reply. always indicate success */ - samr_reply_lookup_ids(&q_u, rdata); + samr_reply_query_useraliases(&q_u, rdata); } /******************************************************************* @@ -1750,11 +1750,11 @@ static struct api_struct api_samr_cmds [] = { "SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users }, { "SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, { "SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, - { "SAMR_LOOKUP_IDS" , SAMR_LOOKUP_IDS , api_samr_lookup_ids }, + { "SAMR_QUERY_USERALIASES", SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, { "SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, { "SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, { "SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, - { "SAMR_QUERY_DOMAIN_INFO", SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, + { "SAMR_QUERY_DOMAIN_INFO", SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, { "SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, { "SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, { "SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, -- cgit From 30038de4623bc827ee8019c569faf00583d1fe58 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 29 Nov 1998 20:03:33 +0000 Subject: weekend work. user / group database API. - split sam_passwd and smb_passwd into separate higher-order function tables - renamed struct smb_passwd's "smb_user" to "unix_user". added "nt_user" plus user_rid, and added a "wrap" function in both sam_passwd and smb_passwd password databases to fill in the blank entries that are not obtained from whatever password database API instance is being used. NOTE: whenever a struct smb_passwd or struct sam_passwd is used, it MUST be initialised with pwdb_sam_init() or pwd_smb_init(), see chgpasswd.c for the only example outside of the password database APIs i could find. - added query_useraliases code to rpcclient. - dealt with some nasty interdependencies involving non-smbd programs and the password database API. this is still not satisfactorily resolved completelely, but it's the best i can do for now. - #ifdef'd out some password database options so that people don't mistakenly set them unless they recompile to _use_ those options. lots of debugging done, it's still not finished. the unix/NT uid/gid and user-rid/group-rid issues are better, but not perfect. the "BUILTIN" domain is still missing: users cannot be added to "BUILTIN" groups yet, as we only have an "alias" db API and a "group" db API but not "builtin-alias" db API... (This used to be commit 5d5d7e4de7d1514ab87b07ede629de8aa00519a1) --- source3/rpc_server/srv_lookup.c | 288 +++++++++------------------------------- source3/rpc_server/srv_netlog.c | 123 ++++++----------- source3/rpc_server/srv_samr.c | 135 +++++++------------ 3 files changed, 152 insertions(+), 394 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index 9981ce0371..fc73edc4ed 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -52,43 +52,9 @@ extern fstring global_sam_name; extern DOM_SID global_sam_sid; extern DOM_SID global_sid_S_1_5_20; -/* - * A list of the rids of well known BUILTIN and Domain users - * and groups. - */ - -rid_name builtin_alias_rids[] = -{ - { BUILTIN_ALIAS_RID_ADMINS , "Administrators" }, - { BUILTIN_ALIAS_RID_USERS , "Users" }, - { BUILTIN_ALIAS_RID_GUESTS , "Guests" }, - { BUILTIN_ALIAS_RID_POWER_USERS , "Power Users" }, - - { BUILTIN_ALIAS_RID_ACCOUNT_OPS , "Account Operators" }, - { BUILTIN_ALIAS_RID_SYSTEM_OPS , "System Operators" }, - { BUILTIN_ALIAS_RID_PRINT_OPS , "Print Operators" }, - { BUILTIN_ALIAS_RID_BACKUP_OPS , "Backup Operators" }, - { BUILTIN_ALIAS_RID_REPLICATOR , "Replicator" }, - { 0 , NULL } -}; - -/* array lookup of well-known Domain RID users. */ -rid_name domain_user_rids[] = -{ - { DOMAIN_USER_RID_ADMIN , "Administrator" }, - { DOMAIN_USER_RID_GUEST , "Guest" }, - { 0 , NULL } -}; - -/* array lookup of well-known Domain RID groups. */ -rid_name domain_group_rids[] = -{ - { DOMAIN_GROUP_RID_ADMINS , "Domain Admins" }, - { DOMAIN_GROUP_RID_USERS , "Domain Users" }, - { DOMAIN_GROUP_RID_GUESTS , "Domain Guests" }, - { 0 , NULL } -}; - +extern rid_name builtin_alias_rids[]; +extern rid_name domain_user_rids[]; +extern rid_name domain_group_rids[]; int make_dom_gids(DOMAIN_GRP *mem, int num_members, DOM_GID **ppgids) { @@ -117,13 +83,20 @@ int make_dom_gids(DOMAIN_GRP *mem, int num_members, DOM_GID **ppgids) char *name = mem[count].name; become_root(True); - status = lookup_group_name(name, &sid, &type); + status = lookup_name(name, &sid, &type); unbecome_root(True); - sid_split_rid(&sid, &rid); - - if (status == 0x0 && sid_equal(&sid, &global_sam_sid)) + if (status == 0x0 && !sid_front_equal(&global_sam_sid, &sid)) + { + fstring sid_str; + sid_to_string(sid_str, &sid); + DEBUG(1,("make_dom_gids: unknown sid %s for groupname %s\n", + sid_str, name)); + } + else if (status == 0x0) { + sid_split_rid(&sid, &rid); + gids = (DOM_GID *)Realloc( gids, sizeof(DOM_GID) * (count+1) ); if (gids == NULL) @@ -141,7 +114,7 @@ int make_dom_gids(DOMAIN_GRP *mem, int num_members, DOM_GID **ppgids) } else { - DEBUG(1,("make_dom_gids: unknown group name %s\n", name)); + DEBUG(1,("make_dom_gids: unknown groupname %s\n", name)); } } @@ -428,7 +401,7 @@ uint32 lookup_user_sid(DOM_SID *sid, char *user_name, uint8 *type) if (disp_info != NULL) { - fstrcpy(user_name, disp_info->smb_name); + fstrcpy(user_name, disp_info->nt_name); DEBUG(5,(" = %s\n", user_name)); return 0x0; } @@ -442,14 +415,21 @@ uint32 lookup_user_sid(DOM_SID *sid, char *user_name, uint8 *type) /******************************************************************* lookup_group_rid ********************************************************************/ -uint32 lookup_group_name(char *grp_name, DOM_SID *sid, uint8 *type) +uint32 lookup_added_group_name(const char *grp_name, const char *domain, + DOM_SID *sid, uint8 *type) { DOMAIN_GRP *grp = NULL; (*type) = SID_NAME_DOM_GRP; - DEBUG(5,("lookup_group_name: name: %s", grp_name)); + DEBUG(5,("lookup_added_group_name: name: %s", grp_name)); - grp = getgroupnam(grp_name, NULL, NULL); + if (!strequal(domain, global_sam_name)) + { + DEBUG(5,(" not our domain\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; + } + + grp = getgroupntnam(grp_name, NULL, NULL); if (grp != NULL) { @@ -465,45 +445,23 @@ uint32 lookup_group_name(char *grp_name, DOM_SID *sid, uint8 *type) } /******************************************************************* - lookup_wk_group_name - ********************************************************************/ -uint32 lookup_wk_group_name(char *group_name, DOM_SID *sid, uint8 *type) -{ - char *grp_name; - int i = -1; /* start do loop at -1 */ - uint32 rid; - (*type) = SID_NAME_WKN_GRP; - - do /* find, if it exists, a group rid for the group name */ - { - i++; - rid = domain_group_rids[i].rid; - grp_name = domain_group_rids[i].name; - - if (strequal(grp_name, group_name)) - { - sid_copy(sid, &global_sam_sid); - sid_append_rid(sid, rid); - - return 0x0; - } - - } while (grp_name != NULL); - - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_alias_name + lookup_added_alias_name ********************************************************************/ -uint32 lookup_alias_name(char *als_name, DOM_SID *sid, uint8 *type) +uint32 lookup_added_alias_name(const char *als_name, const char *domain, + DOM_SID *sid, uint8 *type) { LOCAL_GRP *als = NULL; (*type) = SID_NAME_ALIAS; - DEBUG(5,("lookup_alias_name: name: %s", als_name)); + DEBUG(5,("lookup_added_alias_name: name: %s\%s", domain, als_name)); - als = getaliasnam(als_name, NULL, NULL); + if (!strequal(domain, global_sam_name)) + { + DEBUG(5,(" not our domain\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; + } + + als = getaliasntnam(als_name, NULL, NULL); if (als != NULL) { @@ -518,40 +476,10 @@ uint32 lookup_alias_name(char *als_name, DOM_SID *sid, uint8 *type) return 0xC0000000 | NT_STATUS_NONE_MAPPED; } -/******************************************************************* - lookup_wk_alias_name - ********************************************************************/ -uint32 lookup_wk_alias_name(char *alias_name, DOM_SID *sid, uint8 *type) -{ - char *als_name; - int i = 0; - uint32 rid; - (*type) = SID_NAME_ALIAS; - - do /* find, if it exists, a alias rid for the alias name*/ - { - rid = builtin_alias_rids[i].rid; - als_name = builtin_alias_rids[i].name; - - i++; - - if (strequal(als_name, alias_name)) - { - sid_copy(sid, &global_sid_S_1_5_20); - sid_append_rid(sid, rid); - - return 0x0; - } - - } while (als_name != NULL); - - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - /******************************************************************* lookup_added_user_rid ********************************************************************/ -uint32 lookup_added_user_rids(char *user_name, +uint32 lookup_added_user_rids(char *nt_name, uint32 *usr_rid, uint32 *grp_rid) { struct sam_passwd *sam_pass; @@ -560,7 +488,7 @@ uint32 lookup_added_user_rids(char *user_name, /* find the user account */ become_root(True); - sam_pass = getsam21pwnam(user_name); + sam_pass = getsam21pwntnam(nt_name); unbecome_root(True); if (sam_pass != NULL) @@ -576,14 +504,20 @@ uint32 lookup_added_user_rids(char *user_name, /******************************************************************* lookup_added_user_name ********************************************************************/ -uint32 lookup_added_user_name(char *user_name, DOM_SID *sid, uint8 *type) +static uint32 lookup_added_user_name(const char *nt_name, const char *domain, + DOM_SID *sid, uint8 *type) { struct sam_passwd *sam_pass; (*type) = SID_NAME_USER; + if (!strequal(domain, global_sam_name)) + { + return 0xC0000000 | NT_STATUS_NONE_MAPPED; + } + /* find the user account */ become_root(True); - sam_pass = getsam21pwnam(user_name); + sam_pass = getsam21pwntnam(nt_name); unbecome_root(True); if (sam_pass != NULL) @@ -597,67 +531,18 @@ uint32 lookup_added_user_name(char *user_name, DOM_SID *sid, uint8 *type) return 0xC0000000 | NT_STATUS_NONE_MAPPED; } -/******************************************************************* - lookup_wk_user_name - ********************************************************************/ -uint32 lookup_wk_user_name(char *user_name, DOM_SID *sid, uint8 *type) -{ - char *usr_name; - int i = -1; /* start do loop at -1 */ - (*type) = SID_NAME_USER; - - do /* find, if it exists, a alias rid for the alias name*/ - { - i++; - usr_name = domain_user_rids[i].name; - - } while (usr_name != NULL && !strequal(usr_name, user_name)); - - if (usr_name != NULL) - { - sid_copy(sid, &global_sid_S_1_5_20); - sid_append_rid(sid, domain_user_rids[i].rid); - return 0; - } - - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_added_grp_name - ********************************************************************/ -uint32 lookup_added_grp_name(char *name, DOM_SID *sid, uint8 *type) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - - status = (status != 0x0) ? lookup_group_name(name, sid, type) : status; - status = (status != 0x0) ? lookup_alias_name(name, sid, type) : status; - - return status; -} - -/******************************************************************* - lookup_builtin_grp_name - ********************************************************************/ -uint32 lookup_builtin_grp_name(char *name, DOM_SID *sid, uint8 *type) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - - status = (status != 0x0) ? lookup_wk_group_name(name, sid, type) : status; - status = (status != 0x0) ? lookup_wk_alias_name(name, sid, type) : status; - - return status; -} - /******************************************************************* lookup_grp_name ********************************************************************/ -uint32 lookup_grp_name(char *name, DOM_SID *sid, uint8 *type) +static uint32 lookup_grp_name(const char *name, const char *domain, + DOM_SID *sid, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_builtin_grp_name(name, sid, type) : status; - status = (status != 0x0) ? lookup_added_grp_name (name, sid, type) : status; + status = (status != 0x0) ? lookup_wk_group_name (name, domain, sid, type) : status; + status = (status != 0x0) ? lookup_builtin_alias_name(name, domain, sid, type) : status; + status = (status != 0x0) ? lookup_added_group_name (name, domain, sid, type) : status; + status = (status != 0x0) ? lookup_added_alias_name (name, domain, sid, type) : status; return status; } @@ -665,12 +550,13 @@ uint32 lookup_grp_name(char *name, DOM_SID *sid, uint8 *type) /******************************************************************* lookup_user_name ********************************************************************/ -uint32 lookup_user_name(char *name, DOM_SID *sid, uint8 *type) +static uint32 lookup_user_name(const char *name, const char *domain, + DOM_SID *sid, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_wk_user_name (name, sid, type) : status; - status = (status != 0x0) ? lookup_added_user_name(name, sid, type) : status; + status = (status != 0x0) ? lookup_wk_user_name (name, domain, sid, type) : status; + status = (status != 0x0) ? lookup_added_user_name(name, domain, sid, type) : status; return status; } @@ -692,66 +578,12 @@ uint32 lookup_name(char *name, DOM_SID *sid, uint8 *type) return status; } - status = (status != 0x0) ? lookup_wk_alias_name(user, sid, type) : status; - status = (status != 0x0) ? lookup_alias_name (user, sid, type) : status; - status = (status != 0x0) ? lookup_user_name (name, sid, type) : status; - status = (status != 0x0) ? lookup_grp_name (name, sid, type) : status; + status = (status != 0x0) ? lookup_user_name (name, domain, sid, type) : status; + status = (status != 0x0) ? lookup_grp_name (name, domain, sid, type) : status; #if 0 - status = (status != 0x0) ? lookup_domain_name (user, sid, type) : status; + status = (status != 0x0) ? lookup_domain_name (domain, sid, type) : status; #endif return status; } -/******************************************************************* - lookup_user_rids - ********************************************************************/ -uint32 lookup_user_rids(char *name, uint32 *usr_rid, uint32 *grp_rid) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - uint8 type; - DOM_SID sid; - - /* - * try an ordinary user lookup - */ - - status = lookup_added_user_rids(name, usr_rid, grp_rid); - if (status == 0) - { - return status; - } - - /* - * hm. must be a well-known user, in a well-known group. - */ - - status = lookup_wk_user_name(name, &sid, &type); - sid_split_rid(&sid, usr_rid); - - if (status != 0 || type != SID_NAME_USER) - { - return status; /* ok, maybe not! */ - } - - if (type != SID_NAME_USER) - { - return 0xC0000000 | NT_STATUS_NONE_MAPPED; /* users only... */ - } - - /* - * ok, got the user rid: now try the group rid - */ - - status = lookup_builtin_grp_name(name, &sid, &type); - sid_split_rid(&sid, usr_rid); - - if (type == SID_NAME_DOM_GRP || - type == SID_NAME_ALIAS || - type == SID_NAME_WKN_GRP) - { - status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - } - - return status; -} diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 7fbd43c38e..4f49735ca0 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -28,10 +28,9 @@ extern int DEBUGLEVEL; -extern BOOL sam_logon_in_ssb; -extern pstring samlogon_user; extern pstring global_myname; extern DOM_SID global_sam_sid; +extern fstring global_sam_name; /************************************************************************* make_net_r_req_chal: @@ -493,7 +492,7 @@ static void api_net_sam_logoff( uint16 vuid, net_login_interactive: *************************************************************************/ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, - struct smb_passwd *smb_pass, + struct sam_passwd *smb_pass, user_struct *vuser) { uint32 status = 0x0; @@ -543,7 +542,7 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, net_login_network: *************************************************************************/ static uint32 net_login_network(NET_ID_INFO_2 *id2, - struct smb_passwd *smb_pass, + struct sam_passwd *smb_pass, user_struct *vuser) { DEBUG(5,("net_login_network: lm_len: %d nt_len: %d\n", @@ -598,7 +597,7 @@ static void api_net_sam_logon( uint16 vuid, NET_USER_INFO_3 usr_info; uint32 status = 0x0; DOM_CRED srv_cred; - struct smb_passwd *smb_pass = NULL; + struct sam_passwd *sam_pass = NULL; UNISTR2 *uni_samlogon_user = NULL; fstring nt_username; @@ -632,14 +631,14 @@ static void api_net_sam_logon( uint16 vuid, { uni_samlogon_user = &(q_l.sam_id.ctr->auth.id1.uni_user_name); - DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); + DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", global_sam_name)); break; } case NET_LOGON_TYPE: { uni_samlogon_user = &(q_l.sam_id.ctr->auth.id2.uni_user_name); - DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); + DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", global_sam_name)); break; } default: @@ -660,26 +659,16 @@ static void api_net_sam_logon( uint16 vuid, DEBUG(3,("User:[%s]\n", nt_username)); - /* - * Convert to a UNIX username. - */ - map_username(nt_username); - - /* - * Do any case conversions. - */ - (void)Get_Pwnam(nt_username, True); - become_root(True); - smb_pass = getsmbpwnam(nt_username); + sam_pass = getsam21pwntnam(nt_username); unbecome_root(True); - if (smb_pass == NULL) + if (sam_pass == NULL) { status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; } - else if (IS_BITS_SET_ALL(smb_pass->acct_ctrl, ACB_DISABLED) && - IS_BITS_CLR_ALL(smb_pass->acct_ctrl, ACB_PWNOTREQ)) + else if (IS_BITS_SET_ALL(sam_pass->acct_ctrl, ACB_DISABLED) && + IS_BITS_CLR_ALL(sam_pass->acct_ctrl, ACB_PWNOTREQ)) { status = 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED; } @@ -687,20 +676,20 @@ static void api_net_sam_logon( uint16 vuid, /* validate password - if required */ - if (status == 0 && !(IS_BITS_SET_ALL(smb_pass->acct_ctrl, ACB_PWNOTREQ))) + if (status == 0 && !(IS_BITS_SET_ALL(sam_pass->acct_ctrl, ACB_PWNOTREQ))) { switch (q_l.sam_id.logon_level) { case INTERACTIVE_LOGON_TYPE: { /* interactive login. */ - status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, smb_pass, vuser); + status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, sam_pass, vuser); break; } case NET_LOGON_TYPE: { /* network login. lm challenge and 24 byte responses */ - status = net_login_network(&q_l.sam_id.ctr->auth.id2, smb_pass, vuser); + status = net_login_network(&q_l.sam_id.ctr->auth.id2, sam_pass, vuser); break; } } @@ -715,88 +704,60 @@ static void api_net_sam_logon( uint16 vuid, if (status == 0) { - DOM_GID *gids = NULL; int num_gids = 0; - NTTIME dummy_time; - pstring logon_script; - pstring profile_path; - pstring home_dir; - pstring home_drive; - pstring my_name; - pstring my_workgroup; DOMAIN_GRP *grp_mem; - 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; - - /* 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); - - pstrcpy(logon_script, lp_logon_script()); - pstrcpy(profile_path, lp_logon_path()); - - pstrcpy(my_workgroup, lp_workgroup()); - - pstrcpy(home_drive, lp_logon_drive()); - pstrcpy(home_dir, lp_logon_home()); - pstrcpy(my_name, global_myname); - strupper(my_name); - - status = lookup_user_rids(nt_username, &r_uid, &r_gid); - status = getusergroupsnam(nt_username, &grp_mem, &num_gids) ? 0 : 0xC0000000 | NT_STATUS_INVALID_PRIMARY_GROUP; - - sam_logon_in_ssb = False; + if (!getusergroupsntnam(nt_username, &grp_mem, &num_gids)) + { + status = 0xC0000000 | NT_STATUS_INVALID_PRIMARY_GROUP; + } if (status == 0x0) { - gids = NULL; + DOM_GID *gids = NULL; num_gids = make_dom_gids(grp_mem, num_gids, &gids); make_net_user_info3(&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 */ - vuser->real_name, /* full_name */ - logon_script , /* logon_script */ - profile_path , /* profile_path */ - home_dir , /* home_dir */ - home_drive , /* dir_drive */ + &sam_pass->logon_time, + &sam_pass->logoff_time, + &sam_pass->kickoff_time, + &sam_pass->pass_last_set_time, + &sam_pass->pass_can_change_time, + &sam_pass->pass_must_change_time, + + sam_pass->nt_name , /* 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 */ + sam_pass->user_rid , /* RID user_id */ + sam_pass->group_rid , /* 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 */ + global_myname , /* char *logon_srv */ + global_sam_name, /* char *logon_dom */ + &global_sam_sid, /* DOM_SID *dom_sid */ NULL); /* char *other_sids */ - } - /* Free any allocated groups array. */ - if (gids) - { - free((char *)gids); + /* Free any allocated groups array. */ + if (gids) + { + free((char *)gids); + } } + } net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status); diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index ff782a7248..fb613c3c51 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -28,8 +28,6 @@ extern int DEBUGLEVEL; -extern BOOL sam_logon_in_ssb; -extern pstring samlogon_user; extern fstring global_sam_name; extern pstring global_myname; extern DOM_SID global_sam_sid; @@ -79,8 +77,8 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, continue; } - user_name_len = strlen(pwd->smb_name); - make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len); + user_name_len = strlen(pwd->nt_name); + make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->nt_name, user_name_len); make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len, user_name_len, 1); pw_buf[(*num_entries)].user_rid = pwd->user_rid; @@ -95,7 +93,7 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, pw_buf[(*num_entries)].acb_info = (uint16)pwd->acct_ctrl; DEBUG(5, ("entry idx: %d user %s, rid 0x%x, acb %x", - (*num_entries), pwd->smb_name, + (*num_entries), pwd->nt_name, pwd->user_rid, pwd->acct_ctrl)); if (acb_mask == 0 || IS_BITS_SET_SOME(pwd->acct_ctrl, acb_mask)) @@ -401,7 +399,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_R_ENUM_DOM_GROUPS r_e; DOMAIN_GRP *grps = NULL; int num_entries = 0; - BOOL got_grps; + BOOL got_grps = False; DOM_SID sid; fstring sid_str; @@ -418,39 +416,29 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, DEBUG(5,("samr_reply_enum_dom_groups: sid %s\n", sid_str)); - /* well-known groups */ - if (sid_equal(&sid, &global_sid_S_1_5_20)) + if (sid_equal(&sid, &global_sam_sid)) { - char *name; + BOOL ret; got_grps = True; - while (num_entries < MAX_SAM_ENTRIES && ((name = domain_group_rids[num_entries].name) != NULL)) - { - DOMAIN_GRP tmp_grp; - - fstrcpy(tmp_grp.name , name); - fstrcpy(tmp_grp.comment, ""); - tmp_grp.rid = domain_group_rids[num_entries].rid; - tmp_grp.attr = 0x7; + become_root(True); + ret = enumdomgroups(&grps, &num_entries); + unbecome_root(True); - if (!add_domain_group(&grps, &num_entries, &tmp_grp)) - { - r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; - break; - } + if (!ret) + { + r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; } } - else if (sid_equal(&sid, &global_sam_sid)) + + if (r_e.status == 0x0 && + (sid_equal(&sid, &global_sam_sid) || + sid_equal(&sid, &global_sid_S_1_5_20))) { - BOOL ret; char *name; int i = 0; got_grps = True; - become_root(True); - ret = enumdomgroups(&grps, &num_entries); - unbecome_root(True); - while (num_entries < MAX_SAM_ENTRIES && ((name = domain_group_rids[i].name) != NULL)) { DOMAIN_GRP tmp_grp; @@ -468,11 +456,6 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, i++; } - - if (!ret) - { - r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; - } } if (r_e.status == 0 && got_grps) @@ -747,10 +730,10 @@ static void api_samr_query_aliasinfo( uint16 vuid, prs_struct *data, prs_struct static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, prs_struct *rdata) { - uint32 rid[MAX_SAM_ENTRIES]; - uint32 status = 0; + uint32 status = 0; + + uint32 *rid = NULL; int num_rids = 0; - int i; struct sam_passwd *sam_pass; DOM_SID usr_sid; DOM_SID dom_sid; @@ -774,12 +757,6 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, sid_to_string(sam_sid_str, &global_sam_sid); } - if (num_rids > MAX_SAM_ENTRIES) - { - num_rids = MAX_SAM_ENTRIES; - DEBUG(5,("samr_query_useraliases: truncating entries to %d\n", num_rids)); - } - if (status == 0x0) { usr_sid = q_u->sid[0].sid; @@ -811,17 +788,18 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, else if (sid_equal(&dom_sid, &usr_sid)) { LOCAL_GRP *mem_grp = NULL; + num_rids = 0; DEBUG(10,("lookup on Domain SID\n")); become_root(True); - getuseraliasnam(sam_pass->smb_name, &mem_grp, &num_rids); + getuseraliasntnam(sam_pass->nt_name, &mem_grp, &num_rids); unbecome_root(True); - num_rids = MIN(num_rids, MAX_SAM_ENTRIES); - - if (mem_grp != NULL) + rid = malloc(num_rids * sizeof(uint32)); + if (mem_grp != NULL && rid != NULL) { + int i; for (i = 0; i < num_rids; i++) { rid[i] = mem_grp[i].rid; @@ -840,6 +818,11 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, /* store the response in the SMB stream */ samr_io_r_query_useraliases("", &r_u, rdata, 0); + if (rid != NULL) + { + free(rid); + } + DEBUG(5,("samr_query_useraliases: %d\n", __LINE__)); } @@ -1150,27 +1133,21 @@ static void api_samr_open_user( uint16 vuid, prs_struct *data, prs_struct *rdata *************************************************************************/ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) { - struct smb_passwd *smb_pass; - - if (!pwdb_rid_is_user(user_rid)) - { - DEBUG(4,("RID 0x%x is not a user RID\n", user_rid)); - return False; - } + struct sam_passwd *sam_pass; become_root(True); - smb_pass = getsmbpwrid(user_rid); + sam_pass = getsam21pwrid(user_rid); unbecome_root(True); - if (smb_pass == NULL) + if (sam_pass == NULL) { DEBUG(4,("User 0x%x not found\n", user_rid)); return False; } - DEBUG(3,("User:[%s]\n", smb_pass->smb_name)); + DEBUG(3,("User:[%s]\n", sam_pass->nt_name)); - make_sam_user_info10(id10, smb_pass->acct_ctrl); + make_sam_user_info10(id10, sam_pass->acct_ctrl); return True; } @@ -1180,17 +1157,10 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) *************************************************************************/ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) { - NTTIME dummy_time; struct sam_passwd *sam_pass; LOGON_HRS hrs; int i; - if (!pwdb_rid_is_user(user_rid)) - { - DEBUG(4,("RID 0x%x is not a user RID\n", user_rid)); - return False; - } - become_root(True); sam_pass = getsam21pwrid(user_rid); unbecome_root(True); @@ -1201,12 +1171,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) return False; } - DEBUG(3,("User:[%s]\n", sam_pass->smb_name)); - - dummy_time.low = 0xffffffff; - dummy_time.high = 0x7fffffff; - - DEBUG(0,("get_user_info_21 - TODO: convert unix times to NTTIMEs\n")); + DEBUG(3,("User:[%s]\n", sam_pass->nt_name)); /* create a LOGON_HRS structure */ hrs.len = sam_pass->hours_len; @@ -1218,14 +1183,14 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) make_sam_user_info21(id21, - &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 */ + &sam_pass->logon_time, + &sam_pass->logoff_time, + &sam_pass->kickoff_time, + &sam_pass->pass_last_set_time, + &sam_pass->pass_can_change_time, + &sam_pass->pass_must_change_time, - sam_pass->smb_name, /* user_name */ + sam_pass->nt_name, /* user_name */ sam_pass->full_name, /* full_name */ sam_pass->home_dir, /* home_dir */ sam_pass->dir_drive, /* dir_drive */ @@ -1238,13 +1203,13 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) sam_pass->user_rid, /* RID user_id */ sam_pass->group_rid, /* RID group_id */ - sam_pass->acct_ctrl, + sam_pass->acct_ctrl, - sam_pass->unknown_3, /* unknown_3 */ - sam_pass->logon_divs, /* divisions per week */ - &hrs, /* logon hours */ - sam_pass->unknown_5, - sam_pass->unknown_6); + sam_pass->unknown_3, /* unknown_3 */ + sam_pass->logon_divs, /* divisions per week */ + &hrs, /* logon hours */ + sam_pass->unknown_5, + sam_pass->unknown_6); return True; } @@ -1393,7 +1358,7 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, DOMAIN_GRP *mem_grp = NULL; become_root(True); - getusergroupsnam(sam_pass->smb_name, &mem_grp, &num_groups); + getusergroupsntnam(sam_pass->nt_name, &mem_grp, &num_groups); unbecome_root(True); gids = NULL; @@ -1559,7 +1524,7 @@ static void api_samr_unknown_32( uint16 vuid, prs_struct *data, prs_struct *rdat q_u.uni_mach_acct.uni_str_len)); become_root(True); - sam_pass = getsam21pwnam(mach_acct); + sam_pass = getsam21pwntnam(mach_acct); unbecome_root(True); if (sam_pass != NULL) -- cgit From 53373894acfff45885caf1e19a54141546ba5eea Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 29 Nov 1998 20:06:52 +0000 Subject: "retired" two modules to preserve their cvs history. added their replacements, added sam password database API modules (This used to be commit b1d1c1337c69c6f6bf25ab932a1a6a757e3ea2ae) --- source3/rpc_server/srv_sid.c | 521 +------------------------------------------ 1 file changed, 1 insertion(+), 520 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_sid.c b/source3/rpc_server/srv_sid.c index a428a7f068..6552e0963b 100644 --- a/source3/rpc_server/srv_sid.c +++ b/source3/rpc_server/srv_sid.c @@ -19,523 +19,4 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "includes.h" - - -extern int DEBUGLEVEL; -extern pstring scope; -extern pstring global_myname; - -/* - * This is set on startup - it defines the SID for this - * machine, and therefore the SAM database for which it is - * responsible. - */ - -DOM_SID global_sam_sid; - -/* - * This is the name associated with the SAM database for - * which this machine is responsible. In the case of a PDC - * or PDC, this name is the same as the workgroup. In the - * case of "security = domain" mode, this is the same as - * the name of the server (global_myname). - */ - -fstring global_sam_name; - -/* - * This is obtained on startup - it defines the SID for which - * this machine is a member. It is therefore only set, and - * used, in "security = domain" mode. - */ - -DOM_SID global_member_sid; - -/* - * note the lack of a "global_member_name" - this is because - * this is the same as "global_myworkgroup". - */ - -/* - * some useful sids - */ - -DOM_SID global_sid_S_1_5_20; /* local well-known domain */ -DOM_SID global_sid_S_1_1; /* everyone */ -DOM_SID global_sid_S_1_3; /* */ -DOM_SID global_sid_S_1_5; /* NT Authority */ - -extern fstring global_myworkgroup; -/* extern fstring global_member_dom_name; */ - -static struct sid_name_map_info -{ - DOM_SID *sid; - char *name; - -} -sid_name_map[] = -{ - { &global_sid_S_1_5_20, "BUILTIN" }, - { &global_sid_S_1_1 , "Everyone" }, - { &global_sid_S_1_3 , "don't know" }, - { &global_sid_S_1_5 , "NT Authority" }, - { &global_sam_sid , global_sam_name }, - { &global_member_sid , global_myworkgroup }, - { NULL , NULL } -}; - -/**************************************************************************** - Read the machine SID from a file. -****************************************************************************/ - -static BOOL read_sid_from_file(int fd, char *sid_file) -{ - fstring fline; - fstring sid_str; - - memset(fline, '\0', sizeof(fline)); - - if (read(fd, fline, sizeof(fline) -1 ) < 0) { - DEBUG(0,("unable to read file %s. Error was %s\n", - sid_file, strerror(errno) )); - return False; - } - - /* - * Convert to the machine SID. - */ - - fline[sizeof(fline)-1] = '\0'; - if (!string_to_sid( &global_sam_sid, fline)) { - DEBUG(0,("unable to generate machine SID.\n")); - return False; - } - - sid_to_string(sid_str, &global_sam_sid); - DEBUG(5,("read_sid_from_file: sid %s\n", sid_str)); - - return True; -} - -/**************************************************************************** - sets up the name associated with the SAM database for which we are responsible -****************************************************************************/ -void get_sam_domain_name(void) -{ - switch (lp_server_role()) - { - case ROLE_DOMAIN_PDC: - case ROLE_DOMAIN_BDC: - { - /* we are PDC (or BDC) for a Domain */ - fstrcpy(global_sam_name, lp_workgroup()); - break; - } - case ROLE_DOMAIN_MEMBER: - { - /* we are a "PDC", but FOR LOCAL SAM DATABASE ONLY */ - fstrcpy(global_sam_name, global_myname); - break; - } - default: - { - /* no domain role, probably due to "security = share" */ - memset(global_sam_name, 0, sizeof(global_sam_name)); - break; - } - } -} - -/**************************************************************************** - obtain the sid from the PDC. do some verification along the way... -****************************************************************************/ -BOOL get_member_domain_sid(void) -{ - POLICY_HND pol; - fstring srv_name; - struct cli_state cli; - BOOL res = True; - DOM_SID sid3; - DOM_SID sid5; - fstring dom3; - fstring dom5; - - switch (lp_server_role()) - { - case ROLE_DOMAIN_NONE: - { - ZERO_STRUCT(global_member_sid); - return True; - } - case ROLE_DOMAIN_PDC: - { - sid_copy(&global_member_sid, &global_sam_sid); - return True; - } - default: - { - /* member or BDC, we're going for connection to PDC */ - break; - } - } - - if (!cli_connect_serverlist(&cli, lp_passwordserver())) - { - DEBUG(0,("get_member_domain_sid: unable to initialise client connection.\n")); - return False; - } - - /* - * Ok - we have an anonymous connection to the IPC$ share. - * Now start the NT Domain stuff :-). - */ - - fstrcpy(dom3, ""); - fstrcpy(dom5, ""); - ZERO_STRUCT(sid3); - ZERO_STRUCT(sid5); - - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, global_myname); - strupper(srv_name); - - /* open LSARPC session. */ - res = res ? cli_nt_session_open(&cli, PIPE_LSARPC) : False; - - /* lookup domain controller; receive a policy handle */ - res = res ? do_lsa_open_policy(&cli, srv_name, &pol, False) : False; - - /* send client info query, level 3. receive domain name and sid */ - res = res ? do_lsa_query_info_pol(&cli, &pol, 3, dom3, &sid3) : False; - - /* send client info query, level 5. receive domain name and sid */ - res = res ? do_lsa_query_info_pol(&cli, &pol, 5, dom5, &sid5) : False; - - /* close policy handle */ - res = res ? do_lsa_close(&cli, &pol) : False; - - /* close the session */ - cli_nt_session_close(&cli); - cli_ulogoff(&cli); - cli_shutdown(&cli); - - if (res) - { - pstring sid; - DEBUG(2,("LSA Query Info Policy\n")); - sid_to_string(sid, &sid3); - DEBUG(2,("Domain Member - Domain: %s SID: %s\n", dom3, sid)); - sid_to_string(sid, &sid5); - DEBUG(2,("Domain Controller - Domain: %s SID: %s\n", dom5, sid)); - - if (!strequal(dom3, global_myworkgroup) || - !strequal(dom5, global_myworkgroup)) - { - DEBUG(0,("get_member_domain_sid: %s is a DC for %s not %s\n", - cli.desthost, dom5, global_myworkgroup)); - res = False; - } - } - else - { - DEBUG(1,("lsa query info failed\n")); - } - if (!res) - { - DEBUG(0,("get_member_domain_sid: unable to obtain Domain member SID\n")); - } - else - { - /* this is a _lot_ of trouble to go to for just this info: */ - global_member_sid = sid5; - } - - return res; -} - -/**************************************************************************** - creates some useful well known sids -****************************************************************************/ -void generate_wellknown_sids(void) -{ - string_to_sid(&global_sid_S_1_5_20, "S-1-5-32"); - string_to_sid(&global_sid_S_1_1 , "S-1-1" ); - string_to_sid(&global_sid_S_1_3 , "S-1-3" ); - string_to_sid(&global_sid_S_1_5 , "S-1-5" ); -} - -/**************************************************************************** - Generate the global machine sid. Look for the MACHINE.SID file first, if - not found then look in smb.conf and use it to create the MACHINE.SID file. -****************************************************************************/ -BOOL generate_sam_sid(void) -{ - int fd; - int i; - char *p; - pstring sid_file; - fstring sid_string; - SMB_STRUCT_STAT st; - uchar raw_sid_data[12]; - - pstrcpy(sid_file, lp_smb_passwd_file()); - p = strrchr(sid_file, '/'); - if (p != NULL) { - *++p = '\0'; - } - - if (!directory_exist(sid_file, NULL)) { - if (dos_mkdir(sid_file, 0700) != 0) { - DEBUG(0,("can't create private directory %s : %s\n", - sid_file, strerror(errno))); - return False; - } - } - - pstrcat(sid_file, "MACHINE.SID"); - - if ((fd = sys_open(sid_file, O_RDWR | O_CREAT, 0644)) == -1) { - DEBUG(0,("unable to open or create file %s. Error was %s\n", - sid_file, strerror(errno) )); - return False; - } - - /* - * Check if the file contains data. - */ - - if (sys_fstat( fd, &st) < 0) { - DEBUG(0,("unable to stat file %s. Error was %s\n", - sid_file, strerror(errno) )); - close(fd); - return False; - } - - if (st.st_size > 0) { - /* - * We have a valid SID - read it. - */ - if (!read_sid_from_file( fd, sid_file)) { - DEBUG(0,("unable to read file %s. Error was %s\n", - sid_file, strerror(errno) )); - close(fd); - return False; - } - close(fd); - return True; - } - - /* - * Generate the new sid data & turn it into a string. - */ - generate_random_buffer( raw_sid_data, 12, True); - - fstrcpy( sid_string, "S-1-5-21"); - for( i = 0; i < 3; i++) { - fstring tmp_string; - slprintf( tmp_string, sizeof(tmp_string) - 1, "-%u", IVAL(raw_sid_data, i*4)); - fstrcat( sid_string, tmp_string); - } - - fstrcat(sid_string, "\n"); - - /* - * Ensure our new SID is valid. - */ - - if (!string_to_sid( &global_sam_sid, sid_string)) { - DEBUG(0,("unable to generate machine SID.\n")); - return False; - } - - /* - * Do an exclusive blocking lock on the file. - */ - - if (!do_file_lock( fd, 60, F_WRLCK)) { - DEBUG(0,("unable to lock file %s. Error was %s\n", - sid_file, strerror(errno) )); - close(fd); - return False; - } - - /* - * At this point we have a blocking lock on the SID - * file - check if in the meantime someone else wrote - * SID data into the file. If so - they were here first, - * use their data. - */ - - if (sys_fstat( fd, &st) < 0) { - DEBUG(0,("unable to stat file %s. Error was %s\n", - sid_file, strerror(errno) )); - close(fd); - return False; - } - - if (st.st_size > 0) { - /* - * Unlock as soon as possible to reduce - * contention on the exclusive lock. - */ - do_file_lock( fd, 60, F_UNLCK); - - /* - * We have a valid SID - read it. - */ - - if (!read_sid_from_file( fd, sid_file)) { - DEBUG(0,("unable to read file %s. Error was %s\n", - sid_file, strerror(errno) )); - close(fd); - return False; - } - close(fd); - return True; - } - - /* - * The file is still empty and we have an exlusive lock on it. - * Write out out SID data into the file. - */ - - if (fchmod(fd, 0644) < 0) { - DEBUG(0,("unable to set correct permissions on file %s. \ -Error was %s\n", sid_file, strerror(errno) )); - close(fd); - return False; - } - - if (write( fd, sid_string, strlen(sid_string)) != strlen(sid_string)) { - DEBUG(0,("unable to write file %s. Error was %s\n", - sid_file, strerror(errno) )); - close(fd); - return False; - } - - /* - * Unlock & exit. - */ - - do_file_lock( fd, 60, F_UNLCK); - close(fd); - return True; -} - -/************************************************************************** - turns a domain name into a SID. - - *** side-effect: if the domain name is NULL, it is set to our domain *** - -***************************************************************************/ -BOOL map_domain_name_to_sid(DOM_SID *sid, char **nt_domain) -{ - if (nt_domain == NULL) - { - *sid = global_sam_sid; - return True; - } - - if ((*nt_domain) == NULL) - { - DEBUG(5,("map_domain_name_to_sid: overriding NULL name to %s\n", - global_sam_name)); - (*nt_domain) = strdup(global_sam_name); - sid_copy(sid, &global_sam_sid); - return True; - } - - if ((*nt_domain)[0] == 0) - { - DEBUG(5,("map_domain_name_to_sid: overriding blank name to %s\n", - global_sam_name)); - free(*nt_domain); - (*nt_domain) = strdup(global_sam_name); - sid_copy(sid, &global_sam_sid); - return True; - } - - if (strequal((*nt_domain), global_sam_name)) - { - sid_copy(sid, &global_sam_sid); - return True; - } - - DEBUG(0,("map_domain_name_to_sid: mapping to %s NOT IMPLEMENTED\n", - (*nt_domain))); - return False; -} - -/************************************************************************** - turns a domain SID into a name. - -***************************************************************************/ -BOOL map_domain_sid_to_name(DOM_SID *sid, char *nt_domain) -{ - fstring sid_str; - int i = 0; - sid_to_string(sid_str, sid); - - DEBUG(5,("map_domain_sid_to_name: %s\n", sid_str)); - - if (nt_domain == NULL) - { - return False; - } - - while (sid_name_map[i].sid != NULL) - { - sid_to_string(sid_str, sid_name_map[i].sid); - DEBUG(5,("compare: %s\n", sid_str)); - if (sid_equal(sid_name_map[i].sid, sid)) - { - fstrcpy(nt_domain, sid_name_map[i].name); - DEBUG(5,("found %s\n", nt_domain)); - return True; - } - i++; - } - - DEBUG(0,("map_domain_sid_to_name: mapping NOT IMPLEMENTED\n")); - - return False; -} - -/************************************************************************** - splits a name of format \DOMAIN\name into its two components. - sets the DOMAIN name to global_sam_name if it has not been specified. -***************************************************************************/ -BOOL split_domain_name(char *fullname, char *domain, char *name) -{ - fstring full_name; - char *p; - - if (fullname == NULL || domain == NULL || name == NULL) - { - return False; - } - - if (fullname[0] == '\\') - { - fullname++; - } - fstrcpy(full_name, fullname); - p = strchr(full_name+1, '\\'); - - if (p != NULL) - { - *p = 0; - fstrcpy(domain, full_name); - fstrcpy(name, p+1); - } - else - { - fstrcpy(domain, global_sam_name); - fstrcpy(name, full_name); - } - - DEBUG(5,("name '%s' split into '\\%s\\%s'\n", fullname, domain, name)); - return True; -} +/* this module is retired, is is called lib/sids.c */ -- cgit From 31044dd8e6419b305779408a4b3b0fbd8eab11b5 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 30 Nov 1998 15:08:58 +0000 Subject: - adding builtin[alias]db. - lib/sids.c: generate_sam_sid() modified to take a domain name: it now generates "DOMAIN_NAME.SID". reasons: 1) if you run multiple samba servers on the same machine under different netbios names as members of a domain, they won't all use the same SID, which is a _big_ mistake but it would happen _by default_. 2) we have (had) a problem with sid_to_string() and string_to_sid() which cause SIDs to be incorrectly read. one of the major reasons for *NOT* making this change was so as not to disrupt existing users. but as they will be anyway by this bug, we might as well go ahead. - passdb/smbpass.c: wanted to change the meaning of the name in the smbpasswd file to an "nt" name not a "unix" name. this is probably not a good idea: reverted this. - output formatting / bug-fixing in rpcclient query_useraliases code. (This used to be commit e4930f5f48f8246ceec8add8bf769954a963190c) --- source3/rpc_server/srv_lsa.c | 7 +++---- source3/rpc_server/srv_samr.c | 23 +++++++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index abbe4ccd93..62c8f8a0cd 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -32,9 +32,7 @@ extern DOM_SID global_sam_sid; extern fstring global_sam_name; extern DOM_SID global_member_sid; extern fstring global_myworkgroup; -extern DOM_SID global_sid_S_1_1; -extern DOM_SID global_sid_S_1_3; -extern DOM_SID global_sid_S_1_5; +extern DOM_SID global_sid_S_1_5_20; /*************************************************************************** lsa_reply_open_policy2 @@ -264,7 +262,8 @@ static void make_lsa_trans_names(DOM_R_REF *ref, else if (sid_split_rid (&find_sid, &rid) && map_domain_sid_to_name(&find_sid, dom_name)) { - if (sid_equal(&find_sid, &global_sam_sid)) + if (sid_equal(&find_sid, &global_sam_sid) || + sid_equal(&find_sid, &global_sid_S_1_5_20)) { status = lookup_sid(&tmp_sid, name, &sid_name_use); } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index fb613c3c51..d0f139645c 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -732,6 +732,7 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, { uint32 status = 0; + LOCAL_GRP *mem_grp = NULL; uint32 *rid = NULL; int num_rids = 0; struct sam_passwd *sam_pass; @@ -781,21 +782,32 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, if (status == 0x0) { + DEBUG(10,("sid is %s\n", dom_sid_str)); + if (sid_equal(&dom_sid, &global_sid_S_1_5_20)) { DEBUG(10,("lookup on S-1-5-20\n")); + + become_root(True); + getuserbuiltinntnam(sam_pass->nt_name, &mem_grp, &num_rids); + unbecome_root(True); } else if (sid_equal(&dom_sid, &usr_sid)) { - LOCAL_GRP *mem_grp = NULL; - num_rids = 0; - DEBUG(10,("lookup on Domain SID\n")); become_root(True); getuseraliasntnam(sam_pass->nt_name, &mem_grp, &num_rids); unbecome_root(True); + } + else + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + } + } + if (status == 0x0 && num_rids > 0) + { rid = malloc(num_rids * sizeof(uint32)); if (mem_grp != NULL && rid != NULL) { @@ -805,11 +817,6 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, rid[i] = mem_grp[i].rid; } free(mem_grp); - } - } - else - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; } } -- cgit From c6ad04b8fb4ee5cbf862a35b4c143a6f75555718 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 30 Nov 1998 22:42:13 +0000 Subject: attempting to fix "domain user map" up, but it's a bit complicated. i may simply go for a response in the NetSamLogon returning the unix username, forcing the NT user to appear to be a unix user, however even that is fraught with implications. might just have to go the whole hog and do this tuple thing, "unix_name + nt_name" always associated together... issue with api_net_sam_logon, getsam21pwent() being called twice, the second time overwriting static buffer data (argh) so had to make a copy. noticed a nested "become_root()"/"unbecome_root()" which will have to be tracked down... (This used to be commit 474f94f419a531e33b475249da7efb99ac22f454) --- source3/rpc_server/srv_netlog.c | 81 +++++++++++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 4f49735ca0..bb8bc59bc5 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -599,8 +599,26 @@ static void api_net_sam_logon( uint16 vuid, DOM_CRED srv_cred; struct sam_passwd *sam_pass = NULL; UNISTR2 *uni_samlogon_user = NULL; + UNISTR2 *uni_domain = NULL; fstring nt_username; + NTTIME logon_time ; + NTTIME logoff_time ; + NTTIME kickoff_time ; + NTTIME pass_last_set_time ; + NTTIME pass_can_change_time ; + NTTIME pass_must_change_time; + + fstring nt_name ; + fstring full_name ; + fstring logon_script; + fstring profile_path; + fstring home_dir ; + fstring dir_drive ; + + uint32 user_rid ; + uint32 group_rid; + user_struct *vuser = NULL; if ((vuser = get_valid_user_struct(vuid)) == NULL) @@ -630,6 +648,7 @@ static void api_net_sam_logon( uint16 vuid, case INTERACTIVE_LOGON_TYPE: { uni_samlogon_user = &(q_l.sam_id.ctr->auth.id1.uni_user_name); + uni_domain = &(q_l.sam_id.ctr->auth.id1.uni_domain_name); DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", global_sam_name)); break; @@ -637,6 +656,7 @@ static void api_net_sam_logon( uint16 vuid, case NET_LOGON_TYPE: { uni_samlogon_user = &(q_l.sam_id.ctr->auth.id2.uni_user_name); + uni_domain = &(q_l.sam_id.ctr->auth.id2.uni_domain_name); DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", global_sam_name)); break; @@ -654,9 +674,12 @@ static void api_net_sam_logon( uint16 vuid, if (status == 0) { - pstrcpy(nt_username, unistrn2(uni_samlogon_user->buffer, - uni_samlogon_user->uni_str_len)); - + fstrcpy(nt_username, unistr2_to_str(uni_samlogon_user)); +#if 0 + slprintf(nt_username, sizeof(nt_username), "%s\\%s", + unistr2_to_str(uni_domain), + unistr2_to_str(uni_samlogon_user)); +#endif DEBUG(3,("User:[%s]\n", nt_username)); become_root(True); @@ -674,6 +697,26 @@ static void api_net_sam_logon( uint16 vuid, } } + if (status == 0x0) + { + logon_time = sam_pass->logon_time; + logoff_time = sam_pass->logoff_time; + kickoff_time = sam_pass->kickoff_time; + pass_last_set_time = sam_pass->pass_last_set_time; + pass_can_change_time = sam_pass->pass_can_change_time; + pass_must_change_time = sam_pass->pass_must_change_time; + + fstrcpy(nt_name , sam_pass->nt_name); + fstrcpy(full_name , sam_pass->full_name); + fstrcpy(logon_script, sam_pass->logon_script); + fstrcpy(profile_path, sam_pass->profile_path); + fstrcpy(home_dir , sam_pass->home_dir); + fstrcpy(dir_drive , sam_pass->dir_drive); + + user_rid = sam_pass->user_rid; + group_rid = sam_pass->group_rid; + } + /* validate password - if required */ if (status == 0 && !(IS_BITS_SET_ALL(sam_pass->acct_ctrl, ACB_PWNOTREQ))) @@ -705,7 +748,7 @@ static void api_net_sam_logon( uint16 vuid, if (status == 0) { int num_gids = 0; - DOMAIN_GRP *grp_mem; + DOMAIN_GRP *grp_mem = NULL; /* set up pointer indicating user/password failed to be found */ usr_info.ptr_user_info = 0; @@ -721,25 +764,25 @@ static void api_net_sam_logon( uint16 vuid, num_gids = make_dom_gids(grp_mem, num_gids, &gids); make_net_user_info3(&usr_info, - &sam_pass->logon_time, - &sam_pass->logoff_time, - &sam_pass->kickoff_time, - &sam_pass->pass_last_set_time, - &sam_pass->pass_can_change_time, - &sam_pass->pass_must_change_time, - - sam_pass->nt_name , /* 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 */ + &logon_time, + &logoff_time, + &kickoff_time, + &pass_last_set_time, + &pass_can_change_time, + &pass_must_change_time, + + nt_name , /* user_name */ + full_name , /* full_name */ + logon_script , /* logon_script */ + profile_path , /* profile_path */ + home_dir , /* home_dir */ + dir_drive , /* dir_drive */ 0, /* logon_count */ 0, /* bad_pw_count */ - sam_pass->user_rid , /* RID user_id */ - sam_pass->group_rid , /* RID group_id */ + user_rid , /* RID user_id */ + group_rid , /* RID group_id */ num_gids, /* uint32 num_groups */ gids , /* DOM_GID *gids */ 0x20 , /* uint32 user_flgs (?) */ -- cgit From 67638b8d2b59dc992280af934346a5a1ef5fe62d Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 1 Dec 1998 16:04:24 +0000 Subject: adding some samr parsing calls (group / alias adding / deleting) added code that moves MACHINE.SID to DOMAIN_NAME.SID if it exists. (This used to be commit 51c1c31768a92d9c57ee6c09b78419bcbc544f03) --- source3/rpc_server/srv_samr.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index d0f139645c..45095a9c3b 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -678,8 +678,9 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, prs_struct *rdata) { SAMR_R_QUERY_ALIASINFO r_e; + ALIAS_INFO_CTR ctr; + uint32 status = 0x0; - r_e.status = 0x0; r_e.ptr = 0; /* find the policy handle. open a policy on it. */ @@ -690,17 +691,21 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, DEBUG(5,("samr_reply_query_aliasinfo: %d\n", __LINE__)); - if (r_e.status == 0x0) + if (status == 0x0) { - if (q_u->switch_level != 3) + if (q_u->switch_level == 3) + { + status = NT_STATUS_INVALID_INFO_CLASS; + } + else { - r_e.status = NT_STATUS_INVALID_INFO_CLASS; + r_e.ptr = 1; + ctr.switch_value = 3; + make_samr_alias_info3(&ctr.alias.info3, ""); } } - make_samr_r_query_aliasinfo(&r_e, q_u->switch_level, - "", - r_e.status); + make_samr_r_query_aliasinfo(&r_e, status == 0 ? &ctr : NULL, status); /* store the response in the SMB stream */ samr_io_r_query_aliasinfo("", &r_e, rdata, 0); -- cgit From 04e382fb166a64de193dc3c7b21187d8382eaeea Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 1 Dec 1998 19:10:44 +0000 Subject: rpc_samr.h parse_samr.c srv_samr.c : samr_query_aliasmembers (cool!) util_pwdb.c sids.c nmbd.c server.c smbpasswd.c swat.c : pwdb_initialise(BOOL is_server) now creates / reads DOMAIN_NAME.SID if is_server is True, and does LsaQueryInfoPolicy(levels 3 and 5) to obtain member and pdc sids. (This used to be commit 3e1eb4f26b67e484b05e1dde94fd4e4dae982631) --- source3/rpc_server/srv_samr.c | 118 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 114 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 45095a9c3b..0ba7d0871e 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -694,15 +694,15 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, if (status == 0x0) { if (q_u->switch_level == 3) - { - status = NT_STATUS_INVALID_INFO_CLASS; - } - else { r_e.ptr = 1; ctr.switch_value = 3; make_samr_alias_info3(&ctr.alias.info3, ""); } + else + { + status = NT_STATUS_INVALID_INFO_CLASS; + } } make_samr_r_query_aliasinfo(&r_e, status == 0 ? &ctr : NULL, status); @@ -853,6 +853,104 @@ static void api_samr_query_useraliases( uint16 vuid, prs_struct *data, prs_struc samr_reply_query_useraliases(&q_u, rdata); } +/******************************************************************* + samr_reply_query_aliasmem + ********************************************************************/ +static void samr_reply_query_aliasmem(SAMR_Q_QUERY_ALIASMEM *q_u, + prs_struct *rdata) +{ + uint32 status = 0; + + LOCAL_GRP_MEMBER *mem_grp = NULL; + DOM_SID *sid = NULL; + int num_sids = 0; + DOM_SID alias_sid; + uint32 alias_rid; + fstring alias_sid_str; + + SAMR_R_QUERY_ALIASMEM r_u; + + DEBUG(5,("samr_query_aliasmem: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->alias_pol, &alias_sid)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + else + { + sid_to_string(alias_sid_str, &alias_sid ); + sid_split_rid(&alias_sid, &alias_rid); + } + + if (status == 0x0) + { + DEBUG(10,("sid is %s\n", alias_sid_str)); + + if (sid_equal(&alias_sid, &global_sid_S_1_5_20)) + { + DEBUG(10,("lookup on S-1-5-20\n")); + + become_root(True); + status = getbuiltinrid(alias_rid, &mem_grp, &num_sids) ? 0xC0000000 | NT_STATUS_NO_SUCH_GROUP : 0x0; + unbecome_root(True); + } + else if (sid_equal(&alias_sid, &global_sam_sid)) + { + DEBUG(10,("lookup on Domain SID\n")); + + become_root(True); + status = getaliasrid(alias_rid, &mem_grp, &num_sids) ? 0xC0000000 | NT_STATUS_NO_SUCH_GROUP : 0x0; + unbecome_root(True); + } + else + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + } + } + + if (status == 0x0 && num_sids > 0) + { + sid = malloc(num_sids * sizeof(DOM_SID)); + if (mem_grp != NULL && sid != NULL) + { + int i; + for (i = 0; i < num_sids; i++) + { + sid[i] = mem_grp[i].sid; + } + free(mem_grp); + } + } + + make_samr_r_query_aliasmem(&r_u, num_sids, sid, status); + + /* store the response in the SMB stream */ + samr_io_r_query_aliasmem("", &r_u, rdata, 0); + + if (sid != NULL) + { + free(sid); + } + + DEBUG(5,("samr_query_aliasmem: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_query_aliasmem + ********************************************************************/ +static void api_samr_query_aliasmem( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_QUERY_ALIASMEM q_u; + + /* grab the samr 0x21 */ + samr_io_q_query_aliasmem("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_query_aliasmem(&q_u, rdata); +} + /******************************************************************* samr_reply_lookup_names ********************************************************************/ @@ -1669,6 +1767,7 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, prs_struct *rdata) { SAMR_R_OPEN_ALIAS r_u; + DOM_SID sid; BOOL pol_open = False; /* set up the SAMR open_alias response */ @@ -1687,6 +1786,16 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } + sid_copy(&sid, &global_sid_S_1_5_20); + sid_append_rid(&sid, q_u->rid_alias); + + /* associate an alias SID with the (unique) handle. */ + if (r_u.status == 0x0 && !set_lsa_policy_samr_sid(&(r_u.pol), &sid)) + { + /* oh, whoops. don't know what error message to return, here */ + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + if (r_u.status != 0 && pol_open) { close_lsa_policy_hnd(&(r_u.pol)); @@ -1728,6 +1837,7 @@ static struct api_struct api_samr_cmds [] = { "SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, { "SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, { "SAMR_QUERY_USERALIASES", SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, + { "SAMR_QUERY_ALIASMEM" , SAMR_QUERY_ALIASMEM , api_samr_query_aliasmem }, { "SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, { "SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, { "SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, -- cgit From 5dd26daad55da89a7a0996caadd1d474f6031001 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 1 Dec 1998 22:18:48 +0000 Subject: query_aliasmem code. it works (hurrah). (This used to be commit f7f2516df46dde1671235f788f7689c93d9395ae) --- source3/rpc_server/srv_samr.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 0ba7d0871e..a02338bf34 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -862,7 +862,7 @@ static void samr_reply_query_aliasmem(SAMR_Q_QUERY_ALIASMEM *q_u, uint32 status = 0; LOCAL_GRP_MEMBER *mem_grp = NULL; - DOM_SID *sid = NULL; + DOM_SID2 *sid = NULL; int num_sids = 0; DOM_SID alias_sid; uint32 alias_rid; @@ -892,7 +892,7 @@ static void samr_reply_query_aliasmem(SAMR_Q_QUERY_ALIASMEM *q_u, DEBUG(10,("lookup on S-1-5-20\n")); become_root(True); - status = getbuiltinrid(alias_rid, &mem_grp, &num_sids) ? 0xC0000000 | NT_STATUS_NO_SUCH_GROUP : 0x0; + status = getbuiltinrid(alias_rid, &mem_grp, &num_sids) != NULL ? 0x0 : 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; unbecome_root(True); } else if (sid_equal(&alias_sid, &global_sam_sid)) @@ -900,7 +900,7 @@ static void samr_reply_query_aliasmem(SAMR_Q_QUERY_ALIASMEM *q_u, DEBUG(10,("lookup on Domain SID\n")); become_root(True); - status = getaliasrid(alias_rid, &mem_grp, &num_sids) ? 0xC0000000 | NT_STATUS_NO_SUCH_GROUP : 0x0; + status = getaliasrid(alias_rid, &mem_grp, &num_sids) != NULL ? 0x0 : 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; unbecome_root(True); } else @@ -917,7 +917,7 @@ static void samr_reply_query_aliasmem(SAMR_Q_QUERY_ALIASMEM *q_u, int i; for (i = 0; i < num_sids; i++) { - sid[i] = mem_grp[i].sid; + make_dom_sid2(&sid[i], &mem_grp[i].sid); } free(mem_grp); } @@ -1773,6 +1773,11 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, /* set up the SAMR open_alias response */ r_u.status = 0x0; + if (r_u.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->dom_pol, &sid)) + { + r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + /* get a (unique) handle. open a policy on it. */ if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.pol)))) { @@ -1786,7 +1791,6 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } - sid_copy(&sid, &global_sid_S_1_5_20); sid_append_rid(&sid, q_u->rid_alias); /* associate an alias SID with the (unique) handle. */ -- cgit From 51534a4b97f09fc0f98d00e7a2730dddde496dd8 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 2 Dec 1998 01:13:02 +0000 Subject: adding group member code, made a start. found that the group members' rid is needed not the name (see DOMAIN_GRP_MEMBER) decided to go home. (This used to be commit 9337049dfc98becfa74522d418dae64a97c7a304) --- source3/rpc_server/srv_samr.c | 235 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index a02338bf34..505fad25b4 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -670,6 +670,166 @@ static void api_samr_query_dispinfo( uint16 vuid, prs_struct *data, prs_struct * samr_reply_query_dispinfo(&q_e, rdata); } +#if 0 +/******************************************************************* + samr_reply_query_groupmem + ********************************************************************/ +static void samr_reply_query_groupmem(SAMR_Q_QUERY_GROUPMEM *q_u, + prs_struct *rdata) +{ + uint32 status = 0; + + DOMAIN_GRP_MEMBER *mem_grp = NULL; + uint32 *rid = NULL; + uint32 *attr = NULL; + int num_rids = 0; + DOM_SID group_sid; + uint32 group_rid; + fstring group_sid_str; + + SAMR_R_QUERY_GROUPMEM r_u; + + DEBUG(5,("samr_query_groupmem: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->group_pol, &group_sid)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + else + { + sid_to_string(group_sid_str, &group_sid ); + sid_split_rid(&group_sid, &group_rid); + } + + if (status == 0x0) + { + DEBUG(10,("sid is %s\n", group_sid_str)); + + if (sid_equal(&group_sid, &global_sam_sid)) + { + DEBUG(10,("lookup on Domain SID\n")); + + become_root(True); + status = getgrouprid(group_rid, &mem_grp, &num_rids) != NULL ? 0x0 : 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; + unbecome_root(True); + } + else + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + } + } + + if (status == 0x0 && num_rids > 0) + { + rid = malloc(num_rids * sizeof(uint32)); + attr = malloc(num_rids * sizeof(uint32)); + if (mem_grp != NULL && rid != NULL && attr != NULL) + { + int i; + for (i = 0; i < num_rids; i++) + { + rid [i] = mem_grp[i].rid; + attr[i] = mem_grp[i].attr; + } + free(mem_grp); + } + } + + make_samr_r_query_groupmem(&r_u, num_rids, rid, attr, status); + + /* store the response in the SMB stream */ + samr_io_r_query_groupmem("", &r_u, rdata, 0); + + if (sid != NULL) + { + free(sid); + } + + DEBUG(5,("samr_query_groupmem: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_query_groupmem + ********************************************************************/ +static void api_samr_query_groupmem( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_QUERY_GROUPMEM q_u; + + /* grab the samr 0x19 */ + samr_io_q_query_groupmem("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_query_groupmem(&q_u, rdata); +} + +#endif + + +/******************************************************************* + samr_reply_query_groupinfo + ********************************************************************/ +static void samr_reply_query_groupinfo(SAMR_Q_QUERY_GROUPINFO *q_u, + prs_struct *rdata) +{ + SAMR_R_QUERY_GROUPINFO r_e; + GROUP_INFO_CTR ctr; + uint32 status = 0x0; + + r_e.ptr = 0; + + /* find the policy handle. open a policy on it. */ + if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + { + r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + DEBUG(5,("samr_reply_query_groupinfo: %d\n", __LINE__)); + + if (status == 0x0) + { + if (q_u->switch_level == 1) + { + r_e.ptr = 1; + ctr.switch_value = 1; + make_samr_group_info1(&ctr.group.info1, "", ""); + } + else if (q_u->switch_level == 4) + { + r_e.ptr = 1; + ctr.switch_value = 4; + make_samr_group_info4(&ctr.group.info4, ""); + } + else + { + status = NT_STATUS_INVALID_INFO_CLASS; + } + } + + make_samr_r_query_groupinfo(&r_e, status == 0 ? &ctr : NULL, status); + + /* store the response in the SMB stream */ + samr_io_r_query_groupinfo("", &r_e, rdata, 0); + + DEBUG(5,("samr_query_groupinfo: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_query_groupinfo + ********************************************************************/ +static void api_samr_query_groupinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_QUERY_GROUPINFO q_e; + + /* grab the samr open */ + samr_io_q_query_groupinfo("", &q_e, data, 0); + + /* construct reply. */ + samr_reply_query_groupinfo(&q_e, rdata); +} + /******************************************************************* samr_reply_query_aliasinfo @@ -1784,6 +1944,8 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } + DEBUG(0,("TODO: verify that the alias rid exists\n")); + /* associate a RID with the (unique) handle. */ if (r_u.status == 0x0 && !set_lsa_policy_samr_rid(&(r_u.pol), q_u->rid_alias)) { @@ -1829,6 +1991,77 @@ static void api_samr_open_alias( uint16 vuid, prs_struct *data, prs_struct *rdat samr_reply_open_alias(&q_u, rdata); } +/******************************************************************* + samr_reply_open_group + ********************************************************************/ +static void samr_reply_open_group(SAMR_Q_OPEN_GROUP *q_u, + prs_struct *rdata) +{ + SAMR_R_OPEN_GROUP r_u; + DOM_SID sid; + BOOL pol_open = False; + + /* set up the SAMR open_group response */ + + r_u.status = 0x0; + if (r_u.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->domain_pol, &sid)) + { + r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + /* get a (unique) handle. open a policy on it. */ + if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.pol)))) + { + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + DEBUG(0,("TODO: verify that the group rid exists\n")); + + /* associate a RID with the (unique) handle. */ + if (r_u.status == 0x0 && !set_lsa_policy_samr_rid(&(r_u.pol), q_u->rid_group)) + { + /* oh, whoops. don't know what error message to return, here */ + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + sid_append_rid(&sid, q_u->rid_group); + + /* associate an group SID with the (unique) handle. */ + if (r_u.status == 0x0 && !set_lsa_policy_samr_sid(&(r_u.pol), &sid)) + { + /* oh, whoops. don't know what error message to return, here */ + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + if (r_u.status != 0 && pol_open) + { + close_lsa_policy_hnd(&(r_u.pol)); + } + + DEBUG(5,("samr_open_group: %d\n", __LINE__)); + + /* store the response in the SMB stream */ + samr_io_r_open_group("", &r_u, rdata, 0); + + DEBUG(5,("samr_open_group: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_open_group + ********************************************************************/ +static void api_samr_open_group( uint16 vuid, prs_struct *data, prs_struct *rdata) + +{ + SAMR_Q_OPEN_GROUP q_u; + + /* grab the samr open policy */ + samr_io_q_open_group("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_open_group(&q_u, rdata); +} + /******************************************************************* array of \PIPE\samr operations ********************************************************************/ @@ -1849,11 +2082,13 @@ static struct api_struct api_samr_cmds [] = { "SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, { "SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, { "SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, + { "SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, { "SAMR_0x32" , 0x32 , api_samr_unknown_32 }, { "SAMR_UNKNOWN_12" , SAMR_UNKNOWN_12 , api_samr_unknown_12 }, { "SAMR_UNKNOWN_38" , SAMR_UNKNOWN_38 , api_samr_unknown_38 }, { "SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, { "SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, + { "SAMR_OPEN_GROUP" , SAMR_OPEN_GROUP , api_samr_open_group }, { "SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, { "SAMR_UNKNOWN_3" , SAMR_UNKNOWN_3 , api_samr_unknown_3 }, { "SAMR_UNKNOWN_2C" , SAMR_UNKNOWN_2C , api_samr_unknown_2c }, -- cgit From 1bf14231e1b3a114b46f92bb96bdd55b554570bc Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 2 Dec 1998 16:20:36 +0000 Subject: issues spotted by andrej: %s\\%s not %s\%s (This used to be commit 779a7aa30d4b8a3c8ca1d817a3fd9886c0437def) --- source3/rpc_server/srv_lookup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index fc73edc4ed..c97a4cd0b9 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -453,7 +453,7 @@ uint32 lookup_added_alias_name(const char *als_name, const char *domain, LOCAL_GRP *als = NULL; (*type) = SID_NAME_ALIAS; - DEBUG(5,("lookup_added_alias_name: name: %s\%s", domain, als_name)); + DEBUG(5,("lookup_added_alias_name: name: %s\\%s", domain, als_name)); if (!strequal(domain, global_sam_name)) { -- cgit From 78df0fb8f1ef52b629ccc2634bb0e158a80058a3 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 2 Dec 1998 22:05:56 +0000 Subject: added rid and sid_name_use to DOMAIN_GRP_MEMBER, for use in group member query. domain groups now work, hurrah! only thing is that the description is one character long, don't know why (which is wierd in itself). (This used to be commit 78a86c64960a7823b0db8b7bebfffabb4a5ba864) --- source3/rpc_server/srv_samr.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 505fad25b4..7bc12afe74 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -670,7 +670,6 @@ static void api_samr_query_dispinfo( uint16 vuid, prs_struct *data, prs_struct * samr_reply_query_dispinfo(&q_e, rdata); } -#if 0 /******************************************************************* samr_reply_query_groupmem ********************************************************************/ @@ -741,9 +740,14 @@ static void samr_reply_query_groupmem(SAMR_Q_QUERY_GROUPMEM *q_u, /* store the response in the SMB stream */ samr_io_r_query_groupmem("", &r_u, rdata, 0); - if (sid != NULL) + if (rid != NULL) { - free(sid); + free(rid); + } + + if (attr != NULL) + { + free(attr); } DEBUG(5,("samr_query_groupmem: %d\n", __LINE__)); @@ -764,8 +768,6 @@ static void api_samr_query_groupmem( uint16 vuid, prs_struct *data, prs_struct * samr_reply_query_groupmem(&q_u, rdata); } -#endif - /******************************************************************* samr_reply_query_groupinfo @@ -793,13 +795,13 @@ static void samr_reply_query_groupinfo(SAMR_Q_QUERY_GROUPINFO *q_u, { r_e.ptr = 1; ctr.switch_value = 1; - make_samr_group_info1(&ctr.group.info1, "", ""); + make_samr_group_info1(&ctr.group.info1, "account name", "account description"); } else if (q_u->switch_level == 4) { r_e.ptr = 1; ctr.switch_value = 4; - make_samr_group_info4(&ctr.group.info4, ""); + make_samr_group_info4(&ctr.group.info4, "account description"); } else { @@ -1296,7 +1298,6 @@ static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, sid_copy(&sid, &pol_sid); sid_append_rid(&sid, q_u->gid[i]); lookup_sid(&sid, group_names[i], &group_attrs[i]); - group_attrs[i] = 0x2; } } @@ -2075,6 +2076,7 @@ static struct api_struct api_samr_cmds [] = { "SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, { "SAMR_QUERY_USERALIASES", SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, { "SAMR_QUERY_ALIASMEM" , SAMR_QUERY_ALIASMEM , api_samr_query_aliasmem }, + { "SAMR_QUERY_GROUPMEM" , SAMR_QUERY_GROUPMEM , api_samr_query_groupmem }, { "SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, { "SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, { "SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, -- cgit From b99dc808df7e1a4d51145f4ce0bd89819b037dc4 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 3 Dec 1998 20:50:33 +0000 Subject: create domain group command (creategroup) added to rpcclient. renamed do_samr_xxxx to samr_xxxx. (This used to be commit 1e5d81c154740349a2cda4c1892b33a21c0683a8) --- source3/rpc_server/srv_samr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 7bc12afe74..455b26318e 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -794,13 +794,13 @@ static void samr_reply_query_groupinfo(SAMR_Q_QUERY_GROUPINFO *q_u, if (q_u->switch_level == 1) { r_e.ptr = 1; - ctr.switch_value = 1; + ctr.switch_value1 = 1; make_samr_group_info1(&ctr.group.info1, "account name", "account description"); } else if (q_u->switch_level == 4) { r_e.ptr = 1; - ctr.switch_value = 4; + ctr.switch_value1 = 4; make_samr_group_info4(&ctr.group.info4, "account description"); } else -- cgit From 32167eda0dc10bf55bd40d676ff882b3c585662b Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 3 Dec 1998 22:20:30 +0000 Subject: added createalias command to rpcclient (This used to be commit 4771d5451b49375cc2fd4246d7d746b0d03cd5ba) --- source3/rpc_server/srv_samr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 455b26318e..f010c76614 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -858,7 +858,7 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, if (q_u->switch_level == 3) { r_e.ptr = 1; - ctr.switch_value = 3; + ctr.switch_value1 = 3; make_samr_alias_info3(&ctr.alias.info3, ""); } else -- cgit From cf0ea874b1a7cb1dcaaea159d9a4a8a5deae1310 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 4 Dec 1998 16:30:00 +0000 Subject: - renamed do_samr_xxx to samr_xxx - renamed do_lsa_xxx to lsa_xxx - added "enumgroups [-m]" command, enumerates groups, shows members. - added cmd_sam_add_groupmem(), need to call these in rpcclient.c - added cmd_sam_add_aliasmem(), need to call these in rpcclient.c - modified "enumaliases [-m]" command - improved "enumgroups" and "enumaliases" to display names not just RIDS/SIDs. - renamed "samr_unknown_12" to "samr_lookup_rids". - added the following client-side functions: get_samr_query_groupmem() get_samr_query_aliasmem() get_samr_query_groupinfo() samr_enum_dom_groups() samr_enum_dom_aliases() samr_add_aliasmem() samr_add_groupmem() - improved display output (display.c) (This used to be commit eacc5e581af2b4de24186b9be3238b352c54effe) --- source3/rpc_server/srv_samr.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index f010c76614..9ed2409ab2 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1257,20 +1257,20 @@ static void api_samr_unknown_38( uint16 vuid, prs_struct *data, prs_struct *rdat /******************************************************************* - samr_reply_unknown_12 + samr_reply_lookup_rids ********************************************************************/ -static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, +static void samr_reply_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u, prs_struct *rdata) { fstring group_names[MAX_SAM_ENTRIES]; uint8 group_attrs[MAX_SAM_ENTRIES]; uint32 status = 0; - int num_gids = q_u->num_gids1; + int num_rids = q_u->num_rids1; DOM_SID pol_sid; - SAMR_R_UNKNOWN_12 r_u; + SAMR_R_LOOKUP_RIDS r_u; - DEBUG(5,("samr_unknown_12: %d\n", __LINE__)); + DEBUG(5,("samr_lookup_rids: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) @@ -1286,42 +1286,42 @@ static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, if (status == 0x0) { int i; - if (num_gids > MAX_SAM_ENTRIES) + if (num_rids > MAX_SAM_ENTRIES) { - num_gids = MAX_SAM_ENTRIES; - DEBUG(5,("samr_unknown_12: truncating entries to %d\n", num_gids)); + num_rids = MAX_SAM_ENTRIES; + DEBUG(5,("samr_lookup_rids: truncating entries to %d\n", num_rids)); } - for (i = 0; i < num_gids && status == 0; i++) + for (i = 0; i < num_rids && status == 0; i++) { DOM_SID sid; sid_copy(&sid, &pol_sid); - sid_append_rid(&sid, q_u->gid[i]); + sid_append_rid(&sid, q_u->rid[i]); lookup_sid(&sid, group_names[i], &group_attrs[i]); } } - make_samr_r_unknown_12(&r_u, num_gids, group_names, group_attrs, status); + make_samr_r_lookup_rids(&r_u, num_rids, group_names, group_attrs, status); /* store the response in the SMB stream */ - samr_io_r_unknown_12("", &r_u, rdata, 0); + samr_io_r_lookup_rids("", &r_u, rdata, 0); - DEBUG(5,("samr_unknown_12: %d\n", __LINE__)); + DEBUG(5,("samr_lookup_rids: %d\n", __LINE__)); } /******************************************************************* - api_samr_unknown_12 + api_samr_lookup_rids ********************************************************************/ -static void api_samr_unknown_12( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_lookup_rids( uint16 vuid, prs_struct *data, prs_struct *rdata) { - SAMR_Q_UNKNOWN_12 q_u; + SAMR_Q_LOOKUP_RIDS q_u; /* grab the samr lookup names */ - samr_io_q_unknown_12("", &q_u, data, 0); + samr_io_q_lookup_rids("", &q_u, data, 0); /* construct reply. always indicate success */ - samr_reply_unknown_12(&q_u, rdata); + samr_reply_lookup_rids(&q_u, rdata); } @@ -2085,8 +2085,8 @@ static struct api_struct api_samr_cmds [] = { "SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, { "SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, { "SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, - { "SAMR_0x32" , 0x32 , api_samr_unknown_32 }, - { "SAMR_UNKNOWN_12" , SAMR_UNKNOWN_12 , api_samr_unknown_12 }, + { "SAMR_0x32" , SAMR_UNKNOWN_32 , api_samr_unknown_32 }, + { "SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids }, { "SAMR_UNKNOWN_38" , SAMR_UNKNOWN_38 , api_samr_unknown_38 }, { "SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, { "SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, -- cgit From 89c56492a86fb02b2045182490b93f17a475f03d Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 4 Dec 1998 21:48:06 +0000 Subject: - oops, i got "add alias member" and "delete alias member" swapped. - samr_enum_dom_users, the first 4 bytes is some sort of garbage, nt5-beta2 clears them out to zeros whereas nt4 does not. fixed bug where we were assuming that the first 4 bytes of a response _had_ to be non-zero. - cli_lsarpc.c: forgot to append the rid on the lsa_lookup_names() client call. - added in "addaliasmem" and "addgroupmem" commands. the addaliasmem command actually turned out to be a "delaliasmem" :-) :-) - parse_lsa.c: moved assert array check to after the size of useable array space is set... (This used to be commit 165b15a8cacc4bc7cf8cc0b9aaabb6b92cef7fdb) --- source3/rpc_server/srv_samr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 9ed2409ab2..02bfa2e178 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -350,7 +350,6 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, int total_entries; r_e.status = 0x0; - r_e.total_num_entries = 0; /* find the policy handle. open a policy on it. */ if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) @@ -364,8 +363,8 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, get_sampwd_entries(pass, 0, &total_entries, &num_entries, MAX_SAM_ENTRIES, q_u->acb_mask); unbecome_root(True); - make_samr_r_enum_dom_users(&r_e, total_entries, - q_u->unknown_0, num_entries, + make_samr_r_enum_dom_users(&r_e, + 0x00000000, num_entries, pass, r_e.status); /* store the response in the SMB stream */ -- cgit From 312f4f3960a9b1938ae133678cd8567be1331b99 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 7 Dec 1998 17:23:48 +0000 Subject: - lib/unix_sec_ctxt.c attempt at taking lib/uid.c and getting a unix security context change module that is independent of "cnums" and "snums". a security context is needed for pipes, not just IPC$ or other services. - group database API added add_group/alias_member, del_group/alias_member, del_group/alias_entry functions. del_builtin_entry() is deliberately set to NULL to cause an exception, you cannot delete builtin aliases. - parse_lsa.c srv_lsa.c fixed lookup_names code, it was a load of trash and didn't do anything. - cmd_samr.c rpcclient.c srv_samr.c added "deletegroup", "deletealias", "delaliasmem", "delgroupmem", "addgroupmem", "addaliasmem", "createalias", "creategroup", to both client and server code. server code calls into unix stubs right now, which don't actually do anything. the only instance where they are expected to do anything is in appliance mode NOT even in the ldap code or anything. client code modified to call samr_lookup_names() for group code (because we can) and lsa_lookup_names() for alias code (because we have to). - srv_lookup.c oops, lookup on unsplit name, we got lookup on DOMAIN, DOMAIN\name instead of DOMAIN, name. (This used to be commit b8175702ef61b8b37b078f38e81452c00a5e2986) --- source3/rpc_server/srv_lookup.c | 10 +- source3/rpc_server/srv_lsa.c | 133 ++++--- source3/rpc_server/srv_samr.c | 846 ++++++++++++++++++++++++++++++++-------- 3 files changed, 762 insertions(+), 227 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index c97a4cd0b9..70183636d1 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -572,14 +572,8 @@ uint32 lookup_name(char *name, DOM_SID *sid, uint8 *type) split_domain_name(name, domain, user); - if (!strequal(domain, global_sam_name)) - { - DEBUG(0,("lookup_name: remote domain %s not supported\n", domain)); - return status; - } - - status = (status != 0x0) ? lookup_user_name (name, domain, sid, type) : status; - status = (status != 0x0) ? lookup_grp_name (name, domain, sid, type) : status; + status = (status != 0x0) ? lookup_user_name (user, domain, sid, type) : status; + status = (status != 0x0) ? lookup_grp_name (user, domain, sid, type) : status; #if 0 status = (status != 0x0) ? lookup_domain_name (domain, sid, type) : status; #endif diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 62c8f8a0cd..947de768b5 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -193,37 +193,88 @@ static int make_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) } /*************************************************************************** -make_reply_lookup_names +make_lsa_rid2s ***************************************************************************/ -static void make_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, - int num_entries, - DOM_SID dom_sids [MAX_LOOKUP_SIDS], - uint8 dom_types[MAX_LOOKUP_SIDS]) +static void make_lsa_rid2s(DOM_R_REF *ref, + DOM_RID2 *rid2, + int num_entries, UNISTR2 name[MAX_LOOKUP_SIDS], + uint32 *mapped_count) { int i; + int total = 0; + (*mapped_count) = 0; - r_l->num_entries = 0; - r_l->undoc_buffer = 0; - r_l->num_entries2 = 0; - -#if 0 - r_l->num_entries = num_entries; - r_l->undoc_buffer = 1; - r_l->num_entries2 = num_entries; - - SMB_ASSERT_ARRAY(r_l->dom_rid, num_entries); + SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS); for (i = 0; i < num_entries; i++) { - DOM_SID sid = dom_sids[i]; - uint32 rid; - sid_split_rid(&sid, &rid); - make_dom_ref(&(r_l->dom_ref), dom_name, dom_sid); - make_dom_rid2(&(r_l->dom_rid[i]), rid, dom_types[i]); + uint32 status = 0x0; + DOM_SID find_sid; + DOM_SID sid; + uint32 rid = 0xffffffff; + int dom_idx = -1; + fstring find_name; + char *dom_name = NULL; + uint8 sid_name_use = SID_NAME_UNKNOWN; + + fstrcpy(find_name, unistr2_to_str(&name[i])); + dom_name = strdup(find_name); + + if (map_domain_name_to_sid(&sid, &dom_name)) + { + sid_name_use = SID_NAME_DOMAIN; + dom_idx = make_dom_ref(ref, dom_name, &find_sid); + } + + if (lookup_name(find_name, &sid, &sid_name_use) == 0x0 && + sid_split_rid(&sid, &rid)) + { + if (map_domain_sid_to_name(&sid, find_name)) + { + dom_idx = make_dom_ref(ref, find_name, &sid); + } + else + { + status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + } + } + else + { + status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + } + + if (status == 0x0) + { + (*mapped_count)++; + } + else + { + dom_idx = -1; + rid = 0xffffffff; + sid_name_use = SID_NAME_UNKNOWN; + } + + make_dom_rid2(&rid2[total], rid, sid_name_use, dom_idx); + total++; + + if (dom_name != NULL) + { + free(dom_name); + } } +} - r_l->num_entries3 = num_entries; -#endif +/*************************************************************************** +make_reply_lookup_names + ***************************************************************************/ +static void make_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, + DOM_R_REF *ref, DOM_RID2 *rid2, + uint32 mapped_count, uint32 status) +{ + r_l->dom_ref = ref; + r_l->dom_rid = rid2; + r_l->mapped_count = mapped_count; + r_l->status = status; } /*************************************************************************** @@ -340,18 +391,24 @@ static void lsa_reply_lookup_sids(prs_struct *rdata, lsa_reply_lookup_names ***************************************************************************/ static void lsa_reply_lookup_names(prs_struct *rdata, - int num_entries, - DOM_SID dom_sids [MAX_LOOKUP_SIDS], - uint8 dom_types[MAX_LOOKUP_SIDS]) + UNISTR2 names[MAX_LOOKUP_SIDS], int num_entries) { LSA_R_LOOKUP_NAMES r_l; + DOM_R_REF ref; + DOM_RID2 rids[MAX_LOOKUP_SIDS]; + uint32 mapped_count = 0; ZERO_STRUCT(r_l); + ZERO_STRUCT(ref); + ZERO_STRUCT(rids); /* set up the LSA Lookup RIDs response */ - make_reply_lookup_names(&r_l, num_entries, dom_sids, dom_types); + make_lsa_rid2s(&ref, rids, num_entries, names, &mapped_count); + make_reply_lookup_names(&r_l, &ref, rids, mapped_count, 0x0); - r_l.status = 0x0; + r_l.num_entries = num_entries; + r_l.undoc_buffer = 1; + r_l.num_entries2 = num_entries; /* store the response in the SMB stream */ lsa_io_r_lookup_names("", &r_l, rdata, 0); @@ -476,36 +533,16 @@ api_lsa_lookup_names static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rdata ) { - int i; LSA_Q_LOOKUP_NAMES q_l; - DOM_SID dom_sids [MAX_LOOKUP_SIDS]; - uint8 dom_types[MAX_LOOKUP_SIDS]; - ZERO_STRUCT(q_l); - ZERO_ARRAY(dom_sids); /* grab the info class and policy handle */ lsa_io_q_lookup_names("", &q_l, data, 0); SMB_ASSERT_ARRAY(q_l.uni_name, q_l.num_entries); - /* convert received RIDs to strings, so we can do them. */ - for (i = 0; i < q_l.num_entries; i++) - { - fstring name; - fstrcpy(name, unistr2_to_str(&q_l.uni_name[i])); - - if (!lookup_name(name, &dom_sids[i], &dom_types[i])) - { - dom_types[i] = SID_NAME_UNKNOWN; - } - } - /* construct reply. return status is always 0x0 */ - lsa_reply_lookup_names(rdata, - q_l.num_entries, - dom_sids, /* text-converted SIDs */ - dom_types); /* SID_NAME_USE types */ + lsa_reply_lookup_names(rdata, q_l.uni_name, q_l.num_entries); } /*************************************************************************** diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 02bfa2e178..82dea29d9a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -150,11 +150,7 @@ static void samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, static void api_samr_close_hnd( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_CLOSE_HND q_u; - - /* grab the samr unknown 1 */ samr_io_q_close_hnd("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_close_hnd(&q_u, rdata); } @@ -209,11 +205,7 @@ static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, static void api_samr_open_domain( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_DOMAIN q_u; - - /* grab the samr open */ samr_io_q_open_domain("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_open_domain(&q_u, rdata); } @@ -236,7 +228,7 @@ static void samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, /* find the user's rid */ if ((status == 0x0) && (get_lsa_policy_samr_rid(&(q_u->user_pol)) == 0xffffffff)) { - status = NT_STATUS_OBJECT_TYPE_MISMATCH; + status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } make_samr_r_unknown_2c(&r_u, status); @@ -256,11 +248,7 @@ static void samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, static void api_samr_unknown_2c( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_2C q_u; - - /* grab the samr open */ samr_io_q_unknown_2c("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_unknown_2c(&q_u, rdata); } @@ -287,7 +275,7 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, /* find the user's rid */ if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->user_pol))) == 0xffffffff) { - status = NT_STATUS_OBJECT_TYPE_MISMATCH; + status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } if (status == 0x0) @@ -329,11 +317,7 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, static void api_samr_unknown_3( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_3 q_u; - - /* grab the samr open */ samr_io_q_unknown_3("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_unknown_3(&q_u, rdata); } @@ -380,17 +364,261 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, static void api_samr_enum_dom_users( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_USERS q_e; - - /* grab the samr open */ samr_io_q_enum_dom_users("", &q_e, data, 0); - - /* construct reply. */ samr_reply_enum_dom_users(&q_e, rdata); } /******************************************************************* - samr_reply_enum_dom_groups + samr_reply_add_groupmem + ********************************************************************/ +static void samr_reply_add_groupmem(SAMR_Q_ADD_GROUPMEM *q_u, + prs_struct *rdata) +{ + SAMR_R_ADD_GROUPMEM r_e; + DOM_SID group_sid; + uint32 group_rid; + fstring group_sid_str; + + r_e.status = 0x0; + + /* find the policy handle. open a policy on it. */ + if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &group_sid)) + { + r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + else + { + sid_to_string(group_sid_str, &group_sid); + sid_split_rid(&group_sid, &group_rid); + } + + if (r_e.status == 0x0) + { + DEBUG(10,("sid is %s\n", group_sid_str)); + + if (sid_equal(&group_sid, &global_sam_sid)) + { + DEBUG(10,("lookup on Domain SID\n")); + + become_root(True); + r_e.status = add_group_member(group_rid, q_u->rid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + unbecome_root(True); + } + else + { + r_e.status = 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; + } + } + + /* store the response in the SMB stream */ + samr_io_r_add_groupmem("", &r_e, rdata, 0); + + DEBUG(5,("samr_add_groupmem: %d\n", __LINE__)); +} + +/******************************************************************* + api_samr_add_groupmem + ********************************************************************/ +static void api_samr_add_groupmem( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_ADD_GROUPMEM q_e; + samr_io_q_add_groupmem("", &q_e, data, 0); + samr_reply_add_groupmem(&q_e, rdata); +} + +/******************************************************************* + samr_reply_del_groupmem + ********************************************************************/ +static void samr_reply_del_groupmem(SAMR_Q_DEL_GROUPMEM *q_u, + prs_struct *rdata) +{ + SAMR_R_DEL_GROUPMEM r_e; + DOM_SID group_sid; + uint32 group_rid; + fstring group_sid_str; + + r_e.status = 0x0; + + /* find the policy handle. open a policy on it. */ + if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &group_sid)) + { + r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + else + { + sid_to_string(group_sid_str, &group_sid); + sid_split_rid(&group_sid, &group_rid); + } + + if (r_e.status == 0x0) + { + DEBUG(10,("sid is %s\n", group_sid_str)); + + if (sid_equal(&group_sid, &global_sam_sid)) + { + DEBUG(10,("lookup on Domain SID\n")); + + become_root(True); + r_e.status = del_group_member(group_rid, q_u->rid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + unbecome_root(True); + } + else + { + r_e.status = 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; + } + } + + /* store the response in the SMB stream */ + samr_io_r_del_groupmem("", &r_e, rdata, 0); + + DEBUG(5,("samr_del_groupmem: %d\n", __LINE__)); +} + +/******************************************************************* + api_samr_del_groupmem + ********************************************************************/ +static void api_samr_del_groupmem( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_DEL_GROUPMEM q_e; + samr_io_q_del_groupmem("", &q_e, data, 0); + samr_reply_del_groupmem(&q_e, rdata); +} + +/******************************************************************* + samr_reply_add_aliasmem + ********************************************************************/ +static void samr_reply_add_aliasmem(SAMR_Q_ADD_ALIASMEM *q_u, + prs_struct *rdata) +{ + SAMR_R_ADD_ALIASMEM r_e; + DOM_SID alias_sid; + uint32 alias_rid; + fstring alias_sid_str; + + r_e.status = 0x0; + + /* find the policy handle. open a policy on it. */ + if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->alias_pol, &alias_sid)) + { + r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + else + { + sid_to_string(alias_sid_str, &alias_sid); + sid_split_rid(&alias_sid, &alias_rid); + } + + if (r_e.status == 0x0) + { + DEBUG(10,("sid is %s\n", alias_sid_str)); + + if (sid_equal(&alias_sid, &global_sam_sid)) + { + DEBUG(10,("add member on Domain SID\n")); + + become_root(True); + r_e.status = add_alias_member(alias_rid, &q_u->sid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + unbecome_root(True); + } + else if (sid_equal(&alias_sid, &global_sid_S_1_5_20)) + { + DEBUG(10,("add member on BUILTIN SID\n")); + + become_root(True); + r_e.status = add_builtin_member(alias_rid, &q_u->sid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + unbecome_root(True); + } + else + { + r_e.status = 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; + } + } + + /* store the response in the SMB stream */ + samr_io_r_add_aliasmem("", &r_e, rdata, 0); + + DEBUG(5,("samr_add_aliasmem: %d\n", __LINE__)); +} + +/******************************************************************* + api_samr_add_aliasmem + ********************************************************************/ +static void api_samr_add_aliasmem( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_ADD_ALIASMEM q_e; + samr_io_q_add_aliasmem("", &q_e, data, 0); + samr_reply_add_aliasmem(&q_e, rdata); +} + +/******************************************************************* + samr_reply_del_aliasmem + ********************************************************************/ +static void samr_reply_del_aliasmem(SAMR_Q_DEL_ALIASMEM *q_u, + prs_struct *rdata) +{ + SAMR_R_DEL_ALIASMEM r_e; + DOM_SID alias_sid; + uint32 alias_rid; + fstring alias_sid_str; + + r_e.status = 0x0; + + /* find the policy handle. open a policy on it. */ + if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->alias_pol, &alias_sid)) + { + r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + else + { + sid_to_string(alias_sid_str, &alias_sid); + sid_split_rid(&alias_sid, &alias_rid); + } + + if (r_e.status == 0x0) + { + DEBUG(10,("sid is %s\n", alias_sid_str)); + + if (sid_equal(&alias_sid, &global_sam_sid)) + { + DEBUG(10,("del member on Domain SID\n")); + + become_root(True); + r_e.status = del_alias_member(alias_rid, &q_u->sid.sid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + unbecome_root(True); + } + else if (sid_equal(&alias_sid, &global_sid_S_1_5_20)) + { + DEBUG(10,("del member on BUILTIN SID\n")); + + become_root(True); + r_e.status = del_builtin_member(alias_rid, &q_u->sid.sid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + unbecome_root(True); + } + else + { + r_e.status = 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; + } + } + + /* store the response in the SMB stream */ + samr_io_r_del_aliasmem("", &r_e, rdata, 0); + + DEBUG(5,("samr_del_aliasmem: %d\n", __LINE__)); +} + +/******************************************************************* + api_samr_del_aliasmem + ********************************************************************/ +static void api_samr_del_aliasmem( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_DEL_ALIASMEM q_e; + samr_io_q_del_aliasmem("", &q_e, data, 0); + samr_reply_del_aliasmem(&q_e, rdata); +} + +/******************************************************************* + samr_reply_add_groupmem ********************************************************************/ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, prs_struct *rdata) @@ -479,11 +707,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, static void api_samr_enum_dom_groups( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_GROUPS q_e; - - /* grab the samr open */ samr_io_q_enum_dom_groups("", &q_e, data, 0); - - /* construct reply. */ samr_reply_enum_dom_groups(&q_e, rdata); } @@ -669,6 +893,68 @@ static void api_samr_query_dispinfo( uint16 vuid, prs_struct *data, prs_struct * samr_reply_query_dispinfo(&q_e, rdata); } +/******************************************************************* + samr_reply_delete_dom_group + ********************************************************************/ +static void samr_reply_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP *q_u, + prs_struct *rdata) +{ + uint32 status = 0; + + DOM_SID group_sid; + uint32 group_rid; + fstring group_sid_str; + + SAMR_R_DELETE_DOM_GROUP r_u; + + DEBUG(5,("samr_delete_dom_group: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->group_pol, &group_sid)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + else + { + sid_to_string(group_sid_str, &group_sid ); + sid_split_rid(&group_sid, &group_rid); + } + + if (status == 0x0) + { + DEBUG(10,("sid is %s\n", group_sid_str)); + + if (sid_equal(&group_sid, &global_sam_sid)) + { + DEBUG(10,("lookup on Domain SID\n")); + + become_root(True); + status = del_group_entry(group_rid) ? 0x0 : 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; + unbecome_root(True); + } + else + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + } + } + + make_samr_r_delete_dom_group(&r_u, status); + + /* store the response in the SMB stream */ + samr_io_r_delete_dom_group("", &r_u, rdata, 0); +} + +/******************************************************************* + api_samr_delete_dom_group + ********************************************************************/ +static void api_samr_delete_dom_group( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_DELETE_DOM_GROUP q_u; + samr_io_q_delete_dom_group("", &q_u, data, 0); + samr_reply_delete_dom_group(&q_u, rdata); +} + + /******************************************************************* samr_reply_query_groupmem ********************************************************************/ @@ -759,11 +1045,7 @@ static void samr_reply_query_groupmem(SAMR_Q_QUERY_GROUPMEM *q_u, static void api_samr_query_groupmem( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_GROUPMEM q_u; - - /* grab the samr 0x19 */ samr_io_q_query_groupmem("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_query_groupmem(&q_u, rdata); } @@ -804,7 +1086,7 @@ static void samr_reply_query_groupinfo(SAMR_Q_QUERY_GROUPINFO *q_u, } else { - status = NT_STATUS_INVALID_INFO_CLASS; + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; } } @@ -823,11 +1105,7 @@ static void samr_reply_query_groupinfo(SAMR_Q_QUERY_GROUPINFO *q_u, static void api_samr_query_groupinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_GROUPINFO q_e; - - /* grab the samr open */ samr_io_q_query_groupinfo("", &q_e, data, 0); - - /* construct reply. */ samr_reply_query_groupinfo(&q_e, rdata); } @@ -862,7 +1140,7 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, } else { - status = NT_STATUS_INVALID_INFO_CLASS; + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; } } @@ -881,11 +1159,7 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, static void api_samr_query_aliasinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_ALIASINFO q_e; - - /* grab the samr open */ samr_io_q_query_aliasinfo("", &q_e, data, 0); - - /* construct reply. */ samr_reply_query_aliasinfo(&q_e, rdata); } @@ -948,22 +1222,105 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, if (status == 0x0) { - DEBUG(10,("sid is %s\n", dom_sid_str)); - - if (sid_equal(&dom_sid, &global_sid_S_1_5_20)) - { - DEBUG(10,("lookup on S-1-5-20\n")); + DEBUG(10,("sid is %s\n", dom_sid_str)); + + if (sid_equal(&dom_sid, &global_sid_S_1_5_20)) + { + DEBUG(10,("lookup on S-1-5-20\n")); + + become_root(True); + getuserbuiltinntnam(sam_pass->nt_name, &mem_grp, &num_rids); + unbecome_root(True); + } + else if (sid_equal(&dom_sid, &usr_sid)) + { + DEBUG(10,("lookup on Domain SID\n")); + + become_root(True); + getuseraliasntnam(sam_pass->nt_name, &mem_grp, &num_rids); + unbecome_root(True); + } + else + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + } + } + + if (status == 0x0 && num_rids > 0) + { + rid = malloc(num_rids * sizeof(uint32)); + if (mem_grp != NULL && rid != NULL) + { + int i; + for (i = 0; i < num_rids; i++) + { + rid[i] = mem_grp[i].rid; + } + free(mem_grp); + } + } + + make_samr_r_query_useraliases(&r_u, num_rids, rid, status); + + /* store the response in the SMB stream */ + samr_io_r_query_useraliases("", &r_u, rdata, 0); + + if (rid != NULL) + { + free(rid); + } + + DEBUG(5,("samr_query_useraliases: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_query_useraliases + ********************************************************************/ +static void api_samr_query_useraliases( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_QUERY_USERALIASES q_u; + samr_io_q_query_useraliases("", &q_u, data, 0); + samr_reply_query_useraliases(&q_u, rdata); +} + +/******************************************************************* + samr_reply_delete_dom_alias + ********************************************************************/ +static void samr_reply_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS *q_u, + prs_struct *rdata) +{ + uint32 status = 0; + + DOM_SID alias_sid; + uint32 alias_rid; + fstring alias_sid_str; + + SAMR_R_DELETE_DOM_ALIAS r_u; + + DEBUG(5,("samr_delete_dom_alias: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->alias_pol, &alias_sid)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + else + { + sid_to_string(alias_sid_str, &alias_sid ); + sid_split_rid(&alias_sid, &alias_rid); + } + + if (status == 0x0) + { + DEBUG(10,("sid is %s\n", alias_sid_str)); - become_root(True); - getuserbuiltinntnam(sam_pass->nt_name, &mem_grp, &num_rids); - unbecome_root(True); - } - else if (sid_equal(&dom_sid, &usr_sid)) + if (sid_equal(&alias_sid, &global_sam_sid)) { DEBUG(10,("lookup on Domain SID\n")); become_root(True); - getuseraliasntnam(sam_pass->nt_name, &mem_grp, &num_rids); + status = del_alias_entry(alias_rid) ? 0x0 : 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; unbecome_root(True); } else @@ -972,48 +1329,23 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, } } - if (status == 0x0 && num_rids > 0) - { - rid = malloc(num_rids * sizeof(uint32)); - if (mem_grp != NULL && rid != NULL) - { - int i; - for (i = 0; i < num_rids; i++) - { - rid[i] = mem_grp[i].rid; - } - free(mem_grp); - } - } - - make_samr_r_query_useraliases(&r_u, num_rids, rid, status); + make_samr_r_delete_dom_alias(&r_u, status); /* store the response in the SMB stream */ - samr_io_r_query_useraliases("", &r_u, rdata, 0); - - if (rid != NULL) - { - free(rid); - } - - DEBUG(5,("samr_query_useraliases: %d\n", __LINE__)); - + samr_io_r_delete_dom_alias("", &r_u, rdata, 0); } /******************************************************************* - api_samr_query_useraliases + api_samr_delete_dom_alias ********************************************************************/ -static void api_samr_query_useraliases( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_delete_dom_alias( uint16 vuid, prs_struct *data, prs_struct *rdata) { - SAMR_Q_QUERY_USERALIASES q_u; - - /* grab the samr 0x10 */ - samr_io_q_query_useraliases("", &q_u, data, 0); - - /* construct reply. always indicate success */ - samr_reply_query_useraliases(&q_u, rdata); + SAMR_Q_DELETE_DOM_ALIAS q_u; + samr_io_q_delete_dom_alias("", &q_u, data, 0); + samr_reply_delete_dom_alias(&q_u, rdata); } + /******************************************************************* samr_reply_query_aliasmem ********************************************************************/ @@ -1104,11 +1436,7 @@ static void samr_reply_query_aliasmem(SAMR_Q_QUERY_ALIASMEM *q_u, static void api_samr_query_aliasmem( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_ALIASMEM q_u; - - /* grab the samr 0x21 */ samr_io_q_query_aliasmem("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_query_aliasmem(&q_u, rdata); } @@ -1122,25 +1450,31 @@ static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, uint8 type[MAX_SAM_ENTRIES]; uint32 status = 0; int i; - int num_rids = q_u->num_rids1; + int num_rids = q_u->num_names1; + DOM_SID pol_sid; SAMR_R_LOOKUP_NAMES r_u; DEBUG(5,("samr_lookup_names: %d\n", __LINE__)); + if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &pol_sid)) + { + status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; + } + if (num_rids > MAX_SAM_ENTRIES) { num_rids = MAX_SAM_ENTRIES; DEBUG(5,("samr_lookup_names: truncating entries to %d\n", num_rids)); } - SMB_ASSERT_ARRAY(q_u->uni_user_name, num_rids); + SMB_ASSERT_ARRAY(q_u->uni_name, num_rids); for (i = 0; i < num_rids && status == 0; i++) { DOM_SID sid; fstring name; - fstrcpy(name, unistrn2(q_u->uni_user_name[i].buffer, q_u->uni_user_name[i].uni_str_len)); + fstrcpy(name, unistr2_to_str(&q_u->uni_name[i])); status = lookup_name(name, &sid, &(type[i])); if (status == 0x0) @@ -1150,6 +1484,12 @@ static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, else { type[i] = SID_NAME_UNKNOWN; + rid [i] = 0xffffffff; + } + if (!sid_equal(&pol_sid, &sid)) + { + rid [i] = 0xffffffff; + type[i] = SID_NAME_UNKNOWN; } } @@ -1168,11 +1508,7 @@ static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, static void api_samr_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_NAMES q_u; - - /* grab the samr lookup names */ samr_io_q_lookup_names("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_lookup_names(&q_u, rdata); } @@ -1213,11 +1549,7 @@ static void samr_reply_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u, static void api_samr_chgpasswd_user( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_CHGPASSWD_USER q_u; - - /* unknown 38 command */ samr_io_q_chgpasswd_user("", &q_u, data, 0); - - /* construct reply. */ samr_reply_chgpasswd_user(&q_u, rdata); } @@ -1246,11 +1578,7 @@ static void samr_reply_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, static void api_samr_unknown_38( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_38 q_u; - - /* unknown 38 command */ samr_io_q_unknown_38("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_unknown_38(&q_u, rdata); } @@ -1279,7 +1607,7 @@ static void samr_reply_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u, if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &pol_sid)) { - status = NT_STATUS_OBJECT_TYPE_MISMATCH; + status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } if (status == 0x0) @@ -1315,11 +1643,7 @@ static void samr_reply_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u, static void api_samr_lookup_rids( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_RIDS q_u; - - /* grab the samr lookup names */ samr_io_q_lookup_rids("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_lookup_rids(&q_u, rdata); } @@ -1389,11 +1713,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, static void api_samr_open_user( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_USER q_u; - - /* grab the samr unknown 22 */ samr_io_q_open_user("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_open_user(&q_u, rdata, 0x0); } @@ -1506,13 +1826,13 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, /* search for the handle */ if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { - status = NT_STATUS_INVALID_HANDLE; + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* find the user's rid */ if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->pol))) == 0xffffffff) { - status = NT_STATUS_OBJECT_TYPE_MISMATCH; + status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } DEBUG(5,("samr_reply_query_userinfo: rid:0x%x\n", rid)); @@ -1552,7 +1872,7 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, default: { - status = NT_STATUS_INVALID_INFO_CLASS; + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; break; } @@ -1574,11 +1894,7 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, static void api_samr_query_userinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERINFO q_u; - - /* grab the samr unknown 24 */ samr_io_q_query_userinfo("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_query_userinfo(&q_u, rdata); } @@ -1608,7 +1924,7 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, /* find the user's rid */ if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->pol))) == 0xffffffff) { - status = NT_STATUS_OBJECT_TYPE_MISMATCH; + status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } if (status == 0x0) @@ -1661,14 +1977,234 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, static void api_samr_query_usergroups( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERGROUPS q_u; - /* grab the samr unknown 32 */ samr_io_q_query_usergroups("", &q_u, data, 0); - - /* construct reply. */ samr_reply_query_usergroups(&q_u, rdata); } +/******************************************************************* + opens a samr alias by rid, returns a policy handle. + ********************************************************************/ +static uint32 open_samr_alias(DOM_SID *sid, POLICY_HND *alias_pol, + uint32 alias_rid) +{ + BOOL pol_open = False; + uint32 status = 0x0; + + /* get a (unique) handle. open a policy on it. */ + if (status == 0x0 && !(pol_open = open_lsa_policy_hnd(alias_pol))) + { + status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + DEBUG(0,("TODO: verify that the alias rid exists\n")); + + /* associate a RID with the (unique) handle. */ + if (status == 0x0 && !set_lsa_policy_samr_rid(alias_pol, alias_rid)) + { + /* oh, whoops. don't know what error message to return, here */ + status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + sid_append_rid(sid, alias_rid); + + /* associate an alias SID with the (unique) handle. */ + if (status == 0x0 && !set_lsa_policy_samr_sid(alias_pol, sid)) + { + /* oh, whoops. don't know what error message to return, here */ + status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + if (status != 0 && pol_open) + { + close_lsa_policy_hnd(alias_pol); + } + + return status; +} + +/******************************************************************* + samr_reply_create_dom_alias + ********************************************************************/ +static void samr_reply_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS *q_u, + prs_struct *rdata) +{ + SAMR_R_CREATE_DOM_ALIAS r_u; + DOM_SID dom_sid; + LOCAL_GRP grp; + POLICY_HND alias_pol; + uint32 status = 0x0; + + bzero(&alias_pol, sizeof(alias_pol)); + + DEBUG(5,("samr_create_dom_alias: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->dom_pol)) == -1)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + /* find the domain sid */ + if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->dom_pol, &dom_sid)) + { + status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + if (!sid_equal(&dom_sid, &global_sam_sid)) + { + status = 0xC0000000 | NT_STATUS_ACCESS_DENIED; + } + + if (status == 0x0) + { + fstrcpy(grp.name, unistr2_to_str(&q_u->uni_acct_desc)); + fstrcpy(grp.comment, ""); + grp.rid = 0xffffffff; + + become_root(True); + status = add_alias_entry(&grp) ? 0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + unbecome_root(True); + } + + if (status == 0x0) + { + status = open_samr_alias(&dom_sid, &alias_pol, grp.rid); + } + + /* construct the response. */ + make_samr_r_create_dom_alias(&r_u, &alias_pol, grp.rid, status); + + /* store the response in the SMB stream */ + samr_io_r_create_dom_alias("", &r_u, rdata, 0); + + DEBUG(5,("samr_create_dom_alias: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_create_dom_alias + ********************************************************************/ +static void api_samr_create_dom_alias( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_CREATE_DOM_ALIAS q_u; + samr_io_q_create_dom_alias("", &q_u, data, 0); + samr_reply_create_dom_alias(&q_u, rdata); +} + + +/******************************************************************* + opens a samr group by rid, returns a policy handle. + ********************************************************************/ +static uint32 open_samr_group(DOM_SID *sid, POLICY_HND *group_pol, + uint32 group_rid) +{ + BOOL pol_open = False; + uint32 status = 0x0; + + /* get a (unique) handle. open a policy on it. */ + if (status == 0x0 && !(pol_open = open_lsa_policy_hnd(group_pol))) + { + status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + DEBUG(0,("TODO: verify that the group rid exists\n")); + + /* associate a RID with the (unique) handle. */ + if (status == 0x0 && !set_lsa_policy_samr_rid(group_pol, group_rid)) + { + /* oh, whoops. don't know what error message to return, here */ + status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + sid_append_rid(sid, group_rid); + + /* associate an group SID with the (unique) handle. */ + if (status == 0x0 && !set_lsa_policy_samr_sid(group_pol, sid)) + { + /* oh, whoops. don't know what error message to return, here */ + status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + if (status != 0 && pol_open) + { + close_lsa_policy_hnd(group_pol); + } + + return status; +} + +/******************************************************************* + samr_reply_create_dom_group + ********************************************************************/ +static void samr_reply_create_dom_group(SAMR_Q_CREATE_DOM_GROUP *q_u, + prs_struct *rdata) +{ + SAMR_R_CREATE_DOM_GROUP r_u; + DOM_SID dom_sid; + DOMAIN_GRP grp; + POLICY_HND group_pol; + uint32 status = 0x0; + + bzero(&group_pol, sizeof(group_pol)); + + DEBUG(5,("samr_create_dom_group: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + /* find the domain sid */ + if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &dom_sid)) + { + status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + if (!sid_equal(&dom_sid, &global_sam_sid)) + { + status = 0xC0000000 | NT_STATUS_ACCESS_DENIED; + } + + if (status == 0x0) + { + fstrcpy(grp.name, unistr2_to_str(&q_u->uni_acct_desc)); + fstrcpy(grp.comment, ""); + grp.rid = 0xffffffff; + grp.attr = 0x07; + + become_root(True); + status = add_group_entry(&grp) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + unbecome_root(True); + } + + if (status == 0x0) + { + status = open_samr_group(&dom_sid, &group_pol, grp.rid); + } + + /* construct the response. */ + make_samr_r_create_dom_group(&r_u, &group_pol, grp.rid, status); + + /* store the response in the SMB stream */ + samr_io_r_create_dom_group("", &r_u, rdata, 0); + + DEBUG(5,("samr_create_dom_group: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_create_dom_group + ********************************************************************/ +static void api_samr_create_dom_group( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_CREATE_DOM_GROUP q_u; + samr_io_q_create_dom_group("", &q_u, data, 0); + samr_reply_create_dom_group(&q_u, rdata); +} + + /******************************************************************* samr_reply_query_dom_info ********************************************************************/ @@ -1728,11 +2264,7 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, static void api_samr_query_dom_info( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_DOMAIN_INFO q_e; - - /* grab the samr unknown 8 command */ samr_io_q_query_dom_info("", &q_e, data, 0); - - /* construct reply. */ samr_reply_query_dom_info(&q_e, rdata); } @@ -1859,11 +2391,7 @@ static void samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, static void api_samr_connect_anon( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_CONNECT_ANON q_u; - - /* grab the samr open policy */ samr_io_q_connect_anon("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_connect_anon(&q_u, rdata); } @@ -1912,11 +2440,7 @@ static void samr_reply_connect(SAMR_Q_CONNECT *q_u, static void api_samr_connect( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_CONNECT q_u; - - /* grab the samr open policy */ samr_io_q_connect("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_connect(&q_u, rdata); } @@ -1983,11 +2507,7 @@ static void api_samr_open_alias( uint16 vuid, prs_struct *data, prs_struct *rdat { SAMR_Q_OPEN_ALIAS q_u; - - /* grab the samr open policy */ samr_io_q_open_alias("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_open_alias(&q_u, rdata); } @@ -1999,47 +2519,27 @@ static void samr_reply_open_group(SAMR_Q_OPEN_GROUP *q_u, { SAMR_R_OPEN_GROUP r_u; DOM_SID sid; - BOOL pol_open = False; - /* set up the SAMR open_group response */ + DEBUG(5,("samr_open_group: %d\n", __LINE__)); r_u.status = 0x0; + + /* find the domain sid associated with the policy handle */ if (r_u.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->domain_pol, &sid)) { r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } - /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.pol)))) - { - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - - DEBUG(0,("TODO: verify that the group rid exists\n")); - - /* associate a RID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_lsa_policy_samr_rid(&(r_u.pol), q_u->rid_group)) - { - /* oh, whoops. don't know what error message to return, here */ - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - - sid_append_rid(&sid, q_u->rid_group); - - /* associate an group SID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_lsa_policy_samr_sid(&(r_u.pol), &sid)) + if (r_u.status == 0x0 && !sid_equal(&sid, &global_sam_sid)) { - /* oh, whoops. don't know what error message to return, here */ - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + r_u.status = 0xC0000000 | NT_STATUS_ACCESS_DENIED; } - if (r_u.status != 0 && pol_open) + if (r_u.status == 0x0) { - close_lsa_policy_hnd(&(r_u.pol)); + r_u.status = open_samr_group(&sid, &r_u.pol, q_u->rid_group); } - DEBUG(5,("samr_open_group: %d\n", __LINE__)); - /* store the response in the SMB stream */ samr_io_r_open_group("", &r_u, rdata, 0); @@ -2054,11 +2554,7 @@ static void api_samr_open_group( uint16 vuid, prs_struct *data, prs_struct *rdat { SAMR_Q_OPEN_GROUP q_u; - - /* grab the samr open policy */ samr_io_q_open_group("", &q_u, data, 0); - - /* construct reply. always indicate success */ samr_reply_open_group(&q_u, rdata); } @@ -2076,6 +2572,14 @@ static struct api_struct api_samr_cmds [] = { "SAMR_QUERY_USERALIASES", SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, { "SAMR_QUERY_ALIASMEM" , SAMR_QUERY_ALIASMEM , api_samr_query_aliasmem }, { "SAMR_QUERY_GROUPMEM" , SAMR_QUERY_GROUPMEM , api_samr_query_groupmem }, + { "SAMR_ADD_ALIASMEM" , SAMR_ADD_ALIASMEM , api_samr_del_aliasmem }, + { "SAMR_DEL_ALIASMEM" , SAMR_DEL_ALIASMEM , api_samr_add_aliasmem }, + { "SAMR_ADD_GROUPMEM" , SAMR_ADD_GROUPMEM , api_samr_del_groupmem }, + { "SAMR_DEL_GROUPMEM" , SAMR_DEL_GROUPMEM , api_samr_add_groupmem }, + { "SAMR_DELETE_DOM_GROUP" , SAMR_DELETE_DOM_GROUP , api_samr_delete_dom_group }, + { "SAMR_DELETE_DOM_ALIAS" , SAMR_DELETE_DOM_ALIAS , api_samr_delete_dom_alias }, + { "SAMR_CREATE_DOM_GROUP" , SAMR_CREATE_DOM_GROUP , api_samr_create_dom_group }, + { "SAMR_CREATE_DOM_ALIAS" , SAMR_CREATE_DOM_ALIAS , api_samr_create_dom_alias }, { "SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, { "SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, { "SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, -- cgit From 8308c000b2022769644ed8ea1fc772776257c99b Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 8 Dec 1998 00:25:04 +0000 Subject: adding srvsvc pipe. (This used to be commit d06d6369942828ec89e90f99bd0d0d3f91d61d13) --- source3/rpc_server/srv_pipe.c | 1 + source3/rpc_server/srv_samr.c | 18 +++++- source3/rpc_server/srv_svcctl.c | 140 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 source3/rpc_server/srv_svcctl.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 1ad4cb6b9e..d9483deb86 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -347,6 +347,7 @@ static struct api_cmd api_fd_commands[] = { "samr", "lsass", api_samr_rpc }, { "srvsvc", "ntsvcs", api_srvsvc_rpc }, { "wkssvc", "ntsvcs", api_wkssvc_rpc }, + { "svcctl", "ntsvcs", api_svcctl_rpc }, { "NETLOGON", "lsass", api_netlog_rpc }, { "winreg", "winreg", api_reg_rpc }, { NULL, NULL, NULL } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 82dea29d9a..39a9b7591a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -518,7 +518,7 @@ static void samr_reply_add_aliasmem(SAMR_Q_ADD_ALIASMEM *q_u, DEBUG(10,("add member on Domain SID\n")); become_root(True); - r_e.status = add_alias_member(alias_rid, &q_u->sid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + r_e.status = add_alias_member(alias_rid, &q_u->sid.sid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; unbecome_root(True); } else if (sid_equal(&alias_sid, &global_sid_S_1_5_20)) @@ -526,7 +526,7 @@ static void samr_reply_add_aliasmem(SAMR_Q_ADD_ALIASMEM *q_u, DEBUG(10,("add member on BUILTIN SID\n")); become_root(True); - r_e.status = add_builtin_member(alias_rid, &q_u->sid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + r_e.status = add_builtin_member(alias_rid, &q_u->sid.sid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; unbecome_root(True); } else @@ -2234,6 +2234,20 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, { switch (q_u->switch_value) { + case 0x06: + { + switch_value = 0x6; + make_unk_info6(&ctr.info.inf6); + + break; + } + case 0x07: + { + switch_value = 0x7; + make_unk_info7(&ctr.info.inf7); + + break; + } case 0x02: { switch_value = 0x2; diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c new file mode 100644 index 0000000000..6ae8a5c873 --- /dev/null +++ b/source3/rpc_server/srv_svcctl.c @@ -0,0 +1,140 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + + +/******************************************************************* + svc_reply_unknown_1 + ********************************************************************/ +static void svc_reply_close(SVC_Q_CLOSE *q_r, + prs_struct *rdata) +{ + SVC_R_CLOSE r_u; + + /* set up the REG unknown_1 response */ + bzero(r_u.pol.data, POL_HND_SIZE); + + /* close the policy handle */ + if (close_lsa_policy_hnd(&(q_r->pol))) + { + r_u.status = 0; + } + else + { + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_INVALID; + } + + DEBUG(5,("svc_unknown_1: %d\n", __LINE__)); + + /* store the response in the SMB stream */ + svc_io_r_close("", &r_u, rdata, 0); + + DEBUG(5,("svc_unknown_1: %d\n", __LINE__)); +} + +/******************************************************************* + api_svc_close + ********************************************************************/ +static void api_svc_close( uint16 vuid, prs_struct *data, + prs_struct *rdata ) +{ + SVC_Q_CLOSE q_r; + svc_io_q_close("", &q_r, data, 0); + svc_reply_close(&q_r, rdata); +} + + +/******************************************************************* + svc_reply_open_policy + ********************************************************************/ +static void svc_reply_open_policy(SVC_Q_OPEN_POLICY *q_u, + prs_struct *rdata) +{ + uint32 status = 0; + POLICY_HND pol; + SVC_R_OPEN_POLICY r_u; + fstring name; + + DEBUG(5,("svc_open_policy: %d\n", __LINE__)); + + if (status == 0x0 && !open_lsa_policy_hnd(&pol)) + { + status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ + } + + fstrcpy(name, unistr2_to_str(&q_u->uni_srv_name)); + + if (status == 0x0) + { + DEBUG(5,("svc_open_policy: %s\n", name)); + /* lkcl XXXX do a check on the name, here */ + } + + if (status == 0x0 && !set_lsa_policy_reg_name(&pol, name)) + { + status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ + } + + make_svc_r_open_policy(&r_u, &pol, status); + + /* store the response in the SMB stream */ + svc_io_r_open_policy("", &r_u, rdata, 0); + + DEBUG(5,("svc_open_policy: %d\n", __LINE__)); +} + +/******************************************************************* + api_svc_open_policy + ********************************************************************/ +static void api_svc_open_policy( uint16 vuid, prs_struct *data, + prs_struct *rdata ) +{ + SVC_Q_OPEN_POLICY q_u; + svc_io_q_open_policy("", &q_u, data, 0); + svc_reply_open_policy(&q_u, rdata); +} + +/******************************************************************* + array of \PIPE\svcctl operations + ********************************************************************/ +static struct api_struct api_svc_cmds[] = +{ + { "SVC_CLOSE" , SVC_CLOSE , api_svc_close }, + { "SVC_OPEN_POLICY" , SVC_OPEN_POLICY , api_svc_open_policy }, + { NULL, 0 , NULL } +}; + +/******************************************************************* + receives a svcctl pipe and responds. + ********************************************************************/ +BOOL api_svcctl_rpc(pipes_struct *p, prs_struct *data) +{ + return api_rpcTNP(p, "api_svc_rpc", api_svc_cmds, data); +} + -- cgit From 7135fb0a2c869169996206a9c1cf5ac1112b9f0a Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 8 Dec 1998 23:29:37 +0000 Subject: adding "Service Control Manager" commands to rpcclient. (This used to be commit e5ee965f8d8452ab694bc5d88e474c4b91dce5b0) --- source3/rpc_server/srv_svcctl.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 6ae8a5c873..be99063946 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -71,17 +71,17 @@ static void api_svc_close( uint16 vuid, prs_struct *data, /******************************************************************* - svc_reply_open_policy + svc_reply_open_sc_man ********************************************************************/ -static void svc_reply_open_policy(SVC_Q_OPEN_POLICY *q_u, +static void svc_reply_open_sc_man(SVC_Q_OPEN_SC_MAN *q_u, prs_struct *rdata) { uint32 status = 0; POLICY_HND pol; - SVC_R_OPEN_POLICY r_u; + SVC_R_OPEN_SC_MAN r_u; fstring name; - DEBUG(5,("svc_open_policy: %d\n", __LINE__)); + DEBUG(5,("svc_open_sc_man: %d\n", __LINE__)); if (status == 0x0 && !open_lsa_policy_hnd(&pol)) { @@ -92,7 +92,7 @@ static void svc_reply_open_policy(SVC_Q_OPEN_POLICY *q_u, if (status == 0x0) { - DEBUG(5,("svc_open_policy: %s\n", name)); + DEBUG(5,("svc_open_sc_man: %s\n", name)); /* lkcl XXXX do a check on the name, here */ } @@ -101,23 +101,23 @@ static void svc_reply_open_policy(SVC_Q_OPEN_POLICY *q_u, status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } - make_svc_r_open_policy(&r_u, &pol, status); + make_svc_r_open_sc_man(&r_u, &pol, status); /* store the response in the SMB stream */ - svc_io_r_open_policy("", &r_u, rdata, 0); + svc_io_r_open_sc_man("", &r_u, rdata, 0); - DEBUG(5,("svc_open_policy: %d\n", __LINE__)); + DEBUG(5,("svc_open_sc_man: %d\n", __LINE__)); } /******************************************************************* - api_svc_open_policy + api_svc_open_sc_man ********************************************************************/ -static void api_svc_open_policy( uint16 vuid, prs_struct *data, +static void api_svc_open_sc_man( uint16 vuid, prs_struct *data, prs_struct *rdata ) { - SVC_Q_OPEN_POLICY q_u; - svc_io_q_open_policy("", &q_u, data, 0); - svc_reply_open_policy(&q_u, rdata); + SVC_Q_OPEN_SC_MAN q_u; + svc_io_q_open_sc_man("", &q_u, data, 0); + svc_reply_open_sc_man(&q_u, rdata); } /******************************************************************* @@ -126,7 +126,7 @@ static void api_svc_open_policy( uint16 vuid, prs_struct *data, static struct api_struct api_svc_cmds[] = { { "SVC_CLOSE" , SVC_CLOSE , api_svc_close }, - { "SVC_OPEN_POLICY" , SVC_OPEN_POLICY , api_svc_open_policy }, + { "SVC_OPEN_SC_MAN" , SVC_OPEN_SC_MAN , api_svc_open_sc_man }, { NULL, 0 , NULL } }; -- cgit From 74576a48fdf71e4264a892fda58302053f809670 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 9 Dec 1998 16:28:04 +0000 Subject: adding some enumerate services code, client and server. (This used to be commit dacf5b152bf74cc3ee9a816911384a5eb0e77afa) --- source3/rpc_server/srv_svcctl.c | 114 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index be99063946..6cf9b8cd22 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -120,6 +120,119 @@ static void api_svc_open_sc_man( uint16 vuid, prs_struct *data, svc_reply_open_sc_man(&q_u, rdata); } +static char *dummy_services[] = +{ + "imapd", + "popd", + "smbd", + "nmbd", + "httpd", + "inetd", + "syslogd", + NULL +}; + +/******************************************************************* + svc_reply_enum_svcs_status + ********************************************************************/ +static void svc_reply_enum_svcs_status(SVC_Q_ENUM_SVCS_STATUS *q_u, + prs_struct *rdata) +{ + uint32 dos_status = 0; + SVC_R_ENUM_SVCS_STATUS r_u; + ENUM_SRVC_STATUS *svcs = NULL; + int num_svcs = 0; + int buf_size = 0; + int i = get_enum_hnd(&q_u->resume_hnd); + uint32 resume_hnd = 0; + int max_buf_size = 0x80; + + ZERO_STRUCT(r_u); + + DEBUG(5,("svc_enum_svcs_status: %d\n", __LINE__)); + + if (dos_status == 0x0 && find_lsa_policy_by_hnd(&q_u->pol) == -1) + { + dos_status = 0xC000000 | NT_STATUS_INVALID_HANDLE; + } + + if (dos_status == 0x0) + { + DEBUG(5,("svc_enum_svcs_status:\n")); + while (dummy_services[i] != NULL) + { + + ENUM_SRVC_STATUS *svc = NULL; + + buf_size += strlen(dummy_services[i] + 1) * 2; + buf_size += 9 * sizeof(uint32); + + DEBUG(10,("buf_size: %d q_u->buf_size: %d\n", + buf_size, q_u->buf_size)); + + if (buf_size > q_u->buf_size) + { + if (buf_size >= max_buf_size) + { + resume_hnd = i; + } + break; + } + + num_svcs++; + svcs = Realloc(svcs, num_svcs * sizeof(ENUM_SRVC_STATUS)); + if (svcs == NULL) + { + dos_status = ERRnomem; + num_svcs = 0; + break; + } + + svc = &svcs[num_svcs-1]; + ZERO_STRUCTP(svc); + + make_unistr(&svc->uni_srvc_name, dummy_services[i]); + make_unistr(&svc->uni_disp_name, dummy_services[i]); + + DEBUG(10,("show service: %s\n", dummy_services[i])); + i++; + } + } + + /* + * check for finished condition: no resume handle and last buffer fits + */ + + if (resume_hnd == 0 && buf_size <= q_u->buf_size) + { + /* this indicates, along with resume_hnd of 0, an end. */ + max_buf_size = 0; + } + + make_svc_r_enum_svcs_status(&r_u, svcs, max_buf_size, num_svcs, resume_hnd, dos_status); + + /* store the response in the SMB stream */ + svc_io_r_enum_svcs_status("", &r_u, rdata, 0); + + if (svcs != NULL) + { + free(svcs); + } + + DEBUG(5,("svc_enum_svcs_status: %d\n", __LINE__)); +} + +/******************************************************************* + api_svc_enum_svcs_status + ********************************************************************/ +static void api_svc_enum_svcs_status( uint16 vuid, prs_struct *data, + prs_struct *rdata ) +{ + SVC_Q_ENUM_SVCS_STATUS q_u; + svc_io_q_enum_svcs_status("", &q_u, data, 0); + svc_reply_enum_svcs_status(&q_u, rdata); +} + /******************************************************************* array of \PIPE\svcctl operations ********************************************************************/ @@ -127,6 +240,7 @@ static struct api_struct api_svc_cmds[] = { { "SVC_CLOSE" , SVC_CLOSE , api_svc_close }, { "SVC_OPEN_SC_MAN" , SVC_OPEN_SC_MAN , api_svc_open_sc_man }, + { "SVC_ENUM_SVCS_STATUS", SVC_ENUM_SVCS_STATUS, api_svc_enum_svcs_status }, { NULL, 0 , NULL } }; -- cgit From 3cc7e2936a69ba864817e1636439722933d8475e Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 9 Dec 1998 23:16:37 +0000 Subject: adding svcctl parsing code (This used to be commit c6f2f58c74cd79d84ec4a7802882da07a9af80d4) --- source3/rpc_server/srv_svcctl.c | 76 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 67 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 6cf9b8cd22..6e8841f18a 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -70,6 +70,61 @@ static void api_svc_close( uint16 vuid, prs_struct *data, } +/******************************************************************* + svc_reply_open_service + ********************************************************************/ +static void svc_reply_open_service(SVC_Q_OPEN_SERVICE *q_u, + prs_struct *rdata) +{ + uint32 status = 0; + POLICY_HND pol; + SVC_R_OPEN_SERVICE r_u; + fstring name; + + DEBUG(5,("svc_open_service: %d\n", __LINE__)); + + if (status == 0x0 && find_lsa_policy_by_hnd(&q_u->scman_pol) == -1) + { + status = 0xC000000 | NT_STATUS_INVALID_HANDLE; + } + + if (status == 0x0 && !open_lsa_policy_hnd(&pol)) + { + status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ + } + + fstrcpy(name, unistr2_to_str(&q_u->uni_srv_name)); + + if (status == 0x0) + { + DEBUG(5,("svc_open_service: %s\n", name)); + /* lkcl XXXX do a check on the name, here */ + } + + if (status == 0x0 && !set_lsa_policy_reg_name(&pol, name)) + { + status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ + } + + make_svc_r_open_service(&r_u, &pol, status); + + /* store the response in the SMB stream */ + svc_io_r_open_service("", &r_u, rdata, 0); + + DEBUG(5,("svc_open_service: %d\n", __LINE__)); +} + +/******************************************************************* + api_svc_open_service + ********************************************************************/ +static void api_svc_open_service( uint16 vuid, prs_struct *data, + prs_struct *rdata ) +{ + SVC_Q_OPEN_SERVICE q_u; + svc_io_q_open_service("", &q_u, data, 0); + svc_reply_open_service(&q_u, rdata); +} + /******************************************************************* svc_reply_open_sc_man ********************************************************************/ @@ -145,7 +200,7 @@ static void svc_reply_enum_svcs_status(SVC_Q_ENUM_SVCS_STATUS *q_u, int buf_size = 0; int i = get_enum_hnd(&q_u->resume_hnd); uint32 resume_hnd = 0; - int max_buf_size = 0x80; + int max_buf_size = 0x10000; ZERO_STRUCT(r_u); @@ -161,7 +216,6 @@ static void svc_reply_enum_svcs_status(SVC_Q_ENUM_SVCS_STATUS *q_u, DEBUG(5,("svc_enum_svcs_status:\n")); while (dummy_services[i] != NULL) { - ENUM_SRVC_STATUS *svc = NULL; buf_size += strlen(dummy_services[i] + 1) * 2; @@ -170,12 +224,15 @@ static void svc_reply_enum_svcs_status(SVC_Q_ENUM_SVCS_STATUS *q_u, DEBUG(10,("buf_size: %d q_u->buf_size: %d\n", buf_size, q_u->buf_size)); + if (buf_size >= max_buf_size) + { + resume_hnd = i; + break; + } + if (buf_size > q_u->buf_size) { - if (buf_size >= max_buf_size) - { - resume_hnd = i; - } + dos_status = ERRmoredata; break; } @@ -238,10 +295,11 @@ static void api_svc_enum_svcs_status( uint16 vuid, prs_struct *data, ********************************************************************/ static struct api_struct api_svc_cmds[] = { - { "SVC_CLOSE" , SVC_CLOSE , api_svc_close }, - { "SVC_OPEN_SC_MAN" , SVC_OPEN_SC_MAN , api_svc_open_sc_man }, + { "SVC_CLOSE" , SVC_CLOSE , api_svc_close }, + { "SVC_OPEN_SC_MAN" , SVC_OPEN_SC_MAN , api_svc_open_sc_man }, + { "SVC_OPEN_SERVICE" , SVC_OPEN_SERVICE , api_svc_open_service }, { "SVC_ENUM_SVCS_STATUS", SVC_ENUM_SVCS_STATUS, api_svc_enum_svcs_status }, - { NULL, 0 , NULL } + { NULL , 0 , NULL } }; /******************************************************************* -- cgit From 254470cb566fc06f5818830d105361d853648d6e Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 14 Dec 1998 20:23:20 +0000 Subject: added sid_name_use array argument to lsa_lookup_names and lsa_lookup_sids. (This used to be commit 0b2095e092d747f741e78a3349f0b81a72811629) --- source3/rpc_server/srv_lsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 947de768b5..5f4f9fb929 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -224,7 +224,7 @@ static void make_lsa_rid2s(DOM_R_REF *ref, { sid_name_use = SID_NAME_DOMAIN; dom_idx = make_dom_ref(ref, dom_name, &find_sid); - } + } if (lookup_name(find_name, &sid, &sid_name_use) == 0x0 && sid_split_rid(&sid, &rid)) -- cgit From 0504d696f811399ba550be90d9e99be062c78327 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 20 Dec 1998 00:37:24 +0000 Subject: fix for potential lsass.exe crashing due to negative response from LsaLookupNames being incorrect. this is a bit wierd: why would the lsass.exe on the nt _client_ crash due to an LsaLookupNames response from a samba _server_? (This used to be commit a15a3f95f2a14ab164ca758e2145444a803190b2) --- source3/rpc_server/srv_lsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 5f4f9fb929..4db97f6d4c 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -177,7 +177,7 @@ static int make_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) ref->undoc_buffer = 1; ref->num_ref_doms_1 = num+1; - ref->undoc_buffer2 = 1; + ref->ptr_ref_dom = 1; ref->max_entries = MAX_REF_DOMAINS; ref->num_ref_doms_2 = num+1; -- cgit From 837601c9df08266308c37b6afc0bdcb942c572d1 Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Fri, 15 Jan 1999 05:02:41 +0000 Subject: Fixed typo in srv_samr.c where samr_add_groupmem and samr_del_groupmem were the wrong way around. (This used to be commit 2b6f4818858d422399321064245a36be1dba9738) --- source3/rpc_server/srv_samr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 39a9b7591a..2c05377099 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -2586,10 +2586,10 @@ static struct api_struct api_samr_cmds [] = { "SAMR_QUERY_USERALIASES", SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, { "SAMR_QUERY_ALIASMEM" , SAMR_QUERY_ALIASMEM , api_samr_query_aliasmem }, { "SAMR_QUERY_GROUPMEM" , SAMR_QUERY_GROUPMEM , api_samr_query_groupmem }, - { "SAMR_ADD_ALIASMEM" , SAMR_ADD_ALIASMEM , api_samr_del_aliasmem }, - { "SAMR_DEL_ALIASMEM" , SAMR_DEL_ALIASMEM , api_samr_add_aliasmem }, - { "SAMR_ADD_GROUPMEM" , SAMR_ADD_GROUPMEM , api_samr_del_groupmem }, - { "SAMR_DEL_GROUPMEM" , SAMR_DEL_GROUPMEM , api_samr_add_groupmem }, + { "SAMR_ADD_ALIASMEM" , SAMR_ADD_ALIASMEM , api_samr_add_aliasmem }, + { "SAMR_DEL_ALIASMEM" , SAMR_DEL_ALIASMEM , api_samr_del_aliasmem }, + { "SAMR_ADD_GROUPMEM" , SAMR_ADD_GROUPMEM , api_samr_add_groupmem }, + { "SAMR_DEL_GROUPMEM" , SAMR_DEL_GROUPMEM , api_samr_del_groupmem }, { "SAMR_DELETE_DOM_GROUP" , SAMR_DELETE_DOM_GROUP , api_samr_delete_dom_group }, { "SAMR_DELETE_DOM_ALIAS" , SAMR_DELETE_DOM_ALIAS , api_samr_delete_dom_alias }, { "SAMR_CREATE_DOM_GROUP" , SAMR_CREATE_DOM_GROUP , api_samr_create_dom_group }, -- cgit From 92aca8b1b7d292d7c558928217f1c8dbbb9dfa87 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 28 Jan 1999 21:10:38 +0000 Subject: error code cleanup (This used to be commit 61c40982d6fde34729dc6850cf3372482392f4c9) --- source3/rpc_server/srv_samr.c | 54 +++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 2c05377099..15cef476c4 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -402,7 +402,7 @@ static void samr_reply_add_groupmem(SAMR_Q_ADD_GROUPMEM *q_u, DEBUG(10,("lookup on Domain SID\n")); become_root(True); - r_e.status = add_group_member(group_rid, q_u->rid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + r_e.status = add_group_member(group_rid, q_u->rid) ? 0x0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); unbecome_root(True); } else @@ -460,7 +460,7 @@ static void samr_reply_del_groupmem(SAMR_Q_DEL_GROUPMEM *q_u, DEBUG(10,("lookup on Domain SID\n")); become_root(True); - r_e.status = del_group_member(group_rid, q_u->rid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + r_e.status = del_group_member(group_rid, q_u->rid) ? 0x0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); unbecome_root(True); } else @@ -518,7 +518,7 @@ static void samr_reply_add_aliasmem(SAMR_Q_ADD_ALIASMEM *q_u, DEBUG(10,("add member on Domain SID\n")); become_root(True); - r_e.status = add_alias_member(alias_rid, &q_u->sid.sid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + r_e.status = add_alias_member(alias_rid, &q_u->sid.sid) ? 0x0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); unbecome_root(True); } else if (sid_equal(&alias_sid, &global_sid_S_1_5_20)) @@ -526,7 +526,7 @@ static void samr_reply_add_aliasmem(SAMR_Q_ADD_ALIASMEM *q_u, DEBUG(10,("add member on BUILTIN SID\n")); become_root(True); - r_e.status = add_builtin_member(alias_rid, &q_u->sid.sid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + r_e.status = add_builtin_member(alias_rid, &q_u->sid.sid) ? 0x0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); unbecome_root(True); } else @@ -584,7 +584,7 @@ static void samr_reply_del_aliasmem(SAMR_Q_DEL_ALIASMEM *q_u, DEBUG(10,("del member on Domain SID\n")); become_root(True); - r_e.status = del_alias_member(alias_rid, &q_u->sid.sid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + r_e.status = del_alias_member(alias_rid, &q_u->sid.sid) ? 0x0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); unbecome_root(True); } else if (sid_equal(&alias_sid, &global_sid_S_1_5_20)) @@ -592,7 +592,7 @@ static void samr_reply_del_aliasmem(SAMR_Q_DEL_ALIASMEM *q_u, DEBUG(10,("del member on BUILTIN SID\n")); become_root(True); - r_e.status = del_builtin_member(alias_rid, &q_u->sid.sid) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + r_e.status = del_builtin_member(alias_rid, &q_u->sid.sid) ? 0x0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); unbecome_root(True); } else @@ -929,12 +929,12 @@ static void samr_reply_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP *q_u, DEBUG(10,("lookup on Domain SID\n")); become_root(True); - status = del_group_entry(group_rid) ? 0x0 : 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; + status = del_group_entry(group_rid) ? 0x0 : (0xC0000000 | NT_STATUS_NO_SUCH_GROUP); unbecome_root(True); } else { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + status = 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; } } @@ -995,12 +995,12 @@ static void samr_reply_query_groupmem(SAMR_Q_QUERY_GROUPMEM *q_u, DEBUG(10,("lookup on Domain SID\n")); become_root(True); - status = getgrouprid(group_rid, &mem_grp, &num_rids) != NULL ? 0x0 : 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; + status = getgrouprid(group_rid, &mem_grp, &num_rids) != NULL ? 0x0 : (0xC0000000 | NT_STATUS_NO_SUCH_GROUP); unbecome_root(True); } else { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + status = 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; } } @@ -1248,15 +1248,15 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, if (status == 0x0 && num_rids > 0) { - rid = malloc(num_rids * sizeof(uint32)); - if (mem_grp != NULL && rid != NULL) + rid = malloc(num_rids * sizeof(uint32)); + if (mem_grp != NULL && rid != NULL) + { + int i; + for (i = 0; i < num_rids; i++) { - int i; - for (i = 0; i < num_rids; i++) - { - rid[i] = mem_grp[i].rid; - } - free(mem_grp); + rid[i] = mem_grp[i].rid; + } + free(mem_grp); } } @@ -1320,12 +1320,12 @@ static void samr_reply_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS *q_u, DEBUG(10,("lookup on Domain SID\n")); become_root(True); - status = del_alias_entry(alias_rid) ? 0x0 : 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; + status = del_alias_entry(alias_rid) ? 0x0 : (0xC0000000 | NT_STATUS_NO_SUCH_ALIAS); unbecome_root(True); } else { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + status = 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; } } @@ -1385,7 +1385,7 @@ static void samr_reply_query_aliasmem(SAMR_Q_QUERY_ALIASMEM *q_u, DEBUG(10,("lookup on S-1-5-20\n")); become_root(True); - status = getbuiltinrid(alias_rid, &mem_grp, &num_sids) != NULL ? 0x0 : 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; + status = getbuiltinrid(alias_rid, &mem_grp, &num_sids) != NULL ? 0x0 : 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; unbecome_root(True); } else if (sid_equal(&alias_sid, &global_sam_sid)) @@ -1393,12 +1393,12 @@ static void samr_reply_query_aliasmem(SAMR_Q_QUERY_ALIASMEM *q_u, DEBUG(10,("lookup on Domain SID\n")); become_root(True); - status = getaliasrid(alias_rid, &mem_grp, &num_sids) != NULL ? 0x0 : 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; + status = getaliasrid(alias_rid, &mem_grp, &num_sids) != NULL ? 0x0 : 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; unbecome_root(True); } else { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + status = 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; } } @@ -1845,7 +1845,7 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, case 0x10: { info = (void*)&id10; - status = get_user_info_10(&id10, rid) ? 0 : NT_STATUS_NO_SUCH_USER; + status = get_user_info_10(&id10, rid) ? 0 : (0xC0000000 | NT_STATUS_NO_SUCH_USER); break; } #if 0 @@ -1866,7 +1866,7 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, case 21: { info = (void*)&id21; - status = get_user_info_21(&id21, rid) ? 0 : NT_STATUS_NO_SUCH_USER; + status = get_user_info_21(&id21, rid) ? 0 : (0xC0000000 | NT_STATUS_NO_SUCH_USER); break; } @@ -2063,7 +2063,7 @@ static void samr_reply_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS *q_u, grp.rid = 0xffffffff; become_root(True); - status = add_alias_entry(&grp) ? 0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + status = add_alias_entry(&grp) ? 0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); unbecome_root(True); } @@ -2175,7 +2175,7 @@ static void samr_reply_create_dom_group(SAMR_Q_CREATE_DOM_GROUP *q_u, grp.attr = 0x07; become_root(True); - status = add_group_entry(&grp) ? 0x0 : 0xC0000000 | NT_STATUS_ACCESS_DENIED; + status = add_group_entry(&grp) ? 0x0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); unbecome_root(True); } -- cgit From 206013169c77cb0bb8f9db2476dba53509503846 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 29 Jan 1999 19:20:27 +0000 Subject: uni_svc_name not uni_srv_name (This used to be commit 14080a564a24f8f35cb8711b912c46f7243cd723) --- source3/rpc_server/srv_svcctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 6e8841f18a..6a39b246d0 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -93,7 +93,7 @@ static void svc_reply_open_service(SVC_Q_OPEN_SERVICE *q_u, status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } - fstrcpy(name, unistr2_to_str(&q_u->uni_srv_name)); + fstrcpy(name, unistr2_to_str(&q_u->uni_svc_name)); if (status == 0x0) { -- cgit From 9b5043cb2f125c39eda1e986cfcce3b534dc3b43 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 29 Jan 1999 21:22:08 +0000 Subject: fix for enumerate domain users (bug spotted by sean matthews). also needed to use start index properly and generate next index. both client and server code need to recognise error code 0x105 when there's not enough room to store all the users in one call. sort this out another time. (This used to be commit ad58cdfac6b85d9431216e32e532ad4d60f9c6dd) --- source3/rpc_server/srv_samr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 15cef476c4..1fb64c10ef 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -73,7 +73,10 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, /* skip the requested number of entries. not very efficient, but hey... */ - start_idx--; + if (acb_mask == 0 || IS_BITS_SET_SOME(pwd->acct_ctrl, acb_mask)) + { + start_idx--; + } continue; } @@ -344,11 +347,12 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, DEBUG(5,("samr_reply_enum_dom_users: %d\n", __LINE__)); become_root(True); - get_sampwd_entries(pass, 0, &total_entries, &num_entries, MAX_SAM_ENTRIES, q_u->acb_mask); + get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, + MAX_SAM_ENTRIES, q_u->acb_mask); unbecome_root(True); make_samr_r_enum_dom_users(&r_e, - 0x00000000, num_entries, + q_u->start_idx + num_entries, num_entries, pass, r_e.status); /* store the response in the SMB stream */ -- cgit From 07948f3f2d6625d1197036bb1763269f2e52345f Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 2 Feb 1999 19:53:10 +0000 Subject: server type announcements modified to include the "role" of the server: domain member, pdc, bdc. (This used to be commit d95bb252f838b3612f5eba5d2b61d7b38b01f5ef) --- source3/rpc_server/srv_srvsvc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index c7aeee9b11..dacef42121 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -865,9 +865,12 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, case 102: { make_srv_info_102(&ctr.srv.sv102, - 500, global_myname, lp_serverstring(), - 5, 4, /* major/minor version - NT 5.4 :-) */ - 0x4100b, /* browsing stuff SV_TYPE_XXXX */ + 500, /* platform id */ + global_myname, + lp_serverstring(), + lp_major_announce_version(), + lp_minor_announce_version(), + lp_default_server_announce(), 0xffffffff, /* users */ 0xf, /* disc */ 0, /* hidden */ @@ -880,9 +883,11 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, case 101: { make_srv_info_101(&ctr.srv.sv101, - 500, global_myname, - 5, 4, /* major/minor version - NT 5.4 :-) */ - 0x4100b, /* browsing stuff SV_TYPE_XXXX */ + 500, /* platform id */ + global_myname, + lp_major_announce_version(), + lp_minor_announce_version(), + lp_default_server_announce(), lp_serverstring()); break; } -- cgit From fe609d810e145d5491968fee5d691d6eee41e152 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 3 Feb 1999 00:48:27 +0000 Subject: multiple dce/rpc PDUs failed to work after ntlmssp update was added. (This used to be commit f082f07e764c04b75b6880f852b80faec86f1b1c) --- source3/rpc_server/srv_pipe.c | 1 - source3/rpc_server/srv_pipe_hnd.c | 54 +++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index d9483deb86..9e03188af5 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -203,7 +203,6 @@ BOOL create_rpc_reply(pipes_struct *p, } /* indicate to subsequent data reads where we are up to */ - p->frag_len_left = p->hdr.frag_len - p->file_offset; p->next_frag_start = p->hdr.frag_len; return p->rhdr.data != NULL && p->rhdr.offset == 0x18; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 54ecbf707e..e29e1ee8db 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -133,8 +133,8 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->rdata.offset = 0; p->file_offset = 0; + p->prev_pdu_file_offset = 0; p->hdr_offsets = 0; - p->frag_len_left = 0; p->next_frag_start = 0; p->ntlmssp_validated = False; @@ -230,24 +230,12 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) DEBUG(6,("read_pipe: p: %p file_offset: %d file_pos: %d\n", p, p->file_offset, n)); - DEBUG(6,("read_pipe: frag_len_left: %d next_frag_start: %d\n", - p->frag_len_left, p->next_frag_start)); + DEBUG(6,("read_pipe: next_frag_start: %d\n", + p->next_frag_start)); /* the read request starts from where the SMBtrans2 left off. */ - data_pos = p->file_offset - p->hdr_offsets; - data_hdr_pos = p->file_offset; - - len = mem_buf_len(p->rhdr.data); - num = len - (int)data_pos; - - DEBUG(6,("read_pipe: len: %d num: %d n: %d\n", len, num, n)); - - if (num > n) num = n; - if (num <= 0) - { - DEBUG(5,("read_pipe: 0 or -ve data length\n")); - return 0; - } + data_hdr_pos = p->file_offset - p->prev_pdu_file_offset; + data_pos = data_hdr_pos - p->hdr_offsets; if (!IS_BITS_SET_ALL(p->hdr.flags, RPC_FLG_LAST)) { @@ -256,48 +244,52 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) DEBUG(5,("read_pipe: frag_len: %d data_pos: %d data_hdr_pos: %d\n", p->hdr.frag_len, data_pos, data_hdr_pos)); - if (data_hdr_pos == p->next_frag_start) + if (data_hdr_pos == 0) { DEBUG(6,("read_pipe: next fragment header\n")); /* this is subtracted from the total data bytes, later */ hdr_num = 0x18; + p->hdr_offsets += 0x18; /* create and copy in a new header. */ - create_rpc_reply(p, data_pos, p->rdata.offset); - mem_buf_copy(data, p->rhdr.data, 0, 0x18); - - data += 0x18; - p->hdr_offsets += 0x18; + create_rpc_reply(p, p->file_offset - p->hdr_offsets, p->rdata.offset); } } + len = mem_buf_len(p->rhdr.data); + num = len - (int)data_pos; + + DEBUG(6,("read_pipe: len: %d num: %d n: %d\n", len, num, n)); + + if (num > n) num = n; + if (num <= 0) + { + DEBUG(5,("read_pipe: 0 or -ve data length\n")); + return 0; + } + if (num < hdr_num) { DEBUG(5,("read_pipe: warning - data read only part of a header\n")); } - DEBUG(6,("read_pipe: adjusted data_pos: %d num-hdr_num: %d\n", - data_pos, num - hdr_num)); - mem_buf_copy(data, p->rhdr.data, data_pos, num - hdr_num); + mem_buf_copy(data, p->rhdr.data, data_pos, num); data_pos += num; data_hdr_pos += num; + p->file_offset += num; if (hdr_num == 0x18 && num == 0x18) { DEBUG(6,("read_pipe: just header read\n")); - - /* advance to the next fragment */ - p->frag_len_left -= 0x18; } else if (data_hdr_pos == p->next_frag_start) { DEBUG(6,("read_pipe: next fragment expected\n")); + p->prev_pdu_file_offset = p->file_offset; } - p->file_offset += num; - return num; } -- cgit From 1153f00f889e5bb310e895d319eed75bc93deef4 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 3 Feb 1999 00:49:24 +0000 Subject: cache unix groups so that two-level getgrent calls don't occur. (This used to be commit f7dfa55a2e191ae780d399026bce48f68cda4bf0) --- source3/rpc_server/srv_reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 33ccae3f93..b90912488f 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -194,7 +194,7 @@ static void reg_reply_info(REG_Q_INFO *q_u, { } - make_reg_r_info(&r_u, 1, "LanmanNT", 0x12, 0x12, status); + make_reg_r_info(&r_u, 1, "LanmanNT", status); /* store the response in the SMB stream */ reg_io_r_info("", &r_u, rdata, 0); -- cgit From f61fc8923d4eceab8c82ff9c49745f9c6bed44e7 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 3 Feb 1999 01:58:52 +0000 Subject: corrections to get data stream for 2nd and subsequent pdus copied from right place (forgot to subtract 0x18 header bytes) (This used to be commit 5b9a7278da4a25ea217f914c8daae31238fa5cfe) --- source3/rpc_server/srv_pipe.c | 3 --- source3/rpc_server/srv_pipe_hnd.c | 38 +++++++++++++++++++------------------- 2 files changed, 19 insertions(+), 22 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 9e03188af5..f8d882cd0c 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -202,9 +202,6 @@ BOOL create_rpc_reply(pipes_struct *p, prs_link(&p->rhdr, &p->rdata_i, NULL ); } - /* indicate to subsequent data reads where we are up to */ - p->next_frag_start = p->hdr.frag_len; - return p->rhdr.data != NULL && p->rhdr.offset == 0x18; } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index e29e1ee8db..ca5dde18d2 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -135,7 +135,6 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->file_offset = 0; p->prev_pdu_file_offset = 0; p->hdr_offsets = 0; - p->next_frag_start = 0; p->ntlmssp_validated = False; p->ntlmssp_auth = False; @@ -203,10 +202,11 @@ ssize_t write_pipe(pipes_struct *p, char *data, size_t n) int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) { int num = 0; - int len = 0; + int pdu_len = 0; uint32 hdr_num = 0; - int data_hdr_pos; - int data_pos; + int pdu_data_sent; /* amount of current pdu already sent */ + int data_pos; /* entire rpc data sent - no headers, no auth verifiers */ + int this_pdu_data_pos; DEBUG(6,("read_pipe: %x", p->pnum)); @@ -230,37 +230,37 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) DEBUG(6,("read_pipe: p: %p file_offset: %d file_pos: %d\n", p, p->file_offset, n)); - DEBUG(6,("read_pipe: next_frag_start: %d\n", - p->next_frag_start)); /* the read request starts from where the SMBtrans2 left off. */ - data_hdr_pos = p->file_offset - p->prev_pdu_file_offset; - data_pos = data_hdr_pos - p->hdr_offsets; + data_pos = p->file_offset - p->hdr_offsets; + this_pdu_data_pos = data_pos - p->prev_pdu_file_offset; + pdu_data_sent = p->file_offset - p->prev_pdu_file_offset; if (!IS_BITS_SET_ALL(p->hdr.flags, RPC_FLG_LAST)) { /* intermediate fragment - possibility of another header */ - DEBUG(5,("read_pipe: frag_len: %d data_pos: %d data_hdr_pos: %d\n", - p->hdr.frag_len, data_pos, data_hdr_pos)); + DEBUG(5,("read_pipe: frag_len: %d data_pos: %d pdu_data_sent: %d\n", + p->hdr.frag_len, data_pos, pdu_data_sent)); - if (data_hdr_pos == 0) + if (pdu_data_sent == 0) { DEBUG(6,("read_pipe: next fragment header\n")); /* this is subtracted from the total data bytes, later */ hdr_num = 0x18; p->hdr_offsets += 0x18; + data_pos -= 0x18; /* create and copy in a new header. */ - create_rpc_reply(p, p->file_offset - p->hdr_offsets, p->rdata.offset); + create_rpc_reply(p, data_pos, p->rdata.offset); } } - len = mem_buf_len(p->rhdr.data); - num = len - (int)data_pos; + pdu_len = mem_buf_len(p->rhdr.data); + num = pdu_len - (int)this_pdu_data_pos; - DEBUG(6,("read_pipe: len: %d num: %d n: %d\n", len, num, n)); + DEBUG(6,("read_pipe: pdu_len: %d num: %d n: %d\n", pdu_len, num, n)); if (num > n) num = n; if (num <= 0) @@ -274,17 +274,17 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) DEBUG(5,("read_pipe: warning - data read only part of a header\n")); } - mem_buf_copy(data, p->rhdr.data, data_pos, num); + mem_buf_copy(data, p->rhdr.data, pdu_data_sent, num); - data_pos += num; - data_hdr_pos += num; p->file_offset += num; + pdu_data_sent += num; if (hdr_num == 0x18 && num == 0x18) { DEBUG(6,("read_pipe: just header read\n")); } - else if (data_hdr_pos == p->next_frag_start) + + if (pdu_data_sent == p->hdr.frag_len) { DEBUG(6,("read_pipe: next fragment expected\n")); p->prev_pdu_file_offset = p->file_offset; -- cgit From 99a9b0f7c4f85f46102457cf4707e8948b77fb3f Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 8 Feb 1999 23:40:49 +0000 Subject: UNICODE byte ordering issue: typecast to uint16* replaced with SSVAL() (This used to be commit 9084b7e33dfe717bd8d5604ee71d137e3baef0f5) --- source3/rpc_server/srv_pipe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index f8d882cd0c..5908fe06b5 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -225,9 +225,9 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) if (IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_UNICODE)) { - fstrcpy(p->user_name, unistrn2((uint16*)p->ntlmssp_resp.user , p->ntlmssp_resp.hdr_usr .str_str_len/2)); - fstrcpy(p->domain , unistrn2((uint16*)p->ntlmssp_resp.domain, p->ntlmssp_resp.hdr_domain.str_str_len/2)); - fstrcpy(p->wks , unistrn2((uint16*)p->ntlmssp_resp.wks , p->ntlmssp_resp.hdr_wks .str_str_len/2)); + fstrcpy(p->user_name, unistrn2(p->ntlmssp_resp.user , p->ntlmssp_resp.hdr_usr .str_str_len/2)); + fstrcpy(p->domain , unistrn2(p->ntlmssp_resp.domain, p->ntlmssp_resp.hdr_domain.str_str_len/2)); + fstrcpy(p->wks , unistrn2(p->ntlmssp_resp.wks , p->ntlmssp_resp.hdr_wks .str_str_len/2)); } else { -- cgit From bfff648f382169321bbefec4f96bdfd0438b9168 Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Tue, 9 Feb 1999 03:57:10 +0000 Subject: Fix for NT BSOD problem. There's no reason to have two "NT usernames" running around anyway. The real problem is, once again, the brokenness of pwdb_sam_map_names et al. This time it is deciding to return blank NT usernames, which NT's redirector objects to. I'm currently working on improving the pwdb/mapping code, should be ready in a couple of weeks. (This used to be commit 30a085bf80982c619cd78aee9ad410ece5f88679) --- source3/rpc_server/srv_netlog.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index bb8bc59bc5..c3810a09e5 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -609,7 +609,6 @@ static void api_net_sam_logon( uint16 vuid, NTTIME pass_can_change_time ; NTTIME pass_must_change_time; - fstring nt_name ; fstring full_name ; fstring logon_script; fstring profile_path; @@ -706,7 +705,6 @@ static void api_net_sam_logon( uint16 vuid, pass_can_change_time = sam_pass->pass_can_change_time; pass_must_change_time = sam_pass->pass_must_change_time; - fstrcpy(nt_name , sam_pass->nt_name); fstrcpy(full_name , sam_pass->full_name); fstrcpy(logon_script, sam_pass->logon_script); fstrcpy(profile_path, sam_pass->profile_path); @@ -771,7 +769,7 @@ static void api_net_sam_logon( uint16 vuid, &pass_can_change_time, &pass_must_change_time, - nt_name , /* user_name */ + nt_username , /* user_name */ full_name , /* full_name */ logon_script , /* logon_script */ profile_path , /* profile_path */ -- cgit From 3b12477f34a4311235c7c0b2e9a9cdc9f5a4f0e9 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 9 Feb 1999 16:01:28 +0000 Subject: pwdb_smb_to_sam was not returning NULL for nt name so that pwdb_sam_map_names() was using a "blank" static string instead of a NULL pointer for nt names. NULL means over-ride, so the nt name got left as "blank". this causes nt clients to terminate with extreme prejudice. (This used to be commit ddd350198202d6a1d2c715b3dce7db3a5d76a63a) --- source3/rpc_server/srv_netlog.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index c3810a09e5..33eb889ff2 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -288,8 +288,7 @@ static void api_net_req_chal( uint16 vuid, /* grab the challenge... */ net_io_q_req_chal("", &q_r, data, 0); - fstrcpy(mach_acct, unistrn2(q_r.uni_logon_clnt.buffer, - q_r.uni_logon_clnt.uni_str_len)); + fstrcpy(mach_acct, unistr2_to_str(&q_r.uni_logon_clnt)); fstrcpy(mach_name, mach_acct); strlower(mach_name); @@ -400,8 +399,7 @@ static void api_net_srv_pwset( uint16 vuid, DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); - pstrcpy(mach_acct, unistrn2(q_a.clnt_id.login.uni_acct_name.buffer, - q_a.clnt_id.login.uni_acct_name.uni_str_len)); + fstrcpy(mach_acct, unistr2_to_str(&q_a.clnt_id.login.uni_acct_name)); DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); @@ -609,6 +607,7 @@ static void api_net_sam_logon( uint16 vuid, NTTIME pass_can_change_time ; NTTIME pass_must_change_time; + fstring nt_name ; fstring full_name ; fstring logon_script; fstring profile_path; @@ -705,6 +704,7 @@ static void api_net_sam_logon( uint16 vuid, pass_can_change_time = sam_pass->pass_can_change_time; pass_must_change_time = sam_pass->pass_must_change_time; + fstrcpy(nt_name , sam_pass->nt_name); fstrcpy(full_name , sam_pass->full_name); fstrcpy(logon_script, sam_pass->logon_script); fstrcpy(profile_path, sam_pass->profile_path); @@ -769,7 +769,7 @@ static void api_net_sam_logon( uint16 vuid, &pass_can_change_time, &pass_must_change_time, - nt_username , /* user_name */ + nt_name , /* user_name */ full_name , /* full_name */ logon_script , /* logon_script */ profile_path , /* profile_path */ -- cgit From 748f296a76a76d38525ad35df6658811cae60222 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 9 Feb 1999 19:51:44 +0000 Subject: removal of the use of unistrn2 function: replace it with unistr2_to_str which is more appropriate. (This used to be commit ac72fe1ab3d10f64a5945ccbd4ed3817e30f9f7b) --- source3/rpc_server/srv_reg.c | 2 +- source3/rpc_server/srv_samr.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index b90912488f..f98133626d 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -136,7 +136,7 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } - fstrcpy(name, unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len)); + fstrcpy(name, unistr2_to_str(&q_u->uni_name)); if (status == 0x0) { diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 1fb64c10ef..8961660071 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1527,8 +1527,8 @@ static void samr_reply_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u, fstring user_name; fstring wks; - fstrcpy(user_name, unistrn2(q_u->uni_user_name.buffer, q_u->uni_user_name.uni_str_len)); - fstrcpy(wks , unistrn2(q_u->uni_dest_host.buffer, q_u->uni_dest_host.uni_str_len)); + fstrcpy(user_name, unistr2_to_str(&q_u->uni_user_name)); + fstrcpy(wks , unistr2_to_str(&q_u->uni_dest_host)); DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); @@ -2340,8 +2340,7 @@ static void api_samr_unknown_32( uint16 vuid, prs_struct *data, prs_struct *rdat reply if the account already exists... */ - fstrcpy(mach_acct, unistrn2(q_u.uni_mach_acct.buffer, - q_u.uni_mach_acct.uni_str_len)); + fstrcpy(mach_acct, unistr2_to_str(&q_u.uni_mach_acct)); become_root(True); sam_pass = getsam21pwntnam(mach_acct); -- cgit From 96983a13bac8276590024b37149b7bf3e80477dd Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 9 Feb 1999 21:42:39 +0000 Subject: when multiple independent large rpc calls come in on the same pipe, prev_pdu_file_offset was not being re-initialised to zero. (This used to be commit fcaa1214412f5a417a648d4da5c4332f75f59f57) --- source3/rpc_server/srv_pipe_hnd.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index ca5dde18d2..27aa79381c 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -208,11 +208,8 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) int data_pos; /* entire rpc data sent - no headers, no auth verifiers */ int this_pdu_data_pos; - DEBUG(6,("read_pipe: %x", p->pnum)); - - DEBUG(6,("name: %s open: %s pos: %d len: %d", - p->name, - BOOLSTR(p->open), + DEBUG(6,("read_pipe: %x name: %s open: %s pos: %d len: %d", + p->pnum, p->name, BOOLSTR(p->open), pos, n)); if (!p || !p->open) -- cgit From 4cb18cd734951597f1fcdffdb99ddc97f5ea83d3 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 9 Feb 1999 21:56:06 +0000 Subject: groups and aliases being "manually" added which do not necessarily have representation in the underlying database: removed this code. for example, with the nt->unix mapping system (don't know about the ldap one) if you want "Domain Admins" to appear you _must_ put it in the domaingroup.map file. the previous code was adding builtin aliases and well-known groups even if they weren't in the domain maps. bad idea. (This used to be commit 56469578a1af0fbcf6edddf94c498c7bbfb385c6) --- source3/rpc_server/srv_samr.c | 52 ++++++------------------------------------- 1 file changed, 7 insertions(+), 45 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 8961660071..ec3fa289a7 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -34,10 +34,6 @@ extern DOM_SID global_sam_sid; extern DOM_SID global_sid_S_1_1; extern DOM_SID global_sid_S_1_5_20; -extern rid_name domain_group_rids[]; -extern rid_name domain_alias_rids[]; -extern rid_name builtin_alias_rids[]; - /******************************************************************* This next function should be replaced with something that dynamically returns the correct user info..... JRA. @@ -662,33 +658,6 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, } } - if (r_e.status == 0x0 && - (sid_equal(&sid, &global_sam_sid) || - sid_equal(&sid, &global_sid_S_1_5_20))) - { - char *name; - int i = 0; - got_grps = True; - - while (num_entries < MAX_SAM_ENTRIES && ((name = domain_group_rids[i].name) != NULL)) - { - DOMAIN_GRP tmp_grp; - - fstrcpy(tmp_grp.name , name); - fstrcpy(tmp_grp.comment, ""); - tmp_grp.rid = domain_group_rids[i].rid; - tmp_grp.attr = 0x7; - - if (!add_domain_group(&grps, &num_entries, &tmp_grp)) - { - r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; - break; - } - - i++; - } - } - if (r_e.status == 0 && got_grps) { make_samr_r_enum_dom_groups(&r_e, q_u->start_idx, num_entries, grps, r_e.status); @@ -744,28 +713,21 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, /* well-known aliases */ if (sid_equal(&sid, &global_sid_S_1_5_20)) { - char *name; + BOOL ret; + /* builtin aliases */ - while ((name = builtin_alias_rids[num_entries].name) != NULL) + become_root(True); + ret = enumdombuiltins(&alss, &num_entries); + unbecome_root(True); + if (!ret) { - LOCAL_GRP tmp_als; - - fstrcpy(tmp_als.name , name); - fstrcpy(tmp_als.comment, ""); - tmp_als.rid = builtin_alias_rids[num_entries].rid; - - if (!add_domain_alias(&alss, &num_entries, &tmp_als)) - { - r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; - break; - } + r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; } } else if (sid_equal(&sid, &global_sam_sid)) { BOOL ret; /* local aliases */ - num_entries = 0; become_root(True); ret = enumdomaliases(&alss, &num_entries); -- cgit From 7a65924133431a45cf3b80f06b741f17d4f729c1 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 9 Feb 1999 22:13:20 +0000 Subject: Having Well-known Domain Groups ("Domain Admins/Guests/Users") returned under SID_NAME_ENUM 0x5 instead of 0x2 (Well-known group instead of Domain Group) was making it impossible to view these groups from USRMGR.EXE. (This used to be commit 3072044134eadbf46350b32c1ed0703681b0d590) --- source3/rpc_server/srv_lookup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index 70183636d1..08f2e11d77 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -196,7 +196,7 @@ uint32 lookup_wk_group_sid(DOM_SID *sid, char *group_name, uint8 *type) uint32 rid; DOM_SID tmp; - (*type) = SID_NAME_WKN_GRP; + (*type) = SID_NAME_DOM_GRP; sid_copy(&tmp, sid); sid_split_rid(&tmp, &rid); -- cgit From 8b6b6b57b54aeafb915cf99e5610941ee1d464b8 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 10 Feb 1999 22:30:47 +0000 Subject: use jeremy's versions of the UNICODE routines. (This used to be commit c5109ff782be8774db47a92b48ca6335ec8d6065) --- source3/rpc_server/srv_pipe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 5908fe06b5..f8d882cd0c 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -225,9 +225,9 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) if (IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_UNICODE)) { - fstrcpy(p->user_name, unistrn2(p->ntlmssp_resp.user , p->ntlmssp_resp.hdr_usr .str_str_len/2)); - fstrcpy(p->domain , unistrn2(p->ntlmssp_resp.domain, p->ntlmssp_resp.hdr_domain.str_str_len/2)); - fstrcpy(p->wks , unistrn2(p->ntlmssp_resp.wks , p->ntlmssp_resp.hdr_wks .str_str_len/2)); + fstrcpy(p->user_name, unistrn2((uint16*)p->ntlmssp_resp.user , p->ntlmssp_resp.hdr_usr .str_str_len/2)); + fstrcpy(p->domain , unistrn2((uint16*)p->ntlmssp_resp.domain, p->ntlmssp_resp.hdr_domain.str_str_len/2)); + fstrcpy(p->wks , unistrn2((uint16*)p->ntlmssp_resp.wks , p->ntlmssp_resp.hdr_wks .str_str_len/2)); } else { -- cgit From f38bfc7d9aa07c4e21448aa846956bd89a259a65 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 11 Feb 1999 22:12:49 +0000 Subject: UNICODE issues. (This used to be commit 6a437cfb33f24913e0c1f8484c0b08ef317e513b) --- source3/rpc_server/srv_pipe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index f8d882cd0c..5908fe06b5 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -225,9 +225,9 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) if (IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_UNICODE)) { - fstrcpy(p->user_name, unistrn2((uint16*)p->ntlmssp_resp.user , p->ntlmssp_resp.hdr_usr .str_str_len/2)); - fstrcpy(p->domain , unistrn2((uint16*)p->ntlmssp_resp.domain, p->ntlmssp_resp.hdr_domain.str_str_len/2)); - fstrcpy(p->wks , unistrn2((uint16*)p->ntlmssp_resp.wks , p->ntlmssp_resp.hdr_wks .str_str_len/2)); + fstrcpy(p->user_name, unistrn2(p->ntlmssp_resp.user , p->ntlmssp_resp.hdr_usr .str_str_len/2)); + fstrcpy(p->domain , unistrn2(p->ntlmssp_resp.domain, p->ntlmssp_resp.hdr_domain.str_str_len/2)); + fstrcpy(p->wks , unistrn2(p->ntlmssp_resp.wks , p->ntlmssp_resp.hdr_wks .str_str_len/2)); } else { -- cgit From fd96929ec1fa27e0affd4c4e9ba307c4ee30b978 Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Fri, 12 Feb 1999 00:16:09 +0000 Subject: UNICODE cleanup (see lib/util_unistr.c). No more ugly static library buffers and all functions take a destination string length (especially unistrcpy was rather dangerous; we were only saved by the fact that datagrams are limited in size). (This used to be commit a1d39af1ce1d451b811dbd7c2ba391214851b87e) --- source3/rpc_server/srv_lsa.c | 4 ++-- source3/rpc_server/srv_netlog.c | 14 ++++++-------- source3/rpc_server/srv_pipe.c | 12 +++++++++--- source3/rpc_server/srv_reg.c | 2 +- source3/rpc_server/srv_samr.c | 12 ++++++------ source3/rpc_server/srv_svcctl.c | 4 ++-- 6 files changed, 26 insertions(+), 22 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 4db97f6d4c..fbbeb4233e 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -156,7 +156,7 @@ static int make_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) for (num = 0; num < ref->num_ref_doms_1; num++) { fstring domname; - fstrcpy(domname, unistr2_to_str(&ref->ref_dom[num].uni_dom_name)); + unistr2_to_ascii(domname, &ref->ref_dom[num].uni_dom_name, sizeof(domname)); if (strequal(domname, dom_name)) { return num; @@ -217,7 +217,7 @@ static void make_lsa_rid2s(DOM_R_REF *ref, char *dom_name = NULL; uint8 sid_name_use = SID_NAME_UNKNOWN; - fstrcpy(find_name, unistr2_to_str(&name[i])); + unistr2_to_ascii(find_name, &name[i], sizeof(find_name)); dom_name = strdup(find_name); if (map_domain_name_to_sid(&sid, &dom_name)) diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 33eb889ff2..f34aa502ed 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -288,7 +288,7 @@ static void api_net_req_chal( uint16 vuid, /* grab the challenge... */ net_io_q_req_chal("", &q_r, data, 0); - fstrcpy(mach_acct, unistr2_to_str(&q_r.uni_logon_clnt)); + unistr2_to_ascii(mach_acct, &q_r.uni_logon_clnt, sizeof(mach_acct)); fstrcpy(mach_name, mach_acct); strlower(mach_name); @@ -399,7 +399,8 @@ static void api_net_srv_pwset( uint16 vuid, DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); - fstrcpy(mach_acct, unistr2_to_str(&q_a.clnt_id.login.uni_acct_name)); + unistr2_to_ascii(mach_acct, &q_a.clnt_id.login.uni_acct_name, + sizeof(mach_acct)); DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); @@ -672,12 +673,9 @@ static void api_net_sam_logon( uint16 vuid, if (status == 0) { - fstrcpy(nt_username, unistr2_to_str(uni_samlogon_user)); -#if 0 - slprintf(nt_username, sizeof(nt_username), "%s\\%s", - unistr2_to_str(uni_domain), - unistr2_to_str(uni_samlogon_user)); -#endif + unistr2_to_ascii(nt_username, uni_samlogon_user, + sizeof(nt_username)); + DEBUG(3,("User:[%s]\n", nt_username)); become_root(True); diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 5908fe06b5..07e16c7e5d 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -225,9 +225,15 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) if (IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_UNICODE)) { - fstrcpy(p->user_name, unistrn2(p->ntlmssp_resp.user , p->ntlmssp_resp.hdr_usr .str_str_len/2)); - fstrcpy(p->domain , unistrn2(p->ntlmssp_resp.domain, p->ntlmssp_resp.hdr_domain.str_str_len/2)); - fstrcpy(p->wks , unistrn2(p->ntlmssp_resp.wks , p->ntlmssp_resp.hdr_wks .str_str_len/2)); + unibuf_to_ascii(p->user_name, p->ntlmssp_resp.user, + MIN(p->ntlmssp_resp.hdr_usr .str_str_len/2, + sizeof(p->user_name))); + unibuf_to_ascii(p->domain , p->ntlmssp_resp.domain, + MIN(p->ntlmssp_resp.hdr_domain.str_str_len/2, + sizeof(p->domain ))); + unibuf_to_ascii(p->wks , p->ntlmssp_resp.wks, + MIN(p->ntlmssp_resp.hdr_wks .str_str_len/2, + sizeof(p->wks ))); } else { diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index f98133626d..52fff8716c 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -136,7 +136,7 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } - fstrcpy(name, unistr2_to_str(&q_u->uni_name)); + unistr2_to_ascii(name, &q_u->uni_name, sizeof(name)); if (status == 0x0) { diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index ec3fa289a7..7f2b62212e 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1440,7 +1440,7 @@ static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, { DOM_SID sid; fstring name; - fstrcpy(name, unistr2_to_str(&q_u->uni_name[i])); + unistr2_to_ascii(name, &q_u->uni_name[i], sizeof(name)); status = lookup_name(name, &sid, &(type[i])); if (status == 0x0) @@ -1489,8 +1489,8 @@ static void samr_reply_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u, fstring user_name; fstring wks; - fstrcpy(user_name, unistr2_to_str(&q_u->uni_user_name)); - fstrcpy(wks , unistr2_to_str(&q_u->uni_dest_host)); + unistr2_to_ascii(user_name, &q_u->uni_user_name, sizeof(user_name)); + unistr2_to_ascii(wks, &q_u->uni_dest_host, sizeof(wks)); DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); @@ -2024,7 +2024,7 @@ static void samr_reply_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS *q_u, if (status == 0x0) { - fstrcpy(grp.name, unistr2_to_str(&q_u->uni_acct_desc)); + unistr2_to_ascii(grp.name, &q_u->uni_acct_desc, sizeof(grp.name)); fstrcpy(grp.comment, ""); grp.rid = 0xffffffff; @@ -2135,7 +2135,7 @@ static void samr_reply_create_dom_group(SAMR_Q_CREATE_DOM_GROUP *q_u, if (status == 0x0) { - fstrcpy(grp.name, unistr2_to_str(&q_u->uni_acct_desc)); + unistr2_to_ascii(grp.name, &q_u->uni_acct_desc, sizeof(grp.name)); fstrcpy(grp.comment, ""); grp.rid = 0xffffffff; grp.attr = 0x07; @@ -2302,7 +2302,7 @@ static void api_samr_unknown_32( uint16 vuid, prs_struct *data, prs_struct *rdat reply if the account already exists... */ - fstrcpy(mach_acct, unistr2_to_str(&q_u.uni_mach_acct)); + unistr2_to_ascii(mach_acct, &q_u.uni_mach_acct, sizeof(mach_acct)); become_root(True); sam_pass = getsam21pwntnam(mach_acct); diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 6a39b246d0..cf6ab5a0e1 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -93,7 +93,7 @@ static void svc_reply_open_service(SVC_Q_OPEN_SERVICE *q_u, status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } - fstrcpy(name, unistr2_to_str(&q_u->uni_svc_name)); + unistr2_to_ascii(name, &q_u->uni_svc_name, sizeof(name)); if (status == 0x0) { @@ -143,7 +143,7 @@ static void svc_reply_open_sc_man(SVC_Q_OPEN_SC_MAN *q_u, status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } - fstrcpy(name, unistr2_to_str(&q_u->uni_srv_name)); + unistr2_to_ascii(name, &q_u->uni_srv_name, sizeof(name)); if (status == 0x0) { -- cgit From 2737f26ad64ee32d6ef7365dcce0a3eb881f99db Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Mon, 15 Feb 1999 05:33:30 +0000 Subject: Always null-terminate strings. Also some string length and sizeof(pointer) corrections. (This used to be commit ce24191939b82985d09eabe945199f38b0fea486) --- source3/rpc_server/srv_lsa.c | 4 ++-- source3/rpc_server/srv_netlog.c | 6 +++--- source3/rpc_server/srv_pipe.c | 6 +++--- source3/rpc_server/srv_reg.c | 2 +- source3/rpc_server/srv_samr.c | 12 ++++++------ source3/rpc_server/srv_svcctl.c | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index fbbeb4233e..45ddefe592 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -156,7 +156,7 @@ static int make_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) for (num = 0; num < ref->num_ref_doms_1; num++) { fstring domname; - unistr2_to_ascii(domname, &ref->ref_dom[num].uni_dom_name, sizeof(domname)); + unistr2_to_ascii(domname, &ref->ref_dom[num].uni_dom_name, sizeof(domname)-1); if (strequal(domname, dom_name)) { return num; @@ -217,7 +217,7 @@ static void make_lsa_rid2s(DOM_R_REF *ref, char *dom_name = NULL; uint8 sid_name_use = SID_NAME_UNKNOWN; - unistr2_to_ascii(find_name, &name[i], sizeof(find_name)); + unistr2_to_ascii(find_name, &name[i], sizeof(find_name)-1); dom_name = strdup(find_name); if (map_domain_name_to_sid(&sid, &dom_name)) diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index f34aa502ed..30c132aa06 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -288,7 +288,7 @@ static void api_net_req_chal( uint16 vuid, /* grab the challenge... */ net_io_q_req_chal("", &q_r, data, 0); - unistr2_to_ascii(mach_acct, &q_r.uni_logon_clnt, sizeof(mach_acct)); + unistr2_to_ascii(mach_acct, &q_r.uni_logon_clnt, sizeof(mach_acct)-1); fstrcpy(mach_name, mach_acct); strlower(mach_name); @@ -400,7 +400,7 @@ static void api_net_srv_pwset( uint16 vuid, DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); unistr2_to_ascii(mach_acct, &q_a.clnt_id.login.uni_acct_name, - sizeof(mach_acct)); + sizeof(mach_acct)-1); DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); @@ -674,7 +674,7 @@ static void api_net_sam_logon( uint16 vuid, if (status == 0) { unistr2_to_ascii(nt_username, uni_samlogon_user, - sizeof(nt_username)); + sizeof(nt_username)-1); DEBUG(3,("User:[%s]\n", nt_username)); diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 07e16c7e5d..e619797f6e 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -227,13 +227,13 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) { unibuf_to_ascii(p->user_name, p->ntlmssp_resp.user, MIN(p->ntlmssp_resp.hdr_usr .str_str_len/2, - sizeof(p->user_name))); + sizeof(p->user_name)-1)); unibuf_to_ascii(p->domain , p->ntlmssp_resp.domain, MIN(p->ntlmssp_resp.hdr_domain.str_str_len/2, - sizeof(p->domain ))); + sizeof(p->domain )-1)); unibuf_to_ascii(p->wks , p->ntlmssp_resp.wks, MIN(p->ntlmssp_resp.hdr_wks .str_str_len/2, - sizeof(p->wks ))); + sizeof(p->wks )-1)); } else { diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 52fff8716c..47ead00227 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -136,7 +136,7 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } - unistr2_to_ascii(name, &q_u->uni_name, sizeof(name)); + unistr2_to_ascii(name, &q_u->uni_name, sizeof(name)-1); if (status == 0x0) { diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 7f2b62212e..449a47e4c9 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1440,7 +1440,7 @@ static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, { DOM_SID sid; fstring name; - unistr2_to_ascii(name, &q_u->uni_name[i], sizeof(name)); + unistr2_to_ascii(name, &q_u->uni_name[i], sizeof(name)-1); status = lookup_name(name, &sid, &(type[i])); if (status == 0x0) @@ -1489,8 +1489,8 @@ static void samr_reply_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u, fstring user_name; fstring wks; - unistr2_to_ascii(user_name, &q_u->uni_user_name, sizeof(user_name)); - unistr2_to_ascii(wks, &q_u->uni_dest_host, sizeof(wks)); + unistr2_to_ascii(user_name, &q_u->uni_user_name, sizeof(user_name)-1); + unistr2_to_ascii(wks, &q_u->uni_dest_host, sizeof(wks)-1); DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); @@ -2024,7 +2024,7 @@ static void samr_reply_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS *q_u, if (status == 0x0) { - unistr2_to_ascii(grp.name, &q_u->uni_acct_desc, sizeof(grp.name)); + unistr2_to_ascii(grp.name, &q_u->uni_acct_desc, sizeof(grp.name)-1); fstrcpy(grp.comment, ""); grp.rid = 0xffffffff; @@ -2135,7 +2135,7 @@ static void samr_reply_create_dom_group(SAMR_Q_CREATE_DOM_GROUP *q_u, if (status == 0x0) { - unistr2_to_ascii(grp.name, &q_u->uni_acct_desc, sizeof(grp.name)); + unistr2_to_ascii(grp.name, &q_u->uni_acct_desc, sizeof(grp.name)-1); fstrcpy(grp.comment, ""); grp.rid = 0xffffffff; grp.attr = 0x07; @@ -2302,7 +2302,7 @@ static void api_samr_unknown_32( uint16 vuid, prs_struct *data, prs_struct *rdat reply if the account already exists... */ - unistr2_to_ascii(mach_acct, &q_u.uni_mach_acct, sizeof(mach_acct)); + unistr2_to_ascii(mach_acct, &q_u.uni_mach_acct, sizeof(mach_acct)-1); become_root(True); sam_pass = getsam21pwntnam(mach_acct); diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index cf6ab5a0e1..56a0749776 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -93,7 +93,7 @@ static void svc_reply_open_service(SVC_Q_OPEN_SERVICE *q_u, status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } - unistr2_to_ascii(name, &q_u->uni_svc_name, sizeof(name)); + unistr2_to_ascii(name, &q_u->uni_svc_name, sizeof(name)-1); if (status == 0x0) { @@ -143,7 +143,7 @@ static void svc_reply_open_sc_man(SVC_Q_OPEN_SC_MAN *q_u, status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } - unistr2_to_ascii(name, &q_u->uni_srv_name, sizeof(name)); + unistr2_to_ascii(name, &q_u->uni_srv_name, sizeof(name)-1); if (status == 0x0) { -- cgit From 05f772b431f9c77a2fb37736fc4f801d84cac365 Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Wed, 24 Feb 1999 01:52:30 +0000 Subject: Win9x user level security. * Added SAMR_LOOKUP_DOMAIN (-> SamrLookupDomainInSamServer) * Added real SAMR_ENUM_DOM_GROUPS (corresponding to SamrEnumerateGroupsInDomain). The existing one is just an alias for SamrQueryDisplayInformation (see below). * Added three extra info levels to SAMR_QUERY_DISPINFO. Info level 3 is what was previously SAMR_ENUM_DOM_GROUPS; info levels 4 and 5 are simple user/group list requests used by Win9x and I suspect (haven't checked) the "low speed connection" User Manager. * Added another two aliases for SAMR_QUERY_DISPINFO, opcodes 0x30 and 0x33. Usually the first is with info level 3 and the second 4 but there is some overlap so indeed these should be implemented as just aliases. * Return ERRDOS/ERRmoredata on extra data instead of STATUS_BUFFER_OVERFLOW for Win95's benefit. On a named pipe this results in an SMBreadX as usual. Still need to fix SAMR_QUERY_DOMAIN_INFO which has a hard-coded number of users and groups - which Win95 proceeds to truncate at. (This used to be commit 7d03e6e21908f3a759a4e65c5edd850622335e3e) --- source3/rpc_server/srv_samr.c | 223 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 182 insertions(+), 41 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 449a47e4c9..4f190270dd 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -618,7 +618,7 @@ static void api_samr_del_aliasmem( uint16 vuid, prs_struct *data, prs_struct *rd } /******************************************************************* - samr_reply_add_groupmem + samr_reply_enum_dom_groups ********************************************************************/ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, prs_struct *rdata) @@ -626,7 +626,6 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_R_ENUM_DOM_GROUPS r_e; DOMAIN_GRP *grps = NULL; int num_entries = 0; - BOOL got_grps = False; DOM_SID sid; fstring sid_str; @@ -646,21 +645,19 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, if (sid_equal(&sid, &global_sam_sid)) { BOOL ret; - got_grps = True; become_root(True); ret = enumdomgroups(&grps, &num_entries); unbecome_root(True); - if (!ret) { r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; } } - if (r_e.status == 0 && got_grps) + if (r_e.status == 0x0) { - make_samr_r_enum_dom_groups(&r_e, q_u->start_idx, num_entries, grps, r_e.status); + make_samr_r_enum_dom_groups(&r_e, num_entries, grps, r_e.status); } /* store the response in the SMB stream */ @@ -675,12 +672,16 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, } /******************************************************************* - api_samr_enum_dom_groups + api_samr_enum_dom_aliases ********************************************************************/ static void api_samr_enum_dom_groups( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_GROUPS q_e; + + /* grab the samr open */ samr_io_q_enum_dom_groups("", &q_e, data, 0); + + /* construct reply. */ samr_reply_enum_dom_groups(&q_e, rdata); } @@ -777,72 +778,154 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, prs_struct *rdata) { SAMR_R_QUERY_DISPINFO r_e; - SAM_INFO_CTR ctr; - SAM_INFO_1 info1; - SAM_INFO_2 info2; + SAM_DISPINFO_CTR ctr; SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; + DOMAIN_GRP *grps = NULL; + DOMAIN_GRP *sam_grps = NULL; + uint32 data_size = 0; + uint32 status = 0x0; + uint16 acb_mask = ACB_NORMAL; + int num_sam_entries = 0; int num_entries = 0; - int total_entries = 0; - BOOL got_pwds; - uint16 switch_level = 0x0; - - ZERO_STRUCT(r_e); - - r_e.status = 0x0; + int total_entries; DEBUG(5,("samr_reply_query_dispinfo: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + if (find_lsa_policy_by_hnd(&(q_u->domain_pol)) == -1) { - r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; DEBUG(5,("samr_reply_query_dispinfo: invalid handle\n")); } - if (r_e.status == 0x0) + if (status == 0x0) { become_root(True); - got_pwds = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); - unbecome_root(True); + /* Get what we need from the password database */ switch (q_u->switch_level) { + case 0x2: + { + acb_mask = ACB_WSTRUST; + /* Fall through */ + } case 0x1: + case 0x4: + { + get_sampwd_entries(pass, q_u->start_idx, + &total_entries, &num_sam_entries, + MAX_SAM_ENTRIES, acb_mask); + break; + } + case 0x3: + case 0x5: { - - /* query disp info is for users */ - switch_level = 0x1; - make_sam_info_1(&info1, ACB_NORMAL, - q_u->start_idx, num_entries, pass); + enumdomgroups(&sam_grps, &num_sam_entries); + + if (q_u->start_idx < num_sam_entries) { + grps = sam_grps + q_u->start_idx; + num_sam_entries -= q_u->start_idx; + } else { + num_sam_entries = 0; + } + break; + } + } + + unbecome_root(True); + + num_entries = num_sam_entries; + + if (num_entries > q_u->max_entries) + { + num_entries = q_u->max_entries; + } + + if (num_entries > MAX_SAM_ENTRIES) + { + num_entries = MAX_SAM_ENTRIES; + DEBUG(5,("limiting number of entries to %d\n", + num_entries)); + } - ctr.sam.info1 = &info1; + data_size = q_u->max_size; + /* Now create reply structure */ + switch (q_u->switch_level) + { + case 0x1: + { + ctr.sam.info1 = malloc(sizeof(SAM_DISPINFO_1)); + make_sam_dispinfo_1(ctr.sam.info1, + &num_entries, &data_size, + q_u->start_idx, pass); break; } case 0x2: { - /* query disp info is for servers */ - switch_level = 0x2; - make_sam_info_2(&info2, ACB_WSTRUST, - q_u->start_idx, num_entries, pass); - - ctr.sam.info2 = &info2; - + ctr.sam.info2 = malloc(sizeof(SAM_DISPINFO_2)); + make_sam_dispinfo_2(ctr.sam.info2, + &num_entries, &data_size, + q_u->start_idx, pass); + break; + } + case 0x3: + { + ctr.sam.info3 = malloc(sizeof(SAM_DISPINFO_3)); + make_sam_dispinfo_3(ctr.sam.info3, + &num_entries, &data_size, + q_u->start_idx, grps); + break; + } + case 0x4: + { + ctr.sam.info4 = malloc(sizeof(SAM_DISPINFO_4)); + make_sam_dispinfo_4(ctr.sam.info4, + &num_entries, &data_size, + q_u->start_idx, pass); + break; + } + case 0x5: + { + ctr.sam.info5 = malloc(sizeof(SAM_DISPINFO_5)); + make_sam_dispinfo_5(ctr.sam.info5, + &num_entries, &data_size, + q_u->start_idx, grps); + break; + } + default: + { + ctr.sam.info = NULL; + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; break; } } } - if (r_e.status == 0 && got_pwds) + if ((status == 0) && (num_entries < num_sam_entries)) { - make_samr_r_query_dispinfo(&r_e, switch_level, &ctr, r_e.status); + status = 0x105; /* STATUS_MORE_ENTRIES */ } + make_samr_r_query_dispinfo(&r_e, num_entries, data_size, + q_u->switch_level, &ctr, status); + /* store the response in the SMB stream */ samr_io_r_query_dispinfo("", &r_e, rdata, 0); - DEBUG(5,("samr_query_dispinfo: %d\n", __LINE__)); + /* free malloc'd areas */ + if (sam_grps != NULL) + { + free(sam_grps); + } + if (ctr.sam.info != NULL) + { + free(ctr.sam.info); + } + + DEBUG(5,("samr_reply_query_dispinfo: %d\n", __LINE__)); } /******************************************************************* @@ -852,10 +935,7 @@ static void api_samr_query_dispinfo( uint16 vuid, prs_struct *data, prs_struct * { SAMR_Q_QUERY_DISPINFO q_e; - /* grab the samr open */ samr_io_q_query_dispinfo("", &q_e, data, 0); - - /* construct reply. */ samr_reply_query_dispinfo(&q_e, rdata); } @@ -2537,6 +2617,64 @@ static void api_samr_open_group( uint16 vuid, prs_struct *data, prs_struct *rdat samr_reply_open_group(&q_u, rdata); } +/******************************************************************* + samr_reply_lookup_domain + ********************************************************************/ +static void samr_reply_lookup_domain(SAMR_Q_LOOKUP_DOMAIN *q_u, + prs_struct *rdata) +{ + SAMR_R_LOOKUP_DOMAIN r_u; + fstring domain; + + DEBUG(5,("samr_lookup_domain: %d\n", __LINE__)); + + r_u.ptr_sid = 0; + r_u.status = 0x0; + + /* find the connection policy handle */ + if (find_lsa_policy_by_hnd(&(q_u->connect_pol)) == -1) + { + r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + if (r_u.status == 0x0) + { + unistr2_to_ascii(domain, &(q_u->uni_domain), sizeof(domain)); + DEBUG(5, ("Lookup Domain: %s\n", domain)); + + /* check it's one of ours */ + if (strequal(domain, global_sam_name)) + { + make_dom_sid2(&(r_u.dom_sid), &global_sam_sid); + r_u.ptr_sid = 1; + } + else if (strequal(domain, "BUILTIN")) + { + make_dom_sid2(&(r_u.dom_sid), &global_sid_S_1_5_20); + r_u.ptr_sid = 1; + } + else + { + r_u.status = 0xC0000000 | NT_STATUS_NO_SUCH_DOMAIN; + } + } + + /* store the response in the SMB stream */ + samr_io_r_lookup_domain("", &r_u, rdata, 0); + + DEBUG(5,("samr_lookup_domain: %d\n", __LINE__)); +} + +/******************************************************************* + api_samr_lookup_domain + ********************************************************************/ +static void api_samr_lookup_domain( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_LOOKUP_DOMAIN q_u; + samr_io_q_lookup_domain("", &q_u, data, 0); + samr_reply_lookup_domain(&q_u, rdata); +} + /******************************************************************* array of \PIPE\samr operations ********************************************************************/ @@ -2565,6 +2703,8 @@ static struct api_struct api_samr_cmds [] = { "SAMR_QUERY_DOMAIN_INFO", SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, { "SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, { "SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, + { "SAMR_QUERY_DISPINFO3" , SAMR_QUERY_DISPINFO3 , api_samr_query_dispinfo }, + { "SAMR_QUERY_DISPINFO4" , SAMR_QUERY_DISPINFO4 , api_samr_query_dispinfo }, { "SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, { "SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, { "SAMR_0x32" , SAMR_UNKNOWN_32 , api_samr_unknown_32 }, @@ -2574,6 +2714,7 @@ static struct api_struct api_samr_cmds [] = { "SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, { "SAMR_OPEN_GROUP" , SAMR_OPEN_GROUP , api_samr_open_group }, { "SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, + { "SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, { "SAMR_UNKNOWN_3" , SAMR_UNKNOWN_3 , api_samr_unknown_3 }, { "SAMR_UNKNOWN_2C" , SAMR_UNKNOWN_2C , api_samr_unknown_2c }, { NULL , 0 , NULL } -- cgit From 2aadefe8ccb84414988e8c195619c97216c19ae2 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 10 Mar 1999 17:06:07 +0000 Subject: Greg Dickie: spotted bug where smb_nt_passwd could be NULL. (This used to be commit d8946f1cc7b77b06f346344ffdb4772e6d225396) --- source3/rpc_server/srv_netlog.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 30c132aa06..1bb86e183f 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -528,8 +528,15 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, dump_data(100, nt_pwd, 16); #endif + if (smb_pass->smb_nt_passwd == NULL) + { + DEBUG(5,("warning: NETLOGON user %s only has an LM password\n", + smb_pass->unix_name)); + } + if (memcmp(smb_pass->smb_passwd , lm_pwd, 16) != 0 && - memcmp(smb_pass->smb_nt_passwd, nt_pwd, 16) != 0) + (smb_pass->smb_nt_passwd == NULL || + memcmp(smb_pass->smb_nt_passwd, nt_pwd, 16) != 0)) { status = 0xC0000000 | NT_STATUS_WRONG_PASSWORD; } -- cgit From 0aaf5a368c1b654a7560b19095481199a426530e Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 12 Mar 1999 05:46:10 +0000 Subject: check for exactly _one_ key: for USRMGR.EXE. (This used to be commit 478d9ddfcf59e3d847d83947c8d4f0bf84f26833) --- source3/rpc_server/srv_reg.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 47ead00227..d9aedc86bd 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -142,6 +142,10 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, { DEBUG(5,("reg_open_entry: %s\n", name)); /* lkcl XXXX do a check on the name, here */ + if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions")) + { + status = 0xC000000 | NT_STATUS_ACCESS_DENIED; + } } if (status == 0x0 && !set_lsa_policy_reg_name(&pol, name)) -- cgit From 517aade8bd6759124ef7c2d9bc0f7059327de36c Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Tue, 16 Mar 1999 06:24:24 +0000 Subject: Added SVC_QUERY_DISP_NAME (corresponding to the GetServiceDisplayName API). Needed during preliminary part of SAM replication. (This used to be commit 03e722cdf502491d09d4c5eb9024d837ae10ab32) --- source3/rpc_server/srv_svcctl.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 56a0749776..d52816df80 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -290,6 +290,44 @@ static void api_svc_enum_svcs_status( uint16 vuid, prs_struct *data, svc_reply_enum_svcs_status(&q_u, rdata); } +/******************************************************************* + svc_reply_query_disp_name + ********************************************************************/ +static void svc_reply_query_disp_name(SVC_Q_QUERY_DISP_NAME *q_u, + prs_struct *rdata) +{ + SVC_R_QUERY_DISP_NAME r_u; + fstring svc_name; + uint32 status = 0; + + DEBUG(5,("svc_query_disp_name: %d\n", __LINE__)); + + if (find_lsa_policy_by_hnd(&q_u->scman_pol) == -1) + { + status = 0xC000000 | NT_STATUS_INVALID_HANDLE; + } + + /* for now display name = service name */ + unistr2_to_ascii(svc_name, &q_u->uni_svc_name, sizeof(svc_name)-1); + make_svc_r_query_disp_name(&r_u, svc_name, status); + + /* store the response in the SMB stream */ + svc_io_r_query_disp_name("", &r_u, rdata, 0); + + DEBUG(5,("svc_query_disp_name: %d\n", __LINE__)); +} + +/******************************************************************* + api_svc_query_disp_name + ********************************************************************/ +static void api_svc_query_disp_name( uint16 vuid, prs_struct *data, + prs_struct *rdata ) +{ + SVC_Q_QUERY_DISP_NAME q_u; + svc_io_q_query_disp_name("", &q_u, data, 0); + svc_reply_query_disp_name(&q_u, rdata); +} + /******************************************************************* array of \PIPE\svcctl operations ********************************************************************/ @@ -299,6 +337,7 @@ static struct api_struct api_svc_cmds[] = { "SVC_OPEN_SC_MAN" , SVC_OPEN_SC_MAN , api_svc_open_sc_man }, { "SVC_OPEN_SERVICE" , SVC_OPEN_SERVICE , api_svc_open_service }, { "SVC_ENUM_SVCS_STATUS", SVC_ENUM_SVCS_STATUS, api_svc_enum_svcs_status }, + { "SVC_QUERY_DISP_NAME" , SVC_QUERY_DISP_NAME , api_svc_query_disp_name }, { NULL , 0 , NULL } }; -- cgit From 7f02de406d4a59fdaaa646ca6e28fdcb3e40a13d Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 17 Mar 1999 19:49:14 +0000 Subject: Stefan Walters: purify spotted rverf should be alloc'd to 16 bytes not 8. (This used to be commit 4bb74fcc714fccac791ce86c8882d19d704b17a1) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index e619797f6e..ec5b547c86 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -102,7 +102,7 @@ BOOL create_rpc_reply(pipes_struct *p, prs_init(&p->rhdr , 0x18, 4, 0, False); prs_init(&p->rauth, 1024, 4, 0, False); - prs_init(&p->rverf, 0x08, 4, 0, False); + prs_init(&p->rverf, 0x10, 4, 0, False); p->hdr.pkt_type = RPC_RESPONSE; /* mark header as an rpc response */ -- cgit From f7eaf17216c91c66719b2393c7a8716fc55e4e5f Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Thu, 18 Mar 1999 09:36:43 +0000 Subject: Added SVC_START_SERVICE rpc. An NT PDC will attempt to start the NETLOGON service on its BDC's prior to initiating SAM replication. For now just return success. (This used to be commit 113d03a38a34e5c4115dab59349078093bcd4888) --- source3/rpc_server/srv_svcctl.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index d52816df80..6a420c1493 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -125,6 +125,42 @@ static void api_svc_open_service( uint16 vuid, prs_struct *data, svc_reply_open_service(&q_u, rdata); } +/******************************************************************* + svc_reply_start_service + ********************************************************************/ +static void svc_reply_start_service(SVC_Q_START_SERVICE *q_s, + prs_struct *rdata) +{ + SVC_R_START_SERVICE r_s; + + DEBUG(5,("svc_start_service: %d\n", __LINE__)); + + r_s.status = 0x0; + + if (find_lsa_policy_by_hnd(&q_s->pol) == -1) + { + r_s.status = 0xC000000 | NT_STATUS_INVALID_HANDLE; + } + + /* start the service here */ + + /* store the response in the SMB stream */ + svc_io_r_start_service("", &r_s, rdata, 0); + + DEBUG(5,("svc_start_service: %d\n", __LINE__)); +} + +/******************************************************************* + api_svc_start_service + ********************************************************************/ +static void api_svc_start_service( uint16 vuid, prs_struct *data, + prs_struct *rdata ) +{ + SVC_Q_START_SERVICE q_u; + svc_io_q_start_service("", &q_u, data, 0); + svc_reply_start_service(&q_u, rdata); +} + /******************************************************************* svc_reply_open_sc_man ********************************************************************/ @@ -338,6 +374,7 @@ static struct api_struct api_svc_cmds[] = { "SVC_OPEN_SERVICE" , SVC_OPEN_SERVICE , api_svc_open_service }, { "SVC_ENUM_SVCS_STATUS", SVC_ENUM_SVCS_STATUS, api_svc_enum_svcs_status }, { "SVC_QUERY_DISP_NAME" , SVC_QUERY_DISP_NAME , api_svc_query_disp_name }, + { "SVC_START_SERVICE" , SVC_START_SERVICE , api_svc_start_service }, { NULL , 0 , NULL } }; -- cgit From a4bc522a7292f3bb87740e87df8449ba0ea6be10 Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Sun, 21 Mar 1999 13:01:31 +0000 Subject: The line: this_pdu_data_pos = data_pos - p->prev_pdu_file_offset; is correct for first two PDU's only, after that it results in extra garbage after each fragment and hence "Protocol Error" messages from NT4 SP4. Changed to: this_pdu_data_pos = (pdu_data_sent == 0) ? 0 : (pdu_data_sent - 0x18); (This used to be commit b9e8a3ef3a25a81c4bb125bdd4f4d8334a578c85) --- source3/rpc_server/srv_pipe_hnd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 27aa79381c..531fcf6add 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -230,8 +230,8 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) /* the read request starts from where the SMBtrans2 left off. */ data_pos = p->file_offset - p->hdr_offsets; - this_pdu_data_pos = data_pos - p->prev_pdu_file_offset; pdu_data_sent = p->file_offset - p->prev_pdu_file_offset; + this_pdu_data_pos = (pdu_data_sent == 0) ? 0 : (pdu_data_sent - 0x18); if (!IS_BITS_SET_ALL(p->hdr.flags, RPC_FLG_LAST)) { @@ -255,7 +255,7 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) } pdu_len = mem_buf_len(p->rhdr.data); - num = pdu_len - (int)this_pdu_data_pos; + num = pdu_len - this_pdu_data_pos; DEBUG(6,("read_pipe: pdu_len: %d num: %d n: %d\n", pdu_len, num, n)); -- cgit From 6b9cb3a2545226257d698406c1ab3b016464705e Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 23 Mar 1999 20:43:44 +0000 Subject: dynamic memory allocation in samr enum dom users. works with 849 entries now. (This used to be commit 103557e26b071bf1e65e025ef5a52ccdbf483d02) --- source3/rpc_server/srv_samr.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 4f190270dd..0371fbc88c 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -354,6 +354,16 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, /* store the response in the SMB stream */ samr_io_r_enum_dom_users("", &r_e, rdata, 0); + if (r_e.sam != NULL) + { + free(r_e.sam); + } + + if (r_e.uni_acct_name != NULL) + { + free(r_e.uni_acct_name); + } + DEBUG(5,("samr_enum_dom_users: %d\n", __LINE__)); } -- cgit From 22ab15823fde3926f4fea5538632a2215d30d435 Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Wed, 24 Mar 1999 12:18:28 +0000 Subject: Fixed LSA Lookup Names. There were a few too many NULL pointers in a negative response, which tended to crash lsass.exe. (This used to be commit 6d03f61d2536630968007958345cf44a42b03584) --- source3/rpc_server/srv_lsa.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 45ddefe592..75512036b6 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -175,7 +175,6 @@ static int make_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) return -1; } - ref->undoc_buffer = 1; ref->num_ref_doms_1 = num+1; ref->ptr_ref_dom = 1; ref->max_entries = MAX_REF_DOMAINS; @@ -268,13 +267,27 @@ static void make_lsa_rid2s(DOM_R_REF *ref, make_reply_lookup_names ***************************************************************************/ static void make_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, - DOM_R_REF *ref, DOM_RID2 *rid2, - uint32 mapped_count, uint32 status) + DOM_R_REF *ref, uint32 num_entries, + DOM_RID2 *rid2, uint32 mapped_count) { + r_l->ptr_dom_ref = 1; r_l->dom_ref = ref; + + r_l->num_entries = num_entries; + r_l->ptr_entries = 1; + r_l->num_entries2 = num_entries; r_l->dom_rid = rid2; + r_l->mapped_count = mapped_count; - r_l->status = status; + + if (mapped_count == 0) + { + r_l->status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + } + else + { + r_l->status = 0x0; + } } /*************************************************************************** @@ -356,12 +369,21 @@ make_reply_lookup_sids ***************************************************************************/ static void make_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *names, - uint32 mapped_count, uint32 status) + uint32 mapped_count) { + r_l->ptr_dom_ref = 1; r_l->dom_ref = ref; r_l->names = names; r_l->mapped_count = mapped_count; - r_l->status = status; + + if (mapped_count == 0) + { + r_l->status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + } + else + { + r_l->status = 0x0; + } } /*************************************************************************** @@ -381,7 +403,7 @@ static void lsa_reply_lookup_sids(prs_struct *rdata, /* set up the LSA Lookup SIDs response */ make_lsa_trans_names(&ref, &names, num_entries, sid, &mapped_count); - make_reply_lookup_sids(&r_l, &ref, &names, mapped_count, 0x0); + make_reply_lookup_sids(&r_l, &ref, &names, mapped_count); /* store the response in the SMB stream */ lsa_io_r_lookup_sids("", &r_l, rdata, 0); @@ -404,11 +426,7 @@ static void lsa_reply_lookup_names(prs_struct *rdata, /* set up the LSA Lookup RIDs response */ make_lsa_rid2s(&ref, rids, num_entries, names, &mapped_count); - make_reply_lookup_names(&r_l, &ref, rids, mapped_count, 0x0); - - r_l.num_entries = num_entries; - r_l.undoc_buffer = 1; - r_l.num_entries2 = num_entries; + make_reply_lookup_names(&r_l, &ref, num_entries, rids, mapped_count); /* store the response in the SMB stream */ lsa_io_r_lookup_names("", &r_l, rdata, 0); @@ -541,7 +559,6 @@ static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, SMB_ASSERT_ARRAY(q_l.uni_name, q_l.num_entries); - /* construct reply. return status is always 0x0 */ lsa_reply_lookup_names(rdata, q_l.uni_name, q_l.num_entries); } -- cgit From cd7c530f569045a47b51f357759f4cf5089992a0 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 24 Mar 1999 17:26:08 +0000 Subject: removed 2 unnecessary args from make_uni_hdr. (This used to be commit f84dede27e16a5f02ee6d02fe2d16f2661c65470) --- source3/rpc_server/srv_lsa.c | 2 +- source3/rpc_server/srv_samr.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 75512036b6..61aac58e62 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -182,7 +182,7 @@ static int make_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) len = dom_name != NULL ? strlen(dom_name) : 0; - make_uni_hdr(&(ref->hdr_ref_dom[num].hdr_dom_name), len, len, len != 0 ? 1 : 0); + make_uni_hdr(&(ref->hdr_ref_dom[num].hdr_dom_name), len); ref->hdr_ref_dom[num].ptr_dom_sid = dom_sid != NULL ? 1 : 0; make_unistr2 (&(ref->ref_dom[num].uni_dom_name), dom_name, len); diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 0371fbc88c..2dd7801e81 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -78,8 +78,7 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, user_name_len = strlen(pwd->nt_name); make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->nt_name, user_name_len); - make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len, - user_name_len, 1); + make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len); pw_buf[(*num_entries)].user_rid = pwd->user_rid; bzero( pw_buf[(*num_entries)].nt_pwd , 16); -- cgit From 43a460075a39148060d4193fcb9c62bfa4acc737 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 25 Mar 1999 13:54:31 +0000 Subject: SAM database "set user info". ---------------------------- - removed DOM_RID4 - removed SAMR_UNKNOWN_32 - added SAMR_SET_USERINFO (opcode 0x32) - added level 0x1 to SAMR_QUERY_DOM_INFO (needed for create user) - fixed pwdb_gethexpwd() it was failing on XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - added mod_sam21pwd_entry() - preparing to call mod_sam21pwd_entry() - added "user session key" to user_struct.dc. this is md4(nt#) and is needed to decode user's clear-text passwords in SAMR_SET_USERINFO. - split code out in chgpasswd.c to decode 516 byte password buffers. (This used to be commit 2e58ed742435befe419aa366c4052019fede8c23) --- source3/rpc_server/srv_pipe.c | 10 +- source3/rpc_server/srv_pipe_hnd.c | 2 +- source3/rpc_server/srv_samr.c | 244 ++++++++++++++++++++++++++++++-------- 3 files changed, 204 insertions(+), 52 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index ec5b547c86..54d26650e9 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -211,8 +211,16 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) uchar nt_owf[24]; struct smb_passwd *smb_pass = NULL; + user_struct *vuser = get_valid_user_struct(p->vuid); + DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); + if (vuser == NULL) + { + DEBUG(0,("get user struct %d failed\n", p->vuid)); + return False; + } + if (p->ntlmssp_resp.hdr_lm_resp.str_str_len == 0) return False; if (p->ntlmssp_resp.hdr_nt_resp.str_str_len == 0) return False; if (p->ntlmssp_resp.hdr_usr .str_str_len == 0) return False; @@ -256,7 +264,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) become_root(True); p->ntlmssp_validated = pass_check_smb(p->user_name, p->domain, (uchar*)p->ntlmssp_chal.challenge, - lm_owf, nt_owf, NULL); + lm_owf, nt_owf, NULL, vuser->dc.user_sess_key); smb_pass = getsmbpwnam(p->user_name); unbecome_root(True); diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 531fcf6add..4361c0772e 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -140,7 +140,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->ntlmssp_auth = False; fstrcpy(p->name, pipe_name); - + DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n", pipe_name, i, pipes_open)); diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 2dd7801e81..2437163f2b 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1943,6 +1943,27 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, } +/******************************************************************* + set_user_info_23 + ********************************************************************/ +static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) +{ + static struct sam_passwd *pwd; + fstring new_pw; + if (!decode_pw_buffer(id23->pass, new_pw, sizeof(new_pw), True)) + { + return False; + } +#ifdef DEBUG_PASSWORD + DEBUG(0,("New Password: %s\n", new_pw)); +#endif +#if 0 + return mod_sam21pwd_entry(&pwd, True); +#else + return True; +#endif +} + /******************************************************************* api_samr_query_userinfo ********************************************************************/ @@ -1954,6 +1975,87 @@ static void api_samr_query_userinfo( uint16 vuid, prs_struct *data, prs_struct * } +/******************************************************************* + samr_reply_set_userinfo + ********************************************************************/ +static void samr_reply_set_userinfo(SAMR_Q_SET_USERINFO *q_u, + prs_struct *rdata, uchar user_sess_key[16]) +{ + SAMR_R_SET_USERINFO r_u; + + uint32 status = 0x0; + uint32 rid = 0x0; + + DEBUG(5,("samr_reply_set_userinfo: %d\n", __LINE__)); + + /* search for the handle */ + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + /* find the user's rid */ + if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->pol))) == 0xffffffff) + { + status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + DEBUG(5,("samr_reply_set_userinfo: rid:0x%x\n", rid)); + + /* ok! user info levels (there are lots: see MSDEV help), off we go... */ + if (status == 0x0) + { + switch (q_u->switch_value) + { + case 23: + { + SAM_USER_INFO_23 *id23 = q_u->info.id23; + SamOEMhash(id23->pass, user_sess_key, True); + status = set_user_info_23(id23, rid) ? 0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); + break; + } + + default: + { + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + + break; + } + } + } + + make_samr_r_set_userinfo(&r_u, status); + + /* store the response in the SMB stream */ + samr_io_r_set_userinfo("", &r_u, rdata, 0); + + DEBUG(5,("samr_reply_set_userinfo: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_set_userinfo + ********************************************************************/ +static void api_samr_set_userinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + user_struct *vuser = get_valid_user_struct(vuid); + SAMR_Q_SET_USERINFO q_u; + ZERO_STRUCT(q_u); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("set user info: sess_key: ")); + dump_data(100, vuser->dc.user_sess_key, 16); +#endif + samr_io_q_set_userinfo("", &q_u, data, 0); + samr_reply_set_userinfo(&q_u, rdata, vuser->dc.user_sess_key); + + if (q_u.info.id != NULL) + { + free(q_u.info.id); + } +} + + /******************************************************************* samr_reply_query_usergroups ********************************************************************/ @@ -2310,6 +2412,13 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, break; } + case 0x01: + { + switch_value = 0x1; + make_unk_info1(&ctr.info.inf1); + + break; + } default: { status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; @@ -2340,50 +2449,19 @@ static void api_samr_query_dom_info( uint16 vuid, prs_struct *data, prs_struct * /******************************************************************* - samr_reply_unknown_32 + samr_reply_create_user ********************************************************************/ -static void samr_reply_unknown_32(SAMR_Q_UNKNOWN_32 *q_u, - prs_struct *rdata, - int status) -{ - int i; - SAMR_R_UNKNOWN_32 r_u; - - /* set up the SAMR unknown_32 response */ - bzero(r_u.pol.data, POL_HND_SIZE); - if (status == 0) - { - for (i = 4; i < POL_HND_SIZE; i++) - { - r_u.pol.data[i] = i+1; - } - } - - make_dom_rid4(&(r_u.rid4), 0x0030, 0, 0); - r_u.status = status; - - DEBUG(5,("samr_unknown_32: %d\n", __LINE__)); - - /* store the response in the SMB stream */ - samr_io_r_unknown_32("", &r_u, rdata, 0); - - DEBUG(5,("samr_unknown_32: %d\n", __LINE__)); - -} - -/******************************************************************* - api_samr_unknown_32 - ********************************************************************/ -static void api_samr_unknown_32( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void samr_reply_create_user(SAMR_Q_CREATE_USER *q_u, + prs_struct *rdata) { - uint32 status = 0; struct sam_passwd *sam_pass; - fstring mach_acct; - - SAMR_Q_UNKNOWN_32 q_u; + fstring user_name; - /* grab the samr unknown 32 */ - samr_io_q_unknown_32("", &q_u, data, 0); + SAMR_R_CREATE_USER r_u; + POLICY_HND pol; + uint32 status = 0x0; + uint32 user_rid = 0xffffffff; + BOOL pol_open = False; /* find the machine account: tell the caller if it exists. lkclXXXX i have *no* idea if this is a problem or not @@ -2391,26 +2469,91 @@ static void api_samr_unknown_32( uint16 vuid, prs_struct *data, prs_struct *rdat reply if the account already exists... */ - unistr2_to_ascii(mach_acct, &q_u.uni_mach_acct, sizeof(mach_acct)-1); + /* find the policy handle. open a policy on it. */ + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->domain_pol)) == -1)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } - become_root(True); - sam_pass = getsam21pwntnam(mach_acct); - unbecome_root(True); + /* get a (unique) handle. open a policy on it. */ + if (status == 0x0 && !(pol_open = open_lsa_policy_hnd(&pol))) + { + status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + unistr2_to_ascii(user_name, &q_u->uni_name, sizeof(user_name)-1); + + sam_pass = getsam21pwntnam(user_name); if (sam_pass != NULL) { - /* machine account exists: say so */ + /* account exists: say so */ status = 0xC0000000 | NT_STATUS_USER_EXISTS; } else { - /* this could cause trouble... */ - DEBUG(0,("trouble!\n")); - status = 0; + pstring err_str; + pstring msg_str; + + if (!local_password_change(user_name, True, + q_u->acb_info | ACB_DISABLED, 0xffff, + NULL, + err_str, sizeof(err_str), + msg_str, sizeof(msg_str))) + { + DEBUG(0,("%s\n", err_str)); + status = 0xC0000000 | NT_STATUS_ACCESS_DENIED; + } + else + { + sam_pass = getsam21pwntnam(user_name); + if (sam_pass == NULL) + { + /* account doesn't exist: say so */ + status = 0xC0000000 | NT_STATUS_ACCESS_DENIED; + } + else + { + user_rid = sam_pass->user_rid; + } + } + } + + /* associate the RID with the (unique) handle. */ + if (status == 0x0 && !set_lsa_policy_samr_rid(&pol, user_rid)) + { + /* oh, whoops. don't know what error message to return, here */ + status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + if (status != 0 && pol_open) + { + close_lsa_policy_hnd(&pol); } + DEBUG(5,("samr_create_user: %d\n", __LINE__)); + + make_samr_r_create_user(&r_u, &pol, 0x000703ff, user_rid, status); + + /* store the response in the SMB stream */ + samr_io_r_create_user("", &r_u, rdata, 0); + + DEBUG(5,("samr_create_user: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_create_user + ********************************************************************/ +static void api_samr_create_user( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_CREATE_USER q_u; + + /* grab the samr unknown 32 */ + samr_io_q_create_user("", &q_u, data, 0); + /* construct reply. */ - samr_reply_unknown_32(&q_u, rdata, status); + samr_reply_create_user(&q_u, rdata); } @@ -2709,6 +2852,7 @@ static struct api_struct api_samr_cmds [] = { "SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, { "SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, { "SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, + { "SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo }, { "SAMR_QUERY_DOMAIN_INFO", SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, { "SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, { "SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, @@ -2716,7 +2860,7 @@ static struct api_struct api_samr_cmds [] = { "SAMR_QUERY_DISPINFO4" , SAMR_QUERY_DISPINFO4 , api_samr_query_dispinfo }, { "SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, { "SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, - { "SAMR_0x32" , SAMR_UNKNOWN_32 , api_samr_unknown_32 }, + { "SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user }, { "SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids }, { "SAMR_UNKNOWN_38" , SAMR_UNKNOWN_38 , api_samr_unknown_38 }, { "SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, -- cgit From fa01e8764c9da8d0e37f07dbe1a3b116a0640acc Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 25 Mar 1999 15:14:30 +0000 Subject: added SAMR_USER_INFO_24 info level to samr_set_userinfo. this is used by "Welcome to SAMBA Domain". (This used to be commit 4aed18b5e1e2309c0f6931fbfdd604b01cb9498a) --- source3/rpc_server/srv_samr.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 2437163f2b..b0fc64a2e7 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1943,6 +1943,27 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, } +/******************************************************************* + set_user_info_24 + ********************************************************************/ +static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) +{ + static struct sam_passwd *pwd; + fstring new_pw; + if (!decode_pw_buffer(id24->pass, new_pw, sizeof(new_pw), True)) + { + return False; + } +#ifdef DEBUG_PASSWORD + DEBUG(0,("New Password: %s\n", new_pw)); +#endif +#if 0 + return mod_sam21pwd_entry(&pwd, True); +#else + return True; +#endif +} + /******************************************************************* set_user_info_23 ********************************************************************/ @@ -2007,6 +2028,15 @@ static void samr_reply_set_userinfo(SAMR_Q_SET_USERINFO *q_u, { switch (q_u->switch_value) { + case 24: + { + SAM_USER_INFO_24 *id24 = q_u->info.id24; + nt_lm_owf_gen("test", nt_pwd, lm_pwd); + SamOEMhash(id24->pass, user_sess_key, True); + status = set_user_info_24(id24, rid) ? 0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); + break; + } + case 23: { SAM_USER_INFO_23 *id23 = q_u->info.id23; -- cgit From 3b07eff9eaa0bd3255dbbcdeb0fbd95e1a064e97 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 25 Mar 1999 20:56:28 +0000 Subject: fixed issues with "Welcome to SAMBA Domain" for when admin user/pass is used to add workstation to domain. unix account db not modified: only SAM password db is used. (This used to be commit 129a9a4d4b74897ed753a697a3aed9b194c25568) --- source3/rpc_server/srv_samr.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index b0fc64a2e7..15b2159383 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1948,20 +1948,35 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, ********************************************************************/ static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) { - static struct sam_passwd *pwd; - fstring new_pw; + struct sam_passwd *pwd = getsam21pwrid(rid); + struct sam_passwd new_pwd; + static uchar nt_hash[16]; + static uchar lm_hash[16]; + pstring new_pw; + + if (pwd == NULL) + { + return False; + } + + pwdb_init_sam(&new_pwd); + copy_sam_passwd(&new_pwd, pwd); + if (!decode_pw_buffer(id24->pass, new_pw, sizeof(new_pw), True)) { return False; } + #ifdef DEBUG_PASSWORD DEBUG(0,("New Password: %s\n", new_pw)); #endif -#if 0 - return mod_sam21pwd_entry(&pwd, True); -#else - return True; -#endif + + nt_lm_owf_gen(new_pw, nt_hash, lm_hash); + + new_pwd.smb_passwd = lm_hash; + new_pwd.smb_nt_passwd = nt_hash; + + return mod_sam21pwd_entry(&new_pwd, True); } /******************************************************************* @@ -2031,7 +2046,6 @@ static void samr_reply_set_userinfo(SAMR_Q_SET_USERINFO *q_u, case 24: { SAM_USER_INFO_24 *id24 = q_u->info.id24; - nt_lm_owf_gen("test", nt_pwd, lm_pwd); SamOEMhash(id24->pass, user_sess_key, True); status = set_user_info_24(id24, rid) ? 0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); break; @@ -2526,7 +2540,7 @@ static void samr_reply_create_user(SAMR_Q_CREATE_USER *q_u, pstring msg_str; if (!local_password_change(user_name, True, - q_u->acb_info | ACB_DISABLED, 0xffff, + q_u->acb_info, 0xffff, NULL, err_str, sizeof(err_str), msg_str, sizeof(msg_str))) -- cgit From 068e77c86104c5cae2edc4418797e656d617e182 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 25 Mar 1999 21:32:04 +0000 Subject: "User Manager" - create user + change password now work. next problem: user group adding not supported so an "access denied" message is reported instead of "ok" when a new user is created. (This used to be commit f5f61bd477b4910cb90675c926381342c30a5b16) --- source3/rpc_server/srv_samr.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 15b2159383..63aa0dc914 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1984,20 +1984,38 @@ static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) ********************************************************************/ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) { - static struct sam_passwd *pwd; - fstring new_pw; + struct sam_passwd *pwd = getsam21pwrid(rid); + struct sam_passwd new_pwd; + static uchar nt_hash[16]; + static uchar lm_hash[16]; + pstring new_pw; + + if (pwd == NULL) + { + return False; + } + + pwdb_init_sam(&new_pwd); + copy_sam_passwd(&new_pwd, pwd); +#if 0 + copy_id23_to_sam_passwd(&new_pwd, id23); +#endif + if (!decode_pw_buffer(id23->pass, new_pw, sizeof(new_pw), True)) { return False; } + #ifdef DEBUG_PASSWORD DEBUG(0,("New Password: %s\n", new_pw)); #endif -#if 0 - return mod_sam21pwd_entry(&pwd, True); -#else - return True; -#endif + + nt_lm_owf_gen(new_pw, nt_hash, lm_hash); + + new_pwd.smb_passwd = lm_hash; + new_pwd.smb_nt_passwd = nt_hash; + + return mod_sam21pwd_entry(&new_pwd, True); } /******************************************************************* -- cgit From 6ce4aaad2ba38fce30c54dac4f7552b4b748e224 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 29 Mar 1999 17:24:46 +0000 Subject: added SamrQueryDomainInfo call info level 0x3 for kix32.exe support (This used to be commit ac070dfd39bfa9b60680855585155ce528ab7691) --- source3/rpc_server/srv_samr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 63aa0dc914..4b1c5a4ea1 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1997,9 +1997,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) pwdb_init_sam(&new_pwd); copy_sam_passwd(&new_pwd, pwd); -#if 0 copy_id23_to_sam_passwd(&new_pwd, id23); -#endif if (!decode_pw_buffer(id23->pass, new_pw, sizeof(new_pw), True)) { @@ -2453,6 +2451,13 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, { switch (q_u->switch_value) { + case 0x07: + { + switch_value = 0x7; + make_unk_info7(&ctr.info.inf7); + + break; + } case 0x06: { switch_value = 0x6; @@ -2460,10 +2465,10 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, break; } - case 0x07: + case 0x03: { - switch_value = 0x7; - make_unk_info7(&ctr.info.inf7); + switch_value = 0x3; + make_unk_info3(&ctr.info.inf3); break; } -- cgit From bc973ffbddc96e0b43edae2df1f8240bb25789b6 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 6 Apr 1999 16:36:52 +0000 Subject: Dejan Ilic: spotted "NETLOGON" bug, failure of NT_STATUS WRONG_PASSWORD. (This used to be commit 2f02a083b2f766d2f3d3f410377da7f552739345) --- source3/rpc_server/srv_netlog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 1bb86e183f..33af093625 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -534,9 +534,9 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, smb_pass->unix_name)); } - if (memcmp(smb_pass->smb_passwd , lm_pwd, 16) != 0 && - (smb_pass->smb_nt_passwd == NULL || - memcmp(smb_pass->smb_nt_passwd, nt_pwd, 16) != 0)) + if (memcmp(smb_pass->smb_passwd , lm_pwd, 16) != 0 || + smb_pass->smb_nt_passwd == NULL || + memcmp(smb_pass->smb_nt_passwd, nt_pwd, 16) != 0) { status = 0xC0000000 | NT_STATUS_WRONG_PASSWORD; } -- cgit From 53f0cd990c3d26e73b42266be35516d6db9621e0 Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Thu, 8 Apr 1999 05:35:53 +0000 Subject: Mainly BDC-related changes. * Added SEC_CHAN_BDC * Fix for endianness problem reported by Edan Idzerda . A BUFFER2 is really a "unibuf" in my terminology and we should treat it as such. * Added some more common NT structures (BIGINT, BUFHDR2, BUFFER4). * Added NET_SAM_SYNC (-> NetDatabaseSync2) RPC for account replication. Still experimental and incomplete, with a few too many NULL security descriptors lying around (must go look at Jeremy's SD code). Haven't worked out password encryption yet either. However, the XXX_INFO structures I've added to rpc_netlogon.h are quite nice as they give some insight into how these objects are stored in the SAM. (This used to be commit 74d6dec25d6b44e26d3895f789f1958d5f4639ee) --- source3/rpc_server/srv_netlog.c | 78 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 33af093625..c84e91f643 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -224,6 +224,48 @@ static void net_reply_sam_logoff(NET_Q_SAM_LOGOFF *q_s, prs_struct *rdata, } +/************************************************************************* + net_reply_sam_sync: + *************************************************************************/ +static void net_reply_sam_sync(NET_Q_SAM_SYNC *q_s, prs_struct *rdata, + DOM_CRED *srv_creds, uint32 status) +{ + NET_R_SAM_SYNC r_s; + int i = 0; + struct sam_passwd *pwd; + void *vp; + + memcpy(&(r_s.srv_creds), srv_creds, sizeof(r_s.srv_creds)); + r_s.sync_context = 1; + r_s.ptr_deltas = 0; + + if ((status == 0x0) && ((vp = startsmbpwent(False)) != NULL)) + { + /* Give the poor BDC some accounts */ + + while (((pwd = getsam21pwent(vp)) != NULL) && (i < MAX_SAM_DELTAS)) + { + make_sam_delta_hdr(&r_s.hdr_deltas[i], 5, pwd->user_rid); + make_sam_account_info(&r_s.deltas[i].account_info, + pwd->nt_name, pwd->full_name, pwd->user_rid, + pwd->group_rid, pwd->home_dir, pwd->dir_drive, + pwd->logon_script, pwd->acct_desc, + pwd->acct_ctrl, pwd->profile_path); + } + + endsmbpwent(vp); + + r_s.ptr_deltas = r_s.ptr_deltas2 = 1; + r_s.num_deltas = r_s.num_deltas2 = i; + } + + r_s.status = status; + + /* store the response in the SMB stream */ + net_io_r_sam_sync("", &r_s, rdata, 0); + +} + /****************************************************************** gets a machine password entry. checks access rights of the host. ******************************************************************/ @@ -487,6 +529,41 @@ static void api_net_sam_logoff( uint16 vuid, 0x0); } +/************************************************************************* + api_net_sam_sync: + *************************************************************************/ +static void api_net_sam_sync( uint16 vuid, + prs_struct *data, + prs_struct *rdata) +{ + NET_Q_SAM_SYNC q_s; + DOM_CRED srv_creds; + user_struct *vuser; + uint32 status = 0x0; + + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return; + + /* grab the challenge... */ + net_io_q_sam_sync("", &q_s, data, 0); + + /* checks and updates credentials. creates reply credentials */ + if (deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), + &(q_s.cli_creds), &srv_creds)) + { + memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), + sizeof(vuser->dc.clnt_cred)); + } + else + { + status = 0xC0000000 | NT_STATUS_NETWORK_CREDENTIAL_CONFLICT; + } + + /* construct reply. */ + net_reply_sam_sync(&q_s, rdata, &srv_creds, status); +} + + /************************************************************************* net_login_interactive: *************************************************************************/ @@ -881,6 +958,7 @@ static struct api_struct api_net_cmds [] = { "NET_SAMLOGOFF" , NET_SAMLOGOFF , api_net_sam_logoff }, { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 }, { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, + { "NET_SAM_SYNC" , NET_SAM_SYNC , api_net_sam_sync }, { NULL , 0 , NULL } }; -- cgit From 2bc0641b88bb770812fbfbcfa8cf63b60eb49e45 Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Fri, 23 Apr 1999 14:48:22 +0000 Subject: Added new define NT_STATUS_MORE_ENTRIES = 0x105. (This used to be commit 52b4fd5b55c22deb691124b743ae9d3beb33b39e) --- source3/rpc_server/srv_samr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 4b1c5a4ea1..008ad57c4d 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -914,7 +914,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, if ((status == 0) && (num_entries < num_sam_entries)) { - status = 0x105; /* STATUS_MORE_ENTRIES */ + status = NT_STATUS_MORE_ENTRIES; } make_samr_r_query_dispinfo(&r_e, num_entries, data_size, -- cgit From de0c233a7ae5eab1e0f5a2c07eca3269b0bd9cdc Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 27 Apr 1999 10:13:02 +0000 Subject: Adding RPC spoolss code support and some new low-level printing functions. Jean Francois (This used to be commit 9e8192cc674db7551569d23982877dd25c488b50) --- source3/rpc_server/srv_spoolss.c | 3415 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 3415 insertions(+) create mode 100755 source3/rpc_server/srv_spoolss.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c new file mode 100755 index 0000000000..52b60c5017 --- /dev/null +++ b/source3/rpc_server/srv_spoolss.c @@ -0,0 +1,3415 @@ +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1998, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, + * Copyright (C) Jean François Micouleau 1998. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; +extern pstring global_myname; + +#ifndef MAX_OPEN_PRINTERS +#define MAX_OPEN_PRINTERS 50 +#endif + +#define PRINTER_HANDLE_IS_PRINTER 0 +#define PRINTER_HANDLE_IS_PRINTSERVER 1 + + +/* structure to store the printer handles */ +/* and a reference to what it's pointing to */ +/* and the notify info asked about */ +/* that's the central struct */ +static struct +{ + BOOL open; + BOOL document_started; + BOOL page_started; + uint32 current_jobid; + uint32 document_fd; + uint32 document_lastwritten; + pstring document_name; + pstring job_name; + PRINTER_HND printer_hnd; + BOOL printer_type; + union + { + fstring printername; + fstring printerservername; + } dev; + uint32 type; + uint32 access; + uint32 number_of_notify; + SPOOL_NOTIFY_OPTION_TYPE notify_info[MAX_PRINTER_NOTIFY+MAX_JOB_NOTIFY]; +} Printer[MAX_OPEN_PRINTERS]; + +#define VALID_HANDLE(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PRINTERS)) +#define OPEN_HANDLE(pnum) (VALID_HANDLE(pnum) && Printer[pnum].open) + +/**************************************************************************** + initialise printer handle states... +****************************************************************************/ +void init_printer_hnd(void) +{ + int i; + for (i = 0; i < MAX_OPEN_PRINTERS; i++) + { + Printer[i].open = False; + } +} + + +/**************************************************************************** + create a unique printer handle +****************************************************************************/ +static void create_printer_hnd(PRINTER_HND *hnd) +{ + static uint32 prt_hnd_low = 0; + static uint32 prt_hnd_high = 0; + + if (hnd == NULL) return; + + /* i severely doubt that prt_hnd_high will ever be non-zero... */ + prt_hnd_low++; + if (prt_hnd_low == 0) prt_hnd_high++; + + SIVAL(hnd->data, 0 , 0x0); /* first bit must be null */ + SIVAL(hnd->data, 4 , prt_hnd_low ); /* second bit is incrementing */ + SIVAL(hnd->data, 8 , prt_hnd_high); /* second bit is incrementing */ + SIVAL(hnd->data, 12, time(NULL)); /* something random */ + SIVAL(hnd->data, 16, getpid()); /* something more random */ +} + +/**************************************************************************** + clear an handle +****************************************************************************/ +static void clear_handle(PRINTER_HND *hnd) +{ + bzero(hnd->data, PRINTER_HND_SIZE); +} + +/**************************************************************************** + find first available printer slot. creates a printer handle for you. + ****************************************************************************/ +static BOOL open_printer_hnd(PRINTER_HND *hnd) +{ + int i; + + for (i = 0; i < MAX_OPEN_PRINTERS; i++) + { + if (!Printer[i].open) + { + Printer[i].open = True; + create_printer_hnd(hnd); + memcpy(&(Printer[i].printer_hnd), hnd, sizeof(*hnd)); + + DEBUG(4,("Opened printer handle[%x] ", i)); + dump_data(4, hnd->data, sizeof(hnd->data)); + return True; + } + } + DEBUG(1,("ERROR - open_printer_hnd: out of Printers Handles!\n")); + return False; +} + +/**************************************************************************** + find printer index by handle +****************************************************************************/ +static int find_printer_index_by_hnd(PRINTER_HND *hnd) +{ + int i; + + for (i = 0; i < MAX_OPEN_PRINTERS; i++) + { + if (memcmp(&(Printer[i].printer_hnd), hnd, sizeof(*hnd)) == 0) + { + DEBUG(4,("Found printer handle[%x] ", i)); + dump_data(4, hnd->data, sizeof(hnd->data)); + return i; + } + } + DEBUG(3,("Whoops, Printer handle not found: ")); + dump_data(4, hnd->data, sizeof(hnd->data)); + return -1; +} + +/**************************************************************************** + set printer handle type. +****************************************************************************/ +static BOOL set_printer_hnd_accesstype(PRINTER_HND *hnd, uint32 access_required) +{ + int pnum = find_printer_index_by_hnd(hnd); + + if (OPEN_HANDLE(pnum)) + { + DEBUG(4,("Setting printer access=%x (pnum=%x)\n", + access_required, pnum)); + + + + Printer[pnum].access = access_required; + return True; + } + else + { + DEBUG(4,("Error setting printer type=%x (pnum=%x)", + access_required, pnum)); + return False; + } + return False; +} + +/**************************************************************************** + set printer handle type. +****************************************************************************/ +static BOOL set_printer_hnd_printertype(PRINTER_HND *hnd, char *printername) +{ + int pnum = find_printer_index_by_hnd(hnd); + + if (OPEN_HANDLE(pnum)) + { + DEBUG(3,("Setting printer type=%s (pnum=%x)\n", printername, pnum)); + + if ( strlen(printername) < 3 ) + { + DEBUGADD(4,("A print server must have at least 1 char ! %s\n", printername)); + return False; + } + + /* check if it's \\server or \\server\printer */ + /* +2 is to skip the leading \\ */ + if (!strchr(printername+2, '\\')) + { + /* it's a print server */ + DEBUGADD(4,("Printer is a print server\n")); + Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTSERVER; + return True; + } + else + { + /* it's a printer */ + DEBUGADD(4,("Printer is a printer\n")); + Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTER; + return True; + } + } + else + { + DEBUGADD(4,("Error setting printer name %s (pnum=%x)", + printername, pnum)); + return False; + } + return False; +} + +/**************************************************************************** + set printer handle printername. +****************************************************************************/ +static BOOL set_printer_hnd_printername(PRINTER_HND *hnd, char *printername) +{ + int pnum = find_printer_index_by_hnd(hnd); + char *back; + NT_PRINTER_INFO_LEVEL printer; + int snum; + int n_services=lp_numservices(); + uint32 marche; + + if (OPEN_HANDLE(pnum)) + { + DEBUG(4,("Setting printer name=%s (len=%d) (pnum=%x)\n", + printername,strlen(printername), pnum)); + + switch (Printer[pnum].printer_type) + { + case PRINTER_HANDLE_IS_PRINTER: + back=strchr(printername+2, '\\'); + back=back+1; + DEBUGADD(5,("searching for %s (len=%d)\n", back,strlen(back))); + /* + * store the Samba share name in it + * in back we have the long printer name + * need to iterate all the snum and do a + * get_a_printer each time to find the printer + * faster to do it here than later. + */ + for (snum=0;snumprintername) == strlen(back) ) + && ( !strncasecmp(printer.info_2->printername, back, strlen(back))) + ) + { + DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); + strncpy(Printer[pnum].dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); + return True; + break; + } + free_a_printer(printer, 2); + } + } + + return False; + break; + case PRINTER_HANDLE_IS_PRINTSERVER: + strncpy(Printer[pnum].dev.printerservername, printername, strlen(printername)); + return True; + break; + default: + return False; + break; + } + } + else + { + DEBUG(0,("Error setting printer name=%s (pnum=%x)\n", + printername , pnum)); + return False; + } +} + +/**************************************************************************** + return the snum of a printer corresponding to an handle +****************************************************************************/ +static BOOL get_printer_snum(PRINTER_HND *hnd, int *number) +{ + int snum; + int pnum = find_printer_index_by_hnd(hnd); + int n_services=lp_numservices(); + + if (OPEN_HANDLE(pnum)) + { + switch (Printer[pnum].printer_type) + { + case PRINTER_HANDLE_IS_PRINTER: + DEBUG(4,("get_printer_snum, short name:%s\n", Printer[pnum].dev.printername)); + for (snum=0;snumprintername), sizeof(name)-1); + + DEBUGADD(3,("checking name: %s\n",name)); + + /* now the response */ + r_u.status=0x00000000; + + printer_open = open_printer_hnd(&(r_u.handle)); + set_printer_hnd_printertype(&(r_u.handle), name); + + if ( !set_printer_hnd_printername(&(r_u.handle), name) ) + { + r_u.status=0xC0000000|NT_STATUS_ACCESS_DENIED; + } + + set_printer_hnd_accesstype(&(r_u.handle), q_u->access_required); + + spoolss_io_r_open_printer("",&r_u,rdata,0); +} + +/******************************************************************** + * api_spoolss_open_printer + * + * called from the spoolss dispatcher + ********************************************************************/ +static void api_spoolss_open_printer(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_OPEN_PRINTER q_u; + + /* grab the spoolss open policy */ + spoolss_io_q_open_printer("", &q_u, data, 0); + + /* construct reply. always indicate success */ + spoolss_reply_open_printer(&q_u, rdata); +} + +/******************************************************************** + ********************************************************************/ +static BOOL getprinterdata_printer_server(fstring value, uint32 size, uint32 *type, + uint32 *numeric_data, uint8 **data, uint32 *needed) +{ + + if (!strcmp(value, "BeepEnabled")) + { + *type = 0x4; + *data = (uint8 *)malloc( 4*sizeof(uint8) ); + ZERO_STRUCTP(*data); + (*data)[0]=0x01; + (*data)[1]=0x00; + (*data)[2]=0x00; + (*data)[3]=0x00; + *numeric_data = 0x1; /* beep enabled */ + *needed = 0x4; + return True; + } + + if (!strcmp(value, "EventLog")) + { + *type = 0x4; + *data = (uint8 *)malloc( 4*sizeof(uint8) ); + ZERO_STRUCTP(*data); + (*data)[0]=0x1B; + (*data)[1]=0x00; + (*data)[2]=0x00; + (*data)[3]=0x00; + *numeric_data = 0x1B; /* Don't know ??? */ + *needed = 0x4; + return True; + } + + if (!strcmp(value, "NetPopup")) + { + *type = 0x4; + *data = (uint8 *)malloc( 4*sizeof(uint8) ); + ZERO_STRUCTP(*data); + (*data)[0]=0x01; + (*data)[1]=0x00; + (*data)[2]=0x00; + (*data)[3]=0x00; + *numeric_data = 0x1; /* popup enabled */ + *needed = 0x4; + return True; + } + + if (!strcmp(value, "MajorVersion")) + { + *type = 0x4; + *data = (uint8 *)malloc( 4*sizeof(uint8) ); + (*data)[0]=0x02; + (*data)[1]=0x00; + (*data)[2]=0x00; + (*data)[3]=0x00; + *numeric_data = 0x2; /* it's 2, period. */ + *needed = 0x4; + return True; + } + + if (!strcmp(value, "DefaultSpoolDirectory")) + { + pstring directory="You are using a Samba server"; + *type = 0x1; + *data = (uint8 *)malloc( size*sizeof(uint8) ); + ZERO_STRUCTP(*data); + make_unistr((UNISTR *)*data, directory); + *needed = 2*(strlen(directory)+1); + return True; + } + + if (!strcmp(value, "Architecture")) + { + pstring directory="Windows NT x86"; + *type = 0x1; + *data = (uint8 *)malloc( size*sizeof(uint8) ); + ZERO_STRUCTP(*data); + make_unistr((UNISTR *)*data, directory); + *needed = 2*(strlen(directory)+1); + return True; + } + + return False; +} + +static BOOL getprinterdata_printer(PRINTER_HND *handle, fstring value, uint32 size, uint32 *type, + uint32 *numeric_data, uint8 **data, uint32 *needed ) +{ + NT_PRINTER_INFO_LEVEL printer; + int pnum=0; + int snum=0; + uint8 *idata; + uint32 len; + + DEBUG(5,("getprinterdata_printer\n")); + + pnum = find_printer_index_by_hnd(handle); + if (OPEN_HANDLE(pnum)) + { + get_printer_snum(handle, &snum); + get_a_printer(&printer, 2, lp_servicename(snum)); + + if (get_specific_param(printer, 2, value, &idata, type, &len)) + { + switch (*type) + { + case 1: + case 3: + case 4: + *data = (uint8 *)malloc( size*sizeof(uint8) ); + bzero(*data, sizeof(uint8)*size); + memcpy(*data, idata, len>size?size:len); + *needed = len; + break; + /*case 4: + *numeric_data=atoi(idata); + break;*/ + } + return (True); + } + + } + + return (False); +} + +/******************************************************************** + * api_spoolss_reply_getprinterdata + * + * called from api_spoolss_getprinterdata + ********************************************************************/ +static void spoolss_reply_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *rdata) +{ + SPOOL_R_GETPRINTERDATA r_u; + fstring value; + BOOL found; + int pnum = find_printer_index_by_hnd(&(q_u->handle)); + + /* + * Reminder: when it's a string, the length is in BYTES + * even if UNICODE is negociated. + * + * r_u.type is the kind of data + * 1 is a string + * 4 is a uint32 + * + * I think it's documented in MSDN somewhere in + * the registry data type (yep it's linked ...) + * + * JFM, 4/19/1999 + */ + + if (OPEN_HANDLE(pnum)) + { + r_u.size = q_u->size; + r_u.status = 0x0; + + unistr2_to_ascii(value, &(q_u->valuename), sizeof(value)-1); + + if (handle_is_printserver(&(q_u->handle))) + { + found=getprinterdata_printer_server(value, r_u.size, + &(r_u.type), &(r_u.numeric_data), + &(r_u.data), &(r_u.needed)); + } + else + { + found=getprinterdata_printer(&(q_u->handle), value, r_u.size, + &(r_u.type), &(r_u.numeric_data), + &(r_u.data), &(r_u.needed)); + } + + if (found==False) + { + /* reply this param doesn't exist */ + r_u.type = 0x4; + r_u.size = 0x0; + r_u.data = NULL; + r_u.numeric_data=0x0; + r_u.needed = 0x0; + r_u.status = ERROR_INVALID_PARAMETER; + } + + spoolss_io_r_getprinterdata("", &r_u, rdata, 0); + } +} + +/******************************************************************** + * api_spoolss_getprinterdata + * + * called from the spoolss dispatcher + ********************************************************************/ +static void api_spoolss_getprinterdata(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_GETPRINTERDATA q_u; + + /* read the stream and fill the struct */ + spoolss_io_q_getprinterdata("", &q_u, data, 0); + + spoolss_reply_getprinterdata(&q_u,rdata); +} + +/******************************************************************** + * api_spoolss_reply_closeprinter + * + * called from api_spoolss_closeprinter + ********************************************************************/ +static void spoolss_reply_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *rdata) +{ + SPOOL_R_CLOSEPRINTER r_u; + + int pnum = find_printer_index_by_hnd(&(q_u->handle)); + + clear_handle(&(r_u.handle)); + + if (OPEN_HANDLE(pnum)) + { + Printer[pnum].open=False; + r_u.status=0x0; + spoolss_io_r_closeprinter("",&r_u,rdata,0); + } + else + { + r_u.status= 0xC0000000 | NT_STATUS_INVALID_HANDLE; + DEBUG(3,("Error closing printer handle (pnum=%x)\n", pnum)); + } + + spoolss_io_r_closeprinter("",&r_u,rdata,0); +} + +/******************************************************************** + * api_spoolss_closeprinter + * + * called from the spoolss dispatcher + ********************************************************************/ +static void api_spoolss_closeprinter(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_CLOSEPRINTER q_u; + + spoolss_io_q_closeprinter("", &q_u, data, 0); + + spoolss_reply_closeprinter(&q_u,rdata); +} + +/******************************************************************** + * api_spoolss_reply_rffpcnex + * + * called from api_spoolss_rffpcnex (see this to understand) + ********************************************************************/ +static void spoolss_reply_rffpcnex(SPOOL_Q_RFFPCNEX *q_u, prs_struct *rdata) +{ + SPOOL_R_RFFPCNEX r_u; + + r_u.status = 0x0000; + + spoolss_io_r_rffpcnex("",&r_u,rdata,0); +} + +/******************************************************************** + * api_spoolss_rffpcnex + * ReplyFindFirstPrinterChangeNotifyEx + * called from the spoolss dispatcher + * + * jfmxxxx: before replying OK: status=0 + * should do a rpc call to the workstation asking ReplyOpenPrinter + * have to code it, later. + * + * in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe + ********************************************************************/ +static void api_spoolss_rffpcnex(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_RFFPCNEX q_u; + + int i,j,k; + + spoolss_io_q_rffpcnex("", &q_u, data, 0); + + /* store the notify value in the printer struct */ + + i=find_printer_index_by_hnd(&(q_u.handle)); + + Printer[i].number_of_notify=q_u.option.count; + + DEBUG(3,("Copying %x notify option info\n",Printer[i].number_of_notify)); + + for (j=0;jnotify_data.data.length=strlen(temp_name); + ascii_to_unistr(data->notify_data.data.string, temp_name, sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the servicename + * jfmxxxx: it's incorrect should be long_printername + ********************************************************************/ +static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ +/* + data->notify_data.data.length=strlen(lp_servicename(snum)); + ascii_to_unistr(data->notify_data.data.string, lp_servicename(snum), sizeof(data->notify_data.data.string)-1); +*/ + data->notify_data.data.length=strlen(printer->info_2->printername); + ascii_to_unistr(data->notify_data.data.string, + printer->info_2->printername, + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the servicename + ********************************************************************/ +static void spoolss_notify_share_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(lp_servicename(snum)); + ascii_to_unistr(data->notify_data.data.string, + lp_servicename(snum), + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the port name + ********************************************************************/ +static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + /* even if it's strange, that's consistant in all the code */ + + data->notify_data.data.length=strlen(lp_servicename(snum)); + ascii_to_unistr(data->notify_data.data.string, + lp_servicename(snum), + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the printername + * jfmxxxx: it's incorrect, should be lp_printerdrivername() + * but it doesn't exist, have to see what to do + ********************************************************************/ +static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(printer->info_2->drivername); + ascii_to_unistr(data->notify_data.data.string, + printer->info_2->drivername, + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the comment + ********************************************************************/ +static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(lp_comment(snum)); + ascii_to_unistr(data->notify_data.data.string, + lp_comment(snum), + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the comment + * jfm:xxxx incorrect, have to create a new smb.conf option + * location = "Room 1, floor 2, building 3" + ********************************************************************/ +static void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(printer->info_2->location); + ascii_to_unistr(data->notify_data.data.string, + printer->info_2->location, + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the device mode + * jfm:xxxx don't to it for know but that's a real problem !!! + ********************************************************************/ +static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ +} + +/******************************************************************* + * fill a notify_info_data with the separator file name + * jfm:xxxx just return no file could add an option to smb.conf + * separator file = "separator.txt" + ********************************************************************/ +static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(printer->info_2->sepfile); + ascii_to_unistr(data->notify_data.data.string, + printer->info_2->sepfile, + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the print processor + * jfm:xxxx return always winprint to indicate we don't do anything to it + ********************************************************************/ +static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(printer->info_2->printprocessor); + ascii_to_unistr(data->notify_data.data.string, + printer->info_2->printprocessor, + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the print processor options + * jfm:xxxx send an empty string + ********************************************************************/ +static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(printer->info_2->parameters); + ascii_to_unistr(data->notify_data.data.string, + printer->info_2->parameters, + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the data type + * jfm:xxxx always send RAW as data type + ********************************************************************/ +static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(printer->info_2->datatype); + ascii_to_unistr(data->notify_data.data.string, + printer->info_2->datatype, + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the security descriptor + * jfm:xxxx send an null pointer to say no security desc + * have to implement security before ! + ********************************************************************/ +static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=0; + data->notify_data.data.string[0]=0x00; +} + +/******************************************************************* + * fill a notify_info_data with the attributes + * jfm:xxxx a samba printer is always shared + ********************************************************************/ +static void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0] = PRINTER_ATTRIBUTE_SHARED \ + | PRINTER_ATTRIBUTE_NETWORK \ + | PRINTER_ATTRIBUTE_RAW_ONLY ; +} + +/******************************************************************* + * fill a notify_info_data with the priority + ********************************************************************/ +static void spoolss_notify_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0] = printer->info_2->priority; +} + +/******************************************************************* + * fill a notify_info_data with the default priority + ********************************************************************/ +static void spoolss_notify_default_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0] = printer->info_2->default_priority; +} + +/******************************************************************* + * fill a notify_info_data with the start time + ********************************************************************/ +static void spoolss_notify_start_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0] = printer->info_2->starttime; +} + +/******************************************************************* + * fill a notify_info_data with the until time + ********************************************************************/ +static void spoolss_notify_until_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0] = printer->info_2->untiltime; +} + +/******************************************************************* + * fill a notify_info_data with the status + ********************************************************************/ +static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + int count; + print_queue_struct *q=NULL; + print_status_struct status; + + bzero(&status,sizeof(status)); + + count=get_printqueue(snum,0,&q,&status); + + data->notify_data.value[0]=(uint32) status.status; +} + +/******************************************************************* + * fill a notify_info_data with the number of jobs queued + ********************************************************************/ +static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + print_queue_struct *q=NULL; + print_status_struct status; + + bzero(&status,sizeof(status)); + + data->notify_data.value[0]=get_printqueue(snum,0,&q,&status); +} + +/******************************************************************* + * fill a notify_info_data with the average ppm + ********************************************************************/ +static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + /* always respond 8 pages per minutes */ + /* a little hard ! */ + data->notify_data.value[0] = printer->info_2->averageppm; +} + +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(queue->user); + ascii_to_unistr(data->notify_data.data.string, queue->user, sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0]=queue->status; +} + +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(queue->file); + ascii_to_unistr(data->notify_data.data.string, queue->file, sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen("En attente"); + ascii_to_unistr(data->notify_data.data.string, "En attente", sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0]=0x0; +} + +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0]=queue->size; +} + +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0]=queue->job; +} + +#define END 65535 + +struct s_notify_info_data_table notify_info_data_table[] = +{ +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", POINTER, spoolss_notify_server_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, "PRINTER_NOTIFY_PRINTER_NAME", POINTER, spoolss_notify_printer_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SHARE_NAME, "PRINTER_NOTIFY_SHARE_NAME", POINTER, spoolss_notify_share_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PORT_NAME, "PRINTER_NOTIFY_PORT_NAME", POINTER, spoolss_notify_port_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DRIVER_NAME, "PRINTER_NOTIFY_DRIVER_NAME", POINTER, spoolss_notify_driver_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_COMMENT, "PRINTER_NOTIFY_COMMENT", POINTER, spoolss_notify_comment }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_LOCATION, "PRINTER_NOTIFY_LOCATION", POINTER, spoolss_notify_location }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEVMODE, "PRINTER_NOTIFY_DEVMODE", POINTER, spoolss_notify_devmode }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SEPFILE, "PRINTER_NOTIFY_SEPFILE", POINTER, spoolss_notify_sepfile }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINT_PROCESSOR, "PRINTER_NOTIFY_PRINT_PROCESSOR", POINTER, spoolss_notify_print_processor }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PARAMETERS, "PRINTER_NOTIFY_PARAMETERS", POINTER, spoolss_notify_parameters }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DATATYPE, "PRINTER_NOTIFY_DATATYPE", POINTER, spoolss_notify_datatype }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SECURITY_DESCRIPTOR, "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", POINTER, spoolss_notify_security_desc }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_ATTRIBUTES, "PRINTER_NOTIFY_ATTRIBUTES", ONE_VALUE, spoolss_notify_attributes }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRIORITY, "PRINTER_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEFAULT_PRIORITY, "PRINTER_NOTIFY_DEFAULT_PRIORITY", ONE_VALUE, spoolss_notify_default_priority }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_START_TIME, "PRINTER_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_UNTIL_TIME, "PRINTER_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS, "PRINTER_NOTIFY_STATUS", ONE_VALUE, spoolss_notify_status }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS_STRING, "PRINTER_NOTIFY_STATUS_STRING", POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_CJOBS, "PRINTER_NOTIFY_CJOBS", ONE_VALUE, spoolss_notify_cjobs }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_AVERAGE_PPM, "PRINTER_NOTIFY_AVERAGE_PPM", ONE_VALUE, spoolss_notify_average_ppm }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_PAGES, "PRINTER_NOTIFY_TOTAL_PAGES", POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PAGES_PRINTED, "PRINTER_NOTIFY_PAGES_PRINTED", POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_BYTES, "PRINTER_NOTIFY_TOTAL_BYTES", POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_BYTES_PRINTED, "PRINTER_NOTIFY_BYTES_PRINTED", POINTER, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINTER_NAME, "JOB_NOTIFY_PRINTER_NAME", POINTER, spoolss_notify_printer_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_MACHINE_NAME, "JOB_NOTIFY_MACHINE_NAME", POINTER, spoolss_notify_server_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PORT_NAME, "JOB_NOTIFY_PORT_NAME", POINTER, spoolss_notify_port_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_USER_NAME, "JOB_NOTIFY_USER_NAME", POINTER, spoolss_notify_username }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_NOTIFY_NAME, "JOB_NOTIFY_NOTIFY_NAME", POINTER, spoolss_notify_username }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DATATYPE, "JOB_NOTIFY_DATATYPE", POINTER, spoolss_notify_datatype }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINT_PROCESSOR, "JOB_NOTIFY_PRINT_PROCESSOR", POINTER, spoolss_notify_print_processor }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PARAMETERS, "JOB_NOTIFY_PARAMETERS", POINTER, spoolss_notify_parameters }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DRIVER_NAME, "JOB_NOTIFY_DRIVER_NAME", POINTER, spoolss_notify_driver_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DEVMODE, "JOB_NOTIFY_DEVMODE", POINTER, spoolss_notify_devmode }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS, "JOB_NOTIFY_STATUS", ONE_VALUE, spoolss_notify_job_status }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS_STRING, "JOB_NOTIFY_STATUS_STRING", POINTER, spoolss_notify_job_status_string }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SECURITY_DESCRIPTOR, "JOB_NOTIFY_SECURITY_DESCRIPTOR", POINTER, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DOCUMENT, "JOB_NOTIFY_DOCUMENT", POINTER, spoolss_notify_job_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRIORITY, "JOB_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_POSITION, "JOB_NOTIFY_POSITION", ONE_VALUE, spoolss_notify_job_position }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SUBMITTED, "JOB_NOTIFY_SUBMITTED", POINTER, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_START_TIME, "JOB_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_UNTIL_TIME, "JOB_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TIME, "JOB_NOTIFY_TIME", ONE_VALUE, spoolss_notify_job_time }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", ONE_VALUE, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", ONE_VALUE, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_BYTES, "JOB_NOTIFY_TOTAL_BYTES", ONE_VALUE, spoolss_notify_job_size }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_BYTES_PRINTED, "JOB_NOTIFY_BYTES_PRINTED", ONE_VALUE, NULL }, +{ END, END, "", END, NULL } +}; + +/******************************************************************* +return the size of info_data structure +********************************************************************/ +uint32 size_of_notify_info_data(uint16 type, uint16 field) +{ + int i=0; + + while (notify_info_data_table[i].type != END) + { + if ( (notify_info_data_table[i].type == type ) && + (notify_info_data_table[i].field == field ) ) + { + return (notify_info_data_table[i].size); + continue; + } + i++; + } + return (65535); +} + +/******************************************************************* +return the type of notify_info_data +********************************************************************/ +BOOL type_of_notify_info_data(uint16 type, uint16 field) +{ + int i=0; + + while (notify_info_data_table[i].type != END) + { + if ( (notify_info_data_table[i].type == type ) && + (notify_info_data_table[i].field == field ) ) + { + if (notify_info_data_table[i].size == POINTER) + { + return (False); + } + else + { + return (True); + } + continue; + } + i++; + } + return (False); +} + +/**************************************************************************** +****************************************************************************/ +static int search_notify(uint16 type, uint16 field, int *value) +{ + int j; + BOOL found; + + DEBUG(4,("\tsearch_notify: in\n")); + for (j=0, found=False; found==False && notify_info_data_table[j].type != END ; j++) + { + if ( (notify_info_data_table[j].type == type ) && + (notify_info_data_table[j].field == field ) ) + { + found=True; + } + } + *value=--j; + + if ( found && (notify_info_data_table[j].fn != NULL) ) + { + DEBUG(4,("\tsearch_notify: out TRUE\n")); + return (True); + } + else + { + DEBUG(4,("\tsearch_notify: out FALSE\n")); + return (False); + } +} + +/**************************************************************************** +****************************************************************************/ +static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 field, int id) +{ + DEBUG(4,("\tconstruct_info_data: in\n")); + info_data->type = type; + info_data->field = field; + info_data->id = id; + info_data->size = size_of_notify_info_data(type, field); + info_data->enc_type = type_of_notify_info_data(type, field); + DEBUG(4,("\tconstruct_info_data: out\n")); +} + + +/******************************************************************* + * + * fill a notify_info struct with info asked + * + ********************************************************************/ +static void construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int pnum, + int snum, int i, uint32 id) +{ + + int k,j; + uint16 type; + uint16 field; + + SPOOL_NOTIFY_INFO_DATA *info_data; + print_queue_struct *queue=NULL; + NT_PRINTER_INFO_LEVEL printer; + + DEBUG(4,("construct_notify_printer_info\n")); + + info_data=&(info->data[info->count]); + + type = Printer[pnum].notify_info[i].type; + + DEBUGADD(4,("Notify number %d -> number of notify info: %d\n",i,Printer[pnum].notify_info[i].count)); + + if (!get_a_printer(&printer, 2, lp_servicename(snum))) + { + + for(k=0; kcount++; + info_data=&(info->data[info->count]); + } + } + + free_a_printer(printer, 2); + } +} + +/******************************************************************* + * + * fill a notify_info struct with info asked + * + ********************************************************************/ +static void construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, + int pnum, int snum, int i, uint32 id) +{ + + int k,j; + uint16 type; + uint16 field; + + SPOOL_NOTIFY_INFO_DATA *info_data; + NT_PRINTER_INFO_LEVEL printer; + + DEBUG(4,("construct_notify_jobs_info\n")); + info_data=&(info->data[info->count]); + + type = Printer[pnum].notify_info[i].type; + + DEBUGADD(4,("Notify number %d -> number of notify info: %d\n",i,Printer[pnum].notify_info[i].count)); + + if (!get_a_printer(&printer, 2, lp_servicename(snum))) + { + for(k=0; kcount++; + info_data=&(info->data[info->count]); + } + } + free_a_printer(printer, 2); + } +} + + +/******************************************************************* + * + * enumerate all printers on the printserver + * fill a notify_info struct with info asked + * + ********************************************************************/ +static void printserver_notify_info(PRINTER_HND *hnd, SPOOL_NOTIFY_INFO *info) +{ + int snum; + int pnum=find_printer_index_by_hnd(hnd); + int n_services=lp_numservices(); + int i=0; + uint32 id=1; + info->count=0; + + DEBUG(4,("Enumerating printers\n")); + + for (i=0; icount=0; + + if (get_printer_snum(hnd, &snum) ) + { + for (i=0; ihandle)); + + if (OPEN_HANDLE(pnum)) + { + DEBUG(4,("Printer %x of type %x\n",pnum,Printer[pnum].printer_type)); + switch (Printer[pnum].printer_type) + { + case PRINTER_HANDLE_IS_PRINTSERVER: + printserver_notify_info(&(q_u->handle), &(r_u.info)); + break; + case PRINTER_HANDLE_IS_PRINTER: + printer_notify_info(&(q_u->handle), &(r_u.info)); + break; + } + + spoolss_io_r_rfnpcnex("", &r_u, rdata, 0); + } +} + +/******************************************************************** + * api_spoolss_rfnpcnex + * ReplyFindNextPrinterChangeNotifyEx + * called from the spoolss dispatcher + * + ********************************************************************/ +static void api_spoolss_rfnpcnex(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_RFNPCNEX q_u; + + spoolss_io_q_rfnpcnex("", &q_u, data, 0); + + spoolss_reply_rfnpcnex(&q_u,rdata); +} + +/******************************************************************** + * construct_printer_info_0 + * fill a printer_info_1 struct + ********************************************************************/ +static void construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring servername) +{ + pstring chaine; + int count; + + print_queue_struct *queue=NULL; + print_status_struct status; + bzero(&status,sizeof(status)); + count=get_printqueue(snum,0,&queue,&status); + + /* the description and the name are of the form \\server\share */ + slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s",servername, lp_servicename(snum)); + + make_unistr(&(printer->printername), chaine); + + slprintf(chaine,sizeof(chaine)-1,"\\\\%s", servername); + make_unistr(&(printer->servername), chaine); + + printer->cjobs = count; + printer->attributes = PRINTER_ATTRIBUTE_SHARED \ + | PRINTER_ATTRIBUTE_NETWORK \ + | PRINTER_ATTRIBUTE_RAW_ONLY ; + printer->unknown0 = 0x1; /* pointer */ + printer->unknown1 = 0x000A07CE; /* don't known */ + printer->unknown2 = 0x00020005; + printer->unknown3 = 0x0006000D; + printer->unknown4 = 0x02180026; + printer->unknown5 = 0x09; + printer->unknown6 = 0x36; + printer->majorversion = 0x0004; /* NT 4 */ + printer->buildversion = 0x0565; /* build 1381 */ + printer->unknown7 = 0x1; + printer->unknown8 = 0x0; + printer->unknown9 = 0x2; + printer->unknown10 = 0x3; + printer->unknown11 = 0x0; + printer->unknown12 = 0x0; + printer->unknown13 = 0x0; + printer->unknown14 = 0x1; + printer->unknown15 = 0x024a; /*586 Pentium ? */ + printer->unknown16 = 0x0; + printer->unknown17 = 0x423ed444; + printer->unknown18 = 0x0; + printer->status = status.status; + printer->unknown20 = 0x0; + printer->unknown21 = 0x0648; + printer->unknown22 = 0x0; + printer->unknown23 = 0x5; + +} + +/******************************************************************** + * construct_printer_info_1 + * fill a printer_info_1 struct + ********************************************************************/ +static BOOL construct_printer_info_1(PRINTER_INFO_1 *printer,int snum, pstring servername) +{ + pstring chaine; + NT_PRINTER_INFO_LEVEL ntprinter; + + if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0) + { + return (False); + } + + printer->flags=PRINTER_ENUM_NAME; + + /* the description and the name are of the form \\server\share */ + slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s,%s,%s",servername, + ntprinter.info_2->printername, + ntprinter.info_2->drivername, + lp_comment(snum)); + make_unistr(&(printer->description), chaine); + + slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s", servername, ntprinter.info_2->printername); + make_unistr(&(printer->name), chaine); + + make_unistr(&(printer->comment), lp_comment(snum)); + + free_a_printer(ntprinter, 2); + return (True); +} + +/**************************************************************************** +****************************************************************************/ +static void construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) +{ + char adevice[32]; + char aform[32]; + NT_PRINTER_INFO_LEVEL printer; + NT_DEVICEMODE *ntdevmode; + + DEBUG(7,("construct_dev_mode\n")); + + bzero(&(devmode->devicename), 2*sizeof(adevice)); + bzero(&(devmode->formname), 2*sizeof(aform)); + + DEBUGADD(8,("getting printer characteristics\n")); + + get_a_printer(&printer, 2, lp_servicename(snum)); + ntdevmode=(printer.info_2)->devmode; + + DEBUGADD(8,("loading DEVICEMODE\n")); + snprintf(adevice, sizeof(adevice), "\\\\%s\\%s", global_myname, + printer.info_2->printername); + make_unistr(&(devmode->devicename), adevice); + + snprintf(aform, sizeof(aform), ntdevmode->formname); + make_unistr(&(devmode->formname), aform); + + devmode->specversion = ntdevmode->specversion; + devmode->driverversion = ntdevmode->driverversion; + devmode->size = ntdevmode->size; + devmode->driverextra = ntdevmode->driverextra; + devmode->fields = ntdevmode->fields; + + devmode->orientation = ntdevmode->orientation; + devmode->papersize = ntdevmode->papersize; + devmode->paperlength = ntdevmode->paperlength; + devmode->paperwidth = ntdevmode->paperwidth; + devmode->scale = ntdevmode->scale; + devmode->copies = ntdevmode->copies; + devmode->defaultsource = ntdevmode->defaultsource; + devmode->printquality = ntdevmode->printquality; + devmode->color = ntdevmode->color; + devmode->duplex = ntdevmode->duplex; + devmode->yresolution = ntdevmode->yresolution; + devmode->ttoption = ntdevmode->ttoption; + devmode->collate = ntdevmode->collate; + devmode->icmmethod = ntdevmode->icmmethod; + devmode->icmintent = ntdevmode->icmintent; + devmode->mediatype = ntdevmode->mediatype; + devmode->dithertype = ntdevmode->dithertype; + + if (ntdevmode->private != NULL) + { + devmode->private=(uint8 *)malloc(devmode->driverextra*sizeof(uint8)); + memcpy(devmode->private, ntdevmode->private, devmode->driverextra); + } + + free_a_printer(printer, 2); +} + +/******************************************************************** + * construct_printer_info_2 + * fill a printer_info_2 struct + ********************************************************************/ +static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring servername) +{ + pstring chaine; + int count; + DEVICEMODE *devmode; + NT_PRINTER_INFO_LEVEL ntprinter; + + print_queue_struct *queue=NULL; + print_status_struct status; + bzero(&status, sizeof(status)); + count=get_printqueue(snum, 0, &queue, &status); + + if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) + { + return (False); + } + + snprintf(chaine, sizeof(chaine)-1, "\\\\%s", servername); + make_unistr(&(printer->servername), chaine); /* servername*/ + + snprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", servername, ntprinter.info_2->printername); + make_unistr(&(printer->printername), chaine); /* printername*/ + + make_unistr(&(printer->sharename), lp_servicename(snum)); /* sharename */ + + make_unistr(&(printer->portname), lp_servicename(snum)); /* port */ + make_unistr(&(printer->drivername), ntprinter.info_2->drivername); /* drivername */ + + make_unistr(&(printer->comment), ntprinter.info_2->comment); /* comment */ + make_unistr(&(printer->location), ntprinter.info_2->location); /* location */ + make_unistr(&(printer->sepfile), ntprinter.info_2->sepfile); /* separator file */ + make_unistr(&(printer->printprocessor), ntprinter.info_2->printprocessor);/* print processor */ + make_unistr(&(printer->datatype), ntprinter.info_2->datatype); /* datatype */ + make_unistr(&(printer->parameters), ntprinter.info_2->parameters); /* parameters (of print processor) */ + + printer->attributes = PRINTER_ATTRIBUTE_SHARED \ + | PRINTER_ATTRIBUTE_NETWORK \ + | PRINTER_ATTRIBUTE_RAW_ONLY ; /* attributes */ + + printer->priority = ntprinter.info_2->priority; /* priority */ + printer->defaultpriority = ntprinter.info_2->default_priority; /* default priority */ + printer->starttime = ntprinter.info_2->starttime; /* starttime */ + printer->untiltime = ntprinter.info_2->untiltime; /* untiltime */ + printer->status = status.status; /* status */ + printer->cjobs = count; /* jobs */ + printer->averageppm = ntprinter.info_2->averageppm; /* average pages per minute */ + + devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE)); + ZERO_STRUCTP(devmode); + construct_dev_mode(devmode, snum, servername); + printer->devmode=devmode; + + return (True); +} + +/******************************************************************** + * enum_printer_info_1 + * glue between spoolss_reply_enumprinters and construct_printer_info_1 + ********************************************************************/ +static BOOL enum_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number) +{ + pstring servername; + + *printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1)); + DEBUG(4,("Allocated memory for ONE PRINTER_INFO_1 at [%p]\n", *printer)); + pstrcpy(servername, global_myname); + if (!construct_printer_info_1(*printer, snum, servername)) + { + free(*printer); + return (False); + } + else + { + return (True); + } +} + +/******************************************************************** + * enum_printer_info_2 + * glue between spoolss_reply_enumprinters and construct_printer_info_2 + ********************************************************************/ +static BOOL enum_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number) +{ + pstring servername; + + *printer=(PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2)); + DEBUG(4,("Allocated memory for ONE PRINTER_INFO_2 at [%p]\n", *printer)); + pstrcpy(servername, global_myname); + if (!construct_printer_info_2(*printer, snum, servername)) + { + free(*printer); + return (False); + } + else + { + return (True); + } +} + +/******************************************************************** + * api_spoolss_reply_enumprinters + * + * called from api_spoolss_enumprinters (see this to understand) + ********************************************************************/ +static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number) +{ + int snum; + int n_services=lp_numservices(); + *printers=NULL; + *number=0; + + for (snum=0;snumdevmode); + free(printers[number]); + } + } + free(printers); + } +} + +/**************************************************************************** +****************************************************************************/ +static void free_enum_printers_info(SPOOL_R_ENUMPRINTERS *r_u) +{ + DEBUG(4,("free_enum_printers_info: [%d] structs to free at level [%d]\n", r_u->returned, r_u->level)); + switch (r_u->level) + { + case 1: + free_enum_printers_info_1(r_u->printer.printers_1, r_u->returned); + break; + case 2: + free_enum_printers_info_2(r_u->printer.printers_2, r_u->returned); + break; + } +} + +/******************************************************************** + * api_spoolss_reply_enumprinters + * + * called from api_spoolss_enumprinters (see this to understand) + ********************************************************************/ +static void spoolss_reply_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *rdata) +{ + SPOOL_R_ENUMPRINTERS r_u; + + DEBUG(4,("Enumerating printers\n")); + + memcpy(r_u.servername.buffer,q_u->servername.buffer,2*q_u->servername.uni_str_len); + r_u.servername.buffer[q_u->servername.uni_str_len]=0x0000; + r_u.returned=0; + + switch (q_u->level) + { + case 1: + if ( (q_u->flags==PRINTER_ENUM_NAME) || (q_u->flags==PRINTER_ENUM_NETWORK) ) + /*if (is_a_printerserver(q_u->servername))*/ + enum_all_printers_info_1(&(r_u.printer.printers_1), &(r_u.returned) ); + /*else + enum_one_printer_info_1(&r_u);*/ + break; + case 2: + if ( (q_u->flags==PRINTER_ENUM_NAME) || (q_u->flags==PRINTER_ENUM_NETWORK) ) + /*if (is_a_printerserver(q_u->servername))*/ + enum_all_printers_info_2(&(r_u.printer.printers_2), &(r_u.returned) ); + /*else + enum_one_printer_info_2(&r_u);*/ + break; + case 3: /* doesn't exist */ + break; + case 4: /* can't, always on local machine */ + break; + case 5: + break; + + } + DEBUG(4,("%d printers enumerated\n", r_u.returned)); + r_u.offered=q_u->buffer.size; + r_u.level=q_u->level; + r_u.status=0x0000; + + spoolss_io_r_enumprinters("",&r_u,rdata,0); + free_enum_printers_info(&r_u); +} + +/******************************************************************** + * api_spoolss_enumprinters + * called from the spoolss dispatcher + * + ********************************************************************/ +static void api_spoolss_enumprinters(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_ENUMPRINTERS q_u; + + spoolss_io_q_enumprinters("", &q_u, data, 0); + + spoolss_reply_enumprinters(&q_u,rdata); +} + + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata) +{ + SPOOL_R_GETPRINTER r_u; + int snum; + pstring servername; + + pstrcpy(servername, global_myname); + + get_printer_snum(&(q_u->handle),&snum); + + switch (q_u->level) + { + case 0: + { + PRINTER_INFO_0 *printer; + + printer=(PRINTER_INFO_0 *)malloc(sizeof(PRINTER_INFO_0)); + + construct_printer_info_0(printer, snum, servername); + r_u.printer.info0=printer; + r_u.status=0x0000; + r_u.offered=q_u->offered; + r_u.level=q_u->level; + + spoolss_io_r_getprinter("",&r_u,rdata,0); + + free(printer); + + break; + } + case 1: + { + PRINTER_INFO_1 *printer; + + printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1)); + + construct_printer_info_1(printer, snum, servername); + + r_u.printer.info1=printer; + r_u.status=0x0000; + r_u.offered=q_u->offered; + r_u.level=q_u->level; + spoolss_io_r_getprinter("",&r_u,rdata,0); + + free(printer); + + break; + } + case 2: + { + PRINTER_INFO_2 *printer; + + printer=(PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2)); + construct_printer_info_2(printer, snum, servername); + + r_u.printer.info2=printer; + r_u.status=0x0000; + r_u.offered=q_u->offered; + r_u.level=q_u->level; + spoolss_io_r_getprinter("",&r_u,rdata,0); + + free(printer->devmode); + free(printer); + + break; + } + } +} + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static void api_spoolss_getprinter(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_GETPRINTER q_u; + + spoolss_io_q_getprinter("", &q_u, data, 0); + + spoolss_reply_getprinter(&q_u, rdata); +} + +/******************************************************************** + * construct_printer_driver_info_1 + * fill a construct_printer_driver_info_1 struct + ********************************************************************/ +static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, + NT_PRINTER_DRIVER_INFO_LEVEL driver, + pstring servername, fstring architecture) +{ + make_unistr( &(info->name), driver.info_3->name); +} + +static void construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, + pstring servername, fstring architecture) +{ + NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + + get_a_printer(&printer, 2, lp_servicename(snum) ); + get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); + + fill_printer_driver_info_1(info, driver, servername, architecture); + + free_a_printer_driver(driver, 3); + free_a_printer(printer, 2); +} + +/******************************************************************** + * construct_printer_driver_info_2 + * fill a printer_info_2 struct + ********************************************************************/ +static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, + NT_PRINTER_DRIVER_INFO_LEVEL driver, + pstring servername, fstring architecture) +{ + pstring where; + pstring temp_driverpath; + pstring temp_datafile; + pstring temp_configfile; + fstring short_archi; + + get_short_archi(short_archi,architecture); + + snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\", servername, short_archi); + + info->version=driver.info_3->cversion; + + make_unistr( &(info->name), driver.info_3->name ); + make_unistr( &(info->architecture), architecture ); + + snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "%s%s", where, + driver.info_3->driverpath); + make_unistr( &(info->driverpath), temp_driverpath ); + + snprintf(temp_datafile, sizeof(temp_driverpath)-1, "%s%s", where, + driver.info_3->datafile); + make_unistr( &(info->datafile), temp_datafile ); + + snprintf(temp_configfile, sizeof(temp_driverpath)-1, "%s%s", where, + driver.info_3->configfile); + make_unistr( &(info->configfile), temp_configfile ); +} + +/******************************************************************** + * construct_printer_driver_info_2 + * fill a printer_info_2 struct + ********************************************************************/ +static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, + pstring servername, fstring architecture) +{ + NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + + get_a_printer(&printer, 2, lp_servicename(snum) ); + get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); + + fill_printer_driver_info_2(info, driver, servername, architecture); + + free_a_printer_driver(driver, 3); + free_a_printer(printer, 2); +} + +/******************************************************************** + * construct_printer_info_3 + * fill a printer_info_3 struct + ********************************************************************/ +static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, + NT_PRINTER_DRIVER_INFO_LEVEL driver, + pstring servername, fstring architecture) +{ + pstring where; + pstring temp_driverpath; + pstring temp_datafile; + pstring temp_configfile; + pstring temp_helpfile; + fstring short_archi; + + get_short_archi(short_archi, architecture); + + snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\", servername, short_archi); + + info->version=driver.info_3->cversion; + + make_unistr( &(info->name), driver.info_3->name ); + make_unistr( &(info->architecture), architecture ); + + snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "%s%s", where, driver.info_3->driverpath); + make_unistr( &(info->driverpath), temp_driverpath ); + + snprintf(temp_datafile, sizeof(temp_datafile)-1, "%s%s", where, driver.info_3->datafile); + make_unistr( &(info->datafile), temp_datafile ); + + snprintf(temp_configfile, sizeof(temp_configfile)-1, "%s%s", where, driver.info_3->configfile); + make_unistr( &(info->configfile), temp_configfile ); + + snprintf(temp_helpfile, sizeof(temp_helpfile)-1, "%s%s", where, driver.info_3->helpfile); + make_unistr( &(info->helpfile), temp_helpfile ); + + make_unistr( &(info->monitorname), driver.info_3->monitorname ); + make_unistr( &(info->defaultdatatype), driver.info_3->defaultdatatype ); + + make_unistr( &(info->dependentfiles), "" ); +} + +/******************************************************************** + * construct_printer_info_3 + * fill a printer_info_3 struct + ********************************************************************/ +static void construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, + pstring servername, fstring architecture) +{ + NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + + get_a_printer(&printer, 2, lp_servicename(snum) ); + get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); + + fill_printer_driver_info_3(info, driver, servername, architecture); + + free_a_printer_driver(driver, 3); + free_a_printer(printer, 2); +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *rdata) +{ + SPOOL_R_GETPRINTERDRIVER2 r_u; + pstring servername; + fstring architecture; + int snum; + DRIVER_INFO_1 *info1=NULL; + DRIVER_INFO_2 *info2=NULL; + DRIVER_INFO_3 *info3=NULL; + + pstrcpy(servername, global_myname); + get_printer_snum(&(q_u->handle),&snum); + + r_u.offered=q_u->buf_size; + r_u.level=q_u->level; + r_u.status=0x0000; + + unistr2_to_ascii(architecture, &(q_u->architecture), sizeof(architecture) ); + + DEBUG(1,("spoolss_reply_getprinterdriver2:[%d]\n", q_u->level)); + + switch (q_u->level) + { + case 1: + { + info1=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1)); + construct_printer_driver_info_1(info1, snum, servername, architecture); + r_u.printer.info1=info1; + break; + } + case 2: + { + info2=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2)); + construct_printer_driver_info_2(info2, snum, servername, architecture); + r_u.printer.info2=info2; + break; + } + case 3: + { + info3=(DRIVER_INFO_3 *)malloc(sizeof(DRIVER_INFO_3)); + construct_printer_driver_info_3(info3, snum, servername, architecture); + r_u.printer.info3=info3; + break; + } + } + + spoolss_io_r_getprinterdriver2("",&r_u,rdata,0); + + if (info1!=NULL) free(info1); + if (info2!=NULL) free(info2); + if (info3!=NULL) free(info3); + +} + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static void api_spoolss_getprinterdriver2(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_GETPRINTERDRIVER2 q_u; + + spoolss_io_q_getprinterdriver2("", &q_u, data, 0); + + spoolss_reply_getprinterdriver2(&q_u, rdata); +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_startpageprinter(SPOOL_Q_STARTPAGEPRINTER *q_u, prs_struct *rdata) +{ + SPOOL_R_STARTPAGEPRINTER r_u; + int pnum = find_printer_index_by_hnd(&(q_u->handle)); + + if (OPEN_HANDLE(pnum)) + { + Printer[pnum].page_started=True; + r_u.status=0x0; + + spoolss_io_r_startpageprinter("",&r_u,rdata,0); + } + else + { + DEBUG(3,("Error in startpageprinter printer handle (pnum=%x)\n",pnum)); + } +} + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static void api_spoolss_startpageprinter(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_STARTPAGEPRINTER q_u; + + spoolss_io_q_startpageprinter("", &q_u, data, 0); + + spoolss_reply_startpageprinter(&q_u, rdata); +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_endpageprinter(SPOOL_Q_ENDPAGEPRINTER *q_u, prs_struct *rdata) +{ + SPOOL_R_ENDPAGEPRINTER r_u; + int pnum = find_printer_index_by_hnd(&(q_u->handle)); + + if (OPEN_HANDLE(pnum)) + { + Printer[pnum].page_started=False; + r_u.status=0x0; + + spoolss_io_r_endpageprinter("",&r_u,rdata,0); + } + else + { + DEBUG(3,("Error in endpageprinter printer handle (pnum=%x)\n",pnum)); + } +} + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static void api_spoolss_endpageprinter(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_ENDPAGEPRINTER q_u; + + spoolss_io_q_endpageprinter("", &q_u, data, 0); + + spoolss_reply_endpageprinter(&q_u, rdata); +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_startdocprinter(SPOOL_Q_STARTDOCPRINTER *q_u, prs_struct *rdata) +{ + SPOOL_R_STARTDOCPRINTER r_u; + int pnum = find_printer_index_by_hnd(&(q_u->handle)); + + if (OPEN_HANDLE(pnum)) + { + r_u.jobid=Printer[pnum].current_jobid; + r_u.status=0x0; + + spoolss_io_r_startdocprinter("",&r_u,rdata,0); + } + else + { + DEBUG(3,("Error in startdocprinter printer handle (pnum=%x)\n",pnum)); + } +} + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static void api_spoolss_startdocprinter(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_STARTDOCPRINTER q_u; + pstring fname; + pstring tempname; + int fd = -1; + int snum; + int pnum; + + /* decode the stream and fill the struct */ + spoolss_io_q_startdocprinter("", &q_u, data, 0); + + pnum = find_printer_index_by_hnd(&(q_u.handle)); + + if (OPEN_HANDLE(pnum)) + { + /* get the share number of the printer */ + get_printer_snum(&(q_u.handle),&snum); + + /* Create a temporary file in the printer spool directory + * and open it + */ + + slprintf(tempname,sizeof(tempname)-1, "%s/smb_print.XXXXXX",lp_pathname(snum)); + pstrcpy(fname, (char *)mktemp(tempname)); + + fd=open(fname, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR ); + DEBUG(4,("Temp spool file created: [%s]\n", fname)); + + Printer[pnum].current_jobid=fd; + pstrcpy(Printer[pnum].document_name,fname); + + unistr2_to_ascii(Printer[pnum].job_name, + &(q_u.doc_info_container.docinfo.doc_info_1.docname), + sizeof(Printer[pnum].job_name)); + + Printer[pnum].document_fd=fd; + Printer[pnum].document_started=True; + } + spoolss_reply_startdocprinter(&q_u, rdata); +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_enddocprinter(SPOOL_Q_ENDDOCPRINTER *q_u, prs_struct *rdata) +{ + SPOOL_R_ENDDOCPRINTER r_u; + int pnum = find_printer_index_by_hnd(&(q_u->handle)); + + if (OPEN_HANDLE(pnum)) + { + r_u.status=0x0; + + spoolss_io_r_enddocprinter("",&r_u,rdata,0); + } + else + { + DEBUG(3,("Error in enddocprinter printer handle (pnum=%x)\n",pnum)); + } +} + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static void api_spoolss_enddocprinter(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_ENDDOCPRINTER q_u; + int pnum; + int snum; + pstring filename; + pstring filename1; + pstring job_name; + pstring syscmd; + char *tstr; + + spoolss_io_q_enddocprinter("", &q_u, data, 0); + + *syscmd=0; + + pnum = find_printer_index_by_hnd(&(q_u.handle)); + + if (OPEN_HANDLE(pnum)) + { + Printer[pnum].document_started=False; + close(Printer[pnum].document_fd); + DEBUG(4,("Temp spool file closed, printing now ...\n")); + + pstrcpy(filename1, Printer[pnum].document_name); + pstrcpy(job_name, Printer[pnum].job_name); + + get_printer_snum(&(q_u.handle),&snum); + + /* copy the command into the buffer for extensive meddling. */ + StrnCpy(syscmd, lp_printcommand(snum), sizeof(pstring) - 1); + + /* look for "%s" in the string. If there is no %s, we cannot print. */ + if (!strstr(syscmd, "%s") && !strstr(syscmd, "%f")) + { + DEBUG(2,("WARNING! No placeholder for the filename in the print command for service %s!\n", SERVICE(snum))); + } + + if (strstr(syscmd,"%s")) + { + pstrcpy(filename,filename1); + string_sub(syscmd, "%s", filename); + } + + string_sub(syscmd, "%f", filename1); + + /* Does the service have a printername? If not, make a fake and empty */ + /* printer name. That way a %p is treated sanely if no printer */ + /* name was specified to replace it. This eventuality is logged. */ + tstr = lp_printername(snum); + if (tstr == NULL || tstr[0] == '\0') + { + DEBUG(3,( "No printer name - using %s.\n", SERVICE(snum))); + tstr = SERVICE(snum); + } + + string_sub(syscmd, "%p", tstr); + + /* If the lpr command support the 'Job' option replace here */ + string_sub(syscmd, "%j", job_name); + + if ( *syscmd != '\0') + { + int ret = smbrun(syscmd, NULL, False); + DEBUG(3,("Running the command `%s' gave %d\n", syscmd, ret)); + } + else + DEBUG(0,("Null print command?\n")); + + lpq_reset(snum); + } + + spoolss_reply_enddocprinter(&q_u, rdata); +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_writeprinter(SPOOL_Q_WRITEPRINTER *q_u, prs_struct *rdata) +{ + SPOOL_R_WRITEPRINTER r_u; + int pnum = find_printer_index_by_hnd(&(q_u->handle)); + + if (OPEN_HANDLE(pnum)) + { + r_u.buffer_written=Printer[pnum].document_lastwritten; + r_u.status=0x0; + + spoolss_io_r_writeprinter("",&r_u,rdata,0); + } + else + { + DEBUG(3,("Error in writeprinter printer handle (pnum=%x)\n",pnum)); + } +} + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static void api_spoolss_writeprinter(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_WRITEPRINTER q_u; + int pnum; + int fd; + int size; + spoolss_io_q_writeprinter("", &q_u, data, 0); + + pnum = find_printer_index_by_hnd(&(q_u.handle)); + + if (OPEN_HANDLE(pnum)) + { + fd=Printer[pnum].document_fd; + size=write(fd, q_u.buffer, q_u.buffer_size); + Printer[pnum].document_lastwritten=size; + } + + spoolss_reply_writeprinter(&q_u, rdata); +} + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static void control_printer(PRINTER_HND handle, uint32 command) +{ + int pnum; + int snum; + pnum = find_printer_index_by_hnd(&(handle)); + + if ( get_printer_snum(&handle, &snum) ) + { + /* + * status_printqueue requires a connection_struct + * + * anybody want to explain me what value it has here ??? + */ + + switch (command) + { + case PRINTER_CONTROL_PAUSE: + /* pause the printer here */ + status_printqueue(0, snum, LPSTAT_STOPPED); + break; + + case PRINTER_CONTROL_RESUME: + case PRINTER_CONTROL_UNPAUSE: + /* UN-pause the printer here */ + status_printqueue(0, snum, LPSTAT_OK); + break; + case PRINTER_CONTROL_PURGE: + /* Envoi des dragées FUCA dans l'imprimante */ + break; + } + } +} + +/******************************************************************** + * called by spoolss_api_setprinter + * when updating a printer description + ********************************************************************/ +static void update_printer(PRINTER_HND handle, uint32 level, + SPOOL_PRINTER_INFO_LEVEL info, DEVICEMODE *devmode) +{ + int pnum; + int snum; + NT_PRINTER_INFO_LEVEL printer; + NT_DEVICEMODE *nt_devmode; + + nt_devmode=NULL; + + DEBUG(8,("update_printer\n")); + + if (level!=2) + { + DEBUG(0,("Send a mail to samba-bugs@samba.org\n")); + DEBUGADD(0,("with the following message: update_printer: level!=2\n")); + return; + } + + pnum = find_printer_index_by_hnd(&handle); + + if ( get_printer_snum(&handle, &snum) ) + { + get_a_printer(&printer, level, lp_servicename(snum)); + + DEBUGADD(8,("Converting info_2 struct\n")); + convert_printer_info(info, &printer, level); + + if ((info.info_2)->devmode_ptr != 0) + { + /* we have a valid devmode + convert it and link it*/ + + /* the nt_devmode memory is already alloced + * while doing the get_a_printer call + * but the devmode private part is not + * it's done by convert_devicemode + */ + DEBUGADD(8,("Converting the devicemode struct\n")); + nt_devmode=printer.info_2->devmode; + + init_devicemode(nt_devmode); + + convert_devicemode(*devmode, nt_devmode); + + /* now clear the memory used in + * the RPC parsing routine + */ + if (devmode->private != NULL) + free(devmode->private); + free(devmode); + } + else + { + if (printer.info_2->devmode != NULL) + { + free(printer.info_2->devmode); + } + printer.info_2->devmode=NULL; + } + + add_a_printer(printer, level); + free_a_printer(printer, level); + } +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_setprinter(SPOOL_Q_SETPRINTER *q_u, prs_struct *rdata) +{ + SPOOL_R_SETPRINTER r_u; + + /* + Let's the sun shine !!! + Always respond everything is alright + */ + + r_u.status=0x0; + + spoolss_io_r_setprinter("",&r_u,rdata,0); +} + +/**************************************************************************** +****************************************************************************/ +static void api_spoolss_setprinter(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_SETPRINTER q_u; + int pnum; + spoolss_io_q_setprinter("", &q_u, data, 0); + + pnum = find_printer_index_by_hnd(&(q_u.handle)); + + if (OPEN_HANDLE(pnum)) + { + /* check the level */ + switch (q_u.level) + { + case 0: + control_printer(q_u.handle, q_u.command); + break; + case 2: + update_printer(q_u.handle, q_u.level, q_u.info, q_u.devmode); + break; + } + } + spoolss_reply_setprinter(&q_u, rdata); +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_fcpn(SPOOL_Q_FCPN *q_u, prs_struct *rdata) +{ + SPOOL_R_FCPN r_u; + + r_u.status=0x0; + + spoolss_io_r_fcpn("",&r_u,rdata,0); +} + +/**************************************************************************** +****************************************************************************/ +static void api_spoolss_fcpn(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_FCPN q_u; + + spoolss_io_q_fcpn("", &q_u, data, 0); + + spoolss_reply_fcpn(&q_u, rdata); +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_addjob(SPOOL_Q_ADDJOB *q_u, prs_struct *rdata) +{ + SPOOL_R_ADDJOB r_u; + + r_u.status=0x0; + + spoolss_io_r_addjob("",&r_u,rdata,0); +} + +/**************************************************************************** +****************************************************************************/ +static void api_spoolss_addjob(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_ADDJOB q_u; + + spoolss_io_q_addjob("", &q_u, data, 0); + + spoolss_reply_addjob(&q_u, rdata); +} + +/**************************************************************************** +****************************************************************************/ +static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, + int position, int snum) +{ + pstring temp_name; + + struct tm *t; + time_t unixdate = time(NULL); + + t=gmtime(&unixdate); + snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); + + job_info->jobid=queue->job; + make_unistr(&(job_info->printername), lp_servicename(snum)); + make_unistr(&(job_info->machinename), temp_name); + make_unistr(&(job_info->username), queue->user); + make_unistr(&(job_info->document), queue->file); + make_unistr(&(job_info->datatype), "RAW"); + make_unistr(&(job_info->text_status), ""); + job_info->status=queue->status; + job_info->priority=queue->priority; + job_info->position=position; + job_info->totalpages=0; + job_info->pagesprinted=0; + + make_systemtime(&(job_info->submitted), t); +} + +/**************************************************************************** +****************************************************************************/ +static void fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, + int position, int snum) +{ + pstring temp_name; + + struct tm *t; + time_t unixdate = time(NULL); + + t=gmtime(&unixdate); + snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); + + job_info->jobid=queue->job; + make_unistr(&(job_info->printername), lp_servicename(snum)); + make_unistr(&(job_info->machinename), temp_name); + make_unistr(&(job_info->username), queue->user); + make_unistr(&(job_info->document), queue->file); + make_unistr(&(job_info->notifyname), queue->user); + make_unistr(&(job_info->datatype), "RAW"); + make_unistr(&(job_info->printprocessor), "winprint"); + make_unistr(&(job_info->parameters), ""); + +/* here the devicemode should be filled up */ + + make_unistr(&(job_info->text_status), ""); + +/* and here the security descriptor */ + + job_info->status=queue->status; + job_info->priority=queue->priority; + job_info->position=position; + job_info->starttime=0; + job_info->untiltime=0; + job_info->totalpages=0; + job_info->size=queue->size; + make_systemtime(&(job_info->submitted), t); + job_info->timeelapsed=0; + job_info->pagesprinted=0; +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata) +{ + SPOOL_R_ENUMJOBS r_u; + int snum; + int count; + int i; + print_queue_struct *queue=NULL; + print_status_struct status; + JOB_INFO_1 *job_info_1=NULL; + JOB_INFO_2 *job_info_2=NULL; + + DEBUG(4,("spoolss_reply_enumjobs\n")); + + bzero(&status,sizeof(status)); + + r_u.offered=q_u->buf_size; + + + if (get_printer_snum(&(q_u->handle), &snum)) + { + count=get_printqueue(snum, 0, &queue, &status); + r_u.numofjobs=count; + + r_u.level=q_u->level; + + DEBUG(4,("count:[%d], status:[%d], [%s]\n", count, status.status, status.message)); + + switch (r_u.level) + { + case 1: + { + job_info_1=(JOB_INFO_1 *)malloc(count*sizeof(JOB_INFO_1)); + + for (i=0; ihandle), &snum)) + { + count=get_printqueue(snum, 0, &queue, &status); + while ( (ijobid == queue[i].job ) + { + found=True; + } + i++; + } + + if (found==True) + { + switch (q_u->command) + { + case JOB_CONTROL_CANCEL: + case JOB_CONTROL_DELETE: + { + del_printqueue(0, snum, q_u->jobid); + break; + } + case JOB_CONTROL_PAUSE: + { + status_printjob(0, snum, q_u->jobid, LPQ_PAUSED); + break; + } + case JOB_CONTROL_RESUME: + { + status_printjob(0, snum, q_u->jobid, LPQ_QUEUED); + break; + } + } + } + } + r_u.status=0x0; + spoolss_io_r_setjob("",&r_u,rdata,0); +} + +/**************************************************************************** +****************************************************************************/ +static void api_spoolss_setjob(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_SETJOB q_u; + + spoolss_io_q_setjob("", &q_u, data, 0); + + spoolss_reply_setjob(&q_u, rdata); +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *rdata) +{ + SPOOL_R_ENUMPRINTERDRIVERS r_u; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + int count; + int i; + fstring *list; + DRIVER_INFO_1 *driver_info_1=NULL; + DRIVER_INFO_2 *driver_info_2=NULL; + DRIVER_INFO_3 *driver_info_3=NULL; + fstring servername; + fstring architecture; + + DEBUG(4,("spoolss_reply_enumdrivers\n")); + fstrcpy(servername, global_myname); + + unistr2_to_ascii(architecture, &(q_u->environment), sizeof(architecture)); + count=get_ntdrivers(&list, architecture); + + DEBUGADD(4,("we have: [%d] drivers on archi [%s]\n",count, architecture)); + for (i=0; ibuf_size; + r_u.numofdrivers=count; + r_u.level=q_u->level; + + switch (r_u.level) + { + case 1: + { + driver_info_1=(DRIVER_INFO_1 *)malloc(count*sizeof(DRIVER_INFO_1)); + + for (i=0; iflag=list->flag; + make_unistr(&(form->name), list->name); + form->width=list->width; + form->length=list->length; + form->left=list->left; + form->top=list->top; + form->right=list->right; + form->bottom=list->bottom; +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_enumforms(SPOOL_Q_ENUMFORMS *q_u, prs_struct *rdata) +{ + SPOOL_R_ENUMFORMS r_u; + int count; + int i; + nt_forms_struct *list=NULL; + FORM_1 *forms_1=NULL; + + DEBUG(4,("spoolss_reply_enumforms\n")); + + count=get_ntforms(&list); + r_u.offered=q_u->buf_size; + r_u.numofforms=count; + r_u.level=q_u->level; + r_u.status=0x0; + + DEBUGADD(5,("Offered buffer size [%d]\n", r_u.offered)); + DEBUGADD(5,("Number of forms [%d]\n", r_u.numofforms)); + DEBUGADD(5,("Info level [%d]\n", r_u.level)); + + switch (r_u.level) + { + case 1: + { + forms_1=(FORM_1 *)malloc(count*sizeof(FORM_1)); + for (i=0; iport_name), name); + make_unistr(&(port->monitor_name), "Moniteur Local"); + make_unistr(&(port->description), "Local Port"); +#define PORT_TYPE_WRITE 1 + port->port_type=PORT_TYPE_WRITE; + port->reserved=0x0; +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_enumports(SPOOL_Q_ENUMPORTS *q_u, prs_struct *rdata) +{ + SPOOL_R_ENUMPORTS r_u; + int i=0; + PORT_INFO_2 *ports_2=NULL; + int n_services=lp_numservices(); + int snum; + + DEBUG(4,("spoolss_reply_enumports\n")); + + r_u.offered=q_u->buf_size; + r_u.level=q_u->level; + r_u.status=0x0; + + switch (r_u.level) + { + case 2: + { + ports_2=(PORT_INFO_2 *)malloc(n_services*sizeof(PORT_INFO_2)); + for (snum=0; snuminfo); + info2=info->info_2; + portname=&(info2->portname); + + r_u.status=0x0; /* everything is always nice in this world */ + + StrnCpy(server_name, global_myname, strlen(global_myname) ); + unistr2_to_ascii(share_name, portname, sizeof(share_name)-1); + + slprintf(ascii_name, sizeof(ascii_name)-1, "\\\\%s\\%s", + server_name, share_name); + + printer_open = open_printer_hnd(&(r_u.handle)); + set_printer_hnd_printertype(&(r_u.handle), ascii_name); + set_printer_hnd_printername(&(r_u.handle), ascii_name); + + spoolss_io_r_addprinterex("", &r_u, rdata, 0); +} + +/**************************************************************************** +****************************************************************************/ +static void api_spoolss_addprinterex(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ADDPRINTEREX q_u; + NT_PRINTER_INFO_LEVEL printer; + + /* read the stream and decode */ + spoolss_io_q_addprinterex("", &q_u, data, 0); + + /* NULLify info_2 here */ + /* don't put it in convert_printer_info as it's used also with non-NULL values */ + printer.info_2=NULL; + + /* convert from UNICODE to ASCII */ + convert_printer_info(q_u.info, &printer, q_u.level); + + /* write the ASCII on disk */ + add_a_printer(printer, q_u.level); + + spoolss_reply_addprinterex(&q_u, rdata); + /* free mem used in q_u and r_u */ + + /* free_add_printer(q_u, r_u); */ +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_addprinterdriver(SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *rdata) +{ + SPOOL_R_ADDPRINTERDRIVER r_u; + + r_u.status=0x0; /* everything is always nice in this world */ + + spoolss_io_r_addprinterdriver("", &r_u, rdata, 0); +} + +/**************************************************************************** +****************************************************************************/ +static void api_spoolss_addprinterdriver(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_ADDPRINTERDRIVER q_u; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + + spoolss_io_q_addprinterdriver("", &q_u, data, 0); + + convert_printer_driver_info(q_u.info, &driver, q_u.level); + + add_a_printer_driver(driver, q_u.level); + + spoolss_reply_addprinterdriver(&q_u, rdata); + /* free mem used in q_u and r_u */ +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_getprinterdriverdirectory(SPOOL_Q_GETPRINTERDRIVERDIR *q_u, prs_struct *rdata) +{ + SPOOL_R_GETPRINTERDRIVERDIR r_u; + pstring chaine; + pstring long_archi; + pstring archi; + + r_u.offered=q_u->buf_size; + r_u.level=q_u->level; + r_u.status=0x0; + + unistr2_to_ascii(long_archi, &(q_u->environment), sizeof(long_archi)-1); + get_short_archi(archi, long_archi); + + slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\print$\\%s", global_myname, archi); + + DEBUG(4,("printer driver directory: [%s]\n", chaine)); + + make_unistr(&(r_u.driver.driver_info_1.name), chaine); + + spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0); +} + +/**************************************************************************** +****************************************************************************/ +static void api_spoolss_getprinterdriverdirectory(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_GETPRINTERDRIVERDIR q_u; + + spoolss_io_q_getprinterdriverdir("", &q_u, data, 0); + + spoolss_reply_getprinterdriverdirectory(&q_u, rdata); +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *rdata) +{ + SPOOL_R_ENUMPRINTERDATA r_u; + NT_PRINTER_INFO_LEVEL printer; + + uint32 type; + fstring value; + uint8 *data; + + uint32 param_index; + uint32 biggest_valuesize; + uint32 biggest_datasize; + uint32 data_len; + + int pnum = find_printer_index_by_hnd(&(q_u->handle)); + int snum; + + DEBUG(5,("spoolss_reply_enumprinterdata\n")); + + if (OPEN_HANDLE(pnum)) + { + get_printer_snum(&(q_u->handle), &snum); + get_a_printer(&printer, 2, lp_servicename(snum)); + + /* The NT machine wants to know the biggest size of value and data */ + if ( (q_u->valuesize==0) && (q_u->datasize==0) ) + { + DEBUGADD(6,("Activating NT mega-hack to find sizes\n")); + + r_u.valuesize=0; + r_u.realvaluesize=0; + r_u.type=0; + r_u.datasize=0; + r_u.realdatasize=0; + + param_index=0; + biggest_valuesize=0; + biggest_datasize=0; + + while (get_specific_param_by_index(printer, 2, param_index, value, &data, &type, &data_len)) + { + if (strlen(value) > biggest_valuesize) biggest_valuesize=strlen(value); + if (data_len > biggest_datasize) biggest_datasize=data_len; + + param_index++; + } + + /* I wrote it, I didn't designed the protocol */ + SIVAL(&(r_u.value),0, 2*(biggest_valuesize+1) ); + r_u.data=(uint8 *)malloc(4*sizeof(uint8)); + SIVAL(r_u.data, 0, biggest_datasize ); + } + else + { + /* + * the value len is wrong in NT sp3 + * that's the number of bytes not the number of unicode chars + */ + + r_u.valuesize=q_u->valuesize; + r_u.datasize=q_u->datasize; + + if (get_specific_param_by_index(printer, 2, q_u->index, value, &data, &type, &data_len)) + { + make_unistr(&(r_u.value), value); + r_u.data=data; + + r_u.type=type; + + /* the length are in bytes including leading NULL */ + r_u.realvaluesize=2*(strlen(value)+1); + r_u.realdatasize=data_len; + + r_u.status=0; + } + else + { + r_u.valuesize=0; + r_u.realvaluesize=0; + r_u.datasize=0; + r_u.realdatasize=0; + r_u.type=0; + r_u.status=0x0103; /* ERROR_NO_MORE_ITEMS */ + } + } + + free_a_printer(printer, 2); + } + spoolss_io_r_enumprinterdata("", &r_u, rdata, 0); + free(r_u.data); +} + +/**************************************************************************** +****************************************************************************/ +static void api_spoolss_enumprinterdata(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_ENUMPRINTERDATA q_u; + + spoolss_io_q_enumprinterdata("", &q_u, data, 0); + + spoolss_reply_enumprinterdata(&q_u, rdata); +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *rdata) +{ + SPOOL_R_SETPRINTERDATA r_u; + NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_PARAM *param = NULL; + + int pnum=0; + int snum=0; + + DEBUG(5,("spoolss_reply_setprinterdata\n")); + + pnum = find_printer_index_by_hnd(&(q_u->handle)); + + if (OPEN_HANDLE(pnum)) + { + get_printer_snum(&(q_u->handle), &snum); + get_a_printer(&printer, 2, lp_servicename(snum)); + convert_specific_param(¶m, q_u->value , q_u->type, q_u->data, q_u->real_len); + + unlink_specific_param_if_exist(printer.info_2, param); + + add_a_specific_param(printer.info_2, param); + + add_a_printer(printer, 2); + + free_a_printer(printer, 2); + } + + r_u.status = 0x0; + spoolss_io_r_setprinterdata("", &r_u, rdata, 0); +} + +/**************************************************************************** +****************************************************************************/ +static void api_spoolss_setprinterdata(uint16 vuid, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_SETPRINTERDATA q_u; + + spoolss_io_q_setprinterdata("", &q_u, data, 0); + + spoolss_reply_setprinterdata(&q_u, rdata); + + free(q_u.data); +} + +/******************************************************************* +\pipe\spoolss commands +********************************************************************/ +struct api_struct api_spoolss_cmds[] = +{ + {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer }, + {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata }, + {"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter }, + {"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex }, + {"SPOOLSS_RFNPCNEX", SPOOLSS_RFNPCNEX, api_spoolss_rfnpcnex }, + {"SPOOLSS_ENUMPRINTERS", SPOOLSS_ENUMPRINTERS, api_spoolss_enumprinters }, + {"SPOOLSS_GETPRINTER", SPOOLSS_GETPRINTER, api_spoolss_getprinter }, + {"SPOOLSS_GETPRINTERDRIVER2", SPOOLSS_GETPRINTERDRIVER2, api_spoolss_getprinterdriver2 }, + {"SPOOLSS_STARTPAGEPRINTER", SPOOLSS_STARTPAGEPRINTER, api_spoolss_startpageprinter }, + {"SPOOLSS_ENDPAGEPRINTER", SPOOLSS_ENDPAGEPRINTER, api_spoolss_endpageprinter }, + {"SPOOLSS_STARTDOCPRINTER", SPOOLSS_STARTDOCPRINTER, api_spoolss_startdocprinter }, + {"SPOOLSS_ENDDOCPRINTER", SPOOLSS_ENDDOCPRINTER, api_spoolss_enddocprinter }, + {"SPOOLSS_WRITEPRINTER", SPOOLSS_WRITEPRINTER, api_spoolss_writeprinter }, + {"SPOOLSS_SETPRINTER", SPOOLSS_SETPRINTER, api_spoolss_setprinter }, + {"SPOOLSS_FCPN", SPOOLSS_FCPN, api_spoolss_fcpn }, + {"SPOOLSS_ADDJOB", SPOOLSS_ADDJOB, api_spoolss_addjob }, + {"SPOOLSS_ENUMJOBS", SPOOLSS_ENUMJOBS, api_spoolss_enumjobs }, + {"SPOOLSS_SCHEDULEJOB", SPOOLSS_SCHEDULEJOB, api_spoolss_schedulejob }, + {"SPOOLSS_SETJOB", SPOOLSS_SETJOB, api_spoolss_setjob }, + {"SPOOLSS_ENUMFORMS", SPOOLSS_ENUMFORMS, api_spoolss_enumforms }, + {"SPOOLSS_ENUMPORTS", SPOOLSS_ENUMPORTS, api_spoolss_enumports }, + {"SPOOLSS_ENUMPRINTERDRIVERS", SPOOLSS_ENUMPRINTERDRIVERS, api_spoolss_enumprinterdrivers }, + {"SPOOLSS_ADDPRINTEREX", SPOOLSS_ADDPRINTEREX, api_spoolss_addprinterex }, + {"SPOOLSS_ADDPRINTERDRIVER", SPOOLSS_ADDPRINTERDRIVER, api_spoolss_addprinterdriver }, + {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory }, + {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata }, + {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata }, + { NULL, 0, NULL } +}; + +/******************************************************************* +receives a spoolss pipe and responds. +********************************************************************/ +BOOL api_spoolss_rpc(pipes_struct *p, prs_struct *data) +{ + return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds, data); +} + -- cgit From be552ca3504ebd98da37e70bac1f10b248cf860b Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 27 Apr 1999 10:43:32 +0000 Subject: rpc_parse/parse_misc.c : defined a new BUFFER5 struct include/ntdomain.h : added rpc_spoolss.h include statement include/proto.h include/rpc_dce.h : added definition of RPC_ALTER_CONTEXT request & reply param/loadparm.c : 2 new options for NT printing support and some changes to initial values in the LPRNG case. rpc_parse/parse_prs.c : added prs_uint16s() rpc_parse/parse_rpc.c : added SYNT_SPOOLSS_V1 and code for the alter-context support. rpc_server/srv_pipe.c : alter-context support smbd/nttrans.c smbd/server.c include/rpc_misc.h Makefile.in include/smb.h Jean Francois (This used to be commit 4c515804b70254248e378a3f90f47e4c32639d29) --- source3/rpc_server/srv_pipe.c | 51 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 54d26650e9..466d56b67a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -360,6 +360,7 @@ static struct api_cmd api_fd_commands[] = { "svcctl", "ntsvcs", api_svcctl_rpc }, { "NETLOGON", "lsass", api_netlog_rpc }, { "winreg", "winreg", api_reg_rpc }, + { "spoolss", "spoolss", api_spoolss_rpc }, { NULL, NULL, NULL } }; @@ -383,7 +384,7 @@ static BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *pd) return api_pipe_ntlmssp(p, pd); } -static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) +static BOOL api_pipe_bind_and_alt_req(pipes_struct *p, prs_struct *pd, enum RPC_PKT_TYPE pkt_type) { uint16 assoc_gid; fstring ack_pipe_name; @@ -435,9 +436,29 @@ static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) } } - /* name has to be \PIPE\xxxxx */ - fstrcpy(ack_pipe_name, "\\PIPE\\"); - fstrcat(ack_pipe_name, p->pipe_srv_name); + switch (pkt_type) + { + case RPC_BINDACK: + { + /* name has to be \PIPE\xxxxx */ + fstrcpy(ack_pipe_name, "\\PIPE\\"); + fstrcat(ack_pipe_name, p->pipe_srv_name); + break; + } + case RPC_ALTCONTRESP: + { + /* secondary address CAN be NULL + * as the specs says it's ignored. + * It MUST NULL to have the spoolss working. + */ + fstrcpy(ack_pipe_name, ""); + break; + } + default: + { + return False; + } + } DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); @@ -505,7 +526,7 @@ static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) /*** then do the header, now we know the length ***/ /***/ - make_rpc_hdr(&p->hdr, RPC_BINDACK, RPC_FLG_FIRST | RPC_FLG_LAST, + make_rpc_hdr(&p->hdr, pkt_type, RPC_FLG_FIRST | RPC_FLG_LAST, p->hdr.call_id, p->rdata.offset + p->rverf.offset + p->rauth.offset + p->rntlm.offset + 0x10, p->rauth.offset + p->rntlm.offset); @@ -534,6 +555,21 @@ static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) return True; } +/* + * The RPC Alter-Context call is used only by the spoolss pipe + * simply because there is a bug (?) in the MS unmarshalling code + * or in the marshalling code. If it's in the later, then Samba + * have the same bug. + */ +static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) +{ + return api_pipe_bind_and_alt_req(p, pd, RPC_BINDACK); +} + +static BOOL api_pipe_alt_req(pipes_struct *p, prs_struct *pd) +{ + return api_pipe_bind_and_alt_req(p, pd, RPC_ALTCONTRESP); +} static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) { @@ -635,6 +671,11 @@ BOOL rpc_command(pipes_struct *p, prs_struct *pd) reply = api_pipe_bind_req(p, pd); break; } + case RPC_ALTCONT: + { + reply = api_pipe_alt_req(p, pd); + break; + } case RPC_REQUEST: { if (p->ntlmssp_auth && !p->ntlmssp_validated) -- cgit From 4e5bf481fba36655e8fc8e04f6f67ba17dcb9844 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 3 May 1999 22:04:02 +0000 Subject: last part of RPC api change. and of rpcclient eventlog funtion Jean Francois (This used to be commit 7fc8659e83bf0269df297016beac6793ff0bdf32) --- source3/rpc_server/srv_lsa.c | 16 +-- source3/rpc_server/srv_netlog.c | 42 +++---- source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_reg.c | 8 +- source3/rpc_server/srv_samr.c | 74 ++++++------ source3/rpc_server/srv_spoolss.c | 253 ++++++++++++++++++++------------------- source3/rpc_server/srv_srvsvc.c | 12 +- source3/rpc_server/srv_svcctl.c | 12 +- source3/rpc_server/srv_wkssvc.c | 2 +- 9 files changed, 216 insertions(+), 205 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 61aac58e62..d8a74d627b 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -435,7 +435,7 @@ static void lsa_reply_lookup_names(prs_struct *rdata, /*************************************************************************** api_lsa_open_policy ***************************************************************************/ -static void api_lsa_open_policy2( uint16 vuid, prs_struct *data, +static void api_lsa_open_policy2( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { LSA_Q_OPEN_POL2 q_o; @@ -454,7 +454,7 @@ static void api_lsa_open_policy2( uint16 vuid, prs_struct *data, /*************************************************************************** api_lsa_open_policy ***************************************************************************/ -static void api_lsa_open_policy( uint16 vuid, prs_struct *data, +static void api_lsa_open_policy( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { LSA_Q_OPEN_POL q_o; @@ -473,7 +473,7 @@ static void api_lsa_open_policy( uint16 vuid, prs_struct *data, /*************************************************************************** api_lsa_enum_trust_dom ***************************************************************************/ -static void api_lsa_enum_trust_dom( uint16 vuid, prs_struct *data, +static void api_lsa_enum_trust_dom( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { LSA_Q_ENUM_TRUST_DOM q_e; @@ -490,7 +490,7 @@ static void api_lsa_enum_trust_dom( uint16 vuid, prs_struct *data, /*************************************************************************** api_lsa_query_info ***************************************************************************/ -static void api_lsa_query_info( uint16 vuid, prs_struct *data, +static void api_lsa_query_info( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { LSA_Q_QUERY_INFO q_i; @@ -532,7 +532,7 @@ static void api_lsa_query_info( uint16 vuid, prs_struct *data, /*************************************************************************** api_lsa_lookup_sids ***************************************************************************/ -static void api_lsa_lookup_sids( uint16 vuid, prs_struct *data, +static void api_lsa_lookup_sids( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { LSA_Q_LOOKUP_SIDS q_l; @@ -548,7 +548,7 @@ static void api_lsa_lookup_sids( uint16 vuid, prs_struct *data, /*************************************************************************** api_lsa_lookup_names ***************************************************************************/ -static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, +static void api_lsa_lookup_names( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { LSA_Q_LOOKUP_NAMES q_l; @@ -565,7 +565,7 @@ static void api_lsa_lookup_names( uint16 vuid, prs_struct *data, /*************************************************************************** api_lsa_close ***************************************************************************/ -static void api_lsa_close( uint16 vuid, prs_struct *data, +static void api_lsa_close( pipes_struct *p, prs_struct *data, prs_struct *rdata) { /* XXXX this is NOT good */ @@ -590,7 +590,7 @@ static void api_lsa_close( uint16 vuid, prs_struct *data, /*************************************************************************** api_lsa_open_secret ***************************************************************************/ -static void api_lsa_open_secret( uint16 vuid, prs_struct *data, +static void api_lsa_open_secret( pipes_struct *p, prs_struct *data, prs_struct *rdata) { /* XXXX this is NOT good */ diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index c84e91f643..44ad4fd064 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -310,7 +310,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) /************************************************************************* api_net_req_chal: *************************************************************************/ -static void api_net_req_chal( uint16 vuid, +static void api_net_req_chal( pipes_struct *p, prs_struct *data, prs_struct *rdata) { @@ -322,9 +322,9 @@ static void api_net_req_chal( uint16 vuid, user_struct *vuser; - DEBUG(5,("api_net_req_chal(%d): vuid %d\n", __LINE__, (int)vuid)); + DEBUG(5,("api_net_req_chal(%d): vuid %d\n", __LINE__, (int)p->vuid)); - if ((vuser = get_valid_user_struct(vuid)) == NULL) + if ((vuser = get_valid_user_struct(p->vuid)) == NULL) return; /* grab the challenge... */ @@ -370,7 +370,7 @@ static void api_net_req_chal( uint16 vuid, /************************************************************************* api_net_auth_2: *************************************************************************/ -static void api_net_auth_2( uint16 vuid, +static void api_net_auth_2( pipes_struct *p, prs_struct *data, prs_struct *rdata) { @@ -382,7 +382,7 @@ static void api_net_auth_2( uint16 vuid, user_struct *vuser; - if ((vuser = get_valid_user_struct(vuid)) == NULL) + if ((vuser = get_valid_user_struct(p->vuid)) == NULL) return; srv_time.time = 0; @@ -415,7 +415,7 @@ static void api_net_auth_2( uint16 vuid, /************************************************************************* api_net_srv_pwset: *************************************************************************/ -static void api_net_srv_pwset( uint16 vuid, +static void api_net_srv_pwset( pipes_struct *p, prs_struct *data, prs_struct *rdata) { @@ -427,7 +427,7 @@ static void api_net_srv_pwset( uint16 vuid, BOOL ret; user_struct *vuser; - if ((vuser = get_valid_user_struct(vuid)) == NULL) + if ((vuser = get_valid_user_struct(p->vuid)) == NULL) return; /* grab the challenge and encrypted password ... */ @@ -497,9 +497,9 @@ static void api_net_srv_pwset( uint16 vuid, /************************************************************************* api_net_sam_logoff: *************************************************************************/ -static void api_net_sam_logoff( uint16 vuid, - prs_struct *data, - prs_struct *rdata) +static void api_net_sam_logoff( pipes_struct *p, + prs_struct *data, + prs_struct *rdata) { NET_Q_SAM_LOGOFF q_l; NET_ID_INFO_CTR ctr; @@ -508,7 +508,7 @@ static void api_net_sam_logoff( uint16 vuid, user_struct *vuser; - if ((vuser = get_valid_user_struct(vuid)) == NULL) + if ((vuser = get_valid_user_struct(p->vuid)) == NULL) return; /* the DOM_ID_INFO_1 structure is a bit big. plus we might want to @@ -532,16 +532,16 @@ static void api_net_sam_logoff( uint16 vuid, /************************************************************************* api_net_sam_sync: *************************************************************************/ -static void api_net_sam_sync( uint16 vuid, - prs_struct *data, - prs_struct *rdata) +static void api_net_sam_sync( pipes_struct *p, + prs_struct *data, + prs_struct *rdata) { NET_Q_SAM_SYNC q_s; DOM_CRED srv_creds; user_struct *vuser; uint32 status = 0x0; - if ((vuser = get_valid_user_struct(vuid)) == NULL) + if ((vuser = get_valid_user_struct(p->vuid)) == NULL) return; /* grab the challenge... */ @@ -671,7 +671,7 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, /************************************************************************* api_net_sam_logon: *************************************************************************/ -static void api_net_sam_logon( uint16 vuid, +static void api_net_sam_logon( pipes_struct *p, prs_struct *data, prs_struct *rdata) { @@ -704,7 +704,7 @@ static void api_net_sam_logon( uint16 vuid, user_struct *vuser = NULL; - if ((vuser = get_valid_user_struct(vuid)) == NULL) + if ((vuser = get_valid_user_struct(p->vuid)) == NULL) return; q_l.sam_id.ctr = &ctr; @@ -890,9 +890,9 @@ static void api_net_sam_logon( uint16 vuid, /************************************************************************* api_net_trust_dom_list: *************************************************************************/ -static void api_net_trust_dom_list( uint16 vuid, - prs_struct *data, - prs_struct *rdata) +static void api_net_trust_dom_list( pipes_struct *p, + prs_struct *data, + prs_struct *rdata) { NET_Q_TRUST_DOM_LIST q_t; @@ -920,7 +920,7 @@ static void api_net_trust_dom_list( uint16 vuid, /************************************************************************* api_net_logon_ctrl2: *************************************************************************/ -static void api_net_logon_ctrl2( uint16 vuid, +static void api_net_logon_ctrl2( pipes_struct *p, prs_struct *data, prs_struct *rdata) { diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 466d56b67a..d98fecbc1f 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -739,7 +739,7 @@ static BOOL api_rpc_command(pipes_struct *p, prs_init(&p->rdata, 1024, 4, SAFETY_MARGIN, False); /* do the actual command */ - api_rpc_cmds[fn_num].fn(p->vuid, data, &(p->rdata)); + api_rpc_cmds[fn_num].fn(p, data, &(p->rdata)); if (p->rdata.data == NULL || p->rdata.offset == 0) { diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index d9aedc86bd..ea53f2ee2b 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -61,7 +61,7 @@ static void reg_reply_close(REG_Q_CLOSE *q_r, /******************************************************************* api_reg_close ********************************************************************/ -static void api_reg_close( uint16 vuid, prs_struct *data, +static void api_reg_close( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { REG_Q_CLOSE q_r; @@ -100,7 +100,7 @@ static void reg_reply_open(REG_Q_OPEN_HKLM *q_r, /******************************************************************* api_reg_open ********************************************************************/ -static void api_reg_open( uint16 vuid, prs_struct *data, +static void api_reg_open( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { REG_Q_OPEN_HKLM q_u; @@ -164,7 +164,7 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, /******************************************************************* api_reg_open_entry ********************************************************************/ -static void api_reg_open_entry( uint16 vuid, prs_struct *data, +static void api_reg_open_entry( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { REG_Q_OPEN_ENTRY q_u; @@ -209,7 +209,7 @@ static void reg_reply_info(REG_Q_INFO *q_u, /******************************************************************* api_reg_info ********************************************************************/ -static void api_reg_info( uint16 vuid, prs_struct *data, +static void api_reg_info( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { REG_Q_INFO q_u; diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 008ad57c4d..257f8869f7 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -145,7 +145,7 @@ static void samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, /******************************************************************* api_samr_close_hnd ********************************************************************/ -static void api_samr_close_hnd( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_close_hnd( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_CLOSE_HND q_u; samr_io_q_close_hnd("", &q_u, data, 0); @@ -200,7 +200,7 @@ static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, /******************************************************************* api_samr_open_domain ********************************************************************/ -static void api_samr_open_domain( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_open_domain( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_DOMAIN q_u; samr_io_q_open_domain("", &q_u, data, 0); @@ -243,7 +243,7 @@ static void samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, /******************************************************************* api_samr_unknown_2c ********************************************************************/ -static void api_samr_unknown_2c( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_unknown_2c( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_2C q_u; samr_io_q_unknown_2c("", &q_u, data, 0); @@ -312,7 +312,7 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, /******************************************************************* api_samr_unknown_3 ********************************************************************/ -static void api_samr_unknown_3( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_unknown_3( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_3 q_u; samr_io_q_unknown_3("", &q_u, data, 0); @@ -370,7 +370,7 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, /******************************************************************* api_samr_enum_dom_users ********************************************************************/ -static void api_samr_enum_dom_users( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_enum_dom_users( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_USERS q_e; samr_io_q_enum_dom_users("", &q_e, data, 0); @@ -429,7 +429,7 @@ static void samr_reply_add_groupmem(SAMR_Q_ADD_GROUPMEM *q_u, /******************************************************************* api_samr_add_groupmem ********************************************************************/ -static void api_samr_add_groupmem( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_add_groupmem( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_ADD_GROUPMEM q_e; samr_io_q_add_groupmem("", &q_e, data, 0); @@ -487,7 +487,7 @@ static void samr_reply_del_groupmem(SAMR_Q_DEL_GROUPMEM *q_u, /******************************************************************* api_samr_del_groupmem ********************************************************************/ -static void api_samr_del_groupmem( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_del_groupmem( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_DEL_GROUPMEM q_e; samr_io_q_del_groupmem("", &q_e, data, 0); @@ -553,7 +553,7 @@ static void samr_reply_add_aliasmem(SAMR_Q_ADD_ALIASMEM *q_u, /******************************************************************* api_samr_add_aliasmem ********************************************************************/ -static void api_samr_add_aliasmem( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_add_aliasmem( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_ADD_ALIASMEM q_e; samr_io_q_add_aliasmem("", &q_e, data, 0); @@ -619,7 +619,7 @@ static void samr_reply_del_aliasmem(SAMR_Q_DEL_ALIASMEM *q_u, /******************************************************************* api_samr_del_aliasmem ********************************************************************/ -static void api_samr_del_aliasmem( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_del_aliasmem( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_DEL_ALIASMEM q_e; samr_io_q_del_aliasmem("", &q_e, data, 0); @@ -683,7 +683,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, /******************************************************************* api_samr_enum_dom_aliases ********************************************************************/ -static void api_samr_enum_dom_groups( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_enum_dom_groups( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_GROUPS q_e; @@ -768,7 +768,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, /******************************************************************* api_samr_enum_dom_aliases ********************************************************************/ -static void api_samr_enum_dom_aliases( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_enum_dom_aliases( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_ALIASES q_e; @@ -940,7 +940,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, /******************************************************************* api_samr_query_dispinfo ********************************************************************/ -static void api_samr_query_dispinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_dispinfo( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_DISPINFO q_e; @@ -1002,7 +1002,7 @@ static void samr_reply_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP *q_u, /******************************************************************* api_samr_delete_dom_group ********************************************************************/ -static void api_samr_delete_dom_group( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_delete_dom_group( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_DELETE_DOM_GROUP q_u; samr_io_q_delete_dom_group("", &q_u, data, 0); @@ -1097,7 +1097,7 @@ static void samr_reply_query_groupmem(SAMR_Q_QUERY_GROUPMEM *q_u, /******************************************************************* api_samr_query_groupmem ********************************************************************/ -static void api_samr_query_groupmem( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_groupmem( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_GROUPMEM q_u; samr_io_q_query_groupmem("", &q_u, data, 0); @@ -1157,7 +1157,7 @@ static void samr_reply_query_groupinfo(SAMR_Q_QUERY_GROUPINFO *q_u, /******************************************************************* api_samr_query_groupinfo ********************************************************************/ -static void api_samr_query_groupinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_groupinfo( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_GROUPINFO q_e; samr_io_q_query_groupinfo("", &q_e, data, 0); @@ -1211,7 +1211,7 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, /******************************************************************* api_samr_query_aliasinfo ********************************************************************/ -static void api_samr_query_aliasinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_aliasinfo( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_ALIASINFO q_e; samr_io_q_query_aliasinfo("", &q_e, data, 0); @@ -1332,7 +1332,7 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, /******************************************************************* api_samr_query_useraliases ********************************************************************/ -static void api_samr_query_useraliases( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_useraliases( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERALIASES q_u; samr_io_q_query_useraliases("", &q_u, data, 0); @@ -1393,7 +1393,7 @@ static void samr_reply_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS *q_u, /******************************************************************* api_samr_delete_dom_alias ********************************************************************/ -static void api_samr_delete_dom_alias( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_delete_dom_alias( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_DELETE_DOM_ALIAS q_u; samr_io_q_delete_dom_alias("", &q_u, data, 0); @@ -1488,7 +1488,7 @@ static void samr_reply_query_aliasmem(SAMR_Q_QUERY_ALIASMEM *q_u, /******************************************************************* api_samr_query_aliasmem ********************************************************************/ -static void api_samr_query_aliasmem( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_aliasmem( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_ALIASMEM q_u; samr_io_q_query_aliasmem("", &q_u, data, 0); @@ -1560,7 +1560,7 @@ static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, /******************************************************************* api_samr_lookup_names ********************************************************************/ -static void api_samr_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_lookup_names( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_NAMES q_u; samr_io_q_lookup_names("", &q_u, data, 0); @@ -1601,7 +1601,7 @@ static void samr_reply_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u, /******************************************************************* api_samr_chgpasswd_user ********************************************************************/ -static void api_samr_chgpasswd_user( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_chgpasswd_user( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_CHGPASSWD_USER q_u; samr_io_q_chgpasswd_user("", &q_u, data, 0); @@ -1630,7 +1630,7 @@ static void samr_reply_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, /******************************************************************* api_samr_unknown_38 ********************************************************************/ -static void api_samr_unknown_38( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_unknown_38( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_38 q_u; samr_io_q_unknown_38("", &q_u, data, 0); @@ -1695,7 +1695,7 @@ static void samr_reply_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u, /******************************************************************* api_samr_lookup_rids ********************************************************************/ -static void api_samr_lookup_rids( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_lookup_rids( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_RIDS q_u; samr_io_q_lookup_rids("", &q_u, data, 0); @@ -1765,7 +1765,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, /******************************************************************* api_samr_open_user ********************************************************************/ -static void api_samr_open_user( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_open_user( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_USER q_u; samr_io_q_open_user("", &q_u, data, 0); @@ -2019,7 +2019,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) /******************************************************************* api_samr_query_userinfo ********************************************************************/ -static void api_samr_query_userinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_userinfo( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERINFO q_u; samr_io_q_query_userinfo("", &q_u, data, 0); @@ -2096,9 +2096,9 @@ static void samr_reply_set_userinfo(SAMR_Q_SET_USERINFO *q_u, /******************************************************************* api_samr_set_userinfo ********************************************************************/ -static void api_samr_set_userinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_set_userinfo( pipes_struct *p, prs_struct *data, prs_struct *rdata) { - user_struct *vuser = get_valid_user_struct(vuid); + user_struct *vuser = get_valid_user_struct(p->vuid); SAMR_Q_SET_USERINFO q_u; ZERO_STRUCT(q_u); @@ -2191,7 +2191,7 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, /******************************************************************* api_samr_query_usergroups ********************************************************************/ -static void api_samr_query_usergroups( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_usergroups( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERGROUPS q_u; samr_io_q_query_usergroups("", &q_u, data, 0); @@ -2302,7 +2302,7 @@ static void samr_reply_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS *q_u, /******************************************************************* api_samr_create_dom_alias ********************************************************************/ -static void api_samr_create_dom_alias( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_create_dom_alias( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_CREATE_DOM_ALIAS q_u; samr_io_q_create_dom_alias("", &q_u, data, 0); @@ -2414,7 +2414,7 @@ static void samr_reply_create_dom_group(SAMR_Q_CREATE_DOM_GROUP *q_u, /******************************************************************* api_samr_create_dom_group ********************************************************************/ -static void api_samr_create_dom_group( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_create_dom_group( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_CREATE_DOM_GROUP q_u; samr_io_q_create_dom_group("", &q_u, data, 0); @@ -2506,7 +2506,7 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, /******************************************************************* api_samr_query_dom_info ********************************************************************/ -static void api_samr_query_dom_info( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_query_dom_info( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_DOMAIN_INFO q_e; samr_io_q_query_dom_info("", &q_e, data, 0); @@ -2612,7 +2612,7 @@ static void samr_reply_create_user(SAMR_Q_CREATE_USER *q_u, /******************************************************************* api_samr_create_user ********************************************************************/ -static void api_samr_create_user( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_create_user( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_CREATE_USER q_u; @@ -2666,7 +2666,7 @@ static void samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, /******************************************************************* api_samr_connect_anon ********************************************************************/ -static void api_samr_connect_anon( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_connect_anon( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_CONNECT_ANON q_u; samr_io_q_connect_anon("", &q_u, data, 0); @@ -2715,7 +2715,7 @@ static void samr_reply_connect(SAMR_Q_CONNECT *q_u, /******************************************************************* api_samr_connect ********************************************************************/ -static void api_samr_connect( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_connect( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_CONNECT q_u; samr_io_q_connect("", &q_u, data, 0); @@ -2781,7 +2781,7 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, /******************************************************************* api_samr_open_alias ********************************************************************/ -static void api_samr_open_alias( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_open_alias( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_ALIAS q_u; @@ -2828,7 +2828,7 @@ static void samr_reply_open_group(SAMR_Q_OPEN_GROUP *q_u, /******************************************************************* api_samr_open_group ********************************************************************/ -static void api_samr_open_group( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_open_group( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_GROUP q_u; @@ -2887,7 +2887,7 @@ static void samr_reply_lookup_domain(SAMR_Q_LOOKUP_DOMAIN *q_u, /******************************************************************* api_samr_lookup_domain ********************************************************************/ -static void api_samr_lookup_domain( uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_samr_lookup_domain( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_DOMAIN q_u; samr_io_q_lookup_domain("", &q_u, data, 0); diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 52b60c5017..5b3ea4502a 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -4,7 +4,7 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1998, * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, - * Copyright (C) Jean François Micouleau 1998. + * Copyright (C) Jean François Micouleau 1998-1999. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -269,6 +269,7 @@ static BOOL set_printer_hnd_printername(PRINTER_HND *hnd, char *printername) { DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); strncpy(Printer[pnum].dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); + free_a_printer(printer, 2); return True; break; } @@ -413,7 +414,7 @@ static void spoolss_reply_open_printer(SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *rd * * called from the spoolss dispatcher ********************************************************************/ -static void api_spoolss_open_printer(uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_spoolss_open_printer(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_OPEN_PRINTER q_u; @@ -516,7 +517,7 @@ static BOOL getprinterdata_printer(PRINTER_HND *handle, fstring value, uint32 si NT_PRINTER_INFO_LEVEL printer; int pnum=0; int snum=0; - uint8 *idata; + uint8 *idata=NULL; uint32 len; DEBUG(5,("getprinterdata_printer\n")); @@ -538,6 +539,7 @@ static BOOL getprinterdata_printer(PRINTER_HND *handle, fstring value, uint32 si bzero(*data, sizeof(uint8)*size); memcpy(*data, idata, len>size?size:len); *needed = len; + if (idata) free(idata); break; /*case 4: *numeric_data=atoi(idata); @@ -545,7 +547,7 @@ static BOOL getprinterdata_printer(PRINTER_HND *handle, fstring value, uint32 si } return (True); } - + free_a_printer(printer, 2); } return (False); @@ -581,6 +583,10 @@ static void spoolss_reply_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u, prs_struct { r_u.size = q_u->size; r_u.status = 0x0; + r_u.type = 0x4; + r_u.needed = 0x0; + r_u.data = NULL; + r_u.numeric_data=0x0; unistr2_to_ascii(value, &(q_u->valuename), sizeof(value)-1); @@ -609,6 +615,7 @@ static void spoolss_reply_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u, prs_struct } spoolss_io_r_getprinterdata("", &r_u, rdata, 0); + if (r_u.data) free(r_u.data); } } @@ -617,7 +624,7 @@ static void spoolss_reply_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u, prs_struct * * called from the spoolss dispatcher ********************************************************************/ -static void api_spoolss_getprinterdata(uint16 vuid, prs_struct *data, +static void api_spoolss_getprinterdata(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_GETPRINTERDATA q_u; @@ -661,7 +668,7 @@ static void spoolss_reply_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *rd * * called from the spoolss dispatcher ********************************************************************/ -static void api_spoolss_closeprinter(uint16 vuid, prs_struct *data, +static void api_spoolss_closeprinter(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_CLOSEPRINTER q_u; @@ -696,7 +703,7 @@ static void spoolss_reply_rffpcnex(SPOOL_Q_RFFPCNEX *q_u, prs_struct *rdata) * * in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe ********************************************************************/ -static void api_spoolss_rffpcnex(uint16 vuid, prs_struct *data, +static void api_spoolss_rffpcnex(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_RFFPCNEX q_u; @@ -732,7 +739,7 @@ static void api_spoolss_rffpcnex(uint16 vuid, prs_struct *data, /******************************************************************* * fill a notify_info_data with the servername ********************************************************************/ -static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_server_name(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { pstring temp_name; @@ -746,7 +753,7 @@ static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, p * fill a notify_info_data with the servicename * jfmxxxx: it's incorrect should be long_printername ********************************************************************/ -static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_printer_name(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { /* data->notify_data.data.length=strlen(lp_servicename(snum)); @@ -761,7 +768,7 @@ static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, /******************************************************************* * fill a notify_info_data with the servicename ********************************************************************/ -static void spoolss_notify_share_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_share_name(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(lp_servicename(snum)); ascii_to_unistr(data->notify_data.data.string, @@ -772,7 +779,7 @@ static void spoolss_notify_share_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr /******************************************************************* * fill a notify_info_data with the port name ********************************************************************/ -static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_port_name(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { /* even if it's strange, that's consistant in all the code */ @@ -787,7 +794,7 @@ static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, pri * jfmxxxx: it's incorrect, should be lp_printerdrivername() * but it doesn't exist, have to see what to do ********************************************************************/ -static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_driver_name(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->drivername); ascii_to_unistr(data->notify_data.data.string, @@ -798,7 +805,7 @@ static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, p /******************************************************************* * fill a notify_info_data with the comment ********************************************************************/ -static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_comment(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(lp_comment(snum)); ascii_to_unistr(data->notify_data.data.string, @@ -811,7 +818,7 @@ static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print * jfm:xxxx incorrect, have to create a new smb.conf option * location = "Room 1, floor 2, building 3" ********************************************************************/ -static void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_location(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->location); ascii_to_unistr(data->notify_data.data.string, @@ -823,7 +830,7 @@ static void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin * fill a notify_info_data with the device mode * jfm:xxxx don't to it for know but that's a real problem !!! ********************************************************************/ -static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_devmode(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { } @@ -832,7 +839,7 @@ static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print * jfm:xxxx just return no file could add an option to smb.conf * separator file = "separator.txt" ********************************************************************/ -static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_sepfile(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->sepfile); ascii_to_unistr(data->notify_data.data.string, @@ -844,7 +851,7 @@ static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print * fill a notify_info_data with the print processor * jfm:xxxx return always winprint to indicate we don't do anything to it ********************************************************************/ -static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_print_processor(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->printprocessor); ascii_to_unistr(data->notify_data.data.string, @@ -856,7 +863,7 @@ static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *dat * fill a notify_info_data with the print processor options * jfm:xxxx send an empty string ********************************************************************/ -static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_parameters(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->parameters); ascii_to_unistr(data->notify_data.data.string, @@ -868,7 +875,7 @@ static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr * fill a notify_info_data with the data type * jfm:xxxx always send RAW as data type ********************************************************************/ -static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_datatype(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->datatype); ascii_to_unistr(data->notify_data.data.string, @@ -881,7 +888,7 @@ static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin * jfm:xxxx send an null pointer to say no security desc * have to implement security before ! ********************************************************************/ -static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_security_desc(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=0; data->notify_data.data.string[0]=0x00; @@ -891,7 +898,7 @@ static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data, * fill a notify_info_data with the attributes * jfm:xxxx a samba printer is always shared ********************************************************************/ -static void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_attributes(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0] = PRINTER_ATTRIBUTE_SHARED \ | PRINTER_ATTRIBUTE_NETWORK \ @@ -901,7 +908,7 @@ static void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr /******************************************************************* * fill a notify_info_data with the priority ********************************************************************/ -static void spoolss_notify_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_priority(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0] = printer->info_2->priority; } @@ -909,7 +916,7 @@ static void spoolss_notify_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin /******************************************************************* * fill a notify_info_data with the default priority ********************************************************************/ -static void spoolss_notify_default_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_default_priority(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0] = printer->info_2->default_priority; } @@ -917,7 +924,7 @@ static void spoolss_notify_default_priority(int snum, SPOOL_NOTIFY_INFO_DATA *da /******************************************************************* * fill a notify_info_data with the start time ********************************************************************/ -static void spoolss_notify_start_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_start_time(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0] = printer->info_2->starttime; } @@ -925,7 +932,7 @@ static void spoolss_notify_start_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr /******************************************************************* * fill a notify_info_data with the until time ********************************************************************/ -static void spoolss_notify_until_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_until_time(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0] = printer->info_2->untiltime; } @@ -933,7 +940,7 @@ static void spoolss_notify_until_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr /******************************************************************* * fill a notify_info_data with the status ********************************************************************/ -static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_status(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { int count; print_queue_struct *q=NULL; @@ -941,28 +948,30 @@ static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_ bzero(&status,sizeof(status)); - count=get_printqueue(snum,0,&q,&status); + count=get_printqueue(snum, conn, &q, &status); data->notify_data.value[0]=(uint32) status.status; + if (q) free(q); } /******************************************************************* * fill a notify_info_data with the number of jobs queued ********************************************************************/ -static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_cjobs(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { print_queue_struct *q=NULL; print_status_struct status; bzero(&status,sizeof(status)); - data->notify_data.value[0]=get_printqueue(snum,0,&q,&status); + data->notify_data.value[0]=get_printqueue(snum, conn, &q, &status); + if (q) free(q); } /******************************************************************* * fill a notify_info_data with the average ppm ********************************************************************/ -static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_average_ppm(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { /* always respond 8 pages per minutes */ /* a little hard ! */ @@ -972,7 +981,7 @@ static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, p /******************************************************************* * fill a notify_info_data with ********************************************************************/ -static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_username(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(queue->user); ascii_to_unistr(data->notify_data.data.string, queue->user, sizeof(data->notify_data.data.string)-1); @@ -981,7 +990,7 @@ static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin /******************************************************************* * fill a notify_info_data with ********************************************************************/ -static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_status(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0]=queue->status; } @@ -989,7 +998,7 @@ static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr /******************************************************************* * fill a notify_info_data with ********************************************************************/ -static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_name(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(queue->file); ascii_to_unistr(data->notify_data.data.string, queue->file, sizeof(data->notify_data.data.string)-1); @@ -998,7 +1007,7 @@ static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin /******************************************************************* * fill a notify_info_data with ********************************************************************/ -static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_status_string(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen("En attente"); ascii_to_unistr(data->notify_data.data.string, "En attente", sizeof(data->notify_data.data.string)-1); @@ -1007,7 +1016,7 @@ static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *d /******************************************************************* * fill a notify_info_data with ********************************************************************/ -static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_time(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0]=0x0; } @@ -1015,7 +1024,7 @@ static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin /******************************************************************* * fill a notify_info_data with ********************************************************************/ -static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_size(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0]=queue->size; } @@ -1023,7 +1032,7 @@ static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin /******************************************************************* * fill a notify_info_data with ********************************************************************/ -static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_position(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0]=queue->job; } @@ -1182,7 +1191,7 @@ static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, * ********************************************************************/ static void construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int pnum, - int snum, int i, uint32 id) + int snum, int i, uint32 id, connection_struct *conn) { int k,j; @@ -1215,7 +1224,7 @@ static void construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int pnum, construct_info_data(info_data, type, field, id); DEBUGADD(4,("notify_info_data_table: in\n")); - notify_info_data_table[j].fn(snum, info_data, queue, &printer); + notify_info_data_table[j].fn(conn,snum, info_data, queue, &printer); DEBUGADD(4,("notify_info_data_table: out\n")); info->count++; info_data=&(info->data[info->count]); @@ -1232,7 +1241,7 @@ static void construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int pnum, * ********************************************************************/ static void construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, - int pnum, int snum, int i, uint32 id) + int pnum, int snum, int i, uint32 id, connection_struct *conn) { int k,j; @@ -1261,13 +1270,13 @@ static void construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I DEBUGADD(4,("j=[%d]:%s\n", j, notify_info_data_table[j].name)); construct_info_data(info_data, type, field, id); DEBUGADD(4,("notify_info_data_table: in\n")); - notify_info_data_table[j].fn(snum, info_data, queue, &printer); + notify_info_data_table[j].fn(conn, snum, info_data, queue, &printer); DEBUGADD(4,("notify_info_data_table: out\n")); info->count++; info_data=&(info->data[info->count]); } } - free_a_printer(printer, 2); + free_a_printer(printer, 2); } } @@ -1278,7 +1287,7 @@ static void construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I * fill a notify_info struct with info asked * ********************************************************************/ -static void printserver_notify_info(PRINTER_HND *hnd, SPOOL_NOTIFY_INFO *info) +static void printserver_notify_info(PRINTER_HND *hnd, SPOOL_NOTIFY_INFO *info, connection_struct *conn) { int snum; int pnum=find_printer_index_by_hnd(hnd); @@ -1297,7 +1306,7 @@ static void printserver_notify_info(PRINTER_HND *hnd, SPOOL_NOTIFY_INFO *info) { if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { - construct_notify_printer_info(info, pnum, snum, i, id); + construct_notify_printer_info(info, pnum, snum, i, id, conn); id++; } } @@ -1311,7 +1320,7 @@ static void printserver_notify_info(PRINTER_HND *hnd, SPOOL_NOTIFY_INFO *info) * fill a notify_info struct with info asked * ********************************************************************/ -static void printer_notify_info(PRINTER_HND *hnd, SPOOL_NOTIFY_INFO *info) +static void printer_notify_info(PRINTER_HND *hnd, SPOOL_NOTIFY_INFO *info, connection_struct *conn) { int snum; int pnum=find_printer_index_by_hnd(hnd); @@ -1328,7 +1337,7 @@ static void printer_notify_info(PRINTER_HND *hnd, SPOOL_NOTIFY_INFO *info) { case PRINTER_NOTIFY_TYPE: { - construct_notify_printer_info(info, pnum, snum, i, id); + construct_notify_printer_info(info, pnum, snum, i, id, conn); id--; break; } @@ -1338,11 +1347,12 @@ static void printer_notify_info(PRINTER_HND *hnd, SPOOL_NOTIFY_INFO *info) print_queue_struct *queue=NULL; print_status_struct status; bzero(&status, sizeof(status)); - count=get_printqueue(snum, 0, &queue, &status); + count=get_printqueue(snum, conn, &queue, &status); for (j=0; jhandle)); @@ -1366,10 +1376,10 @@ static void spoolss_reply_rfnpcnex(SPOOL_Q_RFNPCNEX *q_u, prs_struct *rdata) switch (Printer[pnum].printer_type) { case PRINTER_HANDLE_IS_PRINTSERVER: - printserver_notify_info(&(q_u->handle), &(r_u.info)); + printserver_notify_info(&(q_u->handle), &(r_u.info), conn); break; case PRINTER_HANDLE_IS_PRINTER: - printer_notify_info(&(q_u->handle), &(r_u.info)); + printer_notify_info(&(q_u->handle), &(r_u.info), conn); break; } @@ -1383,21 +1393,21 @@ static void spoolss_reply_rfnpcnex(SPOOL_Q_RFNPCNEX *q_u, prs_struct *rdata) * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_rfnpcnex(uint16 vuid, prs_struct *data, +static void api_spoolss_rfnpcnex(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_RFNPCNEX q_u; spoolss_io_q_rfnpcnex("", &q_u, data, 0); - spoolss_reply_rfnpcnex(&q_u,rdata); + spoolss_reply_rfnpcnex(&q_u, rdata, p->conn); } /******************************************************************** * construct_printer_info_0 * fill a printer_info_1 struct ********************************************************************/ -static void construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring servername) +static void construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring servername, connection_struct *conn) { pstring chaine; int count; @@ -1405,7 +1415,7 @@ static void construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring s print_queue_struct *queue=NULL; print_status_struct status; bzero(&status,sizeof(status)); - count=get_printqueue(snum,0,&queue,&status); + count=get_printqueue(snum, conn ,&queue,&status); /* the description and the name are of the form \\server\share */ slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s",servername, lp_servicename(snum)); @@ -1445,6 +1455,7 @@ static void construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring s printer->unknown21 = 0x0648; printer->unknown22 = 0x0; printer->unknown23 = 0x5; + if (queue) free(queue); } @@ -1452,7 +1463,7 @@ static void construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring s * construct_printer_info_1 * fill a printer_info_1 struct ********************************************************************/ -static BOOL construct_printer_info_1(PRINTER_INFO_1 *printer,int snum, pstring servername) +static BOOL construct_printer_info_1(PRINTER_INFO_1 *printer,int snum, pstring servername, connection_struct *conn) { pstring chaine; NT_PRINTER_INFO_LEVEL ntprinter; @@ -1544,7 +1555,7 @@ static void construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) * construct_printer_info_2 * fill a printer_info_2 struct ********************************************************************/ -static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring servername) +static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring servername, connection_struct *conn) { pstring chaine; int count; @@ -1554,7 +1565,7 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring print_queue_struct *queue=NULL; print_status_struct status; bzero(&status, sizeof(status)); - count=get_printqueue(snum, 0, &queue, &status); + count=get_printqueue(snum, conn, &queue, &status); if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) { @@ -1596,6 +1607,8 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring construct_dev_mode(devmode, snum, servername); printer->devmode=devmode; + if (queue) free(queue); + free_a_printer(ntprinter, 2); return (True); } @@ -1603,14 +1616,14 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring * enum_printer_info_1 * glue between spoolss_reply_enumprinters and construct_printer_info_1 ********************************************************************/ -static BOOL enum_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number) +static BOOL enum_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number, connection_struct *conn) { pstring servername; *printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1)); DEBUG(4,("Allocated memory for ONE PRINTER_INFO_1 at [%p]\n", *printer)); pstrcpy(servername, global_myname); - if (!construct_printer_info_1(*printer, snum, servername)) + if (!construct_printer_info_1(*printer, snum, servername, conn)) { free(*printer); return (False); @@ -1625,14 +1638,14 @@ static BOOL enum_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number) * enum_printer_info_2 * glue between spoolss_reply_enumprinters and construct_printer_info_2 ********************************************************************/ -static BOOL enum_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number) +static BOOL enum_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number, connection_struct *conn) { pstring servername; *printer=(PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2)); DEBUG(4,("Allocated memory for ONE PRINTER_INFO_2 at [%p]\n", *printer)); pstrcpy(servername, global_myname); - if (!construct_printer_info_2(*printer, snum, servername)) + if (!construct_printer_info_2(*printer, snum, servername, conn)) { free(*printer); return (False); @@ -1648,7 +1661,7 @@ static BOOL enum_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number) * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number) +static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number, connection_struct *conn) { int snum; int n_services=lp_numservices(); @@ -1662,7 +1675,7 @@ static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number) DEBUG(4,("Found a printer: %s[%x]\n",lp_servicename(snum),snum)); *printers=Realloc(*printers, (*number+1)*sizeof(PRINTER_INFO_1 *)); DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1 pointers at [%p]\n", *number+1, *printers)); - if (enum_printer_info_1( &((*printers)[*number]), snum, *number) ) + if (enum_printer_info_1( &((*printers)[*number]), snum, *number, conn) ) { (*number)++; } @@ -1675,7 +1688,7 @@ static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number) * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number) +static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number, connection_struct *conn) { int snum; int n_services=lp_numservices(); @@ -1689,7 +1702,7 @@ static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number) DEBUG(4,("Found a printer: %s[%x]\n",lp_servicename(snum),snum)); *printers=Realloc(*printers, (*number+1)*sizeof(PRINTER_INFO_2 *)); DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1 pointers at [%p]\n", *number+1, *printers)); - if (enum_printer_info_2( &((*printers)[*number]), snum, *number) ) + if (enum_printer_info_2( &((*printers)[*number]), snum, *number, conn) ) { (*number)++; } @@ -1755,7 +1768,7 @@ static void free_enum_printers_info(SPOOL_R_ENUMPRINTERS *r_u) * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -static void spoolss_reply_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *rdata) +static void spoolss_reply_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *rdata, connection_struct *conn) { SPOOL_R_ENUMPRINTERS r_u; @@ -1770,14 +1783,14 @@ static void spoolss_reply_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *rd case 1: if ( (q_u->flags==PRINTER_ENUM_NAME) || (q_u->flags==PRINTER_ENUM_NETWORK) ) /*if (is_a_printerserver(q_u->servername))*/ - enum_all_printers_info_1(&(r_u.printer.printers_1), &(r_u.returned) ); + enum_all_printers_info_1(&(r_u.printer.printers_1), &(r_u.returned), conn ); /*else enum_one_printer_info_1(&r_u);*/ break; case 2: if ( (q_u->flags==PRINTER_ENUM_NAME) || (q_u->flags==PRINTER_ENUM_NETWORK) ) /*if (is_a_printerserver(q_u->servername))*/ - enum_all_printers_info_2(&(r_u.printer.printers_2), &(r_u.returned) ); + enum_all_printers_info_2(&(r_u.printer.printers_2), &(r_u.returned), conn ); /*else enum_one_printer_info_2(&r_u);*/ break; @@ -1803,20 +1816,20 @@ static void spoolss_reply_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *rd * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_enumprinters(uint16 vuid, prs_struct *data, +static void api_spoolss_enumprinters(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPRINTERS q_u; spoolss_io_q_enumprinters("", &q_u, data, 0); - spoolss_reply_enumprinters(&q_u,rdata); + spoolss_reply_enumprinters(&q_u, rdata, p->conn); } /**************************************************************************** ****************************************************************************/ -static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata) +static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata, connection_struct *conn) { SPOOL_R_GETPRINTER r_u; int snum; @@ -1834,7 +1847,7 @@ static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata) printer=(PRINTER_INFO_0 *)malloc(sizeof(PRINTER_INFO_0)); - construct_printer_info_0(printer, snum, servername); + construct_printer_info_0(printer, snum, servername, conn); r_u.printer.info0=printer; r_u.status=0x0000; r_u.offered=q_u->offered; @@ -1852,7 +1865,7 @@ static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata) printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1)); - construct_printer_info_1(printer, snum, servername); + construct_printer_info_1(printer, snum, servername, conn); r_u.printer.info1=printer; r_u.status=0x0000; @@ -1869,7 +1882,7 @@ static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata) PRINTER_INFO_2 *printer; printer=(PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2)); - construct_printer_info_2(printer, snum, servername); + construct_printer_info_2(printer, snum, servername, conn); r_u.printer.info2=printer; r_u.status=0x0000; @@ -1890,14 +1903,14 @@ static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata) * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_getprinter(uint16 vuid, prs_struct *data, +static void api_spoolss_getprinter(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_GETPRINTER q_u; spoolss_io_q_getprinter("", &q_u, data, 0); - spoolss_reply_getprinter(&q_u, rdata); + spoolss_reply_getprinter(&q_u, rdata, p->conn); } /******************************************************************** @@ -2103,7 +2116,7 @@ static void spoolss_reply_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_ * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_getprinterdriver2(uint16 vuid, prs_struct *data, +static void api_spoolss_getprinterdriver2(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_GETPRINTERDRIVER2 q_u; @@ -2138,7 +2151,7 @@ static void spoolss_reply_startpageprinter(SPOOL_Q_STARTPAGEPRINTER *q_u, prs_st * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_startpageprinter(uint16 vuid, prs_struct *data, +static void api_spoolss_startpageprinter(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_STARTPAGEPRINTER q_u; @@ -2173,7 +2186,7 @@ static void spoolss_reply_endpageprinter(SPOOL_Q_ENDPAGEPRINTER *q_u, prs_struct * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_endpageprinter(uint16 vuid, prs_struct *data, +static void api_spoolss_endpageprinter(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENDPAGEPRINTER q_u; @@ -2208,7 +2221,7 @@ static void spoolss_reply_startdocprinter(SPOOL_Q_STARTDOCPRINTER *q_u, prs_stru * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_startdocprinter(uint16 vuid, prs_struct *data, +static void api_spoolss_startdocprinter(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_STARTDOCPRINTER q_u; @@ -2275,7 +2288,7 @@ static void spoolss_reply_enddocprinter(SPOOL_Q_ENDDOCPRINTER *q_u, prs_struct * * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_enddocprinter(uint16 vuid, prs_struct *data, +static void api_spoolss_enddocprinter(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENDDOCPRINTER q_u; @@ -2375,7 +2388,7 @@ static void spoolss_reply_writeprinter(SPOOL_Q_WRITEPRINTER *q_u, prs_struct *rd * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_writeprinter(uint16 vuid, prs_struct *data, +static void api_spoolss_writeprinter(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_WRITEPRINTER q_u; @@ -2390,6 +2403,7 @@ static void api_spoolss_writeprinter(uint16 vuid, prs_struct *data, { fd=Printer[pnum].document_fd; size=write(fd, q_u.buffer, q_u.buffer_size); + if (q_u.buffer) free(q_u.buffer); Printer[pnum].document_lastwritten=size; } @@ -2401,31 +2415,25 @@ static void api_spoolss_writeprinter(uint16 vuid, prs_struct *data, * called from the spoolss dispatcher * ********************************************************************/ -static void control_printer(PRINTER_HND handle, uint32 command) +static void control_printer(PRINTER_HND handle, uint32 command, connection_struct *conn) { int pnum; int snum; pnum = find_printer_index_by_hnd(&(handle)); if ( get_printer_snum(&handle, &snum) ) - { - /* - * status_printqueue requires a connection_struct - * - * anybody want to explain me what value it has here ??? - */ - + { switch (command) { case PRINTER_CONTROL_PAUSE: /* pause the printer here */ - status_printqueue(0, snum, LPSTAT_STOPPED); + status_printqueue(conn, snum, LPSTAT_STOPPED); break; case PRINTER_CONTROL_RESUME: case PRINTER_CONTROL_UNPAUSE: /* UN-pause the printer here */ - status_printqueue(0, snum, LPSTAT_OK); + status_printqueue(conn, snum, LPSTAT_OK); break; case PRINTER_CONTROL_PURGE: /* Envoi des dragées FUCA dans l'imprimante */ @@ -2522,7 +2530,7 @@ static void spoolss_reply_setprinter(SPOOL_Q_SETPRINTER *q_u, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static void api_spoolss_setprinter(uint16 vuid, prs_struct *data, +static void api_spoolss_setprinter(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_SETPRINTER q_u; @@ -2537,7 +2545,7 @@ static void api_spoolss_setprinter(uint16 vuid, prs_struct *data, switch (q_u.level) { case 0: - control_printer(q_u.handle, q_u.command); + control_printer(q_u.handle, q_u.command, p->conn); break; case 2: update_printer(q_u.handle, q_u.level, q_u.info, q_u.devmode); @@ -2560,7 +2568,7 @@ static void spoolss_reply_fcpn(SPOOL_Q_FCPN *q_u, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static void api_spoolss_fcpn(uint16 vuid, prs_struct *data, +static void api_spoolss_fcpn(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_FCPN q_u; @@ -2583,7 +2591,7 @@ static void spoolss_reply_addjob(SPOOL_Q_ADDJOB *q_u, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static void api_spoolss_addjob(uint16 vuid, prs_struct *data, +static void api_spoolss_addjob(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ADDJOB q_u; @@ -2665,7 +2673,7 @@ static void fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, /**************************************************************************** ****************************************************************************/ -static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata) +static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata, connection_struct *conn) { SPOOL_R_ENUMJOBS r_u; int snum; @@ -2685,7 +2693,7 @@ static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata) if (get_printer_snum(&(q_u->handle), &snum)) { - count=get_printqueue(snum, 0, &queue, &status); + count=get_printqueue(snum, conn, &queue, &status); r_u.numofjobs=count; r_u.level=q_u->level; @@ -2717,7 +2725,6 @@ static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata) break; } } - } r_u.status=0x0; @@ -2736,18 +2743,20 @@ static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata) break; } } + if (queue) free(queue); + } /**************************************************************************** ****************************************************************************/ -static void api_spoolss_enumjobs(uint16 vuid, prs_struct *data, +static void api_spoolss_enumjobs(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMJOBS q_u; spoolss_io_q_enumjobs("", &q_u, data, 0); - spoolss_reply_enumjobs(&q_u, rdata); + spoolss_reply_enumjobs(&q_u, rdata, p->conn); } /**************************************************************************** @@ -2763,7 +2772,7 @@ static void spoolss_reply_schedulejob(SPOOL_Q_SCHEDULEJOB *q_u, prs_struct *rdat /**************************************************************************** ****************************************************************************/ -static void api_spoolss_schedulejob(uint16 vuid, prs_struct *data, +static void api_spoolss_schedulejob(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_SCHEDULEJOB q_u; @@ -2775,7 +2784,7 @@ static void api_spoolss_schedulejob(uint16 vuid, prs_struct *data, /**************************************************************************** ****************************************************************************/ -static void spoolss_reply_setjob(SPOOL_Q_SETJOB *q_u, prs_struct *rdata) +static void spoolss_reply_setjob(SPOOL_Q_SETJOB *q_u, prs_struct *rdata, connection_struct *conn) { SPOOL_R_SETJOB r_u; int snum; @@ -2789,7 +2798,7 @@ static void spoolss_reply_setjob(SPOOL_Q_SETJOB *q_u, prs_struct *rdata) if (get_printer_snum(&(q_u->handle), &snum)) { - count=get_printqueue(snum, 0, &queue, &status); + count=get_printqueue(snum, conn, &queue, &status); while ( (ijobid == queue[i].job ) @@ -2806,17 +2815,17 @@ static void spoolss_reply_setjob(SPOOL_Q_SETJOB *q_u, prs_struct *rdata) case JOB_CONTROL_CANCEL: case JOB_CONTROL_DELETE: { - del_printqueue(0, snum, q_u->jobid); + del_printqueue(conn, snum, q_u->jobid); break; } case JOB_CONTROL_PAUSE: { - status_printjob(0, snum, q_u->jobid, LPQ_PAUSED); + status_printjob(conn, snum, q_u->jobid, LPQ_PAUSED); break; } case JOB_CONTROL_RESUME: { - status_printjob(0, snum, q_u->jobid, LPQ_QUEUED); + status_printjob(conn, snum, q_u->jobid, LPQ_QUEUED); break; } } @@ -2824,23 +2833,25 @@ static void spoolss_reply_setjob(SPOOL_Q_SETJOB *q_u, prs_struct *rdata) } r_u.status=0x0; spoolss_io_r_setjob("",&r_u,rdata,0); + if (queue) free(queue); + } /**************************************************************************** ****************************************************************************/ -static void api_spoolss_setjob(uint16 vuid, prs_struct *data, +static void api_spoolss_setjob(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_SETJOB q_u; spoolss_io_q_setjob("", &q_u, data, 0); - spoolss_reply_setjob(&q_u, rdata); + spoolss_reply_setjob(&q_u, rdata, p->conn); } /**************************************************************************** ****************************************************************************/ -static void spoolss_reply_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *rdata) +static void spoolss_reply_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *rdata, connection_struct *conn) { SPOOL_R_ENUMPRINTERDRIVERS r_u; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -2857,7 +2868,7 @@ static void spoolss_reply_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, pr fstrcpy(servername, global_myname); unistr2_to_ascii(architecture, &(q_u->environment), sizeof(architecture)); - count=get_ntdrivers(&list, architecture); + count=get_ntdrivers(conn, &list, architecture); DEBUGADD(4,("we have: [%d] drivers on archi [%s]\n",count, architecture)); for (i=0; iconn); } @@ -3014,7 +3025,7 @@ static void spoolss_reply_enumforms(SPOOL_Q_ENUMFORMS *q_u, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static void api_spoolss_enumforms(uint16 vuid, prs_struct *data, +static void api_spoolss_enumforms(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMFORMS q_u; @@ -3082,7 +3093,7 @@ static void spoolss_reply_enumports(SPOOL_Q_ENUMPORTS *q_u, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static void api_spoolss_enumports(uint16 vuid, prs_struct *data, +static void api_spoolss_enumports(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPORTS q_u; @@ -3126,7 +3137,7 @@ static void spoolss_reply_addprinterex(SPOOL_Q_ADDPRINTEREX *q_u, prs_struct *rd /**************************************************************************** ****************************************************************************/ -static void api_spoolss_addprinterex(uint16 vuid, prs_struct *data, prs_struct *rdata) +static void api_spoolss_addprinterex(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ADDPRINTEREX q_u; NT_PRINTER_INFO_LEVEL printer; @@ -3163,7 +3174,7 @@ static void spoolss_reply_addprinterdriver(SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_st /**************************************************************************** ****************************************************************************/ -static void api_spoolss_addprinterdriver(uint16 vuid, prs_struct *data, +static void api_spoolss_addprinterdriver(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ADDPRINTERDRIVER q_u; @@ -3206,7 +3217,7 @@ static void spoolss_reply_getprinterdriverdirectory(SPOOL_Q_GETPRINTERDRIVERDIR /**************************************************************************** ****************************************************************************/ -static void api_spoolss_getprinterdriverdirectory(uint16 vuid, prs_struct *data, +static void api_spoolss_getprinterdriverdirectory(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_GETPRINTERDRIVERDIR q_u; @@ -3312,7 +3323,7 @@ static void spoolss_reply_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, prs_stru /**************************************************************************** ****************************************************************************/ -static void api_spoolss_enumprinterdata(uint16 vuid, prs_struct *data, +static void api_spoolss_enumprinterdata(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPRINTERDATA q_u; @@ -3358,7 +3369,7 @@ static void spoolss_reply_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, prs_struct /**************************************************************************** ****************************************************************************/ -static void api_spoolss_setprinterdata(uint16 vuid, prs_struct *data, +static void api_spoolss_setprinterdata(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_SETPRINTERDATA q_u; diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index dacef42121..5b43ec0303 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -909,7 +909,7 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, /******************************************************************* ********************************************************************/ -static void api_srv_net_srv_get_info( uint16 vuid, prs_struct *data, +static void api_srv_net_srv_get_info( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SRV_GET_INFO q_n; @@ -924,7 +924,7 @@ static void api_srv_net_srv_get_info( uint16 vuid, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_file_enum( uint16 vuid, prs_struct *data, +static void api_srv_net_file_enum( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_FILE_ENUM q_n; @@ -942,7 +942,7 @@ static void api_srv_net_file_enum( uint16 vuid, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_conn_enum( uint16 vuid, prs_struct *data, +static void api_srv_net_conn_enum( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_CONN_ENUM q_n; @@ -960,7 +960,7 @@ static void api_srv_net_conn_enum( uint16 vuid, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_sess_enum( uint16 vuid, prs_struct *data, +static void api_srv_net_sess_enum( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SESS_ENUM q_n; @@ -978,7 +978,7 @@ static void api_srv_net_sess_enum( uint16 vuid, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_share_enum( uint16 vuid, prs_struct *data, +static void api_srv_net_share_enum( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SHARE_ENUM q_n; @@ -1034,7 +1034,7 @@ static void srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n, } /******************************************************************* ********************************************************************/ -static void api_srv_net_remote_tod( uint16 vuid, prs_struct *data, +static void api_srv_net_remote_tod( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_REMOTE_TOD q_n; diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 6a420c1493..39ec2c93ec 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -61,7 +61,7 @@ static void svc_reply_close(SVC_Q_CLOSE *q_r, /******************************************************************* api_svc_close ********************************************************************/ -static void api_svc_close( uint16 vuid, prs_struct *data, +static void api_svc_close( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { SVC_Q_CLOSE q_r; @@ -117,7 +117,7 @@ static void svc_reply_open_service(SVC_Q_OPEN_SERVICE *q_u, /******************************************************************* api_svc_open_service ********************************************************************/ -static void api_svc_open_service( uint16 vuid, prs_struct *data, +static void api_svc_open_service( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { SVC_Q_OPEN_SERVICE q_u; @@ -153,7 +153,7 @@ static void svc_reply_start_service(SVC_Q_START_SERVICE *q_s, /******************************************************************* api_svc_start_service ********************************************************************/ -static void api_svc_start_service( uint16 vuid, prs_struct *data, +static void api_svc_start_service( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { SVC_Q_START_SERVICE q_u; @@ -203,7 +203,7 @@ static void svc_reply_open_sc_man(SVC_Q_OPEN_SC_MAN *q_u, /******************************************************************* api_svc_open_sc_man ********************************************************************/ -static void api_svc_open_sc_man( uint16 vuid, prs_struct *data, +static void api_svc_open_sc_man( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { SVC_Q_OPEN_SC_MAN q_u; @@ -318,7 +318,7 @@ static void svc_reply_enum_svcs_status(SVC_Q_ENUM_SVCS_STATUS *q_u, /******************************************************************* api_svc_enum_svcs_status ********************************************************************/ -static void api_svc_enum_svcs_status( uint16 vuid, prs_struct *data, +static void api_svc_enum_svcs_status( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { SVC_Q_ENUM_SVCS_STATUS q_u; @@ -356,7 +356,7 @@ static void svc_reply_query_disp_name(SVC_Q_QUERY_DISP_NAME *q_u, /******************************************************************* api_svc_query_disp_name ********************************************************************/ -static void api_svc_query_disp_name( uint16 vuid, prs_struct *data, +static void api_svc_query_disp_name( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { SVC_Q_QUERY_DISP_NAME q_u; diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index acb5cde831..9b0b0a3ca8 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -80,7 +80,7 @@ static void wks_reply_query_info(WKS_Q_QUERY_INFO *q_u, /******************************************************************* api_wks_query_info ********************************************************************/ -static void api_wks_query_info( uint16 vuid, prs_struct *data, +static void api_wks_query_info( pipes_struct *p, prs_struct *data, prs_struct *rdata ) { WKS_Q_QUERY_INFO q_u; -- cgit From 99e42c0656d3e1e3b8e06437a8a9082c12df22d2 Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Wed, 2 Jun 1999 03:19:20 +0000 Subject: Some more BDC-related fixes, mainly to the NET_SAM_SYNC RPC with respect to alignment, missing fields, etc. - it should now work correctly. There is still the problem of decoding the private data field. (This used to be commit c3c25e762fbc30d5663323f23449c913f2ce4b0e) --- source3/rpc_server/srv_netlog.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 44ad4fd064..7ee45ada16 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -251,6 +251,8 @@ static void net_reply_sam_sync(NET_Q_SAM_SYNC *q_s, prs_struct *rdata, pwd->group_rid, pwd->home_dir, pwd->dir_drive, pwd->logon_script, pwd->acct_desc, pwd->acct_ctrl, pwd->profile_path); + + i++; } endsmbpwent(vp); -- cgit From 0c927f2b1b7ff547954a7a68fd44c7ce8ad65299 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 22 Jun 1999 18:42:10 +0000 Subject: Fixed most memory leak and big-endian bug in the spoolss code. Also added addform/setform rpc api calls. Now I can add/change forms from the server property dialog box. Jean Francois (This used to be commit 8d73f83b6c112327a51c0df2e96a1866deb13c3a) --- source3/rpc_server/srv_spoolss.c | 117 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 5b3ea4502a..c8df41a810 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -430,6 +430,7 @@ static void api_spoolss_open_printer(pipes_struct *p, prs_struct *data, prs_stru static BOOL getprinterdata_printer_server(fstring value, uint32 size, uint32 *type, uint32 *numeric_data, uint8 **data, uint32 *needed) { + int i; if (!strcmp(value, "BeepEnabled")) { @@ -492,8 +493,14 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 size, uint32 *ty *type = 0x1; *data = (uint8 *)malloc( size*sizeof(uint8) ); ZERO_STRUCTP(*data); - make_unistr((UNISTR *)*data, directory); - *needed = 2*(strlen(directory)+1); + + /* it's done by hand ready to go on the wire */ + for (i=0; iconn); + + spoolss_io_free_buffer(&(q_u.buffer)); } @@ -2124,6 +2137,8 @@ static void api_spoolss_getprinterdriver2(pipes_struct *p, prs_struct *data, spoolss_io_q_getprinterdriver2("", &q_u, data, 0); spoolss_reply_getprinterdriver2(&q_u, rdata); + + spoolss_io_free_buffer(&(q_u.buffer)); } /**************************************************************************** @@ -2599,6 +2614,8 @@ static void api_spoolss_addjob(pipes_struct *p, prs_struct *data, spoolss_io_q_addjob("", &q_u, data, 0); spoolss_reply_addjob(&q_u, rdata); + + spoolss_io_free_buffer(&(q_u.buffer)); } /**************************************************************************** @@ -2757,6 +2774,8 @@ static void api_spoolss_enumjobs(pipes_struct *p, prs_struct *data, spoolss_io_q_enumjobs("", &q_u, data, 0); spoolss_reply_enumjobs(&q_u, rdata, p->conn); + + spoolss_io_free_buffer(&(q_u.buffer)); } /**************************************************************************** @@ -2958,6 +2977,8 @@ static void api_spoolss_enumprinterdrivers(pipes_struct *p, prs_struct *data, spoolss_io_q_enumprinterdrivers("", &q_u, data, 0); spoolss_reply_enumprinterdrivers(&q_u, rdata, p->conn); + + spoolss_io_free_buffer(&(q_u.buffer)); } @@ -3033,8 +3054,12 @@ static void api_spoolss_enumforms(pipes_struct *p, prs_struct *data, spoolss_io_q_enumforms("", &q_u, data, 0); spoolss_reply_enumforms(&q_u, rdata); + + spoolss_io_free_buffer(&(q_u.buffer)); } +/**************************************************************************** +****************************************************************************/ static void fill_port_2(PORT_INFO_2 *port, char *name) { make_unistr(&(port->port_name), name); @@ -3101,6 +3126,8 @@ static void api_spoolss_enumports(pipes_struct *p, prs_struct *data, spoolss_io_q_enumports("", &q_u, data, 0); spoolss_reply_enumports(&q_u, rdata); + + spoolss_io_free_buffer(&(q_u.buffer)); } /**************************************************************************** @@ -3225,6 +3252,8 @@ static void api_spoolss_getprinterdriverdirectory(pipes_struct *p, prs_struct *d spoolss_io_q_getprinterdriverdir("", &q_u, data, 0); spoolss_reply_getprinterdriverdirectory(&q_u, rdata); + + spoolss_io_free_buffer(&(q_u.buffer)); } /**************************************************************************** @@ -3381,6 +3410,86 @@ static void api_spoolss_setprinterdata(pipes_struct *p, prs_struct *data, free(q_u.data); } +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_addform(SPOOL_Q_ADDFORM *q_u, prs_struct *rdata) +{ + SPOOL_R_ADDFORM r_u; + int pnum=0; + int count=0; + nt_forms_struct *list=NULL; + + DEBUG(5,("spoolss_reply_addform\n")); + + pnum = find_printer_index_by_hnd(&(q_u->handle)); + + if (OPEN_HANDLE(pnum)) + { + count=get_ntforms(&list); + + add_a_form(&list, q_u->form, count); + + write_ntforms(&list, count+1); + + free(list); + } + + r_u.status = 0x0; + spoolss_io_r_addform("", &r_u, rdata, 0); +} + +/**************************************************************************** +****************************************************************************/ +static void api_spoolss_addform(pipes_struct *p, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_ADDFORM q_u; + + spoolss_io_q_addform("", &q_u, data, 0); + + spoolss_reply_addform(&q_u, rdata); +} + + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_setform(SPOOL_Q_SETFORM *q_u, prs_struct *rdata) +{ + SPOOL_R_SETFORM r_u; + int pnum=0; + int count=0; + nt_forms_struct *list=NULL; + + DEBUG(5,("spoolss_reply_setform\n")); + + pnum = find_printer_index_by_hnd(&(q_u->handle)); + + if (OPEN_HANDLE(pnum)) + { + count=get_ntforms(&list); + + update_a_form(&list, q_u->form, count); + + write_ntforms(&list, count); + + free(list); + } + r_u.status = 0x0; + spoolss_io_r_setform("", &r_u, rdata, 0); +} + +/**************************************************************************** +****************************************************************************/ +static void api_spoolss_setform(pipes_struct *p, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_SETFORM q_u; + + spoolss_io_q_setform("", &q_u, data, 0); + + spoolss_reply_setform(&q_u, rdata); +} + /******************************************************************* \pipe\spoolss commands ********************************************************************/ @@ -3413,6 +3522,8 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory }, {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata }, {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata }, + {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform }, + {"SPOOLSS_SETFORM", SPOOLSS_SETFORM, api_spoolss_setform }, { NULL, 0, NULL } }; -- cgit From 73891ca8e4f6cca6aa8bb0ae043f660a64baa056 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 29 Jun 1999 18:47:06 +0000 Subject: improving authentication code (tidyup). (This used to be commit ab1a6aa42db5217f025941fb5107436556bc23b7) --- source3/rpc_server/srv_netlog.c | 45 +++++++++++++---------------------------- source3/rpc_server/srv_pipe.c | 38 ++++++++++++++++++++++------------ 2 files changed, 39 insertions(+), 44 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 7ee45ada16..9c260d5759 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -630,43 +630,26 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, struct sam_passwd *smb_pass, user_struct *vuser) { - 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)); + fstring user; + fstring domain; - /* JRA. Check the NT password first if it exists - this is a higher quality - password, if it exists and it doesn't match - fail. */ + int nt_pw_len = id2->hdr_nt_chal_resp.str_str_len >= 24; + int lm_pw_len = id2->hdr_lm_chal_resp.str_str_len >= 24; - 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 0x0; - else - return 0xC0000000 | NT_STATUS_WRONG_PASSWORD; - } + unistr2_to_ascii(user , &id2->uni_user_name, sizeof(user)-1); + unistr2_to_ascii(domain, &id2->uni_domain_name, sizeof(domain)-1); + + DEBUG(5,("net_login_network: lm_len:%d nt_len:%d user:%s domain:%s\n", + lm_pw_len, nt_pw_len, user, domain)); - /* lkclXXXX this is not a good place to put disabling of LM hashes in. - if that is to be done, first move this entire function into a - library routine that calls the two smb_password_check() functions. - if disabling LM hashes (which nt can do for security reasons) then - an attempt should be made to disable them everywhere (which nt does - not do, for various security-hole reasons). - */ - - if (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)) + if (smb_password_ok(pwdb_sam_to_smb(smb_pass), id2->lm_chal, + user, domain, + (uchar *)id2->lm_chal_resp.buffer, lm_pw_len, + (uchar *)id2->nt_chal_resp.buffer, nt_pw_len)) { - return 0x0; + return 0x0; } - - /* oops! neither password check succeeded */ - return 0xC0000000 | NT_STATUS_WRONG_PASSWORD; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index d98fecbc1f..3e5d986935 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -208,7 +208,9 @@ BOOL create_rpc_reply(pipes_struct *p, static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) { uchar lm_owf[24]; - uchar nt_owf[24]; + uchar nt_owf[128]; + size_t lm_owf_len; + size_t nt_owf_len; struct smb_passwd *smb_pass = NULL; user_struct *vuser = get_valid_user_struct(p->vuid); @@ -221,12 +223,29 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) return False; } - if (p->ntlmssp_resp.hdr_lm_resp.str_str_len == 0) return False; - if (p->ntlmssp_resp.hdr_nt_resp.str_str_len == 0) return False; + lm_owf_len = p->ntlmssp_resp.hdr_lm_resp.str_str_len; + nt_owf_len = p->ntlmssp_resp.hdr_nt_resp.str_str_len; + + + if (lm_owf_len == 0) return False; + if (nt_owf_len == 0) return False; if (p->ntlmssp_resp.hdr_usr .str_str_len == 0) return False; if (p->ntlmssp_resp.hdr_domain .str_str_len == 0) return False; if (p->ntlmssp_resp.hdr_wks .str_str_len == 0) return False; + if (lm_owf_len > sizeof(lm_owf)) return False; + if (nt_owf_len > sizeof(nt_owf)) return False; + + memcpy(lm_owf, p->ntlmssp_resp.lm_resp, sizeof(lm_owf)); + memcpy(nt_owf, p->ntlmssp_resp.nt_resp, sizeof(nt_owf)); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("lm, nt owfs, chal\n")); + dump_data(100, lm_owf, sizeof(lm_owf)); + dump_data(100, nt_owf, sizeof(nt_owf)); + dump_data(100, p->ntlmssp_chal.challenge, 8); +#endif + memset(p->user_name, 0, sizeof(p->user_name)); memset(p->domain , 0, sizeof(p->domain )); memset(p->wks , 0, sizeof(p->wks )); @@ -252,19 +271,12 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) DEBUG(5,("user: %s domain: %s wks: %s\n", p->user_name, p->domain, p->wks)); - memcpy(lm_owf, p->ntlmssp_resp.lm_resp, sizeof(lm_owf)); - memcpy(nt_owf, p->ntlmssp_resp.nt_resp, sizeof(nt_owf)); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("lm, nt owfs, chal\n")); - dump_data(100, lm_owf, sizeof(lm_owf)); - dump_data(100, nt_owf, sizeof(nt_owf)); - dump_data(100, p->ntlmssp_chal.challenge, 8); -#endif become_root(True); p->ntlmssp_validated = pass_check_smb(p->user_name, p->domain, (uchar*)p->ntlmssp_chal.challenge, - lm_owf, nt_owf, NULL, vuser->dc.user_sess_key); + lm_owf, lm_owf_len, + nt_owf, nt_owf_len, + NULL, vuser->dc.user_sess_key); smb_pass = getsmbpwnam(p->user_name); unbecome_root(True); -- cgit From 89517ed4d37f230d6f10986edbf15e3315cdeb43 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Thu, 1 Jul 1999 18:02:34 +0000 Subject: many small bugs... J.F. (This used to be commit bda429eb73fa3c0a6d59cf47a8285e3fc0cdae98) --- source3/rpc_server/srv_spoolss.c | 50 ++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index c8df41a810..2cb5543f26 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -258,16 +258,17 @@ static BOOL set_printer_hnd_printername(PRINTER_HND *hnd, char *printername) lp_snum_ok(snum) && lp_print_ok(snum) ) { - DEBUGADD(5,("get_printer_snum, share:%s\n",lp_servicename(snum))); + DEBUGADD(5,("share:%s\n",lp_servicename(snum))); marche=get_a_printer(&printer, 2, lp_servicename(snum)); - DEBUGADD(6,("get_printer_snum, marche:%d\n",marche)); + DEBUGADD(6,("marche:%d\n",marche)); if ( marche==0 && ( strlen(printer.info_2->printername) == strlen(back) ) && ( !strncasecmp(printer.info_2->printername, back, strlen(back))) ) { DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); + ZERO_STRUCT(Printer[pnum].dev.printername); strncpy(Printer[pnum].dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); free_a_printer(printer, 2); return True; @@ -280,6 +281,7 @@ static BOOL set_printer_hnd_printername(PRINTER_HND *hnd, char *printername) return False; break; case PRINTER_HANDLE_IS_PRINTSERVER: + ZERO_STRUCT(Printer[pnum].dev.printerservername); strncpy(Printer[pnum].dev.printerservername, printername, strlen(printername)); return True; break; @@ -310,12 +312,12 @@ static BOOL get_printer_snum(PRINTER_HND *hnd, int *number) switch (Printer[pnum].printer_type) { case PRINTER_HANDLE_IS_PRINTER: - DEBUG(4,("get_printer_snum, short name:%s\n", Printer[pnum].dev.printername)); + DEBUG(4,("short name:%s\n", Printer[pnum].dev.printername)); for (snum=0;snumsize?size:len); *needed = len; if (idata) free(idata); - break; + /*break;*/ /*case 4: *numeric_data=atoi(idata); break;*/ - } + /*}*/ return (True); } free_a_printer(printer, 2); @@ -626,7 +630,9 @@ static void spoolss_reply_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u, prs_struct } spoolss_io_r_getprinterdata("", &r_u, rdata, 0); + DEBUG(3,("freeing memory\n")); if (r_u.data) free(r_u.data); + DEBUG(3,("freeing memory:ok\n")); } } @@ -1721,6 +1727,18 @@ static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number, } } +/**************************************************************************** +****************************************************************************/ +static void free_printer_info_2(PRINTER_INFO_2 *printer) +{ + if (printer->devmode->private!=NULL) + free(printer->devmode->private); + if (printer->devmode!=NULL) + free(printer->devmode); + if (printer!=NULL) + free(printer); +} + /**************************************************************************** ****************************************************************************/ static void free_enum_printers_info_1(PRINTER_INFO_1 **printers, uint32 total) @@ -1750,8 +1768,7 @@ static void free_enum_printers_info_2(PRINTER_INFO_2 **printers, uint32 total) { if (printers[number] != NULL) { - free(printers[number]->devmode); - free(printers[number]); + free_printer_info_2(printers[number]); } } free(printers); @@ -1903,8 +1920,7 @@ static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata, r_u.level=q_u->level; spoolss_io_r_getprinter("",&r_u,rdata,0); - free(printer->devmode); - free(printer); + free_printer_info_2(printer); break; } @@ -3265,7 +3281,7 @@ static void spoolss_reply_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, prs_stru uint32 type; fstring value; - uint8 *data; + uint8 *data=NULL; uint32 param_index; uint32 biggest_valuesize; @@ -3292,6 +3308,7 @@ static void spoolss_reply_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, prs_stru r_u.type=0; r_u.datasize=0; r_u.realdatasize=0; + r_u.status=0; param_index=0; biggest_valuesize=0; @@ -3306,7 +3323,10 @@ static void spoolss_reply_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, prs_stru } /* I wrote it, I didn't designed the protocol */ - SIVAL(&(r_u.value),0, 2*(biggest_valuesize+1) ); + if (biggest_valuesize!=0) + { + SIVAL(&(r_u.value),0, 2*(biggest_valuesize+1) ); + } r_u.data=(uint8 *)malloc(4*sizeof(uint8)); SIVAL(r_u.data, 0, biggest_datasize ); } @@ -3347,7 +3367,7 @@ static void spoolss_reply_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, prs_stru free_a_printer(printer, 2); } spoolss_io_r_enumprinterdata("", &r_u, rdata, 0); - free(r_u.data); + if (r_u.data!=NULL) free(r_u.data); } /**************************************************************************** -- cgit From f922d25ce820a644bf517e4d39cf7d9f0b3895f9 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 6 Jul 1999 20:33:24 +0000 Subject: oops, set password lengths to a boolean value. (This used to be commit e6d43ddb1bdb249f93dca65180964a61d281935b) --- source3/rpc_server/srv_netlog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 9c260d5759..45d9e009a6 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -633,8 +633,8 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, fstring user; fstring domain; - int nt_pw_len = id2->hdr_nt_chal_resp.str_str_len >= 24; - int lm_pw_len = id2->hdr_lm_chal_resp.str_str_len >= 24; + int nt_pw_len = id2->hdr_nt_chal_resp.str_str_len; + int lm_pw_len = id2->hdr_lm_chal_resp.str_str_len; unistr2_to_ascii(user , &id2->uni_user_name, sizeof(user)-1); unistr2_to_ascii(domain, &id2->uni_domain_name, sizeof(domain)-1); -- cgit From 1f33d5a8aaa6b9a94dde21529fe2aa407fb5ffa1 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 14 Jul 1999 19:21:44 +0000 Subject: code from bertl to allow remap of default built-in names to anything. parameter is "builtin rid file". Copyright 1999 Bertl (This used to be commit 80d36778432d42eb265ed9428f27a27250ba5e08) --- source3/rpc_server/srv_lookup.c | 69 ++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 43 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index 08f2e11d77..193c7931ab 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -52,10 +52,6 @@ extern fstring global_sam_name; extern DOM_SID global_sam_sid; extern DOM_SID global_sid_S_1_5_20; -extern rid_name builtin_alias_rids[]; -extern rid_name domain_user_rids[]; -extern rid_name domain_group_rids[]; - int make_dom_gids(DOMAIN_GRP *mem, int num_members, DOM_GID **ppgids) { int count; @@ -192,9 +188,9 @@ uint32 lookup_sid(DOM_SID *sid, char *name, uint8 *type) ********************************************************************/ uint32 lookup_wk_group_sid(DOM_SID *sid, char *group_name, uint8 *type) { - int i = 0; uint32 rid; DOM_SID tmp; + char *mapped; (*type) = SID_NAME_DOM_GRP; @@ -208,20 +204,16 @@ uint32 lookup_wk_group_sid(DOM_SID *sid, char *group_name, uint8 *type) DEBUG(5,("lookup_wk_group_sid: rid: %d", rid)); - while (domain_group_rids[i].rid != rid && domain_group_rids[i].rid != 0) - { - i++; - } - - if (domain_group_rids[i].rid != 0) + /* look up the well-known domain group rids first */ + mapped = lookup_wk_group_rid(rid); + if(mapped == NULL) { - fstrcpy(group_name, domain_group_rids[i].name); - DEBUG(5,(" = %s\n", group_name)); - return 0x0; + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; } - - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + fstrcpy(group_name, mapped); + DEBUG(5,(" = %s\n", group_name)); + return 0x0; } /******************************************************************* @@ -267,9 +259,9 @@ uint32 lookup_group_sid(DOM_SID *sid, char *group_name, uint8 *type) ********************************************************************/ uint32 lookup_wk_alias_sid(DOM_SID *sid, char *alias_name, uint8 *type) { - int i = 0; uint32 rid; DOM_SID tmp; + char *mapped; (*type) = SID_NAME_ALIAS; @@ -283,20 +275,16 @@ uint32 lookup_wk_alias_sid(DOM_SID *sid, char *alias_name, uint8 *type) DEBUG(5,("lookup_wk_alias_sid: rid: %d", rid)); - while (builtin_alias_rids[i].rid != rid && builtin_alias_rids[i].rid != 0) + /* look up the well-known alias group rids first */ + mapped = lookup_wk_alias_rid(rid); + if(mapped == NULL) { - i++; - } - - if (builtin_alias_rids[i].rid != 0) - { - fstrcpy(alias_name, builtin_alias_rids[i].name); - DEBUG(5,(" = %s\n", alias_name)); - return 0x0; + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; } - - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + fstrcpy(alias_name, mapped); + DEBUG(5,(" = %s\n", alias_name)); + return 0x0; } /******************************************************************* @@ -342,9 +330,9 @@ uint32 lookup_alias_sid(DOM_SID *sid, char *alias_name, uint8 *type) ********************************************************************/ uint32 lookup_wk_user_sid(DOM_SID *sid, char *user_name, uint8 *type) { - int i = 0; uint32 rid; DOM_SID tmp; + char *mapped; (*type) = SID_NAME_USER; @@ -359,20 +347,15 @@ uint32 lookup_wk_user_sid(DOM_SID *sid, char *user_name, uint8 *type) DEBUG(5,("lookup_wk_user_sid: rid: %d", rid)); /* look up the well-known domain user rids first */ - while (domain_user_rids[i].rid != rid && domain_user_rids[i].rid != 0) + mapped = lookup_wk_user_rid(rid); + if(mapped == NULL) { - i++; - } - - if (domain_user_rids[i].rid != 0) - { - fstrcpy(user_name, domain_user_rids[i].name); - DEBUG(5,(" = %s\n", user_name)); - return 0x0; + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; } - - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + fstrcpy(user_name, mapped); + DEBUG(5,(" = %s\n", user_name)); + return 0x0; } /******************************************************************* -- cgit From ae0d7718ebb14788c464c54de090a423491cdba2 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 21 Jul 1999 05:07:20 +0000 Subject: Tim Potter spotted compile error: matthew had added BDC support to smbd, which i didn't know about! (This used to be commit 30620b93e5c476ba7bf09c459ab4b7bea3f67642) --- source3/rpc_server/srv_netlog.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 45d9e009a6..91276a617f 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -228,6 +228,7 @@ static void net_reply_sam_logoff(NET_Q_SAM_LOGOFF *q_s, prs_struct *rdata, net_reply_sam_sync: *************************************************************************/ static void net_reply_sam_sync(NET_Q_SAM_SYNC *q_s, prs_struct *rdata, + uint8 sess_key[16], DOM_CRED *srv_creds, uint32 status) { NET_R_SAM_SYNC r_s; @@ -264,7 +265,7 @@ static void net_reply_sam_sync(NET_Q_SAM_SYNC *q_s, prs_struct *rdata, r_s.status = status; /* store the response in the SMB stream */ - net_io_r_sam_sync("", &r_s, rdata, 0); + net_io_r_sam_sync("", sess_key, &r_s, rdata, 0); } @@ -562,7 +563,7 @@ static void api_net_sam_sync( pipes_struct *p, } /* construct reply. */ - net_reply_sam_sync(&q_s, rdata, &srv_creds, status); + net_reply_sam_sync(&q_s, rdata, vuser->dc.sess_key, &srv_creds, status); } -- cgit From d300fc317319ac9b83f7475532847fb23b1d7ea6 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 26 Jul 1999 17:46:06 +0000 Subject: commented location where lookup_sids(), a direct call to the password database API, needs to be replaced with over-the-wire (actually, tcp/ip loopback) to smbd. in fact, this is the location where, if we want to put in an nt5 ldap lookup system or netware NDS instead, we make the calls to resolve users-to-sids and vice-versa: NOT by replacing rpc_server/srv_samr.c. (This used to be commit fd886af3317ca806c9c28f71afca5c7b063c1226) --- source3/rpc_server/srv_lsa.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index d8a74d627b..26153fca47 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -329,6 +329,9 @@ static void make_lsa_trans_names(DOM_R_REF *ref, if (sid_equal(&find_sid, &global_sam_sid) || sid_equal(&find_sid, &global_sid_S_1_5_20)) { + /* lkclXXXX REPLACE THIS FUNCTION WITH + samr_xxxx() routines + */ status = lookup_sid(&tmp_sid, name, &sid_name_use); } else -- cgit From f2e0bbffb5e40df4850b6bd0eae73a8fb0edc6d7 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 26 Jul 1999 21:47:23 +0000 Subject: renaming AUTH VERIFIER to AUTH NTLMSSP VERIFIER. ready for adding another RPC authentication system. (This used to be commit 1a211bafebad8c63d98b5ef275a6272013527c65) --- source3/rpc_server/srv_pipe.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 3e5d986935..458d7e883c 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -388,10 +388,10 @@ static BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *pd) if (!rpc_hdr_auth_chk(&(p->auth_info))) return False; - smb_io_rpc_auth_verifier("", &p->auth_verifier, pd, 0); + smb_io_rpc_auth_ntlmssp_verifier("", &p->auth_verifier, pd, 0); if (pd->offset == 0) return False; - if (!rpc_auth_verifier_chk(&(p->auth_verifier), "NTLMSSP", NTLMSSP_AUTH)) return False; + if (!rpc_auth_ntlmssp_verifier_chk(&(p->auth_verifier), "NTLMSSP", NTLMSSP_AUTH)) return False; return api_pipe_ntlmssp(p, pd); } @@ -436,7 +436,7 @@ static BOOL api_pipe_bind_and_alt_req(pipes_struct *p, prs_struct *pd, enum RPC_ if (p->ntlmssp_auth) { - smb_io_rpc_auth_verifier("", &p->auth_verifier, pd, 0); + smb_io_rpc_auth_ntlmssp_verifier("", &p->auth_verifier, pd, 0); if (pd->offset == 0) return False; p->ntlmssp_auth = strequal(p->auth_verifier.signature, "NTLMSSP"); @@ -521,9 +521,9 @@ static BOOL api_pipe_bind_and_alt_req(pipes_struct *p, prs_struct *pd, enum RPC_ /*** NTLMSSP verifier ***/ - make_rpc_auth_verifier(&p->auth_verifier, + make_rpc_auth_ntlmssp_verifier(&p->auth_verifier, "NTLMSSP", NTLMSSP_CHALLENGE); - smb_io_rpc_auth_verifier("", &p->auth_verifier, &p->rauth, 0); + smb_io_rpc_auth_ntlmssp_verifier("", &p->auth_verifier, &p->rauth, 0); mem_realloc_data(p->rauth.data, p->rauth.offset); /* NTLMSSP challenge ***/ -- cgit From 4bff2675746518af740e475e4e996247ac21d817 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 27 Jul 1999 10:46:44 +0000 Subject: - enumprintprocessors and enumprintmonitors added. - getjob (level 1 and 2) done. - better handling of getprinterdriver (level 2). - added workaround to print PCL files. Now the spoolss code should be compliant with all kind of printers :-) Jean Francois (This used to be commit bf9b639bf9162d61eb152af506dc2c1a7e8a4c85) --- source3/rpc_server/srv_spoolss.c | 334 ++++++++++++++++++++++++++++++++++----- 1 file changed, 297 insertions(+), 37 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 2cb5543f26..067fdd3ff7 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1424,18 +1424,25 @@ static void api_spoolss_rfnpcnex(pipes_struct *p, prs_struct *data, * construct_printer_info_0 * fill a printer_info_1 struct ********************************************************************/ -static void construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring servername, connection_struct *conn) +static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring servername, connection_struct *conn) { pstring chaine; int count; + NT_PRINTER_INFO_LEVEL ntprinter; print_queue_struct *queue=NULL; print_status_struct status; bzero(&status,sizeof(status)); + + if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0) + { + return (False); + } + count=get_printqueue(snum, conn ,&queue,&status); /* the description and the name are of the form \\server\share */ - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s",servername, lp_servicename(snum)); + slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s",servername, ntprinter.info_2->printername); make_unistr(&(printer->printername), chaine); @@ -1472,8 +1479,11 @@ static void construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring s printer->unknown21 = 0x0648; printer->unknown22 = 0x0; printer->unknown23 = 0x5; + if (queue) free(queue); - + + free_a_printer(ntprinter, 2); + return (True); } /******************************************************************** @@ -1727,14 +1737,21 @@ static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number, } } +/**************************************************************************** +****************************************************************************/ +static void free_devmode(DEVICEMODE *devmode) +{ + if (devmode->private!=NULL) + free(devmode->private); + if (devmode!=NULL) + free(devmode); +} + /**************************************************************************** ****************************************************************************/ static void free_printer_info_2(PRINTER_INFO_2 *printer) { - if (printer->devmode->private!=NULL) - free(printer->devmode->private); - if (printer->devmode!=NULL) - free(printer->devmode); + free_devmode(printer->devmode); if (printer!=NULL) free(printer); } @@ -2023,6 +2040,40 @@ static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, free_a_printer(printer, 2); } +/******************************************************************** + * copy a strings array and convert to UNICODE + ********************************************************************/ +static void make_unistr_array(UNISTR ***uni_array, char **char_array) +{ + int i=0; + char *v; + + DEBUG(6,("make_unistr_array\n")); + + for (v=char_array[i]; *v!='\0'; v=char_array[i]) + { + DEBUGADD(6,("i:%d:", i)); + DEBUGADD(6,("%s:%d:", v, strlen(v))); + + *uni_array=(UNISTR **)Realloc(*uni_array, sizeof(UNISTR *)*(i+1)); + DEBUGADD(7,("realloc:[%p],", *uni_array)); + + (*uni_array)[i]=(UNISTR *)malloc( sizeof(UNISTR) ); + DEBUGADD(7,("alloc:[%p],", (*uni_array)[i])); + + make_unistr( (*uni_array)[i], v ); + DEBUGADD(7,("copy\n")); + + i++; + } + DEBUGADD(7,("last one\n")); + + *uni_array=(UNISTR **)Realloc(*uni_array, sizeof(UNISTR *)*(i+1)); + (*uni_array)[i]=(UNISTR *)malloc( sizeof(UNISTR)); + (*uni_array)[i]=0x0000; + DEBUGADD(6,("last one:done\n")); +} + /******************************************************************** * construct_printer_info_3 * fill a printer_info_3 struct @@ -2062,7 +2113,8 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, make_unistr( &(info->monitorname), driver.info_3->monitorname ); make_unistr( &(info->defaultdatatype), driver.info_3->defaultdatatype ); - make_unistr( &(info->dependentfiles), "" ); + info->dependentfiles=NULL; + make_unistr_array(&(info->dependentfiles), driver.info_3->dependentfiles); } /******************************************************************** @@ -2227,26 +2279,6 @@ static void api_spoolss_endpageprinter(pipes_struct *p, prs_struct *data, spoolss_reply_endpageprinter(&q_u, rdata); } -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_startdocprinter(SPOOL_Q_STARTDOCPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_STARTDOCPRINTER r_u; - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - r_u.jobid=Printer[pnum].current_jobid; - r_u.status=0x0; - - spoolss_io_r_startdocprinter("",&r_u,rdata,0); - } - else - { - DEBUG(3,("Error in startdocprinter printer handle (pnum=%x)\n",pnum)); - } -} - /******************************************************************** * api_spoolss_getprinter * called from the spoolss dispatcher @@ -2256,8 +2288,12 @@ static void api_spoolss_startdocprinter(pipes_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_STARTDOCPRINTER q_u; + SPOOL_R_STARTDOCPRINTER r_u; + DOC_INFO_1 *info_1; + pstring fname; pstring tempname; + pstring datatype; int fd = -1; int snum; int pnum; @@ -2265,9 +2301,29 @@ static void api_spoolss_startdocprinter(pipes_struct *p, prs_struct *data, /* decode the stream and fill the struct */ spoolss_io_q_startdocprinter("", &q_u, data, 0); + info_1=&(q_u.doc_info_container.docinfo.doc_info_1); + r_u.status=0x0; pnum = find_printer_index_by_hnd(&(q_u.handle)); - if (OPEN_HANDLE(pnum)) + /* + * a nice thing with NT is it doesn't listen to what you tell it. + * when asked to send _only_ RAW datas, it tries to send datas + * in EMF format. + * + * So I add checks like in NT Server ... + */ + + if (info_1->p_datatype != 0) + { + unistr2_to_ascii(datatype, &(info_1->docname), sizeof(datatype)); + if (strcmp(datatype, "RAW") != 0) + { + r_u.jobid=0; + r_u.status=1804; + } + } + + if (r_u.status==0 && OPEN_HANDLE(pnum)) { /* get the share number of the printer */ get_printer_snum(&(q_u.handle),&snum); @@ -2291,8 +2347,12 @@ static void api_spoolss_startdocprinter(pipes_struct *p, prs_struct *data, Printer[pnum].document_fd=fd; Printer[pnum].document_started=True; - } - spoolss_reply_startdocprinter(&q_u, rdata); + r_u.jobid=Printer[pnum].current_jobid; + r_u.status=0x0; + + } + + spoolss_io_r_startdocprinter("",&r_u,rdata,0); } /**************************************************************************** @@ -2665,19 +2725,30 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, /**************************************************************************** ****************************************************************************/ -static void fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, +static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, int position, int snum) { pstring temp_name; + DEVICEMODE *devmode; + NT_PRINTER_INFO_LEVEL ntprinter; + pstring chaine; struct tm *t; time_t unixdate = time(NULL); + + if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) + { + return (False); + } t=gmtime(&unixdate); snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); job_info->jobid=queue->job; - make_unistr(&(job_info->printername), lp_servicename(snum)); + + snprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", global_myname, ntprinter.info_2->printername); + make_unistr(&(job_info->printername), chaine); + make_unistr(&(job_info->machinename), temp_name); make_unistr(&(job_info->username), queue->user); make_unistr(&(job_info->document), queue->file); @@ -2685,9 +2756,6 @@ static void fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, make_unistr(&(job_info->datatype), "RAW"); make_unistr(&(job_info->printprocessor), "winprint"); make_unistr(&(job_info->parameters), ""); - -/* here the devicemode should be filled up */ - make_unistr(&(job_info->text_status), ""); /* and here the security descriptor */ @@ -2702,6 +2770,14 @@ static void fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, make_systemtime(&(job_info->submitted), t); job_info->timeelapsed=0; job_info->pagesprinted=0; + + devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE)); + ZERO_STRUCTP(devmode); + construct_dev_mode(devmode, snum, global_myname); + job_info->devmode=devmode; + + free_a_printer(ntprinter, 2); + return (True); } /**************************************************************************** @@ -2772,6 +2848,7 @@ static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata, con } case 2: { + free_devmode(job_info_2->devmode); free(job_info_2); break; } @@ -3470,7 +3547,6 @@ static void api_spoolss_addform(pipes_struct *p, prs_struct *data, spoolss_reply_addform(&q_u, rdata); } - /**************************************************************************** ****************************************************************************/ static void spoolss_reply_setform(SPOOL_Q_SETFORM *q_u, prs_struct *rdata) @@ -3510,6 +3586,187 @@ static void api_spoolss_setform(pipes_struct *p, prs_struct *data, spoolss_reply_setform(&q_u, rdata); } +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_enumprintprocessors(SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *rdata) +{ + SPOOL_R_ENUMPRINTPROCESSORS r_u; + PRINTPROCESSOR_1 *info_1; + + DEBUG(5,("spoolss_reply_enumprintprocessors\n")); + + /* + * Enumerate the print processors ... + * + * Just reply with "winprint", to keep NT happy + * and I can use my nice printer checker. + */ + + r_u.status = 0x0; + r_u.offered = q_u->buf_size; + r_u.level = q_u->level; + + r_u.numofprintprocessors = 0x1; + + info_1 = (PRINTPROCESSOR_1 *)malloc(sizeof(PRINTPROCESSOR_1)); + + make_unistr(&(info_1->name), "winprint"); + + r_u.info_1=info_1; + + spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0); +} + +/**************************************************************************** +****************************************************************************/ +static void api_spoolss_enumprintprocessors(pipes_struct *p, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_ENUMPRINTPROCESSORS q_u; + + spoolss_io_q_enumprintprocessors("", &q_u, data, 0); + + spoolss_reply_enumprintprocessors(&q_u, rdata); +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_enumprintmonitors(SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *rdata) +{ + SPOOL_R_ENUMPRINTMONITORS r_u; + PRINTMONITOR_1 *info_1; + + DEBUG(5,("spoolss_reply_enumprintmonitors\n")); + + /* + * Enumerate the print monitors ... + * + * Just reply with "Local Port", to keep NT happy + * and I can use my nice printer checker. + */ + + r_u.status = 0x0; + r_u.offered = q_u->buf_size; + r_u.level = q_u->level; + + r_u.numofprintmonitors = 0x1; + + info_1 = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1)); + + make_unistr(&(info_1->name), "Local Port"); + + r_u.info_1=info_1; + + spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0); +} + +/**************************************************************************** +****************************************************************************/ +static void api_spoolss_enumprintmonitors(pipes_struct *p, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_ENUMPRINTMONITORS q_u; + + spoolss_io_q_enumprintmonitors("", &q_u, data, 0); + + spoolss_reply_enumprintmonitors(&q_u, rdata); +} + +/**************************************************************************** +****************************************************************************/ +static void spoolss_reply_getjob(SPOOL_Q_GETJOB *q_u, prs_struct *rdata, connection_struct *conn) +{ + SPOOL_R_GETJOB r_u; + int snum; + int count; + int i; + print_queue_struct *queue=NULL; + print_status_struct status; + JOB_INFO_1 *job_info_1=NULL; + JOB_INFO_2 *job_info_2=NULL; + + DEBUG(4,("spoolss_reply_getjob\n")); + + bzero(&status,sizeof(status)); + + r_u.offered=q_u->buf_size; + + if (get_printer_snum(&(q_u->handle), &snum)) + { + count=get_printqueue(snum, conn, &queue, &status); + + r_u.level=q_u->level; + + DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", count, status.status, status.message)); + + switch (r_u.level) + { + case 1: + { + job_info_1=(JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1)); + + for (i=0; ijobid) + { + fill_job_info_1(job_info_1, &(queue[i]), i, snum); + } + } + r_u.job.job_info_1=job_info_1; + break; + } + case 2: + { + job_info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2)); + + for (i=0; ijobid) + { + fill_job_info_2(job_info_2, &(queue[i]), i, snum); + } + } + r_u.job.job_info_2=job_info_2; + break; + } + } + } + + r_u.status=0x0; + + spoolss_io_r_getjob("",&r_u,rdata,0); + switch (r_u.level) + { + case 1: + { + free(job_info_1); + break; + } + case 2: + { + free_devmode(job_info_2->devmode); + free(job_info_2); + break; + } + } + if (queue) free(queue); + +} + +/**************************************************************************** +****************************************************************************/ +static void api_spoolss_getjob(pipes_struct *p, prs_struct *data, + prs_struct *rdata) +{ + SPOOL_Q_GETJOB q_u; + + spoolss_io_q_getjob("", &q_u, data, 0); + + spoolss_reply_getjob(&q_u, rdata, p->conn); + + spoolss_io_free_buffer(&(q_u.buffer)); +} + /******************************************************************* \pipe\spoolss commands ********************************************************************/ @@ -3544,6 +3801,9 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata }, {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform }, {"SPOOLSS_SETFORM", SPOOLSS_SETFORM, api_spoolss_setform }, + {"SPOOLSS_ENUMPRINTPROCESSORS", SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_enumprintprocessors }, + {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors }, + {"SPOOLSS_GETJOB", SPOOLSS_GETJOB, api_spoolss_getjob }, { NULL, 0, NULL } }; -- cgit From e0559720098ca57ab29badca282763879cbac6e4 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 17 Aug 1999 23:16:17 +0000 Subject: patch from Michael Glauche to list connections from STATUS..LCK. (This used to be commit 91a66dd5c3a551691fbf91e782cb6ff16dfea37b) --- source3/rpc_server/srv_srvsvc.c | 47 +++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 5b43ec0303..834c95615a 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -509,8 +509,18 @@ static void srv_reply_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n, ********************************************************************/ static void make_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *stot) { - uint32 num_entries = 0; - (*stot) = 1; + uint32 num_entries = 0; + struct connect_record *crec; + uint32 connection_count; + + if (!get_connection_status(&crec, &connection_count)) + { + (*snum) = 0; + (*stot) = 0; + return; + } + + (*stot) = connection_count; if (ss0 == NULL) { @@ -518,13 +528,13 @@ static void make_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *sto return; } - DEBUG(5,("make_srv_conn_0_ss0\n")); + DEBUG(0,("make_srv_conn_0_ss0\n")); if (snum) { for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) { - make_srv_conn_info0(&(ss0->info_0 [num_entries]), (*stot)); + make_srv_conn_info0(&(ss0->info_0 [num_entries]), (*snum)); /* move on to creating next connection */ /* move on to creating next conn */ @@ -550,6 +560,8 @@ static void make_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *sto (*stot) = 0; } + + free(crec); } /******************************************************************* @@ -579,8 +591,21 @@ static void make_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1, ********************************************************************/ static void make_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *stot) { - uint32 num_entries = 0; - (*stot) = 1; + uint32 num_entries = 0; + time_t current_time; + time_t diff; + + struct connect_record *crec; + uint32 connection_count; + + if (!get_connection_status(&crec, &connection_count)) + { + (*snum) = 0; + (*stot) = 0; + return; + } + + (*stot) = connection_count; if (ss1 == NULL) { @@ -588,15 +613,21 @@ static void make_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto return; } + current_time=time(NULL); + DEBUG(5,("make_srv_conn_1_ss1\n")); if (snum) { for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) { + diff = current_time - crec[num_entries].start; make_srv_conn_1_info(&(ss1->info_1 [num_entries]), &(ss1->info_1_str[num_entries]), - (*stot), 0x3, 1, 1, 3,"dummy_user", "IPC$"); + (*snum), 0, 0, 1, diff,uidtoname(crec[num_entries].uid), + crec[num_entries].name); + +/* FIXME : type of connection + number of locked files */ /* move on to creating next connection */ /* move on to creating next conn */ @@ -621,6 +652,8 @@ static void make_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto (*stot) = 0; } + + free(crec); } /******************************************************************* -- cgit From b3f59299a089b5860653fea1bee82253ec18cc87 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 18 Aug 1999 21:18:42 +0000 Subject: patch from michael glauche to add session enum code into smbd. (This used to be commit e90e38c66d51dc1808f716c016299b1604636ce9) --- source3/rpc_server/srv_srvsvc.c | 42 +++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 834c95615a..35f1676232 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -300,23 +300,36 @@ static void make_srv_sess_0_info(SESS_INFO_0 *se0, SESS_INFO_0_STR *str0, static void make_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot) { uint32 num_entries = 0; - (*stot) = 1; + struct connect_record *crec; + uint32 session_count; - if (ss0 == NULL) + if (!get_session_count(&crec, &session_count)) { (*snum) = 0; + (*stot) = 0; return; } - DEBUG(5,("make_srv_sess_0_ss0\n")); + (*stot) = session_count; + + DEBUG(0,("Session Count : %u\n",session_count)); + + if (ss0 == NULL) + { + (*snum) = 0; + free(crec); + return; + } if (snum) { + DEBUG(0,("snum ok\n")); for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { make_srv_sess_0_info(&(ss0->info_0 [num_entries]), - &(ss0->info_0_str[num_entries]), "MACHINE"); + &(ss0->info_0_str[num_entries]), crec[num_entries].machine); + DEBUG(0,("make_srv_sess_0_info\n")); /* move on to creating next session */ /* move on to creating next sess */ num_entries++; @@ -337,6 +350,7 @@ static void make_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *sto ss0->ptr_sess_info = 0; ss0->num_entries_read2 = 0; } + free(crec); } /******************************************************************* @@ -368,11 +382,23 @@ static void make_srv_sess_1_info(SESS_INFO_1 *se1, SESS_INFO_1_STR *str1, static void make_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot) { uint32 num_entries = 0; - (*stot) = 1; + struct connect_record *crec; + uint32 session_count; + + if (!get_session_count(&crec, &session_count)) + { + (*snum) = 0; + (*stot) = 0; + return; + } + (*stot) = session_count; + + DEBUG(0,("Session Count (info1) : %u\n",session_count)); if (ss1 == NULL) { (*snum) = 0; + free(crec); return; } @@ -382,9 +408,12 @@ static void make_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto { for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { + DEBUG(0,("sess1 machine: %s, uid : %u\n",crec[num_entries].machine,crec[num_entries].uid)); make_srv_sess_1_info(&(ss1->info_1 [num_entries]), &(ss1->info_1_str[num_entries]), - "MACHINE", "dummy_user", 1, 10, 5, 0); + crec[num_entries].machine, + uidtoname(crec[num_entries].uid), 1, 10, 5, 0); +/* What are these on the End ??? */ /* move on to creating next session */ /* move on to creating next sess */ @@ -408,6 +437,7 @@ static void make_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto (*stot) = 0; } + free(crec); } /******************************************************************* -- cgit From 736c507722ff5f1f7cb0bf31c2f5ea4af821fba5 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 30 Aug 1999 17:15:59 +0000 Subject: debugged enumgroups -g option (This used to be commit 1cde47ba6a6409e0ae178ca9f44be2123bef0f9d) --- source3/rpc_server/srv_samr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 257f8869f7..c020d33340 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1131,13 +1131,16 @@ static void samr_reply_query_groupinfo(SAMR_Q_QUERY_GROUPINFO *q_u, { r_e.ptr = 1; ctr.switch_value1 = 1; - make_samr_group_info1(&ctr.group.info1, "account name", "account description"); + make_samr_group_info1(&ctr.group.info1, + "account name", + "account description"); } else if (q_u->switch_level == 4) { r_e.ptr = 1; ctr.switch_value1 = 4; - make_samr_group_info4(&ctr.group.info4, "account description"); + make_samr_group_info4(&ctr.group.info4, + "account description"); } else { -- cgit From 58f8159566e49df82be1ed0ade83821a184b9203 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 31 Aug 1999 13:19:55 +0000 Subject: matthew chapman identified 4 previously unknown samr functions. (This used to be commit 001b53866c819045bc52330cad5746e1a2f7a4b1) --- source3/rpc_server/srv_samr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index c020d33340..b055891611 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -2932,14 +2932,14 @@ static struct api_struct api_samr_cmds [] = { "SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, { "SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user }, { "SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids }, - { "SAMR_UNKNOWN_38" , SAMR_UNKNOWN_38 , api_samr_unknown_38 }, + { "SAMR_GET_DOM_PWINFO" , SAMR_GET_DOM_PWINFO , api_samr_unknown_38 }, { "SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, { "SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, { "SAMR_OPEN_GROUP" , SAMR_OPEN_GROUP , api_samr_open_group }, { "SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, { "SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, - { "SAMR_UNKNOWN_3" , SAMR_UNKNOWN_3 , api_samr_unknown_3 }, - { "SAMR_UNKNOWN_2C" , SAMR_UNKNOWN_2C , api_samr_unknown_2c }, + { "SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_unknown_3 }, + { "SAMR_GET_USRDOM_PWINFO", SAMR_GET_USRDOM_PWINFO, api_samr_unknown_2c }, { NULL , 0 , NULL } }; -- cgit From 178ad937ecb3a3d30fde6f7ac5cc7fe653c5ec8d Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 9 Sep 1999 18:15:08 +0000 Subject: allan hourihane sent log 100 in which showed that some really old code for lsa_close response was messing up. fixed by calling lsa_io_r_close() which i've been meaning to do for over eighteen months. (This used to be commit f9a0ea09486b18a130ce1a1e5381ca61e0293c75) --- source3/rpc_server/srv_lsa.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 26153fca47..36259477da 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -571,23 +571,12 @@ static void api_lsa_lookup_names( pipes_struct *p, prs_struct *data, static void api_lsa_close( pipes_struct *p, prs_struct *data, prs_struct *rdata) { - /* XXXX this is NOT good */ - char *q = mem_data(&(rdata->data), rdata->offset); + LSA_R_CLOSE r_c; - SIVAL(q, 0, 0); - q += 4; - SIVAL(q, 0, 0); - q += 4; - SIVAL(q, 0, 0); - q += 4; - SIVAL(q, 0, 0); - q += 4; - SIVAL(q, 0, 0); - q += 4; - SIVAL(q, 0, 0); - q += 4; + ZERO_STRUCT(r_c); - rdata->offset += 24; + /* store the response in the SMB stream */ + lsa_io_r_close("", &r_c, rdata, 0); } /*************************************************************************** -- cgit From 7b88001235e6228ed672541f4afd2b06b610b8e1 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 24 Sep 1999 14:45:21 +0000 Subject: Correctly handle the dependent files in the printer_driver_info_3 struct It means complex printer drivers should now download fine. J.F. (This used to be commit a893df5c00189d7e81efd619a4a4ee2bd8ead61f) --- source3/rpc_server/srv_spoolss.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 067fdd3ff7..eee3fcbe68 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -2012,11 +2012,11 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, driver.info_3->driverpath); make_unistr( &(info->driverpath), temp_driverpath ); - snprintf(temp_datafile, sizeof(temp_driverpath)-1, "%s%s", where, + snprintf(temp_datafile, sizeof(temp_datafile)-1, "%s%s", where, driver.info_3->datafile); make_unistr( &(info->datafile), temp_datafile ); - snprintf(temp_configfile, sizeof(temp_driverpath)-1, "%s%s", where, + snprintf(temp_configfile, sizeof(temp_configfile)-1, "%s%s", where, driver.info_3->configfile); make_unistr( &(info->configfile), temp_configfile ); } @@ -2043,10 +2043,11 @@ static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, /******************************************************************** * copy a strings array and convert to UNICODE ********************************************************************/ -static void make_unistr_array(UNISTR ***uni_array, char **char_array) +static void make_unistr_array(UNISTR ***uni_array, char **char_array, char *where) { int i=0; char *v; + pstring line; DEBUG(6,("make_unistr_array\n")); @@ -2061,7 +2062,8 @@ static void make_unistr_array(UNISTR ***uni_array, char **char_array) (*uni_array)[i]=(UNISTR *)malloc( sizeof(UNISTR) ); DEBUGADD(7,("alloc:[%p],", (*uni_array)[i])); - make_unistr( (*uni_array)[i], v ); + snprintf(line, sizeof(line)-1, "%s%s", where, v); + make_unistr( (*uni_array)[i], line ); DEBUGADD(7,("copy\n")); i++; @@ -2114,7 +2116,7 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, make_unistr( &(info->defaultdatatype), driver.info_3->defaultdatatype ); info->dependentfiles=NULL; - make_unistr_array(&(info->dependentfiles), driver.info_3->dependentfiles); + make_unistr_array(&(info->dependentfiles), driver.info_3->dependentfiles, where); } /******************************************************************** -- cgit From 0490365b04564750d73eea36af0ba1444d1d3d77 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Sat, 25 Sep 1999 14:18:48 +0000 Subject: Don't duplicate forms anymore, just update the definition. Many memory leaks fixed. J.F. (This used to be commit f328ae8024584599324ae4263bb9fb89a358279f) --- source3/rpc_server/srv_spoolss.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index eee3fcbe68..736ed07dca 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1728,7 +1728,7 @@ static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number, { DEBUG(4,("Found a printer: %s[%x]\n",lp_servicename(snum),snum)); *printers=Realloc(*printers, (*number+1)*sizeof(PRINTER_INFO_2 *)); - DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1 pointers at [%p]\n", *number+1, *printers)); + DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2 pointers at [%p]\n", *number+1, *printers)); if (enum_printer_info_2( &((*printers)[*number]), snum, *number, conn) ) { (*number)++; @@ -2071,7 +2071,6 @@ static void make_unistr_array(UNISTR ***uni_array, char **char_array, char *wher DEBUGADD(7,("last one\n")); *uni_array=(UNISTR **)Realloc(*uni_array, sizeof(UNISTR *)*(i+1)); - (*uni_array)[i]=(UNISTR *)malloc( sizeof(UNISTR)); (*uni_array)[i]=0x0000; DEBUGADD(6,("last one:done\n")); } @@ -2190,8 +2189,20 @@ static void spoolss_reply_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_ if (info1!=NULL) free(info1); if (info2!=NULL) free(info2); - if (info3!=NULL) free(info3); + if (info3!=NULL) + { + UNISTR **dependentfiles; + int j=0; + dependentfiles=info3->dependentfiles; + while ( dependentfiles[j] != NULL ) + { + free(dependentfiles[j]); + j++; + } + free(dependentfiles); + free(info3); + } } /******************************************************************** @@ -3055,6 +3066,20 @@ static void spoolss_reply_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, pr } case 3: { + UNISTR **dependentfiles; + + for (i=0; i Date: Mon, 27 Sep 1999 13:12:55 +0000 Subject: don't leak printer handles, don't coredump when adding forms, and a small non obvious memory leak in the rpc buffers J.F. (This used to be commit bee11f8889378b9f1cc6e2818fd0f8dd7ddcf10d) --- source3/rpc_server/srv_spoolss.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 736ed07dca..166ac5a452 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -407,7 +407,19 @@ static void spoolss_reply_open_printer(SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *rd } set_printer_hnd_accesstype(&(r_u.handle), q_u->access_required); + + + /* if there is a error free the printer entry */ + if (r_u.status != 0x00000000) + { + int pnum; + + pnum = find_printer_index_by_hnd(&(r_u.handle)); + Printer[pnum].open=False; + clear_handle(&(r_u.handle)); + } + spoolss_io_r_open_printer("",&r_u,rdata,0); } @@ -669,7 +681,6 @@ static void spoolss_reply_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *rd { Printer[pnum].open=False; r_u.status=0x0; - spoolss_io_r_closeprinter("",&r_u,rdata,0); } else { @@ -3551,9 +3562,9 @@ static void spoolss_reply_addform(SPOOL_Q_ADDFORM *q_u, prs_struct *rdata) { count=get_ntforms(&list); - add_a_form(&list, q_u->form, count); + add_a_form(&list, q_u->form, &count); - write_ntforms(&list, count+1); + write_ntforms(&list, count); free(list); } -- cgit From 003f7364fd54ccdd190d447e275b70b0f76e95f7 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 15 Oct 1999 20:00:30 +0000 Subject: adding error checking in parsing code (This used to be commit 4c98d71ebd3f1cdaef664d46c998c864af34632a) --- source3/rpc_server/srv_pipe_hnd.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 4361c0772e..bd712a1702 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -182,6 +182,7 @@ ssize_t write_pipe(pipes_struct *p, char *data, size_t n) pd.data = &data_buf; pd.align = 4; pd.io = True; + pd.error = False; pd.offset = 0; return rpc_command(p, &pd) ? ((ssize_t)n) : -1; -- cgit From 6f9105c853020fde1691a28cd707d6d3f6561b4d Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 21 Oct 1999 16:53:50 +0000 Subject: various. debug levels changed. nmbd doesn't need libsmb/clienttrust.c. samr_lookup_rids() moved to a dynamic memory structure not a static one limited to 32 RIDs. cli_pipe.c reading wasn't checking ERRmoredata when DOS error codes negotiated (this terminates MSRPC code with prejudice). (This used to be commit 8976eca2db43576c32069dcda017e8777048e007) --- source3/rpc_server/srv_samr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index b055891611..876035186e 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1654,6 +1654,7 @@ static void samr_reply_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u, DOM_SID pol_sid; SAMR_R_LOOKUP_RIDS r_u; + ZERO_STRUCT(r_u); DEBUG(5,("samr_lookup_rids: %d\n", __LINE__)); -- cgit From 45b794bdde0cb906216425c8fc2af8610aa8ad3c Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 21 Oct 1999 19:02:57 +0000 Subject: the dynamic memory alloc blood-fest goes on... (This used to be commit 134b20e2a7b5ddfa4cc9bf100de5025c7b98f594) --- source3/rpc_server/srv_samr.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 876035186e..b1ee0cfe31 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1242,6 +1242,7 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, fstring usr_sid_str; SAMR_R_QUERY_USERALIASES r_u; + ZERO_STRUCT(r_u); DEBUG(5,("samr_query_useraliases: %d\n", __LINE__)); @@ -1340,6 +1341,7 @@ static void api_samr_query_useraliases( pipes_struct *p, prs_struct *data, prs_s SAMR_Q_QUERY_USERALIASES q_u; samr_io_q_query_useraliases("", &q_u, data, 0); samr_reply_query_useraliases(&q_u, rdata); + samr_free_q_query_useraliases(&q_u); } /******************************************************************* @@ -1704,6 +1706,7 @@ static void api_samr_lookup_rids( pipes_struct *p, prs_struct *data, prs_struct SAMR_Q_LOOKUP_RIDS q_u; samr_io_q_lookup_rids("", &q_u, data, 0); samr_reply_lookup_rids(&q_u, rdata); + samr_free_q_lookup_rids(&q_u); } -- cgit From 8e1f542ddf97fef925a88e2c3d9c1e82fb2f6683 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 25 Oct 1999 16:22:08 +0000 Subject: one of those wonderful moments when running against a different MSRPC implementation (NT5) when you discover that your code is trash. samr_enum_dom_users(), samr_enum_dom_aliases() and samr_enum_dom_groups() all take a HANDLE for multiple-call enumeration purposes. (This used to be commit 19490d8b4fb8a103f3df4e6104f6f22937b0c518) --- source3/rpc_server/srv_samr.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index b1ee0cfe31..bfbeb5718c 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -639,7 +639,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, fstring sid_str; r_e.status = 0x0; - r_e.num_entries = 0; + r_e.num_entries2 = 0; /* find the policy handle. open a policy on it. */ if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &sid)) @@ -666,7 +666,9 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, if (r_e.status == 0x0) { - make_samr_r_enum_dom_groups(&r_e, num_entries, grps, r_e.status); + make_samr_r_enum_dom_groups(&r_e, + q_u->start_idx + num_entries, + num_entries, grps, r_e.status); } /* store the response in the SMB stream */ @@ -708,7 +710,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, fstring sid_str; r_e.status = 0x0; - r_e.num_entries = 0; + r_e.num_entries2 = 0; /* find the policy handle. open a policy on it. */ if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &sid)) @@ -750,7 +752,9 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, if (r_e.status == 0x0) { - make_samr_r_enum_dom_aliases(&r_e, num_entries, alss, r_e.status); + make_samr_r_enum_dom_aliases(&r_e, + q_u->start_idx + num_entries, + num_entries, alss, r_e.status); } /* store the response in the SMB stream */ @@ -914,7 +918,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, if ((status == 0) && (num_entries < num_sam_entries)) { - status = NT_STATUS_MORE_ENTRIES; + status = STATUS_MORE_ENTRIES; } make_samr_r_query_dispinfo(&r_e, num_entries, data_size, -- cgit From 050121b1a14cc00ca004c31fc3c9b5677d203fea Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 27 Oct 1999 17:20:55 +0000 Subject: rewrote api_net_sam_logon() to be a little clearer. (This used to be commit 3adc31083b5308e983e057c7b942242209d74f59) --- source3/rpc_server/srv_netlog.c | 276 ++++++++++++++++++++-------------------- 1 file changed, 136 insertions(+), 140 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 91276a617f..d51ed58113 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -527,9 +527,7 @@ static void api_net_sam_logoff( pipes_struct *p, memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); /* construct reply. always indicate success */ - net_reply_sam_logoff(&q_l, rdata, - &srv_cred, - 0x0); + net_reply_sam_logoff(&q_l, rdata, &srv_cred, 0x0); } /************************************************************************* @@ -657,17 +655,11 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, /************************************************************************* api_net_sam_logon: *************************************************************************/ -static void api_net_sam_logon( pipes_struct *p, - prs_struct *data, - prs_struct *rdata) +static uint32 reply_net_sam_logon( NET_Q_SAM_LOGON *q_l, user_struct *vuser, + DOM_CRED *srv_cred, NET_USER_INFO_3 *usr_info) { - NET_Q_SAM_LOGON q_l; - NET_ID_INFO_CTR ctr; - NET_USER_INFO_3 usr_info; - uint32 status = 0x0; - DOM_CRED srv_cred; struct sam_passwd *sam_pass = NULL; - UNISTR2 *uni_samlogon_user = NULL; + UNISTR2 *uni_samusr = NULL; UNISTR2 *uni_domain = NULL; fstring nt_username; @@ -688,120 +680,108 @@ static void api_net_sam_logon( pipes_struct *p, uint32 user_rid ; uint32 group_rid; - user_struct *vuser = NULL; - - if ((vuser = get_valid_user_struct(p->vuid)) == NULL) - return; - - q_l.sam_id.ctr = &ctr; - - net_io_q_sam_logon("", &q_l, data, 0); + int num_gids = 0; + DOMAIN_GRP *grp_mem = NULL; + DOM_GID *gids = NULL; /* checks and updates credentials. creates reply credentials */ if (!deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), - &(q_l.sam_id.client.cred), &srv_cred)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - else + &(q_l->sam_id.client.cred), srv_cred)) { - memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); + return 0xC0000000 | NT_STATUS_INVALID_HANDLE; } + + memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); /* find the username */ - if (status == 0) + switch (q_l->sam_id.logon_level) { - switch (q_l.sam_id.logon_level) + case INTERACTIVE_LOGON_TYPE: { - case INTERACTIVE_LOGON_TYPE: - { - uni_samlogon_user = &(q_l.sam_id.ctr->auth.id1.uni_user_name); - uni_domain = &(q_l.sam_id.ctr->auth.id1.uni_domain_name); + uni_samusr = &(q_l->sam_id.ctr->auth.id1.uni_user_name); + uni_domain = &(q_l->sam_id.ctr->auth.id1.uni_domain_name); - DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", global_sam_name)); - break; - } - case NET_LOGON_TYPE: - { - uni_samlogon_user = &(q_l.sam_id.ctr->auth.id2.uni_user_name); - uni_domain = &(q_l.sam_id.ctr->auth.id2.uni_domain_name); + DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", global_sam_name)); + break; + } + case NET_LOGON_TYPE: + { + uni_samusr = &(q_l->sam_id.ctr->auth.id2.uni_user_name); + uni_domain = &(q_l->sam_id.ctr->auth.id2.uni_domain_name); - DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", global_sam_name)); - break; - } - default: - { - DEBUG(2,("SAM Logon: unsupported switch value\n")); - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; - break; - } - } /* end switch */ - } /* end if status == 0 */ + DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", global_sam_name)); + break; + } + default: + { + DEBUG(2,("SAM Logon: unsupported switch value\n")); + return 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + } + } /* check username exists */ - if (status == 0) - { - unistr2_to_ascii(nt_username, uni_samlogon_user, - sizeof(nt_username)-1); + unistr2_to_ascii(nt_username, uni_samusr, + sizeof(nt_username)-1); - DEBUG(3,("User:[%s]\n", nt_username)); + DEBUG(3,("User:[%s]\n", nt_username)); - become_root(True); - sam_pass = getsam21pwntnam(nt_username); - unbecome_root(True); + become_root(True); + sam_pass = getsam21pwntnam(nt_username); + unbecome_root(True); - if (sam_pass == NULL) - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - } - else if (IS_BITS_SET_ALL(sam_pass->acct_ctrl, ACB_DISABLED) && - IS_BITS_CLR_ALL(sam_pass->acct_ctrl, ACB_PWNOTREQ)) - { - status = 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED; - } + if (sam_pass == NULL) + { + return 0xC0000000 | NT_STATUS_NO_SUCH_USER; } - - if (status == 0x0) + else if (IS_BITS_SET_ALL(sam_pass->acct_ctrl, ACB_DISABLED) && + IS_BITS_CLR_ALL(sam_pass->acct_ctrl, ACB_PWNOTREQ)) { - logon_time = sam_pass->logon_time; - logoff_time = sam_pass->logoff_time; - kickoff_time = sam_pass->kickoff_time; - pass_last_set_time = sam_pass->pass_last_set_time; - pass_can_change_time = sam_pass->pass_can_change_time; - pass_must_change_time = sam_pass->pass_must_change_time; - - fstrcpy(nt_name , sam_pass->nt_name); - fstrcpy(full_name , sam_pass->full_name); - fstrcpy(logon_script, sam_pass->logon_script); - fstrcpy(profile_path, sam_pass->profile_path); - fstrcpy(home_dir , sam_pass->home_dir); - fstrcpy(dir_drive , sam_pass->dir_drive); - - user_rid = sam_pass->user_rid; - group_rid = sam_pass->group_rid; + return 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED; } + logon_time = sam_pass->logon_time; + logoff_time = sam_pass->logoff_time; + kickoff_time = sam_pass->kickoff_time; + pass_last_set_time = sam_pass->pass_last_set_time; + pass_can_change_time = sam_pass->pass_can_change_time; + pass_must_change_time = sam_pass->pass_must_change_time; + + fstrcpy(nt_name , sam_pass->nt_name); + fstrcpy(full_name , sam_pass->full_name); + fstrcpy(logon_script, sam_pass->logon_script); + fstrcpy(profile_path, sam_pass->profile_path); + fstrcpy(home_dir , sam_pass->home_dir); + fstrcpy(dir_drive , sam_pass->dir_drive); + + user_rid = sam_pass->user_rid; + group_rid = sam_pass->group_rid; + /* validate password - if required */ - if (status == 0 && !(IS_BITS_SET_ALL(sam_pass->acct_ctrl, ACB_PWNOTREQ))) + if (!(IS_BITS_SET_ALL(sam_pass->acct_ctrl, ACB_PWNOTREQ))) { - switch (q_l.sam_id.logon_level) + uint32 status = 0x0; + switch (q_l->sam_id.logon_level) { case INTERACTIVE_LOGON_TYPE: { /* interactive login. */ - status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, sam_pass, vuser); + status = net_login_interactive(&q_l->sam_id.ctr->auth.id1, sam_pass, vuser); break; } case NET_LOGON_TYPE: { /* network login. lm challenge and 24 byte responses */ - status = net_login_network(&q_l.sam_id.ctr->auth.id2, sam_pass, vuser); + status = net_login_network(&q_l->sam_id.ctr->auth.id2, sam_pass, vuser); break; } } + if (status != 0x0) + { + return status; + } } /* lkclXXXX this is the point at which, if the login was @@ -811,64 +791,80 @@ static void api_net_sam_logon( pipes_struct *p, /* return the profile plus other bits :-) */ - if (status == 0) + /* set up pointer indicating user/password failed to be found */ + usr_info->ptr_user_info = 0; + + if (!getusergroupsntnam(nt_username, &grp_mem, &num_gids)) { - int num_gids = 0; - DOMAIN_GRP *grp_mem = NULL; + return 0xC0000000 | NT_STATUS_INVALID_PRIMARY_GROUP; + } - /* set up pointer indicating user/password failed to be found */ - usr_info.ptr_user_info = 0; + num_gids = make_dom_gids(grp_mem, num_gids, &gids); + + make_net_user_info3(usr_info, + &logon_time, + &logoff_time, + &kickoff_time, + &pass_last_set_time, + &pass_can_change_time, + &pass_must_change_time, + + nt_name , /* user_name */ + full_name , /* full_name */ + logon_script , /* logon_script */ + profile_path , /* profile_path */ + home_dir , /* home_dir */ + dir_drive , /* dir_drive */ + + 0, /* logon_count */ + 0, /* bad_pw_count */ + + user_rid , /* RID user_id */ + group_rid , /* RID group_id */ + num_gids, /* uint32 num_groups */ + gids , /* DOM_GID *gids */ + 0x20 , /* uint32 user_flgs (?) */ + + NULL, /* char sess_key[16] */ + + global_myname , /* char *logon_srv */ + global_sam_name, /* char *logon_dom */ + &global_sam_sid, /* DOM_SID *dom_sid */ + NULL); /* char *other_sids */ + + /* Free any allocated groups array. */ + if (gids) + { + free((char *)gids); + } - if (!getusergroupsntnam(nt_username, &grp_mem, &num_gids)) - { - status = 0xC0000000 | NT_STATUS_INVALID_PRIMARY_GROUP; - } + return 0x0; +} - if (status == 0x0) - { - DOM_GID *gids = NULL; - num_gids = make_dom_gids(grp_mem, num_gids, &gids); - - make_net_user_info3(&usr_info, - &logon_time, - &logoff_time, - &kickoff_time, - &pass_last_set_time, - &pass_can_change_time, - &pass_must_change_time, - - nt_name , /* user_name */ - full_name , /* full_name */ - logon_script , /* logon_script */ - profile_path , /* profile_path */ - home_dir , /* home_dir */ - dir_drive , /* dir_drive */ - - 0, /* logon_count */ - 0, /* bad_pw_count */ - - user_rid , /* RID user_id */ - group_rid , /* RID group_id */ - num_gids, /* uint32 num_groups */ - gids , /* DOM_GID *gids */ - 0x20 , /* uint32 user_flgs (?) */ - - NULL, /* char sess_key[16] */ - - global_myname , /* char *logon_srv */ - global_sam_name, /* char *logon_dom */ - &global_sam_sid, /* DOM_SID *dom_sid */ - NULL); /* char *other_sids */ - - /* Free any allocated groups array. */ - if (gids) - { - free((char *)gids); - } - } +/************************************************************************* + api_net_sam_logon: + *************************************************************************/ +static void api_net_sam_logon( pipes_struct *p, + prs_struct *data, + prs_struct *rdata) +{ + NET_Q_SAM_LOGON q_l; + NET_ID_INFO_CTR ctr; + NET_USER_INFO_3 usr_info; + uint32 status = 0x0; + DOM_CRED srv_cred; + + user_struct *vuser = get_valid_user_struct(p->vuid); + if (vuser == NULL) + { + return; } + q_l.sam_id.ctr = &ctr; + net_io_q_sam_logon("", &q_l, data, 0); + + status = reply_net_sam_logon(&q_l, vuser, &srv_cred, &usr_info); net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status); } -- cgit From d0fd259514a4cc4e7ec2b021ff68fe0e3fd1bf09 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 29 Oct 1999 17:37:27 +0000 Subject: more reshuffling of enum groups code. more higher order functions. (This used to be commit 497d4231723576390b10f5ea8704bd0af88d76ab) --- source3/rpc_server/srv_samr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index bfbeb5718c..7af69a2eb4 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1136,15 +1136,15 @@ static void samr_reply_query_groupinfo(SAMR_Q_QUERY_GROUPINFO *q_u, r_e.ptr = 1; ctr.switch_value1 = 1; make_samr_group_info1(&ctr.group.info1, - "account name", - "account description"); + "fake account name", + "fake account description", 2); } else if (q_u->switch_level == 4) { r_e.ptr = 1; ctr.switch_value1 = 4; make_samr_group_info4(&ctr.group.info4, - "account description"); + "fake account description"); } else { @@ -1198,7 +1198,7 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, { r_e.ptr = 1; ctr.switch_value1 = 3; - make_samr_alias_info3(&ctr.alias.info3, ""); + make_samr_alias_info3(&ctr.alias.info3, ""); } else { -- cgit From 70115706101a11b32f598b80731468a9ce4bfb87 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 2 Nov 1999 23:32:16 +0000 Subject: free up memory allocated by enum dom groups / aliases (This used to be commit edb49e754b66ecb59685234338a96d48a53f0161) --- source3/rpc_server/srv_samr.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 7af69a2eb4..e85621a8a0 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -679,6 +679,16 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, free(grps); } + if (r_e.sam != NULL) + { + free(r_e.sam); + } + + if (r_e.uni_grp_name != NULL) + { + free(r_e.uni_grp_name); + } + DEBUG(5,("samr_enum_dom_groups: %d\n", __LINE__)); } @@ -765,6 +775,16 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, free(alss); } + if (r_e.sam != NULL) + { + free(r_e.sam); + } + + if (r_e.uni_grp_name != NULL) + { + free(r_e.uni_grp_name); + } + DEBUG(5,("samr_enum_dom_aliases: %d\n", __LINE__)); } -- cgit From bd6467154e73412753c22022b1615cf471bfa297 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sat, 6 Nov 1999 18:11:19 +0000 Subject: spoolss openprinterex / closeprinter client-code. experimental spoolopen command added. jean-francois, f.y.i. i changed the #define for SPOOLSS_OPENPRINTEREX from op code 0x44 to 0x45. (This used to be commit ef7fa58fd3c259c765c3bc82424d4c0f192ec90e) --- source3/rpc_server/srv_spoolss.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 166ac5a452..5883c9baac 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -28,8 +28,8 @@ extern int DEBUGLEVEL; extern pstring global_myname; -#ifndef MAX_OPEN_PRINTERS -#define MAX_OPEN_PRINTERS 50 +#ifndef MAX_OPEN_PRINTER_EXS +#define MAX_OPEN_PRINTER_EXS 50 #endif #define PRINTER_HANDLE_IS_PRINTER 0 @@ -61,9 +61,9 @@ static struct uint32 access; uint32 number_of_notify; SPOOL_NOTIFY_OPTION_TYPE notify_info[MAX_PRINTER_NOTIFY+MAX_JOB_NOTIFY]; -} Printer[MAX_OPEN_PRINTERS]; +} Printer[MAX_OPEN_PRINTER_EXS]; -#define VALID_HANDLE(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PRINTERS)) +#define VALID_HANDLE(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PRINTER_EXS)) #define OPEN_HANDLE(pnum) (VALID_HANDLE(pnum) && Printer[pnum].open) /**************************************************************************** @@ -72,7 +72,7 @@ static struct void init_printer_hnd(void) { int i; - for (i = 0; i < MAX_OPEN_PRINTERS; i++) + for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++) { Printer[i].open = False; } @@ -115,7 +115,7 @@ static BOOL open_printer_hnd(PRINTER_HND *hnd) { int i; - for (i = 0; i < MAX_OPEN_PRINTERS; i++) + for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++) { if (!Printer[i].open) { @@ -139,7 +139,7 @@ static int find_printer_index_by_hnd(PRINTER_HND *hnd) { int i; - for (i = 0; i < MAX_OPEN_PRINTERS; i++) + for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++) { if (memcmp(&(Printer[i].printer_hnd), hnd, sizeof(*hnd)) == 0) { @@ -383,9 +383,9 @@ static BOOL handle_is_printer(PRINTER_HND *handle) * * called from the spoolss dispatcher ********************************************************************/ -static void spoolss_reply_open_printer(SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *rdata) +static void spoolss_reply_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *rdata) { - SPOOL_R_OPEN_PRINTER r_u; + SPOOL_R_OPEN_PRINTER_EX r_u; BOOL printer_open = False; fstring name; @@ -420,7 +420,7 @@ static void spoolss_reply_open_printer(SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *rd clear_handle(&(r_u.handle)); } - spoolss_io_r_open_printer("",&r_u,rdata,0); + spoolss_io_r_open_printer_ex("",&r_u,rdata,0); } /******************************************************************** @@ -428,15 +428,15 @@ static void spoolss_reply_open_printer(SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *rd * * called from the spoolss dispatcher ********************************************************************/ -static void api_spoolss_open_printer(pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_spoolss_open_printer_ex(pipes_struct *p, prs_struct *data, prs_struct *rdata) { - SPOOL_Q_OPEN_PRINTER q_u; + SPOOL_Q_OPEN_PRINTER_EX q_u; /* grab the spoolss open policy */ - spoolss_io_q_open_printer("", &q_u, data, 0); + spoolss_io_q_open_printer_ex("", &q_u, data, 0); /* construct reply. always indicate success */ - spoolss_reply_open_printer(&q_u, rdata); + spoolss_reply_open_printer_ex(&q_u, rdata); } /******************************************************************** @@ -3818,7 +3818,7 @@ static void api_spoolss_getjob(pipes_struct *p, prs_struct *data, ********************************************************************/ struct api_struct api_spoolss_cmds[] = { - {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer }, + {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex }, {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata }, {"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter }, {"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex }, -- cgit From 702b085293af8ffe7a04865db78a36c85beb22ee Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 8 Nov 1999 22:00:41 +0000 Subject: preparation for doing a spoolss enum jobs command. had to rewrite spoolss_enumjobs parsing code to do read / writes not just writes. (This used to be commit bc659a09f9103eee9616279e27fafacf89dcd9b9) --- source3/rpc_server/srv_spoolss.c | 112 ++++++--------------------------------- 1 file changed, 15 insertions(+), 97 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 5883c9baac..1f9d8a19d5 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1748,77 +1748,6 @@ static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number, } } -/**************************************************************************** -****************************************************************************/ -static void free_devmode(DEVICEMODE *devmode) -{ - if (devmode->private!=NULL) - free(devmode->private); - if (devmode!=NULL) - free(devmode); -} - -/**************************************************************************** -****************************************************************************/ -static void free_printer_info_2(PRINTER_INFO_2 *printer) -{ - free_devmode(printer->devmode); - if (printer!=NULL) - free(printer); -} - -/**************************************************************************** -****************************************************************************/ -static void free_enum_printers_info_1(PRINTER_INFO_1 **printers, uint32 total) -{ - int number=0; - if (printers != NULL) - { - for (number=0; numberreturned, r_u->level)); - switch (r_u->level) - { - case 1: - free_enum_printers_info_1(r_u->printer.printers_1, r_u->returned); - break; - case 2: - free_enum_printers_info_2(r_u->printer.printers_2, r_u->returned); - break; - } -} - /******************************************************************** * api_spoolss_reply_enumprinters * @@ -1864,7 +1793,6 @@ static void spoolss_reply_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *rd r_u.status=0x0000; spoolss_io_r_enumprinters("",&r_u,rdata,0); - free_enum_printers_info(&r_u); } /******************************************************************** @@ -2827,7 +2755,7 @@ static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata, con if (get_printer_snum(&(q_u->handle), &snum)) { count=get_printqueue(snum, conn, &queue, &status); - r_u.numofjobs=count; + r_u.numofjobs=0; r_u.level=q_u->level; @@ -2837,48 +2765,38 @@ static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata, con { case 1: { - job_info_1=(JOB_INFO_1 *)malloc(count*sizeof(JOB_INFO_1)); - for (i=0; idevmode); - free(job_info_2); - break; - } - } - if (queue) free(queue); + if (queue) free(queue); } /**************************************************************************** -- cgit From b231d2fafaff8dc67ef2dbaec778f716524d4f6a Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 15 Nov 1999 22:11:10 +0000 Subject: - added DCE/RPC "fault" PDU support. - disabled (AGAIN) the GETDC "if (MAILSLOT\NTLOGON)" code that will get NT5rc2 to work but WILL break win95 (AGAIN). this needs _not_ to be re-enabled but to be replaced with a better mechanism. - added SMBwrite support (note: SMBwriteX already existed) as NT5rc2 is sending DCE/RPC over SMBwrite not SMBwriteX. (This used to be commit 25c70e3c984c4fed19763ed405741e83fe14f87e) --- source3/rpc_server/srv_pipe.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 458d7e883c..1073ba2179 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -396,6 +396,45 @@ static BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *pd) return api_pipe_ntlmssp(p, pd); } +static BOOL api_pipe_fault_resp(pipes_struct *p, prs_struct *pd, uint32 status) +{ + DEBUG(5,("api_pipe_fault_resp: make response\n")); + + prs_init(&(p->rhdr ), 0x18, 4, 0, False); + prs_init(&(p->rfault ), 0x8 , 4, 0, False); + + /***/ + /*** set up the header, response header and fault status ***/ + /***/ + + p->hdr_fault.status = status; + p->hdr_fault.reserved = 0x0; + + p->hdr_resp.alloc_hint = 0x0; + p->hdr_resp.cancel_count = 0x0; + p->hdr_resp.reserved = 0x0; + + make_rpc_hdr(&p->hdr, RPC_FAULT, RPC_FLG_NOCALL | RPC_FLG_FIRST | RPC_FLG_LAST, + p->hdr.call_id, + 0x20, + 0); + + smb_io_rpc_hdr ("hdr" , &(p->hdr ), &(p->rhdr), 0); + smb_io_rpc_hdr_resp ("resp" , &(p->hdr_resp ), &(p->rhdr), 0); + smb_io_rpc_hdr_fault("fault", &(p->hdr_fault), &(p->rfault), 0); + mem_realloc_data(p->rhdr.data, p->rhdr.offset); + mem_realloc_data(p->rfault.data, p->rfault.offset); + + /***/ + /*** link rpc header and fault together ***/ + /***/ + + prs_link(NULL , &p->rhdr , &p->rfault); + prs_link(&p->rhdr, &p->rfault, NULL ); + + return True; +} + static BOOL api_pipe_bind_and_alt_req(pipes_struct *p, prs_struct *pd, enum RPC_PKT_TYPE pkt_type) { uint16 assoc_gid; @@ -669,6 +708,8 @@ static BOOL api_pipe_request(pipes_struct *p, prs_struct *pd) BOOL rpc_command(pipes_struct *p, prs_struct *pd) { BOOL reply = False; + DEBUG(10,("rpc_command\n")); + if (pd->data == NULL) return False; /* process the rpc header */ @@ -715,7 +756,7 @@ BOOL rpc_command(pipes_struct *p, prs_struct *pd) if (!reply) { - DEBUG(3,("rpc_command: DCE/RPC fault should be sent here\n")); + reply = api_pipe_fault_resp(p, pd, 0x1c010002); } return reply; -- cgit From 089b57b5b4e81ceb854f10e89c5d83fc885f8809 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 15 Nov 1999 23:46:27 +0000 Subject: added server-side samr enum domains. fixed some parsing issues, server-side. (This used to be commit 60b0840106a6f5c283a8339428f3cfeb62398355) --- source3/rpc_server/srv_samr.c | 72 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index e85621a8a0..c3464380ed 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -626,6 +626,75 @@ static void api_samr_del_aliasmem( pipes_struct *p, prs_struct *data, prs_struct samr_reply_del_aliasmem(&q_e, rdata); } +/******************************************************************* + samr_reply_enum_domains + ********************************************************************/ +static void samr_reply_enum_domains(SAMR_Q_ENUM_DOMAINS *q_u, + prs_struct *rdata) +{ + SAMR_R_ENUM_DOMAINS r_e; + char **doms = NULL; + uint32 num_entries = 0; + + r_e.status = 0x0; + r_e.num_entries2 = 0; + + ZERO_STRUCT(r_e); + + r_e.status = 0x0; + + /* find the connection policy handle. */ + if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + { + r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + DEBUG(5,("samr_reply_enum_domains:\n")); + + if (!enumdomains(&doms, &num_entries)) + { + r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; + } + + if (r_e.status == 0x0) + { + make_samr_r_enum_domains(&r_e, + q_u->start_idx + num_entries, + num_entries, doms, r_e.status); + } + + /* store the response in the SMB stream */ + samr_io_r_enum_domains("", &r_e, rdata, 0); + + free_char_array(num_entries, doms); + + if (r_e.sam != NULL) + { + free(r_e.sam); + } + + if (r_e.uni_dom_name != NULL) + { + free(r_e.uni_dom_name); + } + + DEBUG(5,("samr_enum_domains: %d\n", __LINE__)); +} + +/******************************************************************* + api_samr_enum_domains + ********************************************************************/ +static void api_samr_enum_domains( pipes_struct *p, prs_struct *data, prs_struct *rdata) +{ + SAMR_Q_ENUM_DOMAINS q_e; + + /* grab the samr open */ + samr_io_q_enum_domains("", &q_e, data, 0); + + /* construct reply. */ + samr_reply_enum_domains(&q_e, rdata); +} + /******************************************************************* samr_reply_enum_dom_groups ********************************************************************/ @@ -693,7 +762,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, } /******************************************************************* - api_samr_enum_dom_aliases + api_samr_enum_dom_groups ********************************************************************/ static void api_samr_enum_dom_groups( pipes_struct *p, prs_struct *data, prs_struct *rdata) { @@ -2933,6 +3002,7 @@ static struct api_struct api_samr_cmds [] = { "SAMR_CLOSE_HND" , SAMR_CLOSE_HND , api_samr_close_hnd }, { "SAMR_CONNECT" , SAMR_CONNECT , api_samr_connect }, { "SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon }, + { "SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains }, { "SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users }, { "SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, { "SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, -- cgit From 8a84d000c96fe4487adba5df0f50fa6e8fb27c24 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Tue, 16 Nov 1999 14:10:23 +0000 Subject: Changes to implement NET_AUTH based on NET_AUTH2, to get Win2000 happier in joining a Samba domain. (This used to be commit 70274b5253182f3541584ecd844f07376a3d3df9) --- source3/rpc_server/srv_netlog.c | 76 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index d51ed58113..440ac87c86 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -106,6 +106,34 @@ static void net_reply_trust_dom_list(NET_Q_TRUST_DOM_LIST *q_t, prs_struct *rdat } + +/************************************************************************* + make_net_r_auth: + *************************************************************************/ +static void make_net_r_auth(NET_R_AUTH *r_a, + DOM_CHAL *resp_cred, int status) +{ + memcpy( r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); + r_a->status = status; +} + +/************************************************************************* + net_reply_auth: + *************************************************************************/ +static void net_reply_auth(NET_Q_AUTH *q_a, prs_struct *rdata, + DOM_CHAL *resp_cred, int status) +{ + NET_R_AUTH r_a; + + /* set up the LSA AUTH 2 response */ + + make_net_r_auth(&r_a, resp_cred, status); + + /* store the response in the SMB stream */ + net_io_r_auth("", &r_a, rdata, 0); + +} + /************************************************************************* make_net_r_auth_2: *************************************************************************/ @@ -370,6 +398,50 @@ static void api_net_req_chal( pipes_struct *p, } +/************************************************************************* + api_net_auth: + *************************************************************************/ +static void api_net_auth( pipes_struct *p, + prs_struct *data, + prs_struct *rdata) +{ + NET_Q_AUTH q_a; + uint32 status = 0x0; + + DOM_CHAL srv_cred; + UTIME srv_time; + + user_struct *vuser; + + if ((vuser = get_valid_user_struct(p->vuid)) == NULL) + return; + + srv_time.time = 0; + + /* grab the challenge... */ + net_io_q_auth("", &q_a, data, 0); + + /* check that the client credentials are valid */ + if (cred_assert(&(q_a.clnt_chal), vuser->dc.sess_key, + &(vuser->dc.clnt_cred.challenge), srv_time)) + { + + /* create server challenge for inclusion in the reply */ + cred_create(vuser->dc.sess_key, &(vuser->dc.srv_cred.challenge), srv_time, &srv_cred); + + /* copy the received client credentials for use next time */ + memcpy(vuser->dc.clnt_cred.challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); + memcpy(vuser->dc.srv_cred .challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); + } + else + { + status = NT_STATUS_ACCESS_DENIED | 0xC0000000; + } + + /* construct reply. */ + net_reply_auth(&q_a, rdata, &srv_cred, status); +} + /************************************************************************* api_net_auth_2: *************************************************************************/ @@ -414,7 +486,6 @@ static void api_net_auth_2( pipes_struct *p, net_reply_auth_2(&q_a, rdata, &srv_cred, status); } - /************************************************************************* api_net_srv_pwset: *************************************************************************/ @@ -934,6 +1005,7 @@ static void api_net_logon_ctrl2( pipes_struct *p, static struct api_struct api_net_cmds [] = { { "NET_REQCHAL" , NET_REQCHAL , api_net_req_chal }, + { "NET_AUTH" , NET_AUTH , api_net_auth }, { "NET_AUTH2" , NET_AUTH2 , api_net_auth_2 }, { "NET_SRVPWSET" , NET_SRVPWSET , api_net_srv_pwset }, { "NET_SAMLOGON" , NET_SAMLOGON , api_net_sam_logon }, @@ -941,7 +1013,7 @@ static struct api_struct api_net_cmds [] = { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 }, { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, { "NET_SAM_SYNC" , NET_SAM_SYNC , api_net_sam_sync }, - { NULL , 0 , NULL } + { NULL , 0 , NULL } }; /******************************************************************* -- cgit From 774d2d73666b7deca79ae90dd10397e2e1f8e6d9 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 16 Nov 1999 15:39:09 +0000 Subject: Shirish Kalele noticed that NT workstations are sending anonymous NTLMSSP user credentials to set up \PIPE\samr. added anonymous NTLMSSP sessions. (This used to be commit df5ee2bd427ccd5fcf27fd3c366e06e037bc4f1e) --- source3/rpc_server/srv_pipe.c | 69 ++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 1073ba2179..c6d9cf070e 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -207,14 +207,23 @@ BOOL create_rpc_reply(pipes_struct *p, static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) { + uchar *pwd = NULL; + uchar null_pwd[16]; uchar lm_owf[24]; uchar nt_owf[128]; size_t lm_owf_len; size_t nt_owf_len; + size_t usr_len; + size_t dom_len; + size_t wks_len; + BOOL anonymous = False; + struct smb_passwd *smb_pass = NULL; user_struct *vuser = get_valid_user_struct(p->vuid); + memset(null_pwd, 0, sizeof(null_pwd)); + DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); if (vuser == NULL) @@ -225,13 +234,23 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) lm_owf_len = p->ntlmssp_resp.hdr_lm_resp.str_str_len; nt_owf_len = p->ntlmssp_resp.hdr_nt_resp.str_str_len; + usr_len = p->ntlmssp_resp.hdr_usr .str_str_len; + dom_len = p->ntlmssp_resp.hdr_domain .str_str_len; + wks_len = p->ntlmssp_resp.hdr_wks .str_str_len; - - if (lm_owf_len == 0) return False; - if (nt_owf_len == 0) return False; - if (p->ntlmssp_resp.hdr_usr .str_str_len == 0) return False; - if (p->ntlmssp_resp.hdr_domain .str_str_len == 0) return False; - if (p->ntlmssp_resp.hdr_wks .str_str_len == 0) return False; + if (lm_owf_len == 0 && nt_owf_len == 0 && + usr_len == 0 && dom_len == 0 && wks_len == 0) + { + anonymous = True; + } + else + { + if (lm_owf_len == 0) return False; + if (nt_owf_len == 0) return False; + if (p->ntlmssp_resp.hdr_usr .str_str_len == 0) return False; + if (p->ntlmssp_resp.hdr_domain .str_str_len == 0) return False; + if (p->ntlmssp_resp.hdr_wks .str_str_len == 0) return False; + } if (lm_owf_len > sizeof(lm_owf)) return False; if (nt_owf_len > sizeof(nt_owf)) return False; @@ -269,21 +288,36 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) fstrcpy(p->wks , p->ntlmssp_resp.wks ); } - DEBUG(5,("user: %s domain: %s wks: %s\n", p->user_name, p->domain, p->wks)); - become_root(True); - p->ntlmssp_validated = pass_check_smb(p->user_name, p->domain, - (uchar*)p->ntlmssp_chal.challenge, - lm_owf, lm_owf_len, - nt_owf, nt_owf_len, - NULL, vuser->dc.user_sess_key); - smb_pass = getsmbpwnam(p->user_name); - unbecome_root(True); + if (anonymous) + { + DEBUG(5,("anonymous user session\n")); + mdfour(vuser->dc.user_sess_key, null_pwd, 16); + pwd = null_pwd; + p->ntlmssp_validated = True; + } + else + { + DEBUG(5,("user: %s domain: %s wks: %s\n", p->user_name, p->domain, p->wks)); + become_root(True); + p->ntlmssp_validated = pass_check_smb(p->user_name, p->domain, + (uchar*)p->ntlmssp_chal.challenge, + lm_owf, lm_owf_len, + nt_owf, nt_owf_len, + NULL, vuser->dc.user_sess_key); + smb_pass = getsmbpwnam(p->user_name); + unbecome_root(True); + + if (smb_pass != NULL) + { + pwd = smb_pass->smb_passwd; + } + } - if (p->ntlmssp_validated && smb_pass != NULL && smb_pass->smb_passwd) + if (p->ntlmssp_validated && pwd != NULL) { uchar p24[24]; - NTLMSSPOWFencrypt(smb_pass->smb_passwd, lm_owf, p24); + NTLMSSPOWFencrypt(pwd, lm_owf, p24); { unsigned char j = 0; int ind; @@ -314,7 +348,6 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) p->ntlmssp_hash[256] = 0; p->ntlmssp_hash[257] = 0; } -/* NTLMSSPhash(p->ntlmssp_hash, p24); */ p->ntlmssp_seq_num = 0; } else -- cgit From 82f1f32ff7a6d1c1db221aaeb265cbad5ff7c583 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 16 Nov 1999 17:25:45 +0000 Subject: added another dummy key so that NT5 can check in the registry whether password changes are allowed or not. *dur*!!!! (This used to be commit b51fa05c820c4629b278dc294ad0a405ee470a6e) --- source3/rpc_server/srv_reg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index ea53f2ee2b..0ba6774900 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -142,7 +142,8 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, { DEBUG(5,("reg_open_entry: %s\n", name)); /* lkcl XXXX do a check on the name, here */ - if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions")) + if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions") || + !strequal(name, "SYSTEM\\CurrentControlSet\\Services\\NETLOGON\Parameters")) { status = 0xC000000 | NT_STATUS_ACCESS_DENIED; } -- cgit From 6b56ebb7cf48b350ba4e9fd5c61a8900b805a001 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 16 Nov 1999 17:27:41 +0000 Subject: added two new params: "trusted domains" and "trusting domains". these _may_ not actually ever get used, as trust relationships really need to be established with shared secrets, and you need to get the SID of the trusted and trusting domains, so this may have to go in a private/xxx.mac file. (This used to be commit 71f12138679251a9ebcada35969d9baea286a3e9) --- source3/rpc_server/srv_netlog.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 440ac87c86..09678e3eaf 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -90,7 +90,7 @@ static void net_reply_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, prs_struct *rdata, net_reply_trust_dom_list: *************************************************************************/ static void net_reply_trust_dom_list(NET_Q_TRUST_DOM_LIST *q_t, prs_struct *rdata, - uint32 num_trust_domains, char *trust_domain_name) + uint32 num_trust_domains, char **trust_domain_name) { NET_R_TRUST_DOM_LIST r_t; @@ -948,8 +948,10 @@ static void api_net_trust_dom_list( pipes_struct *p, prs_struct *rdata) { NET_Q_TRUST_DOM_LIST q_t; + char **doms = NULL; + uint32 num_doms = 0; - char *trusted_domain = "test_domain"; + enumtrustdoms(&doms, &num_doms); DEBUG(6,("api_net_trust_dom_list: %d\n", __LINE__)); @@ -958,7 +960,9 @@ static void api_net_trust_dom_list( pipes_struct *p, /* construct reply. */ net_reply_trust_dom_list(&q_t, rdata, - 1, trusted_domain); + num_doms, doms); + + free_char_array(num_doms, doms); DEBUG(6,("api_net_trust_dom_list: %d\n", __LINE__)); } -- cgit From cc8df5ce4955fc721e11ff08de052554894d963a Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 16 Nov 1999 21:14:53 +0000 Subject: attempting to get nt5 wksta to join domain. 1) had to fix samr "create user" and "set user info" (level 23). 2) had to fix netlogon enum trust domains 3) registry key needed \\ in it not \. (This used to be commit 70b2c1ecbb4fbbb86fea676c80754485aae5ab13) --- source3/rpc_server/srv_netlog.c | 2 +- source3/rpc_server/srv_reg.c | 2 +- source3/rpc_server/srv_samr.c | 21 +++++++++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 09678e3eaf..5e9ae35094 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -102,7 +102,7 @@ static void net_reply_trust_dom_list(NET_Q_TRUST_DOM_LIST *q_t, prs_struct *rdat /* store the response in the SMB stream */ net_io_r_trust_dom("", &r_t, rdata, 0); - DEBUG(6,("net_reply_trust_dom_listlogon_ctrl2: %d\n", __LINE__)); + DEBUG(6,("net_reply_trust_dom_list: %d\n", __LINE__)); } diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 0ba6774900..fcc22a792a 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -143,7 +143,7 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, DEBUG(5,("reg_open_entry: %s\n", name)); /* lkcl XXXX do a check on the name, here */ if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions") || - !strequal(name, "SYSTEM\\CurrentControlSet\\Services\\NETLOGON\Parameters")) + !strequal(name, "SYSTEM\\CurrentControlSet\\Services\\NETLOGON\\Parameters")) { status = 0xC000000 | NT_STATUS_ACCESS_DENIED; } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index c3464380ed..ff2f1bbb8c 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -2090,6 +2090,11 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) static uchar lm_hash[16]; pstring new_pw; + if (id23 == NULL) + { + DEBUG(5, ("set_user_info_23: NULL id23\n")); + return False; + } if (pwd == NULL) { return False; @@ -2155,6 +2160,12 @@ static void samr_reply_set_userinfo(SAMR_Q_SET_USERINFO *q_u, DEBUG(5,("samr_reply_set_userinfo: rid:0x%x\n", rid)); /* ok! user info levels (there are lots: see MSDEV help), off we go... */ + if (status == 0x0 && q_u->info.id == NULL) + { + DEBUG(5,("samr_reply_set_userinfo: NULL info level\n")); + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + } + if (status == 0x0) { switch (q_u->switch_value) @@ -2170,7 +2181,13 @@ static void samr_reply_set_userinfo(SAMR_Q_SET_USERINFO *q_u, case 23: { SAM_USER_INFO_23 *id23 = q_u->info.id23; - SamOEMhash(id23->pass, user_sess_key, True); + SamOEMhash(id23->pass, user_sess_key, 1); +#if DEBUG_PASSWORD + DEBUG(100,("pass buff:\n")); + dump_data(100, id23->pass, sizeof(id23->pass)); +#endif + dbgflush(); + status = set_user_info_23(id23, rid) ? 0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); break; } @@ -2663,7 +2680,7 @@ static void samr_reply_create_user(SAMR_Q_CREATE_USER *q_u, pstring msg_str; if (!local_password_change(user_name, True, - q_u->acb_info, 0xffff, + q_u->acb_info | ACB_DISABLED, 0xffff, NULL, err_str, sizeof(err_str), msg_str, sizeof(msg_str))) -- cgit From ccc8585567804d6a7e6f684a97d58871e2fd9f8a Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 18 Nov 1999 00:26:11 +0000 Subject: added regqueryval command (experimental) to get reg_io_q_info() and reg_io_r_info() working properly. previously they weren't well understood (well, they were the first of the registry functions i did, back in december 97, ok??? :-) set ntversion to 0x1 in SAMQUERY, so that we reply same as NT4 srv. (This used to be commit 98ddeaf442cb30972cb281bf0489a6e5f7eb2883) --- source3/rpc_server/srv_lsa.c | 52 ++++++++++++++++++++++++++++++++------------ source3/rpc_server/srv_reg.c | 6 ++--- 2 files changed, 41 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 36259477da..7bc5841cfc 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -39,18 +39,19 @@ lsa_reply_open_policy2 ***************************************************************************/ static void lsa_reply_open_policy2(prs_struct *rdata) { - int i; LSA_R_OPEN_POL2 r_o; ZERO_STRUCT(r_o); /* set up the LSA QUERY INFO response */ - for (i = 4; i < POL_HND_SIZE; i++) + r_o.status = 0x0; + + /* get a (unique) handle. open a policy on it. */ + if (!open_lsa_policy_hnd(&r_o.pol)) { - r_o.pol.data[i] = i; + r_o.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } - r_o.status = 0x0; /* store the response in the SMB stream */ lsa_io_r_open_pol2("", &r_o, rdata, 0); @@ -61,18 +62,19 @@ lsa_reply_open_policy ***************************************************************************/ static void lsa_reply_open_policy(prs_struct *rdata) { - int i; LSA_R_OPEN_POL r_o; ZERO_STRUCT(r_o); /* set up the LSA QUERY INFO response */ - for (i = 4; i < POL_HND_SIZE; i++) + r_o.status = 0x0; + + /* get a (unique) handle. open a policy on it. */ + if (!open_lsa_policy_hnd(&r_o.pol)) { - r_o.pol.data[i] = i; + r_o.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } - r_o.status = 0x0; /* store the response in the SMB stream */ lsa_io_r_open_pol("", &r_o, rdata, 0); @@ -128,15 +130,22 @@ static void lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, ZERO_STRUCT(r_q); - /* set up the LSA QUERY INFO response */ - - r_q.undoc_buffer = 0x22000000; /* bizarre */ - r_q.info_class = q_q->info_class; + /* get a (unique) handle. open a policy on it. */ + if (r_q.status == 0x0 && !open_lsa_policy_hnd(&q_q->pol)) + { + r_q.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + else + { + /* set up the LSA QUERY INFO response */ - make_dom_query(&r_q.dom.id5, dom_name, dom_sid); + r_q.undoc_buffer = 0x1; /* bizarre */ + r_q.info_class = q_q->info_class; - r_q.status = 0x0; + make_dom_query(&r_q.dom.id5, dom_name, dom_sid); + r_q.status = 0x0; + } /* store the response in the SMB stream */ lsa_io_r_query("", &r_q, rdata, 0); } @@ -572,9 +581,24 @@ static void api_lsa_close( pipes_struct *p, prs_struct *data, prs_struct *rdata) { LSA_R_CLOSE r_c; + LSA_Q_CLOSE q_c; + + lsa_io_q_close("", &q_c, data, 0); ZERO_STRUCT(r_c); + r_c.status = 0x0; + + /* find the connection policy handle. */ + if (r_c.status == 0x0 && (find_lsa_policy_by_hnd(&(q_c.pol)) == -1)) + { + r_c.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + if (r_c.status == 0x0) + { + close_lsa_policy_hnd(&(q_c.pol)); + } + /* store the response in the SMB stream */ lsa_io_r_close("", &r_c, rdata, 0); } diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index fcc22a792a..ab7e4cf3ec 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -142,8 +142,8 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, { DEBUG(5,("reg_open_entry: %s\n", name)); /* lkcl XXXX do a check on the name, here */ - if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions") || - !strequal(name, "SYSTEM\\CurrentControlSet\\Services\\NETLOGON\\Parameters")) + if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions") && + !strequal(name, "SYSTEM\\CurrentControlSet\\Services\\NETLOGON\\Parameters\\")) { status = 0xC000000 | NT_STATUS_ACCESS_DENIED; } @@ -197,9 +197,9 @@ static void reg_reply_info(REG_Q_INFO *q_u, if (status == 0) { + make_reg_r_info(&r_u, 1, "LanmanNT", status); } - make_reg_r_info(&r_u, 1, "LanmanNT", status); /* store the response in the SMB stream */ reg_io_r_info("", &r_u, rdata, 0); -- cgit From a394a4a8fa2c4c0ff03fbc5bc4ea925245ec1fed Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 18 Nov 1999 17:57:21 +0000 Subject: updating reg_value_info() parsing code to take BUFFER2 instead of just a char*. now copes with multiple types. (This used to be commit 3df7c903c5b70f336294a95ad864aedbacf544b0) --- source3/rpc_server/srv_reg.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index ab7e4cf3ec..18781d0cd0 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -187,6 +187,8 @@ static void reg_reply_info(REG_Q_INFO *q_u, uint32 status = 0; REG_R_INFO r_u; + uint32 type = 1; + BUFFER2 buf; DEBUG(5,("reg_info: %d\n", __LINE__)); @@ -197,7 +199,9 @@ static void reg_reply_info(REG_Q_INFO *q_u, if (status == 0) { - make_reg_r_info(&r_u, 1, "LanmanNT", status); + char *key = "LanmanNT"; + make_buffer2(&buf, key, strlen(key)); + make_reg_r_info(&r_u, &type, &buf, status); } -- cgit From e3b2f276e04bce6365dfb1a7e0b904b7c788c364 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 18 Nov 1999 19:29:08 +0000 Subject: added samuserset2 rpcclient command to test ACB_XXX bit-setting on samr opcode 0x25. _yet_ another failed attempt to get nt5rc2 to join a samba domain. what _is_ it with this stuff, dammit? (This used to be commit c3913f8ae272c496fc4519141accf01ee9f1e49e) --- source3/rpc_server/srv_samr.c | 107 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index ff2f1bbb8c..4761ceb014 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -2121,6 +2121,31 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) return mod_sam21pwd_entry(&new_pwd, True); } +/******************************************************************* + set_user_info_16 + ********************************************************************/ +static BOOL set_user_info_16(SAM_USER_INFO_16 *id16, uint32 rid) +{ + struct sam_passwd *pwd = getsam21pwrid(rid); + struct sam_passwd new_pwd; + + if (id16 == NULL) + { + DEBUG(5, ("set_user_info_16: NULL id16\n")); + return False; + } + if (pwd == NULL) + { + return False; + } + + copy_sam_passwd(&new_pwd, pwd); + + new_pwd.acct_ctrl = id16->acb_info; + + return mod_sam21pwd_entry(&new_pwd, True); +} + /******************************************************************* api_samr_query_userinfo ********************************************************************/ @@ -2132,6 +2157,87 @@ static void api_samr_query_userinfo( pipes_struct *p, prs_struct *data, prs_stru } +/******************************************************************* + samr_reply_set_userinfo2 + ********************************************************************/ +static void samr_reply_set_userinfo2(SAMR_Q_SET_USERINFO2 *q_u, + prs_struct *rdata, uchar user_sess_key[16]) +{ + SAMR_R_SET_USERINFO2 r_u; + + uint32 status = 0x0; + uint32 rid = 0x0; + + DEBUG(5,("samr_reply_set_userinfo2: %d\n", __LINE__)); + + /* search for the handle */ + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + { + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } + + /* find the user's rid */ + if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->pol))) == 0xffffffff) + { + status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + DEBUG(5,("samr_reply_set_userinfo2: rid:0x%x\n", rid)); + + /* ok! user info levels (there are lots: see MSDEV help), off we go... */ + if (status == 0x0 && q_u->info.id == NULL) + { + DEBUG(5,("samr_reply_set_userinfo2: NULL info level\n")); + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + } + + if (status == 0x0) + { + switch (q_u->switch_value) + { + case 16: + { + SAM_USER_INFO_16 *id16 = q_u->info.id16; + status = set_user_info_16(id16, rid) ? 0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); + break; + } + default: + { + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + + break; + } + } + } + + make_samr_r_set_userinfo2(&r_u, status); + + /* store the response in the SMB stream */ + samr_io_r_set_userinfo2("", &r_u, rdata, 0); + + DEBUG(5,("samr_reply_set_userinfo2: %d\n", __LINE__)); + +} + +/******************************************************************* + api_samr_set_userinfo2 + ********************************************************************/ +static void api_samr_set_userinfo2( pipes_struct *p, prs_struct *data, prs_struct *rdata) +{ + user_struct *vuser = get_valid_user_struct(p->vuid); + SAMR_Q_SET_USERINFO2 q_u; + ZERO_STRUCT(q_u); + + samr_io_q_set_userinfo2("", &q_u, data, 0); + samr_reply_set_userinfo2(&q_u, rdata, vuser->dc.user_sess_key); + + if (q_u.info.id != NULL) + { + free(q_u.info.id); + } +} + + /******************************************************************* samr_reply_set_userinfo ********************************************************************/ @@ -3038,6 +3144,7 @@ static struct api_struct api_samr_cmds [] = { "SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, { "SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, { "SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo }, + { "SAMR_SET_USERINFO2" , SAMR_SET_USERINFO2 , api_samr_set_userinfo2 }, { "SAMR_QUERY_DOMAIN_INFO", SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, { "SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, { "SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, -- cgit From 4245278ca3fea4a6b79daf58a8712a2774811c58 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 18 Nov 1999 22:03:47 +0000 Subject: set "key does not exist" response to reg_query_val() (win32 status code of 0x2). [p.s. getting REALLY bored of this nt5rc2->samba domain stuff]. (This used to be commit a8801942f72b2394a54e4a46546029fac70efeed) --- source3/rpc_server/srv_lsa_hnd.c | 28 +++++++++++++++++++++++++--- source3/rpc_server/srv_reg.c | 17 +++++++++++++---- 2 files changed, 38 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index dabc5520ff..d53264a73e 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -271,9 +271,10 @@ BOOL set_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) { struct policy *p = find_lsa_policy(hnd); - if (p && p->open) { - DEBUG(3,("Setting policy pnum=%x name=%s\n", - p->pnum, name)); + if (p && p->open) + { + DEBUG(3,("Getting policy pnum=%x\n", + p->pnum)); fstrcpy(p->dev.reg.name, name); return True; @@ -283,6 +284,27 @@ BOOL set_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) return False; } +/**************************************************************************** + set reg name +****************************************************************************/ +BOOL get_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) +{ + struct policy *p = find_lsa_policy(hnd); + + if (p && p->open) + { + DEBUG(3,("Setting policy pnum=%x name=%s\n", + p->pnum, name)); + + fstrcpy(name, p->dev.reg.name); + DEBUG(5,("getting policy reg name=%s\n", name)); + return True; + } + + DEBUG(3,("Error getting policy reg name\n")); + return False; +} + /**************************************************************************** close an lsa policy ****************************************************************************/ diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 18781d0cd0..10b9bac90c 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -187,23 +187,32 @@ static void reg_reply_info(REG_Q_INFO *q_u, uint32 status = 0; REG_R_INFO r_u; - uint32 type = 1; + uint32 type = 0xcafeface; BUFFER2 buf; + fstring name; + + ZERO_STRUCT(buf); DEBUG(5,("reg_info: %d\n", __LINE__)); - if (status == 0 && find_lsa_policy_by_hnd(&(q_u->pol)) == -1) + if (status == 0x0 && !get_lsa_policy_reg_name(&q_u->pol, name)) { status = 0xC000000 | NT_STATUS_INVALID_HANDLE; } - if (status == 0) + if (status == 0 && + strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions")) { char *key = "LanmanNT"; make_buffer2(&buf, key, strlen(key)); - make_reg_r_info(&r_u, &type, &buf, status); + type = 0x1; + } + else + { + status = 0x2; /* Win32 status code. ick */ } + make_reg_r_info(&r_u, &type, &buf, status); /* store the response in the SMB stream */ reg_io_r_info("", &r_u, rdata, 0); -- cgit From da517a3ff4c133a1475e8e63054201551d132436 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 18 Nov 1999 23:15:45 +0000 Subject: responses to UDP samquery go back to SERVER<00> not DOMAIN<1c>, the request name. modified createuser rpcclient command to examine name being added. if it ends in a $, assume that a workstation trust account is being added. (This used to be commit 4aea261cb0e5f34255ff83271eb5cadb0eb78bc9) --- source3/rpc_server/srv_samr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 4761ceb014..a220e38b07 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -2750,8 +2750,9 @@ static void samr_reply_create_user(SAMR_Q_CREATE_USER *q_u, SAMR_R_CREATE_USER r_u; POLICY_HND pol; uint32 status = 0x0; - uint32 user_rid = 0xffffffff; + uint32 user_rid = 0x0; BOOL pol_open = False; + uint32 unk_0 = 0x30; /* find the machine account: tell the caller if it exists. lkclXXXX i have *no* idea if this is a problem or not @@ -2786,7 +2787,7 @@ static void samr_reply_create_user(SAMR_Q_CREATE_USER *q_u, pstring msg_str; if (!local_password_change(user_name, True, - q_u->acb_info | ACB_DISABLED, 0xffff, + q_u->acb_info | ACB_DISABLED | ACB_PWNOTREQ, 0xffff, NULL, err_str, sizeof(err_str), msg_str, sizeof(msg_str))) @@ -2805,6 +2806,7 @@ static void samr_reply_create_user(SAMR_Q_CREATE_USER *q_u, else { user_rid = sam_pass->user_rid; + unk_0 = 0x000703ff; } } } @@ -2823,7 +2825,7 @@ static void samr_reply_create_user(SAMR_Q_CREATE_USER *q_u, DEBUG(5,("samr_create_user: %d\n", __LINE__)); - make_samr_r_create_user(&r_u, &pol, 0x000703ff, user_rid, status); + make_samr_r_create_user(&r_u, &pol, unk_0, user_rid, status); /* store the response in the SMB stream */ samr_io_r_create_user("", &r_u, rdata, 0); -- cgit From 161c11e4bcd408064493c063b228aab589fd2a19 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 19 Nov 1999 01:01:07 +0000 Subject: - bug in nmbd registering DOMAIN_NAME<1c> to WINS server; recursion desired flag MUST be set in any NBT UDP packets sent to a WINS server, else they will go to the WINS client side of the NT NetBIOS kernel instead, and will get trashed. - added \PIPE\browser server-side code. (This used to be commit 8e406c1fa296c3f97b1cd7ddde7b5aeb9232b26e) --- source3/rpc_server/srv_brs.c | 98 +++++++++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_pipe.c | 1 + 2 files changed, 99 insertions(+) create mode 100644 source3/rpc_server/srv_brs.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_brs.c b/source3/rpc_server/srv_brs.c new file mode 100644 index 0000000000..c2abd28cf8 --- /dev/null +++ b/source3/rpc_server/srv_brs.c @@ -0,0 +1,98 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1999, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1999, + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; +extern pstring global_myname; + + +/******************************************************************* + create_brs_info_100 + ********************************************************************/ +static void create_brs_info_100(BRS_INFO_100 *inf) +{ + DEBUG(5,("create_brs_info_100: %d\n", __LINE__)); + + make_brs_info_100(inf); +} + +/******************************************************************* + brs_reply_query_info + + only supports info level 100 at the moment. + + ********************************************************************/ +static void brs_reply_query_info(BRS_Q_QUERY_INFO *q_u, + prs_struct *rdata, + int status) +{ + BRS_R_QUERY_INFO r_u; + BRS_INFO_100 brs100; + + DEBUG(5,("brs_query_info: %d\n", __LINE__)); + + create_brs_info_100(&brs100); + make_brs_r_query_info(&r_u, q_u->switch_value1, &brs100, status); + + /* store the response in the SMB stream */ + brs_io_r_query_info("", &r_u, rdata, 0); + + DEBUG(5,("brs_query_info: %d\n", __LINE__)); +} + +/******************************************************************* + api_brs_query_info + ********************************************************************/ +static void api_brs_query_info( pipes_struct *p, prs_struct *data, + prs_struct *rdata ) +{ + BRS_Q_QUERY_INFO q_u; + + /* grab the net share enum */ + brs_io_q_query_info("", &q_u, data, 0); + + /* construct reply. always indicate success */ + brs_reply_query_info(&q_u, rdata, 0x0); +} + + +/******************************************************************* + \PIPE\brssvc commands + ********************************************************************/ +struct api_struct api_brs_cmds[] = +{ + { "BRS_Q_QUERY_INFO", BRS_QUERY_INFO, api_brs_query_info }, + { NULL , 0 , NULL } +}; + +/******************************************************************* + receives a browser pipe and responds. + ********************************************************************/ +BOOL api_brs_rpc(pipes_struct *p, prs_struct *data) +{ + return api_rpcTNP(p, "api_brssvc_rpc", api_brs_cmds, data); +} + diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index c6d9cf070e..075c9b0d37 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -402,6 +402,7 @@ static struct api_cmd api_fd_commands[] = { "samr", "lsass", api_samr_rpc }, { "srvsvc", "ntsvcs", api_srvsvc_rpc }, { "wkssvc", "ntsvcs", api_wkssvc_rpc }, + { "browser", "ntsvcs", api_brs_rpc }, { "svcctl", "ntsvcs", api_svcctl_rpc }, { "NETLOGON", "lsass", api_netlog_rpc }, { "winreg", "winreg", api_reg_rpc }, -- cgit From 3365a2fd234966ecfcd06d2295cbd085c7bbd8c6 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 19 Nov 1999 01:37:16 +0000 Subject: The First Necessary UNICODE String Support. the random workstation trust account password is TOTAL garbage. i mean, complete garbage. it's nowhere CLOSE to being a UNICODE string. therefore we can't just take every second character. created nt_owf_genW() which creates NT#(password) instead of NT#(Unicode(pw)). followed through to the password setting in srv_samr.c (This used to be commit 172601b84ae94044b27ded917d4e0e21e47a5a66) --- source3/rpc_server/srv_samr.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index a220e38b07..e55a6b2ce8 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -2052,7 +2052,8 @@ static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) struct sam_passwd new_pwd; static uchar nt_hash[16]; static uchar lm_hash[16]; - pstring new_pw; + UNISTR2 new_pw; + uint32 len; if (pwd == NULL) { @@ -2062,16 +2063,15 @@ static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) pwdb_init_sam(&new_pwd); copy_sam_passwd(&new_pwd, pwd); - if (!decode_pw_buffer(id24->pass, new_pw, sizeof(new_pw), True)) + if (!decode_pw_buffer(id24->pass, (char *)new_pw.buffer, 256, &len)) { return False; } -#ifdef DEBUG_PASSWORD - DEBUG(0,("New Password: %s\n", new_pw)); -#endif + new_pw.uni_max_len = len / 2; + new_pw.uni_str_len = len / 2; - nt_lm_owf_gen(new_pw, nt_hash, lm_hash); + nt_lm_owf_genW(&new_pw, nt_hash, lm_hash); new_pwd.smb_passwd = lm_hash; new_pwd.smb_nt_passwd = nt_hash; @@ -2088,7 +2088,8 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) struct sam_passwd new_pwd; static uchar nt_hash[16]; static uchar lm_hash[16]; - pstring new_pw; + UNISTR2 new_pw; + uint32 len; if (id23 == NULL) { @@ -2104,16 +2105,15 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) copy_sam_passwd(&new_pwd, pwd); copy_id23_to_sam_passwd(&new_pwd, id23); - if (!decode_pw_buffer(id23->pass, new_pw, sizeof(new_pw), True)) + if (!decode_pw_buffer(id23->pass, (char*)new_pw.buffer, 256, &len)) { return False; } -#ifdef DEBUG_PASSWORD - DEBUG(0,("New Password: %s\n", new_pw)); -#endif + new_pw.uni_max_len = len / 2; + new_pw.uni_str_len = len / 2; - nt_lm_owf_gen(new_pw, nt_hash, lm_hash); + nt_lm_owf_genW(&new_pw, nt_hash, lm_hash); new_pwd.smb_passwd = lm_hash; new_pwd.smb_nt_passwd = nt_hash; -- cgit From e1820455c24de024a2ff7418bd2d14ad943563fa Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 19 Nov 1999 02:05:19 +0000 Subject: nt5rc2 falling over because the LsaQueryInfoPolicy() response _must_ have the string max length = string length + 1. if not, then it gets its knickers in a twist over whether the string is NULL-terminated or not. four days. four days i spent on this one. (This used to be commit 9795e5948c698115e34c28993cdb82ba31377f5d) --- source3/rpc_server/srv_lsa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 7bc5841cfc..b1761219af 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -88,14 +88,15 @@ static void make_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) fstring sid_str; int domlen = strlen(dom_name); + d_q->uni_dom_str_len = (domlen+1) * 2; d_q->uni_dom_max_len = domlen * 2; - d_q->uni_dom_str_len = domlen * 2; d_q->buffer_dom_name = domlen != 0 ? 1 : 0; /* domain buffer pointer */ d_q->buffer_dom_sid = dom_sid != NULL ? 1 : 0; /* domain sid pointer */ /* this string is supposed to be character short */ make_unistr2(&(d_q->uni_domain_name), dom_name, domlen); + d_q->uni_domain_name.uni_max_len++; sid_to_string(sid_str, dom_sid); make_dom_sid2(&(d_q->dom_sid), dom_sid); -- cgit From ef8ced0ca6688f037d74a5e26b52b41afce37682 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sat, 20 Nov 1999 18:17:29 +0000 Subject: dynamic memory allocation i added a month ago: forgot to ZERO_STRUCT() some of the server-side stuff. Realloc() was being used, so it Realloc()d some random area of memory. oops.dynamic memory allocation i added a month ago: forgot to ZERO_STRUCT() some of the server-side stuff. Realloc() was being used, so it Realloc()d some random area of memory. oops.dynamic memory allocation i added a month ago: forgot to ZERO_STRUCT() some of the server-side stuff. Realloc() was being used, so it Realloc()d some random area of memory. oops. (This used to be commit a51f62f4cf610c23e45251cedb543144747a3e54) --- source3/rpc_server/srv_samr.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index e55a6b2ce8..bc3a842677 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1432,6 +1432,7 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, static void api_samr_query_useraliases( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERALIASES q_u; + ZERO_STRUCT(q_u); samr_io_q_query_useraliases("", &q_u, data, 0); samr_reply_query_useraliases(&q_u, rdata); samr_free_q_query_useraliases(&q_u); @@ -1797,6 +1798,7 @@ static void samr_reply_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u, static void api_samr_lookup_rids( pipes_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_RIDS q_u; + ZERO_STRUCT(q_u); samr_io_q_lookup_rids("", &q_u, data, 0); samr_reply_lookup_rids(&q_u, rdata); samr_free_q_lookup_rids(&q_u); -- cgit From 4081147c31919a973ce1859394d0f5a49a0c2f39 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 21 Nov 1999 17:11:00 +0000 Subject: adding user session key into network netlogon response. (This used to be commit c73f6b0d02fa7700319ba696f54296006167e5d1) --- source3/rpc_server/srv_netlog.c | 44 ++++++++++++++++++++++++++++++++--------- source3/rpc_server/srv_pipe.c | 4 ++-- 2 files changed, 37 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 5e9ae35094..f8d7fe5718 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -666,8 +666,8 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, dump_data(100, nt_pwd, 16); #endif - SamOEMhash((uchar *)lm_pwd, key, False); - SamOEMhash((uchar *)nt_pwd, key, False); + SamOEMhash((uchar *)lm_pwd, key, 0); + SamOEMhash((uchar *)nt_pwd, key, 0); #ifdef DEBUG_PASSWORD DEBUG(100,("decrypt of lm owf password:")); @@ -697,8 +697,9 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, net_login_network: *************************************************************************/ static uint32 net_login_network(NET_ID_INFO_2 *id2, - struct sam_passwd *smb_pass, - user_struct *vuser) + struct sam_passwd *sam_pass, + user_struct *vuser, + char sess_key[16]) { fstring user; fstring domain; @@ -712,11 +713,33 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, DEBUG(5,("net_login_network: lm_len:%d nt_len:%d user:%s domain:%s\n", lm_pw_len, nt_pw_len, user, domain)); - if (smb_password_ok(pwdb_sam_to_smb(smb_pass), id2->lm_chal, - user, domain, + if (pass_check_smb(pwdb_sam_to_smb(sam_pass), + domain, + id2->lm_chal, (uchar *)id2->lm_chal_resp.buffer, lm_pw_len, - (uchar *)id2->nt_chal_resp.buffer, nt_pw_len)) + (uchar *)id2->nt_chal_resp.buffer, nt_pw_len, + NULL, sess_key)) { + unsigned char key[16]; + + memset(key, 0, 16); + memcpy(key, vuser->dc.sess_key, 8); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("key:")); + dump_data(100, key, 16); + + DEBUG(100,("user sess key:")); + dump_data(100, sess_key, 16); +#endif + + SamOEMhash((uchar *)sess_key, key, 0); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("encrypt of user session key:")); + dump_data(100, sess_key, 16); +#endif + return 0x0; } @@ -733,6 +756,8 @@ static uint32 reply_net_sam_logon( NET_Q_SAM_LOGON *q_l, user_struct *vuser, UNISTR2 *uni_samusr = NULL; UNISTR2 *uni_domain = NULL; fstring nt_username; + char *enc_user_sess_key = NULL; + char sess_key[16]; NTTIME logon_time ; NTTIME logoff_time ; @@ -845,7 +870,8 @@ static uint32 reply_net_sam_logon( NET_Q_SAM_LOGON *q_l, user_struct *vuser, case NET_LOGON_TYPE: { /* network login. lm challenge and 24 byte responses */ - status = net_login_network(&q_l->sam_id.ctr->auth.id2, sam_pass, vuser); + status = net_login_network(&q_l->sam_id.ctr->auth.id2, sam_pass, vuser, sess_key); + enc_user_sess_key = sess_key; break; } } @@ -896,7 +922,7 @@ static uint32 reply_net_sam_logon( NET_Q_SAM_LOGON *q_l, user_struct *vuser, gids , /* DOM_GID *gids */ 0x20 , /* uint32 user_flgs (?) */ - NULL, /* char sess_key[16] */ + enc_user_sess_key, /* char sess_key[16] */ global_myname , /* char *logon_srv */ global_sam_name, /* char *logon_dom */ diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 075c9b0d37..c4664f7d7b 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -300,12 +300,12 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) { DEBUG(5,("user: %s domain: %s wks: %s\n", p->user_name, p->domain, p->wks)); become_root(True); - p->ntlmssp_validated = pass_check_smb(p->user_name, p->domain, + smb_pass = getsmbpwnam(p->user_name); + p->ntlmssp_validated = pass_check_smb(smb_pass, p->domain, (uchar*)p->ntlmssp_chal.challenge, lm_owf, lm_owf_len, nt_owf, nt_owf_len, NULL, vuser->dc.user_sess_key); - smb_pass = getsmbpwnam(p->user_name); unbecome_root(True); if (smb_pass != NULL) -- cgit From d7889cd22347e7acd4effb7682d442eef7a666e4 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 24 Nov 1999 18:09:33 +0000 Subject: rewrote policy handle code to be generic (it's needed for client-side too) attempted to fix regsetsec command (This used to be commit eaac0923e0e5e3f4c3d944272a71f3235ac2a741) --- source3/rpc_server/srv_lsa.c | 10 +- source3/rpc_server/srv_lsa_hnd.c | 198 ++++++++++++++++++++++++++++++++------- source3/rpc_server/srv_reg.c | 12 +-- source3/rpc_server/srv_samr.c | 140 +++++++++++++-------------- source3/rpc_server/srv_svcctl.c | 18 ++-- 5 files changed, 254 insertions(+), 124 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index b1761219af..9b6a98e9a6 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -48,7 +48,7 @@ static void lsa_reply_open_policy2(prs_struct *rdata) r_o.status = 0x0; /* get a (unique) handle. open a policy on it. */ - if (!open_lsa_policy_hnd(&r_o.pol)) + if (!open_policy_hnd(&r_o.pol)) { r_o.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -71,7 +71,7 @@ static void lsa_reply_open_policy(prs_struct *rdata) r_o.status = 0x0; /* get a (unique) handle. open a policy on it. */ - if (!open_lsa_policy_hnd(&r_o.pol)) + if (!open_policy_hnd(&r_o.pol)) { r_o.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -132,7 +132,7 @@ static void lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, ZERO_STRUCT(r_q); /* get a (unique) handle. open a policy on it. */ - if (r_q.status == 0x0 && !open_lsa_policy_hnd(&q_q->pol)) + if (r_q.status == 0x0 && !open_policy_hnd(&q_q->pol)) { r_q.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -591,13 +591,13 @@ static void api_lsa_close( pipes_struct *p, prs_struct *data, r_c.status = 0x0; /* find the connection policy handle. */ - if (r_c.status == 0x0 && (find_lsa_policy_by_hnd(&(q_c.pol)) == -1)) + if (r_c.status == 0x0 && (find_policy_by_hnd(&(q_c.pol)) == -1)) { r_c.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } if (r_c.status == 0x0) { - close_lsa_policy_hnd(&(q_c.pol)); + close_policy_hnd(&(q_c.pol)); } /* store the response in the SMB stream */ diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index d53264a73e..7a14437482 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -31,6 +31,11 @@ extern int DEBUGLEVEL; #define MAX_OPEN_POLS 64 #endif +#define POL_NO_INFO 0 +#define POL_REG_INFO 1 +#define POL_SAMR_INFO 2 +#define POL_CLI_INFO 3 + struct reg_info { /* for use by \PIPE\winreg */ @@ -45,17 +50,28 @@ struct samr_info uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ }; +struct cli_info +{ + struct cli_state *cli; + uint16 fnum; + void (*free)(struct cli_state*, uint16 fnum); +}; + static struct policy { struct policy *next, *prev; int pnum; BOOL open; POLICY_HND pol_hnd; + int type; union { - struct samr_info samr; - struct reg_info reg; + struct samr_info *samr; + struct reg_info *reg; + struct cli_info *cli; + } dev; + } *Policy; static struct bitmap *bmap; @@ -85,18 +101,18 @@ static void create_pol_hnd(POLICY_HND *hnd) /**************************************************************************** initialise policy handle states... ****************************************************************************/ -void init_lsa_policy_hnd(void) +void init_policy_hnd(int num_pol_hnds) { - bmap = bitmap_allocate(MAX_OPEN_POLS); + bmap = bitmap_allocate(num_pol_hnds); if (!bmap) { - exit_server("out of memory in init_lsa_policy_hnd\n"); + exit_server("out of memory in init_policy_hnd\n"); } } /**************************************************************************** find first available policy slot. creates a policy handle for you. ****************************************************************************/ -BOOL open_lsa_policy_hnd(POLICY_HND *hnd) +BOOL open_policy_hnd(POLICY_HND *hnd) { int i; struct policy *p; @@ -118,6 +134,7 @@ BOOL open_lsa_policy_hnd(POLICY_HND *hnd) p->open = True; p->pnum = i; + p->type = POL_NO_INFO; create_pol_hnd(hnd); memcpy(&p->pol_hnd, hnd, sizeof(*hnd)); @@ -135,7 +152,7 @@ BOOL open_lsa_policy_hnd(POLICY_HND *hnd) /**************************************************************************** find policy by handle ****************************************************************************/ -static struct policy *find_lsa_policy(POLICY_HND *hnd) +static struct policy *find_policy(POLICY_HND *hnd) { struct policy *p; @@ -156,9 +173,9 @@ static struct policy *find_lsa_policy(POLICY_HND *hnd) /**************************************************************************** find policy index by handle ****************************************************************************/ -int find_lsa_policy_by_hnd(POLICY_HND *hnd) +int find_policy_by_hnd(POLICY_HND *hnd) { - struct policy *p = find_lsa_policy(hnd); + struct policy *p = find_policy(hnd); return p?p->pnum:-1; } @@ -166,15 +183,24 @@ int find_lsa_policy_by_hnd(POLICY_HND *hnd) /**************************************************************************** set samr rid ****************************************************************************/ -BOOL set_lsa_policy_samr_rid(POLICY_HND *hnd, uint32 rid) +BOOL set_policy_samr_rid(POLICY_HND *hnd, uint32 rid) { - struct policy *p = find_lsa_policy(hnd); + struct policy *p = find_policy(hnd); - if (p && p->open) { + if (p && p->open) + { DEBUG(3,("Setting policy device rid=%x pnum=%x\n", rid, p->pnum)); - p->dev.samr.rid = rid; + if (p->dev.samr == NULL) + { + p->dev.samr = (struct samr_info*)malloc(sizeof(*p->dev.samr)); + } + if (p->dev.samr == NULL) + { + return False; + } + p->dev.samr->rid = rid; return True; } @@ -186,15 +212,25 @@ BOOL set_lsa_policy_samr_rid(POLICY_HND *hnd, uint32 rid) /**************************************************************************** set samr pol status. absolutely no idea what this is. ****************************************************************************/ -BOOL set_lsa_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status) +BOOL set_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status) { - struct policy *p = find_lsa_policy(hnd); + struct policy *p = find_policy(hnd); - if (p && p->open) { + if (p && p->open) + { DEBUG(3,("Setting policy status=%x pnum=%x\n", pol_status, p->pnum)); - p->dev.samr.status = pol_status; + if (p->dev.samr == NULL) + { + p->type = POL_SAMR_INFO; + p->dev.samr = (struct samr_info*)malloc(sizeof(*p->dev.samr)); + } + if (p->dev.samr == NULL) + { + return False; + } + p->dev.samr->status = pol_status; return True; } @@ -206,16 +242,25 @@ BOOL set_lsa_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status) /**************************************************************************** set samr sid ****************************************************************************/ -BOOL set_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) +BOOL set_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) { pstring sidstr; - struct policy *p = find_lsa_policy(hnd); + struct policy *p = find_policy(hnd); if (p && p->open) { DEBUG(3,("Setting policy sid=%s pnum=%x\n", sid_to_string(sidstr, sid), p->pnum)); - memcpy(&p->dev.samr.sid, sid, sizeof(*sid)); + if (p->dev.samr == NULL) + { + p->type = POL_SAMR_INFO; + p->dev.samr = (struct samr_info*)malloc(sizeof(*p->dev.samr)); + } + if (p->dev.samr == NULL) + { + return False; + } + memcpy(&p->dev.samr->sid, sid, sizeof(*sid)); return True; } @@ -227,14 +272,14 @@ BOOL set_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) /**************************************************************************** get samr sid ****************************************************************************/ -BOOL get_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) +BOOL get_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) { - struct policy *p = find_lsa_policy(hnd); + struct policy *p = find_policy(hnd); if (p != NULL && p->open) { pstring sidstr; - memcpy(sid, &p->dev.samr.sid, sizeof(*sid)); + memcpy(sid, &p->dev.samr->sid, sizeof(*sid)); DEBUG(3,("Getting policy sid=%s pnum=%x\n", sid_to_string(sidstr, sid), p->pnum)); @@ -248,12 +293,12 @@ BOOL get_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) /**************************************************************************** get samr rid ****************************************************************************/ -uint32 get_lsa_policy_samr_rid(POLICY_HND *hnd) +uint32 get_policy_samr_rid(POLICY_HND *hnd) { - struct policy *p = find_lsa_policy(hnd); + struct policy *p = find_policy(hnd); if (p && p->open) { - uint32 rid = p->dev.samr.rid; + uint32 rid = p->dev.samr->rid; DEBUG(3,("Getting policy device rid=%x pnum=%x\n", rid, p->pnum)); @@ -267,16 +312,25 @@ uint32 get_lsa_policy_samr_rid(POLICY_HND *hnd) /**************************************************************************** set reg name ****************************************************************************/ -BOOL set_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) +BOOL set_policy_reg_name(POLICY_HND *hnd, fstring name) { - struct policy *p = find_lsa_policy(hnd); + struct policy *p = find_policy(hnd); if (p && p->open) { DEBUG(3,("Getting policy pnum=%x\n", p->pnum)); - fstrcpy(p->dev.reg.name, name); + if (p->dev.reg == NULL) + { + p->type = POL_REG_INFO; + p->dev.reg = (struct reg_info*)malloc(sizeof(*p->dev.reg)); + } + if (p->dev.reg == NULL) + { + return False; + } + fstrcpy(p->dev.reg->name, name); return True; } @@ -287,16 +341,16 @@ BOOL set_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) /**************************************************************************** set reg name ****************************************************************************/ -BOOL get_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) +BOOL get_policy_reg_name(POLICY_HND *hnd, fstring name) { - struct policy *p = find_lsa_policy(hnd); + struct policy *p = find_policy(hnd); if (p && p->open) { DEBUG(3,("Setting policy pnum=%x name=%s\n", p->pnum, name)); - fstrcpy(name, p->dev.reg.name); + fstrcpy(name, p->dev.reg->name); DEBUG(5,("getting policy reg name=%s\n", name)); return True; } @@ -305,12 +359,65 @@ BOOL get_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) return False; } +/**************************************************************************** + set cli state +****************************************************************************/ +BOOL set_policy_cli_state(POLICY_HND *hnd, struct cli_state *cli, uint16 fnum, + void (*free_fn)(struct cli_state *, uint16)) +{ + struct policy *p = find_policy(hnd); + + if (p && p->open) + { + DEBUG(3,("Setting policy cli state pnum=%x\n", p->pnum)); + + if (p->dev.cli == NULL) + { + p->type = POL_CLI_INFO; + p->dev.cli = (struct cli_info*)malloc(sizeof(*p->dev.cli)); + } + if (p->dev.cli == NULL) + { + return False; + } + p->dev.cli->cli = cli; + p->dev.cli->free = free_fn; + p->dev.cli->fnum = fnum; + return True; + } + + DEBUG(3,("Error setting policy cli state\n")); + + return False; +} + +/**************************************************************************** + get cli state +****************************************************************************/ +BOOL get_policy_cli_state(POLICY_HND *hnd, struct cli_state **cli, uint16 *fnum) +{ + struct policy *p = find_policy(hnd); + + if (p != NULL && p->open) + { + DEBUG(3,("Getting cli state pnum=%x\n", p->pnum)); + + (*cli ) = p->dev.cli->cli; + (*fnum) = p->dev.cli->fnum; + + return True; + } + + DEBUG(3,("Error getting policy\n")); + return False; +} + /**************************************************************************** close an lsa policy ****************************************************************************/ -BOOL close_lsa_policy_hnd(POLICY_HND *hnd) +BOOL close_policy_hnd(POLICY_HND *hnd) { - struct policy *p = find_lsa_policy(hnd); + struct policy *p = find_policy(hnd); if (!p) { @@ -327,6 +434,29 @@ BOOL close_lsa_policy_hnd(POLICY_HND *hnd) ZERO_STRUCTP(p); ZERO_STRUCTP(hnd); + switch (p->type) + { + case POL_REG_INFO: + { + free(p->dev.reg); + break; + } + case POL_SAMR_INFO: + { + free(p->dev.samr); + break; + } + case POL_CLI_INFO: + { + if (p->dev.cli->free != NULL) + { + p->dev.cli->free(p->dev.cli->cli, + p->dev.cli->fnum); + } + break; + } + } + free(p); return True; diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 10b9bac90c..22314d9c5e 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -41,7 +41,7 @@ static void reg_reply_close(REG_Q_CLOSE *q_r, bzero(r_u.pol.data, POL_HND_SIZE); /* close the policy handle */ - if (close_lsa_policy_hnd(&(q_r->pol))) + if (close_policy_hnd(&(q_r->pol))) { r_u.status = 0; } @@ -84,7 +84,7 @@ static void reg_reply_open(REG_Q_OPEN_HKLM *q_r, r_u.status = 0x0; /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !open_lsa_policy_hnd(&(r_u.pol))) + if (r_u.status == 0x0 && !open_policy_hnd(&(r_u.pol))) { r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -126,12 +126,12 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, DEBUG(5,("reg_open_entry: %d\n", __LINE__)); - if (status == 0 && find_lsa_policy_by_hnd(&(q_u->pol)) == -1) + if (status == 0 && find_policy_by_hnd(&(q_u->pol)) == -1) { status = 0xC000000 | NT_STATUS_INVALID_HANDLE; } - if (status == 0x0 && !open_lsa_policy_hnd(&pol)) + if (status == 0x0 && !open_policy_hnd(&pol)) { status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } @@ -149,7 +149,7 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, } } - if (status == 0x0 && !set_lsa_policy_reg_name(&pol, name)) + if (status == 0x0 && !set_policy_reg_name(&pol, name)) { status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } @@ -195,7 +195,7 @@ static void reg_reply_info(REG_Q_INFO *q_u, DEBUG(5,("reg_info: %d\n", __LINE__)); - if (status == 0x0 && !get_lsa_policy_reg_name(&q_u->pol, name)) + if (status == 0x0 && !get_policy_reg_name(&q_u->pol, name)) { status = 0xC000000 | NT_STATUS_INVALID_HANDLE; } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index bc3a842677..894e8f2e2c 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -124,7 +124,7 @@ static void samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, bzero(r_u.pol.data, POL_HND_SIZE); /* close the policy handle */ - if (close_lsa_policy_hnd(&(q_u->pol))) + if (close_policy_hnd(&(q_u->pol))) { r_u.status = 0; } @@ -165,19 +165,19 @@ static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, r_u.status = 0x0; /* find the connection policy handle. */ - if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->connect_pol)) == -1)) + if (r_u.status == 0x0 && (find_policy_by_hnd(&(q_u->connect_pol)) == -1)) { r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.domain_pol)))) + if (r_u.status == 0x0 && !(pol_open = open_policy_hnd(&(r_u.domain_pol)))) { r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } /* associate the domain SID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_lsa_policy_samr_sid(&(r_u.domain_pol), &(q_u->dom_sid.sid))) + if (r_u.status == 0x0 && !set_policy_samr_sid(&(r_u.domain_pol), &(q_u->dom_sid.sid))) { /* oh, whoops. don't know what error message to return, here */ r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -185,7 +185,7 @@ static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, if (r_u.status != 0 && pol_open) { - close_lsa_policy_hnd(&(r_u.domain_pol)); + close_policy_hnd(&(r_u.domain_pol)); } DEBUG(5,("samr_open_domain: %d\n", __LINE__)); @@ -218,13 +218,13 @@ static void samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, uint32 status = 0x0; /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->user_pol)) == -1)) + if (status == 0x0 && (find_policy_by_hnd(&(q_u->user_pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* find the user's rid */ - if ((status == 0x0) && (get_lsa_policy_samr_rid(&(q_u->user_pol)) == 0xffffffff)) + if ((status == 0x0) && (get_policy_samr_rid(&(q_u->user_pol)) == 0xffffffff)) { status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } @@ -265,13 +265,13 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, status = 0x0; /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->user_pol)) == -1)) + if (status == 0x0 && (find_policy_by_hnd(&(q_u->user_pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* find the user's rid */ - if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->user_pol))) == 0xffffffff) + if (status == 0x0 && (rid = get_policy_samr_rid(&(q_u->user_pol))) == 0xffffffff) { status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } @@ -334,7 +334,7 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, r_e.status = 0x0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + if (r_e.status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -392,7 +392,7 @@ static void samr_reply_add_groupmem(SAMR_Q_ADD_GROUPMEM *q_u, r_e.status = 0x0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &group_sid)) + if (r_e.status == 0x0 && !get_policy_samr_sid(&q_u->pol, &group_sid)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -450,7 +450,7 @@ static void samr_reply_del_groupmem(SAMR_Q_DEL_GROUPMEM *q_u, r_e.status = 0x0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &group_sid)) + if (r_e.status == 0x0 && !get_policy_samr_sid(&q_u->pol, &group_sid)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -508,7 +508,7 @@ static void samr_reply_add_aliasmem(SAMR_Q_ADD_ALIASMEM *q_u, r_e.status = 0x0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->alias_pol, &alias_sid)) + if (r_e.status == 0x0 && !get_policy_samr_sid(&q_u->alias_pol, &alias_sid)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -574,7 +574,7 @@ static void samr_reply_del_aliasmem(SAMR_Q_DEL_ALIASMEM *q_u, r_e.status = 0x0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->alias_pol, &alias_sid)) + if (r_e.status == 0x0 && !get_policy_samr_sid(&q_u->alias_pol, &alias_sid)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -644,7 +644,7 @@ static void samr_reply_enum_domains(SAMR_Q_ENUM_DOMAINS *q_u, r_e.status = 0x0; /* find the connection policy handle. */ - if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + if (r_e.status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -711,7 +711,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, r_e.num_entries2 = 0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &sid)) + if (r_e.status == 0x0 && !get_policy_samr_sid(&q_u->pol, &sid)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -792,7 +792,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, r_e.num_entries2 = 0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &sid)) + if (r_e.status == 0x0 && !get_policy_samr_sid(&q_u->pol, &sid)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -894,7 +894,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, DEBUG(5,("samr_reply_query_dispinfo: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (find_lsa_policy_by_hnd(&(q_u->domain_pol)) == -1) + if (find_policy_by_hnd(&(q_u->domain_pol)) == -1) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; DEBUG(5,("samr_reply_query_dispinfo: invalid handle\n")); @@ -1058,7 +1058,7 @@ static void samr_reply_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP *q_u, DEBUG(5,("samr_delete_dom_group: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->group_pol, &group_sid)) + if (status == 0x0 && !get_policy_samr_sid(&q_u->group_pol, &group_sid)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -1124,7 +1124,7 @@ static void samr_reply_query_groupmem(SAMR_Q_QUERY_GROUPMEM *q_u, DEBUG(5,("samr_query_groupmem: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->group_pol, &group_sid)) + if (status == 0x0 && !get_policy_samr_sid(&q_u->group_pol, &group_sid)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -1211,7 +1211,7 @@ static void samr_reply_query_groupinfo(SAMR_Q_QUERY_GROUPINFO *q_u, r_e.ptr = 0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + if (r_e.status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -1274,7 +1274,7 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, r_e.ptr = 0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + if (r_e.status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -1340,7 +1340,7 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, DEBUG(5,("samr_query_useraliases: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &dom_sid)) + if (status == 0x0 && !get_policy_samr_sid(&q_u->pol, &dom_sid)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -1455,7 +1455,7 @@ static void samr_reply_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS *q_u, DEBUG(5,("samr_delete_dom_alias: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->alias_pol, &alias_sid)) + if (status == 0x0 && !get_policy_samr_sid(&q_u->alias_pol, &alias_sid)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -1520,7 +1520,7 @@ static void samr_reply_query_aliasmem(SAMR_Q_QUERY_ALIASMEM *q_u, DEBUG(5,("samr_query_aliasmem: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->alias_pol, &alias_sid)) + if (status == 0x0 && !get_policy_samr_sid(&q_u->alias_pol, &alias_sid)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -1611,7 +1611,7 @@ static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, DEBUG(5,("samr_lookup_names: %d\n", __LINE__)); - if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &pol_sid)) + if (status == 0x0 && !get_policy_samr_sid(&q_u->pol, &pol_sid)) { status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } @@ -1755,12 +1755,12 @@ static void samr_reply_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u, DEBUG(5,("samr_lookup_rids: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + if (status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } - if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &pol_sid)) + if (status == 0x0 && !get_policy_samr_sid(&q_u->pol, &pol_sid)) { status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } @@ -1822,13 +1822,13 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, r_u.status = 0x0; /* find the policy handle. open a policy on it. */ - if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->domain_pol)) == -1)) + if (r_u.status == 0x0 && (find_policy_by_hnd(&(q_u->domain_pol)) == -1)) { r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.user_pol)))) + if (r_u.status == 0x0 && !(pol_open = open_policy_hnd(&(r_u.user_pol)))) { r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -1844,7 +1844,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, } /* associate the RID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_lsa_policy_samr_rid(&(r_u.user_pol), q_u->user_rid)) + if (r_u.status == 0x0 && !set_policy_samr_rid(&(r_u.user_pol), q_u->user_rid)) { /* oh, whoops. don't know what error message to return, here */ r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -1852,7 +1852,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, if (r_u.status != 0 && pol_open) { - close_lsa_policy_hnd(&(r_u.user_pol)); + close_policy_hnd(&(r_u.user_pol)); } DEBUG(5,("samr_open_user: %d\n", __LINE__)); @@ -1981,13 +1981,13 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, DEBUG(5,("samr_reply_query_userinfo: %d\n", __LINE__)); /* search for the handle */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + if (status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* find the user's rid */ - if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->pol))) == 0xffffffff) + if (status == 0x0 && (rid = get_policy_samr_rid(&(q_u->pol))) == 0xffffffff) { status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } @@ -2173,13 +2173,13 @@ static void samr_reply_set_userinfo2(SAMR_Q_SET_USERINFO2 *q_u, DEBUG(5,("samr_reply_set_userinfo2: %d\n", __LINE__)); /* search for the handle */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + if (status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* find the user's rid */ - if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->pol))) == 0xffffffff) + if (status == 0x0 && (rid = get_policy_samr_rid(&(q_u->pol))) == 0xffffffff) { status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } @@ -2254,13 +2254,13 @@ static void samr_reply_set_userinfo(SAMR_Q_SET_USERINFO *q_u, DEBUG(5,("samr_reply_set_userinfo: %d\n", __LINE__)); /* search for the handle */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + if (status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* find the user's rid */ - if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->pol))) == 0xffffffff) + if (status == 0x0 && (rid = get_policy_samr_rid(&(q_u->pol))) == 0xffffffff) { status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } @@ -2358,13 +2358,13 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, DEBUG(5,("samr_query_usergroups: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + if (status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* find the user's rid */ - if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->pol))) == 0xffffffff) + if (status == 0x0 && (rid = get_policy_samr_rid(&(q_u->pol))) == 0xffffffff) { status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } @@ -2434,7 +2434,7 @@ static uint32 open_samr_alias(DOM_SID *sid, POLICY_HND *alias_pol, uint32 status = 0x0; /* get a (unique) handle. open a policy on it. */ - if (status == 0x0 && !(pol_open = open_lsa_policy_hnd(alias_pol))) + if (status == 0x0 && !(pol_open = open_policy_hnd(alias_pol))) { status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -2442,7 +2442,7 @@ static uint32 open_samr_alias(DOM_SID *sid, POLICY_HND *alias_pol, DEBUG(0,("TODO: verify that the alias rid exists\n")); /* associate a RID with the (unique) handle. */ - if (status == 0x0 && !set_lsa_policy_samr_rid(alias_pol, alias_rid)) + if (status == 0x0 && !set_policy_samr_rid(alias_pol, alias_rid)) { /* oh, whoops. don't know what error message to return, here */ status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2451,7 +2451,7 @@ static uint32 open_samr_alias(DOM_SID *sid, POLICY_HND *alias_pol, sid_append_rid(sid, alias_rid); /* associate an alias SID with the (unique) handle. */ - if (status == 0x0 && !set_lsa_policy_samr_sid(alias_pol, sid)) + if (status == 0x0 && !set_policy_samr_sid(alias_pol, sid)) { /* oh, whoops. don't know what error message to return, here */ status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2459,7 +2459,7 @@ static uint32 open_samr_alias(DOM_SID *sid, POLICY_HND *alias_pol, if (status != 0 && pol_open) { - close_lsa_policy_hnd(alias_pol); + close_policy_hnd(alias_pol); } return status; @@ -2482,13 +2482,13 @@ static void samr_reply_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS *q_u, DEBUG(5,("samr_create_dom_alias: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->dom_pol)) == -1)) + if (status == 0x0 && (find_policy_by_hnd(&(q_u->dom_pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* find the domain sid */ - if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->dom_pol, &dom_sid)) + if (status == 0x0 && !get_policy_samr_sid(&q_u->dom_pol, &dom_sid)) { status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } @@ -2545,7 +2545,7 @@ static uint32 open_samr_group(DOM_SID *sid, POLICY_HND *group_pol, uint32 status = 0x0; /* get a (unique) handle. open a policy on it. */ - if (status == 0x0 && !(pol_open = open_lsa_policy_hnd(group_pol))) + if (status == 0x0 && !(pol_open = open_policy_hnd(group_pol))) { status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -2553,7 +2553,7 @@ static uint32 open_samr_group(DOM_SID *sid, POLICY_HND *group_pol, DEBUG(0,("TODO: verify that the group rid exists\n")); /* associate a RID with the (unique) handle. */ - if (status == 0x0 && !set_lsa_policy_samr_rid(group_pol, group_rid)) + if (status == 0x0 && !set_policy_samr_rid(group_pol, group_rid)) { /* oh, whoops. don't know what error message to return, here */ status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2562,7 +2562,7 @@ static uint32 open_samr_group(DOM_SID *sid, POLICY_HND *group_pol, sid_append_rid(sid, group_rid); /* associate an group SID with the (unique) handle. */ - if (status == 0x0 && !set_lsa_policy_samr_sid(group_pol, sid)) + if (status == 0x0 && !set_policy_samr_sid(group_pol, sid)) { /* oh, whoops. don't know what error message to return, here */ status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2570,7 +2570,7 @@ static uint32 open_samr_group(DOM_SID *sid, POLICY_HND *group_pol, if (status != 0 && pol_open) { - close_lsa_policy_hnd(group_pol); + close_policy_hnd(group_pol); } return status; @@ -2593,13 +2593,13 @@ static void samr_reply_create_dom_group(SAMR_Q_CREATE_DOM_GROUP *q_u, DEBUG(5,("samr_create_dom_group: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + if (status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* find the domain sid */ - if (status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &dom_sid)) + if (status == 0x0 && !get_policy_samr_sid(&q_u->pol, &dom_sid)) { status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; } @@ -2666,7 +2666,7 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, DEBUG(5,("samr_reply_query_dom_info: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->domain_pol)) == -1)) + if (r_u.status == 0x0 && (find_policy_by_hnd(&(q_u->domain_pol)) == -1)) { r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; DEBUG(5,("samr_reply_query_dom_info: invalid handle\n")); @@ -2763,13 +2763,13 @@ static void samr_reply_create_user(SAMR_Q_CREATE_USER *q_u, */ /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->domain_pol)) == -1)) + if (status == 0x0 && (find_policy_by_hnd(&(q_u->domain_pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* get a (unique) handle. open a policy on it. */ - if (status == 0x0 && !(pol_open = open_lsa_policy_hnd(&pol))) + if (status == 0x0 && !(pol_open = open_policy_hnd(&pol))) { status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -2814,7 +2814,7 @@ static void samr_reply_create_user(SAMR_Q_CREATE_USER *q_u, } /* associate the RID with the (unique) handle. */ - if (status == 0x0 && !set_lsa_policy_samr_rid(&pol, user_rid)) + if (status == 0x0 && !set_policy_samr_rid(&pol, user_rid)) { /* oh, whoops. don't know what error message to return, here */ status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2822,7 +2822,7 @@ static void samr_reply_create_user(SAMR_Q_CREATE_USER *q_u, if (status != 0 && pol_open) { - close_lsa_policy_hnd(&pol); + close_policy_hnd(&pol); } DEBUG(5,("samr_create_user: %d\n", __LINE__)); @@ -2864,13 +2864,13 @@ static void samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, r_u.status = 0x0; /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.connect_pol)))) + if (r_u.status == 0x0 && !(pol_open = open_policy_hnd(&(r_u.connect_pol)))) { r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } /* associate the domain SID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_lsa_policy_samr_pol_status(&(r_u.connect_pol), q_u->unknown_0)) + if (r_u.status == 0x0 && !set_policy_samr_pol_status(&(r_u.connect_pol), q_u->unknown_0)) { /* oh, whoops. don't know what error message to return, here */ r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2878,7 +2878,7 @@ static void samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, if (r_u.status != 0 && pol_open) { - close_lsa_policy_hnd(&(r_u.connect_pol)); + close_policy_hnd(&(r_u.connect_pol)); } DEBUG(5,("samr_connect_anon: %d\n", __LINE__)); @@ -2913,13 +2913,13 @@ static void samr_reply_connect(SAMR_Q_CONNECT *q_u, r_u.status = 0x0; /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.connect_pol)))) + if (r_u.status == 0x0 && !(pol_open = open_policy_hnd(&(r_u.connect_pol)))) { r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } /* associate the domain SID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_lsa_policy_samr_pol_status(&(r_u.connect_pol), q_u->unknown_0)) + if (r_u.status == 0x0 && !set_policy_samr_pol_status(&(r_u.connect_pol), q_u->unknown_0)) { /* oh, whoops. don't know what error message to return, here */ r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2927,7 +2927,7 @@ static void samr_reply_connect(SAMR_Q_CONNECT *q_u, if (r_u.status != 0 && pol_open) { - close_lsa_policy_hnd(&(r_u.connect_pol)); + close_policy_hnd(&(r_u.connect_pol)); } DEBUG(5,("samr_connect: %d\n", __LINE__)); @@ -2962,13 +2962,13 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, /* set up the SAMR open_alias response */ r_u.status = 0x0; - if (r_u.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->dom_pol, &sid)) + if (r_u.status == 0x0 && !get_policy_samr_sid(&q_u->dom_pol, &sid)) { r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.pol)))) + if (r_u.status == 0x0 && !(pol_open = open_policy_hnd(&(r_u.pol)))) { r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -2976,7 +2976,7 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, DEBUG(0,("TODO: verify that the alias rid exists\n")); /* associate a RID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_lsa_policy_samr_rid(&(r_u.pol), q_u->rid_alias)) + if (r_u.status == 0x0 && !set_policy_samr_rid(&(r_u.pol), q_u->rid_alias)) { /* oh, whoops. don't know what error message to return, here */ r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2985,7 +2985,7 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, sid_append_rid(&sid, q_u->rid_alias); /* associate an alias SID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_lsa_policy_samr_sid(&(r_u.pol), &sid)) + if (r_u.status == 0x0 && !set_policy_samr_sid(&(r_u.pol), &sid)) { /* oh, whoops. don't know what error message to return, here */ r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2993,7 +2993,7 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, if (r_u.status != 0 && pol_open) { - close_lsa_policy_hnd(&(r_u.pol)); + close_policy_hnd(&(r_u.pol)); } DEBUG(5,("samr_open_alias: %d\n", __LINE__)); @@ -3030,7 +3030,7 @@ static void samr_reply_open_group(SAMR_Q_OPEN_GROUP *q_u, r_u.status = 0x0; /* find the domain sid associated with the policy handle */ - if (r_u.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->domain_pol, &sid)) + if (r_u.status == 0x0 && !get_policy_samr_sid(&q_u->domain_pol, &sid)) { r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -3078,7 +3078,7 @@ static void samr_reply_lookup_domain(SAMR_Q_LOOKUP_DOMAIN *q_u, r_u.status = 0x0; /* find the connection policy handle */ - if (find_lsa_policy_by_hnd(&(q_u->connect_pol)) == -1) + if (find_policy_by_hnd(&(q_u->connect_pol)) == -1) { r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 39ec2c93ec..e67cafb9df 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -41,7 +41,7 @@ static void svc_reply_close(SVC_Q_CLOSE *q_r, bzero(r_u.pol.data, POL_HND_SIZE); /* close the policy handle */ - if (close_lsa_policy_hnd(&(q_r->pol))) + if (close_policy_hnd(&(q_r->pol))) { r_u.status = 0; } @@ -83,12 +83,12 @@ static void svc_reply_open_service(SVC_Q_OPEN_SERVICE *q_u, DEBUG(5,("svc_open_service: %d\n", __LINE__)); - if (status == 0x0 && find_lsa_policy_by_hnd(&q_u->scman_pol) == -1) + if (status == 0x0 && find_policy_by_hnd(&q_u->scman_pol) == -1) { status = 0xC000000 | NT_STATUS_INVALID_HANDLE; } - if (status == 0x0 && !open_lsa_policy_hnd(&pol)) + if (status == 0x0 && !open_policy_hnd(&pol)) { status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } @@ -101,7 +101,7 @@ static void svc_reply_open_service(SVC_Q_OPEN_SERVICE *q_u, /* lkcl XXXX do a check on the name, here */ } - if (status == 0x0 && !set_lsa_policy_reg_name(&pol, name)) + if (status == 0x0 && !set_policy_reg_name(&pol, name)) { status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } @@ -137,7 +137,7 @@ static void svc_reply_start_service(SVC_Q_START_SERVICE *q_s, r_s.status = 0x0; - if (find_lsa_policy_by_hnd(&q_s->pol) == -1) + if (find_policy_by_hnd(&q_s->pol) == -1) { r_s.status = 0xC000000 | NT_STATUS_INVALID_HANDLE; } @@ -174,7 +174,7 @@ static void svc_reply_open_sc_man(SVC_Q_OPEN_SC_MAN *q_u, DEBUG(5,("svc_open_sc_man: %d\n", __LINE__)); - if (status == 0x0 && !open_lsa_policy_hnd(&pol)) + if (status == 0x0 && !open_policy_hnd(&pol)) { status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } @@ -187,7 +187,7 @@ static void svc_reply_open_sc_man(SVC_Q_OPEN_SC_MAN *q_u, /* lkcl XXXX do a check on the name, here */ } - if (status == 0x0 && !set_lsa_policy_reg_name(&pol, name)) + if (status == 0x0 && !set_policy_reg_name(&pol, name)) { status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } @@ -242,7 +242,7 @@ static void svc_reply_enum_svcs_status(SVC_Q_ENUM_SVCS_STATUS *q_u, DEBUG(5,("svc_enum_svcs_status: %d\n", __LINE__)); - if (dos_status == 0x0 && find_lsa_policy_by_hnd(&q_u->pol) == -1) + if (dos_status == 0x0 && find_policy_by_hnd(&q_u->pol) == -1) { dos_status = 0xC000000 | NT_STATUS_INVALID_HANDLE; } @@ -338,7 +338,7 @@ static void svc_reply_query_disp_name(SVC_Q_QUERY_DISP_NAME *q_u, DEBUG(5,("svc_query_disp_name: %d\n", __LINE__)); - if (find_lsa_policy_by_hnd(&q_u->scman_pol) == -1) + if (find_policy_by_hnd(&q_u->scman_pol) == -1) { status = 0xC000000 | NT_STATUS_INVALID_HANDLE; } -- cgit From 2752e372b64337de24edef52575ddc7da0ed8d04 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 24 Nov 1999 18:15:50 +0000 Subject: WARNING! MOVED rpc_server/srv_lsa_hnd.c TO lib/util_hnd.c CVS UPDATE MAY ISSUE WARNING ABOUT lib/util_hnd.c MODIFICATION DATE BEING IN THE FUTURE. CVS CHECKOUT A NEW REPOSITORY MAY BE SAFER. (This used to be commit c26e8a6ac59934ae580077df937439c2c538dbdb) --- source3/rpc_server/srv_lsa_hnd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 7a14437482..36bacad59b 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -101,12 +101,11 @@ static void create_pol_hnd(POLICY_HND *hnd) /**************************************************************************** initialise policy handle states... ****************************************************************************/ -void init_policy_hnd(int num_pol_hnds) +BOOL init_policy_hnd(int num_pol_hnds) { bmap = bitmap_allocate(num_pol_hnds); - if (!bmap) { - exit_server("out of memory in init_policy_hnd\n"); - } + + return bmap != NULL; } /**************************************************************************** -- cgit From f8b82a7b9507e11595bc924def179dc1d7d79a54 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 24 Nov 1999 20:24:33 +0000 Subject: first stages of removing struct cli_state* and uint16 fnum from all msrpc client code. the intent is to hide / abstract / associate connection info behind policy handles. this makes the msrpc functions look more and more like their nt equivalents. who-hou! (This used to be commit c01b18e632aede6fce7264ef6971d7ddba945cfb) --- source3/rpc_server/srv_lsa_hnd.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 36bacad59b..8e4620f8dc 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -111,7 +111,7 @@ BOOL init_policy_hnd(int num_pol_hnds) /**************************************************************************** find first available policy slot. creates a policy handle for you. ****************************************************************************/ -BOOL open_policy_hnd(POLICY_HND *hnd) +BOOL register_policy_hnd(POLICY_HND *hnd) { int i; struct policy *p; @@ -135,7 +135,6 @@ BOOL open_policy_hnd(POLICY_HND *hnd) p->pnum = i; p->type = POL_NO_INFO; - create_pol_hnd(hnd); memcpy(&p->pol_hnd, hnd, sizeof(*hnd)); bitmap_set(bmap, i); @@ -148,23 +147,33 @@ BOOL open_policy_hnd(POLICY_HND *hnd) return True; } +/**************************************************************************** + find first available policy slot. creates a policy handle for you. +****************************************************************************/ +BOOL open_policy_hnd(POLICY_HND *hnd) +{ + create_pol_hnd(hnd); + return register_policy_hnd(hnd); +} + /**************************************************************************** find policy by handle ****************************************************************************/ -static struct policy *find_policy(POLICY_HND *hnd) +static struct policy *find_policy(const POLICY_HND *hnd) { struct policy *p; for (p=Policy;p;p=p->next) { if (memcmp(&p->pol_hnd, hnd, sizeof(*hnd)) == 0) { DEBUG(4,("Found policy hnd[%x] ", p->pnum)); - dump_data(4, (char *)hnd->data, sizeof(hnd->data)); + dump_data(4, (const char *)hnd->data, + sizeof(hnd->data)); return p; } } DEBUG(4,("Policy not found: ")); - dump_data(4, (char *)hnd->data, sizeof(hnd->data)); + dump_data(4, (const char *)hnd->data, sizeof(hnd->data)); return NULL; } @@ -172,7 +181,7 @@ static struct policy *find_policy(POLICY_HND *hnd) /**************************************************************************** find policy index by handle ****************************************************************************/ -int find_policy_by_hnd(POLICY_HND *hnd) +int find_policy_by_hnd(const POLICY_HND *hnd) { struct policy *p = find_policy(hnd); @@ -393,7 +402,8 @@ BOOL set_policy_cli_state(POLICY_HND *hnd, struct cli_state *cli, uint16 fnum, /**************************************************************************** get cli state ****************************************************************************/ -BOOL get_policy_cli_state(POLICY_HND *hnd, struct cli_state **cli, uint16 *fnum) +BOOL get_policy_cli_state(const POLICY_HND *hnd, struct cli_state **cli, + uint16 *fnum) { struct policy *p = find_policy(hnd); -- cgit From a70a4626df78965e1ad9c7f89f5d1c490e373ee0 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 24 Nov 1999 23:11:03 +0000 Subject: service control manager API completed. svcenum -i works, but does not do so twice. possible memory corruption, revolving around getopt(). (This used to be commit 7cacf8bd026f1ee274f1d352c68cf79cf4f3b499) --- source3/rpc_server/srv_lsa_hnd.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 8e4620f8dc..b32b3322b3 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -462,6 +462,7 @@ BOOL close_policy_hnd(POLICY_HND *hnd) p->dev.cli->free(p->dev.cli->cli, p->dev.cli->fnum); } + free(p->dev.cli); break; } } -- cgit From 75bc1009438c2ff1696205ab0ee5667ec3ef3062 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Thu, 25 Nov 1999 05:26:48 +0000 Subject: cool! completed a samr* API that _would_ look like an msdn samr* api... if microsoft bothered to publish it. actually, there are good reasons for not publishing it: people might write programs for it, and then those programs wouldn't work on nt5, for example... (This used to be commit 8ce93b80d3b4e1c1e28aa1dde38cdef184eff3c1) --- source3/rpc_server/srv_lsa_hnd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index b32b3322b3..add040aa3d 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -411,8 +411,14 @@ BOOL get_policy_cli_state(const POLICY_HND *hnd, struct cli_state **cli, { DEBUG(3,("Getting cli state pnum=%x\n", p->pnum)); - (*cli ) = p->dev.cli->cli; - (*fnum) = p->dev.cli->fnum; + if (cli != NULL) + { + (*cli ) = p->dev.cli->cli; + } + if (fnum != NULL) + { + (*fnum) = p->dev.cli->fnum; + } return True; } -- cgit From 3fc5ec73be6009d50ec1e8e83505572ad16c1943 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sat, 27 Nov 1999 21:50:11 +0000 Subject: further abstraction involving client states. main client-side code is pretty much independent of SMB client states, which will make it easier to add other transports. (This used to be commit a1ff7e8fc3129ba4a04722f977bc2d3725d13624) --- source3/rpc_server/srv_lsa_hnd.c | 52 +++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index add040aa3d..b895fb31c0 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -50,11 +50,10 @@ struct samr_info uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ }; -struct cli_info +struct con_info { - struct cli_state *cli; - uint16 fnum; - void (*free)(struct cli_state*, uint16 fnum); + struct cli_connection *con; + void (*free)(struct cli_connection*); }; static struct policy @@ -68,7 +67,7 @@ static struct policy union { struct samr_info *samr; struct reg_info *reg; - struct cli_info *cli; + struct con_info *con; } dev; @@ -368,56 +367,50 @@ BOOL get_policy_reg_name(POLICY_HND *hnd, fstring name) } /**************************************************************************** - set cli state + set con state ****************************************************************************/ -BOOL set_policy_cli_state(POLICY_HND *hnd, struct cli_state *cli, uint16 fnum, - void (*free_fn)(struct cli_state *, uint16)) +BOOL set_policy_con(POLICY_HND *hnd, struct cli_connection *con, + void (*free_fn)(struct cli_connection *)) { struct policy *p = find_policy(hnd); if (p && p->open) { - DEBUG(3,("Setting policy cli state pnum=%x\n", p->pnum)); + DEBUG(3,("Setting policy con state pnum=%x\n", p->pnum)); - if (p->dev.cli == NULL) + if (p->dev.con == NULL) { p->type = POL_CLI_INFO; - p->dev.cli = (struct cli_info*)malloc(sizeof(*p->dev.cli)); + p->dev.con = (struct con_info*)malloc(sizeof(*p->dev.con)); } - if (p->dev.cli == NULL) + if (p->dev.con == NULL) { return False; } - p->dev.cli->cli = cli; - p->dev.cli->free = free_fn; - p->dev.cli->fnum = fnum; + p->dev.con->con = con; + p->dev.con->free = free_fn; return True; } - DEBUG(3,("Error setting policy cli state\n")); + DEBUG(3,("Error setting policy con state\n")); return False; } /**************************************************************************** - get cli state + get con state ****************************************************************************/ -BOOL get_policy_cli_state(const POLICY_HND *hnd, struct cli_state **cli, - uint16 *fnum) +BOOL get_policy_con(const POLICY_HND *hnd, struct cli_connection **con) { struct policy *p = find_policy(hnd); if (p != NULL && p->open) { - DEBUG(3,("Getting cli state pnum=%x\n", p->pnum)); + DEBUG(3,("Getting con state pnum=%x\n", p->pnum)); - if (cli != NULL) + if (con != NULL) { - (*cli ) = p->dev.cli->cli; - } - if (fnum != NULL) - { - (*fnum) = p->dev.cli->fnum; + (*con ) = p->dev.con->con; } return True; @@ -463,12 +456,11 @@ BOOL close_policy_hnd(POLICY_HND *hnd) } case POL_CLI_INFO: { - if (p->dev.cli->free != NULL) + if (p->dev.con->free != NULL) { - p->dev.cli->free(p->dev.cli->cli, - p->dev.cli->fnum); + p->dev.con->free(p->dev.con->con); } - free(p->dev.cli); + free(p->dev.con); break; } } -- cgit From 0d44ff9a765f2e89be8b0ee99ec7c907e7c225c3 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 29 Nov 1999 21:47:14 +0000 Subject: attempting to resolve the issue that multiple servers often specified in parameters to connect to \PIPE\NETLOGON. (This used to be commit d1986ade30bdcac1f49707221a3e5a5ae597ce62) --- source3/rpc_server/srv_spoolss.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 1f9d8a19d5..a3760587cd 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -50,7 +50,7 @@ static struct uint32 document_lastwritten; pstring document_name; pstring job_name; - PRINTER_HND printer_hnd; + POLICY_HND printer_hnd; BOOL printer_type; union { @@ -82,7 +82,7 @@ void init_printer_hnd(void) /**************************************************************************** create a unique printer handle ****************************************************************************/ -static void create_printer_hnd(PRINTER_HND *hnd) +static void create_printer_hnd(POLICY_HND *hnd) { static uint32 prt_hnd_low = 0; static uint32 prt_hnd_high = 0; @@ -103,15 +103,15 @@ static void create_printer_hnd(PRINTER_HND *hnd) /**************************************************************************** clear an handle ****************************************************************************/ -static void clear_handle(PRINTER_HND *hnd) +static void clear_handle(POLICY_HND *hnd) { - bzero(hnd->data, PRINTER_HND_SIZE); + bzero(hnd->data, POLICY_HND_SIZE); } /**************************************************************************** find first available printer slot. creates a printer handle for you. ****************************************************************************/ -static BOOL open_printer_hnd(PRINTER_HND *hnd) +static BOOL open_printer_hnd(POLICY_HND *hnd) { int i; @@ -135,7 +135,7 @@ static BOOL open_printer_hnd(PRINTER_HND *hnd) /**************************************************************************** find printer index by handle ****************************************************************************/ -static int find_printer_index_by_hnd(PRINTER_HND *hnd) +static int find_printer_index_by_hnd(POLICY_HND *hnd) { int i; @@ -156,7 +156,7 @@ static int find_printer_index_by_hnd(PRINTER_HND *hnd) /**************************************************************************** set printer handle type. ****************************************************************************/ -static BOOL set_printer_hnd_accesstype(PRINTER_HND *hnd, uint32 access_required) +static BOOL set_printer_hnd_accesstype(POLICY_HND *hnd, uint32 access_required) { int pnum = find_printer_index_by_hnd(hnd); @@ -182,7 +182,7 @@ static BOOL set_printer_hnd_accesstype(PRINTER_HND *hnd, uint32 access_required) /**************************************************************************** set printer handle type. ****************************************************************************/ -static BOOL set_printer_hnd_printertype(PRINTER_HND *hnd, char *printername) +static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername) { int pnum = find_printer_index_by_hnd(hnd); @@ -225,7 +225,7 @@ static BOOL set_printer_hnd_printertype(PRINTER_HND *hnd, char *printername) /**************************************************************************** set printer handle printername. ****************************************************************************/ -static BOOL set_printer_hnd_printername(PRINTER_HND *hnd, char *printername) +static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) { int pnum = find_printer_index_by_hnd(hnd); char *back; @@ -301,7 +301,7 @@ static BOOL set_printer_hnd_printername(PRINTER_HND *hnd, char *printername) /**************************************************************************** return the snum of a printer corresponding to an handle ****************************************************************************/ -static BOOL get_printer_snum(PRINTER_HND *hnd, int *number) +static BOOL get_printer_snum(POLICY_HND *hnd, int *number) { int snum; int pnum = find_printer_index_by_hnd(hnd); @@ -350,7 +350,7 @@ static BOOL get_printer_snum(PRINTER_HND *hnd, int *number) /******************************************************************** ********************************************************************/ -static BOOL handle_is_printserver(PRINTER_HND *handle) +static BOOL handle_is_printserver(POLICY_HND *handle) { int pnum=find_printer_index_by_hnd(handle); @@ -372,7 +372,7 @@ static BOOL handle_is_printserver(PRINTER_HND *handle) /******************************************************************** ********************************************************************/ /* -static BOOL handle_is_printer(PRINTER_HND *handle) +static BOOL handle_is_printer(POLICY_HND *handle) { return (!handle_is_printserver(handle)); } @@ -538,7 +538,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 size, uint32 *ty /******************************************************************** ********************************************************************/ -static BOOL getprinterdata_printer(PRINTER_HND *handle, fstring value, uint32 size, uint32 *type, +static BOOL getprinterdata_printer(POLICY_HND *handle, fstring value, uint32 size, uint32 *type, uint32 *numeric_data, uint8 **data, uint32 *needed ) { NT_PRINTER_INFO_LEVEL printer; @@ -1315,7 +1315,7 @@ static void construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I * fill a notify_info struct with info asked * ********************************************************************/ -static void printserver_notify_info(PRINTER_HND *hnd, SPOOL_NOTIFY_INFO *info, connection_struct *conn) +static void printserver_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, connection_struct *conn) { int snum; int pnum=find_printer_index_by_hnd(hnd); @@ -1348,7 +1348,7 @@ static void printserver_notify_info(PRINTER_HND *hnd, SPOOL_NOTIFY_INFO *info, c * fill a notify_info struct with info asked * ********************************************************************/ -static void printer_notify_info(PRINTER_HND *hnd, SPOOL_NOTIFY_INFO *info, connection_struct *conn) +static void printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, connection_struct *conn) { int snum; int pnum=find_printer_index_by_hnd(hnd); @@ -2458,7 +2458,7 @@ static void api_spoolss_writeprinter(pipes_struct *p, prs_struct *data, * called from the spoolss dispatcher * ********************************************************************/ -static void control_printer(PRINTER_HND handle, uint32 command, connection_struct *conn) +static void control_printer(POLICY_HND handle, uint32 command, connection_struct *conn) { int pnum; int snum; @@ -2489,7 +2489,7 @@ static void control_printer(PRINTER_HND handle, uint32 command, connection_struc * called by spoolss_api_setprinter * when updating a printer description ********************************************************************/ -static void update_printer(PRINTER_HND handle, uint32 level, +static void update_printer(POLICY_HND handle, uint32 level, SPOOL_PRINTER_INFO_LEVEL info, DEVICEMODE *devmode) { int pnum; -- cgit From a0ba234cf9b40adf6b5390e4e67730163a42883f Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 6 Dec 1999 00:44:32 +0000 Subject: the first independent msrpc daemon - lsarpcd. one horrible cut / paste job from smbd, plus a code split of shared components between the two. the job is not _yet_ complete, as i need to be able to do a become_user() call for security reasons. i picked lsarpcd first because you don't _need_ security on it (microsoft botched so badly on this one, it's not real. at least they fixed this in nt5 with restrictanonymous=0x2). fixing this involves sending the current smb and unix credentials down the unix pipe so that the daemon it eventually goes to can pick them up at the other end. i can't believe this all worked!!! (This used to be commit 2245b0c6d13c7c5886e81f9137b05df883598c26) --- source3/rpc_server/srv_pipe.c | 120 +++++++++++++++++++++++++++++++++----- source3/rpc_server/srv_pipe_hnd.c | 25 ++++++++ 2 files changed, 132 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index c4664f7d7b..04fa0955ea 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -396,7 +396,69 @@ struct api_cmd BOOL (*fn) (pipes_struct *, prs_struct *); }; -static struct api_cmd api_fd_commands[] = +static struct api_cmd **api_fd_commands = NULL; +uint32 num_cmds = 0; + +static void api_cmd_free(struct api_cmd *item) +{ + if (item != NULL) + { + if (item->pipe_clnt_name != NULL) + { + free(item->pipe_clnt_name); + } + if (item->pipe_srv_name != NULL) + { + free(item->pipe_srv_name); + } + free(item); + } +} + +static struct api_cmd *api_cmd_dup(const struct api_cmd *from) +{ + struct api_cmd *copy = NULL; + if (from == NULL) + { + return NULL; + } + copy = (struct api_cmd *) malloc(sizeof(struct api_cmd)); + if (copy != NULL) + { + ZERO_STRUCTP(copy); + if (from->pipe_clnt_name != NULL) + { + copy->pipe_clnt_name = strdup(from->pipe_clnt_name ); + } + if (from->pipe_srv_name != NULL) + { + copy->pipe_srv_name = strdup(from->pipe_srv_name); + } + if (from->fn != NULL) + { + copy->fn = from->fn; + } + } + return copy; +} + +static void free_api_cmd_array(uint32 num_entries, struct api_cmd **entries) +{ + void(*fn)(void*) = (void(*)(void*))&api_cmd_free; + free_void_array(num_entries, (void**)entries, *fn); +} + +static struct api_cmd* add_api_cmd_to_array(uint32 *len, + struct api_cmd ***array, + const struct api_cmd *name) +{ + void*(*fn)(const void*) = (void*(*)(const void*))&api_cmd_dup; + return (struct api_cmd*)add_copy_to_array(len, + (void***)array, (const void*)name, *fn, False); + +} + +#if 0 { { "lsarpc", "lsass", api_ntlsa_rpc }, { "samr", "lsass", api_samr_rpc }, @@ -409,6 +471,20 @@ static struct api_cmd api_fd_commands[] = { "spoolss", "spoolss", api_spoolss_rpc }, { NULL, NULL, NULL } }; +#endif + +void close_msrpc_command_processor(void) +{ + free_api_cmd_array(num_cmds, api_fd_commands); +} + +void add_msrpc_command_processor(char* pipe_name, + char* process_name, + BOOL (*fn) (pipes_struct *, prs_struct *)) +{ + struct api_cmd cmd = { pipe_name, process_name, fn }; + add_api_cmd_to_array(&num_cmds, &api_fd_commands, &cmd); +} static BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *pd) { @@ -479,20 +555,20 @@ static BOOL api_pipe_bind_and_alt_req(pipes_struct *p, prs_struct *pd, enum RPC_ DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); - for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) + for (i = 0; i < num_cmds; i++) { - if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && - api_fd_commands[i].fn != NULL) + if (strequal(api_fd_commands[i]->pipe_clnt_name, p->name) && + api_fd_commands[i]->fn != NULL) { DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", - api_fd_commands[i].pipe_clnt_name, - api_fd_commands[i].pipe_srv_name)); - fstrcpy(p->pipe_srv_name, api_fd_commands[i].pipe_srv_name); + api_fd_commands[i]->pipe_clnt_name, + api_fd_commands[i]->pipe_srv_name)); + fstrcpy(p->pipe_srv_name, api_fd_commands[i]->pipe_srv_name); break; } } - if (api_fd_commands[i].fn == NULL) return False; + if (api_fd_commands[i]->fn == NULL) return False; /* decode the bind request */ smb_io_rpc_hdr_rb("", &p->hdr_rb, pd, 0); @@ -727,13 +803,13 @@ static BOOL api_pipe_request(pipes_struct *p, prs_struct *pd) #endif } - for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) + for (i = 0; i < num_cmds; i++) { - if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && - api_fd_commands[i].fn != NULL) + if (strequal(api_fd_commands[i]->pipe_clnt_name, p->name) && + api_fd_commands[i]->fn != NULL) { - DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i].pipe_clnt_name)); - return api_fd_commands[i].fn(p, pd); + DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i]->pipe_clnt_name)); + return api_fd_commands[i]->fn(p, pd); } } return False; @@ -744,6 +820,24 @@ BOOL rpc_command(pipes_struct *p, prs_struct *pd) BOOL reply = False; DEBUG(10,("rpc_command\n")); + if (p->m != NULL) + { + DEBUG(10,("msrpc redirect\n")); + if (!msrpc_send_prs(p->m, pd)) + { + DEBUG(2,("msrpc redirect send failed\n")); + return False; + } + if (!msrpc_receive_prs(p->m, &p->rhdr)) + { + DEBUG(2,("msrpc redirect receive failed\n")); + return False; + } + prs_link(NULL, &p->rhdr, NULL); + prs_debug_out(&p->rhdr, 10); + return True; + } + if (pd->data == NULL) return False; /* process the rpc header */ diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index bd712a1702..a7e451e6da 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -83,6 +83,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, int i; pipes_struct *p; static int next_pipe; + struct msrpc_state *m = NULL; DEBUG(4,("Open pipe requested %s (pipes_open=%d)\n", pipe_name, pipes_open)); @@ -108,6 +109,16 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, DEBUG(5,("open pipes: name %s pnum=%x\n", p->name, p->pnum)); } + if (strequal(pipe_name, "lsarpc")) + { + m = msrpc_use_add(pipe_name, NULL, False); + if (m == NULL) + { + DEBUG(5,("open pipes: msrpc redirect failed\n")); + return NULL; + } + } + p = (pipes_struct *)malloc(sizeof(*p)); if (!p) return NULL; @@ -120,6 +131,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, pipes_open++; p->pnum = i; + p->m = m; p->open = True; p->device_state = 0; @@ -359,6 +371,19 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) DLIST_REMOVE(Pipes, p); + if (p->m != NULL) + { + DEBUG(4,("closed msrpc redirect: ")); + if (msrpc_use_del(p->m->pipe_name, &p->m->usr, False, NULL)) + { + DEBUG(4,("OK\n")); + } + else + { + DEBUG(4,("FAILED\n")); + } + } + ZERO_STRUCTP(p); free(p); -- cgit From 4ab9d91428b66bd2fe407b0dba94f4130160b576 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 8 Dec 1999 21:43:03 +0000 Subject: ABOUT TIME!!!!!!!! damn, this one is bad. started, at least two days ago, to add an authentication mechanism to the smbd<->msrpc redirector/relay, such that sufficient unix / nt information could be transferred across the unix socket to do a become_user() on the other side of the socket. it is necessary that the msrpc daemon inherit the same unix and nt credentials as the smbd process from which it was spawned, until such time as the msrpc daemon receives an authentication request of its own, whereupon the msrpc daemon is responsible for authenticating the new credentials and doing yet another become_user() etc sequence. (This used to be commit 30c7fdd6ef10ecd35594311c1b250b95ff895489) --- source3/rpc_server/srv_pipe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 04fa0955ea..ca87cafcf7 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -482,7 +482,11 @@ void add_msrpc_command_processor(char* pipe_name, char* process_name, BOOL (*fn) (pipes_struct *, prs_struct *)) { - struct api_cmd cmd = { pipe_name, process_name, fn }; + struct api_cmd cmd; + cmd.pipe_clnt_name = pipe_name; + cmd.pipe_srv_name = process_name; + cmd.fn = fn; + add_api_cmd_to_array(&num_cmds, &api_fd_commands, &cmd); } -- cgit From 0ce128e3550794d4dbbd1def00e87c020f72c992 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 12 Dec 1999 01:25:49 +0000 Subject: delineation between smb and msrpc more marked. smbd now constructs pdus, and then feeds them over either a "local" function call or a "remote" function call to an msrpc service. the "remote" msrpc daemon, on the other side of a unix socket, then calls the same "local" function that smbd would, if the msrpc service were being run from inside smbd. this allows a transition from local msrpc services (inside the same smbd process) to remote (over a unix socket). removed reference to pipes_struct in msrpc services. all msrpc processing functions take rpcsrv_struct which is a structure containing state info for the msrpc functions to decode and create pdus. created become_vuser() which does everything not related to connection_struct that become_user() does. removed, as best i could, connection_struct dependencies from the nt spoolss printing code. todo: remove dcinfo from rpcsrv_struct because this stores NETLOGON-specific info on a per-connection basis, and if the connection dies then so does the info, and that's a fairly serious problem. had to put pretty much everything that is in user_struct into parse_creds.c to feed unix user info over to the msrpc daemons. why? because it's expensive to do unix password/group database lookups, and it's definitely expensive to do nt user profile lookups, not to mention pretty difficult and if you did either of these it would introduce a complication / unnecessary interdependency. so, send uid/gid/num_groups/gid_t* + SID+num_rids+domain_group_rids* + unix username + nt username + nt domain + user session key etc. this is the MINIMUM info identified so far that's actually implemented. missing bits include the called and calling netbios names etc. (basically, anything that can be loaded into standard_sub() and standard_sub_basic()...) (This used to be commit aa3c659a8dba0437c17c60055a6ed30fdfecdb6d) --- source3/rpc_server/srv_brs.c | 4 +- source3/rpc_server/srv_lsa.c | 20 +- source3/rpc_server/srv_netlog.c | 136 +++----- source3/rpc_server/srv_pipe.c | 703 +++++++++++++++++++++++--------------- source3/rpc_server/srv_pipe_hnd.c | 111 +++--- source3/rpc_server/srv_reg.c | 10 +- source3/rpc_server/srv_samr.c | 86 +++-- source3/rpc_server/srv_spoolss.c | 236 ++++++------- source3/rpc_server/srv_srvsvc.c | 14 +- source3/rpc_server/srv_svcctl.c | 14 +- source3/rpc_server/srv_wkssvc.c | 4 +- 11 files changed, 739 insertions(+), 599 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_brs.c b/source3/rpc_server/srv_brs.c index c2abd28cf8..cde5a79beb 100644 --- a/source3/rpc_server/srv_brs.c +++ b/source3/rpc_server/srv_brs.c @@ -66,7 +66,7 @@ static void brs_reply_query_info(BRS_Q_QUERY_INFO *q_u, /******************************************************************* api_brs_query_info ********************************************************************/ -static void api_brs_query_info( pipes_struct *p, prs_struct *data, +static void api_brs_query_info( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { BRS_Q_QUERY_INFO q_u; @@ -91,7 +91,7 @@ struct api_struct api_brs_cmds[] = /******************************************************************* receives a browser pipe and responds. ********************************************************************/ -BOOL api_brs_rpc(pipes_struct *p, prs_struct *data) +BOOL api_brs_rpc(rpcsrv_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_brssvc_rpc", api_brs_cmds, data); } diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 9b6a98e9a6..fbe83b02c8 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -140,7 +140,7 @@ static void lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, { /* set up the LSA QUERY INFO response */ - r_q.undoc_buffer = 0x1; /* bizarre */ + r_q.undoc_buffer = 0x1; r_q.info_class = q_q->info_class; make_dom_query(&r_q.dom.id5, dom_name, dom_sid); @@ -448,7 +448,7 @@ static void lsa_reply_lookup_names(prs_struct *rdata, /*************************************************************************** api_lsa_open_policy ***************************************************************************/ -static void api_lsa_open_policy2( pipes_struct *p, prs_struct *data, +static void api_lsa_open_policy2( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { LSA_Q_OPEN_POL2 q_o; @@ -467,7 +467,7 @@ static void api_lsa_open_policy2( pipes_struct *p, prs_struct *data, /*************************************************************************** api_lsa_open_policy ***************************************************************************/ -static void api_lsa_open_policy( pipes_struct *p, prs_struct *data, +static void api_lsa_open_policy( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { LSA_Q_OPEN_POL q_o; @@ -486,7 +486,7 @@ static void api_lsa_open_policy( pipes_struct *p, prs_struct *data, /*************************************************************************** api_lsa_enum_trust_dom ***************************************************************************/ -static void api_lsa_enum_trust_dom( pipes_struct *p, prs_struct *data, +static void api_lsa_enum_trust_dom( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { LSA_Q_ENUM_TRUST_DOM q_e; @@ -503,7 +503,7 @@ static void api_lsa_enum_trust_dom( pipes_struct *p, prs_struct *data, /*************************************************************************** api_lsa_query_info ***************************************************************************/ -static void api_lsa_query_info( pipes_struct *p, prs_struct *data, +static void api_lsa_query_info( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { LSA_Q_QUERY_INFO q_i; @@ -545,7 +545,7 @@ static void api_lsa_query_info( pipes_struct *p, prs_struct *data, /*************************************************************************** api_lsa_lookup_sids ***************************************************************************/ -static void api_lsa_lookup_sids( pipes_struct *p, prs_struct *data, +static void api_lsa_lookup_sids( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { LSA_Q_LOOKUP_SIDS q_l; @@ -561,7 +561,7 @@ static void api_lsa_lookup_sids( pipes_struct *p, prs_struct *data, /*************************************************************************** api_lsa_lookup_names ***************************************************************************/ -static void api_lsa_lookup_names( pipes_struct *p, prs_struct *data, +static void api_lsa_lookup_names( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { LSA_Q_LOOKUP_NAMES q_l; @@ -578,7 +578,7 @@ static void api_lsa_lookup_names( pipes_struct *p, prs_struct *data, /*************************************************************************** api_lsa_close ***************************************************************************/ -static void api_lsa_close( pipes_struct *p, prs_struct *data, +static void api_lsa_close( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { LSA_R_CLOSE r_c; @@ -607,7 +607,7 @@ static void api_lsa_close( pipes_struct *p, prs_struct *data, /*************************************************************************** api_lsa_open_secret ***************************************************************************/ -static void api_lsa_open_secret( pipes_struct *p, prs_struct *data, +static void api_lsa_open_secret( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { /* XXXX this is NOT good */ @@ -648,7 +648,7 @@ static struct api_struct api_lsa_cmds[] = /*************************************************************************** api_ntLsarpcTNP ***************************************************************************/ -BOOL api_ntlsa_rpc(pipes_struct *p, prs_struct *data) +BOOL api_ntlsa_rpc(rpcsrv_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds, data); } diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index f8d7fe5718..22788508eb 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -341,7 +341,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) /************************************************************************* api_net_req_chal: *************************************************************************/ -static void api_net_req_chal( pipes_struct *p, +static void api_net_req_chal( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { @@ -351,12 +351,7 @@ static void api_net_req_chal( pipes_struct *p, fstring mach_acct; fstring mach_name; - user_struct *vuser; - - DEBUG(5,("api_net_req_chal(%d): vuid %d\n", __LINE__, (int)p->vuid)); - - if ((vuser = get_valid_user_struct(p->vuid)) == NULL) - return; + DEBUG(5,("api_net_req_chal(%d)\n", __LINE__)); /* grab the challenge... */ net_io_q_req_chal("", &q_r, data, 0); @@ -368,23 +363,23 @@ static void api_net_req_chal( pipes_struct *p, fstrcat(mach_acct, "$"); - if (get_md4pw((char *)vuser->dc.md4pw, mach_name, mach_acct)) + if (get_md4pw((char *)p->dc.md4pw, mach_name, mach_acct)) { /* copy the client credentials */ - memcpy(vuser->dc.clnt_chal.data , q_r.clnt_chal.data, sizeof(q_r.clnt_chal.data)); - memcpy(vuser->dc.clnt_cred.challenge.data, q_r.clnt_chal.data, sizeof(q_r.clnt_chal.data)); + memcpy(p->dc.clnt_chal.data , q_r.clnt_chal.data, sizeof(q_r.clnt_chal.data)); + memcpy(p->dc.clnt_cred.challenge.data, q_r.clnt_chal.data, sizeof(q_r.clnt_chal.data)); /* create a server challenge for the client */ /* Set these to random values. */ - generate_random_buffer(vuser->dc.srv_chal.data, 8, False); + generate_random_buffer(p->dc.srv_chal.data, 8, False); - memcpy(vuser->dc.srv_cred.challenge.data, vuser->dc.srv_chal.data, 8); + memcpy(p->dc.srv_cred.challenge.data, p->dc.srv_chal.data, 8); - bzero(vuser->dc.sess_key, sizeof(vuser->dc.sess_key)); + bzero(p->dc.sess_key, sizeof(p->dc.sess_key)); /* from client / server challenges and md4 password, generate sess key */ - cred_session_key(&(vuser->dc.clnt_chal), &(vuser->dc.srv_chal), - (char *)vuser->dc.md4pw, vuser->dc.sess_key); + cred_session_key(&(p->dc.clnt_chal), &(p->dc.srv_chal), + (char *)p->dc.md4pw, p->dc.sess_key); } else { @@ -394,14 +389,14 @@ static void api_net_req_chal( pipes_struct *p, /* construct reply. */ net_reply_req_chal(&q_r, rdata, - &(vuser->dc.srv_chal), status); + &(p->dc.srv_chal), status); } /************************************************************************* api_net_auth: *************************************************************************/ -static void api_net_auth( pipes_struct *p, +static void api_net_auth( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { @@ -411,27 +406,22 @@ static void api_net_auth( pipes_struct *p, DOM_CHAL srv_cred; UTIME srv_time; - user_struct *vuser; - - if ((vuser = get_valid_user_struct(p->vuid)) == NULL) - return; - srv_time.time = 0; /* grab the challenge... */ net_io_q_auth("", &q_a, data, 0); /* check that the client credentials are valid */ - if (cred_assert(&(q_a.clnt_chal), vuser->dc.sess_key, - &(vuser->dc.clnt_cred.challenge), srv_time)) + if (cred_assert(&(q_a.clnt_chal), p->dc.sess_key, + &(p->dc.clnt_cred.challenge), srv_time)) { /* create server challenge for inclusion in the reply */ - cred_create(vuser->dc.sess_key, &(vuser->dc.srv_cred.challenge), srv_time, &srv_cred); + cred_create(p->dc.sess_key, &(p->dc.srv_cred.challenge), srv_time, &srv_cred); /* copy the received client credentials for use next time */ - memcpy(vuser->dc.clnt_cred.challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); - memcpy(vuser->dc.srv_cred .challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); + memcpy(p->dc.clnt_cred.challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); + memcpy(p->dc.srv_cred .challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); } else { @@ -445,7 +435,7 @@ static void api_net_auth( pipes_struct *p, /************************************************************************* api_net_auth_2: *************************************************************************/ -static void api_net_auth_2( pipes_struct *p, +static void api_net_auth_2( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { @@ -455,27 +445,22 @@ static void api_net_auth_2( pipes_struct *p, DOM_CHAL srv_cred; UTIME srv_time; - user_struct *vuser; - - if ((vuser = get_valid_user_struct(p->vuid)) == NULL) - return; - srv_time.time = 0; /* grab the challenge... */ net_io_q_auth_2("", &q_a, data, 0); /* check that the client credentials are valid */ - if (cred_assert(&(q_a.clnt_chal), vuser->dc.sess_key, - &(vuser->dc.clnt_cred.challenge), srv_time)) + if (cred_assert(&(q_a.clnt_chal), p->dc.sess_key, + &(p->dc.clnt_cred.challenge), srv_time)) { /* create server challenge for inclusion in the reply */ - cred_create(vuser->dc.sess_key, &(vuser->dc.srv_cred.challenge), srv_time, &srv_cred); + cred_create(p->dc.sess_key, &(p->dc.srv_cred.challenge), srv_time, &srv_cred); /* copy the received client credentials for use next time */ - memcpy(vuser->dc.clnt_cred.challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); - memcpy(vuser->dc.srv_cred .challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); + memcpy(p->dc.clnt_cred.challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); + memcpy(p->dc.srv_cred .challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); } else { @@ -489,7 +474,7 @@ static void api_net_auth_2( pipes_struct *p, /************************************************************************* api_net_srv_pwset: *************************************************************************/ -static void api_net_srv_pwset( pipes_struct *p, +static void api_net_srv_pwset( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { @@ -499,19 +484,15 @@ static void api_net_srv_pwset( pipes_struct *p, pstring mach_acct; struct smb_passwd *smb_pass; BOOL ret; - user_struct *vuser; - - if ((vuser = get_valid_user_struct(p->vuid)) == NULL) - return; /* grab the challenge and encrypted password ... */ net_io_q_srv_pwset("", &q_a, data, 0); /* checks and updates credentials. creates reply credentials */ - if (deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), + if (deal_with_creds(p->dc.sess_key, &(p->dc.clnt_cred), &(q_a.clnt_id.cred), &srv_cred)) { - memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); + memcpy(&(p->dc.srv_cred), &(p->dc.clnt_cred), sizeof(p->dc.clnt_cred)); DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); @@ -536,7 +517,7 @@ static void api_net_srv_pwset( pipes_struct *p, } DEBUG(100,("\n")); - cred_hash3( pwd, q_a.pwd, vuser->dc.sess_key, 0); + cred_hash3( pwd, q_a.pwd, p->dc.sess_key, 0); /* lies! nt and lm passwords are _not_ the same: don't care */ smb_pass->smb_passwd = pwd; @@ -571,7 +552,7 @@ static void api_net_srv_pwset( pipes_struct *p, /************************************************************************* api_net_sam_logoff: *************************************************************************/ -static void api_net_sam_logoff( pipes_struct *p, +static void api_net_sam_logoff( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { @@ -580,11 +561,6 @@ static void api_net_sam_logoff( pipes_struct *p, DOM_CRED srv_cred; - user_struct *vuser; - - if ((vuser = get_valid_user_struct(p->vuid)) == NULL) - return; - /* the DOM_ID_INFO_1 structure is a bit big. plus we might want to dynamically allocate it inside net_io_q_sam_logon, at some point */ q_l.sam_id.ctr = &ctr; @@ -593,9 +569,9 @@ static void api_net_sam_logoff( pipes_struct *p, net_io_q_sam_logoff("", &q_l, data, 0); /* checks and updates credentials. creates reply credentials */ - deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), + deal_with_creds(p->dc.sess_key, &(p->dc.clnt_cred), &(q_l.sam_id.client.cred), &srv_cred); - memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); + memcpy(&(p->dc.srv_cred), &(p->dc.clnt_cred), sizeof(p->dc.clnt_cred)); /* construct reply. always indicate success */ net_reply_sam_logoff(&q_l, rdata, &srv_cred, 0x0); @@ -604,27 +580,23 @@ static void api_net_sam_logoff( pipes_struct *p, /************************************************************************* api_net_sam_sync: *************************************************************************/ -static void api_net_sam_sync( pipes_struct *p, +static void api_net_sam_sync( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { NET_Q_SAM_SYNC q_s; DOM_CRED srv_creds; - user_struct *vuser; uint32 status = 0x0; - if ((vuser = get_valid_user_struct(p->vuid)) == NULL) - return; - /* grab the challenge... */ net_io_q_sam_sync("", &q_s, data, 0); /* checks and updates credentials. creates reply credentials */ - if (deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), + if (deal_with_creds(p->dc.sess_key, &(p->dc.clnt_cred), &(q_s.cli_creds), &srv_creds)) { - memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), - sizeof(vuser->dc.clnt_cred)); + memcpy(&(p->dc.srv_cred), &(p->dc.clnt_cred), + sizeof(p->dc.clnt_cred)); } else { @@ -632,7 +604,7 @@ static void api_net_sam_sync( pipes_struct *p, } /* construct reply. */ - net_reply_sam_sync(&q_s, rdata, vuser->dc.sess_key, &srv_creds, status); + net_reply_sam_sync(&q_s, rdata, p->dc.sess_key, &srv_creds, status); } @@ -641,7 +613,7 @@ static void api_net_sam_sync( pipes_struct *p, *************************************************************************/ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, struct sam_passwd *smb_pass, - user_struct *vuser) + struct dcinfo *dc) { uint32 status = 0x0; @@ -650,7 +622,7 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, unsigned char key[16]; memset(key, 0, 16); - memcpy(key, vuser->dc.sess_key, 8); + memcpy(key, dc->sess_key, 8); memcpy(lm_pwd, id1->lm_owf.data, 16); memcpy(nt_pwd, id1->nt_owf.data, 16); @@ -698,7 +670,7 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, *************************************************************************/ static uint32 net_login_network(NET_ID_INFO_2 *id2, struct sam_passwd *sam_pass, - user_struct *vuser, + struct dcinfo *dc, char sess_key[16]) { fstring user; @@ -723,7 +695,7 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, unsigned char key[16]; memset(key, 0, 16); - memcpy(key, vuser->dc.sess_key, 8); + memcpy(key, dc->sess_key, 8); #ifdef DEBUG_PASSWORD DEBUG(100,("key:")); @@ -749,8 +721,9 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, /************************************************************************* api_net_sam_logon: *************************************************************************/ -static uint32 reply_net_sam_logon( NET_Q_SAM_LOGON *q_l, user_struct *vuser, - DOM_CRED *srv_cred, NET_USER_INFO_3 *usr_info) +static uint32 reply_net_sam_logon(NET_Q_SAM_LOGON *q_l, + struct dcinfo *dc, + DOM_CRED *srv_cred, NET_USER_INFO_3 *usr_info) { struct sam_passwd *sam_pass = NULL; UNISTR2 *uni_samusr = NULL; @@ -781,13 +754,13 @@ static uint32 reply_net_sam_logon( NET_Q_SAM_LOGON *q_l, user_struct *vuser, DOM_GID *gids = NULL; /* checks and updates credentials. creates reply credentials */ - if (!deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), + if (!deal_with_creds(dc->sess_key, &(dc->clnt_cred), &(q_l->sam_id.client.cred), srv_cred)) { return 0xC0000000 | NT_STATUS_INVALID_HANDLE; } - memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); + memcpy(&(dc->srv_cred), &(dc->clnt_cred), sizeof(dc->clnt_cred)); /* find the username */ @@ -864,13 +837,13 @@ static uint32 reply_net_sam_logon( NET_Q_SAM_LOGON *q_l, user_struct *vuser, case INTERACTIVE_LOGON_TYPE: { /* interactive login. */ - status = net_login_interactive(&q_l->sam_id.ctr->auth.id1, sam_pass, vuser); + status = net_login_interactive(&q_l->sam_id.ctr->auth.id1, sam_pass, dc); break; } case NET_LOGON_TYPE: { /* network login. lm challenge and 24 byte responses */ - status = net_login_network(&q_l->sam_id.ctr->auth.id2, sam_pass, vuser, sess_key); + status = net_login_network(&q_l->sam_id.ctr->auth.id2, sam_pass, dc, sess_key); enc_user_sess_key = sess_key; break; } @@ -941,7 +914,7 @@ static uint32 reply_net_sam_logon( NET_Q_SAM_LOGON *q_l, user_struct *vuser, /************************************************************************* api_net_sam_logon: *************************************************************************/ -static void api_net_sam_logon( pipes_struct *p, +static void api_net_sam_logon( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { @@ -951,17 +924,10 @@ static void api_net_sam_logon( pipes_struct *p, uint32 status = 0x0; DOM_CRED srv_cred; - user_struct *vuser = get_valid_user_struct(p->vuid); - - if (vuser == NULL) - { - return; - } - q_l.sam_id.ctr = &ctr; net_io_q_sam_logon("", &q_l, data, 0); - status = reply_net_sam_logon(&q_l, vuser, &srv_cred, &usr_info); + status = reply_net_sam_logon(&q_l, &p->dc, &srv_cred, &usr_info); net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status); } @@ -969,7 +935,7 @@ static void api_net_sam_logon( pipes_struct *p, /************************************************************************* api_net_trust_dom_list: *************************************************************************/ -static void api_net_trust_dom_list( pipes_struct *p, +static void api_net_trust_dom_list( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { @@ -1003,7 +969,7 @@ static void api_net_trust_dom_list( pipes_struct *p, /************************************************************************* api_net_logon_ctrl2: *************************************************************************/ -static void api_net_logon_ctrl2( pipes_struct *p, +static void api_net_logon_ctrl2( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { @@ -1049,7 +1015,7 @@ static struct api_struct api_net_cmds [] = /******************************************************************* receives a netlogon pipe and responds. ********************************************************************/ -BOOL api_netlog_rpc(pipes_struct *p, prs_struct *data) +BOOL api_netlog_rpc(rpcsrv_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_netlog_rpc", api_net_cmds, data); } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index ca87cafcf7..73a06b208c 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -43,7 +43,7 @@ extern int DEBUGLEVEL; -static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) +static void NTLMSSPcalc_p( rpcsrv_struct *p, unsigned char *data, int len) { unsigned char *hash = p->ntlmssp_hash; unsigned char index_i = hash[256]; @@ -70,6 +70,19 @@ static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) hash[257] = index_j; } +/******************************************************************* + frees all temporary data used in construction of pdu + ********************************************************************/ +void rpcsrv_free_temp(rpcsrv_struct *l) +{ + mem_free_data(l->rhdr .data); + mem_free_data(l->rfault .data); + mem_free_data(l->rdata_i.data); + mem_free_data(l->rauth .data); + mem_free_data(l->rverf .data); + mem_free_data(l->rntlm .data); +} + /******************************************************************* turns a DCE/RPC request into a DCE/RPC reply @@ -77,21 +90,21 @@ static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) headers and data sections. ********************************************************************/ -BOOL create_rpc_reply(pipes_struct *p, - uint32 data_start, uint32 data_end) +BOOL create_rpc_reply(rpcsrv_struct *l, uint32 data_start) { char *data; - BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SIGN); - BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SEAL); + BOOL auth_verify = IS_BITS_SET_ALL(l->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SIGN); + BOOL auth_seal = IS_BITS_SET_ALL(l->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SEAL); uint32 data_len; uint32 auth_len; + uint32 data_end = l->rdata.offset + (l->ntlmssp_auth ? (8 + 16) : 0); DEBUG(5,("create_rpc_reply: data_start: %d data_end: %d max_tsize: %d\n", - data_start, data_end, p->hdr_ba.bba.max_tsize)); + data_start, data_end, l->hdr_ba.bba.max_tsize)); - auth_len = p->hdr.auth_len; + auth_len = l->hdr.auth_len; - if (p->ntlmssp_auth) + if (l->ntlmssp_auth) { DEBUG(10,("create_rpc_reply: auth\n")); if (auth_len != 16) @@ -100,63 +113,63 @@ BOOL create_rpc_reply(pipes_struct *p, } } - prs_init(&p->rhdr , 0x18, 4, 0, False); - prs_init(&p->rauth, 1024, 4, 0, False); - prs_init(&p->rverf, 0x10, 4, 0, False); + prs_init(&l->rhdr , 0x18, 4, 0, False); + prs_init(&l->rauth, 1024, 4, 0, False); + prs_init(&l->rverf, 0x10, 4, 0, False); - p->hdr.pkt_type = RPC_RESPONSE; /* mark header as an rpc response */ + l->hdr.pkt_type = RPC_RESPONSE; /* mark header as an rpc response */ /* set up rpc header (fragmentation issues) */ if (data_start == 0) { - p->hdr.flags = RPC_FLG_FIRST; + l->hdr.flags = RPC_FLG_FIRST; } else { - p->hdr.flags = 0; + l->hdr.flags = 0; } - p->hdr_resp.alloc_hint = data_end - data_start; /* calculate remaining data to be sent */ + l->hdr_resp.alloc_hint = data_end - data_start; /* calculate remaining data to be sent */ - if (p->hdr_resp.alloc_hint + 0x18 <= p->hdr_ba.bba.max_tsize) + if (l->hdr_resp.alloc_hint + 0x18 <= l->hdr_ba.bba.max_tsize) { - p->hdr.flags |= RPC_FLG_LAST; - p->hdr.frag_len = p->hdr_resp.alloc_hint + 0x18; + l->hdr.flags |= RPC_FLG_LAST; + l->hdr.frag_len = l->hdr_resp.alloc_hint + 0x18; } else { - p->hdr.frag_len = p->hdr_ba.bba.max_tsize; + l->hdr.frag_len = l->hdr_ba.bba.max_tsize; } - if (p->ntlmssp_auth) + if (l->ntlmssp_auth) { - p->hdr_resp.alloc_hint -= auth_len + 8; + l->hdr_resp.alloc_hint -= auth_len + 8; } - if (p->ntlmssp_auth) + if (l->ntlmssp_auth) { - data_len = p->hdr.frag_len - auth_len - (auth_verify ? 8 : 0) - 0x18; + data_len = l->hdr.frag_len - auth_len - (auth_verify ? 8 : 0) - 0x18; } else { - data_len = p->hdr.frag_len - 0x18; + data_len = l->hdr.frag_len - 0x18; } - p->rhdr.data->offset.start = 0; - p->rhdr.data->offset.end = 0x18; + l->rhdr.data->offset.start = 0; + l->rhdr.data->offset.end = 0x18; /* store the header in the data stream */ - smb_io_rpc_hdr ("hdr" , &(p->hdr ), &(p->rhdr), 0); - smb_io_rpc_hdr_resp("resp", &(p->hdr_resp), &(p->rhdr), 0); + smb_io_rpc_hdr ("hdr" , &(l->hdr ), &(l->rhdr), 0); + smb_io_rpc_hdr_resp("resp", &(l->hdr_resp), &(l->rhdr), 0); /* don't use rdata: use rdata_i instead, which moves... */ /* make a pointer to the rdata data, NOT A COPY */ - p->rdata_i.data = NULL; - prs_init(&p->rdata_i, 0, p->rdata.align, p->rdata.data->margin, p->rdata.io); - data = mem_data(&(p->rdata.data), data_start); - mem_create(p->rdata_i.data, data, 0, data_len, 0, False); - p->rdata_i.offset = data_len; + l->rdata_i.data = NULL; + prs_init(&l->rdata_i, 0, l->rdata.align, l->rdata.data->margin, l->rdata.io); + data = mem_data(&(l->rdata.data), data_start); + mem_create(l->rdata_i.data, data, 0, data_len, 0, False); + l->rdata_i.offset = data_len; if (auth_len > 0) { @@ -168,44 +181,44 @@ BOOL create_rpc_reply(pipes_struct *p, if (auth_seal) { crc32 = crc32_calc_buffer(data_len, data); - NTLMSSPcalc_p(p, (uchar*)data, data_len); + NTLMSSPcalc_p(l, (uchar*)data, data_len); } if (auth_seal || auth_verify) { - make_rpc_hdr_auth(&p->auth_info, 0x0a, 0x06, 0x08, (auth_verify ? 1 : 0)); - smb_io_rpc_hdr_auth("hdr_auth", &p->auth_info, &p->rauth, 0); + make_rpc_hdr_auth(&l->auth_info, 0x0a, 0x06, 0x08, (auth_verify ? 1 : 0)); + smb_io_rpc_hdr_auth("hdr_auth", &l->auth_info, &l->rauth, 0); } if (auth_verify) { char *auth_data; - p->ntlmssp_seq_num++; - make_rpc_auth_ntlmssp_chk(&p->ntlmssp_chk, NTLMSSP_SIGN_VERSION, crc32, p->ntlmssp_seq_num++); - smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(p->ntlmssp_chk), &p->rverf, 0); - auth_data = mem_data(&p->rverf.data, 4); - NTLMSSPcalc_p(p, (uchar*)auth_data, 12); + l->ntlmssp_seq_num++; + make_rpc_auth_ntlmssp_chk(&l->ntlmssp_chk, NTLMSSP_SIGN_VERSION, crc32, l->ntlmssp_seq_num++); + smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(l->ntlmssp_chk), &l->rverf, 0); + auth_data = mem_data(&l->rverf.data, 4); + NTLMSSPcalc_p(l, (uchar*)auth_data, 12); } } /* set up the data chain */ - if (p->ntlmssp_auth) + if (l->ntlmssp_auth) { - prs_link(NULL , &p->rhdr , &p->rdata_i); - prs_link(&p->rhdr , &p->rdata_i, &p->rauth ); - prs_link(&p->rdata_i, &p->rauth , &p->rverf ); - prs_link(&p->rauth , &p->rverf , NULL ); + prs_link(NULL , &l->rhdr , &l->rdata_i); + prs_link(&l->rhdr , &l->rdata_i, &l->rauth ); + prs_link(&l->rdata_i, &l->rauth , &l->rverf ); + prs_link(&l->rauth , &l->rverf , NULL ); } else { - prs_link(NULL , &p->rhdr , &p->rdata_i); - prs_link(&p->rhdr, &p->rdata_i, NULL ); + prs_link(NULL , &l->rhdr , &l->rdata_i); + prs_link(&l->rhdr, &l->rdata_i, NULL ); } - return p->rhdr.data != NULL && p->rhdr.offset == 0x18; + return l->rhdr.data != NULL && l->rhdr.offset == 0x18; } -static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) +static BOOL api_pipe_ntlmssp_verify(rpcsrv_struct *l) { uchar *pwd = NULL; uchar null_pwd[16]; @@ -220,23 +233,15 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) struct smb_passwd *smb_pass = NULL; - user_struct *vuser = get_valid_user_struct(p->vuid); - memset(null_pwd, 0, sizeof(null_pwd)); DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); - if (vuser == NULL) - { - DEBUG(0,("get user struct %d failed\n", p->vuid)); - return False; - } - - lm_owf_len = p->ntlmssp_resp.hdr_lm_resp.str_str_len; - nt_owf_len = p->ntlmssp_resp.hdr_nt_resp.str_str_len; - usr_len = p->ntlmssp_resp.hdr_usr .str_str_len; - dom_len = p->ntlmssp_resp.hdr_domain .str_str_len; - wks_len = p->ntlmssp_resp.hdr_wks .str_str_len; + lm_owf_len = l->ntlmssp_resp.hdr_lm_resp.str_str_len; + nt_owf_len = l->ntlmssp_resp.hdr_nt_resp.str_str_len; + usr_len = l->ntlmssp_resp.hdr_usr .str_str_len; + dom_len = l->ntlmssp_resp.hdr_domain .str_str_len; + wks_len = l->ntlmssp_resp.hdr_wks .str_str_len; if (lm_owf_len == 0 && nt_owf_len == 0 && usr_len == 0 && dom_len == 0 && wks_len == 0) @@ -247,65 +252,65 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) { if (lm_owf_len == 0) return False; if (nt_owf_len == 0) return False; - if (p->ntlmssp_resp.hdr_usr .str_str_len == 0) return False; - if (p->ntlmssp_resp.hdr_domain .str_str_len == 0) return False; - if (p->ntlmssp_resp.hdr_wks .str_str_len == 0) return False; + if (l->ntlmssp_resp.hdr_usr .str_str_len == 0) return False; + if (l->ntlmssp_resp.hdr_domain .str_str_len == 0) return False; + if (l->ntlmssp_resp.hdr_wks .str_str_len == 0) return False; } if (lm_owf_len > sizeof(lm_owf)) return False; if (nt_owf_len > sizeof(nt_owf)) return False; - memcpy(lm_owf, p->ntlmssp_resp.lm_resp, sizeof(lm_owf)); - memcpy(nt_owf, p->ntlmssp_resp.nt_resp, sizeof(nt_owf)); + memcpy(lm_owf, l->ntlmssp_resp.lm_resp, sizeof(lm_owf)); + memcpy(nt_owf, l->ntlmssp_resp.nt_resp, sizeof(nt_owf)); #ifdef DEBUG_PASSWORD DEBUG(100,("lm, nt owfs, chal\n")); dump_data(100, lm_owf, sizeof(lm_owf)); dump_data(100, nt_owf, sizeof(nt_owf)); - dump_data(100, p->ntlmssp_chal.challenge, 8); + dump_data(100, l->ntlmssp_chal.challenge, 8); #endif - memset(p->user_name, 0, sizeof(p->user_name)); - memset(p->domain , 0, sizeof(p->domain )); - memset(p->wks , 0, sizeof(p->wks )); + memset(l->user_name, 0, sizeof(l->user_name)); + memset(l->domain , 0, sizeof(l->domain )); + memset(l->wks , 0, sizeof(l->wks )); - if (IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_UNICODE)) + if (IS_BITS_SET_ALL(l->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_UNICODE)) { - unibuf_to_ascii(p->user_name, p->ntlmssp_resp.user, - MIN(p->ntlmssp_resp.hdr_usr .str_str_len/2, - sizeof(p->user_name)-1)); - unibuf_to_ascii(p->domain , p->ntlmssp_resp.domain, - MIN(p->ntlmssp_resp.hdr_domain.str_str_len/2, - sizeof(p->domain )-1)); - unibuf_to_ascii(p->wks , p->ntlmssp_resp.wks, - MIN(p->ntlmssp_resp.hdr_wks .str_str_len/2, - sizeof(p->wks )-1)); + unibuf_to_ascii(l->user_name, l->ntlmssp_resp.user, + MIN(l->ntlmssp_resp.hdr_usr .str_str_len/2, + sizeof(l->user_name)-1)); + unibuf_to_ascii(l->domain , l->ntlmssp_resp.domain, + MIN(l->ntlmssp_resp.hdr_domain.str_str_len/2, + sizeof(l->domain )-1)); + unibuf_to_ascii(l->wks , l->ntlmssp_resp.wks, + MIN(l->ntlmssp_resp.hdr_wks .str_str_len/2, + sizeof(l->wks )-1)); } else { - fstrcpy(p->user_name, p->ntlmssp_resp.user ); - fstrcpy(p->domain , p->ntlmssp_resp.domain); - fstrcpy(p->wks , p->ntlmssp_resp.wks ); + fstrcpy(l->user_name, l->ntlmssp_resp.user ); + fstrcpy(l->domain , l->ntlmssp_resp.domain); + fstrcpy(l->wks , l->ntlmssp_resp.wks ); } if (anonymous) { DEBUG(5,("anonymous user session\n")); - mdfour(vuser->dc.user_sess_key, null_pwd, 16); + mdfour(l->user_sess_key, null_pwd, 16); pwd = null_pwd; - p->ntlmssp_validated = True; + l->ntlmssp_validated = True; } else { - DEBUG(5,("user: %s domain: %s wks: %s\n", p->user_name, p->domain, p->wks)); + DEBUG(5,("user: %s domain: %s wks: %s\n", l->user_name, l->domain, l->wks)); become_root(True); - smb_pass = getsmbpwnam(p->user_name); - p->ntlmssp_validated = pass_check_smb(smb_pass, p->domain, - (uchar*)p->ntlmssp_chal.challenge, + smb_pass = getsmbpwnam(l->user_name); + l->ntlmssp_validated = pass_check_smb(smb_pass, l->domain, + (uchar*)l->ntlmssp_chal.challenge, lm_owf, lm_owf_len, nt_owf, nt_owf_len, - NULL, vuser->dc.user_sess_key); + NULL, l->user_sess_key); unbecome_root(True); if (smb_pass != NULL) @@ -314,7 +319,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) } } - if (p->ntlmssp_validated && pwd != NULL) + if (l->ntlmssp_validated && pwd != NULL) { uchar p24[24]; NTLMSSPOWFencrypt(pwd, lm_owf, p24); @@ -331,47 +336,47 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p) for (ind = 0; ind < 256; ind++) { - p->ntlmssp_hash[ind] = (unsigned char)ind; + l->ntlmssp_hash[ind] = (unsigned char)ind; } for( ind = 0; ind < 256; ind++) { unsigned char tc; - j += (p->ntlmssp_hash[ind] + k2[ind%8]); + j += (l->ntlmssp_hash[ind] + k2[ind%8]); - tc = p->ntlmssp_hash[ind]; - p->ntlmssp_hash[ind] = p->ntlmssp_hash[j]; - p->ntlmssp_hash[j] = tc; + tc = l->ntlmssp_hash[ind]; + l->ntlmssp_hash[ind] = l->ntlmssp_hash[j]; + l->ntlmssp_hash[j] = tc; } - p->ntlmssp_hash[256] = 0; - p->ntlmssp_hash[257] = 0; + l->ntlmssp_hash[256] = 0; + l->ntlmssp_hash[257] = 0; } - p->ntlmssp_seq_num = 0; + l->ntlmssp_seq_num = 0; } else { - p->ntlmssp_validated = False; + l->ntlmssp_validated = False; } - return p->ntlmssp_validated; + return l->ntlmssp_validated; } -static BOOL api_pipe_ntlmssp(pipes_struct *p, prs_struct *pd) +static BOOL api_pipe_ntlmssp(rpcsrv_struct *l, prs_struct *pd) { /* receive a negotiate; send a challenge; receive a response */ - switch (p->auth_verifier.msg_type) + switch (l->auth_verifier.msg_type) { case NTLMSSP_NEGOTIATE: { - smb_io_rpc_auth_ntlmssp_neg("", &p->ntlmssp_neg, pd, 0); + smb_io_rpc_auth_ntlmssp_neg("", &l->ntlmssp_neg, pd, 0); break; } case NTLMSSP_AUTH: { - smb_io_rpc_auth_ntlmssp_resp("", &p->ntlmssp_resp, pd, 0); - if (!api_pipe_ntlmssp_verify(p)) + smb_io_rpc_auth_ntlmssp_resp("", &l->ntlmssp_resp, pd, 0); + if (!api_pipe_ntlmssp_verify(l)) { pd->offset = 0; } @@ -381,7 +386,7 @@ static BOOL api_pipe_ntlmssp(pipes_struct *p, prs_struct *pd) { /* NTLMSSP expected: unexpected message type */ DEBUG(3,("unexpected message type in NTLMSSP %d\n", - p->auth_verifier.msg_type)); + l->auth_verifier.msg_type)); return False; } } @@ -393,7 +398,7 @@ struct api_cmd { char * pipe_clnt_name; char * pipe_srv_name; - BOOL (*fn) (pipes_struct *, prs_struct *); + BOOL (*fn) (rpcsrv_struct *, prs_struct *); }; static struct api_cmd **api_fd_commands = NULL; @@ -480,7 +485,7 @@ void close_msrpc_command_processor(void) void add_msrpc_command_processor(char* pipe_name, char* process_name, - BOOL (*fn) (pipes_struct *, prs_struct *)) + BOOL (*fn) (rpcsrv_struct *, prs_struct *)) { struct api_cmd cmd; cmd.pipe_clnt_name = pipe_name; @@ -490,269 +495,281 @@ void add_msrpc_command_processor(char* pipe_name, add_api_cmd_to_array(&num_cmds, &api_fd_commands, &cmd); } -static BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *pd) +static BOOL api_pipe_bind_auth_resp(rpcsrv_struct *l, prs_struct *pd) { DEBUG(5,("api_pipe_bind_auth_resp: decode request. %d\n", __LINE__)); - if (p->hdr.auth_len == 0) return False; + if (l->hdr.auth_len == 0) return False; /* decode the authentication verifier response */ - smb_io_rpc_hdr_autha("", &p->autha_info, pd, 0); + smb_io_rpc_hdr_autha("", &l->autha_info, pd, 0); if (pd->offset == 0) return False; - if (!rpc_hdr_auth_chk(&(p->auth_info))) return False; + if (!rpc_hdr_auth_chk(&(l->auth_info))) return False; - smb_io_rpc_auth_ntlmssp_verifier("", &p->auth_verifier, pd, 0); + smb_io_rpc_auth_ntlmssp_verifier("", &l->auth_verifier, pd, 0); if (pd->offset == 0) return False; - if (!rpc_auth_ntlmssp_verifier_chk(&(p->auth_verifier), "NTLMSSP", NTLMSSP_AUTH)) return False; + if (!rpc_auth_ntlmssp_verifier_chk(&(l->auth_verifier), "NTLMSSP", NTLMSSP_AUTH)) return False; - return api_pipe_ntlmssp(p, pd); + return api_pipe_ntlmssp(l, pd); } -static BOOL api_pipe_fault_resp(pipes_struct *p, prs_struct *pd, uint32 status) +static BOOL api_pipe_fault_resp(rpcsrv_struct *l, prs_struct *pd, uint32 status) { DEBUG(5,("api_pipe_fault_resp: make response\n")); - prs_init(&(p->rhdr ), 0x18, 4, 0, False); - prs_init(&(p->rfault ), 0x8 , 4, 0, False); + prs_init(&(l->rhdr ), 0x18, 4, 0, False); + prs_init(&(l->rfault ), 0x8 , 4, 0, False); /***/ /*** set up the header, response header and fault status ***/ /***/ - p->hdr_fault.status = status; - p->hdr_fault.reserved = 0x0; + l->hdr_fault.status = status; + l->hdr_fault.reserved = 0x0; - p->hdr_resp.alloc_hint = 0x0; - p->hdr_resp.cancel_count = 0x0; - p->hdr_resp.reserved = 0x0; + l->hdr_resp.alloc_hint = 0x0; + l->hdr_resp.cancel_count = 0x0; + l->hdr_resp.reserved = 0x0; - make_rpc_hdr(&p->hdr, RPC_FAULT, RPC_FLG_NOCALL | RPC_FLG_FIRST | RPC_FLG_LAST, - p->hdr.call_id, + make_rpc_hdr(&l->hdr, RPC_FAULT, RPC_FLG_NOCALL | RPC_FLG_FIRST | RPC_FLG_LAST, + l->hdr.call_id, 0x20, 0); - smb_io_rpc_hdr ("hdr" , &(p->hdr ), &(p->rhdr), 0); - smb_io_rpc_hdr_resp ("resp" , &(p->hdr_resp ), &(p->rhdr), 0); - smb_io_rpc_hdr_fault("fault", &(p->hdr_fault), &(p->rfault), 0); - mem_realloc_data(p->rhdr.data, p->rhdr.offset); - mem_realloc_data(p->rfault.data, p->rfault.offset); + smb_io_rpc_hdr ("hdr" , &(l->hdr ), &(l->rhdr), 0); + smb_io_rpc_hdr_resp ("resp" , &(l->hdr_resp ), &(l->rhdr), 0); + smb_io_rpc_hdr_fault("fault", &(l->hdr_fault), &(l->rfault), 0); + mem_realloc_data(l->rhdr.data, l->rhdr.offset); + mem_realloc_data(l->rfault.data, l->rfault.offset); /***/ /*** link rpc header and fault together ***/ /***/ - prs_link(NULL , &p->rhdr , &p->rfault); - prs_link(&p->rhdr, &p->rfault, NULL ); + prs_link(NULL , &l->rhdr , &l->rfault); + prs_link(&l->rhdr, &l->rfault, NULL ); return True; } -static BOOL api_pipe_bind_and_alt_req(pipes_struct *p, prs_struct *pd, enum RPC_PKT_TYPE pkt_type) +static BOOL srv_pipe_bind_and_alt_req(rpcsrv_struct *l, prs_struct *pd, + const char* ack_pipe_name, + enum RPC_PKT_TYPE pkt_type) { uint16 assoc_gid; - fstring ack_pipe_name; - int i = 0; - - p->ntlmssp_auth = False; - - DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); - - for (i = 0; i < num_cmds; i++) - { - if (strequal(api_fd_commands[i]->pipe_clnt_name, p->name) && - api_fd_commands[i]->fn != NULL) - { - DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", - api_fd_commands[i]->pipe_clnt_name, - api_fd_commands[i]->pipe_srv_name)); - fstrcpy(p->pipe_srv_name, api_fd_commands[i]->pipe_srv_name); - break; - } - } - if (api_fd_commands[i]->fn == NULL) return False; + l->ntlmssp_auth = False; /* decode the bind request */ - smb_io_rpc_hdr_rb("", &p->hdr_rb, pd, 0); + smb_io_rpc_hdr_rb("", &l->hdr_rb, pd, 0); if (pd->offset == 0) return False; - if (p->hdr.auth_len != 0) + if (l->hdr.auth_len != 0) { /* decode the authentication verifier */ - smb_io_rpc_hdr_auth ("", &p->auth_info , pd, 0); + smb_io_rpc_hdr_auth ("", &l->auth_info , pd, 0); if (pd->offset == 0) return False; - p->ntlmssp_auth = p->auth_info.auth_type = 0x0a; + l->ntlmssp_auth = l->auth_info.auth_type = 0x0a; - if (p->ntlmssp_auth) + if (l->ntlmssp_auth) { - smb_io_rpc_auth_ntlmssp_verifier("", &p->auth_verifier, pd, 0); + smb_io_rpc_auth_ntlmssp_verifier("", &l->auth_verifier, pd, 0); if (pd->offset == 0) return False; - p->ntlmssp_auth = strequal(p->auth_verifier.signature, "NTLMSSP"); + l->ntlmssp_auth = strequal(l->auth_verifier.signature, "NTLMSSP"); } - if (p->ntlmssp_auth) + if (l->ntlmssp_auth) { - if (!api_pipe_ntlmssp(p, pd)) return False; - } - } - - switch (pkt_type) - { - case RPC_BINDACK: - { - /* name has to be \PIPE\xxxxx */ - fstrcpy(ack_pipe_name, "\\PIPE\\"); - fstrcat(ack_pipe_name, p->pipe_srv_name); - break; - } - case RPC_ALTCONTRESP: - { - /* secondary address CAN be NULL - * as the specs says it's ignored. - * It MUST NULL to have the spoolss working. - */ - fstrcpy(ack_pipe_name, ""); - break; - } - default: - { - return False; + if (!api_pipe_ntlmssp(l, pd)) return False; } } DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); - prs_init(&(p->rdata), 1024, 4, 0, False); - prs_init(&(p->rhdr ), 0x18, 4, 0, False); - prs_init(&(p->rauth), 1024, 4, 0, False); - prs_init(&(p->rverf), 0x08, 4, 0, False); - prs_init(&(p->rntlm), 1024, 4, 0, False); + prs_init(&(l->rdata), 1024, 4, 0, False); + prs_init(&(l->rhdr ), 0x18, 4, 0, False); + prs_init(&(l->rauth), 1024, 4, 0, False); + prs_init(&(l->rverf), 0x08, 4, 0, False); + prs_init(&(l->rntlm), 1024, 4, 0, False); /***/ /*** do the bind ack first ***/ /***/ - if (p->ntlmssp_auth) + if (l->ntlmssp_auth) { assoc_gid = 0x7a77; } else { - assoc_gid = p->hdr_rb.bba.assoc_gid; + assoc_gid = l->hdr_rb.bba.assoc_gid; } - make_rpc_hdr_ba(&p->hdr_ba, - p->hdr_rb.bba.max_tsize, - p->hdr_rb.bba.max_rsize, + make_rpc_hdr_ba(&l->hdr_ba, + l->hdr_rb.bba.max_tsize, + l->hdr_rb.bba.max_rsize, assoc_gid, ack_pipe_name, 0x1, 0x0, 0x0, - &(p->hdr_rb.transfer)); + &(l->hdr_rb.transfer)); - smb_io_rpc_hdr_ba("", &p->hdr_ba, &p->rdata, 0); - mem_realloc_data(p->rdata.data, p->rdata.offset); + smb_io_rpc_hdr_ba("", &l->hdr_ba, &l->rdata, 0); + mem_realloc_data(l->rdata.data, l->rdata.offset); /***/ /*** now the authentication ***/ /***/ - if (p->ntlmssp_auth) + if (l->ntlmssp_auth) { uint8 challenge[8]; generate_random_buffer(challenge, 8, False); /*** authentication info ***/ - make_rpc_hdr_auth(&p->auth_info, 0x0a, 0x06, 0, 1); - smb_io_rpc_hdr_auth("", &p->auth_info, &p->rverf, 0); - mem_realloc_data(p->rverf.data, p->rverf.offset); + make_rpc_hdr_auth(&l->auth_info, 0x0a, 0x06, 0, 1); + smb_io_rpc_hdr_auth("", &l->auth_info, &l->rverf, 0); + mem_realloc_data(l->rverf.data, l->rverf.offset); /*** NTLMSSP verifier ***/ - make_rpc_auth_ntlmssp_verifier(&p->auth_verifier, + make_rpc_auth_ntlmssp_verifier(&l->auth_verifier, "NTLMSSP", NTLMSSP_CHALLENGE); - smb_io_rpc_auth_ntlmssp_verifier("", &p->auth_verifier, &p->rauth, 0); - mem_realloc_data(p->rauth.data, p->rauth.offset); + smb_io_rpc_auth_ntlmssp_verifier("", &l->auth_verifier, &l->rauth, 0); + mem_realloc_data(l->rauth.data, l->rauth.offset); /* NTLMSSP challenge ***/ - make_rpc_auth_ntlmssp_chal(&p->ntlmssp_chal, + make_rpc_auth_ntlmssp_chal(&l->ntlmssp_chal, 0x000082b1, challenge); - smb_io_rpc_auth_ntlmssp_chal("", &p->ntlmssp_chal, &p->rntlm, 0); - mem_realloc_data(p->rntlm.data, p->rntlm.offset); + smb_io_rpc_auth_ntlmssp_chal("", &l->ntlmssp_chal, &l->rntlm, 0); + mem_realloc_data(l->rntlm.data, l->rntlm.offset); } /***/ /*** then do the header, now we know the length ***/ /***/ - make_rpc_hdr(&p->hdr, pkt_type, RPC_FLG_FIRST | RPC_FLG_LAST, - p->hdr.call_id, - p->rdata.offset + p->rverf.offset + p->rauth.offset + p->rntlm.offset + 0x10, - p->rauth.offset + p->rntlm.offset); + make_rpc_hdr(&l->hdr, pkt_type, RPC_FLG_FIRST | RPC_FLG_LAST, + l->hdr.call_id, + l->rdata.offset + l->rverf.offset + l->rauth.offset + l->rntlm.offset + 0x10, + l->rauth.offset + l->rntlm.offset); - smb_io_rpc_hdr("", &p->hdr, &p->rhdr, 0); - mem_realloc_data(p->rhdr.data, p->rdata.offset); + smb_io_rpc_hdr("", &l->hdr, &l->rhdr, 0); + mem_realloc_data(l->rhdr.data, l->rdata.offset); /***/ /*** link rpc header, bind acknowledgment and authentication responses ***/ /***/ - if (p->ntlmssp_auth) + if (l->ntlmssp_auth) { - prs_link(NULL , &p->rhdr , &p->rdata); - prs_link(&p->rhdr , &p->rdata, &p->rverf); - prs_link(&p->rdata, &p->rverf, &p->rauth); - prs_link(&p->rverf, &p->rauth, &p->rntlm); - prs_link(&p->rauth, &p->rntlm, NULL ); + prs_link(NULL , &l->rhdr , &l->rdata); + prs_link(&l->rhdr , &l->rdata, &l->rverf); + prs_link(&l->rdata, &l->rverf, &l->rauth); + prs_link(&l->rverf, &l->rauth, &l->rntlm); + prs_link(&l->rauth, &l->rntlm, NULL ); } else { - prs_link(NULL , &p->rhdr , &p->rdata); - prs_link(&p->rhdr, &p->rdata, NULL ); + prs_link(NULL , &l->rhdr , &l->rdata); + prs_link(&l->rhdr, &l->rdata, NULL ); } return True; } +static BOOL api_pipe_bind_and_alt_req(rpcsrv_struct *l, prs_struct *pd, + const char* name, + enum RPC_PKT_TYPE pkt_type) +{ + fstring ack_pipe_name; + fstring pipe_srv_name; + int i = 0; + + DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); + + for (i = 0; i < num_cmds; i++) + { + if (strequal(api_fd_commands[i]->pipe_clnt_name, name) && + api_fd_commands[i]->fn != NULL) + { + DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", + api_fd_commands[i]->pipe_clnt_name, + api_fd_commands[i]->pipe_srv_name)); + fstrcpy(pipe_srv_name, api_fd_commands[i]->pipe_srv_name); + break; + } + } + + if (api_fd_commands[i]->fn == NULL) return False; + + switch (pkt_type) + { + case RPC_BINDACK: + { + /* name has to be \PIPE\xxxxx */ + fstrcpy(ack_pipe_name, "\\PIPE\\"); + fstrcat(ack_pipe_name, pipe_srv_name); + break; + } + case RPC_ALTCONTRESP: + { + /* secondary address CAN be NULL + * as the specs says it's ignored. + * It MUST NULL to have the spoolss working. + */ + fstrcpy(ack_pipe_name, ""); + break; + } + default: + { + return False; + } + } + return srv_pipe_bind_and_alt_req(l, pd, ack_pipe_name, pkt_type); +} + /* * The RPC Alter-Context call is used only by the spoolss pipe * simply because there is a bug (?) in the MS unmarshalling code * or in the marshalling code. If it's in the later, then Samba * have the same bug. */ -static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) +static BOOL api_pipe_bind_req(rpcsrv_struct *l, prs_struct *pd, + const char* name) { - return api_pipe_bind_and_alt_req(p, pd, RPC_BINDACK); + return api_pipe_bind_and_alt_req(l, pd, name, RPC_BINDACK); } -static BOOL api_pipe_alt_req(pipes_struct *p, prs_struct *pd) +static BOOL api_pipe_alt_req(rpcsrv_struct *l, prs_struct *pd, + const char* name) { - return api_pipe_bind_and_alt_req(p, pd, RPC_ALTCONTRESP); + return api_pipe_bind_and_alt_req(l, pd, name, RPC_ALTCONTRESP); } -static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) +static BOOL api_pipe_auth_process(rpcsrv_struct *l, prs_struct *pd) { - BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SIGN); - BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SEAL); + BOOL auth_verify = IS_BITS_SET_ALL(l->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SIGN); + BOOL auth_seal = IS_BITS_SET_ALL(l->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SEAL); int data_len; int auth_len; uint32 old_offset; uint32 crc32 = 0; - auth_len = p->hdr.auth_len; + auth_len = l->hdr.auth_len; if (auth_len != 16 && auth_verify) { return False; } - data_len = p->hdr.frag_len - auth_len - (auth_verify ? 8 : 0) - 0x18; + data_len = l->hdr.frag_len - auth_len - (auth_verify ? 8 : 0) - 0x18; DEBUG(5,("api_pipe_auth_process: sign: %s seal: %s data %d auth %d\n", BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); @@ -761,7 +778,7 @@ static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) { char *data = mem_data(&pd->data, pd->offset); DEBUG(5,("api_pipe_auth_process: data %d\n", pd->offset)); - NTLMSSPcalc_p(p, (uchar*)data, data_len); + NTLMSSPcalc_p(l, (uchar*)data, data_len); crc32 = crc32_calc_buffer(data_len, data); } @@ -771,18 +788,18 @@ static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) if (auth_seal || auth_verify) { pd->offset += data_len; - smb_io_rpc_hdr_auth("hdr_auth", &p->auth_info, pd, 0); + smb_io_rpc_hdr_auth("hdr_auth", &l->auth_info, pd, 0); } if (auth_verify) { char *req_data = mem_data(&pd->data, pd->offset + 4); DEBUG(5,("api_pipe_auth_process: auth %d\n", pd->offset + 4)); - NTLMSSPcalc_p(p, (uchar*)req_data, 12); - smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(p->ntlmssp_chk), pd, 0); + NTLMSSPcalc_p(l, (uchar*)req_data, 12); + smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(l->ntlmssp_chk), pd, 0); - if (!rpc_auth_ntlmssp_chk(&(p->ntlmssp_chk), crc32, - p->ntlmssp_seq_num)) + if (!rpc_auth_ntlmssp_chk(&(l->ntlmssp_chk), crc32, + l->ntlmssp_seq_num)) { return False; } @@ -793,13 +810,13 @@ static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *pd) return True; } -static BOOL api_pipe_request(pipes_struct *p, prs_struct *pd) +static BOOL api_pipe_request(rpcsrv_struct *l, prs_struct *pd, const char* name) { int i = 0; - if (p->ntlmssp_auth && p->ntlmssp_validated) + if (l->ntlmssp_auth && l->ntlmssp_validated) { - if (!api_pipe_auth_process(p, pd)) return False; + if (!api_pipe_auth_process(l, pd)) return False; DEBUG(0,("api_pipe_request: **** MUST CALL become_user() HERE **** \n")); #if 0 @@ -809,61 +826,116 @@ static BOOL api_pipe_request(pipes_struct *p, prs_struct *pd) for (i = 0; i < num_cmds; i++) { - if (strequal(api_fd_commands[i]->pipe_clnt_name, p->name) && + if (strequal(api_fd_commands[i]->pipe_clnt_name, name) && api_fd_commands[i]->fn != NULL) { DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i]->pipe_clnt_name)); - return api_fd_commands[i]->fn(p, pd); + return api_fd_commands[i]->fn(l, pd); } } return False; } -BOOL rpc_command(pipes_struct *p, prs_struct *pd) +BOOL rpc_add_to_pdu(prs_struct *ps, const char *data, int len) { - BOOL reply = False; - DEBUG(10,("rpc_command\n")); + int prev_size; + int new_size; + char *to = NULL; - if (p->m != NULL) + ps->offset = 0; + + if (ps->data == NULL) { - DEBUG(10,("msrpc redirect\n")); - if (!msrpc_send_prs(p->m, pd)) + DEBUG(10,("rpc_add_to_pdu: new_size: %d\n", len)); + prs_init(ps, len, 4, 0, True); + prev_size = 0; + new_size = len; + if (ps->data == NULL) { - DEBUG(2,("msrpc redirect send failed\n")); return False; } - if (!msrpc_receive_prs(p->m, &p->rhdr)) + } + else + { + prev_size = ps->data->data_used; + new_size = prev_size + len; + DEBUG(10,("rpc_add_to_pdu: prev_size: %d new_size: %d\n", + prev_size, new_size)); + if (!mem_realloc_data(ps->data, new_size)) { - DEBUG(2,("msrpc redirect receive failed\n")); return False; } - prs_link(NULL, &p->rhdr, NULL); - prs_debug_out(&p->rhdr, 10); - return True; } - if (pd->data == NULL) return False; + DEBUG(10,("ps->data->start: %d\n", ps->data->offset.start)); + ps->data->offset.start = 0x0; + + to = mem_data(&ps->data, prev_size); + if (to == NULL) + { + DEBUG(10,("rpc_add_to_pdu: data could not be found\n")); + return False; + } + if (ps->data->data_used != new_size) + { + DEBUG(10,("rpc_add_to_pdu: ERROR: data used %d new_size %d\n", + ps->data->data_used, new_size)); + return False; + } + memcpy(to, data, len); + return True; +} + +static BOOL rpc_redir_remote(pipes_struct *p, prs_struct *req, prs_struct *resp) +{ + DEBUG(10,("rpc_redirect\n")); + + if (!msrpc_send_prs(p->m, req)) + { + DEBUG(2,("msrpc redirect send failed\n")); + return False; + } + if (!msrpc_receive_prs(p->m, resp)) + { + DEBUG(2,("msrpc redirect receive failed\n")); + return False; + } + prs_link(NULL, resp, NULL); + prs_debug_out(resp, "redirect", 100); + return True; +} +static BOOL rpc_redir_local(rpcsrv_struct *l, prs_struct *req, prs_struct *resp, + const char* name) +{ + BOOL reply = False; + + if (req->data == NULL) return False; + + /* lkclXXXX still assume that the first complete PDU is always + in a single request!!! + */ /* process the rpc header */ - smb_io_rpc_hdr("", &p->hdr, pd, 0); + req->offset = 0x0; + smb_io_rpc_hdr("", &l->hdr, req, 0); - if (pd->offset == 0) return False; + if (req->offset == 0) return False; - switch (p->hdr.pkt_type) + switch (l->hdr.pkt_type) { case RPC_BIND : { - reply = api_pipe_bind_req(p, pd); + reply = api_pipe_bind_req(l, req, name); break; } case RPC_ALTCONT: { - reply = api_pipe_alt_req(p, pd); + reply = api_pipe_alt_req(l, req, name); break; } case RPC_REQUEST: { - if (p->ntlmssp_auth && !p->ntlmssp_validated) + if (l->ntlmssp_auth && !l->ntlmssp_validated) { /* authentication _was_ requested and it failed. sorry, no deal! @@ -873,41 +945,87 @@ BOOL rpc_command(pipes_struct *p, prs_struct *pd) else { /* read the rpc header */ - smb_io_rpc_hdr_req("req", &(p->hdr_req), pd, 0); - reply = api_pipe_request(p, pd); + smb_io_rpc_hdr_req("req", &(l->hdr_req), req, 0); + reply = api_pipe_request(l, req, name); } break; } case RPC_BINDRESP: /* not the real name! */ { - reply = api_pipe_bind_auth_resp(p, pd); - p->ntlmssp_auth = reply; + reply = api_pipe_bind_auth_resp(l, req); + l->ntlmssp_auth = reply; break; } } if (!reply) { - reply = api_pipe_fault_resp(p, pd, 0x1c010002); + reply = api_pipe_fault_resp(l, req, 0x1c010002); + } + + if (reply) + { + /* flatten the data into a single pdu */ + reply = prs_copy(resp, &l->rhdr); } + /* delete intermediate data used to set up the pdu. leave + rdata alone because that's got the rest of the data in it */ + rpcsrv_free_temp(l); + return reply; } +BOOL rpc_send_and_rcv_pdu(pipes_struct *p) +{ + DEBUG(10,("rpc_send_and_rcv_pdu\n")); + + if (p->m != NULL) + { + return rpc_redir_remote(p, &p->smb_pdu, &p->rsmb_pdu); + } + else if (p->l != NULL) + { + return rpc_redir_local(p->l, &p->smb_pdu, &p->rsmb_pdu, + p->name); + } + return False; +} + +/******************************************************************* + entry point from msrpc to smb. adds data received to pdu; checks + pdu; hands pdu off to msrpc, which gets a pdu back (except in the + case of the RPC_BINDCONT pdu). + ********************************************************************/ +BOOL rpc_to_smb(pipes_struct *p, char *data, int len) +{ + BOOL reply = rpc_add_to_pdu(&p->smb_pdu, data, len); + + if (reply && is_complete_pdu(&p->smb_pdu)) + { + p->smb_pdu.offset = p->smb_pdu.data->data_size; + prs_link(NULL, &p->smb_pdu, NULL); + reply = rpc_send_and_rcv_pdu(p); + mem_free_data(p->smb_pdu.data); + prs_init(&p->smb_pdu, 0, 4, 0, True); + + } + return reply; +} /******************************************************************* receives a netlogon pipe and responds. ********************************************************************/ -static BOOL api_rpc_command(pipes_struct *p, +static BOOL api_rpc_command(rpcsrv_struct *l, char *rpc_name, struct api_struct *api_rpc_cmds, prs_struct *data) { int fn_num; - DEBUG(4,("api_rpc_command: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); + DEBUG(4,("api_rpc_command: %s op 0x%x - ", rpc_name, l->hdr_req.opnum)); for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) { - if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) + if (api_rpc_cmds[fn_num].opnum == l->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) { DEBUG(3,("api_rpc_command: %s\n", api_rpc_cmds[fn_num].name)); break; @@ -921,18 +1039,18 @@ static BOOL api_rpc_command(pipes_struct *p, } /* start off with 1024 bytes, and a large safety margin too */ - prs_init(&p->rdata, 1024, 4, SAFETY_MARGIN, False); + prs_init(&l->rdata, 1024, 4, SAFETY_MARGIN, False); /* do the actual command */ - api_rpc_cmds[fn_num].fn(p, data, &(p->rdata)); + api_rpc_cmds[fn_num].fn(l, data, &(l->rdata)); - if (p->rdata.data == NULL || p->rdata.offset == 0) + if (l->rdata.data == NULL || l->rdata.offset == 0) { - mem_free_data(p->rdata.data); + mem_free_data(l->rdata.data); return False; } - mem_realloc_data(p->rdata.data, p->rdata.offset); + mem_realloc_data(l->rdata.data, l->rdata.offset); DEBUG(10,("called %s\n", rpc_name)); @@ -943,7 +1061,7 @@ static BOOL api_rpc_command(pipes_struct *p, /******************************************************************* receives a netlogon pipe and responds. ********************************************************************/ -BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds, +BOOL api_rpcTNP(rpcsrv_struct *l, char *rpc_name, struct api_struct *api_rpc_cmds, prs_struct *data) { if (data == NULL || data->data == NULL) @@ -953,16 +1071,39 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds } /* interpret the command */ - if (!api_rpc_command(p, rpc_name, api_rpc_cmds, data)) + if (!api_rpc_command(l, rpc_name, api_rpc_cmds, data)) { return False; } /* create the rpc header */ - if (!create_rpc_reply(p, 0, p->rdata.offset + (p->ntlmssp_auth ? (16 + 8) : 0))) + if (!create_rpc_reply(l, 0)) { return False; } return True; } + +BOOL is_complete_pdu(prs_struct *ps) +{ + RPC_HDR hdr; + int len = ps->data->data_size; + + DEBUG(10,("is_complete_pdu - len %d\n", len)); + ps->offset = 0x0; + + if (!ps->io) + { + /* writing. oops!! */ + DEBUG(4,("is_complete_pdu: write set, not read!\n")); + return False; + } + + if (!smb_io_rpc_hdr("hdr", &hdr, ps, 0)) + { + return False; + } + /* check that the fragment length is equal to the data length so far */ + return hdr.frag_len == len; +} diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index a7e451e6da..8a28674d3d 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -84,14 +84,40 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, pipes_struct *p; static int next_pipe; struct msrpc_state *m = NULL; + struct rpcsrv_struct *l = NULL; + user_struct *vuser = get_valid_user_struct(vuid); + struct user_creds usr; + + ZERO_STRUCT(usr); DEBUG(4,("Open pipe requested %s (pipes_open=%d)\n", pipe_name, pipes_open)); + if (vuser == NULL) + { + DEBUG(4,("invalid vuid %d\n", vuid)); + return NULL; + } + + /* set up unix credentials from the smb side, to feed over the pipe */ + make_creds_unix(&usr.uxc, vuser->name, vuser->requested_name, + vuser->real_name, vuser->guest); + usr.ptr_uxc = 1; + make_creds_unix_sec(&usr.uxs, vuser->uid, vuser->gid, + vuser->n_groups, vuser->groups); + usr.ptr_uxs = 1; + + /* set up nt credentials from the smb side, to feed over the pipe */ + /* lkclXXXX todo! + make_creds_nt(&usr.ntc); + make_creds_nt_sec(&usr.nts); + */ + /* not repeating pipe numbers makes it easier to track things in log files and prevents client bugs where pipe numbers are reused over connection restarts */ - if (next_pipe == 0) { + if (next_pipe == 0) + { next_pipe = (getpid() ^ time(NULL)) % MAX_OPEN_PIPES; } @@ -111,13 +137,33 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, if (strequal(pipe_name, "lsarpc")) { - m = msrpc_use_add(pipe_name, NULL, False); + m = msrpc_use_add(pipe_name, &usr, False); if (m == NULL) { DEBUG(5,("open pipes: msrpc redirect failed\n")); return NULL; } } + else + { + l = malloc(sizeof(*l)); + if (l == NULL) + { + DEBUG(5,("open pipes: local msrpc malloc failed\n")); + return NULL; + } + ZERO_STRUCTP(l); + l->rhdr.data = NULL; + l->rdata.data = NULL; + l->rhdr.offset = 0; + l->rdata.offset = 0; + + l->ntlmssp_validated = False; + l->ntlmssp_auth = False; + + memcpy(l->user_sess_key, vuser->user_sess_key, + sizeof(l->user_sess_key)); + } p = (pipes_struct *)malloc(sizeof(*p)); if (!p) return NULL; @@ -132,6 +178,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->pnum = i; p->m = m; + p->l = l; p->open = True; p->device_state = 0; @@ -139,20 +186,15 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->conn = conn; p->vuid = vuid; - p->rhdr.data = NULL; - p->rdata.data = NULL; - p->rhdr.offset = 0; - p->rdata.offset = 0; - p->file_offset = 0; p->prev_pdu_file_offset = 0; p->hdr_offsets = 0; - p->ntlmssp_validated = False; - p->ntlmssp_auth = False; - fstrcpy(p->name, pipe_name); + prs_init(&p->smb_pdu, 0, 4, 0, True); + prs_init(&p->rsmb_pdu, 0, 4, 0, False); + DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n", pipe_name, i, pipes_open)); @@ -175,29 +217,13 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, ****************************************************************************/ ssize_t write_pipe(pipes_struct *p, char *data, size_t n) { - prs_struct pd; - struct mem_buf data_buf; - DEBUG(6,("write_pipe: %x", p->pnum)); - DEBUG(6,("name: %s open: %s len: %d", p->name, BOOLSTR(p->open), n)); dump_data(50, data, n); - /* fake up a data buffer from the write_pipe data parameters */ - mem_create(&data_buf, data, 0, n, 0, False); - data_buf.offset.start = 0; - data_buf.offset.end = n; - - /* fake up a parsing structure */ - pd.data = &data_buf; - pd.align = 4; - pd.io = True; - pd.error = False; - pd.offset = 0; - - return rpc_command(p, &pd) ? ((ssize_t)n) : -1; + return rpc_to_smb(p, data, n) ? ((ssize_t)n) : -1; } @@ -232,8 +258,8 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) } - if (p->rhdr.data == NULL || p->rhdr.data->data == NULL || - p->rhdr.data->data_used == 0) + if (p->rsmb_pdu.data == NULL || p->rsmb_pdu.data->data == NULL || + p->rsmb_pdu.data->data_used == 0) { return 0; } @@ -246,12 +272,12 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) pdu_data_sent = p->file_offset - p->prev_pdu_file_offset; this_pdu_data_pos = (pdu_data_sent == 0) ? 0 : (pdu_data_sent - 0x18); - if (!IS_BITS_SET_ALL(p->hdr.flags, RPC_FLG_LAST)) + if (!IS_BITS_SET_ALL(p->l->hdr.flags, RPC_FLG_LAST)) { /* intermediate fragment - possibility of another header */ DEBUG(5,("read_pipe: frag_len: %d data_pos: %d pdu_data_sent: %d\n", - p->hdr.frag_len, data_pos, pdu_data_sent)); + p->l->hdr.frag_len, data_pos, pdu_data_sent)); if (pdu_data_sent == 0) { @@ -263,11 +289,11 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) data_pos -= 0x18; /* create and copy in a new header. */ - create_rpc_reply(p, data_pos, p->rdata.offset); + create_rpc_reply(p->l, data_pos); } } - pdu_len = mem_buf_len(p->rhdr.data); + pdu_len = mem_buf_len(p->rsmb_pdu.data); num = pdu_len - this_pdu_data_pos; DEBUG(6,("read_pipe: pdu_len: %d num: %d n: %d\n", pdu_len, num, n)); @@ -284,7 +310,7 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) DEBUG(5,("read_pipe: warning - data read only part of a header\n")); } - mem_buf_copy(data, p->rhdr.data, pdu_data_sent, num); + mem_buf_copy(data, p->rsmb_pdu.data, pdu_data_sent, num); p->file_offset += num; pdu_data_sent += num; @@ -294,7 +320,7 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) DEBUG(6,("read_pipe: just header read\n")); } - if (pdu_data_sent == p->hdr.frag_len) + if (pdu_data_sent == p->l->hdr.frag_len) { DEBUG(6,("read_pipe: next fragment expected\n")); p->prev_pdu_file_offset = p->file_offset; @@ -359,8 +385,8 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) return False; } - mem_buf_free(&(p->rdata.data)); - mem_buf_free(&(p->rhdr .data)); + mem_buf_free(&(p->smb_pdu .data)); + mem_buf_free(&(p->rsmb_pdu.data)); bitmap_clear(bmap, p->pnum - pipe_handle_offset); @@ -384,8 +410,17 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) } } - ZERO_STRUCTP(p); + if (p->l != NULL) + { + DEBUG(4,("closed msrpc local: OK\n")); + + mem_free_data(p->l->rdata .data); + rpcsrv_free_temp(p->l); + free(p->l); + } + + ZERO_STRUCTP(p); free(p); return True; diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 22314d9c5e..ea3150fd3c 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -61,7 +61,7 @@ static void reg_reply_close(REG_Q_CLOSE *q_r, /******************************************************************* api_reg_close ********************************************************************/ -static void api_reg_close( pipes_struct *p, prs_struct *data, +static void api_reg_close( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { REG_Q_CLOSE q_r; @@ -100,7 +100,7 @@ static void reg_reply_open(REG_Q_OPEN_HKLM *q_r, /******************************************************************* api_reg_open ********************************************************************/ -static void api_reg_open( pipes_struct *p, prs_struct *data, +static void api_reg_open( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { REG_Q_OPEN_HKLM q_u; @@ -165,7 +165,7 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, /******************************************************************* api_reg_open_entry ********************************************************************/ -static void api_reg_open_entry( pipes_struct *p, prs_struct *data, +static void api_reg_open_entry( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { REG_Q_OPEN_ENTRY q_u; @@ -223,7 +223,7 @@ static void reg_reply_info(REG_Q_INFO *q_u, /******************************************************************* api_reg_info ********************************************************************/ -static void api_reg_info( pipes_struct *p, prs_struct *data, +static void api_reg_info( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { REG_Q_INFO q_u; @@ -251,7 +251,7 @@ static struct api_struct api_reg_cmds[] = /******************************************************************* receives a reg pipe and responds. ********************************************************************/ -BOOL api_reg_rpc(pipes_struct *p, prs_struct *data) +BOOL api_reg_rpc(rpcsrv_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds, data); } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 894e8f2e2c..738623ec4d 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -145,7 +145,7 @@ static void samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, /******************************************************************* api_samr_close_hnd ********************************************************************/ -static void api_samr_close_hnd( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_close_hnd( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_CLOSE_HND q_u; samr_io_q_close_hnd("", &q_u, data, 0); @@ -200,7 +200,7 @@ static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, /******************************************************************* api_samr_open_domain ********************************************************************/ -static void api_samr_open_domain( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_open_domain( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_DOMAIN q_u; samr_io_q_open_domain("", &q_u, data, 0); @@ -243,7 +243,7 @@ static void samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, /******************************************************************* api_samr_unknown_2c ********************************************************************/ -static void api_samr_unknown_2c( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_unknown_2c( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_2C q_u; samr_io_q_unknown_2c("", &q_u, data, 0); @@ -312,7 +312,7 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, /******************************************************************* api_samr_unknown_3 ********************************************************************/ -static void api_samr_unknown_3( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_unknown_3( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_3 q_u; samr_io_q_unknown_3("", &q_u, data, 0); @@ -370,7 +370,7 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, /******************************************************************* api_samr_enum_dom_users ********************************************************************/ -static void api_samr_enum_dom_users( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_enum_dom_users( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_USERS q_e; samr_io_q_enum_dom_users("", &q_e, data, 0); @@ -429,7 +429,7 @@ static void samr_reply_add_groupmem(SAMR_Q_ADD_GROUPMEM *q_u, /******************************************************************* api_samr_add_groupmem ********************************************************************/ -static void api_samr_add_groupmem( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_add_groupmem( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_ADD_GROUPMEM q_e; samr_io_q_add_groupmem("", &q_e, data, 0); @@ -487,7 +487,7 @@ static void samr_reply_del_groupmem(SAMR_Q_DEL_GROUPMEM *q_u, /******************************************************************* api_samr_del_groupmem ********************************************************************/ -static void api_samr_del_groupmem( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_del_groupmem( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_DEL_GROUPMEM q_e; samr_io_q_del_groupmem("", &q_e, data, 0); @@ -553,7 +553,7 @@ static void samr_reply_add_aliasmem(SAMR_Q_ADD_ALIASMEM *q_u, /******************************************************************* api_samr_add_aliasmem ********************************************************************/ -static void api_samr_add_aliasmem( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_add_aliasmem( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_ADD_ALIASMEM q_e; samr_io_q_add_aliasmem("", &q_e, data, 0); @@ -619,7 +619,7 @@ static void samr_reply_del_aliasmem(SAMR_Q_DEL_ALIASMEM *q_u, /******************************************************************* api_samr_del_aliasmem ********************************************************************/ -static void api_samr_del_aliasmem( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_del_aliasmem( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_DEL_ALIASMEM q_e; samr_io_q_del_aliasmem("", &q_e, data, 0); @@ -684,7 +684,7 @@ static void samr_reply_enum_domains(SAMR_Q_ENUM_DOMAINS *q_u, /******************************************************************* api_samr_enum_domains ********************************************************************/ -static void api_samr_enum_domains( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_enum_domains( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOMAINS q_e; @@ -764,7 +764,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, /******************************************************************* api_samr_enum_dom_groups ********************************************************************/ -static void api_samr_enum_dom_groups( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_enum_dom_groups( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_GROUPS q_e; @@ -861,7 +861,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, /******************************************************************* api_samr_enum_dom_aliases ********************************************************************/ -static void api_samr_enum_dom_aliases( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_enum_dom_aliases( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_ALIASES q_e; @@ -1033,7 +1033,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, /******************************************************************* api_samr_query_dispinfo ********************************************************************/ -static void api_samr_query_dispinfo( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_query_dispinfo( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_DISPINFO q_e; @@ -1095,7 +1095,7 @@ static void samr_reply_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP *q_u, /******************************************************************* api_samr_delete_dom_group ********************************************************************/ -static void api_samr_delete_dom_group( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_delete_dom_group( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_DELETE_DOM_GROUP q_u; samr_io_q_delete_dom_group("", &q_u, data, 0); @@ -1190,7 +1190,7 @@ static void samr_reply_query_groupmem(SAMR_Q_QUERY_GROUPMEM *q_u, /******************************************************************* api_samr_query_groupmem ********************************************************************/ -static void api_samr_query_groupmem( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_query_groupmem( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_GROUPMEM q_u; samr_io_q_query_groupmem("", &q_u, data, 0); @@ -1253,7 +1253,7 @@ static void samr_reply_query_groupinfo(SAMR_Q_QUERY_GROUPINFO *q_u, /******************************************************************* api_samr_query_groupinfo ********************************************************************/ -static void api_samr_query_groupinfo( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_query_groupinfo( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_GROUPINFO q_e; samr_io_q_query_groupinfo("", &q_e, data, 0); @@ -1307,7 +1307,7 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, /******************************************************************* api_samr_query_aliasinfo ********************************************************************/ -static void api_samr_query_aliasinfo( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_query_aliasinfo( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_ALIASINFO q_e; samr_io_q_query_aliasinfo("", &q_e, data, 0); @@ -1429,7 +1429,7 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, /******************************************************************* api_samr_query_useraliases ********************************************************************/ -static void api_samr_query_useraliases( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_query_useraliases( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERALIASES q_u; ZERO_STRUCT(q_u); @@ -1492,7 +1492,7 @@ static void samr_reply_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS *q_u, /******************************************************************* api_samr_delete_dom_alias ********************************************************************/ -static void api_samr_delete_dom_alias( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_delete_dom_alias( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_DELETE_DOM_ALIAS q_u; samr_io_q_delete_dom_alias("", &q_u, data, 0); @@ -1587,7 +1587,7 @@ static void samr_reply_query_aliasmem(SAMR_Q_QUERY_ALIASMEM *q_u, /******************************************************************* api_samr_query_aliasmem ********************************************************************/ -static void api_samr_query_aliasmem( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_query_aliasmem( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_ALIASMEM q_u; samr_io_q_query_aliasmem("", &q_u, data, 0); @@ -1659,7 +1659,7 @@ static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, /******************************************************************* api_samr_lookup_names ********************************************************************/ -static void api_samr_lookup_names( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_lookup_names( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_NAMES q_u; samr_io_q_lookup_names("", &q_u, data, 0); @@ -1700,7 +1700,7 @@ static void samr_reply_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u, /******************************************************************* api_samr_chgpasswd_user ********************************************************************/ -static void api_samr_chgpasswd_user( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_chgpasswd_user( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_CHGPASSWD_USER q_u; samr_io_q_chgpasswd_user("", &q_u, data, 0); @@ -1729,7 +1729,7 @@ static void samr_reply_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, /******************************************************************* api_samr_unknown_38 ********************************************************************/ -static void api_samr_unknown_38( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_unknown_38( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_38 q_u; samr_io_q_unknown_38("", &q_u, data, 0); @@ -1795,7 +1795,7 @@ static void samr_reply_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u, /******************************************************************* api_samr_lookup_rids ********************************************************************/ -static void api_samr_lookup_rids( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_lookup_rids( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_RIDS q_u; ZERO_STRUCT(q_u); @@ -1867,7 +1867,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, /******************************************************************* api_samr_open_user ********************************************************************/ -static void api_samr_open_user( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_open_user( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_USER q_u; samr_io_q_open_user("", &q_u, data, 0); @@ -2151,7 +2151,7 @@ static BOOL set_user_info_16(SAM_USER_INFO_16 *id16, uint32 rid) /******************************************************************* api_samr_query_userinfo ********************************************************************/ -static void api_samr_query_userinfo( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_query_userinfo( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERINFO q_u; samr_io_q_query_userinfo("", &q_u, data, 0); @@ -2224,14 +2224,13 @@ static void samr_reply_set_userinfo2(SAMR_Q_SET_USERINFO2 *q_u, /******************************************************************* api_samr_set_userinfo2 ********************************************************************/ -static void api_samr_set_userinfo2( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_set_userinfo2( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { - user_struct *vuser = get_valid_user_struct(p->vuid); SAMR_Q_SET_USERINFO2 q_u; ZERO_STRUCT(q_u); samr_io_q_set_userinfo2("", &q_u, data, 0); - samr_reply_set_userinfo2(&q_u, rdata, vuser->dc.user_sess_key); + samr_reply_set_userinfo2(&q_u, rdata, p->user_sess_key); if (q_u.info.id != NULL) { @@ -2321,18 +2320,17 @@ static void samr_reply_set_userinfo(SAMR_Q_SET_USERINFO *q_u, /******************************************************************* api_samr_set_userinfo ********************************************************************/ -static void api_samr_set_userinfo( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_set_userinfo( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { - user_struct *vuser = get_valid_user_struct(p->vuid); SAMR_Q_SET_USERINFO q_u; ZERO_STRUCT(q_u); #ifdef DEBUG_PASSWORD DEBUG(100,("set user info: sess_key: ")); - dump_data(100, vuser->dc.user_sess_key, 16); + dump_data(100, p->user_sess_key, 16); #endif samr_io_q_set_userinfo("", &q_u, data, 0); - samr_reply_set_userinfo(&q_u, rdata, vuser->dc.user_sess_key); + samr_reply_set_userinfo(&q_u, rdata, p->user_sess_key); if (q_u.info.id != NULL) { @@ -2416,7 +2414,7 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, /******************************************************************* api_samr_query_usergroups ********************************************************************/ -static void api_samr_query_usergroups( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_query_usergroups( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERGROUPS q_u; samr_io_q_query_usergroups("", &q_u, data, 0); @@ -2527,7 +2525,7 @@ static void samr_reply_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS *q_u, /******************************************************************* api_samr_create_dom_alias ********************************************************************/ -static void api_samr_create_dom_alias( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_create_dom_alias( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_CREATE_DOM_ALIAS q_u; samr_io_q_create_dom_alias("", &q_u, data, 0); @@ -2639,7 +2637,7 @@ static void samr_reply_create_dom_group(SAMR_Q_CREATE_DOM_GROUP *q_u, /******************************************************************* api_samr_create_dom_group ********************************************************************/ -static void api_samr_create_dom_group( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_create_dom_group( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_CREATE_DOM_GROUP q_u; samr_io_q_create_dom_group("", &q_u, data, 0); @@ -2731,7 +2729,7 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, /******************************************************************* api_samr_query_dom_info ********************************************************************/ -static void api_samr_query_dom_info( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_query_dom_info( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_DOMAIN_INFO q_e; samr_io_q_query_dom_info("", &q_e, data, 0); @@ -2839,7 +2837,7 @@ static void samr_reply_create_user(SAMR_Q_CREATE_USER *q_u, /******************************************************************* api_samr_create_user ********************************************************************/ -static void api_samr_create_user( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_create_user( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_CREATE_USER q_u; @@ -2893,7 +2891,7 @@ static void samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, /******************************************************************* api_samr_connect_anon ********************************************************************/ -static void api_samr_connect_anon( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_connect_anon( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_CONNECT_ANON q_u; samr_io_q_connect_anon("", &q_u, data, 0); @@ -2942,7 +2940,7 @@ static void samr_reply_connect(SAMR_Q_CONNECT *q_u, /******************************************************************* api_samr_connect ********************************************************************/ -static void api_samr_connect( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_connect( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_CONNECT q_u; samr_io_q_connect("", &q_u, data, 0); @@ -3008,7 +3006,7 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, /******************************************************************* api_samr_open_alias ********************************************************************/ -static void api_samr_open_alias( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_open_alias( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_ALIAS q_u; @@ -3055,7 +3053,7 @@ static void samr_reply_open_group(SAMR_Q_OPEN_GROUP *q_u, /******************************************************************* api_samr_open_group ********************************************************************/ -static void api_samr_open_group( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_open_group( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_GROUP q_u; @@ -3114,7 +3112,7 @@ static void samr_reply_lookup_domain(SAMR_Q_LOOKUP_DOMAIN *q_u, /******************************************************************* api_samr_lookup_domain ********************************************************************/ -static void api_samr_lookup_domain( pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_samr_lookup_domain( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_DOMAIN q_u; samr_io_q_lookup_domain("", &q_u, data, 0); @@ -3172,7 +3170,7 @@ static struct api_struct api_samr_cmds [] = /******************************************************************* receives a samr pipe and responds. ********************************************************************/ -BOOL api_samr_rpc(pipes_struct *p, prs_struct *data) +BOOL api_samr_rpc(rpcsrv_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_samr_rpc", api_samr_cmds, data); } diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index a3760587cd..aff896edfd 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -428,7 +428,7 @@ static void spoolss_reply_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_stru * * called from the spoolss dispatcher ********************************************************************/ -static void api_spoolss_open_printer_ex(pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_spoolss_open_printer_ex(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_OPEN_PRINTER_EX q_u; @@ -653,7 +653,7 @@ static void spoolss_reply_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u, prs_struct * * called from the spoolss dispatcher ********************************************************************/ -static void api_spoolss_getprinterdata(pipes_struct *p, prs_struct *data, +static void api_spoolss_getprinterdata(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_GETPRINTERDATA q_u; @@ -696,7 +696,7 @@ static void spoolss_reply_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *rd * * called from the spoolss dispatcher ********************************************************************/ -static void api_spoolss_closeprinter(pipes_struct *p, prs_struct *data, +static void api_spoolss_closeprinter(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_CLOSEPRINTER q_u; @@ -731,7 +731,7 @@ static void spoolss_reply_rffpcnex(SPOOL_Q_RFFPCNEX *q_u, prs_struct *rdata) * * in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe ********************************************************************/ -static void api_spoolss_rffpcnex(pipes_struct *p, prs_struct *data, +static void api_spoolss_rffpcnex(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_RFFPCNEX q_u; @@ -767,7 +767,7 @@ static void api_spoolss_rffpcnex(pipes_struct *p, prs_struct *data, /******************************************************************* * fill a notify_info_data with the servername ********************************************************************/ -static void spoolss_notify_server_name(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { pstring temp_name; @@ -781,7 +781,7 @@ static void spoolss_notify_server_name(connection_struct *conn, int snum, SPOOL_ * fill a notify_info_data with the servicename * jfmxxxx: it's incorrect should be long_printername ********************************************************************/ -static void spoolss_notify_printer_name(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { /* data->notify_data.data.length=strlen(lp_servicename(snum)); @@ -796,7 +796,7 @@ static void spoolss_notify_printer_name(connection_struct *conn, int snum, SPOOL /******************************************************************* * fill a notify_info_data with the servicename ********************************************************************/ -static void spoolss_notify_share_name(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_share_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(lp_servicename(snum)); ascii_to_unistr(data->notify_data.data.string, @@ -807,7 +807,7 @@ static void spoolss_notify_share_name(connection_struct *conn, int snum, SPOOL_N /******************************************************************* * fill a notify_info_data with the port name ********************************************************************/ -static void spoolss_notify_port_name(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { /* even if it's strange, that's consistant in all the code */ @@ -822,7 +822,7 @@ static void spoolss_notify_port_name(connection_struct *conn, int snum, SPOOL_NO * jfmxxxx: it's incorrect, should be lp_printerdrivername() * but it doesn't exist, have to see what to do ********************************************************************/ -static void spoolss_notify_driver_name(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->drivername); ascii_to_unistr(data->notify_data.data.string, @@ -833,7 +833,7 @@ static void spoolss_notify_driver_name(connection_struct *conn, int snum, SPOOL_ /******************************************************************* * fill a notify_info_data with the comment ********************************************************************/ -static void spoolss_notify_comment(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(lp_comment(snum)); ascii_to_unistr(data->notify_data.data.string, @@ -846,7 +846,7 @@ static void spoolss_notify_comment(connection_struct *conn, int snum, SPOOL_NOTI * jfm:xxxx incorrect, have to create a new smb.conf option * location = "Room 1, floor 2, building 3" ********************************************************************/ -static void spoolss_notify_location(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->location); ascii_to_unistr(data->notify_data.data.string, @@ -858,7 +858,7 @@ static void spoolss_notify_location(connection_struct *conn, int snum, SPOOL_NOT * fill a notify_info_data with the device mode * jfm:xxxx don't to it for know but that's a real problem !!! ********************************************************************/ -static void spoolss_notify_devmode(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { } @@ -867,7 +867,7 @@ static void spoolss_notify_devmode(connection_struct *conn, int snum, SPOOL_NOTI * jfm:xxxx just return no file could add an option to smb.conf * separator file = "separator.txt" ********************************************************************/ -static void spoolss_notify_sepfile(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->sepfile); ascii_to_unistr(data->notify_data.data.string, @@ -879,7 +879,7 @@ static void spoolss_notify_sepfile(connection_struct *conn, int snum, SPOOL_NOTI * fill a notify_info_data with the print processor * jfm:xxxx return always winprint to indicate we don't do anything to it ********************************************************************/ -static void spoolss_notify_print_processor(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->printprocessor); ascii_to_unistr(data->notify_data.data.string, @@ -891,7 +891,7 @@ static void spoolss_notify_print_processor(connection_struct *conn, int snum, SP * fill a notify_info_data with the print processor options * jfm:xxxx send an empty string ********************************************************************/ -static void spoolss_notify_parameters(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->parameters); ascii_to_unistr(data->notify_data.data.string, @@ -903,7 +903,7 @@ static void spoolss_notify_parameters(connection_struct *conn, int snum, SPOOL_N * fill a notify_info_data with the data type * jfm:xxxx always send RAW as data type ********************************************************************/ -static void spoolss_notify_datatype(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->datatype); ascii_to_unistr(data->notify_data.data.string, @@ -916,7 +916,7 @@ static void spoolss_notify_datatype(connection_struct *conn, int snum, SPOOL_NOT * jfm:xxxx send an null pointer to say no security desc * have to implement security before ! ********************************************************************/ -static void spoolss_notify_security_desc(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=0; data->notify_data.data.string[0]=0x00; @@ -926,7 +926,7 @@ static void spoolss_notify_security_desc(connection_struct *conn, int snum, SPOO * fill a notify_info_data with the attributes * jfm:xxxx a samba printer is always shared ********************************************************************/ -static void spoolss_notify_attributes(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0] = PRINTER_ATTRIBUTE_SHARED \ | PRINTER_ATTRIBUTE_NETWORK \ @@ -936,7 +936,7 @@ static void spoolss_notify_attributes(connection_struct *conn, int snum, SPOOL_N /******************************************************************* * fill a notify_info_data with the priority ********************************************************************/ -static void spoolss_notify_priority(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0] = printer->info_2->priority; } @@ -944,7 +944,7 @@ static void spoolss_notify_priority(connection_struct *conn, int snum, SPOOL_NOT /******************************************************************* * fill a notify_info_data with the default priority ********************************************************************/ -static void spoolss_notify_default_priority(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_default_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0] = printer->info_2->default_priority; } @@ -952,7 +952,7 @@ static void spoolss_notify_default_priority(connection_struct *conn, int snum, S /******************************************************************* * fill a notify_info_data with the start time ********************************************************************/ -static void spoolss_notify_start_time(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_start_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0] = printer->info_2->starttime; } @@ -960,7 +960,7 @@ static void spoolss_notify_start_time(connection_struct *conn, int snum, SPOOL_N /******************************************************************* * fill a notify_info_data with the until time ********************************************************************/ -static void spoolss_notify_until_time(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_until_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0] = printer->info_2->untiltime; } @@ -968,7 +968,7 @@ static void spoolss_notify_until_time(connection_struct *conn, int snum, SPOOL_N /******************************************************************* * fill a notify_info_data with the status ********************************************************************/ -static void spoolss_notify_status(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { int count; print_queue_struct *q=NULL; @@ -976,7 +976,7 @@ static void spoolss_notify_status(connection_struct *conn, int snum, SPOOL_NOTIF bzero(&status,sizeof(status)); - count=get_printqueue(snum, conn, &q, &status); + count=get_printqueue(snum, NULL, &q, &status); data->notify_data.value[0]=(uint32) status.status; if (q) free(q); @@ -985,21 +985,21 @@ static void spoolss_notify_status(connection_struct *conn, int snum, SPOOL_NOTIF /******************************************************************* * fill a notify_info_data with the number of jobs queued ********************************************************************/ -static void spoolss_notify_cjobs(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { print_queue_struct *q=NULL; print_status_struct status; bzero(&status,sizeof(status)); - data->notify_data.value[0]=get_printqueue(snum, conn, &q, &status); + data->notify_data.value[0]=get_printqueue(snum, NULL, &q, &status); if (q) free(q); } /******************************************************************* * fill a notify_info_data with the average ppm ********************************************************************/ -static void spoolss_notify_average_ppm(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { /* always respond 8 pages per minutes */ /* a little hard ! */ @@ -1009,7 +1009,7 @@ static void spoolss_notify_average_ppm(connection_struct *conn, int snum, SPOOL_ /******************************************************************* * fill a notify_info_data with ********************************************************************/ -static void spoolss_notify_username(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(queue->user); ascii_to_unistr(data->notify_data.data.string, queue->user, sizeof(data->notify_data.data.string)-1); @@ -1018,7 +1018,7 @@ static void spoolss_notify_username(connection_struct *conn, int snum, SPOOL_NOT /******************************************************************* * fill a notify_info_data with ********************************************************************/ -static void spoolss_notify_job_status(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0]=queue->status; } @@ -1026,7 +1026,7 @@ static void spoolss_notify_job_status(connection_struct *conn, int snum, SPOOL_N /******************************************************************* * fill a notify_info_data with ********************************************************************/ -static void spoolss_notify_job_name(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(queue->file); ascii_to_unistr(data->notify_data.data.string, queue->file, sizeof(data->notify_data.data.string)-1); @@ -1035,7 +1035,7 @@ static void spoolss_notify_job_name(connection_struct *conn, int snum, SPOOL_NOT /******************************************************************* * fill a notify_info_data with ********************************************************************/ -static void spoolss_notify_job_status_string(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen("En attente"); ascii_to_unistr(data->notify_data.data.string, "En attente", sizeof(data->notify_data.data.string)-1); @@ -1044,7 +1044,7 @@ static void spoolss_notify_job_status_string(connection_struct *conn, int snum, /******************************************************************* * fill a notify_info_data with ********************************************************************/ -static void spoolss_notify_job_time(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0]=0x0; } @@ -1052,7 +1052,7 @@ static void spoolss_notify_job_time(connection_struct *conn, int snum, SPOOL_NOT /******************************************************************* * fill a notify_info_data with ********************************************************************/ -static void spoolss_notify_job_size(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0]=queue->size; } @@ -1060,7 +1060,7 @@ static void spoolss_notify_job_size(connection_struct *conn, int snum, SPOOL_NOT /******************************************************************* * fill a notify_info_data with ********************************************************************/ -static void spoolss_notify_job_position(connection_struct *conn, int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0]=queue->job; } @@ -1219,7 +1219,7 @@ static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, * ********************************************************************/ static void construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int pnum, - int snum, int i, uint32 id, connection_struct *conn) + int snum, int i, uint32 id) { int k,j; @@ -1252,7 +1252,7 @@ static void construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int pnum, construct_info_data(info_data, type, field, id); DEBUGADD(4,("notify_info_data_table: in\n")); - notify_info_data_table[j].fn(conn,snum, info_data, queue, &printer); + notify_info_data_table[j].fn(snum, info_data, queue, &printer); DEBUGADD(4,("notify_info_data_table: out\n")); info->count++; info_data=&(info->data[info->count]); @@ -1269,7 +1269,7 @@ static void construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int pnum, * ********************************************************************/ static void construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, - int pnum, int snum, int i, uint32 id, connection_struct *conn) + int pnum, int snum, int i, uint32 id) { int k,j; @@ -1298,7 +1298,7 @@ static void construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I DEBUGADD(4,("j=[%d]:%s\n", j, notify_info_data_table[j].name)); construct_info_data(info_data, type, field, id); DEBUGADD(4,("notify_info_data_table: in\n")); - notify_info_data_table[j].fn(conn, snum, info_data, queue, &printer); + notify_info_data_table[j].fn(snum, info_data, queue, &printer); DEBUGADD(4,("notify_info_data_table: out\n")); info->count++; info_data=&(info->data[info->count]); @@ -1315,7 +1315,7 @@ static void construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I * fill a notify_info struct with info asked * ********************************************************************/ -static void printserver_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, connection_struct *conn) +static void printserver_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) { int snum; int pnum=find_printer_index_by_hnd(hnd); @@ -1334,7 +1334,7 @@ static void printserver_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, co { if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { - construct_notify_printer_info(info, pnum, snum, i, id, conn); + construct_notify_printer_info(info, pnum, snum, i, id); id++; } } @@ -1348,7 +1348,7 @@ static void printserver_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, co * fill a notify_info struct with info asked * ********************************************************************/ -static void printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, connection_struct *conn) +static void printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) { int snum; int pnum=find_printer_index_by_hnd(hnd); @@ -1365,7 +1365,7 @@ static void printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, connec { case PRINTER_NOTIFY_TYPE: { - construct_notify_printer_info(info, pnum, snum, i, id, conn); + construct_notify_printer_info(info, pnum, snum, i, id); id--; break; } @@ -1375,10 +1375,10 @@ static void printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, connec print_queue_struct *queue=NULL; print_status_struct status; bzero(&status, sizeof(status)); - count=get_printqueue(snum, conn, &queue, &status); + count=get_printqueue(snum, NULL, &queue, &status); for (j=0; jhandle)); @@ -1404,10 +1404,10 @@ static void spoolss_reply_rfnpcnex(SPOOL_Q_RFNPCNEX *q_u, prs_struct *rdata, con switch (Printer[pnum].printer_type) { case PRINTER_HANDLE_IS_PRINTSERVER: - printserver_notify_info(&(q_u->handle), &(r_u.info), conn); + printserver_notify_info(&(q_u->handle), &(r_u.info)); break; case PRINTER_HANDLE_IS_PRINTER: - printer_notify_info(&(q_u->handle), &(r_u.info), conn); + printer_notify_info(&(q_u->handle), &(r_u.info)); break; } @@ -1421,21 +1421,21 @@ static void spoolss_reply_rfnpcnex(SPOOL_Q_RFNPCNEX *q_u, prs_struct *rdata, con * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_rfnpcnex(pipes_struct *p, prs_struct *data, +static void api_spoolss_rfnpcnex(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_RFNPCNEX q_u; spoolss_io_q_rfnpcnex("", &q_u, data, 0); - spoolss_reply_rfnpcnex(&q_u, rdata, p->conn); + spoolss_reply_rfnpcnex(&q_u, rdata); } /******************************************************************** * construct_printer_info_0 * fill a printer_info_1 struct ********************************************************************/ -static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring servername, connection_struct *conn) +static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring servername) { pstring chaine; int count; @@ -1450,7 +1450,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring s return (False); } - count=get_printqueue(snum, conn ,&queue,&status); + count=get_printqueue(snum, NULL, &queue, &status); /* the description and the name are of the form \\server\share */ slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s",servername, ntprinter.info_2->printername); @@ -1501,7 +1501,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring s * construct_printer_info_1 * fill a printer_info_1 struct ********************************************************************/ -static BOOL construct_printer_info_1(PRINTER_INFO_1 *printer,int snum, pstring servername, connection_struct *conn) +static BOOL construct_printer_info_1(PRINTER_INFO_1 *printer,int snum, pstring servername) { pstring chaine; NT_PRINTER_INFO_LEVEL ntprinter; @@ -1593,7 +1593,7 @@ static void construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) * construct_printer_info_2 * fill a printer_info_2 struct ********************************************************************/ -static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring servername, connection_struct *conn) +static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring servername) { pstring chaine; int count; @@ -1603,7 +1603,7 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring print_queue_struct *queue=NULL; print_status_struct status; bzero(&status, sizeof(status)); - count=get_printqueue(snum, conn, &queue, &status); + count=get_printqueue(snum, NULL, &queue, &status); if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) { @@ -1654,14 +1654,14 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring * enum_printer_info_1 * glue between spoolss_reply_enumprinters and construct_printer_info_1 ********************************************************************/ -static BOOL enum_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number, connection_struct *conn) +static BOOL enum_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number) { pstring servername; *printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1)); DEBUG(4,("Allocated memory for ONE PRINTER_INFO_1 at [%p]\n", *printer)); pstrcpy(servername, global_myname); - if (!construct_printer_info_1(*printer, snum, servername, conn)) + if (!construct_printer_info_1(*printer, snum, servername)) { free(*printer); return (False); @@ -1676,14 +1676,14 @@ static BOOL enum_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number, * enum_printer_info_2 * glue between spoolss_reply_enumprinters and construct_printer_info_2 ********************************************************************/ -static BOOL enum_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number, connection_struct *conn) +static BOOL enum_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number) { pstring servername; *printer=(PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2)); DEBUG(4,("Allocated memory for ONE PRINTER_INFO_2 at [%p]\n", *printer)); pstrcpy(servername, global_myname); - if (!construct_printer_info_2(*printer, snum, servername, conn)) + if (!construct_printer_info_2(*printer, snum, servername)) { free(*printer); return (False); @@ -1699,7 +1699,7 @@ static BOOL enum_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number, * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number, connection_struct *conn) +static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number) { int snum; int n_services=lp_numservices(); @@ -1713,7 +1713,7 @@ static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number, DEBUG(4,("Found a printer: %s[%x]\n",lp_servicename(snum),snum)); *printers=Realloc(*printers, (*number+1)*sizeof(PRINTER_INFO_1 *)); DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1 pointers at [%p]\n", *number+1, *printers)); - if (enum_printer_info_1( &((*printers)[*number]), snum, *number, conn) ) + if (enum_printer_info_1( &((*printers)[*number]), snum, *number) ) { (*number)++; } @@ -1726,7 +1726,7 @@ static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number, * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number, connection_struct *conn) +static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number) { int snum; int n_services=lp_numservices(); @@ -1740,7 +1740,7 @@ static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number, DEBUG(4,("Found a printer: %s[%x]\n",lp_servicename(snum),snum)); *printers=Realloc(*printers, (*number+1)*sizeof(PRINTER_INFO_2 *)); DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2 pointers at [%p]\n", *number+1, *printers)); - if (enum_printer_info_2( &((*printers)[*number]), snum, *number, conn) ) + if (enum_printer_info_2( &((*printers)[*number]), snum, *number) ) { (*number)++; } @@ -1753,7 +1753,7 @@ static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number, * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -static void spoolss_reply_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *rdata, connection_struct *conn) +static void spoolss_reply_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *rdata) { SPOOL_R_ENUMPRINTERS r_u; @@ -1768,14 +1768,14 @@ static void spoolss_reply_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *rd case 1: if ( (q_u->flags==PRINTER_ENUM_NAME) || (q_u->flags==PRINTER_ENUM_NETWORK) ) /*if (is_a_printerserver(q_u->servername))*/ - enum_all_printers_info_1(&(r_u.printer.printers_1), &(r_u.returned), conn ); + enum_all_printers_info_1(&(r_u.printer.printers_1), &(r_u.returned) ); /*else enum_one_printer_info_1(&r_u);*/ break; case 2: if ( (q_u->flags==PRINTER_ENUM_NAME) || (q_u->flags==PRINTER_ENUM_NETWORK) ) /*if (is_a_printerserver(q_u->servername))*/ - enum_all_printers_info_2(&(r_u.printer.printers_2), &(r_u.returned), conn ); + enum_all_printers_info_2(&(r_u.printer.printers_2), &(r_u.returned) ); /*else enum_one_printer_info_2(&r_u);*/ break; @@ -1800,14 +1800,14 @@ static void spoolss_reply_enumprinters(SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *rd * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_enumprinters(pipes_struct *p, prs_struct *data, +static void api_spoolss_enumprinters(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPRINTERS q_u; spoolss_io_q_enumprinters("", &q_u, data, 0); - spoolss_reply_enumprinters(&q_u, rdata, p->conn); + spoolss_reply_enumprinters(&q_u, rdata); spoolss_io_free_buffer(&(q_u.buffer)); } @@ -1815,7 +1815,7 @@ static void api_spoolss_enumprinters(pipes_struct *p, prs_struct *data, /**************************************************************************** ****************************************************************************/ -static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata, connection_struct *conn) +static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata) { SPOOL_R_GETPRINTER r_u; int snum; @@ -1833,7 +1833,7 @@ static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata, printer=(PRINTER_INFO_0 *)malloc(sizeof(PRINTER_INFO_0)); - construct_printer_info_0(printer, snum, servername, conn); + construct_printer_info_0(printer, snum, servername); r_u.printer.info0=printer; r_u.status=0x0000; r_u.offered=q_u->offered; @@ -1851,7 +1851,7 @@ static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata, printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1)); - construct_printer_info_1(printer, snum, servername, conn); + construct_printer_info_1(printer, snum, servername); r_u.printer.info1=printer; r_u.status=0x0000; @@ -1868,7 +1868,7 @@ static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata, PRINTER_INFO_2 *printer; printer=(PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2)); - construct_printer_info_2(printer, snum, servername, conn); + construct_printer_info_2(printer, snum, servername); r_u.printer.info2=printer; r_u.status=0x0000; @@ -1888,14 +1888,14 @@ static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata, * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_getprinter(pipes_struct *p, prs_struct *data, +static void api_spoolss_getprinter(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_GETPRINTER q_u; spoolss_io_q_getprinter("", &q_u, data, 0); - spoolss_reply_getprinter(&q_u, rdata, p->conn); + spoolss_reply_getprinter(&q_u, rdata); } /******************************************************************** @@ -2149,7 +2149,7 @@ static void spoolss_reply_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_ * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_getprinterdriver2(pipes_struct *p, prs_struct *data, +static void api_spoolss_getprinterdriver2(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_GETPRINTERDRIVER2 q_u; @@ -2186,7 +2186,7 @@ static void spoolss_reply_startpageprinter(SPOOL_Q_STARTPAGEPRINTER *q_u, prs_st * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_startpageprinter(pipes_struct *p, prs_struct *data, +static void api_spoolss_startpageprinter(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_STARTPAGEPRINTER q_u; @@ -2221,7 +2221,7 @@ static void spoolss_reply_endpageprinter(SPOOL_Q_ENDPAGEPRINTER *q_u, prs_struct * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_endpageprinter(pipes_struct *p, prs_struct *data, +static void api_spoolss_endpageprinter(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENDPAGEPRINTER q_u; @@ -2236,7 +2236,7 @@ static void api_spoolss_endpageprinter(pipes_struct *p, prs_struct *data, * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_startdocprinter(pipes_struct *p, prs_struct *data, +static void api_spoolss_startdocprinter(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_STARTDOCPRINTER q_u; @@ -2331,7 +2331,7 @@ static void spoolss_reply_enddocprinter(SPOOL_Q_ENDDOCPRINTER *q_u, prs_struct * * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_enddocprinter(pipes_struct *p, prs_struct *data, +static void api_spoolss_enddocprinter(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENDDOCPRINTER q_u; @@ -2431,7 +2431,7 @@ static void spoolss_reply_writeprinter(SPOOL_Q_WRITEPRINTER *q_u, prs_struct *rd * called from the spoolss dispatcher * ********************************************************************/ -static void api_spoolss_writeprinter(pipes_struct *p, prs_struct *data, +static void api_spoolss_writeprinter(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_WRITEPRINTER q_u; @@ -2458,7 +2458,7 @@ static void api_spoolss_writeprinter(pipes_struct *p, prs_struct *data, * called from the spoolss dispatcher * ********************************************************************/ -static void control_printer(POLICY_HND handle, uint32 command, connection_struct *conn) +static void control_printer(POLICY_HND handle, uint32 command) { int pnum; int snum; @@ -2470,13 +2470,13 @@ static void control_printer(POLICY_HND handle, uint32 command, connection_struct { case PRINTER_CONTROL_PAUSE: /* pause the printer here */ - status_printqueue(conn, snum, LPSTAT_STOPPED); + status_printqueue(NULL, snum, LPSTAT_STOPPED); break; case PRINTER_CONTROL_RESUME: case PRINTER_CONTROL_UNPAUSE: /* UN-pause the printer here */ - status_printqueue(conn, snum, LPSTAT_OK); + status_printqueue(NULL, snum, LPSTAT_OK); break; case PRINTER_CONTROL_PURGE: /* Envoi des dragées FUCA dans l'imprimante */ @@ -2573,7 +2573,7 @@ static void spoolss_reply_setprinter(SPOOL_Q_SETPRINTER *q_u, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static void api_spoolss_setprinter(pipes_struct *p, prs_struct *data, +static void api_spoolss_setprinter(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_SETPRINTER q_u; @@ -2588,7 +2588,7 @@ static void api_spoolss_setprinter(pipes_struct *p, prs_struct *data, switch (q_u.level) { case 0: - control_printer(q_u.handle, q_u.command, p->conn); + control_printer(q_u.handle, q_u.command); break; case 2: update_printer(q_u.handle, q_u.level, q_u.info, q_u.devmode); @@ -2611,7 +2611,7 @@ static void spoolss_reply_fcpn(SPOOL_Q_FCPN *q_u, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static void api_spoolss_fcpn(pipes_struct *p, prs_struct *data, +static void api_spoolss_fcpn(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_FCPN q_u; @@ -2634,7 +2634,7 @@ static void spoolss_reply_addjob(SPOOL_Q_ADDJOB *q_u, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static void api_spoolss_addjob(pipes_struct *p, prs_struct *data, +static void api_spoolss_addjob(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ADDJOB q_u; @@ -2734,7 +2734,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, /**************************************************************************** ****************************************************************************/ -static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata, connection_struct *conn) +static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata) { SPOOL_R_ENUMJOBS r_u; int snum; @@ -2754,7 +2754,7 @@ static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata, con if (get_printer_snum(&(q_u->handle), &snum)) { - count=get_printqueue(snum, conn, &queue, &status); + count=get_printqueue(snum, NULL, &queue, &status); r_u.numofjobs=0; r_u.level=q_u->level; @@ -2801,14 +2801,14 @@ static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata, con /**************************************************************************** ****************************************************************************/ -static void api_spoolss_enumjobs(pipes_struct *p, prs_struct *data, +static void api_spoolss_enumjobs(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMJOBS q_u; spoolss_io_q_enumjobs("", &q_u, data, 0); - spoolss_reply_enumjobs(&q_u, rdata, p->conn); + spoolss_reply_enumjobs(&q_u, rdata); spoolss_io_free_buffer(&(q_u.buffer)); } @@ -2826,7 +2826,7 @@ static void spoolss_reply_schedulejob(SPOOL_Q_SCHEDULEJOB *q_u, prs_struct *rdat /**************************************************************************** ****************************************************************************/ -static void api_spoolss_schedulejob(pipes_struct *p, prs_struct *data, +static void api_spoolss_schedulejob(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_SCHEDULEJOB q_u; @@ -2838,7 +2838,7 @@ static void api_spoolss_schedulejob(pipes_struct *p, prs_struct *data, /**************************************************************************** ****************************************************************************/ -static void spoolss_reply_setjob(SPOOL_Q_SETJOB *q_u, prs_struct *rdata, connection_struct *conn) +static void spoolss_reply_setjob(SPOOL_Q_SETJOB *q_u, prs_struct *rdata) { SPOOL_R_SETJOB r_u; int snum; @@ -2852,7 +2852,7 @@ static void spoolss_reply_setjob(SPOOL_Q_SETJOB *q_u, prs_struct *rdata, connect if (get_printer_snum(&(q_u->handle), &snum)) { - count=get_printqueue(snum, conn, &queue, &status); + count=get_printqueue(snum, NULL, &queue, &status); while ( (ijobid == queue[i].job ) @@ -2869,17 +2869,17 @@ static void spoolss_reply_setjob(SPOOL_Q_SETJOB *q_u, prs_struct *rdata, connect case JOB_CONTROL_CANCEL: case JOB_CONTROL_DELETE: { - del_printqueue(conn, snum, q_u->jobid); + del_printqueue(NULL, snum, q_u->jobid); break; } case JOB_CONTROL_PAUSE: { - status_printjob(conn, snum, q_u->jobid, LPQ_PAUSED); + status_printjob(NULL, snum, q_u->jobid, LPQ_PAUSED); break; } case JOB_CONTROL_RESUME: { - status_printjob(conn, snum, q_u->jobid, LPQ_QUEUED); + status_printjob(NULL, snum, q_u->jobid, LPQ_QUEUED); break; } } @@ -2893,19 +2893,19 @@ static void spoolss_reply_setjob(SPOOL_Q_SETJOB *q_u, prs_struct *rdata, connect /**************************************************************************** ****************************************************************************/ -static void api_spoolss_setjob(pipes_struct *p, prs_struct *data, +static void api_spoolss_setjob(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_SETJOB q_u; spoolss_io_q_setjob("", &q_u, data, 0); - spoolss_reply_setjob(&q_u, rdata, p->conn); + spoolss_reply_setjob(&q_u, rdata); } /**************************************************************************** ****************************************************************************/ -static void spoolss_reply_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *rdata, connection_struct *conn) +static void spoolss_reply_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *rdata) { SPOOL_R_ENUMPRINTERDRIVERS r_u; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -2922,7 +2922,7 @@ static void spoolss_reply_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, pr fstrcpy(servername, global_myname); unistr2_to_ascii(architecture, &(q_u->environment), sizeof(architecture)); - count=get_ntdrivers(conn, &list, architecture); + count=get_ntdrivers(&list, architecture); DEBUGADD(4,("we have: [%d] drivers on archi [%s]\n",count, architecture)); for (i=0; iconn); + spoolss_reply_enumprinterdrivers(&q_u, rdata); spoolss_io_free_buffer(&(q_u.buffer)); } @@ -3095,7 +3095,7 @@ static void spoolss_reply_enumforms(SPOOL_Q_ENUMFORMS *q_u, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static void api_spoolss_enumforms(pipes_struct *p, prs_struct *data, +static void api_spoolss_enumforms(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMFORMS q_u; @@ -3167,7 +3167,7 @@ static void spoolss_reply_enumports(SPOOL_Q_ENUMPORTS *q_u, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static void api_spoolss_enumports(pipes_struct *p, prs_struct *data, +static void api_spoolss_enumports(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPORTS q_u; @@ -3213,7 +3213,7 @@ static void spoolss_reply_addprinterex(SPOOL_Q_ADDPRINTEREX *q_u, prs_struct *rd /**************************************************************************** ****************************************************************************/ -static void api_spoolss_addprinterex(pipes_struct *p, prs_struct *data, prs_struct *rdata) +static void api_spoolss_addprinterex(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ADDPRINTEREX q_u; NT_PRINTER_INFO_LEVEL printer; @@ -3250,7 +3250,7 @@ static void spoolss_reply_addprinterdriver(SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_st /**************************************************************************** ****************************************************************************/ -static void api_spoolss_addprinterdriver(pipes_struct *p, prs_struct *data, +static void api_spoolss_addprinterdriver(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ADDPRINTERDRIVER q_u; @@ -3293,7 +3293,7 @@ static void spoolss_reply_getprinterdriverdirectory(SPOOL_Q_GETPRINTERDRIVERDIR /**************************************************************************** ****************************************************************************/ -static void api_spoolss_getprinterdriverdirectory(pipes_struct *p, prs_struct *data, +static void api_spoolss_getprinterdriverdirectory(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_GETPRINTERDRIVERDIR q_u; @@ -3405,7 +3405,7 @@ static void spoolss_reply_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, prs_stru /**************************************************************************** ****************************************************************************/ -static void api_spoolss_enumprinterdata(pipes_struct *p, prs_struct *data, +static void api_spoolss_enumprinterdata(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPRINTERDATA q_u; @@ -3451,7 +3451,7 @@ static void spoolss_reply_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, prs_struct /**************************************************************************** ****************************************************************************/ -static void api_spoolss_setprinterdata(pipes_struct *p, prs_struct *data, +static void api_spoolss_setprinterdata(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_SETPRINTERDATA q_u; @@ -3493,7 +3493,7 @@ static void spoolss_reply_addform(SPOOL_Q_ADDFORM *q_u, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static void api_spoolss_addform(pipes_struct *p, prs_struct *data, +static void api_spoolss_addform(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ADDFORM q_u; @@ -3532,7 +3532,7 @@ static void spoolss_reply_setform(SPOOL_Q_SETFORM *q_u, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static void api_spoolss_setform(pipes_struct *p, prs_struct *data, +static void api_spoolss_setform(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_SETFORM q_u; @@ -3577,7 +3577,7 @@ static void spoolss_reply_enumprintprocessors(SPOOL_Q_ENUMPRINTPROCESSORS *q_u, /**************************************************************************** ****************************************************************************/ -static void api_spoolss_enumprintprocessors(pipes_struct *p, prs_struct *data, +static void api_spoolss_enumprintprocessors(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPRINTPROCESSORS q_u; @@ -3624,7 +3624,7 @@ static void spoolss_reply_enumprintmonitors(SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_ /**************************************************************************** ****************************************************************************/ -static void api_spoolss_enumprintmonitors(pipes_struct *p, prs_struct *data, +static void api_spoolss_enumprintmonitors(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPRINTMONITORS q_u; @@ -3638,7 +3638,7 @@ static void api_spoolss_enumprintmonitors(pipes_struct *p, prs_struct *data, /**************************************************************************** ****************************************************************************/ -static void spoolss_reply_getjob(SPOOL_Q_GETJOB *q_u, prs_struct *rdata, connection_struct *conn) +static void spoolss_reply_getjob(SPOOL_Q_GETJOB *q_u, prs_struct *rdata) { SPOOL_R_GETJOB r_u; int snum; @@ -3657,7 +3657,7 @@ static void spoolss_reply_getjob(SPOOL_Q_GETJOB *q_u, prs_struct *rdata, connect if (get_printer_snum(&(q_u->handle), &snum)) { - count=get_printqueue(snum, conn, &queue, &status); + count=get_printqueue(snum, NULL, &queue, &status); r_u.level=q_u->level; @@ -3719,14 +3719,14 @@ static void spoolss_reply_getjob(SPOOL_Q_GETJOB *q_u, prs_struct *rdata, connect /**************************************************************************** ****************************************************************************/ -static void api_spoolss_getjob(pipes_struct *p, prs_struct *data, +static void api_spoolss_getjob(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) { SPOOL_Q_GETJOB q_u; spoolss_io_q_getjob("", &q_u, data, 0); - spoolss_reply_getjob(&q_u, rdata, p->conn); + spoolss_reply_getjob(&q_u, rdata); spoolss_io_free_buffer(&(q_u.buffer)); } @@ -3774,7 +3774,7 @@ struct api_struct api_spoolss_cmds[] = /******************************************************************* receives a spoolss pipe and responds. ********************************************************************/ -BOOL api_spoolss_rpc(pipes_struct *p, prs_struct *data) +BOOL api_spoolss_rpc(rpcsrv_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds, data); } diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 35f1676232..8dd99cccc6 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -972,7 +972,7 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, /******************************************************************* ********************************************************************/ -static void api_srv_net_srv_get_info( pipes_struct *p, prs_struct *data, +static void api_srv_net_srv_get_info( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SRV_GET_INFO q_n; @@ -987,7 +987,7 @@ static void api_srv_net_srv_get_info( pipes_struct *p, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_file_enum( pipes_struct *p, prs_struct *data, +static void api_srv_net_file_enum( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_FILE_ENUM q_n; @@ -1005,7 +1005,7 @@ static void api_srv_net_file_enum( pipes_struct *p, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_conn_enum( pipes_struct *p, prs_struct *data, +static void api_srv_net_conn_enum( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_CONN_ENUM q_n; @@ -1023,7 +1023,7 @@ static void api_srv_net_conn_enum( pipes_struct *p, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_sess_enum( pipes_struct *p, prs_struct *data, +static void api_srv_net_sess_enum( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SESS_ENUM q_n; @@ -1041,7 +1041,7 @@ static void api_srv_net_sess_enum( pipes_struct *p, prs_struct *data, /******************************************************************* ********************************************************************/ -static void api_srv_net_share_enum( pipes_struct *p, prs_struct *data, +static void api_srv_net_share_enum( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SHARE_ENUM q_n; @@ -1097,7 +1097,7 @@ static void srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n, } /******************************************************************* ********************************************************************/ -static void api_srv_net_remote_tod( pipes_struct *p, prs_struct *data, +static void api_srv_net_remote_tod( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_REMOTE_TOD q_n; @@ -1127,7 +1127,7 @@ struct api_struct api_srv_cmds[] = /******************************************************************* receives a srvsvc pipe and responds. ********************************************************************/ -BOOL api_srvsvc_rpc(pipes_struct *p, prs_struct *data) +BOOL api_srvsvc_rpc(rpcsrv_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_srvsvc_rpc", api_srv_cmds, data); } diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index e67cafb9df..12f0bdf3b3 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -61,7 +61,7 @@ static void svc_reply_close(SVC_Q_CLOSE *q_r, /******************************************************************* api_svc_close ********************************************************************/ -static void api_svc_close( pipes_struct *p, prs_struct *data, +static void api_svc_close( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { SVC_Q_CLOSE q_r; @@ -117,7 +117,7 @@ static void svc_reply_open_service(SVC_Q_OPEN_SERVICE *q_u, /******************************************************************* api_svc_open_service ********************************************************************/ -static void api_svc_open_service( pipes_struct *p, prs_struct *data, +static void api_svc_open_service( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { SVC_Q_OPEN_SERVICE q_u; @@ -153,7 +153,7 @@ static void svc_reply_start_service(SVC_Q_START_SERVICE *q_s, /******************************************************************* api_svc_start_service ********************************************************************/ -static void api_svc_start_service( pipes_struct *p, prs_struct *data, +static void api_svc_start_service( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { SVC_Q_START_SERVICE q_u; @@ -203,7 +203,7 @@ static void svc_reply_open_sc_man(SVC_Q_OPEN_SC_MAN *q_u, /******************************************************************* api_svc_open_sc_man ********************************************************************/ -static void api_svc_open_sc_man( pipes_struct *p, prs_struct *data, +static void api_svc_open_sc_man( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { SVC_Q_OPEN_SC_MAN q_u; @@ -318,7 +318,7 @@ static void svc_reply_enum_svcs_status(SVC_Q_ENUM_SVCS_STATUS *q_u, /******************************************************************* api_svc_enum_svcs_status ********************************************************************/ -static void api_svc_enum_svcs_status( pipes_struct *p, prs_struct *data, +static void api_svc_enum_svcs_status( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { SVC_Q_ENUM_SVCS_STATUS q_u; @@ -356,7 +356,7 @@ static void svc_reply_query_disp_name(SVC_Q_QUERY_DISP_NAME *q_u, /******************************************************************* api_svc_query_disp_name ********************************************************************/ -static void api_svc_query_disp_name( pipes_struct *p, prs_struct *data, +static void api_svc_query_disp_name( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { SVC_Q_QUERY_DISP_NAME q_u; @@ -381,7 +381,7 @@ static struct api_struct api_svc_cmds[] = /******************************************************************* receives a svcctl pipe and responds. ********************************************************************/ -BOOL api_svcctl_rpc(pipes_struct *p, prs_struct *data) +BOOL api_svcctl_rpc(rpcsrv_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_svc_rpc", api_svc_cmds, data); } diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 9b0b0a3ca8..e97ae1ee6e 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -80,7 +80,7 @@ static void wks_reply_query_info(WKS_Q_QUERY_INFO *q_u, /******************************************************************* api_wks_query_info ********************************************************************/ -static void api_wks_query_info( pipes_struct *p, prs_struct *data, +static void api_wks_query_info( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata ) { WKS_Q_QUERY_INFO q_u; @@ -105,7 +105,7 @@ struct api_struct api_wks_cmds[] = /******************************************************************* receives a wkssvc pipe and responds. ********************************************************************/ -BOOL api_wkssvc_rpc(pipes_struct *p, prs_struct *data) +BOOL api_wkssvc_rpc(rpcsrv_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_wkssvc_rpc", api_wks_cmds, data); } -- cgit From 4f8a24522c683761c6f2ee23dba56f6c7913377b Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 12 Dec 1999 20:03:42 +0000 Subject: final part of "first" phase converting over to msrpc daemon architecture. done a minimal amout of clean-up in the Makefile, removing unnecessary modules from the link stage. this is not complete, yet, and will involve some changes, for example to smbd, to remove dependencies on the password database API that shouldn't be there. for example, smbd should not ever call getsmbpwXXX() it should call the Samr or Lsa API. this first implementation has minor problems with not reinstantiating the same services as the caller. the "homes" service is a good example. (This used to be commit caa50525220b0d0250fa139367593c2de2c12135) --- source3/rpc_server/srv_brs.c | 2 +- source3/rpc_server/srv_netlog.c | 7 +++++++ source3/rpc_server/srv_pipe.c | 30 ++++-------------------------- source3/rpc_server/srv_pipe_hnd.c | 14 +++++++------- 4 files changed, 19 insertions(+), 34 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_brs.c b/source3/rpc_server/srv_brs.c index cde5a79beb..c9abab20be 100644 --- a/source3/rpc_server/srv_brs.c +++ b/source3/rpc_server/srv_brs.c @@ -93,6 +93,6 @@ struct api_struct api_brs_cmds[] = ********************************************************************/ BOOL api_brs_rpc(rpcsrv_struct *p, prs_struct *data) { - return api_rpcTNP(p, "api_brssvc_rpc", api_brs_cmds, data); + return api_rpcTNP(p, "api_brs_rpc", api_brs_cmds, data); } diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 22788508eb..9721b3bf00 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -334,6 +334,13 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) return True; } + if (strequal(mach_name, global_myname)) + { + DEBUG(0,("get_md4pw: *** LOOPBACK DETECTED - USING NULL KEY ***\n")); + memset(md4pw, 0, 16); + return True; + } + DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); return False; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 73a06b208c..d15cc1248c 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -231,8 +231,6 @@ static BOOL api_pipe_ntlmssp_verify(rpcsrv_struct *l) size_t wks_len; BOOL anonymous = False; - struct smb_passwd *smb_pass = NULL; - memset(null_pwd, 0, sizeof(null_pwd)); DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); @@ -304,19 +302,13 @@ static BOOL api_pipe_ntlmssp_verify(rpcsrv_struct *l) else { DEBUG(5,("user: %s domain: %s wks: %s\n", l->user_name, l->domain, l->wks)); - become_root(True); - smb_pass = getsmbpwnam(l->user_name); - l->ntlmssp_validated = pass_check_smb(smb_pass, l->domain, + become_root(False); + l->ntlmssp_validated = check_domain_security(l->user_name, l->domain, (uchar*)l->ntlmssp_chal.challenge, lm_owf, lm_owf_len, nt_owf, nt_owf_len, - NULL, l->user_sess_key); - unbecome_root(True); - - if (smb_pass != NULL) - { - pwd = smb_pass->smb_passwd; - } + l->user_sess_key); + unbecome_root(False); } if (l->ntlmssp_validated && pwd != NULL) @@ -463,20 +455,6 @@ static struct api_cmd* add_api_cmd_to_array(uint32 *len, } -#if 0 -{ - { "lsarpc", "lsass", api_ntlsa_rpc }, - { "samr", "lsass", api_samr_rpc }, - { "srvsvc", "ntsvcs", api_srvsvc_rpc }, - { "wkssvc", "ntsvcs", api_wkssvc_rpc }, - { "browser", "ntsvcs", api_brs_rpc }, - { "svcctl", "ntsvcs", api_svcctl_rpc }, - { "NETLOGON", "lsass", api_netlog_rpc }, - { "winreg", "winreg", api_reg_rpc }, - { "spoolss", "spoolss", api_spoolss_rpc }, - { NULL, NULL, NULL } -}; -#endif void close_msrpc_command_processor(void) { diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 8a28674d3d..f8bde1bf9b 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -135,14 +135,13 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, DEBUG(5,("open pipes: name %s pnum=%x\n", p->name, p->pnum)); } - if (strequal(pipe_name, "lsarpc")) + m = msrpc_use_add(pipe_name, &usr, False); + if (m == NULL) { - m = msrpc_use_add(pipe_name, &usr, False); - if (m == NULL) - { - DEBUG(5,("open pipes: msrpc redirect failed\n")); - return NULL; - } + DEBUG(5,("open pipes: msrpc redirect failed\n")); + return NULL; + } +#if 0 } else { @@ -164,6 +163,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, memcpy(l->user_sess_key, vuser->user_sess_key, sizeof(l->user_sess_key)); } +#endif p = (pipes_struct *)malloc(sizeof(*p)); if (!p) return NULL; -- cgit From 3db52feb1f3b2c07ce0b06ad4a7099fa6efe3fc7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:27:58 +0000 Subject: first pass at updating head branch to be to be the same as the SAMBA_2_0 branch (This used to be commit 453a822a76780063dff23526c35408866d0c0154) --- source3/rpc_server/srv_lookup.c | 592 +++++--- source3/rpc_server/srv_lsa.c | 507 ++++--- source3/rpc_server/srv_lsa_hnd.c | 245 +-- source3/rpc_server/srv_netlog.c | 934 ++++++------ source3/rpc_server/srv_pipe.c | 1510 ++++++++++--------- source3/rpc_server/srv_pipe_hnd.c | 371 ++--- source3/rpc_server/srv_reg.c | 59 +- source3/rpc_server/srv_samr.c | 2962 ++++++++++--------------------------- source3/rpc_server/srv_srvsvc.c | 640 ++++---- source3/rpc_server/srv_util.c | 323 +++- source3/rpc_server/srv_wkssvc.c | 10 +- 11 files changed, 3409 insertions(+), 4744 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index 193c7931ab..e6df9933bf 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -52,6 +52,44 @@ extern fstring global_sam_name; extern DOM_SID global_sam_sid; extern DOM_SID global_sid_S_1_5_20; +/* + * A list of the rids of well known BUILTIN and Domain users + * and groups. + */ + +rid_name builtin_alias_rids[] = +{ + { BUILTIN_ALIAS_RID_ADMINS , "Administrators" }, + { BUILTIN_ALIAS_RID_USERS , "Users" }, + { BUILTIN_ALIAS_RID_GUESTS , "Guests" }, + { BUILTIN_ALIAS_RID_POWER_USERS , "Power Users" }, + + { BUILTIN_ALIAS_RID_ACCOUNT_OPS , "Account Operators" }, + { BUILTIN_ALIAS_RID_SYSTEM_OPS , "System Operators" }, + { BUILTIN_ALIAS_RID_PRINT_OPS , "Print Operators" }, + { BUILTIN_ALIAS_RID_BACKUP_OPS , "Backup Operators" }, + { BUILTIN_ALIAS_RID_REPLICATOR , "Replicator" }, + { 0 , NULL } +}; + +/* array lookup of well-known Domain RID users. */ +rid_name domain_user_rids[] = +{ + { DOMAIN_USER_RID_ADMIN , "Administrator" }, + { DOMAIN_USER_RID_GUEST , "Guest" }, + { 0 , NULL } +}; + +/* array lookup of well-known Domain RID groups. */ +rid_name domain_group_rids[] = +{ + { DOMAIN_GROUP_RID_ADMINS , "Domain Admins" }, + { DOMAIN_GROUP_RID_USERS , "Domain Users" }, + { DOMAIN_GROUP_RID_GUESTS , "Domain Guests" }, + { 0 , NULL } +}; + + int make_dom_gids(DOMAIN_GRP *mem, int num_members, DOM_GID **ppgids) { int count; @@ -72,27 +110,17 @@ int make_dom_gids(DOMAIN_GRP *mem, int num_members, DOM_GID **ppgids) uint32 status; uint32 rid; - DOM_SID sid; uint8 type; uint8 attr = mem[count].attr; char *name = mem[count].name; become_root(True); - status = lookup_name(name, &sid, &type); + status = lookup_grp_rid(name, &rid, &type); unbecome_root(True); - if (status == 0x0 && !sid_front_equal(&global_sam_sid, &sid)) - { - fstring sid_str; - sid_to_string(sid_str, &sid); - DEBUG(1,("make_dom_gids: unknown sid %s for groupname %s\n", - sid_str, name)); - } - else if (status == 0x0) + if (status == 0x0) { - sid_split_rid(&sid, &rid); - gids = (DOM_GID *)Realloc( gids, sizeof(DOM_GID) * (count+1) ); if (gids == NULL) @@ -110,7 +138,7 @@ int make_dom_gids(DOMAIN_GRP *mem, int num_members, DOM_GID **ppgids) } else { - DEBUG(1,("make_dom_gids: unknown groupname %s\n", name)); + DEBUG(1,("make_dom_gids: unknown group name %s\n", name)); } } @@ -140,286 +168,282 @@ int get_domain_user_groups(DOMAIN_GRP_MEMBER **grp_members, uint32 group_rid) /******************************************************************* - lookup_builtin_sid + lookup_builtin_names ********************************************************************/ -uint32 lookup_builtin_sid(DOM_SID *sid, char *name, uint8 *type) +uint32 lookup_builtin_names(uint32 rid, char *name, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_wk_user_sid (sid, name, type) : status; - status = (status != 0x0) ? lookup_wk_group_sid(sid, name, type) : status; - status = (status != 0x0) ? lookup_wk_alias_sid(sid, name, type) : status; + status = (status != 0x0) ? lookup_wk_user_name (rid, name, type) : status; + status = (status != 0x0) ? lookup_wk_group_name(rid, name, type) : status; + status = (status != 0x0) ? lookup_wk_alias_name(rid, name, type) : status; return status; } /******************************************************************* - lookup_added_sid - names that have been added to the SAM database by admins. + lookup_added_name - names that have been added to the SAM database by admins. ********************************************************************/ -uint32 lookup_added_sid(DOM_SID *sid, char *name, uint8 *type) +uint32 lookup_added_name(uint32 rid, char *name, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_user_sid (sid, name, type) : status; - status = (status != 0x0) ? lookup_group_sid(sid, name, type) : status; - status = (status != 0x0) ? lookup_alias_sid(sid, name, type) : status; + status = (status != 0x0) ? lookup_user_name (rid, name, type) : status; + status = (status != 0x0) ? lookup_group_name(rid, name, type) : status; + status = (status != 0x0) ? lookup_alias_name(rid, name, type) : status; return status; } /******************************************************************* - lookup_sid + lookup_name ********************************************************************/ -uint32 lookup_sid(DOM_SID *sid, char *name, uint8 *type) +uint32 lookup_name(uint32 rid, char *name, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_builtin_sid(sid, name, type) : status; - status = (status != 0x0) ? lookup_added_sid (sid, name, type) : status; + status = (status != 0x0) ? lookup_builtin_names(rid, name, type) : status; + status = (status != 0x0) ? lookup_added_name (rid, name, type) : status; return status; } /******************************************************************* - lookup_wk_group_sid + lookup_wk_group_name ********************************************************************/ -uint32 lookup_wk_group_sid(DOM_SID *sid, char *group_name, uint8 *type) +uint32 lookup_wk_group_name(uint32 rid, char *group_name, uint8 *type) { - uint32 rid; - DOM_SID tmp; - char *mapped; + int i = 0; + (*type) = SID_NAME_WKN_GRP; - (*type) = SID_NAME_DOM_GRP; - - sid_copy(&tmp, sid); - sid_split_rid(&tmp, &rid); + DEBUG(5,("lookup_wk_group_name: rid: %d", rid)); - if (!sid_equal(&global_sid_S_1_5_20, &tmp)) + while (domain_group_rids[i].rid != rid && domain_group_rids[i].rid != 0) { - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + i++; } - DEBUG(5,("lookup_wk_group_sid: rid: %d", rid)); - - /* look up the well-known domain group rids first */ - mapped = lookup_wk_group_rid(rid); - if(mapped == NULL) + if (domain_group_rids[i].rid != 0) { - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + fstrcpy(group_name, domain_group_rids[i].name); + DEBUG(5,(" = %s\n", group_name)); + return 0x0; } - fstrcpy(group_name, mapped); - DEBUG(5,(" = %s\n", group_name)); - return 0x0; + + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; } /******************************************************************* - lookup_group_sid + lookup_group_name ********************************************************************/ -uint32 lookup_group_sid(DOM_SID *sid, char *group_name, uint8 *type) +uint32 lookup_group_name(uint32 rid, char *group_name, uint8 *type) { - pstring sid_str; - uint32 rid; - DOM_SID tmp; - DOMAIN_GRP *grp = NULL; uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + DOM_SID sid; - (*type) = SID_NAME_DOM_GRP; + DEBUG(5,("lookup_group_name: rid: 0x%x", rid)); - sid_to_string(sid_str, sid); - DEBUG(5,("lookup_group_sid: sid: %s", sid_str)); + sid_copy (&sid, &global_sam_sid); + sid_append_rid(&sid, rid); - sid_copy(&tmp, sid); - sid_split_rid(&tmp, &rid); + (*type) = SID_NAME_DOM_GRP; - if (!sid_equal(&global_sam_sid, &tmp)) + if (map_group_sid_to_name(&sid, group_name, NULL)) { - DEBUG(5,("not our SID\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + status = 0x0; } - grp = getgrouprid(rid, NULL, NULL); - - if (grp != NULL) + if (status == 0x0) { - fstrcpy(group_name, grp->name); DEBUG(5,(" = %s\n", group_name)); - return 0x0; + } + else + { + DEBUG(5,(" none mapped\n")); } - DEBUG(5,(" none mapped\n")); return status; } /******************************************************************* - lookup_wk_alias_sid + lookup_wk_alias_name ********************************************************************/ -uint32 lookup_wk_alias_sid(DOM_SID *sid, char *alias_name, uint8 *type) +uint32 lookup_wk_alias_name(uint32 rid, char *alias_name, uint8 *type) { - uint32 rid; - DOM_SID tmp; - char *mapped; - + int i = 0; (*type) = SID_NAME_ALIAS; - sid_copy(&tmp, sid); - sid_split_rid(&tmp, &rid); + DEBUG(5,("lookup_wk_alias_name: rid: %d", rid)); - if (!sid_equal(&global_sid_S_1_5_20, &tmp)) + while (builtin_alias_rids[i].rid != rid && builtin_alias_rids[i].rid != 0) { - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + i++; } - DEBUG(5,("lookup_wk_alias_sid: rid: %d", rid)); - - /* look up the well-known alias group rids first */ - mapped = lookup_wk_alias_rid(rid); - if(mapped == NULL) + if (builtin_alias_rids[i].rid != 0) { - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + fstrcpy(alias_name, builtin_alias_rids[i].name); + DEBUG(5,(" = %s\n", alias_name)); + return 0x0; } - fstrcpy(alias_name, mapped); - DEBUG(5,(" = %s\n", alias_name)); - return 0x0; + + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; } /******************************************************************* - lookup_alias_sid + lookup_alias_name ********************************************************************/ -uint32 lookup_alias_sid(DOM_SID *sid, char *alias_name, uint8 *type) +uint32 lookup_alias_name(uint32 rid, char *alias_name, uint8 *type) { - pstring sid_str; - uint32 rid; - DOM_SID tmp; - LOCAL_GRP *als = NULL; - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - (*type) = SID_NAME_ALIAS; - sid_to_string(sid_str, sid); - DEBUG(5,("lookup_alias_sid: sid: %s", sid_str)); + DEBUG(2,("lookup_alias_name: rid: %d\n", rid)); + DEBUG(2,(" NOT IMPLEMENTED\n")); - sid_copy(&tmp, sid); - sid_split_rid(&tmp, &rid); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} - if (!sid_equal(&global_sam_sid, &tmp)) +/******************************************************************* + lookup well-known user name + ********************************************************************/ +uint32 lookup_wk_user_name(uint32 rid, char *user_name, uint8 *type) +{ + int i = 0; + (*type) = SID_NAME_USER; + + DEBUG(5,("lookup_wk_user_name: rid: %d", rid)); + + /* look up the well-known domain user rids first */ + while (domain_user_rids[i].rid != rid && domain_user_rids[i].rid != 0) { - DEBUG(5,("not our SID\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + i++; } - als = getaliasrid(rid, NULL, NULL); - - if (als != NULL) + if (domain_user_rids[i].rid != 0) { - fstrcpy(alias_name, als->name); - DEBUG(5,(" = %s\n", alias_name)); + fstrcpy(user_name, domain_user_rids[i].name); + DEBUG(5,(" = %s\n", user_name)); return 0x0; } DEBUG(5,(" none mapped\n")); - return status; + return 0xC0000000 | NT_STATUS_NONE_MAPPED; } /******************************************************************* - lookup well-known user name + lookup user name ********************************************************************/ -uint32 lookup_wk_user_sid(DOM_SID *sid, char *user_name, uint8 *type) +uint32 lookup_user_name(uint32 rid, char *user_name, uint8 *type) { - uint32 rid; - DOM_SID tmp; - char *mapped; - + struct sam_disp_info *disp_info; (*type) = SID_NAME_USER; - sid_copy(&tmp, sid); - sid_split_rid(&tmp, &rid); + DEBUG(5,("lookup_user_name: rid: %d", rid)); - if (!sid_equal(&global_sid_S_1_5_20, &tmp)) + /* find the user account */ + become_root(True); + disp_info = getsamdisprid(rid); + unbecome_root(True); + + if (disp_info != NULL) { - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + fstrcpy(user_name, disp_info->smb_name); + DEBUG(5,(" = %s\n", user_name)); + return 0x0; } - DEBUG(5,("lookup_wk_user_sid: rid: %d", rid)); + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} - /* look up the well-known domain user rids first */ - mapped = lookup_wk_user_rid(rid); - if(mapped == NULL) +/******************************************************************* + lookup_group_rid + ********************************************************************/ +uint32 lookup_group_rid(char *group_name, uint32 *rid, uint8 *type) +{ + DOM_SID sid; + + (*rid) = 0; + (*type) = SID_NAME_DOM_GRP; + + DEBUG(5,("lookup_group_rid: name: %s", group_name)); + + if (map_group_name_to_sid(group_name, &sid) && + sid_split_rid(&sid, rid) && + sid_equal(&sid, &global_sam_sid)) { - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + DEBUG(5,(" = 0x%x\n", (*rid))); + return 0x0; } - fstrcpy(user_name, mapped); - DEBUG(5,(" = %s\n", user_name)); - return 0x0; + + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; } /******************************************************************* - lookup user name + lookup_wk_group_rid ********************************************************************/ -uint32 lookup_user_sid(DOM_SID *sid, char *user_name, uint8 *type) +uint32 lookup_wk_group_rid(char *group_name, uint32 *rid, uint8 *type) { - struct sam_disp_info *disp_info; - uint32 rid; - DOM_SID tmp; + char *grp_name; + int i = -1; /* start do loop at -1 */ + (*rid) = 0; + (*type) = SID_NAME_WKN_GRP; - (*type) = SID_NAME_USER; + do /* find, if it exists, a group rid for the group name */ + { + i++; + (*rid) = domain_group_rids[i].rid; + grp_name = domain_group_rids[i].name; - sid_copy(&tmp, sid); - sid_split_rid(&tmp, &rid); + } while (grp_name != NULL && !strequal(grp_name, group_name)); - if (sid_equal(&global_sam_sid, &tmp)) - { - DEBUG(5,("lookup_user_sid in SAM %s: rid: %d", - global_sam_name, rid)); + return (grp_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; +} - /* find the user account */ - become_root(True); - disp_info = getsamdisprid(rid); - unbecome_root(True); +/******************************************************************* + lookup_alias_sid + ********************************************************************/ +uint32 lookup_alias_sid(char *alias_name, DOM_SID *sid, uint8 *type) +{ + (*type) = SID_NAME_ALIAS; - if (disp_info != NULL) - { - fstrcpy(user_name, disp_info->nt_name); - DEBUG(5,(" = %s\n", user_name)); - return 0x0; - } + DEBUG(5,("lookup_alias_rid: name: %s", alias_name)); - DEBUG(5,(" none mapped\n")); + if (map_alias_name_to_sid(alias_name, sid)) + { + fstring sid_str; + sid_to_string(sid_str, sid); + DEBUG(5,(" = %s\n", sid_str)); + return 0x0; } + DEBUG(5,(" none mapped\n")); return 0xC0000000 | NT_STATUS_NONE_MAPPED; } /******************************************************************* - lookup_group_rid + lookup_alias_rid ********************************************************************/ -uint32 lookup_added_group_name(const char *grp_name, const char *domain, - DOM_SID *sid, uint8 *type) +uint32 lookup_alias_rid(char *alias_name, uint32 *rid, uint8 *type) { - DOMAIN_GRP *grp = NULL; - (*type) = SID_NAME_DOM_GRP; - - DEBUG(5,("lookup_added_group_name: name: %s", grp_name)); + DOM_SID sid; - if (!strequal(domain, global_sam_name)) - { - DEBUG(5,(" not our domain\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; - } + (*rid) = 0; + (*type) = SID_NAME_ALIAS; - grp = getgroupntnam(grp_name, NULL, NULL); + DEBUG(5,("lookup_alias_rid: name: %s", alias_name)); - if (grp != NULL) + if (map_alias_name_to_sid(alias_name, &sid) && + sid_split_rid(&sid, rid) && + sid_equal(&sid, &global_sam_sid)) { - sid_copy(sid, &global_sam_sid); - sid_append_rid(sid, grp->rid); - - DEBUG(5,(" = 0x%x\n", grp->rid)); + DEBUG(5,(" = 0x%x\n", (*rid))); return 0x0; } @@ -428,41 +452,86 @@ uint32 lookup_added_group_name(const char *grp_name, const char *domain, } /******************************************************************* - lookup_added_alias_name + lookup_wk_alias_sid ********************************************************************/ -uint32 lookup_added_alias_name(const char *als_name, const char *domain, - DOM_SID *sid, uint8 *type) +uint32 lookup_wk_alias_sid(char *alias_name, DOM_SID *sid, uint8 *type) { - LOCAL_GRP *als = NULL; + char *als_name; + int i = 0; + uint32 rid; (*type) = SID_NAME_ALIAS; - DEBUG(5,("lookup_added_alias_name: name: %s\\%s", domain, als_name)); - - if (!strequal(domain, global_sam_name)) + do /* find, if it exists, a alias rid for the alias name*/ { - DEBUG(5,(" not our domain\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; - } + rid = builtin_alias_rids[i].rid; + als_name = builtin_alias_rids[i].name; - als = getaliasntnam(als_name, NULL, NULL); + i++; - if (als != NULL) + if (strequal(als_name, alias_name)) + { + sid_copy(sid, &global_sid_S_1_5_20); + sid_append_rid(sid, rid); + + return 0x0; + } + + } while (als_name != NULL); + + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_wk_alias_rid + ********************************************************************/ +uint32 lookup_wk_alias_rid(char *alias_name, uint32 *rid, uint8 *type) +{ + char *als_name; + int i = -1; /* start do loop at -1 */ + (*rid) = 0; + (*type) = SID_NAME_ALIAS; + + do /* find, if it exists, a alias rid for the alias name*/ { - sid_copy(sid, &global_sam_sid); - sid_append_rid(sid, als->rid); + i++; + (*rid) = builtin_alias_rids[i].rid; + als_name = builtin_alias_rids[i].name; - DEBUG(5,(" = 0x%x\n", als->rid)); - return 0x0; + } while (als_name != NULL && !strequal(als_name, alias_name)); + + return (als_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_sid + ********************************************************************/ +uint32 lookup_sid(char *name, DOM_SID *sid, uint8 *type) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + fstring domain; + fstring user; + + split_domain_name(name, domain, user); + + if (!strequal(domain, global_sam_name)) + { + DEBUG(0,("lookup_sid: remote domain %s not supported\n", domain)); + return status; } - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + status = (status != 0x0) ? lookup_wk_alias_sid(user, sid, type) : status; + status = (status != 0x0) ? lookup_alias_sid (user, sid, type) : status; +#if 0 + status = (status != 0x0) ? lookup_domain_sid (user, sid, type) : status; +#endif + + return status; } /******************************************************************* lookup_added_user_rid ********************************************************************/ -uint32 lookup_added_user_rids(char *nt_name, +uint32 lookup_added_user_rids(char *user_name, uint32 *usr_rid, uint32 *grp_rid) { struct sam_passwd *sam_pass; @@ -471,7 +540,7 @@ uint32 lookup_added_user_rids(char *nt_name, /* find the user account */ become_root(True); - sam_pass = getsam21pwntnam(nt_name); + sam_pass = getsam21pwnam(user_name); unbecome_root(True); if (sam_pass != NULL) @@ -485,29 +554,22 @@ uint32 lookup_added_user_rids(char *nt_name, } /******************************************************************* - lookup_added_user_name + lookup_added_user_rid ********************************************************************/ -static uint32 lookup_added_user_name(const char *nt_name, const char *domain, - DOM_SID *sid, uint8 *type) +uint32 lookup_added_user_rid(char *user_name, uint32 *rid, uint8 *type) { struct sam_passwd *sam_pass; + (*rid) = 0; (*type) = SID_NAME_USER; - if (!strequal(domain, global_sam_name)) - { - return 0xC0000000 | NT_STATUS_NONE_MAPPED; - } - /* find the user account */ become_root(True); - sam_pass = getsam21pwntnam(nt_name); + sam_pass = getsam21pwnam(user_name); unbecome_root(True); if (sam_pass != NULL) { - sid_copy(sid, &global_sam_sid); - sid_append_rid(sid, sam_pass->user_rid); - + (*rid) = sam_pass->user_rid; return 0x0; } @@ -515,52 +577,134 @@ static uint32 lookup_added_user_name(const char *nt_name, const char *domain, } /******************************************************************* - lookup_grp_name + lookup_wk_user_rid ********************************************************************/ -static uint32 lookup_grp_name(const char *name, const char *domain, - DOM_SID *sid, uint8 *type) +uint32 lookup_wk_user_rid(char *user_name, uint32 *rid, uint8 *type) +{ + char *usr_name; + int i = -1; /* start do loop at -1 */ + (*rid) = 0; + (*type) = SID_NAME_USER; + + do /* find, if it exists, a alias rid for the alias name*/ + { + i++; + (*rid) = domain_user_rids[i].rid; + usr_name = domain_user_rids[i].name; + + } while (usr_name != NULL && !strequal(usr_name, user_name)); + + return (usr_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_added_grp_rid + ********************************************************************/ +uint32 lookup_added_grp_rid(char *name, uint32 *rid, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_wk_group_name (name, domain, sid, type) : status; - status = (status != 0x0) ? lookup_builtin_alias_name(name, domain, sid, type) : status; - status = (status != 0x0) ? lookup_added_group_name (name, domain, sid, type) : status; - status = (status != 0x0) ? lookup_added_alias_name (name, domain, sid, type) : status; + status = (status != 0x0) ? lookup_group_rid(name, rid, type) : status; + status = (status != 0x0) ? lookup_alias_rid(name, rid, type) : status; return status; } /******************************************************************* - lookup_user_name + lookup_builtin_grp_rid ********************************************************************/ -static uint32 lookup_user_name(const char *name, const char *domain, - DOM_SID *sid, uint8 *type) +uint32 lookup_builtin_grp_rid(char *name, uint32 *rid, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - status = (status != 0x0) ? lookup_wk_user_name (name, domain, sid, type) : status; - status = (status != 0x0) ? lookup_added_user_name(name, domain, sid, type) : status; + status = (status != 0x0) ? lookup_wk_group_rid(name, rid, type) : status; + status = (status != 0x0) ? lookup_wk_alias_rid(name, rid, type) : status; return status; } /******************************************************************* - lookup_name + lookup_grp_rid ********************************************************************/ -uint32 lookup_name(char *name, DOM_SID *sid, uint8 *type) +uint32 lookup_grp_rid(char *name, uint32 *rid, uint8 *type) { uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - fstring domain; - fstring user; - - split_domain_name(name, domain, user); - status = (status != 0x0) ? lookup_user_name (user, domain, sid, type) : status; - status = (status != 0x0) ? lookup_grp_name (user, domain, sid, type) : status; -#if 0 - status = (status != 0x0) ? lookup_domain_name (domain, sid, type) : status; -#endif + status = (status != 0x0) ? lookup_builtin_grp_rid(name, rid, type) : status; + status = (status != 0x0) ? lookup_added_grp_rid (name, rid, type) : status; return status; } +/******************************************************************* + lookup_user_rid + ********************************************************************/ +uint32 lookup_user_rid(char *name, uint32 *rid, uint8 *type) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + + status = (status != 0x0) ? lookup_wk_user_rid (name, rid, type) : status; + status = (status != 0x0) ? lookup_added_user_rid(name, rid, type) : status; + + return status; +} + +/******************************************************************* + lookup_rid + ********************************************************************/ +uint32 lookup_rid(char *name, uint32 *rid, uint8 *type) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + + status = (status != 0x0) ? lookup_user_rid(name, rid, type) : status; + status = (status != 0x0) ? lookup_grp_rid (name, rid, type) : status; + + return status; +} + +/******************************************************************* + lookup_user_rids + ********************************************************************/ +uint32 lookup_user_rids(char *name, uint32 *usr_rid, uint32 *grp_rid) +{ + uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + uint8 type; + + /* + * try an ordinary user lookup + */ + + status = lookup_added_user_rids(name, usr_rid, grp_rid); + if (status == 0) + { + return status; + } + + /* + * hm. must be a well-known user, in a well-known group. + */ + + status = lookup_wk_user_rid(name, usr_rid, &type); + if (status != 0 || type != SID_NAME_USER) + { + return status; /* ok, maybe not! */ + } + if (type != SID_NAME_USER) + { + return 0xC0000000 | NT_STATUS_NONE_MAPPED; /* users only... */ + } + + /* + * ok, got the user rid: now try the group rid + */ + + status = lookup_builtin_grp_rid(name, grp_rid, &type); + if (type == SID_NAME_DOM_GRP || + type == SID_NAME_ALIAS || + type == SID_NAME_WKN_GRP) + { + status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + } + + return status; +} diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index fbe83b02c8..7094d842b4 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -29,82 +29,87 @@ extern int DEBUGLEVEL; extern DOM_SID global_sam_sid; -extern fstring global_sam_name; -extern DOM_SID global_member_sid; extern fstring global_myworkgroup; -extern DOM_SID global_sid_S_1_5_20; +extern pstring global_myname; /*************************************************************************** -lsa_reply_open_policy2 + lsa_reply_open_policy2 ***************************************************************************/ -static void lsa_reply_open_policy2(prs_struct *rdata) + +static BOOL lsa_reply_open_policy2(prs_struct *rdata) { + int i; LSA_R_OPEN_POL2 r_o; ZERO_STRUCT(r_o); /* set up the LSA QUERY INFO response */ + for (i = 4; i < POL_HND_SIZE; i++) + r_o.pol.data[i] = i; r_o.status = 0x0; - /* get a (unique) handle. open a policy on it. */ - if (!open_policy_hnd(&r_o.pol)) - { - r_o.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + /* store the response in the SMB stream */ + if(!lsa_io_r_open_pol2("", &r_o, rdata, 0)) { + DEBUG(0,("lsa_reply_open_policy2: unable to marshall LSA_R_OPEN_POL2.\n")); + return False; } - /* store the response in the SMB stream */ - lsa_io_r_open_pol2("", &r_o, rdata, 0); + return True; } /*************************************************************************** lsa_reply_open_policy ***************************************************************************/ -static void lsa_reply_open_policy(prs_struct *rdata) + +static BOOL lsa_reply_open_policy(prs_struct *rdata) { + int i; LSA_R_OPEN_POL r_o; ZERO_STRUCT(r_o); /* set up the LSA QUERY INFO response */ + for (i = 4; i < POL_HND_SIZE; i++) + r_o.pol.data[i] = i; r_o.status = 0x0; - /* get a (unique) handle. open a policy on it. */ - if (!open_policy_hnd(&r_o.pol)) - { - r_o.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + /* store the response in the SMB stream */ + if(!lsa_io_r_open_pol("", &r_o, rdata, 0)) { + DEBUG(0,("lsa_reply_open_policy: unable to marshall LSA_R_OPEN_POL.\n")); + return False; } - /* store the response in the SMB stream */ - lsa_io_r_open_pol("", &r_o, rdata, 0); + return True; } /*************************************************************************** -make_dom_query +Init dom_query ***************************************************************************/ -static void make_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) + +static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) { fstring sid_str; int domlen = strlen(dom_name); - d_q->uni_dom_str_len = (domlen+1) * 2; d_q->uni_dom_max_len = domlen * 2; + d_q->uni_dom_str_len = domlen * 2; d_q->buffer_dom_name = domlen != 0 ? 1 : 0; /* domain buffer pointer */ d_q->buffer_dom_sid = dom_sid != NULL ? 1 : 0; /* domain sid pointer */ /* this string is supposed to be character short */ - make_unistr2(&(d_q->uni_domain_name), dom_name, domlen); - d_q->uni_domain_name.uni_max_len++; + init_unistr2(&d_q->uni_domain_name, dom_name, domlen); sid_to_string(sid_str, dom_sid); - make_dom_sid2(&(d_q->dom_sid), dom_sid); + init_dom_sid2(&d_q->dom_sid, dom_sid); } /*************************************************************************** -lsa_reply_query_info + lsa_reply_enum_trust_dom ***************************************************************************/ + static void lsa_reply_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM *q_e, prs_struct *rdata, uint32 enum_context, char *dom_name, DOM_SID *dom_sid) @@ -114,7 +119,7 @@ static void lsa_reply_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM *q_e, ZERO_STRUCT(r_e); /* set up the LSA QUERY INFO response */ - make_r_enum_trust_dom(&r_e, enum_context, dom_name, dom_sid, + init_r_enum_trust_dom(&r_e, enum_context, dom_name, dom_sid, dom_name != NULL ? 0x0 : 0x80000000 | NT_STATUS_UNABLE_TO_FREE_VM); /* store the response in the SMB stream */ @@ -124,63 +129,53 @@ static void lsa_reply_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM *q_e, /*************************************************************************** lsa_reply_query_info ***************************************************************************/ -static void lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, + +static BOOL lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, char *dom_name, DOM_SID *dom_sid) { LSA_R_QUERY_INFO r_q; ZERO_STRUCT(r_q); - /* get a (unique) handle. open a policy on it. */ - if (r_q.status == 0x0 && !open_policy_hnd(&q_q->pol)) - { - r_q.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - else - { - /* set up the LSA QUERY INFO response */ + /* set up the LSA QUERY INFO response */ - r_q.undoc_buffer = 0x1; - r_q.info_class = q_q->info_class; + r_q.undoc_buffer = 0x22000000; /* bizarre */ + r_q.info_class = q_q->info_class; - make_dom_query(&r_q.dom.id5, dom_name, dom_sid); + init_dom_query(&r_q.dom.id5, dom_name, dom_sid); + + r_q.status = 0x0; - r_q.status = 0x0; - } /* store the response in the SMB stream */ - lsa_io_r_query("", &r_q, rdata, 0); -} + if(!lsa_io_r_query("", &r_q, rdata, 0)) { + DEBUG(0,("lsa_reply_query_info: failed to marshall LSA_R_QUERY_INFO.\n")); + return False; + } + return True; +} /*************************************************************************** -make_dom_ref - adds a domain if it's not already in, returns the index - ***************************************************************************/ -static int make_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) - + init_dom_ref - adds a domain if it's not already in, returns the index. +***************************************************************************/ + +static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) { int num = 0; int len; - if (dom_name != NULL) - { - for (num = 0; num < ref->num_ref_doms_1; num++) - { + if (dom_name != NULL) { + for (num = 0; num < ref->num_ref_doms_1; num++) { fstring domname; - unistr2_to_ascii(domname, &ref->ref_dom[num].uni_dom_name, sizeof(domname)-1); + fstrcpy(domname, dos_unistr2_to_str(&ref->ref_dom[num].uni_dom_name)); if (strequal(domname, dom_name)) - { return num; - } } - - } - else - { + } else { num = ref->num_ref_doms_1; } - if (num >= MAX_REF_DOMAINS) - { + if (num >= MAX_REF_DOMAINS) { /* index not found, already at maximum domain limit */ return -1; } @@ -190,95 +185,85 @@ static int make_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) ref->max_entries = MAX_REF_DOMAINS; ref->num_ref_doms_2 = num+1; - len = dom_name != NULL ? strlen(dom_name) : 0; + len = (dom_name != NULL) ? strlen(dom_name) : 0; + if(dom_name != NULL && len == 0) + len = 1; - make_uni_hdr(&(ref->hdr_ref_dom[num].hdr_dom_name), len); + init_uni_hdr(&ref->hdr_ref_dom[num].hdr_dom_name, len); ref->hdr_ref_dom[num].ptr_dom_sid = dom_sid != NULL ? 1 : 0; - make_unistr2 (&(ref->ref_dom[num].uni_dom_name), dom_name, len); - make_dom_sid2(&(ref->ref_dom[num].ref_dom ), dom_sid ); + init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name, len); + init_dom_sid2(&ref->ref_dom[num].ref_dom, dom_sid ); return num; } /*************************************************************************** -make_lsa_rid2s + init_lsa_rid2s ***************************************************************************/ -static void make_lsa_rid2s(DOM_R_REF *ref, - DOM_RID2 *rid2, + +static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, int num_entries, UNISTR2 name[MAX_LOOKUP_SIDS], uint32 *mapped_count) { int i; int total = 0; - (*mapped_count) = 0; + *mapped_count = 0; SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS); - for (i = 0; i < num_entries; i++) - { - uint32 status = 0x0; - DOM_SID find_sid; + for (i = 0; i < num_entries; i++) { + BOOL status = False; + DOM_SID dom_sid; DOM_SID sid; uint32 rid = 0xffffffff; int dom_idx = -1; - fstring find_name; - char *dom_name = NULL; + pstring full_name; + fstring dom_name; + fstring user; uint8 sid_name_use = SID_NAME_UNKNOWN; - unistr2_to_ascii(find_name, &name[i], sizeof(find_name)-1); - dom_name = strdup(find_name); + pstrcpy(full_name, dos_unistr2_to_str(&name[i])); - if (map_domain_name_to_sid(&sid, &dom_name)) - { - sid_name_use = SID_NAME_DOMAIN; - dom_idx = make_dom_ref(ref, dom_name, &find_sid); - } + /* + * Try and split the name into a DOMAIN and + * user component. + */ - if (lookup_name(find_name, &sid, &sid_name_use) == 0x0 && - sid_split_rid(&sid, &rid)) - { - if (map_domain_sid_to_name(&sid, find_name)) - { - dom_idx = make_dom_ref(ref, find_name, &sid); - } - else - { - status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - } - } - else - { - status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + split_domain_name(full_name, dom_name, user); + + /* + * We only do anything with this name if we + * can map the Domain into a SID we know. + */ + + if (map_domain_name_to_sid(&dom_sid, dom_name)) { + dom_idx = init_dom_ref(ref, dom_name, &dom_sid); + + if (lookup_local_name(dom_name, user, &sid, &sid_name_use) && sid_split_rid(&sid, &rid)) + status = True; } - if (status == 0x0) - { + if (status) (*mapped_count)++; - } - else - { + else { dom_idx = -1; rid = 0xffffffff; sid_name_use = SID_NAME_UNKNOWN; } - make_dom_rid2(&rid2[total], rid, sid_name_use, dom_idx); + init_dom_rid2(&rid2[total], rid, sid_name_use, dom_idx); total++; - - if (dom_name != NULL) - { - free(dom_name); - } } } /*************************************************************************** -make_reply_lookup_names + init_reply_lookup_names ***************************************************************************/ -static void make_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, - DOM_R_REF *ref, uint32 num_entries, - DOM_RID2 *rid2, uint32 mapped_count) + +static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, + DOM_R_REF *ref, uint32 num_entries, + DOM_RID2 *rid2, uint32 mapped_count) { r_l->ptr_dom_ref = 1; r_l->dom_ref = ref; @@ -291,84 +276,74 @@ static void make_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, r_l->mapped_count = mapped_count; if (mapped_count == 0) - { r_l->status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - } else - { r_l->status = 0x0; - } } /*************************************************************************** -make_lsa_trans_names + Init lsa_trans_names. ***************************************************************************/ -static void make_lsa_trans_names(DOM_R_REF *ref, - LSA_TRANS_NAME_ENUM *trn, - int num_entries, DOM_SID2 sid[MAX_LOOKUP_SIDS], - uint32 *mapped_count) + +static void init_lsa_trans_names(DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, + int num_entries, DOM_SID2 sid[MAX_LOOKUP_SIDS], uint32 *mapped_count) { + extern DOM_SID global_sid_S_1_5_0x20; /* BUILTIN sid. */ int i; int total = 0; - (*mapped_count) = 0; + *mapped_count = 0; SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS); - for (i = 0; i < num_entries; i++) - { - uint32 status = 0x0; + for (i = 0; i < num_entries; i++) { + BOOL status = False; DOM_SID find_sid = sid[i].sid; - DOM_SID tmp_sid = sid[i].sid; uint32 rid = 0xffffffff; int dom_idx = -1; fstring name; fstring dom_name; uint8 sid_name_use = 0; - - memset(dom_name, 0, sizeof(dom_name)); - memset(name , 0, sizeof(name )); - if (map_domain_sid_to_name(&find_sid, dom_name)) - { + memset(dom_name, '\0', sizeof(dom_name)); + memset(name, '\0', sizeof(name)); + + /* + * First, check to see if the SID is one of the well + * known ones (this includes our own domain SID). + * Next, check if the domain prefix is one of the + * well known ones. If so and the domain prefix was + * either BUILTIN or our own global sid, then lookup + * the RID as a user or group id and translate to + * a name. + */ + + if (map_domain_sid_to_name(&find_sid, dom_name)) { sid_name_use = SID_NAME_DOMAIN; - dom_idx = make_dom_ref(ref, dom_name, &find_sid); - } - else if (sid_split_rid (&find_sid, &rid) && - map_domain_sid_to_name(&find_sid, dom_name)) - { + } else if (sid_split_rid(&find_sid, &rid) && map_domain_sid_to_name(&find_sid, dom_name)) { if (sid_equal(&find_sid, &global_sam_sid) || - sid_equal(&find_sid, &global_sid_S_1_5_20)) - { - /* lkclXXXX REPLACE THIS FUNCTION WITH - samr_xxxx() routines - */ - status = lookup_sid(&tmp_sid, name, &sid_name_use); + sid_equal(&find_sid, &global_sid_S_1_5_0x20)) { + status = lookup_local_rid(rid, name, &sid_name_use); + } else { + status = lookup_known_rid(&find_sid, rid, name, &sid_name_use); } - else - { - status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - } - } - else - { - status = 0xC0000000 | NT_STATUS_NONE_MAPPED; } - dom_idx = make_dom_ref(ref, dom_name, &find_sid); + DEBUG(10,("init_lsa_trans_names: adding domain '%s' sid %s to referenced list.\n", + dom_name, name )); - if (status == 0x0) - { - (*mapped_count)++; - } - else - { - snprintf(name, sizeof(name), "%08x", rid); - sid_name_use = SID_NAME_UNKNOWN; + dom_idx = init_dom_ref(ref, dom_name, &find_sid); + if(!status) { + slprintf(name, sizeof(name)-1, "unix.%08x", rid); + sid_name_use = SID_NAME_UNKNOWN; } - make_lsa_trans_name(&(trn->name [total]), - &(trn->uni_name[total]), - sid_name_use, name, dom_idx); + + DEBUG(10,("init_lsa_trans_names: added user '%s\\%s' to referenced list.\n", dom_name, name )); + + (*mapped_count)++; + + init_lsa_trans_name(&trn->name[total], &trn->uni_name[total], + sid_name_use, name, dom_idx); total++; } @@ -378,11 +353,12 @@ static void make_lsa_trans_names(DOM_R_REF *ref, } /*************************************************************************** -make_reply_lookup_sids + Init_reply_lookup_sids. ***************************************************************************/ -static void make_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, - DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *names, - uint32 mapped_count) + +static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, + DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *names, + uint32 mapped_count) { r_l->ptr_dom_ref = 1; r_l->dom_ref = ref; @@ -390,20 +366,16 @@ static void make_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, r_l->mapped_count = mapped_count; if (mapped_count == 0) - { r_l->status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - } else - { r_l->status = 0x0; - } } /*************************************************************************** lsa_reply_lookup_sids ***************************************************************************/ -static void lsa_reply_lookup_sids(prs_struct *rdata, - DOM_SID2 *sid, int num_entries) + +static BOOL lsa_reply_lookup_sids(prs_struct *rdata, DOM_SID2 *sid, int num_entries) { LSA_R_LOOKUP_SIDS r_l; DOM_R_REF ref; @@ -415,18 +387,24 @@ static void lsa_reply_lookup_sids(prs_struct *rdata, ZERO_STRUCT(names); /* set up the LSA Lookup SIDs response */ - make_lsa_trans_names(&ref, &names, num_entries, sid, &mapped_count); - make_reply_lookup_sids(&r_l, &ref, &names, mapped_count); + init_lsa_trans_names(&ref, &names, num_entries, sid, &mapped_count); + init_reply_lookup_sids(&r_l, &ref, &names, mapped_count); /* store the response in the SMB stream */ - lsa_io_r_lookup_sids("", &r_l, rdata, 0); + if(!lsa_io_r_lookup_sids("", &r_l, rdata, 0)) { + DEBUG(0,("lsa_reply_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS.\n")); + return False; + } + + return True; } /*************************************************************************** lsa_reply_lookup_names ***************************************************************************/ -static void lsa_reply_lookup_names(prs_struct *rdata, - UNISTR2 names[MAX_LOOKUP_SIDS], int num_entries) + +static BOOL lsa_reply_lookup_names(prs_struct *rdata, + UNISTR2 names[MAX_LOOKUP_SIDS], int num_entries) { LSA_R_LOOKUP_NAMES r_l; DOM_R_REF ref; @@ -435,20 +413,26 @@ static void lsa_reply_lookup_names(prs_struct *rdata, ZERO_STRUCT(r_l); ZERO_STRUCT(ref); - ZERO_STRUCT(rids); + ZERO_ARRAY(rids); /* set up the LSA Lookup RIDs response */ - make_lsa_rid2s(&ref, rids, num_entries, names, &mapped_count); - make_reply_lookup_names(&r_l, &ref, num_entries, rids, mapped_count); + init_lsa_rid2s(&ref, rids, num_entries, names, &mapped_count); + init_reply_lookup_names(&r_l, &ref, num_entries, rids, mapped_count); /* store the response in the SMB stream */ - lsa_io_r_lookup_names("", &r_l, rdata, 0); + if(!lsa_io_r_lookup_names("", &r_l, rdata, 0)) { + DEBUG(0,("lsa_reply_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n")); + return False; + } + + return True; } /*************************************************************************** -api_lsa_open_policy + api_lsa_open_policy2 ***************************************************************************/ -static void api_lsa_open_policy2( rpcsrv_struct *p, prs_struct *data, + +static BOOL api_lsa_open_policy2( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_OPEN_POL2 q_o; @@ -456,18 +440,24 @@ static void api_lsa_open_policy2( rpcsrv_struct *p, prs_struct *data, ZERO_STRUCT(q_o); /* grab the server, object attributes and desired access flag...*/ - lsa_io_q_open_pol2("", &q_o, data, 0); + if(!lsa_io_q_open_pol2("", &q_o, data, 0)) { + DEBUG(0,("api_lsa_open_policy2: unable to unmarshall LSA_Q_OPEN_POL2.\n")); + return False; + } /* lkclXXXX having decoded it, ignore all fields in the open policy! */ /* return a 20 byte policy handle */ - lsa_reply_open_policy2(rdata); + if(!lsa_reply_open_policy2(rdata)) + return False; + + return True; } /*************************************************************************** api_lsa_open_policy ***************************************************************************/ -static void api_lsa_open_policy( rpcsrv_struct *p, prs_struct *data, +static BOOL api_lsa_open_policy( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_OPEN_POL q_o; @@ -475,18 +465,24 @@ static void api_lsa_open_policy( rpcsrv_struct *p, prs_struct *data, ZERO_STRUCT(q_o); /* grab the server, object attributes and desired access flag...*/ - lsa_io_q_open_pol("", &q_o, data, 0); + if(!lsa_io_q_open_pol("", &q_o, data, 0)) { + DEBUG(0,("api_lsa_open_policy: unable to unmarshall LSA_Q_OPEN_POL.\n")); + return False; + } /* lkclXXXX having decoded it, ignore all fields in the open policy! */ /* return a 20 byte policy handle */ - lsa_reply_open_policy(rdata); + if(!lsa_reply_open_policy(rdata)) + return False; + + return True; } /*************************************************************************** api_lsa_enum_trust_dom ***************************************************************************/ -static void api_lsa_enum_trust_dom( rpcsrv_struct *p, prs_struct *data, +static BOOL api_lsa_enum_trust_dom( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_ENUM_TRUST_DOM q_e; @@ -498,12 +494,14 @@ static void api_lsa_enum_trust_dom( rpcsrv_struct *p, prs_struct *data, /* construct reply. return status is always 0x0 */ lsa_reply_enum_trust_dom(&q_e, rdata, 0, NULL, NULL); + + return True; } /*************************************************************************** api_lsa_query_info ***************************************************************************/ -static void api_lsa_query_info( rpcsrv_struct *p, prs_struct *data, +static BOOL api_lsa_query_info( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_QUERY_INFO q_i; @@ -514,119 +512,118 @@ static void api_lsa_query_info( rpcsrv_struct *p, prs_struct *data, ZERO_STRUCT(q_i); /* grab the info class and policy handle */ - lsa_io_q_query("", &q_i, data, 0); - - switch (q_i.info_class) - { - case 0x03: - { - fstrcpy(name, global_myworkgroup); - sid = &global_member_sid; - break; - } - case 0x05: - { - fstrcpy(name, global_sam_name); - sid = &global_sam_sid; - break; - } - default: - { - DEBUG(5,("unknown info level in Lsa Query: %d\n", - q_i.info_class)); - break; - } + if(!lsa_io_q_query("", &q_i, data, 0)) { + DEBUG(0,("api_lsa_query_info: failed to unmarshall LSA_Q_QUERY_INFO.\n")); + return False; + } + + switch (q_i.info_class) { + case 0x03: + fstrcpy(name, global_myworkgroup); + sid = &global_sam_sid; + break; + case 0x05: + fstrcpy(name, global_myname); + sid = &global_sam_sid; + break; + default: + DEBUG(0,("api_lsa_query_info: unknown info level in Lsa Query: %d\n", q_i.info_class)); + break; } /* construct reply. return status is always 0x0 */ - lsa_reply_query_info(&q_i, rdata, name, sid); + if(!lsa_reply_query_info(&q_i, rdata, name, sid)) + return False; + + return True; } /*************************************************************************** -api_lsa_lookup_sids + api_lsa_lookup_sids ***************************************************************************/ -static void api_lsa_lookup_sids( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) + +static BOOL api_lsa_lookup_sids( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_LOOKUP_SIDS q_l; ZERO_STRUCT(q_l); /* grab the info class and policy handle */ - lsa_io_q_lookup_sids("", &q_l, data, 0); + if(!lsa_io_q_lookup_sids("", &q_l, data, 0)) { + DEBUG(0,("api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS.\n")); + return False; + } /* construct reply. return status is always 0x0 */ - lsa_reply_lookup_sids(rdata, q_l.sids.sid, q_l.sids.num_entries); + if(!lsa_reply_lookup_sids(rdata, q_l.sids.sid, q_l.sids.num_entries)) + return False; + + return True; } /*************************************************************************** -api_lsa_lookup_names + api_lsa_lookup_names ***************************************************************************/ -static void api_lsa_lookup_names( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) + +static BOOL api_lsa_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rdata ) { LSA_Q_LOOKUP_NAMES q_l; ZERO_STRUCT(q_l); /* grab the info class and policy handle */ - lsa_io_q_lookup_names("", &q_l, data, 0); + if(!lsa_io_q_lookup_names("", &q_l, data, 0)) { + DEBUG(0,("api_lsa_lookup_names: failed to unmarshall LSA_Q_LOOKUP_NAMES.\n")); + return False; + } SMB_ASSERT_ARRAY(q_l.uni_name, q_l.num_entries); - lsa_reply_lookup_names(rdata, q_l.uni_name, q_l.num_entries); + return lsa_reply_lookup_names(rdata, q_l.uni_name, q_l.num_entries); } /*************************************************************************** api_lsa_close ***************************************************************************/ -static void api_lsa_close( rpcsrv_struct *p, prs_struct *data, +static BOOL api_lsa_close( uint16 vuid, prs_struct *data, prs_struct *rdata) { LSA_R_CLOSE r_c; - LSA_Q_CLOSE q_c; - - lsa_io_q_close("", &q_c, data, 0); ZERO_STRUCT(r_c); - r_c.status = 0x0; - - /* find the connection policy handle. */ - if (r_c.status == 0x0 && (find_policy_by_hnd(&(q_c.pol)) == -1)) - { - r_c.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - if (r_c.status == 0x0) - { - close_policy_hnd(&(q_c.pol)); + /* store the response in the SMB stream */ + if (!lsa_io_r_close("", &r_c, rdata, 0)) { + DEBUG(0,("api_lsa_close: lsa_io_r_close failed.\n")); + return False; } - /* store the response in the SMB stream */ - lsa_io_r_close("", &r_c, rdata, 0); + return True; } /*************************************************************************** api_lsa_open_secret ***************************************************************************/ -static void api_lsa_open_secret( rpcsrv_struct *p, prs_struct *data, +static BOOL api_lsa_open_secret( uint16 vuid, prs_struct *data, prs_struct *rdata) { /* XXXX this is NOT good */ - char *q = mem_data(&(rdata->data), rdata->offset); - - SIVAL(q, 0, 0); - q += 4; - SIVAL(q, 0, 0); - q += 4; - SIVAL(q, 0, 0); - q += 4; - SIVAL(q, 0, 0); - q += 4; - SIVAL(q, 0, 0); - q += 4; - SIVAL(q, 0, 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND); - q += 4; - - rdata->offset += 24; + size_t i; + uint32 dummy = 0; + + for(i =0; i < 4; i++) { + if(!prs_uint32("api_lsa_close", rdata, 1, &dummy)) { + DEBUG(0,("api_lsa_open_secret: prs_uint32 %d failed.\n", + (int)i )); + return False; + } + } + + dummy = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + if(!prs_uint32("api_lsa_close", rdata, 1, &dummy)) { + DEBUG(0,("api_lsa_open_secret: prs_uint32 status failed.\n")); + return False; + } + + return True; } /*************************************************************************** @@ -648,7 +645,7 @@ static struct api_struct api_lsa_cmds[] = /*************************************************************************** api_ntLsarpcTNP ***************************************************************************/ -BOOL api_ntlsa_rpc(rpcsrv_struct *p, prs_struct *data) +BOOL api_ntlsa_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds, data); } diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index b895fb31c0..24aec701f0 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -31,11 +31,6 @@ extern int DEBUGLEVEL; #define MAX_OPEN_POLS 64 #endif -#define POL_NO_INFO 0 -#define POL_REG_INFO 1 -#define POL_SAMR_INFO 2 -#define POL_CLI_INFO 3 - struct reg_info { /* for use by \PIPE\winreg */ @@ -50,27 +45,17 @@ struct samr_info uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ }; -struct con_info -{ - struct cli_connection *con; - void (*free)(struct cli_connection*); -}; - static struct policy { struct policy *next, *prev; int pnum; BOOL open; POLICY_HND pol_hnd; - int type; union { - struct samr_info *samr; - struct reg_info *reg; - struct con_info *con; - + struct samr_info samr; + struct reg_info reg; } dev; - } *Policy; static struct bitmap *bmap; @@ -100,17 +85,18 @@ static void create_pol_hnd(POLICY_HND *hnd) /**************************************************************************** initialise policy handle states... ****************************************************************************/ -BOOL init_policy_hnd(int num_pol_hnds) +void init_lsa_policy_hnd(void) { - bmap = bitmap_allocate(num_pol_hnds); - - return bmap != NULL; + bmap = bitmap_allocate(MAX_OPEN_POLS); + if (!bmap) { + exit_server("out of memory in init_lsa_policy_hnd\n"); + } } /**************************************************************************** find first available policy slot. creates a policy handle for you. ****************************************************************************/ -BOOL register_policy_hnd(POLICY_HND *hnd) +BOOL open_lsa_policy_hnd(POLICY_HND *hnd) { int i; struct policy *p; @@ -132,8 +118,8 @@ BOOL register_policy_hnd(POLICY_HND *hnd) p->open = True; p->pnum = i; - p->type = POL_NO_INFO; + create_pol_hnd(hnd); memcpy(&p->pol_hnd, hnd, sizeof(*hnd)); bitmap_set(bmap, i); @@ -146,33 +132,23 @@ BOOL register_policy_hnd(POLICY_HND *hnd) return True; } -/**************************************************************************** - find first available policy slot. creates a policy handle for you. -****************************************************************************/ -BOOL open_policy_hnd(POLICY_HND *hnd) -{ - create_pol_hnd(hnd); - return register_policy_hnd(hnd); -} - /**************************************************************************** find policy by handle ****************************************************************************/ -static struct policy *find_policy(const POLICY_HND *hnd) +static struct policy *find_lsa_policy(POLICY_HND *hnd) { struct policy *p; for (p=Policy;p;p=p->next) { if (memcmp(&p->pol_hnd, hnd, sizeof(*hnd)) == 0) { DEBUG(4,("Found policy hnd[%x] ", p->pnum)); - dump_data(4, (const char *)hnd->data, - sizeof(hnd->data)); + dump_data(4, (char *)hnd->data, sizeof(hnd->data)); return p; } } DEBUG(4,("Policy not found: ")); - dump_data(4, (const char *)hnd->data, sizeof(hnd->data)); + dump_data(4, (char *)hnd->data, sizeof(hnd->data)); return NULL; } @@ -180,9 +156,9 @@ static struct policy *find_policy(const POLICY_HND *hnd) /**************************************************************************** find policy index by handle ****************************************************************************/ -int find_policy_by_hnd(const POLICY_HND *hnd) +int find_lsa_policy_by_hnd(POLICY_HND *hnd) { - struct policy *p = find_policy(hnd); + struct policy *p = find_lsa_policy(hnd); return p?p->pnum:-1; } @@ -190,24 +166,15 @@ int find_policy_by_hnd(const POLICY_HND *hnd) /**************************************************************************** set samr rid ****************************************************************************/ -BOOL set_policy_samr_rid(POLICY_HND *hnd, uint32 rid) +BOOL set_lsa_policy_samr_rid(POLICY_HND *hnd, uint32 rid) { - struct policy *p = find_policy(hnd); + struct policy *p = find_lsa_policy(hnd); - if (p && p->open) - { + if (p && p->open) { DEBUG(3,("Setting policy device rid=%x pnum=%x\n", rid, p->pnum)); - if (p->dev.samr == NULL) - { - p->dev.samr = (struct samr_info*)malloc(sizeof(*p->dev.samr)); - } - if (p->dev.samr == NULL) - { - return False; - } - p->dev.samr->rid = rid; + p->dev.samr.rid = rid; return True; } @@ -219,25 +186,15 @@ BOOL set_policy_samr_rid(POLICY_HND *hnd, uint32 rid) /**************************************************************************** set samr pol status. absolutely no idea what this is. ****************************************************************************/ -BOOL set_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status) +BOOL set_lsa_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status) { - struct policy *p = find_policy(hnd); + struct policy *p = find_lsa_policy(hnd); - if (p && p->open) - { + if (p && p->open) { DEBUG(3,("Setting policy status=%x pnum=%x\n", pol_status, p->pnum)); - if (p->dev.samr == NULL) - { - p->type = POL_SAMR_INFO; - p->dev.samr = (struct samr_info*)malloc(sizeof(*p->dev.samr)); - } - if (p->dev.samr == NULL) - { - return False; - } - p->dev.samr->status = pol_status; + p->dev.samr.status = pol_status; return True; } @@ -249,25 +206,16 @@ BOOL set_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status) /**************************************************************************** set samr sid ****************************************************************************/ -BOOL set_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) +BOOL set_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) { - pstring sidstr; - struct policy *p = find_policy(hnd); + fstring sidstr; + struct policy *p = find_lsa_policy(hnd); if (p && p->open) { DEBUG(3,("Setting policy sid=%s pnum=%x\n", sid_to_string(sidstr, sid), p->pnum)); - if (p->dev.samr == NULL) - { - p->type = POL_SAMR_INFO; - p->dev.samr = (struct samr_info*)malloc(sizeof(*p->dev.samr)); - } - if (p->dev.samr == NULL) - { - return False; - } - memcpy(&p->dev.samr->sid, sid, sizeof(*sid)); + memcpy(&p->dev.samr.sid, sid, sizeof(*sid)); return True; } @@ -279,14 +227,14 @@ BOOL set_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) /**************************************************************************** get samr sid ****************************************************************************/ -BOOL get_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) +BOOL get_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) { - struct policy *p = find_policy(hnd); + struct policy *p = find_lsa_policy(hnd); if (p != NULL && p->open) { - pstring sidstr; - memcpy(sid, &p->dev.samr->sid, sizeof(*sid)); + fstring sidstr; + memcpy(sid, &p->dev.samr.sid, sizeof(*sid)); DEBUG(3,("Getting policy sid=%s pnum=%x\n", sid_to_string(sidstr, sid), p->pnum)); @@ -300,12 +248,12 @@ BOOL get_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) /**************************************************************************** get samr rid ****************************************************************************/ -uint32 get_policy_samr_rid(POLICY_HND *hnd) +uint32 get_lsa_policy_samr_rid(POLICY_HND *hnd) { - struct policy *p = find_policy(hnd); + struct policy *p = find_lsa_policy(hnd); if (p && p->open) { - uint32 rid = p->dev.samr->rid; + uint32 rid = p->dev.samr.rid; DEBUG(3,("Getting policy device rid=%x pnum=%x\n", rid, p->pnum)); @@ -319,116 +267,30 @@ uint32 get_policy_samr_rid(POLICY_HND *hnd) /**************************************************************************** set reg name ****************************************************************************/ -BOOL set_policy_reg_name(POLICY_HND *hnd, fstring name) -{ - struct policy *p = find_policy(hnd); - - if (p && p->open) - { - DEBUG(3,("Getting policy pnum=%x\n", - p->pnum)); - - if (p->dev.reg == NULL) - { - p->type = POL_REG_INFO; - p->dev.reg = (struct reg_info*)malloc(sizeof(*p->dev.reg)); - } - if (p->dev.reg == NULL) - { - return False; - } - fstrcpy(p->dev.reg->name, name); - return True; - } - - DEBUG(3,("Error setting policy name=%s\n", name)); - return False; -} - -/**************************************************************************** - set reg name -****************************************************************************/ -BOOL get_policy_reg_name(POLICY_HND *hnd, fstring name) +BOOL set_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) { - struct policy *p = find_policy(hnd); + struct policy *p = find_lsa_policy(hnd); - if (p && p->open) - { + if (p && p->open) { DEBUG(3,("Setting policy pnum=%x name=%s\n", p->pnum, name)); - fstrcpy(name, p->dev.reg->name); - DEBUG(5,("getting policy reg name=%s\n", name)); - return True; - } - - DEBUG(3,("Error getting policy reg name\n")); - return False; -} - -/**************************************************************************** - set con state -****************************************************************************/ -BOOL set_policy_con(POLICY_HND *hnd, struct cli_connection *con, - void (*free_fn)(struct cli_connection *)) -{ - struct policy *p = find_policy(hnd); - - if (p && p->open) - { - DEBUG(3,("Setting policy con state pnum=%x\n", p->pnum)); - - if (p->dev.con == NULL) - { - p->type = POL_CLI_INFO; - p->dev.con = (struct con_info*)malloc(sizeof(*p->dev.con)); - } - if (p->dev.con == NULL) - { - return False; - } - p->dev.con->con = con; - p->dev.con->free = free_fn; + fstrcpy(p->dev.reg.name, name); return True; } - DEBUG(3,("Error setting policy con state\n")); - - return False; -} - -/**************************************************************************** - get con state -****************************************************************************/ -BOOL get_policy_con(const POLICY_HND *hnd, struct cli_connection **con) -{ - struct policy *p = find_policy(hnd); - - if (p != NULL && p->open) - { - DEBUG(3,("Getting con state pnum=%x\n", p->pnum)); - - if (con != NULL) - { - (*con ) = p->dev.con->con; - } - - return True; - } - - DEBUG(3,("Error getting policy\n")); + DEBUG(3,("Error setting policy name=%s\n", name)); return False; } /**************************************************************************** close an lsa policy ****************************************************************************/ -BOOL close_policy_hnd(POLICY_HND *hnd) +BOOL close_lsa_policy_hnd(POLICY_HND *hnd) { - struct policy *p = find_policy(hnd); + struct policy *p = find_lsa_policy(hnd); - if (!p) - { + if (!p) { DEBUG(3,("Error closing policy\n")); return False; } @@ -440,33 +302,8 @@ BOOL close_policy_hnd(POLICY_HND *hnd) bitmap_clear(bmap, p->pnum); ZERO_STRUCTP(p); - ZERO_STRUCTP(hnd); - - switch (p->type) - { - case POL_REG_INFO: - { - free(p->dev.reg); - break; - } - case POL_SAMR_INFO: - { - free(p->dev.samr); - break; - } - case POL_CLI_INFO: - { - if (p->dev.con->free != NULL) - { - p->dev.con->free(p->dev.con->con); - } - free(p->dev.con); - break; - } - } free(p); return True; } - diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 9721b3bf00..c0233d80c6 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -1,3 +1,4 @@ + /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -28,17 +29,19 @@ extern int DEBUGLEVEL; +extern BOOL sam_logon_in_ssb; +extern pstring samlogon_user; extern pstring global_myname; extern DOM_SID global_sam_sid; -extern fstring global_sam_name; /************************************************************************* - make_net_r_req_chal: + init_net_r_req_chal: *************************************************************************/ -static void make_net_r_req_chal(NET_R_REQ_CHAL *r_c, + +static void init_net_r_req_chal(NET_R_REQ_CHAL *r_c, DOM_CHAL *srv_chal, int status) { - DEBUG(6,("make_net_r_req_chal: %d\n", __LINE__)); + DEBUG(6,("init_net_r_req_chal: %d\n", __LINE__)); memcpy(r_c->srv_chal.data, srv_chal->data, sizeof(srv_chal->data)); r_c->status = status; } @@ -46,7 +49,8 @@ static void make_net_r_req_chal(NET_R_REQ_CHAL *r_c, /************************************************************************* net_reply_req_chal: *************************************************************************/ -static void net_reply_req_chal(NET_Q_REQ_CHAL *q_c, prs_struct *rdata, + +static BOOL net_reply_req_chal(NET_Q_REQ_CHAL *q_c, prs_struct *rdata, DOM_CHAL *srv_chal, uint32 srv_time) { NET_R_REQ_CHAL r_c; @@ -54,19 +58,24 @@ static void net_reply_req_chal(NET_Q_REQ_CHAL *q_c, prs_struct *rdata, DEBUG(6,("net_reply_req_chal: %d\n", __LINE__)); /* set up the LSA REQUEST CHALLENGE response */ - make_net_r_req_chal(&r_c, srv_chal, srv_time); + init_net_r_req_chal(&r_c, srv_chal, srv_time); /* store the response in the SMB stream */ - net_io_r_req_chal("", &r_c, rdata, 0); + if(!net_io_r_req_chal("", &r_c, rdata, 0)) { + DEBUG(0,("net_reply_req_chal: Failed to marshall NET_R_REQ_CHAL.\n")); + return False; + } DEBUG(6,("net_reply_req_chal: %d\n", __LINE__)); + return True; } /************************************************************************* net_reply_logon_ctrl2: *************************************************************************/ -static void net_reply_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, prs_struct *rdata, + +static BOOL net_reply_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, prs_struct *rdata, uint32 flags, uint32 pdc_status, uint32 logon_attempts, uint32 tc_status, char *trust_domain_name) { @@ -75,80 +84,63 @@ static void net_reply_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, prs_struct *rdata, DEBUG(6,("net_reply_logon_ctrl2: %d\n", __LINE__)); /* set up the Logon Control2 response */ - make_r_logon_ctrl2(&r_l, q_l->query_level, + init_r_logon_ctrl2(&r_l, q_l->query_level, flags, pdc_status, logon_attempts, tc_status, trust_domain_name); /* store the response in the SMB stream */ - net_io_r_logon_ctrl2("", &r_l, rdata, 0); + if(!net_io_r_logon_ctrl2("", &r_l, rdata, 0)) { + DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL2.\n")); + return False; + } DEBUG(6,("net_reply_logon_ctrl2: %d\n", __LINE__)); + return True; } /************************************************************************* net_reply_trust_dom_list: *************************************************************************/ -static void net_reply_trust_dom_list(NET_Q_TRUST_DOM_LIST *q_t, prs_struct *rdata, - uint32 num_trust_domains, char **trust_domain_name) + +static BOOL net_reply_trust_dom_list(NET_Q_TRUST_DOM_LIST *q_t, prs_struct *rdata, + uint32 num_trust_domains, char *trust_domain_name) { NET_R_TRUST_DOM_LIST r_t; DEBUG(6,("net_reply_trust_dom_list: %d\n", __LINE__)); /* set up the Trusted Domain List response */ - make_r_trust_dom(&r_t, num_trust_domains, trust_domain_name); + init_r_trust_dom(&r_t, num_trust_domains, trust_domain_name); /* store the response in the SMB stream */ - net_io_r_trust_dom("", &r_t, rdata, 0); + if(!net_io_r_trust_dom("", &r_t, rdata, 0)) { + DEBUG(0,("net_reply_trust_dom_list: Failed to marshall NET_R_TRUST_DOM_LIST.\n")); + return False; + } - DEBUG(6,("net_reply_trust_dom_list: %d\n", __LINE__)); + DEBUG(6,("net_reply_trust_dom_listlogon_ctrl2: %d\n", __LINE__)); + return True; } - /************************************************************************* - make_net_r_auth: + init_net_r_auth_2: *************************************************************************/ -static void make_net_r_auth(NET_R_AUTH *r_a, - DOM_CHAL *resp_cred, int status) -{ - memcpy( r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); - r_a->status = status; -} -/************************************************************************* - net_reply_auth: - *************************************************************************/ -static void net_reply_auth(NET_Q_AUTH *q_a, prs_struct *rdata, - DOM_CHAL *resp_cred, int status) -{ - NET_R_AUTH r_a; - - /* set up the LSA AUTH 2 response */ - - make_net_r_auth(&r_a, resp_cred, status); - - /* store the response in the SMB stream */ - net_io_r_auth("", &r_a, rdata, 0); - -} - -/************************************************************************* - make_net_r_auth_2: - *************************************************************************/ -static void make_net_r_auth_2(NET_R_AUTH_2 *r_a, +static void init_net_r_auth_2(NET_R_AUTH_2 *r_a, DOM_CHAL *resp_cred, NEG_FLAGS *flgs, int status) { - memcpy( r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); - memcpy(&(r_a->srv_flgs) , flgs , sizeof(r_a->srv_flgs)); + memcpy(r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); + memcpy(&r_a->srv_flgs, flgs, sizeof(r_a->srv_flgs)); r_a->status = status; } -/************************************************************************* +/************************************************************************ net_reply_auth_2: *************************************************************************/ -static void net_reply_auth_2(NET_Q_AUTH_2 *q_a, prs_struct *rdata, + +static BOOL net_reply_auth_2(NET_Q_AUTH_2 *q_a, prs_struct *rdata, DOM_CHAL *resp_cred, int status) { NET_R_AUTH_2 r_a; @@ -158,31 +150,37 @@ static void net_reply_auth_2(NET_Q_AUTH_2 *q_a, prs_struct *rdata, /* set up the LSA AUTH 2 response */ - make_net_r_auth_2(&r_a, resp_cred, &srv_flgs, status); + init_net_r_auth_2(&r_a, resp_cred, &srv_flgs, status); /* store the response in the SMB stream */ - net_io_r_auth_2("", &r_a, rdata, 0); + if(!net_io_r_auth_2("", &r_a, rdata, 0)) { + DEBUG(0,("net_reply_auth_2: Failed to marshall NET_R_AUTH_2.\n")); + return False; + } + return True; } /*********************************************************************************** - make_net_r_srv_pwset: + init_net_r_srv_pwset: ***********************************************************************************/ -static void make_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, + +static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, DOM_CRED *srv_cred, int status) { - DEBUG(5,("make_net_r_srv_pwset: %d\n", __LINE__)); + DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); - memcpy(&(r_s->srv_cred), srv_cred, sizeof(r_s->srv_cred)); + memcpy(&r_s->srv_cred, srv_cred, sizeof(r_s->srv_cred)); r_s->status = status; - DEBUG(5,("make_net_r_srv_pwset: %d\n", __LINE__)); + DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); } /************************************************************************* net_reply_srv_pwset: *************************************************************************/ -static void net_reply_srv_pwset(NET_Q_SRV_PWSET *q_s, prs_struct *rdata, + +static BOOL net_reply_srv_pwset(NET_Q_SRV_PWSET *q_s, prs_struct *rdata, DOM_CRED *srv_cred, int status) { NET_R_SRV_PWSET r_s; @@ -190,19 +188,24 @@ static void net_reply_srv_pwset(NET_Q_SRV_PWSET *q_s, prs_struct *rdata, DEBUG(5,("net_srv_pwset: %d\n", __LINE__)); /* set up the LSA Server Password Set response */ - make_net_r_srv_pwset(&r_s, srv_cred, status); + init_net_r_srv_pwset(&r_s, srv_cred, status); /* store the response in the SMB stream */ - net_io_r_srv_pwset("", &r_s, rdata, 0); + if(!net_io_r_srv_pwset("", &r_s, rdata, 0)) { + DEBUG(0,("net_reply_srv_pwset: Failed to marshall NET_R_SRV_PWSET.\n")); + return False; + } DEBUG(5,("net_srv_pwset: %d\n", __LINE__)); + return True; } /************************************************************************* net_reply_sam_logon: *************************************************************************/ -static void net_reply_sam_logon(NET_Q_SAM_LOGON *q_s, prs_struct *rdata, + +static BOOL net_reply_sam_logon(NET_Q_SAM_LOGON *q_s, prs_struct *rdata, DOM_CRED *srv_cred, NET_USER_INFO_3 *user_info, uint32 status) { @@ -210,32 +213,33 @@ static void net_reply_sam_logon(NET_Q_SAM_LOGON *q_s, prs_struct *rdata, /* XXXX maybe we want to say 'no', reject the client's credentials */ r_s.buffer_creds = 1; /* yes, we have valid server credentials */ - memcpy(&(r_s.srv_creds), srv_cred, sizeof(r_s.srv_creds)); + memcpy(&r_s.srv_creds, srv_cred, sizeof(r_s.srv_creds)); /* store the user information, if there is any. */ r_s.user = user_info; if (status == 0x0 && user_info != NULL && user_info->ptr_user_info != 0) - { r_s.switch_value = 3; /* indicates type of validation user info */ - } else - { r_s.switch_value = 0; /* indicates no info */ - } r_s.status = status; r_s.auth_resp = 1; /* authoritative response */ /* store the response in the SMB stream */ - net_io_r_sam_logon("", &r_s, rdata, 0); + if(!net_io_r_sam_logon("", &r_s, rdata, 0)) { + DEBUG(0,("net_reply_sam_logon: Failed to marshall NET_R_SAM_LOGON.\n")); + return False; + } + return True; } /************************************************************************* net_reply_sam_logoff: *************************************************************************/ -static void net_reply_sam_logoff(NET_Q_SAM_LOGOFF *q_s, prs_struct *rdata, + +static BOOL net_reply_sam_logoff(NET_Q_SAM_LOGOFF *q_s, prs_struct *rdata, DOM_CRED *srv_cred, uint32 status) { @@ -243,63 +247,23 @@ static void net_reply_sam_logoff(NET_Q_SAM_LOGOFF *q_s, prs_struct *rdata, /* XXXX maybe we want to say 'no', reject the client's credentials */ r_s.buffer_creds = 1; /* yes, we have valid server credentials */ - memcpy(&(r_s.srv_creds), srv_cred, sizeof(r_s.srv_creds)); + memcpy(&r_s.srv_creds, srv_cred, sizeof(r_s.srv_creds)); r_s.status = status; /* store the response in the SMB stream */ - net_io_r_sam_logoff("", &r_s, rdata, 0); - -} - -/************************************************************************* - net_reply_sam_sync: - *************************************************************************/ -static void net_reply_sam_sync(NET_Q_SAM_SYNC *q_s, prs_struct *rdata, - uint8 sess_key[16], - DOM_CRED *srv_creds, uint32 status) -{ - NET_R_SAM_SYNC r_s; - int i = 0; - struct sam_passwd *pwd; - void *vp; - - memcpy(&(r_s.srv_creds), srv_creds, sizeof(r_s.srv_creds)); - r_s.sync_context = 1; - r_s.ptr_deltas = 0; - - if ((status == 0x0) && ((vp = startsmbpwent(False)) != NULL)) - { - /* Give the poor BDC some accounts */ - - while (((pwd = getsam21pwent(vp)) != NULL) && (i < MAX_SAM_DELTAS)) - { - make_sam_delta_hdr(&r_s.hdr_deltas[i], 5, pwd->user_rid); - make_sam_account_info(&r_s.deltas[i].account_info, - pwd->nt_name, pwd->full_name, pwd->user_rid, - pwd->group_rid, pwd->home_dir, pwd->dir_drive, - pwd->logon_script, pwd->acct_desc, - pwd->acct_ctrl, pwd->profile_path); - - i++; - } - - endsmbpwent(vp); - - r_s.ptr_deltas = r_s.ptr_deltas2 = 1; - r_s.num_deltas = r_s.num_deltas2 = i; + if(!net_io_r_sam_logoff("", &r_s, rdata, 0)) { + DEBUG(0,("net_reply_sam_logoff: Failed to marshall NET_R_SAM_LOGOFF.\n")); + return False; } - r_s.status = status; - - /* store the response in the SMB stream */ - net_io_r_sam_sync("", sess_key, &r_s, rdata, 0); - + return True; } /****************************************************************** gets a machine password entry. checks access rights of the host. ******************************************************************/ + static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) { struct smb_passwd *smb_pass; @@ -334,13 +298,6 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) return True; } - if (strequal(mach_name, global_myname)) - { - DEBUG(0,("get_md4pw: *** LOOPBACK DETECTED - USING NULL KEY ***\n")); - memset(md4pw, 0, 16); - return True; - } - DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); return False; } @@ -348,9 +305,8 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) /************************************************************************* api_net_req_chal: *************************************************************************/ -static void api_net_req_chal( rpcsrv_struct *p, - prs_struct *data, - prs_struct *rdata) + +static BOOL api_net_req_chal( uint16 vuid, prs_struct *data, prs_struct *rdata) { NET_Q_REQ_CHAL q_r; uint32 status = 0x0; @@ -358,93 +314,60 @@ static void api_net_req_chal( rpcsrv_struct *p, fstring mach_acct; fstring mach_name; - DEBUG(5,("api_net_req_chal(%d)\n", __LINE__)); + user_struct *vuser; + + DEBUG(5,("api_net_req_chal(%d): vuid %d\n", __LINE__, (int)vuid)); + + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return False; /* grab the challenge... */ - net_io_q_req_chal("", &q_r, data, 0); + if(!net_io_q_req_chal("", &q_r, data, 0)) { + DEBUG(0,("api_net_req_chal: Failed to unmarshall NET_Q_REQ_CHAL.\n")); + return False; + } - unistr2_to_ascii(mach_acct, &q_r.uni_logon_clnt, sizeof(mach_acct)-1); + fstrcpy(mach_acct, dos_unistrn2(q_r.uni_logon_clnt.buffer, + q_r.uni_logon_clnt.uni_str_len)); fstrcpy(mach_name, mach_acct); strlower(mach_name); fstrcat(mach_acct, "$"); - if (get_md4pw((char *)p->dc.md4pw, mach_name, mach_acct)) - { + if (get_md4pw((char *)vuser->dc.md4pw, mach_name, mach_acct)) { /* copy the client credentials */ - memcpy(p->dc.clnt_chal.data , q_r.clnt_chal.data, sizeof(q_r.clnt_chal.data)); - memcpy(p->dc.clnt_cred.challenge.data, q_r.clnt_chal.data, sizeof(q_r.clnt_chal.data)); + memcpy(vuser->dc.clnt_chal.data , q_r.clnt_chal.data, sizeof(q_r.clnt_chal.data)); + memcpy(vuser->dc.clnt_cred.challenge.data, q_r.clnt_chal.data, sizeof(q_r.clnt_chal.data)); /* create a server challenge for the client */ /* Set these to random values. */ - generate_random_buffer(p->dc.srv_chal.data, 8, False); + generate_random_buffer(vuser->dc.srv_chal.data, 8, False); - memcpy(p->dc.srv_cred.challenge.data, p->dc.srv_chal.data, 8); + memcpy(vuser->dc.srv_cred.challenge.data, vuser->dc.srv_chal.data, 8); - bzero(p->dc.sess_key, sizeof(p->dc.sess_key)); + memset((char *)vuser->dc.sess_key, '\0', sizeof(vuser->dc.sess_key)); /* from client / server challenges and md4 password, generate sess key */ - cred_session_key(&(p->dc.clnt_chal), &(p->dc.srv_chal), - (char *)p->dc.md4pw, p->dc.sess_key); - } - else - { + cred_session_key(&(vuser->dc.clnt_chal), &(vuser->dc.srv_chal), + (char *)vuser->dc.md4pw, vuser->dc.sess_key); + } else { /* lkclXXXX take a guess at a good error message to return :-) */ status = 0xC0000000 | NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT; } /* construct reply. */ - net_reply_req_chal(&q_r, rdata, - &(p->dc.srv_chal), status); - -} - -/************************************************************************* - api_net_auth: - *************************************************************************/ -static void api_net_auth( rpcsrv_struct *p, - prs_struct *data, - prs_struct *rdata) -{ - NET_Q_AUTH q_a; - uint32 status = 0x0; - - DOM_CHAL srv_cred; - UTIME srv_time; - - srv_time.time = 0; - - /* grab the challenge... */ - net_io_q_auth("", &q_a, data, 0); - - /* check that the client credentials are valid */ - if (cred_assert(&(q_a.clnt_chal), p->dc.sess_key, - &(p->dc.clnt_cred.challenge), srv_time)) - { - - /* create server challenge for inclusion in the reply */ - cred_create(p->dc.sess_key, &(p->dc.srv_cred.challenge), srv_time, &srv_cred); - - /* copy the received client credentials for use next time */ - memcpy(p->dc.clnt_cred.challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); - memcpy(p->dc.srv_cred .challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); - } - else - { - status = NT_STATUS_ACCESS_DENIED | 0xC0000000; - } + if(!net_reply_req_chal(&q_r, rdata, &vuser->dc.srv_chal, status)) + return False; - /* construct reply. */ - net_reply_auth(&q_a, rdata, &srv_cred, status); + return True; } /************************************************************************* api_net_auth_2: *************************************************************************/ -static void api_net_auth_2( rpcsrv_struct *p, - prs_struct *data, - prs_struct *rdata) + +static BOOL api_net_auth_2( uint16 vuid, prs_struct *data, prs_struct *rdata) { NET_Q_AUTH_2 q_a; uint32 status = 0x0; @@ -452,38 +375,46 @@ static void api_net_auth_2( rpcsrv_struct *p, DOM_CHAL srv_cred; UTIME srv_time; + user_struct *vuser; + + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return False; + srv_time.time = 0; /* grab the challenge... */ - net_io_q_auth_2("", &q_a, data, 0); + if(!net_io_q_auth_2("", &q_a, data, 0)) { + DEBUG(0,("api_net_auth_2: Failed to unmarshall NET_Q_AUTH_2.\n")); + return False; + } /* check that the client credentials are valid */ - if (cred_assert(&(q_a.clnt_chal), p->dc.sess_key, - &(p->dc.clnt_cred.challenge), srv_time)) - { + if (cred_assert(&(q_a.clnt_chal), vuser->dc.sess_key, + &(vuser->dc.clnt_cred.challenge), srv_time)) { /* create server challenge for inclusion in the reply */ - cred_create(p->dc.sess_key, &(p->dc.srv_cred.challenge), srv_time, &srv_cred); + cred_create(vuser->dc.sess_key, &(vuser->dc.srv_cred.challenge), srv_time, &srv_cred); /* copy the received client credentials for use next time */ - memcpy(p->dc.clnt_cred.challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); - memcpy(p->dc.srv_cred .challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); - } - else - { + memcpy(vuser->dc.clnt_cred.challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); + memcpy(vuser->dc.srv_cred .challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); + } else { status = NT_STATUS_ACCESS_DENIED | 0xC0000000; } /* construct reply. */ - net_reply_auth_2(&q_a, rdata, &srv_cred, status); + if(!net_reply_auth_2(&q_a, rdata, &srv_cred, status)) + return False; + + return True; } + /************************************************************************* api_net_srv_pwset: *************************************************************************/ -static void api_net_srv_pwset( rpcsrv_struct *p, - prs_struct *data, - prs_struct *rdata) + +static BOOL api_net_srv_pwset( uint16 vuid, prs_struct *data, prs_struct *rdata) { NET_Q_SRV_PWSET q_a; uint32 status = NT_STATUS_WRONG_PASSWORD|0xC0000000; @@ -491,20 +422,27 @@ static void api_net_srv_pwset( rpcsrv_struct *p, pstring mach_acct; struct smb_passwd *smb_pass; BOOL ret; + user_struct *vuser; + + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return False; /* grab the challenge and encrypted password ... */ - net_io_q_srv_pwset("", &q_a, data, 0); + if(!net_io_q_srv_pwset("", &q_a, data, 0)) { + DEBUG(0,("api_net_srv_pwset: Failed to unmarshall NET_Q_SRV_PWSET.\n")); + return False; + } /* checks and updates credentials. creates reply credentials */ - if (deal_with_creds(p->dc.sess_key, &(p->dc.clnt_cred), + if (deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), &(q_a.clnt_id.cred), &srv_cred)) { - memcpy(&(p->dc.srv_cred), &(p->dc.clnt_cred), sizeof(p->dc.clnt_cred)); + memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); - unistr2_to_ascii(mach_acct, &q_a.clnt_id.login.uni_acct_name, - sizeof(mach_acct)-1); + pstrcpy(mach_acct, dos_unistrn2(q_a.clnt_id.login.uni_acct_name.buffer, + q_a.clnt_id.login.uni_acct_name.uni_str_len)); DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); @@ -512,19 +450,16 @@ static void api_net_srv_pwset( rpcsrv_struct *p, smb_pass = getsmbpwnam(mach_acct); unbecome_root(True); - if (smb_pass != NULL) - { + if (smb_pass != NULL) { unsigned char pwd[16]; int i; DEBUG(100,("Server password set : new given value was :\n")); for(i = 0; i < 16; i++) - { DEBUG(100,("%02X ", q_a.pwd[i])); - } DEBUG(100,("\n")); - cred_hash3( pwd, q_a.pwd, p->dc.sess_key, 0); + cred_hash3( pwd, q_a.pwd, vuser->dc.sess_key, 0); /* lies! nt and lm passwords are _not_ the same: don't care */ smb_pass->smb_passwd = pwd; @@ -535,8 +470,7 @@ static void api_net_srv_pwset( rpcsrv_struct *p, ret = mod_smbpwd_entry(smb_pass,False); unbecome_root(True); - if (ret) - { + if (ret) { /* hooray! */ status = 0x0; } @@ -544,83 +478,63 @@ static void api_net_srv_pwset( rpcsrv_struct *p, DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); - } - else - { + } else { /* lkclXXXX take a guess at a sensible error code to return... */ status = 0xC0000000 | NT_STATUS_NETWORK_CREDENTIAL_CONFLICT; } /* Construct reply. */ - net_reply_srv_pwset(&q_a, rdata, &srv_cred, status); + if(!net_reply_srv_pwset(&q_a, rdata, &srv_cred, status)) + return False; + + return True; } /************************************************************************* api_net_sam_logoff: *************************************************************************/ -static void api_net_sam_logoff( rpcsrv_struct *p, - prs_struct *data, - prs_struct *rdata) + +static BOOL api_net_sam_logoff( uint16 vuid, prs_struct *data, prs_struct *rdata) { NET_Q_SAM_LOGOFF q_l; NET_ID_INFO_CTR ctr; DOM_CRED srv_cred; + user_struct *vuser; + + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return False; + /* the DOM_ID_INFO_1 structure is a bit big. plus we might want to dynamically allocate it inside net_io_q_sam_logon, at some point */ q_l.sam_id.ctr = &ctr; /* grab the challenge... */ - net_io_q_sam_logoff("", &q_l, data, 0); + if(!net_io_q_sam_logoff("", &q_l, data, 0)) { + DEBUG(0,("api_net_sam_logoff: Failed to unmarshall NET_Q_SAM_LOGOFF.\n")); + return False; + } /* checks and updates credentials. creates reply credentials */ - deal_with_creds(p->dc.sess_key, &(p->dc.clnt_cred), - &(q_l.sam_id.client.cred), &srv_cred); - memcpy(&(p->dc.srv_cred), &(p->dc.clnt_cred), sizeof(p->dc.clnt_cred)); + deal_with_creds(vuser->dc.sess_key, &vuser->dc.clnt_cred, + &q_l.sam_id.client.cred, &srv_cred); + memcpy(&vuser->dc.srv_cred, &vuser->dc.clnt_cred, sizeof(vuser->dc.clnt_cred)); /* construct reply. always indicate success */ - net_reply_sam_logoff(&q_l, rdata, &srv_cred, 0x0); -} - -/************************************************************************* - api_net_sam_sync: - *************************************************************************/ -static void api_net_sam_sync( rpcsrv_struct *p, - prs_struct *data, - prs_struct *rdata) -{ - NET_Q_SAM_SYNC q_s; - DOM_CRED srv_creds; - uint32 status = 0x0; - - /* grab the challenge... */ - net_io_q_sam_sync("", &q_s, data, 0); - - /* checks and updates credentials. creates reply credentials */ - if (deal_with_creds(p->dc.sess_key, &(p->dc.clnt_cred), - &(q_s.cli_creds), &srv_creds)) - { - memcpy(&(p->dc.srv_cred), &(p->dc.clnt_cred), - sizeof(p->dc.clnt_cred)); - } - else - { - status = 0xC0000000 | NT_STATUS_NETWORK_CREDENTIAL_CONFLICT; - } + if(!net_reply_sam_logoff(&q_l, rdata, &srv_cred, 0x0)) + return False; - /* construct reply. */ - net_reply_sam_sync(&q_s, rdata, p->dc.sess_key, &srv_creds, status); + return True; } - /************************************************************************* net_login_interactive: *************************************************************************/ -static uint32 net_login_interactive(NET_ID_INFO_1 *id1, - struct sam_passwd *smb_pass, - struct dcinfo *dc) + +static uint32 net_login_interactive(NET_ID_INFO_1 *id1, struct smb_passwd *smb_pass, + user_struct *vuser) { uint32 status = 0x0; @@ -629,14 +543,14 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, unsigned char key[16]; memset(key, 0, 16); - memcpy(key, dc->sess_key, 8); + memcpy(key, vuser->dc.sess_key, 8); memcpy(lm_pwd, id1->lm_owf.data, 16); memcpy(nt_pwd, id1->nt_owf.data, 16); #ifdef DEBUG_PASSWORD DEBUG(100,("key:")); - dump_data(100, key, 16); + dump_data(100, (char *)key, 16); DEBUG(100,("lm owf password:")); dump_data(100, lm_pwd, 16); @@ -645,8 +559,8 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, dump_data(100, nt_pwd, 16); #endif - SamOEMhash((uchar *)lm_pwd, key, 0); - SamOEMhash((uchar *)nt_pwd, key, 0); + SamOEMhash((uchar *)lm_pwd, key, False); + SamOEMhash((uchar *)nt_pwd, key, False); #ifdef DEBUG_PASSWORD DEBUG(100,("decrypt of lm owf password:")); @@ -656,14 +570,7 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, dump_data(100, nt_pwd, 16); #endif - if (smb_pass->smb_nt_passwd == NULL) - { - DEBUG(5,("warning: NETLOGON user %s only has an LM password\n", - smb_pass->unix_name)); - } - if (memcmp(smb_pass->smb_passwd , lm_pwd, 16) != 0 || - smb_pass->smb_nt_passwd == NULL || memcmp(smb_pass->smb_nt_passwd, nt_pwd, 16) != 0) { status = 0xC0000000 | NT_STATUS_WRONG_PASSWORD; @@ -675,52 +582,45 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, /************************************************************************* net_login_network: *************************************************************************/ -static uint32 net_login_network(NET_ID_INFO_2 *id2, - struct sam_passwd *sam_pass, - struct dcinfo *dc, - char sess_key[16]) -{ - fstring user; - fstring domain; - - int nt_pw_len = id2->hdr_nt_chal_resp.str_str_len; - int lm_pw_len = id2->hdr_lm_chal_resp.str_str_len; - unistr2_to_ascii(user , &id2->uni_user_name, sizeof(user)-1); - unistr2_to_ascii(domain, &id2->uni_domain_name, sizeof(domain)-1); +static uint32 net_login_network(NET_ID_INFO_2 *id2, struct smb_passwd *smb_pass) +{ + 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)); - DEBUG(5,("net_login_network: lm_len:%d nt_len:%d user:%s domain:%s\n", - lm_pw_len, nt_pw_len, user, domain)); + /* 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 (pass_check_smb(pwdb_sam_to_smb(sam_pass), - domain, - id2->lm_chal, - (uchar *)id2->lm_chal_resp.buffer, lm_pw_len, - (uchar *)id2->nt_chal_resp.buffer, nt_pw_len, - NULL, sess_key)) + if (id2->hdr_nt_chal_resp.str_str_len == 24 && + smb_pass->smb_nt_passwd != NULL) { - unsigned char key[16]; - - memset(key, 0, 16); - memcpy(key, dc->sess_key, 8); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("key:")); - dump_data(100, key, 16); - - DEBUG(100,("user sess key:")); - dump_data(100, sess_key, 16); -#endif + if(smb_password_check((char *)id2->nt_chal_resp.buffer, + smb_pass->smb_nt_passwd, + id2->lm_chal)) + return 0x0; + else + return 0xC0000000 | NT_STATUS_WRONG_PASSWORD; + } - SamOEMhash((uchar *)sess_key, key, 0); + /* lkclXXXX this is not a good place to put disabling of LM hashes in. + if that is to be done, first move this entire function into a + library routine that calls the two smb_password_check() functions. + if disabling LM hashes (which nt can do for security reasons) then + an attempt should be made to disable them everywhere (which nt does + not do, for various security-hole reasons). + */ + + if (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)) + { + return 0x0; + } -#ifdef DEBUG_PASSWORD - DEBUG(100,("encrypt of user session key:")); - dump_data(100, sess_key, 16); -#endif - return 0x0; - } + /* oops! neither password check succeeded */ return 0xC0000000 | NT_STATUS_WRONG_PASSWORD; } @@ -728,242 +628,242 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, /************************************************************************* api_net_sam_logon: *************************************************************************/ -static uint32 reply_net_sam_logon(NET_Q_SAM_LOGON *q_l, - struct dcinfo *dc, - DOM_CRED *srv_cred, NET_USER_INFO_3 *usr_info) -{ - struct sam_passwd *sam_pass = NULL; - UNISTR2 *uni_samusr = NULL; - UNISTR2 *uni_domain = NULL; - fstring nt_username; - char *enc_user_sess_key = NULL; - char sess_key[16]; - - NTTIME logon_time ; - NTTIME logoff_time ; - NTTIME kickoff_time ; - NTTIME pass_last_set_time ; - NTTIME pass_can_change_time ; - NTTIME pass_must_change_time; - - fstring nt_name ; - fstring full_name ; - fstring logon_script; - fstring profile_path; - fstring home_dir ; - fstring dir_drive ; - - uint32 user_rid ; - uint32 group_rid; - - int num_gids = 0; - DOMAIN_GRP *grp_mem = NULL; - DOM_GID *gids = NULL; - - /* checks and updates credentials. creates reply credentials */ - if (!deal_with_creds(dc->sess_key, &(dc->clnt_cred), - &(q_l->sam_id.client.cred), srv_cred)) - { - return 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - - memcpy(&(dc->srv_cred), &(dc->clnt_cred), sizeof(dc->clnt_cred)); - - /* find the username */ - - switch (q_l->sam_id.logon_level) - { - case INTERACTIVE_LOGON_TYPE: - { - uni_samusr = &(q_l->sam_id.ctr->auth.id1.uni_user_name); - uni_domain = &(q_l->sam_id.ctr->auth.id1.uni_domain_name); - - DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", global_sam_name)); - break; - } - case NET_LOGON_TYPE: - { - uni_samusr = &(q_l->sam_id.ctr->auth.id2.uni_user_name); - uni_domain = &(q_l->sam_id.ctr->auth.id2.uni_domain_name); - - DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", global_sam_name)); - break; - } - default: - { - DEBUG(2,("SAM Logon: unsupported switch value\n")); - return 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; - } - } - - /* check username exists */ - - unistr2_to_ascii(nt_username, uni_samusr, - sizeof(nt_username)-1); - DEBUG(3,("User:[%s]\n", nt_username)); - - become_root(True); - sam_pass = getsam21pwntnam(nt_username); - unbecome_root(True); - - if (sam_pass == NULL) - { - return 0xC0000000 | NT_STATUS_NO_SUCH_USER; - } - else if (IS_BITS_SET_ALL(sam_pass->acct_ctrl, ACB_DISABLED) && - IS_BITS_CLR_ALL(sam_pass->acct_ctrl, ACB_PWNOTREQ)) - { - return 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED; - } +static BOOL api_net_sam_logon( uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + NET_Q_SAM_LOGON q_l; + NET_ID_INFO_CTR ctr; + NET_USER_INFO_3 usr_info; + uint32 status = 0x0; + DOM_CRED srv_cred; + struct smb_passwd *smb_pass = NULL; + UNISTR2 *uni_samlogon_user = NULL; + fstring nt_username; + + user_struct *vuser = NULL; + + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return False; + + memset(&q_l, '\0', sizeof(q_l)); + memset(&ctr, '\0', sizeof(ctr)); + memset(&usr_info, '\0', sizeof(usr_info)); + + q_l.sam_id.ctr = &ctr; + + if(!net_io_q_sam_logon("", &q_l, data, 0)) { + DEBUG(0,("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n")); + return False; + } + + /* checks and updates credentials. creates reply credentials */ + if (!deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), + &(q_l.sam_id.client.cred), &srv_cred)) + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + else + memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); + + /* find the username */ + + if (status == 0) { + switch (q_l.sam_id.logon_level) { + case INTERACTIVE_LOGON_TYPE: + uni_samlogon_user = &q_l.sam_id.ctr->auth.id1.uni_user_name; + + DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); + break; + case NET_LOGON_TYPE: + uni_samlogon_user = &q_l.sam_id.ctr->auth.id2.uni_user_name; + + DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); + break; + default: + DEBUG(2,("SAM Logon: unsupported switch value\n")); + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + break; + } /* end switch */ + } /* end if status == 0 */ + + /* check username exists */ + + if (status == 0) { + pstrcpy(nt_username, dos_unistrn2(uni_samlogon_user->buffer, + uni_samlogon_user->uni_str_len)); + + DEBUG(3,("User:[%s]\n", nt_username)); - logon_time = sam_pass->logon_time; - logoff_time = sam_pass->logoff_time; - kickoff_time = sam_pass->kickoff_time; - pass_last_set_time = sam_pass->pass_last_set_time; - pass_can_change_time = sam_pass->pass_can_change_time; - pass_must_change_time = sam_pass->pass_must_change_time; + /* + * Convert to a UNIX username. + */ + map_username(nt_username); - fstrcpy(nt_name , sam_pass->nt_name); - fstrcpy(full_name , sam_pass->full_name); - fstrcpy(logon_script, sam_pass->logon_script); - fstrcpy(profile_path, sam_pass->profile_path); - fstrcpy(home_dir , sam_pass->home_dir); - fstrcpy(dir_drive , sam_pass->dir_drive); + /* + * Do any case conversions. + */ + (void)Get_Pwnam(nt_username, True); + + become_root(True); + smb_pass = getsmbpwnam(nt_username); + unbecome_root(True); + + if (smb_pass == NULL) + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + else if (smb_pass->acct_ctrl & ACB_PWNOTREQ) + status = 0; + else if (smb_pass->acct_ctrl & ACB_DISABLED) + status = 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED; + } + + /* Validate password - if required. */ + + if ((status == 0) && !(smb_pass->acct_ctrl & ACB_PWNOTREQ)) { + switch (q_l.sam_id.logon_level) { + case INTERACTIVE_LOGON_TYPE: + /* interactive login. */ + status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, smb_pass, vuser); + break; + case NET_LOGON_TYPE: + /* network login. lm challenge and 24 byte responses */ + status = net_login_network(&q_l.sam_id.ctr->auth.id2, smb_pass); + break; + } + } + + /* 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. + */ - user_rid = sam_pass->user_rid; - group_rid = sam_pass->group_rid; + /* return the profile plus other bits :-) */ - /* validate password - if required */ + if (status == 0) { + DOM_GID *gids = NULL; + int num_gids = 0; + NTTIME dummy_time; + pstring logon_script; + pstring profile_path; + pstring home_dir; + pstring home_drive; + pstring my_name; + pstring my_workgroup; + pstring domain_groups; + uint32 r_uid; + uint32 r_gid; - if (!(IS_BITS_SET_ALL(sam_pass->acct_ctrl, ACB_PWNOTREQ))) - { - uint32 status = 0x0; - switch (q_l->sam_id.logon_level) - { - case INTERACTIVE_LOGON_TYPE: - { - /* interactive login. */ - status = net_login_interactive(&q_l->sam_id.ctr->auth.id1, sam_pass, dc); - break; - } - case NET_LOGON_TYPE: - { - /* network login. lm challenge and 24 byte responses */ - status = net_login_network(&q_l->sam_id.ctr->auth.id2, sam_pass, dc, sess_key); - enc_user_sess_key = sess_key; - break; - } - } - if (status != 0x0) - { - return status; - } - } + /* set up pointer indicating user/password failed to be found */ + usr_info.ptr_user_info = 0; - /* 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. - */ + dummy_time.low = 0xffffffff; + dummy_time.high = 0x7fffffff; - /* return the profile plus other bits :-) */ + /* 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); - /* set up pointer indicating user/password failed to be found */ - usr_info->ptr_user_info = 0; + pstrcpy(logon_script, lp_logon_script()); + pstrcpy(profile_path, lp_logon_path()); - if (!getusergroupsntnam(nt_username, &grp_mem, &num_gids)) - { - return 0xC0000000 | NT_STATUS_INVALID_PRIMARY_GROUP; - } + pstrcpy(my_workgroup, lp_workgroup()); - num_gids = make_dom_gids(grp_mem, num_gids, &gids); - - make_net_user_info3(usr_info, - &logon_time, - &logoff_time, - &kickoff_time, - &pass_last_set_time, - &pass_can_change_time, - &pass_must_change_time, - - nt_name , /* user_name */ - full_name , /* full_name */ - logon_script , /* logon_script */ - profile_path , /* profile_path */ - home_dir , /* home_dir */ - dir_drive , /* dir_drive */ - - 0, /* logon_count */ - 0, /* bad_pw_count */ - - user_rid , /* RID user_id */ - group_rid , /* RID group_id */ - num_gids, /* uint32 num_groups */ - gids , /* DOM_GID *gids */ - 0x20 , /* uint32 user_flgs (?) */ - - enc_user_sess_key, /* char sess_key[16] */ - - global_myname , /* char *logon_srv */ - global_sam_name, /* char *logon_dom */ - &global_sam_sid, /* DOM_SID *dom_sid */ - NULL); /* char *other_sids */ - - /* Free any allocated groups array. */ - if (gids) - { - free((char *)gids); - } + pstrcpy(home_drive, lp_logon_drive()); + pstrcpy(home_dir, lp_logon_home()); - return 0x0; -} + pstrcpy(my_name, global_myname); + strupper(my_name); -/************************************************************************* - api_net_sam_logon: - *************************************************************************/ -static void api_net_sam_logon( rpcsrv_struct *p, - prs_struct *data, - prs_struct *rdata) -{ - NET_Q_SAM_LOGON q_l; - NET_ID_INFO_CTR ctr; - NET_USER_INFO_3 usr_info; - uint32 status = 0x0; - DOM_CRED srv_cred; + /* + * This is the point at which we get the group + * database - we should be getting the gid_t list + * from /etc/group and then turning the uids into + * rids and then into machine sids for this user. + * JRA. + */ - q_l.sam_id.ctr = &ctr; - net_io_q_sam_logon("", &q_l, data, 0); + get_domain_user_groups(domain_groups, nt_username); - status = reply_net_sam_logon(&q_l, &p->dc, &srv_cred, &usr_info); - net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status); + /* + * make_dom_gids allocates the gids array. JRA. + */ + gids = NULL; + num_gids = make_dom_gids(domain_groups, &gids); + + sam_logon_in_ssb = False; + + if (pdb_name_to_rid(nt_username, &r_uid, &r_gid)) + init_net_user_info3(&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 */ + vuser->real_name, /* full_name */ + logon_script , /* logon_script */ + profile_path , /* profile_path */ + home_dir , /* home_dir */ + home_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 + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + + /* Free any allocated groups array. */ + if(gids) + free((char *)gids); + } + + if(!net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status)) + return False; + + return True; } /************************************************************************* api_net_trust_dom_list: *************************************************************************/ -static void api_net_trust_dom_list( rpcsrv_struct *p, - prs_struct *data, - prs_struct *rdata) + +static BOOL api_net_trust_dom_list( uint16 vuid, + prs_struct *data, + prs_struct *rdata) { NET_Q_TRUST_DOM_LIST q_t; - char **doms = NULL; - uint32 num_doms = 0; - enumtrustdoms(&doms, &num_doms); + char *trusted_domain = "test_domain"; DEBUG(6,("api_net_trust_dom_list: %d\n", __LINE__)); /* grab the lsa trusted domain list query... */ - net_io_q_trust_dom("", &q_t, data, 0); + if(!net_io_q_trust_dom("", &q_t, data, 0)) { + DEBUG(0,("api_net_trust_dom_list: Failed to unmarshall NET_Q_TRUST_DOM_LIST.\n")); + return False; + } /* construct reply. */ - net_reply_trust_dom_list(&q_t, rdata, - num_doms, doms); - - free_char_array(num_doms, doms); + if(!net_reply_trust_dom_list(&q_t, rdata, 1, trusted_domain)) + return False; DEBUG(6,("api_net_trust_dom_list: %d\n", __LINE__)); + + return True; } @@ -976,7 +876,8 @@ static void api_net_trust_dom_list( rpcsrv_struct *p, /************************************************************************* api_net_logon_ctrl2: *************************************************************************/ -static void api_net_logon_ctrl2( rpcsrv_struct *p, + +static BOOL api_net_logon_ctrl2( uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -992,14 +893,20 @@ static void api_net_logon_ctrl2( rpcsrv_struct *p, DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__)); /* grab the lsa netlogon ctrl2 query... */ - net_io_q_logon_ctrl2("", &q_l, data, 0); + if(!net_io_q_logon_ctrl2("", &q_l, data, 0)) { + DEBUG(0,("api_net_logon_ctrl2: Failed to unmarshall NET_Q_LOGON_CTRL2.\n")); + return False; + } /* construct reply. */ - net_reply_logon_ctrl2(&q_l, rdata, + if(!net_reply_logon_ctrl2(&q_l, rdata, flags, pdc_connection_status, logon_attempts, - tc_status, trusted_domain); + tc_status, trusted_domain)) + return False; DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__)); + + return True; } /******************************************************************* @@ -1008,21 +915,20 @@ static void api_net_logon_ctrl2( rpcsrv_struct *p, static struct api_struct api_net_cmds [] = { { "NET_REQCHAL" , NET_REQCHAL , api_net_req_chal }, - { "NET_AUTH" , NET_AUTH , api_net_auth }, { "NET_AUTH2" , NET_AUTH2 , api_net_auth_2 }, { "NET_SRVPWSET" , NET_SRVPWSET , api_net_srv_pwset }, { "NET_SAMLOGON" , NET_SAMLOGON , api_net_sam_logon }, { "NET_SAMLOGOFF" , NET_SAMLOGOFF , api_net_sam_logoff }, { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 }, { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, - { "NET_SAM_SYNC" , NET_SAM_SYNC , api_net_sam_sync }, - { NULL , 0 , NULL } + { NULL , 0 , NULL } }; /******************************************************************* receives a netlogon pipe and responds. ********************************************************************/ -BOOL api_netlog_rpc(rpcsrv_struct *p, prs_struct *data) + +BOOL api_netlog_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_netlog_rpc", api_net_cmds, data); } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index d15cc1248c..236558ba70 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1,4 +1,3 @@ - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -6,6 +5,7 @@ * Copyright (C) Andrew Tridgell 1992-1998 * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, * Copyright (C) Paul Ashton 1997-1998. + * Copyright (C) Jeremy Allison 1999. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,15 +43,14 @@ extern int DEBUGLEVEL; -static void NTLMSSPcalc_p( rpcsrv_struct *p, unsigned char *data, int len) +static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) { unsigned char *hash = p->ntlmssp_hash; unsigned char index_i = hash[256]; unsigned char index_j = hash[257]; int ind; - for( ind = 0; ind < len; ind++) - { + for( ind = 0; ind < len; ind++) { unsigned char tc; unsigned char t; @@ -71,250 +70,332 @@ static void NTLMSSPcalc_p( rpcsrv_struct *p, unsigned char *data, int len) } /******************************************************************* - frees all temporary data used in construction of pdu + Generate the next PDU to be returned from the data in p->rdata. + We cheat here as this function doesn't handle the special auth + footers of the authenticated bind response reply. ********************************************************************/ -void rpcsrv_free_temp(rpcsrv_struct *l) + +BOOL create_next_pdu(pipes_struct *p) { - mem_free_data(l->rhdr .data); - mem_free_data(l->rfault .data); - mem_free_data(l->rdata_i.data); - mem_free_data(l->rauth .data); - mem_free_data(l->rverf .data); - mem_free_data(l->rntlm .data); -} + RPC_HDR_RESP hdr_resp; + BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SIGN); + BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SEAL); + uint32 data_len; + uint32 data_space_available; + uint32 data_len_left; + prs_struct outgoing_pdu; + char *data; + char *data_from; + uint32 data_pos; -/******************************************************************* - turns a DCE/RPC request into a DCE/RPC reply + memset((char *)&hdr_resp, '\0', sizeof(hdr_resp)); - this is where the data really should be split up into an array of - headers and data sections. + /* Change the incoming request header to a response. */ + p->hdr.pkt_type = RPC_RESPONSE; - ********************************************************************/ -BOOL create_rpc_reply(rpcsrv_struct *l, uint32 data_start) -{ - char *data; - BOOL auth_verify = IS_BITS_SET_ALL(l->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SIGN); - BOOL auth_seal = IS_BITS_SET_ALL(l->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SEAL); - uint32 data_len; - uint32 auth_len; - uint32 data_end = l->rdata.offset + (l->ntlmssp_auth ? (8 + 16) : 0); + /* Set up rpc header flags. */ + if (p->data_sent_length == 0) + p->hdr.flags = RPC_FLG_FIRST; + else + p->hdr.flags = 0; - DEBUG(5,("create_rpc_reply: data_start: %d data_end: %d max_tsize: %d\n", - data_start, data_end, l->hdr_ba.bba.max_tsize)); + /* + * Work out how much we can fit in a sigle PDU. + */ - auth_len = l->hdr.auth_len; + data_space_available = sizeof(p->current_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN; + if(p->ntlmssp_auth_validated) + data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN); - if (l->ntlmssp_auth) - { - DEBUG(10,("create_rpc_reply: auth\n")); - if (auth_len != 16) - { - return False; - } - } + /* + * The amount we send is the minimum of the available + * space and the amount left to send. + */ - prs_init(&l->rhdr , 0x18, 4, 0, False); - prs_init(&l->rauth, 1024, 4, 0, False); - prs_init(&l->rverf, 0x10, 4, 0, False); + data_len_left = prs_offset(&p->rdata) - p->data_sent_length; - l->hdr.pkt_type = RPC_RESPONSE; /* mark header as an rpc response */ + /* + * Ensure there really is data left to send. + */ - /* set up rpc header (fragmentation issues) */ - if (data_start == 0) - { - l->hdr.flags = RPC_FLG_FIRST; - } - else - { - l->hdr.flags = 0; + if(!data_len_left) { + DEBUG(0,("create_next_pdu: no data left to send !\n")); + return False; } - l->hdr_resp.alloc_hint = data_end - data_start; /* calculate remaining data to be sent */ + data_len = MIN(data_len_left, data_space_available); - if (l->hdr_resp.alloc_hint + 0x18 <= l->hdr_ba.bba.max_tsize) - { - l->hdr.flags |= RPC_FLG_LAST; - l->hdr.frag_len = l->hdr_resp.alloc_hint + 0x18; - } - else - { - l->hdr.frag_len = l->hdr_ba.bba.max_tsize; - } + /* + * Set up the alloc hint. This should be the data left to + * send. + */ - if (l->ntlmssp_auth) - { - l->hdr_resp.alloc_hint -= auth_len + 8; + hdr_resp.alloc_hint = data_len_left; + + /* + * Set up the header lengths. + */ + + if (p->ntlmssp_auth_validated) { + p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len + + RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN; + p->hdr.auth_len = RPC_AUTH_NTLMSSP_CHK_LEN; + } else { + p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len; + p->hdr.auth_len = 0; } - if (l->ntlmssp_auth) - { - data_len = l->hdr.frag_len - auth_len - (auth_verify ? 8 : 0) - 0x18; + /* + * Work out if this PDU will be the last. + */ + + if(p->data_sent_length + data_len >= prs_offset(&p->rdata)) + p->hdr.flags |= RPC_FLG_LAST; + + /* + * Init the parse struct to point at the outgoing + * data. + */ + + prs_init( &outgoing_pdu, 0, 4, MARSHALL); + prs_give_memory( &outgoing_pdu, (char *)p->current_pdu, sizeof(p->current_pdu), False); + + /* Store the header in the data stream. */ + if(!smb_io_rpc_hdr("hdr", &p->hdr, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR.\n")); + return False; } - else - { - data_len = l->hdr.frag_len - 0x18; + + if(!smb_io_rpc_hdr_resp("resp", &hdr_resp, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_RESP.\n")); + return False; } - l->rhdr.data->offset.start = 0; - l->rhdr.data->offset.end = 0x18; + /* Store the current offset. */ + data_pos = prs_offset(&outgoing_pdu); - /* store the header in the data stream */ - smb_io_rpc_hdr ("hdr" , &(l->hdr ), &(l->rhdr), 0); - smb_io_rpc_hdr_resp("resp", &(l->hdr_resp), &(l->rhdr), 0); + /* Copy the data into the PDU. */ + data_from = prs_data_p(&p->rdata) + p->data_sent_length; + + if(!prs_append_data(&outgoing_pdu, data_from, data_len)) { + DEBUG(0,("create_next_pdu: failed to copy %u bytes of data.\n", (unsigned int)data_len)); + return False; + } - /* don't use rdata: use rdata_i instead, which moves... */ - /* make a pointer to the rdata data, NOT A COPY */ + /* + * Set data to point to where we copied the data into. + */ - l->rdata_i.data = NULL; - prs_init(&l->rdata_i, 0, l->rdata.align, l->rdata.data->margin, l->rdata.io); - data = mem_data(&(l->rdata.data), data_start); - mem_create(l->rdata_i.data, data, 0, data_len, 0, False); - l->rdata_i.offset = data_len; + data = prs_data_p(&outgoing_pdu) + data_pos; - if (auth_len > 0) - { + if (p->hdr.auth_len > 0) { uint32 crc32 = 0; - DEBUG(5,("create_rpc_reply: sign: %s seal: %s data %d auth %d\n", - BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); + DEBUG(5,("create_next_pdu: sign: %s seal: %s data %d auth %d\n", + BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, p->hdr.auth_len)); - if (auth_seal) - { - crc32 = crc32_calc_buffer(data_len, data); - NTLMSSPcalc_p(l, (uchar*)data, data_len); + if (auth_seal) { + crc32 = crc32_calc_buffer(data, data_len); + NTLMSSPcalc_p(p, (uchar*)data, data_len); } - if (auth_seal || auth_verify) - { - make_rpc_hdr_auth(&l->auth_info, 0x0a, 0x06, 0x08, (auth_verify ? 1 : 0)); - smb_io_rpc_hdr_auth("hdr_auth", &l->auth_info, &l->rauth, 0); + if (auth_seal || auth_verify) { + RPC_HDR_AUTH auth_info; + + init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, NTLMSSP_AUTH_LEVEL, + (auth_verify ? RPC_HDR_AUTH_LEN : 0), (auth_verify ? 1 : 0)); + if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_AUTH.\n")); + return False; + } } - if (auth_verify) - { - char *auth_data; - l->ntlmssp_seq_num++; - make_rpc_auth_ntlmssp_chk(&l->ntlmssp_chk, NTLMSSP_SIGN_VERSION, crc32, l->ntlmssp_seq_num++); - smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(l->ntlmssp_chk), &l->rverf, 0); - auth_data = mem_data(&l->rverf.data, 4); - NTLMSSPcalc_p(l, (uchar*)auth_data, 12); + if (auth_verify) { + RPC_AUTH_NTLMSSP_CHK ntlmssp_chk; + char *auth_data = prs_data_p(&outgoing_pdu); + + p->ntlmssp_seq_num++; + init_rpc_auth_ntlmssp_chk(&ntlmssp_chk, NTLMSSP_SIGN_VERSION, + crc32, p->ntlmssp_seq_num++); + auth_data = prs_data_p(&outgoing_pdu) + prs_offset(&outgoing_pdu) + 4; + if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &ntlmssp_chk, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_AUTH_NTLMSSP_CHK.\n")); + return False; + } + NTLMSSPcalc_p(p, (uchar*)auth_data, RPC_AUTH_NTLMSSP_CHK_LEN - 4); } } - /* set up the data chain */ - if (l->ntlmssp_auth) - { - prs_link(NULL , &l->rhdr , &l->rdata_i); - prs_link(&l->rhdr , &l->rdata_i, &l->rauth ); - prs_link(&l->rdata_i, &l->rauth , &l->rverf ); - prs_link(&l->rauth , &l->rverf , NULL ); - } - else - { - prs_link(NULL , &l->rhdr , &l->rdata_i); - prs_link(&l->rhdr, &l->rdata_i, NULL ); - } + /* + * Setup the counts for this PDU. + */ - return l->rhdr.data != NULL && l->rhdr.offset == 0x18; + p->data_sent_length += data_len; + p->current_pdu_len = p->hdr.frag_len; + p->current_pdu_sent = 0; + + return True; } -static BOOL api_pipe_ntlmssp_verify(rpcsrv_struct *l) +/******************************************************************* + Process an NTLMSSP authentication response. + If this function succeeds, the user has been authenticated + and their domain, name and calling workstation stored in + the pipe struct. + The initial challenge is stored in p->challenge. + *******************************************************************/ + +static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlmssp_resp) { - uchar *pwd = NULL; - uchar null_pwd[16]; uchar lm_owf[24]; - uchar nt_owf[128]; - size_t lm_owf_len; - size_t nt_owf_len; - size_t usr_len; - size_t dom_len; - size_t wks_len; - BOOL anonymous = False; + uchar nt_owf[24]; + fstring user_name; + fstring unix_user_name; + fstring domain; + fstring wks; + BOOL guest_user = False; + struct smb_passwd *smb_pass = NULL; + struct passwd *pass = NULL; + uchar null_smb_passwd[16]; + uchar *smb_passwd_ptr = NULL; + + DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); - memset(null_pwd, 0, sizeof(null_pwd)); + memset(p->user_name, '\0', sizeof(p->user_name)); + memset(p->unix_user_name, '\0', sizeof(p->unix_user_name)); + memset(p->domain, '\0', sizeof(p->domain)); + memset(p->wks, '\0', sizeof(p->wks)); - DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); + /* + * Setup an empty password for a guest user. + */ - lm_owf_len = l->ntlmssp_resp.hdr_lm_resp.str_str_len; - nt_owf_len = l->ntlmssp_resp.hdr_nt_resp.str_str_len; - usr_len = l->ntlmssp_resp.hdr_usr .str_str_len; - dom_len = l->ntlmssp_resp.hdr_domain .str_str_len; - wks_len = l->ntlmssp_resp.hdr_wks .str_str_len; + memset(null_smb_passwd,0,16); - if (lm_owf_len == 0 && nt_owf_len == 0 && - usr_len == 0 && dom_len == 0 && wks_len == 0) - { - anonymous = True; - } - else - { - if (lm_owf_len == 0) return False; - if (nt_owf_len == 0) return False; - if (l->ntlmssp_resp.hdr_usr .str_str_len == 0) return False; - if (l->ntlmssp_resp.hdr_domain .str_str_len == 0) return False; - if (l->ntlmssp_resp.hdr_wks .str_str_len == 0) return False; + /* + * We always negotiate UNICODE. + */ + + if (IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_UNICODE)) { + fstrcpy(user_name, dos_unistrn2((uint16*)ntlmssp_resp->user, ntlmssp_resp->hdr_usr.str_str_len/2)); + fstrcpy(domain, dos_unistrn2((uint16*)ntlmssp_resp->domain, ntlmssp_resp->hdr_domain.str_str_len/2)); + fstrcpy(wks, dos_unistrn2((uint16*)ntlmssp_resp->wks, ntlmssp_resp->hdr_wks.str_str_len/2)); + } else { + fstrcpy(user_name, ntlmssp_resp->user); + fstrcpy(domain, ntlmssp_resp->domain); + fstrcpy(wks, ntlmssp_resp->wks); } - if (lm_owf_len > sizeof(lm_owf)) return False; - if (nt_owf_len > sizeof(nt_owf)) return False; + DEBUG(5,("user: %s domain: %s wks: %s\n", user_name, domain, wks)); - memcpy(lm_owf, l->ntlmssp_resp.lm_resp, sizeof(lm_owf)); - memcpy(nt_owf, l->ntlmssp_resp.nt_resp, sizeof(nt_owf)); + memcpy(lm_owf, ntlmssp_resp->lm_resp, sizeof(lm_owf)); + memcpy(nt_owf, ntlmssp_resp->nt_resp, sizeof(nt_owf)); #ifdef DEBUG_PASSWORD DEBUG(100,("lm, nt owfs, chal\n")); - dump_data(100, lm_owf, sizeof(lm_owf)); - dump_data(100, nt_owf, sizeof(nt_owf)); - dump_data(100, l->ntlmssp_chal.challenge, 8); + dump_data(100, (char *)lm_owf, sizeof(lm_owf)); + dump_data(100, (char *)nt_owf, sizeof(nt_owf)); + dump_data(100, (char *)p->challenge, 8); #endif - memset(l->user_name, 0, sizeof(l->user_name)); - memset(l->domain , 0, sizeof(l->domain )); - memset(l->wks , 0, sizeof(l->wks )); + /* + * Allow guest access. Patch from Shirish Kalele . + */ + + if((strlen(user_name) == 0) && (ntlmssp_resp->hdr_lm_resp.str_str_len==0) && + (ntlmssp_resp->hdr_nt_resp.str_str_len==0)) { + + guest_user = True; + + fstrcpy(unix_user_name, lp_guestaccount(-1)); + DEBUG(100,("Null user in NTLMSSP verification. Using guest = %s\n", unix_user_name)); + + smb_passwd_ptr = null_smb_passwd; + + } else { + + /* + * Pass the user through the NT -> unix user mapping + * function. + */ + + fstrcpy(unix_user_name, user_name); + (void)map_username(unix_user_name); + + /* + * Do the length checking only if user is not NULL. + */ + + if (ntlmssp_resp->hdr_lm_resp.str_str_len == 0) + return False; + if (ntlmssp_resp->hdr_nt_resp.str_str_len == 0) + return False; + if (ntlmssp_resp->hdr_usr.str_str_len == 0) + return False; + if (ntlmssp_resp->hdr_domain.str_str_len == 0) + return False; + if (ntlmssp_resp->hdr_wks.str_str_len == 0) + return False; - if (IS_BITS_SET_ALL(l->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_UNICODE)) - { - unibuf_to_ascii(l->user_name, l->ntlmssp_resp.user, - MIN(l->ntlmssp_resp.hdr_usr .str_str_len/2, - sizeof(l->user_name)-1)); - unibuf_to_ascii(l->domain , l->ntlmssp_resp.domain, - MIN(l->ntlmssp_resp.hdr_domain.str_str_len/2, - sizeof(l->domain )-1)); - unibuf_to_ascii(l->wks , l->ntlmssp_resp.wks, - MIN(l->ntlmssp_resp.hdr_wks .str_str_len/2, - sizeof(l->wks )-1)); - } - else - { - fstrcpy(l->user_name, l->ntlmssp_resp.user ); - fstrcpy(l->domain , l->ntlmssp_resp.domain); - fstrcpy(l->wks , l->ntlmssp_resp.wks ); } + /* + * Find the user in the unix password db. + */ - if (anonymous) - { - DEBUG(5,("anonymous user session\n")); - mdfour(l->user_sess_key, null_pwd, 16); - pwd = null_pwd; - l->ntlmssp_validated = True; + if(!(pass = Get_Pwnam(unix_user_name,True))) { + DEBUG(1,("Couldn't find user '%s' in UNIX password database.\n",unix_user_name)); + return(False); } - else - { - DEBUG(5,("user: %s domain: %s wks: %s\n", l->user_name, l->domain, l->wks)); - become_root(False); - l->ntlmssp_validated = check_domain_security(l->user_name, l->domain, - (uchar*)l->ntlmssp_chal.challenge, - lm_owf, lm_owf_len, - nt_owf, nt_owf_len, - l->user_sess_key); - unbecome_root(False); + + if(!guest_user) { + + become_root(True); + + if(!(p->ntlmssp_auth_validated = pass_check_smb(unix_user_name, domain, + (uchar*)p->challenge, lm_owf, nt_owf, NULL))) { + DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ +failed authentication on named pipe %s.\n", domain, unix_user_name, wks, p->name )); + unbecome_root(True); + return False; + } + + if(!(smb_pass = getsmbpwnam(unix_user_name))) { + DEBUG(1,("api_pipe_ntlmssp_verify: Cannot find user %s in smb passwd database.\n", + unix_user_name)); + unbecome_root(True); + return False; + } + + unbecome_root(True); + + if (smb_pass == NULL) { + DEBUG(1,("api_pipe_ntlmssp_verify: Couldn't find user '%s' in smb_passwd file.\n", + unix_user_name)); + return(False); + } + + /* Quit if the account was disabled. */ + if((smb_pass->acct_ctrl & ACB_DISABLED) || !smb_pass->smb_passwd) { + DEBUG(1,("Account for user '%s' was disabled.\n", unix_user_name)); + return(False); + } + + if(!smb_pass->smb_nt_passwd) { + DEBUG(1,("Account for user '%s' has no NT password hash.\n", unix_user_name)); + return(False); + } + + smb_passwd_ptr = smb_pass->smb_passwd; } - if (l->ntlmssp_validated && pwd != NULL) + /* + * Set up the sign/seal data. + */ + { uchar p24[24]; - NTLMSSPOWFencrypt(pwd, lm_owf, p24); + NTLMSSPOWFencrypt(smb_passwd_ptr, lm_owf, p24); { unsigned char j = 0; int ind; @@ -327,761 +408,670 @@ static BOOL api_pipe_ntlmssp_verify(rpcsrv_struct *l) k2[7] = 0xb0; for (ind = 0; ind < 256; ind++) - { - l->ntlmssp_hash[ind] = (unsigned char)ind; - } + p->ntlmssp_hash[ind] = (unsigned char)ind; - for( ind = 0; ind < 256; ind++) - { + for( ind = 0; ind < 256; ind++) { unsigned char tc; - j += (l->ntlmssp_hash[ind] + k2[ind%8]); + j += (p->ntlmssp_hash[ind] + k2[ind%8]); - tc = l->ntlmssp_hash[ind]; - l->ntlmssp_hash[ind] = l->ntlmssp_hash[j]; - l->ntlmssp_hash[j] = tc; + tc = p->ntlmssp_hash[ind]; + p->ntlmssp_hash[ind] = p->ntlmssp_hash[j]; + p->ntlmssp_hash[j] = tc; } - l->ntlmssp_hash[256] = 0; - l->ntlmssp_hash[257] = 0; + p->ntlmssp_hash[256] = 0; + p->ntlmssp_hash[257] = 0; } - l->ntlmssp_seq_num = 0; - } - else - { - l->ntlmssp_validated = False; +/* NTLMSSPhash(p->ntlmssp_hash, p24); */ + p->ntlmssp_seq_num = 0; + } - return l->ntlmssp_validated; -} + fstrcpy(p->user_name, user_name); + fstrcpy(p->unix_user_name, unix_user_name); + fstrcpy(p->domain, domain); + fstrcpy(p->wks, wks); -static BOOL api_pipe_ntlmssp(rpcsrv_struct *l, prs_struct *pd) -{ - /* receive a negotiate; send a challenge; receive a response */ - switch (l->auth_verifier.msg_type) - { - case NTLMSSP_NEGOTIATE: - { - smb_io_rpc_auth_ntlmssp_neg("", &l->ntlmssp_neg, pd, 0); - break; - } - case NTLMSSP_AUTH: - { - smb_io_rpc_auth_ntlmssp_resp("", &l->ntlmssp_resp, pd, 0); - if (!api_pipe_ntlmssp_verify(l)) - { - pd->offset = 0; - } - break; - } - default: - { - /* NTLMSSP expected: unexpected message type */ - DEBUG(3,("unexpected message type in NTLMSSP %d\n", - l->auth_verifier.msg_type)); - return False; - } - } + /* + * Store the UNIX credential data (uid/gid pair) in the pipe structure. + */ + + p->uid = pass->pw_uid; + p->gid = pass->pw_gid; - return (pd->offset != 0); + p->ntlmssp_auth_validated = True; + return True; } +/******************************************************************* + The switch table for the pipe names and the functions to handle them. + *******************************************************************/ + struct api_cmd { char * pipe_clnt_name; char * pipe_srv_name; - BOOL (*fn) (rpcsrv_struct *, prs_struct *); + BOOL (*fn) (pipes_struct *, prs_struct *); }; -static struct api_cmd **api_fd_commands = NULL; -uint32 num_cmds = 0; - -static void api_cmd_free(struct api_cmd *item) -{ - if (item != NULL) - { - if (item->pipe_clnt_name != NULL) - { - free(item->pipe_clnt_name); - } - if (item->pipe_srv_name != NULL) - { - free(item->pipe_srv_name); - } - free(item); - } -} - -static struct api_cmd *api_cmd_dup(const struct api_cmd *from) +static struct api_cmd api_fd_commands[] = { - struct api_cmd *copy = NULL; - if (from == NULL) - { - return NULL; - } - copy = (struct api_cmd *) malloc(sizeof(struct api_cmd)); - if (copy != NULL) - { - ZERO_STRUCTP(copy); - if (from->pipe_clnt_name != NULL) - { - copy->pipe_clnt_name = strdup(from->pipe_clnt_name ); - } - if (from->pipe_srv_name != NULL) - { - copy->pipe_srv_name = strdup(from->pipe_srv_name); - } - if (from->fn != NULL) - { - copy->fn = from->fn; - } - } - return copy; -} + { "lsarpc", "lsass", api_ntlsa_rpc }, + { "samr", "lsass", api_samr_rpc }, + { "srvsvc", "ntsvcs", api_srvsvc_rpc }, + { "wkssvc", "ntsvcs", api_wkssvc_rpc }, + { "NETLOGON", "lsass", api_netlog_rpc }, +#if DISABLED_IN_2_0 + { "winreg", "winreg", api_reg_rpc }, +#endif + { NULL, NULL, NULL } +}; -static void free_api_cmd_array(uint32 num_entries, struct api_cmd **entries) -{ - void(*fn)(void*) = (void(*)(void*))&api_cmd_free; - free_void_array(num_entries, (void**)entries, *fn); -} +/******************************************************************* + This is the client reply to our challenge for an authenticated + bind request. The challenge we sent is in p->challenge. +*******************************************************************/ -static struct api_cmd* add_api_cmd_to_array(uint32 *len, - struct api_cmd ***array, - const struct api_cmd *name) +static BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *pd) { - void*(*fn)(const void*) = (void*(*)(const void*))&api_cmd_dup; - return (struct api_cmd*)add_copy_to_array(len, - (void***)array, (const void*)name, *fn, False); - -} + RPC_HDR_AUTHA autha_info; + RPC_AUTH_VERIFIER auth_verifier; + RPC_AUTH_NTLMSSP_RESP ntlmssp_resp; + DEBUG(5,("api_pipe_bind_auth_resp: decode request. %d\n", __LINE__)); -void close_msrpc_command_processor(void) -{ - free_api_cmd_array(num_cmds, api_fd_commands); -} + if (p->hdr.auth_len == 0) { + DEBUG(0,("api_pipe_bind_auth_resp: No auth field sent !\n")); + return False; + } -void add_msrpc_command_processor(char* pipe_name, - char* process_name, - BOOL (*fn) (rpcsrv_struct *, prs_struct *)) -{ - struct api_cmd cmd; - cmd.pipe_clnt_name = pipe_name; - cmd.pipe_srv_name = process_name; - cmd.fn = fn; + /* + * Decode the authentication verifier response. + */ - add_api_cmd_to_array(&num_cmds, &api_fd_commands, &cmd); -} + if(!smb_io_rpc_hdr_autha("", &autha_info, pd, 0)) { + DEBUG(0,("api_pipe_bind_auth_resp: unmarshall of RPC_HDR_AUTHA failed.\n")); + return False; + } -static BOOL api_pipe_bind_auth_resp(rpcsrv_struct *l, prs_struct *pd) -{ - DEBUG(5,("api_pipe_bind_auth_resp: decode request. %d\n", __LINE__)); + if (autha_info.auth_type != NTLMSSP_AUTH_TYPE || autha_info.auth_level != NTLMSSP_AUTH_LEVEL) { + DEBUG(0,("api_pipe_bind_auth_resp: incorrect auth type (%d) or level (%d).\n", + (int)autha_info.auth_type, (int)autha_info.auth_level )); + return False; + } - if (l->hdr.auth_len == 0) return False; + if(!smb_io_rpc_auth_verifier("", &auth_verifier, pd, 0)) { + DEBUG(0,("api_pipe_bind_auth_resp: unmarshall of RPC_AUTH_VERIFIER failed.\n")); + return False; + } - /* decode the authentication verifier response */ - smb_io_rpc_hdr_autha("", &l->autha_info, pd, 0); - if (pd->offset == 0) return False; + /* + * Ensure this is a NTLMSSP_AUTH packet type. + */ - if (!rpc_hdr_auth_chk(&(l->auth_info))) return False; + if (!rpc_auth_verifier_chk(&auth_verifier, "NTLMSSP", NTLMSSP_AUTH)) { + DEBUG(0,("api_pipe_bind_auth_resp: rpc_auth_verifier_chk failed.\n")); + return False; + } - smb_io_rpc_auth_ntlmssp_verifier("", &l->auth_verifier, pd, 0); - if (pd->offset == 0) return False; + if(!smb_io_rpc_auth_ntlmssp_resp("", &ntlmssp_resp, pd, 0)) { + DEBUG(0,("api_pipe_bind_auth_resp: Failed to unmarshall RPC_AUTH_NTLMSSP_RESP.\n")); + return False; + } - if (!rpc_auth_ntlmssp_verifier_chk(&(l->auth_verifier), "NTLMSSP", NTLMSSP_AUTH)) return False; + /* + * The following call actually checks the challenge/response data. + * for correctness against the given DOMAIN\user name. + */ - return api_pipe_ntlmssp(l, pd); + if (!api_pipe_ntlmssp_verify(p, &ntlmssp_resp)) + return False; + + return True; } -static BOOL api_pipe_fault_resp(rpcsrv_struct *l, prs_struct *pd, uint32 status) +/******************************************************************* + Marshall a bind_nak pdu. +*******************************************************************/ + +static BOOL setup_bind_nak(pipes_struct *p, prs_struct *pd) { - DEBUG(5,("api_pipe_fault_resp: make response\n")); + prs_struct outgoing_rpc; + RPC_HDR nak_hdr; + uint16 zero = 0; + + /* + * Marshall directly into the outgoing PDU space. We + * must do this as we need to set to the bind response + * header and are never sending more than one PDU here. + */ - prs_init(&(l->rhdr ), 0x18, 4, 0, False); - prs_init(&(l->rfault ), 0x8 , 4, 0, False); + prs_init( &outgoing_rpc, 0, 4, MARSHALL); + prs_give_memory( &outgoing_rpc, (char *)p->current_pdu, sizeof(p->current_pdu), False); - /***/ - /*** set up the header, response header and fault status ***/ - /***/ - l->hdr_fault.status = status; - l->hdr_fault.reserved = 0x0; + /* + * Initialize a bind_nak header. + */ - l->hdr_resp.alloc_hint = 0x0; - l->hdr_resp.cancel_count = 0x0; - l->hdr_resp.reserved = 0x0; + init_rpc_hdr(&nak_hdr, RPC_BINDNACK, RPC_FLG_FIRST | RPC_FLG_LAST, + p->hdr.call_id, RPC_HEADER_LEN + sizeof(uint16), 0); - make_rpc_hdr(&l->hdr, RPC_FAULT, RPC_FLG_NOCALL | RPC_FLG_FIRST | RPC_FLG_LAST, - l->hdr.call_id, - 0x20, - 0); + /* + * Marshall the header into the outgoing PDU. + */ - smb_io_rpc_hdr ("hdr" , &(l->hdr ), &(l->rhdr), 0); - smb_io_rpc_hdr_resp ("resp" , &(l->hdr_resp ), &(l->rhdr), 0); - smb_io_rpc_hdr_fault("fault", &(l->hdr_fault), &(l->rfault), 0); - mem_realloc_data(l->rhdr.data, l->rhdr.offset); - mem_realloc_data(l->rfault.data, l->rfault.offset); + if(!smb_io_rpc_hdr("", &nak_hdr, &outgoing_rpc, 0)) { + DEBUG(0,("setup_bind_nak: marshalling of RPC_HDR failed.\n")); + return False; + } - /***/ - /*** link rpc header and fault together ***/ - /***/ + /* + * Now add the reject reason. + */ - prs_link(NULL , &l->rhdr , &l->rfault); - prs_link(&l->rhdr, &l->rfault, NULL ); + if(!prs_uint16("reject code", &outgoing_rpc, 0, &zero)) + return False; + + p->data_sent_length = 0; + p->current_pdu_len = prs_offset(&outgoing_rpc); + p->current_pdu_sent = 0; return True; } -static BOOL srv_pipe_bind_and_alt_req(rpcsrv_struct *l, prs_struct *pd, - const char* ack_pipe_name, - enum RPC_PKT_TYPE pkt_type) +/******************************************************************* + Respond to a pipe bind request. +*******************************************************************/ + +static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) { + RPC_HDR_BA hdr_ba; + RPC_HDR_RB hdr_rb; + RPC_HDR_AUTH auth_info; uint16 assoc_gid; + fstring ack_pipe_name; + prs_struct out_hdr_ba; + prs_struct out_auth; + prs_struct outgoing_rpc; + int i = 0; + int auth_len = 0; + + p->ntlmssp_auth_requested = False; + + DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); + + /* + * Try and find the correct pipe name to ensure + * that this is a pipe name we support. + */ - l->ntlmssp_auth = False; + for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { + if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && + api_fd_commands[i].fn != NULL) { + DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", + api_fd_commands[i].pipe_clnt_name, + api_fd_commands[i].pipe_srv_name)); + fstrcpy(p->pipe_srv_name, api_fd_commands[i].pipe_srv_name); + break; + } + } + + if (api_fd_commands[i].fn == NULL) { + DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", + p->name )); + if(!setup_bind_nak(p, pd)) + return False; + return True; + } /* decode the bind request */ - smb_io_rpc_hdr_rb("", &l->hdr_rb, pd, 0); + if(!smb_io_rpc_hdr_rb("", &hdr_rb, pd, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_RB struct.\n")); + return False; + } - if (pd->offset == 0) return False; + /* + * Check if this is an authenticated request. + */ - if (l->hdr.auth_len != 0) - { - /* decode the authentication verifier */ - smb_io_rpc_hdr_auth ("", &l->auth_info , pd, 0); - if (pd->offset == 0) return False; + if (p->hdr.auth_len != 0) { + RPC_AUTH_VERIFIER auth_verifier; + RPC_AUTH_NTLMSSP_NEG ntlmssp_neg; - l->ntlmssp_auth = l->auth_info.auth_type = 0x0a; + /* + * Decode the authentication verifier. + */ - if (l->ntlmssp_auth) - { - smb_io_rpc_auth_ntlmssp_verifier("", &l->auth_verifier, pd, 0); - if (pd->offset == 0) return False; + if(!smb_io_rpc_hdr_auth("", &auth_info, pd, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); + return False; + } - l->ntlmssp_auth = strequal(l->auth_verifier.signature, "NTLMSSP"); + /* + * We only support NTLMSSP_AUTH_TYPE requests. + */ + + if(auth_info.auth_type != NTLMSSP_AUTH_TYPE) { + DEBUG(0,("api_pipe_bind_req: unknown auth type %x requested.\n", + auth_info.auth_type )); + return False; } - if (l->ntlmssp_auth) - { - if (!api_pipe_ntlmssp(l, pd)) return False; + if(!smb_io_rpc_auth_verifier("", &auth_verifier, pd, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); + return False; + } + + if(!strequal(auth_verifier.signature, "NTLMSSP")) { + DEBUG(0,("api_pipe_bind_req: auth_verifier.signature != NTLMSSP\n")); + return False; + } + + if(auth_verifier.msg_type != NTLMSSP_NEGOTIATE) { + DEBUG(0,("api_pipe_bind_req: auth_verifier.msg_type (%d) != NTLMSSP_NEGOTIATE\n", + auth_verifier.msg_type)); + return False; } + + if(!smb_io_rpc_auth_ntlmssp_neg("", &ntlmssp_neg, pd, 0)) { + DEBUG(0,("api_pipe_bind_req: Failed to unmarshall RPC_AUTH_NTLMSSP_NEG.\n")); + return False; + } + + p->ntlmssp_chal_flags = SMBD_NTLMSSP_NEG_FLAGS; + p->ntlmssp_auth_requested = True; } + /* name has to be \PIPE\xxxxx */ + fstrcpy(ack_pipe_name, "\\PIPE\\"); + fstrcat(ack_pipe_name, p->pipe_srv_name); + DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); - prs_init(&(l->rdata), 1024, 4, 0, False); - prs_init(&(l->rhdr ), 0x18, 4, 0, False); - prs_init(&(l->rauth), 1024, 4, 0, False); - prs_init(&(l->rverf), 0x08, 4, 0, False); - prs_init(&(l->rntlm), 1024, 4, 0, False); + /* + * Marshall directly into the outgoing PDU space. We + * must do this as we need to set to the bind response + * header and are never sending more than one PDU here. + */ - /***/ - /*** do the bind ack first ***/ - /***/ + prs_init( &outgoing_rpc, 0, 4, MARSHALL); + prs_give_memory( &outgoing_rpc, (char *)p->current_pdu, sizeof(p->current_pdu), False); - if (l->ntlmssp_auth) - { - assoc_gid = 0x7a77; + /* + * Setup the memory to marshall the ba header, and the + * auth footers. + */ + + if(!prs_init(&out_hdr_ba, 1024, 4, MARSHALL)) { + DEBUG(0,("api_pipe_bind_req: malloc out_hdr_ba failed.\n")); + return False; } - else - { - assoc_gid = l->hdr_rb.bba.assoc_gid; + + if(!prs_init(&out_auth, 1024, 4, MARSHALL)) { + DEBUG(0,("pi_pipe_bind_req: malloc out_auth failed.\n")); + prs_mem_free(&out_hdr_ba); + return False; } - make_rpc_hdr_ba(&l->hdr_ba, - l->hdr_rb.bba.max_tsize, - l->hdr_rb.bba.max_rsize, + if (p->ntlmssp_auth_requested) + assoc_gid = 0x7a77; + else + assoc_gid = hdr_rb.bba.assoc_gid; + + /* + * Create the bind response struct. + */ + + init_rpc_hdr_ba(&hdr_ba, + hdr_rb.bba.max_tsize, + hdr_rb.bba.max_rsize, assoc_gid, ack_pipe_name, 0x1, 0x0, 0x0, - &(l->hdr_rb.transfer)); + &hdr_rb.transfer); + + /* + * and marshall it. + */ - smb_io_rpc_hdr_ba("", &l->hdr_ba, &l->rdata, 0); - mem_realloc_data(l->rdata.data, l->rdata.offset); + if(!smb_io_rpc_hdr_ba("", &hdr_ba, &out_hdr_ba, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_BA failed.\n")); + goto err_exit; + } - /***/ - /*** now the authentication ***/ - /***/ + /* + * Now the authentication. + */ - if (l->ntlmssp_auth) - { - uint8 challenge[8]; - generate_random_buffer(challenge, 8, False); + if (p->ntlmssp_auth_requested) { + RPC_AUTH_VERIFIER auth_verifier; + RPC_AUTH_NTLMSSP_CHAL ntlmssp_chal; - /*** authentication info ***/ + generate_random_buffer(p->challenge, 8, False); - make_rpc_hdr_auth(&l->auth_info, 0x0a, 0x06, 0, 1); - smb_io_rpc_hdr_auth("", &l->auth_info, &l->rverf, 0); - mem_realloc_data(l->rverf.data, l->rverf.offset); + /*** Authentication info ***/ + + init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, NTLMSSP_AUTH_LEVEL, RPC_HDR_AUTH_LEN, 1); + if(!smb_io_rpc_hdr_auth("", &auth_info, &out_auth, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_AUTH failed.\n")); + goto err_exit; + } /*** NTLMSSP verifier ***/ - make_rpc_auth_ntlmssp_verifier(&l->auth_verifier, - "NTLMSSP", NTLMSSP_CHALLENGE); - smb_io_rpc_auth_ntlmssp_verifier("", &l->auth_verifier, &l->rauth, 0); - mem_realloc_data(l->rauth.data, l->rauth.offset); + init_rpc_auth_verifier(&auth_verifier, "NTLMSSP", NTLMSSP_CHALLENGE); + if(!smb_io_rpc_auth_verifier("", &auth_verifier, &out_auth, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_VERIFIER failed.\n")); + goto err_exit; + } /* NTLMSSP challenge ***/ - make_rpc_auth_ntlmssp_chal(&l->ntlmssp_chal, - 0x000082b1, challenge); - smb_io_rpc_auth_ntlmssp_chal("", &l->ntlmssp_chal, &l->rntlm, 0); - mem_realloc_data(l->rntlm.data, l->rntlm.offset); - } + init_rpc_auth_ntlmssp_chal(&ntlmssp_chal, p->ntlmssp_chal_flags, p->challenge); + if(!smb_io_rpc_auth_ntlmssp_chal("", &ntlmssp_chal, &out_auth, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_NTLMSSP_CHAL failed.\n")); + goto err_exit; + } - /***/ - /*** then do the header, now we know the length ***/ - /***/ + /* Auth len in the rpc header doesn't include auth_header. */ + auth_len = prs_offset(&out_auth) - RPC_HDR_AUTH_LEN; + } - make_rpc_hdr(&l->hdr, pkt_type, RPC_FLG_FIRST | RPC_FLG_LAST, - l->hdr.call_id, - l->rdata.offset + l->rverf.offset + l->rauth.offset + l->rntlm.offset + 0x10, - l->rauth.offset + l->rntlm.offset); + /* + * Create the header, now we know the length. + */ - smb_io_rpc_hdr("", &l->hdr, &l->rhdr, 0); - mem_realloc_data(l->rhdr.data, l->rdata.offset); + init_rpc_hdr(&p->hdr, RPC_BINDACK, RPC_FLG_FIRST | RPC_FLG_LAST, + p->hdr.call_id, + RPC_HEADER_LEN + prs_offset(&out_hdr_ba) + prs_offset(&out_auth), + auth_len); - /***/ - /*** link rpc header, bind acknowledgment and authentication responses ***/ - /***/ + /* + * Marshall the header into the outgoing PDU. + */ - if (l->ntlmssp_auth) - { - prs_link(NULL , &l->rhdr , &l->rdata); - prs_link(&l->rhdr , &l->rdata, &l->rverf); - prs_link(&l->rdata, &l->rverf, &l->rauth); - prs_link(&l->rverf, &l->rauth, &l->rntlm); - prs_link(&l->rauth, &l->rntlm, NULL ); + if(!smb_io_rpc_hdr("", &p->hdr, &outgoing_rpc, 0)) { + DEBUG(0,("pi_pipe_bind_req: marshalling of RPC_HDR failed.\n")); + goto err_exit; } - else - { - prs_link(NULL , &l->rhdr , &l->rdata); - prs_link(&l->rhdr, &l->rdata, NULL ); + + /* + * Now add the RPC_HDR_BA and any auth needed. + */ + + if(!prs_append_prs_data( &outgoing_rpc, &out_hdr_ba)) { + DEBUG(0,("api_pipe_bind_req: append of RPC_HDR_BA failed.\n")); + goto err_exit; } - return True; -} + if(p->ntlmssp_auth_requested && !prs_append_prs_data( &outgoing_rpc, &out_auth)) { + DEBUG(0,("api_pipe_bind_req: append of auth info failed.\n")); + goto err_exit; + } -static BOOL api_pipe_bind_and_alt_req(rpcsrv_struct *l, prs_struct *pd, - const char* name, - enum RPC_PKT_TYPE pkt_type) -{ - fstring ack_pipe_name; - fstring pipe_srv_name; - int i = 0; + /* + * Setup the lengths for the initial reply. + */ - DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); + p->data_sent_length = 0; + p->current_pdu_len = prs_offset(&outgoing_rpc); + p->current_pdu_sent = 0; - for (i = 0; i < num_cmds; i++) - { - if (strequal(api_fd_commands[i]->pipe_clnt_name, name) && - api_fd_commands[i]->fn != NULL) - { - DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", - api_fd_commands[i]->pipe_clnt_name, - api_fd_commands[i]->pipe_srv_name)); - fstrcpy(pipe_srv_name, api_fd_commands[i]->pipe_srv_name); - break; - } - } + prs_mem_free(&out_hdr_ba); + prs_mem_free(&out_auth); - if (api_fd_commands[i]->fn == NULL) return False; + return True; - switch (pkt_type) - { - case RPC_BINDACK: - { - /* name has to be \PIPE\xxxxx */ - fstrcpy(ack_pipe_name, "\\PIPE\\"); - fstrcat(ack_pipe_name, pipe_srv_name); - break; - } - case RPC_ALTCONTRESP: - { - /* secondary address CAN be NULL - * as the specs says it's ignored. - * It MUST NULL to have the spoolss working. - */ - fstrcpy(ack_pipe_name, ""); - break; - } - default: - { - return False; - } - } - return srv_pipe_bind_and_alt_req(l, pd, ack_pipe_name, pkt_type); -} + err_exit: -/* - * The RPC Alter-Context call is used only by the spoolss pipe - * simply because there is a bug (?) in the MS unmarshalling code - * or in the marshalling code. If it's in the later, then Samba - * have the same bug. - */ -static BOOL api_pipe_bind_req(rpcsrv_struct *l, prs_struct *pd, - const char* name) -{ - return api_pipe_bind_and_alt_req(l, pd, name, RPC_BINDACK); + prs_mem_free(&out_hdr_ba); + prs_mem_free(&out_auth); + return False; } -static BOOL api_pipe_alt_req(rpcsrv_struct *l, prs_struct *pd, - const char* name) -{ - return api_pipe_bind_and_alt_req(l, pd, name, RPC_ALTCONTRESP); -} +/**************************************************************************** + Deal with sign & seal processing on an RPC request. +****************************************************************************/ -static BOOL api_pipe_auth_process(rpcsrv_struct *l, prs_struct *pd) +static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) { - BOOL auth_verify = IS_BITS_SET_ALL(l->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SIGN); - BOOL auth_seal = IS_BITS_SET_ALL(l->ntlmssp_chal.neg_flags, NTLMSSP_NEGOTIATE_SEAL); + /* + * We always negotiate the following two bits.... + */ + BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SIGN); + BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SEAL); int data_len; int auth_len; uint32 old_offset; uint32 crc32 = 0; - auth_len = l->hdr.auth_len; + auth_len = p->hdr.auth_len; - if (auth_len != 16 && auth_verify) - { + if ((auth_len != RPC_AUTH_NTLMSSP_CHK_LEN) && auth_verify) { + DEBUG(0,("api_pipe_auth_process: Incorrect auth_len %d.\n", auth_len )); return False; } - data_len = l->hdr.frag_len - auth_len - (auth_verify ? 8 : 0) - 0x18; + /* + * The following is that length of the data we must verify or unseal. + * This doesn't include the RPC headers or the auth_len or the RPC_HDR_AUTH_LEN + * preceeding the auth_data. + */ + + data_len = p->hdr.frag_len - RPC_HEADER_LEN - RPC_HDR_REQ_LEN - + (auth_verify ? RPC_HDR_AUTH_LEN : 0) - auth_len; DEBUG(5,("api_pipe_auth_process: sign: %s seal: %s data %d auth %d\n", BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); - if (auth_seal) - { - char *data = mem_data(&pd->data, pd->offset); - DEBUG(5,("api_pipe_auth_process: data %d\n", pd->offset)); - NTLMSSPcalc_p(l, (uchar*)data, data_len); - crc32 = crc32_calc_buffer(data_len, data); + if (auth_seal) { + char *data = prs_data_p(rpc_in) + RPC_HEADER_LEN + RPC_HDR_REQ_LEN; + NTLMSSPcalc_p(p, (uchar*)data, data_len); + crc32 = crc32_calc_buffer(data, data_len); } - /*** skip the data, record the offset so we can restore it again */ - old_offset = pd->offset; + old_offset = prs_offset(rpc_in); - if (auth_seal || auth_verify) - { - pd->offset += data_len; - smb_io_rpc_hdr_auth("hdr_auth", &l->auth_info, pd, 0); - } + if (auth_seal || auth_verify) { + RPC_HDR_AUTH auth_info; - if (auth_verify) - { - char *req_data = mem_data(&pd->data, pd->offset + 4); - DEBUG(5,("api_pipe_auth_process: auth %d\n", pd->offset + 4)); - NTLMSSPcalc_p(l, (uchar*)req_data, 12); - smb_io_rpc_auth_ntlmssp_chk("auth_sign", &(l->ntlmssp_chk), pd, 0); + if(!prs_set_offset(rpc_in, old_offset + data_len)) { + DEBUG(0,("api_pipe_auth_process: cannot move offset to %u.\n", + (unsigned int)old_offset + data_len )); + return False; + } - if (!rpc_auth_ntlmssp_chk(&(l->ntlmssp_chk), crc32, - l->ntlmssp_seq_num)) - { + if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, rpc_in, 0)) { + DEBUG(0,("api_pipe_auth_process: failed to unmarshall RPC_HDR_AUTH.\n")); return False; } } - pd->offset = old_offset; - - return True; -} - -static BOOL api_pipe_request(rpcsrv_struct *l, prs_struct *pd, const char* name) -{ - int i = 0; - - if (l->ntlmssp_auth && l->ntlmssp_validated) - { - if (!api_pipe_auth_process(l, pd)) return False; + if (auth_verify) { + RPC_AUTH_NTLMSSP_CHK ntlmssp_chk; + char *req_data = prs_data_p(rpc_in) + prs_offset(rpc_in) + 4; - DEBUG(0,("api_pipe_request: **** MUST CALL become_user() HERE **** \n")); -#if 0 - become_user(); -#endif - } + DEBUG(5,("api_pipe_auth_process: auth %d\n", prs_offset(rpc_in) + 4)); - for (i = 0; i < num_cmds; i++) - { - if (strequal(api_fd_commands[i]->pipe_clnt_name, name) && - api_fd_commands[i]->fn != NULL) - { - DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i]->pipe_clnt_name)); - return api_fd_commands[i]->fn(l, pd); + /* + * Ensure we have RPC_AUTH_NTLMSSP_CHK_LEN - 4 more bytes in the + * incoming buffer. + */ + if(prs_mem_get(rpc_in, RPC_AUTH_NTLMSSP_CHK_LEN - 4) == NULL) { + DEBUG(0,("api_pipe_auth_process: missing %d bytes in buffer.\n", + RPC_AUTH_NTLMSSP_CHK_LEN - 4 )); + return False; } - } - return False; -} - -BOOL rpc_add_to_pdu(prs_struct *ps, const char *data, int len) -{ - int prev_size; - int new_size; - char *to = NULL; - - ps->offset = 0; - if (ps->data == NULL) - { - DEBUG(10,("rpc_add_to_pdu: new_size: %d\n", len)); - prs_init(ps, len, 4, 0, True); - prev_size = 0; - new_size = len; - if (ps->data == NULL) - { + NTLMSSPcalc_p(p, (uchar*)req_data, RPC_AUTH_NTLMSSP_CHK_LEN - 4); + if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &ntlmssp_chk, rpc_in, 0)) { + DEBUG(0,("api_pipe_auth_process: failed to unmarshall RPC_AUTH_NTLMSSP_CHK.\n")); return False; } - } - else - { - prev_size = ps->data->data_used; - new_size = prev_size + len; - DEBUG(10,("rpc_add_to_pdu: prev_size: %d new_size: %d\n", - prev_size, new_size)); - if (!mem_realloc_data(ps->data, new_size)) - { + + if (!rpc_auth_ntlmssp_chk(&ntlmssp_chk, crc32, p->ntlmssp_seq_num)) { + DEBUG(0,("api_pipe_auth_process: NTLMSSP check failed.\n")); return False; } } - DEBUG(10,("ps->data->start: %d\n", ps->data->offset.start)); - ps->data->offset.start = 0x0; + /* + * Return the current pointer to the data offset. + */ - to = mem_data(&ps->data, prev_size); - if (to == NULL) - { - DEBUG(10,("rpc_add_to_pdu: data could not be found\n")); - return False; - } - if (ps->data->data_used != new_size) - { - DEBUG(10,("rpc_add_to_pdu: ERROR: data used %d new_size %d\n", - ps->data->data_used, new_size)); + if(!prs_set_offset(rpc_in, old_offset)) { + DEBUG(0,("api_pipe_auth_process: failed to set offset back to %u\n", + (unsigned int)old_offset )); return False; } - memcpy(to, data, len); + return True; } -static BOOL rpc_redir_remote(pipes_struct *p, prs_struct *req, prs_struct *resp) +/**************************************************************************** + Find the correct RPC function to call for this request. + If the pipe is authenticated then become the correct UNIX user + before doing the call. +****************************************************************************/ + +static BOOL api_pipe_request(pipes_struct *p, prs_struct *rpc_in) { - DEBUG(10,("rpc_redirect\n")); + int i = 0; + BOOL ret = False; + BOOL changed_user_id = False; - if (!msrpc_send_prs(p->m, req)) - { - DEBUG(2,("msrpc redirect send failed\n")); - return False; + if (p->ntlmssp_auth_validated) { + if (!api_pipe_auth_process(p, rpc_in)) + return False; + + if(!become_authenticated_pipe_user(p)) + return False; + + changed_user_id = True; } - if (!msrpc_receive_prs(p->m, resp)) - { - DEBUG(2,("msrpc redirect receive failed\n")); - return False; + + for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { + if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && + api_fd_commands[i].fn != NULL) { + DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i].pipe_clnt_name)); + ret = api_fd_commands[i].fn(p, rpc_in); + } } - prs_link(NULL, resp, NULL); - prs_debug_out(resp, "redirect", 100); - return True; + + if(changed_user_id) + unbecome_authenticated_pipe_user(p); + + return ret; } -static BOOL rpc_redir_local(rpcsrv_struct *l, prs_struct *req, prs_struct *resp, - const char* name) +/**************************************************************************** + This function is the entry point to processing a DCE/RPC request. + All the data for the request (including RPC headers and authentication + verifiers) must be linearized in the input_data buffer, with a length + of data_len. + + The output is placed into the pipes_struct, and handed back to the + client on demand. +****************************************************************************/ + +BOOL rpc_command(pipes_struct *p, char *input_data, int data_len) { + prs_struct rpc_in; BOOL reply = False; - if (req->data == NULL) return False; + if (input_data == NULL) + return False; + + prs_init(&rpc_in, 0, 4, UNMARSHALL); - /* lkclXXXX still assume that the first complete PDU is always - in a single request!!! + /* + * Hand the data to the prs_struct, but don't let + * it own it. */ - /* process the rpc header */ - req->offset = 0x0; - smb_io_rpc_hdr("", &l->hdr, req, 0); + prs_give_memory( &rpc_in, input_data, (uint32)data_len, False); - if (req->offset == 0) return False; + /* Unmarshall the rpc header */ + if(!smb_io_rpc_hdr("", &p->hdr, &rpc_in, 0)) { + DEBUG(0,("rpc_command: failed to unmarshall RPC_HDR.\n")); + return False; + } - switch (l->hdr.pkt_type) - { - case RPC_BIND : - { - reply = api_pipe_bind_req(l, req, name); - break; - } - case RPC_ALTCONT: - { - reply = api_pipe_alt_req(l, req, name); - break; - } - case RPC_REQUEST: - { - if (l->ntlmssp_auth && !l->ntlmssp_validated) - { - /* authentication _was_ requested - and it failed. sorry, no deal! - */ - reply = False; - } - else - { - /* read the rpc header */ - smb_io_rpc_hdr_req("req", &(l->hdr_req), req, 0); - reply = api_pipe_request(l, req, name); + /* + * Create the response data buffer. + */ + + if(!pipe_init_outgoing_data(p)) { + DEBUG(0,("rpc_command: failed to unmarshall RPC_HDR.\n")); + return False; + } + + switch (p->hdr.pkt_type) { + case RPC_BIND: + reply = api_pipe_bind_req(p, &rpc_in); + break; + case RPC_REQUEST: + if (p->ntlmssp_auth_requested && !p->ntlmssp_auth_validated) { + /* authentication _was_ requested + and it failed. sorry, no deal! + */ + DEBUG(0,("rpc_command: RPC request received on pipe %s where \ +authentication failed. Denying the request.\n", p->name)); + reply = False; + } else { + /* read the RPC request header */ + if(!smb_io_rpc_hdr_req("req", &p->hdr_req, &rpc_in, 0)) { + DEBUG(0,("rpc_command: failed to unmarshall RPC_HDR_REQ.\n")); + return False; } - break; - } - case RPC_BINDRESP: /* not the real name! */ - { - reply = api_pipe_bind_auth_resp(l, req); - l->ntlmssp_auth = reply; - break; + reply = api_pipe_request(p, &rpc_in); } + break; + case RPC_BINDRESP: /* not the real name! */ + reply = api_pipe_bind_auth_resp(p, &rpc_in); + break; } if (!reply) - { - reply = api_pipe_fault_resp(l, req, 0x1c010002); - } - - if (reply) - { - /* flatten the data into a single pdu */ - reply = prs_copy(resp, &l->rhdr); - } - - /* delete intermediate data used to set up the pdu. leave - rdata alone because that's got the rest of the data in it */ - rpcsrv_free_temp(l); + DEBUG(3,("rpc_command: DCE/RPC fault should be sent here\n")); return reply; } -BOOL rpc_send_and_rcv_pdu(pipes_struct *p) -{ - DEBUG(10,("rpc_send_and_rcv_pdu\n")); - - if (p->m != NULL) - { - return rpc_redir_remote(p, &p->smb_pdu, &p->rsmb_pdu); - } - else if (p->l != NULL) - { - return rpc_redir_local(p->l, &p->smb_pdu, &p->rsmb_pdu, - p->name); - } - return False; -} /******************************************************************* - entry point from msrpc to smb. adds data received to pdu; checks - pdu; hands pdu off to msrpc, which gets a pdu back (except in the - case of the RPC_BINDCONT pdu). + Calls the underlying RPC function for a named pipe. ********************************************************************/ -BOOL rpc_to_smb(pipes_struct *p, char *data, int len) -{ - BOOL reply = rpc_add_to_pdu(&p->smb_pdu, data, len); - if (reply && is_complete_pdu(&p->smb_pdu)) - { - p->smb_pdu.offset = p->smb_pdu.data->data_size; - prs_link(NULL, &p->smb_pdu, NULL); - reply = rpc_send_and_rcv_pdu(p); - mem_free_data(p->smb_pdu.data); - prs_init(&p->smb_pdu, 0, 4, 0, True); - - } - return reply; -} - -/******************************************************************* - receives a netlogon pipe and responds. - ********************************************************************/ -static BOOL api_rpc_command(rpcsrv_struct *l, - char *rpc_name, struct api_struct *api_rpc_cmds, - prs_struct *data) +BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds, + prs_struct *rpc_in) { int fn_num; - DEBUG(4,("api_rpc_command: %s op 0x%x - ", rpc_name, l->hdr_req.opnum)); - for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) - { - if (api_rpc_cmds[fn_num].opnum == l->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) - { + /* interpret the command */ + DEBUG(4,("api_rpcTNP: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); + + for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) { + if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) { DEBUG(3,("api_rpc_command: %s\n", api_rpc_cmds[fn_num].name)); break; } } - if (api_rpc_cmds[fn_num].name == NULL) - { + if (api_rpc_cmds[fn_num].name == NULL) { DEBUG(4, ("unknown\n")); return False; } - /* start off with 1024 bytes, and a large safety margin too */ - prs_init(&l->rdata, 1024, 4, SAFETY_MARGIN, False); - /* do the actual command */ - api_rpc_cmds[fn_num].fn(l, data, &(l->rdata)); - - if (l->rdata.data == NULL || l->rdata.offset == 0) - { - mem_free_data(l->rdata.data); + if(!api_rpc_cmds[fn_num].fn(p->vuid, rpc_in, &p->rdata)) { + DEBUG(0,("api_rpcTNP: %s: failed.\n", rpc_name)); + prs_mem_free(&p->rdata); return False; } - mem_realloc_data(l->rdata.data, l->rdata.offset); - - DEBUG(10,("called %s\n", rpc_name)); + DEBUG(5,("api_rpcTNP: called %s successfully\n", rpc_name)); return True; } - - -/******************************************************************* - receives a netlogon pipe and responds. - ********************************************************************/ -BOOL api_rpcTNP(rpcsrv_struct *l, char *rpc_name, struct api_struct *api_rpc_cmds, - prs_struct *data) -{ - if (data == NULL || data->data == NULL) - { - DEBUG(2,("%s: NULL data received\n", rpc_name)); - return False; - } - - /* interpret the command */ - if (!api_rpc_command(l, rpc_name, api_rpc_cmds, data)) - { - return False; - } - - /* create the rpc header */ - if (!create_rpc_reply(l, 0)) - { - return False; - } - - return True; -} - -BOOL is_complete_pdu(prs_struct *ps) -{ - RPC_HDR hdr; - int len = ps->data->data_size; - - DEBUG(10,("is_complete_pdu - len %d\n", len)); - ps->offset = 0x0; - - if (!ps->io) - { - /* writing. oops!! */ - DEBUG(4,("is_complete_pdu: write set, not read!\n")); - return False; - } - - if (!smb_io_rpc_hdr("hdr", &hdr, ps, 0)) - { - return False; - } - /* check that the fragment length is equal to the data length so far */ - return hdr.frag_len == len; -} diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index f8bde1bf9b..b21b768a6e 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -5,6 +5,7 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1998, * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, + * Copyright (C) Jeremy Allison 1999. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,7 +56,7 @@ void set_pipe_handle_offset(int max_open_files) } /**************************************************************************** - reset pipe chain handle number + Reset pipe chain handle number. ****************************************************************************/ void reset_chain_p(void) { @@ -63,63 +64,64 @@ void reset_chain_p(void) } /**************************************************************************** - initialise pipe handle states... + Initialise pipe handle states. ****************************************************************************/ + void init_rpc_pipe_hnd(void) { bmap = bitmap_allocate(MAX_OPEN_PIPES); - if (!bmap) { + if (!bmap) exit_server("out of memory in init_rpc_pipe_hnd\n"); - } } +/**************************************************************************** + Initialise an outgoing packet. +****************************************************************************/ + +BOOL pipe_init_outgoing_data( pipes_struct *p) +{ + + memset(p->current_pdu, '\0', sizeof(p->current_pdu)); + + /* Free any memory in the current return data buffer. */ + prs_mem_free(&p->rdata); + + /* + * Initialize the outgoing RPC data buffer. + * we will use this as the raw data area for replying to rpc requests. + */ + if(!prs_init(&p->rdata, 1024, 4, MARSHALL)) { + DEBUG(0,("pipe_init_outgoing_data: malloc fail.\n")); + return False; + } + + /* Reset the offset counters. */ + p->data_sent_length = 0; + p->current_pdu_len = 0; + p->current_pdu_sent = 0; + + return True; +} /**************************************************************************** - find first available file slot + Find first available pipe slot. ****************************************************************************/ + pipes_struct *open_rpc_pipe_p(char *pipe_name, connection_struct *conn, uint16 vuid) { int i; pipes_struct *p; static int next_pipe; - struct msrpc_state *m = NULL; - struct rpcsrv_struct *l = NULL; - user_struct *vuser = get_valid_user_struct(vuid); - struct user_creds usr; - - ZERO_STRUCT(usr); DEBUG(4,("Open pipe requested %s (pipes_open=%d)\n", pipe_name, pipes_open)); - if (vuser == NULL) - { - DEBUG(4,("invalid vuid %d\n", vuid)); - return NULL; - } - - /* set up unix credentials from the smb side, to feed over the pipe */ - make_creds_unix(&usr.uxc, vuser->name, vuser->requested_name, - vuser->real_name, vuser->guest); - usr.ptr_uxc = 1; - make_creds_unix_sec(&usr.uxs, vuser->uid, vuser->gid, - vuser->n_groups, vuser->groups); - usr.ptr_uxs = 1; - - /* set up nt credentials from the smb side, to feed over the pipe */ - /* lkclXXXX todo! - make_creds_nt(&usr.ntc); - make_creds_nt_sec(&usr.nts); - */ - /* not repeating pipe numbers makes it easier to track things in log files and prevents client bugs where pipe numbers are reused over connection restarts */ if (next_pipe == 0) - { next_pipe = (getpid() ^ time(NULL)) % MAX_OPEN_PIPES; - } i = bitmap_find(bmap, next_pipe); @@ -131,44 +133,19 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, next_pipe = (i+1) % MAX_OPEN_PIPES; for (p = Pipes; p; p = p->next) - { DEBUG(5,("open pipes: name %s pnum=%x\n", p->name, p->pnum)); - } - - m = msrpc_use_add(pipe_name, &usr, False); - if (m == NULL) - { - DEBUG(5,("open pipes: msrpc redirect failed\n")); - return NULL; - } -#if 0 - } - else - { - l = malloc(sizeof(*l)); - if (l == NULL) - { - DEBUG(5,("open pipes: local msrpc malloc failed\n")); - return NULL; - } - ZERO_STRUCTP(l); - l->rhdr.data = NULL; - l->rdata.data = NULL; - l->rhdr.offset = 0; - l->rdata.offset = 0; - - l->ntlmssp_validated = False; - l->ntlmssp_auth = False; - - memcpy(l->user_sess_key, vuser->user_sess_key, - sizeof(l->user_sess_key)); - } -#endif p = (pipes_struct *)malloc(sizeof(*p)); - if (!p) return NULL; + if (!p) + return NULL; ZERO_STRUCTP(p); + + /* + * Initialize the RPC and PDU data buffers with no memory. + */ + prs_init(&p->rdata, 0, 4, MARSHALL); + DLIST_ADD(Pipes, p); bitmap_set(bmap, i); @@ -177,24 +154,28 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, pipes_open++; p->pnum = i; - p->m = m; - p->l = l; p->open = True; p->device_state = 0; p->priority = 0; p->conn = conn; p->vuid = vuid; + + p->max_trans_reply = 0; - p->file_offset = 0; - p->prev_pdu_file_offset = 0; - p->hdr_offsets = 0; - - fstrcpy(p->name, pipe_name); + p->ntlmssp_chal_flags = 0; + p->ntlmssp_auth_validated = False; + p->ntlmssp_auth_requested = False; - prs_init(&p->smb_pdu, 0, 4, 0, True); - prs_init(&p->rsmb_pdu, 0, 4, 0, False); + p->current_pdu_len = 0; + p->current_pdu_sent = 0; + p->data_sent_length = 0; + p->uid = (uid_t)-1; + p->gid = (gid_t)-1; + + fstrcpy(p->name, pipe_name); + DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n", pipe_name, i, pipes_open)); @@ -202,182 +183,179 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, /* OVERWRITE p as a temp variable, to display all open pipes */ for (p = Pipes; p; p = p->next) - { DEBUG(5,("open pipes: name %s pnum=%x\n", p->name, p->pnum)); - } return chain_p; } /**************************************************************************** - writes data to a pipe. + Accepts incoming data on an rpc pipe. - SERIOUSLY ALPHA CODE! + This code is probably incorrect at the moment. The problem is + that the rpc request shouldn't really be executed until all the + data needed for it is received. This currently assumes that each + SMBwrite or SMBwriteX contains all the data needed for an rpc + request. JRA. ****************************************************************************/ -ssize_t write_pipe(pipes_struct *p, char *data, size_t n) + +ssize_t write_to_pipe(pipes_struct *p, char *data, size_t n) { DEBUG(6,("write_pipe: %x", p->pnum)); + DEBUG(6,("name: %s open: %s len: %d", - p->name, BOOLSTR(p->open), n)); + p->name, BOOLSTR(p->open), (int)n)); dump_data(50, data, n); - return rpc_to_smb(p, data, n) ? ((ssize_t)n) : -1; + return rpc_command(p, data, (int)n) ? ((ssize_t)n) : -1; } /**************************************************************************** - reads data from a pipe. + Replyies to a request to read data from a pipe. - headers are interspersed with the data at regular intervals. by the time + Headers are interspersed with the data at PDU intervals. By the time this function is called, the start of the data could possibly have been read by an SMBtrans (file_offset != 0). - calling create_rpc_reply() here is a fudge. the data should already + Calling create_rpc_reply() here is a hack. The data should already have been prepared into arrays of headers + data stream sections. ****************************************************************************/ -int read_pipe(pipes_struct *p, char *data, uint32 pos, int n) + +int read_from_pipe(pipes_struct *p, char *data, int n) { - int num = 0; - int pdu_len = 0; - uint32 hdr_num = 0; - int pdu_data_sent; /* amount of current pdu already sent */ - int data_pos; /* entire rpc data sent - no headers, no auth verifiers */ - int this_pdu_data_pos; - - DEBUG(6,("read_pipe: %x name: %s open: %s pos: %d len: %d", - p->pnum, p->name, BOOLSTR(p->open), - pos, n)); - - if (!p || !p->open) - { - DEBUG(6,("pipe not open\n")); + uint32 pdu_remaining = 0; + int data_returned = 0; + + if (!p || !p->open) { + DEBUG(0,("read_from_pipe: pipe not open\n")); return -1; } + DEBUG(6,("read_from_pipe: %x", p->pnum)); - if (p->rsmb_pdu.data == NULL || p->rsmb_pdu.data->data == NULL || - p->rsmb_pdu.data->data_used == 0) - { - return 0; + DEBUG(6,("name: %s len: %d\n", p->name, n)); + + /* + * We cannot return more than one PDU length per + * read request. + */ + + if(n > MAX_PDU_FRAG_LEN) { + DEBUG(0,("read_from_pipe: loo large read (%d) requested on pipe %s. We can \ +only service %d sized reads.\n", n, p->name, MAX_PDU_FRAG_LEN )); + return -1; } - DEBUG(6,("read_pipe: p: %p file_offset: %d file_pos: %d\n", - p, p->file_offset, n)); + /* + * Determine if there is still data to send in the + * pipe PDU buffer. Always send this first. Never + * send more than is left in the current PDU. The + * client should send a new read request for a new + * PDU. + */ - /* the read request starts from where the SMBtrans2 left off. */ - data_pos = p->file_offset - p->hdr_offsets; - pdu_data_sent = p->file_offset - p->prev_pdu_file_offset; - this_pdu_data_pos = (pdu_data_sent == 0) ? 0 : (pdu_data_sent - 0x18); + if((pdu_remaining = p->current_pdu_len - p->current_pdu_sent) > 0) { + data_returned = MIN(n, pdu_remaining); - if (!IS_BITS_SET_ALL(p->l->hdr.flags, RPC_FLG_LAST)) - { - /* intermediate fragment - possibility of another header */ - - DEBUG(5,("read_pipe: frag_len: %d data_pos: %d pdu_data_sent: %d\n", - p->l->hdr.frag_len, data_pos, pdu_data_sent)); - - if (pdu_data_sent == 0) - { - DEBUG(6,("read_pipe: next fragment header\n")); - - /* this is subtracted from the total data bytes, later */ - hdr_num = 0x18; - p->hdr_offsets += 0x18; - data_pos -= 0x18; - - /* create and copy in a new header. */ - create_rpc_reply(p->l, data_pos); - } - } - - pdu_len = mem_buf_len(p->rsmb_pdu.data); - num = pdu_len - this_pdu_data_pos; - - DEBUG(6,("read_pipe: pdu_len: %d num: %d n: %d\n", pdu_len, num, n)); - - if (num > n) num = n; - if (num <= 0) - { - DEBUG(5,("read_pipe: 0 or -ve data length\n")); - return 0; - } + DEBUG(10,("read_from_pipe: %s: current_pdu_len = %u, current_pdu_sent = %u \ +returning %d bytes.\n", p->name, (unsigned int)p->current_pdu_len, + (unsigned int)p->current_pdu_sent, (int)data_returned)); - if (num < hdr_num) - { - DEBUG(5,("read_pipe: warning - data read only part of a header\n")); + memcpy( data, &p->current_pdu[p->current_pdu_sent], (size_t)data_returned); + p->current_pdu_sent += (uint32)data_returned; + return data_returned; } - mem_buf_copy(data, p->rsmb_pdu.data, pdu_data_sent, num); - - p->file_offset += num; - pdu_data_sent += num; - - if (hdr_num == 0x18 && num == 0x18) - { - DEBUG(6,("read_pipe: just header read\n")); + /* + * At this point p->current_pdu_len == p->current_pdu_sent (which + * may of course be zero if this is the first return fragment. + */ + + DEBUG(10,("read_from_pipe: %s: data_sent_length = %u, prs_offset(&p->rdata) = %u.\n", + p->name, (unsigned int)p->data_sent_length, (unsigned int)prs_offset(&p->rdata) )); + + if(p->data_sent_length >= prs_offset(&p->rdata)) { + /* + * We have sent all possible data. Return 0. + */ + return 0; } - if (pdu_data_sent == p->l->hdr.frag_len) - { - DEBUG(6,("read_pipe: next fragment expected\n")); - p->prev_pdu_file_offset = p->file_offset; + /* + * We need to create a new PDU from the data left in p->rdata. + * Create the header/data/footers. This also sets up the fields + * p->current_pdu_len, p->current_pdu_sent, p->data_sent_length + * and stores the outgoing PDU in p->current_pdu. + */ + + if(!create_next_pdu(p)) { + DEBUG(0,("read_from_pipe: %s: create_next_pdu failed.\n", + p->name)); + return -1; } - return num; -} + data_returned = MIN(n, p->current_pdu_len); + memcpy( data, p->current_pdu, (size_t)data_returned); + p->current_pdu_sent += (uint32)data_returned; + return data_returned; +} /**************************************************************************** - wait device state on a pipe. exactly what this is for is unknown... + Wait device state on a pipe. Exactly what this is for is unknown... ****************************************************************************/ + BOOL wait_rpc_pipe_hnd_state(pipes_struct *p, uint16 priority) { - if (p == NULL) return False; + if (p == NULL) + return False; - if (p->open) - { - DEBUG(3,("%s Setting pipe wait state priority=%x on pipe (name=%s)\n", - timestring(), priority, p->name)); + if (p->open) { + DEBUG(3,("wait_rpc_pipe_hnd_state: Setting pipe wait state priority=%x on pipe (name=%s)\n", + priority, p->name)); p->priority = priority; return True; } - DEBUG(3,("%s Error setting pipe wait state priority=%x (name=%s)\n", - timestring(), priority, p->name)); + DEBUG(3,("wait_rpc_pipe_hnd_state: Error setting pipe wait state priority=%x (name=%s)\n", + priority, p->name)); return False; } /**************************************************************************** - set device state on a pipe. exactly what this is for is unknown... + Set device state on a pipe. Exactly what this is for is unknown... ****************************************************************************/ + BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state) { - if (p == NULL) return False; + if (p == NULL) + return False; if (p->open) { - DEBUG(3,("%s Setting pipe device state=%x on pipe (name=%s)\n", - timestring(), device_state, p->name)); + DEBUG(3,("set_rpc_pipe_hnd_state: Setting pipe device state=%x on pipe (name=%s)\n", + device_state, p->name)); p->device_state = device_state; return True; } - DEBUG(3,("%s Error setting pipe device state=%x (name=%s)\n", - timestring(), device_state, p->name)); + DEBUG(3,("set_rpc_pipe_hnd_state: Error setting pipe device state=%x (name=%s)\n", + device_state, p->name)); return False; } /**************************************************************************** - close an rpc pipe + Close an rpc pipe. ****************************************************************************/ + BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) { if (!p) { @@ -385,8 +363,7 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) return False; } - mem_buf_free(&(p->smb_pdu .data)); - mem_buf_free(&(p->rsmb_pdu.data)); + prs_mem_free(&p->rdata); bitmap_clear(bmap, p->pnum - pipe_handle_offset); @@ -397,50 +374,31 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) DLIST_REMOVE(Pipes, p); - if (p->m != NULL) - { - DEBUG(4,("closed msrpc redirect: ")); - if (msrpc_use_del(p->m->pipe_name, &p->m->usr, False, NULL)) - { - DEBUG(4,("OK\n")); - } - else - { - DEBUG(4,("FAILED\n")); - } - } - - if (p->l != NULL) - { - DEBUG(4,("closed msrpc local: OK\n")); - - mem_free_data(p->l->rdata .data); - rpcsrv_free_temp(p->l); - - free(p->l); - } - ZERO_STRUCTP(p); + free(p); return True; } /**************************************************************************** - close an rpc pipe + Find an rpc pipe given a pipe handle in a buffer and an offset. ****************************************************************************/ + pipes_struct *get_rpc_pipe_p(char *buf, int where) { int pnum = SVAL(buf,where); - if (chain_p) return chain_p; + if (chain_p) + return chain_p; return get_rpc_pipe(pnum); } /**************************************************************************** - close an rpc pipe + Find an rpc pipe given a pipe handle. ****************************************************************************/ + pipes_struct *get_rpc_pipe(int pnum) { pipes_struct *p; @@ -448,15 +406,11 @@ pipes_struct *get_rpc_pipe(int pnum) DEBUG(4,("search for pipe pnum=%x\n", pnum)); for (p=Pipes;p;p=p->next) - { DEBUG(5,("pipe name %s pnum=%x (pipes_open=%d)\n", p->name, p->pnum, pipes_open)); - } - for (p=Pipes;p;p=p->next) - { - if (p->pnum == pnum) - { + for (p=Pipes;p;p=p->next) { + if (p->pnum == pnum) { chain_p = p; return p; } @@ -464,4 +418,3 @@ pipes_struct *get_rpc_pipe(int pnum) return NULL; } - diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index ea3150fd3c..fc3ce9c0d2 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -1,4 +1,3 @@ - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -38,10 +37,10 @@ static void reg_reply_close(REG_Q_CLOSE *q_r, REG_R_CLOSE r_u; /* set up the REG unknown_1 response */ - bzero(r_u.pol.data, POL_HND_SIZE); + memset((char *)r_u.pol.data, '\0', POL_HND_SIZE); /* close the policy handle */ - if (close_policy_hnd(&(q_r->pol))) + if (close_lsa_policy_hnd(&(q_r->pol))) { r_u.status = 0; } @@ -61,7 +60,7 @@ static void reg_reply_close(REG_Q_CLOSE *q_r, /******************************************************************* api_reg_close ********************************************************************/ -static void api_reg_close( rpcsrv_struct *p, prs_struct *data, +static BOOL api_reg_close( uint16 vuid, prs_struct *data, prs_struct *rdata ) { REG_Q_CLOSE q_r; @@ -71,6 +70,8 @@ static void api_reg_close( rpcsrv_struct *p, prs_struct *data, /* construct reply. always indicate success */ reg_reply_close(&q_r, rdata); + + return True; } @@ -84,7 +85,7 @@ static void reg_reply_open(REG_Q_OPEN_HKLM *q_r, r_u.status = 0x0; /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !open_policy_hnd(&(r_u.pol))) + if (r_u.status == 0x0 && !open_lsa_policy_hnd(&(r_u.pol))) { r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -100,7 +101,7 @@ static void reg_reply_open(REG_Q_OPEN_HKLM *q_r, /******************************************************************* api_reg_open ********************************************************************/ -static void api_reg_open( rpcsrv_struct *p, prs_struct *data, +static BOOL api_reg_open( uint16 vuid, prs_struct *data, prs_struct *rdata ) { REG_Q_OPEN_HKLM q_u; @@ -110,6 +111,8 @@ static void api_reg_open( rpcsrv_struct *p, prs_struct *data, /* construct reply. always indicate success */ reg_reply_open(&q_u, rdata); + + return True; } @@ -126,35 +129,30 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, DEBUG(5,("reg_open_entry: %d\n", __LINE__)); - if (status == 0 && find_policy_by_hnd(&(q_u->pol)) == -1) + if (status == 0 && find_lsa_policy_by_hnd(&(q_u->pol)) == -1) { status = 0xC000000 | NT_STATUS_INVALID_HANDLE; } - if (status == 0x0 && !open_policy_hnd(&pol)) + if (status == 0x0 && !open_lsa_policy_hnd(&pol)) { status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } - unistr2_to_ascii(name, &q_u->uni_name, sizeof(name)-1); + fstrcpy(name, dos_unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len)); if (status == 0x0) { DEBUG(5,("reg_open_entry: %s\n", name)); /* lkcl XXXX do a check on the name, here */ - if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions") && - !strequal(name, "SYSTEM\\CurrentControlSet\\Services\\NETLOGON\\Parameters\\")) - { - status = 0xC000000 | NT_STATUS_ACCESS_DENIED; - } } - if (status == 0x0 && !set_policy_reg_name(&pol, name)) + if (status == 0x0 && !set_lsa_policy_reg_name(&pol, name)) { status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } - make_reg_r_open_entry(&r_u, &pol, status); + init_reg_r_open_entry(&r_u, &pol, status); /* store the response in the SMB stream */ reg_io_r_open_entry("", &r_u, rdata, 0); @@ -165,7 +163,7 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, /******************************************************************* api_reg_open_entry ********************************************************************/ -static void api_reg_open_entry( rpcsrv_struct *p, prs_struct *data, +static BOOL api_reg_open_entry( uint16 vuid, prs_struct *data, prs_struct *rdata ) { REG_Q_OPEN_ENTRY q_u; @@ -175,6 +173,8 @@ static void api_reg_open_entry( rpcsrv_struct *p, prs_struct *data, /* construct reply. */ reg_reply_open_entry(&q_u, rdata); + + return True; } @@ -187,32 +187,19 @@ static void reg_reply_info(REG_Q_INFO *q_u, uint32 status = 0; REG_R_INFO r_u; - uint32 type = 0xcafeface; - BUFFER2 buf; - fstring name; - - ZERO_STRUCT(buf); DEBUG(5,("reg_info: %d\n", __LINE__)); - if (status == 0x0 && !get_policy_reg_name(&q_u->pol, name)) + if (status == 0 && find_lsa_policy_by_hnd(&(q_u->pol)) == -1) { status = 0xC000000 | NT_STATUS_INVALID_HANDLE; } - if (status == 0 && - strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions")) + if (status == 0) { - char *key = "LanmanNT"; - make_buffer2(&buf, key, strlen(key)); - type = 0x1; - } - else - { - status = 0x2; /* Win32 status code. ick */ } - make_reg_r_info(&r_u, &type, &buf, status); + init_reg_r_info(&r_u, 1, "LanmanNT", 0x12, 0x12, status); /* store the response in the SMB stream */ reg_io_r_info("", &r_u, rdata, 0); @@ -223,7 +210,7 @@ static void reg_reply_info(REG_Q_INFO *q_u, /******************************************************************* api_reg_info ********************************************************************/ -static void api_reg_info( rpcsrv_struct *p, prs_struct *data, +static BOOL api_reg_info( uint16 vuid, prs_struct *data, prs_struct *rdata ) { REG_Q_INFO q_u; @@ -233,6 +220,8 @@ static void api_reg_info( rpcsrv_struct *p, prs_struct *data, /* construct reply. always indicate success */ reg_reply_info(&q_u, rdata); + + return True; } @@ -251,7 +240,7 @@ static struct api_struct api_reg_cmds[] = /******************************************************************* receives a reg pipe and responds. ********************************************************************/ -BOOL api_reg_rpc(rpcsrv_struct *p, prs_struct *data) +BOOL api_reg_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds, data); } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 738623ec4d..169dc2169e 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -28,11 +28,13 @@ extern int DEBUGLEVEL; -extern fstring global_sam_name; +extern fstring global_myworkgroup; extern pstring global_myname; extern DOM_SID global_sam_sid; -extern DOM_SID global_sid_S_1_1; -extern DOM_SID global_sid_S_1_5_20; + +extern rid_name domain_group_rids[]; +extern rid_name domain_alias_rids[]; +extern rid_name builtin_alias_rids[]; /******************************************************************* This next function should be replaced with something that @@ -69,18 +71,15 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, /* skip the requested number of entries. not very efficient, but hey... */ - if (acb_mask == 0 || IS_BITS_SET_SOME(pwd->acct_ctrl, acb_mask)) - { - start_idx--; - } + start_idx--; continue; } - user_name_len = strlen(pwd->nt_name); - make_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->nt_name, user_name_len); - make_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len); + user_name_len = strlen(pwd->smb_name); + 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; - bzero( pw_buf[(*num_entries)].nt_pwd , 16); + 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) @@ -91,7 +90,7 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, pw_buf[(*num_entries)].acb_info = (uint16)pwd->acct_ctrl; DEBUG(5, ("entry idx: %d user %s, rid 0x%x, acb %x", - (*num_entries), pwd->nt_name, + (*num_entries), pwd->smb_name, pwd->user_rid, pwd->acct_ctrl)); if (acb_mask == 0 || IS_BITS_SET_SOME(pwd->acct_ctrl, acb_mask)) @@ -121,10 +120,10 @@ static void samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, SAMR_R_CLOSE_HND r_u; /* set up the SAMR unknown_1 response */ - bzero(r_u.pol.data, POL_HND_SIZE); + memset((char *)r_u.pol.data, '\0', POL_HND_SIZE); /* close the policy handle */ - if (close_policy_hnd(&(q_u->pol))) + if (close_lsa_policy_hnd(&(q_u->pol))) { r_u.status = 0; } @@ -145,11 +144,17 @@ static void samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, /******************************************************************* api_samr_close_hnd ********************************************************************/ -static void api_samr_close_hnd( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_close_hnd( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_CLOSE_HND q_u; + + /* grab the samr unknown 1 */ samr_io_q_close_hnd("", &q_u, data, 0); + + /* construct reply. always indicate success */ samr_reply_close_hnd(&q_u, rdata); + + return True; } @@ -165,19 +170,19 @@ static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, r_u.status = 0x0; /* find the connection policy handle. */ - if (r_u.status == 0x0 && (find_policy_by_hnd(&(q_u->connect_pol)) == -1)) + if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->connect_pol)) == -1)) { r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_policy_hnd(&(r_u.domain_pol)))) + if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.domain_pol)))) { r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } /* associate the domain SID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_policy_samr_sid(&(r_u.domain_pol), &(q_u->dom_sid.sid))) + if (r_u.status == 0x0 && !set_lsa_policy_samr_sid(&(r_u.domain_pol), &(q_u->dom_sid.sid))) { /* oh, whoops. don't know what error message to return, here */ r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -185,7 +190,7 @@ static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, if (r_u.status != 0 && pol_open) { - close_policy_hnd(&(r_u.domain_pol)); + close_lsa_policy_hnd(&(r_u.domain_pol)); } DEBUG(5,("samr_open_domain: %d\n", __LINE__)); @@ -200,11 +205,17 @@ static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, /******************************************************************* api_samr_open_domain ********************************************************************/ -static void api_samr_open_domain( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_open_domain( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_DOMAIN q_u; + + /* grab the samr open */ samr_io_q_open_domain("", &q_u, data, 0); + + /* construct reply. always indicate success */ samr_reply_open_domain(&q_u, rdata); + + return True; } @@ -218,18 +229,18 @@ static void samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, uint32 status = 0x0; /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_policy_by_hnd(&(q_u->user_pol)) == -1)) + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->user_pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* find the user's rid */ - if ((status == 0x0) && (get_policy_samr_rid(&(q_u->user_pol)) == 0xffffffff)) + if ((status == 0x0) && (get_lsa_policy_samr_rid(&(q_u->user_pol)) == 0xffffffff)) { - status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; + status = NT_STATUS_OBJECT_TYPE_MISMATCH; } - make_samr_r_unknown_2c(&r_u, status); + init_samr_r_unknown_2c(&r_u, status); DEBUG(5,("samr_unknown_2c: %d\n", __LINE__)); @@ -243,11 +254,17 @@ static void samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, /******************************************************************* api_samr_unknown_2c ********************************************************************/ -static void api_samr_unknown_2c( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_2c( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_2C q_u; + + /* grab the samr open */ samr_io_q_unknown_2c("", &q_u, data, 0); + + /* construct reply. always indicate success */ samr_reply_unknown_2c(&q_u, rdata); + + return True; } @@ -265,37 +282,40 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, status = 0x0; /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_policy_by_hnd(&(q_u->user_pol)) == -1)) + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->user_pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } /* find the user's rid */ - if (status == 0x0 && (rid = get_policy_samr_rid(&(q_u->user_pol))) == 0xffffffff) + if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->user_pol))) == 0xffffffff) { - status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; + status = NT_STATUS_OBJECT_TYPE_MISMATCH; } if (status == 0x0) { - DOM_SID usr_sid; + DOM_SID user_sid; + DOM_SID everyone_sid; - usr_sid = global_sam_sid; + user_sid = global_sam_sid; - SMB_ASSERT_ARRAY(usr_sid.sub_auths, usr_sid.num_auths+1); + SMB_ASSERT_ARRAY(user_sid.sub_auths, user_sid.num_auths+1); /* * Add the user RID. */ - sid_append_rid(&usr_sid, rid); + user_sid.sub_auths[user_sid.num_auths++] = rid; - /* maybe need another 1 or 2 (S-1-5-0x20-0x220 and S-1-5-20-0x224) */ - /* these two are DOMAIN_ADMIN and DOMAIN_ACCT_OP group RIDs */ - make_dom_sid3(&(sid[0]), 0x035b, 0x0002, &global_sid_S_1_1); - make_dom_sid3(&(sid[1]), 0x0044, 0x0002, &usr_sid); + string_to_sid(&everyone_sid, "S-1-1"); + + /* maybe need another 1 or 2 (S-1-5-0x20-0x220 and S-1-5-20-0x224) */ + /* these two are DOMAIN_ADMIN and DOMAIN_ACCT_OP group RIDs */ + init_dom_sid3(&(sid[0]), 0x035b, 0x0002, &everyone_sid); + init_dom_sid3(&(sid[1]), 0x0044, 0x0002, &user_sid); } - make_samr_r_unknown_3(&r_u, + init_samr_r_unknown_3(&r_u, 0x0001, 0x8004, 0x00000014, 0x0002, 0x0070, 2, sid, status); @@ -312,11 +332,17 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, /******************************************************************* api_samr_unknown_3 ********************************************************************/ -static void api_samr_unknown_3( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_3( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_3 q_u; + + /* grab the samr open */ samr_io_q_unknown_3("", &q_u, data, 0); + + /* construct reply. always indicate success */ samr_reply_unknown_3(&q_u, rdata); + + return True; } @@ -332,9 +358,10 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, int total_entries; r_e.status = 0x0; + r_e.total_num_entries = 0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) + if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -342,27 +369,16 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, DEBUG(5,("samr_reply_enum_dom_users: %d\n", __LINE__)); become_root(True); - get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, - MAX_SAM_ENTRIES, q_u->acb_mask); + get_sampwd_entries(pass, 0, &total_entries, &num_entries, MAX_SAM_ENTRIES, q_u->acb_mask); unbecome_root(True); - make_samr_r_enum_dom_users(&r_e, - q_u->start_idx + num_entries, num_entries, + init_samr_r_enum_dom_users(&r_e, total_entries, + q_u->unknown_0, num_entries, pass, r_e.status); /* store the response in the SMB stream */ samr_io_r_enum_dom_users("", &r_e, rdata, 0); - if (r_e.sam != NULL) - { - free(r_e.sam); - } - - if (r_e.uni_acct_name != NULL) - { - free(r_e.uni_acct_name); - } - DEBUG(5,("samr_enum_dom_users: %d\n", __LINE__)); } @@ -370,2278 +386,984 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, /******************************************************************* api_samr_enum_dom_users ********************************************************************/ -static void api_samr_enum_dom_users( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_enum_dom_users( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_USERS q_e; + + /* grab the samr open */ samr_io_q_enum_dom_users("", &q_e, data, 0); + + /* construct reply. */ samr_reply_enum_dom_users(&q_e, rdata); + + return True; } /******************************************************************* - samr_reply_add_groupmem + samr_reply_enum_dom_groups ********************************************************************/ -static void samr_reply_add_groupmem(SAMR_Q_ADD_GROUPMEM *q_u, +static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, prs_struct *rdata) { - SAMR_R_ADD_GROUPMEM r_e; - DOM_SID group_sid; - uint32 group_rid; - fstring group_sid_str; + SAMR_R_ENUM_DOM_GROUPS r_e; + SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; + int num_entries; + BOOL got_grps; + char *dummy_group = "Domain Admins"; r_e.status = 0x0; + r_e.num_entries = 0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && !get_policy_samr_sid(&q_u->pol, &group_sid)) + if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } - else - { - sid_to_string(group_sid_str, &group_sid); - sid_split_rid(&group_sid, &group_rid); - } - if (r_e.status == 0x0) - { - DEBUG(10,("sid is %s\n", group_sid_str)); + DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); - if (sid_equal(&group_sid, &global_sam_sid)) - { - DEBUG(10,("lookup on Domain SID\n")); + got_grps = True; + num_entries = 1; + init_unistr2(&(pass[0].uni_user_name), dummy_group, strlen(dummy_group)); + pass[0].user_rid = DOMAIN_GROUP_RID_ADMINS; - become_root(True); - r_e.status = add_group_member(group_rid, q_u->rid) ? 0x0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); - unbecome_root(True); - } - else - { - r_e.status = 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; - } + if (r_e.status == 0 && got_grps) + { + init_samr_r_enum_dom_groups(&r_e, q_u->start_idx, num_entries, pass, r_e.status); } /* store the response in the SMB stream */ - samr_io_r_add_groupmem("", &r_e, rdata, 0); + samr_io_r_enum_dom_groups("", &r_e, rdata, 0); + + DEBUG(5,("samr_enum_dom_groups: %d\n", __LINE__)); - DEBUG(5,("samr_add_groupmem: %d\n", __LINE__)); } /******************************************************************* - api_samr_add_groupmem + api_samr_enum_dom_groups ********************************************************************/ -static void api_samr_add_groupmem( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_enum_dom_groups( uint16 vuid, prs_struct *data, prs_struct *rdata) { - SAMR_Q_ADD_GROUPMEM q_e; - samr_io_q_add_groupmem("", &q_e, data, 0); - samr_reply_add_groupmem(&q_e, rdata); + SAMR_Q_ENUM_DOM_GROUPS q_e; + + /* grab the samr open */ + samr_io_q_enum_dom_groups("", &q_e, data, 0); + + /* construct reply. */ + samr_reply_enum_dom_groups(&q_e, rdata); + + return True; } + /******************************************************************* - samr_reply_del_groupmem + samr_reply_enum_dom_aliases ********************************************************************/ -static void samr_reply_del_groupmem(SAMR_Q_DEL_GROUPMEM *q_u, +static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, prs_struct *rdata) { - SAMR_R_DEL_GROUPMEM r_e; - DOM_SID group_sid; - uint32 group_rid; - fstring group_sid_str; + SAMR_R_ENUM_DOM_ALIASES r_e; + SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; + int num_entries = 0; + DOM_SID sid; + fstring sid_str; + fstring sam_sid_str; r_e.status = 0x0; + r_e.num_entries = 0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && !get_policy_samr_sid(&q_u->pol, &group_sid)) + if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &sid)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } - else - { - sid_to_string(group_sid_str, &group_sid); - sid_split_rid(&group_sid, &group_rid); - } - if (r_e.status == 0x0) - { - DEBUG(10,("sid is %s\n", group_sid_str)); + sid_to_string(sid_str, &sid); + sid_to_string(sam_sid_str, &global_sam_sid); - if (sid_equal(&group_sid, &global_sam_sid)) - { - DEBUG(10,("lookup on Domain SID\n")); + DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", sid_str)); - become_root(True); - r_e.status = del_group_member(group_rid, q_u->rid) ? 0x0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); - unbecome_root(True); - } - else + /* well-known aliases */ + if (strequal(sid_str, "S-1-5-32")) + { + char *name; + while (num_entries < MAX_SAM_ENTRIES && ((name = builtin_alias_rids[num_entries].name) != NULL)) { - r_e.status = 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; + init_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)); + pass[num_entries].user_rid = builtin_alias_rids[num_entries].rid; + num_entries++; } } + else if (strequal(sid_str, sam_sid_str)) + { + /* local aliases */ + /* oops! there's no code to deal with this */ + DEBUG(3,("samr_reply_enum_dom_aliases: enum of aliases in our domain not supported yet\n")); + num_entries = 0; + } + + init_samr_r_enum_dom_aliases(&r_e, num_entries, pass, r_e.status); /* store the response in the SMB stream */ - samr_io_r_del_groupmem("", &r_e, rdata, 0); + samr_io_r_enum_dom_aliases("", &r_e, rdata, 0); + + DEBUG(5,("samr_enum_dom_aliases: %d\n", __LINE__)); - DEBUG(5,("samr_del_groupmem: %d\n", __LINE__)); } /******************************************************************* - api_samr_del_groupmem + api_samr_enum_dom_aliases ********************************************************************/ -static void api_samr_del_groupmem( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_enum_dom_aliases( uint16 vuid, prs_struct *data, prs_struct *rdata) { - SAMR_Q_DEL_GROUPMEM q_e; - samr_io_q_del_groupmem("", &q_e, data, 0); - samr_reply_del_groupmem(&q_e, rdata); + SAMR_Q_ENUM_DOM_ALIASES q_e; + + /* grab the samr open */ + samr_io_q_enum_dom_aliases("", &q_e, data, 0); + + /* construct reply. */ + samr_reply_enum_dom_aliases(&q_e, rdata); + + return True; } + /******************************************************************* - samr_reply_add_aliasmem + samr_reply_query_dispinfo ********************************************************************/ -static void samr_reply_add_aliasmem(SAMR_Q_ADD_ALIASMEM *q_u, +static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, prs_struct *rdata) { - SAMR_R_ADD_ALIASMEM r_e; - DOM_SID alias_sid; - uint32 alias_rid; - fstring alias_sid_str; + SAMR_R_QUERY_DISPINFO r_e; + SAM_INFO_CTR ctr; + SAM_INFO_1 info1; + SAM_INFO_2 info2; + SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; + int num_entries = 0; + int total_entries = 0; + BOOL got_pwds; + uint16 switch_level = 0x0; + + ZERO_STRUCT(r_e); r_e.status = 0x0; + DEBUG(5,("samr_reply_query_dispinfo: %d\n", __LINE__)); + /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && !get_policy_samr_sid(&q_u->alias_pol, &alias_sid)) + if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - else - { - sid_to_string(alias_sid_str, &alias_sid); - sid_split_rid(&alias_sid, &alias_rid); + DEBUG(5,("samr_reply_query_dispinfo: invalid handle\n")); } if (r_e.status == 0x0) { - DEBUG(10,("sid is %s\n", alias_sid_str)); + become_root(True); + got_pwds = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); + unbecome_root(True); - if (sid_equal(&alias_sid, &global_sam_sid)) + switch (q_u->switch_level) { - DEBUG(10,("add member on Domain SID\n")); + case 0x1: + { + + /* query disp info is for users */ + switch_level = 0x1; + init_sam_info_1(&info1, ACB_NORMAL, + q_u->start_idx, num_entries, pass); - become_root(True); - r_e.status = add_alias_member(alias_rid, &q_u->sid.sid) ? 0x0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); - unbecome_root(True); - } - else if (sid_equal(&alias_sid, &global_sid_S_1_5_20)) - { - DEBUG(10,("add member on BUILTIN SID\n")); + ctr.sam.info1 = &info1; - become_root(True); - r_e.status = add_builtin_member(alias_rid, &q_u->sid.sid) ? 0x0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); - unbecome_root(True); - } - else - { - r_e.status = 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; + break; + } + case 0x2: + { + /* query disp info is for servers */ + switch_level = 0x2; + init_sam_info_2(&info2, ACB_WSTRUST, + q_u->start_idx, num_entries, pass); + + ctr.sam.info2 = &info2; + + break; + } } } + if (r_e.status == 0 && got_pwds) + { + init_samr_r_query_dispinfo(&r_e, switch_level, &ctr, r_e.status); + } + /* store the response in the SMB stream */ - samr_io_r_add_aliasmem("", &r_e, rdata, 0); + samr_io_r_query_dispinfo("", &r_e, rdata, 0); + + DEBUG(5,("samr_query_dispinfo: %d\n", __LINE__)); - DEBUG(5,("samr_add_aliasmem: %d\n", __LINE__)); } /******************************************************************* - api_samr_add_aliasmem + api_samr_query_dispinfo ********************************************************************/ -static void api_samr_add_aliasmem( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_query_dispinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) { - SAMR_Q_ADD_ALIASMEM q_e; - samr_io_q_add_aliasmem("", &q_e, data, 0); - samr_reply_add_aliasmem(&q_e, rdata); + SAMR_Q_QUERY_DISPINFO q_e; + + /* grab the samr open */ + samr_io_q_query_dispinfo("", &q_e, data, 0); + + /* construct reply. */ + samr_reply_query_dispinfo(&q_e, rdata); + + return True; } + /******************************************************************* - samr_reply_del_aliasmem + samr_reply_query_aliasinfo ********************************************************************/ -static void samr_reply_del_aliasmem(SAMR_Q_DEL_ALIASMEM *q_u, +static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, prs_struct *rdata) { - SAMR_R_DEL_ALIASMEM r_e; - DOM_SID alias_sid; - uint32 alias_rid; - fstring alias_sid_str; + SAMR_R_QUERY_ALIASINFO r_e; r_e.status = 0x0; + r_e.ptr = 0; /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && !get_policy_samr_sid(&q_u->alias_pol, &alias_sid)) + if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } - else - { - sid_to_string(alias_sid_str, &alias_sid); - sid_split_rid(&alias_sid, &alias_rid); - } + + DEBUG(5,("samr_reply_query_aliasinfo: %d\n", __LINE__)); if (r_e.status == 0x0) { - DEBUG(10,("sid is %s\n", alias_sid_str)); - - if (sid_equal(&alias_sid, &global_sam_sid)) + if (q_u->switch_level != 3) { - DEBUG(10,("del member on Domain SID\n")); - - become_root(True); - r_e.status = del_alias_member(alias_rid, &q_u->sid.sid) ? 0x0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); - unbecome_root(True); - } - else if (sid_equal(&alias_sid, &global_sid_S_1_5_20)) - { - DEBUG(10,("del member on BUILTIN SID\n")); - - become_root(True); - r_e.status = del_builtin_member(alias_rid, &q_u->sid.sid) ? 0x0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); - unbecome_root(True); - } - else - { - r_e.status = 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; + r_e.status = NT_STATUS_INVALID_INFO_CLASS; } } + init_samr_r_query_aliasinfo(&r_e, q_u->switch_level, + "", + r_e.status); + /* store the response in the SMB stream */ - samr_io_r_del_aliasmem("", &r_e, rdata, 0); + samr_io_r_query_aliasinfo("", &r_e, rdata, 0); + + DEBUG(5,("samr_query_aliasinfo: %d\n", __LINE__)); - DEBUG(5,("samr_del_aliasmem: %d\n", __LINE__)); } /******************************************************************* - api_samr_del_aliasmem + api_samr_query_aliasinfo ********************************************************************/ -static void api_samr_del_aliasmem( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_query_aliasinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) { - SAMR_Q_DEL_ALIASMEM q_e; - samr_io_q_del_aliasmem("", &q_e, data, 0); - samr_reply_del_aliasmem(&q_e, rdata); + SAMR_Q_QUERY_ALIASINFO q_e; + + /* grab the samr open */ + samr_io_q_query_aliasinfo("", &q_e, data, 0); + + /* construct reply. */ + samr_reply_query_aliasinfo(&q_e, rdata); + + return True; } + /******************************************************************* - samr_reply_enum_domains + samr_reply_lookup_ids ********************************************************************/ -static void samr_reply_enum_domains(SAMR_Q_ENUM_DOMAINS *q_u, +static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, prs_struct *rdata) { - SAMR_R_ENUM_DOMAINS r_e; - char **doms = NULL; - uint32 num_entries = 0; - - r_e.status = 0x0; - r_e.num_entries2 = 0; + uint32 rid[MAX_SAM_ENTRIES]; + uint32 status = 0; + int num_rids = q_u->num_sids1; - ZERO_STRUCT(r_e); + SAMR_R_LOOKUP_IDS r_u; - r_e.status = 0x0; + DEBUG(5,("samr_lookup_ids: %d\n", __LINE__)); - /* find the connection policy handle. */ - if (r_e.status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) + if (num_rids > MAX_SAM_ENTRIES) { - r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + num_rids = MAX_SAM_ENTRIES; + DEBUG(5,("samr_lookup_ids: truncating entries to %d\n", num_rids)); } - DEBUG(5,("samr_reply_enum_domains:\n")); +#if 0 + int i; + SMB_ASSERT_ARRAY(q_u->uni_user_name, num_rids); - if (!enumdomains(&doms, &num_entries)) + for (i = 0; i < num_rids && status == 0; i++) { - r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; - } + struct sam_passwd *sam_pass; + fstring user_name; - if (r_e.status == 0x0) - { - make_samr_r_enum_domains(&r_e, - q_u->start_idx + num_entries, - num_entries, doms, r_e.status); - } - /* store the response in the SMB stream */ - samr_io_r_enum_domains("", &r_e, rdata, 0); + fstrcpy(user_name, unistrn2(q_u->uni_user_name[i].buffer, + q_u->uni_user_name[i].uni_str_len)); - free_char_array(num_entries, doms); + /* find the user account */ + become_root(True); + sam_pass = get_smb21pwd_entry(user_name, 0); + unbecome_root(True); - if (r_e.sam != NULL) - { - free(r_e.sam); + if (sam_pass == NULL) + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + rid[i] = 0; + } + else + { + rid[i] = sam_pass->user_rid; + } } +#endif - if (r_e.uni_dom_name != NULL) - { - free(r_e.uni_dom_name); - } + num_rids = 1; + rid[0] = BUILTIN_ALIAS_RID_USERS; + + init_samr_r_lookup_ids(&r_u, num_rids, rid, status); + + /* store the response in the SMB stream */ + samr_io_r_lookup_ids("", &r_u, rdata, 0); + + DEBUG(5,("samr_lookup_ids: %d\n", __LINE__)); - DEBUG(5,("samr_enum_domains: %d\n", __LINE__)); } /******************************************************************* - api_samr_enum_domains + api_samr_lookup_ids ********************************************************************/ -static void api_samr_enum_domains( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_lookup_ids( uint16 vuid, prs_struct *data, prs_struct *rdata) { - SAMR_Q_ENUM_DOMAINS q_e; + SAMR_Q_LOOKUP_IDS q_u; - /* grab the samr open */ - samr_io_q_enum_domains("", &q_e, data, 0); + /* grab the samr 0x10 */ + samr_io_q_lookup_ids("", &q_u, data, 0); - /* construct reply. */ - samr_reply_enum_domains(&q_e, rdata); + /* construct reply. always indicate success */ + samr_reply_lookup_ids(&q_u, rdata); + + return True; } /******************************************************************* - samr_reply_enum_dom_groups + samr_reply_lookup_names ********************************************************************/ -static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, + +static BOOL samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, prs_struct *rdata) { - SAMR_R_ENUM_DOM_GROUPS r_e; - DOMAIN_GRP *grps = NULL; - int num_entries = 0; - DOM_SID sid; - fstring sid_str; - - r_e.status = 0x0; - r_e.num_entries2 = 0; - - /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && !get_policy_samr_sid(&q_u->pol, &sid)) - { - r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } + uint32 rid[MAX_SAM_ENTRIES]; + uint8 type[MAX_SAM_ENTRIES]; + uint32 status = 0; + int i; + int num_rids = q_u->num_names1; + DOM_SID pol_sid; - sid_to_string(sid_str, &sid); + SAMR_R_LOOKUP_NAMES r_u; - DEBUG(5,("samr_reply_enum_dom_groups: sid %s\n", sid_str)); + DEBUG(5,("samr_lookup_names: %d\n", __LINE__)); - if (sid_equal(&sid, &global_sam_sid)) - { - BOOL ret; + ZERO_ARRAY(rid); + ZERO_ARRAY(type); - become_root(True); - ret = enumdomgroups(&grps, &num_entries); - unbecome_root(True); - if (!ret) - { - r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; + if (!get_lsa_policy_samr_sid(&q_u->pol, &pol_sid)) { + status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; + init_samr_r_lookup_names(&r_u, 0, rid, type, status); + if(!samr_io_r_lookup_names("", &r_u, rdata, 0)) { + DEBUG(0,("samr_reply_lookup_names: failed to marshall SAMR_R_LOOKUP_NAMES.\n")); + return False; } - } + return True; + } - if (r_e.status == 0x0) - { - make_samr_r_enum_dom_groups(&r_e, - q_u->start_idx + num_entries, - num_entries, grps, r_e.status); + if (num_rids > MAX_SAM_ENTRIES) { + num_rids = MAX_SAM_ENTRIES; + DEBUG(5,("samr_lookup_names: truncating entries to %d\n", num_rids)); } - /* store the response in the SMB stream */ - samr_io_r_enum_dom_groups("", &r_e, rdata, 0); + SMB_ASSERT_ARRAY(q_u->uni_name, num_rids); - if (grps != NULL) - { - free(grps); - } - - if (r_e.sam != NULL) - { - free(r_e.sam); - } - - if (r_e.uni_grp_name != NULL) - { - free(r_e.uni_grp_name); - } - - DEBUG(5,("samr_enum_dom_groups: %d\n", __LINE__)); -} - -/******************************************************************* - api_samr_enum_dom_groups - ********************************************************************/ -static void api_samr_enum_dom_groups( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_ENUM_DOM_GROUPS q_e; - - /* grab the samr open */ - samr_io_q_enum_dom_groups("", &q_e, data, 0); - - /* construct reply. */ - samr_reply_enum_dom_groups(&q_e, rdata); -} - - -/******************************************************************* - samr_reply_enum_dom_aliases - ********************************************************************/ -static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, - prs_struct *rdata) -{ - SAMR_R_ENUM_DOM_ALIASES r_e; - LOCAL_GRP *alss = NULL; - int num_entries = 0; - DOM_SID sid; - fstring sid_str; - - r_e.status = 0x0; - r_e.num_entries2 = 0; - - /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && !get_policy_samr_sid(&q_u->pol, &sid)) - { - r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - - sid_to_string(sid_str, &sid); - - DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", sid_str)); - - /* well-known aliases */ - if (sid_equal(&sid, &global_sid_S_1_5_20)) - { - BOOL ret; - /* builtin aliases */ - - become_root(True); - ret = enumdombuiltins(&alss, &num_entries); - unbecome_root(True); - if (!ret) - { - r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; - } - } - else if (sid_equal(&sid, &global_sam_sid)) - { - BOOL ret; - /* local aliases */ - - become_root(True); - ret = enumdomaliases(&alss, &num_entries); - unbecome_root(True); - if (!ret) - { - r_e.status = 0xC0000000 | NT_STATUS_NO_MEMORY; - } - } - - if (r_e.status == 0x0) - { - make_samr_r_enum_dom_aliases(&r_e, - q_u->start_idx + num_entries, - num_entries, alss, r_e.status); - } - - /* store the response in the SMB stream */ - samr_io_r_enum_dom_aliases("", &r_e, rdata, 0); - - if (alss != NULL) - { - free(alss); - } - - if (r_e.sam != NULL) - { - free(r_e.sam); - } - - if (r_e.uni_grp_name != NULL) - { - free(r_e.uni_grp_name); - } - - DEBUG(5,("samr_enum_dom_aliases: %d\n", __LINE__)); - -} - -/******************************************************************* - api_samr_enum_dom_aliases - ********************************************************************/ -static void api_samr_enum_dom_aliases( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_ENUM_DOM_ALIASES q_e; - - /* grab the samr open */ - samr_io_q_enum_dom_aliases("", &q_e, data, 0); - - /* construct reply. */ - samr_reply_enum_dom_aliases(&q_e, rdata); -} - - -/******************************************************************* - samr_reply_query_dispinfo - ********************************************************************/ -static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, - prs_struct *rdata) -{ - SAMR_R_QUERY_DISPINFO r_e; - SAM_DISPINFO_CTR ctr; - SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; - DOMAIN_GRP *grps = NULL; - DOMAIN_GRP *sam_grps = NULL; - uint32 data_size = 0; - uint32 status = 0x0; - uint16 acb_mask = ACB_NORMAL; - int num_sam_entries = 0; - int num_entries = 0; - int total_entries; - - DEBUG(5,("samr_reply_query_dispinfo: %d\n", __LINE__)); - - /* find the policy handle. open a policy on it. */ - if (find_policy_by_hnd(&(q_u->domain_pol)) == -1) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - DEBUG(5,("samr_reply_query_dispinfo: invalid handle\n")); - } - - if (status == 0x0) - { - become_root(True); - - /* Get what we need from the password database */ - switch (q_u->switch_level) - { - case 0x2: - { - acb_mask = ACB_WSTRUST; - /* Fall through */ - } - case 0x1: - case 0x4: - { - get_sampwd_entries(pass, q_u->start_idx, - &total_entries, &num_sam_entries, - MAX_SAM_ENTRIES, acb_mask); - break; - } - case 0x3: - case 0x5: - { - enumdomgroups(&sam_grps, &num_sam_entries); - - if (q_u->start_idx < num_sam_entries) { - grps = sam_grps + q_u->start_idx; - num_sam_entries -= q_u->start_idx; - } else { - num_sam_entries = 0; - } - break; - } - } - - unbecome_root(True); - - num_entries = num_sam_entries; - - if (num_entries > q_u->max_entries) - { - num_entries = q_u->max_entries; - } - - if (num_entries > MAX_SAM_ENTRIES) - { - num_entries = MAX_SAM_ENTRIES; - DEBUG(5,("limiting number of entries to %d\n", - num_entries)); - } - - data_size = q_u->max_size; - - /* Now create reply structure */ - switch (q_u->switch_level) - { - case 0x1: - { - ctr.sam.info1 = malloc(sizeof(SAM_DISPINFO_1)); - make_sam_dispinfo_1(ctr.sam.info1, - &num_entries, &data_size, - q_u->start_idx, pass); - break; - } - case 0x2: - { - ctr.sam.info2 = malloc(sizeof(SAM_DISPINFO_2)); - make_sam_dispinfo_2(ctr.sam.info2, - &num_entries, &data_size, - q_u->start_idx, pass); - break; - } - case 0x3: - { - ctr.sam.info3 = malloc(sizeof(SAM_DISPINFO_3)); - make_sam_dispinfo_3(ctr.sam.info3, - &num_entries, &data_size, - q_u->start_idx, grps); - break; - } - case 0x4: - { - ctr.sam.info4 = malloc(sizeof(SAM_DISPINFO_4)); - make_sam_dispinfo_4(ctr.sam.info4, - &num_entries, &data_size, - q_u->start_idx, pass); - break; - } - case 0x5: - { - ctr.sam.info5 = malloc(sizeof(SAM_DISPINFO_5)); - make_sam_dispinfo_5(ctr.sam.info5, - &num_entries, &data_size, - q_u->start_idx, grps); - break; - } - default: - { - ctr.sam.info = NULL; - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; - break; - } - } - } - - if ((status == 0) && (num_entries < num_sam_entries)) - { - status = STATUS_MORE_ENTRIES; - } - - make_samr_r_query_dispinfo(&r_e, num_entries, data_size, - q_u->switch_level, &ctr, status); - - /* store the response in the SMB stream */ - samr_io_r_query_dispinfo("", &r_e, rdata, 0); - - /* free malloc'd areas */ - if (sam_grps != NULL) - { - free(sam_grps); - } - - if (ctr.sam.info != NULL) - { - free(ctr.sam.info); - } - - DEBUG(5,("samr_reply_query_dispinfo: %d\n", __LINE__)); -} - -/******************************************************************* - api_samr_query_dispinfo - ********************************************************************/ -static void api_samr_query_dispinfo( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_QUERY_DISPINFO q_e; - - samr_io_q_query_dispinfo("", &q_e, data, 0); - samr_reply_query_dispinfo(&q_e, rdata); -} - -/******************************************************************* - samr_reply_delete_dom_group - ********************************************************************/ -static void samr_reply_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP *q_u, - prs_struct *rdata) -{ - uint32 status = 0; - - DOM_SID group_sid; - uint32 group_rid; - fstring group_sid_str; - - SAMR_R_DELETE_DOM_GROUP r_u; - - DEBUG(5,("samr_delete_dom_group: %d\n", __LINE__)); - - /* find the policy handle. open a policy on it. */ - if (status == 0x0 && !get_policy_samr_sid(&q_u->group_pol, &group_sid)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - else - { - sid_to_string(group_sid_str, &group_sid ); - sid_split_rid(&group_sid, &group_rid); - } - - if (status == 0x0) - { - DEBUG(10,("sid is %s\n", group_sid_str)); - - if (sid_equal(&group_sid, &global_sam_sid)) - { - DEBUG(10,("lookup on Domain SID\n")); - - become_root(True); - status = del_group_entry(group_rid) ? 0x0 : (0xC0000000 | NT_STATUS_NO_SUCH_GROUP); - unbecome_root(True); - } - else - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; - } - } - - make_samr_r_delete_dom_group(&r_u, status); - - /* store the response in the SMB stream */ - samr_io_r_delete_dom_group("", &r_u, rdata, 0); -} - -/******************************************************************* - api_samr_delete_dom_group - ********************************************************************/ -static void api_samr_delete_dom_group( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_DELETE_DOM_GROUP q_u; - samr_io_q_delete_dom_group("", &q_u, data, 0); - samr_reply_delete_dom_group(&q_u, rdata); -} - - -/******************************************************************* - samr_reply_query_groupmem - ********************************************************************/ -static void samr_reply_query_groupmem(SAMR_Q_QUERY_GROUPMEM *q_u, - prs_struct *rdata) -{ - uint32 status = 0; - - DOMAIN_GRP_MEMBER *mem_grp = NULL; - uint32 *rid = NULL; - uint32 *attr = NULL; - int num_rids = 0; - DOM_SID group_sid; - uint32 group_rid; - fstring group_sid_str; - - SAMR_R_QUERY_GROUPMEM r_u; - - DEBUG(5,("samr_query_groupmem: %d\n", __LINE__)); - - /* find the policy handle. open a policy on it. */ - if (status == 0x0 && !get_policy_samr_sid(&q_u->group_pol, &group_sid)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - else - { - sid_to_string(group_sid_str, &group_sid ); - sid_split_rid(&group_sid, &group_rid); - } - - if (status == 0x0) - { - DEBUG(10,("sid is %s\n", group_sid_str)); - - if (sid_equal(&group_sid, &global_sam_sid)) - { - DEBUG(10,("lookup on Domain SID\n")); - - become_root(True); - status = getgrouprid(group_rid, &mem_grp, &num_rids) != NULL ? 0x0 : (0xC0000000 | NT_STATUS_NO_SUCH_GROUP); - unbecome_root(True); - } - else - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_GROUP; - } - } - - if (status == 0x0 && num_rids > 0) - { - rid = malloc(num_rids * sizeof(uint32)); - attr = malloc(num_rids * sizeof(uint32)); - if (mem_grp != NULL && rid != NULL && attr != NULL) - { - int i; - for (i = 0; i < num_rids; i++) - { - rid [i] = mem_grp[i].rid; - attr[i] = mem_grp[i].attr; - } - free(mem_grp); - } - } - - make_samr_r_query_groupmem(&r_u, num_rids, rid, attr, status); - - /* store the response in the SMB stream */ - samr_io_r_query_groupmem("", &r_u, rdata, 0); - - if (rid != NULL) - { - free(rid); - } - - if (attr != NULL) - { - free(attr); - } - - DEBUG(5,("samr_query_groupmem: %d\n", __LINE__)); - -} - -/******************************************************************* - api_samr_query_groupmem - ********************************************************************/ -static void api_samr_query_groupmem( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_QUERY_GROUPMEM q_u; - samr_io_q_query_groupmem("", &q_u, data, 0); - samr_reply_query_groupmem(&q_u, rdata); -} - - -/******************************************************************* - samr_reply_query_groupinfo - ********************************************************************/ -static void samr_reply_query_groupinfo(SAMR_Q_QUERY_GROUPINFO *q_u, - prs_struct *rdata) -{ - SAMR_R_QUERY_GROUPINFO r_e; - GROUP_INFO_CTR ctr; - uint32 status = 0x0; - - r_e.ptr = 0; - - /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) - { - r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - - DEBUG(5,("samr_reply_query_groupinfo: %d\n", __LINE__)); - - if (status == 0x0) - { - if (q_u->switch_level == 1) - { - r_e.ptr = 1; - ctr.switch_value1 = 1; - make_samr_group_info1(&ctr.group.info1, - "fake account name", - "fake account description", 2); - } - else if (q_u->switch_level == 4) - { - r_e.ptr = 1; - ctr.switch_value1 = 4; - make_samr_group_info4(&ctr.group.info4, - "fake account description"); - } - else - { - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; - } - } - - make_samr_r_query_groupinfo(&r_e, status == 0 ? &ctr : NULL, status); - - /* store the response in the SMB stream */ - samr_io_r_query_groupinfo("", &r_e, rdata, 0); - - DEBUG(5,("samr_query_groupinfo: %d\n", __LINE__)); - -} - -/******************************************************************* - api_samr_query_groupinfo - ********************************************************************/ -static void api_samr_query_groupinfo( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_QUERY_GROUPINFO q_e; - samr_io_q_query_groupinfo("", &q_e, data, 0); - samr_reply_query_groupinfo(&q_e, rdata); -} - - -/******************************************************************* - samr_reply_query_aliasinfo - ********************************************************************/ -static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, - prs_struct *rdata) -{ - SAMR_R_QUERY_ALIASINFO r_e; - ALIAS_INFO_CTR ctr; - uint32 status = 0x0; - - r_e.ptr = 0; - - /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) - { - r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - - DEBUG(5,("samr_reply_query_aliasinfo: %d\n", __LINE__)); - - if (status == 0x0) - { - if (q_u->switch_level == 3) - { - r_e.ptr = 1; - ctr.switch_value1 = 3; - make_samr_alias_info3(&ctr.alias.info3, ""); - } - else - { - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; - } - } - - make_samr_r_query_aliasinfo(&r_e, status == 0 ? &ctr : NULL, status); - - /* store the response in the SMB stream */ - samr_io_r_query_aliasinfo("", &r_e, rdata, 0); - - DEBUG(5,("samr_query_aliasinfo: %d\n", __LINE__)); - -} - -/******************************************************************* - api_samr_query_aliasinfo - ********************************************************************/ -static void api_samr_query_aliasinfo( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_QUERY_ALIASINFO q_e; - samr_io_q_query_aliasinfo("", &q_e, data, 0); - samr_reply_query_aliasinfo(&q_e, rdata); -} - - -/******************************************************************* - samr_reply_query_useraliases - ********************************************************************/ -static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u, - prs_struct *rdata) -{ - uint32 status = 0; - - LOCAL_GRP *mem_grp = NULL; - uint32 *rid = NULL; - int num_rids = 0; - struct sam_passwd *sam_pass; - DOM_SID usr_sid; - DOM_SID dom_sid; - uint32 user_rid; - fstring sam_sid_str; - fstring dom_sid_str; - fstring usr_sid_str; - - SAMR_R_QUERY_USERALIASES r_u; - ZERO_STRUCT(r_u); - - DEBUG(5,("samr_query_useraliases: %d\n", __LINE__)); - - /* find the policy handle. open a policy on it. */ - if (status == 0x0 && !get_policy_samr_sid(&q_u->pol, &dom_sid)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - else - { - sid_to_string(dom_sid_str, &dom_sid ); - sid_to_string(sam_sid_str, &global_sam_sid); - } - - if (status == 0x0) - { - usr_sid = q_u->sid[0].sid; - sid_split_rid(&usr_sid, &user_rid); - sid_to_string(usr_sid_str, &usr_sid); - - } - - if (status == 0x0) - { - /* find the user account */ - become_root(True); - sam_pass = getsam21pwrid(user_rid); - unbecome_root(True); - - if (sam_pass == NULL) - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - num_rids = 0; - } - } - - if (status == 0x0) - { - DEBUG(10,("sid is %s\n", dom_sid_str)); - - if (sid_equal(&dom_sid, &global_sid_S_1_5_20)) - { - DEBUG(10,("lookup on S-1-5-20\n")); - - become_root(True); - getuserbuiltinntnam(sam_pass->nt_name, &mem_grp, &num_rids); - unbecome_root(True); - } - else if (sid_equal(&dom_sid, &usr_sid)) - { - DEBUG(10,("lookup on Domain SID\n")); - - become_root(True); - getuseraliasntnam(sam_pass->nt_name, &mem_grp, &num_rids); - unbecome_root(True); - } - else - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - } - } - - if (status == 0x0 && num_rids > 0) - { - rid = malloc(num_rids * sizeof(uint32)); - if (mem_grp != NULL && rid != NULL) - { - int i; - for (i = 0; i < num_rids; i++) - { - rid[i] = mem_grp[i].rid; - } - free(mem_grp); - } - } - - make_samr_r_query_useraliases(&r_u, num_rids, rid, status); - - /* store the response in the SMB stream */ - samr_io_r_query_useraliases("", &r_u, rdata, 0); - - if (rid != NULL) - { - free(rid); - } - - DEBUG(5,("samr_query_useraliases: %d\n", __LINE__)); - -} - -/******************************************************************* - api_samr_query_useraliases - ********************************************************************/ -static void api_samr_query_useraliases( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_QUERY_USERALIASES q_u; - ZERO_STRUCT(q_u); - samr_io_q_query_useraliases("", &q_u, data, 0); - samr_reply_query_useraliases(&q_u, rdata); - samr_free_q_query_useraliases(&q_u); -} - -/******************************************************************* - samr_reply_delete_dom_alias - ********************************************************************/ -static void samr_reply_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS *q_u, - prs_struct *rdata) -{ - uint32 status = 0; - - DOM_SID alias_sid; - uint32 alias_rid; - fstring alias_sid_str; - - SAMR_R_DELETE_DOM_ALIAS r_u; - - DEBUG(5,("samr_delete_dom_alias: %d\n", __LINE__)); - - /* find the policy handle. open a policy on it. */ - if (status == 0x0 && !get_policy_samr_sid(&q_u->alias_pol, &alias_sid)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - else - { - sid_to_string(alias_sid_str, &alias_sid ); - sid_split_rid(&alias_sid, &alias_rid); - } - - if (status == 0x0) - { - DEBUG(10,("sid is %s\n", alias_sid_str)); - - if (sid_equal(&alias_sid, &global_sam_sid)) - { - DEBUG(10,("lookup on Domain SID\n")); - - become_root(True); - status = del_alias_entry(alias_rid) ? 0x0 : (0xC0000000 | NT_STATUS_NO_SUCH_ALIAS); - unbecome_root(True); - } - else - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; - } - } - - make_samr_r_delete_dom_alias(&r_u, status); - - /* store the response in the SMB stream */ - samr_io_r_delete_dom_alias("", &r_u, rdata, 0); -} - -/******************************************************************* - api_samr_delete_dom_alias - ********************************************************************/ -static void api_samr_delete_dom_alias( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_DELETE_DOM_ALIAS q_u; - samr_io_q_delete_dom_alias("", &q_u, data, 0); - samr_reply_delete_dom_alias(&q_u, rdata); -} - - -/******************************************************************* - samr_reply_query_aliasmem - ********************************************************************/ -static void samr_reply_query_aliasmem(SAMR_Q_QUERY_ALIASMEM *q_u, - prs_struct *rdata) -{ - uint32 status = 0; - - LOCAL_GRP_MEMBER *mem_grp = NULL; - DOM_SID2 *sid = NULL; - int num_sids = 0; - DOM_SID alias_sid; - uint32 alias_rid; - fstring alias_sid_str; - - SAMR_R_QUERY_ALIASMEM r_u; - - DEBUG(5,("samr_query_aliasmem: %d\n", __LINE__)); - - /* find the policy handle. open a policy on it. */ - if (status == 0x0 && !get_policy_samr_sid(&q_u->alias_pol, &alias_sid)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - else - { - sid_to_string(alias_sid_str, &alias_sid ); - sid_split_rid(&alias_sid, &alias_rid); - } - - if (status == 0x0) - { - DEBUG(10,("sid is %s\n", alias_sid_str)); - - if (sid_equal(&alias_sid, &global_sid_S_1_5_20)) - { - DEBUG(10,("lookup on S-1-5-20\n")); - - become_root(True); - status = getbuiltinrid(alias_rid, &mem_grp, &num_sids) != NULL ? 0x0 : 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; - unbecome_root(True); - } - else if (sid_equal(&alias_sid, &global_sam_sid)) - { - DEBUG(10,("lookup on Domain SID\n")); - - become_root(True); - status = getaliasrid(alias_rid, &mem_grp, &num_sids) != NULL ? 0x0 : 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; - unbecome_root(True); - } - else - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; - } - } - - if (status == 0x0 && num_sids > 0) - { - sid = malloc(num_sids * sizeof(DOM_SID)); - if (mem_grp != NULL && sid != NULL) - { - int i; - for (i = 0; i < num_sids; i++) - { - make_dom_sid2(&sid[i], &mem_grp[i].sid); - } - free(mem_grp); - } - } - - make_samr_r_query_aliasmem(&r_u, num_sids, sid, status); - - /* store the response in the SMB stream */ - samr_io_r_query_aliasmem("", &r_u, rdata, 0); - - if (sid != NULL) - { - free(sid); - } - - DEBUG(5,("samr_query_aliasmem: %d\n", __LINE__)); - -} - -/******************************************************************* - api_samr_query_aliasmem - ********************************************************************/ -static void api_samr_query_aliasmem( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_QUERY_ALIASMEM q_u; - samr_io_q_query_aliasmem("", &q_u, data, 0); - samr_reply_query_aliasmem(&q_u, rdata); -} - -/******************************************************************* - samr_reply_lookup_names - ********************************************************************/ -static void samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, - prs_struct *rdata) -{ - uint32 rid [MAX_SAM_ENTRIES]; - uint8 type[MAX_SAM_ENTRIES]; - uint32 status = 0; - int i; - int num_rids = q_u->num_names1; - DOM_SID pol_sid; - - SAMR_R_LOOKUP_NAMES r_u; - - DEBUG(5,("samr_lookup_names: %d\n", __LINE__)); - - if (status == 0x0 && !get_policy_samr_sid(&q_u->pol, &pol_sid)) - { - status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; - } - - if (num_rids > MAX_SAM_ENTRIES) - { - num_rids = MAX_SAM_ENTRIES; - DEBUG(5,("samr_lookup_names: truncating entries to %d\n", num_rids)); - } - - SMB_ASSERT_ARRAY(q_u->uni_name, num_rids); - - for (i = 0; i < num_rids && status == 0; i++) - { - DOM_SID sid; - fstring name; - unistr2_to_ascii(name, &q_u->uni_name[i], sizeof(name)-1); - - status = lookup_name(name, &sid, &(type[i])); - if (status == 0x0) - { - sid_split_rid(&sid, &rid[i]); - } - else - { - type[i] = SID_NAME_UNKNOWN; - rid [i] = 0xffffffff; - } - if (!sid_equal(&pol_sid, &sid)) - { - rid [i] = 0xffffffff; - type[i] = SID_NAME_UNKNOWN; - } - } - - make_samr_r_lookup_names(&r_u, num_rids, rid, type, status); - - /* store the response in the SMB stream */ - samr_io_r_lookup_names("", &r_u, rdata, 0); - - DEBUG(5,("samr_lookup_names: %d\n", __LINE__)); - -} - -/******************************************************************* - api_samr_lookup_names - ********************************************************************/ -static void api_samr_lookup_names( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_LOOKUP_NAMES q_u; - samr_io_q_lookup_names("", &q_u, data, 0); - samr_reply_lookup_names(&q_u, rdata); -} - -/******************************************************************* - samr_reply_chgpasswd_user - ********************************************************************/ -static void samr_reply_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u, - prs_struct *rdata) -{ - SAMR_R_CHGPASSWD_USER r_u; - uint32 status = 0x0; - fstring user_name; - fstring wks; - - unistr2_to_ascii(user_name, &q_u->uni_user_name, sizeof(user_name)-1); - unistr2_to_ascii(wks, &q_u->uni_dest_host, sizeof(wks)-1); - - DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); - - if (!pass_oem_change(user_name, - q_u->lm_newpass.pass, q_u->lm_oldhash.hash, - q_u->nt_newpass.pass, q_u->nt_oldhash.hash)) - { - status = 0xC0000000 | NT_STATUS_WRONG_PASSWORD; - } - - make_samr_r_chgpasswd_user(&r_u, status); - - /* store the response in the SMB stream */ - samr_io_r_chgpasswd_user("", &r_u, rdata, 0); - - DEBUG(5,("samr_chgpasswd_user: %d\n", __LINE__)); -} - -/******************************************************************* - api_samr_chgpasswd_user - ********************************************************************/ -static void api_samr_chgpasswd_user( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_CHGPASSWD_USER q_u; - samr_io_q_chgpasswd_user("", &q_u, data, 0); - samr_reply_chgpasswd_user(&q_u, rdata); -} - - -/******************************************************************* - samr_reply_unknown_38 - ********************************************************************/ -static void samr_reply_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, - prs_struct *rdata) -{ - SAMR_R_UNKNOWN_38 r_u; - - DEBUG(5,("samr_unknown_38: %d\n", __LINE__)); - - make_samr_r_unknown_38(&r_u); - - /* store the response in the SMB stream */ - samr_io_r_unknown_38("", &r_u, rdata, 0); - - DEBUG(5,("samr_unknown_38: %d\n", __LINE__)); -} - -/******************************************************************* - api_samr_unknown_38 - ********************************************************************/ -static void api_samr_unknown_38( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_UNKNOWN_38 q_u; - samr_io_q_unknown_38("", &q_u, data, 0); - samr_reply_unknown_38(&q_u, rdata); -} - - -/******************************************************************* - samr_reply_lookup_rids - ********************************************************************/ -static void samr_reply_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u, - prs_struct *rdata) -{ - fstring group_names[MAX_SAM_ENTRIES]; - uint8 group_attrs[MAX_SAM_ENTRIES]; - uint32 status = 0; - int num_rids = q_u->num_rids1; - DOM_SID pol_sid; - - SAMR_R_LOOKUP_RIDS r_u; - ZERO_STRUCT(r_u); - - DEBUG(5,("samr_lookup_rids: %d\n", __LINE__)); - - /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - - if (status == 0x0 && !get_policy_samr_sid(&q_u->pol, &pol_sid)) - { - status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; - } - - if (status == 0x0) - { - int i; - if (num_rids > MAX_SAM_ENTRIES) - { - num_rids = MAX_SAM_ENTRIES; - DEBUG(5,("samr_lookup_rids: truncating entries to %d\n", num_rids)); - } - - for (i = 0; i < num_rids && status == 0; i++) - { - DOM_SID sid; - sid_copy(&sid, &pol_sid); - sid_append_rid(&sid, q_u->rid[i]); - lookup_sid(&sid, group_names[i], &group_attrs[i]); - } - } - - make_samr_r_lookup_rids(&r_u, num_rids, group_names, group_attrs, status); - - /* store the response in the SMB stream */ - samr_io_r_lookup_rids("", &r_u, rdata, 0); - - DEBUG(5,("samr_lookup_rids: %d\n", __LINE__)); - -} - -/******************************************************************* - api_samr_lookup_rids - ********************************************************************/ -static void api_samr_lookup_rids( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_LOOKUP_RIDS q_u; - ZERO_STRUCT(q_u); - samr_io_q_lookup_rids("", &q_u, data, 0); - samr_reply_lookup_rids(&q_u, rdata); - samr_free_q_lookup_rids(&q_u); -} - - -/******************************************************************* - samr_reply_open_user - ********************************************************************/ -static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, - prs_struct *rdata, - int status) -{ - SAMR_R_OPEN_USER r_u; - struct sam_passwd *sam_pass; - BOOL pol_open = False; - - /* set up the SAMR open_user response */ - bzero(r_u.user_pol.data, POL_HND_SIZE); - - r_u.status = 0x0; - - /* find the policy handle. open a policy on it. */ - if (r_u.status == 0x0 && (find_policy_by_hnd(&(q_u->domain_pol)) == -1)) - { - r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } + for (i = 0; i < num_rids; i++) { + fstring name; - /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_policy_hnd(&(r_u.user_pol)))) - { - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } + status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - become_root(True); - sam_pass = getsam21pwrid(q_u->user_rid); - unbecome_root(True); + rid [i] = 0xffffffff; + type[i] = SID_NAME_UNKNOWN; - /* check that the RID exists in our domain. */ - if (r_u.status == 0x0 && sam_pass == NULL) - { - r_u.status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - } + fstrcpy(name, dos_unistrn2(q_u->uni_name[i].buffer, + q_u->uni_name[i].uni_str_len)); - /* associate the RID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_policy_samr_rid(&(r_u.user_pol), q_u->user_rid)) - { - /* oh, whoops. don't know what error message to return, here */ - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } + if(sid_equal(&pol_sid, &global_sam_sid)) { + DOM_SID sid; - if (r_u.status != 0 && pol_open) - { - close_policy_hnd(&(r_u.user_pol)); + if(lookup_local_name(global_myname, name, &sid, &type[i])) { + sid_split_rid( &sid, &rid[i]); + status = 0; + } + } } - DEBUG(5,("samr_open_user: %d\n", __LINE__)); + init_samr_r_lookup_names(&r_u, num_rids, rid, type, status); /* store the response in the SMB stream */ - samr_io_r_open_user("", &r_u, rdata, 0); + if(!samr_io_r_lookup_names("", &r_u, rdata, 0)) { + DEBUG(0,("samr_reply_lookup_names: failed to marshall SAMR_R_LOOKUP_NAMES.\n")); + return False; + } - DEBUG(5,("samr_open_user: %d\n", __LINE__)); + DEBUG(5,("samr_lookup_names: %d\n", __LINE__)); + return True; } /******************************************************************* - api_samr_open_user + api_samr_lookup_names ********************************************************************/ -static void api_samr_open_user( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_OPEN_USER q_u; - samr_io_q_open_user("", &q_u, data, 0); - samr_reply_open_user(&q_u, rdata, 0x0); -} - -/************************************************************************* - get_user_info_10 - *************************************************************************/ -static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) +static BOOL api_samr_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rdata) { - struct sam_passwd *sam_pass; + SAMR_Q_LOOKUP_NAMES q_u; - become_root(True); - sam_pass = getsam21pwrid(user_rid); - unbecome_root(True); + memset(&q_u, '\0', sizeof(q_u)); - if (sam_pass == NULL) - { - DEBUG(4,("User 0x%x not found\n", user_rid)); + /* grab the samr lookup names */ + if(!samr_io_q_lookup_names("", &q_u, data, 0)) { + DEBUG(0,("api_samr_lookup_names: failed to unmarshall SAMR_Q_LOOKUP_NAMES.\n")); return False; } - DEBUG(3,("User:[%s]\n", sam_pass->nt_name)); - - make_sam_user_info10(id10, sam_pass->acct_ctrl); - - return True; -} - -/************************************************************************* - get_user_info_21 - *************************************************************************/ -static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) -{ - struct sam_passwd *sam_pass; - LOGON_HRS hrs; - int i; - - become_root(True); - sam_pass = getsam21pwrid(user_rid); - unbecome_root(True); - - if (sam_pass == NULL) - { - DEBUG(4,("User 0x%x not found\n", user_rid)); + /* construct reply. always indicate success */ + if(!samr_reply_lookup_names(&q_u, rdata)) return False; - } - - DEBUG(3,("User:[%s]\n", sam_pass->nt_name)); - - /* 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]; - } - - make_sam_user_info21(id21, - - &sam_pass->logon_time, - &sam_pass->logoff_time, - &sam_pass->kickoff_time, - &sam_pass->pass_last_set_time, - &sam_pass->pass_can_change_time, - &sam_pass->pass_must_change_time, - - sam_pass->nt_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 */ - - sam_pass->user_rid, /* RID user_id */ - sam_pass->group_rid, /* RID group_id */ - sam_pass->acct_ctrl, - - sam_pass->unknown_3, /* unknown_3 */ - sam_pass->logon_divs, /* divisions per week */ - &hrs, /* logon hours */ - sam_pass->unknown_5, - sam_pass->unknown_6); return True; } /******************************************************************* - samr_reply_query_userinfo + samr_reply_chgpasswd_user ********************************************************************/ -static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, + +static BOOL samr_reply_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u, prs_struct *rdata) { - SAMR_R_QUERY_USERINFO r_u; -#if 0 - SAM_USER_INFO_11 id11; -#endif - SAM_USER_INFO_10 id10; - SAM_USER_INFO_21 id21; - void *info = NULL; - + SAMR_R_CHGPASSWD_USER r_u; uint32 status = 0x0; - uint32 rid = 0x0; - - DEBUG(5,("samr_reply_query_userinfo: %d\n", __LINE__)); - - /* search for the handle */ - if (status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } + fstring user_name; + fstring wks; - /* find the user's rid */ - if (status == 0x0 && (rid = get_policy_samr_rid(&(q_u->pol))) == 0xffffffff) - { - status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; - } + 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)); - DEBUG(5,("samr_reply_query_userinfo: rid:0x%x\n", rid)); + DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); - /* ok! user info levels (there are lots: see MSDEV help), off we go... */ - if (status == 0x0) + if (!pass_oem_change(user_name, + q_u->lm_newpass.pass, q_u->lm_oldhash.hash, + q_u->nt_newpass.pass, q_u->nt_oldhash.hash)) { - switch (q_u->switch_value) - { - case 0x10: - { - info = (void*)&id10; - status = get_user_info_10(&id10, rid) ? 0 : (0xC0000000 | NT_STATUS_NO_SUCH_USER); - break; - } -#if 0 -/* whoops - got this wrong. i think. or don't understand what's happening. */ - case 0x11: - { - NTTIME expire; - info = (void*)&id11; - - expire.low = 0xffffffff; - expire.high = 0x7fffffff; - - make_sam_user_info11(&id11, &expire, "BROOKFIELDS$", 0x03ef, 0x201, 0x0080); - - break; - } -#endif - case 21: - { - info = (void*)&id21; - status = get_user_info_21(&id21, rid) ? 0 : (0xC0000000 | NT_STATUS_NO_SUCH_USER); - break; - } - - default: - { - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; - - break; - } - } + status = 0xC0000000 | NT_STATUS_WRONG_PASSWORD; } - make_samr_r_query_userinfo(&r_u, q_u->switch_value, info, status); + init_samr_r_chgpasswd_user(&r_u, status); /* store the response in the SMB stream */ - samr_io_r_query_userinfo("", &r_u, rdata, 0); - - DEBUG(5,("samr_reply_query_userinfo: %d\n", __LINE__)); - -} - -/******************************************************************* - set_user_info_24 - ********************************************************************/ -static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) -{ - struct sam_passwd *pwd = getsam21pwrid(rid); - struct sam_passwd new_pwd; - static uchar nt_hash[16]; - static uchar lm_hash[16]; - UNISTR2 new_pw; - uint32 len; - - if (pwd == NULL) - { + if(!samr_io_r_chgpasswd_user("", &r_u, rdata, 0)) { + DEBUG(0,("samr_reply_chgpasswd_user: Failed to marshall SAMR_R_CHGPASSWD_USER struct.\n" )); return False; } - pwdb_init_sam(&new_pwd); - copy_sam_passwd(&new_pwd, pwd); - - if (!decode_pw_buffer(id24->pass, (char *)new_pw.buffer, 256, &len)) - { - return False; - } - - new_pw.uni_max_len = len / 2; - new_pw.uni_str_len = len / 2; - - nt_lm_owf_genW(&new_pw, nt_hash, lm_hash); - - new_pwd.smb_passwd = lm_hash; - new_pwd.smb_nt_passwd = nt_hash; - - return mod_sam21pwd_entry(&new_pwd, True); + DEBUG(5,("samr_chgpasswd_user: %d\n", __LINE__)); + return True; } /******************************************************************* - set_user_info_23 + api_samr_chgpasswd_user ********************************************************************/ -static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) + +static BOOL api_samr_chgpasswd_user( uint16 vuid, prs_struct *data, prs_struct *rdata) { - struct sam_passwd *pwd = getsam21pwrid(rid); - struct sam_passwd new_pwd; - static uchar nt_hash[16]; - static uchar lm_hash[16]; - UNISTR2 new_pw; - uint32 len; - - if (id23 == NULL) - { - DEBUG(5, ("set_user_info_23: NULL id23\n")); - return False; - } - if (pwd == NULL) - { + SAMR_Q_CHGPASSWD_USER q_u; + + /* unknown 38 command */ + if (!samr_io_q_chgpasswd_user("", &q_u, data, 0)) { + DEBUG(0,("api_samr_chgpasswd_user: samr_io_q_chgpasswd_user failed to parse RPC packet.\n")); return False; } - pwdb_init_sam(&new_pwd); - copy_sam_passwd(&new_pwd, pwd); - copy_id23_to_sam_passwd(&new_pwd, id23); - - if (!decode_pw_buffer(id23->pass, (char*)new_pw.buffer, 256, &len)) - { + /* construct reply. */ + if(!samr_reply_chgpasswd_user(&q_u, rdata)) { + DEBUG(0,("api_samr_chgpasswd_user: samr_reply_chgpasswd_user failed to create reply packet.\n")); return False; } - new_pw.uni_max_len = len / 2; - new_pw.uni_str_len = len / 2; - - nt_lm_owf_genW(&new_pw, nt_hash, lm_hash); - - new_pwd.smb_passwd = lm_hash; - new_pwd.smb_nt_passwd = nt_hash; - - return mod_sam21pwd_entry(&new_pwd, True); + return True; } + /******************************************************************* - set_user_info_16 + samr_reply_unknown_38 ********************************************************************/ -static BOOL set_user_info_16(SAM_USER_INFO_16 *id16, uint32 rid) +static void samr_reply_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, + prs_struct *rdata) { - struct sam_passwd *pwd = getsam21pwrid(rid); - struct sam_passwd new_pwd; + SAMR_R_UNKNOWN_38 r_u; - if (id16 == NULL) - { - DEBUG(5, ("set_user_info_16: NULL id16\n")); - return False; - } - if (pwd == NULL) - { - return False; - } + DEBUG(5,("samr_unknown_38: %d\n", __LINE__)); - copy_sam_passwd(&new_pwd, pwd); + init_samr_r_unknown_38(&r_u); - new_pwd.acct_ctrl = id16->acb_info; + /* store the response in the SMB stream */ + samr_io_r_unknown_38("", &r_u, rdata, 0); - return mod_sam21pwd_entry(&new_pwd, True); + DEBUG(5,("samr_unknown_38: %d\n", __LINE__)); } /******************************************************************* - api_samr_query_userinfo + api_samr_unknown_38 ********************************************************************/ -static void api_samr_query_userinfo( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_38( uint16 vuid, prs_struct *data, prs_struct *rdata) { - SAMR_Q_QUERY_USERINFO q_u; - samr_io_q_query_userinfo("", &q_u, data, 0); - samr_reply_query_userinfo(&q_u, rdata); + SAMR_Q_UNKNOWN_38 q_u; + + /* unknown 38 command */ + samr_io_q_unknown_38("", &q_u, data, 0); + + /* construct reply. always indicate success */ + samr_reply_unknown_38(&q_u, rdata); + + return True; } /******************************************************************* - samr_reply_set_userinfo2 + samr_reply_unknown_12 ********************************************************************/ -static void samr_reply_set_userinfo2(SAMR_Q_SET_USERINFO2 *q_u, - prs_struct *rdata, uchar user_sess_key[16]) +static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, + prs_struct *rdata) { - SAMR_R_SET_USERINFO2 r_u; + fstring group_names[MAX_SAM_ENTRIES]; + uint32 group_attrs[MAX_SAM_ENTRIES]; + uint32 status = 0; + int num_gids = q_u->num_gids1; - uint32 status = 0x0; - uint32 rid = 0x0; + SAMR_R_UNKNOWN_12 r_u; - DEBUG(5,("samr_reply_set_userinfo2: %d\n", __LINE__)); + DEBUG(5,("samr_unknown_12: %d\n", __LINE__)); - /* search for the handle */ - if (status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) + /* find the policy handle. open a policy on it. */ + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } - /* find the user's rid */ - if (status == 0x0 && (rid = get_policy_samr_rid(&(q_u->pol))) == 0xffffffff) - { - status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; - } - - DEBUG(5,("samr_reply_set_userinfo2: rid:0x%x\n", rid)); - - /* ok! user info levels (there are lots: see MSDEV help), off we go... */ - if (status == 0x0 && q_u->info.id == NULL) - { - DEBUG(5,("samr_reply_set_userinfo2: NULL info level\n")); - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; - } - if (status == 0x0) { - switch (q_u->switch_value) + int i; + if (num_gids > MAX_SAM_ENTRIES) { - case 16: - { - SAM_USER_INFO_16 *id16 = q_u->info.id16; - status = set_user_info_16(id16, rid) ? 0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); - break; - } - default: - { - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + num_gids = MAX_SAM_ENTRIES; + DEBUG(5,("samr_unknown_12: truncating entries to %d\n", num_gids)); + } - break; - } + for (i = 0; i < num_gids && status == 0; i++) + { + fstrcpy(group_names[i], "dummy group"); + group_attrs[i] = 0x2; } } - make_samr_r_set_userinfo2(&r_u, status); + init_samr_r_unknown_12(&r_u, num_gids, group_names, group_attrs, status); /* store the response in the SMB stream */ - samr_io_r_set_userinfo2("", &r_u, rdata, 0); + samr_io_r_unknown_12("", &r_u, rdata, 0); - DEBUG(5,("samr_reply_set_userinfo2: %d\n", __LINE__)); + DEBUG(5,("samr_unknown_12: %d\n", __LINE__)); } /******************************************************************* - api_samr_set_userinfo2 + api_samr_unknown_12 ********************************************************************/ -static void api_samr_set_userinfo2( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_12( uint16 vuid, prs_struct *data, prs_struct *rdata) { - SAMR_Q_SET_USERINFO2 q_u; - ZERO_STRUCT(q_u); + SAMR_Q_UNKNOWN_12 q_u; - samr_io_q_set_userinfo2("", &q_u, data, 0); - samr_reply_set_userinfo2(&q_u, rdata, p->user_sess_key); + /* grab the samr lookup names */ + samr_io_q_unknown_12("", &q_u, data, 0); - if (q_u.info.id != NULL) - { - free(q_u.info.id); - } + /* construct reply. always indicate success */ + samr_reply_unknown_12(&q_u, rdata); + + return True; } /******************************************************************* - samr_reply_set_userinfo + samr_reply_open_user ********************************************************************/ -static void samr_reply_set_userinfo(SAMR_Q_SET_USERINFO *q_u, - prs_struct *rdata, uchar user_sess_key[16]) +static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, + prs_struct *rdata, + int status) { - SAMR_R_SET_USERINFO r_u; + SAMR_R_OPEN_USER r_u; + struct sam_passwd *sam_pass; + BOOL pol_open = False; - uint32 status = 0x0; - uint32 rid = 0x0; + /* set up the SAMR open_user response */ + memset((char *)r_u.user_pol.data, '\0', POL_HND_SIZE); - DEBUG(5,("samr_reply_set_userinfo: %d\n", __LINE__)); + r_u.status = 0x0; - /* search for the handle */ - if (status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) + /* find the policy handle. open a policy on it. */ + if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->domain_pol)) == -1)) { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } - /* find the user's rid */ - if (status == 0x0 && (rid = get_policy_samr_rid(&(q_u->pol))) == 0xffffffff) + /* get a (unique) handle. open a policy on it. */ + if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.user_pol)))) { - status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } - DEBUG(5,("samr_reply_set_userinfo: rid:0x%x\n", rid)); + become_root(True); + sam_pass = getsam21pwrid(q_u->user_rid); + unbecome_root(True); - /* ok! user info levels (there are lots: see MSDEV help), off we go... */ - if (status == 0x0 && q_u->info.id == NULL) + /* check that the RID exists in our domain. */ + if (r_u.status == 0x0 && sam_pass == NULL) { - DEBUG(5,("samr_reply_set_userinfo: NULL info level\n")); - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + r_u.status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; } - if (status == 0x0) + /* associate the RID with the (unique) handle. */ + if (r_u.status == 0x0 && !set_lsa_policy_samr_rid(&(r_u.user_pol), q_u->user_rid)) { - switch (q_u->switch_value) - { - case 24: - { - SAM_USER_INFO_24 *id24 = q_u->info.id24; - SamOEMhash(id24->pass, user_sess_key, True); - status = set_user_info_24(id24, rid) ? 0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); - break; - } - - case 23: - { - SAM_USER_INFO_23 *id23 = q_u->info.id23; - SamOEMhash(id23->pass, user_sess_key, 1); -#if DEBUG_PASSWORD - DEBUG(100,("pass buff:\n")); - dump_data(100, id23->pass, sizeof(id23->pass)); -#endif - dbgflush(); - - status = set_user_info_23(id23, rid) ? 0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); - break; - } - - default: - { - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + /* oh, whoops. don't know what error message to return, here */ + r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + } - break; - } - } + if (r_u.status != 0 && pol_open) + { + close_lsa_policy_hnd(&(r_u.user_pol)); } - make_samr_r_set_userinfo(&r_u, status); + DEBUG(5,("samr_open_user: %d\n", __LINE__)); /* store the response in the SMB stream */ - samr_io_r_set_userinfo("", &r_u, rdata, 0); + samr_io_r_open_user("", &r_u, rdata, 0); - DEBUG(5,("samr_reply_set_userinfo: %d\n", __LINE__)); + DEBUG(5,("samr_open_user: %d\n", __LINE__)); } /******************************************************************* - api_samr_set_userinfo + api_samr_open_user ********************************************************************/ -static void api_samr_set_userinfo( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_open_user( uint16 vuid, prs_struct *data, prs_struct *rdata) { - SAMR_Q_SET_USERINFO q_u; - ZERO_STRUCT(q_u); + SAMR_Q_OPEN_USER q_u; -#ifdef DEBUG_PASSWORD - DEBUG(100,("set user info: sess_key: ")); - dump_data(100, p->user_sess_key, 16); -#endif - samr_io_q_set_userinfo("", &q_u, data, 0); - samr_reply_set_userinfo(&q_u, rdata, p->user_sess_key); + /* grab the samr unknown 22 */ + samr_io_q_open_user("", &q_u, data, 0); - if (q_u.info.id != NULL) - { - free(q_u.info.id); - } + /* construct reply. always indicate success */ + samr_reply_open_user(&q_u, rdata, 0x0); + + return True; } -/******************************************************************* - samr_reply_query_usergroups - ********************************************************************/ -static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, - prs_struct *rdata) +/************************************************************************* + get_user_info_10 + *************************************************************************/ +static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) { - SAMR_R_QUERY_USERGROUPS r_u; - uint32 status = 0x0; - - struct sam_passwd *sam_pass; - DOM_GID *gids = NULL; - int num_groups = 0; - uint32 rid; - - DEBUG(5,("samr_query_usergroups: %d\n", __LINE__)); + struct smb_passwd *smb_pass; - /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) + if (!pdb_rid_is_user(user_rid)) { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + DEBUG(4,("RID 0x%x is not a user RID\n", user_rid)); + return False; } - /* find the user's rid */ - if (status == 0x0 && (rid = get_policy_samr_rid(&(q_u->pol))) == 0xffffffff) - { - status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; - } + become_root(True); + smb_pass = getsmbpwrid(user_rid); + unbecome_root(True); - if (status == 0x0) + if (smb_pass == NULL) { - become_root(True); - sam_pass = getsam21pwrid(rid); - unbecome_root(True); - - if (sam_pass == NULL) - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - } + DEBUG(4,("User 0x%x not found\n", user_rid)); + return False; } - if (status == 0x0) - { - DOMAIN_GRP *mem_grp = NULL; - - become_root(True); - getusergroupsntnam(sam_pass->nt_name, &mem_grp, &num_groups); - unbecome_root(True); - - gids = NULL; - num_groups = make_dom_gids(mem_grp, num_groups, &gids); + DEBUG(3,("User:[%s]\n", smb_pass->smb_name)); - if (mem_grp != NULL) - { - free(mem_grp); - } - } + init_sam_user_info10(id10, smb_pass->acct_ctrl); - /* construct the response. lkclXXXX: gids are not copied! */ - make_samr_r_query_usergroups(&r_u, num_groups, gids, status); + return True; +} - /* store the response in the SMB stream */ - samr_io_r_query_usergroups("", &r_u, rdata, 0); +/************************************************************************* + get_user_info_21 + *************************************************************************/ +static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) +{ + NTTIME dummy_time; + struct sam_passwd *sam_pass; + LOGON_HRS hrs; + int i; - if (gids) + if (!pdb_rid_is_user(user_rid)) { - free((char *)gids); + DEBUG(4,("RID 0x%x is not a user RID\n", user_rid)); + return False; } - DEBUG(5,("samr_query_usergroups: %d\n", __LINE__)); + become_root(True); + sam_pass = getsam21pwrid(user_rid); + unbecome_root(True); -} + if (sam_pass == NULL) + { + DEBUG(4,("User 0x%x not found\n", user_rid)); + return False; + } -/******************************************************************* - api_samr_query_usergroups - ********************************************************************/ -static void api_samr_query_usergroups( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_QUERY_USERGROUPS q_u; - samr_io_q_query_usergroups("", &q_u, data, 0); - samr_reply_query_usergroups(&q_u, rdata); -} + DEBUG(3,("User:[%s]\n", sam_pass->smb_name)); + dummy_time.low = 0xffffffff; + dummy_time.high = 0x7fffffff; -/******************************************************************* - opens a samr alias by rid, returns a policy handle. - ********************************************************************/ -static uint32 open_samr_alias(DOM_SID *sid, POLICY_HND *alias_pol, - uint32 alias_rid) -{ - BOOL pol_open = False; - uint32 status = 0x0; + DEBUG(5,("get_user_info_21 - TODO: convert unix times to NTTIMEs\n")); - /* get a (unique) handle. open a policy on it. */ - if (status == 0x0 && !(pol_open = open_policy_hnd(alias_pol))) + /* 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++) { - status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + hrs.hours[i] = sam_pass->hours[i]; } - DEBUG(0,("TODO: verify that the alias rid exists\n")); + init_sam_user_info21(id21, - /* associate a RID with the (unique) handle. */ - if (status == 0x0 && !set_policy_samr_rid(alias_pol, alias_rid)) - { - /* oh, whoops. don't know what error message to return, here */ - status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } + &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 */ - sid_append_rid(sid, alias_rid); + 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 */ - /* associate an alias SID with the (unique) handle. */ - if (status == 0x0 && !set_policy_samr_sid(alias_pol, sid)) - { - /* oh, whoops. don't know what error message to return, here */ - status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } + sam_pass->user_rid, /* RID user_id */ + sam_pass->group_rid, /* RID group_id */ + sam_pass->acct_ctrl, - if (status != 0 && pol_open) - { - close_policy_hnd(alias_pol); - } + sam_pass->unknown_3, /* unknown_3 */ + sam_pass->logon_divs, /* divisions per week */ + &hrs, /* logon hours */ + sam_pass->unknown_5, + sam_pass->unknown_6); - return status; + return True; } /******************************************************************* - samr_reply_create_dom_alias + samr_reply_query_userinfo ********************************************************************/ -static void samr_reply_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS *q_u, +static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, prs_struct *rdata) { - SAMR_R_CREATE_DOM_ALIAS r_u; - DOM_SID dom_sid; - LOCAL_GRP grp; - POLICY_HND alias_pol; - uint32 status = 0x0; + SAMR_R_QUERY_USERINFO r_u; +#if 0 + SAM_USER_INFO_11 id11; +#endif + SAM_USER_INFO_10 id10; + SAM_USER_INFO_21 id21; + void *info = NULL; - bzero(&alias_pol, sizeof(alias_pol)); + uint32 status = 0x0; + uint32 rid = 0x0; - DEBUG(5,("samr_create_dom_alias: %d\n", __LINE__)); + DEBUG(5,("samr_reply_query_userinfo: %d\n", __LINE__)); - /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_policy_by_hnd(&(q_u->dom_pol)) == -1)) + /* search for the handle */ + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + status = NT_STATUS_INVALID_HANDLE; } - /* find the domain sid */ - if (status == 0x0 && !get_policy_samr_sid(&q_u->dom_pol, &dom_sid)) + /* find the user's rid */ + if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->pol))) == 0xffffffff) { - status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; + status = NT_STATUS_OBJECT_TYPE_MISMATCH; } - if (!sid_equal(&dom_sid, &global_sam_sid)) - { - status = 0xC0000000 | NT_STATUS_ACCESS_DENIED; - } + DEBUG(5,("samr_reply_query_userinfo: rid:0x%x\n", rid)); + /* ok! user info levels (there are lots: see MSDEV help), off we go... */ if (status == 0x0) { - unistr2_to_ascii(grp.name, &q_u->uni_acct_desc, sizeof(grp.name)-1); - fstrcpy(grp.comment, ""); - grp.rid = 0xffffffff; + switch (q_u->switch_value) + { + case 0x10: + { + info = (void*)&id10; + status = get_user_info_10(&id10, rid) ? 0 : NT_STATUS_NO_SUCH_USER; + break; + } +#if 0 +/* whoops - got this wrong. i think. or don't understand what's happening. */ + case 0x11: + { + NTTIME expire; + info = (void*)&id11; + + expire.low = 0xffffffff; + expire.high = 0x7fffffff; + + make_sam_user_info11(&id11, &expire, "BROOKFIELDS$", 0x03ef, 0x201, 0x0080); + + break; + } +#endif + case 21: + { + info = (void*)&id21; + status = get_user_info_21(&id21, rid) ? 0 : NT_STATUS_NO_SUCH_USER; + break; + } - become_root(True); - status = add_alias_entry(&grp) ? 0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); - unbecome_root(True); - } + default: + { + status = NT_STATUS_INVALID_INFO_CLASS; - if (status == 0x0) - { - status = open_samr_alias(&dom_sid, &alias_pol, grp.rid); + break; + } + } } - /* construct the response. */ - make_samr_r_create_dom_alias(&r_u, &alias_pol, grp.rid, status); + init_samr_r_query_userinfo(&r_u, q_u->switch_value, info, status); /* store the response in the SMB stream */ - samr_io_r_create_dom_alias("", &r_u, rdata, 0); - - DEBUG(5,("samr_create_dom_alias: %d\n", __LINE__)); + samr_io_r_query_userinfo("", &r_u, rdata, 0); -} + DEBUG(5,("samr_reply_query_userinfo: %d\n", __LINE__)); -/******************************************************************* - api_samr_create_dom_alias - ********************************************************************/ -static void api_samr_create_dom_alias( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_CREATE_DOM_ALIAS q_u; - samr_io_q_create_dom_alias("", &q_u, data, 0); - samr_reply_create_dom_alias(&q_u, rdata); } - /******************************************************************* - opens a samr group by rid, returns a policy handle. + api_samr_query_userinfo ********************************************************************/ -static uint32 open_samr_group(DOM_SID *sid, POLICY_HND *group_pol, - uint32 group_rid) +static BOOL api_samr_query_userinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) { - BOOL pol_open = False; - uint32 status = 0x0; - - /* get a (unique) handle. open a policy on it. */ - if (status == 0x0 && !(pol_open = open_policy_hnd(group_pol))) - { - status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - - DEBUG(0,("TODO: verify that the group rid exists\n")); - - /* associate a RID with the (unique) handle. */ - if (status == 0x0 && !set_policy_samr_rid(group_pol, group_rid)) - { - /* oh, whoops. don't know what error message to return, here */ - status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - - sid_append_rid(sid, group_rid); + SAMR_Q_QUERY_USERINFO q_u; - /* associate an group SID with the (unique) handle. */ - if (status == 0x0 && !set_policy_samr_sid(group_pol, sid)) - { - /* oh, whoops. don't know what error message to return, here */ - status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } + /* grab the samr unknown 24 */ + samr_io_q_query_userinfo("", &q_u, data, 0); - if (status != 0 && pol_open) - { - close_policy_hnd(group_pol); - } + /* construct reply. always indicate success */ + samr_reply_query_userinfo(&q_u, rdata); - return status; + return True; } + /******************************************************************* - samr_reply_create_dom_group + samr_reply_query_usergroups ********************************************************************/ -static void samr_reply_create_dom_group(SAMR_Q_CREATE_DOM_GROUP *q_u, +static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, prs_struct *rdata) { - SAMR_R_CREATE_DOM_GROUP r_u; - DOM_SID dom_sid; - DOMAIN_GRP grp; - POLICY_HND group_pol; + SAMR_R_QUERY_USERGROUPS r_u; uint32 status = 0x0; - bzero(&group_pol, sizeof(group_pol)); + struct sam_passwd *sam_pass; + DOM_GID *gids = NULL; + int num_groups = 0; + uint32 rid; - DEBUG(5,("samr_create_dom_group: %d\n", __LINE__)); + DEBUG(5,("samr_query_usergroups: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_policy_by_hnd(&(q_u->pol)) == -1)) + if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } - /* find the domain sid */ - if (status == 0x0 && !get_policy_samr_sid(&q_u->pol, &dom_sid)) - { - status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; - } - - if (!sid_equal(&dom_sid, &global_sam_sid)) + /* find the user's rid */ + if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->pol))) == 0xffffffff) { - status = 0xC0000000 | NT_STATUS_ACCESS_DENIED; + status = NT_STATUS_OBJECT_TYPE_MISMATCH; } if (status == 0x0) { - unistr2_to_ascii(grp.name, &q_u->uni_acct_desc, sizeof(grp.name)-1); - fstrcpy(grp.comment, ""); - grp.rid = 0xffffffff; - grp.attr = 0x07; - become_root(True); - status = add_group_entry(&grp) ? 0x0 : (0xC0000000 | NT_STATUS_ACCESS_DENIED); + sam_pass = getsam21pwrid(rid); unbecome_root(True); + + if (sam_pass == NULL) + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + } } if (status == 0x0) { - status = open_samr_group(&dom_sid, &group_pol, grp.rid); + pstring groups; + get_domain_user_groups(groups, sam_pass->smb_name); + gids = NULL; + num_groups = make_dom_gids(groups, &gids); } - /* construct the response. */ - make_samr_r_create_dom_group(&r_u, &group_pol, grp.rid, status); + /* construct the response. lkclXXXX: gids are not copied! */ + init_samr_r_query_usergroups(&r_u, num_groups, gids, status); /* store the response in the SMB stream */ - samr_io_r_create_dom_group("", &r_u, rdata, 0); + samr_io_r_query_usergroups("", &r_u, rdata, 0); + + if (gids) + { + free((char *)gids); + } - DEBUG(5,("samr_create_dom_group: %d\n", __LINE__)); + DEBUG(5,("samr_query_usergroups: %d\n", __LINE__)); } /******************************************************************* - api_samr_create_dom_group + api_samr_query_usergroups ********************************************************************/ -static void api_samr_create_dom_group( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_query_usergroups( uint16 vuid, prs_struct *data, prs_struct *rdata) { - SAMR_Q_CREATE_DOM_GROUP q_u; - samr_io_q_create_dom_group("", &q_u, data, 0); - samr_reply_create_dom_group(&q_u, rdata); + SAMR_Q_QUERY_USERGROUPS q_u; + /* grab the samr unknown 32 */ + samr_io_q_query_usergroups("", &q_u, data, 0); + + /* construct reply. */ + samr_reply_query_usergroups(&q_u, rdata); + + return True; } @@ -2664,7 +1386,7 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, DEBUG(5,("samr_reply_query_dom_info: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (r_u.status == 0x0 && (find_policy_by_hnd(&(q_u->domain_pol)) == -1)) + if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->domain_pol)) == -1)) { r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; DEBUG(5,("samr_reply_query_dom_info: invalid handle\n")); @@ -2674,38 +1396,10 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, { switch (q_u->switch_value) { - case 0x07: - { - switch_value = 0x7; - make_unk_info7(&ctr.info.inf7); - - break; - } - case 0x06: - { - switch_value = 0x6; - make_unk_info6(&ctr.info.inf6); - - break; - } - case 0x03: - { - switch_value = 0x3; - make_unk_info3(&ctr.info.inf3); - - break; - } case 0x02: { switch_value = 0x2; - make_unk_info2(&ctr.info.inf2, global_sam_name, global_myname); - - break; - } - case 0x01: - { - switch_value = 0x1; - make_unk_info1(&ctr.info.inf1); + init_unk_info2(&ctr.info.inf2, global_myworkgroup, global_myname); break; } @@ -2717,7 +1411,7 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, } } - make_samr_r_query_dom_info(&r_u, switch_value, &ctr, status); + init_samr_r_query_dom_info(&r_u, switch_value, &ctr, status); /* store the response in the SMB stream */ samr_io_r_query_dom_info("", &r_u, rdata, 0); @@ -2729,123 +1423,96 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, /******************************************************************* api_samr_query_dom_info ********************************************************************/ -static void api_samr_query_dom_info( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_query_dom_info( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_DOMAIN_INFO q_e; + + /* grab the samr unknown 8 command */ samr_io_q_query_dom_info("", &q_e, data, 0); + + /* construct reply. */ samr_reply_query_dom_info(&q_e, rdata); + + return True; } /******************************************************************* - samr_reply_create_user + samr_reply_unknown_32 ********************************************************************/ -static void samr_reply_create_user(SAMR_Q_CREATE_USER *q_u, - prs_struct *rdata) +static void samr_reply_unknown_32(SAMR_Q_UNKNOWN_32 *q_u, + prs_struct *rdata, + int status) { - struct sam_passwd *sam_pass; - fstring user_name; - - SAMR_R_CREATE_USER r_u; - POLICY_HND pol; - uint32 status = 0x0; - uint32 user_rid = 0x0; - BOOL pol_open = False; - uint32 unk_0 = 0x30; - - /* 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... - */ - - /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_policy_by_hnd(&(q_u->domain_pol)) == -1)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - - /* get a (unique) handle. open a policy on it. */ - if (status == 0x0 && !(pol_open = open_policy_hnd(&pol))) - { - status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - - unistr2_to_ascii(user_name, &q_u->uni_name, sizeof(user_name)-1); - - sam_pass = getsam21pwntnam(user_name); + int i; + SAMR_R_UNKNOWN_32 r_u; - if (sam_pass != NULL) - { - /* account exists: say so */ - status = 0xC0000000 | NT_STATUS_USER_EXISTS; - } - else + /* set up the SAMR unknown_32 response */ + memset((char *)r_u.pol.data, '\0', POL_HND_SIZE); + if (status == 0) { - pstring err_str; - pstring msg_str; - - if (!local_password_change(user_name, True, - q_u->acb_info | ACB_DISABLED | ACB_PWNOTREQ, 0xffff, - NULL, - err_str, sizeof(err_str), - msg_str, sizeof(msg_str))) - { - DEBUG(0,("%s\n", err_str)); - status = 0xC0000000 | NT_STATUS_ACCESS_DENIED; - } - else + for (i = 4; i < POL_HND_SIZE; i++) { - sam_pass = getsam21pwntnam(user_name); - if (sam_pass == NULL) - { - /* account doesn't exist: say so */ - status = 0xC0000000 | NT_STATUS_ACCESS_DENIED; - } - else - { - user_rid = sam_pass->user_rid; - unk_0 = 0x000703ff; - } + r_u.pol.data[i] = i+1; } } - /* associate the RID with the (unique) handle. */ - if (status == 0x0 && !set_policy_samr_rid(&pol, user_rid)) - { - /* oh, whoops. don't know what error message to return, here */ - status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - - if (status != 0 && pol_open) - { - close_policy_hnd(&pol); - } - - DEBUG(5,("samr_create_user: %d\n", __LINE__)); + init_dom_rid4(&(r_u.rid4), 0x0030, 0, 0); + r_u.status = status; - make_samr_r_create_user(&r_u, &pol, unk_0, user_rid, status); + DEBUG(5,("samr_unknown_32: %d\n", __LINE__)); /* store the response in the SMB stream */ - samr_io_r_create_user("", &r_u, rdata, 0); + samr_io_r_unknown_32("", &r_u, rdata, 0); - DEBUG(5,("samr_create_user: %d\n", __LINE__)); + DEBUG(5,("samr_unknown_32: %d\n", __LINE__)); } /******************************************************************* - api_samr_create_user + api_samr_unknown_32 ********************************************************************/ -static void api_samr_create_user( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_32( uint16 vuid, prs_struct *data, prs_struct *rdata) { - SAMR_Q_CREATE_USER q_u; + uint32 status = 0; + struct sam_passwd *sam_pass; + fstring mach_acct; + + SAMR_Q_UNKNOWN_32 q_u; /* grab the samr unknown 32 */ - samr_io_q_create_user("", &q_u, data, 0); + samr_io_q_unknown_32("", &q_u, data, 0); + + /* 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(q_u.uni_mach_acct.buffer, + q_u.uni_mach_acct.uni_str_len)); + + become_root(True); + sam_pass = getsam21pwnam(mach_acct); + unbecome_root(True); + + if (sam_pass != NULL) + { + /* machine account exists: say so */ + status = 0xC0000000 | NT_STATUS_USER_EXISTS; + } + else + { + /* this could cause trouble... */ + DEBUG(0,("trouble!\n")); + status = 0; + } /* construct reply. */ - samr_reply_create_user(&q_u, rdata); + samr_reply_unknown_32(&q_u, rdata, status); + + return True; } @@ -2862,13 +1529,13 @@ static void samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, r_u.status = 0x0; /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_policy_hnd(&(r_u.connect_pol)))) + if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.connect_pol)))) { r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } /* associate the domain SID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_policy_samr_pol_status(&(r_u.connect_pol), q_u->unknown_0)) + if (r_u.status == 0x0 && !set_lsa_policy_samr_pol_status(&(r_u.connect_pol), q_u->unknown_0)) { /* oh, whoops. don't know what error message to return, here */ r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2876,7 +1543,7 @@ static void samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, if (r_u.status != 0 && pol_open) { - close_policy_hnd(&(r_u.connect_pol)); + close_lsa_policy_hnd(&(r_u.connect_pol)); } DEBUG(5,("samr_connect_anon: %d\n", __LINE__)); @@ -2891,11 +1558,17 @@ static void samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, /******************************************************************* api_samr_connect_anon ********************************************************************/ -static void api_samr_connect_anon( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_connect_anon( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_CONNECT_ANON q_u; + + /* grab the samr open policy */ samr_io_q_connect_anon("", &q_u, data, 0); + + /* construct reply. always indicate success */ samr_reply_connect_anon(&q_u, rdata); + + return True; } /******************************************************************* @@ -2911,13 +1584,13 @@ static void samr_reply_connect(SAMR_Q_CONNECT *q_u, r_u.status = 0x0; /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_policy_hnd(&(r_u.connect_pol)))) + if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.connect_pol)))) { r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } /* associate the domain SID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_policy_samr_pol_status(&(r_u.connect_pol), q_u->unknown_0)) + if (r_u.status == 0x0 && !set_lsa_policy_samr_pol_status(&(r_u.connect_pol), q_u->unknown_0)) { /* oh, whoops. don't know what error message to return, here */ r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2925,7 +1598,7 @@ static void samr_reply_connect(SAMR_Q_CONNECT *q_u, if (r_u.status != 0 && pol_open) { - close_policy_hnd(&(r_u.connect_pol)); + close_lsa_policy_hnd(&(r_u.connect_pol)); } DEBUG(5,("samr_connect: %d\n", __LINE__)); @@ -2940,11 +1613,17 @@ static void samr_reply_connect(SAMR_Q_CONNECT *q_u, /******************************************************************* api_samr_connect ********************************************************************/ -static void api_samr_connect( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_connect( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_CONNECT q_u; + + /* grab the samr open policy */ samr_io_q_connect("", &q_u, data, 0); + + /* construct reply. always indicate success */ samr_reply_connect(&q_u, rdata); + + return True; } /******************************************************************* @@ -2954,36 +1633,19 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, prs_struct *rdata) { SAMR_R_OPEN_ALIAS r_u; - DOM_SID sid; BOOL pol_open = False; /* set up the SAMR open_alias response */ r_u.status = 0x0; - if (r_u.status == 0x0 && !get_policy_samr_sid(&q_u->dom_pol, &sid)) - { - r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_policy_hnd(&(r_u.pol)))) + if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.pol)))) { r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } - DEBUG(0,("TODO: verify that the alias rid exists\n")); - /* associate a RID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_policy_samr_rid(&(r_u.pol), q_u->rid_alias)) - { - /* oh, whoops. don't know what error message to return, here */ - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - - sid_append_rid(&sid, q_u->rid_alias); - - /* associate an alias SID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_policy_samr_sid(&(r_u.pol), &sid)) + if (r_u.status == 0x0 && !set_lsa_policy_samr_rid(&(r_u.pol), q_u->rid_alias)) { /* oh, whoops. don't know what error message to return, here */ r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2991,7 +1653,7 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, if (r_u.status != 0 && pol_open) { - close_policy_hnd(&(r_u.pol)); + close_lsa_policy_hnd(&(r_u.pol)); } DEBUG(5,("samr_open_alias: %d\n", __LINE__)); @@ -3006,117 +1668,18 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, /******************************************************************* api_samr_open_alias ********************************************************************/ -static void api_samr_open_alias( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_open_alias( uint16 vuid, prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_ALIAS q_u; - samr_io_q_open_alias("", &q_u, data, 0); - samr_reply_open_alias(&q_u, rdata); -} - -/******************************************************************* - samr_reply_open_group - ********************************************************************/ -static void samr_reply_open_group(SAMR_Q_OPEN_GROUP *q_u, - prs_struct *rdata) -{ - SAMR_R_OPEN_GROUP r_u; - DOM_SID sid; - - DEBUG(5,("samr_open_group: %d\n", __LINE__)); - - r_u.status = 0x0; - - /* find the domain sid associated with the policy handle */ - if (r_u.status == 0x0 && !get_policy_samr_sid(&q_u->domain_pol, &sid)) - { - r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - - if (r_u.status == 0x0 && !sid_equal(&sid, &global_sam_sid)) - { - r_u.status = 0xC0000000 | NT_STATUS_ACCESS_DENIED; - } - - if (r_u.status == 0x0) - { - r_u.status = open_samr_group(&sid, &r_u.pol, q_u->rid_group); - } - - /* store the response in the SMB stream */ - samr_io_r_open_group("", &r_u, rdata, 0); - - DEBUG(5,("samr_open_group: %d\n", __LINE__)); - -} - -/******************************************************************* - api_samr_open_group - ********************************************************************/ -static void api_samr_open_group( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) - -{ - SAMR_Q_OPEN_GROUP q_u; - samr_io_q_open_group("", &q_u, data, 0); - samr_reply_open_group(&q_u, rdata); -} - -/******************************************************************* - samr_reply_lookup_domain - ********************************************************************/ -static void samr_reply_lookup_domain(SAMR_Q_LOOKUP_DOMAIN *q_u, - prs_struct *rdata) -{ - SAMR_R_LOOKUP_DOMAIN r_u; - fstring domain; - - DEBUG(5,("samr_lookup_domain: %d\n", __LINE__)); - - r_u.ptr_sid = 0; - r_u.status = 0x0; - - /* find the connection policy handle */ - if (find_policy_by_hnd(&(q_u->connect_pol)) == -1) - { - r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - - if (r_u.status == 0x0) - { - unistr2_to_ascii(domain, &(q_u->uni_domain), sizeof(domain)); - DEBUG(5, ("Lookup Domain: %s\n", domain)); - - /* check it's one of ours */ - if (strequal(domain, global_sam_name)) - { - make_dom_sid2(&(r_u.dom_sid), &global_sam_sid); - r_u.ptr_sid = 1; - } - else if (strequal(domain, "BUILTIN")) - { - make_dom_sid2(&(r_u.dom_sid), &global_sid_S_1_5_20); - r_u.ptr_sid = 1; - } - else - { - r_u.status = 0xC0000000 | NT_STATUS_NO_SUCH_DOMAIN; - } - } - /* store the response in the SMB stream */ - samr_io_r_lookup_domain("", &r_u, rdata, 0); + /* grab the samr open policy */ + samr_io_q_open_alias("", &q_u, data, 0); - DEBUG(5,("samr_lookup_domain: %d\n", __LINE__)); -} + /* construct reply. always indicate success */ + samr_reply_open_alias(&q_u, rdata); -/******************************************************************* - api_samr_lookup_domain - ********************************************************************/ -static void api_samr_lookup_domain( rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SAMR_Q_LOOKUP_DOMAIN q_u; - samr_io_q_lookup_domain("", &q_u, data, 0); - samr_reply_lookup_domain(&q_u, rdata); + return True; } /******************************************************************* @@ -3127,51 +1690,32 @@ static struct api_struct api_samr_cmds [] = { "SAMR_CLOSE_HND" , SAMR_CLOSE_HND , api_samr_close_hnd }, { "SAMR_CONNECT" , SAMR_CONNECT , api_samr_connect }, { "SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon }, - { "SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains }, { "SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users }, { "SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, { "SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, - { "SAMR_QUERY_USERALIASES", SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, - { "SAMR_QUERY_ALIASMEM" , SAMR_QUERY_ALIASMEM , api_samr_query_aliasmem }, - { "SAMR_QUERY_GROUPMEM" , SAMR_QUERY_GROUPMEM , api_samr_query_groupmem }, - { "SAMR_ADD_ALIASMEM" , SAMR_ADD_ALIASMEM , api_samr_add_aliasmem }, - { "SAMR_DEL_ALIASMEM" , SAMR_DEL_ALIASMEM , api_samr_del_aliasmem }, - { "SAMR_ADD_GROUPMEM" , SAMR_ADD_GROUPMEM , api_samr_add_groupmem }, - { "SAMR_DEL_GROUPMEM" , SAMR_DEL_GROUPMEM , api_samr_del_groupmem }, - { "SAMR_DELETE_DOM_GROUP" , SAMR_DELETE_DOM_GROUP , api_samr_delete_dom_group }, - { "SAMR_DELETE_DOM_ALIAS" , SAMR_DELETE_DOM_ALIAS , api_samr_delete_dom_alias }, - { "SAMR_CREATE_DOM_GROUP" , SAMR_CREATE_DOM_GROUP , api_samr_create_dom_group }, - { "SAMR_CREATE_DOM_ALIAS" , SAMR_CREATE_DOM_ALIAS , api_samr_create_dom_alias }, + { "SAMR_LOOKUP_IDS" , SAMR_LOOKUP_IDS , api_samr_lookup_ids }, { "SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, { "SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, { "SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, - { "SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo }, - { "SAMR_SET_USERINFO2" , SAMR_SET_USERINFO2 , api_samr_set_userinfo2 }, - { "SAMR_QUERY_DOMAIN_INFO", SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, + { "SAMR_QUERY_DOMAIN_INFO", SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, { "SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, { "SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, - { "SAMR_QUERY_DISPINFO3" , SAMR_QUERY_DISPINFO3 , api_samr_query_dispinfo }, - { "SAMR_QUERY_DISPINFO4" , SAMR_QUERY_DISPINFO4 , api_samr_query_dispinfo }, { "SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, - { "SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, - { "SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user }, - { "SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids }, - { "SAMR_GET_DOM_PWINFO" , SAMR_GET_DOM_PWINFO , api_samr_unknown_38 }, + { "SAMR_0x32" , 0x32 , api_samr_unknown_32 }, + { "SAMR_UNKNOWN_12" , SAMR_UNKNOWN_12 , api_samr_unknown_12 }, + { "SAMR_UNKNOWN_38" , SAMR_UNKNOWN_38 , api_samr_unknown_38 }, { "SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, { "SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, - { "SAMR_OPEN_GROUP" , SAMR_OPEN_GROUP , api_samr_open_group }, { "SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, - { "SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, - { "SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_unknown_3 }, - { "SAMR_GET_USRDOM_PWINFO", SAMR_GET_USRDOM_PWINFO, api_samr_unknown_2c }, + { "SAMR_UNKNOWN_3" , SAMR_UNKNOWN_3 , api_samr_unknown_3 }, + { "SAMR_UNKNOWN_2C" , SAMR_UNKNOWN_2C , api_samr_unknown_2c }, { NULL , 0 , NULL } }; /******************************************************************* receives a samr pipe and responds. ********************************************************************/ -BOOL api_samr_rpc(rpcsrv_struct *p, prs_struct *data) +BOOL api_samr_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_samr_rpc", api_samr_cmds, data); } - diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 8dd99cccc6..f42b94832b 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -30,248 +30,253 @@ extern int DEBUGLEVEL; extern pstring global_myname; /******************************************************************* - fill in a share info level 1 structure. + Fill in a share info level 1 structure. + ********************************************************************/ - this function breaks the rule that i'd like to be in place, namely - it doesn't receive its data as arguments: it has to call lp_xxxx() - functions itself. yuck. +static void init_srv_share_info_1(SRV_SHARE_INFO_1 *sh1, int snum) +{ + int len_net_name; + pstring net_name; + pstring remark; + uint32 type; - see ipc.c:fill_share_info() + pstrcpy(net_name, lp_servicename(snum)); + pstrcpy(remark, lp_comment(snum)); + pstring_sub(remark,"%S",lp_servicename(snum)); + len_net_name = strlen(net_name); + /* work out the share type */ + type = STYPE_DISKTREE; + + if (lp_print_ok(snum)) + type = STYPE_PRINTQ; + if (strequal("IPC$", net_name)) + type = STYPE_IPC; + if (net_name[len_net_name] == '$') + type |= STYPE_HIDDEN; + + init_srv_share_info1(&sh1->info_1, net_name, type, remark); + init_srv_share_info1_str(&sh1->info_1_str, net_name, remark); +} + +/******************************************************************* + Fill in a share info level 2 structure. ********************************************************************/ -static void make_srv_share_1_info(SH_INFO_1 *sh1, - SH_INFO_1_STR *str1, int snum) + +static void init_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, int snum) { int len_net_name; pstring net_name; pstring remark; + pstring path; + pstring passwd; uint32 type; pstrcpy(net_name, lp_servicename(snum)); - pstrcpy(remark , lp_comment (snum)); + pstrcpy(remark, lp_comment(snum)); + pstring_sub(remark,"%S",lp_servicename(snum)); + pstrcpy(path, lp_pathname(snum)); + pstrcpy(passwd, ""); len_net_name = strlen(net_name); /* work out the share type */ type = STYPE_DISKTREE; - if (lp_print_ok(snum)) type = STYPE_PRINTQ; - if (strequal("IPC$", net_name)) type = STYPE_IPC; - if (net_name[len_net_name] == '$') type |= STYPE_HIDDEN; - - make_srv_share_info1 (sh1 , net_name, type, remark); - make_srv_share_info1_str(str1, net_name, remark); + if (lp_print_ok(snum)) + type = STYPE_PRINTQ; + if (strequal("IPC$", net_name)) + type = STYPE_IPC; + if (net_name[len_net_name] == '$') + type |= STYPE_HIDDEN; + + init_srv_share_info2(&sh2->info_2, net_name, type, remark, 0, 0xffffffff, 1, path, passwd); + init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); } /******************************************************************* - fill in a share info level 1 structure. - - this function breaks the rule that i'd like to be in place, namely - it doesn't receive its data as arguments: it has to call lp_xxxx() - functions itself. yuck. - + Fill in a share info structure. ********************************************************************/ -static void make_srv_share_info_1(SRV_SHARE_INFO_1 *sh1, uint32 *snum, uint32 *svcs) + +static BOOL init_srv_share_info_ctr(SRV_SHARE_INFO_CTR *ctr, + uint32 info_level, uint32 *resume_hnd, uint32 *total_entries) { - uint32 num_entries = 0; - (*svcs) = lp_numservices(); + int num_entries = 0; + int num_services = lp_numservices(); + int snum; - if (sh1 == NULL) - { - (*snum) = 0; - return; + DEBUG(5,("init_srv_share_info_ctr\n")); + + ZERO_STRUCTPN(ctr); + + ctr->info_level = ctr->switch_value = info_level; + *resume_hnd = 0; + + /* Count the number of entries. */ + for (snum = 0; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum)) + num_entries++; } - DEBUG(5,("make_srv_share_1_sh1\n")); + *total_entries = num_entries; + ctr->num_entries2 = ctr->num_entries = num_entries; + ctr->ptr_share_info = ctr->ptr_entries = 1; - for (; (*snum) < (*svcs) && num_entries < MAX_SHARE_ENTRIES; (*snum)++) + if (!num_entries) + return True; + + switch (info_level) { + case 1: { - if (lp_browseable((*snum)) && lp_snum_ok((*snum))) - { - make_srv_share_1_info(&(sh1->info_1 [num_entries]), - &(sh1->info_1_str[num_entries]), (*snum)); + SRV_SHARE_INFO_1 *info1; + int i = 0; - /* move on to creating next share */ - num_entries++; + info1 = malloc(num_entries * sizeof(SRV_SHARE_INFO_1)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum)) { + init_srv_share_info_1(&info1[i++], snum); + } } + + ctr->share.info1 = info1; + break; } - sh1->num_entries_read = num_entries; - sh1->ptr_share_info = num_entries > 0 ? 1 : 0; - sh1->num_entries_read2 = num_entries; - - if ((*snum) >= (*svcs)) + case 2: { - (*snum) = 0; + SRV_SHARE_INFO_2 *info2; + int i = 0; + + info2 = malloc(num_entries * sizeof(SRV_SHARE_INFO_2)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum)) { + init_srv_share_info_2(&info2[i++], snum); + } + } + + ctr->share.info2 = info2; + break; } -} -/******************************************************************* - fill in a share info level 2 structure. + default: + DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level)); + return False; + } - this function breaks the rule that i'd like to be in place, namely - it doesn't receive its data as arguments: it has to call lp_xxxx() - functions itself. yuck. + return True; +} - see ipc.c:fill_share_info() +/******************************************************************* + Inits a SRV_R_NET_SHARE_ENUM structure. +********************************************************************/ - ********************************************************************/ -static void make_srv_share_2_info(SH_INFO_2 *sh2, - SH_INFO_2_STR *str2, int snum) +static void init_srv_r_net_share_enum(SRV_R_NET_SHARE_ENUM *r_n, + uint32 info_level, uint32 resume_hnd) { - int len_net_name; - pstring net_name; - pstring remark; - pstring path; - pstring passwd; - uint32 type; + DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__)); - pstrcpy(net_name, lp_servicename(snum)); - pstrcpy(remark , lp_comment (snum)); - pstrcpy(path , lp_pathname (snum)); - pstrcpy(passwd , ""); - len_net_name = strlen(net_name); - - /* work out the share type */ - type = STYPE_DISKTREE; - - if (lp_print_ok(snum)) type = STYPE_PRINTQ; - if (strequal("IPC$", net_name)) type = STYPE_IPC; - if (net_name[len_net_name] == '$') type |= STYPE_HIDDEN; + if (init_srv_share_info_ctr(&r_n->ctr, info_level, + &resume_hnd, &r_n->total_entries)) { + r_n->status = 0x0; + } else { + r_n->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + } - make_srv_share_info2 (sh2 , net_name, type, remark, 0, 0xffffffff, 1, path, passwd); - make_srv_share_info2_str(str2, net_name, remark, path, passwd); + init_enum_hnd(&r_n->enum_hnd, resume_hnd); } /******************************************************************* - fill in a share info level 2 structure. - - this function breaks the rule that i'd like to be in place, namely - it doesn't receive its data as arguments: it has to call lp_xxxx() - functions itself. yuck. + Net share enum. +********************************************************************/ - ********************************************************************/ -static void make_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, uint32 *snum, uint32 *svcs) +static BOOL srv_reply_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n, + prs_struct *rdata) { - uint32 num_entries = 0; - (*svcs) = lp_numservices(); + SRV_R_NET_SHARE_ENUM r_n; + BOOL ret; - if (sh2 == NULL) - { - (*snum) = 0; - return; - } + DEBUG(5,("srv_net_share_enum: %d\n", __LINE__)); - DEBUG(5,("make_srv_share_2_sh1\n")); + /* Create the list of shares for the response. */ + init_srv_r_net_share_enum(&r_n, + q_n->ctr.info_level, + get_enum_hnd(&q_n->enum_hnd)); - for (; (*snum) < (*svcs) && num_entries < MAX_SHARE_ENTRIES; (*snum)++) - { - if (lp_browseable((*snum)) && lp_snum_ok((*snum))) - { - make_srv_share_2_info(&(sh2->info_2 [num_entries]), - &(sh2->info_2_str[num_entries]), (*snum)); + /* store the response in the SMB stream */ + ret = srv_io_r_net_share_enum("", &r_n, rdata, 0); - /* move on to creating next share */ - num_entries++; - } - } + /* Free the memory used by the response. */ + free_srv_r_net_share_enum(&r_n); - sh2->num_entries_read = num_entries; - sh2->ptr_share_info = num_entries > 0 ? 1 : 0; - sh2->num_entries_read2 = num_entries; - - if ((*snum) >= (*svcs)) - { - (*snum) = 0; - } + DEBUG(5,("srv_net_share_enum: %d\n", __LINE__)); + + return ret; } /******************************************************************* - makes a SRV_R_NET_SHARE_ENUM structure. + Inits a SRV_R_NET_SHARE_GET_INFO structure. ********************************************************************/ -static uint32 make_srv_share_info_ctr(SRV_SHARE_INFO_CTR *ctr, - int switch_value, uint32 *resume_hnd, uint32 *total_entries) + +static void init_srv_r_net_share_get_info(SRV_R_NET_SHARE_GET_INFO *r_n, + char *share_name, uint32 info_level) { uint32 status = 0x0; - DEBUG(5,("make_srv_share_info_ctr: %d\n", __LINE__)); + int snum; - ctr->switch_value = switch_value; + DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__)); - switch (switch_value) - { + r_n->switch_value = info_level; + + snum = find_service(share_name); + + if (snum >= 0) { + switch (info_level) { case 1: - { - make_srv_share_info_1(&(ctr->share.info1), resume_hnd, total_entries); - ctr->ptr_share_ctr = 1; + init_srv_share_info_1(&r_n->share.info1, snum); break; - } case 2: - { - make_srv_share_info_2(&(ctr->share.info2), resume_hnd, total_entries); - ctr->ptr_share_ctr = 2; + init_srv_share_info_2(&r_n->share.info2, snum); break; - } default: - { - DEBUG(5,("make_srv_share_info_ctr: unsupported switch value %d\n", - switch_value)); - (*resume_hnd = 0); - (*total_entries) = 0; - ctr->ptr_share_ctr = 0; + DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level)); status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; break; } + } else { + status = 0xC0000000 | NT_STATUS_BAD_NETWORK_NAME; } - return status; + r_n->ptr_share_ctr = (status == 0x0) ? 1 : 0; + r_n->status = status; } /******************************************************************* - makes a SRV_R_NET_SHARE_ENUM structure. + Net share get info. ********************************************************************/ -static void make_srv_r_net_share_enum(SRV_R_NET_SHARE_ENUM *r_n, - uint32 resume_hnd, int share_level, int switch_value) -{ - DEBUG(5,("make_srv_r_net_share_enum: %d\n", __LINE__)); - - r_n->share_level = share_level; - if (share_level == 0) - { - r_n->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; - } - else - { - r_n->status = make_srv_share_info_ctr(r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries)); - } - if (r_n->status != 0x0) - { - resume_hnd = 0; - } - make_enum_hnd(&(r_n->enum_hnd), resume_hnd); -} -/******************************************************************* -net share enum -********************************************************************/ -static void srv_reply_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n, - prs_struct *rdata) +static BOOL srv_reply_net_share_get_info(SRV_Q_NET_SHARE_GET_INFO *q_n, + prs_struct *rdata) { - SRV_R_NET_SHARE_ENUM r_n; - SRV_SHARE_INFO_CTR ctr; + SRV_R_NET_SHARE_GET_INFO r_n; + char *share_name; + BOOL ret; - r_n.ctr = &ctr; + DEBUG(5,("srv_net_share_get_info: %d\n", __LINE__)); - DEBUG(5,("srv_net_share_enum: %d\n", __LINE__)); - - /* set up the */ - make_srv_r_net_share_enum(&r_n, - get_enum_hnd(&q_n->enum_hnd), - q_n->share_level, - q_n->ctr->switch_value); + /* Create the list of shares for the response. */ + share_name = dos_unistr2_to_str(&q_n->uni_share_name); + init_srv_r_net_share_get_info(&r_n, share_name, q_n->info_level); /* store the response in the SMB stream */ - srv_io_r_net_share_enum("", &r_n, rdata, 0); + ret = srv_io_r_net_share_get_info("", &r_n, rdata, 0); - DEBUG(5,("srv_net_share_enum: %d\n", __LINE__)); + /* Free the memory used by the response. */ + free_srv_r_net_share_get_info(&r_n); + + DEBUG(5,("srv_net_share_get_info: %d\n", __LINE__)); + + return ret; } /******************************************************************* @@ -282,11 +287,11 @@ static void srv_reply_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n, functions itself. yuck. ********************************************************************/ -static void make_srv_sess_0_info(SESS_INFO_0 *se0, SESS_INFO_0_STR *str0, +static void init_srv_sess_0_info(SESS_INFO_0 *se0, SESS_INFO_0_STR *str0, char *name) { - make_srv_sess_info0 (se0 , name); - make_srv_sess_info0_str(str0, name); + init_srv_sess_info0 (se0 , name); + init_srv_sess_info0_str(str0, name); } /******************************************************************* @@ -297,39 +302,26 @@ static void make_srv_sess_0_info(SESS_INFO_0 *se0, SESS_INFO_0_STR *str0, functions itself. yuck. ********************************************************************/ -static void make_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot) +static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot) { uint32 num_entries = 0; - struct connect_record *crec; - uint32 session_count; + (*stot) = 1; - if (!get_session_count(&crec, &session_count)) - { - (*snum) = 0; - (*stot) = 0; - return; - } - - (*stot) = session_count; - - DEBUG(0,("Session Count : %u\n",session_count)); - if (ss0 == NULL) { (*snum) = 0; - free(crec); return; } + DEBUG(5,("init_srv_sess_0_ss0\n")); + if (snum) { - DEBUG(0,("snum ok\n")); for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { - make_srv_sess_0_info(&(ss0->info_0 [num_entries]), - &(ss0->info_0_str[num_entries]), crec[num_entries].machine); + init_srv_sess_0_info(&(ss0->info_0 [num_entries]), + &(ss0->info_0_str[num_entries]), "MACHINE"); - DEBUG(0,("make_srv_sess_0_info\n")); /* move on to creating next session */ /* move on to creating next sess */ num_entries++; @@ -350,7 +342,6 @@ static void make_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *sto ss0->ptr_sess_info = 0; ss0->num_entries_read2 = 0; } - free(crec); } /******************************************************************* @@ -361,14 +352,14 @@ static void make_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *sto functions itself. yuck. ********************************************************************/ -static void make_srv_sess_1_info(SESS_INFO_1 *se1, SESS_INFO_1_STR *str1, +static void init_srv_sess_1_info(SESS_INFO_1 *se1, SESS_INFO_1_STR *str1, char *name, char *user, uint32 num_opens, uint32 open_time, uint32 idle_time, uint32 usr_flgs) { - make_srv_sess_info1 (se1 , name, user, num_opens, open_time, idle_time, usr_flgs); - make_srv_sess_info1_str(str1, name, user); + init_srv_sess_info1 (se1 , name, user, num_opens, open_time, idle_time, usr_flgs); + init_srv_sess_info1_str(str1, name, user); } /******************************************************************* @@ -379,41 +370,26 @@ static void make_srv_sess_1_info(SESS_INFO_1 *se1, SESS_INFO_1_STR *str1, functions itself. yuck. ********************************************************************/ -static void make_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot) +static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot) { uint32 num_entries = 0; - struct connect_record *crec; - uint32 session_count; + (*stot) = 1; - if (!get_session_count(&crec, &session_count)) - { - (*snum) = 0; - (*stot) = 0; - return; - } - - (*stot) = session_count; - - DEBUG(0,("Session Count (info1) : %u\n",session_count)); if (ss1 == NULL) { (*snum) = 0; - free(crec); return; } - DEBUG(5,("make_srv_sess_1_ss1\n")); + DEBUG(5,("init_srv_sess_1_ss1\n")); if (snum) { for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { - DEBUG(0,("sess1 machine: %s, uid : %u\n",crec[num_entries].machine,crec[num_entries].uid)); - make_srv_sess_1_info(&(ss1->info_1 [num_entries]), + init_srv_sess_1_info(&(ss1->info_1 [num_entries]), &(ss1->info_1_str[num_entries]), - crec[num_entries].machine, - uidtoname(crec[num_entries].uid), 1, 10, 5, 0); -/* What are these on the End ??? */ + "MACHINE", "dummy_user", 1, 10, 5, 0); /* move on to creating next session */ /* move on to creating next sess */ @@ -437,17 +413,16 @@ static void make_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto (*stot) = 0; } - free(crec); } /******************************************************************* makes a SRV_R_NET_SESS_ENUM structure. ********************************************************************/ -static uint32 make_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, +static uint32 init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { uint32 status = 0x0; - DEBUG(5,("make_srv_sess_info_ctr: %d\n", __LINE__)); + DEBUG(5,("init_srv_sess_info_ctr: %d\n", __LINE__)); ctr->switch_value = switch_value; @@ -455,19 +430,19 @@ static uint32 make_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, { case 0: { - make_srv_sess_info_0(&(ctr->sess.info0), resume_hnd, total_entries); + init_srv_sess_info_0(&(ctr->sess.info0), resume_hnd, total_entries); ctr->ptr_sess_ctr = 1; break; } case 1: { - make_srv_sess_info_1(&(ctr->sess.info1), resume_hnd, total_entries); + init_srv_sess_info_1(&(ctr->sess.info1), resume_hnd, total_entries); ctr->ptr_sess_ctr = 1; break; } default: { - DEBUG(5,("make_srv_sess_info_ctr: unsupported switch value %d\n", + DEBUG(5,("init_srv_sess_info_ctr: unsupported switch value %d\n", switch_value)); (*resume_hnd) = 0; (*total_entries) = 0; @@ -483,10 +458,10 @@ static uint32 make_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, /******************************************************************* makes a SRV_R_NET_SESS_ENUM structure. ********************************************************************/ -static void make_srv_r_net_sess_enum(SRV_R_NET_SESS_ENUM *r_n, +static void init_srv_r_net_sess_enum(SRV_R_NET_SESS_ENUM *r_n, uint32 resume_hnd, int sess_level, int switch_value) { - DEBUG(5,("make_srv_r_net_sess_enum: %d\n", __LINE__)); + DEBUG(5,("init_srv_r_net_sess_enum: %d\n", __LINE__)); r_n->sess_level = sess_level; if (sess_level == -1) @@ -495,13 +470,13 @@ static void make_srv_r_net_sess_enum(SRV_R_NET_SESS_ENUM *r_n, } else { - r_n->status = make_srv_sess_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); + r_n->status = init_srv_sess_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); } if (r_n->status != 0x0) { resume_hnd = 0; } - make_enum_hnd(&(r_n->enum_hnd), resume_hnd); + init_enum_hnd(&(r_n->enum_hnd), resume_hnd); } /******************************************************************* @@ -518,7 +493,7 @@ static void srv_reply_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n, DEBUG(5,("srv_net_sess_enum: %d\n", __LINE__)); /* set up the */ - make_srv_r_net_sess_enum(&r_n, + init_srv_r_net_sess_enum(&r_n, get_enum_hnd(&q_n->enum_hnd), q_n->sess_level, q_n->ctr->switch_value); @@ -537,20 +512,10 @@ static void srv_reply_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n, functions itself. yuck. ********************************************************************/ -static void make_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *stot) +static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *stot) { - uint32 num_entries = 0; - struct connect_record *crec; - uint32 connection_count; - - if (!get_connection_status(&crec, &connection_count)) - { - (*snum) = 0; - (*stot) = 0; - return; - } - - (*stot) = connection_count; + uint32 num_entries = 0; + (*stot) = 1; if (ss0 == NULL) { @@ -558,13 +523,13 @@ static void make_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *sto return; } - DEBUG(0,("make_srv_conn_0_ss0\n")); + DEBUG(5,("init_srv_conn_0_ss0\n")); if (snum) { for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) { - make_srv_conn_info0(&(ss0->info_0 [num_entries]), (*snum)); + init_srv_conn_info0(&(ss0->info_0 [num_entries]), (*stot)); /* move on to creating next connection */ /* move on to creating next conn */ @@ -590,8 +555,6 @@ static void make_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *sto (*stot) = 0; } - - free(crec); } /******************************************************************* @@ -602,13 +565,13 @@ static void make_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *sto functions itself. yuck. ********************************************************************/ -static void make_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1, +static void init_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1, uint32 id, uint32 type, uint32 num_opens, uint32 num_users, uint32 open_time, char *usr_name, char *net_name) { - make_srv_conn_info1 (se1 , id, type, num_opens, num_users, open_time, usr_name, net_name); - make_srv_conn_info1_str(str1, usr_name, net_name); + init_srv_conn_info1 (se1 , id, type, num_opens, num_users, open_time, usr_name, net_name); + init_srv_conn_info1_str(str1, usr_name, net_name); } /******************************************************************* @@ -619,23 +582,10 @@ static void make_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1, functions itself. yuck. ********************************************************************/ -static void make_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *stot) +static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *stot) { - uint32 num_entries = 0; - time_t current_time; - time_t diff; - - struct connect_record *crec; - uint32 connection_count; - - if (!get_connection_status(&crec, &connection_count)) - { - (*snum) = 0; - (*stot) = 0; - return; - } - - (*stot) = connection_count; + uint32 num_entries = 0; + (*stot) = 1; if (ss1 == NULL) { @@ -643,21 +593,15 @@ static void make_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto return; } - current_time=time(NULL); - - DEBUG(5,("make_srv_conn_1_ss1\n")); + DEBUG(5,("init_srv_conn_1_ss1\n")); if (snum) { for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) { - diff = current_time - crec[num_entries].start; - make_srv_conn_1_info(&(ss1->info_1 [num_entries]), + init_srv_conn_1_info(&(ss1->info_1 [num_entries]), &(ss1->info_1_str[num_entries]), - (*snum), 0, 0, 1, diff,uidtoname(crec[num_entries].uid), - crec[num_entries].name); - -/* FIXME : type of connection + number of locked files */ + (*stot), 0x3, 1, 1, 3,"dummy_user", "IPC$"); /* move on to creating next connection */ /* move on to creating next conn */ @@ -682,18 +626,16 @@ static void make_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto (*stot) = 0; } - - free(crec); } /******************************************************************* makes a SRV_R_NET_CONN_ENUM structure. ********************************************************************/ -static uint32 make_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, +static uint32 init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { uint32 status = 0x0; - DEBUG(5,("make_srv_conn_info_ctr: %d\n", __LINE__)); + DEBUG(5,("init_srv_conn_info_ctr: %d\n", __LINE__)); ctr->switch_value = switch_value; @@ -701,19 +643,19 @@ static uint32 make_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, { case 0: { - make_srv_conn_info_0(&(ctr->conn.info0), resume_hnd, total_entries); + init_srv_conn_info_0(&(ctr->conn.info0), resume_hnd, total_entries); ctr->ptr_conn_ctr = 1; break; } case 1: { - make_srv_conn_info_1(&(ctr->conn.info1), resume_hnd, total_entries); + init_srv_conn_info_1(&(ctr->conn.info1), resume_hnd, total_entries); ctr->ptr_conn_ctr = 1; break; } default: { - DEBUG(5,("make_srv_conn_info_ctr: unsupported switch value %d\n", + DEBUG(5,("init_srv_conn_info_ctr: unsupported switch value %d\n", switch_value)); (*resume_hnd = 0); (*total_entries) = 0; @@ -729,10 +671,10 @@ static uint32 make_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, /******************************************************************* makes a SRV_R_NET_CONN_ENUM structure. ********************************************************************/ -static void make_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, +static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, uint32 resume_hnd, int conn_level, int switch_value) { - DEBUG(5,("make_srv_r_net_conn_enum: %d\n", __LINE__)); + DEBUG(5,("init_srv_r_net_conn_enum: %d\n", __LINE__)); r_n->conn_level = conn_level; if (conn_level == -1) @@ -741,13 +683,13 @@ static void make_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, } else { - r_n->status = make_srv_conn_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); + r_n->status = init_srv_conn_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); } if (r_n->status != 0x0) { resume_hnd = 0; } - make_enum_hnd(&(r_n->enum_hnd), resume_hnd); + init_enum_hnd(&(r_n->enum_hnd), resume_hnd); } /******************************************************************* @@ -764,7 +706,7 @@ static void srv_reply_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n, DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); /* set up the */ - make_srv_r_net_conn_enum(&r_n, + init_srv_r_net_conn_enum(&r_n, get_enum_hnd(&q_n->enum_hnd), q_n->conn_level, q_n->ctr->switch_value); @@ -778,12 +720,12 @@ static void srv_reply_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n, /******************************************************************* fill in a file info level 3 structure. ********************************************************************/ -static void make_srv_file_3_info(FILE_INFO_3 *fl3, FILE_INFO_3_STR *str3, +static void init_srv_file_3_info(FILE_INFO_3 *fl3, FILE_INFO_3_STR *str3, uint32 fnum, uint32 perms, uint32 num_locks, char *path_name, char *user_name) { - make_srv_file_info3 (fl3 , fnum, perms, num_locks, path_name, user_name); - make_srv_file_info3_str(str3, path_name, user_name); + init_srv_file_info3 (fl3 , fnum, perms, num_locks, path_name, user_name); + init_srv_file_info3_str(str3, path_name, user_name); } /******************************************************************* @@ -794,7 +736,7 @@ static void make_srv_file_3_info(FILE_INFO_3 *fl3, FILE_INFO_3_STR *str3, functions itself. yuck. ********************************************************************/ -static void make_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *ftot) +static void init_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *ftot) { uint32 num_entries = 0; (*ftot) = 1; @@ -805,11 +747,11 @@ static void make_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *fto return; } - DEBUG(5,("make_srv_file_3_fl3\n")); + DEBUG(5,("init_srv_file_3_fl3\n")); for (; (*fnum) < (*ftot) && num_entries < MAX_FILE_ENTRIES; (*fnum)++) { - make_srv_file_3_info(&(fl3->info_3 [num_entries]), + init_srv_file_3_info(&(fl3->info_3 [num_entries]), &(fl3->info_3_str[num_entries]), (*fnum), 0x35, 0, "\\PIPE\\samr", "dummy user"); @@ -830,11 +772,11 @@ static void make_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *fto /******************************************************************* makes a SRV_R_NET_FILE_ENUM structure. ********************************************************************/ -static uint32 make_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, +static uint32 init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { uint32 status = 0x0; - DEBUG(5,("make_srv_file_info_ctr: %d\n", __LINE__)); + DEBUG(5,("init_srv_file_info_ctr: %d\n", __LINE__)); ctr->switch_value = switch_value; @@ -842,13 +784,13 @@ static uint32 make_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, { case 3: { - make_srv_file_info_3(&(ctr->file.info3), resume_hnd, total_entries); + init_srv_file_info_3(&(ctr->file.info3), resume_hnd, total_entries); ctr->ptr_file_ctr = 1; break; } default: { - DEBUG(5,("make_srv_file_info_ctr: unsupported switch value %d\n", + DEBUG(5,("init_srv_file_info_ctr: unsupported switch value %d\n", switch_value)); (*resume_hnd = 0); (*total_entries) = 0; @@ -864,10 +806,10 @@ static uint32 make_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, /******************************************************************* makes a SRV_R_NET_FILE_ENUM structure. ********************************************************************/ -static void make_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n, +static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n, uint32 resume_hnd, int file_level, int switch_value) { - DEBUG(5,("make_srv_r_net_file_enum: %d\n", __LINE__)); + DEBUG(5,("init_srv_r_net_file_enum: %d\n", __LINE__)); r_n->file_level = file_level; if (file_level == 0) @@ -876,13 +818,13 @@ static void make_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n, } else { - r_n->status = make_srv_file_info_ctr(r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries)); + r_n->status = init_srv_file_info_ctr(r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries)); } if (r_n->status != 0x0) { resume_hnd = 0; } - make_enum_hnd(&(r_n->enum_hnd), resume_hnd); + init_enum_hnd(&(r_n->enum_hnd), resume_hnd); } /******************************************************************* @@ -899,7 +841,7 @@ static void srv_reply_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n, DEBUG(5,("srv_net_file_enum: %d\n", __LINE__)); /* set up the */ - make_srv_r_net_file_enum(&r_n, + init_srv_r_net_file_enum(&r_n, get_enum_hnd(&q_n->enum_hnd), q_n->file_level, q_n->ctr->switch_value); @@ -913,6 +855,7 @@ static void srv_reply_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n, /******************************************************************* net server get info ********************************************************************/ + static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *rdata) { @@ -927,12 +870,10 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, { case 102: { - make_srv_info_102(&ctr.srv.sv102, - 500, /* platform id */ - global_myname, - lp_serverstring(), - lp_major_announce_version(), - lp_minor_announce_version(), + init_srv_info_102(&ctr.srv.sv102, + 500, global_myname, + string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), + lp_major_announce_version(), lp_minor_announce_version(), lp_default_server_announce(), 0xffffffff, /* users */ 0xf, /* disc */ @@ -945,13 +886,11 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, } case 101: { - make_srv_info_101(&ctr.srv.sv101, - 500, /* platform id */ - global_myname, - lp_major_announce_version(), - lp_minor_announce_version(), + init_srv_info_101(&ctr.srv.sv101, + 500, global_myname, + lp_major_announce_version(), lp_minor_announce_version(), lp_default_server_announce(), - lp_serverstring()); + string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); break; } default: @@ -962,7 +901,7 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, } /* set up the net server get info structure */ - make_srv_r_net_srv_get_info(&r_n, q_n->switch_value, &ctr, status); + init_srv_r_net_srv_get_info(&r_n, q_n->switch_value, &ctr, status); /* store the response in the SMB stream */ srv_io_r_net_srv_get_info("", &r_n, rdata, 0); @@ -972,7 +911,7 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, /******************************************************************* ********************************************************************/ -static void api_srv_net_srv_get_info( rpcsrv_struct *p, prs_struct *data, +static BOOL api_srv_net_srv_get_info( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SRV_GET_INFO q_n; @@ -982,12 +921,14 @@ static void api_srv_net_srv_get_info( rpcsrv_struct *p, prs_struct *data, /* construct reply. always indicate success */ srv_reply_net_srv_get_info(&q_n, rdata); + + return True; } /******************************************************************* ********************************************************************/ -static void api_srv_net_file_enum( rpcsrv_struct *p, prs_struct *data, +static BOOL api_srv_net_file_enum( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_FILE_ENUM q_n; @@ -1000,12 +941,14 @@ static void api_srv_net_file_enum( rpcsrv_struct *p, prs_struct *data, /* construct reply. always indicate success */ srv_reply_net_file_enum(&q_n, rdata); + + return True; } /******************************************************************* ********************************************************************/ -static void api_srv_net_conn_enum( rpcsrv_struct *p, prs_struct *data, +static BOOL api_srv_net_conn_enum( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_CONN_ENUM q_n; @@ -1018,12 +961,14 @@ static void api_srv_net_conn_enum( rpcsrv_struct *p, prs_struct *data, /* construct reply. always indicate success */ srv_reply_net_conn_enum(&q_n, rdata); + + return True; } /******************************************************************* ********************************************************************/ -static void api_srv_net_sess_enum( rpcsrv_struct *p, prs_struct *data, +static BOOL api_srv_net_sess_enum( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SESS_ENUM q_n; @@ -1036,30 +981,63 @@ static void api_srv_net_sess_enum( rpcsrv_struct *p, prs_struct *data, /* construct reply. always indicate success */ srv_reply_net_sess_enum(&q_n, rdata); + + return True; } /******************************************************************* + RPC to enumerate shares. ********************************************************************/ -static void api_srv_net_share_enum( rpcsrv_struct *p, prs_struct *data, + +static BOOL api_srv_net_share_enum( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SHARE_ENUM q_n; - SRV_SHARE_INFO_CTR ctr; + BOOL ret; - q_n.ctr = &ctr; + /* Unmarshall the net server get enum. */ + if(!srv_io_q_net_share_enum("", &q_n, data, 0)) { + DEBUG(0,("api_srv_net_share_enum: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n")); + return False; + } - /* grab the net server get enum */ - srv_io_q_net_share_enum("", &q_n, data, 0); + ret = srv_reply_net_share_enum(&q_n, rdata); - /* construct reply. always indicate success */ - srv_reply_net_share_enum(&q_n, rdata); + /* Free any data allocated in the unmarshalling. */ + free_srv_q_net_share_enum(&q_n); + + return ret; +} + +/******************************************************************* + RPC to return share information. +********************************************************************/ + +static BOOL api_srv_net_share_get_info( uint16 vuid, prs_struct *data, + prs_struct *rdata ) +{ + SRV_Q_NET_SHARE_GET_INFO q_n; + BOOL ret; + + /* Unmarshall the net server get info. */ + if(!srv_io_q_net_share_get_info("", &q_n, data, 0)) { + DEBUG(0,("api_srv_net_share_get_info: Failed to unmarshall SRV_Q_NET_SHARE_GET_INFO.\n")); + return False; + } + + ret = srv_reply_net_share_get_info(&q_n, rdata); + + /* Free any data allocated in the unmarshalling. */ + free_srv_q_net_share_get_info(&q_n); + + return ret; } /******************************************************************* time of day ********************************************************************/ -static void srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n, +static BOOL srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *rdata) { SRV_R_NET_REMOTE_TOD r_n; @@ -1076,7 +1054,7 @@ static void srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n, t = gmtime(&unixdate); /* set up the */ - make_time_of_day_info(&tod, + init_time_of_day_info(&tod, unixdate, 0, t->tm_hour, @@ -1094,10 +1072,12 @@ static void srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n, srv_io_r_net_remote_tod("", &r_n, rdata, 0); DEBUG(5,("srv_reply_net_remote_tod: %d\n", __LINE__)); + + return True; } /******************************************************************* ********************************************************************/ -static void api_srv_net_remote_tod( rpcsrv_struct *p, prs_struct *data, +static BOOL api_srv_net_remote_tod( uint16 vuid, prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_REMOTE_TOD q_n; @@ -1107,6 +1087,8 @@ static void api_srv_net_remote_tod( rpcsrv_struct *p, prs_struct *data, /* construct reply. always indicate success */ srv_reply_net_remote_tod(&q_n, rdata); + + return True; } @@ -1115,20 +1097,20 @@ static void api_srv_net_remote_tod( rpcsrv_struct *p, prs_struct *data, ********************************************************************/ struct api_struct api_srv_cmds[] = { - { "SRV_NETCONNENUM" , SRV_NETCONNENUM , api_srv_net_conn_enum }, - { "SRV_NETSESSENUM" , SRV_NETSESSENUM , api_srv_net_sess_enum }, - { "SRV_NETSHAREENUM" , SRV_NETSHAREENUM , api_srv_net_share_enum }, - { "SRV_NETFILEENUM" , SRV_NETFILEENUM , api_srv_net_file_enum }, - { "SRV_NET_SRV_GET_INFO", SRV_NET_SRV_GET_INFO, api_srv_net_srv_get_info }, - { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, - { NULL , 0 , NULL } + { "SRV_NETCONNENUM" , SRV_NETCONNENUM , api_srv_net_conn_enum }, + { "SRV_NETSESSENUM" , SRV_NETSESSENUM , api_srv_net_sess_enum }, + { "SRV_NETSHAREENUM" , SRV_NETSHAREENUM , api_srv_net_share_enum }, + { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info }, + { "SRV_NETFILEENUM" , SRV_NETFILEENUM , api_srv_net_file_enum }, + { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, + { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, + { NULL , 0 , NULL } }; /******************************************************************* receives a srvsvc pipe and responds. ********************************************************************/ -BOOL api_srvsvc_rpc(rpcsrv_struct *p, prs_struct *data) +BOOL api_srvsvc_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_srvsvc_rpc", api_srv_cmds, data); } - diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 25dceb41a0..097ab92d76 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -22,4 +22,325 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* retired module */ +/* this module apparently provides an implementation of DCE/RPC over a + * named pipe (IPC$ connection using SMBtrans). details of DCE/RPC + * documentation are available (in on-line form) from the X-Open group. + * + * this module should provide a level of abstraction between SMB + * and DCE/RPC, while minimising the amount of mallocs, unnecessary + * data copies, and network traffic. + * + * in this version, which takes a "let's learn what's going on and + * get something running" approach, there is additional network + * traffic generated, but the code should be easier to understand... + * + * ... if you read the docs. or stare at packets for weeks on end. + * + */ + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + +/* + * A list of the rids of well known BUILTIN and Domain users + * and groups. + */ + +rid_name builtin_alias_rids[] = +{ + { BUILTIN_ALIAS_RID_ADMINS , "Administrators" }, + { BUILTIN_ALIAS_RID_USERS , "Users" }, + { BUILTIN_ALIAS_RID_GUESTS , "Guests" }, + { BUILTIN_ALIAS_RID_POWER_USERS , "Power Users" }, + + { BUILTIN_ALIAS_RID_ACCOUNT_OPS , "Account Operators" }, + { BUILTIN_ALIAS_RID_SYSTEM_OPS , "System Operators" }, + { BUILTIN_ALIAS_RID_PRINT_OPS , "Print Operators" }, + { BUILTIN_ALIAS_RID_BACKUP_OPS , "Backup Operators" }, + { BUILTIN_ALIAS_RID_REPLICATOR , "Replicator" }, + { 0 , NULL } +}; + +/* array lookup of well-known Domain RID users. */ +rid_name domain_user_rids[] = +{ + { DOMAIN_USER_RID_ADMIN , "Administrator" }, + { DOMAIN_USER_RID_GUEST , "Guest" }, + { 0 , NULL } +}; + +/* array lookup of well-known Domain RID groups. */ +rid_name domain_group_rids[] = +{ + { DOMAIN_GROUP_RID_ADMINS , "Domain Admins" }, + { DOMAIN_GROUP_RID_USERS , "Domain Users" }, + { DOMAIN_GROUP_RID_GUESTS , "Domain Guests" }, + { 0 , NULL } +}; + +int make_dom_gids(char *gids_str, DOM_GID **ppgids) +{ + char *ptr; + pstring s2; + int count; + DOM_GID *gids; + + *ppgids = NULL; + + DEBUG(4,("make_dom_gids: %s\n", gids_str)); + + if (gids_str == NULL || *gids_str == 0) + return 0; + + for (count = 0, ptr = gids_str; + next_token(&ptr, s2, NULL, sizeof(s2)); + count++) + ; + + gids = (DOM_GID *)malloc( sizeof(DOM_GID) * count ); + if(!gids) + { + DEBUG(0,("make_dom_gids: malloc fail !\n")); + return 0; + } + + for (count = 0, ptr = gids_str; + next_token(&ptr, s2, NULL, sizeof(s2)) && + count < LSA_MAX_GROUPS; + count++) + { + /* the entries are of the form GID/ATTR, ATTR being optional.*/ + char *attr; + uint32 rid = 0; + int i; + + attr = strchr(s2,'/'); + if (attr) + *attr++ = 0; + + if (!attr || !*attr) + attr = "7"; /* default value for attribute is 7 */ + + /* look up the RID string and see if we can turn it into a rid number */ + for (i = 0; builtin_alias_rids[i].name != NULL; i++) + { + if (strequal(builtin_alias_rids[i].name, s2)) + { + rid = builtin_alias_rids[i].rid; + break; + } + } + + if (rid == 0) + rid = atoi(s2); + + if (rid == 0) + { + DEBUG(1,("make_dom_gids: unknown well-known alias RID %s/%s\n", s2, attr)); + count--; + } + else + { + gids[count].g_rid = rid; + gids[count].attr = atoi(attr); + + DEBUG(5,("group id: %d attr: %d\n", gids[count].g_rid, gids[count].attr)); + } + } + + *ppgids = gids; + return count; +} + + +/******************************************************************* + gets a domain user's groups + ********************************************************************/ +void get_domain_user_groups(char *domain_groups, char *user) +{ + pstring tmp; + + if (domain_groups == NULL || user == NULL) return; + + /* any additional groups this user is in. e.g power users */ + pstrcpy(domain_groups, lp_domain_groups()); + + /* can only be a user or a guest. cannot be guest _and_ admin */ + if (user_in_list(user, lp_domain_guest_group())) + { + slprintf(tmp, sizeof(tmp) - 1, " %ld/7 ", DOMAIN_GROUP_RID_GUESTS); + pstrcat(domain_groups, tmp); + + DEBUG(3,("domain guest group access %s granted\n", tmp)); + } + else + { + slprintf(tmp, sizeof(tmp) -1, " %ld/7 ", DOMAIN_GROUP_RID_USERS); + pstrcat(domain_groups, tmp); + + DEBUG(3,("domain group access %s granted\n", tmp)); + + if (user_in_list(user, lp_domain_admin_group())) + { + slprintf(tmp, sizeof(tmp) - 1, " %ld/7 ", DOMAIN_GROUP_RID_ADMINS); + pstrcat(domain_groups, tmp); + + DEBUG(3,("domain admin group access %s granted\n", tmp)); + } + } +} + + +/******************************************************************* + lookup_group_name + ********************************************************************/ +uint32 lookup_group_name(uint32 rid, char *group_name, uint32 *type) +{ + int i = 0; + (*type) = SID_NAME_DOM_GRP; + + DEBUG(5,("lookup_group_name: rid: %d", rid)); + + while (domain_group_rids[i].rid != rid && domain_group_rids[i].rid != 0) + { + i++; + } + + if (domain_group_rids[i].rid != 0) + { + fstrcpy(group_name, domain_group_rids[i].name); + DEBUG(5,(" = %s\n", group_name)); + return 0x0; + } + + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_alias_name + ********************************************************************/ +uint32 lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) +{ + int i = 0; + (*type) = SID_NAME_WKN_GRP; + + DEBUG(5,("lookup_alias_name: rid: %d", rid)); + + while (builtin_alias_rids[i].rid != rid && builtin_alias_rids[i].rid != 0) + { + i++; + } + + if (builtin_alias_rids[i].rid != 0) + { + fstrcpy(alias_name, builtin_alias_rids[i].name); + DEBUG(5,(" = %s\n", alias_name)); + return 0x0; + } + + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_user_name + ********************************************************************/ +uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) +{ + struct sam_disp_info *disp_info; + int i = 0; + (*type) = SID_NAME_USER; + + DEBUG(5,("lookup_user_name: rid: %d", rid)); + + /* look up the well-known domain user rids first */ + while (domain_user_rids[i].rid != rid && domain_user_rids[i].rid != 0) + { + i++; + } + + if (domain_user_rids[i].rid != 0) + { + fstrcpy(user_name, domain_user_rids[i].name); + DEBUG(5,(" = %s\n", user_name)); + return 0x0; + } + + /* ok, it's a user. find the user account */ + become_root(True); + disp_info = getsamdisprid(rid); + unbecome_root(True); + + if (disp_info != NULL) + { + fstrcpy(user_name, disp_info->smb_name); + DEBUG(5,(" = %s\n", user_name)); + return 0x0; + } + + DEBUG(5,(" none mapped\n")); + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_group_rid + ********************************************************************/ +uint32 lookup_group_rid(char *group_name, uint32 *rid) +{ + char *grp_name; + int i = -1; /* start do loop at -1 */ + + do /* find, if it exists, a group rid for the group name*/ + { + i++; + (*rid) = domain_group_rids[i].rid; + grp_name = domain_group_rids[i].name; + + } while (grp_name != NULL && !strequal(grp_name, group_name)); + + return (grp_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_alias_rid + ********************************************************************/ +uint32 lookup_alias_rid(char *alias_name, uint32 *rid) +{ + char *als_name; + int i = -1; /* start do loop at -1 */ + + do /* find, if it exists, a alias rid for the alias name*/ + { + i++; + (*rid) = builtin_alias_rids[i].rid; + als_name = builtin_alias_rids[i].name; + + } while (als_name != NULL && !strequal(als_name, alias_name)); + + return (als_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; +} + +/******************************************************************* + lookup_user_rid + ********************************************************************/ +uint32 lookup_user_rid(char *user_name, uint32 *rid) +{ + struct sam_passwd *sam_pass; + (*rid) = 0; + + /* find the user account */ + become_root(True); + sam_pass = getsam21pwnam(user_name); + unbecome_root(True); + + if (sam_pass != NULL) + { + (*rid) = sam_pass->user_rid; + return 0x0; + } + + return 0xC0000000 | NT_STATUS_NONE_MAPPED; +} diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index e97ae1ee6e..658cadc625 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -46,7 +46,7 @@ static void create_wks_info_100(WKS_INFO_100 *inf) pstrcpy (domain , lp_workgroup()); strupper(domain); - make_wks_info_100(inf, + init_wks_info_100(inf, 0x000001f4, /* platform id info */ lp_major_announce_version(), lp_minor_announce_version(), @@ -69,7 +69,7 @@ static void wks_reply_query_info(WKS_Q_QUERY_INFO *q_u, DEBUG(5,("wks_query_info: %d\n", __LINE__)); create_wks_info_100(&wks100); - make_wks_r_query_info(&r_u, q_u->switch_value, &wks100, status); + init_wks_r_query_info(&r_u, q_u->switch_value, &wks100, status); /* store the response in the SMB stream */ wks_io_r_query_info("", &r_u, rdata, 0); @@ -80,7 +80,7 @@ static void wks_reply_query_info(WKS_Q_QUERY_INFO *q_u, /******************************************************************* api_wks_query_info ********************************************************************/ -static void api_wks_query_info( rpcsrv_struct *p, prs_struct *data, +static BOOL api_wks_query_info( uint16 vuid, prs_struct *data, prs_struct *rdata ) { WKS_Q_QUERY_INFO q_u; @@ -90,6 +90,8 @@ static void api_wks_query_info( rpcsrv_struct *p, prs_struct *data, /* construct reply. always indicate success */ wks_reply_query_info(&q_u, rdata, 0x0); + + return True; } @@ -105,7 +107,7 @@ struct api_struct api_wks_cmds[] = /******************************************************************* receives a wkssvc pipe and responds. ********************************************************************/ -BOOL api_wkssvc_rpc(rpcsrv_struct *p, prs_struct *data) +BOOL api_wkssvc_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_wkssvc_rpc", api_wks_cmds, data); } -- cgit From 32a965e09ce4befe971855e11e1fb5ceb51a9ed1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Dec 1999 13:35:20 +0000 Subject: 2nd phase of head branch sync with SAMBA_2_0 - this delets all the files that were in the head branch but weren't in SAMBA_2_0 (This used to be commit d7b208786590b5a28618590172b8d523627dda09) --- source3/rpc_server/srv_brs.c | 98 - source3/rpc_server/srv_sid.c | 22 - source3/rpc_server/srv_spoolss.c | 3781 -------------------------------------- source3/rpc_server/srv_svcctl.c | 388 ---- 4 files changed, 4289 deletions(-) delete mode 100644 source3/rpc_server/srv_brs.c delete mode 100644 source3/rpc_server/srv_sid.c delete mode 100755 source3/rpc_server/srv_spoolss.c delete mode 100644 source3/rpc_server/srv_svcctl.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_brs.c b/source3/rpc_server/srv_brs.c deleted file mode 100644 index c9abab20be..0000000000 --- a/source3/rpc_server/srv_brs.c +++ /dev/null @@ -1,98 +0,0 @@ - -/* - * Unix SMB/Netbios implementation. - * Version 1.9. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1999, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1999, - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -#include "includes.h" -#include "nterr.h" - -extern int DEBUGLEVEL; -extern pstring global_myname; - - -/******************************************************************* - create_brs_info_100 - ********************************************************************/ -static void create_brs_info_100(BRS_INFO_100 *inf) -{ - DEBUG(5,("create_brs_info_100: %d\n", __LINE__)); - - make_brs_info_100(inf); -} - -/******************************************************************* - brs_reply_query_info - - only supports info level 100 at the moment. - - ********************************************************************/ -static void brs_reply_query_info(BRS_Q_QUERY_INFO *q_u, - prs_struct *rdata, - int status) -{ - BRS_R_QUERY_INFO r_u; - BRS_INFO_100 brs100; - - DEBUG(5,("brs_query_info: %d\n", __LINE__)); - - create_brs_info_100(&brs100); - make_brs_r_query_info(&r_u, q_u->switch_value1, &brs100, status); - - /* store the response in the SMB stream */ - brs_io_r_query_info("", &r_u, rdata, 0); - - DEBUG(5,("brs_query_info: %d\n", __LINE__)); -} - -/******************************************************************* - api_brs_query_info - ********************************************************************/ -static void api_brs_query_info( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) -{ - BRS_Q_QUERY_INFO q_u; - - /* grab the net share enum */ - brs_io_q_query_info("", &q_u, data, 0); - - /* construct reply. always indicate success */ - brs_reply_query_info(&q_u, rdata, 0x0); -} - - -/******************************************************************* - \PIPE\brssvc commands - ********************************************************************/ -struct api_struct api_brs_cmds[] = -{ - { "BRS_Q_QUERY_INFO", BRS_QUERY_INFO, api_brs_query_info }, - { NULL , 0 , NULL } -}; - -/******************************************************************* - receives a browser pipe and responds. - ********************************************************************/ -BOOL api_brs_rpc(rpcsrv_struct *p, prs_struct *data) -{ - return api_rpcTNP(p, "api_brs_rpc", api_brs_cmds, data); -} - diff --git a/source3/rpc_server/srv_sid.c b/source3/rpc_server/srv_sid.c deleted file mode 100644 index 6552e0963b..0000000000 --- a/source3/rpc_server/srv_sid.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - Unix SMB/Netbios implementation. - Version 1.9. - Samba utility functions - Copyright (C) Andrew Tridgell 1992-1998 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/* this module is retired, is is called lib/sids.c */ diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c deleted file mode 100755 index aff896edfd..0000000000 --- a/source3/rpc_server/srv_spoolss.c +++ /dev/null @@ -1,3781 +0,0 @@ -/* - * Unix SMB/Netbios implementation. - * Version 1.9. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1998, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, - * Copyright (C) Jean François Micouleau 1998-1999. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -#include "includes.h" -#include "nterr.h" - -extern int DEBUGLEVEL; -extern pstring global_myname; - -#ifndef MAX_OPEN_PRINTER_EXS -#define MAX_OPEN_PRINTER_EXS 50 -#endif - -#define PRINTER_HANDLE_IS_PRINTER 0 -#define PRINTER_HANDLE_IS_PRINTSERVER 1 - - -/* structure to store the printer handles */ -/* and a reference to what it's pointing to */ -/* and the notify info asked about */ -/* that's the central struct */ -static struct -{ - BOOL open; - BOOL document_started; - BOOL page_started; - uint32 current_jobid; - uint32 document_fd; - uint32 document_lastwritten; - pstring document_name; - pstring job_name; - POLICY_HND printer_hnd; - BOOL printer_type; - union - { - fstring printername; - fstring printerservername; - } dev; - uint32 type; - uint32 access; - uint32 number_of_notify; - SPOOL_NOTIFY_OPTION_TYPE notify_info[MAX_PRINTER_NOTIFY+MAX_JOB_NOTIFY]; -} Printer[MAX_OPEN_PRINTER_EXS]; - -#define VALID_HANDLE(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PRINTER_EXS)) -#define OPEN_HANDLE(pnum) (VALID_HANDLE(pnum) && Printer[pnum].open) - -/**************************************************************************** - initialise printer handle states... -****************************************************************************/ -void init_printer_hnd(void) -{ - int i; - for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++) - { - Printer[i].open = False; - } -} - - -/**************************************************************************** - create a unique printer handle -****************************************************************************/ -static void create_printer_hnd(POLICY_HND *hnd) -{ - static uint32 prt_hnd_low = 0; - static uint32 prt_hnd_high = 0; - - if (hnd == NULL) return; - - /* i severely doubt that prt_hnd_high will ever be non-zero... */ - prt_hnd_low++; - if (prt_hnd_low == 0) prt_hnd_high++; - - SIVAL(hnd->data, 0 , 0x0); /* first bit must be null */ - SIVAL(hnd->data, 4 , prt_hnd_low ); /* second bit is incrementing */ - SIVAL(hnd->data, 8 , prt_hnd_high); /* second bit is incrementing */ - SIVAL(hnd->data, 12, time(NULL)); /* something random */ - SIVAL(hnd->data, 16, getpid()); /* something more random */ -} - -/**************************************************************************** - clear an handle -****************************************************************************/ -static void clear_handle(POLICY_HND *hnd) -{ - bzero(hnd->data, POLICY_HND_SIZE); -} - -/**************************************************************************** - find first available printer slot. creates a printer handle for you. - ****************************************************************************/ -static BOOL open_printer_hnd(POLICY_HND *hnd) -{ - int i; - - for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++) - { - if (!Printer[i].open) - { - Printer[i].open = True; - create_printer_hnd(hnd); - memcpy(&(Printer[i].printer_hnd), hnd, sizeof(*hnd)); - - DEBUG(4,("Opened printer handle[%x] ", i)); - dump_data(4, hnd->data, sizeof(hnd->data)); - return True; - } - } - DEBUG(1,("ERROR - open_printer_hnd: out of Printers Handles!\n")); - return False; -} - -/**************************************************************************** - find printer index by handle -****************************************************************************/ -static int find_printer_index_by_hnd(POLICY_HND *hnd) -{ - int i; - - for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++) - { - if (memcmp(&(Printer[i].printer_hnd), hnd, sizeof(*hnd)) == 0) - { - DEBUG(4,("Found printer handle[%x] ", i)); - dump_data(4, hnd->data, sizeof(hnd->data)); - return i; - } - } - DEBUG(3,("Whoops, Printer handle not found: ")); - dump_data(4, hnd->data, sizeof(hnd->data)); - return -1; -} - -/**************************************************************************** - set printer handle type. -****************************************************************************/ -static BOOL set_printer_hnd_accesstype(POLICY_HND *hnd, uint32 access_required) -{ - int pnum = find_printer_index_by_hnd(hnd); - - if (OPEN_HANDLE(pnum)) - { - DEBUG(4,("Setting printer access=%x (pnum=%x)\n", - access_required, pnum)); - - - - Printer[pnum].access = access_required; - return True; - } - else - { - DEBUG(4,("Error setting printer type=%x (pnum=%x)", - access_required, pnum)); - return False; - } - return False; -} - -/**************************************************************************** - set printer handle type. -****************************************************************************/ -static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername) -{ - int pnum = find_printer_index_by_hnd(hnd); - - if (OPEN_HANDLE(pnum)) - { - DEBUG(3,("Setting printer type=%s (pnum=%x)\n", printername, pnum)); - - if ( strlen(printername) < 3 ) - { - DEBUGADD(4,("A print server must have at least 1 char ! %s\n", printername)); - return False; - } - - /* check if it's \\server or \\server\printer */ - /* +2 is to skip the leading \\ */ - if (!strchr(printername+2, '\\')) - { - /* it's a print server */ - DEBUGADD(4,("Printer is a print server\n")); - Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTSERVER; - return True; - } - else - { - /* it's a printer */ - DEBUGADD(4,("Printer is a printer\n")); - Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTER; - return True; - } - } - else - { - DEBUGADD(4,("Error setting printer name %s (pnum=%x)", - printername, pnum)); - return False; - } - return False; -} - -/**************************************************************************** - set printer handle printername. -****************************************************************************/ -static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) -{ - int pnum = find_printer_index_by_hnd(hnd); - char *back; - NT_PRINTER_INFO_LEVEL printer; - int snum; - int n_services=lp_numservices(); - uint32 marche; - - if (OPEN_HANDLE(pnum)) - { - DEBUG(4,("Setting printer name=%s (len=%d) (pnum=%x)\n", - printername,strlen(printername), pnum)); - - switch (Printer[pnum].printer_type) - { - case PRINTER_HANDLE_IS_PRINTER: - back=strchr(printername+2, '\\'); - back=back+1; - DEBUGADD(5,("searching for %s (len=%d)\n", back,strlen(back))); - /* - * store the Samba share name in it - * in back we have the long printer name - * need to iterate all the snum and do a - * get_a_printer each time to find the printer - * faster to do it here than later. - */ - for (snum=0;snumprintername) == strlen(back) ) - && ( !strncasecmp(printer.info_2->printername, back, strlen(back))) - ) - { - DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); - ZERO_STRUCT(Printer[pnum].dev.printername); - strncpy(Printer[pnum].dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); - free_a_printer(printer, 2); - return True; - break; - } - free_a_printer(printer, 2); - } - } - - return False; - break; - case PRINTER_HANDLE_IS_PRINTSERVER: - ZERO_STRUCT(Printer[pnum].dev.printerservername); - strncpy(Printer[pnum].dev.printerservername, printername, strlen(printername)); - return True; - break; - default: - return False; - break; - } - } - else - { - DEBUG(0,("Error setting printer name=%s (pnum=%x)\n", - printername , pnum)); - return False; - } -} - -/**************************************************************************** - return the snum of a printer corresponding to an handle -****************************************************************************/ -static BOOL get_printer_snum(POLICY_HND *hnd, int *number) -{ - int snum; - int pnum = find_printer_index_by_hnd(hnd); - int n_services=lp_numservices(); - - if (OPEN_HANDLE(pnum)) - { - switch (Printer[pnum].printer_type) - { - case PRINTER_HANDLE_IS_PRINTER: - DEBUG(4,("short name:%s\n", Printer[pnum].dev.printername)); - for (snum=0;snumprintername), sizeof(name)-1); - - DEBUGADD(3,("checking name: %s\n",name)); - - /* now the response */ - r_u.status=0x00000000; - - printer_open = open_printer_hnd(&(r_u.handle)); - set_printer_hnd_printertype(&(r_u.handle), name); - - if ( !set_printer_hnd_printername(&(r_u.handle), name) ) - { - r_u.status=0xC0000000|NT_STATUS_ACCESS_DENIED; - } - - set_printer_hnd_accesstype(&(r_u.handle), q_u->access_required); - - - /* if there is a error free the printer entry */ - - if (r_u.status != 0x00000000) - { - int pnum; - - pnum = find_printer_index_by_hnd(&(r_u.handle)); - Printer[pnum].open=False; - clear_handle(&(r_u.handle)); - } - - spoolss_io_r_open_printer_ex("",&r_u,rdata,0); -} - -/******************************************************************** - * api_spoolss_open_printer - * - * called from the spoolss dispatcher - ********************************************************************/ -static void api_spoolss_open_printer_ex(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SPOOL_Q_OPEN_PRINTER_EX q_u; - - /* grab the spoolss open policy */ - spoolss_io_q_open_printer_ex("", &q_u, data, 0); - - /* construct reply. always indicate success */ - spoolss_reply_open_printer_ex(&q_u, rdata); -} - -/******************************************************************** - ********************************************************************/ -static BOOL getprinterdata_printer_server(fstring value, uint32 size, uint32 *type, - uint32 *numeric_data, uint8 **data, uint32 *needed) -{ - int i; - - if (!strcmp(value, "BeepEnabled")) - { - *type = 0x4; - *data = (uint8 *)malloc( 4*sizeof(uint8) ); - ZERO_STRUCTP(*data); - (*data)[0]=0x01; - (*data)[1]=0x00; - (*data)[2]=0x00; - (*data)[3]=0x00; - *numeric_data = 0x1; /* beep enabled */ - *needed = 0x4; - return True; - } - - if (!strcmp(value, "EventLog")) - { - *type = 0x4; - *data = (uint8 *)malloc( 4*sizeof(uint8) ); - ZERO_STRUCTP(*data); - (*data)[0]=0x1B; - (*data)[1]=0x00; - (*data)[2]=0x00; - (*data)[3]=0x00; - *numeric_data = 0x1B; /* Don't know ??? */ - *needed = 0x4; - return True; - } - - if (!strcmp(value, "NetPopup")) - { - *type = 0x4; - *data = (uint8 *)malloc( 4*sizeof(uint8) ); - ZERO_STRUCTP(*data); - (*data)[0]=0x01; - (*data)[1]=0x00; - (*data)[2]=0x00; - (*data)[3]=0x00; - *numeric_data = 0x1; /* popup enabled */ - *needed = 0x4; - return True; - } - - if (!strcmp(value, "MajorVersion")) - { - *type = 0x4; - *data = (uint8 *)malloc( 4*sizeof(uint8) ); - (*data)[0]=0x02; - (*data)[1]=0x00; - (*data)[2]=0x00; - (*data)[3]=0x00; - *numeric_data = 0x2; /* it's 2, period. */ - *needed = 0x4; - return True; - } - - if (!strcmp(value, "DefaultSpoolDirectory")) - { - pstring directory="You are using a Samba server"; - *type = 0x1; - *data = (uint8 *)malloc( size*sizeof(uint8) ); - ZERO_STRUCTP(*data); - - /* it's done by hand ready to go on the wire */ - for (i=0; isize?size:len); - *needed = len; - if (idata) free(idata); - /*break;*/ - /*case 4: - *numeric_data=atoi(idata); - break;*/ - /*}*/ - return (True); - } - free_a_printer(printer, 2); - } - - return (False); -} - -/******************************************************************** - * api_spoolss_reply_getprinterdata - * - * called from api_spoolss_getprinterdata - ********************************************************************/ -static void spoolss_reply_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *rdata) -{ - SPOOL_R_GETPRINTERDATA r_u; - fstring value; - BOOL found; - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - - /* - * Reminder: when it's a string, the length is in BYTES - * even if UNICODE is negociated. - * - * r_u.type is the kind of data - * 1 is a string - * 4 is a uint32 - * - * I think it's documented in MSDN somewhere in - * the registry data type (yep it's linked ...) - * - * JFM, 4/19/1999 - */ - - if (OPEN_HANDLE(pnum)) - { - r_u.size = q_u->size; - r_u.status = 0x0; - r_u.type = 0x4; - r_u.needed = 0x0; - r_u.data = NULL; - r_u.numeric_data=0x0; - - unistr2_to_ascii(value, &(q_u->valuename), sizeof(value)-1); - - if (handle_is_printserver(&(q_u->handle))) - { - found=getprinterdata_printer_server(value, r_u.size, - &(r_u.type), &(r_u.numeric_data), - &(r_u.data), &(r_u.needed)); - } - else - { - found=getprinterdata_printer(&(q_u->handle), value, r_u.size, - &(r_u.type), &(r_u.numeric_data), - &(r_u.data), &(r_u.needed)); - } - - if (found==False) - { - /* reply this param doesn't exist */ - r_u.type = 0x4; - r_u.size = 0x0; - r_u.data = NULL; - r_u.numeric_data=0x0; - r_u.needed = 0x0; - r_u.status = ERROR_INVALID_PARAMETER; - } - - spoolss_io_r_getprinterdata("", &r_u, rdata, 0); - DEBUG(3,("freeing memory\n")); - if (r_u.data) free(r_u.data); - DEBUG(3,("freeing memory:ok\n")); - } -} - -/******************************************************************** - * api_spoolss_getprinterdata - * - * called from the spoolss dispatcher - ********************************************************************/ -static void api_spoolss_getprinterdata(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_GETPRINTERDATA q_u; - - /* read the stream and fill the struct */ - spoolss_io_q_getprinterdata("", &q_u, data, 0); - - spoolss_reply_getprinterdata(&q_u,rdata); -} - -/******************************************************************** - * api_spoolss_reply_closeprinter - * - * called from api_spoolss_closeprinter - ********************************************************************/ -static void spoolss_reply_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_CLOSEPRINTER r_u; - - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - - clear_handle(&(r_u.handle)); - - if (OPEN_HANDLE(pnum)) - { - Printer[pnum].open=False; - r_u.status=0x0; - } - else - { - r_u.status= 0xC0000000 | NT_STATUS_INVALID_HANDLE; - DEBUG(3,("Error closing printer handle (pnum=%x)\n", pnum)); - } - - spoolss_io_r_closeprinter("",&r_u,rdata,0); -} - -/******************************************************************** - * api_spoolss_closeprinter - * - * called from the spoolss dispatcher - ********************************************************************/ -static void api_spoolss_closeprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_CLOSEPRINTER q_u; - - spoolss_io_q_closeprinter("", &q_u, data, 0); - - spoolss_reply_closeprinter(&q_u,rdata); -} - -/******************************************************************** - * api_spoolss_reply_rffpcnex - * - * called from api_spoolss_rffpcnex (see this to understand) - ********************************************************************/ -static void spoolss_reply_rffpcnex(SPOOL_Q_RFFPCNEX *q_u, prs_struct *rdata) -{ - SPOOL_R_RFFPCNEX r_u; - - r_u.status = 0x0000; - - spoolss_io_r_rffpcnex("",&r_u,rdata,0); -} - -/******************************************************************** - * api_spoolss_rffpcnex - * ReplyFindFirstPrinterChangeNotifyEx - * called from the spoolss dispatcher - * - * jfmxxxx: before replying OK: status=0 - * should do a rpc call to the workstation asking ReplyOpenPrinter - * have to code it, later. - * - * in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe - ********************************************************************/ -static void api_spoolss_rffpcnex(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_RFFPCNEX q_u; - - int i,j,k; - - spoolss_io_q_rffpcnex("", &q_u, data, 0); - - /* store the notify value in the printer struct */ - - i=find_printer_index_by_hnd(&(q_u.handle)); - - Printer[i].number_of_notify=q_u.option.count; - - DEBUG(3,("Copying %x notify option info\n",Printer[i].number_of_notify)); - - for (j=0;jnotify_data.data.length=strlen(temp_name); - ascii_to_unistr(data->notify_data.data.string, temp_name, sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the servicename - * jfmxxxx: it's incorrect should be long_printername - ********************************************************************/ -static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ -/* - data->notify_data.data.length=strlen(lp_servicename(snum)); - ascii_to_unistr(data->notify_data.data.string, lp_servicename(snum), sizeof(data->notify_data.data.string)-1); -*/ - data->notify_data.data.length=strlen(printer->info_2->printername); - ascii_to_unistr(data->notify_data.data.string, - printer->info_2->printername, - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the servicename - ********************************************************************/ -static void spoolss_notify_share_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(lp_servicename(snum)); - ascii_to_unistr(data->notify_data.data.string, - lp_servicename(snum), - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the port name - ********************************************************************/ -static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - /* even if it's strange, that's consistant in all the code */ - - data->notify_data.data.length=strlen(lp_servicename(snum)); - ascii_to_unistr(data->notify_data.data.string, - lp_servicename(snum), - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the printername - * jfmxxxx: it's incorrect, should be lp_printerdrivername() - * but it doesn't exist, have to see what to do - ********************************************************************/ -static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(printer->info_2->drivername); - ascii_to_unistr(data->notify_data.data.string, - printer->info_2->drivername, - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the comment - ********************************************************************/ -static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(lp_comment(snum)); - ascii_to_unistr(data->notify_data.data.string, - lp_comment(snum), - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the comment - * jfm:xxxx incorrect, have to create a new smb.conf option - * location = "Room 1, floor 2, building 3" - ********************************************************************/ -static void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(printer->info_2->location); - ascii_to_unistr(data->notify_data.data.string, - printer->info_2->location, - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the device mode - * jfm:xxxx don't to it for know but that's a real problem !!! - ********************************************************************/ -static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ -} - -/******************************************************************* - * fill a notify_info_data with the separator file name - * jfm:xxxx just return no file could add an option to smb.conf - * separator file = "separator.txt" - ********************************************************************/ -static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(printer->info_2->sepfile); - ascii_to_unistr(data->notify_data.data.string, - printer->info_2->sepfile, - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the print processor - * jfm:xxxx return always winprint to indicate we don't do anything to it - ********************************************************************/ -static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(printer->info_2->printprocessor); - ascii_to_unistr(data->notify_data.data.string, - printer->info_2->printprocessor, - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the print processor options - * jfm:xxxx send an empty string - ********************************************************************/ -static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(printer->info_2->parameters); - ascii_to_unistr(data->notify_data.data.string, - printer->info_2->parameters, - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the data type - * jfm:xxxx always send RAW as data type - ********************************************************************/ -static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(printer->info_2->datatype); - ascii_to_unistr(data->notify_data.data.string, - printer->info_2->datatype, - sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with the security descriptor - * jfm:xxxx send an null pointer to say no security desc - * have to implement security before ! - ********************************************************************/ -static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=0; - data->notify_data.data.string[0]=0x00; -} - -/******************************************************************* - * fill a notify_info_data with the attributes - * jfm:xxxx a samba printer is always shared - ********************************************************************/ -static void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0] = PRINTER_ATTRIBUTE_SHARED \ - | PRINTER_ATTRIBUTE_NETWORK \ - | PRINTER_ATTRIBUTE_RAW_ONLY ; -} - -/******************************************************************* - * fill a notify_info_data with the priority - ********************************************************************/ -static void spoolss_notify_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0] = printer->info_2->priority; -} - -/******************************************************************* - * fill a notify_info_data with the default priority - ********************************************************************/ -static void spoolss_notify_default_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0] = printer->info_2->default_priority; -} - -/******************************************************************* - * fill a notify_info_data with the start time - ********************************************************************/ -static void spoolss_notify_start_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0] = printer->info_2->starttime; -} - -/******************************************************************* - * fill a notify_info_data with the until time - ********************************************************************/ -static void spoolss_notify_until_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0] = printer->info_2->untiltime; -} - -/******************************************************************* - * fill a notify_info_data with the status - ********************************************************************/ -static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - int count; - print_queue_struct *q=NULL; - print_status_struct status; - - bzero(&status,sizeof(status)); - - count=get_printqueue(snum, NULL, &q, &status); - - data->notify_data.value[0]=(uint32) status.status; - if (q) free(q); -} - -/******************************************************************* - * fill a notify_info_data with the number of jobs queued - ********************************************************************/ -static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - print_queue_struct *q=NULL; - print_status_struct status; - - bzero(&status,sizeof(status)); - - data->notify_data.value[0]=get_printqueue(snum, NULL, &q, &status); - if (q) free(q); -} - -/******************************************************************* - * fill a notify_info_data with the average ppm - ********************************************************************/ -static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - /* always respond 8 pages per minutes */ - /* a little hard ! */ - data->notify_data.value[0] = printer->info_2->averageppm; -} - -/******************************************************************* - * fill a notify_info_data with - ********************************************************************/ -static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(queue->user); - ascii_to_unistr(data->notify_data.data.string, queue->user, sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with - ********************************************************************/ -static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0]=queue->status; -} - -/******************************************************************* - * fill a notify_info_data with - ********************************************************************/ -static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen(queue->file); - ascii_to_unistr(data->notify_data.data.string, queue->file, sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with - ********************************************************************/ -static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.data.length=strlen("En attente"); - ascii_to_unistr(data->notify_data.data.string, "En attente", sizeof(data->notify_data.data.string)-1); -} - -/******************************************************************* - * fill a notify_info_data with - ********************************************************************/ -static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0]=0x0; -} - -/******************************************************************* - * fill a notify_info_data with - ********************************************************************/ -static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0]=queue->size; -} - -/******************************************************************* - * fill a notify_info_data with - ********************************************************************/ -static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) -{ - data->notify_data.value[0]=queue->job; -} - -#define END 65535 - -struct s_notify_info_data_table notify_info_data_table[] = -{ -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", POINTER, spoolss_notify_server_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, "PRINTER_NOTIFY_PRINTER_NAME", POINTER, spoolss_notify_printer_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SHARE_NAME, "PRINTER_NOTIFY_SHARE_NAME", POINTER, spoolss_notify_share_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PORT_NAME, "PRINTER_NOTIFY_PORT_NAME", POINTER, spoolss_notify_port_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DRIVER_NAME, "PRINTER_NOTIFY_DRIVER_NAME", POINTER, spoolss_notify_driver_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_COMMENT, "PRINTER_NOTIFY_COMMENT", POINTER, spoolss_notify_comment }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_LOCATION, "PRINTER_NOTIFY_LOCATION", POINTER, spoolss_notify_location }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEVMODE, "PRINTER_NOTIFY_DEVMODE", POINTER, spoolss_notify_devmode }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SEPFILE, "PRINTER_NOTIFY_SEPFILE", POINTER, spoolss_notify_sepfile }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINT_PROCESSOR, "PRINTER_NOTIFY_PRINT_PROCESSOR", POINTER, spoolss_notify_print_processor }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PARAMETERS, "PRINTER_NOTIFY_PARAMETERS", POINTER, spoolss_notify_parameters }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DATATYPE, "PRINTER_NOTIFY_DATATYPE", POINTER, spoolss_notify_datatype }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SECURITY_DESCRIPTOR, "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", POINTER, spoolss_notify_security_desc }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_ATTRIBUTES, "PRINTER_NOTIFY_ATTRIBUTES", ONE_VALUE, spoolss_notify_attributes }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRIORITY, "PRINTER_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEFAULT_PRIORITY, "PRINTER_NOTIFY_DEFAULT_PRIORITY", ONE_VALUE, spoolss_notify_default_priority }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_START_TIME, "PRINTER_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_UNTIL_TIME, "PRINTER_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS, "PRINTER_NOTIFY_STATUS", ONE_VALUE, spoolss_notify_status }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS_STRING, "PRINTER_NOTIFY_STATUS_STRING", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_CJOBS, "PRINTER_NOTIFY_CJOBS", ONE_VALUE, spoolss_notify_cjobs }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_AVERAGE_PPM, "PRINTER_NOTIFY_AVERAGE_PPM", ONE_VALUE, spoolss_notify_average_ppm }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_PAGES, "PRINTER_NOTIFY_TOTAL_PAGES", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PAGES_PRINTED, "PRINTER_NOTIFY_PAGES_PRINTED", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_BYTES, "PRINTER_NOTIFY_TOTAL_BYTES", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_BYTES_PRINTED, "PRINTER_NOTIFY_BYTES_PRINTED", POINTER, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINTER_NAME, "JOB_NOTIFY_PRINTER_NAME", POINTER, spoolss_notify_printer_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_MACHINE_NAME, "JOB_NOTIFY_MACHINE_NAME", POINTER, spoolss_notify_server_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PORT_NAME, "JOB_NOTIFY_PORT_NAME", POINTER, spoolss_notify_port_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_USER_NAME, "JOB_NOTIFY_USER_NAME", POINTER, spoolss_notify_username }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_NOTIFY_NAME, "JOB_NOTIFY_NOTIFY_NAME", POINTER, spoolss_notify_username }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DATATYPE, "JOB_NOTIFY_DATATYPE", POINTER, spoolss_notify_datatype }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINT_PROCESSOR, "JOB_NOTIFY_PRINT_PROCESSOR", POINTER, spoolss_notify_print_processor }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PARAMETERS, "JOB_NOTIFY_PARAMETERS", POINTER, spoolss_notify_parameters }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DRIVER_NAME, "JOB_NOTIFY_DRIVER_NAME", POINTER, spoolss_notify_driver_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DEVMODE, "JOB_NOTIFY_DEVMODE", POINTER, spoolss_notify_devmode }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS, "JOB_NOTIFY_STATUS", ONE_VALUE, spoolss_notify_job_status }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS_STRING, "JOB_NOTIFY_STATUS_STRING", POINTER, spoolss_notify_job_status_string }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SECURITY_DESCRIPTOR, "JOB_NOTIFY_SECURITY_DESCRIPTOR", POINTER, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DOCUMENT, "JOB_NOTIFY_DOCUMENT", POINTER, spoolss_notify_job_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRIORITY, "JOB_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_POSITION, "JOB_NOTIFY_POSITION", ONE_VALUE, spoolss_notify_job_position }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SUBMITTED, "JOB_NOTIFY_SUBMITTED", POINTER, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_START_TIME, "JOB_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_UNTIL_TIME, "JOB_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TIME, "JOB_NOTIFY_TIME", ONE_VALUE, spoolss_notify_job_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", ONE_VALUE, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", ONE_VALUE, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_BYTES, "JOB_NOTIFY_TOTAL_BYTES", ONE_VALUE, spoolss_notify_job_size }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_BYTES_PRINTED, "JOB_NOTIFY_BYTES_PRINTED", ONE_VALUE, NULL }, -{ END, END, "", END, NULL } -}; - -/******************************************************************* -return the size of info_data structure -********************************************************************/ -uint32 size_of_notify_info_data(uint16 type, uint16 field) -{ - int i=0; - - while (notify_info_data_table[i].type != END) - { - if ( (notify_info_data_table[i].type == type ) && - (notify_info_data_table[i].field == field ) ) - { - return (notify_info_data_table[i].size); - continue; - } - i++; - } - return (65535); -} - -/******************************************************************* -return the type of notify_info_data -********************************************************************/ -BOOL type_of_notify_info_data(uint16 type, uint16 field) -{ - int i=0; - - while (notify_info_data_table[i].type != END) - { - if ( (notify_info_data_table[i].type == type ) && - (notify_info_data_table[i].field == field ) ) - { - if (notify_info_data_table[i].size == POINTER) - { - return (False); - } - else - { - return (True); - } - continue; - } - i++; - } - return (False); -} - -/**************************************************************************** -****************************************************************************/ -static int search_notify(uint16 type, uint16 field, int *value) -{ - int j; - BOOL found; - - DEBUG(4,("\tsearch_notify: in\n")); - for (j=0, found=False; found==False && notify_info_data_table[j].type != END ; j++) - { - if ( (notify_info_data_table[j].type == type ) && - (notify_info_data_table[j].field == field ) ) - { - found=True; - } - } - *value=--j; - - if ( found && (notify_info_data_table[j].fn != NULL) ) - { - DEBUG(4,("\tsearch_notify: out TRUE\n")); - return (True); - } - else - { - DEBUG(4,("\tsearch_notify: out FALSE\n")); - return (False); - } -} - -/**************************************************************************** -****************************************************************************/ -static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 field, int id) -{ - DEBUG(4,("\tconstruct_info_data: in\n")); - info_data->type = type; - info_data->field = field; - info_data->id = id; - info_data->size = size_of_notify_info_data(type, field); - info_data->enc_type = type_of_notify_info_data(type, field); - DEBUG(4,("\tconstruct_info_data: out\n")); -} - - -/******************************************************************* - * - * fill a notify_info struct with info asked - * - ********************************************************************/ -static void construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int pnum, - int snum, int i, uint32 id) -{ - - int k,j; - uint16 type; - uint16 field; - - SPOOL_NOTIFY_INFO_DATA *info_data; - print_queue_struct *queue=NULL; - NT_PRINTER_INFO_LEVEL printer; - - DEBUG(4,("construct_notify_printer_info\n")); - - info_data=&(info->data[info->count]); - - type = Printer[pnum].notify_info[i].type; - - DEBUGADD(4,("Notify number %d -> number of notify info: %d\n",i,Printer[pnum].notify_info[i].count)); - - if (!get_a_printer(&printer, 2, lp_servicename(snum))) - { - - for(k=0; kcount++; - info_data=&(info->data[info->count]); - } - } - - free_a_printer(printer, 2); - } -} - -/******************************************************************* - * - * fill a notify_info struct with info asked - * - ********************************************************************/ -static void construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, - int pnum, int snum, int i, uint32 id) -{ - - int k,j; - uint16 type; - uint16 field; - - SPOOL_NOTIFY_INFO_DATA *info_data; - NT_PRINTER_INFO_LEVEL printer; - - DEBUG(4,("construct_notify_jobs_info\n")); - info_data=&(info->data[info->count]); - - type = Printer[pnum].notify_info[i].type; - - DEBUGADD(4,("Notify number %d -> number of notify info: %d\n",i,Printer[pnum].notify_info[i].count)); - - if (!get_a_printer(&printer, 2, lp_servicename(snum))) - { - for(k=0; kcount++; - info_data=&(info->data[info->count]); - } - } - free_a_printer(printer, 2); - } -} - - -/******************************************************************* - * - * enumerate all printers on the printserver - * fill a notify_info struct with info asked - * - ********************************************************************/ -static void printserver_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) -{ - int snum; - int pnum=find_printer_index_by_hnd(hnd); - int n_services=lp_numservices(); - int i=0; - uint32 id=1; - info->count=0; - - DEBUG(4,("Enumerating printers\n")); - - for (i=0; icount=0; - - if (get_printer_snum(hnd, &snum) ) - { - for (i=0; ihandle)); - - if (OPEN_HANDLE(pnum)) - { - DEBUG(4,("Printer %x of type %x\n",pnum,Printer[pnum].printer_type)); - switch (Printer[pnum].printer_type) - { - case PRINTER_HANDLE_IS_PRINTSERVER: - printserver_notify_info(&(q_u->handle), &(r_u.info)); - break; - case PRINTER_HANDLE_IS_PRINTER: - printer_notify_info(&(q_u->handle), &(r_u.info)); - break; - } - - spoolss_io_r_rfnpcnex("", &r_u, rdata, 0); - } -} - -/******************************************************************** - * api_spoolss_rfnpcnex - * ReplyFindNextPrinterChangeNotifyEx - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_rfnpcnex(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_RFNPCNEX q_u; - - spoolss_io_q_rfnpcnex("", &q_u, data, 0); - - spoolss_reply_rfnpcnex(&q_u, rdata); -} - -/******************************************************************** - * construct_printer_info_0 - * fill a printer_info_1 struct - ********************************************************************/ -static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring servername) -{ - pstring chaine; - int count; - NT_PRINTER_INFO_LEVEL ntprinter; - - print_queue_struct *queue=NULL; - print_status_struct status; - bzero(&status,sizeof(status)); - - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0) - { - return (False); - } - - count=get_printqueue(snum, NULL, &queue, &status); - - /* the description and the name are of the form \\server\share */ - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s",servername, ntprinter.info_2->printername); - - make_unistr(&(printer->printername), chaine); - - slprintf(chaine,sizeof(chaine)-1,"\\\\%s", servername); - make_unistr(&(printer->servername), chaine); - - printer->cjobs = count; - printer->attributes = PRINTER_ATTRIBUTE_SHARED \ - | PRINTER_ATTRIBUTE_NETWORK \ - | PRINTER_ATTRIBUTE_RAW_ONLY ; - printer->unknown0 = 0x1; /* pointer */ - printer->unknown1 = 0x000A07CE; /* don't known */ - printer->unknown2 = 0x00020005; - printer->unknown3 = 0x0006000D; - printer->unknown4 = 0x02180026; - printer->unknown5 = 0x09; - printer->unknown6 = 0x36; - printer->majorversion = 0x0004; /* NT 4 */ - printer->buildversion = 0x0565; /* build 1381 */ - printer->unknown7 = 0x1; - printer->unknown8 = 0x0; - printer->unknown9 = 0x2; - printer->unknown10 = 0x3; - printer->unknown11 = 0x0; - printer->unknown12 = 0x0; - printer->unknown13 = 0x0; - printer->unknown14 = 0x1; - printer->unknown15 = 0x024a; /*586 Pentium ? */ - printer->unknown16 = 0x0; - printer->unknown17 = 0x423ed444; - printer->unknown18 = 0x0; - printer->status = status.status; - printer->unknown20 = 0x0; - printer->unknown21 = 0x0648; - printer->unknown22 = 0x0; - printer->unknown23 = 0x5; - - if (queue) free(queue); - - free_a_printer(ntprinter, 2); - return (True); -} - -/******************************************************************** - * construct_printer_info_1 - * fill a printer_info_1 struct - ********************************************************************/ -static BOOL construct_printer_info_1(PRINTER_INFO_1 *printer,int snum, pstring servername) -{ - pstring chaine; - NT_PRINTER_INFO_LEVEL ntprinter; - - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0) - { - return (False); - } - - printer->flags=PRINTER_ENUM_NAME; - - /* the description and the name are of the form \\server\share */ - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s,%s,%s",servername, - ntprinter.info_2->printername, - ntprinter.info_2->drivername, - lp_comment(snum)); - make_unistr(&(printer->description), chaine); - - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s", servername, ntprinter.info_2->printername); - make_unistr(&(printer->name), chaine); - - make_unistr(&(printer->comment), lp_comment(snum)); - - free_a_printer(ntprinter, 2); - return (True); -} - -/**************************************************************************** -****************************************************************************/ -static void construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) -{ - char adevice[32]; - char aform[32]; - NT_PRINTER_INFO_LEVEL printer; - NT_DEVICEMODE *ntdevmode; - - DEBUG(7,("construct_dev_mode\n")); - - bzero(&(devmode->devicename), 2*sizeof(adevice)); - bzero(&(devmode->formname), 2*sizeof(aform)); - - DEBUGADD(8,("getting printer characteristics\n")); - - get_a_printer(&printer, 2, lp_servicename(snum)); - ntdevmode=(printer.info_2)->devmode; - - DEBUGADD(8,("loading DEVICEMODE\n")); - snprintf(adevice, sizeof(adevice), "\\\\%s\\%s", global_myname, - printer.info_2->printername); - make_unistr(&(devmode->devicename), adevice); - - snprintf(aform, sizeof(aform), ntdevmode->formname); - make_unistr(&(devmode->formname), aform); - - devmode->specversion = ntdevmode->specversion; - devmode->driverversion = ntdevmode->driverversion; - devmode->size = ntdevmode->size; - devmode->driverextra = ntdevmode->driverextra; - devmode->fields = ntdevmode->fields; - - devmode->orientation = ntdevmode->orientation; - devmode->papersize = ntdevmode->papersize; - devmode->paperlength = ntdevmode->paperlength; - devmode->paperwidth = ntdevmode->paperwidth; - devmode->scale = ntdevmode->scale; - devmode->copies = ntdevmode->copies; - devmode->defaultsource = ntdevmode->defaultsource; - devmode->printquality = ntdevmode->printquality; - devmode->color = ntdevmode->color; - devmode->duplex = ntdevmode->duplex; - devmode->yresolution = ntdevmode->yresolution; - devmode->ttoption = ntdevmode->ttoption; - devmode->collate = ntdevmode->collate; - devmode->icmmethod = ntdevmode->icmmethod; - devmode->icmintent = ntdevmode->icmintent; - devmode->mediatype = ntdevmode->mediatype; - devmode->dithertype = ntdevmode->dithertype; - - if (ntdevmode->private != NULL) - { - devmode->private=(uint8 *)malloc(devmode->driverextra*sizeof(uint8)); - memcpy(devmode->private, ntdevmode->private, devmode->driverextra); - } - - free_a_printer(printer, 2); -} - -/******************************************************************** - * construct_printer_info_2 - * fill a printer_info_2 struct - ********************************************************************/ -static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring servername) -{ - pstring chaine; - int count; - DEVICEMODE *devmode; - NT_PRINTER_INFO_LEVEL ntprinter; - - print_queue_struct *queue=NULL; - print_status_struct status; - bzero(&status, sizeof(status)); - count=get_printqueue(snum, NULL, &queue, &status); - - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) - { - return (False); - } - - snprintf(chaine, sizeof(chaine)-1, "\\\\%s", servername); - make_unistr(&(printer->servername), chaine); /* servername*/ - - snprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", servername, ntprinter.info_2->printername); - make_unistr(&(printer->printername), chaine); /* printername*/ - - make_unistr(&(printer->sharename), lp_servicename(snum)); /* sharename */ - - make_unistr(&(printer->portname), lp_servicename(snum)); /* port */ - make_unistr(&(printer->drivername), ntprinter.info_2->drivername); /* drivername */ - - make_unistr(&(printer->comment), ntprinter.info_2->comment); /* comment */ - make_unistr(&(printer->location), ntprinter.info_2->location); /* location */ - make_unistr(&(printer->sepfile), ntprinter.info_2->sepfile); /* separator file */ - make_unistr(&(printer->printprocessor), ntprinter.info_2->printprocessor);/* print processor */ - make_unistr(&(printer->datatype), ntprinter.info_2->datatype); /* datatype */ - make_unistr(&(printer->parameters), ntprinter.info_2->parameters); /* parameters (of print processor) */ - - printer->attributes = PRINTER_ATTRIBUTE_SHARED \ - | PRINTER_ATTRIBUTE_NETWORK \ - | PRINTER_ATTRIBUTE_RAW_ONLY ; /* attributes */ - - printer->priority = ntprinter.info_2->priority; /* priority */ - printer->defaultpriority = ntprinter.info_2->default_priority; /* default priority */ - printer->starttime = ntprinter.info_2->starttime; /* starttime */ - printer->untiltime = ntprinter.info_2->untiltime; /* untiltime */ - printer->status = status.status; /* status */ - printer->cjobs = count; /* jobs */ - printer->averageppm = ntprinter.info_2->averageppm; /* average pages per minute */ - - devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE)); - ZERO_STRUCTP(devmode); - construct_dev_mode(devmode, snum, servername); - printer->devmode=devmode; - - if (queue) free(queue); - free_a_printer(ntprinter, 2); - return (True); -} - -/******************************************************************** - * enum_printer_info_1 - * glue between spoolss_reply_enumprinters and construct_printer_info_1 - ********************************************************************/ -static BOOL enum_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number) -{ - pstring servername; - - *printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1)); - DEBUG(4,("Allocated memory for ONE PRINTER_INFO_1 at [%p]\n", *printer)); - pstrcpy(servername, global_myname); - if (!construct_printer_info_1(*printer, snum, servername)) - { - free(*printer); - return (False); - } - else - { - return (True); - } -} - -/******************************************************************** - * enum_printer_info_2 - * glue between spoolss_reply_enumprinters and construct_printer_info_2 - ********************************************************************/ -static BOOL enum_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number) -{ - pstring servername; - - *printer=(PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2)); - DEBUG(4,("Allocated memory for ONE PRINTER_INFO_2 at [%p]\n", *printer)); - pstrcpy(servername, global_myname); - if (!construct_printer_info_2(*printer, snum, servername)) - { - free(*printer); - return (False); - } - else - { - return (True); - } -} - -/******************************************************************** - * api_spoolss_reply_enumprinters - * - * called from api_spoolss_enumprinters (see this to understand) - ********************************************************************/ -static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number) -{ - int snum; - int n_services=lp_numservices(); - *printers=NULL; - *number=0; - - for (snum=0;snumservername.buffer,2*q_u->servername.uni_str_len); - r_u.servername.buffer[q_u->servername.uni_str_len]=0x0000; - r_u.returned=0; - - switch (q_u->level) - { - case 1: - if ( (q_u->flags==PRINTER_ENUM_NAME) || (q_u->flags==PRINTER_ENUM_NETWORK) ) - /*if (is_a_printerserver(q_u->servername))*/ - enum_all_printers_info_1(&(r_u.printer.printers_1), &(r_u.returned) ); - /*else - enum_one_printer_info_1(&r_u);*/ - break; - case 2: - if ( (q_u->flags==PRINTER_ENUM_NAME) || (q_u->flags==PRINTER_ENUM_NETWORK) ) - /*if (is_a_printerserver(q_u->servername))*/ - enum_all_printers_info_2(&(r_u.printer.printers_2), &(r_u.returned) ); - /*else - enum_one_printer_info_2(&r_u);*/ - break; - case 3: /* doesn't exist */ - break; - case 4: /* can't, always on local machine */ - break; - case 5: - break; - - } - DEBUG(4,("%d printers enumerated\n", r_u.returned)); - r_u.offered=q_u->buffer.size; - r_u.level=q_u->level; - r_u.status=0x0000; - - spoolss_io_r_enumprinters("",&r_u,rdata,0); -} - -/******************************************************************** - * api_spoolss_enumprinters - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_enumprinters(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENUMPRINTERS q_u; - - spoolss_io_q_enumprinters("", &q_u, data, 0); - - spoolss_reply_enumprinters(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_getprinter(SPOOL_Q_GETPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_GETPRINTER r_u; - int snum; - pstring servername; - - pstrcpy(servername, global_myname); - - get_printer_snum(&(q_u->handle),&snum); - - switch (q_u->level) - { - case 0: - { - PRINTER_INFO_0 *printer; - - printer=(PRINTER_INFO_0 *)malloc(sizeof(PRINTER_INFO_0)); - - construct_printer_info_0(printer, snum, servername); - r_u.printer.info0=printer; - r_u.status=0x0000; - r_u.offered=q_u->offered; - r_u.level=q_u->level; - - spoolss_io_r_getprinter("",&r_u,rdata,0); - - free(printer); - - break; - } - case 1: - { - PRINTER_INFO_1 *printer; - - printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1)); - - construct_printer_info_1(printer, snum, servername); - - r_u.printer.info1=printer; - r_u.status=0x0000; - r_u.offered=q_u->offered; - r_u.level=q_u->level; - spoolss_io_r_getprinter("",&r_u,rdata,0); - - free(printer); - - break; - } - case 2: - { - PRINTER_INFO_2 *printer; - - printer=(PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2)); - construct_printer_info_2(printer, snum, servername); - - r_u.printer.info2=printer; - r_u.status=0x0000; - r_u.offered=q_u->offered; - r_u.level=q_u->level; - spoolss_io_r_getprinter("",&r_u,rdata,0); - - free_printer_info_2(printer); - - break; - } - } -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_getprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_GETPRINTER q_u; - - spoolss_io_q_getprinter("", &q_u, data, 0); - - spoolss_reply_getprinter(&q_u, rdata); -} - -/******************************************************************** - * construct_printer_driver_info_1 - * fill a construct_printer_driver_info_1 struct - ********************************************************************/ -static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, - NT_PRINTER_DRIVER_INFO_LEVEL driver, - pstring servername, fstring architecture) -{ - make_unistr( &(info->name), driver.info_3->name); -} - -static void construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, - pstring servername, fstring architecture) -{ - NT_PRINTER_INFO_LEVEL printer; - NT_PRINTER_DRIVER_INFO_LEVEL driver; - - get_a_printer(&printer, 2, lp_servicename(snum) ); - get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); - - fill_printer_driver_info_1(info, driver, servername, architecture); - - free_a_printer_driver(driver, 3); - free_a_printer(printer, 2); -} - -/******************************************************************** - * construct_printer_driver_info_2 - * fill a printer_info_2 struct - ********************************************************************/ -static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, - NT_PRINTER_DRIVER_INFO_LEVEL driver, - pstring servername, fstring architecture) -{ - pstring where; - pstring temp_driverpath; - pstring temp_datafile; - pstring temp_configfile; - fstring short_archi; - - get_short_archi(short_archi,architecture); - - snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\", servername, short_archi); - - info->version=driver.info_3->cversion; - - make_unistr( &(info->name), driver.info_3->name ); - make_unistr( &(info->architecture), architecture ); - - snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "%s%s", where, - driver.info_3->driverpath); - make_unistr( &(info->driverpath), temp_driverpath ); - - snprintf(temp_datafile, sizeof(temp_datafile)-1, "%s%s", where, - driver.info_3->datafile); - make_unistr( &(info->datafile), temp_datafile ); - - snprintf(temp_configfile, sizeof(temp_configfile)-1, "%s%s", where, - driver.info_3->configfile); - make_unistr( &(info->configfile), temp_configfile ); -} - -/******************************************************************** - * construct_printer_driver_info_2 - * fill a printer_info_2 struct - ********************************************************************/ -static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, - pstring servername, fstring architecture) -{ - NT_PRINTER_INFO_LEVEL printer; - NT_PRINTER_DRIVER_INFO_LEVEL driver; - - get_a_printer(&printer, 2, lp_servicename(snum) ); - get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); - - fill_printer_driver_info_2(info, driver, servername, architecture); - - free_a_printer_driver(driver, 3); - free_a_printer(printer, 2); -} - -/******************************************************************** - * copy a strings array and convert to UNICODE - ********************************************************************/ -static void make_unistr_array(UNISTR ***uni_array, char **char_array, char *where) -{ - int i=0; - char *v; - pstring line; - - DEBUG(6,("make_unistr_array\n")); - - for (v=char_array[i]; *v!='\0'; v=char_array[i]) - { - DEBUGADD(6,("i:%d:", i)); - DEBUGADD(6,("%s:%d:", v, strlen(v))); - - *uni_array=(UNISTR **)Realloc(*uni_array, sizeof(UNISTR *)*(i+1)); - DEBUGADD(7,("realloc:[%p],", *uni_array)); - - (*uni_array)[i]=(UNISTR *)malloc( sizeof(UNISTR) ); - DEBUGADD(7,("alloc:[%p],", (*uni_array)[i])); - - snprintf(line, sizeof(line)-1, "%s%s", where, v); - make_unistr( (*uni_array)[i], line ); - DEBUGADD(7,("copy\n")); - - i++; - } - DEBUGADD(7,("last one\n")); - - *uni_array=(UNISTR **)Realloc(*uni_array, sizeof(UNISTR *)*(i+1)); - (*uni_array)[i]=0x0000; - DEBUGADD(6,("last one:done\n")); -} - -/******************************************************************** - * construct_printer_info_3 - * fill a printer_info_3 struct - ********************************************************************/ -static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, - NT_PRINTER_DRIVER_INFO_LEVEL driver, - pstring servername, fstring architecture) -{ - pstring where; - pstring temp_driverpath; - pstring temp_datafile; - pstring temp_configfile; - pstring temp_helpfile; - fstring short_archi; - - get_short_archi(short_archi, architecture); - - snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\", servername, short_archi); - - info->version=driver.info_3->cversion; - - make_unistr( &(info->name), driver.info_3->name ); - make_unistr( &(info->architecture), architecture ); - - snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "%s%s", where, driver.info_3->driverpath); - make_unistr( &(info->driverpath), temp_driverpath ); - - snprintf(temp_datafile, sizeof(temp_datafile)-1, "%s%s", where, driver.info_3->datafile); - make_unistr( &(info->datafile), temp_datafile ); - - snprintf(temp_configfile, sizeof(temp_configfile)-1, "%s%s", where, driver.info_3->configfile); - make_unistr( &(info->configfile), temp_configfile ); - - snprintf(temp_helpfile, sizeof(temp_helpfile)-1, "%s%s", where, driver.info_3->helpfile); - make_unistr( &(info->helpfile), temp_helpfile ); - - make_unistr( &(info->monitorname), driver.info_3->monitorname ); - make_unistr( &(info->defaultdatatype), driver.info_3->defaultdatatype ); - - info->dependentfiles=NULL; - make_unistr_array(&(info->dependentfiles), driver.info_3->dependentfiles, where); -} - -/******************************************************************** - * construct_printer_info_3 - * fill a printer_info_3 struct - ********************************************************************/ -static void construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, - pstring servername, fstring architecture) -{ - NT_PRINTER_INFO_LEVEL printer; - NT_PRINTER_DRIVER_INFO_LEVEL driver; - - get_a_printer(&printer, 2, lp_servicename(snum) ); - get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); - - fill_printer_driver_info_3(info, driver, servername, architecture); - - free_a_printer_driver(driver, 3); - free_a_printer(printer, 2); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *rdata) -{ - SPOOL_R_GETPRINTERDRIVER2 r_u; - pstring servername; - fstring architecture; - int snum; - DRIVER_INFO_1 *info1=NULL; - DRIVER_INFO_2 *info2=NULL; - DRIVER_INFO_3 *info3=NULL; - - pstrcpy(servername, global_myname); - get_printer_snum(&(q_u->handle),&snum); - - r_u.offered=q_u->buf_size; - r_u.level=q_u->level; - r_u.status=0x0000; - - unistr2_to_ascii(architecture, &(q_u->architecture), sizeof(architecture) ); - - DEBUG(1,("spoolss_reply_getprinterdriver2:[%d]\n", q_u->level)); - - switch (q_u->level) - { - case 1: - { - info1=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1)); - construct_printer_driver_info_1(info1, snum, servername, architecture); - r_u.printer.info1=info1; - break; - } - case 2: - { - info2=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2)); - construct_printer_driver_info_2(info2, snum, servername, architecture); - r_u.printer.info2=info2; - break; - } - case 3: - { - info3=(DRIVER_INFO_3 *)malloc(sizeof(DRIVER_INFO_3)); - construct_printer_driver_info_3(info3, snum, servername, architecture); - r_u.printer.info3=info3; - break; - } - } - - spoolss_io_r_getprinterdriver2("",&r_u,rdata,0); - - if (info1!=NULL) free(info1); - if (info2!=NULL) free(info2); - if (info3!=NULL) - { - UNISTR **dependentfiles; - int j=0; - dependentfiles=info3->dependentfiles; - while ( dependentfiles[j] != NULL ) - { - free(dependentfiles[j]); - j++; - } - free(dependentfiles); - - free(info3); - } -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_getprinterdriver2(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_GETPRINTERDRIVER2 q_u; - - spoolss_io_q_getprinterdriver2("", &q_u, data, 0); - - spoolss_reply_getprinterdriver2(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_startpageprinter(SPOOL_Q_STARTPAGEPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_STARTPAGEPRINTER r_u; - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - Printer[pnum].page_started=True; - r_u.status=0x0; - - spoolss_io_r_startpageprinter("",&r_u,rdata,0); - } - else - { - DEBUG(3,("Error in startpageprinter printer handle (pnum=%x)\n",pnum)); - } -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_startpageprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_STARTPAGEPRINTER q_u; - - spoolss_io_q_startpageprinter("", &q_u, data, 0); - - spoolss_reply_startpageprinter(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_endpageprinter(SPOOL_Q_ENDPAGEPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_ENDPAGEPRINTER r_u; - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - Printer[pnum].page_started=False; - r_u.status=0x0; - - spoolss_io_r_endpageprinter("",&r_u,rdata,0); - } - else - { - DEBUG(3,("Error in endpageprinter printer handle (pnum=%x)\n",pnum)); - } -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_endpageprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENDPAGEPRINTER q_u; - - spoolss_io_q_endpageprinter("", &q_u, data, 0); - - spoolss_reply_endpageprinter(&q_u, rdata); -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_startdocprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_STARTDOCPRINTER q_u; - SPOOL_R_STARTDOCPRINTER r_u; - DOC_INFO_1 *info_1; - - pstring fname; - pstring tempname; - pstring datatype; - int fd = -1; - int snum; - int pnum; - - /* decode the stream and fill the struct */ - spoolss_io_q_startdocprinter("", &q_u, data, 0); - - info_1=&(q_u.doc_info_container.docinfo.doc_info_1); - r_u.status=0x0; - pnum = find_printer_index_by_hnd(&(q_u.handle)); - - /* - * a nice thing with NT is it doesn't listen to what you tell it. - * when asked to send _only_ RAW datas, it tries to send datas - * in EMF format. - * - * So I add checks like in NT Server ... - */ - - if (info_1->p_datatype != 0) - { - unistr2_to_ascii(datatype, &(info_1->docname), sizeof(datatype)); - if (strcmp(datatype, "RAW") != 0) - { - r_u.jobid=0; - r_u.status=1804; - } - } - - if (r_u.status==0 && OPEN_HANDLE(pnum)) - { - /* get the share number of the printer */ - get_printer_snum(&(q_u.handle),&snum); - - /* Create a temporary file in the printer spool directory - * and open it - */ - - slprintf(tempname,sizeof(tempname)-1, "%s/smb_print.XXXXXX",lp_pathname(snum)); - pstrcpy(fname, (char *)mktemp(tempname)); - - fd=open(fname, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR ); - DEBUG(4,("Temp spool file created: [%s]\n", fname)); - - Printer[pnum].current_jobid=fd; - pstrcpy(Printer[pnum].document_name,fname); - - unistr2_to_ascii(Printer[pnum].job_name, - &(q_u.doc_info_container.docinfo.doc_info_1.docname), - sizeof(Printer[pnum].job_name)); - - Printer[pnum].document_fd=fd; - Printer[pnum].document_started=True; - r_u.jobid=Printer[pnum].current_jobid; - r_u.status=0x0; - - } - - spoolss_io_r_startdocprinter("",&r_u,rdata,0); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enddocprinter(SPOOL_Q_ENDDOCPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_ENDDOCPRINTER r_u; - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - r_u.status=0x0; - - spoolss_io_r_enddocprinter("",&r_u,rdata,0); - } - else - { - DEBUG(3,("Error in enddocprinter printer handle (pnum=%x)\n",pnum)); - } -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_enddocprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENDDOCPRINTER q_u; - int pnum; - int snum; - pstring filename; - pstring filename1; - pstring job_name; - pstring syscmd; - char *tstr; - - spoolss_io_q_enddocprinter("", &q_u, data, 0); - - *syscmd=0; - - pnum = find_printer_index_by_hnd(&(q_u.handle)); - - if (OPEN_HANDLE(pnum)) - { - Printer[pnum].document_started=False; - close(Printer[pnum].document_fd); - DEBUG(4,("Temp spool file closed, printing now ...\n")); - - pstrcpy(filename1, Printer[pnum].document_name); - pstrcpy(job_name, Printer[pnum].job_name); - - get_printer_snum(&(q_u.handle),&snum); - - /* copy the command into the buffer for extensive meddling. */ - StrnCpy(syscmd, lp_printcommand(snum), sizeof(pstring) - 1); - - /* look for "%s" in the string. If there is no %s, we cannot print. */ - if (!strstr(syscmd, "%s") && !strstr(syscmd, "%f")) - { - DEBUG(2,("WARNING! No placeholder for the filename in the print command for service %s!\n", SERVICE(snum))); - } - - if (strstr(syscmd,"%s")) - { - pstrcpy(filename,filename1); - string_sub(syscmd, "%s", filename); - } - - string_sub(syscmd, "%f", filename1); - - /* Does the service have a printername? If not, make a fake and empty */ - /* printer name. That way a %p is treated sanely if no printer */ - /* name was specified to replace it. This eventuality is logged. */ - tstr = lp_printername(snum); - if (tstr == NULL || tstr[0] == '\0') - { - DEBUG(3,( "No printer name - using %s.\n", SERVICE(snum))); - tstr = SERVICE(snum); - } - - string_sub(syscmd, "%p", tstr); - - /* If the lpr command support the 'Job' option replace here */ - string_sub(syscmd, "%j", job_name); - - if ( *syscmd != '\0') - { - int ret = smbrun(syscmd, NULL, False); - DEBUG(3,("Running the command `%s' gave %d\n", syscmd, ret)); - } - else - DEBUG(0,("Null print command?\n")); - - lpq_reset(snum); - } - - spoolss_reply_enddocprinter(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_writeprinter(SPOOL_Q_WRITEPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_WRITEPRINTER r_u; - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - r_u.buffer_written=Printer[pnum].document_lastwritten; - r_u.status=0x0; - - spoolss_io_r_writeprinter("",&r_u,rdata,0); - } - else - { - DEBUG(3,("Error in writeprinter printer handle (pnum=%x)\n",pnum)); - } -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void api_spoolss_writeprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_WRITEPRINTER q_u; - int pnum; - int fd; - int size; - spoolss_io_q_writeprinter("", &q_u, data, 0); - - pnum = find_printer_index_by_hnd(&(q_u.handle)); - - if (OPEN_HANDLE(pnum)) - { - fd=Printer[pnum].document_fd; - size=write(fd, q_u.buffer, q_u.buffer_size); - if (q_u.buffer) free(q_u.buffer); - Printer[pnum].document_lastwritten=size; - } - - spoolss_reply_writeprinter(&q_u, rdata); -} - -/******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ -static void control_printer(POLICY_HND handle, uint32 command) -{ - int pnum; - int snum; - pnum = find_printer_index_by_hnd(&(handle)); - - if ( get_printer_snum(&handle, &snum) ) - { - switch (command) - { - case PRINTER_CONTROL_PAUSE: - /* pause the printer here */ - status_printqueue(NULL, snum, LPSTAT_STOPPED); - break; - - case PRINTER_CONTROL_RESUME: - case PRINTER_CONTROL_UNPAUSE: - /* UN-pause the printer here */ - status_printqueue(NULL, snum, LPSTAT_OK); - break; - case PRINTER_CONTROL_PURGE: - /* Envoi des dragées FUCA dans l'imprimante */ - break; - } - } -} - -/******************************************************************** - * called by spoolss_api_setprinter - * when updating a printer description - ********************************************************************/ -static void update_printer(POLICY_HND handle, uint32 level, - SPOOL_PRINTER_INFO_LEVEL info, DEVICEMODE *devmode) -{ - int pnum; - int snum; - NT_PRINTER_INFO_LEVEL printer; - NT_DEVICEMODE *nt_devmode; - - nt_devmode=NULL; - - DEBUG(8,("update_printer\n")); - - if (level!=2) - { - DEBUG(0,("Send a mail to samba-bugs@samba.org\n")); - DEBUGADD(0,("with the following message: update_printer: level!=2\n")); - return; - } - - pnum = find_printer_index_by_hnd(&handle); - - if ( get_printer_snum(&handle, &snum) ) - { - get_a_printer(&printer, level, lp_servicename(snum)); - - DEBUGADD(8,("Converting info_2 struct\n")); - convert_printer_info(info, &printer, level); - - if ((info.info_2)->devmode_ptr != 0) - { - /* we have a valid devmode - convert it and link it*/ - - /* the nt_devmode memory is already alloced - * while doing the get_a_printer call - * but the devmode private part is not - * it's done by convert_devicemode - */ - DEBUGADD(8,("Converting the devicemode struct\n")); - nt_devmode=printer.info_2->devmode; - - init_devicemode(nt_devmode); - - convert_devicemode(*devmode, nt_devmode); - - /* now clear the memory used in - * the RPC parsing routine - */ - if (devmode->private != NULL) - free(devmode->private); - free(devmode); - } - else - { - if (printer.info_2->devmode != NULL) - { - free(printer.info_2->devmode); - } - printer.info_2->devmode=NULL; - } - - add_a_printer(printer, level); - free_a_printer(printer, level); - } -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_setprinter(SPOOL_Q_SETPRINTER *q_u, prs_struct *rdata) -{ - SPOOL_R_SETPRINTER r_u; - - /* - Let's the sun shine !!! - Always respond everything is alright - */ - - r_u.status=0x0; - - spoolss_io_r_setprinter("",&r_u,rdata,0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_setprinter(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_SETPRINTER q_u; - int pnum; - spoolss_io_q_setprinter("", &q_u, data, 0); - - pnum = find_printer_index_by_hnd(&(q_u.handle)); - - if (OPEN_HANDLE(pnum)) - { - /* check the level */ - switch (q_u.level) - { - case 0: - control_printer(q_u.handle, q_u.command); - break; - case 2: - update_printer(q_u.handle, q_u.level, q_u.info, q_u.devmode); - break; - } - } - spoolss_reply_setprinter(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_fcpn(SPOOL_Q_FCPN *q_u, prs_struct *rdata) -{ - SPOOL_R_FCPN r_u; - - r_u.status=0x0; - - spoolss_io_r_fcpn("",&r_u,rdata,0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_fcpn(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_FCPN q_u; - - spoolss_io_q_fcpn("", &q_u, data, 0); - - spoolss_reply_fcpn(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_addjob(SPOOL_Q_ADDJOB *q_u, prs_struct *rdata) -{ - SPOOL_R_ADDJOB r_u; - - r_u.status=0x0; - - spoolss_io_r_addjob("",&r_u,rdata,0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_addjob(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ADDJOB q_u; - - spoolss_io_q_addjob("", &q_u, data, 0); - - spoolss_reply_addjob(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/**************************************************************************** -****************************************************************************/ -static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, - int position, int snum) -{ - pstring temp_name; - - struct tm *t; - time_t unixdate = time(NULL); - - t=gmtime(&unixdate); - snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); - - job_info->jobid=queue->job; - make_unistr(&(job_info->printername), lp_servicename(snum)); - make_unistr(&(job_info->machinename), temp_name); - make_unistr(&(job_info->username), queue->user); - make_unistr(&(job_info->document), queue->file); - make_unistr(&(job_info->datatype), "RAW"); - make_unistr(&(job_info->text_status), ""); - job_info->status=queue->status; - job_info->priority=queue->priority; - job_info->position=position; - job_info->totalpages=0; - job_info->pagesprinted=0; - - make_systemtime(&(job_info->submitted), t); -} - -/**************************************************************************** -****************************************************************************/ -static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, - int position, int snum) -{ - pstring temp_name; - DEVICEMODE *devmode; - NT_PRINTER_INFO_LEVEL ntprinter; - pstring chaine; - - struct tm *t; - time_t unixdate = time(NULL); - - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) - { - return (False); - } - - t=gmtime(&unixdate); - snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); - - job_info->jobid=queue->job; - - snprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", global_myname, ntprinter.info_2->printername); - make_unistr(&(job_info->printername), chaine); - - make_unistr(&(job_info->machinename), temp_name); - make_unistr(&(job_info->username), queue->user); - make_unistr(&(job_info->document), queue->file); - make_unistr(&(job_info->notifyname), queue->user); - make_unistr(&(job_info->datatype), "RAW"); - make_unistr(&(job_info->printprocessor), "winprint"); - make_unistr(&(job_info->parameters), ""); - make_unistr(&(job_info->text_status), ""); - -/* and here the security descriptor */ - - job_info->status=queue->status; - job_info->priority=queue->priority; - job_info->position=position; - job_info->starttime=0; - job_info->untiltime=0; - job_info->totalpages=0; - job_info->size=queue->size; - make_systemtime(&(job_info->submitted), t); - job_info->timeelapsed=0; - job_info->pagesprinted=0; - - devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE)); - ZERO_STRUCTP(devmode); - construct_dev_mode(devmode, snum, global_myname); - job_info->devmode=devmode; - - free_a_printer(ntprinter, 2); - return (True); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enumjobs(SPOOL_Q_ENUMJOBS *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMJOBS r_u; - int snum; - int count; - int i; - print_queue_struct *queue=NULL; - print_status_struct status; - JOB_INFO_1 *job_info_1=NULL; - JOB_INFO_2 *job_info_2=NULL; - - DEBUG(4,("spoolss_reply_enumjobs\n")); - - bzero(&status,sizeof(status)); - - r_u.offered=q_u->buf_size; - - - if (get_printer_snum(&(q_u->handle), &snum)) - { - count=get_printqueue(snum, NULL, &queue, &status); - r_u.numofjobs=0; - - r_u.level=q_u->level; - - DEBUG(4,("count:[%d], status:[%d], [%s]\n", count, status.status, status.message)); - - switch (r_u.level) - { - case 1: - { - for (i=0; ihandle), &snum)) - { - count=get_printqueue(snum, NULL, &queue, &status); - while ( (ijobid == queue[i].job ) - { - found=True; - } - i++; - } - - if (found==True) - { - switch (q_u->command) - { - case JOB_CONTROL_CANCEL: - case JOB_CONTROL_DELETE: - { - del_printqueue(NULL, snum, q_u->jobid); - break; - } - case JOB_CONTROL_PAUSE: - { - status_printjob(NULL, snum, q_u->jobid, LPQ_PAUSED); - break; - } - case JOB_CONTROL_RESUME: - { - status_printjob(NULL, snum, q_u->jobid, LPQ_QUEUED); - break; - } - } - } - } - r_u.status=0x0; - spoolss_io_r_setjob("",&r_u,rdata,0); - if (queue) free(queue); - -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_setjob(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_SETJOB q_u; - - spoolss_io_q_setjob("", &q_u, data, 0); - - spoolss_reply_setjob(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMPRINTERDRIVERS r_u; - NT_PRINTER_DRIVER_INFO_LEVEL driver; - int count; - int i; - fstring *list; - DRIVER_INFO_1 *driver_info_1=NULL; - DRIVER_INFO_2 *driver_info_2=NULL; - DRIVER_INFO_3 *driver_info_3=NULL; - fstring servername; - fstring architecture; - - DEBUG(4,("spoolss_reply_enumdrivers\n")); - fstrcpy(servername, global_myname); - - unistr2_to_ascii(architecture, &(q_u->environment), sizeof(architecture)); - count=get_ntdrivers(&list, architecture); - - DEBUGADD(4,("we have: [%d] drivers on archi [%s]\n",count, architecture)); - for (i=0; ibuf_size; - r_u.numofdrivers=count; - r_u.level=q_u->level; - - switch (r_u.level) - { - case 1: - { - driver_info_1=(DRIVER_INFO_1 *)malloc(count*sizeof(DRIVER_INFO_1)); - - for (i=0; iflag=list->flag; - make_unistr(&(form->name), list->name); - form->width=list->width; - form->length=list->length; - form->left=list->left; - form->top=list->top; - form->right=list->right; - form->bottom=list->bottom; -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enumforms(SPOOL_Q_ENUMFORMS *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMFORMS r_u; - int count; - int i; - nt_forms_struct *list=NULL; - FORM_1 *forms_1=NULL; - - DEBUG(4,("spoolss_reply_enumforms\n")); - - count=get_ntforms(&list); - r_u.offered=q_u->buf_size; - r_u.numofforms=count; - r_u.level=q_u->level; - r_u.status=0x0; - - DEBUGADD(5,("Offered buffer size [%d]\n", r_u.offered)); - DEBUGADD(5,("Number of forms [%d]\n", r_u.numofforms)); - DEBUGADD(5,("Info level [%d]\n", r_u.level)); - - switch (r_u.level) - { - case 1: - { - forms_1=(FORM_1 *)malloc(count*sizeof(FORM_1)); - for (i=0; iport_name), name); - make_unistr(&(port->monitor_name), "Moniteur Local"); - make_unistr(&(port->description), "Local Port"); -#define PORT_TYPE_WRITE 1 - port->port_type=PORT_TYPE_WRITE; - port->reserved=0x0; -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enumports(SPOOL_Q_ENUMPORTS *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMPORTS r_u; - int i=0; - PORT_INFO_2 *ports_2=NULL; - int n_services=lp_numservices(); - int snum; - - DEBUG(4,("spoolss_reply_enumports\n")); - - r_u.offered=q_u->buf_size; - r_u.level=q_u->level; - r_u.status=0x0; - - switch (r_u.level) - { - case 2: - { - ports_2=(PORT_INFO_2 *)malloc(n_services*sizeof(PORT_INFO_2)); - for (snum=0; snuminfo); - info2=info->info_2; - portname=&(info2->portname); - - r_u.status=0x0; /* everything is always nice in this world */ - - StrnCpy(server_name, global_myname, strlen(global_myname) ); - unistr2_to_ascii(share_name, portname, sizeof(share_name)-1); - - slprintf(ascii_name, sizeof(ascii_name)-1, "\\\\%s\\%s", - server_name, share_name); - - printer_open = open_printer_hnd(&(r_u.handle)); - set_printer_hnd_printertype(&(r_u.handle), ascii_name); - set_printer_hnd_printername(&(r_u.handle), ascii_name); - - spoolss_io_r_addprinterex("", &r_u, rdata, 0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_addprinterex(rpcsrv_struct *p, prs_struct *data, prs_struct *rdata) -{ - SPOOL_Q_ADDPRINTEREX q_u; - NT_PRINTER_INFO_LEVEL printer; - - /* read the stream and decode */ - spoolss_io_q_addprinterex("", &q_u, data, 0); - - /* NULLify info_2 here */ - /* don't put it in convert_printer_info as it's used also with non-NULL values */ - printer.info_2=NULL; - - /* convert from UNICODE to ASCII */ - convert_printer_info(q_u.info, &printer, q_u.level); - - /* write the ASCII on disk */ - add_a_printer(printer, q_u.level); - - spoolss_reply_addprinterex(&q_u, rdata); - /* free mem used in q_u and r_u */ - - /* free_add_printer(q_u, r_u); */ -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_addprinterdriver(SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *rdata) -{ - SPOOL_R_ADDPRINTERDRIVER r_u; - - r_u.status=0x0; /* everything is always nice in this world */ - - spoolss_io_r_addprinterdriver("", &r_u, rdata, 0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_addprinterdriver(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ADDPRINTERDRIVER q_u; - NT_PRINTER_DRIVER_INFO_LEVEL driver; - - spoolss_io_q_addprinterdriver("", &q_u, data, 0); - - convert_printer_driver_info(q_u.info, &driver, q_u.level); - - add_a_printer_driver(driver, q_u.level); - - spoolss_reply_addprinterdriver(&q_u, rdata); - /* free mem used in q_u and r_u */ -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_getprinterdriverdirectory(SPOOL_Q_GETPRINTERDRIVERDIR *q_u, prs_struct *rdata) -{ - SPOOL_R_GETPRINTERDRIVERDIR r_u; - pstring chaine; - pstring long_archi; - pstring archi; - - r_u.offered=q_u->buf_size; - r_u.level=q_u->level; - r_u.status=0x0; - - unistr2_to_ascii(long_archi, &(q_u->environment), sizeof(long_archi)-1); - get_short_archi(archi, long_archi); - - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\print$\\%s", global_myname, archi); - - DEBUG(4,("printer driver directory: [%s]\n", chaine)); - - make_unistr(&(r_u.driver.driver_info_1.name), chaine); - - spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_getprinterdriverdirectory(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_GETPRINTERDRIVERDIR q_u; - - spoolss_io_q_getprinterdriverdir("", &q_u, data, 0); - - spoolss_reply_getprinterdriverdirectory(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMPRINTERDATA r_u; - NT_PRINTER_INFO_LEVEL printer; - - uint32 type; - fstring value; - uint8 *data=NULL; - - uint32 param_index; - uint32 biggest_valuesize; - uint32 biggest_datasize; - uint32 data_len; - - int pnum = find_printer_index_by_hnd(&(q_u->handle)); - int snum; - - DEBUG(5,("spoolss_reply_enumprinterdata\n")); - - if (OPEN_HANDLE(pnum)) - { - get_printer_snum(&(q_u->handle), &snum); - get_a_printer(&printer, 2, lp_servicename(snum)); - - /* The NT machine wants to know the biggest size of value and data */ - if ( (q_u->valuesize==0) && (q_u->datasize==0) ) - { - DEBUGADD(6,("Activating NT mega-hack to find sizes\n")); - - r_u.valuesize=0; - r_u.realvaluesize=0; - r_u.type=0; - r_u.datasize=0; - r_u.realdatasize=0; - r_u.status=0; - - param_index=0; - biggest_valuesize=0; - biggest_datasize=0; - - while (get_specific_param_by_index(printer, 2, param_index, value, &data, &type, &data_len)) - { - if (strlen(value) > biggest_valuesize) biggest_valuesize=strlen(value); - if (data_len > biggest_datasize) biggest_datasize=data_len; - - param_index++; - } - - /* I wrote it, I didn't designed the protocol */ - if (biggest_valuesize!=0) - { - SIVAL(&(r_u.value),0, 2*(biggest_valuesize+1) ); - } - r_u.data=(uint8 *)malloc(4*sizeof(uint8)); - SIVAL(r_u.data, 0, biggest_datasize ); - } - else - { - /* - * the value len is wrong in NT sp3 - * that's the number of bytes not the number of unicode chars - */ - - r_u.valuesize=q_u->valuesize; - r_u.datasize=q_u->datasize; - - if (get_specific_param_by_index(printer, 2, q_u->index, value, &data, &type, &data_len)) - { - make_unistr(&(r_u.value), value); - r_u.data=data; - - r_u.type=type; - - /* the length are in bytes including leading NULL */ - r_u.realvaluesize=2*(strlen(value)+1); - r_u.realdatasize=data_len; - - r_u.status=0; - } - else - { - r_u.valuesize=0; - r_u.realvaluesize=0; - r_u.datasize=0; - r_u.realdatasize=0; - r_u.type=0; - r_u.status=0x0103; /* ERROR_NO_MORE_ITEMS */ - } - } - - free_a_printer(printer, 2); - } - spoolss_io_r_enumprinterdata("", &r_u, rdata, 0); - if (r_u.data!=NULL) free(r_u.data); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_enumprinterdata(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENUMPRINTERDATA q_u; - - spoolss_io_q_enumprinterdata("", &q_u, data, 0); - - spoolss_reply_enumprinterdata(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *rdata) -{ - SPOOL_R_SETPRINTERDATA r_u; - NT_PRINTER_INFO_LEVEL printer; - NT_PRINTER_PARAM *param = NULL; - - int pnum=0; - int snum=0; - - DEBUG(5,("spoolss_reply_setprinterdata\n")); - - pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - get_printer_snum(&(q_u->handle), &snum); - get_a_printer(&printer, 2, lp_servicename(snum)); - convert_specific_param(¶m, q_u->value , q_u->type, q_u->data, q_u->real_len); - - unlink_specific_param_if_exist(printer.info_2, param); - - add_a_specific_param(printer.info_2, param); - - add_a_printer(printer, 2); - - free_a_printer(printer, 2); - } - - r_u.status = 0x0; - spoolss_io_r_setprinterdata("", &r_u, rdata, 0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_setprinterdata(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_SETPRINTERDATA q_u; - - spoolss_io_q_setprinterdata("", &q_u, data, 0); - - spoolss_reply_setprinterdata(&q_u, rdata); - - free(q_u.data); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_addform(SPOOL_Q_ADDFORM *q_u, prs_struct *rdata) -{ - SPOOL_R_ADDFORM r_u; - int pnum=0; - int count=0; - nt_forms_struct *list=NULL; - - DEBUG(5,("spoolss_reply_addform\n")); - - pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - count=get_ntforms(&list); - - add_a_form(&list, q_u->form, &count); - - write_ntforms(&list, count); - - free(list); - } - - r_u.status = 0x0; - spoolss_io_r_addform("", &r_u, rdata, 0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_addform(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ADDFORM q_u; - - spoolss_io_q_addform("", &q_u, data, 0); - - spoolss_reply_addform(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_setform(SPOOL_Q_SETFORM *q_u, prs_struct *rdata) -{ - SPOOL_R_SETFORM r_u; - int pnum=0; - int count=0; - nt_forms_struct *list=NULL; - - DEBUG(5,("spoolss_reply_setform\n")); - - pnum = find_printer_index_by_hnd(&(q_u->handle)); - - if (OPEN_HANDLE(pnum)) - { - count=get_ntforms(&list); - - update_a_form(&list, q_u->form, count); - - write_ntforms(&list, count); - - free(list); - } - r_u.status = 0x0; - spoolss_io_r_setform("", &r_u, rdata, 0); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_setform(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_SETFORM q_u; - - spoolss_io_q_setform("", &q_u, data, 0); - - spoolss_reply_setform(&q_u, rdata); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enumprintprocessors(SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMPRINTPROCESSORS r_u; - PRINTPROCESSOR_1 *info_1; - - DEBUG(5,("spoolss_reply_enumprintprocessors\n")); - - /* - * Enumerate the print processors ... - * - * Just reply with "winprint", to keep NT happy - * and I can use my nice printer checker. - */ - - r_u.status = 0x0; - r_u.offered = q_u->buf_size; - r_u.level = q_u->level; - - r_u.numofprintprocessors = 0x1; - - info_1 = (PRINTPROCESSOR_1 *)malloc(sizeof(PRINTPROCESSOR_1)); - - make_unistr(&(info_1->name), "winprint"); - - r_u.info_1=info_1; - - spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0); - - free(info_1); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_enumprintprocessors(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENUMPRINTPROCESSORS q_u; - - spoolss_io_q_enumprintprocessors("", &q_u, data, 0); - - spoolss_reply_enumprintprocessors(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_enumprintmonitors(SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *rdata) -{ - SPOOL_R_ENUMPRINTMONITORS r_u; - PRINTMONITOR_1 *info_1; - - DEBUG(5,("spoolss_reply_enumprintmonitors\n")); - - /* - * Enumerate the print monitors ... - * - * Just reply with "Local Port", to keep NT happy - * and I can use my nice printer checker. - */ - - r_u.status = 0x0; - r_u.offered = q_u->buf_size; - r_u.level = q_u->level; - - r_u.numofprintmonitors = 0x1; - - info_1 = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1)); - - make_unistr(&(info_1->name), "Local Port"); - - r_u.info_1=info_1; - - spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0); - - free(info_1); -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_enumprintmonitors(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_ENUMPRINTMONITORS q_u; - - spoolss_io_q_enumprintmonitors("", &q_u, data, 0); - - spoolss_reply_enumprintmonitors(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/**************************************************************************** -****************************************************************************/ -static void spoolss_reply_getjob(SPOOL_Q_GETJOB *q_u, prs_struct *rdata) -{ - SPOOL_R_GETJOB r_u; - int snum; - int count; - int i; - print_queue_struct *queue=NULL; - print_status_struct status; - JOB_INFO_1 *job_info_1=NULL; - JOB_INFO_2 *job_info_2=NULL; - - DEBUG(4,("spoolss_reply_getjob\n")); - - bzero(&status,sizeof(status)); - - r_u.offered=q_u->buf_size; - - if (get_printer_snum(&(q_u->handle), &snum)) - { - count=get_printqueue(snum, NULL, &queue, &status); - - r_u.level=q_u->level; - - DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", count, status.status, status.message)); - - switch (r_u.level) - { - case 1: - { - job_info_1=(JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1)); - - for (i=0; ijobid) - { - fill_job_info_1(job_info_1, &(queue[i]), i, snum); - } - } - r_u.job.job_info_1=job_info_1; - break; - } - case 2: - { - job_info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2)); - - for (i=0; ijobid) - { - fill_job_info_2(job_info_2, &(queue[i]), i, snum); - } - } - r_u.job.job_info_2=job_info_2; - break; - } - } - } - - r_u.status=0x0; - - spoolss_io_r_getjob("",&r_u,rdata,0); - switch (r_u.level) - { - case 1: - { - free(job_info_1); - break; - } - case 2: - { - free_devmode(job_info_2->devmode); - free(job_info_2); - break; - } - } - if (queue) free(queue); - -} - -/**************************************************************************** -****************************************************************************/ -static void api_spoolss_getjob(rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata) -{ - SPOOL_Q_GETJOB q_u; - - spoolss_io_q_getjob("", &q_u, data, 0); - - spoolss_reply_getjob(&q_u, rdata); - - spoolss_io_free_buffer(&(q_u.buffer)); -} - -/******************************************************************* -\pipe\spoolss commands -********************************************************************/ -struct api_struct api_spoolss_cmds[] = -{ - {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex }, - {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata }, - {"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter }, - {"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex }, - {"SPOOLSS_RFNPCNEX", SPOOLSS_RFNPCNEX, api_spoolss_rfnpcnex }, - {"SPOOLSS_ENUMPRINTERS", SPOOLSS_ENUMPRINTERS, api_spoolss_enumprinters }, - {"SPOOLSS_GETPRINTER", SPOOLSS_GETPRINTER, api_spoolss_getprinter }, - {"SPOOLSS_GETPRINTERDRIVER2", SPOOLSS_GETPRINTERDRIVER2, api_spoolss_getprinterdriver2 }, - {"SPOOLSS_STARTPAGEPRINTER", SPOOLSS_STARTPAGEPRINTER, api_spoolss_startpageprinter }, - {"SPOOLSS_ENDPAGEPRINTER", SPOOLSS_ENDPAGEPRINTER, api_spoolss_endpageprinter }, - {"SPOOLSS_STARTDOCPRINTER", SPOOLSS_STARTDOCPRINTER, api_spoolss_startdocprinter }, - {"SPOOLSS_ENDDOCPRINTER", SPOOLSS_ENDDOCPRINTER, api_spoolss_enddocprinter }, - {"SPOOLSS_WRITEPRINTER", SPOOLSS_WRITEPRINTER, api_spoolss_writeprinter }, - {"SPOOLSS_SETPRINTER", SPOOLSS_SETPRINTER, api_spoolss_setprinter }, - {"SPOOLSS_FCPN", SPOOLSS_FCPN, api_spoolss_fcpn }, - {"SPOOLSS_ADDJOB", SPOOLSS_ADDJOB, api_spoolss_addjob }, - {"SPOOLSS_ENUMJOBS", SPOOLSS_ENUMJOBS, api_spoolss_enumjobs }, - {"SPOOLSS_SCHEDULEJOB", SPOOLSS_SCHEDULEJOB, api_spoolss_schedulejob }, - {"SPOOLSS_SETJOB", SPOOLSS_SETJOB, api_spoolss_setjob }, - {"SPOOLSS_ENUMFORMS", SPOOLSS_ENUMFORMS, api_spoolss_enumforms }, - {"SPOOLSS_ENUMPORTS", SPOOLSS_ENUMPORTS, api_spoolss_enumports }, - {"SPOOLSS_ENUMPRINTERDRIVERS", SPOOLSS_ENUMPRINTERDRIVERS, api_spoolss_enumprinterdrivers }, - {"SPOOLSS_ADDPRINTEREX", SPOOLSS_ADDPRINTEREX, api_spoolss_addprinterex }, - {"SPOOLSS_ADDPRINTERDRIVER", SPOOLSS_ADDPRINTERDRIVER, api_spoolss_addprinterdriver }, - {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory }, - {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata }, - {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata }, - {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform }, - {"SPOOLSS_SETFORM", SPOOLSS_SETFORM, api_spoolss_setform }, - {"SPOOLSS_ENUMPRINTPROCESSORS", SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_enumprintprocessors }, - {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors }, - {"SPOOLSS_GETJOB", SPOOLSS_GETJOB, api_spoolss_getjob }, - { NULL, 0, NULL } -}; - -/******************************************************************* -receives a spoolss pipe and responds. -********************************************************************/ -BOOL api_spoolss_rpc(rpcsrv_struct *p, prs_struct *data) -{ - return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds, data); -} - diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c deleted file mode 100644 index 12f0bdf3b3..0000000000 --- a/source3/rpc_server/srv_svcctl.c +++ /dev/null @@ -1,388 +0,0 @@ - -/* - * Unix SMB/Netbios implementation. - * Version 1.9. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -#include "includes.h" -#include "nterr.h" - -extern int DEBUGLEVEL; - - -/******************************************************************* - svc_reply_unknown_1 - ********************************************************************/ -static void svc_reply_close(SVC_Q_CLOSE *q_r, - prs_struct *rdata) -{ - SVC_R_CLOSE r_u; - - /* set up the REG unknown_1 response */ - bzero(r_u.pol.data, POL_HND_SIZE); - - /* close the policy handle */ - if (close_policy_hnd(&(q_r->pol))) - { - r_u.status = 0; - } - else - { - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_INVALID; - } - - DEBUG(5,("svc_unknown_1: %d\n", __LINE__)); - - /* store the response in the SMB stream */ - svc_io_r_close("", &r_u, rdata, 0); - - DEBUG(5,("svc_unknown_1: %d\n", __LINE__)); -} - -/******************************************************************* - api_svc_close - ********************************************************************/ -static void api_svc_close( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) -{ - SVC_Q_CLOSE q_r; - svc_io_q_close("", &q_r, data, 0); - svc_reply_close(&q_r, rdata); -} - - -/******************************************************************* - svc_reply_open_service - ********************************************************************/ -static void svc_reply_open_service(SVC_Q_OPEN_SERVICE *q_u, - prs_struct *rdata) -{ - uint32 status = 0; - POLICY_HND pol; - SVC_R_OPEN_SERVICE r_u; - fstring name; - - DEBUG(5,("svc_open_service: %d\n", __LINE__)); - - if (status == 0x0 && find_policy_by_hnd(&q_u->scman_pol) == -1) - { - status = 0xC000000 | NT_STATUS_INVALID_HANDLE; - } - - if (status == 0x0 && !open_policy_hnd(&pol)) - { - status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ - } - - unistr2_to_ascii(name, &q_u->uni_svc_name, sizeof(name)-1); - - if (status == 0x0) - { - DEBUG(5,("svc_open_service: %s\n", name)); - /* lkcl XXXX do a check on the name, here */ - } - - if (status == 0x0 && !set_policy_reg_name(&pol, name)) - { - status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ - } - - make_svc_r_open_service(&r_u, &pol, status); - - /* store the response in the SMB stream */ - svc_io_r_open_service("", &r_u, rdata, 0); - - DEBUG(5,("svc_open_service: %d\n", __LINE__)); -} - -/******************************************************************* - api_svc_open_service - ********************************************************************/ -static void api_svc_open_service( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) -{ - SVC_Q_OPEN_SERVICE q_u; - svc_io_q_open_service("", &q_u, data, 0); - svc_reply_open_service(&q_u, rdata); -} - -/******************************************************************* - svc_reply_start_service - ********************************************************************/ -static void svc_reply_start_service(SVC_Q_START_SERVICE *q_s, - prs_struct *rdata) -{ - SVC_R_START_SERVICE r_s; - - DEBUG(5,("svc_start_service: %d\n", __LINE__)); - - r_s.status = 0x0; - - if (find_policy_by_hnd(&q_s->pol) == -1) - { - r_s.status = 0xC000000 | NT_STATUS_INVALID_HANDLE; - } - - /* start the service here */ - - /* store the response in the SMB stream */ - svc_io_r_start_service("", &r_s, rdata, 0); - - DEBUG(5,("svc_start_service: %d\n", __LINE__)); -} - -/******************************************************************* - api_svc_start_service - ********************************************************************/ -static void api_svc_start_service( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) -{ - SVC_Q_START_SERVICE q_u; - svc_io_q_start_service("", &q_u, data, 0); - svc_reply_start_service(&q_u, rdata); -} - -/******************************************************************* - svc_reply_open_sc_man - ********************************************************************/ -static void svc_reply_open_sc_man(SVC_Q_OPEN_SC_MAN *q_u, - prs_struct *rdata) -{ - uint32 status = 0; - POLICY_HND pol; - SVC_R_OPEN_SC_MAN r_u; - fstring name; - - DEBUG(5,("svc_open_sc_man: %d\n", __LINE__)); - - if (status == 0x0 && !open_policy_hnd(&pol)) - { - status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ - } - - unistr2_to_ascii(name, &q_u->uni_srv_name, sizeof(name)-1); - - if (status == 0x0) - { - DEBUG(5,("svc_open_sc_man: %s\n", name)); - /* lkcl XXXX do a check on the name, here */ - } - - if (status == 0x0 && !set_policy_reg_name(&pol, name)) - { - status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ - } - - make_svc_r_open_sc_man(&r_u, &pol, status); - - /* store the response in the SMB stream */ - svc_io_r_open_sc_man("", &r_u, rdata, 0); - - DEBUG(5,("svc_open_sc_man: %d\n", __LINE__)); -} - -/******************************************************************* - api_svc_open_sc_man - ********************************************************************/ -static void api_svc_open_sc_man( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) -{ - SVC_Q_OPEN_SC_MAN q_u; - svc_io_q_open_sc_man("", &q_u, data, 0); - svc_reply_open_sc_man(&q_u, rdata); -} - -static char *dummy_services[] = -{ - "imapd", - "popd", - "smbd", - "nmbd", - "httpd", - "inetd", - "syslogd", - NULL -}; - -/******************************************************************* - svc_reply_enum_svcs_status - ********************************************************************/ -static void svc_reply_enum_svcs_status(SVC_Q_ENUM_SVCS_STATUS *q_u, - prs_struct *rdata) -{ - uint32 dos_status = 0; - SVC_R_ENUM_SVCS_STATUS r_u; - ENUM_SRVC_STATUS *svcs = NULL; - int num_svcs = 0; - int buf_size = 0; - int i = get_enum_hnd(&q_u->resume_hnd); - uint32 resume_hnd = 0; - int max_buf_size = 0x10000; - - ZERO_STRUCT(r_u); - - DEBUG(5,("svc_enum_svcs_status: %d\n", __LINE__)); - - if (dos_status == 0x0 && find_policy_by_hnd(&q_u->pol) == -1) - { - dos_status = 0xC000000 | NT_STATUS_INVALID_HANDLE; - } - - if (dos_status == 0x0) - { - DEBUG(5,("svc_enum_svcs_status:\n")); - while (dummy_services[i] != NULL) - { - ENUM_SRVC_STATUS *svc = NULL; - - buf_size += strlen(dummy_services[i] + 1) * 2; - buf_size += 9 * sizeof(uint32); - - DEBUG(10,("buf_size: %d q_u->buf_size: %d\n", - buf_size, q_u->buf_size)); - - if (buf_size >= max_buf_size) - { - resume_hnd = i; - break; - } - - if (buf_size > q_u->buf_size) - { - dos_status = ERRmoredata; - break; - } - - num_svcs++; - svcs = Realloc(svcs, num_svcs * sizeof(ENUM_SRVC_STATUS)); - if (svcs == NULL) - { - dos_status = ERRnomem; - num_svcs = 0; - break; - } - - svc = &svcs[num_svcs-1]; - ZERO_STRUCTP(svc); - - make_unistr(&svc->uni_srvc_name, dummy_services[i]); - make_unistr(&svc->uni_disp_name, dummy_services[i]); - - DEBUG(10,("show service: %s\n", dummy_services[i])); - i++; - } - } - - /* - * check for finished condition: no resume handle and last buffer fits - */ - - if (resume_hnd == 0 && buf_size <= q_u->buf_size) - { - /* this indicates, along with resume_hnd of 0, an end. */ - max_buf_size = 0; - } - - make_svc_r_enum_svcs_status(&r_u, svcs, max_buf_size, num_svcs, resume_hnd, dos_status); - - /* store the response in the SMB stream */ - svc_io_r_enum_svcs_status("", &r_u, rdata, 0); - - if (svcs != NULL) - { - free(svcs); - } - - DEBUG(5,("svc_enum_svcs_status: %d\n", __LINE__)); -} - -/******************************************************************* - api_svc_enum_svcs_status - ********************************************************************/ -static void api_svc_enum_svcs_status( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) -{ - SVC_Q_ENUM_SVCS_STATUS q_u; - svc_io_q_enum_svcs_status("", &q_u, data, 0); - svc_reply_enum_svcs_status(&q_u, rdata); -} - -/******************************************************************* - svc_reply_query_disp_name - ********************************************************************/ -static void svc_reply_query_disp_name(SVC_Q_QUERY_DISP_NAME *q_u, - prs_struct *rdata) -{ - SVC_R_QUERY_DISP_NAME r_u; - fstring svc_name; - uint32 status = 0; - - DEBUG(5,("svc_query_disp_name: %d\n", __LINE__)); - - if (find_policy_by_hnd(&q_u->scman_pol) == -1) - { - status = 0xC000000 | NT_STATUS_INVALID_HANDLE; - } - - /* for now display name = service name */ - unistr2_to_ascii(svc_name, &q_u->uni_svc_name, sizeof(svc_name)-1); - make_svc_r_query_disp_name(&r_u, svc_name, status); - - /* store the response in the SMB stream */ - svc_io_r_query_disp_name("", &r_u, rdata, 0); - - DEBUG(5,("svc_query_disp_name: %d\n", __LINE__)); -} - -/******************************************************************* - api_svc_query_disp_name - ********************************************************************/ -static void api_svc_query_disp_name( rpcsrv_struct *p, prs_struct *data, - prs_struct *rdata ) -{ - SVC_Q_QUERY_DISP_NAME q_u; - svc_io_q_query_disp_name("", &q_u, data, 0); - svc_reply_query_disp_name(&q_u, rdata); -} - -/******************************************************************* - array of \PIPE\svcctl operations - ********************************************************************/ -static struct api_struct api_svc_cmds[] = -{ - { "SVC_CLOSE" , SVC_CLOSE , api_svc_close }, - { "SVC_OPEN_SC_MAN" , SVC_OPEN_SC_MAN , api_svc_open_sc_man }, - { "SVC_OPEN_SERVICE" , SVC_OPEN_SERVICE , api_svc_open_service }, - { "SVC_ENUM_SVCS_STATUS", SVC_ENUM_SVCS_STATUS, api_svc_enum_svcs_status }, - { "SVC_QUERY_DISP_NAME" , SVC_QUERY_DISP_NAME , api_svc_query_disp_name }, - { "SVC_START_SERVICE" , SVC_START_SERVICE , api_svc_start_service }, - { NULL , 0 , NULL } -}; - -/******************************************************************* - receives a svcctl pipe and responds. - ********************************************************************/ -BOOL api_svcctl_rpc(rpcsrv_struct *p, prs_struct *data) -{ - return api_rpcTNP(p, "api_svc_rpc", api_svc_cmds, data); -} - -- cgit From fbd17c8dafeefac788f4bc1c41045726825f513f Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Mon, 3 Jan 2000 19:19:48 +0000 Subject: simple mods to add msrpc pipe redirection. default behaviour: fall back to using internal msrpc code in smbd. (This used to be commit 8976e26d46cb991710bc77463f7f928ac00dd4d8) --- source3/rpc_server/srv_pipe.c | 1037 ++--------------------------------- source3/rpc_server/srv_pipe_hnd.c | 51 +- source3/rpc_server/srv_pipe_srv.c | 1077 +++++++++++++++++++++++++++++++++++++ 3 files changed, 1167 insertions(+), 998 deletions(-) create mode 100644 source3/rpc_server/srv_pipe_srv.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 236558ba70..98c3e90c06 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1,3 +1,4 @@ + /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -5,7 +6,6 @@ * Copyright (C) Andrew Tridgell 1992-1998 * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, * Copyright (C) Paul Ashton 1997-1998. - * Copyright (C) Jeremy Allison 1999. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,1035 +43,78 @@ extern int DEBUGLEVEL; -static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) -{ - unsigned char *hash = p->ntlmssp_hash; - unsigned char index_i = hash[256]; - unsigned char index_j = hash[257]; - int ind; - - for( ind = 0; ind < len; ind++) { - unsigned char tc; - unsigned char t; - - index_i++; - index_j += hash[index_i]; - - tc = hash[index_i]; - hash[index_i] = hash[index_j]; - hash[index_j] = tc; - - t = hash[index_i] + hash[index_j]; - data[ind] = data[ind] ^ hash[t]; - } - - hash[256] = index_i; - hash[257] = index_j; -} - /******************************************************************* - Generate the next PDU to be returned from the data in p->rdata. - We cheat here as this function doesn't handle the special auth - footers of the authenticated bind response reply. + entry point from msrpc to smb. adds data received to pdu; checks + pdu; hands pdu off to msrpc, which gets a pdu back (except in the + case of the RPC_BINDCONT pdu). ********************************************************************/ - -BOOL create_next_pdu(pipes_struct *p) -{ - RPC_HDR_RESP hdr_resp; - BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SIGN); - BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SEAL); - uint32 data_len; - uint32 data_space_available; - uint32 data_len_left; - prs_struct outgoing_pdu; - char *data; - char *data_from; - uint32 data_pos; - - memset((char *)&hdr_resp, '\0', sizeof(hdr_resp)); - - /* Change the incoming request header to a response. */ - p->hdr.pkt_type = RPC_RESPONSE; - - /* Set up rpc header flags. */ - if (p->data_sent_length == 0) - p->hdr.flags = RPC_FLG_FIRST; - else - p->hdr.flags = 0; - - /* - * Work out how much we can fit in a sigle PDU. - */ - - data_space_available = sizeof(p->current_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN; - if(p->ntlmssp_auth_validated) - data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN); - - /* - * The amount we send is the minimum of the available - * space and the amount left to send. - */ - - data_len_left = prs_offset(&p->rdata) - p->data_sent_length; - - /* - * Ensure there really is data left to send. - */ - - if(!data_len_left) { - DEBUG(0,("create_next_pdu: no data left to send !\n")); - return False; - } - - data_len = MIN(data_len_left, data_space_available); - - /* - * Set up the alloc hint. This should be the data left to - * send. - */ - - hdr_resp.alloc_hint = data_len_left; - - /* - * Set up the header lengths. - */ - - if (p->ntlmssp_auth_validated) { - p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len + - RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN; - p->hdr.auth_len = RPC_AUTH_NTLMSSP_CHK_LEN; - } else { - p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len; - p->hdr.auth_len = 0; - } - - /* - * Work out if this PDU will be the last. - */ - - if(p->data_sent_length + data_len >= prs_offset(&p->rdata)) - p->hdr.flags |= RPC_FLG_LAST; - - /* - * Init the parse struct to point at the outgoing - * data. - */ - - prs_init( &outgoing_pdu, 0, 4, MARSHALL); - prs_give_memory( &outgoing_pdu, (char *)p->current_pdu, sizeof(p->current_pdu), False); - - /* Store the header in the data stream. */ - if(!smb_io_rpc_hdr("hdr", &p->hdr, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR.\n")); - return False; - } - - if(!smb_io_rpc_hdr_resp("resp", &hdr_resp, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_RESP.\n")); - return False; - } - - /* Store the current offset. */ - data_pos = prs_offset(&outgoing_pdu); - - /* Copy the data into the PDU. */ - data_from = prs_data_p(&p->rdata) + p->data_sent_length; - - if(!prs_append_data(&outgoing_pdu, data_from, data_len)) { - DEBUG(0,("create_next_pdu: failed to copy %u bytes of data.\n", (unsigned int)data_len)); - return False; - } - - /* - * Set data to point to where we copied the data into. - */ - - data = prs_data_p(&outgoing_pdu) + data_pos; - - if (p->hdr.auth_len > 0) { - uint32 crc32 = 0; - - DEBUG(5,("create_next_pdu: sign: %s seal: %s data %d auth %d\n", - BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, p->hdr.auth_len)); - - if (auth_seal) { - crc32 = crc32_calc_buffer(data, data_len); - NTLMSSPcalc_p(p, (uchar*)data, data_len); - } - - if (auth_seal || auth_verify) { - RPC_HDR_AUTH auth_info; - - init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, NTLMSSP_AUTH_LEVEL, - (auth_verify ? RPC_HDR_AUTH_LEN : 0), (auth_verify ? 1 : 0)); - if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_AUTH.\n")); - return False; - } - } - - if (auth_verify) { - RPC_AUTH_NTLMSSP_CHK ntlmssp_chk; - char *auth_data = prs_data_p(&outgoing_pdu); - - p->ntlmssp_seq_num++; - init_rpc_auth_ntlmssp_chk(&ntlmssp_chk, NTLMSSP_SIGN_VERSION, - crc32, p->ntlmssp_seq_num++); - auth_data = prs_data_p(&outgoing_pdu) + prs_offset(&outgoing_pdu) + 4; - if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &ntlmssp_chk, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_AUTH_NTLMSSP_CHK.\n")); - return False; - } - NTLMSSPcalc_p(p, (uchar*)auth_data, RPC_AUTH_NTLMSSP_CHK_LEN - 4); - } - } - - /* - * Setup the counts for this PDU. - */ - - p->data_sent_length += data_len; - p->current_pdu_len = p->hdr.frag_len; - p->current_pdu_sent = 0; - - return True; -} - -/******************************************************************* - Process an NTLMSSP authentication response. - If this function succeeds, the user has been authenticated - and their domain, name and calling workstation stored in - the pipe struct. - The initial challenge is stored in p->challenge. - *******************************************************************/ - -static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlmssp_resp) +BOOL readwrite_pipe(pipes_struct *p, char *data, int len, + char **rdata, int *rlen) { - uchar lm_owf[24]; - uchar nt_owf[24]; - fstring user_name; - fstring unix_user_name; - fstring domain; - fstring wks; - BOOL guest_user = False; - struct smb_passwd *smb_pass = NULL; - struct passwd *pass = NULL; - uchar null_smb_passwd[16]; - uchar *smb_passwd_ptr = NULL; - - DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); - - memset(p->user_name, '\0', sizeof(p->user_name)); - memset(p->unix_user_name, '\0', sizeof(p->unix_user_name)); - memset(p->domain, '\0', sizeof(p->domain)); - memset(p->wks, '\0', sizeof(p->wks)); - - /* - * Setup an empty password for a guest user. - */ - - memset(null_smb_passwd,0,16); - - /* - * We always negotiate UNICODE. - */ - - if (IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_UNICODE)) { - fstrcpy(user_name, dos_unistrn2((uint16*)ntlmssp_resp->user, ntlmssp_resp->hdr_usr.str_str_len/2)); - fstrcpy(domain, dos_unistrn2((uint16*)ntlmssp_resp->domain, ntlmssp_resp->hdr_domain.str_str_len/2)); - fstrcpy(wks, dos_unistrn2((uint16*)ntlmssp_resp->wks, ntlmssp_resp->hdr_wks.str_str_len/2)); - } else { - fstrcpy(user_name, ntlmssp_resp->user); - fstrcpy(domain, ntlmssp_resp->domain); - fstrcpy(wks, ntlmssp_resp->wks); - } - - DEBUG(5,("user: %s domain: %s wks: %s\n", user_name, domain, wks)); - - memcpy(lm_owf, ntlmssp_resp->lm_resp, sizeof(lm_owf)); - memcpy(nt_owf, ntlmssp_resp->nt_resp, sizeof(nt_owf)); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("lm, nt owfs, chal\n")); - dump_data(100, (char *)lm_owf, sizeof(lm_owf)); - dump_data(100, (char *)nt_owf, sizeof(nt_owf)); - dump_data(100, (char *)p->challenge, 8); -#endif - - /* - * Allow guest access. Patch from Shirish Kalele . - */ - - if((strlen(user_name) == 0) && (ntlmssp_resp->hdr_lm_resp.str_str_len==0) && - (ntlmssp_resp->hdr_nt_resp.str_str_len==0)) { - - guest_user = True; - - fstrcpy(unix_user_name, lp_guestaccount(-1)); - DEBUG(100,("Null user in NTLMSSP verification. Using guest = %s\n", unix_user_name)); - - smb_passwd_ptr = null_smb_passwd; - - } else { - - /* - * Pass the user through the NT -> unix user mapping - * function. - */ - - fstrcpy(unix_user_name, user_name); - (void)map_username(unix_user_name); - - /* - * Do the length checking only if user is not NULL. - */ - - if (ntlmssp_resp->hdr_lm_resp.str_str_len == 0) - return False; - if (ntlmssp_resp->hdr_nt_resp.str_str_len == 0) - return False; - if (ntlmssp_resp->hdr_usr.str_str_len == 0) - return False; - if (ntlmssp_resp->hdr_domain.str_str_len == 0) - return False; - if (ntlmssp_resp->hdr_wks.str_str_len == 0) - return False; - - } - - /* - * Find the user in the unix password db. - */ - - if(!(pass = Get_Pwnam(unix_user_name,True))) { - DEBUG(1,("Couldn't find user '%s' in UNIX password database.\n",unix_user_name)); - return(False); - } - - if(!guest_user) { - - become_root(True); - - if(!(p->ntlmssp_auth_validated = pass_check_smb(unix_user_name, domain, - (uchar*)p->challenge, lm_owf, nt_owf, NULL))) { - DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ -failed authentication on named pipe %s.\n", domain, unix_user_name, wks, p->name )); - unbecome_root(True); - return False; - } - - if(!(smb_pass = getsmbpwnam(unix_user_name))) { - DEBUG(1,("api_pipe_ntlmssp_verify: Cannot find user %s in smb passwd database.\n", - unix_user_name)); - unbecome_root(True); - return False; - } - - unbecome_root(True); - - if (smb_pass == NULL) { - DEBUG(1,("api_pipe_ntlmssp_verify: Couldn't find user '%s' in smb_passwd file.\n", - unix_user_name)); - return(False); - } - - /* Quit if the account was disabled. */ - if((smb_pass->acct_ctrl & ACB_DISABLED) || !smb_pass->smb_passwd) { - DEBUG(1,("Account for user '%s' was disabled.\n", unix_user_name)); - return(False); - } - - if(!smb_pass->smb_nt_passwd) { - DEBUG(1,("Account for user '%s' has no NT password hash.\n", unix_user_name)); - return(False); - } - - smb_passwd_ptr = smb_pass->smb_passwd; - } - - /* - * Set up the sign/seal data. - */ + DEBUG(10,("rpc_to_smb_readwrite: len %d\n", len)); + if (write(p->m->fd, data, len) != len) { - uchar p24[24]; - NTLMSSPOWFencrypt(smb_passwd_ptr, lm_owf, p24); - { - unsigned char j = 0; - int ind; - - unsigned char k2[8]; - - memcpy(k2, p24, 5); - k2[5] = 0xe5; - k2[6] = 0x38; - k2[7] = 0xb0; - - for (ind = 0; ind < 256; ind++) - p->ntlmssp_hash[ind] = (unsigned char)ind; - - for( ind = 0; ind < 256; ind++) { - unsigned char tc; - - j += (p->ntlmssp_hash[ind] + k2[ind%8]); - - tc = p->ntlmssp_hash[ind]; - p->ntlmssp_hash[ind] = p->ntlmssp_hash[j]; - p->ntlmssp_hash[j] = tc; - } - - p->ntlmssp_hash[256] = 0; - p->ntlmssp_hash[257] = 0; - } -/* NTLMSSPhash(p->ntlmssp_hash, p24); */ - p->ntlmssp_seq_num = 0; - - } - - fstrcpy(p->user_name, user_name); - fstrcpy(p->unix_user_name, unix_user_name); - fstrcpy(p->domain, domain); - fstrcpy(p->wks, wks); - - /* - * Store the UNIX credential data (uid/gid pair) in the pipe structure. - */ - - p->uid = pass->pw_uid; - p->gid = pass->pw_gid; - - p->ntlmssp_auth_validated = True; - return True; -} - -/******************************************************************* - The switch table for the pipe names and the functions to handle them. - *******************************************************************/ - -struct api_cmd -{ - char * pipe_clnt_name; - char * pipe_srv_name; - BOOL (*fn) (pipes_struct *, prs_struct *); -}; - -static struct api_cmd api_fd_commands[] = -{ - { "lsarpc", "lsass", api_ntlsa_rpc }, - { "samr", "lsass", api_samr_rpc }, - { "srvsvc", "ntsvcs", api_srvsvc_rpc }, - { "wkssvc", "ntsvcs", api_wkssvc_rpc }, - { "NETLOGON", "lsass", api_netlog_rpc }, -#if DISABLED_IN_2_0 - { "winreg", "winreg", api_reg_rpc }, -#endif - { NULL, NULL, NULL } -}; - -/******************************************************************* - This is the client reply to our challenge for an authenticated - bind request. The challenge we sent is in p->challenge. -*******************************************************************/ - -static BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *pd) -{ - RPC_HDR_AUTHA autha_info; - RPC_AUTH_VERIFIER auth_verifier; - RPC_AUTH_NTLMSSP_RESP ntlmssp_resp; - - DEBUG(5,("api_pipe_bind_auth_resp: decode request. %d\n", __LINE__)); - - if (p->hdr.auth_len == 0) { - DEBUG(0,("api_pipe_bind_auth_resp: No auth field sent !\n")); - return False; - } - - /* - * Decode the authentication verifier response. - */ - - if(!smb_io_rpc_hdr_autha("", &autha_info, pd, 0)) { - DEBUG(0,("api_pipe_bind_auth_resp: unmarshall of RPC_HDR_AUTHA failed.\n")); - return False; - } - - if (autha_info.auth_type != NTLMSSP_AUTH_TYPE || autha_info.auth_level != NTLMSSP_AUTH_LEVEL) { - DEBUG(0,("api_pipe_bind_auth_resp: incorrect auth type (%d) or level (%d).\n", - (int)autha_info.auth_type, (int)autha_info.auth_level )); return False; } - if(!smb_io_rpc_auth_verifier("", &auth_verifier, pd, 0)) { - DEBUG(0,("api_pipe_bind_auth_resp: unmarshall of RPC_AUTH_VERIFIER failed.\n")); - return False; - } - - /* - * Ensure this is a NTLMSSP_AUTH packet type. - */ - - if (!rpc_auth_verifier_chk(&auth_verifier, "NTLMSSP", NTLMSSP_AUTH)) { - DEBUG(0,("api_pipe_bind_auth_resp: rpc_auth_verifier_chk failed.\n")); - return False; - } - - if(!smb_io_rpc_auth_ntlmssp_resp("", &ntlmssp_resp, pd, 0)) { - DEBUG(0,("api_pipe_bind_auth_resp: Failed to unmarshall RPC_AUTH_NTLMSSP_RESP.\n")); - return False; - } - - /* - * The following call actually checks the challenge/response data. - * for correctness against the given DOMAIN\user name. - */ - - if (!api_pipe_ntlmssp_verify(p, &ntlmssp_resp)) - return False; - - return True; -} - -/******************************************************************* - Marshall a bind_nak pdu. -*******************************************************************/ - -static BOOL setup_bind_nak(pipes_struct *p, prs_struct *pd) -{ - prs_struct outgoing_rpc; - RPC_HDR nak_hdr; - uint16 zero = 0; - - /* - * Marshall directly into the outgoing PDU space. We - * must do this as we need to set to the bind response - * header and are never sending more than one PDU here. - */ - - prs_init( &outgoing_rpc, 0, 4, MARSHALL); - prs_give_memory( &outgoing_rpc, (char *)p->current_pdu, sizeof(p->current_pdu), False); - - - /* - * Initialize a bind_nak header. - */ - - init_rpc_hdr(&nak_hdr, RPC_BINDNACK, RPC_FLG_FIRST | RPC_FLG_LAST, - p->hdr.call_id, RPC_HEADER_LEN + sizeof(uint16), 0); - - /* - * Marshall the header into the outgoing PDU. - */ - - if(!smb_io_rpc_hdr("", &nak_hdr, &outgoing_rpc, 0)) { - DEBUG(0,("setup_bind_nak: marshalling of RPC_HDR failed.\n")); + if ((*rlen) == 0) + { return False; } - /* - * Now add the reject reason. - */ - - if(!prs_uint16("reject code", &outgoing_rpc, 0, &zero)) - return False; - - p->data_sent_length = 0; - p->current_pdu_len = prs_offset(&outgoing_rpc); - p->current_pdu_sent = 0; - - return True; -} - -/******************************************************************* - Respond to a pipe bind request. -*******************************************************************/ - -static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) -{ - RPC_HDR_BA hdr_ba; - RPC_HDR_RB hdr_rb; - RPC_HDR_AUTH auth_info; - uint16 assoc_gid; - fstring ack_pipe_name; - prs_struct out_hdr_ba; - prs_struct out_auth; - prs_struct outgoing_rpc; - int i = 0; - int auth_len = 0; - - p->ntlmssp_auth_requested = False; - - DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); - - /* - * Try and find the correct pipe name to ensure - * that this is a pipe name we support. - */ - - for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { - if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && - api_fd_commands[i].fn != NULL) { - DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", - api_fd_commands[i].pipe_clnt_name, - api_fd_commands[i].pipe_srv_name)); - fstrcpy(p->pipe_srv_name, api_fd_commands[i].pipe_srv_name); - break; - } - } - - if (api_fd_commands[i].fn == NULL) { - DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", - p->name )); - if(!setup_bind_nak(p, pd)) - return False; - return True; - } - - /* decode the bind request */ - if(!smb_io_rpc_hdr_rb("", &hdr_rb, pd, 0)) { - DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_RB struct.\n")); + (*rdata) = (char*)Realloc((*rdata), (*rlen)); + if ((*rdata) == NULL) + { return False; } - - /* - * Check if this is an authenticated request. - */ - - if (p->hdr.auth_len != 0) { - RPC_AUTH_VERIFIER auth_verifier; - RPC_AUTH_NTLMSSP_NEG ntlmssp_neg; - - /* - * Decode the authentication verifier. - */ - - if(!smb_io_rpc_hdr_auth("", &auth_info, pd, 0)) { - DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); - return False; - } - - /* - * We only support NTLMSSP_AUTH_TYPE requests. - */ - - if(auth_info.auth_type != NTLMSSP_AUTH_TYPE) { - DEBUG(0,("api_pipe_bind_req: unknown auth type %x requested.\n", - auth_info.auth_type )); - return False; - } - - if(!smb_io_rpc_auth_verifier("", &auth_verifier, pd, 0)) { - DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); - return False; - } - - if(!strequal(auth_verifier.signature, "NTLMSSP")) { - DEBUG(0,("api_pipe_bind_req: auth_verifier.signature != NTLMSSP\n")); - return False; - } - - if(auth_verifier.msg_type != NTLMSSP_NEGOTIATE) { - DEBUG(0,("api_pipe_bind_req: auth_verifier.msg_type (%d) != NTLMSSP_NEGOTIATE\n", - auth_verifier.msg_type)); - return False; - } - - if(!smb_io_rpc_auth_ntlmssp_neg("", &ntlmssp_neg, pd, 0)) { - DEBUG(0,("api_pipe_bind_req: Failed to unmarshall RPC_AUTH_NTLMSSP_NEG.\n")); - return False; - } - - p->ntlmssp_chal_flags = SMBD_NTLMSSP_NEG_FLAGS; - p->ntlmssp_auth_requested = True; - } - - /* name has to be \PIPE\xxxxx */ - fstrcpy(ack_pipe_name, "\\PIPE\\"); - fstrcat(ack_pipe_name, p->pipe_srv_name); - - DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); - - /* - * Marshall directly into the outgoing PDU space. We - * must do this as we need to set to the bind response - * header and are never sending more than one PDU here. - */ - - prs_init( &outgoing_rpc, 0, 4, MARSHALL); - prs_give_memory( &outgoing_rpc, (char *)p->current_pdu, sizeof(p->current_pdu), False); - - /* - * Setup the memory to marshall the ba header, and the - * auth footers. - */ - - if(!prs_init(&out_hdr_ba, 1024, 4, MARSHALL)) { - DEBUG(0,("api_pipe_bind_req: malloc out_hdr_ba failed.\n")); + (*rlen) = read(p->m->fd, (*rdata), (*rlen)); + if ((*rlen) < 0) + { return False; } - - if(!prs_init(&out_auth, 1024, 4, MARSHALL)) { - DEBUG(0,("pi_pipe_bind_req: malloc out_auth failed.\n")); - prs_mem_free(&out_hdr_ba); + (*rdata) = (char*)Realloc((*rdata), (*rlen)); + if ((*rdata) == NULL) + { return False; } - - if (p->ntlmssp_auth_requested) - assoc_gid = 0x7a77; - else - assoc_gid = hdr_rb.bba.assoc_gid; - - /* - * Create the bind response struct. - */ - - init_rpc_hdr_ba(&hdr_ba, - hdr_rb.bba.max_tsize, - hdr_rb.bba.max_rsize, - assoc_gid, - ack_pipe_name, - 0x1, 0x0, 0x0, - &hdr_rb.transfer); - - /* - * and marshall it. - */ - - if(!smb_io_rpc_hdr_ba("", &hdr_ba, &out_hdr_ba, 0)) { - DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_BA failed.\n")); - goto err_exit; - } - - /* - * Now the authentication. - */ - - if (p->ntlmssp_auth_requested) { - RPC_AUTH_VERIFIER auth_verifier; - RPC_AUTH_NTLMSSP_CHAL ntlmssp_chal; - - generate_random_buffer(p->challenge, 8, False); - - /*** Authentication info ***/ - - init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, NTLMSSP_AUTH_LEVEL, RPC_HDR_AUTH_LEN, 1); - if(!smb_io_rpc_hdr_auth("", &auth_info, &out_auth, 0)) { - DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_AUTH failed.\n")); - goto err_exit; - } - - /*** NTLMSSP verifier ***/ - - init_rpc_auth_verifier(&auth_verifier, "NTLMSSP", NTLMSSP_CHALLENGE); - if(!smb_io_rpc_auth_verifier("", &auth_verifier, &out_auth, 0)) { - DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_VERIFIER failed.\n")); - goto err_exit; - } - - /* NTLMSSP challenge ***/ - - init_rpc_auth_ntlmssp_chal(&ntlmssp_chal, p->ntlmssp_chal_flags, p->challenge); - if(!smb_io_rpc_auth_ntlmssp_chal("", &ntlmssp_chal, &out_auth, 0)) { - DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_NTLMSSP_CHAL failed.\n")); - goto err_exit; - } - - /* Auth len in the rpc header doesn't include auth_header. */ - auth_len = prs_offset(&out_auth) - RPC_HDR_AUTH_LEN; - } - - /* - * Create the header, now we know the length. - */ - - init_rpc_hdr(&p->hdr, RPC_BINDACK, RPC_FLG_FIRST | RPC_FLG_LAST, - p->hdr.call_id, - RPC_HEADER_LEN + prs_offset(&out_hdr_ba) + prs_offset(&out_auth), - auth_len); - - /* - * Marshall the header into the outgoing PDU. - */ - - if(!smb_io_rpc_hdr("", &p->hdr, &outgoing_rpc, 0)) { - DEBUG(0,("pi_pipe_bind_req: marshalling of RPC_HDR failed.\n")); - goto err_exit; - } - - /* - * Now add the RPC_HDR_BA and any auth needed. - */ - - if(!prs_append_prs_data( &outgoing_rpc, &out_hdr_ba)) { - DEBUG(0,("api_pipe_bind_req: append of RPC_HDR_BA failed.\n")); - goto err_exit; - } - - if(p->ntlmssp_auth_requested && !prs_append_prs_data( &outgoing_rpc, &out_auth)) { - DEBUG(0,("api_pipe_bind_req: append of auth info failed.\n")); - goto err_exit; - } - - /* - * Setup the lengths for the initial reply. - */ - - p->data_sent_length = 0; - p->current_pdu_len = prs_offset(&outgoing_rpc); - p->current_pdu_sent = 0; - - prs_mem_free(&out_hdr_ba); - prs_mem_free(&out_auth); - return True; - - err_exit: - - prs_mem_free(&out_hdr_ba); - prs_mem_free(&out_auth); - return False; } /**************************************************************************** - Deal with sign & seal processing on an RPC request. -****************************************************************************/ - -static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) + writes data to a pipe. + ****************************************************************************/ +ssize_t write_pipe(pipes_struct *p, char *data, size_t n) { - /* - * We always negotiate the following two bits.... - */ - BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SIGN); - BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SEAL); - int data_len; - int auth_len; - uint32 old_offset; - uint32 crc32 = 0; - - auth_len = p->hdr.auth_len; + DEBUG(6,("write_pipe: %x", p->pnum)); + DEBUG(6,("name: %s open: %s len: %d", + p->name, BOOLSTR(p->open), n)); - if ((auth_len != RPC_AUTH_NTLMSSP_CHK_LEN) && auth_verify) { - DEBUG(0,("api_pipe_auth_process: Incorrect auth_len %d.\n", auth_len )); - return False; - } - - /* - * The following is that length of the data we must verify or unseal. - * This doesn't include the RPC headers or the auth_len or the RPC_HDR_AUTH_LEN - * preceeding the auth_data. - */ - - data_len = p->hdr.frag_len - RPC_HEADER_LEN - RPC_HDR_REQ_LEN - - (auth_verify ? RPC_HDR_AUTH_LEN : 0) - auth_len; - - DEBUG(5,("api_pipe_auth_process: sign: %s seal: %s data %d auth %d\n", - BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); - - if (auth_seal) { - char *data = prs_data_p(rpc_in) + RPC_HEADER_LEN + RPC_HDR_REQ_LEN; - NTLMSSPcalc_p(p, (uchar*)data, data_len); - crc32 = crc32_calc_buffer(data, data_len); - } - - old_offset = prs_offset(rpc_in); - - if (auth_seal || auth_verify) { - RPC_HDR_AUTH auth_info; - - if(!prs_set_offset(rpc_in, old_offset + data_len)) { - DEBUG(0,("api_pipe_auth_process: cannot move offset to %u.\n", - (unsigned int)old_offset + data_len )); - return False; - } - - if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, rpc_in, 0)) { - DEBUG(0,("api_pipe_auth_process: failed to unmarshall RPC_HDR_AUTH.\n")); - return False; - } - } + dump_data(50, data, n); - if (auth_verify) { - RPC_AUTH_NTLMSSP_CHK ntlmssp_chk; - char *req_data = prs_data_p(rpc_in) + prs_offset(rpc_in) + 4; - - DEBUG(5,("api_pipe_auth_process: auth %d\n", prs_offset(rpc_in) + 4)); - - /* - * Ensure we have RPC_AUTH_NTLMSSP_CHK_LEN - 4 more bytes in the - * incoming buffer. - */ - if(prs_mem_get(rpc_in, RPC_AUTH_NTLMSSP_CHK_LEN - 4) == NULL) { - DEBUG(0,("api_pipe_auth_process: missing %d bytes in buffer.\n", - RPC_AUTH_NTLMSSP_CHK_LEN - 4 )); - return False; - } - - NTLMSSPcalc_p(p, (uchar*)req_data, RPC_AUTH_NTLMSSP_CHK_LEN - 4); - if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &ntlmssp_chk, rpc_in, 0)) { - DEBUG(0,("api_pipe_auth_process: failed to unmarshall RPC_AUTH_NTLMSSP_CHK.\n")); - return False; - } - - if (!rpc_auth_ntlmssp_chk(&ntlmssp_chk, crc32, p->ntlmssp_seq_num)) { - DEBUG(0,("api_pipe_auth_process: NTLMSSP check failed.\n")); - return False; - } - } - - /* - * Return the current pointer to the data offset. - */ - - if(!prs_set_offset(rpc_in, old_offset)) { - DEBUG(0,("api_pipe_auth_process: failed to set offset back to %u\n", - (unsigned int)old_offset )); - return False; - } - - return True; + return write(p->m->fd, data, n); } -/**************************************************************************** - Find the correct RPC function to call for this request. - If the pipe is authenticated then become the correct UNIX user - before doing the call. -****************************************************************************/ - -static BOOL api_pipe_request(pipes_struct *p, prs_struct *rpc_in) -{ - int i = 0; - BOOL ret = False; - BOOL changed_user_id = False; - - if (p->ntlmssp_auth_validated) { - if (!api_pipe_auth_process(p, rpc_in)) - return False; - - if(!become_authenticated_pipe_user(p)) - return False; - - changed_user_id = True; - } - - for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { - if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && - api_fd_commands[i].fn != NULL) { - DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i].pipe_clnt_name)); - ret = api_fd_commands[i].fn(p, rpc_in); - } - } - - if(changed_user_id) - unbecome_authenticated_pipe_user(p); - - return ret; -} /**************************************************************************** - This function is the entry point to processing a DCE/RPC request. - All the data for the request (including RPC headers and authentication - verifiers) must be linearized in the input_data buffer, with a length - of data_len. + reads data from a pipe. - The output is placed into the pipes_struct, and handed back to the - client on demand. -****************************************************************************/ + headers are interspersed with the data at regular intervals. by the time + this function is called, the start of the data could possibly have been + read by an SMBtrans (file_offset != 0). -BOOL rpc_command(pipes_struct *p, char *input_data, int data_len) + ****************************************************************************/ +int read_pipe(pipes_struct *p, char *data, int n) { - prs_struct rpc_in; - BOOL reply = False; - - if (input_data == NULL) - return False; - - prs_init(&rpc_in, 0, 4, UNMARSHALL); - - /* - * Hand the data to the prs_struct, but don't let - * it own it. - */ - prs_give_memory( &rpc_in, input_data, (uint32)data_len, False); + DEBUG(6,("read_pipe: %x name: %s open: %s len: %d", + p->pnum, p->name, BOOLSTR(p->open), n)); - /* Unmarshall the rpc header */ - if(!smb_io_rpc_hdr("", &p->hdr, &rpc_in, 0)) { - DEBUG(0,("rpc_command: failed to unmarshall RPC_HDR.\n")); - return False; - } - - /* - * Create the response data buffer. - */ - - if(!pipe_init_outgoing_data(p)) { - DEBUG(0,("rpc_command: failed to unmarshall RPC_HDR.\n")); - return False; - } - - switch (p->hdr.pkt_type) { - case RPC_BIND: - reply = api_pipe_bind_req(p, &rpc_in); - break; - case RPC_REQUEST: - if (p->ntlmssp_auth_requested && !p->ntlmssp_auth_validated) { - /* authentication _was_ requested - and it failed. sorry, no deal! - */ - DEBUG(0,("rpc_command: RPC request received on pipe %s where \ -authentication failed. Denying the request.\n", p->name)); - reply = False; - } else { - /* read the RPC request header */ - if(!smb_io_rpc_hdr_req("req", &p->hdr_req, &rpc_in, 0)) { - DEBUG(0,("rpc_command: failed to unmarshall RPC_HDR_REQ.\n")); - return False; - } - reply = api_pipe_request(p, &rpc_in); - } - break; - case RPC_BINDRESP: /* not the real name! */ - reply = api_pipe_bind_auth_resp(p, &rpc_in); - break; + if (!p || !p->open) + { + DEBUG(6,("pipe not open\n")); + return -1; } - if (!reply) - DEBUG(3,("rpc_command: DCE/RPC fault should be sent here\n")); - - return reply; + return read(p->m->fd, data, n); } - -/******************************************************************* - Calls the underlying RPC function for a named pipe. - ********************************************************************/ - -BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds, - prs_struct *rpc_in) -{ - int fn_num; - - /* interpret the command */ - DEBUG(4,("api_rpcTNP: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); - - for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) { - if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) { - DEBUG(3,("api_rpc_command: %s\n", api_rpc_cmds[fn_num].name)); - break; - } - } - - if (api_rpc_cmds[fn_num].name == NULL) { - DEBUG(4, ("unknown\n")); - return False; - } - - /* do the actual command */ - if(!api_rpc_cmds[fn_num].fn(p->vuid, rpc_in, &p->rdata)) { - DEBUG(0,("api_rpcTNP: %s: failed.\n", rpc_name)); - prs_mem_free(&p->rdata); - return False; - } - - DEBUG(5,("api_rpcTNP: called %s successfully\n", rpc_name)); - - return True; -} diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index b21b768a6e..46beba6316 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -113,10 +113,44 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, int i; pipes_struct *p; static int next_pipe; + struct msrpc_state *m = NULL; + user_struct *vuser = get_valid_user_struct(vuid); + struct user_creds usr; + + ZERO_STRUCT(usr); DEBUG(4,("Open pipe requested %s (pipes_open=%d)\n", pipe_name, pipes_open)); + if (vuser == NULL) + { + DEBUG(4,("invalid vuid %d\n", vuid)); + return NULL; + } + + /* set up unix credentials from the smb side, to feed over the pipe */ + make_creds_unix(&usr.uxc, vuser->name, vuser->requested_name, + vuser->real_name, vuser->guest); + usr.ptr_uxc = 1; + make_creds_unix_sec(&usr.uxs, vuser->uid, vuser->gid, + vuser->n_groups, vuser->groups); + usr.ptr_uxs = 1; + + /* set up nt credentials from the smb side, to feed over the pipe */ + /* lkclXXXX todo! + make_creds_nt(&usr.ntc); + make_creds_nt_sec(&usr.nts); + */ + + become_root(False); /* to connect to pipe */ + m = msrpc_use_add(pipe_name, &usr, False); + unbecome_root(False); + + if (m == NULL) + { + DEBUG(10,("open pipes: msrpc redirect failed - go local.\n")); + } + /* not repeating pipe numbers makes it easier to track things in log files and prevents client bugs where pipe numbers are reused over connection restarts */ @@ -160,6 +194,8 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->priority = 0; p->conn = conn; p->vuid = vuid; + + p->m = m; p->max_trans_reply = 0; @@ -201,7 +237,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, ssize_t write_to_pipe(pipes_struct *p, char *data, size_t n) { - DEBUG(6,("write_pipe: %x", p->pnum)); + DEBUG(6,("write_to_pipe: %x", p->pnum)); DEBUG(6,("name: %s open: %s len: %d", p->name, BOOLSTR(p->open), (int)n)); @@ -372,6 +408,19 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) DEBUG(4,("closed pipe name %s pnum=%x (pipes_open=%d)\n", p->name, p->pnum, pipes_open)); + if (p->m != NULL) + { + DEBUG(4,("closed msrpc redirect: ")); + if (msrpc_use_del(p->m->pipe_name, &p->m->usr, False, NULL)) + { + DEBUG(4,("OK\n")); + } + else + { + DEBUG(4,("FAILED\n")); + } + } + DLIST_REMOVE(Pipes, p); ZERO_STRUCTP(p); diff --git a/source3/rpc_server/srv_pipe_srv.c b/source3/rpc_server/srv_pipe_srv.c new file mode 100644 index 0000000000..236558ba70 --- /dev/null +++ b/source3/rpc_server/srv_pipe_srv.c @@ -0,0 +1,1077 @@ +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1998 + * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, + * Copyright (C) Paul Ashton 1997-1998. + * Copyright (C) Jeremy Allison 1999. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* this module apparently provides an implementation of DCE/RPC over a + * named pipe (IPC$ connection using SMBtrans). details of DCE/RPC + * documentation are available (in on-line form) from the X-Open group. + * + * this module should provide a level of abstraction between SMB + * and DCE/RPC, while minimising the amount of mallocs, unnecessary + * data copies, and network traffic. + * + * in this version, which takes a "let's learn what's going on and + * get something running" approach, there is additional network + * traffic generated, but the code should be easier to understand... + * + * ... if you read the docs. or stare at packets for weeks on end. + * + */ + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + +static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) +{ + unsigned char *hash = p->ntlmssp_hash; + unsigned char index_i = hash[256]; + unsigned char index_j = hash[257]; + int ind; + + for( ind = 0; ind < len; ind++) { + unsigned char tc; + unsigned char t; + + index_i++; + index_j += hash[index_i]; + + tc = hash[index_i]; + hash[index_i] = hash[index_j]; + hash[index_j] = tc; + + t = hash[index_i] + hash[index_j]; + data[ind] = data[ind] ^ hash[t]; + } + + hash[256] = index_i; + hash[257] = index_j; +} + +/******************************************************************* + Generate the next PDU to be returned from the data in p->rdata. + We cheat here as this function doesn't handle the special auth + footers of the authenticated bind response reply. + ********************************************************************/ + +BOOL create_next_pdu(pipes_struct *p) +{ + RPC_HDR_RESP hdr_resp; + BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SIGN); + BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SEAL); + uint32 data_len; + uint32 data_space_available; + uint32 data_len_left; + prs_struct outgoing_pdu; + char *data; + char *data_from; + uint32 data_pos; + + memset((char *)&hdr_resp, '\0', sizeof(hdr_resp)); + + /* Change the incoming request header to a response. */ + p->hdr.pkt_type = RPC_RESPONSE; + + /* Set up rpc header flags. */ + if (p->data_sent_length == 0) + p->hdr.flags = RPC_FLG_FIRST; + else + p->hdr.flags = 0; + + /* + * Work out how much we can fit in a sigle PDU. + */ + + data_space_available = sizeof(p->current_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN; + if(p->ntlmssp_auth_validated) + data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN); + + /* + * The amount we send is the minimum of the available + * space and the amount left to send. + */ + + data_len_left = prs_offset(&p->rdata) - p->data_sent_length; + + /* + * Ensure there really is data left to send. + */ + + if(!data_len_left) { + DEBUG(0,("create_next_pdu: no data left to send !\n")); + return False; + } + + data_len = MIN(data_len_left, data_space_available); + + /* + * Set up the alloc hint. This should be the data left to + * send. + */ + + hdr_resp.alloc_hint = data_len_left; + + /* + * Set up the header lengths. + */ + + if (p->ntlmssp_auth_validated) { + p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len + + RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN; + p->hdr.auth_len = RPC_AUTH_NTLMSSP_CHK_LEN; + } else { + p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len; + p->hdr.auth_len = 0; + } + + /* + * Work out if this PDU will be the last. + */ + + if(p->data_sent_length + data_len >= prs_offset(&p->rdata)) + p->hdr.flags |= RPC_FLG_LAST; + + /* + * Init the parse struct to point at the outgoing + * data. + */ + + prs_init( &outgoing_pdu, 0, 4, MARSHALL); + prs_give_memory( &outgoing_pdu, (char *)p->current_pdu, sizeof(p->current_pdu), False); + + /* Store the header in the data stream. */ + if(!smb_io_rpc_hdr("hdr", &p->hdr, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR.\n")); + return False; + } + + if(!smb_io_rpc_hdr_resp("resp", &hdr_resp, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_RESP.\n")); + return False; + } + + /* Store the current offset. */ + data_pos = prs_offset(&outgoing_pdu); + + /* Copy the data into the PDU. */ + data_from = prs_data_p(&p->rdata) + p->data_sent_length; + + if(!prs_append_data(&outgoing_pdu, data_from, data_len)) { + DEBUG(0,("create_next_pdu: failed to copy %u bytes of data.\n", (unsigned int)data_len)); + return False; + } + + /* + * Set data to point to where we copied the data into. + */ + + data = prs_data_p(&outgoing_pdu) + data_pos; + + if (p->hdr.auth_len > 0) { + uint32 crc32 = 0; + + DEBUG(5,("create_next_pdu: sign: %s seal: %s data %d auth %d\n", + BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, p->hdr.auth_len)); + + if (auth_seal) { + crc32 = crc32_calc_buffer(data, data_len); + NTLMSSPcalc_p(p, (uchar*)data, data_len); + } + + if (auth_seal || auth_verify) { + RPC_HDR_AUTH auth_info; + + init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, NTLMSSP_AUTH_LEVEL, + (auth_verify ? RPC_HDR_AUTH_LEN : 0), (auth_verify ? 1 : 0)); + if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_AUTH.\n")); + return False; + } + } + + if (auth_verify) { + RPC_AUTH_NTLMSSP_CHK ntlmssp_chk; + char *auth_data = prs_data_p(&outgoing_pdu); + + p->ntlmssp_seq_num++; + init_rpc_auth_ntlmssp_chk(&ntlmssp_chk, NTLMSSP_SIGN_VERSION, + crc32, p->ntlmssp_seq_num++); + auth_data = prs_data_p(&outgoing_pdu) + prs_offset(&outgoing_pdu) + 4; + if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &ntlmssp_chk, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_AUTH_NTLMSSP_CHK.\n")); + return False; + } + NTLMSSPcalc_p(p, (uchar*)auth_data, RPC_AUTH_NTLMSSP_CHK_LEN - 4); + } + } + + /* + * Setup the counts for this PDU. + */ + + p->data_sent_length += data_len; + p->current_pdu_len = p->hdr.frag_len; + p->current_pdu_sent = 0; + + return True; +} + +/******************************************************************* + Process an NTLMSSP authentication response. + If this function succeeds, the user has been authenticated + and their domain, name and calling workstation stored in + the pipe struct. + The initial challenge is stored in p->challenge. + *******************************************************************/ + +static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlmssp_resp) +{ + uchar lm_owf[24]; + uchar nt_owf[24]; + fstring user_name; + fstring unix_user_name; + fstring domain; + fstring wks; + BOOL guest_user = False; + struct smb_passwd *smb_pass = NULL; + struct passwd *pass = NULL; + uchar null_smb_passwd[16]; + uchar *smb_passwd_ptr = NULL; + + DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); + + memset(p->user_name, '\0', sizeof(p->user_name)); + memset(p->unix_user_name, '\0', sizeof(p->unix_user_name)); + memset(p->domain, '\0', sizeof(p->domain)); + memset(p->wks, '\0', sizeof(p->wks)); + + /* + * Setup an empty password for a guest user. + */ + + memset(null_smb_passwd,0,16); + + /* + * We always negotiate UNICODE. + */ + + if (IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_UNICODE)) { + fstrcpy(user_name, dos_unistrn2((uint16*)ntlmssp_resp->user, ntlmssp_resp->hdr_usr.str_str_len/2)); + fstrcpy(domain, dos_unistrn2((uint16*)ntlmssp_resp->domain, ntlmssp_resp->hdr_domain.str_str_len/2)); + fstrcpy(wks, dos_unistrn2((uint16*)ntlmssp_resp->wks, ntlmssp_resp->hdr_wks.str_str_len/2)); + } else { + fstrcpy(user_name, ntlmssp_resp->user); + fstrcpy(domain, ntlmssp_resp->domain); + fstrcpy(wks, ntlmssp_resp->wks); + } + + DEBUG(5,("user: %s domain: %s wks: %s\n", user_name, domain, wks)); + + memcpy(lm_owf, ntlmssp_resp->lm_resp, sizeof(lm_owf)); + memcpy(nt_owf, ntlmssp_resp->nt_resp, sizeof(nt_owf)); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("lm, nt owfs, chal\n")); + dump_data(100, (char *)lm_owf, sizeof(lm_owf)); + dump_data(100, (char *)nt_owf, sizeof(nt_owf)); + dump_data(100, (char *)p->challenge, 8); +#endif + + /* + * Allow guest access. Patch from Shirish Kalele . + */ + + if((strlen(user_name) == 0) && (ntlmssp_resp->hdr_lm_resp.str_str_len==0) && + (ntlmssp_resp->hdr_nt_resp.str_str_len==0)) { + + guest_user = True; + + fstrcpy(unix_user_name, lp_guestaccount(-1)); + DEBUG(100,("Null user in NTLMSSP verification. Using guest = %s\n", unix_user_name)); + + smb_passwd_ptr = null_smb_passwd; + + } else { + + /* + * Pass the user through the NT -> unix user mapping + * function. + */ + + fstrcpy(unix_user_name, user_name); + (void)map_username(unix_user_name); + + /* + * Do the length checking only if user is not NULL. + */ + + if (ntlmssp_resp->hdr_lm_resp.str_str_len == 0) + return False; + if (ntlmssp_resp->hdr_nt_resp.str_str_len == 0) + return False; + if (ntlmssp_resp->hdr_usr.str_str_len == 0) + return False; + if (ntlmssp_resp->hdr_domain.str_str_len == 0) + return False; + if (ntlmssp_resp->hdr_wks.str_str_len == 0) + return False; + + } + + /* + * Find the user in the unix password db. + */ + + if(!(pass = Get_Pwnam(unix_user_name,True))) { + DEBUG(1,("Couldn't find user '%s' in UNIX password database.\n",unix_user_name)); + return(False); + } + + if(!guest_user) { + + become_root(True); + + if(!(p->ntlmssp_auth_validated = pass_check_smb(unix_user_name, domain, + (uchar*)p->challenge, lm_owf, nt_owf, NULL))) { + DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ +failed authentication on named pipe %s.\n", domain, unix_user_name, wks, p->name )); + unbecome_root(True); + return False; + } + + if(!(smb_pass = getsmbpwnam(unix_user_name))) { + DEBUG(1,("api_pipe_ntlmssp_verify: Cannot find user %s in smb passwd database.\n", + unix_user_name)); + unbecome_root(True); + return False; + } + + unbecome_root(True); + + if (smb_pass == NULL) { + DEBUG(1,("api_pipe_ntlmssp_verify: Couldn't find user '%s' in smb_passwd file.\n", + unix_user_name)); + return(False); + } + + /* Quit if the account was disabled. */ + if((smb_pass->acct_ctrl & ACB_DISABLED) || !smb_pass->smb_passwd) { + DEBUG(1,("Account for user '%s' was disabled.\n", unix_user_name)); + return(False); + } + + if(!smb_pass->smb_nt_passwd) { + DEBUG(1,("Account for user '%s' has no NT password hash.\n", unix_user_name)); + return(False); + } + + smb_passwd_ptr = smb_pass->smb_passwd; + } + + /* + * Set up the sign/seal data. + */ + + { + uchar p24[24]; + NTLMSSPOWFencrypt(smb_passwd_ptr, lm_owf, p24); + { + unsigned char j = 0; + int ind; + + unsigned char k2[8]; + + memcpy(k2, p24, 5); + k2[5] = 0xe5; + k2[6] = 0x38; + k2[7] = 0xb0; + + for (ind = 0; ind < 256; ind++) + p->ntlmssp_hash[ind] = (unsigned char)ind; + + for( ind = 0; ind < 256; ind++) { + unsigned char tc; + + j += (p->ntlmssp_hash[ind] + k2[ind%8]); + + tc = p->ntlmssp_hash[ind]; + p->ntlmssp_hash[ind] = p->ntlmssp_hash[j]; + p->ntlmssp_hash[j] = tc; + } + + p->ntlmssp_hash[256] = 0; + p->ntlmssp_hash[257] = 0; + } +/* NTLMSSPhash(p->ntlmssp_hash, p24); */ + p->ntlmssp_seq_num = 0; + + } + + fstrcpy(p->user_name, user_name); + fstrcpy(p->unix_user_name, unix_user_name); + fstrcpy(p->domain, domain); + fstrcpy(p->wks, wks); + + /* + * Store the UNIX credential data (uid/gid pair) in the pipe structure. + */ + + p->uid = pass->pw_uid; + p->gid = pass->pw_gid; + + p->ntlmssp_auth_validated = True; + return True; +} + +/******************************************************************* + The switch table for the pipe names and the functions to handle them. + *******************************************************************/ + +struct api_cmd +{ + char * pipe_clnt_name; + char * pipe_srv_name; + BOOL (*fn) (pipes_struct *, prs_struct *); +}; + +static struct api_cmd api_fd_commands[] = +{ + { "lsarpc", "lsass", api_ntlsa_rpc }, + { "samr", "lsass", api_samr_rpc }, + { "srvsvc", "ntsvcs", api_srvsvc_rpc }, + { "wkssvc", "ntsvcs", api_wkssvc_rpc }, + { "NETLOGON", "lsass", api_netlog_rpc }, +#if DISABLED_IN_2_0 + { "winreg", "winreg", api_reg_rpc }, +#endif + { NULL, NULL, NULL } +}; + +/******************************************************************* + This is the client reply to our challenge for an authenticated + bind request. The challenge we sent is in p->challenge. +*******************************************************************/ + +static BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *pd) +{ + RPC_HDR_AUTHA autha_info; + RPC_AUTH_VERIFIER auth_verifier; + RPC_AUTH_NTLMSSP_RESP ntlmssp_resp; + + DEBUG(5,("api_pipe_bind_auth_resp: decode request. %d\n", __LINE__)); + + if (p->hdr.auth_len == 0) { + DEBUG(0,("api_pipe_bind_auth_resp: No auth field sent !\n")); + return False; + } + + /* + * Decode the authentication verifier response. + */ + + if(!smb_io_rpc_hdr_autha("", &autha_info, pd, 0)) { + DEBUG(0,("api_pipe_bind_auth_resp: unmarshall of RPC_HDR_AUTHA failed.\n")); + return False; + } + + if (autha_info.auth_type != NTLMSSP_AUTH_TYPE || autha_info.auth_level != NTLMSSP_AUTH_LEVEL) { + DEBUG(0,("api_pipe_bind_auth_resp: incorrect auth type (%d) or level (%d).\n", + (int)autha_info.auth_type, (int)autha_info.auth_level )); + return False; + } + + if(!smb_io_rpc_auth_verifier("", &auth_verifier, pd, 0)) { + DEBUG(0,("api_pipe_bind_auth_resp: unmarshall of RPC_AUTH_VERIFIER failed.\n")); + return False; + } + + /* + * Ensure this is a NTLMSSP_AUTH packet type. + */ + + if (!rpc_auth_verifier_chk(&auth_verifier, "NTLMSSP", NTLMSSP_AUTH)) { + DEBUG(0,("api_pipe_bind_auth_resp: rpc_auth_verifier_chk failed.\n")); + return False; + } + + if(!smb_io_rpc_auth_ntlmssp_resp("", &ntlmssp_resp, pd, 0)) { + DEBUG(0,("api_pipe_bind_auth_resp: Failed to unmarshall RPC_AUTH_NTLMSSP_RESP.\n")); + return False; + } + + /* + * The following call actually checks the challenge/response data. + * for correctness against the given DOMAIN\user name. + */ + + if (!api_pipe_ntlmssp_verify(p, &ntlmssp_resp)) + return False; + + return True; +} + +/******************************************************************* + Marshall a bind_nak pdu. +*******************************************************************/ + +static BOOL setup_bind_nak(pipes_struct *p, prs_struct *pd) +{ + prs_struct outgoing_rpc; + RPC_HDR nak_hdr; + uint16 zero = 0; + + /* + * Marshall directly into the outgoing PDU space. We + * must do this as we need to set to the bind response + * header and are never sending more than one PDU here. + */ + + prs_init( &outgoing_rpc, 0, 4, MARSHALL); + prs_give_memory( &outgoing_rpc, (char *)p->current_pdu, sizeof(p->current_pdu), False); + + + /* + * Initialize a bind_nak header. + */ + + init_rpc_hdr(&nak_hdr, RPC_BINDNACK, RPC_FLG_FIRST | RPC_FLG_LAST, + p->hdr.call_id, RPC_HEADER_LEN + sizeof(uint16), 0); + + /* + * Marshall the header into the outgoing PDU. + */ + + if(!smb_io_rpc_hdr("", &nak_hdr, &outgoing_rpc, 0)) { + DEBUG(0,("setup_bind_nak: marshalling of RPC_HDR failed.\n")); + return False; + } + + /* + * Now add the reject reason. + */ + + if(!prs_uint16("reject code", &outgoing_rpc, 0, &zero)) + return False; + + p->data_sent_length = 0; + p->current_pdu_len = prs_offset(&outgoing_rpc); + p->current_pdu_sent = 0; + + return True; +} + +/******************************************************************* + Respond to a pipe bind request. +*******************************************************************/ + +static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) +{ + RPC_HDR_BA hdr_ba; + RPC_HDR_RB hdr_rb; + RPC_HDR_AUTH auth_info; + uint16 assoc_gid; + fstring ack_pipe_name; + prs_struct out_hdr_ba; + prs_struct out_auth; + prs_struct outgoing_rpc; + int i = 0; + int auth_len = 0; + + p->ntlmssp_auth_requested = False; + + DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); + + /* + * Try and find the correct pipe name to ensure + * that this is a pipe name we support. + */ + + for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { + if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && + api_fd_commands[i].fn != NULL) { + DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", + api_fd_commands[i].pipe_clnt_name, + api_fd_commands[i].pipe_srv_name)); + fstrcpy(p->pipe_srv_name, api_fd_commands[i].pipe_srv_name); + break; + } + } + + if (api_fd_commands[i].fn == NULL) { + DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", + p->name )); + if(!setup_bind_nak(p, pd)) + return False; + return True; + } + + /* decode the bind request */ + if(!smb_io_rpc_hdr_rb("", &hdr_rb, pd, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_RB struct.\n")); + return False; + } + + /* + * Check if this is an authenticated request. + */ + + if (p->hdr.auth_len != 0) { + RPC_AUTH_VERIFIER auth_verifier; + RPC_AUTH_NTLMSSP_NEG ntlmssp_neg; + + /* + * Decode the authentication verifier. + */ + + if(!smb_io_rpc_hdr_auth("", &auth_info, pd, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); + return False; + } + + /* + * We only support NTLMSSP_AUTH_TYPE requests. + */ + + if(auth_info.auth_type != NTLMSSP_AUTH_TYPE) { + DEBUG(0,("api_pipe_bind_req: unknown auth type %x requested.\n", + auth_info.auth_type )); + return False; + } + + if(!smb_io_rpc_auth_verifier("", &auth_verifier, pd, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); + return False; + } + + if(!strequal(auth_verifier.signature, "NTLMSSP")) { + DEBUG(0,("api_pipe_bind_req: auth_verifier.signature != NTLMSSP\n")); + return False; + } + + if(auth_verifier.msg_type != NTLMSSP_NEGOTIATE) { + DEBUG(0,("api_pipe_bind_req: auth_verifier.msg_type (%d) != NTLMSSP_NEGOTIATE\n", + auth_verifier.msg_type)); + return False; + } + + if(!smb_io_rpc_auth_ntlmssp_neg("", &ntlmssp_neg, pd, 0)) { + DEBUG(0,("api_pipe_bind_req: Failed to unmarshall RPC_AUTH_NTLMSSP_NEG.\n")); + return False; + } + + p->ntlmssp_chal_flags = SMBD_NTLMSSP_NEG_FLAGS; + p->ntlmssp_auth_requested = True; + } + + /* name has to be \PIPE\xxxxx */ + fstrcpy(ack_pipe_name, "\\PIPE\\"); + fstrcat(ack_pipe_name, p->pipe_srv_name); + + DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); + + /* + * Marshall directly into the outgoing PDU space. We + * must do this as we need to set to the bind response + * header and are never sending more than one PDU here. + */ + + prs_init( &outgoing_rpc, 0, 4, MARSHALL); + prs_give_memory( &outgoing_rpc, (char *)p->current_pdu, sizeof(p->current_pdu), False); + + /* + * Setup the memory to marshall the ba header, and the + * auth footers. + */ + + if(!prs_init(&out_hdr_ba, 1024, 4, MARSHALL)) { + DEBUG(0,("api_pipe_bind_req: malloc out_hdr_ba failed.\n")); + return False; + } + + if(!prs_init(&out_auth, 1024, 4, MARSHALL)) { + DEBUG(0,("pi_pipe_bind_req: malloc out_auth failed.\n")); + prs_mem_free(&out_hdr_ba); + return False; + } + + if (p->ntlmssp_auth_requested) + assoc_gid = 0x7a77; + else + assoc_gid = hdr_rb.bba.assoc_gid; + + /* + * Create the bind response struct. + */ + + init_rpc_hdr_ba(&hdr_ba, + hdr_rb.bba.max_tsize, + hdr_rb.bba.max_rsize, + assoc_gid, + ack_pipe_name, + 0x1, 0x0, 0x0, + &hdr_rb.transfer); + + /* + * and marshall it. + */ + + if(!smb_io_rpc_hdr_ba("", &hdr_ba, &out_hdr_ba, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_BA failed.\n")); + goto err_exit; + } + + /* + * Now the authentication. + */ + + if (p->ntlmssp_auth_requested) { + RPC_AUTH_VERIFIER auth_verifier; + RPC_AUTH_NTLMSSP_CHAL ntlmssp_chal; + + generate_random_buffer(p->challenge, 8, False); + + /*** Authentication info ***/ + + init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, NTLMSSP_AUTH_LEVEL, RPC_HDR_AUTH_LEN, 1); + if(!smb_io_rpc_hdr_auth("", &auth_info, &out_auth, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_AUTH failed.\n")); + goto err_exit; + } + + /*** NTLMSSP verifier ***/ + + init_rpc_auth_verifier(&auth_verifier, "NTLMSSP", NTLMSSP_CHALLENGE); + if(!smb_io_rpc_auth_verifier("", &auth_verifier, &out_auth, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_VERIFIER failed.\n")); + goto err_exit; + } + + /* NTLMSSP challenge ***/ + + init_rpc_auth_ntlmssp_chal(&ntlmssp_chal, p->ntlmssp_chal_flags, p->challenge); + if(!smb_io_rpc_auth_ntlmssp_chal("", &ntlmssp_chal, &out_auth, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_NTLMSSP_CHAL failed.\n")); + goto err_exit; + } + + /* Auth len in the rpc header doesn't include auth_header. */ + auth_len = prs_offset(&out_auth) - RPC_HDR_AUTH_LEN; + } + + /* + * Create the header, now we know the length. + */ + + init_rpc_hdr(&p->hdr, RPC_BINDACK, RPC_FLG_FIRST | RPC_FLG_LAST, + p->hdr.call_id, + RPC_HEADER_LEN + prs_offset(&out_hdr_ba) + prs_offset(&out_auth), + auth_len); + + /* + * Marshall the header into the outgoing PDU. + */ + + if(!smb_io_rpc_hdr("", &p->hdr, &outgoing_rpc, 0)) { + DEBUG(0,("pi_pipe_bind_req: marshalling of RPC_HDR failed.\n")); + goto err_exit; + } + + /* + * Now add the RPC_HDR_BA and any auth needed. + */ + + if(!prs_append_prs_data( &outgoing_rpc, &out_hdr_ba)) { + DEBUG(0,("api_pipe_bind_req: append of RPC_HDR_BA failed.\n")); + goto err_exit; + } + + if(p->ntlmssp_auth_requested && !prs_append_prs_data( &outgoing_rpc, &out_auth)) { + DEBUG(0,("api_pipe_bind_req: append of auth info failed.\n")); + goto err_exit; + } + + /* + * Setup the lengths for the initial reply. + */ + + p->data_sent_length = 0; + p->current_pdu_len = prs_offset(&outgoing_rpc); + p->current_pdu_sent = 0; + + prs_mem_free(&out_hdr_ba); + prs_mem_free(&out_auth); + + return True; + + err_exit: + + prs_mem_free(&out_hdr_ba); + prs_mem_free(&out_auth); + return False; +} + +/**************************************************************************** + Deal with sign & seal processing on an RPC request. +****************************************************************************/ + +static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) +{ + /* + * We always negotiate the following two bits.... + */ + BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SIGN); + BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SEAL); + int data_len; + int auth_len; + uint32 old_offset; + uint32 crc32 = 0; + + auth_len = p->hdr.auth_len; + + if ((auth_len != RPC_AUTH_NTLMSSP_CHK_LEN) && auth_verify) { + DEBUG(0,("api_pipe_auth_process: Incorrect auth_len %d.\n", auth_len )); + return False; + } + + /* + * The following is that length of the data we must verify or unseal. + * This doesn't include the RPC headers or the auth_len or the RPC_HDR_AUTH_LEN + * preceeding the auth_data. + */ + + data_len = p->hdr.frag_len - RPC_HEADER_LEN - RPC_HDR_REQ_LEN - + (auth_verify ? RPC_HDR_AUTH_LEN : 0) - auth_len; + + DEBUG(5,("api_pipe_auth_process: sign: %s seal: %s data %d auth %d\n", + BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); + + if (auth_seal) { + char *data = prs_data_p(rpc_in) + RPC_HEADER_LEN + RPC_HDR_REQ_LEN; + NTLMSSPcalc_p(p, (uchar*)data, data_len); + crc32 = crc32_calc_buffer(data, data_len); + } + + old_offset = prs_offset(rpc_in); + + if (auth_seal || auth_verify) { + RPC_HDR_AUTH auth_info; + + if(!prs_set_offset(rpc_in, old_offset + data_len)) { + DEBUG(0,("api_pipe_auth_process: cannot move offset to %u.\n", + (unsigned int)old_offset + data_len )); + return False; + } + + if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, rpc_in, 0)) { + DEBUG(0,("api_pipe_auth_process: failed to unmarshall RPC_HDR_AUTH.\n")); + return False; + } + } + + if (auth_verify) { + RPC_AUTH_NTLMSSP_CHK ntlmssp_chk; + char *req_data = prs_data_p(rpc_in) + prs_offset(rpc_in) + 4; + + DEBUG(5,("api_pipe_auth_process: auth %d\n", prs_offset(rpc_in) + 4)); + + /* + * Ensure we have RPC_AUTH_NTLMSSP_CHK_LEN - 4 more bytes in the + * incoming buffer. + */ + if(prs_mem_get(rpc_in, RPC_AUTH_NTLMSSP_CHK_LEN - 4) == NULL) { + DEBUG(0,("api_pipe_auth_process: missing %d bytes in buffer.\n", + RPC_AUTH_NTLMSSP_CHK_LEN - 4 )); + return False; + } + + NTLMSSPcalc_p(p, (uchar*)req_data, RPC_AUTH_NTLMSSP_CHK_LEN - 4); + if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &ntlmssp_chk, rpc_in, 0)) { + DEBUG(0,("api_pipe_auth_process: failed to unmarshall RPC_AUTH_NTLMSSP_CHK.\n")); + return False; + } + + if (!rpc_auth_ntlmssp_chk(&ntlmssp_chk, crc32, p->ntlmssp_seq_num)) { + DEBUG(0,("api_pipe_auth_process: NTLMSSP check failed.\n")); + return False; + } + } + + /* + * Return the current pointer to the data offset. + */ + + if(!prs_set_offset(rpc_in, old_offset)) { + DEBUG(0,("api_pipe_auth_process: failed to set offset back to %u\n", + (unsigned int)old_offset )); + return False; + } + + return True; +} + +/**************************************************************************** + Find the correct RPC function to call for this request. + If the pipe is authenticated then become the correct UNIX user + before doing the call. +****************************************************************************/ + +static BOOL api_pipe_request(pipes_struct *p, prs_struct *rpc_in) +{ + int i = 0; + BOOL ret = False; + BOOL changed_user_id = False; + + if (p->ntlmssp_auth_validated) { + if (!api_pipe_auth_process(p, rpc_in)) + return False; + + if(!become_authenticated_pipe_user(p)) + return False; + + changed_user_id = True; + } + + for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { + if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && + api_fd_commands[i].fn != NULL) { + DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i].pipe_clnt_name)); + ret = api_fd_commands[i].fn(p, rpc_in); + } + } + + if(changed_user_id) + unbecome_authenticated_pipe_user(p); + + return ret; +} + +/**************************************************************************** + This function is the entry point to processing a DCE/RPC request. + All the data for the request (including RPC headers and authentication + verifiers) must be linearized in the input_data buffer, with a length + of data_len. + + The output is placed into the pipes_struct, and handed back to the + client on demand. +****************************************************************************/ + +BOOL rpc_command(pipes_struct *p, char *input_data, int data_len) +{ + prs_struct rpc_in; + BOOL reply = False; + + if (input_data == NULL) + return False; + + prs_init(&rpc_in, 0, 4, UNMARSHALL); + + /* + * Hand the data to the prs_struct, but don't let + * it own it. + */ + prs_give_memory( &rpc_in, input_data, (uint32)data_len, False); + + /* Unmarshall the rpc header */ + if(!smb_io_rpc_hdr("", &p->hdr, &rpc_in, 0)) { + DEBUG(0,("rpc_command: failed to unmarshall RPC_HDR.\n")); + return False; + } + + /* + * Create the response data buffer. + */ + + if(!pipe_init_outgoing_data(p)) { + DEBUG(0,("rpc_command: failed to unmarshall RPC_HDR.\n")); + return False; + } + + switch (p->hdr.pkt_type) { + case RPC_BIND: + reply = api_pipe_bind_req(p, &rpc_in); + break; + case RPC_REQUEST: + if (p->ntlmssp_auth_requested && !p->ntlmssp_auth_validated) { + /* authentication _was_ requested + and it failed. sorry, no deal! + */ + DEBUG(0,("rpc_command: RPC request received on pipe %s where \ +authentication failed. Denying the request.\n", p->name)); + reply = False; + } else { + /* read the RPC request header */ + if(!smb_io_rpc_hdr_req("req", &p->hdr_req, &rpc_in, 0)) { + DEBUG(0,("rpc_command: failed to unmarshall RPC_HDR_REQ.\n")); + return False; + } + reply = api_pipe_request(p, &rpc_in); + } + break; + case RPC_BINDRESP: /* not the real name! */ + reply = api_pipe_bind_auth_resp(p, &rpc_in); + break; + } + + if (!reply) + DEBUG(3,("rpc_command: DCE/RPC fault should be sent here\n")); + + return reply; +} + + +/******************************************************************* + Calls the underlying RPC function for a named pipe. + ********************************************************************/ + +BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds, + prs_struct *rpc_in) +{ + int fn_num; + + /* interpret the command */ + DEBUG(4,("api_rpcTNP: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); + + for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) { + if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) { + DEBUG(3,("api_rpc_command: %s\n", api_rpc_cmds[fn_num].name)); + break; + } + } + + if (api_rpc_cmds[fn_num].name == NULL) { + DEBUG(4, ("unknown\n")); + return False; + } + + /* do the actual command */ + if(!api_rpc_cmds[fn_num].fn(p->vuid, rpc_in, &p->rdata)) { + DEBUG(0,("api_rpcTNP: %s: failed.\n", rpc_name)); + prs_mem_free(&p->rdata); + return False; + } + + DEBUG(5,("api_rpcTNP: called %s successfully\n", rpc_name)); + + return True; +} -- cgit From 528399a8a2a0903e6b8a9de0e3ac07f1f0b5f21b Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 4 Jan 2000 07:52:21 +0000 Subject: oops, must use read_data() not read(), as read() may only provide part of the data stream. read_data() is a wrapper to guarantee receiving exactly the requested number of bytes. (This used to be commit 90c27b7bffa9b2121eaed0e07931830c3ba308d7) --- source3/rpc_server/srv_pipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 98c3e90c06..49733b0767 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -68,7 +68,7 @@ BOOL readwrite_pipe(pipes_struct *p, char *data, int len, { return False; } - (*rlen) = read(p->m->fd, (*rdata), (*rlen)); + (*rlen) = read_data(p->m->fd, (*rdata), (*rlen)); if ((*rlen) < 0) { return False; @@ -115,6 +115,6 @@ int read_pipe(pipes_struct *p, char *data, int n) return -1; } - return read(p->m->fd, data, n); + return read_data(p->m->fd, data, n); } -- cgit From ac9c6994e02ff0a204a19931c4c118c5f1028479 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 4 Jan 2000 15:59:57 +0000 Subject: using read_with_timeout(), min data size 16 bytes (DCE/RPC header), max size of SMBtrans response, timeout of 10 seconds. read_data() _certainly_ doesn't work, as you don't know what size of the data is going to come back that needs to be fed back in the SMBtrans response. yes, oops :-) (This used to be commit 70d6f7635776bba98c9c09405eff6c2087dac590) --- source3/rpc_server/srv_pipe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 49733b0767..f8439de9a7 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -68,7 +68,11 @@ BOOL readwrite_pipe(pipes_struct *p, char *data, int len, { return False; } - (*rlen) = read_data(p->m->fd, (*rdata), (*rlen)); + + /* read a minimum of an rpc header, then wait for up to 10 seconds + * to read up to a maximum of the SMBtrans max data size + */ + (*rlen) = read_with_timeout(p->m->fd, (*rdata), 16, (*rlen), 10000); if ((*rlen) < 0) { return False; -- cgit From 8433aa437990357a327dbed19afc8033a1ed9be4 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 11 Jan 2000 02:00:31 +0000 Subject: modified smbd/msrpc credential transfer system. user session key is *missing* from samba cvs main, therefore it is set to all zeros. this will cause, amongst other things, administrator-changing-user-passwords, and setting up new accounts, to fail, as the user's password can only be decoded with the session key (in this case, the administrator's usr sess key). it's never a perfect world, is it? (This used to be commit 3362fcdfa492cfd1d9d4ec35ef2108192302b984) --- source3/rpc_server/srv_pipe_hnd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 46beba6316..736d1435d1 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -136,6 +136,16 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, vuser->n_groups, vuser->groups); usr.ptr_uxs = 1; + usr.ptr_ssk = 1; + DEBUG(0,("user session key not available (yet).\n")); + DEBUG(0,("password-change operations may fail.\n")); + +#if USER_SESSION_KEY_DEFINED_IN_VUSER_STRUCT + memcpy(usr.usr_sess_key, vuser->usr_sess_key, sizeof(usr.usr_sess_key)); +#else + memset(usr.usr_sess_key, 0, sizeof(usr.usr_sess_key)); +#endif + /* set up nt credentials from the smb side, to feed over the pipe */ /* lkclXXXX todo! make_creds_nt(&usr.ntc); -- cgit From 86da0e8ac1bc0197235b012ba6c56f29aef5c74e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 14 Jan 2000 21:16:59 +0000 Subject: HP changes for registry querying. Jeremy. (This used to be commit fd8582cc0a751618f4699f435d561f5de54bf7f4) --- source3/rpc_server/srv_reg.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index fc3ce9c0d2..f2083fa22f 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -5,6 +5,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. + * Copyright (C) Hewlett-Packard Company 1999. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -145,6 +146,10 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, { DEBUG(5,("reg_open_entry: %s\n", name)); /* lkcl XXXX do a check on the name, here */ + if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions")) + { + status = 0xC000000 | NT_STATUS_ACCESS_DENIED; + } } if (status == 0x0 && !set_lsa_policy_reg_name(&pol, name)) @@ -199,7 +204,10 @@ static void reg_reply_info(REG_Q_INFO *q_u, { } - init_reg_r_info(&r_u, 1, "LanmanNT", 0x12, 0x12, status); + /* This makes the server look like a member server to clients */ + /* which tells clients that we have our own local user and */ + /* group databases and helps with ACL support. */ + init_reg_r_info(&r_u, 1, "ServerNT", 0x12, 0x12, status); /* store the response in the SMB stream */ reg_io_r_info("", &r_u, rdata, 0); -- cgit From d91bfabc5df7226cc1b0da231e18fd16c8807a25 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 21 Jan 2000 02:33:21 +0000 Subject: made cvs main up-to-date with samba_tng, with addition of process id to msrpc loop-back interface. (This used to be commit adbf97c0a93149e17496b002ecc8ecdb3f360ed5) --- source3/rpc_server/srv_pipe_hnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 736d1435d1..b8e7c1946a 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -153,7 +153,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, */ become_root(False); /* to connect to pipe */ - m = msrpc_use_add(pipe_name, &usr, False); + m = msrpc_use_add(pipe_name, getpid(), &usr, False); unbecome_root(False); if (m == NULL) -- cgit From 6a6749d81e892bb06bfdc0fefdc428e5e6599f71 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 7 Feb 2000 16:17:59 +0000 Subject: First commit of the spoolss code to the HEAD branch. still needs a lot of cleaning/debuging. J.F. (This used to be commit bd9d4cdde9193c120c6f4e8cf72f87cd67a9387e) --- source3/rpc_server/srv_spoolss.c | 793 ++++++++ source3/rpc_server/srv_spoolss_nt.c | 3434 +++++++++++++++++++++++++++++++++++ 2 files changed, 4227 insertions(+) create mode 100755 source3/rpc_server/srv_spoolss.c create mode 100644 source3/rpc_server/srv_spoolss_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c new file mode 100755 index 0000000000..60333e1f3b --- /dev/null +++ b/source3/rpc_server/srv_spoolss.c @@ -0,0 +1,793 @@ +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-2000, + * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, + * Copyright (C) Jean François Micouleau 1998-2000. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; + +/******************************************************************** + * api_spoolss_open_printer_ex + ********************************************************************/ +static BOOL api_spoolss_open_printer_ex(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_OPEN_PRINTER_EX q_u; + SPOOL_R_OPEN_PRINTER_EX r_u; + UNISTR2 *printername = NULL; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!spoolss_io_q_open_printer_ex("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_open_printer_ex: unable to unmarshall SPOOL_Q_OPEN_PRINTER_EX.\n")); + return False; + } + + if (q_u.printername_ptr != 0) + { + printername = &q_u.printername; + } + + r_u.status = _spoolss_open_printer_ex( printername, + &q_u.printer_default, + q_u.user_switch, q_u.user_ctr, + &r_u.handle); + + if (!spoolss_io_r_open_printer_ex("",&r_u,rdata,0)){ + DEBUG(0,("spoolss_io_r_open_printer_ex: unable to marshall SPOOL_R_OPEN_PRINTER_EX.\n")); + return False; + } + + return True; +} + +/******************************************************************** + * api_spoolss_getprinterdata + * + * called from the spoolss dispatcher + ********************************************************************/ +static BOOL api_spoolss_getprinterdata(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_GETPRINTERDATA q_u; + SPOOL_R_GETPRINTERDATA r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* read the stream and fill the struct */ + if (!spoolss_io_q_getprinterdata("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_getprinterdata: unable to unmarshall SPOOL_Q_GETPRINTERDATA.\n")); + return False; + } + + r_u.status = _spoolss_getprinterdata( &q_u.handle, &q_u.valuename, + q_u.size, &r_u.type, &r_u.size, + &r_u.data, &r_u.needed); + + if (!spoolss_io_r_getprinterdata("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_getprinterdata: unable to marshall SPOOL_R_GETPRINTERDATA.\n")); + return False; + } + + safe_free(r_u.data); + + return True; +} + +/******************************************************************** + * api_spoolss_closeprinter + * + * called from the spoolss dispatcher + ********************************************************************/ +static BOOL api_spoolss_closeprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_CLOSEPRINTER q_u; + SPOOL_R_CLOSEPRINTER r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_closeprinter("", &q_u, data, 0); + r_u.status = _spoolss_closeprinter(&q_u.handle); + memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle)); + spoolss_io_r_closeprinter("",&r_u,rdata,0); +} + +/******************************************************************** + * api_spoolss_rffpcnex + * ReplyFindFirstPrinterChangeNotifyEx + ********************************************************************/ +static BOOL api_spoolss_rffpcnex(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_RFFPCNEX q_u; + SPOOL_R_RFFPCNEX r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_rffpcnex("", &q_u, data, 0); + + r_u.status = _spoolss_rffpcnex(&q_u.handle, q_u.flags, + q_u.options, &q_u.localmachine, + q_u.printerlocal, &q_u.option); + spoolss_io_r_rffpcnex("",&r_u,rdata,0); +} + + +/******************************************************************** + * api_spoolss_rfnpcnex + * ReplyFindNextPrinterChangeNotifyEx + * called from the spoolss dispatcher + * + ********************************************************************/ +static BOOL api_spoolss_rfnpcnex(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_RFNPCNEX q_u; + SPOOL_R_RFNPCNEX r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_rfnpcnex("", &q_u, data, 0); + + r_u.status = _spoolss_rfnpcnex(&q_u.handle, q_u.change, + &q_u.option, &r_u.count, &r_u.info); + spoolss_io_r_rfnpcnex("", &r_u, rdata, 0); +} + + +/******************************************************************** + * api_spoolss_enumprinters + * called from the spoolss dispatcher + * + ********************************************************************/ +static BOOL api_spoolss_enumprinters(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ENUMPRINTERS q_u; + SPOOL_R_ENUMPRINTERS r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_enumprinters("", &q_u, data, 0); + + /* lkclXXX DAMN DAMN DAMN! MICROSOFT @#$%S IT UP, AGAIN, AND WE + HAVE TO DEAL WITH IT! AGH! + */ + r_u.level = q_u.level; + r_u.status = _spoolss_enumprinters( + q_u.flags, + &q_u.servername, + q_u.level, + &q_u.buffer, + q_u.buf_size, + &r_u.offered, + &r_u.needed, + &r_u.ctr, + &r_u.returned); + + memcpy(r_u.servername.buffer,q_u.servername.buffer, + 2*q_u.servername.uni_str_len); + r_u.servername.buffer[q_u.servername.uni_str_len] = 0; + + spoolss_io_free_buffer(&(q_u.buffer)); + spoolss_io_r_enumprinters("",&r_u,rdata,0); +} + + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static BOOL api_spoolss_getprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_GETPRINTER q_u; + SPOOL_R_GETPRINTER r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_getprinter("", &q_u, data, 0); + + r_u.status = _spoolss_getprinter(&q_u.handle, q_u.level, + &r_u.ctr, &q_u.offered, &r_u.needed); + + memcpy(&r_u.handle, &q_u.handle, sizeof(&r_u.handle)); + r_u.offered = q_u.offered; + r_u.level = q_u.level; + safe_free(q_u.buffer); + + spoolss_io_r_getprinter("",&r_u,rdata,0); +} + + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static BOOL api_spoolss_getprinterdriver2(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_GETPRINTERDRIVER2 q_u; + SPOOL_R_GETPRINTERDRIVER2 r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_getprinterdriver2("", &q_u, data, 0); + + r_u.status = _spoolss_getprinterdriver2(&q_u.handle, + &q_u.architecture, q_u.level, + &r_u.ctr, &q_u.buf_size, + &r_u.needed); + + r_u.offered = q_u.buf_size; + r_u.level = q_u.level; + spoolss_io_free_buffer(&(q_u.buffer)); + + spoolss_io_r_getprinterdriver2("",&r_u,rdata,0); +} + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static BOOL api_spoolss_startpageprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_STARTPAGEPRINTER q_u; + SPOOL_R_STARTPAGEPRINTER r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_startpageprinter("", &q_u, data, 0); + r_u.status = _spoolss_startpageprinter(&q_u.handle); + spoolss_io_r_startpageprinter("",&r_u,rdata,0); +} + + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static BOOL api_spoolss_endpageprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ENDPAGEPRINTER q_u; + SPOOL_R_ENDPAGEPRINTER r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_endpageprinter("", &q_u, data, 0); + r_u.status = _spoolss_endpageprinter(&q_u.handle); + spoolss_io_r_endpageprinter("",&r_u,rdata,0); +} + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static BOOL api_spoolss_startdocprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_STARTDOCPRINTER q_u; + SPOOL_R_STARTDOCPRINTER r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_startdocprinter("", &q_u, data, 0); + r_u.status = _spoolss_startdocprinter(&q_u.handle, + q_u.doc_info_container.level, + &q_u.doc_info_container.docinfo, + &r_u.jobid); + spoolss_io_r_startdocprinter("",&r_u,rdata,0); +} + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static BOOL api_spoolss_enddocprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ENDDOCPRINTER q_u; + SPOOL_R_ENDDOCPRINTER r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_enddocprinter("", &q_u, data, 0); + r_u.status = _spoolss_enddocprinter(&q_u.handle); + spoolss_io_r_enddocprinter("",&r_u,rdata,0); +} + + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static BOOL api_spoolss_writeprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_WRITEPRINTER q_u; + SPOOL_R_WRITEPRINTER r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_writeprinter("", &q_u, data, 0); + r_u.status = _spoolss_writeprinter(&q_u.handle, + q_u.buffer_size, + q_u.buffer, + &q_u.buffer_size2); + r_u.buffer_written = q_u.buffer_size2; + safe_free(q_u.buffer); + spoolss_io_r_writeprinter("",&r_u,rdata,0); +} + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_setprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_SETPRINTER q_u; + SPOOL_R_SETPRINTER r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_setprinter("", &q_u, data, 0); + DEBUG(0,("api_spoolss_setprinter: typecast sec_des to uint8*!\n")); + r_u.status = _spoolss_setprinter(&q_u.handle, + q_u.level, &q_u.info, + q_u.devmode, + q_u.security.size_of_buffer, + (const uint8*)q_u.security.data, + q_u.command); + spoolss_io_r_setprinter("",&r_u,rdata,0); +} + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_fcpn(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_FCPN q_u; + SPOOL_R_FCPN r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_fcpn("", &q_u, data, 0); + r_u.status = _spoolss_fcpn(&q_u.handle); + spoolss_io_r_fcpn("",&r_u,rdata,0); +} + + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_addjob(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ADDJOB q_u; + SPOOL_R_ADDJOB r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_addjob("", &q_u, data, 0); + + r_u.status = _spoolss_addjob(&q_u.handle, q_u.level, + &q_u.buffer, q_u.buf_size); + + spoolss_io_free_buffer(&(q_u.buffer)); + spoolss_io_r_addjob("",&r_u,rdata,0); +} + + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_enumjobs(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ENUMJOBS q_u; + SPOOL_R_ENUMJOBS r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_enumjobs("", &q_u, data, 0); + r_u.offered = q_u.buf_size; + r_u.level = q_u.level; + r_u.status = _spoolss_enumjobs(&q_u.handle, + q_u.firstjob, q_u.numofjobs, q_u.level, + &r_u.ctr, &r_u.offered, &r_u.numofjobs); + spoolss_io_free_buffer(&(q_u.buffer)); + spoolss_io_r_enumjobs("",&r_u,rdata,0); +} + + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_schedulejob(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_SCHEDULEJOB q_u; + SPOOL_R_SCHEDULEJOB r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_schedulejob("", &q_u, data, 0); + r_u.status = _spoolss_schedulejob(&q_u.handle, q_u.jobid); + spoolss_io_r_schedulejob("",&r_u,rdata,0); +} + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_setjob(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_SETJOB q_u; + SPOOL_R_SETJOB r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_setjob("", &q_u, data, 0); + r_u.status = _spoolss_setjob(&q_u.handle, q_u.jobid, + q_u.level, &q_u.ctr, q_u.command); + spoolss_io_r_setjob("",&r_u,rdata,0); +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_enumprinterdrivers(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ENUMPRINTERDRIVERS q_u; + SPOOL_R_ENUMPRINTERDRIVERS r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_enumprinterdrivers("", &q_u, data, 0); + + r_u.offered = q_u.buf_size; + r_u.level = q_u.level; + r_u.status = _spoolss_enumprinterdrivers(&q_u.name, + &q_u.environment, q_u. level, + &r_u.ctr, &r_u.offered, &r_u.numofdrivers); + + spoolss_io_free_buffer(&q_u.buffer); + spoolss_io_r_enumdrivers("",&r_u,rdata,0); + free_spoolss_r_enumdrivers(&r_u); +} + + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_enumforms(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ENUMFORMS q_u; + SPOOL_R_ENUMFORMS r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + DEBUG(5,("spoolss_io_q_enumforms\n")); + + new_spoolss_allocate_buffer(&q_u.buffer); + + if (!spoolss_io_q_enumforms("", &q_u, data, 0)) + return False; + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); + + r_u.status = _new_spoolss_enumforms(&q_u.handle, q_u.level, + r_u.buffer, q_u.offered, + &r_u.needed, &r_u.numofforms); + + if (!new_spoolss_io_r_enumforms("",&r_u,rdata,0)) { + new_spoolss_free_buffer(q_u.buffer); + return False; + } + + new_spoolss_free_buffer(q_u.buffer); + + return True; +} + + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_enumports(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ENUMPORTS q_u; + SPOOL_R_ENUMPORTS r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_enumports("", &q_u, data, 0); + + r_u.offered = q_u.buf_size; + r_u.level = q_u.level; + r_u.status = _spoolss_enumports(&q_u.name, + q_u.level, + &r_u.ctr, + &r_u.offered, + &r_u.numofports); + + spoolss_io_free_buffer(&(q_u.buffer)); + spoolss_io_r_enumports("",&r_u,rdata,0); + spoolss_free_r_enumports(&r_u); +} + + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_addprinterex(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ADDPRINTEREX q_u; + SPOOL_R_ADDPRINTEREX r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_addprinterex("", &q_u, data, 0); + r_u.status = _spoolss_addprinterex(&q_u.server_name, + q_u.level, &q_u.info, + q_u.unk0, q_u.unk1, q_u.unk2, q_u.unk3, + q_u.user_level, &q_u.user, + &r_u.handle); + spoolss_io_r_addprinterex("", &r_u, rdata, 0); +} + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_addprinterdriver(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ADDPRINTERDRIVER q_u; + SPOOL_R_ADDPRINTERDRIVER r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_addprinterdriver("", &q_u, data, 0); + r_u.status = _spoolss_addprinterdriver(&q_u.server_name, + q_u.level, &q_u.info); + spoolss_io_r_addprinterdriver("", &r_u, rdata, 0); +} + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_getprinterdriverdirectory(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_GETPRINTERDRIVERDIR q_u; + SPOOL_R_GETPRINTERDRIVERDIR r_u; + + spoolss_io_q_getprinterdriverdir("", &q_u, data, 0); + + r_u.offered = q_u.buf_size; + r_u.level = q_u.level; + r_u.status = _spoolss_getprinterdriverdirectory(&q_u.name, + &q_u.environment, + q_u.level, + &r_u.ctr, + &r_u.offered); + spoolss_io_free_buffer(&q_u.buffer); + spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0); +} + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_enumprinterdata(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ENUMPRINTERDATA q_u; + SPOOL_R_ENUMPRINTERDATA r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_enumprinterdata("", &q_u, data, 0); + r_u.valuesize = q_u.valuesize; + r_u.datasize = q_u.datasize; + + r_u.status = _spoolss_enumprinterdata(&q_u.handle, + q_u.index,/* in */ + &r_u.valuesize,/* in out */ + &r_u.value,/* out */ + &r_u.realvaluesize,/* out */ + &r_u.type,/* out */ + &r_u.datasize,/* in out */ + &r_u.data,/* out */ + &r_u.realdatasize);/* out */ + spoolss_io_r_enumprinterdata("", &r_u, rdata, 0); + safe_free(r_u.data); +} + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_setprinterdata(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_SETPRINTERDATA q_u; + SPOOL_R_SETPRINTERDATA r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_setprinterdata("", &q_u, data, 0); + r_u.status = _spoolss_setprinterdata(&q_u.handle, + &q_u.value, q_u.type, q_u.max_len, + q_u.data, q_u.real_len, q_u.numeric_data); + spoolss_io_r_setprinterdata("", &r_u, rdata, 0); + safe_free(q_u.data); +} + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_addform(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ADDFORM q_u; + SPOOL_R_ADDFORM r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_addform("", &q_u, data, 0); + r_u.status = _spoolss_addform(&q_u.handle, q_u.level, &q_u.form); + spoolss_io_r_addform("", &r_u, rdata, 0); +} + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_setform(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_SETFORM q_u; + SPOOL_R_SETFORM r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_setform("", &q_u, data, 0); + r_u.status = _spoolss_setform(&q_u.handle, + &q_u.name, q_u.level, &q_u.form); + spoolss_io_r_setform("", &r_u, rdata, 0); +} + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_enumprintprocessors(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ENUMPRINTPROCESSORS q_u; + SPOOL_R_ENUMPRINTPROCESSORS r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_enumprintprocessors("", &q_u, data, 0); + r_u.offered = q_u.buf_size; + r_u.level = q_u.level; + r_u.status = _spoolss_enumprintprocessors(&q_u.name, + &q_u.environment, + q_u.level, + &r_u.info_1, + &r_u.offered, + &r_u.numofprintprocessors); + spoolss_io_free_buffer(&q_u.buffer); + spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0); + safe_free(r_u.info_1); +} + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_enumprintmonitors(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ENUMPRINTMONITORS q_u; + SPOOL_R_ENUMPRINTMONITORS r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + spoolss_io_q_enumprintmonitors("", &q_u, data, 0); + r_u.offered = q_u.buf_size; + r_u.level = q_u.level; + r_u.status = _spoolss_enumprintmonitors(&q_u.name, + q_u.level, + &r_u.info_1, + &r_u.offered, + &r_u.numofprintmonitors); + spoolss_io_free_buffer(&q_u.buffer); + spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0); + safe_free(r_u.info_1); +} + +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_getjob(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_GETJOB q_u; + SPOOL_R_GETJOB r_u; + + spoolss_io_q_getjob("", &q_u, data, 0); + + r_u.offered = q_u.buf_size; + r_u.level = q_u.level; + r_u.status = _spoolss_getjob(&q_u.handle, + q_u.jobid, + q_u.level, + &r_u.ctr, + &r_u.offered); + spoolss_io_free_buffer(&(q_u.buffer)); + spoolss_io_r_getjob("",&r_u,rdata,0); + free_spoolss_r_getjob(&r_u); +} + +/******************************************************************* +\pipe\spoolss commands +********************************************************************/ +struct api_struct api_spoolss_cmds[] = +{ + {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex }, + {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata }, + {"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter }, + {"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex }, + {"SPOOLSS_RFNPCNEX", SPOOLSS_RFNPCNEX, api_spoolss_rfnpcnex }, + {"SPOOLSS_ENUMPRINTERS", SPOOLSS_ENUMPRINTERS, api_spoolss_enumprinters }, + {"SPOOLSS_GETPRINTER", SPOOLSS_GETPRINTER, api_spoolss_getprinter }, + {"SPOOLSS_GETPRINTERDRIVER2", SPOOLSS_GETPRINTERDRIVER2, api_spoolss_getprinterdriver2 }, + {"SPOOLSS_STARTPAGEPRINTER", SPOOLSS_STARTPAGEPRINTER, api_spoolss_startpageprinter }, + {"SPOOLSS_ENDPAGEPRINTER", SPOOLSS_ENDPAGEPRINTER, api_spoolss_endpageprinter }, + {"SPOOLSS_STARTDOCPRINTER", SPOOLSS_STARTDOCPRINTER, api_spoolss_startdocprinter }, + {"SPOOLSS_ENDDOCPRINTER", SPOOLSS_ENDDOCPRINTER, api_spoolss_enddocprinter }, + {"SPOOLSS_WRITEPRINTER", SPOOLSS_WRITEPRINTER, api_spoolss_writeprinter }, + {"SPOOLSS_SETPRINTER", SPOOLSS_SETPRINTER, api_spoolss_setprinter }, + {"SPOOLSS_FCPN", SPOOLSS_FCPN, api_spoolss_fcpn }, + {"SPOOLSS_ADDJOB", SPOOLSS_ADDJOB, api_spoolss_addjob }, + {"SPOOLSS_ENUMJOBS", SPOOLSS_ENUMJOBS, api_spoolss_enumjobs }, + {"SPOOLSS_SCHEDULEJOB", SPOOLSS_SCHEDULEJOB, api_spoolss_schedulejob }, + {"SPOOLSS_SETJOB", SPOOLSS_SETJOB, api_spoolss_setjob }, + {"SPOOLSS_ENUMFORMS", SPOOLSS_ENUMFORMS, api_spoolss_enumforms }, + {"SPOOLSS_ENUMPORTS", SPOOLSS_ENUMPORTS, api_spoolss_enumports }, + {"SPOOLSS_ENUMPRINTERDRIVERS", SPOOLSS_ENUMPRINTERDRIVERS, api_spoolss_enumprinterdrivers }, + {"SPOOLSS_ADDPRINTEREX", SPOOLSS_ADDPRINTEREX, api_spoolss_addprinterex }, + {"SPOOLSS_ADDPRINTERDRIVER", SPOOLSS_ADDPRINTERDRIVER, api_spoolss_addprinterdriver }, + {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory }, + {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata }, + {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata }, + {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform }, + {"SPOOLSS_SETFORM", SPOOLSS_SETFORM, api_spoolss_setform }, + {"SPOOLSS_ENUMPRINTPROCESSORS", SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_enumprintprocessors }, + {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors }, + {"SPOOLSS_GETJOB", SPOOLSS_GETJOB, api_spoolss_getjob }, + { NULL, 0, NULL } +}; + +/******************************************************************* +receives a spoolss pipe and responds. +********************************************************************/ +BOOL api_spoolss_rpc(pipes_struct *p, prs_struct *data) +{ + return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds, data); +} + diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c new file mode 100644 index 0000000000..db48fa42ff --- /dev/null +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -0,0 +1,3434 @@ +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-2000, + * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, + * Copyright (C) Jean François Micouleau 1998-2000. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; +extern pstring global_myname; + +#ifndef MAX_OPEN_PRINTER_EXS +#define MAX_OPEN_PRINTER_EXS 50 +#endif + +#define PRINTER_HANDLE_IS_PRINTER 0 +#define PRINTER_HANDLE_IS_PRINTSERVER 1 + +/* structure to store the printer handles */ +/* and a reference to what it's pointing to */ +/* and the notify info asked about */ +/* that's the central struct */ +static struct +{ + BOOL open; + BOOL ok; + BOOL document_started; + BOOL page_started; + uint32 current_jobid; + uint32 document_fd; + uint32 document_lastwritten; + pstring document_name; + pstring job_name; + POLICY_HND printer_hnd; + BOOL printer_type; + union + { + fstring printername; + fstring printerservername; + } dev; + uint32 type; + uint32 access; + uint32 number_of_notify; + SPOOL_NOTIFY_OPTION_TYPE notify_info[MAX_PRINTER_NOTIFY+MAX_JOB_NOTIFY]; +} Printer[MAX_OPEN_PRINTER_EXS]; + +#define VALID_HANDLE(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PRINTER_EXS)) +#define OPEN_HANDLE(pnum) (VALID_HANDLE(pnum) && Printer[pnum].open) + +/**************************************************************************** + initialise printer handle states... +****************************************************************************/ +void init_printer_hnd(void) +{ + int i; + for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++) + { + Printer[i].open = False; + } +} + +/**************************************************************************** + create a unique printer handle +****************************************************************************/ +static void create_printer_hnd(POLICY_HND *hnd) +{ + static uint32 prt_hnd_low = 0; + static uint32 prt_hnd_high = 0; + + if (hnd == NULL) return; + + /* i severely doubt that prt_hnd_high will ever be non-zero... */ + prt_hnd_low++; + if (prt_hnd_low == 0) prt_hnd_high++; + + SIVAL(hnd->data, 0 , 0x0); /* first bit must be null */ + SIVAL(hnd->data, 4 , prt_hnd_low ); /* second bit is incrementing */ + SIVAL(hnd->data, 8 , prt_hnd_high); /* second bit is incrementing */ + SIVAL(hnd->data, 12, time(NULL)); /* something random */ + SIVAL(hnd->data, 16, getpid()); /* something more random */ +} + +/**************************************************************************** + find printer index by handle +****************************************************************************/ +static int find_printer_index_by_hnd(const POLICY_HND *hnd) +{ + int i; + + for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++) + { + if (memcmp(&(Printer[i].printer_hnd), hnd, sizeof(*hnd)) == 0) + { + DEBUG(4,("Found printer handle[%x] ", i)); + dump_data(4, hnd->data, sizeof(hnd->data)); + return i; + } + } + DEBUG(3,("Whoops, Printer handle not found: ")); + dump_data(4, hnd->data, sizeof(hnd->data)); + return -1; +} + +/**************************************************************************** + clear an handle +****************************************************************************/ +static void clear_handle(POLICY_HND *hnd) +{ + bzero(hnd->data, POLICY_HND_SIZE); +} + +/**************************************************************************** + close printer index by handle +****************************************************************************/ +static BOOL close_printer_handle(POLICY_HND *hnd) +{ + int pnum = find_printer_index_by_hnd(hnd); + + if (pnum == -1) + { + DEBUG(3,("Error closing printer handle (pnum=%x)\n", pnum)); + return False; + } + + Printer[pnum].open=False; + clear_handle(hnd); + + return True; +} + +/**************************************************************************** + return the snum of a printer corresponding to an handle +****************************************************************************/ +static BOOL get_printer_snum(const POLICY_HND *hnd, int *number) +{ + int snum; + int pnum = find_printer_index_by_hnd(hnd); + int n_services=lp_numservices(); + + if (!OPEN_HANDLE(pnum)) { + DEBUG(3,("Error getting printer - take a nap quickly !\n")); + return False; + } + + switch (Printer[pnum].printer_type) { + case PRINTER_HANDLE_IS_PRINTER: + DEBUG(4,("short name:%s\n", Printer[pnum].dev.printername)); + for (snum=0;snumdata, sizeof(hnd->data)); + return True; + } + } + DEBUG(1,("ERROR - open_printer_hnd: out of Printers Handles!\n")); + return False; +} + +/**************************************************************************** + set printer handle type. +****************************************************************************/ +static BOOL set_printer_hnd_accesstype(POLICY_HND *hnd, uint32 access_required) +{ + int pnum = find_printer_index_by_hnd(hnd); + + if (OPEN_HANDLE(pnum)) { + DEBUG(4,("Setting printer access=%x (pnum=%x)\n", access_required, pnum)); + Printer[pnum].access = access_required; + return True; + } + else { + DEBUG(4,("Error setting printer type=%x (pnum=%x)", access_required, pnum)); + return False; + } + return False; +} + +/**************************************************************************** + . +****************************************************************************/ +static BOOL printer_entry_is_valid(POLICY_HND *hnd) +{ + int pnum = find_printer_index_by_hnd(hnd); + + if (!OPEN_HANDLE(pnum)) + return False; + + if (Printer[pnum].ok == False) + return False; + + return True; +} + +/**************************************************************************** + set printer handle type. + check if it's \\server or \\server\printer +****************************************************************************/ +static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername) +{ + int pnum = find_printer_index_by_hnd(hnd); + + if (!OPEN_HANDLE(pnum)) { + DEBUGADD(4,("Error setting printer name %s (pnum=%x)", printername, pnum)); + return False; + } + + DEBUG(3,("Setting printer type=%s (pnum=%x)\n", printername, pnum)); + + if ( strlen(printername) < 3 ) { + DEBUGADD(4,("A print server must have at least 1 char ! %s\n", printername)); + Printer[pnum].ok=False; + return False; + } + + /* it's a print server */ + if (!strchr(printername+2, '\\')) { + DEBUGADD(4,("Printer is a print server\n")); + Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTSERVER; + Printer[pnum].ok=True; + + return True; + } + /* it's a printer */ + else { + DEBUGADD(4,("Printer is a printer\n")); + Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTER; + Printer[pnum].ok=True; + return True; + } + + return False; +} + +/**************************************************************************** + set printer handle printername. +****************************************************************************/ +static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) +{ + int pnum = find_printer_index_by_hnd(hnd); + char *back; + NT_PRINTER_INFO_LEVEL printer; + int snum; + int n_services=lp_numservices(); + uint32 marche; + + if (!OPEN_HANDLE(pnum)) + { + DEBUG(0,("Error setting printer name=%s (pnum=%x)\n", printername, pnum)); + return False; + } + + DEBUG(4,("Setting printer name=%s (len=%d) (pnum=%x)\n", printername, strlen(printername), pnum)); + + switch (Printer[pnum].printer_type) { + case PRINTER_HANDLE_IS_PRINTSERVER: + ZERO_STRUCT(Printer[pnum].dev.printerservername); + strncpy(Printer[pnum].dev.printerservername, printername, strlen(printername)); + return True; + break; + + case PRINTER_HANDLE_IS_PRINTER: + back=strchr(printername+2, '\\'); + back=back+1; + DEBUGADD(5,("searching for %s (len=%d)\n", back,strlen(back))); + /* + * store the Samba share name in it + * in back we have the long printer name + * need to iterate all the snum and do a + * get_a_printer each time to find the printer + * faster to do it here than later. + */ + for (snum=0;snumprintername) == strlen(back) ) + && ( !strncasecmp(printer.info_2->printername, back, strlen(back))) + ) { + DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); + ZERO_STRUCT(Printer[pnum].dev.printername); + strncpy(Printer[pnum].dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); + free_a_printer(printer, 2); + return True; + break; + } + free_a_printer(printer, 2); + } + } + return False; + break; + + default: + return False; + break; + } +} + +/******************************************************************** + ********************************************************************/ +static BOOL handle_is_printserver(const POLICY_HND *handle) +{ + int pnum=find_printer_index_by_hnd(handle); + + if (!OPEN_HANDLE(pnum)) + return False; + + if (Printer[pnum].printer_type != PRINTER_HANDLE_IS_PRINTSERVER) + return False; + + return True; +} + +/******************************************************************** + * spoolss_open_printer + * + * called from the spoolss dispatcher + ********************************************************************/ +uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, + const PRINTER_DEFAULT *printer_default, + uint32 user_switch, SPOOL_USER_CTR user_ctr, + POLICY_HND *handle) +{ + BOOL printer_open = False; + fstring name; + fstring datatype; + + clear_handle(handle); + + if (printername == NULL) + return NT_STATUS_ACCESS_DENIED; + + /* some sanity check because you can open a printer or a print server */ + /* aka: \\server\printer or \\server */ + unistr2_to_ascii(name, printername, sizeof(name)-1); + + DEBUGADD(3,("checking name: %s\n",name)); + + create_printer_hnd(handle); + + open_printer_hnd(handle); + + set_printer_hnd_printertype(handle, name); + + set_printer_hnd_printername(handle, name); + +/* + if (printer_default->datatype_ptr != NULL) + { + unistr2_to_ascii(datatype, printer_default->datatype, sizeof(datatype)-1); + set_printer_hnd_datatype(handle, datatype); + } + else + set_printer_hnd_datatype(handle, ""); +*/ + + set_printer_hnd_accesstype(handle, printer_default->access_required); + + if (!printer_entry_is_valid(handle)) + { + close_printer_handle(handle); + return NT_STATUS_ACCESS_DENIED; + } + + return NT_STATUS_NO_PROBLEMO; +} + +static BOOL convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni, + NT_PRINTER_INFO_LEVEL *printer, + uint32 level) +{ + switch (level) + { + case 2: + { + uni_2_asc_printer_info_2(uni->info_2, + &(printer->info_2)); + break; + } + default: + break; + } + + + + return True; +} + +static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *uni, + NT_PRINTER_DRIVER_INFO_LEVEL *printer, + uint32 level) +{ + switch (level) + { + case 3: + { + printer->info_3=NULL; + uni_2_asc_printer_driver_3(uni->info_3, &(printer->info_3)); + break; + } + default: + break; + } + + + + return True; +} + +static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode) +{ + unistr_to_ascii(nt_devmode->devicename, + devmode.devicename.buffer, + 31); + + unistr_to_ascii(nt_devmode->formname, + devmode.formname.buffer, + 31); + + nt_devmode->specversion=devmode.specversion; + nt_devmode->driverversion=devmode.driverversion; + nt_devmode->size=devmode.size; + nt_devmode->driverextra=devmode.driverextra; + nt_devmode->fields=devmode.fields; + nt_devmode->orientation=devmode.orientation; + nt_devmode->papersize=devmode.papersize; + nt_devmode->paperlength=devmode.paperlength; + nt_devmode->paperwidth=devmode.paperwidth; + nt_devmode->scale=devmode.scale; + nt_devmode->copies=devmode.copies; + nt_devmode->defaultsource=devmode.defaultsource; + nt_devmode->printquality=devmode.printquality; + nt_devmode->color=devmode.color; + nt_devmode->duplex=devmode.duplex; + nt_devmode->yresolution=devmode.yresolution; + nt_devmode->ttoption=devmode.ttoption; + nt_devmode->collate=devmode.collate; + + nt_devmode->logpixels=devmode.logpixels; + nt_devmode->bitsperpel=devmode.bitsperpel; + nt_devmode->pelswidth=devmode.pelswidth; + nt_devmode->pelsheight=devmode.pelsheight; + nt_devmode->displayflags=devmode.displayflags; + nt_devmode->displayfrequency=devmode.displayfrequency; + nt_devmode->icmmethod=devmode.icmmethod; + nt_devmode->icmintent=devmode.icmintent; + nt_devmode->mediatype=devmode.mediatype; + nt_devmode->dithertype=devmode.dithertype; + nt_devmode->reserved1=devmode.reserved1; + nt_devmode->reserved2=devmode.reserved2; + nt_devmode->panningwidth=devmode.panningwidth; + nt_devmode->panningheight=devmode.panningheight; + + if (nt_devmode->driverextra != 0) + { + /* if we had a previous private delete it and make a new one */ + if (nt_devmode->private != NULL) + free(nt_devmode->private); + nt_devmode->private=(uint8 *)malloc(nt_devmode->driverextra * sizeof(uint8)); + memcpy(nt_devmode->private, devmode.private, nt_devmode->driverextra); + } + + + return True; +} + +/******************************************************************** + * api_spoolss_closeprinter + ********************************************************************/ +uint32 _spoolss_closeprinter(POLICY_HND *handle) +{ + if (!close_printer_handle(handle)) + return NT_STATUS_INVALID_HANDLE; + + return NT_STATUS_NO_PROBLEMO; +} + +/******************************************************************** + ********************************************************************/ +static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **data, uint32 *needed) +{ + int i; + + if (!strcmp(value, "BeepEnabled")) + { + *type = 0x4; + *data = (uint8 *)malloc( 4*sizeof(uint8) ); + SIVAL(data, 0, 0x01); + *needed = 0x4; + return True; + } + + if (!strcmp(value, "EventLog")) + { + *type = 0x4; + *data = (uint8 *)malloc( 4*sizeof(uint8) ); + SIVAL(data, 0, 0x1B); + *needed = 0x4; + return True; + } + + if (!strcmp(value, "NetPopup")) + { + *type = 0x4; + *data = (uint8 *)malloc( 4*sizeof(uint8) ); + SIVAL(data, 0, 0x01); + *needed = 0x4; + return True; + } + + if (!strcmp(value, "MajorVersion")) + { + *type = 0x4; + *data = (uint8 *)malloc( 4*sizeof(uint8) ); + SIVAL(data, 0, 0x02); + *needed = 0x4; + return True; + } + + if (!strcmp(value, "DefaultSpoolDirectory")) + { + pstring directory="You are using a Samba server"; + *type = 0x1; + *needed = 2*(strlen(directory)+1); + *data = (uint8 *)malloc(*needed *sizeof(uint8)); + ZERO_STRUCTP(*data); + + /* it's done by hand ready to go on the wire */ + for (i=0; i *out_size) + return ERROR_INSUFFICIENT_BUFFER; + else + return NT_STATUS_NO_PROBLEMO; +} + +/******************************************************************** + * _spoolss_rffpcnex + * ReplyFindFirstPrinterChangeNotifyEx + * + * jfmxxxx: before replying OK: status=0 + * should do a rpc call to the workstation asking ReplyOpenPrinter + * have to code it, later. + * + * in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe + * called from api_spoolss_rffpcnex + ********************************************************************/ +uint32 _spoolss_rffpcnex(const POLICY_HND *handle, + uint32 flags, uint32 options, + const UNISTR2 *localmachine, + uint32 printerlocal, + SPOOL_NOTIFY_OPTION *option) +{ + int i,j,k; + + /* store the notify value in the printer struct */ + + i=find_printer_index_by_hnd(handle); + + if (i == -1) + { + return NT_STATUS_INVALID_HANDLE; + } + + Printer[i].number_of_notify=option->count; + + DEBUG(3,("Copying %x notify option info\n",Printer[i].number_of_notify)); + + for (j=0;jtype[j].count; + Printer[i].notify_info[j].type=option->type[j].type ; + + DEBUG(4,("Copying %x info fields of type %x\n", + Printer[i].notify_info[j].count, + Printer[i].notify_info[j].type)); + for(k=0;ktype[j].fields[k]; + } + } + + return 0x0; +} + +/******************************************************************* + * fill a notify_info_data with the servername + ********************************************************************/ +static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + pstring temp_name; + + snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); + + data->notify_data.data.length=strlen(temp_name); + ascii_to_unistr(data->notify_data.data.string, temp_name, sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the servicename + * jfmxxxx: it's incorrect should be long_printername + ********************************************************************/ +static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ +/* + data->notify_data.data.length=strlen(lp_servicename(snum)); + ascii_to_unistr(data->notify_data.data.string, lp_servicename(snum), sizeof(data->notify_data.data.string)-1); +*/ + data->notify_data.data.length=strlen(printer->info_2->printername); + ascii_to_unistr(data->notify_data.data.string, + printer->info_2->printername, + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the servicename + ********************************************************************/ +static void spoolss_notify_share_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(lp_servicename(snum)); + ascii_to_unistr(data->notify_data.data.string, + lp_servicename(snum), + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the port name + ********************************************************************/ +static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + /* even if it's strange, that's consistant in all the code */ + + data->notify_data.data.length=strlen(lp_servicename(snum)); + ascii_to_unistr(data->notify_data.data.string, + lp_servicename(snum), + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the printername + * jfmxxxx: it's incorrect, should be lp_printerdrivername() + * but it doesn't exist, have to see what to do + ********************************************************************/ +static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(printer->info_2->drivername); + ascii_to_unistr(data->notify_data.data.string, + printer->info_2->drivername, + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the comment + ********************************************************************/ +static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(lp_comment(snum)); + ascii_to_unistr(data->notify_data.data.string, + lp_comment(snum), + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the comment + * jfm:xxxx incorrect, have to create a new smb.conf option + * location = "Room 1, floor 2, building 3" + ********************************************************************/ +static void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(printer->info_2->location); + ascii_to_unistr(data->notify_data.data.string, + printer->info_2->location, + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the device mode + * jfm:xxxx don't to it for know but that's a real problem !!! + ********************************************************************/ +static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ +} + +/******************************************************************* + * fill a notify_info_data with the separator file name + * jfm:xxxx just return no file could add an option to smb.conf + * separator file = "separator.txt" + ********************************************************************/ +static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(printer->info_2->sepfile); + ascii_to_unistr(data->notify_data.data.string, + printer->info_2->sepfile, + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the print processor + * jfm:xxxx return always winprint to indicate we don't do anything to it + ********************************************************************/ +static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(printer->info_2->printprocessor); + ascii_to_unistr(data->notify_data.data.string, + printer->info_2->printprocessor, + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the print processor options + * jfm:xxxx send an empty string + ********************************************************************/ +static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(printer->info_2->parameters); + ascii_to_unistr(data->notify_data.data.string, + printer->info_2->parameters, + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the data type + * jfm:xxxx always send RAW as data type + ********************************************************************/ +static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(printer->info_2->datatype); + ascii_to_unistr(data->notify_data.data.string, + printer->info_2->datatype, + sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with the security descriptor + * jfm:xxxx send an null pointer to say no security desc + * have to implement security before ! + ********************************************************************/ +static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=0; + data->notify_data.data.string[0]=0x00; +} + +/******************************************************************* + * fill a notify_info_data with the attributes + * jfm:xxxx a samba printer is always shared + ********************************************************************/ +static void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0] = PRINTER_ATTRIBUTE_SHARED \ + | PRINTER_ATTRIBUTE_NETWORK \ + | PRINTER_ATTRIBUTE_RAW_ONLY ; +} + +/******************************************************************* + * fill a notify_info_data with the priority + ********************************************************************/ +static void spoolss_notify_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0] = printer->info_2->priority; +} + +/******************************************************************* + * fill a notify_info_data with the default priority + ********************************************************************/ +static void spoolss_notify_default_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0] = printer->info_2->default_priority; +} + +/******************************************************************* + * fill a notify_info_data with the start time + ********************************************************************/ +static void spoolss_notify_start_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0] = printer->info_2->starttime; +} + +/******************************************************************* + * fill a notify_info_data with the until time + ********************************************************************/ +static void spoolss_notify_until_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0] = printer->info_2->untiltime; +} + +/******************************************************************* + * fill a notify_info_data with the status + ********************************************************************/ +static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + int count; + print_queue_struct *q=NULL; + print_status_struct status; + + bzero(&status,sizeof(status)); + + count=get_printqueue(snum, NULL, &q, &status); + + data->notify_data.value[0]=(uint32) status.status; + if (q) free(q); +} + +/******************************************************************* + * fill a notify_info_data with the number of jobs queued + ********************************************************************/ +static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + print_queue_struct *q=NULL; + print_status_struct status; + + bzero(&status,sizeof(status)); + + data->notify_data.value[0]=get_printqueue(snum, NULL, &q, &status); + if (q) free(q); +} + +/******************************************************************* + * fill a notify_info_data with the average ppm + ********************************************************************/ +static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + /* always respond 8 pages per minutes */ + /* a little hard ! */ + data->notify_data.value[0] = printer->info_2->averageppm; +} + +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(queue->user); + ascii_to_unistr(data->notify_data.data.string, queue->user, sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0]=queue->status; +} + +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen(queue->file); + ascii_to_unistr(data->notify_data.data.string, queue->file, sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.data.length=strlen("En attente"); + ascii_to_unistr(data->notify_data.data.string, "En attente", sizeof(data->notify_data.data.string)-1); +} + +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0]=0x0; +} + +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0]=queue->size; +} + +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + data->notify_data.value[0]=queue->job; +} + +#define END 65535 + +struct s_notify_info_data_table notify_info_data_table[] = +{ +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", POINTER, spoolss_notify_server_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, "PRINTER_NOTIFY_PRINTER_NAME", POINTER, spoolss_notify_printer_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SHARE_NAME, "PRINTER_NOTIFY_SHARE_NAME", POINTER, spoolss_notify_share_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PORT_NAME, "PRINTER_NOTIFY_PORT_NAME", POINTER, spoolss_notify_port_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DRIVER_NAME, "PRINTER_NOTIFY_DRIVER_NAME", POINTER, spoolss_notify_driver_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_COMMENT, "PRINTER_NOTIFY_COMMENT", POINTER, spoolss_notify_comment }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_LOCATION, "PRINTER_NOTIFY_LOCATION", POINTER, spoolss_notify_location }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEVMODE, "PRINTER_NOTIFY_DEVMODE", POINTER, spoolss_notify_devmode }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SEPFILE, "PRINTER_NOTIFY_SEPFILE", POINTER, spoolss_notify_sepfile }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINT_PROCESSOR, "PRINTER_NOTIFY_PRINT_PROCESSOR", POINTER, spoolss_notify_print_processor }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PARAMETERS, "PRINTER_NOTIFY_PARAMETERS", POINTER, spoolss_notify_parameters }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DATATYPE, "PRINTER_NOTIFY_DATATYPE", POINTER, spoolss_notify_datatype }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SECURITY_DESCRIPTOR, "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", POINTER, spoolss_notify_security_desc }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_ATTRIBUTES, "PRINTER_NOTIFY_ATTRIBUTES", ONE_VALUE, spoolss_notify_attributes }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRIORITY, "PRINTER_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEFAULT_PRIORITY, "PRINTER_NOTIFY_DEFAULT_PRIORITY", ONE_VALUE, spoolss_notify_default_priority }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_START_TIME, "PRINTER_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_UNTIL_TIME, "PRINTER_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS, "PRINTER_NOTIFY_STATUS", ONE_VALUE, spoolss_notify_status }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS_STRING, "PRINTER_NOTIFY_STATUS_STRING", POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_CJOBS, "PRINTER_NOTIFY_CJOBS", ONE_VALUE, spoolss_notify_cjobs }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_AVERAGE_PPM, "PRINTER_NOTIFY_AVERAGE_PPM", ONE_VALUE, spoolss_notify_average_ppm }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_PAGES, "PRINTER_NOTIFY_TOTAL_PAGES", POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PAGES_PRINTED, "PRINTER_NOTIFY_PAGES_PRINTED", POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_BYTES, "PRINTER_NOTIFY_TOTAL_BYTES", POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_BYTES_PRINTED, "PRINTER_NOTIFY_BYTES_PRINTED", POINTER, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINTER_NAME, "JOB_NOTIFY_PRINTER_NAME", POINTER, spoolss_notify_printer_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_MACHINE_NAME, "JOB_NOTIFY_MACHINE_NAME", POINTER, spoolss_notify_server_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PORT_NAME, "JOB_NOTIFY_PORT_NAME", POINTER, spoolss_notify_port_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_USER_NAME, "JOB_NOTIFY_USER_NAME", POINTER, spoolss_notify_username }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_NOTIFY_NAME, "JOB_NOTIFY_NOTIFY_NAME", POINTER, spoolss_notify_username }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DATATYPE, "JOB_NOTIFY_DATATYPE", POINTER, spoolss_notify_datatype }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINT_PROCESSOR, "JOB_NOTIFY_PRINT_PROCESSOR", POINTER, spoolss_notify_print_processor }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PARAMETERS, "JOB_NOTIFY_PARAMETERS", POINTER, spoolss_notify_parameters }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DRIVER_NAME, "JOB_NOTIFY_DRIVER_NAME", POINTER, spoolss_notify_driver_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DEVMODE, "JOB_NOTIFY_DEVMODE", POINTER, spoolss_notify_devmode }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS, "JOB_NOTIFY_STATUS", ONE_VALUE, spoolss_notify_job_status }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS_STRING, "JOB_NOTIFY_STATUS_STRING", POINTER, spoolss_notify_job_status_string }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SECURITY_DESCRIPTOR, "JOB_NOTIFY_SECURITY_DESCRIPTOR", POINTER, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DOCUMENT, "JOB_NOTIFY_DOCUMENT", POINTER, spoolss_notify_job_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRIORITY, "JOB_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_POSITION, "JOB_NOTIFY_POSITION", ONE_VALUE, spoolss_notify_job_position }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SUBMITTED, "JOB_NOTIFY_SUBMITTED", POINTER, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_START_TIME, "JOB_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_UNTIL_TIME, "JOB_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TIME, "JOB_NOTIFY_TIME", ONE_VALUE, spoolss_notify_job_time }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", ONE_VALUE, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", ONE_VALUE, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_BYTES, "JOB_NOTIFY_TOTAL_BYTES", ONE_VALUE, spoolss_notify_job_size }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_BYTES_PRINTED, "JOB_NOTIFY_BYTES_PRINTED", ONE_VALUE, NULL }, +{ END, END, "", END, NULL } +}; + +/******************************************************************* +return the size of info_data structure +********************************************************************/ +static uint32 size_of_notify_info_data(uint16 type, uint16 field) +{ + int i=0; + + while (notify_info_data_table[i].type != END) + { + if ( (notify_info_data_table[i].type == type ) && + (notify_info_data_table[i].field == field ) ) + { + return (notify_info_data_table[i].size); + continue; + } + i++; + } + return (65535); +} + +/******************************************************************* +return the type of notify_info_data +********************************************************************/ +static BOOL type_of_notify_info_data(uint16 type, uint16 field) +{ + int i=0; + + while (notify_info_data_table[i].type != END) + { + if ( (notify_info_data_table[i].type == type ) && + (notify_info_data_table[i].field == field ) ) + { + if (notify_info_data_table[i].size == POINTER) + { + return (False); + } + else + { + return (True); + } + continue; + } + i++; + } + return (False); +} + +/**************************************************************************** +****************************************************************************/ +static int search_notify(uint16 type, uint16 field, int *value) +{ + int j; + BOOL found; + + DEBUG(4,("\tsearch_notify: in\n")); + for (j=0, found=False; found==False && notify_info_data_table[j].type != END ; j++) + { + if ( (notify_info_data_table[j].type == type ) && + (notify_info_data_table[j].field == field ) ) + { + found=True; + } + } + *value=--j; + + if ( found && (notify_info_data_table[j].fn != NULL) ) + { + DEBUG(4,("\tsearch_notify: out TRUE\n")); + return (True); + } + else + { + DEBUG(4,("\tsearch_notify: out FALSE\n")); + return (False); + } +} + +/**************************************************************************** +****************************************************************************/ +static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 field, int id) +{ + DEBUG(4,("\tconstruct_info_data: in\n")); + info_data->type = type; + info_data->field = field; + info_data->id = id; + info_data->size = size_of_notify_info_data(type, field); + info_data->enc_type = type_of_notify_info_data(type, field); + DEBUG(4,("\tconstruct_info_data: out\n")); +} + + +/******************************************************************* + * + * fill a notify_info struct with info asked + * + ********************************************************************/ +static void construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int pnum, + int snum, int i, uint32 id) +{ + + int k,j; + uint16 type; + uint16 field; + + SPOOL_NOTIFY_INFO_DATA *info_data; + print_queue_struct *queue=NULL; + NT_PRINTER_INFO_LEVEL printer; + + DEBUG(4,("construct_notify_printer_info\n")); + + info_data=&(info->data[info->count]); + + type = Printer[pnum].notify_info[i].type; + + DEBUGADD(4,("Notify number %d -> number of notify info: %d\n",i,Printer[pnum].notify_info[i].count)); + + if (!get_a_printer(&printer, 2, lp_servicename(snum))) + { + + for(k=0; kcount++; + info_data=&(info->data[info->count]); + } + } + + free_a_printer(printer, 2); + } +} + +/******************************************************************* + * + * fill a notify_info struct with info asked + * + ********************************************************************/ +static void construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, + int pnum, int snum, int i, uint32 id) +{ + + int k,j; + uint16 type; + uint16 field; + + SPOOL_NOTIFY_INFO_DATA *info_data; + NT_PRINTER_INFO_LEVEL printer; + + DEBUG(4,("construct_notify_jobs_info\n")); + info_data=&(info->data[info->count]); + + type = Printer[pnum].notify_info[i].type; + + DEBUGADD(4,("Notify number %d -> number of notify info: %d\n",i,Printer[pnum].notify_info[i].count)); + + if (!get_a_printer(&printer, 2, lp_servicename(snum))) + { + for(k=0; kcount++; + info_data=&(info->data[info->count]); + } + } + free_a_printer(printer, 2); + } +} + + +/******************************************************************* + * + * enumerate all printers on the printserver + * fill a notify_info struct with info asked + * + ********************************************************************/ +static uint32 printserver_notify_info(const POLICY_HND *hnd, + SPOOL_NOTIFY_INFO *info) +{ + int snum; + int pnum=find_printer_index_by_hnd(hnd); + int n_services=lp_numservices(); + int i=0; + uint32 id=1; + info->count=0; + + if (pnum == -1) + { + return NT_STATUS_INVALID_HANDLE; + } + + DEBUG(4,("Enumerating printers\n")); + + for (i=0; icount=0; + + if (pnum == -1 || !get_printer_snum(hnd, &snum) ) + { + return NT_STATUS_INVALID_HANDLE; + } + + for (i=0; iprintername); + + init_unistr(&(printer->printername), chaine); + + slprintf(chaine,sizeof(chaine)-1,"\\\\%s", servername); + init_unistr(&(printer->servername), chaine); + + printer->cjobs = count; + printer->attributes = PRINTER_ATTRIBUTE_SHARED \ + | PRINTER_ATTRIBUTE_NETWORK \ + | PRINTER_ATTRIBUTE_RAW_ONLY ; + printer->unknown0 = 0x1; /* pointer */ + printer->unknown1 = 0x000A07CE; /* don't known */ + printer->unknown2 = 0x00020005; + printer->unknown3 = 0x0006000D; + printer->unknown4 = 0x02180026; + printer->unknown5 = 0x09; + printer->unknown6 = 0x36; + printer->majorversion = 0x0004; /* NT 4 */ + printer->buildversion = 0x0565; /* build 1381 */ + printer->unknown7 = 0x1; + printer->unknown8 = 0x0; + printer->unknown9 = 0x2; + printer->unknown10 = 0x3; + printer->unknown11 = 0x0; + printer->unknown12 = 0x0; + printer->unknown13 = 0x0; + printer->unknown14 = 0x1; + printer->unknown15 = 0x024a; /*586 Pentium ? */ + printer->unknown16 = 0x0; + printer->unknown17 = 0x423ed444; + printer->unknown18 = 0x0; + printer->status = status.status; + printer->unknown20 = 0x0; + printer->unknown21 = 0x0648; + printer->unknown22 = 0x0; + printer->unknown23 = 0x5; + + safe_free(queue); + + free_a_printer(ntprinter, 2); + return (True); +} + +/******************************************************************** + * construct_printer_info_1 + * fill a printer_info_1 struct + ********************************************************************/ +static BOOL construct_printer_info_1(PRINTER_INFO_1 *printer,int snum, pstring servername) +{ + pstring chaine; + NT_PRINTER_INFO_LEVEL ntprinter; + + if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0) + { + return (False); + } + + printer->flags=PRINTER_ENUM_NAME; + + /* the description and the name are of the form \\server\share */ + slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s,%s,%s",servername, + ntprinter.info_2->printername, + ntprinter.info_2->drivername, + lp_comment(snum)); + init_unistr(&(printer->description), chaine); + + slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s", servername, ntprinter.info_2->printername); + init_unistr(&(printer->name), chaine); + + init_unistr(&(printer->comment), lp_comment(snum)); + + free_a_printer(ntprinter, 2); + return (True); +} + +/**************************************************************************** +****************************************************************************/ +static void construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) +{ + char adevice[32]; + char aform[32]; + NT_PRINTER_INFO_LEVEL printer; + NT_DEVICEMODE *ntdevmode; + + DEBUG(7,("construct_dev_mode\n")); + + bzero(&(devmode->devicename), 2*sizeof(adevice)); + bzero(&(devmode->formname), 2*sizeof(aform)); + + DEBUGADD(8,("getting printer characteristics\n")); + + get_a_printer(&printer, 2, lp_servicename(snum)); + ntdevmode=(printer.info_2)->devmode; + + DEBUGADD(8,("loading DEVICEMODE\n")); + snprintf(adevice, sizeof(adevice), "\\\\%s\\%s", global_myname, + printer.info_2->printername); + init_unistr(&(devmode->devicename), adevice); + + snprintf(aform, sizeof(aform), ntdevmode->formname); + init_unistr(&(devmode->formname), aform); + + devmode->specversion = ntdevmode->specversion; + devmode->driverversion = ntdevmode->driverversion; + devmode->size = ntdevmode->size; + devmode->driverextra = ntdevmode->driverextra; + devmode->fields = ntdevmode->fields; + + devmode->orientation = ntdevmode->orientation; + devmode->papersize = ntdevmode->papersize; + devmode->paperlength = ntdevmode->paperlength; + devmode->paperwidth = ntdevmode->paperwidth; + devmode->scale = ntdevmode->scale; + devmode->copies = ntdevmode->copies; + devmode->defaultsource = ntdevmode->defaultsource; + devmode->printquality = ntdevmode->printquality; + devmode->color = ntdevmode->color; + devmode->duplex = ntdevmode->duplex; + devmode->yresolution = ntdevmode->yresolution; + devmode->ttoption = ntdevmode->ttoption; + devmode->collate = ntdevmode->collate; + devmode->icmmethod = ntdevmode->icmmethod; + devmode->icmintent = ntdevmode->icmintent; + devmode->mediatype = ntdevmode->mediatype; + devmode->dithertype = ntdevmode->dithertype; + + if (ntdevmode->private != NULL) + { + devmode->private=(uint8 *)malloc(devmode->driverextra*sizeof(uint8)); + memcpy(devmode->private, ntdevmode->private, devmode->driverextra); + } + + free_a_printer(printer, 2); +} + +/******************************************************************** + * construct_printer_info_2 + * fill a printer_info_2 struct + ********************************************************************/ +static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring servername) +{ + pstring chaine; + int count; + DEVICEMODE *devmode; + NT_PRINTER_INFO_LEVEL ntprinter; + + print_queue_struct *queue=NULL; + print_status_struct status; + bzero(&status, sizeof(status)); + count=get_printqueue(snum, NULL, &queue, &status); + + if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) + { + return (False); + } + + snprintf(chaine, sizeof(chaine)-1, "\\\\%s", servername); + init_unistr(&(printer->servername), chaine); /* servername*/ + + snprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", servername, ntprinter.info_2->printername); + init_unistr(&(printer->printername), chaine); /* printername*/ + + init_unistr(&(printer->sharename), lp_servicename(snum)); /* sharename */ + + init_unistr(&(printer->portname), lp_servicename(snum)); /* port */ + init_unistr(&(printer->drivername), ntprinter.info_2->drivername); /* drivername */ + + init_unistr(&(printer->comment), ntprinter.info_2->comment); /* comment */ + init_unistr(&(printer->location), ntprinter.info_2->location); /* location */ + init_unistr(&(printer->sepfile), ntprinter.info_2->sepfile); /* separator file */ + init_unistr(&(printer->printprocessor), ntprinter.info_2->printprocessor);/* print processor */ + init_unistr(&(printer->datatype), ntprinter.info_2->datatype); /* datatype */ + init_unistr(&(printer->parameters), ntprinter.info_2->parameters); /* parameters (of print processor) */ + + printer->attributes = PRINTER_ATTRIBUTE_SHARED \ + | PRINTER_ATTRIBUTE_NETWORK \ + | PRINTER_ATTRIBUTE_RAW_ONLY ; /* attributes */ + + printer->priority = ntprinter.info_2->priority; /* priority */ + printer->defaultpriority = ntprinter.info_2->default_priority; /* default priority */ + printer->starttime = ntprinter.info_2->starttime; /* starttime */ + printer->untiltime = ntprinter.info_2->untiltime; /* untiltime */ + printer->status = status.status; /* status */ + printer->cjobs = count; /* jobs */ + printer->averageppm = ntprinter.info_2->averageppm; /* average pages per minute */ + + devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE)); + ZERO_STRUCTP(devmode); + construct_dev_mode(devmode, snum, servername); + printer->devmode=devmode; + + safe_free(queue); + free_a_printer(ntprinter, 2); + return (True); +} + +/******************************************************************** + * enum_printer_info_1 + * glue between spoolss_enumprinters and construct_printer_info_1 + ********************************************************************/ +static BOOL enum_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number) +{ + pstring servername; + + *printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1)); + DEBUG(4,("Allocated memory for ONE PRINTER_INFO_1 at [%p]\n", *printer)); + pstrcpy(servername, global_myname); + if (!construct_printer_info_1(*printer, snum, servername)) + { + free(*printer); + return (False); + } + else + { + return (True); + } +} + +/******************************************************************** + * enum_printer_info_2 + * glue between spoolss_enumprinters and construct_printer_info_2 + ********************************************************************/ +static BOOL enum_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number) +{ + pstring servername; + + *printer=(PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2)); + DEBUG(4,("Allocated memory for ONE PRINTER_INFO_2 at [%p]\n", *printer)); + pstrcpy(servername, global_myname); + if (!construct_printer_info_2(*printer, snum, servername)) + { + free(*printer); + return (False); + } + else + { + return (True); + } +} + +/******************************************************************** + * spoolss_enumprinters + * + * called from api_spoolss_enumprinters (see this to understand) + ********************************************************************/ +static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number) +{ + int snum; + int n_services=lp_numservices(); + *printers=NULL; + *number=0; + + for (snum=0;snumprinter.printers_1, returned ); + /*else + enum_one_printer_info_1(&r_u);*/ + break; + } + case 2: + if (flags == PRINTER_ENUM_NAME || + flags == PRINTER_ENUM_NETWORK ) + { + /*if (is_a_printerserver(servername))*/ + enum_all_printers_info_2(&ctr->printer.printers_2, returned ); + /*else + enum_one_printer_info_2(&r_u);*/ + break; + } + case 3: /* doesn't exist */ + return NT_STATUS_INVALID_INFO_CLASS; + case 4: /* can't, always on local machine */ + break; + case 5: + return NT_STATUS_INVALID_INFO_CLASS; + + } + DEBUG(4,("%d printers enumerated\n", *returned)); + (*offered) = buffer->size; + + return 0x0; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_getprinter( POLICY_HND *handle, + uint32 level, + PRINTER_INFO *ctr, + uint32 *offered, + uint32 *needed) +{ + int snum; + pstring servername; + + pstrcpy(servername, global_myname); + + if (!get_printer_snum(handle,&snum)) + { + return NT_STATUS_INVALID_HANDLE; + } + + DEBUG(0,("_spoolss_getprinter: offered and needed params ignored\n")); + + switch (level) + { + case 0: + { + PRINTER_INFO_0 *printer; + + printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0)); + construct_printer_info_0(printer, snum, servername); + ctr->printer.info0=printer; + + return 0x0; + } + case 1: + { + PRINTER_INFO_1 *printer; + + printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1)); + construct_printer_info_1(printer, snum, servername); + ctr->printer.info1=printer; + + return 0x0; + } + case 2: + { + PRINTER_INFO_2 *printer; + + printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)); + construct_printer_info_2(printer, snum, servername); + ctr->printer.info2=printer; + + return 0x0; + } + default: + { + break; + } + } + + return NT_STATUS_INVALID_INFO_CLASS; +} + +/******************************************************************** + * construct_printer_driver_info_1 + * fill a construct_printer_driver_info_1 struct + ********************************************************************/ +static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, + NT_PRINTER_DRIVER_INFO_LEVEL driver, + pstring servername, fstring architecture) +{ + init_unistr( &(info->name), driver.info_3->name); +} + +static void construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, + pstring servername, fstring architecture) +{ + NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + + get_a_printer(&printer, 2, lp_servicename(snum) ); + get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); + + fill_printer_driver_info_1(info, driver, servername, architecture); + + free_a_printer_driver(driver, 3); + free_a_printer(printer, 2); +} + +/******************************************************************** + * construct_printer_driver_info_2 + * fill a printer_info_2 struct + ********************************************************************/ +static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, + NT_PRINTER_DRIVER_INFO_LEVEL driver, + pstring servername, fstring architecture) +{ + pstring where; + pstring temp_driverpath; + pstring temp_datafile; + pstring temp_configfile; + fstring short_archi; + + get_short_archi(short_archi,architecture); + + snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\", servername, short_archi); + + info->version=driver.info_3->cversion; + + init_unistr( &(info->name), driver.info_3->name ); + init_unistr( &(info->architecture), architecture ); + + snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "%s%s", where, + driver.info_3->driverpath); + init_unistr( &(info->driverpath), temp_driverpath ); + + snprintf(temp_datafile, sizeof(temp_datafile)-1, "%s%s", where, + driver.info_3->datafile); + init_unistr( &(info->datafile), temp_datafile ); + + snprintf(temp_configfile, sizeof(temp_configfile)-1, "%s%s", where, + driver.info_3->configfile); + init_unistr( &(info->configfile), temp_configfile ); +} + +/******************************************************************** + * construct_printer_driver_info_2 + * fill a printer_info_2 struct + ********************************************************************/ +static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, + pstring servername, fstring architecture) +{ + NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + + get_a_printer(&printer, 2, lp_servicename(snum) ); + get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); + + fill_printer_driver_info_2(info, driver, servername, architecture); + + free_a_printer_driver(driver, 3); + free_a_printer(printer, 2); +} + +/******************************************************************** + * copy a strings array and convert to UNICODE + ********************************************************************/ +static void init_unistr_array(UNISTR ***uni_array, char **char_array, char *where) +{ + int i=0; + char *v; + pstring line; + + DEBUG(6,("init_unistr_array\n")); + + for (v=char_array[i]; *v!='\0'; v=char_array[i]) + { + DEBUGADD(6,("i:%d:", i)); + DEBUGADD(6,("%s:%d:", v, strlen(v))); + + *uni_array=(UNISTR **)Realloc(*uni_array, sizeof(UNISTR *)*(i+1)); + DEBUGADD(7,("realloc:[%p],", *uni_array)); + + (*uni_array)[i]=(UNISTR *)malloc( sizeof(UNISTR) ); + DEBUGADD(7,("alloc:[%p],", (*uni_array)[i])); + + snprintf(line, sizeof(line)-1, "%s%s", where, v); + init_unistr( (*uni_array)[i], line ); + DEBUGADD(7,("copy\n")); + + i++; + } + DEBUGADD(7,("last one\n")); + + *uni_array=(UNISTR **)Realloc(*uni_array, sizeof(UNISTR *)*(i+1)); + (*uni_array)[i]=0x0000; + DEBUGADD(6,("last one:done\n")); +} + +/******************************************************************** + * construct_printer_info_3 + * fill a printer_info_3 struct + ********************************************************************/ +static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, + NT_PRINTER_DRIVER_INFO_LEVEL driver, + pstring servername, fstring architecture) +{ + pstring where; + pstring temp_driverpath; + pstring temp_datafile; + pstring temp_configfile; + pstring temp_helpfile; + fstring short_archi; + + get_short_archi(short_archi, architecture); + + snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\", servername, short_archi); + + info->version=driver.info_3->cversion; + + init_unistr( &(info->name), driver.info_3->name ); + init_unistr( &(info->architecture), architecture ); + + snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "%s%s", where, driver.info_3->driverpath); + init_unistr( &(info->driverpath), temp_driverpath ); + + snprintf(temp_datafile, sizeof(temp_datafile)-1, "%s%s", where, driver.info_3->datafile); + init_unistr( &(info->datafile), temp_datafile ); + + snprintf(temp_configfile, sizeof(temp_configfile)-1, "%s%s", where, driver.info_3->configfile); + init_unistr( &(info->configfile), temp_configfile ); + + snprintf(temp_helpfile, sizeof(temp_helpfile)-1, "%s%s", where, driver.info_3->helpfile); + init_unistr( &(info->helpfile), temp_helpfile ); + + init_unistr( &(info->monitorname), driver.info_3->monitorname ); + init_unistr( &(info->defaultdatatype), driver.info_3->defaultdatatype ); + + info->dependentfiles=NULL; + init_unistr_array(&(info->dependentfiles), driver.info_3->dependentfiles, where); +} + +/******************************************************************** + * construct_printer_info_3 + * fill a printer_info_3 struct + ********************************************************************/ +static void construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, + pstring servername, fstring architecture) +{ + NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + + get_a_printer(&printer, 2, lp_servicename(snum) ); + get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); + + fill_printer_driver_info_3(info, driver, servername, architecture); + + free_a_printer_driver(driver, 3); + free_a_printer(printer, 2); +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_getprinterdriver2( const POLICY_HND *handle, + const UNISTR2 *uni_arch, + uint32 level, + DRIVER_INFO *ctr, + uint32 *offered, + uint32 *needed) +{ + pstring servername; + fstring architecture; + int snum; + DRIVER_INFO_1 *info1=NULL; + DRIVER_INFO_2 *info2=NULL; + DRIVER_INFO_3 *info3=NULL; + + pstrcpy(servername, global_myname); + + if (!get_printer_snum(handle,&snum)) + { + return NT_STATUS_INVALID_HANDLE; + } + + unistr2_to_ascii(architecture, uni_arch, sizeof(architecture) ); + + DEBUG(1,("spoolss_getprinterdriver2:[%d]\n", level)); + + switch (level) + { + case 1: + { + info1=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1)); + construct_printer_driver_info_1(info1, snum, servername, architecture); + ctr->driver.info1=info1; + + return 0x0; + } + case 2: + { + info2=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2)); + construct_printer_driver_info_2(info2, snum, servername, architecture); + ctr->driver.info2=info2; + + return 0x0; + } + case 3: + { + info3=(DRIVER_INFO_3 *)malloc(sizeof(DRIVER_INFO_3)); + construct_printer_driver_info_3(info3, snum, servername, architecture); + ctr->driver.info3=info3; + + return 0x0; + } + default: + { + break; + } + } + return NT_STATUS_INVALID_INFO_CLASS; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_startpageprinter(const POLICY_HND *handle) +{ + int pnum = find_printer_index_by_hnd(handle); + + if (OPEN_HANDLE(pnum)) + { + Printer[pnum].page_started=True; + return 0x0; + } + + DEBUG(3,("Error in startpageprinter printer handle (pnum=%x)\n",pnum)); + return NT_STATUS_INVALID_HANDLE; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_endpageprinter(const POLICY_HND *handle) +{ + int pnum = find_printer_index_by_hnd(handle); + + if (OPEN_HANDLE(pnum)) + { + Printer[pnum].page_started=False; + return 0x0; + } + + DEBUG(3,("Error in endpageprinter printer handle (pnum=%x)\n",pnum)); + return NT_STATUS_INVALID_HANDLE; +} + + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, + DOC_INFO *docinfo, uint32 *jobid) +{ + DOC_INFO_1 *info_1 = &docinfo->doc_info_1; + + pstring fname; + pstring tempname; + pstring datatype; + int fd = -1; + int snum; + int pnum; + + pnum = find_printer_index_by_hnd(handle); + + if (!VALID_HANDLE(pnum)) + { + return NT_STATUS_INVALID_HANDLE; + } + + /* + * a nice thing with NT is it doesn't listen to what you tell it. + * when asked to send _only_ RAW datas, it tries to send datas + * in EMF format. + * + * So I add checks like in NT Server ... + * + * lkclXXXX jean-francois, i love this kind of thing. oh, well, + * there's a bug in NT client-side code, so we'll fix it in the + * server-side code. *nnnnnggggh!* + */ + + if (info_1->p_datatype != 0) + { + unistr2_to_ascii(datatype, &(info_1->docname), sizeof(datatype)); + if (strcmp(datatype, "RAW") != 0) + { + (*jobid)=0; + return STATUS_1804; + } + } + + /* get the share number of the printer */ + if (!get_printer_snum(handle, &snum)) + { + return NT_STATUS_INVALID_HANDLE; + } + + /* Create a temporary file in the printer spool directory + * and open it + */ + + slprintf(tempname,sizeof(tempname)-1, "%s/smb_print.XXXXXX",lp_pathname(snum)); + pstrcpy(fname, (char *)mktemp(tempname)); + + fd=open(fname, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR ); + DEBUG(4,("Temp spool file created: [%s]\n", fname)); + + Printer[pnum].current_jobid=fd; + pstrcpy(Printer[pnum].document_name,fname); + + unistr2_to_ascii(Printer[pnum].job_name, + &info_1->docname, + sizeof(Printer[pnum].job_name)); + + Printer[pnum].document_fd=fd; + Printer[pnum].document_started=True; + (*jobid) = Printer[pnum].current_jobid; + + return 0x0; +} + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +uint32 _spoolss_enddocprinter(const POLICY_HND *handle) +{ + int pnum; + int snum; + pstring filename; + pstring filename1; + pstring job_name; + pstring syscmd; + char *tstr; + + *syscmd=0; + + pnum = find_printer_index_by_hnd(handle); + + if (!OPEN_HANDLE(pnum)) + { + DEBUG(3,("Error in enddocprinter handle (pnum=%x)\n",pnum)); + return NT_STATUS_INVALID_HANDLE; + } + Printer[pnum].document_started=False; + close(Printer[pnum].document_fd); + DEBUG(4,("Temp spool file closed, printing now ...\n")); + + pstrcpy(filename1, Printer[pnum].document_name); + pstrcpy(job_name, Printer[pnum].job_name); + + if (!get_printer_snum(handle,&snum)) + { + return NT_STATUS_INVALID_HANDLE; + } + + /* copy the command into the buffer for extensive meddling. */ + StrnCpy(syscmd, lp_printcommand(snum), sizeof(pstring) - 1); + + /* look for "%s" in the string. If there is no %s, we cannot print. */ + if (!strstr(syscmd, "%s") && !strstr(syscmd, "%f")) + { + DEBUG(2,("WARNING! No placeholder for the filename in the print command for service %s!\n", SERVICE(snum))); + } + + if (strstr(syscmd,"%s")) + { + pstrcpy(filename,filename1); + pstring_sub(syscmd, "%s", filename); + } + + pstring_sub(syscmd, "%f", filename1); + + /* Does the service have a printername? If not, make a fake and empty + * printer name. That way a %p is treated sanely if no printer + * name was specified to replace it. This eventuality is logged. + */ + + tstr = lp_printername(snum); + if (tstr == NULL || tstr[0] == '\0') + { + DEBUG(3,( "No printer name - using %s.\n", SERVICE(snum))); + tstr = SERVICE(snum); + } + + pstring_sub(syscmd, "%p", tstr); + + /* If the lpr command support the 'Job' option replace here */ + pstring_sub(syscmd, "%j", job_name); + + if ( *syscmd != '\0') + { + int ret = smbrun(syscmd, NULL, False); + DEBUG(3,("Running the command `%s' gave %d\n", syscmd, ret)); + if (ret < 0) + { + lpq_reset(snum); + return NT_STATUS_ACCESS_DENIED; + } + } + else + { + DEBUG(0,("Null print command?\n")); + lpq_reset(snum); + return NT_STATUS_ACCESS_DENIED; + } + + lpq_reset(snum); + + return 0x0; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_writeprinter( const POLICY_HND *handle, + uint32 buffer_size, + const uint8 *buffer, + uint32 *buffer_written) +{ + int pnum; + int fd; + + pnum = find_printer_index_by_hnd(handle); + + if (!OPEN_HANDLE(pnum)) + { + DEBUG(3,("Error in writeprinter handle (pnum=%x)\n",pnum)); + return NT_STATUS_INVALID_HANDLE; + } + + fd = Printer[pnum].document_fd; + (*buffer_written) = write(fd, buffer, buffer_size); + Printer[pnum].document_lastwritten = (*buffer_written); + + return 0x0; +} + +/******************************************************************** + * api_spoolss_getprinter + * called from the spoolss dispatcher + * + ********************************************************************/ +static uint32 control_printer(const POLICY_HND *handle, uint32 command) +{ + int pnum; + int snum; + pnum = find_printer_index_by_hnd(handle); + + if ( pnum == -1 || !get_printer_snum(handle, &snum) ) + { + return NT_STATUS_INVALID_HANDLE; + } + + switch (command) + { + case PRINTER_CONTROL_PAUSE: + /* pause the printer here */ + status_printqueue(NULL, snum, LPSTAT_STOPPED); + return 0x0; + + case PRINTER_CONTROL_RESUME: + case PRINTER_CONTROL_UNPAUSE: + /* UN-pause the printer here */ + status_printqueue(NULL, snum, LPSTAT_OK); + return 0x0; + case PRINTER_CONTROL_PURGE: + /* Envoi des dragées FUCA dans l'imprimante */ + break; + } + + return NT_STATUS_INVALID_INFO_CLASS; +} + +/******************************************************************** + * called by spoolss_api_setprinter + * when updating a printer description + ********************************************************************/ +static uint32 update_printer(const POLICY_HND *handle, uint32 level, + const SPOOL_PRINTER_INFO_LEVEL *info, + const DEVICEMODE *devmode) +{ + int pnum; + int snum; + NT_PRINTER_INFO_LEVEL printer; + NT_DEVICEMODE *nt_devmode; + uint32 status = 0x0; + + nt_devmode=NULL; + + DEBUG(8,("update_printer\n")); + + if (level!=2) + { + DEBUG(0,("Send a mail to samba-bugs@samba.org\n")); + DEBUGADD(0,("with the following message: update_printer: level!=2\n")); + return NT_STATUS_INVALID_INFO_CLASS; + } + + pnum = find_printer_index_by_hnd(handle); + if ( pnum == -1 || !get_printer_snum(handle, &snum) ) + { + return NT_STATUS_INVALID_HANDLE; + } + get_a_printer(&printer, level, lp_servicename(snum)); + + DEBUGADD(8,("Converting info_2 struct\n")); + convert_printer_info(info, &printer, level); + + if ((info->info_2)->devmode_ptr != 0) + { + /* we have a valid devmode + convert it and link it*/ + + /* the nt_devmode memory is already alloced + * while doing the get_a_printer call + * but the devmode private part is not + * it's done by convert_devicemode + */ + DEBUGADD(8,("Converting the devicemode struct\n")); + nt_devmode=printer.info_2->devmode; + + init_devicemode(nt_devmode); + + convert_devicemode(*devmode, nt_devmode); + } + else + { + if (printer.info_2->devmode != NULL) + { + free(printer.info_2->devmode); + } + printer.info_2->devmode=NULL; + } + + if (status == 0x0) + { + status = add_a_printer(printer, level); + } + if (status == 0x0) + { + status = free_a_printer(printer, level); + } + + return status; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_setprinter( const POLICY_HND *handle, + uint32 level, + const SPOOL_PRINTER_INFO_LEVEL *info, + const DEVICEMODE *devmode, + uint32 sec_buf_size, + const char *sec_buf, + uint32 command) +{ + int pnum = find_printer_index_by_hnd(handle); + + if (!OPEN_HANDLE(pnum)) + { + return NT_STATUS_INVALID_HANDLE; + } + /* check the level */ + switch (level) + { + case 0: return control_printer(handle, command); + case 2: return update_printer(handle, level, info, devmode); + } + + return NT_STATUS_INVALID_INFO_CLASS; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_fcpn( const POLICY_HND *handle) +{ + return 0x0; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_addjob( const POLICY_HND *handle, uint32 level, + const BUFFER *buffer, + uint32 buf_size) +{ + return 0x0; +} + +/**************************************************************************** +****************************************************************************/ +static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, + int position, int snum) +{ + pstring temp_name; + + struct tm *t; + time_t unixdate = time(NULL); + + t=gmtime(&unixdate); + snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); + + job_info->jobid=queue->job; + init_unistr(&(job_info->printername), lp_servicename(snum)); + init_unistr(&(job_info->machinename), temp_name); + init_unistr(&(job_info->username), queue->user); + init_unistr(&(job_info->document), queue->file); + init_unistr(&(job_info->datatype), "RAW"); + init_unistr(&(job_info->text_status), ""); + job_info->status=queue->status; + job_info->priority=queue->priority; + job_info->position=position; + job_info->totalpages=0; + job_info->pagesprinted=0; + + make_systemtime(&(job_info->submitted), t); +} + +/**************************************************************************** +****************************************************************************/ +static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, + int position, int snum) +{ + pstring temp_name; + DEVICEMODE *devmode; + NT_PRINTER_INFO_LEVEL ntprinter; + pstring chaine; + + struct tm *t; + time_t unixdate = time(NULL); + + if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) + { + return (False); + } + + t=gmtime(&unixdate); + snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); + + job_info->jobid=queue->job; + + snprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", global_myname, ntprinter.info_2->printername); + init_unistr(&(job_info->printername), chaine); + + init_unistr(&(job_info->machinename), temp_name); + init_unistr(&(job_info->username), queue->user); + init_unistr(&(job_info->document), queue->file); + init_unistr(&(job_info->notifyname), queue->user); + init_unistr(&(job_info->datatype), "RAW"); + init_unistr(&(job_info->printprocessor), "winprint"); + init_unistr(&(job_info->parameters), ""); + init_unistr(&(job_info->text_status), ""); + +/* and here the security descriptor */ + + job_info->status=queue->status; + job_info->priority=queue->priority; + job_info->position=position; + job_info->starttime=0; + job_info->untiltime=0; + job_info->totalpages=0; + job_info->size=queue->size; + make_systemtime(&(job_info->submitted), t); + job_info->timeelapsed=0; + job_info->pagesprinted=0; + + devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE)); + ZERO_STRUCTP(devmode); + construct_dev_mode(devmode, snum, global_myname); + job_info->devmode=devmode; + + free_a_printer(ntprinter, 2); + return (True); +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_enumjobs( const POLICY_HND *handle, + uint32 reqfirstjob, + uint32 reqnumofjobs, + uint32 level, + JOB_INFO_CTR *ctr, + uint32 *buf_size, + uint32 *numofjobs) +{ + int snum; + int count; + int i; + print_queue_struct *queue=NULL; + print_status_struct prt_status; + + DEBUG(4,("spoolss_enumjobs\n")); + + ZERO_STRUCT(prt_status); + + if (!get_printer_snum(handle, &snum)) + { + return NT_STATUS_INVALID_HANDLE; + } + + count = get_printqueue(snum, NULL, &queue, &prt_status); + (*numofjobs) = 0; + + DEBUG(4,("count:[%d], status:[%d], [%s]\n", + count, prt_status.status, prt_status.message)); + + switch (level) + { + case 1: + { + for (i=0; ijob.job_info_1, + job_info_1); + + fill_job_info_1(ctr->job.job_info_1[i], + &(queue[i]), i, snum); + } + safe_free(queue); + return 0x0; + } + case 2: + { + for (i=0; ijob.job_info_2, + job_info_2); + + fill_job_info_2(ctr->job.job_info_2[i], + &(queue[i]), i, snum); + } + safe_free(queue); + return 0x0; + } + } + + safe_free(queue); + + return NT_STATUS_INVALID_INFO_CLASS; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_schedulejob( const POLICY_HND *handle, uint32 jobid) +{ + return 0x0; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_setjob( const POLICY_HND *handle, + uint32 jobid, + uint32 level, + JOB_INFO *ctr, + uint32 command) + +{ + int snum; + print_queue_struct *queue=NULL; + print_status_struct prt_status; + int i=0; + BOOL found=False; + int count; + + bzero(&prt_status,sizeof(prt_status)); + + if (!get_printer_snum(handle, &snum)) + { + return NT_STATUS_INVALID_HANDLE; + } + + count=get_printqueue(snum, NULL, &queue, &prt_status); + + while ( (idriver.info1=driver_info_1; + break; + } + case 2: + { + DRIVER_INFO_2 *driver_info_2=NULL; + driver_info_2=(DRIVER_INFO_2 *)malloc(count*sizeof(DRIVER_INFO_2)); + + for (i=0; idriver.info2=driver_info_2; + break; + } + case 3: + { + DRIVER_INFO_3 *driver_info_3=NULL; + driver_info_3=(DRIVER_INFO_3 *)malloc(count*sizeof(DRIVER_INFO_3)); + + for (i=0; idriver.info3=driver_info_3; + break; + } + default: + { + return NT_STATUS_INVALID_INFO_CLASS; + } + } + return 0x0; + +} + +/**************************************************************************** +****************************************************************************/ +static void fill_form_1(FORM_1 *form, nt_forms_struct *list, int position) +{ + form->flag=list->flag; + init_unistr(&(form->name), list->name); + form->width=list->width; + form->length=list->length; + form->left=list->left; + form->top=list->top; + form->right=list->right; + form->bottom=list->bottom; +} + +/**************************************************************************** +****************************************************************************/ +static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) +{ + prs_struct *ps; + uint32 extra_space; + + ps=&(buffer->prs); + + /* damn, I'm doing the reverse operation of prs_grow() :) */ + extra_space = buffer_size - prs_data_size(ps); + + if (!prs_grow(ps, extra_space)) + return False; + + buffer->string_at_end=buffer_size; + + return True; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed, uint32 *numofforms) +{ + nt_forms_struct *list=NULL; + FORM_1 *forms_1; + int buffer_size=0; + int i; + + + DEBUG(4,("_new_spoolss_enumforms\n")); + DEBUGADD(5,("Offered buffer size [%d]\n", offered)); + DEBUGADD(5,("Info level [%d]\n", level)); + + *numofforms = get_ntforms(&list); + DEBUGADD(5,("Number of forms [%d]\n", *numofforms)); + + switch (level) { + case 1: + forms_1=(FORM_1 *)malloc(*numofforms * sizeof(FORM_1)); + + /* construct the list of form structures */ + for (i=0; i<*numofforms; i++) + { + DEBUGADD(6,("Filling form number [%d]\n",i)); + fill_form_1(&(forms_1[i]), &(list[i]), i); + } + + /* check the required size. */ + for (i=0; i<*numofforms; i++) + { + DEBUGADD(6,("adding form [%d]'s size\n",i)); + buffer_size += spoolss_size_form_1(&(forms_1[i])); + } + + *needed=buffer_size; + + if (!alloc_buffer_size(buffer, buffer_size)) + return ERROR_INSUFFICIENT_BUFFER; + + /* fill the buffer with the form structures */ + for (i=0; i<*numofforms; i++) + { + DEBUGADD(6,("adding form [%d] to buffer\n",i)); + new_smb_io_form_1("", buffer, &(forms_1[i]), 0); + } + + safe_free(list); + + if (*needed > offered) + return ERROR_INSUFFICIENT_BUFFER; + else + return NT_STATUS_NO_PROBLEMO; + + default: + safe_free(list); + return NT_STATUS_INVALID_INFO_CLASS; + } + +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_enumforms( const POLICY_HND *handle, + uint32 level, + FORM_1 **forms_1, + uint32 *offered, + uint32 *numofforms) +{ + int count; + int i; + nt_forms_struct *list=NULL; + (*forms_1)=NULL; + + DEBUG(4,("spoolss_enumforms\n")); + + count = get_ntforms(&list); + (*numofforms) = count; + + DEBUGADD(5,("Offered buffer size [%d]\n", *offered)); + DEBUGADD(5,("Number of forms [%d]\n", *numofforms)); + DEBUGADD(5,("Info level [%d]\n", level)); + + switch (level) + { + case 1: + { + (*forms_1)=(FORM_1 *)malloc(count*sizeof(FORM_1)); + for (i=0; iport_name), name); + init_unistr(&(port->monitor_name), "Moniteur Local"); + init_unistr(&(port->description), "Local Port"); +#define PORT_TYPE_WRITE 1 + port->port_type=PORT_TYPE_WRITE; + port->reserved=0x0; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_enumports( const UNISTR2 *name, + uint32 level, + PORT_INFO_CTR *ctr, + uint32 *offered, + uint32 *numofports) +{ + int n_services=lp_numservices(); + int snum; + + DEBUG(4,("spoolss_enumports\n")); + + (*numofports) = 0; + + switch (level) + { + case 2: + { + PORT_INFO_2 *ports_2=NULL; + ports_2=(PORT_INFO_2 *)malloc(n_services*sizeof(PORT_INFO_2)); + for (snum=0; snumport.info_2=ports_2; + return 0x0; + } + } + + return NT_STATUS_INVALID_INFO_CLASS; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, + uint32 level, + const SPOOL_PRINTER_INFO_LEVEL *info, + uint32 unk0, + uint32 unk1, + uint32 unk2, + uint32 unk3, + uint32 user_level, + const SPOOL_USER_LEVEL *user, + POLICY_HND *handle) +{ + NT_PRINTER_INFO_LEVEL printer; + fstring ascii_name; + fstring server_name; + fstring share_name; + UNISTR2 *portname; + SPOOL_PRINTER_INFO_LEVEL_2 *info2; + uint32 status = 0x0; + + if (!open_printer_hnd(handle)) + { + return NT_STATUS_ACCESS_DENIED; + } + + /* NULLify info_2 here */ + /* don't put it in convert_printer_info as it's used also with non-NULL values */ + printer.info_2=NULL; + + /* convert from UNICODE to ASCII */ + convert_printer_info(info, &printer, level); + + /* write the ASCII on disk */ + status = add_a_printer(printer, level); + if (status != 0x0) + { + close_printer_handle(handle); + return status; + } + + info2=info->info_2; + portname=&(info2->portname); + + StrnCpy(server_name, global_myname, strlen(global_myname) ); + unistr2_to_ascii(share_name, portname, sizeof(share_name)-1); + + slprintf(ascii_name, sizeof(ascii_name)-1, "\\\\%s\\%s", + server_name, share_name); + + if (!set_printer_hnd_printertype(handle, ascii_name) || + !set_printer_hnd_printername(handle, ascii_name)) + { + close_printer_handle(handle); + return NT_STATUS_ACCESS_DENIED; + } + + return 0x0; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name, + uint32 level, + const SPOOL_PRINTER_DRIVER_INFO_LEVEL *info) +{ + NT_PRINTER_DRIVER_INFO_LEVEL driver; + convert_printer_driver_info(info, &driver, level); + return add_a_printer_driver(driver, level); +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_getprinterdriverdirectory( const UNISTR2 *name, + const UNISTR2 *uni_environment, + uint32 level, + DRIVER_DIRECTORY_CTR *ctr, + uint32 *offered) +{ + pstring chaine; + pstring long_archi; + pstring archi; + + unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); + get_short_archi(archi, long_archi); + + slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\print$\\%s", + global_myname, archi); + + DEBUG(4,("printer driver directory: [%s]\n", chaine)); + + init_unistr(&(ctr->driver.info_1.name), chaine); + + return 0x0; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, + uint32 idx, + uint32 *valuesize, + UNISTR *uni_value, + uint32 *realvaluesize, + uint32 *type, + uint32 *datasize, + uint8 **data, + uint32 *realdatasize) +{ + NT_PRINTER_INFO_LEVEL printer; + + fstring value; + + uint32 param_index; + uint32 biggest_valuesize; + uint32 biggest_datasize; + uint32 data_len; + uint32 status = 0x0; + + int pnum = find_printer_index_by_hnd(handle); + int snum; + + ZERO_STRUCT(printer); + (*data)=NULL; + + DEBUG(5,("spoolss_enumprinterdata\n")); + + if (!OPEN_HANDLE(pnum)) + { + return NT_STATUS_INVALID_HANDLE; + } + if (!get_printer_snum(handle, &snum)) + { + return NT_STATUS_INVALID_HANDLE; + } + status = get_a_printer(&printer, 2, lp_servicename(snum)); + + if (status != 0x0) + { + return status; + } + + /* The NT machine wants to know the biggest size of value and data */ + if ( ((*valuesize)==0) && ((*datasize)==0) ) + { + DEBUGADD(6,("Activating NT mega-hack to find sizes\n")); + + (*valuesize)=0; + (*realvaluesize)=0; + (*type)=0; + (*datasize)=0; + (*realdatasize)=0; + status=0; + + param_index=0; + biggest_valuesize=0; + biggest_datasize=0; + + while (get_specific_param_by_index(printer, 2, param_index, value, data, type, &data_len)) + { + if (strlen(value) > biggest_valuesize) biggest_valuesize=strlen(value); + if (data_len > biggest_datasize) biggest_datasize=data_len; + + param_index++; + } + + /* I wrote it, I didn't designed the protocol */ + if (biggest_valuesize!=0) + { + SIVAL(&(value),0, 2*(biggest_valuesize+1) ); + } + (*data)=(uint8 *)malloc(4*sizeof(uint8)); + SIVAL((*data), 0, biggest_datasize ); + } + else + { + /* + * the value len is wrong in NT sp3 + * that's the number of bytes not the number of unicode chars + */ + + if (get_specific_param_by_index(printer, 2, idx, value, data, type, &data_len)) + { + init_unistr(uni_value, value); + + /* the length are in bytes including leading NULL */ + (*realvaluesize)=2*(strlen(value)+1); + (*realdatasize)=data_len; + + status=0; + } + else + { + (*valuesize)=0; + (*realvaluesize)=0; + (*datasize)=0; + (*realdatasize)=0; + (*type)=0; + status=0x0103; /* ERROR_NO_MORE_ITEMS */ + } + } + + free_a_printer(printer, 2); + + return status; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_setprinterdata( const POLICY_HND *handle, + const UNISTR2 *value, + uint32 type, + uint32 max_len, + const uint8 *data, + uint32 real_len, + uint32 numeric_data) +{ + NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_PARAM *param = NULL; + + int pnum=0; + int snum=0; + uint32 status = 0x0; + + DEBUG(5,("spoolss_setprinterdata\n")); + + pnum = find_printer_index_by_hnd(handle); + + if (!OPEN_HANDLE(pnum)) + { + return NT_STATUS_INVALID_HANDLE; + } + if (!get_printer_snum(handle, &snum)) + { + return NT_STATUS_INVALID_HANDLE; + } + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (status != 0x0) + { + return status; + } + + convert_specific_param(¶m, value , type, data, real_len); + unlink_specific_param_if_exist(printer.info_2, param); + + if (!add_a_specific_param(printer.info_2, param)) + { + status = NT_STATUS_INVALID_PARAMETER; + } + else + { + status = add_a_printer(printer, 2); + } + free_a_printer(printer, 2); + + return status; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_addform( const POLICY_HND *handle, + uint32 level, + const FORM *form) +{ + int pnum=0; + int count=0; + nt_forms_struct *list=NULL; + + DEBUG(5,("spoolss_addform\n")); + + pnum = find_printer_index_by_hnd(handle); + + if (!OPEN_HANDLE(pnum)) + { + return NT_STATUS_INVALID_HANDLE; + } + + count=get_ntforms(&list); + add_a_form(&list, form, &count); + write_ntforms(&list, count); + + safe_free(list); + + return 0x0; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_setform( const POLICY_HND *handle, + const UNISTR2 *uni_name, + uint32 level, + const FORM *form) +{ + int pnum=0; + int count=0; + nt_forms_struct *list=NULL; + + DEBUG(5,("spoolss_setform\n")); + + pnum = find_printer_index_by_hnd(handle); + if (!OPEN_HANDLE(pnum)) + { + return NT_STATUS_INVALID_HANDLE; + } + count=get_ntforms(&list); + update_a_form(&list, form, count); + write_ntforms(&list, count); + + safe_free(list); + + return 0x0; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_enumprintprocessors(const UNISTR2 *name, + const UNISTR2 *environment, + uint32 level, + PRINTPROCESSOR_1 **info_1, + uint32 *offered, + uint32 *numofprintprocessors) +{ + DEBUG(5,("spoolss_enumprintprocessors\n")); + + /* + * Enumerate the print processors ... + * + * Just reply with "winprint", to keep NT happy + * and I can use my nice printer checker. + */ + + (*numofprintprocessors) = 0x1; + (*info_1) = (PRINTPROCESSOR_1 *)malloc(sizeof(PRINTPROCESSOR_1)); + + if ((*info_1) == NULL) + { + return NT_STATUS_NO_MEMORY; + } + + init_unistr(&((*info_1)->name), "winprint"); + + return 0x0; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_enumprintmonitors( const UNISTR2 *name, + uint32 level, + PRINTMONITOR_1 **info_1, + uint32 *offered, + uint32 *numofprintmonitors) +{ + DEBUG(5,("spoolss_enumprintmonitors\n")); + + /* + * Enumerate the print monitors ... + * + * Just reply with "Local Port", to keep NT happy + * and I can use my nice printer checker. + */ + + (*numofprintmonitors) = 0x1; + (*info_1) = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1)); + if ((*info_1) == NULL) + { + return NT_STATUS_NO_MEMORY; + } + + init_unistr(&((*info_1)->name), "Local Port"); + + return 0x0; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_getjob( const POLICY_HND *handle, + uint32 jobid, + uint32 level, + PJOB_INFO *ctr, + uint32 *offered) +{ + int snum; + int count; + int i; + print_queue_struct *queue=NULL; + print_status_struct prt_status; + + DEBUG(4,("spoolss_getjob\n")); + + bzero(&prt_status,sizeof(prt_status)); + + if (!get_printer_snum(handle, &snum)) + { + return NT_STATUS_INVALID_HANDLE; + } + count=get_printqueue(snum, NULL, &queue, &prt_status); + + DEBUGADD(4,("count:[%d], prt_status:[%d], [%s]\n", + count, prt_status.status, prt_status.message)); + + switch (level) + { + case 1: + { + JOB_INFO_1 *job_info_1=NULL; + job_info_1=(JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1)); + + if (job_info_1 == NULL) + { + safe_free(queue); + return NT_STATUS_NO_MEMORY; + } + + for (i=0; ijob.job_info_1=job_info_1; + break; + } + case 2: + { + JOB_INFO_2 *job_info_2=NULL; + job_info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2)); + + if (job_info_2 == NULL) + { + safe_free(queue); + return NT_STATUS_NO_MEMORY; + } + + for (i=0; ijob.job_info_2=job_info_2; + break; + } + default: + { + safe_free(queue); + return NT_STATUS_INVALID_INFO_CLASS; + } + } + + safe_free(queue); + return 0x0; +} -- cgit From 195e3d44daccc3b6457486018ba0322ac9d44566 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 7 Feb 2000 16:25:15 +0000 Subject: spoolss definitions. also added some prs_struct functions, 'cause I'm handling buffers as prs_struct. J.F. (This used to be commit 81e375bbbe0fb022a44a2aaaa3729a9518b7a854) --- source3/rpc_server/srv_pipe_srv.c | 47 +++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_srv.c b/source3/rpc_server/srv_pipe_srv.c index 236558ba70..2cebc8148b 100644 --- a/source3/rpc_server/srv_pipe_srv.c +++ b/source3/rpc_server/srv_pipe_srv.c @@ -465,6 +465,7 @@ static struct api_cmd api_fd_commands[] = #if DISABLED_IN_2_0 { "winreg", "winreg", api_reg_rpc }, #endif + { "spoolss", "spoolss", api_spoolss_rpc }, { NULL, NULL, NULL } }; @@ -585,7 +586,7 @@ static BOOL setup_bind_nak(pipes_struct *p, prs_struct *pd) Respond to a pipe bind request. *******************************************************************/ -static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) +static BOOL api_pipe_bind_and_alt_req(pipes_struct *p, prs_struct *pd, enum RPC_PKT_TYPE pkt_type) { RPC_HDR_BA hdr_ba; RPC_HDR_RB hdr_rb; @@ -684,9 +685,21 @@ static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) p->ntlmssp_auth_requested = True; } - /* name has to be \PIPE\xxxxx */ - fstrcpy(ack_pipe_name, "\\PIPE\\"); - fstrcat(ack_pipe_name, p->pipe_srv_name); + switch (pkt_type) { + case RPC_BINDACK: + /* name has to be \PIPE\xxxxx */ + fstrcpy(ack_pipe_name, "\\PIPE\\"); + fstrcat(ack_pipe_name, p->pipe_srv_name); + case RPC_ALTCONTRESP: + /* secondary address CAN be NULL + * as the specs says it's ignored. + * It MUST NULL to have the spoolss working. + */ + fstrcpy(ack_pipe_name, ""); + break; + default: + return False; + } DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); @@ -831,6 +844,29 @@ static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) return False; } +/******************************************************************* + Respond to a pipe bind request. +*******************************************************************/ + +static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) +{ + return api_pipe_bind_and_alt_req(p, pd, RPC_BINDACK); +} + +/******************************************************************* + Respond to a pipe alter request. + + The RPC Alter-Context call is used only by the spoolss pipe + simply because there is a bug (?) in the MS unmarshalling code + or in the marshalling code. If it's in the later, then Samba + have the same bug. +*******************************************************************/ + +static BOOL api_pipe_altercontext_req(pipes_struct *p, prs_struct *pd) +{ + return api_pipe_bind_and_alt_req(p, pd, RPC_ALTCONTRESP); +} + /**************************************************************************** Deal with sign & seal processing on an RPC request. ****************************************************************************/ @@ -1011,6 +1047,9 @@ BOOL rpc_command(pipes_struct *p, char *input_data, int data_len) case RPC_BIND: reply = api_pipe_bind_req(p, &rpc_in); break; + case RPC_ALTCONT: + reply = api_pipe_altercontext_req(p, &rpc_in); + break; case RPC_REQUEST: if (p->ntlmssp_auth_requested && !p->ntlmssp_auth_validated) { /* authentication _was_ requested -- cgit From 07fd3b392d8b3dc5bc8c72584e31a7369b92ff13 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 7 Feb 2000 18:06:54 +0000 Subject: Hum, I should remove my gloves when I'm in front of an xterm :) fixed a stupid bug in unistr2_to_ascii that I introduced fixed getprinterdata() (This used to be commit 2f544a807714024c0fe2ddc26e11c9ddcb47e81f) --- source3/rpc_server/srv_spoolss_nt.c | 45 ++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index db48fa42ff..d25281cea5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -537,15 +537,17 @@ uint32 _spoolss_closeprinter(POLICY_HND *handle) /******************************************************************** ********************************************************************/ -static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **data, uint32 *needed) +static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size) { int i; + + DEBUG(8,("getprinterdata_printer_server:%s\n", value)); if (!strcmp(value, "BeepEnabled")) { *type = 0x4; *data = (uint8 *)malloc( 4*sizeof(uint8) ); - SIVAL(data, 0, 0x01); + SIVAL(*data, 0, 0x01); *needed = 0x4; return True; } @@ -554,7 +556,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d { *type = 0x4; *data = (uint8 *)malloc( 4*sizeof(uint8) ); - SIVAL(data, 0, 0x1B); + SIVAL(*data, 0, 0x1B); *needed = 0x4; return True; } @@ -563,7 +565,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d { *type = 0x4; *data = (uint8 *)malloc( 4*sizeof(uint8) ); - SIVAL(data, 0, 0x01); + SIVAL(*data, 0, 0x01); *needed = 0x4; return True; } @@ -572,23 +574,23 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d { *type = 0x4; *data = (uint8 *)malloc( 4*sizeof(uint8) ); - SIVAL(data, 0, 0x02); + SIVAL(*data, 0, 0x02); *needed = 0x4; return True; } if (!strcmp(value, "DefaultSpoolDirectory")) { - pstring directory="You are using a Samba server"; + pstring string="You are using a Samba server"; *type = 0x1; - *needed = 2*(strlen(directory)+1); - *data = (uint8 *)malloc(*needed *sizeof(uint8)); + *needed = 2*(strlen(string)+1); + *data = (uint8 *)malloc( ((*needed > in_size) ? *needed:in_size) *sizeof(uint8)); ZERO_STRUCTP(*data); /* it's done by hand ready to go on the wire */ - for (i=0; i in_size) ? *needed:in_size) *sizeof(uint8)); ZERO_STRUCTP(*data); - for (i=0; iin_size)?len:in_size *sizeof(uint8) ); bzero(*data, sizeof(uint8)*len); - memcpy(*data, idata, len); + memcpy(*data, idata, (len>in_size)?len:in_size); *needed = len; if (idata) free(idata); @@ -659,7 +661,7 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, uint32 *needed) { fstring value; - BOOL found; + BOOL found=False; int pnum = find_printer_index_by_hnd(handle); /* @@ -675,6 +677,7 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, *needed=in_size; *type=4; + DEBUG(4,("_spoolss_getprinterdata\n")); if (!OPEN_HANDLE(pnum)) { *data=(uint8 *)malloc(4*sizeof(uint8)); @@ -684,9 +687,9 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, unistr2_to_ascii(value, valuename, sizeof(value)-1); if (handle_is_printserver(handle)) - found=getprinterdata_printer_server(value, type, data, needed); + found=getprinterdata_printer_server(value, type, data, needed, *out_size); else - found=getprinterdata_printer(handle, value, type, data, needed); + found=getprinterdata_printer(handle, value, type, data, needed, *out_size); if (found==False) { /* reply this param doesn't exist */ -- cgit From 8688933c7feb87179c178a30e4fc42970fe1da8f Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 15 Feb 2000 18:07:45 +0000 Subject: fix the reply of rpc_alter_context OpenPrinterEx is now decoding correctly the query most of the EnumXXX use the new_buffer struct. check the (un)marshalling return code. conclusion: still a long way to go. all the client code has to be rewritten, and I still wonder how to implement correctly the notify stuff. (This used to be commit 3d6d3863751787b08d40268c83221add1487a5c9) --- source3/rpc_server/srv_pipe_srv.c | 2 +- source3/rpc_server/srv_spoolss.c | 526 +++++++++++---- source3/rpc_server/srv_spoolss_nt.c | 1229 +++++++++++++++++++++++------------ 3 files changed, 1218 insertions(+), 539 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_srv.c b/source3/rpc_server/srv_pipe_srv.c index 2cebc8148b..6e8b306760 100644 --- a/source3/rpc_server/srv_pipe_srv.c +++ b/source3/rpc_server/srv_pipe_srv.c @@ -796,7 +796,7 @@ static BOOL api_pipe_bind_and_alt_req(pipes_struct *p, prs_struct *pd, enum RPC_ * Create the header, now we know the length. */ - init_rpc_hdr(&p->hdr, RPC_BINDACK, RPC_FLG_FIRST | RPC_FLG_LAST, + init_rpc_hdr(&p->hdr, pkt_type, RPC_FLG_FIRST | RPC_FLG_LAST, p->hdr.call_id, RPC_HEADER_LEN + prs_offset(&out_hdr_ba) + prs_offset(&out_auth), auth_len); diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 60333e1f3b..50b6dd3846 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -107,10 +107,18 @@ static BOOL api_spoolss_closeprinter(uint16 vuid, prs_struct *data, prs_struct * ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_closeprinter("", &q_u, data, 0); + if (!spoolss_io_q_closeprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_closeprinter: unable to unmarshall SPOOL_Q_CLOSEPRINTER.\n")); + return False; + } + r_u.status = _spoolss_closeprinter(&q_u.handle); memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle)); - spoolss_io_r_closeprinter("",&r_u,rdata,0); + + if (!spoolss_io_r_closeprinter("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_closeprinter: unable to marshall SPOOL_R_CLOSEPRINTER.\n")); + return False; + } } /******************************************************************** @@ -125,12 +133,19 @@ static BOOL api_spoolss_rffpcnex(uint16 vuid, prs_struct *data, prs_struct *rdat ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_rffpcnex("", &q_u, data, 0); + if (!spoolss_io_q_rffpcnex("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_rffpcnex: unable to unmarshall SPOOL_Q_RFFPCNEX.\n")); + return False; + } r_u.status = _spoolss_rffpcnex(&q_u.handle, q_u.flags, q_u.options, &q_u.localmachine, q_u.printerlocal, &q_u.option); - spoolss_io_r_rffpcnex("",&r_u,rdata,0); + + if (!spoolss_io_r_rffpcnex("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_rffpcnex: unable to marshall SPOOL_R_RFFPCNEX.\n")); + return False; + } } @@ -148,11 +163,18 @@ static BOOL api_spoolss_rfnpcnex(uint16 vuid, prs_struct *data, prs_struct *rdat ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_rfnpcnex("", &q_u, data, 0); + if (!spoolss_io_q_rfnpcnex("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_rfnpcnex: unable to unmarshall SPOOL_Q_RFNPCNEX.\n")); + return False; + } r_u.status = _spoolss_rfnpcnex(&q_u.handle, q_u.change, &q_u.option, &r_u.count, &r_u.info); - spoolss_io_r_rfnpcnex("", &r_u, rdata, 0); + + if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n")); + return False; + } } @@ -169,32 +191,33 @@ static BOOL api_spoolss_enumprinters(uint16 vuid, prs_struct *data, prs_struct * ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_enumprinters("", &q_u, data, 0); + DEBUG(5,("api_spoolss_enumprinters\n")); - /* lkclXXX DAMN DAMN DAMN! MICROSOFT @#$%S IT UP, AGAIN, AND WE - HAVE TO DEAL WITH IT! AGH! - */ - r_u.level = q_u.level; - r_u.status = _spoolss_enumprinters( - q_u.flags, - &q_u.servername, - q_u.level, - &q_u.buffer, - q_u.buf_size, - &r_u.offered, - &r_u.needed, - &r_u.ctr, - &r_u.returned); + new_spoolss_allocate_buffer(&q_u.buffer); + + if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n")); + return False; + } + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); + + r_u.status = _spoolss_enumprinters( q_u.flags, &q_u.servername, q_u.level, + r_u.buffer, q_u.offered, + &r_u.needed, &r_u.returned); - memcpy(r_u.servername.buffer,q_u.servername.buffer, - 2*q_u.servername.uni_str_len); - r_u.servername.buffer[q_u.servername.uni_str_len] = 0; + if (!new_spoolss_io_r_enumprinters("", &r_u, rdata, 0)) { + DEBUG(0,("new_spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n")); + new_spoolss_free_buffer(q_u.buffer); + return False; + } - spoolss_io_free_buffer(&(q_u.buffer)); - spoolss_io_r_enumprinters("",&r_u,rdata,0); + new_spoolss_free_buffer(q_u.buffer); + + return True; } - /******************************************************************** * api_spoolss_getprinter * called from the spoolss dispatcher @@ -208,7 +231,10 @@ static BOOL api_spoolss_getprinter(uint16 vuid, prs_struct *data, prs_struct *rd ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_getprinter("", &q_u, data, 0); + if(!spoolss_io_q_getprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n")); + return False; + } r_u.status = _spoolss_getprinter(&q_u.handle, q_u.level, &r_u.ctr, &q_u.offered, &r_u.needed); @@ -218,7 +244,12 @@ static BOOL api_spoolss_getprinter(uint16 vuid, prs_struct *data, prs_struct *rd r_u.level = q_u.level; safe_free(q_u.buffer); - spoolss_io_r_getprinter("",&r_u,rdata,0); + if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n")); + return False; + } + + return True; } @@ -235,7 +266,10 @@ static BOOL api_spoolss_getprinterdriver2(uint16 vuid, prs_struct *data, prs_str ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_getprinterdriver2("", &q_u, data, 0); + if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n")); + return False; + } r_u.status = _spoolss_getprinterdriver2(&q_u.handle, &q_u.architecture, q_u.level, @@ -246,7 +280,12 @@ static BOOL api_spoolss_getprinterdriver2(uint16 vuid, prs_struct *data, prs_str r_u.level = q_u.level; spoolss_io_free_buffer(&(q_u.buffer)); - spoolss_io_r_getprinterdriver2("",&r_u,rdata,0); + if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n")); + return False; + } + + return True; } /******************************************************************** @@ -262,9 +301,19 @@ static BOOL api_spoolss_startpageprinter(uint16 vuid, prs_struct *data, prs_stru ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_startpageprinter("", &q_u, data, 0); + if(!spoolss_io_q_startpageprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_startpageprinter: unable to unmarshall SPOOL_Q_STARTPAGEPRINTER.\n")); + return False; + } + r_u.status = _spoolss_startpageprinter(&q_u.handle); - spoolss_io_r_startpageprinter("",&r_u,rdata,0); + + if(!spoolss_io_r_startpageprinter("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_startpageprinter: unable to marshall SPOOL_R_STARTPAGEPRINTER.\n")); + return False; + } + + return True; } @@ -281,9 +330,19 @@ static BOOL api_spoolss_endpageprinter(uint16 vuid, prs_struct *data, prs_struct ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_endpageprinter("", &q_u, data, 0); + if(!spoolss_io_q_endpageprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_endpageprinter: unable to unmarshall SPOOL_Q_ENDPAGEPRINTER.\n")); + return False; + } + r_u.status = _spoolss_endpageprinter(&q_u.handle); - spoolss_io_r_endpageprinter("",&r_u,rdata,0); + + if(!spoolss_io_r_endpageprinter("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_endpageprinter: unable to marshall SPOOL_R_ENDPAGEPRINTER.\n")); + return False; + } + + return True; } /******************************************************************** @@ -299,12 +358,22 @@ static BOOL api_spoolss_startdocprinter(uint16 vuid, prs_struct *data, prs_struc ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_startdocprinter("", &q_u, data, 0); + if(!spoolss_io_q_startdocprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_startdocprinter: unable to unmarshall SPOOL_Q_STARTDOCPRINTER.\n")); + return False; + } + r_u.status = _spoolss_startdocprinter(&q_u.handle, q_u.doc_info_container.level, &q_u.doc_info_container.docinfo, &r_u.jobid); - spoolss_io_r_startdocprinter("",&r_u,rdata,0); + + if(!spoolss_io_r_startdocprinter("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_startdocprinter: unable to marshall SPOOL_R_STARTDOCPRINTER.\n")); + return False; + } + + return True; } /******************************************************************** @@ -320,9 +389,19 @@ static BOOL api_spoolss_enddocprinter(uint16 vuid, prs_struct *data, prs_struct ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_enddocprinter("", &q_u, data, 0); + if(!spoolss_io_q_enddocprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_enddocprinter: unable to unmarshall SPOOL_Q_ENDDOCPRINTER.\n")); + return False; + } + r_u.status = _spoolss_enddocprinter(&q_u.handle); - spoolss_io_r_enddocprinter("",&r_u,rdata,0); + + if(!spoolss_io_r_enddocprinter("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_enddocprinter: unable to marshall SPOOL_R_ENDDOCPRINTER.\n")); + return False; + } + + return True; } @@ -339,14 +418,24 @@ static BOOL api_spoolss_writeprinter(uint16 vuid, prs_struct *data, prs_struct * ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_writeprinter("", &q_u, data, 0); + if(!spoolss_io_q_writeprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_writeprinter: unable to unmarshall SPOOL_Q_WRITEPRINTER.\n")); + return False; + } + r_u.status = _spoolss_writeprinter(&q_u.handle, q_u.buffer_size, q_u.buffer, &q_u.buffer_size2); r_u.buffer_written = q_u.buffer_size2; safe_free(q_u.buffer); - spoolss_io_r_writeprinter("",&r_u,rdata,0); + + if(!spoolss_io_r_writeprinter("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_writeprinter: unable to marshall SPOOL_R_WRITEPRINTER.\n")); + return False; + } + + return True; } /**************************************************************************** @@ -359,7 +448,11 @@ static BOOL api_spoolss_setprinter(uint16 vuid, prs_struct *data, prs_struct *rd ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_setprinter("", &q_u, data, 0); + if(!spoolss_io_q_setprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_setprinter: unable to unmarshall SPOOL_Q_SETPRINTER.\n")); + return False; + } + DEBUG(0,("api_spoolss_setprinter: typecast sec_des to uint8*!\n")); r_u.status = _spoolss_setprinter(&q_u.handle, q_u.level, &q_u.info, @@ -367,7 +460,13 @@ static BOOL api_spoolss_setprinter(uint16 vuid, prs_struct *data, prs_struct *rd q_u.security.size_of_buffer, (const uint8*)q_u.security.data, q_u.command); - spoolss_io_r_setprinter("",&r_u,rdata,0); + + if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n")); + return False; + } + + return True; } /**************************************************************************** @@ -380,9 +479,19 @@ static BOOL api_spoolss_fcpn(uint16 vuid, prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_fcpn("", &q_u, data, 0); + if(!spoolss_io_q_fcpn("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_fcpn: unable to unmarshall SPOOL_Q_FCPN.\n")); + return False; + } + r_u.status = _spoolss_fcpn(&q_u.handle); - spoolss_io_r_fcpn("",&r_u,rdata,0); + + if(!spoolss_io_r_fcpn("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_fcpn: unable to marshall SPOOL_R_FCPN.\n")); + return False; + } + + return True; } @@ -396,13 +505,22 @@ static BOOL api_spoolss_addjob(uint16 vuid, prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_addjob("", &q_u, data, 0); + if(!spoolss_io_q_addjob("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_addjob: unable to unmarshall SPOOL_Q_ADDJOB.\n")); + return False; + } r_u.status = _spoolss_addjob(&q_u.handle, q_u.level, &q_u.buffer, q_u.buf_size); spoolss_io_free_buffer(&(q_u.buffer)); - spoolss_io_r_addjob("",&r_u,rdata,0); + + if(!spoolss_io_r_addjob("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_addjob: unable to marshall SPOOL_R_ADDJOB.\n")); + return False; + } + + return True; } @@ -415,15 +533,30 @@ static BOOL api_spoolss_enumjobs(uint16 vuid, prs_struct *data, prs_struct *rdat ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); + + new_spoolss_allocate_buffer(&q_u.buffer); + + if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n")); + return False; + } + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); + + r_u.status = _spoolss_enumjobs(&q_u.handle, q_u.firstjob, q_u.numofjobs, q_u.level, + r_u.buffer, q_u.offered, + &r_u.needed, &r_u.returned); + + if (!spoolss_io_r_enumjobs("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_enumjobs: unable to marshall SPOOL_R_ENUMJOBS.\n")); + new_spoolss_free_buffer(q_u.buffer); + return False; + } + + new_spoolss_free_buffer(q_u.buffer); - spoolss_io_q_enumjobs("", &q_u, data, 0); - r_u.offered = q_u.buf_size; - r_u.level = q_u.level; - r_u.status = _spoolss_enumjobs(&q_u.handle, - q_u.firstjob, q_u.numofjobs, q_u.level, - &r_u.ctr, &r_u.offered, &r_u.numofjobs); - spoolss_io_free_buffer(&(q_u.buffer)); - spoolss_io_r_enumjobs("",&r_u,rdata,0); + return True; } @@ -437,9 +570,19 @@ static BOOL api_spoolss_schedulejob(uint16 vuid, prs_struct *data, prs_struct *r ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_schedulejob("", &q_u, data, 0); + if(!spoolss_io_q_schedulejob("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_schedulejob: unable to unmarshall SPOOL_Q_SCHEDULEJOB.\n")); + return False; + } + r_u.status = _spoolss_schedulejob(&q_u.handle, q_u.jobid); - spoolss_io_r_schedulejob("",&r_u,rdata,0); + + if(!spoolss_io_r_schedulejob("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_schedulejob: unable to marshall SPOOL_R_SCHEDULEJOB.\n")); + return False; + } + + return True; } /**************************************************************************** @@ -452,10 +595,20 @@ static BOOL api_spoolss_setjob(uint16 vuid, prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_setjob("", &q_u, data, 0); + if(!spoolss_io_q_setjob("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_setjob: unable to unmarshall SPOOL_Q_SETJOB.\n")); + return False; + } + r_u.status = _spoolss_setjob(&q_u.handle, q_u.jobid, q_u.level, &q_u.ctr, q_u.command); - spoolss_io_r_setjob("",&r_u,rdata,0); + + if(!spoolss_io_r_setjob("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_setjob: unable to marshall SPOOL_R_SETJOB.\n")); + return False; + } + + return True; } /**************************************************************************** @@ -468,18 +621,30 @@ static BOOL api_spoolss_enumprinterdrivers(uint16 vuid, prs_struct *data, prs_st ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - - spoolss_io_q_enumprinterdrivers("", &q_u, data, 0); - r_u.offered = q_u.buf_size; - r_u.level = q_u.level; - r_u.status = _spoolss_enumprinterdrivers(&q_u.name, - &q_u.environment, q_u. level, - &r_u.ctr, &r_u.offered, &r_u.numofdrivers); + new_spoolss_allocate_buffer(&q_u.buffer); - spoolss_io_free_buffer(&q_u.buffer); - spoolss_io_r_enumdrivers("",&r_u,rdata,0); - free_spoolss_r_enumdrivers(&r_u); + if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n")); + return False; + } + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); + + r_u.status = _spoolss_enumprinterdrivers(&q_u.name, &q_u.environment, q_u.level, + r_u.buffer, q_u.offered, + &r_u.needed, &r_u.returned); + + if (!new_spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) { + DEBUG(0,("new_spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n")); + new_spoolss_free_buffer(q_u.buffer); + return False; + } + + new_spoolss_free_buffer(q_u.buffer); + + return True; } @@ -493,12 +658,12 @@ static BOOL api_spoolss_enumforms(uint16 vuid, prs_struct *data, prs_struct *rda ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - DEBUG(5,("spoolss_io_q_enumforms\n")); - new_spoolss_allocate_buffer(&q_u.buffer); - if (!spoolss_io_q_enumforms("", &q_u, data, 0)) + if (!spoolss_io_q_enumforms("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n")); return False; + } /* that's an [in out] buffer */ new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); @@ -508,6 +673,7 @@ static BOOL api_spoolss_enumforms(uint16 vuid, prs_struct *data, prs_struct *rda &r_u.needed, &r_u.numofforms); if (!new_spoolss_io_r_enumforms("",&r_u,rdata,0)) { + DEBUG(0,("new_spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n")); new_spoolss_free_buffer(q_u.buffer); return False; } @@ -527,20 +693,30 @@ static BOOL api_spoolss_enumports(uint16 vuid, prs_struct *data, prs_struct *rda ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - - spoolss_io_q_enumports("", &q_u, data, 0); - r_u.offered = q_u.buf_size; - r_u.level = q_u.level; - r_u.status = _spoolss_enumports(&q_u.name, - q_u.level, - &r_u.ctr, - &r_u.offered, - &r_u.numofports); + new_spoolss_allocate_buffer(&q_u.buffer); + + if(!spoolss_io_q_enumports("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n")); + return False; + } + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - spoolss_io_free_buffer(&(q_u.buffer)); - spoolss_io_r_enumports("",&r_u,rdata,0); - spoolss_free_r_enumports(&r_u); + r_u.status = _spoolss_enumports(&q_u.name, q_u.level, + r_u.buffer, q_u.offered, + &r_u.needed, &r_u.returned); + + if (!new_spoolss_io_r_enumports("",&r_u,rdata,0)) { + DEBUG(0,("new_spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n")); + new_spoolss_free_buffer(q_u.buffer); + return False; + } + + new_spoolss_free_buffer(q_u.buffer); + + return True; } @@ -554,13 +730,23 @@ static BOOL api_spoolss_addprinterex(uint16 vuid, prs_struct *data, prs_struct * ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_addprinterex("", &q_u, data, 0); + if(!spoolss_io_q_addprinterex("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_addprinterex: unable to unmarshall SPOOL_Q_ADDPRINTEREX.\n")); + return False; + } + r_u.status = _spoolss_addprinterex(&q_u.server_name, q_u.level, &q_u.info, q_u.unk0, q_u.unk1, q_u.unk2, q_u.unk3, q_u.user_level, &q_u.user, &r_u.handle); - spoolss_io_r_addprinterex("", &r_u, rdata, 0); + + if(!spoolss_io_r_addprinterex("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_addprinterex: unable to marshall SPOOL_R_ADDPRINTEREX.\n")); + return False; + } + + return True; } /**************************************************************************** @@ -573,10 +759,20 @@ static BOOL api_spoolss_addprinterdriver(uint16 vuid, prs_struct *data, prs_stru ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_addprinterdriver("", &q_u, data, 0); + if(!spoolss_io_q_addprinterdriver("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n")); + return False; + } + r_u.status = _spoolss_addprinterdriver(&q_u.server_name, q_u.level, &q_u.info); - spoolss_io_r_addprinterdriver("", &r_u, rdata, 0); + + if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n")); + return False; + } + + return True; } /**************************************************************************** @@ -586,7 +782,10 @@ static BOOL api_spoolss_getprinterdriverdirectory(uint16 vuid, prs_struct *data, SPOOL_Q_GETPRINTERDRIVERDIR q_u; SPOOL_R_GETPRINTERDRIVERDIR r_u; - spoolss_io_q_getprinterdriverdir("", &q_u, data, 0); + if(!spoolss_io_q_getprinterdriverdir("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n")); + return False; + } r_u.offered = q_u.buf_size; r_u.level = q_u.level; @@ -596,7 +795,13 @@ static BOOL api_spoolss_getprinterdriverdirectory(uint16 vuid, prs_struct *data, &r_u.ctr, &r_u.offered); spoolss_io_free_buffer(&q_u.buffer); - spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0); + + if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n")); + return False; + } + + return True; } /**************************************************************************** @@ -609,7 +814,11 @@ static BOOL api_spoolss_enumprinterdata(uint16 vuid, prs_struct *data, prs_struc ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_enumprinterdata("", &q_u, data, 0); + if(!spoolss_io_q_enumprinterdata("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_enumprinterdata: unable to unmarshall SPOOL_Q_ENUMPRINTERDATA.\n")); + return False; + } + r_u.valuesize = q_u.valuesize; r_u.datasize = q_u.datasize; @@ -622,8 +831,15 @@ static BOOL api_spoolss_enumprinterdata(uint16 vuid, prs_struct *data, prs_struc &r_u.datasize,/* in out */ &r_u.data,/* out */ &r_u.realdatasize);/* out */ - spoolss_io_r_enumprinterdata("", &r_u, rdata, 0); + + if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n")); + return False; + } + safe_free(r_u.data); + + return True; } /**************************************************************************** @@ -636,12 +852,21 @@ static BOOL api_spoolss_setprinterdata(uint16 vuid, prs_struct *data, prs_struct ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_setprinterdata("", &q_u, data, 0); + if(!spoolss_io_q_setprinterdata("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n")); + return False; + } + r_u.status = _spoolss_setprinterdata(&q_u.handle, &q_u.value, q_u.type, q_u.max_len, q_u.data, q_u.real_len, q_u.numeric_data); - spoolss_io_r_setprinterdata("", &r_u, rdata, 0); - safe_free(q_u.data); + + if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n")); + return False; + } + + return True; } /**************************************************************************** @@ -654,9 +879,19 @@ static BOOL api_spoolss_addform(uint16 vuid, prs_struct *data, prs_struct *rdata ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_addform("", &q_u, data, 0); + if(!spoolss_io_q_addform("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_addform: unable to unmarshall SPOOL_Q_ADDFORM.\n")); + return False; + } + r_u.status = _spoolss_addform(&q_u.handle, q_u.level, &q_u.form); - spoolss_io_r_addform("", &r_u, rdata, 0); + + if(!spoolss_io_r_addform("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_addform: unable to marshall SPOOL_R_ADDFORM.\n")); + return False; + } + + return True; } /**************************************************************************** @@ -669,10 +904,20 @@ static BOOL api_spoolss_setform(uint16 vuid, prs_struct *data, prs_struct *rdata ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_setform("", &q_u, data, 0); + if(!spoolss_io_q_setform("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_setform: unable to unmarshall SPOOL_Q_SETFORM.\n")); + return False; + } + r_u.status = _spoolss_setform(&q_u.handle, &q_u.name, q_u.level, &q_u.form); - spoolss_io_r_setform("", &r_u, rdata, 0); + + if(!spoolss_io_r_setform("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_setform: unable to marshall SPOOL_R_SETFORM.\n")); + return False; + } + + return True; } /**************************************************************************** @@ -685,18 +930,29 @@ static BOOL api_spoolss_enumprintprocessors(uint16 vuid, prs_struct *data, prs_s ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_enumprintprocessors("", &q_u, data, 0); - r_u.offered = q_u.buf_size; - r_u.level = q_u.level; - r_u.status = _spoolss_enumprintprocessors(&q_u.name, - &q_u.environment, - q_u.level, - &r_u.info_1, - &r_u.offered, - &r_u.numofprintprocessors); - spoolss_io_free_buffer(&q_u.buffer); - spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0); - safe_free(r_u.info_1); + new_spoolss_allocate_buffer(&q_u.buffer); + + if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n")); + return False; + } + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); + + r_u.status = _spoolss_enumprintprocessors(&q_u.name, &q_u.environment, q_u.level, + r_u.buffer, q_u.offered, + &r_u.needed, &r_u.returned); + + if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n")); + new_spoolss_free_buffer(q_u.buffer); + return False; + } + + new_spoolss_free_buffer(q_u.buffer); + + return True; } /**************************************************************************** @@ -709,17 +965,29 @@ static BOOL api_spoolss_enumprintmonitors(uint16 vuid, prs_struct *data, prs_str ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - spoolss_io_q_enumprintmonitors("", &q_u, data, 0); - r_u.offered = q_u.buf_size; - r_u.level = q_u.level; - r_u.status = _spoolss_enumprintmonitors(&q_u.name, - q_u.level, - &r_u.info_1, - &r_u.offered, - &r_u.numofprintmonitors); - spoolss_io_free_buffer(&q_u.buffer); - spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0); - safe_free(r_u.info_1); + new_spoolss_allocate_buffer(&q_u.buffer); + + if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n")); + return False; + } + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); + + r_u.status = _spoolss_enumprintmonitors(&q_u.name, q_u.level, + r_u.buffer, q_u.offered, + &r_u.needed, &r_u.returned); + + if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n")); + new_spoolss_free_buffer(q_u.buffer); + return False; + } + + new_spoolss_free_buffer(q_u.buffer); + + return True; } /**************************************************************************** @@ -729,7 +997,10 @@ static BOOL api_spoolss_getjob(uint16 vuid, prs_struct *data, prs_struct *rdata) SPOOL_Q_GETJOB q_u; SPOOL_R_GETJOB r_u; - spoolss_io_q_getjob("", &q_u, data, 0); + if(!spoolss_io_q_getjob("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n")); + return False; + } r_u.offered = q_u.buf_size; r_u.level = q_u.level; @@ -739,8 +1010,15 @@ static BOOL api_spoolss_getjob(uint16 vuid, prs_struct *data, prs_struct *rdata) &r_u.ctr, &r_u.offered); spoolss_io_free_buffer(&(q_u.buffer)); - spoolss_io_r_getjob("",&r_u,rdata,0); + + if(!spoolss_io_r_getjob("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n")); + return False; + } + free_spoolss_r_getjob(&r_u); + + return True; } /******************************************************************* diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d25281cea5..2e80cbdbf6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -200,11 +200,8 @@ static BOOL open_printer_hnd(POLICY_HND *hnd) { if (!Printer[i].open) { - Printer[i].open = True; - Printer[i].ok = True; - + Printer[i].open = True; memcpy(&(Printer[i].printer_hnd), hnd, sizeof(*hnd)); - DEBUG(4,("Opened printer handle[%x] ", i)); dump_data(4, hnd->data, sizeof(hnd->data)); return True; @@ -221,32 +218,14 @@ static BOOL set_printer_hnd_accesstype(POLICY_HND *hnd, uint32 access_required) { int pnum = find_printer_index_by_hnd(hnd); - if (OPEN_HANDLE(pnum)) { - DEBUG(4,("Setting printer access=%x (pnum=%x)\n", access_required, pnum)); - Printer[pnum].access = access_required; - return True; - } - else { + if (!OPEN_HANDLE(pnum)) { DEBUG(4,("Error setting printer type=%x (pnum=%x)", access_required, pnum)); return False; } - return False; -} - -/**************************************************************************** - . -****************************************************************************/ -static BOOL printer_entry_is_valid(POLICY_HND *hnd) -{ - int pnum = find_printer_index_by_hnd(hnd); - if (!OPEN_HANDLE(pnum)) - return False; - - if (Printer[pnum].ok == False) - return False; - - return True; + DEBUG(4,("Setting printer access=%x (pnum=%x)\n", access_required, pnum)); + Printer[pnum].access = access_required; + return True; } /**************************************************************************** @@ -266,23 +245,19 @@ static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername) if ( strlen(printername) < 3 ) { DEBUGADD(4,("A print server must have at least 1 char ! %s\n", printername)); - Printer[pnum].ok=False; return False; } /* it's a print server */ if (!strchr(printername+2, '\\')) { DEBUGADD(4,("Printer is a print server\n")); - Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTSERVER; - Printer[pnum].ok=True; - + Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTSERVER; return True; } /* it's a printer */ else { DEBUGADD(4,("Printer is a printer\n")); Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTER; - Printer[pnum].ok=True; return True; } @@ -295,11 +270,11 @@ static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername) static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) { int pnum = find_printer_index_by_hnd(hnd); - char *back; NT_PRINTER_INFO_LEVEL printer; int snum; int n_services=lp_numservices(); - uint32 marche; + char *aprinter; + BOOL found=False; if (!OPEN_HANDLE(pnum)) { @@ -309,54 +284,66 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) DEBUG(4,("Setting printer name=%s (len=%d) (pnum=%x)\n", printername, strlen(printername), pnum)); - switch (Printer[pnum].printer_type) { - case PRINTER_HANDLE_IS_PRINTSERVER: + if (Printer[pnum].printer_type==PRINTER_HANDLE_IS_PRINTSERVER) { ZERO_STRUCT(Printer[pnum].dev.printerservername); strncpy(Printer[pnum].dev.printerservername, printername, strlen(printername)); return True; - break; + } - case PRINTER_HANDLE_IS_PRINTER: - back=strchr(printername+2, '\\'); - back=back+1; - DEBUGADD(5,("searching for %s (len=%d)\n", back,strlen(back))); - /* - * store the Samba share name in it - * in back we have the long printer name - * need to iterate all the snum and do a - * get_a_printer each time to find the printer - * faster to do it here than later. - */ - for (snum=0;snumprintername) == strlen(back) ) - && ( !strncasecmp(printer.info_2->printername, back, strlen(back))) - ) { - DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); - ZERO_STRUCT(Printer[pnum].dev.printername); - strncpy(Printer[pnum].dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); - free_a_printer(printer, 2); - return True; - break; - } - free_a_printer(printer, 2); - } - } + if (Printer[pnum].printer_type!=PRINTER_HANDLE_IS_PRINTER) return False; - break; - - default: + + aprinter=strchr(printername+2, '\\'); + aprinter++; + + DEBUGADD(5,("searching for [%s] (len=%d)\n", aprinter, strlen(aprinter))); + /* + * store the Samba share name in it + * in back we have the long printer name + * need to iterate all the snum and do a + * get_a_printer each time to find the printer + * faster to do it here than later. + */ + + for (snum=0;snumprintername) != strlen(aprinter) ) { + free_a_printer(printer, 2); + continue; + } + + if ( strncasecmp(printer.info_2->printername, aprinter, strlen(aprinter))) { + free_a_printer(printer, 2); + continue; + } + + found=True; + } + + if (found==False) + { + DEBUGADD(4,("Printer not found\n")); return False; - break; - } + } + + DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); + ZERO_STRUCT(Printer[pnum].dev.printername); + strncpy(Printer[pnum].dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); + free_a_printer(printer, 2); + + return True; } /******************************************************************** + Return True is the handle is a print server. ********************************************************************/ static BOOL handle_is_printserver(const POLICY_HND *handle) { @@ -371,6 +358,30 @@ static BOOL handle_is_printserver(const POLICY_HND *handle) return True; } +/**************************************************************************** + allocate more memory for a BUFFER. +****************************************************************************/ +static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) +{ + prs_struct *ps; + uint32 extra_space; + + ps=&(buffer->prs); + + /* damn, I'm doing the reverse operation of prs_grow() :) */ + if (buffer_size < prs_data_size(ps)) + extra_space=0; + else + extra_space = buffer_size - prs_data_size(ps); + + if (!prs_grow(ps, extra_space)) + return False; + + buffer->string_at_end=prs_data_size(ps); + + return True; +} + /******************************************************************** * spoolss_open_printer * @@ -400,9 +411,15 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, open_printer_hnd(handle); - set_printer_hnd_printertype(handle, name); + if (!set_printer_hnd_printertype(handle, name)) { + close_printer_handle(handle); + return NT_STATUS_ACCESS_DENIED; + } - set_printer_hnd_printername(handle, name); + if (!set_printer_hnd_printername(handle, name)) { + close_printer_handle(handle); + return NT_STATUS_ACCESS_DENIED; + } /* if (printer_default->datatype_ptr != NULL) @@ -414,14 +431,11 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, set_printer_hnd_datatype(handle, ""); */ - set_printer_hnd_accesstype(handle, printer_default->access_required); - - if (!printer_entry_is_valid(handle)) - { + if (!set_printer_hnd_accesstype(handle, printer_default->access_required)) { close_printer_handle(handle); return NT_STATUS_ACCESS_DENIED; } - + return NT_STATUS_NO_PROBLEMO; } @@ -536,7 +550,8 @@ uint32 _spoolss_closeprinter(POLICY_HND *handle) } /******************************************************************** - ********************************************************************/ + GetPrinterData on a printer server Handle. +********************************************************************/ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size) { int i; @@ -585,7 +600,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d *type = 0x1; *needed = 2*(strlen(string)+1); *data = (uint8 *)malloc( ((*needed > in_size) ? *needed:in_size) *sizeof(uint8)); - ZERO_STRUCTP(*data); + memset(*data, 0, (*needed > in_size) ? *needed:in_size); /* it's done by hand ready to go on the wire */ for (i=0; i in_size) ? *needed:in_size) *sizeof(uint8)); - ZERO_STRUCTP(*data); + memset(*data, 0, (*needed > in_size) ? *needed:in_size); for (i=0; iflags=PRINTER_ENUM_NAME; + printer->flags=PRINTER_ENUM_ICON8; /* the description and the name are of the form \\server\share */ - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s,%s,%s",servername, + + snprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s,%s,%s",servername, ntprinter.info_2->printername, ntprinter.info_2->drivername, lp_comment(snum)); init_unistr(&(printer->description), chaine); - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s", servername, ntprinter.info_2->printername); - init_unistr(&(printer->name), chaine); + snprintf(chaine2,sizeof(chaine)-1,"\\\\%s\\%s", servername, ntprinter.info_2->printername); + init_unistr(&(printer->name), chaine2); init_unistr(&(printer->comment), lp_comment(snum)); free_a_printer(ntprinter, 2); + return (True); } @@ -1648,29 +1668,26 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring * enum_printer_info_1 * glue between spoolss_enumprinters and construct_printer_info_1 ********************************************************************/ -static BOOL enum_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number) +static BOOL get_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number) { pstring servername; *printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1)); DEBUG(4,("Allocated memory for ONE PRINTER_INFO_1 at [%p]\n", *printer)); pstrcpy(servername, global_myname); - if (!construct_printer_info_1(*printer, snum, servername)) - { + if (!construct_printer_info_1(*printer, snum, servername)) { free(*printer); - return (False); + return False; } else - { - return (True); - } + return True; } /******************************************************************** * enum_printer_info_2 * glue between spoolss_enumprinters and construct_printer_info_2 ********************************************************************/ -static BOOL enum_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number) +static BOOL get_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number) { pstring servername; @@ -1693,26 +1710,100 @@ static BOOL enum_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number) * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number) +static BOOL enum_printer_info_1(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int snum; + int i; int n_services=lp_numservices(); - *printers=NULL; - *number=0; + PRINTER_INFO_1 *printer=NULL; +DEBUG(1,("enum_printer_info_1\n")); + for (snum=0; snum offered) { + *returned=0; + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; +} + +/******************************************************************** + Spoolss_enumprinters. +********************************************************************/ +static BOOL enum_all_printers_info_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +{ + int snum; + int i; + int n_services=lp_numservices(); + PRINTER_INFO_1 *printers=NULL; + PRINTER_INFO_1 current_prt; + pstring servername; + + DEBUG(4,("enum_all_printers_info_1\n")); + + pstrcpy(servername, global_myname); + + for (snum=0; snum offered) { + *returned=0; + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; } /******************************************************************** @@ -1720,26 +1811,90 @@ static void enum_all_printers_info_1(PRINTER_INFO_1 ***printers, uint32 *number) * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number) +static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int snum; + int i; int n_services=lp_numservices(); - *printers=NULL; - *number=0; + PRINTER_INFO_2 **printers=NULL; - for (snum=0;snum offered) { + *returned=0; + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; +} + +/******************************************************************** + * handle enumeration of printers at level 1 + ********************************************************************/ +static uint32 enumprinters_level1( uint32 flags, fstring name, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed, uint32 *returned) +{ + if (flags && PRINTER_ENUM_NETWORK) + return enum_all_printers_info_1(buffer, offered, needed, returned); + + if (flags && PRINTER_ENUM_NAME) { + if (*name=='\0') + return enum_all_printers_info_1(buffer, offered, needed, returned); + else + return enum_printer_info_1(name, buffer, offered, needed, returned); + } + + if (flags && PRINTER_ENUM_REMOTE) + return enum_all_printers_info_1(buffer, offered, needed, returned); + + +} + +/******************************************************************** + * handle enumeration of printers at level 2 + ********************************************************************/ +static uint32 enumprinters_level2( uint32 flags, fstring servername, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed, uint32 *returned) +{ + return enum_all_printers_info_2(buffer, offered, needed, returned); +} + +/******************************************************************** + * handle enumeration of printers at level 5 + ********************************************************************/ +static uint32 enumprinters_level5( uint32 flags, fstring servername, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed, uint32 *returned) +{ +/* return enum_all_printers_info_5(buffer, offered, needed, returned);*/ + return NT_STATUS_NO_PROBLEMO; } /******************************************************************** @@ -1747,55 +1902,48 @@ static void enum_all_printers_info_2(PRINTER_INFO_2 ***printers, uint32 *number) * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -uint32 _spoolss_enumprinters( - uint32 flags, - const UNISTR2 *servername, - uint32 level, - const BUFFER *buffer, - uint32 buf_size, - uint32 *offered, - uint32 *needed, - PRINTER_INFO_CTR *ctr, - uint32 *returned) +uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 level, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed, uint32 *returned) { - DEBUG(4,("Enumerating printers\n")); + fstring name; + + DEBUG(4,("_spoolss_enumprinters\n")); - (*returned)=0; + *needed=0; + *returned=0; + + /* + * Level 1: + * flags==PRINTER_ENUM_NAME + * if name=="" then enumerates all printers + * if name!="" then enumerate the printer + * flags==PRINTER_ENUM_REMOTE + * name is NULL, enumerate printers + * Level 2: name!="" enumerates printers, name can't be NULL + * Level 3: doesn't exist + * Level 4: does a local registry lookup + * Level 5: same as Level 2 + */ - switch (level) - { - case 1: - if (flags == PRINTER_ENUM_NAME || - flags == PRINTER_ENUM_NETWORK ) - { - /*if (is_a_printerserver(servername))*/ - enum_all_printers_info_1(&ctr->printer.printers_1, returned ); - /*else - enum_one_printer_info_1(&r_u);*/ - break; - } - case 2: - if (flags == PRINTER_ENUM_NAME || - flags == PRINTER_ENUM_NETWORK ) - { - /*if (is_a_printerserver(servername))*/ - enum_all_printers_info_2(&ctr->printer.printers_2, returned ); - /*else - enum_one_printer_info_2(&r_u);*/ - break; - } - case 3: /* doesn't exist */ - return NT_STATUS_INVALID_INFO_CLASS; - case 4: /* can't, always on local machine */ - break; - case 5: - return NT_STATUS_INVALID_INFO_CLASS; - - } - DEBUG(4,("%d printers enumerated\n", *returned)); - (*offered) = buffer->size; + unistr2_to_ascii(name, servername, sizeof(name)-1); - return 0x0; + switch (level) { + case 1: + return enumprinters_level1(flags, name, buffer, offered, needed, returned); + break; + case 2: + return enumprinters_level2(flags, name, buffer, offered, needed, returned); + break; + case 5: + return enumprinters_level5(flags, name, buffer, offered, needed, returned); + break; + case 3: + case 4: + default: + return NT_STATUS_INVALID_LEVEL; + break; + } } /**************************************************************************** @@ -2562,86 +2710,135 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, } /**************************************************************************** + Enumjobs at level 1. ****************************************************************************/ -uint32 _spoolss_enumjobs( const POLICY_HND *handle, - uint32 reqfirstjob, - uint32 reqnumofjobs, - uint32 level, - JOB_INFO_CTR *ctr, - uint32 *buf_size, - uint32 *numofjobs) +static uint32 enumjobs_level1(print_queue_struct *queue, int snum, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed, uint32 *returned) { - int snum; - int count; + JOB_INFO_1 *info; int i; - print_queue_struct *queue=NULL; - print_status_struct prt_status; - - DEBUG(4,("spoolss_enumjobs\n")); - - ZERO_STRUCT(prt_status); - - if (!get_printer_snum(handle, &snum)) - { - return NT_STATUS_INVALID_HANDLE; - } - - count = get_printqueue(snum, NULL, &queue, &prt_status); - (*numofjobs) = 0; - DEBUG(4,("count:[%d], status:[%d], [%s]\n", - count, prt_status.status, prt_status.message)); + info=(JOB_INFO_1 *)malloc(*returned*sizeof(JOB_INFO_1)); - switch (level) + for (i=0; i<*returned; i++) { - case 1: - { - for (i=0; ijob.job_info_1, - job_info_1); - - fill_job_info_1(ctr->job.job_info_1[i], - &(queue[i]), i, snum); - } - safe_free(queue); - return 0x0; - } - case 2: - { - for (i=0; ijob.job_info_2, - job_info_2); - - fill_job_info_2(ctr->job.job_info_2[i], - &(queue[i]), i, snum); - } - safe_free(queue); - return 0x0; - } + fill_job_info_1(&(info[i]), &(queue[i]), i, snum); } + /* check the required size. */ + for (i=0; i<*returned; i++) + (*needed) += spoolss_size_job_info_1(&(info[i])); + + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + /* fill the buffer with the structures */ + for (i=0; i<*returned; i++) + new_smb_io_job_info_1("", buffer, &(info[i]), 0); + + /* clear memory */ safe_free(queue); + safe_free(info); - return NT_STATUS_INVALID_INFO_CLASS; + if (*needed > offered) { + *returned=0; + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; } /**************************************************************************** + Enumjobs at level 2. ****************************************************************************/ -uint32 _spoolss_schedulejob( const POLICY_HND *handle, uint32 jobid) +static uint32 enumjobs_level2(print_queue_struct *queue, int snum, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed, uint32 *returned) { - return 0x0; -} - -/**************************************************************************** -****************************************************************************/ + JOB_INFO_2 *info; + int i; + + info=(JOB_INFO_2 *)malloc(*returned*sizeof(JOB_INFO_2)); + + for (i=0; i<*returned; i++) + { + fill_job_info_2(&(info[i]), &(queue[i]), i, snum); + } + + /* check the required size. */ + for (i=0; i<*returned; i++) + (*needed) += spoolss_size_job_info_2(&(info[i])); + + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + /* fill the buffer with the structures */ + for (i=0; i<*returned; i++) + new_smb_io_job_info_2("", buffer, &(info[i]), 0); + + /* clear memory */ + safe_free(queue); + safe_free(info); + + if (*needed > offered) { + *returned=0; + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; +} + +/**************************************************************************** + Enumjobs. +****************************************************************************/ +uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, uint32 level, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed, uint32 *returned) +{ + int snum; + print_queue_struct *queue=NULL; + print_status_struct prt_status; + + DEBUG(4,("_spoolss_enumjobs\n")); + + ZERO_STRUCT(prt_status); + + *needed=0; + *returned=0; + + if (!get_printer_snum(handle, &snum)) + { + return NT_STATUS_INVALID_HANDLE; + } + + *returned = get_printqueue(snum, NULL, &queue, &prt_status); + DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); + + switch (level) { + case 1: + return enumjobs_level1(queue, snum, buffer, offered, needed, returned); + break; + case 2: + return enumjobs_level2(queue, snum, buffer, offered, needed, returned); + break; + default: + return NT_STATUS_INVALID_LEVEL; + break; + } +} + + + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_schedulejob( const POLICY_HND *handle, uint32 jobid) +{ + return 0x0; +} + +/**************************************************************************** +****************************************************************************/ uint32 _spoolss_setjob( const POLICY_HND *handle, uint32 jobid, uint32 level, @@ -2705,86 +2902,166 @@ uint32 _spoolss_setjob( const POLICY_HND *handle, } /**************************************************************************** + Enumerates all printer drivers at level 1. ****************************************************************************/ -uint32 _spoolss_enumprinterdrivers( const UNISTR2 *name, - const UNISTR2 *environment, - uint32 level, - DRIVER_INFO *ctr, - uint32 *offered, - uint32 *numofdrivers) +static uint32 enumprinterdrivers_level1(fstring *list, fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - NT_PRINTER_DRIVER_INFO_LEVEL driver; - int count; int i; - fstring *list; - fstring servername; - fstring architecture; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + DRIVER_INFO_1 *driver_info_1=NULL; + driver_info_1=(DRIVER_INFO_1 *)malloc(*returned * sizeof(DRIVER_INFO_1)); - DEBUG(4,("spoolss_enumdrivers\n")); - fstrcpy(servername, global_myname); + for (i=0; i<*returned; i++) { + get_a_printer_driver(&driver, 3, list[i], architecture); + fill_printer_driver_info_1(&(driver_info_1[i]), driver, servername, architecture ); + free_a_printer_driver(driver, 3); + } + + /* check the required size. */ + for (i=0; i<*returned; i++) + { + DEBUGADD(6,("adding driver [%d]'s size\n",i)); + *needed += spoolss_size_printer_driver_info_1(&(driver_info_1[i])); + } - unistr2_to_ascii(architecture, environment, sizeof(architecture)); - count=get_ntdrivers(&list, architecture); + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; - DEBUGADD(4,("we have: [%d] drivers on archi [%s]\n",count, architecture)); - for (i=0; i offered) + return ERROR_INSUFFICIENT_BUFFER; + else + return NT_STATUS_NO_PROBLEMO; +} + +/**************************************************************************** + Enumerates all printer drivers at level 2. +****************************************************************************/ +static uint32 enumprinterdrivers_level2(fstring *list, fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +{ + int i; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + DRIVER_INFO_2 *driver_info_2=NULL; + driver_info_2=(DRIVER_INFO_2 *)malloc(*returned * sizeof(DRIVER_INFO_2)); + + for (i=0; i<*returned; i++) { + get_a_printer_driver(&driver, 3, list[i], architecture); + fill_printer_driver_info_2(&(driver_info_2[i]), driver, servername, architecture ); + free_a_printer_driver(driver, 3); } - (*numofdrivers)=count; + /* check the required size. */ + for (i=0; i<*returned; i++) + { + DEBUGADD(6,("adding driver [%d]'s size\n",i)); + *needed += spoolss_size_printer_driver_info_2(&(driver_info_2[i])); + } + + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + /* fill the buffer with the form structures */ + for (i=0; i<*returned; i++) + { + DEBUGADD(6,("adding form [%d] to buffer\n",i)); + new_smb_io_printer_driver_info_2("", buffer, &(driver_info_2[i]), 0); + } + + safe_free(list); + + if (*needed > offered) + return ERROR_INSUFFICIENT_BUFFER; + else + return NT_STATUS_NO_PROBLEMO; +} + +/**************************************************************************** + Enumerates all printer drivers at level 3. +****************************************************************************/ +static uint32 enumprinterdrivers_level3(fstring *list, fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +{ + int i; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + DRIVER_INFO_3 *driver_info_3=NULL; + driver_info_3=(DRIVER_INFO_3 *)malloc((*returned)*sizeof(DRIVER_INFO_3)); + + for (i=0; i<*returned; i++) { + get_a_printer_driver(&driver, 3, list[i], architecture); + fill_printer_driver_info_3(&(driver_info_3[i]), driver, servername, architecture ); + free_a_printer_driver(driver, 3); + } - switch (level) + /* check the required size. */ + for (i=0; i<*returned; i++) { - case 1: - { - DRIVER_INFO_1 *driver_info_1=NULL; - driver_info_1=(DRIVER_INFO_1 *)malloc(count*sizeof(DRIVER_INFO_1)); + DEBUGADD(6,("adding driver [%d]'s size\n",i)); + *needed += spoolss_size_printer_driver_info_3(&(driver_info_3[i])); + } - for (i=0; idriver.info1=driver_info_1; - break; - } - case 2: - { - DRIVER_INFO_2 *driver_info_2=NULL; - driver_info_2=(DRIVER_INFO_2 *)malloc(count*sizeof(DRIVER_INFO_2)); - - for (i=0; idriver.info2=driver_info_2; - break; - } - case 3: - { - DRIVER_INFO_3 *driver_info_3=NULL; - driver_info_3=(DRIVER_INFO_3 *)malloc(count*sizeof(DRIVER_INFO_3)); - - for (i=0; idriver.info3=driver_info_3; - break; - } - default: - { - return NT_STATUS_INVALID_INFO_CLASS; - } + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + /* fill the buffer with the form structures */ + for (i=0; i<*returned; i++) + { + DEBUGADD(6,("adding form [%d] to buffer\n",i)); + new_smb_io_printer_driver_info_3("", buffer, &(driver_info_3[i]), 0); } - return 0x0; + safe_free(list); + + if (*needed > offered) + return ERROR_INSUFFICIENT_BUFFER; + else + return NT_STATUS_NO_PROBLEMO; +} + +/**************************************************************************** + Enumerates all printer drivers. +****************************************************************************/ +uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32 level, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed, uint32 *returned) +{ + int i; + fstring *list; + fstring servername; + fstring architecture; + + DEBUG(4,("_spoolss_enumprinterdrivers\n")); + fstrcpy(servername, global_myname); + *needed=0; + *returned=0; + + unistr2_to_ascii(architecture, environment, sizeof(architecture)-1); + *returned=get_ntdrivers(&list, architecture); + + DEBUGADD(4,("we have: [%d] drivers in environment [%s]\n", *returned, architecture)); + for (i=0; i<*returned; i++) + DEBUGADD(5,("driver: [%s]\n", list[i])); + + switch (level) { + case 1: + return enumprinterdrivers_level1(list, servername, architecture, buffer, offered, needed, returned); + break; + case 2: + return enumprinterdrivers_level2(list, servername, architecture, buffer, offered, needed, returned); + break; + case 3: + return enumprinterdrivers_level3(list, servername, architecture, buffer, offered, needed, returned); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + break; + } } /**************************************************************************** @@ -2801,26 +3078,6 @@ static void fill_form_1(FORM_1 *form, nt_forms_struct *list, int position) form->bottom=list->bottom; } -/**************************************************************************** -****************************************************************************/ -static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) -{ - prs_struct *ps; - uint32 extra_space; - - ps=&(buffer->prs); - - /* damn, I'm doing the reverse operation of prs_grow() :) */ - extra_space = buffer_size - prs_data_size(ps); - - if (!prs_grow(ps, extra_space)) - return False; - - buffer->string_at_end=buffer_size; - - return True; -} - /**************************************************************************** ****************************************************************************/ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, @@ -2832,7 +3089,6 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, int buffer_size=0; int i; - DEBUG(4,("_new_spoolss_enumforms\n")); DEBUGADD(5,("Offered buffer size [%d]\n", offered)); DEBUGADD(5,("Info level [%d]\n", level)); @@ -2886,43 +3142,9 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_enumforms( const POLICY_HND *handle, - uint32 level, - FORM_1 **forms_1, - uint32 *offered, - uint32 *numofforms) +static void fill_port_1(PORT_INFO_1 *port, char *name) { - int count; - int i; - nt_forms_struct *list=NULL; - (*forms_1)=NULL; - - DEBUG(4,("spoolss_enumforms\n")); - - count = get_ntforms(&list); - (*numofforms) = count; - - DEBUGADD(5,("Offered buffer size [%d]\n", *offered)); - DEBUGADD(5,("Number of forms [%d]\n", *numofforms)); - DEBUGADD(5,("Info level [%d]\n", level)); - - switch (level) - { - case 1: - { - (*forms_1)=(FORM_1 *)malloc(count*sizeof(FORM_1)); - for (i=0; iport_name), name); } /**************************************************************************** @@ -2938,45 +3160,135 @@ static void fill_port_2(PORT_INFO_2 *port, char *name) } /**************************************************************************** + enumports level 1. ****************************************************************************/ -uint32 _spoolss_enumports( const UNISTR2 *name, - uint32 level, - PORT_INFO_CTR *ctr, - uint32 *offered, - uint32 *numofports) +static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int n_services=lp_numservices(); int snum; + int i=0; + + PORT_INFO_1 *ports=NULL; - DEBUG(4,("spoolss_enumports\n")); + for (snum=0; snumport.info_2=ports_2; - return 0x0; - } + DEBUGADD(6,("adding port [%d]'s size\n", i)); + *needed += spoolss_size_port_info_1(&(ports[i])); + } + + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + /* fill the buffer with the ports structures */ + for (i=0; i<*returned; i++) + { + DEBUGADD(6,("adding port [%d] to buffer\n", i)); + new_smb_io_port_1("", buffer, &(ports[i]), 0); + } + + safe_free(ports); + + if (*needed > offered) { + *returned=0; + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; +} + + +/**************************************************************************** + enumports level 2. +****************************************************************************/ +static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +{ + int n_services=lp_numservices(); + int snum; + int i=0; + + PORT_INFO_2 *ports=NULL; + + for (snum=0; snum offered) { + *returned=0; + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; +} + +/**************************************************************************** + enumports. +****************************************************************************/ +uint32 _spoolss_enumports( UNISTR2 *name, uint32 level, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed, uint32 *returned) +{ + DEBUG(4,("spoolss_enumports\n")); + + *returned=0; + *needed=0; + + switch (level) { + case 1: + return enumports_level_1(buffer, offered, needed, returned); + break; + case 2: + return enumports_level_2(buffer, offered, needed, returned); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + break; + } } /**************************************************************************** @@ -3293,13 +3605,39 @@ uint32 _spoolss_setform( const POLICY_HND *handle, } /**************************************************************************** + enumprintprocessors level 1. ****************************************************************************/ -uint32 _spoolss_enumprintprocessors(const UNISTR2 *name, - const UNISTR2 *environment, - uint32 level, - PRINTPROCESSOR_1 **info_1, - uint32 *offered, - uint32 *numofprintprocessors) +static uint32 enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +{ + PRINTPROCESSOR_1 *info_1=NULL; + + info_1 = (PRINTPROCESSOR_1 *)malloc(sizeof(PRINTPROCESSOR_1)); + (*returned) = 0x1; + + init_unistr(&(info_1->name), "winprint"); + + *needed += spoolss_size_printprocessor_info_1(info_1); + + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + smb_io_printprocessor_info_1("", buffer, info_1, 0); + + safe_free(info_1); + + if (*needed > offered) { + *returned=0; + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_enumprintprocessors(UNISTR2 *name, UNISTR2 *environment, uint32 level, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed, uint32 *returned) { DEBUG(5,("spoolss_enumprintprocessors\n")); @@ -3310,26 +3648,85 @@ uint32 _spoolss_enumprintprocessors(const UNISTR2 *name, * and I can use my nice printer checker. */ - (*numofprintprocessors) = 0x1; - (*info_1) = (PRINTPROCESSOR_1 *)malloc(sizeof(PRINTPROCESSOR_1)); + *returned=0; + *needed=0; - if ((*info_1) == NULL) - { - return NT_STATUS_NO_MEMORY; + switch (level) { + case 1: + return enumprintprocessors_level_1(buffer, offered, needed, returned); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + break; } - init_unistr(&((*info_1)->name), "winprint"); +} - return 0x0; +/**************************************************************************** + enumprintmonitors level 1. +****************************************************************************/ +static uint32 enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +{ + PRINTMONITOR_1 *info_1=NULL; + + info_1 = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1)); + (*returned) = 0x1; + + init_unistr(&(info_1->name), "Local Port"); + + *needed += spoolss_size_printmonitor_info_1(info_1); + + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + smb_io_printmonitor_info_1("", buffer, info_1, 0); + + safe_free(info_1); + + if (*needed > offered) { + *returned=0; + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; } /**************************************************************************** + enumprintmonitors level 2. ****************************************************************************/ -uint32 _spoolss_enumprintmonitors( const UNISTR2 *name, - uint32 level, - PRINTMONITOR_1 **info_1, - uint32 *offered, - uint32 *numofprintmonitors) +static uint32 enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +{ + PRINTMONITOR_2 *info_2=NULL; + + info_2 = (PRINTMONITOR_2 *)malloc(sizeof(PRINTMONITOR_2)); + (*returned) = 0x1; + + init_unistr(&(info_2->name), "Local Port"); + init_unistr(&(info_2->environment), "Windows NT X86"); + init_unistr(&(info_2->dll_name), "localmon.dll"); + + *needed += spoolss_size_printmonitor_info_2(info_2); + + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + smb_io_printmonitor_info_2("", buffer, info_2, 0); + + safe_free(info_2); + + if (*needed > offered) { + *returned=0; + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_enumprintmonitors(UNISTR2 *name,uint32 level, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed, uint32 *returned) { DEBUG(5,("spoolss_enumprintmonitors\n")); @@ -3340,16 +3737,20 @@ uint32 _spoolss_enumprintmonitors( const UNISTR2 *name, * and I can use my nice printer checker. */ - (*numofprintmonitors) = 0x1; - (*info_1) = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1)); - if ((*info_1) == NULL) - { - return NT_STATUS_NO_MEMORY; - } + *returned=0; + *needed=0; - init_unistr(&((*info_1)->name), "Local Port"); - - return 0x0; + switch (level) { + case 1: + return enumprintmonitors_level_1(buffer, offered, needed, returned); + break; + case 2: + return enumprintmonitors_level_2(buffer, offered, needed, returned); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + break; + } } /**************************************************************************** -- cgit From 0e004212d25ebee5db7b27e017ddb1015f4c2a7e Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 21 Feb 2000 01:58:13 +0000 Subject: more rewrite ... comitting before starting on new functions. J.F. (This used to be commit f9c20801114f72b587a6e8c3177cbab13dbdcc28) --- source3/rpc_server/srv_spoolss.c | 255 +++++++------- source3/rpc_server/srv_spoolss_nt.c | 655 +++++++++++++++++++++++------------- 2 files changed, 551 insertions(+), 359 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 50b6dd3846..4965542d73 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -42,17 +42,15 @@ static BOOL api_spoolss_open_printer_ex(uint16 vuid, prs_struct *data, prs_struc DEBUG(0,("spoolss_io_q_open_printer_ex: unable to unmarshall SPOOL_Q_OPEN_PRINTER_EX.\n")); return False; } - + if (q_u.printername_ptr != 0) - { printername = &q_u.printername; - } - + r_u.status = _spoolss_open_printer_ex( printername, &q_u.printer_default, q_u.user_switch, q_u.user_ctr, &r_u.handle); - + if (!spoolss_io_r_open_printer_ex("",&r_u,rdata,0)){ DEBUG(0,("spoolss_io_r_open_printer_ex: unable to marshall SPOOL_R_OPEN_PRINTER_EX.\n")); return False; @@ -88,9 +86,9 @@ static BOOL api_spoolss_getprinterdata(uint16 vuid, prs_struct *data, prs_struct DEBUG(0,("spoolss_io_r_getprinterdata: unable to marshall SPOOL_R_GETPRINTERDATA.\n")); return False; } - + safe_free(r_u.data); - + return True; } @@ -111,7 +109,7 @@ static BOOL api_spoolss_closeprinter(uint16 vuid, prs_struct *data, prs_struct * DEBUG(0,("spoolss_io_q_closeprinter: unable to unmarshall SPOOL_Q_CLOSEPRINTER.\n")); return False; } - + r_u.status = _spoolss_closeprinter(&q_u.handle); memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle)); @@ -119,6 +117,8 @@ static BOOL api_spoolss_closeprinter(uint16 vuid, prs_struct *data, prs_struct * DEBUG(0,("spoolss_io_r_closeprinter: unable to marshall SPOOL_R_CLOSEPRINTER.\n")); return False; } + + return True; } /******************************************************************** @@ -141,11 +141,13 @@ static BOOL api_spoolss_rffpcnex(uint16 vuid, prs_struct *data, prs_struct *rdat r_u.status = _spoolss_rffpcnex(&q_u.handle, q_u.flags, q_u.options, &q_u.localmachine, q_u.printerlocal, &q_u.option); - + if (!spoolss_io_r_rffpcnex("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_rffpcnex: unable to marshall SPOOL_R_RFFPCNEX.\n")); return False; } + + return True; } @@ -170,11 +172,13 @@ static BOOL api_spoolss_rfnpcnex(uint16 vuid, prs_struct *data, prs_struct *rdat r_u.status = _spoolss_rfnpcnex(&q_u.handle, q_u.change, &q_u.option, &r_u.count, &r_u.info); - + if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n")); return False; } + + return True; } @@ -191,8 +195,6 @@ static BOOL api_spoolss_enumprinters(uint16 vuid, prs_struct *data, prs_struct * ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - DEBUG(5,("api_spoolss_enumprinters\n")); - new_spoolss_allocate_buffer(&q_u.buffer); if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) { @@ -206,7 +208,7 @@ static BOOL api_spoolss_enumprinters(uint16 vuid, prs_struct *data, prs_struct * r_u.status = _spoolss_enumprinters( q_u.flags, &q_u.servername, q_u.level, r_u.buffer, q_u.offered, &r_u.needed, &r_u.returned); - + if (!new_spoolss_io_r_enumprinters("", &r_u, rdata, 0)) { DEBUG(0,("new_spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n")); new_spoolss_free_buffer(q_u.buffer); @@ -214,7 +216,7 @@ static BOOL api_spoolss_enumprinters(uint16 vuid, prs_struct *data, prs_struct * } new_spoolss_free_buffer(q_u.buffer); - + return True; } @@ -231,24 +233,27 @@ static BOOL api_spoolss_getprinter(uint16 vuid, prs_struct *data, prs_struct *rd ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); + new_spoolss_allocate_buffer(&q_u.buffer); + if(!spoolss_io_q_getprinter("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n")); return False; } - r_u.status = _spoolss_getprinter(&q_u.handle, q_u.level, - &r_u.ctr, &q_u.offered, &r_u.needed); + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - memcpy(&r_u.handle, &q_u.handle, sizeof(&r_u.handle)); - r_u.offered = q_u.offered; - r_u.level = q_u.level; - safe_free(q_u.buffer); + r_u.status = _spoolss_getprinter(&q_u.handle, q_u.level, + r_u.buffer, q_u.offered, + &r_u.needed); if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n")); + new_spoolss_free_buffer(q_u.buffer); return False; } - + + new_spoolss_free_buffer(q_u.buffer); return True; } @@ -265,26 +270,28 @@ static BOOL api_spoolss_getprinterdriver2(uint16 vuid, prs_struct *data, prs_str ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - + + new_spoolss_allocate_buffer(&q_u.buffer); + if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n")); return False; } - - r_u.status = _spoolss_getprinterdriver2(&q_u.handle, - &q_u.architecture, q_u.level, - &r_u.ctr, &q_u.buf_size, - &r_u.needed); - - r_u.offered = q_u.buf_size; - r_u.level = q_u.level; - spoolss_io_free_buffer(&(q_u.buffer)); + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); + + r_u.status = _spoolss_getprinterdriver2(&q_u.handle, &q_u.architecture, q_u.level, q_u.unknown, + r_u.buffer, q_u.offered, + &r_u.needed, &r_u.unknown0, &r_u.unknown1); + if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n")); + new_spoolss_free_buffer(q_u.buffer); return False; } + new_spoolss_free_buffer(q_u.buffer); return True; } @@ -300,20 +307,20 @@ static BOOL api_spoolss_startpageprinter(uint16 vuid, prs_struct *data, prs_stru ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - + if(!spoolss_io_q_startpageprinter("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_startpageprinter: unable to unmarshall SPOOL_Q_STARTPAGEPRINTER.\n")); return False; } - + r_u.status = _spoolss_startpageprinter(&q_u.handle); - + if(!spoolss_io_r_startpageprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_startpageprinter: unable to marshall SPOOL_R_STARTPAGEPRINTER.\n")); return False; } - - return True; + + return True; } @@ -329,58 +336,53 @@ static BOOL api_spoolss_endpageprinter(uint16 vuid, prs_struct *data, prs_struct ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - + if(!spoolss_io_q_endpageprinter("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_endpageprinter: unable to unmarshall SPOOL_Q_ENDPAGEPRINTER.\n")); return False; } - + r_u.status = _spoolss_endpageprinter(&q_u.handle); - + if(!spoolss_io_r_endpageprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_endpageprinter: unable to marshall SPOOL_R_ENDPAGEPRINTER.\n")); return False; } - + return True; } /******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ +********************************************************************/ static BOOL api_spoolss_startdocprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) { SPOOL_Q_STARTDOCPRINTER q_u; SPOOL_R_STARTDOCPRINTER r_u; - + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - + if(!spoolss_io_q_startdocprinter("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_startdocprinter: unable to unmarshall SPOOL_Q_STARTDOCPRINTER.\n")); return False; } - + r_u.status = _spoolss_startdocprinter(&q_u.handle, q_u.doc_info_container.level, &q_u.doc_info_container.docinfo, &r_u.jobid); - + if(!spoolss_io_r_startdocprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_startdocprinter: unable to marshall SPOOL_R_STARTDOCPRINTER.\n")); return False; } - + return True; } + /******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ +********************************************************************/ static BOOL api_spoolss_enddocprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENDDOCPRINTER q_u; @@ -388,28 +390,25 @@ static BOOL api_spoolss_enddocprinter(uint16 vuid, prs_struct *data, prs_struct ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - + if(!spoolss_io_q_enddocprinter("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enddocprinter: unable to unmarshall SPOOL_Q_ENDDOCPRINTER.\n")); return False; } - + r_u.status = _spoolss_enddocprinter(&q_u.handle); - + if(!spoolss_io_r_enddocprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_enddocprinter: unable to marshall SPOOL_R_ENDDOCPRINTER.\n")); return False; } - + return True; } /******************************************************************** - * api_spoolss_getprinter - * called from the spoolss dispatcher - * - ********************************************************************/ +********************************************************************/ static BOOL api_spoolss_writeprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) { SPOOL_Q_WRITEPRINTER q_u; @@ -417,19 +416,19 @@ static BOOL api_spoolss_writeprinter(uint16 vuid, prs_struct *data, prs_struct * ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - + if(!spoolss_io_q_writeprinter("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_writeprinter: unable to unmarshall SPOOL_Q_WRITEPRINTER.\n")); return False; } - + r_u.status = _spoolss_writeprinter(&q_u.handle, q_u.buffer_size, q_u.buffer, &q_u.buffer_size2); r_u.buffer_written = q_u.buffer_size2; safe_free(q_u.buffer); - + if(!spoolss_io_r_writeprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_writeprinter: unable to marshall SPOOL_R_WRITEPRINTER.\n")); return False; @@ -439,6 +438,9 @@ static BOOL api_spoolss_writeprinter(uint16 vuid, prs_struct *data, prs_struct * } /**************************************************************************** + +FIX ME: JFM: freeing memory ???? + ****************************************************************************/ static BOOL api_spoolss_setprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -483,9 +485,9 @@ static BOOL api_spoolss_fcpn(uint16 vuid, prs_struct *data, prs_struct *rdata) DEBUG(0,("spoolss_io_q_fcpn: unable to unmarshall SPOOL_Q_FCPN.\n")); return False; } - + r_u.status = _spoolss_fcpn(&q_u.handle); - + if(!spoolss_io_r_fcpn("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_fcpn: unable to marshall SPOOL_R_FCPN.\n")); return False; @@ -501,25 +503,30 @@ static BOOL api_spoolss_addjob(uint16 vuid, prs_struct *data, prs_struct *rdata) { SPOOL_Q_ADDJOB q_u; SPOOL_R_ADDJOB r_u; - + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - + + new_spoolss_allocate_buffer(&q_u.buffer); + if(!spoolss_io_q_addjob("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_addjob: unable to unmarshall SPOOL_Q_ADDJOB.\n")); return False; } + /* that's only an [in] buffer ! */ + r_u.status = _spoolss_addjob(&q_u.handle, q_u.level, - &q_u.buffer, q_u.buf_size); - - spoolss_io_free_buffer(&(q_u.buffer)); - + q_u.buffer, q_u.offered); + if(!spoolss_io_r_addjob("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_addjob: unable to marshall SPOOL_R_ADDJOB.\n")); + new_spoolss_free_buffer(q_u.buffer); return False; } + new_spoolss_free_buffer(q_u.buffer); + return True; } @@ -555,7 +562,7 @@ static BOOL api_spoolss_enumjobs(uint16 vuid, prs_struct *data, prs_struct *rdat } new_spoolss_free_buffer(q_u.buffer); - + return True; } @@ -566,22 +573,22 @@ static BOOL api_spoolss_schedulejob(uint16 vuid, prs_struct *data, prs_struct *r { SPOOL_Q_SCHEDULEJOB q_u; SPOOL_R_SCHEDULEJOB r_u; - + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - + if(!spoolss_io_q_schedulejob("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_schedulejob: unable to unmarshall SPOOL_Q_SCHEDULEJOB.\n")); return False; } - + r_u.status = _spoolss_schedulejob(&q_u.handle, q_u.jobid); - + if(!spoolss_io_r_schedulejob("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_schedulejob: unable to marshall SPOOL_R_SCHEDULEJOB.\n")); return False; } - + return True; } @@ -591,23 +598,23 @@ static BOOL api_spoolss_setjob(uint16 vuid, prs_struct *data, prs_struct *rdata) { SPOOL_Q_SETJOB q_u; SPOOL_R_SETJOB r_u; - + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - + if(!spoolss_io_q_setjob("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_setjob: unable to unmarshall SPOOL_Q_SETJOB.\n")); return False; } - + r_u.status = _spoolss_setjob(&q_u.handle, q_u.jobid, q_u.level, &q_u.ctr, q_u.command); - + if(!spoolss_io_r_setjob("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_setjob: unable to marshall SPOOL_R_SETJOB.\n")); return False; } - + return True; } @@ -618,7 +625,7 @@ static BOOL api_spoolss_enumprinterdrivers(uint16 vuid, prs_struct *data, prs_st { SPOOL_Q_ENUMPRINTERDRIVERS q_u; SPOOL_R_ENUMPRINTERDRIVERS r_u; - + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -643,7 +650,7 @@ static BOOL api_spoolss_enumprinterdrivers(uint16 vuid, prs_struct *data, prs_st } new_spoolss_free_buffer(q_u.buffer); - + return True; } @@ -654,7 +661,7 @@ static BOOL api_spoolss_enumforms(uint16 vuid, prs_struct *data, prs_struct *rda { SPOOL_Q_ENUMFORMS q_u; SPOOL_R_ENUMFORMS r_u; - + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -667,7 +674,7 @@ static BOOL api_spoolss_enumforms(uint16 vuid, prs_struct *data, prs_struct *rda /* that's an [in out] buffer */ new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - + r_u.status = _new_spoolss_enumforms(&q_u.handle, q_u.level, r_u.buffer, q_u.offered, &r_u.needed, &r_u.numofforms); @@ -677,9 +684,9 @@ static BOOL api_spoolss_enumforms(uint16 vuid, prs_struct *data, prs_struct *rda new_spoolss_free_buffer(q_u.buffer); return False; } - + new_spoolss_free_buffer(q_u.buffer); - + return True; } @@ -690,7 +697,7 @@ static BOOL api_spoolss_enumports(uint16 vuid, prs_struct *data, prs_struct *rda { SPOOL_Q_ENUMPORTS q_u; SPOOL_R_ENUMPORTS r_u; - + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -703,19 +710,19 @@ static BOOL api_spoolss_enumports(uint16 vuid, prs_struct *data, prs_struct *rda /* that's an [in out] buffer */ new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - + r_u.status = _spoolss_enumports(&q_u.name, q_u.level, r_u.buffer, q_u.offered, &r_u.needed, &r_u.returned); - + if (!new_spoolss_io_r_enumports("",&r_u,rdata,0)) { DEBUG(0,("new_spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n")); new_spoolss_free_buffer(q_u.buffer); return False; } - + new_spoolss_free_buffer(q_u.buffer); - + return True; } @@ -738,7 +745,7 @@ static BOOL api_spoolss_addprinterex(uint16 vuid, prs_struct *data, prs_struct * r_u.status = _spoolss_addprinterex(&q_u.server_name, q_u.level, &q_u.info, q_u.unk0, q_u.unk1, q_u.unk2, q_u.unk3, - q_u.user_level, &q_u.user, + q_u.user_switch, &q_u.user_ctr, &r_u.handle); if(!spoolss_io_r_addprinterex("", &r_u, rdata, 0)) { @@ -764,8 +771,7 @@ static BOOL api_spoolss_addprinterdriver(uint16 vuid, prs_struct *data, prs_stru return False; } - r_u.status = _spoolss_addprinterdriver(&q_u.server_name, - q_u.level, &q_u.info); + r_u.status = _spoolss_addprinterdriver(&q_u.server_name, q_u.level, &q_u.info); if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n")); @@ -781,26 +787,32 @@ static BOOL api_spoolss_getprinterdriverdirectory(uint16 vuid, prs_struct *data, { SPOOL_Q_GETPRINTERDRIVERDIR q_u; SPOOL_R_GETPRINTERDRIVERDIR r_u; - + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + new_spoolss_allocate_buffer(&q_u.buffer); + if(!spoolss_io_q_getprinterdriverdir("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n")); return False; } - - r_u.offered = q_u.buf_size; - r_u.level = q_u.level; - r_u.status = _spoolss_getprinterdriverdirectory(&q_u.name, - &q_u.environment, - q_u.level, - &r_u.ctr, - &r_u.offered); - spoolss_io_free_buffer(&q_u.buffer); - + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); + + r_u.status = _spoolss_getprinterdriverdirectory(&q_u.name, &q_u.environment, q_u.level, + r_u.buffer, q_u.offered, + &r_u.needed); + if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n")); + new_spoolss_free_buffer(q_u.buffer); return False; } - + + new_spoolss_free_buffer(q_u.buffer); + return True; } @@ -909,8 +921,7 @@ static BOOL api_spoolss_setform(uint16 vuid, prs_struct *data, prs_struct *rdata return False; } - r_u.status = _spoolss_setform(&q_u.handle, - &q_u.name, q_u.level, &q_u.form); + r_u.status = _spoolss_setform(&q_u.handle, &q_u.name, q_u.level, &q_u.form); if(!spoolss_io_r_setform("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_setform: unable to marshall SPOOL_R_SETFORM.\n")); @@ -997,27 +1008,27 @@ static BOOL api_spoolss_getjob(uint16 vuid, prs_struct *data, prs_struct *rdata) SPOOL_Q_GETJOB q_u; SPOOL_R_GETJOB r_u; + new_spoolss_allocate_buffer(&q_u.buffer); + if(!spoolss_io_q_getjob("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n")); return False; } - r_u.offered = q_u.buf_size; - r_u.level = q_u.level; - r_u.status = _spoolss_getjob(&q_u.handle, - q_u.jobid, - q_u.level, - &r_u.ctr, - &r_u.offered); - spoolss_io_free_buffer(&(q_u.buffer)); + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); + + r_u.status = _spoolss_getjob(&q_u.handle, q_u.jobid, q_u.level, + r_u.buffer, q_u.offered, + &r_u.needed); if(!spoolss_io_r_getjob("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n")); + new_spoolss_free_buffer(q_u.buffer); return False; } - - free_spoolss_r_getjob(&r_u); - + + new_spoolss_free_buffer(q_u.buffer); return True; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2e80cbdbf6..90a7b44aef 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -392,7 +392,6 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, uint32 user_switch, SPOOL_USER_CTR user_ctr, POLICY_HND *handle) { - BOOL printer_open = False; fstring name; fstring datatype; @@ -439,57 +438,41 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, return NT_STATUS_NO_PROBLEMO; } +/**************************************************************************** +****************************************************************************/ static BOOL convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni, - NT_PRINTER_INFO_LEVEL *printer, - uint32 level) + NT_PRINTER_INFO_LEVEL *printer, uint32 level) { - switch (level) - { + switch (level) { case 2: - { - uni_2_asc_printer_info_2(uni->info_2, - &(printer->info_2)); + uni_2_asc_printer_info_2(uni->info_2, &(printer->info_2)); break; - } default: break; } - - return True; } static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *uni, - NT_PRINTER_DRIVER_INFO_LEVEL *printer, - uint32 level) + NT_PRINTER_DRIVER_INFO_LEVEL *printer, uint32 level) { - switch (level) - { + switch (level) { case 3: - { printer->info_3=NULL; uni_2_asc_printer_driver_3(uni->info_3, &(printer->info_3)); break; - } default: break; } - - return True; } static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode) { - unistr_to_ascii(nt_devmode->devicename, - devmode.devicename.buffer, - 31); - - unistr_to_ascii(nt_devmode->formname, - devmode.formname.buffer, - 31); + unistr_to_ascii(nt_devmode->devicename, devmode.devicename.buffer, 31); + unistr_to_ascii(nt_devmode->formname, devmode.formname.buffer, 31); nt_devmode->specversion=devmode.specversion; nt_devmode->driverversion=devmode.driverversion; @@ -524,7 +507,7 @@ static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode) nt_devmode->reserved2=devmode.reserved2; nt_devmode->panningwidth=devmode.panningwidth; nt_devmode->panningheight=devmode.panningheight; - + if (nt_devmode->driverextra != 0) { /* if we had a previous private delete it and make a new one */ @@ -533,7 +516,6 @@ static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode) nt_devmode->private=(uint8 *)malloc(nt_devmode->driverextra * sizeof(uint8)); memcpy(nt_devmode->private, devmode.private, nt_devmode->driverextra); } - return True; } @@ -1948,65 +1930,121 @@ uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 le /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getprinter( POLICY_HND *handle, - uint32 level, - PRINTER_INFO *ctr, - uint32 *offered, - uint32 *needed) +static uint32 getprinter_level_0(pstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { - int snum; - pstring servername; + PRINTER_INFO_0 *printer=NULL; + + printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0)); + construct_printer_info_0(printer, snum, servername); - pstrcpy(servername, global_myname); + /* check the required size. */ + *needed += spoolss_size_printer_info_0(printer); - if (!get_printer_snum(handle,&snum)) - { - return NT_STATUS_INVALID_HANDLE; + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + /* fill the buffer with the structures */ + new_smb_io_printer_info_0("", buffer, printer, 0); + + /* clear memory */ + safe_free(printer); + + if (*needed > offered) { + return ERROR_INSUFFICIENT_BUFFER; } + else + return NT_STATUS_NO_PROBLEMO; +} - DEBUG(0,("_spoolss_getprinter: offered and needed params ignored\n")); +/**************************************************************************** +****************************************************************************/ +static uint32 getprinter_level_1(pstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + PRINTER_INFO_1 *printer=NULL; - switch (level) - { - case 0: - { - PRINTER_INFO_0 *printer; - - printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0)); - construct_printer_info_0(printer, snum, servername); - ctr->printer.info0=printer; - - return 0x0; - } - case 1: - { - PRINTER_INFO_1 *printer; - - printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1)); - construct_printer_info_1(printer, snum, servername); - ctr->printer.info1=printer; + printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1)); + construct_printer_info_1(printer, snum, servername); + + /* check the required size. */ + *needed += spoolss_size_printer_info_1(printer); - return 0x0; - } - case 2: - { - PRINTER_INFO_2 *printer; - - printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)); - construct_printer_info_2(printer, snum, servername); - ctr->printer.info2=printer; + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; - return 0x0; - } - default: - { - break; - } + /* fill the buffer with the structures */ + new_smb_io_printer_info_1("", buffer, printer, 0); + + /* clear memory */ + safe_free(printer); + + if (*needed > offered) { + return ERROR_INSUFFICIENT_BUFFER; } + else + return NT_STATUS_NO_PROBLEMO; +} - return NT_STATUS_INVALID_INFO_CLASS; +/**************************************************************************** +****************************************************************************/ +static uint32 getprinter_level_2(pstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + PRINTER_INFO_2 *printer=NULL; + + printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)); + construct_printer_info_2(printer, snum, servername); + + /* check the required size. */ + *needed += spoolss_size_printer_info_2(printer); + + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + /* fill the buffer with the structures */ + new_smb_io_printer_info_2("", buffer, printer, 0); + + /* clear memory */ + safe_free(printer); + + if (*needed > offered) { + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; } +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, + NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + int snum; + pstring servername; + + *needed=0; + + pstrcpy(servername, global_myname); + + if (!get_printer_snum(handle, &snum)) + { + return NT_STATUS_INVALID_HANDLE; + } + + switch (level) { + case 0: + return getprinter_level_0(servername, snum, buffer, offered, needed); + break; + case 1: + return getprinter_level_1(servername,snum, buffer, offered, needed); + break; + case 2: + return getprinter_level_2(servername,snum, buffer, offered, needed); + break; + default: + return NT_STATUS_INVALID_LEVEL; + break; + } +} + /******************************************************************** * construct_printer_driver_info_1 * fill a construct_printer_driver_info_1 struct @@ -2187,63 +2225,129 @@ static void construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getprinterdriver2( const POLICY_HND *handle, - const UNISTR2 *uni_arch, - uint32 level, - DRIVER_INFO *ctr, - uint32 *offered, - uint32 *needed) +static uint32 getprinterdriver2_level1(pstring servername, pstring architecture, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + DRIVER_INFO_1 *info=NULL; + + info=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1)); + + construct_printer_driver_info_1(info, snum, servername, architecture); + + /* check the required size. */ + *needed += spoolss_size_printer_driver_info_1(info); + + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + /* fill the buffer with the structures */ + new_smb_io_printer_driver_info_1("", buffer, info, 0); + + /* clear memory */ + safe_free(info); + + if (*needed > offered) { + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; +} + +/**************************************************************************** +****************************************************************************/ +static uint32 getprinterdriver2_level2(pstring servername, pstring architecture, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + DRIVER_INFO_2 *info=NULL; + + info=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2)); + + construct_printer_driver_info_2(info, snum, servername, architecture); + + /* check the required size. */ + *needed += spoolss_size_printer_driver_info_2(info); + + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + /* fill the buffer with the structures */ + new_smb_io_printer_driver_info_2("", buffer, info, 0); + + /* clear memory */ + safe_free(info); + + if (*needed > offered) { + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; +} + +/**************************************************************************** +****************************************************************************/ +static uint32 getprinterdriver2_level3(pstring servername, pstring architecture, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + DRIVER_INFO_3 *info=NULL; + + info=(DRIVER_INFO_3 *)malloc(sizeof(DRIVER_INFO_3)); + + construct_printer_driver_info_3(info, snum, servername, architecture); + + /* check the required size. */ + *needed += spoolss_size_printer_driver_info_3(info); + + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + /* fill the buffer with the structures */ + new_smb_io_printer_driver_info_3("", buffer, info, 0); + + /* clear memory */ + safe_free(info); + + if (*needed > offered) { + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level, uint32 unknown, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed, uint32 *unknown0, uint32 *unknown1) { pstring servername; fstring architecture; int snum; - DRIVER_INFO_1 *info1=NULL; - DRIVER_INFO_2 *info2=NULL; - DRIVER_INFO_3 *info3=NULL; + + DEBUG(4,("_spoolss_getprinterdriver2\n")); + + *needed=0; + *unknown0=0; + *unknown1=0; pstrcpy(servername, global_myname); + unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); - if (!get_printer_snum(handle,&snum)) + if (!get_printer_snum(handle, &snum)) { return NT_STATUS_INVALID_HANDLE; } - unistr2_to_ascii(architecture, uni_arch, sizeof(architecture) ); - - DEBUG(1,("spoolss_getprinterdriver2:[%d]\n", level)); - - switch (level) - { - case 1: - { - info1=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1)); - construct_printer_driver_info_1(info1, snum, servername, architecture); - ctr->driver.info1=info1; - - return 0x0; - } - case 2: - { - info2=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2)); - construct_printer_driver_info_2(info2, snum, servername, architecture); - ctr->driver.info2=info2; - - return 0x0; - } - case 3: - { - info3=(DRIVER_INFO_3 *)malloc(sizeof(DRIVER_INFO_3)); - construct_printer_driver_info_3(info3, snum, servername, architecture); - ctr->driver.info3=info3; - - return 0x0; - } - default: - { - break; - } + switch (level) { + case 1: + return getprinterdriver2_level1(servername, architecture, snum, buffer, offered, needed); + break; + case 2: + return getprinterdriver2_level2(servername, architecture, snum, buffer, offered, needed); + break; + case 3: + return getprinterdriver2_level3(servername, architecture, snum, buffer, offered, needed); + break; + default: + return NT_STATUS_INVALID_LEVEL; + break; } - return NT_STATUS_INVALID_INFO_CLASS; } /**************************************************************************** @@ -2617,10 +2721,9 @@ uint32 _spoolss_fcpn( const POLICY_HND *handle) /**************************************************************************** ****************************************************************************/ uint32 _spoolss_addjob( const POLICY_HND *handle, uint32 level, - const BUFFER *buffer, - uint32 buf_size) + NEW_BUFFER *buffer, uint32 offered) { - return 0x0; + return NT_STATUS_NO_PROBLEMO; } /**************************************************************************** @@ -3273,7 +3376,7 @@ uint32 _spoolss_enumports( UNISTR2 *name, uint32 level, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - DEBUG(4,("spoolss_enumports\n")); + DEBUG(4,("_spoolss_enumports\n")); *returned=0; *needed=0; @@ -3293,30 +3396,23 @@ uint32 _spoolss_enumports( UNISTR2 *name, uint32 level, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, - uint32 level, +uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, - uint32 unk0, - uint32 unk1, - uint32 unk2, - uint32 unk3, - uint32 user_level, - const SPOOL_USER_LEVEL *user, + uint32 unk0, uint32 unk1, uint32 unk2, uint32 unk3, + uint32 user_switch, const SPOOL_USER_CTR *user, POLICY_HND *handle) { NT_PRINTER_INFO_LEVEL printer; - fstring ascii_name; - fstring server_name; + fstring name; fstring share_name; - UNISTR2 *portname; - SPOOL_PRINTER_INFO_LEVEL_2 *info2; - uint32 status = 0x0; - - if (!open_printer_hnd(handle)) - { - return NT_STATUS_ACCESS_DENIED; - } + clear_handle(handle); + +/* + * FIX: JFM: we need to check the user here !!!! + * + * as the code is running as root, anybody can add printers to the server + */ /* NULLify info_2 here */ /* don't put it in convert_printer_info as it's used also with non-NULL values */ printer.info_2=NULL; @@ -3324,31 +3420,31 @@ uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, /* convert from UNICODE to ASCII */ convert_printer_info(info, &printer, level); - /* write the ASCII on disk */ - status = add_a_printer(printer, level); - if (status != 0x0) - { - close_printer_handle(handle); - return status; - } + unistr2_to_ascii(share_name, &((info->info_2)->portname), sizeof(share_name)-1); + + slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname, share_name); + + create_printer_hnd(handle); - info2=info->info_2; - portname=&(info2->portname); + open_printer_hnd(handle); - StrnCpy(server_name, global_myname, strlen(global_myname) ); - unistr2_to_ascii(share_name, portname, sizeof(share_name)-1); + if (!set_printer_hnd_printertype(handle, name)) { + close_printer_handle(handle); + return NT_STATUS_ACCESS_DENIED; + } - slprintf(ascii_name, sizeof(ascii_name)-1, "\\\\%s\\%s", - server_name, share_name); - - if (!set_printer_hnd_printertype(handle, ascii_name) || - !set_printer_hnd_printername(handle, ascii_name)) - { + if (!set_printer_hnd_printername(handle, name)) { close_printer_handle(handle); return NT_STATUS_ACCESS_DENIED; } - return 0x0; + /* write the ASCII on disk */ + if (add_a_printer(printer, level) != 0x0) { + close_printer_handle(handle); + return NT_STATUS_ACCESS_DENIED; + } + + return NT_STATUS_NO_PROBLEMO; } /**************************************************************************** @@ -3358,35 +3454,77 @@ uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name, const SPOOL_PRINTER_DRIVER_INFO_LEVEL *info) { NT_PRINTER_DRIVER_INFO_LEVEL driver; + convert_printer_driver_info(info, &driver, level); - return add_a_printer_driver(driver, level); + + if (add_a_printer_driver(driver, level)!=0) + return NT_STATUS_ACCESS_DENIED; + + return NT_STATUS_NO_PROBLEMO; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getprinterdriverdirectory( const UNISTR2 *name, - const UNISTR2 *uni_environment, - uint32 level, - DRIVER_DIRECTORY_CTR *ctr, - uint32 *offered) +static void fill_driverdir_1(DRIVER_DIRECTORY_1 *info, char *name) +{ + init_unistr(&(info->name), name); +} + +/**************************************************************************** +****************************************************************************/ +static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environment, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { pstring chaine; pstring long_archi; - pstring archi; - + pstring short_archi; + DRIVER_DIRECTORY_1 *info=NULL; + + info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1)); + unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); - get_short_archi(archi, long_archi); + get_short_archi(short_archi, long_archi); - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\print$\\%s", - global_myname, archi); + slprintf(chaine, sizeof(chaine)-1, "\\\\%s\\print$\\%s", global_myname, short_archi); DEBUG(4,("printer driver directory: [%s]\n", chaine)); - - init_unistr(&(ctr->driver.info_1.name), chaine); - return 0x0; + fill_driverdir_1(info, chaine); + + *needed += spoolss_size_driverdir_info_1(info); + + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + new_smb_io_driverdir_1("", buffer, info, 0); + + safe_free(info); + + if (*needed > offered) + return ERROR_INSUFFICIENT_BUFFER; + else + return NT_STATUS_NO_PROBLEMO; } +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_getprinterdriverdirectory(UNISTR2 *name, UNISTR2 *uni_environment, uint32 level, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed) +{ + DEBUG(4,("_spoolss_getprinterdriverdirectory\n")); + + *needed=0; + + switch(level) { + case 1: + return getprinterdriverdir_level_1(name, uni_environment, buffer, offered, needed); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + break; + } +} + /**************************************************************************** ****************************************************************************/ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, @@ -3755,84 +3893,127 @@ uint32 _spoolss_enumprintmonitors(UNISTR2 *name,uint32 level, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getjob( const POLICY_HND *handle, - uint32 jobid, - uint32 level, - PJOB_INFO *ctr, - uint32 *offered) +static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + int i=0; + BOOL found=False; + JOB_INFO_1 *info_1=NULL; + info_1=(JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1)); + + if (info_1 == NULL) { + safe_free(queue); + return NT_STATUS_NO_MEMORY; + } + + for (i=0; i offered) + return ERROR_INSUFFICIENT_BUFFER; + else + return NT_STATUS_NO_PROBLEMO; +} + + +/**************************************************************************** +****************************************************************************/ +static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + int i=0; + BOOL found=False; + JOB_INFO_2 *info_2=NULL; + info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2)); + + if (info_2 == NULL) { + safe_free(queue); + return NT_STATUS_NO_MEMORY; + } + + for (i=0; i offered) + return ERROR_INSUFFICIENT_BUFFER; + else + return NT_STATUS_NO_PROBLEMO; +} + +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_getjob( POLICY_HND *handle, uint32 jobid, uint32 level, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed) { int snum; int count; - int i; print_queue_struct *queue=NULL; print_status_struct prt_status; - DEBUG(4,("spoolss_getjob\n")); + DEBUG(5,("spoolss_getjob\n")); - bzero(&prt_status,sizeof(prt_status)); + bzero(&prt_status, sizeof(prt_status)); + *needed=0; + if (!get_printer_snum(handle, &snum)) { return NT_STATUS_INVALID_HANDLE; } + count=get_printqueue(snum, NULL, &queue, &prt_status); DEBUGADD(4,("count:[%d], prt_status:[%d], [%s]\n", count, prt_status.status, prt_status.message)); - - switch (level) - { - case 1: - { - JOB_INFO_1 *job_info_1=NULL; - job_info_1=(JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1)); - - if (job_info_1 == NULL) - { - safe_free(queue); - return NT_STATUS_NO_MEMORY; - } - - for (i=0; ijob.job_info_1=job_info_1; - break; - } - case 2: - { - JOB_INFO_2 *job_info_2=NULL; - job_info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2)); - - if (job_info_2 == NULL) - { - safe_free(queue); - return NT_STATUS_NO_MEMORY; - } - - for (i=0; ijob.job_info_2=job_info_2; - break; - } - default: - { - safe_free(queue); - return NT_STATUS_INVALID_INFO_CLASS; - } + + switch (level) { + case 1: + return getjob_level_1(queue, count, snum, jobid, buffer, offered, needed); + break; + case 2: + return getjob_level_1(queue, count, snum, jobid, buffer, offered, needed); + break; + default: + safe_free(queue); + return NT_STATUS_INVALID_INFO_CLASS; + break; } - - safe_free(queue); - return 0x0; } + -- cgit From 9db96b7646aa36aa5b4ff309419235fe20bef78a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 23 Feb 2000 02:02:33 +0000 Subject: lib/system.c: Fixed gcc warnings. nmbd/nmbd_processlogon.c: Use "True" and "False" instead of 1 and 0. Others - preparing for multiple pdu write code. Jeremy. (This used to be commit 9f879ec396230deba34fbe5e82d8a65f92137c54) --- source3/rpc_server/srv_pipe_hnd.c | 46 +++++++++++++++++++-------------------- source3/rpc_server/srv_pipe_srv.c | 40 +++++++++++++++++----------------- 2 files changed, 43 insertions(+), 43 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index b8e7c1946a..32a804d5d5 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -78,27 +78,27 @@ void init_rpc_pipe_hnd(void) Initialise an outgoing packet. ****************************************************************************/ -BOOL pipe_init_outgoing_data( pipes_struct *p) +BOOL pipe_init_outgoing_data(output_data *out_data) { - memset(p->current_pdu, '\0', sizeof(p->current_pdu)); + memset(out_data->current_pdu, '\0', sizeof(out_data->current_pdu)); /* Free any memory in the current return data buffer. */ - prs_mem_free(&p->rdata); + prs_mem_free(&out_data->rdata); /* * Initialize the outgoing RPC data buffer. * we will use this as the raw data area for replying to rpc requests. */ - if(!prs_init(&p->rdata, 1024, 4, MARSHALL)) { + if(!prs_init(&out_data->rdata, 1024, 4, MARSHALL)) { DEBUG(0,("pipe_init_outgoing_data: malloc fail.\n")); return False; } /* Reset the offset counters. */ - p->data_sent_length = 0; - p->current_pdu_len = 0; - p->current_pdu_sent = 0; + out_data->data_sent_length = 0; + out_data->current_pdu_len = 0; + out_data->current_pdu_sent = 0; return True; } @@ -188,7 +188,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, /* * Initialize the RPC and PDU data buffers with no memory. */ - prs_init(&p->rdata, 0, 4, MARSHALL); + prs_init(&p->out_data.rdata, 0, 4, MARSHALL); DLIST_ADD(Pipes, p); @@ -213,9 +213,9 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->ntlmssp_auth_validated = False; p->ntlmssp_auth_requested = False; - p->current_pdu_len = 0; - p->current_pdu_sent = 0; - p->data_sent_length = 0; + p->out_data.current_pdu_len = 0; + p->out_data.current_pdu_sent = 0; + p->out_data.data_sent_length = 0; p->uid = (uid_t)-1; p->gid = (gid_t)-1; @@ -303,15 +303,15 @@ only service %d sized reads.\n", n, p->name, MAX_PDU_FRAG_LEN )); * PDU. */ - if((pdu_remaining = p->current_pdu_len - p->current_pdu_sent) > 0) { + if((pdu_remaining = p->out_data.current_pdu_len - p->out_data.current_pdu_sent) > 0) { data_returned = MIN(n, pdu_remaining); DEBUG(10,("read_from_pipe: %s: current_pdu_len = %u, current_pdu_sent = %u \ -returning %d bytes.\n", p->name, (unsigned int)p->current_pdu_len, - (unsigned int)p->current_pdu_sent, (int)data_returned)); +returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, + (unsigned int)p->out_data.current_pdu_sent, (int)data_returned)); - memcpy( data, &p->current_pdu[p->current_pdu_sent], (size_t)data_returned); - p->current_pdu_sent += (uint32)data_returned; + memcpy( data, &p->out_data.current_pdu[p->out_data.current_pdu_sent], (size_t)data_returned); + p->out_data.current_pdu_sent += (uint32)data_returned; return data_returned; } @@ -320,10 +320,10 @@ returning %d bytes.\n", p->name, (unsigned int)p->current_pdu_len, * may of course be zero if this is the first return fragment. */ - DEBUG(10,("read_from_pipe: %s: data_sent_length = %u, prs_offset(&p->rdata) = %u.\n", - p->name, (unsigned int)p->data_sent_length, (unsigned int)prs_offset(&p->rdata) )); + DEBUG(10,("read_from_pipe: %s: data_sent_length = %u, prs_offset(&p->out_data.rdata) = %u.\n", + p->name, (unsigned int)p->out_data.data_sent_length, (unsigned int)prs_offset(&p->out_data.rdata) )); - if(p->data_sent_length >= prs_offset(&p->rdata)) { + if(p->out_data.data_sent_length >= prs_offset(&p->out_data.rdata)) { /* * We have sent all possible data. Return 0. */ @@ -343,10 +343,10 @@ returning %d bytes.\n", p->name, (unsigned int)p->current_pdu_len, return -1; } - data_returned = MIN(n, p->current_pdu_len); + data_returned = MIN(n, p->out_data.current_pdu_len); - memcpy( data, p->current_pdu, (size_t)data_returned); - p->current_pdu_sent += (uint32)data_returned; + memcpy( data, p->out_data.current_pdu, (size_t)data_returned); + p->out_data.current_pdu_sent += (uint32)data_returned; return data_returned; } @@ -409,7 +409,7 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) return False; } - prs_mem_free(&p->rdata); + prs_mem_free(&p->out_data.rdata); bitmap_clear(bmap, p->pnum - pipe_handle_offset); diff --git a/source3/rpc_server/srv_pipe_srv.c b/source3/rpc_server/srv_pipe_srv.c index 6e8b306760..86cc9e47e6 100644 --- a/source3/rpc_server/srv_pipe_srv.c +++ b/source3/rpc_server/srv_pipe_srv.c @@ -94,7 +94,7 @@ BOOL create_next_pdu(pipes_struct *p) p->hdr.pkt_type = RPC_RESPONSE; /* Set up rpc header flags. */ - if (p->data_sent_length == 0) + if (p->out_data.data_sent_length == 0) p->hdr.flags = RPC_FLG_FIRST; else p->hdr.flags = 0; @@ -103,7 +103,7 @@ BOOL create_next_pdu(pipes_struct *p) * Work out how much we can fit in a sigle PDU. */ - data_space_available = sizeof(p->current_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN; + data_space_available = sizeof(p->out_data.current_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN; if(p->ntlmssp_auth_validated) data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN); @@ -112,7 +112,7 @@ BOOL create_next_pdu(pipes_struct *p) * space and the amount left to send. */ - data_len_left = prs_offset(&p->rdata) - p->data_sent_length; + data_len_left = prs_offset(&p->out_data.rdata) - p->out_data.data_sent_length; /* * Ensure there really is data left to send. @@ -149,7 +149,7 @@ BOOL create_next_pdu(pipes_struct *p) * Work out if this PDU will be the last. */ - if(p->data_sent_length + data_len >= prs_offset(&p->rdata)) + if(p->out_data.data_sent_length + data_len >= prs_offset(&p->out_data.rdata)) p->hdr.flags |= RPC_FLG_LAST; /* @@ -158,7 +158,7 @@ BOOL create_next_pdu(pipes_struct *p) */ prs_init( &outgoing_pdu, 0, 4, MARSHALL); - prs_give_memory( &outgoing_pdu, (char *)p->current_pdu, sizeof(p->current_pdu), False); + prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* Store the header in the data stream. */ if(!smb_io_rpc_hdr("hdr", &p->hdr, &outgoing_pdu, 0)) { @@ -175,7 +175,7 @@ BOOL create_next_pdu(pipes_struct *p) data_pos = prs_offset(&outgoing_pdu); /* Copy the data into the PDU. */ - data_from = prs_data_p(&p->rdata) + p->data_sent_length; + data_from = prs_data_p(&p->out_data.rdata) + p->out_data.data_sent_length; if(!prs_append_data(&outgoing_pdu, data_from, data_len)) { DEBUG(0,("create_next_pdu: failed to copy %u bytes of data.\n", (unsigned int)data_len)); @@ -230,9 +230,9 @@ BOOL create_next_pdu(pipes_struct *p) * Setup the counts for this PDU. */ - p->data_sent_length += data_len; - p->current_pdu_len = p->hdr.frag_len; - p->current_pdu_sent = 0; + p->out_data.data_sent_length += data_len; + p->out_data.current_pdu_len = p->hdr.frag_len; + p->out_data.current_pdu_sent = 0; return True; } @@ -549,7 +549,7 @@ static BOOL setup_bind_nak(pipes_struct *p, prs_struct *pd) */ prs_init( &outgoing_rpc, 0, 4, MARSHALL); - prs_give_memory( &outgoing_rpc, (char *)p->current_pdu, sizeof(p->current_pdu), False); + prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* @@ -575,9 +575,9 @@ static BOOL setup_bind_nak(pipes_struct *p, prs_struct *pd) if(!prs_uint16("reject code", &outgoing_rpc, 0, &zero)) return False; - p->data_sent_length = 0; - p->current_pdu_len = prs_offset(&outgoing_rpc); - p->current_pdu_sent = 0; + p->out_data.data_sent_length = 0; + p->out_data.current_pdu_len = prs_offset(&outgoing_rpc); + p->out_data.current_pdu_sent = 0; return True; } @@ -710,7 +710,7 @@ static BOOL api_pipe_bind_and_alt_req(pipes_struct *p, prs_struct *pd, enum RPC_ */ prs_init( &outgoing_rpc, 0, 4, MARSHALL); - prs_give_memory( &outgoing_rpc, (char *)p->current_pdu, sizeof(p->current_pdu), False); + prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* * Setup the memory to marshall the ba header, and the @@ -828,9 +828,9 @@ static BOOL api_pipe_bind_and_alt_req(pipes_struct *p, prs_struct *pd, enum RPC_ * Setup the lengths for the initial reply. */ - p->data_sent_length = 0; - p->current_pdu_len = prs_offset(&outgoing_rpc); - p->current_pdu_sent = 0; + p->out_data.data_sent_length = 0; + p->out_data.current_pdu_len = prs_offset(&outgoing_rpc); + p->out_data.current_pdu_sent = 0; prs_mem_free(&out_hdr_ba); prs_mem_free(&out_auth); @@ -1038,7 +1038,7 @@ BOOL rpc_command(pipes_struct *p, char *input_data, int data_len) * Create the response data buffer. */ - if(!pipe_init_outgoing_data(p)) { + if(!pipe_init_outgoing_data(&p->out_data)) { DEBUG(0,("rpc_command: failed to unmarshall RPC_HDR.\n")); return False; } @@ -1104,9 +1104,9 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds } /* do the actual command */ - if(!api_rpc_cmds[fn_num].fn(p->vuid, rpc_in, &p->rdata)) { + if(!api_rpc_cmds[fn_num].fn(p->vuid, rpc_in, &p->out_data.rdata)) { DEBUG(0,("api_rpcTNP: %s: failed.\n", rpc_name)); - prs_mem_free(&p->rdata); + prs_mem_free(&p->out_data.rdata); return False; } -- cgit From f3319f7963e04a9642d604e706a10df3cd96dd73 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Thu, 24 Feb 2000 16:27:06 +0000 Subject: converted a couple of bzero() to memset() rewrote the printer notify code, so now it's compatible with SP5 and fully dynamic. No more limits on printers and job lists. removed the make_xxx() functions as they are not used and broken fixed a bug in the open handle function. J.F. (This used to be commit aa9054d14bc940f251639ab897d9f356814f5fc0) --- source3/rpc_server/srv_spoolss.c | 11 +- source3/rpc_server/srv_spoolss_nt.c | 469 ++++++++++++++++++++---------------- 2 files changed, 274 insertions(+), 206 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 4965542d73..be6775f35d 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -140,9 +140,9 @@ static BOOL api_spoolss_rffpcnex(uint16 vuid, prs_struct *data, prs_struct *rdat r_u.status = _spoolss_rffpcnex(&q_u.handle, q_u.flags, q_u.options, &q_u.localmachine, - q_u.printerlocal, &q_u.option); + q_u.printerlocal, q_u.option); - if (!spoolss_io_r_rffpcnex("",&r_u,rdata,0)) { + if (!spoolss_io_r_rffpcnex("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_rffpcnex: unable to marshall SPOOL_R_RFFPCNEX.\n")); return False; } @@ -171,13 +171,18 @@ static BOOL api_spoolss_rfnpcnex(uint16 vuid, prs_struct *data, prs_struct *rdat } r_u.status = _spoolss_rfnpcnex(&q_u.handle, q_u.change, - &q_u.option, &r_u.count, &r_u.info); + q_u.option, &r_u.info); + + /* we always have a NOTIFY_INFO struct */ + r_u.info_ptr=0x1; if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n")); return False; } + safe_free(r_u.info.data); + return True; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 90a7b44aef..cd0d0a8ab1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -39,28 +39,31 @@ extern pstring global_myname; /* and a reference to what it's pointing to */ /* and the notify info asked about */ /* that's the central struct */ -static struct -{ - BOOL open; - BOOL ok; - BOOL document_started; - BOOL page_started; - uint32 current_jobid; - uint32 document_fd; - uint32 document_lastwritten; - pstring document_name; - pstring job_name; - POLICY_HND printer_hnd; - BOOL printer_type; - union - { - fstring printername; - fstring printerservername; - } dev; - uint32 type; - uint32 access; - uint32 number_of_notify; - SPOOL_NOTIFY_OPTION_TYPE notify_info[MAX_PRINTER_NOTIFY+MAX_JOB_NOTIFY]; +static struct { + BOOL open; + BOOL ok; + BOOL document_started; + BOOL page_started; + uint32 current_jobid; + uint32 document_fd; + uint32 document_lastwritten; + pstring document_name; + pstring job_name; + POLICY_HND printer_hnd; + BOOL printer_type; + union { + fstring printername; + fstring printerservername; + } dev; + uint32 type; + uint32 access; + struct { + uint32 flags; + uint32 options; + fstring localmachine; + uint32 printerlocal; + SPOOL_NOTIFY_OPTION *option; + } notify; } Printer[MAX_OPEN_PRINTER_EXS]; #define VALID_HANDLE(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PRINTER_EXS)) @@ -110,13 +113,13 @@ static int find_printer_index_by_hnd(const POLICY_HND *hnd) { if (memcmp(&(Printer[i].printer_hnd), hnd, sizeof(*hnd)) == 0) { - DEBUG(4,("Found printer handle[%x] ", i)); - dump_data(4, hnd->data, sizeof(hnd->data)); + DEBUG(4,("Found printer handle[%x] \n", i)); + /*dump_data(4, hnd->data, sizeof(hnd->data));*/ return i; } } DEBUG(3,("Whoops, Printer handle not found: ")); - dump_data(4, hnd->data, sizeof(hnd->data)); + /*dump_data(4, hnd->data, sizeof(hnd->data));*/ return -1; } @@ -125,7 +128,7 @@ static int find_printer_index_by_hnd(const POLICY_HND *hnd) ****************************************************************************/ static void clear_handle(POLICY_HND *hnd) { - bzero(hnd->data, POLICY_HND_SIZE); + memset(hnd->data, 0, POLICY_HND_SIZE); } /**************************************************************************** @@ -142,6 +145,13 @@ static BOOL close_printer_handle(POLICY_HND *hnd) } Printer[pnum].open=False; + Printer[pnum].notify.flags=0; + Printer[pnum].notify.options=0; + Printer[pnum].notify.localmachine[0]='\0'; + Printer[pnum].notify.printerlocal=0; + safe_free(Printer[pnum].notify.option); + Printer[pnum].notify.option=NULL; + clear_handle(hnd); return True; @@ -204,6 +214,7 @@ static BOOL open_printer_hnd(POLICY_HND *hnd) memcpy(&(Printer[i].printer_hnd), hnd, sizeof(*hnd)); DEBUG(4,("Opened printer handle[%x] ", i)); dump_data(4, hnd->data, sizeof(hnd->data)); + Printer[i].notify.option=NULL; return True; } } @@ -334,6 +345,7 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) return False; } + snum--; DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); ZERO_STRUCT(Printer[pnum].dev.printername); strncpy(Printer[pnum].dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); @@ -635,7 +647,7 @@ static BOOL getprinterdata_printer(const POLICY_HND *handle, if (get_specific_param(printer, 2, value, &idata, type, &len)) { *data = (uint8 *)malloc( (len>in_size)?len:in_size *sizeof(uint8) ); - bzero(*data, sizeof(uint8)*len); + memset(*data, 0, sizeof(uint8)*len); memcpy(*data, idata, (len>in_size)?len:in_size); *needed = len; @@ -713,42 +725,26 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, * in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe * called from api_spoolss_rffpcnex ********************************************************************/ -uint32 _spoolss_rffpcnex(const POLICY_HND *handle, - uint32 flags, uint32 options, - const UNISTR2 *localmachine, - uint32 printerlocal, - SPOOL_NOTIFY_OPTION *option) +uint32 _spoolss_rffpcnex(const POLICY_HND *handle, uint32 flags, uint32 options, + const UNISTR2 *localmachine, uint32 printerlocal, + SPOOL_NOTIFY_OPTION *option) { - int i,j,k; + int i; /* store the notify value in the printer struct */ i=find_printer_index_by_hnd(handle); if (i == -1) - { return NT_STATUS_INVALID_HANDLE; - } - - Printer[i].number_of_notify=option->count; - DEBUG(3,("Copying %x notify option info\n",Printer[i].number_of_notify)); + Printer[i].notify.flags=flags; + Printer[i].notify.options=options; + Printer[i].notify.printerlocal=printerlocal; + Printer[i].notify.option=option; + unistr2_to_ascii(Printer[i].notify.localmachine, localmachine, sizeof(Printer[i].notify.localmachine)-1); - for (j=0;jtype[j].count; - Printer[i].notify_info[j].type=option->type[j].type ; - - DEBUG(4,("Copying %x info fields of type %x\n", - Printer[i].notify_info[j].count, - Printer[i].notify_info[j].type)); - for(k=0;ktype[j].fields[k]; - } - } - - return 0x0; + return NT_STATUS_NO_PROBLEMO; } /******************************************************************* @@ -961,7 +957,7 @@ static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_ print_queue_struct *q=NULL; print_status_struct status; - bzero(&status,sizeof(status)); + memset(&status, 0, sizeof(status)); count=get_printqueue(snum, NULL, &q, &status); @@ -977,7 +973,7 @@ static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_q print_queue_struct *q=NULL; print_status_struct status; - bzero(&status,sizeof(status)); + memset(&status, 0, sizeof(status)); data->notify_data.value[0]=get_printqueue(snum, NULL, &q, &status); if (q) free(q); @@ -1163,40 +1159,30 @@ static int search_notify(uint16 type, uint16 field, int *value) int j; BOOL found; - DEBUG(4,("\tsearch_notify: in\n")); for (j=0, found=False; found==False && notify_info_data_table[j].type != END ; j++) { if ( (notify_info_data_table[j].type == type ) && (notify_info_data_table[j].field == field ) ) - { found=True; - } } *value=--j; if ( found && (notify_info_data_table[j].fn != NULL) ) - { - DEBUG(4,("\tsearch_notify: out TRUE\n")); - return (True); - } + return True; else - { - DEBUG(4,("\tsearch_notify: out FALSE\n")); - return (False); - } + return False; } /**************************************************************************** ****************************************************************************/ static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 field, int id) { - DEBUG(4,("\tconstruct_info_data: in\n")); info_data->type = type; info_data->field = field; + info_data->reserved = 0; info_data->id = id; info_data->size = size_of_notify_info_data(type, field); info_data->enc_type = type_of_notify_info_data(type, field); - DEBUG(4,("\tconstruct_info_data: out\n")); } @@ -1205,49 +1191,48 @@ static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, * fill a notify_info struct with info asked * ********************************************************************/ -static void construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int pnum, - int snum, int i, uint32 id) +static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id) { - - int k,j; + int field_num,j; uint16 type; uint16 field; - SPOOL_NOTIFY_INFO_DATA *info_data; - print_queue_struct *queue=NULL; + SPOOL_NOTIFY_INFO_DATA *current_data; NT_PRINTER_INFO_LEVEL printer; + print_queue_struct *queue=NULL; DEBUG(4,("construct_notify_printer_info\n")); - info_data=&(info->data[info->count]); - - type = Printer[pnum].notify_info[i].type; + type=option_type->type; - DEBUGADD(4,("Notify number %d -> number of notify info: %d\n",i,Printer[pnum].notify_info[i].count)); + DEBUGADD(4,("Notify type: [%s], number of notify info: [%d] on printer: [%s]\n", + (option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"), + option_type->count, lp_servicename(snum))); - if (!get_a_printer(&printer, 2, lp_servicename(snum))) + if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) + { + return False; + } + + for(field_num=0; field_numcount; field_num++) { + field = option_type->fields[field_num]; + DEBUGADD(4,("notify [%d]: type [%x], field [%x]\n", field_num, type, field)); + + if (!search_notify(type, field, &j) ) + continue; - for(k=0; kdata=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA)); + current_data=&(info->data[info->count]); - if (search_notify(type, field, &j) ) - { - DEBUGADD(4,("j=[%d]:%s\n", j, notify_info_data_table[j].name)); - construct_info_data(info_data, type, field, id); - - DEBUGADD(4,("notify_info_data_table: in\n")); - notify_info_data_table[j].fn(snum, info_data, queue, &printer); - DEBUGADD(4,("notify_info_data_table: out\n")); - info->count++; - info_data=&(info->data[info->count]); - } - } - - free_a_printer(printer, 2); + construct_info_data(current_data, type, field, id); + notify_info_data_table[j].fn(snum, current_data, queue, &printer); + + info->count++; } + + free_a_printer(printer, 2); + return True; } /******************************************************************* @@ -1255,46 +1240,72 @@ static void construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int pnum, * fill a notify_info struct with info asked * ********************************************************************/ -static void construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, - int pnum, int snum, int i, uint32 id) +static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id) { - - int k,j; + int field_num,j; uint16 type; uint16 field; - SPOOL_NOTIFY_INFO_DATA *info_data; + SPOOL_NOTIFY_INFO_DATA *current_data; NT_PRINTER_INFO_LEVEL printer; DEBUG(4,("construct_notify_jobs_info\n")); - info_data=&(info->data[info->count]); - type = Printer[pnum].notify_info[i].type; + type = option_type->type; - DEBUGADD(4,("Notify number %d -> number of notify info: %d\n",i,Printer[pnum].notify_info[i].count)); + DEBUGADD(4,("Notify type: [%s], number of notify info: [%d]\n", + (option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"), + option_type->count)); - if (!get_a_printer(&printer, 2, lp_servicename(snum))) + if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) { - for(k=0; kcount; field_num++) + { + field = option_type->fields[field_num]; - if (search_notify(type, field, &j) ) - { - DEBUGADD(4,("j=[%d]:%s\n", j, notify_info_data_table[j].name)); - construct_info_data(info_data, type, field, id); - DEBUGADD(4,("notify_info_data_table: in\n")); - notify_info_data_table[j].fn(snum, info_data, queue, &printer); - DEBUGADD(4,("notify_info_data_table: out\n")); - info->count++; - info_data=&(info->data[info->count]); - } - } - free_a_printer(printer, 2); + if (!search_notify(type, field, &j) ) + continue; + + info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA)); + current_data=&(info->data[info->count]); + + construct_info_data(current_data, type, field, id); + notify_info_data_table[j].fn(snum, current_data, queue, &printer); + info->count++; } + + free_a_printer(printer, 2); + + return True; } +/* + * JFM: The enumeration is not that simple, it's even non obvious. + * + * let's take an example: I want to monitor the PRINTER SERVER for + * the printer's name and the number of jobs currently queued. + * So in the NOTIFY_OPTION, I have one NOTIFY_OPTION_TYPE structure. + * Its type is PRINTER_NOTIFY_TYPE and it has 2 fields NAME and CJOBS. + * + * I have 3 printers on the back of my server. + * + * Now the response is a NOTIFY_INFO structure, with 6 NOTIFY_INFO_DATA + * structures. + * Number Data Id + * 1 printer 1 name 1 + * 2 printer 1 cjob 1 + * 3 printer 2 name 2 + * 4 printer 2 cjob 2 + * 5 printer 3 name 3 + * 6 printer 3 name 3 + * + * that's the print server case, the printer case is even worse. + */ + + /******************************************************************* * @@ -1302,40 +1313,54 @@ static void construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I * fill a notify_info struct with info asked * ********************************************************************/ -static uint32 printserver_notify_info(const POLICY_HND *hnd, - SPOOL_NOTIFY_INFO *info) +static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) { int snum; int pnum=find_printer_index_by_hnd(hnd); int n_services=lp_numservices(); - int i=0; - uint32 id=1; + int i; + uint32 id; + SPOOL_NOTIFY_OPTION *option; + SPOOL_NOTIFY_OPTION_TYPE *option_type; + + DEBUG(4,("printserver_notify_info\n")); + + option=Printer[pnum].notify.option; + id=1; + info->version=2; + info->data=NULL; info->count=0; - if (pnum == -1) + for (i=0; icount; i++) { - return NT_STATUS_INVALID_HANDLE; + option_type=&(option->ctr.type[i]); + + if (option_type->type!=PRINTER_NOTIFY_TYPE) + continue; + + for (snum=0; snumversion:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); + DEBUGADD(1,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); + + for (i=0; icount; i++) { - if ( Printer[pnum].notify_info[i].type == PRINTER_NOTIFY_TYPE ) - { - for (snum=0; snumdata[i].type, info->data[i].field, info->data[i].reserved, + info->data[i].id, info->data[i].size, info->data[i].enc_type)); } - DEBUG(4,("All printers enumerated\n")); - - return 0x0; + */ + + return NT_STATUS_NO_PROBLEMO; } /******************************************************************* @@ -1343,59 +1368,72 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, * fill a notify_info struct with info asked * ********************************************************************/ -static uint32 printer_notify_info(const POLICY_HND *hnd, - SPOOL_NOTIFY_INFO *info) +static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) { int snum; int pnum=find_printer_index_by_hnd(hnd); - int i=0, j; - uint32 id=0xFFFF; + int i; + uint32 id; + SPOOL_NOTIFY_OPTION *option; + SPOOL_NOTIFY_OPTION_TYPE *option_type; + int count,j; + print_queue_struct *queue=NULL; + print_status_struct status; + DEBUG(4,("printer_notify_info\n")); + + option=Printer[pnum].notify.option; + id=1; + info->version=2; + info->data=NULL; info->count=0; - if (pnum == -1 || !get_printer_snum(hnd, &snum) ) - { - return NT_STATUS_INVALID_HANDLE; - } + get_printer_snum(hnd, &snum); - for (i=0; icount; i++) { - switch ( Printer[pnum].notify_info[i].type ) - { - case PRINTER_NOTIFY_TYPE: - { - construct_notify_printer_info(info, pnum, snum, i, id); - id--; - break; - } - case JOB_NOTIFY_TYPE: - { - int count; - print_queue_struct *queue=NULL; - print_status_struct status; - bzero(&status, sizeof(status)); - count=get_printqueue(snum, NULL, &queue, &status); - for (j=0; jctr.type[i]); + + switch ( option_type->type ) { + case PRINTER_NOTIFY_TYPE: + if(construct_notify_printer_info(info, snum, option_type, id)) + id++; + break; + + case JOB_NOTIFY_TYPE: + memset(&status, 0, sizeof(status)); + count=get_printqueue(snum, NULL, &queue, &status); + for (j=0; jversion:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); + DEBUGADD(1,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); + + for (i=0; icount; i++) + { + DEBUGADD(1,("[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\n", + i, info->data[i].type, info->data[i].field, info->data[i].reserved, + info->data[i].id, info->data[i].size, info->data[i].enc_type)); + } + */ + return NT_STATUS_NO_PROBLEMO; } /******************************************************************** * spoolss_rfnpcnex ********************************************************************/ -uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, - uint32 change, - const SPOOL_NOTIFY_OPTION *option, - uint32 *count, - SPOOL_NOTIFY_INFO *info) +uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, uint32 change, + SPOOL_NOTIFY_OPTION *option, SPOOL_NOTIFY_INFO *info) { int pnum=find_printer_index_by_hnd(handle); @@ -1404,21 +1442,32 @@ uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, return NT_STATUS_INVALID_HANDLE; } - DEBUG(4,("Printer %x of type %x\n",pnum,Printer[pnum].printer_type)); + DEBUG(4,("Printer %x of type %x\n",pnum, Printer[pnum].printer_type)); + + /* jfm: the change value isn't used right now. + * we will honour it when + * a) we'll be able to send notification to the client + * b) we'll have a way to communicate between the spoolss process. + * + * same thing for option->flags + * I should check for PRINTER_NOTIFY_OPTIONS_REFRESH but as + * I don't have a global notification system, I'm sending back all the + * informations even when _NOTHING_ has changed. + */ - /* lkxlXXXX - jfm, is this right? put a warning in for you to review! */ - DEBUG(0,("_spoolss_rfnpcnex: change, option and count ignored\n")); + /* just discard the SPOOL_NOTIFY_OPTION */ + if (option!=NULL) + safe_free(option->ctr.type); + + safe_free(option); - switch (Printer[pnum].printer_type) - { + switch (Printer[pnum].printer_type) { case PRINTER_HANDLE_IS_PRINTSERVER: - { return printserver_notify_info(handle, info); - } + break; case PRINTER_HANDLE_IS_PRINTER: - { return printer_notify_info(handle, info); - } + break; } return NT_STATUS_INVALID_INFO_CLASS; @@ -1436,7 +1485,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring s print_queue_struct *queue=NULL; print_status_struct status; - bzero(&status,sizeof(status)); + memset(&status, 0, sizeof(status)); if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0) { @@ -1476,7 +1525,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring s printer->unknown14 = 0x1; printer->unknown15 = 0x024a; /*586 Pentium ? */ printer->unknown16 = 0x0; - printer->unknown17 = 0x423ed444; + printer->unknown17 = 0x423ed444; /* CacheChangeID */ printer->unknown18 = 0x0; printer->status = status.status; printer->unknown20 = 0x0; @@ -1536,8 +1585,8 @@ static void construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) DEBUG(7,("construct_dev_mode\n")); - bzero(&(devmode->devicename), 2*sizeof(adevice)); - bzero(&(devmode->formname), 2*sizeof(aform)); + memset(&(devmode->devicename), 0, 2*sizeof(adevice)); + memset(&(devmode->formname), 0, 2*sizeof(aform)); DEBUGADD(8,("getting printer characteristics\n")); @@ -1598,7 +1647,7 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring print_queue_struct *queue=NULL; print_status_struct status; - bzero(&status, sizeof(status)); + memset(&status, 0, sizeof(status)); count=get_printqueue(snum, NULL, &queue, &status); if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) @@ -2713,14 +2762,28 @@ uint32 _spoolss_setprinter( const POLICY_HND *handle, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_fcpn( const POLICY_HND *handle) +uint32 _spoolss_fcpn(const POLICY_HND *handle) { - return 0x0; + int pnum = find_printer_index_by_hnd(handle); + + if (!OPEN_HANDLE(pnum)) + { + return NT_STATUS_INVALID_HANDLE; + } + + Printer[pnum].notify.flags=0; + Printer[pnum].notify.options=0; + Printer[pnum].notify.localmachine[0]='\0'; + Printer[pnum].notify.printerlocal=0; + safe_free(Printer[pnum].notify.option); + Printer[pnum].notify.option=NULL; + + return NT_STATUS_NO_PROBLEMO; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_addjob( const POLICY_HND *handle, uint32 level, +uint32 _spoolss_addjob(const POLICY_HND *handle, uint32 level, NEW_BUFFER *buffer, uint32 offered) { return NT_STATUS_NO_PROBLEMO; @@ -2956,7 +3019,7 @@ uint32 _spoolss_setjob( const POLICY_HND *handle, BOOL found=False; int count; - bzero(&prt_status,sizeof(prt_status)); + memset(&prt_status, 0, sizeof(prt_status)); if (!get_printer_snum(handle, &snum)) { @@ -3989,7 +4052,7 @@ uint32 _spoolss_getjob( POLICY_HND *handle, uint32 jobid, uint32 level, DEBUG(5,("spoolss_getjob\n")); - bzero(&prt_status, sizeof(prt_status)); + memset(&prt_status, 0, sizeof(prt_status)); *needed=0; -- cgit From 66018871c7eb1fedcdf8829b53038b6b484db6a3 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Thu, 24 Feb 2000 23:01:24 +0000 Subject: made dynamic the Printer struct. No more limits :-) J.F. (This used to be commit b59233b3b61b17e85f5d5b44cc6f2ced9d27b497) --- source3/rpc_server/srv_spoolss_nt.c | 356 +++++++++++++++++------------------- 1 file changed, 169 insertions(+), 187 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cd0d0a8ab1..da7eda5795 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -39,9 +39,11 @@ extern pstring global_myname; /* and a reference to what it's pointing to */ /* and the notify info asked about */ /* that's the central struct */ -static struct { +typedef struct _Printer{ + ubi_dlNode Next; + ubi_dlNode Prev; + BOOL open; - BOOL ok; BOOL document_started; BOOL page_started; uint32 current_jobid; @@ -64,21 +66,18 @@ static struct { uint32 printerlocal; SPOOL_NOTIFY_OPTION *option; } notify; -} Printer[MAX_OPEN_PRINTER_EXS]; +} Printer_entry; + +static ubi_dlList Printer_list; -#define VALID_HANDLE(pnum) (((pnum) >= 0) && ((pnum) < MAX_OPEN_PRINTER_EXS)) -#define OPEN_HANDLE(pnum) (VALID_HANDLE(pnum) && Printer[pnum].open) +#define OPEN_HANDLE(pnum) ((pnum!=NULL) && (pnum->open!=False)) /**************************************************************************** initialise printer handle states... ****************************************************************************/ void init_printer_hnd(void) { - int i; - for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++) - { - Printer[i].open = False; - } + ubi_dlInitList(&Printer_list); } /**************************************************************************** @@ -105,22 +104,25 @@ static void create_printer_hnd(POLICY_HND *hnd) /**************************************************************************** find printer index by handle ****************************************************************************/ -static int find_printer_index_by_hnd(const POLICY_HND *hnd) +static Printer_entry *find_printer_index_by_hnd(const POLICY_HND *hnd) { - int i; + Printer_entry *find_printer; - for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++) - { - if (memcmp(&(Printer[i].printer_hnd), hnd, sizeof(*hnd)) == 0) + find_printer = (Printer_entry *)ubi_dlFirst(&Printer_list); + + for(; find_printer; find_printer = (Printer_entry *)ubi_dlNext(find_printer)) { + + if (memcmp(&(find_printer->printer_hnd), hnd, sizeof(*hnd)) == 0) { - DEBUG(4,("Found printer handle[%x] \n", i)); + DEBUG(4,("Found printer handle \n")); /*dump_data(4, hnd->data, sizeof(hnd->data));*/ - return i; + return find_printer; } } + DEBUG(3,("Whoops, Printer handle not found: ")); /*dump_data(4, hnd->data, sizeof(hnd->data));*/ - return -1; + return NULL; } /**************************************************************************** @@ -136,24 +138,30 @@ static void clear_handle(POLICY_HND *hnd) ****************************************************************************/ static BOOL close_printer_handle(POLICY_HND *hnd) { - int pnum = find_printer_index_by_hnd(hnd); + Printer_entry *Printer = find_printer_index_by_hnd(hnd); - if (pnum == -1) + if (!OPEN_HANDLE(Printer)) { - DEBUG(3,("Error closing printer handle (pnum=%x)\n", pnum)); + DEBUG(3,("Error closing printer handle\n")); return False; } - Printer[pnum].open=False; - Printer[pnum].notify.flags=0; - Printer[pnum].notify.options=0; - Printer[pnum].notify.localmachine[0]='\0'; - Printer[pnum].notify.printerlocal=0; - safe_free(Printer[pnum].notify.option); - Printer[pnum].notify.option=NULL; + Printer->open=False; + Printer->notify.flags=0; + Printer->notify.options=0; + Printer->notify.localmachine[0]='\0'; + Printer->notify.printerlocal=0; + safe_free(Printer->notify.option); + Printer->notify.option=NULL; clear_handle(hnd); + ubi_dlRemThis(&Printer_list, Printer); + + safe_free(Printer); + + DEBUG(0,("[%d] entrys still in list\n", ubi_dlCount(&Printer_list))); + return True; } @@ -163,23 +171,23 @@ static BOOL close_printer_handle(POLICY_HND *hnd) static BOOL get_printer_snum(const POLICY_HND *hnd, int *number) { int snum; - int pnum = find_printer_index_by_hnd(hnd); + Printer_entry *Printer = find_printer_index_by_hnd(hnd); int n_services=lp_numservices(); - if (!OPEN_HANDLE(pnum)) { + if (!OPEN_HANDLE(Printer)) { DEBUG(3,("Error getting printer - take a nap quickly !\n")); return False; } - switch (Printer[pnum].printer_type) { + switch (Printer->printer_type) { case PRINTER_HANDLE_IS_PRINTER: - DEBUG(4,("short name:%s\n", Printer[pnum].dev.printername)); + DEBUG(4,("short name:%s\n", Printer->dev.printername)); for (snum=0;snumdev.printername ) ) && ( !strncasecmp(lp_servicename(snum), - Printer[pnum].dev.printername, + Printer->dev.printername, strlen( lp_servicename(snum) ))) ) { DEBUG(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); *number=snum; @@ -204,22 +212,19 @@ static BOOL get_printer_snum(const POLICY_HND *hnd, int *number) ****************************************************************************/ static BOOL open_printer_hnd(POLICY_HND *hnd) { - int i; + Printer_entry *new_printer; - for (i = 0; i < MAX_OPEN_PRINTER_EXS; i++) - { - if (!Printer[i].open) - { - Printer[i].open = True; - memcpy(&(Printer[i].printer_hnd), hnd, sizeof(*hnd)); - DEBUG(4,("Opened printer handle[%x] ", i)); - dump_data(4, hnd->data, sizeof(hnd->data)); - Printer[i].notify.option=NULL; - return True; - } - } - DEBUG(1,("ERROR - open_printer_hnd: out of Printers Handles!\n")); - return False; + new_printer=(Printer_entry *)malloc(sizeof(Printer_entry)); + ZERO_STRUCTP(new_printer); + + new_printer->open = True; + new_printer->notify.option=NULL; + + memcpy(&(new_printer->printer_hnd), hnd, sizeof(*hnd)); + + ubi_dlAddHead( &Printer_list, (ubi_dlNode *)new_printer); + + return True; } /**************************************************************************** @@ -227,15 +232,15 @@ static BOOL open_printer_hnd(POLICY_HND *hnd) ****************************************************************************/ static BOOL set_printer_hnd_accesstype(POLICY_HND *hnd, uint32 access_required) { - int pnum = find_printer_index_by_hnd(hnd); + Printer_entry *Printer = find_printer_index_by_hnd(hnd); - if (!OPEN_HANDLE(pnum)) { - DEBUG(4,("Error setting printer type=%x (pnum=%x)", access_required, pnum)); + if (!OPEN_HANDLE(Printer)) { + DEBUG(4,("Error setting printer type=%x", access_required)); return False; } - DEBUG(4,("Setting printer access=%x (pnum=%x)\n", access_required, pnum)); - Printer[pnum].access = access_required; + DEBUG(4,("Setting printer access=%x\n", access_required)); + Printer->access = access_required; return True; } @@ -245,14 +250,14 @@ static BOOL set_printer_hnd_accesstype(POLICY_HND *hnd, uint32 access_required) ****************************************************************************/ static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername) { - int pnum = find_printer_index_by_hnd(hnd); + Printer_entry *Printer = find_printer_index_by_hnd(hnd); - if (!OPEN_HANDLE(pnum)) { - DEBUGADD(4,("Error setting printer name %s (pnum=%x)", printername, pnum)); + if (!OPEN_HANDLE(Printer)) { + DEBUGADD(4,("Error setting printer name %s", printername)); return False; } - DEBUG(3,("Setting printer type=%s (pnum=%x)\n", printername, pnum)); + DEBUG(3,("Setting printer type=%s\n", printername)); if ( strlen(printername) < 3 ) { DEBUGADD(4,("A print server must have at least 1 char ! %s\n", printername)); @@ -262,13 +267,13 @@ static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername) /* it's a print server */ if (!strchr(printername+2, '\\')) { DEBUGADD(4,("Printer is a print server\n")); - Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTSERVER; + Printer->printer_type = PRINTER_HANDLE_IS_PRINTSERVER; return True; } /* it's a printer */ else { DEBUGADD(4,("Printer is a printer\n")); - Printer[pnum].printer_type = PRINTER_HANDLE_IS_PRINTER; + Printer->printer_type = PRINTER_HANDLE_IS_PRINTER; return True; } @@ -280,28 +285,28 @@ static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername) ****************************************************************************/ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) { - int pnum = find_printer_index_by_hnd(hnd); + Printer_entry *Printer = find_printer_index_by_hnd(hnd); NT_PRINTER_INFO_LEVEL printer; int snum; int n_services=lp_numservices(); char *aprinter; BOOL found=False; - if (!OPEN_HANDLE(pnum)) + if (!OPEN_HANDLE(Printer)) { - DEBUG(0,("Error setting printer name=%s (pnum=%x)\n", printername, pnum)); + DEBUG(0,("Error setting printer name=%s\n", printername)); return False; } - DEBUG(4,("Setting printer name=%s (len=%d) (pnum=%x)\n", printername, strlen(printername), pnum)); + DEBUG(4,("Setting printer name=%s (len=%d)\n", printername, strlen(printername))); - if (Printer[pnum].printer_type==PRINTER_HANDLE_IS_PRINTSERVER) { - ZERO_STRUCT(Printer[pnum].dev.printerservername); - strncpy(Printer[pnum].dev.printerservername, printername, strlen(printername)); + if (Printer->printer_type==PRINTER_HANDLE_IS_PRINTSERVER) { + ZERO_STRUCT(Printer->dev.printerservername); + strncpy(Printer->dev.printerservername, printername, strlen(printername)); return True; } - if (Printer[pnum].printer_type!=PRINTER_HANDLE_IS_PRINTER) + if (Printer->printer_type!=PRINTER_HANDLE_IS_PRINTER) return False; aprinter=strchr(printername+2, '\\'); @@ -347,8 +352,8 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) snum--; DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); - ZERO_STRUCT(Printer[pnum].dev.printername); - strncpy(Printer[pnum].dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); + ZERO_STRUCT(Printer->dev.printername); + strncpy(Printer->dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); free_a_printer(printer, 2); return True; @@ -359,12 +364,12 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) ********************************************************************/ static BOOL handle_is_printserver(const POLICY_HND *handle) { - int pnum=find_printer_index_by_hnd(handle); + Printer_entry *Printer=find_printer_index_by_hnd(handle); - if (!OPEN_HANDLE(pnum)) + if (!OPEN_HANDLE(Printer)) return False; - if (Printer[pnum].printer_type != PRINTER_HANDLE_IS_PRINTSERVER) + if (Printer->printer_type != PRINTER_HANDLE_IS_PRINTSERVER) return False; return True; @@ -631,15 +636,14 @@ static BOOL getprinterdata_printer(const POLICY_HND *handle, uint8 **data, uint32 *needed, uint32 in_size ) { NT_PRINTER_INFO_LEVEL printer; - int pnum=0; int snum=0; uint8 *idata=NULL; uint32 len; + Printer_entry *Printer = find_printer_index_by_hnd(handle); DEBUG(5,("getprinterdata_printer\n")); - pnum = find_printer_index_by_hnd(handle); - if (OPEN_HANDLE(pnum)) + if (OPEN_HANDLE(Printer)) { get_printer_snum(handle, &snum); get_a_printer(&printer, 2, lp_servicename(snum)); @@ -672,7 +676,7 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, { fstring value; BOOL found=False; - int pnum = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(handle); /* * Reminder: when it's a string, the length is in BYTES @@ -689,7 +693,7 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, DEBUG(4,("_spoolss_getprinterdata\n")); - if (!OPEN_HANDLE(pnum)) { + if (!OPEN_HANDLE(Printer)) { *data=(uint8 *)malloc(4*sizeof(uint8)); return NT_STATUS_INVALID_HANDLE; } @@ -729,20 +733,18 @@ uint32 _spoolss_rffpcnex(const POLICY_HND *handle, uint32 flags, uint32 options, const UNISTR2 *localmachine, uint32 printerlocal, SPOOL_NOTIFY_OPTION *option) { - int i; - /* store the notify value in the printer struct */ - i=find_printer_index_by_hnd(handle); + Printer_entry *Printer=find_printer_index_by_hnd(handle); - if (i == -1) + if (!OPEN_HANDLE(Printer)) return NT_STATUS_INVALID_HANDLE; - Printer[i].notify.flags=flags; - Printer[i].notify.options=options; - Printer[i].notify.printerlocal=printerlocal; - Printer[i].notify.option=option; - unistr2_to_ascii(Printer[i].notify.localmachine, localmachine, sizeof(Printer[i].notify.localmachine)-1); + Printer->notify.flags=flags; + Printer->notify.options=options; + Printer->notify.printerlocal=printerlocal; + Printer->notify.option=option; + unistr2_to_ascii(Printer->notify.localmachine, localmachine, sizeof(Printer->notify.localmachine)-1); return NT_STATUS_NO_PROBLEMO; } @@ -1316,7 +1318,7 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) { int snum; - int pnum=find_printer_index_by_hnd(hnd); + Printer_entry *Printer=find_printer_index_by_hnd(hnd); int n_services=lp_numservices(); int i; uint32 id; @@ -1325,7 +1327,7 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO * DEBUG(4,("printserver_notify_info\n")); - option=Printer[pnum].notify.option; + option=Printer->notify.option; id=1; info->version=2; info->data=NULL; @@ -1371,7 +1373,7 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO * static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) { int snum; - int pnum=find_printer_index_by_hnd(hnd); + Printer_entry *Printer=find_printer_index_by_hnd(hnd); int i; uint32 id; SPOOL_NOTIFY_OPTION *option; @@ -1382,7 +1384,7 @@ static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info DEBUG(4,("printer_notify_info\n")); - option=Printer[pnum].notify.option; + option=Printer->notify.option; id=1; info->version=2; info->data=NULL; @@ -1435,14 +1437,12 @@ static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, uint32 change, SPOOL_NOTIFY_OPTION *option, SPOOL_NOTIFY_INFO *info) { - int pnum=find_printer_index_by_hnd(handle); + Printer_entry *Printer=find_printer_index_by_hnd(handle); - if (pnum == -1 || !OPEN_HANDLE(pnum)) - { + if (!OPEN_HANDLE(Printer)) return NT_STATUS_INVALID_HANDLE; - } - DEBUG(4,("Printer %x of type %x\n",pnum, Printer[pnum].printer_type)); + DEBUG(4,("Printer type %x\n",Printer->printer_type)); /* jfm: the change value isn't used right now. * we will honour it when @@ -1461,7 +1461,7 @@ uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, uint32 change, safe_free(option); - switch (Printer[pnum].printer_type) { + switch (Printer->printer_type) { case PRINTER_HANDLE_IS_PRINTSERVER: return printserver_notify_info(handle, info); break; @@ -2403,15 +2403,15 @@ uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_a ****************************************************************************/ uint32 _spoolss_startpageprinter(const POLICY_HND *handle) { - int pnum = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(handle); - if (OPEN_HANDLE(pnum)) + if (OPEN_HANDLE(Printer)) { - Printer[pnum].page_started=True; + Printer->page_started=True; return 0x0; } - DEBUG(3,("Error in startpageprinter printer handle (pnum=%x)\n",pnum)); + DEBUG(3,("Error in startpageprinter printer handle\n")); return NT_STATUS_INVALID_HANDLE; } @@ -2419,16 +2419,17 @@ uint32 _spoolss_startpageprinter(const POLICY_HND *handle) ****************************************************************************/ uint32 _spoolss_endpageprinter(const POLICY_HND *handle) { - int pnum = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(handle); - if (OPEN_HANDLE(pnum)) + if (!OPEN_HANDLE(Printer)) { - Printer[pnum].page_started=False; - return 0x0; + DEBUG(3,("Error in endpageprinter printer handle\n")); + return NT_STATUS_INVALID_HANDLE; } + + Printer->page_started=False; - DEBUG(3,("Error in endpageprinter printer handle (pnum=%x)\n",pnum)); - return NT_STATUS_INVALID_HANDLE; + return NT_STATUS_NO_PROBLEMO; } @@ -2447,11 +2448,9 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, pstring datatype; int fd = -1; int snum; - int pnum; - - pnum = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(handle); - if (!VALID_HANDLE(pnum)) + if (!OPEN_HANDLE(Printer)) { return NT_STATUS_INVALID_HANDLE; } @@ -2494,16 +2493,14 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, fd=open(fname, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR ); DEBUG(4,("Temp spool file created: [%s]\n", fname)); - Printer[pnum].current_jobid=fd; - pstrcpy(Printer[pnum].document_name,fname); + Printer->current_jobid=fd; + pstrcpy(Printer->document_name, fname); - unistr2_to_ascii(Printer[pnum].job_name, - &info_1->docname, - sizeof(Printer[pnum].job_name)); + unistr2_to_ascii(Printer->job_name, &info_1->docname, sizeof(Printer->job_name)); - Printer[pnum].document_fd=fd; - Printer[pnum].document_started=True; - (*jobid) = Printer[pnum].current_jobid; + Printer->document_fd=fd; + Printer->document_started=True; + (*jobid) = Printer->current_jobid; return 0x0; } @@ -2515,29 +2512,28 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, ********************************************************************/ uint32 _spoolss_enddocprinter(const POLICY_HND *handle) { - int pnum; int snum; pstring filename; pstring filename1; pstring job_name; pstring syscmd; char *tstr; + Printer_entry *Printer=find_printer_index_by_hnd(handle); *syscmd=0; - pnum = find_printer_index_by_hnd(handle); - - if (!OPEN_HANDLE(pnum)) + if (!OPEN_HANDLE(Printer)) { - DEBUG(3,("Error in enddocprinter handle (pnum=%x)\n",pnum)); + DEBUG(3,("Error in enddocprinter handle\n")); return NT_STATUS_INVALID_HANDLE; } - Printer[pnum].document_started=False; - close(Printer[pnum].document_fd); + + Printer->document_started=False; + close(Printer->document_fd); DEBUG(4,("Temp spool file closed, printing now ...\n")); - pstrcpy(filename1, Printer[pnum].document_name); - pstrcpy(job_name, Printer[pnum].job_name); + pstrcpy(filename1, Printer->document_name); + pstrcpy(job_name, Printer->job_name); if (!get_printer_snum(handle,&snum)) { @@ -2607,20 +2603,18 @@ uint32 _spoolss_writeprinter( const POLICY_HND *handle, const uint8 *buffer, uint32 *buffer_written) { - int pnum; int fd; + Printer_entry *Printer = find_printer_index_by_hnd(handle); - pnum = find_printer_index_by_hnd(handle); - - if (!OPEN_HANDLE(pnum)) + if (!OPEN_HANDLE(Printer)) { - DEBUG(3,("Error in writeprinter handle (pnum=%x)\n",pnum)); + DEBUG(3,("Error in writeprinter handle\n")); return NT_STATUS_INVALID_HANDLE; } - fd = Printer[pnum].document_fd; + fd = Printer->document_fd; (*buffer_written) = write(fd, buffer, buffer_size); - Printer[pnum].document_lastwritten = (*buffer_written); + Printer->document_lastwritten = (*buffer_written); return 0x0; } @@ -2632,11 +2626,13 @@ uint32 _spoolss_writeprinter( const POLICY_HND *handle, ********************************************************************/ static uint32 control_printer(const POLICY_HND *handle, uint32 command) { - int pnum; int snum; - pnum = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(handle); + + if (!OPEN_HANDLE(Printer)) + return NT_STATUS_INVALID_HANDLE; - if ( pnum == -1 || !get_printer_snum(handle, &snum) ) + if (!get_printer_snum(handle, &snum) ) { return NT_STATUS_INVALID_HANDLE; } @@ -2669,11 +2665,11 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, const DEVICEMODE *devmode) { - int pnum; int snum; NT_PRINTER_INFO_LEVEL printer; NT_DEVICEMODE *nt_devmode; uint32 status = 0x0; + Printer_entry *Printer = find_printer_index_by_hnd(handle); nt_devmode=NULL; @@ -2686,11 +2682,12 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, return NT_STATUS_INVALID_INFO_CLASS; } - pnum = find_printer_index_by_hnd(handle); - if ( pnum == -1 || !get_printer_snum(handle, &snum) ) - { + if (!OPEN_HANDLE(Printer)) return NT_STATUS_INVALID_HANDLE; - } + + if (!get_printer_snum(handle, &snum) ) + return NT_STATUS_INVALID_HANDLE; + get_a_printer(&printer, level, lp_servicename(snum)); DEBUGADD(8,("Converting info_2 struct\n")); @@ -2744,17 +2741,20 @@ uint32 _spoolss_setprinter( const POLICY_HND *handle, const char *sec_buf, uint32 command) { - int pnum = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(handle); - if (!OPEN_HANDLE(pnum)) - { + if (!OPEN_HANDLE(Printer)) return NT_STATUS_INVALID_HANDLE; - } + /* check the level */ switch (level) { - case 0: return control_printer(handle, command); - case 2: return update_printer(handle, level, info, devmode); + case 0: + return control_printer(handle, command); + break; + case 2: + return update_printer(handle, level, info, devmode); + break; } return NT_STATUS_INVALID_INFO_CLASS; @@ -2764,19 +2764,17 @@ uint32 _spoolss_setprinter( const POLICY_HND *handle, ****************************************************************************/ uint32 _spoolss_fcpn(const POLICY_HND *handle) { - int pnum = find_printer_index_by_hnd(handle); + Printer_entry *Printer= find_printer_index_by_hnd(handle); - if (!OPEN_HANDLE(pnum)) - { + if (!OPEN_HANDLE(Printer)) return NT_STATUS_INVALID_HANDLE; - } - Printer[pnum].notify.flags=0; - Printer[pnum].notify.options=0; - Printer[pnum].notify.localmachine[0]='\0'; - Printer[pnum].notify.printerlocal=0; - safe_free(Printer[pnum].notify.option); - Printer[pnum].notify.option=NULL; + Printer->notify.flags=0; + Printer->notify.options=0; + Printer->notify.localmachine[0]='\0'; + Printer->notify.printerlocal=0; + safe_free(Printer->notify.option); + Printer->notify.option=NULL; return NT_STATUS_NO_PROBLEMO; } @@ -3608,9 +3606,8 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 biggest_valuesize; uint32 biggest_datasize; uint32 data_len; - uint32 status = 0x0; - - int pnum = find_printer_index_by_hnd(handle); + uint32 status = 0x0; + Printer_entry *Printer = find_printer_index_by_hnd(handle); int snum; ZERO_STRUCT(printer); @@ -3618,20 +3615,16 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, DEBUG(5,("spoolss_enumprinterdata\n")); - if (!OPEN_HANDLE(pnum)) - { + if (!OPEN_HANDLE(Printer)) return NT_STATUS_INVALID_HANDLE; - } + if (!get_printer_snum(handle, &snum)) - { return NT_STATUS_INVALID_HANDLE; - } + status = get_a_printer(&printer, 2, lp_servicename(snum)); if (status != 0x0) - { return status; - } /* The NT machine wants to know the biggest size of value and data */ if ( ((*valuesize)==0) && ((*datasize)==0) ) @@ -3711,28 +3704,22 @@ uint32 _spoolss_setprinterdata( const POLICY_HND *handle, NT_PRINTER_INFO_LEVEL printer; NT_PRINTER_PARAM *param = NULL; - int pnum=0; int snum=0; uint32 status = 0x0; + Printer_entry *Printer=find_printer_index_by_hnd(handle); DEBUG(5,("spoolss_setprinterdata\n")); - pnum = find_printer_index_by_hnd(handle); - if (!OPEN_HANDLE(pnum)) - { + if (!OPEN_HANDLE(Printer)) return NT_STATUS_INVALID_HANDLE; - } + if (!get_printer_snum(handle, &snum)) - { return NT_STATUS_INVALID_HANDLE; - } status = get_a_printer(&printer, 2, lp_servicename(snum)); if (status != 0x0) - { return status; - } convert_specific_param(¶m, value , type, data, real_len); unlink_specific_param_if_exist(printer.info_2, param); @@ -3756,18 +3743,14 @@ uint32 _spoolss_addform( const POLICY_HND *handle, uint32 level, const FORM *form) { - int pnum=0; int count=0; nt_forms_struct *list=NULL; + Printer_entry *Printer = find_printer_index_by_hnd(handle); DEBUG(5,("spoolss_addform\n")); - pnum = find_printer_index_by_hnd(handle); - - if (!OPEN_HANDLE(pnum)) - { + if (!OPEN_HANDLE(Printer)) return NT_STATUS_INVALID_HANDLE; - } count=get_ntforms(&list); add_a_form(&list, form, &count); @@ -3785,14 +3768,13 @@ uint32 _spoolss_setform( const POLICY_HND *handle, uint32 level, const FORM *form) { - int pnum=0; int count=0; nt_forms_struct *list=NULL; + Printer_entry *Printer = find_printer_index_by_hnd(handle); DEBUG(5,("spoolss_setform\n")); - pnum = find_printer_index_by_hnd(handle); - if (!OPEN_HANDLE(pnum)) + if (!OPEN_HANDLE(Printer)) { return NT_STATUS_INVALID_HANDLE; } -- cgit From badee62bca8b81db7ede74ac8ea7710b14a07b4c Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Sat, 26 Feb 2000 22:22:24 +0000 Subject: rewrote enumprinterdata. still a bug in it but reproducing it hard and borring. I need a client test program urgently!!! rewrote setprinter, doesn't coredump anymore, and no memleak. J.F. (This used to be commit b76ae1f92f4f12b38c4245456cdd2db970724077) --- source3/rpc_server/srv_spoolss.c | 37 +++---- source3/rpc_server/srv_spoolss_nt.c | 213 +++++++++++++++++++----------------- 2 files changed, 126 insertions(+), 124 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index be6775f35d..d20f6c1616 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -444,8 +444,6 @@ static BOOL api_spoolss_writeprinter(uint16 vuid, prs_struct *data, prs_struct * /**************************************************************************** -FIX ME: JFM: freeing memory ???? - ****************************************************************************/ static BOOL api_spoolss_setprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) { @@ -460,13 +458,15 @@ static BOOL api_spoolss_setprinter(uint16 vuid, prs_struct *data, prs_struct *rd return False; } - DEBUG(0,("api_spoolss_setprinter: typecast sec_des to uint8*!\n")); - r_u.status = _spoolss_setprinter(&q_u.handle, - q_u.level, &q_u.info, - q_u.devmode, - q_u.security.size_of_buffer, - (const uint8*)q_u.security.data, - q_u.command); + r_u.status = _spoolss_setprinter(&q_u.handle, q_u.level, &q_u.info, + q_u.devmode_ctr, q_u.command); + + /* now, we can free the memory */ + if (q_u.info.level==2 && q_u.info.info_ptr!=0) + safe_free(q_u.info.info_2); + + if (q_u.devmode_ctr.devmode_ptr!=0) + safe_free(q_u.devmode_ctr.devmode); if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n")); @@ -836,24 +836,19 @@ static BOOL api_spoolss_enumprinterdata(uint16 vuid, prs_struct *data, prs_struc return False; } - r_u.valuesize = q_u.valuesize; - r_u.datasize = q_u.datasize; - - r_u.status = _spoolss_enumprinterdata(&q_u.handle, - q_u.index,/* in */ - &r_u.valuesize,/* in out */ - &r_u.value,/* out */ - &r_u.realvaluesize,/* out */ - &r_u.type,/* out */ - &r_u.datasize,/* in out */ - &r_u.data,/* out */ - &r_u.realdatasize);/* out */ + r_u.status = _spoolss_enumprinterdata(&q_u.handle, q_u.index, q_u.valuesize, q_u.datasize, + &r_u.valuesize, &r_u.value, &r_u.realvaluesize, + &r_u.type, + &r_u.datasize, &r_u.data, &r_u.realdatasize); if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n")); + safe_free(r_u.value); + safe_free(r_u.data); return False; } + safe_free(r_u.value); safe_free(r_u.data); return True; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index da7eda5795..3ab426e9c2 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -66,6 +66,10 @@ typedef struct _Printer{ uint32 printerlocal; SPOOL_NOTIFY_OPTION *option; } notify; + struct { + fstring machine; + fstring user; + } client; } Printer_entry; static ubi_dlList Printer_list; @@ -160,8 +164,6 @@ static BOOL close_printer_handle(POLICY_HND *hnd) safe_free(Printer); - DEBUG(0,("[%d] entrys still in list\n", ubi_dlCount(&Printer_list))); - return True; } @@ -2632,25 +2634,30 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command) if (!OPEN_HANDLE(Printer)) return NT_STATUS_INVALID_HANDLE; - if (!get_printer_snum(handle, &snum) ) - { + if (!get_printer_snum(handle, &snum) ) return NT_STATUS_INVALID_HANDLE; - } - switch (command) - { + switch (command) { case PRINTER_CONTROL_PAUSE: /* pause the printer here */ status_printqueue(NULL, snum, LPSTAT_STOPPED); return 0x0; - + break; case PRINTER_CONTROL_RESUME: case PRINTER_CONTROL_UNPAUSE: /* UN-pause the printer here */ status_printqueue(NULL, snum, LPSTAT_OK); return 0x0; + break; case PRINTER_CONTROL_PURGE: - /* Envoi des dragées FUCA dans l'imprimante */ + /* + * It's not handled by samba + * we need a smb.conf param to do + * lprm -P%p - on BSD + * lprm -P%p all on LPRNG + * I don't know on SysV + * we could do it by looping in the job's list... + */ break; } @@ -2675,9 +2682,8 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, DEBUG(8,("update_printer\n")); - if (level!=2) - { - DEBUG(0,("Send a mail to samba-bugs@samba.org\n")); + if (level!=2) { + DEBUG(0,("Send a mail to jfm@samba.org\n")); DEBUGADD(0,("with the following message: update_printer: level!=2\n")); return NT_STATUS_INVALID_INFO_CLASS; } @@ -2688,13 +2694,12 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, if (!get_printer_snum(handle, &snum) ) return NT_STATUS_INVALID_HANDLE; - get_a_printer(&printer, level, lp_servicename(snum)); + get_a_printer(&printer, 2, lp_servicename(snum)); DEBUGADD(8,("Converting info_2 struct\n")); convert_printer_info(info, &printer, level); - if ((info->info_2)->devmode_ptr != 0) - { + if ((info->info_2)->devmode_ptr != 0) { /* we have a valid devmode convert it and link it*/ @@ -2710,36 +2715,30 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, convert_devicemode(*devmode, nt_devmode); } - else - { + else { if (printer.info_2->devmode != NULL) - { free(printer.info_2->devmode); - } printer.info_2->devmode=NULL; } - if (status == 0x0) - { - status = add_a_printer(printer, level); - } - if (status == 0x0) - { - status = free_a_printer(printer, level); + if (add_a_printer(printer, 2)!=0) { + free_a_printer(printer, 2); + + /* I don't really know what to return here !!! */ + return NT_STATUS_INVALID_INFO_CLASS; } - return status; + free_a_printer(printer, 2); + + return NT_STATUS_NO_PROBLEMO; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_setprinter( const POLICY_HND *handle, - uint32 level, - const SPOOL_PRINTER_INFO_LEVEL *info, - const DEVICEMODE *devmode, - uint32 sec_buf_size, - const char *sec_buf, - uint32 command) +uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, + const SPOOL_PRINTER_INFO_LEVEL *info, + const DEVMODE_CTR devmode_ctr, + uint32 command) { Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -2747,13 +2746,12 @@ uint32 _spoolss_setprinter( const POLICY_HND *handle, return NT_STATUS_INVALID_HANDLE; /* check the level */ - switch (level) - { + switch (level) { case 0: return control_printer(handle, command); break; case 2: - return update_printer(handle, level, info, devmode); + return update_printer(handle, level, info, devmode_ctr.devmode); break; } @@ -3094,7 +3092,7 @@ static uint32 enumprinterdrivers_level1(fstring *list, fstring servername, fstri /* fill the buffer with the form structures */ for (i=0; i<*returned; i++) { - DEBUGADD(6,("adding form [%d] to buffer\n",i)); + DEBUGADD(6,("adding driver [%d] to buffer\n",i)); new_smb_io_printer_driver_info_1("", buffer, &(driver_info_1[i]), 0); } @@ -3135,7 +3133,7 @@ static uint32 enumprinterdrivers_level2(fstring *list, fstring servername, fstri /* fill the buffer with the form structures */ for (i=0; i<*returned; i++) { - DEBUGADD(6,("adding form [%d] to buffer\n",i)); + DEBUGADD(6,("adding driver [%d] to buffer\n",i)); new_smb_io_printer_driver_info_2("", buffer, &(driver_info_2[i]), 0); } @@ -3588,15 +3586,11 @@ uint32 _spoolss_getprinterdriverdirectory(UNISTR2 *name, UNISTR2 *uni_environmen /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, - uint32 idx, - uint32 *valuesize, - UNISTR *uni_value, - uint32 *realvaluesize, - uint32 *type, - uint32 *datasize, - uint8 **data, - uint32 *realdatasize) +uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 index, + uint32 in_value_len, uint32 in_data_len, + uint32 *out_max_value_len, uint16 **out_value, uint32 *out_value_len, + uint32 *out_type, + uint32 *out_max_data_len, uint8 **out_data, uint32 *out_data_len) { NT_PRINTER_INFO_LEVEL printer; @@ -3606,12 +3600,22 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 biggest_valuesize; uint32 biggest_datasize; uint32 data_len; - uint32 status = 0x0; Printer_entry *Printer = find_printer_index_by_hnd(handle); int snum; + uint8 *data=NULL; + uint32 type; ZERO_STRUCT(printer); - (*data)=NULL; + + *out_max_value_len=0; + *out_value=NULL; + *out_value_len=0; + + *out_type=0; + + *out_max_data_len=0; + *out_data=NULL; + *out_data_len=0; DEBUG(5,("spoolss_enumprinterdata\n")); @@ -3621,74 +3625,77 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, if (!get_printer_snum(handle, &snum)) return NT_STATUS_INVALID_HANDLE; - status = get_a_printer(&printer, 2, lp_servicename(snum)); - - if (status != 0x0) - return status; + if (get_a_printer(&printer, 2, lp_servicename(snum)) != 0x0) + return NT_STATUS_INVALID_HANDLE; - /* The NT machine wants to know the biggest size of value and data */ - if ( ((*valuesize)==0) && ((*datasize)==0) ) - { + /* + * The NT machine wants to know the biggest size of value and data + * + * cf: MSDN EnumPrinterData remark section + */ + if ( (in_value_len==0) && (in_data_len==0) ) { DEBUGADD(6,("Activating NT mega-hack to find sizes\n")); - (*valuesize)=0; - (*realvaluesize)=0; - (*type)=0; - (*datasize)=0; - (*realdatasize)=0; - status=0; - param_index=0; biggest_valuesize=0; biggest_datasize=0; - while (get_specific_param_by_index(printer, 2, param_index, value, data, type, &data_len)) - { + while (get_specific_param_by_index(printer, 2, param_index, value, &data, &type, &data_len)) { if (strlen(value) > biggest_valuesize) biggest_valuesize=strlen(value); - if (data_len > biggest_datasize) biggest_datasize=data_len; + if (data_len > biggest_datasize) biggest_datasize=data_len; + DEBUG(6,("current values: [%d], [%d]\n", biggest_valuesize, biggest_datasize)); + + safe_free(data); param_index++; } - - /* I wrote it, I didn't designed the protocol */ - if (biggest_valuesize!=0) - { - SIVAL(&(value),0, 2*(biggest_valuesize+1) ); - } - (*data)=(uint8 *)malloc(4*sizeof(uint8)); - SIVAL((*data), 0, biggest_datasize ); + + /* the value is an UNICODE string but realvaluesize is the length in bytes including the leading 0 */ + *out_value_len=2*(1+biggest_valuesize); + *out_data_len=biggest_datasize; + + DEBUG(6,("final values: [%d], [%d]\n", *out_value_len, *out_data_len)); + + free_a_printer(printer, 2); + return NT_STATUS_NO_PROBLEMO; } - else - { - /* - * the value len is wrong in NT sp3 - * that's the number of bytes not the number of unicode chars - */ - - if (get_specific_param_by_index(printer, 2, idx, value, data, type, &data_len)) - { - init_unistr(uni_value, value); - - /* the length are in bytes including leading NULL */ - (*realvaluesize)=2*(strlen(value)+1); - (*realdatasize)=data_len; - - status=0; - } - else - { - (*valuesize)=0; - (*realvaluesize)=0; - (*datasize)=0; - (*realdatasize)=0; - (*type)=0; - status=0x0103; /* ERROR_NO_MORE_ITEMS */ - } + + /* + * the value len is wrong in NT sp3 + * that's the number of bytes not the number of unicode chars + */ + + if (!get_specific_param_by_index(printer, 2, index, value, &data, &type, &data_len)) { + free_a_printer(printer, 2); + return 0x0103; /* ERROR_NO_MORE_ITEMS */ } + + /* + * the value is: + * - counted in bytes in the request + * - counted in UNICODE chars in the max reply + * - counted in bytes in the real size + * + * take a pause *before* coding not *during* coding + */ + + *out_max_value_len=in_value_len/2; + *out_value=(uint16 *)malloc(in_value_len*sizeof(uint8)); + ascii_to_unistr(*out_value, value, *out_max_value_len); + *out_value_len=2*(1+strlen(value)); + + *out_type=type; + + /* the data is counted in bytes */ + *out_max_data_len=in_data_len; + *out_data=(uint8 *)malloc(in_data_len*sizeof(uint8)); + memcpy(*out_data, data, data_len); + *out_data_len=data_len; + + safe_free(data); free_a_printer(printer, 2); - - return status; + return NT_STATUS_NO_PROBLEMO; } /**************************************************************************** -- cgit From fd3acf437acb923757e1b59b503c864b4d1c45cc Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Sat, 26 Feb 2000 23:01:02 +0000 Subject: added enumprintprocessordatatypes now NT is happy and the "always send data in RAW mode" is checked J.F. (This used to be commit d7bcfe17cee64a513595d7c44456e93e88f2448b) --- source3/rpc_server/srv_spoolss.c | 36 +++++++++++++++++++++++++++ source3/rpc_server/srv_spoolss_nt.c | 49 +++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index d20f6c1616..75493b7a30 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -966,6 +966,41 @@ static BOOL api_spoolss_enumprintprocessors(uint16 vuid, prs_struct *data, prs_s return True; } +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_enumprintprocdatatypes(uint16 vuid, prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_ENUMPRINTPROCDATATYPES q_u; + SPOOL_R_ENUMPRINTPROCDATATYPES r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + new_spoolss_allocate_buffer(&q_u.buffer); + + if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n")); + return False; + } + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); + + r_u.status = _spoolss_enumprintprocdatatypes(&q_u.name, &q_u.processor, q_u.level, + r_u.buffer, q_u.offered, + &r_u.needed, &r_u.returned); + + if(!spoolss_io_r_enumprintprocdatatypes("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_enumprintprocdatatypes: unable to marshall SPOOL_R_ENUMPRINTPROCDATATYPES.\n")); + new_spoolss_free_buffer(q_u.buffer); + return False; + } + + new_spoolss_free_buffer(q_u.buffer); + + return True; +} + /**************************************************************************** ****************************************************************************/ static BOOL api_spoolss_enumprintmonitors(uint16 vuid, prs_struct *data, prs_struct *rdata) @@ -1069,6 +1104,7 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_ENUMPRINTPROCESSORS", SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_enumprintprocessors }, {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors }, {"SPOOLSS_GETJOB", SPOOLSS_GETJOB, api_spoolss_getjob }, + {"SPOOLSS_ENUMPRINTPROCDATATYPES", SPOOLSS_ENUMPRINTPROCDATATYPES, api_spoolss_enumprintprocdatatypes }, { NULL, 0, NULL } }; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3ab426e9c2..90a0ef6d60 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3849,7 +3849,56 @@ uint32 _spoolss_enumprintprocessors(UNISTR2 *name, UNISTR2 *environment, uint32 return NT_STATUS_INVALID_INFO_CLASS; break; } +} + +/**************************************************************************** + enumprintprocdatatypes level 1. +****************************************************************************/ +static uint32 enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +{ + PRINTPROCDATATYPE_1 *info_1=NULL; + + info_1 = (PRINTPROCDATATYPE_1 *)malloc(sizeof(PRINTPROCDATATYPE_1)); + (*returned) = 0x1; + + init_unistr(&(info_1->name), "RAW"); + + *needed += spoolss_size_printprocdatatype_info_1(info_1); + + if (!alloc_buffer_size(buffer, *needed)) + return ERROR_INSUFFICIENT_BUFFER; + + smb_io_printprocdatatype_info_1("", buffer, info_1, 0); + + safe_free(info_1); + + if (*needed > offered) { + *returned=0; + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; +} +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_enumprintprocdatatypes(UNISTR2 *name, UNISTR2 *processor, uint32 level, + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed, uint32 *returned) +{ + DEBUG(5,("_spoolss_enumprintprocdatatypes\n")); + + *returned=0; + *needed=0; + + switch (level) { + case 1: + return enumprintprocdatatypes_level_1(buffer, offered, needed, returned); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + break; + } } /**************************************************************************** -- cgit From 4fb014372e7bcf1b40396841f162a14cb58a086a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 29 Feb 2000 21:39:54 +0000 Subject: Fixes from Luke, back-ported from TNG to Win2k. Correctly return FAULT_PDU on unknown rpc calls. Win2k now correctly shows the owners of files. Jeremy. (This used to be commit 066898689f496dc655c3f0a553ac5e884e078022) --- source3/rpc_server/srv_pipe_srv.c | 69 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_srv.c b/source3/rpc_server/srv_pipe_srv.c index 86cc9e47e6..d4d313b803 100644 --- a/source3/rpc_server/srv_pipe_srv.c +++ b/source3/rpc_server/srv_pipe_srv.c @@ -582,6 +582,68 @@ static BOOL setup_bind_nak(pipes_struct *p, prs_struct *pd) return True; } +/******************************************************************* + Marshall a fault pdu. +*******************************************************************/ + +static BOOL setup_fault_pdu(pipes_struct *p) +{ + prs_struct outgoing_pdu; + RPC_HDR fault_hdr; + RPC_HDR_RESP hdr_resp; + RPC_HDR_FAULT fault_resp; + + /* + * Marshall directly into the outgoing PDU space. We + * must do this as we need to set to the bind response + * header and are never sending more than one PDU here. + */ + + prs_init( &outgoing_pdu, 0, 4, MARSHALL); + prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); + + /* + * Initialize a fault header. + */ + + init_rpc_hdr(&fault_hdr, RPC_FAULT, RPC_FLG_FIRST | RPC_FLG_LAST | RPC_FLG_NOCALL, + p->hdr.call_id, RPC_HEADER_LEN + RPC_HDR_RESP_LEN + RPC_HDR_FAULT_LEN, 0); + + /* + * Initialize the HDR_RESP and FAULT parts of the PDU. + */ + + memset((char *)&hdr_resp, '\0', sizeof(hdr_resp)); + + fault_resp.status = 0x1c010002; + fault_resp.reserved = 0; + + /* + * Marshall the header into the outgoing PDU. + */ + + if(!smb_io_rpc_hdr("", &fault_hdr, &outgoing_pdu, 0)) { + DEBUG(0,("setup_bind_nak: marshalling of RPC_HDR failed.\n")); + return False; + } + + if(!smb_io_rpc_hdr_resp("resp", &hdr_resp, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_RESP.\n")); + return False; + } + + if(!smb_io_rpc_hdr_fault("fault", &fault_resp, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_FAULT.\n")); + return False; + } + + p->out_data.data_sent_length = 0; + p->out_data.current_pdu_len = prs_offset(&outgoing_pdu); + p->out_data.current_pdu_sent = 0; + + return True; +} + /******************************************************************* Respond to a pipe bind request. *******************************************************************/ @@ -1052,6 +1114,7 @@ BOOL rpc_command(pipes_struct *p, char *input_data, int data_len) break; case RPC_REQUEST: if (p->ntlmssp_auth_requested && !p->ntlmssp_auth_validated) { + /* authentication _was_ requested and it failed. sorry, no deal! */ @@ -1072,8 +1135,10 @@ authentication failed. Denying the request.\n", p->name)); break; } - if (!reply) - DEBUG(3,("rpc_command: DCE/RPC fault should be sent here\n")); + if (!reply) { + DEBUG(3,("rpc_command: DCE/RPC fault sent on pipe %s\n", p->pipe_srv_name)); + reply = setup_fault_pdu(p); + } return reply; } -- cgit From 78d7ba5ca021518ec5c088eb492b36710e556c31 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 6 Mar 2000 11:13:40 +0000 Subject: changed prs_unistr to parse empty and non-empty strings the same way. fixed typo in SPOOLSS_SYNT some cleanup of unused functions wrote make_spoolss_enumprinter and make_spoolss_openprinterex for rpcclient as I'm trying to keep in sync the parsing code between HEAD and TNG. Will commit changes to TNG after lunch. J.F. (This used to be commit 025cdb345f6de287a41d4449b2662dbc5e762bf2) --- source3/rpc_server/srv_spoolss_nt.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 90a0ef6d60..9d465ca145 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -384,6 +384,7 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) { prs_struct *ps; uint32 extra_space; + uint32 old_offset; ps=&(buffer->prs); @@ -392,10 +393,19 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) extra_space=0; else extra_space = buffer_size - prs_data_size(ps); + + /* + * save the offset and move to the end of the buffer + * prs_grow() checks the extra_space against the offset + */ + old_offset=prs_offset(ps); + prs_set_offset(ps, prs_data_size(ps)); if (!prs_grow(ps, extra_space)) return False; + prs_set_offset(ps, old_offset); + buffer->string_at_end=prs_data_size(ps); return True; @@ -412,7 +422,6 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, POLICY_HND *handle) { fstring name; - fstring datatype; clear_handle(handle); @@ -962,9 +971,7 @@ static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_ print_status_struct status; memset(&status, 0, sizeof(status)); - count=get_printqueue(snum, NULL, &q, &status); - data->notify_data.value[0]=(uint32) status.status; if (q) free(q); } @@ -978,7 +985,6 @@ static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_q print_status_struct status; memset(&status, 0, sizeof(status)); - data->notify_data.value[0]=get_printqueue(snum, NULL, &q, &status); if (q) free(q); } @@ -1869,6 +1875,8 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 for (i=0; i<*returned; i++) (*needed) += spoolss_size_printer_info_2(printers[i]); + DEBUG(4,("we need [%d] bytes\n", *needed)); + if (!alloc_buffer_size(buffer, *needed)) return ERROR_INSUFFICIENT_BUFFER; @@ -1906,7 +1914,7 @@ static uint32 enumprinters_level1( uint32 flags, fstring name, if (flags && PRINTER_ENUM_REMOTE) return enum_all_printers_info_1(buffer, offered, needed, returned); - + return NT_STATUS_INVALID_LEVEL; } /******************************************************************** @@ -2675,7 +2683,6 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, int snum; NT_PRINTER_INFO_LEVEL printer; NT_DEVICEMODE *nt_devmode; - uint32 status = 0x0; Printer_entry *Printer = find_printer_index_by_hnd(handle); nt_devmode=NULL; -- cgit From 0f987d77becebc7d528f5fda6d0e23325035131c Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 7 Mar 2000 09:06:03 +0000 Subject: fixed enumprinterdata. J.F. (This used to be commit 2b4f09e7bbcbf1bf835f299e9f6bf89b32a7f03f) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 9d465ca145..f15fc75181 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2483,7 +2483,7 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, if (strcmp(datatype, "RAW") != 0) { (*jobid)=0; - return STATUS_1804; + return ERROR_INVALID_DATATYPE; } } @@ -3674,7 +3674,7 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 index, if (!get_specific_param_by_index(printer, 2, index, value, &data, &type, &data_len)) { free_a_printer(printer, 2); - return 0x0103; /* ERROR_NO_MORE_ITEMS */ + return ERROR_NO_MORE_ITEMS; } /* -- cgit From fd69e4a13a8bbaf838b33ab7a3f3f00ed558b163 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 7 Mar 2000 18:10:20 +0000 Subject: Enumprinters level 1: reply *exactly* like an NT server BTW, found a little memleak in it. J.F. (This used to be commit 9c37b5df2de9bf8fa6f5536fd75f9c8faf338a52) --- source3/rpc_server/srv_spoolss_nt.c | 228 ++++++++++++++++++++---------------- 1 file changed, 126 insertions(+), 102 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f15fc75181..41f37c3f74 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1551,35 +1551,29 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring s * construct_printer_info_1 * fill a printer_info_1 struct ********************************************************************/ -static BOOL construct_printer_info_1(PRINTER_INFO_1 *printer, int snum, pstring servername) +static BOOL construct_printer_info_1(fstring server, uint32 flags, PRINTER_INFO_1 *printer, int snum) { pstring chaine; pstring chaine2; NT_PRINTER_INFO_LEVEL ntprinter; - + if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0) - { - return (False); - } - - printer->flags=PRINTER_ENUM_ICON8; + return False; - /* the description and the name are of the form \\server\share */ + printer->flags=flags; - snprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s,%s,%s",servername, - ntprinter.info_2->printername, - ntprinter.info_2->drivername, - lp_comment(snum)); - init_unistr(&(printer->description), chaine); - - snprintf(chaine2,sizeof(chaine)-1,"\\\\%s\\%s", servername, ntprinter.info_2->printername); - init_unistr(&(printer->name), chaine2); - - init_unistr(&(printer->comment), lp_comment(snum)); + snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",server, ntprinter.info_2->printername, + ntprinter.info_2->drivername, lp_comment(snum)); + + snprintf(chaine2,sizeof(chaine)-1,"%s%s", server, ntprinter.info_2->printername); + + init_unistr(&printer->description, chaine); + init_unistr(&printer->name, chaine2); + init_unistr(&printer->comment, lp_comment(snum)); free_a_printer(ntprinter, 2); - return (True); + return True; } /**************************************************************************** @@ -1703,25 +1697,6 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring return (True); } -/******************************************************************** - * enum_printer_info_1 - * glue between spoolss_enumprinters and construct_printer_info_1 - ********************************************************************/ -static BOOL get_printer_info_1(PRINTER_INFO_1 **printer, int snum, int number) -{ - pstring servername; - - *printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1)); - DEBUG(4,("Allocated memory for ONE PRINTER_INFO_1 at [%p]\n", *printer)); - pstrcpy(servername, global_myname); - if (!construct_printer_info_1(*printer, snum, servername)) { - free(*printer); - return False; - } - else - return True; -} - /******************************************************************** * enum_printer_info_2 * glue between spoolss_enumprinters and construct_printer_info_2 @@ -1745,44 +1720,45 @@ static BOOL get_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number) } /******************************************************************** - * spoolss_enumprinters - * - * called from api_spoolss_enumprinters (see this to understand) - ********************************************************************/ -static BOOL enum_printer_info_1(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) + Spoolss_enumprinters. +********************************************************************/ +static BOOL enum_all_printers_info_1(fstring server, uint32 flags, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int snum; int i; int n_services=lp_numservices(); - PRINTER_INFO_1 *printer=NULL; -DEBUG(1,("enum_printer_info_1\n")); + PRINTER_INFO_1 *printers=NULL; + PRINTER_INFO_1 current_prt; + + DEBUG(4,("enum_all_printers_info_1\n")); + for (snum=0; snum offered) { *returned=0; @@ -1793,49 +1769,85 @@ DEBUG(1,("enum_printer_info_1\n")); } /******************************************************************** - Spoolss_enumprinters. -********************************************************************/ -static BOOL enum_all_printers_info_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) + enum_all_printers_info_1_local. +*********************************************************************/ +static BOOL enum_all_printers_info_1_local(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - int snum; - int i; - int n_services=lp_numservices(); - PRINTER_INFO_1 *printers=NULL; - PRINTER_INFO_1 current_prt; - pstring servername; + fstring temp; + DEBUG(4,("enum_all_printers_info_1_local\n")); - DEBUG(4,("enum_all_printers_info_1\n")); + fstrcpy(temp, "\\\\"); + fstrcat(temp, global_myname); + + if (!strcmp(name, temp)) { + fstrcat(temp, "\\"); + enum_all_printers_info_1(temp, PRINTER_ENUM_ICON8, buffer, offered, needed, returned); + } + else + enum_all_printers_info_1("", PRINTER_ENUM_ICON8, buffer, offered, needed, returned); +} + +/******************************************************************** + enum_all_printers_info_1_name. +*********************************************************************/ +static BOOL enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +{ + fstring temp; + DEBUG(4,("enum_all_printers_info_1_name\n")); - pstrcpy(servername, global_myname); + fstrcpy(temp, "\\\\"); + fstrcat(temp, global_myname); - for (snum=0; snumdescription, desc); + init_unistr(&printer->name, printername); + init_unistr(&printer->comment, comment); + printer->flags=PRINTER_ENUM_ICON3|PRINTER_ENUM_CONTAINER; /* check the required size. */ - for (i=0; i<*returned; i++) - (*needed) += spoolss_size_printer_info_1(&(printers[i])); + *needed += spoolss_size_printer_info_1(printer); if (!alloc_buffer_size(buffer, *needed)) return ERROR_INSUFFICIENT_BUFFER; - /* fill the buffer with the structures */ - - for (i=0; i<*returned; i++) - new_smb_io_printer_info_1("", buffer, &(printers[i]), 0); + new_smb_io_printer_info_1("", buffer, printer, 0); /* clear memory */ + safe_free(printer); if (*needed > offered) { *returned=0; @@ -1845,6 +1857,20 @@ static BOOL enum_all_printers_info_1(NEW_BUFFER *buffer, uint32 offered, uint32 return NT_STATUS_NO_PROBLEMO; } +/******************************************************************** + enum_all_printers_info_1_network. +*********************************************************************/ +static BOOL enum_all_printers_info_1_network(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +{ + fstring temp; + DEBUG(4,("enum_all_printers_info_1_network\n")); + + fstrcpy(temp, "\\\\"); + fstrcat(temp, global_myname); + fstrcat(temp, "\\"); + enum_all_printers_info_1(temp, PRINTER_ENUM_UNKNOWN_8, buffer, offered, needed, returned); +} + /******************************************************************** * api_spoolss_enumprinters * @@ -1861,11 +1887,8 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); - printers=Realloc(printers, ((*returned)+1)*sizeof(PRINTER_INFO_2 *)); - DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2 pointers\n", (*returned)+1)); - if (get_printer_info_2( &(printers[*returned]), snum, *returned) ) (*returned)++; } @@ -1901,20 +1924,21 @@ static uint32 enumprinters_level1( uint32 flags, fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - if (flags && PRINTER_ENUM_NETWORK) - return enum_all_printers_info_1(buffer, offered, needed, returned); - - if (flags && PRINTER_ENUM_NAME) { - if (*name=='\0') - return enum_all_printers_info_1(buffer, offered, needed, returned); - else - return enum_printer_info_1(name, buffer, offered, needed, returned); - } - - if (flags && PRINTER_ENUM_REMOTE) - return enum_all_printers_info_1(buffer, offered, needed, returned); + /* Not all the flags are equals */ + + if (flags & PRINTER_ENUM_LOCAL) + return enum_all_printers_info_1_local(name, buffer, offered, needed, returned); + + if (flags & PRINTER_ENUM_NAME) + return enum_all_printers_info_1_name(name, buffer, offered, needed, returned); + + if (flags & PRINTER_ENUM_REMOTE) + return enum_all_printers_info_1_remote(name, buffer, offered, needed, returned); + + if (flags & PRINTER_ENUM_NETWORK) + return enum_all_printers_info_1_network(name, buffer, offered, needed, returned); - return NT_STATUS_INVALID_LEVEL; + return NT_STATUS_NO_PROBLEMO; /* NT4sp5 does that */ } /******************************************************************** @@ -2022,7 +2046,7 @@ static uint32 getprinter_level_1(pstring servername, int snum, NEW_BUFFER *buffe PRINTER_INFO_1 *printer=NULL; printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1)); - construct_printer_info_1(printer, snum, servername); + construct_printer_info_1(servername, PRINTER_ENUM_ICON8, printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_1(printer); -- cgit From 6bb92a6d38db41a11e80c4369623d137763f0f52 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 9 Mar 2000 21:45:16 +0000 Subject: Big update moving the multi-pdu support from 2.0.x into HEAD for JF and the printer functions. Also tidied up some header includes and got the order right so you can now do a : make proto make clean make Jeremy. (This used to be commit 833cd9fba92e4ad5297b235d108dd2be8c17079b) --- source3/rpc_server/srv_pipe.c | 1099 +++++++++++++++++++++++++++++++++++-- source3/rpc_server/srv_pipe_hnd.c | 539 +++++++++++++++--- 2 files changed, 1533 insertions(+), 105 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index f8439de9a7..11822e7d03 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1,4 +1,3 @@ - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -6,6 +5,7 @@ * Copyright (C) Andrew Tridgell 1992-1998 * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, * Copyright (C) Paul Ashton 1997-1998. + * Copyright (C) Jeremy Allison 1999. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,82 +43,1095 @@ extern int DEBUGLEVEL; +static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) +{ + unsigned char *hash = p->ntlmssp_hash; + unsigned char index_i = hash[256]; + unsigned char index_j = hash[257]; + int ind; + + for( ind = 0; ind < len; ind++) { + unsigned char tc; + unsigned char t; + + index_i++; + index_j += hash[index_i]; + + tc = hash[index_i]; + hash[index_i] = hash[index_j]; + hash[index_j] = tc; + + t = hash[index_i] + hash[index_j]; + data[ind] = data[ind] ^ hash[t]; + } + + hash[256] = index_i; + hash[257] = index_j; +} + /******************************************************************* - entry point from msrpc to smb. adds data received to pdu; checks - pdu; hands pdu off to msrpc, which gets a pdu back (except in the - case of the RPC_BINDCONT pdu). + Generate the next PDU to be returned from the data in p->rdata. + We cheat here as this function doesn't handle the special auth + footers of the authenticated bind response reply. ********************************************************************/ -BOOL readwrite_pipe(pipes_struct *p, char *data, int len, - char **rdata, int *rlen) + +BOOL create_next_pdu(pipes_struct *p) { - DEBUG(10,("rpc_to_smb_readwrite: len %d\n", len)); + RPC_HDR_RESP hdr_resp; + BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SIGN); + BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SEAL); + uint32 data_len; + uint32 data_space_available; + uint32 data_len_left; + prs_struct outgoing_pdu; + char *data; + char *data_from; + uint32 data_pos; - if (write(p->m->fd, data, len) != len) - { + /* + * If we're in the fault state, keep returning fault PDU's until + * the pipe gets closed. JRA. + */ + + if(p->fault_state) { + setup_fault_pdu(p); + return True; + } + + memset((char *)&hdr_resp, '\0', sizeof(hdr_resp)); + + /* Change the incoming request header to a response. */ + p->hdr.pkt_type = RPC_RESPONSE; + + /* Set up rpc header flags. */ + if (p->out_data.data_sent_length == 0) + p->hdr.flags = RPC_FLG_FIRST; + else + p->hdr.flags = 0; + + /* + * Work out how much we can fit in a sigle PDU. + */ + + data_space_available = sizeof(p->out_data.current_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN; + if(p->ntlmssp_auth_validated) + data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN); + + /* + * The amount we send is the minimum of the available + * space and the amount left to send. + */ + + data_len_left = prs_offset(&p->out_data.rdata) - p->out_data.data_sent_length; + + /* + * Ensure there really is data left to send. + */ + + if(!data_len_left) { + DEBUG(0,("create_next_pdu: no data left to send !\n")); return False; } - if ((*rlen) == 0) - { + data_len = MIN(data_len_left, data_space_available); + + /* + * Set up the alloc hint. This should be the data left to + * send. + */ + + hdr_resp.alloc_hint = data_len_left; + + /* + * Set up the header lengths. + */ + + if (p->ntlmssp_auth_validated) { + p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len + + RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN; + p->hdr.auth_len = RPC_AUTH_NTLMSSP_CHK_LEN; + } else { + p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len; + p->hdr.auth_len = 0; + } + + /* + * Work out if this PDU will be the last. + */ + + if(p->out_data.data_sent_length + data_len >= prs_offset(&p->out_data.rdata)) + p->hdr.flags |= RPC_FLG_LAST; + + /* + * Init the parse struct to point at the outgoing + * data. + */ + + prs_init( &outgoing_pdu, 0, 4, MARSHALL); + prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); + + /* Store the header in the data stream. */ + if(!smb_io_rpc_hdr("hdr", &p->hdr, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR.\n")); return False; } - (*rdata) = (char*)Realloc((*rdata), (*rlen)); - if ((*rdata) == NULL) - { + if(!smb_io_rpc_hdr_resp("resp", &hdr_resp, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_RESP.\n")); return False; } - /* read a minimum of an rpc header, then wait for up to 10 seconds - * to read up to a maximum of the SMBtrans max data size + /* Store the current offset. */ + data_pos = prs_offset(&outgoing_pdu); + + /* Copy the data into the PDU. */ + data_from = prs_data_p(&p->out_data.rdata) + p->out_data.data_sent_length; + + if(!prs_append_data(&outgoing_pdu, data_from, data_len)) { + DEBUG(0,("create_next_pdu: failed to copy %u bytes of data.\n", (unsigned int)data_len)); + return False; + } + + /* + * Set data to point to where we copied the data into. + */ + + data = prs_data_p(&outgoing_pdu) + data_pos; + + if (p->hdr.auth_len > 0) { + uint32 crc32 = 0; + + DEBUG(5,("create_next_pdu: sign: %s seal: %s data %d auth %d\n", + BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, p->hdr.auth_len)); + + if (auth_seal) { + crc32 = crc32_calc_buffer(data, data_len); + NTLMSSPcalc_p(p, (uchar*)data, data_len); + } + + if (auth_seal || auth_verify) { + RPC_HDR_AUTH auth_info; + + init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, NTLMSSP_AUTH_LEVEL, + (auth_verify ? RPC_HDR_AUTH_LEN : 0), (auth_verify ? 1 : 0)); + if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_AUTH.\n")); + return False; + } + } + + if (auth_verify) { + RPC_AUTH_NTLMSSP_CHK ntlmssp_chk; + char *auth_data = prs_data_p(&outgoing_pdu); + + p->ntlmssp_seq_num++; + init_rpc_auth_ntlmssp_chk(&ntlmssp_chk, NTLMSSP_SIGN_VERSION, + crc32, p->ntlmssp_seq_num++); + auth_data = prs_data_p(&outgoing_pdu) + prs_offset(&outgoing_pdu) + 4; + if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &ntlmssp_chk, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_AUTH_NTLMSSP_CHK.\n")); + return False; + } + NTLMSSPcalc_p(p, (uchar*)auth_data, RPC_AUTH_NTLMSSP_CHK_LEN - 4); + } + } + + /* + * Setup the counts for this PDU. + */ + + p->out_data.data_sent_length += data_len; + p->out_data.current_pdu_len = p->hdr.frag_len; + p->out_data.current_pdu_sent = 0; + + return True; +} + +/******************************************************************* + Process an NTLMSSP authentication response. + If this function succeeds, the user has been authenticated + and their domain, name and calling workstation stored in + the pipe struct. + The initial challenge is stored in p->challenge. + *******************************************************************/ + +static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlmssp_resp) +{ + uchar lm_owf[24]; + uchar nt_owf[24]; + fstring user_name; + fstring unix_user_name; + fstring domain; + fstring wks; + BOOL guest_user = False; + struct smb_passwd *smb_pass = NULL; + struct passwd *pass = NULL; + uchar null_smb_passwd[16]; + uchar *smb_passwd_ptr = NULL; + + DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); + + memset(p->user_name, '\0', sizeof(p->user_name)); + memset(p->unix_user_name, '\0', sizeof(p->unix_user_name)); + memset(p->domain, '\0', sizeof(p->domain)); + memset(p->wks, '\0', sizeof(p->wks)); + + /* + * Setup an empty password for a guest user. */ - (*rlen) = read_with_timeout(p->m->fd, (*rdata), 16, (*rlen), 10000); - if ((*rlen) < 0) + + memset(null_smb_passwd,0,16); + + /* + * We always negotiate UNICODE. + */ + + if (IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_UNICODE)) { + fstrcpy(user_name, dos_unistrn2((uint16*)ntlmssp_resp->user, ntlmssp_resp->hdr_usr.str_str_len/2)); + fstrcpy(domain, dos_unistrn2((uint16*)ntlmssp_resp->domain, ntlmssp_resp->hdr_domain.str_str_len/2)); + fstrcpy(wks, dos_unistrn2((uint16*)ntlmssp_resp->wks, ntlmssp_resp->hdr_wks.str_str_len/2)); + } else { + fstrcpy(user_name, ntlmssp_resp->user); + fstrcpy(domain, ntlmssp_resp->domain); + fstrcpy(wks, ntlmssp_resp->wks); + } + + DEBUG(5,("user: %s domain: %s wks: %s\n", user_name, domain, wks)); + + memcpy(lm_owf, ntlmssp_resp->lm_resp, sizeof(lm_owf)); + memcpy(nt_owf, ntlmssp_resp->nt_resp, sizeof(nt_owf)); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("lm, nt owfs, chal\n")); + dump_data(100, (char *)lm_owf, sizeof(lm_owf)); + dump_data(100, (char *)nt_owf, sizeof(nt_owf)); + dump_data(100, (char *)p->challenge, 8); +#endif + + /* + * Allow guest access. Patch from Shirish Kalele . + */ + + if((strlen(user_name) == 0) && (ntlmssp_resp->hdr_lm_resp.str_str_len==0) && + (ntlmssp_resp->hdr_nt_resp.str_str_len==0)) { + + guest_user = True; + + fstrcpy(unix_user_name, lp_guestaccount(-1)); + DEBUG(100,("Null user in NTLMSSP verification. Using guest = %s\n", unix_user_name)); + + smb_passwd_ptr = null_smb_passwd; + + } else { + + /* + * Pass the user through the NT -> unix user mapping + * function. + */ + + fstrcpy(unix_user_name, user_name); + (void)map_username(unix_user_name); + + /* + * Do the length checking only if user is not NULL. + */ + + if (ntlmssp_resp->hdr_lm_resp.str_str_len == 0) + return False; + if (ntlmssp_resp->hdr_nt_resp.str_str_len == 0) + return False; + if (ntlmssp_resp->hdr_usr.str_str_len == 0) + return False; + if (ntlmssp_resp->hdr_domain.str_str_len == 0) + return False; + if (ntlmssp_resp->hdr_wks.str_str_len == 0) + return False; + + } + + /* + * Find the user in the unix password db. + */ + + if(!(pass = Get_Pwnam(unix_user_name,True))) { + DEBUG(1,("Couldn't find user '%s' in UNIX password database.\n",unix_user_name)); + return(False); + } + + if(!guest_user) { + + become_root(True); + + if(!(p->ntlmssp_auth_validated = pass_check_smb(unix_user_name, domain, + (uchar*)p->challenge, lm_owf, nt_owf, NULL))) { + DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ +failed authentication on named pipe %s.\n", domain, unix_user_name, wks, p->name )); + unbecome_root(True); + return False; + } + + if(!(smb_pass = getsmbpwnam(unix_user_name))) { + DEBUG(1,("api_pipe_ntlmssp_verify: Cannot find user %s in smb passwd database.\n", + unix_user_name)); + unbecome_root(True); + return False; + } + + unbecome_root(True); + + if (smb_pass == NULL) { + DEBUG(1,("api_pipe_ntlmssp_verify: Couldn't find user '%s' in smb_passwd file.\n", + unix_user_name)); + return(False); + } + + /* Quit if the account was disabled. */ + if((smb_pass->acct_ctrl & ACB_DISABLED) || !smb_pass->smb_passwd) { + DEBUG(1,("Account for user '%s' was disabled.\n", unix_user_name)); + return(False); + } + + if(!smb_pass->smb_nt_passwd) { + DEBUG(1,("Account for user '%s' has no NT password hash.\n", unix_user_name)); + return(False); + } + + smb_passwd_ptr = smb_pass->smb_passwd; + } + + /* + * Set up the sign/seal data. + */ + { + uchar p24[24]; + NTLMSSPOWFencrypt(smb_passwd_ptr, lm_owf, p24); + { + unsigned char j = 0; + int ind; + + unsigned char k2[8]; + + memcpy(k2, p24, 5); + k2[5] = 0xe5; + k2[6] = 0x38; + k2[7] = 0xb0; + + for (ind = 0; ind < 256; ind++) + p->ntlmssp_hash[ind] = (unsigned char)ind; + + for( ind = 0; ind < 256; ind++) { + unsigned char tc; + + j += (p->ntlmssp_hash[ind] + k2[ind%8]); + + tc = p->ntlmssp_hash[ind]; + p->ntlmssp_hash[ind] = p->ntlmssp_hash[j]; + p->ntlmssp_hash[j] = tc; + } + + p->ntlmssp_hash[256] = 0; + p->ntlmssp_hash[257] = 0; + } +/* NTLMSSPhash(p->ntlmssp_hash, p24); */ + p->ntlmssp_seq_num = 0; + + } + + fstrcpy(p->user_name, user_name); + fstrcpy(p->unix_user_name, unix_user_name); + fstrcpy(p->domain, domain); + fstrcpy(p->wks, wks); + + /* + * Store the UNIX credential data (uid/gid pair) in the pipe structure. + */ + + p->uid = pass->pw_uid; + p->gid = pass->pw_gid; + + p->ntlmssp_auth_validated = True; + return True; +} + +/******************************************************************* + The switch table for the pipe names and the functions to handle them. + *******************************************************************/ + +struct api_cmd +{ + char * pipe_clnt_name; + char * pipe_srv_name; + BOOL (*fn) (pipes_struct *, prs_struct *); +}; + +static struct api_cmd api_fd_commands[] = +{ + { "lsarpc", "lsass", api_ntlsa_rpc }, + { "samr", "lsass", api_samr_rpc }, + { "srvsvc", "ntsvcs", api_srvsvc_rpc }, + { "wkssvc", "ntsvcs", api_wkssvc_rpc }, + { "NETLOGON", "lsass", api_netlog_rpc }, +#if 1 /* DISABLED_IN_2_0 JRATEST */ + { "winreg", "winreg", api_reg_rpc }, +#endif + { NULL, NULL, NULL } +}; + +/******************************************************************* + This is the client reply to our challenge for an authenticated + bind request. The challenge we sent is in p->challenge. +*******************************************************************/ + +BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *rpc_in_p) +{ + RPC_HDR_AUTHA autha_info; + RPC_AUTH_VERIFIER auth_verifier; + RPC_AUTH_NTLMSSP_RESP ntlmssp_resp; + + DEBUG(5,("api_pipe_bind_auth_resp: decode request. %d\n", __LINE__)); + + /* + * Create the response data buffer. + */ + + if(!pipe_init_outgoing_data(&p->out_data)) { + DEBUG(0,("api_pipe_bind_auth_resp: failed to create outgoing buffer.\n")); return False; } - (*rdata) = (char*)Realloc((*rdata), (*rlen)); - if ((*rdata) == NULL) - { + + if (p->hdr.auth_len == 0) { + DEBUG(0,("api_pipe_bind_auth_resp: No auth field sent !\n")); + return False; + } + + /* + * Decode the authentication verifier response. + */ + + if(!smb_io_rpc_hdr_autha("", &autha_info, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_auth_resp: unmarshall of RPC_HDR_AUTHA failed.\n")); + return False; + } + + if (autha_info.auth_type != NTLMSSP_AUTH_TYPE || autha_info.auth_level != NTLMSSP_AUTH_LEVEL) { + DEBUG(0,("api_pipe_bind_auth_resp: incorrect auth type (%d) or level (%d).\n", + (int)autha_info.auth_type, (int)autha_info.auth_level )); return False; } + + if(!smb_io_rpc_auth_verifier("", &auth_verifier, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_auth_resp: unmarshall of RPC_AUTH_VERIFIER failed.\n")); + return False; + } + + /* + * Ensure this is a NTLMSSP_AUTH packet type. + */ + + if (!rpc_auth_verifier_chk(&auth_verifier, "NTLMSSP", NTLMSSP_AUTH)) { + DEBUG(0,("api_pipe_bind_auth_resp: rpc_auth_verifier_chk failed.\n")); + return False; + } + + if(!smb_io_rpc_auth_ntlmssp_resp("", &ntlmssp_resp, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_auth_resp: Failed to unmarshall RPC_AUTH_NTLMSSP_RESP.\n")); + return False; + } + + /* + * The following call actually checks the challenge/response data. + * for correctness against the given DOMAIN\user name. + */ + + if (!api_pipe_ntlmssp_verify(p, &ntlmssp_resp)) + return False; + + p->pipe_bound = True +; return True; } -/**************************************************************************** - writes data to a pipe. - ****************************************************************************/ -ssize_t write_pipe(pipes_struct *p, char *data, size_t n) +/******************************************************************* + Marshall a bind_nak pdu. +*******************************************************************/ + +static BOOL setup_bind_nak(pipes_struct *p) { - DEBUG(6,("write_pipe: %x", p->pnum)); - DEBUG(6,("name: %s open: %s len: %d", - p->name, BOOLSTR(p->open), n)); + prs_struct outgoing_rpc; + RPC_HDR nak_hdr; + uint16 zero = 0; + + /* Free any memory in the current return data buffer. */ + prs_mem_free(&p->out_data.rdata); + + /* + * Marshall directly into the outgoing PDU space. We + * must do this as we need to set to the bind response + * header and are never sending more than one PDU here. + */ + + prs_init( &outgoing_rpc, 0, 4, MARSHALL); + prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); + + + /* + * Initialize a bind_nak header. + */ + + init_rpc_hdr(&nak_hdr, RPC_BINDNACK, RPC_FLG_FIRST | RPC_FLG_LAST, + p->hdr.call_id, RPC_HEADER_LEN + sizeof(uint16), 0); + + /* + * Marshall the header into the outgoing PDU. + */ + + if(!smb_io_rpc_hdr("", &nak_hdr, &outgoing_rpc, 0)) { + DEBUG(0,("setup_bind_nak: marshalling of RPC_HDR failed.\n")); + return False; + } + + /* + * Now add the reject reason. + */ + + if(!prs_uint16("reject code", &outgoing_rpc, 0, &zero)) + return False; - dump_data(50, data, n); + p->out_data.data_sent_length = 0; + p->out_data.current_pdu_len = prs_offset(&outgoing_rpc); + p->out_data.current_pdu_sent = 0; - return write(p->m->fd, data, n); + p->pipe_bound = False; + + return True; } +/******************************************************************* + Marshall a fault pdu. +*******************************************************************/ + +BOOL setup_fault_pdu(pipes_struct *p) +{ + prs_struct outgoing_pdu; + RPC_HDR fault_hdr; + RPC_HDR_RESP hdr_resp; + RPC_HDR_FAULT fault_resp; + + /* Free any memory in the current return data buffer. */ + prs_mem_free(&p->out_data.rdata); + + /* + * Marshall directly into the outgoing PDU space. We + * must do this as we need to set to the bind response + * header and are never sending more than one PDU here. + */ + + prs_init( &outgoing_pdu, 0, 4, MARSHALL); + prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); + + /* + * Initialize a fault header. + */ + + init_rpc_hdr(&fault_hdr, RPC_FAULT, RPC_FLG_FIRST | RPC_FLG_LAST | RPC_FLG_NOCALL, + p->hdr.call_id, RPC_HEADER_LEN + RPC_HDR_RESP_LEN + RPC_HDR_FAULT_LEN, 0); + + /* + * Initialize the HDR_RESP and FAULT parts of the PDU. + */ + + memset((char *)&hdr_resp, '\0', sizeof(hdr_resp)); + + fault_resp.status = 0x1c010002; + fault_resp.reserved = 0; + + /* + * Marshall the header into the outgoing PDU. + */ + + if(!smb_io_rpc_hdr("", &fault_hdr, &outgoing_pdu, 0)) { + DEBUG(0,("setup_fault_pdu: marshalling of RPC_HDR failed.\n")); + return False; + } + + if(!smb_io_rpc_hdr_resp("resp", &hdr_resp, &outgoing_pdu, 0)) { + DEBUG(0,("setup_fault_pdu: failed to marshall RPC_HDR_RESP.\n")); + return False; + } + + if(!smb_io_rpc_hdr_fault("fault", &fault_resp, &outgoing_pdu, 0)) { + DEBUG(0,("setup_fault_pdu: failed to marshall RPC_HDR_FAULT.\n")); + return False; + } + + p->out_data.data_sent_length = 0; + p->out_data.current_pdu_len = prs_offset(&outgoing_pdu); + p->out_data.current_pdu_sent = 0; + + return True; +} + +/******************************************************************* + Respond to a pipe bind request. +*******************************************************************/ + +BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) +{ + RPC_HDR_BA hdr_ba; + RPC_HDR_RB hdr_rb; + RPC_HDR_AUTH auth_info; + uint16 assoc_gid; + fstring ack_pipe_name; + prs_struct out_hdr_ba; + prs_struct out_auth; + prs_struct outgoing_rpc; + int i = 0; + int auth_len = 0; + enum RPC_PKT_TYPE reply_pkt_type; + + p->ntlmssp_auth_requested = False; + + DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); + + /* + * Create the response data buffer. + */ + + if(!pipe_init_outgoing_data(&p->out_data)) { + DEBUG(0,("api_pipe_bind_req: failed to create outgoing buffer.\n")); + return False; + } + + /* + * Try and find the correct pipe name to ensure + * that this is a pipe name we support. + */ + + for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { + if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && + api_fd_commands[i].fn != NULL) { + DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", + api_fd_commands[i].pipe_clnt_name, + api_fd_commands[i].pipe_srv_name)); + fstrcpy(p->pipe_srv_name, api_fd_commands[i].pipe_srv_name); + break; + } + } + + if (api_fd_commands[i].fn == NULL) { + DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", + p->name )); + if(!setup_bind_nak(p)) + return False; + return True; + } + + /* decode the bind request */ + if(!smb_io_rpc_hdr_rb("", &hdr_rb, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_RB struct.\n")); + return False; + } + + /* + * Check if this is an authenticated request. + */ + + if (p->hdr.auth_len != 0) { + RPC_AUTH_VERIFIER auth_verifier; + RPC_AUTH_NTLMSSP_NEG ntlmssp_neg; + + /* + * Decode the authentication verifier. + */ + + if(!smb_io_rpc_hdr_auth("", &auth_info, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); + return False; + } + + /* + * We only support NTLMSSP_AUTH_TYPE requests. + */ + + if(auth_info.auth_type != NTLMSSP_AUTH_TYPE) { + DEBUG(0,("api_pipe_bind_req: unknown auth type %x requested.\n", + auth_info.auth_type )); + return False; + } + + if(!smb_io_rpc_auth_verifier("", &auth_verifier, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); + return False; + } + + if(!strequal(auth_verifier.signature, "NTLMSSP")) { + DEBUG(0,("api_pipe_bind_req: auth_verifier.signature != NTLMSSP\n")); + return False; + } + + if(auth_verifier.msg_type != NTLMSSP_NEGOTIATE) { + DEBUG(0,("api_pipe_bind_req: auth_verifier.msg_type (%d) != NTLMSSP_NEGOTIATE\n", + auth_verifier.msg_type)); + return False; + } + + if(!smb_io_rpc_auth_ntlmssp_neg("", &ntlmssp_neg, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: Failed to unmarshall RPC_AUTH_NTLMSSP_NEG.\n")); + return False; + } + + p->ntlmssp_chal_flags = SMBD_NTLMSSP_NEG_FLAGS; + p->ntlmssp_auth_requested = True; + } + + switch(p->hdr.pkt_type) { + case RPC_BIND: + /* name has to be \PIPE\xxxxx */ + fstrcpy(ack_pipe_name, "\\PIPE\\"); + fstrcat(ack_pipe_name, p->pipe_srv_name); + reply_pkt_type = RPC_BINDACK; + break; + case RPC_ALTCONT: + /* secondary address CAN be NULL + * as the specs say it's ignored. + * It MUST NULL to have the spoolss working. + */ + fstrcpy(ack_pipe_name,""); + reply_pkt_type = RPC_ALTCONTRESP; + break; + default: + return False; + } + + DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); + + /* + * Marshall directly into the outgoing PDU space. We + * must do this as we need to set to the bind response + * header and are never sending more than one PDU here. + */ + + prs_init( &outgoing_rpc, 0, 4, MARSHALL); + prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); + + /* + * Setup the memory to marshall the ba header, and the + * auth footers. + */ + + if(!prs_init(&out_hdr_ba, 1024, 4, MARSHALL)) { + DEBUG(0,("api_pipe_bind_req: malloc out_hdr_ba failed.\n")); + return False; + } + + if(!prs_init(&out_auth, 1024, 4, MARSHALL)) { + DEBUG(0,("pi_pipe_bind_req: malloc out_auth failed.\n")); + prs_mem_free(&out_hdr_ba); + return False; + } + + if (p->ntlmssp_auth_requested) + assoc_gid = 0x7a77; + else + assoc_gid = hdr_rb.bba.assoc_gid; + + /* + * Create the bind response struct. + */ + + init_rpc_hdr_ba(&hdr_ba, + MAX_PDU_FRAG_LEN, + MAX_PDU_FRAG_LEN, + assoc_gid, + ack_pipe_name, + 0x1, 0x0, 0x0, + &hdr_rb.transfer); + + /* + * and marshall it. + */ + + if(!smb_io_rpc_hdr_ba("", &hdr_ba, &out_hdr_ba, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_BA failed.\n")); + goto err_exit; + } + + /* + * Now the authentication. + */ + + if (p->ntlmssp_auth_requested) { + RPC_AUTH_VERIFIER auth_verifier; + RPC_AUTH_NTLMSSP_CHAL ntlmssp_chal; + + generate_random_buffer(p->challenge, 8, False); + + /*** Authentication info ***/ + + init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, NTLMSSP_AUTH_LEVEL, RPC_HDR_AUTH_LEN, 1); + if(!smb_io_rpc_hdr_auth("", &auth_info, &out_auth, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_AUTH failed.\n")); + goto err_exit; + } + + /*** NTLMSSP verifier ***/ + + init_rpc_auth_verifier(&auth_verifier, "NTLMSSP", NTLMSSP_CHALLENGE); + if(!smb_io_rpc_auth_verifier("", &auth_verifier, &out_auth, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_VERIFIER failed.\n")); + goto err_exit; + } + + /* NTLMSSP challenge ***/ + + init_rpc_auth_ntlmssp_chal(&ntlmssp_chal, p->ntlmssp_chal_flags, p->challenge); + if(!smb_io_rpc_auth_ntlmssp_chal("", &ntlmssp_chal, &out_auth, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_NTLMSSP_CHAL failed.\n")); + goto err_exit; + } + + /* Auth len in the rpc header doesn't include auth_header. */ + auth_len = prs_offset(&out_auth) - RPC_HDR_AUTH_LEN; + } + + /* + * Create the header, now we know the length. + */ + + init_rpc_hdr(&p->hdr, reply_pkt_type, RPC_FLG_FIRST | RPC_FLG_LAST, + p->hdr.call_id, + RPC_HEADER_LEN + prs_offset(&out_hdr_ba) + prs_offset(&out_auth), + auth_len); + + /* + * Marshall the header into the outgoing PDU. + */ + + if(!smb_io_rpc_hdr("", &p->hdr, &outgoing_rpc, 0)) { + DEBUG(0,("pi_pipe_bind_req: marshalling of RPC_HDR failed.\n")); + goto err_exit; + } + + /* + * Now add the RPC_HDR_BA and any auth needed. + */ + + if(!prs_append_prs_data( &outgoing_rpc, &out_hdr_ba)) { + DEBUG(0,("api_pipe_bind_req: append of RPC_HDR_BA failed.\n")); + goto err_exit; + } + + if(p->ntlmssp_auth_requested && !prs_append_prs_data( &outgoing_rpc, &out_auth)) { + DEBUG(0,("api_pipe_bind_req: append of auth info failed.\n")); + goto err_exit; + } + + if(!p->ntlmssp_auth_requested) + p->pipe_bound = True; + + /* + * Setup the lengths for the initial reply. + */ + + p->out_data.data_sent_length = 0; + p->out_data.current_pdu_len = prs_offset(&outgoing_rpc); + p->out_data.current_pdu_sent = 0; + + prs_mem_free(&out_hdr_ba); + prs_mem_free(&out_auth); + + return True; + + err_exit: + + prs_mem_free(&out_hdr_ba); + prs_mem_free(&out_auth); + return False; +} /**************************************************************************** - reads data from a pipe. + Deal with sign & seal processing on an RPC request. +****************************************************************************/ + +BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) +{ + /* + * We always negotiate the following two bits.... + */ + BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SIGN); + BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SEAL); + int data_len; + int auth_len; + uint32 old_offset; + uint32 crc32 = 0; + + auth_len = p->hdr.auth_len; + + if ((auth_len != RPC_AUTH_NTLMSSP_CHK_LEN) && auth_verify) { + DEBUG(0,("api_pipe_auth_process: Incorrect auth_len %d.\n", auth_len )); + return False; + } + + /* + * The following is that length of the data we must verify or unseal. + * This doesn't include the RPC headers or the auth_len or the RPC_HDR_AUTH_LEN + * preceeding the auth_data. + */ + + data_len = p->hdr.frag_len - RPC_HEADER_LEN - RPC_HDR_REQ_LEN - + (auth_verify ? RPC_HDR_AUTH_LEN : 0) - auth_len; + + DEBUG(5,("api_pipe_auth_process: sign: %s seal: %s data %d auth %d\n", + BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); + + if (auth_seal) { + char *data = prs_data_p(rpc_in) + RPC_HEADER_LEN + RPC_HDR_REQ_LEN; + NTLMSSPcalc_p(p, (uchar*)data, data_len); + crc32 = crc32_calc_buffer(data, data_len); + } + + old_offset = prs_offset(rpc_in); + + if (auth_seal || auth_verify) { + RPC_HDR_AUTH auth_info; - headers are interspersed with the data at regular intervals. by the time - this function is called, the start of the data could possibly have been - read by an SMBtrans (file_offset != 0). + if(!prs_set_offset(rpc_in, old_offset + data_len)) { + DEBUG(0,("api_pipe_auth_process: cannot move offset to %u.\n", + (unsigned int)old_offset + data_len )); + return False; + } - ****************************************************************************/ -int read_pipe(pipes_struct *p, char *data, int n) + if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, rpc_in, 0)) { + DEBUG(0,("api_pipe_auth_process: failed to unmarshall RPC_HDR_AUTH.\n")); + return False; + } + } + + if (auth_verify) { + RPC_AUTH_NTLMSSP_CHK ntlmssp_chk; + char *req_data = prs_data_p(rpc_in) + prs_offset(rpc_in) + 4; + + DEBUG(5,("api_pipe_auth_process: auth %d\n", prs_offset(rpc_in) + 4)); + + /* + * Ensure we have RPC_AUTH_NTLMSSP_CHK_LEN - 4 more bytes in the + * incoming buffer. + */ + if(prs_mem_get(rpc_in, RPC_AUTH_NTLMSSP_CHK_LEN - 4) == NULL) { + DEBUG(0,("api_pipe_auth_process: missing %d bytes in buffer.\n", + RPC_AUTH_NTLMSSP_CHK_LEN - 4 )); + return False; + } + + NTLMSSPcalc_p(p, (uchar*)req_data, RPC_AUTH_NTLMSSP_CHK_LEN - 4); + if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &ntlmssp_chk, rpc_in, 0)) { + DEBUG(0,("api_pipe_auth_process: failed to unmarshall RPC_AUTH_NTLMSSP_CHK.\n")); + return False; + } + + if (!rpc_auth_ntlmssp_chk(&ntlmssp_chk, crc32, p->ntlmssp_seq_num)) { + DEBUG(0,("api_pipe_auth_process: NTLMSSP check failed.\n")); + return False; + } + } + + /* + * Return the current pointer to the data offset. + */ + + if(!prs_set_offset(rpc_in, old_offset)) { + DEBUG(0,("api_pipe_auth_process: failed to set offset back to %u\n", + (unsigned int)old_offset )); + return False; + } + + return True; +} + +/**************************************************************************** + Find the correct RPC function to call for this request. + If the pipe is authenticated then become the correct UNIX user + before doing the call. +****************************************************************************/ + +BOOL api_pipe_request(pipes_struct *p) { - DEBUG(6,("read_pipe: %x name: %s open: %s len: %d", - p->pnum, p->name, BOOLSTR(p->open), n)); + int i = 0; + BOOL ret = False; + BOOL changed_user_id = False; - if (!p || !p->open) - { - DEBUG(6,("pipe not open\n")); - return -1; + /* + * Create the response data buffer. + */ + + if(!pipe_init_outgoing_data(&p->out_data)) { + DEBUG(0,("api_pipe_request: failed to create outgoing buffer.\n")); + return False; } - return read_data(p->m->fd, data, n); + if (p->ntlmssp_auth_validated) { + + if(!become_authenticated_pipe_user(p)) { + prs_mem_free(&p->out_data.rdata); + return False; + } + + changed_user_id = True; + } + + for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { + if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && + api_fd_commands[i].fn != NULL) { + DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i].pipe_clnt_name)); + ret = api_fd_commands[i].fn(p, &p->in_data.data); + } + } + + if(changed_user_id) + unbecome_authenticated_pipe_user(p); + + return ret; } +/******************************************************************* + Calls the underlying RPC function for a named pipe. + ********************************************************************/ + +BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds, + prs_struct *rpc_in) +{ + int fn_num; + + /* interpret the command */ + DEBUG(4,("api_rpcTNP: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); + + for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) { + if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) { + DEBUG(3,("api_rpcTNP: rpc command: %s\n", api_rpc_cmds[fn_num].name)); + break; + } + } + + if (api_rpc_cmds[fn_num].name == NULL) { + /* + * For an unknown RPC just return a fault PDU but + * return True to allow RPC's on the pipe to continue + * and not put the pipe into fault state. JRA. + */ + DEBUG(4, ("unknown\n")); + setup_fault_pdu(p); + return True; + } + + /* do the actual command */ + if(!api_rpc_cmds[fn_num].fn(p->vuid, rpc_in, &p->out_data.rdata)) { + DEBUG(0,("api_rpcTNP: %s: failed.\n", rpc_name)); + prs_mem_free(&p->out_data.rdata); + return False; + } + + DEBUG(5,("api_rpcTNP: called %s successfully\n", rpc_name)); + + return True; +} diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 32a804d5d5..c63390c35f 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1,4 +1,3 @@ - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -78,67 +77,61 @@ void init_rpc_pipe_hnd(void) Initialise an outgoing packet. ****************************************************************************/ -BOOL pipe_init_outgoing_data(output_data *out_data) +BOOL pipe_init_outgoing_data(output_data *o_data) { - memset(out_data->current_pdu, '\0', sizeof(out_data->current_pdu)); + memset(o_data->current_pdu, '\0', sizeof(o_data->current_pdu)); /* Free any memory in the current return data buffer. */ - prs_mem_free(&out_data->rdata); + prs_mem_free(&o_data->rdata); /* * Initialize the outgoing RPC data buffer. * we will use this as the raw data area for replying to rpc requests. */ - if(!prs_init(&out_data->rdata, 1024, 4, MARSHALL)) { + if(!prs_init(&o_data->rdata, MAX_PDU_FRAG_LEN, 4, MARSHALL)) { DEBUG(0,("pipe_init_outgoing_data: malloc fail.\n")); return False; } /* Reset the offset counters. */ - out_data->data_sent_length = 0; - out_data->current_pdu_len = 0; - out_data->current_pdu_sent = 0; + o_data->data_sent_length = 0; + o_data->current_pdu_len = 0; + o_data->current_pdu_sent = 0; return True; } /**************************************************************************** - Find first available pipe slot. + HACK !!! Attempt to find a remote process to communicate RPC's with. ****************************************************************************/ -pipes_struct *open_rpc_pipe_p(char *pipe_name, - connection_struct *conn, uint16 vuid) +static void attempt_remote_rpc_connect(pipes_struct *p) { - int i; - pipes_struct *p; - static int next_pipe; - struct msrpc_state *m = NULL; - user_struct *vuser = get_valid_user_struct(vuid); struct user_creds usr; + struct msrpc_state *m; + user_struct *vuser = get_valid_user_struct(p->vuid); - ZERO_STRUCT(usr); + p->m = NULL; - DEBUG(4,("Open pipe requested %s (pipes_open=%d)\n", - pipe_name, pipes_open)); - - if (vuser == NULL) - { - DEBUG(4,("invalid vuid %d\n", vuid)); - return NULL; + if (vuser == NULL) { + DEBUG(4,("attempt_remote_rpc_connect: invalid vuid %d\n", (int)p->vuid)); + return; } + ZERO_STRUCT(usr); + /* set up unix credentials from the smb side, to feed over the pipe */ make_creds_unix(&usr.uxc, vuser->name, vuser->requested_name, - vuser->real_name, vuser->guest); + vuser->real_name, vuser->guest); usr.ptr_uxc = 1; make_creds_unix_sec(&usr.uxs, vuser->uid, vuser->gid, - vuser->n_groups, vuser->groups); + vuser->n_groups, vuser->groups); usr.ptr_uxs = 1; usr.ptr_ssk = 1; - DEBUG(0,("user session key not available (yet).\n")); - DEBUG(0,("password-change operations may fail.\n")); + DEBUG(10,("user session key not available (yet).\n")); + DEBUG(10,("password-change operations may fail.\n")); #if USER_SESSION_KEY_DEFINED_IN_VUSER_STRUCT memcpy(usr.usr_sess_key, vuser->usr_sess_key, sizeof(usr.usr_sess_key)); @@ -153,14 +146,28 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, */ become_root(False); /* to connect to pipe */ - m = msrpc_use_add(pipe_name, getpid(), &usr, False); + p->m = msrpc_use_add(p->name, getpid(), &usr, False); unbecome_root(False); - if (m == NULL) - { - DEBUG(10,("open pipes: msrpc redirect failed - go local.\n")); - } + if (p->m == NULL) + DEBUG(10,("attempt_remote_rpc_connect: msrpc redirect failed - using local implementation.\n")); +} + +/**************************************************************************** + Find first available pipe slot. +****************************************************************************/ + +pipes_struct *open_rpc_pipe_p(char *pipe_name, + connection_struct *conn, uint16 vuid) +{ + int i; + pipes_struct *p; + static int next_pipe; + + DEBUG(4,("Open pipe requested %s (pipes_open=%d)\n", + pipe_name, pipes_open)); + /* not repeating pipe numbers makes it easier to track things in log files and prevents client bugs where pipe numbers are reused over connection restarts */ @@ -180,18 +187,26 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, DEBUG(5,("open pipes: name %s pnum=%x\n", p->name, p->pnum)); p = (pipes_struct *)malloc(sizeof(*p)); + if (!p) return NULL; ZERO_STRUCTP(p); - /* - * Initialize the RPC and PDU data buffers with no memory. - */ - prs_init(&p->out_data.rdata, 0, 4, MARSHALL); - DLIST_ADD(Pipes, p); + /* + * Initialize the incoming RPC data buffer with one PDU worth of memory. + * We cheat here and say we're marshalling, as we intend to add incoming + * data directly into the prs_struct and we want it to auto grow. We will + * change the type to UNMARSALLING before processing the stream. + */ + + if(!prs_init(&p->in_data.data, MAX_PDU_FRAG_LEN, 4, MARSHALL)) { + DEBUG(0,("open_rpc_pipe_p: malloc fail for in_data struct.\n")); + return NULL; + } + bitmap_set(bmap, i); i += pipe_handle_offset; @@ -204,8 +219,6 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->priority = 0; p->conn = conn; p->vuid = vuid; - - p->m = m; p->max_trans_reply = 0; @@ -213,15 +226,40 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->ntlmssp_auth_validated = False; p->ntlmssp_auth_requested = False; + p->pipe_bound = False; + p->fault_state = False; + + /* + * Initialize the incoming RPC struct. + */ + + p->in_data.pdu_needed_len = 0; + p->in_data.pdu_received_len = 0; + + /* + * Initialize the outgoing RPC struct. + */ + p->out_data.current_pdu_len = 0; p->out_data.current_pdu_sent = 0; p->out_data.data_sent_length = 0; + /* + * Initialize the outgoing RPC data buffer with no memory. + */ + prs_init(&p->out_data.rdata, 0, 4, MARSHALL); + p->uid = (uid_t)-1; p->gid = (gid_t)-1; fstrcpy(p->name, pipe_name); + /* + * HACK !!! For Luke - attempt to connect to RPC redirect process. + */ + + attempt_remote_rpc_connect(p); + DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n", pipe_name, i, pipes_open)); @@ -234,27 +272,408 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, return chain_p; } +/**************************************************************************** + Sets the fault state on incoming packets. +****************************************************************************/ + +static void set_incoming_fault(pipes_struct *p) +{ + prs_mem_free(&p->in_data.data); + p->in_data.pdu_needed_len = 0; + p->in_data.pdu_received_len = 0; + p->fault_state = True; + DEBUG(10,("set_incoming_fault: Setting fault state on pipe %s : pnum = 0x%x\n", + p->name, p->pnum )); +} /**************************************************************************** - Accepts incoming data on an rpc pipe. + Ensures we have at least RPC_HEADER_LEN amount of data in the incoming buffer. +****************************************************************************/ - This code is probably incorrect at the moment. The problem is - that the rpc request shouldn't really be executed until all the - data needed for it is received. This currently assumes that each - SMBwrite or SMBwriteX contains all the data needed for an rpc - request. JRA. - ****************************************************************************/ +static ssize_t fill_rpc_header(pipes_struct *p, char *data, size_t data_to_copy) +{ + size_t len_needed_to_complete_hdr = MIN(data_to_copy, RPC_HEADER_LEN - p->in_data.pdu_received_len); + + DEBUG(10,("fill_rpc_header: data_to_copy = %u, len_needed_to_complete_hdr = %u, receive_len = %u\n", + (unsigned int)data_to_copy, (unsigned int)len_needed_to_complete_hdr, + (unsigned int)p->in_data.pdu_received_len )); + + memcpy((char *)&p->in_data.current_in_pdu[p->in_data.pdu_received_len], data, len_needed_to_complete_hdr); + p->in_data.pdu_received_len += len_needed_to_complete_hdr; + + return (ssize_t)len_needed_to_complete_hdr; +} + +/**************************************************************************** + Unmarshalls a new PDU header. Assumes the raw header data is in current_in_pdu. +****************************************************************************/ + +static ssize_t unmarshall_rpc_header(pipes_struct *p) +{ + /* + * Unmarshall the header to determine the needed length. + */ + + prs_struct rpc_in; + + if(p->in_data.pdu_received_len != RPC_HEADER_LEN) { + DEBUG(0,("unmarshall_rpc_header: assert on rpc header length failed.\n")); + set_incoming_fault(p); + return -1; + } + + prs_init( &rpc_in, 0, 4, UNMARSHALL); + prs_give_memory( &rpc_in, (char *)&p->in_data.current_in_pdu[0], + p->in_data.pdu_received_len, False); + + /* + * Unmarshall the header as this will tell us how much + * data we need to read to get the complete pdu. + */ + + if(!smb_io_rpc_hdr("", &p->hdr, &rpc_in, 0)) { + DEBUG(0,("unmarshall_rpc_header: failed to unmarshall RPC_HDR.\n")); + set_incoming_fault(p); + return -1; + } + + /* + * Validate the RPC header. + */ + + if(p->hdr.major != 5 && p->hdr.minor != 0) { + DEBUG(0,("unmarshall_rpc_header: invalid major/minor numbers in RPC_HDR.\n")); + set_incoming_fault(p); + return -1; + } + + /* + * If there is no data in the incoming buffer and it's a requst pdu then + * ensure that the FIRST flag is set. If not then we have + * a stream missmatch. + */ + + if((p->hdr.pkt_type == RPC_REQUEST) && (prs_offset(&p->in_data.data) == 0) && !(p->hdr.flags & RPC_FLG_FIRST)) { + DEBUG(0,("unmarshall_rpc_header: FIRST flag not set in first PDU !\n")); + set_incoming_fault(p); + return -1; + } + + /* + * Ensure that the pdu length is sane. + */ + + if((p->hdr.frag_len < RPC_HEADER_LEN) || (p->hdr.frag_len > MAX_PDU_FRAG_LEN)) { + DEBUG(0,("unmarshall_rpc_header: assert on frag length failed.\n")); + set_incoming_fault(p); + return -1; + } + + DEBUG(10,("unmarshall_rpc_header: type = %u, flags = %u\n", (unsigned int)p->hdr.pkt_type, + (unsigned int)p->hdr.flags )); + + /* + * Adjust for the header we just ate. + */ + p->in_data.pdu_received_len = 0; + p->in_data.pdu_needed_len = (uint32)p->hdr.frag_len - RPC_HEADER_LEN; + + /* + * Null the data we just ate. + */ + + memset((char *)&p->in_data.current_in_pdu[0], '\0', RPC_HEADER_LEN); + + return 0; /* No extra data processed. */ +} + +/**************************************************************************** + Processes a request pdu. This will do auth processing if needed, and + appends the data into the complete stream if the LAST flag is not set. +****************************************************************************/ + +static BOOL process_request_pdu(pipes_struct *p, prs_struct *rpc_in_p) +{ + BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SIGN); + size_t data_len = p->hdr.frag_len - RPC_HEADER_LEN - RPC_HDR_REQ_LEN - + (auth_verify ? RPC_HDR_AUTH_LEN : 0) - p->hdr.auth_len; + + if(!p->pipe_bound) { + DEBUG(0,("process_request_pdu: rpc request with no bind.\n")); + set_incoming_fault(p); + return False; + } + + /* + * Check if we need to do authentication processing. + * This is only done on requests, not binds. + */ + + /* + * Read the RPC request header. + */ + + if(!smb_io_rpc_hdr_req("req", &p->hdr_req, rpc_in_p, 0)) { + DEBUG(0,("process_request_pdu: failed to unmarshall RPC_HDR_REQ.\n")); + set_incoming_fault(p); + return False; + } + + if(p->ntlmssp_auth_validated && !api_pipe_auth_process(p, rpc_in_p)) { + DEBUG(0,("process_request_pdu: failed to do auth processing.\n")); + set_incoming_fault(p); + return False; + } + + if (p->ntlmssp_auth_requested && !p->ntlmssp_auth_validated) { + + /* + * Authentication _was_ requested and it already failed. + */ + + DEBUG(0,("process_request_pdu: RPC request received on pipe %s where \ +authentication failed. Denying the request.\n", p->name)); + set_incoming_fault(p); + return False; + } + + /* + * Check the data length doesn't go over the 1Mb limit. + */ + + if(prs_data_size(&p->in_data.data) + data_len > 1024*1024) { + DEBUG(0,("process_request_pdu: rpc data buffer too large (%u) + (%u)\n", + (unsigned int)prs_data_size(&p->in_data.data), (unsigned int)data_len )); + set_incoming_fault(p); + return False; + } + + /* + * Append the data portion into the buffer and return. + */ + + { + char *data_from = prs_data_p(rpc_in_p) + prs_offset(rpc_in_p); + + if(!prs_append_data(&p->in_data.data, data_from, data_len)) { + DEBUG(0,("process_request_pdu: Unable to append data size %u to parse buffer of size %u.\n", + (unsigned int)data_len, (unsigned int)prs_data_size(&p->in_data.data) )); + set_incoming_fault(p); + return False; + } + + } + + if(p->hdr.flags & RPC_FLG_LAST) { + BOOL ret; + /* + * Ok - we finally have a complete RPC stream. + * Call the rpc command to process it. + */ + + /* + * Set the parse offset to the start of the data and set the + * prs_struct to UNMARSHALL. + */ + + prs_set_offset(&p->in_data.data, 0); + prs_switch_type(&p->in_data.data, UNMARSHALL); + + /* + * Process the complete data stream here. + */ + + ret = api_pipe_request(p); + + /* + * We have consumed the whole data stream. Set back to + * marshalling and set the offset back to the start of + * the buffer to re-use it (we could also do a prs_mem_free() + * and then re_init on the next start of PDU. Not sure which + * is best here.... JRA. + */ + + prs_switch_type(&p->in_data.data, MARSHALL); + prs_set_offset(&p->in_data.data, 0); + return ret; + } + + return True; +} + +/**************************************************************************** + Processes a finished PDU stored in current_in_pdu. The RPC_HEADER has + already been parsed and stored in p->hdr. +****************************************************************************/ + +static ssize_t process_complete_pdu(pipes_struct *p) +{ + prs_struct rpc_in; + size_t data_len = p->in_data.pdu_received_len; + char *data_p = (char *)&p->in_data.current_in_pdu[0]; + BOOL reply = False; + + if(p->fault_state) { + DEBUG(10,("process_complete_pdu: pipe %s in fault state.\n", + p->name )); + set_incoming_fault(p); + setup_fault_pdu(p); + return (ssize_t)data_len; + } + + prs_init( &rpc_in, 0, 4, UNMARSHALL); + prs_give_memory( &rpc_in, data_p, (uint32)data_len, False); + + DEBUG(10,("process_complete_pdu: processing packet type %u\n", + (unsigned int)p->hdr.pkt_type )); + + switch (p->hdr.pkt_type) { + case RPC_BIND: + case RPC_ALTCONT: + /* + * We assume that a pipe bind is only in one pdu. + */ + reply = api_pipe_bind_req(p, &rpc_in); + break; + case RPC_BINDRESP: + /* + * We assume that a pipe bind_resp is only in one pdu. + */ + reply = api_pipe_bind_auth_resp(p, &rpc_in); + break; + case RPC_REQUEST: + reply = process_request_pdu(p, &rpc_in); + break; + default: + DEBUG(0,("process_complete_pdu: Unknown rpc type = %u received.\n", (unsigned int)p->hdr.pkt_type )); + break; + } + + if (!reply) { + DEBUG(3,("process_complete_pdu: DCE/RPC fault sent on pipe %s\n", p->pipe_srv_name)); + set_incoming_fault(p); + setup_fault_pdu(p); + } else { + /* + * Reset the lengths. We're ready for a new pdu. + */ + p->in_data.pdu_needed_len = 0; + p->in_data.pdu_received_len = 0; + } + + return (ssize_t)data_len; +} + +/**************************************************************************** + Accepts incoming data on an rpc pipe. Processes the data in pdu sized units. +****************************************************************************/ + +static ssize_t process_incoming_data(pipes_struct *p, char *data, size_t n) +{ + size_t data_to_copy = MIN(n, MAX_PDU_FRAG_LEN - p->in_data.pdu_received_len); + + DEBUG(10,("process_incoming_data: Start: pdu_received_len = %u, pdu_needed_len = %u, incoming data = %u\n", + (unsigned int)p->in_data.pdu_received_len, (unsigned int)p->in_data.pdu_needed_len, + (unsigned int)n )); + + if(data_to_copy == 0) { + /* + * This is an error - data is being received and there is no + * space in the PDU. Free the received data and go into the fault state. + */ + DEBUG(0,("process_incoming_data: No space in incoming pdu buffer. Current size = %u \ +incoming data size = %u\n", (unsigned int)p->in_data.pdu_received_len, (unsigned int)n )); + set_incoming_fault(p); + return -1; + } + + /* + * If we have no data already, wait until we get at least a RPC_HEADER_LEN + * number of bytes before we can do anything. + */ + + if((p->in_data.pdu_needed_len == 0) && (p->in_data.pdu_received_len < RPC_HEADER_LEN)) { + /* + * Always return here. If we have more data then the RPC_HEADER + * will be processed the next time around the loop. + */ + return fill_rpc_header(p, data, data_to_copy); + } + + /* + * At this point we know we have at least an RPC_HEADER_LEN amount of data + * stored in current_in_pdu. + */ + + /* + * If pdu_needed_len is zero this is a new pdu. + * Unmarshall the header so we know how much more + * data we need, then loop again. + */ + + if(p->in_data.pdu_needed_len == 0) + return unmarshall_rpc_header(p); + + /* + * Ok - at this point we have a valid RPC_HEADER in p->hdr. + * Keep reading until we have a full pdu. + */ + + data_to_copy = MIN(data_to_copy, p->in_data.pdu_needed_len); + + /* + * Copy as much of the data as we need into the current_in_pdu buffer. + */ + + memcpy( (char *)&p->in_data.current_in_pdu[p->in_data.pdu_received_len], data, data_to_copy); + p->in_data.pdu_received_len += data_to_copy; + + /* + * Do we have a complete PDU ? + */ + + if(p->in_data.pdu_received_len == p->in_data.pdu_needed_len) + return process_complete_pdu(p); + + DEBUG(10,("process_incoming_data: not a complete PDU yet. pdu_received_len = %u, pdu_needed_len = %u\n", + (unsigned int)p->in_data.pdu_received_len, (unsigned int)p->in_data.pdu_needed_len )); + + return (ssize_t)data_to_copy; + +} + +/**************************************************************************** + Accepts incoming data on an rpc pipe. +****************************************************************************/ ssize_t write_to_pipe(pipes_struct *p, char *data, size_t n) { + size_t data_left = n; + DEBUG(6,("write_to_pipe: %x", p->pnum)); - DEBUG(6,("name: %s open: %s len: %d", + DEBUG(6,(" name: %s open: %s len: %d\n", p->name, BOOLSTR(p->open), (int)n)); dump_data(50, data, n); - return rpc_command(p, data, (int)n) ? ((ssize_t)n) : -1; + while(data_left) { + ssize_t data_used; + + DEBUG(10,("write_to_pipe: data_left = %u\n", (unsigned int)data_left )); + + data_used = process_incoming_data(p, data, data_left); + + DEBUG(10,("write_to_pipe: data_used = %d\n", (int)data_used )); + + if(data_used < 0) + return -1; + + data_left -= data_used; + data += data_used; + } + + return n; } @@ -282,7 +701,7 @@ int read_from_pipe(pipes_struct *p, char *data, int n) DEBUG(6,("read_from_pipe: %x", p->pnum)); - DEBUG(6,("name: %s len: %d\n", p->name, n)); + DEBUG(6,(" name: %s len: %d\n", p->name, n)); /* * We cannot return more than one PDU length per @@ -320,8 +739,9 @@ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, * may of course be zero if this is the first return fragment. */ - DEBUG(10,("read_from_pipe: %s: data_sent_length = %u, prs_offset(&p->out_data.rdata) = %u.\n", - p->name, (unsigned int)p->out_data.data_sent_length, (unsigned int)prs_offset(&p->out_data.rdata) )); + DEBUG(10,("read_from_pipe: %s: fault_state = %d : data_sent_length \ += %u, prs_offset(&p->out_data.rdata) = %u.\n", + p->name, (int)p->fault_state, (unsigned int)p->out_data.data_sent_length, (unsigned int)prs_offset(&p->out_data.rdata) )); if(p->out_data.data_sent_length >= prs_offset(&p->out_data.rdata)) { /* @@ -415,22 +835,17 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) pipes_open--; - DEBUG(4,("closed pipe name %s pnum=%x (pipes_open=%d)\n", - p->name, p->pnum, pipes_open)); - - if (p->m != NULL) - { - DEBUG(4,("closed msrpc redirect: ")); + if (p->m != NULL) { + DEBUG(4,("close_rpc_pipe_hnd: closing msrpc redirect: ")); if (msrpc_use_del(p->m->pipe_name, &p->m->usr, False, NULL)) - { DEBUG(4,("OK\n")); - } else - { DEBUG(4,("FAILED\n")); - } } + DEBUG(4,("closed pipe name %s pnum=%x (pipes_open=%d)\n", + p->name, p->pnum, pipes_open)); + DLIST_REMOVE(Pipes, p); ZERO_STRUCTP(p); -- cgit From 7f7c2e259084399e402589bed88ba1ad6fa4b57e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 9 Mar 2000 21:46:04 +0000 Subject: Not used. Functionality folded back into rpc_server/srv_pipe.c (where it originally came from). Jeremy. (This used to be commit b9bc7e8cb6255f2973f680678f93978f17489938) --- source3/rpc_server/srv_pipe_srv.c | 1181 ------------------------------------- 1 file changed, 1181 deletions(-) delete mode 100644 source3/rpc_server/srv_pipe_srv.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_srv.c b/source3/rpc_server/srv_pipe_srv.c deleted file mode 100644 index d4d313b803..0000000000 --- a/source3/rpc_server/srv_pipe_srv.c +++ /dev/null @@ -1,1181 +0,0 @@ -/* - * Unix SMB/Netbios implementation. - * Version 1.9. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1998 - * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, - * Copyright (C) Paul Ashton 1997-1998. - * Copyright (C) Jeremy Allison 1999. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* this module apparently provides an implementation of DCE/RPC over a - * named pipe (IPC$ connection using SMBtrans). details of DCE/RPC - * documentation are available (in on-line form) from the X-Open group. - * - * this module should provide a level of abstraction between SMB - * and DCE/RPC, while minimising the amount of mallocs, unnecessary - * data copies, and network traffic. - * - * in this version, which takes a "let's learn what's going on and - * get something running" approach, there is additional network - * traffic generated, but the code should be easier to understand... - * - * ... if you read the docs. or stare at packets for weeks on end. - * - */ - -#include "includes.h" -#include "nterr.h" - -extern int DEBUGLEVEL; - -static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) -{ - unsigned char *hash = p->ntlmssp_hash; - unsigned char index_i = hash[256]; - unsigned char index_j = hash[257]; - int ind; - - for( ind = 0; ind < len; ind++) { - unsigned char tc; - unsigned char t; - - index_i++; - index_j += hash[index_i]; - - tc = hash[index_i]; - hash[index_i] = hash[index_j]; - hash[index_j] = tc; - - t = hash[index_i] + hash[index_j]; - data[ind] = data[ind] ^ hash[t]; - } - - hash[256] = index_i; - hash[257] = index_j; -} - -/******************************************************************* - Generate the next PDU to be returned from the data in p->rdata. - We cheat here as this function doesn't handle the special auth - footers of the authenticated bind response reply. - ********************************************************************/ - -BOOL create_next_pdu(pipes_struct *p) -{ - RPC_HDR_RESP hdr_resp; - BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SIGN); - BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SEAL); - uint32 data_len; - uint32 data_space_available; - uint32 data_len_left; - prs_struct outgoing_pdu; - char *data; - char *data_from; - uint32 data_pos; - - memset((char *)&hdr_resp, '\0', sizeof(hdr_resp)); - - /* Change the incoming request header to a response. */ - p->hdr.pkt_type = RPC_RESPONSE; - - /* Set up rpc header flags. */ - if (p->out_data.data_sent_length == 0) - p->hdr.flags = RPC_FLG_FIRST; - else - p->hdr.flags = 0; - - /* - * Work out how much we can fit in a sigle PDU. - */ - - data_space_available = sizeof(p->out_data.current_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN; - if(p->ntlmssp_auth_validated) - data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN); - - /* - * The amount we send is the minimum of the available - * space and the amount left to send. - */ - - data_len_left = prs_offset(&p->out_data.rdata) - p->out_data.data_sent_length; - - /* - * Ensure there really is data left to send. - */ - - if(!data_len_left) { - DEBUG(0,("create_next_pdu: no data left to send !\n")); - return False; - } - - data_len = MIN(data_len_left, data_space_available); - - /* - * Set up the alloc hint. This should be the data left to - * send. - */ - - hdr_resp.alloc_hint = data_len_left; - - /* - * Set up the header lengths. - */ - - if (p->ntlmssp_auth_validated) { - p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len + - RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN; - p->hdr.auth_len = RPC_AUTH_NTLMSSP_CHK_LEN; - } else { - p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len; - p->hdr.auth_len = 0; - } - - /* - * Work out if this PDU will be the last. - */ - - if(p->out_data.data_sent_length + data_len >= prs_offset(&p->out_data.rdata)) - p->hdr.flags |= RPC_FLG_LAST; - - /* - * Init the parse struct to point at the outgoing - * data. - */ - - prs_init( &outgoing_pdu, 0, 4, MARSHALL); - prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); - - /* Store the header in the data stream. */ - if(!smb_io_rpc_hdr("hdr", &p->hdr, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR.\n")); - return False; - } - - if(!smb_io_rpc_hdr_resp("resp", &hdr_resp, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_RESP.\n")); - return False; - } - - /* Store the current offset. */ - data_pos = prs_offset(&outgoing_pdu); - - /* Copy the data into the PDU. */ - data_from = prs_data_p(&p->out_data.rdata) + p->out_data.data_sent_length; - - if(!prs_append_data(&outgoing_pdu, data_from, data_len)) { - DEBUG(0,("create_next_pdu: failed to copy %u bytes of data.\n", (unsigned int)data_len)); - return False; - } - - /* - * Set data to point to where we copied the data into. - */ - - data = prs_data_p(&outgoing_pdu) + data_pos; - - if (p->hdr.auth_len > 0) { - uint32 crc32 = 0; - - DEBUG(5,("create_next_pdu: sign: %s seal: %s data %d auth %d\n", - BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, p->hdr.auth_len)); - - if (auth_seal) { - crc32 = crc32_calc_buffer(data, data_len); - NTLMSSPcalc_p(p, (uchar*)data, data_len); - } - - if (auth_seal || auth_verify) { - RPC_HDR_AUTH auth_info; - - init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, NTLMSSP_AUTH_LEVEL, - (auth_verify ? RPC_HDR_AUTH_LEN : 0), (auth_verify ? 1 : 0)); - if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_AUTH.\n")); - return False; - } - } - - if (auth_verify) { - RPC_AUTH_NTLMSSP_CHK ntlmssp_chk; - char *auth_data = prs_data_p(&outgoing_pdu); - - p->ntlmssp_seq_num++; - init_rpc_auth_ntlmssp_chk(&ntlmssp_chk, NTLMSSP_SIGN_VERSION, - crc32, p->ntlmssp_seq_num++); - auth_data = prs_data_p(&outgoing_pdu) + prs_offset(&outgoing_pdu) + 4; - if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &ntlmssp_chk, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_AUTH_NTLMSSP_CHK.\n")); - return False; - } - NTLMSSPcalc_p(p, (uchar*)auth_data, RPC_AUTH_NTLMSSP_CHK_LEN - 4); - } - } - - /* - * Setup the counts for this PDU. - */ - - p->out_data.data_sent_length += data_len; - p->out_data.current_pdu_len = p->hdr.frag_len; - p->out_data.current_pdu_sent = 0; - - return True; -} - -/******************************************************************* - Process an NTLMSSP authentication response. - If this function succeeds, the user has been authenticated - and their domain, name and calling workstation stored in - the pipe struct. - The initial challenge is stored in p->challenge. - *******************************************************************/ - -static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlmssp_resp) -{ - uchar lm_owf[24]; - uchar nt_owf[24]; - fstring user_name; - fstring unix_user_name; - fstring domain; - fstring wks; - BOOL guest_user = False; - struct smb_passwd *smb_pass = NULL; - struct passwd *pass = NULL; - uchar null_smb_passwd[16]; - uchar *smb_passwd_ptr = NULL; - - DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); - - memset(p->user_name, '\0', sizeof(p->user_name)); - memset(p->unix_user_name, '\0', sizeof(p->unix_user_name)); - memset(p->domain, '\0', sizeof(p->domain)); - memset(p->wks, '\0', sizeof(p->wks)); - - /* - * Setup an empty password for a guest user. - */ - - memset(null_smb_passwd,0,16); - - /* - * We always negotiate UNICODE. - */ - - if (IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_UNICODE)) { - fstrcpy(user_name, dos_unistrn2((uint16*)ntlmssp_resp->user, ntlmssp_resp->hdr_usr.str_str_len/2)); - fstrcpy(domain, dos_unistrn2((uint16*)ntlmssp_resp->domain, ntlmssp_resp->hdr_domain.str_str_len/2)); - fstrcpy(wks, dos_unistrn2((uint16*)ntlmssp_resp->wks, ntlmssp_resp->hdr_wks.str_str_len/2)); - } else { - fstrcpy(user_name, ntlmssp_resp->user); - fstrcpy(domain, ntlmssp_resp->domain); - fstrcpy(wks, ntlmssp_resp->wks); - } - - DEBUG(5,("user: %s domain: %s wks: %s\n", user_name, domain, wks)); - - memcpy(lm_owf, ntlmssp_resp->lm_resp, sizeof(lm_owf)); - memcpy(nt_owf, ntlmssp_resp->nt_resp, sizeof(nt_owf)); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("lm, nt owfs, chal\n")); - dump_data(100, (char *)lm_owf, sizeof(lm_owf)); - dump_data(100, (char *)nt_owf, sizeof(nt_owf)); - dump_data(100, (char *)p->challenge, 8); -#endif - - /* - * Allow guest access. Patch from Shirish Kalele . - */ - - if((strlen(user_name) == 0) && (ntlmssp_resp->hdr_lm_resp.str_str_len==0) && - (ntlmssp_resp->hdr_nt_resp.str_str_len==0)) { - - guest_user = True; - - fstrcpy(unix_user_name, lp_guestaccount(-1)); - DEBUG(100,("Null user in NTLMSSP verification. Using guest = %s\n", unix_user_name)); - - smb_passwd_ptr = null_smb_passwd; - - } else { - - /* - * Pass the user through the NT -> unix user mapping - * function. - */ - - fstrcpy(unix_user_name, user_name); - (void)map_username(unix_user_name); - - /* - * Do the length checking only if user is not NULL. - */ - - if (ntlmssp_resp->hdr_lm_resp.str_str_len == 0) - return False; - if (ntlmssp_resp->hdr_nt_resp.str_str_len == 0) - return False; - if (ntlmssp_resp->hdr_usr.str_str_len == 0) - return False; - if (ntlmssp_resp->hdr_domain.str_str_len == 0) - return False; - if (ntlmssp_resp->hdr_wks.str_str_len == 0) - return False; - - } - - /* - * Find the user in the unix password db. - */ - - if(!(pass = Get_Pwnam(unix_user_name,True))) { - DEBUG(1,("Couldn't find user '%s' in UNIX password database.\n",unix_user_name)); - return(False); - } - - if(!guest_user) { - - become_root(True); - - if(!(p->ntlmssp_auth_validated = pass_check_smb(unix_user_name, domain, - (uchar*)p->challenge, lm_owf, nt_owf, NULL))) { - DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ -failed authentication on named pipe %s.\n", domain, unix_user_name, wks, p->name )); - unbecome_root(True); - return False; - } - - if(!(smb_pass = getsmbpwnam(unix_user_name))) { - DEBUG(1,("api_pipe_ntlmssp_verify: Cannot find user %s in smb passwd database.\n", - unix_user_name)); - unbecome_root(True); - return False; - } - - unbecome_root(True); - - if (smb_pass == NULL) { - DEBUG(1,("api_pipe_ntlmssp_verify: Couldn't find user '%s' in smb_passwd file.\n", - unix_user_name)); - return(False); - } - - /* Quit if the account was disabled. */ - if((smb_pass->acct_ctrl & ACB_DISABLED) || !smb_pass->smb_passwd) { - DEBUG(1,("Account for user '%s' was disabled.\n", unix_user_name)); - return(False); - } - - if(!smb_pass->smb_nt_passwd) { - DEBUG(1,("Account for user '%s' has no NT password hash.\n", unix_user_name)); - return(False); - } - - smb_passwd_ptr = smb_pass->smb_passwd; - } - - /* - * Set up the sign/seal data. - */ - - { - uchar p24[24]; - NTLMSSPOWFencrypt(smb_passwd_ptr, lm_owf, p24); - { - unsigned char j = 0; - int ind; - - unsigned char k2[8]; - - memcpy(k2, p24, 5); - k2[5] = 0xe5; - k2[6] = 0x38; - k2[7] = 0xb0; - - for (ind = 0; ind < 256; ind++) - p->ntlmssp_hash[ind] = (unsigned char)ind; - - for( ind = 0; ind < 256; ind++) { - unsigned char tc; - - j += (p->ntlmssp_hash[ind] + k2[ind%8]); - - tc = p->ntlmssp_hash[ind]; - p->ntlmssp_hash[ind] = p->ntlmssp_hash[j]; - p->ntlmssp_hash[j] = tc; - } - - p->ntlmssp_hash[256] = 0; - p->ntlmssp_hash[257] = 0; - } -/* NTLMSSPhash(p->ntlmssp_hash, p24); */ - p->ntlmssp_seq_num = 0; - - } - - fstrcpy(p->user_name, user_name); - fstrcpy(p->unix_user_name, unix_user_name); - fstrcpy(p->domain, domain); - fstrcpy(p->wks, wks); - - /* - * Store the UNIX credential data (uid/gid pair) in the pipe structure. - */ - - p->uid = pass->pw_uid; - p->gid = pass->pw_gid; - - p->ntlmssp_auth_validated = True; - return True; -} - -/******************************************************************* - The switch table for the pipe names and the functions to handle them. - *******************************************************************/ - -struct api_cmd -{ - char * pipe_clnt_name; - char * pipe_srv_name; - BOOL (*fn) (pipes_struct *, prs_struct *); -}; - -static struct api_cmd api_fd_commands[] = -{ - { "lsarpc", "lsass", api_ntlsa_rpc }, - { "samr", "lsass", api_samr_rpc }, - { "srvsvc", "ntsvcs", api_srvsvc_rpc }, - { "wkssvc", "ntsvcs", api_wkssvc_rpc }, - { "NETLOGON", "lsass", api_netlog_rpc }, -#if DISABLED_IN_2_0 - { "winreg", "winreg", api_reg_rpc }, -#endif - { "spoolss", "spoolss", api_spoolss_rpc }, - { NULL, NULL, NULL } -}; - -/******************************************************************* - This is the client reply to our challenge for an authenticated - bind request. The challenge we sent is in p->challenge. -*******************************************************************/ - -static BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *pd) -{ - RPC_HDR_AUTHA autha_info; - RPC_AUTH_VERIFIER auth_verifier; - RPC_AUTH_NTLMSSP_RESP ntlmssp_resp; - - DEBUG(5,("api_pipe_bind_auth_resp: decode request. %d\n", __LINE__)); - - if (p->hdr.auth_len == 0) { - DEBUG(0,("api_pipe_bind_auth_resp: No auth field sent !\n")); - return False; - } - - /* - * Decode the authentication verifier response. - */ - - if(!smb_io_rpc_hdr_autha("", &autha_info, pd, 0)) { - DEBUG(0,("api_pipe_bind_auth_resp: unmarshall of RPC_HDR_AUTHA failed.\n")); - return False; - } - - if (autha_info.auth_type != NTLMSSP_AUTH_TYPE || autha_info.auth_level != NTLMSSP_AUTH_LEVEL) { - DEBUG(0,("api_pipe_bind_auth_resp: incorrect auth type (%d) or level (%d).\n", - (int)autha_info.auth_type, (int)autha_info.auth_level )); - return False; - } - - if(!smb_io_rpc_auth_verifier("", &auth_verifier, pd, 0)) { - DEBUG(0,("api_pipe_bind_auth_resp: unmarshall of RPC_AUTH_VERIFIER failed.\n")); - return False; - } - - /* - * Ensure this is a NTLMSSP_AUTH packet type. - */ - - if (!rpc_auth_verifier_chk(&auth_verifier, "NTLMSSP", NTLMSSP_AUTH)) { - DEBUG(0,("api_pipe_bind_auth_resp: rpc_auth_verifier_chk failed.\n")); - return False; - } - - if(!smb_io_rpc_auth_ntlmssp_resp("", &ntlmssp_resp, pd, 0)) { - DEBUG(0,("api_pipe_bind_auth_resp: Failed to unmarshall RPC_AUTH_NTLMSSP_RESP.\n")); - return False; - } - - /* - * The following call actually checks the challenge/response data. - * for correctness against the given DOMAIN\user name. - */ - - if (!api_pipe_ntlmssp_verify(p, &ntlmssp_resp)) - return False; - - return True; -} - -/******************************************************************* - Marshall a bind_nak pdu. -*******************************************************************/ - -static BOOL setup_bind_nak(pipes_struct *p, prs_struct *pd) -{ - prs_struct outgoing_rpc; - RPC_HDR nak_hdr; - uint16 zero = 0; - - /* - * Marshall directly into the outgoing PDU space. We - * must do this as we need to set to the bind response - * header and are never sending more than one PDU here. - */ - - prs_init( &outgoing_rpc, 0, 4, MARSHALL); - prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); - - - /* - * Initialize a bind_nak header. - */ - - init_rpc_hdr(&nak_hdr, RPC_BINDNACK, RPC_FLG_FIRST | RPC_FLG_LAST, - p->hdr.call_id, RPC_HEADER_LEN + sizeof(uint16), 0); - - /* - * Marshall the header into the outgoing PDU. - */ - - if(!smb_io_rpc_hdr("", &nak_hdr, &outgoing_rpc, 0)) { - DEBUG(0,("setup_bind_nak: marshalling of RPC_HDR failed.\n")); - return False; - } - - /* - * Now add the reject reason. - */ - - if(!prs_uint16("reject code", &outgoing_rpc, 0, &zero)) - return False; - - p->out_data.data_sent_length = 0; - p->out_data.current_pdu_len = prs_offset(&outgoing_rpc); - p->out_data.current_pdu_sent = 0; - - return True; -} - -/******************************************************************* - Marshall a fault pdu. -*******************************************************************/ - -static BOOL setup_fault_pdu(pipes_struct *p) -{ - prs_struct outgoing_pdu; - RPC_HDR fault_hdr; - RPC_HDR_RESP hdr_resp; - RPC_HDR_FAULT fault_resp; - - /* - * Marshall directly into the outgoing PDU space. We - * must do this as we need to set to the bind response - * header and are never sending more than one PDU here. - */ - - prs_init( &outgoing_pdu, 0, 4, MARSHALL); - prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); - - /* - * Initialize a fault header. - */ - - init_rpc_hdr(&fault_hdr, RPC_FAULT, RPC_FLG_FIRST | RPC_FLG_LAST | RPC_FLG_NOCALL, - p->hdr.call_id, RPC_HEADER_LEN + RPC_HDR_RESP_LEN + RPC_HDR_FAULT_LEN, 0); - - /* - * Initialize the HDR_RESP and FAULT parts of the PDU. - */ - - memset((char *)&hdr_resp, '\0', sizeof(hdr_resp)); - - fault_resp.status = 0x1c010002; - fault_resp.reserved = 0; - - /* - * Marshall the header into the outgoing PDU. - */ - - if(!smb_io_rpc_hdr("", &fault_hdr, &outgoing_pdu, 0)) { - DEBUG(0,("setup_bind_nak: marshalling of RPC_HDR failed.\n")); - return False; - } - - if(!smb_io_rpc_hdr_resp("resp", &hdr_resp, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_RESP.\n")); - return False; - } - - if(!smb_io_rpc_hdr_fault("fault", &fault_resp, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_FAULT.\n")); - return False; - } - - p->out_data.data_sent_length = 0; - p->out_data.current_pdu_len = prs_offset(&outgoing_pdu); - p->out_data.current_pdu_sent = 0; - - return True; -} - -/******************************************************************* - Respond to a pipe bind request. -*******************************************************************/ - -static BOOL api_pipe_bind_and_alt_req(pipes_struct *p, prs_struct *pd, enum RPC_PKT_TYPE pkt_type) -{ - RPC_HDR_BA hdr_ba; - RPC_HDR_RB hdr_rb; - RPC_HDR_AUTH auth_info; - uint16 assoc_gid; - fstring ack_pipe_name; - prs_struct out_hdr_ba; - prs_struct out_auth; - prs_struct outgoing_rpc; - int i = 0; - int auth_len = 0; - - p->ntlmssp_auth_requested = False; - - DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); - - /* - * Try and find the correct pipe name to ensure - * that this is a pipe name we support. - */ - - for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { - if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && - api_fd_commands[i].fn != NULL) { - DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", - api_fd_commands[i].pipe_clnt_name, - api_fd_commands[i].pipe_srv_name)); - fstrcpy(p->pipe_srv_name, api_fd_commands[i].pipe_srv_name); - break; - } - } - - if (api_fd_commands[i].fn == NULL) { - DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", - p->name )); - if(!setup_bind_nak(p, pd)) - return False; - return True; - } - - /* decode the bind request */ - if(!smb_io_rpc_hdr_rb("", &hdr_rb, pd, 0)) { - DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_RB struct.\n")); - return False; - } - - /* - * Check if this is an authenticated request. - */ - - if (p->hdr.auth_len != 0) { - RPC_AUTH_VERIFIER auth_verifier; - RPC_AUTH_NTLMSSP_NEG ntlmssp_neg; - - /* - * Decode the authentication verifier. - */ - - if(!smb_io_rpc_hdr_auth("", &auth_info, pd, 0)) { - DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); - return False; - } - - /* - * We only support NTLMSSP_AUTH_TYPE requests. - */ - - if(auth_info.auth_type != NTLMSSP_AUTH_TYPE) { - DEBUG(0,("api_pipe_bind_req: unknown auth type %x requested.\n", - auth_info.auth_type )); - return False; - } - - if(!smb_io_rpc_auth_verifier("", &auth_verifier, pd, 0)) { - DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); - return False; - } - - if(!strequal(auth_verifier.signature, "NTLMSSP")) { - DEBUG(0,("api_pipe_bind_req: auth_verifier.signature != NTLMSSP\n")); - return False; - } - - if(auth_verifier.msg_type != NTLMSSP_NEGOTIATE) { - DEBUG(0,("api_pipe_bind_req: auth_verifier.msg_type (%d) != NTLMSSP_NEGOTIATE\n", - auth_verifier.msg_type)); - return False; - } - - if(!smb_io_rpc_auth_ntlmssp_neg("", &ntlmssp_neg, pd, 0)) { - DEBUG(0,("api_pipe_bind_req: Failed to unmarshall RPC_AUTH_NTLMSSP_NEG.\n")); - return False; - } - - p->ntlmssp_chal_flags = SMBD_NTLMSSP_NEG_FLAGS; - p->ntlmssp_auth_requested = True; - } - - switch (pkt_type) { - case RPC_BINDACK: - /* name has to be \PIPE\xxxxx */ - fstrcpy(ack_pipe_name, "\\PIPE\\"); - fstrcat(ack_pipe_name, p->pipe_srv_name); - case RPC_ALTCONTRESP: - /* secondary address CAN be NULL - * as the specs says it's ignored. - * It MUST NULL to have the spoolss working. - */ - fstrcpy(ack_pipe_name, ""); - break; - default: - return False; - } - - DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); - - /* - * Marshall directly into the outgoing PDU space. We - * must do this as we need to set to the bind response - * header and are never sending more than one PDU here. - */ - - prs_init( &outgoing_rpc, 0, 4, MARSHALL); - prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); - - /* - * Setup the memory to marshall the ba header, and the - * auth footers. - */ - - if(!prs_init(&out_hdr_ba, 1024, 4, MARSHALL)) { - DEBUG(0,("api_pipe_bind_req: malloc out_hdr_ba failed.\n")); - return False; - } - - if(!prs_init(&out_auth, 1024, 4, MARSHALL)) { - DEBUG(0,("pi_pipe_bind_req: malloc out_auth failed.\n")); - prs_mem_free(&out_hdr_ba); - return False; - } - - if (p->ntlmssp_auth_requested) - assoc_gid = 0x7a77; - else - assoc_gid = hdr_rb.bba.assoc_gid; - - /* - * Create the bind response struct. - */ - - init_rpc_hdr_ba(&hdr_ba, - hdr_rb.bba.max_tsize, - hdr_rb.bba.max_rsize, - assoc_gid, - ack_pipe_name, - 0x1, 0x0, 0x0, - &hdr_rb.transfer); - - /* - * and marshall it. - */ - - if(!smb_io_rpc_hdr_ba("", &hdr_ba, &out_hdr_ba, 0)) { - DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_BA failed.\n")); - goto err_exit; - } - - /* - * Now the authentication. - */ - - if (p->ntlmssp_auth_requested) { - RPC_AUTH_VERIFIER auth_verifier; - RPC_AUTH_NTLMSSP_CHAL ntlmssp_chal; - - generate_random_buffer(p->challenge, 8, False); - - /*** Authentication info ***/ - - init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, NTLMSSP_AUTH_LEVEL, RPC_HDR_AUTH_LEN, 1); - if(!smb_io_rpc_hdr_auth("", &auth_info, &out_auth, 0)) { - DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_AUTH failed.\n")); - goto err_exit; - } - - /*** NTLMSSP verifier ***/ - - init_rpc_auth_verifier(&auth_verifier, "NTLMSSP", NTLMSSP_CHALLENGE); - if(!smb_io_rpc_auth_verifier("", &auth_verifier, &out_auth, 0)) { - DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_VERIFIER failed.\n")); - goto err_exit; - } - - /* NTLMSSP challenge ***/ - - init_rpc_auth_ntlmssp_chal(&ntlmssp_chal, p->ntlmssp_chal_flags, p->challenge); - if(!smb_io_rpc_auth_ntlmssp_chal("", &ntlmssp_chal, &out_auth, 0)) { - DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_NTLMSSP_CHAL failed.\n")); - goto err_exit; - } - - /* Auth len in the rpc header doesn't include auth_header. */ - auth_len = prs_offset(&out_auth) - RPC_HDR_AUTH_LEN; - } - - /* - * Create the header, now we know the length. - */ - - init_rpc_hdr(&p->hdr, pkt_type, RPC_FLG_FIRST | RPC_FLG_LAST, - p->hdr.call_id, - RPC_HEADER_LEN + prs_offset(&out_hdr_ba) + prs_offset(&out_auth), - auth_len); - - /* - * Marshall the header into the outgoing PDU. - */ - - if(!smb_io_rpc_hdr("", &p->hdr, &outgoing_rpc, 0)) { - DEBUG(0,("pi_pipe_bind_req: marshalling of RPC_HDR failed.\n")); - goto err_exit; - } - - /* - * Now add the RPC_HDR_BA and any auth needed. - */ - - if(!prs_append_prs_data( &outgoing_rpc, &out_hdr_ba)) { - DEBUG(0,("api_pipe_bind_req: append of RPC_HDR_BA failed.\n")); - goto err_exit; - } - - if(p->ntlmssp_auth_requested && !prs_append_prs_data( &outgoing_rpc, &out_auth)) { - DEBUG(0,("api_pipe_bind_req: append of auth info failed.\n")); - goto err_exit; - } - - /* - * Setup the lengths for the initial reply. - */ - - p->out_data.data_sent_length = 0; - p->out_data.current_pdu_len = prs_offset(&outgoing_rpc); - p->out_data.current_pdu_sent = 0; - - prs_mem_free(&out_hdr_ba); - prs_mem_free(&out_auth); - - return True; - - err_exit: - - prs_mem_free(&out_hdr_ba); - prs_mem_free(&out_auth); - return False; -} - -/******************************************************************* - Respond to a pipe bind request. -*******************************************************************/ - -static BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *pd) -{ - return api_pipe_bind_and_alt_req(p, pd, RPC_BINDACK); -} - -/******************************************************************* - Respond to a pipe alter request. - - The RPC Alter-Context call is used only by the spoolss pipe - simply because there is a bug (?) in the MS unmarshalling code - or in the marshalling code. If it's in the later, then Samba - have the same bug. -*******************************************************************/ - -static BOOL api_pipe_altercontext_req(pipes_struct *p, prs_struct *pd) -{ - return api_pipe_bind_and_alt_req(p, pd, RPC_ALTCONTRESP); -} - -/**************************************************************************** - Deal with sign & seal processing on an RPC request. -****************************************************************************/ - -static BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) -{ - /* - * We always negotiate the following two bits.... - */ - BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SIGN); - BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SEAL); - int data_len; - int auth_len; - uint32 old_offset; - uint32 crc32 = 0; - - auth_len = p->hdr.auth_len; - - if ((auth_len != RPC_AUTH_NTLMSSP_CHK_LEN) && auth_verify) { - DEBUG(0,("api_pipe_auth_process: Incorrect auth_len %d.\n", auth_len )); - return False; - } - - /* - * The following is that length of the data we must verify or unseal. - * This doesn't include the RPC headers or the auth_len or the RPC_HDR_AUTH_LEN - * preceeding the auth_data. - */ - - data_len = p->hdr.frag_len - RPC_HEADER_LEN - RPC_HDR_REQ_LEN - - (auth_verify ? RPC_HDR_AUTH_LEN : 0) - auth_len; - - DEBUG(5,("api_pipe_auth_process: sign: %s seal: %s data %d auth %d\n", - BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); - - if (auth_seal) { - char *data = prs_data_p(rpc_in) + RPC_HEADER_LEN + RPC_HDR_REQ_LEN; - NTLMSSPcalc_p(p, (uchar*)data, data_len); - crc32 = crc32_calc_buffer(data, data_len); - } - - old_offset = prs_offset(rpc_in); - - if (auth_seal || auth_verify) { - RPC_HDR_AUTH auth_info; - - if(!prs_set_offset(rpc_in, old_offset + data_len)) { - DEBUG(0,("api_pipe_auth_process: cannot move offset to %u.\n", - (unsigned int)old_offset + data_len )); - return False; - } - - if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, rpc_in, 0)) { - DEBUG(0,("api_pipe_auth_process: failed to unmarshall RPC_HDR_AUTH.\n")); - return False; - } - } - - if (auth_verify) { - RPC_AUTH_NTLMSSP_CHK ntlmssp_chk; - char *req_data = prs_data_p(rpc_in) + prs_offset(rpc_in) + 4; - - DEBUG(5,("api_pipe_auth_process: auth %d\n", prs_offset(rpc_in) + 4)); - - /* - * Ensure we have RPC_AUTH_NTLMSSP_CHK_LEN - 4 more bytes in the - * incoming buffer. - */ - if(prs_mem_get(rpc_in, RPC_AUTH_NTLMSSP_CHK_LEN - 4) == NULL) { - DEBUG(0,("api_pipe_auth_process: missing %d bytes in buffer.\n", - RPC_AUTH_NTLMSSP_CHK_LEN - 4 )); - return False; - } - - NTLMSSPcalc_p(p, (uchar*)req_data, RPC_AUTH_NTLMSSP_CHK_LEN - 4); - if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &ntlmssp_chk, rpc_in, 0)) { - DEBUG(0,("api_pipe_auth_process: failed to unmarshall RPC_AUTH_NTLMSSP_CHK.\n")); - return False; - } - - if (!rpc_auth_ntlmssp_chk(&ntlmssp_chk, crc32, p->ntlmssp_seq_num)) { - DEBUG(0,("api_pipe_auth_process: NTLMSSP check failed.\n")); - return False; - } - } - - /* - * Return the current pointer to the data offset. - */ - - if(!prs_set_offset(rpc_in, old_offset)) { - DEBUG(0,("api_pipe_auth_process: failed to set offset back to %u\n", - (unsigned int)old_offset )); - return False; - } - - return True; -} - -/**************************************************************************** - Find the correct RPC function to call for this request. - If the pipe is authenticated then become the correct UNIX user - before doing the call. -****************************************************************************/ - -static BOOL api_pipe_request(pipes_struct *p, prs_struct *rpc_in) -{ - int i = 0; - BOOL ret = False; - BOOL changed_user_id = False; - - if (p->ntlmssp_auth_validated) { - if (!api_pipe_auth_process(p, rpc_in)) - return False; - - if(!become_authenticated_pipe_user(p)) - return False; - - changed_user_id = True; - } - - for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { - if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && - api_fd_commands[i].fn != NULL) { - DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i].pipe_clnt_name)); - ret = api_fd_commands[i].fn(p, rpc_in); - } - } - - if(changed_user_id) - unbecome_authenticated_pipe_user(p); - - return ret; -} - -/**************************************************************************** - This function is the entry point to processing a DCE/RPC request. - All the data for the request (including RPC headers and authentication - verifiers) must be linearized in the input_data buffer, with a length - of data_len. - - The output is placed into the pipes_struct, and handed back to the - client on demand. -****************************************************************************/ - -BOOL rpc_command(pipes_struct *p, char *input_data, int data_len) -{ - prs_struct rpc_in; - BOOL reply = False; - - if (input_data == NULL) - return False; - - prs_init(&rpc_in, 0, 4, UNMARSHALL); - - /* - * Hand the data to the prs_struct, but don't let - * it own it. - */ - prs_give_memory( &rpc_in, input_data, (uint32)data_len, False); - - /* Unmarshall the rpc header */ - if(!smb_io_rpc_hdr("", &p->hdr, &rpc_in, 0)) { - DEBUG(0,("rpc_command: failed to unmarshall RPC_HDR.\n")); - return False; - } - - /* - * Create the response data buffer. - */ - - if(!pipe_init_outgoing_data(&p->out_data)) { - DEBUG(0,("rpc_command: failed to unmarshall RPC_HDR.\n")); - return False; - } - - switch (p->hdr.pkt_type) { - case RPC_BIND: - reply = api_pipe_bind_req(p, &rpc_in); - break; - case RPC_ALTCONT: - reply = api_pipe_altercontext_req(p, &rpc_in); - break; - case RPC_REQUEST: - if (p->ntlmssp_auth_requested && !p->ntlmssp_auth_validated) { - - /* authentication _was_ requested - and it failed. sorry, no deal! - */ - DEBUG(0,("rpc_command: RPC request received on pipe %s where \ -authentication failed. Denying the request.\n", p->name)); - reply = False; - } else { - /* read the RPC request header */ - if(!smb_io_rpc_hdr_req("req", &p->hdr_req, &rpc_in, 0)) { - DEBUG(0,("rpc_command: failed to unmarshall RPC_HDR_REQ.\n")); - return False; - } - reply = api_pipe_request(p, &rpc_in); - } - break; - case RPC_BINDRESP: /* not the real name! */ - reply = api_pipe_bind_auth_resp(p, &rpc_in); - break; - } - - if (!reply) { - DEBUG(3,("rpc_command: DCE/RPC fault sent on pipe %s\n", p->pipe_srv_name)); - reply = setup_fault_pdu(p); - } - - return reply; -} - - -/******************************************************************* - Calls the underlying RPC function for a named pipe. - ********************************************************************/ - -BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds, - prs_struct *rpc_in) -{ - int fn_num; - - /* interpret the command */ - DEBUG(4,("api_rpcTNP: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); - - for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) { - if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) { - DEBUG(3,("api_rpc_command: %s\n", api_rpc_cmds[fn_num].name)); - break; - } - } - - if (api_rpc_cmds[fn_num].name == NULL) { - DEBUG(4, ("unknown\n")); - return False; - } - - /* do the actual command */ - if(!api_rpc_cmds[fn_num].fn(p->vuid, rpc_in, &p->out_data.rdata)) { - DEBUG(0,("api_rpcTNP: %s: failed.\n", rpc_name)); - prs_mem_free(&p->out_data.rdata); - return False; - } - - DEBUG(5,("api_rpcTNP: called %s successfully\n", rpc_name)); - - return True; -} -- cgit From 32811abdf10bd499d3ea3d511f176528e2a04002 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 10 Mar 2000 17:03:04 +0000 Subject: restore the spoolss pipe as Jeremy replaced srv_pipe with the one from SAMBA_2_0 :-) J.F. (This used to be commit 34a3781961a5c41aba9929ec49aacc3bfa14270f) --- source3/rpc_server/srv_pipe.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 11822e7d03..9079590f31 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -475,6 +475,7 @@ static struct api_cmd api_fd_commands[] = #if 1 /* DISABLED_IN_2_0 JRATEST */ { "winreg", "winreg", api_reg_rpc }, #endif + { "spoolss", "spoolss", api_spoolss_rpc }, { NULL, NULL, NULL } }; -- cgit From 115d98e639b94fdd0773bfb9516af14d857c59d2 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 10 Mar 2000 17:06:12 +0000 Subject: removed unused variable J.F. (This used to be commit e2557ae5515ce30d0341ef7785cc4380266d4c94) --- source3/rpc_server/srv_pipe_hnd.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index c63390c35f..4c71433c2a 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -109,7 +109,6 @@ BOOL pipe_init_outgoing_data(output_data *o_data) static void attempt_remote_rpc_connect(pipes_struct *p) { struct user_creds usr; - struct msrpc_state *m; user_struct *vuser = get_valid_user_struct(p->vuid); p->m = NULL; -- cgit From e0ebb76a7453c07c16e8f736233226a774ab58e8 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 10 Mar 2000 17:12:24 +0000 Subject: getprinter level 0: was to short, found most of the fields, undocumented, undecoded, nothing in MSDN, but now it works :-) cleanup of error codes. fixed some dfs declarations function. J.F. (This used to be commit 87da4404aba29a2ebd999886e4c06958c96d3e05) --- source3/rpc_server/srv_spoolss_nt.c | 314 ++++++++++++++++++++++-------------- 1 file changed, 193 insertions(+), 121 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 41f37c3f74..9170b8afdd 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -72,7 +72,17 @@ typedef struct _Printer{ } client; } Printer_entry; +typedef struct _counter_printer_0 { + ubi_dlNode Next; + ubi_dlNode Prev; + + int snum; + uint32 counter; +} counter_printer_0; + static ubi_dlList Printer_list; +static ubi_dlList counter_list; + #define OPEN_HANDLE(pnum) ((pnum!=NULL) && (pnum->open!=False)) @@ -82,6 +92,7 @@ static ubi_dlList Printer_list; void init_printer_hnd(void) { ubi_dlInitList(&Printer_list); + ubi_dlInitList(&counter_list); } /**************************************************************************** @@ -1485,22 +1496,50 @@ uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, uint32 change, * construct_printer_info_0 * fill a printer_info_1 struct ********************************************************************/ -static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring servername) +static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, pstring servername) { pstring chaine; int count; NT_PRINTER_INFO_LEVEL ntprinter; - + counter_printer_0 *session_counter; + uint32 global_counter; + struct tm *t; + print_queue_struct *queue=NULL; print_status_struct status; + memset(&status, 0, sizeof(status)); if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0) - { - return (False); - } + return False; count=get_printqueue(snum, NULL, &queue, &status); + + /* check if we already have a counter for this printer */ + session_counter = (counter_printer_0 *)ubi_dlFirst(&counter_list); + + for(; session_counter; session_counter = (counter_printer_0 *)ubi_dlNext(session_counter)) { + if (session_counter->snum == snum) + break; + } + + /* it's the first time, add it to the list */ + if (session_counter==NULL) { + session_counter=(counter_printer_0 *)malloc(sizeof(counter_printer_0)); + ZERO_STRUCTP(session_counter); + session_counter->snum=snum; + session_counter->counter=0; + ubi_dlAddHead( &counter_list, (ubi_dlNode *)session_counter); + } + + /* increment it */ + session_counter->counter++; + + /* JFM: + * the global_counter should be stored in a TDB as it's common to all the clients + * and should be zeroed on samba startup + */ + global_counter=session_counter->counter; /* the description and the name are of the form \\server\share */ slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s",servername, ntprinter.info_2->printername); @@ -1511,36 +1550,48 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring s init_unistr(&(printer->servername), chaine); printer->cjobs = count; - printer->attributes = PRINTER_ATTRIBUTE_SHARED \ - | PRINTER_ATTRIBUTE_NETWORK \ - | PRINTER_ATTRIBUTE_RAW_ONLY ; - printer->unknown0 = 0x1; /* pointer */ - printer->unknown1 = 0x000A07CE; /* don't known */ - printer->unknown2 = 0x00020005; - printer->unknown3 = 0x0006000D; - printer->unknown4 = 0x02180026; - printer->unknown5 = 0x09; - printer->unknown6 = 0x36; - printer->majorversion = 0x0004; /* NT 4 */ - printer->buildversion = 0x0565; /* build 1381 */ - printer->unknown7 = 0x1; - printer->unknown8 = 0x0; - printer->unknown9 = 0x2; - printer->unknown10 = 0x3; - printer->unknown11 = 0x0; - printer->unknown12 = 0x0; - printer->unknown13 = 0x0; - printer->unknown14 = 0x1; - printer->unknown15 = 0x024a; /*586 Pentium ? */ - printer->unknown16 = 0x0; - printer->unknown17 = 0x423ed444; /* CacheChangeID */ - printer->unknown18 = 0x0; - printer->status = status.status; - printer->unknown20 = 0x0; - printer->unknown21 = 0x0648; - printer->unknown22 = 0x0; - printer->unknown23 = 0x5; - + printer->total_jobs = 0; + printer->total_bytes = 0; + + t=gmtime(&ntprinter.info_2->setuptime); + + printer->year = t->tm_year+1900; + printer->month = t->tm_mon+1; + printer->dayofweek = t->tm_wday; + printer->day = t->tm_mday; + printer->hour = t->tm_hour; + printer->minute = t->tm_min; + printer->second = t->tm_sec; + printer->milliseconds = 0; + + printer->global_counter = global_counter; + printer->total_pages = 0; + printer->major_version = 0x0004; /* NT 4 */ + printer->build_version = 0x0565; /* build 1381 */ + printer->unknown7 = 0x1; + printer->unknown8 = 0x0; + printer->unknown9 = 0x2; + printer->session_counter = session_counter->counter; + printer->unknown11 = 0x0; + printer->printer_errors = 0x0; /* number of print failure */ + printer->unknown13 = 0x0; + printer->unknown14 = 0x1; + printer->unknown15 = 0x024a; /* 586 Pentium ? */ + printer->unknown16 = 0x0; + printer->change_id = ntprinter.info_2->changeid; /* ChangeID in milliseconds*/ + printer->unknown18 = 0x0; + printer->status = status.status; + printer->unknown20 = 0x0; + printer->c_setprinter = ntprinter.info_2->c_setprinter; /* how many times setprinter has been called */ + printer->unknown22 = 0x0; + printer->unknown23 = 0x6; /* 6 ???*/ + printer->unknown24 = 0; /* unknown 24 to 26 are always 0 */ + printer->unknown25 = 0; + printer->unknown26 = 0; + printer->unknown27 = 0; + printer->unknown28 = 0; + printer->unknown29 = 0; + safe_free(queue); free_a_printer(ntprinter, 2); @@ -1640,52 +1691,57 @@ static void construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) * construct_printer_info_2 * fill a printer_info_2 struct ********************************************************************/ -static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring servername) +static BOOL construct_printer_info_2(pstring servername, PRINTER_INFO_2 *printer, int snum) { pstring chaine; + pstring chaine2; + pstring sl; int count; DEVICEMODE *devmode; NT_PRINTER_INFO_LEVEL ntprinter; - + print_queue_struct *queue=NULL; print_status_struct status; memset(&status, 0, sizeof(status)); - count=get_printqueue(snum, NULL, &queue, &status); if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) - { - return (False); - } - - snprintf(chaine, sizeof(chaine)-1, "\\\\%s", servername); - init_unistr(&(printer->servername), chaine); /* servername*/ - - snprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", servername, ntprinter.info_2->printername); - init_unistr(&(printer->printername), chaine); /* printername*/ + return False; + + memset(&status, 0, sizeof(status)); + count=get_printqueue(snum, NULL, &queue, &status); - init_unistr(&(printer->sharename), lp_servicename(snum)); /* sharename */ + snprintf(chaine, sizeof(chaine)-1, "%s", servername); - init_unistr(&(printer->portname), lp_servicename(snum)); /* port */ - init_unistr(&(printer->drivername), ntprinter.info_2->drivername); /* drivername */ - - init_unistr(&(printer->comment), ntprinter.info_2->comment); /* comment */ - init_unistr(&(printer->location), ntprinter.info_2->location); /* location */ - init_unistr(&(printer->sepfile), ntprinter.info_2->sepfile); /* separator file */ - init_unistr(&(printer->printprocessor), ntprinter.info_2->printprocessor);/* print processor */ - init_unistr(&(printer->datatype), ntprinter.info_2->datatype); /* datatype */ - init_unistr(&(printer->parameters), ntprinter.info_2->parameters); /* parameters (of print processor) */ + if (strlen(servername)!=0) + fstrcpy(sl, "\\"); + else + fstrcpy(sl, '\0'); + + snprintf(chaine2, sizeof(chaine)-1, "%s%s%s", servername, sl, ntprinter.info_2->printername); + + init_unistr(&printer->servername, chaine); /* servername*/ + init_unistr(&printer->printername, chaine2); /* printername*/ + init_unistr(&printer->sharename, lp_servicename(snum)); /* sharename */ + init_unistr(&printer->portname, lp_servicename(snum)); /* port */ + init_unistr(&printer->drivername, ntprinter.info_2->drivername); /* drivername */ + init_unistr(&printer->comment, lp_comment(snum)); /* comment */ + init_unistr(&printer->location, ntprinter.info_2->location); /* location */ + init_unistr(&printer->sepfile, ntprinter.info_2->sepfile); /* separator file */ + init_unistr(&printer->printprocessor, ntprinter.info_2->printprocessor);/* print processor */ + init_unistr(&printer->datatype, ntprinter.info_2->datatype); /* datatype */ + init_unistr(&printer->parameters, ntprinter.info_2->parameters); /* parameters (of print processor) */ printer->attributes = PRINTER_ATTRIBUTE_SHARED \ - | PRINTER_ATTRIBUTE_NETWORK \ - | PRINTER_ATTRIBUTE_RAW_ONLY ; /* attributes */ - - printer->priority = ntprinter.info_2->priority; /* priority */ - printer->defaultpriority = ntprinter.info_2->default_priority; /* default priority */ - printer->starttime = ntprinter.info_2->starttime; /* starttime */ - printer->untiltime = ntprinter.info_2->untiltime; /* untiltime */ - printer->status = status.status; /* status */ - printer->cjobs = count; /* jobs */ - printer->averageppm = ntprinter.info_2->averageppm; /* average pages per minute */ + | PRINTER_ATTRIBUTE_LOCAL \ + | PRINTER_ATTRIBUTE_RAW_ONLY ; /* attributes */ + + printer->priority = ntprinter.info_2->priority; /* priority */ + printer->defaultpriority = ntprinter.info_2->default_priority; /* default priority */ + printer->starttime = ntprinter.info_2->starttime; /* starttime */ + printer->untiltime = ntprinter.info_2->untiltime; /* untiltime */ + printer->status = status.status; /* status */ + printer->cjobs = count; /* jobs */ + printer->averageppm = ntprinter.info_2->averageppm; /* average pages per minute */ devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE)); ZERO_STRUCTP(devmode); @@ -1694,29 +1750,7 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum, pstring safe_free(queue); free_a_printer(ntprinter, 2); - return (True); -} - -/******************************************************************** - * enum_printer_info_2 - * glue between spoolss_enumprinters and construct_printer_info_2 - ********************************************************************/ -static BOOL get_printer_info_2(PRINTER_INFO_2 **printer, int snum, int number) -{ - pstring servername; - - *printer=(PRINTER_INFO_2 *)malloc(sizeof(PRINTER_INFO_2)); - DEBUG(4,("Allocated memory for ONE PRINTER_INFO_2 at [%p]\n", *printer)); - pstrcpy(servername, global_myname); - if (!construct_printer_info_2(*printer, snum, servername)) - { - free(*printer); - return (False); - } - else - { - return (True); - } + return True; } /******************************************************************** @@ -1736,8 +1770,7 @@ static BOOL enum_all_printers_info_1(fstring server, uint32 flags, NEW_BUFFER *b if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); - if (construct_printer_info_1(server, flags, ¤t_prt, snum)) - { + if (construct_printer_info_1(server, flags, ¤t_prt, snum)) { printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1)); DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned)); memcpy(&(printers[*returned]), ¤t_prt, sizeof(PRINTER_INFO_1)); @@ -1781,10 +1814,10 @@ static BOOL enum_all_printers_info_1_local(fstring name, NEW_BUFFER *buffer, uin if (!strcmp(name, temp)) { fstrcat(temp, "\\"); - enum_all_printers_info_1(temp, PRINTER_ENUM_ICON8, buffer, offered, needed, returned); + return enum_all_printers_info_1(temp, PRINTER_ENUM_ICON8, buffer, offered, needed, returned); } else - enum_all_printers_info_1("", PRINTER_ENUM_ICON8, buffer, offered, needed, returned); + return enum_all_printers_info_1("", PRINTER_ENUM_ICON8, buffer, offered, needed, returned); } /******************************************************************** @@ -1800,7 +1833,7 @@ static BOOL enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, uint if (!strcmp(name, temp)) { fstrcat(temp, "\\"); - enum_all_printers_info_1(temp, PRINTER_ENUM_ICON8, buffer, offered, needed, returned); + return enum_all_printers_info_1(temp, PRINTER_ENUM_ICON8, buffer, offered, needed, returned); } else return ERROR_INVALID_NAME; @@ -1840,8 +1873,10 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui /* check the required size. */ *needed += spoolss_size_printer_info_1(printer); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(printer); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the structures */ new_smb_io_printer_info_1("", buffer, printer, 0); @@ -1868,7 +1903,7 @@ static BOOL enum_all_printers_info_1_network(fstring name, NEW_BUFFER *buffer, u fstrcpy(temp, "\\\\"); fstrcat(temp, global_myname); fstrcat(temp, "\\"); - enum_all_printers_info_1(temp, PRINTER_ENUM_UNKNOWN_8, buffer, offered, needed, returned); + return enum_all_printers_info_1(temp, PRINTER_ENUM_UNKNOWN_8, buffer, offered, needed, returned); } /******************************************************************** @@ -1876,38 +1911,40 @@ static BOOL enum_all_printers_info_1_network(fstring name, NEW_BUFFER *buffer, u * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static BOOL enum_all_printers_info_2(fstring servername, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int snum; int i; int n_services=lp_numservices(); - PRINTER_INFO_2 **printers=NULL; + PRINTER_INFO_2 *printers=NULL; + PRINTER_INFO_2 current_prt; for (snum=0; snum offered) { *returned=0; @@ -1948,7 +1985,33 @@ static uint32 enumprinters_level2( uint32 flags, fstring servername, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - return enum_all_printers_info_2(buffer, offered, needed, returned); + fstring temp; + + fstrcpy(temp, "\\\\"); + fstrcat(temp, global_myname); + + if (flags & PRINTER_ENUM_LOCAL) { + if (!strcmp(servername, temp)) { + fstrcat(temp, "\\"); + return enum_all_printers_info_2(temp, buffer, offered, needed, returned); + } + else + return enum_all_printers_info_2("", buffer, offered, needed, returned); + } + + if (flags & PRINTER_ENUM_NAME) { + if (!strcmp(servername, temp)) { + fstrcat(temp, "\\"); + return enum_all_printers_info_2(temp, buffer, offered, needed, returned); + } + else + return ERROR_INVALID_NAME; + } + + if (flags & PRINTER_ENUM_REMOTE) + return ERROR_INVALID_LEVEL; + + return NT_STATUS_NO_PROBLEMO; } /******************************************************************** @@ -2018,13 +2081,16 @@ static uint32 getprinter_level_0(pstring servername, int snum, NEW_BUFFER *buffe PRINTER_INFO_0 *printer=NULL; printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0)); + construct_printer_info_0(printer, snum, servername); /* check the required size. */ *needed += spoolss_size_printer_info_0(printer); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(printer); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the structures */ new_smb_io_printer_info_0("", buffer, printer, 0); @@ -2051,8 +2117,10 @@ static uint32 getprinter_level_1(pstring servername, int snum, NEW_BUFFER *buffe /* check the required size. */ *needed += spoolss_size_printer_info_1(printer); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(printer); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the structures */ new_smb_io_printer_info_1("", buffer, printer, 0); @@ -2072,15 +2140,21 @@ static uint32 getprinter_level_1(pstring servername, int snum, NEW_BUFFER *buffe static uint32 getprinter_level_2(pstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_2 *printer=NULL; + fstring temp; - printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)); - construct_printer_info_2(printer, snum, servername); + printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)); + + fstrcpy(temp, "\\\\"); + fstrcat(temp, servername); + construct_printer_info_2(temp, printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_2(printer); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(printer); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the structures */ new_smb_io_printer_info_2("", buffer, printer, 0); @@ -2108,9 +2182,7 @@ uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, pstrcpy(servername, global_myname); if (!get_printer_snum(handle, &snum)) - { return NT_STATUS_INVALID_HANDLE; - } switch (level) { case 0: @@ -2123,7 +2195,7 @@ uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, return getprinter_level_2(servername,snum, buffer, offered, needed); break; default: - return NT_STATUS_INVALID_LEVEL; + return ERROR_INVALID_LEVEL; break; } } @@ -3617,11 +3689,11 @@ uint32 _spoolss_getprinterdriverdirectory(UNISTR2 *name, UNISTR2 *uni_environmen /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 index, +uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, uint32 in_value_len, uint32 in_data_len, uint32 *out_max_value_len, uint16 **out_value, uint32 *out_value_len, uint32 *out_type, - uint32 *out_max_data_len, uint8 **out_data, uint32 *out_data_len) + uint32 *out_max_data_len, uint8 **data_out, uint32 *out_data_len) { NT_PRINTER_INFO_LEVEL printer; @@ -3645,7 +3717,7 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 index, *out_type=0; *out_max_data_len=0; - *out_data=NULL; + *data_out=NULL; *out_data_len=0; DEBUG(5,("spoolss_enumprinterdata\n")); @@ -3696,7 +3768,7 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 index, * that's the number of bytes not the number of unicode chars */ - if (!get_specific_param_by_index(printer, 2, index, value, &data, &type, &data_len)) { + if (!get_specific_param_by_index(printer, 2, idx, value, &data, &type, &data_len)) { free_a_printer(printer, 2); return ERROR_NO_MORE_ITEMS; } @@ -3719,7 +3791,7 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 index, /* the data is counted in bytes */ *out_max_data_len=in_data_len; - *out_data=(uint8 *)malloc(in_data_len*sizeof(uint8)); + *data_out=(uint8 *)malloc(in_data_len*sizeof(uint8)); memcpy(*out_data, data, data_len); *out_data_len=data_len; -- cgit From 5e22394654eba2ed5d01e81b165a044a59dd65ab Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 10 Mar 2000 19:50:03 +0000 Subject: Fixups for compiles with gcc flags -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual Partially implemented rpc daemon redirect (needs more work). Jeremy. (This used to be commit a462191698fa589ceac4afd14c652adf699eccad) --- source3/rpc_server/srv_pipe.c | 27 ------- source3/rpc_server/srv_pipe_hnd.c | 148 ++++++++++++++++++++++++++++-------- source3/rpc_server/srv_spoolss_nt.c | 3 + 3 files changed, 118 insertions(+), 60 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 9079590f31..9a17862bd5 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -492,15 +492,6 @@ BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *rpc_in_p) DEBUG(5,("api_pipe_bind_auth_resp: decode request. %d\n", __LINE__)); - /* - * Create the response data buffer. - */ - - if(!pipe_init_outgoing_data(&p->out_data)) { - DEBUG(0,("api_pipe_bind_auth_resp: failed to create outgoing buffer.\n")); - return False; - } - if (p->hdr.auth_len == 0) { DEBUG(0,("api_pipe_bind_auth_resp: No auth field sent !\n")); return False; @@ -695,15 +686,6 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); - /* - * Create the response data buffer. - */ - - if(!pipe_init_outgoing_data(&p->out_data)) { - DEBUG(0,("api_pipe_bind_req: failed to create outgoing buffer.\n")); - return False; - } - /* * Try and find the correct pipe name to ensure * that this is a pipe name we support. @@ -1062,15 +1044,6 @@ BOOL api_pipe_request(pipes_struct *p) BOOL ret = False; BOOL changed_user_id = False; - /* - * Create the response data buffer. - */ - - if(!pipe_init_outgoing_data(&p->out_data)) { - DEBUG(0,("api_pipe_request: failed to create outgoing buffer.\n")); - return False; - } - if (p->ntlmssp_auth_validated) { if(!become_authenticated_pipe_user(p)) { diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 4c71433c2a..fdee90e8ae 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -77,8 +77,12 @@ void init_rpc_pipe_hnd(void) Initialise an outgoing packet. ****************************************************************************/ -BOOL pipe_init_outgoing_data(output_data *o_data) +static BOOL pipe_init_outgoing_data(output_data *o_data, uint32 len) { + /* Reset the offset counters. */ + o_data->data_sent_length = 0; + o_data->current_pdu_len = 0; + o_data->current_pdu_sent = 0; memset(o_data->current_pdu, '\0', sizeof(o_data->current_pdu)); @@ -89,21 +93,16 @@ BOOL pipe_init_outgoing_data(output_data *o_data) * Initialize the outgoing RPC data buffer. * we will use this as the raw data area for replying to rpc requests. */ - if(!prs_init(&o_data->rdata, MAX_PDU_FRAG_LEN, 4, MARSHALL)) { + if(!prs_init(&o_data->rdata, len, 4, MARSHALL)) { DEBUG(0,("pipe_init_outgoing_data: malloc fail.\n")); return False; } - /* Reset the offset counters. */ - o_data->data_sent_length = 0; - o_data->current_pdu_len = 0; - o_data->current_pdu_sent = 0; - return True; } /**************************************************************************** - HACK !!! Attempt to find a remote process to communicate RPC's with. + Attempt to find a remote process to communicate RPC's with. ****************************************************************************/ static void attempt_remote_rpc_connect(pipes_struct *p) @@ -254,7 +253,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, fstrcpy(p->name, pipe_name); /* - * HACK !!! For Luke - attempt to connect to RPC redirect process. + * For Luke - attempt to connect to RPC redirect process. */ attempt_remote_rpc_connect(p); @@ -464,7 +463,7 @@ authentication failed. Denying the request.\n", p->name)); } if(p->hdr.flags & RPC_FLG_LAST) { - BOOL ret; + BOOL ret = False; /* * Ok - we finally have a complete RPC stream. * Call the rpc command to process it. @@ -482,7 +481,8 @@ authentication failed. Denying the request.\n", p->name)); * Process the complete data stream here. */ - ret = api_pipe_request(p); + if(pipe_init_outgoing_data(&p->out_data, MAX_PDU_FRAG_LEN)) + ret = api_pipe_request(p); /* * We have consumed the whole data stream. Set back to @@ -532,13 +532,15 @@ static ssize_t process_complete_pdu(pipes_struct *p) /* * We assume that a pipe bind is only in one pdu. */ - reply = api_pipe_bind_req(p, &rpc_in); + if(pipe_init_outgoing_data(&p->out_data, MAX_PDU_FRAG_LEN)) + reply = api_pipe_bind_req(p, &rpc_in); break; case RPC_BINDRESP: /* * We assume that a pipe bind_resp is only in one pdu. */ - reply = api_pipe_bind_auth_resp(p, &rpc_in); + if(pipe_init_outgoing_data(&p->out_data, MAX_PDU_FRAG_LEN)) + reply = api_pipe_bind_auth_resp(p, &rpc_in); break; case RPC_REQUEST: reply = process_request_pdu(p, &rpc_in); @@ -661,7 +663,14 @@ ssize_t write_to_pipe(pipes_struct *p, char *data, size_t n) DEBUG(10,("write_to_pipe: data_left = %u\n", (unsigned int)data_left )); - data_used = process_incoming_data(p, data, data_left); + /* + * Deal with the redirect to the remote RPC daemon. + */ + + if(p->m) + data_used = write(p->m->fd, data, data_left); + else + data_used = process_incoming_data(p, data, data_left); DEBUG(10,("write_to_pipe: data_used = %d\n", (int)data_used )); @@ -675,9 +684,72 @@ ssize_t write_to_pipe(pipes_struct *p, char *data, size_t n) return n; } +/**************************************************************************** + Gets data from a remote TNG daemon. Gets data from the remote daemon into + the outgoing prs_struct. + + NB. Note to Luke : This code will be broken until Luke implements a length + field before reply data... + +****************************************************************************/ + +static BOOL read_from_remote(pipes_struct *p) +{ + uint32 data_len; + uint32 data_len_left; + + if(prs_offset(&p->out_data.rdata) == 0) { + + ssize_t len = 0; + + /* + * Read all the reply data as a stream of pre-created + * PDU's from the remote deamon into the rdata struct. + */ + + /* + * Create the response data buffer. + */ + + if(!pipe_init_outgoing_data(&p->out_data, 65536)) { + DEBUG(0,("read_from_remote: failed to create outgoing buffer.\n")); + return False; + } + + /* Read from remote here. */ + if((len = read_with_timeout(p->m->fd, prs_data_p(&p->out_data.rdata), 1, 65536, 10000)) < 0) { + DEBUG(0,("read_from_remote: failed to read from external daemon.\n")); + prs_mem_free(&p->out_data.rdata); + return False; + } + + /* Set the length we got. */ + prs_set_offset(&p->out_data.rdata, (uint32)len); + } + + /* + * The amount we send is the minimum of the available + * space and the amount left to send. + */ + + data_len_left = prs_offset(&p->out_data.rdata) - p->out_data.data_sent_length; + + /* + * Ensure there really is data left to send. + */ + + if(!data_len_left) { + DEBUG(0,("read_from_remote: no data left to send !\n")); + return False; + } + + data_len = MIN(data_len_left, MAX_PDU_FRAG_LEN); + + return False; /* Notfinished... */ +} /**************************************************************************** - Replyies to a request to read data from a pipe. + Replies to a request to read data from a pipe. Headers are interspersed with the data at PDU intervals. By the time this function is called, the start of the data could possibly have been @@ -685,13 +757,12 @@ ssize_t write_to_pipe(pipes_struct *p, char *data, size_t n) Calling create_rpc_reply() here is a hack. The data should already have been prepared into arrays of headers + data stream sections. +****************************************************************************/ - ****************************************************************************/ - -int read_from_pipe(pipes_struct *p, char *data, int n) +ssize_t read_from_pipe(pipes_struct *p, char *data, size_t n) { uint32 pdu_remaining = 0; - int data_returned = 0; + ssize_t data_returned = 0; if (!p || !p->open) { DEBUG(0,("read_from_pipe: pipe not open\n")); @@ -700,7 +771,7 @@ int read_from_pipe(pipes_struct *p, char *data, int n) DEBUG(6,("read_from_pipe: %x", p->pnum)); - DEBUG(6,(" name: %s len: %d\n", p->name, n)); + DEBUG(6,(" name: %s len: %u\n", p->name, (unsigned int)n)); /* * We cannot return more than one PDU length per @@ -708,8 +779,8 @@ int read_from_pipe(pipes_struct *p, char *data, int n) */ if(n > MAX_PDU_FRAG_LEN) { - DEBUG(0,("read_from_pipe: loo large read (%d) requested on pipe %s. We can \ -only service %d sized reads.\n", n, p->name, 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; } @@ -722,7 +793,7 @@ only service %d sized reads.\n", n, p->name, MAX_PDU_FRAG_LEN )); */ if((pdu_remaining = p->out_data.current_pdu_len - p->out_data.current_pdu_sent) > 0) { - data_returned = MIN(n, pdu_remaining); + data_returned = (ssize_t)MIN(n, pdu_remaining); DEBUG(10,("read_from_pipe: %s: current_pdu_len = %u, current_pdu_sent = %u \ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, @@ -749,17 +820,28 @@ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, return 0; } - /* - * We need to create a new PDU from the data left in p->rdata. - * Create the header/data/footers. This also sets up the fields - * p->current_pdu_len, p->current_pdu_sent, p->data_sent_length - * and stores the outgoing PDU in p->current_pdu. - */ + if(p->m) { + /* + * Remote to the RPC daemon. + */ + if(!read_from_remote(p)) { + DEBUG(0,("read_from_pipe: %s: read_from_remote failed.\n", p->name )); + return -1; + } - if(!create_next_pdu(p)) { - DEBUG(0,("read_from_pipe: %s: create_next_pdu failed.\n", - p->name)); - return -1; + } else { + + /* + * We need to create a new PDU from the data left in p->rdata. + * Create the header/data/footers. This also sets up the fields + * p->current_pdu_len, p->current_pdu_sent, p->data_sent_length + * and stores the outgoing PDU in p->current_pdu. + */ + + if(!create_next_pdu(p)) { + DEBUG(0,("read_from_pipe: %s: create_next_pdu failed.\n", p->name)); + return -1; + } } data_returned = MIN(n, p->out_data.current_pdu_len); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 9170b8afdd..b4aefe44c1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4140,6 +4140,8 @@ static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uin /**************************************************************************** ****************************************************************************/ +#if 0 +... Not yet used... static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { int i=0; @@ -4179,6 +4181,7 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin else return NT_STATUS_NO_PROBLEMO; } +#endif /**************************************************************************** ****************************************************************************/ -- cgit From 7b97d056a1deae9e885765153f596e8e30e334b1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 11 Mar 2000 01:02:45 +0000 Subject: You *must* use O_EXCL when using mktemp (security issue). Glad this code never shipped :-). This is not a problem in 2.0.x. Jeremy. (This used to be commit a0c302f4d03ab07d697115fa8520d0cb0b2ba616) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b4aefe44c1..ef0b7fad9b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2596,7 +2596,7 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, slprintf(tempname,sizeof(tempname)-1, "%s/smb_print.XXXXXX",lp_pathname(snum)); pstrcpy(fname, (char *)mktemp(tempname)); - fd=open(fname, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR ); + fd=open(fname, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, S_IRUSR|S_IWUSR ); DEBUG(4,("Temp spool file created: [%s]\n", fname)); Printer->current_jobid=fd; -- cgit From 79bfb14318423f5a26a4d0dc6fc6faa62b1401f8 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 13 Mar 2000 11:09:20 +0000 Subject: parse correctly getprinterdriver2 found a stupid bug in enumprinters fixed some memleaks found a coredump in enumprinterdata getprinterdriverdir responds correctly now. J.F. (This used to be commit 07f2e194ba61e72320636fb7e5d0f041e255868b) --- source3/rpc_server/srv_spoolss.c | 5 ++- source3/rpc_server/srv_spoolss_nt.c | 85 +++++++++++++++++++------------------ 2 files changed, 46 insertions(+), 44 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 75493b7a30..1cf187d825 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -286,9 +286,10 @@ static BOOL api_spoolss_getprinterdriver2(uint16 vuid, prs_struct *data, prs_str /* that's an [in out] buffer */ new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - r_u.status = _spoolss_getprinterdriver2(&q_u.handle, &q_u.architecture, q_u.level, q_u.unknown, + r_u.status = _spoolss_getprinterdriver2(&q_u.handle, &q_u.architecture, q_u.level, + q_u.clientmajorversion, q_u.clientminorversion, r_u.buffer, q_u.offered, - &r_u.needed, &r_u.unknown0, &r_u.unknown1); + &r_u.needed, &r_u.servermajorversion, &r_u.serverminorversion); if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n")); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ef0b7fad9b..d0fc839154 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1991,19 +1991,15 @@ static uint32 enumprinters_level2( uint32 flags, fstring servername, fstrcat(temp, global_myname); if (flags & PRINTER_ENUM_LOCAL) { - if (!strcmp(servername, temp)) { - fstrcat(temp, "\\"); + if (!strcmp(servername, temp)) return enum_all_printers_info_2(temp, buffer, offered, needed, returned); - } else return enum_all_printers_info_2("", buffer, offered, needed, returned); } if (flags & PRINTER_ENUM_NAME) { - if (!strcmp(servername, temp)) { - fstrcat(temp, "\\"); + if (!strcmp(servername, temp)) return enum_all_printers_info_2(temp, buffer, offered, needed, returned); - } else return ERROR_INVALID_NAME; } @@ -2055,6 +2051,7 @@ uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 le */ unistr2_to_ascii(name, servername, sizeof(name)-1); + strupper(name); switch (level) { case 1: @@ -2391,8 +2388,10 @@ static uint32 getprinterdriver2_level1(pstring servername, pstring architecture, /* check the required size. */ *needed += spoolss_size_printer_driver_info_1(info); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(info); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the structures */ new_smb_io_printer_driver_info_1("", buffer, info, 0); @@ -2400,9 +2399,8 @@ static uint32 getprinterdriver2_level1(pstring servername, pstring architecture, /* clear memory */ safe_free(info); - if (*needed > offered) { + if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; - } else return NT_STATUS_NO_PROBLEMO; } @@ -2420,8 +2418,10 @@ static uint32 getprinterdriver2_level2(pstring servername, pstring architecture, /* check the required size. */ *needed += spoolss_size_printer_driver_info_2(info); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(info); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the structures */ new_smb_io_printer_driver_info_2("", buffer, info, 0); @@ -2429,9 +2429,8 @@ static uint32 getprinterdriver2_level2(pstring servername, pstring architecture, /* clear memory */ safe_free(info); - if (*needed > offered) { + if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; - } else return NT_STATUS_NO_PROBLEMO; } @@ -2449,8 +2448,10 @@ static uint32 getprinterdriver2_level3(pstring servername, pstring architecture, /* check the required size. */ *needed += spoolss_size_printer_driver_info_3(info); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(info); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the structures */ new_smb_io_printer_driver_info_3("", buffer, info, 0); @@ -2458,18 +2459,18 @@ static uint32 getprinterdriver2_level3(pstring servername, pstring architecture, /* clear memory */ safe_free(info); - if (*needed > offered) { + if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; - } else return NT_STATUS_NO_PROBLEMO; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level, uint32 unknown, +uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level, + uint32 clientmajorversion, uint32 clientminorversion, NEW_BUFFER *buffer, uint32 offered, - uint32 *needed, uint32 *unknown0, uint32 *unknown1) + uint32 *needed, uint32 *servermajorversion, uint32 *serverminorversion) { pstring servername; fstring architecture; @@ -2478,16 +2479,14 @@ uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_a DEBUG(4,("_spoolss_getprinterdriver2\n")); *needed=0; - *unknown0=0; - *unknown1=0; + *servermajorversion=0; + *serverminorversion=0; pstrcpy(servername, global_myname); unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); if (!get_printer_snum(handle, &snum)) - { return NT_STATUS_INVALID_HANDLE; - } switch (level) { case 1: @@ -3381,8 +3380,10 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, *needed=buffer_size; - if (!alloc_buffer_size(buffer, buffer_size)) + if (!alloc_buffer_size(buffer, buffer_size)){ + safe_free(list); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the form structures */ for (i=0; i<*numofforms; i++) @@ -3400,7 +3401,7 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, default: safe_free(list); - return NT_STATUS_INVALID_INFO_CLASS; + return ERROR_INVALID_LEVEL; } } @@ -3441,8 +3442,7 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need ports=(PORT_INFO_1 *)malloc( (*returned+1) * sizeof(PORT_INFO_1) ); - for (snum=0; snum Date: Mon, 13 Mar 2000 15:53:02 +0000 Subject: small fix for addprinterex at level 2 I have some network dumps at level 1, but quoting MSDN: "Level [in] Specifies the version of the structure to which pPrinter points. This value must be 2." I like NT so much :-) J.F. (This used to be commit fbf40c6a9140a27e773d59eaf056c9e25659d9b8) --- source3/rpc_server/srv_spoolss_nt.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d0fc839154..340d776493 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3581,30 +3581,28 @@ uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level, /* convert from UNICODE to ASCII */ convert_printer_info(info, &printer, level); - unistr2_to_ascii(share_name, &((info->info_2)->portname), sizeof(share_name)-1); + unistr2_to_ascii(share_name, &((info->info_2)->printername), sizeof(share_name)-1); slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname, share_name); + /* write the ASCII on disk */ + if (add_a_printer(printer, level) != 0x0) + return ERROR_ACCESS_DENIED; + create_printer_hnd(handle); open_printer_hnd(handle); if (!set_printer_hnd_printertype(handle, name)) { close_printer_handle(handle); - return NT_STATUS_ACCESS_DENIED; + return ERROR_ACCESS_DENIED; } - + if (!set_printer_hnd_printername(handle, name)) { close_printer_handle(handle); - return NT_STATUS_ACCESS_DENIED; + return ERROR_ACCESS_DENIED; } - /* write the ASCII on disk */ - if (add_a_printer(printer, level) != 0x0) { - close_printer_handle(handle); - return NT_STATUS_ACCESS_DENIED; - } - return NT_STATUS_NO_PROBLEMO; } -- cgit From c5fbb293a8fe2cc2251ffa0d46c79a2d247f7d9a Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 13 Mar 2000 19:34:04 +0000 Subject: oops ! forgot smb.h in last commit added info level 1 parsing code for addprinter(ex) J.F. (This used to be commit 4847f7b17b2d23e4efd4e7cae6bfcfc2319b9409) --- source3/rpc_server/srv_spoolss.c | 11 +++++++++++ source3/rpc_server/srv_spoolss_nt.c | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 1cf187d825..1649df8608 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -759,6 +759,17 @@ static BOOL api_spoolss_addprinterex(uint16 vuid, prs_struct *data, prs_struct * return False; } + if (q_u.info.info_ptr!=0) { + switch (q_u.info.level) { + case 1: + safe_free(q_u.info.info_1); + break; + case 2: + safe_free(q_u.info.info_2); + break; + } + } + return True; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 340d776493..de994a1b5d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2855,9 +2855,10 @@ uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, case 2: return update_printer(handle, level, info, devmode_ctr.devmode); break; + default: + return ERROR_INVALID_LEVEL; + break; } - - return NT_STATUS_INVALID_INFO_CLASS; } /**************************************************************************** -- cgit From 4d439771302ec46225f31e8fa26f62ec30df6d1d Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Thu, 16 Mar 2000 16:23:38 +0000 Subject: fix a bug in enumprinterdrivers J.F. (This used to be commit a8d04c26da601cb97e66c27c7ad21dd672fcec2d) --- source3/rpc_server/srv_spoolss_nt.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index de994a1b5d..8f1bcef9f3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3189,8 +3189,10 @@ static uint32 enumprinterdrivers_level1(fstring *list, fstring servername, fstri *needed += spoolss_size_printer_driver_info_1(&(driver_info_1[i])); } - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(driver_info_1); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the form structures */ for (i=0; i<*returned; i++) @@ -3199,10 +3201,12 @@ static uint32 enumprinterdrivers_level1(fstring *list, fstring servername, fstri new_smb_io_printer_driver_info_1("", buffer, &(driver_info_1[i]), 0); } - safe_free(list); + safe_free(driver_info_1); - if (*needed > offered) + if (*needed > offered) { + *returned=0; return ERROR_INSUFFICIENT_BUFFER; + } else return NT_STATUS_NO_PROBLEMO; } @@ -3230,8 +3234,10 @@ static uint32 enumprinterdrivers_level2(fstring *list, fstring servername, fstri *needed += spoolss_size_printer_driver_info_2(&(driver_info_2[i])); } - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(driver_info_2); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the form structures */ for (i=0; i<*returned; i++) @@ -3240,10 +3246,12 @@ static uint32 enumprinterdrivers_level2(fstring *list, fstring servername, fstri new_smb_io_printer_driver_info_2("", buffer, &(driver_info_2[i]), 0); } - safe_free(list); + safe_free(driver_info_2); - if (*needed > offered) + if (*needed > offered) { + *returned=0; return ERROR_INSUFFICIENT_BUFFER; + } else return NT_STATUS_NO_PROBLEMO; } -- cgit From d1ac0e95e4082f6906df77ed80fdd319df78ad4e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 21 Mar 2000 18:33:08 +0000 Subject: Added preliminary user list code from HP. Needs to be made dynamic and backended with a tdb database so the list can be shared between multiple smbds. ToDO. Jermey. (This used to be commit 171222ce22595743a052e5c3d4428ce916d7c345) --- source3/rpc_server/srv_samr.c | 272 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 252 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 169dc2169e..a99e2a2734 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -6,6 +6,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. + * Copyright (C) Hewlett-Packard Company 1999. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,18 +57,15 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, if (pw_buf == NULL) return False; vp = startsmbpwent(False); - if (!vp) - { + if (!vp) { DEBUG(0, ("get_sampwd_entries: Unable to open SMB password database.\n")); return False; } - while (((pwd = getsam21pwent(vp)) != NULL) && (*num_entries) < max_num_entries) - { + while (((pwd = getsam21pwent(vp)) != NULL) && (*num_entries) < max_num_entries) { int user_name_len; - if (start_idx > 0) - { + if (start_idx > 0) { /* skip the requested number of entries. not very efficient, but hey... */ @@ -82,8 +80,7 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, 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) - { + if (pwd->smb_nt_passwd != NULL) { memcpy( pw_buf[(*num_entries)].nt_pwd , pwd->smb_nt_passwd, 16); } @@ -93,13 +90,10 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, (*num_entries), pwd->smb_name, pwd->user_rid, pwd->acct_ctrl)); - if (acb_mask == 0 || IS_BITS_SET_SOME(pwd->acct_ctrl, acb_mask)) - { + if (acb_mask == 0 || IS_BITS_SET_SOME(pwd->acct_ctrl, acb_mask)) { DEBUG(5,(" acb_mask %x accepts\n", acb_mask)); (*num_entries)++; - } - else - { + } else { DEBUG(5,(" acb_mask %x rejects\n", acb_mask)); } @@ -111,6 +105,232 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, return (*num_entries) > 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 + map_username() function.) Since more than one DOS name can map + to the UNIX name, to reverse the mapping you have to specify + which corresponding DOS name you want; that's where the name_idx + parameter comes in. Returns the string requested or NULL if it + fails or can't complete the request for any reason. This doesn't + handle group names (starting with '@') or names starting with + '+' or '&'. If they are encountered, they are skipped. +********************************************************************/ + +static char *unmap_unixname(char *unix_user_name, int name_idx) +{ + FILE *f; + char *mapfile = lp_username_map(); + char *s; + pstring buf; + static pstring tok; + + if (!*unix_user_name) return NULL; + if (!*mapfile) return NULL; + + f = sys_fopen(mapfile,"r"); + if (!f) { + DEBUG(0,("unmap_unixname: can't open username map %s\n", mapfile)); + return NULL; + } + + DEBUG(5,("unmap_unixname: scanning username map %s, index: %d\n", mapfile, name_idx)); + + while((s=fgets_slash(buf,sizeof(buf),f))!=NULL) { + char *unixname = s; + char *dosname = strchr(unixname,'='); + + if (!dosname) + continue; + + *dosname++ = 0; + + while (isspace(*unixname)) + unixname++; + if ('!' == *unixname) { + unixname++; + while (*unixname && isspace(*unixname)) + unixname++; + } + + if (!*unixname || strchr("#;",*unixname)) + continue; + + if (strncmp(unixname, unix_user_name, strlen(unix_user_name))) + continue; + + /* We have matched the UNIX user name */ + + while(next_token(&dosname, tok, LIST_SEP, sizeof(tok))) { + if (!strchr("@&+", *tok)) { + name_idx--; + if (name_idx < 0 ) { + break; + } + } + } + + if (name_idx >= 0) { + DEBUG(0,("unmap_unixname: index too high - not that many DOS names\n")); + fclose(f); + return NULL; + } else { + fclose(f); + return tok; + } + } + + DEBUG(0,("unmap_unixname: Couldn't find the UNIX user name\n")); + fclose(f); + return NULL; +} + +/******************************************************************* + This function sets up a list of users taken from the list of + users that UNIX knows about, as well as all the user names that + Samba maps to a valid UNIX user name. (This should work with + /etc/passwd or NIS.) +********************************************************************/ + +static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, + int start_idx, + int *total_entries, int *num_entries, + int max_num_entries, + uint16 acb_mask) +{ + static struct passwd *pwd = NULL; + static uint32 pw_rid; + static BOOL orig_done = False; + static int current_idx = 0; + static int mapped_idx = 0; + + DEBUG(5, ("get_passwd_entries: retrieving a list of UNIX users\n")); + + (*num_entries) = 0; + (*total_entries) = 0; + + if (pw_buf == NULL) return False; + + if (current_idx == 0) { + setpwent(); + } + + /* These two cases are inefficient, but should be called very rarely */ + /* they are the cases where the starting index isn't picking up */ + /* where we left off last time. It is efficient when it starts over */ + /* at zero though. */ + if (start_idx > current_idx) { + /* We aren't far enough; advance to start_idx */ + while (current_idx < start_idx) { + char *unmap_name; + + if(!orig_done) { + if ((pwd = getpwent()) == NULL) break; + current_idx++; + orig_done = True; + } + + while (((unmap_name = unmap_unixname(pwd->pw_name, mapped_idx)) != NULL) && + (current_idx < start_idx)) { + current_idx++; + mapped_idx++; + } + + if (unmap_name == NULL) { + orig_done = False; + mapped_idx = 0; + } + } + } else if (start_idx < current_idx) { + /* We are already too far; start over and advance to start_idx */ + endpwent(); + setpwent(); + current_idx = 0; + mapped_idx = 0; + orig_done = False; + while (current_idx < start_idx) { + char *unmap_name; + + if(!orig_done) { + if ((pwd = getpwent()) == NULL) break; + current_idx++; + orig_done = True; + } + + while (((unmap_name = unmap_unixname(pwd->pw_name, mapped_idx)) != NULL) && + (current_idx < start_idx)) { + current_idx++; + mapped_idx++; + } + + if (unmap_name == NULL) { + orig_done = False; + mapped_idx = 0; + } + } + } + + /* now current_idx == start_idx */ + while ((*num_entries) < max_num_entries) { + int user_name_len; + char *unmap_name; + + /* This does the original UNIX user itself */ + if(!orig_done) { + if ((pwd = getpwent()) == NULL) break; + user_name_len = strlen(pwd->pw_name); + pw_rid = pdb_uid_to_user_rid(pwd->pw_uid); + init_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->pw_name, user_name_len); + init_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len); + pw_buf[(*num_entries)].user_rid = pw_rid; + memset((char *)pw_buf[(*num_entries)].nt_pwd, '\0', 16); + + pw_buf[(*num_entries)].acb_info = ACB_NORMAL; + + DEBUG(5, ("get_passwd_entries: entry idx %d user %s, rid 0x%x\n", (*num_entries), pwd->pw_name, pw_rid)); + + (*num_entries)++; + (*total_entries)++; + current_idx++; + orig_done = True; + } + + /* This does all the user names that map to the UNIX user */ + while (((unmap_name = unmap_unixname(pwd->pw_name, mapped_idx)) != NULL) && + (*num_entries < max_num_entries)) { + user_name_len = strlen(unmap_name); + init_unistr2(&(pw_buf[(*num_entries)].uni_user_name), unmap_name, user_name_len); + init_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len); + pw_buf[(*num_entries)].user_rid = pw_rid; + memset((char *)pw_buf[(*num_entries)].nt_pwd, '\0', 16); + + pw_buf[(*num_entries)].acb_info = ACB_NORMAL; + + DEBUG(5, ("get_passwd_entries: entry idx %d user %s, rid 0x%x\n", (*num_entries), pwd->pw_name, pw_rid)); + + (*num_entries)++; + (*total_entries)++; + current_idx++; + mapped_idx++; + } + + if (unmap_name == NULL) { + /* done with 'aliases', go on to next UNIX user */ + orig_done = False; + mapped_idx = 0; + } + } + + if (pwd == NULL) { + /* totally done, reset everything */ + endpwent(); + current_idx = 0; + mapped_idx = 0; + } + + return (*num_entries) > 0; +} + /******************************************************************* samr_reply_unknown_1 ********************************************************************/ @@ -456,7 +676,6 @@ static BOOL api_samr_enum_dom_groups( uint16 vuid, prs_struct *data, prs_struct return True; } - /******************************************************************* samr_reply_enum_dom_aliases ********************************************************************/ @@ -469,6 +688,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, DOM_SID sid; fstring sid_str; fstring sam_sid_str; + struct group *grp; r_e.status = 0x0; r_e.num_entries = 0; @@ -497,10 +717,22 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, } else if (strequal(sid_str, sam_sid_str)) { + char *name; /* local aliases */ - /* oops! there's no code to deal with this */ - DEBUG(3,("samr_reply_enum_dom_aliases: enum of aliases in our domain not supported yet\n")); - num_entries = 0; + /* we return the UNIX groups here. This seems to be the right */ + /* thing to do, since NT member servers return their local */ + /* groups in the same situation. */ + setgrent(); + + while (num_entries < MAX_SAM_ENTRIES && ((grp = getgrent()) != NULL)) + { + name = grp->gr_name; + init_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)); + pass[num_entries].user_rid = pdb_gid_to_group_rid(grp->gr_gid); + num_entries++; + } + + endgrent(); } init_samr_r_enum_dom_aliases(&r_e, num_entries, pass, r_e.status); @@ -561,7 +793,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, if (r_e.status == 0x0) { become_root(True); - got_pwds = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); + got_pwds = get_passwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); unbecome_root(True); switch (q_u->switch_level) @@ -592,7 +824,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, } } - if (r_e.status == 0 && got_pwds) + if (r_e.status == 0) { init_samr_r_query_dispinfo(&r_e, switch_level, &ctr, r_e.status); } @@ -649,7 +881,7 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, } init_samr_r_query_aliasinfo(&r_e, q_u->switch_level, - "", + "local UNIX group", r_e.status); /* store the response in the SMB stream */ -- cgit From b89b75a368c5245c38ebe467b2d3820b3df59c6a Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 22 Mar 2000 10:26:09 +0000 Subject: added the following message to all dce/rpc client/server code, except the spoolss code (it's cut from TNG) and the smb-dce/rpc interface code that jeremy has been working up to TNG-functionality. i also want this message to go into SAMBA_2_0 and SAMBA_2_0_RELEASE, because it is intolerable that potentially good modifications be made to code that is going to be thrown away, and people waste their time fixing bugs and adding enhancements that have already been carried out already, up to two years ago in the TNG branch. /* * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. * * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. * * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH * * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT * MAY BE LOST. * * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. * * THANK YOU. * * lkcl@samba.org */ (This used to be commit cfaea90529be222f8df0e20a7ca1289f99c29e09) --- source3/rpc_server/srv_lookup.c | 24 ++++++++++++++++++++++++ source3/rpc_server/srv_lsa.c | 24 ++++++++++++++++++++++++ source3/rpc_server/srv_lsa_hnd.c | 25 +++++++++++++++++++++++++ source3/rpc_server/srv_netlog.c | 25 +++++++++++++++++++++++++ source3/rpc_server/srv_reg.c | 26 ++++++++++++++++++++++++++ source3/rpc_server/srv_samr.c | 24 ++++++++++++++++++++++++ source3/rpc_server/srv_srvsvc.c | 24 ++++++++++++++++++++++++ source3/rpc_server/srv_util.c | 25 +++++++++++++++++++++++++ source3/rpc_server/srv_wkssvc.c | 24 ++++++++++++++++++++++++ 9 files changed, 221 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index e6df9933bf..d9d0c464b4 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -1,3 +1,27 @@ +/* + * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, + * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE + * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. + * + * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. + * + * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT + * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT + * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH + * + * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT + * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. + * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG + * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO + * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT + * MAY BE LOST. + * + * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. + * + * THANK YOU. + * + * lkcl@samba.org + */ /* * Unix SMB/Netbios implementation. diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 7094d842b4..02725f7d47 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -1,3 +1,27 @@ +/* + * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, + * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE + * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. + * + * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. + * + * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT + * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT + * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH + * + * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT + * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. + * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG + * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO + * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT + * MAY BE LOST. + * + * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. + * + * THANK YOU. + * + * lkcl@samba.org + */ /* * Unix SMB/Netbios implementation. diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 24aec701f0..4fddb9f0a3 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -1,4 +1,29 @@ +/* + * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, + * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE + * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. + * + * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. + * + * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT + * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT + * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH + * + * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT + * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. + * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG + * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO + * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT + * MAY BE LOST. + * + * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. + * + * THANK YOU. + * + * lkcl@samba.org + */ + /* * Unix SMB/Netbios implementation. * Version 1.9. diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index c0233d80c6..b79571c6ef 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -1,4 +1,29 @@ +/* + * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, + * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE + * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. + * + * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. + * + * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT + * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT + * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH + * + * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT + * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. + * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG + * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO + * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT + * MAY BE LOST. + * + * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. + * + * THANK YOU. + * + * lkcl@samba.org + */ + /* * Unix SMB/Netbios implementation. * Version 1.9. diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index f2083fa22f..6289d3046e 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -1,3 +1,29 @@ + +/* + * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, + * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE + * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. + * + * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. + * + * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT + * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT + * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH + * + * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT + * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. + * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG + * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO + * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT + * MAY BE LOST. + * + * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. + * + * THANK YOU. + * + * lkcl@samba.org + */ + /* * Unix SMB/Netbios implementation. * Version 1.9. diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index a99e2a2734..5056c9382b 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1,3 +1,27 @@ +/* + * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, + * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE + * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. + * + * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. + * + * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT + * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT + * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH + * + * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT + * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. + * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG + * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO + * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT + * MAY BE LOST. + * + * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. + * + * THANK YOU. + * + * lkcl@samba.org + */ /* * Unix SMB/Netbios implementation. diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index f42b94832b..b01d8554cd 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -1,3 +1,27 @@ +/* + * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, + * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE + * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. + * + * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. + * + * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT + * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT + * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH + * + * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT + * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. + * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG + * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO + * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT + * MAY BE LOST. + * + * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. + * + * THANK YOU. + * + * lkcl@samba.org + */ /* * Unix SMB/Netbios implementation. diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 097ab92d76..a1ad97188a 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -1,4 +1,29 @@ +/* + * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, + * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE + * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. + * + * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. + * + * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT + * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT + * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH + * + * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT + * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. + * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG + * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO + * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT + * MAY BE LOST. + * + * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. + * + * THANK YOU. + * + * lkcl@samba.org + */ + /* * Unix SMB/Netbios implementation. * Version 1.9. diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 658cadc625..185c017473 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -1,3 +1,27 @@ +/* + * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, + * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE + * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. + * + * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. + * + * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT + * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT + * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH + * + * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT + * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. + * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG + * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO + * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT + * MAY BE LOST. + * + * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. + * + * THANK YOU. + * + * lkcl@samba.org + */ /* * Unix SMB/Netbios implementation. -- cgit From 253e4eec84eb55ff31f3586ad89d1b226bfaa138 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 22 Mar 2000 10:55:01 +0000 Subject: disabled code from HP that replaced get_sampwd_entries() with get_passwd_entries(). get_sampwd_entries() calls the generic SAM pwdb API, whereas get_passwd_entries() calls the Unix database explicitly. this will result in LDAP, MYSQL, NISPLUS and any other future modules (e.g "appliance" mode SAM database) failing to operate correctly. i know what problem was attempted to be fixed, here, but this is not the right place to attempt to fix it. (This used to be commit 04fa6a02739671fa02b531ae47e5d24c54753331) --- source3/rpc_server/srv_samr.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 5056c9382b..1e0b2fc16a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -209,6 +209,29 @@ static char *unmap_unixname(char *unix_user_name, int name_idx) return NULL; } +#ifdef DISABLED_BECAUSE_IT_FIXES_THE_PROBLEM_IN_THE_WRONG_WAY + +/* + * 1) this code should be *inside* getsam21pwent(), behind the + * sam database API. it should *not* be explictly in the samsrv + * implementation. that's the whole point of the sam database API: + * it hides implementation issues like this and allows code reuse + * for LDAP, NISPLUS, SMBPASSWD+Unix Passwd, MYSQL, tdb etc. + * + * 2) modifications to cvs main and 2_0 should be absolutely critical + * bug-fixes only, and TNG should be checked and worked on first. + * any bug-fixes and enhancements should be made to TNG, + * as per instructions at top of this file. + * + * i really appreciate the efforts of the person who wrote this code + * (whoever they are), however please consult with me because there + * are design issues that you should be aware of, and your skills + * are needed to fix the problems in the correct code-module in + * the right branch, not this one. + * + * lkcl@samba.org 23mar2000. + */ + /******************************************************************* This function sets up a list of users taken from the list of users that UNIX knows about, as well as all the user names that @@ -355,6 +378,8 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, return (*num_entries) > 0; } +#endif + /******************************************************************* samr_reply_unknown_1 ********************************************************************/ @@ -817,7 +842,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, if (r_e.status == 0x0) { become_root(True); - got_pwds = get_passwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); + got_pwds = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); unbecome_root(True); switch (q_u->switch_level) -- cgit From c90a455f32ef8ab6eec6aaeb1fffeb00ce67fa2e Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 22 Mar 2000 11:03:32 +0000 Subject: disabled the getgrent() code recently added that returns all unix groups as NT aliases. no allowance is made for possible clashes with some unix groups that may be mapped to NT groups, not NT aliases. it is not the place of this code to make decisions about which unix groups should be mapped to NT aliases or NT groups, or in fact whether unix groups exist at all (e.g "appliance" mode). please could the person who wrote this code contact me and i will outline the architecture and design issues that you need to be aware of when working in this area: i need your skills and ability -- applied in the right places. thank you. (This used to be commit 67d9b3733f7f3ffab0ff6e78de7638fb469195e6) --- source3/rpc_server/srv_samr.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 1e0b2fc16a..6871671ff0 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -766,6 +766,22 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, } else if (strequal(sid_str, sam_sid_str)) { +#ifdef _DISABLED_BECAUSE_THERE_IS_AN_API_TO_CALL_TO_OBTAIN_ALIASES + + /* + * this code has been disabled because there is an API + * to call to enumerate NT aliases. + * + * it is the job of this API to decide which unix groups + * should be mapped to NT aliases and which should be + * mapped to NT groups. + * + * putting *all* unix groups as aliases is not the correct + * thing to do, just as it is not the correct thing to + * do to return all unix users as NT users (as is done + * by the disabled function, get_passwd_entries()) + */ + char *name; /* local aliases */ /* we return the UNIX groups here. This seems to be the right */ @@ -782,6 +798,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, } endgrent(); +#endif } init_samr_r_enum_dom_aliases(&r_e, num_entries, pass, r_e.status); -- cgit From 8f1620125dcb9c29c223f4efb6485528ece70f11 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 22 Mar 2000 19:03:12 +0000 Subject: acconfig.h configure configure.in: Added check for UT_SYSLEN for utmp code. include/byteorder.h: Added alignment macros. include/nameserv.h: Added defines for msg_type field options - from rfc1002. lib/time.c: Typo fix. lib/util_unistr.c: Updates from UNICODE branch. printing/nt_printing.c: bzero -> memset. smbd/connection.c: Added check for UT_SYSLEN for utmp code. Other fixes : Rollback of unapproved commit from Luke. Please *ask* next time before doing large changes to HEAD. Jeremy. (This used to be commit f02999dbf7971b4ea05050d7206205d7737a78b2) --- source3/rpc_server/srv_lookup.c | 24 -------------- source3/rpc_server/srv_lsa.c | 24 -------------- source3/rpc_server/srv_lsa_hnd.c | 25 --------------- source3/rpc_server/srv_netlog.c | 25 --------------- source3/rpc_server/srv_reg.c | 26 --------------- source3/rpc_server/srv_samr.c | 68 +--------------------------------------- source3/rpc_server/srv_srvsvc.c | 24 -------------- source3/rpc_server/srv_util.c | 25 --------------- source3/rpc_server/srv_wkssvc.c | 24 -------------- 9 files changed, 1 insertion(+), 264 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index d9d0c464b4..e6df9933bf 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -1,27 +1,3 @@ -/* - * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, - * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE - * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. - * - * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. - * - * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT - * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT - * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH - * - * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT - * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. - * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG - * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO - * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT - * MAY BE LOST. - * - * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. - * - * THANK YOU. - * - * lkcl@samba.org - */ /* * Unix SMB/Netbios implementation. diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 02725f7d47..7094d842b4 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -1,27 +1,3 @@ -/* - * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, - * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE - * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. - * - * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. - * - * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT - * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT - * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH - * - * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT - * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. - * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG - * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO - * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT - * MAY BE LOST. - * - * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. - * - * THANK YOU. - * - * lkcl@samba.org - */ /* * Unix SMB/Netbios implementation. diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 4fddb9f0a3..24aec701f0 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -1,29 +1,4 @@ -/* - * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, - * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE - * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. - * - * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. - * - * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT - * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT - * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH - * - * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT - * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. - * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG - * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO - * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT - * MAY BE LOST. - * - * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. - * - * THANK YOU. - * - * lkcl@samba.org - */ - /* * Unix SMB/Netbios implementation. * Version 1.9. diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index b79571c6ef..c0233d80c6 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -1,29 +1,4 @@ -/* - * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, - * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE - * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. - * - * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. - * - * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT - * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT - * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH - * - * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT - * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. - * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG - * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO - * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT - * MAY BE LOST. - * - * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. - * - * THANK YOU. - * - * lkcl@samba.org - */ - /* * Unix SMB/Netbios implementation. * Version 1.9. diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 6289d3046e..f2083fa22f 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -1,29 +1,3 @@ - -/* - * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, - * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE - * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. - * - * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. - * - * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT - * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT - * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH - * - * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT - * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. - * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG - * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO - * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT - * MAY BE LOST. - * - * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. - * - * THANK YOU. - * - * lkcl@samba.org - */ - /* * Unix SMB/Netbios implementation. * Version 1.9. diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 6871671ff0..a99e2a2734 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1,27 +1,3 @@ -/* - * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, - * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE - * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. - * - * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. - * - * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT - * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT - * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH - * - * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT - * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. - * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG - * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO - * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT - * MAY BE LOST. - * - * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. - * - * THANK YOU. - * - * lkcl@samba.org - */ /* * Unix SMB/Netbios implementation. @@ -209,29 +185,6 @@ static char *unmap_unixname(char *unix_user_name, int name_idx) return NULL; } -#ifdef DISABLED_BECAUSE_IT_FIXES_THE_PROBLEM_IN_THE_WRONG_WAY - -/* - * 1) this code should be *inside* getsam21pwent(), behind the - * sam database API. it should *not* be explictly in the samsrv - * implementation. that's the whole point of the sam database API: - * it hides implementation issues like this and allows code reuse - * for LDAP, NISPLUS, SMBPASSWD+Unix Passwd, MYSQL, tdb etc. - * - * 2) modifications to cvs main and 2_0 should be absolutely critical - * bug-fixes only, and TNG should be checked and worked on first. - * any bug-fixes and enhancements should be made to TNG, - * as per instructions at top of this file. - * - * i really appreciate the efforts of the person who wrote this code - * (whoever they are), however please consult with me because there - * are design issues that you should be aware of, and your skills - * are needed to fix the problems in the correct code-module in - * the right branch, not this one. - * - * lkcl@samba.org 23mar2000. - */ - /******************************************************************* This function sets up a list of users taken from the list of users that UNIX knows about, as well as all the user names that @@ -378,8 +331,6 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, return (*num_entries) > 0; } -#endif - /******************************************************************* samr_reply_unknown_1 ********************************************************************/ @@ -766,22 +717,6 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, } else if (strequal(sid_str, sam_sid_str)) { -#ifdef _DISABLED_BECAUSE_THERE_IS_AN_API_TO_CALL_TO_OBTAIN_ALIASES - - /* - * this code has been disabled because there is an API - * to call to enumerate NT aliases. - * - * it is the job of this API to decide which unix groups - * should be mapped to NT aliases and which should be - * mapped to NT groups. - * - * putting *all* unix groups as aliases is not the correct - * thing to do, just as it is not the correct thing to - * do to return all unix users as NT users (as is done - * by the disabled function, get_passwd_entries()) - */ - char *name; /* local aliases */ /* we return the UNIX groups here. This seems to be the right */ @@ -798,7 +733,6 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, } endgrent(); -#endif } init_samr_r_enum_dom_aliases(&r_e, num_entries, pass, r_e.status); @@ -859,7 +793,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, if (r_e.status == 0x0) { become_root(True); - got_pwds = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); + got_pwds = get_passwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); unbecome_root(True); switch (q_u->switch_level) diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index b01d8554cd..f42b94832b 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -1,27 +1,3 @@ -/* - * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, - * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE - * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. - * - * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. - * - * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT - * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT - * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH - * - * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT - * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. - * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG - * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO - * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT - * MAY BE LOST. - * - * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. - * - * THANK YOU. - * - * lkcl@samba.org - */ /* * Unix SMB/Netbios implementation. diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index a1ad97188a..097ab92d76 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -1,29 +1,4 @@ -/* - * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, - * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE - * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. - * - * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. - * - * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT - * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT - * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH - * - * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT - * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. - * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG - * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO - * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT - * MAY BE LOST. - * - * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. - * - * THANK YOU. - * - * lkcl@samba.org - */ - /* * Unix SMB/Netbios implementation. * Version 1.9. diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 185c017473..658cadc625 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -1,27 +1,3 @@ -/* - * THIS CODE IS OUT-OF-DATE BY TWO YEARS, IS LEGACY DESIGN AND VERY, VERY, - * INCOMPLETE. PLEASE DO NOT MAKE ANY FURTHER ENHANCEMENTS TO THIS CODE - * UNLESS THEY ARE ALSO CARRIED OUT IN THE SAMBA_TNG BRANCH. - * - * PLEASE DO NOT TREAT THIS CODE AS AUTHORITATIVE IN *ANY* WAY. - * - * REPEAT, PLEASE DO NOT MAKE ANY MODIFICATIONS TO THIS CODE WITHOUT - * FIRST CHECKING THE EQUIVALENT MODULE IN SAMBA_TNG, UPDATING THAT - * FIRST, *THEN* CONSIDER MAKING THE SAME MODIFICATION IN THIS BRANCH - * - * YOU WILL, ALMOST GUARANTEED, FIND THAT THE BUG-FIX OR ENHANCEMENT THAT - * YOU THINK IS NECESSARY, HAS ALREADY BEEN IMPLEMENTED IN SAMBA_TNG. - * IF IT HAS NOT, YOUR BUG-FIX OR ENHANCEMENT *MUST* GO INTO SAMBA_TNG - * AS THE SAMBA_TNG CODE WILL REPLACE THIS MODULE WITHOUT REFERENCE TO - * ANYTHING IN IT, WITH THE POSSIBLE RISK THAT THE BUG-FIX OR ENHANCEMENT - * MAY BE LOST. - * - * PLEASE OBSERVE AND RESPECT THIS SIMPLE REQUEST. - * - * THANK YOU. - * - * lkcl@samba.org - */ /* * Unix SMB/Netbios implementation. -- cgit From 6ca0ed9baa7d2a4b4d46ca730d4984f80965d849 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Wed, 29 Mar 2000 12:36:44 +0000 Subject: rewrote getprinterdriver level 3, now correctly handle the dependent files. A number of memleak fixed some error return values fixed. J.F. (This used to be commit c212fbe009fe556d5329b5d7106159cf21402d82) --- source3/rpc_server/srv_spoolss_nt.c | 169 ++++++++++++++++++++---------------- 1 file changed, 95 insertions(+), 74 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8f1bcef9f3..d08571b80b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -305,8 +305,7 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) char *aprinter; BOOL found=False; - if (!OPEN_HANDLE(Printer)) - { + if (!OPEN_HANDLE(Printer)) { DEBUG(0,("Error setting printer name=%s\n", printername)); return False; } @@ -437,7 +436,7 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, clear_handle(handle); if (printername == NULL) - return NT_STATUS_ACCESS_DENIED; + return ERROR_INVALID_PRINTER_NAME; /* some sanity check because you can open a printer or a print server */ /* aka: \\server\printer or \\server */ @@ -451,12 +450,12 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, if (!set_printer_hnd_printertype(handle, name)) { close_printer_handle(handle); - return NT_STATUS_ACCESS_DENIED; + return ERROR_INVALID_PRINTER_NAME; } if (!set_printer_hnd_printername(handle, name)) { close_printer_handle(handle); - return NT_STATUS_ACCESS_DENIED; + return ERROR_INVALID_PRINTER_NAME; } /* @@ -471,7 +470,7 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, if (!set_printer_hnd_accesstype(handle, printer_default->access_required)) { close_printer_handle(handle); - return NT_STATUS_ACCESS_DENIED; + return ERROR_ACCESS_DENIED; } return NT_STATUS_NO_PROBLEMO; @@ -665,25 +664,32 @@ static BOOL getprinterdata_printer(const POLICY_HND *handle, DEBUG(5,("getprinterdata_printer\n")); - if (OPEN_HANDLE(Printer)) - { - get_printer_snum(handle, &snum); - get_a_printer(&printer, 2, lp_servicename(snum)); - - if (get_specific_param(printer, 2, value, &idata, type, &len)) - { - *data = (uint8 *)malloc( (len>in_size)?len:in_size *sizeof(uint8) ); - memset(*data, 0, sizeof(uint8)*len); - memcpy(*data, idata, (len>in_size)?len:in_size); - *needed = len; - - if (idata) free(idata); - return (True); - } + if (!OPEN_HANDLE(Printer)) + return False; + + get_printer_snum(handle, &snum); + get_a_printer(&printer, 2, lp_servicename(snum)); + + if (!get_specific_param(printer, 2, value, &idata, type, &len)) { free_a_printer(printer, 2); + return False; } - return (False); + DEBUG(5,("getprinterdata_printer:allocating %d\n", in_size)); + + *data = (uint8 *)malloc( in_size *sizeof(uint8) ); + memset(*data, 0, in_size *sizeof(uint8)); + /* copy the min(in_size, len) */ + memcpy(*data, idata, (len>in_size)?in_size:len *sizeof(uint8)); + + *needed = len; + + DEBUG(5,("getprinterdata_printer:copy done\n")); + + free_a_printer(printer, 2); + safe_free(idata); + + return True; } /******************************************************************** @@ -728,9 +734,10 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, found=getprinterdata_printer(handle, value, type, data, needed, *out_size); if (found==False) { + DEBUG(5, ("value not found, allocating %d\n", *out_size)); /* reply this param doesn't exist */ - *data=(uint8 *)malloc(4*sizeof(uint8)); - memset(*data, 0x0, 4); + *data=(uint8 *)malloc(*out_size*sizeof(uint8)); + memset(*data, 0x0, *out_size*sizeof(uint8)); return ERROR_INVALID_PARAMETER; } @@ -984,7 +991,7 @@ static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_ memset(&status, 0, sizeof(status)); count=get_printqueue(snum, NULL, &q, &status); data->notify_data.value[0]=(uint32) status.status; - if (q) free(q); + safe_free(q); } /******************************************************************* @@ -997,7 +1004,7 @@ static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_q memset(&status, 0, sizeof(status)); data->notify_data.value[0]=get_printqueue(snum, NULL, &q, &status); - if (q) free(q); + safe_free(q); } /******************************************************************* @@ -1936,14 +1943,24 @@ static BOOL enum_all_printers_info_2(fstring servername, NEW_BUFFER *buffer, uin for (i=0; i<*returned; i++) (*needed) += spoolss_size_printer_info_2(&(printers[i])); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + for (i=0; i<*returned; i++) { + safe_free(printers[i].devmode->private); + safe_free(printers[i].devmode); + } + safe_free(printers); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the structures */ for (i=0; i<*returned; i++) new_smb_io_printer_info_2("", buffer, &(printers[i]), 0); /* clear memory */ + for (i=0; i<*returned; i++) { + safe_free(printers[i].devmode->private); + safe_free(printers[i].devmode); + } safe_free(printers); if (*needed > offered) { @@ -2157,6 +2174,8 @@ static uint32 getprinter_level_2(pstring servername, int snum, NEW_BUFFER *buffe new_smb_io_printer_info_2("", buffer, printer, 0); /* clear memory */ + safe_free(printer->devmode->private); + safe_free(printer->devmode); safe_free(printer); if (*needed > offered) { @@ -2263,8 +2282,7 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, * construct_printer_driver_info_2 * fill a printer_info_2 struct ********************************************************************/ -static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, - pstring servername, fstring architecture) +static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, pstring servername, fstring architecture) { NT_PRINTER_INFO_LEVEL printer; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -2280,36 +2298,30 @@ static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, /******************************************************************** * copy a strings array and convert to UNICODE + * + * convert an array of ascii string to a UNICODE string ********************************************************************/ -static void init_unistr_array(UNISTR ***uni_array, char **char_array, char *where) +static void init_unistr_array(uint16 **uni_array, char **char_array, char *where) { int i=0; + int j=0; char *v; pstring line; DEBUG(6,("init_unistr_array\n")); + *uni_array=NULL; - for (v=char_array[i]; *v!='\0'; v=char_array[i]) - { - DEBUGADD(6,("i:%d:", i)); - DEBUGADD(6,("%s:%d:", v, strlen(v))); - - *uni_array=(UNISTR **)Realloc(*uni_array, sizeof(UNISTR *)*(i+1)); - DEBUGADD(7,("realloc:[%p],", *uni_array)); - - (*uni_array)[i]=(UNISTR *)malloc( sizeof(UNISTR) ); - DEBUGADD(7,("alloc:[%p],", (*uni_array)[i])); - + for (v=char_array[i]; *v!='\0'; v=char_array[i]) { snprintf(line, sizeof(line)-1, "%s%s", where, v); - init_unistr( (*uni_array)[i], line ); - DEBUGADD(7,("copy\n")); - + DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); + *uni_array=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16)); + ascii_to_unistr( *uni_array+j, line , strlen(line)); + j+=strlen(line)+1; i++; } - DEBUGADD(7,("last one\n")); - *uni_array=(UNISTR **)Realloc(*uni_array, sizeof(UNISTR *)*(i+1)); - (*uni_array)[i]=0x0000; + (*uni_array)[j]=0x0000; + DEBUGADD(6,("last one:done\n")); } @@ -2457,6 +2469,7 @@ static uint32 getprinterdriver2_level3(pstring servername, pstring architecture, new_smb_io_printer_driver_info_3("", buffer, info, 0); /* clear memory */ + safe_free(info->dependentfiles); safe_free(info); if (*needed > offered) @@ -3182,9 +3195,10 @@ static uint32 enumprinterdrivers_level1(fstring *list, fstring servername, fstri free_a_printer_driver(driver, 3); } + safe_free(list); + /* check the required size. */ - for (i=0; i<*returned; i++) - { + for (i=0; i<*returned; i++) { DEBUGADD(6,("adding driver [%d]'s size\n",i)); *needed += spoolss_size_printer_driver_info_1(&(driver_info_1[i])); } @@ -3195,8 +3209,7 @@ static uint32 enumprinterdrivers_level1(fstring *list, fstring servername, fstri } /* fill the buffer with the form structures */ - for (i=0; i<*returned; i++) - { + for (i=0; i<*returned; i++) { DEBUGADD(6,("adding driver [%d] to buffer\n",i)); new_smb_io_printer_driver_info_1("", buffer, &(driver_info_1[i]), 0); } @@ -3227,9 +3240,10 @@ static uint32 enumprinterdrivers_level2(fstring *list, fstring servername, fstri free_a_printer_driver(driver, 3); } + safe_free(list); + /* check the required size. */ - for (i=0; i<*returned; i++) - { + for (i=0; i<*returned; i++) { DEBUGADD(6,("adding driver [%d]'s size\n",i)); *needed += spoolss_size_printer_driver_info_2(&(driver_info_2[i])); } @@ -3240,8 +3254,7 @@ static uint32 enumprinterdrivers_level2(fstring *list, fstring servername, fstri } /* fill the buffer with the form structures */ - for (i=0; i<*returned; i++) - { + for (i=0; i<*returned; i++) { DEBUGADD(6,("adding driver [%d] to buffer\n",i)); new_smb_io_printer_driver_info_2("", buffer, &(driver_info_2[i]), 0); } @@ -3272,27 +3285,34 @@ static uint32 enumprinterdrivers_level3(fstring *list, fstring servername, fstri free_a_printer_driver(driver, 3); } + safe_free(list); + /* check the required size. */ - for (i=0; i<*returned; i++) - { + for (i=0; i<*returned; i++) { DEBUGADD(6,("adding driver [%d]'s size\n",i)); *needed += spoolss_size_printer_driver_info_3(&(driver_info_3[i])); } - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(driver_info_3); return ERROR_INSUFFICIENT_BUFFER; - + } + /* fill the buffer with the form structures */ - for (i=0; i<*returned; i++) - { + for (i=0; i<*returned; i++) { DEBUGADD(6,("adding form [%d] to buffer\n",i)); new_smb_io_printer_driver_info_3("", buffer, &(driver_info_3[i]), 0); } - safe_free(list); - - if (*needed > offered) + for (i=0; i<*returned; i++) + safe_free(driver_info_3[i].dependentfiles); + + safe_free(driver_info_3); + + if (*needed > offered) { + *returned=0; return ERROR_INSUFFICIENT_BUFFER; + } else return NT_STATUS_NO_PROBLEMO; } @@ -3332,7 +3352,7 @@ uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32 return enumprinterdrivers_level3(list, servername, architecture, buffer, offered, needed, returned); break; default: - return NT_STATUS_INVALID_INFO_CLASS; + return ERROR_INVALID_LEVEL; break; } } @@ -3374,15 +3394,15 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, forms_1=(FORM_1 *)malloc(*numofforms * sizeof(FORM_1)); /* construct the list of form structures */ - for (i=0; i<*numofforms; i++) - { + for (i=0; i<*numofforms; i++) { DEBUGADD(6,("Filling form number [%d]\n",i)); fill_form_1(&(forms_1[i]), &(list[i]), i); } + + safe_free(list); /* check the required size. */ - for (i=0; i<*numofforms; i++) - { + for (i=0; i<*numofforms; i++) { DEBUGADD(6,("adding form [%d]'s size\n",i)); buffer_size += spoolss_size_form_1(&(forms_1[i])); } @@ -3390,21 +3410,22 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, *needed=buffer_size; if (!alloc_buffer_size(buffer, buffer_size)){ - safe_free(list); + safe_free(forms_1); return ERROR_INSUFFICIENT_BUFFER; } /* fill the buffer with the form structures */ - for (i=0; i<*numofforms; i++) - { + for (i=0; i<*numofforms; i++) { DEBUGADD(6,("adding form [%d] to buffer\n",i)); new_smb_io_form_1("", buffer, &(forms_1[i]), 0); } - safe_free(list); + safe_free(forms_1); - if (*needed > offered) + if (*needed > offered) { + *numofforms=0; return ERROR_INSUFFICIENT_BUFFER; + } else return NT_STATUS_NO_PROBLEMO; -- cgit From c475ab51d99ee3aa33f9d2c6eaa2811f2f8ea931 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Wed, 29 Mar 2000 14:49:05 +0000 Subject: split addprinterex in preparation for level 1 support and to stop it coredump. J.F. (This used to be commit aea47dee7d85310f35309ecfa91d0b87e632a33f) --- source3/rpc_server/srv_spoolss_nt.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d08571b80b..e55f1fb305 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3587,7 +3587,7 @@ uint32 _spoolss_enumports( UNISTR2 *name, uint32 level, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level, +static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, const SPOOL_PRINTER_INFO_LEVEL *info, uint32 unk0, uint32 unk1, uint32 unk2, uint32 unk3, uint32 user_switch, const SPOOL_USER_CTR *user, @@ -3599,24 +3599,19 @@ uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level, clear_handle(handle); -/* - * FIX: JFM: we need to check the user here !!!! - * - * as the code is running as root, anybody can add printers to the server - */ /* NULLify info_2 here */ /* don't put it in convert_printer_info as it's used also with non-NULL values */ printer.info_2=NULL; /* convert from UNICODE to ASCII */ - convert_printer_info(info, &printer, level); + convert_printer_info(info, &printer, 2); unistr2_to_ascii(share_name, &((info->info_2)->printername), sizeof(share_name)-1); slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname, share_name); /* write the ASCII on disk */ - if (add_a_printer(printer, level) != 0x0) + if (add_a_printer(printer, 2) != 0x0) return ERROR_ACCESS_DENIED; create_printer_hnd(handle); @@ -3636,6 +3631,31 @@ uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level, return NT_STATUS_NO_PROBLEMO; } +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level, + const SPOOL_PRINTER_INFO_LEVEL *info, + uint32 unk0, uint32 unk1, uint32 unk2, uint32 unk3, + uint32 user_switch, const SPOOL_USER_CTR *user, + POLICY_HND *handle) +{ + switch (level) { + case 1: + /* we don't handle yet */ + /* but I know what to do ... */ + break; + case 2: + return spoolss_addprinterex_level_2(uni_srv_name, info, + unk0, unk1, unk2, unk3, + user_switch, user, handle); + break; + default: + return ERROR_INVALID_LEVEL; + break; + } +} + + /**************************************************************************** ****************************************************************************/ uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name, -- cgit From 15bb28ccd2aeb712c2d874912adc465d83809d60 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 31 Mar 2000 20:44:55 +0000 Subject: IRIX include fixes. Jeremy. (This used to be commit 3a39acd3535647b0f28f51eea29573d5cb1eb9be) --- source3/rpc_server/srv_pipe_hnd.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index fdee90e8ae..88b3dfbe80 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -252,11 +252,16 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, fstrcpy(p->name, pipe_name); +#if 0 + + Comment out until memory leak fixed. JRA. + /* * For Luke - attempt to connect to RPC redirect process. */ attempt_remote_rpc_connect(p); +#endif DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n", pipe_name, i, pipes_open)); -- cgit From ba0a53b52ca934389268b65ec0d9e7336ae85d4f Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 4 Apr 2000 00:35:34 +0000 Subject: Removed unused parameter vuid from rpc_server api_* calls. For the very few functions that need to access the vuid, it can be obtained from the current_user global. Did some whitespace cleanup. (This used to be commit 738b307bd7053ede369431da7b1349befaa523d9) --- source3/rpc_server/srv_lsa.c | 25 +-- source3/rpc_server/srv_netlog.c | 434 ++++++++++++++++++++------------------- source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_reg.c | 16 +- source3/rpc_server/srv_samr.c | 47 ++--- source3/rpc_server/srv_spoolss.c | 68 +++--- source3/rpc_server/srv_srvsvc.c | 16 +- source3/rpc_server/srv_wkssvc.c | 8 +- 8 files changed, 296 insertions(+), 320 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 7094d842b4..81e9b737ee 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -1,4 +1,3 @@ - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -23,9 +22,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "includes.h" -#include "nterr.h" extern int DEBUGLEVEL; extern DOM_SID global_sam_sid; @@ -432,8 +429,7 @@ static BOOL lsa_reply_lookup_names(prs_struct *rdata, api_lsa_open_policy2 ***************************************************************************/ -static BOOL api_lsa_open_policy2( uint16 vuid, prs_struct *data, - prs_struct *rdata ) +static BOOL api_lsa_open_policy2(prs_struct *data, prs_struct *rdata) { LSA_Q_OPEN_POL2 q_o; @@ -457,8 +453,7 @@ static BOOL api_lsa_open_policy2( uint16 vuid, prs_struct *data, /*************************************************************************** api_lsa_open_policy ***************************************************************************/ -static BOOL api_lsa_open_policy( uint16 vuid, prs_struct *data, - prs_struct *rdata ) +static BOOL api_lsa_open_policy(prs_struct *data, prs_struct *rdata) { LSA_Q_OPEN_POL q_o; @@ -482,8 +477,7 @@ static BOOL api_lsa_open_policy( uint16 vuid, prs_struct *data, /*************************************************************************** api_lsa_enum_trust_dom ***************************************************************************/ -static BOOL api_lsa_enum_trust_dom( uint16 vuid, prs_struct *data, - prs_struct *rdata ) +static BOOL api_lsa_enum_trust_dom(prs_struct *data, prs_struct *rdata) { LSA_Q_ENUM_TRUST_DOM q_e; @@ -501,8 +495,7 @@ static BOOL api_lsa_enum_trust_dom( uint16 vuid, prs_struct *data, /*************************************************************************** api_lsa_query_info ***************************************************************************/ -static BOOL api_lsa_query_info( uint16 vuid, prs_struct *data, - prs_struct *rdata ) +static BOOL api_lsa_query_info(prs_struct *data, prs_struct *rdata) { LSA_Q_QUERY_INFO q_i; fstring name; @@ -542,7 +535,7 @@ static BOOL api_lsa_query_info( uint16 vuid, prs_struct *data, api_lsa_lookup_sids ***************************************************************************/ -static BOOL api_lsa_lookup_sids( uint16 vuid, prs_struct *data, prs_struct *rdata ) +static BOOL api_lsa_lookup_sids(prs_struct *data, prs_struct *rdata) { LSA_Q_LOOKUP_SIDS q_l; ZERO_STRUCT(q_l); @@ -564,7 +557,7 @@ static BOOL api_lsa_lookup_sids( uint16 vuid, prs_struct *data, prs_struct *rdat api_lsa_lookup_names ***************************************************************************/ -static BOOL api_lsa_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rdata ) +static BOOL api_lsa_lookup_names(prs_struct *data, prs_struct *rdata) { LSA_Q_LOOKUP_NAMES q_l; ZERO_STRUCT(q_l); @@ -583,8 +576,7 @@ static BOOL api_lsa_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rda /*************************************************************************** api_lsa_close ***************************************************************************/ -static BOOL api_lsa_close( uint16 vuid, prs_struct *data, - prs_struct *rdata) +static BOOL api_lsa_close(prs_struct *data, prs_struct *rdata) { LSA_R_CLOSE r_c; @@ -602,8 +594,7 @@ static BOOL api_lsa_close( uint16 vuid, prs_struct *data, /*************************************************************************** api_lsa_open_secret ***************************************************************************/ -static BOOL api_lsa_open_secret( uint16 vuid, prs_struct *data, - prs_struct *rdata) +static BOOL api_lsa_open_secret(prs_struct *data, prs_struct *rdata) { /* XXXX this is NOT good */ size_t i; diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index c0233d80c6..db1a4a9c6b 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -1,4 +1,3 @@ - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -23,9 +22,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "includes.h" -#include "nterr.h" extern int DEBUGLEVEL; @@ -302,21 +299,24 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) return False; } +extern struct current_user current_user; /* To pick up vuid */ + /************************************************************************* api_net_req_chal: *************************************************************************/ -static BOOL api_net_req_chal( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_net_req_chal(prs_struct *data, prs_struct *rdata) { NET_Q_REQ_CHAL q_r; uint32 status = 0x0; + uint16 vuid = current_user.vuid; fstring mach_acct; fstring mach_name; user_struct *vuser; - DEBUG(5,("api_net_req_chal(%d): vuid %d\n", __LINE__, (int)vuid)); + DEBUG(5,("api_net_req_chal(%d): vuid %d\n", __LINE__, (int)vuid)); if ((vuser = get_valid_user_struct(vuid)) == NULL) return False; @@ -367,8 +367,9 @@ static BOOL api_net_req_chal( uint16 vuid, prs_struct *data, prs_struct *rdata) api_net_auth_2: *************************************************************************/ -static BOOL api_net_auth_2( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_net_auth_2(prs_struct *data, prs_struct *rdata) { + uint16 vuid = current_user.vuid; NET_Q_AUTH_2 q_a; uint32 status = 0x0; @@ -414,8 +415,9 @@ static BOOL api_net_auth_2( uint16 vuid, prs_struct *data, prs_struct *rdata) api_net_srv_pwset: *************************************************************************/ -static BOOL api_net_srv_pwset( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_net_srv_pwset(prs_struct *data, prs_struct *rdata) { + uint16 vuid = current_user.vuid; NET_Q_SRV_PWSET q_a; uint32 status = NT_STATUS_WRONG_PASSWORD|0xC0000000; DOM_CRED srv_cred; @@ -495,8 +497,9 @@ static BOOL api_net_srv_pwset( uint16 vuid, prs_struct *data, prs_struct *rdata) api_net_sam_logoff: *************************************************************************/ -static BOOL api_net_sam_logoff( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_net_sam_logoff(prs_struct *data, prs_struct *rdata) { + uint16 vuid = current_user.vuid; NET_Q_SAM_LOGOFF q_l; NET_ID_INFO_CTR ctr; @@ -629,211 +632,216 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, struct smb_passwd *smb_pass) api_net_sam_logon: *************************************************************************/ -static BOOL api_net_sam_logon( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_net_sam_logon(prs_struct *data, prs_struct *rdata) { - NET_Q_SAM_LOGON q_l; - NET_ID_INFO_CTR ctr; - NET_USER_INFO_3 usr_info; - uint32 status = 0x0; - DOM_CRED srv_cred; - struct smb_passwd *smb_pass = NULL; - UNISTR2 *uni_samlogon_user = NULL; - fstring nt_username; - - user_struct *vuser = NULL; - - if ((vuser = get_valid_user_struct(vuid)) == NULL) - return False; - - memset(&q_l, '\0', sizeof(q_l)); - memset(&ctr, '\0', sizeof(ctr)); - memset(&usr_info, '\0', sizeof(usr_info)); - - q_l.sam_id.ctr = &ctr; - - if(!net_io_q_sam_logon("", &q_l, data, 0)) { - DEBUG(0,("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n")); - return False; - } - - /* checks and updates credentials. creates reply credentials */ - if (!deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), - &(q_l.sam_id.client.cred), &srv_cred)) - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - else - memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); - - /* find the username */ - - if (status == 0) { - switch (q_l.sam_id.logon_level) { - case INTERACTIVE_LOGON_TYPE: - uni_samlogon_user = &q_l.sam_id.ctr->auth.id1.uni_user_name; - - DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); - break; - case NET_LOGON_TYPE: - uni_samlogon_user = &q_l.sam_id.ctr->auth.id2.uni_user_name; - - DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); - break; - default: - DEBUG(2,("SAM Logon: unsupported switch value\n")); - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; - break; - } /* end switch */ - } /* end if status == 0 */ - - /* check username exists */ - - if (status == 0) { - pstrcpy(nt_username, dos_unistrn2(uni_samlogon_user->buffer, - uni_samlogon_user->uni_str_len)); - - DEBUG(3,("User:[%s]\n", nt_username)); - - /* - * Convert to a UNIX username. - */ - map_username(nt_username); - - /* - * Do any case conversions. - */ - (void)Get_Pwnam(nt_username, True); - - become_root(True); - smb_pass = getsmbpwnam(nt_username); - unbecome_root(True); - - if (smb_pass == NULL) - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - else if (smb_pass->acct_ctrl & ACB_PWNOTREQ) - status = 0; - else if (smb_pass->acct_ctrl & ACB_DISABLED) - status = 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED; - } - - /* Validate password - if required. */ - - if ((status == 0) && !(smb_pass->acct_ctrl & ACB_PWNOTREQ)) { - switch (q_l.sam_id.logon_level) { - case INTERACTIVE_LOGON_TYPE: - /* interactive login. */ - status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, smb_pass, vuser); - break; - case NET_LOGON_TYPE: - /* network login. lm challenge and 24 byte responses */ - status = net_login_network(&q_l.sam_id.ctr->auth.id2, smb_pass); - break; + uint16 vuid = current_user.vuid; + NET_Q_SAM_LOGON q_l; + NET_ID_INFO_CTR ctr; + NET_USER_INFO_3 usr_info; + uint32 status = 0x0; + DOM_CRED srv_cred; + struct smb_passwd *smb_pass = NULL; + UNISTR2 *uni_samlogon_user = NULL; + fstring nt_username; + + user_struct *vuser = NULL; + + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return False; + + memset(&q_l, '\0', sizeof(q_l)); + memset(&ctr, '\0', sizeof(ctr)); + memset(&usr_info, '\0', sizeof(usr_info)); + + q_l.sam_id.ctr = &ctr; + + if(!net_io_q_sam_logon("", &q_l, data, 0)) { + DEBUG(0, + ("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n")); + return False; } - } - - /* 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 :-) */ - - if (status == 0) { - DOM_GID *gids = NULL; - int num_gids = 0; - NTTIME dummy_time; - pstring logon_script; - pstring profile_path; - pstring home_dir; - pstring home_drive; - 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; - - /* 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); - - pstrcpy(logon_script, lp_logon_script()); - pstrcpy(profile_path, lp_logon_path()); - - pstrcpy(my_workgroup, lp_workgroup()); - - pstrcpy(home_drive, lp_logon_drive()); - pstrcpy(home_dir, lp_logon_home()); - - pstrcpy(my_name, global_myname); - strupper(my_name); - - /* - * This is the point at which we get the group - * database - we should be getting the gid_t list - * from /etc/group and then turning the uids into - * rids and then into machine sids for this user. - * JRA. - */ - - get_domain_user_groups(domain_groups, nt_username); - - /* - * make_dom_gids allocates the gids array. JRA. - */ - gids = NULL; - num_gids = make_dom_gids(domain_groups, &gids); - - sam_logon_in_ssb = False; - - if (pdb_name_to_rid(nt_username, &r_uid, &r_gid)) - init_net_user_info3(&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 */ - vuser->real_name, /* full_name */ - logon_script , /* logon_script */ - profile_path , /* profile_path */ - home_dir , /* home_dir */ - home_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 */ + + /* checks and updates credentials. creates reply credentials */ + if (!deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), + &(q_l.sam_id.client.cred), &srv_cred)) + status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; else - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - - /* Free any allocated groups array. */ - if(gids) - free((char *)gids); - } + memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), + sizeof(vuser->dc.clnt_cred)); + + /* find the username */ + + if (status == 0) { + switch (q_l.sam_id.logon_level) { + case INTERACTIVE_LOGON_TYPE: + uni_samlogon_user = &q_l.sam_id.ctr->auth.id1.uni_user_name; + + DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", + lp_workgroup())); + break; + case NET_LOGON_TYPE: + uni_samlogon_user = &q_l.sam_id.ctr->auth.id2.uni_user_name; + + DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); + break; + default: + DEBUG(2,("SAM Logon: unsupported switch value\n")); + status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + break; + } /* end switch */ + } /* end if status == 0 */ - if(!net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status)) - return False; + /* check username exists */ - return True; + if (status == 0) { + pstrcpy(nt_username, dos_unistrn2(uni_samlogon_user->buffer, + uni_samlogon_user->uni_str_len)); + + DEBUG(3,("User:[%s]\n", nt_username)); + + /* + * Convert to a UNIX username. + */ + map_username(nt_username); + + /* + * Do any case conversions. + */ + (void)Get_Pwnam(nt_username, True); + + become_root(True); + smb_pass = getsmbpwnam(nt_username); + unbecome_root(True); + + if (smb_pass == NULL) + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + else if (smb_pass->acct_ctrl & ACB_PWNOTREQ) + status = 0; + else if (smb_pass->acct_ctrl & ACB_DISABLED) + status = 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED; + } + + /* Validate password - if required. */ + + if ((status == 0) && !(smb_pass->acct_ctrl & ACB_PWNOTREQ)) { + switch (q_l.sam_id.logon_level) { + case INTERACTIVE_LOGON_TYPE: + /* interactive login. */ + status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, + smb_pass, vuser); + break; + case NET_LOGON_TYPE: + /* network login. lm challenge and 24 byte responses */ + status = net_login_network(&q_l.sam_id.ctr->auth.id2, smb_pass); + break; + } + } + + /* 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 :-) */ + + if (status == 0) { + DOM_GID *gids = NULL; + int num_gids = 0; + NTTIME dummy_time; + pstring logon_script; + pstring profile_path; + pstring home_dir; + pstring home_drive; + 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; + + /* 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); + + pstrcpy(logon_script, lp_logon_script()); + pstrcpy(profile_path, lp_logon_path()); + + pstrcpy(my_workgroup, lp_workgroup()); + + pstrcpy(home_drive, lp_logon_drive()); + pstrcpy(home_dir, lp_logon_home()); + + pstrcpy(my_name, global_myname); + strupper(my_name); + + /* + * This is the point at which we get the group + * database - we should be getting the gid_t list + * from /etc/group and then turning the uids into + * rids and then into machine sids for this user. + * JRA. + */ + + get_domain_user_groups(domain_groups, nt_username); + + /* + * make_dom_gids allocates the gids array. JRA. + */ + gids = NULL; + num_gids = make_dom_gids(domain_groups, &gids); + + sam_logon_in_ssb = False; + + if (pdb_name_to_rid(nt_username, &r_uid, &r_gid)) + init_net_user_info3(&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 */ + vuser->real_name, /* full_name */ + logon_script , /* logon_script */ + profile_path , /* profile_path */ + home_dir , /* home_dir */ + home_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 + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + + /* Free any allocated groups array. */ + if(gids) + free((char *)gids); + } + + if(!net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status)) + return False; + + return True; } @@ -841,10 +849,9 @@ static BOOL api_net_sam_logon( uint16 vuid, prs_struct *data, prs_struct *rdata) api_net_trust_dom_list: *************************************************************************/ -static BOOL api_net_trust_dom_list( uint16 vuid, - prs_struct *data, - prs_struct *rdata) +static BOOL api_net_trust_dom_list(prs_struct *data, prs_struct *rdata) { + uint16 vuid = current_user.vuid; NET_Q_TRUST_DOM_LIST q_t; char *trusted_domain = "test_domain"; @@ -877,10 +884,9 @@ static BOOL api_net_trust_dom_list( uint16 vuid, api_net_logon_ctrl2: *************************************************************************/ -static BOOL api_net_logon_ctrl2( uint16 vuid, - prs_struct *data, - prs_struct *rdata) +static BOOL api_net_logon_ctrl2(prs_struct *data, prs_struct *rdata) { + uint16 vuid = current_user.vuid; NET_Q_LOGON_CTRL2 q_l; /* lkclXXXX - guess what - absolutely no idea what these are! */ diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 9a17862bd5..ebb38154d3 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1099,7 +1099,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds } /* do the actual command */ - if(!api_rpc_cmds[fn_num].fn(p->vuid, rpc_in, &p->out_data.rdata)) { + if(!api_rpc_cmds[fn_num].fn(rpc_in, &p->out_data.rdata)) { DEBUG(0,("api_rpcTNP: %s: failed.\n", rpc_name)); prs_mem_free(&p->out_data.rdata); return False; diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index f2083fa22f..b1d3784ec1 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -22,13 +22,10 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "includes.h" -#include "nterr.h" extern int DEBUGLEVEL; - /******************************************************************* reg_reply_unknown_1 ********************************************************************/ @@ -61,8 +58,7 @@ static void reg_reply_close(REG_Q_CLOSE *q_r, /******************************************************************* api_reg_close ********************************************************************/ -static BOOL api_reg_close( uint16 vuid, prs_struct *data, - prs_struct *rdata ) +static BOOL api_reg_close(prs_struct *data, prs_struct *rdata) { REG_Q_CLOSE q_r; @@ -102,8 +98,7 @@ static void reg_reply_open(REG_Q_OPEN_HKLM *q_r, /******************************************************************* api_reg_open ********************************************************************/ -static BOOL api_reg_open( uint16 vuid, prs_struct *data, - prs_struct *rdata ) +static BOOL api_reg_open(prs_struct *data, prs_struct *rdata) { REG_Q_OPEN_HKLM q_u; @@ -168,8 +163,7 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, /******************************************************************* api_reg_open_entry ********************************************************************/ -static BOOL api_reg_open_entry( uint16 vuid, prs_struct *data, - prs_struct *rdata ) +static BOOL api_reg_open_entry(prs_struct *data, prs_struct *rdata) { REG_Q_OPEN_ENTRY q_u; @@ -218,8 +212,7 @@ static void reg_reply_info(REG_Q_INFO *q_u, /******************************************************************* api_reg_info ********************************************************************/ -static BOOL api_reg_info( uint16 vuid, prs_struct *data, - prs_struct *rdata ) +static BOOL api_reg_info(prs_struct *data, prs_struct *rdata) { REG_Q_INFO q_u; @@ -252,4 +245,3 @@ BOOL api_reg_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds, data); } - diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index a99e2a2734..88a7f54efa 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1,4 +1,3 @@ - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -23,9 +22,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "includes.h" -#include "nterr.h" extern int DEBUGLEVEL; @@ -364,7 +361,7 @@ static void samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, /******************************************************************* api_samr_close_hnd ********************************************************************/ -static BOOL api_samr_close_hnd( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_close_hnd(prs_struct *data, prs_struct *rdata) { SAMR_Q_CLOSE_HND q_u; @@ -425,7 +422,7 @@ static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, /******************************************************************* api_samr_open_domain ********************************************************************/ -static BOOL api_samr_open_domain( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_open_domain(prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_DOMAIN q_u; @@ -474,7 +471,7 @@ static void samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, /******************************************************************* api_samr_unknown_2c ********************************************************************/ -static BOOL api_samr_unknown_2c( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_2c(prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_2C q_u; @@ -552,7 +549,7 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, /******************************************************************* api_samr_unknown_3 ********************************************************************/ -static BOOL api_samr_unknown_3( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_3(prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_3 q_u; @@ -606,7 +603,7 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, /******************************************************************* api_samr_enum_dom_users ********************************************************************/ -static BOOL api_samr_enum_dom_users( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_enum_dom_users(prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_USERS q_e; @@ -663,7 +660,7 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, /******************************************************************* api_samr_enum_dom_groups ********************************************************************/ -static BOOL api_samr_enum_dom_groups( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_enum_dom_groups(prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_GROUPS q_e; @@ -747,7 +744,7 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, /******************************************************************* api_samr_enum_dom_aliases ********************************************************************/ -static BOOL api_samr_enum_dom_aliases( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_enum_dom_aliases(prs_struct *data, prs_struct *rdata) { SAMR_Q_ENUM_DOM_ALIASES q_e; @@ -839,7 +836,7 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, /******************************************************************* api_samr_query_dispinfo ********************************************************************/ -static BOOL api_samr_query_dispinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_query_dispinfo(prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_DISPINFO q_e; @@ -894,7 +891,7 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, /******************************************************************* api_samr_query_aliasinfo ********************************************************************/ -static BOOL api_samr_query_aliasinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_query_aliasinfo(prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_ALIASINFO q_e; @@ -973,7 +970,7 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, /******************************************************************* api_samr_lookup_ids ********************************************************************/ -static BOOL api_samr_lookup_ids( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_lookup_ids(prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_IDS q_u; @@ -1062,7 +1059,7 @@ static BOOL samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, api_samr_lookup_names ********************************************************************/ -static BOOL api_samr_lookup_names( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_lookup_names(prs_struct *data, prs_struct *rdata) { SAMR_Q_LOOKUP_NAMES q_u; @@ -1121,7 +1118,7 @@ static BOOL samr_reply_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u, api_samr_chgpasswd_user ********************************************************************/ -static BOOL api_samr_chgpasswd_user( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_chgpasswd_user(prs_struct *data, prs_struct *rdata) { SAMR_Q_CHGPASSWD_USER q_u; @@ -1162,7 +1159,7 @@ static void samr_reply_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, /******************************************************************* api_samr_unknown_38 ********************************************************************/ -static BOOL api_samr_unknown_38( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_38(prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_38 q_u; @@ -1225,7 +1222,7 @@ static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, /******************************************************************* api_samr_unknown_12 ********************************************************************/ -static BOOL api_samr_unknown_12( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_12(prs_struct *data, prs_struct *rdata) { SAMR_Q_UNKNOWN_12 q_u; @@ -1301,7 +1298,7 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, /******************************************************************* api_samr_open_user ********************************************************************/ -static BOOL api_samr_open_user( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_open_user(prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_USER q_u; @@ -1506,7 +1503,7 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, /******************************************************************* api_samr_query_userinfo ********************************************************************/ -static BOOL api_samr_query_userinfo( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_query_userinfo(prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERINFO q_u; @@ -1586,7 +1583,7 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, /******************************************************************* api_samr_query_usergroups ********************************************************************/ -static BOOL api_samr_query_usergroups( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_query_usergroups(prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERGROUPS q_u; /* grab the samr unknown 32 */ @@ -1655,7 +1652,7 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, /******************************************************************* api_samr_query_dom_info ********************************************************************/ -static BOOL api_samr_query_dom_info( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_query_dom_info(prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_DOMAIN_INFO q_e; @@ -1705,7 +1702,7 @@ static void samr_reply_unknown_32(SAMR_Q_UNKNOWN_32 *q_u, /******************************************************************* api_samr_unknown_32 ********************************************************************/ -static BOOL api_samr_unknown_32( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_32(prs_struct *data, prs_struct *rdata) { uint32 status = 0; struct sam_passwd *sam_pass; @@ -1790,7 +1787,7 @@ static void samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, /******************************************************************* api_samr_connect_anon ********************************************************************/ -static BOOL api_samr_connect_anon( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_connect_anon(prs_struct *data, prs_struct *rdata) { SAMR_Q_CONNECT_ANON q_u; @@ -1845,7 +1842,7 @@ static void samr_reply_connect(SAMR_Q_CONNECT *q_u, /******************************************************************* api_samr_connect ********************************************************************/ -static BOOL api_samr_connect( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_connect(prs_struct *data, prs_struct *rdata) { SAMR_Q_CONNECT q_u; @@ -1900,7 +1897,7 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, /******************************************************************* api_samr_open_alias ********************************************************************/ -static BOOL api_samr_open_alias( uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_samr_open_alias(prs_struct *data, prs_struct *rdata) { SAMR_Q_OPEN_ALIAS q_u; diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 1649df8608..f23422d87a 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -22,14 +22,13 @@ */ #include "includes.h" -#include "nterr.h" extern int DEBUGLEVEL; /******************************************************************** * api_spoolss_open_printer_ex ********************************************************************/ -static BOOL api_spoolss_open_printer_ex(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_open_printer_ex(prs_struct *data, prs_struct *rdata) { SPOOL_Q_OPEN_PRINTER_EX q_u; SPOOL_R_OPEN_PRINTER_EX r_u; @@ -64,7 +63,7 @@ static BOOL api_spoolss_open_printer_ex(uint16 vuid, prs_struct *data, prs_struc * * called from the spoolss dispatcher ********************************************************************/ -static BOOL api_spoolss_getprinterdata(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_getprinterdata(prs_struct *data, prs_struct *rdata) { SPOOL_Q_GETPRINTERDATA q_u; SPOOL_R_GETPRINTERDATA r_u; @@ -97,7 +96,7 @@ static BOOL api_spoolss_getprinterdata(uint16 vuid, prs_struct *data, prs_struct * * called from the spoolss dispatcher ********************************************************************/ -static BOOL api_spoolss_closeprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_closeprinter(prs_struct *data, prs_struct *rdata) { SPOOL_Q_CLOSEPRINTER q_u; SPOOL_R_CLOSEPRINTER r_u; @@ -125,7 +124,7 @@ static BOOL api_spoolss_closeprinter(uint16 vuid, prs_struct *data, prs_struct * * api_spoolss_rffpcnex * ReplyFindFirstPrinterChangeNotifyEx ********************************************************************/ -static BOOL api_spoolss_rffpcnex(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_rffpcnex(prs_struct *data, prs_struct *rdata) { SPOOL_Q_RFFPCNEX q_u; SPOOL_R_RFFPCNEX r_u; @@ -157,7 +156,7 @@ static BOOL api_spoolss_rffpcnex(uint16 vuid, prs_struct *data, prs_struct *rdat * called from the spoolss dispatcher * ********************************************************************/ -static BOOL api_spoolss_rfnpcnex(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_rfnpcnex(prs_struct *data, prs_struct *rdata) { SPOOL_Q_RFNPCNEX q_u; SPOOL_R_RFNPCNEX r_u; @@ -192,7 +191,7 @@ static BOOL api_spoolss_rfnpcnex(uint16 vuid, prs_struct *data, prs_struct *rdat * called from the spoolss dispatcher * ********************************************************************/ -static BOOL api_spoolss_enumprinters(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumprinters(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPRINTERS q_u; SPOOL_R_ENUMPRINTERS r_u; @@ -230,7 +229,7 @@ static BOOL api_spoolss_enumprinters(uint16 vuid, prs_struct *data, prs_struct * * called from the spoolss dispatcher * ********************************************************************/ -static BOOL api_spoolss_getprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_getprinter(prs_struct *data, prs_struct *rdata) { SPOOL_Q_GETPRINTER q_u; SPOOL_R_GETPRINTER r_u; @@ -268,7 +267,7 @@ static BOOL api_spoolss_getprinter(uint16 vuid, prs_struct *data, prs_struct *rd * called from the spoolss dispatcher * ********************************************************************/ -static BOOL api_spoolss_getprinterdriver2(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_getprinterdriver2(prs_struct *data, prs_struct *rdata) { SPOOL_Q_GETPRINTERDRIVER2 q_u; SPOOL_R_GETPRINTERDRIVER2 r_u; @@ -306,7 +305,7 @@ static BOOL api_spoolss_getprinterdriver2(uint16 vuid, prs_struct *data, prs_str * called from the spoolss dispatcher * ********************************************************************/ -static BOOL api_spoolss_startpageprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_startpageprinter(prs_struct *data, prs_struct *rdata) { SPOOL_Q_STARTPAGEPRINTER q_u; SPOOL_R_STARTPAGEPRINTER r_u; @@ -335,7 +334,7 @@ static BOOL api_spoolss_startpageprinter(uint16 vuid, prs_struct *data, prs_stru * called from the spoolss dispatcher * ********************************************************************/ -static BOOL api_spoolss_endpageprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_endpageprinter(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENDPAGEPRINTER q_u; SPOOL_R_ENDPAGEPRINTER r_u; @@ -360,7 +359,7 @@ static BOOL api_spoolss_endpageprinter(uint16 vuid, prs_struct *data, prs_struct /******************************************************************** ********************************************************************/ -static BOOL api_spoolss_startdocprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_startdocprinter(prs_struct *data, prs_struct *rdata) { SPOOL_Q_STARTDOCPRINTER q_u; SPOOL_R_STARTDOCPRINTER r_u; @@ -389,7 +388,7 @@ static BOOL api_spoolss_startdocprinter(uint16 vuid, prs_struct *data, prs_struc /******************************************************************** ********************************************************************/ -static BOOL api_spoolss_enddocprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enddocprinter(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENDDOCPRINTER q_u; SPOOL_R_ENDDOCPRINTER r_u; @@ -415,7 +414,7 @@ static BOOL api_spoolss_enddocprinter(uint16 vuid, prs_struct *data, prs_struct /******************************************************************** ********************************************************************/ -static BOOL api_spoolss_writeprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_writeprinter(prs_struct *data, prs_struct *rdata) { SPOOL_Q_WRITEPRINTER q_u; SPOOL_R_WRITEPRINTER r_u; @@ -446,7 +445,7 @@ static BOOL api_spoolss_writeprinter(uint16 vuid, prs_struct *data, prs_struct * /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_setprinter(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_setprinter(prs_struct *data, prs_struct *rdata) { SPOOL_Q_SETPRINTER q_u; SPOOL_R_SETPRINTER r_u; @@ -479,7 +478,7 @@ static BOOL api_spoolss_setprinter(uint16 vuid, prs_struct *data, prs_struct *rd /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_fcpn(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_fcpn(prs_struct *data, prs_struct *rdata) { SPOOL_Q_FCPN q_u; SPOOL_R_FCPN r_u; @@ -505,7 +504,7 @@ static BOOL api_spoolss_fcpn(uint16 vuid, prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addjob(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_addjob(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ADDJOB q_u; SPOOL_R_ADDJOB r_u; @@ -539,7 +538,7 @@ static BOOL api_spoolss_addjob(uint16 vuid, prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumjobs(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumjobs(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMJOBS q_u; SPOOL_R_ENUMJOBS r_u; @@ -575,7 +574,7 @@ static BOOL api_spoolss_enumjobs(uint16 vuid, prs_struct *data, prs_struct *rdat /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_schedulejob(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_schedulejob(prs_struct *data, prs_struct *rdata) { SPOOL_Q_SCHEDULEJOB q_u; SPOOL_R_SCHEDULEJOB r_u; @@ -600,7 +599,7 @@ static BOOL api_spoolss_schedulejob(uint16 vuid, prs_struct *data, prs_struct *r /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_setjob(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_setjob(prs_struct *data, prs_struct *rdata) { SPOOL_Q_SETJOB q_u; SPOOL_R_SETJOB r_u; @@ -627,7 +626,7 @@ static BOOL api_spoolss_setjob(uint16 vuid, prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprinterdrivers(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumprinterdrivers(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPRINTERDRIVERS q_u; SPOOL_R_ENUMPRINTERDRIVERS r_u; @@ -663,7 +662,7 @@ static BOOL api_spoolss_enumprinterdrivers(uint16 vuid, prs_struct *data, prs_st /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumforms(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumforms(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMFORMS q_u; SPOOL_R_ENUMFORMS r_u; @@ -699,7 +698,7 @@ static BOOL api_spoolss_enumforms(uint16 vuid, prs_struct *data, prs_struct *rda /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumports(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumports(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPORTS q_u; SPOOL_R_ENUMPORTS r_u; @@ -735,7 +734,7 @@ static BOOL api_spoolss_enumports(uint16 vuid, prs_struct *data, prs_struct *rda /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addprinterex(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_addprinterex(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ADDPRINTEREX q_u; SPOOL_R_ADDPRINTEREX r_u; @@ -775,7 +774,7 @@ static BOOL api_spoolss_addprinterex(uint16 vuid, prs_struct *data, prs_struct * /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addprinterdriver(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_addprinterdriver(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ADDPRINTERDRIVER q_u; SPOOL_R_ADDPRINTERDRIVER r_u; @@ -800,7 +799,7 @@ static BOOL api_spoolss_addprinterdriver(uint16 vuid, prs_struct *data, prs_stru /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_getprinterdriverdirectory(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_getprinterdriverdirectory(prs_struct *data, prs_struct *rdata) { SPOOL_Q_GETPRINTERDRIVERDIR q_u; SPOOL_R_GETPRINTERDRIVERDIR r_u; @@ -835,7 +834,7 @@ static BOOL api_spoolss_getprinterdriverdirectory(uint16 vuid, prs_struct *data, /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprinterdata(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumprinterdata(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPRINTERDATA q_u; SPOOL_R_ENUMPRINTERDATA r_u; @@ -868,7 +867,7 @@ static BOOL api_spoolss_enumprinterdata(uint16 vuid, prs_struct *data, prs_struc /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_setprinterdata(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_setprinterdata(prs_struct *data, prs_struct *rdata) { SPOOL_Q_SETPRINTERDATA q_u; SPOOL_R_SETPRINTERDATA r_u; @@ -895,7 +894,7 @@ static BOOL api_spoolss_setprinterdata(uint16 vuid, prs_struct *data, prs_struct /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addform(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_addform(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ADDFORM q_u; SPOOL_R_ADDFORM r_u; @@ -920,7 +919,7 @@ static BOOL api_spoolss_addform(uint16 vuid, prs_struct *data, prs_struct *rdata /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_setform(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_setform(prs_struct *data, prs_struct *rdata) { SPOOL_Q_SETFORM q_u; SPOOL_R_SETFORM r_u; @@ -945,7 +944,7 @@ static BOOL api_spoolss_setform(uint16 vuid, prs_struct *data, prs_struct *rdata /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprintprocessors(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumprintprocessors(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPRINTPROCESSORS q_u; SPOOL_R_ENUMPRINTPROCESSORS r_u; @@ -980,7 +979,7 @@ static BOOL api_spoolss_enumprintprocessors(uint16 vuid, prs_struct *data, prs_s /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprintprocdatatypes(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumprintprocdatatypes(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPRINTPROCDATATYPES q_u; SPOOL_R_ENUMPRINTPROCDATATYPES r_u; @@ -1015,7 +1014,7 @@ static BOOL api_spoolss_enumprintprocdatatypes(uint16 vuid, prs_struct *data, pr /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprintmonitors(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumprintmonitors(prs_struct *data, prs_struct *rdata) { SPOOL_Q_ENUMPRINTMONITORS q_u; SPOOL_R_ENUMPRINTMONITORS r_u; @@ -1050,7 +1049,7 @@ static BOOL api_spoolss_enumprintmonitors(uint16 vuid, prs_struct *data, prs_str /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_getjob(uint16 vuid, prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_getjob(prs_struct *data, prs_struct *rdata) { SPOOL_Q_GETJOB q_u; SPOOL_R_GETJOB r_u; @@ -1127,4 +1126,3 @@ BOOL api_spoolss_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds, data); } - diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index f42b94832b..c5307b264e 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -1,4 +1,3 @@ - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -22,7 +21,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "includes.h" #include "nterr.h" @@ -911,7 +909,7 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, /******************************************************************* ********************************************************************/ -static BOOL api_srv_net_srv_get_info( uint16 vuid, prs_struct *data, +static BOOL api_srv_net_srv_get_info(prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SRV_GET_INFO q_n; @@ -928,7 +926,7 @@ static BOOL api_srv_net_srv_get_info( uint16 vuid, prs_struct *data, /******************************************************************* ********************************************************************/ -static BOOL api_srv_net_file_enum( uint16 vuid, prs_struct *data, +static BOOL api_srv_net_file_enum(prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_FILE_ENUM q_n; @@ -948,7 +946,7 @@ static BOOL api_srv_net_file_enum( uint16 vuid, prs_struct *data, /******************************************************************* ********************************************************************/ -static BOOL api_srv_net_conn_enum( uint16 vuid, prs_struct *data, +static BOOL api_srv_net_conn_enum(prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_CONN_ENUM q_n; @@ -968,7 +966,7 @@ static BOOL api_srv_net_conn_enum( uint16 vuid, prs_struct *data, /******************************************************************* ********************************************************************/ -static BOOL api_srv_net_sess_enum( uint16 vuid, prs_struct *data, +static BOOL api_srv_net_sess_enum(prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SESS_ENUM q_n; @@ -990,7 +988,7 @@ static BOOL api_srv_net_sess_enum( uint16 vuid, prs_struct *data, RPC to enumerate shares. ********************************************************************/ -static BOOL api_srv_net_share_enum( uint16 vuid, prs_struct *data, +static BOOL api_srv_net_share_enum(prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SHARE_ENUM q_n; @@ -1014,7 +1012,7 @@ static BOOL api_srv_net_share_enum( uint16 vuid, prs_struct *data, RPC to return share information. ********************************************************************/ -static BOOL api_srv_net_share_get_info( uint16 vuid, prs_struct *data, +static BOOL api_srv_net_share_get_info(prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_SHARE_GET_INFO q_n; @@ -1077,7 +1075,7 @@ static BOOL srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n, } /******************************************************************* ********************************************************************/ -static BOOL api_srv_net_remote_tod( uint16 vuid, prs_struct *data, +static BOOL api_srv_net_remote_tod(prs_struct *data, prs_struct *rdata ) { SRV_Q_NET_REMOTE_TOD q_n; diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 658cadc625..ee60d73011 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -1,4 +1,3 @@ - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -22,14 +21,11 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "includes.h" -#include "nterr.h" extern int DEBUGLEVEL; extern pstring global_myname; - /******************************************************************* create_wks_info_100 ********************************************************************/ @@ -80,8 +76,7 @@ static void wks_reply_query_info(WKS_Q_QUERY_INFO *q_u, /******************************************************************* api_wks_query_info ********************************************************************/ -static BOOL api_wks_query_info( uint16 vuid, prs_struct *data, - prs_struct *rdata ) +static BOOL api_wks_query_info(prs_struct *data, prs_struct *rdata) { WKS_Q_QUERY_INFO q_u; @@ -111,4 +106,3 @@ BOOL api_wkssvc_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_wkssvc_rpc", api_wks_cmds, data); } - -- cgit From 16d53e8752ba6da1eb2b2b516763570544aca83b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 4 Apr 2000 00:36:19 +0000 Subject: Snuck in some whitespace cleanup while I was visiting these files. (-: (This used to be commit f249dc041f3f3bdb1adaa41271236ffdb2447475) --- source3/rpc_server/srv_lookup.c | 1 - source3/rpc_server/srv_lsa_hnd.c | 3 --- source3/rpc_server/srv_util.c | 2 -- 3 files changed, 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index e6df9933bf..4041cd2660 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -1,4 +1,3 @@ - /* * Unix SMB/Netbios implementation. * Version 1.9. diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 24aec701f0..937da42ec8 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -1,4 +1,3 @@ - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -21,10 +20,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "includes.h" - extern int DEBUGLEVEL; #ifndef MAX_OPEN_POLS diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 097ab92d76..f5cf615fd7 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -1,4 +1,3 @@ - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -39,7 +38,6 @@ */ #include "includes.h" -#include "nterr.h" extern int DEBUGLEVEL; -- cgit From 2d15c34f4fc2f3943328976361ab8c67508b6e82 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 4 Apr 2000 18:44:04 +0000 Subject: Change to vfs API. POSIX states fsync should return an int, not a void. Jeremy. (This used to be commit 6c442d68afae4140e28b770343a900b5ce510b4a) --- source3/rpc_server/srv_netlog.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index db1a4a9c6b..7f893e2633 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -851,7 +851,6 @@ static BOOL api_net_sam_logon(prs_struct *data, prs_struct *rdata) static BOOL api_net_trust_dom_list(prs_struct *data, prs_struct *rdata) { - uint16 vuid = current_user.vuid; NET_Q_TRUST_DOM_LIST q_t; char *trusted_domain = "test_domain"; @@ -886,7 +885,6 @@ static BOOL api_net_trust_dom_list(prs_struct *data, prs_struct *rdata) static BOOL api_net_logon_ctrl2(prs_struct *data, prs_struct *rdata) { - uint16 vuid = current_user.vuid; NET_Q_LOGON_CTRL2 q_l; /* lkclXXXX - guess what - absolutely no idea what these are! */ -- cgit From dc2d1544b3718dce5b3d7d91989b3cc5abfdef6b Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Wed, 5 Apr 2000 10:05:32 +0000 Subject: changed all the status code to ERROR_xxx instead of NT_STATUS_xx which are wrong in the spoolss case. fxed a bug in the job notify code (that's the polite answer), the truth is different: there is a bug in the NT spooler service, including SP6a and NT2K. changed the default lpcommand in the LPRNG case. J.F. (This used to be commit 396f73c11b29a47650b3243fef0825252a3cef9b) --- source3/rpc_server/srv_spoolss_nt.c | 162 ++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 88 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e55f1fb305..79ad5197cd 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -564,7 +564,7 @@ static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode) uint32 _spoolss_closeprinter(POLICY_HND *handle) { if (!close_printer_handle(handle)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; return NT_STATUS_NO_PROBLEMO; } @@ -723,7 +723,7 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, if (!OPEN_HANDLE(Printer)) { *data=(uint8 *)malloc(4*sizeof(uint8)); - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } unistr2_to_ascii(value, valuename, sizeof(value)-1); @@ -767,7 +767,7 @@ uint32 _spoolss_rffpcnex(const POLICY_HND *handle, uint32 flags, uint32 options, Printer_entry *Printer=find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; Printer->notify.flags=flags; Printer->notify.options=options; @@ -1411,7 +1411,7 @@ static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info DEBUG(4,("printer_notify_info\n")); option=Printer->notify.option; - id=1; + id=0xffffffff; info->version=2; info->data=NULL; info->count=0; @@ -1425,15 +1425,14 @@ static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info switch ( option_type->type ) { case PRINTER_NOTIFY_TYPE: if(construct_notify_printer_info(info, snum, option_type, id)) - id++; + id--; break; case JOB_NOTIFY_TYPE: memset(&status, 0, sizeof(status)); count=get_printqueue(snum, NULL, &queue, &status); for (j=0; jprinter_type)); @@ -1496,7 +1495,7 @@ uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, uint32 change, break; } - return NT_STATUS_INVALID_INFO_CLASS; + return ERROR_INVALID_HANDLE; } /******************************************************************** @@ -1577,7 +1576,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, pstring printer->build_version = 0x0565; /* build 1381 */ printer->unknown7 = 0x1; printer->unknown8 = 0x0; - printer->unknown9 = 0x2; + printer->unknown9 = 0x0; printer->session_counter = session_counter->counter; printer->unknown11 = 0x0; printer->printer_errors = 0x0; /* number of print failure */ @@ -2083,7 +2082,7 @@ uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 le case 3: case 4: default: - return NT_STATUS_INVALID_LEVEL; + return ERROR_INVALID_LEVEL; break; } } @@ -2198,7 +2197,7 @@ uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, pstrcpy(servername, global_myname); if (!get_printer_snum(handle, &snum)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; switch (level) { case 0: @@ -2361,7 +2360,7 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, snprintf(temp_helpfile, sizeof(temp_helpfile)-1, "%s%s", where, driver.info_3->helpfile); init_unistr( &(info->helpfile), temp_helpfile ); - init_unistr( &(info->monitorname), driver.info_3->monitorname ); + init_unistr( &(info->monitorname), driver.info_3->monitorname ); init_unistr( &(info->defaultdatatype), driver.info_3->defaultdatatype ); info->dependentfiles=NULL; @@ -2499,7 +2498,7 @@ uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_a unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); if (!get_printer_snum(handle, &snum)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; switch (level) { case 1: @@ -2512,7 +2511,7 @@ uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_a return getprinterdriver2_level3(servername, architecture, snum, buffer, offered, needed); break; default: - return NT_STATUS_INVALID_LEVEL; + return ERROR_INVALID_LEVEL; break; } } @@ -2530,7 +2529,7 @@ uint32 _spoolss_startpageprinter(const POLICY_HND *handle) } DEBUG(3,("Error in startpageprinter printer handle\n")); - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } /**************************************************************************** @@ -2542,7 +2541,7 @@ uint32 _spoolss_endpageprinter(const POLICY_HND *handle) if (!OPEN_HANDLE(Printer)) { DEBUG(3,("Error in endpageprinter printer handle\n")); - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } Printer->page_started=False; @@ -2570,7 +2569,7 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, if (!OPEN_HANDLE(Printer)) { - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } /* @@ -2598,7 +2597,7 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, /* get the share number of the printer */ if (!get_printer_snum(handle, &snum)) { - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } /* Create a temporary file in the printer spool directory @@ -2643,7 +2642,7 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle) if (!OPEN_HANDLE(Printer)) { DEBUG(3,("Error in enddocprinter handle\n")); - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } Printer->document_started=False; @@ -2655,7 +2654,7 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle) if (!get_printer_snum(handle,&snum)) { - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } /* copy the command into the buffer for extensive meddling. */ @@ -2681,8 +2680,7 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle) */ tstr = lp_printername(snum); - if (tstr == NULL || tstr[0] == '\0') - { + if (tstr == NULL || tstr[0] == '\0') { DEBUG(3,( "No printer name - using %s.\n", SERVICE(snum))); tstr = SERVICE(snum); } @@ -2692,22 +2690,19 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle) /* If the lpr command support the 'Job' option replace here */ pstring_sub(syscmd, "%j", job_name); - if ( *syscmd != '\0') - { - int ret = smbrun(syscmd, NULL, False); - DEBUG(3,("Running the command `%s' gave %d\n", syscmd, ret)); - if (ret < 0) - { + if ( *syscmd != '\0') { + int ret = smbrun(syscmd, NULL, False); + DEBUG(3,("Running the command `%s' gave %d\n", syscmd, ret)); + if (ret < 0) { lpq_reset(snum); - return NT_STATUS_ACCESS_DENIED; + return ERROR_ACCESS_DENIED; } } - else - { - DEBUG(0,("Null print command?\n")); - lpq_reset(snum); - return NT_STATUS_ACCESS_DENIED; - } + else { + DEBUG(0,("Null print command?\n")); + lpq_reset(snum); + return ERROR_ACCESS_DENIED; + } lpq_reset(snum); @@ -2727,7 +2722,7 @@ uint32 _spoolss_writeprinter( const POLICY_HND *handle, if (!OPEN_HANDLE(Printer)) { DEBUG(3,("Error in writeprinter handle\n")); - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } fd = Printer->document_fd; @@ -2748,10 +2743,10 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command) Printer_entry *Printer = find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; if (!get_printer_snum(handle, &snum) ) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; switch (command) { case PRINTER_CONTROL_PAUSE: @@ -2777,7 +2772,7 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command) break; } - return NT_STATUS_INVALID_INFO_CLASS; + return ERROR_INVALID_FUNCTION; } /******************************************************************** @@ -2800,14 +2795,14 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, if (level!=2) { DEBUG(0,("Send a mail to jfm@samba.org\n")); DEBUGADD(0,("with the following message: update_printer: level!=2\n")); - return NT_STATUS_INVALID_INFO_CLASS; + return ERROR_INVALID_LEVEL; } if (!OPEN_HANDLE(Printer)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; if (!get_printer_snum(handle, &snum) ) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; get_a_printer(&printer, 2, lp_servicename(snum)); @@ -2840,7 +2835,7 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, free_a_printer(printer, 2); /* I don't really know what to return here !!! */ - return NT_STATUS_INVALID_INFO_CLASS; + return ERROR_ACCESS_DENIED; } free_a_printer(printer, 2); @@ -2858,7 +2853,7 @@ uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, Printer_entry *Printer = find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; /* check the level */ switch (level) { @@ -2881,7 +2876,7 @@ uint32 _spoolss_fcpn(const POLICY_HND *handle) Printer_entry *Printer= find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; Printer->notify.flags=0; Printer->notify.options=0; @@ -3087,7 +3082,7 @@ uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, if (!get_printer_snum(handle, &snum)) { - return NT_STATUS_INVALID_HANDLE; + return ERROR_INVALID_HANDLE; } *returned = get_printqueue(snum, NULL, &queue, &prt_status); @@ -3101,7 +3096,7 @@ uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, return enumjobs_level2(queue, snum, buffer, offered, needed, returned); break; default: - return NT_STATUS_INVALID_LEVEL; + return ERROR_INVALID_LEVEL; break; } } @@ -3133,26 +3128,21 @@ uint32 _spoolss_setjob( const POLICY_HND *handle, memset(&prt_status, 0, sizeof(prt_status)); - if (!get_printer_snum(handle, &snum)) - { - return NT_STATUS_INVALID_HANDLE; + if (!get_printer_snum(handle, &snum)) { + return ERROR_INVALID_HANDLE; } count=get_printqueue(snum, NULL, &queue, &prt_status); - while ( (i Date: Thu, 6 Apr 2000 16:23:04 +0000 Subject: filled the architecture table (useless for the moment). fixed GetJob. J.F. (This used to be commit 3fea49e1d896987c54187cb326607284810fcb0d) --- source3/rpc_server/srv_spoolss_nt.c | 55 +++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 79ad5197cd..b7533c7873 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2939,9 +2939,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, time_t unixdate = time(NULL); if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) - { - return (False); - } + return False; t=gmtime(&unixdate); snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); @@ -2993,25 +2991,31 @@ static uint32 enumjobs_level1(print_queue_struct *queue, int snum, int i; info=(JOB_INFO_1 *)malloc(*returned*sizeof(JOB_INFO_1)); + if (info==NULL) { + safe_free(queue); + *returned=0; + return ERROR_NOT_ENOUGH_MEMORY; + } for (i=0; i<*returned; i++) - { fill_job_info_1(&(info[i]), &(queue[i]), i, snum); - } + + safe_free(queue); /* check the required size. */ for (i=0; i<*returned; i++) (*needed) += spoolss_size_job_info_1(&(info[i])); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(info); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the structures */ for (i=0; i<*returned; i++) new_smb_io_job_info_1("", buffer, &(info[i]), 0); /* clear memory */ - safe_free(queue); safe_free(info); if (*needed > offered) { @@ -3033,25 +3037,31 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum, int i; info=(JOB_INFO_2 *)malloc(*returned*sizeof(JOB_INFO_2)); + if (info==NULL) { + safe_free(queue); + *returned=0; + return ERROR_NOT_ENOUGH_MEMORY; + } for (i=0; i<*returned; i++) - { fill_job_info_2(&(info[i]), &(queue[i]), i, snum); - } + + safe_free(queue); /* check the required size. */ for (i=0; i<*returned; i++) (*needed) += spoolss_size_job_info_2(&(info[i])); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(info); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the structures */ for (i=0; i<*returned; i++) new_smb_io_job_info_2("", buffer, &(info[i]), 0); /* clear memory */ - safe_free(queue); safe_free(info); if (*needed > offered) { @@ -3081,9 +3091,7 @@ uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, *returned=0; if (!get_printer_snum(handle, &snum)) - { return ERROR_INVALID_HANDLE; - } *returned = get_printqueue(snum, NULL, &queue, &prt_status); DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); @@ -3096,13 +3104,14 @@ uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, return enumjobs_level2(queue, snum, buffer, offered, needed, returned); break; default: + safe_free(queue); + *returned=0; return ERROR_INVALID_LEVEL; break; } } - /**************************************************************************** ****************************************************************************/ uint32 _spoolss_schedulejob( const POLICY_HND *handle, uint32 jobid) @@ -4156,16 +4165,21 @@ 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; } - fill_job_info_1(info_1, &(queue[i]), i, snum); + fill_job_info_1(info_1, &(queue[i-1]), i, snum); + + safe_free(queue); *needed += spoolss_size_job_info_1(info_1); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(info_1); return ERROR_INSUFFICIENT_BUFFER; + } new_smb_io_job_info_1("", buffer, info_1, 0); @@ -4199,16 +4213,21 @@ 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; } - fill_job_info_2(info_2, &(queue[i]), i, snum); + fill_job_info_2(info_2, &(queue[i-1]), i, snum); + + safe_free(queue); *needed += spoolss_size_job_info_2(info_2); - if (!alloc_buffer_size(buffer, *needed)) + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(info_2); return ERROR_INSUFFICIENT_BUFFER; + } new_smb_io_job_info_2("", buffer, info_2, 0); -- cgit From aac823aca154c46264dd29510c89b8eafac361c8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 6 Apr 2000 22:48:53 +0000 Subject: Modified interfaces and added checks around *all* *alloc calls so that errors are returned on memory allocation failure. Jeremy. (This used to be commit 9a118cd4a2b03146b341eeffb62144a2d29b574c) --- source3/rpc_server/srv_spoolss.c | 39 +++++--- source3/rpc_server/srv_spoolss_nt.c | 195 +++++++++++++++++++++++++++--------- 2 files changed, 174 insertions(+), 60 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index f23422d87a..8ae75eec6c 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -199,7 +199,8 @@ static BOOL api_spoolss_enumprinters(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n")); @@ -237,7 +238,8 @@ static BOOL api_spoolss_getprinter(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_getprinter("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n")); @@ -275,7 +277,8 @@ static BOOL api_spoolss_getprinterdriver2(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n")); @@ -512,7 +515,8 @@ static BOOL api_spoolss_addjob(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_addjob("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_addjob: unable to unmarshall SPOOL_Q_ADDJOB.\n")); @@ -546,7 +550,8 @@ static BOOL api_spoolss_enumjobs(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n")); @@ -634,7 +639,8 @@ static BOOL api_spoolss_enumprinterdrivers(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n")); @@ -670,7 +676,8 @@ static BOOL api_spoolss_enumforms(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if (!spoolss_io_q_enumforms("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n")); @@ -706,7 +713,8 @@ static BOOL api_spoolss_enumports(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_enumports("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n")); @@ -807,7 +815,8 @@ static BOOL api_spoolss_getprinterdriverdirectory(prs_struct *data, prs_struct * ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_getprinterdriverdir("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n")); @@ -952,7 +961,8 @@ static BOOL api_spoolss_enumprintprocessors(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n")); @@ -987,7 +997,8 @@ static BOOL api_spoolss_enumprintprocdatatypes(prs_struct *data, prs_struct *rda ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n")); @@ -1022,7 +1033,8 @@ static BOOL api_spoolss_enumprintmonitors(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n")); @@ -1054,7 +1066,8 @@ static BOOL api_spoolss_getjob(prs_struct *data, prs_struct *rdata) SPOOL_Q_GETJOB q_u; SPOOL_R_GETJOB r_u; - new_spoolss_allocate_buffer(&q_u.buffer); + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; if(!spoolss_io_q_getjob("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n")); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b7533c7873..1d33b1b8bb 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -227,7 +227,9 @@ static BOOL open_printer_hnd(POLICY_HND *hnd) { Printer_entry *new_printer; - new_printer=(Printer_entry *)malloc(sizeof(Printer_entry)); + if((new_printer=(Printer_entry *)malloc(sizeof(Printer_entry))) == NULL) + return False; + ZERO_STRUCTP(new_printer); new_printer->open = True; @@ -343,6 +345,9 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) continue; + DEBUG(10,("set_printer_hnd_printername: printername [%s], aprinter [%s]\n", + printer.info_2->printername, aprinter )); + if ( strlen(printer.info_2->printername) != strlen(aprinter) ) { free_a_printer(printer, 2); continue; @@ -551,7 +556,8 @@ static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode) /* if we had a previous private delete it and make a new one */ if (nt_devmode->private != NULL) free(nt_devmode->private); - nt_devmode->private=(uint8 *)malloc(nt_devmode->driverextra * sizeof(uint8)); + if((nt_devmode->private=(uint8 *)malloc(nt_devmode->driverextra * sizeof(uint8))) == NULL) + return False; memcpy(nt_devmode->private, devmode.private, nt_devmode->driverextra); } @@ -581,7 +587,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d if (!strcmp(value, "BeepEnabled")) { *type = 0x4; - *data = (uint8 *)malloc( 4*sizeof(uint8) ); + if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL) + return False; SIVAL(*data, 0, 0x01); *needed = 0x4; return True; @@ -590,7 +597,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d if (!strcmp(value, "EventLog")) { *type = 0x4; - *data = (uint8 *)malloc( 4*sizeof(uint8) ); + if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL) + return False; SIVAL(*data, 0, 0x1B); *needed = 0x4; return True; @@ -599,7 +607,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d if (!strcmp(value, "NetPopup")) { *type = 0x4; - *data = (uint8 *)malloc( 4*sizeof(uint8) ); + if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL) + return False; SIVAL(*data, 0, 0x01); *needed = 0x4; return True; @@ -608,7 +617,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d if (!strcmp(value, "MajorVersion")) { *type = 0x4; - *data = (uint8 *)malloc( 4*sizeof(uint8) ); + if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL) + return False; SIVAL(*data, 0, 0x02); *needed = 0x4; return True; @@ -619,7 +629,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d pstring string="You are using a Samba server"; *type = 0x1; *needed = 2*(strlen(string)+1); - *data = (uint8 *)malloc( ((*needed > in_size) ? *needed:in_size) *sizeof(uint8)); + if((*data = (uint8 *)malloc( ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) + return False; memset(*data, 0, (*needed > in_size) ? *needed:in_size); /* it's done by hand ready to go on the wire */ @@ -636,7 +647,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d pstring string="Windows NT x86"; *type = 0x1; *needed = 2*(strlen(string)+1); - *data = (uint8 *)malloc( ((*needed > in_size) ? *needed:in_size) *sizeof(uint8)); + if((*data = (uint8 *)malloc( ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) + return False; memset(*data, 0, (*needed > in_size) ? *needed:in_size); for (i=0; iin_size)?in_size:len *sizeof(uint8)); @@ -722,7 +741,8 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, DEBUG(4,("_spoolss_getprinterdata\n")); if (!OPEN_HANDLE(Printer)) { - *data=(uint8 *)malloc(4*sizeof(uint8)); + if((*data=(uint8 *)malloc(4*sizeof(uint8))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; return ERROR_INVALID_HANDLE; } @@ -736,7 +756,8 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, if (found==False) { DEBUG(5, ("value not found, allocating %d\n", *out_size)); /* reply this param doesn't exist */ - *data=(uint8 *)malloc(*out_size*sizeof(uint8)); + if((*data=(uint8 *)malloc(*out_size*sizeof(uint8))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; memset(*data, 0x0, *out_size*sizeof(uint8)); return ERROR_INVALID_PARAMETER; } @@ -1250,7 +1271,10 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO if (!search_notify(type, field, &j) ) continue; - info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA)); + if((info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) { + free_a_printer(printer, 2); + return False; + } current_data=&(info->data[info->count]); construct_info_data(current_data, type, field, id); @@ -1297,7 +1321,11 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I if (!search_notify(type, field, &j) ) continue; - info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA)); + if((info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) { + free_a_printer(printer, 2); + return False; + } + current_data=&(info->data[info->count]); construct_info_data(current_data, type, field, id); @@ -1531,7 +1559,8 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, pstring /* it's the first time, add it to the list */ if (session_counter==NULL) { - session_counter=(counter_printer_0 *)malloc(sizeof(counter_printer_0)); + if((session_counter=(counter_printer_0 *)malloc(sizeof(counter_printer_0))) == NULL) + return False; ZERO_STRUCTP(session_counter); session_counter->snum=snum; session_counter->counter=0; @@ -1635,7 +1664,7 @@ static BOOL construct_printer_info_1(fstring server, uint32 flags, PRINTER_INFO_ /**************************************************************************** ****************************************************************************/ -static void construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) +static BOOL construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) { char adevice[32]; char aform[32]; @@ -1686,11 +1715,16 @@ static void construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) if (ntdevmode->private != NULL) { - devmode->private=(uint8 *)malloc(devmode->driverextra*sizeof(uint8)); + if((devmode->private=(uint8 *)malloc(devmode->driverextra*sizeof(uint8))) == NULL) { + free_a_printer(printer, 2); + return False; + } memcpy(devmode->private, ntdevmode->private, devmode->driverextra); } free_a_printer(printer, 2); + + return True; } /******************************************************************** @@ -1749,14 +1783,25 @@ static BOOL construct_printer_info_2(pstring servername, PRINTER_INFO_2 *printer printer->cjobs = count; /* jobs */ printer->averageppm = ntprinter.info_2->averageppm; /* average pages per minute */ - devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE)); + if((devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL) + goto err; + ZERO_STRUCTP(devmode); - construct_dev_mode(devmode, snum, servername); + + if(!construct_dev_mode(devmode, snum, servername)) + goto err; + printer->devmode=devmode; safe_free(queue); free_a_printer(ntprinter, 2); return True; + + err: + + safe_free(queue); + free_a_printer(ntprinter, 2); + return False; } /******************************************************************** @@ -1777,7 +1822,10 @@ static BOOL enum_all_printers_info_1(fstring server, uint32 flags, NEW_BUFFER *b DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); if (construct_printer_info_1(server, flags, ¤t_prt, snum)) { - printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1)); + if((printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) { + *returned=0; + return ERROR_NOT_ENOUGH_MEMORY; + } DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned)); memcpy(&(printers[*returned]), ¤t_prt, sizeof(PRINTER_INFO_1)); (*returned)++; @@ -1863,7 +1911,8 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui * We should have a TDB here. The registration is done thru an undocumented RPC call. */ - printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1)); + if((printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; *returned=1; @@ -1930,7 +1979,8 @@ static BOOL enum_all_printers_info_2(fstring servername, NEW_BUFFER *buffer, uin DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); if (construct_printer_info_2(servername, ¤t_prt, snum)) { - printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2)); + if((printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *returned)); memcpy(&(printers[*returned]), ¤t_prt, sizeof(PRINTER_INFO_2)); (*returned)++; @@ -2093,7 +2143,8 @@ static uint32 getprinter_level_0(pstring servername, int snum, NEW_BUFFER *buffe { PRINTER_INFO_0 *printer=NULL; - printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0)); + if((printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; construct_printer_info_0(printer, snum, servername); @@ -2124,7 +2175,9 @@ static uint32 getprinter_level_1(pstring servername, int snum, NEW_BUFFER *buffe { PRINTER_INFO_1 *printer=NULL; - printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1)); + if((printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; + construct_printer_info_1(servername, PRINTER_ENUM_ICON8, printer, snum); /* check the required size. */ @@ -2155,7 +2208,8 @@ static uint32 getprinter_level_2(pstring servername, int snum, NEW_BUFFER *buffe PRINTER_INFO_2 *printer=NULL; fstring temp; - printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)); + if((printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)))==NULL) + return ERROR_NOT_ENOUGH_MEMORY; fstrcpy(temp, "\\\\"); fstrcat(temp, servername); @@ -2313,7 +2367,10 @@ static void init_unistr_array(uint16 **uni_array, char **char_array, char *where for (v=char_array[i]; *v!='\0'; v=char_array[i]) { snprintf(line, sizeof(line)-1, "%s%s", where, v); DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); - *uni_array=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16)); + if((*uni_array=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL) { + DEBUG(0,("init_unistr_array: Realloc error\n" )); + return; + } ascii_to_unistr( *uni_array+j, line , strlen(line)); j+=strlen(line)+1; i++; @@ -2392,7 +2449,8 @@ static uint32 getprinterdriver2_level1(pstring servername, pstring architecture, { DRIVER_INFO_1 *info=NULL; - info=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1)); + if((info=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; construct_printer_driver_info_1(info, snum, servername, architecture); @@ -2422,7 +2480,8 @@ static uint32 getprinterdriver2_level2(pstring servername, pstring architecture, { DRIVER_INFO_2 *info=NULL; - info=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2)); + if((info=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; construct_printer_driver_info_2(info, snum, servername, architecture); @@ -2452,7 +2511,8 @@ static uint32 getprinterdriver2_level3(pstring servername, pstring architecture, { DRIVER_INFO_3 *info=NULL; - info=(DRIVER_INFO_3 *)malloc(sizeof(DRIVER_INFO_3)); + if((info=(DRIVER_INFO_3 *)malloc(sizeof(DRIVER_INFO_3)))==NULL) + return ERROR_NOT_ENOUGH_MEMORY; construct_printer_driver_info_3(info, snum, servername, architecture); @@ -2971,9 +3031,16 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, job_info->timeelapsed=0; job_info->pagesprinted=0; - devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE)); + if((devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL) { + free_a_printer(ntprinter, 2); + return False; + } + ZERO_STRUCTP(devmode); - construct_dev_mode(devmode, snum, global_myname); + if(!construct_dev_mode(devmode, snum, global_myname)) { + free_a_printer(ntprinter, 2); + return False; + } job_info->devmode=devmode; free_a_printer(ntprinter, 2); @@ -3189,7 +3256,9 @@ static uint32 enumprinterdrivers_level1(fstring *list, fstring servername, fstri int i; NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_1 *driver_info_1=NULL; - driver_info_1=(DRIVER_INFO_1 *)malloc(*returned * sizeof(DRIVER_INFO_1)); + + if((driver_info_1=(DRIVER_INFO_1 *)malloc(*returned * sizeof(DRIVER_INFO_1))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; for (i=0; i<*returned; i++) { get_a_printer_driver(&driver, 3, list[i], architecture); @@ -3234,7 +3303,9 @@ static uint32 enumprinterdrivers_level2(fstring *list, fstring servername, fstri int i; NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_2 *driver_info_2=NULL; - driver_info_2=(DRIVER_INFO_2 *)malloc(*returned * sizeof(DRIVER_INFO_2)); + + if((driver_info_2=(DRIVER_INFO_2 *)malloc(*returned * sizeof(DRIVER_INFO_2))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; for (i=0; i<*returned; i++) { get_a_printer_driver(&driver, 3, list[i], architecture); @@ -3279,7 +3350,9 @@ static uint32 enumprinterdrivers_level3(fstring *list, fstring servername, fstri int i; NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_3 *driver_info_3=NULL; - driver_info_3=(DRIVER_INFO_3 *)malloc((*returned)*sizeof(DRIVER_INFO_3)); + + if((driver_info_3=(DRIVER_INFO_3 *)malloc((*returned)*sizeof(DRIVER_INFO_3))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; for (i=0; i<*returned; i++) { get_a_printer_driver(&driver, 3, list[i], architecture); @@ -3340,6 +3413,9 @@ uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32 *returned=get_ntdrivers(&list, architecture); DEBUGADD(4,("we have: [%d] drivers in environment [%s]\n", *returned, architecture)); + if(*returned == -1) + return ERROR_NOT_ENOUGH_MEMORY; + for (i=0; i<*returned; i++) DEBUGADD(5,("driver: [%s]\n", list[i])); @@ -3393,7 +3469,10 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, switch (level) { case 1: - forms_1=(FORM_1 *)malloc(*numofforms * sizeof(FORM_1)); + if((forms_1=(FORM_1 *)malloc(*numofforms * sizeof(FORM_1))) == NULL) { + *numofforms=0; + return ERROR_NOT_ENOUGH_MEMORY; + } /* construct the list of form structures */ for (i=0; i<*numofforms; i++) { @@ -3472,7 +3551,8 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) (*returned)++; - ports=(PORT_INFO_1 *)malloc( (*returned+1) * sizeof(PORT_INFO_1) ); + if((ports=(PORT_INFO_1 *)malloc( (*returned+1) * sizeof(PORT_INFO_1) )) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; for (snum=0; snumname), "winprint"); @@ -4010,7 +4104,9 @@ static uint32 enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, { PRINTPROCDATATYPE_1 *info_1=NULL; - info_1 = (PRINTPROCDATATYPE_1 *)malloc(sizeof(PRINTPROCDATATYPE_1)); + if((info_1 = (PRINTPROCDATATYPE_1 *)malloc(sizeof(PRINTPROCDATATYPE_1))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; + (*returned) = 0x1; init_unistr(&(info_1->name), "RAW"); @@ -4060,7 +4156,9 @@ static uint32 enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint { PRINTMONITOR_1 *info_1=NULL; - info_1 = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1)); + if((info_1 = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; + (*returned) = 0x1; init_unistr(&(info_1->name), "Local Port"); @@ -4089,7 +4187,9 @@ static uint32 enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint { PRINTMONITOR_2 *info_2=NULL; - info_2 = (PRINTMONITOR_2 *)malloc(sizeof(PRINTMONITOR_2)); + if((info_2 = (PRINTMONITOR_2 *)malloc(sizeof(PRINTMONITOR_2))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; + (*returned) = 0x1; init_unistr(&(info_2->name), "Local Port"); @@ -4151,6 +4251,7 @@ static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uin int i=0; BOOL found=False; JOB_INFO_1 *info_1=NULL; + info_1=(JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1)); if (info_1 == NULL) { -- cgit From 416fa5377bfca53f21b1fe9c1a71c7ca255abeb2 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 10 Apr 2000 21:47:46 +0000 Subject: added checks to open both \\server\printer and \\server\share. it doesn't work, the getprinter level 0 reply is wrong... J.F. (This used to be commit a7b09e3e11dc66779ee50524ebe1f6687ec744c6) --- source3/rpc_server/srv_spoolss_nt.c | 47 ++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1d33b1b8bb..3f9e98caa3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -327,6 +327,7 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) aprinter++; DEBUGADD(5,("searching for [%s] (len=%d)\n", aprinter, strlen(aprinter))); + /* * store the Samba share name in it * in back we have the long printer name @@ -361,14 +362,54 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) found=True; } - if (found==False) - { + /* + * if we haven't found a printer with the given printername + * then it can be a share name as you can open both \\server\printer and + * \\server\share + */ + + /* + * we still check if the printer description file exists as NT won't be happy + * if we reply OK in the openprinter call and can't reply in the subsequent RPC calls + */ + + if (found==False) { + DEBUGADD(5,("Printer not found, checking for share now\n")); + + for (snum=0;snumprintername, aprinter )); + + if ( strlen(lp_servicename(snum)) != strlen(aprinter) ) { + free_a_printer(printer, 2); + continue; + } + + if ( strncasecmp(lp_servicename(snum), aprinter, strlen(aprinter))) { + free_a_printer(printer, 2); + continue; + } + + found=True; + } + } + + if (found==False) { DEBUGADD(4,("Printer not found\n")); return False; } snum--; - DEBUGADD(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); + DEBUGADD(4,("Printer found: %s -> %s[%x]\n",printer.info_2->printername, lp_servicename(snum),snum)); ZERO_STRUCT(Printer->dev.printername); strncpy(Printer->dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); free_a_printer(printer, 2); -- cgit From 2fa922611bf7160e2c1ce80c11b50006448bf98d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 11 Apr 2000 13:55:53 +0000 Subject: finally got sick of the "extern int Client" code and the stupid assumption that we have one socket everywhere while doing so I discovered a few bugs! 1) the clientgen session retarget code if used from smbd or nmbd would cause a crash as it called close_sockets() which closed our main socket! fixed by removing close_sockets() completely - it is unnecessary 2) the caching in client_addr() and client_name() was bogus - it could easily get fooled and give the wrong result. fixed. 3) the retarget could could recurse, allowing an easy denial of service attack on nmbd. fixed. (This used to be commit 5937ab14d222696e40a3fc6f0e6a536f2d7305d3) --- source3/rpc_server/srv_netlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 7f893e2633..a198b6b98a 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -276,7 +276,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) */ if (!allow_access(lp_domain_hostsdeny(), lp_domain_hostsallow(), - client_name(Client), client_addr(Client))) + client_name(), client_addr())) { DEBUG(0,("get_md4pw: Workstation %s denied access to domain\n", mach_acct)); return False; -- cgit From 067b341a01319577f59e4c742f7bf11b42381ecc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 14 Apr 2000 19:02:41 +0000 Subject: Ensure sign&seal work. Data len must have RPC_HEADER_LEN removed, but offset should not (rpc header already consumed). This fix does not affect tng. Jeremy. (This used to be commit 018ec4fdd937994824f53cb956cea1ade9690f97) --- source3/rpc_server/srv_pipe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index ebb38154d3..a20b112196 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -969,7 +969,11 @@ BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); if (auth_seal) { - char *data = prs_data_p(rpc_in) + RPC_HEADER_LEN + RPC_HDR_REQ_LEN; + /* + * The data in rpc_in doesn't contain the RPC_HEADER as this + * has already been consumed. + */ + char *data = prs_data_p(rpc_in) + RPC_HDR_REQ_LEN; NTLMSSPcalc_p(p, (uchar*)data, data_len); crc32 = crc32_calc_buffer(data, data_len); } -- cgit From 8a91379a00cade86a0b448c6a7c4e949cc58185c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 16 Apr 2000 06:20:43 +0000 Subject: JF and Jeremy - please have a look at what I did to the spoolss code. It now uses the new printing backend. ------------ The following series of commits are for the new tdb based printing backend. This completely replaces our old printing backend. Major changes include: - all print ops are now done in printing/*.c rather than scattered all over the place - system job ids are decoupled from SMB job ids - the lpq parsers don't need to be nearly so smart, they only need to parse the filename, the status and system job id - we can store lots more info about a job, including the full job name - the queue cache control is much better I also added a new utility routine file_lines_load() that loads a text file and parses it into lines. This is used in out lpq parsing and I also want to use it to replace all of our fgets() based code in other places. (This used to be commit 2df82862c061cca5644f5f69146c97302ccb42d5) --- source3/rpc_server/srv_spoolss_nt.c | 242 +++++++++--------------------------- 1 file changed, 59 insertions(+), 183 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3f9e98caa3..54564b6c7d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -46,11 +46,7 @@ typedef struct _Printer{ BOOL open; BOOL document_started; BOOL page_started; - uint32 current_jobid; - uint32 document_fd; - uint32 document_lastwritten; - pstring document_name; - pstring job_name; + int jobid; /* jobid in printing backend */ POLICY_HND printer_hnd; BOOL printer_type; union { @@ -183,11 +179,9 @@ static BOOL close_printer_handle(POLICY_HND *hnd) ****************************************************************************/ static BOOL get_printer_snum(const POLICY_HND *hnd, int *number) { - int snum; Printer_entry *Printer = find_printer_index_by_hnd(hnd); - int n_services=lp_numservices(); - if (!OPEN_HANDLE(Printer)) { + if (!OPEN_HANDLE(Printer)) { DEBUG(3,("Error getting printer - take a nap quickly !\n")); return False; } @@ -195,22 +189,8 @@ static BOOL get_printer_snum(const POLICY_HND *hnd, int *number) switch (Printer->printer_type) { case PRINTER_HANDLE_IS_PRINTER: DEBUG(4,("short name:%s\n", Printer->dev.printername)); - for (snum=0;snumdev.printername ) ) - && ( !strncasecmp(lp_servicename(snum), - Printer->dev.printername, - strlen( lp_servicename(snum) ))) ) { - DEBUG(4,("Printer found: %s[%x]\n",lp_servicename(snum),snum)); - *number=snum; - return True; - break; - } - } - } - return False; - break; + *number = print_queue_snum(Printer->dev.printername); + return (*number != -1); case PRINTER_HANDLE_IS_PRINTSERVER: return False; break; @@ -338,7 +318,7 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) for (snum=0;snumnotify_data.value[0]=(uint32) status.status; safe_free(q); } @@ -1065,7 +1045,7 @@ static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_q print_status_struct status; memset(&status, 0, sizeof(status)); - data->notify_data.value[0]=get_printqueue(snum, NULL, &q, &status); + data->notify_data.value[0] = print_queue_status(snum, &q, &status); safe_free(q); } @@ -1499,7 +1479,7 @@ static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info case JOB_NOTIFY_TYPE: memset(&status, 0, sizeof(status)); - count=get_printqueue(snum, NULL, &queue, &status); + count = print_queue_status(snum, &queue, &status); for (j=0; jdoc_info_1; - - pstring fname; - pstring tempname; - pstring datatype; - int fd = -1; int snum; + pstring jobname; + fstring datatype; Printer_entry *Printer = find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) @@ -2701,24 +2678,18 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, return ERROR_INVALID_HANDLE; } - /* Create a temporary file in the printer spool directory - * and open it - */ - - slprintf(tempname,sizeof(tempname)-1, "%s/smb_print.XXXXXX",lp_pathname(snum)); - pstrcpy(fname, (char *)mktemp(tempname)); - - fd=open(fname, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, S_IRUSR|S_IWUSR ); - DEBUG(4,("Temp spool file created: [%s]\n", fname)); - - Printer->current_jobid=fd; - pstrcpy(Printer->document_name, fname); + unistr2_to_ascii(jobname, &info_1->docname, sizeof(jobname)); - unistr2_to_ascii(Printer->job_name, &info_1->docname, sizeof(Printer->job_name)); + Printer->jobid = print_job_start(snum, jobname); + + /* need to map error codes properly - for now give out of + memory as I don't know the correct codes (tridge) */ + if (Printer->jobid == -1) { + return ERROR_NOT_ENOUGH_MEMORY; + } - Printer->document_fd=fd; Printer->document_started=True; - (*jobid) = Printer->current_jobid; + (*jobid) = Printer->jobid; return 0x0; } @@ -2730,16 +2701,8 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, ********************************************************************/ uint32 _spoolss_enddocprinter(const POLICY_HND *handle) { - int snum; - pstring filename; - pstring filename1; - pstring job_name; - pstring syscmd; - char *tstr; Printer_entry *Printer=find_printer_index_by_hnd(handle); - *syscmd=0; - if (!OPEN_HANDLE(Printer)) { DEBUG(3,("Error in enddocprinter handle\n")); @@ -2747,65 +2710,8 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle) } Printer->document_started=False; - close(Printer->document_fd); - DEBUG(4,("Temp spool file closed, printing now ...\n")); - - pstrcpy(filename1, Printer->document_name); - pstrcpy(job_name, Printer->job_name); - - if (!get_printer_snum(handle,&snum)) - { - return ERROR_INVALID_HANDLE; - } - - /* copy the command into the buffer for extensive meddling. */ - StrnCpy(syscmd, lp_printcommand(snum), sizeof(pstring) - 1); - - /* look for "%s" in the string. If there is no %s, we cannot print. */ - if (!strstr(syscmd, "%s") && !strstr(syscmd, "%f")) - { - DEBUG(2,("WARNING! No placeholder for the filename in the print command for service %s!\n", SERVICE(snum))); - } - - if (strstr(syscmd,"%s")) - { - pstrcpy(filename,filename1); - pstring_sub(syscmd, "%s", filename); - } - - pstring_sub(syscmd, "%f", filename1); - - /* Does the service have a printername? If not, make a fake and empty - * printer name. That way a %p is treated sanely if no printer - * name was specified to replace it. This eventuality is logged. - */ - - tstr = lp_printername(snum); - if (tstr == NULL || tstr[0] == '\0') { - DEBUG(3,( "No printer name - using %s.\n", SERVICE(snum))); - tstr = SERVICE(snum); - } - - pstring_sub(syscmd, "%p", tstr); - - /* If the lpr command support the 'Job' option replace here */ - pstring_sub(syscmd, "%j", job_name); - - if ( *syscmd != '\0') { - int ret = smbrun(syscmd, NULL, False); - DEBUG(3,("Running the command `%s' gave %d\n", syscmd, ret)); - if (ret < 0) { - lpq_reset(snum); - return ERROR_ACCESS_DENIED; - } - } - else { - DEBUG(0,("Null print command?\n")); - lpq_reset(snum); - return ERROR_ACCESS_DENIED; - } - - lpq_reset(snum); + print_job_end(Printer->jobid); + /* error codes unhandled so far ... */ return 0x0; } @@ -2817,7 +2723,6 @@ uint32 _spoolss_writeprinter( const POLICY_HND *handle, const uint8 *buffer, uint32 *buffer_written) { - int fd; Printer_entry *Printer = find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) @@ -2826,9 +2731,7 @@ uint32 _spoolss_writeprinter( const POLICY_HND *handle, return ERROR_INVALID_HANDLE; } - fd = Printer->document_fd; - (*buffer_written) = write(fd, buffer, buffer_size); - Printer->document_lastwritten = (*buffer_written); + (*buffer_written) = print_job_write(Printer->jobid, buffer, buffer_size); return 0x0; } @@ -2850,27 +2753,22 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command) return ERROR_INVALID_HANDLE; switch (command) { - case PRINTER_CONTROL_PAUSE: - /* pause the printer here */ - status_printqueue(NULL, snum, LPSTAT_STOPPED); - return 0x0; - break; - case PRINTER_CONTROL_RESUME: - case PRINTER_CONTROL_UNPAUSE: - /* UN-pause the printer here */ - status_printqueue(NULL, snum, LPSTAT_OK); - return 0x0; - break; - case PRINTER_CONTROL_PURGE: - /* - * It's not handled by samba - * we need a smb.conf param to do - * lprm -P%p - on BSD - * lprm -P%p all on LPRNG - * I don't know on SysV - * we could do it by looping in the job's list... - */ - break; + case PRINTER_CONTROL_PAUSE: + if (print_queue_pause(snum)) { + return 0; + } + break; + case PRINTER_CONTROL_RESUME: + case PRINTER_CONTROL_UNPAUSE: + if (print_queue_resume(snum)) { + return 0; + } + break; + case PRINTER_CONTROL_PURGE: + if (print_queue_purge(snum)) { + return 0; + } + break; } return ERROR_INVALID_FUNCTION; @@ -3201,7 +3099,7 @@ uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, if (!get_printer_snum(handle, &snum)) return ERROR_INVALID_HANDLE; - *returned = get_printqueue(snum, NULL, &queue, &prt_status); + *returned = print_queue_status(snum, &queue, &prt_status); DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); switch (level) { @@ -3237,11 +3135,7 @@ uint32 _spoolss_setjob( const POLICY_HND *handle, { int snum; - print_queue_struct *queue=NULL; print_status_struct prt_status; - int i=0; - BOOL found=False; - int count; memset(&prt_status, 0, sizeof(prt_status)); @@ -3249,44 +3143,26 @@ uint32 _spoolss_setjob( const POLICY_HND *handle, return ERROR_INVALID_HANDLE; } - count=get_printqueue(snum, NULL, &queue, &prt_status); - - while ( (i Date: Sun, 16 Apr 2000 07:28:06 +0000 Subject: - put the job status in english not french! - add helper fns to change from internal status codes to nt spoolss codes (This used to be commit 917c4814fe076cc38b1becf7d219f2437cba6e60) --- source3/rpc_server/srv_spoolss_nt.c | 56 ++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 54564b6c7d..786bc90b91 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -82,6 +82,33 @@ static ubi_dlList counter_list; #define OPEN_HANDLE(pnum) ((pnum!=NULL) && (pnum->open!=False)) +/* translate between internal status numbers and NT status numbers */ +static int nt_printj_status(int v) +{ + switch (v) { + case LPQ_PAUSED: + return PRINTER_STATUS_PAUSED; + case LPQ_QUEUED: + case LPQ_SPOOLING: + case LPQ_PRINTING: + return 0; + } + return 0; +} + +static int nt_printq_status(int v) +{ + switch (v) { + case LPQ_PAUSED: + return PRINTER_STATUS_ERROR; + case LPQ_QUEUED: + case LPQ_SPOOLING: + case LPQ_PRINTING: + return 0; + } + return 0; +} + /**************************************************************************** initialise printer handle states... ****************************************************************************/ @@ -1073,7 +1100,7 @@ static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin ********************************************************************/ static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { - data->notify_data.value[0]=queue->status; + data->notify_data.value[0]=nt_printj_status(queue->status); } /******************************************************************* @@ -1090,8 +1117,23 @@ static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin ********************************************************************/ static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { - data->notify_data.data.length=strlen("En attente"); - ascii_to_unistr(data->notify_data.data.string, "En attente", sizeof(data->notify_data.data.string)-1); + char *p = "unknown"; + switch (queue->status) { + case LPQ_QUEUED: + p = "QUEUED"; + break; + case LPQ_PAUSED: + p = "PAUSED"; + break; + case LPQ_SPOOLING: + p = "SPOOLING"; + break; + case LPQ_PRINTING: + p = "PRINTING"; + break; + } + data->notify_data.data.length=strlen(p); + ascii_to_unistr(data->notify_data.data.string, p, sizeof(data->notify_data.data.string)-1); } /******************************************************************* @@ -1636,7 +1678,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, pstring printer->unknown16 = 0x0; printer->change_id = ntprinter.info_2->changeid; /* ChangeID in milliseconds*/ printer->unknown18 = 0x0; - printer->status = status.status; + printer->status = nt_printq_status(status.status); printer->unknown20 = 0x0; printer->c_setprinter = ntprinter.info_2->c_setprinter; /* how many times setprinter has been called */ printer->unknown22 = 0x0; @@ -1800,7 +1842,7 @@ static BOOL construct_printer_info_2(pstring servername, PRINTER_INFO_2 *printer printer->defaultpriority = ntprinter.info_2->default_priority; /* default priority */ printer->starttime = ntprinter.info_2->starttime; /* starttime */ printer->untiltime = ntprinter.info_2->untiltime; /* untiltime */ - printer->status = status.status; /* status */ + printer->status = nt_printq_status(status.status); /* status */ printer->cjobs = count; /* jobs */ printer->averageppm = ntprinter.info_2->averageppm; /* average pages per minute */ @@ -2915,7 +2957,7 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, init_unistr(&(job_info->document), queue->file); init_unistr(&(job_info->datatype), "RAW"); init_unistr(&(job_info->text_status), ""); - job_info->status=queue->status; + job_info->status=nt_printj_status(queue->status); job_info->priority=queue->priority; job_info->position=position; job_info->totalpages=0; @@ -2959,7 +3001,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, /* and here the security descriptor */ - job_info->status=queue->status; + job_info->status=nt_printj_status(queue->status); job_info->priority=queue->priority; job_info->position=position; job_info->starttime=0; -- cgit From 83170b36c5511b000e36ad0d3a1d9b73a73d2046 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 16 Apr 2000 09:42:09 +0000 Subject: got rid of FILE* in the unix name mapping code (This used to be commit 92f85cef8b4c283374edb726ff0b4999a2000b2a) --- source3/rpc_server/srv_samr.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 88a7f54efa..08bba0eef4 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -116,24 +116,24 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, static char *unmap_unixname(char *unix_user_name, int name_idx) { - FILE *f; char *mapfile = lp_username_map(); char *s; - pstring buf; + char **lines; static pstring tok; + int i; if (!*unix_user_name) return NULL; if (!*mapfile) return NULL; - f = sys_fopen(mapfile,"r"); - if (!f) { + lines = file_lines_load(mapfile, NULL); + if (!lines) { DEBUG(0,("unmap_unixname: can't open username map %s\n", mapfile)); return NULL; } DEBUG(5,("unmap_unixname: scanning username map %s, index: %d\n", mapfile, name_idx)); - while((s=fgets_slash(buf,sizeof(buf),f))!=NULL) { + for (i=0; lines[i]; i++) { char *unixname = s; char *dosname = strchr(unixname,'='); @@ -169,16 +169,16 @@ static char *unmap_unixname(char *unix_user_name, int name_idx) if (name_idx >= 0) { DEBUG(0,("unmap_unixname: index too high - not that many DOS names\n")); - fclose(f); + file_lines_free(lines); return NULL; } else { - fclose(f); + file_lines_free(lines); return tok; } } DEBUG(0,("unmap_unixname: Couldn't find the UNIX user name\n")); - fclose(f); + file_lines_free(lines); return NULL; } -- cgit From d2db520692898c317acc2eba78f88f8398a1fd21 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Apr 2000 21:23:26 +0000 Subject: Sync up with 2.0.7 w.r.t. guest users. Jeremy. (This used to be commit 8a99d824c0e9a43c8a8c81140f8c9005c7e2621a) --- source3/rpc_server/srv_pipe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index a20b112196..fe78d48fa6 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -312,9 +312,9 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm * Allow guest access. Patch from Shirish Kalele . */ - if((strlen(user_name) == 0) && (ntlmssp_resp->hdr_lm_resp.str_str_len==0) && - (ntlmssp_resp->hdr_nt_resp.str_str_len==0)) { - + if((strlen(user_name) == 0) && + (ntlmssp_resp->hdr_nt_resp.str_str_len==0)) + { guest_user = True; fstrcpy(unix_user_name, lp_guestaccount(-1)); -- cgit From 6259f51dd9918eccc9697f3763d918f7c9b82b50 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 22 Apr 2000 00:33:16 +0000 Subject: This is a *big* checkin that may break some things, but implements the new open mechanism Andrew & I discussed. config.sub: configure: Included the QNX patch. include/vfs.h: smbd/vfs-wrap.c: smbd/vfs.c: Added ftruncate vfs call (needed). Note that we will also need locking calls in the vfs (to be added). lib/util_unistr.c: nmbd/nmbd_processlogon.c: Fix for NT domain logons causing nmbd to core dump. Also fix for sidsize DOS bug. locking/locking.c: Check value of ret before using it for memdup. printing/printing.c: Convert print_fsp_open to return an allocated fsp. rpc_server/srv_lsa.c: Fix for NT domain logons. I have removed all use of lp_share_modes() from the code (although I left the parameter in the table for backwards compatibility). It no longer makes sense for this to exist. smbd/close.c: Removed lp_share_modes(). smbd/fileio.c: Fixed parameters to unlock_share_entry call in panic code. smbd/files.c: Correctly set the unix_ERR_code to ERRnofids on fsp allocation fail. smbd/nttrans.c: smbd/reply.c: smbd/trans2.c: Changed all occurrences of open_file_shared/open_directory/ open_file_stat to return an fsp from the call. smbd/open.c: Changed all occurrences of open_file_shared/open_directory/ open_file_stat to return an fsp from the call. In addition I have fixed a long standing race condition in the deny mode processing w.r.t. two smbd's creating a file. Andrew, please note that your original idea of using open with O_EXCL in this case would not work (I went over the races very carefully) and so we must re-check deny modes *after* the open() call returns. This is because there is a race between the open with O_EXCL and the lock of the share mode entry. Imagine the case where the first smbd does the open with O_EXCL and a deny mode of DENY_ALL, but is pre-empted before it locks the share modes and creates the deny mode entry for DENY_ALL. A second smbd could then come in with O_RDONLY and a deny mode of DENY_NONE and the two opens would be allowed. The *only* way to fix this race is to lock the share modes after the open and then do the deny mode checks *after* this lock in the case where the file did not originally exist. This code will need extensive testing but seems to initially work. Jeremy. (This used to be commit ab0ecc39d688f16b9692fe90b991f0b89287070a) --- source3/rpc_server/srv_lsa.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 81e9b737ee..f5dd09d05e 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -512,8 +512,12 @@ static BOOL api_lsa_query_info(prs_struct *data, prs_struct *rdata) switch (q_i.info_class) { case 0x03: - fstrcpy(name, global_myworkgroup); - sid = &global_sam_sid; + if(lp_domain_logons()) { + fstrcpy(name, global_myworkgroup); + sid = &global_sam_sid; + } else { + *name = '\0'; + } break; case 0x05: fstrcpy(name, global_myname); -- cgit From 9e3f457db01aaa97d05b40b265d6659597a03392 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 23 Apr 2000 07:38:18 +0000 Subject: fixed a prs memory leak (weren't freeing input buffer) (This used to be commit be7186b0dd2779fc9f98b4c9f77874ef3ded37d6) --- source3/rpc_server/srv_pipe_hnd.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 88b3dfbe80..2d11c5eda5 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -916,6 +916,7 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) } prs_mem_free(&p->out_data.rdata); + prs_mem_free(&p->in_data.data); bitmap_clear(bmap, p->pnum - pipe_handle_offset); -- cgit From b1686a61091fb10ebaac837c95554076ed49e67a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 23 Apr 2000 08:13:48 +0000 Subject: we can't pass a fstring to a routine expecting a pstring (This used to be commit 8af70f288723e4597bc8639fc0cbec44af2e50c7) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 786bc90b91..52eaaafe6f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1794,7 +1794,7 @@ static BOOL construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) * construct_printer_info_2 * fill a printer_info_2 struct ********************************************************************/ -static BOOL construct_printer_info_2(pstring servername, PRINTER_INFO_2 *printer, int snum) +static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer, int snum) { pstring chaine; pstring chaine2; -- cgit From 6d667ad4d31f9ec02e6cdf289b4958506b847f26 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 23 Apr 2000 08:40:54 +0000 Subject: fixed another spoolss memory leak I am falling in love with insure - it is finding _lots_ of memory problems (This used to be commit d9b4076293a4d37e1558ad63a3f522385ee3e521) --- source3/rpc_server/srv_spoolss.c | 2 ++ source3/rpc_server/srv_spoolss_nt.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 8ae75eec6c..aaa87fe6ff 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -172,6 +172,8 @@ static BOOL api_spoolss_rfnpcnex(prs_struct *data, prs_struct *rdata) r_u.status = _spoolss_rfnpcnex(&q_u.handle, q_u.change, q_u.option, &r_u.info); + safe_free(q_u.option); + /* we always have a NOTIFY_INFO struct */ r_u.info_ptr=0x1; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 52eaaafe6f..05af14e830 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1575,8 +1575,6 @@ uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, uint32 change, if (option!=NULL) safe_free(option->ctr.type); - safe_free(option); - switch (Printer->printer_type) { case PRINTER_HANDLE_IS_PRINTSERVER: return printserver_notify_info(handle, info); -- cgit From d0e9a0c4f2decbf2cd0753bdc25ac1463e8fb22b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 23 Apr 2000 08:44:55 +0000 Subject: another fstring/pstring fix (This used to be commit 91ed7d8ffe8208d06191c64f5332954ec6bf75da) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 05af14e830..89d4c55de1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2362,7 +2362,7 @@ static void construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, ********************************************************************/ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, - pstring servername, fstring architecture) + fstring servername, fstring architecture) { pstring where; pstring temp_driverpath; -- cgit From d315f69e542762efc54f1004e85c860dc5d7177a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 23 Apr 2000 14:25:36 +0000 Subject: more pstring/fstring errors found by insure (This used to be commit ba1931bb6596b538549e712cb8898b1ed19f5adc) --- source3/rpc_server/srv_spoolss_nt.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 89d4c55de1..d1ad0f6229 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1591,7 +1591,7 @@ uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, uint32 change, * construct_printer_info_0 * fill a printer_info_1 struct ********************************************************************/ -static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, pstring servername) +static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring servername) { pstring chaine; int count; @@ -2200,7 +2200,7 @@ uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 le /**************************************************************************** ****************************************************************************/ -static uint32 getprinter_level_0(pstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static uint32 getprinter_level_0(fstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_0 *printer=NULL; @@ -2232,7 +2232,7 @@ static uint32 getprinter_level_0(pstring servername, int snum, NEW_BUFFER *buffe /**************************************************************************** ****************************************************************************/ -static uint32 getprinter_level_1(pstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static uint32 getprinter_level_1(fstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_1 *printer=NULL; @@ -2264,7 +2264,7 @@ static uint32 getprinter_level_1(pstring servername, int snum, NEW_BUFFER *buffe /**************************************************************************** ****************************************************************************/ -static uint32 getprinter_level_2(pstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static uint32 getprinter_level_2(fstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_2 *printer=NULL; fstring temp; @@ -2305,7 +2305,7 @@ uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { int snum; - pstring servername; + fstring servername; *needed=0; @@ -2336,13 +2336,13 @@ uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, ********************************************************************/ static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, - pstring servername, fstring architecture) + fstring servername, fstring architecture) { init_unistr( &(info->name), driver.info_3->name); } static void construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, - pstring servername, fstring architecture) + fstring servername, fstring architecture) { NT_PRINTER_INFO_LEVEL printer; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -2396,7 +2396,7 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, * construct_printer_driver_info_2 * fill a printer_info_2 struct ********************************************************************/ -static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, pstring servername, fstring architecture) +static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstring servername, fstring architecture) { NT_PRINTER_INFO_LEVEL printer; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -2448,7 +2448,7 @@ static void init_unistr_array(uint16 **uni_array, char **char_array, char *where ********************************************************************/ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, - pstring servername, fstring architecture) + fstring servername, fstring architecture) { pstring where; pstring temp_driverpath; @@ -2490,7 +2490,7 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, * fill a printer_info_3 struct ********************************************************************/ static void construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, - pstring servername, fstring architecture) + fstring servername, fstring architecture) { NT_PRINTER_INFO_LEVEL printer; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -2506,7 +2506,7 @@ static void construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, /**************************************************************************** ****************************************************************************/ -static uint32 getprinterdriver2_level1(pstring servername, pstring architecture, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static uint32 getprinterdriver2_level1(fstring servername, fstring architecture, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_1 *info=NULL; @@ -2537,7 +2537,7 @@ static uint32 getprinterdriver2_level1(pstring servername, pstring architecture, /**************************************************************************** ****************************************************************************/ -static uint32 getprinterdriver2_level2(pstring servername, pstring architecture, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static uint32 getprinterdriver2_level2(fstring servername, fstring architecture, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_2 *info=NULL; @@ -2568,7 +2568,7 @@ static uint32 getprinterdriver2_level2(pstring servername, pstring architecture, /**************************************************************************** ****************************************************************************/ -static uint32 getprinterdriver2_level3(pstring servername, pstring architecture, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static uint32 getprinterdriver2_level3(fstring servername, fstring architecture, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_3 *info=NULL; @@ -2605,7 +2605,7 @@ uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_a NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *servermajorversion, uint32 *serverminorversion) { - pstring servername; + fstring servername; fstring architecture; int snum; @@ -3261,7 +3261,8 @@ static uint32 enumprinterdrivers_level2(fstring *list, fstring servername, fstri NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_2 *driver_info_2=NULL; - if((driver_info_2=(DRIVER_INFO_2 *)malloc(*returned * sizeof(DRIVER_INFO_2))) == NULL) + if (*returned > 0 && + !(driver_info_2=(DRIVER_INFO_2 *)malloc(*returned * sizeof(DRIVER_INFO_2)))) return ERROR_NOT_ENOUGH_MEMORY; for (i=0; i<*returned; i++) { -- cgit From 4a57f9763a7b8ab5114bbecf9e1096b66174137f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 25 Apr 2000 00:46:24 +0000 Subject: fixed a memory leak of devmode in spoolss this stuff is screaming out for talloc() rather than malloc/free (This used to be commit e9576124cbe8322ed7bee9f4e72b5d1753ee0bac) --- source3/rpc_server/srv_spoolss.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index aaa87fe6ff..da7db8e557 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -50,6 +50,9 @@ static BOOL api_spoolss_open_printer_ex(prs_struct *data, prs_struct *rdata) q_u.user_switch, q_u.user_ctr, &r_u.handle); + /* we _really_ need to switch to talloc() */ + safe_free(q_u.printer_default.devmode_cont.devmode); + if (!spoolss_io_r_open_printer_ex("",&r_u,rdata,0)){ DEBUG(0,("spoolss_io_r_open_printer_ex: unable to marshall SPOOL_R_OPEN_PRINTER_EX.\n")); return False; -- cgit From 00e3fe132476fcaed0f4b9bbe74b0a6559c39df0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 25 Apr 2000 14:06:57 +0000 Subject: moved trans2.h and nterr.h into includes.h with all our other includes (This used to be commit d7cd7c88fdabb01d9e40ae8a657737907a21ac37) --- source3/rpc_server/srv_lookup.c | 1 - source3/rpc_server/srv_pipe.c | 1 - source3/rpc_server/srv_spoolss_nt.c | 1 - source3/rpc_server/srv_srvsvc.c | 1 - 4 files changed, 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index 4041cd2660..274c68f18d 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -43,7 +43,6 @@ */ #include "includes.h" -#include "nterr.h" extern int DEBUGLEVEL; diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index fe78d48fa6..3637f68adf 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -39,7 +39,6 @@ */ #include "includes.h" -#include "nterr.h" extern int DEBUGLEVEL; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d1ad0f6229..1121d5c2b1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -23,7 +23,6 @@ #include "includes.h" -#include "nterr.h" extern int DEBUGLEVEL; extern pstring global_myname; diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index c5307b264e..51ba7e8a8f 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -22,7 +22,6 @@ */ #include "includes.h" -#include "nterr.h" extern int DEBUGLEVEL; extern pstring global_myname; -- cgit From b39cee0bb9de856f8e4fa1f8a227ff885a5c56ff Mon Sep 17 00:00:00 2001 From: Shirish Kalele Date: Fri, 28 Apr 2000 18:36:47 +0000 Subject: Added info level 1005 to netsharegetinfo (is the share a DFS root) Added dfs_server announcement in set_default_server_announce_type() (This used to be commit 99d07e13520b04d99999938d259d56fa65c8a8ea) --- source3/rpc_server/srv_srvsvc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 51ba7e8a8f..bb2083e28a 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -90,6 +90,20 @@ static void init_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, int snum) init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); } +/*************************************************************************** + Fill in a share info level 1005 structure. + ***************************************************************************/ +static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum) +{ + sh1005->dfs_root_flag = 0; + +#ifdef MS_DFS + if(lp_host_msdfs() && *lp_dfsmap(snum) && lp_dfsmap_loaded(snum)) + sh1005->dfs_root_flag = 3; +#endif + +} + /******************************************************************* Fill in a share info structure. ********************************************************************/ @@ -235,6 +249,9 @@ static void init_srv_r_net_share_get_info(SRV_R_NET_SHARE_GET_INFO *r_n, case 2: init_srv_share_info_2(&r_n->share.info2, snum); break; + case 1005: + init_srv_share_info_1005(&r_n->share.info1005, snum); + break; default: DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level)); status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; -- cgit From 565cc66e6ae93aa44305419298cd5973e57529fc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 30 Apr 2000 14:27:39 +0000 Subject: fix handing of ascii_to_unistr (This used to be commit 385b1844b60beeb9db5f412a452816444e25cb83) --- source3/rpc_server/srv_spoolss_nt.c | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1121d5c2b1..1daa7e55da 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -561,8 +561,8 @@ static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *u static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode) { - unistr_to_ascii(nt_devmode->devicename, devmode.devicename.buffer, 31); - unistr_to_ascii(nt_devmode->formname, devmode.formname.buffer, 31); + unistr_to_ascii(nt_devmode->devicename, (char *)devmode.devicename.buffer, 31); + unistr_to_ascii(nt_devmode->formname, (char *)devmode.formname.buffer, 31); nt_devmode->specversion=devmode.specversion; nt_devmode->driverversion=devmode.driverversion; @@ -856,7 +856,7 @@ static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, p snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); data->notify_data.data.length=strlen(temp_name); - ascii_to_unistr(data->notify_data.data.string, temp_name, sizeof(data->notify_data.data.string)-1); + ascii_to_unistr((char *)data->notify_data.data.string, temp_name, sizeof(data->notify_data.data.string)-1); } /******************************************************************* @@ -870,7 +870,7 @@ static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, ascii_to_unistr(data->notify_data.data.string, lp_servicename(snum), sizeof(data->notify_data.data.string)-1); */ data->notify_data.data.length=strlen(printer->info_2->printername); - ascii_to_unistr(data->notify_data.data.string, + ascii_to_unistr((char *)data->notify_data.data.string, printer->info_2->printername, sizeof(data->notify_data.data.string)-1); } @@ -881,7 +881,7 @@ static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, static void spoolss_notify_share_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(lp_servicename(snum)); - ascii_to_unistr(data->notify_data.data.string, + ascii_to_unistr((char *)data->notify_data.data.string, lp_servicename(snum), sizeof(data->notify_data.data.string)-1); } @@ -894,7 +894,7 @@ static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, pri /* even if it's strange, that's consistant in all the code */ data->notify_data.data.length=strlen(lp_servicename(snum)); - ascii_to_unistr(data->notify_data.data.string, + ascii_to_unistr((char *)data->notify_data.data.string, lp_servicename(snum), sizeof(data->notify_data.data.string)-1); } @@ -907,7 +907,7 @@ static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, pri static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->drivername); - ascii_to_unistr(data->notify_data.data.string, + ascii_to_unistr((char *)data->notify_data.data.string, printer->info_2->drivername, sizeof(data->notify_data.data.string)-1); } @@ -918,7 +918,7 @@ static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, p static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(lp_comment(snum)); - ascii_to_unistr(data->notify_data.data.string, + ascii_to_unistr((char *)data->notify_data.data.string, lp_comment(snum), sizeof(data->notify_data.data.string)-1); } @@ -931,7 +931,7 @@ static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print static void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->location); - ascii_to_unistr(data->notify_data.data.string, + ascii_to_unistr((char *)data->notify_data.data.string, printer->info_2->location, sizeof(data->notify_data.data.string)-1); } @@ -952,7 +952,7 @@ static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->sepfile); - ascii_to_unistr(data->notify_data.data.string, + ascii_to_unistr((char *)data->notify_data.data.string, printer->info_2->sepfile, sizeof(data->notify_data.data.string)-1); } @@ -964,7 +964,7 @@ static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->printprocessor); - ascii_to_unistr(data->notify_data.data.string, + ascii_to_unistr((char *)data->notify_data.data.string, printer->info_2->printprocessor, sizeof(data->notify_data.data.string)-1); } @@ -976,7 +976,7 @@ static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *dat static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->parameters); - ascii_to_unistr(data->notify_data.data.string, + ascii_to_unistr((char *)data->notify_data.data.string, printer->info_2->parameters, sizeof(data->notify_data.data.string)-1); } @@ -988,7 +988,7 @@ static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(printer->info_2->datatype); - ascii_to_unistr(data->notify_data.data.string, + ascii_to_unistr((char *)data->notify_data.data.string, printer->info_2->datatype, sizeof(data->notify_data.data.string)-1); } @@ -1091,7 +1091,7 @@ static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, p static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(queue->user); - ascii_to_unistr(data->notify_data.data.string, queue->user, sizeof(data->notify_data.data.string)-1); + ascii_to_unistr((char *)data->notify_data.data.string, queue->user, sizeof(data->notify_data.data.string)-1); } /******************************************************************* @@ -1108,7 +1108,7 @@ static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.data.length=strlen(queue->file); - ascii_to_unistr(data->notify_data.data.string, queue->file, sizeof(data->notify_data.data.string)-1); + ascii_to_unistr((char *)data->notify_data.data.string, queue->file, sizeof(data->notify_data.data.string)-1); } /******************************************************************* @@ -1132,7 +1132,7 @@ static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *d break; } data->notify_data.data.length=strlen(p); - ascii_to_unistr(data->notify_data.data.string, p, sizeof(data->notify_data.data.string)-1); + ascii_to_unistr((char *)data->notify_data.data.string, p, sizeof(data->notify_data.data.string)-1); } /******************************************************************* @@ -2431,7 +2431,7 @@ static void init_unistr_array(uint16 **uni_array, char **char_array, char *where DEBUG(0,("init_unistr_array: Realloc error\n" )); return; } - ascii_to_unistr( *uni_array+j, line , strlen(line)); + ascii_to_unistr((char *)(*uni_array+j), line , 2*strlen(line)); j+=strlen(line)+1; i++; } @@ -3874,13 +3874,13 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, * take a pause *before* coding not *during* coding */ - *out_max_value_len=in_value_len/2; + *out_max_value_len=in_value_len; if((*out_value=(uint16 *)malloc(in_value_len*sizeof(uint8))) == NULL) { free_a_printer(printer, 2); safe_free(data); return ERROR_NOT_ENOUGH_MEMORY; } - ascii_to_unistr(*out_value, value, *out_max_value_len); + ascii_to_unistr((char *)*out_value, value, *out_max_value_len); *out_value_len=2*(1+strlen(value)); *out_type=type; -- cgit From 693ffb8466ada58ecc59fde754ba79fc6f51528d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 2 May 2000 02:23:41 +0000 Subject: Added sys_fork() and sys_getpid() functions to stop the overhead of doing a system call every time we want to just get our pid. Jeremy. (This used to be commit 148628b616b5c29ba6340d65fc3ddbcabba6e67a) --- source3/rpc_server/srv_lsa_hnd.c | 2 +- source3/rpc_server/srv_pipe_hnd.c | 4 ++-- source3/rpc_server/srv_spoolss_nt.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 937da42ec8..58a7dc6913 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -76,7 +76,7 @@ static void create_pol_hnd(POLICY_HND *hnd) SIVAL(hnd->data, 4 , pol_hnd_low ); /* second bit is incrementing */ SIVAL(hnd->data, 8 , pol_hnd_high); /* second bit is incrementing */ SIVAL(hnd->data, 12, time(NULL)); /* something random */ - SIVAL(hnd->data, 16, getpid()); /* something more random */ + SIVAL(hnd->data, 16, sys_getpid()); /* something more random */ } /**************************************************************************** diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 2d11c5eda5..7110342383 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -144,7 +144,7 @@ static void attempt_remote_rpc_connect(pipes_struct *p) */ become_root(False); /* to connect to pipe */ - p->m = msrpc_use_add(p->name, getpid(), &usr, False); + p->m = msrpc_use_add(p->name, sys_getpid(), &usr, False); unbecome_root(False); if (p->m == NULL) @@ -170,7 +170,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, log files and prevents client bugs where pipe numbers are reused over connection restarts */ if (next_pipe == 0) - next_pipe = (getpid() ^ time(NULL)) % MAX_OPEN_PIPES; + next_pipe = (sys_getpid() ^ time(NULL)) % MAX_OPEN_PIPES; i = bitmap_find(bmap, next_pipe); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1daa7e55da..2680c3a553 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -135,7 +135,7 @@ static void create_printer_hnd(POLICY_HND *hnd) SIVAL(hnd->data, 4 , prt_hnd_low ); /* second bit is incrementing */ SIVAL(hnd->data, 8 , prt_hnd_high); /* second bit is incrementing */ SIVAL(hnd->data, 12, time(NULL)); /* something random */ - SIVAL(hnd->data, 16, getpid()); /* something more random */ + SIVAL(hnd->data, 16, sys_getpid()); /* something more random */ } /**************************************************************************** -- cgit From f6dec4d551ba1054f9e936a973c2d9f90f84374f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 May 2000 07:10:26 +0000 Subject: fixed a memory leak (This used to be commit d4743ec0be419565c805fbc5ba2680c6ad5fe36d) --- source3/rpc_server/srv_spoolss_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2680c3a553..6a0323f850 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3710,6 +3710,8 @@ uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name, if (add_a_printer_driver(driver, level)!=0) return ERROR_ACCESS_DENIED; + safe_free(driver.info_3); + return NT_STATUS_NO_PROBLEMO; } -- cgit From 32d5416b6a777a7874fec8518ec44e750560d882 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 May 2000 13:55:42 +0000 Subject: split the username in the vuser structure into a separate userdom_struct. As the name implies this also contains a domain (unused at the moment). This will be important shortly, as operation in appliance mode needs the domain to be always carried with the username. (This used to be commit ee8546342d5be90e730372b985710d764564b124) --- source3/rpc_server/srv_netlog.c | 2 +- source3/rpc_server/srv_pipe_hnd.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index a198b6b98a..82573f7952 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -808,7 +808,7 @@ static BOOL api_net_sam_logon(prs_struct *data, prs_struct *rdata) &dummy_time, /* pass_must_change_time */ nt_username , /* user_name */ - vuser->real_name, /* full_name */ + vuser->user.real_name, /* full_name */ logon_script , /* logon_script */ profile_path , /* profile_path */ home_dir , /* home_dir */ diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 7110342383..35fb0423a5 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -120,8 +120,8 @@ static void attempt_remote_rpc_connect(pipes_struct *p) ZERO_STRUCT(usr); /* set up unix credentials from the smb side, to feed over the pipe */ - make_creds_unix(&usr.uxc, vuser->name, vuser->requested_name, - vuser->real_name, vuser->guest); + make_creds_unix(&usr.uxc, vuser->user.unix_name, vuser->user.smb_name, + vuser->user.real_name, vuser->guest); usr.ptr_uxc = 1; make_creds_unix_sec(&usr.uxs, vuser->uid, vuser->gid, vuser->n_groups, vuser->groups); -- cgit From 59fa2dbe2cb18762e14a86045c7ad403205a3841 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 May 2000 15:31:55 +0000 Subject: added support for deleting printers into the spoolss system (This used to be commit e72a5718537b84409fc20ff21951b1d1ab24d97f) --- source3/rpc_server/srv_spoolss.c | 31 +++++++++++++++++++++++++++++++ source3/rpc_server/srv_spoolss_nt.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index da7db8e557..db4cab662b 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -123,6 +123,36 @@ static BOOL api_spoolss_closeprinter(prs_struct *data, prs_struct *rdata) return True; } +/******************************************************************** + * api_spoolss_deleteprinter + * + * called from the spoolss dispatcher + ********************************************************************/ +static BOOL api_spoolss_deleteprinter(prs_struct *data, prs_struct *rdata) +{ + SPOOL_Q_DELETEPRINTER q_u; + SPOOL_R_DELETEPRINTER r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!spoolss_io_q_deleteprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_deleteprinter: unable to unmarshall SPOOL_Q_DELETEPRINTER.\n")); + return False; + } + + r_u.status = _spoolss_deleteprinter(&q_u.handle); + memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle)); + + if (!spoolss_io_r_deleteprinter("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_deleteprinter: unable to marshall SPOOL_R_DELETEPRINTER.\n")); + return False; + } + + return True; +} + + /******************************************************************** * api_spoolss_rffpcnex * ReplyFindFirstPrinterChangeNotifyEx @@ -1104,6 +1134,7 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex }, {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata }, {"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter }, + {"SPOOLSS_DELETEPRINTER", SPOOLSS_DELETEPRINTER, api_spoolss_deleteprinter }, {"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex }, {"SPOOLSS_RFNPCNEX", SPOOLSS_RFNPCNEX, api_spoolss_rfnpcnex }, {"SPOOLSS_ENUMPRINTERS", SPOOLSS_ENUMPRINTERS, api_spoolss_enumprinters }, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 6a0323f850..43f0c94987 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -200,6 +200,27 @@ static BOOL close_printer_handle(POLICY_HND *hnd) return True; } +/**************************************************************************** + delete a printer given a handle +****************************************************************************/ +static BOOL delete_printer_handle(POLICY_HND *hnd) +{ + Printer_entry *Printer = find_printer_index_by_hnd(hnd); + + if (!OPEN_HANDLE(Printer)) + { + DEBUG(3,("Error closing printer handle\n")); + return False; + } + + if (del_a_printer(Printer->dev.printername) != 0) { + DEBUG(3,("Error deleting printer %s\n", Printer->dev.printername)); + return False; + } + + return True; +} + /**************************************************************************** return the snum of a printer corresponding to an handle ****************************************************************************/ @@ -622,6 +643,17 @@ uint32 _spoolss_closeprinter(POLICY_HND *handle) return NT_STATUS_NO_PROBLEMO; } +/******************************************************************** + * api_spoolss_deleteprinter + ********************************************************************/ +uint32 _spoolss_deleteprinter(POLICY_HND *handle) +{ + if (!delete_printer_handle(handle)) + return ERROR_INVALID_HANDLE; + + return NT_STATUS_NO_PROBLEMO; +} + /******************************************************************** GetPrinterData on a printer server Handle. ********************************************************************/ -- cgit From f3a861e04e33901c89408a9c89ebaa81fc606f97 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 4 May 2000 07:59:34 +0000 Subject: - use full_name instead of real_name - got rid of guest map code in lpq parser (This used to be commit 8e53f781d3cf6a7007764916a0d8e8f1abea1f66) --- source3/rpc_server/srv_netlog.c | 2 +- source3/rpc_server/srv_pipe_hnd.c | 2 +- source3/rpc_server/srv_spoolss.c | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 82573f7952..0821b671e5 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -808,7 +808,7 @@ static BOOL api_net_sam_logon(prs_struct *data, prs_struct *rdata) &dummy_time, /* pass_must_change_time */ nt_username , /* user_name */ - vuser->user.real_name, /* full_name */ + vuser->user.full_name, /* full_name */ logon_script , /* logon_script */ profile_path , /* profile_path */ home_dir , /* home_dir */ diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 35fb0423a5..56b76d92be 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -121,7 +121,7 @@ static void attempt_remote_rpc_connect(pipes_struct *p) /* set up unix credentials from the smb side, to feed over the pipe */ make_creds_unix(&usr.uxc, vuser->user.unix_name, vuser->user.smb_name, - vuser->user.real_name, vuser->guest); + vuser->user.full_name, vuser->guest); usr.ptr_uxc = 1; make_creds_unix_sec(&usr.uxs, vuser->uid, vuser->gid, vuser->n_groups, vuser->groups); diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index db4cab662b..7284fb2389 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1175,3 +1175,5 @@ BOOL api_spoolss_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds, data); } + + -- cgit From 045469493c2870cb1d63c964b18afc5e2210dcd5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 4 May 2000 21:57:28 +0000 Subject: rpc_server/srv_lsa.c: Bring into sync with 2.0.x. rpc_server/srv_pipe_hnd.c: Bring into sync with 2.0.x. smbd/blocking.c: Improve blocking debug reporting. utils/torture.c: Added check for NT locking bug. Jeremy. (This used to be commit e8ff6d3fb5537c39611a5784bf7216ae812acd27) --- source3/rpc_server/srv_lsa.c | 28 +++++++++++++++++++--------- source3/rpc_server/srv_pipe_hnd.c | 12 ++++++------ 2 files changed, 25 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index f5dd09d05e..1c682044cf 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -90,6 +90,8 @@ static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) fstring sid_str; int domlen = strlen(dom_name); + *sid_str = '\0'; + d_q->uni_dom_max_len = domlen * 2; d_q->uni_dom_str_len = domlen * 2; @@ -99,8 +101,10 @@ static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) /* this string is supposed to be character short */ init_unistr2(&d_q->uni_domain_name, dom_name, domlen); - sid_to_string(sid_str, dom_sid); - init_dom_sid2(&d_q->dom_sid, dom_sid); + if(dom_sid) { + sid_to_string(sid_str, dom_sid); + init_dom_sid2(&d_q->dom_sid, dom_sid); + } } /*************************************************************************** @@ -128,7 +132,7 @@ lsa_reply_query_info ***************************************************************************/ static BOOL lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, - char *dom_name, DOM_SID *dom_sid) + char *dom_name, DOM_SID *dom_sid, uint32 status_code) { LSA_R_QUERY_INFO r_q; @@ -136,12 +140,14 @@ static BOOL lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, /* set up the LSA QUERY INFO response */ - r_q.undoc_buffer = 0x22000000; /* bizarre */ - r_q.info_class = q_q->info_class; + if(status_code == 0) { + r_q.undoc_buffer = 0x22000000; /* bizarre */ + r_q.info_class = q_q->info_class; - init_dom_query(&r_q.dom.id5, dom_name, dom_sid); + init_dom_query(&r_q.dom.id5, dom_name, dom_sid); + } - r_q.status = 0x0; + r_q.status = status_code; /* store the response in the SMB stream */ if(!lsa_io_r_query("", &r_q, rdata, 0)) { @@ -484,7 +490,8 @@ static BOOL api_lsa_enum_trust_dom(prs_struct *data, prs_struct *rdata) ZERO_STRUCT(q_e); /* grab the enum trust domain context etc. */ - lsa_io_q_enum_trust_dom("", &q_e, data, 0); + if(!lsa_io_q_enum_trust_dom("", &q_e, data, 0)) + return False; /* construct reply. return status is always 0x0 */ lsa_reply_enum_trust_dom(&q_e, rdata, 0, NULL, NULL); @@ -500,6 +507,8 @@ static BOOL api_lsa_query_info(prs_struct *data, prs_struct *rdata) LSA_Q_QUERY_INFO q_i; fstring name; DOM_SID *sid = NULL; + uint32 status_code = 0; + memset(name, 0, sizeof(name)); ZERO_STRUCT(q_i); @@ -525,11 +534,12 @@ static BOOL api_lsa_query_info(prs_struct *data, prs_struct *rdata) break; default: DEBUG(0,("api_lsa_query_info: unknown info level in Lsa Query: %d\n", q_i.info_class)); + status_code = (NT_STATUS_INVALID_INFO_CLASS | 0xC0000000); break; } /* construct reply. return status is always 0x0 */ - if(!lsa_reply_query_info(&q_i, rdata, name, sid)) + if(!lsa_reply_query_info(&q_i, rdata, name, sid, status_code)) return False; return True; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 56b76d92be..17ed35addd 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -77,7 +77,7 @@ void init_rpc_pipe_hnd(void) Initialise an outgoing packet. ****************************************************************************/ -static BOOL pipe_init_outgoing_data(output_data *o_data, uint32 len) +static BOOL pipe_init_outgoing_data(output_data *o_data) { /* Reset the offset counters. */ o_data->data_sent_length = 0; @@ -93,7 +93,7 @@ static BOOL pipe_init_outgoing_data(output_data *o_data, uint32 len) * Initialize the outgoing RPC data buffer. * we will use this as the raw data area for replying to rpc requests. */ - if(!prs_init(&o_data->rdata, len, 4, MARSHALL)) { + if(!prs_init(&o_data->rdata, MAX_PDU_FRAG_LEN, 4, MARSHALL)) { DEBUG(0,("pipe_init_outgoing_data: malloc fail.\n")); return False; } @@ -486,7 +486,7 @@ authentication failed. Denying the request.\n", p->name)); * Process the complete data stream here. */ - if(pipe_init_outgoing_data(&p->out_data, MAX_PDU_FRAG_LEN)) + if(pipe_init_outgoing_data(&p->out_data)) ret = api_pipe_request(p); /* @@ -537,14 +537,14 @@ static ssize_t process_complete_pdu(pipes_struct *p) /* * We assume that a pipe bind is only in one pdu. */ - if(pipe_init_outgoing_data(&p->out_data, MAX_PDU_FRAG_LEN)) + if(pipe_init_outgoing_data(&p->out_data)) reply = api_pipe_bind_req(p, &rpc_in); break; case RPC_BINDRESP: /* * We assume that a pipe bind_resp is only in one pdu. */ - if(pipe_init_outgoing_data(&p->out_data, MAX_PDU_FRAG_LEN)) + if(pipe_init_outgoing_data(&p->out_data)) reply = api_pipe_bind_auth_resp(p, &rpc_in); break; case RPC_REQUEST: @@ -716,7 +716,7 @@ static BOOL read_from_remote(pipes_struct *p) * Create the response data buffer. */ - if(!pipe_init_outgoing_data(&p->out_data, 65536)) { + if(!pipe_init_outgoing_data(&p->out_data)) { DEBUG(0,("read_from_remote: failed to create outgoing buffer.\n")); return False; } -- cgit From c23e01d049cc7aee34e8ac83efeb74c09aa257a2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 9 May 2000 13:28:19 +0000 Subject: the beginnings of a new scheme I've working on to allow an easier head/tng merge. It goes something like this: - headers from tng get copied over one at a time - the old headers get renamed to *_old.h - server side code that used the old headers gets a #define OLD_NTDOMAIN 1 #undef OLD_NTDOMAIN at the start and end of the code - mkproto.awk recognises these special defines and does magic stuff so that each .c file sees the right headers - we start moving the rpc client libraries from tng to head. if this goes OK then, in theory, we should be able to move the client side rpc code from tng to head without disturbing the existing head server side code. Then when that works we can consider merging the server side. it remains to be seen if this scheme will work. So far I've moved rpc_samr.h and don't seem to have broken anything. Note this this is still a very delicate operation, as at every step of the way I want to keep head fully functional. Please don't take part unless you discuss it with me first. (This used to be commit f76c037255a6a79d11bec65e863e009a41a4f0fd) --- source3/rpc_server/srv_pipe.c | 3 +++ source3/rpc_server/srv_samr.c | 5 +++++ 2 files changed, 8 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 3637f68adf..581d6c04bd 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1,3 +1,4 @@ +#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -1112,3 +1113,5 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds return True; } + +#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 08bba0eef4..650fa704b8 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1,3 +1,5 @@ +#define OLD_NTDOMAIN 1 + /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -1948,3 +1950,6 @@ BOOL api_samr_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_samr_rpc", api_samr_cmds, data); } + +#undef OLD_NTDOMAIN + -- cgit From 49a0e6d5989656c1b3c9c063a20308ca4ee5d73b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 10 May 2000 10:41:59 +0000 Subject: more merging voodoo this adds "#define OLD_NTDOMAIN 1" in lots of places. Don't panic - this isn't permanent, it should go after another few merge steps have been done (This used to be commit 92109d7b3c06f240452d39f669ecb8c9c86ab610) --- source3/rpc_server/srv_lsa.c | 3 +++ source3/rpc_server/srv_lsa_hnd.c | 4 ++++ source3/rpc_server/srv_netlog.c | 2 ++ source3/rpc_server/srv_pipe_hnd.c | 3 +++ source3/rpc_server/srv_reg.c | 3 +++ source3/rpc_server/srv_spoolss.c | 3 ++- source3/rpc_server/srv_srvsvc.c | 3 +++ source3/rpc_server/srv_util.c | 4 ++++ source3/rpc_server/srv_wkssvc.c | 3 +++ 9 files changed, 27 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 1c682044cf..e7d08ff788 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -1,3 +1,4 @@ +#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -654,3 +655,5 @@ BOOL api_ntlsa_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds, data); } + +#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 58a7dc6913..5670178732 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -1,3 +1,5 @@ +#define OLD_NTDOMAIN 1 + /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -304,3 +306,5 @@ BOOL close_lsa_policy_hnd(POLICY_HND *hnd) return True; } + +#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 0821b671e5..7ca03a5e8b 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -1,3 +1,4 @@ +#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -936,3 +937,4 @@ BOOL api_netlog_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_netlog_rpc", api_net_cmds, data); } +#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 17ed35addd..f19aed1886 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1,3 +1,4 @@ +#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -979,3 +980,5 @@ pipes_struct *get_rpc_pipe(int pnum) return NULL; } + +#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index b1d3784ec1..6a8d803c2e 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -1,3 +1,4 @@ +#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -245,3 +246,5 @@ BOOL api_reg_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds, data); } + +#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 7284fb2389..0f85ba8c80 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1,3 +1,4 @@ +#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -1176,4 +1177,4 @@ BOOL api_spoolss_rpc(pipes_struct *p, prs_struct *data) return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds, data); } - +#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index bb2083e28a..853aa0e2f6 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -1,3 +1,4 @@ +#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -1128,3 +1129,5 @@ BOOL api_srvsvc_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_srvsvc_rpc", api_srv_cmds, data); } + +#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index f5cf615fd7..8264741db0 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -1,3 +1,5 @@ +#define OLD_NTDOMAIN 1 + /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -342,3 +344,5 @@ uint32 lookup_user_rid(char *user_name, uint32 *rid) return 0xC0000000 | NT_STATUS_NONE_MAPPED; } + +#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index ee60d73011..2d2045dc1c 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -1,3 +1,4 @@ +#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -106,3 +107,5 @@ BOOL api_wkssvc_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_wkssvc_rpc", api_wks_cmds, data); } + +#undef OLD_NTDOMAIN -- cgit From 612738a9e14b6fb6a2687993d6416bbe6c3ea94d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 10 May 2000 22:47:09 +0000 Subject: lib/util_unistr.c: libsmb/clilist.c: rpc_server/srv_spoolss_nt.c: smbd/trans2.c: Changed unistr_to_ascii to unistr_to_dos - do codepage conversion. msdfs/msdfs.c: Removed stub unistr_to_dos. libsmb/pwd_cache.c: Removed obfuscation functions as they don't do anything and don't add any security. Jeremy. (This used to be commit 1ed146467e764e6a81d8f78cd58fb5765ebf5d21) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 43f0c94987..34e459d72b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -582,8 +582,8 @@ static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *u static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode) { - unistr_to_ascii(nt_devmode->devicename, (char *)devmode.devicename.buffer, 31); - unistr_to_ascii(nt_devmode->formname, (char *)devmode.formname.buffer, 31); + unistr_to_dos(nt_devmode->devicename, (char *)devmode.devicename.buffer, 31); + unistr_to_dos(nt_devmode->formname, (char *)devmode.formname.buffer, 31); nt_devmode->specversion=devmode.specversion; nt_devmode->driverversion=devmode.driverversion; -- cgit From 053322d0ca6b68be638c2d5f4caa9909a19c1646 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 12 May 2000 06:38:41 +0000 Subject: fixed two uninitialised variables (This used to be commit eefb36f130f79f2f2c6cfb58c1646aa6ce4303be) --- source3/rpc_server/srv_samr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 650fa704b8..d09ae2ad01 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -119,7 +119,6 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, static char *unmap_unixname(char *unix_user_name, int name_idx) { char *mapfile = lp_username_map(); - char *s; char **lines; static pstring tok; int i; @@ -136,7 +135,7 @@ static char *unmap_unixname(char *unix_user_name, int name_idx) DEBUG(5,("unmap_unixname: scanning username map %s, index: %d\n", mapfile, name_idx)); for (i=0; lines[i]; i++) { - char *unixname = s; + char *unixname = lines[i]; char *dosname = strchr(unixname,'='); if (!dosname) -- cgit From 0806cf75ff96dee6715610bd61e21cde08fa1c61 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 12 May 2000 14:28:46 +0000 Subject: added spool_io_printer_driver_info_level_6() thsi function and the associated header structure were autogenerated using a little awk based code geerator I wroe ths evening. I'll commit that next ... (This used to be commit 974813f0d4afb6c14ed27c48ab24b19932557f9f) --- source3/rpc_server/srv_spoolss_nt.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 34e459d72b..95d7b7fdff 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -571,7 +571,11 @@ static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *u switch (level) { case 3: printer->info_3=NULL; - uni_2_asc_printer_driver_3(uni->info_3, &(printer->info_3)); + uni_2_asc_printer_driver_3(uni->info_3, &(printer->info_3)); + break; + case 6: + printer->info_6=NULL; + uni_2_asc_printer_driver_6(uni->info_6, &(printer->info_6)); break; default: break; @@ -2378,6 +2382,9 @@ static void construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, NT_PRINTER_INFO_LEVEL printer; NT_PRINTER_DRIVER_INFO_LEVEL driver; + ZERO_STRUCT(driver); + ZERO_STRUCT(printer); + get_a_printer(&printer, 2, lp_servicename(snum) ); get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); @@ -2431,7 +2438,10 @@ static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstri { NT_PRINTER_INFO_LEVEL printer; NT_PRINTER_DRIVER_INFO_LEVEL driver; - + + ZERO_STRUCT(printer); + ZERO_STRUCT(driver); + get_a_printer(&printer, 2, lp_servicename(snum) ); get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); @@ -2525,7 +2535,10 @@ static void construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, { NT_PRINTER_INFO_LEVEL printer; NT_PRINTER_DRIVER_INFO_LEVEL driver; - + + ZERO_STRUCT(printer); + ZERO_STRUCT(driver); + get_a_printer(&printer, 2, lp_servicename(snum) ); get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); @@ -3245,6 +3258,8 @@ static uint32 enumprinterdrivers_level1(fstring *list, fstring servername, fstri NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_1 *driver_info_1=NULL; + ZERO_STRUCT(driver); + if((driver_info_1=(DRIVER_INFO_1 *)malloc(*returned * sizeof(DRIVER_INFO_1))) == NULL) return ERROR_NOT_ENOUGH_MEMORY; @@ -3292,6 +3307,8 @@ static uint32 enumprinterdrivers_level2(fstring *list, fstring servername, fstri NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_2 *driver_info_2=NULL; + ZERO_STRUCT(driver); + if (*returned > 0 && !(driver_info_2=(DRIVER_INFO_2 *)malloc(*returned * sizeof(DRIVER_INFO_2)))) return ERROR_NOT_ENOUGH_MEMORY; @@ -3340,6 +3357,8 @@ static uint32 enumprinterdrivers_level3(fstring *list, fstring servername, fstri NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_3 *driver_info_3=NULL; + ZERO_STRUCT(driver); + if((driver_info_3=(DRIVER_INFO_3 *)malloc((*returned)*sizeof(DRIVER_INFO_3))) == NULL) return ERROR_NOT_ENOUGH_MEMORY; @@ -3736,6 +3755,8 @@ uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name, const SPOOL_PRINTER_DRIVER_INFO_LEVEL *info) { NT_PRINTER_DRIVER_INFO_LEVEL driver; + + ZERO_STRUCT(driver); convert_printer_driver_info(info, &driver, level); @@ -3743,6 +3764,7 @@ uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name, return ERROR_ACCESS_DENIED; safe_free(driver.info_3); + safe_free(driver.info_6); return NT_STATUS_NO_PROBLEMO; } @@ -3775,7 +3797,7 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen fill_driverdir_1(info, chaine); - *needed += spoolss_size_driverdir_info_1(info); + *needed += spoolss_size_driverdir_info_1(info); if (!alloc_buffer_size(buffer, *needed)) { safe_free(info); -- cgit From 378ec58bebdbc2ae7c7306fc25f358a58478ecf8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 May 2000 07:18:12 +0000 Subject: add prs_dump() at the top level rpc switch this gets us examples of all rpc messages sent to us (This used to be commit ce3dd8db6d3cf6bfdbd695f6e32f60488c9073ae) --- source3/rpc_server/srv_pipe.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 581d6c04bd..9c1ad2ef5a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1084,6 +1084,8 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds /* interpret the command */ DEBUG(4,("api_rpcTNP: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); + prs_dump(rpc_name, p->hdr_req.opnum, rpc_in); + for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) { if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) { DEBUG(3,("api_rpcTNP: rpc command: %s\n", api_rpc_cmds[fn_num].name)); -- cgit From e2e33eb3207e1a6f85ca36cafc564aa9427fd7af Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 May 2000 09:59:58 +0000 Subject: call prs_dump() on every input and output packet so we have plenty of data to work with (This used to be commit 839ab0e33255be37d72c113c2e09baaa34d50ce4) --- source3/rpc_server/srv_pipe.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 9c1ad2ef5a..853c1b8ed6 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1080,11 +1080,14 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds prs_struct *rpc_in) { int fn_num; - + fstring name; + uint32 offset1, offset2; + /* interpret the command */ DEBUG(4,("api_rpcTNP: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); - prs_dump(rpc_name, p->hdr_req.opnum, rpc_in); + slprintf(name, sizeof(name), "in_%s", rpc_name); + prs_dump(name, p->hdr_req.opnum, rpc_in); for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) { if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) { @@ -1104,6 +1107,8 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds return True; } + offset1 = p->out_data.rdata.data_offset; + /* do the actual command */ if(!api_rpc_cmds[fn_num].fn(rpc_in, &p->out_data.rdata)) { DEBUG(0,("api_rpcTNP: %s: failed.\n", rpc_name)); @@ -1111,6 +1116,12 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds return False; } + slprintf(name, sizeof(name), "out_%s", rpc_name); + offset2 = p->out_data.rdata.data_offset; + p->out_data.rdata.data_offset = offset1; + prs_dump(name, p->hdr_req.opnum, &p->out_data.rdata); + p->out_data.rdata.data_offset = offset2; + DEBUG(5,("api_rpcTNP: called %s successfully\n", rpc_name)); return True; -- cgit From b27886addbdb1ff7c8e678023c7c1ef6d3bba9a9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 15 May 2000 17:13:50 +0000 Subject: passdb/secrets.c: Fix typo in comment. rpc_server/srv_pipe.c: Use accessor functions rather than diddling with structure internals directly. smbd/process.c: smbd/reply.c: Remove READ_PREDICTION #ifdefs. Jeremy. (This used to be commit eba825ff030a175bd271caa6f543379dfdbbd646) --- source3/rpc_server/srv_pipe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 853c1b8ed6..ebd4f55fce 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1107,7 +1107,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds return True; } - offset1 = p->out_data.rdata.data_offset; + offset1 = prs_offset(&p->out_data.rdata); /* do the actual command */ if(!api_rpc_cmds[fn_num].fn(rpc_in, &p->out_data.rdata)) { @@ -1117,10 +1117,10 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds } slprintf(name, sizeof(name), "out_%s", rpc_name); - offset2 = p->out_data.rdata.data_offset; - p->out_data.rdata.data_offset = offset1; + offset2 = prs_offset(&p->out_data.rdata); + prs_set_offset(&p->out_data.rdata, offset1); prs_dump(name, p->hdr_req.opnum, &p->out_data.rdata); - p->out_data.rdata.data_offset = offset2; + prs_set_offset(&p->out_data.rdata, offset2); DEBUG(5,("api_rpcTNP: called %s successfully\n", rpc_name)); -- cgit From 4fb2e2c72f25a1204bf764504c370d746d12a162 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 15 May 2000 20:08:26 +0000 Subject: Added fix for Win2k ACL query code from Shirish. I need this back ported to 2.2.0. Jeremy. (This used to be commit 74851a481efedd15f59d5da15db7078dc4ce5d20) --- source3/rpc_server/srv_pipe.c | 57 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index ebd4f55fce..9ba62ea656 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -472,9 +472,7 @@ static struct api_cmd api_fd_commands[] = { "srvsvc", "ntsvcs", api_srvsvc_rpc }, { "wkssvc", "ntsvcs", api_wkssvc_rpc }, { "NETLOGON", "lsass", api_netlog_rpc }, -#if 1 /* DISABLED_IN_2_0 JRATEST */ { "winreg", "winreg", api_reg_rpc }, -#endif { "spoolss", "spoolss", api_spoolss_rpc }, { NULL, NULL, NULL } }; @@ -664,6 +662,43 @@ BOOL setup_fault_pdu(pipes_struct *p) return True; } +/******************************************************************* + Ensure a bind request has the correct abstract & transfer interface. + Used to reject unknown binds from Win2k. +*******************************************************************/ + +BOOL check_bind_req(char* pipe_name, RPC_IFACE* abstract, + RPC_IFACE* transfer) +{ + extern struct pipe_id_info pipe_names[]; + int i=0; + fstring pname; + fstrcpy(pname,"\\PIPE\\"); + fstrcat(pname,pipe_name); + + for(i=0;pipe_names[i].client_pipe; i++) { + if(strequal(pipe_names[i].client_pipe, pname)) + break; + } + + if(pipe_names[i].client_pipe == NULL) + return False; + + /* check the abstract interface */ + if((abstract->version != pipe_names[i].abstr_syntax.version) || + (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, + sizeof(RPC_UUID)) != 0)) + return False; + + /* check the transfer interface */ + if((transfer->version != pipe_names[i].trans_syntax.version) || + (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, + sizeof(RPC_UUID)) != 0)) + return False; + + return True; +} + /******************************************************************* Respond to a pipe bind request. *******************************************************************/ @@ -823,13 +858,29 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) * Create the bind response struct. */ - init_rpc_hdr_ba(&hdr_ba, + /* If the requested abstract synt uuid doesn't match our client pipe, + reject the bind_ack & set the transfer interface synt to all 0's, + ver 0 (observed when NT5 attempts to bind to abstract interfaces + unknown to NT4) + Needed when adding entries to a DACL from NT5 - SK */ + + if(check_bind_req(p->name, &hdr_rb.abstract, &hdr_rb.transfer)) { + init_rpc_hdr_ba(&hdr_ba, MAX_PDU_FRAG_LEN, MAX_PDU_FRAG_LEN, assoc_gid, ack_pipe_name, 0x1, 0x0, 0x0, &hdr_rb.transfer); + } else { + RPC_IFACE null_interface; + ZERO_STRUCT(null_interface); + /* Rejection reason: abstract syntax not supported */ + init_rpc_hdr_ba(&hdr_ba, MAX_PDU_FRAG_LEN, + MAX_PDU_FRAG_LEN, assoc_gid, + ack_pipe_name, 0x1, 0x2, 0x1, + &null_interface); + } /* * and marshall it. -- cgit From ad9a3a16e000e25693508e0b2eac280f7593d095 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 15 May 2000 20:53:08 +0000 Subject: Added Shirish's reg changes to HEAD. Sync up with 2.2.0 backport. Also added prs_xx error return checks to new code in rpc_parse/parse_reg.c Jeremy. (This used to be commit a148cb996297ed34342660f82ef0e66773d40500) --- source3/rpc_server/srv_reg.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 6a8d803c2e..cba24d7dfb 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -23,6 +23,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + #include "includes.h" extern int DEBUGLEVEL; @@ -59,7 +60,7 @@ static void reg_reply_close(REG_Q_CLOSE *q_r, /******************************************************************* api_reg_close ********************************************************************/ -static BOOL api_reg_close(prs_struct *data, prs_struct *rdata) +static BOOL api_reg_close(prs_struct *data, prs_struct *rdata ) { REG_Q_CLOSE q_r; @@ -99,7 +100,7 @@ static void reg_reply_open(REG_Q_OPEN_HKLM *q_r, /******************************************************************* api_reg_open ********************************************************************/ -static BOOL api_reg_open(prs_struct *data, prs_struct *rdata) +static BOOL api_reg_open(prs_struct *data, prs_struct *rdata ) { REG_Q_OPEN_HKLM q_u; @@ -164,7 +165,7 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, /******************************************************************* api_reg_open_entry ********************************************************************/ -static BOOL api_reg_open_entry(prs_struct *data, prs_struct *rdata) +static BOOL api_reg_open_entry(prs_struct *data, prs_struct *rdata ) { REG_Q_OPEN_ENTRY q_u; @@ -185,6 +186,11 @@ static void reg_reply_info(REG_Q_INFO *q_u, prs_struct *rdata) { uint32 status = 0; + fstring key = "ServerNT"; /* always a non-PDC */ + uint32 type=0x1; /* key type: REG_SZ */ + + UNISTR2 uni_key; + BUFFER2 buf; REG_R_INFO r_u; @@ -195,14 +201,13 @@ static void reg_reply_info(REG_Q_INFO *q_u, status = 0xC000000 | NT_STATUS_INVALID_HANDLE; } - if (status == 0) - { - } - /* This makes the server look like a member server to clients */ /* which tells clients that we have our own local user and */ /* group databases and helps with ACL support. */ - init_reg_r_info(&r_u, 1, "ServerNT", 0x12, 0x12, status); + init_unistr2(&uni_key, key, strlen(key)+1); + init_buffer2(&buf, (uint8*) uni_key.buffer, uni_key.uni_str_len*2); + + init_reg_r_info(q_u->ptr_buf, &r_u, &buf, type, status); /* store the response in the SMB stream */ reg_io_r_info("", &r_u, rdata, 0); @@ -213,7 +218,7 @@ static void reg_reply_info(REG_Q_INFO *q_u, /******************************************************************* api_reg_info ********************************************************************/ -static BOOL api_reg_info(prs_struct *data, prs_struct *rdata) +static BOOL api_reg_info(prs_struct *data, prs_struct *rdata ) { REG_Q_INFO q_u; @@ -246,5 +251,4 @@ BOOL api_reg_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds, data); } - #undef OLD_NTDOMAIN -- cgit From 210f11d0e346db3c38d4d4f19cf77773537c9560 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 15 May 2000 21:38:03 +0000 Subject: Check error returns. Jeremy. (This used to be commit 919d49b58ad8213c0e89948f560d816b20312bb2) --- source3/rpc_server/srv_wkssvc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 2d2045dc1c..a09250a80b 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -56,7 +56,7 @@ static void create_wks_info_100(WKS_INFO_100 *inf) only supports info level 100 at the moment. ********************************************************************/ -static void wks_reply_query_info(WKS_Q_QUERY_INFO *q_u, +static BOOL wks_reply_query_info(WKS_Q_QUERY_INFO *q_u, prs_struct *rdata, int status) { @@ -69,9 +69,12 @@ static void wks_reply_query_info(WKS_Q_QUERY_INFO *q_u, init_wks_r_query_info(&r_u, q_u->switch_value, &wks100, status); /* store the response in the SMB stream */ - wks_io_r_query_info("", &r_u, rdata, 0); + if(!wks_io_r_query_info("", &r_u, rdata, 0)) + return False; DEBUG(5,("wks_query_info: %d\n", __LINE__)); + + return True; } /******************************************************************* @@ -82,10 +85,12 @@ static BOOL api_wks_query_info(prs_struct *data, prs_struct *rdata) WKS_Q_QUERY_INFO q_u; /* grab the net share enum */ - wks_io_q_query_info("", &q_u, data, 0); + if(!wks_io_q_query_info("", &q_u, data, 0)) + return False; /* construct reply. always indicate success */ - wks_reply_query_info(&q_u, rdata, 0x0); + if(!wks_reply_query_info(&q_u, rdata, 0x0)) + return False; return True; } -- cgit From 651946153e41354769839fa6cbcfd36fd320efbe Mon Sep 17 00:00:00 2001 From: Shirish Kalele Date: Tue, 16 May 2000 01:13:16 +0000 Subject: The new msdfs implementation that uses symlinks to point to other servers. Very intuitive. Removed the dfs map parsing code and tdb maintenance code (files msdfs/parse_dfs_map.c & msdfs/msdfs_tdb.c), dfs map loading and unloading calls (param/loadparm.c smbd/server.c). Added code to display msdfs format symlinks as directories in a transact2_findfirst/findnext. (smbd/trans2.c) Modified msdfs/msdfs.c to use the msdfs symlinks to create dfs referrals. Changed msdfs/README to reflect new operability. (This used to be commit 6803d2574fab9e5931786d5c9aa5dc5867bb5f05) --- source3/rpc_server/srv_srvsvc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 853aa0e2f6..44c4f5569d 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -99,7 +99,7 @@ static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum) sh1005->dfs_root_flag = 0; #ifdef MS_DFS - if(lp_host_msdfs() && *lp_dfsmap(snum) && lp_dfsmap_loaded(snum)) + if(lp_host_msdfs() && lp_msdfs_root(snum)) sh1005->dfs_root_flag = 3; #endif -- cgit From 91b736d2586d1dcfeb3a5ea915608411e5de440f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 16 May 2000 19:45:26 +0000 Subject: Synced up srv_samr with HP changes. Added error checking to original code - what a concept :-). All this code will be replaced with TNG stuff anyway, so not a big deal.... Jeremy. (This used to be commit b090cff4b5fcdef01fc553e6359627bb2285d68e) --- source3/rpc_server/srv_samr.c | 534 ++++++++++++++++++++++++++++-------------- 1 file changed, 361 insertions(+), 173 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index d09ae2ad01..9ad1d34561 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1,5 +1,4 @@ #define OLD_NTDOMAIN 1 - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -332,7 +331,7 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, /******************************************************************* samr_reply_unknown_1 ********************************************************************/ -static void samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, +static BOOL samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, prs_struct *rdata) { SAMR_R_CLOSE_HND r_u; @@ -353,10 +352,12 @@ static void samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, DEBUG(5,("samr_reply_close_hnd: %d\n", __LINE__)); /* store the response in the SMB stream */ - samr_io_r_close_hnd("", &r_u, rdata, 0); + if(!samr_io_r_close_hnd("", &r_u, rdata, 0)) + return False; DEBUG(5,("samr_reply_close_hnd: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -367,10 +368,12 @@ static BOOL api_samr_close_hnd(prs_struct *data, prs_struct *rdata) SAMR_Q_CLOSE_HND q_u; /* grab the samr unknown 1 */ - samr_io_q_close_hnd("", &q_u, data, 0); + if(!samr_io_q_close_hnd("", &q_u, data, 0)) + return False; /* construct reply. always indicate success */ - samr_reply_close_hnd(&q_u, rdata); + if(!samr_reply_close_hnd(&q_u, rdata)) + return False; return True; } @@ -379,7 +382,7 @@ static BOOL api_samr_close_hnd(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_open_domain ********************************************************************/ -static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, +static BOOL samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, prs_struct *rdata) { SAMR_R_OPEN_DOMAIN r_u; @@ -414,10 +417,12 @@ static void samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, DEBUG(5,("samr_open_domain: %d\n", __LINE__)); /* store the response in the SMB stream */ - samr_io_r_open_domain("", &r_u, rdata, 0); + if(!samr_io_r_open_domain("", &r_u, rdata, 0)) + return False; DEBUG(5,("samr_open_domain: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -428,10 +433,12 @@ static BOOL api_samr_open_domain(prs_struct *data, prs_struct *rdata) SAMR_Q_OPEN_DOMAIN q_u; /* grab the samr open */ - samr_io_q_open_domain("", &q_u, data, 0); + if(!samr_io_q_open_domain("", &q_u, data, 0)) + return False; /* construct reply. always indicate success */ - samr_reply_open_domain(&q_u, rdata); + if(!samr_reply_open_domain(&q_u, rdata)) + return False; return True; } @@ -440,7 +447,7 @@ static BOOL api_samr_open_domain(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_unknown_2c ********************************************************************/ -static void samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, +static BOOL samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, prs_struct *rdata) { SAMR_R_UNKNOWN_2C r_u; @@ -463,10 +470,12 @@ static void samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, DEBUG(5,("samr_unknown_2c: %d\n", __LINE__)); /* store the response in the SMB stream */ - samr_io_r_unknown_2c("", &r_u, rdata, 0); + if(!samr_io_r_unknown_2c("", &r_u, rdata, 0)) + return False; DEBUG(5,("samr_unknown_2c: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -477,10 +486,12 @@ static BOOL api_samr_unknown_2c(prs_struct *data, prs_struct *rdata) SAMR_Q_UNKNOWN_2C q_u; /* grab the samr open */ - samr_io_q_unknown_2c("", &q_u, data, 0); + if(!samr_io_q_unknown_2c("", &q_u, data, 0)) + return False; /* construct reply. always indicate success */ - samr_reply_unknown_2c(&q_u, rdata); + if(!samr_reply_unknown_2c(&q_u, rdata)) + return False; return True; } @@ -489,7 +500,7 @@ static BOOL api_samr_unknown_2c(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_unknown_3 ********************************************************************/ -static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, +static BOOL samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, prs_struct *rdata) { SAMR_R_UNKNOWN_3 r_u; @@ -541,10 +552,12 @@ static void samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, DEBUG(5,("samr_unknown_3: %d\n", __LINE__)); /* store the response in the SMB stream */ - samr_io_r_unknown_3("", &r_u, rdata, 0); + if(!samr_io_r_unknown_3("", &r_u, rdata, 0)) + return False; DEBUG(5,("samr_unknown_3: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -555,10 +568,12 @@ static BOOL api_samr_unknown_3(prs_struct *data, prs_struct *rdata) SAMR_Q_UNKNOWN_3 q_u; /* grab the samr open */ - samr_io_q_unknown_3("", &q_u, data, 0); + if(!samr_io_q_unknown_3("", &q_u, data, 0)) + return False; /* construct reply. always indicate success */ - samr_reply_unknown_3(&q_u, rdata); + if(!samr_reply_unknown_3(&q_u, rdata)) + return False; return True; } @@ -567,7 +582,7 @@ static BOOL api_samr_unknown_3(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_enum_dom_users ********************************************************************/ -static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, +static BOOL samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, prs_struct *rdata) { SAMR_R_ENUM_DOM_USERS r_e; @@ -595,10 +610,12 @@ static void samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, pass, r_e.status); /* store the response in the SMB stream */ - samr_io_r_enum_dom_users("", &r_e, rdata, 0); + if(!samr_io_r_enum_dom_users("", &r_e, rdata, 0)) + return False; DEBUG(5,("samr_enum_dom_users: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -609,19 +626,20 @@ static BOOL api_samr_enum_dom_users(prs_struct *data, prs_struct *rdata) SAMR_Q_ENUM_DOM_USERS q_e; /* grab the samr open */ - samr_io_q_enum_dom_users("", &q_e, data, 0); + if(!samr_io_q_enum_dom_users("", &q_e, data, 0)) + return False; /* construct reply. */ - samr_reply_enum_dom_users(&q_e, rdata); + if(!samr_reply_enum_dom_users(&q_e, rdata)) + return False; return True; } - /******************************************************************* samr_reply_enum_dom_groups ********************************************************************/ -static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, +static BOOL samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, prs_struct *rdata) { SAMR_R_ENUM_DOM_GROUPS r_e; @@ -652,10 +670,12 @@ static void samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, } /* store the response in the SMB stream */ - samr_io_r_enum_dom_groups("", &r_e, rdata, 0); + if(!samr_io_r_enum_dom_groups("", &r_e, rdata, 0)) + return False; DEBUG(5,("samr_enum_dom_groups: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -666,10 +686,12 @@ static BOOL api_samr_enum_dom_groups(prs_struct *data, prs_struct *rdata) SAMR_Q_ENUM_DOM_GROUPS q_e; /* grab the samr open */ - samr_io_q_enum_dom_groups("", &q_e, data, 0); + if(!samr_io_q_enum_dom_groups("", &q_e, data, 0)) + return False; /* construct reply. */ - samr_reply_enum_dom_groups(&q_e, rdata); + if(!samr_reply_enum_dom_groups(&q_e, rdata)) + return False; return True; } @@ -677,7 +699,7 @@ static BOOL api_samr_enum_dom_groups(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_enum_dom_aliases ********************************************************************/ -static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, +static BOOL samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, prs_struct *rdata) { SAMR_R_ENUM_DOM_ALIASES r_e; @@ -736,10 +758,12 @@ static void samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, init_samr_r_enum_dom_aliases(&r_e, num_entries, pass, r_e.status); /* store the response in the SMB stream */ - samr_io_r_enum_dom_aliases("", &r_e, rdata, 0); + if(!samr_io_r_enum_dom_aliases("", &r_e, rdata, 0)) + return False; DEBUG(5,("samr_enum_dom_aliases: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -750,10 +774,12 @@ static BOOL api_samr_enum_dom_aliases(prs_struct *data, prs_struct *rdata) SAMR_Q_ENUM_DOM_ALIASES q_e; /* grab the samr open */ - samr_io_q_enum_dom_aliases("", &q_e, data, 0); + if(!samr_io_q_enum_dom_aliases("", &q_e, data, 0)) + return False; /* construct reply. */ - samr_reply_enum_dom_aliases(&q_e, rdata); + if(!samr_reply_enum_dom_aliases(&q_e, rdata)) + return False; return True; } @@ -762,7 +788,7 @@ static BOOL api_samr_enum_dom_aliases(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_query_dispinfo ********************************************************************/ -static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, +static BOOL samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, prs_struct *rdata) { SAMR_R_QUERY_DISPINFO r_e; @@ -790,10 +816,36 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, if (r_e.status == 0x0) { + /* decide how many entries to get depending on the max_entries + and max_size passed by client */ + uint32 retsize; + + if(q_u->max_entries > MAX_SAM_ENTRIES) + q_u->max_entries = MAX_SAM_ENTRIES; + + retsize = (q_u->max_entries * (sizeof(SAM_ENTRY1)+sizeof(SAM_STR1))) + + 3*sizeof(uint32); + + if(retsize > q_u->max_size) + { + /* determine max_entries based on max_size */ + q_u->max_entries = (q_u->max_size - 3*sizeof(uint32)) / + (sizeof(SAM_ENTRY1)+sizeof(SAM_STR1)); + q_u->max_entries = (q_u->max_entries>0?q_u->max_entries:1); + } + + DEBUG(10,("samr_reply_query_dispinfo: Setting q_u->max_entries to %u\n",q_u->max_entries)); + become_root(True); - got_pwds = get_passwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, MAX_SAM_ENTRIES, 0); + got_pwds = get_passwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, q_u->max_entries, 0); unbecome_root(True); + /* more left - set resume handle */ + if(total_entries > num_entries) + { + r_e.status = 0x105; + } + switch (q_u->switch_level) { case 0x1: @@ -822,16 +874,24 @@ static void samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, } } - if (r_e.status == 0) + /* more left - set resume handle */ + if(total_entries > num_entries) + { + r_e.status = 0x105; + } + + if (r_e.status == 0 || r_e.status == 0x105) { - init_samr_r_query_dispinfo(&r_e, switch_level, &ctr, r_e.status); + init_samr_r_query_dispinfo(&r_e, switch_level, &ctr, r_e.status); } /* store the response in the SMB stream */ - samr_io_r_query_dispinfo("", &r_e, rdata, 0); + if(!samr_io_r_query_dispinfo("", &r_e, rdata, 0)) + return False; DEBUG(5,("samr_query_dispinfo: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -842,10 +902,12 @@ static BOOL api_samr_query_dispinfo(prs_struct *data, prs_struct *rdata) SAMR_Q_QUERY_DISPINFO q_e; /* grab the samr open */ - samr_io_q_query_dispinfo("", &q_e, data, 0); + if(!samr_io_q_query_dispinfo("", &q_e, data, 0)) + return False; /* construct reply. */ - samr_reply_query_dispinfo(&q_e, rdata); + if(!samr_reply_query_dispinfo(&q_e, rdata)) + return False; return True; } @@ -854,39 +916,43 @@ static BOOL api_samr_query_dispinfo(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_query_aliasinfo ********************************************************************/ -static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, +static BOOL samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, prs_struct *rdata) { - SAMR_R_QUERY_ALIASINFO r_e; - - r_e.status = 0x0; - r_e.ptr = 0; - - /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) - { - r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } + SAMR_R_QUERY_ALIASINFO r_e; + fstring alias_desc = "Local Unix group"; + fstring alias=""; + uint8 type; + uint32 alias_rid; - DEBUG(5,("samr_reply_query_aliasinfo: %d\n", __LINE__)); + ZERO_STRUCT(r_e); - if (r_e.status == 0x0) - { - if (q_u->switch_level != 3) - { - r_e.status = NT_STATUS_INVALID_INFO_CLASS; - } - } + DEBUG(5,("samr_reply_query_aliasinfo: %d\n", __LINE__)); - init_samr_r_query_aliasinfo(&r_e, q_u->switch_level, - "local UNIX group", - r_e.status); + /* find the policy handle. open a policy on it. */ + if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) + { + r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + } - /* store the response in the SMB stream */ - samr_io_r_query_aliasinfo("", &r_e, rdata, 0); + alias_rid = get_lsa_policy_samr_rid(&q_u->pol); + if(alias_rid == 0xffffffff) + r_e.status = 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; - DEBUG(5,("samr_query_aliasinfo: %d\n", __LINE__)); + if(!lookup_local_rid(alias_rid, alias, &type)) + { + r_e.status = 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; + } + + init_samr_r_query_aliasinfo(&r_e, q_u->switch_level, alias, alias_desc); + + /* store the response in the SMB stream */ + if(!samr_io_r_query_aliasinfo("", &r_e, rdata, 0)) + return False; + + DEBUG(5,("samr_query_aliasinfo: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -897,10 +963,12 @@ static BOOL api_samr_query_aliasinfo(prs_struct *data, prs_struct *rdata) SAMR_Q_QUERY_ALIASINFO q_e; /* grab the samr open */ - samr_io_q_query_aliasinfo("", &q_e, data, 0); + if(!samr_io_q_query_aliasinfo("", &q_e, data, 0)) + return False; /* construct reply. */ - samr_reply_query_aliasinfo(&q_e, rdata); + if(!samr_reply_query_aliasinfo(&q_e, rdata)) + return False; return True; } @@ -909,7 +977,7 @@ static BOOL api_samr_query_aliasinfo(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_lookup_ids ********************************************************************/ -static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, +static BOOL samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, prs_struct *rdata) { uint32 rid[MAX_SAM_ENTRIES]; @@ -962,10 +1030,12 @@ static void samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, init_samr_r_lookup_ids(&r_u, num_rids, rid, status); /* store the response in the SMB stream */ - samr_io_r_lookup_ids("", &r_u, rdata, 0); + if(!samr_io_r_lookup_ids("", &r_u, rdata, 0)) + return False; DEBUG(5,("samr_lookup_ids: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -976,10 +1046,12 @@ static BOOL api_samr_lookup_ids(prs_struct *data, prs_struct *rdata) SAMR_Q_LOOKUP_IDS q_u; /* grab the samr 0x10 */ - samr_io_q_lookup_ids("", &q_u, data, 0); + if(!samr_io_q_lookup_ids("", &q_u, data, 0)) + return False; /* construct reply. always indicate success */ - samr_reply_lookup_ids(&q_u, rdata); + if(!samr_reply_lookup_ids(&q_u, rdata)) + return False; return True; } @@ -989,71 +1061,73 @@ static BOOL api_samr_lookup_ids(prs_struct *data, prs_struct *rdata) ********************************************************************/ static BOOL samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, - prs_struct *rdata) + prs_struct *rdata) { - uint32 rid[MAX_SAM_ENTRIES]; - uint8 type[MAX_SAM_ENTRIES]; - uint32 status = 0; - int i; - int num_rids = q_u->num_names1; - DOM_SID pol_sid; - - SAMR_R_LOOKUP_NAMES r_u; - - DEBUG(5,("samr_lookup_names: %d\n", __LINE__)); - - ZERO_ARRAY(rid); - ZERO_ARRAY(type); - - if (!get_lsa_policy_samr_sid(&q_u->pol, &pol_sid)) { - status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; - init_samr_r_lookup_names(&r_u, 0, rid, type, status); - if(!samr_io_r_lookup_names("", &r_u, rdata, 0)) { - DEBUG(0,("samr_reply_lookup_names: failed to marshall SAMR_R_LOOKUP_NAMES.\n")); - return False; - } - return True; + uint32 rid[MAX_SAM_ENTRIES]; + uint8 type[MAX_SAM_ENTRIES]; + uint32 status = 0; + int i; + int num_rids = q_u->num_names1; + DOM_SID pol_sid; + + SAMR_R_LOOKUP_NAMES r_u; + + DEBUG(5,("samr_lookup_names: %d\n", __LINE__)); + + ZERO_ARRAY(rid); + ZERO_ARRAY(type); + + if (!get_lsa_policy_samr_sid(&q_u->pol, &pol_sid)) { + status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; + init_samr_r_lookup_names(&r_u, 0, rid, type, status); + if(!samr_io_r_lookup_names("", &r_u, rdata, 0)) { + DEBUG(0,("samr_reply_lookup_names: failed to marshall SAMR_R_LOOKUP_NAMES.\n")); + return False; } + return True; + } - if (num_rids > MAX_SAM_ENTRIES) { - num_rids = MAX_SAM_ENTRIES; - DEBUG(5,("samr_lookup_names: truncating entries to %d\n", num_rids)); - } - - SMB_ASSERT_ARRAY(q_u->uni_name, num_rids); + if (num_rids > MAX_SAM_ENTRIES) { + num_rids = MAX_SAM_ENTRIES; + DEBUG(5,("samr_lookup_names: truncating entries to %d\n", num_rids)); + } - for (i = 0; i < num_rids; i++) { - fstring name; + SMB_ASSERT_ARRAY(q_u->uni_name, num_rids); - status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + for (i = 0; i < num_rids; i++) { + fstring name; - rid [i] = 0xffffffff; - type[i] = SID_NAME_UNKNOWN; + status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - fstrcpy(name, dos_unistrn2(q_u->uni_name[i].buffer, - q_u->uni_name[i].uni_str_len)); + rid [i] = 0xffffffff; + type[i] = SID_NAME_UNKNOWN; - if(sid_equal(&pol_sid, &global_sam_sid)) { - DOM_SID sid; + fstrcpy(name, dos_unistrn2(q_u->uni_name[i].buffer, + q_u->uni_name[i].uni_str_len)); - if(lookup_local_name(global_myname, name, &sid, &type[i])) { - sid_split_rid( &sid, &rid[i]); - status = 0; - } - } + if(sid_equal(&pol_sid, &global_sam_sid)) + { + DOM_SID sid; + if(lookup_local_name(global_myname, name, + &sid, &type[i])) + { + sid_split_rid( &sid, &rid[i]); + status = 0; } + } + } - init_samr_r_lookup_names(&r_u, num_rids, rid, type, status); + init_samr_r_lookup_names(&r_u, num_rids, rid, type, status); - /* store the response in the SMB stream */ - if(!samr_io_r_lookup_names("", &r_u, rdata, 0)) { - DEBUG(0,("samr_reply_lookup_names: failed to marshall SAMR_R_LOOKUP_NAMES.\n")); - return False; - } + /* store the response in the SMB stream */ + if(!samr_io_r_lookup_names("", &r_u, rdata, 0)) { + DEBUG(0,("samr_reply_lookup_names: failed to marshall SAMR_R_LOOKUP_NAMES.\n")); + return False; + } - DEBUG(5,("samr_lookup_names: %d\n", __LINE__)); + DEBUG(5,("samr_lookup_names: %d\n", __LINE__)); - return True; + return True; } /******************************************************************* @@ -1142,8 +1216,7 @@ static BOOL api_samr_chgpasswd_user(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_unknown_38 ********************************************************************/ -static void samr_reply_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, - prs_struct *rdata) +static BOOL samr_reply_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, prs_struct *rdata) { SAMR_R_UNKNOWN_38 r_u; @@ -1152,9 +1225,11 @@ static void samr_reply_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, init_samr_r_unknown_38(&r_u); /* store the response in the SMB stream */ - samr_io_r_unknown_38("", &r_u, rdata, 0); + if(!samr_io_r_unknown_38("", &r_u, rdata, 0)) + return False; DEBUG(5,("samr_unknown_38: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -1165,10 +1240,12 @@ static BOOL api_samr_unknown_38(prs_struct *data, prs_struct *rdata) SAMR_Q_UNKNOWN_38 q_u; /* unknown 38 command */ - samr_io_q_unknown_38("", &q_u, data, 0); + if(!samr_io_q_unknown_38("", &q_u, data, 0)) + return False; /* construct reply. always indicate success */ - samr_reply_unknown_38(&q_u, rdata); + if(!samr_reply_unknown_38(&q_u, rdata)) + return False; return True; } @@ -1177,7 +1254,7 @@ static BOOL api_samr_unknown_38(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_unknown_12 ********************************************************************/ -static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, +static BOOL samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, prs_struct *rdata) { fstring group_names[MAX_SAM_ENTRIES]; @@ -1214,10 +1291,12 @@ static void samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, init_samr_r_unknown_12(&r_u, num_gids, group_names, group_attrs, status); /* store the response in the SMB stream */ - samr_io_r_unknown_12("", &r_u, rdata, 0); + if(!samr_io_r_unknown_12("", &r_u, rdata, 0)) + return False; DEBUG(5,("samr_unknown_12: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -1228,10 +1307,12 @@ static BOOL api_samr_unknown_12(prs_struct *data, prs_struct *rdata) SAMR_Q_UNKNOWN_12 q_u; /* grab the samr lookup names */ - samr_io_q_unknown_12("", &q_u, data, 0); + if(!samr_io_q_unknown_12("", &q_u, data, 0)) + return False; /* construct reply. always indicate success */ - samr_reply_unknown_12(&q_u, rdata); + if(!samr_reply_unknown_12(&q_u, rdata)) + return False; return True; } @@ -1240,9 +1321,7 @@ static BOOL api_samr_unknown_12(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_open_user ********************************************************************/ -static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, - prs_struct *rdata, - int status) +static BOOL samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, prs_struct *rdata, int status) { SAMR_R_OPEN_USER r_u; struct sam_passwd *sam_pass; @@ -1290,10 +1369,12 @@ static void samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, DEBUG(5,("samr_open_user: %d\n", __LINE__)); /* store the response in the SMB stream */ - samr_io_r_open_user("", &r_u, rdata, 0); + if(!samr_io_r_open_user("", &r_u, rdata, 0)) + return False; DEBUG(5,("samr_open_user: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -1304,10 +1385,12 @@ static BOOL api_samr_open_user(prs_struct *data, prs_struct *rdata) SAMR_Q_OPEN_USER q_u; /* grab the samr unknown 22 */ - samr_io_q_open_user("", &q_u, data, 0); + if(!samr_io_q_open_user("", &q_u, data, 0)) + return False; /* construct reply. always indicate success */ - samr_reply_open_user(&q_u, rdata, 0x0); + if(!samr_reply_open_user(&q_u, rdata, 0x0)) + return False; return True; } @@ -1420,7 +1503,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) /******************************************************************* samr_reply_query_userinfo ********************************************************************/ -static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, +static BOOL samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, prs_struct *rdata) { SAMR_R_QUERY_USERINFO r_u; @@ -1495,10 +1578,12 @@ static void samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, init_samr_r_query_userinfo(&r_u, q_u->switch_value, info, status); /* store the response in the SMB stream */ - samr_io_r_query_userinfo("", &r_u, rdata, 0); + if(!samr_io_r_query_userinfo("", &r_u, rdata, 0)) + return False; DEBUG(5,("samr_reply_query_userinfo: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -1509,10 +1594,12 @@ static BOOL api_samr_query_userinfo(prs_struct *data, prs_struct *rdata) SAMR_Q_QUERY_USERINFO q_u; /* grab the samr unknown 24 */ - samr_io_q_query_userinfo("", &q_u, data, 0); + if(!samr_io_q_query_userinfo("", &q_u, data, 0)) + return False; /* construct reply. always indicate success */ - samr_reply_query_userinfo(&q_u, rdata); + if(!samr_reply_query_userinfo(&q_u, rdata)) + return False; return True; } @@ -1521,7 +1608,7 @@ static BOOL api_samr_query_userinfo(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_query_usergroups ********************************************************************/ -static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, +static BOOL samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, prs_struct *rdata) { SAMR_R_QUERY_USERGROUPS r_u; @@ -1570,15 +1657,18 @@ static void samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, init_samr_r_query_usergroups(&r_u, num_groups, gids, status); /* store the response in the SMB stream */ - samr_io_r_query_usergroups("", &r_u, rdata, 0); + if(!samr_io_r_query_usergroups("", &r_u, rdata, 0)) { + if (gids) + free((char *)gids); + return False; + } if (gids) - { free((char *)gids); - } DEBUG(5,("samr_query_usergroups: %d\n", __LINE__)); - + + return True; } /******************************************************************* @@ -1588,10 +1678,12 @@ static BOOL api_samr_query_usergroups(prs_struct *data, prs_struct *rdata) { SAMR_Q_QUERY_USERGROUPS q_u; /* grab the samr unknown 32 */ - samr_io_q_query_usergroups("", &q_u, data, 0); + if(!samr_io_q_query_usergroups("", &q_u, data, 0)) + return False; /* construct reply. */ - samr_reply_query_usergroups(&q_u, rdata); + if(!samr_reply_query_usergroups(&q_u, rdata)) + return False; return True; } @@ -1600,8 +1692,7 @@ static BOOL api_samr_query_usergroups(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_query_dom_info ********************************************************************/ -static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, - prs_struct *rdata) +static BOOL samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, prs_struct *rdata) { SAMR_R_QUERY_DOMAIN_INFO r_u; SAM_UNK_CTR ctr; @@ -1644,10 +1735,12 @@ static void samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, init_samr_r_query_dom_info(&r_u, switch_value, &ctr, status); /* store the response in the SMB stream */ - samr_io_r_query_dom_info("", &r_u, rdata, 0); + if(!samr_io_r_query_dom_info("", &r_u, rdata, 0)) + return False; DEBUG(5,("samr_query_dom_info: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -1658,20 +1751,20 @@ static BOOL api_samr_query_dom_info(prs_struct *data, prs_struct *rdata) SAMR_Q_QUERY_DOMAIN_INFO q_e; /* grab the samr unknown 8 command */ - samr_io_q_query_dom_info("", &q_e, data, 0); + if(!samr_io_q_query_dom_info("", &q_e, data, 0)) + return False; /* construct reply. */ - samr_reply_query_dom_info(&q_e, rdata); + if(!samr_reply_query_dom_info(&q_e, rdata)) + return False; return True; } - - /******************************************************************* samr_reply_unknown_32 ********************************************************************/ -static void samr_reply_unknown_32(SAMR_Q_UNKNOWN_32 *q_u, +static BOOL samr_reply_unknown_32(SAMR_Q_UNKNOWN_32 *q_u, prs_struct *rdata, int status) { @@ -1694,10 +1787,12 @@ static void samr_reply_unknown_32(SAMR_Q_UNKNOWN_32 *q_u, DEBUG(5,("samr_unknown_32: %d\n", __LINE__)); /* store the response in the SMB stream */ - samr_io_r_unknown_32("", &r_u, rdata, 0); + if(!samr_io_r_unknown_32("", &r_u, rdata, 0)) + return False; DEBUG(5,("samr_unknown_32: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -1740,7 +1835,8 @@ static BOOL api_samr_unknown_32(prs_struct *data, prs_struct *rdata) } /* construct reply. */ - samr_reply_unknown_32(&q_u, rdata, status); + if(!samr_reply_unknown_32(&q_u, rdata, status)) + return False; return True; } @@ -1749,8 +1845,7 @@ static BOOL api_samr_unknown_32(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_connect_anon ********************************************************************/ -static void samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, - prs_struct *rdata) +static BOOL samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, prs_struct *rdata) { SAMR_R_CONNECT_ANON r_u; BOOL pol_open = False; @@ -1779,10 +1874,12 @@ static void samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, DEBUG(5,("samr_connect_anon: %d\n", __LINE__)); /* store the response in the SMB stream */ - samr_io_r_connect_anon("", &r_u, rdata, 0); + if(!samr_io_r_connect_anon("", &r_u, rdata, 0)) + return False; DEBUG(5,("samr_connect_anon: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -1793,10 +1890,12 @@ static BOOL api_samr_connect_anon(prs_struct *data, prs_struct *rdata) SAMR_Q_CONNECT_ANON q_u; /* grab the samr open policy */ - samr_io_q_connect_anon("", &q_u, data, 0); + if(!samr_io_q_connect_anon("", &q_u, data, 0)) + return False; /* construct reply. always indicate success */ - samr_reply_connect_anon(&q_u, rdata); + if(!samr_reply_connect_anon(&q_u, rdata)) + return False; return True; } @@ -1804,8 +1903,7 @@ static BOOL api_samr_connect_anon(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_connect ********************************************************************/ -static void samr_reply_connect(SAMR_Q_CONNECT *q_u, - prs_struct *rdata) +static BOOL samr_reply_connect(SAMR_Q_CONNECT *q_u, prs_struct *rdata) { SAMR_R_CONNECT r_u; BOOL pol_open = False; @@ -1834,10 +1932,12 @@ static void samr_reply_connect(SAMR_Q_CONNECT *q_u, DEBUG(5,("samr_connect: %d\n", __LINE__)); /* store the response in the SMB stream */ - samr_io_r_connect("", &r_u, rdata, 0); + if(!samr_io_r_connect("", &r_u, rdata, 0)) + return False; DEBUG(5,("samr_connect: %d\n", __LINE__)); + return True; } /******************************************************************* @@ -1848,19 +1948,103 @@ static BOOL api_samr_connect(prs_struct *data, prs_struct *rdata) SAMR_Q_CONNECT q_u; /* grab the samr open policy */ - samr_io_q_connect("", &q_u, data, 0); + if(!samr_io_q_connect("", &q_u, data, 0)) + return False; /* construct reply. always indicate success */ - samr_reply_connect(&q_u, rdata); + if(!samr_reply_connect(&q_u, rdata)) + return False; + + return True; +} + +/********************************************************************** + api_reply_lookup_domain + **********************************************************************/ +static BOOL samr_reply_lookup_domain(SAMR_Q_LOOKUP_DOMAIN* q_u, prs_struct* rdata) +{ + SAMR_R_LOOKUP_DOMAIN r_u; + + r_u.status = 0x0; + if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->connect_pol)) == -1)) + { + r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + DEBUG(5,("samr_reply_lookup_domain: invalid handle\n")); + } + + /* assume the domain name sent is our global_myname and + send global_sam_sid */ + init_samr_r_lookup_domain(&r_u, &global_sam_sid, r_u.status); + + if(!samr_io_r_lookup_domain("", &r_u, rdata, 0)) + return False; + + DEBUG(5,("samr_reply_lookup_domain: %d\n", __LINE__)); + + return True; +} + +/********************************************************************** + api_samr_lookup_domain + **********************************************************************/ +static BOOL api_samr_lookup_domain(prs_struct* data, prs_struct* rdata) +{ + SAMR_Q_LOOKUP_DOMAIN q_u; + + if(!samr_io_q_lookup_domain("", &q_u, data, 0)) + return False; + + if(!samr_reply_lookup_domain(&q_u, rdata)) + return False; + + return True; +} + +/********************************************************************** + samr_reply_enum_domains + **********************************************************************/ +static BOOL samr_reply_enum_domains(SAMR_Q_ENUM_DOMAINS* q_u, prs_struct* rdata) +{ + SAMR_R_ENUM_DOMAINS r_u; + fstring dom[2]; + + fstrcpy(dom[0],global_myname); + fstrcpy(dom[1],"Builtin"); + r_u.status = 0; + + init_samr_r_enum_domains(&r_u, q_u->start_idx, dom, 2); + if(!samr_io_r_enum_domains("", &r_u, rdata, 0)) { + free(r_u.sam); + free(r_u.uni_dom_name); + return False; + } + + free(r_u.sam); + free(r_u.uni_dom_name); return True; } +/********************************************************************** + api_samr_enum_domains + **********************************************************************/ +static BOOL api_samr_enum_domains(prs_struct* data, prs_struct* rdata) +{ + SAMR_Q_ENUM_DOMAINS q_u; + + if(!samr_io_q_enum_domains("", &q_u, data, 0)) + return False; + + if(!samr_reply_enum_domains(&q_u, rdata)) + return False; + + return True; +} + /******************************************************************* samr_reply_open_alias ********************************************************************/ -static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, - prs_struct *rdata) +static BOOL samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, prs_struct *rdata) { SAMR_R_OPEN_ALIAS r_u; BOOL pol_open = False; @@ -1889,10 +2073,12 @@ static void samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, DEBUG(5,("samr_open_alias: %d\n", __LINE__)); /* store the response in the SMB stream */ - samr_io_r_open_alias("", &r_u, rdata, 0); + if(!samr_io_r_open_alias("", &r_u, rdata, 0)) + return False; DEBUG(5,("samr_open_alias: %d\n", __LINE__)); - + + return True; } /******************************************************************* @@ -1904,10 +2090,12 @@ static BOOL api_samr_open_alias(prs_struct *data, prs_struct *rdata) SAMR_Q_OPEN_ALIAS q_u; /* grab the samr open policy */ - samr_io_q_open_alias("", &q_u, data, 0); + if(!samr_io_q_open_alias("", &q_u, data, 0)) + return False; /* construct reply. always indicate success */ - samr_reply_open_alias(&q_u, rdata); + if(!samr_reply_open_alias(&q_u, rdata)) + return False; return True; } @@ -1939,6 +2127,8 @@ static struct api_struct api_samr_cmds [] = { "SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, { "SAMR_UNKNOWN_3" , SAMR_UNKNOWN_3 , api_samr_unknown_3 }, { "SAMR_UNKNOWN_2C" , SAMR_UNKNOWN_2C , api_samr_unknown_2c }, + { "SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, + { "SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains }, { NULL , 0 , NULL } }; @@ -1949,6 +2139,4 @@ BOOL api_samr_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_samr_rpc", api_samr_cmds, data); } - #undef OLD_NTDOMAIN - -- cgit From c560164030c0b842ee06f651a2b019c5596624a2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 17 May 2000 03:12:56 +0000 Subject: Fixed bug where mallocd size of prs_struct could be larger than incoming packet. Ensure new alloced memory is zeroed before use. Jeremy. (This used to be commit 1c3193aa1c1137734dc34ef2e6d62abb0609c30e) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 9ba62ea656..06743d8d16 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -110,7 +110,7 @@ BOOL create_next_pdu(pipes_struct *p) p->hdr.flags = 0; /* - * Work out how much we can fit in a sigle PDU. + * Work out how much we can fit in a single PDU. */ data_space_available = sizeof(p->out_data.current_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN; -- cgit From 819c15449882a0c08689a4565bf0b31f756f05bd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 17 May 2000 19:17:16 +0000 Subject: Fixed bug I introduced last night (sorry). Now truncate incoming prs_struct buffer size to exact size of incoming data to prevent read overruns into slop space. Jeremy. (This used to be commit aa1a4f46da9584240cd6cee6fb652aa73e77015c) --- source3/rpc_server/srv_pipe_hnd.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index f19aed1886..a349da839a 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -475,6 +475,13 @@ authentication failed. Denying the request.\n", p->name)); * Call the rpc command to process it. */ + /* + * Ensure the internal prs buffer size is *exactly* the same + * size as the current offset. + */ + + prs_set_buffer_size(&p->in_data.data, prs_offset(&p->in_data.data)); + /* * Set the parse offset to the start of the data and set the * prs_struct to UNMARSHALL. -- cgit From 74d677ec591a715e28dba29a33ee40e1b1c2f830 Mon Sep 17 00:00:00 2001 From: Shirish Kalele Date: Thu, 18 May 2000 18:43:53 +0000 Subject: Added the NETDFS pipe to allow remote administration of the msdfs symlinks on the samba server. (This used to be commit 15e7d8f6c5cddf6ce409ee2505744250d181ec34) --- source3/rpc_server/srv_dfs.c | 456 ++++++++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_pipe.c | 3 + 2 files changed, 459 insertions(+) create mode 100644 source3/rpc_server/srv_dfs.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c new file mode 100644 index 0000000000..9f78b7db37 --- /dev/null +++ b/source3/rpc_server/srv_dfs.c @@ -0,0 +1,456 @@ + +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines for Dfs + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Shirish Kalele 2000. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" +#include "nterr.h" + +#define MAX_MSDFS_JUNCTIONS 256 + +extern int DEBUGLEVEL; +extern pstring global_myname; + +#ifdef MS_DFS + +/********************************************************************** + api_dfs_exist + **********************************************************************/ +static BOOL api_dfs_exist( prs_struct *data, + prs_struct *rdata) +{ + DFS_R_DFS_EXIST r_d; + + if(lp_host_msdfs()) + r_d.dfs_exist_flag = 1; + else + r_d.dfs_exist_flag = 0; + + return dfs_io_r_dfs_exist("", &r_d, rdata, 0); +} + +static uint32 init_reply_dfs_add(DFS_Q_DFS_ADD* q_a) +{ + struct junction_map jn; + struct referral* old_referral_list = NULL; + BOOL exists = False; + + pstring dfspath, servername, sharename; + pstring altpath; + + unistr2_to_ascii(dfspath, &(q_a->DfsEntryPath), sizeof(dfspath)-1); + unistr2_to_ascii(servername, &(q_a->ServerName), sizeof(servername)-1); + unistr2_to_ascii(sharename, &(q_a->ShareName), sizeof(sharename)-1); + + DEBUG(5,("init_reply_dfs_add: Request to add %s -> %s\\%s.\n", + dfspath, servername, sharename)); + + pstrcpy(altpath, servername); + pstrcat(altpath, "\\"); + pstrcat(altpath, sharename); + + if(!create_junction(dfspath, &jn)) + return NERR_DfsNoSuchServer; + + if(get_referred_path(&jn)) + { + exists = True; + jn.referral_count += 1; + old_referral_list = jn.referral_list; + } + else + jn.referral_count = 1; + + jn.referral_list = (struct referral*) malloc(jn.referral_count + * sizeof(struct referral)); + + if(jn.referral_list == NULL) + { + DEBUG(0,("init_reply_dfs_add: malloc failed for referral list!\n")); + return NERR_DfsInternalError; + } + + if(old_referral_list) + { + memcpy(jn.referral_list, old_referral_list, + sizeof(struct referral)*jn.referral_count-1); + free(old_referral_list); + } + + jn.referral_list[jn.referral_count-1].proximity = 0; + jn.referral_list[jn.referral_count-1].ttl = REFERRAL_TTL; + + pstrcpy(jn.referral_list[jn.referral_count-1].alternate_path, altpath); + + if(!create_msdfs_link(&jn, exists)) + return NERR_DfsCantCreateJunctionPoint; + + return 0; +} +/***************************************************************** + api_dfs_add + *****************************************************************/ +static BOOL api_dfs_add(prs_struct* data, prs_struct* rdata) +{ + DFS_Q_DFS_ADD q_a; + DFS_R_DFS_ADD r_a; + + if(!dfs_io_q_dfs_add("", &q_a, data, 0)) + return False; + + r_a.status = init_reply_dfs_add(&q_a); + + dfs_io_r_dfs_add("", &r_a, rdata, 0); + + return True; +} + +static uint32 init_reply_dfs_remove(DFS_Q_DFS_REMOVE* q_r) +{ + struct junction_map jn; + BOOL found = False; + + pstring dfspath, servername, sharename; + pstring altpath; + + unistr2_to_ascii(dfspath, &(q_r->DfsEntryPath), sizeof(dfspath)-1); + if(q_r->ptr_ServerName) + unistr2_to_ascii(servername, &(q_r->ServerName), sizeof(servername)-1); + + if(q_r->ptr_ShareName) + unistr2_to_ascii(sharename, &(q_r->ShareName), sizeof(sharename)-1); + + if(q_r->ptr_ServerName && q_r->ptr_ShareName) + { + pstrcpy(altpath, servername); + pstrcat(altpath, "\\"); + pstrcat(altpath, sharename); + } + + 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 no server-share pair given, remove the msdfs link completely */ + if(!q_r->ptr_ServerName && !q_r->ptr_ShareName) + { + if(!remove_msdfs_link(&jn)) + return NERR_DfsNoSuchVolume; + } + else + { + int i=0; + /* compare each referral in the list with the one to remove */ + for(i=0;ialternate_path); + trim_string(path,"\\",""); + p = strrchr(path,'\\'); + if(p==NULL) + { + DEBUG(4,("init_reply_dfs_info_3: invalid path: no \\ found in %s\n",path)); + continue; + } + *p = '\0'; + DEBUG(5,("storage %d: %s.%s\n",ii,path,p+1)); + stor->state = 2; /* set all storages as ONLINE */ + init_unistr2(&stor->servername, path, strlen(path)+1); + init_unistr2(&stor->sharename, p+1, strlen(p+1)+1); + stor->ptr_servername = stor->ptr_sharename = 1; + } + } + return True; +} + +static uint32 init_reply_dfs_ctr(uint32 level, DFS_INFO_CTR* ctr, + struct junction_map* jn, int num_jn) +{ + /* do the levels */ + switch(level) + { + case 1: + { + DFS_INFO_1* dfs1; + dfs1 = (DFS_INFO_1*) malloc(num_jn * sizeof(DFS_INFO_1)); + init_reply_dfs_info_1(jn, dfs1, num_jn); + ctr->dfs.info1 = dfs1; + break; + } + case 2: + { + DFS_INFO_2* dfs2; + dfs2 = (DFS_INFO_2*) malloc(num_jn * sizeof(DFS_INFO_2)); + init_reply_dfs_info_2(jn, dfs2, num_jn); + ctr->dfs.info2 = dfs2; + break; + } + case 3: + { + DFS_INFO_3* dfs3; + dfs3 = (DFS_INFO_3*) malloc(num_jn * sizeof(DFS_INFO_3)); + init_reply_dfs_info_3(jn, dfs3, num_jn); + ctr->dfs.info3 = dfs3; + } + } + return 0; +} + +static uint32 init_reply_dfs_enum(uint32 level, DFS_R_DFS_ENUM *q_r) +{ + struct junction_map jn[MAX_MSDFS_JUNCTIONS]; + int num_jn = 0; + int i=0; + + num_jn = enum_msdfs_junctions(jn); + + DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", + num_jn, level)); + + q_r->ptr_buffer = level; + q_r->level = q_r->level2 = level; + q_r->ptr_num_entries = q_r->ptr_num_entries2 = 1; + q_r->num_entries = q_r->num_entries2 = num_jn; + q_r->reshnd.ptr_hnd = 1; + q_r->reshnd.handle = num_jn; + + q_r->ctr = (DFS_INFO_CTR*) malloc(sizeof(DFS_INFO_CTR)); + q_r->ctr->switch_value = level; + q_r->ctr->num_entries = num_jn; + q_r->ctr->ptr_dfs_ctr = 1; + + init_reply_dfs_ctr(level, q_r->ctr, jn, num_jn); + + for(i=0;ilevel = level; + r_i->ptr_ctr = 1; + r_i->status = init_reply_dfs_ctr(level, &(r_i->ctr), &jn, 1); + + free(jn.referral_list); + return 0; +} +/******************************************************************* + api_dfs_get_info + *******************************************************************/ +static BOOL api_dfs_get_info(prs_struct* data, prs_struct* rdata) +{ + DFS_Q_DFS_GET_INFO q_i; + DFS_R_DFS_GET_INFO r_i; + + ZERO_STRUCT(r_i); + + if(!dfs_io_q_dfs_get_info("", &q_i, data, 0)) + return False; + + r_i.status = init_reply_dfs_get_info(&q_i.uni_path, q_i.level, &r_i); + + if(!dfs_io_r_dfs_get_info("", &r_i, rdata, 0)) + return False; + + switch(r_i.level) { + case 1: free(r_i.ctr.dfs.info1); break; + case 2: free(r_i.ctr.dfs.info2); break; + case 3: + { + free(r_i.ctr.dfs.info3->storages); + free(r_i.ctr.dfs.info3); + break; + } + } + return True; +} + +/******************************************************************* + api_dfs_enum + *******************************************************************/ +static BOOL api_dfs_enum(prs_struct* data, prs_struct* rdata) +{ + DFS_Q_DFS_ENUM q_e; + DFS_R_DFS_ENUM q_r; + + if(!dfs_io_q_dfs_enum("", &q_e, data, 0)) + return False; + + q_r.status = init_reply_dfs_enum(q_e.level, &q_r); + + if(!dfs_io_r_dfs_enum("", &q_r, rdata, 0)) + return False; + switch(q_e.level) { + case 1: + free(q_r.ctr->dfs.info1); break; + case 2: + free(q_r.ctr->dfs.info2); break; + case 3: + free(q_r.ctr->dfs.info3->storages); free(q_r.ctr->dfs.info3); break; + } + free(q_r.ctr); + return True; +} + +/******************************************************************* +\pipe\netdfs commands +********************************************************************/ +struct api_struct api_netdfs_cmds[] = +{ + {"DFS_EXIST", DFS_EXIST, api_dfs_exist }, + {"DFS_ADD", DFS_ADD, api_dfs_add }, + {"DFS_REMOVE", DFS_REMOVE, api_dfs_remove }, + {"DFS_GET_INFO", DFS_GET_INFO, api_dfs_get_info }, + {"DFS_ENUM", DFS_ENUM, api_dfs_enum }, + {NULL, 0, NULL } +}; + +/******************************************************************* +receives a netdfs pipe and responds. +********************************************************************/ +BOOL api_netdfs_rpc(pipes_struct *p, prs_struct *data) +{ + return api_rpcTNP(p, "api_netdfs_rpc", api_netdfs_cmds, data); +} + +#endif diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 06743d8d16..aef0c9d23b 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -474,6 +474,9 @@ static struct api_cmd api_fd_commands[] = { "NETLOGON", "lsass", api_netlog_rpc }, { "winreg", "winreg", api_reg_rpc }, { "spoolss", "spoolss", api_spoolss_rpc }, +#ifdef MS_DFS + { "netdfs", "netdfs" , api_netdfs_rpc }, +#endif { NULL, NULL, NULL } }; -- cgit From 69519df0f6a6d9c0d2b88cd092fa58421b13f4a3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 22 May 2000 20:04:50 +0000 Subject: Modify NT driver heirarchy to fix HP bug with duplicate printer driver filenames :-). Jeremy. (This used to be commit adb6ad812a4d897ee0c0712cc06d1ff8553fa093) --- source3/rpc_server/srv_spoolss_nt.c | 68 +++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 95d7b7fdff..da808f1b57 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -889,7 +889,7 @@ static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, p { pstring temp_name; - snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); + snprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname); data->notify_data.data.length=strlen(temp_name); ascii_to_unistr((char *)data->notify_data.data.string, temp_name, sizeof(data->notify_data.data.string)-1); @@ -2410,7 +2410,7 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, get_short_archi(short_archi,architecture); - snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\", servername, short_archi); + snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\%s\\", servername, short_archi, driver.info_3->name); info->version=driver.info_3->cversion; @@ -2500,8 +2500,8 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, get_short_archi(short_archi, architecture); - snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\", servername, short_archi); - + snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\%s\\", servername, short_archi, driver.info_3->name); + info->version=driver.info_3->cversion; init_unistr( &(info->name), driver.info_3->name ); @@ -3747,6 +3747,48 @@ uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level, } } +/**************************************************************************** + Modify internal driver heirarchy. +****************************************************************************/ + +static uint32 modify_driver_heirarchy(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32 level) +{ + pstring path_old; + pstring path_new; + pstring short_archi; + int snum = snum = find_service("print$"); + char *model = NULL; + + *short_archi = '\0'; + switch (level) { + case 3: + get_short_archi(short_archi, driver->info_3->environment); + model = driver->info_3->name; + break; + case 6: + get_short_archi(short_archi, driver->info_6->environment); + model = driver->info_6->name; + break; + default: + DEBUG(0,("modify_driver_heirarchy: unknown info level (%d)\n", level)); + return ERROR_INVALID_LEVEL; + break; + } + + slprintf(path_old, sizeof(path_old)-1, "%s/%s/TMP_%u", lp_pathname(snum), short_archi, + (unsigned int)sys_getpid()); + slprintf(path_new, sizeof(path_new)-1, "%s/%s/%s", lp_pathname(snum), short_archi, model); + + DEBUG(10,("_spoolss_addprinterdriver: old_path=%s, new_path=%s\n", + path_old, path_new )); + if (dos_rename(path_old, path_new) == -1) { + DEBUG(0,("modify_driver_heirarchy: rename failed (%s)\n", strerror(errno) )); + /* We need to clean up here.... - how ? */ + return ERROR_ACCESS_DENIED; /* We need a generic mapping from NT errors here... */ + } + + return NT_STATUS_NO_PROBLEMO; +} /**************************************************************************** ****************************************************************************/ @@ -3755,7 +3797,7 @@ uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name, const SPOOL_PRINTER_DRIVER_INFO_LEVEL *info) { NT_PRINTER_DRIVER_INFO_LEVEL driver; - + uint32 err; ZERO_STRUCT(driver); convert_printer_driver_info(info, &driver, level); @@ -3763,6 +3805,12 @@ uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name, if (add_a_printer_driver(driver, level)!=0) return ERROR_ACCESS_DENIED; + if ((err = modify_driver_heirarchy(&driver, level)) != 0) { + safe_free(driver.info_3); + safe_free(driver.info_6); + return err; + } + safe_free(driver.info_3); safe_free(driver.info_6); @@ -3780,7 +3828,7 @@ static void fill_driverdir_1(DRIVER_DIRECTORY_1 *info, char *name) ****************************************************************************/ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environment, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { - pstring chaine; + pstring path; pstring long_archi; pstring short_archi; DRIVER_DIRECTORY_1 *info=NULL; @@ -3791,11 +3839,11 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); get_short_archi(short_archi, long_archi); - slprintf(chaine, sizeof(chaine)-1, "\\\\%s\\print$\\%s", global_myname, short_archi); - - DEBUG(4,("printer driver directory: [%s]\n", chaine)); + slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s\\TMP_%u", global_myname, short_archi, + (unsigned int)sys_getpid()); + DEBUG(4,("printer driver directory: [%s]\n", path)); - fill_driverdir_1(info, chaine); + fill_driverdir_1(info, path); *needed += spoolss_size_driverdir_info_1(info); -- cgit From 722c86a38f72fb8b114a1d89aed23f262d00b6c6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 24 May 2000 06:34:47 +0000 Subject: a fairly big change in spoolss. got rid of the forms, drivers and printers files in the nt drivers directory and instead use a single tdb note that this is _not_ all finished. (This used to be commit 537cd6dff057df481fb208121ce4396fc76c2a06) --- source3/rpc_server/srv_spoolss_nt.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index da808f1b57..dc24c3bc31 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2456,7 +2456,7 @@ static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstri * * convert an array of ascii string to a UNICODE string ********************************************************************/ -static void init_unistr_array(uint16 **uni_array, char **char_array, char *where) +static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *where) { int i=0; int j=0; @@ -2466,7 +2466,8 @@ static void init_unistr_array(uint16 **uni_array, char **char_array, char *where DEBUG(6,("init_unistr_array\n")); *uni_array=NULL; - for (v=char_array[i]; *v!='\0'; v=char_array[i]) { + while (1) { + v = char_array[i]; snprintf(line, sizeof(line)-1, "%s%s", where, v); DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); if((*uni_array=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL) { @@ -2476,9 +2477,12 @@ static void init_unistr_array(uint16 **uni_array, char **char_array, char *where ascii_to_unistr((char *)(*uni_array+j), line , 2*strlen(line)); j+=strlen(line)+1; i++; + if (strlen(v) == 0) break; } - (*uni_array)[j]=0x0000; + if (*uni_array) { + (*uni_array)[j]=0x0000; + } DEBUGADD(6,("last one:done\n")); } @@ -2614,27 +2618,21 @@ static uint32 getprinterdriver2_level2(fstring servername, fstring architecture, ****************************************************************************/ static uint32 getprinterdriver2_level3(fstring servername, fstring architecture, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { - DRIVER_INFO_3 *info=NULL; - - if((info=(DRIVER_INFO_3 *)malloc(sizeof(DRIVER_INFO_3)))==NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - construct_printer_driver_info_3(info, snum, servername, architecture); + DRIVER_INFO_3 info; + + ZERO_STRUCT(info); + + construct_printer_driver_info_3(&info, snum, servername, architecture); /* check the required size. */ - *needed += spoolss_size_printer_driver_info_3(info); + *needed += spoolss_size_printer_driver_info_3(&info); if (!alloc_buffer_size(buffer, *needed)) { - safe_free(info); return ERROR_INSUFFICIENT_BUFFER; } /* fill the buffer with the structures */ - new_smb_io_printer_driver_info_3("", buffer, info, 0); - - /* clear memory */ - safe_free(info->dependentfiles); - safe_free(info); + new_smb_io_printer_driver_info_3("", buffer, &info, 0); if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; -- cgit From 8a86541e282424c4e0ea5626b26e818779ba0375 Mon Sep 17 00:00:00 2001 From: Shirish Kalele Date: Fri, 26 May 2000 17:10:40 +0000 Subject: Changed MS_DFS to WITH_MSDFS throughout. Fixed trans2 calls on IPC$ to let dfs referral calls through. (This used to be commit e0965a80bdca5239886b11ef55dc29fed261bfc0) --- source3/rpc_server/srv_dfs.c | 4 ++-- source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_srvsvc.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 9f78b7db37..2a8bb71604 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -30,7 +30,7 @@ extern int DEBUGLEVEL; extern pstring global_myname; -#ifdef MS_DFS +#ifdef WITH_MSDFS /********************************************************************** api_dfs_exist @@ -329,7 +329,7 @@ static uint32 init_reply_dfs_enum(uint32 level, DFS_R_DFS_ENUM *q_r) int num_jn = 0; int i=0; - num_jn = enum_msdfs_junctions(jn); + num_jn = enum_msdfs_links(jn); DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", num_jn, level)); diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index aef0c9d23b..11dc5a2f89 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -474,7 +474,7 @@ static struct api_cmd api_fd_commands[] = { "NETLOGON", "lsass", api_netlog_rpc }, { "winreg", "winreg", api_reg_rpc }, { "spoolss", "spoolss", api_spoolss_rpc }, -#ifdef MS_DFS +#ifdef WITH_MSDFS { "netdfs", "netdfs" , api_netdfs_rpc }, #endif { NULL, NULL, NULL } diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 44c4f5569d..2e8d33d4d2 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -98,7 +98,7 @@ static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum) { sh1005->dfs_root_flag = 0; -#ifdef MS_DFS +#ifdef WITH_MSDFS if(lp_host_msdfs() && lp_msdfs_root(snum)) sh1005->dfs_root_flag = 3; #endif -- cgit From 9646e6e1ba5e44b3c4349e85e08ab9f73372a4d5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 26 May 2000 20:54:46 +0000 Subject: Compile time warning fixes and a time_t -> uint32 conversion fix. Jeremy. (This used to be commit 80a0079b2f993159ef35b02ba5c70ce9d8096879) --- source3/rpc_server/srv_spoolss_nt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index dc24c3bc31..7c56a5f640 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1,3 +1,4 @@ +#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -1634,6 +1635,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring counter_printer_0 *session_counter; uint32 global_counter; struct tm *t; + time_t setup_time; print_queue_struct *queue=NULL; print_status_struct status; @@ -1684,7 +1686,8 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring printer->total_jobs = 0; printer->total_bytes = 0; - t=gmtime(&ntprinter.info_2->setuptime); + t=gmtime(&setup_time); + ntprinter.info_2->setuptime = (uint32)setup_time; /* FIXME !! */ printer->year = t->tm_year+1900; printer->month = t->tm_mon+1; @@ -3754,7 +3757,7 @@ static uint32 modify_driver_heirarchy(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint pstring path_old; pstring path_new; pstring short_archi; - int snum = snum = find_service("print$"); + int snum = find_service("print$"); char *model = NULL; *short_archi = '\0'; @@ -4437,4 +4440,5 @@ uint32 _spoolss_getjob( POLICY_HND *handle, uint32 jobid, uint32 level, break; } } +#undef OLD_NTDOMAIN -- cgit From f3c44fba111392a7680e489330f3f69aedbff13d Mon Sep 17 00:00:00 2001 From: Shirish Kalele Date: Fri, 26 May 2000 22:37:08 +0000 Subject: Fixed memory leak in RPC parsing code. Problem in prs_set_buffer_size() was Realloc returns a NULL when newsize is zero (equivalent to a free()). We were returning a failure here without resetting the buffer_size or the data_p pointer in the prs_struct. And we weren't checking for a failure from prs_set_buffer_size(). So realloc's to zero size were not reflected in the prs_struct: memory leak. (This used to be commit 590d9ece8449b1feecfe1aa13e61bcd8fea4e5bf) --- source3/rpc_server/srv_pipe_hnd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index a349da839a..e01ecf82a2 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -480,7 +480,12 @@ authentication failed. Denying the request.\n", p->name)); * size as the current offset. */ - prs_set_buffer_size(&p->in_data.data, prs_offset(&p->in_data.data)); + if(!prs_set_buffer_size(&p->in_data.data, prs_offset(&p->in_data.data))) + { + DEBUG(0,("process_request_pdu: Call to prs_set_buffer_size failed!\n")); + set_incoming_fault(p); + return False; + } /* * Set the parse offset to the start of the data and set the -- cgit From a65dead017b3f52d7c2f753ce8ca876371183629 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sat, 27 May 2000 01:26:34 +0000 Subject: security descs in spoolss. needs parse_sec.c nttrans.c broken. (This used to be commit f9f2a04fdb7b2af1cfe5bf26ec6f0d955ea948b9) --- source3/rpc_server/srv_spoolss_nt.c | 80 ++++++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7c56a5f640..90a3a3e632 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -587,8 +587,8 @@ static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *u static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode) { - unistr_to_dos(nt_devmode->devicename, (char *)devmode.devicename.buffer, 31); - unistr_to_dos(nt_devmode->formname, (char *)devmode.formname.buffer, 31); + unistr_to_ascii(nt_devmode->devicename, (char *)devmode.devicename.buffer, 31); + unistr_to_ascii(nt_devmode->formname, (char *)devmode.formname.buffer, 31); nt_devmode->specversion=devmode.specversion; nt_devmode->driverversion=devmode.driverversion; @@ -1892,6 +1892,17 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer printer->devmode=devmode; + if (ntprinter.info_2->secdesc.len != 0) + { + /* steal the printer info sec_desc structure. [badly done]. */ + printer->secdesc = ntprinter.info_2->secdesc.sec; + ZERO_STRUCT(ntprinter.info_2->secdesc); + } + else + { + printer->secdesc = NULL; + } + safe_free(queue); free_a_printer(ntprinter, 2); return True; @@ -1903,6 +1914,31 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer return False; } +/******************************************************************** + * construct_printer_info_3 + * fill a printer_info_3 struct + ********************************************************************/ +static BOOL construct_printer_info_3(fstring servername, + PRINTER_INFO_3 *printer, int snum) +{ + NT_PRINTER_INFO_LEVEL ntprinter; + + if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) + return False; + + printer->flags = 4; /* no idea, yet. see MSDN. */ + if (ntprinter.info_2->secdesc.len != 0) + { + /* steal the printer info sec_desc structure. [badly done]. */ + printer->sec = *ntprinter.info_2->secdesc.sec; + safe_free(ntprinter.info_2->secdesc.sec); + ZERO_STRUCT(ntprinter.info_2->secdesc); + } + + free_a_printer(ntprinter, 2); + return True; +} + /******************************************************************** Spoolss_enumprinters. ********************************************************************/ @@ -2337,6 +2373,41 @@ static uint32 getprinter_level_2(fstring servername, int snum, NEW_BUFFER *buffe return NT_STATUS_NO_PROBLEMO; } +/**************************************************************************** +****************************************************************************/ +static uint32 getprinter_level_3(fstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + PRINTER_INFO_3 *printer=NULL; + fstring temp; + + if((printer=(PRINTER_INFO_3*)malloc(sizeof(PRINTER_INFO_3)))==NULL) + return ERROR_NOT_ENOUGH_MEMORY; + + fstrcpy(temp, "\\\\"); + fstrcat(temp, servername); + construct_printer_info_3(temp, printer, snum); + + /* check the required size. */ + *needed += spoolss_size_printer_info_3(printer); + + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(printer); + return ERROR_INSUFFICIENT_BUFFER; + } + + /* fill the buffer with the structures */ + new_smb_io_printer_info_3("", buffer, printer, 0); + + /* clear memory */ + free_sec_desc(&printer->sec); + + if (*needed > offered) { + return ERROR_INSUFFICIENT_BUFFER; + } + else + return NT_STATUS_NO_PROBLEMO; +} + /**************************************************************************** ****************************************************************************/ uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, @@ -2355,13 +2426,12 @@ uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, switch (level) { case 0: return getprinter_level_0(servername, snum, buffer, offered, needed); - break; case 1: return getprinter_level_1(servername,snum, buffer, offered, needed); - break; case 2: return getprinter_level_2(servername,snum, buffer, offered, needed); - break; + case 3: + return getprinter_level_3(servername,snum, buffer, offered, needed); default: return ERROR_INVALID_LEVEL; break; -- cgit From 682cccd8af4008b508328672009a5bfc1344f55d Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sat, 27 May 2000 02:05:15 +0000 Subject: unistr_to_dos not unistr_to_ascii (This used to be commit f46c4fe876a0cabe7044ca30c17e6c217d618635) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 90a3a3e632..f974311c71 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -587,8 +587,8 @@ static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *u static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode) { - unistr_to_ascii(nt_devmode->devicename, (char *)devmode.devicename.buffer, 31); - unistr_to_ascii(nt_devmode->formname, (char *)devmode.formname.buffer, 31); + unistr_to_dos(nt_devmode->devicename, (char *)devmode.devicename.buffer, 31); + unistr_to_dos(nt_devmode->formname, (char *)devmode.formname.buffer, 31); nt_devmode->specversion=devmode.specversion; nt_devmode->driverversion=devmode.driverversion; -- cgit From afab6492e1297737366573cdd9d1483320c30b3f Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sat, 27 May 2000 03:12:06 +0000 Subject: uninitialised variable "list" (This used to be commit bf33b10a43a42c3ec5dbfdc713869c4aeb452aef) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f974311c71..29294f1783 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3479,7 +3479,7 @@ uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32 uint32 *needed, uint32 *returned) { int i; - fstring *list; + fstring *list = NULL; fstring servername; fstring architecture; -- cgit From 5f7c40f6d02df70dd3a92d5658f79b668e0ed5df Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 27 May 2000 09:53:11 +0000 Subject: getting and setting security descriptors on printers now works this needed some fixes in tdb_unpack(). Tim, you'll need to update (This used to be commit 9422719ab4c35e4ce3199b62dd632433bf391283) --- source3/rpc_server/srv_spoolss.c | 10 ++-------- source3/rpc_server/srv_spoolss_nt.c | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 0f85ba8c80..0e6c456ec3 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -498,14 +498,8 @@ static BOOL api_spoolss_setprinter(prs_struct *data, prs_struct *rdata) } r_u.status = _spoolss_setprinter(&q_u.handle, q_u.level, &q_u.info, - q_u.devmode_ctr, q_u.command); - - /* now, we can free the memory */ - if (q_u.info.level==2 && q_u.info.info_ptr!=0) - safe_free(q_u.info.info_2); - - if (q_u.devmode_ctr.devmode_ptr!=0) - safe_free(q_u.devmode_ctr.devmode); + q_u.devmode_ctr, &q_u.secdesc_ctr, + q_u.command); if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n")); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 29294f1783..01535b2933 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2620,9 +2620,6 @@ static void construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); fill_printer_driver_info_3(info, driver, servername, architecture); - - free_a_printer_driver(driver, 3); - free_a_printer(printer, 2); } /**************************************************************************** @@ -2929,6 +2926,23 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command) return ERROR_INVALID_FUNCTION; } +/******************************************************************** + * called by spoolss_api_setprinter + * when updating a printer description + ********************************************************************/ +static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level, + const SPOOL_PRINTER_INFO_LEVEL *info, + const SEC_DESC_BUF *secdesc_ctr) +{ + Printer_entry *Printer = find_printer_index_by_hnd(handle); + + if (!OPEN_HANDLE(Printer)) + return ERROR_INVALID_HANDLE; + + return nt_printing_setsec(Printer->dev.printername, secdesc_ctr); +} + + /******************************************************************** * called by spoolss_api_setprinter * when updating a printer description @@ -3002,6 +3016,7 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, const DEVMODE_CTR devmode_ctr, + const SEC_DESC_BUF *secdesc_ctr, uint32 command) { Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -3017,6 +3032,9 @@ uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, case 2: return update_printer(handle, level, info, devmode_ctr.devmode); break; + case 3: + return update_printer_sec(handle, level, info, secdesc_ctr); + break; default: return ERROR_INVALID_LEVEL; break; -- cgit From b38aa95bc9becb89fa1b966c7d6ecd91e3d47a99 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 28 May 2000 21:01:14 +0000 Subject: moved notif_y_table struct to spoolss_nt.c only used there. #ifdef'd driver-code out with define RELIES_ON_SMBD_SPECIFIC_CODE because spoolssd doesn't link with smbd/*.c (find_service("print$") is not possible). (This used to be commit 726c359d1d9f1fc8227ca920c888d2f040170e0b) --- source3/rpc_server/srv_spoolss_nt.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 01535b2933..ba122e04f8 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -25,6 +25,8 @@ #include "includes.h" +#define RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD + extern int DEBUGLEVEL; extern pstring global_myname; @@ -168,7 +170,7 @@ static Printer_entry *find_printer_index_by_hnd(const POLICY_HND *hnd) ****************************************************************************/ static void clear_handle(POLICY_HND *hnd) { - memset(hnd->data, 0, POLICY_HND_SIZE); + ZERO_STRUCTP(hnd); } /**************************************************************************** @@ -1198,6 +1200,17 @@ static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, #define END 65535 +struct s_notify_info_data_table +{ + uint16 type; + uint16 field; + char *name; + uint32 size; + void (*fn) (int snum, SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer); +}; + struct s_notify_info_data_table notify_info_data_table[] = { { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", POINTER, spoolss_notify_server_name }, @@ -3840,11 +3853,13 @@ uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level, Modify internal driver heirarchy. ****************************************************************************/ +#if RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD static uint32 modify_driver_heirarchy(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32 level) { pstring path_old; pstring path_new; pstring short_archi; + /* find_service is an smbd-specific function call */ int snum = find_service("print$"); char *model = NULL; @@ -3878,6 +3893,7 @@ static uint32 modify_driver_heirarchy(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint return NT_STATUS_NO_PROBLEMO; } +#endif /**************************************************************************** ****************************************************************************/ @@ -3894,11 +3910,13 @@ uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name, if (add_a_printer_driver(driver, level)!=0) return ERROR_ACCESS_DENIED; +#if RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD if ((err = modify_driver_heirarchy(&driver, level)) != 0) { safe_free(driver.info_3); safe_free(driver.info_6); return err; } +#endif safe_free(driver.info_3); safe_free(driver.info_6); @@ -3928,8 +3946,13 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); get_short_archi(short_archi, long_archi); +#if RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s\\TMP_%u", global_myname, short_archi, (unsigned int)sys_getpid()); +#else + slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", + global_myname, short_archi); +#endif DEBUG(4,("printer driver directory: [%s]\n", path)); fill_driverdir_1(info, path); -- cgit From 4a0635cd6df183b0093a672616065fb44cdd2e0c Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 28 May 2000 21:21:07 +0000 Subject: #ifdef not #if (This used to be commit f0229102fe337213cd53fcb0a3d7e2ba786470b9) --- source3/rpc_server/srv_spoolss_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ba122e04f8..25d8f63aef 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3853,7 +3853,7 @@ uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level, Modify internal driver heirarchy. ****************************************************************************/ -#if RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD +#ifdef RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD static uint32 modify_driver_heirarchy(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32 level) { pstring path_old; @@ -3910,7 +3910,7 @@ uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name, if (add_a_printer_driver(driver, level)!=0) return ERROR_ACCESS_DENIED; -#if RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD +#ifdef RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD if ((err = modify_driver_heirarchy(&driver, level)) != 0) { safe_free(driver.info_3); safe_free(driver.info_6); @@ -3946,7 +3946,7 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); get_short_archi(short_archi, long_archi); -#if RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD +#ifdef RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s\\TMP_%u", global_myname, short_archi, (unsigned int)sys_getpid()); #else -- cgit From 0c396eef79b83d7ecb99b63d5b6592f60ed9c276 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 28 May 2000 22:59:13 +0000 Subject: fixed return error code that had 0xC with not enough zeros (This used to be commit d859de2870d6524f4ff58a059469fe65c1b37940) --- source3/rpc_server/srv_reg.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index cba24d7dfb..ea7f3ecd5d 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -129,12 +129,12 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, if (status == 0 && find_lsa_policy_by_hnd(&(q_u->pol)) == -1) { - status = 0xC000000 | NT_STATUS_INVALID_HANDLE; + status = NT_STATUS_INVALID_HANDLE; } if (status == 0x0 && !open_lsa_policy_hnd(&pol)) { - status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ + status = NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } fstrcpy(name, dos_unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len)); @@ -145,13 +145,13 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, /* lkcl XXXX do a check on the name, here */ if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions")) { - status = 0xC000000 | NT_STATUS_ACCESS_DENIED; + status = NT_STATUS_ACCESS_DENIED; } } if (status == 0x0 && !set_lsa_policy_reg_name(&pol, name)) { - status = 0xC000000 | NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ + status = NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ } init_reg_r_open_entry(&r_u, &pol, status); @@ -198,7 +198,7 @@ static void reg_reply_info(REG_Q_INFO *q_u, if (status == 0 && find_lsa_policy_by_hnd(&(q_u->pol)) == -1) { - status = 0xC000000 | NT_STATUS_INVALID_HANDLE; + status = NT_STATUS_INVALID_HANDLE; } /* This makes the server look like a member server to clients */ -- cgit From 38b32fb97f5a91f09a6e41b6c14aafb510bbbe6a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 28 May 2000 23:00:23 +0000 Subject: don't free a driver structure from the stack! (This used to be commit d241f1dcaf612881a428dd578b97383d02a4d3c3) --- source3/rpc_server/srv_spoolss_nt.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 25d8f63aef..fbf5bc88bf 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3406,19 +3406,21 @@ static uint32 enumprinterdrivers_level1(fstring *list, fstring servername, fstri static uint32 enumprinterdrivers_level2(fstring *list, fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; - NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_2 *driver_info_2=NULL; - ZERO_STRUCT(driver); - if (*returned > 0 && !(driver_info_2=(DRIVER_INFO_2 *)malloc(*returned * sizeof(DRIVER_INFO_2)))) return ERROR_NOT_ENOUGH_MEMORY; for (i=0; i<*returned; i++) { - get_a_printer_driver(&driver, 3, list[i], architecture); + NT_PRINTER_DRIVER_INFO_LEVEL driver; + ZERO_STRUCT(driver); + if (get_a_printer_driver(&driver, 3, list[i], architecture) + != 0) { + *returned = i; + break; + } fill_printer_driver_info_2(&(driver_info_2[i]), driver, servername, architecture ); - free_a_printer_driver(driver, 3); } safe_free(list); -- cgit From 140523dc46786bff24d9940728baacfa3a359b80 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Sun, 28 May 2000 23:34:34 +0000 Subject: lp_server_role() + use in srv_reg. (This used to be commit 82e47e268ca33dd7e692c5e6d0571428307b5287) --- source3/rpc_server/srv_reg.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index ea7f3ecd5d..ca3911121f 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -186,7 +186,7 @@ static void reg_reply_info(REG_Q_INFO *q_u, prs_struct *rdata) { uint32 status = 0; - fstring key = "ServerNT"; /* always a non-PDC */ + char *key; uint32 type=0x1; /* key type: REG_SZ */ UNISTR2 uni_key; @@ -201,6 +201,25 @@ static void reg_reply_info(REG_Q_INFO *q_u, status = NT_STATUS_INVALID_HANDLE; } + switch (lp_server_role()) + { + case ROLE_DOMAIN_PDC: + case ROLE_DOMAIN_BDC: + { + key = "LanmanNT"; + break; + } + case ROLE_STANDALONE: + { + key = "ServerNT"; + break; + } + case ROLE_DOMAIN_MEMBER: + { + key = "WinNT"; + break; + } + } /* This makes the server look like a member server to clients */ /* which tells clients that we have our own local user and */ /* group databases and helps with ACL support. */ -- cgit From 5b5f41d8e0e707bb4e1626f4406b2e46305a5183 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 29 May 2000 01:09:14 +0000 Subject: fixed some more crashes this introduces some memory leaks that I need to fix later (This used to be commit 2170d72d508ab8fb63a1da3024395f8fd6011cfa) --- source3/rpc_server/srv_spoolss_nt.c | 130 ++++++++++++------------------------ 1 file changed, 44 insertions(+), 86 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index fbf5bc88bf..f817300734 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -380,12 +380,10 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) printer.info_2->printername, aprinter )); if ( strlen(printer.info_2->printername) != strlen(aprinter) ) { - free_a_printer(printer, 2); continue; } if ( strncasecmp(printer.info_2->printername, aprinter, strlen(aprinter))) { - free_a_printer(printer, 2); continue; } @@ -420,12 +418,10 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) printer.info_2->printername, aprinter )); if ( strlen(lp_servicename(snum)) != strlen(aprinter) ) { - free_a_printer(printer, 2); continue; } if ( strncasecmp(lp_servicename(snum), aprinter, strlen(aprinter))) { - free_a_printer(printer, 2); continue; } @@ -442,7 +438,6 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) DEBUGADD(4,("Printer found: %s -> %s[%x]\n",printer.info_2->printername, lp_servicename(snum),snum)); ZERO_STRUCT(Printer->dev.printername); strncpy(Printer->dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); - free_a_printer(printer, 2); return True; } @@ -772,14 +767,12 @@ static BOOL getprinterdata_printer(const POLICY_HND *handle, return False; if (!get_specific_param(printer, 2, value, &idata, type, &len)) { - free_a_printer(printer, 2); return False; } DEBUG(5,("getprinterdata_printer:allocating %d\n", in_size)); if((*data = (uint8 *)malloc( in_size *sizeof(uint8) )) == NULL) { - free_a_printer(printer, 2); return False; } @@ -791,7 +784,6 @@ static BOOL getprinterdata_printer(const POLICY_HND *handle, DEBUG(5,("getprinterdata_printer:copy done\n")); - free_a_printer(printer, 2); safe_free(idata); return True; @@ -1384,7 +1376,6 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO continue; if((info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) { - free_a_printer(printer, 2); return False; } current_data=&(info->data[info->count]); @@ -1395,7 +1386,6 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO info->count++; } - free_a_printer(printer, 2); return True; } @@ -1434,7 +1424,6 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I continue; if((info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) { - free_a_printer(printer, 2); return False; } @@ -1445,8 +1434,6 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I info->count++; } - free_a_printer(printer, 2); - return True; } @@ -1741,7 +1728,6 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring safe_free(queue); - free_a_printer(ntprinter, 2); return (True); } @@ -1769,8 +1755,6 @@ static BOOL construct_printer_info_1(fstring server, uint32 flags, PRINTER_INFO_ init_unistr(&printer->name, chaine2); init_unistr(&printer->comment, lp_comment(snum)); - free_a_printer(ntprinter, 2); - return True; } @@ -1781,7 +1765,7 @@ static BOOL construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) char adevice[32]; char aform[32]; NT_PRINTER_INFO_LEVEL printer; - NT_DEVICEMODE *ntdevmode; + NT_DEVICEMODE ntdevmode; DEBUG(7,("construct_dev_mode\n")); @@ -1791,51 +1775,52 @@ static BOOL construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) DEBUGADD(8,("getting printer characteristics\n")); get_a_printer(&printer, 2, lp_servicename(snum)); - ntdevmode=(printer.info_2)->devmode; + if (printer.info_2->devmode) { + ntdevmode = *printer.info_2->devmode; + } else { + init_devicemode(&ntdevmode); + } DEBUGADD(8,("loading DEVICEMODE\n")); snprintf(adevice, sizeof(adevice), "\\\\%s\\%s", global_myname, printer.info_2->printername); init_unistr(&(devmode->devicename), adevice); - snprintf(aform, sizeof(aform), ntdevmode->formname); + snprintf(aform, sizeof(aform), ntdevmode.formname); init_unistr(&(devmode->formname), aform); - devmode->specversion = ntdevmode->specversion; - devmode->driverversion = ntdevmode->driverversion; - devmode->size = ntdevmode->size; - devmode->driverextra = ntdevmode->driverextra; - devmode->fields = ntdevmode->fields; + devmode->specversion = ntdevmode.specversion; + devmode->driverversion = ntdevmode.driverversion; + devmode->size = ntdevmode.size; + devmode->driverextra = ntdevmode.driverextra; + devmode->fields = ntdevmode.fields; - devmode->orientation = ntdevmode->orientation; - devmode->papersize = ntdevmode->papersize; - devmode->paperlength = ntdevmode->paperlength; - devmode->paperwidth = ntdevmode->paperwidth; - devmode->scale = ntdevmode->scale; - devmode->copies = ntdevmode->copies; - devmode->defaultsource = ntdevmode->defaultsource; - devmode->printquality = ntdevmode->printquality; - devmode->color = ntdevmode->color; - devmode->duplex = ntdevmode->duplex; - devmode->yresolution = ntdevmode->yresolution; - devmode->ttoption = ntdevmode->ttoption; - devmode->collate = ntdevmode->collate; - devmode->icmmethod = ntdevmode->icmmethod; - devmode->icmintent = ntdevmode->icmintent; - devmode->mediatype = ntdevmode->mediatype; - devmode->dithertype = ntdevmode->dithertype; - - if (ntdevmode->private != NULL) + devmode->orientation = ntdevmode.orientation; + devmode->papersize = ntdevmode.papersize; + devmode->paperlength = ntdevmode.paperlength; + devmode->paperwidth = ntdevmode.paperwidth; + devmode->scale = ntdevmode.scale; + devmode->copies = ntdevmode.copies; + devmode->defaultsource = ntdevmode.defaultsource; + devmode->printquality = ntdevmode.printquality; + devmode->color = ntdevmode.color; + devmode->duplex = ntdevmode.duplex; + devmode->yresolution = ntdevmode.yresolution; + devmode->ttoption = ntdevmode.ttoption; + devmode->collate = ntdevmode.collate; + devmode->icmmethod = ntdevmode.icmmethod; + devmode->icmintent = ntdevmode.icmintent; + devmode->mediatype = ntdevmode.mediatype; + devmode->dithertype = ntdevmode.dithertype; + + if (ntdevmode.private != NULL) { if((devmode->private=(uint8 *)malloc(devmode->driverextra*sizeof(uint8))) == NULL) { - free_a_printer(printer, 2); return False; } - memcpy(devmode->private, ntdevmode->private, devmode->driverextra); + memcpy(devmode->private, ntdevmode.private, devmode->driverextra); } - free_a_printer(printer, 2); - return True; } @@ -1917,13 +1902,11 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer } safe_free(queue); - free_a_printer(ntprinter, 2); return True; err: safe_free(queue); - free_a_printer(ntprinter, 2); return False; } @@ -1948,7 +1931,6 @@ static BOOL construct_printer_info_3(fstring servername, ZERO_STRUCT(ntprinter.info_2->secdesc); } - free_a_printer(ntprinter, 2); return True; } @@ -2475,9 +2457,6 @@ static void construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); fill_printer_driver_info_1(info, driver, servername, architecture); - - free_a_printer_driver(driver, 3); - free_a_printer(printer, 2); } /******************************************************************** @@ -2532,9 +2511,6 @@ static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstri get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); fill_printer_driver_info_2(info, driver, servername, architecture); - - free_a_printer_driver(driver, 3); - free_a_printer(printer, 2); } /******************************************************************** @@ -2554,6 +2530,7 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *whe while (1) { v = char_array[i]; + if (!v) v = ""; /* hack to handle null lists */ snprintf(line, sizeof(line)-1, "%s%s", where, v); DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); if((*uni_array=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL) { @@ -2945,7 +2922,7 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command) ********************************************************************/ static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, - const SEC_DESC_BUF *secdesc_ctr) + SEC_DESC_BUF *secdesc_ctr) { Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -2966,10 +2943,8 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, { int snum; NT_PRINTER_INFO_LEVEL printer; - NT_DEVICEMODE *nt_devmode; + NT_DEVICEMODE nt_devmode; Printer_entry *Printer = find_printer_index_by_hnd(handle); - - nt_devmode=NULL; DEBUG(8,("update_printer\n")); @@ -2994,17 +2969,14 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, /* we have a valid devmode convert it and link it*/ - /* the nt_devmode memory is already alloced - * while doing the get_a_printer call - * but the devmode private part is not - * it's done by convert_devicemode - */ DEBUGADD(8,("Converting the devicemode struct\n")); - nt_devmode=printer.info_2->devmode; - - init_devicemode(nt_devmode); + if (printer.info_2->devmode) { + nt_devmode = *printer.info_2->devmode; + } else { + init_devicemode(&nt_devmode); + } - convert_devicemode(*devmode, nt_devmode); + convert_devicemode(*devmode, &nt_devmode); } else { if (printer.info_2->devmode != NULL) @@ -3013,14 +2985,10 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, } if (add_a_printer(printer, 2)!=0) { - free_a_printer(printer, 2); - /* I don't really know what to return here !!! */ return ERROR_ACCESS_DENIED; } - free_a_printer(printer, 2); - return NT_STATUS_NO_PROBLEMO; } @@ -3157,18 +3125,15 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, job_info->pagesprinted=0; if((devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL) { - free_a_printer(ntprinter, 2); return False; } ZERO_STRUCTP(devmode); if(!construct_dev_mode(devmode, snum, global_myname)) { - free_a_printer(ntprinter, 2); return False; } job_info->devmode=devmode; - free_a_printer(ntprinter, 2); return (True); } @@ -3368,7 +3333,6 @@ static uint32 enumprinterdrivers_level1(fstring *list, fstring servername, fstri for (i=0; i<*returned; i++) { get_a_printer_driver(&driver, 3, list[i], architecture); fill_printer_driver_info_1(&(driver_info_1[i]), driver, servername, architecture ); - free_a_printer_driver(driver, 3); } safe_free(list); @@ -3469,7 +3433,6 @@ static uint32 enumprinterdrivers_level3(fstring *list, fstring servername, fstri for (i=0; i<*returned; i++) { get_a_printer_driver(&driver, 3, list[i], architecture); fill_printer_driver_info_3(&(driver_info_3[i]), driver, servername, architecture ); - free_a_printer_driver(driver, 3); } safe_free(list); @@ -3579,9 +3542,11 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, *numofforms = get_ntforms(&list); DEBUGADD(5,("Number of forms [%d]\n", *numofforms)); + if (*numofforms == 0) return ERROR_NO_MORE_ITEMS; + switch (level) { case 1: - if((forms_1=(FORM_1 *)malloc(*numofforms * sizeof(FORM_1))) == NULL) { + if ((forms_1=(FORM_1 *)malloc(*numofforms * sizeof(FORM_1))) == NULL) { *numofforms=0; return ERROR_NOT_ENOUGH_MEMORY; } @@ -4068,7 +4033,6 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, DEBUG(6,("final values: [%d], [%d]\n", *out_value_len, *out_data_len)); - free_a_printer(printer, 2); return NT_STATUS_NO_PROBLEMO; } @@ -4078,7 +4042,6 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, */ if (!get_specific_param_by_index(printer, 2, idx, value, &data, &type, &data_len)) { - free_a_printer(printer, 2); safe_free(data); return ERROR_NO_MORE_ITEMS; } @@ -4094,7 +4057,6 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, *out_max_value_len=in_value_len; if((*out_value=(uint16 *)malloc(in_value_len*sizeof(uint8))) == NULL) { - free_a_printer(printer, 2); safe_free(data); return ERROR_NOT_ENOUGH_MEMORY; } @@ -4106,7 +4068,6 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, /* the data is counted in bytes */ *out_max_data_len=in_data_len; if((*data_out=(uint8 *)malloc(in_data_len*sizeof(uint8))) == NULL) { - free_a_printer(printer, 2); safe_free(data); return ERROR_NOT_ENOUGH_MEMORY; } @@ -4115,7 +4076,6 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, safe_free(data); - free_a_printer(printer, 2); return NT_STATUS_NO_PROBLEMO; } @@ -4157,8 +4117,6 @@ uint32 _spoolss_setprinterdata( const POLICY_HND *handle, else status = add_a_printer(printer, 2); - free_a_printer(printer, 2); - return status; } -- cgit From badb7fc0d21267110e39287c897c0f956f43bb16 Mon Sep 17 00:00:00 2001 From: Matthew Chapman Date: Mon, 29 May 2000 01:23:48 +0000 Subject: Fixed LsaQueryInformationPolicy level 3 to return primary domain info. Domain SID is saved in secrets.tdb upon joining domain. Added "Authenticated Users" and "SYSTEM" well-known SIDs (under NT Authority). (This used to be commit 7710b4f48d3e8532df5e37f99a779758f750efdb) --- source3/rpc_server/srv_lsa.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index e7d08ff788..71162ac782 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -88,24 +88,18 @@ Init dom_query static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) { - fstring sid_str; - int domlen = strlen(dom_name); - - *sid_str = '\0'; + int domlen = (dom_name != NULL) ? strlen(dom_name) : 0; d_q->uni_dom_max_len = domlen * 2; d_q->uni_dom_str_len = domlen * 2; - d_q->buffer_dom_name = domlen != 0 ? 1 : 0; /* domain buffer pointer */ - d_q->buffer_dom_sid = dom_sid != NULL ? 1 : 0; /* domain sid pointer */ + d_q->buffer_dom_name = (dom_name != 0) ? 1 : 0; + d_q->buffer_dom_sid = (dom_sid != NULL) ? 1 : 0; /* this string is supposed to be character short */ init_unistr2(&d_q->uni_domain_name, dom_name, domlen); - - if(dom_sid) { - sid_to_string(sid_str, dom_sid); + if (dom_sid != NULL) init_dom_sid2(&d_q->dom_sid, dom_sid); - } } /*************************************************************************** @@ -506,12 +500,11 @@ api_lsa_query_info static BOOL api_lsa_query_info(prs_struct *data, prs_struct *rdata) { LSA_Q_QUERY_INFO q_i; - fstring name; + DOM_SID domain_sid; + char *name = NULL; DOM_SID *sid = NULL; uint32 status_code = 0; - memset(name, 0, sizeof(name)); - ZERO_STRUCT(q_i); /* grab the info class and policy handle */ @@ -522,15 +515,26 @@ static BOOL api_lsa_query_info(prs_struct *data, prs_struct *rdata) switch (q_i.info_class) { case 0x03: - if(lp_domain_logons()) { - fstrcpy(name, global_myworkgroup); - sid = &global_sam_sid; - } else { - *name = '\0'; + switch (lp_server_role()) + { + case ROLE_DOMAIN_PDC: + case ROLE_DOMAIN_BDC: + name = global_myworkgroup; + sid = &global_sam_sid; + break; + case ROLE_DOMAIN_MEMBER: + if (secrets_fetch_domain_sid(global_myworkgroup, + &domain_sid)) + { + name = global_myworkgroup; + sid = &domain_sid; + } + default: + break; } break; case 0x05: - fstrcpy(name, global_myname); + name = global_myname; sid = &global_sam_sid; break; default: -- cgit From cc22d7ea29f0ccb2256a58510600e1f73d69bb6a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Jun 2000 02:35:30 +0000 Subject: Changes I really don't want to lose whilst CVS is playing up. Dynamic changes to spoolss code. Jeremy. (This used to be commit 0a5e7a8f31c26fe80db5398a441a1969a8882845) --- source3/rpc_server/srv_spoolss_nt.c | 479 +++++++++++++++++++----------------- 1 file changed, 257 insertions(+), 222 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f817300734..424e1f5e95 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -331,7 +331,7 @@ static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername) static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) { Printer_entry *Printer = find_printer_index_by_hnd(hnd); - NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_INFO_LEVEL *printer = NULL; int snum; int n_services=lp_numservices(); char *aprinter; @@ -377,13 +377,15 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) continue; DEBUG(10,("set_printer_hnd_printername: printername [%s], aprinter [%s]\n", - printer.info_2->printername, aprinter )); + printer->info_2->printername, aprinter )); - if ( strlen(printer.info_2->printername) != strlen(aprinter) ) { + if ( strlen(printer->info_2->printername) != strlen(aprinter) ) { + free_a_printer(&printer, 2); continue; } - if ( strncasecmp(printer.info_2->printername, aprinter, strlen(aprinter))) { + if ( strncasecmp(printer->info_2->printername, aprinter, strlen(aprinter))) { + free_a_printer(&printer, 2); continue; } @@ -415,13 +417,15 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) continue; DEBUG(10,("set_printer_hnd_printername: printername [%s], aprinter [%s]\n", - printer.info_2->printername, aprinter )); + printer->info_2->printername, aprinter )); if ( strlen(lp_servicename(snum)) != strlen(aprinter) ) { + free_a_printer(&printer, 2); continue; } if ( strncasecmp(lp_servicename(snum), aprinter, strlen(aprinter))) { + free_a_printer(&printer, 2); continue; } @@ -435,10 +439,12 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) } snum--; - DEBUGADD(4,("Printer found: %s -> %s[%x]\n",printer.info_2->printername, lp_servicename(snum),snum)); + DEBUGADD(4,("Printer found: %s -> %s[%x]\n",printer->info_2->printername, lp_servicename(snum),snum)); ZERO_STRUCT(Printer->dev.printername); strncpy(Printer->dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); + free_a_printer(&printer, 2); + return True; } @@ -582,53 +588,51 @@ static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *u return True; } -static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode) -{ - unistr_to_dos(nt_devmode->devicename, (char *)devmode.devicename.buffer, 31); - unistr_to_dos(nt_devmode->formname, (char *)devmode.formname.buffer, 31); - - nt_devmode->specversion=devmode.specversion; - nt_devmode->driverversion=devmode.driverversion; - nt_devmode->size=devmode.size; - nt_devmode->driverextra=devmode.driverextra; - nt_devmode->fields=devmode.fields; - nt_devmode->orientation=devmode.orientation; - nt_devmode->papersize=devmode.papersize; - nt_devmode->paperlength=devmode.paperlength; - nt_devmode->paperwidth=devmode.paperwidth; - nt_devmode->scale=devmode.scale; - nt_devmode->copies=devmode.copies; - nt_devmode->defaultsource=devmode.defaultsource; - nt_devmode->printquality=devmode.printquality; - nt_devmode->color=devmode.color; - nt_devmode->duplex=devmode.duplex; - nt_devmode->yresolution=devmode.yresolution; - nt_devmode->ttoption=devmode.ttoption; - nt_devmode->collate=devmode.collate; - - nt_devmode->logpixels=devmode.logpixels; - nt_devmode->bitsperpel=devmode.bitsperpel; - nt_devmode->pelswidth=devmode.pelswidth; - nt_devmode->pelsheight=devmode.pelsheight; - nt_devmode->displayflags=devmode.displayflags; - nt_devmode->displayfrequency=devmode.displayfrequency; - nt_devmode->icmmethod=devmode.icmmethod; - nt_devmode->icmintent=devmode.icmintent; - nt_devmode->mediatype=devmode.mediatype; - nt_devmode->dithertype=devmode.dithertype; - nt_devmode->reserved1=devmode.reserved1; - nt_devmode->reserved2=devmode.reserved2; - nt_devmode->panningwidth=devmode.panningwidth; - nt_devmode->panningheight=devmode.panningheight; - - if (nt_devmode->driverextra != 0) - { +static BOOL convert_devicemode(const DEVICEMODE *devmode, NT_DEVICEMODE *nt_devmode) +{ + unistr_to_dos(nt_devmode->devicename, (const char *)devmode->devicename.buffer, 31); + unistr_to_dos(nt_devmode->formname, (const char *)devmode->formname.buffer, 31); + + nt_devmode->specversion=devmode->specversion; + nt_devmode->driverversion=devmode->driverversion; + nt_devmode->size=devmode->size; + nt_devmode->driverextra=devmode->driverextra; + nt_devmode->fields=devmode->fields; + nt_devmode->orientation=devmode->orientation; + nt_devmode->papersize=devmode->papersize; + nt_devmode->paperlength=devmode->paperlength; + nt_devmode->paperwidth=devmode->paperwidth; + nt_devmode->scale=devmode->scale; + nt_devmode->copies=devmode->copies; + nt_devmode->defaultsource=devmode->defaultsource; + nt_devmode->printquality=devmode->printquality; + nt_devmode->color=devmode->color; + nt_devmode->duplex=devmode->duplex; + nt_devmode->yresolution=devmode->yresolution; + nt_devmode->ttoption=devmode->ttoption; + nt_devmode->collate=devmode->collate; + + nt_devmode->logpixels=devmode->logpixels; + nt_devmode->bitsperpel=devmode->bitsperpel; + nt_devmode->pelswidth=devmode->pelswidth; + nt_devmode->pelsheight=devmode->pelsheight; + nt_devmode->displayflags=devmode->displayflags; + nt_devmode->displayfrequency=devmode->displayfrequency; + nt_devmode->icmmethod=devmode->icmmethod; + nt_devmode->icmintent=devmode->icmintent; + nt_devmode->mediatype=devmode->mediatype; + nt_devmode->dithertype=devmode->dithertype; + nt_devmode->reserved1=devmode->reserved1; + nt_devmode->reserved2=devmode->reserved2; + nt_devmode->panningwidth=devmode->panningwidth; + nt_devmode->panningheight=devmode->panningheight; + + if (nt_devmode->driverextra != 0) { /* if we had a previous private delete it and make a new one */ - if (nt_devmode->private != NULL) - free(nt_devmode->private); + safe_free(nt_devmode->private); if((nt_devmode->private=(uint8 *)malloc(nt_devmode->driverextra * sizeof(uint8))) == NULL) return False; - memcpy(nt_devmode->private, devmode.private, nt_devmode->driverextra); + memcpy(nt_devmode->private, devmode->private, nt_devmode->driverextra); } return True; @@ -665,8 +669,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d DEBUG(8,("getprinterdata_printer_server:%s\n", value)); - if (!strcmp(value, "BeepEnabled")) - { + if (!strcmp(value, "BeepEnabled")) { *type = 0x4; if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL) return False; @@ -675,8 +678,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d return True; } - if (!strcmp(value, "EventLog")) - { + if (!strcmp(value, "EventLog")) { *type = 0x4; if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL) return False; @@ -685,8 +687,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d return True; } - if (!strcmp(value, "NetPopup")) - { + if (!strcmp(value, "NetPopup")) { *type = 0x4; if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL) return False; @@ -695,8 +696,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d return True; } - if (!strcmp(value, "MajorVersion")) - { + if (!strcmp(value, "MajorVersion")) { *type = 0x4; if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL) return False; @@ -705,8 +705,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d return True; } - if (!strcmp(value, "DefaultSpoolDirectory")) - { + if (!strcmp(value, "DefaultSpoolDirectory")) { pstring string="You are using a Samba server"; *type = 0x1; *needed = 2*(strlen(string)+1); @@ -715,24 +714,21 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d memset(*data, 0, (*needed > in_size) ? *needed:in_size); /* it's done by hand ready to go on the wire */ - for (i=0; i in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) return False; memset(*data, 0, (*needed > in_size) ? *needed:in_size); - for (i=0; inotify_data.data.length=strlen(lp_servicename(snum)); @@ -1351,7 +1352,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO uint16 field; SPOOL_NOTIFY_INFO_DATA *current_data; - NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_INFO_LEVEL *printer = NULL; print_queue_struct *queue=NULL; DEBUG(4,("construct_notify_printer_info\n")); @@ -1363,9 +1364,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO option_type->count, lp_servicename(snum))); if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) - { return False; - } for(field_num=0; field_numcount; field_num++) { @@ -1381,11 +1380,12 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO current_data=&(info->data[info->count]); construct_info_data(current_data, type, field, id); - notify_info_data_table[j].fn(snum, current_data, queue, &printer); + notify_info_data_table[j].fn(snum, current_data, queue, printer); info->count++; } + free_a_printer(&printer, 2); return True; } @@ -1401,7 +1401,7 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I uint16 field; SPOOL_NOTIFY_INFO_DATA *current_data; - NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_INFO_LEVEL *printer = NULL; DEBUG(4,("construct_notify_jobs_info\n")); @@ -1412,12 +1412,9 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I option_type->count)); if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) - { return False; - } - for(field_num=0; field_numcount; field_num++) - { + for(field_num=0; field_numcount; field_num++) { field = option_type->fields[field_num]; if (!search_notify(type, field, &j) ) @@ -1430,10 +1427,11 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I current_data=&(info->data[info->count]); construct_info_data(current_data, type, field, id); - notify_info_data_table[j].fn(snum, current_data, queue, &printer); + notify_info_data_table[j].fn(snum, current_data, queue, printer); info->count++; } - + + free_a_printer(&printer, 2); return True; } @@ -1631,7 +1629,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring { pstring chaine; int count; - NT_PRINTER_INFO_LEVEL ntprinter; + NT_PRINTER_INFO_LEVEL *ntprinter = NULL; counter_printer_0 *session_counter; uint32 global_counter; struct tm *t; @@ -1657,8 +1655,10 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring /* it's the first time, add it to the list */ if (session_counter==NULL) { - if((session_counter=(counter_printer_0 *)malloc(sizeof(counter_printer_0))) == NULL) + if((session_counter=(counter_printer_0 *)malloc(sizeof(counter_printer_0))) == NULL) { + free_a_printer(&ntprinter, 2); return False; + } ZERO_STRUCTP(session_counter); session_counter->snum=snum; session_counter->counter=0; @@ -1675,7 +1675,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring global_counter=session_counter->counter; /* the description and the name are of the form \\server\share */ - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s",servername, ntprinter.info_2->printername); + slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s",servername, ntprinter->info_2->printername); init_unistr(&(printer->printername), chaine); @@ -1687,7 +1687,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring printer->total_bytes = 0; t=gmtime(&setup_time); - ntprinter.info_2->setuptime = (uint32)setup_time; /* FIXME !! */ + ntprinter->info_2->setuptime = (uint32)setup_time; /* FIXME !! */ printer->year = t->tm_year+1900; printer->month = t->tm_mon+1; @@ -1712,11 +1712,11 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring printer->unknown14 = 0x1; printer->unknown15 = 0x024a; /* 586 Pentium ? */ printer->unknown16 = 0x0; - printer->change_id = ntprinter.info_2->changeid; /* ChangeID in milliseconds*/ + printer->change_id = ntprinter->info_2->changeid; /* ChangeID in milliseconds*/ printer->unknown18 = 0x0; printer->status = nt_printq_status(status.status); printer->unknown20 = 0x0; - printer->c_setprinter = ntprinter.info_2->c_setprinter; /* how many times setprinter has been called */ + printer->c_setprinter = ntprinter->info_2->c_setprinter; /* how many times setprinter has been called */ printer->unknown22 = 0x0; printer->unknown23 = 0x6; /* 6 ???*/ printer->unknown24 = 0; /* unknown 24 to 26 are always 0 */ @@ -1727,7 +1727,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring printer->unknown29 = 0; safe_free(queue); - + free_a_printer(&ntprinter,2); return (True); } @@ -1739,103 +1739,138 @@ static BOOL construct_printer_info_1(fstring server, uint32 flags, PRINTER_INFO_ { pstring chaine; pstring chaine2; - NT_PRINTER_INFO_LEVEL ntprinter; + NT_PRINTER_INFO_LEVEL *ntprinter = NULL; if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0) return False; printer->flags=flags; - snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",server, ntprinter.info_2->printername, - ntprinter.info_2->drivername, lp_comment(snum)); + snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",server, ntprinter->info_2->printername, + ntprinter->info_2->drivername, lp_comment(snum)); - snprintf(chaine2,sizeof(chaine)-1,"%s%s", server, ntprinter.info_2->printername); + snprintf(chaine2,sizeof(chaine)-1,"%s%s", server, ntprinter->info_2->printername); init_unistr(&printer->description, chaine); init_unistr(&printer->name, chaine2); init_unistr(&printer->comment, lp_comment(snum)); + free_a_printer(&ntprinter,2); + return True; } /**************************************************************************** + Free a DEVMODE struct. +****************************************************************************/ + +static void free_dev_mode(DEVICEMODE *dev) +{ + if (dev == NULL) + return; + + if (dev->private) + safe_free(dev->private); + + safe_free(dev); +} + +/**************************************************************************** + Create a DEVMODE struct. Returns malloced memory. ****************************************************************************/ -static BOOL construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername) + +static DEVICEMODE *construct_dev_mode(int snum, char *servername) { char adevice[32]; char aform[32]; - NT_PRINTER_INFO_LEVEL printer; - NT_DEVICEMODE ntdevmode; + NT_PRINTER_INFO_LEVEL *printer = NULL; + NT_DEVICEMODE *ntdevmode = NULL; + DEVICEMODE *devmode = NULL; DEBUG(7,("construct_dev_mode\n")); - memset(&(devmode->devicename), 0, 2*sizeof(adevice)); - memset(&(devmode->formname), 0, 2*sizeof(aform)); - DEBUGADD(8,("getting printer characteristics\n")); - get_a_printer(&printer, 2, lp_servicename(snum)); - if (printer.info_2->devmode) { - ntdevmode = *printer.info_2->devmode; - } else { - init_devicemode(&ntdevmode); + if ((devmode = (DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL) { + DEBUG(0,("construct_dev_mode: malloc fail.\n")); + return NULL; } + ZERO_STRUCTP(devmode); + + if(get_a_printer(&printer, 2, lp_servicename(snum)) != 0) + goto fail; + + if (printer->info_2->devmode) + ntdevmode = dup_nt_devicemode(printer->info_2->devmode); + else + ntdevmode = construct_nt_devicemode(); + + if (ntdevmode == NULL) + goto fail; + DEBUGADD(8,("loading DEVICEMODE\n")); snprintf(adevice, sizeof(adevice), "\\\\%s\\%s", global_myname, - printer.info_2->printername); - init_unistr(&(devmode->devicename), adevice); + printer->info_2->printername); + init_unistr(&devmode->devicename, adevice); - snprintf(aform, sizeof(aform), ntdevmode.formname); - init_unistr(&(devmode->formname), aform); + snprintf(aform, sizeof(aform), ntdevmode->formname); + init_unistr(&devmode->formname, aform); - devmode->specversion = ntdevmode.specversion; - devmode->driverversion = ntdevmode.driverversion; - devmode->size = ntdevmode.size; - devmode->driverextra = ntdevmode.driverextra; - devmode->fields = ntdevmode.fields; + devmode->specversion = ntdevmode->specversion; + devmode->driverversion = ntdevmode->driverversion; + devmode->size = ntdevmode->size; + devmode->driverextra = ntdevmode->driverextra; + devmode->fields = ntdevmode->fields; - devmode->orientation = ntdevmode.orientation; - devmode->papersize = ntdevmode.papersize; - devmode->paperlength = ntdevmode.paperlength; - devmode->paperwidth = ntdevmode.paperwidth; - devmode->scale = ntdevmode.scale; - devmode->copies = ntdevmode.copies; - devmode->defaultsource = ntdevmode.defaultsource; - devmode->printquality = ntdevmode.printquality; - devmode->color = ntdevmode.color; - devmode->duplex = ntdevmode.duplex; - devmode->yresolution = ntdevmode.yresolution; - devmode->ttoption = ntdevmode.ttoption; - devmode->collate = ntdevmode.collate; - devmode->icmmethod = ntdevmode.icmmethod; - devmode->icmintent = ntdevmode.icmintent; - devmode->mediatype = ntdevmode.mediatype; - devmode->dithertype = ntdevmode.dithertype; - - if (ntdevmode.private != NULL) - { - if((devmode->private=(uint8 *)malloc(devmode->driverextra*sizeof(uint8))) == NULL) { - return False; - } - memcpy(devmode->private, ntdevmode.private, devmode->driverextra); - } + devmode->orientation = ntdevmode->orientation; + devmode->papersize = ntdevmode->papersize; + devmode->paperlength = ntdevmode->paperlength; + devmode->paperwidth = ntdevmode->paperwidth; + devmode->scale = ntdevmode->scale; + devmode->copies = ntdevmode->copies; + devmode->defaultsource = ntdevmode->defaultsource; + devmode->printquality = ntdevmode->printquality; + devmode->color = ntdevmode->color; + devmode->duplex = ntdevmode->duplex; + devmode->yresolution = ntdevmode->yresolution; + devmode->ttoption = ntdevmode->ttoption; + devmode->collate = ntdevmode->collate; + devmode->icmmethod = ntdevmode->icmmethod; + devmode->icmintent = ntdevmode->icmintent; + devmode->mediatype = ntdevmode->mediatype; + devmode->dithertype = ntdevmode->dithertype; + + if (ntdevmode->private != NULL) { + if ((devmode->private=(uint8 *)memdup(ntdevmode->private, ntdevmode->driverextra)) == NULL) + goto fail; + } + + return devmode; + + fail: + + if (ntdevmode) + free_nt_devicemode(&ntdevmode); + if (printer) + free_a_printer(&printer,2); + free_dev_mode(devmode); - return True; + return NULL; } /******************************************************************** * construct_printer_info_2 * fill a printer_info_2 struct ********************************************************************/ + static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer, int snum) { pstring chaine; pstring chaine2; pstring sl; int count; - DEVICEMODE *devmode; - NT_PRINTER_INFO_LEVEL ntprinter; + NT_PRINTER_INFO_LEVEL *ntprinter = NULL; print_queue_struct *queue=NULL; print_status_struct status; @@ -1854,58 +1889,54 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer else fstrcpy(sl, '\0'); - snprintf(chaine2, sizeof(chaine)-1, "%s%s%s", servername, sl, ntprinter.info_2->printername); + snprintf(chaine2, sizeof(chaine)-1, "%s%s%s", servername, sl, ntprinter->info_2->printername); init_unistr(&printer->servername, chaine); /* servername*/ init_unistr(&printer->printername, chaine2); /* printername*/ init_unistr(&printer->sharename, lp_servicename(snum)); /* sharename */ init_unistr(&printer->portname, lp_servicename(snum)); /* port */ - init_unistr(&printer->drivername, ntprinter.info_2->drivername); /* drivername */ + init_unistr(&printer->drivername, ntprinter->info_2->drivername); /* drivername */ init_unistr(&printer->comment, lp_comment(snum)); /* comment */ - init_unistr(&printer->location, ntprinter.info_2->location); /* location */ - init_unistr(&printer->sepfile, ntprinter.info_2->sepfile); /* separator file */ - init_unistr(&printer->printprocessor, ntprinter.info_2->printprocessor);/* print processor */ - init_unistr(&printer->datatype, ntprinter.info_2->datatype); /* datatype */ - init_unistr(&printer->parameters, ntprinter.info_2->parameters); /* parameters (of print processor) */ + init_unistr(&printer->location, ntprinter->info_2->location); /* location */ + init_unistr(&printer->sepfile, ntprinter->info_2->sepfile); /* separator file */ + init_unistr(&printer->printprocessor, ntprinter->info_2->printprocessor);/* print processor */ + init_unistr(&printer->datatype, ntprinter->info_2->datatype); /* datatype */ + init_unistr(&printer->parameters, ntprinter->info_2->parameters); /* parameters (of print processor) */ printer->attributes = PRINTER_ATTRIBUTE_SHARED \ | PRINTER_ATTRIBUTE_LOCAL \ | PRINTER_ATTRIBUTE_RAW_ONLY ; /* attributes */ - printer->priority = ntprinter.info_2->priority; /* priority */ - printer->defaultpriority = ntprinter.info_2->default_priority; /* default priority */ - printer->starttime = ntprinter.info_2->starttime; /* starttime */ - printer->untiltime = ntprinter.info_2->untiltime; /* untiltime */ + printer->priority = ntprinter->info_2->priority; /* priority */ + printer->defaultpriority = ntprinter->info_2->default_priority; /* default priority */ + printer->starttime = ntprinter->info_2->starttime; /* starttime */ + printer->untiltime = ntprinter->info_2->untiltime; /* untiltime */ printer->status = nt_printq_status(status.status); /* status */ printer->cjobs = count; /* jobs */ - printer->averageppm = ntprinter.info_2->averageppm; /* average pages per minute */ + printer->averageppm = ntprinter->info_2->averageppm; /* average pages per minute */ - if((devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL) + if((printer->devmode = construct_dev_mode(snum, servername)) == NULL) goto err; - ZERO_STRUCTP(devmode); - - if(!construct_dev_mode(devmode, snum, servername)) - goto err; - - printer->devmode=devmode; - - if (ntprinter.info_2->secdesc.len != 0) - { + if (ntprinter->info_2->secdesc_buf->len != 0) { /* steal the printer info sec_desc structure. [badly done]. */ - printer->secdesc = ntprinter.info_2->secdesc.sec; - ZERO_STRUCT(ntprinter.info_2->secdesc); + printer->secdesc = ntprinter->info_2->secdesc_buf->sec; + ntprinter->info_2->secdesc_buf->sec = NULL; /* Stolen memory. */ + ntprinter->info_2->secdesc_buf->len = 0; /* Stolen memory. */ + ntprinter->info_2->secdesc_buf->max_len = 0; /* Stolen memory. */ } - else - { + else { printer->secdesc = NULL; } + free_a_printer(&ntprinter, 2); safe_free(queue); return True; err: + if (ntprinter) + free_a_printer(&ntprinter, 2); safe_free(queue); return False; } @@ -1917,20 +1948,21 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer static BOOL construct_printer_info_3(fstring servername, PRINTER_INFO_3 *printer, int snum) { - NT_PRINTER_INFO_LEVEL ntprinter; + NT_PRINTER_INFO_LEVEL *ntprinter = NULL; if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) return False; - printer->flags = 4; /* no idea, yet. see MSDN. */ - if (ntprinter.info_2->secdesc.len != 0) - { + printer->flags = 4; /* This is the offset to the SEC_DESC. */ + if (ntprinter->info_2->secdesc_buf->len != 0) { /* steal the printer info sec_desc structure. [badly done]. */ - printer->sec = *ntprinter.info_2->secdesc.sec; - safe_free(ntprinter.info_2->secdesc.sec); - ZERO_STRUCT(ntprinter.info_2->secdesc); + printer->secdesc = ntprinter->info_2->secdesc_buf->sec; + ntprinter->info_2->secdesc_buf->sec = NULL; /* Stolen the malloced memory. */ + ntprinter->info_2->secdesc_buf->len = 0; /* Stolen the malloced memory. */ + ntprinter->info_2->secdesc_buf->max_len = 0; /* Stolen the malloced memory. */ } + free_a_printer(&ntprinter, 2); return True; } @@ -2394,7 +2426,7 @@ static uint32 getprinter_level_3(fstring servername, int snum, NEW_BUFFER *buffe new_smb_io_printer_info_3("", buffer, printer, 0); /* clear memory */ - free_sec_desc(&printer->sec); + free_sec_desc(&printer->secdesc); if (*needed > offered) { return ERROR_INSUFFICIENT_BUFFER; @@ -2447,16 +2479,17 @@ static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, static void construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fstring servername, fstring architecture) { - NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; ZERO_STRUCT(driver); - ZERO_STRUCT(printer); get_a_printer(&printer, 2, lp_servicename(snum) ); - get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); + get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture); fill_printer_driver_info_1(info, driver, servername, architecture); + + free_a_printer(&printer,2); } /******************************************************************** @@ -2501,16 +2534,18 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, ********************************************************************/ static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstring servername, fstring architecture) { - NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; ZERO_STRUCT(printer); ZERO_STRUCT(driver); get_a_printer(&printer, 2, lp_servicename(snum) ); - get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); + get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture); fill_printer_driver_info_2(info, driver, servername, architecture); + + free_a_printer(&printer,2); } /******************************************************************** @@ -2600,16 +2635,17 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, static void construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fstring servername, fstring architecture) { - NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; - ZERO_STRUCT(printer); ZERO_STRUCT(driver); get_a_printer(&printer, 2, lp_servicename(snum) ); - get_a_printer_driver(&driver, 3, printer.info_2->drivername, architecture); + get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture); fill_printer_driver_info_3(info, driver, servername, architecture); + + free_a_printer(&printer,2); } /**************************************************************************** @@ -2932,24 +2968,24 @@ static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level, return nt_printing_setsec(Printer->dev.printername, secdesc_ctr); } - /******************************************************************** * called by spoolss_api_setprinter * when updating a printer description ********************************************************************/ + static uint32 update_printer(const POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, - const DEVICEMODE *devmode) + DEVICEMODE *devmode) { int snum; - NT_PRINTER_INFO_LEVEL printer; - NT_DEVICEMODE nt_devmode; + NT_PRINTER_INFO_LEVEL *printer = NULL; + NT_DEVICEMODE *ntdevmode = NULL; Printer_entry *Printer = find_printer_index_by_hnd(handle); DEBUG(8,("update_printer\n")); if (level!=2) { - DEBUG(0,("Send a mail to jfm@samba.org\n")); + DEBUG(0,("Send a mail to samba@samba.org\n")); DEBUGADD(0,("with the following message: update_printer: level!=2\n")); return ERROR_INVALID_LEVEL; } @@ -2963,32 +2999,34 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, get_a_printer(&printer, 2, lp_servicename(snum)); DEBUGADD(8,("Converting info_2 struct\n")); - convert_printer_info(info, &printer, level); + convert_printer_info(info, printer, level); - if ((info->info_2)->devmode_ptr != 0) { + if (info->info_2->devmode_ptr != 0) { /* we have a valid devmode convert it and link it*/ DEBUGADD(8,("Converting the devicemode struct\n")); - if (printer.info_2->devmode) { - nt_devmode = *printer.info_2->devmode; + if (printer->info_2->devmode) { + ntdevmode = dup_nt_devicemode(printer->info_2->devmode); } else { - init_devicemode(&nt_devmode); + ntdevmode = construct_nt_devicemode(); } - convert_devicemode(*devmode, &nt_devmode); - } - else { - if (printer.info_2->devmode != NULL) - free(printer.info_2->devmode); - printer.info_2->devmode=NULL; + convert_devicemode(devmode, ntdevmode); + } else { + if (printer->info_2->devmode != NULL) + free_nt_devicemode(&printer->info_2->devmode); + printer->info_2->devmode=NULL; } - if (add_a_printer(printer, 2)!=0) { + if (add_a_printer(*printer, 2)!=0) { /* I don't really know what to return here !!! */ + free_a_printer(&printer, 2); return ERROR_ACCESS_DENIED; } + free_a_printer(&printer, 2); + return NT_STATUS_NO_PROBLEMO; } @@ -2996,8 +3034,8 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, ****************************************************************************/ uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, - const DEVMODE_CTR devmode_ctr, - const SEC_DESC_BUF *secdesc_ctr, + DEVMODE_CTR devmode_ctr, + SEC_DESC_BUF *secdesc_ctr, uint32 command) { Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -3085,7 +3123,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, { pstring temp_name; DEVICEMODE *devmode; - NT_PRINTER_INFO_LEVEL ntprinter; + NT_PRINTER_INFO_LEVEL *ntprinter = NULL; pstring chaine; struct tm *t; @@ -3099,7 +3137,8 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, job_info->jobid=queue->job; - snprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", global_myname, ntprinter.info_2->printername); + snprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", global_myname, ntprinter->info_2->printername); + init_unistr(&(job_info->printername), chaine); init_unistr(&(job_info->machinename), temp_name); @@ -3124,16 +3163,13 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, job_info->timeelapsed=0; job_info->pagesprinted=0; - if((devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL) { + if((job_info->devmode = construct_dev_mode(snum, global_myname)) == NULL) { + free_a_printer(&ntprinter, 2); return False; } - ZERO_STRUCTP(devmode); - if(!construct_dev_mode(devmode, snum, global_myname)) { - return False; - } job_info->devmode=devmode; - + free_a_printer(&ntprinter, 2); return (True); } @@ -3753,7 +3789,7 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, uint32 user_switch, const SPOOL_USER_CTR *user, POLICY_HND *handle) { - NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_INFO_LEVEL *printer = NULL; fstring name; fstring share_name; @@ -3761,17 +3797,17 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, /* NULLify info_2 here */ /* don't put it in convert_printer_info as it's used also with non-NULL values */ - printer.info_2=NULL; + printer->info_2=NULL; /* convert from UNICODE to ASCII */ - convert_printer_info(info, &printer, 2); + convert_printer_info(info, printer, 2); - unistr2_to_ascii(share_name, &((info->info_2)->printername), sizeof(share_name)-1); + unistr2_to_ascii(share_name, &info->info_2->printername, sizeof(share_name)-1); slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname, share_name); /* write the ASCII on disk */ - if (add_a_printer(printer, 2) != 0x0) + if (add_a_printer(*printer, 2) != 0x0) return ERROR_ACCESS_DENIED; create_printer_hnd(handle); @@ -3969,7 +4005,7 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, uint32 *out_type, uint32 *out_max_data_len, uint8 **data_out, uint32 *out_data_len) { - NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_INFO_LEVEL *printer = NULL; fstring value; @@ -4017,7 +4053,7 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, biggest_valuesize=0; biggest_datasize=0; - while (get_specific_param_by_index(printer, 2, param_index, value, &data, &type, &data_len)) { + while (get_specific_param_by_index(*printer, 2, param_index, value, &data, &type, &data_len)) { if (strlen(value) > biggest_valuesize) biggest_valuesize=strlen(value); if (data_len > biggest_datasize) biggest_datasize=data_len; @@ -4041,7 +4077,7 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, * that's the number of bytes not the number of unicode chars */ - if (!get_specific_param_by_index(printer, 2, idx, value, &data, &type, &data_len)) { + if (!get_specific_param_by_index(*printer, 2, idx, value, &data, &type, &data_len)) { safe_free(data); return ERROR_NO_MORE_ITEMS; } @@ -4089,7 +4125,7 @@ uint32 _spoolss_setprinterdata( const POLICY_HND *handle, uint32 real_len, uint32 numeric_data) { - NT_PRINTER_INFO_LEVEL printer; + NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_PARAM *param = NULL; int snum=0; @@ -4110,12 +4146,12 @@ uint32 _spoolss_setprinterdata( const POLICY_HND *handle, return ERROR_INVALID_NAME; convert_specific_param(¶m, value , type, data, real_len); - unlink_specific_param_if_exist(printer.info_2, param); + unlink_specific_param_if_exist(printer->info_2, param); - if (!add_a_specific_param(printer.info_2, param)) + if (!add_a_specific_param(printer->info_2, param)) status = ERROR_INVALID_PARAMETER; else - status = add_a_printer(printer, 2); + status = add_a_printer(*printer, 2); return status; } @@ -4512,4 +4548,3 @@ uint32 _spoolss_getjob( POLICY_HND *handle, uint32 jobid, uint32 level, } } #undef OLD_NTDOMAIN - -- cgit From f0080e5a3979fac94d6668cf6ee9d9f61302839c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Jun 2000 17:01:34 +0000 Subject: Getting back to a compilable state (not there yet but close). Added patches for random -> sys_random. Added set_effective_xxx patches for AFS code. Memory allocation changes in spoolss code. Jeremy. (This used to be commit c2099cfb033c2cdb6035f4f7f50ce21b98e1584d) --- source3/rpc_server/srv_samr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 9ad1d34561..49db7a9e48 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -277,6 +277,7 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, if ((pwd = getpwent()) == NULL) break; user_name_len = strlen(pwd->pw_name); pw_rid = pdb_uid_to_user_rid(pwd->pw_uid); + ZERO_STRUCTP(&pw_buf[(*num_entries)]); init_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->pw_name, user_name_len); init_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len); pw_buf[(*num_entries)].user_rid = pw_rid; @@ -296,6 +297,7 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, while (((unmap_name = unmap_unixname(pwd->pw_name, mapped_idx)) != NULL) && (*num_entries < max_num_entries)) { user_name_len = strlen(unmap_name); + ZERO_STRUCTP(&pw_buf[(*num_entries)]); init_unistr2(&(pw_buf[(*num_entries)].uni_user_name), unmap_name, user_name_len); init_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len); pw_buf[(*num_entries)].user_rid = pw_rid; @@ -661,6 +663,7 @@ static BOOL samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, got_grps = True; num_entries = 1; + ZERO_STRUCTP(&pass[0]); init_unistr2(&(pass[0].uni_user_name), dummy_group, strlen(dummy_group)); pass[0].user_rid = DOMAIN_GROUP_RID_ADMINS; @@ -788,8 +791,7 @@ static BOOL api_samr_enum_dom_aliases(prs_struct *data, prs_struct *rdata) /******************************************************************* samr_reply_query_dispinfo ********************************************************************/ -static BOOL samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, - prs_struct *rdata) +static BOOL samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, prs_struct *rdata) { SAMR_R_QUERY_DISPINFO r_e; SAM_INFO_CTR ctr; -- cgit From 61ab5b46cfb93939651b4426016845a035315bf7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Jun 2000 18:17:22 +0000 Subject: Back to building. Now to test with insure. Added some frees needed to stop memory leaks. Jeremy. (This used to be commit eba31e4e802120c9eb8c4688f521b4de9cb91f5c) --- source3/rpc_server/srv_spoolss.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 0e6c456ec3..74901efa78 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -498,14 +498,18 @@ static BOOL api_spoolss_setprinter(prs_struct *data, prs_struct *rdata) } r_u.status = _spoolss_setprinter(&q_u.handle, q_u.level, &q_u.info, - q_u.devmode_ctr, &q_u.secdesc_ctr, + q_u.devmode_ctr, q_u.secdesc_ctr, q_u.command); if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n")); + free_spoolss_q_setprinter(&q_u); return False; } + /* Free anything allocated in the unparse. */ + free_spoolss_q_setprinter(&q_u); + return True; } -- cgit From b9fedcb2de5612bdb4e763fe0788e1a4a9c16d33 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Jun 2000 21:00:37 +0000 Subject: param/loadparm.c: Looks like someone ran indent on this ! passdb/smbpass.c: Insure uninitialized memory reference fix. printing/nt_printing.c: rpc_server/srv_spoolss_nt.c: Insure memory leak fixes. smbd/unix_acls.c: Shadow ref fix. Jeremy. (This used to be commit d175d3ebefc053e9badd91ca5f2d8bd03eb6705d) --- source3/rpc_server/srv_spoolss_nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 424e1f5e95..f181585c84 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3862,6 +3862,7 @@ static uint32 modify_driver_heirarchy(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint pstring path_old; pstring path_new; pstring short_archi; + /* find_service is an smbd-specific function call */ int snum = find_service("print$"); char *model = NULL; @@ -3886,10 +3887,11 @@ static uint32 modify_driver_heirarchy(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint (unsigned int)sys_getpid()); slprintf(path_new, sizeof(path_new)-1, "%s/%s/%s", lp_pathname(snum), short_archi, model); - DEBUG(10,("_spoolss_addprinterdriver: old_path=%s, new_path=%s\n", + DEBUG(10,("modify_driver_heirarchy: old_path=%s, new_path=%s\n", path_old, path_new )); if (dos_rename(path_old, path_new) == -1) { - DEBUG(0,("modify_driver_heirarchy: rename failed (%s)\n", strerror(errno) )); + DEBUG(0,("modify_driver_heirarchy: rename from %s to %s failed (%s)\n", + path_old, path_new, strerror(errno) )); /* We need to clean up here.... - how ? */ return ERROR_ACCESS_DENIED; /* We need a generic mapping from NT errors here... */ } -- cgit From 8ff6458a3e568e759969fd1a9c827c4b47008cfb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Jun 2000 21:52:49 +0000 Subject: More insure found memory leak and corruption fixes. Jeremy. (This used to be commit 3cdcfa6325b9cd2d7f7c90c4b2d1c6ec73fc2f6d) --- source3/rpc_server/srv_spoolss.c | 3 +++ source3/rpc_server/srv_spoolss_nt.c | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 74901efa78..2513fe91e6 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -833,9 +833,12 @@ static BOOL api_spoolss_addprinterdriver(prs_struct *data, prs_struct *rdata) if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n")); + free_spoolss_q_addprinterdriver(&q_u); return False; } + free_spoolss_q_addprinterdriver(&q_u); + return True; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f181585c84..b77deca158 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3917,14 +3917,12 @@ uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name, #ifdef RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD if ((err = modify_driver_heirarchy(&driver, level)) != 0) { - safe_free(driver.info_3); - safe_free(driver.info_6); + free_a_printer_driver(driver, level); return err; } #endif - safe_free(driver.info_3); - safe_free(driver.info_6); + free_a_printer_driver(driver, level); return NT_STATUS_NO_PROBLEMO; } -- cgit From 01c4ecd2343a4c87a0f023cd58382bf08610304e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 2 Jun 2000 18:38:49 +0000 Subject: Fixed null pointer indirect in addprinterex. Still working on problem with extra directory layer in NT drivers. Jeremy. (This used to be commit 48a80318269c832e702678237e86ba55c10444f1) --- source3/rpc_server/srv_spoolss_nt.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b77deca158..e88aa9fa72 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -560,7 +560,7 @@ static BOOL convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni, { switch (level) { case 2: - uni_2_asc_printer_info_2(uni->info_2, &(printer->info_2)); + uni_2_asc_printer_info_2(uni->info_2, &printer->info_2); break; default: break; @@ -3793,13 +3793,16 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, fstring name; fstring share_name; + 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; + } + + ZERO_STRUCTP(printer); + clear_handle(handle); - /* NULLify info_2 here */ - /* don't put it in convert_printer_info as it's used also with non-NULL values */ - printer->info_2=NULL; - - /* convert from UNICODE to ASCII */ + /* convert from UNICODE to ASCII - this allocates the info_2 struct inside *printer.*/ convert_printer_info(info, printer, 2); unistr2_to_ascii(share_name, &info->info_2->printername, sizeof(share_name)-1); @@ -3807,23 +3810,28 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname, share_name); /* write the ASCII on disk */ - if (add_a_printer(*printer, 2) != 0x0) + if (add_a_printer(*printer, 2) != 0) { + free_a_printer(&printer,2); return ERROR_ACCESS_DENIED; + } create_printer_hnd(handle); open_printer_hnd(handle); if (!set_printer_hnd_printertype(handle, name)) { + free_a_printer(&printer,2); close_printer_handle(handle); return ERROR_ACCESS_DENIED; } if (!set_printer_hnd_printername(handle, name)) { + free_a_printer(&printer,2); close_printer_handle(handle); return ERROR_ACCESS_DENIED; } + free_a_printer(&printer,2); return NT_STATUS_NO_PROBLEMO; } @@ -3862,6 +3870,7 @@ static uint32 modify_driver_heirarchy(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint pstring path_old; pstring path_new; pstring short_archi; + pstring model_name; /* find_service is an smbd-specific function call */ int snum = find_service("print$"); @@ -3885,7 +3894,11 @@ static uint32 modify_driver_heirarchy(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint slprintf(path_old, sizeof(path_old)-1, "%s/%s/TMP_%u", lp_pathname(snum), short_archi, (unsigned int)sys_getpid()); - slprintf(path_new, sizeof(path_new)-1, "%s/%s/%s", lp_pathname(snum), short_archi, model); + + /* Clean up any '/' and other characters in the model name. */ + alpha_strcpy(model_name, model, sizeof(pstring)); + + slprintf(path_new, sizeof(path_new)-1, "%s/%s/%s", lp_pathname(snum), short_archi, model_name); DEBUG(10,("modify_driver_heirarchy: old_path=%s, new_path=%s\n", path_old, path_new )); -- cgit From 2472ab1e60c27bf8ac84e32e67c8cb18e5647306 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 2 Jun 2000 19:42:11 +0000 Subject: More memory corruption (leaks etc.) fixes. Jeremy. (This used to be commit 71a0621f552083880e89923055e8bd14d0b1b82f) --- source3/rpc_server/srv_spoolss_nt.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e88aa9fa72..37833df508 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1846,6 +1846,9 @@ static DEVICEMODE *construct_dev_mode(int snum, char *servername) goto fail; } + free_nt_devicemode(&ntdevmode); + free_a_printer(&printer,2); + return devmode; fail: @@ -2152,12 +2155,12 @@ static BOOL enum_all_printers_info_2(fstring servername, NEW_BUFFER *buffer, uin /* check the required size. */ for (i=0; i<*returned; i++) - (*needed) += spoolss_size_printer_info_2(&(printers[i])); + (*needed) += spoolss_size_printer_info_2(&printers[i]); if (!alloc_buffer_size(buffer, *needed)) { for (i=0; i<*returned; i++) { - safe_free(printers[i].devmode->private); - safe_free(printers[i].devmode); + free_devmode(printers[i].devmode); + free_sec_desc(&printers[i].secdesc); } safe_free(printers); return ERROR_INSUFFICIENT_BUFFER; @@ -2381,7 +2384,7 @@ static uint32 getprinter_level_2(fstring servername, int snum, NEW_BUFFER *buffe *needed += spoolss_size_printer_info_2(printer); if (!alloc_buffer_size(buffer, *needed)) { - safe_free(printer); + free_printer_info_2(printer); return ERROR_INSUFFICIENT_BUFFER; } @@ -2389,9 +2392,7 @@ static uint32 getprinter_level_2(fstring servername, int snum, NEW_BUFFER *buffe new_smb_io_printer_info_2("", buffer, printer, 0); /* clear memory */ - safe_free(printer->devmode->private); - safe_free(printer->devmode); - safe_free(printer); + free_printer_info_2(printer); if (*needed > offered) { return ERROR_INSUFFICIENT_BUFFER; @@ -3892,8 +3893,8 @@ static uint32 modify_driver_heirarchy(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint break; } - slprintf(path_old, sizeof(path_old)-1, "%s/%s/TMP_%u", lp_pathname(snum), short_archi, - (unsigned int)sys_getpid()); + slprintf(path_old, sizeof(path_old)-1, "%s/%s/TMP_%s", lp_pathname(snum), short_archi, + client_addr()); /* Clean up any '/' and other characters in the model name. */ alpha_strcpy(model_name, model, sizeof(pstring)); @@ -3963,8 +3964,8 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen get_short_archi(short_archi, long_archi); #ifdef RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD - slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s\\TMP_%u", global_myname, short_archi, - (unsigned int)sys_getpid()); + slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s\\TMP_%s", global_myname, short_archi, + client_addr()); #else slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", global_myname, short_archi); -- cgit From c7d0975183c286d9f93e57bf8c73c96c1a9ebd55 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 2 Jun 2000 20:08:28 +0000 Subject: More memory leak fixes. Jeremy. (This used to be commit 4e7b6b20eabe02f1ab74254607178ba35e61c9ce) --- source3/rpc_server/srv_spoolss_nt.c | 52 ++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 37833df508..327a4a15fe 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1633,7 +1633,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring counter_printer_0 *session_counter; uint32 global_counter; struct tm *t; - time_t setup_time; + time_t setup_time = time(NULL); print_queue_struct *queue=NULL; print_status_struct status; @@ -1949,13 +1949,20 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer * fill a printer_info_3 struct ********************************************************************/ static BOOL construct_printer_info_3(fstring servername, - PRINTER_INFO_3 *printer, int snum) + PRINTER_INFO_3 **pp_printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; + PRINTER_INFO_3 *printer = NULL; if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) return False; - + + *pp_printer = NULL; + if ((printer = (PRINTER_INFO_3 *)malloc(sizeof(PRINTER_INFO_3))) == NULL) { + DEBUG(0,("construct_printer_info_3: malloc fail.\n")); + return False; + } + printer->flags = 4; /* This is the offset to the SEC_DESC. */ if (ntprinter->info_2->secdesc_buf->len != 0) { /* steal the printer info sec_desc structure. [badly done]. */ @@ -1966,6 +1973,8 @@ static BOOL construct_printer_info_3(fstring servername, } free_a_printer(&ntprinter, 2); + + *pp_printer = printer; return True; } @@ -2172,8 +2181,8 @@ static BOOL enum_all_printers_info_2(fstring servername, NEW_BUFFER *buffer, uin /* clear memory */ for (i=0; i<*returned; i++) { - safe_free(printers[i].devmode->private); - safe_free(printers[i].devmode); + free_devmode(printers[i].devmode); + free_sec_desc(&printers[i].secdesc); } safe_free(printers); @@ -2408,18 +2417,16 @@ static uint32 getprinter_level_3(fstring servername, int snum, NEW_BUFFER *buffe PRINTER_INFO_3 *printer=NULL; fstring temp; - if((printer=(PRINTER_INFO_3*)malloc(sizeof(PRINTER_INFO_3)))==NULL) - return ERROR_NOT_ENOUGH_MEMORY; - fstrcpy(temp, "\\\\"); fstrcat(temp, servername); - construct_printer_info_3(temp, printer, snum); + if (!construct_printer_info_3(temp, &printer, snum)) + return ERROR_NOT_ENOUGH_MEMORY; /* check the required size. */ *needed += spoolss_size_printer_info_3(printer); if (!alloc_buffer_size(buffer, *needed)) { - safe_free(printer); + free_printer_info_3(printer); return ERROR_INSUFFICIENT_BUFFER; } @@ -2427,8 +2434,8 @@ static uint32 getprinter_level_3(fstring servername, int snum, NEW_BUFFER *buffe new_smb_io_printer_info_3("", buffer, printer, 0); /* clear memory */ - free_sec_desc(&printer->secdesc); - + free_printer_info_3(printer); + if (*needed > offered) { return ERROR_INSUFFICIENT_BUFFER; } @@ -2565,8 +2572,12 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *whe *uni_array=NULL; while (1) { - v = char_array[i]; - if (!v) v = ""; /* hack to handle null lists */ + if (char_array == NULL) + v = ""; + else { + v = char_array[i]; + if (!v) v = ""; /* hack to handle null lists */ + } snprintf(line, sizeof(line)-1, "%s%s", where, v); DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); if((*uni_array=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL) { @@ -2626,7 +2637,7 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, init_unistr( &(info->defaultdatatype), driver.info_3->defaultdatatype ); info->dependentfiles=NULL; - init_unistr_array(&(info->dependentfiles), driver.info_3->dependentfiles, where); + init_unistr_array(&info->dependentfiles, driver.info_3->dependentfiles, where); } /******************************************************************** @@ -2649,6 +2660,14 @@ static void construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, free_a_printer(&printer,2); } +/**************************************************************************** +****************************************************************************/ + +static void free_printer_driver_info_3(DRIVER_INFO_3 *info) +{ + safe_free(info->dependentfiles); +} + /**************************************************************************** ****************************************************************************/ static uint32 getprinterdriver2_level1(fstring servername, fstring architecture, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) @@ -2725,12 +2744,15 @@ static uint32 getprinterdriver2_level3(fstring servername, fstring architecture, *needed += spoolss_size_printer_driver_info_3(&info); if (!alloc_buffer_size(buffer, *needed)) { + free_printer_driver_info_3(&info); return ERROR_INSUFFICIENT_BUFFER; } /* fill the buffer with the structures */ new_smb_io_printer_driver_info_3("", buffer, &info, 0); + free_printer_driver_info_3(&info); + if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; else -- cgit From 0cc138993573a8337c335563ba3c5936d260f298 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 2 Jun 2000 21:16:39 +0000 Subject: More memory leak and PANIC action fixes. This is *horrible* code :-(. Jeremy. (This used to be commit ac383bb765ea606fc1105aa91470fcdf453d9335) --- source3/rpc_server/srv_spoolss_nt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 327a4a15fe..393ba64130 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -473,7 +473,7 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) uint32 extra_space; uint32 old_offset; - ps=&(buffer->prs); + ps= &buffer->prs; /* damn, I'm doing the reverse operation of prs_grow() :) */ if (buffer_size < prs_data_size(ps)) @@ -2398,7 +2398,10 @@ static uint32 getprinter_level_2(fstring servername, int snum, NEW_BUFFER *buffe } /* fill the buffer with the structures */ - new_smb_io_printer_info_2("", buffer, printer, 0); + if (!new_smb_io_printer_info_2("", buffer, printer, 0)) { + free_printer_info_2(printer); + return ERROR_NOT_ENOUGH_MEMORY; + } /* clear memory */ free_printer_info_2(printer); @@ -3002,7 +3005,6 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, { int snum; NT_PRINTER_INFO_LEVEL *printer = NULL; - NT_DEVICEMODE *ntdevmode = NULL; Printer_entry *Printer = find_printer_index_by_hnd(handle); DEBUG(8,("update_printer\n")); @@ -3025,6 +3027,7 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, convert_printer_info(info, printer, level); if (info->info_2->devmode_ptr != 0) { + NT_DEVICEMODE *ntdevmode = NULL; /* we have a valid devmode convert it and link it*/ @@ -3036,6 +3039,7 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, } convert_devicemode(devmode, ntdevmode); + free_nt_devicemode(&ntdevmode); } else { if (printer->info_2->devmode != NULL) free_nt_devicemode(&printer->info_2->devmode); @@ -3097,6 +3101,7 @@ uint32 _spoolss_fcpn(const POLICY_HND *handle) Printer->notify.localmachine[0]='\0'; Printer->notify.printerlocal=0; safe_free(Printer->notify.option); + safe_free(Printer->notify.option->ctr.type); Printer->notify.option=NULL; return NT_STATUS_NO_PROBLEMO; -- cgit From 5a5540f87a89224397d791f4fe8093be214e1f15 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Jun 2000 00:53:07 +0000 Subject: rpc_client/cli_lsarpc.c: Removed unused variable. rpc_server/srv_spoolss_nt.c: Fixed more memory leaks. smbd/nttrans.c: Fixed shadow variable problem. Jeremy. (This used to be commit f0a7540831181d3a47e7f8ce8be55a36a2f2aba1) --- source3/rpc_server/srv_spoolss_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 393ba64130..0efcbdae1c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4110,6 +4110,7 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, DEBUG(6,("final values: [%d], [%d]\n", *out_value_len, *out_data_len)); + free_a_printer(&printer, 2); return NT_STATUS_NO_PROBLEMO; } @@ -4120,9 +4121,12 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, 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; } + free_a_printer(&printer, 2); + /* * the value is: * - counted in bytes in the request @@ -4194,6 +4198,7 @@ uint32 _spoolss_setprinterdata( const POLICY_HND *handle, else status = add_a_printer(*printer, 2); + free_a_printer(&printer, 2); return status; } -- cgit From dbf004bdabd08272e5dfb07a5511091746b6631a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 4 Jun 2000 00:26:08 +0000 Subject: added a MANGLE_DRIVER_PATH define to chooose whether we stuff with the driver path do a rename etc. I turned it off by default as it is causing me no end of problems. The client will *cache* this path, and that screws things up badly as the temp directory is no longer there when it is needed. (This used to be commit 46f5f41c88b6ffa117d30f7702628b43dd456902) --- source3/rpc_server/srv_spoolss_nt.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0efcbdae1c..8015b9e4f8 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -25,7 +25,9 @@ #include "includes.h" -#define RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD +#ifndef MANGLE_DRIVER_PATH +#define MANGLE_DRIVER_PATH 0 +#endif extern int DEBUGLEVEL; extern pstring global_myname; @@ -3892,7 +3894,7 @@ uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level, Modify internal driver heirarchy. ****************************************************************************/ -#ifdef RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD +#if MANGLE_DRIVER_PATH static uint32 modify_driver_heirarchy(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32 level) { pstring path_old; @@ -3947,8 +3949,8 @@ uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name, uint32 level, const SPOOL_PRINTER_DRIVER_INFO_LEVEL *info) { + uint32 err = NT_STATUS_NO_PROBLEMO; NT_PRINTER_DRIVER_INFO_LEVEL driver; - uint32 err; ZERO_STRUCT(driver); convert_printer_driver_info(info, &driver, level); @@ -3956,16 +3958,13 @@ uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name, if (add_a_printer_driver(driver, level)!=0) return ERROR_ACCESS_DENIED; -#ifdef RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD - if ((err = modify_driver_heirarchy(&driver, level)) != 0) { - free_a_printer_driver(driver, level); - return err; - } +#if MANGLE_DRIVER_PATH + err = modify_driver_heirarchy(&driver, level); #endif free_a_printer_driver(driver, level); - return NT_STATUS_NO_PROBLEMO; + return err; } /**************************************************************************** @@ -3990,7 +3989,7 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); get_short_archi(short_archi, long_archi); -#ifdef RELIES_ON_SMBD_FUNCTIONS_LINKED_INTO_SPOOLSSD +#if MANGLE_DRIVER_PATH slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s\\TMP_%s", global_myname, short_archi, client_addr()); #else -- cgit From 6d8c131f50e708d4c009355a7c5fe026cf8d350a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 5 Jun 2000 20:55:57 +0000 Subject: Some tidyup fixes (memory leaks etc.). Still no progress with the "no driver" issue. I'm banging my head against comparitive packet dumps right now... Jeremy. (This used to be commit 03cd4aa1443acd958593f37c61ff9c90a43c660b) --- source3/rpc_server/srv_spoolss.c | 2 ++ source3/rpc_server/srv_spoolss_nt.c | 29 +++++++++++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 2513fe91e6..c2839bfbf7 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -930,6 +930,8 @@ static BOOL api_spoolss_setprinterdata(prs_struct *data, prs_struct *rdata) &q_u.value, q_u.type, q_u.max_len, q_u.data, q_u.real_len, q_u.numeric_data); + free_spoolss_q_setprinterdata(&q_u); + if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n")); return False; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8015b9e4f8..8dca09dc95 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -773,13 +773,17 @@ static BOOL getprinterdata_printer(const POLICY_HND *handle, DEBUG(5,("getprinterdata_printer:allocating %d\n", in_size)); - if((*data = (uint8 *)malloc( in_size *sizeof(uint8) )) == NULL) { - return False; - } + if (in_size) { + if((*data = (uint8 *)malloc( in_size *sizeof(uint8) )) == NULL) { + return False; + } - memset(*data, 0, in_size *sizeof(uint8)); - /* copy the min(in_size, len) */ - memcpy(*data, idata, (len>in_size)?in_size:len *sizeof(uint8)); + memset(*data, 0, in_size *sizeof(uint8)); + /* copy the min(in_size, len) */ + memcpy(*data, idata, (len>in_size)?in_size:len *sizeof(uint8)); + } else { + *data = NULL; + } *needed = len; @@ -835,9 +839,14 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, if (found==False) { DEBUG(5, ("value not found, allocating %d\n", *out_size)); /* reply this param doesn't exist */ - if((*data=(uint8 *)malloc(*out_size*sizeof(uint8))) == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - memset(*data, 0x0, *out_size*sizeof(uint8)); + if (*out_size) { + if((*data=(uint8 *)malloc(*out_size*sizeof(uint8))) == NULL) + return ERROR_NOT_ENOUGH_MEMORY; + memset(*data, '\0', *out_size*sizeof(uint8)); + } else { + *data = NULL; + } + return ERROR_INVALID_PARAMETER; } @@ -3102,8 +3111,8 @@ uint32 _spoolss_fcpn(const POLICY_HND *handle) Printer->notify.options=0; Printer->notify.localmachine[0]='\0'; Printer->notify.printerlocal=0; - safe_free(Printer->notify.option); safe_free(Printer->notify.option->ctr.type); + safe_free(Printer->notify.option); Printer->notify.option=NULL; return NT_STATUS_NO_PROBLEMO; -- cgit From 84aa9ad0493ede5acf6b1bbf901b3cbb980c5dbc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 6 Jun 2000 01:34:20 +0000 Subject: Create elements in default, not in read. Jeremy. (This used to be commit 0d681ea252e0cf7fdf57d316d2bfe7caa9b4fbf5) --- source3/rpc_server/srv_spoolss_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8dca09dc95..5793d5a137 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1917,9 +1917,7 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer init_unistr(&printer->datatype, ntprinter->info_2->datatype); /* datatype */ init_unistr(&printer->parameters, ntprinter->info_2->parameters); /* parameters (of print processor) */ - printer->attributes = PRINTER_ATTRIBUTE_SHARED \ - | PRINTER_ATTRIBUTE_LOCAL \ - | PRINTER_ATTRIBUTE_RAW_ONLY ; /* attributes */ + printer->attributes = ntprinter->info_2->attributes; printer->priority = ntprinter->info_2->priority; /* priority */ printer->defaultpriority = ntprinter->info_2->default_priority; /* default priority */ -- cgit From d253db1b9a10644940650cc802feb2a509adbaed Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 6 Jun 2000 20:44:58 +0000 Subject: Memory leak fixes. Jeremy. (This used to be commit 34b63896ab1543936d6b9b382ef6727a161b6bf2) --- source3/rpc_server/srv_spoolss.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index c2839bfbf7..c259260385 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -52,7 +52,7 @@ static BOOL api_spoolss_open_printer_ex(prs_struct *data, prs_struct *rdata) &r_u.handle); /* we _really_ need to switch to talloc() */ - safe_free(q_u.printer_default.devmode_cont.devmode); + free_spoolss_q_open_printer_ex(&q_u); if (!spoolss_io_r_open_printer_ex("",&r_u,rdata,0)){ DEBUG(0,("spoolss_io_r_open_printer_ex: unable to marshall SPOOL_R_OPEN_PRINTER_EX.\n")); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5793d5a137..b341dbe12a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3109,7 +3109,8 @@ uint32 _spoolss_fcpn(const POLICY_HND *handle) Printer->notify.options=0; Printer->notify.localmachine[0]='\0'; Printer->notify.printerlocal=0; - safe_free(Printer->notify.option->ctr.type); + if (Printer->notify.option) + safe_free(Printer->notify.option->ctr.type); safe_free(Printer->notify.option); Printer->notify.option=NULL; -- cgit From 0164047afbd082b0003147845a72ca08b4781b81 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 7 Jun 2000 01:49:23 +0000 Subject: Fixing get/set of security descriptors. Removed ugly hack for NT printing. Fixed up tdb parse stuff memory leaks. Jeremy. (This used to be commit 8ef41f31c53e14ad057d883810a1cd2301fede2a) --- source3/rpc_server/srv_spoolss_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b341dbe12a..e3552c3879 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1971,6 +1971,8 @@ static BOOL construct_printer_info_3(fstring servername, DEBUG(0,("construct_printer_info_3: malloc fail.\n")); return False; } + + ZERO_STRUCTP(printer); printer->flags = 4; /* This is the offset to the SEC_DESC. */ if (ntprinter->info_2->secdesc_buf->len != 0) { -- cgit From e58682eb077a79b5c54a0cea485b7d134a01f853 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 9 Jun 2000 14:13:11 +0000 Subject: do some standard_sub_advanced() in api_net_sam_logon on lp_logon_xxx(). and if you have unix realname=yes, you get the gecos name when locking the station. J.F. (This used to be commit b5ad24ae0b15643df5832e2369fb4e43c98a1359) --- source3/rpc_server/srv_netlog.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 7ca03a5e8b..a5aaffc174 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -644,6 +644,7 @@ static BOOL api_net_sam_logon(prs_struct *data, prs_struct *rdata) struct smb_passwd *smb_pass = NULL; UNISTR2 *uni_samlogon_user = NULL; fstring nt_username; + struct passwd *pw; user_struct *vuser = NULL; @@ -708,7 +709,7 @@ static BOOL api_net_sam_logon(prs_struct *data, prs_struct *rdata) /* * Do any case conversions. */ - (void)Get_Pwnam(nt_username, True); + pw=Get_Pwnam(nt_username, True); become_root(True); smb_pass = getsmbpwnam(nt_username); @@ -758,7 +759,8 @@ static BOOL api_net_sam_logon(prs_struct *data, prs_struct *rdata) pstring domain_groups; uint32 r_uid; uint32 r_gid; - + fstring full_name; + /* set up pointer indicating user/password failed to be found */ usr_info.ptr_user_info = 0; @@ -769,17 +771,27 @@ static BOOL api_net_sam_logon(prs_struct *data, prs_struct *rdata) /* possibly a better way would be to do a become_user() call */ sam_logon_in_ssb = True; pstrcpy(samlogon_user, nt_username); - + pstrcpy(logon_script, lp_logon_script()); + standard_sub_advanced(-1, nt_username, "", pw->pw_gid, logon_script); + pstrcpy(profile_path, lp_logon_path()); + standard_sub_advanced(-1, nt_username, "", pw->pw_gid, profile_path); pstrcpy(my_workgroup, lp_workgroup()); pstrcpy(home_drive, lp_logon_drive()); + standard_sub_advanced(-1, nt_username, "", pw->pw_gid, home_drive); + pstrcpy(home_dir, lp_logon_home()); + standard_sub_advanced(-1, nt_username, "", pw->pw_gid, home_dir); pstrcpy(my_name, global_myname); strupper(my_name); + + fstrcpy(full_name, ""); + if (lp_unix_realname()) + fstrcpy(full_name, pw->pw_gecos); /* * This is the point at which we get the group @@ -809,7 +821,7 @@ static BOOL api_net_sam_logon(prs_struct *data, prs_struct *rdata) &dummy_time, /* pass_must_change_time */ nt_username , /* user_name */ - vuser->user.full_name, /* full_name */ + full_name, /* full_name */ logon_script , /* logon_script */ profile_path , /* profile_path */ home_dir , /* home_dir */ -- cgit From 7b89d2b93fdcc96e99036e539cac161c6d3c6bb5 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 14 Jun 2000 10:02:48 +0000 Subject: Changed server side lsa_lookup_sids function to look up SIDs that we are not authoritative for using winbindd. (This used to be commit a39cdffb141a8e4188b00dfb6eb3317f134cddda) --- source3/rpc_server/srv_lsa.c | 102 +++++++++++++++++++++++++++++++------------ 1 file changed, 74 insertions(+), 28 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 71162ac782..047c02eb3e 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -279,6 +279,68 @@ static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, r_l->status = 0x0; } +/* Call winbindd to convert sid to name */ + +static BOOL winbind_lookup_sid(DOM_SID *sid, fstring dom_name, fstring name, + uint8 *name_type) +{ + struct winbindd_request request; + struct winbindd_response response; + enum winbindd_result result; + DOM_SID tmp_sid; + uint32 rid; + fstring sid_str; + + if (!name_type) return False; + + /* Check if this is our own sid. This should perhaps be done by + winbind? For the moment handle it here. */ + + sid_to_string(sid_str, sid); + DEBUG(0, ("*** looking up sid %s\n", sid_str)); + + if (sid->num_auths == 5) { + sid_copy(&tmp_sid, sid); + sid_split_rid(&tmp_sid, &rid); + + if (sid_equal(&global_sam_sid, &tmp_sid)) { + + sid_to_string(sid_str, &tmp_sid); + DEBUG(0, ("*** split up sid %s with rid %d\n", sid_str, + rid)); + + sid_to_string(sid_str, &global_sam_sid); + DEBUG(0, ("*** my sid is %s\n", sid_str)); + + return map_domain_sid_to_name(&tmp_sid, dom_name) && + lookup_local_rid(rid, name, name_type); + } + } + + DEBUG(0, ("*** calling winbindd\n")); + + /* Initialise request */ + + ZERO_STRUCT(request); + ZERO_STRUCT(response); + + sid_to_string(sid_str, sid); + fstrcpy(request.data.sid, sid_str); + + /* Make request */ + + result = generic_request(WINBINDD_LOOKUPSID, &request, &response); + + /* Copy out result */ + + if (result == WINBINDD_OK) { + parse_domain_user(response.data.name.name, dom_name, name); + *name_type = response.data.name.type; + } + + return (result == WINBINDD_OK); +} + /*************************************************************************** Init lsa_trans_names. ***************************************************************************/ @@ -286,7 +348,6 @@ static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, static void init_lsa_trans_names(DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, int num_entries, DOM_SID2 sid[MAX_LOOKUP_SIDS], uint32 *mapped_count) { - extern DOM_SID global_sid_S_1_5_0x20; /* BUILTIN sid. */ int i; int total = 0; *mapped_count = 0; @@ -298,44 +359,29 @@ static void init_lsa_trans_names(DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, DOM_SID find_sid = sid[i].sid; uint32 rid = 0xffffffff; int dom_idx = -1; - fstring name; - fstring dom_name; + fstring name, dom_name; uint8 sid_name_use = 0; + /* Lookup sid from winbindd */ + memset(dom_name, '\0', sizeof(dom_name)); memset(name, '\0', sizeof(name)); - /* - * First, check to see if the SID is one of the well - * known ones (this includes our own domain SID). - * Next, check if the domain prefix is one of the - * well known ones. If so and the domain prefix was - * either BUILTIN or our own global sid, then lookup - * the RID as a user or group id and translate to - * a name. - */ + status = winbind_lookup_sid(&find_sid, dom_name, name, + &sid_name_use); - if (map_domain_sid_to_name(&find_sid, dom_name)) { - sid_name_use = SID_NAME_DOMAIN; - } else if (sid_split_rid(&find_sid, &rid) && map_domain_sid_to_name(&find_sid, dom_name)) { - if (sid_equal(&find_sid, &global_sam_sid) || - sid_equal(&find_sid, &global_sid_S_1_5_0x20)) { - status = lookup_local_rid(rid, name, &sid_name_use); - } else { - status = lookup_known_rid(&find_sid, rid, name, &sid_name_use); - } + if (!status) { + sid_name_use = SID_NAME_UNKNOWN; } - DEBUG(10,("init_lsa_trans_names: adding domain '%s' sid %s to referenced list.\n", - dom_name, name )); - - dom_idx = init_dom_ref(ref, dom_name, &find_sid); + /* Store domain sid in ref array */ - if(!status) { - slprintf(name, sizeof(name)-1, "unix.%08x", rid); - sid_name_use = SID_NAME_UNKNOWN; + if (find_sid.num_auths == 5) { + sid_split_rid(&find_sid, &rid); } + dom_idx = init_dom_ref(ref, dom_name, &find_sid); + DEBUG(10,("init_lsa_trans_names: added user '%s\\%s' to referenced list.\n", dom_name, name )); (*mapped_count)++; -- cgit From 2c3cd9ecba363d78bed2d7c67c17b40204f8a64a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 15 Jun 2000 02:26:54 +0000 Subject: Removed some debugs. (This used to be commit 6faa963b232b4c4d883c1b346c73b2f2b6da6370) --- source3/rpc_server/srv_lsa.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 047c02eb3e..f132e4b39b 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -296,29 +296,17 @@ static BOOL winbind_lookup_sid(DOM_SID *sid, fstring dom_name, fstring name, /* Check if this is our own sid. This should perhaps be done by winbind? For the moment handle it here. */ - sid_to_string(sid_str, sid); - DEBUG(0, ("*** looking up sid %s\n", sid_str)); - if (sid->num_auths == 5) { sid_copy(&tmp_sid, sid); sid_split_rid(&tmp_sid, &rid); if (sid_equal(&global_sam_sid, &tmp_sid)) { - sid_to_string(sid_str, &tmp_sid); - DEBUG(0, ("*** split up sid %s with rid %d\n", sid_str, - rid)); - - sid_to_string(sid_str, &global_sam_sid); - DEBUG(0, ("*** my sid is %s\n", sid_str)); - return map_domain_sid_to_name(&tmp_sid, dom_name) && lookup_local_rid(rid, name, name_type); } } - DEBUG(0, ("*** calling winbindd\n")); - /* Initialise request */ ZERO_STRUCT(request); -- cgit From a72f277f721903d504fc8501de55bf8c07801e05 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 16 Jun 2000 08:11:32 +0000 Subject: Simplified server pipe implementation by changing arguments passed down through to the individual pipe api calls. Instead of passing two prs_struct pointers, we now pass the pipes_struct pointer which contains the former information as well as other useful stuff like the vuid. (This used to be commit 96addba216bad2189120d78f5531d5caa6f37880) --- source3/rpc_server/srv_dfs.c | 184 +++++++++++++++++++++------------------- source3/rpc_server/srv_lsa.c | 44 +++++++--- source3/rpc_server/srv_pipe.c | 12 +-- source3/rpc_server/srv_reg.c | 20 +++-- source3/rpc_server/srv_samr.c | 122 +++++++++++++++++--------- source3/rpc_server/srv_srvsvc.c | 39 +++++---- source3/rpc_server/srv_wkssvc.c | 8 +- 7 files changed, 259 insertions(+), 170 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 2a8bb71604..62acbaa6cc 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -1,4 +1,3 @@ - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -35,17 +34,18 @@ extern pstring global_myname; /********************************************************************** api_dfs_exist **********************************************************************/ -static BOOL api_dfs_exist( prs_struct *data, - prs_struct *rdata) +static BOOL api_dfs_exist(pipes_struct *p) { - DFS_R_DFS_EXIST r_d; - - if(lp_host_msdfs()) - r_d.dfs_exist_flag = 1; - else - r_d.dfs_exist_flag = 0; - - return dfs_io_r_dfs_exist("", &r_d, rdata, 0); + DFS_R_DFS_EXIST r_d; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + if(lp_host_msdfs()) + r_d.dfs_exist_flag = 1; + else + r_d.dfs_exist_flag = 0; + + return dfs_io_r_dfs_exist("", &r_d, rdata, 0); } static uint32 init_reply_dfs_add(DFS_Q_DFS_ADD* q_a) @@ -109,19 +109,21 @@ static uint32 init_reply_dfs_add(DFS_Q_DFS_ADD* q_a) /***************************************************************** api_dfs_add *****************************************************************/ -static BOOL api_dfs_add(prs_struct* data, prs_struct* rdata) +static BOOL api_dfs_add(pipes-struct *p) { - DFS_Q_DFS_ADD q_a; - DFS_R_DFS_ADD r_a; - - if(!dfs_io_q_dfs_add("", &q_a, data, 0)) - return False; - - r_a.status = init_reply_dfs_add(&q_a); - - dfs_io_r_dfs_add("", &r_a, rdata, 0); - - return True; + DFS_Q_DFS_ADD q_a; + DFS_R_DFS_ADD r_a; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + if(!dfs_io_q_dfs_add("", &q_a, data, 0)) + return False; + + r_a.status = init_reply_dfs_add(&q_a); + + dfs_io_r_dfs_add("", &r_a, rdata, 0); + + return True; } static uint32 init_reply_dfs_remove(DFS_Q_DFS_REMOVE* q_r) @@ -198,19 +200,19 @@ static uint32 init_reply_dfs_remove(DFS_Q_DFS_REMOVE* q_r) /***************************************************************** api_dfs_remove *****************************************************************/ -static BOOL api_dfs_remove(prs_struct* data, prs_struct* rdata) +static BOOL api_dfs_remove(pipes_struct *p) { - DFS_Q_DFS_REMOVE q_r; - DFS_R_DFS_REMOVE r_r; - - if(!dfs_io_q_dfs_remove("", &q_r, data, 0)) - return False; - - r_r.status = init_reply_dfs_remove(&q_r); - - dfs_io_r_dfs_remove("", &r_r, rdata, 0); - - return True; + DFS_Q_DFS_REMOVE q_r; + DFS_R_DFS_REMOVE r_r; + + if(!dfs_io_q_dfs_remove("", &q_r, data, 0)) + return False; + + r_r.status = init_reply_dfs_remove(&q_r); + + dfs_io_r_dfs_remove("", &r_r, rdata, 0); + + return True; } static BOOL init_reply_dfs_info_1(struct junction_map* j, DFS_INFO_1* dfs1, int num_j) @@ -377,59 +379,63 @@ static uint32 init_reply_dfs_get_info(UNISTR2* uni_path, uint32 level, /******************************************************************* api_dfs_get_info *******************************************************************/ -static BOOL api_dfs_get_info(prs_struct* data, prs_struct* rdata) +static BOOL api_dfs_get_info(pipes_struct *p) { - DFS_Q_DFS_GET_INFO q_i; - DFS_R_DFS_GET_INFO r_i; - - ZERO_STRUCT(r_i); - - if(!dfs_io_q_dfs_get_info("", &q_i, data, 0)) - return False; - - r_i.status = init_reply_dfs_get_info(&q_i.uni_path, q_i.level, &r_i); - - if(!dfs_io_r_dfs_get_info("", &r_i, rdata, 0)) - return False; - - switch(r_i.level) { - case 1: free(r_i.ctr.dfs.info1); break; - case 2: free(r_i.ctr.dfs.info2); break; - case 3: - { - free(r_i.ctr.dfs.info3->storages); - free(r_i.ctr.dfs.info3); - break; - } - } - return True; + DFS_Q_DFS_GET_INFO q_i; + DFS_R_DFS_GET_INFO r_i; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(r_i); + + if(!dfs_io_q_dfs_get_info("", &q_i, data, 0)) + return False; + + r_i.status = init_reply_dfs_get_info(&q_i.uni_path, q_i.level, &r_i); + + if(!dfs_io_r_dfs_get_info("", &r_i, rdata, 0)) + return False; + + switch(r_i.level) { + case 1: free(r_i.ctr.dfs.info1); break; + case 2: free(r_i.ctr.dfs.info2); break; + case 3: { + free(r_i.ctr.dfs.info3->storages); + free(r_i.ctr.dfs.info3); + break; + } + } + return True; } /******************************************************************* api_dfs_enum *******************************************************************/ -static BOOL api_dfs_enum(prs_struct* data, prs_struct* rdata) +static BOOL api_dfs_enum(pipes_struct *p) { - DFS_Q_DFS_ENUM q_e; - DFS_R_DFS_ENUM q_r; - - if(!dfs_io_q_dfs_enum("", &q_e, data, 0)) - return False; - - q_r.status = init_reply_dfs_enum(q_e.level, &q_r); - - if(!dfs_io_r_dfs_enum("", &q_r, rdata, 0)) - return False; - switch(q_e.level) { - case 1: - free(q_r.ctr->dfs.info1); break; - case 2: - free(q_r.ctr->dfs.info2); break; - case 3: - free(q_r.ctr->dfs.info3->storages); free(q_r.ctr->dfs.info3); break; - } - free(q_r.ctr); - return True; + DFS_Q_DFS_ENUM q_e; + DFS_R_DFS_ENUM q_r; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + if(!dfs_io_q_dfs_enum("", &q_e, data, 0)) + return False; + + q_r.status = init_reply_dfs_enum(q_e.level, &q_r); + + if(!dfs_io_r_dfs_enum("", &q_r, rdata, 0)) + return False; + switch(q_e.level) { + case 1: + free(q_r.ctr->dfs.info1); break; + case 2: + free(q_r.ctr->dfs.info2); break; + case 3: + free(q_r.ctr->dfs.info3->storages); + free(q_r.ctr->dfs.info3); break; + } + free(q_r.ctr); + return True; } /******************************************************************* @@ -437,20 +443,20 @@ static BOOL api_dfs_enum(prs_struct* data, prs_struct* rdata) ********************************************************************/ struct api_struct api_netdfs_cmds[] = { - {"DFS_EXIST", DFS_EXIST, api_dfs_exist }, - {"DFS_ADD", DFS_ADD, api_dfs_add }, - {"DFS_REMOVE", DFS_REMOVE, api_dfs_remove }, - {"DFS_GET_INFO", DFS_GET_INFO, api_dfs_get_info }, - {"DFS_ENUM", DFS_ENUM, api_dfs_enum }, - {NULL, 0, NULL } + {"DFS_EXIST", DFS_EXIST, api_dfs_exist }, + {"DFS_ADD", DFS_ADD, api_dfs_add }, + {"DFS_REMOVE", DFS_REMOVE, api_dfs_remove }, + {"DFS_GET_INFO", DFS_GET_INFO, api_dfs_get_info }, + {"DFS_ENUM", DFS_ENUM, api_dfs_enum }, + {NULL, 0, NULL } }; /******************************************************************* receives a netdfs pipe and responds. ********************************************************************/ -BOOL api_netdfs_rpc(pipes_struct *p, prs_struct *data) +BOOL api_netdfs_rpc(pipes_struct *p) { - return api_rpcTNP(p, "api_netdfs_rpc", api_netdfs_cmds, data); + return api_rpcTNP(p, "api_netdfs_rpc", api_netdfs_cmds); } #endif diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index f132e4b39b..7df7686878 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -281,8 +281,8 @@ static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, /* Call winbindd to convert sid to name */ -static BOOL winbind_lookup_sid(DOM_SID *sid, fstring dom_name, fstring name, - uint8 *name_type) +BOOL winbind_lookup_sid(DOM_SID *sid, fstring dom_name, fstring name, + uint8 *name_type) { struct winbindd_request request; struct winbindd_response response; @@ -464,8 +464,11 @@ static BOOL lsa_reply_lookup_names(prs_struct *rdata, api_lsa_open_policy2 ***************************************************************************/ -static BOOL api_lsa_open_policy2(prs_struct *data, prs_struct *rdata) +static BOOL api_lsa_open_policy2(pipes_struct *p) { + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + LSA_Q_OPEN_POL2 q_o; ZERO_STRUCT(q_o); @@ -488,8 +491,11 @@ static BOOL api_lsa_open_policy2(prs_struct *data, prs_struct *rdata) /*************************************************************************** api_lsa_open_policy ***************************************************************************/ -static BOOL api_lsa_open_policy(prs_struct *data, prs_struct *rdata) +static BOOL api_lsa_open_policy(pipes_struct *p) { + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + LSA_Q_OPEN_POL q_o; ZERO_STRUCT(q_o); @@ -512,9 +518,11 @@ static BOOL api_lsa_open_policy(prs_struct *data, prs_struct *rdata) /*************************************************************************** api_lsa_enum_trust_dom ***************************************************************************/ -static BOOL api_lsa_enum_trust_dom(prs_struct *data, prs_struct *rdata) +static BOOL api_lsa_enum_trust_dom(pipes_struct *p) { LSA_Q_ENUM_TRUST_DOM q_e; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_e); @@ -531,13 +539,15 @@ static BOOL api_lsa_enum_trust_dom(prs_struct *data, prs_struct *rdata) /*************************************************************************** api_lsa_query_info ***************************************************************************/ -static BOOL api_lsa_query_info(prs_struct *data, prs_struct *rdata) +static BOOL api_lsa_query_info(pipes_struct *p) { LSA_Q_QUERY_INFO q_i; DOM_SID domain_sid; char *name = NULL; DOM_SID *sid = NULL; uint32 status_code = 0; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_i); @@ -588,9 +598,12 @@ static BOOL api_lsa_query_info(prs_struct *data, prs_struct *rdata) api_lsa_lookup_sids ***************************************************************************/ -static BOOL api_lsa_lookup_sids(prs_struct *data, prs_struct *rdata) +static BOOL api_lsa_lookup_sids(pipes_struct *p) { LSA_Q_LOOKUP_SIDS q_l; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_l); /* grab the info class and policy handle */ @@ -610,9 +623,12 @@ static BOOL api_lsa_lookup_sids(prs_struct *data, prs_struct *rdata) api_lsa_lookup_names ***************************************************************************/ -static BOOL api_lsa_lookup_names(prs_struct *data, prs_struct *rdata) +static BOOL api_lsa_lookup_names(pipes_struct *p) { LSA_Q_LOOKUP_NAMES q_l; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_l); /* grab the info class and policy handle */ @@ -629,9 +645,11 @@ static BOOL api_lsa_lookup_names(prs_struct *data, prs_struct *rdata) /*************************************************************************** api_lsa_close ***************************************************************************/ -static BOOL api_lsa_close(prs_struct *data, prs_struct *rdata) +static BOOL api_lsa_close(pipes_struct *p) { LSA_R_CLOSE r_c; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(r_c); @@ -647,11 +665,13 @@ static BOOL api_lsa_close(prs_struct *data, prs_struct *rdata) /*************************************************************************** api_lsa_open_secret ***************************************************************************/ -static BOOL api_lsa_open_secret(prs_struct *data, prs_struct *rdata) +static BOOL api_lsa_open_secret(pipes_struct *p) { /* XXXX this is NOT good */ size_t i; uint32 dummy = 0; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; for(i =0; i < 4; i++) { if(!prs_uint32("api_lsa_close", rdata, 1, &dummy)) { @@ -689,9 +709,9 @@ static struct api_struct api_lsa_cmds[] = /*************************************************************************** api_ntLsarpcTNP ***************************************************************************/ -BOOL api_ntlsa_rpc(pipes_struct *p, prs_struct *data) +BOOL api_ntlsa_rpc(pipes_struct *p) { - return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds, data); + return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds); } #undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 11dc5a2f89..46cb521018 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -462,7 +462,7 @@ struct api_cmd { char * pipe_clnt_name; char * pipe_srv_name; - BOOL (*fn) (pipes_struct *, prs_struct *); + BOOL (*fn) (pipes_struct *); }; static struct api_cmd api_fd_commands[] = @@ -1116,7 +1116,7 @@ BOOL api_pipe_request(pipes_struct *p) if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && api_fd_commands[i].fn != NULL) { DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i].pipe_clnt_name)); - ret = api_fd_commands[i].fn(p, &p->in_data.data); + ret = api_fd_commands[i].fn(p); } } @@ -1130,8 +1130,8 @@ BOOL api_pipe_request(pipes_struct *p) Calls the underlying RPC function for a named pipe. ********************************************************************/ -BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds, - prs_struct *rpc_in) +BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, + struct api_struct *api_rpc_cmds) { int fn_num; fstring name; @@ -1141,7 +1141,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds DEBUG(4,("api_rpcTNP: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); slprintf(name, sizeof(name), "in_%s", rpc_name); - prs_dump(name, p->hdr_req.opnum, rpc_in); + prs_dump(name, p->hdr_req.opnum, &p->in_data.data); for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) { if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) { @@ -1164,7 +1164,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, struct api_struct *api_rpc_cmds offset1 = prs_offset(&p->out_data.rdata); /* do the actual command */ - if(!api_rpc_cmds[fn_num].fn(rpc_in, &p->out_data.rdata)) { + if(!api_rpc_cmds[fn_num].fn(p)) { DEBUG(0,("api_rpcTNP: %s: failed.\n", rpc_name)); prs_mem_free(&p->out_data.rdata); return False; diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index ca3911121f..dd411fc55e 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -60,9 +60,11 @@ static void reg_reply_close(REG_Q_CLOSE *q_r, /******************************************************************* api_reg_close ********************************************************************/ -static BOOL api_reg_close(prs_struct *data, prs_struct *rdata ) +static BOOL api_reg_close(pipes_struct *p) { REG_Q_CLOSE q_r; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the reg unknown 1 */ reg_io_q_close("", &q_r, data, 0); @@ -100,9 +102,11 @@ static void reg_reply_open(REG_Q_OPEN_HKLM *q_r, /******************************************************************* api_reg_open ********************************************************************/ -static BOOL api_reg_open(prs_struct *data, prs_struct *rdata ) +static BOOL api_reg_open(pipes_struct *p) { REG_Q_OPEN_HKLM q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the reg open */ reg_io_q_open_hklm("", &q_u, data, 0); @@ -165,9 +169,11 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, /******************************************************************* api_reg_open_entry ********************************************************************/ -static BOOL api_reg_open_entry(prs_struct *data, prs_struct *rdata ) +static BOOL api_reg_open_entry(pipes_struct *p) { REG_Q_OPEN_ENTRY q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the reg open entry */ reg_io_q_open_entry("", &q_u, data, 0); @@ -237,9 +243,11 @@ static void reg_reply_info(REG_Q_INFO *q_u, /******************************************************************* api_reg_info ********************************************************************/ -static BOOL api_reg_info(prs_struct *data, prs_struct *rdata ) +static BOOL api_reg_info(pipes_struct *p) { REG_Q_INFO q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the reg unknown 0x11*/ reg_io_q_info("", &q_u, data, 0); @@ -266,8 +274,8 @@ static struct api_struct api_reg_cmds[] = /******************************************************************* receives a reg pipe and responds. ********************************************************************/ -BOOL api_reg_rpc(pipes_struct *p, prs_struct *data) +BOOL api_reg_rpc(pipes_struct *p) { - return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds, data); + return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds); } #undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 49db7a9e48..3ea0ba4615 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -365,9 +365,11 @@ static BOOL samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, /******************************************************************* api_samr_close_hnd ********************************************************************/ -static BOOL api_samr_close_hnd(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_close_hnd(pipes_struct *p) { SAMR_Q_CLOSE_HND q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr unknown 1 */ if(!samr_io_q_close_hnd("", &q_u, data, 0)) @@ -430,9 +432,11 @@ static BOOL samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, /******************************************************************* api_samr_open_domain ********************************************************************/ -static BOOL api_samr_open_domain(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_open_domain(pipes_struct *p) { SAMR_Q_OPEN_DOMAIN q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr open */ if(!samr_io_q_open_domain("", &q_u, data, 0)) @@ -483,9 +487,11 @@ static BOOL samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, /******************************************************************* api_samr_unknown_2c ********************************************************************/ -static BOOL api_samr_unknown_2c(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_2c(pipes_struct *p) { SAMR_Q_UNKNOWN_2C q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr open */ if(!samr_io_q_unknown_2c("", &q_u, data, 0)) @@ -565,9 +571,11 @@ static BOOL samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, /******************************************************************* api_samr_unknown_3 ********************************************************************/ -static BOOL api_samr_unknown_3(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_3(pipes_struct *p) { SAMR_Q_UNKNOWN_3 q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr open */ if(!samr_io_q_unknown_3("", &q_u, data, 0)) @@ -623,9 +631,11 @@ static BOOL samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, /******************************************************************* api_samr_enum_dom_users ********************************************************************/ -static BOOL api_samr_enum_dom_users(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_enum_dom_users(pipes_struct *p) { SAMR_Q_ENUM_DOM_USERS q_e; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr open */ if(!samr_io_q_enum_dom_users("", &q_e, data, 0)) @@ -684,9 +694,11 @@ static BOOL samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, /******************************************************************* api_samr_enum_dom_groups ********************************************************************/ -static BOOL api_samr_enum_dom_groups(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_enum_dom_groups(pipes_struct *p) { SAMR_Q_ENUM_DOM_GROUPS q_e; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr open */ if(!samr_io_q_enum_dom_groups("", &q_e, data, 0)) @@ -899,9 +911,11 @@ static BOOL samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, prs_struct *rd /******************************************************************* api_samr_query_dispinfo ********************************************************************/ -static BOOL api_samr_query_dispinfo(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_query_dispinfo(pipes_struct *p) { SAMR_Q_QUERY_DISPINFO q_e; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr open */ if(!samr_io_q_query_dispinfo("", &q_e, data, 0)) @@ -960,9 +974,11 @@ static BOOL samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, /******************************************************************* api_samr_query_aliasinfo ********************************************************************/ -static BOOL api_samr_query_aliasinfo(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_query_aliasinfo(pipes_struct *p) { SAMR_Q_QUERY_ALIASINFO q_e; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr open */ if(!samr_io_q_query_aliasinfo("", &q_e, data, 0)) @@ -1043,9 +1059,11 @@ static BOOL samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, /******************************************************************* api_samr_lookup_ids ********************************************************************/ -static BOOL api_samr_lookup_ids(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_lookup_ids(pipes_struct *p) { SAMR_Q_LOOKUP_IDS q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr 0x10 */ if(!samr_io_q_lookup_ids("", &q_u, data, 0)) @@ -1136,9 +1154,11 @@ static BOOL samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, api_samr_lookup_names ********************************************************************/ -static BOOL api_samr_lookup_names(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_lookup_names(pipes_struct *p) { SAMR_Q_LOOKUP_NAMES q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; memset(&q_u, '\0', sizeof(q_u)); @@ -1195,9 +1215,11 @@ static BOOL samr_reply_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u, api_samr_chgpasswd_user ********************************************************************/ -static BOOL api_samr_chgpasswd_user(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_chgpasswd_user(pipes_struct *p) { SAMR_Q_CHGPASSWD_USER q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* unknown 38 command */ if (!samr_io_q_chgpasswd_user("", &q_u, data, 0)) { @@ -1237,9 +1259,11 @@ static BOOL samr_reply_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, prs_struct *rdata) /******************************************************************* api_samr_unknown_38 ********************************************************************/ -static BOOL api_samr_unknown_38(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_38(pipes_struct *p) { SAMR_Q_UNKNOWN_38 q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* unknown 38 command */ if(!samr_io_q_unknown_38("", &q_u, data, 0)) @@ -1304,9 +1328,11 @@ static BOOL samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, /******************************************************************* api_samr_unknown_12 ********************************************************************/ -static BOOL api_samr_unknown_12(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_12(pipes_struct *p) { SAMR_Q_UNKNOWN_12 q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr lookup names */ if(!samr_io_q_unknown_12("", &q_u, data, 0)) @@ -1382,9 +1408,11 @@ static BOOL samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, prs_struct *rdata, int s /******************************************************************* api_samr_open_user ********************************************************************/ -static BOOL api_samr_open_user(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_open_user(pipes_struct *p) { SAMR_Q_OPEN_USER q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr unknown 22 */ if(!samr_io_q_open_user("", &q_u, data, 0)) @@ -1591,9 +1619,11 @@ static BOOL samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, /******************************************************************* api_samr_query_userinfo ********************************************************************/ -static BOOL api_samr_query_userinfo(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_query_userinfo(pipes_struct *p) { SAMR_Q_QUERY_USERINFO q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr unknown 24 */ if(!samr_io_q_query_userinfo("", &q_u, data, 0)) @@ -1676,9 +1706,12 @@ static BOOL samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, /******************************************************************* api_samr_query_usergroups ********************************************************************/ -static BOOL api_samr_query_usergroups(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_query_usergroups(pipes_struct *p) { SAMR_Q_QUERY_USERGROUPS q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + /* grab the samr unknown 32 */ if(!samr_io_q_query_usergroups("", &q_u, data, 0)) return False; @@ -1748,9 +1781,11 @@ static BOOL samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, prs_struct /******************************************************************* api_samr_query_dom_info ********************************************************************/ -static BOOL api_samr_query_dom_info(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_query_dom_info(pipes_struct *p) { SAMR_Q_QUERY_DOMAIN_INFO q_e; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr unknown 8 command */ if(!samr_io_q_query_dom_info("", &q_e, data, 0)) @@ -1800,11 +1835,13 @@ static BOOL samr_reply_unknown_32(SAMR_Q_UNKNOWN_32 *q_u, /******************************************************************* api_samr_unknown_32 ********************************************************************/ -static BOOL api_samr_unknown_32(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_unknown_32(pipes_struct *p) { uint32 status = 0; struct sam_passwd *sam_pass; fstring mach_acct; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; SAMR_Q_UNKNOWN_32 q_u; @@ -1887,9 +1924,11 @@ static BOOL samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, prs_struct *rdata) /******************************************************************* api_samr_connect_anon ********************************************************************/ -static BOOL api_samr_connect_anon(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_connect_anon(pipes_struct *p) { SAMR_Q_CONNECT_ANON q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr open policy */ if(!samr_io_q_connect_anon("", &q_u, data, 0)) @@ -1945,9 +1984,11 @@ static BOOL samr_reply_connect(SAMR_Q_CONNECT *q_u, prs_struct *rdata) /******************************************************************* api_samr_connect ********************************************************************/ -static BOOL api_samr_connect(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_connect(pipes_struct *p) { SAMR_Q_CONNECT q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr open policy */ if(!samr_io_q_connect("", &q_u, data, 0)) @@ -1989,17 +2030,19 @@ static BOOL samr_reply_lookup_domain(SAMR_Q_LOOKUP_DOMAIN* q_u, prs_struct* rdat /********************************************************************** api_samr_lookup_domain **********************************************************************/ -static BOOL api_samr_lookup_domain(prs_struct* data, prs_struct* rdata) +static BOOL api_samr_lookup_domain(pipes_struct *p) { - SAMR_Q_LOOKUP_DOMAIN q_u; + SAMR_Q_LOOKUP_DOMAIN q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - if(!samr_io_q_lookup_domain("", &q_u, data, 0)) + if(!samr_io_q_lookup_domain("", &q_u, data, 0)) return False; - - if(!samr_reply_lookup_domain(&q_u, rdata)) + + if(!samr_reply_lookup_domain(&q_u, rdata)) return False; - - return True; + + return True; } /********************************************************************** @@ -2030,17 +2073,19 @@ static BOOL samr_reply_enum_domains(SAMR_Q_ENUM_DOMAINS* q_u, prs_struct* rdata) /********************************************************************** api_samr_enum_domains **********************************************************************/ -static BOOL api_samr_enum_domains(prs_struct* data, prs_struct* rdata) +static BOOL api_samr_enum_domains(pipes_struct *p) { - SAMR_Q_ENUM_DOMAINS q_u; + SAMR_Q_ENUM_DOMAINS q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - if(!samr_io_q_enum_domains("", &q_u, data, 0)) + if(!samr_io_q_enum_domains("", &q_u, data, 0)) return False; - - if(!samr_reply_enum_domains(&q_u, rdata)) + + if(!samr_reply_enum_domains(&q_u, rdata)) return False; - - return True; + + return True; } /******************************************************************* @@ -2086,10 +2131,11 @@ static BOOL samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, prs_struct *rdata) /******************************************************************* api_samr_open_alias ********************************************************************/ -static BOOL api_samr_open_alias(prs_struct *data, prs_struct *rdata) - +static BOOL api_samr_open_alias(pipes_struct *p) { SAMR_Q_OPEN_ALIAS q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr open policy */ if(!samr_io_q_open_alias("", &q_u, data, 0)) @@ -2137,8 +2183,8 @@ static struct api_struct api_samr_cmds [] = /******************************************************************* receives a samr pipe and responds. ********************************************************************/ -BOOL api_samr_rpc(pipes_struct *p, prs_struct *data) +BOOL api_samr_rpc(pipes_struct *p) { - return api_rpcTNP(p, "api_samr_rpc", api_samr_cmds, data); + return api_rpcTNP(p, "api_samr_rpc", api_samr_cmds); } #undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 2e8d33d4d2..34f369bc8b 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -926,10 +926,11 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, /******************************************************************* ********************************************************************/ -static BOOL api_srv_net_srv_get_info(prs_struct *data, - prs_struct *rdata ) +static BOOL api_srv_net_srv_get_info(pipes_struct *p) { SRV_Q_NET_SRV_GET_INFO q_n; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the net server get info */ srv_io_q_net_srv_get_info("", &q_n, data, 0); @@ -943,11 +944,12 @@ static BOOL api_srv_net_srv_get_info(prs_struct *data, /******************************************************************* ********************************************************************/ -static BOOL api_srv_net_file_enum(prs_struct *data, - prs_struct *rdata ) +static BOOL api_srv_net_file_enum(pipes_struct *p) { SRV_Q_NET_FILE_ENUM q_n; SRV_FILE_INFO_CTR ctr; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; q_n.ctr = &ctr; @@ -963,11 +965,12 @@ static BOOL api_srv_net_file_enum(prs_struct *data, /******************************************************************* ********************************************************************/ -static BOOL api_srv_net_conn_enum(prs_struct *data, - prs_struct *rdata ) +static BOOL api_srv_net_conn_enum(pipes_struct *p) { SRV_Q_NET_CONN_ENUM q_n; SRV_CONN_INFO_CTR ctr; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; q_n.ctr = &ctr; @@ -983,11 +986,12 @@ static BOOL api_srv_net_conn_enum(prs_struct *data, /******************************************************************* ********************************************************************/ -static BOOL api_srv_net_sess_enum(prs_struct *data, - prs_struct *rdata ) +static BOOL api_srv_net_sess_enum(pipes_struct *p) { SRV_Q_NET_SESS_ENUM q_n; SRV_SESS_INFO_CTR ctr; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; q_n.ctr = &ctr; @@ -1005,11 +1009,12 @@ static BOOL api_srv_net_sess_enum(prs_struct *data, RPC to enumerate shares. ********************************************************************/ -static BOOL api_srv_net_share_enum(prs_struct *data, - prs_struct *rdata ) +static BOOL api_srv_net_share_enum(pipes_struct *p) { SRV_Q_NET_SHARE_ENUM q_n; BOOL ret; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* Unmarshall the net server get enum. */ if(!srv_io_q_net_share_enum("", &q_n, data, 0)) { @@ -1029,11 +1034,12 @@ static BOOL api_srv_net_share_enum(prs_struct *data, RPC to return share information. ********************************************************************/ -static BOOL api_srv_net_share_get_info(prs_struct *data, - prs_struct *rdata ) +static BOOL api_srv_net_share_get_info(pipes_struct *p) { SRV_Q_NET_SHARE_GET_INFO q_n; BOOL ret; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* Unmarshall the net server get info. */ if(!srv_io_q_net_share_get_info("", &q_n, data, 0)) { @@ -1092,10 +1098,11 @@ static BOOL srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n, } /******************************************************************* ********************************************************************/ -static BOOL api_srv_net_remote_tod(prs_struct *data, - prs_struct *rdata ) +static BOOL api_srv_net_remote_tod(pipes_struct *p) { SRV_Q_NET_REMOTE_TOD q_n; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the net server get enum */ srv_io_q_net_remote_tod("", &q_n, data, 0); @@ -1125,9 +1132,9 @@ struct api_struct api_srv_cmds[] = /******************************************************************* receives a srvsvc pipe and responds. ********************************************************************/ -BOOL api_srvsvc_rpc(pipes_struct *p, prs_struct *data) +BOOL api_srvsvc_rpc(pipes_struct *p) { - return api_rpcTNP(p, "api_srvsvc_rpc", api_srv_cmds, data); + return api_rpcTNP(p, "api_srvsvc_rpc", api_srv_cmds); } #undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index a09250a80b..21e4f933f2 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -80,9 +80,11 @@ static BOOL wks_reply_query_info(WKS_Q_QUERY_INFO *q_u, /******************************************************************* api_wks_query_info ********************************************************************/ -static BOOL api_wks_query_info(prs_struct *data, prs_struct *rdata) +static BOOL api_wks_query_info(pipes_struct *p) { WKS_Q_QUERY_INFO q_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the net share enum */ if(!wks_io_q_query_info("", &q_u, data, 0)) @@ -108,9 +110,9 @@ struct api_struct api_wks_cmds[] = /******************************************************************* receives a wkssvc pipe and responds. ********************************************************************/ -BOOL api_wkssvc_rpc(pipes_struct *p, prs_struct *data) +BOOL api_wkssvc_rpc(pipes_struct *p) { - return api_rpcTNP(p, "api_wkssvc_rpc", api_wks_cmds, data); + return api_rpcTNP(p, "api_wkssvc_rpc", api_wks_cmds); } #undef OLD_NTDOMAIN -- cgit From ea2945881dcce1e6c204cba13c0da169d149cbb3 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 16 Jun 2000 08:12:23 +0000 Subject: Simplified server pipe implementation by changing arguments passed down through to the individual pipe api calls. Instead of passing two prs_struct pointers, we now pass the pipes_struct pointer which contains the former information as well as other useful stuff like the vuid. Removed dependency on extern current_user and fetch the vuid from the pipes_struct. (This used to be commit 1b06451fff11f54be7def4a427a1528bbb52f3d7) --- source3/rpc_server/srv_netlog.c | 47 +++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index a5aaffc174..80e9894b59 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -300,17 +300,17 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) return False; } -extern struct current_user current_user; /* To pick up vuid */ - /************************************************************************* api_net_req_chal: *************************************************************************/ -static BOOL api_net_req_chal(prs_struct *data, prs_struct *rdata) +static BOOL api_net_req_chal(pipes_struct *p) { NET_Q_REQ_CHAL q_r; uint32 status = 0x0; - uint16 vuid = current_user.vuid; + uint16 vuid = p->vuid; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; fstring mach_acct; fstring mach_name; @@ -368,11 +368,13 @@ static BOOL api_net_req_chal(prs_struct *data, prs_struct *rdata) api_net_auth_2: *************************************************************************/ -static BOOL api_net_auth_2(prs_struct *data, prs_struct *rdata) +static BOOL api_net_auth_2(pipes_struct *p) { - uint16 vuid = current_user.vuid; + uint16 vuid = p->vuid; NET_Q_AUTH_2 q_a; uint32 status = 0x0; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; DOM_CHAL srv_cred; UTIME srv_time; @@ -416,9 +418,9 @@ static BOOL api_net_auth_2(prs_struct *data, prs_struct *rdata) api_net_srv_pwset: *************************************************************************/ -static BOOL api_net_srv_pwset(prs_struct *data, prs_struct *rdata) +static BOOL api_net_srv_pwset(pipes_struct *p) { - uint16 vuid = current_user.vuid; + uint16 vuid = p->vuid; NET_Q_SRV_PWSET q_a; uint32 status = NT_STATUS_WRONG_PASSWORD|0xC0000000; DOM_CRED srv_cred; @@ -426,6 +428,8 @@ static BOOL api_net_srv_pwset(prs_struct *data, prs_struct *rdata) struct smb_passwd *smb_pass; BOOL ret; user_struct *vuser; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; if ((vuser = get_valid_user_struct(vuid)) == NULL) return False; @@ -498,13 +502,14 @@ static BOOL api_net_srv_pwset(prs_struct *data, prs_struct *rdata) api_net_sam_logoff: *************************************************************************/ -static BOOL api_net_sam_logoff(prs_struct *data, prs_struct *rdata) +static BOOL api_net_sam_logoff(pipes_struct *p) { - uint16 vuid = current_user.vuid; + uint16 vuid = p->vuid; NET_Q_SAM_LOGOFF q_l; NET_ID_INFO_CTR ctr; - DOM_CRED srv_cred; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; user_struct *vuser; @@ -633,9 +638,9 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, struct smb_passwd *smb_pass) api_net_sam_logon: *************************************************************************/ -static BOOL api_net_sam_logon(prs_struct *data, prs_struct *rdata) +static BOOL api_net_sam_logon(pipes_struct *p) { - uint16 vuid = current_user.vuid; + uint16 vuid = p->vuid; NET_Q_SAM_LOGON q_l; NET_ID_INFO_CTR ctr; NET_USER_INFO_3 usr_info; @@ -645,6 +650,8 @@ static BOOL api_net_sam_logon(prs_struct *data, prs_struct *rdata) UNISTR2 *uni_samlogon_user = NULL; fstring nt_username; struct passwd *pw; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; user_struct *vuser = NULL; @@ -862,9 +869,11 @@ static BOOL api_net_sam_logon(prs_struct *data, prs_struct *rdata) api_net_trust_dom_list: *************************************************************************/ -static BOOL api_net_trust_dom_list(prs_struct *data, prs_struct *rdata) +static BOOL api_net_trust_dom_list(pipes_struct *p) { NET_Q_TRUST_DOM_LIST q_t; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; char *trusted_domain = "test_domain"; @@ -896,9 +905,11 @@ static BOOL api_net_trust_dom_list(prs_struct *data, prs_struct *rdata) api_net_logon_ctrl2: *************************************************************************/ -static BOOL api_net_logon_ctrl2(prs_struct *data, prs_struct *rdata) +static BOOL api_net_logon_ctrl2(pipes_struct *p) { NET_Q_LOGON_CTRL2 q_l; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* lkclXXXX - guess what - absolutely no idea what these are! */ uint32 flags = 0x0; @@ -938,15 +949,15 @@ static struct api_struct api_net_cmds [] = { "NET_SAMLOGOFF" , NET_SAMLOGOFF , api_net_sam_logoff }, { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 }, { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, - { NULL , 0 , NULL } + { NULL , 0 , NULL } }; /******************************************************************* receives a netlogon pipe and responds. ********************************************************************/ -BOOL api_netlog_rpc(pipes_struct *p, prs_struct *data) +BOOL api_netlog_rpc(pipes_struct *p) { - return api_rpcTNP(p, "api_netlog_rpc", api_net_cmds, data); + return api_rpcTNP(p, "api_netlog_rpc", api_net_cmds); } #undef OLD_NTDOMAIN -- cgit From bc21403497c0694d22f8e8212b7efa1f17e415a7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 16 Jun 2000 08:15:01 +0000 Subject: Simplified server pipe implementation by changing arguments passed down through to the individual pipe api calls. Instead of passing two prs_struct pointers, we now pass the pipes_struct pointer which contains the former information as well as other useful stuff like the vuid. Pass the vuid from the pipes_struct down to the lower level spoolss functions to perform security checks. (This used to be commit f6436aacd631abeda60b87d671993f9e426cc684) --- source3/rpc_server/srv_spoolss.c | 148 ++++++++++++++++++++++++++++----------- 1 file changed, 108 insertions(+), 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index c259260385..61e5341c75 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -29,11 +29,13 @@ extern int DEBUGLEVEL; /******************************************************************** * api_spoolss_open_printer_ex ********************************************************************/ -static BOOL api_spoolss_open_printer_ex(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_open_printer_ex(pipes_struct *p) { SPOOL_Q_OPEN_PRINTER_EX q_u; SPOOL_R_OPEN_PRINTER_EX r_u; UNISTR2 *printername = NULL; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -67,10 +69,12 @@ static BOOL api_spoolss_open_printer_ex(prs_struct *data, prs_struct *rdata) * * called from the spoolss dispatcher ********************************************************************/ -static BOOL api_spoolss_getprinterdata(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_getprinterdata(pipes_struct *p) { SPOOL_Q_GETPRINTERDATA q_u; SPOOL_R_GETPRINTERDATA r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -100,10 +104,12 @@ static BOOL api_spoolss_getprinterdata(prs_struct *data, prs_struct *rdata) * * called from the spoolss dispatcher ********************************************************************/ -static BOOL api_spoolss_closeprinter(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_closeprinter(pipes_struct *p) { SPOOL_Q_CLOSEPRINTER q_u; SPOOL_R_CLOSEPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -129,10 +135,12 @@ static BOOL api_spoolss_closeprinter(prs_struct *data, prs_struct *rdata) * * called from the spoolss dispatcher ********************************************************************/ -static BOOL api_spoolss_deleteprinter(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_deleteprinter(pipes_struct *p) { SPOOL_Q_DELETEPRINTER q_u; SPOOL_R_DELETEPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -158,10 +166,12 @@ static BOOL api_spoolss_deleteprinter(prs_struct *data, prs_struct *rdata) * api_spoolss_rffpcnex * ReplyFindFirstPrinterChangeNotifyEx ********************************************************************/ -static BOOL api_spoolss_rffpcnex(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_rffpcnex(pipes_struct *p) { SPOOL_Q_RFFPCNEX q_u; SPOOL_R_RFFPCNEX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -190,10 +200,12 @@ static BOOL api_spoolss_rffpcnex(prs_struct *data, prs_struct *rdata) * called from the spoolss dispatcher * ********************************************************************/ -static BOOL api_spoolss_rfnpcnex(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_rfnpcnex(pipes_struct *p) { SPOOL_Q_RFNPCNEX q_u; SPOOL_R_RFNPCNEX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -227,10 +239,12 @@ static BOOL api_spoolss_rfnpcnex(prs_struct *data, prs_struct *rdata) * called from the spoolss dispatcher * ********************************************************************/ -static BOOL api_spoolss_enumprinters(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumprinters(pipes_struct *p) { SPOOL_Q_ENUMPRINTERS q_u; SPOOL_R_ENUMPRINTERS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -266,10 +280,12 @@ static BOOL api_spoolss_enumprinters(prs_struct *data, prs_struct *rdata) * called from the spoolss dispatcher * ********************************************************************/ -static BOOL api_spoolss_getprinter(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_getprinter(pipes_struct *p) { SPOOL_Q_GETPRINTER q_u; SPOOL_R_GETPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -305,10 +321,12 @@ static BOOL api_spoolss_getprinter(prs_struct *data, prs_struct *rdata) * called from the spoolss dispatcher * ********************************************************************/ -static BOOL api_spoolss_getprinterdriver2(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_getprinterdriver2(pipes_struct *p) { SPOOL_Q_GETPRINTERDRIVER2 q_u; SPOOL_R_GETPRINTERDRIVER2 r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -344,10 +362,12 @@ static BOOL api_spoolss_getprinterdriver2(prs_struct *data, prs_struct *rdata) * called from the spoolss dispatcher * ********************************************************************/ -static BOOL api_spoolss_startpageprinter(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_startpageprinter(pipes_struct *p) { SPOOL_Q_STARTPAGEPRINTER q_u; SPOOL_R_STARTPAGEPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -373,10 +393,12 @@ static BOOL api_spoolss_startpageprinter(prs_struct *data, prs_struct *rdata) * called from the spoolss dispatcher * ********************************************************************/ -static BOOL api_spoolss_endpageprinter(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_endpageprinter(pipes_struct *p) { SPOOL_Q_ENDPAGEPRINTER q_u; SPOOL_R_ENDPAGEPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -398,10 +420,12 @@ static BOOL api_spoolss_endpageprinter(prs_struct *data, prs_struct *rdata) /******************************************************************** ********************************************************************/ -static BOOL api_spoolss_startdocprinter(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_startdocprinter(pipes_struct *p) { SPOOL_Q_STARTDOCPRINTER q_u; SPOOL_R_STARTDOCPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -412,7 +436,7 @@ static BOOL api_spoolss_startdocprinter(prs_struct *data, prs_struct *rdata) } r_u.status = _spoolss_startdocprinter(&q_u.handle, - q_u.doc_info_container.level, + q_u.doc_info_container.level, p->vuid, &q_u.doc_info_container.docinfo, &r_u.jobid); @@ -427,10 +451,12 @@ static BOOL api_spoolss_startdocprinter(prs_struct *data, prs_struct *rdata) /******************************************************************** ********************************************************************/ -static BOOL api_spoolss_enddocprinter(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enddocprinter(pipes_struct *p) { SPOOL_Q_ENDDOCPRINTER q_u; SPOOL_R_ENDDOCPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -453,10 +479,12 @@ static BOOL api_spoolss_enddocprinter(prs_struct *data, prs_struct *rdata) /******************************************************************** ********************************************************************/ -static BOOL api_spoolss_writeprinter(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_writeprinter(pipes_struct *p) { SPOOL_Q_WRITEPRINTER q_u; SPOOL_R_WRITEPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -484,10 +512,12 @@ static BOOL api_spoolss_writeprinter(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_setprinter(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_setprinter(pipes_struct *p) { SPOOL_Q_SETPRINTER q_u; SPOOL_R_SETPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -499,7 +529,7 @@ static BOOL api_spoolss_setprinter(prs_struct *data, prs_struct *rdata) r_u.status = _spoolss_setprinter(&q_u.handle, q_u.level, &q_u.info, q_u.devmode_ctr, q_u.secdesc_ctr, - q_u.command); + q_u.command, p->vuid); if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n")); @@ -515,10 +545,12 @@ static BOOL api_spoolss_setprinter(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_fcpn(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_fcpn(pipes_struct *p) { SPOOL_Q_FCPN q_u; SPOOL_R_FCPN r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -541,10 +573,12 @@ static BOOL api_spoolss_fcpn(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addjob(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_addjob(pipes_struct *p) { SPOOL_Q_ADDJOB q_u; SPOOL_R_ADDJOB r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -576,10 +610,12 @@ static BOOL api_spoolss_addjob(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumjobs(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumjobs(pipes_struct *p) { SPOOL_Q_ENUMJOBS q_u; SPOOL_R_ENUMJOBS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -613,10 +649,12 @@ static BOOL api_spoolss_enumjobs(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_schedulejob(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_schedulejob(pipes_struct *p) { SPOOL_Q_SCHEDULEJOB q_u; SPOOL_R_SCHEDULEJOB r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -638,10 +676,12 @@ static BOOL api_spoolss_schedulejob(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_setjob(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_setjob(pipes_struct *p) { SPOOL_Q_SETJOB q_u; SPOOL_R_SETJOB r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -652,7 +692,7 @@ static BOOL api_spoolss_setjob(prs_struct *data, prs_struct *rdata) } r_u.status = _spoolss_setjob(&q_u.handle, q_u.jobid, - q_u.level, &q_u.ctr, q_u.command); + q_u.level, p->vuid, &q_u.ctr, q_u.command); if(!spoolss_io_r_setjob("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_setjob: unable to marshall SPOOL_R_SETJOB.\n")); @@ -665,10 +705,12 @@ static BOOL api_spoolss_setjob(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprinterdrivers(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p) { SPOOL_Q_ENUMPRINTERDRIVERS q_u; SPOOL_R_ENUMPRINTERDRIVERS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -702,10 +744,12 @@ static BOOL api_spoolss_enumprinterdrivers(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumforms(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumforms(pipes_struct *p) { SPOOL_Q_ENUMFORMS q_u; SPOOL_R_ENUMFORMS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -739,10 +783,12 @@ static BOOL api_spoolss_enumforms(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumports(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumports(pipes_struct *p) { SPOOL_Q_ENUMPORTS q_u; SPOOL_R_ENUMPORTS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -776,10 +822,12 @@ static BOOL api_spoolss_enumports(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addprinterex(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_addprinterex(pipes_struct *p) { SPOOL_Q_ADDPRINTEREX q_u; SPOOL_R_ADDPRINTEREX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -816,10 +864,12 @@ static BOOL api_spoolss_addprinterex(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addprinterdriver(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_addprinterdriver(pipes_struct *p) { SPOOL_Q_ADDPRINTERDRIVER q_u; SPOOL_R_ADDPRINTERDRIVER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -844,10 +894,12 @@ static BOOL api_spoolss_addprinterdriver(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_getprinterdriverdirectory(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_getprinterdriverdirectory(pipes_struct *p) { SPOOL_Q_GETPRINTERDRIVERDIR q_u; SPOOL_R_GETPRINTERDRIVERDIR r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -880,10 +932,12 @@ static BOOL api_spoolss_getprinterdriverdirectory(prs_struct *data, prs_struct * /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprinterdata(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumprinterdata(pipes_struct *p) { SPOOL_Q_ENUMPRINTERDATA q_u; SPOOL_R_ENUMPRINTERDATA r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -913,10 +967,12 @@ static BOOL api_spoolss_enumprinterdata(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_setprinterdata(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_setprinterdata(pipes_struct *p) { SPOOL_Q_SETPRINTERDATA q_u; - SPOOL_R_SETPRINTERDATA r_u; + SPOOL_R_SETPRINTERDATA r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -942,10 +998,12 @@ static BOOL api_spoolss_setprinterdata(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addform(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_addform(pipes_struct *p) { SPOOL_Q_ADDFORM q_u; SPOOL_R_ADDFORM r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -967,10 +1025,12 @@ static BOOL api_spoolss_addform(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_setform(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_setform(pipes_struct *p) { SPOOL_Q_SETFORM q_u; SPOOL_R_SETFORM r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -992,10 +1052,12 @@ static BOOL api_spoolss_setform(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprintprocessors(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumprintprocessors(pipes_struct *p) { SPOOL_Q_ENUMPRINTPROCESSORS q_u; SPOOL_R_ENUMPRINTPROCESSORS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -1028,10 +1090,12 @@ static BOOL api_spoolss_enumprintprocessors(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprintprocdatatypes(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumprintprocdatatypes(pipes_struct *p) { SPOOL_Q_ENUMPRINTPROCDATATYPES q_u; SPOOL_R_ENUMPRINTPROCDATATYPES r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -1064,10 +1128,12 @@ static BOOL api_spoolss_enumprintprocdatatypes(prs_struct *data, prs_struct *rda /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprintmonitors(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_enumprintmonitors(pipes_struct *p) { SPOOL_Q_ENUMPRINTMONITORS q_u; SPOOL_R_ENUMPRINTMONITORS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -1100,10 +1166,12 @@ static BOOL api_spoolss_enumprintmonitors(prs_struct *data, prs_struct *rdata) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_getjob(prs_struct *data, prs_struct *rdata) +static BOOL api_spoolss_getjob(pipes_struct *p) { SPOOL_Q_GETJOB q_u; SPOOL_R_GETJOB r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; if(!new_spoolss_allocate_buffer(&q_u.buffer)) return False; @@ -1175,9 +1243,9 @@ struct api_struct api_spoolss_cmds[] = /******************************************************************* receives a spoolss pipe and responds. ********************************************************************/ -BOOL api_spoolss_rpc(pipes_struct *p, prs_struct *data) +BOOL api_spoolss_rpc(pipes_struct *p) { - return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds, data); + return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds); } #undef OLD_NTDOMAIN -- cgit From e83ddf6e695f6d250c3ebbaa279a19f7f9484fb4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 16 Jun 2000 08:18:09 +0000 Subject: Simplified server pipe implementation by changing arguments passed down through to the individual pipe api calls. Instead of passing two prs_struct pointers, we now pass the pipes_struct pointer which contains the former information as well as other useful stuff like the vuid. Pass the vuid from the pipes_struct down to the lower level spoolss functions to perform security checks. ZERO_STRUCTP the info_2 structure before filling it. Free the device mode field before freeing the info_2 to avoid a memory leak. Fixed uninitialised pointer bug in fill_job_info_2(). (This used to be commit a9547b7e3a068941cda5619f05a64e798584535a) --- source3/rpc_server/srv_spoolss_nt.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e3552c3879..90536daedf 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2852,7 +2852,7 @@ uint32 _spoolss_endpageprinter(const POLICY_HND *handle) * ********************************************************************/ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, - DOC_INFO *docinfo, uint32 *jobid) + uint32 vuid, DOC_INFO *docinfo, uint32 *jobid) { DOC_INFO_1 *info_1 = &docinfo->doc_info_1; int snum; @@ -2895,7 +2895,7 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, unistr2_to_ascii(jobname, &info_1->docname, sizeof(jobname)); - Printer->jobid = print_job_start(snum, jobname); + Printer->jobid = print_job_start(snum, vuid, jobname); /* need to map error codes properly - for now give out of memory as I don't know the correct codes (tridge) */ @@ -2956,7 +2956,8 @@ uint32 _spoolss_writeprinter( const POLICY_HND *handle, * called from the spoolss dispatcher * ********************************************************************/ -static uint32 control_printer(const POLICY_HND *handle, uint32 command) +static uint32 control_printer(const POLICY_HND *handle, uint32 command, + uint16 vuid) { int snum; Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -2969,18 +2970,18 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command) switch (command) { case PRINTER_CONTROL_PAUSE: - if (print_queue_pause(snum)) { + if (print_queue_pause(snum, vuid)) { return 0; } break; case PRINTER_CONTROL_RESUME: case PRINTER_CONTROL_UNPAUSE: - if (print_queue_resume(snum)) { + if (print_queue_resume(snum, vuid)) { return 0; } break; case PRINTER_CONTROL_PURGE: - if (print_queue_purge(snum)) { + if (print_queue_purge(snum, vuid)) { return 0; } break; @@ -3074,7 +3075,7 @@ uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, DEVMODE_CTR devmode_ctr, SEC_DESC_BUF *secdesc_ctr, - uint32 command) + uint32 command, uint16 vuid) { Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -3084,7 +3085,7 @@ uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, /* check the level */ switch (level) { case 0: - return control_printer(handle, command); + return control_printer(handle, command, vuid); break; case 2: return update_printer(handle, level, info, devmode_ctr.devmode); @@ -3162,7 +3163,6 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, int position, int snum) { pstring temp_name; - DEVICEMODE *devmode; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; pstring chaine; @@ -3208,7 +3208,6 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, return False; } - job_info->devmode=devmode; free_a_printer(&ntprinter, 2); return (True); } @@ -3357,6 +3356,7 @@ uint32 _spoolss_schedulejob( const POLICY_HND *handle, uint32 jobid) uint32 _spoolss_setjob( const POLICY_HND *handle, uint32 jobid, uint32 level, + uint32 vuid, JOB_INFO *ctr, uint32 command) @@ -3377,13 +3377,13 @@ uint32 _spoolss_setjob( const POLICY_HND *handle, switch (command) { case JOB_CONTROL_CANCEL: case JOB_CONTROL_DELETE: - if (print_job_delete(jobid)) return 0x0; + if (print_job_delete(vuid, jobid)) return 0x0; break; case JOB_CONTROL_PAUSE: - if (print_job_pause(jobid)) return 0x0; + if (print_job_pause(vuid, jobid)) return 0x0; break; case JOB_CONTROL_RESUME: - if (print_job_resume(jobid)) return 0x0; + if (print_job_resume(vuid, jobid)) return 0x0; break; default: return ERROR_INVALID_LEVEL; @@ -4523,9 +4523,11 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin { int i=0; BOOL found=False; - JOB_INFO_2 *info_2=NULL; + JOB_INFO_2 *info_2; info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2)); + ZERO_STRUCTP(info_2); + if (info_2 == NULL) { safe_free(queue); return ERROR_NOT_ENOUGH_MEMORY; @@ -4556,6 +4558,7 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin new_smb_io_job_info_2("", buffer, info_2, 0); + free_dev_mode(info_2->devmode); safe_free(info_2); if (*needed > offered) -- cgit From 9b305b15430d72c78c2a98b7e9d91b5749b610a6 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 16 Jun 2000 08:47:52 +0000 Subject: Forgot pipes_struct conversion for api_samr_enum_dom_aliases() (This used to be commit 66372765e7c3f85240d54894547a150351426d5f) --- source3/rpc_server/srv_samr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 3ea0ba4615..c1d0444b36 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -784,9 +784,11 @@ static BOOL samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, /******************************************************************* api_samr_enum_dom_aliases ********************************************************************/ -static BOOL api_samr_enum_dom_aliases(prs_struct *data, prs_struct *rdata) +static BOOL api_samr_enum_dom_aliases(pipes_struct *p) { SAMR_Q_ENUM_DOM_ALIASES q_e; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; /* grab the samr open */ if(!samr_io_q_enum_dom_aliases("", &q_e, data, 0)) -- cgit From 69c75c8a165f05c01d13ba4eddbb970540e44b96 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 20 Jun 2000 23:58:56 +0000 Subject: Fixes for Win2k "add printer driver" INFO_LEVEL_6 was wrong, also some memory fixes. Jeremy. (This used to be commit 2a9e645cbddef1cddc5c978310b7efed492758d2) --- source3/rpc_server/srv_spoolss.c | 1 + source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 61e5341c75..a7a63fed89 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -876,6 +876,7 @@ static BOOL api_spoolss_addprinterdriver(pipes_struct *p) if(!spoolss_io_q_addprinterdriver("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n")); + free_spoolss_q_addprinterdriver(&q_u); return False; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 90536daedf..8cff8d68d9 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -577,11 +577,11 @@ static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *u switch (level) { case 3: printer->info_3=NULL; - uni_2_asc_printer_driver_3(uni->info_3, &(printer->info_3)); + uni_2_asc_printer_driver_3(uni->info_3, &printer->info_3); break; case 6: printer->info_6=NULL; - uni_2_asc_printer_driver_6(uni->info_6, &(printer->info_6)); + uni_2_asc_printer_driver_6(uni->info_6, &printer->info_6); break; default: break; -- cgit From f9e9f98a4a579f24d8ad1804b22bf36ede250e23 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 Jun 2000 01:39:17 +0000 Subject: lib/util_unistr.c: Removed ascii_to_unistr() as it does no codepage. Removed unistr_to_ascii() as it was never used. printing/nt_printing.c: Removed "DUMMY.XX" files. rpc_server/srv_spoolss_nt.c: Use dos_PutUniCode() instead of ascii_to_unistr(). Attempted to fix the "return value" size code based on J.F's comments. This needs looking at. Jeremy. (This used to be commit de99011bf3b2a23bd1854a047382a107aaeb9c68) --- source3/rpc_server/srv_spoolss_nt.c | 86 ++++++++++++++----------------------- 1 file changed, 32 insertions(+), 54 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8cff8d68d9..dc4932fdfc 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -897,8 +897,8 @@ static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, p snprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname); - data->notify_data.data.length=strlen(temp_name); - ascii_to_unistr((char *)data->notify_data.data.string, temp_name, sizeof(data->notify_data.data.string)-1); + data->notify_data.data.length= (uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + temp_name, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -910,12 +910,10 @@ static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, { /* data->notify_data.data.length=strlen(lp_servicename(snum)); - ascii_to_unistr(data->notify_data.data.string, lp_servicename(snum), sizeof(data->notify_data.data.string)-1); + dos_PutUniCode(data->notify_data.data.string, lp_servicename(snum), sizeof(data->notify_data.data.string), True); */ - data->notify_data.data.length=strlen(printer->info_2->printername); - ascii_to_unistr((char *)data->notify_data.data.string, - printer->info_2->printername, - sizeof(data->notify_data.data.string)-1); + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + printer->info_2->printername, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -923,10 +921,8 @@ static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, ********************************************************************/ static void spoolss_notify_share_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { - data->notify_data.data.length=strlen(lp_servicename(snum)); - ascii_to_unistr((char *)data->notify_data.data.string, - lp_servicename(snum), - sizeof(data->notify_data.data.string)-1); + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + lp_servicename(snum), sizeof(data->notify_data.data.string),True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -936,10 +932,8 @@ static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, pri { /* even if it's strange, that's consistant in all the code */ - data->notify_data.data.length=strlen(lp_servicename(snum)); - ascii_to_unistr((char *)data->notify_data.data.string, - lp_servicename(snum), - sizeof(data->notify_data.data.string)-1); + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + lp_servicename(snum), sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -949,10 +943,8 @@ static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, pri ********************************************************************/ static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { - data->notify_data.data.length=strlen(printer->info_2->drivername); - ascii_to_unistr((char *)data->notify_data.data.string, - printer->info_2->drivername, - sizeof(data->notify_data.data.string)-1); + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + printer->info_2->drivername, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -960,10 +952,8 @@ static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, p ********************************************************************/ static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { - data->notify_data.data.length=strlen(lp_comment(snum)); - ascii_to_unistr((char *)data->notify_data.data.string, - lp_comment(snum), - sizeof(data->notify_data.data.string)-1); + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + lp_comment(snum), sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -973,10 +963,8 @@ static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print ********************************************************************/ static void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { - data->notify_data.data.length=strlen(printer->info_2->location); - ascii_to_unistr((char *)data->notify_data.data.string, - printer->info_2->location, - sizeof(data->notify_data.data.string)-1); + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + printer->info_2->location, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -994,10 +982,8 @@ static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print ********************************************************************/ static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { - data->notify_data.data.length=strlen(printer->info_2->sepfile); - ascii_to_unistr((char *)data->notify_data.data.string, - printer->info_2->sepfile, - sizeof(data->notify_data.data.string)-1); + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + printer->info_2->sepfile, sizeof(data->notify_data.data.string)-1,True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -1006,10 +992,8 @@ static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print ********************************************************************/ static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { - data->notify_data.data.length=strlen(printer->info_2->printprocessor); - ascii_to_unistr((char *)data->notify_data.data.string, - printer->info_2->printprocessor, - sizeof(data->notify_data.data.string)-1); + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + printer->info_2->printprocessor, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -1018,10 +1002,8 @@ static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *dat ********************************************************************/ static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { - data->notify_data.data.length=strlen(printer->info_2->parameters); - ascii_to_unistr((char *)data->notify_data.data.string, - printer->info_2->parameters, - sizeof(data->notify_data.data.string)-1); + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + printer->info_2->parameters, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -1030,10 +1012,8 @@ static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr ********************************************************************/ static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { - data->notify_data.data.length=strlen(printer->info_2->datatype); - ascii_to_unistr((char *)data->notify_data.data.string, - printer->info_2->datatype, - sizeof(data->notify_data.data.string)-1); + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + printer->info_2->datatype, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -1133,8 +1113,8 @@ static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, p ********************************************************************/ static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { - data->notify_data.data.length=strlen(queue->user); - ascii_to_unistr((char *)data->notify_data.data.string, queue->user, sizeof(data->notify_data.data.string)-1); + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + queue->user, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -1150,8 +1130,8 @@ static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr ********************************************************************/ static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { - data->notify_data.data.length=strlen(queue->file); - ascii_to_unistr((char *)data->notify_data.data.string, queue->file, sizeof(data->notify_data.data.string)-1); + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + queue->file, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -1174,8 +1154,8 @@ static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *d p = "PRINTING"; break; } - data->notify_data.data.length=strlen(p); - ascii_to_unistr((char *)data->notify_data.data.string, p, sizeof(data->notify_data.data.string)-1); + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + p, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -2598,8 +2578,7 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *whe DEBUG(0,("init_unistr_array: Realloc error\n" )); return; } - ascii_to_unistr((char *)(*uni_array+j), line , 2*strlen(line)); - j+=strlen(line)+1; + j += (dos_PutUniCode((char *)(*uni_array+j), line , sizeof(uint16)*strlen(line), True) / sizeof(uint16) ); i++; if (strlen(v) == 0) break; } @@ -4145,13 +4124,12 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, * take a pause *before* coding not *during* coding */ - *out_max_value_len=in_value_len; + *out_max_value_len=(in_value_len/sizeof(uint16)); if((*out_value=(uint16 *)malloc(in_value_len*sizeof(uint8))) == NULL) { safe_free(data); return ERROR_NOT_ENOUGH_MEMORY; } - ascii_to_unistr((char *)*out_value, value, *out_max_value_len); - *out_value_len=2*(1+strlen(value)); + *out_value_len = (uint32)dos_PutUniCode((char *)*out_value, value, in_value_len, True); *out_type=type; -- cgit From eecab5c66096cc42323aaa4a796bf4a17e491a00 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 Jun 2000 23:59:22 +0000 Subject: Changed enumports to show printernames as ports. In line with 'the grand plan' :-) Gerald & I discussed with HP. More changes to follow. Jeremy. (This used to be commit 193a248beda99103c73a0b0ea5e2fbcbb516ce8e) --- source3/rpc_server/srv_spoolss_nt.c | 62 ++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index dc4932fdfc..b8b25a1ecb 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3653,16 +3653,16 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, ****************************************************************************/ static void fill_port_1(PORT_INFO_1 *port, char *name) { - init_unistr(&(port->port_name), name); + init_unistr(&port->port_name, name); } /**************************************************************************** ****************************************************************************/ static void fill_port_2(PORT_INFO_2 *port, char *name) { - init_unistr(&(port->port_name), name); - init_unistr(&(port->monitor_name), "Moniteur Local"); - init_unistr(&(port->description), "Local Port"); + init_unistr(&port->port_name, name); + init_unistr(&port->monitor_name, "Local Monitor"); + init_unistr(&port->description, "Local Port"); #define PORT_TYPE_WRITE 1 port->port_type=PORT_TYPE_WRITE; port->reserved=0x0; @@ -3688,16 +3688,36 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need for (snum=0; snum Date: Fri, 23 Jun 2000 05:53:18 +0000 Subject: Removed save directory argument to become_root() calls. Probably most of this stuff doesn't need to be done as root anyway. (This used to be commit c3cad0ff6482784f95fd54ba51ee5be2354bb95d) --- source3/rpc_server/srv_lookup.c | 16 ++++++++-------- source3/rpc_server/srv_netlog.c | 16 ++++++++-------- source3/rpc_server/srv_pipe.c | 8 ++++---- source3/rpc_server/srv_pipe_hnd.c | 4 ++-- source3/rpc_server/srv_samr.c | 32 ++++++++++++++++---------------- source3/rpc_server/srv_util.c | 8 ++++---- 6 files changed, 42 insertions(+), 42 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index 274c68f18d..e81f3051f3 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -113,9 +113,9 @@ int make_dom_gids(DOMAIN_GRP *mem, int num_members, DOM_GID **ppgids) uint8 attr = mem[count].attr; char *name = mem[count].name; - become_root(True); + become_root(); status = lookup_grp_rid(name, &rid, &type); - unbecome_root(True); + unbecome_root(); if (status == 0x0) { @@ -344,9 +344,9 @@ uint32 lookup_user_name(uint32 rid, char *user_name, uint8 *type) DEBUG(5,("lookup_user_name: rid: %d", rid)); /* find the user account */ - become_root(True); + become_root(); disp_info = getsamdisprid(rid); - unbecome_root(True); + unbecome_root(); if (disp_info != NULL) { @@ -537,9 +537,9 @@ uint32 lookup_added_user_rids(char *user_name, (*grp_rid) = 0; /* find the user account */ - become_root(True); + become_root(); sam_pass = getsam21pwnam(user_name); - unbecome_root(True); + unbecome_root(); if (sam_pass != NULL) { @@ -561,9 +561,9 @@ uint32 lookup_added_user_rid(char *user_name, uint32 *rid, uint8 *type) (*type) = SID_NAME_USER; /* find the user account */ - become_root(True); + become_root(); sam_pass = getsam21pwnam(user_name); - unbecome_root(True); + unbecome_root(); if (sam_pass != NULL) { diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 80e9894b59..7fe89f90b6 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -284,9 +284,9 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) } #endif /* 0 */ - become_root(True); + become_root(); smb_pass = getsmbpwnam(mach_acct); - unbecome_root(True); + unbecome_root(); if ((smb_pass) != NULL && !(smb_pass->acct_ctrl & ACB_DISABLED) && (smb_pass->smb_nt_passwd != NULL)) @@ -453,9 +453,9 @@ static BOOL api_net_srv_pwset(pipes_struct *p) DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); - become_root(True); + become_root(); smb_pass = getsmbpwnam(mach_acct); - unbecome_root(True); + unbecome_root(); if (smb_pass != NULL) { unsigned char pwd[16]; @@ -473,9 +473,9 @@ static BOOL api_net_srv_pwset(pipes_struct *p) smb_pass->smb_nt_passwd = pwd; smb_pass->acct_ctrl = ACB_WSTRUST; - become_root(True); + become_root(); ret = mod_smbpwd_entry(smb_pass,False); - unbecome_root(True); + unbecome_root(); if (ret) { /* hooray! */ @@ -718,9 +718,9 @@ static BOOL api_net_sam_logon(pipes_struct *p) */ pw=Get_Pwnam(nt_username, True); - become_root(True); + become_root(); smb_pass = getsmbpwnam(nt_username); - unbecome_root(True); + unbecome_root(); if (smb_pass == NULL) status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 46cb521018..a5d69efd7e 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -360,24 +360,24 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm if(!guest_user) { - become_root(True); + become_root(); if(!(p->ntlmssp_auth_validated = pass_check_smb(unix_user_name, domain, (uchar*)p->challenge, lm_owf, nt_owf, NULL))) { DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ failed authentication on named pipe %s.\n", domain, unix_user_name, wks, p->name )); - unbecome_root(True); + unbecome_root(); return False; } if(!(smb_pass = getsmbpwnam(unix_user_name))) { DEBUG(1,("api_pipe_ntlmssp_verify: Cannot find user %s in smb passwd database.\n", unix_user_name)); - unbecome_root(True); + unbecome_root(); return False; } - unbecome_root(True); + unbecome_root(); if (smb_pass == NULL) { DEBUG(1,("api_pipe_ntlmssp_verify: Couldn't find user '%s' in smb_passwd file.\n", diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index e01ecf82a2..b11c76b75d 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -144,9 +144,9 @@ static void attempt_remote_rpc_connect(pipes_struct *p) make_creds_nt_sec(&usr.nts); */ - become_root(False); /* to connect to pipe */ + become_root(); /* to connect to pipe */ p->m = msrpc_use_add(p->name, sys_getpid(), &usr, False); - unbecome_root(False); + unbecome_root(); if (p->m == NULL) DEBUG(10,("attempt_remote_rpc_connect: msrpc redirect failed - using local implementation.\n")); diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index c1d0444b36..50fe613e49 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -611,9 +611,9 @@ static BOOL samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, DEBUG(5,("samr_reply_enum_dom_users: %d\n", __LINE__)); - become_root(True); + become_root(); get_sampwd_entries(pass, 0, &total_entries, &num_entries, MAX_SAM_ENTRIES, q_u->acb_mask); - unbecome_root(True); + unbecome_root(); init_samr_r_enum_dom_users(&r_e, total_entries, q_u->unknown_0, num_entries, @@ -852,9 +852,9 @@ static BOOL samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, prs_struct *rd DEBUG(10,("samr_reply_query_dispinfo: Setting q_u->max_entries to %u\n",q_u->max_entries)); - become_root(True); + become_root(); got_pwds = get_passwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, q_u->max_entries, 0); - unbecome_root(True); + unbecome_root(); /* more left - set resume handle */ if(total_entries > num_entries) @@ -1028,9 +1028,9 @@ static BOOL samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, q_u->uni_user_name[i].uni_str_len)); /* find the user account */ - become_root(True); + become_root(); sam_pass = get_smb21pwd_entry(user_name, 0); - unbecome_root(True); + unbecome_root(); if (sam_pass == NULL) { @@ -1374,9 +1374,9 @@ static BOOL samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, prs_struct *rdata, int s r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; } - become_root(True); + become_root(); sam_pass = getsam21pwrid(q_u->user_rid); - unbecome_root(True); + unbecome_root(); /* check that the RID exists in our domain. */ if (r_u.status == 0x0 && sam_pass == NULL) @@ -1441,9 +1441,9 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) return False; } - become_root(True); + become_root(); smb_pass = getsmbpwrid(user_rid); - unbecome_root(True); + unbecome_root(); if (smb_pass == NULL) { @@ -1474,9 +1474,9 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) return False; } - become_root(True); + become_root(); sam_pass = getsam21pwrid(user_rid); - unbecome_root(True); + unbecome_root(); if (sam_pass == NULL) { @@ -1669,9 +1669,9 @@ static BOOL samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, if (status == 0x0) { - become_root(True); + become_root(); sam_pass = getsam21pwrid(rid); - unbecome_root(True); + unbecome_root(); if (sam_pass == NULL) { @@ -1859,9 +1859,9 @@ static BOOL api_samr_unknown_32(pipes_struct *p) fstrcpy(mach_acct, dos_unistrn2(q_u.uni_mach_acct.buffer, q_u.uni_mach_acct.uni_str_len)); - become_root(True); + become_root(); sam_pass = getsam21pwnam(mach_acct); - unbecome_root(True); + unbecome_root(); if (sam_pass != NULL) { diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 8264741db0..a1f2a7c085 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -270,9 +270,9 @@ uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) } /* ok, it's a user. find the user account */ - become_root(True); + become_root(); disp_info = getsamdisprid(rid); - unbecome_root(True); + unbecome_root(); if (disp_info != NULL) { @@ -332,9 +332,9 @@ uint32 lookup_user_rid(char *user_name, uint32 *rid) (*rid) = 0; /* find the user account */ - become_root(True); + become_root(); sam_pass = getsam21pwnam(user_name); - unbecome_root(True); + unbecome_root(); if (sam_pass != NULL) { -- cgit From e1b9e7cfff16301b39ce60ee4b5823698bc267e6 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 23 Jun 2000 06:36:22 +0000 Subject: Removed unused variables. (This used to be commit a75e738211e744adb966bcbc24371554c9642220) --- source3/rpc_server/srv_lsa.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 7df7686878..e67d3dca57 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -648,8 +648,6 @@ static BOOL api_lsa_lookup_names(pipes_struct *p) static BOOL api_lsa_close(pipes_struct *p) { LSA_R_CLOSE r_c; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(r_c); -- cgit From be7ad004e0bb479944a70f28fda0bc011c609e4a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 23 Jun 2000 06:43:08 +0000 Subject: Got a bit carried away deleting things. (This used to be commit 211391d88e10d94edcc81b83fefcadb4a905ea56) --- source3/rpc_server/srv_lsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index e67d3dca57..5855f6c030 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -648,6 +648,7 @@ static BOOL api_lsa_lookup_names(pipes_struct *p) static BOOL api_lsa_close(pipes_struct *p) { LSA_R_CLOSE r_c; + prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(r_c); @@ -668,7 +669,6 @@ static BOOL api_lsa_open_secret(pipes_struct *p) /* XXXX this is NOT good */ size_t i; uint32 dummy = 0; - prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; for(i =0; i < 4; i++) { -- cgit From ec1c58fcc0dc19138fe04533484b8acffef2cf0f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 24 Jun 2000 00:15:08 +0000 Subject: lib/util_sid.c: Uninitialized memory read. rpc_parse/parse_spoolss.c: Added note about prs_align when marshalling a SEC_DESC... rpc_server/srv_lsa.c: Tim - your changes broke the display of the 'everyone' group when doing file access with no winbindd running. This is a partial fix - more when I have analysed this more. rpc_server/srv_spoolss_nt.c: Fix for the 'change driver' problem ! Hurrah ! Jeremy. (This used to be commit 151b131ee01ef916c072bcdaa9943a2e984a0f45) --- source3/rpc_server/srv_lsa.c | 5 +++++ source3/rpc_server/srv_spoolss_nt.c | 16 +++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 5855f6c030..da8929bbc6 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -324,6 +324,11 @@ BOOL winbind_lookup_sid(DOM_SID *sid, fstring dom_name, fstring name, if (result == WINBINDD_OK) { parse_domain_user(response.data.name.name, dom_name, name); *name_type = response.data.name.type; + } else { + sid_copy(&tmp_sid, sid); + sid_split_rid(&tmp_sid, &rid); + return map_domain_sid_to_name(&tmp_sid, dom_name) && + lookup_local_rid(rid, name, name_type); } return (result == WINBINDD_OK); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b8b25a1ecb..d1ff58404e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -413,7 +413,7 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) if ( !(lp_snum_ok(snum) && lp_print_ok(snum) ) ) continue; - DEBUGADD(5,("share:%s\n",lp_servicename(snum))); + DEBUGADD(5,("set_printer_hnd_printername: share:%s\n",lp_servicename(snum))); if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) continue; @@ -441,7 +441,9 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) } snum--; - DEBUGADD(4,("Printer found: %s -> %s[%x]\n",printer->info_2->printername, lp_servicename(snum),snum)); + DEBUGADD(4,("set_printer_hnd_printername: Printer found: %s -> %s[%x]\n", + printer->info_2->printername, lp_servicename(snum),snum)); + ZERO_STRUCT(Printer->dev.printername); strncpy(Printer->dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); @@ -1667,11 +1669,11 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring /* the description and the name are of the form \\server\share */ slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s",servername, ntprinter->info_2->printername); - - init_unistr(&(printer->printername), chaine); + + init_unistr(&printer->printername, chaine); slprintf(chaine,sizeof(chaine)-1,"\\\\%s", servername); - init_unistr(&(printer->servername), chaine); + init_unistr(&printer->servername, chaine); printer->cjobs = count; printer->total_jobs = 0; @@ -1801,8 +1803,8 @@ static DEVICEMODE *construct_dev_mode(int snum, char *servername) goto fail; DEBUGADD(8,("loading DEVICEMODE\n")); - snprintf(adevice, sizeof(adevice), "\\\\%s\\%s", global_myname, - printer->info_2->printername); + snprintf(adevice, sizeof(adevice), "%s", printer->info_2->printername); + init_unistr(&devmode->devicename, adevice); snprintf(aform, sizeof(aform), ntdevmode->formname); -- cgit From 990b8e5f7fbf965e9905514ac4e96ecb4539d38e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 26 Jun 2000 17:41:06 +0000 Subject: Fixed display of "Everyone" in SD's. Jeremy. (This used to be commit 3c7fdaa576c09dab2e4de78ed353b1fa1d65a40d) --- source3/rpc_server/srv_lsa.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index da8929bbc6..be617e071e 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -325,10 +325,14 @@ BOOL winbind_lookup_sid(DOM_SID *sid, fstring dom_name, fstring name, parse_domain_user(response.data.name.name, dom_name, name); *name_type = response.data.name.type; } else { + + DEBUG(10,("winbind_lookup_sid: winbind lookup for %s failed - trying builtin.\n", + sid_str)); + sid_copy(&tmp_sid, sid); sid_split_rid(&tmp_sid, &rid); return map_domain_sid_to_name(&tmp_sid, dom_name) && - lookup_local_rid(rid, name, name_type); + lookup_known_rid(&tmp_sid, rid, name, name_type); } return (result == WINBINDD_OK); -- cgit From 36fd3866efa89b5a537d4cb312e6a0d77ca9b89a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 26 Jun 2000 22:08:20 +0000 Subject: Changing drivers using the properties page works - but only if getting/setting security descriptors is disabled (as it is in this code). If get/set sd's is enabled spooler.exe crashes on NT. I'll investigate and fix that issue next. Jeremy. (This used to be commit 8c9ed874363e6a710bc0fe521bb8c4f7ee219587) --- source3/rpc_server/srv_spoolss_nt.c | 70 +++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d1ff58404e..cd5f829a83 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -154,8 +154,7 @@ static Printer_entry *find_printer_index_by_hnd(const POLICY_HND *hnd) for(; find_printer; find_printer = (Printer_entry *)ubi_dlNext(find_printer)) { - if (memcmp(&(find_printer->printer_hnd), hnd, sizeof(*hnd)) == 0) - { + if (memcmp(&(find_printer->printer_hnd), hnd, sizeof(*hnd)) == 0) { DEBUG(4,("Found printer handle \n")); /*dump_data(4, hnd->data, sizeof(hnd->data));*/ return find_printer; @@ -182,8 +181,7 @@ static BOOL close_printer_handle(POLICY_HND *hnd) { Printer_entry *Printer = find_printer_index_by_hnd(hnd); - if (!OPEN_HANDLE(Printer)) - { + if (!OPEN_HANDLE(Printer)) { DEBUG(3,("Error closing printer handle\n")); return False; } @@ -212,8 +210,7 @@ static BOOL delete_printer_handle(POLICY_HND *hnd) { Printer_entry *Printer = find_printer_index_by_hnd(hnd); - if (!OPEN_HANDLE(Printer)) - { + if (!OPEN_HANDLE(Printer)) { DEBUG(3,("Error closing printer handle\n")); return False; } @@ -267,7 +264,7 @@ static BOOL open_printer_hnd(POLICY_HND *hnd) new_printer->open = True; new_printer->notify.option=NULL; - memcpy(&(new_printer->printer_hnd), hnd, sizeof(*hnd)); + memcpy(&new_printer->printer_hnd, hnd, sizeof(*hnd)); ubi_dlAddHead( &Printer_list, (ubi_dlNode *)new_printer); @@ -1797,14 +1794,18 @@ static DEVICEMODE *construct_dev_mode(int snum, char *servername) if (printer->info_2->devmode) ntdevmode = dup_nt_devicemode(printer->info_2->devmode); else - ntdevmode = construct_nt_devicemode(); + ntdevmode = construct_nt_devicemode(printer->info_2->printername); if (ntdevmode == NULL) goto fail; DEBUGADD(8,("loading DEVICEMODE\n")); - snprintf(adevice, sizeof(adevice), "%s", printer->info_2->printername); +#if 1 /* JRATEST */ + snprintf(adevice, sizeof(adevice), "%s", ntdevmode->devicename); +#else /* JRATEST */ + snprintf(adevice, sizeof(adevice), "%s", printer->info_2->printername); +#endif /* JRATEST */ init_unistr(&devmode->devicename, adevice); snprintf(aform, sizeof(aform), ntdevmode->formname); @@ -1912,7 +1913,7 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer if((printer->devmode = construct_dev_mode(snum, servername)) == NULL) goto err; - if (ntprinter->info_2->secdesc_buf->len != 0) { + if (ntprinter->info_2->secdesc_buf && ntprinter->info_2->secdesc_buf->len != 0) { /* steal the printer info sec_desc structure. [badly done]. */ printer->secdesc = ntprinter->info_2->secdesc_buf->sec; ntprinter->info_2->secdesc_buf->sec = NULL; /* Stolen memory. */ @@ -1957,7 +1958,7 @@ static BOOL construct_printer_info_3(fstring servername, ZERO_STRUCTP(printer); printer->flags = 4; /* This is the offset to the SEC_DESC. */ - if (ntprinter->info_2->secdesc_buf->len != 0) { + if (ntprinter->info_2->secdesc_buf && ntprinter->info_2->secdesc_buf->len != 0) { /* steal the printer info sec_desc structure. [badly done]. */ printer->secdesc = ntprinter->info_2->secdesc_buf->sec; ntprinter->info_2->secdesc_buf->sec = NULL; /* Stolen the malloced memory. */ @@ -2574,6 +2575,7 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *whe v = char_array[i]; if (!v) v = ""; /* hack to handle null lists */ } + if (strlen(v) == 0) break; snprintf(line, sizeof(line)-1, "%s%s", where, v); DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); if((*uni_array=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL) { @@ -2582,7 +2584,6 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *whe } j += (dos_PutUniCode((char *)(*uni_array+j), line , sizeof(uint16)*strlen(line), True) / sizeof(uint16) ); i++; - if (strlen(v) == 0) break; } if (*uni_array) { @@ -2613,23 +2614,23 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, info->version=driver.info_3->cversion; - init_unistr( &(info->name), driver.info_3->name ); - init_unistr( &(info->architecture), architecture ); + init_unistr( &info->name, driver.info_3->name ); + init_unistr( &info->architecture, architecture ); snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "%s%s", where, driver.info_3->driverpath); - init_unistr( &(info->driverpath), temp_driverpath ); + init_unistr( &info->driverpath, temp_driverpath ); snprintf(temp_datafile, sizeof(temp_datafile)-1, "%s%s", where, driver.info_3->datafile); - init_unistr( &(info->datafile), temp_datafile ); + init_unistr( &info->datafile, temp_datafile ); snprintf(temp_configfile, sizeof(temp_configfile)-1, "%s%s", where, driver.info_3->configfile); - init_unistr( &(info->configfile), temp_configfile ); + init_unistr( &info->configfile, temp_configfile ); snprintf(temp_helpfile, sizeof(temp_helpfile)-1, "%s%s", where, driver.info_3->helpfile); - init_unistr( &(info->helpfile), temp_helpfile ); + init_unistr( &info->helpfile, temp_helpfile ); - init_unistr( &(info->monitorname), driver.info_3->monitorname ); - init_unistr( &(info->defaultdatatype), driver.info_3->defaultdatatype ); + init_unistr( &info->monitorname, driver.info_3->monitorname ); + init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype ); info->dependentfiles=NULL; init_unistr_array(&info->dependentfiles, driver.info_3->dependentfiles, where); @@ -3014,25 +3015,34 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, if (!get_printer_snum(handle, &snum) ) return ERROR_INVALID_HANDLE; - get_a_printer(&printer, 2, lp_servicename(snum)); + if(get_a_printer(&printer, 2, lp_servicename(snum)) != 0) + return ERROR_INVALID_HANDLE; DEBUGADD(8,("Converting info_2 struct\n")); + + /* + * convert_printer_info converts the incoming + * info from the client and overwrites the info + * just read from the tdb in the pointer 'printer'. + */ + convert_printer_info(info, printer, level); if (info->info_2->devmode_ptr != 0) { - NT_DEVICEMODE *ntdevmode = NULL; /* we have a valid devmode convert it and link it*/ + + /* + * Ensure printer->info_2->devmode is a valid pointer + * as we will be overwriting it in convert_devicemode(). + */ + if (printer->info_2->devmode == NULL) + printer->info_2->devmode = construct_nt_devicemode(printer->info_2->printername); + DEBUGADD(8,("Converting the devicemode struct\n")); - if (printer->info_2->devmode) { - ntdevmode = dup_nt_devicemode(printer->info_2->devmode); - } else { - ntdevmode = construct_nt_devicemode(); - } - - convert_devicemode(devmode, ntdevmode); - free_nt_devicemode(&ntdevmode); + convert_devicemode(devmode, printer->info_2->devmode); + } else { if (printer->info_2->devmode != NULL) free_nt_devicemode(&printer->info_2->devmode); -- cgit From 774b06ee212ee764fb2e17c1f366d0de552c07cc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Jun 2000 00:52:40 +0000 Subject: Tidy up current spool code - added some JRATEST ifdefs to allow experimentation with what is making spoolss.exe crash - may be removed later. Jeremy. (This used to be commit f3fe384dc39ce49c639a7adf35179a50cb86abf0) --- source3/rpc_server/srv_spoolss_nt.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cd5f829a83..7259ccc428 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1356,8 +1356,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) return False; - for(field_num=0; field_numcount; field_num++) - { + for(field_num=0; field_numcount; field_num++) { field = option_type->fields[field_num]; DEBUGADD(4,("notify [%d]: type [%x], field [%x]\n", field_num, type, field)); @@ -1367,7 +1366,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO if((info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) { return False; } - current_data=&(info->data[info->count]); + current_data=&info->data[info->count]; construct_info_data(current_data, type, field, id); notify_info_data_table[j].fn(snum, current_data, queue, printer); @@ -1474,8 +1473,7 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO * info->data=NULL; info->count=0; - for (i=0; icount; i++) - { + for (i=0; icount; i++) { option_type=&(option->ctr.type[i]); if (option_type->type!=PRINTER_NOTIFY_TYPE) @@ -1495,8 +1493,7 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO * DEBUGADD(1,("info->version:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); DEBUGADD(1,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); - for (i=0; icount; i++) - { + for (i=0; icount; i++) { DEBUGADD(1,("[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\n", i, info->data[i].type, info->data[i].field, info->data[i].reserved, info->data[i].id, info->data[i].size, info->data[i].enc_type)); @@ -1533,9 +1530,8 @@ static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info get_printer_snum(hnd, &snum); - for (i=0; icount; i++) - { - option_type=&(option->ctr.type[i]); + for (i=0; icount; i++) { + option_type=&option->ctr.type[i]; switch ( option_type->type ) { case PRINTER_NOTIFY_TYPE: @@ -1547,7 +1543,7 @@ static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info memset(&status, 0, sizeof(status)); count = print_queue_status(snum, &queue, &status); for (j=0; jversion:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); DEBUGADD(1,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); - for (i=0; icount; i++) - { + for (i=0; icount; i++) { DEBUGADD(1,("[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\n", i, info->data[i].type, info->data[i].field, info->data[i].reserved, info->data[i].id, info->data[i].size, info->data[i].enc_type)); @@ -2150,7 +2145,7 @@ static BOOL enum_all_printers_info_2(fstring servername, NEW_BUFFER *buffer, uin if((printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2))) == NULL) return ERROR_NOT_ENOUGH_MEMORY; DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *returned)); - memcpy(&(printers[*returned]), ¤t_prt, sizeof(PRINTER_INFO_2)); + memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_2)); (*returned)++; } } @@ -4119,7 +4114,7 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, if (!get_printer_snum(handle, &snum)) return ERROR_INVALID_HANDLE; - if (get_a_printer(&printer, 2, lp_servicename(snum)) != 0x0) + if (get_a_printer(&printer, 2, lp_servicename(snum)) != 0) return ERROR_INVALID_HANDLE; /* @@ -4182,6 +4177,9 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, return ERROR_NOT_ENOUGH_MEMORY; } *out_value_len = (uint32)dos_PutUniCode((char *)*out_value, value, in_value_len, True); +#if 1 /* JRATEST */ + *out_max_value_len=(*out_value_len/sizeof(uint16)); +#endif /* JRATEST */ *out_type=type; @@ -4191,8 +4189,11 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, safe_free(data); return ERROR_NOT_ENOUGH_MEMORY; } - memcpy(*data_out, data, data_len); + memcpy(*data_out, data, (size_t)data_len); *out_data_len=data_len; +#if 1 /* JRATEST */ + *out_max_data_len=data_len; +#endif /* JRATEST */ safe_free(data); -- cgit From eed5e03043f851c299a572f5979f6c52d51b1d11 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 30 Jun 2000 01:07:26 +0000 Subject: Fixed oops with missing MANGLE_PATH directive. Jeremy. (This used to be commit fb6b5a964512dec37f85f8de39c0c06f702aabbd) --- source3/rpc_server/srv_spoolss_nt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7259ccc428..79f6030414 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2605,7 +2605,11 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, get_short_archi(short_archi, architecture); +#if MANGLE_DRIVER_PATH snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\%s\\", servername, short_archi, driver.info_3->name); +#else + snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\", servername, short_archi); +#endif info->version=driver.info_3->cversion; @@ -3502,7 +3506,7 @@ static uint32 enumprinterdrivers_level3(fstring *list, fstring servername, fstri /* check the required size. */ for (i=0; i<*returned; i++) { DEBUGADD(6,("adding driver [%d]'s size\n",i)); - *needed += spoolss_size_printer_driver_info_3(&(driver_info_3[i])); + *needed += spoolss_size_printer_driver_info_3(&driver_info_3[i]); } if (!alloc_buffer_size(buffer, *needed)) { @@ -3513,7 +3517,7 @@ static uint32 enumprinterdrivers_level3(fstring *list, fstring servername, fstri /* fill the buffer with the form structures */ for (i=0; i<*returned; i++) { DEBUGADD(6,("adding form [%d] to buffer\n",i)); - new_smb_io_printer_driver_info_3("", buffer, &(driver_info_3[i]), 0); + new_smb_io_printer_driver_info_3("", buffer, &driver_info_3[i], 0); } for (i=0; i<*returned; i++) -- cgit From 104217f3b05aa206b37ab6af0899dbe71d142d2e Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Sat, 1 Jul 2000 09:34:37 +0000 Subject: Found that the minimum priority is 1 and not 0 on NT. Changed back the devicemode's devicename to "\\server\printer". I'm 100% sure it is correct, it's what NT sends on the wire. And that's the printer's name and NOT the port's name as it has to be unique. It must also be a UNC because it's a remote printer (remote for the client). J.F. (This used to be commit a7098c47b6ecbd7bb5df1330ea176aa4d463aad3) --- source3/rpc_server/srv_spoolss_nt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 79f6030414..2e153b26c5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1033,7 +1033,7 @@ static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data, static void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { data->notify_data.value[0] = PRINTER_ATTRIBUTE_SHARED \ - | PRINTER_ATTRIBUTE_NETWORK \ + | PRINTER_ATTRIBUTE_LOCAL \ | PRINTER_ATTRIBUTE_RAW_ONLY ; } @@ -1796,10 +1796,10 @@ static DEVICEMODE *construct_dev_mode(int snum, char *servername) DEBUGADD(8,("loading DEVICEMODE\n")); -#if 1 /* JRATEST */ - snprintf(adevice, sizeof(adevice), "%s", ntdevmode->devicename); +#if 0 /* JRATEST */ + snprintf(adevice, sizeof(adevice), "\\\\%s\\%s", global_myname, ntdevmode->devicename); #else /* JRATEST */ - snprintf(adevice, sizeof(adevice), "%s", printer->info_2->printername); + snprintf(adevice, sizeof(adevice), "\\\\%s\\%s", global_myname, printer->info_2->printername); #endif /* JRATEST */ init_unistr(&devmode->devicename, adevice); -- cgit From 2d2b6a46f7d6430ee274eed70ba488338a32861a Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Sat, 1 Jul 2000 16:40:10 +0000 Subject: reverting Jeremy's changes to enumprinterdata. Jeremy, the out_max_value_len and out_max_data_len were good. Your change is breaking NT4SP6 checked version. J.F. (This used to be commit 5f2be8ba7dcd1eacc169e8d1d53c309e45a5cce6) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2e153b26c5..c31fd8ebf5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4181,7 +4181,7 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, return ERROR_NOT_ENOUGH_MEMORY; } *out_value_len = (uint32)dos_PutUniCode((char *)*out_value, value, in_value_len, True); -#if 1 /* JRATEST */ +#if 0 /* JRATEST */ *out_max_value_len=(*out_value_len/sizeof(uint16)); #endif /* JRATEST */ @@ -4195,7 +4195,7 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, } memcpy(*data_out, data, (size_t)data_len); *out_data_len=data_len; -#if 1 /* JRATEST */ +#if 0 /* JRATEST */ *out_max_data_len=data_len; #endif /* JRATEST */ -- cgit From 877c91bfdda53d2e93f4f4148361555d6461101a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 3 Jul 2000 00:58:13 +0000 Subject: Renamed generic_request() to winbindd_request() (This used to be commit d9041958558fc8e3c7b0491eb0f7e45bee9d19c5) --- source3/rpc_server/srv_lsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index be617e071e..9c9424832b 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -317,7 +317,7 @@ BOOL winbind_lookup_sid(DOM_SID *sid, fstring dom_name, fstring name, /* Make request */ - result = generic_request(WINBINDD_LOOKUPSID, &request, &response); + result = winbindd_request(WINBINDD_LOOKUPSID, &request, &response); /* Copy out result */ -- cgit From f048209484b10ed397c55864ca9ee29789f4e372 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 3 Jul 2000 06:52:31 +0000 Subject: Some more sec_ctx changes. Modified some fields in the pipe_struct structure so authenticated pipe users can have their unix groups set when become_authenticated_pipe_user() is called. (This used to be commit 55c9bf124dc661df43bfe582ef14b1297aeaf0fa) --- source3/rpc_server/srv_pipe.c | 38 ++++++++++++++++++++------------------ source3/rpc_server/srv_pipe_hnd.c | 10 ++++++++-- 2 files changed, 28 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index a5d69efd7e..f6746367bb 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -260,7 +260,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm uchar lm_owf[24]; uchar nt_owf[24]; fstring user_name; - fstring unix_user_name; + fstring pipe_user_name; fstring domain; fstring wks; BOOL guest_user = False; @@ -272,7 +272,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); memset(p->user_name, '\0', sizeof(p->user_name)); - memset(p->unix_user_name, '\0', sizeof(p->unix_user_name)); + memset(p->pipe_user_name, '\0', sizeof(p->pipe_user_name)); memset(p->domain, '\0', sizeof(p->domain)); memset(p->wks, '\0', sizeof(p->wks)); @@ -317,8 +317,8 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm { guest_user = True; - fstrcpy(unix_user_name, lp_guestaccount(-1)); - DEBUG(100,("Null user in NTLMSSP verification. Using guest = %s\n", unix_user_name)); + fstrcpy(pipe_user_name, lp_guestaccount(-1)); + DEBUG(100,("Null user in NTLMSSP verification. Using guest = %s\n", pipe_user_name)); smb_passwd_ptr = null_smb_passwd; @@ -329,8 +329,8 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm * function. */ - fstrcpy(unix_user_name, user_name); - (void)map_username(unix_user_name); + fstrcpy(pipe_user_name, user_name); + (void)map_username(pipe_user_name); /* * Do the length checking only if user is not NULL. @@ -353,8 +353,8 @@ 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(unix_user_name,True))) { - DEBUG(1,("Couldn't find user '%s' in UNIX password database.\n",unix_user_name)); + 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); } @@ -362,17 +362,17 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm become_root(); - if(!(p->ntlmssp_auth_validated = pass_check_smb(unix_user_name, domain, + if(!(p->ntlmssp_auth_validated = pass_check_smb(pipe_user_name, domain, (uchar*)p->challenge, lm_owf, nt_owf, NULL))) { DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ -failed authentication on named pipe %s.\n", domain, unix_user_name, wks, p->name )); +failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name )); unbecome_root(); return False; } - if(!(smb_pass = getsmbpwnam(unix_user_name))) { + if(!(smb_pass = getsmbpwnam(pipe_user_name))) { DEBUG(1,("api_pipe_ntlmssp_verify: Cannot find user %s in smb passwd database.\n", - unix_user_name)); + pipe_user_name)); unbecome_root(); return False; } @@ -381,18 +381,18 @@ failed authentication on named pipe %s.\n", domain, unix_user_name, wks, p->name if (smb_pass == NULL) { DEBUG(1,("api_pipe_ntlmssp_verify: Couldn't find user '%s' in smb_passwd file.\n", - unix_user_name)); + pipe_user_name)); return(False); } /* Quit if the account was disabled. */ if((smb_pass->acct_ctrl & ACB_DISABLED) || !smb_pass->smb_passwd) { - DEBUG(1,("Account for user '%s' was disabled.\n", unix_user_name)); + DEBUG(1,("Account for user '%s' was disabled.\n", pipe_user_name)); return(False); } if(!smb_pass->smb_nt_passwd) { - DEBUG(1,("Account for user '%s' has no NT password hash.\n", unix_user_name)); + DEBUG(1,("Account for user '%s' has no NT password hash.\n", pipe_user_name)); return(False); } @@ -439,7 +439,7 @@ failed authentication on named pipe %s.\n", domain, unix_user_name, wks, p->name } fstrcpy(p->user_name, user_name); - fstrcpy(p->unix_user_name, unix_user_name); + fstrcpy(p->pipe_user_name, pipe_user_name); fstrcpy(p->domain, domain); fstrcpy(p->wks, wks); @@ -447,8 +447,10 @@ failed authentication on named pipe %s.\n", domain, unix_user_name, wks, p->name * Store the UNIX credential data (uid/gid pair) in the pipe structure. */ - p->uid = pass->pw_uid; - p->gid = pass->pw_gid; + p->pipe_user.uid = pass->pw_uid; + p->pipe_user.gid = pass->pw_gid; + + /* XXX also set up pipe user group membership */ p->ntlmssp_auth_validated = True; return True; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index b11c76b75d..faba41b925 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -106,6 +106,8 @@ static BOOL pipe_init_outgoing_data(output_data *o_data) Attempt to find a remote process to communicate RPC's with. ****************************************************************************/ +#if 0 + static void attempt_remote_rpc_connect(pipes_struct *p) { struct user_creds usr; @@ -152,6 +154,8 @@ static void attempt_remote_rpc_connect(pipes_struct *p) DEBUG(10,("attempt_remote_rpc_connect: msrpc redirect failed - using local implementation.\n")); } +#endif + /**************************************************************************** Find first available pipe slot. ****************************************************************************/ @@ -248,8 +252,10 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, */ prs_init(&p->out_data.rdata, 0, 4, MARSHALL); - p->uid = (uid_t)-1; - p->gid = (gid_t)-1; + ZERO_STRUCT(p->pipe_user); + + p->pipe_user.uid = (uid_t)-1; + p->pipe_user.gid = (gid_t)-1; fstrcpy(p->name, pipe_name); -- cgit From 648f0849d6c9f66ebc4bd0445f0fe15ce091c511 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 6 Jul 2000 06:47:38 +0000 Subject: Changed checking for WINBINDD_OK return value instead of NSS_STATUS_SUCCESS when looking up sids from winbindd. (This used to be commit 79fb877bf13ba462ad0a878d8975f8b5183e3ea3) --- source3/rpc_server/srv_lsa.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 9c9424832b..84d2601d2c 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -286,7 +286,7 @@ BOOL winbind_lookup_sid(DOM_SID *sid, fstring dom_name, fstring name, { struct winbindd_request request; struct winbindd_response response; - enum winbindd_result result; + enum nss_status result; DOM_SID tmp_sid; uint32 rid; fstring sid_str; @@ -321,7 +321,7 @@ BOOL winbind_lookup_sid(DOM_SID *sid, fstring dom_name, fstring name, /* Copy out result */ - if (result == WINBINDD_OK) { + if (result == NSS_STATUS_SUCCESS) { parse_domain_user(response.data.name.name, dom_name, name); *name_type = response.data.name.type; } else { @@ -335,7 +335,7 @@ BOOL winbind_lookup_sid(DOM_SID *sid, fstring dom_name, fstring name, lookup_known_rid(&tmp_sid, rid, name, name_type); } - return (result == WINBINDD_OK); + return (result == NSS_STATUS_SUCCESS); } /*************************************************************************** -- cgit From d4081ac703aa3fe0246e2435d9c344f95186b4dc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 6 Jul 2000 06:51:55 +0000 Subject: Pass pipes_struct rather than vuid down to startdocprinter, setprinter and setjob spoolss server commands. (This used to be commit f35745137451f769a0723cb0665ba0b9d4801ad8) --- source3/rpc_server/srv_spoolss.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index a7a63fed89..3f72305465 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -436,7 +436,7 @@ static BOOL api_spoolss_startdocprinter(pipes_struct *p) } r_u.status = _spoolss_startdocprinter(&q_u.handle, - q_u.doc_info_container.level, p->vuid, + q_u.doc_info_container.level, p, &q_u.doc_info_container.docinfo, &r_u.jobid); @@ -529,7 +529,7 @@ static BOOL api_spoolss_setprinter(pipes_struct *p) r_u.status = _spoolss_setprinter(&q_u.handle, q_u.level, &q_u.info, q_u.devmode_ctr, q_u.secdesc_ctr, - q_u.command, p->vuid); + q_u.command, p); if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n")); @@ -692,7 +692,7 @@ static BOOL api_spoolss_setjob(pipes_struct *p) } r_u.status = _spoolss_setjob(&q_u.handle, q_u.jobid, - q_u.level, p->vuid, &q_u.ctr, q_u.command); + q_u.level, p, &q_u.ctr, q_u.command); if(!spoolss_io_r_setjob("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_setjob: unable to marshall SPOOL_R_SETJOB.\n")); -- cgit From d01839e49ec6858c3b0929ad6038a3ff62ac4271 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 6 Jul 2000 06:53:47 +0000 Subject: Pass either an authenticated pipe or SMB user in a current_user struct down to the printing back end functions. (This used to be commit a2751a269e05d5e46d4b22d6082a5898cdb4526f) --- source3/rpc_server/srv_spoolss_nt.c | 51 +++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c31fd8ebf5..92babf37d1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2832,20 +2832,29 @@ uint32 _spoolss_endpageprinter(const POLICY_HND *handle) * called from the spoolss dispatcher * ********************************************************************/ -uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, - uint32 vuid, DOC_INFO *docinfo, uint32 *jobid) +uint32 _spoolss_startdocprinter(const POLICY_HND *handle, uint32 level, + pipes_struct *p, DOC_INFO *docinfo, + uint32 *jobid) { DOC_INFO_1 *info_1 = &docinfo->doc_info_1; int snum; pstring jobname; fstring datatype; Printer_entry *Printer = find_printer_index_by_hnd(handle); + struct current_user user; if (!OPEN_HANDLE(Printer)) { return ERROR_INVALID_HANDLE; } + if (p->ntlmssp_auth_validated) { + memcpy(&user, &p->pipe_user, sizeof(user)); + } else { + extern struct current_user current_user; + memcpy(&user, ¤t_user, sizeof(user)); + } + /* * a nice thing with NT is it doesn't listen to what you tell it. * when asked to send _only_ RAW datas, it tries to send datas @@ -2876,7 +2885,7 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level, unistr2_to_ascii(jobname, &info_1->docname, sizeof(jobname)); - Printer->jobid = print_job_start(snum, vuid, jobname); + Printer->jobid = print_job_start(&user, snum, jobname); /* need to map error codes properly - for now give out of memory as I don't know the correct codes (tridge) */ @@ -2938,11 +2947,19 @@ uint32 _spoolss_writeprinter( const POLICY_HND *handle, * ********************************************************************/ static uint32 control_printer(const POLICY_HND *handle, uint32 command, - uint16 vuid) + pipes_struct *p) { + struct current_user user; int snum; Printer_entry *Printer = find_printer_index_by_hnd(handle); + if (p->ntlmssp_auth_validated) { + memcpy(&user, &p->pipe_user, sizeof(user)); + } else { + extern struct current_user current_user; + memcpy(&user, ¤t_user, sizeof(user)); + } + if (!OPEN_HANDLE(Printer)) return ERROR_INVALID_HANDLE; @@ -2951,18 +2968,18 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command, switch (command) { case PRINTER_CONTROL_PAUSE: - if (print_queue_pause(snum, vuid)) { + if (print_queue_pause(&user, snum)) { return 0; } break; case PRINTER_CONTROL_RESUME: case PRINTER_CONTROL_UNPAUSE: - if (print_queue_resume(snum, vuid)) { + if (print_queue_resume(&user, snum)) { return 0; } break; case PRINTER_CONTROL_PURGE: - if (print_queue_purge(snum, vuid)) { + if (print_queue_purge(&user, snum)) { return 0; } break; @@ -3065,7 +3082,7 @@ uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, DEVMODE_CTR devmode_ctr, SEC_DESC_BUF *secdesc_ctr, - uint32 command, uint16 vuid) + uint32 command, pipes_struct *p) { Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -3075,7 +3092,7 @@ uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, /* check the level */ switch (level) { case 0: - return control_printer(handle, command, vuid); + return control_printer(handle, command, p); break; case 2: return update_printer(handle, level, info, devmode_ctr.devmode); @@ -3346,11 +3363,12 @@ uint32 _spoolss_schedulejob( const POLICY_HND *handle, uint32 jobid) uint32 _spoolss_setjob( const POLICY_HND *handle, uint32 jobid, uint32 level, - uint32 vuid, + pipes_struct *p, JOB_INFO *ctr, uint32 command) { + struct current_user user; int snum; print_status_struct prt_status; @@ -3364,16 +3382,23 @@ uint32 _spoolss_setjob( const POLICY_HND *handle, return ERROR_INVALID_PRINTER_NAME; } + if (p->ntlmssp_auth_validated) { + memcpy(&user, &p->pipe_user, sizeof(user)); + } else { + extern struct current_user current_user; + memcpy(&user, ¤t_user, sizeof(user)); + } + switch (command) { case JOB_CONTROL_CANCEL: case JOB_CONTROL_DELETE: - if (print_job_delete(vuid, jobid)) return 0x0; + if (print_job_delete(&user, jobid)) return 0x0; break; case JOB_CONTROL_PAUSE: - if (print_job_pause(vuid, jobid)) return 0x0; + if (print_job_pause(&user, jobid)) return 0x0; break; case JOB_CONTROL_RESUME: - if (print_job_resume(vuid, jobid)) return 0x0; + if (print_job_resume(&user, jobid)) return 0x0; break; default: return ERROR_INVALID_LEVEL; -- cgit From 89eafd3ceffc7b4965133f6ddc059a134eaffb61 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 6 Jul 2000 23:31:46 +0000 Subject: printing/nt_printing.c: (From JF) use the driver name - already given to us. printing/printing.c: priority needs to be 1 not zero (found by checked build). rpc_server/srv_spoolss_nt.c: Log invalid handle access, also print out if this is a different pid handle. This will help track down client access after a connection is closed. Jeremy. (This used to be commit 4ff949228c40b6abb2008df8db985562ac2895d2) --- source3/rpc_server/srv_spoolss_nt.c | 109 ++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 47 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 92babf37d1..522a266b8c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -84,7 +84,8 @@ static ubi_dlList Printer_list; static ubi_dlList counter_list; -#define OPEN_HANDLE(pnum) ((pnum!=NULL) && (pnum->open!=False)) +#define OPEN_HANDLE(pnum) ((pnum!=NULL) && (pnum->open!=False) && (IVAL(pnum->printer_hnd.data,16)==(uint32)sys_getpid())) +#define OUR_HANDLE(pnum) ((pnum==NULL)?"NULL":(IVAL(pnum->data,16)==sys_getpid()?"OURS":"OTHER")) /* translate between internal status numbers and NT status numbers */ static int nt_printj_status(int v) @@ -182,7 +183,7 @@ static BOOL close_printer_handle(POLICY_HND *hnd) Printer_entry *Printer = find_printer_index_by_hnd(hnd); if (!OPEN_HANDLE(Printer)) { - DEBUG(3,("Error closing printer handle\n")); + DEBUG(0,("close_printer_handle: Invalid handle (%s)\n", OUR_HANDLE(hnd))); return False; } @@ -211,7 +212,7 @@ static BOOL delete_printer_handle(POLICY_HND *hnd) Printer_entry *Printer = find_printer_index_by_hnd(hnd); if (!OPEN_HANDLE(Printer)) { - DEBUG(3,("Error closing printer handle\n")); + DEBUG(0,("delete_printer_handle: Invalid handle (%s)\n", OUR_HANDLE(hnd))); return False; } @@ -231,7 +232,7 @@ static BOOL get_printer_snum(const POLICY_HND *hnd, int *number) Printer_entry *Printer = find_printer_index_by_hnd(hnd); if (!OPEN_HANDLE(Printer)) { - DEBUG(3,("Error getting printer - take a nap quickly !\n")); + DEBUG(0,("get_printer_snum: Invalid handle (%s)\n", OUR_HANDLE(hnd))); return False; } @@ -279,7 +280,7 @@ static BOOL set_printer_hnd_accesstype(POLICY_HND *hnd, uint32 access_required) Printer_entry *Printer = find_printer_index_by_hnd(hnd); if (!OPEN_HANDLE(Printer)) { - DEBUG(4,("Error setting printer type=%x", access_required)); + DEBUG(0,("set_printer_hnd_accesstype: Invalid handle (%s)", OUR_HANDLE(hnd))); return False; } @@ -297,7 +298,7 @@ static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername) Printer_entry *Printer = find_printer_index_by_hnd(hnd); if (!OPEN_HANDLE(Printer)) { - DEBUGADD(4,("Error setting printer name %s", printername)); + DEBUG(0,("set_printer_hnd_printertype: Invalid handle (%s)", OUR_HANDLE(hnd))); return False; } @@ -337,7 +338,7 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) BOOL found=False; if (!OPEN_HANDLE(Printer)) { - DEBUG(0,("Error setting printer name=%s\n", printername)); + DEBUG(0,("set_printer_hnd_printername: Invalid handle (%s)\n", OUR_HANDLE(hnd))); return False; } @@ -754,8 +755,10 @@ static BOOL getprinterdata_printer(const POLICY_HND *handle, DEBUG(5,("getprinterdata_printer\n")); - if (!OPEN_HANDLE(Printer)) + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("getprinterdata_printer: Invalid handle (%s).\n", OUR_HANDLE(handle))); return False; + } if(!get_printer_snum(handle, &snum)) return False; @@ -825,6 +828,7 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, if (!OPEN_HANDLE(Printer)) { if((*data=(uint8 *)malloc(4*sizeof(uint8))) == NULL) return ERROR_NOT_ENOUGH_MEMORY; + DEBUG(0,("_spoolss_getprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } @@ -874,8 +878,10 @@ uint32 _spoolss_rffpcnex(const POLICY_HND *handle, uint32 flags, uint32 options, Printer_entry *Printer=find_printer_index_by_hnd(handle); - if (!OPEN_HANDLE(Printer)) + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_rffpcnex: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; + } Printer->notify.flags=flags; Printer->notify.options=options; @@ -1574,8 +1580,10 @@ uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, uint32 change, { Printer_entry *Printer=find_printer_index_by_hnd(handle); - if (!OPEN_HANDLE(Printer)) + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_rfnpcnex: Invalid handle (%s).\n",OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; + } DEBUG(4,("Printer type %x\n",Printer->printer_type)); @@ -1796,11 +1804,7 @@ static DEVICEMODE *construct_dev_mode(int snum, char *servername) DEBUGADD(8,("loading DEVICEMODE\n")); -#if 0 /* JRATEST */ - snprintf(adevice, sizeof(adevice), "\\\\%s\\%s", global_myname, ntdevmode->devicename); -#else /* JRATEST */ snprintf(adevice, sizeof(adevice), "\\\\%s\\%s", global_myname, printer->info_2->printername); -#endif /* JRATEST */ init_unistr(&devmode->devicename, adevice); snprintf(aform, sizeof(aform), ntdevmode->formname); @@ -1886,7 +1890,12 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer init_unistr(&printer->servername, chaine); /* servername*/ init_unistr(&printer->printername, chaine2); /* printername*/ init_unistr(&printer->sharename, lp_servicename(snum)); /* sharename */ +#if 1 /* JRATEST */ + /* We need to determine the correct model for this..... */ + init_unistr(&printer->portname, lp_printername(snum)); /* port */ +#else init_unistr(&printer->portname, lp_servicename(snum)); /* port */ +#endif init_unistr(&printer->drivername, ntprinter->info_2->drivername); /* drivername */ init_unistr(&printer->comment, lp_comment(snum)); /* comment */ init_unistr(&printer->location, ntprinter->info_2->location); /* location */ @@ -2799,8 +2808,7 @@ uint32 _spoolss_startpageprinter(const POLICY_HND *handle) { Printer_entry *Printer = find_printer_index_by_hnd(handle); - if (OPEN_HANDLE(Printer)) - { + if (OPEN_HANDLE(Printer)) { Printer->page_started=True; return 0x0; } @@ -2815,9 +2823,8 @@ uint32 _spoolss_endpageprinter(const POLICY_HND *handle) { Printer_entry *Printer = find_printer_index_by_hnd(handle); - if (!OPEN_HANDLE(Printer)) - { - DEBUG(3,("Error in endpageprinter printer handle\n")); + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_endpageprinter: Invalid handle (%s).\n",OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } @@ -2843,8 +2850,8 @@ uint32 _spoolss_startdocprinter(const POLICY_HND *handle, uint32 level, Printer_entry *Printer = find_printer_index_by_hnd(handle); struct current_user user; - if (!OPEN_HANDLE(Printer)) - { + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_startdocprinter: Invalid handle (%s)\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } @@ -2908,9 +2915,8 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle) { Printer_entry *Printer=find_printer_index_by_hnd(handle); - if (!OPEN_HANDLE(Printer)) - { - DEBUG(3,("Error in enddocprinter handle\n")); + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_enddocprinter: Invalid handle (%s)\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } @@ -2930,9 +2936,8 @@ uint32 _spoolss_writeprinter( const POLICY_HND *handle, { Printer_entry *Printer = find_printer_index_by_hnd(handle); - if (!OPEN_HANDLE(Printer)) - { - DEBUG(3,("Error in writeprinter handle\n")); + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_writeprinter: Invalid handle (%s)\n",OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } @@ -2960,8 +2965,10 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command, memcpy(&user, ¤t_user, sizeof(user)); } - if (!OPEN_HANDLE(Printer)) + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("control_printer: Invalid handle (%s)\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; + } if (!get_printer_snum(handle, &snum) ) return ERROR_INVALID_HANDLE; @@ -2998,8 +3005,10 @@ static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level, { Printer_entry *Printer = find_printer_index_by_hnd(handle); - if (!OPEN_HANDLE(Printer)) + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("update_printer_sec: Invalid handle (%s)\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; + } return nt_printing_setsec(Printer->dev.printername, secdesc_ctr); } @@ -3025,8 +3034,10 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, return ERROR_INVALID_LEVEL; } - if (!OPEN_HANDLE(Printer)) + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("update_printer: Invalid handle (%s)\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; + } if (!get_printer_snum(handle, &snum) ) return ERROR_INVALID_HANDLE; @@ -3086,8 +3097,10 @@ uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, { Printer_entry *Printer = find_printer_index_by_hnd(handle); - if (!OPEN_HANDLE(Printer)) + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_setprinter: Invalid handle (%s)\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; + } /* check the level */ switch (level) { @@ -3112,8 +3125,10 @@ uint32 _spoolss_fcpn(const POLICY_HND *handle) { Printer_entry *Printer= find_printer_index_by_hnd(handle); - if (!OPEN_HANDLE(Printer)) + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_fcpn: Invalid handle (%s)\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; + } Printer->notify.flags=0; Printer->notify.options=0; @@ -3606,7 +3621,7 @@ uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32 static void fill_form_1(FORM_1 *form, nt_forms_struct *list, int position) { form->flag=list->flag; - init_unistr(&(form->name), list->name); + init_unistr(&form->name, list->name); form->width=list->width; form->length=list->length; form->left=list->left; @@ -3645,7 +3660,7 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, /* construct the list of form structures */ for (i=0; i<*numofforms; i++) { DEBUGADD(6,("Filling form number [%d]\n",i)); - fill_form_1(&(forms_1[i]), &(list[i]), i); + fill_form_1(&forms_1[i], &list[i], i); } safe_free(list); @@ -3653,7 +3668,7 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, /* check the required size. */ for (i=0; i<*numofforms; i++) { DEBUGADD(6,("adding form [%d]'s size\n",i)); - buffer_size += spoolss_size_form_1(&(forms_1[i])); + buffer_size += spoolss_size_form_1(&forms_1[i]); } *needed=buffer_size; @@ -3666,7 +3681,7 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, /* fill the buffer with the form structures */ for (i=0; i<*numofforms; i++) { DEBUGADD(6,("adding form [%d] to buffer\n",i)); - new_smb_io_form_1("", buffer, &(forms_1[i]), 0); + new_smb_io_form_1("", buffer, &forms_1[i], 0); } safe_free(forms_1); @@ -4137,8 +4152,10 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, DEBUG(5,("spoolss_enumprinterdata\n")); - if (!OPEN_HANDLE(Printer)) + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_enumprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; + } if (!get_printer_snum(handle, &snum)) return ERROR_INVALID_HANDLE; @@ -4206,9 +4223,6 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, return ERROR_NOT_ENOUGH_MEMORY; } *out_value_len = (uint32)dos_PutUniCode((char *)*out_value, value, in_value_len, True); -#if 0 /* JRATEST */ - *out_max_value_len=(*out_value_len/sizeof(uint16)); -#endif /* JRATEST */ *out_type=type; @@ -4220,9 +4234,6 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, } memcpy(*data_out, data, (size_t)data_len); *out_data_len=data_len; -#if 0 /* JRATEST */ - *out_max_data_len=data_len; -#endif /* JRATEST */ safe_free(data); @@ -4249,8 +4260,10 @@ uint32 _spoolss_setprinterdata( const POLICY_HND *handle, DEBUG(5,("spoolss_setprinterdata\n")); - if (!OPEN_HANDLE(Printer)) + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_setprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; + } if (!get_printer_snum(handle, &snum)) return ERROR_INVALID_HANDLE; @@ -4283,8 +4296,10 @@ uint32 _spoolss_addform( const POLICY_HND *handle, DEBUG(5,("spoolss_addform\n")); - if (!OPEN_HANDLE(Printer)) + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_addform: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; + } count=get_ntforms(&list); if(!add_a_form(&list, form, &count)) @@ -4309,8 +4324,8 @@ uint32 _spoolss_setform( const POLICY_HND *handle, DEBUG(5,("spoolss_setform\n")); - if (!OPEN_HANDLE(Printer)) - { + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_setform: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } count=get_ntforms(&list); -- cgit From 78a4848e8da7bb4f96e99e3419c5473c4c23bb6d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 10 Jul 2000 05:08:21 +0000 Subject: Re-instated lanman printing security checks (oops). A user can now pause, resume or delete their own job even if they don't have the Manage Documents privilege. Added call to se_access_check() for changing printer properties. The Full Access privilege is required for the user to perform this. Several uninitialised variables and memory leaks plugged. Modified default ACL created on new printers to be Everyone / Print instead of Everyone / Full Access. This required some random stuffing around with the value of the revision field to correspond with the ACL that NT produces when setting the same permission on the printer. Fixed dodgy function call in printing/printfsp.c (This used to be commit 2abce4dcfa351051df6e5f789b34fa99c9b81c22) --- source3/rpc_server/srv_spoolss_nt.c | 69 +++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 522a266b8c..0be371df11 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3001,8 +3001,10 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command, ********************************************************************/ static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, - SEC_DESC_BUF *secdesc_ctr) + pipes_struct *p, SEC_DESC_BUF *secdesc_ctr) { + struct current_user user; + Printer_entry *Printer = find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) { @@ -3010,7 +3012,15 @@ static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level, return ERROR_INVALID_HANDLE; } - return nt_printing_setsec(Printer->dev.printername, secdesc_ctr); + if (p->ntlmssp_auth_validated) { + memcpy(&user, &p->pipe_user, sizeof(user)); + } else { + extern struct current_user current_user; + memcpy(&user, ¤t_user, sizeof(user)); + } + + return nt_printing_setsec(Printer->dev.printername, &user, + secdesc_ctr); } /******************************************************************** @@ -3025,25 +3035,53 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, int snum; NT_PRINTER_INFO_LEVEL *printer = NULL; Printer_entry *Printer = find_printer_index_by_hnd(handle); - + SEC_DESC_BUF *sd = NULL; + uint32 result, acc_granted; + extern struct current_user current_user; + DEBUG(8,("update_printer\n")); + result = NT_STATUS_NO_PROBLEMO; + + /* Check calling user has permission to update printer description */ + + if (!nt_printing_getsec(Printer->dev.printername, &sd)) { + DEBUG(3, ("Could not get security descriptor for printer %s", + Printer->dev.printername)); + result = ERROR_INVALID_FUNCTION; + goto done; + } + + if (!se_access_check(sd->sec, current_user.uid, current_user.gid, + current_user.ngroups, current_user.groups, + PRINTER_ACE_FULL_CONTROL, &acc_granted, + &result)) { + DEBUG(3, ("printer property change denied by security " + "descriptor\n")); + goto done; + } + if (level!=2) { DEBUG(0,("Send a mail to samba@samba.org\n")); DEBUGADD(0,("with the following message: update_printer: level!=2\n")); - return ERROR_INVALID_LEVEL; + result = ERROR_INVALID_LEVEL; + goto done; } if (!OPEN_HANDLE(Printer)) { - DEBUG(0,("update_printer: Invalid handle (%s)\n", OUR_HANDLE(handle))); - return ERROR_INVALID_HANDLE; + result = ERROR_INVALID_HANDLE; + goto done; } - if (!get_printer_snum(handle, &snum) ) - return ERROR_INVALID_HANDLE; + if (!get_printer_snum(handle, &snum)) { + result = ERROR_INVALID_HANDLE; + goto done; + } - if(get_a_printer(&printer, 2, lp_servicename(snum)) != 0) - return ERROR_INVALID_HANDLE; + if(get_a_printer(&printer, 2, lp_servicename(snum)) != 0) { + result = ERROR_INVALID_HANDLE; + goto done; + } DEBUGADD(8,("Converting info_2 struct\n")); @@ -3078,13 +3116,15 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, if (add_a_printer(*printer, 2)!=0) { /* I don't really know what to return here !!! */ - free_a_printer(&printer, 2); - return ERROR_ACCESS_DENIED; + result = ERROR_ACCESS_DENIED; + goto done; } + done: free_a_printer(&printer, 2); + free_sec_desc_buf(&sd); - return NT_STATUS_NO_PROBLEMO; + return result; } /**************************************************************************** @@ -3111,7 +3151,8 @@ uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, return update_printer(handle, level, info, devmode_ctr.devmode); break; case 3: - return update_printer_sec(handle, level, info, secdesc_ctr); + return update_printer_sec(handle, level, info, p, + secdesc_ctr); break; default: return ERROR_INVALID_LEVEL; -- cgit From 64299375b544de91dab75d62610d7dc7f1f8328d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 10 Jul 2000 05:40:43 +0000 Subject: Moved winbind client functions from various odd locations to nsswitch/wb_client.c Merge of nsswitch/common.c rename to nsswitch/wb_common.c from TNG. (This used to be commit f866c18f6be65db67d9d2a6c0b42e1af3b421e6c) --- source3/rpc_server/srv_lsa.c | 59 -------------------------------------------- 1 file changed, 59 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 84d2601d2c..bfb671d167 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -279,65 +279,6 @@ static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, r_l->status = 0x0; } -/* Call winbindd to convert sid to name */ - -BOOL winbind_lookup_sid(DOM_SID *sid, fstring dom_name, fstring name, - uint8 *name_type) -{ - struct winbindd_request request; - struct winbindd_response response; - enum nss_status result; - DOM_SID tmp_sid; - uint32 rid; - fstring sid_str; - - if (!name_type) return False; - - /* Check if this is our own sid. This should perhaps be done by - winbind? For the moment handle it here. */ - - if (sid->num_auths == 5) { - sid_copy(&tmp_sid, sid); - sid_split_rid(&tmp_sid, &rid); - - if (sid_equal(&global_sam_sid, &tmp_sid)) { - - return map_domain_sid_to_name(&tmp_sid, dom_name) && - lookup_local_rid(rid, name, name_type); - } - } - - /* Initialise request */ - - ZERO_STRUCT(request); - ZERO_STRUCT(response); - - sid_to_string(sid_str, sid); - fstrcpy(request.data.sid, sid_str); - - /* Make request */ - - result = winbindd_request(WINBINDD_LOOKUPSID, &request, &response); - - /* Copy out result */ - - if (result == NSS_STATUS_SUCCESS) { - parse_domain_user(response.data.name.name, dom_name, name); - *name_type = response.data.name.type; - } else { - - DEBUG(10,("winbind_lookup_sid: winbind lookup for %s failed - trying builtin.\n", - sid_str)); - - sid_copy(&tmp_sid, sid); - sid_split_rid(&tmp_sid, &rid); - return map_domain_sid_to_name(&tmp_sid, dom_name) && - lookup_known_rid(&tmp_sid, rid, name, name_type); - } - - return (result == NSS_STATUS_SUCCESS); -} - /*************************************************************************** Init lsa_trans_names. ***************************************************************************/ -- cgit From b561c185972921861946a69b8846681bc7ed3f87 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 10 Jul 2000 06:41:04 +0000 Subject: Fixes for various compile warnings on Solaris 8. (This used to be commit 898a483cdab1ed7d8ff902c0dc0e0620440ae4cd) --- source3/rpc_server/srv_spoolss_nt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0be371df11..dd3a5dd733 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2941,7 +2941,8 @@ uint32 _spoolss_writeprinter( const POLICY_HND *handle, return ERROR_INVALID_HANDLE; } - (*buffer_written) = print_job_write(Printer->jobid, buffer, buffer_size); + (*buffer_written) = print_job_write(Printer->jobid, (char *)buffer, + buffer_size); return 0x0; } -- cgit From 445e92eb01949335feed9fa5716209976d8021f1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Jul 2000 22:30:13 +0000 Subject: Ensure correct driver paths are returned in INFO_2 struct. Jeremy. (This used to be commit 7a95c289cd0b4615d2a5aa8a148c767b57460ffa) --- source3/rpc_server/srv_spoolss_nt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index dd3a5dd733..320ff8ff3a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2517,24 +2517,24 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, get_short_archi(short_archi,architecture); - snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\%s\\", servername, short_archi, driver.info_3->name); + snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\", servername, short_archi); info->version=driver.info_3->cversion; - init_unistr( &(info->name), driver.info_3->name ); - init_unistr( &(info->architecture), architecture ); + init_unistr( &info->name, driver.info_3->name ); + init_unistr( &info->architecture, architecture ); snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "%s%s", where, driver.info_3->driverpath); - init_unistr( &(info->driverpath), temp_driverpath ); + init_unistr( &info->driverpath, temp_driverpath ); snprintf(temp_datafile, sizeof(temp_datafile)-1, "%s%s", where, driver.info_3->datafile); - init_unistr( &(info->datafile), temp_datafile ); + init_unistr( &info->datafile, temp_datafile ); snprintf(temp_configfile, sizeof(temp_configfile)-1, "%s%s", where, driver.info_3->configfile); - init_unistr( &(info->configfile), temp_configfile ); + init_unistr( &info->configfile, temp_configfile ); } /******************************************************************** -- cgit From 5813ecff99431c3529cd45f3b579ef16e72a46f0 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Wed, 12 Jul 2000 14:10:40 +0000 Subject: - The printers are indexed by the sharename in both get_a_printer() and add_a_printer() now. - correctly unpack the private part of a devmode and remove a memleak - correctly retrieve the pair(value,data) for getprinterdata - handle null devicemode in printer_info_2 I still have some bugs but I'm not crashing anymore NT4SP6 d/c build :-) J.F. (This used to be commit 493f7d11acf753ba24c88e6cbb73d86a8595a66a) --- source3/rpc_server/srv_spoolss_nt.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 320ff8ff3a..c0c721a082 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1796,9 +1796,10 @@ static DEVICEMODE *construct_dev_mode(int snum, char *servername) if (printer->info_2->devmode) ntdevmode = dup_nt_devicemode(printer->info_2->devmode); +#if 0 /* JFMTEST */ else ntdevmode = construct_nt_devicemode(printer->info_2->printername); - +#endif if (ntdevmode == NULL) goto fail; @@ -1914,8 +1915,12 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer printer->cjobs = count; /* jobs */ printer->averageppm = ntprinter->info_2->averageppm; /* average pages per minute */ - if((printer->devmode = construct_dev_mode(snum, servername)) == NULL) + if((printer->devmode = construct_dev_mode(snum, servername)) == NULL) { + DEBUG(8, ("Returning NULL Devicemode!\n")); +#if 0 /* JFMTEST */ goto err; +#endif + } if (ntprinter->info_2->secdesc_buf && ntprinter->info_2->secdesc_buf->len != 0) { /* steal the printer info sec_desc structure. [badly done]. */ @@ -3045,7 +3050,8 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, result = NT_STATUS_NO_PROBLEMO; /* Check calling user has permission to update printer description */ - + +#if 1 /* JFMTEST */ if (!nt_printing_getsec(Printer->dev.printername, &sd)) { DEBUG(3, ("Could not get security descriptor for printer %s", Printer->dev.printername)); @@ -3061,7 +3067,7 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, "descriptor\n")); goto done; } - +#endif if (level!=2) { DEBUG(0,("Send a mail to samba@samba.org\n")); DEBUGADD(0,("with the following message: update_printer: level!=2\n")); @@ -3596,9 +3602,9 @@ static uint32 enumprinterdrivers_level3(fstring *list, fstring servername, fstri return ERROR_INSUFFICIENT_BUFFER; } - /* fill the buffer with the form structures */ + /* fill the buffer with the driver structures */ for (i=0; i<*returned; i++) { - DEBUGADD(6,("adding form [%d] to buffer\n",i)); + DEBUGADD(6,("adding driver [%d] to buffer\n",i)); new_smb_io_printer_driver_info_3("", buffer, &driver_info_3[i], 0); } @@ -3653,6 +3659,7 @@ uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32 return enumprinterdrivers_level3(list, servername, architecture, buffer, offered, needed, returned); break; default: + *returned=0; return ERROR_INVALID_LEVEL; break; } @@ -4264,6 +4271,8 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, safe_free(data); return ERROR_NOT_ENOUGH_MEMORY; } + + ZERO_STRUCTP(*out_value); *out_value_len = (uint32)dos_PutUniCode((char *)*out_value, value, in_value_len, True); *out_type=type; @@ -4274,6 +4283,8 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, safe_free(data); return ERROR_NOT_ENOUGH_MEMORY; } + + ZERO_STRUCTP(*data_out); memcpy(*data_out, data, (size_t)data_len); *out_data_len=data_len; -- cgit From f3494484cfc657a905e7b6b0e7d841e817667e97 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 13 Jul 2000 04:33:25 +0000 Subject: Don't return winbind groups or users when responding to samr_enum_dom_users and samr_enum_dom_aliases commands. Unfortunately the algorithm for determining winbind groups from normal groups is simply to check for the presence of the lp_winbind_separator() character. )-: (This used to be commit 363a9c45bf0a7d3266ccdf4eeb0b9f5e3d38389f) --- source3/rpc_server/srv_samr.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 50fe613e49..12b0d95abf 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -200,6 +200,7 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, static BOOL orig_done = False; static int current_idx = 0; static int mapped_idx = 0; + char *sep; DEBUG(5, ("get_passwd_entries: retrieving a list of UNIX users\n")); @@ -267,6 +268,8 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, } } + sep = lp_winbind_separator(); + /* now current_idx == start_idx */ while ((*num_entries) < max_num_entries) { int user_name_len; @@ -275,6 +278,13 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, /* This does the original UNIX user itself */ if(!orig_done) { if ((pwd = getpwent()) == NULL) break; + + /* Don't enumerate winbind users as they are not local */ + + if (strchr(pwd->pw_name, *sep) != NULL) { + continue; + } + user_name_len = strlen(pwd->pw_name); pw_rid = pdb_uid_to_user_rid(pwd->pw_uid); ZERO_STRUCTP(&pw_buf[(*num_entries)]); @@ -753,6 +763,10 @@ static BOOL samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, else if (strequal(sid_str, sam_sid_str)) { char *name; + char *sep; + + sep = lp_winbind_separator(); + /* local aliases */ /* we return the UNIX groups here. This seems to be the right */ /* thing to do, since NT member servers return their local */ @@ -762,6 +776,13 @@ static BOOL samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, while (num_entries < MAX_SAM_ENTRIES && ((grp = getgrent()) != NULL)) { name = grp->gr_name; + + /* Don't return winbind groups as they are not local! */ + + if (strchr(name, *sep) != NULL) { + continue; + } + init_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)); pass[num_entries].user_rid = pdb_gid_to_group_rid(grp->gr_gid); num_entries++; -- cgit From 53c91652c62c3629904be94902be64b5652cc02a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 17 Jul 2000 02:38:43 +0000 Subject: Renamed arguments to se_access_check() (This used to be commit 714b50b47dab46f5cdde49d7c200b353c2e0398a) --- source3/rpc_server/srv_spoolss_nt.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c0c721a082..75cec8f04c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3009,7 +3009,9 @@ static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, pipes_struct *p, SEC_DESC_BUF *secdesc_ctr) { + SEC_DESC_BUF *old_secdesc_ctr = NULL; struct current_user user; + uint32 acc_granted, status; Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -3018,6 +3020,8 @@ static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level, return ERROR_INVALID_HANDLE; } + /* Work out which user is performing the operation */ + if (p->ntlmssp_auth_validated) { memcpy(&user, &p->pipe_user, sizeof(user)); } else { @@ -3025,8 +3029,29 @@ static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level, memcpy(&user, ¤t_user, sizeof(user)); } - return nt_printing_setsec(Printer->dev.printername, &user, - secdesc_ctr); + /* Get old security descriptor */ + + if (!nt_printing_getsec(Printer->dev.printername, &old_secdesc_ctr)) { + DEBUG(3, ("could not get old security descriptor for " + "printer %s", Printer->dev.printername)); + return ERROR_INVALID_FUNCTION; + } + + /* Check the user has permissions to change the security + descriptor. By experimentation with two NT machines, the user + requires Full Access to the printer to change security + information. */ + + if (!se_access_check(old_secdesc_ctr->sec, &user, + PRINTER_ACE_FULL_CONTROL, &acc_granted, + &status)) { + DEBUG(3, ("security descriptor change denied by existing " + "security descriptor\n")); + free_sec_desc_buf(&old_secdesc_ctr); + return status; + } + + return nt_printing_setsec(Printer->dev.printername, secdesc_ctr); } /******************************************************************** @@ -3059,8 +3084,7 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, goto done; } - if (!se_access_check(sd->sec, current_user.uid, current_user.gid, - current_user.ngroups, current_user.groups, + if (!se_access_check(sd->sec, ¤t_user, PRINTER_ACE_FULL_CONTROL, &acc_granted, &result)) { DEBUG(3, ("printer property change denied by security " -- cgit From 873c0366d95dd747f93613f6519836fc8f0c8feb Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 17 Jul 2000 05:38:26 +0000 Subject: Free security descriptor after access check in update_printer_sec() (This used to be commit bc5f9c00be5b8c2f6d258f0c95ed3b4fc0201b87) --- source3/rpc_server/srv_spoolss_nt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 75cec8f04c..587b31f535 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3047,11 +3047,15 @@ static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level, &status)) { DEBUG(3, ("security descriptor change denied by existing " "security descriptor\n")); - free_sec_desc_buf(&old_secdesc_ctr); - return status; + result = status; + goto done; } - return nt_printing_setsec(Printer->dev.printername, secdesc_ctr); + result = nt_printing_setsec(Printer->dev.printername, secdesc_ctr); + + done: + free_sec_desc_buf(&old_secdesc_ctr); + return result; } /******************************************************************** -- cgit From 9665d3fc7b5aaa3b514ddd5fb2bc849e25ec494f Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 17 Jul 2000 06:04:23 +0000 Subject: Missing var. (This used to be commit 5c1c5622269c54dca89eb178ca25981ab7928e75) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 587b31f535..e30180a250 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3011,7 +3011,7 @@ static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level, { SEC_DESC_BUF *old_secdesc_ctr = NULL; struct current_user user; - uint32 acc_granted, status; + uint32 acc_granted, status, result; Printer_entry *Printer = find_printer_index_by_hnd(handle); -- cgit From 2637bfee06c1fb2d5fcb9345ff56b0883e024f31 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Jul 2000 19:25:32 +0000 Subject: rpc_parse/parse_prs.c: Removed extraneous ()'s. rpc_parse/parse_spoolss.c: Fixed the security descriptor marshalling in a INFO_2 struct. for some reason SD's should be done inline after the info2, not as the last buffer marshall. rpc_server/srv_spoolss_nt.c: Removed extraneous ()'s. Jeremy. (This used to be commit f038a24e9f624fdb04cd52769d45783248ce8a38) --- source3/rpc_server/srv_spoolss_nt.c | 44 ++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e30180a250..0143f531d5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -495,7 +495,11 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) prs_set_offset(ps, old_offset); +#if 0 /* JRATEST */ + buffer->string_at_end = buffer_size; +#else buffer->string_at_end=prs_data_size(ps); +#endif return True; } @@ -3240,12 +3244,12 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); job_info->jobid=queue->job; - init_unistr(&(job_info->printername), lp_servicename(snum)); - init_unistr(&(job_info->machinename), temp_name); - init_unistr(&(job_info->username), queue->user); - init_unistr(&(job_info->document), queue->file); - init_unistr(&(job_info->datatype), "RAW"); - init_unistr(&(job_info->text_status), ""); + init_unistr(&job_info->printername, lp_servicename(snum)); + init_unistr(&job_info->machinename, temp_name); + init_unistr(&job_info->username, queue->user); + init_unistr(&job_info->document, queue->file); + init_unistr(&job_info->datatype, "RAW"); + init_unistr(&job_info->text_status, ""); job_info->status=nt_printj_status(queue->status); job_info->priority=queue->priority; job_info->position=position; @@ -3279,14 +3283,14 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, init_unistr(&(job_info->printername), chaine); - init_unistr(&(job_info->machinename), temp_name); - init_unistr(&(job_info->username), queue->user); - init_unistr(&(job_info->document), queue->file); - init_unistr(&(job_info->notifyname), queue->user); - init_unistr(&(job_info->datatype), "RAW"); - init_unistr(&(job_info->printprocessor), "winprint"); - init_unistr(&(job_info->parameters), ""); - init_unistr(&(job_info->text_status), ""); + init_unistr(&job_info->machinename, temp_name); + init_unistr(&job_info->username, queue->user); + init_unistr(&job_info->document, queue->file); + init_unistr(&job_info->notifyname, queue->user); + init_unistr(&job_info->datatype, "RAW"); + init_unistr(&job_info->printprocessor, "winprint"); + init_unistr(&job_info->parameters, ""); + init_unistr(&job_info->text_status, ""); /* and here the security descriptor */ @@ -3328,13 +3332,13 @@ static uint32 enumjobs_level1(print_queue_struct *queue, int snum, } for (i=0; i<*returned; i++) - fill_job_info_1(&(info[i]), &(queue[i]), i, snum); + fill_job_info_1(&info[i], &queue[i], i, snum); safe_free(queue); /* check the required size. */ for (i=0; i<*returned; i++) - (*needed) += spoolss_size_job_info_1(&(info[i])); + (*needed) += spoolss_size_job_info_1(&info[i]); if (!alloc_buffer_size(buffer, *needed)) { safe_free(info); @@ -3343,7 +3347,7 @@ static uint32 enumjobs_level1(print_queue_struct *queue, int snum, /* fill the buffer with the structures */ for (i=0; i<*returned; i++) - new_smb_io_job_info_1("", buffer, &(info[i]), 0); + new_smb_io_job_info_1("", buffer, &info[i], 0); /* clear memory */ safe_free(info); @@ -3374,13 +3378,13 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum, } for (i=0; i<*returned; i++) - fill_job_info_2(&(info[i]), &(queue[i]), i, snum); + fill_job_info_2(&(info[i]), &queue[i], i, snum); safe_free(queue); /* check the required size. */ for (i=0; i<*returned; i++) - (*needed) += spoolss_size_job_info_2(&(info[i])); + (*needed) += spoolss_size_job_info_2(&info[i]); if (!alloc_buffer_size(buffer, *needed)) { safe_free(info); @@ -3389,7 +3393,7 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum, /* fill the buffer with the structures */ for (i=0; i<*returned; i++) - new_smb_io_job_info_2("", buffer, &(info[i]), 0); + new_smb_io_job_info_2("", buffer, &info[i], 0); /* clear memory */ safe_free(info); -- cgit From 78bbcec21b0683aa859aceeb42b106580d48e467 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 22 Jul 2000 00:48:29 +0000 Subject: Fixed open handle code in printers - 3 functions were always being done in order - moved them into open_printer_hnd(). Added saving of comment field. Jeremy. (This used to be commit a0ee774fe92e5d0bc84d1d6729e8c538c67e8aba) --- source3/rpc_server/srv_spoolss_nt.c | 254 +++++++++++++++++++----------------- 1 file changed, 134 insertions(+), 120 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0143f531d5..3a8040d905 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -54,7 +54,7 @@ typedef struct _Printer{ POLICY_HND printer_hnd; BOOL printer_type; union { - fstring printername; + fstring handlename; fstring printerservername; } dev; uint32 type; @@ -216,8 +216,8 @@ static BOOL delete_printer_handle(POLICY_HND *hnd) return False; } - if (del_a_printer(Printer->dev.printername) != 0) { - DEBUG(3,("Error deleting printer %s\n", Printer->dev.printername)); + if (del_a_printer(Printer->dev.handlename) != 0) { + DEBUG(3,("Error deleting printer %s\n", Printer->dev.handlename)); return False; } @@ -227,7 +227,7 @@ static BOOL delete_printer_handle(POLICY_HND *hnd) /**************************************************************************** return the snum of a printer corresponding to an handle ****************************************************************************/ -static BOOL get_printer_snum(const POLICY_HND *hnd, int *number) +static BOOL get_printer_snum(POLICY_HND *hnd, int *number) { Printer_entry *Printer = find_printer_index_by_hnd(hnd); @@ -238,8 +238,8 @@ static BOOL get_printer_snum(const POLICY_HND *hnd, int *number) switch (Printer->printer_type) { case PRINTER_HANDLE_IS_PRINTER: - DEBUG(4,("short name:%s\n", Printer->dev.printername)); - *number = print_queue_snum(Printer->dev.printername); + DEBUG(4,("short name:%s\n", Printer->dev.handlename)); + *number = print_queue_snum(Printer->dev.handlename); return (*number != -1); case PRINTER_HANDLE_IS_PRINTSERVER: return False; @@ -250,28 +250,6 @@ static BOOL get_printer_snum(const POLICY_HND *hnd, int *number) } } -/**************************************************************************** - find first available printer slot. creates a printer handle for you. - ****************************************************************************/ -static BOOL open_printer_hnd(POLICY_HND *hnd) -{ - Printer_entry *new_printer; - - if((new_printer=(Printer_entry *)malloc(sizeof(Printer_entry))) == NULL) - return False; - - ZERO_STRUCTP(new_printer); - - new_printer->open = True; - new_printer->notify.option=NULL; - - memcpy(&new_printer->printer_hnd, hnd, sizeof(*hnd)); - - ubi_dlAddHead( &Printer_list, (ubi_dlNode *)new_printer); - - return True; -} - /**************************************************************************** set printer handle type. ****************************************************************************/ @@ -290,27 +268,21 @@ static BOOL set_printer_hnd_accesstype(POLICY_HND *hnd, uint32 access_required) } /**************************************************************************** - set printer handle type. - check if it's \\server or \\server\printer + Set printer handle type. + Check if it's \\server or \\server\printer ****************************************************************************/ -static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername) + +static BOOL set_printer_hnd_printertype(Printer_entry *Printer, char *handlename) { - Printer_entry *Printer = find_printer_index_by_hnd(hnd); - - if (!OPEN_HANDLE(Printer)) { - DEBUG(0,("set_printer_hnd_printertype: Invalid handle (%s)", OUR_HANDLE(hnd))); - return False; - } - - DEBUG(3,("Setting printer type=%s\n", printername)); + DEBUG(3,("Setting printer type=%s\n", handlename)); - if ( strlen(printername) < 3 ) { - DEBUGADD(4,("A print server must have at least 1 char ! %s\n", printername)); + if ( strlen(handlename) < 3 ) { + DEBUGADD(4,("A print server must have at least 1 char ! %s\n", handlename)); return False; } /* it's a print server */ - if (!strchr(printername+2, '\\')) { + if (!strchr(handlename+2, '\\')) { DEBUGADD(4,("Printer is a print server\n")); Printer->printer_type = PRINTER_HANDLE_IS_PRINTSERVER; return True; @@ -326,34 +298,29 @@ static BOOL set_printer_hnd_printertype(POLICY_HND *hnd, char *printername) } /**************************************************************************** - set printer handle printername. + Set printer handle name. ****************************************************************************/ -static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) + +static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) { - Printer_entry *Printer = find_printer_index_by_hnd(hnd); NT_PRINTER_INFO_LEVEL *printer = NULL; int snum; int n_services=lp_numservices(); char *aprinter; BOOL found=False; - if (!OPEN_HANDLE(Printer)) { - DEBUG(0,("set_printer_hnd_printername: Invalid handle (%s)\n", OUR_HANDLE(hnd))); - return False; - } - - DEBUG(4,("Setting printer name=%s (len=%d)\n", printername, strlen(printername))); + DEBUG(4,("Setting printer name=%s (len=%d)\n", handlename, strlen(handlename))); if (Printer->printer_type==PRINTER_HANDLE_IS_PRINTSERVER) { ZERO_STRUCT(Printer->dev.printerservername); - strncpy(Printer->dev.printerservername, printername, strlen(printername)); + strncpy(Printer->dev.printerservername, handlename, strlen(handlename)); return True; } if (Printer->printer_type!=PRINTER_HANDLE_IS_PRINTER) return False; - aprinter=strchr(printername+2, '\\'); + aprinter=strchr(handlename+2, '\\'); aprinter++; DEBUGADD(5,("searching for [%s] (len=%d)\n", aprinter, strlen(aprinter))); @@ -376,7 +343,7 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) continue; - DEBUG(10,("set_printer_hnd_printername: printername [%s], aprinter [%s]\n", + DEBUG(10,("set_printer_hnd_name: name [%s], aprinter [%s]\n", printer->info_2->printername, aprinter )); if ( strlen(printer->info_2->printername) != strlen(aprinter) ) { @@ -393,7 +360,7 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) } /* - * if we haven't found a printer with the given printername + * if we haven't found a printer with the given handlename * then it can be a share name as you can open both \\server\printer and * \\server\share */ @@ -411,12 +378,12 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) if ( !(lp_snum_ok(snum) && lp_print_ok(snum) ) ) continue; - DEBUGADD(5,("set_printer_hnd_printername: share:%s\n",lp_servicename(snum))); + DEBUGADD(5,("set_printer_hnd_name: share:%s\n",lp_servicename(snum))); if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) continue; - DEBUG(10,("set_printer_hnd_printername: printername [%s], aprinter [%s]\n", + DEBUG(10,("set_printer_hnd_name: printername [%s], aprinter [%s]\n", printer->info_2->printername, aprinter )); if ( strlen(lp_servicename(snum)) != strlen(aprinter) ) { @@ -439,17 +406,53 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername) } snum--; - DEBUGADD(4,("set_printer_hnd_printername: Printer found: %s -> %s[%x]\n", + DEBUGADD(4,("set_printer_hnd_name: Printer found: %s -> %s[%x]\n", printer->info_2->printername, lp_servicename(snum),snum)); - ZERO_STRUCT(Printer->dev.printername); - strncpy(Printer->dev.printername, lp_servicename(snum), strlen(lp_servicename(snum))); + ZERO_STRUCT(Printer->dev.handlename); + strncpy(Printer->dev.handlename, lp_servicename(snum), strlen(lp_servicename(snum))); free_a_printer(&printer, 2); return True; } +/**************************************************************************** + find first available printer slot. creates a printer handle for you. + ****************************************************************************/ + +static BOOL open_printer_hnd(POLICY_HND *hnd, char *name) +{ + Printer_entry *new_printer; + + clear_handle(hnd); + create_printer_hnd(hnd); + + if((new_printer=(Printer_entry *)malloc(sizeof(Printer_entry))) == NULL) + return False; + + ZERO_STRUCTP(new_printer); + + new_printer->open = True; + new_printer->notify.option=NULL; + + memcpy(&new_printer->printer_hnd, hnd, sizeof(*hnd)); + + ubi_dlAddHead( &Printer_list, (ubi_dlNode *)new_printer); + + if (!set_printer_hnd_printertype(new_printer, name)) { + close_printer_handle(hnd); + return False; + } + + if (!set_printer_hnd_name(new_printer, name)) { + close_printer_handle(hnd); + return False; + } + + return True; +} + /******************************************************************** Return True is the handle is a print server. ********************************************************************/ @@ -516,8 +519,6 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, { fstring name; - clear_handle(handle); - if (printername == NULL) return ERROR_INVALID_PRINTER_NAME; @@ -527,20 +528,9 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, DEBUGADD(3,("checking name: %s\n",name)); - create_printer_hnd(handle); - - open_printer_hnd(handle); - - if (!set_printer_hnd_printertype(handle, name)) { - close_printer_handle(handle); + if (!open_printer_hnd(handle, name)) return ERROR_INVALID_PRINTER_NAME; - } - if (!set_printer_hnd_printername(handle, name)) { - close_printer_handle(handle); - return ERROR_INVALID_PRINTER_NAME; - } - /* if (printer_default->datatype_ptr != NULL) { @@ -747,7 +737,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d /******************************************************************** GetPrinterData on a printer Handle. ********************************************************************/ -static BOOL getprinterdata_printer(const POLICY_HND *handle, +static BOOL getprinterdata_printer(POLICY_HND *handle, fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size ) { @@ -803,7 +793,7 @@ static BOOL getprinterdata_printer(const POLICY_HND *handle, /******************************************************************** * spoolss_getprinterdata ********************************************************************/ -uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, +uint32 _spoolss_getprinterdata(POLICY_HND *handle, UNISTR2 *valuename, uint32 in_size, uint32 *type, uint32 *out_size, @@ -874,7 +864,7 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename, * in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe * called from api_spoolss_rffpcnex ********************************************************************/ -uint32 _spoolss_rffpcnex(const POLICY_HND *handle, uint32 flags, uint32 options, +uint32 _spoolss_rffpcnex(POLICY_HND *handle, uint32 flags, uint32 options, const UNISTR2 *localmachine, uint32 printerlocal, SPOOL_NOTIFY_OPTION *option) { @@ -1518,7 +1508,7 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO * * fill a notify_info struct with info asked * ********************************************************************/ -static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) +static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) { int snum; Printer_entry *Printer=find_printer_index_by_hnd(hnd); @@ -1579,7 +1569,7 @@ static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info /******************************************************************** * spoolss_rfnpcnex ********************************************************************/ -uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, uint32 change, +uint32 _spoolss_rfnpcnex( POLICY_HND *handle, uint32 change, SPOOL_NOTIFY_OPTION *option, SPOOL_NOTIFY_INFO *info) { Printer_entry *Printer=find_printer_index_by_hnd(handle); @@ -1902,7 +1892,12 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer init_unistr(&printer->portname, lp_servicename(snum)); /* port */ #endif init_unistr(&printer->drivername, ntprinter->info_2->drivername); /* drivername */ - init_unistr(&printer->comment, lp_comment(snum)); /* comment */ + + if (*ntprinter->info_2->comment == '\0') + init_unistr(&printer->comment, lp_comment(snum)); /* comment */ + else + init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ + init_unistr(&printer->location, ntprinter->info_2->location); /* location */ init_unistr(&printer->sepfile, ntprinter->info_2->sepfile); /* separator file */ init_unistr(&printer->printprocessor, ntprinter->info_2->printprocessor);/* print processor */ @@ -2774,7 +2769,7 @@ static uint32 getprinterdriver2_level3(fstring servername, fstring architecture, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level, +uint32 _spoolss_getprinterdriver2(POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level, uint32 clientmajorversion, uint32 clientminorversion, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *servermajorversion, uint32 *serverminorversion) @@ -2813,7 +2808,7 @@ uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_a /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_startpageprinter(const POLICY_HND *handle) +uint32 _spoolss_startpageprinter(POLICY_HND *handle) { Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -2828,7 +2823,7 @@ uint32 _spoolss_startpageprinter(const POLICY_HND *handle) /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_endpageprinter(const POLICY_HND *handle) +uint32 _spoolss_endpageprinter(POLICY_HND *handle) { Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -2848,7 +2843,7 @@ uint32 _spoolss_endpageprinter(const POLICY_HND *handle) * called from the spoolss dispatcher * ********************************************************************/ -uint32 _spoolss_startdocprinter(const POLICY_HND *handle, uint32 level, +uint32 _spoolss_startdocprinter(POLICY_HND *handle, uint32 level, pipes_struct *p, DOC_INFO *docinfo, uint32 *jobid) { @@ -2920,7 +2915,7 @@ uint32 _spoolss_startdocprinter(const POLICY_HND *handle, uint32 level, * called from the spoolss dispatcher * ********************************************************************/ -uint32 _spoolss_enddocprinter(const POLICY_HND *handle) +uint32 _spoolss_enddocprinter(POLICY_HND *handle) { Printer_entry *Printer=find_printer_index_by_hnd(handle); @@ -2938,9 +2933,9 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle) /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_writeprinter( const POLICY_HND *handle, +uint32 _spoolss_writeprinter( POLICY_HND *handle, uint32 buffer_size, - const uint8 *buffer, + uint8 *buffer, uint32 *buffer_written) { Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -2961,7 +2956,7 @@ uint32 _spoolss_writeprinter( const POLICY_HND *handle, * called from the spoolss dispatcher * ********************************************************************/ -static uint32 control_printer(const POLICY_HND *handle, uint32 command, +static uint32 control_printer(POLICY_HND *handle, uint32 command, pipes_struct *p) { struct current_user user; @@ -3009,7 +3004,7 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command, * called by spoolss_api_setprinter * when updating a printer description ********************************************************************/ -static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level, +static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, pipes_struct *p, SEC_DESC_BUF *secdesc_ctr) { @@ -3035,9 +3030,9 @@ static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level, /* Get old security descriptor */ - if (!nt_printing_getsec(Printer->dev.printername, &old_secdesc_ctr)) { + if (!nt_printing_getsec(Printer->dev.handlename, &old_secdesc_ctr)) { DEBUG(3, ("could not get old security descriptor for " - "printer %s", Printer->dev.printername)); + "printer %s", Printer->dev.handlename)); return ERROR_INVALID_FUNCTION; } @@ -3055,19 +3050,42 @@ static uint32 update_printer_sec(const POLICY_HND *handle, uint32 level, goto done; } - result = nt_printing_setsec(Printer->dev.printername, secdesc_ctr); + result = nt_printing_setsec(Printer->dev.handlename, secdesc_ctr); done: free_sec_desc_buf(&old_secdesc_ctr); return result; } +/******************************************************************** + Do Samba sanity checks on a printer info struct. + ********************************************************************/ + +static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) +{ + /* + * Ensure that this printer is shared under the correct name + * as this is what Samba insists upon. + */ + + if (!(info->attributes & PRINTER_ATTRIBUTE_SHARED)) + return False; + + if (!(info->attributes & PRINTER_ATTRIBUTE_RAW_ONLY)) + return False; + + if (!strequal(info->sharename, lp_servicename(snum))) + return False; + + return True; +} + /******************************************************************** * called by spoolss_api_setprinter * when updating a printer description ********************************************************************/ -static uint32 update_printer(const POLICY_HND *handle, uint32 level, +static uint32 update_printer(POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, DEVICEMODE *devmode) { @@ -3085,9 +3103,9 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, /* Check calling user has permission to update printer description */ #if 1 /* JFMTEST */ - if (!nt_printing_getsec(Printer->dev.printername, &sd)) { + if (!nt_printing_getsec(Printer->dev.handlename, &sd)) { DEBUG(3, ("Could not get security descriptor for printer %s", - Printer->dev.printername)); + Printer->dev.handlename)); result = ERROR_INVALID_FUNCTION; goto done; } @@ -3152,7 +3170,16 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, free_nt_devicemode(&printer->info_2->devmode); printer->info_2->devmode=NULL; } - + + /* + * Do sanity check on the requested changes for Samba. + */ + + if (!check_printer_ok(printer->info_2, snum)) { + result = ERROR_ACCESS_DENIED; + goto done; + } + if (add_a_printer(*printer, 2)!=0) { /* I don't really know what to return here !!! */ result = ERROR_ACCESS_DENIED; @@ -3168,7 +3195,7 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, +uint32 _spoolss_setprinter(POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, DEVMODE_CTR devmode_ctr, SEC_DESC_BUF *secdesc_ctr, @@ -3201,7 +3228,7 @@ uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_fcpn(const POLICY_HND *handle) +uint32 _spoolss_fcpn(POLICY_HND *handle) { Printer_entry *Printer= find_printer_index_by_hnd(handle); @@ -3224,7 +3251,7 @@ uint32 _spoolss_fcpn(const POLICY_HND *handle) /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_addjob(const POLICY_HND *handle, uint32 level, +uint32 _spoolss_addjob(POLICY_HND *handle, uint32 level, NEW_BUFFER *buffer, uint32 offered) { return NT_STATUS_NO_PROBLEMO; @@ -3448,14 +3475,14 @@ uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_schedulejob( const POLICY_HND *handle, uint32 jobid) +uint32 _spoolss_schedulejob( POLICY_HND *handle, uint32 jobid) { return 0x0; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_setjob( const POLICY_HND *handle, +uint32 _spoolss_setjob( POLICY_HND *handle, uint32 jobid, uint32 level, pipes_struct *p, @@ -3713,7 +3740,7 @@ static void fill_form_1(FORM_1 *form, nt_forms_struct *list, int position) /**************************************************************************** ****************************************************************************/ -uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level, +uint32 _new_spoolss_enumforms( POLICY_HND *handle, uint32 level, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *numofforms) { @@ -3991,8 +4018,6 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, ZERO_STRUCTP(printer); - clear_handle(handle); - /* convert from UNICODE to ASCII - this allocates the info_2 struct inside *printer.*/ convert_printer_info(info, printer, 2); @@ -4006,19 +4031,8 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, return ERROR_ACCESS_DENIED; } - create_printer_hnd(handle); - - open_printer_hnd(handle); - - if (!set_printer_hnd_printertype(handle, name)) { + if (!open_printer_hnd(handle, name)) { free_a_printer(&printer,2); - close_printer_handle(handle); - return ERROR_ACCESS_DENIED; - } - - if (!set_printer_hnd_printername(handle, name)) { - free_a_printer(&printer,2); - close_printer_handle(handle); return ERROR_ACCESS_DENIED; } @@ -4200,7 +4214,7 @@ uint32 _spoolss_getprinterdriverdirectory(UNISTR2 *name, UNISTR2 *uni_environmen /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, +uint32 _spoolss_enumprinterdata(POLICY_HND *handle, uint32 idx, uint32 in_value_len, uint32 in_data_len, uint32 *out_max_value_len, uint16 **out_value, uint32 *out_value_len, uint32 *out_type, @@ -4327,7 +4341,7 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_setprinterdata( const POLICY_HND *handle, +uint32 _spoolss_setprinterdata( POLICY_HND *handle, const UNISTR2 *value, uint32 type, uint32 max_len, @@ -4371,7 +4385,7 @@ uint32 _spoolss_setprinterdata( const POLICY_HND *handle, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_addform( const POLICY_HND *handle, +uint32 _spoolss_addform( POLICY_HND *handle, uint32 level, const FORM *form) { @@ -4398,7 +4412,7 @@ uint32 _spoolss_addform( const POLICY_HND *handle, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_setform( const POLICY_HND *handle, +uint32 _spoolss_setform( POLICY_HND *handle, const UNISTR2 *uni_name, uint32 level, const FORM *form) -- cgit From ac70155b252eb57e28d54598556e244da438cd34 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 25 Jul 2000 01:50:53 +0000 Subject: Tidy up code to add printer. Always index in tdb by sharename. This is beginning to come together... Jeremy. (This used to be commit 614bf56186b5836020a7813855a5108da0ee8433) --- source3/rpc_server/srv_spoolss_nt.c | 38 ++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3a8040d905..7d5036c6d4 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3068,14 +3068,25 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) * as this is what Samba insists upon. */ - if (!(info->attributes & PRINTER_ATTRIBUTE_SHARED)) + if (!(info->attributes & PRINTER_ATTRIBUTE_SHARED)) { + DEBUG(10,("check_printer_ok: SHARED check failed (%x).\n", (unsigned int)info->attributes )); return False; + } - if (!(info->attributes & PRINTER_ATTRIBUTE_RAW_ONLY)) - return False; + if (!(info->attributes & PRINTER_ATTRIBUTE_RAW_ONLY)) { + /* NT forgets to set the raw attribute but sends the correct type. */ + if (strequal(info->datatype, "RAW")) + info->attributes |= PRINTER_ATTRIBUTE_RAW_ONLY; + else { + DEBUG(10,("check_printer_ok: RAW check failed (%x).\n", (unsigned int)info->attributes )); + return False; + } + } - if (!strequal(info->sharename, lp_servicename(snum))) + if (!strequal(info->sharename, lp_servicename(snum))) { + DEBUG(10,("check_printer_ok: NAME check failed (%s) (%s).\n", info->sharename, lp_servicename(snum))); return False; + } return True; } @@ -4010,6 +4021,7 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, NT_PRINTER_INFO_LEVEL *printer = NULL; fstring name; fstring share_name; + int snum; if ((printer = (NT_PRINTER_INFO_LEVEL *)malloc(sizeof(NT_PRINTER_INFO_LEVEL))) == NULL) { DEBUG(0,("spoolss_addprinterex_level_2: malloc fail.\n")); @@ -4021,10 +4033,24 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, /* convert from UNICODE to ASCII - this allocates the info_2 struct inside *printer.*/ convert_printer_info(info, printer, 2); - unistr2_to_ascii(share_name, &info->info_2->printername, sizeof(share_name)-1); + unistr2_to_ascii(share_name, &info->info_2->sharename, sizeof(share_name)-1); slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname, share_name); + if ((snum = print_queue_snum(share_name)) == -1) { + free_a_printer(&printer,2); + return ERROR_ACCESS_DENIED; + } + + /* + * Do sanity check on the requested changes for Samba. + */ + + if (!check_printer_ok(printer->info_2, snum)) { + free_a_printer(&printer,2); + return ERROR_ACCESS_DENIED; + } + /* write the ASCII on disk */ if (add_a_printer(*printer, 2) != 0) { free_a_printer(&printer,2); @@ -4032,6 +4058,8 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, } if (!open_printer_hnd(handle, name)) { + /* Handle open failed - remove addition. */ + del_a_printer(share_name); free_a_printer(&printer,2); return ERROR_ACCESS_DENIED; } -- cgit From 5a5ef183799dd84ff453db849e929533e709fd0b Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 25 Jul 2000 13:15:16 +0000 Subject: A rather big change set ! (listed in no particular order) - changed the default forms flag to 2 - all short architecture name are uppercased - get_short_archi() is now case unsensitive - the drivers TDB is indexed by archi/version/name - implemented code to move drivers from the upload area to the download area. Someone else need to look at that code. - don't return anymore a default driver if it doesn't exist in the TDB. Instead return an error. - cleaned prs_unistr. - #ifdef out jeremy's new SD parsing in printer_info_2 - removed the unused MANGLE_CODE - #ifdef out the security checking in update_printer() as it doesn't work for me. Zap your ntdrivers.tdb, it won't work anymore. J.F. (This used to be commit ac0a145acc0953a6f362497abbf4dfe70aa522a6) --- source3/rpc_server/srv_spoolss.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 407 +++++++++++++++++++----------------- 2 files changed, 211 insertions(+), 198 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 3f72305465..8b431551b5 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -880,7 +880,7 @@ static BOOL api_spoolss_addprinterdriver(pipes_struct *p) return False; } - r_u.status = _spoolss_addprinterdriver(&q_u.server_name, q_u.level, &q_u.info); + r_u.status = _spoolss_addprinterdriver(p, &q_u.server_name, q_u.level, &q_u.info); if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n")); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7d5036c6d4..99ed18677a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -25,10 +25,6 @@ #include "includes.h" -#ifndef MANGLE_DRIVER_PATH -#define MANGLE_DRIVER_PATH 0 -#endif - extern int DEBUGLEVEL; extern pstring global_myname; @@ -2479,73 +2475,66 @@ uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, } /******************************************************************** - * construct_printer_driver_info_1 - * fill a construct_printer_driver_info_1 struct + * fill a DRIVER_INFO_1 struct ********************************************************************/ -static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, - NT_PRINTER_DRIVER_INFO_LEVEL driver, - fstring servername, fstring architecture) +static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername, fstring architecture) { init_unistr( &(info->name), driver.info_3->name); } -static void construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, - fstring servername, fstring architecture) +/******************************************************************** + * construct_printer_driver_info_1 + ********************************************************************/ +static uint32 construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; ZERO_STRUCT(driver); - get_a_printer(&printer, 2, lp_servicename(snum) ); - get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture); - + if (get_a_printer(&printer, 2, lp_servicename(snum)) != 0) + return ERROR_INVALID_PRINTER_NAME; + + if (get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version) != 0) + return ERROR_UNKNOWN_PRINTER_DRIVER; + fill_printer_driver_info_1(info, driver, servername, architecture); free_a_printer(&printer,2); + + return NT_STATUS_NO_PROBLEMO; } /******************************************************************** * construct_printer_driver_info_2 * fill a printer_info_2 struct ********************************************************************/ -static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, - NT_PRINTER_DRIVER_INFO_LEVEL driver, - fstring servername, fstring architecture) +static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) { - pstring where; pstring temp_driverpath; pstring temp_datafile; pstring temp_configfile; - fstring short_archi; - - get_short_archi(short_archi,architecture); - - snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\", servername, short_archi); info->version=driver.info_3->cversion; - init_unistr( &info->name, driver.info_3->name ); - init_unistr( &info->architecture, architecture ); - - snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "%s%s", where, - driver.info_3->driverpath); - init_unistr( &info->driverpath, temp_driverpath ); + init_unistr( &info->name, driver.info_3->name ); + init_unistr( &info->architecture, driver.info_3->environment ); - snprintf(temp_datafile, sizeof(temp_datafile)-1, "%s%s", where, - driver.info_3->datafile); - init_unistr( &info->datafile, temp_datafile ); + snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + init_unistr( &info->driverpath, temp_driverpath ); - snprintf(temp_configfile, sizeof(temp_configfile)-1, "%s%s", where, - driver.info_3->configfile); - init_unistr( &info->configfile, temp_configfile ); + snprintf(temp_datafile, sizeof(temp_datafile)-1, "\\\\%s%s", servername, driver.info_3->datafile); + init_unistr( &info->datafile, temp_datafile ); + + snprintf(temp_configfile, sizeof(temp_configfile)-1, "\\\\%s%s", servername, driver.info_3->configfile); + init_unistr( &info->configfile, temp_configfile ); } /******************************************************************** * construct_printer_driver_info_2 * fill a printer_info_2 struct ********************************************************************/ -static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstring servername, fstring architecture) +static uint32 construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -2553,12 +2542,17 @@ static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstri ZERO_STRUCT(printer); ZERO_STRUCT(driver); - get_a_printer(&printer, 2, lp_servicename(snum) ); - get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture); + if (!get_a_printer(&printer, 2, lp_servicename(snum)) != 0) + return ERROR_INVALID_PRINTER_NAME; + + if (!get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version) != 0) + return ERROR_UNKNOWN_PRINTER_DRIVER; - fill_printer_driver_info_2(info, driver, servername, architecture); + fill_printer_driver_info_2(info, driver, servername); free_a_printer(&printer,2); + + return NT_STATUS_NO_PROBLEMO; } /******************************************************************** @@ -2566,7 +2560,7 @@ static void construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstri * * convert an array of ascii string to a UNICODE string ********************************************************************/ -static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *where) +static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *servername) { int i=0; int j=0; @@ -2584,7 +2578,7 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *whe if (!v) v = ""; /* hack to handle null lists */ } if (strlen(v) == 0) break; - snprintf(line, sizeof(line)-1, "%s%s", where, v); + snprintf(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) { DEBUG(0,("init_unistr_array: Realloc error\n" )); @@ -2605,67 +2599,63 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *whe * construct_printer_info_3 * fill a printer_info_3 struct ********************************************************************/ -static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, - NT_PRINTER_DRIVER_INFO_LEVEL driver, - fstring servername, fstring architecture) +static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) { - pstring where; pstring temp_driverpath; pstring temp_datafile; pstring temp_configfile; pstring temp_helpfile; - fstring short_archi; - - get_short_archi(short_archi, architecture); - -#if MANGLE_DRIVER_PATH - snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\%s\\", servername, short_archi, driver.info_3->name); -#else - snprintf(where,sizeof(where)-1,"\\\\%s\\print$\\%s\\", servername, short_archi); -#endif info->version=driver.info_3->cversion; - init_unistr( &info->name, driver.info_3->name ); - init_unistr( &info->architecture, architecture ); - - snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "%s%s", where, driver.info_3->driverpath); + init_unistr( &info->name, driver.info_3->name ); + init_unistr( &info->architecture, driver.info_3->environment ); + + snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "\\\\%s%s", servername, driver.info_3->driverpath); init_unistr( &info->driverpath, temp_driverpath ); - - snprintf(temp_datafile, sizeof(temp_datafile)-1, "%s%s", where, driver.info_3->datafile); + + snprintf(temp_datafile, sizeof(temp_datafile)-1, "\\\\%s%s", servername, driver.info_3->datafile); init_unistr( &info->datafile, temp_datafile ); - - snprintf(temp_configfile, sizeof(temp_configfile)-1, "%s%s", where, driver.info_3->configfile); + + snprintf(temp_configfile, sizeof(temp_configfile)-1, "\\\\%s%s", servername, driver.info_3->configfile); init_unistr( &info->configfile, temp_configfile ); - - snprintf(temp_helpfile, sizeof(temp_helpfile)-1, "%s%s", where, driver.info_3->helpfile); + + snprintf(temp_helpfile, sizeof(temp_helpfile)-1, "\\\\%s%s", servername, driver.info_3->helpfile); init_unistr( &info->helpfile, temp_helpfile ); init_unistr( &info->monitorname, driver.info_3->monitorname ); init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype ); info->dependentfiles=NULL; - init_unistr_array(&info->dependentfiles, driver.info_3->dependentfiles, where); + init_unistr_array(&info->dependentfiles, driver.info_3->dependentfiles, servername); } /******************************************************************** * construct_printer_info_3 * fill a printer_info_3 struct ********************************************************************/ -static void construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, - fstring servername, fstring architecture) +static uint32 construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; - +uint32 status=0; ZERO_STRUCT(driver); - get_a_printer(&printer, 2, lp_servicename(snum) ); - get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture); + 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; + + 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) + return ERROR_UNKNOWN_PRINTER_DRIVER; - fill_printer_driver_info_3(info, driver, servername, architecture); + fill_printer_driver_info_3(info, driver, servername); free_a_printer(&printer,2); + + return NT_STATUS_NO_PROBLEMO; } /**************************************************************************** @@ -2678,14 +2668,19 @@ static void free_printer_driver_info_3(DRIVER_INFO_3 *info) /**************************************************************************** ****************************************************************************/ -static uint32 getprinterdriver2_level1(fstring servername, fstring architecture, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static uint32 getprinterdriver2_level1(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_1 *info=NULL; + uint32 status; if((info=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1))) == NULL) return ERROR_NOT_ENOUGH_MEMORY; - construct_printer_driver_info_1(info, snum, servername, architecture); + status=construct_printer_driver_info_1(info, snum, servername, architecture, version); + if (status != NT_STATUS_NO_PROBLEMO) { + safe_free(info); + return status; + } /* check the required size. */ *needed += spoolss_size_printer_driver_info_1(info); @@ -2709,14 +2704,19 @@ static uint32 getprinterdriver2_level1(fstring servername, fstring architecture, /**************************************************************************** ****************************************************************************/ -static uint32 getprinterdriver2_level2(fstring servername, fstring architecture, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static uint32 getprinterdriver2_level2(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_2 *info=NULL; + uint32 status; if((info=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2))) == NULL) return ERROR_NOT_ENOUGH_MEMORY; - construct_printer_driver_info_2(info, snum, servername, architecture); + status=construct_printer_driver_info_2(info, snum, servername, architecture, version); + if (status != NT_STATUS_NO_PROBLEMO) { + safe_free(info); + return status; + } /* check the required size. */ *needed += spoolss_size_printer_driver_info_2(info); @@ -2740,13 +2740,17 @@ static uint32 getprinterdriver2_level2(fstring servername, fstring architecture, /**************************************************************************** ****************************************************************************/ -static uint32 getprinterdriver2_level3(fstring servername, fstring architecture, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static uint32 getprinterdriver2_level3(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_3 info; + uint32 status; ZERO_STRUCT(info); - construct_printer_driver_info_3(&info, snum, servername, architecture); + status=construct_printer_driver_info_3(&info, snum, servername, architecture, version); + if (status != NT_STATUS_NO_PROBLEMO) { + return status; + } /* check the required size. */ *needed += spoolss_size_printer_driver_info_3(&info); @@ -2792,13 +2796,13 @@ uint32 _spoolss_getprinterdriver2(POLICY_HND *handle, const UNISTR2 *uni_arch, u switch (level) { case 1: - return getprinterdriver2_level1(servername, architecture, snum, buffer, offered, needed); + return getprinterdriver2_level1(servername, architecture, clientmajorversion, snum, buffer, offered, needed); break; case 2: - return getprinterdriver2_level2(servername, architecture, snum, buffer, offered, needed); + return getprinterdriver2_level2(servername, architecture, clientmajorversion, snum, buffer, offered, needed); break; case 3: - return getprinterdriver2_level3(servername, architecture, snum, buffer, offered, needed); + return getprinterdriver2_level3(servername, architecture, clientmajorversion, snum, buffer, offered, needed); break; default: return ERROR_INVALID_LEVEL; @@ -3113,7 +3117,7 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, /* Check calling user has permission to update printer description */ -#if 1 /* JFMTEST */ +#if 0 /* JFMTEST */ if (!nt_printing_getsec(Printer->dev.handlename, &sd)) { DEBUG(3, ("Could not get security descriptor for printer %s", Printer->dev.handlename)); @@ -3543,24 +3547,46 @@ uint32 _spoolss_setjob( POLICY_HND *handle, /**************************************************************************** Enumerates all printer drivers at level 1. ****************************************************************************/ -static uint32 enumprinterdrivers_level1(fstring *list, fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; + int ndrivers; + uint32 version; + fstring *list = NULL; + NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_1 *driver_info_1=NULL; - ZERO_STRUCT(driver); + *returned=0; - if((driver_info_1=(DRIVER_INFO_1 *)malloc(*returned * sizeof(DRIVER_INFO_1))) == NULL) - return ERROR_NOT_ENOUGH_MEMORY; +#define MAX_VERSION 4 - for (i=0; i<*returned; i++) { - get_a_printer_driver(&driver, 3, list[i], architecture); - fill_printer_driver_info_1(&(driver_info_1[i]), driver, servername, architecture ); + for (version=0; version 0 && - !(driver_info_2=(DRIVER_INFO_2 *)malloc(*returned * sizeof(DRIVER_INFO_2)))) - return ERROR_NOT_ENOUGH_MEMORY; + *returned=0; - for (i=0; i<*returned; i++) { - NT_PRINTER_DRIVER_INFO_LEVEL driver; - ZERO_STRUCT(driver); - if (get_a_printer_driver(&driver, 3, list[i], architecture) - != 0) { - *returned = i; - break; +#define MAX_VERSION 4 + + for (version=0; versioninfo_3->environment); - model = driver->info_3->name; - break; - case 6: - get_short_archi(short_archi, driver->info_6->environment); - model = driver->info_6->name; - break; - default: - DEBUG(0,("modify_driver_heirarchy: unknown info level (%d)\n", level)); - return ERROR_INVALID_LEVEL; - break; - } - - slprintf(path_old, sizeof(path_old)-1, "%s/%s/TMP_%s", lp_pathname(snum), short_archi, - client_addr()); - - /* Clean up any '/' and other characters in the model name. */ - alpha_strcpy(model_name, model, sizeof(pstring)); - - slprintf(path_new, sizeof(path_new)-1, "%s/%s/%s", lp_pathname(snum), short_archi, model_name); - - DEBUG(10,("modify_driver_heirarchy: old_path=%s, new_path=%s\n", - path_old, path_new )); - if (dos_rename(path_old, path_new) == -1) { - DEBUG(0,("modify_driver_heirarchy: rename from %s to %s failed (%s)\n", - path_old, path_new, strerror(errno) )); - /* We need to clean up here.... - how ? */ - return ERROR_ACCESS_DENIED; /* We need a generic mapping from NT errors here... */ - } - - return NT_STATUS_NO_PROBLEMO; -} -#endif - /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name, - uint32 level, - const SPOOL_PRINTER_DRIVER_INFO_LEVEL *info) +uint32 _spoolss_addprinterdriver(pipes_struct *p, const UNISTR2 *server_name, + uint32 level, const SPOOL_PRINTER_DRIVER_INFO_LEVEL *info) { uint32 err = NT_STATUS_NO_PROBLEMO; NT_PRINTER_DRIVER_INFO_LEVEL driver; + struct current_user user; + ZERO_STRUCT(driver); + if (p->ntlmssp_auth_validated) { + memcpy(&user, &p->pipe_user, sizeof(user)); + } else { + extern struct current_user current_user; + memcpy(&user, ¤t_user, sizeof(user)); + } + convert_printer_driver_info(info, &driver, level); + DEBUG(5,("Cleaning driver's information\n")); + clean_up_driver_struct(driver, level); + + DEBUG(5,("Moving driver to final destination\n")); + move_driver_to_download_area(driver, level, &user); + if (add_a_printer_driver(driver, level)!=0) return ERROR_ACCESS_DENIED; -#if MANGLE_DRIVER_PATH - err = modify_driver_heirarchy(&driver, level); -#endif - free_a_printer_driver(driver, level); return err; @@ -4185,20 +4201,17 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen pstring long_archi; pstring short_archi; DRIVER_DIRECTORY_1 *info=NULL; - + + 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((info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1))) == NULL) return ERROR_NOT_ENOUGH_MEMORY; - - unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); - get_short_archi(short_archi, long_archi); - -#if MANGLE_DRIVER_PATH - slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s\\TMP_%s", global_myname, short_archi, - client_addr()); -#else - slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", - global_myname, short_archi); -#endif + + slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", global_myname, short_archi); + DEBUG(4,("printer driver directory: [%s]\n", path)); fill_driverdir_1(info, path); -- cgit From fcbf69495784000861d432c13217702cc28884f8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 25 Jul 2000 17:09:29 +0000 Subject: Added some error checking and returns to the new 'move' code. Jeremy. (This used to be commit 0bd88d304cd773e0bbf3e6f7fedcb3b544d41cbe) --- source3/rpc_server/srv_spoolss_nt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 99ed18677a..53df5dfee4 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4176,7 +4176,8 @@ uint32 _spoolss_addprinterdriver(pipes_struct *p, const UNISTR2 *server_name, clean_up_driver_struct(driver, level); DEBUG(5,("Moving driver to final destination\n")); - move_driver_to_download_area(driver, level, &user); + if(!move_driver_to_download_area(driver, level, &user)) + return ERROR_ACCESS_DENIED; if (add_a_printer_driver(driver, level)!=0) return ERROR_ACCESS_DENIED; @@ -4190,7 +4191,7 @@ uint32 _spoolss_addprinterdriver(pipes_struct *p, const UNISTR2 *server_name, ****************************************************************************/ static void fill_driverdir_1(DRIVER_DIRECTORY_1 *info, char *name) { - init_unistr(&(info->name), name); + init_unistr(&info->name, name); } /**************************************************************************** -- cgit From bc22ae0b47bddd919b07e4c81ae12243c1f3226a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 25 Jul 2000 22:35:57 +0000 Subject: Fixed up error checking and move printer file code. Fixed a memory leak. Jeremy. (This used to be commit 5130dd0f8b80aed5fb3c0df290b627057cc9b825) --- source3/rpc_server/srv_spoolss_nt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 53df5dfee4..30131482ac 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2648,8 +2648,10 @@ uint32 status=0; 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) + if (status != 0) { + free_a_printer(&printer,2); return ERROR_UNKNOWN_PRINTER_DRIVER; + } fill_printer_driver_info_3(info, driver, servername); @@ -3764,7 +3766,6 @@ uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32 NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - int i; fstring *list = NULL; fstring servername; fstring architecture; -- cgit From c89cf814cc976924c9e1db7ea448af3893a6f70d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 26 Jul 2000 03:38:30 +0000 Subject: Fixed memory leaks in _spoolss_addprinterdriver() (This used to be commit 1f49788442b0d1264c70166e727b8588b936e6ec) --- source3/rpc_server/srv_spoolss_nt.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 30131482ac..288b9648b7 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4177,14 +4177,18 @@ uint32 _spoolss_addprinterdriver(pipes_struct *p, const UNISTR2 *server_name, clean_up_driver_struct(driver, level); DEBUG(5,("Moving driver to final destination\n")); - if(!move_driver_to_download_area(driver, level, &user)) - return ERROR_ACCESS_DENIED; + if(!move_driver_to_download_area(driver, level, &user)) { + err = ERROR_ACCESS_DENIED; + goto done; + } - if (add_a_printer_driver(driver, level)!=0) - return ERROR_ACCESS_DENIED; + if (add_a_printer_driver(driver, level)!=0) { + err = ERROR_ACCESS_DENIED; + goto done; + } + done: free_a_printer_driver(driver, level); - return err; } -- cgit From 134a4b86548db77cba292c50fbd6b91ecaa69f14 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Wed, 26 Jul 2000 10:31:05 +0000 Subject: if no comment in TDB, use comment from print share. J.F. (This used to be commit c267b23620677a11f702bfea4885a28e66a05b05) --- source3/rpc_server/srv_spoolss_nt.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 288b9648b7..76dff789c6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -947,8 +947,12 @@ static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, p ********************************************************************/ static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + if (*printer->info_2->comment == '\0') + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, lp_comment(snum), sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); + else + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, + printer->info_2->comment, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -1729,14 +1733,21 @@ static BOOL construct_printer_info_1(fstring server, uint32 flags, PRINTER_INFO_ printer->flags=flags; - snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",server, ntprinter->info_2->printername, - ntprinter->info_2->drivername, lp_comment(snum)); + if (*ntprinter->info_2->comment == '\0') { + init_unistr(&printer->comment, lp_comment(snum)); + snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",server, ntprinter->info_2->printername, + ntprinter->info_2->drivername, lp_comment(snum)); + } + else { + init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ + snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",server, ntprinter->info_2->printername, + ntprinter->info_2->drivername, ntprinter->info_2->comment); + } snprintf(chaine2,sizeof(chaine)-1,"%s%s", server, ntprinter->info_2->printername); init_unistr(&printer->description, chaine); init_unistr(&printer->name, chaine2); - init_unistr(&printer->comment, lp_comment(snum)); free_a_printer(&ntprinter,2); -- cgit From 5ec1642809d9de83da8c88c65d6595c6eb0270f5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 27 Jul 2000 00:47:19 +0000 Subject: Ok - this is a *BIG* change - but it fixes the problems with static strings in the RPC code. This change was prompted by trying to save a long (>256) character comment in the printer properties page. The new system associates a TALLOC_CTX with the pipe struct, and frees the pool on return of a complete PDU. A global TALLOC_CTX is used for the odd buffer allocated in the BUFFERxx code, and is freed in the main loop. This code works with insure, and seems to be free of memory leaks and crashes (so far) but there are probably the occasional problem with code that uses UNISTRxx structs on the stack and expects them to contain storage without doing a init_unistrXX(). This means that rpcclient will probably be horribly broken. A TALLOC_CTX also needed associating with the struct cli_state also, to make the prs_xx code there work. The main interface change is the addition of a TALLOC_CTX to the prs_init calls - used for dynamic allocation in the prs_XXX calls. Now this is in place it should make dynamic allocation of all RPC memory on unmarshall *much* easier to fix. Jeremy. (This used to be commit 0ff2ce543ee54f7364e6d839db6d06e7ef1edcf4) --- source3/rpc_server/srv_pipe.c | 30 ++++-- source3/rpc_server/srv_pipe_hnd.c | 210 ++++++++---------------------------- source3/rpc_server/srv_spoolss_nt.c | 16 +-- 3 files changed, 77 insertions(+), 179 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index f6746367bb..6f650c7e5e 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -167,17 +167,19 @@ BOOL create_next_pdu(pipes_struct *p) * data. */ - prs_init( &outgoing_pdu, 0, 4, MARSHALL); + prs_init( &outgoing_pdu, 0, 4, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* Store the header in the data stream. */ if(!smb_io_rpc_hdr("hdr", &p->hdr, &outgoing_pdu, 0)) { DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR.\n")); + prs_mem_free(&outgoing_pdu); return False; } if(!smb_io_rpc_hdr_resp("resp", &hdr_resp, &outgoing_pdu, 0)) { DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_RESP.\n")); + prs_mem_free(&outgoing_pdu); return False; } @@ -189,6 +191,7 @@ BOOL create_next_pdu(pipes_struct *p) if(!prs_append_data(&outgoing_pdu, data_from, data_len)) { DEBUG(0,("create_next_pdu: failed to copy %u bytes of data.\n", (unsigned int)data_len)); + prs_mem_free(&outgoing_pdu); return False; } @@ -216,6 +219,7 @@ BOOL create_next_pdu(pipes_struct *p) (auth_verify ? RPC_HDR_AUTH_LEN : 0), (auth_verify ? 1 : 0)); if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_AUTH.\n")); + prs_mem_free(&outgoing_pdu); return False; } } @@ -230,6 +234,7 @@ BOOL create_next_pdu(pipes_struct *p) auth_data = prs_data_p(&outgoing_pdu) + prs_offset(&outgoing_pdu) + 4; if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &ntlmssp_chk, &outgoing_pdu, 0)) { DEBUG(0,("create_next_pdu: failed to marshall RPC_AUTH_NTLMSSP_CHK.\n")); + prs_mem_free(&outgoing_pdu); return False; } NTLMSSPcalc_p(p, (uchar*)auth_data, RPC_AUTH_NTLMSSP_CHK_LEN - 4); @@ -244,6 +249,7 @@ BOOL create_next_pdu(pipes_struct *p) p->out_data.current_pdu_len = p->hdr.frag_len; p->out_data.current_pdu_sent = 0; + prs_mem_free(&outgoing_pdu); return True; } @@ -566,7 +572,7 @@ static BOOL setup_bind_nak(pipes_struct *p) * header and are never sending more than one PDU here. */ - prs_init( &outgoing_rpc, 0, 4, MARSHALL); + prs_init( &outgoing_rpc, 0, 4, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); @@ -583,6 +589,7 @@ static BOOL setup_bind_nak(pipes_struct *p) if(!smb_io_rpc_hdr("", &nak_hdr, &outgoing_rpc, 0)) { DEBUG(0,("setup_bind_nak: marshalling of RPC_HDR failed.\n")); + prs_mem_free(&outgoing_rpc); return False; } @@ -590,8 +597,10 @@ static BOOL setup_bind_nak(pipes_struct *p) * Now add the reject reason. */ - if(!prs_uint16("reject code", &outgoing_rpc, 0, &zero)) + if(!prs_uint16("reject code", &outgoing_rpc, 0, &zero)) { + prs_mem_free(&outgoing_rpc); return False; + } p->out_data.data_sent_length = 0; p->out_data.current_pdu_len = prs_offset(&outgoing_rpc); @@ -622,7 +631,7 @@ BOOL setup_fault_pdu(pipes_struct *p) * header and are never sending more than one PDU here. */ - prs_init( &outgoing_pdu, 0, 4, MARSHALL); + prs_init( &outgoing_pdu, 0, 4, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* @@ -647,16 +656,19 @@ BOOL setup_fault_pdu(pipes_struct *p) if(!smb_io_rpc_hdr("", &fault_hdr, &outgoing_pdu, 0)) { DEBUG(0,("setup_fault_pdu: marshalling of RPC_HDR failed.\n")); + prs_mem_free(&outgoing_pdu); return False; } if(!smb_io_rpc_hdr_resp("resp", &hdr_resp, &outgoing_pdu, 0)) { DEBUG(0,("setup_fault_pdu: failed to marshall RPC_HDR_RESP.\n")); + prs_mem_free(&outgoing_pdu); return False; } if(!smb_io_rpc_hdr_fault("fault", &fault_resp, &outgoing_pdu, 0)) { DEBUG(0,("setup_fault_pdu: failed to marshall RPC_HDR_FAULT.\n")); + prs_mem_free(&outgoing_pdu); return False; } @@ -664,6 +676,7 @@ BOOL setup_fault_pdu(pipes_struct *p) p->out_data.current_pdu_len = prs_offset(&outgoing_pdu); p->out_data.current_pdu_sent = 0; + prs_mem_free(&outgoing_pdu); return True; } @@ -835,7 +848,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) * header and are never sending more than one PDU here. */ - prs_init( &outgoing_rpc, 0, 4, MARSHALL); + prs_init( &outgoing_rpc, 0, 4, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* @@ -843,13 +856,15 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) * auth footers. */ - if(!prs_init(&out_hdr_ba, 1024, 4, MARSHALL)) { + if(!prs_init(&out_hdr_ba, 1024, 4, p->mem_ctx, MARSHALL)) { DEBUG(0,("api_pipe_bind_req: malloc out_hdr_ba failed.\n")); + prs_mem_free(&outgoing_rpc); return False; } - if(!prs_init(&out_auth, 1024, 4, MARSHALL)) { + if(!prs_init(&out_auth, 1024, 4, p->mem_ctx, MARSHALL)) { DEBUG(0,("pi_pipe_bind_req: malloc out_auth failed.\n")); + prs_mem_free(&outgoing_rpc); prs_mem_free(&out_hdr_ba); return False; } @@ -984,6 +999,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) err_exit: + prs_mem_free(&outgoing_rpc); prs_mem_free(&out_hdr_ba); prs_mem_free(&out_auth); return False; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index faba41b925..e51bc5ae4d 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -78,8 +78,10 @@ void init_rpc_pipe_hnd(void) Initialise an outgoing packet. ****************************************************************************/ -static BOOL pipe_init_outgoing_data(output_data *o_data) +static BOOL pipe_init_outgoing_data(pipes_struct *p) { + output_data *o_data = &p->out_data; + /* Reset the offset counters. */ o_data->data_sent_length = 0; o_data->current_pdu_len = 0; @@ -94,7 +96,7 @@ static BOOL pipe_init_outgoing_data(output_data *o_data) * Initialize the outgoing RPC data buffer. * we will use this as the raw data area for replying to rpc requests. */ - if(!prs_init(&o_data->rdata, MAX_PDU_FRAG_LEN, 4, MARSHALL)) { + if(!prs_init(&o_data->rdata, MAX_PDU_FRAG_LEN, 4, p->mem_ctx, MARSHALL)) { DEBUG(0,("pipe_init_outgoing_data: malloc fail.\n")); return False; } @@ -102,60 +104,6 @@ static BOOL pipe_init_outgoing_data(output_data *o_data) return True; } -/**************************************************************************** - Attempt to find a remote process to communicate RPC's with. -****************************************************************************/ - -#if 0 - -static void attempt_remote_rpc_connect(pipes_struct *p) -{ - struct user_creds usr; - user_struct *vuser = get_valid_user_struct(p->vuid); - - p->m = NULL; - - if (vuser == NULL) { - DEBUG(4,("attempt_remote_rpc_connect: invalid vuid %d\n", (int)p->vuid)); - return; - } - - ZERO_STRUCT(usr); - - /* set up unix credentials from the smb side, to feed over the pipe */ - make_creds_unix(&usr.uxc, vuser->user.unix_name, vuser->user.smb_name, - vuser->user.full_name, vuser->guest); - usr.ptr_uxc = 1; - make_creds_unix_sec(&usr.uxs, vuser->uid, vuser->gid, - vuser->n_groups, vuser->groups); - usr.ptr_uxs = 1; - - usr.ptr_ssk = 1; - DEBUG(10,("user session key not available (yet).\n")); - DEBUG(10,("password-change operations may fail.\n")); - -#if USER_SESSION_KEY_DEFINED_IN_VUSER_STRUCT - memcpy(usr.usr_sess_key, vuser->usr_sess_key, sizeof(usr.usr_sess_key)); -#else - memset(usr.usr_sess_key, 0, sizeof(usr.usr_sess_key)); -#endif - - /* set up nt credentials from the smb side, to feed over the pipe */ - /* lkclXXXX todo! - make_creds_nt(&usr.ntc); - make_creds_nt_sec(&usr.nts); - */ - - become_root(); /* to connect to pipe */ - p->m = msrpc_use_add(p->name, sys_getpid(), &usr, False); - unbecome_root(); - - if (p->m == NULL) - DEBUG(10,("attempt_remote_rpc_connect: msrpc redirect failed - using local implementation.\n")); -} - -#endif - /**************************************************************************** Find first available pipe slot. ****************************************************************************/ @@ -196,6 +144,12 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, ZERO_STRUCTP(p); + if ((p->mem_ctx = talloc_init()) == NULL) { + DEBUG(0,("open_rpc_pipe_p: talloc_init failed.\n")); + free(p); + return NULL; + } + DLIST_ADD(Pipes, p); /* @@ -205,7 +159,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, * change the type to UNMARSALLING before processing the stream. */ - if(!prs_init(&p->in_data.data, MAX_PDU_FRAG_LEN, 4, MARSHALL)) { + if(!prs_init(&p->in_data.data, MAX_PDU_FRAG_LEN, 4, p->mem_ctx, MARSHALL)) { DEBUG(0,("open_rpc_pipe_p: malloc fail for in_data struct.\n")); return NULL; } @@ -250,7 +204,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, /* * Initialize the outgoing RPC data buffer with no memory. */ - prs_init(&p->out_data.rdata, 0, 4, MARSHALL); + prs_init(&p->out_data.rdata, 0, 4, p->mem_ctx, MARSHALL); ZERO_STRUCT(p->pipe_user); @@ -332,7 +286,7 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) return -1; } - prs_init( &rpc_in, 0, 4, UNMARSHALL); + prs_init( &rpc_in, 0, 4, p->mem_ctx, UNMARSHALL); prs_give_memory( &rpc_in, (char *)&p->in_data.current_in_pdu[0], p->in_data.pdu_received_len, False); @@ -344,6 +298,7 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) if(!smb_io_rpc_hdr("", &p->hdr, &rpc_in, 0)) { DEBUG(0,("unmarshall_rpc_header: failed to unmarshall RPC_HDR.\n")); set_incoming_fault(p); + prs_mem_free(&rpc_in); return -1; } @@ -354,6 +309,7 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) if(p->hdr.major != 5 && p->hdr.minor != 0) { DEBUG(0,("unmarshall_rpc_header: invalid major/minor numbers in RPC_HDR.\n")); set_incoming_fault(p); + prs_mem_free(&rpc_in); return -1; } @@ -366,6 +322,7 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) if((p->hdr.pkt_type == RPC_REQUEST) && (prs_offset(&p->in_data.data) == 0) && !(p->hdr.flags & RPC_FLG_FIRST)) { DEBUG(0,("unmarshall_rpc_header: FIRST flag not set in first PDU !\n")); set_incoming_fault(p); + prs_mem_free(&rpc_in); return -1; } @@ -376,6 +333,7 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) if((p->hdr.frag_len < RPC_HEADER_LEN) || (p->hdr.frag_len > MAX_PDU_FRAG_LEN)) { DEBUG(0,("unmarshall_rpc_header: assert on frag length failed.\n")); set_incoming_fault(p); + prs_mem_free(&rpc_in); return -1; } @@ -394,6 +352,8 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) memset((char *)&p->in_data.current_in_pdu[0], '\0', RPC_HEADER_LEN); + prs_mem_free(&rpc_in); + return 0; /* No extra data processed. */ } @@ -505,7 +465,7 @@ authentication failed. Denying the request.\n", p->name)); * Process the complete data stream here. */ - if(pipe_init_outgoing_data(&p->out_data)) + if(pipe_init_outgoing_data(p)) ret = api_pipe_request(p); /* @@ -536,6 +496,14 @@ static ssize_t process_complete_pdu(pipes_struct *p) char *data_p = (char *)&p->in_data.current_in_pdu[0]; BOOL reply = False; + if (p->mem_ctx) { + talloc_destroy_pool(p->mem_ctx); + } else { + p->mem_ctx = talloc_init(); + if (p->mem_ctx == NULL) + p->fault_state = True; + } + if(p->fault_state) { DEBUG(10,("process_complete_pdu: pipe %s in fault state.\n", p->name )); @@ -544,7 +512,7 @@ static ssize_t process_complete_pdu(pipes_struct *p) return (ssize_t)data_len; } - prs_init( &rpc_in, 0, 4, UNMARSHALL); + prs_init( &rpc_in, 0, 4, p->mem_ctx, UNMARSHALL); prs_give_memory( &rpc_in, data_p, (uint32)data_len, False); DEBUG(10,("process_complete_pdu: processing packet type %u\n", @@ -556,14 +524,14 @@ static ssize_t process_complete_pdu(pipes_struct *p) /* * We assume that a pipe bind is only in one pdu. */ - if(pipe_init_outgoing_data(&p->out_data)) + if(pipe_init_outgoing_data(p)) reply = api_pipe_bind_req(p, &rpc_in); break; case RPC_BINDRESP: /* * We assume that a pipe bind_resp is only in one pdu. */ - if(pipe_init_outgoing_data(&p->out_data)) + if(pipe_init_outgoing_data(p)) reply = api_pipe_bind_auth_resp(p, &rpc_in); break; case RPC_REQUEST: @@ -578,6 +546,7 @@ static ssize_t process_complete_pdu(pipes_struct *p) DEBUG(3,("process_complete_pdu: DCE/RPC fault sent on pipe %s\n", p->pipe_srv_name)); set_incoming_fault(p); setup_fault_pdu(p); + prs_mem_free(&rpc_in); } else { /* * Reset the lengths. We're ready for a new pdu. @@ -586,6 +555,7 @@ static ssize_t process_complete_pdu(pipes_struct *p) p->in_data.pdu_received_len = 0; } + prs_mem_free(&rpc_in); return (ssize_t)data_len; } @@ -687,14 +657,7 @@ ssize_t write_to_pipe(pipes_struct *p, char *data, size_t n) DEBUG(10,("write_to_pipe: data_left = %u\n", (unsigned int)data_left )); - /* - * Deal with the redirect to the remote RPC daemon. - */ - - if(p->m) - data_used = write(p->m->fd, data, data_left); - else - data_used = process_incoming_data(p, data, data_left); + data_used = process_incoming_data(p, data, data_left); DEBUG(10,("write_to_pipe: data_used = %d\n", (int)data_used )); @@ -708,70 +671,6 @@ ssize_t write_to_pipe(pipes_struct *p, char *data, size_t n) return n; } -/**************************************************************************** - Gets data from a remote TNG daemon. Gets data from the remote daemon into - the outgoing prs_struct. - - NB. Note to Luke : This code will be broken until Luke implements a length - field before reply data... - -****************************************************************************/ - -static BOOL read_from_remote(pipes_struct *p) -{ - uint32 data_len; - uint32 data_len_left; - - if(prs_offset(&p->out_data.rdata) == 0) { - - ssize_t len = 0; - - /* - * Read all the reply data as a stream of pre-created - * PDU's from the remote deamon into the rdata struct. - */ - - /* - * Create the response data buffer. - */ - - if(!pipe_init_outgoing_data(&p->out_data)) { - DEBUG(0,("read_from_remote: failed to create outgoing buffer.\n")); - return False; - } - - /* Read from remote here. */ - if((len = read_with_timeout(p->m->fd, prs_data_p(&p->out_data.rdata), 1, 65536, 10000)) < 0) { - DEBUG(0,("read_from_remote: failed to read from external daemon.\n")); - prs_mem_free(&p->out_data.rdata); - return False; - } - - /* Set the length we got. */ - prs_set_offset(&p->out_data.rdata, (uint32)len); - } - - /* - * The amount we send is the minimum of the available - * space and the amount left to send. - */ - - data_len_left = prs_offset(&p->out_data.rdata) - p->out_data.data_sent_length; - - /* - * Ensure there really is data left to send. - */ - - if(!data_len_left) { - DEBUG(0,("read_from_remote: no data left to send !\n")); - return False; - } - - data_len = MIN(data_len_left, MAX_PDU_FRAG_LEN); - - return False; /* Notfinished... */ -} - /**************************************************************************** Replies to a request to read data from a pipe. @@ -844,28 +743,16 @@ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, return 0; } - if(p->m) { - /* - * Remote to the RPC daemon. - */ - if(!read_from_remote(p)) { - DEBUG(0,("read_from_pipe: %s: read_from_remote failed.\n", p->name )); - return -1; - } - - } else { - - /* - * We need to create a new PDU from the data left in p->rdata. - * Create the header/data/footers. This also sets up the fields - * p->current_pdu_len, p->current_pdu_sent, p->data_sent_length - * and stores the outgoing PDU in p->current_pdu. - */ + /* + * We need to create a new PDU from the data left in p->rdata. + * Create the header/data/footers. This also sets up the fields + * p->current_pdu_len, p->current_pdu_sent, p->data_sent_length + * and stores the outgoing PDU in p->current_pdu. + */ - if(!create_next_pdu(p)) { - DEBUG(0,("read_from_pipe: %s: create_next_pdu failed.\n", p->name)); - return -1; - } + if(!create_next_pdu(p)) { + DEBUG(0,("read_from_pipe: %s: create_next_pdu failed.\n", p->name)); + return -1; } data_returned = MIN(n, p->out_data.current_pdu_len); @@ -937,18 +824,13 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) prs_mem_free(&p->out_data.rdata); prs_mem_free(&p->in_data.data); + if (p->mem_ctx) + talloc_destroy(p->mem_ctx); + bitmap_clear(bmap, p->pnum - pipe_handle_offset); pipes_open--; - if (p->m != NULL) { - DEBUG(4,("close_rpc_pipe_hnd: closing msrpc redirect: ")); - if (msrpc_use_del(p->m->pipe_name, &p->m->usr, False, NULL)) - DEBUG(4,("OK\n")); - else - DEBUG(4,("FAILED\n")); - } - DEBUG(4,("closed pipe name %s pnum=%x (pipes_open=%d)\n", p->name, p->pnum, pipes_open)); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 76dff789c6..c9d81e1cba 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2490,7 +2490,7 @@ uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, ********************************************************************/ static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername, fstring architecture) { - init_unistr( &(info->name), driver.info_3->name); + init_unistr( &info->name, driver.info_3->name); } /******************************************************************** @@ -3336,7 +3336,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, snprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", global_myname, ntprinter->info_2->printername); - init_unistr(&(job_info->printername), chaine); + init_unistr(&job_info->printername, chaine); init_unistr(&job_info->machinename, temp_name); init_unistr(&job_info->username, queue->user); @@ -4506,7 +4506,7 @@ static uint32 enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui (*returned) = 0x1; - init_unistr(&(info_1->name), "winprint"); + init_unistr(&info_1->name, "winprint"); *needed += spoolss_size_printprocessor_info_1(info_1); @@ -4565,7 +4565,7 @@ static uint32 enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, (*returned) = 0x1; - init_unistr(&(info_1->name), "RAW"); + init_unistr(&info_1->name, "RAW"); *needed += spoolss_size_printprocdatatype_info_1(info_1); @@ -4617,7 +4617,7 @@ static uint32 enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint (*returned) = 0x1; - init_unistr(&(info_1->name), "Local Port"); + init_unistr(&info_1->name, "Local Port"); *needed += spoolss_size_printmonitor_info_1(info_1); @@ -4648,9 +4648,9 @@ static uint32 enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint (*returned) = 0x1; - init_unistr(&(info_2->name), "Local Port"); - init_unistr(&(info_2->environment), "Windows NT X86"); - init_unistr(&(info_2->dll_name), "localmon.dll"); + init_unistr(&info_2->name, "Local Port"); + init_unistr(&info_2->environment, "Windows NT X86"); + init_unistr(&info_2->dll_name, "localmon.dll"); *needed += spoolss_size_printmonitor_info_2(info_2); -- cgit From 49fcb300de40d6da8682b485fd2c51236bcbb3dd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 31 Jul 2000 20:41:51 +0000 Subject: Added John Reilly's enumports/addprinter/delprinter scripting code plus the fix for the Win9x printer drivers. Changed command names to add "command" string on the end for some consistancy with the other scripting commands. Added '%P' option to tdbpack/unpack to store long comment string. Made port name be "Samba Printer Port" if no enum port script given. Fixed prs_uint32_pre code to cope with null args. Jeremy. (This used to be commit 902ada63799cf27924c72e24e7593a8c9fb5eba9) --- source3/rpc_server/srv_spoolss_nt.c | 296 +++++++++++++++++++++++++++--------- 1 file changed, 227 insertions(+), 69 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c9d81e1cba..b675175544 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -28,6 +28,10 @@ extern int DEBUGLEVEL; extern pstring global_myname; +#ifndef SAMBA_PRINTER_PORT_NAME +#define SAMBA_PRINTER_PORT_NAME "Samba Printer Port" +#endif + #ifndef MAX_OPEN_PRINTER_EXS #define MAX_OPEN_PRINTER_EXS 50 #endif @@ -217,6 +221,45 @@ static BOOL delete_printer_handle(POLICY_HND *hnd) return False; } + if (*lp_deleteprinter_cmd()) { + + pid_t local_pid = sys_getpid(); + char *cmd = lp_deleteprinter_cmd(); + char *path; + pstring tmp_file; + pstring command; + int ret; + int i; + + if (*lp_pathname(lp_servicenumber(PRINTERS_NAME))) + path = lp_pathname(lp_servicenumber(PRINTERS_NAME)); + else + path = tmpdir(); + + /* Printer->dev.handlename equals portname equals sharename */ + slprintf(command, sizeof(command), "%s \"%s\"", cmd, + Printer->dev.handlename); + slprintf(tmp_file, sizeof(tmp_file), "%s/smbcmd.%d", path, local_pid); + + unlink(tmp_file); + DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); + ret = smbrun(command, tmp_file, False); + if (ret != 0) { + unlink(tmp_file); + return False; + } + DEBUGADD(10,("returned [%d]\n", ret)); + DEBUGADD(10,("Unlinking output file [%s]\n", tmp_file)); + unlink(tmp_file); + + if ( ( i = lp_servicenumber( Printer->dev.handlename ) ) >= 0 ) { + lp_remove_service( i ); + lp_killservice( i ); + return True; + } else + return False; + } + return True; } @@ -3204,7 +3247,7 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, */ if (!check_printer_ok(printer->info_2, snum)) { - result = ERROR_ACCESS_DENIED; + result = ERROR_INVALID_PARAMETER; goto done; } @@ -3914,46 +3957,71 @@ static void fill_port_2(PORT_INFO_2 *port, char *name) ****************************************************************************/ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - int n_services=lp_numservices(); - int snum; - int i=0; - PORT_INFO_1 *ports=NULL; + int i=0; - for (snum=0; snum %s]\n", command,tmp_file)); + ret = smbrun(command, tmp_file, False); + DEBUG(10,("Returned [%d]\n", ret)); + if (ret != 0) { + unlink(tmp_file); + // Is this the best error to return here? + return ERROR_ACCESS_DENIED; + } - if((ports=(PORT_INFO_1 *)malloc( (*returned+1) * sizeof(PORT_INFO_1) )) == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - for (snum=0; snum %s]\n", command,tmp_file)); + ret = smbrun(command, tmp_file, False); + DEBUGADD(10,("returned [%d]\n", ret)); + if (ret != 0) { + unlink(tmp_file); + // Is this the best error to return here? + return ERROR_ACCESS_DENIED; + } - if((ports=(PORT_INFO_2 *)malloc( (*returned+1) * sizeof(PORT_INFO_2) )) == NULL) - return ERROR_NOT_ENOUGH_MEMORY; - - for (snum=0; snuminfo_2->printername, printer->info_2->sharename, + printer->info_2->portname, printer->info_2->drivername, + printer->info_2->location, driverlocation); + + unlink(tmp_file); + DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); + ret = smbrun(command, tmp_file, False); + DEBUGADD(10,("returned [%d]\n", ret)); + + if ( ret != 0 ) { + unlink(tmp_file); + free_a_printer(&printer,2); + return False; + } + + numlines = 0; + qlines = file_lines_load(tmp_file, &numlines); + DEBUGADD(10,("Lines returned = [%d]\n", numlines)); + DEBUGADD(10,("Line[0] = [%s]\n", qlines[0])); + DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file)); + unlink(tmp_file); + + if(numlines) { + // Set the portname to what the script says the portname should be + strncpy(printer->info_2->portname, qlines[0], sizeof(printer->info_2->portname)); + + // Send SIGHUP to process group... is there a better way? + kill(0, SIGHUP); + add_all_printers(); + } + + file_lines_free(qlines); + return True; +} + /**************************************************************************** ****************************************************************************/ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, @@ -4091,7 +4247,6 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, { NT_PRINTER_INFO_LEVEL *printer = NULL; fstring name; - fstring share_name; int snum; if ((printer = (NT_PRINTER_INFO_LEVEL *)malloc(sizeof(NT_PRINTER_INFO_LEVEL))) == NULL) { @@ -4104,11 +4259,14 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, /* convert from UNICODE to ASCII - this allocates the info_2 struct inside *printer.*/ convert_printer_info(info, printer, 2); - unistr2_to_ascii(share_name, &info->info_2->sharename, sizeof(share_name)-1); + if (*lp_addprinter_cmd() ) + if ( !add_printer_hook(printer) ) + return ERROR_ACCESS_DENIED; - slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname, share_name); + slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname, + printer->info_2->sharename); - if ((snum = print_queue_snum(share_name)) == -1) { + if ((snum = print_queue_snum(printer->info_2->sharename)) == -1) { free_a_printer(&printer,2); return ERROR_ACCESS_DENIED; } @@ -4119,7 +4277,7 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, if (!check_printer_ok(printer->info_2, snum)) { free_a_printer(&printer,2); - return ERROR_ACCESS_DENIED; + return ERROR_INVALID_PARAMETER; } /* write the ASCII on disk */ @@ -4130,7 +4288,7 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, if (!open_printer_hnd(handle, name)) { /* Handle open failed - remove addition. */ - del_a_printer(share_name); + del_a_printer(printer->info_2->sharename); free_a_printer(&printer,2); return ERROR_ACCESS_DENIED; } -- cgit From 55ff9cb38bbabfaee591f6f5190e57b5564f3942 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 31 Jul 2000 21:41:03 +0000 Subject: Save & restore the port name correctly. Jeremy. (This used to be commit c0648c981edef2a29b3a22a7d08aa226ca724e95) --- source3/rpc_server/srv_spoolss_nt.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b675175544..47df204ef3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1935,12 +1935,7 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer init_unistr(&printer->servername, chaine); /* servername*/ init_unistr(&printer->printername, chaine2); /* printername*/ init_unistr(&printer->sharename, lp_servicename(snum)); /* sharename */ -#if 1 /* JRATEST */ - /* We need to determine the correct model for this..... */ - init_unistr(&printer->portname, lp_printername(snum)); /* port */ -#else - init_unistr(&printer->portname, lp_servicename(snum)); /* port */ -#endif + init_unistr(&printer->portname, ntprinter->info_2->portname); /* port */ init_unistr(&printer->drivername, ntprinter->info_2->drivername); /* drivername */ if (*ntprinter->info_2->comment == '\0') @@ -1966,9 +1961,6 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer if((printer->devmode = construct_dev_mode(snum, servername)) == NULL) { DEBUG(8, ("Returning NULL Devicemode!\n")); -#if 0 /* JFMTEST */ - goto err; -#endif } if (ntprinter->info_2->secdesc_buf && ntprinter->info_2->secdesc_buf->len != 0) { @@ -1985,13 +1977,6 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer free_a_printer(&ntprinter, 2); safe_free(queue); return True; - - err: - - if (ntprinter) - free_a_printer(&ntprinter, 2); - safe_free(queue); - return False; } /******************************************************************** -- cgit From d95777ac34f68a3525786103b9217f6397d9f1d4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 1 Aug 2000 00:41:19 +0000 Subject: Added print job substitutions for %{printername}, %{sharename} and %{portname} from the NT printer tdb. Also added checks for time restrictions before allowing a job to print. Jeremy. (This used to be commit 8cfb55e81abebf0354e6d470ed68bbac1d6560ad) --- source3/rpc_server/srv_spoolss_nt.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 47df204ef3..4774375db4 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -28,10 +28,6 @@ extern int DEBUGLEVEL; extern pstring global_myname; -#ifndef SAMBA_PRINTER_PORT_NAME -#define SAMBA_PRINTER_PORT_NAME "Samba Printer Port" -#endif - #ifndef MAX_OPEN_PRINTER_EXS #define MAX_OPEN_PRINTER_EXS 50 #endif @@ -3339,7 +3335,7 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, job_info->totalpages=0; job_info->pagesprinted=0; - make_systemtime(&(job_info->submitted), t); + make_systemtime(&job_info->submitted, t); } /**************************************************************************** -- cgit From 7f36df301e28dc8ca0e5bfadc109d6e907d9ba2b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 1 Aug 2000 18:32:34 +0000 Subject: Tidyup removing many of the 0xC0000000 | NT_STATUS_XXX stuff (only need NT_STATUS_XXX). Removed IS_BITS_xxx macros as they were just reproducing "C" syntax in a more obscure way. Jeremy. (This used to be commit c55bcec817f47d6162466b193d533c877194124a) --- source3/rpc_server/srv_netlog.c | 28 ++++++++++++++-------------- source3/rpc_server/srv_pipe.c | 10 +++++----- source3/rpc_server/srv_pipe_hnd.c | 13 +------------ source3/rpc_server/srv_samr.c | 2 +- source3/rpc_server/srv_srvsvc.c | 20 ++++++++++---------- source3/rpc_server/srv_util.c | 12 ++++++------ 6 files changed, 37 insertions(+), 48 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 7fe89f90b6..f634b8e15f 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -354,7 +354,7 @@ static BOOL api_net_req_chal(pipes_struct *p) (char *)vuser->dc.md4pw, vuser->dc.sess_key); } else { /* lkclXXXX take a guess at a good error message to return :-) */ - status = 0xC0000000 | NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT; + status = NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT; } /* construct reply. */ @@ -370,7 +370,7 @@ static BOOL api_net_req_chal(pipes_struct *p) static BOOL api_net_auth_2(pipes_struct *p) { - uint16 vuid = p->vuid; + uint16 vuid = p->vuid; NET_Q_AUTH_2 q_a; uint32 status = 0x0; prs_struct *data = &p->in_data.data; @@ -403,7 +403,7 @@ static BOOL api_net_auth_2(pipes_struct *p) memcpy(vuser->dc.clnt_cred.challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); memcpy(vuser->dc.srv_cred .challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); } else { - status = NT_STATUS_ACCESS_DENIED | 0xC0000000; + status = NT_STATUS_ACCESS_DENIED; } /* construct reply. */ @@ -420,9 +420,9 @@ static BOOL api_net_auth_2(pipes_struct *p) static BOOL api_net_srv_pwset(pipes_struct *p) { - uint16 vuid = p->vuid; + uint16 vuid = p->vuid; NET_Q_SRV_PWSET q_a; - uint32 status = NT_STATUS_WRONG_PASSWORD|0xC0000000; + uint32 status = NT_STATUS_WRONG_PASSWORD; DOM_CRED srv_cred; pstring mach_acct; struct smb_passwd *smb_pass; @@ -487,7 +487,7 @@ static BOOL api_net_srv_pwset(pipes_struct *p) } else { /* lkclXXXX take a guess at a sensible error code to return... */ - status = 0xC0000000 | NT_STATUS_NETWORK_CREDENTIAL_CONFLICT; + status = NT_STATUS_NETWORK_CREDENTIAL_CONFLICT; } /* Construct reply. */ @@ -582,7 +582,7 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, struct smb_passwd *smb_p if (memcmp(smb_pass->smb_passwd , lm_pwd, 16) != 0 || memcmp(smb_pass->smb_nt_passwd, nt_pwd, 16) != 0) { - status = 0xC0000000 | NT_STATUS_WRONG_PASSWORD; + status = NT_STATUS_WRONG_PASSWORD; } return status; @@ -609,7 +609,7 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, struct smb_passwd *smb_pass) id2->lm_chal)) return 0x0; else - return 0xC0000000 | NT_STATUS_WRONG_PASSWORD; + return NT_STATUS_WRONG_PASSWORD; } /* lkclXXXX this is not a good place to put disabling of LM hashes in. @@ -631,7 +631,7 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, struct smb_passwd *smb_pass) /* oops! neither password check succeeded */ - return 0xC0000000 | NT_STATUS_WRONG_PASSWORD; + return NT_STATUS_WRONG_PASSWORD; } /************************************************************************* @@ -673,7 +673,7 @@ static BOOL api_net_sam_logon(pipes_struct *p) /* checks and updates credentials. creates reply credentials */ if (!deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), &(q_l.sam_id.client.cred), &srv_cred)) - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; + status = NT_STATUS_INVALID_HANDLE; else memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); @@ -695,7 +695,7 @@ static BOOL api_net_sam_logon(pipes_struct *p) break; default: DEBUG(2,("SAM Logon: unsupported switch value\n")); - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + status = NT_STATUS_INVALID_INFO_CLASS; break; } /* end switch */ } /* end if status == 0 */ @@ -723,11 +723,11 @@ static BOOL api_net_sam_logon(pipes_struct *p) unbecome_root(); if (smb_pass == NULL) - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + status = NT_STATUS_NO_SUCH_USER; else if (smb_pass->acct_ctrl & ACB_PWNOTREQ) status = 0; else if (smb_pass->acct_ctrl & ACB_DISABLED) - status = 0xC0000000 | NT_STATUS_ACCOUNT_DISABLED; + status = NT_STATUS_ACCOUNT_DISABLED; } /* Validate password - if required. */ @@ -851,7 +851,7 @@ static BOOL api_net_sam_logon(pipes_struct *p) &global_sam_sid, /* DOM_SID *dom_sid */ NULL); /* char *other_sids */ else - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + status = NT_STATUS_NO_SUCH_USER; /* Free any allocated groups array. */ if(gids) diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 6f650c7e5e..049db69ca7 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -78,8 +78,8 @@ static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) BOOL create_next_pdu(pipes_struct *p) { RPC_HDR_RESP hdr_resp; - BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SIGN); - BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SEAL); + BOOL auth_verify = ((p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SIGN) != 0); + BOOL auth_seal = ((p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SEAL) != 0); uint32 data_len; uint32 data_space_available; uint32 data_len_left; @@ -292,7 +292,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm * We always negotiate UNICODE. */ - if (IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_UNICODE)) { + if (p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_UNICODE) { fstrcpy(user_name, dos_unistrn2((uint16*)ntlmssp_resp->user, ntlmssp_resp->hdr_usr.str_str_len/2)); fstrcpy(domain, dos_unistrn2((uint16*)ntlmssp_resp->domain, ntlmssp_resp->hdr_domain.str_str_len/2)); fstrcpy(wks, dos_unistrn2((uint16*)ntlmssp_resp->wks, ntlmssp_resp->hdr_wks.str_str_len/2)); @@ -1014,8 +1014,8 @@ BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) /* * We always negotiate the following two bits.... */ - BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SIGN); - BOOL auth_seal = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SEAL); + BOOL auth_verify = ((p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SIGN) != 0); + BOOL auth_seal = ((p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SEAL) != 0); int data_len; int auth_len; uint32 old_offset; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index e51bc5ae4d..e6aeb26d63 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -213,17 +213,6 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, fstrcpy(p->name, pipe_name); -#if 0 - - Comment out until memory leak fixed. JRA. - - /* - * For Luke - attempt to connect to RPC redirect process. - */ - - attempt_remote_rpc_connect(p); -#endif - DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n", pipe_name, i, pipes_open)); @@ -364,7 +353,7 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) static BOOL process_request_pdu(pipes_struct *p, prs_struct *rpc_in_p) { - BOOL auth_verify = IS_BITS_SET_ALL(p->ntlmssp_chal_flags, NTLMSSP_NEGOTIATE_SIGN); + BOOL auth_verify = ((p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SIGN) != 0); size_t data_len = p->hdr.frag_len - RPC_HEADER_LEN - RPC_HDR_REQ_LEN - (auth_verify ? RPC_HDR_AUTH_LEN : 0) - p->hdr.auth_len; diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 12b0d95abf..5a0f049ba7 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -88,7 +88,7 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, (*num_entries), pwd->smb_name, pwd->user_rid, pwd->acct_ctrl)); - if (acb_mask == 0 || IS_BITS_SET_SOME(pwd->acct_ctrl, acb_mask)) { + if (acb_mask == 0 || (pwd->acct_ctrl & acb_mask)) { DEBUG(5,(" acb_mask %x accepts\n", acb_mask)); (*num_entries)++; } else { diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 34f369bc8b..715a681a29 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -192,7 +192,7 @@ static void init_srv_r_net_share_enum(SRV_R_NET_SHARE_ENUM *r_n, &resume_hnd, &r_n->total_entries)) { r_n->status = 0x0; } else { - r_n->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + r_n->status = NT_STATUS_INVALID_INFO_CLASS; } init_enum_hnd(&r_n->enum_hnd, resume_hnd); @@ -255,11 +255,11 @@ static void init_srv_r_net_share_get_info(SRV_R_NET_SHARE_GET_INFO *r_n, break; default: DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level)); - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + status = NT_STATUS_INVALID_INFO_CLASS; break; } } else { - status = 0xC0000000 | NT_STATUS_BAD_NETWORK_NAME; + status = NT_STATUS_BAD_NETWORK_NAME; } r_n->ptr_share_ctr = (status == 0x0) ? 1 : 0; @@ -462,7 +462,7 @@ static uint32 init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, (*resume_hnd) = 0; (*total_entries) = 0; ctr->ptr_sess_ctr = 0; - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + status = NT_STATUS_INVALID_INFO_CLASS; break; } } @@ -481,7 +481,7 @@ static void init_srv_r_net_sess_enum(SRV_R_NET_SESS_ENUM *r_n, r_n->sess_level = sess_level; if (sess_level == -1) { - r_n->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + r_n->status = NT_STATUS_INVALID_INFO_CLASS; } else { @@ -675,7 +675,7 @@ static uint32 init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, (*resume_hnd = 0); (*total_entries) = 0; ctr->ptr_conn_ctr = 0; - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + status = NT_STATUS_INVALID_INFO_CLASS; break; } } @@ -694,7 +694,7 @@ static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, r_n->conn_level = conn_level; if (conn_level == -1) { - r_n->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + r_n->status = NT_STATUS_INVALID_INFO_CLASS; } else { @@ -810,7 +810,7 @@ static uint32 init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, (*resume_hnd = 0); (*total_entries) = 0; ctr->ptr_file_ctr = 0; - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + status = NT_STATUS_INVALID_INFO_CLASS; break; } } @@ -829,7 +829,7 @@ static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n, r_n->file_level = file_level; if (file_level == 0) { - r_n->status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + r_n->status = NT_STATUS_INVALID_INFO_CLASS; } else { @@ -910,7 +910,7 @@ static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, } default: { - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + status = NT_STATUS_INVALID_INFO_CLASS; break; } } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index a1f2a7c085..ba13f0ed7a 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -216,7 +216,7 @@ uint32 lookup_group_name(uint32 rid, char *group_name, uint32 *type) } DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + return NT_STATUS_NONE_MAPPED; } /******************************************************************* @@ -242,7 +242,7 @@ uint32 lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) } DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + return NT_STATUS_NONE_MAPPED; } /******************************************************************* @@ -282,7 +282,7 @@ uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) } DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + return NT_STATUS_NONE_MAPPED; } /******************************************************************* @@ -301,7 +301,7 @@ uint32 lookup_group_rid(char *group_name, uint32 *rid) } while (grp_name != NULL && !strequal(grp_name, group_name)); - return (grp_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; + return (grp_name != NULL) ? 0 : NT_STATUS_NONE_MAPPED; } /******************************************************************* @@ -320,7 +320,7 @@ uint32 lookup_alias_rid(char *alias_name, uint32 *rid) } while (als_name != NULL && !strequal(als_name, alias_name)); - return (als_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; + return (als_name != NULL) ? 0 : NT_STATUS_NONE_MAPPED; } /******************************************************************* @@ -342,7 +342,7 @@ uint32 lookup_user_rid(char *user_name, uint32 *rid) return 0x0; } - return 0xC0000000 | NT_STATUS_NONE_MAPPED; + return NT_STATUS_NONE_MAPPED; } #undef OLD_NTDOMAIN -- cgit From 17dcd9a834fc915fb1ff2d8042a23000eeb7acfa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 2 Aug 2000 02:11:55 +0000 Subject: Started to canonicalize our handling of uid -> sid code in order to get ready and fix se_access_check(). Added cannonical lookup_name(), lookup_sid(), uid_to_sid(), gid_to_sid() functions that look via winbind first the fall back on local lookup. All Samba should use these rather than trying to call winbindd code directly. Added NT_USER_TOKEN struct in user_struct, contains list of NT sids associated with this user. se_access_check() should use this (cached) value rather than attempting to do the same thing itself when given a uid/gid pair. More work needs to be done to preserve these things accross security context changes (especially with the tricky pipe problem) but I'm beginning to see how this will be done..... probably by registering a new vuid for an authenticated RPC pipe and not treating the pipe calls specially. More thoughts needed - but we're almost there... Jeremy. (This used to be commit 5e5cc6efe2e4687be59085f562caea1e2e05d0a8) --- source3/rpc_server/srv_lsa.c | 2 +- source3/rpc_server/srv_samr.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index bfb671d167..dc97d6db44 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -238,7 +238,7 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, if (map_domain_name_to_sid(&dom_sid, dom_name)) { dom_idx = init_dom_ref(ref, dom_name, &dom_sid); - if (lookup_local_name(dom_name, user, &sid, &sid_name_use) && sid_split_rid(&sid, &rid)) + if (local_lookup_name(dom_name, user, &sid, &sid_name_use) && sid_split_rid(&sid, &rid)) status = True; } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 5a0f049ba7..e80175f71d 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -978,7 +978,7 @@ static BOOL samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, if(alias_rid == 0xffffffff) r_e.status = 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; - if(!lookup_local_rid(alias_rid, alias, &type)) + if(!local_lookup_rid(alias_rid, alias, &type)) { r_e.status = 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; } @@ -1151,7 +1151,7 @@ static BOOL samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, if(sid_equal(&pol_sid, &global_sam_sid)) { DOM_SID sid; - if(lookup_local_name(global_myname, name, + if(local_lookup_name(global_myname, name, &sid, &type[i])) { sid_split_rid( &sid, &rid[i]); -- cgit From 06e4f11acd3aedd6c8e4adf365932a01eca902b8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 Aug 2000 00:59:09 +0000 Subject: Fixed up the user/group contexts when using authenticated pipes. Added a become_root()/unbecome_root() (push/pop security context) around the initgroups() call to ensure it would succeed. Hmmm - I wonder if this call being done as non-root might explain any "group access" bugs we've had in the past.... Jeremy. (This used to be commit 06a65972e872f37d88b84f22ea714feebd38f6c0) --- source3/rpc_server/srv_pipe.c | 13 ++++++++++++- source3/rpc_server/srv_pipe_hnd.c | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 049db69ca7..ded01e4e21 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -282,6 +282,11 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm memset(p->domain, '\0', sizeof(p->domain)); memset(p->wks, '\0', sizeof(p->wks)); + /* Set up for non-authenticated user. */ + delete_nt_token(&p->pipe_user.nt_user_token); + p->pipe_user.ngroups = 0; + safe_free( p->pipe_user.groups); + /* * Setup an empty password for a guest user. */ @@ -456,7 +461,13 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name p->pipe_user.uid = pass->pw_uid; p->pipe_user.gid = pass->pw_gid; - /* XXX also set up pipe user group membership */ + /* Set up pipe user group membership. */ + initialize_groups(pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); + get_current_groups( &p->pipe_user.ngroups, &p->pipe_user.groups); + + /* Create an NT_USER_TOKEN struct for this user. */ + p->pipe_user.nt_user_token = create_nt_token(p->pipe_user.uid,p->pipe_user.gid, + p->pipe_user.ngroups, p->pipe_user.groups); p->ntlmssp_auth_validated = True; return True; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index e6aeb26d63..b8ee235185 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -825,6 +825,9 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) DLIST_REMOVE(Pipes, p); + delete_nt_token(&p->pipe_user.nt_user_token); + safe_free(p->pipe_user.groups); + ZERO_STRUCTP(p); free(p); -- cgit From db2445358161e1a0a68b80a7551ed88e7dcc38c6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 9 Aug 2000 04:19:18 +0000 Subject: added printer admin option any user in that list can do anything to a printer (This used to be commit 7b5912be150dd590d6195be40b0976305b8716ba) --- source3/rpc_server/srv_spoolss_nt.c | 68 ++++++++++++++----------------------- 1 file changed, 26 insertions(+), 42 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4774375db4..d6c39fa022 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3049,19 +3049,18 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, pipes_struct *p, SEC_DESC_BUF *secdesc_ctr) { - SEC_DESC_BUF *old_secdesc_ctr = NULL; struct current_user user; - uint32 acc_granted, status, result; + uint32 result; + int snum; Printer_entry *Printer = find_printer_index_by_hnd(handle); - if (!OPEN_HANDLE(Printer)) { + if (!OPEN_HANDLE(Printer) || !get_printer_snum(handle, &snum)) { DEBUG(0,("update_printer_sec: Invalid handle (%s)\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } /* Work out which user is performing the operation */ - if (p->ntlmssp_auth_validated) { memcpy(&user, &p->pipe_user, sizeof(user)); } else { @@ -3069,32 +3068,18 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, memcpy(&user, ¤t_user, sizeof(user)); } - /* Get old security descriptor */ - - if (!nt_printing_getsec(Printer->dev.handlename, &old_secdesc_ctr)) { - DEBUG(3, ("could not get old security descriptor for " - "printer %s", Printer->dev.handlename)); - return ERROR_INVALID_FUNCTION; - } - /* Check the user has permissions to change the security descriptor. By experimentation with two NT machines, the user requires Full Access to the printer to change security information. */ - - if (!se_access_check(old_secdesc_ctr->sec, &user, - PRINTER_ACE_FULL_CONTROL, &acc_granted, - &status)) { - DEBUG(3, ("security descriptor change denied by existing " - "security descriptor\n")); - result = status; + if (!print_access_check(&user, snum, PRINTER_ACE_FULL_CONTROL)) { + result = NT_STATUS_ACCESS_DENIED; goto done; } result = nt_printing_setsec(Printer->dev.handlename, secdesc_ctr); done: - free_sec_desc_buf(&old_secdesc_ctr); return result; } @@ -3144,9 +3129,7 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, int snum; NT_PRINTER_INFO_LEVEL *printer = NULL; Printer_entry *Printer = find_printer_index_by_hnd(handle); - SEC_DESC_BUF *sd = NULL; - uint32 result, acc_granted; - extern struct current_user current_user; + uint32 result; DEBUG(8,("update_printer\n")); @@ -3154,22 +3137,6 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, /* Check calling user has permission to update printer description */ -#if 0 /* JFMTEST */ - if (!nt_printing_getsec(Printer->dev.handlename, &sd)) { - DEBUG(3, ("Could not get security descriptor for printer %s", - Printer->dev.handlename)); - result = ERROR_INVALID_FUNCTION; - goto done; - } - - if (!se_access_check(sd->sec, ¤t_user, - PRINTER_ACE_FULL_CONTROL, &acc_granted, - &result)) { - DEBUG(3, ("printer property change denied by security " - "descriptor\n")); - goto done; - } -#endif if (level!=2) { DEBUG(0,("Send a mail to samba@samba.org\n")); DEBUGADD(0,("with the following message: update_printer: level!=2\n")); @@ -3186,6 +3153,13 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, result = ERROR_INVALID_HANDLE; goto done; } + + if (!print_access_check(NULL, snum, PRINTER_ACE_FULL_CONTROL)) { + DEBUG(3, ("printer property change denied by security " + "descriptor\n")); + result = NT_STATUS_ACCESS_DENIED; + goto done; + } if(get_a_printer(&printer, 2, lp_servicename(snum)) != 0) { result = ERROR_INVALID_HANDLE; @@ -3240,7 +3214,6 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, done: free_a_printer(&printer, 2); - free_sec_desc_buf(&sd); return result; } @@ -4251,6 +4224,12 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, free_a_printer(&printer,2); return ERROR_ACCESS_DENIED; } + + /* you must be a printer admin to add a new printer */ + if (!print_access_check(NULL, snum, PRINTER_ACE_FULL_CONTROL)) { + free_a_printer(&printer,2); + return ERROR_ACCESS_DENIED; + } /* * Do sanity check on the requested changes for Samba. @@ -4547,8 +4526,7 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, uint32 numeric_data) { NT_PRINTER_INFO_LEVEL *printer = NULL; - NT_PRINTER_PARAM *param = NULL; - + NT_PRINTER_PARAM *param = NULL; int snum=0; uint32 status = 0x0; Printer_entry *Printer=find_printer_index_by_hnd(handle); @@ -4564,6 +4542,12 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, if (!get_printer_snum(handle, &snum)) return ERROR_INVALID_HANDLE; + if (!print_access_check(NULL, snum, PRINTER_ACE_FULL_CONTROL)) { + DEBUG(3, ("security descriptor change denied by existing " + "security descriptor\n")); + return NT_STATUS_ACCESS_DENIED; + } + status = get_a_printer(&printer, 2, lp_servicename(snum)); if (status != 0x0) return ERROR_INVALID_NAME; -- cgit From fadb15da71d6143e622f7fb669080c5b882df48f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 9 Aug 2000 07:34:35 +0000 Subject: got error code right for printer update/add failure (This used to be commit 0d00d2ec258b36d73e865f06d5d11745d7cdafa9) --- source3/rpc_server/srv_spoolss_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d6c39fa022..08abf4c301 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3073,7 +3073,7 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, requires Full Access to the printer to change security information. */ if (!print_access_check(&user, snum, PRINTER_ACE_FULL_CONTROL)) { - result = NT_STATUS_ACCESS_DENIED; + result = ERROR_ACCESS_DENIED; goto done; } @@ -3157,7 +3157,7 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, if (!print_access_check(NULL, snum, PRINTER_ACE_FULL_CONTROL)) { DEBUG(3, ("printer property change denied by security " "descriptor\n")); - result = NT_STATUS_ACCESS_DENIED; + result = ERROR_ACCESS_DENIED; goto done; } @@ -4545,7 +4545,7 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, if (!print_access_check(NULL, snum, PRINTER_ACE_FULL_CONTROL)) { DEBUG(3, ("security descriptor change denied by existing " "security descriptor\n")); - return NT_STATUS_ACCESS_DENIED; + return ERROR_ACCESS_DENIED; } status = get_a_printer(&printer, 2, lp_servicename(snum)); -- cgit From 1e823bc781fdb0738a58f478432c017732b69068 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 10 Aug 2000 19:51:45 +0000 Subject: Tidied up security rights definitions. Jeremy. (This used to be commit e466c863f5540e13776f4477b6d58e3fbfe7276d) --- source3/rpc_server/srv_lsa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index dc97d6db44..f37bb249ba 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -305,8 +305,7 @@ static void init_lsa_trans_names(DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, memset(dom_name, '\0', sizeof(dom_name)); memset(name, '\0', sizeof(name)); - status = winbind_lookup_sid(&find_sid, dom_name, name, - &sid_name_use); + status = lookup_sid(&find_sid, dom_name, name, &sid_name_use); if (!status) { sid_name_use = SID_NAME_UNKNOWN; -- cgit From 137b7f873a7885a9ee30871403229e338a8a4a04 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 10 Aug 2000 23:41:16 +0000 Subject: Added "add_printer_hook" call to update printer for Win9x clients. Patch from John Reilly . Jeremy. (This used to be commit 76a5713bd3fad18ec60d12fc3f965f3e9717c159) --- source3/rpc_server/srv_spoolss_nt.c | 130 +++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 62 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 08abf4c301..a8b948db4a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3117,6 +3117,68 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) return True; } +/**************************************************************************** +****************************************************************************/ +static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) +{ + pid_t local_pid = sys_getpid(); + char *cmd = lp_addprinter_cmd(); + char *path; + char **qlines; + pstring tmp_file; + pstring command; + pstring driverlocation; + int numlines; + int ret; + + if (*lp_pathname(lp_servicenumber(PRINTERS_NAME))) + path = lp_pathname(lp_servicenumber(PRINTERS_NAME)); + else + path = tmpdir(); + + /* build driver path... only 9X architecture is needed for legacy reasons */ + slprintf(driverlocation, sizeof(driverlocation)-1, "\\\\%s\\print$\\WIN40\\0", + global_myname); + /* change \ to \\ for the shell */ + all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring)); + + slprintf(tmp_file, sizeof(tmp_file), "%s/smbcmd.%d", path, local_pid); + slprintf(command, sizeof(command), "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", + cmd, printer->info_2->printername, printer->info_2->sharename, + printer->info_2->portname, printer->info_2->drivername, + printer->info_2->location, driverlocation); + + unlink(tmp_file); + DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); + ret = smbrun(command, tmp_file, False); + DEBUGADD(10,("returned [%d]\n", ret)); + + if ( ret != 0 ) { + unlink(tmp_file); + free_a_printer(&printer,2); + return False; + } + + numlines = 0; + qlines = file_lines_load(tmp_file, &numlines); + DEBUGADD(10,("Lines returned = [%d]\n", numlines)); + DEBUGADD(10,("Line[0] = [%s]\n", qlines[0])); + DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file)); + unlink(tmp_file); + + if(numlines) { + // Set the portname to what the script says the portname should be + strncpy(printer->info_2->portname, qlines[0], sizeof(printer->info_2->portname)); + + // Send SIGHUP to process group... is there a better way? + kill(0, SIGHUP); + add_all_printers(); + } + + file_lines_free(qlines); + return True; +} + /******************************************************************** * called by spoolss_api_setprinter * when updating a printer description @@ -3206,6 +3268,12 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, goto done; } + if (*lp_addprinter_cmd() ) + if ( !add_printer_hook(printer) ) { + result = ERROR_ACCESS_DENIED; + goto done; + } + if (add_a_printer(*printer, 2)!=0) { /* I don't really know what to return here !!! */ result = ERROR_ACCESS_DENIED; @@ -4129,68 +4197,6 @@ uint32 _spoolss_enumports( UNISTR2 *name, uint32 level, } } -/**************************************************************************** -****************************************************************************/ -static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) -{ - pid_t local_pid = sys_getpid(); - char *cmd = lp_addprinter_cmd(); - char *path; - char **qlines; - pstring tmp_file; - pstring command; - pstring driverlocation; - int numlines; - int ret; - - if (*lp_pathname(lp_servicenumber(PRINTERS_NAME))) - path = lp_pathname(lp_servicenumber(PRINTERS_NAME)); - else - path = tmpdir(); - - /* build driver path... only 9X architecture is needed for legacy reasons */ - slprintf(driverlocation, sizeof(driverlocation)-1, "\\\\%s\\print$\\WIN40\\0", - global_myname); - /* change \ to \\ for the shell */ - all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring)); - - slprintf(tmp_file, sizeof(tmp_file), "%s/smbcmd.%d", path, local_pid); - slprintf(command, sizeof(command), "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", - cmd, printer->info_2->printername, printer->info_2->sharename, - printer->info_2->portname, printer->info_2->drivername, - printer->info_2->location, driverlocation); - - unlink(tmp_file); - DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); - ret = smbrun(command, tmp_file, False); - DEBUGADD(10,("returned [%d]\n", ret)); - - if ( ret != 0 ) { - unlink(tmp_file); - free_a_printer(&printer,2); - return False; - } - - numlines = 0; - qlines = file_lines_load(tmp_file, &numlines); - DEBUGADD(10,("Lines returned = [%d]\n", numlines)); - DEBUGADD(10,("Line[0] = [%s]\n", qlines[0])); - DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file)); - unlink(tmp_file); - - if(numlines) { - // Set the portname to what the script says the portname should be - strncpy(printer->info_2->portname, qlines[0], sizeof(printer->info_2->portname)); - - // Send SIGHUP to process group... is there a better way? - kill(0, SIGHUP); - add_all_printers(); - } - - file_lines_free(qlines); - return True; -} - /**************************************************************************** ****************************************************************************/ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, -- cgit From aa3802ba0e2b7c90605104ed4392e94e3d1a80e8 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 15 Aug 2000 21:09:54 +0000 Subject: Merge of uninitialised variable fix from APPLIANCE_HEAD. (This used to be commit 20a7fefee8c85f02f6a0e2a02c0df04a8b22b7cb) --- source3/rpc_server/srv_samr.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index e80175f71d..fd39f87e79 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -735,8 +735,7 @@ static BOOL samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, fstring sam_sid_str; struct group *grp; - r_e.status = 0x0; - r_e.num_entries = 0; + ZERO_STRUCT(r_e); /* find the policy handle. open a policy on it. */ if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &sid)) @@ -840,8 +839,6 @@ static BOOL samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, prs_struct *rd ZERO_STRUCT(r_e); - r_e.status = 0x0; - DEBUG(5,("samr_reply_query_dispinfo: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ -- cgit From 2ba82c02d49c77bee19ad8895883915171062442 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 16 Aug 2000 03:38:52 +0000 Subject: fixed unitialized struct bug in enum_users (whatever it is called) jerry (This used to be commit a606131508592d72f3fd8a0dd63073e9c559062f) --- source3/rpc_server/srv_samr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index fd39f87e79..04399a638c 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -734,7 +734,7 @@ static BOOL samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, fstring sid_str; fstring sam_sid_str; struct group *grp; - + ZERO_STRUCT(r_e); /* find the policy handle. open a policy on it. */ @@ -809,6 +809,8 @@ static BOOL api_samr_enum_dom_aliases(pipes_struct *p) SAMR_Q_ENUM_DOM_ALIASES q_e; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_e); /* grab the samr open */ if(!samr_io_q_enum_dom_aliases("", &q_e, data, 0)) @@ -886,6 +888,7 @@ static BOOL samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, prs_struct *rd { /* query disp info is for users */ + ZERO_STRUCT (info1); switch_level = 0x1; init_sam_info_1(&info1, ACB_NORMAL, q_u->start_idx, num_entries, pass); @@ -897,6 +900,7 @@ static BOOL samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, prs_struct *rd case 0x2: { /* query disp info is for servers */ + ZERO_STRUCT (info2); switch_level = 0x2; init_sam_info_2(&info2, ACB_WSTRUST, q_u->start_idx, num_entries, pass); -- cgit From f77c277184ace2db0f36ea5b09473989b3f58f0d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 18 Aug 2000 05:57:09 +0000 Subject: fixed initialization errors (again!) I must have forgot to check these in before. jerry (This used to be commit e682d6a599934e5460abe0d30cb2465fa80c7937) --- source3/rpc_server/srv_samr.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 04399a638c..95c3e7c6ca 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -609,6 +609,8 @@ static BOOL samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; int num_entries; int total_entries; + + ZERO_STRUCT(r_e); r_e.status = 0x0; r_e.total_num_entries = 0; @@ -669,6 +671,8 @@ static BOOL samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, int num_entries; BOOL got_grps; char *dummy_group = "Domain Admins"; + + ZERO_STRUCT(r_e); r_e.status = 0x0; r_e.num_entries = 0; @@ -2076,6 +2080,8 @@ static BOOL samr_reply_enum_domains(SAMR_Q_ENUM_DOMAINS* q_u, prs_struct* rdata) { SAMR_R_ENUM_DOMAINS r_u; fstring dom[2]; + + ZERO_STRUCT(r_u); fstrcpy(dom[0],global_myname); fstrcpy(dom[1],"Builtin"); -- cgit From f03879e0b3db1871d003bfb5713a88928f032260 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 23 Aug 2000 23:05:49 +0000 Subject: Tidied up some error returns from printing calls. Still need to map UNIX errors to NT error for print job failure returns. Patch from John Reilly at HP. Jeremy. (This used to be commit 3514b5bb8fffd78e3647425d93b74e2e6291bafc) --- source3/rpc_server/srv_spoolss_nt.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a8b948db4a..36a8a1697c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2919,19 +2919,16 @@ uint32 _spoolss_startdocprinter(POLICY_HND *handle, uint32 level, * server-side code. *nnnnnggggh!* */ - if (info_1->p_datatype != 0) - { - unistr2_to_ascii(datatype, &(info_1->docname), sizeof(datatype)); - if (strcmp(datatype, "RAW") != 0) - { + if (info_1->p_datatype != 0) { + unistr2_to_ascii(datatype, &info_1->docname, sizeof(datatype)); + if (strcmp(datatype, "RAW") != 0) { (*jobid)=0; return ERROR_INVALID_DATATYPE; } } /* get the share number of the printer */ - if (!get_printer_snum(handle, &snum)) - { + if (!get_printer_snum(handle, &snum)) { return ERROR_INVALID_HANDLE; } -- cgit From 9e1f9a5719315aaa9b184fc5b0a750c68fbd8941 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 28 Aug 2000 04:42:31 +0000 Subject: yipee! The spoolss AddJob function has an [in,out] buffer not an [in] buffer (despite the comment in the code to the contrary). Also, we must fail this function - not just blindly reply "no problem" as AddJob should always fail on non-local printers. This fixes a bug where the "print test page" failed about half the time. I suspect it will also fix a bunch of other intermittent spoolss bugs where the client (incorrectly) tries to use the AddJob printing interface. (This used to be commit 14e534a8907c34b53e00a63756efd71903ff9432) --- source3/rpc_server/srv_spoolss.c | 5 +++-- source3/rpc_server/srv_spoolss_nt.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 8b431551b5..5a1592e4fb 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -591,10 +591,11 @@ static BOOL api_spoolss_addjob(pipes_struct *p) return False; } - /* that's only an [in] buffer ! */ + /* that's an [in out] buffer (despite appearences to the contrary) */ + new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); r_u.status = _spoolss_addjob(&q_u.handle, q_u.level, - q_u.buffer, q_u.offered); + r_u.buffer, q_u.offered, &r_u.needed); if(!spoolss_io_r_addjob("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_addjob: unable to marshall SPOOL_R_ADDJOB.\n")); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 36a8a1697c..b118b7c933 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3342,9 +3342,14 @@ uint32 _spoolss_fcpn(POLICY_HND *handle) /**************************************************************************** ****************************************************************************/ uint32 _spoolss_addjob(POLICY_HND *handle, uint32 level, - NEW_BUFFER *buffer, uint32 offered) -{ - return NT_STATUS_NO_PROBLEMO; + NEW_BUFFER *buffer, uint32 offered, + uint32 *needed) +{ + *needed = 0; + return ERROR_INVALID_PARAMETER; /* this is what a NT server + returns for AddJob. AddJob + must fail on non-local + printers */ } /**************************************************************************** -- cgit From d12f3fea7529c03b6a3650e7aa8b4b47a445d548 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 28 Aug 2000 06:46:53 +0000 Subject: Merge from appliance branch. (This used to be commit 567b0095b1b8393b3b1e32533aa2860ab3dbfa47) --- source3/rpc_server/srv_pipe.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index ded01e4e21..44bca13c1a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -462,6 +462,7 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name p->pipe_user.gid = pass->pw_gid; /* Set up pipe user group membership. */ + initialise_groups(pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); initialize_groups(pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); get_current_groups( &p->pipe_user.ngroups, &p->pipe_user.groups); -- cgit From d407579b94ee2647d1e51c536534024e5c4c51ad Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 30 Aug 2000 00:45:59 +0000 Subject: Implemented AbortPrinter() from Gerald's Win32 test code. Just purge all possible printjobs from that printer (I think this is correct). Added error code returns for print_queue_XXX() functions. Jeremy. (This used to be commit 6d081a9017f87f59b7189ba507e211db01c40af5) --- source3/rpc_server/srv_spoolss.c | 31 +++++++++++++++++++++++++++++++ source3/rpc_server/srv_spoolss_nt.c | 19 ++++++++++++++++--- 2 files changed, 47 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 5a1592e4fb..e6a0f3ae6d 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -130,6 +130,36 @@ static BOOL api_spoolss_closeprinter(pipes_struct *p) return True; } +/******************************************************************** + * api_spoolss_abortprinter + * + * called from the spoolss dispatcher + ********************************************************************/ +static BOOL api_spoolss_abortprinter(pipes_struct *p) +{ + SPOOL_Q_ABORTPRINTER q_u; + SPOOL_R_ABORTPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!spoolss_io_q_abortprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_abortprinter: unable to unmarshall SPOOL_Q_ABORTPRINTER.\n")); + return False; + } + + r_u.status = _spoolss_abortprinter(&q_u.handle, p); + + if (!spoolss_io_r_abortprinter("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_abortprinter: unable to marshall SPOOL_R_ABORTPRINTER.\n")); + return False; + } + + return True; +} + /******************************************************************** * api_spoolss_deleteprinter * @@ -1209,6 +1239,7 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata }, {"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter }, {"SPOOLSS_DELETEPRINTER", SPOOLSS_DELETEPRINTER, api_spoolss_deleteprinter }, + {"SPOOLSS_ABORTPRINTER", SPOOLSS_ABORTPRINTER, api_spoolss_abortprinter }, {"SPOOLSS_RFFPCNEX", SPOOLSS_RFFPCNEX, api_spoolss_rffpcnex }, {"SPOOLSS_RFNPCNEX", SPOOLSS_RFNPCNEX, api_spoolss_rfnpcnex }, {"SPOOLSS_ENUMPRINTERS", SPOOLSS_ENUMPRINTERS, api_spoolss_enumprinters }, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b118b7c933..b9266c7ee1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2999,6 +2999,7 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command, { struct current_user user; int snum; + int errcode = 0; Printer_entry *Printer = find_printer_index_by_hnd(handle); if (p->ntlmssp_auth_validated) { @@ -3018,26 +3019,38 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command, switch (command) { case PRINTER_CONTROL_PAUSE: - if (print_queue_pause(&user, snum)) { + if (print_queue_pause(&user, snum, &errcode)) { return 0; } break; case PRINTER_CONTROL_RESUME: case PRINTER_CONTROL_UNPAUSE: - if (print_queue_resume(&user, snum)) { + if (print_queue_resume(&user, snum, &errcode)) { return 0; } break; case PRINTER_CONTROL_PURGE: - if (print_queue_purge(&user, snum)) { + if (print_queue_purge(&user, snum, &errcode)) { return 0; } break; } + if (errcode) + return (uint32)errcode; + return ERROR_INVALID_FUNCTION; } +/******************************************************************** + * api_spoolss_abortprinter + ********************************************************************/ + +uint32 _spoolss_abortprinter(POLICY_HND *handle, pipes_struct *p) +{ + return control_printer(handle, PRINTER_CONTROL_PURGE, p); +} + /******************************************************************** * called by spoolss_api_setprinter * when updating a printer description -- cgit From c77bf3d9e2ef416050bd2a25576f8fa584107fb5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 30 Aug 2000 21:09:21 +0000 Subject: Fixed error returns for moving printer driver files around so generic "Access denied" isn't always returned. More fixes found using Gerald's wonderful Win32 test progs :-). Jeremy. (This used to be commit 67b9d40e3df19523714430cb4457717575f2a61e) --- source3/rpc_server/srv_spoolss_nt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b9266c7ee1..8f58f72d73 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4327,8 +4327,9 @@ uint32 _spoolss_addprinterdriver(pipes_struct *p, const UNISTR2 *server_name, clean_up_driver_struct(driver, level); DEBUG(5,("Moving driver to final destination\n")); - if(!move_driver_to_download_area(driver, level, &user)) { - err = ERROR_ACCESS_DENIED; + if(!move_driver_to_download_area(driver, level, &user, &err)) { + if (err == 0) + err = ERROR_ACCESS_DENIED; goto done; } -- cgit From fa810d4c8001c10bddce452b4ab1178eb80dee87 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 31 Aug 2000 19:04:51 +0000 Subject: Implemented DELETEFORM tested using Gerald's Win32 test code :-). Jeremy. (This used to be commit 596c21a2af0309ce43a5e52a343a671036d05ebf) --- source3/rpc_server/srv_spoolss.c | 28 ++++++++++++++++++++++++++++ source3/rpc_server/srv_spoolss_nt.c | 25 +++++++++++++++++++++++++ 2 files changed, 53 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index e6a0f3ae6d..1e5ef1c673 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1055,6 +1055,33 @@ static BOOL api_spoolss_addform(pipes_struct *p) return True; } +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_deleteform(pipes_struct *p) +{ + SPOOL_Q_DELETEFORM q_u; + SPOOL_R_DELETEFORM r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_deleteform("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_deleteform: unable to unmarshall SPOOL_Q_DELETEFORM.\n")); + return False; + } + + r_u.status = _spoolss_deleteform(&q_u.handle, &q_u.name); + + if(!spoolss_io_r_deleteform("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_deleteform: unable to marshall SPOOL_R_DELETEFORM.\n")); + return False; + } + + return True; +} + /**************************************************************************** ****************************************************************************/ static BOOL api_spoolss_setform(pipes_struct *p) @@ -1265,6 +1292,7 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata }, {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata }, {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform }, + {"SPOOLSS_DELETEFORM", SPOOLSS_DELETEFORM, api_spoolss_deleteform }, {"SPOOLSS_SETFORM", SPOOLSS_SETFORM, api_spoolss_setform }, {"SPOOLSS_ENUMPRINTPROCESSORS", SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_enumprintprocessors }, {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors }, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8f58f72d73..0938b37ab3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4613,6 +4613,31 @@ uint32 _spoolss_addform( POLICY_HND *handle, return 0x0; } +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_deleteform( POLICY_HND *handle, UNISTR2 *form_name) +{ + int count=0; + uint32 ret = 0; + nt_forms_struct *list=NULL; + Printer_entry *Printer = find_printer_index_by_hnd(handle); + + DEBUG(5,("spoolss_deleteform\n")); + + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_deleteform: Invalid handle (%s).\n", OUR_HANDLE(handle))); + return ERROR_INVALID_HANDLE; + } + + count = get_ntforms(&list); + if(!delete_a_form(&list, form_name, &count, &ret)) + return ERROR_INVALID_PARAMETER; + + safe_free(list); + + return ret; +} + /**************************************************************************** ****************************************************************************/ uint32 _spoolss_setform( POLICY_HND *handle, -- cgit From a3a28675fafbbc5a5a378b3a7235253d772ef63e Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Fri, 1 Sep 2000 18:49:26 +0000 Subject: Changes from APPLIANCE_HEAD (per Tim Potter): - make proto - addition of function to convert from errno values to NT status codes (source/lib/error.c) - purge queue done without full access permission will purge only the jobs owned by that user, rather than failing. - unlock job database tdb before sending job to printer - in print_job_start(), ensure that we don't pick a jobid with an existing temporary file that may be owned by another user, as it causes silent failures. - fixes for printer permission checking for NT5 clients (source/include/rpc_spoolss.h, source/printing/nt_printing.c, source/printing/printing.c, source/rpc_server/srv_spoolss_nt.c) - change from uint8 to 'enum SID_NAME_USE' (source/rpc_server/srv_lsa.c) - fixed memory leaks for win95 driver download process (source/smbd/lanman.c) - properly free prs_structs and dacl in testsuite/printing/psec.c (This used to be commit 74af3e2caec7197e5d1ca389e2f78054a4197502) --- source3/rpc_server/srv_lsa.c | 4 ++-- source3/rpc_server/srv_spoolss_nt.c | 20 +++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index f37bb249ba..a7abc614e3 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -219,7 +219,7 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, pstring full_name; fstring dom_name; fstring user; - uint8 sid_name_use = SID_NAME_UNKNOWN; + enum SID_NAME_USE sid_name_use = SID_NAME_UNKNOWN; pstrcpy(full_name, dos_unistr2_to_str(&name[i])); @@ -298,7 +298,7 @@ static void init_lsa_trans_names(DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, uint32 rid = 0xffffffff; int dom_idx = -1; fstring name, dom_name; - uint8 sid_name_use = 0; + enum SID_NAME_USE sid_name_use = 0; /* Lookup sid from winbindd */ diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0938b37ab3..1f19be1188 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -22,7 +22,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "includes.h" extern int DEBUGLEVEL; @@ -2936,10 +2935,11 @@ uint32 _spoolss_startdocprinter(POLICY_HND *handle, uint32 level, Printer->jobid = print_job_start(&user, snum, jobname); - /* need to map error codes properly - for now give out of - memory as I don't know the correct codes (tridge) */ + /* An error occured in print_job_start() so return an appropriate + NT error code. */ + if (Printer->jobid == -1) { - return ERROR_NOT_ENOUGH_MEMORY; + return map_nt_error_from_unix(errno); } Printer->document_started=True; @@ -3082,7 +3082,7 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, descriptor. By experimentation with two NT machines, the user requires Full Access to the printer to change security information. */ - if (!print_access_check(&user, snum, PRINTER_ACE_FULL_CONTROL)) { + if (!print_access_check(&user, snum, PRINTER_ACCESS_ADMINISTER)) { result = ERROR_ACCESS_DENIED; goto done; } @@ -3172,13 +3172,13 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) numlines = 0; qlines = file_lines_load(tmp_file, &numlines); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); - DEBUGADD(10,("Line[0] = [%s]\n", qlines[0])); DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file)); unlink(tmp_file); if(numlines) { // Set the portname to what the script says the portname should be strncpy(printer->info_2->portname, qlines[0], sizeof(printer->info_2->portname)); + DEBUGADD(6,("Line[0] = [%s]\n", qlines[0])); // Send SIGHUP to process group... is there a better way? kill(0, SIGHUP); @@ -3226,7 +3226,7 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, goto done; } - if (!print_access_check(NULL, snum, PRINTER_ACE_FULL_CONTROL)) { + if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { DEBUG(3, ("printer property change denied by security " "descriptor\n")); result = ERROR_ACCESS_DENIED; @@ -4028,7 +4028,6 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need numlines = 0; qlines = file_lines_load(tmp_file, &numlines); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); - DEBUGADD(10,("Line[0] = [%s]\n", qlines[0])); DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file)); unlink(tmp_file); @@ -4127,7 +4126,6 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need numlines = 0; qlines = file_lines_load(tmp_file, &numlines); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); - DEBUGADD(10,("Line[0] = [%s]\n", qlines[0])); DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file)); unlink(tmp_file); @@ -4247,7 +4245,7 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, } /* you must be a printer admin to add a new printer */ - if (!print_access_check(NULL, snum, PRINTER_ACE_FULL_CONTROL)) { + if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { free_a_printer(&printer,2); return ERROR_ACCESS_DENIED; } @@ -4564,7 +4562,7 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, if (!get_printer_snum(handle, &snum)) return ERROR_INVALID_HANDLE; - if (!print_access_check(NULL, snum, PRINTER_ACE_FULL_CONTROL)) { + if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { DEBUG(3, ("security descriptor change denied by existing " "security descriptor\n")); return ERROR_ACCESS_DENIED; -- cgit From d644d4438cfef54733118cbd09f89518ffb318ca Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 5 Sep 2000 20:56:09 +0000 Subject: Implemented GETFORM tested and working using Gerald's Win32 test progs.... Jeremy. (This used to be commit 55ed0a9b0c91159c0fc4282c2171d9ced74a302a) --- source3/rpc_server/srv_spoolss.c | 38 +++++++++++++++++++++ source3/rpc_server/srv_spoolss_nt.c | 67 +++++++++++++++++++++++++++++++++++-- 2 files changed, 103 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 1e5ef1c673..fd6cf11746 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -773,6 +773,43 @@ static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p) } +/**************************************************************************** +****************************************************************************/ +static BOOL api_spoolss_getform(pipes_struct *p) +{ + SPOOL_Q_GETFORM q_u; + SPOOL_R_GETFORM r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!new_spoolss_allocate_buffer(&q_u.buffer)) + return False; + + if (!spoolss_io_q_getform("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_getform: unable to unmarshall SPOOL_Q_GETFORM.\n")); + return False; + } + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); + + r_u.status = _spoolss_getform(&q_u.handle, q_u.level, + &q_u.formname, r_u.buffer, q_u.offered, &r_u.needed); + + if (!new_spoolss_io_r_getform("",&r_u,rdata,0)) { + DEBUG(0,("new_spoolss_io_r_getform: unable to marshall SPOOL_R_GETFORM.\n")); + new_spoolss_free_buffer(q_u.buffer); + return False; + } + + new_spoolss_free_buffer(q_u.buffer); + + return True; +} + /**************************************************************************** ****************************************************************************/ static BOOL api_spoolss_enumforms(pipes_struct *p) @@ -1293,6 +1330,7 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata }, {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform }, {"SPOOLSS_DELETEFORM", SPOOLSS_DELETEFORM, api_spoolss_deleteform }, + {"SPOOLSS_GETFORM", SPOOLSS_GETFORM, api_spoolss_getform }, {"SPOOLSS_SETFORM", SPOOLSS_SETFORM, api_spoolss_setform }, {"SPOOLSS_ENUMPRINTPROCESSORS", SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_enumprintprocessors }, {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors }, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1f19be1188..a31858a3e0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3888,7 +3888,7 @@ uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32 /**************************************************************************** ****************************************************************************/ -static void fill_form_1(FORM_1 *form, nt_forms_struct *list, int position) +static void fill_form_1(FORM_1 *form, nt_forms_struct *list) { form->flag=list->flag; init_unistr(&form->name, list->name); @@ -3930,7 +3930,7 @@ uint32 _new_spoolss_enumforms( POLICY_HND *handle, uint32 level, /* construct the list of form structures */ for (i=0; i<*numofforms; i++) { DEBUGADD(6,("Filling form number [%d]\n",i)); - fill_form_1(&forms_1[i], &list[i], i); + fill_form_1(&forms_1[i], &list[i]); } safe_free(list); @@ -3970,6 +3970,69 @@ uint32 _new_spoolss_enumforms( POLICY_HND *handle, uint32 level, } +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_getform( POLICY_HND *handle, uint32 level, UNISTR2 *uni_formname, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + nt_forms_struct *list=NULL; + FORM_1 form_1; + fstring form_name; + int buffer_size=0; + int numofforms, i; + + unistr2_to_ascii(form_name, uni_formname, sizeof(form_name)-1); + + DEBUG(4,("_spoolss_getform\n")); + DEBUGADD(5,("Offered buffer size [%d]\n", offered)); + DEBUGADD(5,("Info level [%d]\n", level)); + + numofforms = get_ntforms(&list); + DEBUGADD(5,("Number of forms [%d]\n", numofforms)); + + if (numofforms == 0) + return ERROR_NO_MORE_ITEMS; + + switch (level) { + case 1: + + /* Check if the requested name is in the list of form structures */ + for (i=0; i offered) { + return ERROR_INSUFFICIENT_BUFFER; + } + + /* fill the buffer with the form structures */ + DEBUGADD(6,("adding form %s [%d] to buffer\n", form_name, i)); + new_smb_io_form_1("", buffer, &form_1, 0); + + return NT_STATUS_NO_PROBLEMO; + + default: + safe_free(list); + return ERROR_INVALID_LEVEL; + } +} + /**************************************************************************** ****************************************************************************/ static void fill_port_1(PORT_INFO_1 *port, char *name) -- cgit From a1f66a820d78244fcab960fe33999c76cc1d65c5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 6 Sep 2000 01:06:39 +0000 Subject: Fix for the SID history problem when using a Win2k domain controller with security=domain. Also fixed to dynamically allocate the SIDs and GIDs. Jeremy. (This used to be commit 2b1f66eb82f05fe0b85ac5b4916e32847b8de675) --- source3/rpc_server/srv_netlog.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index f634b8e15f..9f5d84ee1f 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -665,18 +665,15 @@ static BOOL api_net_sam_logon(pipes_struct *p) q_l.sam_id.ctr = &ctr; if(!net_io_q_sam_logon("", &q_l, data, 0)) { - DEBUG(0, - ("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n")); + DEBUG(0, ("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n")); return False; } /* checks and updates credentials. creates reply credentials */ - if (!deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), - &(q_l.sam_id.client.cred), &srv_cred)) + if (!deal_with_creds(vuser->dc.sess_key, &vuser->dc.clnt_cred, &q_l.sam_id.client.cred, &srv_cred)) status = NT_STATUS_INVALID_HANDLE; else - memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), - sizeof(vuser->dc.clnt_cred)); + memcpy(&vuser->dc.srv_cred, &vuser->dc.clnt_cred, sizeof(vuser->dc.clnt_cred)); /* find the username */ @@ -858,9 +855,13 @@ static BOOL api_net_sam_logon(pipes_struct *p) free((char *)gids); } - if(!net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status)) + if(!net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status)) { + free_user_info3(&usr_info); return False; - + } + + free_user_info3(&usr_info); + return True; } -- cgit From 061fc961cd0f6f10e794402a56b80e0c0039e3b2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 6 Sep 2000 01:55:36 +0000 Subject: Fix from John Reilly for double free of printer struct. Jeremy. (This used to be commit c15b7e41e170ced4e4de2e08f6fba860f51e66ac) --- source3/rpc_server/srv_spoolss_nt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a31858a3e0..d73fc649dd 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3165,7 +3165,6 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) if ( ret != 0 ) { unlink(tmp_file); - free_a_printer(&printer,2); return False; } @@ -4296,9 +4295,11 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, convert_printer_info(info, printer, 2); if (*lp_addprinter_cmd() ) - if ( !add_printer_hook(printer) ) + if ( !add_printer_hook(printer) ) { + free_a_printer(&printer,2); return ERROR_ACCESS_DENIED; - + } + slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname, printer->info_2->sharename); -- cgit From 6ef7bf0eac2ca8838322ffc92704fe275b19ec6f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 7 Sep 2000 19:12:59 +0000 Subject: Added code to return NO_MORE_ENTRIES when trying to determine size using "NT mega hack". I think this is the correct thing to do but JF should also examine the. Jeremy. (This used to be commit 29ba3a2cdf7f6fbcf0be41b75d76c04007cd4651) --- source3/rpc_server/srv_spoolss_nt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d73fc649dd..8e5c48271b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4540,6 +4540,18 @@ uint32 _spoolss_enumprinterdata(POLICY_HND *handle, uint32 idx, param_index++; } + /* + * I think this is correct, it doesn't break APW and + * allows Gerald's Win32 test programs to work correctly, + * but may need altering.... JRA. + */ + + if (param_index == 0) { + /* No parameters found. */ + free_a_printer(&printer, 2); + return ERROR_NO_MORE_ITEMS; + } + /* the value is an UNICODE string but realvaluesize is the length in bytes including the leading 0 */ *out_value_len=2*(1+biggest_valuesize); *out_data_len=biggest_datasize; -- cgit From 8808c4e6c8da17dbb6f173d4694aa58e4443e893 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 7 Sep 2000 20:56:24 +0000 Subject: Fixed the printerdata code to return NO_MORE_ITEMS if a size is requested and the parameter index doesn't exist. I think this code can be simplified considerably, but JF needs to check to be sure. Jeremy. (This used to be commit 4d792e6bcb7bef640c2c4e3054ed8839d8fc86f4) --- source3/rpc_server/srv_spoolss_nt.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8e5c48271b..99ead42ffd 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4525,7 +4525,25 @@ uint32 _spoolss_enumprinterdata(POLICY_HND *handle, uint32 idx, */ if ( (in_value_len==0) && (in_data_len==0) ) { DEBUGADD(6,("Activating NT mega-hack to find sizes\n")); - + + /* + * NT can ask for a specific parameter size - we need to return NO_MORE_ITEMS + * if this parameter size doesn't exist. + * Ok - my opinion here is that the client is not asking for the greatest + * possible size of all the parameters, but is asking specifically for the size needed + * for this specific parameter. In that case we can remove the loop below and + * simplify this lookup code considerably. JF - comments welcome. JRA. + */ + + 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; + } + + safe_free(data); + data = NULL; + param_index=0; biggest_valuesize=0; biggest_datasize=0; @@ -4537,6 +4555,7 @@ uint32 _spoolss_enumprinterdata(POLICY_HND *handle, uint32 idx, DEBUG(6,("current values: [%d], [%d]\n", biggest_valuesize, biggest_datasize)); safe_free(data); + data = NULL; param_index++; } -- cgit From f4ae5a6e389aa64782986ba6eed4bb1e31f1cb71 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 8 Sep 2000 00:28:07 +0000 Subject: Win32 API is explicit that EnumPrinterData returns ERROR_MORE_DATA not ERROR_INSUFICIENT_BUFFER when working out what space is needed. This fix gives us the same return that WinNT does. Jeremy. (This used to be commit a87f6277b1faa1ea492f31add4ce33556bdf3695) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 99ead42ffd..71df03cd08 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -882,7 +882,7 @@ uint32 _spoolss_getprinterdata(POLICY_HND *handle, UNISTR2 *valuename, } if (*needed > *out_size) - return ERROR_INSUFFICIENT_BUFFER; + return ERROR_MORE_DATA; else return NT_STATUS_NO_PROBLEMO; } -- cgit From 912ecf7fb9d2276c7aa23dbe81f59af41fa422f1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 8 Sep 2000 02:20:48 +0000 Subject: Fixed typo where docname was being checked for datatype - was causing STARTDOCPRINTER call to fail. I *love* Gerald's test code :-). Jeremy. (This used to be commit 43192370f31c7cc71d1f72449a067573adad3ebc) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 71df03cd08..52a677fbe0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2919,7 +2919,7 @@ uint32 _spoolss_startdocprinter(POLICY_HND *handle, uint32 level, */ if (info_1->p_datatype != 0) { - unistr2_to_ascii(datatype, &info_1->docname, sizeof(datatype)); + unistr2_to_ascii(datatype, &info_1->datatype, sizeof(datatype)); if (strcmp(datatype, "RAW") != 0) { (*jobid)=0; return ERROR_INVALID_DATATYPE; -- cgit From e0f9de0c49dde82610b0da406b4685e787f69725 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 9 Sep 2000 00:19:35 +0000 Subject: Implemented DELETEPRINTERDATA (tested with Gerald's Win32 progs). Jeremy. (This used to be commit fb48efaf830626f6ef05b88f5f8a74b932ceb257) --- source3/rpc_server/srv_spoolss.c | 32 ++++++++++++++++++++++++++++ source3/rpc_server/srv_spoolss_nt.c | 42 +++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index fd6cf11746..72ce17fee1 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -99,6 +99,37 @@ static BOOL api_spoolss_getprinterdata(pipes_struct *p) return True; } +/******************************************************************** + * api_spoolss_deleteprinterdata + * + * called from the spoolss dispatcher + ********************************************************************/ +static BOOL api_spoolss_deleteprinterdata(pipes_struct *p) +{ + SPOOL_Q_DELETEPRINTERDATA q_u; + SPOOL_R_DELETEPRINTERDATA r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* read the stream and fill the struct */ + if (!spoolss_io_q_deleteprinterdata("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_deleteprinterdata: unable to unmarshall SPOOL_Q_DELETEPRINTERDATA.\n")); + return False; + } + + r_u.status = _spoolss_deleteprinterdata( &q_u.handle, &q_u.valuename); + + if (!spoolss_io_r_deleteprinterdata("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_deleteprinterdata: unable to marshall SPOOL_R_DELETEPRINTERDATA.\n")); + return False; + } + + return True; +} + /******************************************************************** * api_spoolss_closeprinter * @@ -1328,6 +1359,7 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory }, {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata }, {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata }, + {"SPOOLSS_DELETEPRINTERDATA", SPOOLSS_DELETEPRINTERDATA, api_spoolss_deleteprinterdata }, {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform }, {"SPOOLSS_DELETEFORM", SPOOLSS_DELETEFORM, api_spoolss_deleteform }, {"SPOOLSS_GETFORM", SPOOLSS_GETFORM, api_spoolss_getform }, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 52a677fbe0..2c0dc79fb2 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4679,6 +4679,48 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, return status; } +/**************************************************************************** +****************************************************************************/ +uint32 _spoolss_deleteprinterdata( POLICY_HND *handle, const UNISTR2 *value) +{ + NT_PRINTER_INFO_LEVEL *printer = NULL; + NT_PRINTER_PARAM param; + int snum=0; + uint32 status = 0x0; + Printer_entry *Printer=find_printer_index_by_hnd(handle); + + DEBUG(5,("spoolss_deleteprinterdata\n")); + + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_deleteprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); + return ERROR_INVALID_HANDLE; + } + + if (!get_printer_snum(handle, &snum)) + return ERROR_INVALID_HANDLE; + + if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { + DEBUG(3, ("_spoolss_deleteprinterdata: security descriptor change denied by existing " + "security descriptor\n")); + return ERROR_ACCESS_DENIED; + } + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (status != 0x0) + return ERROR_INVALID_NAME; + + ZERO_STRUCTP(¶m); + unistr2_to_ascii(param.value, value, sizeof(param.value)-1); + + if(!unlink_specific_param_if_exist(printer->info_2, ¶m)) + status = ERROR_INVALID_PARAMETER; + else + status = add_a_printer(*printer, 2); + + free_a_printer(&printer, 2); + return status; +} + /**************************************************************************** ****************************************************************************/ uint32 _spoolss_addform( POLICY_HND *handle, -- cgit From 692fe0cabfaf4b0e13083aa5d6fc9dddb4e5dd5b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 11 Sep 2000 23:21:16 +0000 Subject: Fix for malloc of zero bytes found by insure. Jeremy. (This used to be commit 2916790859acc56e582056774b02d4a33cedeaa4) --- source3/rpc_server/srv_spoolss_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2c0dc79fb2..da5b3e960f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3564,6 +3564,11 @@ uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, *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; + } + switch (level) { case 1: return enumjobs_level1(queue, snum, buffer, offered, needed, returned); -- cgit From d836024b2816f37abd523afb3b2d4f2bfb130f0a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 11 Sep 2000 23:43:44 +0000 Subject: Fixed memory leaks found in enumprinterdrivers code. Jeremy. (This used to be commit e08b521559a824da09b0b73a04e462c573c42b06) --- source3/rpc_server/srv_spoolss_nt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index da5b3e960f..7f7a75fc5c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3677,7 +3677,8 @@ static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture DEBUGADD(5,("\tdriver: [%s]\n", list[i])); ZERO_STRUCT(driver); get_a_printer_driver(&driver, 3, list[i], architecture, version); - fill_printer_driver_info_1(&(driver_info_1[*returned+i]), driver, servername, architecture ); + fill_printer_driver_info_1(&driver_info_1[*returned+i], driver, servername, architecture ); + free_a_printer_driver(driver, 3); } *returned+=ndrivers; @@ -3687,7 +3688,7 @@ static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture /* check the required size. */ for (i=0; i<*returned; i++) { DEBUGADD(6,("adding driver [%d]'s size\n",i)); - *needed += spoolss_size_printer_driver_info_1(&(driver_info_1[i])); + *needed += spoolss_size_printer_driver_info_1(&driver_info_1[i]); } if (!alloc_buffer_size(buffer, *needed)) { @@ -3698,7 +3699,7 @@ static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture /* fill the buffer with the form structures */ for (i=0; i<*returned; i++) { DEBUGADD(6,("adding driver [%d] to buffer\n",i)); - new_smb_io_printer_driver_info_1("", buffer, &(driver_info_1[i]), 0); + new_smb_io_printer_driver_info_1("", buffer, &driver_info_1[i], 0); } safe_free(driver_info_1); @@ -3747,7 +3748,8 @@ static uint32 enumprinterdrivers_level2(fstring servername, fstring architecture DEBUGADD(5,("\tdriver: [%s]\n", list[i])); ZERO_STRUCT(driver); get_a_printer_driver(&driver, 3, list[i], architecture, version); - fill_printer_driver_info_2(&(driver_info_2[*returned+i]), driver, servername); + fill_printer_driver_info_2(&driver_info_2[*returned+i], driver, servername); + free_a_printer_driver(driver, 3); } *returned+=ndrivers; @@ -3817,7 +3819,8 @@ static uint32 enumprinterdrivers_level3(fstring servername, fstring architecture DEBUGADD(5,("\tdriver: [%s]\n", list[i])); ZERO_STRUCT(driver); get_a_printer_driver(&driver, 3, list[i], architecture, version); - fill_printer_driver_info_3(&(driver_info_3[*returned+i]), driver, servername); + fill_printer_driver_info_3(&driver_info_3[*returned+i], driver, servername); + free_a_printer_driver(driver, 3); } *returned+=ndrivers; -- cgit From 043860d8b71925b0973d81daf7cf7e39354bdc28 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 12 Sep 2000 21:45:42 +0000 Subject: Fixed error return when printer is PAUSED - should be returning "Pause". Jeremy. (This used to be commit 41d03a118c9981fc2159f37cd5ed4684e1d36037) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7f7a75fc5c..0464d252f0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -100,7 +100,7 @@ static int nt_printq_status(int v) { switch (v) { case LPQ_PAUSED: - return PRINTER_STATUS_ERROR; + return PRINTER_STATUS_PAUSED; case LPQ_QUEUED: case LPQ_SPOOLING: case LPQ_PRINTING: -- cgit From 3e675875a45dea286cc28beef043f6e18d6addde Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 12 Sep 2000 22:33:41 +0000 Subject: Fix for enumjobs infor level 2 which caused smbd to coredump. Uninitialized element in struct. Jeremy. (This used to be commit 9e1fbb0c2f1d2ad0c907f1e902e44ea7af214b57) --- source3/rpc_server/srv_spoolss_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0464d252f0..5f69c097c7 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3424,6 +3424,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, init_unistr(&job_info->datatype, "RAW"); init_unistr(&job_info->printprocessor, "winprint"); init_unistr(&job_info->parameters, ""); + init_unistr(&job_info->drivername, ntprinter->info_2->drivername); init_unistr(&job_info->text_status, ""); /* and here the security descriptor */ -- cgit From ed6530800ccf4e8303bc7e106ca7443950fa27c9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 13 Sep 2000 18:50:38 +0000 Subject: Added SIGHUP when printer deleted as well as added. Jeremy. (This used to be commit 79c94f37d0434150d84858e67c8677650106d76c) --- source3/rpc_server/srv_spoolss_nt.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5f69c097c7..4727ee8092 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -247,6 +247,9 @@ static BOOL delete_printer_handle(POLICY_HND *hnd) DEBUGADD(10,("Unlinking output file [%s]\n", tmp_file)); unlink(tmp_file); + // Send SIGHUP to process group... is there a better way? + kill(0, SIGHUP); + if ( ( i = lp_servicenumber( Printer->dev.handlename ) ) >= 0 ) { lp_remove_service( i ); lp_killservice( i ); -- cgit From ccddd111c6b0c2d41c7b1e3875dca4e760205b79 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 15 Sep 2000 00:15:10 +0000 Subject: Move towards getting W2k p&p to upload NT4.x drivers. Still doesn't work - not sure why (JF - a glance at this would be appreciated). Removed code that JF objected to with enumprinterdata. Added translations to/from level 6 - but Win2k still not happy... hmmm... Jeremy. (This used to be commit e5d98ba9e97eb16337ff6c49f799e130844ae72e) --- source3/rpc_server/srv_spoolss_nt.c | 179 +++++++++++++++++++++++++++++++++--- 1 file changed, 166 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4727ee8092..c22767c43a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -535,11 +535,7 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) prs_set_offset(ps, old_offset); -#if 0 /* JRATEST */ - buffer->string_at_end = buffer_size; -#else buffer->string_at_end=prs_data_size(ps); -#endif return True; } @@ -1838,10 +1834,7 @@ static DEVICEMODE *construct_dev_mode(int snum, char *servername) if (printer->info_2->devmode) ntdevmode = dup_nt_devicemode(printer->info_2->devmode); -#if 0 /* JFMTEST */ - else - ntdevmode = construct_nt_devicemode(printer->info_2->printername); -#endif + if (ntdevmode == NULL) goto fail; @@ -1998,10 +1991,29 @@ static BOOL construct_printer_info_3(fstring servername, ZERO_STRUCTP(printer); - printer->flags = 4; /* This is the offset to the SEC_DESC. */ + printer->flags = 4; /* These are the components of the SD we are returning. */ if (ntprinter->info_2->secdesc_buf && ntprinter->info_2->secdesc_buf->len != 0) { /* steal the printer info sec_desc structure. [badly done]. */ printer->secdesc = ntprinter->info_2->secdesc_buf->sec; + +#if 0 + /* + * Set the flags for the components we are returning. + */ + + if (printer->secdesc->owner_sid) + printer->flags |= OWNER_SECURITY_INFORMATION; + + if (printer->secdesc->grp_sid) + printer->flags |= GROUP_SECURITY_INFORMATION; + + if (printer->secdesc->dacl) + printer->flags |= DACL_SECURITY_INFORMATION; + + if (printer->secdesc->sacl) + printer->flags |= SACL_SECURITY_INFORMATION; +#endif + ntprinter->info_2->secdesc_buf->sec = NULL; /* Stolen the malloced memory. */ ntprinter->info_2->secdesc_buf->len = 0; /* Stolen the malloced memory. */ ntprinter->info_2->secdesc_buf->max_len = 0; /* Stolen the malloced memory. */ @@ -2643,6 +2655,8 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN pstring temp_configfile; pstring temp_helpfile; + ZERO_STRUCTP(info); + info->version=driver.info_3->cversion; init_unistr( &info->name, driver.info_3->name ); @@ -2675,7 +2689,7 @@ static uint32 construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; -uint32 status=0; + uint32 status=0; ZERO_STRUCT(driver); status=get_a_printer(&printer, 2, lp_servicename(snum) ); @@ -2697,6 +2711,84 @@ uint32 status=0; return NT_STATUS_NO_PROBLEMO; } +/******************************************************************** + * construct_printer_info_6 + * fill a printer_info_6 struct - we know that driver is really level 3. This sucks. JRA. + ********************************************************************/ + +static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) +{ + pstring temp_driverpath; + pstring temp_datafile; + pstring temp_configfile; + pstring temp_helpfile; + fstring nullstr; + + ZERO_STRUCTP(info); + memset(&nullstr, '\0', sizeof(fstring)); + + info->version=driver.info_3->cversion; + + init_unistr( &info->name, driver.info_3->name ); + init_unistr( &info->architecture, driver.info_3->environment ); + + snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + init_unistr( &info->driverpath, temp_driverpath ); + + snprintf(temp_datafile, sizeof(temp_datafile)-1, "\\\\%s%s", servername, driver.info_3->datafile); + init_unistr( &info->datafile, temp_datafile ); + + snprintf(temp_configfile, sizeof(temp_configfile)-1, "\\\\%s%s", servername, driver.info_3->configfile); + init_unistr( &info->configfile, temp_configfile ); + + snprintf(temp_helpfile, sizeof(temp_helpfile)-1, "\\\\%s%s", servername, driver.info_3->helpfile); + init_unistr( &info->helpfile, temp_helpfile ); + + init_unistr( &info->monitorname, driver.info_3->monitorname ); + init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype ); + + info->dependentfiles=NULL; + init_unistr_array(&info->dependentfiles, driver.info_3->dependentfiles, servername); + + info->previousdrivernames=NULL; + init_unistr_array(&info->previousdrivernames, &nullstr, servername); + + init_unistr( &info->mfgname, ""); + init_unistr( &info->oem_url, ""); + init_unistr( &info->hardware_id, ""); + init_unistr( &info->provider, ""); +} + +/******************************************************************** + * construct_printer_info_6 + * fill a printer_info_6 struct + ********************************************************************/ +static uint32 construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fstring servername, fstring architecture, uint32 version) +{ + NT_PRINTER_INFO_LEVEL *printer = NULL; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + uint32 status=0; + ZERO_STRUCT(driver); + + 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; + + status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); + DEBUG(8,("construct_printer_driver_info_6: status: %d\n", status)); + if (status != 0) { + free_a_printer(&printer,2); + return ERROR_UNKNOWN_PRINTER_DRIVER; + } + + fill_printer_driver_info_6(info, driver, servername); + + free_a_printer(&printer,2); + + return NT_STATUS_NO_PROBLEMO; +} + /**************************************************************************** ****************************************************************************/ @@ -2705,6 +2797,15 @@ static void free_printer_driver_info_3(DRIVER_INFO_3 *info) safe_free(info->dependentfiles); } +/**************************************************************************** +****************************************************************************/ + +static void free_printer_driver_info_6(DRIVER_INFO_6 *info) +{ + safe_free(info->dependentfiles); + +} + /**************************************************************************** ****************************************************************************/ static uint32 getprinterdriver2_level1(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) @@ -2810,6 +2911,39 @@ static uint32 getprinterdriver2_level3(fstring servername, fstring architecture, return NT_STATUS_NO_PROBLEMO; } +/**************************************************************************** +****************************************************************************/ +static uint32 getprinterdriver2_level6(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + DRIVER_INFO_6 info; + uint32 status; + + ZERO_STRUCT(info); + + status=construct_printer_driver_info_6(&info, snum, servername, architecture, version); + if (status != NT_STATUS_NO_PROBLEMO) { + return status; + } + + /* check the required size. */ + *needed += spoolss_size_printer_driver_info_6(&info); + + if (!alloc_buffer_size(buffer, *needed)) { + free_printer_driver_info_3(&info); + return ERROR_INSUFFICIENT_BUFFER; + } + + /* fill the buffer with the structures */ + new_smb_io_printer_driver_info_6("", buffer, &info, 0); + + free_printer_driver_info_6(&info); + + if (*needed > offered) + return ERROR_INSUFFICIENT_BUFFER; + else + return NT_STATUS_NO_PROBLEMO; +} + /**************************************************************************** ****************************************************************************/ uint32 _spoolss_getprinterdriver2(POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level, @@ -2843,6 +2977,9 @@ uint32 _spoolss_getprinterdriver2(POLICY_HND *handle, const UNISTR2 *uni_arch, u case 3: return getprinterdriver2_level3(servername, architecture, clientmajorversion, snum, buffer, offered, needed); break; + case 6: + return getprinterdriver2_level6(servername, architecture, clientmajorversion, snum, buffer, offered, needed); + break; default: return ERROR_INVALID_LEVEL; break; @@ -3678,9 +3815,13 @@ static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture } for (i=0; i Date: Sat, 16 Sep 2000 10:07:46 +0000 Subject: in a printer_info_6, driver version is 64 bits long and there is a 32 bit padding before. J.F. (This used to be commit cd41d7a35477accec1a82b86f9fa3477e5a49d6e) --- source3/rpc_server/srv_spoolss_nt.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c22767c43a..0430563629 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2753,6 +2753,13 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN info->previousdrivernames=NULL; init_unistr_array(&info->previousdrivernames, &nullstr, servername); + info->driver_date.low=0; + info->driver_date.high=0; + + info->padding=0; + info->driver_version_low=0; + info->driver_version_high=0; + init_unistr( &info->mfgname, ""); init_unistr( &info->oem_url, ""); init_unistr( &info->hardware_id, ""); -- cgit From b774aa4b8978b7824e6a0361672179afb1fc7b2d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 21 Sep 2000 21:44:15 +0000 Subject: Adding fix from Jim Vopni to ensure jobs are closed before a printer is closed/deleted. Jeremy. (This used to be commit f0c16f7228d6923b11ac521aef986960a1d0c0b4) --- source3/rpc_server/srv_spoolss_nt.c | 66 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0430563629..ca1b20522b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -672,6 +672,11 @@ static BOOL convert_devicemode(const DEVICEMODE *devmode, NT_DEVICEMODE *nt_devm ********************************************************************/ uint32 _spoolss_closeprinter(POLICY_HND *handle) { + Printer_entry *Printer=find_printer_index_by_hnd(handle); + + if (Printer && Printer->document_started) + _spoolss_enddocprinter(handle); /* print job was not closed */ + if (!close_printer_handle(handle)) return ERROR_INVALID_HANDLE; @@ -683,6 +688,11 @@ uint32 _spoolss_closeprinter(POLICY_HND *handle) ********************************************************************/ uint32 _spoolss_deleteprinter(POLICY_HND *handle) { + Printer_entry *Printer=find_printer_index_by_hnd(handle); + + if (Printer && Printer->document_started) + _spoolss_enddocprinter(handle); /* print job was not closed */ + if (!delete_printer_handle(handle)) return ERROR_INVALID_HANDLE; @@ -3024,6 +3034,21 @@ uint32 _spoolss_endpageprinter(POLICY_HND *handle) return NT_STATUS_NO_PROBLEMO; } +/**************************************************************************** + Return a user struct for a pipe user. +****************************************************************************/ + +static struct current_user *get_current_user(struct current_user *user, pipes_struct *p) +{ + if (p->ntlmssp_auth_validated) { + memcpy(user, &p->pipe_user, sizeof(user)); + } else { + extern struct current_user current_user; + memcpy(user, ¤t_user, sizeof(user)); + } + + return user; +} /******************************************************************** * api_spoolss_getprinter @@ -3046,12 +3071,7 @@ uint32 _spoolss_startdocprinter(POLICY_HND *handle, uint32 level, return ERROR_INVALID_HANDLE; } - if (p->ntlmssp_auth_validated) { - memcpy(&user, &p->pipe_user, sizeof(user)); - } else { - extern struct current_user current_user; - memcpy(&user, ¤t_user, sizeof(user)); - } + get_current_user(&user, p); /* * a nice thing with NT is it doesn't listen to what you tell it. @@ -3149,12 +3169,7 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command, int errcode = 0; Printer_entry *Printer = find_printer_index_by_hnd(handle); - if (p->ntlmssp_auth_validated) { - memcpy(&user, &p->pipe_user, sizeof(user)); - } else { - extern struct current_user current_user; - memcpy(&user, ¤t_user, sizeof(user)); - } + get_current_user(&user, p); if (!OPEN_HANDLE(Printer)) { DEBUG(0,("control_printer: Invalid handle (%s)\n", OUR_HANDLE(handle))); @@ -3218,12 +3233,7 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, } /* Work out which user is performing the operation */ - if (p->ntlmssp_auth_validated) { - memcpy(&user, &p->pipe_user, sizeof(user)); - } else { - extern struct current_user current_user; - memcpy(&user, ¤t_user, sizeof(user)); - } + get_current_user(&user, p); /* Check the user has permissions to change the security descriptor. By experimentation with two NT machines, the user @@ -3745,7 +3755,7 @@ uint32 _spoolss_schedulejob( POLICY_HND *handle, uint32 jobid) uint32 _spoolss_setjob( POLICY_HND *handle, uint32 jobid, uint32 level, - pipes_struct *p, + pipes_struct *p, JOB_INFO *ctr, uint32 command) @@ -3763,13 +3773,8 @@ uint32 _spoolss_setjob( POLICY_HND *handle, if (!print_job_exists(jobid)) { return ERROR_INVALID_PRINTER_NAME; } - - if (p->ntlmssp_auth_validated) { - memcpy(&user, &p->pipe_user, sizeof(user)); - } else { - extern struct current_user current_user; - memcpy(&user, ¤t_user, sizeof(user)); - } + + get_current_user(&user, p); switch (command) { case JOB_CONTROL_CANCEL: @@ -4545,13 +4550,8 @@ uint32 _spoolss_addprinterdriver(pipes_struct *p, const UNISTR2 *server_name, struct current_user user; ZERO_STRUCT(driver); - - if (p->ntlmssp_auth_validated) { - memcpy(&user, &p->pipe_user, sizeof(user)); - } else { - extern struct current_user current_user; - memcpy(&user, ¤t_user, sizeof(user)); - } + + get_current_user(&user, p); convert_printer_driver_info(info, &driver, level); -- cgit From 233bc000209cf5759e0e49ad83da70b280d51dae Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 25 Sep 2000 21:05:18 +0000 Subject: printer notify code. It only sends notifies to one client. The broadcasting notify code will code soon. J.F. (This used to be commit 4c63c9185887c64e57d901e82a4a16a83522c898) --- source3/rpc_server/srv_spoolss_nt.c | 150 ++++++++++++++++++++++++++++++++++-- 1 file changed, 144 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ca1b20522b..2a25f615d8 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -60,6 +60,8 @@ typedef struct _Printer{ fstring localmachine; uint32 printerlocal; SPOOL_NOTIFY_OPTION *option; + POLICY_HND client_hnd; + uint32 client_connected; } notify; struct { fstring machine; @@ -78,6 +80,8 @@ typedef struct _counter_printer_0 { static ubi_dlList Printer_list; static ubi_dlList counter_list; +static struct cli_state cli; +static uint32 smb_connections=0; #define OPEN_HANDLE(pnum) ((pnum!=NULL) && (pnum->open!=False) && (IVAL(pnum->printer_hnd.data,16)==(uint32)sys_getpid())) #define OUR_HANDLE(pnum) ((pnum==NULL)?"NULL":(IVAL(pnum->data,16)==sys_getpid()?"OURS":"OTHER")) @@ -170,6 +174,30 @@ static void clear_handle(POLICY_HND *hnd) ZERO_STRUCTP(hnd); } +/*************************************************************************** + Disconnect from the client +****************************************************************************/ +static BOOL srv_spoolss_replycloseprinter(POLICY_HND *handle) +{ + uint32 status; + + /* weird if the test succeds !!! */ + if (smb_connections==0) { + DEBUG(0,("srv_spoolss_replycloseprinter:Trying to close non-existant notify backchannel !\n")); + return False; + } + + if(!cli_spoolss_reply_close_printer(&cli, handle, &status)) + return False; + + /* if it's the last connection, deconnect the IPC$ share */ + if (smb_connections==1) + if(!spoolss_disconnect_from_client(&cli)) + return False; + + smb_connections--; +} + /**************************************************************************** close printer index by handle ****************************************************************************/ @@ -182,6 +210,10 @@ static BOOL close_printer_handle(POLICY_HND *hnd) return False; } + if (Printer->notify.client_connected==True) + if(!srv_spoolss_replycloseprinter(&Printer->notify.client_hnd)) + return ERROR_INVALID_HANDLE; + Printer->open=False; Printer->notify.flags=0; Printer->notify.options=0; @@ -189,7 +221,8 @@ static BOOL close_printer_handle(POLICY_HND *hnd) Printer->notify.printerlocal=0; safe_free(Printer->notify.option); Printer->notify.option=NULL; - + Printer->notify.client_connected=False; + clear_handle(hnd); ubi_dlRemThis(&Printer_list, Printer); @@ -540,6 +573,57 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) return True; } +/*************************************************************************** + receive the notify message +****************************************************************************/ +static BOOL srv_spoolss_receive_message(char *printer) +{ + uint32 status; + Printer_entry *find_printer; + + find_printer = (Printer_entry *)ubi_dlFirst(&Printer_list); + + /* Iterate the printer list. */ + for(; find_printer; find_printer = (Printer_entry *)ubi_dlNext(find_printer)) { + + /* + * if the entry is the given printer or if it's a printerserver + * we send the message + */ + + if (find_printer->printer_type==PRINTER_HANDLE_IS_PRINTER) + if (strcmp(find_printer->dev.handlename, printer)) + continue; + + if (find_printer->notify.client_connected==True) + if( !cli_spoolss_reply_rrpcn(&cli, &find_printer->notify.client_hnd, PRINTER_CHANGE_ALL, 0x0, &status)) + return False; + + } +} + +/*************************************************************************** + send a notify event +****************************************************************************/ +static BOOL srv_spoolss_sendnotify(POLICY_HND *handle) +{ + fstring printer; + + Printer_entry *Printer=find_printer_index_by_hnd(handle); + + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("srv_spoolss_sendnotify: Invalid handle (%s).\n", OUR_HANDLE(handle))); + return False; + } + + if (Printer->printer_type==PRINTER_HANDLE_IS_PRINTER) + fstrcpy(printer, Printer->dev.handlename); + else + fstrcpy(printer, ""); + + srv_spoolss_receive_message(printer); +} + /******************************************************************** * spoolss_open_printer * @@ -695,6 +779,8 @@ uint32 _spoolss_deleteprinter(POLICY_HND *handle) if (!delete_printer_handle(handle)) return ERROR_INVALID_HANDLE; + + srv_spoolss_sendnotify(handle); return NT_STATUS_NO_PROBLEMO; } @@ -896,6 +982,27 @@ uint32 _spoolss_getprinterdata(POLICY_HND *handle, UNISTR2 *valuename, return NT_STATUS_NO_PROBLEMO; } +/*************************************************************************** + connect to the client +****************************************************************************/ +static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle) +{ + uint32 status; + + /* + * If it's the first connection, contact the client + * and connect to the IPC$ share anonumously + */ + if (smb_connections==0) + if(!spoolss_connect_to_client(&cli, printer+2)) /* the +2 is to strip the leading 2 backslashs */ + return False; + + smb_connections++; + + if(!cli_spoolss_reply_open_printer(&cli, printer, localprinter, type, &status, handle)) + return False; +} + /******************************************************************** * _spoolss_rffpcnex * ReplyFindFirstPrinterChangeNotifyEx @@ -926,6 +1033,12 @@ uint32 _spoolss_rffpcnex(POLICY_HND *handle, uint32 flags, uint32 options, Printer->notify.option=option; unistr2_to_ascii(Printer->notify.localmachine, localmachine, sizeof(Printer->notify.localmachine)-1); + /* connect to the client machine and send a ReplyOpenPrinter */ + if(srv_spoolss_replyopenprinter(Printer->notify.localmachine, + Printer->notify.printerlocal, 1, + &Printer->notify.client_hnd)) + Printer->notify.client_connected=True; + return NT_STATUS_NO_PROBLEMO; } @@ -3112,6 +3225,7 @@ uint32 _spoolss_startdocprinter(POLICY_HND *handle, uint32 level, Printer->document_started=True; (*jobid) = Printer->jobid; + srv_spoolss_sendnotify(handle); return 0x0; } @@ -3133,6 +3247,8 @@ uint32 _spoolss_enddocprinter(POLICY_HND *handle) print_job_end(Printer->jobid); /* error codes unhandled so far ... */ + srv_spoolss_sendnotify(handle); + return 0x0; } @@ -3182,17 +3298,20 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command, switch (command) { case PRINTER_CONTROL_PAUSE: if (print_queue_pause(&user, snum, &errcode)) { + srv_spoolss_sendnotify(handle); return 0; } break; case PRINTER_CONTROL_RESUME: case PRINTER_CONTROL_UNPAUSE: if (print_queue_resume(&user, snum, &errcode)) { + srv_spoolss_sendnotify(handle); return 0; } break; case PRINTER_CONTROL_PURGE: if (print_queue_purge(&user, snum, &errcode)) { + srv_spoolss_sendnotify(handle); return 0; } break; @@ -3449,6 +3568,8 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, done: free_a_printer(&printer, 2); + srv_spoolss_sendnotify(handle); + return result; } @@ -3495,7 +3616,11 @@ uint32 _spoolss_fcpn(POLICY_HND *handle) DEBUG(0,("_spoolss_fcpn: Invalid handle (%s)\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } - + + if (Printer->notify.client_connected==True) + if(!srv_spoolss_replycloseprinter(&Printer->notify.client_hnd)) + return ERROR_INVALID_HANDLE; + Printer->notify.flags=0; Printer->notify.options=0; Printer->notify.localmachine[0]='\0'; @@ -3504,7 +3629,8 @@ uint32 _spoolss_fcpn(POLICY_HND *handle) safe_free(Printer->notify.option->ctr.type); safe_free(Printer->notify.option); Printer->notify.option=NULL; - + Printer->notify.client_connected=False; + return NT_STATUS_NO_PROBLEMO; } @@ -3779,13 +3905,22 @@ uint32 _spoolss_setjob( POLICY_HND *handle, switch (command) { case JOB_CONTROL_CANCEL: case JOB_CONTROL_DELETE: - if (print_job_delete(&user, jobid)) return 0x0; + if (print_job_delete(&user, jobid)) { + srv_spoolss_sendnotify(handle); + return 0x0; + } break; case JOB_CONTROL_PAUSE: - if (print_job_pause(&user, jobid)) return 0x0; + if (print_job_pause(&user, jobid)) { + srv_spoolss_sendnotify(handle); + return 0x0; + } break; case JOB_CONTROL_RESUME: - if (print_job_resume(&user, jobid)) return 0x0; + if (print_job_resume(&user, jobid)) { + srv_spoolss_sendnotify(handle); + return 0x0; + } break; default: return ERROR_INVALID_LEVEL; @@ -4512,6 +4647,9 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, } free_a_printer(&printer,2); + + srv_spoolss_sendnotify(handle); + return NT_STATUS_NO_PROBLEMO; } -- cgit From 5be845af6bea3d4795dc50fe9ee880527be5ecc0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 26 Sep 2000 00:54:18 +0000 Subject: Changes from John Reilly to add a parameter "show add printer wizard" that allows Samba to turn off the display of APW (hmmm. This should probably be a share specific parameter, I'll fix that in another commit). Also a few small changes to JF's code to fix compiler warnings about missing return statements and also change '//' comments (C++) to /* .. */ comments (C). Jeremy. (This used to be commit 0a9ccc99b335650d235eb747d803d059f7828fd7) --- source3/rpc_server/srv_spoolss_nt.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2a25f615d8..821cdf30e5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -196,6 +196,8 @@ static BOOL srv_spoolss_replycloseprinter(POLICY_HND *handle) return False; smb_connections--; + + return True; } /**************************************************************************** @@ -280,7 +282,7 @@ static BOOL delete_printer_handle(POLICY_HND *hnd) DEBUGADD(10,("Unlinking output file [%s]\n", tmp_file)); unlink(tmp_file); - // Send SIGHUP to process group... is there a better way? + /* Send SIGHUP to process group... is there a better way? */ kill(0, SIGHUP); if ( ( i = lp_servicenumber( Printer->dev.handlename ) ) >= 0 ) { @@ -495,6 +497,7 @@ static BOOL open_printer_hnd(POLICY_HND *hnd, char *name) { Printer_entry *new_printer; + DEBUG(10,("open_printer_hnd: name [%s]\n", name)); clear_handle(hnd); create_printer_hnd(hnd); @@ -600,6 +603,8 @@ static BOOL srv_spoolss_receive_message(char *printer) return False; } + + return True; } /*************************************************************************** @@ -622,6 +627,8 @@ static BOOL srv_spoolss_sendnotify(POLICY_HND *handle) fstrcpy(printer, ""); srv_spoolss_receive_message(printer); + + return True; } /******************************************************************** @@ -663,6 +670,17 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, return ERROR_ACCESS_DENIED; } + /* Disallow MS AddPrinterWizard if access rights are insufficient OR + if parameter disables it. The client tries an OpenPrinterEx with + SERVER_ALL_ACCESS(0xf0003), which we force to fail. It then tries + OpenPrinterEx with SERVER_READ(0x20002) which we allow. This lets + it see any printers there, but does not show the MSAPW */ + if (handle_is_printserver(handle) && + printer_default->access_required != (SERVER_READ) && + !lp_ms_add_printer_wizard() ) { + return ERROR_ACCESS_DENIED; + } + return NT_STATUS_NO_PROBLEMO; } @@ -1001,6 +1019,8 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin if(!cli_spoolss_reply_open_printer(&cli, printer, localprinter, type, &status, handle)) return False; + + return True; } /******************************************************************** @@ -3451,11 +3471,11 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) unlink(tmp_file); if(numlines) { - // Set the portname to what the script says the portname should be + /* Set the portname to what the script says the portname should be. */ strncpy(printer->info_2->portname, qlines[0], sizeof(printer->info_2->portname)); DEBUGADD(6,("Line[0] = [%s]\n", qlines[0])); - // Send SIGHUP to process group... is there a better way? + /* Send SIGHUP to process group... is there a better way? */ kill(0, SIGHUP); add_all_printers(); } @@ -4393,7 +4413,7 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need DEBUG(10,("Returned [%d]\n", ret)); if (ret != 0) { unlink(tmp_file); - // Is this the best error to return here? + /* Is this the best error to return here? */ return ERROR_ACCESS_DENIED; } @@ -4491,7 +4511,7 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need DEBUGADD(10,("returned [%d]\n", ret)); if (ret != 0) { unlink(tmp_file); - // Is this the best error to return here? + /* Is this the best error to return here? */ return ERROR_ACCESS_DENIED; } -- cgit From 56917236a0414a03fb4ec193243c5de123bd3aa5 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 26 Sep 2000 10:15:12 +0000 Subject: broadcast printer notify message to all clients. We now have printer notification as on NT. Andrew, your message passing code is cool :-) J.F. (This used to be commit 0374bc4b5f56d0fab3f7310e13cb71b5a71f9112) --- source3/rpc_server/srv_spoolss_nt.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 821cdf30e5..86fa0d108d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -191,10 +191,13 @@ static BOOL srv_spoolss_replycloseprinter(POLICY_HND *handle) return False; /* if it's the last connection, deconnect the IPC$ share */ - if (smb_connections==1) + if (smb_connections==1) { if(!spoolss_disconnect_from_client(&cli)) return False; + message_deregister(MSG_PRINTER_NOTIFY); + } + smb_connections--; return True; @@ -579,11 +582,14 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) /*************************************************************************** receive the notify message ****************************************************************************/ -static BOOL srv_spoolss_receive_message(char *printer) +void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) { + char printer[256]; uint32 status; Printer_entry *find_printer; + memcpy(printer, buf, len); + find_printer = (Printer_entry *)ubi_dlFirst(&Printer_list); /* Iterate the printer list. */ @@ -599,12 +605,9 @@ static BOOL srv_spoolss_receive_message(char *printer) continue; if (find_printer->notify.client_connected==True) - if( !cli_spoolss_reply_rrpcn(&cli, &find_printer->notify.client_hnd, PRINTER_CHANGE_ALL, 0x0, &status)) - return False; + cli_spoolss_reply_rrpcn(&cli, &find_printer->notify.client_hnd, PRINTER_CHANGE_ALL, 0x0, &status); } - - return True; } /*************************************************************************** @@ -626,7 +629,8 @@ static BOOL srv_spoolss_sendnotify(POLICY_HND *handle) else fstrcpy(printer, ""); - srv_spoolss_receive_message(printer); + /*srv_spoolss_receive_message(printer);*/ + message_send_all(MSG_PRINTER_NOTIFY, printer, strlen(printer)); return True; } @@ -1011,9 +1015,12 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin * If it's the first connection, contact the client * and connect to the IPC$ share anonumously */ - if (smb_connections==0) + if (smb_connections==0) { if(!spoolss_connect_to_client(&cli, printer+2)) /* the +2 is to strip the leading 2 backslashs */ return False; + message_register(MSG_PRINTER_NOTIFY, srv_spoolss_receive_message); + + } smb_connections++; -- cgit From 8c93ddf3e0ea80d482cbee7bf233c32fc69955bb Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Wed, 27 Sep 2000 13:02:57 +0000 Subject: samr unknown 0x32 is in fact samr create user. so renamed and tidy up of the server function. J.F. (This used to be commit 0f707ac1fb5685b800d6599b9074ec1d4e65b1c1) --- source3/rpc_server/srv_samr.c | 77 ++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 49 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 95c3e7c6ca..ab32bfe563 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1827,54 +1827,24 @@ static BOOL api_samr_query_dom_info(pipes_struct *p) } /******************************************************************* - samr_reply_unknown_32 + api_samr_create_user ********************************************************************/ -static BOOL samr_reply_unknown_32(SAMR_Q_UNKNOWN_32 *q_u, - prs_struct *rdata, - int status) -{ - int i; - SAMR_R_UNKNOWN_32 r_u; - - /* set up the SAMR unknown_32 response */ - memset((char *)r_u.pol.data, '\0', POL_HND_SIZE); - if (status == 0) - { - for (i = 4; i < POL_HND_SIZE; i++) - { - r_u.pol.data[i] = i+1; - } - } - - init_dom_rid4(&(r_u.rid4), 0x0030, 0, 0); - r_u.status = status; - - DEBUG(5,("samr_unknown_32: %d\n", __LINE__)); - - /* store the response in the SMB stream */ - if(!samr_io_r_unknown_32("", &r_u, rdata, 0)) - return False; - - DEBUG(5,("samr_unknown_32: %d\n", __LINE__)); - - return True; -} - -/******************************************************************* - api_samr_unknown_32 - ********************************************************************/ -static BOOL api_samr_unknown_32(pipes_struct *p) +static BOOL api_samr_create_user(pipes_struct *p) { uint32 status = 0; struct sam_passwd *sam_pass; fstring mach_acct; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + int i; - SAMR_Q_UNKNOWN_32 q_u; + SAMR_Q_CREATE_USER q_u; + SAMR_R_CREATE_USER r_u; - /* grab the samr unknown 32 */ - samr_io_q_unknown_32("", &q_u, data, 0); + DEBUG(5,("api_samr_create_user: %d\n", __LINE__)); + + /* grab the samr create user */ + samr_io_q_create_user("", &q_u, data, 0); /* find the machine account: tell the caller if it exists. lkclXXXX i have *no* idea if this is a problem or not @@ -1882,29 +1852,38 @@ static BOOL api_samr_unknown_32(pipes_struct *p) reply if the account already exists... */ - fstrcpy(mach_acct, dos_unistrn2(q_u.uni_mach_acct.buffer, - q_u.uni_mach_acct.uni_str_len)); + fstrcpy(mach_acct, dos_unistrn2(q_u.uni_mach_acct.buffer, q_u.uni_mach_acct.uni_str_len)); become_root(); sam_pass = getsam21pwnam(mach_acct); unbecome_root(); - if (sam_pass != NULL) - { + if (sam_pass != NULL) { /* machine account exists: say so */ status = 0xC0000000 | NT_STATUS_USER_EXISTS; - } - else - { + } else { /* this could cause trouble... */ DEBUG(0,("trouble!\n")); status = 0; } - /* construct reply. */ - if(!samr_reply_unknown_32(&q_u, rdata, status)) + /* set up the SAMR create_user response */ + memset((char *)r_u.pol.data, '\0', POL_HND_SIZE); + if (status == 0) { + for (i = 4; i < POL_HND_SIZE; i++) { + r_u.pol.data[i] = i+1; + } + } + + init_dom_rid4(&(r_u.rid4), 0x0030, 0, 0); + r_u.status = status; + + /* store the response in the SMB stream */ + if(!samr_io_r_create_user("", &r_u, rdata, 0)) return False; + DEBUG(5,("api_samr_create_user: %d\n", __LINE__)); + return True; } @@ -2197,7 +2176,7 @@ static struct api_struct api_samr_cmds [] = { "SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, { "SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, { "SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, - { "SAMR_0x32" , 0x32 , api_samr_unknown_32 }, + { "SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user }, { "SAMR_UNKNOWN_12" , SAMR_UNKNOWN_12 , api_samr_unknown_12 }, { "SAMR_UNKNOWN_38" , SAMR_UNKNOWN_38 , api_samr_unknown_38 }, { "SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, -- cgit From efe9922b43ab3c0d89f55749389a7ec49bc8bd62 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 27 Sep 2000 21:57:38 +0000 Subject: Fixed stupid introduced bug found by "Jim McDonough/Boulder/IBM" . Jeremy. (This used to be commit 563f8b09a810446c658bf58303b5fe998d27bec9) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 86fa0d108d..c281ccaacc 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3181,10 +3181,10 @@ uint32 _spoolss_endpageprinter(POLICY_HND *handle) static struct current_user *get_current_user(struct current_user *user, pipes_struct *p) { if (p->ntlmssp_auth_validated) { - memcpy(user, &p->pipe_user, sizeof(user)); + memcpy(user, &p->pipe_user, sizeof(struct current_user)); } else { extern struct current_user current_user; - memcpy(user, ¤t_user, sizeof(user)); + memcpy(user, ¤t_user, sizeof(struct current_user)); } return user; -- cgit From b06d83c909e0587accf93e090c62395ff8b1bb87 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Thu, 28 Sep 2000 17:35:03 +0000 Subject: fixed samr_create_user(). we now correctly parse the query and the reply. And we create the disabled account. That means we can create user and trust accounts remotely ! ifdef out a return in passdb/smbpass.c. I think I didn't break any security. Jeremy could you check if I didn't make any mistakes ??? J.F. (This used to be commit 416be1b64f366c8b859f25856fce2467ec0446d9) --- source3/rpc_server/srv_samr.c | 71 +++++++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index ab32bfe563..2ef29df990 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1826,26 +1826,38 @@ static BOOL api_samr_query_dom_info(pipes_struct *p) return True; } + /******************************************************************* api_samr_create_user ********************************************************************/ static BOOL api_samr_create_user(pipes_struct *p) { - uint32 status = 0; struct sam_passwd *sam_pass; fstring mach_acct; + pstring err_str; + pstring msg_str; + int local_flags=0; + prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - int i; SAMR_Q_CREATE_USER q_u; SAMR_R_CREATE_USER r_u; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + DEBUG(5,("api_samr_create_user: %d\n", __LINE__)); /* grab the samr create user */ samr_io_q_create_user("", &q_u, data, 0); + /* find the policy handle. open a policy on it. */ + if ((find_lsa_policy_by_hnd(&q_u.pol) == -1)) { + r_u.status = NT_STATUS_INVALID_HANDLE; + goto out; + } + /* 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 @@ -1853,31 +1865,58 @@ static BOOL api_samr_create_user(pipes_struct *p) */ fstrcpy(mach_acct, dos_unistrn2(q_u.uni_mach_acct.buffer, q_u.uni_mach_acct.uni_str_len)); + strlower(mach_acct); become_root(); sam_pass = getsam21pwnam(mach_acct); unbecome_root(); - if (sam_pass != NULL) { /* machine account exists: say so */ - status = 0xC0000000 | NT_STATUS_USER_EXISTS; - } else { - /* this could cause trouble... */ - DEBUG(0,("trouble!\n")); - status = 0; + r_u.status = NT_STATUS_USER_EXISTS; + goto out; } - /* set up the SAMR create_user response */ - memset((char *)r_u.pol.data, '\0', POL_HND_SIZE); - if (status == 0) { - for (i = 4; i < POL_HND_SIZE; i++) { - r_u.pol.data[i] = i+1; - } + /* get a (unique) handle. open a policy on it. */ + if (!open_lsa_policy_hnd(&r_u.pol)) { + r_u.status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + goto out; + } + + local_flags=LOCAL_ADD_USER|LOCAL_DISABLE_USER|LOCAL_SET_NO_PASSWORD; + local_flags|= (q_u.acb_info & ACB_WSTRUST) ? LOCAL_TRUST_ACCOUNT:0; + + 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)); + r_u.status = NT_STATUS_ACCESS_DENIED; + close_lsa_policy_hnd(&r_u.pol); + memset((char *)r_u.pol.data, '\0', POL_HND_SIZE); + goto out; + } + + become_root(); + sam_pass = getsam21pwnam(mach_acct); + unbecome_root(); + if (sam_pass == NULL) { + /* account doesn't exist: say so */ + r_u.status = NT_STATUS_ACCESS_DENIED; + close_lsa_policy_hnd(&r_u.pol); + memset((char *)r_u.pol.data, '\0', POL_HND_SIZE); + goto out; + } + + /* associate the RID with the (unique) handle. */ + if (!set_lsa_policy_samr_rid(&r_u.pol, sam_pass->user_rid)) { + /* oh, whoops. don't know what error message to return, here */ + r_u.status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + close_lsa_policy_hnd(&r_u.pol); + memset((char *)r_u.pol.data, '\0', POL_HND_SIZE); + goto out; } - init_dom_rid4(&(r_u.rid4), 0x0030, 0, 0); - r_u.status = status; + r_u.unknown_0=0x000703ff; + r_u.user_rid=sam_pass->user_rid; + out: /* store the response in the SMB stream */ if(!samr_io_r_create_user("", &r_u, rdata, 0)) return False; -- cgit From d6a73c3aaeca61dad455c2939ffb048c7670ae7c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 28 Sep 2000 20:36:28 +0000 Subject: Added comment on JF's new code. Removed ifdef in passdb/smbpass.c as this was not correct. Jeremy. (This used to be commit 1a3f7ecde2ca031b2f93a079f75822354fe241a0) --- source3/rpc_server/srv_samr.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 2ef29df990..e3425f3247 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1850,7 +1850,10 @@ static BOOL api_samr_create_user(pipes_struct *p) DEBUG(5,("api_samr_create_user: %d\n", __LINE__)); /* grab the samr create user */ - samr_io_q_create_user("", &q_u, data, 0); + if (!samr_io_q_create_user("", &q_u, data, 0)) { + DEBUG(0,("api_samr_create_user: Unable to unmarshall SAMR_Q_CREATE_USER.\n")); + return False; + } /* find the policy handle. open a policy on it. */ if ((find_lsa_policy_by_hnd(&q_u.pol) == -1)) { @@ -1885,6 +1888,13 @@ static BOOL api_samr_create_user(pipes_struct *p) local_flags=LOCAL_ADD_USER|LOCAL_DISABLE_USER|LOCAL_SET_NO_PASSWORD; local_flags|= (q_u.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. + */ + 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)); r_u.status = NT_STATUS_ACCESS_DENIED; -- cgit From 7de0b5588e855a967f0a5094c515b955ff4a23cf Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 29 Sep 2000 21:15:45 +0000 Subject: Missing null termination on printer changenotify message caused insure error. Jeremy. (This used to be commit 3733d29ce678c71ef2ee8b600e547765d8d8ea9e) --- source3/rpc_server/srv_spoolss_nt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c281ccaacc..8996389039 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -584,11 +584,12 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) ****************************************************************************/ void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) { - char printer[256]; + fstring printer; uint32 status; Printer_entry *find_printer; - memcpy(printer, buf, len); + *printer = '\0'; + fstrcpy(printer,buf); find_printer = (Printer_entry *)ubi_dlFirst(&Printer_list); @@ -630,7 +631,7 @@ static BOOL srv_spoolss_sendnotify(POLICY_HND *handle) fstrcpy(printer, ""); /*srv_spoolss_receive_message(printer);*/ - message_send_all(MSG_PRINTER_NOTIFY, printer, strlen(printer)); + message_send_all(MSG_PRINTER_NOTIFY, printer, strlen(printer) + 1); /* Null terminate... */ return True; } -- cgit From e26d09685cf4aff2256adccf9b576d48fe52cc89 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 2 Oct 2000 19:28:26 +0000 Subject: Added debug so if zero length messages get sent we successfully remove them (this can happen if smbd processes are shut down at the wrong time). Jeremy. (This used to be commit c1de97f96b8c5ad8e5f01a0d17c6387733769442) --- source3/rpc_server/srv_spoolss_nt.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8996389039..6e222b2386 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -591,6 +591,13 @@ void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) *printer = '\0'; fstrcpy(printer,buf); + if (len == 0) { + DEBUG(0,("srv_spoolss_receive_message: got null message !\n")); + return; + } + + DEBUG(10,("srv_spoolss_receive_message: Got message about printer %s\n", printer )); + find_printer = (Printer_entry *)ubi_dlFirst(&Printer_list); /* Iterate the printer list. */ @@ -631,6 +638,8 @@ static BOOL srv_spoolss_sendnotify(POLICY_HND *handle) fstrcpy(printer, ""); /*srv_spoolss_receive_message(printer);*/ + DEBUG(10,("srv_spoolss_sendnotify: Sending message about printer %s\n", printer )); + message_send_all(MSG_PRINTER_NOTIFY, printer, strlen(printer) + 1); /* Null terminate... */ return True; -- cgit From c5ca95aeb1202c64bf37c8031c83d5c59c990ce3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 3 Oct 2000 18:29:12 +0000 Subject: Fixes from Herb - compiler warnings. Jeremy. (This used to be commit d9d3668fa322cbed36ca3393d8268bf0e5255e8d) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 6e222b2386..717ee1bed1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3096,7 +3096,7 @@ static uint32 getprinterdriver2_level6(fstring servername, fstring architecture, *needed += spoolss_size_printer_driver_info_6(&info); if (!alloc_buffer_size(buffer, *needed)) { - free_printer_driver_info_3(&info); + free_printer_driver_info_6(&info); return ERROR_INSUFFICIENT_BUFFER; } -- cgit From 23f78fd7b91878176c518471cdca84cad826cba9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 4 Oct 2000 01:03:23 +0000 Subject: Adding Herb's compile warning fixes to HEAD. Jeremy. (This used to be commit d131ad1ce3f6e72e295f865a463f8dcbfa6f8d42) --- source3/rpc_server/srv_lsa.c | 2 +- source3/rpc_server/srv_samr.c | 4 ++-- source3/rpc_server/srv_spoolss_nt.c | 45 ------------------------------------- 3 files changed, 3 insertions(+), 48 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index a7abc614e3..9c3d785627 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -298,7 +298,7 @@ static void init_lsa_trans_names(DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, uint32 rid = 0xffffffff; int dom_idx = -1; fstring name, dom_name; - enum SID_NAME_USE sid_name_use = 0; + enum SID_NAME_USE sid_name_use = (enum SID_NAME_USE)0; /* Lookup sid from winbindd */ diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index e3425f3247..7891fc16dc 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -966,7 +966,7 @@ static BOOL samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_R_QUERY_ALIASINFO r_e; fstring alias_desc = "Local Unix group"; fstring alias=""; - uint8 type; + enum SID_NAME_USE type; uint32 alias_rid; ZERO_STRUCT(r_e); @@ -1112,7 +1112,7 @@ static BOOL samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, prs_struct *rdata) { uint32 rid[MAX_SAM_ENTRIES]; - uint8 type[MAX_SAM_ENTRIES]; + enum SID_NAME_USE type[MAX_SAM_ENTRIES]; uint32 status = 0; int i; int num_rids = q_u->num_names1; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 717ee1bed1..c32ca8d871 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -318,10 +318,8 @@ static BOOL get_printer_snum(POLICY_HND *hnd, int *number) return (*number != -1); case PRINTER_HANDLE_IS_PRINTSERVER: return False; - break; default: return False; - break; } } @@ -1459,7 +1457,6 @@ static uint32 size_of_notify_info_data(uint16 type, uint16 field) (notify_info_data_table[i].field == field ) ) { return (notify_info_data_table[i].size); - continue; } i++; } @@ -1486,7 +1483,6 @@ static BOOL type_of_notify_info_data(uint16 type, uint16 field) { return (True); } - continue; } i++; } @@ -1796,10 +1792,8 @@ uint32 _spoolss_rfnpcnex( POLICY_HND *handle, uint32 change, switch (Printer->printer_type) { case PRINTER_HANDLE_IS_PRINTSERVER: return printserver_notify_info(handle, info); - break; case PRINTER_HANDLE_IS_PRINTER: return printer_notify_info(handle, info); - break; } return ERROR_INVALID_HANDLE; @@ -2503,18 +2497,14 @@ uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 le switch (level) { case 1: return enumprinters_level1(flags, name, buffer, offered, needed, returned); - break; case 2: return enumprinters_level2(flags, name, buffer, offered, needed, returned); - break; case 5: return enumprinters_level5(flags, name, buffer, offered, needed, returned); - break; case 3: case 4: default: return ERROR_INVALID_LEVEL; - break; } } @@ -2679,7 +2669,6 @@ uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, return getprinter_level_3(servername,snum, buffer, offered, needed); default: return ERROR_INVALID_LEVEL; - break; } } @@ -3137,19 +3126,14 @@ uint32 _spoolss_getprinterdriver2(POLICY_HND *handle, const UNISTR2 *uni_arch, u switch (level) { case 1: return getprinterdriver2_level1(servername, architecture, clientmajorversion, snum, buffer, offered, needed); - break; case 2: return getprinterdriver2_level2(servername, architecture, clientmajorversion, snum, buffer, offered, needed); - break; case 3: return getprinterdriver2_level3(servername, architecture, clientmajorversion, snum, buffer, offered, needed); - break; case 6: return getprinterdriver2_level6(servername, architecture, clientmajorversion, snum, buffer, offered, needed); - break; default: return ERROR_INVALID_LEVEL; - break; } } @@ -3629,17 +3613,13 @@ uint32 _spoolss_setprinter(POLICY_HND *handle, uint32 level, switch (level) { case 0: return control_printer(handle, command, p); - break; case 2: return update_printer(handle, level, info, devmode_ctr.devmode); - break; case 3: return update_printer_sec(handle, level, info, p, secdesc_ctr); - break; default: return ERROR_INVALID_LEVEL; - break; } } @@ -3893,15 +3873,12 @@ uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, switch (level) { case 1: return enumjobs_level1(queue, snum, buffer, offered, needed, returned); - break; case 2: return enumjobs_level2(queue, snum, buffer, offered, needed, returned); - break; default: safe_free(queue); *returned=0; return ERROR_INVALID_LEVEL; - break; } } @@ -4217,18 +4194,14 @@ uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32 switch (level) { case 1: return enumprinterdrivers_level1(servername, architecture, buffer, offered, needed, returned); - break; case 2: return enumprinterdrivers_level2(servername, architecture, buffer, offered, needed, returned); - break; case 3: return enumprinterdrivers_level3(servername, architecture, buffer, offered, needed, returned); - break; default: *returned=0; safe_free(list); return ERROR_INVALID_LEVEL; - break; } } @@ -4609,13 +4582,10 @@ uint32 _spoolss_enumports( UNISTR2 *name, uint32 level, switch (level) { case 1: return enumports_level_1(buffer, offered, needed, returned); - break; case 2: return enumports_level_2(buffer, offered, needed, returned); - break; default: return ERROR_INVALID_LEVEL; - break; } } @@ -4703,15 +4673,12 @@ uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level, /* we don't handle yet */ /* but I know what to do ... */ return ERROR_INVALID_LEVEL; - break; case 2: return spoolss_addprinterex_level_2(uni_srv_name, info, unk0, unk1, unk2, unk3, user_switch, user, handle); - break; default: return ERROR_INVALID_LEVEL; - break; } } @@ -4810,10 +4777,8 @@ uint32 _spoolss_getprinterdriverdirectory(UNISTR2 *name, UNISTR2 *uni_environmen switch(level) { case 1: return getprinterdriverdir_level_1(name, uni_environment, buffer, offered, needed); - break; default: return ERROR_INVALID_LEVEL; - break; } } @@ -5198,10 +5163,8 @@ uint32 _spoolss_enumprintprocessors(UNISTR2 *name, UNISTR2 *environment, uint32 switch (level) { case 1: return enumprintprocessors_level_1(buffer, offered, needed, returned); - break; default: return ERROR_INVALID_LEVEL; - break; } } @@ -5250,10 +5213,8 @@ uint32 _spoolss_enumprintprocdatatypes(UNISTR2 *name, UNISTR2 *processor, uint32 switch (level) { case 1: return enumprintprocdatatypes_level_1(buffer, offered, needed, returned); - break; default: return ERROR_INVALID_LEVEL; - break; } } @@ -5342,13 +5303,10 @@ uint32 _spoolss_enumprintmonitors(UNISTR2 *name,uint32 level, switch (level) { case 1: return enumprintmonitors_level_1(buffer, offered, needed, returned); - break; case 2: return enumprintmonitors_level_2(buffer, offered, needed, returned); - break; default: return ERROR_INVALID_LEVEL; - break; } } @@ -5479,14 +5437,11 @@ uint32 _spoolss_getjob( POLICY_HND *handle, uint32 jobid, uint32 level, switch (level) { case 1: return getjob_level_1(queue, count, snum, jobid, buffer, offered, needed); - break; case 2: return getjob_level_2(queue, count, snum, jobid, buffer, offered, needed); - break; default: safe_free(queue); return ERROR_INVALID_LEVEL; - break; } } #undef OLD_NTDOMAIN -- cgit From ba00796e6dd13b87b7988a98e532676d9eab702c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 6 Oct 2000 18:13:52 +0000 Subject: Herb's warning fixes. Also the POSIX locking fix. We now use our own vfs layer to do get/set acl calls (hurrah!). Jeremy. (This used to be commit dfe77c7046cbd65ee52aea7439f21503c1eac41d) --- source3/rpc_server/srv_spoolss_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c32ca8d871..5a724d6ab6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -358,16 +358,14 @@ static BOOL set_printer_hnd_printertype(Printer_entry *Printer, char *handlename if (!strchr(handlename+2, '\\')) { DEBUGADD(4,("Printer is a print server\n")); Printer->printer_type = PRINTER_HANDLE_IS_PRINTSERVER; - return True; } /* it's a printer */ else { DEBUGADD(4,("Printer is a printer\n")); Printer->printer_type = PRINTER_HANDLE_IS_PRINTER; - return True; } - return False; + return True; } /**************************************************************************** -- cgit From 1126775808f434c3df4089159512988df82cbdd5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 6 Oct 2000 20:03:17 +0000 Subject: Proto update. Also fix from John Reilly @ HP for not showing APW with W2K. Jeremy. (This used to be commit 698288cb9de316527c0c2a271e18c920578f9930) --- source3/rpc_server/srv_spoolss_nt.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5a724d6ab6..56de5375fb 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -680,14 +680,21 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, return ERROR_ACCESS_DENIED; } - /* Disallow MS AddPrinterWizard if access rights are insufficient OR - if parameter disables it. The client tries an OpenPrinterEx with - SERVER_ALL_ACCESS(0xf0003), which we force to fail. It then tries - OpenPrinterEx with SERVER_READ(0x20002) which we allow. This lets - it see any printers there, but does not show the MSAPW */ + /* Disallow MS AddPrinterWizard if parameter disables it. A Win2k + client 1st tries an OpenPrinterEx with access==0, MUST be allowed. + Then both Win2k and WinNT clients try an OpenPrinterEx with + SERVER_ALL_ACCESS, which we force to fail. Then they try + OpenPrinterEx with SERVER_READ which we allow. This lets the + client view printer folder, but does not show the MSAPW. + + Note: this test needs code to check access rights here too. Jeremy + could you look at this? */ + if (handle_is_printserver(handle) && - printer_default->access_required != (SERVER_READ) && - !lp_ms_add_printer_wizard() ) { + !lp_ms_add_printer_wizard()) { + if (printer_default->access_required == 0) + return NT_STATUS_NO_PROBLEMO; + else if (printer_default->access_required != (SERVER_READ)) return ERROR_ACCESS_DENIED; } -- cgit From 75c346e70c83f7386ecd2f10fe155c4a4dfd47de Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Sat, 7 Oct 2000 15:56:36 +0000 Subject: added samr_set_user_info and info_2. cleanup of create_user cleanup of rid/sid mix in samr. now we only have sid. some prs_align() missing in parse_samr.c a small debug change in srv_pipe.c You still can't change a user's password in this commit. Will be availble in the next one. J.F. (This used to be commit b655bc281fa183b1827a946ada1fcf500fb93aea) --- source3/rpc_server/srv_lsa_hnd.c | 31 +- source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_samr.c | 687 +++++++++++++++++++++++++++++---------- 3 files changed, 522 insertions(+), 198 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 5670178732..0782c8c4b2 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -32,16 +32,15 @@ extern int DEBUGLEVEL; struct reg_info { - /* for use by \PIPE\winreg */ + /* for use by \PIPE\winreg */ fstring name; /* name of registry key */ }; struct samr_info { - /* for use by the \PIPE\samr policy */ + /* for use by the \PIPE\samr policy */ DOM_SID sid; - uint32 rid; /* relative id associated with the pol_hnd */ - uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ + uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ }; static struct policy @@ -162,25 +161,6 @@ int find_lsa_policy_by_hnd(POLICY_HND *hnd) return p?p->pnum:-1; } -/**************************************************************************** - set samr rid -****************************************************************************/ -BOOL set_lsa_policy_samr_rid(POLICY_HND *hnd, uint32 rid) -{ - struct policy *p = find_lsa_policy(hnd); - - if (p && p->open) { - DEBUG(3,("Setting policy device rid=%x pnum=%x\n", - rid, p->pnum)); - - p->dev.samr.rid = rid; - return True; - } - - DEBUG(3,("Error setting policy rid=%x\n",rid)); - return False; -} - /**************************************************************************** set samr pol status. absolutely no idea what this is. @@ -230,8 +210,7 @@ BOOL get_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) { struct policy *p = find_lsa_policy(hnd); - if (p != NULL && p->open) - { + if (p != NULL && p->open) { fstring sidstr; memcpy(sid, &p->dev.samr.sid, sizeof(*sid)); DEBUG(3,("Getting policy sid=%s pnum=%x\n", @@ -252,7 +231,7 @@ uint32 get_lsa_policy_samr_rid(POLICY_HND *hnd) struct policy *p = find_lsa_policy(hnd); if (p && p->open) { - uint32 rid = p->dev.samr.rid; + uint32 rid = p->dev.samr.sid.sub_auths[p->dev.samr.sid.num_auths-1]; DEBUG(3,("Getting policy device rid=%x pnum=%x\n", rid, p->pnum)); diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 44bca13c1a..01d9568477 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1195,7 +1195,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, /* do the actual command */ if(!api_rpc_cmds[fn_num].fn(p)) { - DEBUG(0,("api_rpcTNP: %s: failed.\n", rpc_name)); + DEBUG(0,("api_rpcTNP: %s: %s failed.\n", rpc_name, api_rpc_cmds[fn_num].name)); prs_mem_free(&p->out_data.rdata); return False; } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 7891fc16dc..59a541abd9 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1306,9 +1306,9 @@ static BOOL api_samr_unknown_38(pipes_struct *p) /******************************************************************* - samr_reply_unknown_12 + samr_reply_lookup_rids ********************************************************************/ -static BOOL samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, +static BOOL samr_reply_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u, prs_struct *rdata) { fstring group_names[MAX_SAM_ENTRIES]; @@ -1316,9 +1316,9 @@ static BOOL samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, uint32 status = 0; int num_gids = q_u->num_gids1; - SAMR_R_UNKNOWN_12 r_u; + SAMR_R_LOOKUP_RIDS r_u; - DEBUG(5,("samr_unknown_12: %d\n", __LINE__)); + DEBUG(5,("samr_reply_lookup_rids: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) @@ -1332,7 +1332,7 @@ static BOOL samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, if (num_gids > MAX_SAM_ENTRIES) { num_gids = MAX_SAM_ENTRIES; - DEBUG(5,("samr_unknown_12: truncating entries to %d\n", num_gids)); + DEBUG(5,("samr_reply_lookup_rids: truncating entries to %d\n", num_gids)); } for (i = 0; i < num_gids && status == 0; i++) @@ -1342,32 +1342,32 @@ static BOOL samr_reply_unknown_12(SAMR_Q_UNKNOWN_12 *q_u, } } - init_samr_r_unknown_12(&r_u, num_gids, group_names, group_attrs, status); + init_samr_r_lookup_rids(&r_u, num_gids, group_names, group_attrs, status); /* store the response in the SMB stream */ - if(!samr_io_r_unknown_12("", &r_u, rdata, 0)) + if(!samr_io_r_lookup_rids("", &r_u, rdata, 0)) return False; - DEBUG(5,("samr_unknown_12: %d\n", __LINE__)); + DEBUG(5,("samr_reply_lookup_rids: %d\n", __LINE__)); return True; } /******************************************************************* - api_samr_unknown_12 + api_samr_lookup_rids ********************************************************************/ -static BOOL api_samr_unknown_12(pipes_struct *p) +static BOOL api_samr_lookup_rids(pipes_struct *p) { - SAMR_Q_UNKNOWN_12 q_u; + SAMR_Q_LOOKUP_RIDS q_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; /* grab the samr lookup names */ - if(!samr_io_q_unknown_12("", &q_u, data, 0)) + if(!samr_io_q_lookup_rids("", &q_u, data, 0)) return False; /* construct reply. always indicate success */ - if(!samr_reply_unknown_12(&q_u, rdata)) + if(!samr_reply_lookup_rids(&q_u, rdata)) return False; return True; @@ -1375,62 +1375,51 @@ static BOOL api_samr_unknown_12(pipes_struct *p) /******************************************************************* - samr_reply_open_user + _api_samr_open_user ********************************************************************/ -static BOOL samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, prs_struct *rdata, int status) +static uint32 _api_samr_open_user(POLICY_HND domain_pol, uint32 user_rid, POLICY_HND *user_pol) { - SAMR_R_OPEN_USER r_u; struct sam_passwd *sam_pass; - BOOL pol_open = False; - - /* set up the SAMR open_user response */ - memset((char *)r_u.user_pol.data, '\0', POL_HND_SIZE); + DOM_SID sid; - r_u.status = 0x0; - - /* find the policy handle. open a policy on it. */ - if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->domain_pol)) == -1)) - { - r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } + /* find the domain policy handle. */ + if (find_lsa_policy_by_hnd(&domain_pol) == -1) + return NT_STATUS_INVALID_HANDLE; /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.user_pol)))) - { - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } + if (!open_lsa_policy_hnd(user_pol)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; become_root(); - sam_pass = getsam21pwrid(q_u->user_rid); + sam_pass = getsam21pwrid(user_rid); unbecome_root(); /* check that the RID exists in our domain. */ - if (r_u.status == 0x0 && sam_pass == NULL) - { - r_u.status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + if (sam_pass == NULL) { + close_lsa_policy_hnd(user_pol); + return NT_STATUS_NO_SUCH_USER; } - - /* associate the RID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_lsa_policy_samr_rid(&(r_u.user_pol), q_u->user_rid)) - { - /* oh, whoops. don't know what error message to return, here */ - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + + /* Get the domain SID stored in the domain policy */ + if(!get_lsa_policy_samr_sid(&domain_pol, &sid)) { + close_lsa_policy_hnd(user_pol); + return NT_STATUS_INVALID_HANDLE; } - if (r_u.status != 0 && pol_open) - { - close_lsa_policy_hnd(&(r_u.user_pol)); + /* append the user's RID to it */ + if(!sid_append_rid(&sid, user_rid)) { + close_lsa_policy_hnd(user_pol); + return NT_STATUS_NO_SUCH_USER; } - DEBUG(5,("samr_open_user: %d\n", __LINE__)); - - /* store the response in the SMB stream */ - if(!samr_io_r_open_user("", &r_u, rdata, 0)) - return False; - - DEBUG(5,("samr_open_user: %d\n", __LINE__)); + /* associate the user's SID with the handle. */ + if (!set_lsa_policy_samr_sid(user_pol, &sid)) { + /* oh, whoops. don't know what error message to return, here */ + close_lsa_policy_hnd(user_pol); + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } - return True; + return NT_STATUS_NO_PROBLEMO; } /******************************************************************* @@ -1439,21 +1428,28 @@ static BOOL samr_reply_open_user(SAMR_Q_OPEN_USER *q_u, prs_struct *rdata, int s static BOOL api_samr_open_user(pipes_struct *p) { SAMR_Q_OPEN_USER q_u; + SAMR_R_OPEN_USER r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + /* grab the samr unknown 22 */ if(!samr_io_q_open_user("", &q_u, data, 0)) return False; - /* construct reply. always indicate success */ - if(!samr_reply_open_user(&q_u, rdata, 0x0)) + r_u.status = _api_samr_open_user(q_u.domain_pol, q_u.user_rid, &r_u.user_pol); + + /* store the response in the SMB stream */ + if(!samr_io_r_open_user("", &r_u, rdata, 0)) return False; + DEBUG(5,("samr_open_user: %d\n", __LINE__)); + return True; } - /************************************************************************* get_user_info_10 *************************************************************************/ @@ -1753,45 +1749,64 @@ static BOOL api_samr_query_usergroups(pipes_struct *p) /******************************************************************* - samr_reply_query_dom_info + api_samr_query_dom_info ********************************************************************/ -static BOOL samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, prs_struct *rdata) +static BOOL api_samr_query_dom_info(pipes_struct *p) { + SAMR_Q_QUERY_DOMAIN_INFO q_u; SAMR_R_QUERY_DOMAIN_INFO r_u; SAM_UNK_CTR ctr; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + uint16 switch_value = 0x0; uint32 status = 0x0; + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); ZERO_STRUCT(ctr); - r_u.ctr = &ctr; + DEBUG(5,("api_samr_query_dom_info: %d\n", __LINE__)); - DEBUG(5,("samr_reply_query_dom_info: %d\n", __LINE__)); + /* grab the samr unknown 8 command */ + if(!samr_io_q_query_dom_info("", &q_u, data, 0)) + return False; /* find the policy handle. open a policy on it. */ - if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->domain_pol)) == -1)) - { - r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - DEBUG(5,("samr_reply_query_dom_info: invalid handle\n")); + if (find_lsa_policy_by_hnd(&q_u.domain_pol) == -1) { + status = NT_STATUS_INVALID_HANDLE; + DEBUG(5,("api_samr_query_dom_info: invalid handle\n")); } - if (status == 0x0) - { - switch (q_u->switch_value) - { + if (status == 0x0) { + switch (q_u.switch_value) { + case 0x01: + switch_value = 0x1; + init_unk_info1(&ctr.info.inf1); + break; case 0x02: - { switch_value = 0x2; init_unk_info2(&ctr.info.inf2, global_myworkgroup, global_myname); - break; - } + case 0x03: + switch_value = 0x3; + init_unk_info3(&ctr.info.inf3); + break; + case 0x06: + switch_value = 0x6; + init_unk_info6(&ctr.info.inf6); + break; + case 0x07: + switch_value = 0x7; + init_unk_info7(&ctr.info.inf7); + break; + case 0x0c: + switch_value = 0xc; + init_unk_info12(&ctr.info.inf12); + break; default: - { - status = 0xC0000000 | NT_STATUS_INVALID_INFO_CLASS; + status = NT_STATUS_INVALID_INFO_CLASS; break; - } } } @@ -1801,65 +1816,28 @@ static BOOL samr_reply_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO *q_u, prs_struct if(!samr_io_r_query_dom_info("", &r_u, rdata, 0)) return False; - DEBUG(5,("samr_query_dom_info: %d\n", __LINE__)); - - return True; -} - -/******************************************************************* - api_samr_query_dom_info - ********************************************************************/ -static BOOL api_samr_query_dom_info(pipes_struct *p) -{ - SAMR_Q_QUERY_DOMAIN_INFO q_e; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - /* grab the samr unknown 8 command */ - if(!samr_io_q_query_dom_info("", &q_e, data, 0)) - return False; - - /* construct reply. */ - if(!samr_reply_query_dom_info(&q_e, rdata)) - return False; + DEBUG(5,("api_samr_query_dom_info: %d\n", __LINE__)); return True; } /******************************************************************* - api_samr_create_user + _api_samr_create_user ********************************************************************/ -static BOOL api_samr_create_user(pipes_struct *p) +static BOOL _api_samr_create_user(POLICY_HND dom_pol, UNISTR2 user_account, uint32 acb_info, uint32 access_mask, + POLICY_HND *user_pol, uint32 *unknown0, uint32 *user_rid) { struct sam_passwd *sam_pass; fstring mach_acct; pstring err_str; pstring msg_str; int local_flags=0; + DOM_SID sid; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - SAMR_Q_CREATE_USER q_u; - SAMR_R_CREATE_USER r_u; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - DEBUG(5,("api_samr_create_user: %d\n", __LINE__)); - - /* grab the samr create user */ - if (!samr_io_q_create_user("", &q_u, data, 0)) { - DEBUG(0,("api_samr_create_user: Unable to unmarshall SAMR_Q_CREATE_USER.\n")); - return False; - } - /* find the policy handle. open a policy on it. */ - if ((find_lsa_policy_by_hnd(&q_u.pol) == -1)) { - r_u.status = NT_STATUS_INVALID_HANDLE; - goto out; - } + if (find_lsa_policy_by_hnd(&dom_pol) == -1) + 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 @@ -1867,7 +1845,7 @@ static BOOL api_samr_create_user(pipes_struct *p) reply if the account already exists... */ - fstrcpy(mach_acct, dos_unistrn2(q_u.uni_mach_acct.buffer, q_u.uni_mach_acct.uni_str_len)); + fstrcpy(mach_acct, dos_unistrn2(user_account.buffer, user_account.uni_str_len)); strlower(mach_acct); become_root(); @@ -1875,18 +1853,15 @@ static BOOL api_samr_create_user(pipes_struct *p) unbecome_root(); if (sam_pass != NULL) { /* machine account exists: say so */ - r_u.status = NT_STATUS_USER_EXISTS; - goto out; + return NT_STATUS_USER_EXISTS; } /* get a (unique) handle. open a policy on it. */ - if (!open_lsa_policy_hnd(&r_u.pol)) { - r_u.status = NT_STATUS_OBJECT_NAME_NOT_FOUND; - goto out; - } + if (!open_lsa_policy_hnd(user_pol)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; local_flags=LOCAL_ADD_USER|LOCAL_DISABLE_USER|LOCAL_SET_NO_PASSWORD; - local_flags|= (q_u.acb_info & ACB_WSTRUST) ? LOCAL_TRUST_ACCOUNT:0; + local_flags|= (acb_info & ACB_WSTRUST) ? LOCAL_TRUST_ACCOUNT:0; /* * NB. VERY IMPORTANT ! This call must be done as the current pipe user, @@ -1897,10 +1872,8 @@ static BOOL api_samr_create_user(pipes_struct *p) 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)); - r_u.status = NT_STATUS_ACCESS_DENIED; - close_lsa_policy_hnd(&r_u.pol); - memset((char *)r_u.pol.data, '\0', POL_HND_SIZE); - goto out; + close_lsa_policy_hnd(user_pol); + return NT_STATUS_ACCESS_DENIED; } become_root(); @@ -1908,31 +1881,62 @@ static BOOL api_samr_create_user(pipes_struct *p) unbecome_root(); if (sam_pass == NULL) { /* account doesn't exist: say so */ - r_u.status = NT_STATUS_ACCESS_DENIED; - close_lsa_policy_hnd(&r_u.pol); - memset((char *)r_u.pol.data, '\0', POL_HND_SIZE); - goto out; + close_lsa_policy_hnd(user_pol); + return NT_STATUS_ACCESS_DENIED; + } + + /* Get the domain SID stored in the domain policy */ + if(!get_lsa_policy_samr_sid(&dom_pol, &sid)) { + close_lsa_policy_hnd(user_pol); + return NT_STATUS_INVALID_HANDLE; + } + + /* append the user's RID to it */ + if(!sid_append_rid(&sid, sam_pass->user_rid)) { + close_lsa_policy_hnd(user_pol); + return NT_STATUS_NO_SUCH_USER; } /* associate the RID with the (unique) handle. */ - if (!set_lsa_policy_samr_rid(&r_u.pol, sam_pass->user_rid)) { + if (!set_lsa_policy_samr_sid(user_pol, &sid)) { /* oh, whoops. don't know what error message to return, here */ - r_u.status = NT_STATUS_OBJECT_NAME_NOT_FOUND; - close_lsa_policy_hnd(&r_u.pol); - memset((char *)r_u.pol.data, '\0', POL_HND_SIZE); - goto out; + close_lsa_policy_hnd(user_pol); + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + *unknown0=0x000703ff; + *user_rid=sam_pass->user_rid; + + return NT_STATUS_NO_PROBLEMO; +} + +/******************************************************************* + api_samr_create_user + ********************************************************************/ +static BOOL api_samr_create_user(pipes_struct *p) +{ + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + SAMR_Q_CREATE_USER q_u; + SAMR_R_CREATE_USER r_u; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the samr create user */ + if (!samr_io_q_create_user("", &q_u, data, 0)) { + DEBUG(0,("api_samr_create_user: Unable to unmarshall SAMR_Q_CREATE_USER.\n")); + return False; } - r_u.unknown_0=0x000703ff; - r_u.user_rid=sam_pass->user_rid; + r_u.status=_api_samr_create_user(q_u.pol, q_u.uni_mach_acct, q_u.acb_info, q_u.access_mask, + &r_u.pol, &r_u.unknown_0, &r_u.user_rid); - out: /* store the response in the SMB stream */ if(!samr_io_r_create_user("", &r_u, rdata, 0)) return False; - DEBUG(5,("api_samr_create_user: %d\n", __LINE__)); - return True; } @@ -2146,66 +2150,405 @@ static BOOL api_samr_enum_domains(pipes_struct *p) return True; } + /******************************************************************* - samr_reply_open_alias + api_samr_open_alias ********************************************************************/ -static BOOL samr_reply_open_alias(SAMR_Q_OPEN_ALIAS *q_u, prs_struct *rdata) +static uint32 _api_samr_open_alias(POLICY_HND domain_pol, uint32 alias_rid, POLICY_HND *alias_pol) { - SAMR_R_OPEN_ALIAS r_u; - BOOL pol_open = False; - - /* set up the SAMR open_alias response */ + DOM_SID sid; + + /* get the domain policy. */ + if (!open_lsa_policy_hnd(&domain_pol)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; - r_u.status = 0x0; /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.pol)))) - { - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + if (!open_lsa_policy_hnd(alias_pol)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + /* Get the domain SID stored in the domain policy */ + if(!get_lsa_policy_samr_sid(&domain_pol, &sid)) { + close_lsa_policy_hnd(alias_pol); + return NT_STATUS_INVALID_HANDLE; + } + + /* append the alias' RID to it */ + if(!sid_append_rid(&sid, alias_rid)) { + close_lsa_policy_hnd(alias_pol); + return NT_STATUS_NO_SUCH_USER; } /* associate a RID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_lsa_policy_samr_rid(&(r_u.pol), q_u->rid_alias)) - { + if (!set_lsa_policy_samr_sid(alias_pol, &sid)) { /* oh, whoops. don't know what error message to return, here */ - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; + close_lsa_policy_hnd(alias_pol); + return NT_STATUS_OBJECT_NAME_NOT_FOUND; } - if (r_u.status != 0 && pol_open) - { - close_lsa_policy_hnd(&(r_u.pol)); - } + return NT_STATUS_NO_PROBLEMO; +} - DEBUG(5,("samr_open_alias: %d\n", __LINE__)); +/******************************************************************* + api_samr_open_alias + ********************************************************************/ +static BOOL api_samr_open_alias(pipes_struct *p) +{ + SAMR_Q_OPEN_ALIAS q_u; + SAMR_R_OPEN_ALIAS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the samr open policy */ + if(!samr_io_q_open_alias("", &q_u, data, 0)) + return False; + + r_u.status=_api_samr_open_alias(q_u.dom_pol, q_u.rid_alias, &r_u.pol); /* store the response in the SMB stream */ if(!samr_io_r_open_alias("", &r_u, rdata, 0)) return False; + + return True; +} + +/******************************************************************* + set_user_info_10 + ********************************************************************/ +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; + + if (id10 == NULL) { + DEBUG(5, ("set_user_info_10: NULL id10\n")); + return False; + } + + if (pwd == NULL) + return False; + + copy_sam_passwd(&new_pwd, pwd); + + new_pwd.acct_ctrl = id10->acb_info; + + if(!mod_sam21pwd_entry(&new_pwd, True)) + return False; + + return True; +} + +/******************************************************************* + set_user_info_12 + ********************************************************************/ +static BOOL set_user_info_12(const 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]; + + if (pwd == NULL) + return False; + + if (id12 == NULL) { + DEBUG(2, ("set_user_info_12: id12 is NULL\n")); + 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)) + return False; + + return True; +} + +/******************************************************************* + set_user_info_21 + ********************************************************************/ +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]; + + if (id21 == NULL) { + DEBUG(5, ("set_user_info_21: NULL id21\n")); + return False; + } + + if (pwd == NULL) + return False; + + pdb_init_sam(&new_pwd); + 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)) + return False; + + return True; +} + +/******************************************************************* + set_user_info_23 + ********************************************************************/ +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]; + pstring buf; + uint32 len; + + if (id23 == NULL) { + DEBUG(5, ("set_user_info_23: NULL id23\n")); + return False; + } + + if (pwd == NULL) + return False; + + pdb_init_sam(&new_pwd); + copy_sam_passwd(&new_pwd, pwd); + copy_id23_to_sam_passwd(&new_pwd, id23); - DEBUG(5,("samr_open_alias: %d\n", __LINE__)); + if (!decode_pw_buffer(id23->pass, buf, 256, &len)) + return False; + + nt_lm_owf_gen(buf, nt_hash, lm_hash); + + new_pwd.smb_passwd = lm_hash; + new_pwd.smb_nt_passwd = nt_hash; + + if(!mod_sam21pwd_entry(&new_pwd, True)) + return False; return True; } /******************************************************************* - api_samr_open_alias + set_user_info_24 ********************************************************************/ -static BOOL api_samr_open_alias(pipes_struct *p) +static BOOL set_user_info_24(const SAM_USER_INFO_24 *id24, uint32 rid) { - SAMR_Q_OPEN_ALIAS q_u; + struct sam_passwd *pwd = getsam21pwrid(rid); + struct sam_passwd new_pwd; + static uchar nt_hash[16]; + static uchar lm_hash[16]; + uint32 len; + pstring buf; + + if (pwd == NULL) + return False; + + pdb_init_sam(&new_pwd); + copy_sam_passwd(&new_pwd, pwd); + + if (!decode_pw_buffer(id24->pass, buf, 256, &len)) + return False; + + nt_lm_owf_gen(buf, nt_hash, lm_hash); + + new_pwd.smb_passwd = lm_hash; + new_pwd.smb_nt_passwd = nt_hash; + + if(!mod_sam21pwd_entry(&new_pwd, True)) + return False; + + return True; +} + +/******************************************************************* + samr_reply_set_userinfo + ********************************************************************/ +static uint32 _samr_set_userinfo(POLICY_HND *pol, uint16 switch_value, SAM_USERINFO_CTR *ctr, uint16 vuid) +{ + uint32 rid = 0x0; + DOM_SID sid; + user_struct *vuser = NULL; + + DEBUG(5, ("samr_reply_set_userinfo: %d\n", __LINE__)); + + /* search for the handle */ + if (find_lsa_policy_by_hnd(pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return NT_STATUS_INVALID_HANDLE; + + /* find the policy handle. open a policy on it. */ + if (!get_lsa_policy_samr_sid(pol, &sid)) + return NT_STATUS_INVALID_HANDLE; + + sid_split_rid(&sid, &rid); + + DEBUG(5, ("samr_reply_set_userinfo: rid:0x%x, level:%d\n", rid, switch_value)); + + if (ctr == NULL) { + DEBUG(5, ("samr_reply_set_userinfo: NULL info level\n")); + return NT_STATUS_INVALID_INFO_CLASS; + } + + /* ok! user info levels (lots: see MSDEV help), off we go... */ + switch (switch_value) { + case 0x12: + if (!set_user_info_12(ctr->info.id12, rid)) + return NT_STATUS_ACCESS_DENIED; + break; + + case 24: + SamOEMhash(ctr->info.id24->pass, vuser->dc.sess_key, True); + if (!set_user_info_24(ctr->info.id24, rid)) + return NT_STATUS_ACCESS_DENIED; + break; + + case 23: + DEBUG(5, ("samr_reply_set_userinfo: sess key:[%s]\n", credstr(vuser->dc.sess_key))); + SamOEMhash(ctr->info.id23->pass, vuser->dc.sess_key, 1); + if (!set_user_info_23(ctr->info.id23, rid)) + return NT_STATUS_ACCESS_DENIED; + break; + + default: + return NT_STATUS_INVALID_INFO_CLASS; + } + + return NT_STATUS_NOPROBLEMO; +} + +/******************************************************************* + api_samr_set_userinfo + ********************************************************************/ +static BOOL api_samr_set_userinfo(pipes_struct *p) +{ + SAMR_Q_SET_USERINFO q_u; + SAMR_R_SET_USERINFO r_u; + prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - /* grab the samr open policy */ - if(!samr_io_q_open_alias("", &q_u, data, 0)) + SAM_USERINFO_CTR ctr; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + q_u.ctr = &ctr; + + if (!samr_io_q_set_userinfo("", &q_u, data, 0)) return False; - /* construct reply. always indicate success */ - if(!samr_reply_open_alias(&q_u, rdata)) + r_u.status = _samr_set_userinfo(&q_u.pol, q_u.switch_value, &ctr, p->vuid); + + free_samr_q_set_userinfo(&q_u); + + if(!samr_io_r_set_userinfo("", &r_u, rdata, 0)) return False; return True; } +/******************************************************************* + samr_reply_set_userinfo2 + ********************************************************************/ +static uint32 _samr_set_userinfo2(POLICY_HND *pol, uint16 switch_value, SAM_USERINFO_CTR *ctr) +{ + DOM_SID sid; + uint32 rid = 0x0; + + DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__)); + + /* search for the handle */ + if (find_lsa_policy_by_hnd(pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + /* find the policy handle. open a policy on it. */ + if (!get_lsa_policy_samr_sid(pol, &sid)) + return NT_STATUS_INVALID_HANDLE; + + sid_split_rid(&sid, &rid); + + DEBUG(5, ("samr_reply_set_userinfo2: rid:0x%x\n", rid)); + + if (ctr == NULL) { + DEBUG(5, ("samr_reply_set_userinfo2: NULL info level\n")); + return NT_STATUS_INVALID_INFO_CLASS; + } + + ctr->switch_value = switch_value; + + /* ok! user info levels (lots: see MSDEV help), off we go... */ + switch (switch_value) { + case 21: + if (!set_user_info_21(ctr->info.id21, rid)) + return NT_STATUS_ACCESS_DENIED; + break; + case 16: + if (!set_user_info_10(ctr->info.id10, rid)) + return NT_STATUS_ACCESS_DENIED; + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + } + + return NT_STATUS_NOPROBLEMO; +} + +/******************************************************************* + api_samr_set_userinfo2 + ********************************************************************/ +static BOOL api_samr_set_userinfo2(pipes_struct *p) +{ + SAMR_Q_SET_USERINFO2 q_u; + SAMR_R_SET_USERINFO2 r_u; + SAM_USERINFO_CTR ctr; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + q_u.ctr = &ctr; + + if (!samr_io_q_set_userinfo2("", &q_u, data, 0)) + return False; + + r_u.status = _samr_set_userinfo2(&q_u.pol, q_u.switch_value, &ctr); + + free_samr_q_set_userinfo2(&q_u); + + if(!samr_io_r_set_userinfo2("", &r_u, rdata, 0)) + return False; + + return True; +} + + /******************************************************************* array of \PIPE\samr operations ********************************************************************/ @@ -2221,12 +2564,12 @@ static struct api_struct api_samr_cmds [] = { "SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, { "SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, { "SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, - { "SAMR_QUERY_DOMAIN_INFO", SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, + { "SAMR_QUERY_DOMAIN_INFO", SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, { "SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, { "SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, { "SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, { "SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user }, - { "SAMR_UNKNOWN_12" , SAMR_UNKNOWN_12 , api_samr_unknown_12 }, + { "SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids }, { "SAMR_UNKNOWN_38" , SAMR_UNKNOWN_38 , api_samr_unknown_38 }, { "SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, { "SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, @@ -2235,6 +2578,8 @@ static struct api_struct api_samr_cmds [] = { "SAMR_UNKNOWN_2C" , SAMR_UNKNOWN_2C , api_samr_unknown_2c }, { "SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, { "SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains }, + { "SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo }, + { "SAMR_SET_USERINFO2" , SAMR_SET_USERINFO2 , api_samr_set_userinfo2 }, { NULL , 0 , NULL } }; -- cgit From 5ad18c79ad380596159f729a97d42100074425a6 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Sat, 7 Oct 2000 17:32:40 +0000 Subject: more cleanup of samr J.F. (This used to be commit c49cc884458d6efa0f7f4b1e40f7d98d84836e77) --- source3/rpc_server/srv_samr.c | 127 +++++++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 62 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 59a541abd9..a0c043461f 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1934,8 +1934,10 @@ static BOOL api_samr_create_user(pipes_struct *p) &r_u.pol, &r_u.unknown_0, &r_u.user_rid); /* store the response in the SMB stream */ - if(!samr_io_r_create_user("", &r_u, rdata, 0)) + if(!samr_io_r_create_user("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_create_user: Unable to marshall SAMR_R_CREATE_USER.\n")); return False; + } return True; } @@ -2061,31 +2063,6 @@ static BOOL api_samr_connect(pipes_struct *p) return True; } -/********************************************************************** - api_reply_lookup_domain - **********************************************************************/ -static BOOL samr_reply_lookup_domain(SAMR_Q_LOOKUP_DOMAIN* q_u, prs_struct* rdata) -{ - SAMR_R_LOOKUP_DOMAIN r_u; - - r_u.status = 0x0; - if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->connect_pol)) == -1)) - { - r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - DEBUG(5,("samr_reply_lookup_domain: invalid handle\n")); - } - - /* assume the domain name sent is our global_myname and - send global_sam_sid */ - init_samr_r_lookup_domain(&r_u, &global_sam_sid, r_u.status); - - if(!samr_io_r_lookup_domain("", &r_u, rdata, 0)) - return False; - - DEBUG(5,("samr_reply_lookup_domain: %d\n", __LINE__)); - - return True; -} /********************************************************************** api_samr_lookup_domain @@ -2093,42 +2070,34 @@ static BOOL samr_reply_lookup_domain(SAMR_Q_LOOKUP_DOMAIN* q_u, prs_struct* rdat static BOOL api_samr_lookup_domain(pipes_struct *p) { SAMR_Q_LOOKUP_DOMAIN q_u; + SAMR_R_LOOKUP_DOMAIN r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - if(!samr_io_q_lookup_domain("", &q_u, data, 0)) - return False; - - if(!samr_reply_lookup_domain(&q_u, rdata)) + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!samr_io_q_lookup_domain("", &q_u, data, 0)) { + DEBUG(0,("api_samr_lookup_domain: Unable to unmarshall SAMR_Q_LOOKUP_DOMAIN.\n")); return False; + } - return True; -} + r_u.status = 0x0; -/********************************************************************** - samr_reply_enum_domains - **********************************************************************/ -static BOOL samr_reply_enum_domains(SAMR_Q_ENUM_DOMAINS* q_u, prs_struct* rdata) -{ - SAMR_R_ENUM_DOMAINS r_u; - fstring dom[2]; + if (find_lsa_policy_by_hnd(&q_u.connect_pol) == -1){ + r_u.status = NT_STATUS_INVALID_HANDLE; + DEBUG(5,("api_samr_lookup_domain: invalid handle\n")); + } - ZERO_STRUCT(r_u); - - fstrcpy(dom[0],global_myname); - fstrcpy(dom[1],"Builtin"); - r_u.status = 0; - - init_samr_r_enum_domains(&r_u, q_u->start_idx, dom, 2); - if(!samr_io_r_enum_domains("", &r_u, rdata, 0)) { - free(r_u.sam); - free(r_u.uni_dom_name); + /* assume the domain name sent is our global_myname and + send global_sam_sid */ + init_samr_r_lookup_domain(&r_u, &global_sam_sid, r_u.status); + + if(!samr_io_r_lookup_domain("", &r_u, rdata, 0)){ + DEBUG(0,("api_samr_lookup_domain: Unable to marshall SAMR_R_LOOKUP_DOMAIN.\n")); return False; } - - free(r_u.sam); - free(r_u.uni_dom_name); - + return True; } @@ -2138,14 +2107,36 @@ static BOOL samr_reply_enum_domains(SAMR_Q_ENUM_DOMAINS* q_u, prs_struct* rdata) static BOOL api_samr_enum_domains(pipes_struct *p) { SAMR_Q_ENUM_DOMAINS q_u; + SAMR_R_ENUM_DOMAINS r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + + fstring dom[2]; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - if(!samr_io_q_enum_domains("", &q_u, data, 0)) + fstrcpy(dom[0],global_myname); + fstrcpy(dom[1],"Builtin"); + + if(!samr_io_q_enum_domains("", &q_u, data, 0)) { + DEBUG(0,("api_samr_enum_domains: Unable to unmarshall SAMR_Q_ENUM_DOMAINS.\n")); return False; - - if(!samr_reply_enum_domains(&q_u, rdata)) + } + + r_u.status = NT_STATUS_NO_PROBLEMO; + + init_samr_r_enum_domains(&r_u, q_u.start_idx, dom, 2); + + if(!samr_io_r_enum_domains("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_enum_domains: Unable to marshall SAMR_R_ENUM_DOMAINS.\n")); + free(r_u.sam); + free(r_u.uni_dom_name); return False; + } + + free(r_u.sam); + free(r_u.uni_dom_name); return True; } @@ -2202,14 +2193,18 @@ static BOOL api_samr_open_alias(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the samr open policy */ - if(!samr_io_q_open_alias("", &q_u, data, 0)) + if(!samr_io_q_open_alias("", &q_u, data, 0)) { + DEBUG(0,("api_samr_open_alias: Unable to unmarshall SAMR_Q_OPEN_ALIAS.\n")); return False; + } r_u.status=_api_samr_open_alias(q_u.dom_pol, q_u.rid_alias, &r_u.pol); /* store the response in the SMB stream */ - if(!samr_io_r_open_alias("", &r_u, rdata, 0)) + if(!samr_io_r_open_alias("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_open_alias: Unable to marshall SAMR_R_OPEN_ALIAS.\n")); return False; + } return True; } @@ -2459,15 +2454,19 @@ static BOOL api_samr_set_userinfo(pipes_struct *p) q_u.ctr = &ctr; - if (!samr_io_q_set_userinfo("", &q_u, data, 0)) + if (!samr_io_q_set_userinfo("", &q_u, data, 0)) { + DEBUG(0,("api_samr_set_userinfo: Unable to unmarshall SAMR_Q_SET_USERINFO.\n")); return False; + } r_u.status = _samr_set_userinfo(&q_u.pol, q_u.switch_value, &ctr, p->vuid); free_samr_q_set_userinfo(&q_u); - if(!samr_io_r_set_userinfo("", &r_u, rdata, 0)) + if(!samr_io_r_set_userinfo("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_set_userinfo: Unable to marshall SAMR_R_SET_USERINFO.\n")); return False; + } return True; } @@ -2535,15 +2534,19 @@ static BOOL api_samr_set_userinfo2(pipes_struct *p) q_u.ctr = &ctr; - if (!samr_io_q_set_userinfo2("", &q_u, data, 0)) + if (!samr_io_q_set_userinfo2("", &q_u, data, 0)) { + DEBUG(0,("api_samr_set_userinfo2: Unable to unmarshall SAMR_Q_SET_USERINFO2.\n")); return False; + } r_u.status = _samr_set_userinfo2(&q_u.pol, q_u.switch_value, &ctr); free_samr_q_set_userinfo2(&q_u); - if(!samr_io_r_set_userinfo2("", &r_u, rdata, 0)) + if(!samr_io_r_set_userinfo2("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_set_userinfo2: Unable to marshall SAMR_R_SET_USERINFO2.\n")); return False; + } return True; } -- cgit From 43b2bdce3ebf2598f97a611ad879c7ab527728fd Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 9 Oct 2000 14:41:19 +0000 Subject: I introduced a bug in my last commits. Hopefully nobody noticed :-) J.F. (This used to be commit 044246fe7e40d83673120dc14b5d6572e6c23142) --- source3/rpc_server/srv_samr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index a0c043461f..93f1f704a8 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -2150,8 +2150,8 @@ static uint32 _api_samr_open_alias(POLICY_HND domain_pol, uint32 alias_rid, POLI DOM_SID sid; /* get the domain policy. */ - if (!open_lsa_policy_hnd(&domain_pol)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; + if (find_lsa_policy_by_hnd(&domain_pol) == -1) + return NT_STATUS_INVALID_HANDLE; /* get a (unique) handle. open a policy on it. */ if (!open_lsa_policy_hnd(alias_pol)) -- cgit From 11d999f2bc0c841696bc3ea1ddda48524242482c Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 10 Oct 2000 13:08:55 +0000 Subject: a netlogon enum trust query doesn't have a function_code at end. a sam_user_info_24 doesn't have a uint16 at end samr_create_user also creates the unix account now samr_set_userinfo changes the password. J.F. (This used to be commit 94f4024481fcd0cb6647af1bd4364033be020641) --- source3/rpc_server/srv_samr.c | 67 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 93f1f704a8..1d2626f8fe 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1870,6 +1870,11 @@ static BOOL _api_samr_create_user(POLICY_HND dom_pol, UNISTR2 user_account, uint * to create a user. JRA. */ + /* add the user in the /etc/passwd file or the unix authority system */ + if (lp_adduser_script()) + smb_create_user(mach_acct); + + /* 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)); close_lsa_policy_hnd(user_pol); @@ -2340,6 +2345,13 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) new_pwd.smb_passwd = lm_hash; new_pwd.smb_nt_passwd = nt_hash; + /* update the UNIX password */ + if (lp_unix_password_sync()) + if(!chgpasswd(new_pwd.smb_name, "", buf, True)) + return False; + + memset(buf, 0, sizeof(buf)); + if(!mod_sam21pwd_entry(&new_pwd, True)) return False; @@ -2372,6 +2384,14 @@ static BOOL set_user_info_24(const SAM_USER_INFO_24 *id24, uint32 rid) new_pwd.smb_passwd = lm_hash; new_pwd.smb_nt_passwd = nt_hash; + /* update the UNIX password */ + if (lp_unix_password_sync()) + if(!chgpasswd(new_pwd.smb_name, "", buf, True)) + return False; + + memset(buf, 0, sizeof(buf)); + + /* update the SAMBA password */ if(!mod_sam21pwd_entry(&new_pwd, True)) return False; @@ -2381,34 +2401,58 @@ static BOOL set_user_info_24(const SAM_USER_INFO_24 *id24, uint32 rid) /******************************************************************* samr_reply_set_userinfo ********************************************************************/ -static uint32 _samr_set_userinfo(POLICY_HND *pol, uint16 switch_value, SAM_USERINFO_CTR *ctr, uint16 vuid) +static uint32 _samr_set_userinfo(POLICY_HND *pol, uint16 switch_value, SAM_USERINFO_CTR *ctr, pipes_struct *p) { uint32 rid = 0x0; DOM_SID sid; - user_struct *vuser = NULL; + struct current_user user; + struct smb_passwd *smb_pass; + unsigned char sess_key[16]; + + DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); - DEBUG(5, ("samr_reply_set_userinfo: %d\n", __LINE__)); + if (p->ntlmssp_auth_validated) { + memcpy(&user, &p->pipe_user, sizeof(user)); + } else { + extern struct current_user current_user; + memcpy(&user, ¤t_user, sizeof(user)); + } /* search for the handle */ if (find_lsa_policy_by_hnd(pol) == -1) return NT_STATUS_INVALID_HANDLE; - if ((vuser = get_valid_user_struct(vuid)) == NULL) - return NT_STATUS_INVALID_HANDLE; - /* find the policy handle. open a policy on it. */ if (!get_lsa_policy_samr_sid(pol, &sid)) return NT_STATUS_INVALID_HANDLE; sid_split_rid(&sid, &rid); - DEBUG(5, ("samr_reply_set_userinfo: rid:0x%x, level:%d\n", rid, switch_value)); + DEBUG(5, ("_samr_set_userinfo: rid:0x%x, level:%d\n", rid, switch_value)); if (ctr == NULL) { - DEBUG(5, ("samr_reply_set_userinfo: NULL info level\n")); + DEBUG(5, ("_samr_set_userinfo: NULL info level\n")); return NT_STATUS_INVALID_INFO_CLASS; } + + /* + * 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" + * This "user session key" is in turn used to encrypt/decrypt the user's password. + */ + + become_root(); + smb_pass = getsmbpwuid(user.uid); + unbecome_root(); + if(smb_pass == NULL) { + DEBUG(0,("_samr_set_userinfo: Unable to get smbpasswd 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); + /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { case 0x12: @@ -2417,14 +2461,13 @@ static uint32 _samr_set_userinfo(POLICY_HND *pol, uint16 switch_value, SAM_USERI break; case 24: - SamOEMhash(ctr->info.id24->pass, vuser->dc.sess_key, True); + SamOEMhash(ctr->info.id24->pass, sess_key, 1); if (!set_user_info_24(ctr->info.id24, rid)) return NT_STATUS_ACCESS_DENIED; break; case 23: - DEBUG(5, ("samr_reply_set_userinfo: sess key:[%s]\n", credstr(vuser->dc.sess_key))); - SamOEMhash(ctr->info.id23->pass, vuser->dc.sess_key, 1); + SamOEMhash(ctr->info.id23->pass, sess_key, 1); if (!set_user_info_23(ctr->info.id23, rid)) return NT_STATUS_ACCESS_DENIED; break; @@ -2459,7 +2502,7 @@ static BOOL api_samr_set_userinfo(pipes_struct *p) return False; } - r_u.status = _samr_set_userinfo(&q_u.pol, q_u.switch_value, &ctr, p->vuid); + r_u.status = _samr_set_userinfo(&q_u.pol, q_u.switch_value, &ctr, p); free_samr_q_set_userinfo(&q_u); -- cgit From e8912baf025a1356aa8c02f971fbe3d67adc9b0a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 10 Oct 2000 19:09:48 +0000 Subject: Fix found by Andrew to stop local/remote printers being confused. check_printer_ok was causing SETPRINTER calls to fail. Jeremy. (This used to be commit b41cc5fea7409d07529adad44f0cbba5c764591c) --- source3/rpc_server/srv_spoolss_nt.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 56de5375fb..72c87ae819 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3406,8 +3406,9 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) * as this is what Samba insists upon. */ - if (!(info->attributes & PRINTER_ATTRIBUTE_SHARED)) { - DEBUG(10,("check_printer_ok: SHARED check failed (%x).\n", (unsigned int)info->attributes )); + if (!(info->attributes & (PRINTER_ATTRIBUTE_SHARED|PRINTER_ATTRIBUTE_NETWORK))) { + DEBUG(10,("check_printer_ok: SHARED/NETWORK check failed (%x).\n", + (unsigned int)info->attributes )); return False; } @@ -3421,8 +3422,22 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) } } + /* + * Sometimes the NT client doesn't set the sharename, but + * includes the sharename in the printername. This could + * cause SETPRINTER to fail which causes problems with the + * client getting confused between local/remote printers... + */ + + if (*info->sharename == '\0') { + char *p = strrchr(info->printername, '\\'); + if (p) + fstrcpy(info->sharename, p+1); + } + if (!strequal(info->sharename, lp_servicename(snum))) { - DEBUG(10,("check_printer_ok: NAME check failed (%s) (%s).\n", info->sharename, lp_servicename(snum))); + DEBUG(10,("check_printer_ok: NAME check failed (%s) (%s).\n", + info->sharename, lp_servicename(snum))); return False; } -- cgit From cbee552bdb1a4692a19667175fbbf090a9597d71 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 11 Oct 2000 04:54:37 +0000 Subject: Don't initialise groups twice. (This used to be commit 15d7f16bdc2ff4f2ae82871eb9f318ba45cf4d1c) --- source3/rpc_server/srv_pipe.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 01d9568477..fd5155a554 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -463,7 +463,6 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name /* Set up pipe user group membership. */ initialise_groups(pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); - initialize_groups(pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); get_current_groups( &p->pipe_user.ngroups, &p->pipe_user.groups); /* Create an NT_USER_TOKEN struct for this user. */ -- cgit From 8719c27726d3412edd0781beb956f48f76a62fb6 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Wed, 11 Oct 2000 05:31:39 +0000 Subject: changes to sync with 2.2. tree .cvsignore remove config.h - not in this directory include/profile.h profile changes lib/messages.c added message to return debug level libsmb/clierror.c cast to get rid of compiler warning libsmb/smbencrypt.c cast to get rid of compiler warning profile/profile.c add flush profile stats changes for profile struct rpc_parse/parse_samr.c fix for compiler warning rpc_server/srv_samr.c cast to get rid of compiler warning smbd/ipc.c profile stats message.c profile stats smbd/negprot.c profile stats smbd/nttrans.c profile stats smbd/trans2.c profile stats utils/smbcontrol.c new flush stats command (This used to be commit bbb24daa25dca4e4b6b1f8942cd84ee3aa1bed8e) --- source3/rpc_server/srv_samr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 1d2626f8fe..84ac1ae004 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -2337,7 +2337,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) copy_sam_passwd(&new_pwd, pwd); copy_id23_to_sam_passwd(&new_pwd, id23); - if (!decode_pw_buffer(id23->pass, buf, 256, &len)) + if (!decode_pw_buffer((const char *)id23->pass, buf, 256, &len)) return False; nt_lm_owf_gen(buf, nt_hash, lm_hash); @@ -2376,7 +2376,7 @@ static BOOL set_user_info_24(const SAM_USER_INFO_24 *id24, uint32 rid) pdb_init_sam(&new_pwd); copy_sam_passwd(&new_pwd, pwd); - if (!decode_pw_buffer(id24->pass, buf, 256, &len)) + if (!decode_pw_buffer((const char *)id24->pass, buf, 256, &len)) return False; nt_lm_owf_gen(buf, nt_hash, lm_hash); -- cgit From 85643cd72cbc51d163dba98eecd98c7bb029bfc3 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 13 Oct 2000 14:02:01 +0000 Subject: last part of W2K support. the trust domain list reply on netlogon pipe was wrong, interim hack until we have full trust relationships. changed some unistr2 to parse the ending NULL char. added a prs_align_needed() function. much like a prs_align but with a condition. needed for the unistr2 parsing. J.F. (This used to be commit d8bf81553c17d9ee3419d8150b96119ebb0b8fa9) --- source3/rpc_server/srv_lsa.c | 4 ++-- source3/rpc_server/srv_samr.c | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 9c3d785627..2e12f00bb6 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -88,7 +88,7 @@ Init dom_query static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) { - int domlen = (dom_name != NULL) ? strlen(dom_name) : 0; + int domlen = (dom_name != NULL) ? strlen(dom_name)+1 : 0; d_q->uni_dom_max_len = domlen * 2; d_q->uni_dom_str_len = domlen * 2; @@ -183,7 +183,7 @@ static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) ref->max_entries = MAX_REF_DOMAINS; ref->num_ref_doms_2 = num+1; - len = (dom_name != NULL) ? strlen(dom_name) : 0; + len = (dom_name != NULL) ? strlen(dom_name)+1 : 0; if(dom_name != NULL && len == 0) len = 1; diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 84ac1ae004..72a86c8d80 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -71,7 +71,7 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, continue; } - user_name_len = strlen(pwd->smb_name); + 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; @@ -688,7 +688,7 @@ static BOOL samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, got_grps = True; num_entries = 1; ZERO_STRUCTP(&pass[0]); - init_unistr2(&(pass[0].uni_user_name), dummy_group, strlen(dummy_group)); + init_unistr2(&(pass[0].uni_user_name), dummy_group, strlen(dummy_group)+1); pass[0].user_rid = DOMAIN_GROUP_RID_ADMINS; if (r_e.status == 0 && got_grps) @@ -758,7 +758,7 @@ static BOOL samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, char *name; while (num_entries < MAX_SAM_ENTRIES && ((name = builtin_alias_rids[num_entries].name) != NULL)) { - init_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)); + init_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)+1); pass[num_entries].user_rid = builtin_alias_rids[num_entries].rid; num_entries++; } @@ -786,7 +786,7 @@ static BOOL samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, continue; } - init_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)); + init_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)+1); pass[num_entries].user_rid = pdb_gid_to_group_rid(grp->gr_gid); num_entries++; } @@ -2121,7 +2121,7 @@ static BOOL api_samr_enum_domains(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - fstrcpy(dom[0],global_myname); + fstrcpy(dom[0],global_myworkgroup); fstrcpy(dom[1],"Builtin"); if(!samr_io_q_enum_domains("", &q_u, data, 0)) { @@ -2376,9 +2376,12 @@ static BOOL set_user_info_24(const SAM_USER_INFO_24 *id24, uint32 rid) pdb_init_sam(&new_pwd); copy_sam_passwd(&new_pwd, pwd); + memset(buf, 0, sizeof(buf)); + if (!decode_pw_buffer((const char *)id24->pass, buf, 256, &len)) return False; +DEBUG(0,("set_user_info_24:nt_lm_owf_gen\n")); nt_lm_owf_gen(buf, nt_hash, lm_hash); new_pwd.smb_passwd = lm_hash; @@ -2390,6 +2393,7 @@ static BOOL set_user_info_24(const SAM_USER_INFO_24 *id24, uint32 rid) return False; memset(buf, 0, sizeof(buf)); +DEBUG(0,("set_user_info_24:mod_sam21pwd_entry\n")); /* update the SAMBA password */ if(!mod_sam21pwd_entry(&new_pwd, True)) -- cgit From 359048cc74c0b271f1a961f59d43422c682f1e84 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 13 Oct 2000 21:53:51 +0000 Subject: Fixes to get ms-dfs code to compile with the new changes. Jeremy (This used to be commit d712b5b071eff89eca547678cd1652263708abfb) --- source3/rpc_server/srv_dfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 62acbaa6cc..7aadd0719c 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -37,7 +37,6 @@ extern pstring global_myname; static BOOL api_dfs_exist(pipes_struct *p) { DFS_R_DFS_EXIST r_d; - prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; if(lp_host_msdfs()) @@ -109,7 +108,7 @@ static uint32 init_reply_dfs_add(DFS_Q_DFS_ADD* q_a) /***************************************************************** api_dfs_add *****************************************************************/ -static BOOL api_dfs_add(pipes-struct *p) +static BOOL api_dfs_add(pipes_struct *p) { DFS_Q_DFS_ADD q_a; DFS_R_DFS_ADD r_a; @@ -204,6 +203,8 @@ static BOOL api_dfs_remove(pipes_struct *p) { DFS_Q_DFS_REMOVE q_r; DFS_R_DFS_REMOVE r_r; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; if(!dfs_io_q_dfs_remove("", &q_r, data, 0)) return False; -- cgit From 282930d31f83e658573d1582d2ac89c98616ee2d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 18 Oct 2000 01:15:05 +0000 Subject: Merge of rpc parse buffer underflow debug code. (This used to be commit c8d88713d9f7a646eb3b8e76bdd0250a3b89b722) --- source3/rpc_server/srv_pipe.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index fd5155a554..4cb57c69d8 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1207,6 +1207,25 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, DEBUG(5,("api_rpcTNP: called %s successfully\n", rpc_name)); + /* Check for buffer underflow in rpc parsing */ + + if ((DEBUGLEVEL >= 10) && + (p->in_data.data.data_offset != p->in_data.data.buffer_size)) { + int data_len = p->in_data.data.buffer_size - + p->in_data.data.data_offset; + char *data; + + data = malloc(data_len); + + DEBUG(10, ("api_rpcTNP: rpc input buffer underflow (parse error?)\n")); + if (data) { + prs_uint8s(False, "", &p->in_data.data, 0, data, + data_len); + free(data); + } + + } + return True; } -- cgit From 4e1d30694555fe2b7b2684686778c7b143aea41e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 20 Oct 2000 03:23:36 +0000 Subject: Merge from appliance-head (This used to be commit 6d39df7cf84d391bb4dd55d9a26f9f5a6368f46f) --- source3/rpc_server/srv_spoolss_nt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 72c87ae819..928ac45046 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2080,7 +2080,11 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer else fstrcpy(sl, '\0'); - snprintf(chaine2, sizeof(chaine)-1, "%s%s%s", servername, sl, ntprinter->info_2->printername); + if (!strchr(ntprinter->info_2->printername, '\\')) { + snprintf(chaine2, sizeof(chaine)-1, "%s%s%s", servername, sl, ntprinter->info_2->printername); + } else { + pstrcpy(chaine2, ntprinter->info_2->printername); + } init_unistr(&printer->servername, chaine); /* servername*/ init_unistr(&printer->printername, chaine2); /* printername*/ -- cgit From 888643b981e2ac29d8e7c6dca6943381dfc84e58 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 25 Oct 2000 04:29:35 +0000 Subject: Removed erroneous +1's on length of unicode domain names for various functions in the \\lsarpc pipe. (This used to be commit 30bb3f2df97662c6547c7994ce50efe9abf37968) --- source3/rpc_server/srv_lsa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 2e12f00bb6..9c3d785627 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -88,7 +88,7 @@ Init dom_query static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) { - int domlen = (dom_name != NULL) ? strlen(dom_name)+1 : 0; + int domlen = (dom_name != NULL) ? strlen(dom_name) : 0; d_q->uni_dom_max_len = domlen * 2; d_q->uni_dom_str_len = domlen * 2; @@ -183,7 +183,7 @@ static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) ref->max_entries = MAX_REF_DOMAINS; ref->num_ref_doms_2 = num+1; - len = (dom_name != NULL) ? strlen(dom_name)+1 : 0; + len = (dom_name != NULL) ? strlen(dom_name) : 0; if(dom_name != NULL && len == 0) len = 1; -- cgit From b5ac72cc646a981469ee65305da83f273c4cd093 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 26 Oct 2000 21:43:13 +0000 Subject: Sorry JF - no billable hours :-). I fixed the "stream of events" problem with PCL drivers. The problem was we were updating the changeid on every SETPRINTERDATA/DELETEPRINTERDATA call. We should not do this, we should just update the 'setprinter' called count. We update the changeid on calls to SETPRINTER/ADDPRINTER/ADDPRINTEREX etc. Also fixed the correct returning of the create time on printers. Jeremy. (This used to be commit 521f09829fd329f87b3d19e8871e2b989c98a58e) --- source3/rpc_server/srv_spoolss_nt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 928ac45046..0eb75a7480 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1816,7 +1816,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring counter_printer_0 *session_counter; uint32 global_counter; struct tm *t; - time_t setup_time = time(NULL); + time_t setuptime; print_queue_struct *queue=NULL; print_status_struct status; @@ -1869,8 +1869,8 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring printer->total_jobs = 0; printer->total_bytes = 0; - t=gmtime(&setup_time); - ntprinter->info_2->setuptime = (uint32)setup_time; /* FIXME !! */ + setuptime = (time_t)ntprinter->info_2->setuptime; + t=gmtime(&setuptime); printer->year = t->tm_year+1900; printer->month = t->tm_mon+1; @@ -4957,7 +4957,7 @@ uint32 _spoolss_enumprinterdata(POLICY_HND *handle, uint32 idx, return ERROR_NOT_ENOUGH_MEMORY; } - ZERO_STRUCTP(*data_out); + memset(*data_out,'\0',in_data_len); memcpy(*data_out, data, (size_t)data_len); *out_data_len=data_len; @@ -5009,7 +5009,7 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, if (!add_a_specific_param(printer->info_2, param)) status = ERROR_INVALID_PARAMETER; else - status = add_a_printer(*printer, 2); + status = mod_a_printer(*printer, 2); free_a_printer(&printer, 2); return status; @@ -5051,7 +5051,7 @@ uint32 _spoolss_deleteprinterdata( POLICY_HND *handle, const UNISTR2 *value) if(!unlink_specific_param_if_exist(printer->info_2, ¶m)) status = ERROR_INVALID_PARAMETER; else - status = add_a_printer(*printer, 2); + status = mod_a_printer(*printer, 2); free_a_printer(&printer, 2); return status; -- cgit From 9a8749d33aebdb4b5cb705cf250012bfa8cf9238 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 26 Oct 2000 22:09:22 +0000 Subject: Added John Reillys patch for error code returns from clean_up_printer_driver_strunct() calls. Jeremy. (This used to be commit f81a2a03bf435e65e7484ab021f86a8a4f62b656) --- source3/rpc_server/srv_spoolss_nt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0eb75a7480..ebcccc8cf4 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4722,7 +4722,8 @@ uint32 _spoolss_addprinterdriver(pipes_struct *p, const UNISTR2 *server_name, convert_printer_driver_info(info, &driver, level); DEBUG(5,("Cleaning driver's information\n")); - clean_up_driver_struct(driver, level); + if ((err = clean_up_driver_struct(driver, level)) != NT_STATUS_NO_PROBLEMO ) + goto done; DEBUG(5,("Moving driver to final destination\n")); if(!move_driver_to_download_area(driver, level, &user, &err)) { -- cgit From c33d0e466dbcbb5dfa68250bec031af7503bd2fa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 29 Oct 2000 17:27:41 +0000 Subject: Patches from John Reilly @ HP for print job time bugs. Jeremy. (This used to be commit 0eb7f2d514317882684e9c0c51d46b1ac1eb2568) --- source3/rpc_server/srv_spoolss_nt.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ebcccc8cf4..9c0a3319f5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1381,6 +1381,19 @@ static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, data->notify_data.value[0]=queue->job; } +/******************************************************************* + * fill a notify_info_data with + ********************************************************************/ +static void spoolss_notify_submitted_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +{ + struct tm *t; + + t=gmtime(&queue->time); + + data->notify_data.data.length = sizeof(SYSTEMTIME); + make_systemtime((SYSTEMTIME*)(data->notify_data.data.string), t); +} + #define END 65535 struct s_notify_info_data_table @@ -1438,7 +1451,7 @@ struct s_notify_info_data_table notify_info_data_table[] = { JOB_NOTIFY_TYPE, JOB_NOTIFY_DOCUMENT, "JOB_NOTIFY_DOCUMENT", POINTER, spoolss_notify_job_name }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_PRIORITY, "JOB_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_POSITION, "JOB_NOTIFY_POSITION", ONE_VALUE, spoolss_notify_job_position }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SUBMITTED, "JOB_NOTIFY_SUBMITTED", POINTER, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SUBMITTED, "JOB_NOTIFY_SUBMITTED", POINTER, spoolss_notify_submitted_time }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_START_TIME, "JOB_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_UNTIL_TIME, "JOB_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_TIME, "JOB_NOTIFY_TIME", ONE_VALUE, spoolss_notify_job_time }, @@ -3696,9 +3709,8 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, pstring temp_name; struct tm *t; - time_t unixdate = time(NULL); - t=gmtime(&unixdate); + t=gmtime(&queue->time); snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); job_info->jobid=queue->job; @@ -3725,14 +3737,12 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, pstring temp_name; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; pstring chaine; - struct tm *t; - time_t unixdate = time(NULL); if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) return False; - t=gmtime(&unixdate); + t=gmtime(&queue->time); snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); job_info->jobid=queue->job; -- cgit From cd8525a767b293f0927d9a332e322db8cfb66f8d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 30 Oct 2000 21:55:30 +0000 Subject: Merge of comment repair. (This used to be commit 7712421910b12fd64cf90100e4495669bec67c2f) --- source3/rpc_server/srv_spoolss_nt.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 9c0a3319f5..a99874bfcd 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1308,7 +1308,7 @@ static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, p } /******************************************************************* - * fill a notify_info_data with + * fill a notify_info_data with username ********************************************************************/ static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { @@ -1317,7 +1317,7 @@ static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin } /******************************************************************* - * fill a notify_info_data with + * fill a notify_info_data with job status ********************************************************************/ static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { @@ -1325,7 +1325,7 @@ static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr } /******************************************************************* - * fill a notify_info_data with + * fill a notify_info_data with job name ********************************************************************/ static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { @@ -1334,7 +1334,7 @@ static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin } /******************************************************************* - * fill a notify_info_data with + * fill a notify_info_data with job status ********************************************************************/ static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { @@ -1358,7 +1358,7 @@ static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *d } /******************************************************************* - * fill a notify_info_data with + * fill a notify_info_data with job time ********************************************************************/ static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { @@ -1366,7 +1366,7 @@ static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin } /******************************************************************* - * fill a notify_info_data with + * fill a notify_info_data with job size ********************************************************************/ static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { @@ -1374,7 +1374,7 @@ static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin } /******************************************************************* - * fill a notify_info_data with + * fill a notify_info_data with job position ********************************************************************/ static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { @@ -1382,7 +1382,7 @@ static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, } /******************************************************************* - * fill a notify_info_data with + * fill a notify_info_data with submitted time ********************************************************************/ static void spoolss_notify_submitted_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { -- cgit From 8a190a9e46db3907bd389af68b393adeb6e1ca3d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 7 Nov 2000 02:54:50 +0000 Subject: Merge of printer security descriptor, info level and printerdata comparison changes from appliance branch. (This used to be commit ae087bdf312806e08848695cad70a943bb3d71b9) --- source3/rpc_server/srv_spoolss_nt.c | 304 +++++++++++++++++++++++++++++++----- 1 file changed, 267 insertions(+), 37 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a99874bfcd..9363829165 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3325,7 +3325,7 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command, { struct current_user user; int snum; - int errcode = 0; + int errcode = ERROR_INVALID_FUNCTION; Printer_entry *Printer = find_printer_index_by_hnd(handle); get_current_user(&user, p); @@ -3335,35 +3335,29 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command, return ERROR_INVALID_HANDLE; } - if (!get_printer_snum(handle, &snum) ) + if (!get_printer_snum(handle, &snum)) return ERROR_INVALID_HANDLE; switch (command) { case PRINTER_CONTROL_PAUSE: if (print_queue_pause(&user, snum, &errcode)) { - srv_spoolss_sendnotify(handle); - return 0; + errcode = 0; } break; case PRINTER_CONTROL_RESUME: case PRINTER_CONTROL_UNPAUSE: if (print_queue_resume(&user, snum, &errcode)) { - srv_spoolss_sendnotify(handle); - return 0; + errcode = 0; } break; case PRINTER_CONTROL_PURGE: if (print_queue_purge(&user, snum, &errcode)) { - srv_spoolss_sendnotify(handle); - return 0; + errcode = 0; } break; } - if (errcode) - return (uint32)errcode; - - return ERROR_INVALID_FUNCTION; + return errcode; } /******************************************************************** @@ -3383,6 +3377,7 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, pipes_struct *p, SEC_DESC_BUF *secdesc_ctr) { + SEC_DESC_BUF *new_secdesc_ctr = NULL, *old_secdesc_ctr = NULL; struct current_user user; uint32 result; int snum; @@ -3390,25 +3385,47 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, Printer_entry *Printer = find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer) || !get_printer_snum(handle, &snum)) { - DEBUG(0,("update_printer_sec: Invalid handle (%s)\n", OUR_HANDLE(handle))); - return ERROR_INVALID_HANDLE; + DEBUG(0,("update_printer_sec: Invalid handle (%s)\n", + OUR_HANDLE(handle))); + + result = ERROR_INVALID_HANDLE; + goto done; + } + + /* NT seems to like setting the security descriptor even though + nothing may have actually changed. This causes annoying + dialog boxes when the user doesn't have permission to change + the security descriptor. */ + + nt_printing_getsec(Printer->dev.handlename, &old_secdesc_ctr); + + new_secdesc_ctr = sec_desc_merge(secdesc_ctr, old_secdesc_ctr); + + if (sec_desc_equal(new_secdesc_ctr->sec, old_secdesc_ctr->sec)) { + result = NT_STATUS_NO_PROBLEMO; + goto done; } /* Work out which user is performing the operation */ + get_current_user(&user, p); /* Check the user has permissions to change the security descriptor. By experimentation with two NT machines, the user requires Full Access to the printer to change security information. */ + if (!print_access_check(&user, snum, PRINTER_ACCESS_ADMINISTER)) { result = ERROR_ACCESS_DENIED; goto done; } - result = nt_printing_setsec(Printer->dev.handlename, secdesc_ctr); + result = nt_printing_setsec(Printer->dev.handlename, new_secdesc_ctr); done: + free_sec_desc_buf(&new_secdesc_ctr); + free_sec_desc_buf(&old_secdesc_ctr); + return result; } @@ -3522,6 +3539,181 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) return True; } +/* Return true if two devicemodes are equal */ + +static BOOL nt_devicemode_equal(NT_DEVICEMODE *d1, NT_DEVICEMODE *d2) +{ + if (!strequal(d1->devicename, d2->devicename) || + !strequal(d1->formname, d2->formname)) { + return False; + } + + if (d1->specversion != d2->specversion || + d1->driverversion != d2->driverversion || + d1->size != d2->size || + d1->driverextra != d2->driverextra || + d1->orientation != d2->orientation || + d1->papersize != d2->papersize || + d1->paperlength != d2->paperlength || + d1->paperwidth != d2->paperwidth || + d1->scale != d2->scale || + d1->copies != d2->copies || + d1->defaultsource != d2->defaultsource || + d1->printquality != d2->printquality || + d1->color != d2->color || + d1->duplex != d2->duplex || + d1->yresolution != d2->yresolution || + d1->ttoption != d2->ttoption || + d1->collate != d2->collate || + d1->logpixels != d2->logpixels) { + return False; + } + + if (d1->fields != d2->fields || + d1->bitsperpel != d2->bitsperpel || + d1->pelswidth != d2->pelswidth || + d1->pelsheight != d2->pelsheight || + d1->displayflags != d2->displayflags || + d1->displayfrequency != d2->displayfrequency || + d1->icmmethod != d2->icmmethod || + d1->icmintent != d2->icmintent || + d1->mediatype != d2->mediatype || + d1->dithertype != d2->dithertype || + d1->reserved1 != d2->reserved1 || + d1->reserved2 != d2->reserved2 || + d1->panningwidth != d2->panningwidth || + d1->panningheight != d2->panningheight) { + return False; + } + + /* Not sure what to do about these fields */ +#if 0 + uint8 *private; +#endif + + return True; +} + +/* Return true if two NT_PRINTER_PARAM structures are equal */ + +static BOOL nt_printer_param_equal(NT_PRINTER_PARAM *p1, + NT_PRINTER_PARAM *p2) +{ + if (!p1 && !p2) return True; + + if ((!p1 && p2) || (p1 && !p2)) return False; + + /* Compare lists of printer parameters */ + + while (p1) { + BOOL found = False; + NT_PRINTER_PARAM *q = p1; + + /* Find the parameter in the second structure */ + + while(q) { + + if (strequal(p1->value, q->value) && + p1->type == q->type && + p1->data_len == q->data_len && + memcmp(p1->data, q->data, p1->data_len) == 0) { + found = True; + goto found_it; + } + + q = q->next; + } + + found_it: + if (!found) { + return False; + } + + p1 = p1->next; + } + + return True; +} + +/******************************************************************** + * Called by update_printer when trying to work out whether to + * actually update printer info. + ********************************************************************/ + +static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, + NT_PRINTER_INFO_LEVEL *p2) +{ + NT_PRINTER_INFO_LEVEL_2 *pi1, *pi2; + + /* Trivial conditions */ + + if ((!p1 && !p2) || (!p1->info_2 && !p2->info_2)) { + return True; + } + + if ((!p1 && p2) || (p1 && !p2) || + (!p1->info_2 && p2->info_2) || + (p1->info_2 && !p2->info_2)) { + return False; + } + + /* Compare two nt_printer_info_level structures. Don't compare + status or cjobs as they seem to have something to do with the + printer queue. */ + + pi1 = p1->info_2; + pi2 = p2->info_2; + + if (pi1->attributes != pi2->attributes || + pi1->priority != pi2->priority || + pi1->default_priority != pi2->default_priority || + pi1->starttime != pi2->starttime || + pi1->untiltime != pi2->untiltime || + pi1->averageppm != pi2->averageppm) { + return False; + } + + /* Yuck - don't check the printername or servername as the + add_a_printer() code plays games with them. You can't + change the printername or the sharename through this interface + in Samba. */ + + if (!strequal(pi1->sharename, pi2->sharename) || + !strequal(pi1->portname, pi2->portname) || + !strequal(pi1->drivername, pi2->drivername) || + !strequal(pi1->comment, pi2->comment) || + !strequal(pi1->location, pi2->location)) { + return False; + } + + if (!nt_devicemode_equal(pi1->devmode, pi2->devmode)) { + return False; + } + + if (!strequal(pi1->sepfile, pi2->sepfile) || + !strequal(pi1->printprocessor, pi2->printprocessor) || + !strequal(pi1->datatype, pi2->datatype) || + !strequal(pi1->parameters, pi2->parameters)) { + return False; + } + + if (!nt_printer_param_equal(pi1->specific, pi2->specific)) { + return False; + } + + if (!sec_desc_equal(pi1->secdesc_buf->sec, pi2->secdesc_buf->sec)) { + return False; + } + + if (pi1->changeid != pi2->changeid || + pi1->c_setprinter != pi2->c_setprinter || + pi1->setuptime != pi2->setuptime) { + return False; + } + + return True; +} + /******************************************************************** * called by spoolss_api_setprinter * when updating a printer description @@ -3532,7 +3724,7 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, DEVICEMODE *devmode) { int snum; - NT_PRINTER_INFO_LEVEL *printer = NULL; + NT_PRINTER_INFO_LEVEL *printer = NULL, *old_printer = NULL; Printer_entry *Printer = find_printer_index_by_hnd(handle); uint32 result; @@ -3540,8 +3732,6 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, result = NT_STATUS_NO_PROBLEMO; - /* Check calling user has permission to update printer description */ - if (level!=2) { DEBUG(0,("Send a mail to samba@samba.org\n")); DEBUGADD(0,("with the following message: update_printer: level!=2\n")); @@ -3559,14 +3749,8 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, goto done; } - if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { - DEBUG(3, ("printer property change denied by security " - "descriptor\n")); - result = ERROR_ACCESS_DENIED; - goto done; - } - - if(get_a_printer(&printer, 2, lp_servicename(snum)) != 0) { + if((get_a_printer(&printer, 2, lp_servicename(snum)) != 0) || + (get_a_printer(&old_printer, 2, lp_servicename(snum)) != 0)) { result = ERROR_INVALID_HANDLE; goto done; } @@ -3602,21 +3786,42 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, printer->info_2->devmode=NULL; } - /* - * Do sanity check on the requested changes for Samba. - */ + /* Do sanity check on the requested changes for Samba */ if (!check_printer_ok(printer->info_2, snum)) { result = ERROR_INVALID_PARAMETER; goto done; } + /* NT likes to call this function even though nothing has actually + changed. Check this so the user doesn't end up with an + annoying permission denied dialog box. */ + + if (nt_printer_info_level_equal(printer, old_printer)) { + DEBUG(3, ("printer info has not changed\n")); + result = NT_STATUS_NO_PROBLEMO; + goto done; + } + + /* Check calling user has permission to update printer description */ + + if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { + DEBUG(3, ("printer property change denied by security " + "descriptor\n")); + result = ERROR_ACCESS_DENIED; + goto done; + } + + /* Call addprinter hook */ + if (*lp_addprinter_cmd() ) if ( !add_printer_hook(printer) ) { result = ERROR_ACCESS_DENIED; goto done; } + /* Update printer info */ + if (add_a_printer(*printer, 2)!=0) { /* I don't really know what to return here !!! */ result = ERROR_ACCESS_DENIED; @@ -4988,14 +5193,13 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, uint32 numeric_data) { NT_PRINTER_INFO_LEVEL *printer = NULL; - NT_PRINTER_PARAM *param = NULL; + NT_PRINTER_PARAM *param = NULL, old_param; int snum=0; uint32 status = 0x0; Printer_entry *Printer=find_printer_index_by_hnd(handle); DEBUG(5,("spoolss_setprinterdata\n")); - if (!OPEN_HANDLE(Printer)) { DEBUG(0,("_spoolss_setprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; @@ -5004,17 +5208,40 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, if (!get_printer_snum(handle, &snum)) return ERROR_INVALID_HANDLE; - if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { - DEBUG(3, ("security descriptor change denied by existing " - "security descriptor\n")); - return ERROR_ACCESS_DENIED; - } - status = get_a_printer(&printer, 2, lp_servicename(snum)); if (status != 0x0) return ERROR_INVALID_NAME; convert_specific_param(¶m, 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, &old_param.data_len)) { + + if (param->type == old_param.type && + param->data_len == old_param.data_len && + memcmp(param->data, old_param.data, + old_param.data_len) == 0) { + + DEBUG(3, ("setprinterdata hasn't changed\n")); + status = NT_STATUS_NO_PROBLEMO; + 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); if (!add_a_specific_param(printer->info_2, param)) @@ -5022,7 +5249,10 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, else status = mod_a_printer(*printer, 2); + done: free_a_printer(&printer, 2); + safe_free(old_param.data); + return status; } -- cgit From 1d3747e7f296c062854fe66fffa60c4ff83a2200 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 8 Nov 2000 00:20:26 +0000 Subject: Merge fest!!! (This used to be commit 87775074b22bb969c3585556e2a86ac4c7d4b0d4) --- source3/rpc_server/srv_spoolss_nt.c | 44 +++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 24 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 9363829165..67b29bdbcf 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1339,18 +1339,19 @@ static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { char *p = "unknown"; + switch (queue->status) { case LPQ_QUEUED: - p = "QUEUED"; + p = "Queued"; break; case LPQ_PAUSED: - p = "PAUSED"; + p = ""; /* NT provides the paused string */ break; case LPQ_SPOOLING: - p = "SPOOLING"; + p = "Spooling"; break; case LPQ_PRINTING: - p = "PRINTING"; + p = "Printing"; break; } data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, @@ -3324,8 +3325,7 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command, pipes_struct *p) { struct current_user user; - int snum; - int errcode = ERROR_INVALID_FUNCTION; + int snum, errcode = ERROR_INVALID_FUNCTION; Printer_entry *Printer = find_printer_index_by_hnd(handle); get_current_user(&user, p); @@ -3355,6 +3355,8 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command, errcode = 0; } break; + default: + return ERROR_INVALID_LEVEL; } return errcode; @@ -3830,6 +3832,7 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, done: free_a_printer(&printer, 2); + free_a_printer(&old_printer, 2); srv_spoolss_sendnotify(handle); @@ -4131,17 +4134,12 @@ uint32 _spoolss_schedulejob( POLICY_HND *handle, uint32 jobid) /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_setjob( POLICY_HND *handle, - uint32 jobid, - uint32 level, - pipes_struct *p, - JOB_INFO *ctr, - uint32 command) - +uint32 _spoolss_setjob(POLICY_HND *handle, uint32 jobid, uint32 level, + pipes_struct *p, JOB_INFO *ctr, uint32 command) { struct current_user user; - int snum; print_status_struct prt_status; + int snum, errcode = ERROR_INVALID_FUNCTION; memset(&prt_status, 0, sizeof(prt_status)); @@ -4158,28 +4156,26 @@ uint32 _spoolss_setjob( POLICY_HND *handle, switch (command) { case JOB_CONTROL_CANCEL: case JOB_CONTROL_DELETE: - if (print_job_delete(&user, jobid)) { - srv_spoolss_sendnotify(handle); - return 0x0; + if (print_job_delete(&user, jobid, &errcode)) { + errcode = 0; } break; case JOB_CONTROL_PAUSE: - if (print_job_pause(&user, jobid)) { - srv_spoolss_sendnotify(handle); - return 0x0; + if (print_job_pause(&user, jobid, &errcode)) { + errcode = 0; } break; + case JOB_CONTROL_RESTART: case JOB_CONTROL_RESUME: - if (print_job_resume(&user, jobid)) { - srv_spoolss_sendnotify(handle); - return 0x0; + if (print_job_resume(&user, jobid, &errcode)) { + errcode = 0; } break; default: return ERROR_INVALID_LEVEL; } - return ERROR_INVALID_HANDLE; + return errcode; } /**************************************************************************** -- cgit From 3adc0e7a4ee71d255d2181a928d6e632664b7f4c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 8 Nov 2000 03:12:16 +0000 Subject: an attempt to get the handling of fields in printer info structures consistent. Still working with Jeremy on this, there is probably more to be done (This used to be commit c4bb9c598cf9781d48bc123a8cbbed9c2049bf89) --- source3/rpc_server/srv_spoolss_nt.c | 67 +++++++++++++------------------------ 1 file changed, 24 insertions(+), 43 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 67b29bdbcf..86c97b33ef 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1103,12 +1103,19 @@ static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, p static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { + /* the notify name should not contain the \\server\ part */ + char *p = strrchr(printer->info_2->printername, '\\'); + if (!p) { + p = printer->info_2->printername; + } else { + p++; + } /* data->notify_data.data.length=strlen(lp_servicename(snum)); dos_PutUniCode(data->notify_data.data.string, lp_servicename(snum), sizeof(data->notify_data.data.string), True); */ data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - printer->info_2->printername, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16)); + p, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -1871,8 +1878,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring */ global_counter=session_counter->counter; - /* the description and the name are of the form \\server\share */ - slprintf(chaine,sizeof(chaine)-1,"\\\\%s\\%s",servername, ntprinter->info_2->printername); + pstrcpy(chaine,ntprinter->info_2->printername); init_unistr(&printer->printername, chaine); @@ -2013,7 +2019,7 @@ static DEVICEMODE *construct_dev_mode(int snum, char *servername) DEBUGADD(8,("loading DEVICEMODE\n")); - snprintf(adevice, sizeof(adevice), "\\\\%s\\%s", global_myname, printer->info_2->printername); + safe_strcpy(adevice, printer->info_2->printername, sizeof(adevice)); init_unistr(&devmode->devicename, adevice); snprintf(aform, sizeof(aform), ntdevmode->formname); @@ -3433,50 +3439,25 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, /******************************************************************** Do Samba sanity checks on a printer info struct. + this has changed purpose: it now "canonicalises" printer + info from a client rather than just checking it is correct ********************************************************************/ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) { - /* - * Ensure that this printer is shared under the correct name - * as this is what Samba insists upon. - */ - - if (!(info->attributes & (PRINTER_ATTRIBUTE_SHARED|PRINTER_ATTRIBUTE_NETWORK))) { - DEBUG(10,("check_printer_ok: SHARED/NETWORK check failed (%x).\n", - (unsigned int)info->attributes )); - return False; - } - - if (!(info->attributes & PRINTER_ATTRIBUTE_RAW_ONLY)) { - /* NT forgets to set the raw attribute but sends the correct type. */ - if (strequal(info->datatype, "RAW")) - info->attributes |= PRINTER_ATTRIBUTE_RAW_ONLY; - else { - DEBUG(10,("check_printer_ok: RAW check failed (%x).\n", (unsigned int)info->attributes )); - return False; - } - } - - /* - * Sometimes the NT client doesn't set the sharename, but - * includes the sharename in the printername. This could - * cause SETPRINTER to fail which causes problems with the - * client getting confused between local/remote printers... - */ - - if (*info->sharename == '\0') { - char *p = strrchr(info->printername, '\\'); - if (p) - fstrcpy(info->sharename, p+1); - } - - if (!strequal(info->sharename, lp_servicename(snum))) { - DEBUG(10,("check_printer_ok: NAME check failed (%s) (%s).\n", - info->sharename, lp_servicename(snum))); - return False; - } + DEBUG(5,("check_printer_ok: servername=%s printername=%s sharename=%s portname=%s drivername=%s comment=%s location=%s\n", + info->servername, info->printername, info->sharename, info->portname, info->drivername, info->comment, info->location)); + /* we force some elements to "correct" values */ + slprintf(info->servername, sizeof(info->servername), "\\\\%s", global_myname); + slprintf(info->printername, sizeof(info->printername), "\\\\%s\\%s", + global_myname, lp_servicename(snum)); + fstrcpy(info->sharename, lp_servicename(snum)); + info->attributes = PRINTER_ATTRIBUTE_SHARED \ + | PRINTER_ATTRIBUTE_LOCAL \ + | PRINTER_ATTRIBUTE_RAW_ONLY \ + | PRINTER_ATTRIBUTE_QUEUED ; + return True; } -- cgit From c1900772ce6fdedc5c380d88f3640107d52e2096 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 10 Nov 2000 19:36:34 +0000 Subject: printing/nt_printing.c: use getpwuid not smbgetpwuid. Canonicalize printernames. printing/printing.c: Insure fix for malloc of zero. rpc_parse/parse_misc.c: Enusre UNISTR's are zero filled. rpc_parse/parse_spoolss.c: Correct INFO_6 - differs between pre-releases of W2K and shipping build. rpc_server/srv_spoolss_nt.c: Canonicalize printernames. Jeremy. (This used to be commit b17e23a8ff2b44540726968355a4b7e26f244f3b) --- source3/rpc_server/srv_spoolss_nt.c | 150 ++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 85 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 86c97b33ef..42f9d29d9c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1588,6 +1588,10 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO current_data=&info->data[info->count]; construct_info_data(current_data, type, field, id); + + DEBUG(10,("construct_notify_printer_info: calling %s\n", + notify_info_data_table[j].name )); + notify_info_data_table[j].fn(snum, current_data, queue, printer); info->count++; @@ -1827,9 +1831,9 @@ uint32 _spoolss_rfnpcnex( POLICY_HND *handle, uint32 change, /******************************************************************** * construct_printer_info_0 - * fill a printer_info_1 struct + * fill a printer_info_0 struct ********************************************************************/ -static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring servername) +static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) { pstring chaine; int count; @@ -1882,7 +1886,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring init_unistr(&printer->printername, chaine); - slprintf(chaine,sizeof(chaine)-1,"\\\\%s", servername); + slprintf(chaine,sizeof(chaine)-1,"\\\\%s", global_myname); init_unistr(&printer->servername, chaine); printer->cjobs = count; @@ -1938,7 +1942,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum, fstring * construct_printer_info_1 * fill a printer_info_1 struct ********************************************************************/ -static BOOL construct_printer_info_1(fstring server, uint32 flags, PRINTER_INFO_1 *printer, int snum) +static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int snum) { pstring chaine; pstring chaine2; @@ -1951,16 +1955,16 @@ static BOOL construct_printer_info_1(fstring server, uint32 flags, PRINTER_INFO_ if (*ntprinter->info_2->comment == '\0') { init_unistr(&printer->comment, lp_comment(snum)); - snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",server, ntprinter->info_2->printername, + snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",global_myname, ntprinter->info_2->printername, ntprinter->info_2->drivername, lp_comment(snum)); } else { init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ - snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",server, ntprinter->info_2->printername, + snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",global_myname, ntprinter->info_2->printername, ntprinter->info_2->drivername, ntprinter->info_2->comment); } - snprintf(chaine2,sizeof(chaine)-1,"%s%s", server, ntprinter->info_2->printername); + snprintf(chaine2,sizeof(chaine)-1,"%s", ntprinter->info_2->printername); init_unistr(&printer->description, chaine); init_unistr(&printer->name, chaine2); @@ -1989,7 +1993,7 @@ static void free_dev_mode(DEVICEMODE *dev) Create a DEVMODE struct. Returns malloced memory. ****************************************************************************/ -static DEVICEMODE *construct_dev_mode(int snum, char *servername) +static DEVICEMODE *construct_dev_mode(int snum) { char adevice[32]; char aform[32]; @@ -2075,11 +2079,8 @@ static DEVICEMODE *construct_dev_mode(int snum, char *servername) * fill a printer_info_2 struct ********************************************************************/ -static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer, int snum) +static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum) { - pstring chaine; - pstring chaine2; - pstring sl; int count; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; @@ -2093,21 +2094,8 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer memset(&status, 0, sizeof(status)); count = print_queue_status(snum, &queue, &status); - snprintf(chaine, sizeof(chaine)-1, "%s", servername); - - if (strlen(servername)!=0) - fstrcpy(sl, "\\"); - else - fstrcpy(sl, '\0'); - - if (!strchr(ntprinter->info_2->printername, '\\')) { - snprintf(chaine2, sizeof(chaine)-1, "%s%s%s", servername, sl, ntprinter->info_2->printername); - } else { - pstrcpy(chaine2, ntprinter->info_2->printername); - } - - init_unistr(&printer->servername, chaine); /* servername*/ - init_unistr(&printer->printername, chaine2); /* printername*/ + init_unistr(&printer->servername, ntprinter->info_2->servername); /* servername*/ + init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/ init_unistr(&printer->sharename, lp_servicename(snum)); /* sharename */ init_unistr(&printer->portname, ntprinter->info_2->portname); /* port */ init_unistr(&printer->drivername, ntprinter->info_2->drivername); /* drivername */ @@ -2133,7 +2121,7 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer printer->cjobs = count; /* jobs */ printer->averageppm = ntprinter->info_2->averageppm; /* average pages per minute */ - if((printer->devmode = construct_dev_mode(snum, servername)) == NULL) { + if((printer->devmode = construct_dev_mode(snum)) == NULL) { DEBUG(8, ("Returning NULL Devicemode!\n")); } @@ -2157,8 +2145,7 @@ static BOOL construct_printer_info_2(fstring servername, PRINTER_INFO_2 *printer * construct_printer_info_3 * fill a printer_info_3 struct ********************************************************************/ -static BOOL construct_printer_info_3(fstring servername, - PRINTER_INFO_3 **pp_printer, int snum) +static BOOL construct_printer_info_3(PRINTER_INFO_3 **pp_printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; PRINTER_INFO_3 *printer = NULL; @@ -2211,7 +2198,7 @@ static BOOL construct_printer_info_3(fstring servername, /******************************************************************** Spoolss_enumprinters. ********************************************************************/ -static BOOL enum_all_printers_info_1(fstring server, uint32 flags, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int snum; int i; @@ -2225,7 +2212,7 @@ static BOOL enum_all_printers_info_1(fstring server, uint32 flags, NEW_BUFFER *b if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); - if (construct_printer_info_1(server, flags, ¤t_prt, snum)) { + if (construct_printer_info_1(flags, ¤t_prt, snum)) { if((printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) { *returned=0; return ERROR_NOT_ENOUGH_MEMORY; @@ -2262,20 +2249,11 @@ static BOOL enum_all_printers_info_1(fstring server, uint32 flags, NEW_BUFFER *b /******************************************************************** enum_all_printers_info_1_local. *********************************************************************/ -static BOOL enum_all_printers_info_1_local(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static BOOL enum_all_printers_info_1_local(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - fstring temp; DEBUG(4,("enum_all_printers_info_1_local\n")); - fstrcpy(temp, "\\\\"); - fstrcat(temp, global_myname); - - if (!strcmp(name, temp)) { - fstrcat(temp, "\\"); - return enum_all_printers_info_1(temp, PRINTER_ENUM_ICON8, buffer, offered, needed, returned); - } - else - return enum_all_printers_info_1("", PRINTER_ENUM_ICON8, buffer, offered, needed, returned); + return enum_all_printers_info_1(PRINTER_ENUM_ICON8, buffer, offered, needed, returned); } /******************************************************************** @@ -2289,9 +2267,8 @@ static BOOL enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, uint fstrcpy(temp, "\\\\"); fstrcat(temp, global_myname); - if (!strcmp(name, temp)) { - fstrcat(temp, "\\"); - return enum_all_printers_info_1(temp, PRINTER_ENUM_ICON8, buffer, offered, needed, returned); + if (strequal(name, temp)) { + return enum_all_printers_info_1(PRINTER_ENUM_ICON8, buffer, offered, needed, returned); } else return ERROR_INVALID_NAME; @@ -2354,15 +2331,11 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui /******************************************************************** enum_all_printers_info_1_network. *********************************************************************/ -static BOOL enum_all_printers_info_1_network(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static BOOL enum_all_printers_info_1_network(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - fstring temp; DEBUG(4,("enum_all_printers_info_1_network\n")); - fstrcpy(temp, "\\\\"); - fstrcat(temp, global_myname); - fstrcat(temp, "\\"); - return enum_all_printers_info_1(temp, PRINTER_ENUM_UNKNOWN_8, buffer, offered, needed, returned); + return enum_all_printers_info_1(PRINTER_ENUM_UNKNOWN_8, buffer, offered, needed, returned); } /******************************************************************** @@ -2370,7 +2343,7 @@ static BOOL enum_all_printers_info_1_network(fstring name, NEW_BUFFER *buffer, u * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -static BOOL enum_all_printers_info_2(fstring servername, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int snum; int i; @@ -2382,7 +2355,7 @@ static BOOL enum_all_printers_info_2(fstring servername, NEW_BUFFER *buffer, uin if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); - if (construct_printer_info_2(servername, ¤t_prt, snum)) { + if (construct_printer_info_2(¤t_prt, snum)) { if((printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2))) == NULL) return ERROR_NOT_ENOUGH_MEMORY; DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *returned)); @@ -2434,7 +2407,7 @@ static uint32 enumprinters_level1( uint32 flags, fstring name, /* Not all the flags are equals */ if (flags & PRINTER_ENUM_LOCAL) - return enum_all_printers_info_1_local(name, buffer, offered, needed, returned); + return enum_all_printers_info_1_local(buffer, offered, needed, returned); if (flags & PRINTER_ENUM_NAME) return enum_all_printers_info_1_name(name, buffer, offered, needed, returned); @@ -2443,7 +2416,7 @@ static uint32 enumprinters_level1( uint32 flags, fstring name, return enum_all_printers_info_1_remote(name, buffer, offered, needed, returned); if (flags & PRINTER_ENUM_NETWORK) - return enum_all_printers_info_1_network(name, buffer, offered, needed, returned); + return enum_all_printers_info_1_network(buffer, offered, needed, returned); return NT_STATUS_NO_PROBLEMO; /* NT4sp5 does that */ } @@ -2461,15 +2434,15 @@ static uint32 enumprinters_level2( uint32 flags, fstring servername, fstrcat(temp, global_myname); if (flags & PRINTER_ENUM_LOCAL) { - if (!strcmp(servername, temp)) - return enum_all_printers_info_2(temp, buffer, offered, needed, returned); + if (strequal(servername, temp)) + return enum_all_printers_info_2(buffer, offered, needed, returned); else - return enum_all_printers_info_2("", buffer, offered, needed, returned); + return enum_all_printers_info_2(buffer, offered, needed, returned); } if (flags & PRINTER_ENUM_NAME) { - if (!strcmp(servername, temp)) - return enum_all_printers_info_2(temp, buffer, offered, needed, returned); + if (strequal(servername, temp)) + return enum_all_printers_info_2(buffer, offered, needed, returned); else return ERROR_INVALID_NAME; } @@ -2539,14 +2512,14 @@ uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 le /**************************************************************************** ****************************************************************************/ -static uint32 getprinter_level_0(fstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static uint32 getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_0 *printer=NULL; if((printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0))) == NULL) return ERROR_NOT_ENOUGH_MEMORY; - construct_printer_info_0(printer, snum, servername); + construct_printer_info_0(printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_0(printer); @@ -2571,14 +2544,14 @@ static uint32 getprinter_level_0(fstring servername, int snum, NEW_BUFFER *buffe /**************************************************************************** ****************************************************************************/ -static uint32 getprinter_level_1(fstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static uint32 getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_1 *printer=NULL; if((printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1))) == NULL) return ERROR_NOT_ENOUGH_MEMORY; - construct_printer_info_1(servername, PRINTER_ENUM_ICON8, printer, snum); + construct_printer_info_1(PRINTER_ENUM_ICON8, printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_1(printer); @@ -2603,17 +2576,14 @@ static uint32 getprinter_level_1(fstring servername, int snum, NEW_BUFFER *buffe /**************************************************************************** ****************************************************************************/ -static uint32 getprinter_level_2(fstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static uint32 getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_2 *printer=NULL; - fstring temp; if((printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)))==NULL) return ERROR_NOT_ENOUGH_MEMORY; - fstrcpy(temp, "\\\\"); - fstrcat(temp, servername); - construct_printer_info_2(temp, printer, snum); + construct_printer_info_2(printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_2(printer); @@ -2641,14 +2611,12 @@ static uint32 getprinter_level_2(fstring servername, int snum, NEW_BUFFER *buffe /**************************************************************************** ****************************************************************************/ -static uint32 getprinter_level_3(fstring servername, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static uint32 getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_3 *printer=NULL; fstring temp; - fstrcpy(temp, "\\\\"); - fstrcat(temp, servername); - if (!construct_printer_info_3(temp, &printer, snum)) + if (!construct_printer_info_3(&printer, snum)) return ERROR_NOT_ENOUGH_MEMORY; /* check the required size. */ @@ -2678,24 +2646,21 @@ uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { int snum; - fstring servername; *needed=0; - pstrcpy(servername, global_myname); - if (!get_printer_snum(handle, &snum)) return ERROR_INVALID_HANDLE; switch (level) { case 0: - return getprinter_level_0(servername, snum, buffer, offered, needed); + return getprinter_level_0(snum, buffer, offered, needed); case 1: - return getprinter_level_1(servername,snum, buffer, offered, needed); + return getprinter_level_1(snum, buffer, offered, needed); case 2: - return getprinter_level_2(servername,snum, buffer, offered, needed); + return getprinter_level_2(snum, buffer, offered, needed); case 3: - return getprinter_level_3(servername,snum, buffer, offered, needed); + return getprinter_level_3(snum, buffer, offered, needed); default: return ERROR_INVALID_LEVEL; } @@ -2963,8 +2928,23 @@ static uint32 construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fst status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); DEBUG(8,("construct_printer_driver_info_6: status: %d\n", status)); if (status != 0) { - free_a_printer(&printer,2); - return ERROR_UNKNOWN_PRINTER_DRIVER; + /* + * Is this a W2k client ? + */ + + if (version < 3) { + free_a_printer(&printer,2); + return ERROR_UNKNOWN_PRINTER_DRIVER; + } + + /* Yes - try again with a WinNT driver. */ + version = 2; + status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); + DEBUG(8,("construct_printer_driver_info_6: status: %d\n", status)); + if (status != 0) { + free_a_printer(&printer,2); + return ERROR_UNKNOWN_PRINTER_DRIVER; + } } fill_printer_driver_info_6(info, driver, servername); @@ -3747,7 +3727,7 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, */ convert_printer_info(info, printer, level); - + if (info->info_2->devmode_ptr != 0) { /* we have a valid devmode convert it and link it*/ @@ -3963,7 +3943,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, job_info->timeelapsed=0; job_info->pagesprinted=0; - if((job_info->devmode = construct_dev_mode(snum, global_myname)) == NULL) { + if((job_info->devmode = construct_dev_mode(snum)) == NULL) { free_a_printer(&ntprinter, 2); return False; } -- cgit From 9fede0dc0dbad51528cd1384023d24549c3f0ba4 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 13 Nov 2000 23:03:34 +0000 Subject: Large commit which restructures the local password storage API. Currently the only backend which works is smbpasswd (tdb, LDAP, and NIS+) are broken, but they were somewhat broken before. :) The following functions implement the storage manipulation interface /*The following definitions come from passdb/pdb_smbpasswd.c */ BOOL pdb_setsampwent (BOOL update); void pdb_endsampwent (void); SAM_ACCOUNT* pdb_getsampwent (void); SAM_ACCOUNT* pdb_getsampwnam (char *username); SAM_ACCOUNT* pdb_getsampwuid (uid_t uid); SAM_ACCOUNT* pdb_getsampwrid (uint32 rid); BOOL pdb_add_sam_account (SAM_ACCOUNT *sampass); BOOL pdb_update_sam_account (SAM_ACCOUNT *sampass, BOOL override); BOOL pdb_delete_sam_account (char* username); There is also a host of pdb_set..() and pdb_get..() functions for manipulating SAM_ACCOUNT struct members. Note that the struct passdb_ops {} has gone away. Also notice that struct smb_passwd (formally in smb.h) has been moved to passdb/pdb_smbpasswd.c and is not accessed outisde of static internal functions in this file. All local password searches should make use of the the SAM_ACCOUNT struct and the previously mentioned functions. I'll write some documentation for this later. The next step is to fix the TDB passdb backend, then work on spliting the backends out into share libraries, and finally get the LDAP backend going. What works and may not: o domain logons from Win9x works o domain logons from WinNT 4 works o user and group enumeration as implemented by Tim works o file and print access works o changing password from Win9x & NT ummm...i'll fix this tonight :) If I broke anything else, just yell and I'll fix it. I think it should be fairly quite. -- jerry (This used to be commit 0b92d0838ebdbe24f34f17e313ecbf61a0301389) --- source3/rpc_server/srv_lookup.c | 14 +- source3/rpc_server/srv_netlog.c | 177 ++++++++++++------------- source3/rpc_server/srv_pipe.c | 33 ++--- source3/rpc_server/srv_samr.c | 279 ++++++++++++++++++---------------------- source3/rpc_server/srv_util.c | 8 +- 5 files changed, 234 insertions(+), 277 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c index e81f3051f3..8b29be62e7 100644 --- a/source3/rpc_server/srv_lookup.c +++ b/source3/rpc_server/srv_lookup.c @@ -532,19 +532,19 @@ uint32 lookup_sid(char *name, DOM_SID *sid, uint8 *type) uint32 lookup_added_user_rids(char *user_name, uint32 *usr_rid, uint32 *grp_rid) { - struct sam_passwd *sam_pass; + SAM_ACCOUNT *sam_pass; (*usr_rid) = 0; (*grp_rid) = 0; /* find the user account */ become_root(); - sam_pass = getsam21pwnam(user_name); + sam_pass = getsampwnam(user_name); unbecome_root(); if (sam_pass != NULL) { - (*usr_rid) = sam_pass->user_rid ; - (*grp_rid) = sam_pass->group_rid; + (*usr_rid) = pdb_get_user_rid(sam_pass); + (*grp_rid) = pdb_get_group_rid(sam_pass); return 0x0; } @@ -556,18 +556,18 @@ uint32 lookup_added_user_rids(char *user_name, ********************************************************************/ uint32 lookup_added_user_rid(char *user_name, uint32 *rid, uint8 *type) { - struct sam_passwd *sam_pass; + SAM_ACCOUNT *sam_pass; (*rid) = 0; (*type) = SID_NAME_USER; /* find the user account */ become_root(); - sam_pass = getsam21pwnam(user_name); + sam_pass = getsampwnam(user_name); unbecome_root(); if (sam_pass != NULL) { - (*rid) = sam_pass->user_rid; + (*rid) = pdb_get_user_rid(sam_pass); return 0x0; } diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 9f5d84ee1f..8e2b3819cb 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -264,7 +264,8 @@ static BOOL net_reply_sam_logoff(NET_Q_SAM_LOGOFF *q_s, prs_struct *rdata, static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) { - struct smb_passwd *smb_pass; + SAM_ACCOUNT *sampass = NULL; + BYTE *pass = NULL; #if 0 /* @@ -285,13 +286,13 @@ static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) #endif /* 0 */ become_root(); - smb_pass = getsmbpwnam(mach_acct); + sampass = pdb_getsampwnam(mach_acct); unbecome_root(); - if ((smb_pass) != NULL && !(smb_pass->acct_ctrl & ACB_DISABLED) && - (smb_pass->smb_nt_passwd != NULL)) + if ((sampass) != NULL && !(pdb_get_acct_ctrl(sampass) & ACB_DISABLED) && + ((pass=pdb_get_nt_passwd(sampass)) != NULL)) { - memcpy(md4pw, smb_pass->smb_nt_passwd, 16); + memcpy(md4pw, pass, 16); dump_data(5, md4pw, 16); return True; @@ -425,7 +426,7 @@ static BOOL api_net_srv_pwset(pipes_struct *p) uint32 status = NT_STATUS_WRONG_PASSWORD; DOM_CRED srv_cred; pstring mach_acct; - struct smb_passwd *smb_pass; + SAM_ACCOUNT *sampass; BOOL ret; user_struct *vuser; prs_struct *data = &p->in_data.data; @@ -454,10 +455,10 @@ static BOOL api_net_srv_pwset(pipes_struct *p) DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); become_root(); - smb_pass = getsmbpwnam(mach_acct); + sampass = pdb_getsampwnam(mach_acct); unbecome_root(); - if (smb_pass != NULL) { + if (sampass != NULL) { unsigned char pwd[16]; int i; @@ -469,12 +470,12 @@ static BOOL api_net_srv_pwset(pipes_struct *p) cred_hash3( pwd, q_a.pwd, vuser->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; + pdb_set_lanman_passwd (sampass, pwd); + pdb_set_nt_passwd (sampass, pwd); + pdb_set_acct_ctrl (sampass, ACB_WSTRUST); - become_root(); - ret = mod_smbpwd_entry(smb_pass,False); + become_root(); + ret = pdb_update_sam_account (sampass,False); unbecome_root(); if (ret) { @@ -542,8 +543,8 @@ static BOOL api_net_sam_logoff(pipes_struct *p) net_login_interactive: *************************************************************************/ -static uint32 net_login_interactive(NET_ID_INFO_1 *id1, struct smb_passwd *smb_pass, - user_struct *vuser) +static uint32 net_login_interactive(NET_ID_INFO_1 *id1, SAM_ACCOUNT *sampass, + user_struct *vuser) { uint32 status = 0x0; @@ -579,8 +580,8 @@ 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) + if (memcmp(pdb_get_lanman_passwd(sampass) ,lm_pwd, 16) != 0 || + memcmp(pdb_get_nt_passwd(sampass) ,nt_pwd, 16) != 0) { status = NT_STATUS_WRONG_PASSWORD; } @@ -592,8 +593,10 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, struct smb_passwd *smb_p 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) { + BYTE *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)); @@ -601,11 +604,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. */ + nt_pwd = pdb_get_nt_passwd (sampass); + lanman_pwd = pdb_get_lanman_passwd (sampass); if (id2->hdr_nt_chal_resp.str_str_len == 24 && - smb_pass->smb_nt_passwd != NULL) + nt_pwd != NULL) { - if(smb_password_check((char *)id2->nt_chal_resp.buffer, - smb_pass->smb_nt_passwd, + if(smb_password_check((char *)id2->nt_chal_resp.buffer, nt_pwd, id2->lm_chal)) return 0x0; else @@ -622,8 +626,7 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, struct smb_passwd *smb_pass) if (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 0x0; } @@ -646,21 +649,20 @@ static BOOL api_net_sam_logon(pipes_struct *p) NET_USER_INFO_3 usr_info; uint32 status = 0x0; DOM_CRED srv_cred; - struct smb_passwd *smb_pass = NULL; + SAM_ACCOUNT *sampass = NULL; + uint16 acct_ctrl; UNISTR2 *uni_samlogon_user = NULL; fstring nt_username; - struct passwd *pw; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; user_struct *vuser = NULL; if ((vuser = get_valid_user_struct(vuid)) == NULL) return False; - memset(&q_l, '\0', sizeof(q_l)); - memset(&ctr, '\0', sizeof(ctr)); - memset(&usr_info, '\0', sizeof(usr_info)); + ZERO_STRUCT(q_l); + ZERO_STRUCT(ctr); + ZERO_STRUCT(usr_info); q_l.sam_id.ctr = &ctr; @@ -682,8 +684,7 @@ static BOOL api_net_sam_logon(pipes_struct *p) case INTERACTIVE_LOGON_TYPE: uni_samlogon_user = &q_l.sam_id.ctr->auth.id1.uni_user_name; - DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", - lp_workgroup())); + DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); break; case NET_LOGON_TYPE: uni_samlogon_user = &q_l.sam_id.ctr->auth.id2.uni_user_name; @@ -699,7 +700,8 @@ static BOOL api_net_sam_logon(pipes_struct *p) /* check username exists */ - if (status == 0) { + if (status == 0) + { pstrcpy(nt_username, dos_unistrn2(uni_samlogon_user->buffer, uni_samlogon_user->uni_str_len)); @@ -709,40 +711,37 @@ static BOOL api_net_sam_logon(pipes_struct *p) * Convert to a UNIX username. */ map_username(nt_username); - - /* - * Do any case conversions. - */ - pw=Get_Pwnam(nt_username, True); + /* get the account information */ become_root(); - smb_pass = getsmbpwnam(nt_username); + sampass = pdb_getsampwnam(nt_username); unbecome_root(); - if (smb_pass == NULL) + acct_ctrl = pdb_get_acct_ctrl(sampass); + if (sampass == NULL) status = NT_STATUS_NO_SUCH_USER; - else if (smb_pass->acct_ctrl & ACB_PWNOTREQ) + else if (acct_ctrl & ACB_PWNOTREQ) status = 0; - else if (smb_pass->acct_ctrl & ACB_DISABLED) + else if (acct_ctrl & ACB_DISABLED) status = NT_STATUS_ACCOUNT_DISABLED; } /* Validate password - if required. */ - if ((status == 0) && !(smb_pass->acct_ctrl & ACB_PWNOTREQ)) { + if ((status == 0) && !(acct_ctrl & ACB_PWNOTREQ)) { switch (q_l.sam_id.logon_level) { case INTERACTIVE_LOGON_TYPE: /* interactive login. */ status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, - smb_pass, vuser); + sampass, vuser); break; case NET_LOGON_TYPE: /* network login. lm challenge and 24 byte responses */ - status = net_login_network(&q_l.sam_id.ctr->auth.id2, smb_pass); + status = net_login_network(&q_l.sam_id.ctr->auth.id2, sampass); break; } } - + /* 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. @@ -753,49 +752,47 @@ static BOOL api_net_sam_logon(pipes_struct *p) if (status == 0) { DOM_GID *gids = NULL; int num_gids = 0; - NTTIME dummy_time; - pstring logon_script; - pstring profile_path; - pstring home_dir; - pstring home_drive; pstring my_name; pstring my_workgroup; pstring domain_groups; - uint32 r_uid; - uint32 r_gid; - fstring full_name; /* set up pointer indicating user/password failed to be found */ usr_info.ptr_user_info = 0; - - dummy_time.low = 0xffffffff; - dummy_time.high = 0x7fffffff; - + /* XXXX hack to get standard_sub_basic() to use sam logon username */ /* possibly a better way would be to do a become_user() call */ + + /* + * All this information should be filled in from the + * passdb information + */ sam_logon_in_ssb = True; pstrcpy(samlogon_user, nt_username); - pstrcpy(logon_script, lp_logon_script()); - standard_sub_advanced(-1, nt_username, "", pw->pw_gid, logon_script); +#if 0 + gid = pdb_get_gid(sampass); - pstrcpy(profile_path, lp_logon_path()); - standard_sub_advanced(-1, nt_username, "", pw->pw_gid, profile_path); - - pstrcpy(my_workgroup, lp_workgroup()); + pstrcpy(str, pdb_get_logon_script(sampass)); + standard_sub_advanced(-1, nt_username, "", gid, str); + pdb_set_logon_script(sampass, str); + + pstrcpy(str, pdb_get_profile_path(sampass)); + standard_sub_advanced(-1, nt_username, "", gid, str); + pdb_set_profile_path(sampass, str); + + pstrcpy(str, pdb_get_homedir(sampass)); + standard_sub_advanced(-1, nt_username, "", gid, str); + pdb_set_homedir(sampass, str); - pstrcpy(home_drive, lp_logon_drive()); - standard_sub_advanced(-1, nt_username, "", pw->pw_gid, home_drive); + fstrcpy(full_name, ""); + if (lp_unix_realname()) + fstrcpy(full_name, pdb_get_fullname(sampass)); +#endif - pstrcpy(home_dir, lp_logon_home()); - standard_sub_advanced(-1, nt_username, "", pw->pw_gid, home_dir); - + pstrcpy(my_workgroup, lp_workgroup()); pstrcpy(my_name, global_myname); strupper(my_name); - fstrcpy(full_name, ""); - if (lp_unix_realname()) - fstrcpy(full_name, pw->pw_gecos); /* * This is the point at which we get the group @@ -815,40 +812,32 @@ static BOOL api_net_sam_logon(pipes_struct *p) sam_logon_in_ssb = False; + /* + * This next call is where the 'domain admin users' parameter + * gets mapped. I'm leaving it out for now. The user and group rid + * has already been mapped into the SAM_ACCOUNT struct. I don't + * think this should be overridden here. The correct solution + * is proper group memberships and mapping. --jerry + */ +#if 0 if (pdb_name_to_rid(nt_username, &r_uid, &r_gid)) - init_net_user_info3(&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 */ - full_name, /* full_name */ - logon_script , /* logon_script */ - profile_path , /* profile_path */ - home_dir , /* home_dir */ - home_drive , /* dir_drive */ - +#endif + init_net_user_info3(&usr_info, sampass, 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 */ + +#if 0 else status = NT_STATUS_NO_SUCH_USER; +#endif /* Free any allocated groups array. */ if(gids) diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 4cb57c69d8..d15f045252 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -270,10 +270,9 @@ 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; - uchar null_smb_passwd[16]; - uchar *smb_passwd_ptr = NULL; + SAM_ACCOUNT *sam_pass = NULL; + BYTE null_smb_passwd[16]; + BYTE *smb_passwd_ptr = NULL; DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); @@ -359,7 +358,8 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm return False; } - +/* unnecessary as the passdb validates the user before returning --jerry */ +#if 0 /* * Find the user in the unix password db. */ @@ -369,6 +369,8 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm return(False); } +#endif /* 0 */ + if(!guest_user) { become_root(); @@ -381,8 +383,8 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name return False; } - if(!(smb_pass = getsmbpwnam(pipe_user_name))) { - DEBUG(1,("api_pipe_ntlmssp_verify: Cannot find user %s in smb passwd database.\n", + if(!(sam_pass = pdb_getsampwnam(pipe_user_name))) { + DEBUG(1,("api_pipe_ntlmssp_verify: Cannot find user %s in passdb.\n", pipe_user_name)); unbecome_root(); return False; @@ -390,24 +392,24 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name unbecome_root(); - if (smb_pass == NULL) { - DEBUG(1,("api_pipe_ntlmssp_verify: Couldn't find user '%s' in smb_passwd file.\n", + if (sam_pass == NULL) { + DEBUG(1,("api_pipe_ntlmssp_verify: Couldn't find user '%s' in passdb.\n", pipe_user_name)); return(False); } /* Quit if the account was disabled. */ - if((smb_pass->acct_ctrl & ACB_DISABLED) || !smb_pass->smb_passwd) { + if((pdb_get_acct_ctrl(sam_pass) & ACB_DISABLED) || !pdb_get_lanman_passwd(sam_pass)) { DEBUG(1,("Account for user '%s' was disabled.\n", pipe_user_name)); return(False); } - if(!smb_pass->smb_nt_passwd) { + if(!pdb_get_nt_passwd(sam_pass)) { DEBUG(1,("Account for user '%s' has no NT password hash.\n", pipe_user_name)); return(False); } - smb_passwd_ptr = smb_pass->smb_passwd; + smb_passwd_ptr = pdb_get_lanman_passwd(sam_pass); } /* @@ -457,9 +459,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(sam_pass); + p->pipe_user.gid = pdb_get_gid(sam_pass); /* Set up pipe user group membership. */ initialise_groups(pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); @@ -467,7 +468,7 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name /* Create an NT_USER_TOKEN struct for this user. */ p->pipe_user.nt_user_token = create_nt_token(p->pipe_user.uid,p->pipe_user.gid, - p->pipe_user.ngroups, p->pipe_user.groups); + p->pipe_user.ngroups, p->pipe_user.groups); p->ntlmssp_auth_validated = True; return True; diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 72a86c8d80..dcb5b9c9e3 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -40,27 +40,26 @@ extern rid_name builtin_alias_rids[]; dynamically returns the correct user info..... JRA. ********************************************************************/ -static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, - int start_idx, +static BOOL 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) + int max_num_entries, uint16 acb_mask) { - void *vp = NULL; - struct sam_passwd *pwd = NULL; + SAM_ACCOUNT *pwd = NULL; (*num_entries) = 0; (*total_entries) = 0; - if (pw_buf == NULL) return False; + if (pw_buf == NULL) + return False; - vp = startsmbpwent(False); - if (!vp) { - DEBUG(0, ("get_sampwd_entries: Unable to open SMB password database.\n")); + if (!pdb_setsampwent(False)) + { + DEBUG(0, ("get_sampwd_entries: Unable to open passdb.\n")); return False; } - while (((pwd = getsam21pwent(vp)) != NULL) && (*num_entries) < max_num_entries) { + while ( ((pwd=pdb_getsampwent()) != NULL) && ((*num_entries) < max_num_entries) ) + { int user_name_len; if (start_idx > 0) { @@ -71,34 +70,38 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, continue; } - user_name_len = strlen(pwd->smb_name)+1; - init_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->smb_name, user_name_len); + 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; + 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) != NULL) + { + 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)); + (*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)) { + if (acb_mask == 0 || (pdb_get_acct_ctrl(pwd) & acb_mask)) + { DEBUG(5,(" acb_mask %x accepts\n", acb_mask)); (*num_entries)++; - } else { + } + else + { DEBUG(5,(" acb_mask %x rejects\n", acb_mask)); } (*total_entries)++; } - endsmbpwent(vp); + pdb_endsampwent(); return (*num_entries) > 0; } @@ -1046,7 +1049,7 @@ static BOOL samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, for (i = 0; i < num_rids && status == 0; i++) { - struct sam_passwd *sam_pass; + SAM_ACCOUNT *sam_pass; fstring user_name; @@ -1055,7 +1058,7 @@ static BOOL samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, /* find the user account */ become_root(); - sam_pass = get_smb21pwd_entry(user_name, 0); + sam_pass = pdb_getsampwnam(user_name); unbecome_root(); if (sam_pass == NULL) @@ -1065,7 +1068,7 @@ static BOOL samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, } else { - rid[i] = sam_pass->user_rid; + rid[i] = pdb_get_user_rid(sam_pass); } } #endif @@ -1379,7 +1382,7 @@ static BOOL api_samr_lookup_rids(pipes_struct *p) ********************************************************************/ static uint32 _api_samr_open_user(POLICY_HND domain_pol, uint32 user_rid, POLICY_HND *user_pol) { - struct sam_passwd *sam_pass; + SAM_ACCOUNT *sam_pass; DOM_SID sid; /* find the domain policy handle. */ @@ -1391,7 +1394,7 @@ static uint32 _api_samr_open_user(POLICY_HND domain_pol, uint32 user_rid, POLICY return NT_STATUS_OBJECT_NAME_NOT_FOUND; become_root(); - sam_pass = getsam21pwrid(user_rid); + sam_pass = pdb_getsampwrid(user_rid); unbecome_root(); /* check that the RID exists in our domain. */ @@ -1455,7 +1458,7 @@ static BOOL api_samr_open_user(pipes_struct *p) *************************************************************************/ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) { - struct smb_passwd *smb_pass; + SAM_ACCOUNT *sampass; if (!pdb_rid_is_user(user_rid)) { @@ -1464,18 +1467,18 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) } become_root(); - smb_pass = getsmbpwrid(user_rid); + sampass = pdb_getsampwrid(user_rid); unbecome_root(); - if (smb_pass == NULL) + if (sampass == NULL) { DEBUG(4,("User 0x%x not found\n", user_rid)); return False; } - DEBUG(3,("User:[%s]\n", smb_pass->smb_name)); + DEBUG(3,("User:[%s]\n", pdb_get_username(sampass))); - init_sam_user_info10(id10, smb_pass->acct_ctrl); + init_sam_user_info10(id10, pdb_get_acct_ctrl(sampass)); return True; } @@ -1485,10 +1488,7 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) *************************************************************************/ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) { - NTTIME dummy_time; - struct sam_passwd *sam_pass; - LOGON_HRS hrs; - int i; + SAM_ACCOUNT *sam_pass; if (!pdb_rid_is_user(user_rid)) { @@ -1497,7 +1497,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) } become_root(); - sam_pass = getsam21pwrid(user_rid); + sam_pass = pdb_getsampwrid(user_rid); unbecome_root(); if (sam_pass == NULL) @@ -1506,50 +1506,9 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) return False; } - DEBUG(3,("User:[%s]\n", sam_pass->smb_name)); - - dummy_time.low = 0xffffffff; - dummy_time.high = 0x7fffffff; - - DEBUG(5,("get_user_info_21 - TODO: convert unix times to NTTIMEs\n")); + DEBUG(3,("User:[%s]\n", pdb_get_username(sam_pass))); - /* 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]; - } - - init_sam_user_info21(id21, - - &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 */ - - 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 */ - - sam_pass->user_rid, /* RID user_id */ - sam_pass->group_rid, /* RID group_id */ - sam_pass->acct_ctrl, - - sam_pass->unknown_3, /* unknown_3 */ - sam_pass->logon_divs, /* divisions per week */ - &hrs, /* logon hours */ - sam_pass->unknown_5, - sam_pass->unknown_6); + init_sam_user_info21(id21, sam_pass); return True; } @@ -1670,7 +1629,7 @@ static BOOL samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, SAMR_R_QUERY_USERGROUPS r_u; uint32 status = 0x0; - struct sam_passwd *sam_pass; + SAM_ACCOUNT *sam_pass; DOM_GID *gids = NULL; int num_groups = 0; uint32 rid; @@ -1692,7 +1651,7 @@ static BOOL samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, if (status == 0x0) { become_root(); - sam_pass = getsam21pwrid(rid); + sam_pass = pdb_getsampwrid(rid); unbecome_root(); if (sam_pass == NULL) @@ -1704,7 +1663,7 @@ static BOOL samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, if (status == 0x0) { pstring groups; - get_domain_user_groups(groups, sam_pass->smb_name); + get_domain_user_groups(groups, pdb_get_username(sam_pass)); gids = NULL; num_groups = make_dom_gids(groups, &gids); } @@ -1828,7 +1787,7 @@ static BOOL api_samr_query_dom_info(pipes_struct *p) static BOOL _api_samr_create_user(POLICY_HND dom_pol, UNISTR2 user_account, uint32 acb_info, uint32 access_mask, POLICY_HND *user_pol, uint32 *unknown0, uint32 *user_rid) { - struct sam_passwd *sam_pass; + SAM_ACCOUNT *sam_pass; fstring mach_acct; pstring err_str; pstring msg_str; @@ -1849,9 +1808,10 @@ static BOOL _api_samr_create_user(POLICY_HND dom_pol, UNISTR2 user_account, uint strlower(mach_acct); become_root(); - sam_pass = getsam21pwnam(mach_acct); + sam_pass = pdb_getsampwnam(mach_acct); unbecome_root(); - if (sam_pass != NULL) { + if (sam_pass != NULL) + { /* machine account exists: say so */ return NT_STATUS_USER_EXISTS; } @@ -1875,14 +1835,16 @@ static BOOL _api_samr_create_user(POLICY_HND dom_pol, UNISTR2 user_account, uint smb_create_user(mach_acct); /* 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))) { + 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)); close_lsa_policy_hnd(user_pol); return NT_STATUS_ACCESS_DENIED; } become_root(); - sam_pass = getsam21pwnam(mach_acct); + sam_pass = pdb_getsampwnam(mach_acct); unbecome_root(); if (sam_pass == NULL) { /* account doesn't exist: say so */ @@ -1909,8 +1871,8 @@ static BOOL _api_samr_create_user(POLICY_HND dom_pol, UNISTR2 user_account, uint return NT_STATUS_OBJECT_NAME_NOT_FOUND; } - *unknown0=0x000703ff; - *user_rid=sam_pass->user_rid; + *unknown0 = 0x000703ff; + *user_rid = pdb_get_user_rid(sam_pass); return NT_STATUS_NO_PROBLEMO; } @@ -2219,8 +2181,7 @@ static BOOL api_samr_open_alias(pipes_struct *p) ********************************************************************/ 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 = pdb_getsampwrid(rid); if (id10 == NULL) { DEBUG(5, ("set_user_info_10: NULL id10\n")); @@ -2230,11 +2191,9 @@ static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, uint32 rid) if (pwd == NULL) return False; - copy_sam_passwd(&new_pwd, pwd); + pdb_set_acct_ctrl(pwd, id10->acb_info); - new_pwd.acct_ctrl = id10->acb_info; - - if(!mod_sam21pwd_entry(&new_pwd, True)) + if(!pdb_update_sam_account(pwd, True)) return False; return True; @@ -2243,12 +2202,9 @@ static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, uint32 rid) /******************************************************************* set_user_info_12 ********************************************************************/ -static BOOL set_user_info_12(const SAM_USER_INFO_12 *id12, 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 = pdb_getsampwrid(rid); if (pwd == NULL) return False; @@ -2258,16 +2214,10 @@ static BOOL set_user_info_12(const SAM_USER_INFO_12 *id12, uint32 rid) 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)); + pdb_set_lanman_passwd (pwd, id12->lm_pwd); + pdb_set_nt_passwd (pwd, id12->nt_pwd); - new_pwd.smb_passwd = lm_hash; - new_pwd.smb_nt_passwd = nt_hash; - - if(!mod_sam21pwd_entry(&new_pwd, True)) + if(!pdb_update_sam_account(pwd, True)) return False; return True; @@ -2278,10 +2228,8 @@ static BOOL set_user_info_12(const 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 = pdb_getsampwrid(rid); + SAM_ACCOUNT new_pwd; if (id21 == NULL) { DEBUG(5, ("set_user_info_21: NULL id21\n")); @@ -2291,25 +2239,34 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 * id21, uint32 rid) if (pwd == NULL) return False; + /* Zero out struct and set a few initial items */ pdb_init_sam(&new_pwd); + + /* FIXME!! these two calls may need to be fixed. copy_sam_passwd() + uses static strings and copy_id21..() reassigns some + strings. Right now there is no memory leaks, but if + the internals of copy_sam_passwd() changes to use dynamically + allocated strings, this will need to be fixed --jerry */ 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; + /* passwords are not copied as part of copy_sam_passwd() */ + if (pdb_get_nt_passwd(pwd) != NULL) + pdb_set_nt_passwd (&new_pwd, pdb_get_nt_passwd(pwd)); - 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 (pdb_get_lanman_passwd(pwd) != NULL) + pdb_set_lanman_passwd (&new_pwd, pdb_get_lanman_passwd(pwd)); - if(!mod_sam21pwd_entry(&new_pwd, True)) + if(!pdb_update_sam_account(&new_pwd, True)) return False; + /* FIXME!!! Memory leak here. Cannot call pdb_clear_sam() + because copy_sam_passwd uses static arrays. Therefore, + we will manually free the password pointers here. This + needs to be fixed. ---jerry */ + if (new_pwd.nt_pw) free (new_pwd.nt_pw); + if (new_pwd.lm_pw) free (new_pwd.lm_pw); + return True; } @@ -2318,10 +2275,10 @@ 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 = pdb_getsampwrid(rid); + SAM_ACCOUNT new_pwd; + BYTE nt_hash[16]; + BYTE lm_hash[16]; pstring buf; uint32 len; @@ -2337,23 +2294,30 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) copy_sam_passwd(&new_pwd, pwd); copy_id23_to_sam_passwd(&new_pwd, id23); - if (!decode_pw_buffer((const char *)id23->pass, buf, 256, &len)) + if (!decode_pw_buffer((char*)id23->pass, buf, 256, &len)) return False; nt_lm_owf_gen(buf, nt_hash, lm_hash); - new_pwd.smb_passwd = lm_hash; - new_pwd.smb_nt_passwd = nt_hash; + pdb_set_lanman_passwd (&new_pwd, lm_hash); + pdb_set_nt_passwd (&new_pwd, nt_hash); /* 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)) return False; memset(buf, 0, sizeof(buf)); - if(!mod_sam21pwd_entry(&new_pwd, True)) + if(!pdb_update_sam_account(&new_pwd, True)) return False; + + /* FIXME!!! Memory leak here. Cannot call pdb_clear_sam() + because copy_sam_passwd uses static arrays. Therefore, + we will manually free the password pointers here. This + needs to be fixed. ---jerry */ + if (new_pwd.nt_pw) free (new_pwd.nt_pw); + if (new_pwd.lm_pw) free (new_pwd.lm_pw); return True; } @@ -2363,40 +2327,38 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) ********************************************************************/ static BOOL set_user_info_24(const SAM_USER_INFO_24 *id24, 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 = pdb_getsampwrid(rid); + uchar nt_hash[16]; + uchar lm_hash[16]; uint32 len; pstring buf; if (pwd == NULL) return False; - pdb_init_sam(&new_pwd); - copy_sam_passwd(&new_pwd, pwd); - memset(buf, 0, sizeof(buf)); - if (!decode_pw_buffer((const char *)id24->pass, buf, 256, &len)) + if (!decode_pw_buffer((char*)id24->pass, buf, 256, &len)) return False; -DEBUG(0,("set_user_info_24:nt_lm_owf_gen\n")); + DEBUG(0,("set_user_info_24:nt_lm_owf_gen\n")); + nt_lm_owf_gen(buf, nt_hash, lm_hash); - new_pwd.smb_passwd = lm_hash; - new_pwd.smb_nt_passwd = nt_hash; + pdb_set_lanman_passwd (pwd, lm_hash); + pdb_set_nt_passwd (pwd, nt_hash); /* update the UNIX password */ if (lp_unix_password_sync()) - if(!chgpasswd(new_pwd.smb_name, "", buf, True)) + if(!chgpasswd(pdb_get_username(pwd), "", buf, True)) return False; memset(buf, 0, sizeof(buf)); -DEBUG(0,("set_user_info_24:mod_sam21pwd_entry\n")); + + DEBUG(0,("set_user_info_24: pdb_update_sam_account()\n")); /* update the SAMBA password */ - if(!mod_sam21pwd_entry(&new_pwd, True)) + if(!pdb_update_sam_account(pwd, True)) return False; return True; @@ -2405,19 +2367,23 @@ DEBUG(0,("set_user_info_24:mod_sam21pwd_entry\n")); /******************************************************************* samr_reply_set_userinfo ********************************************************************/ -static uint32 _samr_set_userinfo(POLICY_HND *pol, uint16 switch_value, SAM_USERINFO_CTR *ctr, pipes_struct *p) +static uint32 _samr_set_userinfo(POLICY_HND *pol, uint16 switch_value, + SAM_USERINFO_CTR *ctr, pipes_struct *p) { uint32 rid = 0x0; DOM_SID sid; struct current_user user; - struct smb_passwd *smb_pass; + SAM_ACCOUNT *sam_pass; unsigned char sess_key[16]; DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); - if (p->ntlmssp_auth_validated) { + if (p->ntlmssp_auth_validated) + { memcpy(&user, &p->pipe_user, sizeof(user)); - } else { + } + else + { extern struct current_user current_user; memcpy(&user, ¤t_user, sizeof(user)); } @@ -2447,15 +2413,16 @@ static uint32 _samr_set_userinfo(POLICY_HND *pol, uint16 switch_value, SAM_USERI */ become_root(); - smb_pass = getsmbpwuid(user.uid); + sam_pass = pdb_getsampwuid(user.uid); unbecome_root(); - if(smb_pass == NULL) { - DEBUG(0,("_samr_set_userinfo: Unable to get smbpasswd entry for uid %u\n", (unsigned int)user.uid )); + if(sam_pass == NULL) { + DEBUG(0,("_samr_set_userinfo: Unable to get passdb entry for uid %u\n", + (unsigned int)pdb_get_uid(sam_pass) )); 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); /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index ba13f0ed7a..8349b7add6 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -271,7 +271,7 @@ uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) /* ok, it's a user. find the user account */ become_root(); - disp_info = getsamdisprid(rid); + disp_info = pdb_sam_to_dispinfo(pdb_getsampwrid(rid)); unbecome_root(); if (disp_info != NULL) @@ -328,17 +328,17 @@ uint32 lookup_alias_rid(char *alias_name, uint32 *rid) ********************************************************************/ uint32 lookup_user_rid(char *user_name, uint32 *rid) { - struct sam_passwd *sam_pass; + SAM_ACCOUNT *sam_pass; (*rid) = 0; /* find the user account */ become_root(); - sam_pass = getsam21pwnam(user_name); + sam_pass = pdb_getsampwnam(user_name); unbecome_root(); if (sam_pass != NULL) { - (*rid) = sam_pass->user_rid; + *rid = pdb_get_user_rid(sam_pass); return 0x0; } -- cgit From 8993ee7d6c13b8b7bd9c7a165a2748a8ba38654b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Nov 2000 23:37:53 +0000 Subject: Tims fixes for non-local lookup. Jeremy. (This used to be commit 38e04c43cc2ce8479b8cc3ff0f87d3d150d9af83) --- source3/rpc_server/srv_lsa.c | 45 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 9c3d785627..7e6417f276 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -212,45 +212,38 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, for (i = 0; i < num_entries; i++) { BOOL status = False; - DOM_SID dom_sid; DOM_SID sid; uint32 rid = 0xffffffff; int dom_idx = -1; pstring full_name; - fstring dom_name; - fstring user; - enum SID_NAME_USE sid_name_use = SID_NAME_UNKNOWN; + fstring dom_name, user; + enum SID_NAME_USE name_type = SID_NAME_UNKNOWN; - pstrcpy(full_name, dos_unistr2_to_str(&name[i])); - - /* - * Try and split the name into a DOMAIN and - * user component. - */ + /* Split name into domain and user component */ + pstrcpy(full_name, dos_unistr2_to_str(&name[i])); split_domain_name(full_name, dom_name, user); - /* - * We only do anything with this name if we - * can map the Domain into a SID we know. - */ + /* Lookup name */ - if (map_domain_name_to_sid(&dom_sid, dom_name)) { - dom_idx = init_dom_ref(ref, dom_name, &dom_sid); + DEBUG(5, ("init_lsa_rid2s: looking up name %s\n", full_name)); - if (local_lookup_name(dom_name, user, &sid, &sid_name_use) && sid_split_rid(&sid, &rid)) - status = True; - } + status = lookup_name(full_name, &sid, &name_type); - if (status) + DEBUG(5, ("init_lsa_rid2s: %s\n", status ? "found" : + "not found")); + + if (status) { + sid_split_rid(&sid, &rid); + dom_idx = init_dom_ref(ref, dom_name, &sid); (*mapped_count)++; - else { + } else { dom_idx = -1; rid = 0xffffffff; - sid_name_use = SID_NAME_UNKNOWN; + name_type = SID_NAME_UNKNOWN; } - init_dom_rid2(&rid2[total], rid, sid_name_use, dom_idx); + init_dom_rid2(&rid2[total], rid, name_type, dom_idx); total++; } } @@ -300,6 +293,9 @@ static void init_lsa_trans_names(DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, fstring name, dom_name; enum SID_NAME_USE sid_name_use = (enum SID_NAME_USE)0; + sid_to_string(name, &find_sid); + DEBUG(5, ("init_lsa_trans_names: looking up sid %s\n", name)); + /* Lookup sid from winbindd */ memset(dom_name, '\0', sizeof(dom_name)); @@ -307,6 +303,9 @@ static void init_lsa_trans_names(DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, status = lookup_sid(&find_sid, dom_name, name, &sid_name_use); + DEBUG(5, ("init_lsa_trans_names: %s\n", status ? "found" : + "not found")); + if (!status) { sid_name_use = SID_NAME_UNKNOWN; } -- cgit From e0bcc7ff5434e9f858acc6a79d1842d86d37d73e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 14 Nov 2000 02:14:58 +0000 Subject: printing/nt_printing.c: After long soul searching and making both Andrew and my life a misery, here is the only possible null driver fix we have found. This *SUCKS*. rpc_server/srv_spoolss_nt.c: Correct printername search. Correct portname reply Correct attributes reply. Removal of unused temp variable. Jeremy. (This used to be commit 06e71c9f8be20b84e33e143c3d0b7904225efb45) --- source3/rpc_server/srv_spoolss_nt.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 42f9d29d9c..cd2b4c4e3d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -405,6 +405,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) */ for (snum=0;snuminfo_2->printername+2, '\\'); + printername++; + DEBUG(10,("set_printer_hnd_name: name [%s], aprinter [%s]\n", printer->info_2->printername, aprinter )); - if ( strlen(printer->info_2->printername) != strlen(aprinter) ) { + if ( strlen(printername) != strlen(aprinter) ) { free_a_printer(&printer, 2); continue; } - if ( strncasecmp(printer->info_2->printername, aprinter, strlen(aprinter))) { + if ( strncasecmp(printername, aprinter, strlen(aprinter))) { free_a_printer(&printer, 2); continue; } @@ -1097,8 +1101,7 @@ static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, p } /******************************************************************* - * fill a notify_info_data with the servicename - * jfmxxxx: it's incorrect should be long_printername + * fill a notify_info_data with the printername (not including the servername). ********************************************************************/ static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) @@ -1110,10 +1113,7 @@ static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, } else { p++; } -/* - data->notify_data.data.length=strlen(lp_servicename(snum)); - dos_PutUniCode(data->notify_data.data.string, lp_servicename(snum), sizeof(data->notify_data.data.string), True); -*/ + data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, p, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16)); } @@ -1135,7 +1135,7 @@ static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, pri /* even if it's strange, that's consistant in all the code */ data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - lp_servicename(snum), sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16)); + printer->info_2->portname, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16)); } /******************************************************************* @@ -1239,9 +1239,7 @@ static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data, ********************************************************************/ static void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) { - data->notify_data.value[0] = PRINTER_ATTRIBUTE_SHARED \ - | PRINTER_ATTRIBUTE_LOCAL \ - | PRINTER_ATTRIBUTE_RAW_ONLY ; + data->notify_data.value[0] = printer->info_2->attributes; } /******************************************************************* @@ -2614,7 +2612,6 @@ static uint32 getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, u static uint32 getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_3 *printer=NULL; - fstring temp; if (!construct_printer_info_3(&printer, snum)) return ERROR_NOT_ENOUGH_MEMORY; -- cgit From 4bce271e4fe239a8b4aac2bb65a52165d68d8ea5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 14 Nov 2000 21:56:32 +0000 Subject: Merge from appliance head of JR's changes for driver versioning. Jeremy. (This used to be commit cdbd2e99775642dc2e92004be9014bf38a92d80f) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cd2b4c4e3d..6a3b72ffa7 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4891,7 +4891,7 @@ uint32 _spoolss_addprinterdriver(pipes_struct *p, const UNISTR2 *server_name, convert_printer_driver_info(info, &driver, level); DEBUG(5,("Cleaning driver's information\n")); - if ((err = clean_up_driver_struct(driver, level)) != NT_STATUS_NO_PROBLEMO ) + if ((err = clean_up_driver_struct(driver, level, &user)) != NT_STATUS_NO_PROBLEMO ) goto done; DEBUG(5,("Moving driver to final destination\n")); -- cgit From cdac09614ef426092ed1b1de480fe90c3c4cdd83 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 16 Nov 2000 21:38:24 +0000 Subject: Fix for a problem with the new messaging system. If a sender is using the messaging system as a notification mechanism, and the speed of notification greatly exceeds the speed of message recovery, then you get a massively (>75Mb) growing tdb. If the message is a simple notification, then the message is static, and you only need one of them in transit to a target process at any one time. This patch adds a BOOL "allow_duplicates" to the message_send_XX primitives. If set to False, then before sending a message the sender checks the existing message queue for a target pid for a duplicate of this message, and doesn't add to it if one already exists. Also added code into msgtest.c to test this. Jeremy. (This used to be commit 3aa7995660395ecb85c8e35b638fa9fbbb952558) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 6a3b72ffa7..30acc14904 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -640,7 +640,7 @@ static BOOL srv_spoolss_sendnotify(POLICY_HND *handle) /*srv_spoolss_receive_message(printer);*/ DEBUG(10,("srv_spoolss_sendnotify: Sending message about printer %s\n", printer )); - message_send_all(MSG_PRINTER_NOTIFY, printer, strlen(printer) + 1); /* Null terminate... */ + message_send_all(MSG_PRINTER_NOTIFY, printer, strlen(printer) + 1, False); /* Null terminate... */ return True; } -- cgit From 475fb713a9427b54c747a4e71a011c7db29d5e13 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 17 Nov 2000 02:22:35 +0000 Subject: Fix for memory leak when adding driver. Jeremy. (This used to be commit eeab4e0290f9df84025e91c85d27b21e0c02781f) --- source3/rpc_server/srv_spoolss_nt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 30acc14904..a04c85368f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5198,13 +5198,13 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, unlink_specific_param_if_exist(printer->info_2, param); - if (!add_a_specific_param(printer->info_2, param)) - status = ERROR_INVALID_PARAMETER; - else - status = mod_a_printer(*printer, 2); + add_a_specific_param(printer->info_2, ¶m); + status = mod_a_printer(*printer, 2); done: free_a_printer(&printer, 2); + if (param) + free_nt_printer_param(¶m); safe_free(old_param.data); return status; -- cgit From ac4d2775618a9ac3428d60bf667e3b968d634799 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 17 Nov 2000 23:10:56 +0000 Subject: Fix from John Reilly for equivalence tests. Jeremy. (This used to be commit b456274a7ba22d512bab5ede979cd9363398825b) --- source3/rpc_server/srv_spoolss_nt.c | 155 ++++++++++++++++++------------------ 1 file changed, 79 insertions(+), 76 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a04c85368f..0fea4a8763 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1,22 +1,22 @@ #define OLD_NTDOMAIN 1 -/* +/* * Unix SMB/Netbios implementation. * Version 1.9. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -57,7 +57,7 @@ typedef struct _Printer{ struct { uint32 flags; uint32 options; - fstring localmachine; + fstring localmachine; uint32 printerlocal; SPOOL_NOTIFY_OPTION *option; POLICY_HND client_hnd; @@ -312,7 +312,7 @@ static BOOL get_printer_snum(POLICY_HND *hnd, int *number) } switch (Printer->printer_type) { - case PRINTER_HANDLE_IS_PRINTER: + case PRINTER_HANDLE_IS_PRINTER: DEBUG(4,("short name:%s\n", Printer->dev.handlename)); *number = print_queue_snum(Printer->dev.handlename); return (*number != -1); @@ -418,7 +418,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) printername=strchr(printer->info_2->printername+2, '\\'); printername++; - DEBUG(10,("set_printer_hnd_name: name [%s], aprinter [%s]\n", + DEBUG(10,("set_printer_hnd_name: name [%s], aprinter [%s]\n", printer->info_2->printername, aprinter )); if ( strlen(printername) != strlen(aprinter) ) { @@ -434,7 +434,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) found=True; } - /* + /* * if we haven't found a printer with the given handlename * then it can be a share name as you can open both \\server\printer and * \\server\share @@ -458,7 +458,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) continue; - DEBUG(10,("set_printer_hnd_name: printername [%s], aprinter [%s]\n", + DEBUG(10,("set_printer_hnd_name: printername [%s], aprinter [%s]\n", printer->info_2->printername, aprinter )); if ( strlen(lp_servicename(snum)) != strlen(aprinter) ) { @@ -562,9 +562,9 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) else extra_space = buffer_size - prs_data_size(ps); - /* + /* * save the offset and move to the end of the buffer - * prs_grow() checks the extra_space against the offset + * prs_grow() checks the extra_space against the offset */ old_offset=prs_offset(ps); prs_set_offset(ps, prs_data_size(ps)); @@ -583,7 +583,7 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) receive the notify message ****************************************************************************/ void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) -{ +{ fstring printer; uint32 status; Printer_entry *find_printer; @@ -603,7 +603,7 @@ void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) /* Iterate the printer list. */ for(; find_printer; find_printer = (Printer_entry *)ubi_dlNext(find_printer)) { - /* + /* * if the entry is the given printer or if it's a printerserver * we send the message */ @@ -711,7 +711,7 @@ static BOOL convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni, NT_PRINTER_INFO_LEVEL *printer, uint32 level) { switch (level) { - case 2: + case 2: uni_2_asc_printer_info_2(uni->info_2, &printer->info_2); break; default: @@ -725,11 +725,11 @@ static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *u NT_PRINTER_DRIVER_INFO_LEVEL *printer, uint32 level) { switch (level) { - case 3: + case 3: printer->info_3=NULL; uni_2_asc_printer_driver_3(uni->info_3, &printer->info_3); break; - case 6: + case 6: printer->info_6=NULL; uni_2_asc_printer_driver_6(uni->info_6, &printer->info_6); break; @@ -906,7 +906,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d GetPrinterData on a printer Handle. ********************************************************************/ static BOOL getprinterdata_printer(POLICY_HND *handle, - fstring value, uint32 *type, + fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size ) { NT_PRINTER_INFO_LEVEL *printer = NULL; @@ -972,7 +972,7 @@ uint32 _spoolss_getprinterdata(POLICY_HND *handle, UNISTR2 *valuename, BOOL found=False; Printer_entry *Printer = find_printer_index_by_hnd(handle); - /* + /* * Reminder: when it's a string, the length is in BYTES * even if UNICODE is negociated. * @@ -1029,7 +1029,7 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin uint32 status; /* - * If it's the first connection, contact the client + * If it's the first connection, contact the client * and connect to the IPC$ share anonumously */ if (smb_connections==0) { @@ -1056,7 +1056,7 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin * have to code it, later. * * in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe - * called from api_spoolss_rffpcnex + * called from api_spoolss_rffpcnex ********************************************************************/ uint32 _spoolss_rffpcnex(POLICY_HND *handle, uint32 flags, uint32 options, const UNISTR2 *localmachine, uint32 printerlocal, @@ -1078,8 +1078,8 @@ uint32 _spoolss_rffpcnex(POLICY_HND *handle, uint32 flags, uint32 options, unistr2_to_ascii(Printer->notify.localmachine, localmachine, sizeof(Printer->notify.localmachine)-1); /* connect to the client machine and send a ReplyOpenPrinter */ - if(srv_spoolss_replyopenprinter(Printer->notify.localmachine, - Printer->notify.printerlocal, 1, + if(srv_spoolss_replyopenprinter(Printer->notify.localmachine, + Printer->notify.printerlocal, 1, &Printer->notify.client_hnd)) Printer->notify.client_connected=True; @@ -1470,7 +1470,7 @@ struct s_notify_info_data_table notify_info_data_table[] = /******************************************************************* return the size of info_data structure -********************************************************************/ +********************************************************************/ static uint32 size_of_notify_info_data(uint16 type, uint16 field) { int i=0; @@ -1489,7 +1489,7 @@ static uint32 size_of_notify_info_data(uint16 type, uint16 field) /******************************************************************* return the type of notify_info_data -********************************************************************/ +********************************************************************/ static BOOL type_of_notify_info_data(uint16 type, uint16 field) { int i=0; @@ -1550,7 +1550,7 @@ static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, /******************************************************************* * * fill a notify_info struct with info asked - * + * ********************************************************************/ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id) { @@ -1567,7 +1567,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO type=option_type->type; DEBUGADD(4,("Notify type: [%s], number of notify info: [%d] on printer: [%s]\n", - (option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"), + (option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"), option_type->count, lp_servicename(snum))); if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) @@ -1602,7 +1602,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO /******************************************************************* * * fill a notify_info struct with info asked - * + * ********************************************************************/ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id) { @@ -1618,7 +1618,7 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I type = option_type->type; DEBUGADD(4,("Notify type: [%s], number of notify info: [%d]\n", - (option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"), + (option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"), option_type->count)); if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) @@ -1652,7 +1652,7 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I * the printer's name and the number of jobs currently queued. * So in the NOTIFY_OPTION, I have one NOTIFY_OPTION_TYPE structure. * Its type is PRINTER_NOTIFY_TYPE and it has 2 fields NAME and CJOBS. - * + * * I have 3 printers on the back of my server. * * Now the response is a NOTIFY_INFO structure, with 6 NOTIFY_INFO_DATA @@ -1674,7 +1674,7 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I * * enumerate all printers on the printserver * fill a notify_info struct with info asked - * + * ********************************************************************/ static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) { @@ -1709,7 +1709,7 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO * /* * Debugging information, don't delete. */ - /* + /* DEBUG(1,("dumping the NOTIFY_INFO\n")); DEBUGADD(1,("info->version:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); DEBUGADD(1,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); @@ -1727,7 +1727,7 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO * /******************************************************************* * * fill a notify_info struct with info asked - * + * ********************************************************************/ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) { @@ -1773,7 +1773,7 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) /* * Debugging information, don't delete. */ - /* + /* DEBUG(1,("dumping the NOTIFY_INFO\n")); DEBUGADD(1,("info->version:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); DEBUGADD(1,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); @@ -1808,7 +1808,7 @@ uint32 _spoolss_rfnpcnex( POLICY_HND *handle, uint32 change, * b) we'll have a way to communicate between the spoolss process. * * same thing for option->flags - * I should check for PRINTER_NOTIFY_OPTIONS_REFRESH but as + * I should check for PRINTER_NOTIFY_OPTIONS_REFRESH but as * I don't have a global notification system, I'm sending back all the * informations even when _NOTHING_ has changed. */ @@ -2032,7 +2032,7 @@ static DEVICEMODE *construct_dev_mode(int snum) devmode->size = ntdevmode->size; devmode->driverextra = ntdevmode->driverextra; devmode->fields = ntdevmode->fields; - + devmode->orientation = ntdevmode->orientation; devmode->papersize = ntdevmode->papersize; devmode->paperlength = ntdevmode->paperlength; @@ -2286,7 +2286,7 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui /* JFM: currently it's more a place holder than anything else. * In the spooler world there is a notion of server registration. * the print servers are registring (sp ?) on the PDC (in the same domain) - * + * * We should have a TDB here. The registration is done thru an undocumented RPC call. */ @@ -2479,7 +2479,7 @@ uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 le *returned=0; /* - * Level 1: + * Level 1: * flags==PRINTER_ENUM_NAME * if name=="" then enumerates all printers * if name!="" then enumerate the printer @@ -2802,10 +2802,10 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->name, driver.info_3->name ); init_unistr( &info->architecture, driver.info_3->environment ); - snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "\\\\%s%s", servername, driver.info_3->driverpath); init_unistr( &info->driverpath, temp_driverpath ); - snprintf(temp_datafile, sizeof(temp_datafile)-1, "\\\\%s%s", servername, driver.info_3->datafile); + snprintf(temp_datafile, sizeof(temp_datafile)-1, "\\\\%s%s", servername, driver.info_3->datafile); init_unistr( &info->datafile, temp_datafile ); snprintf(temp_configfile, sizeof(temp_configfile)-1, "\\\\%s%s", servername, driver.info_3->configfile); @@ -2872,10 +2872,10 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->name, driver.info_3->name ); init_unistr( &info->architecture, driver.info_3->environment ); - snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "\\\\%s%s", servername, driver.info_3->driverpath); init_unistr( &info->driverpath, temp_driverpath ); - snprintf(temp_datafile, sizeof(temp_datafile)-1, "\\\\%s%s", servername, driver.info_3->datafile); + snprintf(temp_datafile, sizeof(temp_datafile)-1, "\\\\%s%s", servername, driver.info_3->datafile); init_unistr( &info->datafile, temp_datafile ); snprintf(temp_configfile, sizeof(temp_configfile)-1, "\\\\%s%s", servername, driver.info_3->configfile); @@ -3108,7 +3108,7 @@ static uint32 getprinterdriver2_level6(fstring servername, fstring architecture, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getprinterdriver2(POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level, +uint32 _spoolss_getprinterdriver2(POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level, uint32 clientmajorversion, uint32 clientminorversion, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *servermajorversion, uint32 *serverminorversion) @@ -3196,7 +3196,7 @@ static struct current_user *get_current_user(struct current_user *user, pipes_st * ********************************************************************/ uint32 _spoolss_startdocprinter(POLICY_HND *handle, uint32 level, - pipes_struct *p, DOC_INFO *docinfo, + pipes_struct *p, DOC_INFO *docinfo, uint32 *jobid) { DOC_INFO_1 *info_1 = &docinfo->doc_info_1; @@ -3231,7 +3231,7 @@ uint32 _spoolss_startdocprinter(POLICY_HND *handle, uint32 level, (*jobid)=0; return ERROR_INVALID_DATATYPE; } - } + } /* get the share number of the printer */ if (!get_printer_snum(handle, &snum)) { @@ -3293,7 +3293,7 @@ uint32 _spoolss_writeprinter( POLICY_HND *handle, return ERROR_INVALID_HANDLE; } - (*buffer_written) = print_job_write(Printer->jobid, (char *)buffer, + (*buffer_written) = print_job_write(Printer->jobid, (char *)buffer, buffer_size); return 0x0; @@ -3370,7 +3370,7 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, Printer_entry *Printer = find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer) || !get_printer_snum(handle, &snum)) { - DEBUG(0,("update_printer_sec: Invalid handle (%s)\n", + DEBUG(0,("update_printer_sec: Invalid handle (%s)\n", OUR_HANDLE(handle))); result = ERROR_INVALID_HANDLE; @@ -3398,7 +3398,7 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, /* Check the user has permissions to change the security descriptor. By experimentation with two NT machines, the user requires Full Access to the printer to change security - information. */ + information. */ if (!print_access_check(&user, snum, PRINTER_ACCESS_ADMINISTER)) { result = ERROR_ACCESS_DENIED; @@ -3427,13 +3427,13 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) /* we force some elements to "correct" values */ slprintf(info->servername, sizeof(info->servername), "\\\\%s", global_myname); - slprintf(info->printername, sizeof(info->printername), "\\\\%s\\%s", + slprintf(info->printername, sizeof(info->printername), "\\\\%s\\%s", global_myname, lp_servicename(snum)); fstrcpy(info->sharename, lp_servicename(snum)); info->attributes = PRINTER_ATTRIBUTE_SHARED \ | PRINTER_ATTRIBUTE_LOCAL \ | PRINTER_ATTRIBUTE_RAW_ONLY \ - | PRINTER_ATTRIBUTE_QUEUED ; + | PRINTER_ATTRIBUTE_QUEUED ; return True; } @@ -3503,6 +3503,9 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) static BOOL nt_devicemode_equal(NT_DEVICEMODE *d1, NT_DEVICEMODE *d2) { + if (!d1 && !d2) return True; /* if both are NULL they are equal */ + if (!d1 ^ !d2) return False; /* if either is exclusively NULL are not equal */ + if (!strequal(d1->devicename, d2->devicename) || !strequal(d1->formname, d2->formname)) { return False; @@ -3611,7 +3614,7 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, return True; } - if ((!p1 && p2) || (p1 && !p2) || + if ((!p1 && p2) || (p1 && !p2) || (!p1->info_2 && p2->info_2) || (p1->info_2 && !p2->info_2)) { return False; @@ -3633,7 +3636,7 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, return False; } - /* Yuck - don't check the printername or servername as the + /* Yuck - don't check the printername or servername as the add_a_printer() code plays games with them. You can't change the printername or the sharename through this interface in Samba. */ @@ -3730,7 +3733,7 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, convert it and link it*/ /* - * Ensure printer->info_2->devmode is a valid pointer + * Ensure printer->info_2->devmode is a valid pointer * as we will be overwriting it in convert_devicemode(). */ @@ -3763,7 +3766,7 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, goto done; } - /* Check calling user has permission to update printer description */ + /* Check calling user has permission to update printer description */ if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { DEBUG(3, ("printer property change denied by security " @@ -3952,8 +3955,8 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, /**************************************************************************** Enumjobs at level 1. ****************************************************************************/ -static uint32 enumjobs_level1(print_queue_struct *queue, int snum, - NEW_BUFFER *buffer, uint32 offered, +static uint32 enumjobs_level1(print_queue_struct *queue, int snum, + NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { JOB_INFO_1 *info; @@ -3998,8 +4001,8 @@ static uint32 enumjobs_level1(print_queue_struct *queue, int snum, /**************************************************************************** Enumjobs at level 2. ****************************************************************************/ -static uint32 enumjobs_level2(print_queue_struct *queue, int snum, - NEW_BUFFER *buffer, uint32 offered, +static uint32 enumjobs_level2(print_queue_struct *queue, int snum, + NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { JOB_INFO_2 *info; @@ -4044,7 +4047,7 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum, /**************************************************************************** Enumjobs. ****************************************************************************/ -uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, uint32 level, +uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, uint32 level, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { @@ -4414,8 +4417,8 @@ static void fill_form_1(FORM_1 *form, nt_forms_struct *list) /**************************************************************************** ****************************************************************************/ -uint32 _new_spoolss_enumforms( POLICY_HND *handle, uint32 level, - NEW_BUFFER *buffer, uint32 offered, +uint32 _new_spoolss_enumforms( POLICY_HND *handle, uint32 level, + NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *numofforms) { nt_forms_struct *list=NULL; @@ -4763,8 +4766,8 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need /**************************************************************************** enumports. ****************************************************************************/ -uint32 _spoolss_enumports( UNISTR2 *name, uint32 level, - NEW_BUFFER *buffer, uint32 offered, +uint32 _spoolss_enumports( UNISTR2 *name, uint32 level, + NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { DEBUG(4,("_spoolss_enumports\n")); @@ -4867,7 +4870,7 @@ uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level, /* but I know what to do ... */ return ERROR_INVALID_LEVEL; case 2: - return spoolss_addprinterex_level_2(uni_srv_name, info, + return spoolss_addprinterex_level_2(uni_srv_name, info, unk0, unk1, unk2, unk3, user_switch, user, handle); default: @@ -4961,7 +4964,7 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen /**************************************************************************** ****************************************************************************/ uint32 _spoolss_getprinterdriverdirectory(UNISTR2 *name, UNISTR2 *uni_environment, uint32 level, - NEW_BUFFER *buffer, uint32 offered, + NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DEBUG(4,("_spoolss_getprinterdriverdirectory\n")); @@ -5022,7 +5025,7 @@ uint32 _spoolss_enumprinterdata(POLICY_HND *handle, uint32 idx, if (get_a_printer(&printer, 2, lp_servicename(snum)) != 0) return ERROR_INVALID_HANDLE; - /* + /* * The NT machine wants to know the biggest size of value and data * * cf: MSDN EnumPrinterData remark section @@ -5087,7 +5090,7 @@ uint32 _spoolss_enumprinterdata(POLICY_HND *handle, uint32 idx, return NT_STATUS_NO_PROBLEMO; } - /* + /* * the value len is wrong in NT sp3 * that's the number of bytes not the number of unicode chars */ @@ -5100,7 +5103,7 @@ uint32 _spoolss_enumprinterdata(POLICY_HND *handle, uint32 idx, free_a_printer(&printer, 2); - /* + /* * the value is: * - counted in bytes in the request * - counted in UNICODE chars in the max reply @@ -5108,7 +5111,7 @@ uint32 _spoolss_enumprinterdata(POLICY_HND *handle, uint32 idx, * * take a pause *before* coding not *during* coding */ - + *out_max_value_len=(in_value_len/sizeof(uint16)); if((*out_value=(uint16 *)malloc(in_value_len*sizeof(uint8))) == NULL) { safe_free(data); @@ -5168,13 +5171,13 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, convert_specific_param(¶m, value , type, data, real_len); - /* Check if we are making any changes or not. Return true if + /* 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, &old_param.data_len)) { + &old_param.type, (unsigned int *)&old_param.data_len)) { if (param->type == old_param.type && param->data_len == old_param.data_len && @@ -5364,12 +5367,12 @@ static uint32 enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui /**************************************************************************** ****************************************************************************/ uint32 _spoolss_enumprintprocessors(UNISTR2 *name, UNISTR2 *environment, uint32 level, - NEW_BUFFER *buffer, uint32 offered, + NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { DEBUG(5,("spoolss_enumprintprocessors\n")); - /* + /* * Enumerate the print processors ... * * Just reply with "winprint", to keep NT happy @@ -5421,7 +5424,7 @@ static uint32 enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, /**************************************************************************** ****************************************************************************/ uint32 _spoolss_enumprintprocdatatypes(UNISTR2 *name, UNISTR2 *processor, uint32 level, - NEW_BUFFER *buffer, uint32 offered, + NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { DEBUG(5,("_spoolss_enumprintprocdatatypes\n")); @@ -5504,12 +5507,12 @@ static uint32 enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint /**************************************************************************** ****************************************************************************/ uint32 _spoolss_enumprintmonitors(UNISTR2 *name,uint32 level, - NEW_BUFFER *buffer, uint32 offered, + NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { DEBUG(5,("spoolss_enumprintmonitors\n")); - /* + /* * Enumerate the print monitors ... * * Just reply with "Local Port", to keep NT happy @@ -5631,7 +5634,7 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin /**************************************************************************** ****************************************************************************/ uint32 _spoolss_getjob( POLICY_HND *handle, uint32 jobid, uint32 level, - NEW_BUFFER *buffer, uint32 offered, + NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { int snum; -- cgit From 0dcbafe2b97035df779f2e0742a130c4c79e3241 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 21 Nov 2000 05:55:16 +0000 Subject: Another large patch for the passdb rewrite. o added BOOL own_memory flag in SAM_ACCOUNT so we could use static memory for string pointer assignment or allocate a new string o added a reference TDB passdb backend. This is only a reference and should not be used in production because - RID's are generated using the same algorithm as with smbpasswd - a TDB can only have one key (w/o getting into problems) and we need three. Therefore the pdb_sam-getpwuid() and pdb_getsampwrid() functions are interative searches :-( we need transaction support, multiple indexes, and a nice open source DBM. The Berkeley DB (from sleepycat.com seems to fit this criteria now) o added a new parameter "private dir" as many places in the code were using lp_smb_passwd_file() and chopping off the filename part. This makes more sense to me and I will docuement it in the man pages o Ran through Insure-lite and corrected memory leaks. Need for a public flogging this time Jeremy (-: -- jerry (This used to be commit 4792029a2991bd84251d152a62b1033dec62cee2) --- source3/rpc_server/srv_samr.c | 41 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index dcb5b9c9e3..ed3cf7df82 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -2226,7 +2226,7 @@ static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, uint32 rid) /******************************************************************* set_user_info_21 ********************************************************************/ -static BOOL set_user_info_21(SAM_USER_INFO_21 * id21, uint32 rid) +static BOOL set_user_info_21 (SAM_USER_INFO_21 *id21, uint32 rid) { SAM_ACCOUNT *pwd = pdb_getsampwrid(rid); SAM_ACCOUNT new_pwd; @@ -2239,33 +2239,20 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 * id21, uint32 rid) if (pwd == NULL) return False; - /* Zero out struct and set a few initial items */ - pdb_init_sam(&new_pwd); - - /* FIXME!! these two calls may need to be fixed. copy_sam_passwd() - uses static strings and copy_id21..() reassigns some - strings. Right now there is no memory leaks, but if - the internals of copy_sam_passwd() changes to use dynamically - allocated strings, this will need to be fixed --jerry */ + /* 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 + */ - /* passwords are not copied as part of copy_sam_passwd() */ - if (pdb_get_nt_passwd(pwd) != NULL) - pdb_set_nt_passwd (&new_pwd, pdb_get_nt_passwd(pwd)); - - if (pdb_get_lanman_passwd(pwd) != NULL) - pdb_set_lanman_passwd (&new_pwd, pdb_get_lanman_passwd(pwd)); - + /* write the change out */ if(!pdb_update_sam_account(&new_pwd, True)) return False; - - /* FIXME!!! Memory leak here. Cannot call pdb_clear_sam() - because copy_sam_passwd uses static arrays. Therefore, - we will manually free the password pointers here. This - needs to be fixed. ---jerry */ - if (new_pwd.nt_pw) free (new_pwd.nt_pw); - if (new_pwd.lm_pw) free (new_pwd.lm_pw); return True; } @@ -2290,7 +2277,6 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) if (pwd == NULL) return False; - pdb_init_sam(&new_pwd); copy_sam_passwd(&new_pwd, pwd); copy_id23_to_sam_passwd(&new_pwd, id23); @@ -2311,13 +2297,6 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) if(!pdb_update_sam_account(&new_pwd, True)) return False; - - /* FIXME!!! Memory leak here. Cannot call pdb_clear_sam() - because copy_sam_passwd uses static arrays. Therefore, - we will manually free the password pointers here. This - needs to be fixed. ---jerry */ - if (new_pwd.nt_pw) free (new_pwd.nt_pw); - if (new_pwd.lm_pw) free (new_pwd.lm_pw); return True; } -- cgit From a69a1a87d8f6fece120c423e473b6f67b7a6bb8e Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Wed, 22 Nov 2000 16:19:07 +0000 Subject: Changes from APPLIANCE_HEAD: - Add code to test equivalence of private data in NT_DEVICEMODE (This used to be commit 684981851ffa3b51e78a6fd5960e219823eb90d5) --- source3/rpc_server/srv_spoolss_nt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0fea4a8763..1ef6a8c11b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3549,10 +3549,10 @@ static BOOL nt_devicemode_equal(NT_DEVICEMODE *d1, NT_DEVICEMODE *d2) return False; } - /* Not sure what to do about these fields */ -#if 0 - uint8 *private; -#endif + /* compare the private data if it exists */ + if (!d1->driverextra && !d2->driverextra) return True; + if ( d1->driverextra != d2->driverextra) return False; + if (memcmp(d1->private, d2->private, d1->driverextra)) return False; return True; } -- cgit From cf5b71994d6cdb2f81c390579f4a0e676926c6b9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 7 Dec 2000 19:26:04 +0000 Subject: file_lines_load/file_lines_pload can now optionally convert unix_to_dos() on read. Jeremy. (This used to be commit 76b8dd376d13eb4469417be217c966d54d333367) --- source3/rpc_server/srv_samr.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index ed3cf7df82..352852038a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -128,7 +128,7 @@ static char *unmap_unixname(char *unix_user_name, int name_idx) if (!*unix_user_name) return NULL; if (!*mapfile) return NULL; - lines = file_lines_load(mapfile, NULL); + lines = file_lines_load(mapfile, NULL,False); if (!lines) { DEBUG(0,("unmap_unixname: can't open username map %s\n", mapfile)); return NULL; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1ef6a8c11b..69cb79156b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3480,7 +3480,7 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) } numlines = 0; - qlines = file_lines_load(tmp_file, &numlines); + qlines = file_lines_load(tmp_file, &numlines, True); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file)); unlink(tmp_file); @@ -4604,7 +4604,7 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need } numlines = 0; - qlines = file_lines_load(tmp_file, &numlines); + qlines = file_lines_load(tmp_file, &numlines,True); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file)); unlink(tmp_file); @@ -4702,7 +4702,7 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need } numlines = 0; - qlines = file_lines_load(tmp_file, &numlines); + qlines = file_lines_load(tmp_file, &numlines,True); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file)); unlink(tmp_file); -- cgit From a95ccc27790cb8275f44df76fa6dc33a6a17c12e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 11 Dec 2000 19:24:59 +0000 Subject: Adding in debug for SD's. Jeremy. (This used to be commit a19f936b644fedc4c59ada5f12172abed9894910) --- source3/rpc_server/srv_spoolss_nt.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 69cb79156b..c0ecfefc92 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3384,6 +3384,37 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, nt_printing_getsec(Printer->dev.handlename, &old_secdesc_ctr); + if (DEBUGLEVEL >= 10) { + SEC_ACL *acl; + int i; + + acl = old_secdesc_ctr->sec->dacl; + DEBUG(10, ("old_secdesc_ctr for %s has %d aces:\n", + PRINTERNAME(snum), acl->num_aces)); + + for (i = 0; i < acl->num_aces; i++) { + fstring sid_str; + + sid_to_string(sid_str, &acl->ace[i].sid); + + DEBUG(10, ("%s 0x%08x\n", sid_str, + acl->ace[i].info.mask)); + } + + acl = secdesc_ctr->sec->dacl; + DEBUG(10, ("secdesc_ctr for %s has %d aces:\n", + PRINTERNAME(snum), acl->num_aces)); + + for (i = 0; i < acl->num_aces; i++) { + fstring sid_str; + + sid_to_string(sid_str, &acl->ace[i].sid); + + DEBUG(10, ("%s 0x%08x\n", sid_str, + acl->ace[i].info.mask)); + } + } + new_secdesc_ctr = sec_desc_merge(secdesc_ctr, old_secdesc_ctr); if (sec_desc_equal(new_secdesc_ctr->sec, old_secdesc_ctr->sec)) { -- cgit From 20ac3fc77e9423ab13a2cc1a2ef3d266f5b233e0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 12 Dec 2000 02:45:11 +0000 Subject: Merged in Tim's changes : Removed static limit of MAX_LOOKUP_SIDS in rpc server and client lsa_lookup_names() and lsa_lookup_sids(). Jeremy. (This used to be commit 9e9c71c8b3194b7cd02fea0b6a000d4f2940d905) --- source3/rpc_server/srv_lsa.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 7e6417f276..38f4936209 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -277,13 +277,26 @@ static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, ***************************************************************************/ static void init_lsa_trans_names(DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, - int num_entries, DOM_SID2 sid[MAX_LOOKUP_SIDS], uint32 *mapped_count) + int num_entries, DOM_SID2 *sid, + uint32 *mapped_count) { int i; int total = 0; *mapped_count = 0; - SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS); + /* Allocate memory for list of names */ + + if (!(trn->name = (LSA_TRANS_NAME *)malloc(sizeof(LSA_TRANS_NAME) * + num_entries))) { + DEBUG(0, ("init_lsa_trans_names(): out of memory\n")); + return; + } + + if (!(trn->uni_name = (UNISTR2 *)malloc(sizeof(UNISTR2) * + num_entries))) { + DEBUG(0, ("init_lsa_trans_names(): out of memory\n")); + return; + } for (i = 0; i < num_entries; i++) { BOOL status = False; @@ -318,7 +331,8 @@ static void init_lsa_trans_names(DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, dom_idx = init_dom_ref(ref, dom_name, &find_sid); - DEBUG(10,("init_lsa_trans_names: added user '%s\\%s' to referenced list.\n", dom_name, name )); + DEBUG(10,("init_lsa_trans_names: added user '%s\\%s' to " + "referenced list.\n", dom_name, name )); (*mapped_count)++; @@ -376,6 +390,11 @@ static BOOL lsa_reply_lookup_sids(prs_struct *rdata, DOM_SID2 *sid, int num_entr return False; } + /* Free memory - perhaps this should be done using talloc()? */ + + safe_free(names.name); + safe_free(names.uni_name); + return True; } @@ -551,20 +570,29 @@ static BOOL api_lsa_lookup_sids(pipes_struct *p) LSA_Q_LOOKUP_SIDS q_l; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + BOOL result = True; ZERO_STRUCT(q_l); /* grab the info class and policy handle */ if(!lsa_io_q_lookup_sids("", &q_l, data, 0)) { DEBUG(0,("api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS.\n")); - return False; + result = False; + goto done; } /* construct reply. return status is always 0x0 */ - if(!lsa_reply_lookup_sids(rdata, q_l.sids.sid, q_l.sids.num_entries)) - return False; + if(!lsa_reply_lookup_sids(rdata, q_l.sids.sid, q_l.sids.num_entries)) { + result = False; + goto done; + } - return True; + + done: + safe_free(q_l.sids.ptr_sid); + safe_free(q_l.sids.sid); + + return result; } /*************************************************************************** -- cgit From 90a7d7d3d7e77ed1f33e2bb9969beef7aa464712 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 12 Dec 2000 05:29:47 +0000 Subject: Compile fix for new arg to create_nt_token() (This used to be commit 806185ca8cc8d28f16745a1db9427f52eb8d22e4) --- source3/rpc_server/srv_pipe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index d15f045252..6d0a006593 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -467,8 +467,10 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name get_current_groups( &p->pipe_user.ngroups, &p->pipe_user.groups); /* Create an NT_USER_TOKEN struct for this user. */ - p->pipe_user.nt_user_token = create_nt_token(p->pipe_user.uid,p->pipe_user.gid, - p->pipe_user.ngroups, p->pipe_user.groups); + p->pipe_user.nt_user_token = + create_nt_token(p->pipe_user.uid,p->pipe_user.gid, + p->pipe_user.ngroups, p->pipe_user.groups, + guest_user); p->ntlmssp_auth_validated = True; return True; -- cgit From ed6f6ca043a5a5cc5af9b80894abab82d9ce8d71 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 13 Dec 2000 12:39:55 +0000 Subject: Server side changes for dynamic names in lsa_lookup_names (This used to be commit 5c5c3a8a08efe8c2f36a55b1383e9d3dd9eca4a5) --- source3/rpc_server/srv_lsa.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 38f4936209..5bc780860f 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -402,13 +402,17 @@ static BOOL lsa_reply_lookup_sids(prs_struct *rdata, DOM_SID2 *sid, int num_entr lsa_reply_lookup_names ***************************************************************************/ -static BOOL lsa_reply_lookup_names(prs_struct *rdata, - UNISTR2 names[MAX_LOOKUP_SIDS], int num_entries) +static BOOL lsa_reply_lookup_names(prs_struct *rdata, UNISTR2 *names, + int num_entries) { LSA_R_LOOKUP_NAMES r_l; DOM_R_REF ref; DOM_RID2 rids[MAX_LOOKUP_SIDS]; uint32 mapped_count = 0; + TALLOC_CTX *mem_ctx = talloc_init(); + BOOL result = True; + + if (!mem_ctx) return False; ZERO_STRUCT(r_l); ZERO_STRUCT(ref); @@ -419,12 +423,13 @@ static BOOL lsa_reply_lookup_names(prs_struct *rdata, init_reply_lookup_names(&r_l, &ref, num_entries, rids, mapped_count); /* store the response in the SMB stream */ - if(!lsa_io_r_lookup_names("", &r_l, rdata, 0)) { + if(!lsa_io_r_lookup_names(mem_ctx, "", &r_l, rdata, 0)) { DEBUG(0,("lsa_reply_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n")); - return False; + result = False; } - return True; + talloc_destroy(mem_ctx); + return result; } /*************************************************************************** -- cgit From 57779c6f3bb469263c195b5eb1afbf4769c00ffb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 14 Dec 2000 18:37:01 +0000 Subject: Updates from appliance-head. Jeremy. (This used to be commit 15ae2c335b52e34c06d8f4f9ebad28078292b208) --- source3/rpc_server/srv_spoolss_nt.c | 55 +++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c0ecfefc92..a7614ff640 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3534,11 +3534,16 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) static BOOL nt_devicemode_equal(NT_DEVICEMODE *d1, NT_DEVICEMODE *d2) { - if (!d1 && !d2) return True; /* if both are NULL they are equal */ - if (!d1 ^ !d2) return False; /* if either is exclusively NULL are not equal */ + if (!d1 && !d2) goto equal; /* if both are NULL they are equal */ + + if (!d1 ^ !d2) { + DEBUG(10, ("nt_devicemode_equal(): pointers not equal\n")); + return False; /* if either is exclusively NULL are not equal */ + } if (!strequal(d1->devicename, d2->devicename) || !strequal(d1->formname, d2->formname)) { + DEBUG(10, ("nt_devicemode_equal(): device,form not equal\n")); return False; } @@ -3560,6 +3565,8 @@ static BOOL nt_devicemode_equal(NT_DEVICEMODE *d1, NT_DEVICEMODE *d2) d1->ttoption != d2->ttoption || d1->collate != d2->collate || d1->logpixels != d2->logpixels) { + DEBUG(10, ("nt_devicemode_equal(): specversion-logpixels " + "not equal\n")); return False; } @@ -3577,14 +3584,26 @@ static BOOL nt_devicemode_equal(NT_DEVICEMODE *d1, NT_DEVICEMODE *d2) d1->reserved2 != d2->reserved2 || d1->panningwidth != d2->panningwidth || d1->panningheight != d2->panningheight) { + DEBUG(10, ("nt_devicemode_equal(): fields-panningheight " + "not equal\n")); return False; } /* compare the private data if it exists */ - if (!d1->driverextra && !d2->driverextra) return True; - if ( d1->driverextra != d2->driverextra) return False; - if (memcmp(d1->private, d2->private, d1->driverextra)) return False; + if (!d1->driverextra && !d2->driverextra) goto equal; + + if (d1->driverextra != d2->driverextra) { + DEBUG(10, ("nt_devicemode_equal(): driverextra not equal\n")); + return False; + } + + if (memcmp(d1->private, d2->private, d1->driverextra)) { + DEBUG(10, ("nt_devicemode_equal(): private data not equal\n")); + return False; + } + equal: + DEBUG(10, ("nt_devicemode_equal(): devicemodes identical\n")); return True; } @@ -3593,9 +3612,12 @@ static BOOL nt_devicemode_equal(NT_DEVICEMODE *d1, NT_DEVICEMODE *d2) static BOOL nt_printer_param_equal(NT_PRINTER_PARAM *p1, NT_PRINTER_PARAM *p2) { - if (!p1 && !p2) return True; + if (!p1 && !p2) goto equal; - if ((!p1 && p2) || (p1 && !p2)) return False; + if ((!p1 && p2) || (p1 && !p2)) { + DEBUG(10, ("nt_printer_param_equal(): pointers differ\n")); + return False; + } /* Compare lists of printer parameters */ @@ -3620,12 +3642,17 @@ static BOOL nt_printer_param_equal(NT_PRINTER_PARAM *p1, found_it: if (!found) { + DEBUG(10, ("nt_printer_param_equal(): param %s " + "differs\n", p1->value)); return False; } p1 = p1->next; } + equal: + + DEBUG(10, ("nt_printer_param_equal(): printer params identical\n")); return True; } @@ -3642,12 +3669,14 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, /* Trivial conditions */ if ((!p1 && !p2) || (!p1->info_2 && !p2->info_2)) { - return True; + goto equal; } if ((!p1 && p2) || (p1 && !p2) || (!p1->info_2 && p2->info_2) || (p1->info_2 && !p2->info_2)) { + DEBUG(10, ("nt_printer_info_level_equal(): info levels " + "differ\n")); return False; } @@ -3664,6 +3693,8 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, pi1->starttime != pi2->starttime || pi1->untiltime != pi2->untiltime || pi1->averageppm != pi2->averageppm) { + DEBUG(10, ("nt_printer_info_level_equal(): attr-ppm values " + "differ\n")); return False; } @@ -3677,6 +3708,8 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, !strequal(pi1->drivername, pi2->drivername) || !strequal(pi1->comment, pi2->comment) || !strequal(pi1->location, pi2->location)) { + DEBUG(10, ("nt_printer_info_level_equal(): values for names " + "differ\n")); return False; } @@ -3688,6 +3721,8 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, !strequal(pi1->printprocessor, pi2->printprocessor) || !strequal(pi1->datatype, pi2->datatype) || !strequal(pi1->parameters, pi2->parameters)) { + DEBUG(10, ("nt_printer_info_level_equal(): sep-params values " + "differ\n")); return False; } @@ -3702,9 +3737,13 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, if (pi1->changeid != pi2->changeid || pi1->c_setprinter != pi2->c_setprinter || pi1->setuptime != pi2->setuptime) { + DEBUG(10, ("nt_printer_info_level_equal(): id-setuptime " + "values differ\n")); return False; } + equal: + DEBUG(10, ("nt_printer_info_level_equal(): infos are identical\n")); return True; } -- cgit From 369f5fd1d7a6e6298bc3cbe01e3aaed0106f6cf4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 15 Dec 2000 01:02:11 +0000 Subject: Fixed memory leaks in lsa_XX calls. Fixed memory leaks in smbcacls. Merged in fixes from appliance-head and 2.2. Fixed multiple connection.tdb open problem. Jeremy. (This used to be commit 0a40bc83e14c69a09948ec09bb6fc5026c4f4c14) --- source3/rpc_server/srv_lsa.c | 20 +------------------- source3/rpc_server/srv_spoolss_nt.c | 2 +- 2 files changed, 2 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 5bc780860f..aea7294ffe 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -390,11 +390,6 @@ static BOOL lsa_reply_lookup_sids(prs_struct *rdata, DOM_SID2 *sid, int num_entr return False; } - /* Free memory - perhaps this should be done using talloc()? */ - - safe_free(names.name); - safe_free(names.uni_name); - return True; } @@ -409,11 +404,8 @@ static BOOL lsa_reply_lookup_names(prs_struct *rdata, UNISTR2 *names, DOM_R_REF ref; DOM_RID2 rids[MAX_LOOKUP_SIDS]; uint32 mapped_count = 0; - TALLOC_CTX *mem_ctx = talloc_init(); BOOL result = True; - if (!mem_ctx) return False; - ZERO_STRUCT(r_l); ZERO_STRUCT(ref); ZERO_ARRAY(rids); @@ -423,12 +415,11 @@ static BOOL lsa_reply_lookup_names(prs_struct *rdata, UNISTR2 *names, init_reply_lookup_names(&r_l, &ref, num_entries, rids, mapped_count); /* store the response in the SMB stream */ - if(!lsa_io_r_lookup_names(mem_ctx, "", &r_l, rdata, 0)) { + if(!lsa_io_r_lookup_names("", &r_l, rdata, 0)) { DEBUG(0,("lsa_reply_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n")); result = False; } - talloc_destroy(mem_ctx); return result; } @@ -583,20 +574,13 @@ static BOOL api_lsa_lookup_sids(pipes_struct *p) if(!lsa_io_q_lookup_sids("", &q_l, data, 0)) { DEBUG(0,("api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS.\n")); result = False; - goto done; } /* construct reply. return status is always 0x0 */ if(!lsa_reply_lookup_sids(rdata, q_l.sids.sid, q_l.sids.num_entries)) { result = False; - goto done; } - - done: - safe_free(q_l.sids.ptr_sid); - safe_free(q_l.sids.sid); - return result; } @@ -618,8 +602,6 @@ static BOOL api_lsa_lookup_names(pipes_struct *p) return False; } - SMB_ASSERT_ARRAY(q_l.uni_name, q_l.num_entries); - return lsa_reply_lookup_names(rdata, q_l.uni_name, q_l.num_entries); } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a7614ff640..b43501a56b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -640,7 +640,7 @@ static BOOL srv_spoolss_sendnotify(POLICY_HND *handle) /*srv_spoolss_receive_message(printer);*/ DEBUG(10,("srv_spoolss_sendnotify: Sending message about printer %s\n", printer )); - message_send_all(MSG_PRINTER_NOTIFY, printer, strlen(printer) + 1, False); /* Null terminate... */ + message_send_all(conn_tdb_ctx(), MSG_PRINTER_NOTIFY, printer, strlen(printer) + 1, False); /* Null terminate... */ return True; } -- cgit From a18ade3fe0e823ceb83de2078f8f7e23e6c4fcf2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 15 Dec 2000 01:47:37 +0000 Subject: Fixed memory leak in JOB_INFO_2 code. Jeremy. (This used to be commit d0d31eead3367485bbac684d881839029010975d) --- source3/rpc_server/srv_spoolss_nt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b43501a56b..c2054143b7 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4104,7 +4104,7 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum, new_smb_io_job_info_2("", buffer, &info[i], 0); /* clear memory */ - safe_free(info); + free_job_info_2(info); if (*needed > offered) { *returned=0; @@ -5692,8 +5692,7 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin new_smb_io_job_info_2("", buffer, info_2, 0); - free_dev_mode(info_2->devmode); - safe_free(info_2); + free_job_info_2(info_2); if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; -- cgit From 89af6fd745a6f49668bae5b5c2d239d3671fb299 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 15 Dec 2000 09:31:56 +0000 Subject: lib/util_unistr.c: rewrote unistr2_to_ascii() to correct a bug seen on SGI boxes. rpc_parse/parse_misc.c: rpc_parse/parse_prs.c: rewrote of BUFFER5 handling to NOT byteswap when it was already in network byte order. rpc_parse/parse_samr.c: cleanup of samr_io_q_lookup_domain(), remove the over-parsing by 2 bytes. rpc_server/srv_lsa.c: UNISTR2 strings need to be NULL terminated to pleased W2K. rpc_server/srv_spoolss_nt.c: use snprintf instead of safe_strcpy as we want the string truncated at 32 chars. That should fix SUN and SGI box not able to act as printserver and the problem with joining from a W2K wks. J.F. (This used to be commit 69fe739303b105f2c488f266f13977da1b6b201d) --- source3/rpc_server/srv_lsa.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index aea7294ffe..5fc40d692c 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -88,7 +88,7 @@ Init dom_query static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) { - int domlen = (dom_name != NULL) ? strlen(dom_name) : 0; + int domlen = (dom_name != NULL) ? strlen(dom_name)+1 : 0; d_q->uni_dom_max_len = domlen * 2; d_q->uni_dom_str_len = domlen * 2; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c2054143b7..a4f5e257f1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2021,7 +2021,7 @@ static DEVICEMODE *construct_dev_mode(int snum) DEBUGADD(8,("loading DEVICEMODE\n")); - safe_strcpy(adevice, printer->info_2->printername, sizeof(adevice)); + snprintf(adevice, sizeof(adevice), printer->info_2->printername); init_unistr(&devmode->devicename, adevice); snprintf(aform, sizeof(aform), ntdevmode->formname); -- cgit From 99c2693c620cd222da5561d526aa328bec426b77 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 15 Dec 2000 21:29:06 +0000 Subject: Added lock backouts on fail. When chaining together long lines of bloody "if" statements, which should logically be separated, and one of them allocates memory, remember to *free* it *WHETHER OR NOT THE IF STATEMENTS SUCCEEDED* !!!! Yes I do consider this a bug in the coding style of Tridge, Rusty, Tim et al. :-). I'm just pissed 'cos this took 4 hours to track down even with an insure error report stating me in the face and also Ben Woodward looking over the code with me :-). Jeremy. (This used to be commit 506b5e34c3ba16768dbc82ba21044787de160c45) --- source3/rpc_server/srv_srvsvc.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 715a681a29..52ae54fd94 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -109,7 +109,7 @@ static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum) Fill in a share info structure. ********************************************************************/ -static BOOL init_srv_share_info_ctr(SRV_SHARE_INFO_CTR *ctr, +static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr, uint32 info_level, uint32 *resume_hnd, uint32 *total_entries) { int num_entries = 0; @@ -142,7 +142,7 @@ static BOOL init_srv_share_info_ctr(SRV_SHARE_INFO_CTR *ctr, SRV_SHARE_INFO_1 *info1; int i = 0; - info1 = malloc(num_entries * sizeof(SRV_SHARE_INFO_1)); + info1 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1)); for (snum = *resume_hnd; snum < num_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum)) { @@ -159,7 +159,7 @@ static BOOL init_srv_share_info_ctr(SRV_SHARE_INFO_CTR *ctr, SRV_SHARE_INFO_2 *info2; int i = 0; - info2 = malloc(num_entries * sizeof(SRV_SHARE_INFO_2)); + info2 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_2)); for (snum = *resume_hnd; snum < num_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum)) { @@ -183,12 +183,12 @@ static BOOL init_srv_share_info_ctr(SRV_SHARE_INFO_CTR *ctr, Inits a SRV_R_NET_SHARE_ENUM structure. ********************************************************************/ -static void init_srv_r_net_share_enum(SRV_R_NET_SHARE_ENUM *r_n, +static void init_srv_r_net_share_enum(TALLOC_CTX *ctx, SRV_R_NET_SHARE_ENUM *r_n, uint32 info_level, uint32 resume_hnd) { DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__)); - if (init_srv_share_info_ctr(&r_n->ctr, info_level, + if (init_srv_share_info_ctr(ctx, &r_n->ctr, info_level, &resume_hnd, &r_n->total_entries)) { r_n->status = 0x0; } else { @@ -207,21 +207,25 @@ static BOOL srv_reply_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n, { SRV_R_NET_SHARE_ENUM r_n; BOOL ret; + TALLOC_CTX *ctx = talloc_init(); DEBUG(5,("srv_net_share_enum: %d\n", __LINE__)); + if (!ctx) { + DEBUG(0,("srv_reply_net_share_enum: talloc_init failed.\n")); + return False; + } + /* Create the list of shares for the response. */ - init_srv_r_net_share_enum(&r_n, + init_srv_r_net_share_enum(ctx, &r_n, q_n->ctr.info_level, get_enum_hnd(&q_n->enum_hnd)); /* store the response in the SMB stream */ ret = srv_io_r_net_share_enum("", &r_n, rdata, 0); - /* Free the memory used by the response. */ - free_srv_r_net_share_enum(&r_n); - DEBUG(5,("srv_net_share_enum: %d\n", __LINE__)); + talloc_destroy(ctx); return ret; } @@ -286,9 +290,6 @@ static BOOL srv_reply_net_share_get_info(SRV_Q_NET_SHARE_GET_INFO *q_n, /* store the response in the SMB stream */ ret = srv_io_r_net_share_get_info("", &r_n, rdata, 0); - /* Free the memory used by the response. */ - free_srv_r_net_share_get_info(&r_n); - DEBUG(5,("srv_net_share_get_info: %d\n", __LINE__)); return ret; @@ -1024,9 +1025,6 @@ static BOOL api_srv_net_share_enum(pipes_struct *p) ret = srv_reply_net_share_enum(&q_n, rdata); - /* Free any data allocated in the unmarshalling. */ - free_srv_q_net_share_enum(&q_n); - return ret; } @@ -1049,9 +1047,6 @@ static BOOL api_srv_net_share_get_info(pipes_struct *p) ret = srv_reply_net_share_get_info(&q_n, rdata); - /* Free any data allocated in the unmarshalling. */ - free_srv_q_net_share_get_info(&q_n); - return ret; } -- cgit From fb82ab78fe556656eec605d532e0dabb2f815573 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 15 Dec 2000 23:02:01 +0000 Subject: Never free anything in the rpc_parse/prs_XXX functions. Do it in the enclosing function. lib/util_unistr.c: Check lengths *before* reading source - prevent uninitialised memory reads. Jeremy. (This used to be commit ce4f461965c872fbfc9fe5f6b98aed58bb3dd67a) --- source3/rpc_server/srv_lsa.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 5fc40d692c..ed65e787b4 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -276,7 +276,7 @@ static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, Init lsa_trans_names. ***************************************************************************/ -static void init_lsa_trans_names(DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, +static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, int num_entries, DOM_SID2 *sid, uint32 *mapped_count) { @@ -286,16 +286,18 @@ static void init_lsa_trans_names(DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, /* Allocate memory for list of names */ - if (!(trn->name = (LSA_TRANS_NAME *)malloc(sizeof(LSA_TRANS_NAME) * - num_entries))) { - DEBUG(0, ("init_lsa_trans_names(): out of memory\n")); - return; - } + if (num_entries > 0) { + if (!(trn->name = (LSA_TRANS_NAME *)talloc(ctx, sizeof(LSA_TRANS_NAME) * + num_entries))) { + DEBUG(0, ("init_lsa_trans_names(): out of memory\n")); + return; + } - if (!(trn->uni_name = (UNISTR2 *)malloc(sizeof(UNISTR2) * - num_entries))) { - DEBUG(0, ("init_lsa_trans_names(): out of memory\n")); - return; + if (!(trn->uni_name = (UNISTR2 *)talloc(ctx, sizeof(UNISTR2) * + num_entries))) { + DEBUG(0, ("init_lsa_trans_names(): out of memory\n")); + return; + } } for (i = 0; i < num_entries; i++) { @@ -375,21 +377,24 @@ static BOOL lsa_reply_lookup_sids(prs_struct *rdata, DOM_SID2 *sid, int num_entr DOM_R_REF ref; LSA_TRANS_NAME_ENUM names; uint32 mapped_count = 0; + TALLOC_CTX *ctx = talloc_init(); ZERO_STRUCT(r_l); ZERO_STRUCT(ref); ZERO_STRUCT(names); /* set up the LSA Lookup SIDs response */ - init_lsa_trans_names(&ref, &names, num_entries, sid, &mapped_count); + init_lsa_trans_names(ctx, &ref, &names, num_entries, sid, &mapped_count); init_reply_lookup_sids(&r_l, &ref, &names, mapped_count); /* store the response in the SMB stream */ if(!lsa_io_r_lookup_sids("", &r_l, rdata, 0)) { DEBUG(0,("lsa_reply_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS.\n")); + talloc_destroy(ctx); return False; } + talloc_destroy(ctx); return True; } -- cgit From 452102deb4b8aecb45569239685ec73e2e9282ec Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 18 Dec 2000 06:02:31 +0000 Subject: Merged Tim's fixes from appliance-head. Jeremy. (This used to be commit 26f873540c2299600cb80eb059fcdaf70ec82473) --- source3/rpc_server/srv_spoolss_nt.c | 208 ++++++++++++++++++++---------------- 1 file changed, 113 insertions(+), 95 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a4f5e257f1..38a4b26a60 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3402,16 +3402,21 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, } acl = secdesc_ctr->sec->dacl; - DEBUG(10, ("secdesc_ctr for %s has %d aces:\n", - PRINTERNAME(snum), acl->num_aces)); - for (i = 0; i < acl->num_aces; i++) { - fstring sid_str; - - sid_to_string(sid_str, &acl->ace[i].sid); + if (acl) { + DEBUG(10, ("secdesc_ctr for %s has %d aces:\n", + PRINTERNAME(snum), acl->num_aces)); - DEBUG(10, ("%s 0x%08x\n", sid_str, - acl->ace[i].info.mask)); + for (i = 0; i < acl->num_aces; i++) { + fstring sid_str; + + sid_to_string(sid_str, &acl->ace[i].sid); + + DEBUG(10, ("%s 0x%08x\n", sid_str, + acl->ace[i].info.mask)); + } + } else { + DEBUG(10, ("dacl for secdesc_ctr is NULL\n")); } } @@ -3532,6 +3537,13 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) /* Return true if two devicemodes are equal */ +#define DEVMODE_CHECK_INT(field) \ + if (d1->field != d2->field) { \ + DEBUG(10, ("nt_devicemode_equal(): " #field " not equal (%d != %d)\n", \ + d1->field, d2->field)); \ + return False; \ + } + static BOOL nt_devicemode_equal(NT_DEVICEMODE *d1, NT_DEVICEMODE *d2) { if (!d1 && !d2) goto equal; /* if both are NULL they are equal */ @@ -3547,55 +3559,44 @@ static BOOL nt_devicemode_equal(NT_DEVICEMODE *d1, NT_DEVICEMODE *d2) return False; } - if (d1->specversion != d2->specversion || - d1->driverversion != d2->driverversion || - d1->size != d2->size || - d1->driverextra != d2->driverextra || - d1->orientation != d2->orientation || - d1->papersize != d2->papersize || - d1->paperlength != d2->paperlength || - d1->paperwidth != d2->paperwidth || - d1->scale != d2->scale || - d1->copies != d2->copies || - d1->defaultsource != d2->defaultsource || - d1->printquality != d2->printquality || - d1->color != d2->color || - d1->duplex != d2->duplex || - d1->yresolution != d2->yresolution || - d1->ttoption != d2->ttoption || - d1->collate != d2->collate || - d1->logpixels != d2->logpixels) { - DEBUG(10, ("nt_devicemode_equal(): specversion-logpixels " - "not equal\n")); - return False; - } - - if (d1->fields != d2->fields || - d1->bitsperpel != d2->bitsperpel || - d1->pelswidth != d2->pelswidth || - d1->pelsheight != d2->pelsheight || - d1->displayflags != d2->displayflags || - d1->displayfrequency != d2->displayfrequency || - d1->icmmethod != d2->icmmethod || - d1->icmintent != d2->icmintent || - d1->mediatype != d2->mediatype || - d1->dithertype != d2->dithertype || - d1->reserved1 != d2->reserved1 || - d1->reserved2 != d2->reserved2 || - d1->panningwidth != d2->panningwidth || - d1->panningheight != d2->panningheight) { - DEBUG(10, ("nt_devicemode_equal(): fields-panningheight " - "not equal\n")); - return False; - } + DEVMODE_CHECK_INT(specversion); + DEVMODE_CHECK_INT(driverversion); + DEVMODE_CHECK_INT(driverextra); + DEVMODE_CHECK_INT(orientation); + DEVMODE_CHECK_INT(papersize); + DEVMODE_CHECK_INT(paperlength); + DEVMODE_CHECK_INT(paperwidth); + DEVMODE_CHECK_INT(scale); + DEVMODE_CHECK_INT(copies); + DEVMODE_CHECK_INT(defaultsource); + DEVMODE_CHECK_INT(printquality); + DEVMODE_CHECK_INT(color); + DEVMODE_CHECK_INT(duplex); + DEVMODE_CHECK_INT(yresolution); + DEVMODE_CHECK_INT(ttoption); + DEVMODE_CHECK_INT(collate); + DEVMODE_CHECK_INT(logpixels); + + DEVMODE_CHECK_INT(fields); + DEVMODE_CHECK_INT(bitsperpel); + DEVMODE_CHECK_INT(pelswidth); + DEVMODE_CHECK_INT(pelsheight); + DEVMODE_CHECK_INT(displayflags); + DEVMODE_CHECK_INT(displayfrequency); + DEVMODE_CHECK_INT(icmmethod); + DEVMODE_CHECK_INT(icmintent); + DEVMODE_CHECK_INT(mediatype); + DEVMODE_CHECK_INT(dithertype); + DEVMODE_CHECK_INT(reserved1); + DEVMODE_CHECK_INT(reserved2); + DEVMODE_CHECK_INT(panningwidth); + DEVMODE_CHECK_INT(panningheight); /* compare the private data if it exists */ if (!d1->driverextra && !d2->driverextra) goto equal; - if (d1->driverextra != d2->driverextra) { - DEBUG(10, ("nt_devicemode_equal(): driverextra not equal\n")); - return False; - } + + DEVMODE_CHECK_INT(driverextra); if (memcmp(d1->private, d2->private, d1->driverextra)) { DEBUG(10, ("nt_devicemode_equal(): private data not equal\n")); @@ -3629,21 +3630,40 @@ static BOOL nt_printer_param_equal(NT_PRINTER_PARAM *p1, while(q) { - if (strequal(p1->value, q->value) && - p1->type == q->type && - p1->data_len == q->data_len && - memcmp(p1->data, q->data, p1->data_len) == 0) { - found = True; - goto found_it; + if (strequal(p1->value, q->value)) { + + if (p1->type != q->type) { + DEBUG(10, ("nt_printer_param_equal():" + "types for %s differ (%d != %d)\n", + p1->value, p1->type, + q->type)); + break; + } + + if (p1->data_len != q->data_len) { + DEBUG(10, ("nt_printer_param_equal():" + "len for %s differs (%d != %d)\n", + p1->value, p1->data_len, + q->data_len)); + break; + } + + if (memcmp(p1->data, q->data, p1->data_len) == 0) { + found = True; + } else { + DEBUG(10, ("nt_printer_param_equal():" + "data for %s differs\n", p1->value)); + } + + break; } q = q->next; } - found_it: if (!found) { DEBUG(10, ("nt_printer_param_equal(): param %s " - "differs\n", p1->value)); + "does not exist\n", p1->value)); return False; } @@ -3661,6 +3681,20 @@ static BOOL nt_printer_param_equal(NT_PRINTER_PARAM *p1, * actually update printer info. ********************************************************************/ +#define PI_CHECK_INT(field) \ + if (pi1->field != pi2->field) { \ + DEBUG(10, ("nt_printer_info_level_equal(): " #field " not equal (%d != %d)\n", \ + pi1->field, pi2->field)); \ + return False; \ + } + +#define PI_CHECK_STR(field) \ + if (!strequal(pi1->field, pi2->field)) { \ + DEBUG(10, ("nt_printer_info_level_equal(): " #field " not equal (%s != %s)\n", \ + pi1->field, pi2->field)); \ + return False; \ + } + static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, NT_PRINTER_INFO_LEVEL *p2) { @@ -3687,44 +3721,32 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, pi1 = p1->info_2; pi2 = p2->info_2; - if (pi1->attributes != pi2->attributes || - pi1->priority != pi2->priority || - pi1->default_priority != pi2->default_priority || - pi1->starttime != pi2->starttime || - pi1->untiltime != pi2->untiltime || - pi1->averageppm != pi2->averageppm) { - DEBUG(10, ("nt_printer_info_level_equal(): attr-ppm values " - "differ\n")); - return False; - } + PI_CHECK_INT(attributes); + PI_CHECK_INT(priority); + PI_CHECK_INT(default_priority); + PI_CHECK_INT(starttime); + PI_CHECK_INT(untiltime); + PI_CHECK_INT(averageppm); /* Yuck - don't check the printername or servername as the add_a_printer() code plays games with them. You can't change the printername or the sharename through this interface in Samba. */ - if (!strequal(pi1->sharename, pi2->sharename) || - !strequal(pi1->portname, pi2->portname) || - !strequal(pi1->drivername, pi2->drivername) || - !strequal(pi1->comment, pi2->comment) || - !strequal(pi1->location, pi2->location)) { - DEBUG(10, ("nt_printer_info_level_equal(): values for names " - "differ\n")); - return False; - } + PI_CHECK_STR(sharename); + PI_CHECK_STR(portname); + PI_CHECK_STR(drivername); + PI_CHECK_STR(comment); + PI_CHECK_STR(location); if (!nt_devicemode_equal(pi1->devmode, pi2->devmode)) { return False; } - if (!strequal(pi1->sepfile, pi2->sepfile) || - !strequal(pi1->printprocessor, pi2->printprocessor) || - !strequal(pi1->datatype, pi2->datatype) || - !strequal(pi1->parameters, pi2->parameters)) { - DEBUG(10, ("nt_printer_info_level_equal(): sep-params values " - "differ\n")); - return False; - } + PI_CHECK_STR(sepfile); + PI_CHECK_STR(printprocessor); + PI_CHECK_STR(datatype); + PI_CHECK_STR(parameters); if (!nt_printer_param_equal(pi1->specific, pi2->specific)) { return False; @@ -3734,13 +3756,9 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, return False; } - if (pi1->changeid != pi2->changeid || - pi1->c_setprinter != pi2->c_setprinter || - pi1->setuptime != pi2->setuptime) { - DEBUG(10, ("nt_printer_info_level_equal(): id-setuptime " - "values differ\n")); - return False; - } + PI_CHECK_INT(changeid); + PI_CHECK_INT(c_setprinter); + PI_CHECK_INT(setuptime); equal: DEBUG(10, ("nt_printer_info_level_equal(): infos are identical\n")); -- cgit From 21f0dc985ae2d6c3ef85bcca34f07d216f51b692 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 21 Dec 2000 23:23:34 +0000 Subject: merge from appliance head (This used to be commit 4671a313775f052ae949ba441db7e0060bed0b75) --- source3/rpc_server/srv_spoolss_nt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 38a4b26a60..cd67a3b88a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -779,13 +779,16 @@ static BOOL convert_devicemode(const DEVICEMODE *devmode, NT_DEVICEMODE *nt_devm nt_devmode->panningwidth=devmode->panningwidth; nt_devmode->panningheight=devmode->panningheight; + safe_free(nt_devmode->private); if (nt_devmode->driverextra != 0) { /* if we had a previous private delete it and make a new one */ - safe_free(nt_devmode->private); if((nt_devmode->private=(uint8 *)malloc(nt_devmode->driverextra * sizeof(uint8))) == NULL) return False; memcpy(nt_devmode->private, devmode->private, nt_devmode->driverextra); } + else { + nt_devmode->private = NULL; + } return True; } -- cgit From 85b1953f6dfb8a8219da1b4ee75ba22982853ffb Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Fri, 5 Jan 2001 19:01:11 +0000 Subject: Changes from APPLIANCE_HEAD: source/rpc_server/srv_spoolss_nt.c - fixed printer policy handle leak in the allow MS printer wizard stuff. - mimic behaviour of NT on open_printer_ex() calls by not allowing call to succeed if connecting user doesn't have at least print permissions to the printer. Unfortunately, this seems to trigger a anonymous connection re-using bug so subsequent connects to the printer by a different user from the same machine always fail. Blame Tim. =^) (This used to be commit 33fc7f4527c34b39b1a0f3fee2f0697ea74f79c4) --- source3/rpc_server/srv_spoolss_nt.c | 57 ++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cd67a3b88a..bcd9b46256 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -655,10 +655,16 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, uint32 user_switch, SPOOL_USER_CTR user_ctr, POLICY_HND *handle) { + uint32 result = NT_STATUS_NO_PROBLEMO; + SEC_DESC_BUF *sec_desc = NULL; + uint32 acc_granted, status; fstring name; + extern struct current_user current_user; - if (printername == NULL) - return ERROR_INVALID_PRINTER_NAME; + if (printername == NULL) { + result = ERROR_INVALID_PRINTER_NAME; + goto done; + } /* some sanity check because you can open a printer or a print server */ /* aka: \\server\printer or \\server */ @@ -666,8 +672,10 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, DEBUGADD(3,("checking name: %s\n",name)); - if (!open_printer_hnd(handle, name)) - return ERROR_INVALID_PRINTER_NAME; + if (!open_printer_hnd(handle, name)) { + result = ERROR_INVALID_PRINTER_NAME; + goto done; + } /* if (printer_default->datatype_ptr != NULL) @@ -681,7 +689,8 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, if (!set_printer_hnd_accesstype(handle, printer_default->access_required)) { close_printer_handle(handle); - return ERROR_ACCESS_DENIED; + result = ERROR_ACCESS_DENIED; + goto done; } /* Disallow MS AddPrinterWizard if parameter disables it. A Win2k @@ -696,13 +705,41 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, if (handle_is_printserver(handle) && !lp_ms_add_printer_wizard()) { - if (printer_default->access_required == 0) - return NT_STATUS_NO_PROBLEMO; - else if (printer_default->access_required != (SERVER_READ)) - return ERROR_ACCESS_DENIED; + if (printer_default->access_required == 0) { + goto done; + } + else if (printer_default->access_required != (SERVER_READ)) { + close_printer_handle(handle); + result = ERROR_ACCESS_DENIED; + goto done; + } } - return NT_STATUS_NO_PROBLEMO; + /* NT doesn't let us connect to a printer if the connecting user + doesn't have print permission. If no security descriptor just + return OK. */ + + if (!nt_printing_getsec(name, &sec_desc)) { + goto done; + } + + /* Yuck - we should use the pipe_user rather than current_user but + it doesn't seem to be filled in correctly. )-: */ + + map_printer_permissions(sec_desc->sec); + + if (!se_access_check(sec_desc->sec, ¤t_user, PRINTER_ACCESS_USE, + &acc_granted, &status)) { + DEBUG(3, ("access DENIED for printer open\n")); + close_printer_handle(handle); + result = ERROR_ACCESS_DENIED; + goto done; + } + + done: + free_sec_desc_buf(&sec_desc); + + return result; } /**************************************************************************** -- cgit From ab60974082e1dea0280eb4c80a48f900c0b55995 Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Mon, 8 Jan 2001 19:58:30 +0000 Subject: Changes merged from APPLIANCE_HEAD: source/printing/printing.c source/rpc_server/srv_spoolss_nt.c - convert args for print command to unix codepage. (This used to be commit 1c0ae957f8f1abee7d22a18b6df092eb2a884ae1) --- source3/rpc_server/srv_spoolss_nt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index bcd9b46256..74cc19eee1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3546,6 +3546,9 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) printer->info_2->location, driverlocation); unlink(tmp_file); + + /* Convert script args to unix-codepage */ + dos_to_unix(command, True); DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); ret = smbrun(command, tmp_file, False); DEBUGADD(10,("returned [%d]\n", ret)); @@ -3556,9 +3559,10 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) } numlines = 0; + /* Get lines and convert them back to dos-codepage */ qlines = file_lines_load(tmp_file, &numlines, True); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); - DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file)); + DEBUGADD(10,("Unlinking script output file [%s]\n", tmp_file)); unlink(tmp_file); if(numlines) { -- cgit From 17ab0c2acc1321d8228f604d207deacb1bdd3575 Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Wed, 10 Jan 2001 16:05:41 +0000 Subject: Changes from APPLIANCE_HEAD: source/include/proto.h source/param/loadparm.c source/passdb/passdb.c source/rpc_server/srv_samr.c - add support for "hide local users" option to HEAD. (This used to be commit 44dc339fe757b2b5578b30e74aad8c1b12c23f5f) --- source3/rpc_server/srv_samr.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 352852038a..b0991f7627 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -210,6 +210,10 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, (*num_entries) = 0; (*total_entries) = 0; + /* Skip all this stuff if we're in appliance mode */ + + if (lp_hide_local_users()) goto done; + if (pw_buf == NULL) return False; if (current_idx == 0) { @@ -340,6 +344,7 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, mapped_idx = 0; } +done: return (*num_entries) > 0; } @@ -759,14 +764,16 @@ static BOOL samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, if (strequal(sid_str, "S-1-5-32")) { char *name; - while (num_entries < MAX_SAM_ENTRIES && ((name = builtin_alias_rids[num_entries].name) != NULL)) + while (!lp_hide_local_users() && + num_entries < MAX_SAM_ENTRIES && + ((name = builtin_alias_rids[num_entries].name) != NULL)) { init_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)+1); pass[num_entries].user_rid = builtin_alias_rids[num_entries].rid; num_entries++; } } - else if (strequal(sid_str, sam_sid_str)) + else if (strequal(sid_str, sam_sid_str) && !lp_hide_local_users()) { char *name; char *sep; -- cgit From adb91565b5ec81ebb9e0d57b7d91fbd9da410aa3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 11 Jan 2001 18:38:55 +0000 Subject: rpc_server/srv_samr.c: smbd/reply.c: Added fix needed for appliances. When using winbindd - a new user may exist (from winbind) but have no home directory. Extend add user script so it is called with a %H substitution when a user exists but their home directory does not. Thanks to Alex Win at VA Linux for finding this one and testing the fix. libsmb/clidgram.c: Fixed missing return statements. smbd/uid.c: Fixed typo in debug. Jeremy. (This used to be commit 7ba0a2192b89954604dd793c537b4a17c2d1ac07) --- source3/rpc_server/srv_samr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index b0991f7627..fefa547a37 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1839,7 +1839,7 @@ static BOOL _api_samr_create_user(POLICY_HND dom_pol, UNISTR2 user_account, uint /* add the user in the /etc/passwd file or the unix authority system */ if (lp_adduser_script()) - smb_create_user(mach_acct); + 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, -- cgit From 3380ffae9c231a34406dd694c9ab03bb0b6d8070 Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Thu, 11 Jan 2001 20:41:19 +0000 Subject: Changes from APPLIANCE_HEAD: testsuite/printing/psec.c - Use lock directory from smb.conf parameter when peeking at the ntdrivers.tdb file. source/rpc_parse/parse_sec.c - fix typo in debug message source/script/installbin.sh - create private directory as part of 'make install'. source/nsswitch/winbindd_cache.c source/nsswitch/winbindd_idmap.c source/passdb/secrets.c source/smbd/connection.c - always convert tdb key to unix code-page when generating. source/printing/nt_printing.c - always convert tdb key to unix code-page when generating. - don't prepend path to a filename that is NULL in add_a_printer_driver_3(). source/rpc_server/srv_spoolss_nt.c - always convert tdb key to unix code-page when generating. - don't prepend server name to a path/filename that is NULL in the fill_printer_driver_info functions. source/printing/printing.c - always convert tdb key to unix code-page when generating. - move access check for print_queue_purge() outside of job delete loop. source/smbd/unix_acls.c - fix for setting ACLs (this got missed earlier) source/lib/messages.c - trivial sync with appliance_head (This used to be commit 376601d17d53ef7bfaafa576bd770e554516e808) --- source3/rpc_server/srv_spoolss_nt.c | 112 ++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 43 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 74cc19eee1..23f8ab15ef 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2740,23 +2740,31 @@ static uint32 construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fst ********************************************************************/ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) { - pstring temp_driverpath; - pstring temp_datafile; - pstring temp_configfile; + pstring temp; info->version=driver.info_3->cversion; init_unistr( &info->name, driver.info_3->name ); init_unistr( &info->architecture, driver.info_3->environment ); - snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "\\\\%s%s", servername, driver.info_3->driverpath); - init_unistr( &info->driverpath, temp_driverpath ); - snprintf(temp_datafile, sizeof(temp_datafile)-1, "\\\\%s%s", servername, driver.info_3->datafile); - init_unistr( &info->datafile, temp_datafile ); + if (strlen(driver.info_3->driverpath)) { + snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + init_unistr( &info->driverpath, temp ); + } else + init_unistr( &info->driverpath, "" ); - snprintf(temp_configfile, sizeof(temp_configfile)-1, "\\\\%s%s", servername, driver.info_3->configfile); - init_unistr( &info->configfile, temp_configfile ); + if (strlen(driver.info_3->datafile)) { + snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); + init_unistr( &info->datafile, temp ); + } else + init_unistr( &info->datafile, "" ); + + if (strlen(driver.info_3->configfile)) { + snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); + init_unistr( &info->configfile, temp ); + } else + init_unistr( &info->configfile, "" ); } /******************************************************************** @@ -2830,10 +2838,7 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser ********************************************************************/ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) { - pstring temp_driverpath; - pstring temp_datafile; - pstring temp_configfile; - pstring temp_helpfile; + pstring temp; ZERO_STRUCTP(info); @@ -2842,17 +2847,29 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->name, driver.info_3->name ); init_unistr( &info->architecture, driver.info_3->environment ); - snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "\\\\%s%s", servername, driver.info_3->driverpath); - init_unistr( &info->driverpath, temp_driverpath ); - - snprintf(temp_datafile, sizeof(temp_datafile)-1, "\\\\%s%s", servername, driver.info_3->datafile); - init_unistr( &info->datafile, temp_datafile ); - - snprintf(temp_configfile, sizeof(temp_configfile)-1, "\\\\%s%s", servername, driver.info_3->configfile); - init_unistr( &info->configfile, temp_configfile ); - - snprintf(temp_helpfile, sizeof(temp_helpfile)-1, "\\\\%s%s", servername, driver.info_3->helpfile); - init_unistr( &info->helpfile, temp_helpfile ); + if (strlen(driver.info_3->driverpath)) { + snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + init_unistr( &info->driverpath, temp ); + } else + init_unistr( &info->driverpath, "" ); + + if (strlen(driver.info_3->datafile)) { + snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); + init_unistr( &info->datafile, temp ); + } else + init_unistr( &info->datafile, "" ); + + if (strlen(driver.info_3->configfile)) { + snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); + init_unistr( &info->configfile, temp ); + } else + init_unistr( &info->configfile, "" ); + + if (strlen(driver.info_3->helpfile)) { + snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile); + init_unistr( &info->helpfile, temp ); + } else + init_unistr( &info->helpfile, "" ); init_unistr( &info->monitorname, driver.info_3->monitorname ); init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype ); @@ -2898,10 +2915,7 @@ static uint32 construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) { - pstring temp_driverpath; - pstring temp_datafile; - pstring temp_configfile; - pstring temp_helpfile; + pstring temp; fstring nullstr; ZERO_STRUCTP(info); @@ -2912,18 +2926,30 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->name, driver.info_3->name ); init_unistr( &info->architecture, driver.info_3->environment ); - snprintf(temp_driverpath, sizeof(temp_driverpath)-1, "\\\\%s%s", servername, driver.info_3->driverpath); - init_unistr( &info->driverpath, temp_driverpath ); - - snprintf(temp_datafile, sizeof(temp_datafile)-1, "\\\\%s%s", servername, driver.info_3->datafile); - init_unistr( &info->datafile, temp_datafile ); - - snprintf(temp_configfile, sizeof(temp_configfile)-1, "\\\\%s%s", servername, driver.info_3->configfile); - init_unistr( &info->configfile, temp_configfile ); - - snprintf(temp_helpfile, sizeof(temp_helpfile)-1, "\\\\%s%s", servername, driver.info_3->helpfile); - init_unistr( &info->helpfile, temp_helpfile ); - + if (strlen(driver.info_3->driverpath)) { + snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + init_unistr( &info->driverpath, temp ); + } else + init_unistr( &info->driverpath, "" ); + + if (strlen(driver.info_3->datafile)) { + snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); + init_unistr( &info->datafile, temp ); + } else + init_unistr( &info->datafile, "" ); + + if (strlen(driver.info_3->configfile)) { + snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); + init_unistr( &info->configfile, temp ); + } else + init_unistr( &info->configfile, "" ); + + if (strlen(driver.info_3->helpfile)) { + snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile); + init_unistr( &info->helpfile, temp ); + } else + init_unistr( &info->helpfile, "" ); + init_unistr( &info->monitorname, driver.info_3->monitorname ); init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype ); @@ -3547,8 +3573,8 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) unlink(tmp_file); - /* Convert script args to unix-codepage */ - dos_to_unix(command, True); + /* Convert script args to unix-codepage */ + dos_to_unix(command, True); DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); ret = smbrun(command, tmp_file, False); DEBUGADD(10,("returned [%d]\n", ret)); @@ -3559,7 +3585,7 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) } numlines = 0; - /* Get lines and convert them back to dos-codepage */ + /* Get lines and convert them back to dos-codepage */ qlines = file_lines_load(tmp_file, &numlines, True); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); DEBUGADD(10,("Unlinking script output file [%s]\n", tmp_file)); -- cgit From 13d99e3ea90cf15296630bea2b2bb38e9485fc4e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 11 Jan 2001 23:49:51 +0000 Subject: RPC server fixes for RPC client changes merged from TNG. (This used to be commit 793153ebde08db217a18882c5eec945b7b14de69) --- source3/rpc_server/srv_samr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index fefa547a37..30a0350f67 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -413,7 +413,7 @@ static BOOL samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, r_u.status = 0x0; /* find the connection policy handle. */ - if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->connect_pol)) == -1)) + if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) { r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; } @@ -1995,7 +1995,9 @@ static BOOL samr_reply_connect(SAMR_Q_CONNECT *q_u, prs_struct *rdata) } /* associate the domain SID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_lsa_policy_samr_pol_status(&(r_u.connect_pol), q_u->unknown_0)) + if (r_u.status == 0x0 && + !set_lsa_policy_samr_pol_status(&(r_u.connect_pol), + q_u->access_mask)) { /* oh, whoops. don't know what error message to return, here */ r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; -- cgit From 27922c0430bf28dca910d2a2903cf410a4187643 Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Mon, 15 Jan 2001 18:36:50 +0000 Subject: Changes from APPLIANCE_HEAD: source/rpc_parse/parse_lsa.c - off by one unistr length bug in init_lsa_trans_name() source/lib/util_sid.c - resolve more BUILTIN sid values to names. source/nsswitch/wb_client.c - fix typo in debug message - set errno on error so we don't get bogus value from last failure. source/rpc_server/srv_spoolss_nt.c - add debug to track number of open printer handles for ease of tracking handle leaks in the future. source/rpc_server/srv_lsa.c - fix off-by-one string bug. This was preventing NT from displaying names for well-know SIDs in printer permissions dialog. (This used to be commit 59229b9025cff54cbdd05e374616ffbf9c6fee33) --- source3/rpc_server/srv_lsa.c | 6 +++--- source3/rpc_server/srv_spoolss_nt.c | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index ed65e787b4..3538beefda 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -88,13 +88,13 @@ Init dom_query static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) { - int domlen = (dom_name != NULL) ? strlen(dom_name)+1 : 0; + int domlen = (dom_name != NULL) ? strlen(dom_name) : 0; d_q->uni_dom_max_len = domlen * 2; d_q->uni_dom_str_len = domlen * 2; - d_q->buffer_dom_name = (dom_name != 0) ? 1 : 0; - d_q->buffer_dom_sid = (dom_sid != NULL) ? 1 : 0; + d_q->buffer_dom_name = dom_name ? 1 : 0; + d_q->buffer_dom_sid = dom_sid ? 1 : 0; /* this string is supposed to be character short */ init_unistr2(&d_q->uni_domain_name, dom_name, domlen); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 23f8ab15ef..4355e2eb59 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -526,6 +526,8 @@ static BOOL open_printer_hnd(POLICY_HND *hnd, char *name) return False; } + DEBUG(5, ("%d printer handles active\n", ubi_dlCount(&Printer_list))); + return True; } -- cgit From 792ca5d98938c3c52ff4e598bcb55056565dc202 Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Wed, 17 Jan 2001 18:47:46 +0000 Subject: Changes from APPLIANCE_HEAD: source/rpc_server/srv_spoolss_nt.c - Unrolled construct_notify_jobs_info() loop to only fetch printer info_2 structure once rather than num_print_jobs times. - convert command to unix codepage. - remove lp_remove_service() call as it prevents lp_killservice() from working. - Modified some DEBUG and DEBUGADD statements. source/param/loadparm.c source/param/params.c - change printer, preload, auto services to FLAG_DOS_STRING, reverted earlier changes to szPrintername et al, add comments. source/printing/load.c - fix bug with lp_auto_services() and strtok() source/printing/nt_printing.c source/printing/printing.c - remove redundant test that used SERVICE(snum) source/printing/pcap.c - add unix_to_dos() calls, add notes wrt FIXMEs for xxx_printer_fn() functions. source/web/swat.c - added FIXME comment. source/smbd/service.c - added comment re: dos codepage (This used to be commit 7b774b72c2857af9519012106714a9e2cb099da3) --- source3/rpc_server/srv_spoolss_nt.c | 51 ++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4355e2eb59..0654eea6f4 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -272,6 +272,7 @@ static BOOL delete_printer_handle(POLICY_HND *hnd) /* Printer->dev.handlename equals portname equals sharename */ slprintf(command, sizeof(command), "%s \"%s\"", cmd, Printer->dev.handlename); + dos_to_unix(command, True); /* Convert printername to unix-codepage */ slprintf(tmp_file, sizeof(tmp_file), "%s/smbcmd.%d", path, local_pid); unlink(tmp_file); @@ -289,7 +290,6 @@ static BOOL delete_printer_handle(POLICY_HND *hnd) kill(0, SIGHUP); if ( ( i = lp_servicenumber( Printer->dev.handlename ) ) >= 0 ) { - lp_remove_service( i ); lp_killservice( i ); return True; } else @@ -526,7 +526,8 @@ static BOOL open_printer_hnd(POLICY_HND *hnd, char *name) return False; } - DEBUG(5, ("%d printer handles active\n", ubi_dlCount(&Printer_list))); + DEBUG(5, ("%d printer handles active\n", + (int)ubi_dlCount(&Printer_list))); return True; } @@ -1604,11 +1605,9 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO NT_PRINTER_INFO_LEVEL *printer = NULL; print_queue_struct *queue=NULL; - DEBUG(4,("construct_notify_printer_info\n")); - type=option_type->type; - DEBUGADD(4,("Notify type: [%s], number of notify info: [%d] on printer: [%s]\n", + DEBUG(4,("construct_notify_printer_info: Notify type: [%s], number of notify info: [%d] on printer: [%s]\n", (option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"), option_type->count, lp_servicename(snum))); @@ -1617,7 +1616,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO for(field_num=0; field_numcount; field_num++) { field = option_type->fields[field_num]; - DEBUGADD(4,("notify [%d]: type [%x], field [%x]\n", field_num, type, field)); + DEBUG(4,("construct_notify_printer_info: notify [%d]: type [%x], field [%x]\n", field_num, type, field)); if (!search_notify(type, field, &j) ) continue; @@ -1629,8 +1628,8 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO construct_info_data(current_data, type, field, id); - DEBUG(10,("construct_notify_printer_info: calling %s\n", - notify_info_data_table[j].name )); + DEBUG(10,("construct_notify_printer_info: calling [%s] snum=%d printername=[%s])\n", + notify_info_data_table[j].name, snum, printer->info_2->printername )); notify_info_data_table[j].fn(snum, current_data, queue, printer); @@ -1646,14 +1645,17 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO * fill a notify_info struct with info asked * ********************************************************************/ -static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id) +static BOOL construct_notify_jobs_info(print_queue_struct *queue, + SPOOL_NOTIFY_INFO *info, + NT_PRINTER_INFO_LEVEL *printer, + int snum, SPOOL_NOTIFY_OPTION_TYPE + *option_type, uint32 id) { int field_num,j; uint16 type; uint16 field; SPOOL_NOTIFY_INFO_DATA *current_data; - NT_PRINTER_INFO_LEVEL *printer = NULL; DEBUG(4,("construct_notify_jobs_info\n")); @@ -1663,9 +1665,6 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I (option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"), option_type->count)); - if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) - return False; - for(field_num=0; field_numcount; field_num++) { field = option_type->fields[field_num]; @@ -1683,7 +1682,6 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I info->count++; } - free_a_printer(&printer, 2); return True; } @@ -1798,18 +1796,35 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) switch ( option_type->type ) { case PRINTER_NOTIFY_TYPE: - if(construct_notify_printer_info(info, snum, option_type, id)) + if(construct_notify_printer_info(info, snum, + option_type, id)) id--; break; - case JOB_NOTIFY_TYPE: + case JOB_NOTIFY_TYPE: { + NT_PRINTER_INFO_LEVEL *printer = NULL; + memset(&status, 0, sizeof(status)); count = print_queue_status(snum, &queue, &status); - for (j=0; j Date: Wed, 17 Jan 2001 22:55:02 +0000 Subject: Changes from APPLIANCE_HEAD: source/include/proto.h source/include/rpc_spoolss.h source/rpc_parse/parse_spoolss.c source/rpc_server/srv_spoolss.c source/rpc_server/srv_spoolss_nt.c - speedups in printer queue enumeration - still room for improvement. The construct_dev_mode() still creates and destroys a printer info_2 structure every time it is called. - fixed job->devmode memory leak - converted printer job notification routines to use tallocated memory rather than a fixed 2K buffer. This reduces the memory requirements of a 4500 job queue enumeration from 90MB to about 16MB. (This used to be commit 7853b27bc1765d48d5f06837f8aca71a3a0d1e5d) --- source3/rpc_server/srv_spoolss.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 526 +++++++++++++++++++++++++++++------- 2 files changed, 432 insertions(+), 96 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 72ce17fee1..8d7d238ad0 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -277,7 +277,7 @@ static BOOL api_spoolss_rfnpcnex(pipes_struct *p) } r_u.status = _spoolss_rfnpcnex(&q_u.handle, q_u.change, - q_u.option, &r_u.info); + q_u.option, data->mem_ctx, &r_u.info); safe_free(q_u.option); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0654eea6f4..24626d1a9a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -273,7 +273,7 @@ static BOOL delete_printer_handle(POLICY_HND *hnd) slprintf(command, sizeof(command), "%s \"%s\"", cmd, Printer->dev.handlename); dos_to_unix(command, True); /* Convert printername to unix-codepage */ - slprintf(tmp_file, sizeof(tmp_file), "%s/smbcmd.%d", path, local_pid); + slprintf(tmp_file, sizeof(tmp_file), "%s/smbcmd.%d", path, local_pid); unlink(tmp_file); DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); @@ -1132,53 +1132,116 @@ uint32 _spoolss_rffpcnex(POLICY_HND *handle, uint32 flags, uint32 options, /******************************************************************* * fill a notify_info_data with the servername ********************************************************************/ -static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, - NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_server_name(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { - pstring temp_name; + pstring temp_name, temp; + uint32 len; snprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname); - data->notify_data.data.length= (uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - temp_name, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16)); + len = (uint32)dos_PutUniCode(temp, temp_name, sizeof(temp) - 2, True); + + data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + + memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* * fill a notify_info_data with the printername (not including the servername). ********************************************************************/ -static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, - NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_printer_name(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { + pstring temp; + uint32 len; + /* the notify name should not contain the \\server\ part */ char *p = strrchr(printer->info_2->printername, '\\'); + if (!p) { p = printer->info_2->printername; } else { p++; } - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - p, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16)); + len = (uint32)dos_PutUniCode(temp, p, sizeof(temp) - 2, True); + + data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + + memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* * fill a notify_info_data with the servicename ********************************************************************/ -static void spoolss_notify_share_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_share_name(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - lp_servicename(snum), sizeof(data->notify_data.data.string),True) - sizeof(uint16))/sizeof(uint16)); + pstring temp; + uint32 len; + + len = (uint32)dos_PutUniCode(temp, lp_servicename(snum), + sizeof(temp) - 2, True); + + data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + + memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* * fill a notify_info_data with the port name ********************************************************************/ -static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_port_name(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { + pstring temp; + uint32 len; + /* even if it's strange, that's consistant in all the code */ - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - printer->info_2->portname, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16)); + len = (uint32)dos_PutUniCode(temp, printer->info_2->portname, + sizeof(temp) - 2, True); + + data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + + memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* @@ -1186,23 +1249,57 @@ static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, pri * jfmxxxx: it's incorrect, should be lp_printerdrivername() * but it doesn't exist, have to see what to do ********************************************************************/ -static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_driver_name(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - printer->info_2->drivername, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); + pstring temp; + uint32 len; + + len = (uint32)dos_PutUniCode(temp, printer->info_2->drivername, + sizeof(temp) - 2, True); + + data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + + memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* * fill a notify_info_data with the comment ********************************************************************/ -static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_comment(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { + pstring temp; + uint32 len; + if (*printer->info_2->comment == '\0') - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - lp_comment(snum), sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); + len = (uint32)dos_PutUniCode(temp, lp_comment(snum), + sizeof(temp) - 2, True); else - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - printer->info_2->comment, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); + len = (uint32)dos_PutUniCode(temp, printer->info_2->comment, + sizeof(temp) - 2, True); + + data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + + memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* @@ -1210,17 +1307,38 @@ static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print * jfm:xxxx incorrect, have to create a new smb.conf option * location = "Room 1, floor 2, building 3" ********************************************************************/ -static void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_location(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - printer->info_2->location, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); + pstring temp; + uint32 len; + + len = (uint32)dos_PutUniCode(temp, printer->info_2->location, + sizeof(temp) - 2, True); + + data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + + memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* * fill a notify_info_data with the device mode * jfm:xxxx don't to it for know but that's a real problem !!! ********************************************************************/ -static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_devmode(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { } @@ -1229,40 +1347,108 @@ static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print * jfm:xxxx just return no file could add an option to smb.conf * separator file = "separator.txt" ********************************************************************/ -static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_sepfile(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - printer->info_2->sepfile, sizeof(data->notify_data.data.string)-1,True) - sizeof(uint16))/sizeof(uint16)); + pstring temp; + uint32 len; + + len = (uint32)dos_PutUniCode(temp, printer->info_2->sepfile, + sizeof(temp) - 2, True); + + data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + + memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* * fill a notify_info_data with the print processor * jfm:xxxx return always winprint to indicate we don't do anything to it ********************************************************************/ -static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_print_processor(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - printer->info_2->printprocessor, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); + pstring temp; + uint32 len; + + len = (uint32)dos_PutUniCode(temp, printer->info_2->printprocessor, + sizeof(temp) - 2, True); + + data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + + memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* * fill a notify_info_data with the print processor options * jfm:xxxx send an empty string ********************************************************************/ -static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_parameters(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - printer->info_2->parameters, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); + pstring temp; + uint32 len; + + len = (uint32)dos_PutUniCode(temp, printer->info_2->parameters, + sizeof(temp) - 2, True); + + data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + + memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* * fill a notify_info_data with the data type * jfm:xxxx always send RAW as data type ********************************************************************/ -static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_datatype(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - printer->info_2->datatype, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); + pstring temp; + uint32 len; + + len = (uint32)dos_PutUniCode(temp, printer->info_2->datatype, + sizeof(pstring) - 2, True); + + data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + + memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* @@ -1270,7 +1456,11 @@ static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin * jfm:xxxx send an null pointer to say no security desc * have to implement security before ! ********************************************************************/ -static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_security_desc(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { data->notify_data.data.length=0; data->notify_data.data.string[0]=0x00; @@ -1280,7 +1470,11 @@ static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data, * fill a notify_info_data with the attributes * jfm:xxxx a samba printer is always shared ********************************************************************/ -static void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_attributes(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { data->notify_data.value[0] = printer->info_2->attributes; } @@ -1288,7 +1482,11 @@ static void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr /******************************************************************* * fill a notify_info_data with the priority ********************************************************************/ -static void spoolss_notify_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_priority(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { data->notify_data.value[0] = printer->info_2->priority; } @@ -1296,7 +1494,11 @@ static void spoolss_notify_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin /******************************************************************* * fill a notify_info_data with the default priority ********************************************************************/ -static void spoolss_notify_default_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_default_priority(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { data->notify_data.value[0] = printer->info_2->default_priority; } @@ -1304,7 +1506,11 @@ static void spoolss_notify_default_priority(int snum, SPOOL_NOTIFY_INFO_DATA *da /******************************************************************* * fill a notify_info_data with the start time ********************************************************************/ -static void spoolss_notify_start_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_start_time(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { data->notify_data.value[0] = printer->info_2->starttime; } @@ -1312,7 +1518,11 @@ static void spoolss_notify_start_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr /******************************************************************* * fill a notify_info_data with the until time ********************************************************************/ -static void spoolss_notify_until_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_until_time(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { data->notify_data.value[0] = printer->info_2->untiltime; } @@ -1320,9 +1530,14 @@ static void spoolss_notify_until_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr /******************************************************************* * fill a notify_info_data with the status ********************************************************************/ -static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_status(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { int count; + print_queue_struct *q=NULL; print_status_struct status; @@ -1335,7 +1550,11 @@ static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_ /******************************************************************* * fill a notify_info_data with the number of jobs queued ********************************************************************/ -static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_cjobs(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { print_queue_struct *q=NULL; print_status_struct status; @@ -1348,7 +1567,11 @@ static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_q /******************************************************************* * fill a notify_info_data with the average ppm ********************************************************************/ -static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_average_ppm(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { /* always respond 8 pages per minutes */ /* a little hard ! */ @@ -1358,16 +1581,37 @@ static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, p /******************************************************************* * fill a notify_info_data with username ********************************************************************/ -static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_username(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - queue->user, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); + pstring temp; + uint32 len; + + len = (uint32)dos_PutUniCode(temp, queue->user, + sizeof(temp) - 2, True); + + data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + + memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* * fill a notify_info_data with job status ********************************************************************/ -static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_status(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { data->notify_data.value[0]=nt_printj_status(queue->status); } @@ -1375,18 +1619,41 @@ static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr /******************************************************************* * fill a notify_info_data with job name ********************************************************************/ -static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_name(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - queue->file, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); + pstring temp; + uint32 len; + + len = (uint32)dos_PutUniCode(temp, queue->file, sizeof(temp) - 2, + True); + + data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + + memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* * fill a notify_info_data with job status ********************************************************************/ -static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_status_string(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { char *p = "unknown"; + pstring temp; + uint32 len; switch (queue->status) { case LPQ_QUEUED: @@ -1402,14 +1669,28 @@ static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *d p = "Printing"; break; } - data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string, - p, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16)); + + len = (uint32)dos_PutUniCode(temp, p, sizeof(temp) - 2, True); + + data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + + memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* * fill a notify_info_data with job time ********************************************************************/ -static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_time(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { data->notify_data.value[0]=0x0; } @@ -1417,7 +1698,11 @@ static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin /******************************************************************* * fill a notify_info_data with job size ********************************************************************/ -static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_size(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { data->notify_data.value[0]=queue->size; } @@ -1425,7 +1710,11 @@ static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin /******************************************************************* * fill a notify_info_data with job position ********************************************************************/ -static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_job_position(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { data->notify_data.value[0]=queue->job; } @@ -1433,13 +1722,27 @@ static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, /******************************************************************* * fill a notify_info_data with submitted time ********************************************************************/ -static void spoolss_notify_submitted_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer) +static void spoolss_notify_submitted_time(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) { struct tm *t; + uint32 len; t=gmtime(&queue->time); - data->notify_data.data.length = sizeof(SYSTEMTIME); + len = sizeof(SYSTEMTIME); + + data->notify_data.data.length = len; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + make_systemtime((SYSTEMTIME*)(data->notify_data.data.string), t); } @@ -1453,7 +1756,7 @@ struct s_notify_info_data_table uint32 size; void (*fn) (int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, - NT_PRINTER_INFO_LEVEL *printer); + NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx); }; struct s_notify_info_data_table notify_info_data_table[] = @@ -1595,7 +1898,10 @@ static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, * fill a notify_info struct with info asked * ********************************************************************/ -static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id) +static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int + snum, SPOOL_NOTIFY_OPTION_TYPE + *option_type, uint32 id, + TALLOC_CTX *mem_ctx) { int field_num,j; uint16 type; @@ -1631,7 +1937,8 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO DEBUG(10,("construct_notify_printer_info: calling [%s] snum=%d printername=[%s])\n", notify_info_data_table[j].name, snum, printer->info_2->printername )); - notify_info_data_table[j].fn(snum, current_data, queue, printer); + notify_info_data_table[j].fn(snum, current_data, queue, + printer, mem_ctx); info->count++; } @@ -1649,7 +1956,8 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, NT_PRINTER_INFO_LEVEL *printer, int snum, SPOOL_NOTIFY_OPTION_TYPE - *option_type, uint32 id) + *option_type, uint32 id, + TALLOC_CTX *mem_ctx) { int field_num,j; uint16 type; @@ -1678,7 +1986,8 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, current_data=&(info->data[info->count]); construct_info_data(current_data, type, field, id); - notify_info_data_table[j].fn(snum, current_data, queue, printer); + notify_info_data_table[j].fn(snum, current_data, queue, + printer, mem_ctx); info->count++; } @@ -1716,7 +2025,9 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, * fill a notify_info struct with info asked * ********************************************************************/ -static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) +static uint32 printserver_notify_info(const POLICY_HND *hnd, + SPOOL_NOTIFY_INFO *info, + TALLOC_CTX *mem_ctx) { int snum; Printer_entry *Printer=find_printer_index_by_hnd(hnd); @@ -1742,7 +2053,8 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO * for (snum=0; snumtype ) { case PRINTER_NOTIFY_TYPE: - if(construct_notify_printer_info(info, snum, - option_type, id)) + if(construct_notify_printer_info(info, snum, + option_type, id, + mem_ctx)) id--; break; @@ -1815,11 +2129,12 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) construct_notify_jobs_info(&queue[j], info, printer, snum, option_type, - queue[j].job); + queue[j].job, + mem_ctx); } free_a_printer(&printer, 2); - + done: safe_free(queue); break; @@ -1848,13 +2163,16 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info) * spoolss_rfnpcnex ********************************************************************/ uint32 _spoolss_rfnpcnex( POLICY_HND *handle, uint32 change, - SPOOL_NOTIFY_OPTION *option, SPOOL_NOTIFY_INFO *info) + SPOOL_NOTIFY_OPTION *option, TALLOC_CTX *mem_ctx, + SPOOL_NOTIFY_INFO *info) { Printer_entry *Printer=find_printer_index_by_hnd(handle); + uint32 result = ERROR_INVALID_HANDLE; if (!OPEN_HANDLE(Printer)) { - DEBUG(0,("_spoolss_rfnpcnex: Invalid handle (%s).\n",OUR_HANDLE(handle))); - return ERROR_INVALID_HANDLE; + DEBUG(0,("_spoolss_rfnpcnex: Invalid handle (%s).\n", + OUR_HANDLE(handle))); + goto done; } DEBUG(4,("Printer type %x\n",Printer->printer_type)); @@ -1876,12 +2194,17 @@ uint32 _spoolss_rfnpcnex( POLICY_HND *handle, uint32 change, switch (Printer->printer_type) { case PRINTER_HANDLE_IS_PRINTSERVER: - return printserver_notify_info(handle, info); + result = printserver_notify_info(handle, info, + mem_ctx); + break; + case PRINTER_HANDLE_IS_PRINTER: - return printer_notify_info(handle, info); + result = printer_notify_info(handle, info, mem_ctx); + break; } - - return ERROR_INVALID_HANDLE; + + done: + return result; } /******************************************************************** @@ -4076,16 +4399,13 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, /**************************************************************************** ****************************************************************************/ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, - int position, int snum) + int position, int snum, + NT_PRINTER_INFO_LEVEL *ntprinter) { pstring temp_name; - NT_PRINTER_INFO_LEVEL *ntprinter = NULL; pstring chaine; struct tm *t; - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) - return False; - t=gmtime(&queue->time); snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); @@ -4119,11 +4439,9 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, job_info->pagesprinted=0; if((job_info->devmode = construct_dev_mode(snum)) == NULL) { - free_a_printer(&ntprinter, 2); return False; } - free_a_printer(&ntprinter, 2); return (True); } @@ -4180,19 +4498,25 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { + NT_PRINTER_INFO_LEVEL *ntprinter = NULL; JOB_INFO_2 *info; int i; info=(JOB_INFO_2 *)malloc(*returned*sizeof(JOB_INFO_2)); if (info==NULL) { - safe_free(queue); *returned=0; return ERROR_NOT_ENOUGH_MEMORY; } - + + if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0) { + *returned = 0; + return ERROR_NOT_ENOUGH_MEMORY; + } + for (i=0; i<*returned; i++) - fill_job_info_2(&(info[i]), &queue[i], i, snum); + fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter); + free_a_printer(&ntprinter, 2); safe_free(queue); /* check the required size. */ @@ -4209,7 +4533,10 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum, new_smb_io_job_info_2("", buffer, &info[i], 0); /* clear memory */ - free_job_info_2(info); + for (i = 0; i < *returned; i++) + free_job_info_2(&info[i]); + + free(info); if (*needed > offered) { *returned=0; @@ -5763,6 +6090,8 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin int i=0; BOOL found=False; JOB_INFO_2 *info_2; + NT_PRINTER_INFO_LEVEL *ntprinter = NULL; + info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2)); ZERO_STRUCTP(info_2); @@ -5784,8 +6113,14 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin return NT_STATUS_NO_PROBLEMO; } - fill_job_info_2(info_2, &(queue[i-1]), i, snum); + if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0) { + safe_free(queue); + return ERROR_NOT_ENOUGH_MEMORY; + } + + fill_job_info_2(info_2, &(queue[i-1]), i, snum, ntprinter); + free_a_printer(&ntprinter, 2); safe_free(queue); *needed += spoolss_size_job_info_2(info_2); @@ -5798,6 +6133,7 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin new_smb_io_job_info_2("", buffer, info_2, 0); free_job_info_2(info_2); + free(info_2); if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; -- cgit From 1a0d64a4254ae769e147699f0dc2b40429e43f23 Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Thu, 18 Jan 2001 16:13:03 +0000 Subject: Changes from APPLIANCE_HEAD: source/rpc_server/srv_spoolss_nt.c - Fixed dereference of NULL pointer in security descriptor notification used by Win2K printers. (This used to be commit 1b6efd18943ef3ed0e2e061495d05cfdecd86c88) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 24626d1a9a..5b92a51189 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1463,7 +1463,7 @@ static void spoolss_notify_security_desc(int snum, TALLOC_CTX *mem_ctx) { data->notify_data.data.length=0; - data->notify_data.data.string[0]=0x00; + data->notify_data.data.string = NULL; } /******************************************************************* -- cgit From c4e0cb72bc654cbdae6e9c3bbcb40683bc0cadca Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Fri, 19 Jan 2001 16:58:23 +0000 Subject: Changes from APPLIANCE_HEAD: source/include/proto.h - make proto source/rpc_server/srv_spoolss_nt.c - clean up incorrect debug statement (This used to be commit f07f4e9c7b9bb5230f10fffe50beab163b6f7790) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5b92a51189..d838d08c3c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5736,8 +5736,8 @@ uint32 _spoolss_deleteprinterdata( POLICY_HND *handle, const UNISTR2 *value) return ERROR_INVALID_HANDLE; if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { - DEBUG(3, ("_spoolss_deleteprinterdata: security descriptor change denied by existing " - "security descriptor\n")); + DEBUG(3, ("_spoolss_deleteprinterdata: printer properties " + "change denied by existing security descriptor\n")); return ERROR_ACCESS_DENIED; } -- cgit From b9c5be4d79364db0fd3f9af186f165638cae1c54 Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Tue, 23 Jan 2001 17:39:03 +0000 Subject: Changes from APPLIANCE_HEAD: source/rpc_server/srv_spoolss_nt.c - remove redundant srv_spoolss_sendnotify() calls from _spoolss_startdocprinter() and _spoolss_enddocprinter(), as its functionality is already covered in print_job_start() and print_job_end() source/printing/printing.c - force a print_queue_update() prior to print queue purge so that all jobs are purged. (This used to be commit 0ccc552203d6432cde844c5946b203b27f257b1a) --- source3/rpc_server/srv_spoolss_nt.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d838d08c3c..4f2c7fa03e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3658,7 +3658,6 @@ uint32 _spoolss_startdocprinter(POLICY_HND *handle, uint32 level, Printer->document_started=True; (*jobid) = Printer->jobid; - srv_spoolss_sendnotify(handle); return 0x0; } @@ -3680,8 +3679,6 @@ uint32 _spoolss_enddocprinter(POLICY_HND *handle) print_job_end(Printer->jobid); /* error codes unhandled so far ... */ - srv_spoolss_sendnotify(handle); - return 0x0; } -- cgit From eee29958f5cacc753f3fa324327e0d8b14ac3006 Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Tue, 23 Jan 2001 20:25:25 +0000 Subject: Changes from APPLIANCE_HEAD: source/rpc_server/srv_spoolss_nt.c - add an access check to _spoolss_deleteprinter() to stop random users and passers by from deleting printers. source/lib/messages.c - converted global msg_all struct to a local in message_send_all() function. source/include/smb.h - added a success error code to the spoolss return codes. source/include/proto.h source/param/loadparm.c source/printing/printing.c - Added new parameter "total print jobs" to limit the total number of print jobs across all queues. Currently individual queues are limited by "max print jobs". (This used to be commit 02f154e729b0e8465d3e1e2ac794e6ab3844ce57) --- source3/rpc_server/srv_spoolss_nt.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4f2c7fa03e..4be338d4d6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -240,18 +240,28 @@ static BOOL close_printer_handle(POLICY_HND *hnd) /**************************************************************************** delete a printer given a handle ****************************************************************************/ -static BOOL delete_printer_handle(POLICY_HND *hnd) +static uint32 delete_printer_handle(POLICY_HND *hnd) { Printer_entry *Printer = find_printer_index_by_hnd(hnd); if (!OPEN_HANDLE(Printer)) { DEBUG(0,("delete_printer_handle: Invalid handle (%s)\n", OUR_HANDLE(hnd))); - return False; + return ERROR_INVALID_HANDLE; } if (del_a_printer(Printer->dev.handlename) != 0) { DEBUG(3,("Error deleting printer %s\n", Printer->dev.handlename)); - return False; + return ERROR_INVALID_HANDLE; + } + + /* Check calling user has permission to delete printer. Note that + since we set the snum parameter to -1 only administrators can + delete the printer. This stops people with the Full Control + permission from deleting the printer. */ + + if (!print_access_check(NULL, -1, PRINTER_ACCESS_ADMINISTER)) { + DEBUG(3, ("printer delete denied by security descriptor\n")); + return ERROR_ACCESS_DENIED; } if (*lp_deleteprinter_cmd()) { @@ -280,7 +290,7 @@ static BOOL delete_printer_handle(POLICY_HND *hnd) ret = smbrun(command, tmp_file, False); if (ret != 0) { unlink(tmp_file); - return False; + return ERROR_INVALID_HANDLE; /* What to return here? */ } DEBUGADD(10,("returned [%d]\n", ret)); DEBUGADD(10,("Unlinking output file [%s]\n", tmp_file)); @@ -291,12 +301,12 @@ static BOOL delete_printer_handle(POLICY_HND *hnd) if ( ( i = lp_servicenumber( Printer->dev.handlename ) ) >= 0 ) { lp_killservice( i ); - return True; + return ERROR_SUCCESS; } else - return False; + return ERROR_ACCESS_DENIED; } - return True; + return ERROR_SUCCESS; } /**************************************************************************** @@ -855,16 +865,18 @@ uint32 _spoolss_closeprinter(POLICY_HND *handle) uint32 _spoolss_deleteprinter(POLICY_HND *handle) { Printer_entry *Printer=find_printer_index_by_hnd(handle); + uint32 result; if (Printer && Printer->document_started) - _spoolss_enddocprinter(handle); /* print job was not closed */ + _spoolss_enddocprinter(handle); /* print job was not closed */ - if (!delete_printer_handle(handle)) - return ERROR_INVALID_HANDLE; + result = delete_printer_handle(handle); - srv_spoolss_sendnotify(handle); + if (result == ERROR_SUCCESS) { + srv_spoolss_sendnotify(handle); + } - return NT_STATUS_NO_PROBLEMO; + return result; } /******************************************************************** -- cgit From 05cbf30452babd5a0beeedf00492f5e8951c49ec Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 23 Jan 2001 22:14:33 +0000 Subject: increase MAX_POL_HNDS (merge from 2.2) --jerry (This used to be commit a946d13e0ce8afb509ff24bc8035c7c4d09bcf8b) --- source3/rpc_server/srv_lsa_hnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 0782c8c4b2..93492f671d 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -27,7 +27,7 @@ extern int DEBUGLEVEL; #ifndef MAX_OPEN_POLS -#define MAX_OPEN_POLS 64 +#define MAX_OPEN_POLS 2048 #endif struct reg_info -- cgit From cf90dbd158de152221f294c478cd4f7ba44cdb5c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 25 Jan 2001 02:35:50 +0000 Subject: Fixed "object picker can't determine if object in domain" bug seen from W2K clients. Did this by importing Samba-TNG code that correctly handles LSA lookups. *MANY* thanks to Luke, Sander, Elrond and the rest of the TNG gang ! Jeremy (This used to be commit f76dc952f70862a6a390e9f35edd651867842a01) --- source3/rpc_server/srv_lsa.c | 61 ++++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 3538beefda..b9b7a0328d 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -126,26 +126,17 @@ static void lsa_reply_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM *q_e, lsa_reply_query_info ***************************************************************************/ -static BOOL lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, - char *dom_name, DOM_SID *dom_sid, uint32 status_code) +static BOOL lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, LSA_R_QUERY_INFO *r_q) { - LSA_R_QUERY_INFO r_q; - - ZERO_STRUCT(r_q); - /* set up the LSA QUERY INFO response */ - if(status_code == 0) { - r_q.undoc_buffer = 0x22000000; /* bizarre */ - r_q.info_class = q_q->info_class; - - init_dom_query(&r_q.dom.id5, dom_name, dom_sid); + if(r_q->status == 0) { + r_q->undoc_buffer = 0x22000000; /* bizarre */ + r_q->info_class = q_q->info_class; } - r_q.status = status_code; - /* store the response in the SMB stream */ - if(!lsa_io_r_query("", &r_q, rdata, 0)) { + if(!lsa_io_r_query("", r_q, rdata, 0)) { DEBUG(0,("lsa_reply_query_info: failed to marshall LSA_R_QUERY_INFO.\n")); return False; } @@ -510,14 +501,16 @@ api_lsa_query_info static BOOL api_lsa_query_info(pipes_struct *p) { LSA_Q_QUERY_INFO q_i; + LSA_R_QUERY_INFO r_q; + LSA_INFO_UNION *info = &r_q.dom; DOM_SID domain_sid; char *name = NULL; DOM_SID *sid = NULL; - uint32 status_code = 0; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_i); + ZERO_STRUCT(r_q); /* grab the info class and policy handle */ if(!lsa_io_q_query("", &q_i, data, 0)) { @@ -526,6 +519,19 @@ static BOOL api_lsa_query_info(pipes_struct *p) } switch (q_i.info_class) { + case 0x02: + { + unsigned int i; + /* fake info: We audit everything. ;) */ + info->id2.auditing_enabled = 1; + info->id2.count1 = 7; + info->id2.count2 = 7; + if ((info->id2.auditsettings = (uint32 *)talloc(prs_get_mem_context(rdata),7*sizeof(uint32))) == NULL) + return False; + for (i = 0; i < 7; i++) + info->id2.auditsettings[i] = 3; + break; + } case 0x03: switch (lp_server_role()) { @@ -544,19 +550,40 @@ static BOOL api_lsa_query_info(pipes_struct *p) default: break; } + init_dom_query(&r_q.dom.id3, name, sid); break; case 0x05: name = global_myname; sid = &global_sam_sid; + init_dom_query(&r_q.dom.id5, name, sid); + break; + case 0x06: + switch (lp_server_role()) + { + case ROLE_DOMAIN_BDC: + /* + * only a BDC is a backup controller + * of the domain, it controls. + */ + info->id6.server_role = 2; + break; + default: + /* + * any other role is a primary + * of the domain, it controls. + */ + info->id6.server_role = 3; + break; + } break; default: DEBUG(0,("api_lsa_query_info: unknown info level in Lsa Query: %d\n", q_i.info_class)); - status_code = (NT_STATUS_INVALID_INFO_CLASS | 0xC0000000); + r_q.status = (NT_STATUS_INVALID_INFO_CLASS | 0xC0000000); break; } /* construct reply. return status is always 0x0 */ - if(!lsa_reply_query_info(&q_i, rdata, name, sid, status_code)) + if(!lsa_reply_query_info(&q_i, rdata, &r_q)) return False; return True; -- cgit From c7a7dea3331c5d77f57fb0622303933ca7afb0f9 Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Thu, 25 Jan 2001 20:15:32 +0000 Subject: Changes from APPLIANCE_HEAD: source/rpc_server/srv_spoolss_nt.c - Changed the se_access_check() call in _spoolss_open_printer_ex() to a print_access_check(). This allows the 'printer admins' smb.conf and other permission override parameters to affect the result of a printer open. - Don't perform access check when opening a handle on a print server as it breaks browsing the Printers folder. (This used to be commit bbe51d4b5f6da4c7668214511e25eff098bf03b1) --- source3/rpc_server/srv_spoolss_nt.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4be338d4d6..0ffe172b0a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -669,10 +669,8 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, POLICY_HND *handle) { uint32 result = NT_STATUS_NO_PROBLEMO; - SEC_DESC_BUF *sec_desc = NULL; - uint32 acc_granted, status; fstring name; - extern struct current_user current_user; + int snum; if (printername == NULL) { result = ERROR_INVALID_PRINTER_NAME; @@ -729,29 +727,22 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, } /* NT doesn't let us connect to a printer if the connecting user - doesn't have print permission. If no security descriptor just - return OK. */ + doesn't have print permission. */ - if (!nt_printing_getsec(name, &sec_desc)) { - goto done; - } - - /* Yuck - we should use the pipe_user rather than current_user but - it doesn't seem to be filled in correctly. )-: */ + if (!handle_is_printserver(handle)) { - map_printer_permissions(sec_desc->sec); + if (!get_printer_snum(handle, &snum)) + return ERROR_INVALID_HANDLE; - if (!se_access_check(sec_desc->sec, ¤t_user, PRINTER_ACCESS_USE, - &acc_granted, &status)) { - DEBUG(3, ("access DENIED for printer open\n")); - close_printer_handle(handle); - result = ERROR_ACCESS_DENIED; - goto done; + if (!print_access_check(NULL, snum, PRINTER_ACCESS_USE)) { + DEBUG(3, ("access DENIED for printer open\n")); + close_printer_handle(handle); + result = ERROR_ACCESS_DENIED; + goto done; + } } done: - free_sec_desc_buf(&sec_desc); - return result; } -- cgit From 2506c61ab3bd667d54c5e004cc80ce5e40643b5d Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Mon, 29 Jan 2001 21:34:08 +0000 Subject: Changes from APPLIANCE_HEAD: source/include/proto.h - make proto source/printing/nt_printing.c source/rpc_server/srv_spoolss_nt.c - Fix for the overwriting of printerdata entries when WinNT and Win2k are modifying printer parameters on PCL printers. Turns out that Win2k creates a printer with a NULL devmode entry and then expects to set it on *OPEN* (yes this is insane). So we cannot return a "default" devmode for a printer - and we must allow an open to set it. source/tdb/tdb.c - Show freelist in an easier format. Show total free. - When storing a new record, allocate memory for the key + data before the tdb_allocate() as if the malloc fails a (sparse) hole is left in the tdb. source/tdb/tdbtool.c - Show freelist in an easier format. Show total free. source/tdb/Makefile - cleaned up Makefile dependancies source/smbd/lanman.c - Fix for Win9x corrupting it's own parameter string. source/printing/printfsp.c source/printing/printing.c source/rpc_server/srv_spoolss_nt.c source/smbd/close.c - Added normal close parameter into print_fsp_end() which treats an abnormal close as error condition and deletes the spool file. (This used to be commit 025f7a092ad258ff774e3f5e53737f8210cc8af6) --- source3/rpc_server/srv_spoolss_nt.c | 87 +++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0ffe172b0a..dabaca5d66 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -740,6 +740,22 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, result = ERROR_ACCESS_DENIED; goto done; } + + /* + * If we have a default device pointer in the + * printer_default struct, then we need to get + * the printer info from the tdb and if there is + * no default devicemode there then we do a *SET* + * here ! This is insanity.... JRA. + */ + + if (printer_default->devmode_cont.devmode != NULL) { + result = printer_write_default_dev( snum, printer_default); + if (result != 0) { + close_printer_handle(handle); + goto done; + } + } } done: @@ -781,15 +797,26 @@ static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *u return True; } -static BOOL convert_devicemode(const DEVICEMODE *devmode, NT_DEVICEMODE *nt_devmode) +BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, + NT_DEVICEMODE **pp_nt_devmode) { + NT_DEVICEMODE *nt_devmode = *pp_nt_devmode; + + /* + * Ensure nt_devmode is a valid pointer + * as we will be overwriting it. + */ + + if (nt_devmode == NULL) + if ((nt_devmode = construct_nt_devicemode(printername)) == NULL) + return False; + unistr_to_dos(nt_devmode->devicename, (const char *)devmode->devicename.buffer, 31); unistr_to_dos(nt_devmode->formname, (const char *)devmode->formname.buffer, 31); nt_devmode->specversion=devmode->specversion; nt_devmode->driverversion=devmode->driverversion; nt_devmode->size=devmode->size; - nt_devmode->driverextra=devmode->driverextra; nt_devmode->fields=devmode->fields; nt_devmode->orientation=devmode->orientation; nt_devmode->papersize=devmode->papersize; @@ -820,16 +847,20 @@ static BOOL convert_devicemode(const DEVICEMODE *devmode, NT_DEVICEMODE *nt_devm nt_devmode->panningwidth=devmode->panningwidth; nt_devmode->panningheight=devmode->panningheight; - safe_free(nt_devmode->private); - if (nt_devmode->driverextra != 0) { - /* if we had a previous private delete it and make a new one */ + /* + * Only change private and driverextra if the incoming devmode + * has a new one. JRA. + */ + + if ((devmode->driverextra != 0) && (devmode->private != NULL)) { + safe_free(nt_devmode->private); + nt_devmode->driverextra=devmode->driverextra; if((nt_devmode->private=(uint8 *)malloc(nt_devmode->driverextra * sizeof(uint8))) == NULL) return False; memcpy(nt_devmode->private, devmode->private, nt_devmode->driverextra); } - else { - nt_devmode->private = NULL; - } + + *pp_nt_devmode = nt_devmode; return True; } @@ -915,7 +946,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d return True; } - if (!strcmp(value, "DefaultSpoolDirectory")) { + if (!strcmp(value, "DefaultSpoolDirectory")) { pstring string="You are using a Samba server"; *type = 0x1; *needed = 2*(strlen(string)+1); @@ -1045,7 +1076,7 @@ uint32 _spoolss_getprinterdata(POLICY_HND *handle, UNISTR2 *valuename, if (handle_is_printserver(handle)) found=getprinterdata_printer_server(value, type, data, needed, *out_size); else - found=getprinterdata_printer(handle, value, type, data, needed, *out_size); + found= getprinterdata_printer(handle, value, type, data, needed, *out_size); if (found==False) { DEBUG(5, ("value not found, allocating %d\n", *out_size)); @@ -1063,8 +1094,9 @@ uint32 _spoolss_getprinterdata(POLICY_HND *handle, UNISTR2 *valuename, if (*needed > *out_size) return ERROR_MORE_DATA; - else + else { return NT_STATUS_NO_PROBLEMO; + } } /*************************************************************************** @@ -2299,11 +2331,11 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) printer->unknown13 = 0x0; printer->unknown14 = 0x1; printer->unknown15 = 0x024a; /* 586 Pentium ? */ - printer->unknown16 = 0x0; + printer->unknown16 = 0x0; printer->change_id = ntprinter->info_2->changeid; /* ChangeID in milliseconds*/ - printer->unknown18 = 0x0; + printer->unknown18 = 0x0; printer->status = nt_printq_status(status.status); - printer->unknown20 = 0x0; + printer->unknown20 = 0x0; printer->c_setprinter = ntprinter->info_2->c_setprinter; /* how many times setprinter has been called */ printer->unknown22 = 0x0; printer->unknown23 = 0x6; /* 6 ???*/ @@ -3679,7 +3711,7 @@ uint32 _spoolss_enddocprinter(POLICY_HND *handle) } Printer->document_started=False; - print_job_end(Printer->jobid); + print_job_end(Printer->jobid,True); /* error codes unhandled so far ... */ return 0x0; @@ -4230,21 +4262,12 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, /* we have a valid devmode convert it and link it*/ - /* - * Ensure printer->info_2->devmode is a valid pointer - * as we will be overwriting it in convert_devicemode(). - */ - - if (printer->info_2->devmode == NULL) - printer->info_2->devmode = construct_nt_devicemode(printer->info_2->printername); - DEBUGADD(8,("Converting the devicemode struct\n")); - convert_devicemode(devmode, printer->info_2->devmode); - - } else { - if (printer->info_2->devmode != NULL) - free_nt_devicemode(&printer->info_2->devmode); - printer->info_2->devmode=NULL; + if (!convert_devicemode(printer->info_2->printername, devmode, + &printer->info_2->devmode)) { + result = ERROR_NOT_ENOUGH_MEMORY; + goto done; + } } /* Do sanity check on the requested changes for Samba */ @@ -5673,10 +5696,10 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, convert_specific_param(¶m, value , type, data, real_len); - /* Check if we are making any changes or not. Return true if + /* Check if we are making any changes or not. Return true if nothing is actually changing. */ - - ZERO_STRUCT(old_param); + + ZERO_STRUCT(old_param); if (get_specific_param(*printer, 2, param->value, &old_param.data, &old_param.type, (unsigned int *)&old_param.data_len)) { -- cgit From 4d6b6eb94a3bb53ab47d458a4071ba805281c6a1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 31 Jan 2001 05:14:31 +0000 Subject: lib/system.c: Fix for pw caching. srv_samr.c: Fix for pw caching. smbd/nttrans.c: Fix to allow trans create to set ACL on open. Jeremy. (This used to be commit c4f810a7588a2faf41f4222dc77678c53ab1dec0) --- source3/rpc_server/srv_samr.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 30a0350f67..857581a471 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -217,7 +217,7 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, if (pw_buf == NULL) return False; if (current_idx == 0) { - setpwent(); + sys_setpwent(); } /* These two cases are inefficient, but should be called very rarely */ @@ -230,7 +230,7 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, char *unmap_name; if(!orig_done) { - if ((pwd = getpwent()) == NULL) break; + if ((pwd = sys_getpwent()) == NULL) break; current_idx++; orig_done = True; } @@ -248,8 +248,8 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, } } else if (start_idx < current_idx) { /* We are already too far; start over and advance to start_idx */ - endpwent(); - setpwent(); + sys_endpwent(); + sys_setpwent(); current_idx = 0; mapped_idx = 0; orig_done = False; @@ -257,7 +257,7 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, char *unmap_name; if(!orig_done) { - if ((pwd = getpwent()) == NULL) break; + if ((pwd = sys_getpwent()) == NULL) break; current_idx++; orig_done = True; } @@ -284,7 +284,7 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, /* This does the original UNIX user itself */ if(!orig_done) { - if ((pwd = getpwent()) == NULL) break; + if ((pwd = sys_getpwent()) == NULL) break; /* Don't enumerate winbind users as they are not local */ -- cgit From fd3e20a278385c03527f9348992b753f5e20b21f Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 31 Jan 2001 17:11:58 +0000 Subject: Missing sys_endpwent() call in get_passwd_entries() (This used to be commit a86f219f2f63f63e43d5b99e3d190a536954d400) --- source3/rpc_server/srv_samr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 857581a471..e92658ea4d 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -339,7 +339,7 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, if (pwd == NULL) { /* totally done, reset everything */ - endpwent(); + sys_endpwent(); current_idx = 0; mapped_idx = 0; } -- cgit From 4a9fb6b6b7d8696487f64316010559618f8848d6 Mon Sep 17 00:00:00 2001 From: David O'Neill Date: Wed, 31 Jan 2001 18:34:49 +0000 Subject: Changes from SAMBA_2_2: source/rpc_server/srv_spoolss_nt.c source/rpc_server/srv_spoolss.c source/include/proto.h - correct checking of access_required in openprinterex as talked with John R. and Jerry. You can only do server stuff (adding printers, changing forms, ..) if you're root or if user is in printer admin list. Printers options are grayed if you don't have the PRINTER_ADMINISTER flag in the secdesc. (This used to be commit f449d871bf0c385d8c57de2d795e1d7ef7f256f7) --- source3/rpc_server/srv_spoolss.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 116 ++++++++++++++++++++---------------- 2 files changed, 66 insertions(+), 52 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 8d7d238ad0..8c06f16290 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -48,7 +48,7 @@ static BOOL api_spoolss_open_printer_ex(pipes_struct *p) if (q_u.printername_ptr != 0) printername = &q_u.printername; - r_u.status = _spoolss_open_printer_ex( printername, + r_u.status = _spoolss_open_printer_ex( printername, p, &q_u.printer_default, q_u.user_switch, q_u.user_ctr, &r_u.handle); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index dabaca5d66..ff9dfabe69 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -658,12 +658,28 @@ static BOOL srv_spoolss_sendnotify(POLICY_HND *handle) return True; } +/**************************************************************************** + Return a user struct for a pipe user. +****************************************************************************/ + +static struct current_user *get_current_user(struct current_user *user, pipes_struct *p) +{ + if (p->ntlmssp_auth_validated) { + memcpy(user, &p->pipe_user, sizeof(struct current_user)); + } else { + extern struct current_user current_user; + memcpy(user, ¤t_user, sizeof(struct current_user)); + } + + return user; +} + /******************************************************************** * spoolss_open_printer * * called from the spoolss dispatcher ********************************************************************/ -uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, +uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, pipes_struct *p, const PRINTER_DEFAULT *printer_default, uint32 user_switch, SPOOL_USER_CTR user_ctr, POLICY_HND *handle) @@ -671,11 +687,10 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, uint32 result = NT_STATUS_NO_PROBLEMO; fstring name; int snum; + struct current_user user; - if (printername == NULL) { - result = ERROR_INVALID_PRINTER_NAME; - goto done; - } + if (printername == NULL) + return ERROR_INVALID_PRINTER_NAME; /* some sanity check because you can open a printer or a print server */ /* aka: \\server\printer or \\server */ @@ -683,10 +698,8 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, DEBUGADD(3,("checking name: %s\n",name)); - if (!open_printer_hnd(handle, name)) { - result = ERROR_INVALID_PRINTER_NAME; - goto done; - } + if (!open_printer_hnd(handle, name)) + return ERROR_INVALID_PRINTER_NAME; /* if (printer_default->datatype_ptr != NULL) @@ -700,45 +713,62 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, if (!set_printer_hnd_accesstype(handle, printer_default->access_required)) { close_printer_handle(handle); - result = ERROR_ACCESS_DENIED; - goto done; + return ERROR_ACCESS_DENIED; } - /* Disallow MS AddPrinterWizard if parameter disables it. A Win2k + /* + First case: the user is opening the print server: + + Disallow MS AddPrinterWizard if parameter disables it. A Win2k client 1st tries an OpenPrinterEx with access==0, MUST be allowed. + Then both Win2k and WinNT clients try an OpenPrinterEx with - SERVER_ALL_ACCESS, which we force to fail. Then they try - OpenPrinterEx with SERVER_READ which we allow. This lets the + SERVER_ALL_ACCESS, which we allow only if the user is root (uid=0) + or if the user is listed in the smb.conf printer admin parameter. + + Then they try OpenPrinterEx with SERVER_READ which we allow. This lets the client view printer folder, but does not show the MSAPW. Note: this test needs code to check access rights here too. Jeremy - could you look at this? */ + could you look at this? + + + Second case: the user is opening a printer: + NT doesn't let us connect to a printer if the connecting user + doesn't have print permission. - if (handle_is_printserver(handle) && - !lp_ms_add_printer_wizard()) { + */ + + get_current_user(&user, p); + + if (handle_is_printserver(handle) ) { if (printer_default->access_required == 0) { - goto done; - } - else if (printer_default->access_required != (SERVER_READ)) { - close_printer_handle(handle); - result = ERROR_ACCESS_DENIED; - goto done; + return NT_STATUS_NO_PROBLEMO; } - } - - /* NT doesn't let us connect to a printer if the connecting user - doesn't have print permission. */ - - if (!handle_is_printserver(handle)) { + else if ( (printer_default->access_required & SERVER_ACCESS_ADMINISTER ) == SERVER_ACCESS_ADMINISTER) { + if (lp_ms_add_printer_wizard()) { + close_printer_handle(handle); + return ERROR_ACCESS_DENIED; + } + else if (user.uid == 0 || user_in_list(uidtoname(user.uid), lp_printer_admin(snum))) { + return NT_STATUS_NO_PROBLEMO; + } else { + close_printer_handle(handle); + return ERROR_ACCESS_DENIED; + } + } + else + return NT_STATUS_NO_PROBLEMO; + } else { + if (!get_printer_snum(handle, &snum)) return ERROR_INVALID_HANDLE; - if (!print_access_check(NULL, snum, PRINTER_ACCESS_USE)) { + if (!print_access_check(&user, snum, printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); close_printer_handle(handle); - result = ERROR_ACCESS_DENIED; - goto done; + return ERROR_ACCESS_DENIED; } /* @@ -753,13 +783,13 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, result = printer_write_default_dev( snum, printer_default); if (result != 0) { close_printer_handle(handle); - goto done; + return result; } } + + return NT_STATUS_NO_PROBLEMO; } - done: - return result; } /**************************************************************************** @@ -3615,22 +3645,6 @@ uint32 _spoolss_endpageprinter(POLICY_HND *handle) return NT_STATUS_NO_PROBLEMO; } -/**************************************************************************** - Return a user struct for a pipe user. -****************************************************************************/ - -static struct current_user *get_current_user(struct current_user *user, pipes_struct *p) -{ - if (p->ntlmssp_auth_validated) { - memcpy(user, &p->pipe_user, sizeof(struct current_user)); - } else { - extern struct current_user current_user; - memcpy(user, ¤t_user, sizeof(struct current_user)); - } - - return user; -} - /******************************************************************** * api_spoolss_getprinter * called from the spoolss dispatcher -- cgit From deb638a7aca9b52ce11ce27c8107f6d189b40f38 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 3 Feb 2001 23:45:59 +0000 Subject: merge from APPLIANCE_HEAD (mapping access_required 0x0 to PRINTER_ACCESS_USE) (This used to be commit 0c57b05de46f04dda941fcb4ba4f2a5a88b8dc9f) --- source3/rpc_server/srv_spoolss_nt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ff9dfabe69..fecdadbf08 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -680,7 +680,7 @@ static struct current_user *get_current_user(struct current_user *user, pipes_st * called from the spoolss dispatcher ********************************************************************/ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, pipes_struct *p, - const PRINTER_DEFAULT *printer_default, + PRINTER_DEFAULT *printer_default, uint32 user_switch, SPOOL_USER_CTR user_ctr, POLICY_HND *handle) { @@ -747,7 +747,7 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, pipes_struct *p, } else if ( (printer_default->access_required & SERVER_ACCESS_ADMINISTER ) == SERVER_ACCESS_ADMINISTER) { - if (lp_ms_add_printer_wizard()) { + if (!lp_ms_add_printer_wizard()) { close_printer_handle(handle); return ERROR_ACCESS_DENIED; } @@ -765,6 +765,10 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, pipes_struct *p, if (!get_printer_snum(handle, &snum)) return ERROR_INVALID_HANDLE; + /* map an empty access mask to the minimum access mask */ + if (printer_default->access_required == 0x0) + 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(handle); -- cgit From da20d4e5df3c908cc00bf31570892fa5f19853e7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 13 Feb 2001 16:28:48 +0000 Subject: It compiles for me now :-). rpc_server/srv_lsa.c - added fix to allow w2k clients to join a Samba domain - odd or even domain name length. Needs more testing. Jeremy. (This used to be commit 408672d38261e34cc3714200617b35464d88f931) --- source3/rpc_server/srv_lsa.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index b9b7a0328d..3629bb7d8e 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -90,14 +90,23 @@ static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) { int domlen = (dom_name != NULL) ? strlen(dom_name) : 0; + /* + * I'm not sure why this really odd combination of length + * values works, but it does appear to. I need to look at + * this *much* more closely - but at the moment leave alone + * until it's understood. This allows a W2k client to join + * a domain with both odd and even length names... JRA. + */ + + d_q->uni_dom_str_len = domlen ? ((domlen + 1) * 2) : 0; d_q->uni_dom_max_len = domlen * 2; - d_q->uni_dom_str_len = domlen * 2; - - d_q->buffer_dom_name = dom_name ? 1 : 0; - d_q->buffer_dom_sid = dom_sid ? 1 : 0; + d_q->buffer_dom_name = domlen != 0 ? 1 : 0; /* domain buffer pointer */ + d_q->buffer_dom_sid = dom_sid != NULL ? 1 : 0; /* domain sid pointer */ /* this string is supposed to be character short */ init_unistr2(&d_q->uni_domain_name, dom_name, domlen); + d_q->uni_domain_name.uni_max_len++; + if (dom_sid != NULL) init_dom_sid2(&d_q->dom_sid, dom_sid); } -- cgit From 64172d82fcf1762a8bc938282919f9e3bd39675d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 14 Feb 2001 05:34:50 +0000 Subject: Merge of i18n fixes from appliance branch. Samba can now talk to a network with a PDC that has international netbios name and domain name. There's still quite a bit of i18n stuff to fix though... (This used to be commit 79045bd72ace9144e7dd73785b1d10a71b0d15aa) --- source3/rpc_server/srv_wkssvc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 21e4f933f2..d1e0c8e8eb 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -40,14 +40,14 @@ static void create_wks_info_100(WKS_INFO_100 *inf) pstrcpy (my_name, global_myname); strupper(my_name); - pstrcpy (domain , lp_workgroup()); + pstrcpy (domain, lp_workgroup()); strupper(domain); init_wks_info_100(inf, 0x000001f4, /* platform id info */ lp_major_announce_version(), lp_minor_announce_version(), - my_name, domain); + my_name, unix_to_dos(domain,False)); } /******************************************************************* -- cgit From fd46817f0b20c633c80dee70a29cf7478e2dfd68 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 16 Feb 2001 19:21:18 +0000 Subject: Excise snprintf -> slprintf. srv_samr.c: duplicate gid fix. srv_spoolss_nt.c: Merge of JF's work. uid.c: Fix for returning names when a PDC. Jeremy. (This used to be commit d938ad6963a2dd4eda930d508600ec1902dc2b16) --- source3/rpc_server/srv_samr.c | 10 +- source3/rpc_server/srv_spoolss_nt.c | 204 +++++++++++++++++++++++++----------- 2 files changed, 149 insertions(+), 65 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index e92658ea4d..eb24f672a9 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -788,6 +788,8 @@ static BOOL samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, while (num_entries < MAX_SAM_ENTRIES && ((grp = getgrent()) != NULL)) { + int i; + uint32 trid; name = grp->gr_name; /* Don't return winbind groups as they are not local! */ @@ -796,8 +798,14 @@ static BOOL samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, continue; } + trid = pdb_gid_to_group_rid(grp->gr_gid); + for( i = 0; i < num_entries; i++) + if ( pass[i].user_rid == trid ) break; + if ( i < num_entries ) + continue; /* rid was there, dup! */ + init_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)+1); - pass[num_entries].user_rid = pdb_gid_to_group_rid(grp->gr_gid); + pass[num_entries].user_rid = trid; num_entries++; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index fecdadbf08..05fbbca0f3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -122,6 +122,22 @@ void init_printer_hnd(void) ubi_dlInitList(&counter_list); } +/**************************************************************************** + Return a user struct for a pipe user. +****************************************************************************/ + +static struct current_user *get_current_user(struct current_user *user, pipes_struct *p) +{ + if (p->ntlmssp_auth_validated) { + memcpy(user, &p->pipe_user, sizeof(struct current_user)); + } else { + extern struct current_user current_user; + memcpy(user, ¤t_user, sizeof(struct current_user)); + } + + return user; +} + /**************************************************************************** create a unique printer handle ****************************************************************************/ @@ -280,10 +296,10 @@ static uint32 delete_printer_handle(POLICY_HND *hnd) path = tmpdir(); /* Printer->dev.handlename equals portname equals sharename */ - slprintf(command, sizeof(command), "%s \"%s\"", cmd, + slprintf(command, sizeof(command)-1, "%s \"%s\"", cmd, Printer->dev.handlename); dos_to_unix(command, True); /* Convert printername to unix-codepage */ - slprintf(tmp_file, sizeof(tmp_file), "%s/smbcmd.%d", path, local_pid); + slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d", path, local_pid); unlink(tmp_file); DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); @@ -658,22 +674,6 @@ static BOOL srv_spoolss_sendnotify(POLICY_HND *handle) return True; } -/**************************************************************************** - Return a user struct for a pipe user. -****************************************************************************/ - -static struct current_user *get_current_user(struct current_user *user, pipes_struct *p) -{ - if (p->ntlmssp_auth_validated) { - memcpy(user, &p->pipe_user, sizeof(struct current_user)); - } else { - extern struct current_user current_user; - memcpy(user, ¤t_user, sizeof(struct current_user)); - } - - return user; -} - /******************************************************************** * spoolss_open_printer * @@ -684,7 +684,9 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, pipes_struct *p, uint32 user_switch, SPOOL_USER_CTR user_ctr, POLICY_HND *handle) { +#if 0 uint32 result = NT_STATUS_NO_PROBLEMO; +#endif fstring name; int snum; struct current_user user; @@ -740,12 +742,12 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, pipes_struct *p, */ get_current_user(&user, p); - - if (handle_is_printserver(handle) ) { + + if (handle_is_printserver(handle)) { if (printer_default->access_required == 0) { return NT_STATUS_NO_PROBLEMO; } - else if ( (printer_default->access_required & SERVER_ACCESS_ADMINISTER ) == SERVER_ACCESS_ADMINISTER) { + else if ((printer_default->access_required & SERVER_ACCESS_ADMINISTER ) == SERVER_ACCESS_ADMINISTER) { if (!lp_ms_add_printer_wizard()) { close_printer_handle(handle); @@ -753,15 +755,18 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, pipes_struct *p, } else if (user.uid == 0 || user_in_list(uidtoname(user.uid), lp_printer_admin(snum))) { return NT_STATUS_NO_PROBLEMO; - } else { + } + else { close_printer_handle(handle); return ERROR_ACCESS_DENIED; } } - else - return NT_STATUS_NO_PROBLEMO; - } else { - + } + else + { + /* NT doesn't let us connect to a printer if the connecting user + doesn't have print permission. */ + if (!get_printer_snum(handle, &snum)) return ERROR_INVALID_HANDLE; @@ -783,6 +788,64 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, pipes_struct *p, * here ! This is insanity.... JRA. */ + /* + * If the openprinterex rpc call contains a devmode, + * it's a per-user one. This per-user devmode is derivated + * from the global devmode. Openprinterex() contains a per-user + * devmode for when you do EMF printing and spooling. + * In the EMF case, the NT workstation is only doing half the job + * of rendering the page. The other half is done by running the printer + * driver on the server. + * The EMF file doesn't contain the page description (paper size, orientation, ...). + * The EMF file only contains what is to be printed on the page. + * So in order for the server to know how to print, the NT client sends + * a devicemode attached to the openprinterex call. + * But this devicemode is short lived, it's only valid for the current print job. + * + * If Samba would have supported EMF spooling, this devicemode would + * have been attached to the handle, to sent it to the driver to correctly + * rasterize the EMF file. + * + * As Samba only supports RAW spooling, we only receive a ready-to-print file, + * we just act as a pass-thru between windows and the printer. + * + * In order to know that Samba supports only RAW spooling, NT has to call + * getprinter() at level 2 (attribute field) or NT has to call startdoc() + * and until NT sends a RAW job, we refuse it. + * + * But to call getprinter() or startdoc(), you first need a valid handle, + * and to get an handle you have to call openprintex(). Hence why you have + * a devicemode in the openprinterex() call. + * + * + * Differences between NT4 and NT 2000. + * NT4: + * --- + * On NT4, you only have a global devicemode. This global devicemode can be changed + * by the administrator (or by a user with enough privs). Everytime a user + * wants to print, the devicemode is resetted to the default. In Word, everytime + * you print, the printer's characteristics are always reset to the global devicemode. + * + * NT 2000: + * ------- + * In W2K, there is the notion of per-user devicemode. The first time you use + * a printer, a per-user devicemode is build from the global devicemode. + * If you change your per-user devicemode, it is saved in the registry, under the + * H_KEY_CURRENT_KEY sub_tree. So that everytime you print, you have your default + * printer preferences available. + * + * To change the per-user devicemode: it's the "Printing Preferences ..." button + * on the General Tab of the printer properties windows. + * + * To change the global devicemode: it's the "Printing Defaults..." button + * on the Advanced Tab of the printer properties window. + * + * JFM. + */ + + + +#if 0 if (printer_default->devmode_cont.devmode != NULL) { result = printer_write_default_dev( snum, printer_default); if (result != 0) { @@ -790,10 +853,10 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, pipes_struct *p, return result; } } - - return NT_STATUS_NO_PROBLEMO; +#endif } + return NT_STATUS_NO_PROBLEMO; } /**************************************************************************** @@ -841,9 +904,11 @@ BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, * as we will be overwriting it. */ - if (nt_devmode == NULL) + if (nt_devmode == NULL) { + DEBUG(5, ("convert_devicemode: allocating a generic devmode\n")); if ((nt_devmode = construct_nt_devicemode(printername)) == NULL) return False; + } unistr_to_dos(nt_devmode->devicename, (const char *)devmode->devicename.buffer, 31); unistr_to_dos(nt_devmode->formname, (const char *)devmode->formname.buffer, 31); @@ -1210,7 +1275,7 @@ static void spoolss_notify_server_name(int snum, pstring temp_name, temp; uint32 len; - snprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname); + slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname); len = (uint32)dos_PutUniCode(temp, temp_name, sizeof(temp) - 2, True); @@ -2402,16 +2467,16 @@ static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int if (*ntprinter->info_2->comment == '\0') { init_unistr(&printer->comment, lp_comment(snum)); - snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",global_myname, ntprinter->info_2->printername, + slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",global_myname, ntprinter->info_2->printername, ntprinter->info_2->drivername, lp_comment(snum)); } else { init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ - snprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",global_myname, ntprinter->info_2->printername, + slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",global_myname, ntprinter->info_2->printername, ntprinter->info_2->drivername, ntprinter->info_2->comment); } - snprintf(chaine2,sizeof(chaine)-1,"%s", ntprinter->info_2->printername); + slprintf(chaine2,sizeof(chaine)-1,"%s", ntprinter->info_2->printername); init_unistr(&printer->description, chaine); init_unistr(&printer->name, chaine2); @@ -2470,10 +2535,10 @@ static DEVICEMODE *construct_dev_mode(int snum) DEBUGADD(8,("loading DEVICEMODE\n")); - snprintf(adevice, sizeof(adevice), printer->info_2->printername); + slprintf(adevice, sizeof(adevice)-1, printer->info_2->printername); init_unistr(&devmode->devicename, adevice); - snprintf(aform, sizeof(aform), ntdevmode->formname); + slprintf(aform, sizeof(aform)-1, ntdevmode->formname); init_unistr(&devmode->formname, aform); devmode->specversion = ntdevmode->specversion; @@ -2744,9 +2809,9 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui *returned=1; - snprintf(printername, sizeof(printername)-1,"Windows NT Remote Printers!!\\\\%s", global_myname); - snprintf(desc, sizeof(desc)-1,"%s", global_myname); - snprintf(comment, sizeof(comment)-1, "Logged on Domain"); + slprintf(printername, sizeof(printername)-1,"Windows NT Remote Printers!!\\\\%s", global_myname); + slprintf(desc, sizeof(desc)-1,"%s", global_myname); + slprintf(comment, sizeof(comment)-1, "Logged on Domain"); init_unistr(&printer->description, desc); init_unistr(&printer->name, printername); @@ -3158,19 +3223,19 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_IN if (strlen(driver.info_3->driverpath)) { - snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); init_unistr( &info->driverpath, temp ); } else init_unistr( &info->driverpath, "" ); if (strlen(driver.info_3->datafile)) { - snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); init_unistr( &info->datafile, temp ); } else init_unistr( &info->datafile, "" ); if (strlen(driver.info_3->configfile)) { - snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); init_unistr( &info->configfile, temp ); } else init_unistr( &info->configfile, "" ); @@ -3224,7 +3289,7 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser if (!v) v = ""; /* hack to handle null lists */ } if (strlen(v) == 0) break; - snprintf(line, sizeof(line)-1, "\\\\%s%s", servername, v); + 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) { DEBUG(0,("init_unistr_array: Realloc error\n" )); @@ -3257,25 +3322,25 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->architecture, driver.info_3->environment ); if (strlen(driver.info_3->driverpath)) { - snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); init_unistr( &info->driverpath, temp ); } else init_unistr( &info->driverpath, "" ); if (strlen(driver.info_3->datafile)) { - snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); init_unistr( &info->datafile, temp ); } else init_unistr( &info->datafile, "" ); if (strlen(driver.info_3->configfile)) { - snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); init_unistr( &info->configfile, temp ); } else init_unistr( &info->configfile, "" ); if (strlen(driver.info_3->helpfile)) { - snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile); + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile); init_unistr( &info->helpfile, temp ); } else init_unistr( &info->helpfile, "" ); @@ -3336,25 +3401,25 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->architecture, driver.info_3->environment ); if (strlen(driver.info_3->driverpath)) { - snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); init_unistr( &info->driverpath, temp ); } else init_unistr( &info->driverpath, "" ); if (strlen(driver.info_3->datafile)) { - snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); init_unistr( &info->datafile, temp ); } else init_unistr( &info->datafile, "" ); if (strlen(driver.info_3->configfile)) { - snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); init_unistr( &info->configfile, temp ); } else init_unistr( &info->configfile, "" ); if (strlen(driver.info_3->helpfile)) { - snprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile); + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile); init_unistr( &info->helpfile, temp ); } else init_unistr( &info->helpfile, "" ); @@ -3649,6 +3714,7 @@ uint32 _spoolss_endpageprinter(POLICY_HND *handle) return NT_STATUS_NO_PROBLEMO; } + /******************************************************************** * api_spoolss_getprinter * called from the spoolss dispatcher @@ -3918,8 +3984,8 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) info->servername, info->printername, info->sharename, info->portname, info->drivername, info->comment, info->location)); /* we force some elements to "correct" values */ - slprintf(info->servername, sizeof(info->servername), "\\\\%s", global_myname); - slprintf(info->printername, sizeof(info->printername), "\\\\%s\\%s", + slprintf(info->servername, sizeof(info->servername)-1, "\\\\%s", global_myname); + slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s", global_myname, lp_servicename(snum)); fstrcpy(info->sharename, lp_servicename(snum)); info->attributes = PRINTER_ATTRIBUTE_SHARED \ @@ -3955,8 +4021,8 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) /* change \ to \\ for the shell */ all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring)); - slprintf(tmp_file, sizeof(tmp_file), "%s/smbcmd.%d", path, local_pid); - slprintf(command, sizeof(command), "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", + slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d", path, local_pid); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", cmd, printer->info_2->printername, printer->info_2->sharename, printer->info_2->portname, printer->info_2->drivername, printer->info_2->location, driverlocation); @@ -4013,9 +4079,13 @@ static BOOL nt_devicemode_equal(NT_DEVICEMODE *d1, NT_DEVICEMODE *d2) return False; /* if either is exclusively NULL are not equal */ } - if (!strequal(d1->devicename, d2->devicename) || - !strequal(d1->formname, d2->formname)) { - DEBUG(10, ("nt_devicemode_equal(): device,form not equal\n")); + if (!strequal(d1->devicename, d2->devicename)) { + DEBUG(10, ("nt_devicemode_equal(): device not equal (%s != %s)\n", d1->devicename, d2->devicename)); + return False; + } + + if (!strequal(d1->formname, d2->formname)) { + DEBUG(10, ("nt_devicemode_equal(): formname not equal (%s != %s)\n", d1->formname, d2->formname)); return False; } @@ -4181,7 +4251,13 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, pi1 = p1->info_2; pi2 = p2->info_2; + /* Don't check the attributes as we stomp on the value in + check_printer_ok() anyway. */ + +#if 0 PI_CHECK_INT(attributes); +#endif + PI_CHECK_INT(priority); PI_CHECK_INT(default_priority); PI_CHECK_INT(starttime); @@ -4419,7 +4495,7 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, struct tm *t; t=gmtime(&queue->time); - snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); + slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname); job_info->jobid=queue->job; init_unistr(&job_info->printername, lp_servicename(snum)); @@ -4448,11 +4524,11 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, struct tm *t; t=gmtime(&queue->time); - snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname); + slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname); job_info->jobid=queue->job; - snprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", global_myname, ntprinter->info_2->printername); + slprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", global_myname, ntprinter->info_2->printername); init_unistr(&job_info->printername, chaine); @@ -5133,8 +5209,8 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need else path = tmpdir(); - slprintf(tmp_file, sizeof(tmp_file), "%s/smbcmd.%d", path, local_pid); - slprintf(command, sizeof(command), "%s \"%d\"", cmd, 1); + slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d", path, local_pid); + slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 1); unlink(tmp_file); DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); @@ -5231,8 +5307,8 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need else path = tmpdir(); - slprintf(tmp_file, sizeof(tmp_file), "%s/smbcmd.%d", path, local_pid); - slprintf(command, sizeof(command), "%s \"%d\"", cmd, 2); + slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d", path, local_pid); + slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 2); unlink(tmp_file); DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); -- cgit From ed77fca1990f96dba6fe9204e551056395c6ed29 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 23 Feb 2001 03:59:37 +0000 Subject: include/rpc_spoolss.h: Added JOB_STATUS_XXX defines. include/smb.h: Added LPQ_xx enums to correspond with the NT JOB_STATUS_XXX. We need these to be different as we're storing LPQ_xx enums in the tdb already. rpc_server/srv_spoolss_nt.c: Don't need to return status strings as we're now returning status codes. smbd/lanman.c: Change the RAP status codes to have "RAP" in the name. printing/printing.c: Keep track of the status of a job. Allow a job to be deleted from one smbd when being submitted by another. Made logic in mutex clearer. Jeremy. (This used to be commit 71029da7dd74eb91dd6953752bdf238f319d985d) --- source3/rpc_server/srv_spoolss_nt.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 05fbbca0f3..d5f0703e03 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -45,7 +45,7 @@ typedef struct _Printer{ BOOL open; BOOL document_started; BOOL page_started; - int jobid; /* jobid in printing backend */ + int jobid; /* jobid in printing backend */ POLICY_HND printer_hnd; BOOL printer_type; union { @@ -90,12 +90,30 @@ static uint32 smb_connections=0; static int nt_printj_status(int v) { switch (v) { - case LPQ_PAUSED: - return PRINTER_STATUS_PAUSED; case LPQ_QUEUED: + return 0; + case LPQ_PAUSED: + return JOB_STATUS_PAUSED; case LPQ_SPOOLING: + return JOB_STATUS_SPOOLING; case LPQ_PRINTING: - return 0; + return JOB_STATUS_PRINTING; + case LPQ_ERROR: + return JOB_STATUS_ERROR; + case LPQ_DELETING: + return JOB_STATUS_DELETING; + case LPQ_OFFLINE: + return JOB_STATUS_OFFLINE; + case LPQ_PAPEROUT: + return JOB_STATUS_PAPEROUT; + case LPQ_PRINTED: + return JOB_STATUS_PRINTED; + case LPQ_DELETED: + return JOB_STATUS_DELETED; + case LPQ_BLOCKED: + return JOB_STATUS_BLOCKED; + case LPQ_USER_INTERVENTION: + return JOB_STATUS_USER_INTERVENTION; } return 0; } @@ -1785,10 +1803,17 @@ static void spoolss_notify_job_status_string(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - char *p = "unknown"; + /* + * Now we're returning job status codes we just return a "" here. JRA. + */ + + char *p = ""; pstring temp; uint32 len; +#if 0 /* NO LONGER NEEDED - JRA. 02/22/2001 */ + p = "unknown"; + switch (queue->status) { case LPQ_QUEUED: p = "Queued"; @@ -1803,6 +1828,7 @@ static void spoolss_notify_job_status_string(int snum, p = "Printing"; break; } +#endif /* NO LONGER NEEDED. */ len = (uint32)dos_PutUniCode(temp, p, sizeof(temp) - 2, True); -- cgit From 1c8eb37534f885c7835f3971e5d28c9e89dd85d1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 25 Feb 2001 02:14:49 +0000 Subject: Separated reg code into interface & implementation. libsmb/namequery.c: Removed ununsed variables. Jeremy. (This used to be commit b857113f400551c57ac400a9cdc3c752085d107d) --- source3/rpc_server/srv_reg.c | 220 +++++++++------------------------------- source3/rpc_server/srv_reg_nt.c | 158 +++++++++++++++++++++++++++++ 2 files changed, 207 insertions(+), 171 deletions(-) create mode 100644 source3/rpc_server/srv_reg_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index dd411fc55e..1ca9963cd4 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -7,7 +7,8 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. * Copyright (C) Hewlett-Packard Company 1999. - * + * Copyright (C) Jeremy Allison 2001. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -23,237 +24,113 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* This is the interface for the registry functions. */ #include "includes.h" extern int DEBUGLEVEL; -/******************************************************************* - reg_reply_unknown_1 - ********************************************************************/ -static void reg_reply_close(REG_Q_CLOSE *q_r, - prs_struct *rdata) -{ - REG_R_CLOSE r_u; - - /* set up the REG unknown_1 response */ - memset((char *)r_u.pol.data, '\0', POL_HND_SIZE); - - /* close the policy handle */ - if (close_lsa_policy_hnd(&(q_r->pol))) - { - r_u.status = 0; - } - else - { - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_INVALID; - } - - DEBUG(5,("reg_unknown_1: %d\n", __LINE__)); - - /* store the response in the SMB stream */ - reg_io_r_close("", &r_u, rdata, 0); - - DEBUG(5,("reg_unknown_1: %d\n", __LINE__)); -} - /******************************************************************* api_reg_close ********************************************************************/ + static BOOL api_reg_close(pipes_struct *p) { - REG_Q_CLOSE q_r; + REG_Q_CLOSE q_u; + REG_R_CLOSE r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - /* grab the reg unknown 1 */ - reg_io_q_close("", &q_r, data, 0); - - /* construct reply. always indicate success */ - reg_reply_close(&q_r, rdata); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - return True; -} - - -/******************************************************************* - reg_reply_open - ********************************************************************/ -static void reg_reply_open(REG_Q_OPEN_HKLM *q_r, - prs_struct *rdata) -{ - REG_R_OPEN_HKLM r_u; - - r_u.status = 0x0; - /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !open_lsa_policy_hnd(&(r_u.pol))) - { - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } + /* grab the reg unknown 1 */ + if(!reg_io_q_close("", &q_u, data, 0)) + return False; - DEBUG(5,("reg_open: %d\n", __LINE__)); + r_u.status = _reg_close(p, &q_u, &r_u); - /* store the response in the SMB stream */ - reg_io_r_open_hklm("", &r_u, rdata, 0); + if(!reg_io_r_close("", &r_u, rdata, 0)) + return False; - DEBUG(5,("reg_open: %d\n", __LINE__)); + return True; } /******************************************************************* api_reg_open ********************************************************************/ + static BOOL api_reg_open(pipes_struct *p) { REG_Q_OPEN_HKLM q_u; + REG_R_OPEN_HKLM r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - /* grab the reg open */ - reg_io_q_open_hklm("", &q_u, data, 0); - - /* construct reply. always indicate success */ - reg_reply_open(&q_u, rdata); - - return True; -} - - -/******************************************************************* - reg_reply_open_entry - ********************************************************************/ -static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, - prs_struct *rdata) -{ - uint32 status = 0; - POLICY_HND pol; - REG_R_OPEN_ENTRY r_u; - fstring name; - - DEBUG(5,("reg_open_entry: %d\n", __LINE__)); - - if (status == 0 && find_lsa_policy_by_hnd(&(q_u->pol)) == -1) - { - status = NT_STATUS_INVALID_HANDLE; - } + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - if (status == 0x0 && !open_lsa_policy_hnd(&pol)) - { - status = NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ - } - - fstrcpy(name, dos_unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len)); - - if (status == 0x0) - { - DEBUG(5,("reg_open_entry: %s\n", name)); - /* lkcl XXXX do a check on the name, here */ - if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions")) - { - status = NT_STATUS_ACCESS_DENIED; - } - } - - if (status == 0x0 && !set_lsa_policy_reg_name(&pol, name)) - { - status = NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ - } + /* grab the reg open */ + if(!reg_io_q_open_hklm("", &q_u, data, 0)) + return False; - init_reg_r_open_entry(&r_u, &pol, status); + r_u.status = _reg_open(p, &q_u, &r_u); - /* store the response in the SMB stream */ - reg_io_r_open_entry("", &r_u, rdata, 0); + if(!reg_io_r_open_hklm("", &r_u, rdata, 0)) + return False; - DEBUG(5,("reg_open_entry: %d\n", __LINE__)); + return True; } /******************************************************************* api_reg_open_entry ********************************************************************/ + static BOOL api_reg_open_entry(pipes_struct *p) { REG_Q_OPEN_ENTRY q_u; + REG_R_OPEN_ENTRY r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + /* grab the reg open entry */ - reg_io_q_open_entry("", &q_u, data, 0); + if(!reg_io_q_open_entry("", &q_u, data, 0)) + return False; /* construct reply. */ - reg_reply_open_entry(&q_u, rdata); + r_u.status = _reg_open_entry(p, &q_u, &r_u); - return True; -} - - -/******************************************************************* - reg_reply_info - ********************************************************************/ -static void reg_reply_info(REG_Q_INFO *q_u, - prs_struct *rdata) -{ - uint32 status = 0; - char *key; - uint32 type=0x1; /* key type: REG_SZ */ - - UNISTR2 uni_key; - BUFFER2 buf; + if(!reg_io_r_open_entry("", &r_u, rdata, 0)) + return False; - REG_R_INFO r_u; - - DEBUG(5,("reg_info: %d\n", __LINE__)); - - if (status == 0 && find_lsa_policy_by_hnd(&(q_u->pol)) == -1) - { - status = NT_STATUS_INVALID_HANDLE; - } - - switch (lp_server_role()) - { - case ROLE_DOMAIN_PDC: - case ROLE_DOMAIN_BDC: - { - key = "LanmanNT"; - break; - } - case ROLE_STANDALONE: - { - key = "ServerNT"; - break; - } - case ROLE_DOMAIN_MEMBER: - { - key = "WinNT"; - break; - } - } - /* This makes the server look like a member server to clients */ - /* which tells clients that we have our own local user and */ - /* group databases and helps with ACL support. */ - init_unistr2(&uni_key, key, strlen(key)+1); - init_buffer2(&buf, (uint8*) uni_key.buffer, uni_key.uni_str_len*2); - - init_reg_r_info(q_u->ptr_buf, &r_u, &buf, type, status); - - /* store the response in the SMB stream */ - reg_io_r_info("", &r_u, rdata, 0); - - DEBUG(5,("reg_open_entry: %d\n", __LINE__)); + return True; } /******************************************************************* api_reg_info ********************************************************************/ + static BOOL api_reg_info(pipes_struct *p) { REG_Q_INFO q_u; + REG_R_INFO r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + /* grab the reg unknown 0x11*/ - reg_io_q_info("", &q_u, data, 0); + if(!reg_io_q_info("", &q_u, data, 0)) + return False; - /* construct reply. always indicate success */ - reg_reply_info(&q_u, rdata); + r_u.status = _reg_info(p, &q_u, &r_u); + + if(!reg_io_r_info("", &r_u, rdata, 0)) + return False; return True; } @@ -274,6 +151,7 @@ static struct api_struct api_reg_cmds[] = /******************************************************************* receives a reg pipe and responds. ********************************************************************/ + BOOL api_reg_rpc(pipes_struct *p) { return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds); diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c new file mode 100644 index 0000000000..769b376468 --- /dev/null +++ b/source3/rpc_server/srv_reg_nt.c @@ -0,0 +1,158 @@ +#define OLD_NTDOMAIN 1 +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997. + * Copyright (C) Hewlett-Packard Company 1999. + * Copyright (C) Jeremy Allison 2001. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Implementation of registry functions. */ + +#include "includes.h" + +extern int DEBUGLEVEL; + +/******************************************************************* + reg_reply_unknown_1 + ********************************************************************/ + +uint32 _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) +{ + /* set up the REG unknown_1 response */ + memset((char *)r_u->pol.data, '\0', POL_HND_SIZE); + + /* close the policy handle */ + if (!close_lsa_policy_hnd(&q_u->pol)) + return NT_STATUS_OBJECT_NAME_INVALID; + + return NT_STATUS_NOPROBLEMO; +} + +/******************************************************************* + reg_reply_open + ********************************************************************/ + +uint32 _reg_open(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u) +{ + if (!open_lsa_policy_hnd(&r_u->pol)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + return NT_STATUS_NOPROBLEMO; +} + +/******************************************************************* + reg_reply_open_entry + ********************************************************************/ + +uint32 _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY *r_u) +{ + POLICY_HND pol; + fstring name; + + DEBUG(5,("reg_open_entry: %d\n", __LINE__)); + + if (find_lsa_policy_by_hnd(&q_u->pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + if (!open_lsa_policy_hnd(&pol)) + return NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ + + fstrcpy(name, dos_unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len)); + + DEBUG(5,("reg_open_entry: %s\n", name)); + + /* lkcl XXXX do a check on the name, here */ + if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions") && + !strequal(name, "System\\CurrentControlSet\\services\\Netlogon\\parameters\\")) + return NT_STATUS_ACCESS_DENIED; + + if (!set_lsa_policy_reg_name(&pol, name)) + return NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ + + init_reg_r_open_entry(r_u, &pol, NT_STATUS_NOPROBLEMO); + + DEBUG(5,("reg_open_entry: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* + reg_reply_info + ********************************************************************/ + +uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) +{ + uint32 status = NT_STATUS_NOPROBLEMO; + char *key; + uint32 type=0x1; /* key type: REG_SZ */ + + UNISTR2 uni_key; + BUFFER2 buf; + fstring name; + + DEBUG(5,("_reg_info: %d\n", __LINE__)); + + if (find_lsa_policy_by_hnd(&q_u->pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + fstrcpy(name, dos_unistrn2(q_u->uni_type.buffer, q_u->uni_type.uni_str_len)); + + DEBUG(5,("reg_info: checking key: %s\n", name)); + + if ( strequal(name, "RefusePasswordChange") ) { + type=0xF770; + status = ERRbadfile; + init_unistr2(&uni_key, "", 0); + init_buffer2(&buf, (uint8*) uni_key.buffer, uni_key.uni_str_len*2); + + buf.buf_max_len=4; + + goto out; + } + + switch (lp_server_role()) { + case ROLE_DOMAIN_PDC: + case ROLE_DOMAIN_BDC: + key = "LanmanNT"; + break; + case ROLE_STANDALONE: + key = "ServerNT"; + break; + case ROLE_DOMAIN_MEMBER: + key = "WinNT"; + break; + } + + /* This makes the server look like a member server to clients */ + /* which tells clients that we have our own local user and */ + /* group databases and helps with ACL support. */ + + init_unistr2(&uni_key, key, strlen(key)+1); + init_buffer2(&buf, (uint8*)uni_key.buffer, uni_key.uni_str_len*2); + + out: + init_reg_r_info(q_u->ptr_buf, r_u, &buf, type, status); + + DEBUG(5,("reg_open_entry: %d\n", __LINE__)); + + return status; +} +#undef OLD_NTDOMAIN -- cgit From 683ccef0bdfc6a1460087cc3eed2b7ac643d0227 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 26 Feb 2001 08:10:51 +0000 Subject: Started conversion of lsa server code to canonical format (as srv_reg and srv_samr have been). Jeremy. (This used to be commit f434cda9774b4864321b37b0f8f42e6e8dee8d5b) --- source3/rpc_server/srv_lsa.c | 151 ++++++++++++++++++++++++++----------------- 1 file changed, 93 insertions(+), 58 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 3629bb7d8e..7d79de6bba 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -6,7 +6,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jeremy Allison 1998. + * Copyright (C) Jeremy Allison 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -125,7 +125,7 @@ static void lsa_reply_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM *q_e, /* set up the LSA QUERY INFO response */ init_r_enum_trust_dom(&r_e, enum_context, dom_name, dom_sid, - dom_name != NULL ? 0x0 : 0x80000000 | NT_STATUS_UNABLE_TO_FREE_VM); + dom_name != NULL ? NT_STATUS_NO_PROBLEMO : NT_STATUS_UNABLE_TO_FREE_VM); /* store the response in the SMB stream */ lsa_io_r_enum_trust_dom("", &r_e, rdata, 0); @@ -267,9 +267,9 @@ static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, r_l->mapped_count = mapped_count; if (mapped_count == 0) - r_l->status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + r_l->status = NT_STATUS_NONE_MAPPED; else - r_l->status = 0x0; + r_l->status = NT_STATUS_NO_PROBLEMO; } /*************************************************************************** @@ -362,9 +362,9 @@ static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, r_l->mapped_count = mapped_count; if (mapped_count == 0) - r_l->status = 0xC0000000 | NT_STATUS_NONE_MAPPED; + r_l->status = NT_STATUS_NONE_MAPPED; else - r_l->status = 0x0; + r_l->status = NT_STATUS_NO_PROBLEMO; } /*************************************************************************** @@ -398,36 +398,6 @@ static BOOL lsa_reply_lookup_sids(prs_struct *rdata, DOM_SID2 *sid, int num_entr return True; } -/*************************************************************************** -lsa_reply_lookup_names - ***************************************************************************/ - -static BOOL lsa_reply_lookup_names(prs_struct *rdata, UNISTR2 *names, - int num_entries) -{ - LSA_R_LOOKUP_NAMES r_l; - DOM_R_REF ref; - DOM_RID2 rids[MAX_LOOKUP_SIDS]; - uint32 mapped_count = 0; - BOOL result = True; - - ZERO_STRUCT(r_l); - ZERO_STRUCT(ref); - ZERO_ARRAY(rids); - - /* set up the LSA Lookup RIDs response */ - init_lsa_rid2s(&ref, rids, num_entries, names, &mapped_count); - init_reply_lookup_names(&r_l, &ref, num_entries, rids, mapped_count); - - /* store the response in the SMB stream */ - if(!lsa_io_r_lookup_names("", &r_l, rdata, 0)) { - DEBUG(0,("lsa_reply_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n")); - result = False; - } - - return result; -} - /*************************************************************************** api_lsa_open_policy2 ***************************************************************************/ @@ -587,7 +557,7 @@ static BOOL api_lsa_query_info(pipes_struct *p) break; default: DEBUG(0,("api_lsa_query_info: unknown info level in Lsa Query: %d\n", q_i.info_class)); - r_q.status = (NT_STATUS_INVALID_INFO_CLASS | 0xC0000000); + r_q.status = NT_STATUS_INVALID_INFO_CLASS; break; } @@ -625,39 +595,91 @@ static BOOL api_lsa_lookup_sids(pipes_struct *p) return result; } +/*************************************************************************** +lsa_reply_lookup_names + ***************************************************************************/ + +static uint32 _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_NAMES *r_u) +{ + UNISTR2 *names = q_u->uni_name; + int num_entries = q_u->num_entries; + DOM_R_REF ref; + DOM_RID2 rids[MAX_LOOKUP_SIDS]; + uint32 mapped_count = 0; + + ZERO_STRUCT(ref); + ZERO_ARRAY(rids); + + /* set up the LSA Lookup RIDs response */ + init_lsa_rid2s(&ref, rids, num_entries, names, &mapped_count); + init_reply_lookup_names(r_u, &ref, num_entries, rids, mapped_count); + + return r_u->status; +} + /*************************************************************************** api_lsa_lookup_names ***************************************************************************/ static BOOL api_lsa_lookup_names(pipes_struct *p) { - LSA_Q_LOOKUP_NAMES q_l; + LSA_Q_LOOKUP_NAMES q_u; + LSA_R_LOOKUP_NAMES r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - ZERO_STRUCT(q_l); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_names("", &q_l, data, 0)) { + if(!lsa_io_q_lookup_names("", &q_u, data, 0)) { DEBUG(0,("api_lsa_lookup_names: failed to unmarshall LSA_Q_LOOKUP_NAMES.\n")); return False; } - return lsa_reply_lookup_names(rdata, q_l.uni_name, q_l.num_entries); + r_u.status = _lsa_lookup_names(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_lookup_names("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n")); + return False; + } + + return True; } /*************************************************************************** - api_lsa_close + _lsa_close. Also weird - needs to check if lsa handle is correct. JRA. ***************************************************************************/ + +static uint32 _lsa_close(pipes_struct *p, LSA_Q_CLOSE *q_u, LSA_R_CLOSE *r_u) +{ + return NT_STATUS_NO_PROBLEMO; +} + +/*************************************************************************** + api_lsa_close. + ***************************************************************************/ + static BOOL api_lsa_close(pipes_struct *p) { - LSA_R_CLOSE r_c; + LSA_Q_CLOSE q_u; + LSA_R_CLOSE r_u; + prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - ZERO_STRUCT(r_c); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!lsa_io_q_close("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_close: lsa_io_q_close failed.\n")); + return False; + } + + r_u.status = _lsa_close(p, &q_u, &r_u); /* store the response in the SMB stream */ - if (!lsa_io_r_close("", &r_c, rdata, 0)) { + if (!lsa_io_r_close("", &r_u, rdata, 0)) { DEBUG(0,("api_lsa_close: lsa_io_r_close failed.\n")); return False; } @@ -666,26 +688,38 @@ static BOOL api_lsa_close(pipes_struct *p) } /*************************************************************************** - api_lsa_open_secret + "No more secrets Marty...." :-). + ***************************************************************************/ + +static uint32 _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SECRET *r_u) +{ + return NT_STATUS_OBJECT_NAME_NOT_FOUND; +} + +/*************************************************************************** + api_lsa_open_secret. ***************************************************************************/ + static BOOL api_lsa_open_secret(pipes_struct *p) { - /* XXXX this is NOT good */ - size_t i; - uint32 dummy = 0; + LSA_Q_OPEN_SECRET q_u; + LSA_R_OPEN_SECRET r_u; + prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - for(i =0; i < 4; i++) { - if(!prs_uint32("api_lsa_close", rdata, 1, &dummy)) { - DEBUG(0,("api_lsa_open_secret: prs_uint32 %d failed.\n", - (int)i )); - return False; - } + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_open_secret("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_open_secret: failed to unmarshall LSA_Q_OPEN_SECRET.\n")); + return False; } - dummy = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - if(!prs_uint32("api_lsa_close", rdata, 1, &dummy)) { - DEBUG(0,("api_lsa_open_secret: prs_uint32 status failed.\n")); + r_u.status = _lsa_open_secret(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_open_secret("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_open_secret: Failed to marshall LSA_R_OPEN_SECRET.\n")); return False; } @@ -695,6 +729,7 @@ static BOOL api_lsa_open_secret(pipes_struct *p) /*************************************************************************** \PIPE\ntlsa commands ***************************************************************************/ + static struct api_struct api_lsa_cmds[] = { { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 }, -- cgit From e1951d75fc49b40c9c87d54b61312b6c38468f0c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 26 Feb 2001 19:31:07 +0000 Subject: Added implementation file for lsa. Jeremy. (This used to be commit 72e7c261e85b9cad19b93fb160168531290a5404) --- source3/rpc_server/srv_lsa_nt.c | 475 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 475 insertions(+) create mode 100644 source3/rpc_server/srv_lsa_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c new file mode 100644 index 0000000000..6f7cb0f7b3 --- /dev/null +++ b/source3/rpc_server/srv_lsa_nt.c @@ -0,0 +1,475 @@ +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997. + * Copyright (C) Jeremy Allison 2001. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* This is the implementation of the lsa server code. */ + +#include "includes.h" + +extern int DEBUGLEVEL; +extern DOM_SID global_sam_sid; +extern fstring global_myworkgroup; +extern pstring global_myname; + +/*************************************************************************** +Init dom_query + ***************************************************************************/ + +static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) +{ + int domlen = (dom_name != NULL) ? strlen(dom_name) : 0; + + /* + * I'm not sure why this really odd combination of length + * values works, but it does appear to. I need to look at + * this *much* more closely - but at the moment leave alone + * until it's understood. This allows a W2k client to join + * a domain with both odd and even length names... JRA. + */ + + d_q->uni_dom_str_len = domlen ? ((domlen + 1) * 2) : 0; + d_q->uni_dom_max_len = domlen * 2; + d_q->buffer_dom_name = domlen != 0 ? 1 : 0; /* domain buffer pointer */ + d_q->buffer_dom_sid = dom_sid != NULL ? 1 : 0; /* domain sid pointer */ + + /* this string is supposed to be character short */ + init_unistr2(&d_q->uni_domain_name, dom_name, domlen); + d_q->uni_domain_name.uni_max_len++; + + if (dom_sid != NULL) + init_dom_sid2(&d_q->dom_sid, dom_sid); +} + +/*************************************************************************** + init_dom_ref - adds a domain if it's not already in, returns the index. +***************************************************************************/ + +static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) +{ + int num = 0; + int len; + + if (dom_name != NULL) { + for (num = 0; num < ref->num_ref_doms_1; num++) { + fstring domname; + fstrcpy(domname, dos_unistr2_to_str(&ref->ref_dom[num].uni_dom_name)); + if (strequal(domname, dom_name)) + return num; + } + } else { + num = ref->num_ref_doms_1; + } + + if (num >= MAX_REF_DOMAINS) { + /* index not found, already at maximum domain limit */ + return -1; + } + + ref->num_ref_doms_1 = num+1; + ref->ptr_ref_dom = 1; + ref->max_entries = MAX_REF_DOMAINS; + ref->num_ref_doms_2 = num+1; + + len = (dom_name != NULL) ? strlen(dom_name) : 0; + if(dom_name != NULL && len == 0) + len = 1; + + init_uni_hdr(&ref->hdr_ref_dom[num].hdr_dom_name, len); + ref->hdr_ref_dom[num].ptr_dom_sid = dom_sid != NULL ? 1 : 0; + + init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name, len); + init_dom_sid2(&ref->ref_dom[num].ref_dom, dom_sid ); + + return num; +} + +/*************************************************************************** + init_lsa_rid2s + ***************************************************************************/ + +static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, + int num_entries, UNISTR2 name[MAX_LOOKUP_SIDS], + uint32 *mapped_count) +{ + int i; + int total = 0; + *mapped_count = 0; + + SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS); + + for (i = 0; i < num_entries; i++) { + BOOL status = False; + DOM_SID sid; + uint32 rid = 0xffffffff; + int dom_idx = -1; + pstring full_name; + fstring dom_name, user; + enum SID_NAME_USE name_type = SID_NAME_UNKNOWN; + + /* Split name into domain and user component */ + + pstrcpy(full_name, dos_unistr2_to_str(&name[i])); + split_domain_name(full_name, dom_name, user); + + /* Lookup name */ + + DEBUG(5, ("init_lsa_rid2s: looking up name %s\n", full_name)); + + status = lookup_name(full_name, &sid, &name_type); + + DEBUG(5, ("init_lsa_rid2s: %s\n", status ? "found" : + "not found")); + + if (status) { + sid_split_rid(&sid, &rid); + dom_idx = init_dom_ref(ref, dom_name, &sid); + (*mapped_count)++; + } else { + dom_idx = -1; + rid = 0xffffffff; + name_type = SID_NAME_UNKNOWN; + } + + init_dom_rid2(&rid2[total], rid, name_type, dom_idx); + total++; + } +} + +/*************************************************************************** + init_reply_lookup_names + ***************************************************************************/ + +static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, + DOM_R_REF *ref, uint32 num_entries, + DOM_RID2 *rid2, uint32 mapped_count) +{ + r_l->ptr_dom_ref = 1; + r_l->dom_ref = ref; + + r_l->num_entries = num_entries; + r_l->ptr_entries = 1; + r_l->num_entries2 = num_entries; + r_l->dom_rid = rid2; + + r_l->mapped_count = mapped_count; + + if (mapped_count == 0) + r_l->status = NT_STATUS_NONE_MAPPED; + else + r_l->status = NT_STATUS_NO_PROBLEMO; +} + +/*************************************************************************** + Init lsa_trans_names. + ***************************************************************************/ + +static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, + int num_entries, DOM_SID2 *sid, + uint32 *mapped_count) +{ + int i; + int total = 0; + *mapped_count = 0; + + /* Allocate memory for list of names */ + + if (num_entries > 0) { + if (!(trn->name = (LSA_TRANS_NAME *)talloc(ctx, sizeof(LSA_TRANS_NAME) * + num_entries))) { + DEBUG(0, ("init_lsa_trans_names(): out of memory\n")); + return; + } + + if (!(trn->uni_name = (UNISTR2 *)talloc(ctx, sizeof(UNISTR2) * + num_entries))) { + DEBUG(0, ("init_lsa_trans_names(): out of memory\n")); + return; + } + } + + for (i = 0; i < num_entries; i++) { + BOOL status = False; + DOM_SID find_sid = sid[i].sid; + uint32 rid = 0xffffffff; + int dom_idx = -1; + fstring name, dom_name; + enum SID_NAME_USE sid_name_use = (enum SID_NAME_USE)0; + + sid_to_string(name, &find_sid); + DEBUG(5, ("init_lsa_trans_names: looking up sid %s\n", name)); + + /* Lookup sid from winbindd */ + + memset(dom_name, '\0', sizeof(dom_name)); + memset(name, '\0', sizeof(name)); + + status = lookup_sid(&find_sid, dom_name, name, &sid_name_use); + + DEBUG(5, ("init_lsa_trans_names: %s\n", status ? "found" : + "not found")); + + if (!status) { + sid_name_use = SID_NAME_UNKNOWN; + } + + /* Store domain sid in ref array */ + + if (find_sid.num_auths == 5) { + sid_split_rid(&find_sid, &rid); + } + + dom_idx = init_dom_ref(ref, dom_name, &find_sid); + + DEBUG(10,("init_lsa_trans_names: added user '%s\\%s' to " + "referenced list.\n", dom_name, name )); + + (*mapped_count)++; + + init_lsa_trans_name(&trn->name[total], &trn->uni_name[total], + sid_name_use, name, dom_idx); + total++; + } + + trn->num_entries = total; + trn->ptr_trans_names = 1; + trn->num_entries2 = total; +} + +/*************************************************************************** + Init_reply_lookup_sids. + ***************************************************************************/ + +static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, + DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *names, + uint32 mapped_count) +{ + r_l->ptr_dom_ref = 1; + r_l->dom_ref = ref; + r_l->names = names; + r_l->mapped_count = mapped_count; + + if (mapped_count == 0) + r_l->status = NT_STATUS_NONE_MAPPED; + else + r_l->status = NT_STATUS_NO_PROBLEMO; +} + +/*************************************************************************** + _lsa_open_policy2. + ***************************************************************************/ + +uint32 _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2 *r_u) +{ + int i; + + /* lkclXXXX having decoded it, ignore all fields in the open policy! */ + + /* set up the LSA QUERY INFO response */ + + for (i = 4; i < POL_HND_SIZE; i++) + r_u->pol.data[i] = i; + + return NT_STATUS_NOPROBLEMO; +} + +/*************************************************************************** + _lsa_open_policy + ***************************************************************************/ + +uint32 _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL *r_u) +{ + int i; + + /* lkclXXXX having decoded it, ignore all fields in the open policy! */ + + /* set up the LSA QUERY INFO response */ + + for (i = 4; i < POL_HND_SIZE; i++) + r_u->pol.data[i] = i; + + return NT_STATUS_NOPROBLEMO; +} + +/*************************************************************************** + _lsa_enum_trust_dom - this needs fixing to do more than return NULL ! JRA. + ***************************************************************************/ + +uint32 _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_ENUM_TRUST_DOM *r_u) +{ + uint32 enum_context = 0; + char *dom_name = NULL; + DOM_SID *dom_sid = NULL; + + /* 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); + + return r_u->status; +} + +/*************************************************************************** + _lsa_query_info + ***************************************************************************/ + +uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO *r_u) +{ + LSA_INFO_UNION *info = &r_u->dom; + DOM_SID domain_sid; + char *name = NULL; + DOM_SID *sid = NULL; + + r_u->status = NT_STATUS_NO_PROBLEMO; + + switch (q_u->info_class) { + case 0x02: + { + unsigned int i; + /* fake info: We audit everything. ;) */ + info->id2.auditing_enabled = 1; + info->id2.count1 = 7; + info->id2.count2 = 7; + if ((info->id2.auditsettings = (uint32 *)talloc(p->mem_ctx,7*sizeof(uint32))) == NULL) + return False; + for (i = 0; i < 7; i++) + info->id2.auditsettings[i] = 3; + break; + } + case 0x03: + switch (lp_server_role()) + { + case ROLE_DOMAIN_PDC: + case ROLE_DOMAIN_BDC: + name = global_myworkgroup; + sid = &global_sam_sid; + break; + case ROLE_DOMAIN_MEMBER: + if (secrets_fetch_domain_sid(global_myworkgroup, + &domain_sid)) + { + name = global_myworkgroup; + sid = &domain_sid; + } + default: + break; + } + init_dom_query(&r_u->dom.id3, name, sid); + break; + case 0x05: + name = global_myname; + sid = &global_sam_sid; + init_dom_query(&r_u->dom.id5, name, sid); + break; + case 0x06: + switch (lp_server_role()) + { + case ROLE_DOMAIN_BDC: + /* + * only a BDC is a backup controller + * of the domain, it controls. + */ + info->id6.server_role = 2; + break; + default: + /* + * any other role is a primary + * of the domain, it controls. + */ + info->id6.server_role = 3; + break; + } + break; + default: + DEBUG(0,("_lsa_query_info: unknown info level in Lsa Query: %d\n", q_u->info_class)); + r_u->status = NT_STATUS_INVALID_INFO_CLASS; + break; + } + + if(r_u->status == NT_STATUS_NO_PROBLEMO) { + r_u->undoc_buffer = 0x22000000; /* bizarre */ + r_u->info_class = q_u->info_class; + } + + return r_u->status; +} + +/*************************************************************************** + _lsa_lookup_sids + ***************************************************************************/ + +uint32 _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_SIDS *r_u) +{ + DOM_SID2 *sid = q_u->sids.sid; + int num_entries = q_u->sids.num_entries; + DOM_R_REF ref; + LSA_TRANS_NAME_ENUM names; + uint32 mapped_count = 0; + + ZERO_STRUCT(ref); + ZERO_STRUCT(names); + + /* set up the LSA Lookup SIDs response */ + init_lsa_trans_names(p->mem_ctx, &ref, &names, num_entries, sid, &mapped_count); + init_reply_lookup_sids(r_u, &ref, &names, mapped_count); + + return r_u->status; +} + +/*************************************************************************** +lsa_reply_lookup_names + ***************************************************************************/ + +uint32 _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_NAMES *r_u) +{ + UNISTR2 *names = q_u->uni_name; + int num_entries = q_u->num_entries; + DOM_R_REF ref; + DOM_RID2 rids[MAX_LOOKUP_SIDS]; + uint32 mapped_count = 0; + + ZERO_STRUCT(ref); + ZERO_ARRAY(rids); + + /* set up the LSA Lookup RIDs response */ + init_lsa_rid2s(&ref, rids, num_entries, names, &mapped_count); + init_reply_lookup_names(r_u, &ref, num_entries, rids, mapped_count); + + return r_u->status; +} + +/*************************************************************************** + _lsa_close. Also weird - needs to check if lsa handle is correct. JRA. + ***************************************************************************/ + +uint32 _lsa_close(pipes_struct *p, LSA_Q_CLOSE *q_u, LSA_R_CLOSE *r_u) +{ + return NT_STATUS_NO_PROBLEMO; +} + +/*************************************************************************** + "No more secrets Marty...." :-). + ***************************************************************************/ + +uint32 _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SECRET *r_u) +{ + return NT_STATUS_OBJECT_NAME_NOT_FOUND; +} -- cgit From d757d61abfd028f9088ef133100d4c6aebce3fc6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 26 Feb 2001 19:45:00 +0000 Subject: Separated lsa code into interface and implementation. Jeremy. (This used to be commit 1cc96e0340b9e3ac343d6a28211bf0cc5bc6573b) --- source3/rpc_server/srv_lsa.c | 573 ++++------------------------------------ source3/rpc_server/srv_lsa_nt.c | 2 + 2 files changed, 60 insertions(+), 515 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 7d79de6bba..3b6725ec3a 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -23,380 +23,11 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* This is the interface to the lsa server code. */ + #include "includes.h" extern int DEBUGLEVEL; -extern DOM_SID global_sam_sid; -extern fstring global_myworkgroup; -extern pstring global_myname; - -/*************************************************************************** - lsa_reply_open_policy2 - ***************************************************************************/ - -static BOOL lsa_reply_open_policy2(prs_struct *rdata) -{ - int i; - LSA_R_OPEN_POL2 r_o; - - ZERO_STRUCT(r_o); - - /* set up the LSA QUERY INFO response */ - - for (i = 4; i < POL_HND_SIZE; i++) - r_o.pol.data[i] = i; - r_o.status = 0x0; - - /* store the response in the SMB stream */ - if(!lsa_io_r_open_pol2("", &r_o, rdata, 0)) { - DEBUG(0,("lsa_reply_open_policy2: unable to marshall LSA_R_OPEN_POL2.\n")); - return False; - } - - return True; -} - -/*************************************************************************** -lsa_reply_open_policy - ***************************************************************************/ - -static BOOL lsa_reply_open_policy(prs_struct *rdata) -{ - int i; - LSA_R_OPEN_POL r_o; - - ZERO_STRUCT(r_o); - - /* set up the LSA QUERY INFO response */ - - for (i = 4; i < POL_HND_SIZE; i++) - r_o.pol.data[i] = i; - r_o.status = 0x0; - - /* store the response in the SMB stream */ - if(!lsa_io_r_open_pol("", &r_o, rdata, 0)) { - DEBUG(0,("lsa_reply_open_policy: unable to marshall LSA_R_OPEN_POL.\n")); - return False; - } - - return True; -} - -/*************************************************************************** -Init dom_query - ***************************************************************************/ - -static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) -{ - int domlen = (dom_name != NULL) ? strlen(dom_name) : 0; - - /* - * I'm not sure why this really odd combination of length - * values works, but it does appear to. I need to look at - * this *much* more closely - but at the moment leave alone - * until it's understood. This allows a W2k client to join - * a domain with both odd and even length names... JRA. - */ - - d_q->uni_dom_str_len = domlen ? ((domlen + 1) * 2) : 0; - d_q->uni_dom_max_len = domlen * 2; - d_q->buffer_dom_name = domlen != 0 ? 1 : 0; /* domain buffer pointer */ - d_q->buffer_dom_sid = dom_sid != NULL ? 1 : 0; /* domain sid pointer */ - - /* this string is supposed to be character short */ - init_unistr2(&d_q->uni_domain_name, dom_name, domlen); - d_q->uni_domain_name.uni_max_len++; - - if (dom_sid != NULL) - init_dom_sid2(&d_q->dom_sid, dom_sid); -} - -/*************************************************************************** - lsa_reply_enum_trust_dom - ***************************************************************************/ - -static void lsa_reply_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM *q_e, - prs_struct *rdata, - uint32 enum_context, char *dom_name, DOM_SID *dom_sid) -{ - LSA_R_ENUM_TRUST_DOM r_e; - - ZERO_STRUCT(r_e); - - /* set up the LSA QUERY INFO response */ - init_r_enum_trust_dom(&r_e, enum_context, dom_name, dom_sid, - dom_name != NULL ? NT_STATUS_NO_PROBLEMO : NT_STATUS_UNABLE_TO_FREE_VM); - - /* store the response in the SMB stream */ - lsa_io_r_enum_trust_dom("", &r_e, rdata, 0); -} - -/*************************************************************************** -lsa_reply_query_info - ***************************************************************************/ - -static BOOL lsa_reply_query_info(LSA_Q_QUERY_INFO *q_q, prs_struct *rdata, LSA_R_QUERY_INFO *r_q) -{ - /* set up the LSA QUERY INFO response */ - - if(r_q->status == 0) { - r_q->undoc_buffer = 0x22000000; /* bizarre */ - r_q->info_class = q_q->info_class; - } - - /* store the response in the SMB stream */ - if(!lsa_io_r_query("", r_q, rdata, 0)) { - DEBUG(0,("lsa_reply_query_info: failed to marshall LSA_R_QUERY_INFO.\n")); - return False; - } - - return True; -} - -/*************************************************************************** - init_dom_ref - adds a domain if it's not already in, returns the index. -***************************************************************************/ - -static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) -{ - int num = 0; - int len; - - if (dom_name != NULL) { - for (num = 0; num < ref->num_ref_doms_1; num++) { - fstring domname; - fstrcpy(domname, dos_unistr2_to_str(&ref->ref_dom[num].uni_dom_name)); - if (strequal(domname, dom_name)) - return num; - } - } else { - num = ref->num_ref_doms_1; - } - - if (num >= MAX_REF_DOMAINS) { - /* index not found, already at maximum domain limit */ - return -1; - } - - ref->num_ref_doms_1 = num+1; - ref->ptr_ref_dom = 1; - ref->max_entries = MAX_REF_DOMAINS; - ref->num_ref_doms_2 = num+1; - - len = (dom_name != NULL) ? strlen(dom_name) : 0; - if(dom_name != NULL && len == 0) - len = 1; - - init_uni_hdr(&ref->hdr_ref_dom[num].hdr_dom_name, len); - ref->hdr_ref_dom[num].ptr_dom_sid = dom_sid != NULL ? 1 : 0; - - init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name, len); - init_dom_sid2(&ref->ref_dom[num].ref_dom, dom_sid ); - - return num; -} - -/*************************************************************************** - init_lsa_rid2s - ***************************************************************************/ - -static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, - int num_entries, UNISTR2 name[MAX_LOOKUP_SIDS], - uint32 *mapped_count) -{ - int i; - int total = 0; - *mapped_count = 0; - - SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS); - - for (i = 0; i < num_entries; i++) { - BOOL status = False; - DOM_SID sid; - uint32 rid = 0xffffffff; - int dom_idx = -1; - pstring full_name; - fstring dom_name, user; - enum SID_NAME_USE name_type = SID_NAME_UNKNOWN; - - /* Split name into domain and user component */ - - pstrcpy(full_name, dos_unistr2_to_str(&name[i])); - split_domain_name(full_name, dom_name, user); - - /* Lookup name */ - - DEBUG(5, ("init_lsa_rid2s: looking up name %s\n", full_name)); - - status = lookup_name(full_name, &sid, &name_type); - - DEBUG(5, ("init_lsa_rid2s: %s\n", status ? "found" : - "not found")); - - if (status) { - sid_split_rid(&sid, &rid); - dom_idx = init_dom_ref(ref, dom_name, &sid); - (*mapped_count)++; - } else { - dom_idx = -1; - rid = 0xffffffff; - name_type = SID_NAME_UNKNOWN; - } - - init_dom_rid2(&rid2[total], rid, name_type, dom_idx); - total++; - } -} - -/*************************************************************************** - init_reply_lookup_names - ***************************************************************************/ - -static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, - DOM_R_REF *ref, uint32 num_entries, - DOM_RID2 *rid2, uint32 mapped_count) -{ - r_l->ptr_dom_ref = 1; - r_l->dom_ref = ref; - - r_l->num_entries = num_entries; - r_l->ptr_entries = 1; - r_l->num_entries2 = num_entries; - r_l->dom_rid = rid2; - - r_l->mapped_count = mapped_count; - - if (mapped_count == 0) - r_l->status = NT_STATUS_NONE_MAPPED; - else - r_l->status = NT_STATUS_NO_PROBLEMO; -} - -/*************************************************************************** - Init lsa_trans_names. - ***************************************************************************/ - -static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, - int num_entries, DOM_SID2 *sid, - uint32 *mapped_count) -{ - int i; - int total = 0; - *mapped_count = 0; - - /* Allocate memory for list of names */ - - if (num_entries > 0) { - if (!(trn->name = (LSA_TRANS_NAME *)talloc(ctx, sizeof(LSA_TRANS_NAME) * - num_entries))) { - DEBUG(0, ("init_lsa_trans_names(): out of memory\n")); - return; - } - - if (!(trn->uni_name = (UNISTR2 *)talloc(ctx, sizeof(UNISTR2) * - num_entries))) { - DEBUG(0, ("init_lsa_trans_names(): out of memory\n")); - return; - } - } - - for (i = 0; i < num_entries; i++) { - BOOL status = False; - DOM_SID find_sid = sid[i].sid; - uint32 rid = 0xffffffff; - int dom_idx = -1; - fstring name, dom_name; - enum SID_NAME_USE sid_name_use = (enum SID_NAME_USE)0; - - sid_to_string(name, &find_sid); - DEBUG(5, ("init_lsa_trans_names: looking up sid %s\n", name)); - - /* Lookup sid from winbindd */ - - memset(dom_name, '\0', sizeof(dom_name)); - memset(name, '\0', sizeof(name)); - - status = lookup_sid(&find_sid, dom_name, name, &sid_name_use); - - DEBUG(5, ("init_lsa_trans_names: %s\n", status ? "found" : - "not found")); - - if (!status) { - sid_name_use = SID_NAME_UNKNOWN; - } - - /* Store domain sid in ref array */ - - if (find_sid.num_auths == 5) { - sid_split_rid(&find_sid, &rid); - } - - dom_idx = init_dom_ref(ref, dom_name, &find_sid); - - DEBUG(10,("init_lsa_trans_names: added user '%s\\%s' to " - "referenced list.\n", dom_name, name )); - - (*mapped_count)++; - - init_lsa_trans_name(&trn->name[total], &trn->uni_name[total], - sid_name_use, name, dom_idx); - total++; - } - - trn->num_entries = total; - trn->ptr_trans_names = 1; - trn->num_entries2 = total; -} - -/*************************************************************************** - Init_reply_lookup_sids. - ***************************************************************************/ - -static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, - DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *names, - uint32 mapped_count) -{ - r_l->ptr_dom_ref = 1; - r_l->dom_ref = ref; - r_l->names = names; - r_l->mapped_count = mapped_count; - - if (mapped_count == 0) - r_l->status = NT_STATUS_NONE_MAPPED; - else - r_l->status = NT_STATUS_NO_PROBLEMO; -} - -/*************************************************************************** -lsa_reply_lookup_sids - ***************************************************************************/ - -static BOOL lsa_reply_lookup_sids(prs_struct *rdata, DOM_SID2 *sid, int num_entries) -{ - LSA_R_LOOKUP_SIDS r_l; - DOM_R_REF ref; - LSA_TRANS_NAME_ENUM names; - uint32 mapped_count = 0; - TALLOC_CTX *ctx = talloc_init(); - - ZERO_STRUCT(r_l); - ZERO_STRUCT(ref); - ZERO_STRUCT(names); - - /* set up the LSA Lookup SIDs response */ - init_lsa_trans_names(ctx, &ref, &names, num_entries, sid, &mapped_count); - init_reply_lookup_sids(&r_l, &ref, &names, mapped_count); - - /* store the response in the SMB stream */ - if(!lsa_io_r_lookup_sids("", &r_l, rdata, 0)) { - DEBUG(0,("lsa_reply_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS.\n")); - talloc_destroy(ctx); - return False; - } - - talloc_destroy(ctx); - return True; -} /*************************************************************************** api_lsa_open_policy2 @@ -404,24 +35,27 @@ static BOOL lsa_reply_lookup_sids(prs_struct *rdata, DOM_SID2 *sid, int num_entr static BOOL api_lsa_open_policy2(pipes_struct *p) { + LSA_Q_OPEN_POL2 q_u; + LSA_R_OPEN_POL2 r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - LSA_Q_OPEN_POL2 q_o; - - ZERO_STRUCT(q_o); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); /* grab the server, object attributes and desired access flag...*/ - if(!lsa_io_q_open_pol2("", &q_o, data, 0)) { + if(!lsa_io_q_open_pol2("", &q_u, data, 0)) { DEBUG(0,("api_lsa_open_policy2: unable to unmarshall LSA_Q_OPEN_POL2.\n")); return False; } - /* lkclXXXX having decoded it, ignore all fields in the open policy! */ + r_u.status = _lsa_open_policy2(p, &q_u, &r_u); - /* return a 20 byte policy handle */ - if(!lsa_reply_open_policy2(rdata)) + /* store the response in the SMB stream */ + if(!lsa_io_r_open_pol2("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_open_policy2: unable to marshall LSA_R_OPEN_POL2.\n")); return False; + } return True; } @@ -429,141 +63,87 @@ static BOOL api_lsa_open_policy2(pipes_struct *p) /*************************************************************************** api_lsa_open_policy ***************************************************************************/ + static BOOL api_lsa_open_policy(pipes_struct *p) { + LSA_Q_OPEN_POL q_u; + LSA_R_OPEN_POL r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - LSA_Q_OPEN_POL q_o; - - ZERO_STRUCT(q_o); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); /* grab the server, object attributes and desired access flag...*/ - if(!lsa_io_q_open_pol("", &q_o, data, 0)) { + if(!lsa_io_q_open_pol("", &q_u, data, 0)) { DEBUG(0,("api_lsa_open_policy: unable to unmarshall LSA_Q_OPEN_POL.\n")); return False; } - /* lkclXXXX having decoded it, ignore all fields in the open policy! */ + r_u.status = _lsa_open_policy(p, &q_u, &r_u); - /* return a 20 byte policy handle */ - if(!lsa_reply_open_policy(rdata)) + /* store the response in the SMB stream */ + if(!lsa_io_r_open_pol("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_open_policy: unable to marshall LSA_R_OPEN_POL.\n")); return False; + } return True; } /*************************************************************************** -api_lsa_enum_trust_dom + api_lsa_enum_trust_dom ***************************************************************************/ + static BOOL api_lsa_enum_trust_dom(pipes_struct *p) { - LSA_Q_ENUM_TRUST_DOM q_e; + LSA_Q_ENUM_TRUST_DOM q_u; + LSA_R_ENUM_TRUST_DOM r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - ZERO_STRUCT(q_e); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); /* grab the enum trust domain context etc. */ - if(!lsa_io_q_enum_trust_dom("", &q_e, data, 0)) + if(!lsa_io_q_enum_trust_dom("", &q_u, data, 0)) return False; - /* construct reply. return status is always 0x0 */ - lsa_reply_enum_trust_dom(&q_e, rdata, 0, NULL, NULL); + r_u.status = _lsa_enum_trust_dom(p, &q_u, &r_u); + + if(!lsa_io_r_enum_trust_dom("", &r_u, rdata, 0)) + return False; return True; } /*************************************************************************** -api_lsa_query_info + api_lsa_query_info ***************************************************************************/ + static BOOL api_lsa_query_info(pipes_struct *p) { - LSA_Q_QUERY_INFO q_i; - LSA_R_QUERY_INFO r_q; - LSA_INFO_UNION *info = &r_q.dom; - DOM_SID domain_sid; - char *name = NULL; - DOM_SID *sid = NULL; + LSA_Q_QUERY_INFO q_u; + LSA_R_QUERY_INFO r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - ZERO_STRUCT(q_i); - ZERO_STRUCT(r_q); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); /* grab the info class and policy handle */ - if(!lsa_io_q_query("", &q_i, data, 0)) { + if(!lsa_io_q_query("", &q_u, data, 0)) { DEBUG(0,("api_lsa_query_info: failed to unmarshall LSA_Q_QUERY_INFO.\n")); return False; } - switch (q_i.info_class) { - case 0x02: - { - unsigned int i; - /* fake info: We audit everything. ;) */ - info->id2.auditing_enabled = 1; - info->id2.count1 = 7; - info->id2.count2 = 7; - if ((info->id2.auditsettings = (uint32 *)talloc(prs_get_mem_context(rdata),7*sizeof(uint32))) == NULL) - return False; - for (i = 0; i < 7; i++) - info->id2.auditsettings[i] = 3; - break; - } - case 0x03: - switch (lp_server_role()) - { - case ROLE_DOMAIN_PDC: - case ROLE_DOMAIN_BDC: - name = global_myworkgroup; - sid = &global_sam_sid; - break; - case ROLE_DOMAIN_MEMBER: - if (secrets_fetch_domain_sid(global_myworkgroup, - &domain_sid)) - { - name = global_myworkgroup; - sid = &domain_sid; - } - default: - break; - } - init_dom_query(&r_q.dom.id3, name, sid); - break; - case 0x05: - name = global_myname; - sid = &global_sam_sid; - init_dom_query(&r_q.dom.id5, name, sid); - break; - case 0x06: - switch (lp_server_role()) - { - case ROLE_DOMAIN_BDC: - /* - * only a BDC is a backup controller - * of the domain, it controls. - */ - info->id6.server_role = 2; - break; - default: - /* - * any other role is a primary - * of the domain, it controls. - */ - info->id6.server_role = 3; - break; - } - break; - default: - DEBUG(0,("api_lsa_query_info: unknown info level in Lsa Query: %d\n", q_i.info_class)); - r_q.status = NT_STATUS_INVALID_INFO_CLASS; - break; - } + r_u.status = _lsa_query_info(p, &q_u, &r_u); - /* construct reply. return status is always 0x0 */ - if(!lsa_reply_query_info(&q_i, rdata, &r_q)) + /* store the response in the SMB stream */ + if(!lsa_io_r_query("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_query_info: failed to marshall LSA_R_QUERY_INFO.\n")); return False; + } return True; } @@ -574,47 +154,28 @@ static BOOL api_lsa_query_info(pipes_struct *p) static BOOL api_lsa_lookup_sids(pipes_struct *p) { - LSA_Q_LOOKUP_SIDS q_l; + LSA_Q_LOOKUP_SIDS q_u; + LSA_R_LOOKUP_SIDS r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - BOOL result = True; - ZERO_STRUCT(q_l); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_sids("", &q_l, data, 0)) { + if(!lsa_io_q_lookup_sids("", &q_u, data, 0)) { DEBUG(0,("api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS.\n")); - result = False; - } - - /* construct reply. return status is always 0x0 */ - if(!lsa_reply_lookup_sids(rdata, q_l.sids.sid, q_l.sids.num_entries)) { - result = False; + return False; } - return result; -} - -/*************************************************************************** -lsa_reply_lookup_names - ***************************************************************************/ - -static uint32 _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_NAMES *r_u) -{ - UNISTR2 *names = q_u->uni_name; - int num_entries = q_u->num_entries; - DOM_R_REF ref; - DOM_RID2 rids[MAX_LOOKUP_SIDS]; - uint32 mapped_count = 0; - - ZERO_STRUCT(ref); - ZERO_ARRAY(rids); + r_u.status = _lsa_lookup_sids(p, &q_u, &r_u); - /* set up the LSA Lookup RIDs response */ - init_lsa_rid2s(&ref, rids, num_entries, names, &mapped_count); - init_reply_lookup_names(r_u, &ref, num_entries, rids, mapped_count); + if(!lsa_io_r_lookup_sids("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS.\n")); + return False; + } - return r_u->status; + return True; } /*************************************************************************** @@ -648,15 +209,6 @@ static BOOL api_lsa_lookup_names(pipes_struct *p) return True; } -/*************************************************************************** - _lsa_close. Also weird - needs to check if lsa handle is correct. JRA. - ***************************************************************************/ - -static uint32 _lsa_close(pipes_struct *p, LSA_Q_CLOSE *q_u, LSA_R_CLOSE *r_u) -{ - return NT_STATUS_NO_PROBLEMO; -} - /*************************************************************************** api_lsa_close. ***************************************************************************/ @@ -687,15 +239,6 @@ static BOOL api_lsa_close(pipes_struct *p) return True; } -/*************************************************************************** - "No more secrets Marty...." :-). - ***************************************************************************/ - -static uint32 _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SECRET *r_u) -{ - return NT_STATUS_OBJECT_NAME_NOT_FOUND; -} - /*************************************************************************** api_lsa_open_secret. ***************************************************************************/ diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 6f7cb0f7b3..14d37e9948 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1,3 +1,4 @@ +#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -473,3 +474,4 @@ uint32 _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SECR { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } +#undef OLD_NTDOMAIN -- cgit From 95731132dc3cb78a41fc83c68af0f0168f07f246 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 26 Feb 2001 20:06:25 +0000 Subject: Split wks pipe into interface and implementation modules. Jeremy. (This used to be commit 6a16b3850fdc4d6750ef2046f1db934f1ef92f17) --- source3/rpc_server/srv_wkssvc.c | 64 ++++++------------------------- source3/rpc_server/srv_wkssvc_nt.c | 77 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 53 deletions(-) create mode 100644 source3/rpc_server/srv_wkssvc_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index d1e0c8e8eb..e648c0f122 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -22,76 +22,34 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* This is the interface to the wks pipe. */ + #include "includes.h" extern int DEBUGLEVEL; -extern pstring global_myname; - -/******************************************************************* - create_wks_info_100 - ********************************************************************/ -static void create_wks_info_100(WKS_INFO_100 *inf) -{ - pstring my_name; - pstring domain; - - DEBUG(5,("create_wks_info_100: %d\n", __LINE__)); - - pstrcpy (my_name, global_myname); - strupper(my_name); - - pstrcpy (domain, lp_workgroup()); - strupper(domain); - - init_wks_info_100(inf, - 0x000001f4, /* platform id info */ - lp_major_announce_version(), - lp_minor_announce_version(), - my_name, unix_to_dos(domain,False)); -} - -/******************************************************************* - wks_reply_query_info - - only supports info level 100 at the moment. - - ********************************************************************/ -static BOOL wks_reply_query_info(WKS_Q_QUERY_INFO *q_u, - prs_struct *rdata, - int status) -{ - WKS_R_QUERY_INFO r_u; - WKS_INFO_100 wks100; - - DEBUG(5,("wks_query_info: %d\n", __LINE__)); - - create_wks_info_100(&wks100); - init_wks_r_query_info(&r_u, q_u->switch_value, &wks100, status); - - /* store the response in the SMB stream */ - if(!wks_io_r_query_info("", &r_u, rdata, 0)) - return False; - - DEBUG(5,("wks_query_info: %d\n", __LINE__)); - - return True; -} /******************************************************************* api_wks_query_info ********************************************************************/ + static BOOL api_wks_query_info(pipes_struct *p) { WKS_Q_QUERY_INFO q_u; + WKS_R_QUERY_INFO r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + /* grab the net share enum */ if(!wks_io_q_query_info("", &q_u, data, 0)) return False; - /* construct reply. always indicate success */ - if(!wks_reply_query_info(&q_u, rdata, 0x0)) + r_u.status = _wks_query_info(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!wks_io_r_query_info("", &r_u, rdata, 0)) return False; return True; diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c new file mode 100644 index 0000000000..81d3e1ef8f --- /dev/null +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -0,0 +1,77 @@ +#define OLD_NTDOMAIN 1 +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997. + * Copyright (C) Jeremy Allison 2001. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* This is the implementation of the wks interface. */ + +#include "includes.h" + +extern int DEBUGLEVEL; +extern pstring global_myname; + +/******************************************************************* + create_wks_info_100 + ********************************************************************/ + +static void create_wks_info_100(WKS_INFO_100 *inf) +{ + pstring my_name; + pstring domain; + + DEBUG(5,("create_wks_info_100: %d\n", __LINE__)); + + pstrcpy (my_name, global_myname); + strupper(my_name); + + pstrcpy (domain, lp_workgroup()); + strupper(domain); + + init_wks_info_100(inf, + 0x000001f4, /* platform id info */ + lp_major_announce_version(), + lp_minor_announce_version(), + my_name, unix_to_dos(domain,False)); +} + +/******************************************************************* + wks_reply_query_info + + only supports info level 100 at the moment. + + ********************************************************************/ + +uint32 _wks_query_info(pipes_struct *p, WKS_Q_QUERY_INFO *q_u, WKS_R_QUERY_INFO *r_u) +{ + WKS_INFO_100 wks100; + + DEBUG(5,("_wks_query_info: %d\n", __LINE__)); + + create_wks_info_100(&wks100); + init_wks_r_query_info(r_u, q_u->switch_value, &wks100, NT_STATUS_NOPROBLEMO); + + DEBUG(5,("_wks_query_info: %d\n", __LINE__)); + + return r_u->status; +} +#undef OLD_NTDOMAIN -- cgit From de187df10c3d34ef87b3618fc8fc0e14b466b2f8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 26 Feb 2001 22:05:41 +0000 Subject: Split srvsvc pipe into interface and implementation modules. Jeremy. (This used to be commit e14c88ddf466f17a710724fb4fc273d37a244d77) --- source3/rpc_server/srv_srvsvc.c | 1073 ++++----------------------------------- 1 file changed, 95 insertions(+), 978 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 52ae54fd94..b530d66092 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -6,6 +6,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. + * Copyright (C) Jeremy Allison 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,1010 +23,149 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* This is the interface to the srvsvc pipe. */ + #include "includes.h" extern int DEBUGLEVEL; -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) -{ - int len_net_name; - pstring net_name; - pstring remark; - uint32 type; - - pstrcpy(net_name, lp_servicename(snum)); - pstrcpy(remark, lp_comment(snum)); - pstring_sub(remark,"%S",lp_servicename(snum)); - len_net_name = strlen(net_name); - - /* work out the share type */ - type = STYPE_DISKTREE; - - if (lp_print_ok(snum)) - type = STYPE_PRINTQ; - if (strequal("IPC$", net_name)) - type = STYPE_IPC; - if (net_name[len_net_name] == '$') - type |= STYPE_HIDDEN; - - init_srv_share_info1(&sh1->info_1, net_name, type, remark); - init_srv_share_info1_str(&sh1->info_1_str, net_name, remark); -} - -/******************************************************************* - Fill in a share info level 2 structure. - ********************************************************************/ - -static void init_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, int snum) -{ - int len_net_name; - pstring net_name; - pstring remark; - pstring path; - pstring passwd; - uint32 type; - - pstrcpy(net_name, lp_servicename(snum)); - pstrcpy(remark, lp_comment(snum)); - pstring_sub(remark,"%S",lp_servicename(snum)); - pstrcpy(path, lp_pathname(snum)); - pstrcpy(passwd, ""); - len_net_name = strlen(net_name); - - /* work out the share type */ - type = STYPE_DISKTREE; - - if (lp_print_ok(snum)) - type = STYPE_PRINTQ; - if (strequal("IPC$", net_name)) - type = STYPE_IPC; - if (net_name[len_net_name] == '$') - type |= STYPE_HIDDEN; - - init_srv_share_info2(&sh2->info_2, net_name, type, remark, 0, 0xffffffff, 1, path, passwd); - init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); -} - -/*************************************************************************** - Fill in a share info level 1005 structure. - ***************************************************************************/ -static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum) -{ - sh1005->dfs_root_flag = 0; - -#ifdef WITH_MSDFS - if(lp_host_msdfs() && lp_msdfs_root(snum)) - sh1005->dfs_root_flag = 3; -#endif - -} - -/******************************************************************* - Fill in a share info structure. - ********************************************************************/ - -static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr, - uint32 info_level, uint32 *resume_hnd, uint32 *total_entries) -{ - int num_entries = 0; - int num_services = lp_numservices(); - int snum; - - DEBUG(5,("init_srv_share_info_ctr\n")); - - ZERO_STRUCTPN(ctr); - - ctr->info_level = ctr->switch_value = info_level; - *resume_hnd = 0; - - /* Count the number of entries. */ - for (snum = 0; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum)) - num_entries++; - } - - *total_entries = num_entries; - ctr->num_entries2 = ctr->num_entries = num_entries; - ctr->ptr_share_info = ctr->ptr_entries = 1; - - if (!num_entries) - return True; - - switch (info_level) { - case 1: - { - SRV_SHARE_INFO_1 *info1; - int i = 0; - - info1 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1)); - - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum)) { - init_srv_share_info_1(&info1[i++], snum); - } - } - - ctr->share.info1 = info1; - break; - } - - case 2: - { - SRV_SHARE_INFO_2 *info2; - int i = 0; - - info2 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_2)); - - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum)) { - init_srv_share_info_2(&info2[i++], snum); - } - } - - ctr->share.info2 = info2; - break; - } - - default: - DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level)); - return False; - } - - return True; -} - -/******************************************************************* - 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, - uint32 info_level, uint32 resume_hnd) -{ - DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__)); - - if (init_srv_share_info_ctr(ctx, &r_n->ctr, info_level, - &resume_hnd, &r_n->total_entries)) { - r_n->status = 0x0; - } else { - r_n->status = NT_STATUS_INVALID_INFO_CLASS; - } - - init_enum_hnd(&r_n->enum_hnd, resume_hnd); -} - -/******************************************************************* - Net share enum. -********************************************************************/ - -static BOOL srv_reply_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n, - prs_struct *rdata) -{ - SRV_R_NET_SHARE_ENUM r_n; - BOOL ret; - TALLOC_CTX *ctx = talloc_init(); - - DEBUG(5,("srv_net_share_enum: %d\n", __LINE__)); - - if (!ctx) { - DEBUG(0,("srv_reply_net_share_enum: talloc_init failed.\n")); - return False; - } - - /* Create the list of shares for the response. */ - init_srv_r_net_share_enum(ctx, &r_n, - q_n->ctr.info_level, - get_enum_hnd(&q_n->enum_hnd)); - - /* store the response in the SMB stream */ - ret = srv_io_r_net_share_enum("", &r_n, rdata, 0); - - DEBUG(5,("srv_net_share_enum: %d\n", __LINE__)); - talloc_destroy(ctx); - - return ret; -} - -/******************************************************************* - Inits a SRV_R_NET_SHARE_GET_INFO structure. -********************************************************************/ - -static void init_srv_r_net_share_get_info(SRV_R_NET_SHARE_GET_INFO *r_n, - char *share_name, uint32 info_level) -{ - uint32 status = 0x0; - int snum; - - DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__)); - - r_n->switch_value = info_level; - - snum = find_service(share_name); - - if (snum >= 0) { - switch (info_level) { - case 1: - init_srv_share_info_1(&r_n->share.info1, snum); - break; - case 2: - init_srv_share_info_2(&r_n->share.info2, snum); - break; - case 1005: - init_srv_share_info_1005(&r_n->share.info1005, snum); - break; - default: - DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level)); - status = NT_STATUS_INVALID_INFO_CLASS; - break; - } - } else { - status = NT_STATUS_BAD_NETWORK_NAME; - } - - r_n->ptr_share_ctr = (status == 0x0) ? 1 : 0; - r_n->status = status; -} - -/******************************************************************* - Net share get info. -********************************************************************/ - -static BOOL srv_reply_net_share_get_info(SRV_Q_NET_SHARE_GET_INFO *q_n, - prs_struct *rdata) -{ - SRV_R_NET_SHARE_GET_INFO r_n; - char *share_name; - BOOL ret; - - DEBUG(5,("srv_net_share_get_info: %d\n", __LINE__)); - - /* Create the list of shares for the response. */ - share_name = dos_unistr2_to_str(&q_n->uni_share_name); - init_srv_r_net_share_get_info(&r_n, share_name, q_n->info_level); - - /* store the response in the SMB stream */ - ret = srv_io_r_net_share_get_info("", &r_n, rdata, 0); - - DEBUG(5,("srv_net_share_get_info: %d\n", __LINE__)); - - return ret; -} - -/******************************************************************* - fill in a sess info level 1 structure. - - this function breaks the rule that i'd like to be in place, namely - it doesn't receive its data as arguments: it has to call lp_xxxx() - functions itself. yuck. - - ********************************************************************/ -static void init_srv_sess_0_info(SESS_INFO_0 *se0, SESS_INFO_0_STR *str0, - char *name) -{ - init_srv_sess_info0 (se0 , name); - init_srv_sess_info0_str(str0, name); -} - -/******************************************************************* - fill in a sess info level 0 structure. - - this function breaks the rule that i'd like to be in place, namely - it doesn't receive its data as arguments: it has to call lp_xxxx() - functions itself. yuck. - - ********************************************************************/ -static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot) -{ - uint32 num_entries = 0; - (*stot) = 1; - - if (ss0 == NULL) - { - (*snum) = 0; - return; - } - - DEBUG(5,("init_srv_sess_0_ss0\n")); - - if (snum) - { - for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) - { - init_srv_sess_0_info(&(ss0->info_0 [num_entries]), - &(ss0->info_0_str[num_entries]), "MACHINE"); - - /* move on to creating next session */ - /* move on to creating next sess */ - num_entries++; - } - - ss0->num_entries_read = num_entries; - ss0->ptr_sess_info = num_entries > 0 ? 1 : 0; - ss0->num_entries_read2 = num_entries; - - if ((*snum) >= (*stot)) - { - (*snum) = 0; - } - } - else - { - ss0->num_entries_read = 0; - ss0->ptr_sess_info = 0; - ss0->num_entries_read2 = 0; - } -} - -/******************************************************************* - fill in a sess info level 1 structure. - - this function breaks the rule that i'd like to be in place, namely - it doesn't receive its data as arguments: it has to call lp_xxxx() - functions itself. yuck. - - ********************************************************************/ -static void init_srv_sess_1_info(SESS_INFO_1 *se1, SESS_INFO_1_STR *str1, - char *name, char *user, - uint32 num_opens, - uint32 open_time, uint32 idle_time, - uint32 usr_flgs) -{ - init_srv_sess_info1 (se1 , name, user, num_opens, open_time, idle_time, usr_flgs); - init_srv_sess_info1_str(str1, name, user); -} /******************************************************************* - fill in a sess info level 1 structure. - - this function breaks the rule that i'd like to be in place, namely - it doesn't receive its data as arguments: it has to call lp_xxxx() - functions itself. yuck. - - ********************************************************************/ -static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot) -{ - uint32 num_entries = 0; - (*stot) = 1; - - if (ss1 == NULL) - { - (*snum) = 0; - return; - } - - DEBUG(5,("init_srv_sess_1_ss1\n")); - - if (snum) - { - for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) - { - init_srv_sess_1_info(&(ss1->info_1 [num_entries]), - &(ss1->info_1_str[num_entries]), - "MACHINE", "dummy_user", 1, 10, 5, 0); - - /* move on to creating next session */ - /* move on to creating next sess */ - num_entries++; - } - - ss1->num_entries_read = num_entries; - ss1->ptr_sess_info = num_entries > 0 ? 1 : 0; - ss1->num_entries_read2 = num_entries; - - if ((*snum) >= (*stot)) - { - (*snum) = 0; - } - } - else - { - ss1->num_entries_read = 0; - ss1->ptr_sess_info = 0; - ss1->num_entries_read2 = 0; - - (*stot) = 0; - } -} - -/******************************************************************* - makes a SRV_R_NET_SESS_ENUM structure. -********************************************************************/ -static uint32 init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, - int switch_value, uint32 *resume_hnd, uint32 *total_entries) -{ - uint32 status = 0x0; - DEBUG(5,("init_srv_sess_info_ctr: %d\n", __LINE__)); - - ctr->switch_value = switch_value; - - switch (switch_value) - { - case 0: - { - init_srv_sess_info_0(&(ctr->sess.info0), resume_hnd, total_entries); - ctr->ptr_sess_ctr = 1; - break; - } - case 1: - { - init_srv_sess_info_1(&(ctr->sess.info1), resume_hnd, total_entries); - ctr->ptr_sess_ctr = 1; - break; - } - default: - { - DEBUG(5,("init_srv_sess_info_ctr: unsupported switch value %d\n", - switch_value)); - (*resume_hnd) = 0; - (*total_entries) = 0; - ctr->ptr_sess_ctr = 0; - status = NT_STATUS_INVALID_INFO_CLASS; - break; - } - } - - return status; -} - -/******************************************************************* - makes a SRV_R_NET_SESS_ENUM structure. + api_srv_net_srv_get_info ********************************************************************/ -static void init_srv_r_net_sess_enum(SRV_R_NET_SESS_ENUM *r_n, - uint32 resume_hnd, int sess_level, int switch_value) -{ - DEBUG(5,("init_srv_r_net_sess_enum: %d\n", __LINE__)); - - r_n->sess_level = sess_level; - if (sess_level == -1) - { - r_n->status = NT_STATUS_INVALID_INFO_CLASS; - } - else - { - r_n->status = init_srv_sess_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); - } - if (r_n->status != 0x0) - { - resume_hnd = 0; - } - init_enum_hnd(&(r_n->enum_hnd), resume_hnd); -} - -/******************************************************************* -net sess enum -********************************************************************/ -static void srv_reply_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n, - prs_struct *rdata) -{ - SRV_R_NET_SESS_ENUM r_n; - SRV_SESS_INFO_CTR ctr; - - r_n.ctr = &ctr; - - DEBUG(5,("srv_net_sess_enum: %d\n", __LINE__)); - - /* set up the */ - init_srv_r_net_sess_enum(&r_n, - get_enum_hnd(&q_n->enum_hnd), - q_n->sess_level, - q_n->ctr->switch_value); - - /* store the response in the SMB stream */ - srv_io_r_net_sess_enum("", &r_n, rdata, 0); - - DEBUG(5,("srv_net_sess_enum: %d\n", __LINE__)); -} - -/******************************************************************* - fill in a conn info level 0 structure. - - this function breaks the rule that i'd like to be in place, namely - it doesn't receive its data as arguments: it has to call lp_xxxx() - functions itself. yuck. - - ********************************************************************/ -static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *stot) -{ - uint32 num_entries = 0; - (*stot) = 1; - - if (ss0 == NULL) - { - (*snum) = 0; - return; - } - - DEBUG(5,("init_srv_conn_0_ss0\n")); - - if (snum) - { - for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) - { - init_srv_conn_info0(&(ss0->info_0 [num_entries]), (*stot)); - - /* move on to creating next connection */ - /* move on to creating next conn */ - num_entries++; - } - - ss0->num_entries_read = num_entries; - ss0->ptr_conn_info = num_entries > 0 ? 1 : 0; - ss0->num_entries_read2 = num_entries; - - - if ((*snum) >= (*stot)) - { - (*snum) = 0; - } - } - else - { - ss0->num_entries_read = 0; - ss0->ptr_conn_info = 0; - ss0->num_entries_read2 = 0; - - (*stot) = 0; - } -} - -/******************************************************************* - fill in a conn info level 1 structure. - - this function breaks the rule that i'd like to be in place, namely - it doesn't receive its data as arguments: it has to call lp_xxxx() - functions itself. yuck. - - ********************************************************************/ -static void init_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1, - uint32 id, uint32 type, - uint32 num_opens, uint32 num_users, uint32 open_time, - char *usr_name, char *net_name) -{ - init_srv_conn_info1 (se1 , id, type, num_opens, num_users, open_time, usr_name, net_name); - init_srv_conn_info1_str(str1, usr_name, net_name); -} - -/******************************************************************* - fill in a conn info level 1 structure. - - this function breaks the rule that i'd like to be in place, namely - it doesn't receive its data as arguments: it has to call lp_xxxx() - functions itself. yuck. - - ********************************************************************/ -static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *stot) -{ - uint32 num_entries = 0; - (*stot) = 1; - - if (ss1 == NULL) - { - (*snum) = 0; - return; - } - - DEBUG(5,("init_srv_conn_1_ss1\n")); - - if (snum) - { - for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) - { - init_srv_conn_1_info(&(ss1->info_1 [num_entries]), - &(ss1->info_1_str[num_entries]), - (*stot), 0x3, 1, 1, 3,"dummy_user", "IPC$"); - - /* move on to creating next connection */ - /* move on to creating next conn */ - num_entries++; - } - - ss1->num_entries_read = num_entries; - ss1->ptr_conn_info = num_entries > 0 ? 1 : 0; - ss1->num_entries_read2 = num_entries; - - - if ((*snum) >= (*stot)) - { - (*snum) = 0; - } - } - else - { - ss1->num_entries_read = 0; - ss1->ptr_conn_info = 0; - ss1->num_entries_read2 = 0; - - (*stot) = 0; - } -} - -/******************************************************************* - makes a SRV_R_NET_CONN_ENUM structure. -********************************************************************/ -static uint32 init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, - int switch_value, uint32 *resume_hnd, uint32 *total_entries) -{ - uint32 status = 0x0; - DEBUG(5,("init_srv_conn_info_ctr: %d\n", __LINE__)); - - ctr->switch_value = switch_value; - - switch (switch_value) - { - case 0: - { - init_srv_conn_info_0(&(ctr->conn.info0), resume_hnd, total_entries); - ctr->ptr_conn_ctr = 1; - break; - } - case 1: - { - init_srv_conn_info_1(&(ctr->conn.info1), resume_hnd, total_entries); - ctr->ptr_conn_ctr = 1; - break; - } - default: - { - DEBUG(5,("init_srv_conn_info_ctr: unsupported switch value %d\n", - switch_value)); - (*resume_hnd = 0); - (*total_entries) = 0; - ctr->ptr_conn_ctr = 0; - status = NT_STATUS_INVALID_INFO_CLASS; - break; - } - } - - return status; -} - -/******************************************************************* - makes a SRV_R_NET_CONN_ENUM structure. -********************************************************************/ -static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, - uint32 resume_hnd, int conn_level, int switch_value) -{ - DEBUG(5,("init_srv_r_net_conn_enum: %d\n", __LINE__)); - - r_n->conn_level = conn_level; - if (conn_level == -1) - { - r_n->status = NT_STATUS_INVALID_INFO_CLASS; - } - else - { - r_n->status = init_srv_conn_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); - } - if (r_n->status != 0x0) - { - resume_hnd = 0; - } - init_enum_hnd(&(r_n->enum_hnd), resume_hnd); -} - -/******************************************************************* -net conn enum -********************************************************************/ -static void srv_reply_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n, - prs_struct *rdata) -{ - SRV_R_NET_CONN_ENUM r_n; - SRV_CONN_INFO_CTR ctr; - - r_n.ctr = &ctr; - - DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); - - /* set up the */ - init_srv_r_net_conn_enum(&r_n, - get_enum_hnd(&q_n->enum_hnd), - q_n->conn_level, - q_n->ctr->switch_value); - - /* store the response in the SMB stream */ - srv_io_r_net_conn_enum("", &r_n, rdata, 0); - - DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); -} - -/******************************************************************* - fill in a file info level 3 structure. - ********************************************************************/ -static void init_srv_file_3_info(FILE_INFO_3 *fl3, FILE_INFO_3_STR *str3, - uint32 fnum, uint32 perms, uint32 num_locks, - char *path_name, char *user_name) -{ - init_srv_file_info3 (fl3 , fnum, perms, num_locks, path_name, user_name); - init_srv_file_info3_str(str3, path_name, user_name); -} - -/******************************************************************* - fill in a file info level 3 structure. - - this function breaks the rule that i'd like to be in place, namely - it doesn't receive its data as arguments: it has to call lp_xxxx() - functions itself. yuck. - - ********************************************************************/ -static void init_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *ftot) -{ - uint32 num_entries = 0; - (*ftot) = 1; - - if (fl3 == NULL) - { - (*fnum) = 0; - return; - } - - DEBUG(5,("init_srv_file_3_fl3\n")); - - for (; (*fnum) < (*ftot) && num_entries < MAX_FILE_ENTRIES; (*fnum)++) - { - init_srv_file_3_info(&(fl3->info_3 [num_entries]), - &(fl3->info_3_str[num_entries]), - (*fnum), 0x35, 0, "\\PIPE\\samr", "dummy user"); - - /* move on to creating next file */ - num_entries++; - } - - fl3->num_entries_read = num_entries; - fl3->ptr_file_info = num_entries > 0 ? 1 : 0; - fl3->num_entries_read2 = num_entries; - - if ((*fnum) >= (*ftot)) - { - (*fnum) = 0; - } -} - -/******************************************************************* - makes a SRV_R_NET_FILE_ENUM structure. -********************************************************************/ -static uint32 init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, - int switch_value, uint32 *resume_hnd, uint32 *total_entries) -{ - uint32 status = 0x0; - DEBUG(5,("init_srv_file_info_ctr: %d\n", __LINE__)); - - ctr->switch_value = switch_value; - - switch (switch_value) - { - case 3: - { - init_srv_file_info_3(&(ctr->file.info3), resume_hnd, total_entries); - ctr->ptr_file_ctr = 1; - break; - } - default: - { - DEBUG(5,("init_srv_file_info_ctr: unsupported switch value %d\n", - switch_value)); - (*resume_hnd = 0); - (*total_entries) = 0; - ctr->ptr_file_ctr = 0; - status = NT_STATUS_INVALID_INFO_CLASS; - break; - } - } - - return status; -} - -/******************************************************************* - makes a SRV_R_NET_FILE_ENUM structure. -********************************************************************/ -static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n, - uint32 resume_hnd, int file_level, int switch_value) -{ - DEBUG(5,("init_srv_r_net_file_enum: %d\n", __LINE__)); - - r_n->file_level = file_level; - if (file_level == 0) - { - r_n->status = NT_STATUS_INVALID_INFO_CLASS; - } - else - { - r_n->status = init_srv_file_info_ctr(r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries)); - } - if (r_n->status != 0x0) - { - resume_hnd = 0; - } - init_enum_hnd(&(r_n->enum_hnd), resume_hnd); -} - -/******************************************************************* -net file enum -********************************************************************/ -static void srv_reply_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n, - prs_struct *rdata) -{ - SRV_R_NET_FILE_ENUM r_n; - SRV_FILE_INFO_CTR ctr; - - r_n.ctr = &ctr; - - DEBUG(5,("srv_net_file_enum: %d\n", __LINE__)); - - /* set up the */ - init_srv_r_net_file_enum(&r_n, - get_enum_hnd(&q_n->enum_hnd), - q_n->file_level, - q_n->ctr->switch_value); - - /* store the response in the SMB stream */ - srv_io_r_net_file_enum("", &r_n, rdata, 0); - - DEBUG(5,("srv_net_file_enum: %d\n", __LINE__)); -} - -/******************************************************************* -net server get info -********************************************************************/ - -static void srv_reply_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *q_n, - prs_struct *rdata) -{ - SRV_R_NET_SRV_GET_INFO r_n; - uint32 status = 0x0; - SRV_INFO_CTR ctr; - - - DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); - - switch (q_n->switch_value) - { - case 102: - { - init_srv_info_102(&ctr.srv.sv102, - 500, global_myname, - string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), - lp_major_announce_version(), lp_minor_announce_version(), - lp_default_server_announce(), - 0xffffffff, /* users */ - 0xf, /* disc */ - 0, /* hidden */ - 240, /* announce */ - 3000, /* announce delta */ - 100000, /* licenses */ - "c:\\"); /* user path */ - break; - } - case 101: - { - init_srv_info_101(&ctr.srv.sv101, - 500, global_myname, - lp_major_announce_version(), lp_minor_announce_version(), - lp_default_server_announce(), - string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); - break; - } - default: - { - status = NT_STATUS_INVALID_INFO_CLASS; - break; - } - } - - /* set up the net server get info structure */ - init_srv_r_net_srv_get_info(&r_n, q_n->switch_value, &ctr, status); - - /* store the response in the SMB stream */ - srv_io_r_net_srv_get_info("", &r_n, rdata, 0); - - DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); -} - -/******************************************************************* -********************************************************************/ static BOOL api_srv_net_srv_get_info(pipes_struct *p) { - SRV_Q_NET_SRV_GET_INFO q_n; + SRV_Q_NET_SRV_GET_INFO q_u; + SRV_R_NET_SRV_GET_INFO r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + /* grab the net server get info */ - srv_io_q_net_srv_get_info("", &q_n, data, 0); + if (!srv_io_q_net_srv_get_info("", &q_u, data, 0)) + return False; - /* construct reply. always indicate success */ - srv_reply_net_srv_get_info(&q_n, rdata); + r_u.status = _srv_net_srv_get_info(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if (!srv_io_r_net_srv_get_info("", &r_u, rdata, 0)) + return False; return True; } - /******************************************************************* + api_srv_net_file_enum ********************************************************************/ + static BOOL api_srv_net_file_enum(pipes_struct *p) { - SRV_Q_NET_FILE_ENUM q_n; - SRV_FILE_INFO_CTR ctr; + SRV_Q_NET_FILE_ENUM q_u; + SRV_R_NET_FILE_ENUM r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - q_n.ctr = &ctr; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); /* grab the net file enum */ - srv_io_q_net_file_enum("", &q_n, data, 0); + if (!srv_io_q_net_file_enum("", &q_u, data, 0)) + return False; - /* construct reply. always indicate success */ - srv_reply_net_file_enum(&q_n, rdata); + r_u.status = _srv_net_file_enum(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!srv_io_r_net_file_enum("", &r_u, rdata, 0)) + return False; return True; } - /******************************************************************* + api_srv_net_conn_enum ********************************************************************/ + static BOOL api_srv_net_conn_enum(pipes_struct *p) { - SRV_Q_NET_CONN_ENUM q_n; - SRV_CONN_INFO_CTR ctr; + SRV_Q_NET_CONN_ENUM q_u; + SRV_R_NET_CONN_ENUM r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - q_n.ctr = &ctr; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); /* grab the net server get enum */ - srv_io_q_net_conn_enum("", &q_n, data, 0); + if (!srv_io_q_net_conn_enum("", &q_u, data, 0)) + return False; - /* construct reply. always indicate success */ - srv_reply_net_conn_enum(&q_n, rdata); + r_u.status = _srv_net_conn_enum(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if (!srv_io_r_net_conn_enum("", &r_u, rdata, 0)) + return False; return True; } - /******************************************************************* + Enumerate sessions. ********************************************************************/ + static BOOL api_srv_net_sess_enum(pipes_struct *p) { - SRV_Q_NET_SESS_ENUM q_n; - SRV_SESS_INFO_CTR ctr; + SRV_Q_NET_SESS_ENUM q_u; + SRV_R_NET_SESS_ENUM r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - q_n.ctr = &ctr; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); /* grab the net server get enum */ - srv_io_q_net_sess_enum("", &q_n, data, 0); + if (!srv_io_q_net_sess_enum("", &q_u, data, 0)) + return False; /* construct reply. always indicate success */ - srv_reply_net_sess_enum(&q_n, rdata); + r_u.status = _srv_net_sess_enum(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if (!srv_io_r_net_sess_enum("", &r_u, rdata, 0)) + return False; return True; } - /******************************************************************* RPC to enumerate shares. ********************************************************************/ static BOOL api_srv_net_share_enum(pipes_struct *p) { - SRV_Q_NET_SHARE_ENUM q_n; - BOOL ret; + SRV_Q_NET_SHARE_ENUM q_u; + SRV_R_NET_SHARE_ENUM r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + /* Unmarshall the net server get enum. */ - if(!srv_io_q_net_share_enum("", &q_n, data, 0)) { + if(!srv_io_q_net_share_enum("", &q_u, data, 0)) { DEBUG(0,("api_srv_net_share_enum: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n")); return False; } - ret = srv_reply_net_share_enum(&q_n, rdata); + r_u.status = _srv_net_share_enum(p, &q_u, &r_u); - return ret; + if (!srv_io_r_net_share_enum("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_enum: Failed to marshall SRV_R_NET_SHARE_ENUM.\n")); + return False; + } + + return True; } /******************************************************************* @@ -1034,84 +174,61 @@ static BOOL api_srv_net_share_enum(pipes_struct *p) static BOOL api_srv_net_share_get_info(pipes_struct *p) { - SRV_Q_NET_SHARE_GET_INFO q_n; - BOOL ret; + SRV_Q_NET_SHARE_GET_INFO q_u; + SRV_R_NET_SHARE_GET_INFO r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + /* Unmarshall the net server get info. */ - if(!srv_io_q_net_share_get_info("", &q_n, data, 0)) { + if(!srv_io_q_net_share_get_info("", &q_u, data, 0)) { DEBUG(0,("api_srv_net_share_get_info: Failed to unmarshall SRV_Q_NET_SHARE_GET_INFO.\n")); return False; } - ret = srv_reply_net_share_get_info(&q_n, rdata); + r_u.status = _srv_net_share_get_info(p, &q_u, &r_u); - return ret; -} - -/******************************************************************* -time of day -********************************************************************/ -static BOOL srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n, - prs_struct *rdata) -{ - SRV_R_NET_REMOTE_TOD r_n; - TIME_OF_DAY_INFO tod; - struct tm *t; - time_t unixdate = time(NULL); - - r_n.tod = &tod; - r_n.ptr_srv_tod = 0x1; - r_n.status = 0x0; - - DEBUG(5,("srv_reply_net_remote_tod: %d\n", __LINE__)); - - t = gmtime(&unixdate); - - /* set up the */ - init_time_of_day_info(&tod, - unixdate, - 0, - t->tm_hour, - t->tm_min, - t->tm_sec, - 0, - TimeDiff(unixdate)/60, - 10000, - t->tm_mday, - t->tm_mon + 1, - 1900+t->tm_year, - t->tm_wday); - - /* store the response in the SMB stream */ - srv_io_r_net_remote_tod("", &r_n, rdata, 0); - - DEBUG(5,("srv_reply_net_remote_tod: %d\n", __LINE__)); + if(!srv_io_r_net_share_get_info("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_get_info: Failed to marshall SRV_R_NET_SHARE_GET_INFO.\n")); + return False; + } return True; } + /******************************************************************* + api_srv_net_remote_tod ********************************************************************/ + static BOOL api_srv_net_remote_tod(pipes_struct *p) { - SRV_Q_NET_REMOTE_TOD q_n; + SRV_Q_NET_REMOTE_TOD q_u; + SRV_R_NET_REMOTE_TOD r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + /* grab the net server get enum */ - srv_io_q_net_remote_tod("", &q_n, data, 0); + if(!srv_io_q_net_remote_tod("", &q_u, data, 0)) + return False; - /* construct reply. always indicate success */ - srv_reply_net_remote_tod(&q_n, rdata); + r_u.status = _srv_net_remote_tod(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!srv_io_r_net_remote_tod("", &r_u, rdata, 0)) + return False; return True; } - /******************************************************************* \PIPE\srvsvc commands ********************************************************************/ + struct api_struct api_srv_cmds[] = { { "SRV_NETCONNENUM" , SRV_NETCONNENUM , api_srv_net_conn_enum }, -- cgit From d4a28325f1aa46dccdc9c16f68521284b0983d90 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Feb 2001 00:32:11 +0000 Subject: Implementation module for netlog pipe. Can't be easily integrated into HEAD right now due to passdb changes - placeholder added. Jeremy. (This used to be commit eb88512cff67200f95213db5c1340ceb448af57c) --- source3/rpc_server/srv_netlog_nt.c | 663 +++++++++++++++++++++++++++++++++++++ 1 file changed, 663 insertions(+) create mode 100644 source3/rpc_server/srv_netlog_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c new file mode 100644 index 0000000000..151c72499a --- /dev/null +++ b/source3/rpc_server/srv_netlog_nt.c @@ -0,0 +1,663 @@ +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997. + * Copyright (C) Jeremy Allison 1998-2001. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* This is the implementation of the netlogon pipe. */ + +#include "includes.h" + +extern int DEBUGLEVEL; + +extern BOOL sam_logon_in_ssb; +extern pstring samlogon_user; +extern pstring global_myname; +extern DOM_SID global_sam_sid; + +/************************************************************************* + init_net_r_req_chal: + *************************************************************************/ + +static void init_net_r_req_chal(NET_R_REQ_CHAL *r_c, + DOM_CHAL *srv_chal, int status) +{ + DEBUG(6,("init_net_r_req_chal: %d\n", __LINE__)); + memcpy(r_c->srv_chal.data, srv_chal->data, sizeof(srv_chal->data)); + r_c->status = status; +} + +/************************************************************************* + error messages cropping up when using nltest.exe... + *************************************************************************/ + +#define ERROR_NO_SUCH_DOMAIN 0x54b +#define ERROR_NO_LOGON_SERVERS 0x51f + +/************************************************************************* + net_reply_logon_ctrl2: + *************************************************************************/ + +uint32 _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_CTRL2 *r_u) +{ + /* lkclXXXX - guess what - absolutely no idea what these are! */ + uint32 flags = 0x0; + uint32 pdc_connection_status = 0x0; + uint32 logon_attempts = 0x0; + uint32 tc_status = ERROR_NO_LOGON_SERVERS; + char *trusted_domain = "test_domain"; + + DEBUG(6,("_net_logon_ctrl2: %d\n", __LINE__)); + + /* set up the Logon Control2 response */ + init_r_logon_ctrl2(r_u, q_u->query_level, + flags, pdc_connection_status, logon_attempts, + tc_status, trusted_domain); + + DEBUG(6,("_net_logon_ctrl2: %d\n", __LINE__)); + + return r_u->status; +} + +/************************************************************************* + net_reply_trust_dom_list: + *************************************************************************/ + +uint32 _net_trust_dom_list(pipes_struct *p, NET_Q_TRUST_DOM_LIST *q_u, NET_R_TRUST_DOM_LIST *r_u) +{ + char *trusted_domain = "test_domain"; + uint32 num_trust_domains = 1; + + DEBUG(6,("_net_trust_dom_list: %d\n", __LINE__)); + + /* set up the Trusted Domain List response */ + init_r_trust_dom(r_u, num_trust_domains, trusted_domain); + + DEBUG(6,("_net_trust_dom_list: %d\n", __LINE__)); + + return r_u->status; +} + +/************************************************************************* + init_net_r_auth_2: + *************************************************************************/ + +static void init_net_r_auth_2(NET_R_AUTH_2 *r_a, + DOM_CHAL *resp_cred, NEG_FLAGS *flgs, int status) +{ + memcpy(r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); + memcpy(&r_a->srv_flgs, flgs, sizeof(r_a->srv_flgs)); + r_a->status = status; +} + +/*********************************************************************************** + init_net_r_srv_pwset: + ***********************************************************************************/ + +static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, + DOM_CRED *srv_cred, int status) +{ + DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); + + memcpy(&r_s->srv_cred, srv_cred, sizeof(r_s->srv_cred)); + r_s->status = status; + + DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); +} + +/****************************************************************** + gets a machine password entry. checks access rights of the host. + ******************************************************************/ + +static BOOL get_md4pw(char *md4pw, char *mach_acct) +{ + struct smb_passwd *smb_pass; + +#if 0 + /* + * Currently this code is redundent as we already have a filter + * by hostname list. What this code really needs to do is to + * get a hosts allowed/hosts denied list from the SAM database + * on a per user basis, and make the access decision there. + * I will leave this code here for now as a reminder to implement + * this at a later date. JRA. + */ + + if (!allow_access(lp_domain_hostsdeny(), lp_domain_hostsallow(), + client_name(), client_addr())) + { + DEBUG(0,("get_md4pw: Workstation %s denied access to domain\n", mach_acct)); + return False; + } +#endif /* 0 */ + + become_root(); + smb_pass = getsmbpwnam(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); + + return True; + } + DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); + return False; +} + +/************************************************************************* + _net_req_chal + *************************************************************************/ + +uint32 _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u) +{ + uint32 status = NT_STATUS_NOPROBLEMO; + fstring mach_acct; + user_struct *vuser; + + if ((vuser = get_valid_user_struct(p->vuid)) == NULL) + return False; + + fstrcpy(mach_acct, dos_unistrn2(q_u->uni_logon_clnt.buffer, + q_u->uni_logon_clnt.uni_str_len)); + + strlower(mach_acct); + fstrcat(mach_acct, "$"); + + if (get_md4pw((char *)vuser->dc.md4pw, mach_acct)) { + /* copy the client credentials */ + memcpy(vuser->dc.clnt_chal.data , q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + memcpy(vuser->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + + /* create a server challenge for the client */ + /* Set these to random values. */ + generate_random_buffer(vuser->dc.srv_chal.data, 8, False); + + memcpy(vuser->dc.srv_cred.challenge.data, vuser->dc.srv_chal.data, 8); + + memset((char *)vuser->dc.sess_key, '\0', sizeof(vuser->dc.sess_key)); + + /* from client / server challenges and md4 password, generate sess key */ + cred_session_key(&vuser->dc.clnt_chal, &vuser->dc.srv_chal, + (char *)vuser->dc.md4pw, vuser->dc.sess_key); + } else { + /* lkclXXXX take a guess at a good error message to return :-) */ + status = NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT; + } + + /* set up the LSA REQUEST CHALLENGE response */ + init_net_r_req_chal(r_u, &vuser->dc.srv_chal, status); + + return r_u->status; +} + +/************************************************************************* + _net_auth_2 + *************************************************************************/ + +uint32 _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) +{ + uint32 status = NT_STATUS_NOPROBLEMO; + DOM_CHAL srv_cred; + UTIME srv_time; + NEG_FLAGS srv_flgs; + user_struct *vuser; + + if ((vuser = get_valid_user_struct(p->vuid)) == NULL) + return NT_STATUS_NO_SUCH_USER; + + srv_time.time = 0; + + /* check that the client credentials are valid */ + if (cred_assert(&q_u->clnt_chal, vuser->dc.sess_key, &vuser->dc.clnt_cred.challenge, srv_time)) { + + /* create server challenge for inclusion in the reply */ + cred_create(vuser->dc.sess_key, &vuser->dc.srv_cred.challenge, srv_time, &srv_cred); + + /* copy the received client credentials for use next time */ + memcpy(vuser->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + memcpy(vuser->dc.srv_cred .challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + } else { + status = NT_STATUS_ACCESS_DENIED; + } + + srv_flgs.neg_flags = 0x000001ff; + + /* set up the LSA AUTH 2 response */ + init_net_r_auth_2(r_u, &srv_cred, &srv_flgs, status); + + return r_u->status; +} + +/************************************************************************* + _net_srv_pwset + *************************************************************************/ + +uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_u) +{ + uint16 vuid = p->vuid; + uint32 status = NT_STATUS_NOPROBLEMO; + DOM_CRED srv_cred; + pstring mach_acct; + struct smb_passwd *smb_pass; + BOOL ret; + user_struct *vuser; + unsigned char pwd[16]; + int i; + + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return NT_STATUS_NO_SUCH_USER; + + /* checks and updates credentials. creates reply credentials */ + if (!deal_with_creds(vuser->dc.sess_key, &vuser->dc.clnt_cred, &q_u->clnt_id.cred, &srv_cred)) + return NT_STATUS_INVALID_HANDLE; + + memcpy(&vuser->dc.srv_cred, &vuser->dc.clnt_cred, sizeof(vuser->dc.clnt_cred)); + + DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); + + 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)); + + become_root(); + smb_pass = getsmbpwnam(mach_acct); + unbecome_root(); + + if (smb_pass == NULL) + return NT_STATUS_NO_SUCH_USER; + + DEBUG(100,("Server password set : new given value was :\n")); + for(i = 0; i < 16; i++) + DEBUG(100,("%02X ", q_u->pwd[i])); + DEBUG(100,("\n")); + + cred_hash3( pwd, q_u->pwd, vuser->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; + + become_root(); + ret = mod_smbpwd_entry(smb_pass,False); + unbecome_root(); + + if (!ret) + status = NT_STATUS_WRONG_PASSWORD; + + /* set up the LSA Server Password Set response */ + init_net_r_srv_pwset(r_u, &srv_cred, status); + + return r_u->status; +} + + +/************************************************************************* + _net_sam_logoff: + *************************************************************************/ + +uint32 _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF *r_u) +{ + DOM_CRED srv_cred; + + user_struct *vuser; + + if ((vuser = get_valid_user_struct(p->vuid)) == NULL) + return NT_STATUS_NO_SUCH_USER; + + /* checks and updates credentials. creates reply credentials */ + if (!deal_with_creds(vuser->dc.sess_key, &vuser->dc.clnt_cred, + &q_u->sam_id.client.cred, &srv_cred)) + return NT_STATUS_INVALID_HANDLE; + + memcpy(&vuser->dc.srv_cred, &vuser->dc.clnt_cred, sizeof(vuser->dc.clnt_cred)); + + /* XXXX maybe we want to say 'no', reject the client's credentials */ + 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; + + return r_u->status; +} + +/************************************************************************* + net_login_interactive: + *************************************************************************/ + +static uint32 net_login_interactive(NET_ID_INFO_1 *id1, struct smb_passwd *smb_pass, user_struct *vuser) +{ + uint32 status = 0x0; + + char nt_pwd[16]; + char lm_pwd[16]; + unsigned char key[16]; + + memset(key, 0, 16); + memcpy(key, vuser->dc.sess_key, 8); + + memcpy(lm_pwd, id1->lm_owf.data, 16); + memcpy(nt_pwd, id1->nt_owf.data, 16); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("key:")); + dump_data(100, (char *)key, 16); + + DEBUG(100,("lm owf password:")); + dump_data(100, lm_pwd, 16); + + DEBUG(100,("nt owf password:")); + dump_data(100, nt_pwd, 16); +#endif + + SamOEMhash((uchar *)lm_pwd, key, False); + SamOEMhash((uchar *)nt_pwd, key, False); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("decrypt of lm owf password:")); + dump_data(100, lm_pwd, 16); + + DEBUG(100,("decrypt of nt owf password:")); + 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; + } + + return status; +} + +/************************************************************************* + _net_login_network: + *************************************************************************/ + +static uint32 net_login_network(NET_ID_INFO_2 *id2, struct smb_passwd *smb_pass) +{ + 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)); + + /* 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 0x0; + else + return NT_STATUS_WRONG_PASSWORD; + } + + /* lkclXXXX this is not a good place to put disabling of LM hashes in. + if that is to be done, first move this entire function into a + library routine that calls the two smb_password_check() functions. + if disabling LM hashes (which nt can do for security reasons) then + an attempt should be made to disable them everywhere (which nt does + not do, for various security-hole reasons). + */ + + if (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)) + { + return 0x0; + } + + + /* oops! neither password check succeeded */ + + return NT_STATUS_WRONG_PASSWORD; +} + +/************************************************************************* + _net_sam_logon + *************************************************************************/ + +uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_u) +{ + uint32 status = NT_STATUS_NOPROBLEMO; + uint16 vuid = p->vuid; + NET_USER_INFO_3 *usr_info = NULL; + DOM_CRED srv_cred; + struct smb_passwd *smb_pass = NULL; + struct sam_passwd *sam_pass = NULL; + UNISTR2 *uni_samlogon_user = NULL; + fstring nt_username; + struct passwd *pw; + user_struct *vuser = NULL; + + usr_info = (NET_USER_INFO_3 *)talloc(p->mem_ctx, sizeof(NET_USER_INFO_3)); + if (!usr_info) + return NT_STATUS_NO_MEMORY; + ZERO_STRUCTP(usr_info); + + if ((vuser = get_valid_user_struct(vuid)) == NULL) + return NT_STATUS_NO_SUCH_USER; + + /* checks and updates credentials. creates reply credentials */ + if (!deal_with_creds(vuser->dc.sess_key, &vuser->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred)) + return NT_STATUS_INVALID_HANDLE; + else + memcpy(&vuser->dc.srv_cred, &vuser->dc.clnt_cred, sizeof(vuser->dc.clnt_cred)); + + /* find the username */ + + switch (q_u->sam_id.logon_level) { + case INTERACTIVE_LOGON_TYPE: + uni_samlogon_user = &q_u->sam_id.ctr->auth.id1.uni_user_name; + + DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); + break; + case NET_LOGON_TYPE: + uni_samlogon_user = &q_u->sam_id.ctr->auth.id2.uni_user_name; + + DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); + break; + default: + DEBUG(2,("SAM Logon: unsupported switch value\n")); + return NT_STATUS_INVALID_INFO_CLASS; + } /* end switch */ + + /* check username exists */ + + pstrcpy(nt_username, dos_unistrn2(uni_samlogon_user->buffer, uni_samlogon_user->uni_str_len)); + + DEBUG(3,("User:[%s]\n", nt_username)); + + /* + * Convert to a UNIX username. + */ + + map_username(nt_username); + + /* + * Do any case conversions. + */ + + pw=Get_Pwnam(nt_username, True); + + become_root(); + sam_pass = getsam21pwnam(nt_username); + smb_pass = getsmbpwnam(nt_username); + unbecome_root(); + + if (smb_pass == NULL) + 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)) { + 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, vuser); + 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); + break; + } + } + + if (status != NT_STATUS_NOPROBLEMO) + return status; + + /* 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 logon_script; + pstring profile_path; + pstring home_dir; + pstring home_drive; + pstring my_name; + pstring my_workgroup; + pstring domain_groups; + uint32 r_uid; + uint32 r_gid; + fstring full_name; + + /* set up pointer indicating user/password failed to be found */ + usr_info->ptr_user_info = 0; + + dummy_time.low = 0xffffffff; + dummy_time.high = 0x7fffffff; + + /* 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); + + pstrcpy(logon_script, sam_pass->logon_script); + standard_sub_advanced(-1, nt_username, "", pw->pw_gid, logon_script); + + pstrcpy(profile_path, sam_pass->profile_path); + standard_sub_advanced(-1, nt_username, "", pw->pw_gid, profile_path); + + pstrcpy(my_workgroup, lp_workgroup()); + + pstrcpy(home_drive, sam_pass->dir_drive); + standard_sub_advanced(-1, nt_username, "", pw->pw_gid, home_drive); + + pstrcpy(home_dir, sam_pass->home_dir); + standard_sub_advanced(-1, nt_username, "", pw->pw_gid, home_dir); + + pstrcpy(my_name, global_myname); + strupper(my_name); + + pstrcpy(full_name, sam_pass->full_name ); + if( !*full_name ) { + fstrcpy(full_name, ""); + if (lp_unix_realname()) + fstrcpy(full_name, strtok(pw->pw_gecos, ",")); + } + + /* + * This is the point at which we get the group + * database - we should be getting the gid_t list + * from /etc/group and then turning the uids into + * rids and then into machine sids for this user. + * JRA. + */ + + get_domain_user_groups(domain_groups, nt_username); + + /* + * make_dom_gids allocates the gids array. JRA. + */ + gids = NULL; + num_gids = make_dom_gids(p->mem_ctx, domain_groups, &gids); + + sam_logon_in_ssb = False; + + 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 */ + full_name, /* full_name */ + logon_script , /* logon_script */ + profile_path , /* profile_path */ + home_dir , /* home_dir */ + home_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; + + } + + /* XXXX maybe we want to say 'no', reject the client's credentials */ + r_u->buffer_creds = 1; /* yes, we have valid server credentials */ + memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds)); + + /* store the user information, if there is any. */ + r_u->user = usr_info; + if (status == NT_STATUS_NOPROBLEMO && usr_info != NULL && usr_info->ptr_user_info != 0) + r_u->switch_value = 3; /* indicates type of validation user info */ + else + r_u->switch_value = 0; /* indicates no info */ + + r_u->status = status; + r_u->auth_resp = 1; /* authoritative response */ + + return r_u->status; +} -- cgit From ef2de912f2c0b095ea19986b3dce6b1b8a0ea8b5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Feb 2001 02:09:50 +0000 Subject: Separated dfs pipe into implementation and interface modules. rpc_parse/parse_dfs.c: Had to add buffer overrun checking ! HOW DID THIS GET IN HERE ! rpc_parse/parse_prs.c: Ensure prs_alloc_mem does a memset of zero before returning. Jeremy. (This used to be commit c9a6a17025f4a6850cd2b9a9ddb48bdeec8b3ffe) --- source3/rpc_server/srv_dfs.c | 397 +++++++------------------------------------ 1 file changed, 60 insertions(+), 337 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 7aadd0719c..fe797e84f6 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -5,6 +5,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Shirish Kalele 2000. + * Copyright (C) Jeremy Allison 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +22,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* This is the interface to the dfs pipe. */ + #include "includes.h" #include "nterr.h" @@ -34,414 +37,129 @@ extern pstring global_myname; /********************************************************************** api_dfs_exist **********************************************************************/ + static BOOL api_dfs_exist(pipes_struct *p) { - DFS_R_DFS_EXIST r_d; + DFS_Q_DFS_EXIST q_u; + DFS_R_DFS_EXIST r_u; + prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - if(lp_host_msdfs()) - r_d.dfs_exist_flag = 1; - else - r_d.dfs_exist_flag = 0; + if(!dfs_io_q_dfs_exist("", &q_u, data, 0)) + return False; - return dfs_io_r_dfs_exist("", &r_d, rdata, 0); -} - -static uint32 init_reply_dfs_add(DFS_Q_DFS_ADD* q_a) -{ - struct junction_map jn; - struct referral* old_referral_list = NULL; - BOOL exists = False; - - pstring dfspath, servername, sharename; - pstring altpath; - - unistr2_to_ascii(dfspath, &(q_a->DfsEntryPath), sizeof(dfspath)-1); - unistr2_to_ascii(servername, &(q_a->ServerName), sizeof(servername)-1); - unistr2_to_ascii(sharename, &(q_a->ShareName), sizeof(sharename)-1); - - DEBUG(5,("init_reply_dfs_add: Request to add %s -> %s\\%s.\n", - dfspath, servername, sharename)); - - pstrcpy(altpath, servername); - pstrcat(altpath, "\\"); - pstrcat(altpath, sharename); - - if(!create_junction(dfspath, &jn)) - return NERR_DfsNoSuchServer; - - if(get_referred_path(&jn)) - { - exists = True; - jn.referral_count += 1; - old_referral_list = jn.referral_list; - } - else - jn.referral_count = 1; - - jn.referral_list = (struct referral*) malloc(jn.referral_count - * sizeof(struct referral)); - - if(jn.referral_list == NULL) - { - DEBUG(0,("init_reply_dfs_add: malloc failed for referral list!\n")); - return NERR_DfsInternalError; - } - - if(old_referral_list) - { - memcpy(jn.referral_list, old_referral_list, - sizeof(struct referral)*jn.referral_count-1); - free(old_referral_list); - } - - jn.referral_list[jn.referral_count-1].proximity = 0; - jn.referral_list[jn.referral_count-1].ttl = REFERRAL_TTL; - - pstrcpy(jn.referral_list[jn.referral_count-1].alternate_path, altpath); - - if(!create_msdfs_link(&jn, exists)) - return NERR_DfsCantCreateJunctionPoint; + r_u.status = _dfs_exist(p, &q_u, &r_u); + + if (!dfs_io_r_dfs_exist("", &r_u, rdata, 0)) + return False; - return 0; + return True; } + /***************************************************************** api_dfs_add *****************************************************************/ + static BOOL api_dfs_add(pipes_struct *p) { - DFS_Q_DFS_ADD q_a; - DFS_R_DFS_ADD r_a; + DFS_Q_DFS_ADD q_u; + DFS_R_DFS_ADD r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - if(!dfs_io_q_dfs_add("", &q_a, data, 0)) + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!dfs_io_q_dfs_add("", &q_u, data, 0)) return False; - r_a.status = init_reply_dfs_add(&q_a); + r_u.status = _dfs_add(p, &q_u, &r_u); - dfs_io_r_dfs_add("", &r_a, rdata, 0); + if (!dfs_io_r_dfs_add("", &r_u, rdata, 0)) + return False; return True; } -static uint32 init_reply_dfs_remove(DFS_Q_DFS_REMOVE* q_r) -{ - struct junction_map jn; - BOOL found = False; - - pstring dfspath, servername, sharename; - pstring altpath; - - unistr2_to_ascii(dfspath, &(q_r->DfsEntryPath), sizeof(dfspath)-1); - if(q_r->ptr_ServerName) - unistr2_to_ascii(servername, &(q_r->ServerName), sizeof(servername)-1); - - if(q_r->ptr_ShareName) - unistr2_to_ascii(sharename, &(q_r->ShareName), sizeof(sharename)-1); - - if(q_r->ptr_ServerName && q_r->ptr_ShareName) - { - pstrcpy(altpath, servername); - pstrcat(altpath, "\\"); - pstrcat(altpath, sharename); - } - - 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 no server-share pair given, remove the msdfs link completely */ - if(!q_r->ptr_ServerName && !q_r->ptr_ShareName) - { - if(!remove_msdfs_link(&jn)) - return NERR_DfsNoSuchVolume; - } - else - { - int i=0; - /* compare each referral in the list with the one to remove */ - for(i=0;iin_data.data; prs_struct *rdata = &p->out_data.rdata; - if(!dfs_io_q_dfs_remove("", &q_r, data, 0)) + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!dfs_io_q_dfs_remove("", &q_u, data, 0)) return False; - r_r.status = init_reply_dfs_remove(&q_r); + r_u.status = _dfs_remove(p, &q_u, &r_u); - dfs_io_r_dfs_remove("", &r_r, rdata, 0); + if (!dfs_io_r_dfs_remove("", &r_u, rdata, 0)) + return False; return True; } -static BOOL init_reply_dfs_info_1(struct junction_map* j, DFS_INFO_1* dfs1, int num_j) -{ - int i=0; - for(i=0;ialternate_path); - trim_string(path,"\\",""); - p = strrchr(path,'\\'); - if(p==NULL) - { - DEBUG(4,("init_reply_dfs_info_3: invalid path: no \\ found in %s\n",path)); - continue; - } - *p = '\0'; - DEBUG(5,("storage %d: %s.%s\n",ii,path,p+1)); - stor->state = 2; /* set all storages as ONLINE */ - init_unistr2(&stor->servername, path, strlen(path)+1); - init_unistr2(&stor->sharename, p+1, strlen(p+1)+1); - stor->ptr_servername = stor->ptr_sharename = 1; - } - } - return True; -} - -static uint32 init_reply_dfs_ctr(uint32 level, DFS_INFO_CTR* ctr, - struct junction_map* jn, int num_jn) -{ - /* do the levels */ - switch(level) - { - case 1: - { - DFS_INFO_1* dfs1; - dfs1 = (DFS_INFO_1*) malloc(num_jn * sizeof(DFS_INFO_1)); - init_reply_dfs_info_1(jn, dfs1, num_jn); - ctr->dfs.info1 = dfs1; - break; - } - case 2: - { - DFS_INFO_2* dfs2; - dfs2 = (DFS_INFO_2*) malloc(num_jn * sizeof(DFS_INFO_2)); - init_reply_dfs_info_2(jn, dfs2, num_jn); - ctr->dfs.info2 = dfs2; - break; - } - case 3: - { - DFS_INFO_3* dfs3; - dfs3 = (DFS_INFO_3*) malloc(num_jn * sizeof(DFS_INFO_3)); - init_reply_dfs_info_3(jn, dfs3, num_jn); - ctr->dfs.info3 = dfs3; - } - } - return 0; -} - -static uint32 init_reply_dfs_enum(uint32 level, DFS_R_DFS_ENUM *q_r) -{ - struct junction_map jn[MAX_MSDFS_JUNCTIONS]; - int num_jn = 0; - int i=0; - - num_jn = enum_msdfs_links(jn); - - DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", - num_jn, level)); - - q_r->ptr_buffer = level; - q_r->level = q_r->level2 = level; - q_r->ptr_num_entries = q_r->ptr_num_entries2 = 1; - q_r->num_entries = q_r->num_entries2 = num_jn; - q_r->reshnd.ptr_hnd = 1; - q_r->reshnd.handle = num_jn; - - q_r->ctr = (DFS_INFO_CTR*) malloc(sizeof(DFS_INFO_CTR)); - q_r->ctr->switch_value = level; - q_r->ctr->num_entries = num_jn; - q_r->ctr->ptr_dfs_ctr = 1; - - init_reply_dfs_ctr(level, q_r->ctr, jn, num_jn); - - for(i=0;ilevel = level; - r_i->ptr_ctr = 1; - r_i->status = init_reply_dfs_ctr(level, &(r_i->ctr), &jn, 1); - - free(jn.referral_list); - return 0; -} /******************************************************************* api_dfs_get_info *******************************************************************/ + static BOOL api_dfs_get_info(pipes_struct *p) { - DFS_Q_DFS_GET_INFO q_i; - DFS_R_DFS_GET_INFO r_i; + DFS_Q_DFS_GET_INFO q_u; + DFS_R_DFS_GET_INFO r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - ZERO_STRUCT(r_i); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - if(!dfs_io_q_dfs_get_info("", &q_i, data, 0)) + if(!dfs_io_q_dfs_get_info("", &q_u, data, 0)) return False; - r_i.status = init_reply_dfs_get_info(&q_i.uni_path, q_i.level, &r_i); + r_u.status = _dfs_get_info(p, &q_u, &r_u); - if(!dfs_io_r_dfs_get_info("", &r_i, rdata, 0)) + if(!dfs_io_r_dfs_get_info("", &r_u, rdata, 0)) return False; - - switch(r_i.level) { - case 1: free(r_i.ctr.dfs.info1); break; - case 2: free(r_i.ctr.dfs.info2); break; - case 3: { - free(r_i.ctr.dfs.info3->storages); - free(r_i.ctr.dfs.info3); - break; - } - } + return True; } /******************************************************************* api_dfs_enum *******************************************************************/ + static BOOL api_dfs_enum(pipes_struct *p) { - DFS_Q_DFS_ENUM q_e; - DFS_R_DFS_ENUM q_r; + DFS_Q_DFS_ENUM q_u; + DFS_R_DFS_ENUM r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - if(!dfs_io_q_dfs_enum("", &q_e, data, 0)) + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!dfs_io_q_dfs_enum("", &q_u, data, 0)) return False; - q_r.status = init_reply_dfs_enum(q_e.level, &q_r); + r_u.status = _dfs_enum(p, &q_u, &r_u); - if(!dfs_io_r_dfs_enum("", &q_r, rdata, 0)) + if(!dfs_io_r_dfs_enum("", &r_u, rdata, 0)) return False; - switch(q_e.level) { - case 1: - free(q_r.ctr->dfs.info1); break; - case 2: - free(q_r.ctr->dfs.info2); break; - case 3: - free(q_r.ctr->dfs.info3->storages); - free(q_r.ctr->dfs.info3); break; - } - free(q_r.ctr); + return True; } /******************************************************************* \pipe\netdfs commands ********************************************************************/ + struct api_struct api_netdfs_cmds[] = { {"DFS_EXIST", DFS_EXIST, api_dfs_exist }, @@ -455,9 +173,14 @@ struct api_struct api_netdfs_cmds[] = /******************************************************************* receives a netdfs pipe and responds. ********************************************************************/ + BOOL api_netdfs_rpc(pipes_struct *p) { return api_rpcTNP(p, "api_netdfs_rpc", api_netdfs_cmds); } +#else + + void dfs_dummy(void) {;} /* So some compilers don't complain. */ + #endif -- cgit From dbc5cace14de14556da7a32cd9f4a82ef522e401 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Feb 2001 18:22:39 +0000 Subject: Hmmm. I thought I'd added these files to CVS head..... Jeremy. (This used to be commit d573700a9218bce8efd21f0be70afec6b460f8b9) --- source3/rpc_server/srv_dfs_nt.c | 350 +++++ source3/rpc_server/srv_samr_nt.c | 2457 ++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_srvsvc_nt.c | 866 +++++++++++++ 3 files changed, 3673 insertions(+) create mode 100644 source3/rpc_server/srv_dfs_nt.c create mode 100644 source3/rpc_server/srv_samr_nt.c create mode 100644 source3/rpc_server/srv_srvsvc_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c new file mode 100644 index 0000000000..9b3ac1bb54 --- /dev/null +++ b/source3/rpc_server/srv_dfs_nt.c @@ -0,0 +1,350 @@ +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines for Dfs + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Shirish Kalele 2000. + * Copyright (C) Jeremy Allison 2001. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* This is the implementation of the dfs pipe. */ + +#include "includes.h" +#include "nterr.h" + +extern int DEBUGLEVEL; +extern pstring global_myname; + +#ifdef WITH_MSDFS + +#define MAX_MSDFS_JUNCTIONS 256 + +uint32 _dfs_exist(pipes_struct *p, DFS_Q_DFS_EXIST *q_u, DFS_R_DFS_EXIST *r_u) +{ + if(lp_host_msdfs()) + return 1; + else + return 0; +} + +uint32 _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) +{ + struct junction_map jn; + struct referral* old_referral_list = NULL; + BOOL exists = False; + + pstring dfspath, servername, sharename; + pstring altpath; + + unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1); + unistr2_to_ascii(servername, &q_u->ServerName, sizeof(servername)-1); + unistr2_to_ascii(sharename, &q_u->ShareName, sizeof(sharename)-1); + + DEBUG(5,("init_reply_dfs_add: Request to add %s -> %s\\%s.\n", + dfspath, servername, sharename)); + + pstrcpy(altpath, servername); + pstrcat(altpath, "\\"); + pstrcat(altpath, sharename); + + if(!create_junction(dfspath, &jn)) + return NERR_DfsNoSuchServer; + + if(get_referred_path(&jn)) + { + exists = True; + jn.referral_count += 1; + old_referral_list = jn.referral_list; + } + else + jn.referral_count = 1; + + jn.referral_list = (struct referral*) talloc(p->mem_ctx, jn.referral_count + * sizeof(struct referral)); + + if(jn.referral_list == NULL) + { + DEBUG(0,("init_reply_dfs_add: talloc failed for referral list!\n")); + return NERR_DfsInternalError; + } + + if(old_referral_list) + { + memcpy(jn.referral_list, old_referral_list, + sizeof(struct referral)*jn.referral_count-1); + free(old_referral_list); + } + + jn.referral_list[jn.referral_count-1].proximity = 0; + jn.referral_list[jn.referral_count-1].ttl = REFERRAL_TTL; + + pstrcpy(jn.referral_list[jn.referral_count-1].alternate_path, altpath); + + if(!create_msdfs_link(&jn, exists)) + return NERR_DfsCantCreateJunctionPoint; + + return NT_STATUS_NOPROBLEMO; +} + +uint32 _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DFS_R_DFS_REMOVE *r_u) +{ + struct junction_map jn; + BOOL found = False; + + pstring dfspath, servername, sharename; + pstring altpath; + + unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1); + if(q_u->ptr_ServerName) + unistr2_to_ascii(servername, &q_u->ServerName, sizeof(servername)-1); + + if(q_u->ptr_ShareName) + unistr2_to_ascii(sharename, &q_u->ShareName, sizeof(sharename)-1); + + if(q_u->ptr_ServerName && q_u->ptr_ShareName) + { + pstrcpy(altpath, servername); + pstrcat(altpath, "\\"); + pstrcat(altpath, sharename); + } + + 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 no server-share pair given, remove the msdfs link completely */ + if(!q_u->ptr_ServerName && !q_u->ptr_ShareName) + { + if(!remove_msdfs_link(&jn)) + return NERR_DfsNoSuchVolume; + } + else + { + int i=0; + /* compare each referral in the list with the one to remove */ + for(i=0;ialternate_path); + trim_string(path,"\\",""); + p = strrchr(path,'\\'); + if(p==NULL) + { + DEBUG(4,("init_reply_dfs_info_3: invalid path: no \\ found in %s\n",path)); + continue; + } + *p = '\0'; + DEBUG(5,("storage %d: %s.%s\n",ii,path,p+1)); + stor->state = 2; /* set all storages as ONLINE */ + init_unistr2(&stor->servername, path, strlen(path)+1); + init_unistr2(&stor->sharename, p+1, strlen(p+1)+1); + stor->ptr_servername = stor->ptr_sharename = 1; + } + } + return True; +} + +static uint32 init_reply_dfs_ctr(TALLOC_CTX *ctx, uint32 level, DFS_INFO_CTR* ctr, + struct junction_map* jn, int num_jn) +{ + /* do the levels */ + switch(level) + { + case 1: + { + DFS_INFO_1* dfs1; + dfs1 = (DFS_INFO_1*) talloc(ctx, num_jn * sizeof(DFS_INFO_1)); + if (!dfs1) + return NT_STATUS_NO_MEMORY; + init_reply_dfs_info_1(jn, dfs1, num_jn); + ctr->dfs.info1 = dfs1; + break; + } + case 2: + { + DFS_INFO_2* dfs2; + dfs2 = (DFS_INFO_2*) talloc(ctx, num_jn * sizeof(DFS_INFO_2)); + if (!dfs2) + return NT_STATUS_NO_MEMORY; + init_reply_dfs_info_2(jn, dfs2, num_jn); + ctr->dfs.info2 = dfs2; + break; + } + case 3: + { + DFS_INFO_3* dfs3; + dfs3 = (DFS_INFO_3*) talloc(ctx, num_jn * sizeof(DFS_INFO_3)); + if (!dfs3) + return NT_STATUS_NO_MEMORY; + init_reply_dfs_info_3(ctx, jn, dfs3, num_jn); + ctr->dfs.info3 = dfs3; + } + default: + return NT_STATUS_INVALID_LEVEL; + } + return NT_STATUS_NOPROBLEMO; +} + +uint32 _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u) +{ + uint32 level = q_u->level; + struct junction_map jn[MAX_MSDFS_JUNCTIONS]; + int num_jn = 0; + + num_jn = enum_msdfs_links(jn); + + DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", num_jn, level)); + + r_u->ptr_buffer = level; + r_u->level = r_u->level2 = level; + r_u->ptr_num_entries = r_u->ptr_num_entries2 = 1; + r_u->num_entries = r_u->num_entries2 = num_jn; + r_u->reshnd.ptr_hnd = 1; + r_u->reshnd.handle = num_jn; + + r_u->ctr = (DFS_INFO_CTR*)talloc(p->mem_ctx, sizeof(DFS_INFO_CTR)); + if (!r_u->ctr) + return NT_STATUS_NO_MEMORY; + ZERO_STRUCTP(r_u->ctr); + r_u->ctr->switch_value = level; + r_u->ctr->num_entries = num_jn; + r_u->ctr->ptr_dfs_ctr = 1; + + r_u->status = init_reply_dfs_ctr(p->mem_ctx, level, r_u->ctr, jn, num_jn); + + return r_u->status; +} + +uint32 _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u, DFS_R_DFS_GET_INFO *r_u) +{ + UNISTR2* uni_path = &q_u->uni_path; + uint32 level = q_u->level; + pstring path; + struct junction_map jn; + + unistr2_to_ascii(path, uni_path, sizeof(path)-1); + if(!create_junction(path, &jn)) + return NERR_DfsNoSuchServer; + + if(!get_referred_path(&jn)) + return NERR_DfsNoSuchVolume; + + r_u->level = level; + r_u->ptr_ctr = 1; + r_u->status = init_reply_dfs_ctr(p->mem_ctx, level, &r_u->ctr, &jn, 1); + + return r_u->status; +} +#else + void dfs_dummy1(void) {;} /* So some compilers don't complain. */ +#endif diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c new file mode 100644 index 0000000000..bd04b40c4d --- /dev/null +++ b/source3/rpc_server/srv_samr_nt.c @@ -0,0 +1,2457 @@ +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997. + * Copyright (C) Hewlett-Packard Company 1999. + * Copyright (C) Jeremy Allison 2001. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * This is the implementation of the SAMR code. + */ + +#include "includes.h" + +extern int DEBUGLEVEL; + +extern fstring global_myworkgroup; +extern pstring global_myname; +extern DOM_SID global_sam_sid; + +extern rid_name domain_group_rids[]; +extern rid_name domain_alias_rids[]; +extern rid_name builtin_alias_rids[]; + +/******************************************************************* + This next function should be replaced with something that + dynamically returns the correct user info..... JRA. + ********************************************************************/ + +static BOOL 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; + + (*num_entries) = 0; + (*total_entries) = 0; + + if (pw_buf == NULL) + return False; + + vp = startsmbpwent(False); + if (!vp) { + DEBUG(0, ("get_sampwd_entries: Unable to open SMB password database.\n")); + return False; + } + + while (((pwd = getsam21pwent(vp)) != NULL) && (*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; + } + + 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); + + /* 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); + } + + pw_buf[(*num_entries)].acb_info = (uint16)pwd->acct_ctrl; + + DEBUG(5, ("entry idx: %d user %s, rid 0x%x, acb %x", + (*num_entries), pwd->smb_name, pwd->user_rid, pwd->acct_ctrl)); + + 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)++; + } + + endsmbpwent(vp); + + return (*num_entries) > 0; +} + +static BOOL jf_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; + + *num_entries = 0; + *total_entries = 0; + + if (pw_buf == NULL) + return False; + + vp = startsmbpwent(False); + if (!vp) { + DEBUG(0, ("get_sampwd_entries: Unable to open SMB password database.\n")); + return False; + } + + while (((pwd = getsam21pwent(vp)) != NULL) && (*num_entries) < max_num_entries) { + int user_name_len; + int full_name_len; + + if (acb_mask != 0 && !(pwd->acct_ctrl & acb_mask)) + continue; + + if (start_idx > 0) { + /* skip the requested number of entries. + not very efficient, but hey... + */ + start_idx--; + 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); + 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); + init_uni_hdr(&pw_buf[(*num_entries)].hdr_full_name, full_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); + } + + 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), pwd->smb_name, pwd->user_rid, pwd->acct_ctrl)); + (*num_entries)++; + } + + endsmbpwent(vp); + + *total_entries = *num_entries; + return True; +} + +/******************************************************************* + 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 + map_username() function.) Since more than one DOS name can map + to the UNIX name, to reverse the mapping you have to specify + which corresponding DOS name you want; that's where the name_idx + parameter comes in. Returns the string requested or NULL if it + fails or can't complete the request for any reason. This doesn't + handle group names (starting with '@') or names starting with + '+' or '&'. If they are encountered, they are skipped. +********************************************************************/ + +static char *unmap_unixname(char *unix_user_name, int name_idx) +{ + char *mapfile = lp_username_map(); + char **lines; + static pstring tok; + int i; + + if (!*unix_user_name) return NULL; + if (!*mapfile) return NULL; + + lines = file_lines_load(mapfile, NULL,False); + if (!lines) { + DEBUG(0,("unmap_unixname: can't open username map %s\n", mapfile)); + return NULL; + } + + DEBUG(5,("unmap_unixname: scanning username map %s, index: %d\n", mapfile, name_idx)); + + for (i=0; lines[i]; i++) { + char *unixname = lines[i]; + char *dosname = strchr(unixname,'='); + + if (!dosname) + continue; + + *dosname++ = 0; + + while (isspace(*unixname)) + unixname++; + if ('!' == *unixname) { + unixname++; + while (*unixname && isspace(*unixname)) + unixname++; + } + + if (!*unixname || strchr("#;",*unixname)) + continue; + + if (strncmp(unixname, unix_user_name, strlen(unix_user_name))) + continue; + + /* We have matched the UNIX user name */ + + while(next_token(&dosname, tok, LIST_SEP, sizeof(tok))) { + if (!strchr("@&+", *tok)) { + name_idx--; + if (name_idx < 0 ) { + break; + } + } + } + + if (name_idx >= 0) { + DEBUG(0,("unmap_unixname: index too high - not that many DOS names\n")); + file_lines_free(lines); + return NULL; + } else { + file_lines_free(lines); + return tok; + } + } + + DEBUG(0,("unmap_unixname: Couldn't find the UNIX user name\n")); + file_lines_free(lines); + return NULL; +} + +/******************************************************************* + This function sets up a list of users taken from the list of + users that UNIX knows about, as well as all the user names that + Samba maps to a valid UNIX user name. (This should work with + /etc/passwd or NIS.) +********************************************************************/ + +static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, + int start_idx, + int *total_entries, int *num_entries, + int max_num_entries, + uint16 acb_mask) +{ + static struct passwd *pwd = NULL; + static uint32 pw_rid; + static BOOL orig_done = False; + static int current_idx = 0; + static int mapped_idx = 0; + char *sep; + + DEBUG(5, ("get_passwd_entries: retrieving a list of UNIX users\n")); + + (*num_entries) = 0; + (*total_entries) = 0; + + /* Skip all this stuff if we're in appliance mode */ + + if (lp_hide_local_users()) goto done; + + if (pw_buf == NULL) return False; + + if (current_idx == 0) { + sys_setpwent(); + } + + /* These two cases are inefficient, but should be called very rarely */ + /* they are the cases where the starting index isn't picking up */ + /* where we left off last time. It is efficient when it starts over */ + /* at zero though. */ + if (start_idx > current_idx) { + /* We aren't far enough; advance to start_idx */ + while (current_idx <= start_idx) { + char *unmap_name; + + if(!orig_done) { + if ((pwd = sys_getpwent()) == NULL) break; + current_idx++; + orig_done = True; + } + + while (((unmap_name = unmap_unixname(pwd->pw_name, mapped_idx)) != NULL) && + (current_idx < start_idx)) { + current_idx++; + mapped_idx++; + } + + if (unmap_name == NULL) { + orig_done = False; + mapped_idx = 0; + } + } + } else if (start_idx < current_idx) { + /* We are already too far; start over and advance to start_idx */ + sys_endpwent(); + sys_setpwent(); + current_idx = 0; + mapped_idx = 0; + orig_done = False; + while (current_idx < start_idx) { + char *unmap_name; + + if(!orig_done) { + if ((pwd = sys_getpwent()) == NULL) break; + current_idx++; + orig_done = True; + } + + while (((unmap_name = unmap_unixname(pwd->pw_name, mapped_idx)) != NULL) && + (current_idx < start_idx)) { + current_idx++; + mapped_idx++; + } + + if (unmap_name == NULL) { + orig_done = False; + mapped_idx = 0; + } + } + } + + sep = lp_winbind_separator(); + + /* now current_idx == start_idx */ + while ((*num_entries) < max_num_entries) { + int user_name_len; + char *unmap_name; + + /* This does the original UNIX user itself */ + if(!orig_done) { + if ((pwd = sys_getpwent()) == NULL) break; + + /* Don't enumerate winbind users as they are not local */ + + if (strchr(pwd->pw_name, *sep) != NULL) { + continue; + } + + user_name_len = strlen(pwd->pw_name); + + /* skip the trust account stored in the /etc/passwd file */ + if (pwd->pw_name[user_name_len-1]=='$') + continue; + + pw_rid = pdb_uid_to_user_rid(pwd->pw_uid); + ZERO_STRUCTP(&pw_buf[(*num_entries)]); + init_unistr2(&pw_buf[(*num_entries)].uni_user_name, pwd->pw_name, user_name_len); + init_uni_hdr(&pw_buf[(*num_entries)].hdr_user_name, user_name_len); + pw_buf[(*num_entries)].user_rid = pw_rid; + memset((char *)pw_buf[(*num_entries)].nt_pwd, '\0', 16); + + pw_buf[(*num_entries)].acb_info = ACB_NORMAL; + + DEBUG(5, ("get_passwd_entries: entry idx %d user %s, rid 0x%x\n", (*num_entries), pwd->pw_name, pw_rid)); + + (*num_entries)++; + (*total_entries)++; + current_idx++; + orig_done = True; + } + + /* This does all the user names that map to the UNIX user */ + while (((unmap_name = unmap_unixname(pwd->pw_name, mapped_idx)) != NULL) && + (*num_entries < max_num_entries)) { + user_name_len = strlen(unmap_name); + ZERO_STRUCTP(&pw_buf[(*num_entries)]); + init_unistr2(&pw_buf[(*num_entries)].uni_user_name, unmap_name, user_name_len); + init_uni_hdr(&pw_buf[(*num_entries)].hdr_user_name, user_name_len); + pw_buf[(*num_entries)].user_rid = pw_rid; + memset((char *)pw_buf[(*num_entries)].nt_pwd, '\0', 16); + + pw_buf[(*num_entries)].acb_info = ACB_NORMAL; + + DEBUG(5, ("get_passwd_entries: entry idx %d user %s, rid 0x%x\n", (*num_entries), pwd->pw_name, pw_rid)); + + (*num_entries)++; + (*total_entries)++; + current_idx++; + mapped_idx++; + } + + if (unmap_name == NULL) { + /* done with 'aliases', go on to next UNIX user */ + orig_done = False; + mapped_idx = 0; + } + } + + if (pwd == NULL) { + /* totally done, reset everything */ + sys_endpwent(); + current_idx = 0; + mapped_idx = 0; + } + +done: + return (*num_entries) > 0; +} + +/******************************************************************* + _samr_close_hnd + ********************************************************************/ + +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; + + /* close the policy handle */ + if (!close_lsa_policy_hnd(&q_u->pol)) + return NT_STATUS_OBJECT_NAME_INVALID; + + DEBUG(5,("samr_reply_close_hnd: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* + samr_reply_open_domain + ********************************************************************/ + +uint32 _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN_DOMAIN *r_u) +{ + r_u->status = NT_STATUS_NOPROBLEMO; + + /* find the connection policy handle. */ + if (find_lsa_policy_by_hnd(&q_u->pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + /* get a (unique) handle. open a policy on it. */ + if (!open_lsa_policy_hnd(&r_u->domain_pol)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + /* associate the domain SID with the (unique) handle. */ + if (!set_lsa_policy_samr_sid(&r_u->domain_pol, &q_u->dom_sid.sid)) { + close_lsa_policy_hnd(&r_u->domain_pol); + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + DEBUG(5,("samr_open_domain: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* + _samr_get_usrdom_pwinfo + ********************************************************************/ + +uint32 _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, SAMR_R_GET_USRDOM_PWINFO *r_u) +{ + r_u->status = NT_STATUS_NOPROBLEMO; + + /* find the policy handle. open a policy on it. */ + if (find_lsa_policy_by_hnd(&q_u->user_pol) == -1) { + return NT_STATUS_INVALID_HANDLE; + } + + /* find the user's rid */ + if (get_lsa_policy_samr_rid(&q_u->user_pol) == 0xffffffff) { + return NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + init_samr_r_get_usrdom_pwinfo(r_u, NT_STATUS_NOPROBLEMO); + + DEBUG(5,("_samr_get_usrdom_pwinfo: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* + samr_make_usr_obj_sd + ********************************************************************/ + +static uint32 samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC_BUF **buf, DOM_SID *usr_sid) +{ + extern DOM_SID global_sid_Builtin; + extern DOM_SID global_sid_World; + DOM_SID adm_sid; + DOM_SID act_sid; + + SEC_ACE ace[4]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + SEC_DESC *psd = NULL; + size_t sd_size; + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + sid_copy(&act_sid, &global_sid_Builtin); + sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + + init_sec_access(&mask, 0x2035b); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + init_sec_access(&mask, 0xf07ff); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + init_sec_access(&mask,0x20044); + init_sec_ace(&ace[3], usr_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 4, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if((psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, &sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + if((*buf = make_sec_desc_buf(ctx, sd_size, psd)) == NULL) + return NT_STATUS_NO_MEMORY; + + return NT_STATUS_NOPROBLEMO; +} + +/******************************************************************* + _samr_query_sec_obj + ********************************************************************/ + +uint32 _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_QUERY_SEC_OBJ *r_u) +{ + DOM_SID pol_sid; + + r_u->status = NT_STATUS_NOPROBLEMO; + + /* find the policy handle. open a policy on it. */ + if ((find_lsa_policy_by_hnd(&q_u->user_pol)) == -1) + return NT_STATUS_INVALID_HANDLE; + + /* Get the SID. */ + if (!get_lsa_policy_samr_sid(&q_u->user_pol, &pol_sid)) + return NT_STATUS_OBJECT_TYPE_MISMATCH; + + r_u->status = samr_make_usr_obj_sd(p->mem_ctx, &r_u->buf, &pol_sid); + + if (r_u->status == NT_STATUS_NOPROBLEMO) + r_u->ptr = 1; + + return r_u->status; +} + +/******************************************************************* +makes a SAM_ENTRY / UNISTR2* structure from a user list. +********************************************************************/ + +static void make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNISTR2 **uni_name_pp, + uint32 num_sam_entries, SAM_USER_INFO_21 *pass) +{ + uint32 i; + SAM_ENTRY *sam; + UNISTR2 *uni_name; + + *sam_pp = NULL; + *uni_name_pp = NULL; + + if (num_sam_entries == 0) + return; + + sam = (SAM_ENTRY *)talloc(ctx, sizeof(SAM_ENTRY)*num_sam_entries); + + uni_name = (UNISTR2 *)talloc(ctx, sizeof(UNISTR2)*num_sam_entries); + + if (sam == NULL || uni_name == NULL) { + DEBUG(0, ("NULL pointers in SAMR_R_QUERY_DISPINFO\n")); + return; + } + + for (i = 0; i < num_sam_entries; i++) { + int len = pass[i].uni_user_name.uni_str_len; + + init_sam_entry(&sam[i], len, pass[i].user_rid); + copy_unistr2(&uni_name[i], &pass[i].uni_user_name); + } + + *sam_pp = sam; + *uni_name_pp = uni_name; +} + +/******************************************************************* + samr_reply_enum_dom_users + ********************************************************************/ + +uint32 _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_R_ENUM_DOM_USERS *r_u) +{ + SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; + int num_entries = 0; + int total_entries = 0; + BOOL ret; + + r_u->status = NT_STATUS_NOPROBLEMO; + + /* find the policy handle. open a policy on it. */ + if (find_lsa_policy_by_hnd(&q_u->pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); + + become_root(); + ret = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, + MAX_SAM_ENTRIES, q_u->acb_mask); + unbecome_root(); + + if (!ret) + return NT_STATUS_ACCESS_DENIED; + + /* + * Note from JRA. total_entries is not being used here. Currently if there is a + * large user base then it looks like NT will enumerate until get_sampwd_entries + * returns False due to num_entries being zero. This will cause an access denied + * return. I don't think this is right and needs further investigation. Note that + * this is also the same in the TNG code (I don't think that has been tested with + * a very large user list as MAX_SAM_ENTRIES is set to 600). + * + * I also think that one of the 'num_entries' return parameters is probably + * the "max entries" parameter - but in the TNG code they're all currently set to the same + * value (again I think this is wrong). + */ + + make_user_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_acct_name, num_entries, pass); + + init_samr_r_enum_dom_users(r_u, q_u->start_idx + num_entries, num_entries); + + DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* +makes a SAM_ENTRY / UNISTR2* structure from a group list. +********************************************************************/ + +static void make_group_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNISTR2 **uni_name_pp, + uint32 num_sam_entries, DOMAIN_GRP *grp) +{ + uint32 i; + SAM_ENTRY *sam; + UNISTR2 *uni_name; + + *sam_pp = NULL; + *uni_name_pp = NULL; + + if (num_sam_entries == 0) + return; + + sam = (SAM_ENTRY *)talloc(ctx, sizeof(SAM_ENTRY)*num_sam_entries); + + uni_name = (UNISTR2 *)talloc(ctx, sizeof(UNISTR2)*num_sam_entries); + + if (sam == NULL || uni_name == NULL) { + DEBUG(0, ("NULL pointers in SAMR_R_QUERY_DISPINFO\n")); + return; + } + + for (i = 0; i < num_sam_entries; i++) { + /* + * JRA. I think this should include the null. TNG does not. + */ + int len = strlen(grp[i].name)+1; + + init_sam_entry(&sam[i], len, grp[i].rid); + init_unistr2(&uni_name[i], grp[i].name, len); + } + + *sam_pp = sam; + *uni_name_pp = uni_name; +} + +/******************************************************************* + 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, + uint32 *p_num_entries, uint32 max_entries) +{ + fstring sid_str; + fstring sam_sid_str; + uint32 num_entries = 0; + + sid_to_string(sid_str, sid); + sid_to_string(sam_sid_str, &global_sam_sid); + + *p_num_entries = 0; + + /* well-known aliases */ + if (strequal(sid_str, "S-1-5-32")) { + char *name; + while (!lp_hide_local_users() && + num_entries < max_entries && + ((name = builtin_alias_rids[num_entries].name) != NULL)) { + + fstrcpy(d_grp[num_entries].name, name); + d_grp[num_entries].rid = builtin_alias_rids[num_entries].rid; + + num_entries++; + } + } else if (strequal(sid_str, sam_sid_str) && !lp_hide_local_users()) { + char *name; + char *sep; + struct group *grp; + + sep = lp_winbind_separator(); + + /* local aliases */ + /* we return the UNIX groups here. This seems to be the right */ + /* thing to do, since NT member servers return their local */ + /* groups in the same situation. */ + setgrent(); + + while (num_entries < max_entries && ((grp = getgrent()) != NULL)) { + int i; + uint32 trid; + name = grp->gr_name; + + /* Don't return winbind groups as they are not local! */ + + if (strchr(name, *sep) != NULL) + continue; + + trid = pdb_gid_to_group_rid(grp->gr_gid); + for( i = 0; i < num_entries; i++) + if ( d_grp[i].rid == trid ) break; + + if ( i < num_entries ) + continue; /* rid was there, dup! */ + + /* JRA - added this for large group db enumeration... */ + + if (start_idx > 0) { + /* skip the requested number of entries. + not very efficient, but hey... + */ + start_idx--; + continue; + } + + fstrcpy(d_grp[num_entries].name, name); + d_grp[num_entries].rid = trid; + num_entries++; + } + + endgrent(); + } + + *p_num_entries = num_entries; + + return True; +} + +/******************************************************************* + Get the group entries - similar to get_sampwd_entries(). + ********************************************************************/ + +static BOOL get_group_domain_entries(DOMAIN_GRP *d_grp, DOM_SID *sid, uint32 start_idx, + uint32 *p_num_entries, uint32 max_entries) +{ + fstring sid_str; + fstring sam_sid_str; + uint32 num_entries = 0; + fstring name="Domain Admins"; + fstring comment="Just to make it work !"; + + sid_to_string(sid_str, sid); + sid_to_string(sam_sid_str, &global_sam_sid); + + *p_num_entries = 0; + + fstrcpy(d_grp[0].name, name); + fstrcpy(d_grp[0].comment, comment); + d_grp[0].rid = DOMAIN_GROUP_RID_ADMINS; + d_grp[0].attr=SID_NAME_DOM_GRP; + + fstrcpy(d_grp[1].name, "Domain Users"); + fstrcpy(d_grp[1].comment, "Just to make it work !"); + d_grp[1].rid = DOMAIN_GROUP_RID_USERS; + d_grp[1].attr=SID_NAME_DOM_GRP; + + num_entries = 2; + + *p_num_entries = num_entries; + + return True; +} + +/******************************************************************* + samr_reply_enum_dom_groups + Only reply with one group - domain admins. This must be fixed for + a real PDC. JRA. + ********************************************************************/ + +uint32 _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_R_ENUM_DOM_GROUPS *r_u) +{ + DOMAIN_GRP grp[2]; + int num_entries; + DOM_SID sid; + + r_u->status = NT_STATUS_NOPROBLEMO; + + if (!get_lsa_policy_samr_sid(&q_u->pol, &sid)) + return NT_STATUS_INVALID_HANDLE; + + DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); + + get_group_domain_entries(grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); + + make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp); + + init_samr_r_enum_dom_groups(r_u, q_u->start_idx, num_entries); + + DEBUG(5,("samr_enum_dom_groups: %d\n", __LINE__)); + + return r_u->status; +} + + +/******************************************************************* + samr_reply_enum_dom_aliases + ********************************************************************/ + +uint32 _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, SAMR_R_ENUM_DOM_ALIASES *r_u) +{ + DOMAIN_GRP grp[MAX_SAM_ENTRIES]; + int num_entries = 0; + fstring sid_str; + DOM_SID sid; + + r_u->status = NT_STATUS_NOPROBLEMO; + + /* find the policy handle. open a policy on it. */ + if (!get_lsa_policy_samr_sid(&q_u->pol, &sid)) + return NT_STATUS_INVALID_HANDLE; + + 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; + + 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); + + DEBUG(5,("samr_enum_dom_aliases: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* + samr_reply_query_dispinfo + ********************************************************************/ + +uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_QUERY_DISPINFO *r_u) +{ + SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; + DOMAIN_GRP grps[MAX_SAM_ENTRIES]; + uint16 acb_mask = ACB_NORMAL; + int num_entries = 0; + int orig_num_entries = 0; + int total_entries = 0; + uint32 data_size = 0; + DOM_SID sid; + BOOL ret; + SAM_DISPINFO_CTR *ctr; + + DEBUG(5, ("samr_reply_query_dispinfo: %d\n", __LINE__)); + + r_u->status = NT_STATUS_NOPROBLEMO; + + if (!get_lsa_policy_samr_sid(&q_u->domain_pol, &sid)) + return NT_STATUS_INVALID_HANDLE; + + /* decide how many entries to get depending on the max_entries + and max_size passed by client */ + + if(q_u->max_entries > MAX_SAM_ENTRIES) + q_u->max_entries = MAX_SAM_ENTRIES; + + /* Get what we need from the password database */ + switch (q_u->switch_level) { + case 0x2: + acb_mask = ACB_WSTRUST; + /* Fall through */ + case 0x1: + case 0x4: + become_root(); +#if 0 + ret = get_passwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, + MAX_SAM_ENTRIES, acb_mask); +#endif +#if 0 + /* + * Which should we use here ? JRA. + */ + ret = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, + MAX_SAM_ENTRIES, acb_mask); +#endif +#if 1 + ret = jf_get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, + MAX_SAM_ENTRIES, acb_mask); +#endif + unbecome_root(); + if (!ret) { + DEBUG(5, ("get_sampwd_entries: failed\n")); + return NT_STATUS_ACCESS_DENIED; + } + break; + case 0x3: + case 0x5: + ret = get_group_domain_entries(grps, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); + if (!ret) + return NT_STATUS_ACCESS_DENIED; + break; + default: + DEBUG(0,("_samr_query_dispinfo: Unknown info level (%u)\n", (unsigned int)q_u->switch_level )); + return NT_STATUS_INVALID_INFO_CLASS; + } + + + if (num_entries > q_u->max_entries) + num_entries = q_u->max_entries; + + if (num_entries > MAX_SAM_ENTRIES) { + num_entries = MAX_SAM_ENTRIES; + DEBUG(5, ("limiting number of entries to %d\n", num_entries)); + } + + data_size = q_u->max_size; + orig_num_entries = num_entries; + + ctr = (SAM_DISPINFO_CTR *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_CTR)); + + /* Now create reply structure */ + switch (q_u->switch_level) { + case 0x1: + ctr->sam.info1 = (SAM_DISPINFO_1 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_1)); + init_sam_dispinfo_1(ctr->sam.info1, &num_entries, &data_size, q_u->start_idx, pass); + break; + case 0x2: + ctr->sam.info2 = (SAM_DISPINFO_2 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_2)); + init_sam_dispinfo_2(ctr->sam.info2, &num_entries, &data_size, q_u->start_idx, pass); + break; + case 0x3: + ctr->sam.info3 = (SAM_DISPINFO_3 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_3)); + init_sam_dispinfo_3(ctr->sam.info3, &num_entries, &data_size, q_u->start_idx, grps); + break; + case 0x4: + ctr->sam.info4 = (SAM_DISPINFO_4 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_4)); + init_sam_dispinfo_4(ctr->sam.info4, &num_entries, &data_size, q_u->start_idx, pass); + break; + case 0x5: + ctr->sam.info5 = (SAM_DISPINFO_5 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_5)); + init_sam_dispinfo_5(ctr->sam.info5, &num_entries, &data_size, q_u->start_idx, grps); + break; + default: + ctr->sam.info = NULL; + return NT_STATUS_INVALID_INFO_CLASS; + } + + DEBUG(5, ("_samr_query_dispinfo: %d\n", __LINE__)); + + init_samr_r_query_dispinfo(r_u, num_entries, data_size, q_u->switch_level, ctr, r_u->status); + + if (num_entries < orig_num_entries) { + return STATUS_MORE_ENTRIES; + } + + return r_u->status; +} + +/******************************************************************* + samr_reply_query_aliasinfo + ********************************************************************/ + +uint32 _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_R_QUERY_ALIASINFO *r_u) +{ + fstring alias_desc = "Local Unix group"; + fstring alias=""; + enum SID_NAME_USE type; + uint32 alias_rid; + + r_u->status = NT_STATUS_NOPROBLEMO; + + DEBUG(5,("_samr_query_aliasinfo: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (find_lsa_policy_by_hnd(&q_u->pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + alias_rid = get_lsa_policy_samr_rid(&q_u->pol); + if(alias_rid == 0xffffffff) + return NT_STATUS_NO_SUCH_ALIAS; + + if(!local_lookup_rid(alias_rid, alias, &type)) + return NT_STATUS_NO_SUCH_ALIAS; + + switch (q_u->switch_level) { + case 3: + r_u->ptr = 1; + r_u->ctr.switch_value1 = 3; + init_samr_alias_info3(&r_u->ctr.alias.info3, alias_desc); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + } + + DEBUG(5,("_samr_query_aliasinfo: %d\n", __LINE__)); + + return r_u->status; +} + +#if 0 +/******************************************************************* + samr_reply_lookup_ids + ********************************************************************/ + + uint32 _samr_lookup_ids(pipes_struct *p, SAMR_Q_LOOKUP_IDS *q_u, SAMR_R_LOOKUP_IDS *r_u) +{ + uint32 rid[MAX_SAM_ENTRIES]; + int num_rids = q_u->num_sids1; + + r_u->status = NT_STATUS_NOPROBLEMO; + + DEBUG(5,("_samr_lookup_ids: %d\n", __LINE__)); + + if (num_rids > MAX_SAM_ENTRIES) { + num_rids = MAX_SAM_ENTRIES; + DEBUG(5,("_samr_lookup_ids: truncating entries to %d\n", num_rids)); + } + +#if 0 + int i; + SMB_ASSERT_ARRAY(q_u->uni_user_name, num_rids); + + for (i = 0; i < num_rids && status == 0; i++) + { + struct sam_passwd *sam_pass; + fstring user_name; + + + fstrcpy(user_name, unistrn2(q_u->uni_user_name[i].buffer, + q_u->uni_user_name[i].uni_str_len)); + + /* find the user account */ + become_root(); + sam_pass = get_smb21pwd_entry(user_name, 0); + unbecome_root(); + + if (sam_pass == NULL) + { + status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; + rid[i] = 0; + } + else + { + rid[i] = sam_pass->user_rid; + } + } +#endif + + num_rids = 1; + rid[0] = BUILTIN_ALIAS_RID_USERS; + + init_samr_r_lookup_ids(&r_u, num_rids, rid, NT_STATUS_NOPROBLEMO); + + DEBUG(5,("_samr_lookup_ids: %d\n", __LINE__)); + + return r_u->status; +} +#endif + +/******************************************************************* + _samr_lookup_names + ********************************************************************/ + +uint32 _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOKUP_NAMES *r_u) +{ + uint32 rid[MAX_SAM_ENTRIES]; + enum SID_NAME_USE type[MAX_SAM_ENTRIES]; + int i; + int num_rids = q_u->num_names1; + DOM_SID pol_sid; + + r_u->status = NT_STATUS_NOPROBLEMO; + + DEBUG(5,("_samr_lookup_names: %d\n", __LINE__)); + + ZERO_ARRAY(rid); + ZERO_ARRAY(type); + + if (!get_lsa_policy_samr_sid(&q_u->pol, &pol_sid)) { + init_samr_r_lookup_names(p->mem_ctx, r_u, 0, NULL, NULL, NT_STATUS_OBJECT_TYPE_MISMATCH); + return r_u->status; + } + + if (num_rids > MAX_SAM_ENTRIES) { + num_rids = MAX_SAM_ENTRIES; + DEBUG(5,("_samr_lookup_names: truncating entries to %d\n", num_rids)); + } + + SMB_ASSERT_ARRAY(q_u->uni_name, num_rids); + + for (i = 0; i < num_rids; i++) { + fstring name; + + r_u->status = NT_STATUS_NONE_MAPPED; + + rid [i] = 0xffffffff; + type[i] = SID_NAME_UNKNOWN; + + fstrcpy(name, dos_unistrn2(q_u->uni_name[i].buffer, q_u->uni_name[i].uni_str_len)); + + if(sid_equal(&pol_sid, &global_sam_sid)) { + 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; + } + } + } + + init_samr_r_lookup_names(p->mem_ctx, r_u, num_rids, rid, type, r_u->status); + + DEBUG(5,("_samr_lookup_names: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* + _samr_chgpasswd_user + ********************************************************************/ + +uint32 _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_R_CHGPASSWD_USER *r_u) +{ + fstring user_name; + fstring wks; + + DEBUG(5,("_samr_chgpasswd_user: %d\n", __LINE__)); + + r_u->status = NT_STATUS_NOPROBLEMO; + + 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)); + + DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); + + if (!pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, + q_u->nt_newpass.pass, q_u->nt_oldhash.hash)) + r_u->status = NT_STATUS_WRONG_PASSWORD; + + init_samr_r_chgpasswd_user(r_u, r_u->status); + + DEBUG(5,("_samr_chgpasswd_user: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* +makes a SAMR_R_LOOKUP_RIDS structure. +********************************************************************/ + +static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, fstring names[], + UNIHDR **pp_hdr_name, UNISTR2 **pp_uni_name) +{ + uint32 i; + UNIHDR *hdr_name; + UNISTR2 *uni_name; + + *pp_uni_name = NULL; + *pp_hdr_name = NULL; + + if (num_names != 0) { + hdr_name = (UNIHDR *)talloc(ctx, sizeof(UNIHDR)*num_names); + if (hdr_name == NULL) + return False; + + uni_name = (UNISTR2 *)talloc(ctx,sizeof(UNISTR2)*num_names); + if (uni_name == NULL) + return False; + } + + for (i = 0; i < num_names; i++) { + int len = names[i] != NULL ? strlen(names[i]) : 0; + DEBUG(10, ("names[%d]:%s\n", i, names[i])); + init_uni_hdr(&hdr_name[i], len); + init_unistr2(&uni_name[i], names[i], len); + } + + *pp_uni_name = uni_name; + *pp_hdr_name = hdr_name; + + return True; +} + +/******************************************************************* + _samr_lookup_rids + ********************************************************************/ + +uint32 _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP_RIDS *r_u) +{ + fstring group_names[MAX_SAM_ENTRIES]; + uint32 group_attrs[MAX_SAM_ENTRIES]; + UNIHDR *hdr_name = NULL; + UNISTR2 *uni_name = NULL; + DOM_SID pol_sid; + int num_rids = q_u->num_rids1; + int i; + + r_u->status = NT_STATUS_NOPROBLEMO; + + DEBUG(5,("_samr_lookup_rids: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (!get_lsa_policy_samr_sid(&q_u->pol, &pol_sid)) + return NT_STATUS_INVALID_HANDLE; + + if (num_rids > MAX_SAM_ENTRIES) { + num_rids = MAX_SAM_ENTRIES; + DEBUG(5,("_samr_lookup_rids: truncating entries to %d\n", num_rids)); + } + + r_u->status = NT_STATUS_NONE_MAPPED; + + for (i = 0; i < num_rids; i++) { + fstring tmpname; + fstring domname; + DOM_SID sid; + enum SID_NAME_USE type; + + group_attrs[i] = SID_NAME_UNKNOWN; + *group_names[i] = '\0'; + + if (sid_equal(&pol_sid, &global_sam_sid)) { + sid_copy(&sid, &pol_sid); + sid_append_rid(&sid, q_u->rid[i]); + + if (lookup_sid(&sid, domname, tmpname, &type)) { + r_u->status = NT_STATUS_NOPROBLEMO; + group_attrs[i] = (uint32)type; + fstrcpy(group_names[i],tmpname); + } + } + } + + if(!make_samr_lookup_rids(p->mem_ctx, num_rids, group_names, &hdr_name, &uni_name)) + return NT_STATUS_NO_MEMORY; + + init_samr_r_lookup_rids(r_u, num_rids, hdr_name, uni_name, group_attrs); + + DEBUG(5,("_samr_lookup_rids: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* + _api_samr_open_user + ********************************************************************/ + +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; + + r_u->status = NT_STATUS_NO_PROBLEMO; + + /* find the domain policy handle. */ + if (find_lsa_policy_by_hnd(&domain_pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + /* get a (unique) handle. open a policy on it. */ + if (!open_lsa_policy_hnd(user_pol)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + become_root(); + sam_pass = getsam21pwrid(user_rid); + unbecome_root(); + + /* check that the RID exists in our domain. */ + if (sam_pass == NULL) { + close_lsa_policy_hnd(user_pol); + return NT_STATUS_NO_SUCH_USER; + } + + /* Get the domain SID stored in the domain policy */ + if(!get_lsa_policy_samr_sid(&domain_pol, &sid)) { + close_lsa_policy_hnd(user_pol); + return NT_STATUS_INVALID_HANDLE; + } + + /* append the user's RID to it */ + if(!sid_append_rid(&sid, user_rid)) { + close_lsa_policy_hnd(user_pol); + return NT_STATUS_NO_SUCH_USER; + } + + /* associate the user's SID with the handle. */ + if (!set_lsa_policy_samr_sid(user_pol, &sid)) { + /* oh, whoops. don't know what error message to return, here */ + close_lsa_policy_hnd(user_pol); + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + return r_u->status; +} + +/************************************************************************* + get_user_info_10 + *************************************************************************/ + +static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) +{ + struct smb_passwd *smb_pass; + + 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(); + + if (smb_pass == NULL) + { + DEBUG(4,("User 0x%x not found\n", user_rid)); + return False; + } + + DEBUG(3,("User:[%s]\n", smb_pass->smb_name)); + + init_sam_user_info10(id10, smb_pass->acct_ctrl); + + return True; +} + +/************************************************************************* + get_user_info_12 + *************************************************************************/ + +static BOOL get_user_info_12(SAM_USER_INFO_12 * id12, uint32 user_rid) +{ + struct smb_passwd *smb_pass; + + become_root(); + smb_pass = getsmbpwrid(user_rid); + unbecome_root(); + + if (smb_pass == NULL) { + DEBUG(4, ("User 0x%x not found\n", user_rid)); + return False; + } + + DEBUG(3,("User:[%s] 0x%x\n", smb_pass->smb_name, smb_pass->acct_ctrl)); + + if (smb_pass->acct_ctrl & ACB_DISABLED) + return False; + + init_sam_user_info12(id12, smb_pass->smb_passwd, smb_pass->smb_nt_passwd); + + return True; +} + +/************************************************************************* + get_user_info_21 + *************************************************************************/ + +static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) +{ + NTTIME dummy_time; + struct sam_passwd *sam_pass; + LOGON_HRS hrs; + int i; + + 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(); + + if (sam_pass == NULL) { + DEBUG(4,("User 0x%x not found\n", user_rid)); + return False; + } + + DEBUG(3,("User:[%s]\n", sam_pass->smb_name)); + + dummy_time.low = 0xffffffff; + dummy_time.high = 0x7fffffff; + + DEBUG(5,("get_user_info_21 - TODO: convert unix times to NTTIMEs\n")); + + /* 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]; + + init_sam_user_info21A(id21, + + &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 */ + + 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 */ + + sam_pass->user_rid, /* RID user_id */ + sam_pass->group_rid, /* RID group_id */ + sam_pass->acct_ctrl, + + sam_pass->unknown_3, /* unknown_3 */ + sam_pass->logon_divs, /* divisions per week */ + &hrs, /* logon hours */ + sam_pass->unknown_5, + sam_pass->unknown_6); + + return True; +} + +/******************************************************************* + _samr_query_userinfo + ********************************************************************/ + +uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_QUERY_USERINFO *r_u) +{ + SAM_USERINFO_CTR *ctr; + uint32 rid = 0; + + r_u->status=NT_STATUS_NO_PROBLEMO; + + /* search for the handle */ + if (find_lsa_policy_by_hnd(&q_u->pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + /* find the user's rid */ + if ((rid = get_lsa_policy_samr_rid(&q_u->pol)) == 0xffffffff) + return NT_STATUS_OBJECT_TYPE_MISMATCH; + + DEBUG(5,("_samr_query_userinfo: rid:0x%x\n", rid)); + + ctr = (SAM_USERINFO_CTR *)talloc(p->mem_ctx, sizeof(SAM_USERINFO_CTR)); + if (!ctr) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(ctr); + + /* ok! user info levels (lots: see MSDEV help), off we go... */ + ctr->switch_value = q_u->switch_value; + + switch (q_u->switch_value) { + case 0x10: + ctr->info.id10 = (SAM_USER_INFO_10 *)talloc(p->mem_ctx, sizeof(SAM_USER_INFO_10)); + if (ctr->info.id10 == NULL) + return NT_STATUS_NO_MEMORY; + + if (!get_user_info_10(ctr->info.id10, rid)) + return NT_STATUS_NO_SUCH_USER; + break; + +#if 0 +/* whoops - got this wrong. i think. or don't understand what's happening. */ + case 0x11: + { + NTTIME expire; + info = (void *)&id11; + + expire.low = 0xffffffff; + expire.high = 0x7fffffff; + + ctr->info.id = (SAM_USER_INFO_11 *)talloc(p->mem_ctx, + sizeof + (*ctr-> + info. + id11)); + init_sam_user_info11(ctr->info.id11, &expire, + "BROOKFIELDS$", /* name */ + 0x03ef, /* user rid */ + 0x201, /* group rid */ + 0x0080); /* acb info */ + + break; + } +#endif + + case 0x12: + ctr->info.id12 = (SAM_USER_INFO_12 *)talloc(p->mem_ctx, sizeof(SAM_USER_INFO_12)); + if (ctr->info.id12 == NULL) + return NT_STATUS_NO_MEMORY; + + if (!get_user_info_12(ctr->info.id12, rid)) + return NT_STATUS_NO_SUCH_USER; + break; + + case 21: + ctr->info.id21 = (SAM_USER_INFO_21 *)talloc(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)) + return NT_STATUS_NO_SUCH_USER; + break; + + default: + return NT_STATUS_INVALID_INFO_CLASS; + } + + init_samr_r_query_userinfo(r_u, ctr, r_u->status); + + DEBUG(5,("_samr_query_userinfo: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* + samr_reply_query_usergroups + ********************************************************************/ + +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; + + r_u->status = NT_STATUS_NO_PROBLEMO; + + DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (find_lsa_policy_by_hnd(&q_u->pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + /* find the user's rid */ + if ((rid = get_lsa_policy_samr_rid(&q_u->pol)) == 0xffffffff) + return NT_STATUS_OBJECT_TYPE_MISMATCH; + + become_root(); + sam_pass = getsam21pwrid(rid); + unbecome_root(); + + if (sam_pass == NULL) + 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); + + /* 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__)); + + return r_u->status; +} + +/******************************************************************* + _samr_query_dom_info + ********************************************************************/ + +uint32 _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR_R_QUERY_DOMAIN_INFO *r_u) +{ + SAM_UNK_CTR *ctr; + uint16 switch_value = 0; + + if ((ctr = (SAM_UNK_CTR *)talloc(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(ctr); + + r_u->status = NT_STATUS_NO_PROBLEMO; + + DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (find_lsa_policy_by_hnd(&q_u->domain_pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + switch (q_u->switch_value) { + case 0x01: + switch_value = 0x1; + init_unk_info1(&ctr->info.inf1); + break; + case 0x02: + switch_value = 0x2; + /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ + init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL)); + break; + case 0x03: + switch_value = 0x3; + init_unk_info3(&ctr->info.inf3); + break; + case 0x06: + switch_value = 0x6; + init_unk_info6(&ctr->info.inf6); + break; + case 0x07: + switch_value = 0x7; + init_unk_info7(&ctr->info.inf7); + break; + case 0x0c: + switch_value = 0xc; + init_unk_info12(&ctr->info.inf12); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + break; + } + + init_samr_r_query_dom_info(r_u, q_u->switch_value, ctr, NT_STATUS_NOPROBLEMO); + + DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* + _api_samr_create_user + ********************************************************************/ + +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; + 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; + + /* find the policy handle. open a policy on it. */ + if (find_lsa_policy_by_hnd(&dom_pol) == -1) + 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; + } + + /* get a (unique) handle. open a policy on it. */ + if (!open_lsa_policy_hnd(user_pol)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + 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)); + close_lsa_policy_hnd(user_pol); + return NT_STATUS_ACCESS_DENIED; + } + + become_root(); + sam_pass = getsam21pwnam(mach_acct); + unbecome_root(); + if (sam_pass == NULL) { + /* account doesn't exist: say so */ + close_lsa_policy_hnd(user_pol); + return NT_STATUS_ACCESS_DENIED; + } + + /* Get the domain SID stored in the domain policy */ + if(!get_lsa_policy_samr_sid(&dom_pol, &sid)) { + close_lsa_policy_hnd(user_pol); + return NT_STATUS_INVALID_HANDLE; + } + + /* append the user's RID to it */ + if(!sid_append_rid(&sid, sam_pass->user_rid)) { + close_lsa_policy_hnd(user_pol); + return NT_STATUS_NO_SUCH_USER; + } + + /* associate the SID with the (unique) handle. */ + if (!set_lsa_policy_samr_sid(user_pol, &sid)) { + /* oh, whoops. don't know what error message to return, here */ + close_lsa_policy_hnd(user_pol); + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + r_u->user_rid=sam_pass->user_rid; + r_u->unknown_0 = 0x000703ff; + + return NT_STATUS_NO_PROBLEMO; +} + +/******************************************************************* + samr_reply_connect_anon + ********************************************************************/ + +uint32 _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CONNECT_ANON *r_u) +{ + /* set up the SAMR connect_anon response */ + + r_u->status = NT_STATUS_NO_PROBLEMO; + + /* get a (unique) handle. open a policy on it. */ + if (!open_lsa_policy_hnd(&r_u->connect_pol)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + /* associate the domain SID with the (unique) handle. */ + if (!set_lsa_policy_samr_pol_status(&r_u->connect_pol, q_u->unknown_0)) { + close_lsa_policy_hnd(&r_u->connect_pol); + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + return r_u->status; +} + +/******************************************************************* + samr_reply_connect + ********************************************************************/ + +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; + + /* get a (unique) handle. open a policy on it. */ + if (!open_lsa_policy_hnd(&r_u->connect_pol)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + /* associate the domain SID with the (unique) handle. */ + if (!set_lsa_policy_samr_pol_status(&r_u->connect_pol, q_u->access_mask)) { + close_lsa_policy_hnd(&r_u->connect_pol); + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + DEBUG(5,("_samr_connect: %d\n", __LINE__)); + + return r_u->status; +} + +/********************************************************************** + api_samr_lookup_domain + **********************************************************************/ + +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; + + if (find_lsa_policy_by_hnd(&q_u->connect_pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + /* assume the domain name sent is our global_myname and + send global_sam_sid */ + init_samr_r_lookup_domain(r_u, &global_sam_sid, r_u->status); + + return r_u->status; +} + +/****************************************************************** +makes a SAMR_R_ENUM_DOMAINS structure. +********************************************************************/ + +static BOOL make_enum_domains(TALLOC_CTX *ctx, SAM_ENTRY **pp_sam, + UNISTR2 **pp_uni_name, uint32 num_sam_entries, fstring doms[]) +{ + uint32 i; + SAM_ENTRY *sam; + UNISTR2 *uni_name; + + DEBUG(5, ("make_enum_domains\n")); + + *pp_sam = NULL; + *pp_uni_name = NULL; + + 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); + + if (sam == NULL || uni_name == NULL) + return False; + + for (i = 0; i < num_sam_entries; i++) { + int len = doms[i] != NULL ? strlen(doms[i]) : 0; + + init_sam_entry(&sam[i], len, 0); + init_unistr2(&uni_name[i], doms[i], len); + } + + *pp_sam = sam; + *pp_uni_name = uni_name; + + return True; +} + +/********************************************************************** + api_samr_enum_domains + **********************************************************************/ + +uint32 _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_ENUM_DOMAINS *r_u) +{ + uint32 num_entries = 2; + fstring dom[2]; + + r_u->status = NT_STATUS_NO_PROBLEMO; + + fstrcpy(dom[0],global_myworkgroup); + fstrcpy(dom[1],"Builtin"); + + if (!make_enum_domains(p->mem_ctx, &r_u->sam, &r_u->uni_dom_name, num_entries, dom)) + return NT_STATUS_NO_MEMORY; + + init_samr_r_enum_domains(r_u, q_u->start_idx + num_entries, num_entries); + + return r_u->status; +} + +/******************************************************************* + api_samr_open_alias + ********************************************************************/ + +uint32 _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_ALIAS *r_u) +{ + DOM_SID sid; + POLICY_HND domain_pol = q_u->dom_pol; + uint32 alias_rid = q_u->rid_alias; + POLICY_HND *alias_pol = &r_u->pol; + + r_u->status = NT_STATUS_NO_PROBLEMO; + + /* get the domain policy. */ + if (find_lsa_policy_by_hnd(&domain_pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + /* get a (unique) handle. open a policy on it. */ + if (!open_lsa_policy_hnd(alias_pol)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + /* Get the domain SID stored in the domain policy */ + if(!get_lsa_policy_samr_sid(&domain_pol, &sid)) { + close_lsa_policy_hnd(alias_pol); + return NT_STATUS_INVALID_HANDLE; + } + + /* + * we should check if the rid really exist !!! + * JFM. + */ + + + /* append the alias' RID to it */ + if(!sid_append_rid(&sid, alias_rid)) { + close_lsa_policy_hnd(alias_pol); + return NT_STATUS_NO_SUCH_USER; + } + + /* associate a SID with the (unique) handle. */ + if (!set_lsa_policy_samr_sid(alias_pol, &sid)) { + /* oh, whoops. don't know what error message to return, here */ + close_lsa_policy_hnd(alias_pol); + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + return r_u->status; +} + +/******************************************************************* + set_user_info_10 + ********************************************************************/ + +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; + + if (id10 == NULL) { + DEBUG(5, ("set_user_info_10: NULL id10\n")); + return False; + } + + if (pwd == NULL) + return False; + + copy_sam_passwd(&new_pwd, pwd); + + new_pwd.acct_ctrl = id10->acb_info; + + if(!mod_sam21pwd_entry(&new_pwd, True)) + return False; + + return True; +} + +/******************************************************************* + set_user_info_12 + ********************************************************************/ + +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]; + + if (pwd == NULL) + return False; + + if (id12 == NULL) { + DEBUG(2, ("set_user_info_12: id12 is NULL\n")); + 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)) + return False; + + return True; +} + +/******************************************************************* + set_user_info_21 + ********************************************************************/ + +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]; + + if (id21 == NULL) { + DEBUG(5, ("set_user_info_21: NULL id21\n")); + return False; + } + + if (pwd == NULL) + return False; + + 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)) + return False; + + return True; +} + +/******************************************************************* + set_user_info_23 + ********************************************************************/ + +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]; + pstring buf; + uint32 len; + + if (id23 == NULL) { + DEBUG(5, ("set_user_info_23: NULL id23\n")); + return False; + } + + if (pwd == NULL) + return False; + + 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)) + return False; + + new_pwd.smb_passwd = lm_hash; + new_pwd.smb_nt_passwd = nt_hash; + + /* 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) ) { + 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)) + return False; + } + + memset(buf, 0, sizeof(buf)); + + if(!mod_sam21pwd_entry(&new_pwd, True)) + return False; + + return True; +} + +/******************************************************************* + set_user_info_24 + ********************************************************************/ + +static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) +{ + struct sam_passwd *pwd = getsam21pwrid(rid); + struct sam_passwd new_pwd; + static uchar nt_hash[16]; + static uchar lm_hash[16]; + uint32 len; + pstring buf; + + if (pwd == NULL) + return False; + + pdb_init_sam(&new_pwd); + copy_sam_passwd(&new_pwd, pwd); + + memset(buf, 0, sizeof(pstring)); + + if (!decode_pw_buffer((char*)id24->pass, buf, 256, &len, nt_hash, lm_hash)) + return False; + + new_pwd.smb_passwd = lm_hash; + new_pwd.smb_nt_passwd = nt_hash; + + /* 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) ) { + 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)) + return False; + } + + memset(buf, 0, sizeof(buf)); + + DEBUG(5,("set_user_info_24: pdb_update_sam_account()\n")); + + /* update the SAMBA password */ + if(!mod_sam21pwd_entry(&new_pwd, True)) + return False; + + return True; +} + +/******************************************************************* + samr_reply_set_userinfo + ********************************************************************/ + +uint32 _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_USERINFO *r_u) +{ + uint32 rid = 0x0; + DOM_SID sid; + struct current_user user; + struct smb_passwd *smb_pass; + 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; + + DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); + + r_u->status = NT_STATUS_NOPROBLEMO; + + if (p->ntlmssp_auth_validated) { + memcpy(&user, &p->pipe_user, sizeof(user)); + } else { + extern struct current_user current_user; + memcpy(&user, ¤t_user, sizeof(user)); + } + + /* search for the handle */ + if (find_lsa_policy_by_hnd(pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + /* find the policy handle. open a policy on it. */ + if (!get_lsa_policy_samr_sid(pol, &sid)) + return NT_STATUS_INVALID_HANDLE; + + sid_split_rid(&sid, &rid); + + DEBUG(5, ("_samr_set_userinfo: rid:0x%x, level:%d\n", rid, switch_value)); + + if (ctr == NULL) { + DEBUG(5, ("_samr_set_userinfo: NULL info level\n")); + return NT_STATUS_INVALID_INFO_CLASS; + } + + + /* + * 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" + * This "user session key" is in turn used to encrypt/decrypt the user's password. + */ + + become_root(); + smb_pass = getsmbpwuid(user.uid); + unbecome_root(); + if(smb_pass == NULL) { + DEBUG(0,("_samr_set_userinfo: Unable to get smbpasswd 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); + + /* ok! user info levels (lots: see MSDEV help), off we go... */ + switch (switch_value) { + case 0x12: + if (!set_user_info_12(ctr->info.id12, rid)) + return NT_STATUS_ACCESS_DENIED; + break; + + case 24: + SamOEMhash(ctr->info.id24->pass, sess_key, 1); + if (!set_user_info_24(ctr->info.id24, rid)) + return NT_STATUS_ACCESS_DENIED; + break; + + case 23: + SamOEMhash(ctr->info.id23->pass, sess_key, 1); + if (!set_user_info_23(ctr->info.id23, rid)) + return NT_STATUS_ACCESS_DENIED; + break; + + default: + return NT_STATUS_INVALID_INFO_CLASS; + } + + return r_u->status; +} + +/******************************************************************* + samr_reply_set_userinfo2 + ********************************************************************/ + +uint32 _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SET_USERINFO2 *r_u) +{ + DOM_SID sid; + uint32 rid = 0x0; + SAM_USERINFO_CTR *ctr = NULL; + POLICY_HND *pol = &q_u->pol; + uint16 switch_value = q_u->switch_value; + + DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__)); + + r_u->status = NT_STATUS_NOPROBLEMO; + + ctr = (SAM_USERINFO_CTR *)talloc(p->mem_ctx, sizeof(SAM_USERINFO_CTR)); + if (!ctr) + return NT_STATUS_NO_MEMORY; + + q_u->ctr = ctr; + + /* search for the handle */ + if (find_lsa_policy_by_hnd(pol) == -1) + return NT_STATUS_INVALID_HANDLE; + + /* find the policy handle. open a policy on it. */ + if (!get_lsa_policy_samr_sid(pol, &sid)) + return NT_STATUS_INVALID_HANDLE; + + sid_split_rid(&sid, &rid); + + DEBUG(5, ("samr_reply_set_userinfo2: rid:0x%x\n", rid)); + + if (ctr == NULL) { + DEBUG(5, ("samr_reply_set_userinfo2: NULL info level\n")); + return NT_STATUS_INVALID_INFO_CLASS; + } + + ctr->switch_value = switch_value; + + /* ok! user info levels (lots: see MSDEV help), off we go... */ + switch (switch_value) { + case 21: + if (!set_user_info_21(ctr->info.id21, rid)) + return NT_STATUS_ACCESS_DENIED; + break; + case 16: + if (!set_user_info_10(ctr->info.id10, rid)) + return NT_STATUS_ACCESS_DENIED; + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + } + + return r_u->status; +} + +/********************************************************************* + _samr_query_aliasmem +*********************************************************************/ + +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; +} + +/********************************************************************* + _samr_query_aliasmem +*********************************************************************/ + +uint32 _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_QUERY_ALIASMEM *r_u) +{ + DEBUG(0,("_samr_query_aliasmem: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_query_groupmem +*********************************************************************/ + +uint32 _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_QUERY_GROUPMEM *r_u) +{ + DEBUG(0,("_samr_query_groupmem: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_add_aliasmem +*********************************************************************/ + +uint32 _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_ADD_ALIASMEM *r_u) +{ + DEBUG(0,("_samr_add_aliasmem: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_del_aliasmem +*********************************************************************/ + +uint32 _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DEL_ALIASMEM *r_u) +{ + DEBUG(0,("_samr_del_aliasmem: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_add_groupmem +*********************************************************************/ + +uint32 _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_ADD_GROUPMEM *r_u) +{ + DEBUG(0,("_samr_add_groupmem: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_del_groupmem +*********************************************************************/ + +uint32 _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DEL_GROUPMEM *r_u) +{ + DEBUG(0,("_samr_del_groupmem: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_delete_dom_user +*********************************************************************/ + +uint32 _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAMR_R_DELETE_DOM_USER *r_u ) +{ + DEBUG(0,("_samr_delete_dom_user: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_delete_dom_group +*********************************************************************/ + +uint32 _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, SAMR_R_DELETE_DOM_GROUP *r_u) +{ + DEBUG(0,("_samr_delete_dom_group: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_delete_dom_alias +*********************************************************************/ + +uint32 _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, SAMR_R_DELETE_DOM_ALIAS *r_u) +{ + DEBUG(0,("_samr_delete_dom_alias: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_create_dom_group +*********************************************************************/ + +uint32 _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, SAMR_R_CREATE_DOM_GROUP *r_u) +{ + DEBUG(0,("_samr_create_dom_group: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_create_dom_alias +*********************************************************************/ + +uint32 _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, SAMR_R_CREATE_DOM_ALIAS *r_u) +{ + DEBUG(0,("_samr_create_dom_alias: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_query_groupinfo +*********************************************************************/ + +uint32 _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAMR_R_QUERY_GROUPINFO *r_u) +{ + DEBUG(0,("_samr_query_groupinfo: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_set_groupinfo +*********************************************************************/ + +uint32 _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_SET_GROUPINFO *r_u) +{ + DEBUG(0,("_samr_set_groupinfo: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_get_dom_pwinfo +*********************************************************************/ + +uint32 _samr_get_dom_pwinfo(pipes_struct *p, SAMR_Q_GET_DOM_PWINFO *q_u, SAMR_R_GET_DOM_PWINFO *r_u) +{ + DEBUG(0,("_samr_get_dom_pwinfo: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_open_group +*********************************************************************/ + +uint32 _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_GROUP *r_u) +{ + DEBUG(0,("_samr_open_group: Not yet implemented.\n")); + return False; +} + +/********************************************************************* + _samr_unknown_2d +*********************************************************************/ + +uint32 _samr_unknown_2d(pipes_struct *p, SAMR_Q_UNKNOWN_2D *q_u, SAMR_R_UNKNOWN_2D *r_u) +{ + DEBUG(0,("_samr_unknown_2d: Not yet implemented.\n")); + return False; +} diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c new file mode 100644 index 0000000000..80794609ea --- /dev/null +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -0,0 +1,866 @@ +#define OLD_NTDOMAIN 1 +/* + * Unix SMB/Netbios implementation. + * Version 1.9. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997. + * Copyright (C) Jeremy Allison 2001. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* This is the implementation of the srvsvc pipe. */ + +#include "includes.h" + +extern int DEBUGLEVEL; +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) +{ + int len_net_name; + pstring net_name; + pstring remark; + uint32 type; + + pstrcpy(net_name, lp_servicename(snum)); + pstrcpy(remark, lp_comment(snum)); + pstring_sub(remark,"%S",lp_servicename(snum)); + len_net_name = strlen(net_name); + + /* work out the share type */ + type = STYPE_DISKTREE; + + if (lp_print_ok(snum)) + type = STYPE_PRINTQ; + if (strequal("IPC$", net_name)) + type = STYPE_IPC; + if (net_name[len_net_name] == '$') + type |= STYPE_HIDDEN; + + init_srv_share_info1(&sh1->info_1, net_name, type, remark); + init_srv_share_info1_str(&sh1->info_1_str, net_name, remark); +} + +/******************************************************************* + Fill in a share info level 2 structure. + ********************************************************************/ + +static void init_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, int snum) +{ + int len_net_name; + pstring net_name; + pstring remark; + pstring path; + pstring passwd; + uint32 type; + + pstrcpy(net_name, lp_servicename(snum)); + pstrcpy(remark, lp_comment(snum)); + pstring_sub(remark,"%S",lp_servicename(snum)); + pstrcpy(path, lp_pathname(snum)); + pstrcpy(passwd, ""); + len_net_name = strlen(net_name); + + /* work out the share type */ + type = STYPE_DISKTREE; + + if (lp_print_ok(snum)) + type = STYPE_PRINTQ; + if (strequal("IPC$", net_name)) + type = STYPE_IPC; + if (net_name[len_net_name] == '$') + type |= STYPE_HIDDEN; + + init_srv_share_info2(&sh2->info_2, net_name, type, remark, 0, 0xffffffff, 1, path, passwd); + init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); +} + +/*************************************************************************** + Fill in a share info level 1005 structure. + ***************************************************************************/ + +static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum) +{ + sh1005->dfs_root_flag = 0; + +#ifdef WITH_MSDFS + if(lp_host_msdfs() && lp_msdfs_root(snum)) + sh1005->dfs_root_flag = 3; +#endif + +} + +/******************************************************************* + Fill in a share info structure. + ********************************************************************/ + +static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr, + uint32 info_level, uint32 *resume_hnd, uint32 *total_entries) +{ + int num_entries = 0; + int num_services = lp_numservices(); + int snum; + + DEBUG(5,("init_srv_share_info_ctr\n")); + + ZERO_STRUCTPN(ctr); + + ctr->info_level = ctr->switch_value = info_level; + *resume_hnd = 0; + + /* Count the number of entries. */ + for (snum = 0; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum)) + num_entries++; + } + + *total_entries = num_entries; + ctr->num_entries2 = ctr->num_entries = num_entries; + ctr->ptr_share_info = ctr->ptr_entries = 1; + + if (!num_entries) + return True; + + switch (info_level) { + case 1: + { + SRV_SHARE_INFO_1 *info1; + int i = 0; + + info1 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum)) { + init_srv_share_info_1(&info1[i++], snum); + } + } + + ctr->share.info1 = info1; + break; + } + + case 2: + { + SRV_SHARE_INFO_2 *info2; + int i = 0; + + info2 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_2)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum)) { + init_srv_share_info_2(&info2[i++], snum); + } + } + + ctr->share.info2 = info2; + break; + } + + default: + DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level)); + return False; + } + + return True; +} + +/******************************************************************* + 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, + uint32 info_level, uint32 resume_hnd) +{ + DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__)); + + if (init_srv_share_info_ctr(ctx, &r_n->ctr, info_level, + &resume_hnd, &r_n->total_entries)) { + r_n->status = NT_STATUS_NOPROBLEMO; + } else { + r_n->status = NT_STATUS_INVALID_INFO_CLASS; + } + + init_enum_hnd(&r_n->enum_hnd, resume_hnd); +} + +/******************************************************************* + Inits a SRV_R_NET_SHARE_GET_INFO structure. +********************************************************************/ + +static void init_srv_r_net_share_get_info(SRV_R_NET_SHARE_GET_INFO *r_n, + char *share_name, uint32 info_level) +{ + uint32 status = NT_STATUS_NOPROBLEMO; + int snum; + + DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__)); + + r_n->switch_value = info_level; + + snum = find_service(share_name); + + if (snum >= 0) { + switch (info_level) { + case 1: + init_srv_share_info_1(&r_n->share.info1, snum); + break; + case 2: + init_srv_share_info_2(&r_n->share.info2, snum); + break; + case 1005: + init_srv_share_info_1005(&r_n->share.info1005, snum); + break; + default: + DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level)); + status = NT_STATUS_INVALID_INFO_CLASS; + break; + } + } else { + status = NT_STATUS_BAD_NETWORK_NAME; + } + + r_n->ptr_share_ctr = (status == NT_STATUS_NOPROBLEMO) ? 1 : 0; + r_n->status = status; +} + +/******************************************************************* + fill in a sess info level 1 structure. + ********************************************************************/ + +static void init_srv_sess_0_info(SESS_INFO_0 *se0, SESS_INFO_0_STR *str0, char *name) +{ + init_srv_sess_info0(se0, name); + init_srv_sess_info0_str(str0, name); +} + +/******************************************************************* + fill in a sess info level 0 structure. + ********************************************************************/ + +static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot) +{ + uint32 num_entries = 0; + (*stot) = 1; + + if (ss0 == NULL) { + (*snum) = 0; + return; + } + + DEBUG(5,("init_srv_sess_0_ss0\n")); + + if (snum) { + for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { + init_srv_sess_0_info(&ss0->info_0[num_entries], + &ss0->info_0_str[num_entries], "MACHINE"); + + /* move on to creating next session */ + /* move on to creating next sess */ + num_entries++; + } + + ss0->num_entries_read = num_entries; + ss0->ptr_sess_info = num_entries > 0 ? 1 : 0; + ss0->num_entries_read2 = num_entries; + + if ((*snum) >= (*stot)) { + (*snum) = 0; + } + + } else { + ss0->num_entries_read = 0; + ss0->ptr_sess_info = 0; + ss0->num_entries_read2 = 0; + } +} + +/******************************************************************* + fill in a sess info level 1 structure. + ********************************************************************/ + +static void init_srv_sess_1_info(SESS_INFO_1 *se1, SESS_INFO_1_STR *str1, + char *name, char *user, + uint32 num_opens, + uint32 open_time, uint32 idle_time, + uint32 usr_flgs) +{ + init_srv_sess_info1(se1 , name, user, num_opens, open_time, idle_time, usr_flgs); + init_srv_sess_info1_str(str1, name, user); +} + +/******************************************************************* + fill in a sess info level 1 structure. + ********************************************************************/ + +static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot) +{ + uint32 num_entries = 0; + (*stot) = 1; + + if (ss1 == NULL) { + (*snum) = 0; + return; + } + + DEBUG(5,("init_srv_sess_1_ss1\n")); + + if (snum) { + for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { + init_srv_sess_1_info(&ss1->info_1[num_entries], + &ss1->info_1_str[num_entries], + "MACHINE", "dummy_user", 1, 10, 5, 0); + + /* move on to creating next session */ + /* move on to creating next sess */ + num_entries++; + } + + ss1->num_entries_read = num_entries; + ss1->ptr_sess_info = num_entries > 0 ? 1 : 0; + ss1->num_entries_read2 = num_entries; + + if ((*snum) >= (*stot)) { + (*snum) = 0; + } + + } else { + ss1->num_entries_read = 0; + ss1->ptr_sess_info = 0; + ss1->num_entries_read2 = 0; + + (*stot) = 0; + } +} + +/******************************************************************* + makes a SRV_R_NET_SESS_ENUM structure. +********************************************************************/ + +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; + DEBUG(5,("init_srv_sess_info_ctr: %d\n", __LINE__)); + + ctr->switch_value = switch_value; + + switch (switch_value) { + case 0: + init_srv_sess_info_0(&(ctr->sess.info0), resume_hnd, total_entries); + ctr->ptr_sess_ctr = 1; + break; + case 1: + init_srv_sess_info_1(&(ctr->sess.info1), resume_hnd, total_entries); + ctr->ptr_sess_ctr = 1; + break; + default: + DEBUG(5,("init_srv_sess_info_ctr: unsupported switch value %d\n", switch_value)); + (*resume_hnd) = 0; + (*total_entries) = 0; + ctr->ptr_sess_ctr = 0; + status = NT_STATUS_INVALID_INFO_CLASS; + break; + } + + return status; +} + +/******************************************************************* + makes a SRV_R_NET_SESS_ENUM structure. +********************************************************************/ + +static void init_srv_r_net_sess_enum(SRV_R_NET_SESS_ENUM *r_n, + uint32 resume_hnd, int sess_level, int switch_value) +{ + DEBUG(5,("init_srv_r_net_sess_enum: %d\n", __LINE__)); + + r_n->sess_level = sess_level; + + if (sess_level == -1) + r_n->status = NT_STATUS_INVALID_INFO_CLASS; + 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) + resume_hnd = 0; + + init_enum_hnd(&r_n->enum_hnd, resume_hnd); +} + +/******************************************************************* + fill in a conn info level 0 structure. + ********************************************************************/ + +static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *stot) +{ + uint32 num_entries = 0; + (*stot) = 1; + + if (ss0 == NULL) { + (*snum) = 0; + return; + } + + DEBUG(5,("init_srv_conn_0_ss0\n")); + + if (snum) { + for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) { + + init_srv_conn_info0(&ss0->info_0[num_entries], (*stot)); + + /* move on to creating next connection */ + /* move on to creating next conn */ + num_entries++; + } + + ss0->num_entries_read = num_entries; + ss0->ptr_conn_info = num_entries > 0 ? 1 : 0; + ss0->num_entries_read2 = num_entries; + + if ((*snum) >= (*stot)) { + (*snum) = 0; + } + + } else { + ss0->num_entries_read = 0; + ss0->ptr_conn_info = 0; + ss0->num_entries_read2 = 0; + + (*stot) = 0; + } +} + +/******************************************************************* + fill in a conn info level 1 structure. + ********************************************************************/ + +static void init_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1, + uint32 id, uint32 type, + uint32 num_opens, uint32 num_users, uint32 open_time, + char *usr_name, char *net_name) +{ + init_srv_conn_info1(se1 , id, type, num_opens, num_users, open_time, usr_name, net_name); + init_srv_conn_info1_str(str1, usr_name, net_name); +} + +/******************************************************************* + fill in a conn info level 1 structure. + ********************************************************************/ + +static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *stot) +{ + uint32 num_entries = 0; + (*stot) = 1; + + if (ss1 == NULL) { + (*snum) = 0; + return; + } + + DEBUG(5,("init_srv_conn_1_ss1\n")); + + if (snum) { + for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) { + init_srv_conn_1_info(&ss1->info_1[num_entries], + &ss1->info_1_str[num_entries], + (*stot), 0x3, 1, 1, 3,"dummy_user", "IPC$"); + + /* move on to creating next connection */ + /* move on to creating next conn */ + num_entries++; + } + + ss1->num_entries_read = num_entries; + ss1->ptr_conn_info = num_entries > 0 ? 1 : 0; + ss1->num_entries_read2 = num_entries; + + + if ((*snum) >= (*stot)) { + (*snum) = 0; + } + + } else { + ss1->num_entries_read = 0; + ss1->ptr_conn_info = 0; + ss1->num_entries_read2 = 0; + + (*stot) = 0; + } +} + +/******************************************************************* + makes a SRV_R_NET_CONN_ENUM structure. +********************************************************************/ + +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; + DEBUG(5,("init_srv_conn_info_ctr: %d\n", __LINE__)); + + ctr->switch_value = switch_value; + + switch (switch_value) { + case 0: + init_srv_conn_info_0(&ctr->conn.info0, resume_hnd, total_entries); + ctr->ptr_conn_ctr = 1; + break; + case 1: + init_srv_conn_info_1(&ctr->conn.info1, resume_hnd, total_entries); + ctr->ptr_conn_ctr = 1; + break; + default: + DEBUG(5,("init_srv_conn_info_ctr: unsupported switch value %d\n", switch_value)); + (*resume_hnd = 0); + (*total_entries) = 0; + ctr->ptr_conn_ctr = 0; + status = NT_STATUS_INVALID_INFO_CLASS; + break; + } + + return status; +} + +/******************************************************************* + makes a SRV_R_NET_CONN_ENUM structure. +********************************************************************/ + +static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, + uint32 resume_hnd, int conn_level, int switch_value) +{ + DEBUG(5,("init_srv_r_net_conn_enum: %d\n", __LINE__)); + + r_n->conn_level = conn_level; + if (conn_level == -1) + r_n->status = NT_STATUS_INVALID_INFO_CLASS; + 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) + resume_hnd = 0; + + init_enum_hnd(&r_n->enum_hnd, resume_hnd); +} + +/******************************************************************* + fill in a file info level 3 structure. + ********************************************************************/ + +static void init_srv_file_3_info(FILE_INFO_3 *fl3, FILE_INFO_3_STR *str3, + uint32 fnum, uint32 perms, uint32 num_locks, + char *path_name, char *user_name) +{ + init_srv_file_info3(fl3 , fnum, perms, num_locks, path_name, user_name); + init_srv_file_info3_str(str3, path_name, user_name); +} + +/******************************************************************* + fill in a file info level 3 structure. + ********************************************************************/ + +static void init_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *ftot) +{ + uint32 num_entries = 0; + (*ftot) = 1; + + if (fl3 == NULL) { + (*fnum) = 0; + return; + } + + DEBUG(5,("init_srv_file_3_fl3\n")); + + for (; (*fnum) < (*ftot) && num_entries < MAX_FILE_ENTRIES; (*fnum)++) { + init_srv_file_3_info(&fl3->info_3[num_entries], + &fl3->info_3_str[num_entries], + (*fnum), 0x35, 0, "\\PIPE\\samr", "dummy user"); + + /* move on to creating next file */ + num_entries++; + } + + fl3->num_entries_read = num_entries; + fl3->ptr_file_info = num_entries > 0 ? 1 : 0; + fl3->num_entries_read2 = num_entries; + + if ((*fnum) >= (*ftot)) { + (*fnum) = 0; + } +} + +/******************************************************************* + makes a SRV_R_NET_FILE_ENUM structure. +********************************************************************/ + +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; + DEBUG(5,("init_srv_file_info_ctr: %d\n", __LINE__)); + + ctr->switch_value = switch_value; + + switch (switch_value) { + case 3: + init_srv_file_info_3(&ctr->file.info3, resume_hnd, total_entries); + ctr->ptr_file_ctr = 1; + break; + default: + DEBUG(5,("init_srv_file_info_ctr: unsupported switch value %d\n", switch_value)); + (*resume_hnd = 0); + (*total_entries) = 0; + ctr->ptr_file_ctr = 0; + status = NT_STATUS_INVALID_INFO_CLASS; + break; + } + + return status; +} + +/******************************************************************* + makes a SRV_R_NET_FILE_ENUM structure. +********************************************************************/ + +static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n, + uint32 resume_hnd, int file_level, int switch_value) +{ + DEBUG(5,("init_srv_r_net_file_enum: %d\n", __LINE__)); + + r_n->file_level = file_level; + if (file_level == 0) + r_n->status = NT_STATUS_INVALID_INFO_CLASS; + 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) + resume_hnd = 0; + + init_enum_hnd(&r_n->enum_hnd, resume_hnd); +} + +/******************************************************************* +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; + SRV_INFO_CTR *ctr = (SRV_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_INFO_CTR)); + + if (!ctr) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(ctr); + + DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); + + switch (q_u->switch_value) { + case 102: + init_srv_info_102(&ctr->srv.sv102, + 500, global_myname, + string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), + lp_major_announce_version(), lp_minor_announce_version(), + lp_default_server_announce(), + 0xffffffff, /* users */ + 0xf, /* disc */ + 0, /* hidden */ + 240, /* announce */ + 3000, /* announce delta */ + 100000, /* licenses */ + "c:\\"); /* user path */ + break; + case 101: + init_srv_info_101(&ctr->srv.sv101, + 500, global_myname, + lp_major_announce_version(), lp_minor_announce_version(), + lp_default_server_announce(), + string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); + break; + default: + status = NT_STATUS_INVALID_INFO_CLASS; + break; + } + + /* set up the net server get info structure */ + init_srv_r_net_srv_get_info(r_u, q_u->switch_value, ctr, status); + + DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* +net file enum +********************************************************************/ + +uint32 _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) +{ + r_u->ctr = (SRV_FILE_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_FILE_INFO_CTR)); + if (!r_u->ctr) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(r_u->ctr); + + DEBUG(5,("srv_net_file_enum: %d\n", __LINE__)); + + /* set up the */ + init_srv_r_net_file_enum(r_u, + get_enum_hnd(&q_u->enum_hnd), + q_u->file_level, + q_u->ctr->switch_value); + + DEBUG(5,("srv_net_file_enum: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* +net conn enum +********************************************************************/ + +uint32 _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_CONN_ENUM *r_u) +{ + DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); + + r_u->ctr = (SRV_CONN_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_CONN_INFO_CTR)); + if (!r_u->ctr) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(r_u->ctr); + + /* set up the */ + init_srv_r_net_conn_enum(r_u, + get_enum_hnd(&q_u->enum_hnd), + q_u->conn_level, + q_u->ctr->switch_value); + + DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* +net sess enum +********************************************************************/ + +uint32 _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_SESS_ENUM *r_u) +{ + DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__)); + + r_u->ctr = (SRV_SESS_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_SESS_INFO_CTR)); + if (!r_u->ctr) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(r_u->ctr); + + /* set up the */ + init_srv_r_net_sess_enum(r_u, + get_enum_hnd(&q_u->enum_hnd), + q_u->sess_level, + q_u->ctr->switch_value); + + DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* + Net share enum. +********************************************************************/ + +uint32 _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) +{ + 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, + q_u->ctr.info_level, + get_enum_hnd(&q_u->enum_hnd)); + + DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* + Net share get info. +********************************************************************/ + +uint32 _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, SRV_R_NET_SHARE_GET_INFO *r_u) +{ + char *share_name; + + DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); + + /* Create the list of shares for the response. */ + share_name = dos_unistr2_to_str(&q_u->uni_share_name); + init_srv_r_net_share_get_info(r_u, share_name, q_u->info_level); + + DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* +time of day +********************************************************************/ + +uint32 _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET_REMOTE_TOD *r_u) +{ + TIME_OF_DAY_INFO *tod; + struct tm *t; + time_t unixdate = time(NULL); + + tod = (TIME_OF_DAY_INFO *)talloc(p->mem_ctx, sizeof(TIME_OF_DAY_INFO)); + if (!tod) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(tod); + + r_u->tod = tod; + r_u->ptr_srv_tod = 0x1; + r_u->status = NT_STATUS_NOPROBLEMO; + + DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); + + t = gmtime(&unixdate); + + /* set up the */ + init_time_of_day_info(tod, + unixdate, + 0, + t->tm_hour, + t->tm_min, + t->tm_sec, + 0, + TimeDiff(unixdate)/60, + 10000, + t->tm_mday, + t->tm_mon + 1, + 1900+t->tm_year, + t->tm_wday); + + DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); + + return r_u->status; +} +#undef OLD_NTDOMAIN -- cgit From 5265ce7837a185977f71bcb39a41b57492e24964 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Feb 2001 19:22:02 +0000 Subject: Added total memory allocated counter to talloc, so we can tell if a talloc pool is getting bloated. Also added a talloc_zero function to return zeroed memory. Added debug in rpc_server/srv_pipe_hnd.c so we know when a talloc pool is being freed. Syncup with srv_pipe_hnd.c from 2.2 so we are freeing memory at the same time. Jeremy. (This used to be commit d3a56c6042acf037bbd53de88d7636a5803ead20) --- source3/rpc_server/srv_pipe_hnd.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index b8ee235185..3b60c78ade 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -485,14 +485,6 @@ static ssize_t process_complete_pdu(pipes_struct *p) char *data_p = (char *)&p->in_data.current_in_pdu[0]; BOOL reply = False; - if (p->mem_ctx) { - talloc_destroy_pool(p->mem_ctx); - } else { - p->mem_ctx = talloc_init(); - if (p->mem_ctx == NULL) - p->fault_state = True; - } - if(p->fault_state) { DEBUG(10,("process_complete_pdu: pipe %s in fault state.\n", p->name )); @@ -713,7 +705,7 @@ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, memcpy( data, &p->out_data.current_pdu[p->out_data.current_pdu_sent], (size_t)data_returned); p->out_data.current_pdu_sent += (uint32)data_returned; - return data_returned; + goto out; } /* @@ -727,9 +719,10 @@ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, if(p->out_data.data_sent_length >= prs_offset(&p->out_data.rdata)) { /* - * We have sent all possible data. Return 0. + * We have sent all possible data, return 0. */ - return 0; + data_returned = 0; + goto out; } /* @@ -748,6 +741,26 @@ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, memcpy( data, p->out_data.current_pdu, (size_t)data_returned); p->out_data.current_pdu_sent += (uint32)data_returned; + + out: + + if(p->out_data.data_sent_length >= prs_offset(&p->out_data.rdata)) { + /* + * We have copied all possible data into the current_pdu. This RPC is finished. + * Reset the talloc context to free any allocated data from this RPC. + */ + + if (p->mem_ctx) { + DEBUG(3,("read_from_pipe: destroying talloc pool of size %u\n", talloc_pool_size(p->mem_ctx) )); + talloc_destroy_pool(p->mem_ctx); + } else { + p->mem_ctx = talloc_init(); + if (p->mem_ctx == NULL) + p->fault_state = True; + } + + } + return data_returned; } @@ -872,5 +885,4 @@ pipes_struct *get_rpc_pipe(int pnum) return NULL; } - #undef OLD_NTDOMAIN -- cgit From 20b8d6b0259812b7cf4ffb7fa871632cde9935a6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Feb 2001 20:17:32 +0000 Subject: Don't marshal data from a stack frame..... Jeremy. (This used to be commit 86ee091b3b5814813fbabd20f6de77ed94049ca3) --- source3/rpc_server/srv_reg_nt.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 769b376468..4d35542fc2 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -104,8 +104,8 @@ uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) char *key; uint32 type=0x1; /* key type: REG_SZ */ - UNISTR2 uni_key; - BUFFER2 buf; + UNISTR2 *uni_key = NULL; + BUFFER2 *buf = NULL; fstring name; DEBUG(5,("_reg_info: %d\n", __LINE__)); @@ -117,13 +117,19 @@ uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) DEBUG(5,("reg_info: checking key: %s\n", name)); + uni_key = (UNISTR2 *)talloc_zero(p->mem_ctx, sizeof(UNISTR2)); + buf = (BUFFER2 *)talloc_zero(p->mem_ctx, sizeof(BUFFER2)); + + if (!uni_key || !buf) + return NT_STATUS_NO_MEMORY; + if ( strequal(name, "RefusePasswordChange") ) { type=0xF770; status = ERRbadfile; - init_unistr2(&uni_key, "", 0); - init_buffer2(&buf, (uint8*) uni_key.buffer, uni_key.uni_str_len*2); + init_unistr2(uni_key, "", 0); + init_buffer2(buf, (uint8*) uni_key->buffer, uni_key->uni_str_len*2); - buf.buf_max_len=4; + buf->buf_max_len=4; goto out; } @@ -145,11 +151,11 @@ uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) /* which tells clients that we have our own local user and */ /* group databases and helps with ACL support. */ - init_unistr2(&uni_key, key, strlen(key)+1); - init_buffer2(&buf, (uint8*)uni_key.buffer, uni_key.uni_str_len*2); + init_unistr2(uni_key, key, strlen(key)+1); + init_buffer2(buf, (uint8*)uni_key->buffer, uni_key->uni_str_len*2); out: - init_reg_r_info(q_u->ptr_buf, r_u, &buf, type, status); + init_reg_r_info(q_u->ptr_buf, r_u, buf, type, status); DEBUG(5,("reg_open_entry: %d\n", __LINE__)); -- cgit From 0f2799aaf1e33aa474a12b9389728d57af926cb3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Feb 2001 00:51:02 +0000 Subject: Move to talloc control of SPOOL_XXX structs. Move to talloc control of security descriptors and pointers. Syncup with 2.2 tree. Jeremy. (This used to be commit 14d5997dc841e78a619e865288486d50c245896d) --- source3/rpc_server/srv_spoolss.c | 123 +----------------------------------- source3/rpc_server/srv_spoolss_nt.c | 49 +++++++------- 2 files changed, 27 insertions(+), 145 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 8c06f16290..cd490d1944 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -53,9 +53,6 @@ static BOOL api_spoolss_open_printer_ex(pipes_struct *p) q_u.user_switch, q_u.user_ctr, &r_u.handle); - /* we _really_ need to switch to talloc() */ - free_spoolss_q_open_printer_ex(&q_u); - if (!spoolss_io_r_open_printer_ex("",&r_u,rdata,0)){ DEBUG(0,("spoolss_io_r_open_printer_ex: unable to marshall SPOOL_R_OPEN_PRINTER_EX.\n")); return False; @@ -85,7 +82,7 @@ static BOOL api_spoolss_getprinterdata(pipes_struct *p) return False; } - r_u.status = _spoolss_getprinterdata( &q_u.handle, &q_u.valuename, + r_u.status = _spoolss_getprinterdata( p, &q_u.handle, &q_u.valuename, q_u.size, &r_u.type, &r_u.size, &r_u.data, &r_u.needed); @@ -94,8 +91,6 @@ static BOOL api_spoolss_getprinterdata(pipes_struct *p) return False; } - safe_free(r_u.data); - return True; } @@ -277,9 +272,7 @@ static BOOL api_spoolss_rfnpcnex(pipes_struct *p) } r_u.status = _spoolss_rfnpcnex(&q_u.handle, q_u.change, - q_u.option, data->mem_ctx, &r_u.info); - - safe_free(q_u.option); + q_u.option, p->mem_ctx, &r_u.info); /* we always have a NOTIFY_INFO struct */ r_u.info_ptr=0x1; @@ -289,8 +282,6 @@ static BOOL api_spoolss_rfnpcnex(pipes_struct *p) return False; } - safe_free(r_u.info.data); - return True; } @@ -310,9 +301,6 @@ static BOOL api_spoolss_enumprinters(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!new_spoolss_allocate_buffer(&q_u.buffer)) - return False; - if (!spoolss_io_q_enumprinters("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprinters: unable to unmarshall SPOOL_Q_ENUMPRINTERS.\n")); return False; @@ -327,12 +315,9 @@ static BOOL api_spoolss_enumprinters(pipes_struct *p) if (!new_spoolss_io_r_enumprinters("", &r_u, rdata, 0)) { DEBUG(0,("new_spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n")); - new_spoolss_free_buffer(q_u.buffer); return False; } - new_spoolss_free_buffer(q_u.buffer); - return True; } @@ -351,9 +336,6 @@ static BOOL api_spoolss_getprinter(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!new_spoolss_allocate_buffer(&q_u.buffer)) - return False; - if(!spoolss_io_q_getprinter("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getprinter: unable to unmarshall SPOOL_Q_GETPRINTER.\n")); return False; @@ -368,11 +350,9 @@ static BOOL api_spoolss_getprinter(pipes_struct *p) if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n")); - new_spoolss_free_buffer(q_u.buffer); return False; } - new_spoolss_free_buffer(q_u.buffer); return True; } @@ -392,9 +372,6 @@ static BOOL api_spoolss_getprinterdriver2(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!new_spoolss_allocate_buffer(&q_u.buffer)) - return False; - if(!spoolss_io_q_getprinterdriver2("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getprinterdriver2: unable to unmarshall SPOOL_Q_GETPRINTERDRIVER2.\n")); return False; @@ -410,11 +387,9 @@ static BOOL api_spoolss_getprinterdriver2(pipes_struct *p) if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n")); - new_spoolss_free_buffer(q_u.buffer); return False; } - new_spoolss_free_buffer(q_u.buffer); return True; } @@ -560,7 +535,6 @@ static BOOL api_spoolss_writeprinter(pipes_struct *p) q_u.buffer, &q_u.buffer_size2); r_u.buffer_written = q_u.buffer_size2; - safe_free(q_u.buffer); if(!spoolss_io_r_writeprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_writeprinter: unable to marshall SPOOL_R_WRITEPRINTER.\n")); @@ -594,13 +568,9 @@ static BOOL api_spoolss_setprinter(pipes_struct *p) if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n")); - free_spoolss_q_setprinter(&q_u); return False; } - /* Free anything allocated in the unparse. */ - free_spoolss_q_setprinter(&q_u); - return True; } @@ -644,9 +614,6 @@ static BOOL api_spoolss_addjob(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!new_spoolss_allocate_buffer(&q_u.buffer)) - return False; - if(!spoolss_io_q_addjob("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_addjob: unable to unmarshall SPOOL_Q_ADDJOB.\n")); return False; @@ -660,12 +627,9 @@ static BOOL api_spoolss_addjob(pipes_struct *p) if(!spoolss_io_r_addjob("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_addjob: unable to marshall SPOOL_R_ADDJOB.\n")); - new_spoolss_free_buffer(q_u.buffer); return False; } - new_spoolss_free_buffer(q_u.buffer); - return True; } @@ -682,9 +646,6 @@ static BOOL api_spoolss_enumjobs(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!new_spoolss_allocate_buffer(&q_u.buffer)) - return False; - if (!spoolss_io_q_enumjobs("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumjobs: unable to unmarshall SPOOL_Q_ENUMJOBS.\n")); return False; @@ -699,12 +660,9 @@ static BOOL api_spoolss_enumjobs(pipes_struct *p) if (!spoolss_io_r_enumjobs("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_enumjobs: unable to marshall SPOOL_R_ENUMJOBS.\n")); - new_spoolss_free_buffer(q_u.buffer); return False; } - new_spoolss_free_buffer(q_u.buffer); - return True; } @@ -777,9 +735,6 @@ static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!new_spoolss_allocate_buffer(&q_u.buffer)) - return False; - if (!spoolss_io_q_enumprinterdrivers("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprinterdrivers: unable to unmarshall SPOOL_Q_ENUMPRINTERDRIVERS.\n")); return False; @@ -794,12 +749,9 @@ static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p) if (!new_spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) { DEBUG(0,("new_spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n")); - new_spoolss_free_buffer(q_u.buffer); return False; } - new_spoolss_free_buffer(q_u.buffer); - return True; } @@ -816,9 +768,6 @@ static BOOL api_spoolss_getform(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!new_spoolss_allocate_buffer(&q_u.buffer)) - return False; - if (!spoolss_io_q_getform("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getform: unable to unmarshall SPOOL_Q_GETFORM.\n")); return False; @@ -832,12 +781,9 @@ static BOOL api_spoolss_getform(pipes_struct *p) if (!new_spoolss_io_r_getform("",&r_u,rdata,0)) { DEBUG(0,("new_spoolss_io_r_getform: unable to marshall SPOOL_R_GETFORM.\n")); - new_spoolss_free_buffer(q_u.buffer); return False; } - new_spoolss_free_buffer(q_u.buffer); - return True; } @@ -853,9 +799,6 @@ static BOOL api_spoolss_enumforms(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!new_spoolss_allocate_buffer(&q_u.buffer)) - return False; - if (!spoolss_io_q_enumforms("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n")); return False; @@ -870,12 +813,9 @@ static BOOL api_spoolss_enumforms(pipes_struct *p) if (!new_spoolss_io_r_enumforms("",&r_u,rdata,0)) { DEBUG(0,("new_spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n")); - new_spoolss_free_buffer(q_u.buffer); return False; } - new_spoolss_free_buffer(q_u.buffer); - return True; } @@ -892,9 +832,6 @@ static BOOL api_spoolss_enumports(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!new_spoolss_allocate_buffer(&q_u.buffer)) - return False; - if(!spoolss_io_q_enumports("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumports: unable to unmarshall SPOOL_Q_ENUMPORTS.\n")); return False; @@ -909,12 +846,9 @@ static BOOL api_spoolss_enumports(pipes_struct *p) if (!new_spoolss_io_r_enumports("",&r_u,rdata,0)) { DEBUG(0,("new_spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n")); - new_spoolss_free_buffer(q_u.buffer); return False; } - new_spoolss_free_buffer(q_u.buffer); - return True; } @@ -947,17 +881,6 @@ static BOOL api_spoolss_addprinterex(pipes_struct *p) return False; } - if (q_u.info.info_ptr!=0) { - switch (q_u.info.level) { - case 1: - safe_free(q_u.info.info_1); - break; - case 2: - safe_free(q_u.info.info_2); - break; - } - } - return True; } @@ -975,7 +898,6 @@ static BOOL api_spoolss_addprinterdriver(pipes_struct *p) if(!spoolss_io_q_addprinterdriver("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n")); - free_spoolss_q_addprinterdriver(&q_u); return False; } @@ -983,12 +905,9 @@ static BOOL api_spoolss_addprinterdriver(pipes_struct *p) if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n")); - free_spoolss_q_addprinterdriver(&q_u); return False; } - free_spoolss_q_addprinterdriver(&q_u); - return True; } @@ -1004,9 +923,6 @@ static BOOL api_spoolss_getprinterdriverdirectory(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!new_spoolss_allocate_buffer(&q_u.buffer)) - return False; - if(!spoolss_io_q_getprinterdriverdir("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n")); return False; @@ -1021,12 +937,9 @@ static BOOL api_spoolss_getprinterdriverdirectory(pipes_struct *p) if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n")); - new_spoolss_free_buffer(q_u.buffer); return False; } - new_spoolss_free_buffer(q_u.buffer); - return True; } @@ -1047,21 +960,16 @@ static BOOL api_spoolss_enumprinterdata(pipes_struct *p) return False; } - r_u.status = _spoolss_enumprinterdata(&q_u.handle, q_u.index, q_u.valuesize, q_u.datasize, + r_u.status = _spoolss_enumprinterdata(p, &q_u.handle, q_u.index, q_u.valuesize, q_u.datasize, &r_u.valuesize, &r_u.value, &r_u.realvaluesize, &r_u.type, &r_u.datasize, &r_u.data, &r_u.realdatasize); if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n")); - safe_free(r_u.value); - safe_free(r_u.data); return False; } - safe_free(r_u.value); - safe_free(r_u.data); - return True; } @@ -1086,8 +994,6 @@ static BOOL api_spoolss_setprinterdata(pipes_struct *p) &q_u.value, q_u.type, q_u.max_len, q_u.data, q_u.real_len, q_u.numeric_data); - free_spoolss_q_setprinterdata(&q_u); - if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n")); return False; @@ -1189,9 +1095,6 @@ static BOOL api_spoolss_enumprintprocessors(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!new_spoolss_allocate_buffer(&q_u.buffer)) - return False; - if(!spoolss_io_q_enumprintprocessors("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprintprocessors: unable to unmarshall SPOOL_Q_ENUMPRINTPROCESSORS.\n")); return False; @@ -1206,12 +1109,9 @@ static BOOL api_spoolss_enumprintprocessors(pipes_struct *p) if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n")); - new_spoolss_free_buffer(q_u.buffer); return False; } - new_spoolss_free_buffer(q_u.buffer); - return True; } @@ -1227,9 +1127,6 @@ static BOOL api_spoolss_enumprintprocdatatypes(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!new_spoolss_allocate_buffer(&q_u.buffer)) - return False; - if(!spoolss_io_q_enumprintprocdatatypes("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprintprocdatatypes: unable to unmarshall SPOOL_Q_ENUMPRINTPROCDATATYPES.\n")); return False; @@ -1244,12 +1141,9 @@ static BOOL api_spoolss_enumprintprocdatatypes(pipes_struct *p) if(!spoolss_io_r_enumprintprocdatatypes("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_enumprintprocdatatypes: unable to marshall SPOOL_R_ENUMPRINTPROCDATATYPES.\n")); - new_spoolss_free_buffer(q_u.buffer); return False; } - new_spoolss_free_buffer(q_u.buffer); - return True; } @@ -1265,9 +1159,6 @@ static BOOL api_spoolss_enumprintmonitors(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!new_spoolss_allocate_buffer(&q_u.buffer)) - return False; - if (!spoolss_io_q_enumprintmonitors("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_enumprintmonitors: unable to unmarshall SPOOL_Q_ENUMPRINTMONITORS.\n")); return False; @@ -1282,12 +1173,9 @@ static BOOL api_spoolss_enumprintmonitors(pipes_struct *p) if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n")); - new_spoolss_free_buffer(q_u.buffer); return False; } - new_spoolss_free_buffer(q_u.buffer); - return True; } @@ -1300,9 +1188,6 @@ static BOOL api_spoolss_getjob(pipes_struct *p) prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - if(!new_spoolss_allocate_buffer(&q_u.buffer)) - return False; - if(!spoolss_io_q_getjob("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n")); return False; @@ -1317,11 +1202,9 @@ static BOOL api_spoolss_getjob(pipes_struct *p) if(!spoolss_io_r_getjob("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n")); - new_spoolss_free_buffer(q_u.buffer); return False; } - new_spoolss_free_buffer(q_u.buffer); return True; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d5f0703e03..4612384b0d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1155,7 +1155,7 @@ static BOOL getprinterdata_printer(POLICY_HND *handle, /******************************************************************** * spoolss_getprinterdata ********************************************************************/ -uint32 _spoolss_getprinterdata(POLICY_HND *handle, UNISTR2 *valuename, +uint32 _spoolss_getprinterdata(pipes_struct *p, POLICY_HND *handle, UNISTR2 *valuename, uint32 in_size, uint32 *type, uint32 *out_size, @@ -1199,9 +1199,8 @@ uint32 _spoolss_getprinterdata(POLICY_HND *handle, UNISTR2 *valuename, DEBUG(5, ("value not found, allocating %d\n", *out_size)); /* reply this param doesn't exist */ if (*out_size) { - if((*data=(uint8 *)malloc(*out_size*sizeof(uint8))) == NULL) + if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) return ERROR_NOT_ENOUGH_MEMORY; - memset(*data, '\0', *out_size*sizeof(uint8)); } else { *data = NULL; } @@ -2070,7 +2069,9 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int SPOOL_NOTIFY_INFO_DATA *current_data; NT_PRINTER_INFO_LEVEL *printer = NULL; print_queue_struct *queue=NULL; - + size_t realloc_size = 0; + SPOOL_NOTIFY_INFO_DATA *info_data_ptr = NULL; + type=option_type->type; DEBUG(4,("construct_notify_printer_info: Notify type: [%s], number of notify info: [%d] on printer: [%s]\n", @@ -2087,10 +2088,11 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int if (!search_notify(type, field, &j) ) continue; - if((info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) { + realloc_size = (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA); + if((info_data_ptr=(SPOOL_NOTIFY_INFO_DATA *)Realloc(info_data_ptr, realloc_size)) == NULL) { return False; } - current_data=&info->data[info->count]; + current_data=&info_data_ptr[info->count]; construct_info_data(current_data, type, field, id); @@ -2103,6 +2105,12 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int info->count++; } + if (realloc_size) + info->data = talloc_memdup(mem_ctx, info_data_ptr, realloc_size); + else + info->data = NULL; + + safe_free(info_data_ptr); free_a_printer(&printer, 2); return True; } @@ -2322,9 +2330,8 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, /******************************************************************** * spoolss_rfnpcnex ********************************************************************/ -uint32 _spoolss_rfnpcnex( POLICY_HND *handle, uint32 change, - SPOOL_NOTIFY_OPTION *option, TALLOC_CTX *mem_ctx, - SPOOL_NOTIFY_INFO *info) +uint32 _spoolss_rfnpcnex( pipes_struct *p, POLICY_HND *handle, uint32 change, + SPOOL_NOTIFY_OPTION *option, SPOOL_NOTIFY_INFO *info) { Printer_entry *Printer=find_printer_index_by_hnd(handle); uint32 result = ERROR_INVALID_HANDLE; @@ -2348,18 +2355,16 @@ uint32 _spoolss_rfnpcnex( POLICY_HND *handle, uint32 change, * informations even when _NOTHING_ has changed. */ - /* just discard the SPOOL_NOTIFY_OPTION */ - if (option!=NULL) - safe_free(option->ctr.type); + /* just ignore the SPOOL_NOTIFY_OPTION */ switch (Printer->printer_type) { case PRINTER_HANDLE_IS_PRINTSERVER: result = printserver_notify_info(handle, info, - mem_ctx); + p->mem_ctx); break; case PRINTER_HANDLE_IS_PRINTER: - result = printer_notify_info(handle, info, mem_ctx); + result = printer_notify_info(handle, info, p->mem_ctx); break; } @@ -2910,7 +2915,6 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 if (!alloc_buffer_size(buffer, *needed)) { for (i=0; i<*returned; i++) { free_devmode(printers[i].devmode); - free_sec_desc(&printers[i].secdesc); } safe_free(printers); return ERROR_INSUFFICIENT_BUFFER; @@ -2923,7 +2927,6 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 /* clear memory */ for (i=0; i<*returned; i++) { free_devmode(printers[i].devmode); - free_sec_desc(&printers[i].secdesc); } safe_free(printers); @@ -3930,7 +3933,7 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, dialog boxes when the user doesn't have permission to change the security descriptor. */ - nt_printing_getsec(Printer->dev.handlename, &old_secdesc_ctr); + nt_printing_getsec(p->mem_ctx, Printer->dev.handlename, &old_secdesc_ctr); if (DEBUGLEVEL >= 10) { SEC_ACL *acl; @@ -3968,7 +3971,7 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, } } - new_secdesc_ctr = sec_desc_merge(secdesc_ctr, old_secdesc_ctr); + 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; @@ -3992,8 +3995,6 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, result = nt_printing_setsec(Printer->dev.handlename, new_secdesc_ctr); done: - free_sec_desc_buf(&new_secdesc_ctr); - free_sec_desc_buf(&old_secdesc_ctr); return result; } @@ -5626,7 +5627,7 @@ uint32 _spoolss_getprinterdriverdirectory(UNISTR2 *name, UNISTR2 *uni_environmen /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_enumprinterdata(POLICY_HND *handle, uint32 idx, +uint32 _spoolss_enumprinterdata(pipes_struct *p, POLICY_HND *handle, uint32 idx, uint32 in_value_len, uint32 in_data_len, uint32 *out_max_value_len, uint16 **out_value, uint32 *out_value_len, uint32 *out_type, @@ -5758,24 +5759,22 @@ uint32 _spoolss_enumprinterdata(POLICY_HND *handle, uint32 idx, */ *out_max_value_len=(in_value_len/sizeof(uint16)); - if((*out_value=(uint16 *)malloc(in_value_len*sizeof(uint8))) == NULL) { + if((*out_value=(uint16 *)talloc_zero(p->mem_ctx,in_value_len*sizeof(uint8))) == NULL) { safe_free(data); return ERROR_NOT_ENOUGH_MEMORY; } - ZERO_STRUCTP(*out_value); *out_value_len = (uint32)dos_PutUniCode((char *)*out_value, value, in_value_len, True); *out_type=type; /* the data is counted in bytes */ *out_max_data_len=in_data_len; - if((*data_out=(uint8 *)malloc(in_data_len*sizeof(uint8))) == NULL) { + if((*data_out=(uint8 *)talloc_zero(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) { safe_free(data); return ERROR_NOT_ENOUGH_MEMORY; } - memset(*data_out,'\0',in_data_len); memcpy(*data_out, data, (size_t)data_len); *out_data_len=data_len; -- cgit From 403562cb94bc06707f86ec87caf0cf2d32a02ed7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Feb 2001 01:24:55 +0000 Subject: Partial conversion of SPOOLSS code to canonical format. More to follow. Once complete then the PRINTER_XX functions and structures will be converted to talloc control. Jeremy. (This used to be commit 8171cc56428920d8b765d077198893201f68766e) --- source3/rpc_server/srv_spoolss.c | 49 +++++++---------- source3/rpc_server/srv_spoolss_nt.c | 103 ++++++++++++++++++++++++++++-------- 2 files changed, 98 insertions(+), 54 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index cd490d1944..91107e9dbe 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -29,11 +29,11 @@ extern int DEBUGLEVEL; /******************************************************************** * api_spoolss_open_printer_ex ********************************************************************/ + static BOOL api_spoolss_open_printer_ex(pipes_struct *p) { SPOOL_Q_OPEN_PRINTER_EX q_u; SPOOL_R_OPEN_PRINTER_EX r_u; - UNISTR2 *printername = NULL; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -45,13 +45,7 @@ static BOOL api_spoolss_open_printer_ex(pipes_struct *p) return False; } - if (q_u.printername_ptr != 0) - printername = &q_u.printername; - - r_u.status = _spoolss_open_printer_ex( printername, p, - &q_u.printer_default, - q_u.user_switch, q_u.user_ctr, - &r_u.handle); + r_u.status = _spoolss_open_printer_ex( p, &q_u, &r_u); if (!spoolss_io_r_open_printer_ex("",&r_u,rdata,0)){ DEBUG(0,("spoolss_io_r_open_printer_ex: unable to marshall SPOOL_R_OPEN_PRINTER_EX.\n")); @@ -66,6 +60,7 @@ static BOOL api_spoolss_open_printer_ex(pipes_struct *p) * * called from the spoolss dispatcher ********************************************************************/ + static BOOL api_spoolss_getprinterdata(pipes_struct *p) { SPOOL_Q_GETPRINTERDATA q_u; @@ -82,9 +77,7 @@ static BOOL api_spoolss_getprinterdata(pipes_struct *p) return False; } - r_u.status = _spoolss_getprinterdata( p, &q_u.handle, &q_u.valuename, - q_u.size, &r_u.type, &r_u.size, - &r_u.data, &r_u.needed); + r_u.status = _spoolss_getprinterdata( p, &q_u, &r_u); if (!spoolss_io_r_getprinterdata("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_getprinterdata: unable to marshall SPOOL_R_GETPRINTERDATA.\n")); @@ -99,6 +92,7 @@ static BOOL api_spoolss_getprinterdata(pipes_struct *p) * * called from the spoolss dispatcher ********************************************************************/ + static BOOL api_spoolss_deleteprinterdata(pipes_struct *p) { SPOOL_Q_DELETEPRINTERDATA q_u; @@ -115,7 +109,7 @@ static BOOL api_spoolss_deleteprinterdata(pipes_struct *p) return False; } - r_u.status = _spoolss_deleteprinterdata( &q_u.handle, &q_u.valuename); + r_u.status = _spoolss_deleteprinterdata( p, &q_u, &r_u); if (!spoolss_io_r_deleteprinterdata("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_deleteprinterdata: unable to marshall SPOOL_R_DELETEPRINTERDATA.\n")); @@ -130,6 +124,7 @@ static BOOL api_spoolss_deleteprinterdata(pipes_struct *p) * * called from the spoolss dispatcher ********************************************************************/ + static BOOL api_spoolss_closeprinter(pipes_struct *p) { SPOOL_Q_CLOSEPRINTER q_u; @@ -145,8 +140,7 @@ static BOOL api_spoolss_closeprinter(pipes_struct *p) return False; } - r_u.status = _spoolss_closeprinter(&q_u.handle); - memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle)); + r_u.status = _spoolss_closeprinter(p, &q_u, &r_u); if (!spoolss_io_r_closeprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_closeprinter: unable to marshall SPOOL_R_CLOSEPRINTER.\n")); @@ -161,6 +155,7 @@ static BOOL api_spoolss_closeprinter(pipes_struct *p) * * called from the spoolss dispatcher ********************************************************************/ + static BOOL api_spoolss_abortprinter(pipes_struct *p) { SPOOL_Q_ABORTPRINTER q_u; @@ -176,7 +171,7 @@ static BOOL api_spoolss_abortprinter(pipes_struct *p) return False; } - r_u.status = _spoolss_abortprinter(&q_u.handle, p); + r_u.status = _spoolss_abortprinter(p, &q_u, &r_u); if (!spoolss_io_r_abortprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_abortprinter: unable to marshall SPOOL_R_ABORTPRINTER.\n")); @@ -191,6 +186,7 @@ static BOOL api_spoolss_abortprinter(pipes_struct *p) * * called from the spoolss dispatcher ********************************************************************/ + static BOOL api_spoolss_deleteprinter(pipes_struct *p) { SPOOL_Q_DELETEPRINTER q_u; @@ -206,8 +202,7 @@ static BOOL api_spoolss_deleteprinter(pipes_struct *p) return False; } - r_u.status = _spoolss_deleteprinter(&q_u.handle); - memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle)); + r_u.status = _spoolss_deleteprinter(p, &q_u, &r_u); if (!spoolss_io_r_deleteprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_deleteprinter: unable to marshall SPOOL_R_DELETEPRINTER.\n")); @@ -222,6 +217,7 @@ static BOOL api_spoolss_deleteprinter(pipes_struct *p) * api_spoolss_rffpcnex * ReplyFindFirstPrinterChangeNotifyEx ********************************************************************/ + static BOOL api_spoolss_rffpcnex(pipes_struct *p) { SPOOL_Q_RFFPCNEX q_u; @@ -237,9 +233,7 @@ static BOOL api_spoolss_rffpcnex(pipes_struct *p) return False; } - r_u.status = _spoolss_rffpcnex(&q_u.handle, q_u.flags, - q_u.options, &q_u.localmachine, - q_u.printerlocal, q_u.option); + r_u.status = _spoolss_rffpcnex(p, &q_u, &r_u); if (!spoolss_io_r_rffpcnex("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_rffpcnex: unable to marshall SPOOL_R_RFFPCNEX.\n")); @@ -256,6 +250,7 @@ static BOOL api_spoolss_rffpcnex(pipes_struct *p) * called from the spoolss dispatcher * ********************************************************************/ + static BOOL api_spoolss_rfnpcnex(pipes_struct *p) { SPOOL_Q_RFNPCNEX q_u; @@ -271,11 +266,7 @@ static BOOL api_spoolss_rfnpcnex(pipes_struct *p) return False; } - r_u.status = _spoolss_rfnpcnex(&q_u.handle, q_u.change, - q_u.option, p->mem_ctx, &r_u.info); - - /* we always have a NOTIFY_INFO struct */ - r_u.info_ptr=0x1; + r_u.status = _spoolss_rfnpcnex(p, &q_u, &r_u); if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n")); @@ -291,6 +282,7 @@ static BOOL api_spoolss_rfnpcnex(pipes_struct *p) * called from the spoolss dispatcher * ********************************************************************/ + static BOOL api_spoolss_enumprinters(pipes_struct *p) { SPOOL_Q_ENUMPRINTERS q_u; @@ -306,12 +298,7 @@ static BOOL api_spoolss_enumprinters(pipes_struct *p) return False; } - /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _spoolss_enumprinters( q_u.flags, &q_u.servername, q_u.level, - r_u.buffer, q_u.offered, - &r_u.needed, &r_u.returned); + r_u.status = _spoolss_enumprinters( p, &q_u, &r_u); if (!new_spoolss_io_r_enumprinters("", &r_u, rdata, 0)) { DEBUG(0,("new_spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n")); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4612384b0d..4170700705 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -697,18 +697,26 @@ static BOOL srv_spoolss_sendnotify(POLICY_HND *handle) * * called from the spoolss dispatcher ********************************************************************/ -uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, pipes_struct *p, - PRINTER_DEFAULT *printer_default, - uint32 user_switch, SPOOL_USER_CTR user_ctr, - 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; #endif + + UNISTR2 *printername = NULL; + PRINTER_DEFAULT *printer_default = &q_u->printer_default; +/* uint32 user_switch = q_u->user_switch; - notused */ +/* SPOOL_USER_CTR user_ctr = q_u->user_ctr; - notused */ + POLICY_HND *handle = &r_u->handle; + fstring name; int snum; struct current_user user; - + + if (q_u->printername_ptr != 0) + printername = &q_u->printername; + if (printername == NULL) return ERROR_INVALID_PRINTER_NAME; @@ -985,13 +993,18 @@ BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, /******************************************************************** * api_spoolss_closeprinter ********************************************************************/ -uint32 _spoolss_closeprinter(POLICY_HND *handle) + +uint32 _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL_R_CLOSEPRINTER *r_u) { + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer=find_printer_index_by_hnd(handle); if (Printer && Printer->document_started) _spoolss_enddocprinter(handle); /* print job was not closed */ + memcpy(&r_u->handle, &q_u->handle, sizeof(r_u->handle)); + if (!close_printer_handle(handle)) return ERROR_INVALID_HANDLE; @@ -1000,15 +1013,21 @@ uint32 _spoolss_closeprinter(POLICY_HND *handle) /******************************************************************** * api_spoolss_deleteprinter + ********************************************************************/ -uint32 _spoolss_deleteprinter(POLICY_HND *handle) + +uint32 _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL_R_DELETEPRINTER *r_u) { + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer=find_printer_index_by_hnd(handle); uint32 result; if (Printer && Printer->document_started) _spoolss_enddocprinter(handle); /* print job was not closed */ + memcpy(&r_u->handle, &q_u->handle, sizeof(r_u->handle)); + result = delete_printer_handle(handle); if (result == ERROR_SUCCESS) { @@ -1155,13 +1174,17 @@ static BOOL getprinterdata_printer(POLICY_HND *handle, /******************************************************************** * spoolss_getprinterdata ********************************************************************/ -uint32 _spoolss_getprinterdata(pipes_struct *p, POLICY_HND *handle, UNISTR2 *valuename, - uint32 in_size, - uint32 *type, - uint32 *out_size, - uint8 **data, - uint32 *needed) + +uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPOOL_R_GETPRINTERDATA *r_u) { + POLICY_HND *handle = &q_u->handle; + UNISTR2 *valuename = &q_u->valuename; + uint32 in_size = q_u->size; + uint32 *type = &r_u->type; + uint32 *out_size = &r_u->size; + uint8 **data = &r_u->data; + uint32 *needed = &r_u->needed; + fstring value; BOOL found=False; Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -1252,10 +1275,16 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin * in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe * called from api_spoolss_rffpcnex ********************************************************************/ -uint32 _spoolss_rffpcnex(POLICY_HND *handle, uint32 flags, uint32 options, - const UNISTR2 *localmachine, uint32 printerlocal, - SPOOL_NOTIFY_OPTION *option) + +uint32 _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNEX *r_u) { + POLICY_HND *handle = &q_u->handle; + uint32 flags = q_u->flags; + uint32 options = q_u->options; + UNISTR2 *localmachine = &q_u->localmachine; + uint32 printerlocal = q_u->printerlocal; + SPOOL_NOTIFY_OPTION *option = q_u->option; + /* store the notify value in the printer struct */ Printer_entry *Printer=find_printer_index_by_hnd(handle); @@ -1283,6 +1312,7 @@ uint32 _spoolss_rffpcnex(POLICY_HND *handle, uint32 flags, uint32 options, /******************************************************************* * fill a notify_info_data with the servername ********************************************************************/ + static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -2330,12 +2360,20 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, /******************************************************************** * spoolss_rfnpcnex ********************************************************************/ -uint32 _spoolss_rfnpcnex( pipes_struct *p, POLICY_HND *handle, uint32 change, - SPOOL_NOTIFY_OPTION *option, SPOOL_NOTIFY_INFO *info) + +uint32 _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCNEX *r_u) { + POLICY_HND *handle = &q_u->handle; +/* uint32 change = q_u->change; - notused. */ +/* SPOOL_NOTIFY_OPTION *option = q_u->option; - notused. */ + SPOOL_NOTIFY_INFO *info = &r_u->info; + Printer_entry *Printer=find_printer_index_by_hnd(handle); uint32 result = ERROR_INVALID_HANDLE; + /* we always have a NOTIFY_INFO struct */ + r_u->info_ptr=0x1; + if (!OPEN_HANDLE(Printer)) { DEBUG(0,("_spoolss_rfnpcnex: Invalid handle (%s).\n", OUR_HANDLE(handle))); @@ -2874,6 +2912,7 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui /******************************************************************** enum_all_printers_info_1_network. *********************************************************************/ + static BOOL enum_all_printers_info_1_network(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { DEBUG(4,("enum_all_printers_info_1_network\n")); @@ -2886,6 +2925,7 @@ static BOOL enum_all_printers_info_1_network(NEW_BUFFER *buffer, uint32 offered, * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ + static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int snum; @@ -3010,12 +3050,23 @@ static uint32 enumprinters_level5( uint32 flags, fstring servername, * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 level, - NEW_BUFFER *buffer, uint32 offered, - uint32 *needed, uint32 *returned) + +uint32 _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_R_ENUMPRINTERS *r_u) { + uint32 flags = q_u->flags; + UNISTR2 *servername = &q_u->servername; + uint32 level = q_u->level; + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + uint32 *returned = &r_u->returned; + fstring name; + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_spoolss_enumprinters\n")); *needed=0; @@ -3900,8 +3951,10 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command, * api_spoolss_abortprinter ********************************************************************/ -uint32 _spoolss_abortprinter(POLICY_HND *handle, pipes_struct *p) +uint32 _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R_ABORTPRINTER *r_u) { + POLICY_HND *handle = &q_u->handle; + return control_printer(handle, PRINTER_CONTROL_PURGE, p); } @@ -5859,8 +5912,12 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_deleteprinterdata( POLICY_HND *handle, const UNISTR2 *value) + +uint32 _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_u, SPOOL_R_DELETEPRINTERDATA *r_u) { + POLICY_HND *handle = &q_u->handle; + UNISTR2 *value = &q_u->valuename; + NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_PARAM param; int snum=0; -- cgit From 6ed9b52862fa076c26a267ab48df5a097f17edd6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Feb 2001 01:38:12 +0000 Subject: Ooops - forgot to check the rpcclient and smbcacls compile with the new code :-(. Jeremy. (This used to be commit 70beabf73bdaad7b6a60e24b7a11798a411bed02) --- source3/rpc_server/srv_spoolss.c | 9 +++------ source3/rpc_server/srv_spoolss_nt.c | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 91107e9dbe..4bd70ca755 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -6,6 +6,7 @@ * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000. + * Copyright (C) Jeremy Allison 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -313,6 +314,7 @@ static BOOL api_spoolss_enumprinters(pipes_struct *p) * called from the spoolss dispatcher * ********************************************************************/ + static BOOL api_spoolss_getprinter(pipes_struct *p) { SPOOL_Q_GETPRINTER q_u; @@ -328,12 +330,7 @@ static BOOL api_spoolss_getprinter(pipes_struct *p) return False; } - /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _spoolss_getprinter(&q_u.handle, q_u.level, - r_u.buffer, q_u.offered, - &r_u.needed); + r_u.status = _spoolss_getprinter(p, &q_u, &r_u); if(!spoolss_io_r_getprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_getprinter: unable to marshall SPOOL_R_GETPRINTER.\n")); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4170700705..0e09bff289 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6,6 +6,7 @@ * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000. + * Copyright (C) Jeremy Allison 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -3233,11 +3234,21 @@ static uint32 getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, - NEW_BUFFER *buffer, uint32 offered, uint32 *needed) + +uint32 _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GETPRINTER *r_u) { + POLICY_HND *handle = &q_u->handle; + uint32 level = q_u->level; + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + int snum; - + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + *needed=0; if (!get_printer_snum(handle, &snum)) -- cgit From 2a258f7a64873fe4be213f974e21e6f0f596d0cd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Feb 2001 02:03:02 +0000 Subject: Converted more to canonical format... save as I go., Jeremy. (This used to be commit 1d4ff7a81bccce0e5701102314af4f9c64c55cd6) --- source3/rpc_server/srv_spoolss.c | 24 +++++++-------------- source3/rpc_server/srv_spoolss_nt.c | 42 ++++++++++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 26 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 4bd70ca755..d8eaab2714 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -340,12 +340,12 @@ static BOOL api_spoolss_getprinter(pipes_struct *p) return True; } - /******************************************************************** * api_spoolss_getprinter * called from the spoolss dispatcher * ********************************************************************/ + static BOOL api_spoolss_getprinterdriver2(pipes_struct *p) { SPOOL_Q_GETPRINTERDRIVER2 q_u; @@ -361,13 +361,7 @@ static BOOL api_spoolss_getprinterdriver2(pipes_struct *p) return False; } - /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _spoolss_getprinterdriver2(&q_u.handle, &q_u.architecture, q_u.level, - q_u.clientmajorversion, q_u.clientminorversion, - r_u.buffer, q_u.offered, - &r_u.needed, &r_u.servermajorversion, &r_u.serverminorversion); + r_u.status = _spoolss_getprinterdriver2(p, &q_u, &r_u); if(!spoolss_io_r_getprinterdriver2("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_getprinterdriver2: unable to marshall SPOOL_R_GETPRINTERDRIVER2.\n")); @@ -382,6 +376,7 @@ static BOOL api_spoolss_getprinterdriver2(pipes_struct *p) * called from the spoolss dispatcher * ********************************************************************/ + static BOOL api_spoolss_startpageprinter(pipes_struct *p) { SPOOL_Q_STARTPAGEPRINTER q_u; @@ -397,7 +392,7 @@ static BOOL api_spoolss_startpageprinter(pipes_struct *p) return False; } - r_u.status = _spoolss_startpageprinter(&q_u.handle); + r_u.status = _spoolss_startpageprinter(p, &q_u, &r_u); if(!spoolss_io_r_startpageprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_startpageprinter: unable to marshall SPOOL_R_STARTPAGEPRINTER.\n")); @@ -407,12 +402,12 @@ static BOOL api_spoolss_startpageprinter(pipes_struct *p) return True; } - /******************************************************************** * api_spoolss_getprinter * called from the spoolss dispatcher * ********************************************************************/ + static BOOL api_spoolss_endpageprinter(pipes_struct *p) { SPOOL_Q_ENDPAGEPRINTER q_u; @@ -428,7 +423,7 @@ static BOOL api_spoolss_endpageprinter(pipes_struct *p) return False; } - r_u.status = _spoolss_endpageprinter(&q_u.handle); + r_u.status = _spoolss_endpageprinter(p, &q_u, &r_u); if(!spoolss_io_r_endpageprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_endpageprinter: unable to marshall SPOOL_R_ENDPAGEPRINTER.\n")); @@ -440,6 +435,7 @@ static BOOL api_spoolss_endpageprinter(pipes_struct *p) /******************************************************************** ********************************************************************/ + static BOOL api_spoolss_startdocprinter(pipes_struct *p) { SPOOL_Q_STARTDOCPRINTER q_u; @@ -455,10 +451,7 @@ static BOOL api_spoolss_startdocprinter(pipes_struct *p) return False; } - r_u.status = _spoolss_startdocprinter(&q_u.handle, - q_u.doc_info_container.level, p, - &q_u.doc_info_container.docinfo, - &r_u.jobid); + r_u.status = _spoolss_startdocprinter(p, &q_u, &r_u); if(!spoolss_io_r_startdocprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_startdocprinter: unable to marshall SPOOL_R_STARTDOCPRINTER.\n")); @@ -468,7 +461,6 @@ static BOOL api_spoolss_startdocprinter(pipes_struct *p) return True; } - /******************************************************************** ********************************************************************/ static BOOL api_spoolss_enddocprinter(pipes_struct *p) diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0e09bff289..4b5d27d002 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3739,15 +3739,28 @@ static uint32 getprinterdriver2_level6(fstring servername, fstring architecture, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getprinterdriver2(POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level, - uint32 clientmajorversion, uint32 clientminorversion, - NEW_BUFFER *buffer, uint32 offered, - uint32 *needed, uint32 *servermajorversion, uint32 *serverminorversion) + +uint32 _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_u, SPOOL_R_GETPRINTERDRIVER2 *r_u) { + POLICY_HND *handle = &q_u->handle; + UNISTR2 *uni_arch = &q_u->architecture; + uint32 level = q_u->level; + uint32 clientmajorversion = q_u->clientmajorversion; +/* uint32 clientminorversion = q_u->clientminorversion; - notused. */ + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + uint32 *servermajorversion = &r_u->servermajorversion; + uint32 *serverminorversion = &r_u->serverminorversion; + fstring servername; fstring architecture; int snum; + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_spoolss_getprinterdriver2\n")); *needed=0; @@ -3776,8 +3789,11 @@ uint32 _spoolss_getprinterdriver2(POLICY_HND *handle, const UNISTR2 *uni_arch, u /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_startpageprinter(POLICY_HND *handle) + +uint32 _spoolss_startpageprinter(pipes_struct *p, SPOOL_Q_STARTPAGEPRINTER *q_u, SPOOL_R_STARTPAGEPRINTER *r_u) { + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer = find_printer_index_by_hnd(handle); if (OPEN_HANDLE(Printer)) { @@ -3791,8 +3807,11 @@ uint32 _spoolss_startpageprinter(POLICY_HND *handle) /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_endpageprinter(POLICY_HND *handle) + +uint32 _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPOOL_R_ENDPAGEPRINTER *r_u) { + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer = find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) { @@ -3805,16 +3824,19 @@ uint32 _spoolss_endpageprinter(POLICY_HND *handle) return NT_STATUS_NO_PROBLEMO; } - /******************************************************************** * api_spoolss_getprinter * called from the spoolss dispatcher * ********************************************************************/ -uint32 _spoolss_startdocprinter(POLICY_HND *handle, uint32 level, - pipes_struct *p, DOC_INFO *docinfo, - uint32 *jobid) + +uint32 _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, SPOOL_R_STARTDOCPRINTER *r_u) { + POLICY_HND *handle = &q_u->handle; +/* uint32 level = q_u->doc_info_container.level; - notused. */ + DOC_INFO *docinfo = &q_u->doc_info_container.docinfo; + uint32 *jobid = &r_u->jobid; + DOC_INFO_1 *info_1 = &docinfo->doc_info_1; int snum; pstring jobname; -- cgit From acc06fc7a83f1bdd28bddec7fcf47319d4c35b2b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Feb 2001 02:38:09 +0000 Subject: More converted to canonical format. Home now - do the rest tomorrow... Jeremy. (This used to be commit 9d5979f51ec7b2a62fb9b290eb0393594cfa6224) --- source3/rpc_server/srv_spoolss.c | 52 +++++--------- source3/rpc_server/srv_spoolss_nt.c | 136 +++++++++++++++++++++++++----------- 2 files changed, 113 insertions(+), 75 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index d8eaab2714..685deba2fa 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -463,6 +463,7 @@ static BOOL api_spoolss_startdocprinter(pipes_struct *p) /******************************************************************** ********************************************************************/ + static BOOL api_spoolss_enddocprinter(pipes_struct *p) { SPOOL_Q_ENDDOCPRINTER q_u; @@ -478,7 +479,7 @@ static BOOL api_spoolss_enddocprinter(pipes_struct *p) return False; } - r_u.status = _spoolss_enddocprinter(&q_u.handle); + r_u.status = _spoolss_enddocprinter(p, &q_u, &r_u); if(!spoolss_io_r_enddocprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_enddocprinter: unable to marshall SPOOL_R_ENDDOCPRINTER.\n")); @@ -488,9 +489,9 @@ static BOOL api_spoolss_enddocprinter(pipes_struct *p) return True; } - /******************************************************************** ********************************************************************/ + static BOOL api_spoolss_writeprinter(pipes_struct *p) { SPOOL_Q_WRITEPRINTER q_u; @@ -506,11 +507,7 @@ static BOOL api_spoolss_writeprinter(pipes_struct *p) return False; } - r_u.status = _spoolss_writeprinter(&q_u.handle, - q_u.buffer_size, - q_u.buffer, - &q_u.buffer_size2); - r_u.buffer_written = q_u.buffer_size2; + r_u.status = _spoolss_writeprinter(p, &q_u, &r_u); if(!spoolss_io_r_writeprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_writeprinter: unable to marshall SPOOL_R_WRITEPRINTER.\n")); @@ -523,6 +520,7 @@ static BOOL api_spoolss_writeprinter(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_setprinter(pipes_struct *p) { SPOOL_Q_SETPRINTER q_u; @@ -538,9 +536,7 @@ static BOOL api_spoolss_setprinter(pipes_struct *p) return False; } - r_u.status = _spoolss_setprinter(&q_u.handle, q_u.level, &q_u.info, - q_u.devmode_ctr, q_u.secdesc_ctr, - q_u.command, p); + r_u.status = _spoolss_setprinter(p, &q_u, &r_u); if(!spoolss_io_r_setprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_setprinter: unable to marshall SPOOL_R_SETPRINTER.\n")); @@ -552,6 +548,7 @@ static BOOL api_spoolss_setprinter(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_fcpn(pipes_struct *p) { SPOOL_Q_FCPN q_u; @@ -567,7 +564,7 @@ static BOOL api_spoolss_fcpn(pipes_struct *p) return False; } - r_u.status = _spoolss_fcpn(&q_u.handle); + r_u.status = _spoolss_fcpn(p, &q_u, &r_u); if(!spoolss_io_r_fcpn("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_fcpn: unable to marshall SPOOL_R_FCPN.\n")); @@ -577,9 +574,9 @@ static BOOL api_spoolss_fcpn(pipes_struct *p) return True; } - /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_addjob(pipes_struct *p) { SPOOL_Q_ADDJOB q_u; @@ -595,11 +592,7 @@ static BOOL api_spoolss_addjob(pipes_struct *p) return False; } - /* that's an [in out] buffer (despite appearences to the contrary) */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _spoolss_addjob(&q_u.handle, q_u.level, - r_u.buffer, q_u.offered, &r_u.needed); + r_u.status = _spoolss_addjob(p, &q_u, &r_u); if(!spoolss_io_r_addjob("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_addjob: unable to marshall SPOOL_R_ADDJOB.\n")); @@ -609,9 +602,9 @@ static BOOL api_spoolss_addjob(pipes_struct *p) return True; } - /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_enumjobs(pipes_struct *p) { SPOOL_Q_ENUMJOBS q_u; @@ -627,12 +620,7 @@ static BOOL api_spoolss_enumjobs(pipes_struct *p) return False; } - /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _spoolss_enumjobs(&q_u.handle, q_u.firstjob, q_u.numofjobs, q_u.level, - r_u.buffer, q_u.offered, - &r_u.needed, &r_u.returned); + r_u.status = _spoolss_enumjobs(p, &q_u, &r_u); if (!spoolss_io_r_enumjobs("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_enumjobs: unable to marshall SPOOL_R_ENUMJOBS.\n")); @@ -642,9 +630,9 @@ static BOOL api_spoolss_enumjobs(pipes_struct *p) return True; } - /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_schedulejob(pipes_struct *p) { SPOOL_Q_SCHEDULEJOB q_u; @@ -660,7 +648,7 @@ static BOOL api_spoolss_schedulejob(pipes_struct *p) return False; } - r_u.status = _spoolss_schedulejob(&q_u.handle, q_u.jobid); + r_u.status = _spoolss_schedulejob(p, &q_u, &r_u); if(!spoolss_io_r_schedulejob("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_schedulejob: unable to marshall SPOOL_R_SCHEDULEJOB.\n")); @@ -672,6 +660,7 @@ static BOOL api_spoolss_schedulejob(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_setjob(pipes_struct *p) { SPOOL_Q_SETJOB q_u; @@ -687,8 +676,7 @@ static BOOL api_spoolss_setjob(pipes_struct *p) return False; } - r_u.status = _spoolss_setjob(&q_u.handle, q_u.jobid, - q_u.level, p, &q_u.ctr, q_u.command); + r_u.status = _spoolss_setjob(p, &q_u, &r_u); if(!spoolss_io_r_setjob("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_setjob: unable to marshall SPOOL_R_SETJOB.\n")); @@ -716,12 +704,7 @@ static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p) return False; } - /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _spoolss_enumprinterdrivers(&q_u.name, &q_u.environment, q_u.level, - r_u.buffer, q_u.offered, - &r_u.needed, &r_u.returned); + r_u.status = _spoolss_enumprinterdrivers(p, &q_u, &r_u); if (!new_spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) { DEBUG(0,("new_spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n")); @@ -731,7 +714,6 @@ static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p) return True; } - /**************************************************************************** ****************************************************************************/ static BOOL api_spoolss_getform(pipes_struct *p) diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4b5d27d002..1f179a9b1d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -991,6 +991,26 @@ BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, return True; } +/******************************************************************** + * _spoolss_enddocprinter_internal. + ********************************************************************/ + +static uint32 _spoolss_enddocprinter_internal(POLICY_HND *handle) +{ + Printer_entry *Printer=find_printer_index_by_hnd(handle); + + if (!OPEN_HANDLE(Printer)) { + DEBUG(0,("_spoolss_enddocprinter_internal: Invalid handle (%s)\n", OUR_HANDLE(handle))); + return ERROR_INVALID_HANDLE; + } + + Printer->document_started=False; + print_job_end(Printer->jobid,True); + /* error codes unhandled so far ... */ + + return 0x0; +} + /******************************************************************** * api_spoolss_closeprinter ********************************************************************/ @@ -1002,7 +1022,7 @@ uint32 _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL_R Printer_entry *Printer=find_printer_index_by_hnd(handle); if (Printer && Printer->document_started) - _spoolss_enddocprinter(handle); /* print job was not closed */ + _spoolss_enddocprinter_internal(handle); /* print job was not closed */ memcpy(&r_u->handle, &q_u->handle, sizeof(r_u->handle)); @@ -1025,7 +1045,7 @@ uint32 _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL uint32 result; if (Printer && Printer->document_started) - _spoolss_enddocprinter(handle); /* print job was not closed */ + _spoolss_enddocprinter_internal(handle); /* print job was not closed */ memcpy(&r_u->handle, &q_u->handle, sizeof(r_u->handle)); @@ -3898,38 +3918,36 @@ uint32 _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S * called from the spoolss dispatcher * ********************************************************************/ -uint32 _spoolss_enddocprinter(POLICY_HND *handle) + +uint32 _spoolss_enddocprinter(pipes_struct *p, SPOOL_Q_ENDDOCPRINTER *q_u, SPOOL_R_ENDDOCPRINTER *r_u) { - Printer_entry *Printer=find_printer_index_by_hnd(handle); - - if (!OPEN_HANDLE(Printer)) { - DEBUG(0,("_spoolss_enddocprinter: Invalid handle (%s)\n", OUR_HANDLE(handle))); - return ERROR_INVALID_HANDLE; - } - - Printer->document_started=False; - print_job_end(Printer->jobid,True); - /* error codes unhandled so far ... */ + POLICY_HND *handle = &q_u->handle; - return 0x0; + return _spoolss_enddocprinter_internal(handle); } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_writeprinter( POLICY_HND *handle, - uint32 buffer_size, - uint8 *buffer, - uint32 *buffer_written) + +uint32 _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R_WRITEPRINTER *r_u) { + POLICY_HND *handle = &q_u->handle; + uint32 buffer_size = q_u->buffer_size; + uint8 *buffer = q_u->buffer; + uint32 *buffer_written = &q_u->buffer_size2; + Printer_entry *Printer = find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) { DEBUG(0,("_spoolss_writeprinter: Invalid handle (%s)\n",OUR_HANDLE(handle))); + r_u->buffer_written = q_u->buffer_size2; return ERROR_INVALID_HANDLE; } - (*buffer_written) = print_job_write(Printer->jobid, (char *)buffer, - buffer_size); + (*buffer_written) = print_job_write(Printer->jobid, (char *)buffer, buffer_size); + + + r_u->buffer_written = q_u->buffer_size2; return 0x0; } @@ -4530,12 +4548,16 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_setprinter(POLICY_HND *handle, uint32 level, - const SPOOL_PRINTER_INFO_LEVEL *info, - DEVMODE_CTR devmode_ctr, - SEC_DESC_BUF *secdesc_ctr, - uint32 command, pipes_struct *p) + +uint32 _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SETPRINTER *r_u) { + POLICY_HND *handle = &q_u->handle; + uint32 level = q_u->level; + SPOOL_PRINTER_INFO_LEVEL *info = &q_u->info; + DEVMODE_CTR devmode_ctr = q_u->devmode_ctr; + SEC_DESC_BUF *secdesc_ctr = q_u->secdesc_ctr; + uint32 command = q_u->command; + Printer_entry *Printer = find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) { @@ -4559,8 +4581,11 @@ uint32 _spoolss_setprinter(POLICY_HND *handle, uint32 level, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_fcpn(POLICY_HND *handle) + +uint32 _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) { + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer= find_printer_index_by_hnd(handle); if (!OPEN_HANDLE(Printer)) { @@ -4587,11 +4612,13 @@ uint32 _spoolss_fcpn(POLICY_HND *handle) /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_addjob(POLICY_HND *handle, uint32 level, - NEW_BUFFER *buffer, uint32 offered, - uint32 *needed) + +uint32 _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u) { - *needed = 0; + /* that's an [in out] buffer (despite appearences to the contrary) */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + + r_u->needed = 0; return ERROR_INVALID_PARAMETER; /* this is what a NT server returns for AddJob. AddJob must fail on non-local @@ -4779,14 +4806,26 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum, /**************************************************************************** Enumjobs. ****************************************************************************/ -uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, uint32 level, - NEW_BUFFER *buffer, uint32 offered, - uint32 *needed, uint32 *returned) + +uint32 _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJOBS *r_u) { + POLICY_HND *handle = &q_u->handle; +/* uint32 firstjob = q_u->firstjob; - notused. */ +/* uint32 numofjobs = q_u->numofjobs; - notused. */ + uint32 level = q_u->level; + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + uint32 *returned = &r_u->returned; + int snum; print_queue_struct *queue=NULL; print_status_struct prt_status; + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_spoolss_enumjobs\n")); ZERO_STRUCT(prt_status); @@ -4817,19 +4856,25 @@ uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs, } } - /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_schedulejob( POLICY_HND *handle, uint32 jobid) + +uint32 _spoolss_schedulejob( pipes_struct *p, SPOOL_Q_SCHEDULEJOB *q_u, SPOOL_R_SCHEDULEJOB *r_u) { return 0x0; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_setjob(POLICY_HND *handle, uint32 jobid, uint32 level, - pipes_struct *p, JOB_INFO *ctr, uint32 command) + +uint32 _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u) { + POLICY_HND *handle = &q_u->handle; + uint32 jobid = q_u->jobid; +/* uint32 level = q_u->level; - notused. */ +/* JOB_INFO *ctr = &q_u->ctr; - notused. */ + uint32 command = q_u->command; + struct current_user user; print_status_struct prt_status; int snum, errcode = ERROR_INVALID_FUNCTION; @@ -5104,14 +5149,25 @@ static uint32 enumprinterdrivers_level3(fstring servername, fstring architecture /**************************************************************************** Enumerates all printer drivers. ****************************************************************************/ -uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32 level, - NEW_BUFFER *buffer, uint32 offered, - uint32 *needed, uint32 *returned) + +uint32 _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, SPOOL_R_ENUMPRINTERDRIVERS *r_u) { +/* UNISTR2 *name = &q_u->name; - notused. */ + UNISTR2 *environment = &q_u->environment; + uint32 level = q_u->level; + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + uint32 *returned = &r_u->returned; + fstring *list = NULL; fstring servername; fstring architecture; + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_spoolss_enumprinterdrivers\n")); fstrcpy(servername, global_myname); *needed=0; -- cgit From bd228fb059e3c8a7c82a3019e31163f549881773 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Feb 2001 20:35:08 +0000 Subject: Fix for stack return from "Jim McDonough" . Jeremy. (This used to be commit 7f45836c85df9cb04d062b71afa5e55014841859) --- source3/rpc_server/srv_wkssvc_nt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 81d3e1ef8f..688c7f1d01 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -63,12 +63,17 @@ static void create_wks_info_100(WKS_INFO_100 *inf) uint32 _wks_query_info(pipes_struct *p, WKS_Q_QUERY_INFO *q_u, WKS_R_QUERY_INFO *r_u) { - WKS_INFO_100 wks100; + WKS_INFO_100 *wks100 = NULL; DEBUG(5,("_wks_query_info: %d\n", __LINE__)); - create_wks_info_100(&wks100); - init_wks_r_query_info(r_u, q_u->switch_value, &wks100, NT_STATUS_NOPROBLEMO); + wks100 = (WKS_INFO_100 *)talloc_zero(p->mem_ctx, sizeof(WKS_INFO_100)); + + if (!wks100) + 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); DEBUG(5,("_wks_query_info: %d\n", __LINE__)); -- cgit From 30d74f54e6d6c876d3a6b8258b2c0cab1b5a3ef3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Feb 2001 21:19:31 +0000 Subject: Finished converion of spoolss code to canonical format. Now to work on the PRINT_XX struct alloc/free issues. Jeremy. (This used to be commit db98d4b020032b2a934b21bfdf9082765692fc5a) --- source3/rpc_server/srv_spoolss.c | 96 +++++----------- source3/rpc_server/srv_spoolss_nt.c | 218 ++++++++++++++++++++++++++++-------- 2 files changed, 200 insertions(+), 114 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 685deba2fa..a2bde97865 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -716,6 +716,7 @@ static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_getform(pipes_struct *p) { SPOOL_Q_GETFORM q_u; @@ -731,11 +732,7 @@ static BOOL api_spoolss_getform(pipes_struct *p) return False; } - /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _spoolss_getform(&q_u.handle, q_u.level, - &q_u.formname, r_u.buffer, q_u.offered, &r_u.needed); + r_u.status = _spoolss_getform(p, &q_u, &r_u); if (!new_spoolss_io_r_getform("",&r_u,rdata,0)) { DEBUG(0,("new_spoolss_io_r_getform: unable to marshall SPOOL_R_GETFORM.\n")); @@ -747,6 +744,7 @@ static BOOL api_spoolss_getform(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_enumforms(pipes_struct *p) { SPOOL_Q_ENUMFORMS q_u; @@ -762,12 +760,7 @@ static BOOL api_spoolss_enumforms(pipes_struct *p) return False; } - /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _new_spoolss_enumforms(&q_u.handle, q_u.level, - r_u.buffer, q_u.offered, - &r_u.needed, &r_u.numofforms); + r_u.status = _new_spoolss_enumforms(p, &q_u, &r_u); if (!new_spoolss_io_r_enumforms("",&r_u,rdata,0)) { DEBUG(0,("new_spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n")); @@ -777,9 +770,9 @@ static BOOL api_spoolss_enumforms(pipes_struct *p) return True; } - /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_enumports(pipes_struct *p) { SPOOL_Q_ENUMPORTS q_u; @@ -795,12 +788,7 @@ static BOOL api_spoolss_enumports(pipes_struct *p) return False; } - /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _spoolss_enumports(&q_u.name, q_u.level, - r_u.buffer, q_u.offered, - &r_u.needed, &r_u.returned); + r_u.status = _spoolss_enumports(p, &q_u, &r_u); if (!new_spoolss_io_r_enumports("",&r_u,rdata,0)) { DEBUG(0,("new_spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n")); @@ -810,9 +798,9 @@ static BOOL api_spoolss_enumports(pipes_struct *p) return True; } - /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_addprinterex(pipes_struct *p) { SPOOL_Q_ADDPRINTEREX q_u; @@ -828,11 +816,7 @@ static BOOL api_spoolss_addprinterex(pipes_struct *p) return False; } - r_u.status = _spoolss_addprinterex(&q_u.server_name, - q_u.level, &q_u.info, - q_u.unk0, q_u.unk1, q_u.unk2, q_u.unk3, - q_u.user_switch, &q_u.user_ctr, - &r_u.handle); + r_u.status = _spoolss_addprinterex(p, &q_u, &r_u); if(!spoolss_io_r_addprinterex("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_addprinterex: unable to marshall SPOOL_R_ADDPRINTEREX.\n")); @@ -844,6 +828,7 @@ static BOOL api_spoolss_addprinterex(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_addprinterdriver(pipes_struct *p) { SPOOL_Q_ADDPRINTERDRIVER q_u; @@ -859,7 +844,7 @@ static BOOL api_spoolss_addprinterdriver(pipes_struct *p) return False; } - r_u.status = _spoolss_addprinterdriver(p, &q_u.server_name, q_u.level, &q_u.info); + r_u.status = _spoolss_addprinterdriver(p, &q_u, &r_u); if(!spoolss_io_r_addprinterdriver("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_addprinterdriver: unable to marshall SPOOL_R_ADDPRINTERDRIVER.\n")); @@ -871,6 +856,7 @@ static BOOL api_spoolss_addprinterdriver(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_getprinterdriverdirectory(pipes_struct *p) { SPOOL_Q_GETPRINTERDRIVERDIR q_u; @@ -886,12 +872,7 @@ static BOOL api_spoolss_getprinterdriverdirectory(pipes_struct *p) return False; } - /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _spoolss_getprinterdriverdirectory(&q_u.name, &q_u.environment, q_u.level, - r_u.buffer, q_u.offered, - &r_u.needed); + r_u.status = _spoolss_getprinterdriverdirectory(p, &q_u, &r_u); if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n")); @@ -903,6 +884,7 @@ static BOOL api_spoolss_getprinterdriverdirectory(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_enumprinterdata(pipes_struct *p) { SPOOL_Q_ENUMPRINTERDATA q_u; @@ -918,10 +900,7 @@ static BOOL api_spoolss_enumprinterdata(pipes_struct *p) return False; } - r_u.status = _spoolss_enumprinterdata(p, &q_u.handle, q_u.index, q_u.valuesize, q_u.datasize, - &r_u.valuesize, &r_u.value, &r_u.realvaluesize, - &r_u.type, - &r_u.datasize, &r_u.data, &r_u.realdatasize); + r_u.status = _spoolss_enumprinterdata(p, &q_u, &r_u); if(!spoolss_io_r_enumprinterdata("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_enumprinterdata: unable to marshall SPOOL_R_ENUMPRINTERDATA.\n")); @@ -933,6 +912,7 @@ static BOOL api_spoolss_enumprinterdata(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_setprinterdata(pipes_struct *p) { SPOOL_Q_SETPRINTERDATA q_u; @@ -948,9 +928,7 @@ static BOOL api_spoolss_setprinterdata(pipes_struct *p) return False; } - r_u.status = _spoolss_setprinterdata(&q_u.handle, - &q_u.value, q_u.type, q_u.max_len, - q_u.data, q_u.real_len, q_u.numeric_data); + r_u.status = _spoolss_setprinterdata(p, &q_u, &r_u); if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n")); @@ -962,6 +940,7 @@ static BOOL api_spoolss_setprinterdata(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_addform(pipes_struct *p) { SPOOL_Q_ADDFORM q_u; @@ -977,7 +956,7 @@ static BOOL api_spoolss_addform(pipes_struct *p) return False; } - r_u.status = _spoolss_addform(&q_u.handle, q_u.level, &q_u.form); + r_u.status = _spoolss_addform(p, &q_u, &r_u); if(!spoolss_io_r_addform("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_addform: unable to marshall SPOOL_R_ADDFORM.\n")); @@ -989,6 +968,7 @@ static BOOL api_spoolss_addform(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_deleteform(pipes_struct *p) { SPOOL_Q_DELETEFORM q_u; @@ -1004,7 +984,7 @@ static BOOL api_spoolss_deleteform(pipes_struct *p) return False; } - r_u.status = _spoolss_deleteform(&q_u.handle, &q_u.name); + r_u.status = _spoolss_deleteform(p, &q_u, &r_u); if(!spoolss_io_r_deleteform("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_deleteform: unable to marshall SPOOL_R_DELETEFORM.\n")); @@ -1016,6 +996,7 @@ static BOOL api_spoolss_deleteform(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_setform(pipes_struct *p) { SPOOL_Q_SETFORM q_u; @@ -1031,7 +1012,7 @@ static BOOL api_spoolss_setform(pipes_struct *p) return False; } - r_u.status = _spoolss_setform(&q_u.handle, &q_u.name, q_u.level, &q_u.form); + r_u.status = _spoolss_setform(p, &q_u, &r_u); if(!spoolss_io_r_setform("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_setform: unable to marshall SPOOL_R_SETFORM.\n")); @@ -1043,6 +1024,7 @@ static BOOL api_spoolss_setform(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_enumprintprocessors(pipes_struct *p) { SPOOL_Q_ENUMPRINTPROCESSORS q_u; @@ -1058,12 +1040,7 @@ static BOOL api_spoolss_enumprintprocessors(pipes_struct *p) return False; } - /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _spoolss_enumprintprocessors(&q_u.name, &q_u.environment, q_u.level, - r_u.buffer, q_u.offered, - &r_u.needed, &r_u.returned); + r_u.status = _spoolss_enumprintprocessors(p, &q_u, &r_u); if(!spoolss_io_r_enumprintprocessors("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_enumprintprocessors: unable to marshall SPOOL_R_ENUMPRINTPROCESSORS.\n")); @@ -1075,6 +1052,7 @@ static BOOL api_spoolss_enumprintprocessors(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_enumprintprocdatatypes(pipes_struct *p) { SPOOL_Q_ENUMPRINTPROCDATATYPES q_u; @@ -1090,12 +1068,7 @@ static BOOL api_spoolss_enumprintprocdatatypes(pipes_struct *p) return False; } - /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _spoolss_enumprintprocdatatypes(&q_u.name, &q_u.processor, q_u.level, - r_u.buffer, q_u.offered, - &r_u.needed, &r_u.returned); + r_u.status = _spoolss_enumprintprocdatatypes(p, &q_u, &r_u); if(!spoolss_io_r_enumprintprocdatatypes("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_enumprintprocdatatypes: unable to marshall SPOOL_R_ENUMPRINTPROCDATATYPES.\n")); @@ -1107,6 +1080,7 @@ static BOOL api_spoolss_enumprintprocdatatypes(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_enumprintmonitors(pipes_struct *p) { SPOOL_Q_ENUMPRINTMONITORS q_u; @@ -1122,12 +1096,7 @@ static BOOL api_spoolss_enumprintmonitors(pipes_struct *p) return False; } - /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _spoolss_enumprintmonitors(&q_u.name, q_u.level, - r_u.buffer, q_u.offered, - &r_u.needed, &r_u.returned); + r_u.status = _spoolss_enumprintmonitors(p, &q_u, &r_u); if (!spoolss_io_r_enumprintmonitors("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_enumprintmonitors: unable to marshall SPOOL_R_ENUMPRINTMONITORS.\n")); @@ -1139,6 +1108,7 @@ static BOOL api_spoolss_enumprintmonitors(pipes_struct *p) /**************************************************************************** ****************************************************************************/ + static BOOL api_spoolss_getjob(pipes_struct *p) { SPOOL_Q_GETJOB q_u; @@ -1151,12 +1121,7 @@ static BOOL api_spoolss_getjob(pipes_struct *p) return False; } - /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _spoolss_getjob(&q_u.handle, q_u.jobid, q_u.level, - r_u.buffer, q_u.offered, - &r_u.needed); + r_u.status = _spoolss_getjob(p, &q_u, &r_u); if(!spoolss_io_r_getjob("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_getjob: unable to marshall SPOOL_R_GETJOB.\n")); @@ -1169,6 +1134,7 @@ static BOOL api_spoolss_getjob(pipes_struct *p) /******************************************************************* \pipe\spoolss commands ********************************************************************/ + struct api_struct api_spoolss_cmds[] = { {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex }, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1f179a9b1d..8e7e3c28e5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5191,6 +5191,7 @@ uint32 _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS /**************************************************************************** ****************************************************************************/ + static void fill_form_1(FORM_1 *form, nt_forms_struct *list) { form->flag=list->flag; @@ -5205,15 +5206,25 @@ static void fill_form_1(FORM_1 *form, nt_forms_struct *list) /**************************************************************************** ****************************************************************************/ -uint32 _new_spoolss_enumforms( POLICY_HND *handle, uint32 level, - NEW_BUFFER *buffer, uint32 offered, - uint32 *needed, uint32 *numofforms) + +uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u) { +/* POLICY_HND *handle = &q_u->handle; - notused. */ + uint32 level = q_u->level; + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + uint32 *numofforms = &r_u->numofforms; + nt_forms_struct *list=NULL; FORM_1 *forms_1; int buffer_size=0; int i; + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_new_spoolss_enumforms\n")); DEBUGADD(5,("Offered buffer size [%d]\n", offered)); DEBUGADD(5,("Info level [%d]\n", level)); @@ -5275,14 +5286,26 @@ uint32 _new_spoolss_enumforms( POLICY_HND *handle, uint32 level, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getform( POLICY_HND *handle, uint32 level, UNISTR2 *uni_formname, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) + +uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM *r_u) { +/* POLICY_HND *handle = &q_u->handle; - notused. */ + uint32 level = q_u->level; + UNISTR2 *uni_formname = &q_u->formname; + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + nt_forms_struct *list=NULL; FORM_1 form_1; fstring form_name; int buffer_size=0; int numofforms, i; + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + unistr2_to_ascii(form_name, uni_formname, sizeof(form_name)-1); DEBUG(4,("_spoolss_getform\n")); @@ -5554,10 +5577,20 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need /**************************************************************************** enumports. ****************************************************************************/ -uint32 _spoolss_enumports( UNISTR2 *name, uint32 level, - NEW_BUFFER *buffer, uint32 offered, - uint32 *needed, uint32 *returned) + +uint32 _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u) { +/* UNISTR2 *name = &q_u->name; - notused. */ + uint32 level = q_u->level; + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + uint32 *returned = &r_u->returned; + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_spoolss_enumports\n")); *returned=0; @@ -5646,12 +5679,20 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level, - const SPOOL_PRINTER_INFO_LEVEL *info, - uint32 unk0, uint32 unk1, uint32 unk2, uint32 unk3, - uint32 user_switch, const SPOOL_USER_CTR *user, - POLICY_HND *handle) + +uint32 _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_R_ADDPRINTEREX *r_u) { + UNISTR2 *uni_srv_name = &q_u->server_name; + uint32 level = q_u->level; + SPOOL_PRINTER_INFO_LEVEL *info = &q_u->info; + uint32 unk0 = q_u->unk0; + uint32 unk1 = q_u->unk1; + uint32 unk2 = q_u->unk2; + uint32 unk3 = q_u->unk3; + uint32 user_switch = q_u->user_switch; + SPOOL_USER_CTR *user = &q_u->user_ctr; + POLICY_HND *handle = &r_u->handle; + switch (level) { case 1: /* we don't handle yet */ @@ -5668,9 +5709,13 @@ uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_addprinterdriver(pipes_struct *p, const UNISTR2 *server_name, - uint32 level, const SPOOL_PRINTER_DRIVER_INFO_LEVEL *info) + +uint32 _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, SPOOL_R_ADDPRINTERDRIVER *r_u) { +/* UNISTR2 *server_name = &q_u->server_name; - notused. */ + uint32 level = q_u->level; + SPOOL_PRINTER_DRIVER_INFO_LEVEL *info = &q_u->info; + uint32 err = NT_STATUS_NO_PROBLEMO; NT_PRINTER_DRIVER_INFO_LEVEL driver; struct current_user user; @@ -5751,10 +5796,20 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getprinterdriverdirectory(UNISTR2 *name, UNISTR2 *uni_environment, uint32 level, - NEW_BUFFER *buffer, uint32 offered, - uint32 *needed) + +uint32 _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, SPOOL_R_GETPRINTERDRIVERDIR *r_u) { + UNISTR2 *name = &q_u->name; + UNISTR2 *uni_environment = &q_u->environment; + uint32 level = q_u->level; + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_spoolss_getprinterdriverdirectory\n")); *needed=0; @@ -5769,12 +5824,21 @@ uint32 _spoolss_getprinterdriverdirectory(UNISTR2 *name, UNISTR2 *uni_environmen /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_enumprinterdata(pipes_struct *p, POLICY_HND *handle, uint32 idx, - uint32 in_value_len, uint32 in_data_len, - uint32 *out_max_value_len, uint16 **out_value, uint32 *out_value_len, - uint32 *out_type, - uint32 *out_max_data_len, uint8 **data_out, uint32 *out_data_len) + +uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, SPOOL_R_ENUMPRINTERDATA *r_u) { + POLICY_HND *handle = &q_u->handle; + uint32 idx = q_u->index; + uint32 in_value_len = q_u->valuesize; + uint32 in_data_len = q_u->datasize; + uint32 *out_max_value_len = &r_u->valuesize; + uint16 **out_value = &r_u->value; + uint32 *out_value_len = &r_u->realvaluesize; + uint32 *out_type = &r_u->type; + uint32 *out_max_data_len = &r_u->datasize; + uint8 **data_out = &r_u->data; + uint32 *out_data_len = &r_u->realdatasize; + NT_PRINTER_INFO_LEVEL *printer = NULL; fstring value; @@ -5927,14 +5991,17 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, POLICY_HND *handle, uint32 idx, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_setprinterdata( POLICY_HND *handle, - const UNISTR2 *value, - uint32 type, - uint32 max_len, - const uint8 *data, - uint32 real_len, - uint32 numeric_data) + +uint32 _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SPOOL_R_SETPRINTERDATA *r_u) { + POLICY_HND *handle = &q_u->handle; + UNISTR2 *value = &q_u->value; + uint32 type = q_u->type; +/* uint32 max_len = q_u->max_len; - notused. */ + uint8 *data = q_u->data; + uint32 real_len = q_u->real_len; +/* uint32 numeric_data = q_u->numeric_data; - notused. */ + NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_PARAM *param = NULL, old_param; int snum=0; @@ -6047,10 +6114,13 @@ uint32 _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_addform( POLICY_HND *handle, - uint32 level, - const FORM *form) + +uint32 _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM *r_u) { + POLICY_HND *handle = &q_u->handle; +/* uint32 level = q_u->level; - notused. */ + FORM *form = &q_u->form; + int count=0; nt_forms_struct *list=NULL; Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -6074,8 +6144,12 @@ uint32 _spoolss_addform( POLICY_HND *handle, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_deleteform( POLICY_HND *handle, UNISTR2 *form_name) + +uint32 _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DELETEFORM *r_u) { + POLICY_HND *handle = &q_u->handle; + UNISTR2 *form_name = &q_u->name; + int count=0; uint32 ret = 0; nt_forms_struct *list=NULL; @@ -6099,11 +6173,14 @@ uint32 _spoolss_deleteform( POLICY_HND *handle, UNISTR2 *form_name) /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_setform( POLICY_HND *handle, - const UNISTR2 *uni_name, - uint32 level, - const FORM *form) + +uint32 _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM *r_u) { + POLICY_HND *handle = &q_u->handle; +/* UNISTR2 *uni_name = &q_u->name; - notused. */ +/* uint32 level = q_u->level; - notused. */ + FORM *form = &q_u->form; + int count=0; nt_forms_struct *list=NULL; Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -6156,10 +6233,21 @@ static uint32 enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_enumprintprocessors(UNISTR2 *name, UNISTR2 *environment, uint32 level, - NEW_BUFFER *buffer, uint32 offered, - uint32 *needed, uint32 *returned) + +uint32 _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, SPOOL_R_ENUMPRINTPROCESSORS *r_u) { +/* UNISTR2 *name = &q_u->name; - notused. */ +/* UNISTR2 *environment = &q_u->environment; - notused. */ + uint32 level = q_u->level; + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + uint32 *returned = &r_u->returned; + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(5,("spoolss_enumprintprocessors\n")); /* @@ -6213,10 +6301,21 @@ static uint32 enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_enumprintprocdatatypes(UNISTR2 *name, UNISTR2 *processor, uint32 level, - NEW_BUFFER *buffer, uint32 offered, - uint32 *needed, uint32 *returned) + +uint32 _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u) { +/* UNISTR2 *name = &q_u->name; - notused. */ +/* UNISTR2 *processor = &q_u->processor; - notused. */ + uint32 level = q_u->level; + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + uint32 *returned = &r_u->returned; + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(5,("_spoolss_enumprintprocdatatypes\n")); *returned=0; @@ -6233,6 +6332,7 @@ uint32 _spoolss_enumprintprocdatatypes(UNISTR2 *name, UNISTR2 *processor, uint32 /**************************************************************************** enumprintmonitors level 1. ****************************************************************************/ + static uint32 enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTMONITOR_1 *info_1=NULL; @@ -6296,10 +6396,20 @@ static uint32 enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_enumprintmonitors(UNISTR2 *name,uint32 level, - NEW_BUFFER *buffer, uint32 offered, - uint32 *needed, uint32 *returned) + +uint32 _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_u, SPOOL_R_ENUMPRINTMONITORS *r_u) { +/* UNISTR2 *name = &q_u->name; - notused. */ + uint32 level = q_u->level; + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + uint32 *returned = &r_u->returned; + + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(5,("spoolss_enumprintmonitors\n")); /* @@ -6431,15 +6541,25 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getjob( POLICY_HND *handle, uint32 jobid, uint32 level, - NEW_BUFFER *buffer, uint32 offered, - uint32 *needed) + +uint32 _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_u) { + POLICY_HND *handle = &q_u->handle; + uint32 jobid = q_u->jobid; + uint32 level = q_u->level; + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + int snum; int count; print_queue_struct *queue=NULL; print_status_struct prt_status; + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(5,("spoolss_getjob\n")); memset(&prt_status, 0, sizeof(prt_status)); -- cgit From 011422ab5a45570d92740f4e11d1104296e38c9b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Mar 2001 00:14:45 +0000 Subject: Ensure that SPOOL_NOTIFY_OPTION structs are safely copied out of the talloc area into the Printer_entry struct - these are used for changenotification. Jeremy. (This used to be commit 4c2a49168e53b5ed96d61c6bae908086c3852f64) --- source3/rpc_server/srv_spoolss_nt.c | 76 ++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8e7e3c28e5..d17082b880 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -132,6 +132,55 @@ static int nt_printq_status(int v) return 0; } +/**************************************************************************** + Functions to handle SPOOL_NOTIFY_OPTION struct stored in Printer_entry. +****************************************************************************/ + +static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp) +{ + SPOOL_NOTIFY_OPTION *sp = *pp; + + *pp = NULL; + + if (!sp) + return; + + if (sp->ctr.type) + safe_free(sp->ctr.type); + + free(sp); + +} + +/**************************************************************************** + Functions to duplicate a SPOOL_NOTIFY_OPTION struct stored in Printer_entry. +****************************************************************************/ + +SPOOL_NOTIFY_OPTION *dup_spool_notify_option(SPOOL_NOTIFY_OPTION *sp) +{ + SPOOL_NOTIFY_OPTION *new_sp = malloc(sizeof(SPOOL_NOTIFY_OPTION)); + + if (!sp) + return NULL; + + new_sp = (SPOOL_NOTIFY_OPTION *)malloc(sizeof(SPOOL_NOTIFY_OPTION)); + if (!new_sp) + return NULL; + + *new_sp = *sp; + + if (sp->ctr.count) { + new_sp->ctr.type = (SPOOL_NOTIFY_OPTION_TYPE *)memdup(sp->ctr.type, sizeof(SPOOL_NOTIFY_OPTION_TYPE) * sp->ctr.count); + + if (!new_sp->ctr.type) { + safe_free(new_sp); + return NULL; + } + } + + return new_sp; +} + /**************************************************************************** initialise printer handle states... ****************************************************************************/ @@ -241,6 +290,7 @@ static BOOL srv_spoolss_replycloseprinter(POLICY_HND *handle) /**************************************************************************** close printer index by handle ****************************************************************************/ + static BOOL close_printer_handle(POLICY_HND *hnd) { Printer_entry *Printer = find_printer_index_by_hnd(hnd); @@ -259,8 +309,7 @@ static BOOL close_printer_handle(POLICY_HND *hnd) Printer->notify.options=0; Printer->notify.localmachine[0]='\0'; Printer->notify.printerlocal=0; - safe_free(Printer->notify.option); - Printer->notify.option=NULL; + free_spool_notify_option(&Printer->notify.option); Printer->notify.client_connected=False; clear_handle(hnd); @@ -1316,9 +1365,14 @@ uint32 _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE } Printer->notify.flags=flags; - Printer->notify.options=options; Printer->notify.printerlocal=printerlocal; - Printer->notify.option=option; + + if (Printer->notify.option) + free_spool_notify_option(&Printer->notify.option); + + Printer->notify.options=options; + Printer->notify.option=dup_spool_notify_option(option); + unistr2_to_ascii(Printer->notify.localmachine, localmachine, sizeof(Printer->notify.localmachine)-1); /* connect to the client machine and send a ReplyOpenPrinter */ @@ -2272,8 +2326,7 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, for (snum=0; snumtype ) { case PRINTER_NOTIFY_TYPE: - if(construct_notify_printer_info(info, snum, - option_type, id, - mem_ctx)) + if(construct_notify_printer_info(info, snum, option_type, id, mem_ctx)) id--; break; @@ -2340,8 +2391,7 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, memset(&status, 0, sizeof(status)); count = print_queue_status(snum, &queue, &status); - if (get_a_printer(&printer, 2, - lp_servicename(snum)) != 0) + if (get_a_printer(&printer, 2, lp_servicename(snum)) != 0) goto done; for (j=0; jnotify.localmachine[0]='\0'; Printer->notify.printerlocal=0; if (Printer->notify.option) - safe_free(Printer->notify.option->ctr.type); - safe_free(Printer->notify.option); - Printer->notify.option=NULL; + free_spool_notify_option(&Printer->notify.option); Printer->notify.client_connected=False; return NT_STATUS_NO_PROBLEMO; -- cgit From c014d3b709c0c71f6a092069f88854ee3f5387d3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Mar 2001 00:40:25 +0000 Subject: Remove unused code. Jeremy. (This used to be commit 3495d5cc3ba0f380fc78389b9ba17235ccd97ae4) --- source3/rpc_server/srv_spoolss_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d17082b880..5e666a9a7a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2870,7 +2870,7 @@ static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 of return ERROR_NOT_ENOUGH_MEMORY; } DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned)); - memcpy(&(printers[*returned]), ¤t_prt, sizeof(PRINTER_INFO_1)); + memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_1)); (*returned)++; } } @@ -2878,14 +2878,14 @@ static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 of /* check the required size. */ for (i=0; i<*returned; i++) - (*needed) += spoolss_size_printer_info_1(&(printers[i])); + (*needed) += spoolss_size_printer_info_1(&printers[i]); if (!alloc_buffer_size(buffer, *needed)) return ERROR_INSUFFICIENT_BUFFER; /* fill the buffer with the structures */ for (i=0; i<*returned; i++) - new_smb_io_printer_info_1("", buffer, &(printers[i]), 0); + new_smb_io_printer_info_1("", buffer, &printers[i], 0); /* clear memory */ safe_free(printers); -- cgit From 7d853615338e4c81a2204f57a7fc22da725f55fe Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Mar 2001 03:04:13 +0000 Subject: rpc_parse/parse_spoolss.c: Fixed memory leak introduced by restructuring. rpc_server/srv_spoolss_nt.c: Fixed problem with printer snum being read uninitialised. Jeremy. (This used to be commit 1552db715da576b41060f0d31d2c4cdec790c1d4) --- source3/rpc_server/srv_spoolss_nt.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5e666a9a7a..95bb64fef3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -158,7 +158,7 @@ static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp) SPOOL_NOTIFY_OPTION *dup_spool_notify_option(SPOOL_NOTIFY_OPTION *sp) { - SPOOL_NOTIFY_OPTION *new_sp = malloc(sizeof(SPOOL_NOTIFY_OPTION)); + SPOOL_NOTIFY_OPTION *new_sp = NULL; if (!sp) return NULL; @@ -825,6 +825,9 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, } else if ((printer_default->access_required & SERVER_ACCESS_ADMINISTER ) == SERVER_ACCESS_ADMINISTER) { + if (!get_printer_snum(handle, &snum)) + return ERROR_INVALID_HANDLE; + if (!lp_ms_add_printer_wizard()) { close_printer_handle(handle); return ERROR_ACCESS_DENIED; @@ -843,13 +846,13 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* NT doesn't let us connect to a printer if the connecting user doesn't have print permission. */ - if (!get_printer_snum(handle, &snum)) - return ERROR_INVALID_HANDLE; - /* map an empty access mask to the minimum access mask */ if (printer_default->access_required == 0x0) printer_default->access_required = PRINTER_ACCESS_USE; + if (!get_printer_snum(handle, &snum)) + return ERROR_INVALID_HANDLE; + if (!print_access_check(&user, snum, printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); close_printer_handle(handle); -- cgit From 5fa70d774780c2b3781b8dd89784cb768fbadcb0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Mar 2001 03:36:02 +0000 Subject: When opening a printserver use a global snum of -1. Jeremy (This used to be commit 3f44cb6103fe8df9182fbbca7dc7888171b4352a) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 95bb64fef3..c5a15ed37e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -825,8 +825,8 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, } else if ((printer_default->access_required & SERVER_ACCESS_ADMINISTER ) == SERVER_ACCESS_ADMINISTER) { - if (!get_printer_snum(handle, &snum)) - return ERROR_INVALID_HANDLE; + /* Printserver handles use global struct... */ + snum = -1; if (!lp_ms_add_printer_wizard()) { close_printer_handle(handle); -- cgit From fe4d6cd3bb52f4a28b91f90c3e64e782e2f2f08e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Mar 2001 04:00:45 +0000 Subject: Fix memory leaks introduced in restructure. Jeremy. (This used to be commit a355e11201e4dcb495b65b86e79de40d94c52a5b) --- source3/rpc_server/srv_spoolss_nt.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c5a15ed37e..341117f346 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1113,7 +1113,8 @@ uint32 _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL /******************************************************************** GetPrinterData on a printer server Handle. ********************************************************************/ -static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size) + +static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size) { int i; @@ -1121,7 +1122,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d if (!strcmp(value, "BeepEnabled")) { *type = 0x4; - if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL) + if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return False; SIVAL(*data, 0, 0x01); *needed = 0x4; @@ -1130,7 +1131,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d if (!strcmp(value, "EventLog")) { *type = 0x4; - if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL) + if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return False; SIVAL(*data, 0, 0x1B); *needed = 0x4; @@ -1139,7 +1140,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d if (!strcmp(value, "NetPopup")) { *type = 0x4; - if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL) + if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return False; SIVAL(*data, 0, 0x01); *needed = 0x4; @@ -1148,7 +1149,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d if (!strcmp(value, "MajorVersion")) { *type = 0x4; - if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL) + if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return False; SIVAL(*data, 0, 0x02); *needed = 0x4; @@ -1159,9 +1160,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d pstring string="You are using a Samba server"; *type = 0x1; *needed = 2*(strlen(string)+1); - if((*data = (uint8 *)malloc( ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) + if((*data = (uint8 *)talloc_zero( ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) return False; - memset(*data, 0, (*needed > in_size) ? *needed:in_size); /* it's done by hand ready to go on the wire */ for (i=0; i in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) + if((*data = (uint8 *)talloc_zero( ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) return False; - memset(*data, 0, (*needed > in_size) ? *needed:in_size); for (i=0; iin_size)?in_size:len *sizeof(uint8)); } else { @@ -1278,7 +1276,7 @@ uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO DEBUG(4,("_spoolss_getprinterdata\n")); if (!OPEN_HANDLE(Printer)) { - if((*data=(uint8 *)malloc(4*sizeof(uint8))) == NULL) + if((*data=(uint8 *)talloc_zero(p->mem_ctx, 4*sizeof(uint8))) == NULL) return ERROR_NOT_ENOUGH_MEMORY; DEBUG(0,("_spoolss_getprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; @@ -1287,9 +1285,9 @@ uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO unistr2_to_ascii(value, valuename, sizeof(value)-1); if (handle_is_printserver(handle)) - found=getprinterdata_printer_server(value, type, data, needed, *out_size); + found=getprinterdata_printer_server(p->mem_ctx, value, type, data, needed, *out_size); else - found= getprinterdata_printer(handle, value, type, data, needed, *out_size); + found= getprinterdata_printer(p->mem_ctx, handle, value, type, data, needed, *out_size); if (found==False) { DEBUG(5, ("value not found, allocating %d\n", *out_size)); -- cgit From 865e8a3910ebab04ec83c33280bbbbdb00e33518 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Mar 2001 04:01:23 +0000 Subject: Don't return stack structures... Jeremy. (This used to be commit 94b72c19fe435d31e14e69a3fc9808e75638726a) --- source3/rpc_server/srv_lsa_nt.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 14d37e9948..98910b5812 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -421,16 +421,19 @@ uint32 _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_SI { DOM_SID2 *sid = q_u->sids.sid; int num_entries = q_u->sids.num_entries; - DOM_R_REF ref; - LSA_TRANS_NAME_ENUM names; + DOM_R_REF *ref = NULL; + LSA_TRANS_NAME_ENUM *names = NULL; uint32 mapped_count = 0; - ZERO_STRUCT(ref); - ZERO_STRUCT(names); + ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); + names = (LSA_TRANS_NAME_ENUM *)talloc_zero(p->mem_ctx, sizeof(LSA_TRANS_NAME_ENUM)); + + if (!ref || !names) + return NT_STATUS_NO_MEMORY; /* set up the LSA Lookup SIDs response */ - init_lsa_trans_names(p->mem_ctx, &ref, &names, num_entries, sid, &mapped_count); - init_reply_lookup_sids(r_u, &ref, &names, mapped_count); + init_lsa_trans_names(p->mem_ctx, ref, names, num_entries, sid, &mapped_count); + init_reply_lookup_sids(r_u, ref, names, mapped_count); return r_u->status; } @@ -443,16 +446,19 @@ uint32 _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_N { UNISTR2 *names = q_u->uni_name; int num_entries = q_u->num_entries; - DOM_R_REF ref; - DOM_RID2 rids[MAX_LOOKUP_SIDS]; + DOM_R_REF *ref; + DOM_RID2 *rids; uint32 mapped_count = 0; - ZERO_STRUCT(ref); - ZERO_ARRAY(rids); + ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); + rids = (DOM_RID2 *)talloc_zero(p->mem_ctx, sizeof(DOM_RID2)*MAX_LOOKUP_SIDS); + + if (!ref || !rids) + return NT_STATUS_NO_MEMORY; /* set up the LSA Lookup RIDs response */ - init_lsa_rid2s(&ref, rids, num_entries, names, &mapped_count); - init_reply_lookup_names(r_u, &ref, num_entries, rids, mapped_count); + init_lsa_rid2s(ref, rids, num_entries, names, &mapped_count); + init_reply_lookup_names(r_u, ref, num_entries, rids, mapped_count); return r_u->status; } -- cgit From 74294f5a967cbcdaa4d502bda3b6147d912f8411 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 2 Mar 2001 00:20:43 +0000 Subject: Move to talloc controlled NT forms. Jeremy. (This used to be commit 3e190e693375c6032dd64bf8dd3c90f90dc4e3b4) --- source3/rpc_server/srv_spoolss_nt.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 341117f346..01055f4e71 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5278,14 +5278,14 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E DEBUGADD(5,("Offered buffer size [%d]\n", offered)); DEBUGADD(5,("Info level [%d]\n", level)); - *numofforms = get_ntforms(&list); + *numofforms = get_ntforms(p->mem_ctx, &list); DEBUGADD(5,("Number of forms [%d]\n", *numofforms)); if (*numofforms == 0) return ERROR_NO_MORE_ITEMS; switch (level) { case 1: - if ((forms_1=(FORM_1 *)malloc(*numofforms * sizeof(FORM_1))) == NULL) { + if ((forms_1=(FORM_1 *)talloc(p->mem_ctx, *numofforms * sizeof(FORM_1))) == NULL) { *numofforms=0; return ERROR_NOT_ENOUGH_MEMORY; } @@ -5296,8 +5296,6 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E fill_form_1(&forms_1[i], &list[i]); } - safe_free(list); - /* check the required size. */ for (i=0; i<*numofforms; i++) { DEBUGADD(6,("adding form [%d]'s size\n",i)); @@ -5306,10 +5304,8 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E *needed=buffer_size; - if (!alloc_buffer_size(buffer, buffer_size)){ - safe_free(forms_1); + if (!alloc_buffer_size(buffer, buffer_size)) return ERROR_INSUFFICIENT_BUFFER; - } /* fill the buffer with the form structures */ for (i=0; i<*numofforms; i++) { @@ -5317,8 +5313,6 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E new_smb_io_form_1("", buffer, &forms_1[i], 0); } - safe_free(forms_1); - if (*needed > offered) { *numofforms=0; return ERROR_INSUFFICIENT_BUFFER; @@ -5327,10 +5321,8 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E return NT_STATUS_NO_PROBLEMO; default: - safe_free(list); return ERROR_INVALID_LEVEL; } - } /**************************************************************************** @@ -5361,7 +5353,7 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * DEBUGADD(5,("Offered buffer size [%d]\n", offered)); DEBUGADD(5,("Info level [%d]\n", level)); - numofforms = get_ntforms(&list); + numofforms = get_ntforms(p->mem_ctx, &list); DEBUGADD(5,("Number of forms [%d]\n", numofforms)); if (numofforms == 0) @@ -5382,8 +5374,6 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * } } - safe_free(list); - /* check the required size. */ *needed=spoolss_size_form_1(&form_1); @@ -5403,7 +5393,6 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * return NT_STATUS_NO_PROBLEMO; default: - safe_free(list); return ERROR_INVALID_LEVEL; } } @@ -6181,14 +6170,12 @@ uint32 _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM return ERROR_INVALID_HANDLE; } - count=get_ntforms(&list); - if(!add_a_form(&list, form, &count)) + count=get_ntforms(p->mem_ctx, &list); + if(!add_a_form(p->mem_ctx, &list, form, &count)) return ERROR_NOT_ENOUGH_MEMORY; write_ntforms(&list, count); - safe_free(list); - - return 0x0; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -6211,12 +6198,10 @@ uint32 _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE return ERROR_INVALID_HANDLE; } - count = get_ntforms(&list); + count = get_ntforms(p->mem_ctx, &list); if(!delete_a_form(&list, form_name, &count, &ret)) return ERROR_INVALID_PARAMETER; - safe_free(list); - return ret; } @@ -6240,12 +6225,10 @@ uint32 _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * DEBUG(0,("_spoolss_setform: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } - count=get_ntforms(&list); + count=get_ntforms(p->mem_ctx, &list); update_a_form(&list, form, count); write_ntforms(&list, count); - safe_free(list); - return 0x0; } -- cgit From 28c43a3cd50e2504f814d864f6423b5df4dc8d45 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 2 Mar 2001 02:59:17 +0000 Subject: Arrgggh. Returning the SPOOL_INFO stuff requires that the realloced data be realloced between different functions. This took a *long* time to track down (even with insure :-). Jeremy. (This used to be commit e61899f490e0d4109a5fc2faa04eefb934e8448c) --- source3/rpc_server/srv_spoolss_nt.c | 59 ++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 23 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 01055f4e71..2b6fb9a7e5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2157,12 +2157,12 @@ static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, info_data->enc_type = type_of_notify_info_data(type, field); } - /******************************************************************* * * fill a notify_info struct with info asked * ********************************************************************/ + static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id, @@ -2175,8 +2175,6 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int SPOOL_NOTIFY_INFO_DATA *current_data; NT_PRINTER_INFO_LEVEL *printer = NULL; print_queue_struct *queue=NULL; - size_t realloc_size = 0; - SPOOL_NOTIFY_INFO_DATA *info_data_ptr = NULL; type=option_type->type; @@ -2194,11 +2192,10 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int if (!search_notify(type, field, &j) ) continue; - realloc_size = (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA); - if((info_data_ptr=(SPOOL_NOTIFY_INFO_DATA *)Realloc(info_data_ptr, realloc_size)) == NULL) { + if((info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) { return False; } - current_data=&info_data_ptr[info->count]; + current_data=&info->data[info->count]; construct_info_data(current_data, type, field, id); @@ -2211,12 +2208,6 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int info->count++; } - if (realloc_size) - info->data = talloc_memdup(mem_ctx, info_data_ptr, realloc_size); - else - info->data = NULL; - - safe_free(info_data_ptr); free_a_printer(&printer, 2); return True; } @@ -2226,6 +2217,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int * fill a notify_info struct with info asked * ********************************************************************/ + static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, NT_PRINTER_INFO_LEVEL *printer, @@ -2236,7 +2228,6 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, int field_num,j; uint16 type; uint16 field; - SPOOL_NOTIFY_INFO_DATA *current_data; DEBUG(4,("construct_notify_jobs_info\n")); @@ -2257,9 +2248,13 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, return False; } - current_data=&(info->data[info->count]); + current_data=&info->data[info->count]; construct_info_data(current_data, type, field, id); + + DEBUG(10,("construct_notify_jobs_info: calling [%s] snum=%d printername=[%s])\n", + notify_info_data_table[j].name, snum, printer->info_2->printername )); + notify_info_data_table[j].fn(snum, current_data, queue, printer, mem_ctx); info->count++; @@ -2335,7 +2330,7 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, * Debugging information, don't delete. */ /* - DEBUG(1,("dumping the NOTIFY_INFO\n")); + DEBUG(1,("printserver_notify_info: dumping the NOTIFY_INFO\n")); DEBUGADD(1,("info->version:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); DEBUGADD(1,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); @@ -2415,17 +2410,17 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, /* * Debugging information, don't delete. */ - /* - DEBUG(1,("dumping the NOTIFY_INFO\n")); - DEBUGADD(1,("info->version:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); - DEBUGADD(1,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); + + DEBUG(10,("printer_notify_info: dumping the NOTIFY_INFO\n")); + DEBUGADD(10,("info->version:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); + DEBUGADD(10,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); for (i=0; icount; i++) { - DEBUGADD(1,("[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\n", + DEBUGADD(10,("[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\n", i, info->data[i].type, info->data[i].field, info->data[i].reserved, info->data[i].id, info->data[i].size, info->data[i].enc_type)); } - */ + return NT_STATUS_NO_PROBLEMO; } @@ -2477,7 +2472,25 @@ uint32 _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN result = printer_notify_info(handle, info, p->mem_ctx); break; } - + + /* + * The data returned in info->data is realloced. We need to + * convert to talloc for return. The data really should come + * back as a linked list, not a realloced array, as realloc can + * fail... JRA. + */ + + if (info->data) { + SPOOL_NOTIFY_INFO_DATA *new_data = (SPOOL_NOTIFY_INFO_DATA *)talloc_memdup(p->mem_ctx, + info->data, + info->count * sizeof(SPOOL_NOTIFY_INFO_DATA)); + if (!new_data) + return NT_STATUS_NO_MEMORY; + + safe_free(info->data); + info->data = new_data; + } + done: return result; } @@ -5024,7 +5037,7 @@ static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture return ERROR_INSUFFICIENT_BUFFER; } - /* fill the buffer with the form structures */ + /* fill the buffer with the driver structures */ for (i=0; i<*returned; i++) { DEBUGADD(6,("adding driver [%d] to buffer\n",i)); new_smb_io_printer_driver_info_1("", buffer, &driver_info_1[i], 0); -- cgit From 93169a1f34f180f8a469a25532792f23e55e6966 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Mar 2001 05:27:26 +0000 Subject: Roll back to using malloc/realloc on some of spoolss in head. I'm having problems with talloc_realloc in the 2.2 branch and I want a stable reference. The only problem is this breaks the clean auto-generated code in *one* call in srv_spoolss.c (the rfnpcnex call). Jeremy. (This used to be commit 57a9340cbafa40f3a41e6c676c6f2477855fd799) --- source3/rpc_server/srv_pipe_hnd.c | 4 +- source3/rpc_server/srv_spoolss.c | 3 + source3/rpc_server/srv_spoolss_nt.c | 114 ++++++++++++++++++------------------ 3 files changed, 62 insertions(+), 59 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 3b60c78ade..eb369f22b4 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -397,10 +397,10 @@ authentication failed. Denying the request.\n", p->name)); } /* - * Check the data length doesn't go over the 1Mb limit. + * Check the data length doesn't go over the 10Mb limit. */ - if(prs_data_size(&p->in_data.data) + data_len > 1024*1024) { + if(prs_data_size(&p->in_data.data) + data_len > 10*1024*1024) { DEBUG(0,("process_request_pdu: rpc data buffer too large (%u) + (%u)\n", (unsigned int)prs_data_size(&p->in_data.data), (unsigned int)data_len )); set_incoming_fault(p); diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index a2bde97865..0cb72232f2 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -270,10 +270,13 @@ static BOOL api_spoolss_rfnpcnex(pipes_struct *p) r_u.status = _spoolss_rfnpcnex(p, &q_u, &r_u); if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) { + safe_free(r_u.info.data); DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n")); return False; } + safe_free(r_u.info.data); + return True; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2b6fb9a7e5..830f5cdcf4 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -149,7 +149,6 @@ static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp) safe_free(sp->ctr.type); free(sp); - } /**************************************************************************** @@ -290,7 +289,6 @@ static BOOL srv_spoolss_replycloseprinter(POLICY_HND *handle) /**************************************************************************** close printer index by handle ****************************************************************************/ - static BOOL close_printer_handle(POLICY_HND *hnd) { Printer_entry *Printer = find_printer_index_by_hnd(hnd); @@ -310,6 +308,7 @@ static BOOL close_printer_handle(POLICY_HND *hnd) Printer->notify.localmachine[0]='\0'; Printer->notify.printerlocal=0; free_spool_notify_option(&Printer->notify.option); + Printer->notify.option=NULL; Printer->notify.client_connected=False; clear_handle(hnd); @@ -846,13 +845,13 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* NT doesn't let us connect to a printer if the connecting user doesn't have print permission. */ + if (!get_printer_snum(handle, &snum)) + return ERROR_INVALID_HANDLE; + /* map an empty access mask to the minimum access mask */ if (printer_default->access_required == 0x0) printer_default->access_required = PRINTER_ACCESS_USE; - if (!get_printer_snum(handle, &snum)) - return ERROR_INVALID_HANDLE; - if (!print_access_check(&user, snum, printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); close_printer_handle(handle); @@ -1113,7 +1112,6 @@ uint32 _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL /******************************************************************** GetPrinterData on a printer server Handle. ********************************************************************/ - static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size) { int i; @@ -1160,8 +1158,9 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 pstring string="You are using a Samba server"; *type = 0x1; *needed = 2*(strlen(string)+1); - if((*data = (uint8 *)talloc_zero( ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) + if((*data = (uint8 *)talloc(ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) return False; + memset(*data, 0, (*needed > in_size) ? *needed:in_size); /* it's done by hand ready to go on the wire */ for (i=0; i in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) + if((*data = (uint8 *)talloc(ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) return False; + memset(*data, 0, (*needed > in_size) ? *needed:in_size); for (i=0; iin_size)?in_size:len *sizeof(uint8)); } else { @@ -1276,7 +1277,7 @@ uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO DEBUG(4,("_spoolss_getprinterdata\n")); if (!OPEN_HANDLE(Printer)) { - if((*data=(uint8 *)talloc_zero(p->mem_ctx, 4*sizeof(uint8))) == NULL) + if((*data=(uint8 *)malloc(4*sizeof(uint8))) == NULL) return ERROR_NOT_ENOUGH_MEMORY; DEBUG(0,("_spoolss_getprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; @@ -1366,12 +1367,12 @@ uint32 _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE } Printer->notify.flags=flags; + Printer->notify.options=options; Printer->notify.printerlocal=printerlocal; if (Printer->notify.option) free_spool_notify_option(&Printer->notify.option); - Printer->notify.options=options; Printer->notify.option=dup_spool_notify_option(option); unistr2_to_ascii(Printer->notify.localmachine, localmachine, sizeof(Printer->notify.localmachine)-1); @@ -2157,12 +2158,12 @@ static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, info_data->enc_type = type_of_notify_info_data(type, field); } + /******************************************************************* * * fill a notify_info struct with info asked * ********************************************************************/ - static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id, @@ -2192,7 +2193,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int if (!search_notify(type, field, &j) ) continue; - if((info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) { + if((info->data=(SPOOL_NOTIFY_INFO_DATA *)Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) { return False; } current_data=&info->data[info->count]; @@ -2217,7 +2218,6 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int * fill a notify_info struct with info asked * ********************************************************************/ - static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, NT_PRINTER_INFO_LEVEL *printer, @@ -2228,6 +2228,7 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, int field_num,j; uint16 type; uint16 field; + SPOOL_NOTIFY_INFO_DATA *current_data; DEBUG(4,("construct_notify_jobs_info\n")); @@ -2248,13 +2249,9 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, return False; } - current_data=&info->data[info->count]; + current_data=&(info->data[info->count]); construct_info_data(current_data, type, field, id); - - DEBUG(10,("construct_notify_jobs_info: calling [%s] snum=%d printername=[%s])\n", - notify_info_data_table[j].name, snum, printer->info_2->printername )); - notify_info_data_table[j].fn(snum, current_data, queue, printer, mem_ctx); info->count++; @@ -2322,7 +2319,8 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, for (snum=0; snumversion:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); DEBUGADD(1,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); @@ -2377,7 +2375,9 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, switch ( option_type->type ) { case PRINTER_NOTIFY_TYPE: - if(construct_notify_printer_info(info, snum, option_type, id, mem_ctx)) + if(construct_notify_printer_info(info, snum, + option_type, id, + mem_ctx)) id--; break; @@ -2387,7 +2387,8 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, memset(&status, 0, sizeof(status)); count = print_queue_status(snum, &queue, &status); - if (get_a_printer(&printer, 2, lp_servicename(snum)) != 0) + if (get_a_printer(&printer, 2, + lp_servicename(snum)) != 0) goto done; for (j=0; jversion:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); - DEBUGADD(10,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); + /* + DEBUG(1,("dumping the NOTIFY_INFO\n")); + DEBUGADD(1,("info->version:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); + DEBUGADD(1,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); for (i=0; icount; i++) { - DEBUGADD(10,("[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\n", + DEBUGADD(1,("[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\n", i, info->data[i].type, info->data[i].field, info->data[i].reserved, info->data[i].id, info->data[i].size, info->data[i].enc_type)); } - + */ return NT_STATUS_NO_PROBLEMO; } @@ -2472,25 +2473,7 @@ uint32 _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN result = printer_notify_info(handle, info, p->mem_ctx); break; } - - /* - * The data returned in info->data is realloced. We need to - * convert to talloc for return. The data really should come - * back as a linked list, not a realloced array, as realloc can - * fail... JRA. - */ - - if (info->data) { - SPOOL_NOTIFY_INFO_DATA *new_data = (SPOOL_NOTIFY_INFO_DATA *)talloc_memdup(p->mem_ctx, - info->data, - info->count * sizeof(SPOOL_NOTIFY_INFO_DATA)); - if (!new_data) - return NT_STATUS_NO_MEMORY; - - safe_free(info->data); - info->data = new_data; - } - + done: return result; } @@ -5291,14 +5274,14 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E DEBUGADD(5,("Offered buffer size [%d]\n", offered)); DEBUGADD(5,("Info level [%d]\n", level)); - *numofforms = get_ntforms(p->mem_ctx, &list); + *numofforms = get_ntforms(&list); DEBUGADD(5,("Number of forms [%d]\n", *numofforms)); if (*numofforms == 0) return ERROR_NO_MORE_ITEMS; switch (level) { case 1: - if ((forms_1=(FORM_1 *)talloc(p->mem_ctx, *numofforms * sizeof(FORM_1))) == NULL) { + if ((forms_1=(FORM_1 *)malloc(*numofforms * sizeof(FORM_1))) == NULL) { *numofforms=0; return ERROR_NOT_ENOUGH_MEMORY; } @@ -5309,6 +5292,8 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E fill_form_1(&forms_1[i], &list[i]); } + safe_free(list); + /* check the required size. */ for (i=0; i<*numofforms; i++) { DEBUGADD(6,("adding form [%d]'s size\n",i)); @@ -5317,8 +5302,10 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E *needed=buffer_size; - if (!alloc_buffer_size(buffer, buffer_size)) + if (!alloc_buffer_size(buffer, buffer_size)){ + safe_free(forms_1); return ERROR_INSUFFICIENT_BUFFER; + } /* fill the buffer with the form structures */ for (i=0; i<*numofforms; i++) { @@ -5326,6 +5313,8 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E new_smb_io_form_1("", buffer, &forms_1[i], 0); } + safe_free(forms_1); + if (*needed > offered) { *numofforms=0; return ERROR_INSUFFICIENT_BUFFER; @@ -5334,8 +5323,10 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E return NT_STATUS_NO_PROBLEMO; default: + safe_free(list); return ERROR_INVALID_LEVEL; } + } /**************************************************************************** @@ -5366,7 +5357,7 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * DEBUGADD(5,("Offered buffer size [%d]\n", offered)); DEBUGADD(5,("Info level [%d]\n", level)); - numofforms = get_ntforms(p->mem_ctx, &list); + numofforms = get_ntforms(&list); DEBUGADD(5,("Number of forms [%d]\n", numofforms)); if (numofforms == 0) @@ -5387,6 +5378,8 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * } } + safe_free(list); + /* check the required size. */ *needed=spoolss_size_form_1(&form_1); @@ -5406,6 +5399,7 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * return NT_STATUS_NO_PROBLEMO; default: + safe_free(list); return ERROR_INVALID_LEVEL; } } @@ -6183,12 +6177,14 @@ uint32 _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM return ERROR_INVALID_HANDLE; } - count=get_ntforms(p->mem_ctx, &list); - if(!add_a_form(p->mem_ctx, &list, form, &count)) + count=get_ntforms(&list); + if(!add_a_form(&list, form, &count)) return ERROR_NOT_ENOUGH_MEMORY; write_ntforms(&list, count); - return NT_STATUS_NOPROBLEMO; + safe_free(list); + + return 0x0; } /**************************************************************************** @@ -6211,10 +6207,12 @@ uint32 _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE return ERROR_INVALID_HANDLE; } - count = get_ntforms(p->mem_ctx, &list); + count = get_ntforms(&list); if(!delete_a_form(&list, form_name, &count, &ret)) return ERROR_INVALID_PARAMETER; + safe_free(list); + return ret; } @@ -6238,10 +6236,12 @@ uint32 _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * DEBUG(0,("_spoolss_setform: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } - count=get_ntforms(p->mem_ctx, &list); + count=get_ntforms(&list); update_a_form(&list, form, count); write_ntforms(&list, count); + safe_free(list); + return 0x0; } -- cgit From e2e56e84f07c9427990a2269c5970c1acb4c3967 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Mar 2001 06:47:37 +0000 Subject: Fixed up overrun read when marshelling SYSTEMTIME struct. This was a subtle one... Jeremy. (This used to be commit 65275e73ee7c58352ee20175cbbb43378e16f417) --- source3/rpc_server/srv_spoolss_nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 830f5cdcf4..5c40052295 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1996,12 +1996,13 @@ static void spoolss_notify_submitted_time(int snum, { struct tm *t; uint32 len; + SYSTEMTIME st; t=gmtime(&queue->time); len = sizeof(SYSTEMTIME); - data->notify_data.data.length = len; + data->notify_data.data.length = len/2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -2009,7 +2010,8 @@ static void spoolss_notify_submitted_time(int snum, return; } - make_systemtime((SYSTEMTIME*)(data->notify_data.data.string), t); + make_systemtime(&st, t); + memcpy(data->notify_data.data.string,&st,len); } #define END 65535 -- cgit From 393bede7db6af546431cd5255e465b7b7b0e7c81 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 7 Mar 2001 23:59:13 +0000 Subject: Sync up handle creation with 2.2 branch. We can now join AS/U domains and authenticate against them. Big/little endian issues fixed. Jeremy. (This used to be commit 0e6a34510ed598eaec7fe71a9c91fda528a4675c) --- source3/rpc_server/srv_lsa_hnd.c | 42 +++++++++++++++++++------------------ source3/rpc_server/srv_lsa_nt.c | 15 +++++-------- source3/rpc_server/srv_reg_nt.c | 2 +- source3/rpc_server/srv_samr.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 14 +++---------- 5 files changed, 32 insertions(+), 43 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 93492f671d..10b9bef1be 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -58,26 +58,28 @@ static struct policy static struct bitmap *bmap; +static uint32 pol_hnd_low = 0; +static uint32 pol_hnd_high = 0; -/**************************************************************************** - create a unique policy handle -****************************************************************************/ -static void create_pol_hnd(POLICY_HND *hnd) -{ - static uint32 pol_hnd_low = 0; - static uint32 pol_hnd_high = 0; +/******************************************************************* + Creates a POLICY_HND structure. +********************************************************************/ +void create_policy_handle(POLICY_HND *hnd, uint32 *hnd_low, uint32 *hnd_high) +{ if (hnd == NULL) return; - /* i severely doubt that pol_hnd_high will ever be non-zero... */ - pol_hnd_low++; - if (pol_hnd_low == 0) pol_hnd_high++; + (*hnd_low)++; + if (*hnd_low == 0) (*hnd_high)++; + + ZERO_STRUCTP(hnd); - SIVAL(hnd->data, 0 , 0x0); /* first bit must be null */ - SIVAL(hnd->data, 4 , pol_hnd_low ); /* second bit is incrementing */ - SIVAL(hnd->data, 8 , pol_hnd_high); /* second bit is incrementing */ - SIVAL(hnd->data, 12, time(NULL)); /* something random */ - SIVAL(hnd->data, 16, sys_getpid()); /* something more random */ + SIVAL(&hnd->data1, 0 , 0); /* first bit must be null */ + SIVAL(&hnd->data2, 0 , *hnd_low ); /* second bit is incrementing */ + SSVAL(&hnd->data3, 0 , *hnd_high); /* second bit is incrementing */ + SSVAL(&hnd->data4, 0 , (*hnd_high>>16)); /* second bit is incrementing */ + SIVAL(hnd->data5, 0, time(NULL)); /* something random */ + SIVAL(hnd->data5, 4, sys_getpid()); /* something more random */ } /**************************************************************************** @@ -117,15 +119,15 @@ BOOL open_lsa_policy_hnd(POLICY_HND *hnd) p->open = True; p->pnum = i; - create_pol_hnd(hnd); - memcpy(&p->pol_hnd, hnd, sizeof(*hnd)); + create_policy_handle(hnd, &pol_hnd_low, &pol_hnd_high); + p->pol_hnd = *hnd; bitmap_set(bmap, i); DLIST_ADD(Policy, p); DEBUG(4,("Opened policy hnd[%x] ", i)); - dump_data(4, (char *)hnd->data, sizeof(hnd->data)); + dump_data(4, (char *)hnd, sizeof(hnd)); return True; } @@ -140,13 +142,13 @@ static struct policy *find_lsa_policy(POLICY_HND *hnd) for (p=Policy;p;p=p->next) { if (memcmp(&p->pol_hnd, hnd, sizeof(*hnd)) == 0) { DEBUG(4,("Found policy hnd[%x] ", p->pnum)); - dump_data(4, (char *)hnd->data, sizeof(hnd->data)); + dump_data(4, (char *)hnd, sizeof(hnd)); return p; } } DEBUG(4,("Policy not found: ")); - dump_data(4, (char *)hnd->data, sizeof(hnd->data)); + dump_data(4, (char *)hnd, sizeof(hnd)); return NULL; } diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 98910b5812..ee2f38b715 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -275,20 +275,19 @@ static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, r_l->status = NT_STATUS_NO_PROBLEMO; } +static uint32 lsa_hnd_low = 0; +static uint32 lsa_hnd_high = 0; + /*************************************************************************** _lsa_open_policy2. ***************************************************************************/ uint32 _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2 *r_u) { - int i; - /* lkclXXXX having decoded it, ignore all fields in the open policy! */ /* set up the LSA QUERY INFO response */ - - for (i = 4; i < POL_HND_SIZE; i++) - r_u->pol.data[i] = i; + create_policy_handle(&r_u->pol, &lsa_hnd_low, &lsa_hnd_high); return NT_STATUS_NOPROBLEMO; } @@ -299,14 +298,10 @@ uint32 _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2 uint32 _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL *r_u) { - int i; - /* lkclXXXX having decoded it, ignore all fields in the open policy! */ /* set up the LSA QUERY INFO response */ - - for (i = 4; i < POL_HND_SIZE; i++) - r_u->pol.data[i] = i; + create_policy_handle(&r_u->pol, &lsa_hnd_low, &lsa_hnd_high); return NT_STATUS_NOPROBLEMO; } diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 4d35542fc2..4bd97abb65 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -37,7 +37,7 @@ extern int DEBUGLEVEL; uint32 _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) { /* set up the REG unknown_1 response */ - memset((char *)r_u->pol.data, '\0', POL_HND_SIZE); + ZERO_STRUCT(r_u->pol); /* close the policy handle */ if (!close_lsa_policy_hnd(&q_u->pol)) diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index eb24f672a9..2f4143bd6a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -357,7 +357,7 @@ static BOOL samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, SAMR_R_CLOSE_HND r_u; /* set up the SAMR unknown_1 response */ - memset((char *)r_u.pol.data, '\0', POL_HND_SIZE); + ZERO_STRUCT(r_u.pol); /* close the policy handle */ if (close_lsa_policy_hnd(&(q_u->pol))) diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5c40052295..0fb38b84db 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -84,8 +84,8 @@ static ubi_dlList counter_list; static struct cli_state cli; static uint32 smb_connections=0; -#define OPEN_HANDLE(pnum) ((pnum!=NULL) && (pnum->open!=False) && (IVAL(pnum->printer_hnd.data,16)==(uint32)sys_getpid())) -#define OUR_HANDLE(pnum) ((pnum==NULL)?"NULL":(IVAL(pnum->data,16)==sys_getpid()?"OURS":"OTHER")) +#define OPEN_HANDLE(pnum) ((pnum!=NULL) && (pnum->open!=False) && (IVAL(pnum->printer_hnd.data5,4)==(uint32)sys_getpid())) +#define OUR_HANDLE(pnum) ((pnum==NULL)?"NULL":(IVAL(pnum->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")) /* translate between internal status numbers and NT status numbers */ static int nt_printj_status(int v) @@ -215,15 +215,7 @@ static void create_printer_hnd(POLICY_HND *hnd) if (hnd == NULL) return; - /* i severely doubt that prt_hnd_high will ever be non-zero... */ - prt_hnd_low++; - if (prt_hnd_low == 0) prt_hnd_high++; - - SIVAL(hnd->data, 0 , 0x0); /* first bit must be null */ - SIVAL(hnd->data, 4 , prt_hnd_low ); /* second bit is incrementing */ - SIVAL(hnd->data, 8 , prt_hnd_high); /* second bit is incrementing */ - SIVAL(hnd->data, 12, time(NULL)); /* something random */ - SIVAL(hnd->data, 16, sys_getpid()); /* something more random */ + create_policy_handle(hnd, &prt_hnd_low, &prt_hnd_high); } /**************************************************************************** -- cgit From 25db9b02ba36b25c3254bbb44323fcbfa2a2a5e7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 8 Mar 2001 05:01:20 +0000 Subject: Fix for AS/U not liking it's own assoc_gid. Jeremy. (This used to be commit 81fe571daf62ff3f53d7137dcd30312b6874b786) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 6d0a006593..c0174280ab 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -886,7 +886,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) if (p->ntlmssp_auth_requested) assoc_gid = 0x7a77; else - assoc_gid = hdr_rb.bba.assoc_gid; + assoc_gid = hdr_rb.bba.assoc_gid ? hdr_rb.bba.assoc_gid : 0x53f0; /* * Create the bind response struct. -- cgit From 00ab9021b0cc5fe2667d383eb9cc2973072cdaaa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 9 Mar 2001 23:48:58 +0000 Subject: Serious (and I *mean* serious) attempt to fix little/bigendian RPC issues. We were reading the endainness in the RPC header and then never propagating it to the internal parse_structs used to parse the data. Also removed the "align" argument to prs_init as it was *always* set to 4, and if needed can be set differently on a case by case basis. Now ready for AS/U testing when Herb gets it set up :-). Jeremy. (This used to be commit 0cd37c831d79a12a10e479bf4fa89ffe64c1292a) --- source3/rpc_server/srv_pipe.c | 12 ++++---- source3/rpc_server/srv_pipe_hnd.c | 62 +++++++++++++++++++++++++++++++-------- 2 files changed, 55 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index c0174280ab..dcefeed8b9 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -167,7 +167,7 @@ BOOL create_next_pdu(pipes_struct *p) * data. */ - prs_init( &outgoing_pdu, 0, 4, p->mem_ctx, MARSHALL); + prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* Store the header in the data stream. */ @@ -586,7 +586,7 @@ static BOOL setup_bind_nak(pipes_struct *p) * header and are never sending more than one PDU here. */ - prs_init( &outgoing_rpc, 0, 4, p->mem_ctx, MARSHALL); + prs_init( &outgoing_rpc, 0, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); @@ -645,7 +645,7 @@ BOOL setup_fault_pdu(pipes_struct *p) * header and are never sending more than one PDU here. */ - prs_init( &outgoing_pdu, 0, 4, p->mem_ctx, MARSHALL); + prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* @@ -862,7 +862,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) * header and are never sending more than one PDU here. */ - prs_init( &outgoing_rpc, 0, 4, p->mem_ctx, MARSHALL); + prs_init( &outgoing_rpc, 0, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* @@ -870,13 +870,13 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) * auth footers. */ - if(!prs_init(&out_hdr_ba, 1024, 4, p->mem_ctx, MARSHALL)) { + if(!prs_init(&out_hdr_ba, 1024, p->mem_ctx, MARSHALL)) { DEBUG(0,("api_pipe_bind_req: malloc out_hdr_ba failed.\n")); prs_mem_free(&outgoing_rpc); return False; } - if(!prs_init(&out_auth, 1024, 4, p->mem_ctx, MARSHALL)) { + if(!prs_init(&out_auth, 1024, p->mem_ctx, MARSHALL)) { DEBUG(0,("pi_pipe_bind_req: malloc out_auth failed.\n")); prs_mem_free(&outgoing_rpc); prs_mem_free(&out_hdr_ba); diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index eb369f22b4..5545071913 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -96,7 +96,7 @@ static BOOL pipe_init_outgoing_data(pipes_struct *p) * Initialize the outgoing RPC data buffer. * we will use this as the raw data area for replying to rpc requests. */ - if(!prs_init(&o_data->rdata, MAX_PDU_FRAG_LEN, 4, p->mem_ctx, MARSHALL)) { + if(!prs_init(&o_data->rdata, MAX_PDU_FRAG_LEN, p->mem_ctx, MARSHALL)) { DEBUG(0,("pipe_init_outgoing_data: malloc fail.\n")); return False; } @@ -159,7 +159,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, * change the type to UNMARSALLING before processing the stream. */ - if(!prs_init(&p->in_data.data, MAX_PDU_FRAG_LEN, 4, p->mem_ctx, MARSHALL)) { + if(!prs_init(&p->in_data.data, MAX_PDU_FRAG_LEN, p->mem_ctx, MARSHALL)) { DEBUG(0,("open_rpc_pipe_p: malloc fail for in_data struct.\n")); return NULL; } @@ -185,6 +185,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->pipe_bound = False; p->fault_state = False; + p->endian = RPC_LITTLE_ENDIAN; /* * Initialize the incoming RPC struct. @@ -204,7 +205,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, /* * Initialize the outgoing RPC data buffer with no memory. */ - prs_init(&p->out_data.rdata, 0, 4, p->mem_ctx, MARSHALL); + prs_init(&p->out_data.rdata, 0, p->mem_ctx, MARSHALL); ZERO_STRUCT(p->pipe_user); @@ -275,13 +276,16 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) return -1; } - prs_init( &rpc_in, 0, 4, p->mem_ctx, UNMARSHALL); + prs_init( &rpc_in, 0, p->mem_ctx, UNMARSHALL); + prs_set_endian_data( &rpc_in, p->endian); + prs_give_memory( &rpc_in, (char *)&p->in_data.current_in_pdu[0], p->in_data.pdu_received_len, False); /* * Unmarshall the header as this will tell us how much * data we need to read to get the complete pdu. + * This also sets the endian flag in rpc_in. */ if(!smb_io_rpc_hdr("", &p->hdr, &rpc_in, 0)) { @@ -303,16 +307,45 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) } /* - * If there is no data in the incoming buffer and it's a requst pdu then - * ensure that the FIRST flag is set. If not then we have - * a stream missmatch. + * If there's not data in the incoming buffer and it's a + * request PDU this should be the start of a new RPC. */ - if((p->hdr.pkt_type == RPC_REQUEST) && (prs_offset(&p->in_data.data) == 0) && !(p->hdr.flags & RPC_FLG_FIRST)) { - DEBUG(0,("unmarshall_rpc_header: FIRST flag not set in first PDU !\n")); - set_incoming_fault(p); - prs_mem_free(&rpc_in); - return -1; + if((p->hdr.pkt_type == RPC_REQUEST) && (prs_offset(&p->in_data.data) == 0)) { + + if (!(p->hdr.flags & RPC_FLG_FIRST)) { + /* + * Ensure that the FIRST flag is set. If not then we have + * a stream missmatch. + */ + + DEBUG(0,("unmarshall_rpc_header: FIRST flag not set in first PDU !\n")); + set_incoming_fault(p); + prs_mem_free(&rpc_in); + return -1; + } + + /* + * If this is the first PDU then set the endianness + * flag in the pipe. We will need this when parsing all + * data in this RPC. + */ + + p->endian = rpc_in.bigendian_data; + + } else { + + /* + * If this is *NOT* the first PDU then check the endianness + * flag in the pipe is the same as that in the PDU. + */ + + if (p->endian != rpc_in.bigendian_data) { + DEBUG(0,("unmarshall_rpc_header: FIRST endianness flag different in next PDU !\n")); + set_incoming_fault(p); + prs_mem_free(&rpc_in); + return -1; + } } /* @@ -493,7 +526,10 @@ static ssize_t process_complete_pdu(pipes_struct *p) return (ssize_t)data_len; } - prs_init( &rpc_in, 0, 4, p->mem_ctx, UNMARSHALL); + prs_init( &rpc_in, 0, p->mem_ctx, UNMARSHALL); + /* Ensure we're using the corrent endianness. */ + prs_set_endian_data( &rpc_in, p->endian); + prs_give_memory( &rpc_in, data_p, (uint32)data_len, False); DEBUG(10,("process_complete_pdu: processing packet type %u\n", -- cgit From 1af77d39fa69d201be739e379d8bf4a370fc2df1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 10 Mar 2001 20:11:49 +0000 Subject: Notused. Jeremy. (This used to be commit 635c4cd8e6d29a1fe5043838ae1cb3028e66d060) --- source3/rpc_server/srv_lookup.c | 708 ---------------------------------------- 1 file changed, 708 deletions(-) delete mode 100644 source3/rpc_server/srv_lookup.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lookup.c b/source3/rpc_server/srv_lookup.c deleted file mode 100644 index 8b29be62e7..0000000000 --- a/source3/rpc_server/srv_lookup.c +++ /dev/null @@ -1,708 +0,0 @@ -/* - * Unix SMB/Netbios implementation. - * Version 1.9. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1998 - * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, - * Copyright (C) Paul Ashton 1997-1998. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* - * - * - - this module provides nt user / nt rid lookup functions. - users, local groups, domain groups. - - no unix / samba functions should be called in this module: - it should purely provide a gateway to the password database API, - the local group database API or the domain group database API, - but first checking built-in rids. - - did i say rids? oops, what about "S-1-1" the "Everyone" group - and other such well-known sids... - - speed is not of the essence: no particular optimisation is in place. - - * - * - */ - -#include "includes.h" - -extern int DEBUGLEVEL; - -extern fstring global_sam_name; -extern DOM_SID global_sam_sid; -extern DOM_SID global_sid_S_1_5_20; - -/* - * A list of the rids of well known BUILTIN and Domain users - * and groups. - */ - -rid_name builtin_alias_rids[] = -{ - { BUILTIN_ALIAS_RID_ADMINS , "Administrators" }, - { BUILTIN_ALIAS_RID_USERS , "Users" }, - { BUILTIN_ALIAS_RID_GUESTS , "Guests" }, - { BUILTIN_ALIAS_RID_POWER_USERS , "Power Users" }, - - { BUILTIN_ALIAS_RID_ACCOUNT_OPS , "Account Operators" }, - { BUILTIN_ALIAS_RID_SYSTEM_OPS , "System Operators" }, - { BUILTIN_ALIAS_RID_PRINT_OPS , "Print Operators" }, - { BUILTIN_ALIAS_RID_BACKUP_OPS , "Backup Operators" }, - { BUILTIN_ALIAS_RID_REPLICATOR , "Replicator" }, - { 0 , NULL } -}; - -/* array lookup of well-known Domain RID users. */ -rid_name domain_user_rids[] = -{ - { DOMAIN_USER_RID_ADMIN , "Administrator" }, - { DOMAIN_USER_RID_GUEST , "Guest" }, - { 0 , NULL } -}; - -/* array lookup of well-known Domain RID groups. */ -rid_name domain_group_rids[] = -{ - { DOMAIN_GROUP_RID_ADMINS , "Domain Admins" }, - { DOMAIN_GROUP_RID_USERS , "Domain Users" }, - { DOMAIN_GROUP_RID_GUESTS , "Domain Guests" }, - { 0 , NULL } -}; - - -int make_dom_gids(DOMAIN_GRP *mem, int num_members, DOM_GID **ppgids) -{ - int count; - int i; - DOM_GID *gids = NULL; - - *ppgids = NULL; - - DEBUG(4,("make_dom_gids: %d\n", num_members)); - - if (mem == NULL || num_members == 0) - { - return 0; - } - - for (i = 0, count = 0; i < num_members && count < LSA_MAX_GROUPS; i++) - { - uint32 status; - - uint32 rid; - uint8 type; - - uint8 attr = mem[count].attr; - char *name = mem[count].name; - - become_root(); - status = lookup_grp_rid(name, &rid, &type); - unbecome_root(); - - if (status == 0x0) - { - gids = (DOM_GID *)Realloc( gids, sizeof(DOM_GID) * (count+1) ); - - if (gids == NULL) - { - DEBUG(0,("make_dom_gids: Realloc fail !\n")); - return 0; - } - - gids[count].g_rid = rid; - gids[count].attr = attr; - - DEBUG(5,("group name: %s rid: %d attr: %d\n", - name, rid, attr)); - count++; - } - else - { - DEBUG(1,("make_dom_gids: unknown group name %s\n", name)); - } - } - - *ppgids = gids; - return count; -} - -/******************************************************************* - gets a domain user's groups - ********************************************************************/ -int get_domain_user_groups(DOMAIN_GRP_MEMBER **grp_members, uint32 group_rid) -{ - DOMAIN_GRP *grp; - int num_mem; - - if (grp_members == NULL) return 0; - - grp = getgrouprid(group_rid, grp_members, &num_mem); - - if (grp == NULL) - { - return 0; - } - - return num_mem; -} - - -/******************************************************************* - lookup_builtin_names - ********************************************************************/ -uint32 lookup_builtin_names(uint32 rid, char *name, uint8 *type) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - - status = (status != 0x0) ? lookup_wk_user_name (rid, name, type) : status; - status = (status != 0x0) ? lookup_wk_group_name(rid, name, type) : status; - status = (status != 0x0) ? lookup_wk_alias_name(rid, name, type) : status; - - return status; -} - - -/******************************************************************* - lookup_added_name - names that have been added to the SAM database by admins. - ********************************************************************/ -uint32 lookup_added_name(uint32 rid, char *name, uint8 *type) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - - status = (status != 0x0) ? lookup_user_name (rid, name, type) : status; - status = (status != 0x0) ? lookup_group_name(rid, name, type) : status; - status = (status != 0x0) ? lookup_alias_name(rid, name, type) : status; - - return status; -} - - -/******************************************************************* - lookup_name - ********************************************************************/ -uint32 lookup_name(uint32 rid, char *name, uint8 *type) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - - status = (status != 0x0) ? lookup_builtin_names(rid, name, type) : status; - status = (status != 0x0) ? lookup_added_name (rid, name, type) : status; - - return status; -} - - -/******************************************************************* - lookup_wk_group_name - ********************************************************************/ -uint32 lookup_wk_group_name(uint32 rid, char *group_name, uint8 *type) -{ - int i = 0; - (*type) = SID_NAME_WKN_GRP; - - DEBUG(5,("lookup_wk_group_name: rid: %d", rid)); - - while (domain_group_rids[i].rid != rid && domain_group_rids[i].rid != 0) - { - i++; - } - - if (domain_group_rids[i].rid != 0) - { - fstrcpy(group_name, domain_group_rids[i].name); - DEBUG(5,(" = %s\n", group_name)); - return 0x0; - } - - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_group_name - ********************************************************************/ -uint32 lookup_group_name(uint32 rid, char *group_name, uint8 *type) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - DOM_SID sid; - - DEBUG(5,("lookup_group_name: rid: 0x%x", rid)); - - sid_copy (&sid, &global_sam_sid); - sid_append_rid(&sid, rid); - - (*type) = SID_NAME_DOM_GRP; - - if (map_group_sid_to_name(&sid, group_name, NULL)) - { - status = 0x0; - } - - if (status == 0x0) - { - DEBUG(5,(" = %s\n", group_name)); - } - else - { - DEBUG(5,(" none mapped\n")); - } - - return status; -} - -/******************************************************************* - lookup_wk_alias_name - ********************************************************************/ -uint32 lookup_wk_alias_name(uint32 rid, char *alias_name, uint8 *type) -{ - int i = 0; - (*type) = SID_NAME_ALIAS; - - DEBUG(5,("lookup_wk_alias_name: rid: %d", rid)); - - while (builtin_alias_rids[i].rid != rid && builtin_alias_rids[i].rid != 0) - { - i++; - } - - if (builtin_alias_rids[i].rid != 0) - { - fstrcpy(alias_name, builtin_alias_rids[i].name); - DEBUG(5,(" = %s\n", alias_name)); - return 0x0; - } - - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_alias_name - ********************************************************************/ -uint32 lookup_alias_name(uint32 rid, char *alias_name, uint8 *type) -{ - (*type) = SID_NAME_ALIAS; - - DEBUG(2,("lookup_alias_name: rid: %d\n", rid)); - DEBUG(2,(" NOT IMPLEMENTED\n")); - - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup well-known user name - ********************************************************************/ -uint32 lookup_wk_user_name(uint32 rid, char *user_name, uint8 *type) -{ - int i = 0; - (*type) = SID_NAME_USER; - - DEBUG(5,("lookup_wk_user_name: rid: %d", rid)); - - /* look up the well-known domain user rids first */ - while (domain_user_rids[i].rid != rid && domain_user_rids[i].rid != 0) - { - i++; - } - - if (domain_user_rids[i].rid != 0) - { - fstrcpy(user_name, domain_user_rids[i].name); - DEBUG(5,(" = %s\n", user_name)); - return 0x0; - } - - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup user name - ********************************************************************/ -uint32 lookup_user_name(uint32 rid, char *user_name, uint8 *type) -{ - struct sam_disp_info *disp_info; - (*type) = SID_NAME_USER; - - DEBUG(5,("lookup_user_name: rid: %d", rid)); - - /* find the user account */ - become_root(); - disp_info = getsamdisprid(rid); - unbecome_root(); - - if (disp_info != NULL) - { - fstrcpy(user_name, disp_info->smb_name); - DEBUG(5,(" = %s\n", user_name)); - return 0x0; - } - - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_group_rid - ********************************************************************/ -uint32 lookup_group_rid(char *group_name, uint32 *rid, uint8 *type) -{ - DOM_SID sid; - - (*rid) = 0; - (*type) = SID_NAME_DOM_GRP; - - DEBUG(5,("lookup_group_rid: name: %s", group_name)); - - if (map_group_name_to_sid(group_name, &sid) && - sid_split_rid(&sid, rid) && - sid_equal(&sid, &global_sam_sid)) - { - DEBUG(5,(" = 0x%x\n", (*rid))); - return 0x0; - } - - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_wk_group_rid - ********************************************************************/ -uint32 lookup_wk_group_rid(char *group_name, uint32 *rid, uint8 *type) -{ - char *grp_name; - int i = -1; /* start do loop at -1 */ - (*rid) = 0; - (*type) = SID_NAME_WKN_GRP; - - do /* find, if it exists, a group rid for the group name */ - { - i++; - (*rid) = domain_group_rids[i].rid; - grp_name = domain_group_rids[i].name; - - } while (grp_name != NULL && !strequal(grp_name, group_name)); - - return (grp_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_alias_sid - ********************************************************************/ -uint32 lookup_alias_sid(char *alias_name, DOM_SID *sid, uint8 *type) -{ - (*type) = SID_NAME_ALIAS; - - DEBUG(5,("lookup_alias_rid: name: %s", alias_name)); - - if (map_alias_name_to_sid(alias_name, sid)) - { - fstring sid_str; - sid_to_string(sid_str, sid); - DEBUG(5,(" = %s\n", sid_str)); - return 0x0; - } - - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_alias_rid - ********************************************************************/ -uint32 lookup_alias_rid(char *alias_name, uint32 *rid, uint8 *type) -{ - DOM_SID sid; - - (*rid) = 0; - (*type) = SID_NAME_ALIAS; - - DEBUG(5,("lookup_alias_rid: name: %s", alias_name)); - - if (map_alias_name_to_sid(alias_name, &sid) && - sid_split_rid(&sid, rid) && - sid_equal(&sid, &global_sam_sid)) - { - DEBUG(5,(" = 0x%x\n", (*rid))); - return 0x0; - } - - DEBUG(5,(" none mapped\n")); - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_wk_alias_sid - ********************************************************************/ -uint32 lookup_wk_alias_sid(char *alias_name, DOM_SID *sid, uint8 *type) -{ - char *als_name; - int i = 0; - uint32 rid; - (*type) = SID_NAME_ALIAS; - - do /* find, if it exists, a alias rid for the alias name*/ - { - rid = builtin_alias_rids[i].rid; - als_name = builtin_alias_rids[i].name; - - i++; - - if (strequal(als_name, alias_name)) - { - sid_copy(sid, &global_sid_S_1_5_20); - sid_append_rid(sid, rid); - - return 0x0; - } - - } while (als_name != NULL); - - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_wk_alias_rid - ********************************************************************/ -uint32 lookup_wk_alias_rid(char *alias_name, uint32 *rid, uint8 *type) -{ - char *als_name; - int i = -1; /* start do loop at -1 */ - (*rid) = 0; - (*type) = SID_NAME_ALIAS; - - do /* find, if it exists, a alias rid for the alias name*/ - { - i++; - (*rid) = builtin_alias_rids[i].rid; - als_name = builtin_alias_rids[i].name; - - } while (als_name != NULL && !strequal(als_name, alias_name)); - - return (als_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_sid - ********************************************************************/ -uint32 lookup_sid(char *name, DOM_SID *sid, uint8 *type) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - fstring domain; - fstring user; - - split_domain_name(name, domain, user); - - if (!strequal(domain, global_sam_name)) - { - DEBUG(0,("lookup_sid: remote domain %s not supported\n", domain)); - return status; - } - - status = (status != 0x0) ? lookup_wk_alias_sid(user, sid, type) : status; - status = (status != 0x0) ? lookup_alias_sid (user, sid, type) : status; -#if 0 - status = (status != 0x0) ? lookup_domain_sid (user, sid, type) : status; -#endif - - return status; -} - -/******************************************************************* - lookup_added_user_rid - ********************************************************************/ -uint32 lookup_added_user_rids(char *user_name, - uint32 *usr_rid, uint32 *grp_rid) -{ - SAM_ACCOUNT *sam_pass; - (*usr_rid) = 0; - (*grp_rid) = 0; - - /* find the user account */ - become_root(); - sam_pass = getsampwnam(user_name); - unbecome_root(); - - if (sam_pass != NULL) - { - (*usr_rid) = pdb_get_user_rid(sam_pass); - (*grp_rid) = pdb_get_group_rid(sam_pass); - return 0x0; - } - - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_added_user_rid - ********************************************************************/ -uint32 lookup_added_user_rid(char *user_name, uint32 *rid, uint8 *type) -{ - SAM_ACCOUNT *sam_pass; - (*rid) = 0; - (*type) = SID_NAME_USER; - - /* find the user account */ - become_root(); - sam_pass = getsampwnam(user_name); - unbecome_root(); - - if (sam_pass != NULL) - { - (*rid) = pdb_get_user_rid(sam_pass); - return 0x0; - } - - return 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_wk_user_rid - ********************************************************************/ -uint32 lookup_wk_user_rid(char *user_name, uint32 *rid, uint8 *type) -{ - char *usr_name; - int i = -1; /* start do loop at -1 */ - (*rid) = 0; - (*type) = SID_NAME_USER; - - do /* find, if it exists, a alias rid for the alias name*/ - { - i++; - (*rid) = domain_user_rids[i].rid; - usr_name = domain_user_rids[i].name; - - } while (usr_name != NULL && !strequal(usr_name, user_name)); - - return (usr_name != NULL) ? 0 : 0xC0000000 | NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - lookup_added_grp_rid - ********************************************************************/ -uint32 lookup_added_grp_rid(char *name, uint32 *rid, uint8 *type) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - - status = (status != 0x0) ? lookup_group_rid(name, rid, type) : status; - status = (status != 0x0) ? lookup_alias_rid(name, rid, type) : status; - - return status; -} - -/******************************************************************* - lookup_builtin_grp_rid - ********************************************************************/ -uint32 lookup_builtin_grp_rid(char *name, uint32 *rid, uint8 *type) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - - status = (status != 0x0) ? lookup_wk_group_rid(name, rid, type) : status; - status = (status != 0x0) ? lookup_wk_alias_rid(name, rid, type) : status; - - return status; -} - -/******************************************************************* - lookup_grp_rid - ********************************************************************/ -uint32 lookup_grp_rid(char *name, uint32 *rid, uint8 *type) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - - status = (status != 0x0) ? lookup_builtin_grp_rid(name, rid, type) : status; - status = (status != 0x0) ? lookup_added_grp_rid (name, rid, type) : status; - - return status; -} - -/******************************************************************* - lookup_user_rid - ********************************************************************/ -uint32 lookup_user_rid(char *name, uint32 *rid, uint8 *type) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - - status = (status != 0x0) ? lookup_wk_user_rid (name, rid, type) : status; - status = (status != 0x0) ? lookup_added_user_rid(name, rid, type) : status; - - return status; -} - -/******************************************************************* - lookup_rid - ********************************************************************/ -uint32 lookup_rid(char *name, uint32 *rid, uint8 *type) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - - status = (status != 0x0) ? lookup_user_rid(name, rid, type) : status; - status = (status != 0x0) ? lookup_grp_rid (name, rid, type) : status; - - return status; -} - -/******************************************************************* - lookup_user_rids - ********************************************************************/ -uint32 lookup_user_rids(char *name, uint32 *usr_rid, uint32 *grp_rid) -{ - uint32 status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - uint8 type; - - /* - * try an ordinary user lookup - */ - - status = lookup_added_user_rids(name, usr_rid, grp_rid); - if (status == 0) - { - return status; - } - - /* - * hm. must be a well-known user, in a well-known group. - */ - - status = lookup_wk_user_rid(name, usr_rid, &type); - if (status != 0 || type != SID_NAME_USER) - { - return status; /* ok, maybe not! */ - } - if (type != SID_NAME_USER) - { - return 0xC0000000 | NT_STATUS_NONE_MAPPED; /* users only... */ - } - - /* - * ok, got the user rid: now try the group rid - */ - - status = lookup_builtin_grp_rid(name, grp_rid, &type); - if (type == SID_NAME_DOM_GRP || - type == SID_NAME_ALIAS || - type == SID_NAME_WKN_GRP) - { - status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - } - - return status; -} -- cgit From da3053048c3d224a20d6383ac6682d31059cd46c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 11 Mar 2001 00:32:10 +0000 Subject: Merge of new 2.2 code into HEAD (Gerald I hate you :-) :-). Allows new SAMR RPC code to merge with new passdb code. Currently rpcclient doesn't compile. I'm working on it... Jeremy. (This used to be commit 0be41d5158ea4e645e93e8cd30617c038416e549) --- source3/rpc_server/srv_lsa.c | 3 - source3/rpc_server/srv_lsa_hnd.c | 274 ++-- source3/rpc_server/srv_lsa_nt.c | 27 +- source3/rpc_server/srv_netlog.c | 835 ++---------- source3/rpc_server/srv_netlog_nt.c | 184 +-- source3/rpc_server/srv_pipe.c | 71 +- source3/rpc_server/srv_pipe_hnd.c | 61 +- source3/rpc_server/srv_reg.c | 2 - source3/rpc_server/srv_reg_nt.c | 35 +- source3/rpc_server/srv_samr.c | 2566 +++++++++-------------------------- source3/rpc_server/srv_samr_nt.c | 672 +++++---- source3/rpc_server/srv_spoolss.c | 9 +- source3/rpc_server/srv_spoolss_nt.c | 434 +++--- source3/rpc_server/srv_srvsvc.c | 3 - source3/rpc_server/srv_srvsvc_nt.c | 5 +- source3/rpc_server/srv_util.c | 51 +- source3/rpc_server/srv_wkssvc.c | 3 - source3/rpc_server/srv_wkssvc_nt.c | 2 - 18 files changed, 1497 insertions(+), 3740 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 3b6725ec3a..b6a8c745a4 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -1,4 +1,3 @@ -#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -293,5 +292,3 @@ BOOL api_ntlsa_rpc(pipes_struct *p) { return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds); } - -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 10b9bef1be..bcc3878d86 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -1,11 +1,10 @@ -#define OLD_NTDOMAIN 1 - /* * Unix SMB/Netbios implementation. * Version 1.9. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Jeremy Allison 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,266 +25,145 @@ extern int DEBUGLEVEL; +/* This is the max handles per pipe. */ #ifndef MAX_OPEN_POLS -#define MAX_OPEN_POLS 2048 +#define MAX_OPEN_POLS 256 #endif -struct reg_info -{ - /* for use by \PIPE\winreg */ - fstring name; /* name of registry key */ -}; - -struct samr_info -{ - /* for use by the \PIPE\samr policy */ - DOM_SID sid; - uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ -}; - -static struct policy -{ - struct policy *next, *prev; - int pnum; - BOOL open; - POLICY_HND pol_hnd; - - union { - struct samr_info samr; - struct reg_info reg; - } dev; -} *Policy; - -static struct bitmap *bmap; - -static uint32 pol_hnd_low = 0; -static uint32 pol_hnd_high = 0; - -/******************************************************************* - Creates a POLICY_HND structure. -********************************************************************/ - -void create_policy_handle(POLICY_HND *hnd, uint32 *hnd_low, uint32 *hnd_high) -{ - if (hnd == NULL) return; - - (*hnd_low)++; - if (*hnd_low == 0) (*hnd_high)++; - - ZERO_STRUCTP(hnd); - - SIVAL(&hnd->data1, 0 , 0); /* first bit must be null */ - SIVAL(&hnd->data2, 0 , *hnd_low ); /* second bit is incrementing */ - SSVAL(&hnd->data3, 0 , *hnd_high); /* second bit is incrementing */ - SSVAL(&hnd->data4, 0 , (*hnd_high>>16)); /* second bit is incrementing */ - SIVAL(hnd->data5, 0, time(NULL)); /* something random */ - SIVAL(hnd->data5, 4, sys_getpid()); /* something more random */ -} - /**************************************************************************** initialise policy handle states... ****************************************************************************/ -void init_lsa_policy_hnd(void) + +void init_pipe_handles(pipes_struct *p) { - bmap = bitmap_allocate(MAX_OPEN_POLS); - if (!bmap) { - exit_server("out of memory in init_lsa_policy_hnd\n"); - } + p->pipe_handles.Policy = NULL; + p->pipe_handles.count = 0; } /**************************************************************************** find first available policy slot. creates a policy handle for you. ****************************************************************************/ -BOOL open_lsa_policy_hnd(POLICY_HND *hnd) + +BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *), void *data_ptr) { - int i; - struct policy *p; + static uint32 pol_hnd_low = 0; + static uint32 pol_hnd_high = 0; - i = bitmap_find(bmap, 1); + struct policy *pol; - if (i == -1) { - DEBUG(0,("ERROR: out of Policy Handles!\n")); + if (p->pipe_handles.count > MAX_OPEN_POLS) { + DEBUG(0,("create_policy_hnd: ERROR: too many handles (%d) on this pipe.\n", (int)p->pipe_handles.count)); return False; } - p = (struct policy *)malloc(sizeof(*p)); - if (!p) { - DEBUG(0,("ERROR: out of memory!\n")); + pol = (struct policy *)malloc(sizeof(*p)); + if (!pol) { + DEBUG(0,("create_policy_hnd: ERROR: out of memory!\n")); return False; } - ZERO_STRUCTP(p); + ZERO_STRUCTP(pol); + + pol->p = p; + pol->data_ptr = data_ptr; + pol->free_fn = free_fn; - p->open = True; - p->pnum = i; + pol_hnd_low++; + if (pol_hnd_low == 0) (pol_hnd_high)++; - create_policy_handle(hnd, &pol_hnd_low, &pol_hnd_high); - p->pol_hnd = *hnd; + SIVAL(&pol->pol_hnd.data1, 0 , 0); /* first bit must be null */ + SIVAL(&pol->pol_hnd.data2, 0 , pol_hnd_low ); /* second bit is incrementing */ + SSVAL(&pol->pol_hnd.data3, 0 , pol_hnd_high); /* second bit is incrementing */ + SSVAL(&pol->pol_hnd.data4, 0 , (pol_hnd_high>>16)); /* second bit is incrementing */ + SIVAL(pol->pol_hnd.data5, 0, time(NULL)); /* something random */ + SIVAL(pol->pol_hnd.data5, 4, sys_getpid()); /* something more random */ - bitmap_set(bmap, i); + DLIST_ADD(p->pipe_handles.Policy, pol); + p->pipe_handles.count++; - DLIST_ADD(Policy, p); + *hnd = pol->pol_hnd; - DEBUG(4,("Opened policy hnd[%x] ", i)); - dump_data(4, (char *)hnd, sizeof(hnd)); + DEBUG(4,("Opened policy hnd[%d] ", (int)p->pipe_handles.count)); + dump_data(4, (char *)hnd, sizeof(*hnd)); return True; } /**************************************************************************** - find policy by handle + find policy by handle - internal version. ****************************************************************************/ -static struct policy *find_lsa_policy(POLICY_HND *hnd) -{ - struct policy *p; - for (p=Policy;p;p=p->next) { - if (memcmp(&p->pol_hnd, hnd, sizeof(*hnd)) == 0) { - DEBUG(4,("Found policy hnd[%x] ", p->pnum)); - dump_data(4, (char *)hnd, sizeof(hnd)); - return p; +static struct policy *find_policy_by_hnd_internal(pipes_struct *p, POLICY_HND *hnd, void **data_p) +{ + struct policy *pol; + size_t i; + + if (data_p) + *data_p = NULL; + + for (i = 0, pol=p->pipe_handles.Policy;pol;pol=pol->next, i++) { + if (memcmp(&pol->pol_hnd, hnd, sizeof(*hnd)) == 0) { + DEBUG(4,("Found policy hnd[%d] ", (int)i)); + dump_data(4, (char *)hnd, sizeof(*hnd)); + if (data_p) + *data_p = pol->data_ptr; + return pol; } } DEBUG(4,("Policy not found: ")); - dump_data(4, (char *)hnd, sizeof(hnd)); + dump_data(4, (char *)hnd, sizeof(*hnd)); return NULL; } /**************************************************************************** - find policy index by handle + find policy by handle ****************************************************************************/ -int find_lsa_policy_by_hnd(POLICY_HND *hnd) -{ - struct policy *p = find_lsa_policy(hnd); - return p?p->pnum:-1; -} - - -/**************************************************************************** - set samr pol status. absolutely no idea what this is. -****************************************************************************/ -BOOL set_lsa_policy_samr_pol_status(POLICY_HND *hnd, uint32 pol_status) +BOOL find_policy_by_hnd(pipes_struct *p, POLICY_HND *hnd, void **data_p) { - struct policy *p = find_lsa_policy(hnd); - - if (p && p->open) { - DEBUG(3,("Setting policy status=%x pnum=%x\n", - pol_status, p->pnum)); - - p->dev.samr.status = pol_status; - return True; - } - - DEBUG(3,("Error setting policy status=%x\n", - pol_status)); - return False; + return find_policy_by_hnd_internal(p, hnd, data_p) == NULL ? False : True; } /**************************************************************************** - set samr sid + Close a policy. ****************************************************************************/ -BOOL set_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) -{ - fstring sidstr; - struct policy *p = find_lsa_policy(hnd); - if (p && p->open) { - DEBUG(3,("Setting policy sid=%s pnum=%x\n", - sid_to_string(sidstr, sid), p->pnum)); - - memcpy(&p->dev.samr.sid, sid, sizeof(*sid)); - return True; - } - - DEBUG(3,("Error setting policy sid=%s\n", - sid_to_string(sidstr, sid))); - return False; -} - -/**************************************************************************** - get samr sid -****************************************************************************/ -BOOL get_lsa_policy_samr_sid(POLICY_HND *hnd, DOM_SID *sid) +BOOL close_policy_hnd(pipes_struct *p, POLICY_HND *hnd) { - struct policy *p = find_lsa_policy(hnd); + struct policy *pol = find_policy_by_hnd_internal(p, hnd, NULL); - if (p != NULL && p->open) { - fstring sidstr; - memcpy(sid, &p->dev.samr.sid, sizeof(*sid)); - DEBUG(3,("Getting policy sid=%s pnum=%x\n", - sid_to_string(sidstr, sid), p->pnum)); - - return True; + if (!pol) { + DEBUG(3,("Error closing policy\n")); + return False; } - DEBUG(3,("Error getting policy\n")); - return False; -} + DEBUG(3,("Closed policy\n")); -/**************************************************************************** - get samr rid -****************************************************************************/ -uint32 get_lsa_policy_samr_rid(POLICY_HND *hnd) -{ - struct policy *p = find_lsa_policy(hnd); + if (pol->free_fn && pol->data_ptr) + (*pol->free_fn)(pol->data_ptr); - if (p && p->open) { - uint32 rid = p->dev.samr.sid.sub_auths[p->dev.samr.sid.num_auths-1]; - DEBUG(3,("Getting policy device rid=%x pnum=%x\n", - rid, p->pnum)); + pol->p->pipe_handles.count--; - return rid; - } + DLIST_REMOVE(pol->p->pipe_handles.Policy, pol); - DEBUG(3,("Error getting policy\n")); - return 0xffffffff; -} + ZERO_STRUCTP(pol); -/**************************************************************************** - set reg name -****************************************************************************/ -BOOL set_lsa_policy_reg_name(POLICY_HND *hnd, fstring name) -{ - struct policy *p = find_lsa_policy(hnd); - - if (p && p->open) { - DEBUG(3,("Setting policy pnum=%x name=%s\n", - p->pnum, name)); + free(pol); - fstrcpy(p->dev.reg.name, name); - return True; - } - - DEBUG(3,("Error setting policy name=%s\n", name)); - return False; + return True; } /**************************************************************************** - close an lsa policy + Close all the pipe handles. ****************************************************************************/ -BOOL close_lsa_policy_hnd(POLICY_HND *hnd) -{ - struct policy *p = find_lsa_policy(hnd); - if (!p) { - DEBUG(3,("Error closing policy\n")); - return False; - } - - DEBUG(3,("Closed policy name pnum=%x\n", p->pnum)); - - DLIST_REMOVE(Policy, p); - - bitmap_clear(bmap, p->pnum); - - ZERO_STRUCTP(p); - - free(p); +void close_policy_by_pipe(pipes_struct *p) +{ + while (p->pipe_handles.Policy) + close_policy_hnd(p, &p->pipe_handles.Policy->pol_hnd); - return True; + p->pipe_handles.Policy = NULL; + p->pipe_handles.count = 0; } - -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index ee2f38b715..8e1d934309 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1,4 +1,3 @@ -#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -275,9 +274,6 @@ static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, r_l->status = NT_STATUS_NO_PROBLEMO; } -static uint32 lsa_hnd_low = 0; -static uint32 lsa_hnd_high = 0; - /*************************************************************************** _lsa_open_policy2. ***************************************************************************/ @@ -287,7 +283,8 @@ uint32 _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2 /* lkclXXXX having decoded it, ignore all fields in the open policy! */ /* set up the LSA QUERY INFO response */ - create_policy_handle(&r_u->pol, &lsa_hnd_low, &lsa_hnd_high); + if (!create_policy_hnd(p, &r_u->pol, NULL, NULL)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; return NT_STATUS_NOPROBLEMO; } @@ -301,7 +298,8 @@ uint32 _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL *r_ /* lkclXXXX having decoded it, ignore all fields in the open policy! */ /* set up the LSA QUERY INFO response */ - create_policy_handle(&r_u->pol, &lsa_hnd_low, &lsa_hnd_high); + if (!create_policy_hnd(p, &r_u->pol, NULL, NULL)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; return NT_STATUS_NOPROBLEMO; } @@ -316,6 +314,9 @@ uint32 _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_ENU char *dom_name = NULL; DOM_SID *dom_sid = NULL; + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + 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); @@ -336,6 +337,9 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO r_u->status = NT_STATUS_NO_PROBLEMO; + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + return NT_STATUS_INVALID_HANDLE; + switch (q_u->info_class) { case 0x02: { @@ -420,6 +424,9 @@ uint32 _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_SI LSA_TRANS_NAME_ENUM *names = NULL; uint32 mapped_count = 0; + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + return NT_STATUS_INVALID_HANDLE; + ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); names = (LSA_TRANS_NAME_ENUM *)talloc_zero(p->mem_ctx, sizeof(LSA_TRANS_NAME_ENUM)); @@ -445,6 +452,9 @@ uint32 _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_N DOM_RID2 *rids; uint32 mapped_count = 0; + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + return NT_STATUS_INVALID_HANDLE; + ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); rids = (DOM_RID2 *)talloc_zero(p->mem_ctx, sizeof(DOM_RID2)*MAX_LOOKUP_SIDS); @@ -464,6 +474,10 @@ uint32 _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_N uint32 _lsa_close(pipes_struct *p, LSA_Q_CLOSE *q_u, LSA_R_CLOSE *r_u) { + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + return NT_STATUS_INVALID_HANDLE; + + close_policy_hnd(p, &q_u->pol); return NT_STATUS_NO_PROBLEMO; } @@ -475,4 +489,3 @@ uint32 _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SECR { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 8e2b3819cb..01d646bf57 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -1,4 +1,3 @@ -#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -6,7 +5,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jeremy Allison 1998. + * Copyright (C) Jeremy Allison 1998-2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,344 +22,39 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* This is the interface to the netlogon pipe. */ + #include "includes.h" extern int DEBUGLEVEL; -extern BOOL sam_logon_in_ssb; -extern pstring samlogon_user; -extern pstring global_myname; -extern DOM_SID global_sam_sid; - -/************************************************************************* - init_net_r_req_chal: - *************************************************************************/ - -static void init_net_r_req_chal(NET_R_REQ_CHAL *r_c, - DOM_CHAL *srv_chal, int status) -{ - DEBUG(6,("init_net_r_req_chal: %d\n", __LINE__)); - memcpy(r_c->srv_chal.data, srv_chal->data, sizeof(srv_chal->data)); - r_c->status = status; -} - -/************************************************************************* - net_reply_req_chal: - *************************************************************************/ - -static BOOL net_reply_req_chal(NET_Q_REQ_CHAL *q_c, prs_struct *rdata, - DOM_CHAL *srv_chal, uint32 srv_time) -{ - NET_R_REQ_CHAL r_c; - - DEBUG(6,("net_reply_req_chal: %d\n", __LINE__)); - - /* set up the LSA REQUEST CHALLENGE response */ - init_net_r_req_chal(&r_c, srv_chal, srv_time); - - /* store the response in the SMB stream */ - if(!net_io_r_req_chal("", &r_c, rdata, 0)) { - DEBUG(0,("net_reply_req_chal: Failed to marshall NET_R_REQ_CHAL.\n")); - return False; - } - - DEBUG(6,("net_reply_req_chal: %d\n", __LINE__)); - - return True; -} - -/************************************************************************* - net_reply_logon_ctrl2: - *************************************************************************/ - -static BOOL net_reply_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, prs_struct *rdata, - uint32 flags, uint32 pdc_status, uint32 logon_attempts, - uint32 tc_status, char *trust_domain_name) -{ - NET_R_LOGON_CTRL2 r_l; - - DEBUG(6,("net_reply_logon_ctrl2: %d\n", __LINE__)); - - /* set up the Logon Control2 response */ - init_r_logon_ctrl2(&r_l, q_l->query_level, - flags, pdc_status, logon_attempts, - tc_status, trust_domain_name); - - /* store the response in the SMB stream */ - if(!net_io_r_logon_ctrl2("", &r_l, rdata, 0)) { - DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL2.\n")); - return False; - } - - DEBUG(6,("net_reply_logon_ctrl2: %d\n", __LINE__)); - - return True; -} - -/************************************************************************* - net_reply_trust_dom_list: - *************************************************************************/ - -static BOOL net_reply_trust_dom_list(NET_Q_TRUST_DOM_LIST *q_t, prs_struct *rdata, - uint32 num_trust_domains, char *trust_domain_name) -{ - NET_R_TRUST_DOM_LIST r_t; - - DEBUG(6,("net_reply_trust_dom_list: %d\n", __LINE__)); - - /* set up the Trusted Domain List response */ - init_r_trust_dom(&r_t, num_trust_domains, trust_domain_name); - - /* store the response in the SMB stream */ - if(!net_io_r_trust_dom("", &r_t, rdata, 0)) { - DEBUG(0,("net_reply_trust_dom_list: Failed to marshall NET_R_TRUST_DOM_LIST.\n")); - return False; - } - - DEBUG(6,("net_reply_trust_dom_listlogon_ctrl2: %d\n", __LINE__)); - - return True; -} - -/************************************************************************* - init_net_r_auth_2: - *************************************************************************/ - -static void init_net_r_auth_2(NET_R_AUTH_2 *r_a, - DOM_CHAL *resp_cred, NEG_FLAGS *flgs, int status) -{ - memcpy(r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); - memcpy(&r_a->srv_flgs, flgs, sizeof(r_a->srv_flgs)); - r_a->status = status; -} - -/************************************************************************ - net_reply_auth_2: - *************************************************************************/ - -static BOOL net_reply_auth_2(NET_Q_AUTH_2 *q_a, prs_struct *rdata, - DOM_CHAL *resp_cred, int status) -{ - NET_R_AUTH_2 r_a; - NEG_FLAGS srv_flgs; - - srv_flgs.neg_flags = 0x000001ff; - - /* set up the LSA AUTH 2 response */ - - init_net_r_auth_2(&r_a, resp_cred, &srv_flgs, status); - - /* store the response in the SMB stream */ - if(!net_io_r_auth_2("", &r_a, rdata, 0)) { - DEBUG(0,("net_reply_auth_2: Failed to marshall NET_R_AUTH_2.\n")); - return False; - } - - return True; -} - -/*********************************************************************************** - init_net_r_srv_pwset: - ***********************************************************************************/ - -static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, - DOM_CRED *srv_cred, int status) -{ - DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); - - memcpy(&r_s->srv_cred, srv_cred, sizeof(r_s->srv_cred)); - r_s->status = status; - - DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); -} - -/************************************************************************* - net_reply_srv_pwset: - *************************************************************************/ - -static BOOL net_reply_srv_pwset(NET_Q_SRV_PWSET *q_s, prs_struct *rdata, - DOM_CRED *srv_cred, int status) -{ - NET_R_SRV_PWSET r_s; - - DEBUG(5,("net_srv_pwset: %d\n", __LINE__)); - - /* set up the LSA Server Password Set response */ - init_net_r_srv_pwset(&r_s, srv_cred, status); - - /* store the response in the SMB stream */ - if(!net_io_r_srv_pwset("", &r_s, rdata, 0)) { - DEBUG(0,("net_reply_srv_pwset: Failed to marshall NET_R_SRV_PWSET.\n")); - return False; - } - - DEBUG(5,("net_srv_pwset: %d\n", __LINE__)); - - return True; -} - -/************************************************************************* - net_reply_sam_logon: - *************************************************************************/ - -static BOOL net_reply_sam_logon(NET_Q_SAM_LOGON *q_s, prs_struct *rdata, - DOM_CRED *srv_cred, NET_USER_INFO_3 *user_info, - uint32 status) -{ - NET_R_SAM_LOGON r_s; - - /* XXXX maybe we want to say 'no', reject the client's credentials */ - r_s.buffer_creds = 1; /* yes, we have valid server credentials */ - memcpy(&r_s.srv_creds, srv_cred, sizeof(r_s.srv_creds)); - - /* store the user information, if there is any. */ - r_s.user = user_info; - if (status == 0x0 && user_info != NULL && user_info->ptr_user_info != 0) - r_s.switch_value = 3; /* indicates type of validation user info */ - else - r_s.switch_value = 0; /* indicates no info */ - - r_s.status = status; - r_s.auth_resp = 1; /* authoritative response */ - - /* store the response in the SMB stream */ - if(!net_io_r_sam_logon("", &r_s, rdata, 0)) { - DEBUG(0,("net_reply_sam_logon: Failed to marshall NET_R_SAM_LOGON.\n")); - return False; - } - - return True; -} - - -/************************************************************************* - net_reply_sam_logoff: - *************************************************************************/ - -static BOOL net_reply_sam_logoff(NET_Q_SAM_LOGOFF *q_s, prs_struct *rdata, - DOM_CRED *srv_cred, - uint32 status) -{ - NET_R_SAM_LOGOFF r_s; - - /* XXXX maybe we want to say 'no', reject the client's credentials */ - r_s.buffer_creds = 1; /* yes, we have valid server credentials */ - memcpy(&r_s.srv_creds, srv_cred, sizeof(r_s.srv_creds)); - - r_s.status = status; - - /* store the response in the SMB stream */ - if(!net_io_r_sam_logoff("", &r_s, rdata, 0)) { - DEBUG(0,("net_reply_sam_logoff: Failed to marshall NET_R_SAM_LOGOFF.\n")); - return False; - } - - return True; -} - -/****************************************************************** - gets a machine password entry. checks access rights of the host. - ******************************************************************/ - -static BOOL get_md4pw(char *md4pw, char *mach_name, char *mach_acct) -{ - SAM_ACCOUNT *sampass = NULL; - BYTE *pass = NULL; - -#if 0 - /* - * Currently this code is redundent as we already have a filter - * by hostname list. What this code really needs to do is to - * get a hosts allowed/hosts denied list from the SAM database - * on a per user basis, and make the access decision there. - * I will leave this code here for now as a reminder to implement - * this at a later date. JRA. - */ - - if (!allow_access(lp_domain_hostsdeny(), lp_domain_hostsallow(), - client_name(), client_addr())) - { - DEBUG(0,("get_md4pw: Workstation %s denied access to domain\n", mach_acct)); - return False; - } -#endif /* 0 */ - - become_root(); - sampass = pdb_getsampwnam(mach_acct); - unbecome_root(); - - if ((sampass) != NULL && !(pdb_get_acct_ctrl(sampass) & ACB_DISABLED) && - ((pass=pdb_get_nt_passwd(sampass)) != NULL)) - { - memcpy(md4pw, pass, 16); - dump_data(5, md4pw, 16); - - return True; - } - DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); - return False; -} - /************************************************************************* api_net_req_chal: *************************************************************************/ static BOOL api_net_req_chal(pipes_struct *p) { - NET_Q_REQ_CHAL q_r; - uint32 status = 0x0; - uint16 vuid = p->vuid; + NET_Q_REQ_CHAL q_u; + NET_R_REQ_CHAL r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - fstring mach_acct; - fstring mach_name; - - user_struct *vuser; - - DEBUG(5,("api_net_req_chal(%d): vuid %d\n", __LINE__, (int)vuid)); - - if ((vuser = get_valid_user_struct(vuid)) == NULL) - return False; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); /* grab the challenge... */ - if(!net_io_q_req_chal("", &q_r, data, 0)) { + if(!net_io_q_req_chal("", &q_u, data, 0)) { DEBUG(0,("api_net_req_chal: Failed to unmarshall NET_Q_REQ_CHAL.\n")); return False; } - fstrcpy(mach_acct, dos_unistrn2(q_r.uni_logon_clnt.buffer, - q_r.uni_logon_clnt.uni_str_len)); - - fstrcpy(mach_name, mach_acct); - strlower(mach_name); - - fstrcat(mach_acct, "$"); + r_u.status = _net_req_chal(p, &q_u, &r_u); - if (get_md4pw((char *)vuser->dc.md4pw, mach_name, mach_acct)) { - /* copy the client credentials */ - memcpy(vuser->dc.clnt_chal.data , q_r.clnt_chal.data, sizeof(q_r.clnt_chal.data)); - memcpy(vuser->dc.clnt_cred.challenge.data, q_r.clnt_chal.data, sizeof(q_r.clnt_chal.data)); - - /* create a server challenge for the client */ - /* Set these to random values. */ - generate_random_buffer(vuser->dc.srv_chal.data, 8, False); - - memcpy(vuser->dc.srv_cred.challenge.data, vuser->dc.srv_chal.data, 8); - - memset((char *)vuser->dc.sess_key, '\0', sizeof(vuser->dc.sess_key)); - - /* from client / server challenges and md4 password, generate sess key */ - cred_session_key(&(vuser->dc.clnt_chal), &(vuser->dc.srv_chal), - (char *)vuser->dc.md4pw, vuser->dc.sess_key); - } else { - /* lkclXXXX take a guess at a good error message to return :-) */ - status = NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT; - } - - /* construct reply. */ - if(!net_reply_req_chal(&q_r, rdata, &vuser->dc.srv_chal, status)) + /* store the response in the SMB stream */ + if(!net_io_r_req_chal("", &r_u, rdata, 0)) { + DEBUG(0,("api_net_req_chal: Failed to marshall NET_R_REQ_CHAL.\n")); return False; + } return True; } @@ -371,270 +65,90 @@ static BOOL api_net_req_chal(pipes_struct *p) static BOOL api_net_auth_2(pipes_struct *p) { - uint16 vuid = p->vuid; - NET_Q_AUTH_2 q_a; - uint32 status = 0x0; + NET_Q_AUTH_2 q_u; + NET_R_AUTH_2 r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - DOM_CHAL srv_cred; - UTIME srv_time; - - user_struct *vuser; - - if ((vuser = get_valid_user_struct(vuid)) == NULL) - return False; - - srv_time.time = 0; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); /* grab the challenge... */ - if(!net_io_q_auth_2("", &q_a, data, 0)) { + if(!net_io_q_auth_2("", &q_u, data, 0)) { DEBUG(0,("api_net_auth_2: Failed to unmarshall NET_Q_AUTH_2.\n")); return False; } - /* check that the client credentials are valid */ - if (cred_assert(&(q_a.clnt_chal), vuser->dc.sess_key, - &(vuser->dc.clnt_cred.challenge), srv_time)) { - - /* create server challenge for inclusion in the reply */ - cred_create(vuser->dc.sess_key, &(vuser->dc.srv_cred.challenge), srv_time, &srv_cred); - - /* copy the received client credentials for use next time */ - memcpy(vuser->dc.clnt_cred.challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); - memcpy(vuser->dc.srv_cred .challenge.data, q_a.clnt_chal.data, sizeof(q_a.clnt_chal.data)); - } else { - status = NT_STATUS_ACCESS_DENIED; - } + r_u.status = _net_auth_2(p, &q_u, &r_u); - /* construct reply. */ - if(!net_reply_auth_2(&q_a, rdata, &srv_cred, status)) + /* store the response in the SMB stream */ + if(!net_io_r_auth_2("", &r_u, rdata, 0)) { + DEBUG(0,("api_net_auth_2: Failed to marshall NET_R_AUTH_2.\n")); return False; + } return True; } - /************************************************************************* api_net_srv_pwset: *************************************************************************/ static BOOL api_net_srv_pwset(pipes_struct *p) { - uint16 vuid = p->vuid; - NET_Q_SRV_PWSET q_a; - uint32 status = NT_STATUS_WRONG_PASSWORD; - DOM_CRED srv_cred; - pstring mach_acct; - SAM_ACCOUNT *sampass; - BOOL ret; - user_struct *vuser; + NET_Q_SRV_PWSET q_u; + NET_R_SRV_PWSET r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - if ((vuser = get_valid_user_struct(vuid)) == NULL) - return False; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); /* grab the challenge and encrypted password ... */ - if(!net_io_q_srv_pwset("", &q_a, data, 0)) { + if(!net_io_q_srv_pwset("", &q_u, data, 0)) { DEBUG(0,("api_net_srv_pwset: Failed to unmarshall NET_Q_SRV_PWSET.\n")); return False; } - /* checks and updates credentials. creates reply credentials */ - if (deal_with_creds(vuser->dc.sess_key, &(vuser->dc.clnt_cred), - &(q_a.clnt_id.cred), &srv_cred)) - { - memcpy(&(vuser->dc.srv_cred), &(vuser->dc.clnt_cred), sizeof(vuser->dc.clnt_cred)); - - DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); - - pstrcpy(mach_acct, dos_unistrn2(q_a.clnt_id.login.uni_acct_name.buffer, - q_a.clnt_id.login.uni_acct_name.uni_str_len)); - - DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); - - become_root(); - sampass = pdb_getsampwnam(mach_acct); - unbecome_root(); - - if (sampass != NULL) { - unsigned char pwd[16]; - int i; - - DEBUG(100,("Server password set : new given value was :\n")); - for(i = 0; i < 16; i++) - DEBUG(100,("%02X ", q_a.pwd[i])); - DEBUG(100,("\n")); - - cred_hash3( pwd, q_a.pwd, vuser->dc.sess_key, 0); - - /* lies! nt and lm passwords are _not_ the same: don't care */ - pdb_set_lanman_passwd (sampass, pwd); - pdb_set_nt_passwd (sampass, pwd); - pdb_set_acct_ctrl (sampass, ACB_WSTRUST); - - become_root(); - ret = pdb_update_sam_account (sampass,False); - unbecome_root(); - - if (ret) { - /* hooray! */ - status = 0x0; - } - } - - DEBUG(5,("api_net_srv_pwset: %d\n", __LINE__)); + r_u.status = _net_srv_pwset(p, &q_u, &r_u); - } else { - /* lkclXXXX take a guess at a sensible error code to return... */ - status = NT_STATUS_NETWORK_CREDENTIAL_CONFLICT; - } - - /* Construct reply. */ - if(!net_reply_srv_pwset(&q_a, rdata, &srv_cred, status)) + /* store the response in the SMB stream */ + if(!net_io_r_srv_pwset("", &r_u, rdata, 0)) { + DEBUG(0,("api_net_srv_pwset: Failed to marshall NET_R_SRV_PWSET.\n")); return False; + } return True; } - /************************************************************************* api_net_sam_logoff: *************************************************************************/ static BOOL api_net_sam_logoff(pipes_struct *p) { - uint16 vuid = p->vuid; - NET_Q_SAM_LOGOFF q_l; - NET_ID_INFO_CTR ctr; - DOM_CRED srv_cred; + NET_Q_SAM_LOGOFF q_u; + NET_R_SAM_LOGOFF r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - user_struct *vuser; - - if ((vuser = get_valid_user_struct(vuid)) == NULL) - return False; - - /* the DOM_ID_INFO_1 structure is a bit big. plus we might want to - dynamically allocate it inside net_io_q_sam_logon, at some point */ - q_l.sam_id.ctr = &ctr; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - /* grab the challenge... */ - if(!net_io_q_sam_logoff("", &q_l, data, 0)) { + if(!net_io_q_sam_logoff("", &q_u, data, 0)) { DEBUG(0,("api_net_sam_logoff: Failed to unmarshall NET_Q_SAM_LOGOFF.\n")); return False; } - /* checks and updates credentials. creates reply credentials */ - deal_with_creds(vuser->dc.sess_key, &vuser->dc.clnt_cred, - &q_l.sam_id.client.cred, &srv_cred); - memcpy(&vuser->dc.srv_cred, &vuser->dc.clnt_cred, sizeof(vuser->dc.clnt_cred)); + r_u.status = _net_sam_logoff(p, &q_u, &r_u); - /* construct reply. always indicate success */ - if(!net_reply_sam_logoff(&q_l, rdata, &srv_cred, 0x0)) + /* store the response in the SMB stream */ + if(!net_io_r_sam_logoff("", &r_u, rdata, 0)) { + DEBUG(0,("api_net_sam_logoff: Failed to marshall NET_R_SAM_LOGOFF.\n")); return False; - - return True; -} - -/************************************************************************* - net_login_interactive: - *************************************************************************/ - -static uint32 net_login_interactive(NET_ID_INFO_1 *id1, SAM_ACCOUNT *sampass, - user_struct *vuser) -{ - uint32 status = 0x0; - - char nt_pwd[16]; - char lm_pwd[16]; - unsigned char key[16]; - - memset(key, 0, 16); - memcpy(key, vuser->dc.sess_key, 8); - - memcpy(lm_pwd, id1->lm_owf.data, 16); - memcpy(nt_pwd, id1->nt_owf.data, 16); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("key:")); - dump_data(100, (char *)key, 16); - - DEBUG(100,("lm owf password:")); - dump_data(100, lm_pwd, 16); - - DEBUG(100,("nt owf password:")); - dump_data(100, nt_pwd, 16); -#endif - - SamOEMhash((uchar *)lm_pwd, key, False); - SamOEMhash((uchar *)nt_pwd, key, False); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("decrypt of lm owf password:")); - dump_data(100, lm_pwd, 16); - - DEBUG(100,("decrypt of nt owf password:")); - dump_data(100, nt_pwd, 16); -#endif - - if (memcmp(pdb_get_lanman_passwd(sampass) ,lm_pwd, 16) != 0 || - memcmp(pdb_get_nt_passwd(sampass) ,nt_pwd, 16) != 0) - { - status = NT_STATUS_WRONG_PASSWORD; } - return status; -} - -/************************************************************************* - net_login_network: - *************************************************************************/ - -static uint32 net_login_network(NET_ID_INFO_2 *id2, SAM_ACCOUNT *sampass) -{ - BYTE *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)); - - /* JRA. Check the NT password first if it exists - this is a higher quality - password, if it exists and it doesn't match - fail. */ - - 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 0x0; - else - return NT_STATUS_WRONG_PASSWORD; - } - - /* lkclXXXX this is not a good place to put disabling of LM hashes in. - if that is to be done, first move this entire function into a - library routine that calls the two smb_password_check() functions. - if disabling LM hashes (which nt can do for security reasons) then - an attempt should be made to disable them everywhere (which nt does - not do, for various security-hole reasons). - */ - - if (id2->hdr_lm_chal_resp.str_str_len == 24 && - smb_password_check((char *)id2->lm_chal_resp.buffer, - lanman_pwd, id2->lm_chal)) - { - return 0x0; - } - - - /* oops! neither password check succeeded */ - - return NT_STATUS_WRONG_PASSWORD; + return True; } /************************************************************************* @@ -643,284 +157,94 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, SAM_ACCOUNT *sampass) static BOOL api_net_sam_logon(pipes_struct *p) { - uint16 vuid = p->vuid; - NET_Q_SAM_LOGON q_l; - NET_ID_INFO_CTR ctr; - NET_USER_INFO_3 usr_info; - uint32 status = 0x0; - DOM_CRED srv_cred; - SAM_ACCOUNT *sampass = NULL; - uint16 acct_ctrl; - UNISTR2 *uni_samlogon_user = NULL; - fstring nt_username; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - user_struct *vuser = NULL; - - if ((vuser = get_valid_user_struct(vuid)) == NULL) - return False; - - ZERO_STRUCT(q_l); - ZERO_STRUCT(ctr); - ZERO_STRUCT(usr_info); - - q_l.sam_id.ctr = &ctr; + NET_Q_SAM_LOGON q_u; + NET_R_SAM_LOGON r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - if(!net_io_q_sam_logon("", &q_l, data, 0)) { + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!net_io_q_sam_logon("", &q_u, data, 0)) { DEBUG(0, ("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n")); return False; } - - /* checks and updates credentials. creates reply credentials */ - if (!deal_with_creds(vuser->dc.sess_key, &vuser->dc.clnt_cred, &q_l.sam_id.client.cred, &srv_cred)) - status = NT_STATUS_INVALID_HANDLE; - else - memcpy(&vuser->dc.srv_cred, &vuser->dc.clnt_cred, sizeof(vuser->dc.clnt_cred)); - - /* find the username */ - - if (status == 0) { - switch (q_l.sam_id.logon_level) { - case INTERACTIVE_LOGON_TYPE: - uni_samlogon_user = &q_l.sam_id.ctr->auth.id1.uni_user_name; - - DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); - break; - case NET_LOGON_TYPE: - uni_samlogon_user = &q_l.sam_id.ctr->auth.id2.uni_user_name; - - DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); - break; - default: - DEBUG(2,("SAM Logon: unsupported switch value\n")); - status = NT_STATUS_INVALID_INFO_CLASS; - break; - } /* end switch */ - } /* end if status == 0 */ - - /* check username exists */ - - if (status == 0) - { - pstrcpy(nt_username, dos_unistrn2(uni_samlogon_user->buffer, - uni_samlogon_user->uni_str_len)); - - DEBUG(3,("User:[%s]\n", nt_username)); - - /* - * Convert to a UNIX username. - */ - map_username(nt_username); - - /* get the account information */ - become_root(); - sampass = pdb_getsampwnam(nt_username); - unbecome_root(); - - acct_ctrl = pdb_get_acct_ctrl(sampass); - if (sampass == NULL) - status = NT_STATUS_NO_SUCH_USER; - else if (acct_ctrl & ACB_PWNOTREQ) - status = 0; - else if (acct_ctrl & ACB_DISABLED) - status = NT_STATUS_ACCOUNT_DISABLED; - } - - /* Validate password - if required. */ - - if ((status == 0) && !(acct_ctrl & ACB_PWNOTREQ)) { - switch (q_l.sam_id.logon_level) { - case INTERACTIVE_LOGON_TYPE: - /* interactive login. */ - status = net_login_interactive(&q_l.sam_id.ctr->auth.id1, - sampass, vuser); - break; - case NET_LOGON_TYPE: - /* network login. lm challenge and 24 byte responses */ - status = net_login_network(&q_l.sam_id.ctr->auth.id2, sampass); - break; - } - } - - /* 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 :-) */ - - if (status == 0) { - DOM_GID *gids = NULL; - int num_gids = 0; - pstring my_name; - pstring my_workgroup; - pstring domain_groups; - - /* set up pointer indicating user/password failed to be found */ - usr_info.ptr_user_info = 0; - - /* XXXX hack to get standard_sub_basic() to use sam logon username */ - /* possibly a better way would be to do a become_user() call */ - - /* - * All this information should be filled in from the - * passdb information - */ - sam_logon_in_ssb = True; - pstrcpy(samlogon_user, nt_username); - -#if 0 - gid = pdb_get_gid(sampass); - - pstrcpy(str, pdb_get_logon_script(sampass)); - standard_sub_advanced(-1, nt_username, "", gid, str); - pdb_set_logon_script(sampass, str); - - pstrcpy(str, pdb_get_profile_path(sampass)); - standard_sub_advanced(-1, nt_username, "", gid, str); - pdb_set_profile_path(sampass, str); - - pstrcpy(str, pdb_get_homedir(sampass)); - standard_sub_advanced(-1, nt_username, "", gid, str); - pdb_set_homedir(sampass, str); - - fstrcpy(full_name, ""); - if (lp_unix_realname()) - fstrcpy(full_name, pdb_get_fullname(sampass)); -#endif - - pstrcpy(my_workgroup, lp_workgroup()); - pstrcpy(my_name, global_myname); - strupper(my_name); - - - /* - * This is the point at which we get the group - * database - we should be getting the gid_t list - * from /etc/group and then turning the uids into - * rids and then into machine sids for this user. - * JRA. - */ - - get_domain_user_groups(domain_groups, nt_username); - - /* - * make_dom_gids allocates the gids array. JRA. - */ - gids = NULL; - num_gids = make_dom_gids(domain_groups, &gids); - - sam_logon_in_ssb = False; - - /* - * This next call is where the 'domain admin users' parameter - * gets mapped. I'm leaving it out for now. The user and group rid - * has already been mapped into the SAM_ACCOUNT struct. I don't - * think this should be overridden here. The correct solution - * is proper group memberships and mapping. --jerry - */ -#if 0 - if (pdb_name_to_rid(nt_username, &r_uid, &r_gid)) -#endif - init_net_user_info3(&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 */ - -#if 0 - else - status = NT_STATUS_NO_SUCH_USER; -#endif - - /* Free any allocated groups array. */ - if(gids) - free((char *)gids); - } - - if(!net_reply_sam_logon(&q_l, rdata, &srv_cred, &usr_info, status)) { - free_user_info3(&usr_info); - return False; - } + + r_u.status = _net_sam_logon(p, &q_u, &r_u); - free_user_info3(&usr_info); + /* store the response in the SMB stream */ + if(!net_io_r_sam_logon("", &r_u, rdata, 0)) { + DEBUG(0,("api_net_sam_logon: Failed to marshall NET_R_SAM_LOGON.\n")); + return False; + } return True; } - /************************************************************************* api_net_trust_dom_list: *************************************************************************/ static BOOL api_net_trust_dom_list(pipes_struct *p) { - NET_Q_TRUST_DOM_LIST q_t; + NET_Q_TRUST_DOM_LIST q_u; + NET_R_TRUST_DOM_LIST r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - char *trusted_domain = "test_domain"; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); DEBUG(6,("api_net_trust_dom_list: %d\n", __LINE__)); /* grab the lsa trusted domain list query... */ - if(!net_io_q_trust_dom("", &q_t, data, 0)) { + if(!net_io_q_trust_dom("", &q_u, data, 0)) { DEBUG(0,("api_net_trust_dom_list: Failed to unmarshall NET_Q_TRUST_DOM_LIST.\n")); return False; } /* construct reply. */ - if(!net_reply_trust_dom_list(&q_t, rdata, 1, trusted_domain)) + r_u.status = _net_trust_dom_list(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!net_io_r_trust_dom("", &r_u, rdata, 0)) { + DEBUG(0,("net_reply_trust_dom_list: Failed to marshall NET_R_TRUST_DOM_LIST.\n")); return False; + } DEBUG(6,("api_net_trust_dom_list: %d\n", __LINE__)); return True; } - -/************************************************************************* - error messages cropping up when using nltest.exe... - *************************************************************************/ -#define ERROR_NO_SUCH_DOMAIN 0x54b -#define ERROR_NO_LOGON_SERVERS 0x51f - /************************************************************************* api_net_logon_ctrl2: *************************************************************************/ static BOOL api_net_logon_ctrl2(pipes_struct *p) { - NET_Q_LOGON_CTRL2 q_l; + NET_Q_LOGON_CTRL2 q_u; + NET_R_LOGON_CTRL2 r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - /* lkclXXXX - guess what - absolutely no idea what these are! */ - uint32 flags = 0x0; - uint32 pdc_connection_status = 0x0; - uint32 logon_attempts = 0x0; - uint32 tc_status = ERROR_NO_LOGON_SERVERS; - char *trusted_domain = "test_domain"; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__)); /* grab the lsa netlogon ctrl2 query... */ - if(!net_io_q_logon_ctrl2("", &q_l, data, 0)) { + if(!net_io_q_logon_ctrl2("", &q_u, data, 0)) { DEBUG(0,("api_net_logon_ctrl2: Failed to unmarshall NET_Q_LOGON_CTRL2.\n")); return False; } - /* construct reply. */ - if(!net_reply_logon_ctrl2(&q_l, rdata, - flags, pdc_connection_status, logon_attempts, - tc_status, trusted_domain)) + r_u.status = _net_logon_ctrl2(p, &q_u, &r_u); + + if(!net_io_r_logon_ctrl2("", &r_u, rdata, 0)) { + DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL2.\n")); return False; + } DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__)); @@ -950,4 +274,3 @@ BOOL api_netlog_rpc(pipes_struct *p) { return api_rpcTNP(p, "api_netlog_rpc", api_net_cmds); } -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 151c72499a..613f8f54b2 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -129,7 +129,8 @@ 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; + BYTE *pass; #if 0 /* @@ -150,17 +151,18 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) #endif /* 0 */ become_root(); - smb_pass = getsmbpwnam(mach_acct); + sampass = pdb_getsampwnam(mach_acct); unbecome_root(); - - if ((smb_pass) != NULL && !(smb_pass->acct_ctrl & ACB_DISABLED) && - (smb_pass->smb_nt_passwd != NULL)) + + if ((sampass) != NULL && !(pdb_get_acct_ctrl(sampass) & ACB_DISABLED) && + ((pass=pdb_get_nt_passwd(sampass)) != NULL)) { - memcpy(md4pw, smb_pass->smb_nt_passwd, 16); + memcpy(md4pw, pass, 16); dump_data(5, md4pw, 16); - + return True; } + DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); return False; } @@ -256,11 +258,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) { uint16 vuid = p->vuid; - uint32 status = NT_STATUS_NOPROBLEMO; + uint32 status = NT_STATUS_WRONG_PASSWORD; DOM_CRED srv_cred; pstring mach_acct; - struct smb_passwd *smb_pass; - BOOL ret; + SAM_ACCOUNT *sampass; + BOOL ret = False; user_struct *vuser; unsigned char pwd[16]; int i; @@ -282,10 +284,10 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); become_root(); - smb_pass = getsmbpwnam(mach_acct); + sampass = pdb_getsampwnam(mach_acct); unbecome_root(); - if (smb_pass == NULL) + if (sampass == NULL) return NT_STATUS_NO_SUCH_USER; DEBUG(100,("Server password set : new given value was :\n")); @@ -296,16 +298,16 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ cred_hash3( pwd, q_u->pwd, vuser->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; - + pdb_set_lanman_passwd (sampass, pwd); + pdb_set_nt_passwd (sampass, pwd); + 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_NOPROBLEMO; /* set up the LSA Server Password Set response */ init_net_r_srv_pwset(r_u, &srv_cred, status); @@ -347,7 +349,7 @@ 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, user_struct *vuser) +static uint32 net_login_interactive(NET_ID_INFO_1 *id1, SAM_ACCOUNT *sampass, user_struct *vuser) { uint32 status = 0x0; @@ -383,9 +385,8 @@ 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) - { + if (memcmp(pdb_get_lanman_passwd(sampass), lm_pwd, 16) != 0 || + memcmp(pdb_get_nt_passwd(sampass), nt_pwd, 16) != 0) { status = NT_STATUS_WRONG_PASSWORD; } @@ -396,8 +397,10 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, struct smb_passwd *smb_p _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) { + BYTE *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)); @@ -405,13 +408,13 @@ 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) - { + 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) { if(smb_password_check((char *)id2->nt_chal_resp.buffer, - smb_pass->smb_nt_passwd, - id2->lm_chal)) - return 0x0; + nt_pwd, id2->lm_chal)) + return NT_STATUS_NOPROBLEMO; else return NT_STATUS_WRONG_PASSWORD; } @@ -424,14 +427,10 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, struct smb_passwd *smb_pass) not do, for various security-hole reasons). */ - if (id2->hdr_lm_chal_resp.str_str_len == 24 && + if (id2->hdr_lm_chal_resp.str_str_len == 24 && lanman_pwd && smb_password_check((char *)id2->lm_chal_resp.buffer, - smb_pass->smb_passwd, - id2->lm_chal)) - { - return 0x0; - } - + lanman_pwd, id2->lm_chal)) + return NT_STATUS_NOPROBLEMO; /* oops! neither password check succeeded */ @@ -448,11 +447,10 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ uint16 vuid = p->vuid; 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; + uint16 acct_ctrl; UNISTR2 *uni_samlogon_user = NULL; fstring nt_username; - struct passwd *pw; user_struct *vuser = NULL; usr_info = (NET_USER_INFO_3 *)talloc(p->mem_ctx, sizeof(NET_USER_INFO_3)); @@ -499,33 +497,30 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ map_username(nt_username); - /* - * Do any case conversions. - */ - - pw=Get_Pwnam(nt_username, True); - + /* get the account information */ become_root(); - sam_pass = getsam21pwnam(nt_username); - smb_pass = getsmbpwnam(nt_username); + sampass = pdb_getsampwnam(nt_username); unbecome_root(); - - if (smb_pass == NULL) + + if (sampass == NULL) return NT_STATUS_NO_SUCH_USER; - else if (smb_pass->acct_ctrl & ACB_DISABLED) + + acct_ctrl = pdb_get_acct_ctrl(sampass); + + if (acct_ctrl & ACB_DISABLED) return NT_STATUS_ACCOUNT_DISABLED; /* Validate password - if required. */ - if (!(smb_pass->acct_ctrl & ACB_PWNOTREQ)) { + 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, vuser); + status = net_login_interactive(&q_u->sam_id.ctr->auth.id1, sampass, vuser); 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; } } @@ -538,58 +533,25 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ 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 logon_script; - pstring profile_path; - pstring home_dir; - pstring home_drive; pstring my_name; pstring my_workgroup; pstring domain_groups; - uint32 r_uid; - uint32 r_gid; - fstring full_name; /* set up pointer indicating user/password failed to be found */ usr_info->ptr_user_info = 0; - dummy_time.low = 0xffffffff; - dummy_time.high = 0x7fffffff; - /* 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); - pstrcpy(logon_script, sam_pass->logon_script); - standard_sub_advanced(-1, nt_username, "", pw->pw_gid, logon_script); - - pstrcpy(profile_path, sam_pass->profile_path); - standard_sub_advanced(-1, nt_username, "", pw->pw_gid, profile_path); - pstrcpy(my_workgroup, lp_workgroup()); - - pstrcpy(home_drive, sam_pass->dir_drive); - standard_sub_advanced(-1, nt_username, "", pw->pw_gid, home_drive); - - pstrcpy(home_dir, sam_pass->home_dir); - standard_sub_advanced(-1, nt_username, "", pw->pw_gid, home_dir); - pstrcpy(my_name, global_myname); strupper(my_name); - pstrcpy(full_name, sam_pass->full_name ); - if( !*full_name ) { - fstrcpy(full_name, ""); - if (lp_unix_realname()) - fstrcpy(full_name, strtok(pw->pw_gecos, ",")); - } - /* * This is the point at which we get the group * database - we should be getting the gid_t list @@ -608,41 +570,17 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ sam_logon_in_ssb = False; - 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 */ - full_name, /* full_name */ - logon_script , /* logon_script */ - profile_path , /* profile_path */ - home_dir , /* home_dir */ - home_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 */ } /* XXXX maybe we want to say 'no', reject the client's credentials */ diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index dcefeed8b9..bc5b2ab473 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1,4 +1,3 @@ -#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -270,9 +269,9 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm fstring domain; fstring wks; BOOL guest_user = False; - SAM_ACCOUNT *sam_pass = NULL; - BYTE null_smb_passwd[16]; - BYTE *smb_passwd_ptr = NULL; + SAM_ACCOUNT *sampass = NULL; + uchar null_smb_passwd[16]; + uchar *smb_passwd_ptr = NULL; DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); @@ -358,18 +357,6 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm return False; } -/* unnecessary as the passdb validates the user before returning --jerry */ -#if 0 - /* - * 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); - } - -#endif /* 0 */ if(!guest_user) { @@ -383,8 +370,8 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name return False; } - if(!(sam_pass = pdb_getsampwnam(pipe_user_name))) { - DEBUG(1,("api_pipe_ntlmssp_verify: Cannot find user %s in passdb.\n", + if(!(sampass = pdb_getsampwnam(pipe_user_name))) { + DEBUG(1,("api_pipe_ntlmssp_verify: Cannot find user %s in smb passwd database.\n", pipe_user_name)); unbecome_root(); return False; @@ -392,24 +379,18 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name unbecome_root(); - if (sam_pass == NULL) { - DEBUG(1,("api_pipe_ntlmssp_verify: Couldn't find user '%s' in passdb.\n", - pipe_user_name)); - return(False); - } - - /* Quit if the account was disabled. */ - if((pdb_get_acct_ctrl(sam_pass) & ACB_DISABLED) || !pdb_get_lanman_passwd(sam_pass)) { - DEBUG(1,("Account for user '%s' was disabled.\n", pipe_user_name)); - return(False); - } - - if(!pdb_get_nt_passwd(sam_pass)) { - DEBUG(1,("Account for user '%s' has no NT password hash.\n", pipe_user_name)); - return(False); - } - - smb_passwd_ptr = pdb_get_lanman_passwd(sam_pass); + /* 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(!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 = pdb_get_lanman_passwd(sampass); } /* @@ -459,18 +440,18 @@ 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 = pdb_get_uid(sam_pass); - p->pipe_user.gid = pdb_get_gid(sam_pass); + + p->pipe_user.uid = pdb_get_uid(sampass); + p->pipe_user.gid = pdb_get_uid(sampass); /* Set up pipe user group membership. */ initialise_groups(pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); get_current_groups( &p->pipe_user.ngroups, &p->pipe_user.groups); /* Create an NT_USER_TOKEN struct for this user. */ - p->pipe_user.nt_user_token = - create_nt_token(p->pipe_user.uid,p->pipe_user.gid, - p->pipe_user.ngroups, p->pipe_user.groups, - guest_user); + p->pipe_user.nt_user_token = create_nt_token(p->pipe_user.uid,p->pipe_user.gid, + p->pipe_user.ngroups, p->pipe_user.groups, + guest_user); p->ntlmssp_auth_validated = True; return True; @@ -1148,7 +1129,9 @@ BOOL api_pipe_request(pipes_struct *p) if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && api_fd_commands[i].fn != NULL) { DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i].pipe_clnt_name)); + set_current_rpc_talloc(p->mem_ctx); ret = api_fd_commands[i].fn(p); + set_current_rpc_talloc(NULL); } } @@ -1222,7 +1205,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, DEBUG(10, ("api_rpcTNP: rpc input buffer underflow (parse error?)\n")); if (data) { - prs_uint8s(False, "", &p->in_data.data, 0, data, + prs_uint8s(False, "", &p->in_data.data, 0, (unsigned char *)data, data_len); free(data); } @@ -1231,5 +1214,3 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, return True; } - -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 5545071913..cd072122f3 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1,4 +1,3 @@ -#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -40,6 +39,20 @@ static int pipes_open; static pipes_struct *Pipes; static struct bitmap *bmap; +/**************************************************************************** + Pipe iterator functions. +****************************************************************************/ + +pipes_struct *get_first_pipe(void) +{ + return Pipes; +} + +pipes_struct *get_next_pipe(pipes_struct *p) +{ + return p->next; +} + /* this must be larger than the sum of the open files and directories */ static int pipe_handle_offset; @@ -135,7 +148,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, next_pipe = (i+1) % MAX_OPEN_PIPES; for (p = Pipes; p; p = p->next) - DEBUG(5,("open pipes: name %s pnum=%x\n", p->name, p->pnum)); + DEBUG(5,("open_rpc_pipe_p: name %s pnum=%x\n", p->name, p->pnum)); p = (pipes_struct *)malloc(sizeof(*p)); @@ -150,6 +163,8 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, return NULL; } + init_pipe_handles(p); + DLIST_ADD(Pipes, p); /* @@ -379,6 +394,23 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) return 0; /* No extra data processed. */ } +/**************************************************************************** + Call this to free any talloc'ed memory. Do this before and after processing + a complete PDU. +****************************************************************************/ + +void free_pipe_context(pipes_struct *p) +{ + if (p->mem_ctx) { + DEBUG(3,("free_pipe_context: destroying talloc pool of size %u\n", talloc_pool_size(p->mem_ctx) )); + talloc_destroy_pool(p->mem_ctx); + } else { + p->mem_ctx = talloc_init(); + if (p->mem_ctx == NULL) + p->fault_state = True; + } +} + /**************************************************************************** Processes a request pdu. This will do auth processing if needed, and appends the data into the complete stream if the LAST flag is not set. @@ -487,9 +519,13 @@ authentication failed. Denying the request.\n", p->name)); * Process the complete data stream here. */ + free_pipe_context(p); + if(pipe_init_outgoing_data(p)) ret = api_pipe_request(p); + free_pipe_context(p); + /* * We have consumed the whole data stream. Set back to * marshalling and set the offset back to the start of @@ -780,23 +816,6 @@ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, out: - if(p->out_data.data_sent_length >= prs_offset(&p->out_data.rdata)) { - /* - * We have copied all possible data into the current_pdu. This RPC is finished. - * Reset the talloc context to free any allocated data from this RPC. - */ - - if (p->mem_ctx) { - DEBUG(3,("read_from_pipe: destroying talloc pool of size %u\n", talloc_pool_size(p->mem_ctx) )); - talloc_destroy_pool(p->mem_ctx); - } else { - p->mem_ctx = talloc_init(); - if (p->mem_ctx == NULL) - p->fault_state = True; - } - - } - return data_returned; } @@ -865,6 +884,9 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) if (p->mem_ctx) talloc_destroy(p->mem_ctx); + /* Free the handles database. */ + close_policy_by_pipe(p); + bitmap_clear(bmap, p->pnum - pipe_handle_offset); pipes_open--; @@ -921,4 +943,3 @@ pipes_struct *get_rpc_pipe(int pnum) return NULL; } -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 1ca9963cd4..65f0e2304c 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -1,4 +1,3 @@ -#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -156,4 +155,3 @@ BOOL api_reg_rpc(pipes_struct *p) { return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds); } -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 4bd97abb65..4f941e3e1b 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -1,4 +1,3 @@ -#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -30,6 +29,19 @@ extern int DEBUGLEVEL; +struct reg_info +{ + /* for use by \PIPE\winreg */ + fstring name; /* name of registry key */ +}; + +static void free_reg_info(void *ptr) +{ + struct reg_info *info = (struct reg_info *)ptr; + + safe_free(info); +} + /******************************************************************* reg_reply_unknown_1 ********************************************************************/ @@ -40,7 +52,7 @@ uint32 _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) ZERO_STRUCT(r_u->pol); /* close the policy handle */ - if (!close_lsa_policy_hnd(&q_u->pol)) + if (!close_policy_hnd(p, &q_u->pol)) return NT_STATUS_OBJECT_NAME_INVALID; return NT_STATUS_NOPROBLEMO; @@ -52,7 +64,7 @@ uint32 _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) uint32 _reg_open(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u) { - if (!open_lsa_policy_hnd(&r_u->pol)) + if (!create_policy_hnd(p, &r_u->pol, free_reg_info, NULL)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; return NT_STATUS_NOPROBLEMO; @@ -66,15 +78,13 @@ uint32 _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY { POLICY_HND pol; fstring name; + struct reg_info *info = NULL; DEBUG(5,("reg_open_entry: %d\n", __LINE__)); - if (find_lsa_policy_by_hnd(&q_u->pol) == -1) + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) return NT_STATUS_INVALID_HANDLE; - if (!open_lsa_policy_hnd(&pol)) - return NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ - fstrcpy(name, dos_unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len)); DEBUG(5,("reg_open_entry: %s\n", name)); @@ -84,7 +94,13 @@ uint32 _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY !strequal(name, "System\\CurrentControlSet\\services\\Netlogon\\parameters\\")) return NT_STATUS_ACCESS_DENIED; - if (!set_lsa_policy_reg_name(&pol, name)) + if ((info = (struct reg_info *)malloc(sizeof(struct reg_info))) == NULL) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(info); + fstrcpy(info->name, name); + + 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); @@ -110,7 +126,7 @@ uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) DEBUG(5,("_reg_info: %d\n", __LINE__)); - if (find_lsa_policy_by_hnd(&q_u->pol) == -1) + if (find_policy_by_hnd(p, &q_u->pol, NULL) == -1) return NT_STATUS_INVALID_HANDLE; fstrcpy(name, dos_unistrn2(q_u->uni_type.buffer, q_u->uni_type.uni_str_len)); @@ -161,4 +177,3 @@ uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) return status; } -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 2f4143bd6a..828e2e5595 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1,4 +1,3 @@ -#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -7,6 +6,10 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. * Copyright (C) Hewlett-Packard Company 1999. + * + * Split into interface and implementation modules by, + * + * Copyright (C) Jeremy Allison 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,2458 +26,1109 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* + * This is the interface to the SAMR code. + */ + #include "includes.h" extern int DEBUGLEVEL; -extern fstring global_myworkgroup; -extern pstring global_myname; -extern DOM_SID global_sam_sid; - -extern rid_name domain_group_rids[]; -extern rid_name domain_alias_rids[]; -extern rid_name builtin_alias_rids[]; - /******************************************************************* - This next function should be replaced with something that - dynamically returns the correct user info..... JRA. + api_samr_close_hnd ********************************************************************/ -static BOOL 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) +static BOOL api_samr_close_hnd(pipes_struct *p) { - SAM_ACCOUNT *pwd = NULL; - - (*num_entries) = 0; - (*total_entries) = 0; + SAMR_Q_CLOSE_HND q_u; + SAMR_R_CLOSE_HND r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - if (pw_buf == NULL) - return False; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - if (!pdb_setsampwent(False)) - { - DEBUG(0, ("get_sampwd_entries: Unable to open passdb.\n")); + if(!samr_io_q_close_hnd("", &q_u, data, 0)) { + DEBUG(0,("api_samr_close_hnd: unable to unmarshall SAMR_Q_CLOSE_HND.\n")); return False; } - while ( ((pwd=pdb_getsampwent()) != NULL) && ((*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; - } - - 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 = 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 (pdb_get_nt_passwd(pwd) != NULL) - { - memcpy( pw_buf[(*num_entries)].nt_pwd , pdb_get_nt_passwd(pwd), 16); - } - - 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), pdb_get_username(pwd), - pdb_get_user_rid(pwd), pdb_get_acct_ctrl(pwd))); - - if (acb_mask == 0 || (pdb_get_acct_ctrl(pwd) & 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)++; - } - - pdb_endsampwent(); - - return (*num_entries) > 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 - map_username() function.) Since more than one DOS name can map - to the UNIX name, to reverse the mapping you have to specify - which corresponding DOS name you want; that's where the name_idx - parameter comes in. Returns the string requested or NULL if it - fails or can't complete the request for any reason. This doesn't - handle group names (starting with '@') or names starting with - '+' or '&'. If they are encountered, they are skipped. -********************************************************************/ - -static char *unmap_unixname(char *unix_user_name, int name_idx) -{ - char *mapfile = lp_username_map(); - char **lines; - static pstring tok; - int i; - - if (!*unix_user_name) return NULL; - if (!*mapfile) return NULL; - - lines = file_lines_load(mapfile, NULL,False); - if (!lines) { - DEBUG(0,("unmap_unixname: can't open username map %s\n", mapfile)); - return NULL; - } - - DEBUG(5,("unmap_unixname: scanning username map %s, index: %d\n", mapfile, name_idx)); - - for (i=0; lines[i]; i++) { - char *unixname = lines[i]; - char *dosname = strchr(unixname,'='); - - if (!dosname) - continue; - - *dosname++ = 0; - - while (isspace(*unixname)) - unixname++; - if ('!' == *unixname) { - unixname++; - while (*unixname && isspace(*unixname)) - unixname++; - } - - if (!*unixname || strchr("#;",*unixname)) - continue; - - if (strncmp(unixname, unix_user_name, strlen(unix_user_name))) - continue; - - /* We have matched the UNIX user name */ - - while(next_token(&dosname, tok, LIST_SEP, sizeof(tok))) { - if (!strchr("@&+", *tok)) { - name_idx--; - if (name_idx < 0 ) { - break; - } - } - } - - if (name_idx >= 0) { - DEBUG(0,("unmap_unixname: index too high - not that many DOS names\n")); - file_lines_free(lines); - return NULL; - } else { - file_lines_free(lines); - return tok; - } - } - - DEBUG(0,("unmap_unixname: Couldn't find the UNIX user name\n")); - file_lines_free(lines); - return NULL; -} - -/******************************************************************* - This function sets up a list of users taken from the list of - users that UNIX knows about, as well as all the user names that - Samba maps to a valid UNIX user name. (This should work with - /etc/passwd or NIS.) -********************************************************************/ - -static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, - int start_idx, - int *total_entries, int *num_entries, - int max_num_entries, - uint16 acb_mask) -{ - static struct passwd *pwd = NULL; - static uint32 pw_rid; - static BOOL orig_done = False; - static int current_idx = 0; - static int mapped_idx = 0; - char *sep; - - DEBUG(5, ("get_passwd_entries: retrieving a list of UNIX users\n")); - - (*num_entries) = 0; - (*total_entries) = 0; - - /* Skip all this stuff if we're in appliance mode */ - - if (lp_hide_local_users()) goto done; - - if (pw_buf == NULL) return False; - - if (current_idx == 0) { - sys_setpwent(); - } - - /* These two cases are inefficient, but should be called very rarely */ - /* they are the cases where the starting index isn't picking up */ - /* where we left off last time. It is efficient when it starts over */ - /* at zero though. */ - if (start_idx > current_idx) { - /* We aren't far enough; advance to start_idx */ - while (current_idx < start_idx) { - char *unmap_name; - - if(!orig_done) { - if ((pwd = sys_getpwent()) == NULL) break; - current_idx++; - orig_done = True; - } - - while (((unmap_name = unmap_unixname(pwd->pw_name, mapped_idx)) != NULL) && - (current_idx < start_idx)) { - current_idx++; - mapped_idx++; - } - - if (unmap_name == NULL) { - orig_done = False; - mapped_idx = 0; - } - } - } else if (start_idx < current_idx) { - /* We are already too far; start over and advance to start_idx */ - sys_endpwent(); - sys_setpwent(); - current_idx = 0; - mapped_idx = 0; - orig_done = False; - while (current_idx < start_idx) { - char *unmap_name; - - if(!orig_done) { - if ((pwd = sys_getpwent()) == NULL) break; - current_idx++; - orig_done = True; - } - - while (((unmap_name = unmap_unixname(pwd->pw_name, mapped_idx)) != NULL) && - (current_idx < start_idx)) { - current_idx++; - mapped_idx++; - } - - if (unmap_name == NULL) { - orig_done = False; - mapped_idx = 0; - } - } - } - - sep = lp_winbind_separator(); - - /* now current_idx == start_idx */ - while ((*num_entries) < max_num_entries) { - int user_name_len; - char *unmap_name; - - /* This does the original UNIX user itself */ - if(!orig_done) { - if ((pwd = sys_getpwent()) == NULL) break; - - /* Don't enumerate winbind users as they are not local */ - - if (strchr(pwd->pw_name, *sep) != NULL) { - continue; - } - - user_name_len = strlen(pwd->pw_name); - pw_rid = pdb_uid_to_user_rid(pwd->pw_uid); - ZERO_STRUCTP(&pw_buf[(*num_entries)]); - init_unistr2(&(pw_buf[(*num_entries)].uni_user_name), pwd->pw_name, user_name_len); - init_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len); - pw_buf[(*num_entries)].user_rid = pw_rid; - memset((char *)pw_buf[(*num_entries)].nt_pwd, '\0', 16); - - pw_buf[(*num_entries)].acb_info = ACB_NORMAL; - - DEBUG(5, ("get_passwd_entries: entry idx %d user %s, rid 0x%x\n", (*num_entries), pwd->pw_name, pw_rid)); - - (*num_entries)++; - (*total_entries)++; - current_idx++; - orig_done = True; - } - - /* This does all the user names that map to the UNIX user */ - while (((unmap_name = unmap_unixname(pwd->pw_name, mapped_idx)) != NULL) && - (*num_entries < max_num_entries)) { - user_name_len = strlen(unmap_name); - ZERO_STRUCTP(&pw_buf[(*num_entries)]); - init_unistr2(&(pw_buf[(*num_entries)].uni_user_name), unmap_name, user_name_len); - init_uni_hdr(&(pw_buf[(*num_entries)].hdr_user_name), user_name_len); - pw_buf[(*num_entries)].user_rid = pw_rid; - memset((char *)pw_buf[(*num_entries)].nt_pwd, '\0', 16); - - pw_buf[(*num_entries)].acb_info = ACB_NORMAL; - - DEBUG(5, ("get_passwd_entries: entry idx %d user %s, rid 0x%x\n", (*num_entries), pwd->pw_name, pw_rid)); - - (*num_entries)++; - (*total_entries)++; - current_idx++; - mapped_idx++; - } - - if (unmap_name == NULL) { - /* done with 'aliases', go on to next UNIX user */ - orig_done = False; - mapped_idx = 0; - } - } + r_u.status = _samr_close_hnd(p, &q_u, &r_u); - if (pwd == NULL) { - /* totally done, reset everything */ - sys_endpwent(); - current_idx = 0; - mapped_idx = 0; + /* store the response in the SMB stream */ + if(!samr_io_r_close_hnd("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_close_hnd: unable to marshall SAMR_R_CLOSE_HND.\n")); + return False; } -done: - return (*num_entries) > 0; + return True; } /******************************************************************* - samr_reply_unknown_1 + api_samr_open_domain ********************************************************************/ -static BOOL samr_reply_close_hnd(SAMR_Q_CLOSE_HND *q_u, - prs_struct *rdata) + +static BOOL api_samr_open_domain(pipes_struct *p) { - SAMR_R_CLOSE_HND r_u; + SAMR_Q_OPEN_DOMAIN q_u; + SAMR_R_OPEN_DOMAIN r_u; - /* set up the SAMR unknown_1 response */ - ZERO_STRUCT(r_u.pol); + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - /* close the policy handle */ - if (close_lsa_policy_hnd(&(q_u->pol))) - { - r_u.status = 0; - } - else - { - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_INVALID; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!samr_io_q_open_domain("", &q_u, data, 0)) { + DEBUG(0,("api_samr_open_domain: unable to unmarshall SAMR_Q_OPEN_DOMAIN.\n")); + return False; } - DEBUG(5,("samr_reply_close_hnd: %d\n", __LINE__)); + r_u.status = _samr_open_domain(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_close_hnd("", &r_u, rdata, 0)) + if(!samr_io_r_open_domain("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_open_domain: unable to marshall SAMR_R_OPEN_DOMAIN.\n")); return False; - - DEBUG(5,("samr_reply_close_hnd: %d\n", __LINE__)); + } return True; } /******************************************************************* - api_samr_close_hnd + api_samr_get_usrdom_pwinfo ********************************************************************/ -static BOOL api_samr_close_hnd(pipes_struct *p) + +static BOOL api_samr_get_usrdom_pwinfo(pipes_struct *p) { - SAMR_Q_CLOSE_HND q_u; + SAMR_Q_GET_USRDOM_PWINFO q_u; + SAMR_R_GET_USRDOM_PWINFO r_u; + prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - /* grab the samr unknown 1 */ - if(!samr_io_q_close_hnd("", &q_u, data, 0)) + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!samr_io_q_get_usrdom_pwinfo("", &q_u, data, 0)) return False; - /* construct reply. always indicate success */ - if(!samr_reply_close_hnd(&q_u, rdata)) + r_u.status = _samr_get_usrdom_pwinfo(p, &q_u, &r_u); + + if(!samr_io_r_get_usrdom_pwinfo("", &r_u, rdata, 0)) return False; return True; } - /******************************************************************* - samr_reply_open_domain + api_samr_query_sec_obj ********************************************************************/ -static BOOL samr_reply_open_domain(SAMR_Q_OPEN_DOMAIN *q_u, - prs_struct *rdata) -{ - SAMR_R_OPEN_DOMAIN r_u; - BOOL pol_open = False; - r_u.status = 0x0; - - /* find the connection policy handle. */ - if (r_u.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) - { - r_u.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } +static BOOL api_samr_query_sec_obj(pipes_struct *p) +{ + SAMR_Q_QUERY_SEC_OBJ q_u; + SAMR_R_QUERY_SEC_OBJ r_u; - /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.domain_pol)))) - { - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - /* associate the domain SID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_lsa_policy_samr_sid(&(r_u.domain_pol), &(q_u->dom_sid.sid))) - { - /* oh, whoops. don't know what error message to return, here */ - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - if (r_u.status != 0 && pol_open) - { - close_lsa_policy_hnd(&(r_u.domain_pol)); - } + if(!samr_io_q_query_sec_obj("", &q_u, data, 0)) + return False; - DEBUG(5,("samr_open_domain: %d\n", __LINE__)); + r_u.status = _samr_query_sec_obj(p, &q_u, &r_u); - /* store the response in the SMB stream */ - if(!samr_io_r_open_domain("", &r_u, rdata, 0)) + if(!samr_io_r_query_sec_obj("", &r_u, rdata, 0)) return False; - DEBUG(5,("samr_open_domain: %d\n", __LINE__)); - return True; } /******************************************************************* - api_samr_open_domain + api_samr_enum_dom_users ********************************************************************/ -static BOOL api_samr_open_domain(pipes_struct *p) + +static BOOL api_samr_enum_dom_users(pipes_struct *p) { - SAMR_Q_OPEN_DOMAIN q_u; + SAMR_Q_ENUM_DOM_USERS q_u; + SAMR_R_ENUM_DOM_USERS r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + /* grab the samr open */ - if(!samr_io_q_open_domain("", &q_u, data, 0)) + if(!samr_io_q_enum_dom_users("", &q_u, data, 0)) return False; - /* construct reply. always indicate success */ - if(!samr_reply_open_domain(&q_u, rdata)) + r_u.status = _samr_enum_dom_users(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!samr_io_r_enum_dom_users("", &r_u, rdata, 0)) return False; return True; } - /******************************************************************* - samr_reply_unknown_2c + api_samr_enum_dom_groups ********************************************************************/ -static BOOL samr_reply_unknown_2c(SAMR_Q_UNKNOWN_2C *q_u, - prs_struct *rdata) -{ - SAMR_R_UNKNOWN_2C r_u; - uint32 status = 0x0; - /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->user_pol)) == -1)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } +static BOOL api_samr_enum_dom_groups(pipes_struct *p) +{ + SAMR_Q_ENUM_DOM_GROUPS q_u; + SAMR_R_ENUM_DOM_GROUPS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - /* find the user's rid */ - if ((status == 0x0) && (get_lsa_policy_samr_rid(&(q_u->user_pol)) == 0xffffffff)) - { - status = NT_STATUS_OBJECT_TYPE_MISMATCH; - } + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - init_samr_r_unknown_2c(&r_u, status); + /* grab the samr open */ + if(!samr_io_q_enum_dom_groups("", &q_u, data, 0)) + return False; - DEBUG(5,("samr_unknown_2c: %d\n", __LINE__)); + r_u.status = _samr_enum_dom_groups(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_unknown_2c("", &r_u, rdata, 0)) + if(!samr_io_r_enum_dom_groups("", &r_u, rdata, 0)) return False; - DEBUG(5,("samr_unknown_2c: %d\n", __LINE__)); - return True; } /******************************************************************* - api_samr_unknown_2c + api_samr_enum_dom_aliases ********************************************************************/ -static BOOL api_samr_unknown_2c(pipes_struct *p) + +static BOOL api_samr_enum_dom_aliases(pipes_struct *p) { - SAMR_Q_UNKNOWN_2C q_u; + SAMR_Q_ENUM_DOM_ALIASES q_u; + SAMR_R_ENUM_DOM_ALIASES r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); /* grab the samr open */ - if(!samr_io_q_unknown_2c("", &q_u, data, 0)) + if(!samr_io_q_enum_dom_aliases("", &q_u, data, 0)) return False; - /* construct reply. always indicate success */ - if(!samr_reply_unknown_2c(&q_u, rdata)) + r_u.status = _samr_enum_dom_aliases(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!samr_io_r_enum_dom_aliases("", &r_u, rdata, 0)) return False; return True; } - /******************************************************************* - samr_reply_unknown_3 + api_samr_query_dispinfo ********************************************************************/ -static BOOL samr_reply_unknown_3(SAMR_Q_UNKNOWN_3 *q_u, - prs_struct *rdata) -{ - SAMR_R_UNKNOWN_3 r_u; - DOM_SID3 sid[MAX_SAM_SIDS]; - uint32 rid; - uint32 status; - - status = 0x0; - /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->user_pol)) == -1)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - - /* find the user's rid */ - if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->user_pol))) == 0xffffffff) - { - status = NT_STATUS_OBJECT_TYPE_MISMATCH; - } - - if (status == 0x0) - { - DOM_SID user_sid; - DOM_SID everyone_sid; - - user_sid = global_sam_sid; - - SMB_ASSERT_ARRAY(user_sid.sub_auths, user_sid.num_auths+1); - - /* - * Add the user RID. - */ - user_sid.sub_auths[user_sid.num_auths++] = rid; - - string_to_sid(&everyone_sid, "S-1-1"); +static BOOL api_samr_query_dispinfo(pipes_struct *p) +{ + SAMR_Q_QUERY_DISPINFO q_u; + SAMR_R_QUERY_DISPINFO r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - /* maybe need another 1 or 2 (S-1-5-0x20-0x220 and S-1-5-20-0x224) */ - /* these two are DOMAIN_ADMIN and DOMAIN_ACCT_OP group RIDs */ - init_dom_sid3(&(sid[0]), 0x035b, 0x0002, &everyone_sid); - init_dom_sid3(&(sid[1]), 0x0044, 0x0002, &user_sid); - } + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - init_samr_r_unknown_3(&r_u, - 0x0001, 0x8004, - 0x00000014, 0x0002, 0x0070, - 2, sid, status); + if(!samr_io_q_query_dispinfo("", &q_u, data, 0)) + return False; - DEBUG(5,("samr_unknown_3: %d\n", __LINE__)); + r_u.status = _samr_query_dispinfo(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_unknown_3("", &r_u, rdata, 0)) + if(!samr_io_r_query_dispinfo("", &r_u, rdata, 0)) return False; - DEBUG(5,("samr_unknown_3: %d\n", __LINE__)); - return True; } /******************************************************************* - api_samr_unknown_3 + api_samr_query_aliasinfo ********************************************************************/ -static BOOL api_samr_unknown_3(pipes_struct *p) + +static BOOL api_samr_query_aliasinfo(pipes_struct *p) { - SAMR_Q_UNKNOWN_3 q_u; + SAMR_Q_QUERY_ALIASINFO q_u; + SAMR_R_QUERY_ALIASINFO r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + /* grab the samr open */ - if(!samr_io_q_unknown_3("", &q_u, data, 0)) + if(!samr_io_q_query_aliasinfo("", &q_u, data, 0)) return False; - /* construct reply. always indicate success */ - if(!samr_reply_unknown_3(&q_u, rdata)) - return False; + r_u.status = _samr_query_aliasinfo(p, &q_u, &r_u); + /* store the response in the SMB stream */ + if(!samr_io_r_query_aliasinfo("", &r_u, rdata, 0)) + return False; + return True; } - /******************************************************************* - samr_reply_enum_dom_users + api_samr_lookup_names ********************************************************************/ -static BOOL samr_reply_enum_dom_users(SAMR_Q_ENUM_DOM_USERS *q_u, - prs_struct *rdata) -{ - SAMR_R_ENUM_DOM_USERS r_e; - SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; - int num_entries; - int total_entries; - - ZERO_STRUCT(r_e); - r_e.status = 0x0; - r_e.total_num_entries = 0; - - /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) - { - r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } +static BOOL api_samr_lookup_names(pipes_struct *p) +{ + SAMR_Q_LOOKUP_NAMES q_u; + SAMR_R_LOOKUP_NAMES r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - DEBUG(5,("samr_reply_enum_dom_users: %d\n", __LINE__)); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - become_root(); - get_sampwd_entries(pass, 0, &total_entries, &num_entries, MAX_SAM_ENTRIES, q_u->acb_mask); - unbecome_root(); + /* grab the samr lookup names */ + if(!samr_io_q_lookup_names("", &q_u, data, 0)) + return False; - init_samr_r_enum_dom_users(&r_e, total_entries, - q_u->unknown_0, num_entries, - pass, r_e.status); + r_u.status = _samr_lookup_names(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_enum_dom_users("", &r_e, rdata, 0)) + if(!samr_io_r_lookup_names("", &r_u, rdata, 0)) return False; - DEBUG(5,("samr_enum_dom_users: %d\n", __LINE__)); - return True; } /******************************************************************* - api_samr_enum_dom_users + api_samr_chgpasswd_user ********************************************************************/ -static BOOL api_samr_enum_dom_users(pipes_struct *p) + +static BOOL api_samr_chgpasswd_user(pipes_struct *p) { - SAMR_Q_ENUM_DOM_USERS q_e; + SAMR_Q_CHGPASSWD_USER q_u; + SAMR_R_CHGPASSWD_USER r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - /* grab the samr open */ - if(!samr_io_q_enum_dom_users("", &q_e, data, 0)) + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* unknown 38 command */ + if (!samr_io_q_chgpasswd_user("", &q_u, data, 0)) { + DEBUG(0,("api_samr_chgpasswd_user: Failed to unmarshall SAMR_Q_CHGPASSWD_USER.\n")); return False; + } - /* construct reply. */ - if(!samr_reply_enum_dom_users(&q_e, rdata)) + r_u.status = _samr_chgpasswd_user(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!samr_io_r_chgpasswd_user("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_chgpasswd_user: Failed to marshall SAMR_R_CHGPASSWD_USER.\n" )); return False; + } return True; } /******************************************************************* - samr_reply_enum_dom_groups + api_samr_lookup_rids ********************************************************************/ -static BOOL samr_reply_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS *q_u, - prs_struct *rdata) -{ - SAMR_R_ENUM_DOM_GROUPS r_e; - SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; - int num_entries; - BOOL got_grps; - char *dummy_group = "Domain Admins"; - - ZERO_STRUCT(r_e); - - r_e.status = 0x0; - r_e.num_entries = 0; - /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) - { - r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } +static BOOL api_samr_lookup_rids(pipes_struct *p) +{ + SAMR_Q_LOOKUP_RIDS q_u; + SAMR_R_LOOKUP_RIDS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - got_grps = True; - num_entries = 1; - ZERO_STRUCTP(&pass[0]); - init_unistr2(&(pass[0].uni_user_name), dummy_group, strlen(dummy_group)+1); - pass[0].user_rid = DOMAIN_GROUP_RID_ADMINS; + /* grab the samr lookup names */ + if(!samr_io_q_lookup_rids("", &q_u, data, 0)) + return False; - if (r_e.status == 0 && got_grps) - { - init_samr_r_enum_dom_groups(&r_e, q_u->start_idx, num_entries, pass, r_e.status); - } + r_u.status = _samr_lookup_rids(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_enum_dom_groups("", &r_e, rdata, 0)) + if(!samr_io_r_lookup_rids("", &r_u, rdata, 0)) return False; - DEBUG(5,("samr_enum_dom_groups: %d\n", __LINE__)); - return True; } /******************************************************************* - api_samr_enum_dom_groups + api_samr_open_user ********************************************************************/ -static BOOL api_samr_enum_dom_groups(pipes_struct *p) + +static BOOL api_samr_open_user(pipes_struct *p) { - SAMR_Q_ENUM_DOM_GROUPS q_e; + SAMR_Q_OPEN_USER q_u; + SAMR_R_OPEN_USER r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - /* grab the samr open */ - if(!samr_io_q_enum_dom_groups("", &q_e, data, 0)) + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the samr unknown 22 */ + if(!samr_io_q_open_user("", &q_u, data, 0)) return False; - /* construct reply. */ - if(!samr_reply_enum_dom_groups(&q_e, rdata)) + r_u.status = _api_samr_open_user(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!samr_io_r_open_user("", &r_u, rdata, 0)) return False; + DEBUG(5,("samr_open_user: %d\n", __LINE__)); + return True; } /******************************************************************* - samr_reply_enum_dom_aliases + api_samr_query_userinfo ********************************************************************/ -static BOOL samr_reply_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES *q_u, - prs_struct *rdata) + +static BOOL api_samr_query_userinfo(pipes_struct *p) { - SAMR_R_ENUM_DOM_ALIASES r_e; - SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; - int num_entries = 0; - DOM_SID sid; - fstring sid_str; - fstring sam_sid_str; - struct group *grp; - - ZERO_STRUCT(r_e); + SAMR_Q_QUERY_USERINFO q_u; + SAMR_R_QUERY_USERINFO r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && !get_lsa_policy_samr_sid(&q_u->pol, &sid)) - { - r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - sid_to_string(sid_str, &sid); - sid_to_string(sam_sid_str, &global_sam_sid); - - DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", sid_str)); - - /* well-known aliases */ - if (strequal(sid_str, "S-1-5-32")) - { - char *name; - while (!lp_hide_local_users() && - num_entries < MAX_SAM_ENTRIES && - ((name = builtin_alias_rids[num_entries].name) != NULL)) - { - init_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)+1); - pass[num_entries].user_rid = builtin_alias_rids[num_entries].rid; - num_entries++; - } - } - else if (strequal(sid_str, sam_sid_str) && !lp_hide_local_users()) - { - char *name; - char *sep; - - sep = lp_winbind_separator(); - - /* local aliases */ - /* we return the UNIX groups here. This seems to be the right */ - /* thing to do, since NT member servers return their local */ - /* groups in the same situation. */ - setgrent(); - - while (num_entries < MAX_SAM_ENTRIES && ((grp = getgrent()) != NULL)) - { - int i; - uint32 trid; - name = grp->gr_name; - - /* Don't return winbind groups as they are not local! */ - - if (strchr(name, *sep) != NULL) { - continue; - } - - trid = pdb_gid_to_group_rid(grp->gr_gid); - for( i = 0; i < num_entries; i++) - if ( pass[i].user_rid == trid ) break; - if ( i < num_entries ) - continue; /* rid was there, dup! */ - - init_unistr2(&(pass[num_entries].uni_user_name), name, strlen(name)+1); - pass[num_entries].user_rid = trid; - num_entries++; - } - - endgrent(); - } - - init_samr_r_enum_dom_aliases(&r_e, num_entries, pass, r_e.status); + /* grab the samr unknown 24 */ + if(!samr_io_q_query_userinfo("", &q_u, data, 0)) + return False; + + r_u.status = _samr_query_userinfo(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_enum_dom_aliases("", &r_e, rdata, 0)) + if(!samr_io_r_query_userinfo("", &r_u, rdata, 0)) return False; - DEBUG(5,("samr_enum_dom_aliases: %d\n", __LINE__)); - return True; } /******************************************************************* - api_samr_enum_dom_aliases + api_samr_query_usergroups ********************************************************************/ -static BOOL api_samr_enum_dom_aliases(pipes_struct *p) + +static BOOL api_samr_query_usergroups(pipes_struct *p) { - SAMR_Q_ENUM_DOM_ALIASES q_e; + SAMR_Q_QUERY_USERGROUPS q_u; + SAMR_R_QUERY_USERGROUPS r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_e); - /* grab the samr open */ - if(!samr_io_q_enum_dom_aliases("", &q_e, data, 0)) + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the samr unknown 32 */ + if(!samr_io_q_query_usergroups("", &q_u, data, 0)) return False; - /* construct reply. */ - if(!samr_reply_enum_dom_aliases(&q_e, rdata)) + r_u.status = _samr_query_usergroups(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!samr_io_r_query_usergroups("", &r_u, rdata, 0)) { return False; + } return True; } - /******************************************************************* - samr_reply_query_dispinfo + api_samr_query_dom_info ********************************************************************/ -static BOOL samr_reply_query_dispinfo(SAMR_Q_QUERY_DISPINFO *q_u, prs_struct *rdata) -{ - SAMR_R_QUERY_DISPINFO r_e; - SAM_INFO_CTR ctr; - SAM_INFO_1 info1; - SAM_INFO_2 info2; - SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; - int num_entries = 0; - int total_entries = 0; - BOOL got_pwds; - uint16 switch_level = 0x0; - - ZERO_STRUCT(r_e); - - DEBUG(5,("samr_reply_query_dispinfo: %d\n", __LINE__)); - - /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) - { - r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - DEBUG(5,("samr_reply_query_dispinfo: invalid handle\n")); - } - - if (r_e.status == 0x0) - { - /* decide how many entries to get depending on the max_entries - and max_size passed by client */ - uint32 retsize; - - if(q_u->max_entries > MAX_SAM_ENTRIES) - q_u->max_entries = MAX_SAM_ENTRIES; - - retsize = (q_u->max_entries * (sizeof(SAM_ENTRY1)+sizeof(SAM_STR1))) - + 3*sizeof(uint32); - - if(retsize > q_u->max_size) - { - /* determine max_entries based on max_size */ - q_u->max_entries = (q_u->max_size - 3*sizeof(uint32)) / - (sizeof(SAM_ENTRY1)+sizeof(SAM_STR1)); - q_u->max_entries = (q_u->max_entries>0?q_u->max_entries:1); - } - - DEBUG(10,("samr_reply_query_dispinfo: Setting q_u->max_entries to %u\n",q_u->max_entries)); - - become_root(); - got_pwds = get_passwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, q_u->max_entries, 0); - unbecome_root(); - - /* more left - set resume handle */ - if(total_entries > num_entries) - { - r_e.status = 0x105; - } - - switch (q_u->switch_level) - { - case 0x1: - { - - /* query disp info is for users */ - ZERO_STRUCT (info1); - switch_level = 0x1; - init_sam_info_1(&info1, ACB_NORMAL, - q_u->start_idx, num_entries, pass); - - ctr.sam.info1 = &info1; - - break; - } - case 0x2: - { - /* query disp info is for servers */ - ZERO_STRUCT (info2); - switch_level = 0x2; - init_sam_info_2(&info2, ACB_WSTRUST, - q_u->start_idx, num_entries, pass); - - ctr.sam.info2 = &info2; - - break; - } - } - } - - /* more left - set resume handle */ - if(total_entries > num_entries) - { - r_e.status = 0x105; - } - - if (r_e.status == 0 || r_e.status == 0x105) - { - init_samr_r_query_dispinfo(&r_e, switch_level, &ctr, r_e.status); - } - - /* store the response in the SMB stream */ - if(!samr_io_r_query_dispinfo("", &r_e, rdata, 0)) - return False; - - DEBUG(5,("samr_query_dispinfo: %d\n", __LINE__)); - - return True; -} -/******************************************************************* - api_samr_query_dispinfo - ********************************************************************/ -static BOOL api_samr_query_dispinfo(pipes_struct *p) -{ - SAMR_Q_QUERY_DISPINFO q_e; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - /* grab the samr open */ - if(!samr_io_q_query_dispinfo("", &q_e, data, 0)) - return False; - - /* construct reply. */ - if(!samr_reply_query_dispinfo(&q_e, rdata)) - return False; - - return True; -} - - -/******************************************************************* - samr_reply_query_aliasinfo - ********************************************************************/ -static BOOL samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, - prs_struct *rdata) -{ - SAMR_R_QUERY_ALIASINFO r_e; - fstring alias_desc = "Local Unix group"; - fstring alias=""; - enum SID_NAME_USE type; - uint32 alias_rid; - - ZERO_STRUCT(r_e); - - DEBUG(5,("samr_reply_query_aliasinfo: %d\n", __LINE__)); - - /* find the policy handle. open a policy on it. */ - if (r_e.status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) - { - r_e.status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - - alias_rid = get_lsa_policy_samr_rid(&q_u->pol); - if(alias_rid == 0xffffffff) - r_e.status = 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; - - if(!local_lookup_rid(alias_rid, alias, &type)) - { - r_e.status = 0xC0000000 | NT_STATUS_NO_SUCH_ALIAS; - } - - init_samr_r_query_aliasinfo(&r_e, q_u->switch_level, alias, alias_desc); - - /* store the response in the SMB stream */ - if(!samr_io_r_query_aliasinfo("", &r_e, rdata, 0)) - return False; - - DEBUG(5,("samr_query_aliasinfo: %d\n", __LINE__)); - - return True; -} - -/******************************************************************* - api_samr_query_aliasinfo - ********************************************************************/ -static BOOL api_samr_query_aliasinfo(pipes_struct *p) +static BOOL api_samr_query_dom_info(pipes_struct *p) { - SAMR_Q_QUERY_ALIASINFO q_e; + SAMR_Q_QUERY_DOMAIN_INFO q_u; + SAMR_R_QUERY_DOMAIN_INFO r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - /* grab the samr open */ - if(!samr_io_q_query_aliasinfo("", &q_e, data, 0)) - return False; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - /* construct reply. */ - if(!samr_reply_query_aliasinfo(&q_e, rdata)) + /* grab the samr unknown 8 command */ + if(!samr_io_q_query_dom_info("", &q_u, data, 0)) return False; - return True; -} - - -/******************************************************************* - samr_reply_lookup_ids - ********************************************************************/ -static BOOL samr_reply_lookup_ids(SAMR_Q_LOOKUP_IDS *q_u, - prs_struct *rdata) -{ - uint32 rid[MAX_SAM_ENTRIES]; - uint32 status = 0; - int num_rids = q_u->num_sids1; - - SAMR_R_LOOKUP_IDS r_u; - - DEBUG(5,("samr_lookup_ids: %d\n", __LINE__)); - - if (num_rids > MAX_SAM_ENTRIES) - { - num_rids = MAX_SAM_ENTRIES; - DEBUG(5,("samr_lookup_ids: truncating entries to %d\n", num_rids)); - } - -#if 0 - int i; - SMB_ASSERT_ARRAY(q_u->uni_user_name, num_rids); - - for (i = 0; i < num_rids && status == 0; i++) - { - SAM_ACCOUNT *sam_pass; - fstring user_name; - - - fstrcpy(user_name, unistrn2(q_u->uni_user_name[i].buffer, - q_u->uni_user_name[i].uni_str_len)); - - /* find the user account */ - become_root(); - sam_pass = pdb_getsampwnam(user_name); - unbecome_root(); - - if (sam_pass == NULL) - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - rid[i] = 0; - } - else - { - rid[i] = pdb_get_user_rid(sam_pass); - } - } -#endif - - num_rids = 1; - rid[0] = BUILTIN_ALIAS_RID_USERS; - - init_samr_r_lookup_ids(&r_u, num_rids, rid, status); + r_u.status = _samr_query_dom_info(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_lookup_ids("", &r_u, rdata, 0)) - return False; - - DEBUG(5,("samr_lookup_ids: %d\n", __LINE__)); - - return True; -} - -/******************************************************************* - api_samr_lookup_ids - ********************************************************************/ -static BOOL api_samr_lookup_ids(pipes_struct *p) -{ - SAMR_Q_LOOKUP_IDS q_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - /* grab the samr 0x10 */ - if(!samr_io_q_lookup_ids("", &q_u, data, 0)) + if(!samr_io_r_query_dom_info("", &r_u, rdata, 0)) return False; - /* construct reply. always indicate success */ - if(!samr_reply_lookup_ids(&q_u, rdata)) - return False; + DEBUG(5,("api_samr_query_dom_info: %d\n", __LINE__)); return True; } /******************************************************************* - samr_reply_lookup_names - ********************************************************************/ - -static BOOL samr_reply_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u, - prs_struct *rdata) -{ - uint32 rid[MAX_SAM_ENTRIES]; - enum SID_NAME_USE type[MAX_SAM_ENTRIES]; - uint32 status = 0; - int i; - int num_rids = q_u->num_names1; - DOM_SID pol_sid; - - SAMR_R_LOOKUP_NAMES r_u; - - DEBUG(5,("samr_lookup_names: %d\n", __LINE__)); - - ZERO_ARRAY(rid); - ZERO_ARRAY(type); - - if (!get_lsa_policy_samr_sid(&q_u->pol, &pol_sid)) { - status = 0xC0000000 | NT_STATUS_OBJECT_TYPE_MISMATCH; - init_samr_r_lookup_names(&r_u, 0, rid, type, status); - if(!samr_io_r_lookup_names("", &r_u, rdata, 0)) { - DEBUG(0,("samr_reply_lookup_names: failed to marshall SAMR_R_LOOKUP_NAMES.\n")); - return False; - } - return True; - } - - if (num_rids > MAX_SAM_ENTRIES) { - num_rids = MAX_SAM_ENTRIES; - DEBUG(5,("samr_lookup_names: truncating entries to %d\n", num_rids)); - } - - SMB_ASSERT_ARRAY(q_u->uni_name, num_rids); - - for (i = 0; i < num_rids; i++) { - fstring name; - - status = 0xC0000000 | NT_STATUS_NONE_MAPPED; - - rid [i] = 0xffffffff; - type[i] = SID_NAME_UNKNOWN; - - fstrcpy(name, dos_unistrn2(q_u->uni_name[i].buffer, - q_u->uni_name[i].uni_str_len)); - - if(sid_equal(&pol_sid, &global_sam_sid)) - { - DOM_SID sid; - if(local_lookup_name(global_myname, name, - &sid, &type[i])) - { - sid_split_rid( &sid, &rid[i]); - status = 0; - } - } - } - - init_samr_r_lookup_names(&r_u, num_rids, rid, type, status); - - /* store the response in the SMB stream */ - if(!samr_io_r_lookup_names("", &r_u, rdata, 0)) { - DEBUG(0,("samr_reply_lookup_names: failed to marshall SAMR_R_LOOKUP_NAMES.\n")); - return False; - } - - DEBUG(5,("samr_lookup_names: %d\n", __LINE__)); - - return True; -} - -/******************************************************************* - api_samr_lookup_names + api_samr_create_user ********************************************************************/ -static BOOL api_samr_lookup_names(pipes_struct *p) +static BOOL api_samr_create_user(pipes_struct *p) { - SAMR_Q_LOOKUP_NAMES q_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - memset(&q_u, '\0', sizeof(q_u)); + SAMR_Q_CREATE_USER q_u; + SAMR_R_CREATE_USER r_u; - /* grab the samr lookup names */ - if(!samr_io_q_lookup_names("", &q_u, data, 0)) { - DEBUG(0,("api_samr_lookup_names: failed to unmarshall SAMR_Q_LOOKUP_NAMES.\n")); - return False; - } + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - /* construct reply. always indicate success */ - if(!samr_reply_lookup_names(&q_u, rdata)) + /* grab the samr create user */ + if (!samr_io_q_create_user("", &q_u, data, 0)) { + DEBUG(0,("api_samr_create_user: Unable to unmarshall SAMR_Q_CREATE_USER.\n")); return False; - - return True; -} - -/******************************************************************* - samr_reply_chgpasswd_user - ********************************************************************/ - -static BOOL samr_reply_chgpasswd_user(SAMR_Q_CHGPASSWD_USER *q_u, - prs_struct *rdata) -{ - SAMR_R_CHGPASSWD_USER r_u; - uint32 status = 0x0; - fstring user_name; - fstring wks; - - 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)); - - DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); - - if (!pass_oem_change(user_name, - q_u->lm_newpass.pass, q_u->lm_oldhash.hash, - q_u->nt_newpass.pass, q_u->nt_oldhash.hash)) - { - status = 0xC0000000 | NT_STATUS_WRONG_PASSWORD; } - init_samr_r_chgpasswd_user(&r_u, status); + r_u.status=_api_samr_create_user(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_chgpasswd_user("", &r_u, rdata, 0)) { - DEBUG(0,("samr_reply_chgpasswd_user: Failed to marshall SAMR_R_CHGPASSWD_USER struct.\n" )); + if(!samr_io_r_create_user("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_create_user: Unable to marshall SAMR_R_CREATE_USER.\n")); return False; } - DEBUG(5,("samr_chgpasswd_user: %d\n", __LINE__)); return True; } /******************************************************************* - api_samr_chgpasswd_user + api_samr_connect_anon ********************************************************************/ -static BOOL api_samr_chgpasswd_user(pipes_struct *p) +static BOOL api_samr_connect_anon(pipes_struct *p) { - SAMR_Q_CHGPASSWD_USER q_u; + SAMR_Q_CONNECT_ANON q_u; + SAMR_R_CONNECT_ANON r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - /* unknown 38 command */ - if (!samr_io_q_chgpasswd_user("", &q_u, data, 0)) { - DEBUG(0,("api_samr_chgpasswd_user: samr_io_q_chgpasswd_user failed to parse RPC packet.\n")); - return False; - } + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - /* construct reply. */ - if(!samr_reply_chgpasswd_user(&q_u, rdata)) { - DEBUG(0,("api_samr_chgpasswd_user: samr_reply_chgpasswd_user failed to create reply packet.\n")); + /* grab the samr open policy */ + if(!samr_io_q_connect_anon("", &q_u, data, 0)) return False; - } - - return True; -} - - -/******************************************************************* - samr_reply_unknown_38 - ********************************************************************/ -static BOOL samr_reply_unknown_38(SAMR_Q_UNKNOWN_38 *q_u, prs_struct *rdata) -{ - SAMR_R_UNKNOWN_38 r_u; - - DEBUG(5,("samr_unknown_38: %d\n", __LINE__)); - init_samr_r_unknown_38(&r_u); + r_u.status = _samr_connect_anon(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_unknown_38("", &r_u, rdata, 0)) + if(!samr_io_r_connect_anon("", &r_u, rdata, 0)) return False; - DEBUG(5,("samr_unknown_38: %d\n", __LINE__)); return True; } /******************************************************************* - api_samr_unknown_38 + api_samr_connect ********************************************************************/ -static BOOL api_samr_unknown_38(pipes_struct *p) + +static BOOL api_samr_connect(pipes_struct *p) { - SAMR_Q_UNKNOWN_38 q_u; + SAMR_Q_CONNECT q_u; + SAMR_R_CONNECT r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - /* unknown 38 command */ - if(!samr_io_q_unknown_38("", &q_u, data, 0)) - return False; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - /* construct reply. always indicate success */ - if(!samr_reply_unknown_38(&q_u, rdata)) + /* grab the samr open policy */ + if(!samr_io_q_connect("", &q_u, data, 0)) return False; - return True; -} - - -/******************************************************************* - samr_reply_lookup_rids - ********************************************************************/ -static BOOL samr_reply_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u, - prs_struct *rdata) -{ - fstring group_names[MAX_SAM_ENTRIES]; - uint32 group_attrs[MAX_SAM_ENTRIES]; - uint32 status = 0; - int num_gids = q_u->num_gids1; - - SAMR_R_LOOKUP_RIDS r_u; - - DEBUG(5,("samr_reply_lookup_rids: %d\n", __LINE__)); - - /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - - if (status == 0x0) - { - int i; - if (num_gids > MAX_SAM_ENTRIES) - { - num_gids = MAX_SAM_ENTRIES; - DEBUG(5,("samr_reply_lookup_rids: truncating entries to %d\n", num_gids)); - } - - for (i = 0; i < num_gids && status == 0; i++) - { - fstrcpy(group_names[i], "dummy group"); - group_attrs[i] = 0x2; - } - } - - init_samr_r_lookup_rids(&r_u, num_gids, group_names, group_attrs, status); + r_u.status = _samr_connect(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_lookup_rids("", &r_u, rdata, 0)) - return False; - - DEBUG(5,("samr_reply_lookup_rids: %d\n", __LINE__)); - - return True; -} - -/******************************************************************* - api_samr_lookup_rids - ********************************************************************/ -static BOOL api_samr_lookup_rids(pipes_struct *p) -{ - SAMR_Q_LOOKUP_RIDS q_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - /* grab the samr lookup names */ - if(!samr_io_q_lookup_rids("", &q_u, data, 0)) - return False; - - /* construct reply. always indicate success */ - if(!samr_reply_lookup_rids(&q_u, rdata)) + if(!samr_io_r_connect("", &r_u, rdata, 0)) return False; return True; } +/********************************************************************** + api_samr_lookup_domain + **********************************************************************/ -/******************************************************************* - _api_samr_open_user - ********************************************************************/ -static uint32 _api_samr_open_user(POLICY_HND domain_pol, uint32 user_rid, POLICY_HND *user_pol) -{ - SAM_ACCOUNT *sam_pass; - DOM_SID sid; - - /* find the domain policy handle. */ - if (find_lsa_policy_by_hnd(&domain_pol) == -1) - return NT_STATUS_INVALID_HANDLE; - - /* get a (unique) handle. open a policy on it. */ - if (!open_lsa_policy_hnd(user_pol)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - - become_root(); - sam_pass = pdb_getsampwrid(user_rid); - unbecome_root(); - - /* check that the RID exists in our domain. */ - if (sam_pass == NULL) { - close_lsa_policy_hnd(user_pol); - return NT_STATUS_NO_SUCH_USER; - } - - /* Get the domain SID stored in the domain policy */ - if(!get_lsa_policy_samr_sid(&domain_pol, &sid)) { - close_lsa_policy_hnd(user_pol); - return NT_STATUS_INVALID_HANDLE; - } - - /* append the user's RID to it */ - if(!sid_append_rid(&sid, user_rid)) { - close_lsa_policy_hnd(user_pol); - return NT_STATUS_NO_SUCH_USER; - } - - /* associate the user's SID with the handle. */ - if (!set_lsa_policy_samr_sid(user_pol, &sid)) { - /* oh, whoops. don't know what error message to return, here */ - close_lsa_policy_hnd(user_pol); - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - - return NT_STATUS_NO_PROBLEMO; -} - -/******************************************************************* - api_samr_open_user - ********************************************************************/ -static BOOL api_samr_open_user(pipes_struct *p) +static BOOL api_samr_lookup_domain(pipes_struct *p) { - SAMR_Q_OPEN_USER q_u; - SAMR_R_OPEN_USER r_u; + SAMR_Q_LOOKUP_DOMAIN q_u; + SAMR_R_LOOKUP_DOMAIN r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - /* grab the samr unknown 22 */ - if(!samr_io_q_open_user("", &q_u, data, 0)) - return False; - - r_u.status = _api_samr_open_user(q_u.domain_pol, q_u.user_rid, &r_u.user_pol); - - /* store the response in the SMB stream */ - if(!samr_io_r_open_user("", &r_u, rdata, 0)) - return False; - - DEBUG(5,("samr_open_user: %d\n", __LINE__)); - - return True; -} - -/************************************************************************* - get_user_info_10 - *************************************************************************/ -static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) -{ - SAM_ACCOUNT *sampass; - - if (!pdb_rid_is_user(user_rid)) - { - DEBUG(4,("RID 0x%x is not a user RID\n", user_rid)); + if(!samr_io_q_lookup_domain("", &q_u, data, 0)) { + DEBUG(0,("api_samr_lookup_domain: Unable to unmarshall SAMR_Q_LOOKUP_DOMAIN.\n")); return False; } - become_root(); - sampass = pdb_getsampwrid(user_rid); - unbecome_root(); - - if (sampass == NULL) - { - DEBUG(4,("User 0x%x not found\n", user_rid)); + r_u.status = _samr_lookup_domain(p, &q_u, &r_u); + + if(!samr_io_r_lookup_domain("", &r_u, rdata, 0)){ + DEBUG(0,("api_samr_lookup_domain: Unable to marshall SAMR_R_LOOKUP_DOMAIN.\n")); return False; } - - DEBUG(3,("User:[%s]\n", pdb_get_username(sampass))); - - init_sam_user_info10(id10, pdb_get_acct_ctrl(sampass)); - + return True; } -/************************************************************************* - get_user_info_21 - *************************************************************************/ -static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) +/********************************************************************** + api_samr_enum_domains + **********************************************************************/ + +static BOOL api_samr_enum_domains(pipes_struct *p) { - SAM_ACCOUNT *sam_pass; + SAMR_Q_ENUM_DOMAINS q_u; + SAMR_R_ENUM_DOMAINS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - if (!pdb_rid_is_user(user_rid)) - { - DEBUG(4,("RID 0x%x is not a user RID\n", user_rid)); + if(!samr_io_q_enum_domains("", &q_u, data, 0)) { + DEBUG(0,("api_samr_enum_domains: Unable to unmarshall SAMR_Q_ENUM_DOMAINS.\n")); return False; } - become_root(); - sam_pass = pdb_getsampwrid(user_rid); - unbecome_root(); + r_u.status = _samr_enum_domains(p, &q_u, &r_u); - if (sam_pass == NULL) - { - DEBUG(4,("User 0x%x not found\n", user_rid)); + if(!samr_io_r_enum_domains("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_enum_domains: Unable to marshall SAMR_R_ENUM_DOMAINS.\n")); return False; } - - DEBUG(3,("User:[%s]\n", pdb_get_username(sam_pass))); - - init_sam_user_info21(id21, sam_pass); - + return True; } /******************************************************************* - samr_reply_query_userinfo + api_samr_open_alias ********************************************************************/ -static BOOL samr_reply_query_userinfo(SAMR_Q_QUERY_USERINFO *q_u, - prs_struct *rdata) -{ - SAMR_R_QUERY_USERINFO r_u; -#if 0 - SAM_USER_INFO_11 id11; -#endif - SAM_USER_INFO_10 id10; - SAM_USER_INFO_21 id21; - void *info = NULL; - - uint32 status = 0x0; - uint32 rid = 0x0; - - DEBUG(5,("samr_reply_query_userinfo: %d\n", __LINE__)); - - /* search for the handle */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) - { - status = NT_STATUS_INVALID_HANDLE; - } - - /* find the user's rid */ - if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->pol))) == 0xffffffff) - { - status = NT_STATUS_OBJECT_TYPE_MISMATCH; - } - - DEBUG(5,("samr_reply_query_userinfo: rid:0x%x\n", rid)); - - /* ok! user info levels (there are lots: see MSDEV help), off we go... */ - if (status == 0x0) - { - switch (q_u->switch_value) - { - case 0x10: - { - info = (void*)&id10; - status = get_user_info_10(&id10, rid) ? 0 : NT_STATUS_NO_SUCH_USER; - break; - } -#if 0 -/* whoops - got this wrong. i think. or don't understand what's happening. */ - case 0x11: - { - NTTIME expire; - info = (void*)&id11; - - expire.low = 0xffffffff; - expire.high = 0x7fffffff; - - make_sam_user_info11(&id11, &expire, "BROOKFIELDS$", 0x03ef, 0x201, 0x0080); - - break; - } -#endif - case 21: - { - info = (void*)&id21; - status = get_user_info_21(&id21, rid) ? 0 : NT_STATUS_NO_SUCH_USER; - break; - } - - default: - { - status = NT_STATUS_INVALID_INFO_CLASS; - - break; - } - } - } - - init_samr_r_query_userinfo(&r_u, q_u->switch_value, info, status); - /* store the response in the SMB stream */ - if(!samr_io_r_query_userinfo("", &r_u, rdata, 0)) - return False; - - DEBUG(5,("samr_reply_query_userinfo: %d\n", __LINE__)); - - return True; -} - -/******************************************************************* - api_samr_query_userinfo - ********************************************************************/ -static BOOL api_samr_query_userinfo(pipes_struct *p) +static BOOL api_samr_open_alias(pipes_struct *p) { - SAMR_Q_QUERY_USERINFO q_u; + SAMR_Q_OPEN_ALIAS q_u; + SAMR_R_OPEN_ALIAS r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - /* grab the samr unknown 24 */ - if(!samr_io_q_query_userinfo("", &q_u, data, 0)) - return False; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - /* construct reply. always indicate success */ - if(!samr_reply_query_userinfo(&q_u, rdata)) + /* grab the samr open policy */ + if(!samr_io_q_open_alias("", &q_u, data, 0)) { + DEBUG(0,("api_samr_open_alias: Unable to unmarshall SAMR_Q_OPEN_ALIAS.\n")); return False; - - return True; -} - - -/******************************************************************* - samr_reply_query_usergroups - ********************************************************************/ -static BOOL samr_reply_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u, - prs_struct *rdata) -{ - SAMR_R_QUERY_USERGROUPS r_u; - uint32 status = 0x0; - - SAM_ACCOUNT *sam_pass; - DOM_GID *gids = NULL; - int num_groups = 0; - uint32 rid; - - DEBUG(5,("samr_query_usergroups: %d\n", __LINE__)); - - /* find the policy handle. open a policy on it. */ - if (status == 0x0 && (find_lsa_policy_by_hnd(&(q_u->pol)) == -1)) - { - status = 0xC0000000 | NT_STATUS_INVALID_HANDLE; - } - - /* find the user's rid */ - if (status == 0x0 && (rid = get_lsa_policy_samr_rid(&(q_u->pol))) == 0xffffffff) - { - status = NT_STATUS_OBJECT_TYPE_MISMATCH; } - if (status == 0x0) - { - become_root(); - sam_pass = pdb_getsampwrid(rid); - unbecome_root(); - - if (sam_pass == NULL) - { - status = 0xC0000000 | NT_STATUS_NO_SUCH_USER; - } - } - - if (status == 0x0) - { - pstring groups; - get_domain_user_groups(groups, pdb_get_username(sam_pass)); - gids = NULL; - num_groups = make_dom_gids(groups, &gids); - } - - /* construct the response. lkclXXXX: gids are not copied! */ - init_samr_r_query_usergroups(&r_u, num_groups, gids, status); + r_u.status=_api_samr_open_alias(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_query_usergroups("", &r_u, rdata, 0)) { - if (gids) - free((char *)gids); + if(!samr_io_r_open_alias("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_open_alias: Unable to marshall SAMR_R_OPEN_ALIAS.\n")); return False; } - - if (gids) - free((char *)gids); - - DEBUG(5,("samr_query_usergroups: %d\n", __LINE__)); return True; } /******************************************************************* - api_samr_query_usergroups + api_samr_set_userinfo ********************************************************************/ -static BOOL api_samr_query_usergroups(pipes_struct *p) -{ - SAMR_Q_QUERY_USERGROUPS q_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - /* grab the samr unknown 32 */ - if(!samr_io_q_query_usergroups("", &q_u, data, 0)) - return False; - - /* construct reply. */ - if(!samr_reply_query_usergroups(&q_u, rdata)) - return False; - return True; -} - - -/******************************************************************* - api_samr_query_dom_info - ********************************************************************/ -static BOOL api_samr_query_dom_info(pipes_struct *p) +static BOOL api_samr_set_userinfo(pipes_struct *p) { - SAMR_Q_QUERY_DOMAIN_INFO q_u; - SAMR_R_QUERY_DOMAIN_INFO r_u; - SAM_UNK_CTR ctr; + SAMR_Q_SET_USERINFO q_u; + SAMR_R_SET_USERINFO r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - uint16 switch_value = 0x0; - uint32 status = 0x0; - ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - ZERO_STRUCT(ctr); - DEBUG(5,("api_samr_query_dom_info: %d\n", __LINE__)); - - /* grab the samr unknown 8 command */ - if(!samr_io_q_query_dom_info("", &q_u, data, 0)) + if (!samr_io_q_set_userinfo("", &q_u, data, 0)) { + DEBUG(0,("api_samr_set_userinfo: Unable to unmarshall SAMR_Q_SET_USERINFO.\n")); return False; - - /* find the policy handle. open a policy on it. */ - if (find_lsa_policy_by_hnd(&q_u.domain_pol) == -1) { - status = NT_STATUS_INVALID_HANDLE; - DEBUG(5,("api_samr_query_dom_info: invalid handle\n")); } - if (status == 0x0) { - switch (q_u.switch_value) { - case 0x01: - switch_value = 0x1; - init_unk_info1(&ctr.info.inf1); - break; - case 0x02: - switch_value = 0x2; - init_unk_info2(&ctr.info.inf2, global_myworkgroup, global_myname); - break; - case 0x03: - switch_value = 0x3; - init_unk_info3(&ctr.info.inf3); - break; - case 0x06: - switch_value = 0x6; - init_unk_info6(&ctr.info.inf6); - break; - case 0x07: - switch_value = 0x7; - init_unk_info7(&ctr.info.inf7); - break; - case 0x0c: - switch_value = 0xc; - init_unk_info12(&ctr.info.inf12); - break; - default: - status = NT_STATUS_INVALID_INFO_CLASS; - break; - } - } - - init_samr_r_query_dom_info(&r_u, switch_value, &ctr, status); + r_u.status = _samr_set_userinfo(p, &q_u, &r_u); - /* store the response in the SMB stream */ - if(!samr_io_r_query_dom_info("", &r_u, rdata, 0)) + if(!samr_io_r_set_userinfo("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_set_userinfo: Unable to marshall SAMR_R_SET_USERINFO.\n")); return False; - - DEBUG(5,("api_samr_query_dom_info: %d\n", __LINE__)); + } return True; } - /******************************************************************* - _api_samr_create_user + api_samr_set_userinfo2 ********************************************************************/ -static BOOL _api_samr_create_user(POLICY_HND dom_pol, UNISTR2 user_account, uint32 acb_info, uint32 access_mask, - POLICY_HND *user_pol, uint32 *unknown0, uint32 *user_rid) -{ - SAM_ACCOUNT *sam_pass; - fstring mach_acct; - pstring err_str; - pstring msg_str; - int local_flags=0; - DOM_SID sid; - - /* find the policy handle. open a policy on it. */ - if (find_lsa_policy_by_hnd(&dom_pol) == -1) - 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 = pdb_getsampwnam(mach_acct); - unbecome_root(); - if (sam_pass != NULL) - { - /* machine account exists: say so */ - return NT_STATUS_USER_EXISTS; - } - - /* get a (unique) handle. open a policy on it. */ - if (!open_lsa_policy_hnd(user_pol)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - - 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 */ - if (lp_adduser_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)); - close_lsa_policy_hnd(user_pol); - return NT_STATUS_ACCESS_DENIED; - } - become_root(); - sam_pass = pdb_getsampwnam(mach_acct); - unbecome_root(); - if (sam_pass == NULL) { - /* account doesn't exist: say so */ - close_lsa_policy_hnd(user_pol); - return NT_STATUS_ACCESS_DENIED; - } - - /* Get the domain SID stored in the domain policy */ - if(!get_lsa_policy_samr_sid(&dom_pol, &sid)) { - close_lsa_policy_hnd(user_pol); - return NT_STATUS_INVALID_HANDLE; - } - - /* append the user's RID to it */ - if(!sid_append_rid(&sid, sam_pass->user_rid)) { - close_lsa_policy_hnd(user_pol); - return NT_STATUS_NO_SUCH_USER; - } - - /* associate the RID with the (unique) handle. */ - if (!set_lsa_policy_samr_sid(user_pol, &sid)) { - /* oh, whoops. don't know what error message to return, here */ - close_lsa_policy_hnd(user_pol); - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - } - - *unknown0 = 0x000703ff; - *user_rid = pdb_get_user_rid(sam_pass); - - return NT_STATUS_NO_PROBLEMO; -} - -/******************************************************************* - api_samr_create_user - ********************************************************************/ -static BOOL api_samr_create_user(pipes_struct *p) +static BOOL api_samr_set_userinfo2(pipes_struct *p) { + SAMR_Q_SET_USERINFO2 q_u; + SAMR_R_SET_USERINFO2 r_u; + prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - SAMR_Q_CREATE_USER q_u; - SAMR_R_CREATE_USER r_u; - ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - /* grab the samr create user */ - if (!samr_io_q_create_user("", &q_u, data, 0)) { - DEBUG(0,("api_samr_create_user: Unable to unmarshall SAMR_Q_CREATE_USER.\n")); + if (!samr_io_q_set_userinfo2("", &q_u, data, 0)) { + DEBUG(0,("api_samr_set_userinfo2: Unable to unmarshall SAMR_Q_SET_USERINFO2.\n")); return False; } - r_u.status=_api_samr_create_user(q_u.pol, q_u.uni_mach_acct, q_u.acb_info, q_u.access_mask, - &r_u.pol, &r_u.unknown_0, &r_u.user_rid); + r_u.status = _samr_set_userinfo2(p, &q_u, &r_u); - /* store the response in the SMB stream */ - if(!samr_io_r_create_user("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_create_user: Unable to marshall SAMR_R_CREATE_USER.\n")); + if(!samr_io_r_set_userinfo2("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_set_userinfo2: Unable to marshall SAMR_R_SET_USERINFO2.\n")); return False; } return True; } - /******************************************************************* - samr_reply_connect_anon + api_samr_query_useraliases ********************************************************************/ -static BOOL samr_reply_connect_anon(SAMR_Q_CONNECT_ANON *q_u, prs_struct *rdata) -{ - SAMR_R_CONNECT_ANON r_u; - BOOL pol_open = False; - /* set up the SAMR connect_anon response */ +static BOOL api_samr_query_useraliases(pipes_struct *p) +{ + SAMR_Q_QUERY_USERALIASES q_u; + SAMR_R_QUERY_USERALIASES r_u; - r_u.status = 0x0; - /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.connect_pol)))) - { - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - /* associate the domain SID with the (unique) handle. */ - if (r_u.status == 0x0 && !set_lsa_policy_samr_pol_status(&(r_u.connect_pol), q_u->unknown_0)) - { - /* oh, whoops. don't know what error message to return, here */ - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - if (r_u.status != 0 && pol_open) - { - close_lsa_policy_hnd(&(r_u.connect_pol)); + if (!samr_io_q_query_useraliases("", &q_u, data, 0)) { + DEBUG(0,("api_samr_query_useraliases: Unable to unmarshall SAMR_Q_QUERY_USERALIASES.\n")); + return False; } - DEBUG(5,("samr_connect_anon: %d\n", __LINE__)); + r_u.status = _samr_query_useraliases(p, &q_u, &r_u); - /* store the response in the SMB stream */ - if(!samr_io_r_connect_anon("", &r_u, rdata, 0)) + if (! samr_io_r_query_useraliases("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_query_useraliases: Unable to nmarshall SAMR_R_QUERY_USERALIASES.\n")); return False; - - DEBUG(5,("samr_connect_anon: %d\n", __LINE__)); + } return True; } /******************************************************************* - api_samr_connect_anon + api_samr_query_aliasmem ********************************************************************/ -static BOOL api_samr_connect_anon(pipes_struct *p) + +static BOOL api_samr_query_aliasmem(pipes_struct *p) { - SAMR_Q_CONNECT_ANON q_u; + SAMR_Q_QUERY_ALIASMEM q_u; + SAMR_R_QUERY_ALIASMEM r_u; + prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - /* grab the samr open policy */ - if(!samr_io_q_connect_anon("", &q_u, data, 0)) + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!samr_io_q_query_aliasmem("", &q_u, data, 0)) { return False; + } + + r_u.status = _samr_query_aliasmem(p, &q_u, &r_u); - /* construct reply. always indicate success */ - if(!samr_reply_connect_anon(&q_u, rdata)) + if (!samr_io_r_query_aliasmem("", &r_u, rdata, 0)) { return False; + } return True; } /******************************************************************* - samr_reply_connect + api_samr_query_groupmem ********************************************************************/ -static BOOL samr_reply_connect(SAMR_Q_CONNECT *q_u, prs_struct *rdata) -{ - SAMR_R_CONNECT r_u; - BOOL pol_open = False; - /* set up the SAMR connect response */ +static BOOL api_samr_query_groupmem(pipes_struct *p) +{ + SAMR_Q_QUERY_GROUPMEM q_u; + SAMR_R_QUERY_GROUPMEM r_u; - r_u.status = 0x0; - /* get a (unique) handle. open a policy on it. */ - if (r_u.status == 0x0 && !(pol_open = open_lsa_policy_hnd(&(r_u.connect_pol)))) - { - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - /* associate the domain SID with the (unique) handle. */ - if (r_u.status == 0x0 && - !set_lsa_policy_samr_pol_status(&(r_u.connect_pol), - q_u->access_mask)) - { - /* oh, whoops. don't know what error message to return, here */ - r_u.status = 0xC0000000 | NT_STATUS_OBJECT_NAME_NOT_FOUND; - } + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - if (r_u.status != 0 && pol_open) - { - close_lsa_policy_hnd(&(r_u.connect_pol)); + if (!samr_io_q_query_groupmem("", &q_u, data, 0)) { + return False; } - DEBUG(5,("samr_connect: %d\n", __LINE__)); + r_u.status = _samr_query_groupmem(p, &q_u, &r_u); - /* store the response in the SMB stream */ - if(!samr_io_r_connect("", &r_u, rdata, 0)) + if (!samr_io_r_query_groupmem("", &r_u, rdata, 0)) { return False; - - DEBUG(5,("samr_connect: %d\n", __LINE__)); + } return True; } /******************************************************************* - api_samr_connect + api_samr_add_aliasmem ********************************************************************/ -static BOOL api_samr_connect(pipes_struct *p) + +static BOOL api_samr_add_aliasmem(pipes_struct *p) { - SAMR_Q_CONNECT q_u; + SAMR_Q_ADD_ALIASMEM q_u; + SAMR_R_ADD_ALIASMEM r_u; + prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - /* grab the samr open policy */ - if(!samr_io_q_connect("", &q_u, data, 0)) + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!samr_io_q_add_aliasmem("", &q_u, data, 0)) { return False; + } - /* construct reply. always indicate success */ - if(!samr_reply_connect(&q_u, rdata)) + r_u.status = _samr_add_aliasmem(p, &q_u, &r_u); + + if (!samr_io_r_add_aliasmem("", &r_u, rdata, 0)) { return False; + } return True; } - -/********************************************************************** - api_samr_lookup_domain - **********************************************************************/ -static BOOL api_samr_lookup_domain(pipes_struct *p) +/******************************************************************* + api_samr_del_aliasmem + ********************************************************************/ + +static BOOL api_samr_del_aliasmem(pipes_struct *p) { - SAMR_Q_LOOKUP_DOMAIN q_u; - SAMR_R_LOOKUP_DOMAIN r_u; + SAMR_Q_DEL_ALIASMEM q_u; + SAMR_R_DEL_ALIASMEM r_u; + prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!samr_io_q_lookup_domain("", &q_u, data, 0)) { - DEBUG(0,("api_samr_lookup_domain: Unable to unmarshall SAMR_Q_LOOKUP_DOMAIN.\n")); + if (!samr_io_q_del_aliasmem("", &q_u, data, 0)) { return False; } - - r_u.status = 0x0; - if (find_lsa_policy_by_hnd(&q_u.connect_pol) == -1){ - r_u.status = NT_STATUS_INVALID_HANDLE; - DEBUG(5,("api_samr_lookup_domain: invalid handle\n")); - } - - /* assume the domain name sent is our global_myname and - send global_sam_sid */ - init_samr_r_lookup_domain(&r_u, &global_sam_sid, r_u.status); - - if(!samr_io_r_lookup_domain("", &r_u, rdata, 0)){ - DEBUG(0,("api_samr_lookup_domain: Unable to marshall SAMR_R_LOOKUP_DOMAIN.\n")); + r_u.status = _samr_del_aliasmem(p, &q_u, &r_u); + + if (!samr_io_r_del_aliasmem("", &r_u, rdata, 0)) { return False; } - + return True; } -/********************************************************************** - api_samr_enum_domains - **********************************************************************/ -static BOOL api_samr_enum_domains(pipes_struct *p) +/******************************************************************* + api_samr_add_groupmem + ********************************************************************/ + +static BOOL api_samr_add_groupmem(pipes_struct *p) { - SAMR_Q_ENUM_DOMAINS q_u; - SAMR_R_ENUM_DOMAINS r_u; + SAMR_Q_ADD_GROUPMEM q_u; + SAMR_R_ADD_GROUPMEM r_u; + prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - - fstring dom[2]; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - fstrcpy(dom[0],global_myworkgroup); - fstrcpy(dom[1],"Builtin"); - - if(!samr_io_q_enum_domains("", &q_u, data, 0)) { - DEBUG(0,("api_samr_enum_domains: Unable to unmarshall SAMR_Q_ENUM_DOMAINS.\n")); + if (!samr_io_q_add_groupmem("", &q_u, data, 0)) { return False; } - r_u.status = NT_STATUS_NO_PROBLEMO; - - init_samr_r_enum_domains(&r_u, q_u.start_idx, dom, 2); + r_u.status = _samr_add_groupmem(p, &q_u, &r_u); - if(!samr_io_r_enum_domains("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_enum_domains: Unable to marshall SAMR_R_ENUM_DOMAINS.\n")); - free(r_u.sam); - free(r_u.uni_dom_name); + if (!samr_io_r_add_groupmem("", &r_u, rdata, 0)) { return False; } - free(r_u.sam); - free(r_u.uni_dom_name); - return True; } - /******************************************************************* - api_samr_open_alias + api_samr_del_groupmem ********************************************************************/ -static uint32 _api_samr_open_alias(POLICY_HND domain_pol, uint32 alias_rid, POLICY_HND *alias_pol) + +static BOOL api_samr_del_groupmem(pipes_struct *p) { - DOM_SID sid; - - /* get the domain policy. */ - if (find_lsa_policy_by_hnd(&domain_pol) == -1) - return NT_STATUS_INVALID_HANDLE; - - /* get a (unique) handle. open a policy on it. */ - if (!open_lsa_policy_hnd(alias_pol)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - - /* Get the domain SID stored in the domain policy */ - if(!get_lsa_policy_samr_sid(&domain_pol, &sid)) { - close_lsa_policy_hnd(alias_pol); - return NT_STATUS_INVALID_HANDLE; - } + SAMR_Q_DEL_GROUPMEM q_u; + SAMR_R_DEL_GROUPMEM r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - /* append the alias' RID to it */ - if(!sid_append_rid(&sid, alias_rid)) { - close_lsa_policy_hnd(alias_pol); - return NT_STATUS_NO_SUCH_USER; + if (!samr_io_q_del_groupmem("", &q_u, data, 0)) { + return False; } - /* associate a RID with the (unique) handle. */ - if (!set_lsa_policy_samr_sid(alias_pol, &sid)) { - /* oh, whoops. don't know what error message to return, here */ - close_lsa_policy_hnd(alias_pol); - return NT_STATUS_OBJECT_NAME_NOT_FOUND; + r_u.status = _samr_del_groupmem(p, &q_u, &r_u); + + if (!samr_io_r_del_groupmem("", &r_u, rdata, 0)) { + return False; } - return NT_STATUS_NO_PROBLEMO; + return True; } /******************************************************************* - api_samr_open_alias + api_samr_delete_dom_user ********************************************************************/ -static BOOL api_samr_open_alias(pipes_struct *p) + +static BOOL api_samr_delete_dom_user(pipes_struct *p) { - SAMR_Q_OPEN_ALIAS q_u; - SAMR_R_OPEN_ALIAS r_u; + SAMR_Q_DELETE_DOM_USER q_u; + SAMR_R_DELETE_DOM_USER r_u; + prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - /* grab the samr open policy */ - if(!samr_io_q_open_alias("", &q_u, data, 0)) { - DEBUG(0,("api_samr_open_alias: Unable to unmarshall SAMR_Q_OPEN_ALIAS.\n")); + if (!samr_io_q_delete_dom_user("", &q_u, data, 0)) { return False; } - r_u.status=_api_samr_open_alias(q_u.dom_pol, q_u.rid_alias, &r_u.pol); + r_u.status = _samr_delete_dom_user(p, &q_u, &r_u); - /* store the response in the SMB stream */ - if(!samr_io_r_open_alias("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_open_alias: Unable to marshall SAMR_R_OPEN_ALIAS.\n")); + if (!samr_io_r_delete_dom_user("", &r_u, rdata, 0)) { return False; } - + return True; } /******************************************************************* - set_user_info_10 + api_samr_delete_dom_group ********************************************************************/ -static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, uint32 rid) + +static BOOL api_samr_delete_dom_group(pipes_struct *p) { - SAM_ACCOUNT *pwd = pdb_getsampwrid(rid); + SAMR_Q_DELETE_DOM_GROUP q_u; + SAMR_R_DELETE_DOM_GROUP r_u; - if (id10 == NULL) { - DEBUG(5, ("set_user_info_10: NULL id10\n")); - return False; - } + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - if (pwd == NULL) + if (!samr_io_q_delete_dom_group("", &q_u, data, 0)) { return False; + } - pdb_set_acct_ctrl(pwd, id10->acb_info); + r_u.status = _samr_delete_dom_group(p, &q_u, &r_u); - if(!pdb_update_sam_account(pwd, True)) + if (!samr_io_r_delete_dom_group("", &r_u, rdata, 0)) { return False; + } return True; } /******************************************************************* - set_user_info_12 + api_samr_delete_dom_alias ********************************************************************/ -static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, uint32 rid) + +static BOOL api_samr_delete_dom_alias(pipes_struct *p) { - SAM_ACCOUNT *pwd = pdb_getsampwrid(rid); + SAMR_Q_DELETE_DOM_ALIAS q_u; + SAMR_R_DELETE_DOM_ALIAS r_u; - if (pwd == NULL) - return False; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - if (id12 == NULL) { - DEBUG(2, ("set_user_info_12: id12 is NULL\n")); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!samr_io_q_delete_dom_alias("", &q_u, data, 0)) { return False; } - pdb_set_lanman_passwd (pwd, id12->lm_pwd); - pdb_set_nt_passwd (pwd, id12->nt_pwd); + r_u.status = _samr_delete_dom_alias(p, &q_u, &r_u); - if(!pdb_update_sam_account(pwd, True)) + if (!samr_io_r_delete_dom_alias("", &r_u, rdata, 0)) { return False; + } return True; } /******************************************************************* - set_user_info_21 + api_samr_create_dom_group ********************************************************************/ -static BOOL set_user_info_21 (SAM_USER_INFO_21 *id21, uint32 rid) + +static BOOL api_samr_create_dom_group(pipes_struct *p) { - SAM_ACCOUNT *pwd = pdb_getsampwrid(rid); - SAM_ACCOUNT new_pwd; + SAMR_Q_CREATE_DOM_GROUP q_u; + SAMR_R_CREATE_DOM_GROUP r_u; - if (id21 == NULL) { - DEBUG(5, ("set_user_info_21: NULL id21\n")); - return False; - } + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - if (pwd == NULL) + if (!samr_io_q_create_dom_group("", &q_u, data, 0)) { 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 - */ + r_u.status = _samr_create_dom_group(p, &q_u, &r_u); - /* write the change out */ - if(!pdb_update_sam_account(&new_pwd, True)) + if (!samr_io_r_create_dom_group("", &r_u, rdata, 0)) { return False; - + } + return True; } /******************************************************************* - set_user_info_23 + api_samr_create_dom_alias ********************************************************************/ -static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) -{ - SAM_ACCOUNT *pwd = pdb_getsampwrid(rid); - SAM_ACCOUNT new_pwd; - BYTE nt_hash[16]; - BYTE lm_hash[16]; - pstring buf; - uint32 len; - if (id23 == NULL) { - DEBUG(5, ("set_user_info_23: NULL id23\n")); - return False; - } +static BOOL api_samr_create_dom_alias(pipes_struct *p) +{ + SAMR_Q_CREATE_DOM_ALIAS q_u; + SAMR_R_CREATE_DOM_ALIAS r_u; - if (pwd == NULL) - return False; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - copy_sam_passwd(&new_pwd, pwd); - copy_id23_to_sam_passwd(&new_pwd, id23); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - if (!decode_pw_buffer((char*)id23->pass, buf, 256, &len)) + if (!samr_io_q_create_dom_alias("", &q_u, data, 0)) { return False; + } - nt_lm_owf_gen(buf, nt_hash, lm_hash); - - pdb_set_lanman_passwd (&new_pwd, lm_hash); - pdb_set_nt_passwd (&new_pwd, nt_hash); - - /* update the UNIX password */ - if (lp_unix_password_sync()) - if(!chgpasswd(pdb_get_username(&new_pwd), "", buf, True)) - return False; - - memset(buf, 0, sizeof(buf)); + r_u.status = _samr_create_dom_alias(p, &q_u, &r_u); - if(!pdb_update_sam_account(&new_pwd, True)) + if (!samr_io_r_create_dom_alias("", &r_u, rdata, 0)) { return False; - + } + return True; } /******************************************************************* - set_user_info_24 + api_samr_query_groupinfo ********************************************************************/ -static BOOL set_user_info_24(const SAM_USER_INFO_24 *id24, uint32 rid) + +static BOOL api_samr_query_groupinfo(pipes_struct *p) { - SAM_ACCOUNT *pwd = pdb_getsampwrid(rid); - uchar nt_hash[16]; - uchar lm_hash[16]; - uint32 len; - pstring buf; + SAMR_Q_QUERY_GROUPINFO q_u; + SAMR_R_QUERY_GROUPINFO r_u; - if (pwd == NULL) - return False; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - memset(buf, 0, sizeof(buf)); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - if (!decode_pw_buffer((char*)id24->pass, buf, 256, &len)) + if (!samr_io_q_query_groupinfo("", &q_u, data, 0)) { return False; + } - DEBUG(0,("set_user_info_24:nt_lm_owf_gen\n")); - - nt_lm_owf_gen(buf, nt_hash, lm_hash); - - pdb_set_lanman_passwd (pwd, lm_hash); - pdb_set_nt_passwd (pwd, nt_hash); - - /* update the UNIX password */ - if (lp_unix_password_sync()) - if(!chgpasswd(pdb_get_username(pwd), "", buf, True)) - return False; - - memset(buf, 0, sizeof(buf)); - - DEBUG(0,("set_user_info_24: pdb_update_sam_account()\n")); + r_u.status = _samr_query_groupinfo(p, &q_u, &r_u); - /* update the SAMBA password */ - if(!pdb_update_sam_account(pwd, True)) + if (!samr_io_r_query_groupinfo("", &r_u, rdata, 0)) { return False; + } return True; } /******************************************************************* - samr_reply_set_userinfo + api_samr_set_groupinfo ********************************************************************/ -static uint32 _samr_set_userinfo(POLICY_HND *pol, uint16 switch_value, - SAM_USERINFO_CTR *ctr, pipes_struct *p) -{ - uint32 rid = 0x0; - DOM_SID sid; - struct current_user user; - SAM_ACCOUNT *sam_pass; - unsigned char sess_key[16]; - - DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); - - if (p->ntlmssp_auth_validated) - { - memcpy(&user, &p->pipe_user, sizeof(user)); - } - else - { - extern struct current_user current_user; - memcpy(&user, ¤t_user, sizeof(user)); - } - /* search for the handle */ - if (find_lsa_policy_by_hnd(pol) == -1) - return NT_STATUS_INVALID_HANDLE; - - /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(pol, &sid)) - return NT_STATUS_INVALID_HANDLE; +static BOOL api_samr_set_groupinfo(pipes_struct *p) +{ + SAMR_Q_SET_GROUPINFO q_u; + SAMR_R_SET_GROUPINFO r_u; - sid_split_rid(&sid, &rid); + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - DEBUG(5, ("_samr_set_userinfo: rid:0x%x, level:%d\n", rid, switch_value)); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - if (ctr == NULL) { - DEBUG(5, ("_samr_set_userinfo: NULL info level\n")); - return NT_STATUS_INVALID_INFO_CLASS; + if (!samr_io_q_set_groupinfo("", &q_u, data, 0)) { + return False; } + r_u.status = _samr_set_groupinfo(p, &q_u, &r_u); - /* - * 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" - * This "user session key" is in turn used to encrypt/decrypt the user's password. - */ - - become_root(); - sam_pass = pdb_getsampwuid(user.uid); - unbecome_root(); - if(sam_pass == NULL) { - DEBUG(0,("_samr_set_userinfo: Unable to get passdb entry for uid %u\n", - (unsigned int)pdb_get_uid(sam_pass) )); - return NT_STATUS_ACCESS_DENIED; - } - - memset(sess_key, '\0', 16); - mdfour(sess_key, pdb_get_nt_passwd(sam_pass), 16); - - /* ok! user info levels (lots: see MSDEV help), off we go... */ - switch (switch_value) { - case 0x12: - if (!set_user_info_12(ctr->info.id12, rid)) - return NT_STATUS_ACCESS_DENIED; - break; - - case 24: - SamOEMhash(ctr->info.id24->pass, sess_key, 1); - if (!set_user_info_24(ctr->info.id24, rid)) - return NT_STATUS_ACCESS_DENIED; - break; - - case 23: - SamOEMhash(ctr->info.id23->pass, sess_key, 1); - if (!set_user_info_23(ctr->info.id23, rid)) - return NT_STATUS_ACCESS_DENIED; - break; - - default: - return NT_STATUS_INVALID_INFO_CLASS; + if (!samr_io_r_set_groupinfo("", &r_u, rdata, 0)) { + return False; } - return NT_STATUS_NOPROBLEMO; + return True; } /******************************************************************* - api_samr_set_userinfo + api_samr_get_dom_pwinfo ********************************************************************/ -static BOOL api_samr_set_userinfo(pipes_struct *p) + +static BOOL api_samr_get_dom_pwinfo(pipes_struct *p) { - SAMR_Q_SET_USERINFO q_u; - SAMR_R_SET_USERINFO r_u; + SAMR_Q_GET_DOM_PWINFO q_u; + SAMR_R_GET_DOM_PWINFO r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - SAM_USERINFO_CTR ctr; - ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - q_u.ctr = &ctr; - - if (!samr_io_q_set_userinfo("", &q_u, data, 0)) { - DEBUG(0,("api_samr_set_userinfo: Unable to unmarshall SAMR_Q_SET_USERINFO.\n")); + if (!samr_io_q_get_dom_pwinfo("", &q_u, data, 0)) { return False; } - r_u.status = _samr_set_userinfo(&q_u.pol, q_u.switch_value, &ctr, p); + r_u.status = _samr_get_dom_pwinfo(p, &q_u, &r_u); - free_samr_q_set_userinfo(&q_u); - - if(!samr_io_r_set_userinfo("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_set_userinfo: Unable to marshall SAMR_R_SET_USERINFO.\n")); + if (!samr_io_r_get_dom_pwinfo("", &r_u, rdata, 0)) { return False; } @@ -2482,59 +1136,41 @@ static BOOL api_samr_set_userinfo(pipes_struct *p) } /******************************************************************* - samr_reply_set_userinfo2 + api_samr_open_group ********************************************************************/ -static uint32 _samr_set_userinfo2(POLICY_HND *pol, uint16 switch_value, SAM_USERINFO_CTR *ctr) -{ - DOM_SID sid; - uint32 rid = 0x0; - DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__)); - - /* search for the handle */ - if (find_lsa_policy_by_hnd(pol) == -1) - return NT_STATUS_INVALID_HANDLE; - - /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(pol, &sid)) - return NT_STATUS_INVALID_HANDLE; +static BOOL api_samr_open_group(pipes_struct *p) +{ + SAMR_Q_OPEN_GROUP q_u; + SAMR_R_OPEN_GROUP r_u; - sid_split_rid(&sid, &rid); + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; - DEBUG(5, ("samr_reply_set_userinfo2: rid:0x%x\n", rid)); + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); - if (ctr == NULL) { - DEBUG(5, ("samr_reply_set_userinfo2: NULL info level\n")); - return NT_STATUS_INVALID_INFO_CLASS; + if (!samr_io_q_open_group("", &q_u, data, 0)) { + return False; } - ctr->switch_value = switch_value; - - /* ok! user info levels (lots: see MSDEV help), off we go... */ - switch (switch_value) { - case 21: - if (!set_user_info_21(ctr->info.id21, rid)) - return NT_STATUS_ACCESS_DENIED; - break; - case 16: - if (!set_user_info_10(ctr->info.id10, rid)) - return NT_STATUS_ACCESS_DENIED; - break; - default: - return NT_STATUS_INVALID_INFO_CLASS; + r_u.status = _samr_open_group(p, &q_u, &r_u); + + if (!samr_io_r_open_group("", &r_u, rdata, 0)) { + return False; } - return NT_STATUS_NOPROBLEMO; + return True; } /******************************************************************* - api_samr_set_userinfo2 + api_samr_unknown_2d ********************************************************************/ -static BOOL api_samr_set_userinfo2(pipes_struct *p) + +static BOOL api_samr_unknown_2d(pipes_struct *p) { - SAMR_Q_SET_USERINFO2 q_u; - SAMR_R_SET_USERINFO2 r_u; - SAM_USERINFO_CTR ctr; + SAMR_Q_UNKNOWN_2D q_u; + SAMR_R_UNKNOWN_2D r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -2542,31 +1178,77 @@ static BOOL api_samr_set_userinfo2(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - q_u.ctr = &ctr; - - if (!samr_io_q_set_userinfo2("", &q_u, data, 0)) { - DEBUG(0,("api_samr_set_userinfo2: Unable to unmarshall SAMR_Q_SET_USERINFO2.\n")); + if (!samr_io_q_unknown_2d("", &q_u, data, 0)) { return False; } - r_u.status = _samr_set_userinfo2(&q_u.pol, q_u.switch_value, &ctr); - - free_samr_q_set_userinfo2(&q_u); + r_u.status = _samr_unknown_2d(p, &q_u, &r_u); - if(!samr_io_r_set_userinfo2("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_set_userinfo2: Unable to marshall SAMR_R_SET_USERINFO2.\n")); + if (!samr_io_r_unknown_2d("", &r_u, rdata, 0)) { return False; } return True; } - /******************************************************************* array of \PIPE\samr operations ********************************************************************/ + static struct api_struct api_samr_cmds [] = { + {"SAMR_CLOSE_HND", SAMR_CLOSE_HND, api_samr_close_hnd}, + {"SAMR_CONNECT", SAMR_CONNECT, api_samr_connect}, + {"SAMR_CONNECT_ANON", SAMR_CONNECT_ANON, api_samr_connect_anon}, + {"SAMR_ENUM_DOMAINS", SAMR_ENUM_DOMAINS, api_samr_enum_domains}, + {"SAMR_ENUM_DOM_USERS", SAMR_ENUM_DOM_USERS, api_samr_enum_dom_users}, + + {"SAMR_ENUM_DOM_GROUPS", SAMR_ENUM_DOM_GROUPS, api_samr_enum_dom_groups}, + {"SAMR_ENUM_DOM_ALIASES", SAMR_ENUM_DOM_ALIASES, api_samr_enum_dom_aliases}, + {"SAMR_QUERY_USERALIASES", SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, + {"SAMR_QUERY_ALIASMEM", SAMR_QUERY_ALIASMEM, api_samr_query_aliasmem}, + {"SAMR_QUERY_GROUPMEM", SAMR_QUERY_GROUPMEM, api_samr_query_groupmem}, + {"SAMR_ADD_ALIASMEM", SAMR_ADD_ALIASMEM, api_samr_add_aliasmem}, + {"SAMR_DEL_ALIASMEM", SAMR_DEL_ALIASMEM, api_samr_del_aliasmem}, + {"SAMR_ADD_GROUPMEM", SAMR_ADD_GROUPMEM, api_samr_add_groupmem}, + {"SAMR_DEL_GROUPMEM", SAMR_DEL_GROUPMEM, api_samr_del_groupmem}, + + {"SAMR_DELETE_DOM_USER", SAMR_DELETE_DOM_USER, api_samr_delete_dom_user}, + {"SAMR_DELETE_DOM_GROUP", SAMR_DELETE_DOM_GROUP, api_samr_delete_dom_group}, + {"SAMR_DELETE_DOM_ALIAS", SAMR_DELETE_DOM_ALIAS, api_samr_delete_dom_alias}, + {"SAMR_CREATE_DOM_GROUP", SAMR_CREATE_DOM_GROUP, api_samr_create_dom_group}, + {"SAMR_CREATE_DOM_ALIAS", SAMR_CREATE_DOM_ALIAS, api_samr_create_dom_alias}, + {"SAMR_LOOKUP_NAMES", SAMR_LOOKUP_NAMES, api_samr_lookup_names}, + {"SAMR_OPEN_USER", SAMR_OPEN_USER, api_samr_open_user}, + {"SAMR_QUERY_USERINFO", SAMR_QUERY_USERINFO, api_samr_query_userinfo}, + {"SAMR_SET_USERINFO", SAMR_SET_USERINFO, api_samr_set_userinfo}, + {"SAMR_SET_USERINFO2", SAMR_SET_USERINFO2, api_samr_set_userinfo2}, + + {"SAMR_QUERY_DOMAIN_INFO", SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info}, + {"SAMR_QUERY_USERGROUPS", SAMR_QUERY_USERGROUPS, api_samr_query_usergroups}, + {"SAMR_QUERY_DISPINFO", SAMR_QUERY_DISPINFO, api_samr_query_dispinfo}, + {"SAMR_QUERY_DISPINFO3", SAMR_QUERY_DISPINFO3, api_samr_query_dispinfo}, + {"SAMR_QUERY_DISPINFO4", SAMR_QUERY_DISPINFO4, api_samr_query_dispinfo}, + + {"SAMR_QUERY_ALIASINFO", SAMR_QUERY_ALIASINFO, api_samr_query_aliasinfo}, + {"SAMR_QUERY_GROUPINFO", SAMR_QUERY_GROUPINFO, api_samr_query_groupinfo}, + {"SAMR_SET_GROUPINFO", SAMR_SET_GROUPINFO, api_samr_set_groupinfo}, + {"SAMR_CREATE_USER", SAMR_CREATE_USER, api_samr_create_user}, + {"SAMR_LOOKUP_RIDS", SAMR_LOOKUP_RIDS, api_samr_lookup_rids}, + {"SAMR_GET_DOM_PWINFO", SAMR_GET_DOM_PWINFO, api_samr_get_dom_pwinfo}, + {"SAMR_CHGPASSWD_USER", SAMR_CHGPASSWD_USER, api_samr_chgpasswd_user}, + {"SAMR_OPEN_ALIAS", SAMR_OPEN_ALIAS, api_samr_open_alias}, + {"SAMR_OPEN_GROUP", SAMR_OPEN_GROUP, api_samr_open_group}, + {"SAMR_OPEN_DOMAIN", SAMR_OPEN_DOMAIN, api_samr_open_domain}, + {"SAMR_UNKNOWN_2D", SAMR_UNKNOWN_2D, api_samr_unknown_2d}, + {"SAMR_LOOKUP_DOMAIN", SAMR_LOOKUP_DOMAIN, api_samr_lookup_domain}, + + {"SAMR_QUERY_SEC_OBJECT", SAMR_QUERY_SEC_OBJECT, api_samr_query_sec_obj}, + {"SAMR_GET_USRDOM_PWINFO", SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, + {NULL, 0, NULL} + +#if 0 + { "SAMR_CLOSE_HND" , SAMR_CLOSE_HND , api_samr_close_hnd }, { "SAMR_CONNECT" , SAMR_CONNECT , api_samr_connect }, { "SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon }, @@ -2587,13 +1269,14 @@ static struct api_struct api_samr_cmds [] = { "SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, { "SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, { "SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, - { "SAMR_UNKNOWN_3" , SAMR_UNKNOWN_3 , api_samr_unknown_3 }, - { "SAMR_UNKNOWN_2C" , SAMR_UNKNOWN_2C , api_samr_unknown_2c }, + { "SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, + { "SAMR_GET_USRDOM_PWINFO", SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, { "SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, { "SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains }, { "SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo }, { "SAMR_SET_USERINFO2" , SAMR_SET_USERINFO2 , api_samr_set_userinfo2 }, { NULL , 0 , NULL } +#endif }; /******************************************************************* @@ -2603,4 +1286,3 @@ BOOL api_samr_rpc(pipes_struct *p) { return api_rpcTNP(p, "api_samr_rpc", api_samr_cmds); } -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index bd04b40c4d..ff484a8ff1 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -39,6 +39,23 @@ extern rid_name domain_group_rids[]; extern rid_name domain_alias_rids[]; extern rid_name builtin_alias_rids[]; +struct samr_info { + /* for use by the \PIPE\samr policy */ + DOM_SID sid; + uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ +}; + +/******************************************************************* + Function to free the per handle data. + ********************************************************************/ + +static void free_samr_info(void *ptr) +{ + struct samr_info *samr = (struct samr_info *)ptr; + + safe_free(samr); +} + /******************************************************************* This next function should be replaced with something that dynamically returns the correct user info..... JRA. @@ -48,8 +65,7 @@ static BOOL 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; (*num_entries) = 0; (*total_entries) = 0; @@ -57,13 +73,12 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, if (pw_buf == NULL) return False; - vp = startsmbpwent(False); - if (!vp) { - DEBUG(0, ("get_sampwd_entries: Unable to open SMB password database.\n")); + if (!pdb_setsampwent(False)) { + DEBUG(0, ("get_sampwd_entries: Unable to open passdb.\n")); return False; } - while (((pwd = getsam21pwent(vp)) != NULL) && (*num_entries) < max_num_entries) { + while (((pwd = pdb_getsampwent()) != NULL) && (*num_entries) < max_num_entries) { int user_name_len; if (start_idx > 0) { @@ -74,21 +89,20 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int 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); + 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); - } + 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)); + (*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)); @@ -100,17 +114,16 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, (*total_entries)++; } - endsmbpwent(vp); + pdb_endsampwent(); return (*num_entries) > 0; } static BOOL jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, - int *total_entries, int *num_entries, + 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; *num_entries = 0; *total_entries = 0; @@ -118,17 +131,16 @@ static BOOL jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, if (pw_buf == NULL) return False; - vp = startsmbpwent(False); - if (!vp) { - DEBUG(0, ("get_sampwd_entries: Unable to open SMB password database.\n")); - return False; - } + if (!pdb_setsampwent(False)) { + DEBUG(0, ("jf_get_sampwd_entries: Unable to open passdb.\n")); + return False; + } - while (((pwd = getsam21pwent(vp)) != NULL) && (*num_entries) < max_num_entries) { + while (((pwd = pdb_getsampwent()) != NULL) && (*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)) continue; if (start_idx > 0) { @@ -141,29 +153,29 @@ static BOOL jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, 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 = (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\n", (*num_entries), pwd->smb_name, pwd->user_rid, 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) )); (*num_entries)++; } - endsmbpwent(vp); + pdb_endsampwent(); *total_entries = *num_entries; return True; @@ -425,7 +437,7 @@ uint32 _samr_close_hnd(pipes_struct *p, SAMR_Q_CLOSE_HND *q_u, SAMR_R_CLOSE_HND r_u->status = NT_STATUS_NOPROBLEMO; /* close the policy handle */ - if (!close_lsa_policy_hnd(&q_u->pol)) + if (!close_policy_hnd(p, &q_u->pol)) return NT_STATUS_OBJECT_NAME_INVALID; DEBUG(5,("samr_reply_close_hnd: %d\n", __LINE__)); @@ -439,42 +451,57 @@ uint32 _samr_close_hnd(pipes_struct *p, SAMR_Q_CLOSE_HND *q_u, SAMR_R_CLOSE_HND uint32 _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN_DOMAIN *r_u) { + struct samr_info *info; + r_u->status = NT_STATUS_NOPROBLEMO; /* find the connection policy handle. */ - if (find_lsa_policy_by_hnd(&q_u->pol) == -1) + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) return NT_STATUS_INVALID_HANDLE; - /* get a (unique) handle. open a policy on it. */ - if (!open_lsa_policy_hnd(&r_u->domain_pol)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - /* associate the domain SID with the (unique) handle. */ - if (!set_lsa_policy_samr_sid(&r_u->domain_pol, &q_u->dom_sid.sid)) { - close_lsa_policy_hnd(&r_u->domain_pol); + if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(info); + info->sid = q_u->dom_sid.sid; + + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->domain_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - } DEBUG(5,("samr_open_domain: %d\n", __LINE__)); return r_u->status; } +static uint32 get_lsa_policy_samr_rid(struct samr_info *info) +{ + if (!info) { + DEBUG(3,("Error getting policy\n")); + return 0xffffffff; + } + + return info->sid.sub_auths[info->sid.num_auths-1]; +} + /******************************************************************* _samr_get_usrdom_pwinfo ********************************************************************/ uint32 _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, SAMR_R_GET_USRDOM_PWINFO *r_u) { + struct samr_info *info = NULL; + r_u->status = NT_STATUS_NOPROBLEMO; /* find the policy handle. open a policy on it. */ - if (find_lsa_policy_by_hnd(&q_u->user_pol) == -1) { + if (!find_policy_by_hnd(p, &q_u->user_pol, (void **)&info)) { return NT_STATUS_INVALID_HANDLE; } /* find the user's rid */ - if (get_lsa_policy_samr_rid(&q_u->user_pol) == 0xffffffff) { + if (get_lsa_policy_samr_rid(info) == 0xffffffff) { return NT_STATUS_OBJECT_TYPE_MISMATCH; } @@ -531,6 +558,21 @@ static uint32 samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC_BUF **buf, DOM_SID return NT_STATUS_NOPROBLEMO; } +static BOOL get_lsa_policy_samr_sid(pipes_struct *p, POLICY_HND *pol, DOM_SID *sid) +{ + struct samr_info *info = NULL; + + /* find the policy handle. open a policy on it. */ + if (!find_policy_by_hnd(p, pol, (void **)&info)) + return False; + + if (!info) + return False; + + *sid = info->sid; + return True; +} + /******************************************************************* _samr_query_sec_obj ********************************************************************/ @@ -541,13 +583,10 @@ uint32 _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_QU r_u->status = NT_STATUS_NOPROBLEMO; - /* find the policy handle. open a policy on it. */ - if ((find_lsa_policy_by_hnd(&q_u->user_pol)) == -1) - return NT_STATUS_INVALID_HANDLE; - /* Get the SID. */ - if (!get_lsa_policy_samr_sid(&q_u->user_pol, &pol_sid)) - return NT_STATUS_OBJECT_TYPE_MISMATCH; + + if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &pol_sid)) + return NT_STATUS_INVALID_HANDLE; r_u->status = samr_make_usr_obj_sd(p->mem_ctx, &r_u->buf, &pol_sid); @@ -608,7 +647,7 @@ uint32 _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_R_ r_u->status = NT_STATUS_NOPROBLEMO; /* find the policy handle. open a policy on it. */ - if (find_lsa_policy_by_hnd(&q_u->pol) == -1) + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) return NT_STATUS_INVALID_HANDLE; DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); @@ -808,12 +847,12 @@ static BOOL get_group_domain_entries(DOMAIN_GRP *d_grp, DOM_SID *sid, uint32 sta uint32 _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_R_ENUM_DOM_GROUPS *r_u) { DOMAIN_GRP grp[2]; - int num_entries; + uint32 num_entries; DOM_SID sid; r_u->status = NT_STATUS_NOPROBLEMO; - if (!get_lsa_policy_samr_sid(&q_u->pol, &sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid)) return NT_STATUS_INVALID_HANDLE; DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); @@ -837,14 +876,13 @@ uint32 _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_ uint32 _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, SAMR_R_ENUM_DOM_ALIASES *r_u) { DOMAIN_GRP grp[MAX_SAM_ENTRIES]; - int num_entries = 0; + uint32 num_entries = 0; fstring sid_str; DOM_SID sid; r_u->status = NT_STATUS_NOPROBLEMO; - /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(&q_u->pol, &sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid)) return NT_STATUS_INVALID_HANDLE; sid_to_string(sid_str, &sid); @@ -871,7 +909,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; DOMAIN_GRP grps[MAX_SAM_ENTRIES]; uint16 acb_mask = ACB_NORMAL; - int num_entries = 0; + uint32 num_entries = 0; int orig_num_entries = 0; int total_entries = 0; uint32 data_size = 0; @@ -883,7 +921,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ r_u->status = NT_STATUS_NOPROBLEMO; - if (!get_lsa_policy_samr_sid(&q_u->domain_pol, &sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid)) return NT_STATUS_INVALID_HANDLE; /* decide how many entries to get depending on the max_entries @@ -994,21 +1032,22 @@ uint32 _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_ fstring alias=""; enum SID_NAME_USE type; uint32 alias_rid; + struct samr_info *info = NULL; r_u->status = NT_STATUS_NOPROBLEMO; DEBUG(5,("_samr_query_aliasinfo: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (find_lsa_policy_by_hnd(&q_u->pol) == -1) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - alias_rid = get_lsa_policy_samr_rid(&q_u->pol); + alias_rid = get_lsa_policy_samr_rid(info); if(alias_rid == 0xffffffff) return NT_STATUS_NO_SUCH_ALIAS; if(!local_lookup_rid(alias_rid, alias, &type)) - return NT_STATUS_NO_SUCH_ALIAS; + return NT_STATUS_NO_SUCH_ALIAS; switch (q_u->switch_level) { case 3: @@ -1104,7 +1143,7 @@ uint32 _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOK ZERO_ARRAY(rid); ZERO_ARRAY(type); - if (!get_lsa_policy_samr_sid(&q_u->pol, &pol_sid)) { + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid)) { init_samr_r_lookup_names(p->mem_ctx, r_u, 0, NULL, NULL, NT_STATUS_OBJECT_TYPE_MISMATCH); return r_u->status; } @@ -1135,7 +1174,7 @@ uint32 _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOK } } - init_samr_r_lookup_names(p->mem_ctx, r_u, num_rids, rid, type, r_u->status); + init_samr_r_lookup_names(p->mem_ctx, r_u, num_rids, rid, (uint32 *)type, r_u->status); DEBUG(5,("_samr_lookup_names: %d\n", __LINE__)); @@ -1227,7 +1266,7 @@ uint32 _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP DEBUG(5,("_samr_lookup_rids: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(&q_u->pol, &pol_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid)) return NT_STATUS_INVALID_HANDLE; if (num_rids > MAX_SAM_ENTRIES) { @@ -1274,50 +1313,45 @@ 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; + SAM_ACCOUNT *sampass; 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; r_u->status = NT_STATUS_NO_PROBLEMO; /* find the domain policy handle. */ - if (find_lsa_policy_by_hnd(&domain_pol) == -1) + if (!find_policy_by_hnd(p, &domain_pol, NULL)) return NT_STATUS_INVALID_HANDLE; - /* get a (unique) handle. open a policy on it. */ - if (!open_lsa_policy_hnd(user_pol)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - become_root(); - sam_pass = getsam21pwrid(user_rid); + sampass = pdb_getsampwrid(user_rid); unbecome_root(); /* check that the RID exists in our domain. */ - if (sam_pass == NULL) { - close_lsa_policy_hnd(user_pol); + if (sampass == NULL) return NT_STATUS_NO_SUCH_USER; - } /* Get the domain SID stored in the domain policy */ - if(!get_lsa_policy_samr_sid(&domain_pol, &sid)) { - close_lsa_policy_hnd(user_pol); + if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid)) return NT_STATUS_INVALID_HANDLE; - } /* append the user's RID to it */ - if(!sid_append_rid(&sid, user_rid)) { - close_lsa_policy_hnd(user_pol); + if(!sid_append_rid(&sid, user_rid)) return NT_STATUS_NO_SUCH_USER; - } - /* associate the user's SID with the handle. */ - if (!set_lsa_policy_samr_sid(user_pol, &sid)) { - /* oh, whoops. don't know what error message to return, here */ - close_lsa_policy_hnd(user_pol); + /* 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; + + 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)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - } return r_u->status; } @@ -1328,7 +1362,7 @@ 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; if (!pdb_rid_is_user(user_rid)) { DEBUG(4,("RID 0x%x is not a user RID\n", user_rid)); @@ -1336,18 +1370,17 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) } become_root(); - smb_pass = getsmbpwrid(user_rid); + smbpass = pdb_getsampwrid(user_rid); unbecome_root(); - if (smb_pass == NULL) - { + if (smbpass == NULL) { DEBUG(4,("User 0x%x not found\n", user_rid)); return False; } - DEBUG(3,("User:[%s]\n", smb_pass->smb_name)); + DEBUG(3,("User:[%s]\n", pdb_get_username(smbpass) )); - init_sam_user_info10(id10, smb_pass->acct_ctrl); + init_sam_user_info10(id10, pdb_get_acct_ctrl(smbpass) ); return True; } @@ -1358,23 +1391,23 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) static BOOL get_user_info_12(SAM_USER_INFO_12 * id12, uint32 user_rid) { - struct smb_passwd *smb_pass; + SAM_ACCOUNT *smbpass; become_root(); - smb_pass = getsmbpwrid(user_rid); + smbpass = pdb_getsampwrid(user_rid); unbecome_root(); - if (smb_pass == NULL) { + if (smbpass == NULL) { DEBUG(4, ("User 0x%x not found\n", user_rid)); return False; } - 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) + if ( pdb_get_acct_ctrl(smbpass) & ACB_DISABLED) return False; - init_sam_user_info12(id12, smb_pass->smb_passwd, smb_pass->smb_nt_passwd); + init_sam_user_info12(id12, pdb_get_lanman_passwd(smbpass), pdb_get_nt_passwd(smbpass)); return True; } @@ -1385,10 +1418,7 @@ static BOOL get_user_info_12(SAM_USER_INFO_12 * id12, uint32 user_rid) static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) { - NTTIME dummy_time; - struct sam_passwd *sam_pass; - LOGON_HRS hrs; - int i; + SAM_ACCOUNT *sampass; if (!pdb_rid_is_user(user_rid)) { DEBUG(4,("RID 0x%x is not a user RID\n", user_rid)); @@ -1396,56 +1426,17 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) } become_root(); - sam_pass = getsam21pwrid(user_rid); + sampass = pdb_getsampwrid(user_rid); unbecome_root(); - if (sam_pass == NULL) { + if (sampass == NULL) { DEBUG(4,("User 0x%x not found\n", user_rid)); return False; } - DEBUG(3,("User:[%s]\n", sam_pass->smb_name)); - - dummy_time.low = 0xffffffff; - dummy_time.high = 0x7fffffff; - - DEBUG(5,("get_user_info_21 - TODO: convert unix times to NTTIMEs\n")); - - /* 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]; - - init_sam_user_info21A(id21, - - &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 */ - - 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 */ - - sam_pass->user_rid, /* RID user_id */ - sam_pass->group_rid, /* RID group_id */ - sam_pass->acct_ctrl, - - sam_pass->unknown_3, /* unknown_3 */ - sam_pass->logon_divs, /* divisions per week */ - &hrs, /* logon hours */ - sam_pass->unknown_5, - sam_pass->unknown_6); + DEBUG(3,("User:[%s]\n", pdb_get_username(sampass) )); + + init_sam_user_info21A(id21, sampass); return True; } @@ -1458,15 +1449,16 @@ uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_ { SAM_USERINFO_CTR *ctr; uint32 rid = 0; + struct samr_info *info = NULL; r_u->status=NT_STATUS_NO_PROBLEMO; /* search for the handle */ - if (find_lsa_policy_by_hnd(&q_u->pol) == -1) + 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(&q_u->pol)) == 0xffffffff) + if ((rid = get_lsa_policy_samr_rid(info)) == 0xffffffff) return NT_STATUS_OBJECT_TYPE_MISMATCH; DEBUG(5,("_samr_query_userinfo: rid:0x%x\n", rid)); @@ -1554,27 +1546,28 @@ uint32 _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAM int num_groups = 0; pstring groups; uint32 rid; + struct samr_info *info = NULL; r_u->status = NT_STATUS_NO_PROBLEMO; DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (find_lsa_policy_by_hnd(&q_u->pol) == -1) + 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(&q_u->pol)) == 0xffffffff) + if ((rid = get_lsa_policy_samr_rid(info)) == 0xffffffff) return NT_STATUS_OBJECT_TYPE_MISMATCH; become_root(); - sam_pass = getsam21pwrid(rid); + sam_pass = pdb_getsampwrid(rid); unbecome_root(); if (sam_pass == NULL) return NT_STATUS_NO_SUCH_USER; - get_domain_user_groups(groups, sam_pass->smb_name); + get_domain_user_groups(groups, pdb_get_username(sam_pass)); gids = NULL; num_groups = make_dom_gids(p->mem_ctx, groups, &gids); @@ -1593,7 +1586,6 @@ uint32 _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAM uint32 _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR_R_QUERY_DOMAIN_INFO *r_u) { SAM_UNK_CTR *ctr; - uint16 switch_value = 0; if ((ctr = (SAM_UNK_CTR *)talloc(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL) return NT_STATUS_NO_MEMORY; @@ -1605,38 +1597,31 @@ uint32 _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (find_lsa_policy_by_hnd(&q_u->domain_pol) == -1) + if (!find_policy_by_hnd(p, &q_u->domain_pol, NULL)) return NT_STATUS_INVALID_HANDLE; switch (q_u->switch_value) { case 0x01: - switch_value = 0x1; init_unk_info1(&ctr->info.inf1); break; case 0x02: - switch_value = 0x2; /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL)); break; case 0x03: - switch_value = 0x3; init_unk_info3(&ctr->info.inf3); break; case 0x06: - switch_value = 0x6; init_unk_info6(&ctr->info.inf6); break; case 0x07: - switch_value = 0x7; init_unk_info7(&ctr->info.inf7); break; case 0x0c: - switch_value = 0xc; init_unk_info12(&ctr->info.inf12); break; default: return NT_STATUS_INVALID_INFO_CLASS; - break; } init_samr_r_query_dom_info(r_u, q_u->switch_value, ctr, NT_STATUS_NOPROBLEMO); @@ -1652,7 +1637,7 @@ 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; + SAM_ACCOUNT *sam_pass; fstring mach_acct; pstring err_str; pstring msg_str; @@ -1663,9 +1648,10 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR 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; /* find the policy handle. open a policy on it. */ - if (find_lsa_policy_by_hnd(&dom_pol) == -1) + if (!find_policy_by_hnd(p, &dom_pol, NULL)) return NT_STATUS_INVALID_HANDLE; /* find the machine account: tell the caller if it exists. @@ -1678,17 +1664,13 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR strlower(mach_acct); become_root(); - sam_pass = getsam21pwnam(mach_acct); + sam_pass = pdb_getsampwnam(mach_acct); unbecome_root(); if (sam_pass != NULL) { /* machine account exists: say so */ return NT_STATUS_USER_EXISTS; } - /* get a (unique) handle. open a policy on it. */ - if (!open_lsa_policy_hnd(user_pol)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - local_flags=LOCAL_ADD_USER|LOCAL_DISABLE_USER|LOCAL_SET_NO_PASSWORD; local_flags|= (acb_info & ACB_WSTRUST) ? LOCAL_TRUST_ACCOUNT:0; @@ -1720,37 +1702,41 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR sizeof(err_str), msg_str, sizeof(msg_str))) { DEBUG(0, ("%s\n", err_str)); - close_lsa_policy_hnd(user_pol); + close_policy_hnd(p, user_pol); return NT_STATUS_ACCESS_DENIED; } become_root(); - sam_pass = getsam21pwnam(mach_acct); + sam_pass = pdb_getsampwnam(mach_acct); unbecome_root(); if (sam_pass == NULL) { /* account doesn't exist: say so */ - close_lsa_policy_hnd(user_pol); + close_policy_hnd(p, user_pol); return NT_STATUS_ACCESS_DENIED; } /* Get the domain SID stored in the domain policy */ - if(!get_lsa_policy_samr_sid(&dom_pol, &sid)) { - close_lsa_policy_hnd(user_pol); + if(!get_lsa_policy_samr_sid(p, &dom_pol, &sid)) { + close_policy_hnd(p, user_pol); return NT_STATUS_INVALID_HANDLE; } /* append the user's RID to it */ - if(!sid_append_rid(&sid, sam_pass->user_rid)) { - close_lsa_policy_hnd(user_pol); + if(!sid_append_rid(&sid, pdb_get_user_rid(sam_pass) )) { + close_policy_hnd(p, user_pol); return NT_STATUS_NO_SUCH_USER; } - /* associate the SID with the (unique) handle. */ - if (!set_lsa_policy_samr_sid(user_pol, &sid)) { - /* oh, whoops. don't know what error message to return, here */ - close_lsa_policy_hnd(user_pol); + /* 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; + + 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)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - } r_u->user_rid=sam_pass->user_rid; r_u->unknown_0 = 0x000703ff; @@ -1764,19 +1750,22 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR uint32 _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CONNECT_ANON *r_u) { + struct samr_info *info = NULL; + /* set up the SAMR connect_anon response */ r_u->status = NT_STATUS_NO_PROBLEMO; - /* get a (unique) handle. open a policy on it. */ - if (!open_lsa_policy_hnd(&r_u->connect_pol)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; + /* 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; + + ZERO_STRUCTP(info); + info->status = q_u->unknown_0; - /* associate the domain SID with the (unique) handle. */ - if (!set_lsa_policy_samr_pol_status(&r_u->connect_pol, q_u->unknown_0)) { - close_lsa_policy_hnd(&r_u->connect_pol); + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - } return r_u->status; } @@ -1787,19 +1776,22 @@ uint32 _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CONN uint32 _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u) { + struct samr_info *info = NULL; + DEBUG(5,("_samr_connect: %d\n", __LINE__)); r_u->status = NT_STATUS_NO_PROBLEMO; - /* get a (unique) handle. open a policy on it. */ - if (!open_lsa_policy_hnd(&r_u->connect_pol)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; + /* 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; + + ZERO_STRUCTP(info); + info->status = q_u->access_mask; - /* associate the domain SID with the (unique) handle. */ - if (!set_lsa_policy_samr_pol_status(&r_u->connect_pol, q_u->access_mask)) { - close_lsa_policy_hnd(&r_u->connect_pol); + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - } DEBUG(5,("_samr_connect: %d\n", __LINE__)); @@ -1814,7 +1806,7 @@ uint32 _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_LO { r_u->status = NT_STATUS_NO_PROBLEMO; - if (find_lsa_policy_by_hnd(&q_u->connect_pol) == -1) + if (!find_policy_by_hnd(p, &q_u->connect_pol, NULL)) return NT_STATUS_INVALID_HANDLE; /* assume the domain name sent is our global_myname and @@ -1894,41 +1886,37 @@ uint32 _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN POLICY_HND domain_pol = q_u->dom_pol; uint32 alias_rid = q_u->rid_alias; POLICY_HND *alias_pol = &r_u->pol; + struct samr_info *info = NULL; r_u->status = NT_STATUS_NO_PROBLEMO; /* get the domain policy. */ - if (find_lsa_policy_by_hnd(&domain_pol) == -1) + if (!find_policy_by_hnd(p, &domain_pol, NULL)) return NT_STATUS_INVALID_HANDLE; - /* get a (unique) handle. open a policy on it. */ - if (!open_lsa_policy_hnd(alias_pol)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - /* Get the domain SID stored in the domain policy */ - if(!get_lsa_policy_samr_sid(&domain_pol, &sid)) { - close_lsa_policy_hnd(alias_pol); + if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid)) return NT_STATUS_INVALID_HANDLE; - } + + /* append the alias' RID to it */ + if(!sid_append_rid(&sid, alias_rid)) + return NT_STATUS_NO_SUCH_USER; /* * we should check if the rid really exist !!! * JFM. */ + /* 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 alias' RID to it */ - if(!sid_append_rid(&sid, alias_rid)) { - close_lsa_policy_hnd(alias_pol); - return NT_STATUS_NO_SUCH_USER; - } + ZERO_STRUCTP(info); + info->sid = sid; - /* associate a SID with the (unique) handle. */ - if (!set_lsa_policy_samr_sid(alias_pol, &sid)) { - /* oh, whoops. don't know what error message to return, here */ - close_lsa_policy_hnd(alias_pol); + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, alias_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - } return r_u->status; } @@ -1939,22 +1927,20 @@ 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 = pdb_getsampwrid(rid); if (id10 == NULL) { DEBUG(5, ("set_user_info_10: NULL id10\n")); return False; } - if (pwd == NULL) + pwd = pdb_getsampwrid(rid); + if (!pwd) 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)) return False; return True; @@ -1966,31 +1952,22 @@ 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 = pdb_getsampwrid(rid); + if (pwd == NULL) return False; - + if (id12 == NULL) { DEBUG(2, ("set_user_info_12: id12 is NULL\n")); 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)) + + pdb_set_lanman_passwd (pwd, id12->lm_pwd); + pdb_set_nt_passwd (pwd, id12->nt_pwd); + + if(!pdb_update_sam_account(pwd, True)) return False; - + return True; } @@ -1998,41 +1975,34 @@ static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, uint32 rid) set_user_info_21 ********************************************************************/ -static BOOL set_user_info_21 (SAM_USER_INFO_21 *id21, 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 = pdb_getsampwrid(rid); + SAM_ACCOUNT new_pwd; + if (id21 == NULL) { DEBUG(5, ("set_user_info_21: NULL id21\n")); return False; } - + if (pwd == NULL) return False; - - pdb_init_sam(&new_pwd); - /* we make a copy so that we can modify stuff */ + + /* 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)) + + /* + * 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)) return False; - + return True; } @@ -2042,52 +2012,54 @@ 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]; - pstring buf; - uint32 len; - - if (id23 == NULL) { - DEBUG(5, ("set_user_info_23: NULL id23\n")); - return False; - } - - if (pwd == NULL) - return False; - - 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)) - return False; - - new_pwd.smb_passwd = lm_hash; - new_pwd.smb_nt_passwd = nt_hash; + SAM_ACCOUNT *pwd = pdb_getsampwrid(rid); + SAM_ACCOUNT new_pwd; + BYTE nt_hash[16]; + BYTE 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; + + acct_ctrl = pdb_get_acct_ctrl(pwd); + copy_sam_passwd(&new_pwd, pwd); + copy_id23_to_sam_passwd(&new_pwd, id23); + + if (!decode_pw_buffer((char*)id23->pass, buf, 256, &len)) + return False; + + nt_lm_owf_gen(buf, nt_hash, lm_hash); + + pdb_set_lanman_passwd (&new_pwd, lm_hash); + pdb_set_nt_passwd (&new_pwd, nt_hash); + /* 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 */ /* 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)) return False; } - - memset(buf, 0, sizeof(buf)); - - if(!mod_sam21pwd_entry(&new_pwd, True)) - return False; - - return True; + + memset(buf, 0, sizeof(buf)); + + if(!pdb_update_sam_account(&new_pwd, True)) + return False; + + return True; } /******************************************************************* @@ -2096,49 +2068,51 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, 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 = pdb_getsampwrid(rid); + uchar nt_hash[16]; + uchar lm_hash[16]; uint32 len; pstring buf; - + uint16 acct_ctrl; + if (pwd == NULL) 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((char*)id24->pass, buf, 256, &len, nt_hash, lm_hash)) + memset(buf, 0, sizeof(buf)); + + if (!decode_pw_buffer((char*)id24->pass, buf, 256, &len)) return False; - - new_pwd.smb_passwd = lm_hash; - new_pwd.smb_nt_passwd = nt_hash; - + + DEBUG(5,("set_user_info_24:nt_lm_owf_gen\n")); + + nt_lm_owf_gen(buf, nt_hash, lm_hash); + + pdb_set_lanman_passwd (pwd, lm_hash); + pdb_set_nt_passwd (pwd, nt_hash); + /* 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)) return False; } - - memset(buf, 0, sizeof(buf)); - - DEBUG(5,("set_user_info_24: pdb_update_sam_account()\n")); - - /* update the SAMBA password */ - if(!mod_sam21pwd_entry(&new_pwd, True)) - return False; - - return True; + + memset(buf, 0, sizeof(buf)); + + DEBUG(0,("set_user_info_24: pdb_update_sam_account()\n")); + + /* update the SAMBA password */ + if(!pdb_update_sam_account(pwd, True)) + return False; + + return True; } /******************************************************************* @@ -2150,7 +2124,7 @@ 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; unsigned char sess_key[16]; POLICY_HND *pol = &q_u->pol; uint16 switch_value = q_u->switch_value; @@ -2167,12 +2141,8 @@ uint32 _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_ memcpy(&user, ¤t_user, sizeof(user)); } - /* search for the handle */ - if (find_lsa_policy_by_hnd(pol) == -1) - return NT_STATUS_INVALID_HANDLE; - /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(pol, &sid)) + if (!get_lsa_policy_samr_sid(p, pol, &sid)) return NT_STATUS_INVALID_HANDLE; sid_split_rid(&sid, &rid); @@ -2192,15 +2162,15 @@ uint32 _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_ */ become_root(); - smb_pass = getsmbpwuid(user.uid); + sam_pass = pdb_getsampwuid(user.uid); unbecome_root(); - if(smb_pass == NULL) { + if(sam_pass == NULL) { DEBUG(0,("_samr_set_userinfo: Unable to get smbpasswd 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); /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { @@ -2236,7 +2206,7 @@ uint32 _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SE { DOM_SID sid; uint32 rid = 0x0; - SAM_USERINFO_CTR *ctr = NULL; + SAM_USERINFO_CTR *ctr = q_u->ctr; POLICY_HND *pol = &q_u->pol; uint16 switch_value = q_u->switch_value; @@ -2244,18 +2214,8 @@ uint32 _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SE r_u->status = NT_STATUS_NOPROBLEMO; - ctr = (SAM_USERINFO_CTR *)talloc(p->mem_ctx, sizeof(SAM_USERINFO_CTR)); - if (!ctr) - return NT_STATUS_NO_MEMORY; - - q_u->ctr = ctr; - - /* search for the handle */ - if (find_lsa_policy_by_hnd(pol) == -1) - return NT_STATUS_INVALID_HANDLE; - /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(pol, &sid)) + if (!get_lsa_policy_samr_sid(p, pol, &sid)) return NT_STATUS_INVALID_HANDLE; sid_split_rid(&sid, &rid); @@ -2267,7 +2227,7 @@ uint32 _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SE return NT_STATUS_INVALID_INFO_CLASS; } - ctr->switch_value = switch_value; + switch_value=ctr->switch_value; /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 0cb72232f2..126581ba80 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1,4 +1,3 @@ -#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -249,7 +248,11 @@ static BOOL api_spoolss_rffpcnex(pipes_struct *p) * api_spoolss_rfnpcnex * ReplyFindNextPrinterChangeNotifyEx * called from the spoolss dispatcher - * + + * Note - this is the *ONLY* function that breaks the RPC call + * symmetry in all the other calls. We need to do this to fix + * the massive memory allocation problem with thousands of jobs... + * JRA. ********************************************************************/ static BOOL api_spoolss_rfnpcnex(pipes_struct *p) @@ -1188,5 +1191,3 @@ BOOL api_spoolss_rpc(pipes_struct *p) { return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds); } - -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0fb38b84db..9fcf9930bf 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1,4 +1,3 @@ -#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -40,14 +39,9 @@ extern pstring global_myname; /* and the notify info asked about */ /* that's the central struct */ typedef struct _Printer{ - ubi_dlNode Next; - ubi_dlNode Prev; - - BOOL open; BOOL document_started; BOOL page_started; int jobid; /* jobid in printing backend */ - POLICY_HND printer_hnd; BOOL printer_type; union { fstring handlename; @@ -78,14 +72,12 @@ typedef struct _counter_printer_0 { uint32 counter; } counter_printer_0; -static ubi_dlList Printer_list; static ubi_dlList counter_list; static struct cli_state cli; static uint32 smb_connections=0; -#define OPEN_HANDLE(pnum) ((pnum!=NULL) && (pnum->open!=False) && (IVAL(pnum->printer_hnd.data5,4)==(uint32)sys_getpid())) -#define OUR_HANDLE(pnum) ((pnum==NULL)?"NULL":(IVAL(pnum->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")) +#define OUR_HANDLE(hnd) ((hnd==NULL)?"NULL":(IVAL(hnd->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")) /* translate between internal status numbers and NT status numbers */ static int nt_printj_status(int v) @@ -151,6 +143,56 @@ static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp) free(sp); } +/*************************************************************************** + Disconnect from the client +****************************************************************************/ + +static void srv_spoolss_replycloseprinter(POLICY_HND *handle) +{ + uint32 status; + + /* weird if the test succeds !!! */ + if (smb_connections==0) { + DEBUG(0,("srv_spoolss_replycloseprinter:Trying to close non-existant notify backchannel !\n")); + return; + } + + if(!cli_spoolss_reply_close_printer(&cli, handle, &status)) + DEBUG(0,("srv_spoolss_replycloseprinter: reply_close_printer failed.\n")); + + /* if it's the last connection, deconnect the IPC$ share */ + if (smb_connections==1) { + if(!spoolss_disconnect_from_client(&cli)) + return; + + message_deregister(MSG_PRINTER_NOTIFY); + } + + smb_connections--; +} + +/**************************************************************************** + Functions to free a printer entry datastruct. +****************************************************************************/ + +static void free_printer_entry(void *ptr) +{ + Printer_entry *Printer = (Printer_entry *)ptr; + + if (Printer->notify.client_connected==True) + srv_spoolss_replycloseprinter(&Printer->notify.client_hnd); + + Printer->notify.flags=0; + Printer->notify.options=0; + Printer->notify.localmachine[0]='\0'; + Printer->notify.printerlocal=0; + free_spool_notify_option(&Printer->notify.option); + Printer->notify.option=NULL; + Printer->notify.client_connected=False; + + safe_free(Printer); +} + /**************************************************************************** Functions to duplicate a SPOOL_NOTIFY_OPTION struct stored in Printer_entry. ****************************************************************************/ @@ -180,15 +222,6 @@ SPOOL_NOTIFY_OPTION *dup_spool_notify_option(SPOOL_NOTIFY_OPTION *sp) return new_sp; } -/**************************************************************************** - initialise printer handle states... -****************************************************************************/ -void init_printer_hnd(void) -{ - ubi_dlInitList(&Printer_list); - ubi_dlInitList(&counter_list); -} - /**************************************************************************** Return a user struct for a pipe user. ****************************************************************************/ @@ -205,109 +238,36 @@ static struct current_user *get_current_user(struct current_user *user, pipes_st return user; } -/**************************************************************************** - create a unique printer handle -****************************************************************************/ -static void create_printer_hnd(POLICY_HND *hnd) -{ - static uint32 prt_hnd_low = 0; - static uint32 prt_hnd_high = 0; - - if (hnd == NULL) return; - - create_policy_handle(hnd, &prt_hnd_low, &prt_hnd_high); -} - /**************************************************************************** find printer index by handle ****************************************************************************/ -static Printer_entry *find_printer_index_by_hnd(const POLICY_HND *hnd) -{ - Printer_entry *find_printer; - find_printer = (Printer_entry *)ubi_dlFirst(&Printer_list); - - for(; find_printer; find_printer = (Printer_entry *)ubi_dlNext(find_printer)) { - - if (memcmp(&(find_printer->printer_hnd), hnd, sizeof(*hnd)) == 0) { - DEBUG(4,("Found printer handle \n")); - /*dump_data(4, hnd->data, sizeof(hnd->data));*/ - return find_printer; - } - } - - DEBUG(3,("Whoops, Printer handle not found: ")); - /*dump_data(4, hnd->data, sizeof(hnd->data));*/ - return NULL; -} - -/**************************************************************************** - clear an handle -****************************************************************************/ -static void clear_handle(POLICY_HND *hnd) -{ - ZERO_STRUCTP(hnd); -} - -/*************************************************************************** - Disconnect from the client -****************************************************************************/ -static BOOL srv_spoolss_replycloseprinter(POLICY_HND *handle) +static Printer_entry *find_printer_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) { - uint32 status; - - /* weird if the test succeds !!! */ - if (smb_connections==0) { - DEBUG(0,("srv_spoolss_replycloseprinter:Trying to close non-existant notify backchannel !\n")); - return False; - } - - if(!cli_spoolss_reply_close_printer(&cli, handle, &status)) - return False; - - /* if it's the last connection, deconnect the IPC$ share */ - if (smb_connections==1) { - if(!spoolss_disconnect_from_client(&cli)) - return False; + Printer_entry *find_printer = NULL; - message_deregister(MSG_PRINTER_NOTIFY); + if(!find_policy_by_hnd(p,hnd,(void **)&find_printer)) { + DEBUG(3,("find_printer_index_by_hnd: Printer handle not found: ")); + return NULL; } - smb_connections--; - - return True; + return find_printer; } /**************************************************************************** close printer index by handle ****************************************************************************/ -static BOOL close_printer_handle(POLICY_HND *hnd) + +static BOOL close_printer_handle(pipes_struct *p, POLICY_HND *hnd) { - Printer_entry *Printer = find_printer_index_by_hnd(hnd); + Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("close_printer_handle: Invalid handle (%s)\n", OUR_HANDLE(hnd))); return False; } - if (Printer->notify.client_connected==True) - if(!srv_spoolss_replycloseprinter(&Printer->notify.client_hnd)) - return ERROR_INVALID_HANDLE; - - Printer->open=False; - Printer->notify.flags=0; - Printer->notify.options=0; - Printer->notify.localmachine[0]='\0'; - Printer->notify.printerlocal=0; - free_spool_notify_option(&Printer->notify.option); - Printer->notify.option=NULL; - Printer->notify.client_connected=False; - - clear_handle(hnd); - - ubi_dlRemThis(&Printer_list, Printer); - - safe_free(Printer); + close_policy_hnd(p, hnd); return True; } @@ -315,11 +275,11 @@ static BOOL close_printer_handle(POLICY_HND *hnd) /**************************************************************************** delete a printer given a handle ****************************************************************************/ -static uint32 delete_printer_handle(POLICY_HND *hnd) +static uint32 delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) { - Printer_entry *Printer = find_printer_index_by_hnd(hnd); + Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("delete_printer_handle: Invalid handle (%s)\n", OUR_HANDLE(hnd))); return ERROR_INVALID_HANDLE; } @@ -387,11 +347,11 @@ static uint32 delete_printer_handle(POLICY_HND *hnd) /**************************************************************************** return the snum of a printer corresponding to an handle ****************************************************************************/ -static BOOL get_printer_snum(POLICY_HND *hnd, int *number) +static BOOL get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number) { - Printer_entry *Printer = find_printer_index_by_hnd(hnd); + Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("get_printer_snum: Invalid handle (%s)\n", OUR_HANDLE(hnd))); return False; } @@ -411,11 +371,11 @@ static BOOL get_printer_snum(POLICY_HND *hnd, int *number) /**************************************************************************** set printer handle type. ****************************************************************************/ -static BOOL set_printer_hnd_accesstype(POLICY_HND *hnd, uint32 access_required) +static BOOL set_printer_hnd_accesstype(pipes_struct *p, POLICY_HND *hnd, uint32 access_required) { - Printer_entry *Printer = find_printer_index_by_hnd(hnd); + Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("set_printer_hnd_accesstype: Invalid handle (%s)", OUR_HANDLE(hnd))); return False; } @@ -581,38 +541,35 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) find first available printer slot. creates a printer handle for you. ****************************************************************************/ -static BOOL open_printer_hnd(POLICY_HND *hnd, char *name) +static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name) { Printer_entry *new_printer; DEBUG(10,("open_printer_hnd: name [%s]\n", name)); - clear_handle(hnd); - create_printer_hnd(hnd); if((new_printer=(Printer_entry *)malloc(sizeof(Printer_entry))) == NULL) return False; ZERO_STRUCTP(new_printer); - new_printer->open = True; new_printer->notify.option=NULL; - memcpy(&new_printer->printer_hnd, hnd, sizeof(*hnd)); - - ubi_dlAddHead( &Printer_list, (ubi_dlNode *)new_printer); + if (!create_policy_hnd(p, hnd, free_printer_entry, new_printer)) { + safe_free(new_printer); + return False; + } if (!set_printer_hnd_printertype(new_printer, name)) { - close_printer_handle(hnd); + close_printer_handle(p, hnd); return False; } if (!set_printer_hnd_name(new_printer, name)) { - close_printer_handle(hnd); + close_printer_handle(p, hnd); return False; } - DEBUG(5, ("%d printer handles active\n", - (int)ubi_dlCount(&Printer_list))); + DEBUG(5, ("%d printer handles active\n", (int)p->pipe_handles.count )); return True; } @@ -620,11 +577,12 @@ static BOOL open_printer_hnd(POLICY_HND *hnd, char *name) /******************************************************************** Return True is the handle is a print server. ********************************************************************/ -static BOOL handle_is_printserver(const POLICY_HND *handle) + +static BOOL handle_is_printserver(pipes_struct *p, POLICY_HND *handle) { - Printer_entry *Printer=find_printer_index_by_hnd(handle); + Printer_entry *Printer=find_printer_index_by_hnd(p,handle); - if (!OPEN_HANDLE(Printer)) + if (!Printer) return False; if (Printer->printer_type != PRINTER_HANDLE_IS_PRINTSERVER) @@ -670,11 +628,12 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) /*************************************************************************** receive the notify message ****************************************************************************/ + void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) { fstring printer; uint32 status; - Printer_entry *find_printer; + struct pipes_struct *p; *printer = '\0'; fstrcpy(printer,buf); @@ -686,36 +645,45 @@ void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) DEBUG(10,("srv_spoolss_receive_message: Got message about printer %s\n", printer )); - find_printer = (Printer_entry *)ubi_dlFirst(&Printer_list); + /* We need to enumerate all our pipes and all printers on them. */ + for ( p = get_first_pipe(); p; get_next_pipe(p)) { + struct policy *pol; - /* Iterate the printer list. */ - for(; find_printer; find_printer = (Printer_entry *)ubi_dlNext(find_printer)) { + if (!strequal(p->name, "spoolss")) + continue; - /* - * if the entry is the given printer or if it's a printerserver - * we send the message - */ + /* Iterate the printer list on this pipe. */ + for (pol = p->pipe_handles.Policy; pol; pol = pol->next ) { + Printer_entry *find_printer = (Printer_entry *)pol->data_ptr; - if (find_printer->printer_type==PRINTER_HANDLE_IS_PRINTER) - if (strcmp(find_printer->dev.handlename, printer)) + if (!find_printer) continue; - if (find_printer->notify.client_connected==True) - cli_spoolss_reply_rrpcn(&cli, &find_printer->notify.client_hnd, PRINTER_CHANGE_ALL, 0x0, &status); + /* + * if the entry is the given printer or if it's a printerserver + * we send the message + */ + + if (find_printer->printer_type==PRINTER_HANDLE_IS_PRINTER) + if (strcmp(find_printer->dev.handlename, printer)) + continue; + if (find_printer->notify.client_connected==True) + cli_spoolss_reply_rrpcn(&cli, &find_printer->notify.client_hnd, PRINTER_CHANGE_ALL, 0x0, &status); + } } } /*************************************************************************** send a notify event ****************************************************************************/ -static BOOL srv_spoolss_sendnotify(POLICY_HND *handle) +static BOOL srv_spoolss_sendnotify(pipes_struct *p, POLICY_HND *handle) { fstring printer; - Printer_entry *Printer=find_printer_index_by_hnd(handle); + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("srv_spoolss_sendnotify: Invalid handle (%s).\n", OUR_HANDLE(handle))); return False; } @@ -767,7 +735,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(handle, name)) + if (!open_printer_hnd(p, handle, name)) return ERROR_INVALID_PRINTER_NAME; /* @@ -780,8 +748,8 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, set_printer_hnd_datatype(handle, ""); */ - if (!set_printer_hnd_accesstype(handle, printer_default->access_required)) { - close_printer_handle(handle); + if (!set_printer_hnd_accesstype(p, handle, printer_default->access_required)) { + close_printer_handle(p, handle); return ERROR_ACCESS_DENIED; } @@ -810,7 +778,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, get_current_user(&user, p); - if (handle_is_printserver(handle)) { + if (handle_is_printserver(p, handle)) { if (printer_default->access_required == 0) { return NT_STATUS_NO_PROBLEMO; } @@ -820,14 +788,14 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, snum = -1; if (!lp_ms_add_printer_wizard()) { - close_printer_handle(handle); + close_printer_handle(p, handle); return ERROR_ACCESS_DENIED; } else if (user.uid == 0 || user_in_list(uidtoname(user.uid), lp_printer_admin(snum))) { return NT_STATUS_NO_PROBLEMO; } else { - close_printer_handle(handle); + close_printer_handle(p, handle); return ERROR_ACCESS_DENIED; } } @@ -837,7 +805,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* NT doesn't let us connect to a printer if the connecting user doesn't have print permission. */ - if (!get_printer_snum(handle, &snum)) + if (!get_printer_snum(p, handle, &snum)) return ERROR_INVALID_HANDLE; /* map an empty access mask to the minimum access mask */ @@ -846,7 +814,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, if (!print_access_check(&user, snum, printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); - close_printer_handle(handle); + close_printer_handle(p, handle); return ERROR_ACCESS_DENIED; } @@ -919,7 +887,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, if (printer_default->devmode_cont.devmode != NULL) { result = printer_write_default_dev( snum, printer_default); if (result != 0) { - close_printer_handle(handle); + close_printer_handle(p, handle); return result; } } @@ -1038,11 +1006,11 @@ BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, * _spoolss_enddocprinter_internal. ********************************************************************/ -static uint32 _spoolss_enddocprinter_internal(POLICY_HND *handle) +static uint32 _spoolss_enddocprinter_internal(pipes_struct *p, POLICY_HND *handle) { - Printer_entry *Printer=find_printer_index_by_hnd(handle); + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("_spoolss_enddocprinter_internal: Invalid handle (%s)\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } @@ -1062,14 +1030,14 @@ uint32 _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL_R { POLICY_HND *handle = &q_u->handle; - Printer_entry *Printer=find_printer_index_by_hnd(handle); + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); if (Printer && Printer->document_started) - _spoolss_enddocprinter_internal(handle); /* print job was not closed */ + _spoolss_enddocprinter_internal(p, handle); /* print job was not closed */ memcpy(&r_u->handle, &q_u->handle, sizeof(r_u->handle)); - if (!close_printer_handle(handle)) + if (!close_printer_handle(p, handle)) return ERROR_INVALID_HANDLE; return NT_STATUS_NO_PROBLEMO; @@ -1084,18 +1052,18 @@ uint32 _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL { POLICY_HND *handle = &q_u->handle; - Printer_entry *Printer=find_printer_index_by_hnd(handle); + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); uint32 result; if (Printer && Printer->document_started) - _spoolss_enddocprinter_internal(handle); /* print job was not closed */ + _spoolss_enddocprinter_internal(p, handle); /* print job was not closed */ memcpy(&r_u->handle, &q_u->handle, sizeof(r_u->handle)); - result = delete_printer_handle(handle); + result = delete_printer_handle(p, handle); if (result == ERROR_SUCCESS) { - srv_spoolss_sendnotify(handle); + srv_spoolss_sendnotify(p, handle); } return result; @@ -1182,7 +1150,7 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 /******************************************************************** GetPrinterData on a printer Handle. ********************************************************************/ -static BOOL getprinterdata_printer(TALLOC_CTX *ctx, POLICY_HND *handle, +static BOOL getprinterdata_printer(pipes_struct *p, TALLOC_CTX *ctx, POLICY_HND *handle, fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size ) { @@ -1190,16 +1158,16 @@ static BOOL getprinterdata_printer(TALLOC_CTX *ctx, POLICY_HND *handle, int snum=0; uint8 *idata=NULL; uint32 len; - Printer_entry *Printer = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); DEBUG(5,("getprinterdata_printer\n")); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("getprinterdata_printer: Invalid handle (%s).\n", OUR_HANDLE(handle))); return False; } - if(!get_printer_snum(handle, &snum)) + if(!get_printer_snum(p, handle, &snum)) return False; if(get_a_printer(&printer, 2, lp_servicename(snum)) != 0) @@ -1251,7 +1219,7 @@ uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO fstring value; BOOL found=False; - Printer_entry *Printer = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); /* * Reminder: when it's a string, the length is in BYTES @@ -1268,7 +1236,7 @@ uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO DEBUG(4,("_spoolss_getprinterdata\n")); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { if((*data=(uint8 *)malloc(4*sizeof(uint8))) == NULL) return ERROR_NOT_ENOUGH_MEMORY; DEBUG(0,("_spoolss_getprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); @@ -1277,10 +1245,10 @@ uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO unistr2_to_ascii(value, valuename, sizeof(value)-1); - if (handle_is_printserver(handle)) + if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) found=getprinterdata_printer_server(p->mem_ctx, value, type, data, needed, *out_size); else - found= getprinterdata_printer(p->mem_ctx, handle, value, type, data, needed, *out_size); + found= getprinterdata_printer(p, p->mem_ctx, handle, value, type, data, needed, *out_size); if (found==False) { DEBUG(5, ("value not found, allocating %d\n", *out_size)); @@ -1351,9 +1319,9 @@ uint32 _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE /* store the notify value in the printer struct */ - Printer_entry *Printer=find_printer_index_by_hnd(handle); + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("_spoolss_rffpcnex: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } @@ -1786,13 +1754,11 @@ static void spoolss_notify_status(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - int count; - print_queue_struct *q=NULL; print_status_struct status; memset(&status, 0, sizeof(status)); - count = print_queue_status(snum, &q, &status); + print_queue_status(snum, &q, &status); data->notify_data.value[0]=(uint32) status.status; safe_free(q); } @@ -2277,20 +2243,19 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, * that's the print server case, the printer case is even worse. */ - - /******************************************************************* * * enumerate all printers on the printserver * fill a notify_info struct with info asked * ********************************************************************/ -static uint32 printserver_notify_info(const POLICY_HND *hnd, + +static uint32 printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, TALLOC_CTX *mem_ctx) { int snum; - Printer_entry *Printer=find_printer_index_by_hnd(hnd); + Printer_entry *Printer=find_printer_index_by_hnd(p, hnd); int n_services=lp_numservices(); int i; uint32 id; @@ -2341,11 +2306,11 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, * fill a notify_info struct with info asked * ********************************************************************/ -static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, +static uint32 printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, TALLOC_CTX *mem_ctx) { int snum; - Printer_entry *Printer=find_printer_index_by_hnd(hnd); + Printer_entry *Printer=find_printer_index_by_hnd(p, hnd); int i; uint32 id; SPOOL_NOTIFY_OPTION *option; @@ -2362,7 +2327,7 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, info->data=NULL; info->count=0; - get_printer_snum(hnd, &snum); + get_printer_snum(p, hnd, &snum); for (i=0; icount; i++) { option_type=&option->ctr.type[i]; @@ -2430,13 +2395,13 @@ uint32 _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN /* SPOOL_NOTIFY_OPTION *option = q_u->option; - notused. */ SPOOL_NOTIFY_INFO *info = &r_u->info; - Printer_entry *Printer=find_printer_index_by_hnd(handle); + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); uint32 result = ERROR_INVALID_HANDLE; /* we always have a NOTIFY_INFO struct */ r_u->info_ptr=0x1; - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("_spoolss_rfnpcnex: Invalid handle (%s).\n", OUR_HANDLE(handle))); goto done; @@ -2459,12 +2424,11 @@ uint32 _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN switch (Printer->printer_type) { case PRINTER_HANDLE_IS_PRINTSERVER: - result = printserver_notify_info(handle, info, - p->mem_ctx); + result = printserver_notify_info(p, handle, info, p->mem_ctx); break; case PRINTER_HANDLE_IS_PRINTER: - result = printer_notify_info(handle, info, p->mem_ctx); + result = printer_notify_info(p, handle, info, p->mem_ctx); break; } @@ -3312,7 +3276,7 @@ uint32 _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET *needed=0; - if (!get_printer_snum(handle, &snum)) + if (!get_printer_snum(p, handle, &snum)) return ERROR_INVALID_HANDLE; switch (level) { @@ -3831,7 +3795,7 @@ uint32 _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ pstrcpy(servername, global_myname); unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); - if (!get_printer_snum(handle, &snum)) + if (!get_printer_snum(p, handle, &snum)) return ERROR_INVALID_HANDLE; switch (level) { @@ -3855,9 +3819,9 @@ uint32 _spoolss_startpageprinter(pipes_struct *p, SPOOL_Q_STARTPAGEPRINTER *q_u, { POLICY_HND *handle = &q_u->handle; - Printer_entry *Printer = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - if (OPEN_HANDLE(Printer)) { + if (Printer) { Printer->page_started=True; return 0x0; } @@ -3873,9 +3837,9 @@ uint32 _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPO { POLICY_HND *handle = &q_u->handle; - Printer_entry *Printer = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("_spoolss_endpageprinter: Invalid handle (%s).\n",OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } @@ -3902,10 +3866,10 @@ uint32 _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S int snum; pstring jobname; fstring datatype; - Printer_entry *Printer = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); struct current_user user; - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("_spoolss_startdocprinter: Invalid handle (%s)\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } @@ -3933,7 +3897,7 @@ uint32 _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S } /* get the share number of the printer */ - if (!get_printer_snum(handle, &snum)) { + if (!get_printer_snum(p, handle, &snum)) { return ERROR_INVALID_HANDLE; } @@ -3964,7 +3928,7 @@ uint32 _spoolss_enddocprinter(pipes_struct *p, SPOOL_Q_ENDDOCPRINTER *q_u, SPOOL { POLICY_HND *handle = &q_u->handle; - return _spoolss_enddocprinter_internal(handle); + return _spoolss_enddocprinter_internal(p, handle); } /**************************************************************************** @@ -3977,9 +3941,9 @@ uint32 _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R uint8 *buffer = q_u->buffer; uint32 *buffer_written = &q_u->buffer_size2; - Printer_entry *Printer = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - if (!OPEN_HANDLE(Printer)) { + 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; @@ -4003,16 +3967,16 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command, { struct current_user user; int snum, errcode = ERROR_INVALID_FUNCTION; - Printer_entry *Printer = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); get_current_user(&user, p); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("control_printer: Invalid handle (%s)\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } - if (!get_printer_snum(handle, &snum)) + if (!get_printer_snum(p, handle, &snum)) return ERROR_INVALID_HANDLE; switch (command) { @@ -4063,9 +4027,9 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, uint32 result; int snum; - Printer_entry *Printer = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - if (!OPEN_HANDLE(Printer) || !get_printer_snum(handle, &snum)) { + if (!Printer || !get_printer_snum(p, handle, &snum)) { DEBUG(0,("update_printer_sec: Invalid handle (%s)\n", OUR_HANDLE(handle))); @@ -4478,13 +4442,13 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, * when updating a printer description ********************************************************************/ -static uint32 update_printer(POLICY_HND *handle, uint32 level, +static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, DEVICEMODE *devmode) { int snum; NT_PRINTER_INFO_LEVEL *printer = NULL, *old_printer = NULL; - Printer_entry *Printer = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); uint32 result; DEBUG(8,("update_printer\n")); @@ -4498,12 +4462,12 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, goto done; } - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { result = ERROR_INVALID_HANDLE; goto done; } - if (!get_printer_snum(handle, &snum)) { + if (!get_printer_snum(p, handle, &snum)) { result = ERROR_INVALID_HANDLE; goto done; } @@ -4582,7 +4546,7 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level, free_a_printer(&printer, 2); free_a_printer(&old_printer, 2); - srv_spoolss_sendnotify(handle); + srv_spoolss_sendnotify(p, handle); return result; } @@ -4599,9 +4563,9 @@ uint32 _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET SEC_DESC_BUF *secdesc_ctr = q_u->secdesc_ctr; uint32 command = q_u->command; - Printer_entry *Printer = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("_spoolss_setprinter: Invalid handle (%s)\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } @@ -4611,7 +4575,7 @@ uint32 _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET case 0: return control_printer(handle, command, p); case 2: - return update_printer(handle, level, info, devmode_ctr.devmode); + return update_printer(p, handle, level, info, devmode_ctr.devmode); case 3: return update_printer_sec(handle, level, info, p, secdesc_ctr); @@ -4627,16 +4591,15 @@ uint32 _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) { POLICY_HND *handle = &q_u->handle; - Printer_entry *Printer= find_printer_index_by_hnd(handle); + Printer_entry *Printer= find_printer_index_by_hnd(p, handle); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("_spoolss_fcpn: Invalid handle (%s)\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } if (Printer->notify.client_connected==True) - if(!srv_spoolss_replycloseprinter(&Printer->notify.client_hnd)) - return ERROR_INVALID_HANDLE; + srv_spoolss_replycloseprinter(&Printer->notify.client_hnd); Printer->notify.flags=0; Printer->notify.options=0; @@ -4872,7 +4835,7 @@ uint32 _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO *needed=0; *returned=0; - if (!get_printer_snum(handle, &snum)) + if (!get_printer_snum(p, handle, &snum)) return ERROR_INVALID_HANDLE; *returned = print_queue_status(snum, &queue, &prt_status); @@ -4920,7 +4883,7 @@ uint32 _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u memset(&prt_status, 0, sizeof(prt_status)); - if (!get_printer_snum(handle, &snum)) { + if (!get_printer_snum(p, handle, &snum)) { return ERROR_INVALID_HANDLE; } @@ -5647,7 +5610,7 @@ uint32 _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUM /**************************************************************************** ****************************************************************************/ -static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, +static uint32 spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_srv_name, const SPOOL_PRINTER_INFO_LEVEL *info, uint32 unk0, uint32 unk1, uint32 unk2, uint32 unk3, uint32 user_switch, const SPOOL_USER_CTR *user, @@ -5702,7 +5665,7 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, return ERROR_ACCESS_DENIED; } - if (!open_printer_hnd(handle, name)) { + if (!open_printer_hnd(p, handle, name)) { /* Handle open failed - remove addition. */ del_a_printer(printer->info_2->sharename); free_a_printer(&printer,2); @@ -5711,7 +5674,7 @@ static uint32 spoolss_addprinterex_level_2( const UNISTR2 *uni_srv_name, free_a_printer(&printer,2); - srv_spoolss_sendnotify(handle); + srv_spoolss_sendnotify(p, handle); return NT_STATUS_NO_PROBLEMO; } @@ -5738,7 +5701,7 @@ uint32 _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_ /* but I know what to do ... */ return ERROR_INVALID_LEVEL; case 2: - return spoolss_addprinterex_level_2(uni_srv_name, info, + return spoolss_addprinterex_level_2(p, uni_srv_name, info, unk0, unk1, unk2, unk3, user_switch, user, handle); default: @@ -5886,7 +5849,7 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S uint32 biggest_valuesize; uint32 biggest_datasize; uint32 data_len; - Printer_entry *Printer = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); int snum; uint8 *data=NULL; uint32 type; @@ -5905,12 +5868,12 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S DEBUG(5,("spoolss_enumprinterdata\n")); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("_spoolss_enumprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } - if (!get_printer_snum(handle, &snum)) + if (!get_printer_snum(p,handle, &snum)) return ERROR_INVALID_HANDLE; if (get_a_printer(&printer, 2, lp_servicename(snum)) != 0) @@ -6045,16 +6008,16 @@ uint32 _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP NT_PRINTER_PARAM *param = NULL, old_param; int snum=0; uint32 status = 0x0; - Printer_entry *Printer=find_printer_index_by_hnd(handle); + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); DEBUG(5,("spoolss_setprinterdata\n")); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("_spoolss_setprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } - if (!get_printer_snum(handle, &snum)) + if (!get_printer_snum(p,handle, &snum)) return ERROR_INVALID_HANDLE; status = get_a_printer(&printer, 2, lp_servicename(snum)); @@ -6117,16 +6080,16 @@ uint32 _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ NT_PRINTER_PARAM param; int snum=0; uint32 status = 0x0; - Printer_entry *Printer=find_printer_index_by_hnd(handle); + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); DEBUG(5,("spoolss_deleteprinterdata\n")); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("_spoolss_deleteprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } - if (!get_printer_snum(handle, &snum)) + if (!get_printer_snum(p, handle, &snum)) return ERROR_INVALID_HANDLE; if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { @@ -6162,11 +6125,11 @@ uint32 _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM int count=0; nt_forms_struct *list=NULL; - Printer_entry *Printer = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); DEBUG(5,("spoolss_addform\n")); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("_spoolss_addform: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } @@ -6192,11 +6155,11 @@ uint32 _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE int count=0; uint32 ret = 0; nt_forms_struct *list=NULL; - Printer_entry *Printer = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); DEBUG(5,("spoolss_deleteform\n")); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("_spoolss_deleteform: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } @@ -6222,11 +6185,11 @@ uint32 _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * int count=0; nt_forms_struct *list=NULL; - Printer_entry *Printer = find_printer_index_by_hnd(handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); DEBUG(5,("spoolss_setform\n")); - if (!OPEN_HANDLE(Printer)) { + if (!Printer) { DEBUG(0,("_spoolss_setform: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } @@ -6605,7 +6568,7 @@ uint32 _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ *needed=0; - if (!get_printer_snum(handle, &snum)) + if (!get_printer_snum(p, handle, &snum)) return ERROR_INVALID_HANDLE; count = print_queue_status(snum, &queue, &prt_status); @@ -6623,4 +6586,3 @@ uint32 _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ return ERROR_INVALID_LEVEL; } } -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index b530d66092..a3176bfd73 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -1,4 +1,3 @@ -#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -248,5 +247,3 @@ BOOL api_srvsvc_rpc(pipes_struct *p) { return api_rpcTNP(p, "api_srvsvc_rpc", api_srv_cmds); } - -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 80794609ea..6e0043b0bb 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1,4 +1,3 @@ -#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -695,6 +694,9 @@ uint32 _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R lp_default_server_announce(), string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); break; + case 100: + init_srv_info_100(&ctr->srv.sv100, 500, global_myname); + break; default: status = NT_STATUS_INVALID_INFO_CLASS; break; @@ -863,4 +865,3 @@ uint32 _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET return r_u->status; } -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 8349b7add6..82125a7085 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -1,5 +1,3 @@ -#define OLD_NTDOMAIN 1 - /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -80,7 +78,7 @@ rid_name domain_group_rids[] = { 0 , NULL } }; -int make_dom_gids(char *gids_str, DOM_GID **ppgids) +int make_dom_gids(TALLOC_CTX *ctx, char *gids_str, DOM_GID **ppgids) { char *ptr; pstring s2; @@ -99,10 +97,10 @@ int make_dom_gids(char *gids_str, DOM_GID **ppgids) count++) ; - gids = (DOM_GID *)malloc( sizeof(DOM_GID) * count ); + gids = (DOM_GID *)talloc(ctx, sizeof(DOM_GID) * count ); if(!gids) { - DEBUG(0,("make_dom_gids: malloc fail !\n")); + DEBUG(0,("make_dom_gids: talloc fail !\n")); return 0; } @@ -192,11 +190,10 @@ void get_domain_user_groups(char *domain_groups, char *user) } } - /******************************************************************* - lookup_group_name + Look up a local (domain) rid and return a name and type. ********************************************************************/ -uint32 lookup_group_name(uint32 rid, char *group_name, uint32 *type) +uint32 local_lookup_group_name(uint32 rid, char *group_name, uint32 *type) { int i = 0; (*type) = SID_NAME_DOM_GRP; @@ -220,9 +217,9 @@ uint32 lookup_group_name(uint32 rid, char *group_name, uint32 *type) } /******************************************************************* - lookup_alias_name + Look up a local alias rid and return a name and type. ********************************************************************/ -uint32 lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) +uint32 local_lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) { int i = 0; (*type) = SID_NAME_WKN_GRP; @@ -246,11 +243,11 @@ uint32 lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) } /******************************************************************* - lookup_user_name + Look up a local user rid and return a name and type. ********************************************************************/ -uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) +uint32 local_lookup_user_name(uint32 rid, char *user_name, uint32 *type) { - struct sam_disp_info *disp_info; + SAM_ACCOUNT *sampwd; int i = 0; (*type) = SID_NAME_USER; @@ -271,12 +268,12 @@ uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) /* ok, it's a user. find the user account */ become_root(); - disp_info = pdb_sam_to_dispinfo(pdb_getsampwrid(rid)); + sampwd = pdb_getsampwrid(rid); unbecome_root(); - if (disp_info != NULL) + if (sampwd != NULL) { - fstrcpy(user_name, disp_info->smb_name); + fstrcpy(user_name, pdb_get_username(sampwd) ); DEBUG(5,(" = %s\n", user_name)); return 0x0; } @@ -286,9 +283,9 @@ uint32 lookup_user_name(uint32 rid, char *user_name, uint32 *type) } /******************************************************************* - lookup_group_rid + Look up a local (domain) group name and return a rid ********************************************************************/ -uint32 lookup_group_rid(char *group_name, uint32 *rid) +uint32 local_lookup_group_rid(char *group_name, uint32 *rid) { char *grp_name; int i = -1; /* start do loop at -1 */ @@ -305,9 +302,9 @@ uint32 lookup_group_rid(char *group_name, uint32 *rid) } /******************************************************************* - lookup_alias_rid + Look up a local (BUILTIN) alias name and return a rid ********************************************************************/ -uint32 lookup_alias_rid(char *alias_name, uint32 *rid) +uint32 local_lookup_alias_rid(char *alias_name, uint32 *rid) { char *als_name; int i = -1; /* start do loop at -1 */ @@ -324,25 +321,23 @@ uint32 lookup_alias_rid(char *alias_name, uint32 *rid) } /******************************************************************* - lookup_user_rid + Look up a local user name and return a rid ********************************************************************/ -uint32 lookup_user_rid(char *user_name, uint32 *rid) +uint32 local_lookup_user_rid(char *user_name, uint32 *rid) { - SAM_ACCOUNT *sam_pass; + SAM_ACCOUNT *sampass; (*rid) = 0; /* find the user account */ become_root(); - sam_pass = pdb_getsampwnam(user_name); + sampass = pdb_getsampwnam(user_name); unbecome_root(); - if (sam_pass != NULL) + if (sampass != NULL) { - *rid = pdb_get_user_rid(sam_pass); + (*rid) = pdb_get_user_rid(sampass); return 0x0; } return NT_STATUS_NONE_MAPPED; } - -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index e648c0f122..12e4a8f335 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -1,4 +1,3 @@ -#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -72,5 +71,3 @@ BOOL api_wkssvc_rpc(pipes_struct *p) { return api_rpcTNP(p, "api_wkssvc_rpc", api_wks_cmds); } - -#undef OLD_NTDOMAIN diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 688c7f1d01..40771d2fb9 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -1,4 +1,3 @@ -#define OLD_NTDOMAIN 1 /* * Unix SMB/Netbios implementation. * Version 1.9. @@ -79,4 +78,3 @@ uint32 _wks_query_info(pipes_struct *p, WKS_Q_QUERY_INFO *q_u, WKS_R_QUERY_INFO return r_u->status; } -#undef OLD_NTDOMAIN -- cgit From a2e5dbb1120e726ba80b00a159dad1a1ca2e3a18 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 11 Mar 2001 00:51:54 +0000 Subject: Remove "BYTE" - we already have uint8 - don't need more conflicts with system header files... Jeremy. (This used to be commit 31e0ce310ec38b3a3a05b344d6450d442c6be471) --- source3/rpc_server/srv_netlog_nt.c | 4 ++-- source3/rpc_server/srv_samr_nt.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 613f8f54b2..764f76e0e4 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -130,7 +130,7 @@ static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, static BOOL get_md4pw(char *md4pw, char *mach_acct) { SAM_ACCOUNT *sampass = NULL; - BYTE *pass; + uint8 *pass; #if 0 /* @@ -399,7 +399,7 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, SAM_ACCOUNT *sampass, us static uint32 net_login_network(NET_ID_INFO_2 *id2, SAM_ACCOUNT *sampass) { - BYTE *nt_pwd, *lanman_pwd; + 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, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ff484a8ff1..181e1140eb 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2014,8 +2014,8 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) { SAM_ACCOUNT *pwd = pdb_getsampwrid(rid); SAM_ACCOUNT new_pwd; - BYTE nt_hash[16]; - BYTE lm_hash[16]; + uint8 nt_hash[16]; + uint8 lm_hash[16]; pstring buf; uint32 len; uint16 acct_ctrl; -- cgit From b2bc2bfaf056bdafd14513a0a6d1daef3d327ffc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 11 Mar 2001 04:33:05 +0000 Subject: Ensure we're checking for the "FIRST" flag in other types of PDU than "REQUEST" (ie. BIND, BINDRESP and ALTERCONTEXT) - if we don't do this then we don't set the endianness flag correctly for these PDU's. Herb - this should fix the bug you reported to me today. Jeremy. (This used to be commit dde795154cdc33cb8d6f0dfe9ae2712f7f8be3a7) --- source3/rpc_server/srv_pipe_hnd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index cd072122f3..8846761316 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -322,11 +322,10 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) } /* - * If there's not data in the incoming buffer and it's a - * request PDU this should be the start of a new RPC. + * If there's not data in the incoming buffer this should be the start of a new RPC. */ - if((p->hdr.pkt_type == RPC_REQUEST) && (prs_offset(&p->in_data.data) == 0)) { + if(prs_offset(&p->in_data.data) == 0) { if (!(p->hdr.flags & RPC_FLG_FIRST)) { /* @@ -348,6 +347,9 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) p->endian = rpc_in.bigendian_data; + DEBUG(5,("unmarshall_rpc_header: using %sendian RPC\n", + p->endian == RPC_LITTLE_ENDIAN ? "little-" : "big-" )); + } else { /* @@ -356,7 +358,7 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) */ if (p->endian != rpc_in.bigendian_data) { - DEBUG(0,("unmarshall_rpc_header: FIRST endianness flag different in next PDU !\n")); + DEBUG(0,("unmarshall_rpc_header: FIRST endianness flag (%d) different in next PDU !\n", (int)p->endian)); set_incoming_fault(p); prs_mem_free(&rpc_in); return -1; -- cgit From b840dce67639b8d270eaac27b29d7392981f55bd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 11 Mar 2001 22:26:28 +0000 Subject: Moved cruft out of smb.h into ntdomain.h where it belongs. dc struct now in pipe struct (where used) rather than user_struct. Secured machine account password changing in srv_netlog_nt.c - ensure that only the given machine can change its own password. May need to free this up later for NT admin tools, but this is a fail-safe secure position for now. Jeremy. (This used to be commit 46b12f2275dcd4b3114085160cd456441f9e921e) --- source3/rpc_server/srv_netlog_nt.c | 86 +++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 38 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 764f76e0e4..f022b6f06b 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -150,6 +150,8 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) } #endif /* 0 */ + /* JRA. This is ok as it is only used for generating the challenge. */ + become_root(); sampass = pdb_getsampwnam(mach_acct); unbecome_root(); @@ -175,10 +177,9 @@ uint32 _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u) { uint32 status = NT_STATUS_NOPROBLEMO; fstring mach_acct; - user_struct *vuser; - if ((vuser = get_valid_user_struct(p->vuid)) == NULL) - return False; + if (!get_valid_user_struct(p->vuid)) + return NT_STATUS_NO_SUCH_USER; fstrcpy(mach_acct, dos_unistrn2(q_u->uni_logon_clnt.buffer, q_u->uni_logon_clnt.uni_str_len)); @@ -186,29 +187,33 @@ uint32 _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u) strlower(mach_acct); fstrcat(mach_acct, "$"); - if (get_md4pw((char *)vuser->dc.md4pw, mach_acct)) { + if (get_md4pw((char *)p->dc.md4pw, mach_acct)) { /* copy the client credentials */ - memcpy(vuser->dc.clnt_chal.data , q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); - memcpy(vuser->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + memcpy(p->dc.clnt_chal.data , q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + memcpy(p->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); /* create a server challenge for the client */ /* Set these to random values. */ - generate_random_buffer(vuser->dc.srv_chal.data, 8, False); + generate_random_buffer(p->dc.srv_chal.data, 8, False); - memcpy(vuser->dc.srv_cred.challenge.data, vuser->dc.srv_chal.data, 8); + memcpy(p->dc.srv_cred.challenge.data, p->dc.srv_chal.data, 8); - memset((char *)vuser->dc.sess_key, '\0', sizeof(vuser->dc.sess_key)); + memset((char *)p->dc.sess_key, '\0', sizeof(p->dc.sess_key)); /* from client / server challenges and md4 password, generate sess key */ - cred_session_key(&vuser->dc.clnt_chal, &vuser->dc.srv_chal, - (char *)vuser->dc.md4pw, vuser->dc.sess_key); + cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal, + (char *)p->dc.md4pw, p->dc.sess_key); + + /* Save the machine account name. */ + fstrcpy(p->dc.mach_acct, mach_acct); + } else { /* lkclXXXX take a guess at a good error message to return :-) */ status = NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT; } /* set up the LSA REQUEST CHALLENGE response */ - init_net_r_req_chal(r_u, &vuser->dc.srv_chal, status); + init_net_r_req_chal(r_u, &p->dc.srv_chal, status); return r_u->status; } @@ -223,22 +228,21 @@ uint32 _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) DOM_CHAL srv_cred; UTIME srv_time; NEG_FLAGS srv_flgs; - user_struct *vuser; - if ((vuser = get_valid_user_struct(p->vuid)) == NULL) + if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; srv_time.time = 0; /* check that the client credentials are valid */ - if (cred_assert(&q_u->clnt_chal, vuser->dc.sess_key, &vuser->dc.clnt_cred.challenge, srv_time)) { + if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) { /* create server challenge for inclusion in the reply */ - cred_create(vuser->dc.sess_key, &vuser->dc.srv_cred.challenge, srv_time, &srv_cred); + cred_create(p->dc.sess_key, &p->dc.srv_cred.challenge, srv_time, &srv_cred); /* copy the received client credentials for use next time */ - memcpy(vuser->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); - memcpy(vuser->dc.srv_cred .challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + memcpy(p->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + memcpy(p->dc.srv_cred .challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); } else { status = NT_STATUS_ACCESS_DENIED; } @@ -257,24 +261,22 @@ 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) { - uint16 vuid = p->vuid; uint32 status = NT_STATUS_WRONG_PASSWORD; DOM_CRED srv_cred; pstring mach_acct; SAM_ACCOUNT *sampass; BOOL ret = False; - user_struct *vuser; unsigned char pwd[16]; int i; - if ((vuser = get_valid_user_struct(vuid)) == NULL) + if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; /* checks and updates credentials. creates reply credentials */ - if (!deal_with_creds(vuser->dc.sess_key, &vuser->dc.clnt_cred, &q_u->clnt_id.cred, &srv_cred)) + if (!deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->clnt_id.cred, &srv_cred)) return NT_STATUS_INVALID_HANDLE; - memcpy(&vuser->dc.srv_cred, &vuser->dc.clnt_cred, sizeof(vuser->dc.clnt_cred)); + memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); @@ -287,15 +289,27 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ sampass = pdb_getsampwnam(mach_acct); unbecome_root(); - if (sampass == NULL) + /* Ensure the account exists and is a machine account. */ + + if (sampass == NULL || !(pdb_get_acct_ctrl(sampass) & ACB_WSTRUST)) 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)) + return NT_STATUS_ACCESS_DENIED; + + DEBUG(100,("Server password set : new given value was :\n")); for(i = 0; i < 16; i++) DEBUG(100,("%02X ", q_u->pwd[i])); DEBUG(100,("\n")); - cred_hash3( pwd, q_u->pwd, vuser->dc.sess_key, 0); + cred_hash3( pwd, q_u->pwd, p->dc.sess_key, 0); /* lies! nt and lm passwords are _not_ the same: don't care */ pdb_set_lanman_passwd (sampass, pwd); @@ -324,17 +338,15 @@ uint32 _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF { DOM_CRED srv_cred; - user_struct *vuser; - - if ((vuser = get_valid_user_struct(p->vuid)) == NULL) + if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; /* checks and updates credentials. creates reply credentials */ - if (!deal_with_creds(vuser->dc.sess_key, &vuser->dc.clnt_cred, + if (!deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred)) return NT_STATUS_INVALID_HANDLE; - memcpy(&vuser->dc.srv_cred, &vuser->dc.clnt_cred, sizeof(vuser->dc.clnt_cred)); + memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); /* XXXX maybe we want to say 'no', reject the client's credentials */ r_u->buffer_creds = 1; /* yes, we have valid server credentials */ @@ -349,7 +361,7 @@ 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, SAM_ACCOUNT *sampass, user_struct *vuser) +static uint32 net_login_interactive(NET_ID_INFO_1 *id1, SAM_ACCOUNT *sampass, pipes_struct *p) { uint32 status = 0x0; @@ -358,7 +370,7 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, SAM_ACCOUNT *sampass, us unsigned char key[16]; memset(key, 0, 16); - memcpy(key, vuser->dc.sess_key, 8); + memcpy(key, p->dc.sess_key, 8); memcpy(lm_pwd, id1->lm_owf.data, 16); memcpy(nt_pwd, id1->nt_owf.data, 16); @@ -444,28 +456,26 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, SAM_ACCOUNT *sampass) uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_u) { uint32 status = NT_STATUS_NOPROBLEMO; - uint16 vuid = p->vuid; NET_USER_INFO_3 *usr_info = NULL; DOM_CRED srv_cred; SAM_ACCOUNT *sampass = NULL; uint16 acct_ctrl; UNISTR2 *uni_samlogon_user = NULL; fstring nt_username; - user_struct *vuser = NULL; usr_info = (NET_USER_INFO_3 *)talloc(p->mem_ctx, sizeof(NET_USER_INFO_3)); if (!usr_info) return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(usr_info); - if ((vuser = get_valid_user_struct(vuid)) == NULL) + if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; /* checks and updates credentials. creates reply credentials */ - if (!deal_with_creds(vuser->dc.sess_key, &vuser->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred)) + if (!deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred)) return NT_STATUS_INVALID_HANDLE; else - memcpy(&vuser->dc.srv_cred, &vuser->dc.clnt_cred, sizeof(vuser->dc.clnt_cred)); + memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); /* find the username */ @@ -516,7 +526,7 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ switch (q_u->sam_id.logon_level) { case INTERACTIVE_LOGON_TYPE: /* interactive login. */ - status = net_login_interactive(&q_u->sam_id.ctr->auth.id1, sampass, vuser); + 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 */ -- cgit From 7c99297ea1c090c8c3ecd9c9669a36dab0bfdc36 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 12 Mar 2001 16:43:01 +0000 Subject: Looks like AS/U doesn't set the FIRST flag in a BIND packet. Jeremy. (This used to be commit a8df5e04b5bc22aa4324e3b1b5dd78bf0e1c566f) --- source3/rpc_server/srv_pipe_hnd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 8846761316..3049c3adb9 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -327,7 +327,11 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) if(prs_offset(&p->in_data.data) == 0) { - if (!(p->hdr.flags & RPC_FLG_FIRST)) { + /* + * AS/U doesn't set FIRST flag in a BIND packet it seems. + */ + + if ((p->hdr.pkt_type == RPC_REQUEST) && !(p->hdr.flags & RPC_FLG_FIRST)) { /* * Ensure that the FIRST flag is set. If not then we have * a stream missmatch. -- cgit From 5107a7a96acf1949f5ae0cdc49e9c84570f3482a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 12 Mar 2001 20:19:31 +0000 Subject: Ok - we're now sending back policy handles to bigendian AS/U correctly. Jeremy. (This used to be commit 67e09aea47b73e5a72aae638a58b56f2ef67f8af) --- source3/rpc_server/srv_pipe_hnd.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 3049c3adb9..ed1f9d36db 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -569,8 +569,14 @@ static ssize_t process_complete_pdu(pipes_struct *p) } prs_init( &rpc_in, 0, p->mem_ctx, UNMARSHALL); - /* Ensure we're using the corrent endianness. */ + + /* + * Ensure we're using the corrent endianness for both the + * RPC header flags and the raw data we will be reading from. + */ + prs_set_endian_data( &rpc_in, p->endian); + prs_set_endian_data( &p->in_data.data, p->endian); prs_give_memory( &rpc_in, data_p, (uint32)data_len, False); @@ -601,6 +607,9 @@ static ssize_t process_complete_pdu(pipes_struct *p) break; } + /* Reset to little endian. Probably don't need this but it won't hurt. */ + prs_set_endian_data( &p->in_data.data, RPC_LITTLE_ENDIAN); + if (!reply) { DEBUG(3,("process_complete_pdu: DCE/RPC fault sent on pipe %s\n", p->pipe_srv_name)); set_incoming_fault(p); -- cgit From 9b690629eebf86b55cc0f18a84ed704dfa7ab065 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 13 Mar 2001 00:31:53 +0000 Subject: Ensure we return the correct names/sids on query info. AS/U showed us what we should return here. Jeremy. (This used to be commit d22c6067032e167d4558f4954c58d87404de6d9d) --- source3/rpc_server/srv_lsa_nt.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 8e1d934309..d1a7c049d8 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -366,7 +366,8 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO if (secrets_fetch_domain_sid(global_myworkgroup, &domain_sid)) { - name = global_myworkgroup; + /* I'm sure this should be myname, not myworkgroup. JRA. */ + name = global_myname; sid = &domain_sid; } default: @@ -375,8 +376,24 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO init_dom_query(&r_u->dom.id3, name, sid); break; case 0x05: - name = global_myname; - sid = &global_sam_sid; + /* AS/U shows this needs to be the same as level 3. JRA. */ + switch (lp_server_role()) + { + case ROLE_DOMAIN_PDC: + case ROLE_DOMAIN_BDC: + name = global_myworkgroup; + sid = &global_sam_sid; + break; + case ROLE_DOMAIN_MEMBER: + if (secrets_fetch_domain_sid(global_myworkgroup, + &domain_sid)) + { + name = global_myname; + sid = &domain_sid; + } + default: + break; + } init_dom_query(&r_u->dom.id5, name, sid); break; case 0x06: -- cgit From 769659eb0849fbc30a3284f99563dde965318bfd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 13 Mar 2001 00:32:43 +0000 Subject: Ensure we never return passwords from a user query. Jeremy. (This used to be commit 37248e99e8b8d8a7e247d968b93a7d0cf5f63c8e) --- source3/rpc_server/srv_samr_nt.c | 75 +++++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 181e1140eb..9f0ce9b05d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -56,6 +56,34 @@ static void free_samr_info(void *ptr) safe_free(samr); } +/******************************************************************* + Ensure password info is never given out. Paranioa... JRA. + ********************************************************************/ + +static void samr_clear_passwd_fields( SAM_USER_INFO_21 *pass, int num_entries) +{ + int i; + + if (!pass) + return; + + for (i = 0; i < num_entries; i++) { + memset(&pass[i].lm_pwd, '\0', sizeof(pass[i].lm_pwd)); + memset(&pass[i].nt_pwd, '\0', sizeof(pass[i].nt_pwd)); + } +} + +static void samr_clear_sam_passwd( SAM_ACCOUNT *sam_pass) +{ + if (!sam_pass) + return; + + if (sam_pass->lm_pw) + memset(sam_pass->lm_pw, '\0', 16); + if (sam_pass->nt_pw) + memset(sam_pass->nt_pw, '\0', 16); +} + /******************************************************************* This next function should be replaced with something that dynamically returns the correct user info..... JRA. @@ -660,6 +688,8 @@ uint32 _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_R_ if (!ret) return NT_STATUS_ACCESS_DENIED; + samr_clear_passwd_fields(pass, num_entries); + /* * Note from JRA. total_entries is not being used here. Currently if there is a * large user base then it looks like NT will enumerate until get_sampwd_entries @@ -979,6 +1009,9 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ DEBUG(5, ("limiting number of entries to %d\n", num_entries)); } + /* Ensure password info is never given out here. PARANOIA... JRA */ + samr_clear_passwd_fields(pass, num_entries); + data_size = q_u->max_size; orig_num_entries = num_entries; @@ -1308,7 +1341,7 @@ uint32 _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP } /******************************************************************* - _api_samr_open_user + _api_samr_open_user. Safe - gives out no passwd info. ********************************************************************/ uint32 _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USER *r_u) @@ -1334,6 +1367,8 @@ uint32 _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_U if (sampass == NULL) return NT_STATUS_NO_SUCH_USER; + samr_clear_sam_passwd(sampass); + /* Get the domain SID stored in the domain policy */ if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid)) return NT_STATUS_INVALID_HANDLE; @@ -1357,7 +1392,7 @@ uint32 _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_U } /************************************************************************* - get_user_info_10 + get_user_info_10. Safe. Only gives out acb bits. *************************************************************************/ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) @@ -1386,30 +1421,40 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) } /************************************************************************* - get_user_info_12 + get_user_info_12. OK - this is the killer as it gives out password info. + Ensure that this is only allowed on an encrypted connection with a root + user. JRA. *************************************************************************/ -static BOOL get_user_info_12(SAM_USER_INFO_12 * id12, uint32 user_rid) +static uint32 get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint32 user_rid) { SAM_ACCOUNT *smbpass; - become_root(); + if (!p->ntlmssp_auth_validated) + return NT_STATUS_ACCESS_DENIED; + + if (!(p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SIGN) || !(p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SEAL)) + return NT_STATUS_ACCESS_DENIED; + + /* + * Do *NOT* do become_root()/unbecome_root() here ! JRA. + */ + smbpass = pdb_getsampwrid(user_rid); - unbecome_root(); if (smbpass == NULL) { DEBUG(4, ("User 0x%x not found\n", user_rid)); - return False; + return (geteuid() == (uid_t)0) ? NT_STATUS_NO_SUCH_USER : NT_STATUS_ACCESS_DENIED; } DEBUG(3,("User:[%s] 0x%x\n", pdb_get_username(smbpass), pdb_get_acct_ctrl(smbpass) )); if ( pdb_get_acct_ctrl(smbpass) & ACB_DISABLED) - return False; + return NT_STATUS_ACCOUNT_DISABLED; init_sam_user_info12(id12, pdb_get_lanman_passwd(smbpass), pdb_get_nt_passwd(smbpass)); - return True; + return NT_STATUS_NOPROBLEMO; } /************************************************************************* @@ -1434,6 +1479,8 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) return False; } + samr_clear_sam_passwd(sampass); + DEBUG(3,("User:[%s]\n", pdb_get_username(sampass) )); init_sam_user_info21A(id21, sampass); @@ -1512,8 +1559,8 @@ uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_ if (ctr->info.id12 == NULL) return NT_STATUS_NO_MEMORY; - if (!get_user_info_12(ctr->info.id12, rid)) - return NT_STATUS_NO_SUCH_USER; + if ((r_u->status = get_user_info_12(p, ctr->info.id12, rid)) != NT_STATUS_NOPROBLEMO) + return r_u->status; break; case 21: @@ -1567,6 +1614,8 @@ uint32 _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAM if (sam_pass == NULL) return NT_STATUS_NO_SUCH_USER; + samr_clear_sam_passwd(sam_pass); + get_domain_user_groups(groups, pdb_get_username(sam_pass)); gids = NULL; num_groups = make_dom_gids(p->mem_ctx, groups, &gids); @@ -2392,8 +2441,8 @@ 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) { - DEBUG(0,("_samr_get_dom_pwinfo: Not yet implemented.\n")); - return False; + /* Actually, returning zeros here works quite well :-). */ + return NT_STATUS_NOPROBLEMO; } /********************************************************************* -- cgit From 0ef2179d23a2f9826e17c2b858fd8f2a9634b332 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 13 Mar 2001 01:44:05 +0000 Subject: Fixed reading of strings from big-endian RPC clients. Jeremy. (This used to be commit e7ecb9410ff2e4fcd33bca9f82e14c060590942a) --- source3/rpc_server/srv_lsa_nt.c | 6 +++--- source3/rpc_server/srv_netlog_nt.c | 10 +++++----- source3/rpc_server/srv_pipe.c | 6 +++--- source3/rpc_server/srv_reg_nt.c | 4 ++-- source3/rpc_server/srv_samr_nt.c | 8 ++++---- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index d1a7c049d8..6e70d8cc87 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -109,7 +109,7 @@ static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, int num_entries, UNISTR2 name[MAX_LOOKUP_SIDS], - uint32 *mapped_count) + uint32 *mapped_count, BOOL endian) { int i; int total = 0; @@ -128,7 +128,7 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, /* Split name into domain and user component */ - pstrcpy(full_name, dos_unistr2_to_str(&name[i])); + pstrcpy(full_name, rpc_unistr2_to_str(&name[i], endian)); split_domain_name(full_name, dom_name, user); /* Lookup name */ @@ -479,7 +479,7 @@ uint32 _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_N return NT_STATUS_NO_MEMORY; /* set up the LSA Lookup RIDs response */ - init_lsa_rid2s(ref, rids, num_entries, names, &mapped_count); + init_lsa_rid2s(ref, rids, num_entries, names, &mapped_count, p->endian); init_reply_lookup_names(r_u, ref, num_entries, rids, mapped_count); return r_u->status; diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index f022b6f06b..6a6254574c 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -181,8 +181,8 @@ uint32 _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u) if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; - fstrcpy(mach_acct, dos_unistrn2(q_u->uni_logon_clnt.buffer, - q_u->uni_logon_clnt.uni_str_len)); + fstrcpy(mach_acct, rpc_unistrn2(q_u->uni_logon_clnt.buffer, + q_u->uni_logon_clnt.uni_str_len, p->endian)); strlower(mach_acct); fstrcat(mach_acct, "$"); @@ -280,8 +280,8 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); - 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)); + pstrcpy(mach_acct, rpc_unistrn2(q_u->clnt_id.login.uni_acct_name.buffer, + q_u->clnt_id.login.uni_acct_name.uni_str_len, p->endian)); DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); @@ -497,7 +497,7 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ /* check username exists */ - pstrcpy(nt_username, dos_unistrn2(uni_samlogon_user->buffer, uni_samlogon_user->uni_str_len)); + pstrcpy(nt_username, rpc_unistrn2(uni_samlogon_user->buffer, uni_samlogon_user->uni_str_len, p->endian)); DEBUG(3,("User:[%s]\n", nt_username)); diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index bc5b2ab473..16243043d4 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -296,9 +296,9 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm */ if (p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_UNICODE) { - fstrcpy(user_name, dos_unistrn2((uint16*)ntlmssp_resp->user, ntlmssp_resp->hdr_usr.str_str_len/2)); - fstrcpy(domain, dos_unistrn2((uint16*)ntlmssp_resp->domain, ntlmssp_resp->hdr_domain.str_str_len/2)); - fstrcpy(wks, dos_unistrn2((uint16*)ntlmssp_resp->wks, ntlmssp_resp->hdr_wks.str_str_len/2)); + fstrcpy(user_name, rpc_unistrn2((uint16*)ntlmssp_resp->user, ntlmssp_resp->hdr_usr.str_str_len/2, p->endian)); + fstrcpy(domain, rpc_unistrn2((uint16*)ntlmssp_resp->domain, ntlmssp_resp->hdr_domain.str_str_len/2, p->endian)); + fstrcpy(wks, rpc_unistrn2((uint16*)ntlmssp_resp->wks, ntlmssp_resp->hdr_wks.str_str_len/2, p->endian)); } else { fstrcpy(user_name, ntlmssp_resp->user); fstrcpy(domain, ntlmssp_resp->domain); diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 4f941e3e1b..c953fe9d2a 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -85,7 +85,7 @@ uint32 _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY if (!find_policy_by_hnd(p, &q_u->pol, NULL)) return NT_STATUS_INVALID_HANDLE; - fstrcpy(name, dos_unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len)); + fstrcpy(name, rpc_unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len, p->endian)); DEBUG(5,("reg_open_entry: %s\n", name)); @@ -129,7 +129,7 @@ uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) if (find_policy_by_hnd(p, &q_u->pol, NULL) == -1) return NT_STATUS_INVALID_HANDLE; - fstrcpy(name, dos_unistrn2(q_u->uni_type.buffer, q_u->uni_type.uni_str_len)); + fstrcpy(name, rpc_unistrn2(q_u->uni_type.buffer, q_u->uni_type.uni_str_len, p->endian)); DEBUG(5,("reg_info: checking key: %s\n", name)); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9f0ce9b05d..4ff7125fce 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1196,7 +1196,7 @@ uint32 _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOK rid [i] = 0xffffffff; type[i] = SID_NAME_UNKNOWN; - fstrcpy(name, dos_unistrn2(q_u->uni_name[i].buffer, q_u->uni_name[i].uni_str_len)); + fstrcpy(name, rpc_unistrn2(q_u->uni_name[i].buffer, q_u->uni_name[i].uni_str_len, p->endian)); if(sid_equal(&pol_sid, &global_sam_sid)) { DOM_SID sid; @@ -1227,8 +1227,8 @@ uint32 _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_R_ r_u->status = NT_STATUS_NOPROBLEMO; - 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)); + fstrcpy(user_name, rpc_unistrn2(q_u->uni_user_name.buffer, q_u->uni_user_name.uni_str_len, p->endian)); + fstrcpy(wks , rpc_unistrn2(q_u->uni_dest_host.buffer, q_u->uni_dest_host.uni_str_len, p->endian)); DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); @@ -1709,7 +1709,7 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR reply if the account already exists... */ - fstrcpy(mach_acct, dos_unistrn2(user_account.buffer, user_account.uni_str_len)); + fstrcpy(mach_acct, rpc_unistrn2(user_account.buffer, user_account.uni_str_len, p->endian)); strlower(mach_acct); become_root(); diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 6e0043b0bb..01e289866b 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -814,7 +814,7 @@ uint32 _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, S DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); /* Create the list of shares for the response. */ - share_name = dos_unistr2_to_str(&q_u->uni_share_name); + share_name = rpc_unistr2_to_str(&q_u->uni_share_name, p->endian); init_srv_r_net_share_get_info(r_u, share_name, q_u->info_level); DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); -- cgit From 0f710e9bdc740a30468cc85131bf60848306b6bb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 13 Mar 2001 19:21:51 +0000 Subject: AS/U does setuserinfo2, level 0x12 when joining a domain - identical to setuserinfo level 0x12. Jeremy. (This used to be commit d4ad197f711d5c5f2f60083b396f6dd7e6eca8c0) --- source3/rpc_server/srv_samr_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 4ff7125fce..dbed5227b0 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2288,6 +2288,11 @@ uint32 _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SE if (!set_user_info_10(ctr->info.id10, rid)) return NT_STATUS_ACCESS_DENIED; break; + case 18: + /* Used by AS/U JRA. */ + if (!set_user_info_12(ctr->info.id12, rid)) + return NT_STATUS_ACCESS_DENIED; + break; default: return NT_STATUS_INVALID_INFO_CLASS; } -- cgit From 13a584b05acab8d0bb0257712664a3c6a90e3f97 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 13 Mar 2001 20:13:20 +0000 Subject: rpc_parse/parse_samr.c: Removed unneeded deubg. rpc_server/srv_netlog_nt.c: Ensure we marshall a bad password return correctly to a w2k client. Jeremy. (This used to be commit 500c7bc0fed16713401643bdede67cc0c8044d52) --- source3/rpc_server/srv_netlog_nt.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 6a6254574c..15ca079238 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -477,6 +477,15 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ else memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); + r_u->buffer_creds = 1; /* yes, we have valid server credentials */ + memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds)); + + /* store the user information, if there is any. */ + r_u->user = usr_info; + r_u->switch_value = 0; /* indicates no info */ + r_u->auth_resp = 1; /* authoritative response */ + r_u->switch_value = 3; /* indicates type of validation user info */ + /* find the username */ switch (q_u->sam_id.logon_level) { @@ -593,19 +602,5 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ NULL); /* char *other_sids */ } - /* XXXX maybe we want to say 'no', reject the client's credentials */ - r_u->buffer_creds = 1; /* yes, we have valid server credentials */ - memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds)); - - /* store the user information, if there is any. */ - r_u->user = usr_info; - if (status == NT_STATUS_NOPROBLEMO && usr_info != NULL && usr_info->ptr_user_info != 0) - r_u->switch_value = 3; /* indicates type of validation user info */ - else - r_u->switch_value = 0; /* indicates no info */ - - r_u->status = status; - r_u->auth_resp = 1; /* authoritative response */ - - return r_u->status; + return status; } -- cgit From e532d96a26055d23450bfb3e9c28e0179ee9f2d2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 13 Mar 2001 20:18:45 +0000 Subject: Move to a handle database per pipe name, not per pipe. Jeremy. (This used to be commit a24b248a77ccac364832ff7d4df083d437caf9ed) --- source3/rpc_server/srv_lsa_hnd.c | 94 +++++++++++++++++++++++++++++-------- source3/rpc_server/srv_pipe_hnd.c | 8 +++- source3/rpc_server/srv_spoolss_nt.c | 53 +++++++++++++-------- 3 files changed, 115 insertions(+), 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index bcc3878d86..d0a26abc6b 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -25,19 +25,63 @@ extern int DEBUGLEVEL; -/* This is the max handles per pipe. */ +/* This is the max handles across all instances of a pipe name. */ #ifndef MAX_OPEN_POLS -#define MAX_OPEN_POLS 256 +#define MAX_OPEN_POLS 1024 #endif /**************************************************************************** - initialise policy handle states... + Initialise a policy handle list on a pipe. Handle list is shared between all + pipes of the same name. ****************************************************************************/ -void init_pipe_handles(pipes_struct *p) +BOOL init_pipe_handle_list(pipes_struct *p, char *pipe_name) { - p->pipe_handles.Policy = NULL; - p->pipe_handles.count = 0; + pipes_struct *plist = get_first_pipe(); + struct handle_list *hl = NULL; + + for (plist = get_first_pipe(); plist; plist = get_next_pipe(plist)) { + if (strequal( plist->name, pipe_name)) { + if (!plist->pipe_handles) { + pstring msg; + slprintf(msg, sizeof(msg)-1, "init_pipe_handles: NULL pipe_handle pointer in pipe %s", + pipe_name ); + smb_panic(msg); + } + hl = plist->pipe_handles; + break; + } + } + + if (!hl) { + /* + * No handle list for this pipe (first open of pipe). + * Create list. + */ + + if ((hl = (struct handle_list *)malloc(sizeof(struct handle_list))) == NULL) + return False; + ZERO_STRUCTP(hl); + + DEBUG(10,("init_pipe_handles: created handle list for pipe %s\n", pipe_name )); + } + + /* + * One more pipe is using this list. + */ + + hl->pipe_ref_count++; + + /* + * Point this pipe at this list. + */ + + p->pipe_handles = hl; + + DEBUG(10,("init_pipe_handles: pipe_handles ref count = %u for pipe %s\n", + p->pipe_handles->pipe_ref_count, pipe_name )); + + return True; } /**************************************************************************** @@ -51,8 +95,9 @@ BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *) struct policy *pol; - if (p->pipe_handles.count > MAX_OPEN_POLS) { - DEBUG(0,("create_policy_hnd: ERROR: too many handles (%d) on this pipe.\n", (int)p->pipe_handles.count)); + if (p->pipe_handles->count > MAX_OPEN_POLS) { + DEBUG(0,("create_policy_hnd: ERROR: too many handles (%d) on this pipe.\n", + (int)p->pipe_handles->count)); return False; } @@ -78,12 +123,12 @@ BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *) SIVAL(pol->pol_hnd.data5, 0, time(NULL)); /* something random */ SIVAL(pol->pol_hnd.data5, 4, sys_getpid()); /* something more random */ - DLIST_ADD(p->pipe_handles.Policy, pol); - p->pipe_handles.count++; + DLIST_ADD(p->pipe_handles->Policy, pol); + p->pipe_handles->count++; *hnd = pol->pol_hnd; - DEBUG(4,("Opened policy hnd[%d] ", (int)p->pipe_handles.count)); + DEBUG(4,("Opened policy hnd[%d] ", (int)p->pipe_handles->count)); dump_data(4, (char *)hnd, sizeof(*hnd)); return True; @@ -101,7 +146,7 @@ static struct policy *find_policy_by_hnd_internal(pipes_struct *p, POLICY_HND *h if (data_p) *data_p = NULL; - for (i = 0, pol=p->pipe_handles.Policy;pol;pol=pol->next, i++) { + for (i = 0, pol=p->pipe_handles->Policy;pol;pol=pol->next, i++) { if (memcmp(&pol->pol_hnd, hnd, sizeof(*hnd)) == 0) { DEBUG(4,("Found policy hnd[%d] ", (int)i)); dump_data(4, (char *)hnd, sizeof(*hnd)); @@ -144,9 +189,9 @@ BOOL close_policy_hnd(pipes_struct *p, POLICY_HND *hnd) if (pol->free_fn && pol->data_ptr) (*pol->free_fn)(pol->data_ptr); - pol->p->pipe_handles.count--; + pol->p->pipe_handles->count--; - DLIST_REMOVE(pol->p->pipe_handles.Policy, pol); + DLIST_REMOVE(pol->p->pipe_handles->Policy, pol); ZERO_STRUCTP(pol); @@ -156,14 +201,25 @@ BOOL close_policy_hnd(pipes_struct *p, POLICY_HND *hnd) } /**************************************************************************** - Close all the pipe handles. + Close a pipe - free the handle list if it was the last pipe reference. ****************************************************************************/ void close_policy_by_pipe(pipes_struct *p) { - while (p->pipe_handles.Policy) - close_policy_hnd(p, &p->pipe_handles.Policy->pol_hnd); + p->pipe_handles->pipe_ref_count--; + + if (p->pipe_handles->pipe_ref_count == 0) { + /* + * Last pipe open on this list - free the list. + */ + while (p->pipe_handles->Policy) + close_policy_hnd(p, &p->pipe_handles->Policy->pol_hnd); - p->pipe_handles.Policy = NULL; - p->pipe_handles.count = 0; + p->pipe_handles->Policy = NULL; + p->pipe_handles->count = 0; + + free(p->pipe_handles); + p->pipe_handles = NULL; + DEBUG(10,("close_policy_by_pipe: deleted handle list for pipe %s\n", p->name )); + } } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index ed1f9d36db..893bc8cb88 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -163,7 +163,13 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, return NULL; } - init_pipe_handles(p); + if (!init_pipe_handle_list(p, pipe_name)) { + DEBUG(0,("open_rpc_pipe_p: init_pipe_handles failed.\n")); + talloc_destroy(p->mem_ctx); + free(p); + return NULL; + } + DLIST_ADD(Pipes, p); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 9fcf9930bf..804fe8a523 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -569,7 +569,7 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name) return False; } - DEBUG(5, ("%d printer handles active\n", (int)p->pipe_handles.count )); + DEBUG(5, ("%d printer handles active\n", (int)p->pipe_handles->count )); return True; } @@ -634,6 +634,8 @@ void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) fstring printer; uint32 status; struct pipes_struct *p; + struct policy *pol; + struct handle_list *hl; *printer = '\0'; fstrcpy(printer,buf); @@ -645,32 +647,43 @@ void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) DEBUG(10,("srv_spoolss_receive_message: Got message about printer %s\n", printer )); - /* We need to enumerate all our pipes and all printers on them. */ + /* + * We need to enumerate all printers. The handle list is shared + * across pipes of the same name, so just find the first open + * spoolss pipe. + */ + + hl = NULL; for ( p = get_first_pipe(); p; get_next_pipe(p)) { - struct policy *pol; + if (strequal(p->name, "spoolss")) { + hl = p->pipe_handles; + break; + } + } - if (!strequal(p->name, "spoolss")) - continue; + if (!hl) { + DEBUG(0,("srv_spoolss_receive_message: no handle list on spoolss pipe !\n")); + return; + } - /* Iterate the printer list on this pipe. */ - for (pol = p->pipe_handles.Policy; pol; pol = pol->next ) { - Printer_entry *find_printer = (Printer_entry *)pol->data_ptr; + /* Iterate the printer list on this pipe. */ + for (pol = hl->Policy; pol; pol = pol->next ) { + Printer_entry *find_printer = (Printer_entry *)pol->data_ptr; - if (!find_printer) - continue; + if (!find_printer) + continue; - /* - * if the entry is the given printer or if it's a printerserver - * we send the message - */ + /* + * if the entry is the given printer or if it's a printerserver + * we send the message + */ - if (find_printer->printer_type==PRINTER_HANDLE_IS_PRINTER) - if (strcmp(find_printer->dev.handlename, printer)) - continue; + if (find_printer->printer_type==PRINTER_HANDLE_IS_PRINTER) + if (strcmp(find_printer->dev.handlename, printer)) + continue; - if (find_printer->notify.client_connected==True) - cli_spoolss_reply_rrpcn(&cli, &find_printer->notify.client_hnd, PRINTER_CHANGE_ALL, 0x0, &status); - } + if (find_printer->notify.client_connected==True) + cli_spoolss_reply_rrpcn(&cli, &find_printer->notify.client_hnd, PRINTER_CHANGE_ALL, 0x0, &status); } } -- cgit From 4ab6182a0ffdbe92a01dd6533e0862aa8d0f6d83 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Mar 2001 00:49:13 +0000 Subject: AS/U on a sparc now joins and authenticates against a Samba PDC ! Jeremy. (This used to be commit 28a0bc5f5710aa732db662caa38f9da2138b5db2) --- source3/rpc_server/srv_lsa_nt.c | 2 +- source3/rpc_server/srv_netlog_nt.c | 10 +++++----- source3/rpc_server/srv_pipe.c | 6 +++--- source3/rpc_server/srv_reg_nt.c | 4 ++-- source3/rpc_server/srv_samr_nt.c | 8 ++++---- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 6e70d8cc87..d4c76fe56f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -128,7 +128,7 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, /* Split name into domain and user component */ - pstrcpy(full_name, rpc_unistr2_to_str(&name[i], endian)); + pstrcpy(full_name, dos_unistr2_to_str(&name[i])); split_domain_name(full_name, dom_name, user); /* Lookup name */ diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 15ca079238..cfcfac1d1a 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -181,8 +181,8 @@ uint32 _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u) if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; - fstrcpy(mach_acct, rpc_unistrn2(q_u->uni_logon_clnt.buffer, - q_u->uni_logon_clnt.uni_str_len, p->endian)); + fstrcpy(mach_acct, dos_unistrn2(q_u->uni_logon_clnt.buffer, + q_u->uni_logon_clnt.uni_str_len)); strlower(mach_acct); fstrcat(mach_acct, "$"); @@ -280,8 +280,8 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); - pstrcpy(mach_acct, rpc_unistrn2(q_u->clnt_id.login.uni_acct_name.buffer, - q_u->clnt_id.login.uni_acct_name.uni_str_len, p->endian)); + 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)); @@ -506,7 +506,7 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ /* check username exists */ - pstrcpy(nt_username, rpc_unistrn2(uni_samlogon_user->buffer, uni_samlogon_user->uni_str_len, p->endian)); + pstrcpy(nt_username, dos_unistrn2(uni_samlogon_user->buffer, uni_samlogon_user->uni_str_len)); DEBUG(3,("User:[%s]\n", nt_username)); diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 16243043d4..bc5b2ab473 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -296,9 +296,9 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm */ if (p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_UNICODE) { - fstrcpy(user_name, rpc_unistrn2((uint16*)ntlmssp_resp->user, ntlmssp_resp->hdr_usr.str_str_len/2, p->endian)); - fstrcpy(domain, rpc_unistrn2((uint16*)ntlmssp_resp->domain, ntlmssp_resp->hdr_domain.str_str_len/2, p->endian)); - fstrcpy(wks, rpc_unistrn2((uint16*)ntlmssp_resp->wks, ntlmssp_resp->hdr_wks.str_str_len/2, p->endian)); + fstrcpy(user_name, dos_unistrn2((uint16*)ntlmssp_resp->user, ntlmssp_resp->hdr_usr.str_str_len/2)); + fstrcpy(domain, dos_unistrn2((uint16*)ntlmssp_resp->domain, ntlmssp_resp->hdr_domain.str_str_len/2)); + fstrcpy(wks, dos_unistrn2((uint16*)ntlmssp_resp->wks, ntlmssp_resp->hdr_wks.str_str_len/2)); } else { fstrcpy(user_name, ntlmssp_resp->user); fstrcpy(domain, ntlmssp_resp->domain); diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index c953fe9d2a..4f941e3e1b 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -85,7 +85,7 @@ uint32 _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY if (!find_policy_by_hnd(p, &q_u->pol, NULL)) return NT_STATUS_INVALID_HANDLE; - fstrcpy(name, rpc_unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len, p->endian)); + fstrcpy(name, dos_unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len)); DEBUG(5,("reg_open_entry: %s\n", name)); @@ -129,7 +129,7 @@ uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) if (find_policy_by_hnd(p, &q_u->pol, NULL) == -1) return NT_STATUS_INVALID_HANDLE; - fstrcpy(name, rpc_unistrn2(q_u->uni_type.buffer, q_u->uni_type.uni_str_len, p->endian)); + fstrcpy(name, dos_unistrn2(q_u->uni_type.buffer, q_u->uni_type.uni_str_len)); DEBUG(5,("reg_info: checking key: %s\n", name)); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index dbed5227b0..c3df798c3c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1196,7 +1196,7 @@ uint32 _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOK rid [i] = 0xffffffff; type[i] = SID_NAME_UNKNOWN; - fstrcpy(name, rpc_unistrn2(q_u->uni_name[i].buffer, q_u->uni_name[i].uni_str_len, p->endian)); + fstrcpy(name, dos_unistrn2(q_u->uni_name[i].buffer, q_u->uni_name[i].uni_str_len)); if(sid_equal(&pol_sid, &global_sam_sid)) { DOM_SID sid; @@ -1227,8 +1227,8 @@ uint32 _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_R_ r_u->status = NT_STATUS_NOPROBLEMO; - fstrcpy(user_name, rpc_unistrn2(q_u->uni_user_name.buffer, q_u->uni_user_name.uni_str_len, p->endian)); - fstrcpy(wks , rpc_unistrn2(q_u->uni_dest_host.buffer, q_u->uni_dest_host.uni_str_len, p->endian)); + 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)); DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); @@ -1709,7 +1709,7 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR reply if the account already exists... */ - fstrcpy(mach_acct, rpc_unistrn2(user_account.buffer, user_account.uni_str_len, p->endian)); + fstrcpy(mach_acct, dos_unistrn2(user_account.buffer, user_account.uni_str_len)); strlower(mach_acct); become_root(); diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 01e289866b..6e0043b0bb 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -814,7 +814,7 @@ uint32 _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, S DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); /* Create the list of shares for the response. */ - share_name = rpc_unistr2_to_str(&q_u->uni_share_name, p->endian); + share_name = dos_unistr2_to_str(&q_u->uni_share_name); init_srv_r_net_share_get_info(r_u, share_name, q_u->info_level); DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); -- cgit From 3257008e0d521fa53caacfc8d7885626868ab691 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Mar 2001 02:01:58 +0000 Subject: Fixed a Dr. Watson when viewing permissions - we were missing the "standalone server" case. Jeremy. (This used to be commit b318a754e7d8504072e8d968ee5fe581d105392f) --- source3/rpc_server/srv_lsa_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index d4c76fe56f..f78836b155 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -362,6 +362,7 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO name = global_myworkgroup; sid = &global_sam_sid; break; + case ROLE_STANDALONE: case ROLE_DOMAIN_MEMBER: if (secrets_fetch_domain_sid(global_myworkgroup, &domain_sid)) @@ -384,6 +385,7 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO name = global_myworkgroup; sid = &global_sam_sid; break; + case ROLE_STANDALONE: case ROLE_DOMAIN_MEMBER: if (secrets_fetch_domain_sid(global_myworkgroup, &domain_sid)) -- cgit From 41cb452b73cd70c4a9997d9d8af6c2b18fcf0d22 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Mar 2001 02:49:06 +0000 Subject: Return correct error message if we can't get the SID secret. Jeremy. (This used to be commit c202ebe3b6aa413fa7b00ec6d1b3f123f1e1a55b) --- source3/rpc_server/srv_lsa_nt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f78836b155..08885682ad 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -371,8 +371,11 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO name = global_myname; sid = &domain_sid; } - default: + else + return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; break; + default: + return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; } init_dom_query(&r_u->dom.id3, name, sid); break; @@ -393,8 +396,11 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO name = global_myname; sid = &domain_sid; } - default: + else + return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; break; + default: + return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; } init_dom_query(&r_u->dom.id5, name, sid); break; -- cgit From f4b702cd5e2fcd428476006d08f09031ebf3d63e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Mar 2001 03:03:48 +0000 Subject: Last attempt at fix... Jeremy. (This used to be commit f2680842d755aa77bc70e1c4329fd513c00fece6) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 08885682ad..46c4789928 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -385,10 +385,10 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: + case ROLE_STANDALONE: name = global_myworkgroup; sid = &global_sam_sid; break; - case ROLE_STANDALONE: case ROLE_DOMAIN_MEMBER: if (secrets_fetch_domain_sid(global_myworkgroup, &domain_sid)) -- cgit From eb9e2882d2e837f823ccb63d6b54b93f9cdf3333 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Mar 2001 03:08:22 +0000 Subject: Final ! Fix. Jeremy. (This used to be commit 58dd295882a944934014a31c61eed35bf04fc2bd) --- source3/rpc_server/srv_lsa_nt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 46c4789928..0a20aec8f4 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -362,7 +362,6 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO name = global_myworkgroup; sid = &global_sam_sid; break; - case ROLE_STANDALONE: case ROLE_DOMAIN_MEMBER: if (secrets_fetch_domain_sid(global_myworkgroup, &domain_sid)) @@ -374,6 +373,10 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO else return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; break; + case ROLE_STANDALONE: + name = global_myname; + sid = &global_sam_sid; + break; default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; } @@ -385,7 +388,6 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - case ROLE_STANDALONE: name = global_myworkgroup; sid = &global_sam_sid; break; @@ -399,6 +401,10 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO else return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; break; + case ROLE_STANDALONE: + name = global_myname; + sid = &global_sam_sid; + break; default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; } -- cgit From ae728ea761e82d6d0bd5c96e7c82f1b1115f2e24 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Mar 2001 03:19:01 +0000 Subject: Last tweak (I promise :-). Fallback to returning our SID if we're a domain member but can't get the domain sid. Jeremy. (This used to be commit 45e96777d0eeafbbf40759f02cd3f5e15b12c288) --- source3/rpc_server/srv_lsa_nt.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 0a20aec8f4..87aebfa674 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -363,15 +363,12 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO sid = &global_sam_sid; break; case ROLE_DOMAIN_MEMBER: + name = global_myname; if (secrets_fetch_domain_sid(global_myworkgroup, &domain_sid)) - { - /* I'm sure this should be myname, not myworkgroup. JRA. */ - name = global_myname; - sid = &domain_sid; - } + sid = &domain_sid; else - return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; + sid = &global_sam_sid; break; case ROLE_STANDALONE: name = global_myname; @@ -392,14 +389,12 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO sid = &global_sam_sid; break; case ROLE_DOMAIN_MEMBER: + name = global_myname; if (secrets_fetch_domain_sid(global_myworkgroup, &domain_sid)) - { - name = global_myname; - sid = &domain_sid; - } + sid = &domain_sid; else - return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; + sid = &global_sam_sid; break; case ROLE_STANDALONE: name = global_myname; -- cgit From a8d396f25ed483371e5085ae14000b194af1e70b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Mar 2001 04:34:53 +0000 Subject: Tidyup return of zero-permissions (map to ACE_DENIED, GENERIC_ALL, Everyone). Jeremy. (This used to be commit 0d6c7dedd261c15697a7781678fe6bed877b61f6) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 87aebfa674..f273c7bb4c 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -325,7 +325,7 @@ uint32 _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_ENU } /*************************************************************************** - _lsa_query_info + _lsa_query_info. See the POLICY_INFOMATION_CLASS docs at msdn. ***************************************************************************/ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO *r_u) -- cgit From a9dda48d653810b8f20b3b72f07cc060e2b2e3cd Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 15 Mar 2001 07:11:18 +0000 Subject: renamed one of the enumprinterdrivers parsing functions for consistency sake. (This used to be commit cbce0c935099231af51a34460c6b331822fde213) --- source3/rpc_server/srv_spoolss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 126581ba80..1932c6f927 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -712,8 +712,8 @@ static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p) r_u.status = _spoolss_enumprinterdrivers(p, &q_u, &r_u); - if (!new_spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) { - DEBUG(0,("new_spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n")); + if (!spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n")); return False; } -- cgit From 65d35749b721b76ae826a9423bdefd2f673f35c6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 16 Mar 2001 05:55:30 +0000 Subject: Added Michael Sweet's CUPS patch to call directly into the CUPS backend. Parameterises the printing functions so other backends can be plugged directly in (this is a good thing :-). Jeremy. (This used to be commit c0345bbaed5d1aac777f1a33ff84ad1899f2ed6d) --- source3/rpc_server/srv_reg.c | 2 +- source3/rpc_server/srv_samr.c | 2 +- source3/rpc_server/srv_samr_nt.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 65f0e2304c..2a0e2d172c 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -5,7 +5,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. - * Copyright (C) Hewlett-Packard Company 1999. + * Copyright (C) Marc Jacobsen 2000. * Copyright (C) Jeremy Allison 2001. * * This program is free software; you can redistribute it and/or modify diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 828e2e5595..6315057313 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -5,7 +5,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. - * Copyright (C) Hewlett-Packard Company 1999. + * Copyright (C) Marc Jacobsen 1999. * * Split into interface and implementation modules by, * diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c3df798c3c..ec5ea29f70 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -5,7 +5,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. - * Copyright (C) Hewlett-Packard Company 1999. + * Copyright (C) Marc Jacobsen 1999. * Copyright (C) Jeremy Allison 2001. * * This program is free software; you can redistribute it and/or modify -- cgit From abb183317342fbfdc75a6858d427e550f8f7123d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 17 Mar 2001 14:07:10 +0000 Subject: fix this in rpc calls as well - ADMIN$ is an IPC share, not a disk share (This used to be commit d039d84164fa15ba242b03fdadfab2e259ca6b65) --- source3/rpc_server/srv_srvsvc_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 6e0043b0bb..061c70454f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -50,7 +50,7 @@ static void init_srv_share_info_1(SRV_SHARE_INFO_1 *sh1, int snum) if (lp_print_ok(snum)) type = STYPE_PRINTQ; - if (strequal("IPC$", net_name)) + if (strequal("IPC", lp_fstype(snum))) type = STYPE_IPC; if (net_name[len_net_name] == '$') type |= STYPE_HIDDEN; @@ -84,7 +84,7 @@ static void init_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, int snum) if (lp_print_ok(snum)) type = STYPE_PRINTQ; - if (strequal("IPC$", net_name)) + if (strequal("IPC", lp_fstype(snum))) type = STYPE_IPC; if (net_name[len_net_name] == '$') type |= STYPE_HIDDEN; -- cgit From 344fb49fbf4df55492bfa9cc1aee2d8210c32ca6 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 19 Mar 2001 18:14:09 +0000 Subject: reverted the rename of new_spoolss_io_r_enumprinterdrivers() (This used to be commit fd6bfe03f4454272bdce59c78ae7148a72caaf18) --- source3/rpc_server/srv_spoolss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 1932c6f927..e8f855f7f1 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -712,7 +712,7 @@ static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p) r_u.status = _spoolss_enumprinterdrivers(p, &q_u, &r_u); - if (!spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) { + if (!new_spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n")); return False; } -- cgit From 0053bd8b80cc08d65948c97f8ab0b4e2b829f083 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 23 Mar 2001 00:50:31 +0000 Subject: first pass of the new group mapping code J.F. (This used to be commit 7154deb026d53cb0cd503562174c3332a372be63) --- source3/rpc_server/srv_samr.c | 155 +++++++++++--- source3/rpc_server/srv_samr_nt.c | 451 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 548 insertions(+), 58 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 6315057313..ca7be9831a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -5,7 +5,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. - * Copyright (C) Marc Jacobsen 1999. + * Copyright (C) Marc Jacobsen 1999. * * Split into interface and implementation modules by, * @@ -110,13 +110,17 @@ static BOOL api_samr_get_usrdom_pwinfo(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!samr_io_q_get_usrdom_pwinfo("", &q_u, data, 0)) + if(!samr_io_q_get_usrdom_pwinfo("", &q_u, data, 0)) { + DEBUG(0,("api_samr_get_usrdom_pwinfo: unable to unmarshall SAMR_Q_GET_USRDOM_PWINFO.\n")); return False; + } r_u.status = _samr_get_usrdom_pwinfo(p, &q_u, &r_u); - if(!samr_io_r_get_usrdom_pwinfo("", &r_u, rdata, 0)) + if(!samr_io_r_get_usrdom_pwinfo("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_get_usrdom_pwinfo: unable to marshall SAMR_R_GET_USRDOM_PWINFO.\n")); return False; + } return True; } @@ -136,13 +140,17 @@ static BOOL api_samr_query_sec_obj(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!samr_io_q_query_sec_obj("", &q_u, data, 0)) + if(!samr_io_q_query_sec_obj("", &q_u, data, 0)) { + DEBUG(0,("api_samr_query_sec_obj: unable to unmarshall SAMR_Q_QUERY_SEC_OBJ.\n")); return False; + } r_u.status = _samr_query_sec_obj(p, &q_u, &r_u); - if(!samr_io_r_query_sec_obj("", &r_u, rdata, 0)) + if(!samr_io_r_query_sec_obj("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_query_sec_obj: unable to marshall SAMR_R_QUERY_SEC_OBJ.\n")); return False; + } return True; } @@ -162,14 +170,18 @@ static BOOL api_samr_enum_dom_users(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the samr open */ - if(!samr_io_q_enum_dom_users("", &q_u, data, 0)) + if(!samr_io_q_enum_dom_users("", &q_u, data, 0)) { + DEBUG(0,("api_samr_enum_dom_users: unable to unmarshall SAMR_Q_ENUM_DOM_USERS.\n")); return False; + } r_u.status = _samr_enum_dom_users(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_enum_dom_users("", &r_u, rdata, 0)) + if(!samr_io_r_enum_dom_users("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_enum_dom_users: unable to marshall SAMR_R_ENUM_DOM_USERS.\n")); return False; + } return True; } @@ -189,14 +201,18 @@ static BOOL api_samr_enum_dom_groups(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the samr open */ - if(!samr_io_q_enum_dom_groups("", &q_u, data, 0)) + if(!samr_io_q_enum_dom_groups("", &q_u, data, 0)) { + DEBUG(0,("api_samr_enum_dom_groups: unable to unmarshall SAMR_Q_ENUM_DOM_GROUPS.\n")); return False; + } r_u.status = _samr_enum_dom_groups(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_enum_dom_groups("", &r_u, rdata, 0)) + if(!samr_io_r_enum_dom_groups("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_enum_dom_groups: unable to marshall SAMR_R_ENUM_DOM_GROUPS.\n")); return False; + } return True; } @@ -216,14 +232,18 @@ static BOOL api_samr_enum_dom_aliases(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the samr open */ - if(!samr_io_q_enum_dom_aliases("", &q_u, data, 0)) + if(!samr_io_q_enum_dom_aliases("", &q_u, data, 0)) { + DEBUG(0,("api_samr_enum_dom_aliases: unable to unmarshall SAMR_Q_ENUM_DOM_ALIASES.\n")); return False; + } r_u.status = _samr_enum_dom_aliases(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_enum_dom_aliases("", &r_u, rdata, 0)) + if(!samr_io_r_enum_dom_aliases("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_enum_dom_aliases: unable to marshall SAMR_R_ENUM_DOM_ALIASES.\n")); return False; + } return True; } @@ -242,14 +262,18 @@ static BOOL api_samr_query_dispinfo(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!samr_io_q_query_dispinfo("", &q_u, data, 0)) + if(!samr_io_q_query_dispinfo("", &q_u, data, 0)) { + DEBUG(0,("api_samr_query_dispinfo: unable to unmarshall SAMR_Q_QUERY_DISPINFO.\n")); return False; + } r_u.status = _samr_query_dispinfo(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_query_dispinfo("", &r_u, rdata, 0)) + if(!samr_io_r_query_dispinfo("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_query_dispinfo: unable to marshall SAMR_R_QUERY_DISPINFO.\n")); return False; + } return True; } @@ -269,14 +293,18 @@ static BOOL api_samr_query_aliasinfo(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the samr open */ - if(!samr_io_q_query_aliasinfo("", &q_u, data, 0)) + if(!samr_io_q_query_aliasinfo("", &q_u, data, 0)) { + DEBUG(0,("api_samr_query_aliasinfo: unable to unmarshall SAMR_Q_QUERY_ALIASINFO.\n")); return False; + } r_u.status = _samr_query_aliasinfo(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_query_aliasinfo("", &r_u, rdata, 0)) + if(!samr_io_r_query_aliasinfo("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_query_aliasinfo: unable to marshall SAMR_R_QUERY_ALIASINFO.\n")); return False; + } return True; } @@ -296,14 +324,18 @@ static BOOL api_samr_lookup_names(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the samr lookup names */ - if(!samr_io_q_lookup_names("", &q_u, data, 0)) + if(!samr_io_q_lookup_names("", &q_u, data, 0)) { + DEBUG(0,("api_samr_lookup_names: unable to unmarshall SAMR_Q_LOOKUP_NAMES.\n")); return False; + } r_u.status = _samr_lookup_names(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_lookup_names("", &r_u, rdata, 0)) + if(!samr_io_r_lookup_names("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_lookup_names: unable to marshall SAMR_R_LOOKUP_NAMES.\n")); return False; + } return True; } @@ -354,14 +386,18 @@ static BOOL api_samr_lookup_rids(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the samr lookup names */ - if(!samr_io_q_lookup_rids("", &q_u, data, 0)) + if(!samr_io_q_lookup_rids("", &q_u, data, 0)) { + DEBUG(0,("api_samr_lookup_rids: unable to unmarshall SAMR_Q_LOOKUP_RIDS.\n")); return False; + } r_u.status = _samr_lookup_rids(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_lookup_rids("", &r_u, rdata, 0)) + if(!samr_io_r_lookup_rids("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_lookup_rids: unable to marshall SAMR_R_LOOKUP_RIDS.\n")); return False; + } return True; } @@ -381,16 +417,18 @@ static BOOL api_samr_open_user(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the samr unknown 22 */ - if(!samr_io_q_open_user("", &q_u, data, 0)) + if(!samr_io_q_open_user("", &q_u, data, 0)) { + DEBUG(0,("api_samr_open_user: unable to unmarshall SAMR_Q_OPEN_USER.\n")); return False; + } r_u.status = _api_samr_open_user(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_open_user("", &r_u, rdata, 0)) + if(!samr_io_r_open_user("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_open_user: unable to marshall SAMR_R_OPEN_USER.\n")); return False; - - DEBUG(5,("samr_open_user: %d\n", __LINE__)); + } return True; } @@ -410,14 +448,18 @@ static BOOL api_samr_query_userinfo(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the samr unknown 24 */ - if(!samr_io_q_query_userinfo("", &q_u, data, 0)) + if(!samr_io_q_query_userinfo("", &q_u, data, 0)){ + DEBUG(0,("api_samr_query_userinfo: unable to unmarshall SAMR_Q_QUERY_USERINFO.\n")); return False; + } r_u.status = _samr_query_userinfo(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_query_userinfo("", &r_u, rdata, 0)) + if(!samr_io_r_query_userinfo("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_query_userinfo: unable to marshall SAMR_R_QUERY_USERINFO.\n")); return False; + } return True; } @@ -437,13 +479,16 @@ static BOOL api_samr_query_usergroups(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the samr unknown 32 */ - if(!samr_io_q_query_usergroups("", &q_u, data, 0)) + if(!samr_io_q_query_usergroups("", &q_u, data, 0)) { + DEBUG(0,("api_samr_query_usergroups: unable to unmarshall SAMR_Q_QUERY_USERGROUPS.\n")); return False; + } r_u.status = _samr_query_usergroups(p, &q_u, &r_u); /* store the response in the SMB stream */ if(!samr_io_r_query_usergroups("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_query_usergroups: unable to marshall SAMR_R_QUERY_USERGROUPS.\n")); return False; } @@ -465,16 +510,18 @@ static BOOL api_samr_query_dom_info(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the samr unknown 8 command */ - if(!samr_io_q_query_dom_info("", &q_u, data, 0)) + if(!samr_io_q_query_dom_info("", &q_u, data, 0)) { + DEBUG(0,("api_samr_query_dom_info: unable to unmarshall SAMR_Q_QUERY_DOMAIN_INFO.\n")); return False; + } r_u.status = _samr_query_dom_info(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_query_dom_info("", &r_u, rdata, 0)) + if(!samr_io_r_query_dom_info("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_query_dom_info: unable to marshall SAMR_R_QUERY_DOMAIN_INFO.\n")); return False; - - DEBUG(5,("api_samr_query_dom_info: %d\n", __LINE__)); + } return True; } @@ -526,14 +573,18 @@ static BOOL api_samr_connect_anon(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the samr open policy */ - if(!samr_io_q_connect_anon("", &q_u, data, 0)) + if(!samr_io_q_connect_anon("", &q_u, data, 0)) { + DEBUG(0,("api_samr_connect_anon: unable to unmarshall SAMR_Q_CONNECT_ANON.\n")); return False; + } r_u.status = _samr_connect_anon(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_connect_anon("", &r_u, rdata, 0)) + if(!samr_io_r_connect_anon("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_connect_anon: unable to marshall SAMR_R_CONNECT_ANON.\n")); return False; + } return True; } @@ -553,14 +604,18 @@ static BOOL api_samr_connect(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the samr open policy */ - if(!samr_io_q_connect("", &q_u, data, 0)) + if(!samr_io_q_connect("", &q_u, data, 0)) { + DEBUG(0,("api_samr_connect: unable to unmarshall SAMR_Q_CONNECT.\n")); return False; + } r_u.status = _samr_connect(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_connect("", &r_u, rdata, 0)) + if(!samr_io_r_connect("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_connect: unable to marshall SAMR_R_CONNECT.\n")); return False; + } return True; } @@ -759,12 +814,14 @@ static BOOL api_samr_query_aliasmem(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_query_aliasmem("", &q_u, data, 0)) { + DEBUG(0,("api_samr_query_aliasmem: unable to unmarshall SAMR_Q_QUERY_ALIASMEM.\n")); return False; } r_u.status = _samr_query_aliasmem(p, &q_u, &r_u); if (!samr_io_r_query_aliasmem("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_query_aliasmem: unable to marshall SAMR_R_QUERY_ALIASMEM.\n")); return False; } @@ -787,12 +844,14 @@ static BOOL api_samr_query_groupmem(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_query_groupmem("", &q_u, data, 0)) { + DEBUG(0,("api_samr_query_groupmem: unable to unmarshall SAMR_Q_QUERY_GROUPMEM.\n")); return False; } r_u.status = _samr_query_groupmem(p, &q_u, &r_u); if (!samr_io_r_query_groupmem("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_query_groupmem: unable to marshall SAMR_R_QUERY_GROUPMEM.\n")); return False; } @@ -815,12 +874,14 @@ static BOOL api_samr_add_aliasmem(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_add_aliasmem("", &q_u, data, 0)) { + DEBUG(0,("api_samr_add_aliasmem: unable to unmarshall SAMR_Q_ADD_ALIASMEM.\n")); return False; } r_u.status = _samr_add_aliasmem(p, &q_u, &r_u); if (!samr_io_r_add_aliasmem("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_add_aliasmem: unable to marshall SAMR_R_ADD_ALIASMEM.\n")); return False; } @@ -843,12 +904,14 @@ static BOOL api_samr_del_aliasmem(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_del_aliasmem("", &q_u, data, 0)) { + DEBUG(0,("api_samr_del_aliasmem: unable to unmarshall SAMR_Q_DEL_ALIASMEM.\n")); return False; } r_u.status = _samr_del_aliasmem(p, &q_u, &r_u); if (!samr_io_r_del_aliasmem("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_del_aliasmem: unable to marshall SAMR_R_DEL_ALIASMEM.\n")); return False; } @@ -871,12 +934,14 @@ static BOOL api_samr_add_groupmem(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_add_groupmem("", &q_u, data, 0)) { + DEBUG(0,("api_samr_add_groupmem: unable to unmarshall SAMR_Q_ADD_GROUPMEM.\n")); return False; } r_u.status = _samr_add_groupmem(p, &q_u, &r_u); if (!samr_io_r_add_groupmem("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_add_groupmem: unable to marshall SAMR_R_ADD_GROUPMEM.\n")); return False; } @@ -899,12 +964,14 @@ static BOOL api_samr_del_groupmem(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_del_groupmem("", &q_u, data, 0)) { + DEBUG(0,("api_samr_del_groupmem: unable to unmarshall SAMR_Q_DEL_GROUPMEM.\n")); return False; } r_u.status = _samr_del_groupmem(p, &q_u, &r_u); if (!samr_io_r_del_groupmem("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_del_groupmem: unable to marshall SAMR_R_DEL_GROUPMEM.\n")); return False; } @@ -927,12 +994,14 @@ static BOOL api_samr_delete_dom_user(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_delete_dom_user("", &q_u, data, 0)) { + DEBUG(0,("api_samr_delete_dom_user: unable to unmarshall SAMR_Q_DELETE_DOM_USER.\n")); return False; } r_u.status = _samr_delete_dom_user(p, &q_u, &r_u); if (!samr_io_r_delete_dom_user("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_delete_dom_user: unable to marshall SAMR_R_DELETE_DOM_USER.\n")); return False; } @@ -955,12 +1024,14 @@ static BOOL api_samr_delete_dom_group(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_delete_dom_group("", &q_u, data, 0)) { + DEBUG(0,("api_samr_delete_dom_group: unable to unmarshall SAMR_Q_DELETE_DOM_GROUP.\n")); return False; } r_u.status = _samr_delete_dom_group(p, &q_u, &r_u); if (!samr_io_r_delete_dom_group("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_delete_dom_group: unable to marshall SAMR_R_DELETE_DOM_GROUP.\n")); return False; } @@ -983,12 +1054,14 @@ static BOOL api_samr_delete_dom_alias(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_delete_dom_alias("", &q_u, data, 0)) { + DEBUG(0,("api_samr_delete_dom_alias: unable to unmarshall SAMR_Q_DELETE_DOM_ALIAS.\n")); return False; } r_u.status = _samr_delete_dom_alias(p, &q_u, &r_u); if (!samr_io_r_delete_dom_alias("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_delete_dom_alias: unable to marshall SAMR_R_DELETE_DOM_ALIAS.\n")); return False; } @@ -1011,12 +1084,14 @@ static BOOL api_samr_create_dom_group(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_create_dom_group("", &q_u, data, 0)) { + DEBUG(0,("api_samr_create_dom_group: unable to unmarshall SAMR_Q_CREATE_DOM_GROUP.\n")); return False; } r_u.status = _samr_create_dom_group(p, &q_u, &r_u); if (!samr_io_r_create_dom_group("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_create_dom_group: unable to marshall SAMR_R_CREATE_DOM_GROUP.\n")); return False; } @@ -1039,12 +1114,14 @@ static BOOL api_samr_create_dom_alias(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_create_dom_alias("", &q_u, data, 0)) { + DEBUG(0,("api_samr_create_dom_alias: unable to unmarshall SAMR_Q_CREATE_DOM_ALIAS.\n")); return False; } r_u.status = _samr_create_dom_alias(p, &q_u, &r_u); if (!samr_io_r_create_dom_alias("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_create_dom_alias: unable to marshall SAMR_R_CREATE_DOM_ALIAS.\n")); return False; } @@ -1067,12 +1144,14 @@ static BOOL api_samr_query_groupinfo(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_query_groupinfo("", &q_u, data, 0)) { + DEBUG(0,("api_samr_query_groupinfo: unable to unmarshall SAMR_Q_QUERY_GROUPINFO.\n")); return False; } r_u.status = _samr_query_groupinfo(p, &q_u, &r_u); if (!samr_io_r_query_groupinfo("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_query_groupinfo: unable to marshall SAMR_R_QUERY_GROUPINFO.\n")); return False; } @@ -1095,12 +1174,14 @@ static BOOL api_samr_set_groupinfo(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_set_groupinfo("", &q_u, data, 0)) { + DEBUG(0,("api_samr_set_groupinfo: unable to unmarshall SAMR_Q_SET_GROUPINFO.\n")); return False; } r_u.status = _samr_set_groupinfo(p, &q_u, &r_u); if (!samr_io_r_set_groupinfo("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_set_groupinfo: unable to marshall SAMR_R_SET_GROUPINFO.\n")); return False; } @@ -1123,12 +1204,14 @@ static BOOL api_samr_get_dom_pwinfo(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_get_dom_pwinfo("", &q_u, data, 0)) { + DEBUG(0,("api_samr_get_dom_pwinfo: unable to unmarshall SAMR_Q_GET_DOM_PWINFO.\n")); return False; } r_u.status = _samr_get_dom_pwinfo(p, &q_u, &r_u); if (!samr_io_r_get_dom_pwinfo("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_get_dom_pwinfo: unable to marshall SAMR_R_GET_DOM_PWINFO.\n")); return False; } @@ -1151,12 +1234,14 @@ static BOOL api_samr_open_group(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_open_group("", &q_u, data, 0)) { + DEBUG(0,("api_samr_open_group: unable to unmarshall SAMR_Q_OPEN_GROUP.\n")); return False; } r_u.status = _samr_open_group(p, &q_u, &r_u); if (!samr_io_r_open_group("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_open_group: unable to marshall SAMR_R_OPEN_GROUP.\n")); return False; } @@ -1179,12 +1264,14 @@ static BOOL api_samr_unknown_2d(pipes_struct *p) ZERO_STRUCT(r_u); if (!samr_io_q_unknown_2d("", &q_u, data, 0)) { + DEBUG(0,("api_samr_unknown_2d: unable to unmarshall SAMR_Q_UNKNOWN_2D.\n")); return False; } r_u.status = _samr_unknown_2d(p, &q_u, &r_u); if (!samr_io_r_unknown_2d("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_unknown_2d: unable to marshall SAMR_R_UNKNOWN_2D.\n")); return False; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ec5ea29f70..94524da352 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -5,7 +5,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. - * Copyright (C) Marc Jacobsen 1999. + * Copyright (C) Marc Jacobsen 1999. * Copyright (C) Jeremy Allison 2001. * * This program is free software; you can redistribute it and/or modify @@ -34,6 +34,7 @@ extern int DEBUGLEVEL; extern fstring global_myworkgroup; extern pstring global_myname; extern DOM_SID global_sam_sid; +extern DOM_SID global_sid_Builtin; extern rid_name domain_group_rids[]; extern rid_name domain_alias_rids[]; @@ -546,7 +547,6 @@ uint32 _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, S static uint32 samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC_BUF **buf, DOM_SID *usr_sid) { - extern DOM_SID global_sid_Builtin; extern DOM_SID global_sid_World; DOM_SID adm_sid; DOM_SID act_sid; @@ -1251,8 +1251,8 @@ static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, fstring nam UNIHDR **pp_hdr_name, UNISTR2 **pp_uni_name) { uint32 i; - UNIHDR *hdr_name; - UNISTR2 *uni_name; + UNIHDR *hdr_name=NULL; + UNISTR2 *uni_name=NULL; *pp_uni_name = NULL; *pp_hdr_name = NULL; @@ -2306,8 +2306,22 @@ 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(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_NO_PROBLEMO); + + return NT_STATUS_NO_PROBLEMO; + } /********************************************************************* @@ -2316,8 +2330,61 @@ uint32 _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, S uint32 _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_QUERY_ALIASMEM *r_u) { - DEBUG(0,("_samr_query_aliasmem: Not yet implemented.\n")); - return False; + int i; + + GROUP_MAP map; + int num_uids = 0; + DOM_SID2 *sid; + uid_t *uid=NULL; + + DOM_SID alias_sid; + DOM_SID als_sid; + uint32 alias_rid; + fstring alias_sid_str; + DOM_SID temp_sid; + + + /* find the policy handle. open a policy on it. */ + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid)) + return NT_STATUS_INVALID_HANDLE; + + sid_copy(&als_sid, &alias_sid); + sid_to_string(alias_sid_str, &alias_sid); + sid_split_rid(&alias_sid, &alias_rid); + + DEBUG(10, ("sid is %s\n", alias_sid_str)); + + if (sid_equal(&alias_sid, &global_sid_Builtin)) { + DEBUG(10, ("lookup on Builtin SID (S-1-5-32)\n")); + if(!get_builtin_group_from_sid(als_sid, &map)) + return NT_STATUS_NO_SUCH_ALIAS; + } else { + if (sid_equal(&alias_sid, &global_sam_sid)) { + DEBUG(10, ("lookup on Server SID\n")); + if(!get_local_group_from_sid(als_sid, &map)) + return NT_STATUS_NO_SUCH_ALIAS; + } + } + + if(!get_uid_list_of_group(map.gid, &uid, &num_uids)) + return NT_STATUS_NO_SUCH_ALIAS; + + DEBUG(10, ("sid is %s\n", alias_sid_str)); + sid = (DOM_SID2 *)talloc(p->mem_ctx, sizeof(DOM_SID2) * num_uids); + if (sid == NULL) + return NT_STATUS_NO_SUCH_ALIAS; + + for (i = 0; i < num_uids; i++) { + sid_copy(&temp_sid, &global_sam_sid); + sid_append_rid(&temp_sid, pdb_uid_to_user_rid(uid[i])); + + init_dom_sid2(&sid[i], &temp_sid); + } + + DEBUG(10, ("sid is %s\n", alias_sid_str)); + init_samr_r_query_aliasmem(r_u, num_uids, sid, NT_STATUS_NO_PROBLEMO); + + return NT_STATUS_NOPROBLEMO; } /********************************************************************* @@ -2326,8 +2393,56 @@ uint32 _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_ uint32 _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_QUERY_GROUPMEM *r_u) { - DEBUG(0,("_samr_query_groupmem: Not yet implemented.\n")); - return False; + int num_uids = 0; + int i; + DOM_SID group_sid; + uint32 group_rid; + fstring group_sid_str; + uid_t *uid=NULL; + + GROUP_MAP map; + + uint32 *rid=NULL; + uint32 *attr=NULL; + + + /* find the policy handle. open a policy on it. */ + if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid)) + return NT_STATUS_INVALID_HANDLE; + + /* todo: change to use sid_compare_front */ + + sid_split_rid(&group_sid, &group_rid); + sid_to_string(group_sid_str, &group_sid); + DEBUG(10, ("sid is %s\n", group_sid_str)); + + /* can we get a query for an SID outside our domain ? */ + if (!sid_equal(&group_sid, &global_sam_sid)) + return NT_STATUS_NO_SUCH_GROUP; + + sid_append_rid(&group_sid, group_rid); + DEBUG(10, ("lookup on Domain SID\n")); + + if(!get_domain_group_from_sid(group_sid, &map)) + return NT_STATUS_NO_SUCH_GROUP; + + if(!get_uid_list_of_group(map.gid, &uid, &num_uids)) + return NT_STATUS_NO_SUCH_GROUP; + + rid=talloc(p->mem_ctx, sizeof(uint32)*num_uids); + attr=talloc(p->mem_ctx, sizeof(uint32)*num_uids); + + if (rid==NULL || attr==NULL) + return NT_STATUS_NO_MEMORY; + + for (i=0; ialias_pol, &alias_sid)) + return NT_STATUS_INVALID_HANDLE; + + sid_to_string(alias_sid_str, &alias_sid); + DEBUG(10, ("sid is %s\n", alias_sid_str)); + + if (sid_compare(&alias_sid, &global_sam_sid)>0) { + DEBUG(10, ("adding member on Server SID\n")); + if(!get_local_group_from_sid(alias_sid, &map)) + return NT_STATUS_NO_SUCH_ALIAS; + + } else { + if (sid_compare(&alias_sid, &global_sid_Builtin)>0) { + DEBUG(10, ("adding member on BUILTIN SID\n")); + if( !get_builtin_group_from_sid(alias_sid, &map)) + return NT_STATUS_NO_SUCH_ALIAS; + + } else + return NT_STATUS_NO_SUCH_ALIAS; + } + + sid_split_rid(&q_u->sid.sid, &rid); + uid=pdb_user_rid_to_uid(rid); + + if ((pwd=getpwuid(uid)) == NULL) + return NT_STATUS_NO_SUCH_USER; + + if ((grp=getgrgid(map.gid)) == NULL) + return NT_STATUS_NO_SUCH_ALIAS; + + /* we need to copy the name otherwise it's overloaded in user_in_group_list */ + fstrcpy(grp_name, grp->gr_name); + + /* if the user is already in the group */ + if(user_in_group_list(pwd->pw_name, grp_name)) + return NT_STATUS_MEMBER_IN_ALIAS; + + /* + * ok, the group exist, the user exist, the user is not in the group, + * we can (finally) add it to the group ! + */ + smb_add_user_group(grp_name, pwd->pw_name); + + /* check if the user has been added then ... */ + if(!user_in_group_list(pwd->pw_name, grp_name)) + return NT_STATUS_MEMBER_NOT_IN_ALIAS; /* don't know what to reply else */ + + return NT_STATUS_NOPROBLEMO; } /********************************************************************* @@ -2356,8 +2527,54 @@ uint32 _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DEL_ uint32 _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_ADD_GROUPMEM *r_u) { - DEBUG(0,("_samr_add_groupmem: Not yet implemented.\n")); - return False; + DOM_SID group_sid; + fstring group_sid_str; + struct passwd *pwd; + struct group *grp; + fstring grp_name; + GROUP_MAP map; + + /* Find the policy handle. Open a policy on it. */ + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) + return NT_STATUS_INVALID_HANDLE; + + sid_to_string(group_sid_str, &group_sid); + DEBUG(10, ("sid is %s\n", group_sid_str)); + + if (sid_compare(&group_sid, &global_sam_sid)<=0) + return NT_STATUS_NO_SUCH_GROUP; + + DEBUG(10, ("lookup on Domain SID\n")); + + if(!get_domain_group_from_sid(group_sid, &map)) + return NT_STATUS_NO_SUCH_GROUP; + + if ((pwd=getpwuid(pdb_user_rid_to_uid(q_u->rid))) ==NULL) + return NT_STATUS_NO_SUCH_USER; + + if ((grp=getgrgid(map.gid)) == NULL) + return NT_STATUS_NO_SUCH_GROUP; + + /* we need to copy the name otherwise it's overloaded in user_in_group_list */ + fstrcpy(grp_name, grp->gr_name); + + /* if the user is already in the group */ + if(user_in_group_list(pwd->pw_name, grp_name)) + return NT_STATUS_MEMBER_IN_GROUP; + + /* + * ok, the group exist, the user exist, the user is not in the group, + * + * we can (finally) add it to the group ! + */ + + smb_add_user_group(grp_name, pwd->pw_name); + + /* check if the user has been added then ... */ + if(!user_in_group_list(pwd->pw_name, grp_name)) + return NT_STATUS_MEMBER_NOT_IN_GROUP; /* don't know what to reply else */ + + return NT_STATUS_NOPROBLEMO; } /********************************************************************* @@ -2406,8 +2623,55 @@ uint32 _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, SAM uint32 _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, SAMR_R_CREATE_DOM_GROUP *r_u) { - DEBUG(0,("_samr_create_dom_group: Not yet implemented.\n")); - return False; + DOM_SID dom_sid; + DOM_SID info_sid; + fstring name; + fstring sid_string; + struct group *grp; + struct samr_info *info; + + /* Find the policy handle. Open a policy on it. */ + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid)) + return NT_STATUS_INVALID_HANDLE; + + if (!sid_equal(&dom_sid, &global_sam_sid)) + return NT_STATUS_ACCESS_DENIED; + + /* TODO: check if allowed to create group and add a become_root/unbecome_root pair.*/ + + unistr2_to_ascii(name, &q_u->uni_acct_desc, sizeof(name)-1); + + /* check if group already exist */ + if ((grp=getgrnam(name)) != NULL) + return NT_STATUS_GROUP_EXISTS; + + /* we can create the UNIX group */ + smb_create_group(name); + + /* check if the group has been successfully created */ + if ((grp=getgrnam(name)) == NULL) + return NT_STATUS_ACCESS_DENIED; + + r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); + + /* add the group to the mapping table */ + if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_DOM_GRP, name, NULL, SE_PRIV_NONE)) + return NT_STATUS_ACCESS_DENIED; + + if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(info); + + sid_copy(&info_sid, &global_sam_sid); + sid_append_rid(&info->sid, r_u->rid); + sid_to_string(sid_string, &info->sid); + + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->pol, free_samr_info, (void *)info)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + return NT_STATUS_NOPROBLEMO; } /********************************************************************* @@ -2416,28 +2680,137 @@ uint32 _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, SAM uint32 _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, SAMR_R_CREATE_DOM_ALIAS *r_u) { - DEBUG(0,("_samr_create_dom_alias: Not yet implemented.\n")); - return False; + DOM_SID dom_sid; + fstring name; + fstring sid_string; + struct group *grp; + struct samr_info *info; + + /* Find the policy handle. Open a policy on it. */ + if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid)) + return NT_STATUS_INVALID_HANDLE; + + if (!sid_equal(&dom_sid, &global_sam_sid)) + return NT_STATUS_ACCESS_DENIED; + + /* TODO: check if allowed to create group and add a become_root/unbecome_root pair.*/ + + unistr2_to_ascii(name, &q_u->uni_acct_desc, sizeof(name)-1); + + /* check if group already exists */ + if ( (grp=getgrnam(name)) != NULL) + return NT_STATUS_GROUP_EXISTS; + + /* we can create the UNIX group */ + smb_create_group(name); + + /* check if the group has been successfully created */ + if ((grp=getgrnam(name)) == NULL) + return NT_STATUS_ACCESS_DENIED; + + r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); + + /* add the group to the mapping table */ + if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_ALIAS, NULL, NULL, SE_PRIV_NONE)) + return NT_STATUS_ACCESS_DENIED; + + if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(info); + + sid_copy(&info->sid, &global_sam_sid); + sid_append_rid(&info->sid, r_u->rid); + sid_to_string(sid_string, &info->sid); + + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->alias_pol, free_samr_info, (void *)info)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + return NT_STATUS_NOPROBLEMO; } /********************************************************************* _samr_query_groupinfo + +sends the name/comment pair of a domain group +level 1 send also the number of users of that group *********************************************************************/ uint32 _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAMR_R_QUERY_GROUPINFO *r_u) { - DEBUG(0,("_samr_query_groupinfo: Not yet implemented.\n")); - return False; + DOM_SID group_sid; + GROUP_MAP map; + uid_t *uid; + int num_uids=0; + GROUP_INFO_CTR *ctr; + + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) + return NT_STATUS_INVALID_HANDLE; + + if (!get_domain_group_from_sid(group_sid, &map)) + return NT_STATUS_INVALID_HANDLE; + + ctr=(GROUP_INFO_CTR *)talloc(p->mem_ctx, sizeof(GROUP_INFO_CTR)); + if (ctr==NULL) + return NT_STATUS_NO_MEMORY; + + switch (q_u->switch_level) { + case 1: + ctr->switch_value1 = 1; + if(!get_uid_list_of_group(map.gid, &uid, &num_uids)) + return NT_STATUS_NO_SUCH_GROUP; + init_samr_group_info1(&ctr->group.info1, map.nt_name, map.comment, num_uids); + safe_free(uid); + break; + case 4: + ctr->switch_value1 = 4; + init_samr_group_info4(&ctr->group.info4, map.comment); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + } + + init_samr_r_query_groupinfo(r_u, ctr, NT_STATUS_NO_PROBLEMO); + + return NT_STATUS_NO_PROBLEMO; } /********************************************************************* _samr_set_groupinfo + + update a domain group's comment. *********************************************************************/ uint32 _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_SET_GROUPINFO *r_u) { - DEBUG(0,("_samr_set_groupinfo: Not yet implemented.\n")); - return False; + DOM_SID group_sid; + GROUP_MAP map; + GROUP_INFO_CTR *ctr; + + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) + return NT_STATUS_INVALID_HANDLE; + + if (!get_domain_group_from_sid(group_sid, &map)) + return NT_STATUS_NO_SUCH_GROUP; + + ctr=q_u->ctr; + + switch (ctr->switch_value1) { + case 1: + unistr2_to_ascii(map.comment, &(ctr->group.info1.uni_acct_desc), sizeof(map.comment)-1); + break; + case 4: + unistr2_to_ascii(map.comment, &(ctr->group.info4.uni_acct_desc), sizeof(map.comment)-1); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + } + + if(!add_mapping_entry(&map, TDB_REPLACE)) + return NT_STATUS_NO_SUCH_GROUP; + + return NT_STATUS_NO_PROBLEMO; } /********************************************************************* @@ -2456,8 +2829,38 @@ uint32 _samr_get_dom_pwinfo(pipes_struct *p, SAMR_Q_GET_DOM_PWINFO *q_u, SAMR_R_ uint32 _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_GROUP *r_u) { - DEBUG(0,("_samr_open_group: Not yet implemented.\n")); - return False; + DOM_SID sid; + GROUP_MAP map; + struct samr_info *info; + fstring sid_string; + + if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid)) + return NT_STATUS_INVALID_HANDLE; + + /* this should not be hard-coded like this */ + if (!sid_equal(&sid, &global_sam_sid)) + return NT_STATUS_ACCESS_DENIED; + + if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(info); + + sid_copy(&info->sid, &global_sam_sid); + sid_append_rid(&info->sid, q_u->rid_group); + sid_to_string(sid_string, &info->sid); + + DEBUG(10, ("Opening SID: %s\n", sid_string)); + + /* check if that group really exists */ + if (!get_domain_group_from_sid(info->sid, &map)) + return NT_STATUS_NO_SUCH_USER; + + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->pol, free_samr_info, (void *)info)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + return NT_STATUS_NO_PROBLEMO; } /********************************************************************* -- cgit From da8805b377e361a7cab399b3c786a25f7175e7cf Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 23 Mar 2001 02:14:08 +0000 Subject: groupdb/mapping.c: include/proto.h: Fix missing (void) in proto. rpc_server/srv_samr_nt.c: Fix user private group problem by filtering out groups that clash with users. smbd/posix_acls.c: Ensure default ACE's are sensible. utils/pdbedit.c: Fix from Simo Sorce. Jeremy. (This used to be commit 29414fe0d6665642d9b5f88a35e712426376c47f) --- source3/rpc_server/srv_samr_nt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 94524da352..2434fad74a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -798,10 +798,20 @@ static BOOL get_group_alias_entries(DOMAIN_GRP *d_grp, DOM_SID *sid, uint32 star uint32 trid; name = grp->gr_name; + DEBUG(10,("get_group_alias_entries: got group %s\n", name )); + /* Don't return winbind groups as they are not local! */ - if (strchr(name, *sep) != NULL) + if (strchr(name, *sep) != NULL) { + DEBUG(10,("get_group_alias_entries: not returing %s, not local.\n", name )); continue; + } + + /* Don't return user private groups... */ + if (Get_Pwnam(name, False) != 0) { + DEBUG(10,("get_group_alias_entries: not returing %s, clashes with user.\n", name )); + continue; + } trid = pdb_gid_to_group_rid(grp->gr_gid); for( i = 0; i < num_entries; i++) -- cgit From 25d975e5500243dff4918fe04416695cd3e79a72 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 27 Mar 2001 18:19:01 +0000 Subject: merge from 2.2. (This used to be commit 817258f1174d27d74e8b21ffb5f1384db2238007) --- source3/rpc_server/srv_spoolss.c | 20 ++++++++++---------- source3/rpc_server/srv_spoolss_nt.c | 32 ++++++++++++++++---------------- 2 files changed, 26 insertions(+), 26 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index e8f855f7f1..ddd8255139 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -307,8 +307,8 @@ static BOOL api_spoolss_enumprinters(pipes_struct *p) r_u.status = _spoolss_enumprinters( p, &q_u, &r_u); - if (!new_spoolss_io_r_enumprinters("", &r_u, rdata, 0)) { - DEBUG(0,("new_spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n")); + if (!spoolss_io_r_enumprinters("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n")); return False; } @@ -712,7 +712,7 @@ static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p) r_u.status = _spoolss_enumprinterdrivers(p, &q_u, &r_u); - if (!new_spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) { + if (!spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n")); return False; } @@ -740,8 +740,8 @@ static BOOL api_spoolss_getform(pipes_struct *p) r_u.status = _spoolss_getform(p, &q_u, &r_u); - if (!new_spoolss_io_r_getform("",&r_u,rdata,0)) { - DEBUG(0,("new_spoolss_io_r_getform: unable to marshall SPOOL_R_GETFORM.\n")); + if (!spoolss_io_r_getform("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_getform: unable to marshall SPOOL_R_GETFORM.\n")); return False; } @@ -766,10 +766,10 @@ static BOOL api_spoolss_enumforms(pipes_struct *p) return False; } - r_u.status = _new_spoolss_enumforms(p, &q_u, &r_u); + r_u.status = _spoolss_enumforms(p, &q_u, &r_u); - if (!new_spoolss_io_r_enumforms("",&r_u,rdata,0)) { - DEBUG(0,("new_spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n")); + if (!spoolss_io_r_enumforms("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n")); return False; } @@ -796,8 +796,8 @@ static BOOL api_spoolss_enumports(pipes_struct *p) r_u.status = _spoolss_enumports(p, &q_u, &r_u); - if (!new_spoolss_io_r_enumports("",&r_u,rdata,0)) { - DEBUG(0,("new_spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n")); + if (!spoolss_io_r_enumports("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n")); return False; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 804fe8a523..5234fa3366 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3103,7 +3103,7 @@ uint32 _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ fstring name; /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + spoolss_move_buffer(q_u->buffer, &r_u->buffer); buffer = r_u->buffer; DEBUG(4,("_spoolss_enumprinters\n")); @@ -3284,7 +3284,7 @@ uint32 _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET int snum; /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + spoolss_move_buffer(q_u->buffer, &r_u->buffer); buffer = r_u->buffer; *needed=0; @@ -3796,7 +3796,7 @@ uint32 _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ int snum; /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + spoolss_move_buffer(q_u->buffer, &r_u->buffer); buffer = r_u->buffer; DEBUG(4,("_spoolss_getprinterdriver2\n")); @@ -4631,7 +4631,7 @@ uint32 _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) uint32 _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u) { /* that's an [in out] buffer (despite appearences to the contrary) */ - new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + spoolss_move_buffer(q_u->buffer, &r_u->buffer); r_u->needed = 0; return ERROR_INVALID_PARAMETER; /* this is what a NT server @@ -4838,7 +4838,7 @@ uint32 _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO print_status_struct prt_status; /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + spoolss_move_buffer(q_u->buffer, &r_u->buffer); buffer = r_u->buffer; DEBUG(4,("_spoolss_enumjobs\n")); @@ -5180,7 +5180,7 @@ uint32 _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS fstring architecture; /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + spoolss_move_buffer(q_u->buffer, &r_u->buffer); buffer = r_u->buffer; DEBUG(4,("_spoolss_enumprinterdrivers\n")); @@ -5222,7 +5222,7 @@ static void fill_form_1(FORM_1 *form, nt_forms_struct *list) /**************************************************************************** ****************************************************************************/ -uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u) +uint32 _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u) { /* POLICY_HND *handle = &q_u->handle; - notused. */ uint32 level = q_u->level; @@ -5237,10 +5237,10 @@ uint32 _new_spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_E int i; /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + spoolss_move_buffer(q_u->buffer, &r_u->buffer); buffer = r_u->buffer; - DEBUG(4,("_new_spoolss_enumforms\n")); + DEBUG(4,("_spoolss_enumforms\n")); DEBUGADD(5,("Offered buffer size [%d]\n", offered)); DEBUGADD(5,("Info level [%d]\n", level)); @@ -5318,7 +5318,7 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * int numofforms, i; /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + spoolss_move_buffer(q_u->buffer, &r_u->buffer); buffer = r_u->buffer; unistr2_to_ascii(form_name, uni_formname, sizeof(form_name)-1); @@ -5603,7 +5603,7 @@ uint32 _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUM uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + spoolss_move_buffer(q_u->buffer, &r_u->buffer); buffer = r_u->buffer; DEBUG(4,("_spoolss_enumports\n")); @@ -5822,7 +5822,7 @@ uint32 _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRI uint32 *needed = &r_u->needed; /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + spoolss_move_buffer(q_u->buffer, &r_u->buffer); buffer = r_u->buffer; DEBUG(4,("_spoolss_getprinterdriverdirectory\n")); @@ -6260,7 +6260,7 @@ uint32 _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + spoolss_move_buffer(q_u->buffer, &r_u->buffer); buffer = r_u->buffer; DEBUG(5,("spoolss_enumprintprocessors\n")); @@ -6328,7 +6328,7 @@ uint32 _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDAT uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + spoolss_move_buffer(q_u->buffer, &r_u->buffer); buffer = r_u->buffer; DEBUG(5,("_spoolss_enumprintprocdatatypes\n")); @@ -6422,7 +6422,7 @@ uint32 _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_ uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + spoolss_move_buffer(q_u->buffer, &r_u->buffer); buffer = r_u->buffer; DEBUG(5,("spoolss_enumprintmonitors\n")); @@ -6572,7 +6572,7 @@ uint32 _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ print_status_struct prt_status; /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + spoolss_move_buffer(q_u->buffer, &r_u->buffer); buffer = r_u->buffer; DEBUG(5,("spoolss_getjob\n")); -- cgit From 738a83a14f1eba8fceeec41ab81c7e9da944ccda Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 28 Mar 2001 16:08:00 +0000 Subject: rename of 16 new_smb_io functions to smb_io_* for consistency sake (merge from 2.2) (This used to be commit ea963a648b889da9e47661c61c7fafe13b277e75) --- source3/rpc_server/srv_spoolss_nt.c | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5234fa3366..1360e14db0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2853,7 +2853,7 @@ static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 of /* fill the buffer with the structures */ for (i=0; i<*returned; i++) - new_smb_io_printer_info_1("", buffer, &printers[i], 0); + smb_io_printer_info_1("", buffer, &printers[i], 0); /* clear memory */ safe_free(printers); @@ -2935,7 +2935,7 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui } /* fill the buffer with the structures */ - new_smb_io_printer_info_1("", buffer, printer, 0); + smb_io_printer_info_1("", buffer, printer, 0); /* clear memory */ safe_free(printer); @@ -3001,7 +3001,7 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 /* fill the buffer with the structures */ for (i=0; i<*returned; i++) - new_smb_io_printer_info_2("", buffer, &(printers[i]), 0); + smb_io_printer_info_2("", buffer, &(printers[i]), 0); /* clear memory */ for (i=0; i<*returned; i++) { @@ -3161,7 +3161,7 @@ static uint32 getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, u } /* fill the buffer with the structures */ - new_smb_io_printer_info_0("", buffer, printer, 0); + smb_io_printer_info_0("", buffer, printer, 0); /* clear memory */ safe_free(printer); @@ -3193,7 +3193,7 @@ static uint32 getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, u } /* fill the buffer with the structures */ - new_smb_io_printer_info_1("", buffer, printer, 0); + smb_io_printer_info_1("", buffer, printer, 0); /* clear memory */ safe_free(printer); @@ -3225,7 +3225,7 @@ static uint32 getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, u } /* fill the buffer with the structures */ - if (!new_smb_io_printer_info_2("", buffer, printer, 0)) { + if (!smb_io_printer_info_2("", buffer, printer, 0)) { free_printer_info_2(printer); return ERROR_NOT_ENOUGH_MEMORY; } @@ -3258,7 +3258,7 @@ static uint32 getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, u } /* fill the buffer with the structures */ - new_smb_io_printer_info_3("", buffer, printer, 0); + smb_io_printer_info_3("", buffer, printer, 0); /* clear memory */ free_printer_info_3(printer); @@ -3662,7 +3662,7 @@ static uint32 getprinterdriver2_level1(fstring servername, fstring architecture, } /* fill the buffer with the structures */ - new_smb_io_printer_driver_info_1("", buffer, info, 0); + smb_io_printer_driver_info_1("", buffer, info, 0); /* clear memory */ safe_free(info); @@ -3698,7 +3698,7 @@ static uint32 getprinterdriver2_level2(fstring servername, fstring architecture, } /* fill the buffer with the structures */ - new_smb_io_printer_driver_info_2("", buffer, info, 0); + smb_io_printer_driver_info_2("", buffer, info, 0); /* clear memory */ safe_free(info); @@ -3732,7 +3732,7 @@ static uint32 getprinterdriver2_level3(fstring servername, fstring architecture, } /* fill the buffer with the structures */ - new_smb_io_printer_driver_info_3("", buffer, &info, 0); + smb_io_printer_driver_info_3("", buffer, &info, 0); free_printer_driver_info_3(&info); @@ -3765,7 +3765,7 @@ static uint32 getprinterdriver2_level6(fstring servername, fstring architecture, } /* fill the buffer with the structures */ - new_smb_io_printer_driver_info_6("", buffer, &info, 0); + smb_io_printer_driver_info_6("", buffer, &info, 0); free_printer_driver_info_6(&info); @@ -4750,7 +4750,7 @@ static uint32 enumjobs_level1(print_queue_struct *queue, int snum, /* fill the buffer with the structures */ for (i=0; i<*returned; i++) - new_smb_io_job_info_1("", buffer, &info[i], 0); + smb_io_job_info_1("", buffer, &info[i], 0); /* clear memory */ safe_free(info); @@ -4802,7 +4802,7 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum, /* fill the buffer with the structures */ for (i=0; i<*returned; i++) - new_smb_io_job_info_2("", buffer, &info[i], 0); + smb_io_job_info_2("", buffer, &info[i], 0); /* clear memory */ for (i = 0; i < *returned; i++) @@ -4993,7 +4993,7 @@ static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture /* fill the buffer with the driver structures */ for (i=0; i<*returned; i++) { DEBUGADD(6,("adding driver [%d] to buffer\n",i)); - new_smb_io_printer_driver_info_1("", buffer, &driver_info_1[i], 0); + smb_io_printer_driver_info_1("", buffer, &driver_info_1[i], 0); } safe_free(driver_info_1); @@ -5069,7 +5069,7 @@ static uint32 enumprinterdrivers_level2(fstring servername, fstring architecture /* fill the buffer with the form structures */ for (i=0; i<*returned; i++) { DEBUGADD(6,("adding driver [%d] to buffer\n",i)); - new_smb_io_printer_driver_info_2("", buffer, &(driver_info_2[i]), 0); + smb_io_printer_driver_info_2("", buffer, &(driver_info_2[i]), 0); } safe_free(driver_info_2); @@ -5145,7 +5145,7 @@ static uint32 enumprinterdrivers_level3(fstring servername, fstring architecture /* fill the buffer with the driver structures */ for (i=0; i<*returned; i++) { DEBUGADD(6,("adding driver [%d] to buffer\n",i)); - new_smb_io_printer_driver_info_3("", buffer, &driver_info_3[i], 0); + smb_io_printer_driver_info_3("", buffer, &driver_info_3[i], 0); } for (i=0; i<*returned; i++) @@ -5280,7 +5280,7 @@ uint32 _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF /* fill the buffer with the form structures */ for (i=0; i<*numofforms; i++) { DEBUGADD(6,("adding form [%d] to buffer\n",i)); - new_smb_io_form_1("", buffer, &forms_1[i], 0); + smb_io_form_1("", buffer, &forms_1[i], 0); } safe_free(forms_1); @@ -5364,7 +5364,7 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * /* fill the buffer with the form structures */ DEBUGADD(6,("adding form %s [%d] to buffer\n", form_name, i)); - new_smb_io_form_1("", buffer, &form_1, 0); + smb_io_form_1("", buffer, &form_1, 0); return NT_STATUS_NO_PROBLEMO; @@ -5477,7 +5477,7 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need /* fill the buffer with the ports structures */ for (i=0; i<*returned; i++) { DEBUGADD(6,("adding port [%d] to buffer\n", i)); - new_smb_io_port_1("", buffer, &ports[i], 0); + smb_io_port_1("", buffer, &ports[i], 0); } safe_free(ports); @@ -5576,7 +5576,7 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need /* fill the buffer with the ports structures */ for (i=0; i<*returned; i++) { DEBUGADD(6,("adding port [%d] to buffer\n", i)); - new_smb_io_port_2("", buffer, &ports[i], 0); + smb_io_port_2("", buffer, &ports[i], 0); } safe_free(ports); @@ -5799,7 +5799,7 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen return ERROR_INSUFFICIENT_BUFFER; } - new_smb_io_driverdir_1("", buffer, info, 0); + smb_io_driverdir_1("", buffer, info, 0); safe_free(info); @@ -6485,7 +6485,7 @@ static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uin return ERROR_INSUFFICIENT_BUFFER; } - new_smb_io_job_info_1("", buffer, info_1, 0); + smb_io_job_info_1("", buffer, info_1, 0); safe_free(info_1); @@ -6543,7 +6543,7 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin return ERROR_INSUFFICIENT_BUFFER; } - new_smb_io_job_info_2("", buffer, info_2, 0); + smb_io_job_info_2("", buffer, info_2, 0); free_job_info_2(info_2); free(info_2); -- cgit From 9f793948bd34e79be1adecfe41c53cb7ec2636fa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 2 Apr 2001 22:27:40 +0000 Subject: include/ntdomain.h: rpc_server/srv_lsa_hnd.c: Remove back pointer from policy handle list as the pipe that opened the handle may have been closed. We were dereferencing into something that had been closed. rpc_parse/parse_spoolss.c: Sync up with Gerald's changes in 2.2. lib/replace.c: Don't do proto on setlinebuf as it differs between systems. Jeremy. (This used to be commit 887ef3e12dc56b89b2284d42b16a81f03e15110b) --- source3/rpc_server/srv_lsa_hnd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index d0a26abc6b..393f50a498 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -109,7 +109,6 @@ BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *) ZERO_STRUCTP(pol); - pol->p = p; pol->data_ptr = data_ptr; pol->free_fn = free_fn; @@ -189,9 +188,9 @@ BOOL close_policy_hnd(pipes_struct *p, POLICY_HND *hnd) if (pol->free_fn && pol->data_ptr) (*pol->free_fn)(pol->data_ptr); - pol->p->pipe_handles->count--; + p->pipe_handles->count--; - DLIST_REMOVE(pol->p->pipe_handles->Policy, pol); + DLIST_REMOVE(p->pipe_handles->Policy, pol); ZERO_STRUCTP(pol); -- cgit From 24a4483a9c77041d5c188935cbf688f25f1f2f54 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 3 Apr 2001 22:52:38 +0000 Subject: test commit for jeremy (This used to be commit d747ab8ab37ca20635f99a9dff64a635461852a6) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1360e14db0..f01de4570c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -41,7 +41,7 @@ extern pstring global_myname; typedef struct _Printer{ BOOL document_started; BOOL page_started; - int jobid; /* jobid in printing backend */ + int jobid; /* jobid in printing backend */ BOOL printer_type; union { fstring handlename; -- cgit From 5948fa9fe1992b54378e73f9bd17ef64f6b96ece Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 3 Apr 2001 23:09:04 +0000 Subject: Missed forms update - my CVS mistake. Jeremy. (This used to be commit 06dee898607ff2bf194d53fb55ad6d82e8f305e8) --- source3/rpc_server/srv_spoolss_nt.c | 91 ++++++++++++++++++++++++++++--------- 1 file changed, 70 insertions(+), 21 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f01de4570c..90147c868a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -41,7 +41,7 @@ extern pstring global_myname; typedef struct _Printer{ BOOL document_started; BOOL page_started; - int jobid; /* jobid in printing backend */ + int jobid; /* jobid in printing backend */ BOOL printer_type; union { fstring handlename; @@ -5230,8 +5230,10 @@ uint32 _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *numofforms = &r_u->numofforms; + uint32 numbuiltinforms; nt_forms_struct *list=NULL; + nt_forms_struct *builtinlist=NULL; FORM_1 *forms_1; int buffer_size=0; int i; @@ -5244,8 +5246,11 @@ uint32 _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF DEBUGADD(5,("Offered buffer size [%d]\n", offered)); DEBUGADD(5,("Info level [%d]\n", level)); + numbuiltinforms = get_builtin_ntforms(&builtinlist); + DEBUGADD(5,("Number of builtin forms [%d]\n", numbuiltinforms)); *numofforms = get_ntforms(&list); - DEBUGADD(5,("Number of forms [%d]\n", *numofforms)); + DEBUGADD(5,("Number of user forms [%d]\n", *numofforms)); + *numofforms += numbuiltinforms; if (*numofforms == 0) return ERROR_NO_MORE_ITEMS; @@ -5257,15 +5262,26 @@ uint32 _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF } /* construct the list of form structures */ - for (i=0; i<*numofforms; i++) { + for (i=0; ineeded; nt_forms_struct *list=NULL; + nt_forms_struct builtin_form; + BOOL foundBuiltin; FORM_1 form_1; fstring form_name; int buffer_size=0; @@ -5327,29 +5350,38 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * DEBUGADD(5,("Offered buffer size [%d]\n", offered)); DEBUGADD(5,("Info level [%d]\n", level)); - numofforms = get_ntforms(&list); - DEBUGADD(5,("Number of forms [%d]\n", numofforms)); + foundBuiltin = get_a_builtin_ntform(uni_formname,&builtin_form); + if (!foundBuiltin) { + numofforms = get_ntforms(&list); + DEBUGADD(5,("Number of forms [%d]\n", numofforms)); - if (numofforms == 0) - return ERROR_NO_MORE_ITEMS; + if (numofforms == 0) + return ERROR_INVALID_HANDLE; + } switch (level) { case 1: + if (foundBuiltin) { + fill_form_1(&form_1, &builtin_form); + } else { - /* Check if the requested name is in the list of form structures */ - for (i=0; ihandle; /* uint32 level = q_u->level; - notused. */ FORM *form = &q_u->form; + nt_forms_struct tmpForm; int count=0; nt_forms_struct *list=NULL; @@ -6147,6 +6180,11 @@ uint32 _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM return ERROR_INVALID_HANDLE; } + /* can't add if builtin */ + if (get_a_builtin_ntform(&form->name,&tmpForm)) { + return ERROR_INVALID_PARAMETER; + } + count=get_ntforms(&list); if(!add_a_form(&list, form, &count)) return ERROR_NOT_ENOUGH_MEMORY; @@ -6164,7 +6202,7 @@ uint32 _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE { POLICY_HND *handle = &q_u->handle; UNISTR2 *form_name = &q_u->name; - + nt_forms_struct tmpForm; int count=0; uint32 ret = 0; nt_forms_struct *list=NULL; @@ -6177,6 +6215,11 @@ uint32 _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE return ERROR_INVALID_HANDLE; } + /* can't delete if builtin */ + if (get_a_builtin_ntform(form_name,&tmpForm)) { + return ERROR_INVALID_PARAMETER; + } + count = get_ntforms(&list); if(!delete_a_form(&list, form_name, &count, &ret)) return ERROR_INVALID_PARAMETER; @@ -6195,6 +6238,7 @@ uint32 _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * /* UNISTR2 *uni_name = &q_u->name; - notused. */ /* uint32 level = q_u->level; - notused. */ FORM *form = &q_u->form; + nt_forms_struct tmpForm; int count=0; nt_forms_struct *list=NULL; @@ -6206,6 +6250,11 @@ uint32 _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * DEBUG(0,("_spoolss_setform: Invalid handle (%s).\n", OUR_HANDLE(handle))); return ERROR_INVALID_HANDLE; } + /* can't set if builtin */ + if (get_a_builtin_ntform(&form->name,&tmpForm)) { + return ERROR_INVALID_PARAMETER; + } + count=get_ntforms(&list); update_a_form(&list, form, count); write_ntforms(&list, count); -- cgit From 852242a1b53069e5e6c8861f8243fe4a5016001a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 4 Apr 2001 23:42:17 +0000 Subject: I know we're supposed to be feature frozen, but I couldn't resist this... :-). I worked out and added the per-share get/set RPCs for security descriptors. Currently this code returns Everyone, full access on get and permission denied on set, but backending this with a tdb and checking it on tconX (to give full NT semantics for security on shares) is now an excersise for the reader... :-). Jeremy. (This used to be commit 3bfd155ba78798c50588904d4ea3389f50f8abb6) --- source3/rpc_server/srv_srvsvc.c | 31 ++++++++ source3/rpc_server/srv_srvsvc_nt.c | 152 +++++++++++++++++++++++++++++++++++-- 2 files changed, 176 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index a3176bfd73..76e6be2ec1 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -197,6 +197,36 @@ static BOOL api_srv_net_share_get_info(pipes_struct *p) return True; } +/******************************************************************* + RPC to set share information. +********************************************************************/ + +static BOOL api_srv_net_share_set_info(pipes_struct *p) +{ + SRV_Q_NET_SHARE_SET_INFO q_u; + SRV_R_NET_SHARE_SET_INFO r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server set info. */ + if(!srv_io_q_net_share_set_info("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_share_set_info: Failed to unmarshall SRV_Q_NET_SHARE_SET_INFO.\n")); + return False; + } + + r_u.status = _srv_net_share_set_info(p, &q_u, &r_u); + + if(!srv_io_r_net_share_set_info("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_set_info: Failed to marshall SRV_R_NET_SHARE_SET_INFO.\n")); + return False; + } + + return True; +} + /******************************************************************* api_srv_net_remote_tod ********************************************************************/ @@ -234,6 +264,7 @@ struct api_struct api_srv_cmds[] = { "SRV_NETSESSENUM" , SRV_NETSESSENUM , api_srv_net_sess_enum }, { "SRV_NETSHAREENUM" , SRV_NETSHAREENUM , api_srv_net_share_enum }, { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info }, + { "SRV_NET_SHARE_SET_INFO", SRV_NET_SHARE_SET_INFO, api_srv_net_share_set_info }, { "SRV_NETFILEENUM" , SRV_NETFILEENUM , api_srv_net_file_enum }, { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 061c70454f..4d6d7518bf 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -93,6 +93,73 @@ static void init_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, int snum) init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); } +/******************************************************************* + Fake up a Everyone, full access for now. + ********************************************************************/ + +static SEC_DESC *get_share_security( TALLOC_CTX *ctx, int snum, size_t *psize) +{ + extern DOM_SID global_sid_World; + SEC_ACCESS sa; + SEC_ACE ace; + SEC_ACL *psa = NULL; + SEC_DESC *psd = NULL; + + init_sec_access(&sa, GENERIC_ALL_ACCESS ); + init_sec_ace(&ace, &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, sa, 0); + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 1, &ace)) != NULL) { + psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, psize); + } + + if (!psd) { + DEBUG(0,("get_share_security: Failed to make SEC_DESC.\n")); + return NULL; + } + + return psd; +} + +/******************************************************************* + 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) +{ + int len_net_name; + pstring net_name; + pstring remark; + pstring path; + pstring passwd; + uint32 type; + SEC_DESC *sd; + size_t sd_size; + + ZERO_STRUCTP(sh502); + + pstrcpy(net_name, lp_servicename(snum)); + pstrcpy(remark, lp_comment(snum)); + pstring_sub(remark,"%S",lp_servicename(snum)); + pstrcpy(path, lp_pathname(snum)); + pstrcpy(passwd, ""); + len_net_name = strlen(net_name); + + /* work out the share type */ + type = STYPE_DISKTREE; + + if (lp_print_ok(snum)) + type = STYPE_PRINTQ; + if (strequal("IPC$", net_name)) + type = STYPE_IPC; + if (net_name[len_net_name] == '$') + type |= STYPE_HIDDEN; + + sd = get_share_security(ctx, snum, &sd_size); + + init_srv_share_info502(&sh502->info_502, net_name, type, remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size); + init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, path, passwd, sd, sd_size); +} + /*************************************************************************** Fill in a share info level 1005 structure. ***************************************************************************/ @@ -174,6 +241,23 @@ static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr, break; } + case 502: + { + SRV_SHARE_INFO_502 *info502; + int i = 0; + + info502 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_502)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum)) { + init_srv_share_info_502(ctx, &info502[i++], snum); + } + } + + ctr->share.info502 = info502; + break; + } + default: DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level)); return False; @@ -205,7 +289,7 @@ 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(SRV_R_NET_SHARE_GET_INFO *r_n, +static void init_srv_r_net_share_get_info(TALLOC_CTX *ctx, SRV_R_NET_SHARE_GET_INFO *r_n, char *share_name, uint32 info_level) { uint32 status = NT_STATUS_NOPROBLEMO; @@ -213,20 +297,23 @@ static void init_srv_r_net_share_get_info(SRV_R_NET_SHARE_GET_INFO *r_n, DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__)); - r_n->switch_value = info_level; + r_n->info.switch_value = info_level; snum = find_service(share_name); if (snum >= 0) { switch (info_level) { case 1: - init_srv_share_info_1(&r_n->share.info1, snum); + init_srv_share_info_1(&r_n->info.share.info1, snum); break; case 2: - init_srv_share_info_2(&r_n->share.info2, snum); + init_srv_share_info_2(&r_n->info.share.info2, snum); + break; + case 502: + init_srv_share_info_502(ctx, &r_n->info.share.info502, snum); break; case 1005: - init_srv_share_info_1005(&r_n->share.info1005, snum); + init_srv_share_info_1005(&r_n->info.share.info1005, snum); break; default: DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level)); @@ -237,7 +324,7 @@ static void init_srv_r_net_share_get_info(SRV_R_NET_SHARE_GET_INFO *r_n, status = NT_STATUS_BAD_NETWORK_NAME; } - r_n->ptr_share_ctr = (status == NT_STATUS_NOPROBLEMO) ? 1 : 0; + r_n->info.ptr_share_ctr = (status == NT_STATUS_NOPROBLEMO) ? 1 : 0; r_n->status = status; } @@ -815,13 +902,64 @@ 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. */ share_name = dos_unistr2_to_str(&q_u->uni_share_name); - init_srv_r_net_share_get_info(r_u, share_name, q_u->info_level); + init_srv_r_net_share_get_info(p->mem_ctx, r_u, share_name, q_u->info_level); DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); return r_u->status; } +/******************************************************************* + Net share set info. +********************************************************************/ + +uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) +{ + char *share_name; + uint32 status = NT_STATUS_NOPROBLEMO; + int snum; + + DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); + + share_name = dos_unistr2_to_str(&q_u->uni_share_name); + + r_u->switch_value = q_u->info_level; + + snum = find_service(share_name); + + /* For now we only handle setting the security descriptor. JRA. */ + + if (snum >= 0) { + switch (q_u->info_level) { + case 1: + status = NT_STATUS_ACCESS_DENIED; + break; + case 2: + status = NT_STATUS_ACCESS_DENIED; + break; + case 502: + /* we set sd's here. FIXME. JRA */ + status = NT_STATUS_ACCESS_DENIED; + break; + case 1005: + status = NT_STATUS_ACCESS_DENIED; + break; + default: + DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", q_u->info_level)); + status = NT_STATUS_INVALID_INFO_CLASS; + break; + } + } else { + status = NT_STATUS_BAD_NETWORK_NAME; + } + + r_u->status = status; + + DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); + + return r_u->status; +} + /******************************************************************* time of day ********************************************************************/ -- cgit From 529f7c07f507f186c599826d0b10d10c131ff902 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 6 Apr 2001 01:39:12 +0000 Subject: We can now use server manager to look at Samba shares. NT still expects a ":" in the path though.... I'm looking into it. Jeremy. (This used to be commit a152c2c59a9a8972a3c73287e26e4de2f49c2d65) --- source3/rpc_server/srv_srvsvc.c | 31 +++++++++++++++++++++++++ source3/rpc_server/srv_srvsvc_nt.c | 46 +++++++++++++++++++++++++++++++------- 2 files changed, 69 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 76e6be2ec1..95896f36c8 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -141,6 +141,36 @@ static BOOL api_srv_net_sess_enum(pipes_struct *p) RPC to enumerate shares. ********************************************************************/ +static BOOL api_srv_net_share_enum_all(pipes_struct *p) +{ + SRV_Q_NET_SHARE_ENUM q_u; + SRV_R_NET_SHARE_ENUM r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server get enum. */ + if(!srv_io_q_net_share_enum("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_share_enum_all: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n")); + return False; + } + + r_u.status = _srv_net_share_enum_all(p, &q_u, &r_u); + + if (!srv_io_r_net_share_enum("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_enum_all: Failed to marshall SRV_R_NET_SHARE_ENUM.\n")); + return False; + } + + return True; +} + +/******************************************************************* + RPC to enumerate shares. +********************************************************************/ + static BOOL api_srv_net_share_enum(pipes_struct *p) { SRV_Q_NET_SHARE_ENUM q_u; @@ -262,6 +292,7 @@ struct api_struct api_srv_cmds[] = { { "SRV_NETCONNENUM" , SRV_NETCONNENUM , api_srv_net_conn_enum }, { "SRV_NETSESSENUM" , SRV_NETSESSENUM , api_srv_net_sess_enum }, + { "SRV_NETSHAREENUM_ALL" , SRV_NETSHAREENUM_ALL , api_srv_net_share_enum_all }, { "SRV_NETSHAREENUM" , SRV_NETSHAREENUM , api_srv_net_share_enum }, { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info }, { "SRV_NET_SHARE_SET_INFO", SRV_NET_SHARE_SET_INFO, api_srv_net_share_set_info }, diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 4d6d7518bf..5c0bdf57cb 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -175,12 +175,24 @@ static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum) } +/******************************************************************* + True if it ends in '$'. + ********************************************************************/ + +static BOOL is_admin_share(int snum) +{ + pstring net_name; + + pstrcpy(net_name, lp_servicename(snum)); + return (net_name[strlen(net_name)] == '$') ? True : False; +} + /******************************************************************* Fill in a share info structure. ********************************************************************/ static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr, - uint32 info_level, uint32 *resume_hnd, uint32 *total_entries) + uint32 info_level, uint32 *resume_hnd, uint32 *total_entries, BOOL all_shares) { int num_entries = 0; int num_services = lp_numservices(); @@ -195,7 +207,7 @@ static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr, /* Count the number of entries. */ for (snum = 0; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum)) + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) num_entries++; } @@ -215,7 +227,7 @@ static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr, info1 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1)); for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum)) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) { init_srv_share_info_1(&info1[i++], snum); } } @@ -232,7 +244,7 @@ static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr, info2 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_2)); for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum)) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) { init_srv_share_info_2(&info2[i++], snum); } } @@ -249,7 +261,7 @@ static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr, info502 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_502)); for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum)) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) { init_srv_share_info_502(ctx, &info502[i++], snum); } } @@ -271,12 +283,12 @@ static BOOL init_srv_share_info_ctr(TALLOC_CTX *ctx, SRV_SHARE_INFO_CTR *ctr, ********************************************************************/ static void init_srv_r_net_share_enum(TALLOC_CTX *ctx, SRV_R_NET_SHARE_ENUM *r_n, - uint32 info_level, uint32 resume_hnd) + 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, - &resume_hnd, &r_n->total_entries)) { + &resume_hnd, &r_n->total_entries, all)) { r_n->status = NT_STATUS_NOPROBLEMO; } else { r_n->status = NT_STATUS_INVALID_INFO_CLASS; @@ -872,6 +884,24 @@ uint32 _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_S return r_u->status; } +/******************************************************************* + Net share enum all. +********************************************************************/ + +uint32 _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) +{ + 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, + q_u->ctr.info_level, + get_enum_hnd(&q_u->enum_hnd), True); + + DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); + + return r_u->status; +} + /******************************************************************* Net share enum. ********************************************************************/ @@ -883,7 +913,7 @@ uint32 _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET /* Create the list of shares for the response. */ init_srv_r_net_share_enum(p->mem_ctx, r_u, q_u->ctr.info_level, - get_enum_hnd(&q_u->enum_hnd)); + get_enum_hnd(&q_u->enum_hnd), False); DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); -- cgit From 68c8638b36b5326a33f0c7ce09cdb8d400495de3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 6 Apr 2001 02:12:07 +0000 Subject: NT sucks ! :-). We have to prefix the UNIX path with a C: in order to pass the server manager tests :-). Ensure we don't set a return level on set as server manager barfs.... Jeremy. (This used to be commit cb66e78c181878809e367f4f03f3b4c31cb4b8e1) --- source3/rpc_server/srv_srvsvc_nt.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 5c0bdf57cb..82a299d18e 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -75,7 +75,8 @@ 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)); - pstrcpy(path, lp_pathname(snum)); + pstrcpy(path, "C:"); + pstrcat(path, lp_pathname(snum)); pstrcpy(passwd, ""); len_net_name = strlen(net_name); @@ -140,7 +141,8 @@ static void init_srv_share_info_502(TALLOC_CTX *ctx, SRV_SHARE_INFO_502 *sh502, pstrcpy(net_name, lp_servicename(snum)); pstrcpy(remark, lp_comment(snum)); pstring_sub(remark,"%S",lp_servicename(snum)); - pstrcpy(path, lp_pathname(snum)); + pstrcpy(path, "C:"); + pstrcat(path, lp_pathname(snum)); pstrcpy(passwd, ""); len_net_name = strlen(net_name); @@ -962,17 +964,17 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if (snum >= 0) { switch (q_u->info_level) { case 1: - status = NT_STATUS_ACCESS_DENIED; + status = ERROR_ACCESS_DENIED; break; case 2: - status = NT_STATUS_ACCESS_DENIED; + status = ERROR_ACCESS_DENIED; break; case 502: /* we set sd's here. FIXME. JRA */ - status = NT_STATUS_ACCESS_DENIED; + status = ERROR_ACCESS_DENIED; break; case 1005: - status = NT_STATUS_ACCESS_DENIED; + status = ERROR_ACCESS_DENIED; break; default: DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", q_u->info_level)); @@ -983,6 +985,7 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S status = NT_STATUS_BAD_NETWORK_NAME; } + r_u->switch_value = 0; r_u->status = status; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); -- cgit From 3874261774ef9b56461602b4aea3cf4e7b9cc5a0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 6 Apr 2001 17:41:47 +0000 Subject: Added stub function for NET_SHARE_ADD. Once this is implemented to call a hook function (same for NET_SHARE_DELETE and NET_SHARE_SET) we will be able to manage the shares section in smb.conf via NT server manager........ This should enhance the friendliness of Samba in NT-only shops by an order of magnitude. Jeremy. (This used to be commit a2cd5f2ba11164a17622b96374ab43070f9ed691) --- source3/rpc_server/srv_srvsvc.c | 31 +++++++++++++++++++++++++++++ source3/rpc_server/srv_srvsvc_nt.c | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 95896f36c8..d588298c88 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -257,6 +257,36 @@ static BOOL api_srv_net_share_set_info(pipes_struct *p) return True; } +/******************************************************************* + RPC to add share information. Use the SET wire format. +********************************************************************/ + +static BOOL api_srv_net_share_add(pipes_struct *p) +{ + SRV_Q_NET_SHARE_ADD q_u; + SRV_R_NET_SHARE_ADD r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server add info. */ + if(!srv_io_q_net_share_add("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_share_add: Failed to unmarshall SRV_Q_NET_SHARE_ADD.\n")); + return False; + } + + r_u.status = _srv_net_share_add(p, &q_u, &r_u); + + if(!srv_io_r_net_share_add("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_add: Failed to marshall SRV_R_NET_SHARE_ADD.\n")); + return False; + } + + return True; +} + /******************************************************************* api_srv_net_remote_tod ********************************************************************/ @@ -294,6 +324,7 @@ struct api_struct api_srv_cmds[] = { "SRV_NETSESSENUM" , SRV_NETSESSENUM , api_srv_net_sess_enum }, { "SRV_NETSHAREENUM_ALL" , SRV_NETSHAREENUM_ALL , api_srv_net_share_enum_all }, { "SRV_NETSHAREENUM" , SRV_NETSHAREENUM , api_srv_net_share_enum }, + { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info }, { "SRV_NET_SHARE_SET_INFO", SRV_NET_SHARE_SET_INFO, api_srv_net_share_set_info }, { "SRV_NETFILEENUM" , SRV_NETFILEENUM , api_srv_net_file_enum }, diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 82a299d18e..acb8846db6 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -993,6 +993,46 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return r_u->status; } +/******************************************************************* + Net share add. Stub for now. JRA. +********************************************************************/ + +uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) +{ + uint32 status = NT_STATUS_NOPROBLEMO; + + DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); + + r_u->switch_value = q_u->info_level; + + switch (q_u->info_level) { + case 1: + status = ERROR_ACCESS_DENIED; + break; + case 2: + status = ERROR_ACCESS_DENIED; + break; + case 502: + /* we set sd's here. FIXME. JRA */ + status = ERROR_ACCESS_DENIED; + break; + case 1005: + status = ERROR_ACCESS_DENIED; + break; + default: + DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", q_u->info_level)); + status = NT_STATUS_INVALID_INFO_CLASS; + break; + } + + r_u->switch_value = 0; + r_u->status = status; + + DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); + + return r_u->status; +} + /******************************************************************* time of day ********************************************************************/ -- cgit From 97cf9d3a3de4d005477ee07423b7d9c34d6d1761 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 6 Apr 2001 18:25:17 +0000 Subject: Implemented stub function for NET_SHARE_DELETE. Now to implement the real internals to support server manager. Jeremy (This used to be commit 3512ba1f655d5588db87f1afa1d12f599ad7b74a) --- source3/rpc_server/srv_srvsvc.c | 33 ++++++++++++++++++++++++++++++++- source3/rpc_server/srv_srvsvc_nt.c | 29 +++++++++++++++++++++++++---- 2 files changed, 57 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index d588298c88..d4d5e1bfe8 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -258,7 +258,7 @@ static BOOL api_srv_net_share_set_info(pipes_struct *p) } /******************************************************************* - RPC to add share information. Use the SET wire format. + RPC to add share information. ********************************************************************/ static BOOL api_srv_net_share_add(pipes_struct *p) @@ -287,6 +287,36 @@ static BOOL api_srv_net_share_add(pipes_struct *p) return True; } +/******************************************************************* + RPC to delete share information. +********************************************************************/ + +static BOOL api_srv_net_share_del(pipes_struct *p) +{ + SRV_Q_NET_SHARE_DEL q_u; + SRV_R_NET_SHARE_DEL r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server del info. */ + if(!srv_io_q_net_share_del("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_share_del: Failed to unmarshall SRV_Q_NET_SHARE_DEL.\n")); + return False; + } + + r_u.status = _srv_net_share_del(p, &q_u, &r_u); + + if(!srv_io_r_net_share_del("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_del: Failed to marshall SRV_R_NET_SHARE_DEL.\n")); + return False; + } + + return True; +} + /******************************************************************* api_srv_net_remote_tod ********************************************************************/ @@ -325,6 +355,7 @@ struct api_struct api_srv_cmds[] = { "SRV_NETSHAREENUM_ALL" , SRV_NETSHAREENUM_ALL , api_srv_net_share_enum_all }, { "SRV_NETSHAREENUM" , SRV_NETSHAREENUM , api_srv_net_share_enum }, { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, + { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del }, { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info }, { "SRV_NET_SHARE_SET_INFO", SRV_NET_SHARE_SET_INFO, api_srv_net_share_set_info }, { "SRV_NETFILEENUM" , SRV_NETFILEENUM , api_srv_net_file_enum }, diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index acb8846db6..0e03918bfb 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -955,7 +955,7 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S share_name = dos_unistr2_to_str(&q_u->uni_share_name); - r_u->switch_value = q_u->info_level; + r_u->switch_value = 0; snum = find_service(share_name); @@ -985,7 +985,6 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S status = NT_STATUS_BAD_NETWORK_NAME; } - r_u->switch_value = 0; r_u->status = status; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); @@ -1003,7 +1002,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__)); - r_u->switch_value = q_u->info_level; + r_u->switch_value = 0; switch (q_u->info_level) { case 1: @@ -1025,7 +1024,6 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S break; } - r_u->switch_value = 0; r_u->status = status; DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); @@ -1033,6 +1031,29 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S return r_u->status; } +/******************************************************************* + Net share delete. Stub for now. JRA. +********************************************************************/ + +uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) +{ + char *share_name; + uint32 status = NT_STATUS_NOPROBLEMO; + int snum; + + DEBUG(5,("_srv_net_share_del: %d\n", __LINE__)); + + share_name = dos_unistr2_to_str(&q_u->uni_share_name); + + snum = find_service(share_name); + + if (snum < 0) + return NT_STATUS_BAD_NETWORK_NAME; + + /* Stub... */ + return ERROR_ACCESS_DENIED; +} + /******************************************************************* time of day ********************************************************************/ -- cgit From 950f1d9605179d75ab0755cecffbabbde769beb9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 7 Apr 2001 00:36:38 +0000 Subject: Added 3 params to manipulate shares. "add share command/change share command/ delete share command". Implemented "delete" - more work to come on add and change. Jeremy. (This used to be commit 2e6b1759e14456421066ee131af70a495f862f2b) --- source3/rpc_server/srv_pipe.c | 16 +++++++ source3/rpc_server/srv_spoolss_nt.c | 16 ------- source3/rpc_server/srv_srvsvc_nt.c | 95 ++++++++++++++++++++++++++++++++----- 3 files changed, 98 insertions(+), 29 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index bc5b2ab473..32ec81b07a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1103,6 +1103,22 @@ BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) return True; } +/**************************************************************************** + Return a user struct for a pipe user. +****************************************************************************/ + +struct current_user *get_current_user(struct current_user *user, pipes_struct *p) +{ + if (p->ntlmssp_auth_validated) { + memcpy(user, &p->pipe_user, sizeof(struct current_user)); + } else { + extern struct current_user current_user; + memcpy(user, ¤t_user, sizeof(struct current_user)); + } + + return user; +} + /**************************************************************************** Find the correct RPC function to call for this request. If the pipe is authenticated then become the correct UNIX user diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 90147c868a..c75af92902 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -222,22 +222,6 @@ SPOOL_NOTIFY_OPTION *dup_spool_notify_option(SPOOL_NOTIFY_OPTION *sp) return new_sp; } -/**************************************************************************** - Return a user struct for a pipe user. -****************************************************************************/ - -static struct current_user *get_current_user(struct current_user *user, pipes_struct *p) -{ - if (p->ntlmssp_auth_validated) { - memcpy(user, &p->pipe_user, sizeof(struct current_user)); - } else { - extern struct current_user current_user; - memcpy(user, ¤t_user, sizeof(struct current_user)); - } - - return user; -} - /**************************************************************************** find printer index by handle ****************************************************************************/ diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 0e03918bfb..fb911a0d85 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -928,12 +928,12 @@ uint32 _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET uint32 _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, SRV_R_NET_SHARE_GET_INFO *r_u) { - char *share_name; + fstring share_name; DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); /* Create the list of shares for the response. */ - share_name = dos_unistr2_to_str(&q_u->uni_share_name); + 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); DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); @@ -947,13 +947,16 @@ uint32 _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, S uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) { - char *share_name; + fstring share_name; uint32 status = NT_STATUS_NOPROBLEMO; int snum; + fstring servicename; + fstring comment; + pstring pathname; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); - share_name = dos_unistr2_to_str(&q_u->uni_share_name); + unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); r_u->switch_value = 0; @@ -993,29 +996,51 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S } /******************************************************************* - Net share add. Stub for now. JRA. + Net share add. Call 'add_share_command "sharename" "pathname" "comment"' ********************************************************************/ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) { + struct current_user user; + pstring command; uint32 status = NT_STATUS_NOPROBLEMO; + fstring share_name; + fstring comment; + pstring pathname; + char *ptr; + int type; + int snum; DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); r_u->switch_value = 0; + get_current_user(&user,p); + + if (user.uid != 0) + return ERROR_ACCESS_DENIED; + + if (!lp_add_share_cmd()) + return ERROR_ACCESS_DENIED; + switch (q_u->info_level) { case 1: + /* Not enough info in a level 1 to do anything. */ status = ERROR_ACCESS_DENIED; break; case 2: - status = ERROR_ACCESS_DENIED; + 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)); + unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name)); break; case 502: /* we set sd's here. FIXME. JRA */ - status = ERROR_ACCESS_DENIED; + unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name)); + unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name)); + unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name)); break; case 1005: + /* DFS only level. */ status = ERROR_ACCESS_DENIED; break; default: @@ -1024,6 +1049,26 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S break; } + snum = find_service(share_name); + + /* Share already exists. */ + if (snum >= 0) + return NT_STATUS_BAD_NETWORK_NAME; + + /* Convert any '\' paths to '/' */ + unix_format(pathname); + unix_clean_name(pathname); + + /* NT is braindead - it wants a C: prefix to a pathname ! */ + ptr = pathname; + if (strlen(pathname) > 2 && ptr[1] == ':' && ptr[0] != '/') + ptr += 2; + + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\"", + lp_add_share_cmd(), share_name, ptr, comment ); + +/* HERE ! JRA */ + r_u->status = status; DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); @@ -1032,26 +1077,50 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S } /******************************************************************* - Net share delete. Stub for now. JRA. + Net share delete. Call "delete share command" with the share name as + a parameter. ********************************************************************/ uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) { - char *share_name; - uint32 status = NT_STATUS_NOPROBLEMO; + struct current_user user; + pstring command; + fstring share_name; + int ret; int snum; DEBUG(5,("_srv_net_share_del: %d\n", __LINE__)); - share_name = dos_unistr2_to_str(&q_u->uni_share_name); + unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); snum = find_service(share_name); if (snum < 0) return NT_STATUS_BAD_NETWORK_NAME; - /* Stub... */ - return ERROR_ACCESS_DENIED; + get_current_user(&user,p); + + if (user.uid != 0) + return ERROR_ACCESS_DENIED; + + if (!lp_delete_share_cmd()) + return ERROR_ACCESS_DENIED; + + slprintf(command, sizeof(command)-1, "%s \"%s\"", lp_delete_share_cmd(), 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, False)) != 0) { + DEBUG(0,("_srv_net_share_del: Running [%s] returned (%d)\n", command, ret )); + return ERROR_ACCESS_DENIED; + } + + /* Send SIGHUP to process group. */ + kill(0, SIGHUP); + + lp_killservice(snum); + + return NT_STATUS_NOPROBLEMO; } /******************************************************************* -- cgit From 8e9d11f0144a5e216197ed419ffd4883736edd3c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 7 Apr 2001 18:46:47 +0000 Subject: Fixed up the "add" command - although not SD's yet. Now for the SD db and the "change" command. Jeremy. (This used to be commit bdec63bedbeabb9d74d68a7f03254acc291df76b) --- source3/rpc_server/srv_srvsvc_nt.c | 93 ++++++++++++++++++++++++++++++-------- 1 file changed, 74 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index fb911a0d85..1bff054aa4 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -950,9 +950,11 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S fstring share_name; uint32 status = NT_STATUS_NOPROBLEMO; int snum; +#if 0 fstring servicename; fstring comment; pstring pathname; +#endif DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); @@ -995,6 +997,49 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return r_u->status; } +/******************************************************************* + Check a given DOS pathname is valid for a share. +********************************************************************/ + +static char *valid_share_pathname(char *dos_pathname) +{ + pstring saved_pathname; + pstring unix_pathname; + char *ptr; + int ret; + + /* Convert any '\' paths to '/' */ + unix_format(dos_pathname); + unix_clean_name(dos_pathname); + + /* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */ + ptr = dos_pathname; + if (strlen(dos_pathname) > 2 && ptr[1] == ':' && ptr[0] != '/') + ptr += 2; + + /* Only abolute paths allowed. */ + if (*ptr != '/') + return NULL; + + /* Can we cd to it ? */ + + /* First save our current directory. */ + 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); + + /* We *MUST* be able to chdir back. Abort if we can't. */ + if (chdir(saved_pathname) == -1) + smb_panic("valid_share_pathname: Unable to restore current directory.\n"); + + return (ret != -1) ? ptr : NULL; +} + /******************************************************************* Net share add. Call 'add_share_command "sharename" "pathname" "comment"' ********************************************************************/ @@ -1003,13 +1048,13 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S { struct current_user user; pstring command; - uint32 status = NT_STATUS_NOPROBLEMO; fstring share_name; fstring comment; pstring pathname; - char *ptr; int type; int snum; + int ret; + char *ptr; DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); @@ -1026,27 +1071,26 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S switch (q_u->info_level) { case 1: /* Not enough info in a level 1 to do anything. */ - status = ERROR_ACCESS_DENIED; - break; + return ERROR_ACCESS_DENIED; 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)); unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name)); + type = q_u->info.share.info2.info_2.type; break; case 502: /* we set sd's here. FIXME. JRA */ unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name)); unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name)); unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name)); + type = q_u->info.share.info502.info_502.type; break; case 1005: /* DFS only level. */ - status = ERROR_ACCESS_DENIED; - break; + return ERROR_ACCESS_DENIED; default: DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", q_u->info_level)); - status = NT_STATUS_INVALID_INFO_CLASS; - break; + return NT_STATUS_INVALID_INFO_CLASS; } snum = find_service(share_name); @@ -1055,25 +1099,36 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S if (snum >= 0) return NT_STATUS_BAD_NETWORK_NAME; - /* Convert any '\' paths to '/' */ - unix_format(pathname); - unix_clean_name(pathname); - - /* NT is braindead - it wants a C: prefix to a pathname ! */ - ptr = pathname; - if (strlen(pathname) > 2 && ptr[1] == ':' && ptr[0] != '/') - ptr += 2; + /* We can only add disk shares. */ + if (type != STYPE_DISKTREE) + return ERROR_ACCESS_DENIED; + + /* Check if the pathname is valid. */ + if (!(ptr = valid_share_pathname( pathname ))) + return ERRbadpath; slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\"", lp_add_share_cmd(), share_name, ptr, comment ); + dos_to_unix(command, True); /* Convert to unix-codepage */ -/* HERE ! JRA */ + DEBUG(10,("_srv_net_share_add: Running [%s]\n", command )); + if ((ret = smbrun(command, NULL, False)) != 0) { + DEBUG(0,("_srv_net_share_add: Running [%s] returned (%d)\n", command, ret )); + return ERROR_ACCESS_DENIED; + } - r_u->status = status; + /* Send SIGHUP to process group. */ + kill(0, SIGHUP); + + /* + * We don't call reload_services() here, the SIGHUP will + * cause this to be done before the next packet is read + * from the client. JRA. + */ DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); - return r_u->status; + return NT_STATUS_NOPROBLEMO; } /******************************************************************* -- cgit From 607d5d508d091d6c9b9cd6549b2a89f7359d780c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 8 Apr 2001 20:01:51 +0000 Subject: Added per-share security tdb. Tidied up many slprintfs (need -1 on length). Jeremy. (This used to be commit d786191bc116c17a3f53a1c272d969942b7e5d25) --- source3/rpc_server/srv_srvsvc_nt.c | 258 ++++++++++++++++++++++++++++--------- 1 file changed, 198 insertions(+), 60 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 1bff054aa4..5c1c16c02a 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -95,10 +95,43 @@ static void init_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, int snum) } /******************************************************************* - Fake up a Everyone, full access for now. + Create the share security tdb. ********************************************************************/ -static SEC_DESC *get_share_security( TALLOC_CTX *ctx, int snum, size_t *psize) +static TDB_CONTEXT *share_tdb; /* used for share security descriptors */ +#define SHARE_DATABASE_VERSION 1 + +BOOL share_info_db_init(void) +{ + static pid_t local_pid; + char *vstring = "INFO/version"; + + if (share_tdb && local_pid == sys_getpid()) return True; + share_tdb = tdb_open(lock_path("share_info.tdb"), 0, 0, 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) )); + return False; + } + + local_pid = sys_getpid(); + + /* handle a Samba upgrade */ + tdb_lock_bystring(share_tdb, vstring); + if (tdb_fetch_int(share_tdb, vstring) != SHARE_DATABASE_VERSION) { + tdb_traverse(share_tdb, (tdb_traverse_func)tdb_delete, NULL); + tdb_store_int(share_tdb, vstring, SHARE_DATABASE_VERSION); + } + tdb_unlock_bystring(share_tdb, vstring); + + return True; +} + +/******************************************************************* + Fake up a Everyone, full access as a default. + ********************************************************************/ + +static SEC_DESC *get_share_security_default( TALLOC_CTX *ctx, int snum, size_t *psize) { extern DOM_SID global_sid_World; SEC_ACCESS sa; @@ -121,6 +154,94 @@ static SEC_DESC *get_share_security( TALLOC_CTX *ctx, int snum, size_t *psize) return psd; } +/******************************************************************* + Pull a security descriptor from the share tdb. + ********************************************************************/ + +SEC_DESC *get_share_security( TALLOC_CTX *ctx, int snum, size_t *psize) +{ + prs_struct ps; + fstring key; + SEC_DESC *psd; + + /* Fetch security descriptor from tdb */ + + slprintf(key, sizeof(key)-1, "SECDESC/%s", lp_servicename(snum)); + + if (tdb_prs_fetch(share_tdb, key, &ps, ctx)!=0 || + !sec_io_desc("get_share_security", &psd, &ps, 1)) { + + DEBUG(4,("get_share_security: using default secdesc for %s\n", lp_servicename(snum) )); + + return get_share_security_default(ctx, snum, psize); + } + + prs_mem_free(&ps); + return psd; +} + +/******************************************************************* + Store a security descriptor in the share db. + ********************************************************************/ + +static BOOL set_share_security(TALLOC_CTX *ctx, int snum, SEC_DESC *psd) +{ + prs_struct ps; + TALLOC_CTX *mem_ctx = NULL; + fstring key; + BOOL ret = False; + + mem_ctx = talloc_init(); + if (mem_ctx == NULL) + return False; + + prs_init(&ps, (uint32)sec_desc_size(psd), mem_ctx, MARSHALL); + + if (!sec_io_desc("nt_printing_setsec", &psd, &ps, 1)) { + goto out; + } + + slprintf(key, sizeof(key)-1, "SECDESC/%s", lp_servicename(snum)); + + if (tdb_prs_store(share_tdb, key, &ps)==0) { + ret = True; + DEBUG(5,("set_share_security: stored secdesc for %s\n", lp_servicename(snum) )); + } else { + DEBUG(1,("set_share_security: Failed to store secdesc for %s\n", lp_servicename(snum) )); + } + + /* Free malloc'ed memory */ + + out: + + prs_mem_free(&ps); + if (mem_ctx) + talloc_destroy(mem_ctx); + return ret; +} + +/******************************************************************* + Delete a security descriptor. +********************************************************************/ + +static BOOL delete_share_security(int snum) +{ + TDB_DATA kbuf; + fstring key; + + slprintf(key, sizeof(key)-1, "SECDESC/%s", lp_servicename(snum)); + kbuf.dptr = key; + kbuf.dsize = strlen(key)+1; + + if (tdb_delete(share_tdb, kbuf) != 0) { + DEBUG(0,("delete_share_security: Failed to delete entry for share %s\n", + lp_servicename(snum) )); + return False; + } + + return True; +} + /******************************************************************* Fill in a share info level 502 structure. ********************************************************************/ @@ -941,62 +1062,6 @@ uint32 _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, S return r_u->status; } -/******************************************************************* - Net share set info. -********************************************************************/ - -uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) -{ - fstring share_name; - uint32 status = NT_STATUS_NOPROBLEMO; - int snum; -#if 0 - fstring servicename; - fstring comment; - pstring pathname; -#endif - - DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); - - unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); - - r_u->switch_value = 0; - - snum = find_service(share_name); - - /* For now we only handle setting the security descriptor. JRA. */ - - if (snum >= 0) { - switch (q_u->info_level) { - case 1: - status = ERROR_ACCESS_DENIED; - break; - case 2: - status = ERROR_ACCESS_DENIED; - break; - case 502: - /* we set sd's here. FIXME. JRA */ - status = ERROR_ACCESS_DENIED; - break; - case 1005: - status = ERROR_ACCESS_DENIED; - break; - default: - DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", q_u->info_level)); - status = NT_STATUS_INVALID_INFO_CLASS; - break; - } - } else { - status = NT_STATUS_BAD_NETWORK_NAME; - } - - r_u->status = status; - - DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); - - return r_u->status; -} - /******************************************************************* Check a given DOS pathname is valid for a share. ********************************************************************/ @@ -1040,6 +1105,68 @@ static char *valid_share_pathname(char *dos_pathname) return (ret != -1) ? ptr : NULL; } +/******************************************************************* + Net share set info. Modify share details. +********************************************************************/ + +uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) +{ + struct current_user user; + pstring command; + fstring share_name; + fstring comment; + pstring pathname; + int type; + int snum; + int ret; + char *ptr; + BOOL read_only; + + DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); + + unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); + + r_u->switch_value = 0; + + snum = find_service(share_name); + + /* Does this share exist ? */ + if (snum < 0) + return NT_STATUS_BAD_NETWORK_NAME; + + get_current_user(&user,p); + + if (user.uid != 0) + return ERROR_ACCESS_DENIED; + + if (!lp_change_share_cmd()) + return ERROR_ACCESS_DENIED; + + switch (q_u->info_level) { + case 1: + return ERROR_ACCESS_DENIED; + break; + case 2: + return ERROR_ACCESS_DENIED; + break; + case 502: + /* we set sd's here. FIXME. JRA */ + return ERROR_ACCESS_DENIED; + break; + case 1005: + return ERROR_ACCESS_DENIED; + break; + default: + DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", q_u->info_level)); + return NT_STATUS_INVALID_INFO_CLASS; + break; + } + + DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); + + return NT_STATUS_NOPROBLEMO; +} + /******************************************************************* Net share add. Call 'add_share_command "sharename" "pathname" "comment"' ********************************************************************/ @@ -1055,6 +1182,7 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S int snum; int ret; char *ptr; + BOOL read_only = False; DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); @@ -1077,6 +1205,7 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S 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)); type = q_u->info.share.info2.info_2.type; + read_only = False; /* No SD means "Everyone full access. */ break; case 502: /* we set sd's here. FIXME. JRA */ @@ -1107,8 +1236,14 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S if (!(ptr = valid_share_pathname( pathname ))) return ERRbadpath; - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\"", - lp_add_share_cmd(), share_name, ptr, comment ); + /* Ensure share name, pathname and comment don't contain '"' characters. */ + string_replace(share_name, '"', ' '); + string_replace(ptr, '"', ' '); + string_replace(comment, '"', ' '); + + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", + lp_add_share_cmd(), share_name, ptr, comment, + read_only ? "read only = yes" : "read only = no" ); dos_to_unix(command, True); /* Convert to unix-codepage */ DEBUG(10,("_srv_net_share_add: Running [%s]\n", command )); @@ -1170,6 +1305,9 @@ uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S return ERROR_ACCESS_DENIED; } + /* Delete the SD in the database. */ + delete_share_security(snum); + /* Send SIGHUP to process group. */ kill(0, SIGHUP); -- cgit From f9a15ce1a69f905e94db7650f0a4805720cd9c88 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 8 Apr 2001 20:22:39 +0000 Subject: Got "medieval on our ass" about adding the -1 to slprintf. Jeremy. (This used to be commit 94747b4639ed9b19f7d0fb896e43aa392a84989a) --- source3/rpc_server/srv_pipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 32ec81b07a..0654f24493 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1171,7 +1171,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, /* interpret the command */ DEBUG(4,("api_rpcTNP: %s op 0x%x - ", rpc_name, p->hdr_req.opnum)); - slprintf(name, sizeof(name), "in_%s", rpc_name); + slprintf(name, sizeof(name)-1, "in_%s", rpc_name); prs_dump(name, p->hdr_req.opnum, &p->in_data.data); for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) { @@ -1201,7 +1201,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, return False; } - slprintf(name, sizeof(name), "out_%s", rpc_name); + slprintf(name, sizeof(name)-1, "out_%s", rpc_name); offset2 = prs_offset(&p->out_data.rdata); prs_set_offset(&p->out_data.rdata, offset1); prs_dump(name, p->hdr_req.opnum, &p->out_data.rdata); -- cgit From 9d6dd97624f50dec3edd3bb9a3c0f7f47f9ae071 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Apr 2001 06:36:38 +0000 Subject: Added set/get SD's on shares. Check before tcon. Jeremy. (This used to be commit 036b1a8b09fe6a7cca83d631624145574acad7f2) --- source3/rpc_server/srv_srvsvc_nt.c | 159 +++++++++++++++++++++++++++++++++---- 1 file changed, 142 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 5c1c16c02a..4395a20e46 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -158,7 +158,7 @@ static SEC_DESC *get_share_security_default( TALLOC_CTX *ctx, int snum, size_t * Pull a security descriptor from the share tdb. ********************************************************************/ -SEC_DESC *get_share_security( TALLOC_CTX *ctx, int snum, size_t *psize) +static SEC_DESC *get_share_security( TALLOC_CTX *ctx, int snum, size_t *psize) { prs_struct ps; fstring key; @@ -184,7 +184,7 @@ SEC_DESC *get_share_security( TALLOC_CTX *ctx, int snum, size_t *psize) Store a security descriptor in the share db. ********************************************************************/ -static BOOL set_share_security(TALLOC_CTX *ctx, int snum, SEC_DESC *psd) +static BOOL set_share_security(TALLOC_CTX *ctx, const char *share_name, SEC_DESC *psd) { prs_struct ps; TALLOC_CTX *mem_ctx = NULL; @@ -201,13 +201,13 @@ static BOOL set_share_security(TALLOC_CTX *ctx, int snum, SEC_DESC *psd) goto out; } - slprintf(key, sizeof(key)-1, "SECDESC/%s", lp_servicename(snum)); + slprintf(key, sizeof(key)-1, "SECDESC/%s", share_name); if (tdb_prs_store(share_tdb, key, &ps)==0) { ret = True; - DEBUG(5,("set_share_security: stored secdesc for %s\n", lp_servicename(snum) )); + DEBUG(5,("set_share_security: stored secdesc for %s\n", share_name )); } else { - DEBUG(1,("set_share_security: Failed to store secdesc for %s\n", lp_servicename(snum) )); + DEBUG(1,("set_share_security: Failed to store secdesc for %s\n", share_name )); } /* Free malloc'ed memory */ @@ -242,6 +242,73 @@ static BOOL delete_share_security(int snum) return True; } +/******************************************************************* + Does this security descriptor map to a read only share ? +********************************************************************/ + +static BOOL read_only_share_sd(SEC_DESC *psd) +{ + int i; + SEC_ACL *ps_dacl = psd->dacl; + + if (!ps_dacl) + return True; + + for (i = 0; i < ps_dacl->num_aces; i++) { + SEC_ACE *psa = &ps_dacl->ace[i]; + + if (psa->type == SEC_ACE_TYPE_ACCESS_ALLOWED && + psa->info.mask & FILE_WRITE_DATA) + return False; + } + + return True; +} + +/******************************************************************* + Can this user access with share with the required permissions ? +********************************************************************/ + +BOOL share_access_check(int snum, uint16 vuid, uint32 desired_access) +{ + uint32 granted, status; + TALLOC_CTX *mem_ctx = NULL; + SEC_DESC *psd = NULL; + size_t sd_size; + struct current_user tmp_user; + struct current_user *puser = NULL; + user_struct *vuser = get_valid_user_struct(vuid); + BOOL ret = True; + + mem_ctx = talloc_init(); + if (mem_ctx == NULL) + return False; + + psd = get_share_security(mem_ctx, snum, &sd_size); + + if (!psd) + goto out; + + if (vuser) { + ZERO_STRUCT(tmp_user); + 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; + puser = &tmp_user; + } + + ret = se_access_check(psd, puser, desired_access, &granted, &status); + + out: + + talloc_destroy(mem_ctx); + + return ret; +} + /******************************************************************* Fill in a share info level 502 structure. ********************************************************************/ @@ -1120,7 +1187,8 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S int snum; int ret; char *ptr; - BOOL read_only; + SEC_DESC *psd = NULL; + BOOL read_only = False; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); @@ -1139,27 +1207,76 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if (user.uid != 0) return ERROR_ACCESS_DENIED; - if (!lp_change_share_cmd()) - return ERROR_ACCESS_DENIED; - switch (q_u->info_level) { case 1: + /* Not enough info in a level 1 to do anything. */ return ERROR_ACCESS_DENIED; - break; case 2: - return ERROR_ACCESS_DENIED; + 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)); + type = q_u->info.share.info2.info_2.type; + read_only = False; /* No SD means "Everyone full access. */ break; case 502: - /* we set sd's here. FIXME. JRA */ - return ERROR_ACCESS_DENIED; + unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name)); + unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name)); + type = q_u->info.share.info502.info_502.type; + psd = q_u->info.share.info502.info_502_str.sd; + read_only = read_only_share_sd(psd); break; case 1005: return ERROR_ACCESS_DENIED; - break; default: DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", q_u->info_level)); return NT_STATUS_INVALID_INFO_CLASS; - break; + } + + /* We can only modify disk shares. */ + if (type != STYPE_DISKTREE) + return ERROR_ACCESS_DENIED; + + /* Check if the pathname is valid. */ + if (!(ptr = valid_share_pathname( pathname ))) + return ERRbadpath; + + /* Ensure share name, pathname and comment don't contain '"' characters. */ + string_replace(share_name, '"', ' '); + string_replace(ptr, '"', ' '); + string_replace(comment, '"', ' '); + + /* Only call modify function if something changed. */ + + if (read_only != lp_readonly(snum) || strcmp(ptr, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) ) { + if (!lp_change_share_cmd()) + return ERROR_ACCESS_DENIED; + + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", + lp_change_share_cmd(), share_name, ptr, comment, + read_only ? "read only = yes" : "read only = no" ); + 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, False)) != 0) { + DEBUG(0,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret )); + return ERROR_ACCESS_DENIED; + } + + /* Send SIGHUP to process group. */ + kill(0, SIGHUP); + } + + /* Replace SD if changed. */ + if (psd) { + SEC_DESC *old_sd; + size_t sd_size; + + old_sd = get_share_security(p->mem_ctx, snum, &sd_size); + + if (old_sd && !sec_desc_equal(old_sd, psd)) { + if (!set_share_security(p->mem_ctx, share_name, psd)) + DEBUG(0,("_srv_net_share_set_info: Failed to change security info in share %s.\n", + share_name )); + } } DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); @@ -1168,7 +1285,7 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S } /******************************************************************* - Net share add. Call 'add_share_command "sharename" "pathname" "comment"' + Net share add. Call 'add_share_command "sharename" "pathname" "comment" "read only = xxx"' ********************************************************************/ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) @@ -1183,6 +1300,7 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S int ret; char *ptr; BOOL read_only = False; + SEC_DESC *psd = NULL; DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); @@ -1208,11 +1326,12 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S read_only = False; /* No SD means "Everyone full access. */ break; case 502: - /* we set sd's here. FIXME. JRA */ unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name)); unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name)); unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name)); type = q_u->info.share.info502.info_502.type; + psd = q_u->info.share.info502.info_502_str.sd; + read_only = read_only_share_sd(psd); break; case 1005: /* DFS only level. */ @@ -1252,6 +1371,12 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S return ERROR_ACCESS_DENIED; } + if (psd) { + if (!set_share_security(p->mem_ctx, share_name, psd)) + DEBUG(0,("_srv_net_share_add: Failed to add security info to share %s.\n", + share_name )); + } + /* Send SIGHUP to process group. */ kill(0, SIGHUP); -- cgit From 33706e48f072fa17363155de19650764c5aa4a84 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Apr 2001 07:03:28 +0000 Subject: Ensure Everyone/All access is mapped correctly to file generic perms to allow anonymous IPC access. Jeremy. (This used to be commit 2f34e144c53d6be911de96298c55c34d08c4733f) --- source3/rpc_server/srv_srvsvc_nt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 4395a20e46..e78968a6bb 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -134,12 +134,16 @@ BOOL share_info_db_init(void) static SEC_DESC *get_share_security_default( TALLOC_CTX *ctx, int snum, size_t *psize) { extern DOM_SID global_sid_World; + extern struct generic_mapping file_generic_mapping; SEC_ACCESS sa; SEC_ACE ace; SEC_ACL *psa = NULL; SEC_DESC *psd = NULL; + uint32 def_access = GENERIC_ALL_ACCESS; - init_sec_access(&sa, GENERIC_ALL_ACCESS ); + se_map_generic(&def_access, &file_generic_mapping); + + init_sec_access(&sa, GENERIC_ALL_ACCESS | def_access ); init_sec_ace(&ace, &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, sa, 0); if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 1, &ace)) != NULL) { -- cgit From 2b9e23855e6e4a20021bb7a1bb0df082efe4eac5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Apr 2001 08:00:19 +0000 Subject: Set SD's for share. Added level 1501. Map GENERIC file bits to specific bits. Jeremy. (This used to be commit 04976c32f319531e16d890797b45a76dab64f370) --- source3/rpc_server/srv_srvsvc_nt.c | 48 +++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index e78968a6bb..9860df6f62 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -253,8 +253,12 @@ static BOOL delete_share_security(int snum) static BOOL read_only_share_sd(SEC_DESC *psd) { int i; - SEC_ACL *ps_dacl = psd->dacl; + SEC_ACL *ps_dacl = NULL; + if (!psd) + return True; + + ps_dacl = psd->dacl; if (!ps_dacl) return True; @@ -269,6 +273,32 @@ static BOOL read_only_share_sd(SEC_DESC *psd) return True; } +/******************************************************************* + Map any generic bits to file specific bits. +********************************************************************/ + +void map_generic_share_sd_bits(SEC_DESC *psd) +{ + extern struct generic_mapping file_generic_mapping; + int i; + SEC_ACL *ps_dacl = NULL; + + if (!psd) + return; + + ps_dacl = psd->dacl; + if (!ps_dacl) + return; + + for (i = 0; i < ps_dacl->num_aces; i++) { + SEC_ACE *psa = &ps_dacl->ace[i]; + uint32 orig_mask = psa->info.mask; + + se_map_generic(&psa->info.mask, &file_generic_mapping); + psa->info.mask |= orig_mask; + } +} + /******************************************************************* Can this user access with share with the required permissions ? ********************************************************************/ @@ -1200,6 +1230,9 @@ 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$")) + return NT_STATUS_BAD_NETWORK_NAME; + snum = find_service(share_name); /* Does this share exist ? */ @@ -1220,16 +1253,26 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name)); type = q_u->info.share.info2.info_2.type; read_only = False; /* No SD means "Everyone full access. */ + psd = NULL; break; case 502: unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name)); unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name)); type = q_u->info.share.info502.info_502.type; psd = q_u->info.share.info502.info_502_str.sd; + map_generic_share_sd_bits(psd); read_only = read_only_share_sd(psd); break; case 1005: return ERROR_ACCESS_DENIED; + case 1501: + fstrcpy(pathname, lp_pathname(snum)); + fstrcpy(comment, lp_comment(snum)); + psd = q_u->info.share.info1501.sdb->sec; + map_generic_share_sd_bits(psd); + read_only = read_only_share_sd(psd); + type = STYPE_DISKTREE; + break; default: DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", q_u->info_level)); return NT_STATUS_INVALID_INFO_CLASS; @@ -1267,6 +1310,8 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S /* Send SIGHUP to process group. */ kill(0, SIGHUP); + } else { + DEBUG(10,("_srv_net_share_set_info: No change to share name (%s)\n", share_name )); } /* Replace SD if changed. */ @@ -1335,6 +1380,7 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name)); type = q_u->info.share.info502.info_502.type; psd = q_u->info.share.info502.info_502_str.sd; + map_generic_share_sd_bits(psd); read_only = read_only_share_sd(psd); break; case 1005: -- cgit From 7fba7a0e82e887001d3aa5c3b38c7ee4203a55bc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Apr 2001 17:10:06 +0000 Subject: Get/Set of SD's on shares now works. Correctly ensure scripts exist before calling. Jeremy. (This used to be commit aae44ee41f2f133524e37f72b46b63ce6ddb192b) --- source3/rpc_server/srv_srvsvc_nt.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 9860df6f62..4537cd30d0 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -166,7 +166,9 @@ static SEC_DESC *get_share_security( TALLOC_CTX *ctx, int snum, size_t *psize) { prs_struct ps; fstring key; - SEC_DESC *psd; + SEC_DESC *psd = NULL; + + *psize = 0; /* Fetch security descriptor from tdb */ @@ -180,6 +182,9 @@ static SEC_DESC *get_share_security( TALLOC_CTX *ctx, int snum, size_t *psize) return get_share_security_default(ctx, snum, psize); } + if (psd) + *psize = sec_desc_size(psd); + prs_mem_free(&ps); return psd; } @@ -1222,7 +1227,6 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S int ret; char *ptr; SEC_DESC *psd = NULL; - BOOL read_only = False; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); @@ -1252,7 +1256,6 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S 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)); type = q_u->info.share.info2.info_2.type; - read_only = False; /* No SD means "Everyone full access. */ psd = NULL; break; case 502: @@ -1261,7 +1264,6 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S type = q_u->info.share.info502.info_502.type; psd = q_u->info.share.info502.info_502_str.sd; map_generic_share_sd_bits(psd); - read_only = read_only_share_sd(psd); break; case 1005: return ERROR_ACCESS_DENIED; @@ -1270,7 +1272,6 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S fstrcpy(comment, lp_comment(snum)); psd = q_u->info.share.info1501.sdb->sec; map_generic_share_sd_bits(psd); - read_only = read_only_share_sd(psd); type = STYPE_DISKTREE; break; default: @@ -1291,15 +1292,17 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S string_replace(ptr, '"', ' '); string_replace(comment, '"', ' '); + DEBUG(10,("_srv_net_share_set_info: change share command = %s\n", + lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" )); + /* Only call modify function if something changed. */ - if (read_only != lp_readonly(snum) || strcmp(ptr, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) ) { - if (!lp_change_share_cmd()) + if (strcmp(ptr, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) ) { + if (!lp_change_share_cmd() || !*lp_change_share_cmd()) return ERROR_ACCESS_DENIED; - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", - lp_change_share_cmd(), share_name, ptr, comment, - read_only ? "read only = yes" : "read only = no" ); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\"", + lp_change_share_cmd(), share_name, ptr, comment); dos_to_unix(command, True); /* Convert to unix-codepage */ DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command )); @@ -1360,7 +1363,7 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S if (user.uid != 0) return ERROR_ACCESS_DENIED; - if (!lp_add_share_cmd()) + if (!lp_add_share_cmd() || !*lp_add_share_cmd()) return ERROR_ACCESS_DENIED; switch (q_u->info_level) { @@ -1468,7 +1471,7 @@ uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S if (user.uid != 0) return ERROR_ACCESS_DENIED; - if (!lp_delete_share_cmd()) + if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) return ERROR_ACCESS_DENIED; slprintf(command, sizeof(command)-1, "%s \"%s\"", lp_delete_share_cmd(), lp_servicename(snum)); -- cgit From 7130bb0dcf6194e7098a4d81c6149d810179fb7c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Apr 2001 18:03:02 +0000 Subject: Tidy up return codes for server manager. Jeremy. (This used to be commit b4cbdcb644066e132d5c806ae4f45d6a05276beb) --- source3/rpc_server/srv_srvsvc_nt.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 4537cd30d0..3b0bb352fe 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1235,13 +1235,17 @@ 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$")) - return NT_STATUS_BAD_NETWORK_NAME; + return ERROR_ACCESS_DENIED; snum = find_service(share_name); /* Does this share exist ? */ if (snum < 0) - return NT_STATUS_BAD_NETWORK_NAME; + return ERRnosuchshare; + + /* No change to printer shares. */ + if (lp_print_ok(snum)) + return ERROR_ACCESS_DENIED; get_current_user(&user,p); @@ -1360,11 +1364,15 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S get_current_user(&user,p); - if (user.uid != 0) + if (user.uid != 0) { + DEBUG(10,("_srv_net_share_add: uid != 0. Access denied.\n")); return ERROR_ACCESS_DENIED; + } - if (!lp_add_share_cmd() || !*lp_add_share_cmd()) + if (!lp_add_share_cmd() || !*lp_add_share_cmd()) { + DEBUG(10,("_srv_net_share_add: No add share command\n")); return ERROR_ACCESS_DENIED; + } switch (q_u->info_level) { case 1: @@ -1398,7 +1406,7 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S /* Share already exists. */ if (snum >= 0) - return NT_STATUS_BAD_NETWORK_NAME; + return ERRfilexists; /* We can only add disk shares. */ if (type != STYPE_DISKTREE) @@ -1461,10 +1469,17 @@ 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$")) + return ERROR_ACCESS_DENIED; + snum = find_service(share_name); if (snum < 0) - return NT_STATUS_BAD_NETWORK_NAME; + return ERRnosuchshare; + + /* No change to printer shares. */ + if (lp_print_ok(snum)) + return ERROR_ACCESS_DENIED; get_current_user(&user,p); -- cgit From e796a35a8bf677b25ff733ff4466e54226b7e461 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Apr 2001 20:12:53 +0000 Subject: Removed "read only" arg as it isn't useful. Jeremy. (This used to be commit 6b75d79c4bcfb8333aaf1ed61cf8bd022e498f75) --- source3/rpc_server/srv_srvsvc_nt.c | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 3b0bb352fe..b3a5d1a901 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -251,33 +251,6 @@ static BOOL delete_share_security(int snum) return True; } -/******************************************************************* - Does this security descriptor map to a read only share ? -********************************************************************/ - -static BOOL read_only_share_sd(SEC_DESC *psd) -{ - int i; - SEC_ACL *ps_dacl = NULL; - - if (!psd) - return True; - - ps_dacl = psd->dacl; - if (!ps_dacl) - return True; - - for (i = 0; i < ps_dacl->num_aces; i++) { - SEC_ACE *psa = &ps_dacl->ace[i]; - - if (psa->type == SEC_ACE_TYPE_ACCESS_ALLOWED && - psa->info.mask & FILE_WRITE_DATA) - return False; - } - - return True; -} - /******************************************************************* Map any generic bits to file specific bits. ********************************************************************/ @@ -1355,7 +1328,6 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S int snum; int ret; char *ptr; - BOOL read_only = False; SEC_DESC *psd = NULL; DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); @@ -1383,7 +1355,6 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S 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)); type = q_u->info.share.info2.info_2.type; - read_only = False; /* No SD means "Everyone full access. */ break; case 502: unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name)); @@ -1392,7 +1363,6 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S type = q_u->info.share.info502.info_502.type; psd = q_u->info.share.info502.info_502_str.sd; map_generic_share_sd_bits(psd); - read_only = read_only_share_sd(psd); break; case 1005: /* DFS only level. */ @@ -1421,9 +1391,8 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S string_replace(ptr, '"', ' '); string_replace(comment, '"', ' '); - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", - lp_add_share_cmd(), share_name, ptr, comment, - read_only ? "read only = yes" : "read only = no" ); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\"", + lp_add_share_cmd(), share_name, ptr, comment); dos_to_unix(command, True); /* Convert to unix-codepage */ DEBUG(10,("_srv_net_share_add: Running [%s]\n", command )); -- cgit From a9f6e205fc522a13da97485abd0f39d40630946c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 10 Apr 2001 01:44:45 +0000 Subject: Use message system to notify when smb.conf is updated. Jeremy. (This used to be commit ae9eda5c3c3bbfc8ec795b43ab18dc492e5fdcf6) --- source3/rpc_server/srv_srvsvc_nt.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index b3a5d1a901..cef31f7a8c 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -94,6 +94,16 @@ static void init_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, int snum) init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); } +/******************************************************************* + What to do when smb.conf is updated. + ********************************************************************/ + +static void smb_conf_updated(int msg_type, pid_t src, void *buf, size_t len) +{ + DEBUG(10,("smb_conf_updated: Got message saying smb.conf was updated. Reloading.\n")); + reload_services(False); +} + /******************************************************************* Create the share security tdb. ********************************************************************/ @@ -123,6 +133,8 @@ BOOL share_info_db_init(void) tdb_store_int(share_tdb, vstring, SHARE_DATABASE_VERSION); } tdb_unlock_bystring(share_tdb, vstring); + + message_register(MSG_SMB_CONF_UPDATED, smb_conf_updated); return True; } @@ -1288,8 +1300,9 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return ERROR_ACCESS_DENIED; } - /* Send SIGHUP to process group. */ - kill(0, SIGHUP); + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False); + } else { DEBUG(10,("_srv_net_share_set_info: No change to share name (%s)\n", share_name )); } @@ -1407,11 +1420,11 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S share_name )); } - /* Send SIGHUP to process group. */ - kill(0, SIGHUP); + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False); /* - * We don't call reload_services() here, the SIGHUP will + * We don't call reload_services() here, the message will * cause this to be done before the next packet is read * from the client. JRA. */ @@ -1470,8 +1483,8 @@ uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S /* Delete the SD in the database. */ delete_share_security(snum); - /* Send SIGHUP to process group. */ - kill(0, SIGHUP); + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False); lp_killservice(snum); -- cgit From 6d96224f81039756180d496a95b121768953f5ed Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 10 Apr 2001 19:43:14 +0000 Subject: passdb/pass_check.c: Ensure second check is done only if given username is all in caps. rpc_server/srv_srvsvc_nt.c: Added "CONFIGFILE" arg to scripts so path to smb.conf is given. Jeremy. (This used to be commit 3c4c649951464be51541d5890afb997e3ecfcd23) --- source3/rpc_server/srv_srvsvc_nt.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index cef31f7a8c..bce5c33225 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1219,7 +1219,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$")) + if (strequal(share_name,"IPC$") || strequal(share_name,"ADMIN$") || strequal(share_name,"global")) return ERROR_ACCESS_DENIED; snum = find_service(share_name); @@ -1290,8 +1290,8 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if (!lp_change_share_cmd() || !*lp_change_share_cmd()) return ERROR_ACCESS_DENIED; - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\"", - lp_change_share_cmd(), share_name, ptr, comment); + 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 )); @@ -1385,6 +1385,9 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S return NT_STATUS_INVALID_INFO_CLASS; } + if (strequal(share_name,"IPC$") || strequal(share_name,"ADMIN$") || strequal(share_name,"global")) + return ERROR_ACCESS_DENIED; + snum = find_service(share_name); /* Share already exists. */ @@ -1404,8 +1407,8 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S string_replace(ptr, '"', ' '); string_replace(comment, '"', ' '); - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\"", - lp_add_share_cmd(), share_name, ptr, comment); + 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 )); @@ -1451,7 +1454,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$")) + if (strequal(share_name,"IPC$") || strequal(share_name,"ADMIN$") || strequal(share_name,"global")) return ERROR_ACCESS_DENIED; snum = find_service(share_name); @@ -1471,7 +1474,8 @@ uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) return ERROR_ACCESS_DENIED; - slprintf(command, sizeof(command)-1, "%s \"%s\"", lp_delete_share_cmd(), lp_servicename(snum)); + 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 )); -- cgit From a591def534068a7c76abe8447dea237b3a96e3e1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 10 Apr 2001 23:58:27 +0000 Subject: Merged in missing break fix from Shirish. Jeremy. (This used to be commit 8ecf6c33673693ca64f99bd7fb26d3383658d86b) --- source3/rpc_server/srv_dfs_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 9b3ac1bb54..22e7a24f58 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -288,6 +288,7 @@ static uint32 init_reply_dfs_ctr(TALLOC_CTX *ctx, uint32 level, DFS_INFO_CTR* ct return NT_STATUS_NO_MEMORY; init_reply_dfs_info_3(ctx, jn, dfs3, num_jn); ctr->dfs.info3 = dfs3; + break; } default: return NT_STATUS_INVALID_LEVEL; -- cgit From 9e73a361936fc0b7c2498a3cf2729829c621d1ca Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 11 Apr 2001 00:05:23 +0000 Subject: Restrict dfs add and dfs remote to root at Shirish's advice. Jeremy. (This used to be commit 9dd77c4fb1282d23cfbfd9d0ed790be62534e201) --- source3/rpc_server/srv_dfs_nt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 22e7a24f58..c01ab8f2d9 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -44,6 +44,7 @@ uint32 _dfs_exist(pipes_struct *p, DFS_Q_DFS_EXIST *q_u, DFS_R_DFS_EXIST *r_u) uint32 _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) { + struct current_user user; struct junction_map jn; struct referral* old_referral_list = NULL; BOOL exists = False; @@ -51,6 +52,13 @@ uint32 _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) pstring dfspath, servername, sharename; pstring altpath; + get_current_user(&user,p); + + if (user.uid != 0) { + DEBUG(10,("_dfs_add: uid != 0. Access denied.\n")); + return ERROR_ACCESS_DENIED; + } + unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1); unistr2_to_ascii(servername, &q_u->ServerName, sizeof(servername)-1); unistr2_to_ascii(sharename, &q_u->ShareName, sizeof(sharename)-1); @@ -103,12 +111,20 @@ uint32 _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) uint32 _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DFS_R_DFS_REMOVE *r_u) { + struct current_user user; struct junction_map jn; BOOL found = False; pstring dfspath, servername, sharename; pstring altpath; + get_current_user(&user,p); + + if (user.uid != 0) { + DEBUG(10,("_dfs_add: uid != 0. Access denied.\n")); + return ERROR_ACCESS_DENIED; + } + unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1); if(q_u->ptr_ServerName) unistr2_to_ascii(servername, &q_u->ServerName, sizeof(servername)-1); -- cgit From 0ca9f5c023df2ee498dcd1bdb2f29abc632a5d60 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 11 Apr 2001 21:19:25 +0000 Subject: Fix for core dump in security = share code with new share security db. Jeremy. (This used to be commit 20b13bafdff2fd7be9219ed164e7fe91b597298d) --- source3/rpc_server/srv_srvsvc_nt.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index bce5c33225..0c165bf9fa 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -293,7 +293,7 @@ void map_generic_share_sd_bits(SEC_DESC *psd) Can this user access with share with the required permissions ? ********************************************************************/ -BOOL share_access_check(int snum, uint16 vuid, uint32 desired_access) +BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 desired_access) { uint32 granted, status; TALLOC_CTX *mem_ctx = NULL; @@ -313,17 +313,25 @@ BOOL share_access_check(int snum, uint16 vuid, uint32 desired_access) if (!psd) goto out; + ZERO_STRUCT(tmp_user); if (vuser) { - ZERO_STRUCT(tmp_user); 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; - puser = &tmp_user; + } 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; + ret = se_access_check(psd, puser, desired_access, &granted, &status); out: -- cgit From 09a5daf032b6e206e9371e63ca06ef60ef841b6a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 12 Apr 2001 07:00:08 +0000 Subject: Changed lp_add/delete/enum scripts to use lockdir if spool dir doesn't exist for printer. Rather than using pid for suffix, use a 16 byte random string. Created generate_random_str() function in genrand.c. Still needs more testing but this is the way to go. Jeremy. (This used to be commit 71a330987f990007beb16f00fc468107361b5e9d) --- source3/rpc_server/srv_spoolss_nt.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c75af92902..f91168d3e4 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -285,7 +285,6 @@ static uint32 delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) if (*lp_deleteprinter_cmd()) { - pid_t local_pid = sys_getpid(); char *cmd = lp_deleteprinter_cmd(); char *path; pstring tmp_file; @@ -296,13 +295,13 @@ static uint32 delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) if (*lp_pathname(lp_servicenumber(PRINTERS_NAME))) path = lp_pathname(lp_servicenumber(PRINTERS_NAME)); else - path = tmpdir(); + path = lp_lockdir(); /* Printer->dev.handlename equals portname equals sharename */ slprintf(command, sizeof(command)-1, "%s \"%s\"", cmd, Printer->dev.handlename); dos_to_unix(command, True); /* Convert printername to unix-codepage */ - slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d", path, local_pid); + slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%s", path, generate_random_str(16)); unlink(tmp_file); DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); @@ -4133,7 +4132,6 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) ****************************************************************************/ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) { - pid_t local_pid = sys_getpid(); char *cmd = lp_addprinter_cmd(); char *path; char **qlines; @@ -4146,15 +4144,15 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) if (*lp_pathname(lp_servicenumber(PRINTERS_NAME))) path = lp_pathname(lp_servicenumber(PRINTERS_NAME)); else - path = tmpdir(); + path = lp_lockdir(); /* build driver path... only 9X architecture is needed for legacy reasons */ slprintf(driverlocation, sizeof(driverlocation)-1, "\\\\%s\\print$\\WIN40\\0", global_myname); /* change \ to \\ for the shell */ all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring)); - - slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d", path, local_pid); + + slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%s", path, generate_random_str(16)); slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", cmd, printer->info_2->printername, printer->info_2->sharename, printer->info_2->portname, printer->info_2->drivername, @@ -5418,7 +5416,6 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need int i=0; if (*lp_enumports_cmd()) { - pid_t local_pid = sys_getpid(); char *cmd = lp_enumports_cmd(); char *path; char **qlines; @@ -5430,9 +5427,9 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need if (*lp_pathname(lp_servicenumber(PRINTERS_NAME))) path = lp_pathname(lp_servicenumber(PRINTERS_NAME)); else - path = tmpdir(); + path = lp_lockdir(); - slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d", path, local_pid); + slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%s", path, generate_random_str(16)); slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 1); unlink(tmp_file); @@ -5516,7 +5513,6 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need int i=0; if (*lp_enumports_cmd()) { - pid_t local_pid = sys_getpid(); char *cmd = lp_enumports_cmd(); char *path; char **qlines; @@ -5528,9 +5524,9 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need if (*lp_pathname(lp_servicenumber(PRINTERS_NAME))) path = lp_pathname(lp_servicenumber(PRINTERS_NAME)); else - path = tmpdir(); + path = lp_lockdir(); - slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d", path, local_pid); + slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%s", path, generate_random_str(16)); slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 2); unlink(tmp_file); -- cgit From 50e78a9ac8cf0949c2471fafde844c674f97d73d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 13 Apr 2001 00:37:00 +0000 Subject: As Andrew suggested, make smbrun return a fd for a deleted file which can then be read. Jeremy. (This used to be commit e7d59d6de89a5fdd201e4b5c6072dab08b1519db) --- source3/rpc_server/srv_spoolss_nt.c | 58 +++++++++++++++---------------------- source3/rpc_server/srv_srvsvc_nt.c | 6 ++-- 2 files changed, 26 insertions(+), 38 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f91168d3e4..3bf44cd041 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -286,33 +286,21 @@ static uint32 delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) if (*lp_deleteprinter_cmd()) { char *cmd = lp_deleteprinter_cmd(); - char *path; - pstring tmp_file; pstring command; int ret; int i; - if (*lp_pathname(lp_servicenumber(PRINTERS_NAME))) - path = lp_pathname(lp_servicenumber(PRINTERS_NAME)); - else - path = lp_lockdir(); - /* Printer->dev.handlename equals portname equals sharename */ slprintf(command, sizeof(command)-1, "%s \"%s\"", cmd, Printer->dev.handlename); dos_to_unix(command, True); /* Convert printername to unix-codepage */ - slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%s", path, generate_random_str(16)); - unlink(tmp_file); - DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); - ret = smbrun(command, tmp_file, False); + DEBUG(10,("Running [%s]\n", command)); + ret = smbrun(command, NULL, NULL); if (ret != 0) { - unlink(tmp_file); return ERROR_INVALID_HANDLE; /* What to return here? */ } DEBUGADD(10,("returned [%d]\n", ret)); - DEBUGADD(10,("Unlinking output file [%s]\n", tmp_file)); - unlink(tmp_file); /* Send SIGHUP to process group... is there a better way? */ kill(0, SIGHUP); @@ -4140,6 +4128,7 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) pstring driverlocation; int numlines; int ret; + int fd; if (*lp_pathname(lp_servicenumber(PRINTERS_NAME))) path = lp_pathname(lp_servicenumber(PRINTERS_NAME)); @@ -4152,31 +4141,29 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) /* change \ to \\ for the shell */ all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring)); - slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%s", path, generate_random_str(16)); + slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d.", path, sys_getpid()); slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", cmd, printer->info_2->printername, printer->info_2->sharename, printer->info_2->portname, printer->info_2->drivername, printer->info_2->location, driverlocation); - unlink(tmp_file); - /* Convert script args to unix-codepage */ dos_to_unix(command, True); DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); - ret = smbrun(command, tmp_file, False); + ret = smbrun(command, &fd, tmp_file); DEBUGADD(10,("returned [%d]\n", ret)); if ( ret != 0 ) { - unlink(tmp_file); + if (fd != -1) + close(fd); return False; } numlines = 0; /* Get lines and convert them back to dos-codepage */ - qlines = file_lines_load(tmp_file, &numlines, True); + qlines = fd_lines_load(fd, &numlines, True); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); - DEBUGADD(10,("Unlinking script output file [%s]\n", tmp_file)); - unlink(tmp_file); + close(fd); if(numlines) { /* Set the portname to what the script says the portname should be. */ @@ -5423,30 +5410,30 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need pstring command; int numlines; int ret; + int fd; if (*lp_pathname(lp_servicenumber(PRINTERS_NAME))) path = lp_pathname(lp_servicenumber(PRINTERS_NAME)); else path = lp_lockdir(); - slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%s", path, generate_random_str(16)); + slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d.", path, sys_getpid()); slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 1); - unlink(tmp_file); DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); - ret = smbrun(command, tmp_file, False); + ret = smbrun(command, &fd, tmp_file); DEBUG(10,("Returned [%d]\n", ret)); if (ret != 0) { - unlink(tmp_file); + if (fd != -1) + close(fd); /* Is this the best error to return here? */ return ERROR_ACCESS_DENIED; } numlines = 0; - qlines = file_lines_load(tmp_file, &numlines,True); + qlines = fd_lines_load(fd, &numlines,True); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); - DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file)); - unlink(tmp_file); + close(fd); if(numlines) { if((ports=(PORT_INFO_1 *)malloc( numlines * sizeof(PORT_INFO_1) )) == NULL) { @@ -5520,30 +5507,31 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need pstring command; int numlines; int ret; + int fd; if (*lp_pathname(lp_servicenumber(PRINTERS_NAME))) path = lp_pathname(lp_servicenumber(PRINTERS_NAME)); else path = lp_lockdir(); - slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%s", path, generate_random_str(16)); + slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d.", path, sys_getpid()); slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 2); unlink(tmp_file); DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); - ret = smbrun(command, tmp_file, False); + ret = smbrun(command, &fd, tmp_file); DEBUGADD(10,("returned [%d]\n", ret)); if (ret != 0) { - unlink(tmp_file); + if (fd != -1) + close(fd); /* Is this the best error to return here? */ return ERROR_ACCESS_DENIED; } numlines = 0; - qlines = file_lines_load(tmp_file, &numlines,True); + qlines = fd_lines_load(fd, &numlines,True); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); - DEBUGADD(10,("Unlinking port file [%s]\n", tmp_file)); - unlink(tmp_file); + close(fd); if(numlines) { if((ports=(PORT_INFO_2 *)malloc( numlines * sizeof(PORT_INFO_2) )) == NULL) { diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 0c165bf9fa..e5d93b8b3d 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1303,7 +1303,7 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S 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, False)) != 0) { + if ((ret = smbrun(command, NULL, NULL)) != 0) { DEBUG(0,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret )); return ERROR_ACCESS_DENIED; } @@ -1420,7 +1420,7 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S dos_to_unix(command, True); /* Convert to unix-codepage */ DEBUG(10,("_srv_net_share_add: Running [%s]\n", command )); - if ((ret = smbrun(command, NULL, False)) != 0) { + if ((ret = smbrun(command, NULL, NULL)) != 0) { DEBUG(0,("_srv_net_share_add: Running [%s] returned (%d)\n", command, ret )); return ERROR_ACCESS_DENIED; } @@ -1487,7 +1487,7 @@ uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S dos_to_unix(command, True); /* Convert to unix-codepage */ DEBUG(10,("_srv_net_share_del: Running [%s]\n", command )); - if ((ret = smbrun(command, NULL, False)) != 0) { + if ((ret = smbrun(command, NULL, NULL)) != 0) { DEBUG(0,("_srv_net_share_del: Running [%s] returned (%d)\n", command, ret )); return ERROR_ACCESS_DENIED; } -- cgit From 2ef68c7e92d4661664f0410509f7cb551e74a198 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 13 Apr 2001 19:12:06 +0000 Subject: Merge of Andrew's changes in 2.2. Jeremy. (This used to be commit fc76681812b1469208ad6c8847afdfc68bc6db49) --- source3/rpc_server/srv_reg_nt.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 26 +++++++++++--------------- source3/rpc_server/srv_srvsvc_nt.c | 10 +++++----- 3 files changed, 17 insertions(+), 21 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 4f941e3e1b..502d551437 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -117,7 +117,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; - char *key; + char *key = NULL; uint32 type=0x1; /* key type: REG_SZ */ UNISTR2 *uni_key = NULL; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3bf44cd041..917885eafb 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -296,7 +296,7 @@ static uint32 delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) dos_to_unix(command, True); /* Convert printername to unix-codepage */ DEBUG(10,("Running [%s]\n", command)); - ret = smbrun(command, NULL, NULL); + ret = smbrun(command, NULL); if (ret != 0) { return ERROR_INVALID_HANDLE; /* What to return here? */ } @@ -4123,7 +4123,6 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) char *cmd = lp_addprinter_cmd(); char *path; char **qlines; - pstring tmp_file; pstring command; pstring driverlocation; int numlines; @@ -4141,16 +4140,15 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) /* change \ to \\ for the shell */ all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring)); - slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d.", path, sys_getpid()); slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", cmd, printer->info_2->printername, printer->info_2->sharename, printer->info_2->portname, printer->info_2->drivername, printer->info_2->location, driverlocation); - /* Convert script args to unix-codepage */ - dos_to_unix(command, True); - DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); - ret = smbrun(command, &fd, tmp_file); + /* Convert script args to unix-codepage */ + dos_to_unix(command, True); + DEBUG(10,("Running [%s]\n", command)); + ret = smbrun(command, &fd); DEBUGADD(10,("returned [%d]\n", ret)); if ( ret != 0 ) { @@ -4160,7 +4158,7 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) } numlines = 0; - /* Get lines and convert them back to dos-codepage */ + /* Get lines and convert them back to dos-codepage */ qlines = fd_lines_load(fd, &numlines, True); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); close(fd); @@ -5307,7 +5305,7 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * FORM_1 form_1; fstring form_name; int buffer_size=0; - int numofforms, i; + int numofforms=0, i; /* that's an [in out] buffer */ spoolss_move_buffer(q_u->buffer, &r_u->buffer); @@ -5406,7 +5404,6 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need char *cmd = lp_enumports_cmd(); char *path; char **qlines; - pstring tmp_file; pstring command; int numlines; int ret; @@ -5417,11 +5414,10 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need else path = lp_lockdir(); - slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d.", path, sys_getpid()); slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 1); - DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); - ret = smbrun(command, &fd, tmp_file); + DEBUG(10,("Running [%s]\n", command)); + ret = smbrun(command, &fd); DEBUG(10,("Returned [%d]\n", ret)); if (ret != 0) { if (fd != -1) @@ -5519,7 +5515,7 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need unlink(tmp_file); DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); - ret = smbrun(command, &fd, tmp_file); + ret = smbrun(command, &fd); DEBUGADD(10,("returned [%d]\n", ret)); if (ret != 0) { if (fd != -1) @@ -6045,7 +6041,7 @@ uint32 _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP ZERO_STRUCT(old_param); if (get_specific_param(*printer, 2, param->value, &old_param.data, - &old_param.type, (unsigned int *)&old_param.data_len)) { + &old_param.type, (uint32 *)&old_param.data_len)) { if (param->type == old_param.type && param->data_len == old_param.data_len && diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index e5d93b8b3d..887c100d57 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -50,7 +50,7 @@ static void init_srv_share_info_1(SRV_SHARE_INFO_1 *sh1, int snum) if (lp_print_ok(snum)) type = STYPE_PRINTQ; - if (strequal("IPC", lp_fstype(snum))) + if (strequal("IPC$", net_name) || strequal("ADMIN$", net_name)) type = STYPE_IPC; if (net_name[len_net_name] == '$') type |= STYPE_HIDDEN; @@ -85,7 +85,7 @@ static void init_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, int snum) if (lp_print_ok(snum)) type = STYPE_PRINTQ; - if (strequal("IPC", lp_fstype(snum))) + if (strequal("IPC$", net_name) || strequal("ADMIN$", net_name)) type = STYPE_IPC; if (net_name[len_net_name] == '$') type |= STYPE_HIDDEN; @@ -1303,7 +1303,7 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S 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, NULL)) != 0) { + if ((ret = smbrun(command, NULL)) != 0) { DEBUG(0,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret )); return ERROR_ACCESS_DENIED; } @@ -1420,7 +1420,7 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S dos_to_unix(command, True); /* Convert to unix-codepage */ DEBUG(10,("_srv_net_share_add: Running [%s]\n", command )); - if ((ret = smbrun(command, NULL, NULL)) != 0) { + if ((ret = smbrun(command, NULL)) != 0) { DEBUG(0,("_srv_net_share_add: Running [%s] returned (%d)\n", command, ret )); return ERROR_ACCESS_DENIED; } @@ -1487,7 +1487,7 @@ uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S dos_to_unix(command, True); /* Convert to unix-codepage */ DEBUG(10,("_srv_net_share_del: Running [%s]\n", command )); - if ((ret = smbrun(command, NULL, NULL)) != 0) { + if ((ret = smbrun(command, NULL)) != 0) { DEBUG(0,("_srv_net_share_del: Running [%s] returned (%d)\n", command, ret )); return ERROR_ACCESS_DENIED; } -- cgit From 06a50f51845bf639f7abd47cf39638054f255131 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 15 Apr 2001 22:29:36 +0000 Subject: Patch from "Christoph Zwerschke" to map usernames before calling password change. Jeremy. (This used to be commit ce2a236dc61d819e083b32556a2d9f827944b91c) --- source3/rpc_server/srv_samr_nt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2434fad74a..9e9c5d950e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1242,6 +1242,18 @@ uint32 _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_R_ DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); + /* + * Pass the user through the NT -> unix user mapping + * function. + */ + + (void)map_username(user_name); + + /* + * Do any UNIX username case mangling. + */ + (void)Get_Pwnam( user_name, True); + if (!pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, q_u->nt_newpass.pass, q_u->nt_oldhash.hash)) r_u->status = NT_STATUS_WRONG_PASSWORD; -- cgit From af08cd21eb714abc019656bc8cee86fd7a3f20d6 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 16 Apr 2001 02:35:35 +0000 Subject: Getting medieval with compiler warnings as Jeremy puts it. (This used to be commit d05c3cf0f47a3c863adbed7ad4ab8f3248cd072d) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 917885eafb..57f95873fc 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5305,7 +5305,7 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * FORM_1 form_1; fstring form_name; int buffer_size=0; - int numofforms=0, i; + int numofforms=0, i=0; /* that's an [in out] buffer */ spoolss_move_buffer(q_u->buffer, &r_u->buffer); -- cgit From a626bb3a239e80ad0ea55a00f721b2c0a5dfc8fa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 21 Apr 2001 23:06:59 +0000 Subject: JF pointed out we were returning the wrong info for Domain member with info levels 3 and 5. I *hate* LSAQueryInfoPolicy() :-). Jeremy. (This used to be commit 37581bdf1e1f24dabe67befdc27f54f516d3f08e) --- source3/rpc_server/srv_lsa_nt.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f273c7bb4c..f4407f5d36 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -355,24 +355,25 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO break; } case 0x03: - switch (lp_server_role()) - { + /* Request PolicyPrimaryDomainInformation. */ + switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: name = global_myworkgroup; sid = &global_sam_sid; break; case ROLE_DOMAIN_MEMBER: - name = global_myname; + name = global_myworkgroup; + /* We need to return the Domain SID here. */ if (secrets_fetch_domain_sid(global_myworkgroup, &domain_sid)) sid = &domain_sid; else - sid = &global_sam_sid; + return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; break; case ROLE_STANDALONE: name = global_myname; - sid = &global_sam_sid; + sid = NULL; /* Tell it we're not in a domain. */ break; default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; @@ -380,22 +381,14 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO init_dom_query(&r_u->dom.id3, name, sid); break; case 0x05: - /* AS/U shows this needs to be the same as level 3. JRA. */ - switch (lp_server_role()) - { + /* Request PolicyAccountDomainInformation. */ + switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: name = global_myworkgroup; sid = &global_sam_sid; break; case ROLE_DOMAIN_MEMBER: - name = global_myname; - if (secrets_fetch_domain_sid(global_myworkgroup, - &domain_sid)) - sid = &domain_sid; - else - sid = &global_sam_sid; - break; case ROLE_STANDALONE: name = global_myname; sid = &global_sam_sid; @@ -406,8 +399,7 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO init_dom_query(&r_u->dom.id5, name, sid); break; case 0x06: - switch (lp_server_role()) - { + switch (lp_server_role()) { case ROLE_DOMAIN_BDC: /* * only a BDC is a backup controller -- cgit From ac9e221c3e6bc892e0f73a403c89434ae13a8eec Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 22 Apr 2001 02:54:04 +0000 Subject: merging from 2.2 to head (This used to be commit bfcc6f88271025760732271f03933839b1cbe0de) --- source3/rpc_server/srv_samr_nt.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9e9c5d950e..e0d6d6056e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2104,11 +2104,9 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) copy_sam_passwd(&new_pwd, pwd); copy_id23_to_sam_passwd(&new_pwd, id23); - if (!decode_pw_buffer((char*)id23->pass, buf, 256, &len)) + if (!decode_pw_buffer((char*)id23->pass, buf, 256, &len, nt_hash, lm_hash)) return False; - - nt_lm_owf_gen(buf, nt_hash, lm_hash); - + pdb_set_lanman_passwd (&new_pwd, lm_hash); pdb_set_nt_passwd (&new_pwd, nt_hash); @@ -2153,13 +2151,9 @@ static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) memset(buf, 0, sizeof(buf)); - if (!decode_pw_buffer((char*)id24->pass, buf, 256, &len)) + if (!decode_pw_buffer((char*)id24->pass, buf, 256, &len, nt_hash, lm_hash)) return False; - DEBUG(5,("set_user_info_24:nt_lm_owf_gen\n")); - - nt_lm_owf_gen(buf, nt_hash, lm_hash); - pdb_set_lanman_passwd (pwd, lm_hash); pdb_set_nt_passwd (pwd, nt_hash); -- cgit From 130f31f5713d43ea2f237cfe0fc142a171eeb82f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 22 Apr 2001 06:13:14 +0000 Subject: Finally got name & SID returns correct. Jeremy. (This used to be commit 2a5b513c4459782fa95756f1483235c186ba4a08) --- source3/rpc_server/srv_lsa_nt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f4407f5d36..6f1719b530 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -389,10 +389,13 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO sid = &global_sam_sid; break; case ROLE_DOMAIN_MEMBER: - case ROLE_STANDALONE: name = global_myname; sid = &global_sam_sid; break; + case ROLE_STANDALONE: + name = global_myname; + sid = NULL; /* Tell it we're not in a domain. */ + break; default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; } -- cgit From 3e4c6d130c3c533831ac6a52e2403132b79f4b28 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 23 Apr 2001 23:31:09 +0000 Subject: Fix "proc num out of range" error. Missing rpc call. Jeremy. (This used to be commit 6248fb22926d72fddaecad5af117af1bdd08fda3) --- source3/rpc_server/srv_netlog.c | 32 ++++++++++++++++++ source3/rpc_server/srv_netlog_nt.c | 68 +++++++++++++++++++++++++++++++------- 2 files changed, 88 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 01d646bf57..4c13ad0c67 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -59,6 +59,37 @@ static BOOL api_net_req_chal(pipes_struct *p) return True; } +/************************************************************************* + api_net_auth: + *************************************************************************/ + +static BOOL api_net_auth(pipes_struct *p) +{ + NET_Q_AUTH q_u; + NET_R_AUTH r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the challenge... */ + if(!net_io_q_auth("", &q_u, data, 0)) { + DEBUG(0,("api_net_auth: Failed to unmarshall NET_Q_AUTH.\n")); + return False; + } + + r_u.status = _net_auth(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!net_io_r_auth("", &r_u, rdata, 0)) { + DEBUG(0,("api_net_auth: Failed to marshall NET_R_AUTH.\n")); + return False; + } + + return True; +} + /************************************************************************* api_net_auth_2: *************************************************************************/ @@ -257,6 +288,7 @@ static BOOL api_net_logon_ctrl2(pipes_struct *p) static struct api_struct api_net_cmds [] = { { "NET_REQCHAL" , NET_REQCHAL , api_net_req_chal }, + { "NET_AUTH" , NET_AUTH , api_net_auth }, { "NET_AUTH2" , NET_AUTH2 , api_net_auth_2 }, { "NET_SRVPWSET" , NET_SRVPWSET , api_net_srv_pwset }, { "NET_SAMLOGON" , NET_SAMLOGON , api_net_sam_logon }, diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index cfcfac1d1a..6b1fe64ddc 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -96,18 +96,6 @@ uint32 _net_trust_dom_list(pipes_struct *p, NET_Q_TRUST_DOM_LIST *q_u, NET_R_TRU return r_u->status; } -/************************************************************************* - init_net_r_auth_2: - *************************************************************************/ - -static void init_net_r_auth_2(NET_R_AUTH_2 *r_a, - DOM_CHAL *resp_cred, NEG_FLAGS *flgs, int status) -{ - memcpy(r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); - memcpy(&r_a->srv_flgs, flgs, sizeof(r_a->srv_flgs)); - r_a->status = status; -} - /*********************************************************************************** init_net_r_srv_pwset: ***********************************************************************************/ @@ -218,6 +206,62 @@ uint32 _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u) return r_u->status; } +/************************************************************************* + init_net_r_auth: + *************************************************************************/ + +static void init_net_r_auth(NET_R_AUTH *r_a, DOM_CHAL *resp_cred, int status) +{ + memcpy(r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); + r_a->status = status; +} + +/************************************************************************* + _net_auth + *************************************************************************/ + +uint32 _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) +{ + uint32 status = NT_STATUS_NOPROBLEMO; + DOM_CHAL srv_cred; + UTIME srv_time; + + if (!get_valid_user_struct(p->vuid)) + return NT_STATUS_NO_SUCH_USER; + + srv_time.time = 0; + + /* check that the client credentials are valid */ + if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) { + + /* create server challenge for inclusion in the reply */ + cred_create(p->dc.sess_key, &p->dc.srv_cred.challenge, srv_time, &srv_cred); + + /* copy the received client credentials for use next time */ + memcpy(p->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + memcpy(p->dc.srv_cred .challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + } else { + status = NT_STATUS_ACCESS_DENIED; + } + + /* set up the LSA AUTH 2 response */ + init_net_r_auth(r_u, &srv_cred, status); + + return r_u->status; +} + +/************************************************************************* + init_net_r_auth_2: + *************************************************************************/ + +static void init_net_r_auth_2(NET_R_AUTH_2 *r_a, + DOM_CHAL *resp_cred, NEG_FLAGS *flgs, int status) +{ + memcpy(r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); + memcpy(&r_a->srv_flgs, flgs, sizeof(r_a->srv_flgs)); + r_a->status = status; +} + /************************************************************************* _net_auth_2 *************************************************************************/ -- cgit From c3bf153c0c0c7c1c0f1d012147fb4c061b2be324 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 25 Apr 2001 22:12:13 +0000 Subject: converted the passdb smbpasswd implementation to using talloc for memory allocation. This fixes a long standing seg fault (i knew i would get around to it one day :) ) Tested with NT4 and Win2k. Needs a little more testing with the "create the machine account on the fly" code for NT4. Simo, this is probably going to break the tdb passdb code. Can you look at that when you get a chance and see what you think? (This used to be commit 1c13110873e456748dc09fd51749f664643fe888) --- source3/rpc_server/srv_samr_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e0d6d6056e..7054f85ff9 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2060,6 +2060,7 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) return False; /* we make a copy so that we can modify stuff */ + ZERO_STRUCT(new_pwd); copy_sam_passwd(&new_pwd, pwd); copy_id21_to_sam_passwd(&new_pwd, id21); @@ -2099,8 +2100,9 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) if (pwd == NULL) return False; - acct_ctrl = pdb_get_acct_ctrl(pwd); + acct_ctrl = pdb_get_acct_ctrl(pwd); + ZERO_STRUCT (new_pwd); copy_sam_passwd(&new_pwd, pwd); copy_id23_to_sam_passwd(&new_pwd, id23); -- cgit From 30c0777c1f5cd6953f8e0f279458c73700a206b9 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 27 Apr 2001 17:08:33 +0000 Subject: fix a bug in printer name handling that jerry reported. names can be \\server -> print server \\server\printer -> printer printer -> printer J.F. (This used to be commit ec576722b79e3c5384dd40c532d4233dd6b1b9a8) --- source3/rpc_server/srv_spoolss_nt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 57f95873fc..6dbf90ba8a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -371,7 +371,7 @@ static BOOL set_printer_hnd_printertype(Printer_entry *Printer, char *handlename } /* it's a print server */ - if (!strchr(handlename+2, '\\')) { + if (*handlename=='\\' && *(handlename+1)=='\\' && !strchr(handlename+2, '\\')) { DEBUGADD(4,("Printer is a print server\n")); Printer->printer_type = PRINTER_HANDLE_IS_PRINTSERVER; } @@ -407,8 +407,13 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) if (Printer->printer_type!=PRINTER_HANDLE_IS_PRINTER) return False; - aprinter=strchr(handlename+2, '\\'); - aprinter++; + if (*handlename=='\\') { + aprinter=strchr(handlename+2, '\\'); + aprinter++; + } + else { + aprinter=handlename; + } DEBUGADD(5,("searching for [%s] (len=%d)\n", aprinter, strlen(aprinter))); -- cgit From 9b783398750cbf6e8b6b6bbb76dd393b432403c7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 27 Apr 2001 21:49:22 +0000 Subject: More acl -> the_acl, %d with uid_t issues. Jeremy. (This used to be commit 30edd7fdf1d791d76351a7cc23a83f97386c3087) --- source3/rpc_server/srv_spoolss_nt.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 6dbf90ba8a..d714972179 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4034,35 +4034,35 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, nt_printing_getsec(p->mem_ctx, Printer->dev.handlename, &old_secdesc_ctr); if (DEBUGLEVEL >= 10) { - SEC_ACL *acl; + SEC_ACL *the_acl; int i; - acl = old_secdesc_ctr->sec->dacl; + the_acl = old_secdesc_ctr->sec->dacl; DEBUG(10, ("old_secdesc_ctr for %s has %d aces:\n", - PRINTERNAME(snum), acl->num_aces)); + PRINTERNAME(snum), the_acl->num_aces)); - for (i = 0; i < acl->num_aces; i++) { + for (i = 0; i < the_acl->num_aces; i++) { fstring sid_str; - sid_to_string(sid_str, &acl->ace[i].sid); + sid_to_string(sid_str, &the_acl->ace[i].sid); DEBUG(10, ("%s 0x%08x\n", sid_str, - acl->ace[i].info.mask)); + the_acl->ace[i].info.mask)); } - acl = secdesc_ctr->sec->dacl; + the_acl = secdesc_ctr->sec->dacl; - if (acl) { + if (the_acl) { DEBUG(10, ("secdesc_ctr for %s has %d aces:\n", - PRINTERNAME(snum), acl->num_aces)); + PRINTERNAME(snum), the_acl->num_aces)); - for (i = 0; i < acl->num_aces; i++) { + for (i = 0; i < the_acl->num_aces; i++) { fstring sid_str; - sid_to_string(sid_str, &acl->ace[i].sid); + sid_to_string(sid_str, &the_acl->ace[i].sid); DEBUG(10, ("%s 0x%08x\n", sid_str, - acl->ace[i].info.mask)); + the_acl->ace[i].info.mask)); } } else { DEBUG(10, ("dacl for secdesc_ctr is NULL\n")); @@ -5515,7 +5515,7 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need else path = lp_lockdir(); - slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%d.", path, sys_getpid()); + slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%u.", path, (unsigned int)sys_getpid()); slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 2); unlink(tmp_file); -- cgit From 8bd2a11c86ddc3bbb2bec32415e027d87df639af Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 1 May 2001 01:01:19 +0000 Subject: Added code from "Nigel Williams" (yes, the same famous Nigel Williams who did NIS/GINA !) to implement add/modify/delete shares for Win2k. Needs testing as I made a few mods to the original code. Jeremy. (This used to be commit 9b3dd801765fad28c0f9d58e5af2537cfccdd4ee) --- source3/rpc_server/srv_srvsvc.c | 62 ++++++++++++++++++ source3/rpc_server/srv_srvsvc_nt.c | 131 ++++++++++++++++++++++++++++++++++++- 2 files changed, 192 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index d4d5e1bfe8..76542d1c2f 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -344,6 +344,66 @@ static BOOL api_srv_net_remote_tod(pipes_struct *p) return True; } +/******************************************************************* + RPC to enumerate disks available on a server e.g. C:, D: ... +*******************************************************************/ + +static BOOL api_srv_net_disk_enum(pipes_struct *p) +{ + SRV_Q_NET_DISK_ENUM q_u; + SRV_R_NET_DISK_ENUM r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server disk enum. */ + if(!srv_io_q_net_disk_enum("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_disk_enum: Failed to unmarshall SRV_Q_NET_DISK_ENUM.\n")); + return False; + } + + r_u.status = _srv_net_disk_enum(p, &q_u, &r_u); + + if(!srv_io_r_net_disk_enum("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_disk_enum: Failed to marshall SRV_R_NET_DISK_ENUM.\n")); + return False; + } + + return True; +} + +/******************************************************************* + NetValidateName (opnum 0x21) +*******************************************************************/ + +static BOOL api_srv_net_name_validate(pipes_struct *p) +{ + SRV_Q_NET_NAME_VALIDATE q_u; + SRV_R_NET_NAME_VALIDATE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server disk enum. */ + if(!srv_io_q_net_name_validate("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_name_validate: Failed to unmarshall SRV_Q_NET_NAME_VALIDATE.\n")); + return False; + } + + r_u.status = _srv_net_name_validate(p, &q_u, &r_u); + + if(!srv_io_r_net_name_validate("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_name_validate: Failed to marshall SRV_R_NET_NAME_VALIDATE.\n")); + return False; + } + + return True; +} + /******************************************************************* \PIPE\srvsvc commands ********************************************************************/ @@ -361,6 +421,8 @@ struct api_struct api_srv_cmds[] = { "SRV_NETFILEENUM" , SRV_NETFILEENUM , api_srv_net_file_enum }, { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, + { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, + { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate}, { NULL , 0 , NULL } }; diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 887c100d57..48961dcb64 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -77,6 +77,14 @@ static void init_srv_share_info_2(SRV_SHARE_INFO_2 *sh2, int snum) pstring_sub(remark,"%S",lp_servicename(snum)); pstrcpy(path, "C:"); pstrcat(path, lp_pathname(snum)); + + /* + * Change / to \\ so that win2k will see it as a valid path. This was added to + * enable use of browsing in win2k add share dialog. + */ + + string_replace(path, '/', '\\'); + pstrcpy(passwd, ""); len_net_name = strlen(net_name); @@ -363,6 +371,14 @@ static void init_srv_share_info_502(TALLOC_CTX *ctx, SRV_SHARE_INFO_502 *sh502, pstring_sub(remark,"%S",lp_servicename(snum)); pstrcpy(path, "C:"); pstrcat(path, lp_pathname(snum)); + + /* + * Change / to \\ so that win2k will see it as a valid path. This was added to + * enable use of browsing in win2k add share dialog. + */ + + string_replace(path, '/', '\\'); + pstrcpy(passwd, ""); len_net_name = strlen(net_name); @@ -379,7 +395,7 @@ static void init_srv_share_info_502(TALLOC_CTX *ctx, SRV_SHARE_INFO_502 *sh502, sd = get_share_security(ctx, snum, &sd_size); init_srv_share_info502(&sh502->info_502, net_name, type, remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size); - init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, path, passwd, sd, sd_size); + init_srv_share_info502_str(&sh502->info_502_str, &sh502->info_502, net_name, remark, path, passwd, sd, sd_size); } /*************************************************************************** @@ -1546,3 +1562,116 @@ uint32 _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET return r_u->status; } + +/*********************************************************************************** + It may be that we want to limit users to creating shares on certain areas of the UNIX file area. + We could define areas by mapping Windows style disks to points on the UNIX directory hierarchy. + These disks would the disks listed by this function. + Users could then create shares relative to these disks. Watch out for moving these disks around. + "Nigel Williams" . +/***********************************************************************************/ + +const char *server_disks[] = {"C:"}; + +static uint32 get_server_disk_count(void) +{ + return sizeof(server_disks)/sizeof(server_disks[0]); +} + +static uint32 init_server_disk_enum(uint32 *resume) +{ + uint32 server_disk_count = get_server_disk_count(); + + /*resume can be an offset into the list for now*/ + + if(*resume < 0) + *resume = 0; + + if(*resume > server_disk_count) + *resume = server_disk_count; + + return server_disk_count - *resume; +} + +static const char *next_server_disk_enum(uint32 *resume) +{ + const char *disk; + + if(init_server_disk_enum(resume) == 0) + return NULL; + + disk = server_disks[*resume]; + + (*resume)++; + + DEBUG(10, ("next_server_disk_enum: reporting disk %s. resume handle %d.\n", disk, *resume)); + + return disk; +} + +uint32 _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_DISK_ENUM *r_u) +{ + uint32 i; + const char *disk_name; + uint32 resume=get_enum_hnd(&q_u->enum_hnd); + + r_u->status=NT_STATUS_NOPROBLEMO; + + r_u->total_entries = init_server_disk_enum(&resume); + + r_u->disk_enum_ctr.unknown = 0; + + r_u->disk_enum_ctr.disk_info_ptr = (uint32) r_u->disk_enum_ctr.disk_info; + + /*allow one DISK_INFO for null terminator*/ + + for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(&resume)); i++) { + + r_u->disk_enum_ctr.entries_read++; + + /*copy disk name into a unicode string*/ + + init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name); + } + + /*add a terminating null string. Is this there if there is more data to come?*/ + + r_u->disk_enum_ctr.entries_read++; + + init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, ""); + + init_enum_hnd(&r_u->enum_hnd, resume); + + return r_u->status; +} + +uint32 _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV_R_NET_NAME_VALIDATE *r_u) +{ + int snum; + fstring share_name; + + r_u->status=NT_STATUS_NOPROBLEMO; + + switch(q_u->type) { + + case 0x9: + + /*check if share name is ok*/ + /*also check if we already have a share with this name*/ + + unistr2_to_ascii(share_name, &q_u->uni_name, sizeof(share_name)); + snum = find_service(share_name); + + /* Share already exists. */ + if (snum >= 0) + r_u->status = NT_STATUS_OBJECT_NAME_INVALID; + break; + + default: + /*unsupported type*/ + r_u->status = ERROR_INVALID_LEVEL; + break; + } + + return r_u->status; +} -- cgit From e51cc47cec2e3a5fe4e23310f497bf6a13b0a577 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 1 May 2001 04:02:15 +0000 Subject: fixed comment-in-comment (This used to be commit 4c456c82642649a6dfaadf578488119d195c5b6b) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 48961dcb64..b3c95c6c32 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1569,7 +1569,7 @@ uint32 _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET These disks would the disks listed by this function. Users could then create shares relative to these disks. Watch out for moving these disks around. "Nigel Williams" . -/***********************************************************************************/ + ***********************************************************************************/ const char *server_disks[] = {"C:"}; -- cgit From 3c525aaaa381055d34e2b66e95ae5320f3b9ac58 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 2 May 2001 08:14:00 +0000 Subject: Remove embedded '/*' in comment. Jeremy. (This used to be commit 9a85dc9cdbc6409e25a528be4be960d4eb3ac117) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index b3c95c6c32..93c3e18ca7 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1569,7 +1569,7 @@ uint32 _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET These disks would the disks listed by this function. Users could then create shares relative to these disks. Watch out for moving these disks around. "Nigel Williams" . - ***********************************************************************************/ +***********************************************************************************/ const char *server_disks[] = {"C:"}; -- cgit From dea501bc5fbafddef502c788cf7f44d9034e0fcd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 2 May 2001 20:32:17 +0000 Subject: Fix noticed by John Trostel - we need to return our account SID for level 5. Jeremy. (This used to be commit acf32f277d1a45f49fa3bf6af82850e35df9ae5a) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 6f1719b530..9d80cb5b82 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -394,7 +394,7 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO break; case ROLE_STANDALONE: name = global_myname; - sid = NULL; /* Tell it we're not in a domain. */ + sid = &global_sam_sid; break; default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; -- cgit From f35157f39293f9fa240a28642c41708b55d301c8 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 4 May 2001 15:44:27 +0000 Subject: Big cleanup of passdb and backends. I did some basic tests but I have probably broken something. Notably the password changing. So don't cry ;-) J.F. (This used to be commit a4a4c02b12f030a3b9e6225b999c90689dfc4719) --- source3/rpc_server/srv_netlog_nt.c | 90 +++-- source3/rpc_server/srv_pipe.c | 29 +- source3/rpc_server/srv_samr.c | 129 +++--- source3/rpc_server/srv_samr_nt.c | 782 ++++++++++++++++++++++--------------- source3/rpc_server/srv_util.c | 29 +- 5 files changed, 602 insertions(+), 457 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 6b1fe64ddc..2047aaf255 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -119,6 +119,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) { SAM_ACCOUNT *sampass = NULL; uint8 *pass; + BOOL ret; #if 0 /* @@ -138,23 +139,31 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) } #endif /* 0 */ - /* JRA. This is ok as it is only used for generating the challenge. */ + if(!pdb_init_sam(&sampass)) + return False; + /* JRA. This is ok as it is only used for generating the challenge. */ become_root(); - sampass = pdb_getsampwnam(mach_acct); + ret=pdb_getsampwnam(sampass, mach_acct); unbecome_root(); - if ((sampass) != NULL && !(pdb_get_acct_ctrl(sampass) & ACB_DISABLED) && - ((pass=pdb_get_nt_passwd(sampass)) != NULL)) - { + if (ret==False) { + DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); + pdb_clear_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_clear_sam(sampass); return True; } - + DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); + pdb_clear_sam(sampass); return False; + } /************************************************************************* @@ -308,7 +317,7 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ uint32 status = NT_STATUS_WRONG_PASSWORD; DOM_CRED srv_cred; pstring mach_acct; - SAM_ACCOUNT *sampass; + SAM_ACCOUNT *sampass=NULL; BOOL ret = False; unsigned char pwd[16]; int i; @@ -328,15 +337,19 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ 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(); - sampass = pdb_getsampwnam(mach_acct); + ret=pdb_getsampwnam(sampass, mach_acct); unbecome_root(); /* Ensure the account exists and is a machine account. */ - if (sampass == NULL || !(pdb_get_acct_ctrl(sampass) & ACB_WSTRUST)) + if (ret==False || !(pdb_get_acct_ctrl(sampass) & ACB_WSTRUST)) { + pdb_clear_sam(sampass); return NT_STATUS_NO_SUCH_USER; + } /* * Check the machine account name we're changing is the same @@ -344,8 +357,10 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ * machines changing other machine account passwords. */ - if (!strequal(mach_acct, p->dc.mach_acct)) + if (!strequal(mach_acct, p->dc.mach_acct)) { + pdb_clear_sam(sampass); return NT_STATUS_ACCESS_DENIED; + } DEBUG(100,("Server password set : new given value was :\n")); @@ -370,6 +385,7 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ /* set up the LSA Server Password Set response */ init_net_r_srv_pwset(r_u, &srv_cred, status); + pdb_clear_sam(sampass); return r_u->status; } @@ -500,26 +516,28 @@ static uint32 net_login_network(NET_ID_INFO_2 *id2, SAM_ACCOUNT *sampass) uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_u) { uint32 status = NT_STATUS_NOPROBLEMO; - NET_USER_INFO_3 *usr_info = NULL; - DOM_CRED srv_cred; - SAM_ACCOUNT *sampass = NULL; + NET_USER_INFO_3 *usr_info = NULL; + DOM_CRED srv_cred; + SAM_ACCOUNT *sampass = NULL; uint16 acct_ctrl; - UNISTR2 *uni_samlogon_user = NULL; - fstring nt_username; + UNISTR2 *uni_samlogon_user = NULL; + fstring nt_username; + BOOL ret; usr_info = (NET_USER_INFO_3 *)talloc(p->mem_ctx, sizeof(NET_USER_INFO_3)); if (!usr_info) return NT_STATUS_NO_MEMORY; + ZERO_STRUCTP(usr_info); - if (!get_valid_user_struct(p->vuid)) - return NT_STATUS_NO_SUCH_USER; + if (!get_valid_user_struct(p->vuid)) + return NT_STATUS_NO_SUCH_USER; - /* checks and updates credentials. creates reply credentials */ - if (!deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred)) - return NT_STATUS_INVALID_HANDLE; - else - memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); + /* checks and updates credentials. creates reply credentials */ + if (!deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred)) + return NT_STATUS_INVALID_HANDLE; + else + memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); r_u->buffer_creds = 1; /* yes, we have valid server credentials */ memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds)); @@ -530,7 +548,7 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ r_u->auth_resp = 1; /* authoritative response */ r_u->switch_value = 3; /* indicates type of validation user info */ - /* find the username */ + /* find the username */ switch (q_u->sam_id.logon_level) { case INTERACTIVE_LOGON_TYPE: @@ -560,18 +578,24 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ map_username(nt_username); + pdb_init_sam(&sampass); + /* get the account information */ become_root(); - sampass = pdb_getsampwnam(nt_username); + ret = pdb_getsampwnam(sampass, nt_username); unbecome_root(); - if (sampass == NULL) + if (ret == False){ + pdb_clear_sam(sampass); return NT_STATUS_NO_SUCH_USER; + } acct_ctrl = pdb_get_acct_ctrl(sampass); - if (acct_ctrl & ACB_DISABLED) + if (acct_ctrl & ACB_DISABLED) { + pdb_clear_sam(sampass); return NT_STATUS_ACCOUNT_DISABLED; + } /* Validate password - if required. */ @@ -588,8 +612,10 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ } } - if (status != NT_STATUS_NOPROBLEMO) + if (status != NT_STATUS_NOPROBLEMO) { + pdb_clear_sam(sampass); return status; + } /* lkclXXXX this is the point at which, if the login was successful, that the SAM Local Security Authority should @@ -633,7 +659,7 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ sam_logon_in_ssb = False; - init_net_user_info3(p->mem_ctx, usr_info, sampass, + init_net_user_info3(p->mem_ctx, usr_info, sampass, 0, /* logon_count */ 0, /* bad_pw_count */ num_gids, /* uint32 num_groups */ @@ -644,7 +670,7 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ my_workgroup, /* char *logon_dom */ &global_sam_sid, /* DOM_SID *dom_sid */ NULL); /* char *other_sids */ - } - - return status; + } + pdb_clear_sam(sampass); + return status; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 0654f24493..7060979ce4 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -370,27 +370,32 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name return False; } - if(!(sampass = pdb_getsampwnam(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_clear_sam(sampass); unbecome_root(); return False; } unbecome_root(); - /* 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); - } + /* 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)); + pdb_clear_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); - } + if(!pdb_get_nt_passwd(sampass)) { + DEBUG(1,("Account for user '%s' has no NT password hash.\n", pipe_user_name)); + pdb_clear_sam(sampass); + return False; + } - smb_passwd_ptr = pdb_get_lanman_passwd(sampass); + smb_passwd_ptr = pdb_get_lanman_passwd(sampass); } /* @@ -454,6 +459,8 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name guest_user); p->ntlmssp_auth_validated = True; + + pdb_clear_sam(sampass); return True; } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index ca7be9831a..5012f0c483 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1284,86 +1284,55 @@ static BOOL api_samr_unknown_2d(pipes_struct *p) static struct api_struct api_samr_cmds [] = { - {"SAMR_CLOSE_HND", SAMR_CLOSE_HND, api_samr_close_hnd}, - {"SAMR_CONNECT", SAMR_CONNECT, api_samr_connect}, - {"SAMR_CONNECT_ANON", SAMR_CONNECT_ANON, api_samr_connect_anon}, - {"SAMR_ENUM_DOMAINS", SAMR_ENUM_DOMAINS, api_samr_enum_domains}, - {"SAMR_ENUM_DOM_USERS", SAMR_ENUM_DOM_USERS, api_samr_enum_dom_users}, - - {"SAMR_ENUM_DOM_GROUPS", SAMR_ENUM_DOM_GROUPS, api_samr_enum_dom_groups}, - {"SAMR_ENUM_DOM_ALIASES", SAMR_ENUM_DOM_ALIASES, api_samr_enum_dom_aliases}, - {"SAMR_QUERY_USERALIASES", SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, - {"SAMR_QUERY_ALIASMEM", SAMR_QUERY_ALIASMEM, api_samr_query_aliasmem}, - {"SAMR_QUERY_GROUPMEM", SAMR_QUERY_GROUPMEM, api_samr_query_groupmem}, - {"SAMR_ADD_ALIASMEM", SAMR_ADD_ALIASMEM, api_samr_add_aliasmem}, - {"SAMR_DEL_ALIASMEM", SAMR_DEL_ALIASMEM, api_samr_del_aliasmem}, - {"SAMR_ADD_GROUPMEM", SAMR_ADD_GROUPMEM, api_samr_add_groupmem}, - {"SAMR_DEL_GROUPMEM", SAMR_DEL_GROUPMEM, api_samr_del_groupmem}, - - {"SAMR_DELETE_DOM_USER", SAMR_DELETE_DOM_USER, api_samr_delete_dom_user}, - {"SAMR_DELETE_DOM_GROUP", SAMR_DELETE_DOM_GROUP, api_samr_delete_dom_group}, - {"SAMR_DELETE_DOM_ALIAS", SAMR_DELETE_DOM_ALIAS, api_samr_delete_dom_alias}, - {"SAMR_CREATE_DOM_GROUP", SAMR_CREATE_DOM_GROUP, api_samr_create_dom_group}, - {"SAMR_CREATE_DOM_ALIAS", SAMR_CREATE_DOM_ALIAS, api_samr_create_dom_alias}, - {"SAMR_LOOKUP_NAMES", SAMR_LOOKUP_NAMES, api_samr_lookup_names}, - {"SAMR_OPEN_USER", SAMR_OPEN_USER, api_samr_open_user}, - {"SAMR_QUERY_USERINFO", SAMR_QUERY_USERINFO, api_samr_query_userinfo}, - {"SAMR_SET_USERINFO", SAMR_SET_USERINFO, api_samr_set_userinfo}, - {"SAMR_SET_USERINFO2", SAMR_SET_USERINFO2, api_samr_set_userinfo2}, - - {"SAMR_QUERY_DOMAIN_INFO", SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info}, - {"SAMR_QUERY_USERGROUPS", SAMR_QUERY_USERGROUPS, api_samr_query_usergroups}, - {"SAMR_QUERY_DISPINFO", SAMR_QUERY_DISPINFO, api_samr_query_dispinfo}, - {"SAMR_QUERY_DISPINFO3", SAMR_QUERY_DISPINFO3, api_samr_query_dispinfo}, - {"SAMR_QUERY_DISPINFO4", SAMR_QUERY_DISPINFO4, api_samr_query_dispinfo}, - - {"SAMR_QUERY_ALIASINFO", SAMR_QUERY_ALIASINFO, api_samr_query_aliasinfo}, - {"SAMR_QUERY_GROUPINFO", SAMR_QUERY_GROUPINFO, api_samr_query_groupinfo}, - {"SAMR_SET_GROUPINFO", SAMR_SET_GROUPINFO, api_samr_set_groupinfo}, - {"SAMR_CREATE_USER", SAMR_CREATE_USER, api_samr_create_user}, - {"SAMR_LOOKUP_RIDS", SAMR_LOOKUP_RIDS, api_samr_lookup_rids}, - {"SAMR_GET_DOM_PWINFO", SAMR_GET_DOM_PWINFO, api_samr_get_dom_pwinfo}, - {"SAMR_CHGPASSWD_USER", SAMR_CHGPASSWD_USER, api_samr_chgpasswd_user}, - {"SAMR_OPEN_ALIAS", SAMR_OPEN_ALIAS, api_samr_open_alias}, - {"SAMR_OPEN_GROUP", SAMR_OPEN_GROUP, api_samr_open_group}, - {"SAMR_OPEN_DOMAIN", SAMR_OPEN_DOMAIN, api_samr_open_domain}, - {"SAMR_UNKNOWN_2D", SAMR_UNKNOWN_2D, api_samr_unknown_2d}, - {"SAMR_LOOKUP_DOMAIN", SAMR_LOOKUP_DOMAIN, api_samr_lookup_domain}, - - {"SAMR_QUERY_SEC_OBJECT", SAMR_QUERY_SEC_OBJECT, api_samr_query_sec_obj}, - {"SAMR_GET_USRDOM_PWINFO", SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, - {NULL, 0, NULL} - -#if 0 - - { "SAMR_CLOSE_HND" , SAMR_CLOSE_HND , api_samr_close_hnd }, - { "SAMR_CONNECT" , SAMR_CONNECT , api_samr_connect }, - { "SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon }, - { "SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users }, - { "SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, - { "SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, - { "SAMR_LOOKUP_IDS" , SAMR_LOOKUP_IDS , api_samr_lookup_ids }, - { "SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, - { "SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, - { "SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, - { "SAMR_QUERY_DOMAIN_INFO", SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, - { "SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, - { "SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, - { "SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, - { "SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user }, - { "SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids }, - { "SAMR_UNKNOWN_38" , SAMR_UNKNOWN_38 , api_samr_unknown_38 }, - { "SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, - { "SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, - { "SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, - { "SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, - { "SAMR_GET_USRDOM_PWINFO", SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, - { "SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, - { "SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains }, - { "SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo }, - { "SAMR_SET_USERINFO2" , SAMR_SET_USERINFO2 , api_samr_set_userinfo2 }, - { NULL , 0 , NULL } -#endif + {"SAMR_CLOSE_HND" , SAMR_CLOSE_HND , api_samr_close_hnd }, + {"SAMR_CONNECT" , SAMR_CONNECT , api_samr_connect }, + {"SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon }, + {"SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains }, + {"SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users }, + + {"SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, + {"SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, + {"SAMR_QUERY_USERALIASES" , SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, + {"SAMR_QUERY_ALIASMEM" , SAMR_QUERY_ALIASMEM , api_samr_query_aliasmem }, + {"SAMR_QUERY_GROUPMEM" , SAMR_QUERY_GROUPMEM , api_samr_query_groupmem }, + {"SAMR_ADD_ALIASMEM" , SAMR_ADD_ALIASMEM , api_samr_add_aliasmem }, + {"SAMR_DEL_ALIASMEM" , SAMR_DEL_ALIASMEM , api_samr_del_aliasmem }, + {"SAMR_ADD_GROUPMEM" , SAMR_ADD_GROUPMEM , api_samr_add_groupmem }, + {"SAMR_DEL_GROUPMEM" , SAMR_DEL_GROUPMEM , api_samr_del_groupmem }, + + {"SAMR_DELETE_DOM_USER" , SAMR_DELETE_DOM_USER , api_samr_delete_dom_user }, + {"SAMR_DELETE_DOM_GROUP" , SAMR_DELETE_DOM_GROUP , api_samr_delete_dom_group }, + {"SAMR_DELETE_DOM_ALIAS" , SAMR_DELETE_DOM_ALIAS , api_samr_delete_dom_alias }, + {"SAMR_CREATE_DOM_GROUP" , SAMR_CREATE_DOM_GROUP , api_samr_create_dom_group }, + {"SAMR_CREATE_DOM_ALIAS" , SAMR_CREATE_DOM_ALIAS , api_samr_create_dom_alias }, + {"SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, + {"SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, + {"SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, + {"SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo }, + {"SAMR_SET_USERINFO2" , SAMR_SET_USERINFO2 , api_samr_set_userinfo2 }, + + {"SAMR_QUERY_DOMAIN_INFO" , SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, + {"SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, + {"SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, + {"SAMR_QUERY_DISPINFO3" , SAMR_QUERY_DISPINFO3 , api_samr_query_dispinfo }, + {"SAMR_QUERY_DISPINFO4" , SAMR_QUERY_DISPINFO4 , api_samr_query_dispinfo }, + + {"SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, + {"SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, + {"SAMR_SET_GROUPINFO" , SAMR_SET_GROUPINFO , api_samr_set_groupinfo }, + {"SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user }, + {"SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids }, + {"SAMR_GET_DOM_PWINFO" , SAMR_GET_DOM_PWINFO , api_samr_get_dom_pwinfo }, + {"SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, + {"SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, + {"SAMR_OPEN_GROUP" , SAMR_OPEN_GROUP , api_samr_open_group }, + {"SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, + {"SAMR_UNKNOWN_2D" , SAMR_UNKNOWN_2D , api_samr_unknown_2d }, + {"SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, + + {"SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, + {"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, + {NULL , 0 , NULL } }; /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7054f85ff9..38b4bbd0a9 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -74,15 +74,13 @@ static void samr_clear_passwd_fields( SAM_USER_INFO_21 *pass, int num_entries) } } -static void samr_clear_sam_passwd( SAM_ACCOUNT *sam_pass) +static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) { if (!sam_pass) return; - if (sam_pass->lm_pw) - memset(sam_pass->lm_pw, '\0', 16); - if (sam_pass->nt_pw) - memset(sam_pass->nt_pw, '\0', 16); + memset(sam_pass->lm_pw, '\0', 16); + memset(sam_pass->nt_pw, '\0', 16); } /******************************************************************* @@ -94,20 +92,24 @@ static BOOL 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) { - SAM_ACCOUNT *pwd = NULL; + SAM_ACCOUNT *pwd = NULL; + BOOL ret; + + (*num_entries) = 0; + (*total_entries) = 0; - (*num_entries) = 0; - (*total_entries) = 0; + if (pw_buf == NULL) + return False; - if (pw_buf == NULL) - return False; + pdb_init_sam(&pwd); if (!pdb_setsampwent(False)) { - DEBUG(0, ("get_sampwd_entries: Unable to open passdb.\n")); - return False; - } + DEBUG(0, ("get_sampwd_entries: Unable to open passdb.\n")); + pdb_clear_sam(pwd); + return False; + } - while (((pwd = pdb_getsampwent()) != NULL) && (*num_entries) < max_num_entries) { + while (((ret = pdb_getsampwent(pwd)) != False) && (*num_entries) < max_num_entries) { int user_name_len; if (start_idx > 0) { @@ -143,29 +145,35 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, (*total_entries)++; } - pdb_endsampwent(); + pdb_endsampwent(); + pdb_clear_sam(pwd); - return (*num_entries) > 0; + return (*num_entries) > 0; } static BOOL 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) { - SAM_ACCOUNT *pwd = NULL; + SAM_ACCOUNT *pwd = NULL; *num_entries = 0; *total_entries = 0; if (pw_buf == NULL) return False; + + DEBUG(10,("jf_get_sampwd_entries: start index:%d, max entries:%d, mask:%d\n", + start_idx, max_num_entries, acb_mask)); if (!pdb_setsampwent(False)) { - DEBUG(0, ("jf_get_sampwd_entries: Unable to open passdb.\n")); - return False; - } + DEBUG(0, ("jf_get_sampwd_entries: Unable to open passdb.\n")); + return False; + } + + pdb_init_sam(&pwd); - while (((pwd = pdb_getsampwent()) != NULL) && (*num_entries) < max_num_entries) { + while ((pdb_getsampwent(pwd) != False) && (*num_entries) < max_num_entries) { int user_name_len; int full_name_len; @@ -194,19 +202,23 @@ static BOOL jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, memset((char *)pw_buf[(*num_entries)].nt_pwd, '\0', 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); + 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); 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) )); + (*num_entries)++; } - pdb_endsampwent(); + pdb_endsampwent(); *total_entries = *num_entries; + + pdb_clear_sam(pwd); + return True; } @@ -756,35 +768,42 @@ 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 BOOL get_group_alias_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, uint32 *p_num_entries, uint32 max_entries) { fstring sid_str; - fstring sam_sid_str; uint32 num_entries = 0; + int i; + GROUP_MAP smap; + GROUP_MAP *map; sid_to_string(sid_str, sid); - sid_to_string(sam_sid_str, &global_sam_sid); + DEBUG(5, ("get_group_alias_entries: enumerating aliases on SID: %s\n", sid_str)); *p_num_entries = 0; /* well-known aliases */ - if (strequal(sid_str, "S-1-5-32")) { - char *name; - while (!lp_hide_local_users() && - num_entries < max_entries && - ((name = builtin_alias_rids[num_entries].name) != NULL)) { - - fstrcpy(d_grp[num_entries].name, name); - d_grp[num_entries].rid = builtin_alias_rids[num_entries].rid; + if (sid_equal(sid, &global_sid_Builtin) && !lp_hide_local_users()) { + + enum_group_mapping(SID_NAME_WKN_GRP, &map, &num_entries, ENUM_ONLY_MAPPED); + + *d_grp=(DOMAIN_GRP *)malloc(num_entries*sizeof(DOMAIN_GRP)); + if (*d_grp==NULL) + return NT_STATUS_NO_MEMORY; + + for(i=0; igr_name; + + if(!get_group_from_gid(grp->gr_gid, &smap)) + continue; + + if (smap.sid_name_use!=SID_NAME_ALIAS) + continue; - DEBUG(10,("get_group_alias_entries: got group %s\n", name )); + sid_split_rid(&smap.sid, &trid); /* Don't return winbind groups as they are not local! */ - - if (strchr(name, *sep) != NULL) { - DEBUG(10,("get_group_alias_entries: not returing %s, not local.\n", name )); + if (strchr(smap.nt_name, *sep) != NULL) { + DEBUG(10,("get_group_alias_entries: not returing %s, not local.\n", smap.nt_name )); continue; } /* Don't return user private groups... */ - if (Get_Pwnam(name, False) != 0) { - DEBUG(10,("get_group_alias_entries: not returing %s, clashes with user.\n", name )); - continue; + if (Get_Pwnam(smap.nt_name, False) != 0) { + DEBUG(10,("get_group_alias_entries: not returing %s, clashes with user.\n", smap.nt_name )); + continue; } - trid = pdb_gid_to_group_rid(grp->gr_gid); for( i = 0; i < num_entries; i++) - if ( d_grp[i].rid == trid ) break; + if ( (*d_grp)[i].rid == trid ) break; if ( i < num_entries ) continue; /* rid was there, dup! */ @@ -830,8 +852,12 @@ static BOOL get_group_alias_entries(DOMAIN_GRP *d_grp, DOM_SID *sid, uint32 star continue; } - fstrcpy(d_grp[num_entries].name, name); - d_grp[num_entries].rid = trid; + *d_grp=Realloc(*d_grp, (num_entries+1)*sizeof(DOMAIN_GRP)); + if (*d_grp==NULL) + return NT_STATUS_NO_MEMORY; + + fstrcpy((*d_grp)[num_entries].name, smap.nt_name); + (*d_grp)[num_entries].rid = trid; num_entries++; } @@ -847,31 +873,29 @@ static BOOL get_group_alias_entries(DOMAIN_GRP *d_grp, DOM_SID *sid, uint32 star Get the group entries - similar to get_sampwd_entries(). ********************************************************************/ -static BOOL get_group_domain_entries(DOMAIN_GRP *d_grp, DOM_SID *sid, uint32 start_idx, +static BOOL get_group_domain_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, uint32 *p_num_entries, uint32 max_entries) { - fstring sid_str; - fstring sam_sid_str; + GROUP_MAP *map=NULL; + int i; uint32 num_entries = 0; - fstring name="Domain Admins"; - fstring comment="Just to make it work !"; - - sid_to_string(sid_str, sid); - sid_to_string(sam_sid_str, &global_sam_sid); *p_num_entries = 0; - fstrcpy(d_grp[0].name, name); - fstrcpy(d_grp[0].comment, comment); - d_grp[0].rid = DOMAIN_GROUP_RID_ADMINS; - d_grp[0].attr=SID_NAME_DOM_GRP; + enum_group_mapping(SID_NAME_DOM_GRP, &map, &num_entries, ENUM_ONLY_MAPPED); - fstrcpy(d_grp[1].name, "Domain Users"); - fstrcpy(d_grp[1].comment, "Just to make it work !"); - d_grp[1].rid = DOMAIN_GROUP_RID_USERS; - d_grp[1].attr=SID_NAME_DOM_GRP; + *d_grp=(DOMAIN_GRP *)malloc(num_entries*sizeof(DOMAIN_GRP)); + if (*d_grp==NULL) + return False; + + for (i=0; istart_idx, &num_entries, MAX_SAM_ENTRIES); + /* the domain group array is being allocated in the function below */ + get_group_domain_entries(&grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp); + safe_free(grp); + init_samr_r_enum_dom_groups(r_u, q_u->start_idx, num_entries); DEBUG(5,("samr_enum_dom_groups: %d\n", __LINE__)); @@ -915,7 +942,7 @@ uint32 _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_ uint32 _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, SAMR_R_ENUM_DOM_ALIASES *r_u) { - DOMAIN_GRP grp[MAX_SAM_ENTRIES]; + DOMAIN_GRP *grp=NULL; uint32 num_entries = 0; fstring sid_str; DOM_SID sid; @@ -928,11 +955,13 @@ 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)) + if (!get_group_alias_entries(&grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES)) return NT_STATUS_ACCESS_DENIED; make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp); + safe_free(grp); + init_samr_r_enum_dom_aliases(r_u, q_u->start_idx, num_entries); DEBUG(5,("samr_enum_dom_aliases: %d\n", __LINE__)); @@ -947,12 +976,12 @@ uint32 _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, SAM uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_QUERY_DISPINFO *r_u) { SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; - DOMAIN_GRP grps[MAX_SAM_ENTRIES]; + DOMAIN_GRP *grps=NULL; uint16 acb_mask = ACB_NORMAL; - uint32 num_entries = 0; - int orig_num_entries = 0; - int total_entries = 0; - uint32 data_size = 0; + uint32 num_entries = 0; + int orig_num_entries = 0; + int total_entries = 0; + uint32 data_size = 0; DOM_SID sid; BOOL ret; SAM_DISPINFO_CTR *ctr; @@ -1001,7 +1030,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ break; case 0x3: case 0x5: - ret = get_group_domain_entries(grps, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); + ret = get_group_domain_entries(&grps, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); if (!ret) return NT_STATUS_ACCESS_DENIED; break; @@ -1040,6 +1069,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ case 0x3: ctr->sam.info3 = (SAM_DISPINFO_3 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_3)); init_sam_dispinfo_3(ctr->sam.info3, &num_entries, &data_size, q_u->start_idx, grps); + safe_free(grps); break; case 0x4: ctr->sam.info4 = (SAM_DISPINFO_4 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_4)); @@ -1048,6 +1078,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ case 0x5: ctr->sam.info5 = (SAM_DISPINFO_5 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_5)); init_sam_dispinfo_5(ctr->sam.info5, &num_entries, &data_size, q_u->start_idx, grps); + safe_free(grps); break; default: ctr->sam.info = NULL; @@ -1368,49 +1399,53 @@ 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) { - SAM_ACCOUNT *sampass; - 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_NO_PROBLEMO; - /* 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(); - sampass = pdb_getsampwrid(user_rid); - unbecome_root(); + become_root(); + ret=pdb_getsampwrid(sampass, user_rid); + unbecome_root(); - /* check that the RID exists in our domain. */ - if (sampass == NULL) - return NT_STATUS_NO_SUCH_USER; + /* check that the RID exists in our domain. */ + if (ret == False) { + pdb_clear_sam(sampass); + return NT_STATUS_NO_SUCH_USER; + } samr_clear_sam_passwd(sampass); + pdb_clear_sam(sampass); - /* Get the domain SID stored in the domain policy */ - if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid)) - return NT_STATUS_INVALID_HANDLE; + /* Get the domain SID stored in the domain policy */ + if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid)) + return NT_STATUS_INVALID_HANDLE; - /* append the user's RID to it */ - if(!sid_append_rid(&sid, user_rid)) - return NT_STATUS_NO_SUCH_USER; + /* append the user's RID to it */ + if(!sid_append_rid(&sid, user_rid)) + 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) - return NT_STATUS_NO_MEMORY; + /* 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; - ZERO_STRUCTP(info); - info->sid = sid; + 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)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; + /* 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; + return r_u->status; } /************************************************************************* @@ -1419,27 +1454,34 @@ 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) { - SAM_ACCOUNT *smbpass; + 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(); - smbpass = pdb_getsampwrid(user_rid); - unbecome_root(); + pdb_init_sam(&smbpass); - if (smbpass == NULL) { - DEBUG(4,("User 0x%x not found\n", user_rid)); - return False; - } + become_root(); + ret = pdb_getsampwrid(smbpass, user_rid); + unbecome_root(); + + if (ret==False) { + DEBUG(4,("User 0x%x not found\n", user_rid)); + pdb_clear_sam(smbpass); + return False; + } + + DEBUG(3,("User:[%s]\n", pdb_get_username(smbpass) )); - DEBUG(3,("User:[%s]\n", pdb_get_username(smbpass) )); + init_sam_user_info10(id10, pdb_get_acct_ctrl(smbpass) ); - init_sam_user_info10(id10, pdb_get_acct_ctrl(smbpass) ); + samr_clear_sam_passwd(smbpass); + pdb_clear_sam(smbpass); - return True; + return True; } /************************************************************************* @@ -1450,7 +1492,8 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) static uint32 get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint32 user_rid) { - SAM_ACCOUNT *smbpass; + SAM_ACCOUNT *smbpass=NULL; + BOOL ret; if (!p->ntlmssp_auth_validated) return NT_STATUS_ACCESS_DENIED; @@ -1461,20 +1504,26 @@ static uint32 get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint32 /* * Do *NOT* do become_root()/unbecome_root() here ! JRA. */ + pdb_init_sam(&smbpass); - smbpass = pdb_getsampwrid(user_rid); + ret = pdb_getsampwrid(smbpass, user_rid); - if (smbpass == NULL) { + if (ret == False) { DEBUG(4, ("User 0x%x not found\n", user_rid)); + pdb_clear_sam(smbpass); return (geteuid() == (uid_t)0) ? NT_STATUS_NO_SUCH_USER : NT_STATUS_ACCESS_DENIED; } - DEBUG(3,("User:[%s] 0x%x\n", pdb_get_username(smbpass), pdb_get_acct_ctrl(smbpass) )); + DEBUG(3,("User:[%s] 0x%x\n", pdb_get_username(smbpass), pdb_get_acct_ctrl(smbpass) )); - if ( pdb_get_acct_ctrl(smbpass) & ACB_DISABLED) - return NT_STATUS_ACCOUNT_DISABLED; + if ( pdb_get_acct_ctrl(smbpass) & ACB_DISABLED) { + pdb_clear_sam(smbpass); + return NT_STATUS_ACCOUNT_DISABLED; + } init_sam_user_info12(id12, pdb_get_lanman_passwd(smbpass), pdb_get_nt_passwd(smbpass)); + + pdb_clear_sam(smbpass); return NT_STATUS_NOPROBLEMO; } @@ -1485,29 +1534,33 @@ static uint32 get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint32 static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) { - SAM_ACCOUNT *sampass; + 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(); - sampass = pdb_getsampwrid(user_rid); - unbecome_root(); + become_root(); + ret = pdb_getsampwrid(sampass, user_rid); + unbecome_root(); - if (sampass == NULL) { - DEBUG(4,("User 0x%x not found\n", user_rid)); - return False; - } + if (ret == False) { + DEBUG(4,("User 0x%x not found\n", user_rid)); + pdb_clear_sam(sampass); + return False; + } samr_clear_sam_passwd(sampass); - DEBUG(3,("User:[%s]\n", pdb_get_username(sampass) )); + DEBUG(3,("User:[%s]\n", pdb_get_username(sampass) )); init_sam_user_info21A(id21, sampass); + + pdb_clear_sam(sampass); - return True; + return True; } /******************************************************************* @@ -1610,44 +1663,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; + struct sam_passwd *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_NO_PROBLEMO; - 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 = pdb_getsampwrid(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, pdb_get_username(sam_pass)); - 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; } /******************************************************************* @@ -1708,111 +1766,124 @@ 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) { - SAM_ACCOUNT *sam_pass; - 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 = pdb_getsampwnam(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)); - close_policy_hnd(p, user_pol); - 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 = pdb_getsampwnam(mach_acct); - unbecome_root(); - if (sam_pass == NULL) { - /* account doesn't exist: say so */ - close_policy_hnd(p, user_pol); - 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)) { - close_policy_hnd(p, user_pol); - 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_clear_sam(sam_pass); + return NT_STATUS_USER_EXISTS; + } - /* append the user's RID to it */ - if(!sid_append_rid(&sid, pdb_get_user_rid(sam_pass) )) { - close_policy_hnd(p, user_pol); - 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)); + close_policy_hnd(p, user_pol); + pdb_clear_sam(sam_pass); + return NT_STATUS_ACCESS_DENIED; + } + + become_root(); + ret = pdb_getsampwnam(sam_pass, mach_acct); + unbecome_root(); + if (ret == False) { + /* account doesn't exist: say so */ + close_policy_hnd(p, user_pol); + pdb_clear_sam(sam_pass); + return NT_STATUS_ACCESS_DENIED; + } + + /* Get the domain SID stored in the domain policy */ + if(!get_lsa_policy_samr_sid(p, &dom_pol, &sid)) { + close_policy_hnd(p, user_pol); + pdb_clear_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) )) { + close_policy_hnd(p, user_pol); + pdb_clear_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_clear_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_clear_sam(sam_pass); + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } - r_u->user_rid=sam_pass->user_rid; - r_u->unknown_0 = 0x000703ff; + r_u->user_rid=sam_pass->user_rid; + r_u->unknown_0 = 0x000703ff; - return NT_STATUS_NO_PROBLEMO; + pdb_clear_sam(sam_pass); + + return NT_STATUS_NO_PROBLEMO; } /******************************************************************* @@ -1998,21 +2069,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) { - SAM_ACCOUNT *pwd = pdb_getsampwrid(rid); + SAM_ACCOUNT *pwd =NULL; + BOOL ret; + + pdb_init_sam(&pwd); + + ret = pdb_getsampwrid(pwd, rid); + + if(ret==False) { + pdb_clear_sam(pwd); + return False; + } if (id10 == NULL) { DEBUG(5, ("set_user_info_10: NULL id10\n")); + pdb_clear_sam(pwd); return False; } - pwd = pdb_getsampwrid(rid); - if (!pwd) - return False; - pdb_set_acct_ctrl(pwd, id10->acb_info); - if(!pdb_update_sam_account(pwd, True)) + if(!pdb_update_sam_account(pwd, True)) { + pdb_clear_sam(pwd); return False; + } + + pdb_clear_sam(pwd); return True; } @@ -2023,22 +2105,31 @@ 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) { - SAM_ACCOUNT *pwd = pdb_getsampwrid(rid); - - if (pwd == NULL) + SAM_ACCOUNT *pwd = NULL; + BOOL ret; + + pdb_init_sam(&pwd); + + if(!pdb_getsampwrid(pwd, rid)) { + pdb_clear_sam(pwd); return False; - + } + if (id12 == NULL) { DEBUG(2, ("set_user_info_12: id12 is NULL\n")); + pdb_clear_sam(pwd); return False; } pdb_set_lanman_passwd (pwd, id12->lm_pwd); pdb_set_nt_passwd (pwd, id12->nt_pwd); - if(!pdb_update_sam_account(pwd, True)) + if(!pdb_update_sam_account(pwd, True)) { + pdb_clear_sam(pwd); return False; - + } + + pdb_clear_sam(pwd); return True; } @@ -2048,21 +2139,26 @@ 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) { - SAM_ACCOUNT *pwd = pdb_getsampwrid(rid); - SAM_ACCOUNT new_pwd; + 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) + pdb_init_sam(&pwd); + pdb_init_sam(&new_pwd); + + if (!pdb_getsampwrid(pwd, rid)) { + pdb_clear_sam(pwd); + pdb_clear_sam(new_pwd); return False; + } /* we make a copy so that we can modify stuff */ - ZERO_STRUCT(new_pwd); - copy_sam_passwd(&new_pwd, pwd); - copy_id21_to_sam_passwd(&new_pwd, id21); + copy_sam_passwd(new_pwd, pwd); + copy_id21_to_sam_passwd(new_pwd, id21); /* * The funny part about the previous two calls is @@ -2072,9 +2168,15 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) */ /* write the change out */ - if(!pdb_update_sam_account(&new_pwd, True)) + if(!pdb_update_sam_account(new_pwd, True)) { + pdb_clear_sam(pwd); + pdb_clear_sam(new_pwd); return False; - + } + + pdb_clear_sam(pwd); + pdb_clear_sam(new_pwd); + return True; } @@ -2084,33 +2186,42 @@ 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) { - SAM_ACCOUNT *pwd = pdb_getsampwrid(rid); - SAM_ACCOUNT new_pwd; - uint8 nt_hash[16]; - uint8 lm_hash[16]; - pstring buf; - uint32 len; + 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 (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); - acct_ctrl = pdb_get_acct_ctrl(pwd); + if (pdb_getsampwrid(pwd, rid)) { + pdb_clear_sam(pwd); + pdb_clear_sam(new_pwd); + return False; + } - ZERO_STRUCT (new_pwd); - copy_sam_passwd(&new_pwd, pwd); - copy_id23_to_sam_passwd(&new_pwd, id23); + acct_ctrl = pdb_get_acct_ctrl(pwd); + + copy_sam_passwd(new_pwd, pwd); + pdb_clear_sam(pwd); + + copy_id23_to_sam_passwd(new_pwd, id23); - if (!decode_pw_buffer((char*)id23->pass, buf, 256, &len, nt_hash, lm_hash)) - return False; + if (!decode_pw_buffer((char*)id23->pass, buf, 256, &len, nt_hash, lm_hash)) { + pdb_clear_sam(new_pwd); + return False; + } - pdb_set_lanman_passwd (&new_pwd, lm_hash); - pdb_set_nt_passwd (&new_pwd, nt_hash); + pdb_set_lanman_passwd (new_pwd, lm_hash); + pdb_set_nt_passwd (new_pwd, nt_hash); /* if it's a trust account, don't update /etc/passwd */ if ( ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || @@ -2118,19 +2229,24 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) ( (acct_ctrl & ACB_SVRTRUST) == ACB_SVRTRUST) ) { DEBUG(5, ("Changing trust account password, not updating /etc/passwd\n")); } else { - /* update the UNIX password */ /* update the UNIX password */ if (lp_unix_password_sync() ) - if(!chgpasswd(pdb_get_username(&new_pwd), "", buf, True)) + if(!chgpasswd(pdb_get_username(new_pwd), "", buf, True)) { + pdb_clear_sam(new_pwd); return False; + } } - memset(buf, 0, sizeof(buf)); + memset(buf, 0, sizeof(buf)); - if(!pdb_update_sam_account(&new_pwd, True)) - return False; + if(!pdb_update_sam_account(new_pwd, True)) { + pdb_clear_sam(new_pwd); + return False; + } - return True; + pdb_clear_sam(new_pwd); + + return True; } /******************************************************************* @@ -2139,23 +2255,29 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) { - SAM_ACCOUNT *pwd = pdb_getsampwrid(rid); + SAM_ACCOUNT *pwd = NULL; uchar nt_hash[16]; uchar lm_hash[16]; uint32 len; pstring buf; uint16 acct_ctrl; - if (pwd == NULL) - return False; + pdb_init_sam(&pwd); + if (!pdb_getsampwrid(pwd, rid)) { + pdb_clear_sam(pwd); + return False; + } + acct_ctrl = pdb_get_acct_ctrl(pwd); memset(buf, 0, sizeof(buf)); - if (!decode_pw_buffer((char*)id24->pass, buf, 256, &len, nt_hash, lm_hash)) + if (!decode_pw_buffer((char*)id24->pass, buf, 256, &len, nt_hash, lm_hash)) { + pdb_clear_sam(pwd); return False; - + } + pdb_set_lanman_passwd (pwd, lm_hash); pdb_set_nt_passwd (pwd, nt_hash); @@ -2167,19 +2289,25 @@ static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) } else { /* update the UNIX password */ if (lp_unix_password_sync()) - if(!chgpasswd(pdb_get_username(pwd), "", buf, True)) + if(!chgpasswd(pdb_get_username(pwd), "", buf, True)) { + pdb_clear_sam(pwd); return False; + } } - memset(buf, 0, sizeof(buf)); - - DEBUG(0,("set_user_info_24: pdb_update_sam_account()\n")); + memset(buf, 0, sizeof(buf)); - /* update the SAMBA password */ - if(!pdb_update_sam_account(pwd, True)) - return False; + DEBUG(0,("set_user_info_24: pdb_update_sam_account()\n")); - return True; + /* update the SAMBA password */ + if(!pdb_update_sam_account(pwd, True)) { + pdb_clear_sam(pwd); + return False; + } + + pdb_clear_sam(pwd); + + return True; } /******************************************************************* @@ -2191,11 +2319,12 @@ 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; - SAM_ACCOUNT *sam_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__)); @@ -2222,6 +2351,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" @@ -2229,16 +2360,19 @@ uint32 _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_ */ become_root(); - sam_pass = pdb_getsampwuid(user.uid); + ret = pdb_getsampwuid(sam_pass, user.uid); unbecome_root(); - if(sam_pass == NULL) { + if(ret == False) { DEBUG(0,("_samr_set_userinfo: Unable to get smbpasswd entry for uid %u\n", (unsigned int)user.uid )); + pdb_clear_sam(sam_pass); return NT_STATUS_ACCESS_DENIED; } memset(sess_key, '\0', 16); mdfour(sess_key, pdb_get_nt_passwd(sam_pass), 16); + pdb_clear_sam(sam_pass); + /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { case 0x12: diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 82125a7085..b4472671fc 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -247,8 +247,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) { - SAM_ACCOUNT *sampwd; + SAM_ACCOUNT *sampwd=NULL; int i = 0; + BOOL ret; + (*type) = SID_NAME_USER; DEBUG(5,("lookup_user_name: rid: %d", rid)); @@ -259,26 +261,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(); - sampwd = pdb_getsampwrid(rid); + ret = pdb_getsampwrid(sampwd, rid); unbecome_root(); - if (sampwd != NULL) - { + if (ret == True) { fstrcpy(user_name, pdb_get_username(sampwd) ); DEBUG(5,(" = %s\n", user_name)); + pdb_clear_sam(sampwd); return 0x0; } DEBUG(5,(" none mapped\n")); + pdb_clear_sam(sampwd); return NT_STATUS_NONE_MAPPED; } @@ -325,19 +329,24 @@ uint32 local_lookup_alias_rid(char *alias_name, uint32 *rid) ********************************************************************/ uint32 local_lookup_user_rid(char *user_name, uint32 *rid) { - SAM_ACCOUNT *sampass; + SAM_ACCOUNT *sampass=NULL; + BOOL ret; + (*rid) = 0; + pdb_init_sam(&sampass); + /* find the user account */ become_root(); - sampass = pdb_getsampwnam(user_name); + ret = pdb_getsampwnam(sampass, user_name); unbecome_root(); - if (sampass != NULL) - { + if (ret == True) { (*rid) = pdb_get_user_rid(sampass); + pdb_clear_sam(sampass); return 0x0; } + pdb_clear_sam(sampass); return NT_STATUS_NONE_MAPPED; } -- cgit From 30c4c04c2f584857633ce7605555dcfb37a3e1af Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 7 May 2001 14:04:46 +0000 Subject: Patch from Simo: o sed 's/pdb_clear_sam/pdb_free_sam/g' o add pdb_reset_sam() o password changing should be ok now as well. (This used to be commit 96d0e7c3301ad990f6c83b9c216720cb32661fb5) --- source3/rpc_server/srv_netlog_nt.c | 20 ++++---- source3/rpc_server/srv_pipe.c | 8 ++-- source3/rpc_server/srv_samr_nt.c | 96 +++++++++++++++++++------------------- source3/rpc_server/srv_util.c | 8 ++-- 4 files changed, 66 insertions(+), 66 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 2047aaf255..065f94702c 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -149,19 +149,19 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) if (ret==False) { DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); - pdb_clear_sam(sampass); + 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_clear_sam(sampass); + pdb_free_sam(sampass); return True; } DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return False; } @@ -347,7 +347,7 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ /* Ensure the account exists and is a machine account. */ if (ret==False || !(pdb_get_acct_ctrl(sampass) & ACB_WSTRUST)) { - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return NT_STATUS_NO_SUCH_USER; } @@ -358,7 +358,7 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ */ if (!strequal(mach_acct, p->dc.mach_acct)) { - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return NT_STATUS_ACCESS_DENIED; } @@ -385,7 +385,7 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ /* set up the LSA Server Password Set response */ init_net_r_srv_pwset(r_u, &srv_cred, status); - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return r_u->status; } @@ -586,14 +586,14 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ unbecome_root(); if (ret == False){ - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return NT_STATUS_NO_SUCH_USER; } acct_ctrl = pdb_get_acct_ctrl(sampass); if (acct_ctrl & ACB_DISABLED) { - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return NT_STATUS_ACCOUNT_DISABLED; } @@ -613,7 +613,7 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ } if (status != NT_STATUS_NOPROBLEMO) { - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return status; } @@ -671,6 +671,6 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ &global_sam_sid, /* DOM_SID *dom_sid */ NULL); /* char *other_sids */ } - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return status; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 7060979ce4..345664a396 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -375,7 +375,7 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name 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_clear_sam(sampass); + pdb_free_sam(sampass); unbecome_root(); return False; } @@ -385,13 +385,13 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name /* 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)); - pdb_clear_sam(sampass); + 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)); - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return False; } @@ -460,7 +460,7 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name p->ntlmssp_auth_validated = True; - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return True; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 38b4bbd0a9..8c8418d2e0 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -105,7 +105,7 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, if (!pdb_setsampwent(False)) { DEBUG(0, ("get_sampwd_entries: Unable to open passdb.\n")); - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return False; } @@ -146,7 +146,7 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, } pdb_endsampwent(); - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return (*num_entries) > 0; } @@ -217,7 +217,7 @@ static BOOL jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, *total_entries = *num_entries; - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return True; } @@ -1419,12 +1419,12 @@ uint32 _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_U /* check that the RID exists in our domain. */ if (ret == False) { - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return NT_STATUS_NO_SUCH_USER; } samr_clear_sam_passwd(sampass); - pdb_clear_sam(sampass); + pdb_free_sam(sampass); /* Get the domain SID stored in the domain policy */ if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid)) @@ -1470,7 +1470,7 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) if (ret==False) { DEBUG(4,("User 0x%x not found\n", user_rid)); - pdb_clear_sam(smbpass); + pdb_free_sam(smbpass); return False; } @@ -1479,7 +1479,7 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) init_sam_user_info10(id10, pdb_get_acct_ctrl(smbpass) ); samr_clear_sam_passwd(smbpass); - pdb_clear_sam(smbpass); + pdb_free_sam(smbpass); return True; } @@ -1510,20 +1510,20 @@ static uint32 get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint32 if (ret == False) { DEBUG(4, ("User 0x%x not found\n", user_rid)); - pdb_clear_sam(smbpass); + 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", pdb_get_username(smbpass), pdb_get_acct_ctrl(smbpass) )); if ( pdb_get_acct_ctrl(smbpass) & ACB_DISABLED) { - pdb_clear_sam(smbpass); + pdb_free_sam(smbpass); return NT_STATUS_ACCOUNT_DISABLED; } init_sam_user_info12(id12, pdb_get_lanman_passwd(smbpass), pdb_get_nt_passwd(smbpass)); - pdb_clear_sam(smbpass); + pdb_free_sam(smbpass); return NT_STATUS_NOPROBLEMO; } @@ -1548,7 +1548,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) if (ret == False) { DEBUG(4,("User 0x%x not found\n", user_rid)); - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return False; } @@ -1558,7 +1558,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) init_sam_user_info21A(id21, sampass); - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return True; } @@ -1800,7 +1800,7 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR unbecome_root(); if (ret == True) { /* machine account exists: say so */ - pdb_clear_sam(sam_pass); + pdb_free_sam(sam_pass); return NT_STATUS_USER_EXISTS; } @@ -1835,7 +1835,7 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR sizeof(err_str), msg_str, sizeof(msg_str))) { DEBUG(0, ("%s\n", err_str)); close_policy_hnd(p, user_pol); - pdb_clear_sam(sam_pass); + pdb_free_sam(sam_pass); return NT_STATUS_ACCESS_DENIED; } @@ -1845,27 +1845,27 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR if (ret == False) { /* account doesn't exist: say so */ close_policy_hnd(p, user_pol); - pdb_clear_sam(sam_pass); + pdb_free_sam(sam_pass); return NT_STATUS_ACCESS_DENIED; } /* Get the domain SID stored in the domain policy */ if(!get_lsa_policy_samr_sid(p, &dom_pol, &sid)) { close_policy_hnd(p, user_pol); - pdb_clear_sam(sam_pass); + 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) )) { close_policy_hnd(p, user_pol); - pdb_clear_sam(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_clear_sam(sam_pass); + pdb_free_sam(sam_pass); return NT_STATUS_NO_MEMORY; } @@ -1874,14 +1874,14 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, user_pol, free_samr_info, (void *)info)) { - pdb_clear_sam(sam_pass); + 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_clear_sam(sam_pass); + pdb_free_sam(sam_pass); return NT_STATUS_NO_PROBLEMO; } @@ -2077,24 +2077,24 @@ static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, uint32 rid) ret = pdb_getsampwrid(pwd, rid); if(ret==False) { - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return False; } if (id10 == NULL) { DEBUG(5, ("set_user_info_10: NULL id10\n")); - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return False; } pdb_set_acct_ctrl(pwd, id10->acb_info); if(!pdb_update_sam_account(pwd, True)) { - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return False; } - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return True; } @@ -2111,13 +2111,13 @@ static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, uint32 rid) pdb_init_sam(&pwd); if(!pdb_getsampwrid(pwd, rid)) { - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return False; } if (id12 == NULL) { DEBUG(2, ("set_user_info_12: id12 is NULL\n")); - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return False; } @@ -2125,11 +2125,11 @@ static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, uint32 rid) pdb_set_nt_passwd (pwd, id12->nt_pwd); if(!pdb_update_sam_account(pwd, True)) { - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return False; } - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return True; } @@ -2151,8 +2151,8 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) pdb_init_sam(&new_pwd); if (!pdb_getsampwrid(pwd, rid)) { - pdb_clear_sam(pwd); - pdb_clear_sam(new_pwd); + pdb_free_sam(pwd); + pdb_free_sam(new_pwd); return False; } @@ -2169,13 +2169,13 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) /* write the change out */ if(!pdb_update_sam_account(new_pwd, True)) { - pdb_clear_sam(pwd); - pdb_clear_sam(new_pwd); + pdb_free_sam(pwd); + pdb_free_sam(new_pwd); return False; } - pdb_clear_sam(pwd); - pdb_clear_sam(new_pwd); + pdb_free_sam(pwd); + pdb_free_sam(new_pwd); return True; } @@ -2203,20 +2203,20 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) pdb_init_sam(&new_pwd); if (pdb_getsampwrid(pwd, rid)) { - pdb_clear_sam(pwd); - pdb_clear_sam(new_pwd); + pdb_free_sam(pwd); + pdb_free_sam(new_pwd); return False; } acct_ctrl = pdb_get_acct_ctrl(pwd); copy_sam_passwd(new_pwd, pwd); - pdb_clear_sam(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_clear_sam(new_pwd); + pdb_free_sam(new_pwd); return False; } @@ -2232,7 +2232,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) /* update the UNIX password */ if (lp_unix_password_sync() ) if(!chgpasswd(pdb_get_username(new_pwd), "", buf, True)) { - pdb_clear_sam(new_pwd); + pdb_free_sam(new_pwd); return False; } } @@ -2240,11 +2240,11 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) memset(buf, 0, sizeof(buf)); if(!pdb_update_sam_account(new_pwd, True)) { - pdb_clear_sam(new_pwd); + pdb_free_sam(new_pwd); return False; } - pdb_clear_sam(new_pwd); + pdb_free_sam(new_pwd); return True; } @@ -2265,7 +2265,7 @@ static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) pdb_init_sam(&pwd); if (!pdb_getsampwrid(pwd, rid)) { - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return False; } @@ -2274,7 +2274,7 @@ static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) memset(buf, 0, sizeof(buf)); if (!decode_pw_buffer((char*)id24->pass, buf, 256, &len, nt_hash, lm_hash)) { - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return False; } @@ -2290,7 +2290,7 @@ static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) /* update the UNIX password */ if (lp_unix_password_sync()) if(!chgpasswd(pdb_get_username(pwd), "", buf, True)) { - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return False; } } @@ -2301,11 +2301,11 @@ static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) /* update the SAMBA password */ if(!pdb_update_sam_account(pwd, True)) { - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return False; } - pdb_clear_sam(pwd); + pdb_free_sam(pwd); return True; } @@ -2364,14 +2364,14 @@ uint32 _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_ unbecome_root(); if(ret == False) { DEBUG(0,("_samr_set_userinfo: Unable to get smbpasswd entry for uid %u\n", (unsigned int)user.uid )); - pdb_clear_sam(sam_pass); + pdb_free_sam(sam_pass); return NT_STATUS_ACCESS_DENIED; } memset(sess_key, '\0', 16); mdfour(sess_key, pdb_get_nt_passwd(sam_pass), 16); - pdb_clear_sam(sam_pass); + pdb_free_sam(sam_pass); /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index b4472671fc..861d47b9d8 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -277,12 +277,12 @@ uint32 local_lookup_user_name(uint32 rid, char *user_name, uint32 *type) if (ret == True) { fstrcpy(user_name, pdb_get_username(sampwd) ); DEBUG(5,(" = %s\n", user_name)); - pdb_clear_sam(sampwd); + pdb_free_sam(sampwd); return 0x0; } DEBUG(5,(" none mapped\n")); - pdb_clear_sam(sampwd); + pdb_free_sam(sampwd); return NT_STATUS_NONE_MAPPED; } @@ -343,10 +343,10 @@ uint32 local_lookup_user_rid(char *user_name, uint32 *rid) if (ret == True) { (*rid) = pdb_get_user_rid(sampass); - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return 0x0; } - pdb_clear_sam(sampass); + pdb_free_sam(sampass); return NT_STATUS_NONE_MAPPED; } -- cgit From dbd7e0a54ee39a67e9e368b279cf89ef159b204c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 7 May 2001 22:08:34 +0000 Subject: removed unused variables (This used to be commit 09103b16cf0b70c476b48255190725e3dbb77bdb) --- source3/rpc_server/srv_samr_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 8c8418d2e0..62ebeeb89b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -802,7 +802,6 @@ static BOOL get_group_alias_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 sta } else if (sid_equal(sid, &global_sam_sid) && !lp_hide_local_users()) { char *sep; struct group *grp; - fstring sid_string; sep = lp_winbind_separator(); @@ -2106,7 +2105,6 @@ 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) { SAM_ACCOUNT *pwd = NULL; - BOOL ret; pdb_init_sam(&pwd); -- cgit From 495f6e678774b013ec9da268fb69543ec9fc6cc6 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 7 May 2001 22:10:38 +0000 Subject: merge from 2.2 removing the 'domain XXX' parameters. (This used to be commit 9aefc86e355bf160300580acb85a58a18207ccdf) --- source3/rpc_server/srv_util.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 861d47b9d8..deaa6008b9 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -162,9 +162,6 @@ void get_domain_user_groups(char *domain_groups, char *user) if (domain_groups == NULL || user == NULL) return; - /* any additional groups this user is in. e.g power users */ - pstrcpy(domain_groups, lp_domain_groups()); - /* can only be a user or a guest. cannot be guest _and_ admin */ if (user_in_list(user, lp_domain_guest_group())) { -- cgit From ee8821f2f3994c7e95ae65ef77f8912bd37c9bd5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 8 May 2001 01:26:28 +0000 Subject: Fix for insure missmatched parameter error. Jeremy. (This used to be commit b32b1afe25bc8f7a9c43e0d5fd6703a76caa51f8) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 9d80cb5b82..58a7d8dde9 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -108,7 +108,7 @@ static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) ***************************************************************************/ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, - int num_entries, UNISTR2 name[MAX_LOOKUP_SIDS], + int num_entries, UNISTR2 *name, uint32 *mapped_count, BOOL endian) { int i; -- cgit From f39cb774e76dd54221119c43b3ff34e933983cf1 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 8 May 2001 06:09:52 +0000 Subject: Fixed compiler warning. (This used to be commit 9f1f811154e6d8f1a14687b1ee7f85d1dd18a925) --- source3/rpc_server/srv_samr_nt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 62ebeeb89b..e09f93185c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -812,7 +812,6 @@ static BOOL get_group_alias_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 sta setgrent(); while (num_entries < max_entries && ((grp = getgrent()) != NULL)) { - int i; uint32 trid; if(!get_group_from_gid(grp->gr_gid, &smap)) -- cgit From b6a6b4b02ef923ce71a8be8258ccee1cbb439c6f Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 8 May 2001 16:33:18 +0000 Subject: fixes to the group mapping code. Not ready yet. J.F. (This used to be commit 62a7a567fdea230b77cc97a3f74d868542c34700) --- source3/rpc_server/srv_samr.c | 31 ++++++++++++++++++++++ source3/rpc_server/srv_samr_nt.c | 56 ++++++++++++++++++++++++++++++++++------ 2 files changed, 79 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 5012f0c483..9ab8ad5d15 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1188,6 +1188,36 @@ static BOOL api_samr_set_groupinfo(pipes_struct *p) return True; } +/******************************************************************* + api_samr_set_aliasinfo + ********************************************************************/ + +static BOOL api_samr_set_aliasinfo(pipes_struct *p) +{ + SAMR_Q_SET_ALIASINFO q_u; + SAMR_R_SET_ALIASINFO r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!samr_io_q_set_aliasinfo("", &q_u, data, 0)) { + DEBUG(0,("api_samr_set_aliasinfo: unable to unmarshall SAMR_Q_SET_ALIASINFO.\n")); + return False; + } + + r_u.status = _samr_set_aliasinfo(p, &q_u, &r_u); + + if (!samr_io_r_set_aliasinfo("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_set_aliasinfo: unable to marshall SAMR_R_SET_ALIASINFO.\n")); + return False; + } + + return True; +} + /******************************************************************* api_samr_get_dom_pwinfo ********************************************************************/ @@ -1320,6 +1350,7 @@ static struct api_struct api_samr_cmds [] = {"SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, {"SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, {"SAMR_SET_GROUPINFO" , SAMR_SET_GROUPINFO , api_samr_set_groupinfo }, + {"SAMR_SET_ALIASINFO" , SAMR_SET_ALIASINFO , api_samr_set_aliasinfo }, {"SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user }, {"SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids }, {"SAMR_GET_DOM_PWINFO" , SAMR_GET_DOM_PWINFO , api_samr_get_dom_pwinfo }, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e09f93185c..693ef95df9 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -211,6 +211,8 @@ static BOOL jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, pdb_get_username(pwd), pdb_get_user_rid(pwd), pdb_get_acct_ctrl(pwd) )); (*num_entries)++; + + pdb_reset_sam(pwd); } pdb_endsampwent(); @@ -1411,6 +1413,8 @@ uint32 _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_U if (!find_policy_by_hnd(p, &domain_pol, NULL)) return NT_STATUS_INVALID_HANDLE; + pdb_init_sam(&sampass); + become_root(); ret=pdb_getsampwrid(sampass, user_rid); unbecome_root(); @@ -1540,6 +1544,8 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) return False; } + pdb_init_sam(&sampass); + become_root(); ret = pdb_getsampwrid(sampass, user_rid); unbecome_root(); @@ -2520,8 +2526,8 @@ uint32 _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_ DEBUG(10, ("sid is %s\n", alias_sid_str)); sid = (DOM_SID2 *)talloc(p->mem_ctx, sizeof(DOM_SID2) * num_uids); - if (sid == NULL) - return NT_STATUS_NO_SUCH_ALIAS; + if (num_uids!=0 && sid == NULL) + return NT_STATUS_NO_MEMORY; for (i = 0; i < num_uids; i++) { sid_copy(&temp_sid, &global_sam_sid); @@ -2581,7 +2587,7 @@ uint32 _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_ rid=talloc(p->mem_ctx, sizeof(uint32)*num_uids); attr=talloc(p->mem_ctx, sizeof(uint32)*num_uids); - if (rid==NULL || attr==NULL) + if (num_uids!=0 && (rid==NULL || attr==NULL)) return NT_STATUS_NO_MEMORY; for (i=0; irid=pdb_gid_to_group_rid(grp->gr_gid); - /* add the group to the mapping table */ - if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_ALIAS, NULL, NULL, SE_PRIV_NONE)) - return NT_STATUS_ACCESS_DENIED; - if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) return NT_STATUS_NO_MEMORY; @@ -2872,6 +2874,10 @@ uint32 _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, SAM sid_append_rid(&info->sid, r_u->rid); sid_to_string(sid_string, &info->sid); + /* add the group to the mapping table */ + if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_ALIAS, name, NULL, SE_PRIV_NONE)) + return NT_STATUS_ACCESS_DENIED; + /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, &r_u->alias_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2890,7 +2896,7 @@ uint32 _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAMR_ { DOM_SID group_sid; GROUP_MAP map; - uid_t *uid; + uid_t *uid=NULL; int num_uids=0; GROUP_INFO_CTR *ctr; @@ -2962,6 +2968,40 @@ uint32 _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_SE return NT_STATUS_NO_PROBLEMO; } +/********************************************************************* + _samr_set_groupinfo + + update a domain group's comment. +*********************************************************************/ + +uint32 _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_SET_ALIASINFO *r_u) +{ + DOM_SID group_sid; + GROUP_MAP map; + ALIAS_INFO_CTR *ctr; + + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid)) + return NT_STATUS_INVALID_HANDLE; + + if (!get_local_group_from_sid(group_sid, &map)) + return NT_STATUS_NO_SUCH_GROUP; + + ctr=&q_u->ctr; + + switch (ctr->switch_value1) { + case 3: + unistr2_to_ascii(map.comment, &(ctr->alias.info3.uni_acct_desc), sizeof(map.comment)-1); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + } + + if(!add_mapping_entry(&map, TDB_REPLACE)) + return NT_STATUS_NO_SUCH_GROUP; + + return NT_STATUS_NO_PROBLEMO; +} + /********************************************************************* _samr_get_dom_pwinfo *********************************************************************/ -- cgit From f874646136270eddc54227796356e2d2fc7e4e67 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 9 May 2001 17:57:08 +0000 Subject: check for valid pointer before calling memset() in samr_clear_sam_passwd (This used to be commit a6a4a17f6afce9d1c10c5ab551ce0b6b5f5c1865) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 693ef95df9..e4289dd457 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -79,8 +79,8 @@ static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) if (!sam_pass) return; - memset(sam_pass->lm_pw, '\0', 16); - memset(sam_pass->nt_pw, '\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); } /******************************************************************* -- cgit From 6dd8c06ce9dcd5896a00ad99e81d6e9e9a5f4296 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 10 May 2001 20:05:06 +0000 Subject: Should be faliing on False and not True. Bad check on return value (This used to be commit 5be97aacf4db43a91562b77f010850afb818ac05) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e4289dd457..71b50a359e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2205,7 +2205,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) pdb_init_sam(&pwd); pdb_init_sam(&new_pwd); - if (pdb_getsampwrid(pwd, rid)) { + if (!pdb_getsampwrid(pwd, rid)) { pdb_free_sam(pwd); pdb_free_sam(new_pwd); return False; -- cgit From c912d04389e9bd38ac4e5ef8b29fae1faaf86e7b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 18 May 2001 01:30:21 +0000 Subject: Fix the W2KSP2 joining a Samba domain problem. Jeremy. (This used to be commit 6bbcab5e48f91a80d4ebcbd2bee38f2e0a8bff78) --- source3/rpc_server/srv_pipe.c | 8 ++++---- source3/rpc_server/srv_pipe_hnd.c | 4 ++-- source3/rpc_server/srv_samr.c | 5 +++++ 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 345664a396..5f6a1d479c 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -93,7 +93,7 @@ BOOL create_next_pdu(pipes_struct *p) */ if(p->fault_state) { - setup_fault_pdu(p); + setup_fault_pdu(p, 0x1c010002); return True; } @@ -617,7 +617,7 @@ static BOOL setup_bind_nak(pipes_struct *p) Marshall a fault pdu. *******************************************************************/ -BOOL setup_fault_pdu(pipes_struct *p) +BOOL setup_fault_pdu(pipes_struct *p, uint32 status) { prs_struct outgoing_pdu; RPC_HDR fault_hdr; @@ -649,7 +649,7 @@ BOOL setup_fault_pdu(pipes_struct *p) memset((char *)&hdr_resp, '\0', sizeof(hdr_resp)); - fault_resp.status = 0x1c010002; + fault_resp.status = status; fault_resp.reserved = 0; /* @@ -1195,7 +1195,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, * and not put the pipe into fault state. JRA. */ DEBUG(4, ("unknown\n")); - setup_fault_pdu(p); + setup_fault_pdu(p, 0x1c010002); return True; } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 893bc8cb88..f91df7c4ef 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -570,7 +570,7 @@ static ssize_t process_complete_pdu(pipes_struct *p) DEBUG(10,("process_complete_pdu: pipe %s in fault state.\n", p->name )); set_incoming_fault(p); - setup_fault_pdu(p); + setup_fault_pdu(p, 0x1c010002); return (ssize_t)data_len; } @@ -619,7 +619,7 @@ static ssize_t process_complete_pdu(pipes_struct *p) if (!reply) { DEBUG(3,("process_complete_pdu: DCE/RPC fault sent on pipe %s\n", p->pipe_srv_name)); set_incoming_fault(p); - setup_fault_pdu(p); + setup_fault_pdu(p, 0x1c010002); prs_mem_free(&rpc_in); } else { /* diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 9ab8ad5d15..6cd0f3b854 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -725,6 +725,11 @@ static BOOL api_samr_set_userinfo(pipes_struct *p) if (!samr_io_q_set_userinfo("", &q_u, data, 0)) { DEBUG(0,("api_samr_set_userinfo: Unable to unmarshall SAMR_Q_SET_USERINFO.\n")); + /* Fix for W2K SP2 */ + if (q_u.switch_value == 0x1a) { + setup_fault_pdu(p, 0x1c000006); + return True; + } return False; } -- cgit From 43000d8d0662d4979ae2aa574c10aef0952cd49a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 18 May 2001 04:11:17 +0000 Subject: merge from 2.2 (deleteprinterdriver RPC) (This used to be commit 515caaf7b448e55206433a9ca04fb5078f91cde2) --- source3/rpc_server/srv_spoolss.c | 33 +++++++++++++++ source3/rpc_server/srv_spoolss_nt.c | 82 +++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index ddd8255139..1adc783e24 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -213,6 +213,38 @@ static BOOL api_spoolss_deleteprinter(pipes_struct *p) } +/******************************************************************** + * api_spoolss_deleteprinterdriver + * + * called from the spoolss dispatcher + ********************************************************************/ + +static BOOL api_spoolss_deleteprinterdriver(pipes_struct *p) +{ + SPOOL_Q_DELETEPRINTERDRIVER q_u; + SPOOL_R_DELETEPRINTERDRIVER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!spoolss_io_q_deleteprinterdriver("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_deleteprinterdriver: unable to unmarshall SPOOL_Q_DELETEPRINTERDRIVER.\n")); + return False; + } + + r_u.status = _spoolss_deleteprinterdriver(p, &q_u, &r_u); + + if (!spoolss_io_r_deleteprinterdriver("",&r_u,rdata,0)) { + DEBUG(0,("spoolss_io_r_deleteprinter: unable to marshall SPOOL_R_DELETEPRINTER.\n")); + return False; + } + + return True; +} + + /******************************************************************** * api_spoolss_rffpcnex * ReplyFindFirstPrinterChangeNotifyEx @@ -1169,6 +1201,7 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_ENUMPRINTERDRIVERS", SPOOLSS_ENUMPRINTERDRIVERS, api_spoolss_enumprinterdrivers }, {"SPOOLSS_ADDPRINTEREX", SPOOLSS_ADDPRINTEREX, api_spoolss_addprinterex }, {"SPOOLSS_ADDPRINTERDRIVER", SPOOLSS_ADDPRINTERDRIVER, api_spoolss_addprinterdriver }, + {"SPOOLSS_DELETEPRINTERDRIVER", SPOOLSS_DELETEPRINTERDRIVER, api_spoolss_deleteprinterdriver }, {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory }, {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata }, {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata }, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d714972179..1d1eced2ea 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -34,6 +34,13 @@ extern pstring global_myname; #define PRINTER_HANDLE_IS_PRINTER 0 #define PRINTER_HANDLE_IS_PRINTSERVER 1 +struct table_node { + char *long_archi; + char *short_archi; + int version; +}; + + /* structure to store the printer handles */ /* and a reference to what it's pointing to */ /* and the notify info asked about */ @@ -1058,6 +1065,81 @@ uint32 _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL return result; } +/******************************************************************* + * static function to lookup the version id corresponding to an + * long architecture string + ******************************************************************/ +static int get_version_id (char * arch) +{ + int i; + struct table_node archi_table[]= { + + {"Windows 4.0", "WIN40", 0 }, + {"Windows NT x86", "W32X86", 2 }, + {"Windows NT R4000", "W32MIPS", 2 }, + {"Windows NT Alpha_AXP", "W32ALPHA", 2 }, + {"Windows NT PowerPC", "W32PPC", 2 }, + {NULL, "", -1 } + }; + + for (i=0; archi_table[i].long_archi != NULL; i++) + { + if (strcmp(arch, archi_table[i].long_archi) == 0) + return (archi_table[i].version); + } + + return -1; +} + +/******************************************************************** + * _spoolss_deleteprinterdriver + * + * We currently delete the driver for the architecture only. + * This can leave the driver for other archtectures. However, + * since every printer associates a "Windows NT x86" driver name + * and we cannot delete that one while it is in use, **and** since + * it is impossible to assign a driver to a Samba printer without + * having the "Windows NT x86" driver installed,... + * + * ....we should not get into trouble here. + * + * --jerry + ********************************************************************/ + +uint32 _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER *q_u, + SPOOL_R_DELETEPRINTERDRIVER *r_u) +{ + fstring driver; + fstring arch; + NT_PRINTER_DRIVER_INFO_LEVEL info; + int version; + + unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)-1 ); + unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)-1 ); + + /* 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; + } + + ZERO_STRUCT(info); + if (get_a_printer_driver (&info, 3, driver, arch, version) != 0) { + /* this is what NT returns */ + return ERROR_UNKNOWN_PRINTER_DRIVER; + } + + + if (printer_driver_in_use(arch, driver)) + { + /* this is what NT returns */ + return ERROR_PRINTER_DRIVER_IN_USE; + } + + return delete_printer_driver(info.info_3); +} + + /******************************************************************** GetPrinterData on a printer server Handle. ********************************************************************/ -- cgit From 076ace3e3d5705e88677b0a0af1a274070950c89 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 24 May 2001 08:05:12 +0000 Subject: Added server side reponse to net_logon_ctrl rpc. We can now respond to NLTEST /BDC_QUERY:DOMAIN when acting as a BDC. Reverse engineered a couple of status constants. (This used to be commit 0678c302825afef521ae2b80958a1d7c5aa76d23) --- source3/rpc_server/srv_netlog.c | 35 +++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_netlog_nt.c | 30 +++++++++++++++++++++++++++--- 2 files changed, 62 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 4c13ad0c67..93d7fea554 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -282,6 +282,40 @@ static BOOL api_net_logon_ctrl2(pipes_struct *p) return True; } +/************************************************************************* + api_net_logon_ctrl: + *************************************************************************/ + +static BOOL api_net_logon_ctrl(pipes_struct *p) +{ + NET_Q_LOGON_CTRL q_u; + NET_R_LOGON_CTRL r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + DEBUG(6,("api_net_logon_ctrl: %d\n", __LINE__)); + + /* grab the lsa netlogon ctrl query... */ + if(!net_io_q_logon_ctrl("", &q_u, data, 0)) { + DEBUG(0,("api_net_logon_ctrl: Failed to unmarshall NET_Q_LOGON_CTRL.\n")); + return False; + } + + r_u.status = _net_logon_ctrl(p, &q_u, &r_u); + + if(!net_io_r_logon_ctrl("", &r_u, rdata, 0)) { + DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL2.\n")); + return False; + } + + DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__)); + + return True; +} + /******************************************************************* array of \PIPE\NETLOGON operations ********************************************************************/ @@ -295,6 +329,7 @@ static struct api_struct api_net_cmds [] = { "NET_SAMLOGOFF" , NET_SAMLOGOFF , api_net_sam_logoff }, { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 }, { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, + { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl }, { NULL , 0 , NULL } }; diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 065f94702c..eb026a1f98 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -52,6 +52,30 @@ static void init_net_r_req_chal(NET_R_REQ_CHAL *r_c, #define ERROR_NO_SUCH_DOMAIN 0x54b #define ERROR_NO_LOGON_SERVERS 0x51f +/************************************************************************* + net_reply_logon_ctrl: + *************************************************************************/ + +/* Some flag values reverse engineered from NLTEST.EXE */ + +#define LOGON_CTRL_IN_SYNC 0x00 +#define LOGON_CTRL_REPL_NEEDED 0x01 +#define LOGON_CTRL_REPL_IN_PROGRESS 0x02 + +uint32 _net_logon_ctrl(pipes_struct *p, NET_Q_LOGON_CTRL *q_u, + NET_R_LOGON_CTRL *r_u) +{ + uint32 flags = 0x0; + uint32 pdc_connection_status = 0x00; /* Maybe a win32 error code? */ + + /* Setup the Logon Control response */ + + init_net_r_logon_ctrl(r_u, q_u->query_level, flags, + pdc_connection_status); + + return r_u->status; +} + /************************************************************************* net_reply_logon_ctrl2: *************************************************************************/ @@ -68,9 +92,9 @@ uint32 _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_CTR DEBUG(6,("_net_logon_ctrl2: %d\n", __LINE__)); /* set up the Logon Control2 response */ - init_r_logon_ctrl2(r_u, q_u->query_level, - flags, pdc_connection_status, logon_attempts, - tc_status, trusted_domain); + init_net_r_logon_ctrl2(r_u, q_u->query_level, + flags, pdc_connection_status, logon_attempts, + tc_status, trusted_domain); DEBUG(6,("_net_logon_ctrl2: %d\n", __LINE__)); -- cgit From bbf5ea221aad91a99564ee130a6334d3b25e2a9a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 29 May 2001 07:34:01 +0000 Subject: 4 new functions to retrieve single linked list of group and passwd entries + a fix to an infinite loop in srv_samr_nt.c caused by misuse of setgrent/getgrent/endgrent solved by these new functions (This used to be commit 97dbb54a13e2285f1905ee1ec9aafeebdaee8917) --- source3/rpc_server/srv_samr_nt.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 71b50a359e..55e20ebd07 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -803,7 +803,8 @@ static BOOL get_group_alias_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 sta } else if (sid_equal(sid, &global_sam_sid) && !lp_hide_local_users()) { char *sep; - struct group *grp; + struct sys_grent *glist; + struct sys_grent *grp; sep = lp_winbind_separator(); @@ -811,36 +812,50 @@ static BOOL get_group_alias_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 sta /* we return the UNIX groups here. This seems to be the right */ /* thing to do, since NT member servers return their local */ /* groups in the same situation. */ - setgrent(); - while (num_entries < max_entries && ((grp = getgrent()) != NULL)) { + /* use getgrent_list() to retrieve the list of groups to avoid + * problems with getgrent possible infinite loop by internal + * libc grent structures overwrites by called functions */ + grp = glist = getgrent_list(); + if (grp == NULL) + return NT_STATUS_NO_MEMORY; + + while ((num_entries < max_entries) && (grp != NULL)) { uint32 trid; - if(!get_group_from_gid(grp->gr_gid, &smap)) + if(!get_group_from_gid(grp->gr_gid, &smap)) { + grp = grp->next; continue; + } - if (smap.sid_name_use!=SID_NAME_ALIAS) + if (smap.sid_name_use!=SID_NAME_ALIAS) { + grp = grp->next; continue; + } sid_split_rid(&smap.sid, &trid); /* Don't return winbind groups as they are not local! */ if (strchr(smap.nt_name, *sep) != NULL) { DEBUG(10,("get_group_alias_entries: not returing %s, not local.\n", smap.nt_name )); + grp = grp->next; continue; } /* Don't return user private groups... */ if (Get_Pwnam(smap.nt_name, False) != 0) { DEBUG(10,("get_group_alias_entries: not returing %s, clashes with user.\n", smap.nt_name )); + grp = grp->next; continue; } for( i = 0; i < num_entries; i++) if ( (*d_grp)[i].rid == trid ) break; - if ( i < num_entries ) + if ( i < num_entries ) { + grp = grp->next; continue; /* rid was there, dup! */ + } /* JRA - added this for large group db enumeration... */ @@ -849,19 +864,23 @@ static BOOL get_group_alias_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 sta not very efficient, but hey... */ start_idx--; + grp = grp->next; continue; } *d_grp=Realloc(*d_grp, (num_entries+1)*sizeof(DOMAIN_GRP)); - if (*d_grp==NULL) + if (*d_grp==NULL) { + grent_free(glist); return NT_STATUS_NO_MEMORY; + } fstrcpy((*d_grp)[num_entries].name, smap.nt_name); (*d_grp)[num_entries].rid = trid; num_entries++; + grp = grp->next; } - endgrent(); + grent_free(glist); } *p_num_entries = num_entries; -- cgit From 2eef56f9fa056766922ca05cc0a2cb0615e7faca Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 2 Jun 2001 03:03:28 +0000 Subject: i18n bugfix merge from appliance. (This used to be commit 73eb539da641ce806690bbd893f126859d531c98) --- source3/rpc_server/srv_spoolss_nt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1d1eced2ea..74f40d80ff 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1353,7 +1353,12 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin * and connect to the IPC$ share anonumously */ if (smb_connections==0) { - if(!spoolss_connect_to_client(&cli, printer+2)) /* the +2 is to strip the leading 2 backslashs */ + fstring unix_printer; + + fstrcpy(unix_printer, printer+2); /* the +2 is to strip the leading 2 backslashs */ + dos_to_unix(unix_printer, True); + + if(!spoolss_connect_to_client(&cli, unix_printer)) return False; message_register(MSG_PRINTER_NOTIFY, srv_spoolss_receive_message); -- cgit From 94186f645d3586fb1deffb9891d5db3808395ea4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 2 Jun 2001 06:14:42 +0000 Subject: Merge of i18n domain name fix for lsa_query_info_policy() from appliance branch. (This used to be commit e7a4dd7612d79bb24be68c601eccc987aba6b497) --- source3/rpc_server/srv_lsa_nt.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 58a7d8dde9..5ccb5a665b 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -332,6 +332,7 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO { LSA_INFO_UNION *info = &r_u->dom; DOM_SID domain_sid; + fstring dos_domain; char *name = NULL; DOM_SID *sid = NULL; @@ -340,6 +341,9 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO if (!find_policy_by_hnd(p, &q_u->pol, NULL)) return NT_STATUS_INVALID_HANDLE; + fstrcpy(dos_domain, global_myworkgroup); + unix_to_dos(dos_domain, True); + switch (q_u->info_class) { case 0x02: { @@ -359,20 +363,20 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - name = global_myworkgroup; + name = dos_domain; sid = &global_sam_sid; break; case ROLE_DOMAIN_MEMBER: - name = global_myworkgroup; + name = dos_domain; /* We need to return the Domain SID here. */ - if (secrets_fetch_domain_sid(global_myworkgroup, - &domain_sid)) - sid = &domain_sid; + if (secrets_fetch_domain_sid(dos_domain, + &domain_sid)) + sid = &domain_sid; else return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; break; case ROLE_STANDALONE: - name = global_myname; + name = dos_domain; sid = NULL; /* Tell it we're not in a domain. */ break; default: @@ -385,15 +389,15 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - name = global_myworkgroup; + name = dos_domain; sid = &global_sam_sid; break; case ROLE_DOMAIN_MEMBER: - name = global_myname; + name = dos_domain; sid = &global_sam_sid; break; case ROLE_STANDALONE: - name = global_myname; + name = dos_domain; sid = &global_sam_sid; break; default: -- cgit From 05fc3e578c895f632b351969d09cd00feb7599c7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 4 Jun 2001 05:13:59 +0000 Subject: use LDSHFLAGS not -shared in several places (This used to be commit 8ec9c87b5d1a7dae17d5b1a30f58effaf5e69e4b) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 93c3e18ca7..13d27788e0 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -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(lock_path("share_info.tdb"), 0, 0, O_RDWR|O_CREAT, 0600); + share_tdb = tdb_open_log(lock_path("share_info.tdb"), 0, 0, 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) )); -- cgit From 5d83242a9e03e72e07ff8cc427a67691774c373c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 5 Jun 2001 01:26:06 +0000 Subject: Merge of lsa_lookup_names() i18n bugfix from appliance. (This used to be commit 84a22d5f0a74f440a5288fedf07055ddc8da208e) --- source3/rpc_server/srv_lsa_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 5ccb5a665b..6e501df414 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -238,6 +238,11 @@ static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME sid_split_rid(&find_sid, &rid); } + /* unistr routines take dos codepage strings */ + + unix_to_dos(dom_name, True); + unix_to_dos(name, True); + dom_idx = init_dom_ref(ref, dom_name, &find_sid); DEBUG(10,("init_lsa_trans_names: added user '%s\\%s' to " -- cgit From 11b2de50fc0e8bfcd810e8b07a7eb39a5d903621 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 6 Jun 2001 23:07:10 +0000 Subject: Added getconf flags for RH7.1 lfs support. Changed while() to a for() loop in Simo's code (removes much grp = gep->next code). Jeremy. (This used to be commit d0c276c2429fa19cd95ca887654e049593de68d5) --- source3/rpc_server/srv_samr_nt.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 55e20ebd07..010da5c3e5 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -820,16 +820,14 @@ static BOOL get_group_alias_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 sta if (grp == NULL) return NT_STATUS_NO_MEMORY; - while ((num_entries < max_entries) && (grp != NULL)) { + for (; (num_entries < max_entries) && (grp != NULL); grp = grp->next) { uint32 trid; if(!get_group_from_gid(grp->gr_gid, &smap)) { - grp = grp->next; continue; } if (smap.sid_name_use!=SID_NAME_ALIAS) { - grp = grp->next; continue; } @@ -838,24 +836,21 @@ static BOOL get_group_alias_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 sta /* Don't return winbind groups as they are not local! */ if (strchr(smap.nt_name, *sep) != NULL) { DEBUG(10,("get_group_alias_entries: not returing %s, not local.\n", smap.nt_name )); - grp = grp->next; continue; } /* Don't return user private groups... */ if (Get_Pwnam(smap.nt_name, False) != 0) { DEBUG(10,("get_group_alias_entries: not returing %s, clashes with user.\n", smap.nt_name )); - grp = grp->next; continue; } for( i = 0; i < num_entries; i++) - if ( (*d_grp)[i].rid == trid ) break; + if ( (*d_grp)[i].rid == trid ) + break; - if ( i < num_entries ) { - grp = grp->next; + if ( i < num_entries ) continue; /* rid was there, dup! */ - } /* JRA - added this for large group db enumeration... */ @@ -864,7 +859,6 @@ static BOOL get_group_alias_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 sta not very efficient, but hey... */ start_idx--; - grp = grp->next; continue; } @@ -877,7 +871,6 @@ static BOOL get_group_alias_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 sta fstrcpy((*d_grp)[num_entries].name, smap.nt_name); (*d_grp)[num_entries].rid = trid; num_entries++; - grp = grp->next; } grent_free(glist); -- cgit From c569e20b1071e5e1e6815e102ae0f5ab5710ee0a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 12 Jun 2001 10:13:24 +0000 Subject: Fixed typo in debug message. (This used to be commit 4d2f6605820f7b62ff1a748952fd6edad63c1213) --- source3/rpc_server/srv_dfs_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index c01ab8f2d9..54c3fbf324 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -121,7 +121,7 @@ uint32 _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DFS_R_DFS_REMOVE *r_u get_current_user(&user,p); if (user.uid != 0) { - DEBUG(10,("_dfs_add: uid != 0. Access denied.\n")); + DEBUG(10,("_dfs_remove: uid != 0. Access denied.\n")); return ERROR_ACCESS_DENIED; } -- cgit From 8209eda7742653ea7bb20ffa96b61bdb0c4dce87 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 13 Jun 2001 01:08:27 +0000 Subject: Make message receive fn static. Jeremy. (This used to be commit d8807b19228b12ddd6d93c02d1646a470a8e71ef) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 74f40d80ff..99830c035b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -612,7 +612,7 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) receive the notify message ****************************************************************************/ -void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) +static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) { fstring printer; uint32 status; -- cgit From af604fe7694f3e1d1acdecfab366dfe31cfee9ef Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 16 Jun 2001 00:32:13 +0000 Subject: Modified version of Jim's 0x27 and 0x28 Win9x Secdesc patch. Jeremy. (This used to be commit 5690ec77c87475f1fd2e854cda594eb996d6fd04) --- source3/rpc_server/srv_srvsvc.c | 62 ++++++++++++++ source3/rpc_server/srv_srvsvc_nt.c | 167 +++++++++++++++++++++++++++++++++++++ 2 files changed, 229 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 76542d1c2f..3fa782001c 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -404,6 +404,66 @@ static BOOL api_srv_net_name_validate(pipes_struct *p) return True; } +/******************************************************************* + NetFileQuerySecdesc (opnum 0x27) +*******************************************************************/ + +static BOOL api_srv_net_file_query_secdesc(pipes_struct *p) +{ + SRV_Q_NET_FILE_QUERY_SECDESC q_u; + SRV_R_NET_FILE_QUERY_SECDESC r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net file get info from Win9x */ + if(!srv_io_q_net_file_query_secdesc("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_file_query_secdesc: Failed to unmarshall SRV_Q_NET_FILE_QUERY_SECDESC.\n")); + return False; + } + + r_u.status = _srv_net_file_query_secdesc(p, &q_u, &r_u); + + if(!srv_io_r_net_file_query_secdesc("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_file_query_secdesc: Failed to marshall SRV_R_NET_FILE_QUERY_SECDESC.\n")); + return False; + } + + return True; +} + +/******************************************************************* + NetFileSetSecdesc (opnum 0x28) +*******************************************************************/ + +static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) +{ + SRV_Q_NET_FILE_SET_SECDESC q_u; + SRV_R_NET_FILE_SET_SECDESC r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net file set info from Win9x */ + if(!srv_io_q_net_file_set_secdesc("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_file_set_secdesc: Failed to unmarshall SRV_Q_NET_FILE_SET_SECDESC.\n")); + return False; + } + + r_u.status = _srv_net_file_set_secdesc(p, &q_u, &r_u); + + if(!srv_io_r_net_file_set_secdesc("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_file_set_secdesc: Failed to marshall SRV_R_NET_FILE_SET_SECDESC.\n")); + return False; + } + + return True; +} + /******************************************************************* \PIPE\srvsvc commands ********************************************************************/ @@ -423,6 +483,8 @@ struct api_struct api_srv_cmds[] = { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate}, + { "SRV_NETFILEQUERYSECDESC",SRV_NETFILEQUERYSECDESC,api_srv_net_file_query_secdesc}, + { "SRV_NETFILESETSECDESC" , SRV_NETFILESETSECDESC , api_srv_net_file_set_secdesc}, { NULL , 0 , NULL } }; diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 13d27788e0..7ae95a5eac 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1563,6 +1563,173 @@ uint32 _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET return r_u->status; } +/*********************************************************************************** + Win9x NT tools get security descriptor. +***********************************************************************************/ + +uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC *q_u, + SRV_R_NET_FILE_QUERY_SECDESC *r_u) +{ + SEC_DESC *psd = NULL; + size_t sd_size; + fstring null_pw; + pstring filename; + pstring qualname; + files_struct *fsp = NULL; + SMB_STRUCT_STAT st; + BOOL bad_path; + int access_mode; + int action; + int ecode; + struct current_user user; + fstring user_name; + connection_struct *conn = NULL; + + ZERO_STRUCT(st); + + r_u->status = NT_STATUS_NOPROBLEMO; + + unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); + + /* Null password is ok - we are already an authenticated user... */ + *null_pw = '\0'; + + get_current_user(&user, p); + fstrcpy(user_name, uidtoname(user.uid)); + + conn = make_connection(qualname, user_name, "", 0, "A:", user.vuid, &ecode); + + if (conn == NULL) { + DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", qualname)); + r_u->status = (uint32)ecode; + goto error_exit; + } + + unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename)); + unix_convert(filename, conn, NULL, &bad_path, &st); + fsp = open_file_shared(conn, filename, &st, SET_OPEN_MODE(DOS_OPEN_RDONLY), + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, 0, &access_mode, &action); + + if (!fsp) { + DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); + r_u->status = ERROR_ACCESS_DENIED; + goto error_exit; + } + + sd_size = conn->vfs_ops.get_nt_acl(fsp, fsp->fsp_name, &psd); + + 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; + goto error_exit; + } + + r_u->ptr_response = 1; + r_u->size_response = sd_size; + r_u->ptr_secdesc = 1; + r_u->size_secdesc = sd_size; + r_u->sec_desc = psd; + + psd->dacl->revision = (uint16) NT4_ACL_REVISION; + + fsp->conn->vfs_ops.close(fsp, fsp->fd); + file_free(fsp); + + close_cnum(conn, user.vuid); + return r_u->status; + + error_exit: + + if(fsp) { + fsp->conn->vfs_ops.close(fsp, fsp->fd); + file_free(fsp); + } + + if (conn) + close_cnum(conn, user.vuid); + + return r_u->status; +} + +/*********************************************************************************** + Win9x NT tools set security descriptor. +***********************************************************************************/ + +uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_u, + SRV_R_NET_FILE_SET_SECDESC *r_u) +{ + BOOL ret; + pstring filename; + pstring qualname; + fstring null_pw; + files_struct *fsp = NULL; + SMB_STRUCT_STAT st; + BOOL bad_path; + int access_mode; + int action; + int ecode; + struct current_user user; + fstring user_name; + connection_struct *conn = NULL; + + ZERO_STRUCT(st); + + r_u->status = NT_STATUS_NOPROBLEMO; + + unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); + + /* Null password is ok - we are already an authenticated user... */ + *null_pw = '\0'; + + get_current_user(&user, p); + fstrcpy(user_name, uidtoname(user.uid)); + + conn = make_connection(qualname, user_name, null_pw, 0, "A:", user.vuid, &ecode); + + if (conn == NULL) { + DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", qualname)); + r_u->status = (uint32)ecode; + goto error_exit; + } + + unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename)); + unix_convert(filename, conn, NULL, &bad_path, &st); + + fsp = open_file_shared(conn, filename, &st, SET_OPEN_MODE(DOS_OPEN_RDWR), + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, 0, &access_mode, &action); + + if (!fsp) { + DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename)); + r_u->status = ERROR_ACCESS_DENIED; + goto error_exit; + } + + ret = conn->vfs_ops.set_nt_acl(fsp, fsp->fsp_name, q_u->sec_info, q_u->sec_desc); + + 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; + goto error_exit; + } + + fsp->conn->vfs_ops.close(fsp, fsp->fd); + file_free(fsp); + close_cnum(conn, user.vuid); + return r_u->status; + + error_exit: + + if(fsp) { + fsp->conn->vfs_ops.close(fsp, fsp->fd); + file_free(fsp); + } + + if (conn) + close_cnum(conn, user.vuid); + + return r_u->status; +} + /*********************************************************************************** It may be that we want to limit users to creating shares on certain areas of the UNIX file area. We could define areas by mapping Windows style disks to points on the UNIX directory hierarchy. -- cgit From 0417200fa9af35167de3e4d6df7c3071f07b15a9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 18 Jun 2001 17:52:58 +0000 Subject: Added "Jim McDonough" patches for directory support for Win9x. Jeremy. (This used to be commit 70194b194e0ca4b0f4f9c1eece9176415f9bb928) --- source3/rpc_server/srv_srvsvc_nt.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 7ae95a5eac..b28a0c9683 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1611,9 +1611,14 @@ uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, 0, &access_mode, &action); if (!fsp) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); - r_u->status = ERROR_ACCESS_DENIED; - goto error_exit; + /* Perhaps it is a directory */ + fsp = open_directory(conn, filename, &st, + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); + if (!fsp) { + DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); + r_u->status = ERROR_ACCESS_DENIED; + goto error_exit; + } } sd_size = conn->vfs_ops.get_nt_acl(fsp, fsp->fsp_name, &psd); @@ -1699,9 +1704,14 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, 0, &access_mode, &action); if (!fsp) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename)); - r_u->status = ERROR_ACCESS_DENIED; - goto error_exit; + /* Perhaps it is a directory */ + fsp = open_directory(conn, filename, &st, + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); + if (!fsp) { + DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename)); + r_u->status = ERROR_ACCESS_DENIED; + goto error_exit; + } } ret = conn->vfs_ops.set_nt_acl(fsp, fsp->fsp_name, q_u->sec_info, q_u->sec_desc); -- cgit From 809c0258780cc75cd456518571891fc30998d30d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 18 Jun 2001 20:27:35 +0000 Subject: Added patches to remove Linux specific XFS ACLs. These are now handled by the generic Linux ACL code. rpc_server/srv_samr_nt.c: Don't delete a policy handle before it's created. Jeremy. (This used to be commit db5b82e53a7061c4764d39ceb3df82e706aad42f) --- source3/rpc_server/srv_samr_nt.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 010da5c3e5..1db69716be 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1850,7 +1850,6 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR 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)); - close_policy_hnd(p, user_pol); pdb_free_sam(sam_pass); return NT_STATUS_ACCESS_DENIED; } @@ -1860,21 +1859,18 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR unbecome_root(); if (ret == False) { /* account doesn't exist: say so */ - close_policy_hnd(p, user_pol); pdb_free_sam(sam_pass); return NT_STATUS_ACCESS_DENIED; } /* Get the domain SID stored in the domain policy */ if(!get_lsa_policy_samr_sid(p, &dom_pol, &sid)) { - close_policy_hnd(p, user_pol); 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) )) { - close_policy_hnd(p, user_pol); pdb_free_sam(sam_pass); return NT_STATUS_NO_SUCH_USER; } -- cgit From 48a5c872402e5c445858dd4054571ca0fada11c4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 18 Jun 2001 21:34:01 +0000 Subject: Fix for assert fail - left over when moved to dynamic allocation. Jeremy. (This used to be commit 0fcf2006334bd41d4036e703a6725aaaf684e008) --- source3/rpc_server/srv_samr_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1db69716be..0a82c90a1d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1219,7 +1219,7 @@ uint32 _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOK uint32 rid[MAX_SAM_ENTRIES]; enum SID_NAME_USE type[MAX_SAM_ENTRIES]; int i; - int num_rids = q_u->num_names1; + int num_rids = q_u->num_names2; DOM_SID pol_sid; r_u->status = NT_STATUS_NOPROBLEMO; @@ -1239,8 +1239,6 @@ uint32 _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOK DEBUG(5,("_samr_lookup_names: truncating entries to %d\n", num_rids)); } - SMB_ASSERT_ARRAY(q_u->uni_name, num_rids); - for (i = 0; i < num_rids; i++) { fstring name; -- cgit From c1fbf761ce819a4da9f26758129e0923bfc1e6ff Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 19 Jun 2001 00:44:23 +0000 Subject: rpc_server/srv_srvsvc_nt.c: Don't test an uint32 for < 0. utils/smbcacls.c: Set enum correctly. Jeremy. (This used to be commit 66f959e0ffb0cd385167a34c7db3f4959eaf1d7f) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index b28a0c9683..e56e63490d 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1761,7 +1761,7 @@ static uint32 init_server_disk_enum(uint32 *resume) /*resume can be an offset into the list for now*/ - if(*resume < 0) + if(*resume & 0x80000000) *resume = 0; if(*resume > server_disk_count) -- cgit From fd0f3dfd3ce44cf37b60dca550c8b4022f23cbd8 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 19 Jun 2001 06:52:45 +0000 Subject: Fixed typo in debug message. (This used to be commit d05577c33237a092bbc7ca21e68f3cef06b4ab3b) --- source3/rpc_server/srv_pipe_hnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index f91df7c4ef..baa02beb65 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -776,7 +776,7 @@ ssize_t read_from_pipe(pipes_struct *p, char *data, size_t n) */ if(n > MAX_PDU_FRAG_LEN) { - DEBUG(0,("read_from_pipe: loo large read (%u) requested on pipe %s. We can \ + DEBUG(0,("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 )); return -1; } -- cgit From d2846a3ea93984ab091b6a70bf127e9f7eab1c58 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 19 Jun 2001 18:43:17 +0000 Subject: Only try and open a directory if we get EISDIR. Jeremy. (This used to be commit 5b1245f80357f585ef3b24704e5ef34ef71e232f) --- source3/rpc_server/srv_srvsvc_nt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index e56e63490d..4650512218 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1612,8 +1612,10 @@ uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC if (!fsp) { /* Perhaps it is a directory */ - fsp = open_directory(conn, filename, &st, - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); + if (errno == EISDIR) + fsp = open_directory(conn, filename, &st, + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); + if (!fsp) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); r_u->status = ERROR_ACCESS_DENIED; @@ -1705,8 +1707,10 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ if (!fsp) { /* Perhaps it is a directory */ - fsp = open_directory(conn, filename, &st, - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); + if (errno == EISDIR) + fsp = open_directory(conn, filename, &st, + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); + if (!fsp) { DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename)); r_u->status = ERROR_ACCESS_DENIED; -- cgit From 3f1254bee1b3cc8cce1e17be6f0250090f579417 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 20 Jun 2001 19:55:59 +0000 Subject: Fixed W2K SP2 joining a Samba PDC hosted domain. Jermey. (This used to be commit 05a2911403a0710d994a618e72743205a3b0b87a) --- source3/rpc_server/srv_netlog_nt.c | 4 ++-- source3/rpc_server/srv_samr_nt.c | 40 +++++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index eb026a1f98..bbda4060f2 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -470,8 +470,8 @@ static uint32 net_login_interactive(NET_ID_INFO_1 *id1, SAM_ACCOUNT *sampass, pi dump_data(100, nt_pwd, 16); #endif - SamOEMhash((uchar *)lm_pwd, key, False); - SamOEMhash((uchar *)nt_pwd, key, False); + SamOEMhash((uchar *)lm_pwd, key, 16); + SamOEMhash((uchar *)nt_pwd, key, 16); #ifdef DEBUG_PASSWORD DEBUG(100,("decrypt of lm owf password:")); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 0a82c90a1d..502774e986 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2259,10 +2259,10 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) } /******************************************************************* - set_user_info_24 + set_user_info_pw ********************************************************************/ -static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) +static BOOL set_user_info_pw(char *pass, uint32 rid) { SAM_ACCOUNT *pwd = NULL; uchar nt_hash[16]; @@ -2282,7 +2282,7 @@ static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) memset(buf, 0, sizeof(buf)); - if (!decode_pw_buffer((char*)id24->pass, buf, 256, &len, nt_hash, lm_hash)) { + if (!decode_pw_buffer(pass, buf, 256, &len, nt_hash, lm_hash)) { pdb_free_sam(pwd); return False; } @@ -2306,7 +2306,7 @@ static BOOL set_user_info_24(SAM_USER_INFO_24 *id24, uint32 rid) memset(buf, 0, sizeof(buf)); - DEBUG(0,("set_user_info_24: pdb_update_sam_account()\n")); + DEBUG(5,("set_user_info_pw: pdb_update_sam_account()\n")); /* update the SAMBA password */ if(!pdb_update_sam_account(pwd, True)) { @@ -2390,13 +2390,39 @@ uint32 _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_ break; case 24: - SamOEMhash(ctr->info.id24->pass, sess_key, 1); - if (!set_user_info_24(ctr->info.id24, rid)) + SamOEMhash(ctr->info.id24->pass, sess_key, 516); + + dump_data(100, (char *)ctr->info.id24->pass, 516); + + if (!set_user_info_pw(ctr->info.id24->pass, rid)) return NT_STATUS_ACCESS_DENIED; break; + case 25: +#if 0 + /* + * Currently we don't really know how to unmarshall + * the level 25 struct, and the password encryption + * is different. This is a placeholder for when we + * do understand it. In the meantime just return INVALID + * info level and W2K SP2 drops down to level 23... JRA. + */ + + SamOEMhash(ctr->info.id25->pass, sess_key, 532); + + dump_data(100, (char *)ctr->info.id25->pass, 532); + + if (!set_user_info_pw(ctr->info.id25->pass, rid)) + return NT_STATUS_ACCESS_DENIED; + break; +#endif + return NT_STATUS_INVALID_INFO_CLASS; + case 23: - SamOEMhash(ctr->info.id23->pass, sess_key, 1); + SamOEMhash(ctr->info.id23->pass, sess_key, 516); + + dump_data(100, (char *)ctr->info.id23->pass, 516); + if (!set_user_info_23(ctr->info.id23, rid)) return NT_STATUS_ACCESS_DENIED; break; -- cgit From 3a6019b0eb8a71e8f7fb04fbce384f4478ebe2dd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 21 Jun 2001 17:46:14 +0000 Subject: Merging Gerry's spoolss changes. Jeremy. (This used to be commit 6b4a70cd8285c1e4d452e3af7df070b4c446ff54) --- source3/rpc_server/srv_spoolss.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 1adc783e24..63bbc5f87b 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1091,6 +1091,38 @@ static BOOL api_spoolss_enumprintprocessors(pipes_struct *p) /**************************************************************************** ****************************************************************************/ +static BOOL api_spoolss_addprintprocessor(pipes_struct *p) +{ + SPOOL_Q_ADDPRINTPROCESSOR q_u; + SPOOL_R_ADDPRINTPROCESSOR r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_addprintprocessor("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_addprintprocessor: unable to unmarshall SPOOL_Q_ADDPRINTPROCESSOR.\n")); + return False; + } + + /* for now, just indicate success and ignore the add. We'll + 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; + + if(!spoolss_io_r_addprintprocessor("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_addprintprocessor: unable to marshall SPOOL_R_ADDPRINTPROCESSOR.\n")); + return False; + } + + return True; +} + +/**************************************************************************** +****************************************************************************/ + static BOOL api_spoolss_enumprintprocdatatypes(pipes_struct *p) { SPOOL_Q_ENUMPRINTPROCDATATYPES q_u; @@ -1210,6 +1242,7 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_DELETEFORM", SPOOLSS_DELETEFORM, api_spoolss_deleteform }, {"SPOOLSS_GETFORM", SPOOLSS_GETFORM, api_spoolss_getform }, {"SPOOLSS_SETFORM", SPOOLSS_SETFORM, api_spoolss_setform }, + {"SPOOLSS_ADDPRINTPROCESSOR", SPOOLSS_ADDPRINTPROCESSOR, api_spoolss_addprintprocessor }, {"SPOOLSS_ENUMPRINTPROCESSORS", SPOOLSS_ENUMPRINTPROCESSORS, api_spoolss_enumprintprocessors }, {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors }, {"SPOOLSS_GETJOB", SPOOLSS_GETJOB, api_spoolss_getjob }, -- cgit From b08ee8995da1960546df31fdf876665c996083b3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 22 Jun 2001 18:58:35 +0000 Subject: Fix from "Jim McDonough" " - when we use open_file_shared(), we need to close with close_file(). Jeremy. (This used to be commit 5b2ffd160f3b4b9607bb6fd6db1644af9254ad9e) --- source3/rpc_server/srv_srvsvc_nt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 4650512218..d071572804 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1639,7 +1639,7 @@ uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC psd->dacl->revision = (uint16) NT4_ACL_REVISION; - fsp->conn->vfs_ops.close(fsp, fsp->fd); + close_file(fsp, True); file_free(fsp); close_cnum(conn, user.vuid); @@ -1648,7 +1648,7 @@ uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC error_exit: if(fsp) { - fsp->conn->vfs_ops.close(fsp, fsp->fd); + close_file(fsp, True); file_free(fsp); } @@ -1726,7 +1726,7 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ goto error_exit; } - fsp->conn->vfs_ops.close(fsp, fsp->fd); + close_file(fsp, True); file_free(fsp); close_cnum(conn, user.vuid); return r_u->status; @@ -1734,7 +1734,7 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ error_exit: if(fsp) { - fsp->conn->vfs_ops.close(fsp, fsp->fd); + close_file(fsp, True); file_free(fsp); } -- cgit From 6e0605c3ab266749a411fe50301020fac52eea98 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 25 Jun 2001 06:13:27 +0000 Subject: Cosmetic fixups found while playing with the server manager. Added support for NET_SRV_SET_INFO rpc call which is made when double-clicking on a computer in the server manager and changing the description. We always return NT_STATUS_NOPROBLEMO as NT doesn't seem to decode any error messages passed back. Maybe the changed comment string could be stored in a tdb and regurgitated instead of the "server string" smb.conf parameter? (This used to be commit d936ffedd90fe442f990c9ac2e172877f28d7230) --- source3/rpc_server/srv_srvsvc.c | 28 ++++++++++++++++++++++++++++ source3/rpc_server/srv_srvsvc_nt.c | 22 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 3fa782001c..fe008d0dde 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -55,6 +55,33 @@ static BOOL api_srv_net_srv_get_info(pipes_struct *p) return True; } +/******************************************************************* + api_srv_net_srv_get_info +********************************************************************/ + +static BOOL api_srv_net_srv_set_info(pipes_struct *p) +{ + SRV_Q_NET_SRV_SET_INFO q_u; + SRV_R_NET_SRV_SET_INFO r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the net server set info */ + if (!srv_io_q_net_srv_set_info("", &q_u, data, 0)) + return False; + + r_u.status = _srv_net_srv_set_info(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if (!srv_io_r_net_srv_set_info("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* api_srv_net_file_enum ********************************************************************/ @@ -480,6 +507,7 @@ struct api_struct api_srv_cmds[] = { "SRV_NET_SHARE_SET_INFO", SRV_NET_SHARE_SET_INFO, api_srv_net_share_set_info }, { "SRV_NETFILEENUM" , SRV_NETFILEENUM , api_srv_net_file_enum }, { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, + { "SRV_NET_SRV_SET_INFO" , SRV_NET_SRV_SET_INFO , api_srv_net_srv_set_info }, { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate}, diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index d071572804..902f47f5a2 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1047,6 +1047,28 @@ uint32 _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R return r_u->status; } +/******************************************************************* +net server set info +********************************************************************/ + +uint32 _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R_NET_SRV_SET_INFO *r_u) +{ + /* 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; + + DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__)); + + /* Set up the net server set info structure. */ + + init_srv_r_net_srv_set_info(r_u, 0x0, status); + + DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__)); + + return r_u->status; +} + /******************************************************************* net file enum ********************************************************************/ -- cgit From c2cfcb34e1fdef24ac7979bb0f77340d27fc6926 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Tue, 26 Jun 2001 20:23:45 +0000 Subject: SGI compiler fixes. Jeremy (This used to be commit 45bf995bf62aa6cc176d57e2f954cc2d379717ef) --- source3/rpc_server/srv_spoolss_nt.c | 12 ------------ source3/rpc_server/srv_srvsvc_nt.c | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 99830c035b..3fcb08891d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4213,7 +4213,6 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) { char *cmd = lp_addprinter_cmd(); - char *path; char **qlines; pstring command; pstring driverlocation; @@ -4221,11 +4220,6 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) int ret; int fd; - if (*lp_pathname(lp_servicenumber(PRINTERS_NAME))) - path = lp_pathname(lp_servicenumber(PRINTERS_NAME)); - else - path = lp_lockdir(); - /* build driver path... only 9X architecture is needed for legacy reasons */ slprintf(driverlocation, sizeof(driverlocation)-1, "\\\\%s\\print$\\WIN40\\0", global_myname); @@ -5494,18 +5488,12 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need if (*lp_enumports_cmd()) { char *cmd = lp_enumports_cmd(); - char *path; char **qlines; pstring command; int numlines; int ret; int fd; - if (*lp_pathname(lp_servicenumber(PRINTERS_NAME))) - path = lp_pathname(lp_servicenumber(PRINTERS_NAME)); - else - path = lp_lockdir(); - slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 1); DEBUG(10,("Running [%s]\n", command)); diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 902f47f5a2..39e482dc3c 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1619,7 +1619,7 @@ uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC get_current_user(&user, p); fstrcpy(user_name, uidtoname(user.uid)); - conn = make_connection(qualname, user_name, "", 0, "A:", user.vuid, &ecode); + conn = make_connection(qualname, user_name, null_pw, 0, "A:", user.vuid, &ecode); if (conn == NULL) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", qualname)); -- cgit From 2cddd5fe8ca05cd642428b4a7e2356f05cee6386 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 29 Jun 2001 18:41:31 +0000 Subject: From JF.... hi jeremy, can you commit the following patch against HEAD. I can't do it right now Thanks Tim for me. He changed the SAM_DISPINFO_1 array without checking if he didn't break the server code. And he did. So on my way I cleaned info_1, 2, .. 5 it may break winbind. I leave to tim the pleasure to fix it ;-) jf. I added some talloc changes and checks for alloc fails. Jeremy. (This used to be commit 001e9b7b540f04c80ba65c879aaa41acddc86f3e) --- source3/rpc_server/srv_samr_nt.c | 44 +++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 502774e986..5106271c60 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -770,7 +770,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 BOOL get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, uint32 *p_num_entries, uint32 max_entries) { fstring sid_str; @@ -789,7 +789,7 @@ static BOOL get_group_alias_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 sta enum_group_mapping(SID_NAME_WKN_GRP, &map, &num_entries, ENUM_ONLY_MAPPED); - *d_grp=(DOMAIN_GRP *)malloc(num_entries*sizeof(DOMAIN_GRP)); + *d_grp=(DOMAIN_GRP *)talloc(ctx, num_entries*sizeof(DOMAIN_GRP)); if (*d_grp==NULL) return NT_STATUS_NO_MEMORY; @@ -862,7 +862,7 @@ static BOOL get_group_alias_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 sta continue; } - *d_grp=Realloc(*d_grp, (num_entries+1)*sizeof(DOMAIN_GRP)); + *d_grp=talloc_realloc(ctx,*d_grp, (num_entries+1)*sizeof(DOMAIN_GRP)); if (*d_grp==NULL) { grent_free(glist); return NT_STATUS_NO_MEMORY; @@ -885,7 +885,7 @@ static BOOL get_group_alias_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 sta Get the group entries - similar to get_sampwd_entries(). ********************************************************************/ -static BOOL get_group_domain_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, +static BOOL get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, uint32 *p_num_entries, uint32 max_entries) { GROUP_MAP *map=NULL; @@ -896,7 +896,7 @@ static BOOL get_group_domain_entries(DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 st enum_group_mapping(SID_NAME_DOM_GRP, &map, &num_entries, ENUM_ONLY_MAPPED); - *d_grp=(DOMAIN_GRP *)malloc(num_entries*sizeof(DOMAIN_GRP)); + *d_grp=(DOMAIN_GRP *)talloc(ctx, num_entries*sizeof(DOMAIN_GRP)); if (*d_grp==NULL) return False; @@ -934,7 +934,7 @@ uint32 _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_ DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); /* the domain group array is being allocated in the function below */ - get_group_domain_entries(&grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); + get_group_domain_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp); @@ -967,7 +967,7 @@ 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)) + if (!get_group_alias_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES)) return NT_STATUS_ACCESS_DENIED; make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp); @@ -1042,7 +1042,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ break; case 0x3: case 0x5: - ret = get_group_domain_entries(&grps, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); + ret = get_group_domain_entries(p->mem_ctx, &grps, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); if (!ret) return NT_STATUS_ACCESS_DENIED; break; @@ -1066,30 +1066,36 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ data_size = q_u->max_size; orig_num_entries = num_entries; - ctr = (SAM_DISPINFO_CTR *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_CTR)); + if (!(ctr = (SAM_DISPINFO_CTR *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_CTR)))) + return NT_STATUS_NO_MEMORY; /* Now create reply structure */ switch (q_u->switch_level) { case 0x1: - ctr->sam.info1 = (SAM_DISPINFO_1 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_1)); - init_sam_dispinfo_1(ctr->sam.info1, &num_entries, &data_size, q_u->start_idx, pass); + if (!(ctr->sam.info1 = (SAM_DISPINFO_1 *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_1)))) + return NT_STATUS_NO_MEMORY; + init_sam_dispinfo_1(p->mem_ctx, ctr->sam.info1, &num_entries, &data_size, q_u->start_idx, pass); break; case 0x2: - ctr->sam.info2 = (SAM_DISPINFO_2 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_2)); - init_sam_dispinfo_2(ctr->sam.info2, &num_entries, &data_size, q_u->start_idx, pass); + if (!(ctr->sam.info2 = (SAM_DISPINFO_2 *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_2)))) + return NT_STATUS_NO_MEMORY; + init_sam_dispinfo_2(p->mem_ctx, ctr->sam.info2, &num_entries, &data_size, q_u->start_idx, pass); break; case 0x3: - ctr->sam.info3 = (SAM_DISPINFO_3 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_3)); - init_sam_dispinfo_3(ctr->sam.info3, &num_entries, &data_size, q_u->start_idx, grps); + if (!(ctr->sam.info3 = (SAM_DISPINFO_3 *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_3)))) + return NT_STATUS_NO_MEMORY; + init_sam_dispinfo_3(p->mem_ctx, ctr->sam.info3, &num_entries, &data_size, q_u->start_idx, grps); safe_free(grps); break; case 0x4: - ctr->sam.info4 = (SAM_DISPINFO_4 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_4)); - init_sam_dispinfo_4(ctr->sam.info4, &num_entries, &data_size, q_u->start_idx, pass); + if (!(ctr->sam.info4 = (SAM_DISPINFO_4 *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_4)))) + return NT_STATUS_NO_MEMORY; + init_sam_dispinfo_4(p->mem_ctx, ctr->sam.info4, &num_entries, &data_size, q_u->start_idx, pass); break; case 0x5: - ctr->sam.info5 = (SAM_DISPINFO_5 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_5)); - init_sam_dispinfo_5(ctr->sam.info5, &num_entries, &data_size, q_u->start_idx, grps); + if (!(ctr->sam.info5 = (SAM_DISPINFO_5 *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_5)))) + return NT_STATUS_NO_MEMORY; + init_sam_dispinfo_5(p->mem_ctx, ctr->sam.info5, &num_entries, &data_size, q_u->start_idx, grps); safe_free(grps); break; default: -- cgit From 8d0b9cf534bc2a219ff4fc47ab139efa994cd7d6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 29 Jun 2001 23:12:55 +0000 Subject: Added LsaGetConnectedCredentials patch from Manoj Naik . Jeremy. (This used to be commit 7079300da6dbd950e55dc5871851250d5a3717ff) --- source3/rpc_server/srv_lsa.c | 32 ++++++++++++++++++++++++++++++++ source3/rpc_server/srv_lsa_nt.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index b6a8c745a4..005398924e 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -268,6 +268,37 @@ static BOOL api_lsa_open_secret(pipes_struct *p) return True; } +/*************************************************************************** + api_lsa_UNK_GET_CONNUSER + ***************************************************************************/ + +static BOOL api_lsa_unk_get_connuser(pipes_struct *p) +{ + LSA_Q_UNK_GET_CONNUSER q_u; + LSA_R_UNK_GET_CONNUSER r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_unk_get_connuser("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_unk_get_connuser: failed to unmarshall LSA_Q_UNK_GET_CONNUSER.\n")); + return False; + } + + r_u.status = _lsa_unk_get_connuser(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_unk_get_connuser("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_unk_get_connuser: Failed to marshall LSA_R_UNK_GET_CONNUSER.\n")); + return False; + } + + return True; +} + /*************************************************************************** \PIPE\ntlsa commands ***************************************************************************/ @@ -282,6 +313,7 @@ static struct api_struct api_lsa_cmds[] = { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret }, { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids }, { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names }, + { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser}, { NULL , 0 , NULL } }; diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 6e501df414..afcace3f9c 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -519,3 +519,33 @@ uint32 _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SECR { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } + +uint32 _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u) +{ + fstring username, domname; + int ulen, dlen; + user_struct *vuser = get_valid_user_struct(p->vuid); + + if (vuser == NULL) + return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; + + fstrcpy(username, vuser->user.smb_name); + fstrcpy(domname, vuser->user.domain); + + ulen = strlen(username); + dlen = strlen(domname); + + init_uni_hdr(&r_u->hdr_user_name, ulen); + r_u->ptr_user_name = 1; + init_unistr2(&r_u->uni2_user_name, username, ulen); + + r_u->unk1 = 1; + + init_uni_hdr(&r_u->hdr_dom_name, dlen); + r_u->ptr_dom_name = 1; + init_unistr2(&r_u->uni2_dom_name, domname, dlen); + + r_u->status = NT_STATUS_NO_PROBLEMO; + + return r_u->status; +} -- cgit From e682d6d54e3f23266e3a75d1461e8dff2d729006 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 2 Jul 2001 13:43:46 +0000 Subject: This fix from Eelco Vriezekolk is for a SIG11 bug where we would always file_free(fsp) twice, once in close_file and once afterwoulds. The bug was reported in SAMBA_2_2, but a code inspection shows it to be in HEAD as well. (Unfortunetly I don't have the facilites to actualy check this, but the change is quite simple, makes sence and compiles). Andrew Bartlett (This used to be commit 5d3f622375842961a79536d36ee6f6ad508b91f1) --- source3/rpc_server/srv_srvsvc_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 39e482dc3c..44821d1432 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1662,7 +1662,6 @@ uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC psd->dacl->revision = (uint16) NT4_ACL_REVISION; close_file(fsp, True); - file_free(fsp); close_cnum(conn, user.vuid); return r_u->status; @@ -1671,7 +1670,6 @@ uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC if(fsp) { close_file(fsp, True); - file_free(fsp); } if (conn) -- cgit From ed2fc9622284e928d328c2f91ddf869ca13e0a1e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 2 Jul 2001 18:37:39 +0000 Subject: Fixed extra file_free calls - my fault :-(. Jeremy. (This used to be commit 2f8b84bda040edc87a7af29c3a281cf335e392cb) --- source3/rpc_server/srv_srvsvc_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 44821d1432..b487eb1c82 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1747,7 +1747,6 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ } close_file(fsp, True); - file_free(fsp); close_cnum(conn, user.vuid); return r_u->status; @@ -1755,7 +1754,6 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ if(fsp) { close_file(fsp, True); - file_free(fsp); } if (conn) -- cgit From 87fbb7092b8f8b2f0db0f361c3d625e19de57cd9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 4 Jul 2001 07:15:53 +0000 Subject: The big character set handling changeover! This commit gets rid of all our old codepage handling and replaces it with iconv. All internal strings in Samba are now in "unix" charset, which may be multi-byte. See internals.doc and my posting to samba-technical for a more complete explanation. (This used to be commit debb471267960e56005a741817ebd227ecfc512a) --- source3/rpc_server/srv_lsa_nt.c | 27 +++++---------- source3/rpc_server/srv_netlog_nt.c | 9 +++-- source3/rpc_server/srv_pipe.c | 6 ++-- source3/rpc_server/srv_reg_nt.c | 4 +-- source3/rpc_server/srv_samr_nt.c | 10 +++--- source3/rpc_server/srv_spoolss_nt.c | 67 ++++++++++++++----------------------- source3/rpc_server/srv_srvsvc_nt.c | 5 --- source3/rpc_server/srv_wkssvc_nt.c | 2 +- 8 files changed, 50 insertions(+), 80 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index afcace3f9c..cd97dfc6d1 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -72,7 +72,7 @@ static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) if (dom_name != NULL) { for (num = 0; num < ref->num_ref_doms_1; num++) { fstring domname; - fstrcpy(domname, dos_unistr2_to_str(&ref->ref_dom[num].uni_dom_name)); + rpcstr_pull(domname, &ref->ref_dom[num].uni_dom_name, sizeof(domname), -1, 0); if (strequal(domname, dom_name)) return num; } @@ -128,7 +128,7 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, /* Split name into domain and user component */ - pstrcpy(full_name, dos_unistr2_to_str(&name[i])); + rpcstr_pull(full_name, &name[i], sizeof(full_name), -1, 0); split_domain_name(full_name, dom_name, user); /* Lookup name */ @@ -238,11 +238,6 @@ static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME sid_split_rid(&find_sid, &rid); } - /* unistr routines take dos codepage strings */ - - unix_to_dos(dom_name, True); - unix_to_dos(name, True); - dom_idx = init_dom_ref(ref, dom_name, &find_sid); DEBUG(10,("init_lsa_trans_names: added user '%s\\%s' to " @@ -337,7 +332,6 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO { LSA_INFO_UNION *info = &r_u->dom; DOM_SID domain_sid; - fstring dos_domain; char *name = NULL; DOM_SID *sid = NULL; @@ -346,9 +340,6 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO if (!find_policy_by_hnd(p, &q_u->pol, NULL)) return NT_STATUS_INVALID_HANDLE; - fstrcpy(dos_domain, global_myworkgroup); - unix_to_dos(dos_domain, True); - switch (q_u->info_class) { case 0x02: { @@ -368,20 +359,20 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - name = dos_domain; + name = global_myworkgroup; sid = &global_sam_sid; break; case ROLE_DOMAIN_MEMBER: - name = dos_domain; + name = global_myworkgroup; /* We need to return the Domain SID here. */ - if (secrets_fetch_domain_sid(dos_domain, + if (secrets_fetch_domain_sid(global_myworkgroup, &domain_sid)) sid = &domain_sid; else return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; break; case ROLE_STANDALONE: - name = dos_domain; + name = global_myworkgroup; sid = NULL; /* Tell it we're not in a domain. */ break; default: @@ -394,15 +385,15 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - name = dos_domain; + name = global_myworkgroup; sid = &global_sam_sid; break; case ROLE_DOMAIN_MEMBER: - name = dos_domain; + name = global_myworkgroup; sid = &global_sam_sid; break; case ROLE_STANDALONE: - name = dos_domain; + name = global_myworkgroup; sid = &global_sam_sid; break; default: diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index bbda4060f2..14f3e1d211 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -202,8 +202,7 @@ uint32 _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u) if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; - fstrcpy(mach_acct, dos_unistrn2(q_u->uni_logon_clnt.buffer, - q_u->uni_logon_clnt.uni_str_len)); + rpcstr_pull(mach_acct,q_u->uni_logon_clnt.buffer,sizeof(fstring),q_u->uni_logon_clnt.uni_str_len*2,0); strlower(mach_acct); fstrcat(mach_acct, "$"); @@ -357,8 +356,8 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); - 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)); + rpcstr_pull(mach_acct,q_u->clnt_id.login.uni_acct_name.buffer, + sizeof(mach_acct),q_u->clnt_id.login.uni_acct_name.uni_str_len*2,0); DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); @@ -592,7 +591,7 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ /* check username exists */ - pstrcpy(nt_username, dos_unistrn2(uni_samlogon_user->buffer, uni_samlogon_user->uni_str_len)); + rpcstr_pull(nt_username,uni_samlogon_user->buffer,sizeof(nt_username),uni_samlogon_user->uni_str_len*2,0); DEBUG(3,("User:[%s]\n", nt_username)); diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 5f6a1d479c..cdf914a164 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -296,9 +296,9 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm */ if (p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_UNICODE) { - fstrcpy(user_name, dos_unistrn2((uint16*)ntlmssp_resp->user, ntlmssp_resp->hdr_usr.str_str_len/2)); - fstrcpy(domain, dos_unistrn2((uint16*)ntlmssp_resp->domain, ntlmssp_resp->hdr_domain.str_str_len/2)); - fstrcpy(wks, dos_unistrn2((uint16*)ntlmssp_resp->wks, ntlmssp_resp->hdr_wks.str_str_len/2)); + rpcstr_pull(user_name, ntlmssp_resp->user, sizeof(fstring), ntlmssp_resp->hdr_usr.str_str_len*2, 0 ); + rpcstr_pull(domain, ntlmssp_resp->domain, sizeof(fstring), ntlmssp_resp->hdr_domain.str_str_len*2, 0); + rpcstr_pull(wks, ntlmssp_resp->wks, sizeof(fstring), ntlmssp_resp->hdr_wks.str_str_len*2, 0); } else { fstrcpy(user_name, ntlmssp_resp->user); fstrcpy(domain, ntlmssp_resp->domain); diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 502d551437..3ed673c68a 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -85,7 +85,7 @@ uint32 _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY if (!find_policy_by_hnd(p, &q_u->pol, NULL)) return NT_STATUS_INVALID_HANDLE; - fstrcpy(name, dos_unistrn2(q_u->uni_name.buffer, q_u->uni_name.uni_str_len)); + rpcstr_pull(name,q_u->uni_name.buffer,sizeof(name),q_u->uni_name.uni_str_len*2,0); DEBUG(5,("reg_open_entry: %s\n", name)); @@ -129,7 +129,7 @@ uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) if (find_policy_by_hnd(p, &q_u->pol, NULL) == -1) return NT_STATUS_INVALID_HANDLE; - fstrcpy(name, dos_unistrn2(q_u->uni_type.buffer, q_u->uni_type.uni_str_len)); + rpcstr_pull(name, q_u->uni_type.buffer, sizeof(name), q_u->uni_type.uni_str_len*2, 0); DEBUG(5,("reg_info: checking key: %s\n", name)); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 5106271c60..d783de3b4b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -246,7 +246,7 @@ static char *unmap_unixname(char *unix_user_name, int name_idx) if (!*unix_user_name) return NULL; if (!*mapfile) return NULL; - lines = file_lines_load(mapfile, NULL,False); + lines = file_lines_load(mapfile, NULL); if (!lines) { DEBUG(0,("unmap_unixname: can't open username map %s\n", mapfile)); return NULL; @@ -1253,7 +1253,7 @@ uint32 _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOK rid [i] = 0xffffffff; type[i] = SID_NAME_UNKNOWN; - fstrcpy(name, dos_unistrn2(q_u->uni_name[i].buffer, q_u->uni_name[i].uni_str_len)); + rpcstr_pull(name, q_u->uni_name[i].buffer, sizeof(name), q_u->uni_name[i].uni_str_len*2, 0); if(sid_equal(&pol_sid, &global_sam_sid)) { DOM_SID sid; @@ -1284,8 +1284,8 @@ uint32 _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_R_ r_u->status = NT_STATUS_NOPROBLEMO; - 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)); + rpcstr_pull(user_name, q_u->uni_user_name.buffer, sizeof(user_name), q_u->uni_user_name.uni_str_len*2, 0); + rpcstr_pull(wks, q_u->uni_dest_host.buffer, sizeof(wks), q_u->uni_dest_host.uni_str_len,0); DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); @@ -1810,7 +1810,7 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR reply if the account already exists... */ - fstrcpy(mach_acct, dos_unistrn2(user_account.buffer, user_account.uni_str_len)); + rpcstr_pull(mach_acct, user_account.buffer, sizeof(mach_acct), user_account.uni_str_len*2, 0); strlower(mach_acct); pdb_init_sam(&sam_pass); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3fcb08891d..7002241a00 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -300,7 +300,6 @@ static uint32 delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) /* Printer->dev.handlename equals portname equals sharename */ slprintf(command, sizeof(command)-1, "%s \"%s\"", cmd, Printer->dev.handlename); - dos_to_unix(command, True); /* Convert printername to unix-codepage */ DEBUG(10,("Running [%s]\n", command)); ret = smbrun(command, NULL); @@ -944,8 +943,8 @@ BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, return False; } - unistr_to_dos(nt_devmode->devicename, (const char *)devmode->devicename.buffer, 31); - unistr_to_dos(nt_devmode->formname, (const char *)devmode->formname.buffer, 31); + rpcstr_pull(nt_devmode->devicename,devmode->devicename.buffer, 31, -1, 0); + rpcstr_pull(nt_devmode->formname,devmode->formname.buffer, 31, -1, 0); nt_devmode->specversion=devmode->specversion; nt_devmode->driverversion=devmode->driverversion; @@ -1356,7 +1355,6 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin fstring unix_printer; fstrcpy(unix_printer, printer+2); /* the +2 is to strip the leading 2 backslashs */ - dos_to_unix(unix_printer, True); if(!spoolss_connect_to_client(&cli, unix_printer)) return False; @@ -1437,7 +1435,7 @@ static void spoolss_notify_server_name(int snum, slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname); - len = (uint32)dos_PutUniCode(temp, temp_name, sizeof(temp) - 2, True); + len = rpcstr_push(temp, temp_name, sizeof(temp)-2, 0); data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -1471,8 +1469,7 @@ static void spoolss_notify_printer_name(int snum, p++; } - len = (uint32)dos_PutUniCode(temp, p, sizeof(temp) - 2, True); - + len = rpcstr_push(temp, p, sizeof(temp)-2, 0); data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -1496,8 +1493,7 @@ static void spoolss_notify_share_name(int snum, pstring temp; uint32 len; - len = (uint32)dos_PutUniCode(temp, lp_servicename(snum), - sizeof(temp) - 2, True); + len = rpcstr_push(temp, lp_servicename(snum), sizeof(temp) - 2, 0); data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -1524,8 +1520,7 @@ static void spoolss_notify_port_name(int snum, /* even if it's strange, that's consistant in all the code */ - len = (uint32)dos_PutUniCode(temp, printer->info_2->portname, - sizeof(temp) - 2, True); + len = rpcstr_push(temp, printer->info_2->portname, sizeof(temp) - 2, 0); data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -1552,9 +1547,7 @@ static void spoolss_notify_driver_name(int snum, pstring temp; uint32 len; - len = (uint32)dos_PutUniCode(temp, printer->info_2->drivername, - sizeof(temp) - 2, True); - + len = rpcstr_push(temp, printer->info_2->drivername, sizeof(temp) - 2, 0); data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -1579,11 +1572,10 @@ static void spoolss_notify_comment(int snum, uint32 len; if (*printer->info_2->comment == '\0') - len = (uint32)dos_PutUniCode(temp, lp_comment(snum), - sizeof(temp) - 2, True); + len = rpcstr_push(temp, lp_comment(snum), sizeof(temp) - 2, 0); + else - len = (uint32)dos_PutUniCode(temp, printer->info_2->comment, - sizeof(temp) - 2, True); + len = rpcstr_push(temp, printer->info_2->comment, sizeof(temp) - 2, 0); data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -1610,8 +1602,7 @@ static void spoolss_notify_location(int snum, pstring temp; uint32 len; - len = (uint32)dos_PutUniCode(temp, printer->info_2->location, - sizeof(temp) - 2, True); + len = rpcstr_push(temp, printer->info_2->location,sizeof(temp) - 2, 0); data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -1650,8 +1641,7 @@ static void spoolss_notify_sepfile(int snum, pstring temp; uint32 len; - len = (uint32)dos_PutUniCode(temp, printer->info_2->sepfile, - sizeof(temp) - 2, True); + len = rpcstr_push(temp, printer->info_2->sepfile, sizeof(temp) - 2, 0); data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -1677,8 +1667,7 @@ static void spoolss_notify_print_processor(int snum, pstring temp; uint32 len; - len = (uint32)dos_PutUniCode(temp, printer->info_2->printprocessor, - sizeof(temp) - 2, True); + len = rpcstr_push(temp, printer->info_2->printprocessor, sizeof(temp) - 2, 0); data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -1704,8 +1693,8 @@ static void spoolss_notify_parameters(int snum, pstring temp; uint32 len; - len = (uint32)dos_PutUniCode(temp, printer->info_2->parameters, - sizeof(temp) - 2, True); + len = rpcstr_push(temp, printer->info_2->parameters, sizeof(temp) - + 2, 0); data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -1731,8 +1720,7 @@ static void spoolss_notify_datatype(int snum, pstring temp; uint32 len; - len = (uint32)dos_PutUniCode(temp, printer->info_2->datatype, - sizeof(pstring) - 2, True); + len = rpcstr_push(temp, printer->info_2->datatype, sizeof(pstring)-2, 0); data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -1882,8 +1870,8 @@ static void spoolss_notify_username(int snum, pstring temp; uint32 len; - len = (uint32)dos_PutUniCode(temp, queue->user, - sizeof(temp) - 2, True); + len = rpcstr_push(temp, queue->user, sizeof(temp) - 2, 0); + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -1920,9 +1908,8 @@ static void spoolss_notify_job_name(int snum, pstring temp; uint32 len; - len = (uint32)dos_PutUniCode(temp, queue->file, sizeof(temp) - 2, - True); - + len = rpcstr_push(temp, queue->file, sizeof(temp) - 2, 0); + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -1970,7 +1957,7 @@ static void spoolss_notify_job_status_string(int snum, } #endif /* NO LONGER NEEDED. */ - len = (uint32)dos_PutUniCode(temp, p, sizeof(temp) - 2, True); + len = rpcstr_push(temp, p, sizeof(temp) - 2, 0); data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -3487,7 +3474,7 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser DEBUG(0,("init_unistr_array: Realloc error\n" )); return; } - j += (dos_PutUniCode((char *)(*uni_array+j), line , sizeof(uint16)*strlen(line), True) / sizeof(uint16) ); + j += (rpcstr_push((*uni_array+j), line, sizeof(uint16)*strlen(line)+2, 0)/ sizeof(uint16)); i++; } @@ -4231,8 +4218,6 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) printer->info_2->portname, printer->info_2->drivername, printer->info_2->location, driverlocation); - /* Convert script args to unix-codepage */ - dos_to_unix(command, True); DEBUG(10,("Running [%s]\n", command)); ret = smbrun(command, &fd); DEBUGADD(10,("returned [%d]\n", ret)); @@ -4245,7 +4230,7 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) numlines = 0; /* Get lines and convert them back to dos-codepage */ - qlines = fd_lines_load(fd, &numlines, True); + qlines = fd_lines_load(fd, &numlines); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); close(fd); @@ -5507,7 +5492,7 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need } numlines = 0; - qlines = fd_lines_load(fd, &numlines,True); + qlines = fd_lines_load(fd, &numlines); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); close(fd); @@ -5605,7 +5590,7 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need } numlines = 0; - qlines = fd_lines_load(fd, &numlines,True); + qlines = fd_lines_load(fd, &numlines); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); close(fd); @@ -6061,7 +6046,7 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S return ERROR_NOT_ENOUGH_MEMORY; } - *out_value_len = (uint32)dos_PutUniCode((char *)*out_value, value, in_value_len, True); + *out_value_len = rpcstr_push((char *)*out_value,value, in_value_len, 0); *out_type=type; diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index b487eb1c82..78d9429b43 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1229,9 +1229,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); @@ -1338,7 +1336,6 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S 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) { @@ -1455,7 +1452,6 @@ 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) { @@ -1522,7 +1518,6 @@ uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S 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) { diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 40771d2fb9..47566bbf3e 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -50,7 +50,7 @@ static void create_wks_info_100(WKS_INFO_100 *inf) 0x000001f4, /* platform id info */ lp_major_announce_version(), lp_minor_announce_version(), - my_name, unix_to_dos(domain,False)); + my_name, domain); } /******************************************************************* -- cgit From 527e824293ee934ca5da0ef5424efe5ab7757248 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 4 Jul 2001 07:36:09 +0000 Subject: strchr and strrchr are macros when compiling with optimisation in gcc, so we can't redefine them. damn. (This used to be commit c41fc06376d1a2b83690612304e85010b5e5f3cf) --- source3/rpc_server/srv_dfs_nt.c | 2 +- source3/rpc_server/srv_samr_nt.c | 10 +++++----- source3/rpc_server/srv_spoolss_nt.c | 8 ++++---- source3/rpc_server/srv_util.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 54c3fbf324..a84f2ceb48 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -253,7 +253,7 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I pstrcpy(path, ref->alternate_path); trim_string(path,"\\",""); - p = strrchr(path,'\\'); + p = strrchr_m(path,'\\'); if(p==NULL) { DEBUG(4,("init_reply_dfs_info_3: invalid path: no \\ found in %s\n",path)); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d783de3b4b..a73dcb30d2 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -256,7 +256,7 @@ static char *unmap_unixname(char *unix_user_name, int name_idx) for (i=0; lines[i]; i++) { char *unixname = lines[i]; - char *dosname = strchr(unixname,'='); + char *dosname = strchr_m(unixname,'='); if (!dosname) continue; @@ -271,7 +271,7 @@ static char *unmap_unixname(char *unix_user_name, int name_idx) unixname++; } - if (!*unixname || strchr("#;",*unixname)) + if (!*unixname || strchr_m("#;",*unixname)) continue; if (strncmp(unixname, unix_user_name, strlen(unix_user_name))) @@ -280,7 +280,7 @@ static char *unmap_unixname(char *unix_user_name, int name_idx) /* We have matched the UNIX user name */ while(next_token(&dosname, tok, LIST_SEP, sizeof(tok))) { - if (!strchr("@&+", *tok)) { + if (!strchr_m("@&+", *tok)) { name_idx--; if (name_idx < 0 ) { break; @@ -406,7 +406,7 @@ static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, /* Don't enumerate winbind users as they are not local */ - if (strchr(pwd->pw_name, *sep) != NULL) { + if (strchr_m(pwd->pw_name, *sep) != NULL) { continue; } @@ -834,7 +834,7 @@ static BOOL get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID sid_split_rid(&smap.sid, &trid); /* Don't return winbind groups as they are not local! */ - if (strchr(smap.nt_name, *sep) != NULL) { + if (strchr_m(smap.nt_name, *sep) != NULL) { DEBUG(10,("get_group_alias_entries: not returing %s, not local.\n", smap.nt_name )); continue; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7002241a00..79c788e67b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -377,7 +377,7 @@ static BOOL set_printer_hnd_printertype(Printer_entry *Printer, char *handlename } /* it's a print server */ - if (*handlename=='\\' && *(handlename+1)=='\\' && !strchr(handlename+2, '\\')) { + if (*handlename=='\\' && *(handlename+1)=='\\' && !strchr_m(handlename+2, '\\')) { DEBUGADD(4,("Printer is a print server\n")); Printer->printer_type = PRINTER_HANDLE_IS_PRINTSERVER; } @@ -414,7 +414,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) return False; if (*handlename=='\\') { - aprinter=strchr(handlename+2, '\\'); + aprinter=strchr_m(handlename+2, '\\'); aprinter++; } else { @@ -442,7 +442,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) continue; - printername=strchr(printer->info_2->printername+2, '\\'); + printername=strchr_m(printer->info_2->printername+2, '\\'); printername++; DEBUG(10,("set_printer_hnd_name: name [%s], aprinter [%s]\n", @@ -1461,7 +1461,7 @@ static void spoolss_notify_printer_name(int snum, uint32 len; /* the notify name should not contain the \\server\ part */ - char *p = strrchr(printer->info_2->printername, '\\'); + char *p = strrchr_m(printer->info_2->printername, '\\'); if (!p) { p = printer->info_2->printername; diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index deaa6008b9..f9e02b9bca 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -114,7 +114,7 @@ int make_dom_gids(TALLOC_CTX *ctx, char *gids_str, DOM_GID **ppgids) uint32 rid = 0; int i; - attr = strchr(s2,'/'); + attr = strchr_m(s2,'/'); if (attr) *attr++ = 0; -- cgit From 3a40f80a94cba569c1a1f19ba36165069ba7e83a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 Jul 2001 22:36:25 +0000 Subject: Fix for enumerating large numbers of users. Jeremy. (This used to be commit c8c138c1fbb49799a2dd4c6e781bd89f51c0c0c5) --- source3/rpc_server/srv_samr_nt.c | 81 ++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 33 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a73dcb30d2..fb2dcf03cc 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -88,28 +88,28 @@ static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) dynamically returns the correct user info..... JRA. ********************************************************************/ -static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, +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) { SAM_ACCOUNT *pwd = NULL; - BOOL ret; + BOOL not_finished = True; (*num_entries) = 0; (*total_entries) = 0; if (pw_buf == NULL) - return False; + return NT_STATUS_NO_MEMORY; pdb_init_sam(&pwd); if (!pdb_setsampwent(False)) { DEBUG(0, ("get_sampwd_entries: Unable to open passdb.\n")); pdb_free_sam(pwd); - return False; + return NT_STATUS_ACCESS_DENIED; } - while (((ret = pdb_getsampwent(pwd)) != False) && (*num_entries) < max_num_entries) { + while (((not_finished = pdb_getsampwent(pwd)) != False) && (*num_entries) < max_num_entries) { int user_name_len; if (start_idx > 0) { @@ -148,32 +148,36 @@ static BOOL get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, pdb_endsampwent(); pdb_free_sam(pwd); - return (*num_entries) > 0; + if (not_finished) + return STATUS_MORE_ENTRIES; + else + return NT_STATUS_NO_PROBLEMO; } -static BOOL jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, +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) { SAM_ACCOUNT *pwd = NULL; + BOOL not_finished = True; *num_entries = 0; *total_entries = 0; if (pw_buf == NULL) - return False; + 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)); if (!pdb_setsampwent(False)) { DEBUG(0, ("jf_get_sampwd_entries: Unable to open passdb.\n")); - return False; + return NT_STATUS_ACCESS_DENIED; } pdb_init_sam(&pwd); - while ((pdb_getsampwent(pwd) != False) && (*num_entries) < max_num_entries) { + while (((not_finished = pdb_getsampwent(pwd)) != False) && (*num_entries) < max_num_entries) { int user_name_len; int full_name_len; @@ -221,7 +225,10 @@ static BOOL jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, pdb_free_sam(pwd); - return True; + if (not_finished) + return STATUS_MORE_ENTRIES; + else + return NT_STATUS_NO_PROBLEMO; } /******************************************************************* @@ -684,7 +691,6 @@ uint32 _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_R_ SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; int num_entries = 0; int total_entries = 0; - BOOL ret; r_u->status = NT_STATUS_NOPROBLEMO; @@ -695,12 +701,12 @@ uint32 _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_R_ DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); become_root(); - ret = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, + r_u->status = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, MAX_SAM_ENTRIES, q_u->acb_mask); unbecome_root(); - if (!ret) - return NT_STATUS_ACCESS_DENIED; + if (r_u->status != NT_STATUS_NOPROBLEMO && r_u->status != STATUS_MORE_ENTRIES) + return r_u->status; samr_clear_passwd_fields(pass, num_entries); @@ -995,7 +1001,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ int total_entries = 0; uint32 data_size = 0; DOM_SID sid; - BOOL ret; + uint32 disp_ret; SAM_DISPINFO_CTR *ctr; DEBUG(5, ("samr_reply_query_dispinfo: %d\n", __LINE__)); @@ -1020,30 +1026,30 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ case 0x4: become_root(); #if 0 - ret = get_passwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, + r_u->status = get_passwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, MAX_SAM_ENTRIES, acb_mask); #endif #if 0 /* * Which should we use here ? JRA. */ - ret = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, + r_u->status = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, MAX_SAM_ENTRIES, acb_mask); #endif #if 1 - ret = jf_get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, + r_u->status = jf_get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, MAX_SAM_ENTRIES, acb_mask); #endif unbecome_root(); - if (!ret) { + if (r_u->status!=STATUS_MORE_ENTRIES && r_u->status!=NT_STATUS_NO_PROBLEMO) { DEBUG(5, ("get_sampwd_entries: failed\n")); - return NT_STATUS_ACCESS_DENIED; + return r_u->status; } break; case 0x3: case 0x5: - ret = get_group_domain_entries(p->mem_ctx, &grps, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); - if (!ret) + r_u->status = get_group_domain_entries(p->mem_ctx, &grps, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); + if (r_u->status != NT_STATUS_NO_PROBLEMO) return NT_STATUS_ACCESS_DENIED; break; default: @@ -1051,6 +1057,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ return NT_STATUS_INVALID_INFO_CLASS; } + orig_num_entries = num_entries; if (num_entries > q_u->max_entries) num_entries = q_u->max_entries; @@ -1064,7 +1071,6 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ samr_clear_passwd_fields(pass, num_entries); data_size = q_u->max_size; - orig_num_entries = num_entries; if (!(ctr = (SAM_DISPINFO_CTR *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_CTR)))) return NT_STATUS_NO_MEMORY; @@ -1074,29 +1080,39 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ case 0x1: if (!(ctr->sam.info1 = (SAM_DISPINFO_1 *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_1)))) return NT_STATUS_NO_MEMORY; - init_sam_dispinfo_1(p->mem_ctx, ctr->sam.info1, &num_entries, &data_size, q_u->start_idx, pass); + 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) + return disp_ret; break; case 0x2: if (!(ctr->sam.info2 = (SAM_DISPINFO_2 *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_2)))) return NT_STATUS_NO_MEMORY; - init_sam_dispinfo_2(p->mem_ctx, ctr->sam.info2, &num_entries, &data_size, q_u->start_idx, pass); + 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) + return disp_ret; break; case 0x3: if (!(ctr->sam.info3 = (SAM_DISPINFO_3 *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_3)))) return NT_STATUS_NO_MEMORY; - init_sam_dispinfo_3(p->mem_ctx, ctr->sam.info3, &num_entries, &data_size, q_u->start_idx, grps); + disp_ret = init_sam_dispinfo_3(p->mem_ctx, ctr->sam.info3, &num_entries, &data_size, q_u->start_idx, grps); safe_free(grps); + if (disp_ret != NT_STATUS_NO_PROBLEMO) + return disp_ret; break; case 0x4: if (!(ctr->sam.info4 = (SAM_DISPINFO_4 *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_4)))) return NT_STATUS_NO_MEMORY; - init_sam_dispinfo_4(p->mem_ctx, ctr->sam.info4, &num_entries, &data_size, q_u->start_idx, pass); + 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) + return disp_ret; break; case 0x5: if (!(ctr->sam.info5 = (SAM_DISPINFO_5 *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_5)))) return NT_STATUS_NO_MEMORY; - init_sam_dispinfo_5(p->mem_ctx, ctr->sam.info5, &num_entries, &data_size, q_u->start_idx, grps); + disp_ret = init_sam_dispinfo_5(p->mem_ctx, ctr->sam.info5, &num_entries, &data_size, q_u->start_idx, grps); safe_free(grps); + if (disp_ret != NT_STATUS_NO_PROBLEMO) + return disp_ret; break; default: ctr->sam.info = NULL; @@ -1105,11 +1121,10 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ DEBUG(5, ("_samr_query_dispinfo: %d\n", __LINE__)); - init_samr_r_query_dispinfo(r_u, num_entries, data_size, q_u->switch_level, ctr, r_u->status); - - if (num_entries < orig_num_entries) { + if (num_entries < orig_num_entries) return STATUS_MORE_ENTRIES; - } + + init_samr_r_query_dispinfo(r_u, num_entries, data_size, q_u->switch_level, ctr, r_u->status); return r_u->status; } -- cgit From 28a53730a9c321eed6b833e3b0da69254b5bc08c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 7 Jul 2001 08:45:39 +0000 Subject: Add a new paramater: add machine script This allows the administrator to define different scripts for adding unix users and automaticly adding machines. If it is not defined, it falls back to the value of 'add user script'. Andrew Bartlett (This used to be commit 7a478e050f3ab33bd0141a58c698d748f0d2b204) --- source3/rpc_server/srv_samr_nt.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index fb2dcf03cc..829218008d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1860,10 +1860,18 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR * JFM (2/3/2001), to clear any possible bad understanding (-: */ - pstrcpy(add_script, lp_adduser_script()); + pstrcpy(add_script, lp_addmachine_script()); - if(*add_script) - smb_create_user(mach_acct, NULL); + if (!*add_script) { + pstrcpy(add_script, lp_adduser_script()); + } + + if(*add_script) { + int add_ret; + all_string_sub(add_script, "%u", mach_acct, sizeof(mach_acct)); + add_ret = smbrun(add_script,NULL); + DEBUG(3,("_api_samr_create_user: Running the command `%s' gave %d\n",add_script,add_ret)); + } /* add the user in the smbpasswd file or the Samba authority database */ if (!local_password_change(mach_acct, local_flags, NULL, err_str, -- cgit From 5b8d230e39cedda6117cf8528065cbab45bdd835 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 8 Jul 2001 14:10:30 +0000 Subject: This removes unused paramaters from various authtication functions, and should not change behaviour. This should make my later diffs smaller, where I actualy start cleaning up this mess... Andrew Bartlett (This used to be commit 04f090c224bb7ac3b53c430a591fce1fc939a81c) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index cdf914a164..cd17de77f3 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -363,7 +363,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm become_root(); if(!(p->ntlmssp_auth_validated = pass_check_smb(pipe_user_name, domain, - (uchar*)p->challenge, lm_owf, nt_owf, NULL))) { + (uchar*)p->challenge, lm_owf, nt_owf))) { DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name )); unbecome_root(); -- cgit From 62d399f3cf588b8b2f31672111ac67034009ee78 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 9 Jul 2001 18:25:40 +0000 Subject: add query user info level 20 (for RAS) add query dominfo level 5 some cleanup, don't free talloced memory. implement delete domain and local groups. J.F. (This used to be commit 3f14dda2a21850edfd540be2624867e5f70a382c) --- source3/rpc_server/srv_samr_nt.c | 217 +++++++++++++++++++++++++++++++++++---- 1 file changed, 195 insertions(+), 22 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 829218008d..95caa1dda8 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -181,14 +181,17 @@ static uint32 jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, int user_name_len; int full_name_len; - if (acb_mask != 0 && !(pdb_get_acct_ctrl(pwd) & 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; } @@ -671,6 +674,9 @@ static void make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNISTR return; } + ZERO_STRUCTP(sam); + ZERO_STRUCTP(uni_name); + for (i = 0; i < num_sam_entries; i++) { int len = pass[i].uni_user_name.uni_str_len; @@ -793,7 +799,7 @@ static BOOL get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID /* well-known aliases */ if (sid_equal(sid, &global_sid_Builtin) && !lp_hide_local_users()) { - enum_group_mapping(SID_NAME_WKN_GRP, &map, &num_entries, ENUM_ONLY_MAPPED); + enum_group_mapping(SID_NAME_WKN_GRP, &map, &num_entries, ENUM_ALL_MAPPED); *d_grp=(DOMAIN_GRP *)talloc(ctx, num_entries*sizeof(DOMAIN_GRP)); if (*d_grp==NULL) @@ -877,6 +883,7 @@ static BOOL get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID fstrcpy((*d_grp)[num_entries].name, smap.nt_name); (*d_grp)[num_entries].rid = trid; num_entries++; + DEBUG(10,("get_group_alias_entries: added entry %d, rid:%d\n", num_entries, trid)); } grent_free(glist); @@ -884,32 +891,45 @@ static BOOL get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID *p_num_entries = num_entries; - return True; + DEBUG(10,("get_group_alias_entries: returning %d entries\n", *p_num_entries)); + + return NT_STATUS_NO_PROBLEMO; } /******************************************************************* Get the group entries - similar to get_sampwd_entries(). ********************************************************************/ -static BOOL get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, +static uint32 get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, uint32 *p_num_entries, uint32 max_entries) { GROUP_MAP *map=NULL; int i; + uint32 group_entries = 0; uint32 num_entries = 0; *p_num_entries = 0; - enum_group_mapping(SID_NAME_DOM_GRP, &map, &num_entries, ENUM_ONLY_MAPPED); + enum_group_mapping(SID_NAME_DOM_GRP, &map, &group_entries, ENUM_ONLY_MAPPED); + + num_entries=group_entries-start_idx; + + /* limit the number of entries */ + if (num_entries>max_entries) { + DEBUG(5,("Limiting to %d entries\n", max_entries)); + num_entries=max_entries; + } *d_grp=(DOMAIN_GRP *)talloc(ctx, num_entries*sizeof(DOMAIN_GRP)); - if (*d_grp==NULL) - return False; + if (num_entries!=0 && *d_grp==NULL){ + safe_free(map); + return NT_STATUS_NO_MEMORY; + } for (i=0; imem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp); - safe_free(grp); - init_samr_r_enum_dom_groups(r_u, q_u->start_idx, num_entries); DEBUG(5,("samr_enum_dom_groups: %d\n", __LINE__)); @@ -973,12 +991,12 @@ 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(p->mem_ctx, &grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES)) + if (get_group_alias_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES)!=NT_STATUS_NO_PROBLEMO) return NT_STATUS_ACCESS_DENIED; make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp); - safe_free(grp); + /*safe_free(grp);*/ init_samr_r_enum_dom_aliases(r_u, q_u->start_idx, num_entries); @@ -1014,9 +1032,13 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ /* decide how many entries to get depending on the max_entries and max_size passed by client */ + DEBUG(5, ("samr_reply_query_dispinfo: max_entries before %d\n", q_u->max_entries)); + if(q_u->max_entries > MAX_SAM_ENTRIES) q_u->max_entries = MAX_SAM_ENTRIES; + DEBUG(5, ("samr_reply_query_dispinfo: max_entries after %d\n", q_u->max_entries)); + /* Get what we need from the password database */ switch (q_u->switch_level) { case 0x2: @@ -1095,7 +1117,6 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ if (!(ctr->sam.info3 = (SAM_DISPINFO_3 *)talloc(p->mem_ctx,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); - safe_free(grps); if (disp_ret != NT_STATUS_NO_PROBLEMO) return disp_ret; break; @@ -1110,7 +1131,6 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ if (!(ctr->sam.info5 = (SAM_DISPINFO_5 *)talloc(p->mem_ctx,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); - safe_free(grps); if (disp_ret != NT_STATUS_NO_PROBLEMO) return disp_ret; break; @@ -1371,7 +1391,7 @@ static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, fstring nam uint32 _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP_RIDS *r_u) { fstring group_names[MAX_SAM_ENTRIES]; - uint32 group_attrs[MAX_SAM_ENTRIES]; + uint32 *group_attrs = NULL; UNIHDR *hdr_name = NULL; UNISTR2 *uni_name = NULL; DOM_SID pol_sid; @@ -1391,6 +1411,11 @@ uint32 _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP DEBUG(5,("_samr_lookup_rids: truncating entries to %d\n", num_rids)); } + if (num_rids) { + if ((group_attrs = (uint32 *)talloc(p->mem_ctx, num_rids * sizeof(uint32))) == NULL) + return NT_STATUS_NO_MEMORY; + } + r_u->status = NT_STATUS_NONE_MAPPED; for (i = 0; i < num_rids; i++) { @@ -1410,6 +1435,7 @@ uint32 _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP r_u->status = NT_STATUS_NOPROBLEMO; group_attrs[i] = (uint32)type; fstrcpy(group_names[i],tmpname); + DEBUG(5,("_samr_lookup_rids: %s:%d\n", group_names[i], group_attrs[i])); } } } @@ -1509,6 +1535,7 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) DEBUG(3,("User:[%s]\n", pdb_get_username(smbpass) )); + ZERO_STRUCTP(id10); init_sam_user_info10(id10, pdb_get_acct_ctrl(smbpass) ); samr_clear_sam_passwd(smbpass); @@ -1554,6 +1581,7 @@ static uint32 get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint32 return NT_STATUS_ACCOUNT_DISABLED; } + ZERO_STRUCTP(id12); init_sam_user_info12(id12, pdb_get_lanman_passwd(smbpass), pdb_get_nt_passwd(smbpass)); pdb_free_sam(smbpass); @@ -1561,6 +1589,44 @@ static uint32 get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint32 return NT_STATUS_NOPROBLEMO; } +/************************************************************************* + get_user_info_20 + *************************************************************************/ + +static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, uint32 user_rid) +{ + 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; + } + + pdb_init_sam(&sampass); + + become_root(); + ret = pdb_getsampwrid(sampass, user_rid); + unbecome_root(); + + 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", pdb_get_username(sampass) )); + + ZERO_STRUCTP(id20); + init_sam_user_info20A(id20, sampass); + + pdb_free_sam(sampass); + + return True; +} + /************************************************************************* get_user_info_21 *************************************************************************/ @@ -1591,6 +1657,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) DEBUG(3,("User:[%s]\n", pdb_get_username(sampass) )); + ZERO_STRUCTP(id21); init_sam_user_info21A(id21, sampass); pdb_free_sam(sampass); @@ -1654,6 +1721,7 @@ uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_ (*ctr-> info. id11)); + ZERO_STRUCTP(ctr->info.id11); init_sam_user_info11(ctr->info.id11, &expire, "BROOKFIELDS$", /* name */ 0x03ef, /* user rid */ @@ -1673,6 +1741,14 @@ uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_ return r_u->status; break; + case 20: + ctr->info.id20 = (SAM_USER_INFO_20 *)talloc(p->mem_ctx,sizeof(SAM_USER_INFO_20)); + if (ctr->info.id20 == NULL) + return NT_STATUS_NO_MEMORY; + if (!get_user_info_20(ctr->info.id20, rid)) + return NT_STATUS_NO_SUCH_USER; + break; + case 21: ctr->info.id21 = (SAM_USER_INFO_21 *)talloc(p->mem_ctx,sizeof(SAM_USER_INFO_21)); if (ctr->info.id21 == NULL) @@ -1775,6 +1851,9 @@ uint32 _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR case 0x03: init_unk_info3(&ctr->info.inf3); break; + case 0x05: + init_unk_info5(&ctr->info.inf5, global_myname); + break; case 0x06: init_unk_info6(&ctr->info.inf6); break; @@ -2819,8 +2898,55 @@ uint32 _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAMR_ uint32 _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, SAMR_R_DELETE_DOM_GROUP *r_u) { - DEBUG(0,("_samr_delete_dom_group: Not yet implemented.\n")); - return False; + DOM_SID group_sid; + DOM_SID dom_sid; + uint32 group_rid; + fstring group_sid_str; + gid_t gid; + struct group *grp; + GROUP_MAP map; + + DEBUG(5, ("samr_delete_dom_group: %d\n", __LINE__)); + + /* Find the policy handle. Open a policy on it. */ + if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid)) + return NT_STATUS_INVALID_HANDLE; + + sid_copy(&dom_sid, &group_sid); + sid_to_string(group_sid_str, &dom_sid); + sid_split_rid(&dom_sid, &group_rid); + + DEBUG(10, ("sid is %s\n", group_sid_str)); + + /* we check if it's our SID before deleting */ + if (!sid_equal(&dom_sid, &global_sam_sid)) + return NT_STATUS_NO_SUCH_GROUP; + + DEBUG(10, ("lookup on Domain SID\n")); + + if(!get_domain_group_from_sid(group_sid, &map)) + return NT_STATUS_NO_SUCH_ALIAS; + + gid=map.gid; + + /* check if group really exists */ + if ( (grp=getgrgid(gid)) == NULL) + return NT_STATUS_NO_SUCH_GROUP; + + /* we can delete the UNIX group */ + smb_delete_group(grp->gr_name); + + /* check if the group has been successfully deleted */ + if ( (grp=getgrgid(gid)) != NULL) + return NT_STATUS_ACCESS_DENIED; + + if(!group_map_remove(group_sid)) + return NT_STATUS_ACCESS_DENIED; + + if (!close_policy_hnd(p, &q_u->group_pol)) + return NT_STATUS_OBJECT_NAME_INVALID; + + return NT_STATUS_NOPROBLEMO; } /********************************************************************* @@ -2829,8 +2955,55 @@ uint32 _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, SAM uint32 _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, SAMR_R_DELETE_DOM_ALIAS *r_u) { - DEBUG(0,("_samr_delete_dom_alias: Not yet implemented.\n")); - return False; + DOM_SID alias_sid; + DOM_SID dom_sid; + uint32 alias_rid; + fstring alias_sid_str; + gid_t gid; + struct group *grp; + GROUP_MAP map; + + DEBUG(5, ("_samr_delete_dom_alias: %d\n", __LINE__)); + + /* Find the policy handle. Open a policy on it. */ + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid)) + return NT_STATUS_INVALID_HANDLE; + + sid_copy(&dom_sid, &alias_sid); + sid_to_string(alias_sid_str, &dom_sid); + sid_split_rid(&dom_sid, &alias_rid); + + DEBUG(10, ("sid is %s\n", alias_sid_str)); + + /* we check if it's our SID before deleting */ + if (!sid_equal(&dom_sid, &global_sam_sid)) + return NT_STATUS_NO_SUCH_ALIAS; + + DEBUG(10, ("lookup on Local SID\n")); + + if(!get_local_group_from_sid(alias_sid, &map)) + return NT_STATUS_NO_SUCH_ALIAS; + + gid=map.gid; + + /* check if group really exists */ + if ( (grp=getgrgid(gid)) == NULL) + return NT_STATUS_NO_SUCH_ALIAS; + + /* we can delete the UNIX group */ + smb_delete_group(grp->gr_name); + + /* check if the group has been successfully deleted */ + if ( (grp=getgrgid(gid)) != NULL) + return NT_STATUS_ACCESS_DENIED; + + /* don't check if we removed it as it could be an un-mapped group */ + group_map_remove(alias_sid); + + if (!close_policy_hnd(p, &q_u->alias_pol)) + return NT_STATUS_OBJECT_NAME_INVALID; + + return NT_STATUS_NOPROBLEMO; } /********************************************************************* -- cgit From 0a33cb45c1a30143d3587b102b0cde31158d7788 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 9 Jul 2001 18:32:54 +0000 Subject: implement: LSA_ENUM_PRIVS LSA_PRIV_GET_DISPNAME LSA_ENUM_ACCOUNTS LSA_OPENACCOUNT LSA_ENUMPRIVSACCOUNT LSA_GETSYSTEMACCOUNT It's a work in progress. nobody should expect it to work J.F. (This used to be commit 3056357cd8d4b2460f73ba8a8931a143f07fa2a6) --- source3/rpc_server/srv_lsa.c | 190 +++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_lsa_nt.c | 217 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 406 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 005398924e..9c934f5023 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -268,6 +268,96 @@ static BOOL api_lsa_open_secret(pipes_struct *p) return True; } +/*************************************************************************** + api_lsa_open_secret. + ***************************************************************************/ + +static BOOL api_lsa_enum_privs(pipes_struct *p) +{ + LSA_Q_ENUM_PRIVS q_u; + LSA_R_ENUM_PRIVS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_enum_privs("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_enum_privs: failed to unmarshall LSA_Q_ENUM_PRIVS.\n")); + return False; + } + + r_u.status = _lsa_enum_privs(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_enum_privs("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_enum_privs: Failed to marshall LSA_R_ENUM_PRIVS.\n")); + return False; + } + + return True; +} + +/*************************************************************************** + api_lsa_open_secret. + ***************************************************************************/ + +static BOOL api_lsa_priv_get_dispname(pipes_struct *p) +{ + LSA_Q_PRIV_GET_DISPNAME q_u; + LSA_R_PRIV_GET_DISPNAME r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_priv_get_dispname("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_priv_get_dispname: failed to unmarshall LSA_Q_PRIV_GET_DISPNAME.\n")); + return False; + } + + r_u.status = _lsa_priv_get_dispname(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_priv_get_dispname("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_priv_get_dispname: Failed to marshall LSA_R_PRIV_GET_DISPNAME.\n")); + return False; + } + + return True; +} + +/*************************************************************************** + api_lsa_open_secret. + ***************************************************************************/ + +static BOOL api_lsa_enum_accounts(pipes_struct *p) +{ + LSA_Q_ENUM_ACCOUNTS q_u; + LSA_R_ENUM_ACCOUNTS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_enum_accounts("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_enum_accounts: failed to unmarshall LSA_Q_ENUM_ACCOUNTS.\n")); + return False; + } + + r_u.status = _lsa_enum_accounts(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_enum_accounts("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_enum_accounts: Failed to marshall LSA_R_ENUM_ACCOUNTS.\n")); + return False; + } + + return True; +} + /*************************************************************************** api_lsa_UNK_GET_CONNUSER ***************************************************************************/ @@ -299,6 +389,100 @@ static BOOL api_lsa_unk_get_connuser(pipes_struct *p) return True; } +/*************************************************************************** + api_lsa_open_user + ***************************************************************************/ + +static BOOL api_lsa_open_account(pipes_struct *p) +{ + LSA_Q_OPENACCOUNT q_u; + LSA_R_OPENACCOUNT r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_open_account("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_open_account: failed to unmarshall LSA_Q_OPENACCOUNT.\n")); + return False; + } + + r_u.status = _lsa_open_account(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_open_account("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_open_account: Failed to marshall LSA_R_OPENACCOUNT.\n")); + return False; + } + + return True; +} + +/*************************************************************************** + api_lsa_get_privs + ***************************************************************************/ + +static BOOL api_lsa_enum_privsaccount(pipes_struct *p) +{ + LSA_Q_ENUMPRIVSACCOUNT q_u; + LSA_R_ENUMPRIVSACCOUNT r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_enum_privsaccount("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_enum_privsaccount: failed to unmarshall LSA_Q_ENUMPRIVSACCOUNT.\n")); + return False; + } + + r_u.status = _lsa_enum_privsaccount(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_enum_privsaccount("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_enum_privsaccount: Failed to marshall LSA_R_ENUMPRIVSACCOUNT.\n")); + return False; + } + + return True; +} + +/*************************************************************************** + api_lsa_getsystemaccount + ***************************************************************************/ + +static BOOL api_lsa_getsystemaccount(pipes_struct *p) +{ + LSA_Q_GETSYSTEMACCOUNT q_u; + LSA_R_GETSYSTEMACCOUNT r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_getsystemaccount("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_getsystemaccount: failed to unmarshall LSA_Q_GETSYSTEMACCOUNT.\n")); + return False; + } + + r_u.status = _lsa_getsystemaccount(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_getsystemaccount("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_getsystemaccount: Failed to marshall LSA_R_GETSYSTEMACCOUNT.\n")); + return False; + } + + return True; +} + + /*************************************************************************** \PIPE\ntlsa commands ***************************************************************************/ @@ -313,7 +497,13 @@ static struct api_struct api_lsa_cmds[] = { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret }, { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids }, { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names }, + { "LSA_ENUM_PRIVS" , LSA_ENUM_PRIVS , api_lsa_enum_privs }, + { "LSA_PRIV_GET_DISPNAME",LSA_PRIV_GET_DISPNAME,api_lsa_priv_get_dispname}, + { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS , api_lsa_enum_accounts }, { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser}, + { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT , api_lsa_open_account }, + { "LSA_ENUMPRIVSACCOUNT", LSA_ENUMPRIVSACCOUNT, api_lsa_enum_privsaccount}, + { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT, api_lsa_getsystemaccount}, { NULL , 0 , NULL } }; diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index cd97dfc6d1..85bab7d4b0 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -30,6 +30,23 @@ extern int DEBUGLEVEL; extern DOM_SID global_sam_sid; extern fstring global_myworkgroup; extern pstring global_myname; +extern PRIVS privs[]; + +struct lsa_info { + DOM_SID sid; + uint32 access; +}; + +/******************************************************************* + Function to free the per handle data. + ********************************************************************/ + +static void free_lsa_info(void *ptr) +{ + struct lsa_info *lsa = (struct lsa_info *)ptr; + + safe_free(lsa); +} /*************************************************************************** Init dom_query @@ -128,7 +145,7 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, /* Split name into domain and user component */ - rpcstr_pull(full_name, &name[i], sizeof(full_name), -1, 0); + unistr2_to_ascii(full_name, &name[i], sizeof(full_name)); split_domain_name(full_name, dom_name, user); /* Lookup name */ @@ -511,6 +528,116 @@ uint32 _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SECR return NT_STATUS_OBJECT_NAME_NOT_FOUND; } +/*************************************************************************** +_lsa_enum_privs. + ***************************************************************************/ + +uint32 _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIVS *r_u) +{ + uint32 i; + + uint32 enum_context=q_u->enum_context; + LSA_PRIV_ENTRY *entry; + LSA_PRIV_ENTRY *entries; + + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + return NT_STATUS_INVALID_HANDLE; + + if (enum_context >= PRIV_ALL_INDEX) + return 0x8000001A; + + entries = (LSA_PRIV_ENTRY *)talloc_zero(p->mem_ctx, sizeof(LSA_PRIV_ENTRY) * (PRIV_ALL_INDEX-enum_context)); + if (entries==NULL) + return NT_STATUS_NO_MEMORY; + + entry = entries; + for (i = 0; i < PRIV_ALL_INDEX-enum_context; i++, entry++) { + init_uni_hdr(&entry->hdr_name, strlen(privs[i+1-enum_context].priv)); + init_unistr2(&entry->name, privs[i+1-enum_context].priv, strlen(privs[i+1-enum_context].priv) ); + entry->luid_low = privs[i+1-enum_context].se_priv; + entry->luid_high = 1; + } + + init_lsa_r_enum_privs(r_u, i+enum_context, PRIV_ALL_INDEX-enum_context, entries); + + return NT_STATUS_NO_PROBLEMO; +} + +/*************************************************************************** +_lsa_priv_get_dispname. + ***************************************************************************/ + +uint32 _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, LSA_R_PRIV_GET_DISPNAME *r_u) +{ + fstring name_asc; + fstring desc_asc; + int i; + + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + return NT_STATUS_INVALID_HANDLE; + + unistr2_to_ascii(name_asc, &q_u->name, sizeof(name_asc)); + + DEBUG(0,("_lsa_priv_get_dispname: %s", name_asc)); + + for (i=1; privs[i].se_priv!=SE_PRIV_ALL; i++) { + if ( strcmp(name_asc, privs[i].priv)) { + + fstrcpy(desc_asc, privs[i].description); + + } + } + DEBUG(0,(": %s\n", desc_asc)); + + init_uni_hdr(&r_u->hdr_desc, strlen(desc_asc)); + init_unistr2(&r_u->desc, desc_asc, strlen(desc_asc) ); + + r_u->ptr_info=0xdeadbeef; + r_u->lang_id=q_u->lang_id; + + return NT_STATUS_NO_PROBLEMO; +} + +/*************************************************************************** +_lsa_enum_accounts. + ***************************************************************************/ + +uint32 _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENUM_ACCOUNTS *r_u) +{ + GROUP_MAP *map=NULL; + int num_entries=0; + LSA_SID_ENUM *sids=&r_u->sids; + int i=0,j=0; + + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + return NT_STATUS_INVALID_HANDLE; + + /* get the list of mapped groups (domain, local, builtin) */ + if(!enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED)) + return NT_STATUS_NOPROBLEMO; + + sids->ptr_sid = (uint32 *)talloc_zero(p->mem_ctx, (num_entries-q_u->enum_context)*sizeof(uint32)); + sids->sid = (DOM_SID2 *)talloc_zero(p->mem_ctx, (num_entries-q_u->enum_context)*sizeof(DOM_SID2)); + + if (sids->ptr_sid==NULL || sids->sid==NULL) { + safe_free(map); + return NT_STATUS_NO_MEMORY; + } + + for (i=q_u->enum_context, j=0; istatus; } + +/*************************************************************************** + + ***************************************************************************/ + +uint32 _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENACCOUNT *r_u) +{ + struct lsa_info *info; + + r_u->status = NT_STATUS_NOPROBLEMO; + + /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + return NT_STATUS_INVALID_HANDLE; + + /* associate the user/group SID with the (unique) handle. */ + if ((info = (struct lsa_info *)malloc(sizeof(struct lsa_info))) == NULL) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(info); + info->sid = q_u->sid.sid; + info->access = q_u->access; + + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + return r_u->status; +} + +/*************************************************************************** + + ***************************************************************************/ + +uint32 _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_R_ENUMPRIVSACCOUNT *r_u) +{ + struct lsa_info *info=NULL; + GROUP_MAP map; + int num_entries=0; + uint32 count=0; + int i=0; + + LUID_ATTR *set=NULL; + + r_u->status = NT_STATUS_NOPROBLEMO; + + /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; + + if (!get_group_map_from_sid(info->sid, &map)) + return NT_STATUS_NO_SUCH_GROUP; + + for (i=1; privs[i].se_priv!=SE_PRIV_ALL; i++) { + if ( (map.privilege & privs[i].se_priv) == privs[i].se_priv) { + + set=(LUID_ATTR *)talloc_realloc(p->mem_ctx, set, (count+1)*sizeof(LUID_ATTR)); + + set[count].luid.low=privs[i].se_priv; + set[count].luid.high=1; + set[count].attr=0; + + count++; + + } + } + + init_lsa_r_enum_privsaccount(r_u, set, count, 0); + + return r_u->status; +} + +/*************************************************************************** + + ***************************************************************************/ + +uint32 _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA_R_GETSYSTEMACCOUNT *r_u) +{ + r_u->status = NT_STATUS_NOPROBLEMO; + + /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + return NT_STATUS_INVALID_HANDLE; + + r_u->access=3; + + return r_u->status; +} -- cgit From 5f4a1aa3c33642c49a9f522c514e48bf40c18ff4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 12 Jul 2001 22:19:39 +0000 Subject: Removed unused variable. (This used to be commit 914e78f05356c66665ede6948ec18814c2c2c503) --- source3/rpc_server/srv_lsa_nt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 85bab7d4b0..fe4340edec 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -705,7 +705,6 @@ uint32 _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_ { struct lsa_info *info=NULL; GROUP_MAP map; - int num_entries=0; uint32 count=0; int i=0; -- cgit From 3015fde98080ae0a1c4a4a68df552655a059742e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 17 Jul 2001 02:26:04 +0000 Subject: Fix usermanager for domains - we were returning no memory when we should have been returning empty space at end of enumeration. Jeremy. (This used to be commit 175c6406925cbd798c3aa049912ab63802f44de4) --- source3/rpc_server/srv_samr_nt.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 95caa1dda8..b808d4c9d6 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1097,39 +1097,51 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ if (!(ctr = (SAM_DISPINFO_CTR *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_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,sizeof(SAM_DISPINFO_1)))) - return NT_STATUS_NO_MEMORY; + if (num_entries) { + if (!(ctr->sam.info1 = (SAM_DISPINFO_1 *)talloc(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) return disp_ret; break; case 0x2: - if (!(ctr->sam.info2 = (SAM_DISPINFO_2 *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_2)))) - return NT_STATUS_NO_MEMORY; + if (num_entries) { + if (!(ctr->sam.info2 = (SAM_DISPINFO_2 *)talloc(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) return disp_ret; break; case 0x3: - if (!(ctr->sam.info3 = (SAM_DISPINFO_3 *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_3)))) - return NT_STATUS_NO_MEMORY; + if (num_entries) { + if (!(ctr->sam.info3 = (SAM_DISPINFO_3 *)talloc(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) return disp_ret; break; case 0x4: - if (!(ctr->sam.info4 = (SAM_DISPINFO_4 *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_4)))) - return NT_STATUS_NO_MEMORY; + if (num_entries) { + if (!(ctr->sam.info4 = (SAM_DISPINFO_4 *)talloc(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) return disp_ret; break; case 0x5: - if (!(ctr->sam.info5 = (SAM_DISPINFO_5 *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_5)))) - return NT_STATUS_NO_MEMORY; + if (num_entries) { + if (!(ctr->sam.info5 = (SAM_DISPINFO_5 *)talloc(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) return disp_ret; -- cgit From cdcf646c65f479ff25644cf1844c36ff76a24f3a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 19 Jul 2001 07:44:59 +0000 Subject: #ifdef'ed out some unused functions. (This used to be commit ab5ccce2edd6118db0389701ff9e325ee1f818c7) --- source3/rpc_server/srv_samr_nt.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b808d4c9d6..680f5affc8 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -234,6 +234,8 @@ static uint32 jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, return NT_STATUS_NO_PROBLEMO; } +#if 0 /* This function appears to be unused! */ + /******************************************************************* 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 @@ -313,6 +315,10 @@ static char *unmap_unixname(char *unix_user_name, int name_idx) return NULL; } +#endif /* Unused function */ + +#if 0 /* This function seems to be not used anywhere! */ + /******************************************************************* This function sets up a list of users taken from the list of users that UNIX knows about, as well as all the user names that @@ -481,6 +487,8 @@ done: return (*num_entries) > 0; } +#endif /* Unused function */ + /******************************************************************* _samr_close_hnd ********************************************************************/ -- cgit From a9ab7eaa5d023f0f6c2421f504f81988fd41467b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 23 Jul 2001 22:06:05 +0000 Subject: Fix case insensitive password change code. Fixed crash bug with un-zeroed talloced memory. Jeremy. (This used to be commit eea1c30df246e081e672d7132345d0fd35ad9841) --- source3/rpc_server/srv_samr_nt.c | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 680f5affc8..2e8338c530 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -673,9 +673,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")); @@ -763,9 +763,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")); @@ -809,7 +809,7 @@ static BOOL get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID enum_group_mapping(SID_NAME_WKN_GRP, &map, &num_entries, ENUM_ALL_MAPPED); - *d_grp=(DOMAIN_GRP *)talloc(ctx, num_entries*sizeof(DOMAIN_GRP)); + *d_grp=(DOMAIN_GRP *)talloc_zero(ctx, num_entries*sizeof(DOMAIN_GRP)); if (*d_grp==NULL) return NT_STATUS_NO_MEMORY; @@ -928,7 +928,7 @@ static uint32 get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_ num_entries=max_entries; } - *d_grp=(DOMAIN_GRP *)talloc(ctx, num_entries*sizeof(DOMAIN_GRP)); + *d_grp=(DOMAIN_GRP *)talloc_zero(ctx, num_entries*sizeof(DOMAIN_GRP)); if (num_entries!=0 && *d_grp==NULL){ safe_free(map); return NT_STATUS_NO_MEMORY; @@ -1102,7 +1102,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ data_size = q_u->max_size; - if (!(ctr = (SAM_DISPINFO_CTR *)talloc(p->mem_ctx,sizeof(SAM_DISPINFO_CTR)))) + if (!(ctr = (SAM_DISPINFO_CTR *)talloc_zero(p->mem_ctx,sizeof(SAM_DISPINFO_CTR)))) return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(ctr); @@ -1111,7 +1111,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ switch (q_u->switch_level) { case 0x1: if (num_entries) { - if (!(ctr->sam.info1 = (SAM_DISPINFO_1 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_1)))) + 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); @@ -1120,7 +1120,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ break; case 0x2: if (num_entries) { - if (!(ctr->sam.info2 = (SAM_DISPINFO_2 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_2)))) + 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); @@ -1129,7 +1129,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ break; case 0x3: if (num_entries) { - if (!(ctr->sam.info3 = (SAM_DISPINFO_3 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_3)))) + 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); @@ -1138,7 +1138,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ break; case 0x4: if (num_entries) { - if (!(ctr->sam.info4 = (SAM_DISPINFO_4 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_4)))) + 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); @@ -1147,7 +1147,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ break; case 0x5: if (num_entries) { - if (!(ctr->sam.info5 = (SAM_DISPINFO_5 *)talloc(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_5)))) + 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); @@ -1382,11 +1382,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; } @@ -1432,7 +1432,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; } @@ -1707,7 +1707,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; @@ -1718,7 +1718,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; @@ -1736,7 +1736,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. @@ -1753,7 +1753,7 @@ 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; @@ -1762,7 +1762,7 @@ uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_ break; case 20: - ctr->info.id20 = (SAM_USER_INFO_20 *)talloc(p->mem_ctx,sizeof(SAM_USER_INFO_20)); + ctr->info.id20 = (SAM_USER_INFO_20 *)talloc_zero(p->mem_ctx,sizeof(SAM_USER_INFO_20)); if (ctr->info.id20 == NULL) return NT_STATUS_NO_MEMORY; if (!get_user_info_20(ctr->info.id20, rid)) @@ -1770,7 +1770,7 @@ uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_ 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)) @@ -1847,7 +1847,7 @@ 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); @@ -2115,8 +2115,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; @@ -2625,7 +2625,7 @@ uint32 _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, S int num_rids; num_rids = 1; - rid=(uint32 *)talloc(p->mem_ctx, num_rids*sizeof(uint32)); + rid=(uint32 *)talloc_zero(p->mem_ctx, num_rids*sizeof(uint32)); if (rid==NULL) return NT_STATUS_NO_MEMORY; @@ -2685,7 +2685,7 @@ uint32 _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_ return NT_STATUS_NO_SUCH_ALIAS; DEBUG(10, ("sid is %s\n", alias_sid_str)); - sid = (DOM_SID2 *)talloc(p->mem_ctx, sizeof(DOM_SID2) * num_uids); + sid = (DOM_SID2 *)talloc_zero(p->mem_ctx, sizeof(DOM_SID2) * num_uids); if (num_uids!=0 && sid == NULL) return NT_STATUS_NO_MEMORY; @@ -2744,8 +2744,8 @@ uint32 _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_ if(!get_uid_list_of_group(map.gid, &uid, &num_uids)) return NT_STATUS_NO_SUCH_GROUP; - rid=talloc(p->mem_ctx, sizeof(uint32)*num_uids); - attr=talloc(p->mem_ctx, sizeof(uint32)*num_uids); + rid=talloc_zero(p->mem_ctx, sizeof(uint32)*num_uids); + attr=talloc_zero(p->mem_ctx, sizeof(uint32)*num_uids); if (num_uids!=0 && (rid==NULL || attr==NULL)) return NT_STATUS_NO_MEMORY; @@ -3160,7 +3160,7 @@ uint32 _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAMR_ if (!get_domain_group_from_sid(group_sid, &map)) return NT_STATUS_INVALID_HANDLE; - ctr=(GROUP_INFO_CTR *)talloc(p->mem_ctx, sizeof(GROUP_INFO_CTR)); + ctr=(GROUP_INFO_CTR *)talloc_zero(p->mem_ctx, sizeof(GROUP_INFO_CTR)); if (ctr==NULL) return NT_STATUS_NO_MEMORY; -- cgit From 648528196ca136469d82b83cd2ba89b1b30290ae Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 25 Jul 2001 06:42:05 +0000 Subject: Held a shoot-out between NT_STATUS_NO_PROBLEMO and NT_STATUS_NOPROBLEMO. According to the incorruptible judges find and grep, the latter won. Mmm - procrastination. (-: (This used to be commit 2e339403605177b15d5185a8fdd1b06f3f043168) --- source3/rpc_server/srv_lsa_nt.c | 20 +++--- source3/rpc_server/srv_samr_nt.c | 60 +++++++++--------- source3/rpc_server/srv_spoolss.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 122 ++++++++++++++++++------------------ 4 files changed, 102 insertions(+), 102 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index fe4340edec..a6e45ec03a 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -193,7 +193,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_NOPROBLEMO; } /*************************************************************************** @@ -288,7 +288,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_NOPROBLEMO; } /*************************************************************************** @@ -336,7 +336,7 @@ uint32 _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_ENU /* 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); + dom_name != NULL ? NT_STATUS_NOPROBLEMO : NT_STATUS_UNABLE_TO_FREE_VM); return r_u->status; } @@ -352,7 +352,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_NOPROBLEMO; if (!find_policy_by_hnd(p, &q_u->pol, NULL)) return NT_STATUS_INVALID_HANDLE; @@ -442,7 +442,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_NOPROBLEMO) { r_u->undoc_buffer = 0x22000000; /* bizarre */ r_u->info_class = q_u->info_class; } @@ -516,7 +516,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_NOPROBLEMO; } /*************************************************************************** @@ -560,7 +560,7 @@ uint32 _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIVS init_lsa_r_enum_privs(r_u, i+enum_context, PRIV_ALL_INDEX-enum_context, entries); - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /*************************************************************************** @@ -595,7 +595,7 @@ uint32 _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, LSA r_u->ptr_info=0xdeadbeef; r_u->lang_id=q_u->lang_id; - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /*************************************************************************** @@ -634,7 +634,7 @@ uint32 _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENUM_ init_lsa_r_enum_accounts(r_u, j); - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } @@ -663,7 +663,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_NOPROBLEMO; return r_u->status; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2e8338c530..a4754beb52 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -151,7 +151,7 @@ static uint32 get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, if (not_finished) return STATUS_MORE_ENTRIES; else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } static uint32 jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, @@ -231,7 +231,7 @@ static uint32 jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, if (not_finished) return STATUS_MORE_ENTRIES; else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } #if 0 /* This function appears to be unused! */ @@ -901,7 +901,7 @@ static BOOL get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID DEBUG(10,("get_group_alias_entries: returning %d entries\n", *p_num_entries)); - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /******************************************************************* @@ -945,7 +945,7 @@ static uint32 get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_ *p_num_entries = num_entries; - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /******************************************************************* @@ -999,7 +999,7 @@ 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(p->mem_ctx, &grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES)!=NT_STATUS_NO_PROBLEMO) + if (get_group_alias_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES)!=NT_STATUS_NOPROBLEMO) return NT_STATUS_ACCESS_DENIED; make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp); @@ -1071,7 +1071,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_NOPROBLEMO) { DEBUG(5, ("get_sampwd_entries: failed\n")); return r_u->status; } @@ -1079,7 +1079,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(p->mem_ctx, &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_NOPROBLEMO) return NT_STATUS_ACCESS_DENIED; break; default: @@ -1115,7 +1115,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ 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_NOPROBLEMO) return disp_ret; break; case 0x2: @@ -1124,7 +1124,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ 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_NOPROBLEMO) return disp_ret; break; case 0x3: @@ -1133,7 +1133,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ 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_NOPROBLEMO) return disp_ret; break; case 0x4: @@ -1142,7 +1142,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ 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_NOPROBLEMO) return disp_ret; break; case 0x5: @@ -1151,7 +1151,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ 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_NOPROBLEMO) return disp_ret; break; default: @@ -1484,7 +1484,7 @@ uint32 _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_U struct samr_info *info = NULL; BOOL ret; - r_u->status = NT_STATUS_NO_PROBLEMO; + r_u->status = NT_STATUS_NOPROBLEMO; /* find the domain policy handle. */ if (!find_policy_by_hnd(p, &domain_pol, NULL)) @@ -1695,7 +1695,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_NOPROBLEMO; /* search for the handle */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) @@ -1802,7 +1802,7 @@ uint32 _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAM struct samr_info *info = NULL; BOOL ret; - r_u->status = NT_STATUS_NO_PROBLEMO; + r_u->status = NT_STATUS_NOPROBLEMO; DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__)); @@ -1852,7 +1852,7 @@ uint32 _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR ZERO_STRUCTP(ctr); - r_u->status = NT_STATUS_NO_PROBLEMO; + r_u->status = NT_STATUS_NOPROBLEMO; DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); @@ -2021,7 +2021,7 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR pdb_free_sam(sam_pass); - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /******************************************************************* @@ -2034,7 +2034,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_NOPROBLEMO; /* associate the user's SID with the new handle. */ if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) @@ -2060,7 +2060,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_NOPROBLEMO; /* associate the user's SID with the new handle. */ if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) @@ -2084,7 +2084,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_NOPROBLEMO; if (!find_policy_by_hnd(p, &q_u->connect_pol, NULL)) return NT_STATUS_INVALID_HANDLE; @@ -2143,7 +2143,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_NOPROBLEMO; fstrcpy(dom[0],global_myworkgroup); fstrcpy(dom[1],"Builtin"); @@ -2168,7 +2168,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_NOPROBLEMO; /* get the domain policy. */ if (!find_policy_by_hnd(p, &domain_pol, NULL)) @@ -2633,9 +2633,9 @@ uint32 _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, S rid[0] = BUILTIN_ALIAS_RID_USERS; - init_samr_r_query_useraliases(r_u, num_rids, rid, NT_STATUS_NO_PROBLEMO); + init_samr_r_query_useraliases(r_u, num_rids, rid, NT_STATUS_NOPROBLEMO); - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } @@ -2697,7 +2697,7 @@ uint32 _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_ } DEBUG(10, ("sid is %s\n", alias_sid_str)); - init_samr_r_query_aliasmem(r_u, num_uids, sid, NT_STATUS_NO_PROBLEMO); + init_samr_r_query_aliasmem(r_u, num_uids, sid, NT_STATUS_NOPROBLEMO); return NT_STATUS_NOPROBLEMO; } @@ -3180,9 +3180,9 @@ uint32 _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAMR_ return NT_STATUS_INVALID_INFO_CLASS; } - init_samr_r_query_groupinfo(r_u, ctr, NT_STATUS_NO_PROBLEMO); + init_samr_r_query_groupinfo(r_u, ctr, NT_STATUS_NOPROBLEMO); - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /********************************************************************* @@ -3219,7 +3219,7 @@ uint32 _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_SE if(!add_mapping_entry(&map, TDB_REPLACE)) return NT_STATUS_NO_SUCH_GROUP; - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /********************************************************************* @@ -3253,7 +3253,7 @@ uint32 _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_SE if(!add_mapping_entry(&map, TDB_REPLACE)) return NT_STATUS_NO_SUCH_GROUP; - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /********************************************************************* @@ -3303,7 +3303,7 @@ uint32 _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_GRO if (!create_policy_hnd(p, &r_u->pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /********************************************************************* diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 63bbc5f87b..3500a4f3e1 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/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_NOPROBLEMO; 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/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 79c788e67b..d93f320e2f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -705,7 +705,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 = NT_STATUS_NOPROBLEMO; #endif UNISTR2 *printername = NULL; @@ -775,7 +775,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 NT_STATUS_NOPROBLEMO; } else if ((printer_default->access_required & SERVER_ACCESS_ADMINISTER ) == SERVER_ACCESS_ADMINISTER) { @@ -787,7 +787,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, return ERROR_ACCESS_DENIED; } else if (user.uid == 0 || user_in_list(uidtoname(user.uid), lp_printer_admin(snum))) { - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } else { close_printer_handle(p, handle); @@ -889,7 +889,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, #endif } - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -1035,7 +1035,7 @@ uint32 _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL_R if (!close_printer_handle(p, handle)) return ERROR_INVALID_HANDLE; - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /******************************************************************** @@ -1336,7 +1336,7 @@ uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO if (*needed > *out_size) return ERROR_MORE_DATA; else { - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } } @@ -1417,7 +1417,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 NT_STATUS_NOPROBLEMO; } /******************************************************************* @@ -2361,7 +2361,7 @@ static uint32 printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, } */ - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /******************************************************************* @@ -2444,7 +2444,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 NT_STATUS_NOPROBLEMO; } /******************************************************************** @@ -2913,7 +2913,7 @@ static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 of return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /******************************************************************** @@ -2995,7 +2995,7 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /******************************************************************** @@ -3064,7 +3064,7 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /******************************************************************** @@ -3088,7 +3088,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 NT_STATUS_NOPROBLEMO; /* NT4sp5 does that */ } /******************************************************************** @@ -3120,7 +3120,7 @@ static uint32 enumprinters_level2( uint32 flags, fstring servername, if (flags & PRINTER_ENUM_REMOTE) return ERROR_INVALID_LEVEL; - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /******************************************************************** @@ -3131,7 +3131,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 NT_STATUS_NOPROBLEMO; } /******************************************************************** @@ -3220,7 +3220,7 @@ static uint32 getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, u return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -3252,7 +3252,7 @@ static uint32 getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, u return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -3287,7 +3287,7 @@ static uint32 getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, u return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -3317,7 +3317,7 @@ static uint32 getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, u return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -3384,7 +3384,7 @@ static uint32 construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fst free_a_printer(&printer,2); - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /******************************************************************** @@ -3442,7 +3442,7 @@ static uint32 construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fst free_a_printer(&printer,2); - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /******************************************************************** @@ -3558,7 +3558,7 @@ static uint32 construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst free_a_printer(&printer,2); - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /******************************************************************** @@ -3667,7 +3667,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 NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -3698,7 +3698,7 @@ static uint32 getprinterdriver2_level1(fstring servername, fstring architecture, return ERROR_NOT_ENOUGH_MEMORY; status=construct_printer_driver_info_1(info, snum, servername, architecture, version); - if (status != NT_STATUS_NO_PROBLEMO) { + if (status != NT_STATUS_NOPROBLEMO) { safe_free(info); return status; } @@ -3720,7 +3720,7 @@ static uint32 getprinterdriver2_level1(fstring servername, fstring architecture, if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -3734,7 +3734,7 @@ static uint32 getprinterdriver2_level2(fstring servername, fstring architecture, return ERROR_NOT_ENOUGH_MEMORY; status=construct_printer_driver_info_2(info, snum, servername, architecture, version); - if (status != NT_STATUS_NO_PROBLEMO) { + if (status != NT_STATUS_NOPROBLEMO) { safe_free(info); return status; } @@ -3756,7 +3756,7 @@ static uint32 getprinterdriver2_level2(fstring servername, fstring architecture, if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -3769,7 +3769,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 != NT_STATUS_NOPROBLEMO) { return status; } @@ -3789,7 +3789,7 @@ static uint32 getprinterdriver2_level3(fstring servername, fstring architecture, if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -3802,7 +3802,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 != NT_STATUS_NOPROBLEMO) { return status; } @@ -3822,7 +3822,7 @@ static uint32 getprinterdriver2_level6(fstring servername, fstring architecture, if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -3909,7 +3909,7 @@ uint32 _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPO Printer->page_started=False; - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /******************************************************************** @@ -4146,7 +4146,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 = NT_STATUS_NOPROBLEMO; goto done; } @@ -4504,7 +4504,7 @@ static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, DEBUG(8,("update_printer\n")); - result = NT_STATUS_NO_PROBLEMO; + result = NT_STATUS_NOPROBLEMO; if (level!=2) { DEBUG(0,("Send a mail to samba@samba.org\n")); @@ -4564,7 +4564,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 = NT_STATUS_NOPROBLEMO; goto done; } @@ -4660,7 +4660,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 NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -4798,7 +4798,7 @@ static uint32 enumjobs_level1(print_queue_struct *queue, int snum, return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -4853,7 +4853,7 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum, return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -4894,7 +4894,7 @@ uint32 _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO if (*returned == 0) { safe_free(queue); - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } switch (level) { @@ -5041,7 +5041,7 @@ static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -5117,7 +5117,7 @@ static uint32 enumprinterdrivers_level2(fstring servername, fstring architecture return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -5196,7 +5196,7 @@ static uint32 enumprinterdrivers_level3(fstring servername, fstring architecture return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -5348,7 +5348,7 @@ uint32 _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; default: safe_free(list); @@ -5436,7 +5436,7 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * 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 NT_STATUS_NOPROBLEMO; default: safe_free(list); @@ -5548,7 +5548,7 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -5647,7 +5647,7 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -5750,7 +5750,7 @@ static uint32 spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ srv_spoolss_sendnotify(p, handle); - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -5792,7 +5792,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 = NT_STATUS_NOPROBLEMO; NT_PRINTER_DRIVER_INFO_LEVEL driver; struct current_user user; @@ -5803,7 +5803,7 @@ 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)) != NT_STATUS_NOPROBLEMO ) goto done; DEBUG(5,("Moving driver to final destination\n")); @@ -5867,7 +5867,7 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -6015,7 +6015,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 NT_STATUS_NOPROBLEMO; } /* @@ -6062,7 +6062,7 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S safe_free(data); - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -6114,7 +6114,7 @@ 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 = NT_STATUS_NOPROBLEMO; goto done; } } @@ -6321,7 +6321,7 @@ static uint32 enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -6389,7 +6389,7 @@ static uint32 enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -6451,7 +6451,7 @@ static uint32 enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -6484,7 +6484,7 @@ static uint32 enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint return ERROR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** @@ -6549,7 +6549,7 @@ static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uin safe_free(queue); safe_free(info_1); /* I shoud reply something else ... I can't find the good one */ - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } fill_job_info_1(info_1, &(queue[i-1]), i, snum); @@ -6570,7 +6570,7 @@ static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uin if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } @@ -6601,7 +6601,7 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin safe_free(queue); safe_free(info_2); /* I shoud reply something else ... I can't find the good one */ - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0) { @@ -6629,7 +6629,7 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin if (*needed > offered) return ERROR_INSUFFICIENT_BUFFER; else - return NT_STATUS_NO_PROBLEMO; + return NT_STATUS_NOPROBLEMO; } /**************************************************************************** -- cgit From 996719cce26700c68ff0e456e6a25d20085d091f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 30 Jul 2001 22:21:31 +0000 Subject: Added "use mmap" for HPUX. Jeremy. (This used to be commit 840802f10677cb0009cb4df4c37c7d01aa5edacd) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 78d9429b43..913b04bca3 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -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, USE_TDB_MMAP_FLAG, 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) )); -- cgit From 986372901e85a79343ba32f590a4a3e7658d2565 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 3 Aug 2001 13:09:23 +0000 Subject: This is my 'Authentication Rewrite' version 1.01, mostly as submitted to samba-technical a few weeks ago. The idea here is to standardize the checking of user names and passwords, thereby ensuring that all authtentications pass the same standards. The interface currently implemented in as nt_status = check_password(user_info, server_info) where user_info contains (mostly) the authentication data, and server_info contains things like the user-id they got, and their resolved user name. The current ugliness with the way the structures are created will be killed the next revision, when they will be created and malloced by creator functions. This patch also includes the first implementation of NTLMv2 in HEAD, but which needs some more testing. We also add a hack to allow plaintext passwords to be compared with smbpasswd, not the system password database. Finally, this patch probably reintroduces the PAM accounts bug we had in 2.2.0, I'll fix that once this hits the tree. (I've just finished testing it on a wide variety of platforms, so I want to get this patch in). (This used to be commit b30b6202f31d339b48d51c0d38174cafd1cfcd42) --- source3/rpc_server/srv_netlog_nt.c | 225 +++++++++++++++++++++---------------- source3/rpc_server/srv_pipe.c | 18 ++- 2 files changed, 140 insertions(+), 103 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 14f3e1d211..385fec5862 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -441,97 +441,138 @@ uint32 _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF } /************************************************************************* - net_login_interactive: + _net_logon_any: Use the new authentications subsystem to log in. *************************************************************************/ -static uint32 net_login_interactive(NET_ID_INFO_1 *id1, SAM_ACCOUNT *sampass, pipes_struct *p) +static uint32 _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, char *sess_key) { - uint32 status = 0x0; - char nt_pwd[16]; - char lm_pwd[16]; - unsigned char key[16]; + uint32 nt_status = NT_STATUS_LOGON_FAILURE; - memset(key, 0, 16); - memcpy(key, p->dc.sess_key, 8); + unsigned char local_lm_response[24]; + unsigned char local_nt_response[24]; - memcpy(lm_pwd, id1->lm_owf.data, 16); - memcpy(nt_pwd, id1->nt_owf.data, 16); + auth_usersupplied_info user_info; + auth_serversupplied_info server_info; + AUTH_STR ourdomain, theirdomain, smb_username, wksta_name; -#ifdef DEBUG_PASSWORD - DEBUG(100,("key:")); - dump_data(100, (char *)key, 16); + DEBUG(5, ("_net_logon_any: entered with user %s and domain %s\n", user, domain)); + + ZERO_STRUCT(user_info); + ZERO_STRUCT(server_info); + ZERO_STRUCT(ourdomain); + ZERO_STRUCT(theirdomain); + ZERO_STRUCT(smb_username); + ZERO_STRUCT(wksta_name); + + ourdomain.str = lp_workgroup(); + ourdomain.len = strlen(ourdomain.str); - DEBUG(100,("lm owf password:")); - dump_data(100, lm_pwd, 16); + theirdomain.str = domain; + theirdomain.len = strlen(theirdomain.str); - DEBUG(100,("nt owf password:")); - dump_data(100, nt_pwd, 16); -#endif + user_info.requested_domain = theirdomain; + user_info.domain = ourdomain; + + smb_username.str = user; + smb_username.len = strlen(smb_username.str); - SamOEMhash((uchar *)lm_pwd, key, 16); - SamOEMhash((uchar *)nt_pwd, key, 16); + user_info.requested_username = smb_username; /* For the time-being */ + user_info.smb_username = smb_username; -#ifdef DEBUG_PASSWORD - DEBUG(100,("decrypt of lm owf password:")); - dump_data(100, lm_pwd, 16); +#if 0 + user_info.wksta_name.str = cleint_name(); + user_info.wksta_name.len = strlen(client_name()); - DEBUG(100,("decrypt of nt owf password:")); - dump_data(100, nt_pwd, 16); + user_info.wksta_name = wksta_name; #endif - if (memcmp(pdb_get_lanman_passwd(sampass), lm_pwd, 16) != 0 || - memcmp(pdb_get_nt_passwd(sampass), nt_pwd, 16) != 0) { - status = NT_STATUS_WRONG_PASSWORD; - } - - return status; -} - -/************************************************************************* - _net_login_network: - *************************************************************************/ - -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)); - - /* JRA. Check the NT password first if it exists - this is a higher quality - password, if it exists and it doesn't match - fail. */ + DEBUG(10,("_net_logon_any: Attempting validation level %d.\n", ctr->switch_value)); + switch (ctr->switch_value) { + case NET_LOGON_TYPE: + user_info.lm_resp.buffer = (uint8 *)ctr->auth.id2.lm_chal_resp.buffer; + user_info.lm_resp.len = ctr->auth.id2.lm_chal_resp.str_str_len; + user_info.nt_resp.buffer = (uint8 *)ctr->auth.id2.nt_chal_resp.buffer; + user_info.nt_resp.len = ctr->auth.id2.nt_chal_resp.str_str_len; + memcpy(user_info.chal, ctr->auth.id2.lm_chal, 8); + break; + case INTERACTIVE_LOGON_TYPE: + { + char nt_pwd[16]; + char lm_pwd[16]; + unsigned char key[16]; + + memset(key, 0, 16); + memcpy(key, sess_key, 8); + + memcpy(lm_pwd, ctr->auth.id1.lm_owf.data, 16); + memcpy(nt_pwd, ctr->auth.id1.nt_owf.data, 16); - nt_pwd = pdb_get_nt_passwd(sampass); - lanman_pwd = pdb_get_lanman_passwd(sampass); +#ifdef DEBUG_PASSWORD + DEBUG(100,("key:")); + dump_data(100, (char *)key, 16); + + DEBUG(100,("lm owf password:")); + dump_data(100, lm_pwd, 16); + + DEBUG(100,("nt owf password:")); + dump_data(100, nt_pwd, 16); +#endif + + SamOEMhash((uchar *)lm_pwd, key, 16); + SamOEMhash((uchar *)nt_pwd, key, 16); + +#ifdef DEBUG_PASSWORD + DEBUG(100,("decrypt of lm owf password:")); + dump_data(100, lm_pwd, 16); + + DEBUG(100,("decrypt of nt owf password:")); + dump_data(100, nt_pwd, 16); +#endif - if (id2->hdr_nt_chal_resp.str_str_len == 24 && nt_pwd) { - if(smb_password_check((char *)id2->nt_chal_resp.buffer, - nt_pwd, id2->lm_chal)) - return NT_STATUS_NOPROBLEMO; - else - return NT_STATUS_WRONG_PASSWORD; + generate_random_buffer(user_info.chal, 8, False); + SMBOWFencrypt(lm_pwd, user_info.chal, local_lm_response); + SMBOWFencrypt(nt_pwd, user_info.chal, local_nt_response); + user_info.lm_resp.buffer = (uint8 *)local_lm_response; + user_info.lm_resp.len = 24; + user_info.nt_resp.buffer = (uint8 *)local_nt_response; + user_info.nt_resp.len = 24; + break; } +#if 0 + case GENERAL_LOGON_TYPE: + /* plaintext login. plaintext username and password */ - /* lkclXXXX this is not a good place to put disabling of LM hashes in. - if that is to be done, first move this entire function into a - library routine that calls the two smb_password_check() functions. - if disabling LM hashes (which nt can do for security reasons) then - an attempt should be made to disable them everywhere (which nt does - not do, for various security-hole reasons). - */ + /* + * Not encrypted - do so. + */ + + SMBencrypt( (uchar *)ctr->auth.id4....., user_info.chal, local_lm_response); + SMBNTencrypt((uchar *)ctr->auth.id4......., user_info.chal, local_nt_response); + user_info.lm_resp.buffer = (uint8 *)local_lm_response; + user_info.lm_resp.len = 24; + user_info.nt_resp.buffer = (uint8 *)local_nt_response; + user_info.nt_resp.len = 24; + + user_info.plaintext_password.str = ; + user_info.plaintext_password.len = ; + break; +#endif + default: + DEBUG(2,("SAM Logon: unsupported switch value\n")); + return NT_STATUS_INVALID_INFO_CLASS; + } /* end switch */ + + nt_status = check_password(&user_info, &server_info); - if (id2->hdr_lm_chal_resp.str_str_len == 24 && lanman_pwd && - smb_password_check((char *)id2->lm_chal_resp.buffer, - lanman_pwd, id2->lm_chal)) - return NT_STATUS_NOPROBLEMO; + DEBUG(5, ("_net_logon_any: exited with status %d\n", nt_status)); - /* oops! neither password check succeeded */ + return nt_status; - return NT_STATUS_WRONG_PASSWORD; } + + /************************************************************************* _net_sam_logon *************************************************************************/ @@ -542,11 +583,12 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ NET_USER_INFO_3 *usr_info = NULL; DOM_CRED srv_cred; SAM_ACCOUNT *sampass = NULL; - uint16 acct_ctrl; UNISTR2 *uni_samlogon_user = NULL; + UNISTR2 *uni_samlogon_domain = NULL; fstring nt_username; + fstring nt_domain; BOOL ret; - + usr_info = (NET_USER_INFO_3 *)talloc(p->mem_ctx, sizeof(NET_USER_INFO_3)); if (!usr_info) return NT_STATUS_NO_MEMORY; @@ -576,11 +618,13 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ switch (q_u->sam_id.logon_level) { case INTERACTIVE_LOGON_TYPE: uni_samlogon_user = &q_u->sam_id.ctr->auth.id1.uni_user_name; + uni_samlogon_domain = &q_u->sam_id.ctr->auth.id1.uni_domain_name; DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); break; case NET_LOGON_TYPE: uni_samlogon_user = &q_u->sam_id.ctr->auth.id2.uni_user_name; + uni_samlogon_domain = &q_u->sam_id.ctr->auth.id2.uni_domain_name; DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); break; @@ -592,8 +636,9 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ /* check username exists */ rpcstr_pull(nt_username,uni_samlogon_user->buffer,sizeof(nt_username),uni_samlogon_user->uni_str_len*2,0); + rpcstr_pull(nt_domain,uni_samlogon_domain->buffer,sizeof(nt_domain),uni_samlogon_domain->uni_str_len*2,0); - DEBUG(3,("User:[%s]\n", nt_username)); + DEBUG(3,("User:[%s] Requested Domain:[%s]\n", nt_username, nt_domain)); /* * Convert to a UNIX username. @@ -601,6 +646,17 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ map_username(nt_username); + DEBUG(10,("Attempting validation level %d for mapped username %s.\n", q_u->sam_id.ctr->switch_value, nt_username)); + + status = _net_logon_any(q_u->sam_id.ctr, nt_username, nt_domain, p->dc.sess_key); + + /* Check account and password */ + + if (status != NT_STATUS_NOPROBLEMO) { + pdb_free_sam(sampass); + return status; + } + pdb_init_sam(&sampass); /* get the account information */ @@ -613,33 +669,6 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ return NT_STATUS_NO_SUCH_USER; } - acct_ctrl = pdb_get_acct_ctrl(sampass); - - if (acct_ctrl & ACB_DISABLED) { - pdb_free_sam(sampass); - return NT_STATUS_ACCOUNT_DISABLED; - } - - /* 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, 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, sampass); - break; - } - } - - if (status != NT_STATUS_NOPROBLEMO) { - pdb_free_sam(sampass); - return status; - } - /* 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. diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index cd17de77f3..277cd13522 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -263,7 +263,9 @@ BOOL create_next_pdu(pipes_struct *p) static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlmssp_resp) { uchar lm_owf[24]; - uchar nt_owf[24]; + uchar nt_owf[128]; + int nt_pw_len; + int lm_pw_len; fstring user_name; fstring pipe_user_name; fstring domain; @@ -307,13 +309,16 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm DEBUG(5,("user: %s domain: %s wks: %s\n", user_name, domain, wks)); + nt_pw_len = MIN(sizeof(nt_owf), ntlmssp_resp->hdr_nt_resp.str_str_len); + lm_pw_len = MIN(sizeof(lm_owf), ntlmssp_resp->hdr_lm_resp.str_str_len); + memcpy(lm_owf, ntlmssp_resp->lm_resp, sizeof(lm_owf)); - memcpy(nt_owf, ntlmssp_resp->nt_resp, sizeof(nt_owf)); + memcpy(nt_owf, ntlmssp_resp->nt_resp, nt_pw_len); #ifdef DEBUG_PASSWORD DEBUG(100,("lm, nt owfs, chal\n")); dump_data(100, (char *)lm_owf, sizeof(lm_owf)); - dump_data(100, (char *)nt_owf, sizeof(nt_owf)); + dump_data(100, (char *)nt_owf, nt_pw_len); dump_data(100, (char *)p->challenge, 8); #endif @@ -362,8 +367,11 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm become_root(); - if(!(p->ntlmssp_auth_validated = pass_check_smb(pipe_user_name, domain, - (uchar*)p->challenge, lm_owf, nt_owf))) { + if(!(p->ntlmssp_auth_validated = + pass_check_smb_with_chal(pipe_user_name, domain, + (uchar*)p->challenge, + lm_owf, lm_pw_len, + nt_owf, nt_pw_len) == NT_STATUS_NOPROBLEMO)) { DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name )); unbecome_root(); -- cgit From f8d3cac8af0185eca2995e524c62f064ab9b4017 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 9 Aug 2001 15:53:49 +0000 Subject: a few cleanups while mergeing the passdb code into 2.2 (This used to be commit ef01739708479c43f529c646dd136ee5670b08f9) --- source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_samr_nt.c | 43 ++++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 22 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 277cd13522..4d4d058fba 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -455,7 +455,7 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name */ p->pipe_user.uid = pdb_get_uid(sampass); - p->pipe_user.gid = 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/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a4754beb52..d617dd9809 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -109,26 +109,27 @@ static uint32 get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, 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; + 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; } - 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); + 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 (pdb_get_nt_passwd(pwd)) - memcpy( pw_buf[(*num_entries)].nt_pwd , pdb_get_nt_passwd(pwd), 16); + memcpy( pw_buf[(*num_entries)].nt_pwd , pdb_get_nt_passwd(pwd), 16); pw_buf[(*num_entries)].acb_info = pdb_get_acct_ctrl(pwd); @@ -136,14 +137,14 @@ static uint32 get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, (*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)++; + DEBUG(5,(" acb_mask %x accepts\n", acb_mask)); + (*num_entries)++; } else - DEBUG(5,(" acb_mask %x rejects\n", acb_mask)); + DEBUG(5,(" acb_mask %x rejects\n", acb_mask)); - (*total_entries)++; - } + (*total_entries)++; + } pdb_endsampwent(); pdb_free_sam(pwd); @@ -1794,7 +1795,7 @@ 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=NULL; + SAM_ACCOUNT *sam_pass=NULL; DOM_GID *gids = NULL; int num_groups = 0; pstring groups; -- cgit From 047a7c88d7d004f1581f585dd31caea388ab6f0d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 10 Aug 2001 05:41:53 +0000 Subject: Replaced the duplicate DOS constants with appropriate ones from doserr.h to emphasise the fact that the spoolss pipe returns DOS error codes instead of 32-bit nt status codes. (This used to be commit 5f5ed41ee872d842e944cd2e84a80de714ad4385) --- source3/rpc_server/srv_spoolss_nt.c | 555 ++++++++++++++++++------------------ source3/rpc_server/srv_srvsvc_nt.c | 50 ++-- 2 files changed, 304 insertions(+), 301 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d93f320e2f..a0f14a9e64 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/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; @@ -272,12 +275,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 +290,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()) { @@ -304,7 +307,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)); @@ -313,12 +316,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; } /**************************************************************************** @@ -705,7 +708,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_NOPROBLEMO; + uint32 result = ERRsuccess; #endif UNISTR2 *printername = NULL; @@ -722,7 +725,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 */ @@ -731,7 +734,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) @@ -745,7 +748,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; } /* @@ -775,7 +778,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_NOPROBLEMO; + return ERRsuccess; } else if ((printer_default->access_required & SERVER_ACCESS_ADMINISTER ) == SERVER_ACCESS_ADMINISTER) { @@ -784,14 +787,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_NOPROBLEMO; + return ERRsuccess; } else { close_printer_handle(p, handle); - return ERROR_ACCESS_DENIED; + return ERRnoaccess; } } } @@ -801,7 +804,7 @@ 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) @@ -810,7 +813,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, 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; } /* @@ -889,7 +892,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, #endif } - return NT_STATUS_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -1007,7 +1010,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; @@ -1033,9 +1036,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_NOPROBLEMO; + return ERRsuccess; } /******************************************************************** @@ -1057,7 +1060,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); } @@ -1119,20 +1122,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); @@ -1308,9 +1311,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); @@ -1325,18 +1328,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_NOPROBLEMO; + return ERRsuccess; } } @@ -1397,7 +1400,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; @@ -1417,7 +1420,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_NOPROBLEMO; + return ERRsuccess; } /******************************************************************* @@ -2361,7 +2364,7 @@ static uint32 printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, } */ - return NT_STATUS_NOPROBLEMO; + return ERRsuccess; } /******************************************************************* @@ -2444,7 +2447,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_NOPROBLEMO; + return ERRsuccess; } /******************************************************************** @@ -2459,7 +2462,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; @@ -2885,7 +2888,7 @@ static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 of if (construct_printer_info_1(flags, ¤t_prt, snum)) { if((printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) { *returned=0; - return ERROR_NOT_ENOUGH_MEMORY; + return ERRnomem; } DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned)); memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_1)); @@ -2899,7 +2902,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++) @@ -2910,10 +2913,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_NOPROBLEMO; + return ERRsuccess; } /******************************************************************** @@ -2941,7 +2944,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; } /******************************************************************** @@ -2963,7 +2966,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; @@ -2981,7 +2984,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 */ @@ -2992,10 +2995,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_NOPROBLEMO; + return ERRsuccess; } /******************************************************************** @@ -3029,7 +3032,7 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 if (construct_printer_info_2(¤t_prt, snum)) { if((printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2))) == NULL) - return ERROR_NOT_ENOUGH_MEMORY; + return ERRnomem; DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *returned)); memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_2)); (*returned)++; @@ -3046,7 +3049,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 */ @@ -3061,10 +3064,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_NOPROBLEMO; + return ERRsuccess; } /******************************************************************** @@ -3088,7 +3091,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_NOPROBLEMO; /* NT4sp5 does that */ + return ERRsuccess; /* NT4sp5 does that */ } /******************************************************************** @@ -3114,13 +3117,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_NOPROBLEMO; + return ERRsuccess; } /******************************************************************** @@ -3131,7 +3134,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_NOPROBLEMO; + return ERRsuccess; } /******************************************************************** @@ -3187,7 +3190,7 @@ uint32 _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ case 3: case 4: default: - return ERROR_INVALID_LEVEL; + return ERRunknownlevel; } } @@ -3198,7 +3201,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); @@ -3207,7 +3210,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 */ @@ -3217,10 +3220,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -3230,7 +3233,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); @@ -3239,7 +3242,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 */ @@ -3249,10 +3252,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -3262,7 +3265,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); @@ -3271,23 +3274,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -3297,14 +3300,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 */ @@ -3314,10 +3317,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -3340,7 +3343,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: @@ -3352,7 +3355,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; } } @@ -3375,16 +3378,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_NOPROBLEMO; + return ERRsuccess; } /******************************************************************** @@ -3433,16 +3436,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_NOPROBLEMO; + return ERRsuccess; } /******************************************************************** @@ -3545,20 +3548,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_NOPROBLEMO; + return ERRsuccess; } /******************************************************************** @@ -3639,7 +3642,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)); @@ -3650,7 +3653,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. */ @@ -3659,7 +3662,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; } } @@ -3667,7 +3670,7 @@ static uint32 construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fst free_a_printer(&printer,2); - return NT_STATUS_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -3695,10 +3698,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_NOPROBLEMO) { + if (status != ERRsuccess) { safe_free(info); return status; } @@ -3708,7 +3711,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 */ @@ -3718,9 +3721,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -3731,10 +3734,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_NOPROBLEMO) { + if (status != ERRsuccess) { safe_free(info); return status; } @@ -3744,7 +3747,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 */ @@ -3754,9 +3757,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -3769,7 +3772,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_NOPROBLEMO) { + if (status != ERRsuccess) { return status; } @@ -3778,7 +3781,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 */ @@ -3787,9 +3790,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -3802,7 +3805,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_NOPROBLEMO) { + if (status != ERRsuccess) { return status; } @@ -3811,7 +3814,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 */ @@ -3820,9 +3823,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -3859,7 +3862,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: @@ -3871,7 +3874,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; } } @@ -3890,7 +3893,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; } /**************************************************************************** @@ -3904,12 +3907,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_NOPROBLEMO; + return ERRsuccess; } /******************************************************************** @@ -3934,7 +3937,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); @@ -3955,13 +3958,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)); @@ -4009,7 +4012,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); @@ -4029,18 +4032,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: @@ -4060,7 +4063,7 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command, } break; default: - return ERROR_INVALID_LEVEL; + return ERRunknownlevel; } return errcode; @@ -4096,7 +4099,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; } @@ -4146,7 +4149,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_NOPROBLEMO; + result = ERRsuccess; goto done; } @@ -4160,7 +4163,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; } @@ -4504,28 +4507,28 @@ static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, DEBUG(8,("update_printer\n")); - result = NT_STATUS_NOPROBLEMO; + 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; } @@ -4546,7 +4549,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; } } @@ -4554,7 +4557,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; } @@ -4564,7 +4567,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_NOPROBLEMO; + result = ERRsuccess; goto done; } @@ -4573,7 +4576,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; } @@ -4581,7 +4584,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; } @@ -4589,7 +4592,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; } @@ -4618,7 +4621,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 */ @@ -4631,7 +4634,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; } } @@ -4646,7 +4649,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) @@ -4660,7 +4663,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -4672,7 +4675,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 */ @@ -4769,7 +4772,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++) @@ -4783,7 +4786,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 */ @@ -4795,10 +4798,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -4815,12 +4818,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++) @@ -4835,7 +4838,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 */ @@ -4850,10 +4853,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -4887,14 +4890,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_NOPROBLEMO; + return ERRsuccess; } switch (level) { @@ -4905,7 +4908,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; } } @@ -4930,16 +4933,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); @@ -4963,7 +4966,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; @@ -4992,12 +4995,12 @@ 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) { safe_free(list); - return ERROR_NOT_ENOUGH_MEMORY; + return ERRnomem; } } @@ -5025,7 +5028,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 */ @@ -5038,10 +5041,10 @@ static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture if (*needed > offered) { *returned=0; - return ERROR_INSUFFICIENT_BUFFER; + return ERRinsufficientbuffer; } else - return NT_STATUS_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -5067,12 +5070,12 @@ 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) { safe_free(list); - return ERROR_NOT_ENOUGH_MEMORY; + return ERRnomem; } } @@ -5101,7 +5104,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 */ @@ -5114,10 +5117,10 @@ static uint32 enumprinterdrivers_level2(fstring servername, fstring architecture if (*needed > offered) { *returned=0; - return ERROR_INSUFFICIENT_BUFFER; + return ERRinsufficientbuffer; } else - return NT_STATUS_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -5143,12 +5146,12 @@ 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) { safe_free(list); - return ERROR_NOT_ENOUGH_MEMORY; + return ERRnomem; } } @@ -5177,7 +5180,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 */ @@ -5193,10 +5196,10 @@ static uint32 enumprinterdrivers_level3(fstring servername, fstring architecture if (*needed > offered) { *returned=0; - return ERROR_INSUFFICIENT_BUFFER; + return ERRinsufficientbuffer; } else - return NT_STATUS_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -5238,7 +5241,7 @@ uint32 _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS default: *returned=0; safe_free(list); - return ERROR_INVALID_LEVEL; + return ERRunknownlevel; } } @@ -5290,13 +5293,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 */ @@ -5328,7 +5331,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 */ @@ -5345,15 +5348,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_NOPROBLEMO; + return ERRsuccess; default: safe_free(list); safe_free(builtinlist); - return ERROR_INVALID_LEVEL; + return ERRunknownlevel; } } @@ -5394,7 +5397,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) { @@ -5417,7 +5420,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. */ @@ -5425,22 +5428,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_NOPROBLEMO; + return ERRsuccess; default: safe_free(list); - return ERROR_INVALID_LEVEL; + return ERRunknownlevel; } } @@ -5488,7 +5491,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; @@ -5498,9 +5501,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 offered) { *returned=0; - return ERROR_INSUFFICIENT_BUFFER; + return ERRinsufficientbuffer; } else - return NT_STATUS_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -5586,7 +5589,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; @@ -5596,9 +5599,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 offered) { *returned=0; - return ERROR_INSUFFICIENT_BUFFER; + return ERRinsufficientbuffer; } else - return NT_STATUS_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -5678,7 +5681,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; } } @@ -5696,7 +5699,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); @@ -5707,7 +5710,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, @@ -5715,13 +5718,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; } /* @@ -5730,27 +5733,27 @@ 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; } /* 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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -5773,13 +5776,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; } } @@ -5792,7 +5795,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_NOPROBLEMO; + uint32 err = ERRsuccess; NT_PRINTER_DRIVER_INFO_LEVEL driver; struct current_user user; @@ -5803,18 +5806,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_NOPROBLEMO ) + 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; } @@ -5842,10 +5845,10 @@ 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; + 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); @@ -5857,7 +5860,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); @@ -5865,9 +5868,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -5894,7 +5897,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; } } @@ -5944,14 +5947,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 @@ -5974,7 +5977,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 @@ -6005,7 +6008,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 */ @@ -6015,7 +6018,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_NOPROBLEMO; + return ERRsuccess; } /* @@ -6026,7 +6029,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); @@ -6043,7 +6046,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 = rpcstr_push((char *)*out_value,value, in_value_len, 0); @@ -6054,7 +6057,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); @@ -6062,7 +6065,7 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S safe_free(data); - return NT_STATUS_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -6088,15 +6091,15 @@ 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; status = get_a_printer(&printer, 2, lp_servicename(snum)); if (status != 0x0) - return ERROR_INVALID_NAME; + return ERRinvalidname; convert_specific_param(¶m, value , type, data, real_len); @@ -6114,7 +6117,7 @@ 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_NOPROBLEMO; + status = ERRsuccess; goto done; } } @@ -6124,7 +6127,7 @@ uint32 _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { DEBUG(3, ("security descriptor change denied by existing " "security descriptor\n")); - status = ERROR_ACCESS_DENIED; + status = ERRnoaccess; goto done; } @@ -6160,27 +6163,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(¶m); unistr2_to_ascii(param.value, value, sizeof(param.value)-1); if(!unlink_specific_param_if_exist(printer->info_2, ¶m)) - status = ERROR_INVALID_PARAMETER; + status = ERRinvalidparam; else status = mod_a_printer(*printer, 2); @@ -6206,17 +6209,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); @@ -6241,17 +6244,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); @@ -6277,11 +6280,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); @@ -6301,7 +6304,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; @@ -6310,7 +6313,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); @@ -6318,10 +6321,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -6357,7 +6360,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; } } @@ -6369,7 +6372,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; @@ -6378,7 +6381,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); @@ -6386,10 +6389,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -6418,7 +6421,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; } } @@ -6431,7 +6434,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; @@ -6440,7 +6443,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); @@ -6448,10 +6451,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -6462,7 +6465,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; @@ -6473,7 +6476,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); @@ -6481,10 +6484,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_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -6521,7 +6524,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; } } @@ -6537,7 +6540,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 offered) - return ERROR_INSUFFICIENT_BUFFER; + return ERRinsufficientbuffer; else - return NT_STATUS_NOPROBLEMO; + return ERRsuccess; } @@ -6589,7 +6592,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 offered) - return ERROR_INSUFFICIENT_BUFFER; + return ERRinsufficientbuffer; else - return NT_STATUS_NOPROBLEMO; + return ERRsuccess; } /**************************************************************************** @@ -6660,7 +6663,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); @@ -6674,6 +6677,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/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 913b04bca3..735a429102 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1264,7 +1264,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); @@ -1274,17 +1274,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)); @@ -1299,7 +1299,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)); @@ -1314,7 +1314,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 ))) @@ -1332,7 +1332,7 @@ 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); @@ -1340,7 +1340,7 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S 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. */ @@ -1394,18 +1394,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)); @@ -1422,14 +1422,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); @@ -1439,7 +1439,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 ))) @@ -1456,7 +1456,7 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S 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) { @@ -1497,7 +1497,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); @@ -1506,15 +1506,15 @@ 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)); @@ -1522,7 +1522,7 @@ uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S 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. */ @@ -1635,7 +1635,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; } } @@ -1644,7 +1644,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; } @@ -1728,7 +1728,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; } } @@ -1737,7 +1737,7 @@ 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; } @@ -1863,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; } -- cgit From 4b2016305b7c43c61198f25175531d149db5e989 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 10 Aug 2001 19:38:53 +0000 Subject: Merge in the NT drivers changes from 2.2. Jeremy. (This used to be commit a3781ad38ff6c70238e7e9b83324477e5c9780d5) --- source3/rpc_server/srv_spoolss_nt.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a0f14a9e64..f002ceabd2 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -34,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 @@ -5736,6 +5737,13 @@ static uint32 spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ 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); @@ -6132,10 +6140,23 @@ uint32 _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP } unlink_specific_param_if_exist(printer->info_2, param); - - add_a_specific_param(printer->info_2, ¶m); - 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, ¶m); + status = mod_a_printer(*printer, 2); + } + done: free_a_printer(&printer, 2); if (param) -- cgit From 8d5916d5fa4aea02cd84d3b2d0793ead9455a50a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 11 Aug 2001 16:34:11 +0000 Subject: Without this become_root()/unbecome_root() pair I was not able to login when samba acting as a PDC. I also removed a pdb_free_sam(sampass), because it sampass was never initialized before... Please abartlet can you check this patch is ok? I feel like this was a bad check-in (This used to be commit f25a5dab6012ebbe83435b06650d6ab92432760a) --- source3/rpc_server/srv_netlog_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 385fec5862..b7e1d3538d 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -563,7 +563,9 @@ static uint32 _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, cha return NT_STATUS_INVALID_INFO_CLASS; } /* end switch */ + become_root(); nt_status = check_password(&user_info, &server_info); + unbecome_root(); DEBUG(5, ("_net_logon_any: exited with status %d\n", nt_status)); @@ -652,10 +654,8 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ /* Check account and password */ - if (status != NT_STATUS_NOPROBLEMO) { - pdb_free_sam(sampass); + if (status != NT_STATUS_NOPROBLEMO) return status; - } pdb_init_sam(&sampass); -- cgit From 6ad80352dd2523c310258de3211a2af0f1763d2a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 12 Aug 2001 11:19:57 +0000 Subject: This patch does a number of things, mostly smaller than they look :-) In particuar, it moves the domain_client_validate stuff out of auth_domain.c to somwhere where they (I hope) they can be shared with winbind better. (This may need some work) The main purpose of this patch was however to improve some of the internal documentation and to correctly place become_root()/unbecome_root() calls within the code. Finally this patch moves some more of auth.c into other files, auth_unix.c in this case. Andrew Bartlett (This used to be commit ea1c547ac880def29f150de2172c95213509350e) --- source3/rpc_server/srv_netlog_nt.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index b7e1d3538d..5cf8f6732e 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -446,7 +446,6 @@ uint32 _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF static uint32 _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, char *sess_key) { - uint32 nt_status = NT_STATUS_LOGON_FAILURE; unsigned char local_lm_response[24]; @@ -490,6 +489,8 @@ static uint32 _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, cha DEBUG(10,("_net_logon_any: Attempting validation level %d.\n", ctr->switch_value)); switch (ctr->switch_value) { case NET_LOGON_TYPE: + /* Standard challange/response authenticaion */ + user_info.lm_resp.buffer = (uint8 *)ctr->auth.id2.lm_chal_resp.buffer; user_info.lm_resp.len = ctr->auth.id2.lm_chal_resp.str_str_len; user_info.nt_resp.buffer = (uint8 *)ctr->auth.id2.nt_chal_resp.buffer; @@ -497,6 +498,9 @@ static uint32 _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, cha memcpy(user_info.chal, ctr->auth.id2.lm_chal, 8); break; case INTERACTIVE_LOGON_TYPE: + /* 'Interactive' autheticaion, supplies the password in its MD4 form, encrypted + with the session key. We will convert this to challange/responce for the + auth subsystem to chew on */ { char nt_pwd[16]; char lm_pwd[16]; @@ -539,25 +543,6 @@ static uint32 _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, cha user_info.nt_resp.len = 24; break; } -#if 0 - case GENERAL_LOGON_TYPE: - /* plaintext login. plaintext username and password */ - - /* - * Not encrypted - do so. - */ - - SMBencrypt( (uchar *)ctr->auth.id4....., user_info.chal, local_lm_response); - SMBNTencrypt((uchar *)ctr->auth.id4......., user_info.chal, local_nt_response); - user_info.lm_resp.buffer = (uint8 *)local_lm_response; - user_info.lm_resp.len = 24; - user_info.nt_resp.buffer = (uint8 *)local_nt_response; - user_info.nt_resp.len = 24; - - user_info.plaintext_password.str = ; - user_info.plaintext_password.len = ; - break; -#endif default: DEBUG(2,("SAM Logon: unsupported switch value\n")); return NT_STATUS_INVALID_INFO_CLASS; -- cgit From ddec8306586414cc02eca612777bb547cb8dbcae Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 12 Aug 2001 12:23:50 +0000 Subject: Kill of idra's extra become_root()/unbecome_root() now I have fixed the actual problem. Andrew Bartlett (This used to be commit 895d1cd317d0838d711474f2f19186444a88b52c) --- source3/rpc_server/srv_netlog_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 5cf8f6732e..d878e2db58 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -548,9 +548,7 @@ static uint32 _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, cha return NT_STATUS_INVALID_INFO_CLASS; } /* end switch */ - become_root(); nt_status = check_password(&user_info, &server_info); - unbecome_root(); DEBUG(5, ("_net_logon_any: exited with status %d\n", nt_status)); -- cgit From 2e783a47076bd0994b6ce86df7ec967bc1c2da63 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 12 Aug 2001 17:30:01 +0000 Subject: this is a big global fix for the ptr = Realloc(ptr, size) bug. many possible mem leaks, and segfaults fixed. someone should port this fix to 2.2 also. (This used to be commit fa8e55b8b465114ce209344965c1ca0333b84db9) --- source3/rpc_server/srv_spoolss_nt.c | 69 +++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f002ceabd2..023c9a1203 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -915,20 +915,24 @@ static BOOL convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni, static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *uni, NT_PRINTER_DRIVER_INFO_LEVEL *printer, uint32 level) { + BOOL result = True; + switch (level) { case 3: printer->info_3=NULL; - uni_2_asc_printer_driver_3(uni->info_3, &printer->info_3); + if (!uni_2_asc_printer_driver_3(uni->info_3, &printer->info_3)) + result = False; break; case 6: printer->info_6=NULL; - uni_2_asc_printer_driver_6(uni->info_6, &printer->info_6); + if (!uni_2_asc_printer_driver_6(uni->info_6, &printer->info_6)) + result = False; break; default: break; } - return True; + return result; } BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, @@ -2200,7 +2204,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; @@ -2220,9 +2224,12 @@ 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); @@ -2256,7 +2263,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")); @@ -2272,9 +2279,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]); @@ -2877,7 +2886,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")); @@ -2887,10 +2896,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, ¤t_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 ERRnomem; } + else printers = tp; DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned)); memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_1)); (*returned)++; @@ -3024,7 +3036,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 Date: Mon, 13 Aug 2001 21:30:27 +0000 Subject: merge from 2.2 (This used to be commit 7049217eb40dbe3de6c05fe43742d2f684501723) --- source3/rpc_server/srv_spoolss_nt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 023c9a1203..0710f05870 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -811,6 +811,18 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, 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); -- cgit From e08ca026319f39683e0e935e2ddc48d33f381e71 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Aug 2001 23:19:16 +0000 Subject: Added Jim McDonough's Win9x take ownership fix. Jeremy. (This used to be commit 800e46ea7e724460be2ba5f71e5baa2f2ddd2d3b) --- source3/rpc_server/srv_srvsvc_nt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 735a429102..cf65d5119f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1693,6 +1693,7 @@ 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); @@ -1714,6 +1715,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); @@ -1742,6 +1750,7 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ } close_file(fsp, True); + unbecome_user(); close_cnum(conn, user.vuid); return r_u->status; @@ -1751,6 +1760,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); -- cgit From 28b206f16303d69694174d69fdfe2853bcee56c8 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 22 Aug 2001 16:10:28 +0000 Subject: some %things are not expanded properly in get share info levels (This used to be commit 3e60636f2b7003ea1e915bc7c2d2e8dec5667bbd) --- source3/rpc_server/srv_srvsvc_nt.c | 41 ++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index cf65d5119f..b5b38b1403 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/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)); @@ -353,7 +353,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 +363,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 +431,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 +469,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 +486,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 +503,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,12 +523,12 @@ 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; } else { @@ -539,7 +542,7 @@ 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; @@ -554,13 +557,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); @@ -1153,7 +1156,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 +1174,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 +1195,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__)); -- cgit From b5a5fe44cc06efc32504178eee546c647b08b595 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 23 Aug 2001 18:05:44 +0000 Subject: Fix for filers sending -1 for the maximum read request length on the LSA pipe. (This used to be commit 95307a5d3881803e57639431da967ee3872aacc4) --- source3/rpc_server/srv_pipe_hnd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index baa02beb65..cdcdb82923 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -775,10 +775,14 @@ 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: 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 )); - 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 )); } /* -- cgit From 8ef7ddba65f326df69d3ff247491a0df1fa89578 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 23 Aug 2001 23:25:34 +0000 Subject: so let admins shutdown their samba servers remotely if they want :-) (This used to be commit 6391fd7bdab07c83e9eed02e761db09918e60302) --- source3/rpc_server/srv_reg.c | 28 ++++++++++++++++++++++++++ source3/rpc_server/srv_reg_nt.c | 44 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 2a0e2d172c..105230a22f 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -134,6 +134,32 @@ static BOOL api_reg_info(pipes_struct *p) return True; } +/******************************************************************* + api_reg_shutdown + ********************************************************************/ + +static BOOL api_reg_shutdown(pipes_struct *p) +{ + REG_Q_SHUTDOWN q_u; + REG_R_SHUTDOWN r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the reg shutdown */ + if(!reg_io_q_shutdown("", &q_u, data, 0)) + return False; + + r_u.status = _reg_shutdown(p, &q_u, &r_u); + + if(!reg_io_r_shutdown("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* array of \PIPE\reg operations @@ -144,6 +170,8 @@ static struct api_struct api_reg_cmds[] = { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, { "REG_OPEN" , REG_OPEN_HKLM , api_reg_open }, { "REG_INFO" , REG_INFO , api_reg_info }, + { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, +/* { "REG_ABORT_SHUTDOWN", REG_ABORT_SHUTDOWN, api_reg_abrot_shutdown }, */ { NULL, 0 , NULL } }; diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 3ed673c68a..a467e529cb 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -177,3 +177,47 @@ uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) return status; } + +/******************************************************************* + reg_shutdwon + ********************************************************************/ + +#define SHUTDOWN_R_STRING "-r" +#define SHUTDOWN_F_STRING "-f" + + +uint32 _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) +{ + uint32 status = NT_STATUS_NOPROBLEMO; + pstring shutdown_script; + UNISTR2 unimsg = q_u->uni_msg; + pstring message; + fstring timeout; + fstring r; + fstring f; + + rpcstr_pull (message, unimsg.buffer, sizeof(message), unimsg.uni_str_len*2,0); + snprintf(timeout, sizeof(timeout), "%d", q_u->timeout); + if ((q_u->flags) & 0x100) /* reboot */ + snprintf(r, sizeof(r), SHUTDOWN_R_STRING); + if ((q_u->flags) & 0x001) /* force */ + snprintf(f, sizeof(f), SHUTDOWN_F_STRING); + + pstrcpy(shutdown_script, lp_shutdown_script()); + + if (!*shutdown_script) { + pstrcpy(shutdown_script, lp_shutdown_script()); + } + + if(*shutdown_script) { + int shutdown_ret; + all_string_sub(shutdown_script, "%m", message, sizeof(shutdown_script)); + all_string_sub(shutdown_script, "%t", timeout, sizeof(shutdown_script)); + all_string_sub(shutdown_script, "%r", r, sizeof(shutdown_script)); + all_string_sub(shutdown_script, "%f", f, sizeof(shutdown_script)); + shutdown_ret = smbrun(shutdown_script,NULL); + DEBUG(3,("_reg_shutdown: Running the command `%s' gave %d\n",shutdown_script,shutdown_ret)); + } + + return status; +} -- cgit From 659774bffdf926f461dfe497160c1aabc8773c4d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 24 Aug 2001 07:32:51 +0000 Subject: Fixed malloc -> talloc problems pointed out by Simo. Jeremy (This used to be commit 0f5b187387fb536a6866d9109eff82411798f79e) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index a6e45ec03a..cb1b2fb3c9 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -335,7 +335,7 @@ 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, + init_r_enum_trust_dom(p->mem_ctx, r_u, enum_context, dom_name, dom_sid, dom_name != NULL ? NT_STATUS_NOPROBLEMO : NT_STATUS_UNABLE_TO_FREE_VM); return r_u->status; -- cgit From 0174ccc0d6f34e84b201031a4c3eb58763a19770 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 24 Aug 2001 07:51:59 +0000 Subject: let admins also abort a shutdown (This used to be commit 3b40ec4f149a8813c1d68f184858e2ddd605d8fd) --- source3/rpc_server/srv_reg.c | 28 +++++++++++++++++++++++++++- source3/rpc_server/srv_reg_nt.c | 35 ++++++++++++++++++++++++++--------- 2 files changed, 53 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 105230a22f..8aa5c4bddf 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -160,6 +160,32 @@ static BOOL api_reg_shutdown(pipes_struct *p) return True; } +/******************************************************************* + api_reg_abort_shutdown + ********************************************************************/ + +static BOOL api_reg_abort_shutdown(pipes_struct *p) +{ + REG_Q_ABORT_SHUTDOWN q_u; + REG_R_ABORT_SHUTDOWN r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the reg shutdown */ + if(!reg_io_q_abort_shutdown("", &q_u, data, 0)) + return False; + + r_u.status = _reg_abort_shutdown(p, &q_u, &r_u); + + if(!reg_io_r_abort_shutdown("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* array of \PIPE\reg operations @@ -171,7 +197,7 @@ static struct api_struct api_reg_cmds[] = { "REG_OPEN" , REG_OPEN_HKLM , api_reg_open }, { "REG_INFO" , REG_INFO , api_reg_info }, { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, -/* { "REG_ABORT_SHUTDOWN", REG_ABORT_SHUTDOWN, api_reg_abrot_shutdown }, */ + { "REG_ABORT_SHUTDOWN", REG_ABORT_SHUTDOWN, api_reg_abort_shutdown }, { NULL, 0 , NULL } }; diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index a467e529cb..a77f329d4a 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -192,26 +192,27 @@ uint32 _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) pstring shutdown_script; UNISTR2 unimsg = q_u->uni_msg; pstring message; + pstring chkmsg; fstring timeout; fstring r; fstring f; + /* message */ rpcstr_pull (message, unimsg.buffer, sizeof(message), unimsg.uni_str_len*2,0); + /* security check */ + alpha_strcpy (chkmsg, message, NULL, sizeof(message); + /* timeout */ snprintf(timeout, sizeof(timeout), "%d", q_u->timeout); - if ((q_u->flags) & 0x100) /* reboot */ - snprintf(r, sizeof(r), SHUTDOWN_R_STRING); - if ((q_u->flags) & 0x001) /* force */ - snprintf(f, sizeof(f), SHUTDOWN_F_STRING); + /* reboot */ + snprintf(r, sizeof(r), (q_u->flags & 0x100)?SHUTDOWN_R_STRING:""); + /* force */ + snprintf(f, sizeof(f), (q_u->flags & 0x001)?SHUTDOWN_F_STRING:""); pstrcpy(shutdown_script, lp_shutdown_script()); - if (!*shutdown_script) { - pstrcpy(shutdown_script, lp_shutdown_script()); - } - if(*shutdown_script) { int shutdown_ret; - all_string_sub(shutdown_script, "%m", message, sizeof(shutdown_script)); + all_string_sub(shutdown_script, "%m", chkmsg, sizeof(shutdown_script)); all_string_sub(shutdown_script, "%t", timeout, sizeof(shutdown_script)); all_string_sub(shutdown_script, "%r", r, sizeof(shutdown_script)); all_string_sub(shutdown_script, "%f", f, sizeof(shutdown_script)); @@ -221,3 +222,19 @@ uint32 _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) return status; } + +uint32 _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABORT_SHUTDOWN *r_u) +{ + uint32 status = NT_STATUS_NOPROBLEMO; + pstring abort_shutdown_script; + + pstrcpy(abort_shutdown_script, lp_abort_shutdown_script()); + + if(*abort_shutdown_script) { + int abort_shutdown_ret; + abort_shutdown_ret = smbrun(abort_shutdown_script,NULL); + DEBUG(3,("_reg_abort_shutdown: Running the command `%s' gave %d\n",abort_shutdown_script,abort_shutdown_ret)); + } + + return status; +} -- cgit From 40342d69171dd72886c9a0e540d4cd2334fd2284 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Fri, 24 Aug 2001 14:34:23 +0000 Subject: fix missing ) (This used to be commit f3bc6b5d68bdb01b07b9d780f5ba81c05e22f48c) --- source3/rpc_server/srv_reg_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index a77f329d4a..f7263ff266 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -200,7 +200,7 @@ uint32 _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) /* message */ rpcstr_pull (message, unimsg.buffer, sizeof(message), unimsg.uni_str_len*2,0); /* security check */ - alpha_strcpy (chkmsg, message, NULL, sizeof(message); + alpha_strcpy (chkmsg, message, NULL, sizeof(message)); /* timeout */ snprintf(timeout, sizeof(timeout), "%d", q_u->timeout); /* reboot */ -- cgit From 717533483b41ef975953f58e0c6be04828a3d467 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Fri, 24 Aug 2001 20:32:01 +0000 Subject: get rid of compiler warnings (This used to be commit 0768991d04ea03e774ca8662c9cae5e1951b88e0) --- source3/rpc_server/srv_netlog_nt.c | 6 +++--- source3/rpc_server/srv_samr_nt.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index d878e2db58..886e5fefca 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -535,8 +535,8 @@ static uint32 _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, cha #endif generate_random_buffer(user_info.chal, 8, False); - SMBOWFencrypt(lm_pwd, user_info.chal, local_lm_response); - SMBOWFencrypt(nt_pwd, user_info.chal, local_nt_response); + SMBOWFencrypt((const unsigned char *)lm_pwd, user_info.chal, local_lm_response); + SMBOWFencrypt((const unsigned char *)nt_pwd, user_info.chal, local_nt_response); user_info.lm_resp.buffer = (uint8 *)local_lm_response; user_info.lm_resp.len = 24; user_info.nt_resp.buffer = (uint8 *)local_nt_response; @@ -633,7 +633,7 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ DEBUG(10,("Attempting validation level %d for mapped username %s.\n", q_u->sam_id.ctr->switch_value, nt_username)); - status = _net_logon_any(q_u->sam_id.ctr, nt_username, nt_domain, p->dc.sess_key); + status = _net_logon_any(q_u->sam_id.ctr, nt_username, nt_domain, (char *)p->dc.sess_key); /* Check account and password */ diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d617dd9809..a81b026c65 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -808,7 +808,7 @@ static BOOL get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID /* well-known aliases */ if (sid_equal(sid, &global_sid_Builtin) && !lp_hide_local_users()) { - enum_group_mapping(SID_NAME_WKN_GRP, &map, &num_entries, ENUM_ALL_MAPPED); + enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ALL_MAPPED); *d_grp=(DOMAIN_GRP *)talloc_zero(ctx, num_entries*sizeof(DOMAIN_GRP)); if (*d_grp==NULL) @@ -919,7 +919,7 @@ static uint32 get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_ *p_num_entries = 0; - enum_group_mapping(SID_NAME_DOM_GRP, &map, &group_entries, ENUM_ONLY_MAPPED); + enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED); num_entries=group_entries-start_idx; @@ -2523,7 +2523,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(ctr->info.id24->pass, rid)) + if (!set_user_info_pw((char *)ctr->info.id24->pass, rid)) return NT_STATUS_ACCESS_DENIED; break; -- cgit From d309035c3eac3393252031218525923871d5860c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 26 Aug 2001 20:05:33 +0000 Subject: Spaces -> Tabs. Jeremy. (This used to be commit 5b665122f5a785f858f75c0a3c181ae193e2c503) --- source3/rpc_server/srv_pipe_hnd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index cdcdb82923..3c8e44d84e 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -775,14 +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. */ + /* + * 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(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 )); + 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 )); } /* -- cgit From 3820578473da81b7ae0dfa978605da809be59f62 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 27 Aug 2001 03:56:09 +0000 Subject: As per plug-fest discussions this paramater no longer defaults to the value of add user script. (This used to be commit 9e0c9a99f6ca01cd6a0ee3084f85e1c36b11d7c3) --- source3/rpc_server/srv_samr_nt.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a81b026c65..ba59aa548c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1962,10 +1962,6 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR pstrcpy(add_script, lp_addmachine_script()); - if (!*add_script) { - pstrcpy(add_script, lp_adduser_script()); - } - if(*add_script) { int add_ret; all_string_sub(add_script, "%u", mach_acct, sizeof(mach_acct)); -- cgit From ee5f7237decfe446f4fdb08422beb2e6cb43af7f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Aug 2001 17:52:23 +0000 Subject: started converting NTSTATUS to be a structure on systems with gcc in order to make it type incompatible with BOOL so we catch errors sooner. This has already found a number of bugs (This used to be commit 1b778bc7d22efff3f90dc450eb12baa1241cf68f) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index cb1b2fb3c9..fd4e3b6ec2 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -295,7 +295,7 @@ static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, _lsa_open_policy2. ***************************************************************************/ -uint32 _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2 *r_u) +NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2 *r_u) { /* lkclXXXX having decoded it, ignore all fields in the open policy! */ -- cgit From b031af348c7dcc8c74bf49945211c466b8eca079 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 27 Aug 2001 19:46:22 +0000 Subject: converted another bunch of stuff to NTSTATUS (This used to be commit 1d36250e338ae0ff9fbbf86019809205dd97d05e) --- source3/rpc_server/srv_dfs_nt.c | 6 +- source3/rpc_server/srv_lsa_nt.c | 64 ++--- source3/rpc_server/srv_netlog_nt.c | 50 ++-- source3/rpc_server/srv_pipe.c | 17 +- source3/rpc_server/srv_pipe_hnd.c | 4 +- source3/rpc_server/srv_reg_nt.c | 26 +-- source3/rpc_server/srv_samr.c | 2 +- source3/rpc_server/srv_samr_nt.c | 254 ++++++++++---------- source3/rpc_server/srv_spoolss.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 452 ++++++++++++++++++------------------ source3/rpc_server/srv_srvsvc_nt.c | 149 ++++++------ source3/rpc_server/srv_util.c | 26 +-- source3/rpc_server/srv_wkssvc_nt.c | 4 +- 13 files changed, 528 insertions(+), 528 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index a84f2ceb48..034b1bbe77 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -106,7 +106,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 NT_STATUS_OK; } uint32 _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DFS_R_DFS_REMOVE *r_u) @@ -185,7 +185,7 @@ uint32 _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DFS_R_DFS_REMOVE *r_u } } - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } static BOOL init_reply_dfs_info_1(struct junction_map* j, DFS_INFO_1* dfs1, int num_j) @@ -309,7 +309,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) diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index fd4e3b6ec2..b84293b2f4 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -193,7 +193,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_NOPROBLEMO; + r_l->status = NT_STATUS_OK; } /*************************************************************************** @@ -288,7 +288,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_NOPROBLEMO; + r_l->status = NT_STATUS_OK; } /*************************************************************************** @@ -303,14 +303,14 @@ NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL 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; } /*************************************************************************** _lsa_open_policy ***************************************************************************/ -uint32 _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL *r_u) +NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL *r_u) { /* lkclXXXX having decoded it, ignore all fields in the open policy! */ @@ -318,14 +318,14 @@ 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; } /*************************************************************************** _lsa_enum_trust_dom - this needs fixing to do more than return NULL ! JRA. ***************************************************************************/ -uint32 _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_ENUM_TRUST_DOM *r_u) +NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_ENUM_TRUST_DOM *r_u) { uint32 enum_context = 0; char *dom_name = NULL; @@ -336,7 +336,7 @@ uint32 _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_ENU /* set up the LSA QUERY INFO response */ init_r_enum_trust_dom(p->mem_ctx, r_u, enum_context, dom_name, dom_sid, - dom_name != NULL ? NT_STATUS_NOPROBLEMO : NT_STATUS_UNABLE_TO_FREE_VM); + dom_name != NULL ? NT_STATUS_OK : NT_STATUS_UNABLE_TO_FREE_VM); return r_u->status; } @@ -345,14 +345,14 @@ uint32 _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_ENU _lsa_query_info. See the POLICY_INFOMATION_CLASS docs at msdn. ***************************************************************************/ -uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO *r_u) +NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO *r_u) { LSA_INFO_UNION *info = &r_u->dom; DOM_SID domain_sid; char *name = NULL; DOM_SID *sid = NULL; - r_u->status = NT_STATUS_NOPROBLEMO; + r_u->status = NT_STATUS_OK; if (!find_policy_by_hnd(p, &q_u->pol, NULL)) return NT_STATUS_INVALID_HANDLE; @@ -366,7 +366,7 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO info->id2.count1 = 7; info->id2.count2 = 7; if ((info->id2.auditsettings = (uint32 *)talloc(p->mem_ctx,7*sizeof(uint32))) == NULL) - return False; + return NT_STATUS_NO_MEMORY; for (i = 0; i < 7; i++) info->id2.auditsettings[i] = 3; break; @@ -442,7 +442,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_NOPROBLEMO) { + if (NT_STATUS_IS_OK(r_u->status)) { r_u->undoc_buffer = 0x22000000; /* bizarre */ r_u->info_class = q_u->info_class; } @@ -454,7 +454,7 @@ uint32 _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO _lsa_lookup_sids ***************************************************************************/ -uint32 _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_SIDS *r_u) +NTSTATUS _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_SIDS *r_u) { DOM_SID2 *sid = q_u->sids.sid; int num_entries = q_u->sids.num_entries; @@ -482,7 +482,7 @@ uint32 _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_SI lsa_reply_lookup_names ***************************************************************************/ -uint32 _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_NAMES *r_u) +NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_NAMES *r_u) { UNISTR2 *names = q_u->uni_name; int num_entries = q_u->num_entries; @@ -510,20 +510,20 @@ uint32 _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_N _lsa_close. Also weird - needs to check if lsa handle is correct. JRA. ***************************************************************************/ -uint32 _lsa_close(pipes_struct *p, LSA_Q_CLOSE *q_u, LSA_R_CLOSE *r_u) +NTSTATUS _lsa_close(pipes_struct *p, LSA_Q_CLOSE *q_u, LSA_R_CLOSE *r_u) { if (!find_policy_by_hnd(p, &q_u->pol, NULL)) return NT_STATUS_INVALID_HANDLE; close_policy_hnd(p, &q_u->pol); - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /*************************************************************************** "No more secrets Marty...." :-). ***************************************************************************/ -uint32 _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SECRET *r_u) +NTSTATUS _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SECRET *r_u) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -532,7 +532,7 @@ uint32 _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SECR _lsa_enum_privs. ***************************************************************************/ -uint32 _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIVS *r_u) +NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIVS *r_u) { uint32 i; @@ -544,7 +544,7 @@ uint32 _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIVS return NT_STATUS_INVALID_HANDLE; if (enum_context >= PRIV_ALL_INDEX) - return 0x8000001A; + return NT_STATUS_UNABLE_TO_FREE_VM; entries = (LSA_PRIV_ENTRY *)talloc_zero(p->mem_ctx, sizeof(LSA_PRIV_ENTRY) * (PRIV_ALL_INDEX-enum_context)); if (entries==NULL) @@ -560,14 +560,14 @@ uint32 _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIVS init_lsa_r_enum_privs(r_u, i+enum_context, PRIV_ALL_INDEX-enum_context, entries); - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /*************************************************************************** _lsa_priv_get_dispname. ***************************************************************************/ -uint32 _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, LSA_R_PRIV_GET_DISPNAME *r_u) +NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, LSA_R_PRIV_GET_DISPNAME *r_u) { fstring name_asc; fstring desc_asc; @@ -595,14 +595,14 @@ uint32 _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, LSA r_u->ptr_info=0xdeadbeef; r_u->lang_id=q_u->lang_id; - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /*************************************************************************** _lsa_enum_accounts. ***************************************************************************/ -uint32 _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENUM_ACCOUNTS *r_u) +NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENUM_ACCOUNTS *r_u) { GROUP_MAP *map=NULL; int num_entries=0; @@ -614,7 +614,7 @@ uint32 _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENUM_ /* get the list of mapped groups (domain, local, builtin) */ if(!enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED)) - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; sids->ptr_sid = (uint32 *)talloc_zero(p->mem_ctx, (num_entries-q_u->enum_context)*sizeof(uint32)); sids->sid = (DOM_SID2 *)talloc_zero(p->mem_ctx, (num_entries-q_u->enum_context)*sizeof(DOM_SID2)); @@ -634,11 +634,11 @@ uint32 _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENUM_ init_lsa_r_enum_accounts(r_u, j); - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } -uint32 _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u) +NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u) { fstring username, domname; int ulen, dlen; @@ -663,7 +663,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_NOPROBLEMO; + r_u->status = NT_STATUS_OK; return r_u->status; } @@ -672,11 +672,11 @@ uint32 _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R ***************************************************************************/ -uint32 _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENACCOUNT *r_u) +NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENACCOUNT *r_u) { struct lsa_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)) @@ -701,7 +701,7 @@ uint32 _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENACCO ***************************************************************************/ -uint32 _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_R_ENUMPRIVSACCOUNT *r_u) +NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_R_ENUMPRIVSACCOUNT *r_u) { struct lsa_info *info=NULL; GROUP_MAP map; @@ -710,7 +710,7 @@ uint32 _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_ LUID_ATTR *set=NULL; - 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, (void **)&info)) @@ -742,9 +742,9 @@ uint32 _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_ ***************************************************************************/ -uint32 _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA_R_GETSYSTEMACCOUNT *r_u) +NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA_R_GETSYSTEMACCOUNT *r_u) { - 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)) diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 886e5fefca..e29d9393a6 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -38,7 +38,7 @@ extern DOM_SID global_sam_sid; *************************************************************************/ static void init_net_r_req_chal(NET_R_REQ_CHAL *r_c, - DOM_CHAL *srv_chal, int status) + DOM_CHAL *srv_chal, NTSTATUS status) { DEBUG(6,("init_net_r_req_chal: %d\n", __LINE__)); memcpy(r_c->srv_chal.data, srv_chal->data, sizeof(srv_chal->data)); @@ -62,7 +62,7 @@ static void init_net_r_req_chal(NET_R_REQ_CHAL *r_c, #define LOGON_CTRL_REPL_NEEDED 0x01 #define LOGON_CTRL_REPL_IN_PROGRESS 0x02 -uint32 _net_logon_ctrl(pipes_struct *p, NET_Q_LOGON_CTRL *q_u, +NTSTATUS _net_logon_ctrl(pipes_struct *p, NET_Q_LOGON_CTRL *q_u, NET_R_LOGON_CTRL *r_u) { uint32 flags = 0x0; @@ -80,7 +80,7 @@ uint32 _net_logon_ctrl(pipes_struct *p, NET_Q_LOGON_CTRL *q_u, net_reply_logon_ctrl2: *************************************************************************/ -uint32 _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_CTRL2 *r_u) +NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_CTRL2 *r_u) { /* lkclXXXX - guess what - absolutely no idea what these are! */ uint32 flags = 0x0; @@ -105,7 +105,7 @@ uint32 _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_CTR net_reply_trust_dom_list: *************************************************************************/ -uint32 _net_trust_dom_list(pipes_struct *p, NET_Q_TRUST_DOM_LIST *q_u, NET_R_TRUST_DOM_LIST *r_u) +NTSTATUS _net_trust_dom_list(pipes_struct *p, NET_Q_TRUST_DOM_LIST *q_u, NET_R_TRUST_DOM_LIST *r_u) { char *trusted_domain = "test_domain"; uint32 num_trust_domains = 1; @@ -125,7 +125,7 @@ uint32 _net_trust_dom_list(pipes_struct *p, NET_Q_TRUST_DOM_LIST *q_u, NET_R_TRU ***********************************************************************************/ static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, - DOM_CRED *srv_cred, int status) + DOM_CRED *srv_cred, NTSTATUS status) { DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); @@ -194,9 +194,9 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) _net_req_chal *************************************************************************/ -uint32 _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u) +NTSTATUS _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u) { - uint32 status = NT_STATUS_NOPROBLEMO; + NTSTATUS status = NT_STATUS_OK; fstring mach_acct; if (!get_valid_user_struct(p->vuid)) @@ -242,7 +242,7 @@ uint32 _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u) init_net_r_auth: *************************************************************************/ -static void init_net_r_auth(NET_R_AUTH *r_a, DOM_CHAL *resp_cred, int status) +static void init_net_r_auth(NET_R_AUTH *r_a, DOM_CHAL *resp_cred, NTSTATUS status) { memcpy(r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); r_a->status = status; @@ -252,9 +252,9 @@ static void init_net_r_auth(NET_R_AUTH *r_a, DOM_CHAL *resp_cred, int status) _net_auth *************************************************************************/ -uint32 _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) +NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) { - uint32 status = NT_STATUS_NOPROBLEMO; + NTSTATUS status = NT_STATUS_OK; DOM_CHAL srv_cred; UTIME srv_time; @@ -287,7 +287,7 @@ uint32 _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) *************************************************************************/ static void init_net_r_auth_2(NET_R_AUTH_2 *r_a, - DOM_CHAL *resp_cred, NEG_FLAGS *flgs, int status) + DOM_CHAL *resp_cred, NEG_FLAGS *flgs, NTSTATUS status) { memcpy(r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); memcpy(&r_a->srv_flgs, flgs, sizeof(r_a->srv_flgs)); @@ -298,9 +298,9 @@ static void init_net_r_auth_2(NET_R_AUTH_2 *r_a, _net_auth_2 *************************************************************************/ -uint32 _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) +NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) { - uint32 status = NT_STATUS_NOPROBLEMO; + NTSTATUS status = NT_STATUS_OK; DOM_CHAL srv_cred; UTIME srv_time; NEG_FLAGS srv_flgs; @@ -335,9 +335,9 @@ uint32 _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) _net_srv_pwset *************************************************************************/ -uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_u) +NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_u) { - uint32 status = NT_STATUS_WRONG_PASSWORD; + NTSTATUS status = NT_STATUS_WRONG_PASSWORD; DOM_CRED srv_cred; pstring mach_acct; SAM_ACCOUNT *sampass=NULL; @@ -403,7 +403,7 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ unbecome_root(); if (ret) - status = NT_STATUS_NOPROBLEMO; + status = NT_STATUS_OK; /* set up the LSA Server Password Set response */ init_net_r_srv_pwset(r_u, &srv_cred, status); @@ -417,7 +417,7 @@ uint32 _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_ _net_sam_logoff: *************************************************************************/ -uint32 _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF *r_u) +NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF *r_u) { DOM_CRED srv_cred; @@ -435,7 +435,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; } @@ -444,9 +444,9 @@ uint32 _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF _net_logon_any: Use the new authentications subsystem to log in. *************************************************************************/ -static uint32 _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, char *sess_key) +static NTSTATUS _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, char *sess_key) { - uint32 nt_status = NT_STATUS_LOGON_FAILURE; + NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE; unsigned char local_lm_response[24]; unsigned char local_nt_response[24]; @@ -550,10 +550,10 @@ static uint32 _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, cha nt_status = check_password(&user_info, &server_info); - DEBUG(5, ("_net_logon_any: exited with status %d\n", nt_status)); + DEBUG(5, ("_net_logon_any: exited with status %s\n", + get_nt_error_msg(nt_status))); return nt_status; - } @@ -562,9 +562,9 @@ static uint32 _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, cha _net_sam_logon *************************************************************************/ -uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_u) +NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_u) { - uint32 status = NT_STATUS_NOPROBLEMO; + NTSTATUS status = NT_STATUS_OK; NET_USER_INFO_3 *usr_info = NULL; DOM_CRED srv_cred; SAM_ACCOUNT *sampass = NULL; @@ -637,7 +637,7 @@ uint32 _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_ /* Check account and password */ - if (status != NT_STATUS_NOPROBLEMO) + if (NT_STATUS_V(status)) return status; pdb_init_sam(&sampass); diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 4d4d058fba..60250c903f 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -93,7 +93,7 @@ BOOL create_next_pdu(pipes_struct *p) */ if(p->fault_state) { - setup_fault_pdu(p, 0x1c010002); + setup_fault_pdu(p, NT_STATUS(0x1c010002)); return True; } @@ -367,11 +367,12 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm become_root(); - if(!(p->ntlmssp_auth_validated = - pass_check_smb_with_chal(pipe_user_name, domain, - (uchar*)p->challenge, - lm_owf, lm_pw_len, - nt_owf, nt_pw_len) == NT_STATUS_NOPROBLEMO)) { + p->ntlmssp_auth_validated = + NT_STATUS_IS_OK(pass_check_smb_with_chal(pipe_user_name, domain, + (uchar*)p->challenge, + lm_owf, lm_pw_len, + nt_owf, nt_pw_len)); + if (!p->ntlmssp_auth_validated) { DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name )); unbecome_root(); @@ -625,7 +626,7 @@ static BOOL setup_bind_nak(pipes_struct *p) Marshall a fault pdu. *******************************************************************/ -BOOL setup_fault_pdu(pipes_struct *p, uint32 status) +BOOL setup_fault_pdu(pipes_struct *p, NTSTATUS status) { prs_struct outgoing_pdu; RPC_HDR fault_hdr; @@ -1203,7 +1204,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, * and not put the pipe into fault state. JRA. */ DEBUG(4, ("unknown\n")); - setup_fault_pdu(p, 0x1c010002); + setup_fault_pdu(p, NT_STATUS(0x1c010002)); return True; } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 3c8e44d84e..0111733bb0 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -570,7 +570,7 @@ static ssize_t process_complete_pdu(pipes_struct *p) DEBUG(10,("process_complete_pdu: pipe %s in fault state.\n", p->name )); set_incoming_fault(p); - setup_fault_pdu(p, 0x1c010002); + setup_fault_pdu(p, NT_STATUS(0x1c010002)); return (ssize_t)data_len; } @@ -619,7 +619,7 @@ static ssize_t process_complete_pdu(pipes_struct *p) if (!reply) { DEBUG(3,("process_complete_pdu: DCE/RPC fault sent on pipe %s\n", p->pipe_srv_name)); set_incoming_fault(p); - setup_fault_pdu(p, 0x1c010002); + setup_fault_pdu(p, NT_STATUS(0x1c010002)); prs_mem_free(&rpc_in); } else { /* diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index f7263ff266..71abdd517f 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -46,7 +46,7 @@ static void free_reg_info(void *ptr) reg_reply_unknown_1 ********************************************************************/ -uint32 _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) +NTSTATUS _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) { /* set up the REG unknown_1 response */ ZERO_STRUCT(r_u->pol); @@ -55,26 +55,26 @@ 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; } /******************************************************************* reg_reply_open ********************************************************************/ -uint32 _reg_open(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u) +NTSTATUS _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; } /******************************************************************* reg_reply_open_entry ********************************************************************/ -uint32 _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY *r_u) +NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY *r_u) { POLICY_HND pol; fstring name; @@ -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__)); @@ -114,9 +114,9 @@ uint32 _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY reg_reply_info ********************************************************************/ -uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) +NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) { - uint32 status = NT_STATUS_NOPROBLEMO; + NTSTATUS status = NT_STATUS_OK; char *key = NULL; uint32 type=0x1; /* key type: REG_SZ */ @@ -141,7 +141,7 @@ uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) if ( strequal(name, "RefusePasswordChange") ) { type=0xF770; - status = ERRbadfile; + status = NT_STATUS_NO_SUCH_FILE; init_unistr2(uni_key, "", 0); init_buffer2(buf, (uint8*) uni_key->buffer, uni_key->uni_str_len*2); @@ -186,9 +186,9 @@ uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) #define SHUTDOWN_F_STRING "-f" -uint32 _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) +NTSTATUS _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) { - uint32 status = NT_STATUS_NOPROBLEMO; + NTSTATUS status = NT_STATUS_OK; pstring shutdown_script; UNISTR2 unimsg = q_u->uni_msg; pstring message; @@ -223,9 +223,9 @@ uint32 _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) return status; } -uint32 _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABORT_SHUTDOWN *r_u) +NTSTATUS _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABORT_SHUTDOWN *r_u) { - uint32 status = NT_STATUS_NOPROBLEMO; + NTSTATUS status = NT_STATUS_OK; pstring abort_shutdown_script; pstrcpy(abort_shutdown_script, lp_abort_shutdown_script()); diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 6cd0f3b854..f00ecae3ce 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -727,7 +727,7 @@ static BOOL api_samr_set_userinfo(pipes_struct *p) DEBUG(0,("api_samr_set_userinfo: Unable to unmarshall SAMR_Q_SET_USERINFO.\n")); /* Fix for W2K SP2 */ if (q_u.switch_value == 0x1a) { - setup_fault_pdu(p, 0x1c000006); + setup_fault_pdu(p, NT_STATUS(0x1c000006)); return True; } return False; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ba59aa548c..dce082d31d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -88,7 +88,7 @@ static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) dynamically returns the correct user info..... JRA. ********************************************************************/ -static uint32 get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, +static NTSTATUS 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) { @@ -152,10 +152,10 @@ static uint32 get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, if (not_finished) return STATUS_MORE_ENTRIES; else - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } -static uint32 jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, +static NTSTATUS 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) { @@ -232,7 +232,7 @@ static uint32 jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, if (not_finished) return STATUS_MORE_ENTRIES; else - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } #if 0 /* This function appears to be unused! */ @@ -494,9 +494,9 @@ done: _samr_close_hnd ********************************************************************/ -uint32 _samr_close_hnd(pipes_struct *p, SAMR_Q_CLOSE_HND *q_u, SAMR_R_CLOSE_HND *r_u) +NTSTATUS _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)) @@ -511,11 +511,11 @@ uint32 _samr_close_hnd(pipes_struct *p, SAMR_Q_CLOSE_HND *q_u, SAMR_R_CLOSE_HND samr_reply_open_domain ********************************************************************/ -uint32 _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN_DOMAIN *r_u) +NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN_DOMAIN *r_u) { 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)) @@ -540,8 +540,8 @@ uint32 _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN_D static uint32 get_lsa_policy_samr_rid(struct samr_info *info) { if (!info) { - DEBUG(3,("Error getting policy\n")); - return 0xffffffff; + DEBUG(3,("Error getting policy\n")); + return 0xffffffff; } return info->sid.sub_auths[info->sid.num_auths-1]; @@ -551,11 +551,11 @@ static uint32 get_lsa_policy_samr_rid(struct samr_info *info) _samr_get_usrdom_pwinfo ********************************************************************/ -uint32 _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, SAMR_R_GET_USRDOM_PWINFO *r_u) +NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, SAMR_R_GET_USRDOM_PWINFO *r_u) { 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)) { @@ -567,7 +567,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__)); @@ -578,7 +578,7 @@ uint32 _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, S samr_make_usr_obj_sd ********************************************************************/ -static uint32 samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC_BUF **buf, DOM_SID *usr_sid) +static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC_BUF **buf, DOM_SID *usr_sid) { extern DOM_SID global_sid_World; DOM_SID adm_sid; @@ -616,7 +616,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) @@ -638,11 +638,11 @@ static BOOL get_lsa_policy_samr_sid(pipes_struct *p, POLICY_HND *pol, DOM_SID *s _samr_query_sec_obj ********************************************************************/ -uint32 _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_QUERY_SEC_OBJ *r_u) +NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_QUERY_SEC_OBJ *r_u) { DOM_SID pol_sid; - r_u->status = NT_STATUS_NOPROBLEMO; + r_u->status = NT_STATUS_OK; /* Get the SID. */ @@ -651,7 +651,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 (NT_STATUS_IS_OK(r_u->status)) r_u->ptr = 1; return r_u->status; @@ -701,13 +701,13 @@ static void make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNISTR samr_reply_enum_dom_users ********************************************************************/ -uint32 _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_R_ENUM_DOM_USERS *r_u) +NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_R_ENUM_DOM_USERS *r_u) { SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; 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)) @@ -720,7 +720,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 (NT_STATUS_IS_ERR(r_u->status)) return r_u->status; samr_clear_passwd_fields(pass, num_entries); @@ -791,7 +791,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(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, +static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, uint32 *p_num_entries, uint32 max_entries) { fstring sid_str; @@ -902,14 +902,14 @@ static BOOL get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID DEBUG(10,("get_group_alias_entries: returning %d entries\n", *p_num_entries)); - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /******************************************************************* Get the group entries - similar to get_sampwd_entries(). ********************************************************************/ -static uint32 get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, +static NTSTATUS get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, uint32 *p_num_entries, uint32 max_entries) { GROUP_MAP *map=NULL; @@ -946,7 +946,7 @@ static uint32 get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_ *p_num_entries = num_entries; - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /******************************************************************* @@ -955,13 +955,13 @@ static uint32 get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_ a real PDC. JRA. ********************************************************************/ -uint32 _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_R_ENUM_DOM_GROUPS *r_u) +NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_R_ENUM_DOM_GROUPS *r_u) { DOMAIN_GRP *grp=NULL; 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; @@ -985,14 +985,15 @@ uint32 _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_ samr_reply_enum_dom_aliases ********************************************************************/ -uint32 _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, SAMR_R_ENUM_DOM_ALIASES *r_u) +NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, SAMR_R_ENUM_DOM_ALIASES *r_u) { DOMAIN_GRP *grp=NULL; uint32 num_entries = 0; fstring sid_str; DOM_SID sid; + NTSTATUS status; - 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; @@ -1000,8 +1001,9 @@ 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(p->mem_ctx, &grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES)!=NT_STATUS_NOPROBLEMO) - return NT_STATUS_ACCESS_DENIED; + status = get_group_alias_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, + &num_entries, MAX_SAM_ENTRIES); + if (NT_STATUS_IS_ERR(status)) return status; make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp); @@ -1018,7 +1020,7 @@ uint32 _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, SAM samr_reply_query_dispinfo ********************************************************************/ -uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_QUERY_DISPINFO *r_u) +NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_QUERY_DISPINFO *r_u) { SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; DOMAIN_GRP *grps=NULL; @@ -1028,12 +1030,12 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ int total_entries = 0; uint32 data_size = 0; DOM_SID sid; - uint32 disp_ret; + NTSTATUS disp_ret; SAM_DISPINFO_CTR *ctr; 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; @@ -1072,7 +1074,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_NOPROBLEMO) { + if (NT_STATUS_IS_ERR(r_u->status)) { DEBUG(5, ("get_sampwd_entries: failed\n")); return r_u->status; } @@ -1080,8 +1082,8 @@ 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(p->mem_ctx, &grps, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); - if (r_u->status != NT_STATUS_NOPROBLEMO) - return NT_STATUS_ACCESS_DENIED; + if (NT_STATUS_IS_ERR(r_u->status)) + return r_u->status; break; default: DEBUG(0,("_samr_query_dispinfo: Unknown info level (%u)\n", (unsigned int)q_u->switch_level )); @@ -1116,7 +1118,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ 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_NOPROBLEMO) + if (NT_STATUS_IS_ERR(disp_ret)) return disp_ret; break; case 0x2: @@ -1125,7 +1127,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ 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_NOPROBLEMO) + if (NT_STATUS_IS_ERR(disp_ret)) return disp_ret; break; case 0x3: @@ -1134,7 +1136,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ 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_NOPROBLEMO) + if (NT_STATUS_IS_ERR(disp_ret)) return disp_ret; break; case 0x4: @@ -1143,7 +1145,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ 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_NOPROBLEMO) + if (NT_STATUS_IS_ERR(disp_ret)) return disp_ret; break; case 0x5: @@ -1152,7 +1154,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ 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_NOPROBLEMO) + if (NT_STATUS_IS_ERR(disp_ret)) return disp_ret; break; default: @@ -1174,7 +1176,7 @@ uint32 _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_ samr_reply_query_aliasinfo ********************************************************************/ -uint32 _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_R_QUERY_ALIASINFO *r_u) +NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_R_QUERY_ALIASINFO *r_u) { fstring alias_desc = "Local Unix group"; fstring alias=""; @@ -1182,7 +1184,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__)); @@ -1222,7 +1224,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__)); @@ -1264,7 +1266,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__)); @@ -1276,7 +1278,7 @@ uint32 _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_ _samr_lookup_names ********************************************************************/ -uint32 _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOKUP_NAMES *r_u) +NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOKUP_NAMES *r_u) { uint32 rid[MAX_SAM_ENTRIES]; enum SID_NAME_USE type[MAX_SAM_ENTRIES]; @@ -1284,7 +1286,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__)); @@ -1315,7 +1317,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; } } } @@ -1331,14 +1333,14 @@ uint32 _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOK _samr_chgpasswd_user ********************************************************************/ -uint32 _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_R_CHGPASSWD_USER *r_u) +NTSTATUS _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_R_CHGPASSWD_USER *r_u) { fstring user_name; fstring wks; DEBUG(5,("_samr_chgpasswd_user: %d\n", __LINE__)); - r_u->status = NT_STATUS_NOPROBLEMO; + r_u->status = NT_STATUS_OK; rpcstr_pull(user_name, q_u->uni_user_name.buffer, sizeof(user_name), q_u->uni_user_name.uni_str_len*2, 0); rpcstr_pull(wks, q_u->uni_dest_host.buffer, sizeof(wks), q_u->uni_dest_host.uni_str_len,0); @@ -1409,7 +1411,7 @@ static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, fstring nam _samr_lookup_rids ********************************************************************/ -uint32 _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP_RIDS *r_u) +NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP_RIDS *r_u) { fstring group_names[MAX_SAM_ENTRIES]; uint32 *group_attrs = NULL; @@ -1419,7 +1421,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__)); @@ -1453,7 +1455,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); DEBUG(5,("_samr_lookup_rids: %s:%d\n", group_names[i], group_attrs[i])); @@ -1475,7 +1477,7 @@ uint32 _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP _api_samr_open_user. Safe - gives out no passwd info. ********************************************************************/ -uint32 _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USER *r_u) +NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USER *r_u) { SAM_ACCOUNT *sampass=NULL; DOM_SID sid; @@ -1485,7 +1487,7 @@ uint32 _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_U struct samr_info *info = NULL; BOOL ret; - r_u->status = NT_STATUS_NOPROBLEMO; + r_u->status = NT_STATUS_OK; /* find the domain policy handle. */ if (!find_policy_by_hnd(p, &domain_pol, NULL)) @@ -1571,7 +1573,7 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) user. JRA. *************************************************************************/ -static uint32 get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint32 user_rid) +static NTSTATUS get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint32 user_rid) { SAM_ACCOUNT *smbpass=NULL; BOOL ret; @@ -1607,7 +1609,7 @@ static uint32 get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint32 pdb_free_sam(smbpass); - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /************************************************************************* @@ -1690,13 +1692,13 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) _samr_query_userinfo ********************************************************************/ -uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_QUERY_USERINFO *r_u) +NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_QUERY_USERINFO *r_u) { SAM_USERINFO_CTR *ctr; uint32 rid = 0; struct samr_info *info = NULL; - r_u->status=NT_STATUS_NOPROBLEMO; + r_u->status=NT_STATUS_OK; /* search for the handle */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) @@ -1758,7 +1760,7 @@ uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_ 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 (NT_STATUS_IS_ERR(r_u->status = get_user_info_12(p, ctr->info.id12, rid))) return r_u->status; break; @@ -1793,7 +1795,7 @@ uint32 _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_ samr_reply_query_usergroups ********************************************************************/ -uint32 _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAMR_R_QUERY_USERGROUPS *r_u) +NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAMR_R_QUERY_USERGROUPS *r_u) { SAM_ACCOUNT *sam_pass=NULL; DOM_GID *gids = NULL; @@ -1803,7 +1805,7 @@ uint32 _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAM struct samr_info *info = NULL; BOOL ret; - r_u->status = NT_STATUS_NOPROBLEMO; + r_u->status = NT_STATUS_OK; DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__)); @@ -1844,7 +1846,7 @@ uint32 _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAM _samr_query_dom_info ********************************************************************/ -uint32 _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR_R_QUERY_DOMAIN_INFO *r_u) +NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR_R_QUERY_DOMAIN_INFO *r_u) { SAM_UNK_CTR *ctr; @@ -1853,7 +1855,7 @@ uint32 _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR ZERO_STRUCTP(ctr); - r_u->status = NT_STATUS_NOPROBLEMO; + r_u->status = NT_STATUS_OK; DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); @@ -1888,7 +1890,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__)); @@ -1899,7 +1901,7 @@ uint32 _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR _api_samr_create_user ********************************************************************/ -uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREATE_USER *r_u) +NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREATE_USER *r_u) { SAM_ACCOUNT *sam_pass=NULL; fstring mach_acct; @@ -2018,20 +2020,20 @@ uint32 _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CR pdb_free_sam(sam_pass); - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /******************************************************************* samr_reply_connect_anon ********************************************************************/ -uint32 _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CONNECT_ANON *r_u) +NTSTATUS _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CONNECT_ANON *r_u) { struct samr_info *info = NULL; /* set up the SAMR connect_anon response */ - r_u->status = NT_STATUS_NOPROBLEMO; + 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) @@ -2051,13 +2053,13 @@ uint32 _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CONN samr_reply_connect ********************************************************************/ -uint32 _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u) +NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u) { struct samr_info *info = NULL; DEBUG(5,("_samr_connect: %d\n", __LINE__)); - r_u->status = NT_STATUS_NOPROBLEMO; + 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) @@ -2079,9 +2081,9 @@ uint32 _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u) api_samr_lookup_domain **********************************************************************/ -uint32 _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_LOOKUP_DOMAIN *r_u) +NTSTATUS _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_LOOKUP_DOMAIN *r_u) { - r_u->status = NT_STATUS_NOPROBLEMO; + r_u->status = NT_STATUS_OK; if (!find_policy_by_hnd(p, &q_u->connect_pol, NULL)) return NT_STATUS_INVALID_HANDLE; @@ -2135,12 +2137,12 @@ static BOOL make_enum_domains(TALLOC_CTX *ctx, SAM_ENTRY **pp_sam, api_samr_enum_domains **********************************************************************/ -uint32 _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_ENUM_DOMAINS *r_u) +NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_ENUM_DOMAINS *r_u) { uint32 num_entries = 2; fstring dom[2]; - r_u->status = NT_STATUS_NOPROBLEMO; + r_u->status = NT_STATUS_OK; fstrcpy(dom[0],global_myworkgroup); fstrcpy(dom[1],"Builtin"); @@ -2157,7 +2159,7 @@ uint32 _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_ENUM api_samr_open_alias ********************************************************************/ -uint32 _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_ALIAS *r_u) +NTSTATUS _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_ALIAS *r_u) { DOM_SID sid; POLICY_HND domain_pol = q_u->dom_pol; @@ -2165,7 +2167,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_NOPROBLEMO; + r_u->status = NT_STATUS_OK; /* get the domain policy. */ if (!find_policy_by_hnd(p, &domain_pol, NULL)) @@ -2448,7 +2450,7 @@ static BOOL set_user_info_pw(char *pass, uint32 rid) samr_reply_set_userinfo ********************************************************************/ -uint32 _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_USERINFO *r_u) +NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_USERINFO *r_u) { uint32 rid = 0x0; DOM_SID sid; @@ -2462,7 +2464,7 @@ uint32 _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_ 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)); @@ -2563,7 +2565,7 @@ uint32 _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_ samr_reply_set_userinfo2 ********************************************************************/ -uint32 _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SET_USERINFO2 *r_u) +NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SET_USERINFO2 *r_u) { DOM_SID sid; uint32 rid = 0x0; @@ -2573,7 +2575,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)) @@ -2616,7 +2618,7 @@ uint32 _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SE _samr_query_aliasmem *********************************************************************/ -uint32 _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, SAMR_R_QUERY_USERALIASES *r_u) +NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, SAMR_R_QUERY_USERALIASES *r_u) { uint32 *rid=NULL; int num_rids; @@ -2630,9 +2632,9 @@ uint32 _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, S rid[0] = BUILTIN_ALIAS_RID_USERS; - init_samr_r_query_useraliases(r_u, num_rids, rid, NT_STATUS_NOPROBLEMO); + init_samr_r_query_useraliases(r_u, num_rids, rid, NT_STATUS_OK); - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } @@ -2640,7 +2642,7 @@ uint32 _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, S _samr_query_aliasmem *********************************************************************/ -uint32 _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_QUERY_ALIASMEM *r_u) +NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_QUERY_ALIASMEM *r_u) { int i; @@ -2694,16 +2696,16 @@ uint32 _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_ } DEBUG(10, ("sid is %s\n", alias_sid_str)); - init_samr_r_query_aliasmem(r_u, num_uids, sid, NT_STATUS_NOPROBLEMO); + init_samr_r_query_aliasmem(r_u, num_uids, sid, NT_STATUS_OK); - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /********************************************************************* _samr_query_groupmem *********************************************************************/ -uint32 _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_QUERY_GROUPMEM *r_u) +NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_QUERY_GROUPMEM *r_u) { int num_uids = 0; int i; @@ -2752,16 +2754,16 @@ uint32 _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_ attr[i] = SID_NAME_USER; } - init_samr_r_query_groupmem(r_u, num_uids, rid, attr, NT_STATUS_NOPROBLEMO); + init_samr_r_query_groupmem(r_u, num_uids, rid, attr, NT_STATUS_OK); - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /********************************************************************* _samr_add_aliasmem *********************************************************************/ -uint32 _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_ADD_ALIASMEM *r_u) +NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_ADD_ALIASMEM *r_u) { DOM_SID alias_sid; fstring alias_sid_str; @@ -2820,24 +2822,24 @@ uint32 _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_ADD_ if(!user_in_group_list(pwd->pw_name, grp_name)) return NT_STATUS_MEMBER_NOT_IN_ALIAS; /* don't know what to reply else */ - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /********************************************************************* _samr_del_aliasmem *********************************************************************/ -uint32 _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DEL_ALIASMEM *r_u) +NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DEL_ALIASMEM *r_u) { - DEBUG(0,("_samr_del_aliasmem: Not yet implemented.\n")); - return False; + DEBUG(0,("_samr_del_aliasmem: Not yet implemented.\n")); + return NT_STATUS_NOT_IMPLEMENTED; } /********************************************************************* _samr_add_groupmem *********************************************************************/ -uint32 _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_ADD_GROUPMEM *r_u) +NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_ADD_GROUPMEM *r_u) { DOM_SID group_sid; fstring group_sid_str; @@ -2886,34 +2888,34 @@ uint32 _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_ADD_ if(!user_in_group_list(pwd->pw_name, grp_name)) return NT_STATUS_MEMBER_NOT_IN_GROUP; /* don't know what to reply else */ - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /********************************************************************* _samr_del_groupmem *********************************************************************/ -uint32 _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DEL_GROUPMEM *r_u) +NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DEL_GROUPMEM *r_u) { - DEBUG(0,("_samr_del_groupmem: Not yet implemented.\n")); - return False; + DEBUG(0,("_samr_del_groupmem: Not yet implemented.\n")); + return NT_STATUS_NOT_IMPLEMENTED; } /********************************************************************* _samr_delete_dom_user *********************************************************************/ -uint32 _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAMR_R_DELETE_DOM_USER *r_u ) +NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAMR_R_DELETE_DOM_USER *r_u ) { - DEBUG(0,("_samr_delete_dom_user: Not yet implemented.\n")); - return False; + DEBUG(0,("_samr_delete_dom_user: Not yet implemented.\n")); + return NT_STATUS_NOT_IMPLEMENTED; } /********************************************************************* _samr_delete_dom_group *********************************************************************/ -uint32 _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, SAMR_R_DELETE_DOM_GROUP *r_u) +NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, SAMR_R_DELETE_DOM_GROUP *r_u) { DOM_SID group_sid; DOM_SID dom_sid; @@ -2963,14 +2965,14 @@ uint32 _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, SAM if (!close_policy_hnd(p, &q_u->group_pol)) return NT_STATUS_OBJECT_NAME_INVALID; - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /********************************************************************* _samr_delete_dom_alias *********************************************************************/ -uint32 _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, SAMR_R_DELETE_DOM_ALIAS *r_u) +NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, SAMR_R_DELETE_DOM_ALIAS *r_u) { DOM_SID alias_sid; DOM_SID dom_sid; @@ -3020,14 +3022,14 @@ uint32 _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, SAM if (!close_policy_hnd(p, &q_u->alias_pol)) return NT_STATUS_OBJECT_NAME_INVALID; - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /********************************************************************* _samr_create_dom_group *********************************************************************/ -uint32 _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, SAMR_R_CREATE_DOM_GROUP *r_u) +NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, SAMR_R_CREATE_DOM_GROUP *r_u) { DOM_SID dom_sid; DOM_SID info_sid; @@ -3077,14 +3079,14 @@ uint32 _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, SAM if (!create_policy_hnd(p, &r_u->pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /********************************************************************* _samr_create_dom_alias *********************************************************************/ -uint32 _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, SAMR_R_CREATE_DOM_ALIAS *r_u) +NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, SAMR_R_CREATE_DOM_ALIAS *r_u) { DOM_SID dom_sid; fstring name; @@ -3133,7 +3135,7 @@ uint32 _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, SAM if (!create_policy_hnd(p, &r_u->alias_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /********************************************************************* @@ -3143,7 +3145,7 @@ sends the name/comment pair of a domain group level 1 send also the number of users of that group *********************************************************************/ -uint32 _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAMR_R_QUERY_GROUPINFO *r_u) +NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAMR_R_QUERY_GROUPINFO *r_u) { DOM_SID group_sid; GROUP_MAP map; @@ -3177,9 +3179,9 @@ uint32 _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAMR_ return NT_STATUS_INVALID_INFO_CLASS; } - init_samr_r_query_groupinfo(r_u, ctr, NT_STATUS_NOPROBLEMO); + init_samr_r_query_groupinfo(r_u, ctr, NT_STATUS_OK); - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /********************************************************************* @@ -3188,7 +3190,7 @@ uint32 _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAMR_ update a domain group's comment. *********************************************************************/ -uint32 _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_SET_GROUPINFO *r_u) +NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_SET_GROUPINFO *r_u) { DOM_SID group_sid; GROUP_MAP map; @@ -3216,7 +3218,7 @@ uint32 _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_SE if(!add_mapping_entry(&map, TDB_REPLACE)) return NT_STATUS_NO_SUCH_GROUP; - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /********************************************************************* @@ -3225,7 +3227,7 @@ uint32 _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_SE update a domain group's comment. *********************************************************************/ -uint32 _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_SET_ALIASINFO *r_u) +NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_SET_ALIASINFO *r_u) { DOM_SID group_sid; GROUP_MAP map; @@ -3250,24 +3252,24 @@ uint32 _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_SE if(!add_mapping_entry(&map, TDB_REPLACE)) return NT_STATUS_NO_SUCH_GROUP; - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /********************************************************************* _samr_get_dom_pwinfo *********************************************************************/ -uint32 _samr_get_dom_pwinfo(pipes_struct *p, SAMR_Q_GET_DOM_PWINFO *q_u, SAMR_R_GET_DOM_PWINFO *r_u) +NTSTATUS _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; } /********************************************************************* _samr_open_group *********************************************************************/ -uint32 _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_GROUP *r_u) +NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_GROUP *r_u) { DOM_SID sid; GROUP_MAP map; @@ -3300,15 +3302,15 @@ uint32 _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_GRO if (!create_policy_hnd(p, &r_u->pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - return NT_STATUS_NOPROBLEMO; + return NT_STATUS_OK; } /********************************************************************* _samr_unknown_2d *********************************************************************/ -uint32 _samr_unknown_2d(pipes_struct *p, SAMR_Q_UNKNOWN_2D *q_u, SAMR_R_UNKNOWN_2D *r_u) +NTSTATUS _samr_unknown_2d(pipes_struct *p, SAMR_Q_UNKNOWN_2D *q_u, SAMR_R_UNKNOWN_2D *r_u) { - DEBUG(0,("_samr_unknown_2d: Not yet implemented.\n")); - return False; + DEBUG(0,("_samr_unknown_2d: Not yet implemented.\n")); + return NT_STATUS_NOT_IMPLEMENTED; } diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 3500a4f3e1..011efb1bac 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/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_NOPROBLEMO; + 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/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0710f05870..0ebbc2aada 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -160,7 +160,7 @@ static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp) static void srv_spoolss_replycloseprinter(POLICY_HND *handle) { - uint32 status; + NTSTATUS status; /* weird if the test succeds !!! */ if (smb_connections==0) { @@ -270,18 +270,18 @@ static BOOL close_printer_handle(pipes_struct *p, POLICY_HND *hnd) /**************************************************************************** delete a printer given a handle ****************************************************************************/ -static uint32 delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) +static NTSTATUS delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) { Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); if (!Printer) { DEBUG(0,("delete_printer_handle: Invalid handle (%s)\n", OUR_HANDLE(hnd))); - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } if (del_a_printer(Printer->dev.handlename) != 0) { DEBUG(3,("Error deleting printer %s\n", Printer->dev.handlename)); - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } /* Check calling user has permission to delete printer. Note that @@ -291,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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } if (*lp_deleteprinter_cmd()) { @@ -308,7 +308,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 ERRbadfid; /* What to return here? */ + return NT_STATUS_INVALID_HANDLE; /* What to return here? */ } DEBUGADD(10,("returned [%d]\n", ret)); @@ -317,12 +317,12 @@ static uint32 delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) if ( ( i = lp_servicenumber( Printer->dev.handlename ) ) >= 0 ) { lp_killservice( i ); - return ERRsuccess; + return NT_STATUS_OK; } else - return ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** @@ -618,7 +618,7 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) { fstring printer; - uint32 status; + NTSTATUS status; struct pipes_struct *p; struct policy *pol; struct handle_list *hl; @@ -706,10 +706,10 @@ static BOOL srv_spoolss_sendnotify(pipes_struct *p, POLICY_HND *handle) * called from the spoolss dispatcher ********************************************************************/ -uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, SPOOL_R_OPEN_PRINTER_EX *r_u) +NTSTATUS _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 = ERRsuccess; + uint32 result = NT_STATUS_OK; #endif UNISTR2 *printername = NULL; @@ -726,7 +726,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, printername = &q_u->printername; if (printername == NULL) - return ERRinvalidprintername; + return NT_STATUS_OBJECT_NAME_INVALID; /* some sanity check because you can open a printer or a print server */ /* aka: \\server\printer or \\server */ @@ -735,7 +735,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 ERRinvalidprintername; + return NT_STATUS_OBJECT_NAME_INVALID; /* if (printer_default->datatype_ptr != NULL) @@ -749,7 +749,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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } /* @@ -779,7 +779,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 ERRsuccess; + return NT_STATUS_OK; } else if ((printer_default->access_required & SERVER_ACCESS_ADMINISTER ) == SERVER_ACCESS_ADMINISTER) { @@ -788,14 +788,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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } else if (user.uid == 0 || user_in_list(uidtoname(user.uid), lp_printer_admin(snum))) { - return ERRsuccess; + return NT_STATUS_OK; } else { close_printer_handle(p, handle); - return ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } } } @@ -805,7 +805,7 @@ 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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; /* map an empty access mask to the minimum access mask */ if (printer_default->access_required == 0x0) @@ -826,7 +826,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, if (!print_access_check(&user, snum, printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); close_printer_handle(p, handle); - return ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } /* @@ -905,7 +905,7 @@ uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, #endif } - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** @@ -1021,27 +1021,27 @@ BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, * _spoolss_enddocprinter_internal. ********************************************************************/ -static uint32 _spoolss_enddocprinter_internal(pipes_struct *p, POLICY_HND *handle) +static NTSTATUS _spoolss_enddocprinter_internal(pipes_struct *p, POLICY_HND *handle) { Printer_entry *Printer=find_printer_index_by_hnd(p, handle); if (!Printer) { DEBUG(0,("_spoolss_enddocprinter_internal: Invalid handle (%s)\n", OUR_HANDLE(handle))); - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } Printer->document_started=False; print_job_end(Printer->jobid,True); /* error codes unhandled so far ... */ - return 0x0; + return NT_STATUS_OK; } /******************************************************************** * api_spoolss_closeprinter ********************************************************************/ -uint32 _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL_R_CLOSEPRINTER *r_u) +NTSTATUS _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL_R_CLOSEPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; @@ -1053,9 +1053,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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; - return ERRsuccess; + return NT_STATUS_OK; } /******************************************************************** @@ -1063,12 +1063,11 @@ uint32 _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL_R ********************************************************************/ -uint32 _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL_R_DELETEPRINTER *r_u) +NTSTATUS _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL_R_DELETEPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; - Printer_entry *Printer=find_printer_index_by_hnd(p, handle); - uint32 result; + NTSTATUS result; if (Printer && Printer->document_started) _spoolss_enddocprinter_internal(p, handle); /* print job was not closed */ @@ -1077,7 +1076,7 @@ uint32 _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL result = delete_printer_handle(p, handle); - if (result == ERRsuccess) { + if (NT_STATUS_IS_OK(result)) { srv_spoolss_sendnotify(p, handle); } @@ -1125,7 +1124,7 @@ static int get_version_id (char * arch) * --jerry ********************************************************************/ -uint32 _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER *q_u, +NTSTATUS _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER *q_u, SPOOL_R_DELETEPRINTERDRIVER *r_u) { fstring driver; @@ -1138,21 +1137,18 @@ 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 ERRinvalidenvironment; + return NT_STATUS_REVISION_MISMATCH; } ZERO_STRUCT(info); if (get_a_printer_driver (&info, 3, driver, arch, version) != 0) { - /* this is what NT returns */ - return ERRunknownprinterdriver; + return NT_STATUS_DRIVER_ORDINAL_NOT_FOUND; } if (printer_driver_in_use(arch, driver)) { - /* this is what NT returns */ - return ERRprinterdriverinuse; + return NT_STATUS_NETWORK_BUSY; } return delete_printer_driver(info.info_3); @@ -1297,7 +1293,7 @@ static BOOL getprinterdata_printer(pipes_struct *p, TALLOC_CTX *ctx, POLICY_HND * spoolss_getprinterdata ********************************************************************/ -uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPOOL_R_GETPRINTERDATA *r_u) +NTSTATUS _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPOOL_R_GETPRINTERDATA *r_u) { POLICY_HND *handle = &q_u->handle; UNISTR2 *valuename = &q_u->valuename; @@ -1328,9 +1324,9 @@ uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO if (!Printer) { if((*data=(uint8 *)malloc(4*sizeof(uint8))) == NULL) - return ERRnomem; + return NT_STATUS_NO_MEMORY; DEBUG(0,("_spoolss_getprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } unistr2_to_ascii(value, valuename, sizeof(value)-1); @@ -1345,18 +1341,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 ERRnomem; + return NT_STATUS_NO_MEMORY; } else { *data = NULL; } - return ERRinvalidparam; + return NT_STATUS_INVALID_PARAMETER; } if (*needed > *out_size) - return ERRmoredata; + return STATUS_MORE_ENTRIES; else { - return ERRsuccess; + return NT_STATUS_OK; } } @@ -1365,7 +1361,7 @@ uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO ****************************************************************************/ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle) { - uint32 status; + NTSTATUS status; /* * If it's the first connection, contact the client @@ -1402,7 +1398,7 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin * called from api_spoolss_rffpcnex ********************************************************************/ -uint32 _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNEX *r_u) +NTSTATUS _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNEX *r_u) { POLICY_HND *handle = &q_u->handle; uint32 flags = q_u->flags; @@ -1417,7 +1413,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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } Printer->notify.flags=flags; @@ -1437,7 +1433,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 ERRsuccess; + return NT_STATUS_OK; } /******************************************************************* @@ -2338,7 +2334,7 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, * ********************************************************************/ -static uint32 printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, +static NTSTATUS printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, TALLOC_CTX *mem_ctx) { @@ -2386,7 +2382,7 @@ static uint32 printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, } */ - return ERRsuccess; + return NT_STATUS_OK; } /******************************************************************* @@ -2469,14 +2465,14 @@ 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 ERRsuccess; + return NT_STATUS_OK; } /******************************************************************** * spoolss_rfnpcnex ********************************************************************/ -uint32 _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCNEX *r_u) +NTSTATUS _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCNEX *r_u) { POLICY_HND *handle = &q_u->handle; /* uint32 change = q_u->change; - notused. */ @@ -2484,7 +2480,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 = ERRbadfid; + NTSTATUS result = NT_STATUS_INVALID_HANDLE; /* we always have a NOTIFY_INFO struct */ r_u->info_ptr=0x1; @@ -2941,7 +2937,7 @@ static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 of return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /******************************************************************** @@ -3023,7 +3019,7 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /******************************************************************** @@ -3097,13 +3093,13 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /******************************************************************** * handle enumeration of printers at level 1 ********************************************************************/ -static uint32 enumprinters_level1( uint32 flags, fstring name, +static NTSTATUS enumprinters_level1( uint32 flags, fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { @@ -3121,13 +3117,13 @@ 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 ERRsuccess; /* NT4sp5 does that */ + return NT_STATUS_OK; /* NT4sp5 does that */ } /******************************************************************** * handle enumeration of printers at level 2 ********************************************************************/ -static uint32 enumprinters_level2( uint32 flags, fstring servername, +static NTSTATUS enumprinters_level2( uint32 flags, fstring servername, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { @@ -3153,18 +3149,18 @@ static uint32 enumprinters_level2( uint32 flags, fstring servername, if (flags & PRINTER_ENUM_REMOTE) return ERRunknownlevel; - return ERRsuccess; + return NT_STATUS_OK; } /******************************************************************** * handle enumeration of printers at level 5 ********************************************************************/ -static uint32 enumprinters_level5( uint32 flags, fstring servername, +static NTSTATUS enumprinters_level5( uint32 flags, fstring servername, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { /* return enum_all_printers_info_5(buffer, offered, needed, returned);*/ - return ERRsuccess; + return NT_STATUS_OK; } /******************************************************************** @@ -3173,7 +3169,7 @@ static uint32 enumprinters_level5( uint32 flags, fstring servername, * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -uint32 _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_R_ENUMPRINTERS *r_u) +NTSTATUS _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_R_ENUMPRINTERS *r_u) { uint32 flags = q_u->flags; UNISTR2 *servername = &q_u->servername; @@ -3226,7 +3222,7 @@ uint32 _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ /**************************************************************************** ****************************************************************************/ -static uint32 getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static NTSTATUS getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_0 *printer=NULL; @@ -3253,12 +3249,12 @@ static uint32 getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, u return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -static uint32 getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static NTSTATUS getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_1 *printer=NULL; @@ -3285,12 +3281,12 @@ static uint32 getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, u return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -static uint32 getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static NTSTATUS getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_2 *printer=NULL; @@ -3320,12 +3316,12 @@ static uint32 getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, u return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -static uint32 getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static NTSTATUS getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_3 *printer=NULL; @@ -3350,13 +3346,13 @@ static uint32 getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, u return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GETPRINTER *r_u) +NTSTATUS _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GETPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; uint32 level = q_u->level; @@ -3373,7 +3369,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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; switch (level) { case 0: @@ -3400,7 +3396,7 @@ static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_IN /******************************************************************** * construct_printer_driver_info_1 ********************************************************************/ -static uint32 construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fstring servername, fstring architecture, uint32 version) +static NTSTATUS construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -3417,7 +3413,7 @@ static uint32 construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fst free_a_printer(&printer,2); - return ERRsuccess; + return NT_STATUS_OK; } /******************************************************************** @@ -3457,7 +3453,7 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_IN * construct_printer_driver_info_2 * fill a printer_info_2 struct ********************************************************************/ -static uint32 construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstring servername, fstring architecture, uint32 version) +static NTSTATUS construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -3475,7 +3471,7 @@ static uint32 construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fst free_a_printer(&printer,2); - return ERRsuccess; + return NT_STATUS_OK; } /******************************************************************** @@ -3570,11 +3566,11 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN * construct_printer_info_3 * fill a printer_info_3 struct ********************************************************************/ -static uint32 construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fstring servername, fstring architecture, uint32 version) +static NTSTATUS construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; - uint32 status=0; + NTSTATUS status=0; ZERO_STRUCT(driver); status=get_a_printer(&printer, 2, lp_servicename(snum) ); @@ -3593,7 +3589,7 @@ static uint32 construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst free_a_printer(&printer,2); - return ERRsuccess; + return NT_STATUS_OK; } /******************************************************************** @@ -3664,11 +3660,11 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN * construct_printer_info_6 * fill a printer_info_6 struct ********************************************************************/ -static uint32 construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fstring servername, fstring architecture, uint32 version) +static NTSTATUS construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; - uint32 status=0; + NTSTATUS status=0; ZERO_STRUCT(driver); status=get_a_printer(&printer, 2, lp_servicename(snum) ); @@ -3702,7 +3698,7 @@ static uint32 construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fst free_a_printer(&printer,2); - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** @@ -3724,16 +3720,16 @@ static void free_printer_driver_info_6(DRIVER_INFO_6 *info) /**************************************************************************** ****************************************************************************/ -static uint32 getprinterdriver2_level1(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static NTSTATUS getprinterdriver2_level1(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_1 *info=NULL; - uint32 status; + NTSTATUS status; if((info=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1))) == NULL) return ERRnomem; status=construct_printer_driver_info_1(info, snum, servername, architecture, version); - if (status != ERRsuccess) { + if (status != NT_STATUS_OK) { safe_free(info); return status; } @@ -3755,21 +3751,21 @@ static uint32 getprinterdriver2_level1(fstring servername, fstring architecture, if (*needed > offered) return ERRinsufficientbuffer; else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -static uint32 getprinterdriver2_level2(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static NTSTATUS getprinterdriver2_level2(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_2 *info=NULL; - uint32 status; + NTSTATUS status; if((info=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2))) == NULL) return ERRnomem; status=construct_printer_driver_info_2(info, snum, servername, architecture, version); - if (status != ERRsuccess) { + if (status != NT_STATUS_OK) { safe_free(info); return status; } @@ -3791,20 +3787,20 @@ static uint32 getprinterdriver2_level2(fstring servername, fstring architecture, if (*needed > offered) return ERRinsufficientbuffer; else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -static uint32 getprinterdriver2_level3(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static NTSTATUS getprinterdriver2_level3(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_3 info; - uint32 status; + NTSTATUS status; ZERO_STRUCT(info); status=construct_printer_driver_info_3(&info, snum, servername, architecture, version); - if (status != ERRsuccess) { + if (status != NT_STATUS_OK) { return status; } @@ -3824,20 +3820,20 @@ static uint32 getprinterdriver2_level3(fstring servername, fstring architecture, if (*needed > offered) return ERRinsufficientbuffer; else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -static uint32 getprinterdriver2_level6(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static NTSTATUS getprinterdriver2_level6(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_6 info; - uint32 status; + NTSTATUS status; ZERO_STRUCT(info); status=construct_printer_driver_info_6(&info, snum, servername, architecture, version); - if (status != ERRsuccess) { + if (status != NT_STATUS_OK) { return status; } @@ -3857,13 +3853,13 @@ static uint32 getprinterdriver2_level6(fstring servername, fstring architecture, if (*needed > offered) return ERRinsufficientbuffer; else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_u, SPOOL_R_GETPRINTERDRIVER2 *r_u) +NTSTATUS _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_u, SPOOL_R_GETPRINTERDRIVER2 *r_u) { POLICY_HND *handle = &q_u->handle; UNISTR2 *uni_arch = &q_u->architecture; @@ -3894,7 +3890,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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; switch (level) { case 1: @@ -3913,7 +3909,7 @@ uint32 _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_startpageprinter(pipes_struct *p, SPOOL_Q_STARTPAGEPRINTER *q_u, SPOOL_R_STARTPAGEPRINTER *r_u) +NTSTATUS _spoolss_startpageprinter(pipes_struct *p, SPOOL_Q_STARTPAGEPRINTER *q_u, SPOOL_R_STARTPAGEPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; @@ -3925,13 +3921,13 @@ uint32 _spoolss_startpageprinter(pipes_struct *p, SPOOL_Q_STARTPAGEPRINTER *q_u, } DEBUG(3,("Error in startpageprinter printer handle\n")); - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPOOL_R_ENDPAGEPRINTER *r_u) +NTSTATUS _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPOOL_R_ENDPAGEPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; @@ -3939,12 +3935,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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } Printer->page_started=False; - return ERRsuccess; + return NT_STATUS_OK; } /******************************************************************** @@ -3953,7 +3949,7 @@ uint32 _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPO * ********************************************************************/ -uint32 _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, SPOOL_R_STARTDOCPRINTER *r_u) +NTSTATUS _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, SPOOL_R_STARTDOCPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; /* uint32 level = q_u->doc_info_container.level; - notused. */ @@ -3969,7 +3965,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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } get_current_user(&user, p); @@ -3996,7 +3992,7 @@ uint32 _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S /* get the share number of the printer */ if (!get_printer_snum(p, handle, &snum)) { - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } unistr2_to_ascii(jobname, &info_1->docname, sizeof(jobname)); @@ -4022,7 +4018,7 @@ uint32 _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S * ********************************************************************/ -uint32 _spoolss_enddocprinter(pipes_struct *p, SPOOL_Q_ENDDOCPRINTER *q_u, SPOOL_R_ENDDOCPRINTER *r_u) +NTSTATUS _spoolss_enddocprinter(pipes_struct *p, SPOOL_Q_ENDDOCPRINTER *q_u, SPOOL_R_ENDDOCPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; @@ -4032,7 +4028,7 @@ uint32 _spoolss_enddocprinter(pipes_struct *p, SPOOL_Q_ENDDOCPRINTER *q_u, SPOOL /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R_WRITEPRINTER *r_u) +NTSTATUS _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R_WRITEPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; uint32 buffer_size = q_u->buffer_size; @@ -4044,7 +4040,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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } (*buffer_written) = print_job_write(Printer->jobid, (char *)buffer, buffer_size); @@ -4060,7 +4056,7 @@ uint32 _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R * called from the spoolss dispatcher * ********************************************************************/ -static uint32 control_printer(POLICY_HND *handle, uint32 command, +static NTSTATUS control_printer(POLICY_HND *handle, uint32 command, pipes_struct *p) { struct current_user user; @@ -4071,11 +4067,11 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command, if (!Printer) { DEBUG(0,("control_printer: Invalid handle (%s)\n", OUR_HANDLE(handle))); - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } if (!get_printer_snum(p, handle, &snum)) - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; switch (command) { case PRINTER_CONTROL_PAUSE: @@ -4105,7 +4101,7 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command, * api_spoolss_abortprinter ********************************************************************/ -uint32 _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R_ABORTPRINTER *r_u) +NTSTATUS _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R_ABORTPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; @@ -4116,7 +4112,7 @@ uint32 _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R * called by spoolss_api_setprinter * when updating a printer description ********************************************************************/ -static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, +static NTSTATUS update_printer_sec(POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, pipes_struct *p, SEC_DESC_BUF *secdesc_ctr) { @@ -4131,7 +4127,7 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, DEBUG(0,("update_printer_sec: Invalid handle (%s)\n", OUR_HANDLE(handle))); - result = ERRbadfid; + result = NT_STATUS_INVALID_HANDLE; goto done; } @@ -4181,7 +4177,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 = ERRsuccess; + result = NT_STATUS_OK; goto done; } @@ -4195,7 +4191,7 @@ static uint32 update_printer_sec(POLICY_HND *handle, uint32 level, information. */ if (!print_access_check(&user, snum, PRINTER_ACCESS_ADMINISTER)) { - result = ERRnoaccess; + result = NT_STATUS_ACCESS_DENIED; goto done; } @@ -4528,7 +4524,7 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, * when updating a printer description ********************************************************************/ -static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, +static NTSTATUS update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, DEVICEMODE *devmode) { @@ -4539,7 +4535,7 @@ static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, DEBUG(8,("update_printer\n")); - result = ERRsuccess; + result = NT_STATUS_OK; if (level!=2) { DEBUG(0,("Send a mail to samba@samba.org\n")); @@ -4549,18 +4545,18 @@ static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, } if (!Printer) { - result = ERRbadfid; + result = NT_STATUS_INVALID_HANDLE; goto done; } if (!get_printer_snum(p, handle, &snum)) { - result = ERRbadfid; + result = NT_STATUS_INVALID_HANDLE; goto done; } if((get_a_printer(&printer, 2, lp_servicename(snum)) != 0) || (get_a_printer(&old_printer, 2, lp_servicename(snum)) != 0)) { - result = ERRbadfid; + result = NT_STATUS_INVALID_HANDLE; goto done; } @@ -4599,7 +4595,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 = ERRsuccess; + result = NT_STATUS_OK; goto done; } @@ -4608,7 +4604,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 = ERRnoaccess; + result = NT_STATUS_ACCESS_DENIED; goto done; } @@ -4616,7 +4612,7 @@ static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, if (*lp_addprinter_cmd() ) if ( !add_printer_hook(printer) ) { - result = ERRnoaccess; + result = NT_STATUS_ACCESS_DENIED; goto done; } @@ -4624,7 +4620,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 = ERRnoaccess; + result = NT_STATUS_ACCESS_DENIED; goto done; } @@ -4640,7 +4636,7 @@ static uint32 update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SETPRINTER *r_u) +NTSTATUS _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SETPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; uint32 level = q_u->level; @@ -4653,7 +4649,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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } /* check the level */ @@ -4673,7 +4669,7 @@ uint32 _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) +NTSTATUS _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) { POLICY_HND *handle = &q_u->handle; @@ -4681,7 +4677,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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } if (Printer->notify.client_connected==True) @@ -4695,13 +4691,13 @@ 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 ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u) +NTSTATUS _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u) { /* that's an [in out] buffer (despite appearences to the contrary) */ spoolss_move_buffer(q_u->buffer, &r_u->buffer); @@ -4793,7 +4789,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, /**************************************************************************** Enumjobs at level 1. ****************************************************************************/ -static uint32 enumjobs_level1(print_queue_struct *queue, int snum, +static NTSTATUS enumjobs_level1(print_queue_struct *queue, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { @@ -4833,13 +4829,13 @@ static uint32 enumjobs_level1(print_queue_struct *queue, int snum, return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** Enumjobs at level 2. ****************************************************************************/ -static uint32 enumjobs_level2(print_queue_struct *queue, int snum, +static NTSTATUS enumjobs_level2(print_queue_struct *queue, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { @@ -4888,14 +4884,14 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum, return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** Enumjobs. ****************************************************************************/ -uint32 _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJOBS *r_u) +NTSTATUS _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJOBS *r_u) { POLICY_HND *handle = &q_u->handle; /* uint32 firstjob = q_u->firstjob; - notused. */ @@ -4922,14 +4918,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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; *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 ERRsuccess; + return NT_STATUS_OK; } switch (level) { @@ -4947,7 +4943,7 @@ uint32 _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_schedulejob( pipes_struct *p, SPOOL_Q_SCHEDULEJOB *q_u, SPOOL_R_SCHEDULEJOB *r_u) +NTSTATUS _spoolss_schedulejob( pipes_struct *p, SPOOL_Q_SCHEDULEJOB *q_u, SPOOL_R_SCHEDULEJOB *r_u) { return 0x0; } @@ -4955,7 +4951,7 @@ uint32 _spoolss_schedulejob( pipes_struct *p, SPOOL_Q_SCHEDULEJOB *q_u, SPOOL_R_ /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u) +NTSTATUS _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u) { POLICY_HND *handle = &q_u->handle; uint32 jobid = q_u->jobid; @@ -4970,7 +4966,7 @@ uint32 _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u memset(&prt_status, 0, sizeof(prt_status)); if (!get_printer_snum(p, handle, &snum)) { - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } if (!print_job_exists(jobid)) { @@ -5007,7 +5003,7 @@ uint32 _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u /**************************************************************************** Enumerates all printer drivers at level 1. ****************************************************************************/ -static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static NTSTATUS enumprinterdrivers_level1(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; int ndrivers; @@ -5040,7 +5036,7 @@ static uint32 enumprinterdrivers_level1(fstring servername, fstring architecture } for (i=0; iname; - notused. */ UNISTR2 *environment = &q_u->environment; @@ -5304,7 +5300,7 @@ static void fill_form_1(FORM_1 *form, nt_forms_struct *list) /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u) +NTSTATUS _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u) { /* POLICY_HND *handle = &q_u->handle; - notused. */ uint32 level = q_u->level; @@ -5392,7 +5388,7 @@ uint32 _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; default: safe_free(list); @@ -5405,7 +5401,7 @@ uint32 _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM *r_u) +NTSTATUS _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM *r_u) { /* POLICY_HND *handle = &q_u->handle; - notused. */ uint32 level = q_u->level; @@ -5438,7 +5434,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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } switch (level) { @@ -5461,7 +5457,7 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * safe_free(list); if (i == numofforms) { - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } } /* check the required size. */ @@ -5480,7 +5476,7 @@ uint32 _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * DEBUGADD(6,("adding form %s [%d] to buffer\n", form_name, i)); smb_io_form_1("", buffer, &form_1, 0); - return ERRsuccess; + return NT_STATUS_OK; default: safe_free(list); @@ -5510,7 +5506,7 @@ static void fill_port_2(PORT_INFO_2 *port, char *name) /**************************************************************************** enumports level 1. ****************************************************************************/ -static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static NTSTATUS enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PORT_INFO_1 *ports=NULL; int i=0; @@ -5532,7 +5528,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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } numlines = 0; @@ -5592,14 +5588,14 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** enumports level 2. ****************************************************************************/ -static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static NTSTATUS enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PORT_INFO_2 *ports=NULL; int i=0; @@ -5630,7 +5626,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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } numlines = 0; @@ -5691,14 +5687,14 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** enumports. ****************************************************************************/ -uint32 _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u) +NTSTATUS _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u) { /* UNISTR2 *name = &q_u->name; - notused. */ uint32 level = q_u->level; @@ -5728,7 +5724,7 @@ uint32 _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUM /**************************************************************************** ****************************************************************************/ -static uint32 spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_srv_name, +static NTSTATUS spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_srv_name, const SPOOL_PRINTER_INFO_LEVEL *info, uint32 unk0, uint32 unk1, uint32 unk2, uint32 unk3, uint32 user_switch, const SPOOL_USER_CTR *user, @@ -5751,7 +5747,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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname, @@ -5759,13 +5755,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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } /* 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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } /* @@ -5787,27 +5783,27 @@ static uint32 spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ /* write the ASCII on disk */ if (add_a_printer(*printer, 2) != 0) { free_a_printer(&printer,2); - return ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } 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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } free_a_printer(&printer,2); srv_spoolss_sendnotify(p, handle); - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_R_ADDPRINTEREX *r_u) +NTSTATUS _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_R_ADDPRINTEREX *r_u) { UNISTR2 *uni_srv_name = &q_u->server_name; uint32 level = q_u->level; @@ -5837,13 +5833,13 @@ uint32 _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_ /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, SPOOL_R_ADDPRINTERDRIVER *r_u) +NTSTATUS _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, SPOOL_R_ADDPRINTERDRIVER *r_u) { /* UNISTR2 *server_name = &q_u->server_name; - notused. */ uint32 level = q_u->level; SPOOL_PRINTER_DRIVER_INFO_LEVEL *info = &q_u->info; - uint32 err = ERRsuccess; + uint32 err = NT_STATUS_OK; NT_PRINTER_DRIVER_INFO_LEVEL driver; struct current_user user; @@ -5857,18 +5853,18 @@ uint32 _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, } DEBUG(5,("Cleaning driver's information\n")); - if ((err = clean_up_driver_struct(driver, level, &user)) != ERRsuccess ) + if ((err = clean_up_driver_struct(driver, level, &user)) != NT_STATUS_OK ) goto done; DEBUG(5,("Moving driver to final destination\n")); if(!move_driver_to_download_area(driver, level, &user, &err)) { if (err == 0) - err = ERRnoaccess; + err = NT_STATUS_ACCESS_DENIED; goto done; } if (add_a_printer_driver(driver, level)!=0) { - err = ERRnoaccess; + err = NT_STATUS_ACCESS_DENIED; goto done; } @@ -5886,7 +5882,7 @@ static void fill_driverdir_1(DRIVER_DIRECTORY_1 *info, char *name) /**************************************************************************** ****************************************************************************/ -static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environment, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static NTSTATUS getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environment, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { pstring path; pstring long_archi; @@ -5921,13 +5917,13 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen if (*needed > offered) return ERRinsufficientbuffer; else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, SPOOL_R_GETPRINTERDRIVERDIR *r_u) +NTSTATUS _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, SPOOL_R_GETPRINTERDRIVERDIR *r_u) { UNISTR2 *name = &q_u->name; UNISTR2 *uni_environment = &q_u->environment; @@ -5955,7 +5951,7 @@ uint32 _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRI /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, SPOOL_R_ENUMPRINTERDATA *r_u) +NTSTATUS _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, SPOOL_R_ENUMPRINTERDATA *r_u) { POLICY_HND *handle = &q_u->handle; uint32 idx = q_u->index; @@ -5998,14 +5994,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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } if (!get_printer_snum(p,handle, &snum)) - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; if (get_a_printer(&printer, 2, lp_servicename(snum)) != 0) - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; /* * The NT machine wants to know the biggest size of value and data @@ -6069,7 +6065,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 ERRsuccess; + return NT_STATUS_OK; } /* @@ -6116,13 +6112,13 @@ uint32 _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S safe_free(data); - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SPOOL_R_SETPRINTERDATA *r_u) +NTSTATUS _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SPOOL_R_SETPRINTERDATA *r_u) { POLICY_HND *handle = &q_u->handle; UNISTR2 *value = &q_u->value; @@ -6135,18 +6131,18 @@ uint32 _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_PARAM *param = NULL, old_param; int snum=0; - uint32 status = 0x0; + NTSTATUS status = 0x0; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); DEBUG(5,("spoolss_setprinterdata\n")); if (!Printer) { DEBUG(0,("_spoolss_setprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } if (!get_printer_snum(p,handle, &snum)) - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; status = get_a_printer(&printer, 2, lp_servicename(snum)); if (status != 0x0) @@ -6168,7 +6164,7 @@ 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 = ERRsuccess; + status = NT_STATUS_OK; goto done; } } @@ -6178,7 +6174,7 @@ uint32 _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { DEBUG(3, ("security descriptor change denied by existing " "security descriptor\n")); - status = ERRnoaccess; + status = NT_STATUS_ACCESS_DENIED; goto done; } @@ -6212,7 +6208,7 @@ uint32 _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_u, SPOOL_R_DELETEPRINTERDATA *r_u) +NTSTATUS _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_u, SPOOL_R_DELETEPRINTERDATA *r_u) { POLICY_HND *handle = &q_u->handle; UNISTR2 *value = &q_u->valuename; @@ -6220,23 +6216,23 @@ uint32 _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_PARAM param; int snum=0; - uint32 status = 0x0; + NTSTATUS status = 0x0; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); DEBUG(5,("spoolss_deleteprinterdata\n")); if (!Printer) { DEBUG(0,("_spoolss_deleteprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } if (!get_printer_snum(p, handle, &snum)) - return ERRbadfid; + return NT_STATUS_INVALID_HANDLE; if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { DEBUG(3, ("_spoolss_deleteprinterdata: printer properties " "change denied by existing security descriptor\n")); - return ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } status = get_a_printer(&printer, 2, lp_servicename(snum)); @@ -6258,7 +6254,7 @@ uint32 _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM *r_u) +NTSTATUS _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM *r_u) { POLICY_HND *handle = &q_u->handle; /* uint32 level = q_u->level; - notused. */ @@ -6273,7 +6269,7 @@ 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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } /* can't add if builtin */ @@ -6294,7 +6290,7 @@ uint32 _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DELETEFORM *r_u) +NTSTATUS _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DELETEFORM *r_u) { POLICY_HND *handle = &q_u->handle; UNISTR2 *form_name = &q_u->name; @@ -6308,7 +6304,7 @@ 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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } /* can't delete if builtin */ @@ -6328,7 +6324,7 @@ uint32 _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM *r_u) +NTSTATUS _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM *r_u) { POLICY_HND *handle = &q_u->handle; /* UNISTR2 *uni_name = &q_u->name; - notused. */ @@ -6344,7 +6340,7 @@ 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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; } /* can't set if builtin */ if (get_a_builtin_ntform(&form->name,&tmpForm)) { @@ -6363,7 +6359,7 @@ uint32 _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * /**************************************************************************** enumprintprocessors level 1. ****************************************************************************/ -static uint32 enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static NTSTATUS enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTPROCESSOR_1 *info_1=NULL; @@ -6388,13 +6384,13 @@ static uint32 enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, SPOOL_R_ENUMPRINTPROCESSORS *r_u) +NTSTATUS _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, SPOOL_R_ENUMPRINTPROCESSORS *r_u) { /* UNISTR2 *name = &q_u->name; - notused. */ /* UNISTR2 *environment = &q_u->environment; - notused. */ @@ -6431,7 +6427,7 @@ uint32 _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS /**************************************************************************** enumprintprocdatatypes level 1. ****************************************************************************/ -static uint32 enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static NTSTATUS enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTPROCDATATYPE_1 *info_1=NULL; @@ -6456,13 +6452,13 @@ static uint32 enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u) +NTSTATUS _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u) { /* UNISTR2 *name = &q_u->name; - notused. */ /* UNISTR2 *processor = &q_u->processor; - notused. */ @@ -6493,7 +6489,7 @@ uint32 _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDAT enumprintmonitors level 1. ****************************************************************************/ -static uint32 enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static NTSTATUS enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTMONITOR_1 *info_1=NULL; @@ -6518,13 +6514,13 @@ static uint32 enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** enumprintmonitors level 2. ****************************************************************************/ -static uint32 enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static NTSTATUS enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTMONITOR_2 *info_2=NULL; @@ -6551,13 +6547,13 @@ static uint32 enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint return ERRinsufficientbuffer; } else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_u, SPOOL_R_ENUMPRINTMONITORS *r_u) +NTSTATUS _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_u, SPOOL_R_ENUMPRINTMONITORS *r_u) { /* UNISTR2 *name = &q_u->name; - notused. */ uint32 level = q_u->level; @@ -6594,7 +6590,7 @@ uint32 _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_ /**************************************************************************** ****************************************************************************/ -static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static NTSTATUS getjob_level_1(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { int i=0; BOOL found=False; @@ -6616,7 +6612,7 @@ static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uin safe_free(queue); safe_free(info_1); /* I shoud reply something else ... I can't find the good one */ - return ERRsuccess; + return NT_STATUS_OK; } fill_job_info_1(info_1, &(queue[i-1]), i, snum); @@ -6637,13 +6633,13 @@ static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uin if (*needed > offered) return ERRinsufficientbuffer; else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static NTSTATUS getjob_level_2(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { int i=0; BOOL found=False; @@ -6668,7 +6664,7 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin safe_free(queue); safe_free(info_2); /* I shoud reply something else ... I can't find the good one */ - return ERRsuccess; + return NT_STATUS_OK; } if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0) { @@ -6696,13 +6692,13 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin if (*needed > offered) return ERRinsufficientbuffer; else - return ERRsuccess; + return NT_STATUS_OK; } /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_u) +NTSTATUS _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_u) { POLICY_HND *handle = &q_u->handle; uint32 jobid = q_u->jobid; @@ -6727,7 +6723,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 ERRbadfid; + return NT_STATUS_INVALID_HANDLE; count = print_queue_status(snum, &queue, &prt_status); diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index b5b38b1403..5ba460b607 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -303,7 +303,8 @@ void map_generic_share_sd_bits(SEC_DESC *psd) BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 desired_access) { - uint32 granted, status; + uint32 granted; + NTSTATUS status; TALLOC_CTX *mem_ctx = NULL; SEC_DESC *psd = NULL; size_t sd_size; @@ -530,7 +531,7 @@ static void init_srv_r_net_share_enum(pipes_struct *p, SRV_R_NET_SHARE_ENUM *r_n 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; } @@ -545,7 +546,7 @@ static void init_srv_r_net_share_enum(pipes_struct *p, SRV_R_NET_SHARE_ENUM *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; + NTSTATUS status = NT_STATUS_OK; int snum; DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__)); @@ -577,7 +578,7 @@ static void init_srv_r_net_share_get_info(pipes_struct *p, 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 = NT_STATUS_IS_OK(status) ? 1 : 0; r_n->status = status; } @@ -694,10 +695,10 @@ static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto makes a SRV_R_NET_SESS_ENUM structure. ********************************************************************/ -static uint32 init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, +static NTSTATUS init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { - uint32 status = NT_STATUS_NOPROBLEMO; + NTSTATUS status = NT_STATUS_OK; DEBUG(5,("init_srv_sess_info_ctr: %d\n", __LINE__)); ctr->switch_value = switch_value; @@ -739,7 +740,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 (NT_STATUS_IS_ERR(r_n->status)) resume_hnd = 0; init_enum_hnd(&r_n->enum_hnd, resume_hnd); @@ -850,10 +851,10 @@ static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto makes a SRV_R_NET_CONN_ENUM structure. ********************************************************************/ -static uint32 init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, +static NTSTATUS init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { - uint32 status = NT_STATUS_NOPROBLEMO; + NTSTATUS status = NT_STATUS_OK; DEBUG(5,("init_srv_conn_info_ctr: %d\n", __LINE__)); ctr->switch_value = switch_value; @@ -894,7 +895,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 (NT_STATUS_IS_ERR(r_n->status)) resume_hnd = 0; init_enum_hnd(&r_n->enum_hnd, resume_hnd); @@ -950,10 +951,10 @@ static void init_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *fto makes a SRV_R_NET_FILE_ENUM structure. ********************************************************************/ -static uint32 init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, +static NTSTATUS init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { - uint32 status = NT_STATUS_NOPROBLEMO; + NTSTATUS status = NT_STATUS_OK; DEBUG(5,("init_srv_file_info_ctr: %d\n", __LINE__)); ctr->switch_value = switch_value; @@ -990,7 +991,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 (NT_STATUS_IS_ERR(r_n->status)) resume_hnd = 0; init_enum_hnd(&r_n->enum_hnd, resume_hnd); @@ -1000,9 +1001,9 @@ static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n, 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) +NTSTATUS _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; + NTSTATUS status = NT_STATUS_OK; SRV_INFO_CTR *ctr = (SRV_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_INFO_CTR)); if (!ctr) @@ -1054,12 +1055,12 @@ uint32 _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R net server set info ********************************************************************/ -uint32 _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R_NET_SRV_SET_INFO *r_u) +NTSTATUS _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R_NET_SRV_SET_INFO *r_u) { /* 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; + NTSTATUS status = NT_STATUS_OK; DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__)); @@ -1076,7 +1077,7 @@ uint32 _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R net file enum ********************************************************************/ -uint32 _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) +NTSTATUS _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) { r_u->ctr = (SRV_FILE_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_FILE_INFO_CTR)); if (!r_u->ctr) @@ -1101,7 +1102,7 @@ uint32 _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_F net conn enum ********************************************************************/ -uint32 _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_CONN_ENUM *r_u) +NTSTATUS _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_CONN_ENUM *r_u) { DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); @@ -1126,7 +1127,7 @@ uint32 _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_C net sess enum ********************************************************************/ -uint32 _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_SESS_ENUM *r_u) +NTSTATUS _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_SESS_ENUM *r_u) { DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__)); @@ -1151,7 +1152,7 @@ uint32 _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_S Net share enum all. ********************************************************************/ -uint32 _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) +NTSTATUS _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) { DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); @@ -1169,7 +1170,7 @@ uint32 _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R Net share enum. ********************************************************************/ -uint32 _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) +NTSTATUS _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) { DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); @@ -1187,7 +1188,7 @@ uint32 _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET Net share get info. ********************************************************************/ -uint32 _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, SRV_R_NET_SHARE_GET_INFO *r_u) +NTSTATUS _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, SRV_R_NET_SHARE_GET_INFO *r_u) { fstring share_name; @@ -1247,7 +1248,7 @@ static char *valid_share_pathname(char *dos_pathname) Net share set info. Modify share details. ********************************************************************/ -uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) +NTSTATUS _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) { struct current_user user; pstring command; @@ -1267,27 +1268,27 @@ 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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; snum = find_service(share_name); /* Does this share exist ? */ if (snum < 0) - return ERRnosuchshare; + return NT_STATUS_BAD_NETWORK_NAME; /* No change to printer shares. */ if (lp_print_ok(snum)) - return ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; get_current_user(&user,p); if (user.uid != 0) - return ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; switch (q_u->info_level) { case 1: /* Not enough info in a level 1 to do anything. */ - return ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; 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)); @@ -1302,7 +1303,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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; case 1501: fstrcpy(pathname, lp_pathname(snum)); fstrcpy(comment, lp_comment(snum)); @@ -1317,11 +1318,11 @@ 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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; /* Check if the pathname is valid. */ if (!(ptr = valid_share_pathname( pathname ))) - return ERRbadpath; + return NT_STATUS_OBJECT_PATH_INVALID; /* Ensure share name, pathname and comment don't contain '"' characters. */ string_replace(share_name, '"', ' '); @@ -1335,7 +1336,7 @@ 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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", lp_change_share_cmd(), CONFIGFILE, share_name, ptr, comment); @@ -1343,7 +1344,7 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S 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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } /* Tell everyone we updated smb.conf. */ @@ -1369,14 +1370,14 @@ 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; } /******************************************************************* Net share add. Call 'add_share_command "sharename" "pathname" "comment" "read only = xxx"' ********************************************************************/ -uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) +NTSTATUS _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) { struct current_user user; pstring command; @@ -1397,18 +1398,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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } if (!lp_add_share_cmd() || !*lp_add_share_cmd()) { DEBUG(10,("_srv_net_share_add: No add share command\n")); - return ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } switch (q_u->info_level) { case 1: /* Not enough info in a level 1 to do anything. */ - return ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; 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,28 +1426,28 @@ 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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; 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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; snum = find_service(share_name); /* Share already exists. */ if (snum >= 0) - return ERRfilexists; + return NT_STATUS_OBJECT_NAME_COLLISION; /* We can only add disk shares. */ if (type != STYPE_DISKTREE) - return ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; /* Check if the pathname is valid. */ if (!(ptr = valid_share_pathname( pathname ))) - return ERRbadpath; + return NT_STATUS_OBJECT_PATH_INVALID; /* Ensure share name, pathname and comment don't contain '"' characters. */ string_replace(share_name, '"', ' '); @@ -1459,7 +1460,7 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S 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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } if (psd) { @@ -1479,7 +1480,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; } /******************************************************************* @@ -1487,7 +1488,7 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S a parameter. ********************************************************************/ -uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) +NTSTATUS _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) { struct current_user user; pstring command; @@ -1500,24 +1501,24 @@ 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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; snum = find_service(share_name); if (snum < 0) - return ERRnosuchshare; + return NT_STATUS_BAD_NETWORK_NAME; /* No change to printer shares. */ if (lp_print_ok(snum)) - return ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; get_current_user(&user,p); if (user.uid != 0) - return ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) - return ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", lp_delete_share_cmd(), CONFIGFILE, lp_servicename(snum)); @@ -1525,7 +1526,7 @@ uint32 _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S 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 ERRnoaccess; + return NT_STATUS_ACCESS_DENIED; } /* Delete the SD in the database. */ @@ -1536,14 +1537,14 @@ 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; } /******************************************************************* time of day ********************************************************************/ -uint32 _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET_REMOTE_TOD *r_u) +NTSTATUS _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET_REMOTE_TOD *r_u) { TIME_OF_DAY_INFO *tod; struct tm *t; @@ -1557,7 +1558,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__)); @@ -1587,7 +1588,7 @@ uint32 _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET Win9x NT tools get security descriptor. ***********************************************************************************/ -uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC *q_u, +NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC *q_u, SRV_R_NET_FILE_QUERY_SECDESC *r_u) { SEC_DESC *psd = NULL; @@ -1600,14 +1601,14 @@ uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC BOOL bad_path; int access_mode; int action; - int ecode; + NTSTATUS ecode; struct current_user user; fstring user_name; connection_struct *conn = NULL; 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)); @@ -1621,7 +1622,7 @@ uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC if (conn == NULL) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", qualname)); - r_u->status = (uint32)ecode; + r_u->status = ecode; goto error_exit; } @@ -1638,7 +1639,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 = ERRnoaccess; + r_u->status = NT_STATUS_ACCESS_DENIED; goto error_exit; } } @@ -1647,7 +1648,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 = ERRnoaccess; + r_u->status = NT_STATUS_ACCESS_DENIED; goto error_exit; } @@ -1680,7 +1681,7 @@ uint32 _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC Win9x NT tools set security descriptor. ***********************************************************************************/ -uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_u, +NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_u, SRV_R_NET_FILE_SET_SECDESC *r_u) { BOOL ret; @@ -1692,7 +1693,7 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ BOOL bad_path; int access_mode; int action; - int ecode; + NTSTATUS ecode; struct current_user user; fstring user_name; connection_struct *conn = NULL; @@ -1700,7 +1701,7 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ 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)); @@ -1714,13 +1715,13 @@ uint32 _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ if (conn == NULL) { DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", qualname)); - r_u->status = (uint32)ecode; + r_u->status = ecode; 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; + r_u->status = NT_STATUS_ACCESS_DENIED; goto error_exit; } became_user = True; @@ -1739,7 +1740,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 = ERRnoaccess; + r_u->status = NT_STATUS_ACCESS_DENIED; goto error_exit; } } @@ -1748,7 +1749,7 @@ 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 = ERRnoaccess; + r_u->status = NT_STATUS_ACCESS_DENIED; goto error_exit; } @@ -1818,13 +1819,13 @@ static const char *next_server_disk_enum(uint32 *resume) return disk; } -uint32 _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_DISK_ENUM *r_u) +NTSTATUS _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_DISK_ENUM *r_u) { uint32 i; 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); @@ -1854,12 +1855,12 @@ uint32 _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D return r_u->status; } -uint32 _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV_R_NET_NAME_VALIDATE *r_u) +NTSTATUS _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV_R_NET_NAME_VALIDATE *r_u) { int snum; fstring share_name; - r_u->status=NT_STATUS_NOPROBLEMO; + r_u->status=NT_STATUS_OK; switch(q_u->type) { @@ -1878,7 +1879,7 @@ uint32 _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV default: /*unsupported type*/ - r_u->status = ERRunknownlevel; + r_u->status = NT_STATUS_INVALID_LEVEL; break; } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index f9e02b9bca..5393523a78 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -190,7 +190,7 @@ void get_domain_user_groups(char *domain_groups, char *user) /******************************************************************* Look up a local (domain) rid and return a name and type. ********************************************************************/ -uint32 local_lookup_group_name(uint32 rid, char *group_name, uint32 *type) +NTSTATUS local_lookup_group_name(uint32 rid, char *group_name, uint32 *type) { int i = 0; (*type) = SID_NAME_DOM_GRP; @@ -206,7 +206,7 @@ uint32 local_lookup_group_name(uint32 rid, char *group_name, uint32 *type) { fstrcpy(group_name, domain_group_rids[i].name); DEBUG(5,(" = %s\n", group_name)); - return 0x0; + return NT_STATUS_OK; } DEBUG(5,(" none mapped\n")); @@ -216,7 +216,7 @@ uint32 local_lookup_group_name(uint32 rid, char *group_name, uint32 *type) /******************************************************************* Look up a local alias rid and return a name and type. ********************************************************************/ -uint32 local_lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) +NTSTATUS local_lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) { int i = 0; (*type) = SID_NAME_WKN_GRP; @@ -232,7 +232,7 @@ uint32 local_lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) { fstrcpy(alias_name, builtin_alias_rids[i].name); DEBUG(5,(" = %s\n", alias_name)); - return 0x0; + return NT_STATUS_OK; } DEBUG(5,(" none mapped\n")); @@ -242,7 +242,7 @@ uint32 local_lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) /******************************************************************* Look up a local user rid and return a name and type. ********************************************************************/ -uint32 local_lookup_user_name(uint32 rid, char *user_name, uint32 *type) +NTSTATUS local_lookup_user_name(uint32 rid, char *user_name, uint32 *type) { SAM_ACCOUNT *sampwd=NULL; int i = 0; @@ -261,7 +261,7 @@ uint32 local_lookup_user_name(uint32 rid, char *user_name, uint32 *type) if (domain_user_rids[i].rid != 0) { fstrcpy(user_name, domain_user_rids[i].name); DEBUG(5,(" = %s\n", user_name)); - return 0x0; + return NT_STATUS_OK; } pdb_init_sam(&sampwd); @@ -275,7 +275,7 @@ uint32 local_lookup_user_name(uint32 rid, char *user_name, uint32 *type) fstrcpy(user_name, pdb_get_username(sampwd) ); DEBUG(5,(" = %s\n", user_name)); pdb_free_sam(sampwd); - return 0x0; + return NT_STATUS_OK; } DEBUG(5,(" none mapped\n")); @@ -286,7 +286,7 @@ uint32 local_lookup_user_name(uint32 rid, char *user_name, uint32 *type) /******************************************************************* Look up a local (domain) group name and return a rid ********************************************************************/ -uint32 local_lookup_group_rid(char *group_name, uint32 *rid) +NTSTATUS local_lookup_group_rid(char *group_name, uint32 *rid) { char *grp_name; int i = -1; /* start do loop at -1 */ @@ -299,13 +299,13 @@ uint32 local_lookup_group_rid(char *group_name, uint32 *rid) } while (grp_name != NULL && !strequal(grp_name, group_name)); - return (grp_name != NULL) ? 0 : NT_STATUS_NONE_MAPPED; + return (grp_name != NULL) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; } /******************************************************************* Look up a local (BUILTIN) alias name and return a rid ********************************************************************/ -uint32 local_lookup_alias_rid(char *alias_name, uint32 *rid) +NTSTATUS local_lookup_alias_rid(char *alias_name, uint32 *rid) { char *als_name; int i = -1; /* start do loop at -1 */ @@ -318,13 +318,13 @@ uint32 local_lookup_alias_rid(char *alias_name, uint32 *rid) } while (als_name != NULL && !strequal(als_name, alias_name)); - return (als_name != NULL) ? 0 : NT_STATUS_NONE_MAPPED; + return (als_name != NULL) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; } /******************************************************************* Look up a local user name and return a rid ********************************************************************/ -uint32 local_lookup_user_rid(char *user_name, uint32 *rid) +NTSTATUS local_lookup_user_rid(char *user_name, uint32 *rid) { SAM_ACCOUNT *sampass=NULL; BOOL ret; @@ -341,7 +341,7 @@ uint32 local_lookup_user_rid(char *user_name, uint32 *rid) if (ret == True) { (*rid) = pdb_get_user_rid(sampass); pdb_free_sam(sampass); - return 0x0; + return NT_STATUS_OK; } pdb_free_sam(sampass); diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 47566bbf3e..4bbc0e237f 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -60,7 +60,7 @@ static void create_wks_info_100(WKS_INFO_100 *inf) ********************************************************************/ -uint32 _wks_query_info(pipes_struct *p, WKS_Q_QUERY_INFO *q_u, WKS_R_QUERY_INFO *r_u) +NTSTATUS _wks_query_info(pipes_struct *p, WKS_Q_QUERY_INFO *q_u, WKS_R_QUERY_INFO *r_u) { WKS_INFO_100 *wks100 = NULL; @@ -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__)); -- cgit From cd0a9f6fcc9fbb3071638a17c3aaa579329b4196 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 28 Aug 2001 06:34:08 +0000 Subject: Send a MSG_SMB_SAM_SYNC when a netlogon_ctrl2 message is received. (This used to be commit 73e1b708d0ab7a6e612f8910c5815a6ab6de66cd) --- source3/rpc_server/srv_netlog_nt.c | 41 ++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index e29d9393a6..1a2ef02f2c 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -76,26 +76,55 @@ NTSTATUS _net_logon_ctrl(pipes_struct *p, NET_Q_LOGON_CTRL *q_u, return r_u->status; } +/**************************************************************************** +Send a message to smbd to do a sam synchronisation +**************************************************************************/ +static void send_sync_message() +{ + TDB_CONTEXT *tdb; + + tdb = tdb_open_log(lock_path("connections.tdb"), 0, + USE_TDB_MMAP_FLAG, O_RDONLY, 0); + + if (!tdb) { + DEBUG(3, ("send_sync_message(): failed to open connections " + "database\n")); + return; + } + + DEBUG(3, ("sending sam synchronisation message\n")); + + message_send_all(tdb, MSG_SMB_SAM_SYNC, NULL, 0, False); + + tdb_close(tdb); +} + /************************************************************************* net_reply_logon_ctrl2: *************************************************************************/ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_CTRL2 *r_u) { - /* lkclXXXX - guess what - absolutely no idea what these are! */ - uint32 flags = 0x0; - uint32 pdc_connection_status = 0x0; - uint32 logon_attempts = 0x0; - uint32 tc_status = ERROR_NO_LOGON_SERVERS; - char *trusted_domain = "test_domain"; + uint32 flags = 0x0; + uint32 pdc_connection_status = 0x0; + uint32 logon_attempts = 0x0; + uint32 tc_status = ERROR_NO_LOGON_SERVERS; + char *trusted_domain = "test_domain"; + + DEBUG(0, ("*** net long ctrl2 %d, %d, %d\n", + q_u->function_code, q_u->query_level, q_u->switch_value)); DEBUG(6,("_net_logon_ctrl2: %d\n", __LINE__)); + /* set up the Logon Control2 response */ init_net_r_logon_ctrl2(r_u, q_u->query_level, flags, pdc_connection_status, logon_attempts, tc_status, trusted_domain); + if (lp_server_role() == ROLE_DOMAIN_BDC) + send_sync_message(); + DEBUG(6,("_net_logon_ctrl2: %d\n", __LINE__)); return r_u->status; -- cgit From fd6ea431617d91c5f5c6b07cb26910f4900c1515 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 3 Sep 2001 08:50:59 +0000 Subject: the next step in our error code handling change - added WERROR for win32 error codes - added a configure test for immediate structures still lots to do, so its not enabled by default, but the main structure is there (This used to be commit 24f9ab683dec52587ee56717e821b49c0fa3d70f) --- source3/rpc_server/srv_spoolss_nt.c | 461 ++++++++++++++++++------------------ 1 file changed, 229 insertions(+), 232 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0ebbc2aada..140eed5c05 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -443,7 +443,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) DEBUGADD(5,("share:%s\n",lp_servicename(snum))); - if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) + if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) continue; printername=strchr_m(printer->info_2->printername+2, '\\'); @@ -486,7 +486,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) DEBUGADD(5,("set_printer_hnd_name: share:%s\n",lp_servicename(snum))); - if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) + if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) continue; DEBUG(10,("set_printer_hnd_name: printername [%s], aprinter [%s]\n", @@ -1141,7 +1141,7 @@ NTSTATUS _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV } ZERO_STRUCT(info); - if (get_a_printer_driver (&info, 3, driver, arch, version) != 0) { + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) { return NT_STATUS_DRIVER_ORDINAL_NOT_FOUND; } @@ -1256,7 +1256,7 @@ static BOOL getprinterdata_printer(pipes_struct *p, TALLOC_CTX *ctx, POLICY_HND if(!get_printer_snum(p, handle, &snum)) return False; - if(get_a_printer(&printer, 2, lp_servicename(snum)) != 0) + if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) return False; if (!get_specific_param(*printer, 2, value, &idata, type, &len)) { @@ -2222,7 +2222,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int (option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"), option_type->count, lp_servicename(snum))); - if (get_a_printer(&printer, 2, lp_servicename(snum))!=0) + if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) return False; for(field_num=0; field_numcount; field_num++) { @@ -2334,7 +2334,7 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, * ********************************************************************/ -static NTSTATUS printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, +static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, TALLOC_CTX *mem_ctx) { @@ -2382,7 +2382,7 @@ static NTSTATUS printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, } */ - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************* @@ -2390,7 +2390,7 @@ static NTSTATUS printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, * fill a notify_info struct with info asked * ********************************************************************/ -static uint32 printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, +static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, TALLOC_CTX *mem_ctx) { int snum; @@ -2430,8 +2430,8 @@ static uint32 printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY memset(&status, 0, sizeof(status)); count = print_queue_status(snum, &queue, &status); - if (get_a_printer(&printer, 2, - lp_servicename(snum)) != 0) + if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, + lp_servicename(snum)))) goto done; for (j=0; jdata[i].id, info->data[i].size, info->data[i].enc_type)); } */ - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************** * spoolss_rfnpcnex ********************************************************************/ -NTSTATUS _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCNEX *r_u) +WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCNEX *r_u) { POLICY_HND *handle = &q_u->handle; /* uint32 change = q_u->change; - notused. */ @@ -2480,7 +2480,7 @@ NTSTATUS _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNP SPOOL_NOTIFY_INFO *info = &r_u->info; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); - NTSTATUS result = NT_STATUS_INVALID_HANDLE; + WERROR result = WERR_BADFID; /* we always have a NOTIFY_INFO struct */ r_u->info_ptr=0x1; @@ -2539,7 +2539,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) memset(&status, 0, sizeof(status)); - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0) + if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) return False; count = print_queue_status(snum, &queue, &status); @@ -2639,7 +2639,7 @@ static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int pstring chaine2; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0) + if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) return False; printer->flags=flags; @@ -2703,7 +2703,7 @@ static DEVICEMODE *construct_dev_mode(int snum) ZERO_STRUCTP(devmode); - if(get_a_printer(&printer, 2, lp_servicename(snum)) != 0) + if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) goto fail; if (printer->info_2->devmode) @@ -2779,7 +2779,7 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum) print_status_struct status; memset(&status, 0, sizeof(status)); - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) + if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) return False; memset(&status, 0, sizeof(status)); @@ -2841,7 +2841,7 @@ static BOOL construct_printer_info_3(PRINTER_INFO_3 **pp_printer, int snum) NT_PRINTER_INFO_LEVEL *ntprinter = NULL; PRINTER_INFO_3 *printer = NULL; - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 ) + if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) return False; *pp_printer = NULL; @@ -2889,7 +2889,7 @@ static BOOL construct_printer_info_3(PRINTER_INFO_3 **pp_printer, int snum) /******************************************************************** Spoolss_enumprinters. ********************************************************************/ -static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int snum; int i; @@ -2908,7 +2908,7 @@ static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 of DEBUG(0,("enum_all_printers_info_1: failed to enlarge printers buffer!\n")); safe_free(printers); *returned=0; - return ERRnomem; + return WERR_NOMEM; } else printers = tp; DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned)); @@ -2923,7 +2923,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 ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; /* fill the buffer with the structures */ for (i=0; i<*returned; i++) @@ -2934,16 +2934,16 @@ static BOOL enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 of if (*needed > offered) { *returned=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************** enum_all_printers_info_1_local. *********************************************************************/ -static BOOL enum_all_printers_info_1_local(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enum_all_printers_info_1_local(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { DEBUG(4,("enum_all_printers_info_1_local\n")); @@ -2953,7 +2953,7 @@ static BOOL enum_all_printers_info_1_local(NEW_BUFFER *buffer, uint32 offered, u /******************************************************************** enum_all_printers_info_1_name. *********************************************************************/ -static BOOL enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { fstring temp; DEBUG(4,("enum_all_printers_info_1_name\n")); @@ -2965,13 +2965,13 @@ 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 ERRinvalidname; + return WERR_INVALID_NAME; } /******************************************************************** enum_all_printers_info_1_remote. *********************************************************************/ -static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTER_INFO_1 *printer; fstring printername; @@ -2987,7 +2987,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 ERRnomem; + return WERR_NOMEM; *returned=1; @@ -3005,7 +3005,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 ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the structures */ @@ -3016,17 +3016,17 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui if (*needed > offered) { *returned=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************** enum_all_printers_info_1_network. *********************************************************************/ -static BOOL enum_all_printers_info_1_network(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enum_all_printers_info_1_network(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { DEBUG(4,("enum_all_printers_info_1_network\n")); @@ -3039,7 +3039,7 @@ static BOOL enum_all_printers_info_1_network(NEW_BUFFER *buffer, uint32 offered, * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int snum; int i; @@ -3056,7 +3056,7 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 DEBUG(0,("enum_all_printers_info_2: failed to enlarge printers buffer!\n")); safe_free(printers); *returned = 0; - return ERRnomem; + return WERR_NOMEM; } else printers = tp; DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *returned)); @@ -3075,7 +3075,7 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 free_devmode(printers[i].devmode); } safe_free(printers); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the structures */ @@ -3090,16 +3090,16 @@ static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 if (*needed > offered) { *returned=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************** * handle enumeration of printers at level 1 ********************************************************************/ -static NTSTATUS enumprinters_level1( uint32 flags, fstring name, +static WERROR enumprinters_level1( uint32 flags, fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { @@ -3117,13 +3117,13 @@ static NTSTATUS 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_OK; /* NT4sp5 does that */ + return WERR_OK; /* NT4sp5 does that */ } /******************************************************************** * handle enumeration of printers at level 2 ********************************************************************/ -static NTSTATUS enumprinters_level2( uint32 flags, fstring servername, +static WERROR enumprinters_level2( uint32 flags, fstring servername, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { @@ -3143,24 +3143,24 @@ static NTSTATUS enumprinters_level2( uint32 flags, fstring servername, if (strequal(servername, temp)) return enum_all_printers_info_2(buffer, offered, needed, returned); else - return ERRinvalidname; + return WERR_INVALID_NAME; } if (flags & PRINTER_ENUM_REMOTE) - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************** * handle enumeration of printers at level 5 ********************************************************************/ -static NTSTATUS enumprinters_level5( uint32 flags, fstring servername, +static WERROR enumprinters_level5( uint32 flags, fstring servername, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { /* return enum_all_printers_info_5(buffer, offered, needed, returned);*/ - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************** @@ -3169,7 +3169,7 @@ static NTSTATUS enumprinters_level5( uint32 flags, fstring servername, * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -NTSTATUS _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_R_ENUMPRINTERS *r_u) +WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_R_ENUMPRINTERS *r_u) { uint32 flags = q_u->flags; UNISTR2 *servername = &q_u->servername; @@ -3178,7 +3178,6 @@ NTSTATUS _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOO uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; - fstring name; /* that's an [in out] buffer */ @@ -3216,18 +3215,18 @@ NTSTATUS _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOO case 3: case 4: default: - return ERRunknownlevel; } + return WERR_UNKNOWN_LEVEL; } /**************************************************************************** ****************************************************************************/ -static NTSTATUS getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_0 *printer=NULL; if((printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0))) == NULL) - return ERRnomem; + return WERR_NOMEM; construct_printer_info_0(printer, snum); @@ -3236,7 +3235,7 @@ static NTSTATUS getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, if (!alloc_buffer_size(buffer, *needed)) { safe_free(printer); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the structures */ @@ -3246,20 +3245,20 @@ static NTSTATUS getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, safe_free(printer); if (*needed > offered) { - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -static NTSTATUS getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_1 *printer=NULL; if((printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1))) == NULL) - return ERRnomem; + return WERR_NOMEM; construct_printer_info_1(PRINTER_ENUM_ICON8, printer, snum); @@ -3268,7 +3267,7 @@ static NTSTATUS getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, if (!alloc_buffer_size(buffer, *needed)) { safe_free(printer); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the structures */ @@ -3278,20 +3277,20 @@ static NTSTATUS getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, safe_free(printer); if (*needed > offered) { - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -static NTSTATUS getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_2 *printer=NULL; if((printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)))==NULL) - return ERRnomem; + return WERR_NOMEM; construct_printer_info_2(printer, snum); @@ -3300,40 +3299,40 @@ static NTSTATUS getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, if (!alloc_buffer_size(buffer, *needed)) { free_printer_info_2(printer); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the structures */ if (!smb_io_printer_info_2("", buffer, printer, 0)) { free_printer_info_2(printer); - return ERRnomem; + return WERR_NOMEM; } /* clear memory */ free_printer_info_2(printer); if (*needed > offered) { - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -static NTSTATUS getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_3 *printer=NULL; if (!construct_printer_info_3(&printer, snum)) - return ERRnomem; + return WERR_NOMEM; /* check the required size. */ *needed += spoolss_size_printer_info_3(printer); if (!alloc_buffer_size(buffer, *needed)) { free_printer_info_3(printer); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the structures */ @@ -3343,16 +3342,16 @@ static NTSTATUS getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, free_printer_info_3(printer); if (*needed > offered) { - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GETPRINTER *r_u) +WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GETPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; uint32 level = q_u->level; @@ -3369,7 +3368,7 @@ NTSTATUS _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_G *needed=0; if (!get_printer_snum(p, handle, &snum)) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; switch (level) { case 0: @@ -3380,9 +3379,8 @@ NTSTATUS _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_G return getprinter_level_2(snum, buffer, offered, needed); case 3: return getprinter_level_3(snum, buffer, offered, needed); - default: - return ERRunknownlevel; } + return WERR_UNKNOWN_LEVEL; } /******************************************************************** @@ -3396,24 +3394,24 @@ static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_IN /******************************************************************** * construct_printer_driver_info_1 ********************************************************************/ -static NTSTATUS construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fstring servername, fstring architecture, uint32 version) +static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; ZERO_STRUCT(driver); - if (get_a_printer(&printer, 2, lp_servicename(snum)) != 0) - return ERRinvalidprintername; + if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) + return WERR_INVALID_PRINTER_NAME; - if (get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version) != 0) - return ERRunknownprinterdriver; + if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) + return WERR_UNKNOWN_PRINTER_DRIVER; fill_printer_driver_info_1(info, driver, servername, architecture); free_a_printer(&printer,2); - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************** @@ -3453,7 +3451,7 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_IN * construct_printer_driver_info_2 * fill a printer_info_2 struct ********************************************************************/ -static NTSTATUS construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstring servername, fstring architecture, uint32 version) +static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -3461,17 +3459,17 @@ static NTSTATUS construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, f ZERO_STRUCT(printer); ZERO_STRUCT(driver); - if (!get_a_printer(&printer, 2, lp_servicename(snum)) != 0) - return ERRinvalidprintername; + if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) + return WERR_INVALID_PRINTER_NAME; - if (!get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version) != 0) - return ERRunknownprinterdriver; + if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) + return WERR_UNKNOWN_PRINTER_DRIVER; fill_printer_driver_info_2(info, driver, servername); free_a_printer(&printer,2); - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************** @@ -3566,30 +3564,30 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN * construct_printer_info_3 * fill a printer_info_3 struct ********************************************************************/ -static NTSTATUS construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fstring servername, fstring architecture, uint32 version) +static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; - NTSTATUS status=0; + WERROR status; ZERO_STRUCT(driver); status=get_a_printer(&printer, 2, lp_servicename(snum) ); - DEBUG(8,("construct_printer_driver_info_3: status: %d\n", status)); - if (status != 0) - return ERRinvalidprintername; + DEBUG(8,("construct_printer_driver_info_3: status: %s\n", werror_str(status))); + if (!W_ERROR_IS_OK(status)) + return WERR_INVALID_PRINTER_NAME; 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) { + DEBUG(8,("construct_printer_driver_info_3: status: %s\n", werror_str(status))); + if (!W_ERROR_IS_OK(status)) { free_a_printer(&printer,2); - return ERRunknownprinterdriver; + return WERR_UNKNOWN_PRINTER_DRIVER; } fill_printer_driver_info_3(info, driver, servername); free_a_printer(&printer,2); - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************** @@ -3660,37 +3658,37 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN * construct_printer_info_6 * fill a printer_info_6 struct ********************************************************************/ -static NTSTATUS construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fstring servername, fstring architecture, uint32 version) +static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; - NTSTATUS status=0; + WERROR status; ZERO_STRUCT(driver); status=get_a_printer(&printer, 2, lp_servicename(snum) ); - DEBUG(8,("construct_printer_driver_info_6: status: %d\n", status)); - if (status != 0) - return ERRinvalidprintername; + DEBUG(8,("construct_printer_driver_info_6: status: %s\n", werror_str(status))); + if (!W_ERROR_IS_OK(status)) + return WERR_INVALID_PRINTER_NAME; status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); - DEBUG(8,("construct_printer_driver_info_6: status: %d\n", status)); - if (status != 0) { + DEBUG(8,("construct_printer_driver_info_6: status: %s\n", werror_str(status))); + if (!W_ERROR_IS_OK(status)) { /* * Is this a W2k client ? */ if (version < 3) { free_a_printer(&printer,2); - return ERRunknownprinterdriver; + return WERR_UNKNOWN_PRINTER_DRIVER; } /* Yes - try again with a WinNT driver. */ version = 2; status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); - DEBUG(8,("construct_printer_driver_info_6: status: %d\n", status)); - if (status != 0) { + DEBUG(8,("construct_printer_driver_info_6: status: %s\n", werror_str(status))); + if (!W_ERROR_IS_OK(status)) { free_a_printer(&printer,2); - return ERRunknownprinterdriver; + return WERR_UNKNOWN_PRINTER_DRIVER; } } @@ -3698,7 +3696,7 @@ static NTSTATUS construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, f free_a_printer(&printer,2); - return NT_STATUS_OK; + return WERR_OK; } /**************************************************************************** @@ -3720,16 +3718,16 @@ static void free_printer_driver_info_6(DRIVER_INFO_6 *info) /**************************************************************************** ****************************************************************************/ -static NTSTATUS getprinterdriver2_level1(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinterdriver2_level1(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_1 *info=NULL; - NTSTATUS status; + WERROR status; if((info=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1))) == NULL) - return ERRnomem; + return WERR_NOMEM; status=construct_printer_driver_info_1(info, snum, servername, architecture, version); - if (status != NT_STATUS_OK) { + if (!W_ERROR_IS_OK(status)) { safe_free(info); return status; } @@ -3739,7 +3737,7 @@ static NTSTATUS getprinterdriver2_level1(fstring servername, fstring architectur if (!alloc_buffer_size(buffer, *needed)) { safe_free(info); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the structures */ @@ -3749,23 +3747,23 @@ static NTSTATUS getprinterdriver2_level1(fstring servername, fstring architectur safe_free(info); if (*needed > offered) - return ERRinsufficientbuffer; - else - return NT_STATUS_OK; + return WERR_INSUFFICIENT_BUFFER; + + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -static NTSTATUS getprinterdriver2_level2(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinterdriver2_level2(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_2 *info=NULL; - NTSTATUS status; + WERROR status; if((info=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2))) == NULL) - return ERRnomem; + return WERR_NOMEM; status=construct_printer_driver_info_2(info, snum, servername, architecture, version); - if (status != NT_STATUS_OK) { + if (!W_ERROR_IS_OK(status)) { safe_free(info); return status; } @@ -3775,7 +3773,7 @@ static NTSTATUS getprinterdriver2_level2(fstring servername, fstring architectur if (!alloc_buffer_size(buffer, *needed)) { safe_free(info); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the structures */ @@ -3785,22 +3783,22 @@ static NTSTATUS getprinterdriver2_level2(fstring servername, fstring architectur safe_free(info); if (*needed > offered) - return ERRinsufficientbuffer; - else - return NT_STATUS_OK; + return WERR_INSUFFICIENT_BUFFER; + + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -static NTSTATUS getprinterdriver2_level3(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinterdriver2_level3(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_3 info; - NTSTATUS status; + WERROR status; ZERO_STRUCT(info); status=construct_printer_driver_info_3(&info, snum, servername, architecture, version); - if (status != NT_STATUS_OK) { + if (!W_ERROR_IS_OK(status)) { return status; } @@ -3809,7 +3807,7 @@ static NTSTATUS getprinterdriver2_level3(fstring servername, fstring architectur if (!alloc_buffer_size(buffer, *needed)) { free_printer_driver_info_3(&info); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the structures */ @@ -3818,22 +3816,22 @@ static NTSTATUS getprinterdriver2_level3(fstring servername, fstring architectur free_printer_driver_info_3(&info); if (*needed > offered) - return ERRinsufficientbuffer; - else - return NT_STATUS_OK; + return WERR_INSUFFICIENT_BUFFER; + + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -static NTSTATUS getprinterdriver2_level6(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinterdriver2_level6(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_6 info; - NTSTATUS status; + WERROR status; ZERO_STRUCT(info); status=construct_printer_driver_info_6(&info, snum, servername, architecture, version); - if (status != NT_STATUS_OK) { + if (!W_ERROR_IS_OK(status)) { return status; } @@ -3842,7 +3840,7 @@ static NTSTATUS getprinterdriver2_level6(fstring servername, fstring architectur if (!alloc_buffer_size(buffer, *needed)) { free_printer_driver_info_6(&info); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the structures */ @@ -3851,15 +3849,15 @@ static NTSTATUS getprinterdriver2_level6(fstring servername, fstring architectur free_printer_driver_info_6(&info); if (*needed > offered) - return ERRinsufficientbuffer; - else - return NT_STATUS_OK; + return WERR_INSUFFICIENT_BUFFER; + + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_u, SPOOL_R_GETPRINTERDRIVER2 *r_u) +WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_u, SPOOL_R_GETPRINTERDRIVER2 *r_u) { POLICY_HND *handle = &q_u->handle; UNISTR2 *uni_arch = &q_u->architecture; @@ -3890,7 +3888,7 @@ NTSTATUS _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 * unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); if (!get_printer_snum(p, handle, &snum)) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; switch (level) { case 1: @@ -3901,9 +3899,8 @@ NTSTATUS _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 * return getprinterdriver2_level3(servername, architecture, clientmajorversion, snum, buffer, offered, needed); case 6: return getprinterdriver2_level6(servername, architecture, clientmajorversion, snum, buffer, offered, needed); - default: - return ERRunknownlevel; } + return WERR_UNKNOWN_LEVEL; } /**************************************************************************** @@ -3917,7 +3914,7 @@ NTSTATUS _spoolss_startpageprinter(pipes_struct *p, SPOOL_Q_STARTPAGEPRINTER *q_ if (Printer) { Printer->page_started=True; - return 0x0; + return NT_STATUS_OK; } DEBUG(3,("Error in startpageprinter printer handle\n")); @@ -3949,7 +3946,7 @@ NTSTATUS _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, S * ********************************************************************/ -NTSTATUS _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, SPOOL_R_STARTDOCPRINTER *r_u) +WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, SPOOL_R_STARTDOCPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; /* uint32 level = q_u->doc_info_container.level; - notused. */ @@ -3965,7 +3962,7 @@ NTSTATUS _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, if (!Printer) { DEBUG(0,("_spoolss_startdocprinter: Invalid handle (%s)\n", OUR_HANDLE(handle))); - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } get_current_user(&user, p); @@ -3986,13 +3983,13 @@ NTSTATUS _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, unistr2_to_ascii(datatype, &info_1->datatype, sizeof(datatype)); if (strcmp(datatype, "RAW") != 0) { (*jobid)=0; - return ERRinvaliddatatype; + return WERR_INVALID_DATATYPE; } } /* get the share number of the printer */ if (!get_printer_snum(p, handle, &snum)) { - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } unistr2_to_ascii(jobname, &info_1->docname, sizeof(jobname)); @@ -4009,7 +4006,7 @@ NTSTATUS _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, Printer->document_started=True; (*jobid) = Printer->jobid; - return 0x0; + return WERR_OK; } /******************************************************************** @@ -4091,7 +4088,7 @@ static NTSTATUS control_printer(POLICY_HND *handle, uint32 command, } break; default: - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; } return errcode; @@ -4540,7 +4537,7 @@ static NTSTATUS update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level 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 = ERRunknownlevel; + result = WERR_UNKNOWN_LEVEL; goto done; } @@ -4577,7 +4574,7 @@ static NTSTATUS 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 = ERRnomem; + result = WERR_NOMEM; goto done; } } @@ -4662,7 +4659,7 @@ NTSTATUS _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_S return update_printer_sec(handle, level, info, p, secdesc_ctr); default: - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; } } @@ -4800,7 +4797,7 @@ static NTSTATUS enumjobs_level1(print_queue_struct *queue, int snum, if (info==NULL) { safe_free(queue); *returned=0; - return ERRnomem; + return WERR_NOMEM; } for (i=0; i<*returned; i++) @@ -4814,7 +4811,7 @@ static NTSTATUS enumjobs_level1(print_queue_struct *queue, int snum, if (!alloc_buffer_size(buffer, *needed)) { safe_free(info); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the structures */ @@ -4826,7 +4823,7 @@ static NTSTATUS enumjobs_level1(print_queue_struct *queue, int snum, if (*needed > offered) { *returned=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else return NT_STATUS_OK; @@ -4846,12 +4843,12 @@ static NTSTATUS enumjobs_level2(print_queue_struct *queue, int snum, info=(JOB_INFO_2 *)malloc(*returned*sizeof(JOB_INFO_2)); if (info==NULL) { *returned=0; - return ERRnomem; + return WERR_NOMEM; } if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0) { *returned = 0; - return ERRnomem; + return WERR_NOMEM; } for (i=0; i<*returned; i++) @@ -4866,7 +4863,7 @@ static NTSTATUS enumjobs_level2(print_queue_struct *queue, int snum, if (!alloc_buffer_size(buffer, *needed)) { safe_free(info); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the structures */ @@ -4881,7 +4878,7 @@ static NTSTATUS enumjobs_level2(print_queue_struct *queue, int snum, if (*needed > offered) { *returned=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else return NT_STATUS_OK; @@ -4936,7 +4933,7 @@ NTSTATUS _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUM default: safe_free(queue); *returned=0; - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; } } @@ -4970,7 +4967,7 @@ NTSTATUS _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r } if (!print_job_exists(jobid)) { - return ERRinvalidprintername; + return WERR_INVALID_PRINTER_NAME; } get_current_user(&user, p); @@ -4994,7 +4991,7 @@ NTSTATUS _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r } break; default: - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; } return errcode; @@ -5023,14 +5020,14 @@ static NTSTATUS enumprinterdrivers_level1(fstring servername, fstring architectu DEBUGADD(4,("we have:[%d] drivers in environment [%s] and version [%d]\n", ndrivers, architecture, version)); if(ndrivers == -1) - return ERRnomem; + return WERR_NOMEM; if(ndrivers != 0) { 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 ERRnomem; + return WERR_NOMEM; } else driver_info_1 = tdi1; } @@ -5059,7 +5056,7 @@ static NTSTATUS enumprinterdrivers_level1(fstring servername, fstring architectu if (!alloc_buffer_size(buffer, *needed)) { safe_free(driver_info_1); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the driver structures */ @@ -5072,7 +5069,7 @@ static NTSTATUS enumprinterdrivers_level1(fstring servername, fstring architectu if (*needed > offered) { *returned=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else return NT_STATUS_OK; @@ -5101,14 +5098,14 @@ static NTSTATUS enumprinterdrivers_level2(fstring servername, fstring architectu DEBUGADD(4,("we have:[%d] drivers in environment [%s] and version [%d]\n", ndrivers, architecture, version)); if(ndrivers == -1) - return ERRnomem; + return WERR_NOMEM; if(ndrivers != 0) { 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 ERRnomem; + return WERR_NOMEM; } else driver_info_2 = tdi2; } @@ -5138,7 +5135,7 @@ static NTSTATUS enumprinterdrivers_level2(fstring servername, fstring architectu if (!alloc_buffer_size(buffer, *needed)) { safe_free(driver_info_2); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the form structures */ @@ -5151,7 +5148,7 @@ static NTSTATUS enumprinterdrivers_level2(fstring servername, fstring architectu if (*needed > offered) { *returned=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else return NT_STATUS_OK; @@ -5180,14 +5177,14 @@ static NTSTATUS enumprinterdrivers_level3(fstring servername, fstring architectu DEBUGADD(4,("we have:[%d] drivers in environment [%s] and version [%d]\n", ndrivers, architecture, version)); if(ndrivers == -1) - return ERRnomem; + return WERR_NOMEM; if(ndrivers != 0) { 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 ERRnomem; + return WERR_NOMEM; } else driver_info_3 = tdi3; } @@ -5217,7 +5214,7 @@ static NTSTATUS enumprinterdrivers_level3(fstring servername, fstring architectu if (!alloc_buffer_size(buffer, *needed)) { safe_free(driver_info_3); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the driver structures */ @@ -5233,7 +5230,7 @@ static NTSTATUS enumprinterdrivers_level3(fstring servername, fstring architectu if (*needed > offered) { *returned=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else return NT_STATUS_OK; @@ -5278,7 +5275,7 @@ NTSTATUS _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVER default: *returned=0; safe_free(list); - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; } } @@ -5336,7 +5333,7 @@ NTSTATUS _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENU case 1: if ((forms_1=(FORM_1 *)malloc(*numofforms * sizeof(FORM_1))) == NULL) { *numofforms=0; - return ERRnomem; + return WERR_NOMEM; } /* construct the list of form structures */ @@ -5368,7 +5365,7 @@ NTSTATUS _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENU if (!alloc_buffer_size(buffer, buffer_size)){ safe_free(forms_1); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the form structures */ @@ -5385,7 +5382,7 @@ NTSTATUS _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENU if (*needed > offered) { *numofforms=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else return NT_STATUS_OK; @@ -5393,7 +5390,7 @@ NTSTATUS _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENU default: safe_free(list); safe_free(builtinlist); - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; } } @@ -5465,11 +5462,11 @@ NTSTATUS _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 ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } if (*needed > offered) { - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } /* fill the buffer with the form structures */ @@ -5480,7 +5477,7 @@ NTSTATUS _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM default: safe_free(list); - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; } } @@ -5538,9 +5535,9 @@ static NTSTATUS enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *ne if(numlines) { if((ports=(PORT_INFO_1 *)malloc( numlines * sizeof(PORT_INFO_1) )) == NULL) { - DEBUG(10,("Returning ERRnomem [%x]\n", ERRnomem)); + DEBUG(10,("Returning WERR_NOMEM [%x]\n", WERR_NOMEM)); file_lines_free(qlines); - return ERRnomem; + return WERR_NOMEM; } for (i=0; i offered) { *returned=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else return NT_STATUS_OK; @@ -5636,9 +5633,9 @@ static NTSTATUS enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *ne if(numlines) { if((ports=(PORT_INFO_2 *)malloc( numlines * sizeof(PORT_INFO_2) )) == NULL) { - DEBUG(10,("Returning ERRnomem [%x]\n", ERRnomem)); + DEBUG(10,("Returning WERR_NOMEM [%x]\n", WERR_NOMEM)); file_lines_free(qlines); - return ERRnomem; + return WERR_NOMEM; } for (i=0; i offered) { *returned=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else return NT_STATUS_OK; @@ -5718,7 +5715,7 @@ NTSTATUS _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_EN case 2: return enumports_level_2(buffer, offered, needed, returned); default: - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; } } @@ -5736,7 +5733,7 @@ static NTSTATUS spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *un if ((printer = (NT_PRINTER_INFO_LEVEL *)malloc(sizeof(NT_PRINTER_INFO_LEVEL))) == NULL) { DEBUG(0,("spoolss_addprinterex_level_2: malloc fail.\n")); - return ERRnomem; + return WERR_NOMEM; } ZERO_STRUCTP(printer); @@ -5820,13 +5817,13 @@ NTSTATUS _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOO case 1: /* we don't handle yet */ /* but I know what to do ... */ - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; case 2: return spoolss_addprinterex_level_2(p, uni_srv_name, info, unk0, unk1, unk2, unk3, user_switch, user, handle); default: - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; } } @@ -5848,7 +5845,7 @@ NTSTATUS _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_ get_current_user(&user, p); if (!convert_printer_driver_info(info, &driver, level)) { - err = ERRnomem; + err = WERR_NOMEM; goto done; } @@ -5892,10 +5889,10 @@ static NTSTATUS getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environm unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); if (get_short_archi(short_archi, long_archi)==FALSE) - return ERRinvalidenvironment; + return WERR_INVALID_ENVIRONMENT; if((info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1))) == NULL) - return ERRnomem; + return WERR_NOMEM; slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", global_myname, short_archi); @@ -5907,7 +5904,7 @@ static NTSTATUS getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environm if (!alloc_buffer_size(buffer, *needed)) { safe_free(info); - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } smb_io_driverdir_1("", buffer, info, 0); @@ -5915,7 +5912,7 @@ static NTSTATUS getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environm safe_free(info); if (*needed > offered) - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; else return NT_STATUS_OK; } @@ -5944,7 +5941,7 @@ NTSTATUS _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERD case 1: return getprinterdriverdir_level_1(name, uni_environment, buffer, offered, needed); default: - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; } } @@ -6093,7 +6090,7 @@ NTSTATUS _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, *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 ERRnomem; + return WERR_NOMEM; } *out_value_len = rpcstr_push((char *)*out_value,value, in_value_len, 0); @@ -6104,7 +6101,7 @@ NTSTATUS _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, *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 ERRnomem; + return WERR_NOMEM; } memcpy(*data_out, data, (size_t)data_len); @@ -6146,7 +6143,7 @@ NTSTATUS _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, status = get_a_printer(&printer, 2, lp_servicename(snum)); if (status != 0x0) - return ERRinvalidname; + return WERR_INVALID_NAME; convert_specific_param(¶m, value , type, data, real_len); @@ -6237,7 +6234,7 @@ NTSTATUS _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA * status = get_a_printer(&printer, 2, lp_servicename(snum)); if (status != 0x0) - return ERRinvalidname; + return WERR_INVALID_NAME; ZERO_STRUCTP(¶m); unistr2_to_ascii(param.value, value, sizeof(param.value)-1); @@ -6279,7 +6276,7 @@ NTSTATUS _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFOR count=get_ntforms(&list); if(!add_a_form(&list, form, &count)) - return ERRnomem; + return WERR_NOMEM; write_ntforms(&list, count); safe_free(list); @@ -6364,7 +6361,7 @@ static NTSTATUS enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, PRINTPROCESSOR_1 *info_1=NULL; if((info_1 = (PRINTPROCESSOR_1 *)malloc(sizeof(PRINTPROCESSOR_1))) == NULL) - return ERRnomem; + return WERR_NOMEM; (*returned) = 0x1; @@ -6373,7 +6370,7 @@ static NTSTATUS enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, *needed += spoolss_size_printprocessor_info_1(info_1); if (!alloc_buffer_size(buffer, *needed)) - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; smb_io_printprocessor_info_1("", buffer, info_1, 0); @@ -6381,7 +6378,7 @@ static NTSTATUS enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, if (*needed > offered) { *returned=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else return NT_STATUS_OK; @@ -6420,7 +6417,7 @@ NTSTATUS _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSO case 1: return enumprintprocessors_level_1(buffer, offered, needed, returned); default: - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; } } @@ -6432,7 +6429,7 @@ static NTSTATUS enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offere PRINTPROCDATATYPE_1 *info_1=NULL; if((info_1 = (PRINTPROCDATATYPE_1 *)malloc(sizeof(PRINTPROCDATATYPE_1))) == NULL) - return ERRnomem; + return WERR_NOMEM; (*returned) = 0x1; @@ -6441,7 +6438,7 @@ static NTSTATUS enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offere *needed += spoolss_size_printprocdatatype_info_1(info_1); if (!alloc_buffer_size(buffer, *needed)) - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; smb_io_printprocdatatype_info_1("", buffer, info_1, 0); @@ -6449,7 +6446,7 @@ static NTSTATUS enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offere if (*needed > offered) { *returned=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else return NT_STATUS_OK; @@ -6481,7 +6478,7 @@ NTSTATUS _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCD case 1: return enumprintprocdatatypes_level_1(buffer, offered, needed, returned); default: - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; } } @@ -6494,7 +6491,7 @@ static NTSTATUS enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, ui PRINTMONITOR_1 *info_1=NULL; if((info_1 = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1))) == NULL) - return ERRnomem; + return WERR_NOMEM; (*returned) = 0x1; @@ -6503,7 +6500,7 @@ static NTSTATUS enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, ui *needed += spoolss_size_printmonitor_info_1(info_1); if (!alloc_buffer_size(buffer, *needed)) - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; smb_io_printmonitor_info_1("", buffer, info_1, 0); @@ -6511,7 +6508,7 @@ static NTSTATUS enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, ui if (*needed > offered) { *returned=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else return NT_STATUS_OK; @@ -6525,7 +6522,7 @@ static NTSTATUS enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, ui PRINTMONITOR_2 *info_2=NULL; if((info_2 = (PRINTMONITOR_2 *)malloc(sizeof(PRINTMONITOR_2))) == NULL) - return ERRnomem; + return WERR_NOMEM; (*returned) = 0x1; @@ -6536,7 +6533,7 @@ static NTSTATUS enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, ui *needed += spoolss_size_printmonitor_info_2(info_2); if (!alloc_buffer_size(buffer, *needed)) - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; smb_io_printmonitor_info_2("", buffer, info_2, 0); @@ -6544,7 +6541,7 @@ static NTSTATUS enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, ui if (*needed > offered) { *returned=0; - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; } else return NT_STATUS_OK; @@ -6584,7 +6581,7 @@ NTSTATUS _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS * case 2: return enumprintmonitors_level_2(buffer, offered, needed, returned); default: - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; } } @@ -6600,7 +6597,7 @@ static NTSTATUS getjob_level_1(print_queue_struct *queue, int count, int snum, u if (info_1 == NULL) { safe_free(queue); - return ERRnomem; + return WERR_NOMEM; } for (i=0; i offered) - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; else return NT_STATUS_OK; } @@ -6652,7 +6649,7 @@ static NTSTATUS getjob_level_2(print_queue_struct *queue, int count, int snum, u if (info_2 == NULL) { safe_free(queue); - return ERRnomem; + return WERR_NOMEM; } for (i=0; i offered) - return ERRinsufficientbuffer; + return WERR_INSUFFICIENT_BUFFER; else return NT_STATUS_OK; } @@ -6737,6 +6734,6 @@ NTSTATUS _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB * return getjob_level_2(queue, count, snum, jobid, buffer, offered, needed); default: safe_free(queue); - return ERRunknownlevel; + return WERR_UNKNOWN_LEVEL; } } -- cgit From fbc1f326f445a2826a10155fe0122c779bb1f80e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 3 Sep 2001 10:38:13 +0000 Subject: more NTSTATUS/WERROR conversion (This used to be commit ad648c5cd8ebe4be8304379117f403d7673dcbc8) --- source3/rpc_server/srv_spoolss_nt.c | 314 ++++++++++++++++++------------------ 1 file changed, 156 insertions(+), 158 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 140eed5c05..80c809047c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4000,7 +4000,7 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S NT error code. */ if (Printer->jobid == -1) { - return map_nt_error_from_unix(errno); + return map_werror_from_unix(errno); } Printer->document_started=True; @@ -4045,7 +4045,7 @@ NTSTATUS _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL r_u->buffer_written = q_u->buffer_size2; - return 0x0; + return NT_STATUS_OK; } /******************************************************************** @@ -4053,38 +4053,39 @@ NTSTATUS _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL * called from the spoolss dispatcher * ********************************************************************/ -static NTSTATUS control_printer(POLICY_HND *handle, uint32 command, +static WERROR control_printer(POLICY_HND *handle, uint32 command, pipes_struct *p) { struct current_user user; - int snum, errcode = ERRbadfunc; + int snum; + WERROR errcode = WERR_BADFUNC; 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 NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } if (!get_printer_snum(p, handle, &snum)) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; switch (command) { case PRINTER_CONTROL_PAUSE: if (print_queue_pause(&user, snum, &errcode)) { - errcode = 0; + errcode = WERR_OK; } break; case PRINTER_CONTROL_RESUME: case PRINTER_CONTROL_UNPAUSE: if (print_queue_resume(&user, snum, &errcode)) { - errcode = 0; + errcode = WERR_OK; } break; case PRINTER_CONTROL_PURGE: if (print_queue_purge(&user, snum, &errcode)) { - errcode = 0; + errcode = WERR_OK; } break; default: @@ -4098,7 +4099,7 @@ static NTSTATUS control_printer(POLICY_HND *handle, uint32 command, * api_spoolss_abortprinter ********************************************************************/ -NTSTATUS _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R_ABORTPRINTER *r_u) +WERROR _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R_ABORTPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; @@ -4109,13 +4110,13 @@ NTSTATUS _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL * called by spoolss_api_setprinter * when updating a printer description ********************************************************************/ -static NTSTATUS update_printer_sec(POLICY_HND *handle, uint32 level, +static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, pipes_struct *p, SEC_DESC_BUF *secdesc_ctr) { SEC_DESC_BUF *new_secdesc_ctr = NULL, *old_secdesc_ctr = NULL; struct current_user user; - uint32 result; + WERROR result; int snum; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); @@ -4124,7 +4125,7 @@ static NTSTATUS update_printer_sec(POLICY_HND *handle, uint32 level, DEBUG(0,("update_printer_sec: Invalid handle (%s)\n", OUR_HANDLE(handle))); - result = NT_STATUS_INVALID_HANDLE; + result = WERR_BADFID; goto done; } @@ -4174,7 +4175,7 @@ static NTSTATUS 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_OK; + result = WERR_OK; goto done; } @@ -4188,7 +4189,7 @@ static NTSTATUS update_printer_sec(POLICY_HND *handle, uint32 level, information. */ if (!print_access_check(&user, snum, PRINTER_ACCESS_ADMINISTER)) { - result = NT_STATUS_ACCESS_DENIED; + result = WERR_ACCESS_DENIED; goto done; } @@ -4521,18 +4522,18 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, * when updating a printer description ********************************************************************/ -static NTSTATUS update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, +static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, DEVICEMODE *devmode) { int snum; NT_PRINTER_INFO_LEVEL *printer = NULL, *old_printer = NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - uint32 result; + WERROR result; DEBUG(8,("update_printer\n")); - result = NT_STATUS_OK; + result = WERR_OK; if (level!=2) { DEBUG(0,("Send a mail to samba@samba.org\n")); @@ -4542,18 +4543,18 @@ static NTSTATUS update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level } if (!Printer) { - result = NT_STATUS_INVALID_HANDLE; + result = WERR_BADFID; goto done; } if (!get_printer_snum(p, handle, &snum)) { - result = NT_STATUS_INVALID_HANDLE; + result = WERR_BADFID; goto done; } - if((get_a_printer(&printer, 2, lp_servicename(snum)) != 0) || - (get_a_printer(&old_printer, 2, lp_servicename(snum)) != 0)) { - result = NT_STATUS_INVALID_HANDLE; + if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum))) || + (!W_ERROR_IS_OK(get_a_printer(&old_printer, 2, lp_servicename(snum))))) { + result = WERR_BADFID; goto done; } @@ -4582,7 +4583,7 @@ static NTSTATUS 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 = ERRinvalidparam; + result = WERR_INVALID_PARAM; goto done; } @@ -4592,7 +4593,7 @@ static NTSTATUS 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_OK; + result = WERR_OK; goto done; } @@ -4601,7 +4602,7 @@ static NTSTATUS 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 = NT_STATUS_ACCESS_DENIED; + result = WERR_ACCESS_DENIED; goto done; } @@ -4609,7 +4610,7 @@ static NTSTATUS update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level if (*lp_addprinter_cmd() ) if ( !add_printer_hook(printer) ) { - result = NT_STATUS_ACCESS_DENIED; + result = WERR_ACCESS_DENIED; goto done; } @@ -4617,7 +4618,7 @@ static NTSTATUS 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 = NT_STATUS_ACCESS_DENIED; + result = WERR_ACCESS_DENIED; goto done; } @@ -4633,7 +4634,7 @@ static NTSTATUS update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SETPRINTER *r_u) +WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SETPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; uint32 level = q_u->level; @@ -4646,7 +4647,7 @@ NTSTATUS _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_S if (!Printer) { DEBUG(0,("_spoolss_setprinter: Invalid handle (%s)\n", OUR_HANDLE(handle))); - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } /* check the level */ @@ -4694,16 +4695,16 @@ NTSTATUS _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u) +WERROR _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u) { /* that's an [in out] buffer (despite appearences to the contrary) */ spoolss_move_buffer(q_u->buffer, &r_u->buffer); r_u->needed = 0; - return ERRinvalidparam; /* this is what a NT server - returns for AddJob. AddJob - must fail on non-local - printers */ + return WERR_INVALID_PARAM; /* this is what a NT server + returns for AddJob. AddJob + must fail on non-local + printers */ } /**************************************************************************** @@ -4786,7 +4787,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, /**************************************************************************** Enumjobs at level 1. ****************************************************************************/ -static NTSTATUS enumjobs_level1(print_queue_struct *queue, int snum, +static WERROR enumjobs_level1(print_queue_struct *queue, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { @@ -4825,14 +4826,14 @@ static NTSTATUS enumjobs_level1(print_queue_struct *queue, int snum, *returned=0; return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** Enumjobs at level 2. ****************************************************************************/ -static NTSTATUS enumjobs_level2(print_queue_struct *queue, int snum, +static WERROR enumjobs_level2(print_queue_struct *queue, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { @@ -4880,15 +4881,15 @@ static NTSTATUS enumjobs_level2(print_queue_struct *queue, int snum, *returned=0; return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** Enumjobs. ****************************************************************************/ -NTSTATUS _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJOBS *r_u) +WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJOBS *r_u) { POLICY_HND *handle = &q_u->handle; /* uint32 firstjob = q_u->firstjob; - notused. */ @@ -4915,14 +4916,14 @@ NTSTATUS _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUM *returned=0; if (!get_printer_snum(p, handle, &snum)) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; *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_OK; + return WERR_OK; } switch (level) { @@ -4940,15 +4941,15 @@ NTSTATUS _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUM /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_schedulejob( pipes_struct *p, SPOOL_Q_SCHEDULEJOB *q_u, SPOOL_R_SCHEDULEJOB *r_u) +WERROR _spoolss_schedulejob( pipes_struct *p, SPOOL_Q_SCHEDULEJOB *q_u, SPOOL_R_SCHEDULEJOB *r_u) { - return 0x0; + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u) +WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u) { POLICY_HND *handle = &q_u->handle; uint32 jobid = q_u->jobid; @@ -4958,12 +4959,13 @@ NTSTATUS _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r struct current_user user; print_status_struct prt_status; - int snum, errcode = ERRbadfunc; + int snum; + WERROR errcode = WERR_BADFUNC; memset(&prt_status, 0, sizeof(prt_status)); if (!get_printer_snum(p, handle, &snum)) { - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } if (!print_job_exists(jobid)) { @@ -5000,13 +5002,12 @@ NTSTATUS _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r /**************************************************************************** Enumerates all printer drivers at level 1. ****************************************************************************/ -static NTSTATUS enumprinterdrivers_level1(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; int ndrivers; uint32 version; fstring *list = NULL; - NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_1 *tdi1, *driver_info_1=NULL; @@ -5071,20 +5072,19 @@ static NTSTATUS enumprinterdrivers_level1(fstring servername, fstring architectu *returned=0; return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** Enumerates all printer drivers at level 2. ****************************************************************************/ -static NTSTATUS enumprinterdrivers_level2(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; int ndrivers; uint32 version; fstring *list = NULL; - NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_2 *tdi2, *driver_info_2=NULL; @@ -5150,20 +5150,19 @@ static NTSTATUS enumprinterdrivers_level2(fstring servername, fstring architectu *returned=0; return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** Enumerates all printer drivers at level 3. ****************************************************************************/ -static NTSTATUS enumprinterdrivers_level3(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; int ndrivers; uint32 version; fstring *list = NULL; - NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_3 *tdi3, *driver_info_3=NULL; @@ -5232,15 +5231,15 @@ static NTSTATUS enumprinterdrivers_level3(fstring servername, fstring architectu *returned=0; return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** Enumerates all printer drivers. ****************************************************************************/ -NTSTATUS _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, SPOOL_R_ENUMPRINTERDRIVERS *r_u) +WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, SPOOL_R_ENUMPRINTERDRIVERS *r_u) { /* UNISTR2 *name = &q_u->name; - notused. */ UNISTR2 *environment = &q_u->environment; @@ -5297,7 +5296,7 @@ static void fill_form_1(FORM_1 *form, nt_forms_struct *list) /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u) +WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u) { /* POLICY_HND *handle = &q_u->handle; - notused. */ uint32 level = q_u->level; @@ -5385,7 +5384,7 @@ NTSTATUS _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENU return WERR_INSUFFICIENT_BUFFER; } else - return NT_STATUS_OK; + return WERR_OK; default: safe_free(list); @@ -5398,7 +5397,7 @@ NTSTATUS _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENU /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM *r_u) +WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM *r_u) { /* POLICY_HND *handle = &q_u->handle; - notused. */ uint32 level = q_u->level; @@ -5431,7 +5430,7 @@ NTSTATUS _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 NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } switch (level) { @@ -5473,7 +5472,7 @@ NTSTATUS _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM DEBUGADD(6,("adding form %s [%d] to buffer\n", form_name, i)); smb_io_form_1("", buffer, &form_1, 0); - return NT_STATUS_OK; + return WERR_OK; default: safe_free(list); @@ -5503,7 +5502,7 @@ static void fill_port_2(PORT_INFO_2 *port, char *name) /**************************************************************************** enumports level 1. ****************************************************************************/ -static NTSTATUS enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PORT_INFO_1 *ports=NULL; int i=0; @@ -5525,7 +5524,7 @@ static NTSTATUS enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *ne if (fd != -1) close(fd); /* Is this the best error to return here? */ - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } numlines = 0; @@ -5584,15 +5583,15 @@ static NTSTATUS enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *ne *returned=0; return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** enumports level 2. ****************************************************************************/ -static NTSTATUS enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PORT_INFO_2 *ports=NULL; int i=0; @@ -5623,7 +5622,7 @@ static NTSTATUS enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *ne if (fd != -1) close(fd); /* Is this the best error to return here? */ - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } numlines = 0; @@ -5683,15 +5682,15 @@ static NTSTATUS enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *ne *returned=0; return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** enumports. ****************************************************************************/ -NTSTATUS _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u) +WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u) { /* UNISTR2 *name = &q_u->name; - notused. */ uint32 level = q_u->level; @@ -5721,7 +5720,7 @@ NTSTATUS _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_EN /**************************************************************************** ****************************************************************************/ -static NTSTATUS spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_srv_name, +static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_srv_name, const SPOOL_PRINTER_INFO_LEVEL *info, uint32 unk0, uint32 unk1, uint32 unk2, uint32 unk3, uint32 user_switch, const SPOOL_USER_CTR *user, @@ -5744,7 +5743,7 @@ static NTSTATUS spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *un if (*lp_addprinter_cmd() ) if ( !add_printer_hook(printer) ) { free_a_printer(&printer,2); - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname, @@ -5752,13 +5751,13 @@ static NTSTATUS spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *un if ((snum = print_queue_snum(printer->info_2->sharename)) == -1) { free_a_printer(&printer,2); - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } /* 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 NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } /* @@ -5767,7 +5766,7 @@ static NTSTATUS spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *un if (!check_printer_ok(printer->info_2, snum)) { free_a_printer(&printer,2); - return ERRinvalidparam; + return WERR_INVALID_PARAM; } /* @@ -5780,27 +5779,27 @@ static NTSTATUS spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *un /* write the ASCII on disk */ if (add_a_printer(*printer, 2) != 0) { free_a_printer(&printer,2); - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } 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 NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } free_a_printer(&printer,2); srv_spoolss_sendnotify(p, handle); - return NT_STATUS_OK; + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_R_ADDPRINTEREX *r_u) +WERROR _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_R_ADDPRINTEREX *r_u) { UNISTR2 *uni_srv_name = &q_u->server_name; uint32 level = q_u->level; @@ -5830,13 +5829,12 @@ NTSTATUS _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOO /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, SPOOL_R_ADDPRINTERDRIVER *r_u) +WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, SPOOL_R_ADDPRINTERDRIVER *r_u) { /* UNISTR2 *server_name = &q_u->server_name; - notused. */ uint32 level = q_u->level; SPOOL_PRINTER_DRIVER_INFO_LEVEL *info = &q_u->info; - - uint32 err = NT_STATUS_OK; + WERROR err = WERR_OK; NT_PRINTER_DRIVER_INFO_LEVEL driver; struct current_user user; @@ -5856,12 +5854,12 @@ NTSTATUS _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_ DEBUG(5,("Moving driver to final destination\n")); if(!move_driver_to_download_area(driver, level, &user, &err)) { if (err == 0) - err = NT_STATUS_ACCESS_DENIED; + err = WERR_ACCESS_DENIED; goto done; } if (add_a_printer_driver(driver, level)!=0) { - err = NT_STATUS_ACCESS_DENIED; + err = WERR_ACCESS_DENIED; goto done; } @@ -5879,7 +5877,7 @@ static void fill_driverdir_1(DRIVER_DIRECTORY_1 *info, char *name) /**************************************************************************** ****************************************************************************/ -static NTSTATUS getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environment, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environment, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { pstring path; pstring long_archi; @@ -5913,14 +5911,14 @@ static NTSTATUS getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environm if (*needed > offered) return WERR_INSUFFICIENT_BUFFER; - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, SPOOL_R_GETPRINTERDRIVERDIR *r_u) +WERROR _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, SPOOL_R_GETPRINTERDRIVERDIR *r_u) { UNISTR2 *name = &q_u->name; UNISTR2 *uni_environment = &q_u->environment; @@ -5948,7 +5946,7 @@ NTSTATUS _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERD /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, SPOOL_R_ENUMPRINTERDATA *r_u) +WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, SPOOL_R_ENUMPRINTERDATA *r_u) { POLICY_HND *handle = &q_u->handle; uint32 idx = q_u->index; @@ -5991,14 +5989,14 @@ NTSTATUS _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, if (!Printer) { DEBUG(0,("_spoolss_enumprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } if (!get_printer_snum(p,handle, &snum)) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; if (get_a_printer(&printer, 2, lp_servicename(snum)) != 0) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; /* * The NT machine wants to know the biggest size of value and data @@ -6021,7 +6019,7 @@ NTSTATUS _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, if (!get_specific_param_by_index(*printer, 2, idx, value, &data, &type, &data_len)) { safe_free(data); free_a_printer(&printer, 2); - return ERRnomoreitems; + return WERR_NO_MORE_ITEMS; } #endif @@ -6052,7 +6050,7 @@ NTSTATUS _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, if (param_index == 0) { /* No parameters found. */ free_a_printer(&printer, 2); - return ERRnomoreitems; + return WERR_NO_MORE_ITEMS; } /* the value is an UNICODE string but realvaluesize is the length in bytes including the leading 0 */ @@ -6062,7 +6060,7 @@ NTSTATUS _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, DEBUG(6,("final values: [%d], [%d]\n", *out_value_len, *out_data_len)); free_a_printer(&printer, 2); - return NT_STATUS_OK; + return WERR_OK; } /* @@ -6073,7 +6071,7 @@ NTSTATUS _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, if (!get_specific_param_by_index(*printer, 2, idx, value, &data, &type, &data_len)) { safe_free(data); free_a_printer(&printer, 2); - return ERRnomoreitems; + return WERR_NO_MORE_ITEMS; } free_a_printer(&printer, 2); @@ -6109,13 +6107,13 @@ NTSTATUS _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, safe_free(data); - return NT_STATUS_OK; + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SPOOL_R_SETPRINTERDATA *r_u) +WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SPOOL_R_SETPRINTERDATA *r_u) { POLICY_HND *handle = &q_u->handle; UNISTR2 *value = &q_u->value; @@ -6128,18 +6126,18 @@ NTSTATUS _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_PARAM *param = NULL, old_param; int snum=0; - NTSTATUS status = 0x0; + WERROR status = WERR_OK; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); DEBUG(5,("spoolss_setprinterdata\n")); if (!Printer) { DEBUG(0,("_spoolss_setprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } if (!get_printer_snum(p,handle, &snum)) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; status = get_a_printer(&printer, 2, lp_servicename(snum)); if (status != 0x0) @@ -6150,7 +6148,7 @@ NTSTATUS _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, /* Check if we are making any changes or not. Return true if nothing is actually changing. */ - ZERO_STRUCT(old_param); + ZERO_STRUCT(old_param); if (get_specific_param(*printer, 2, param->value, &old_param.data, &old_param.type, (uint32 *)&old_param.data_len)) { @@ -6161,7 +6159,7 @@ NTSTATUS _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, old_param.data_len) == 0) { DEBUG(3, ("setprinterdata hasn't changed\n")); - status = NT_STATUS_OK; + status = WERR_OK; goto done; } } @@ -6171,7 +6169,7 @@ NTSTATUS _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { DEBUG(3, ("security descriptor change denied by existing " "security descriptor\n")); - status = NT_STATUS_ACCESS_DENIED; + status = WERR_ACCESS_DENIED; goto done; } @@ -6205,7 +6203,7 @@ NTSTATUS _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_u, SPOOL_R_DELETEPRINTERDATA *r_u) +WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_u, SPOOL_R_DELETEPRINTERDATA *r_u) { POLICY_HND *handle = &q_u->handle; UNISTR2 *value = &q_u->valuename; @@ -6213,23 +6211,23 @@ NTSTATUS _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA * NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_PARAM param; int snum=0; - NTSTATUS status = 0x0; + WERROR status = WERR_OK; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); DEBUG(5,("spoolss_deleteprinterdata\n")); if (!Printer) { DEBUG(0,("_spoolss_deleteprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } if (!get_printer_snum(p, handle, &snum)) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { DEBUG(3, ("_spoolss_deleteprinterdata: printer properties " "change denied by existing security descriptor\n")); - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } status = get_a_printer(&printer, 2, lp_servicename(snum)); @@ -6240,7 +6238,7 @@ NTSTATUS _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA * unistr2_to_ascii(param.value, value, sizeof(param.value)-1); if(!unlink_specific_param_if_exist(printer->info_2, ¶m)) - status = ERRinvalidparam; + status = WERR_INVALID_PARAM; else status = mod_a_printer(*printer, 2); @@ -6251,7 +6249,7 @@ NTSTATUS _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA * /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM *r_u) +WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM *r_u) { POLICY_HND *handle = &q_u->handle; /* uint32 level = q_u->level; - notused. */ @@ -6266,12 +6264,12 @@ NTSTATUS _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFOR if (!Printer) { DEBUG(0,("_spoolss_addform: Invalid handle (%s).\n", OUR_HANDLE(handle))); - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } /* can't add if builtin */ if (get_a_builtin_ntform(&form->name,&tmpForm)) { - return ERRinvalidparam; + return WERR_INVALID_PARAM; } count=get_ntforms(&list); @@ -6281,19 +6279,19 @@ NTSTATUS _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFOR safe_free(list); - return 0x0; + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DELETEFORM *r_u) +WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DELETEFORM *r_u) { POLICY_HND *handle = &q_u->handle; UNISTR2 *form_name = &q_u->name; nt_forms_struct tmpForm; int count=0; - uint32 ret = 0; + WERROR ret = 0; nt_forms_struct *list=NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); @@ -6301,17 +6299,17 @@ NTSTATUS _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_ if (!Printer) { DEBUG(0,("_spoolss_deleteform: Invalid handle (%s).\n", OUR_HANDLE(handle))); - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } /* can't delete if builtin */ if (get_a_builtin_ntform(form_name,&tmpForm)) { - return ERRinvalidparam; + return WERR_INVALID_PARAM; } count = get_ntforms(&list); if(!delete_a_form(&list, form_name, &count, &ret)) - return ERRinvalidparam; + return WERR_INVALID_PARAM; safe_free(list); @@ -6321,7 +6319,7 @@ NTSTATUS _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_ /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM *r_u) +WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM *r_u) { POLICY_HND *handle = &q_u->handle; /* UNISTR2 *uni_name = &q_u->name; - notused. */ @@ -6337,11 +6335,11 @@ NTSTATUS _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 NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } /* can't set if builtin */ if (get_a_builtin_ntform(&form->name,&tmpForm)) { - return ERRinvalidparam; + return WERR_INVALID_PARAM; } count=get_ntforms(&list); @@ -6350,13 +6348,13 @@ NTSTATUS _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM safe_free(list); - return 0x0; + return WERR_OK; } /**************************************************************************** enumprintprocessors level 1. ****************************************************************************/ -static NTSTATUS enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTPROCESSOR_1 *info_1=NULL; @@ -6380,21 +6378,21 @@ static NTSTATUS enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, *returned=0; return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, SPOOL_R_ENUMPRINTPROCESSORS *r_u) +WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, SPOOL_R_ENUMPRINTPROCESSORS *r_u) { /* UNISTR2 *name = &q_u->name; - notused. */ /* UNISTR2 *environment = &q_u->environment; - notused. */ uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; - uint32 *needed = &r_u->needed; + uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ @@ -6424,7 +6422,7 @@ NTSTATUS _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSO /**************************************************************************** enumprintprocdatatypes level 1. ****************************************************************************/ -static NTSTATUS enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTPROCDATATYPE_1 *info_1=NULL; @@ -6448,14 +6446,14 @@ static NTSTATUS enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offere *returned=0; return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u) +WERROR _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u) { /* UNISTR2 *name = &q_u->name; - notused. */ /* UNISTR2 *processor = &q_u->processor; - notused. */ @@ -6486,7 +6484,7 @@ NTSTATUS _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCD enumprintmonitors level 1. ****************************************************************************/ -static NTSTATUS enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTMONITOR_1 *info_1=NULL; @@ -6510,14 +6508,14 @@ static NTSTATUS enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, ui *returned=0; return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** enumprintmonitors level 2. ****************************************************************************/ -static NTSTATUS enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTMONITOR_2 *info_2=NULL; @@ -6543,20 +6541,20 @@ static NTSTATUS enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, ui *returned=0; return WERR_INSUFFICIENT_BUFFER; } - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_u, SPOOL_R_ENUMPRINTMONITORS *r_u) +WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_u, SPOOL_R_ENUMPRINTMONITORS *r_u) { /* UNISTR2 *name = &q_u->name; - notused. */ uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; - uint32 *needed = &r_u->needed; + uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ @@ -6587,7 +6585,7 @@ NTSTATUS _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS * /**************************************************************************** ****************************************************************************/ -static NTSTATUS getjob_level_1(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getjob_level_1(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { int i=0; BOOL found=False; @@ -6609,7 +6607,7 @@ static NTSTATUS getjob_level_1(print_queue_struct *queue, int count, int snum, u safe_free(queue); safe_free(info_1); /* I shoud reply something else ... I can't find the good one */ - return NT_STATUS_OK; + return WERR_OK; } fill_job_info_1(info_1, &(queue[i-1]), i, snum); @@ -6629,14 +6627,14 @@ static NTSTATUS getjob_level_1(print_queue_struct *queue, int count, int snum, u if (*needed > offered) return WERR_INSUFFICIENT_BUFFER; - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -static NTSTATUS getjob_level_2(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { int i=0; BOOL found=False; @@ -6661,7 +6659,7 @@ static NTSTATUS getjob_level_2(print_queue_struct *queue, int count, int snum, u safe_free(queue); safe_free(info_2); /* I shoud reply something else ... I can't find the good one */ - return NT_STATUS_OK; + return WERR_OK; } if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0) { @@ -6688,14 +6686,14 @@ static NTSTATUS getjob_level_2(print_queue_struct *queue, int count, int snum, u if (*needed > offered) return WERR_INSUFFICIENT_BUFFER; - else - return NT_STATUS_OK; + + return WERR_OK; } /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_u) +WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_u) { POLICY_HND *handle = &q_u->handle; uint32 jobid = q_u->jobid; @@ -6720,7 +6718,7 @@ NTSTATUS _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB * *needed=0; if (!get_printer_snum(p, handle, &snum)) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; count = print_queue_status(snum, &queue, &prt_status); -- cgit From 19fea3242cf6234786b6cbb60631e0071f31ff9f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 4 Sep 2001 07:13:01 +0000 Subject: the next stage in the NTSTATUS/WERROR change. smbd and nmbd now compile, but the client code still needs some work (This used to be commit dcd6e735f709a9231860ceb9682db40ff26c9a66) --- source3/rpc_server/srv_spoolss.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 203 +++++++++++++++++++----------------- 2 files changed, 108 insertions(+), 97 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 011efb1bac..eed24bfe8c 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/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_OK; + r_u.status = WERR_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/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 80c809047c..c12df62913 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -160,7 +160,7 @@ static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp) static void srv_spoolss_replycloseprinter(POLICY_HND *handle) { - NTSTATUS status; + WERROR status; /* weird if the test succeds !!! */ if (smb_connections==0) { @@ -270,18 +270,18 @@ static BOOL close_printer_handle(pipes_struct *p, POLICY_HND *hnd) /**************************************************************************** delete a printer given a handle ****************************************************************************/ -static NTSTATUS delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) +static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) { Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); if (!Printer) { DEBUG(0,("delete_printer_handle: Invalid handle (%s)\n", OUR_HANDLE(hnd))); - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } if (del_a_printer(Printer->dev.handlename) != 0) { DEBUG(3,("Error deleting printer %s\n", Printer->dev.handlename)); - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } /* Check calling user has permission to delete printer. Note that @@ -291,7 +291,7 @@ static NTSTATUS 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 NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } if (*lp_deleteprinter_cmd()) { @@ -308,7 +308,7 @@ static NTSTATUS delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) DEBUG(10,("Running [%s]\n", command)); ret = smbrun(command, NULL); if (ret != 0) { - return NT_STATUS_INVALID_HANDLE; /* What to return here? */ + return WERR_BADFID; /* What to return here? */ } DEBUGADD(10,("returned [%d]\n", ret)); @@ -317,12 +317,12 @@ static NTSTATUS delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) if ( ( i = lp_servicenumber( Printer->dev.handlename ) ) >= 0 ) { lp_killservice( i ); - return NT_STATUS_OK; + return WERR_OK; } else - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } - return NT_STATUS_OK; + return WERR_OK; } /**************************************************************************** @@ -618,7 +618,7 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) { fstring printer; - NTSTATUS status; + WERROR status; struct pipes_struct *p; struct policy *pol; struct handle_list *hl; @@ -706,10 +706,10 @@ static BOOL srv_spoolss_sendnotify(pipes_struct *p, POLICY_HND *handle) * called from the spoolss dispatcher ********************************************************************/ -NTSTATUS _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, SPOOL_R_OPEN_PRINTER_EX *r_u) +WERROR _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_OK; + WERROR result = WERR_OK; #endif UNISTR2 *printername = NULL; @@ -726,7 +726,7 @@ NTSTATUS _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u printername = &q_u->printername; if (printername == NULL) - return NT_STATUS_OBJECT_NAME_INVALID; + return WERR_INVALID_PRINTER_NAME; /* some sanity check because you can open a printer or a print server */ /* aka: \\server\printer or \\server */ @@ -735,7 +735,7 @@ NTSTATUS _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 NT_STATUS_OBJECT_NAME_INVALID; + return WERR_INVALID_PRINTER_NAME; /* if (printer_default->datatype_ptr != NULL) @@ -749,7 +749,7 @@ NTSTATUS _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 NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } /* @@ -779,7 +779,7 @@ NTSTATUS _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_OK; + return WERR_OK; } else if ((printer_default->access_required & SERVER_ACCESS_ADMINISTER ) == SERVER_ACCESS_ADMINISTER) { @@ -788,14 +788,14 @@ NTSTATUS _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 NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } else if (user.uid == 0 || user_in_list(uidtoname(user.uid), lp_printer_admin(snum))) { - return NT_STATUS_OK; + return WERR_OK; } else { close_printer_handle(p, handle); - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } } } @@ -805,7 +805,7 @@ NTSTATUS _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 NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; /* map an empty access mask to the minimum access mask */ if (printer_default->access_required == 0x0) @@ -826,7 +826,7 @@ NTSTATUS _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u if (!print_access_check(&user, snum, printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); close_printer_handle(p, handle); - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } /* @@ -905,7 +905,7 @@ NTSTATUS _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u #endif } - return NT_STATUS_OK; + return WERR_OK; } /**************************************************************************** @@ -1021,27 +1021,27 @@ BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, * _spoolss_enddocprinter_internal. ********************************************************************/ -static NTSTATUS _spoolss_enddocprinter_internal(pipes_struct *p, POLICY_HND *handle) +static WERROR _spoolss_enddocprinter_internal(pipes_struct *p, POLICY_HND *handle) { Printer_entry *Printer=find_printer_index_by_hnd(p, handle); if (!Printer) { DEBUG(0,("_spoolss_enddocprinter_internal: Invalid handle (%s)\n", OUR_HANDLE(handle))); - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } Printer->document_started=False; print_job_end(Printer->jobid,True); /* error codes unhandled so far ... */ - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************** * api_spoolss_closeprinter ********************************************************************/ -NTSTATUS _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL_R_CLOSEPRINTER *r_u) +WERROR _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL_R_CLOSEPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; @@ -1053,9 +1053,9 @@ NTSTATUS _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL memcpy(&r_u->handle, &q_u->handle, sizeof(r_u->handle)); if (!close_printer_handle(p, handle)) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************** @@ -1063,11 +1063,11 @@ NTSTATUS _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL ********************************************************************/ -NTSTATUS _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL_R_DELETEPRINTER *r_u) +WERROR _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL_R_DELETEPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); - NTSTATUS result; + WERROR result; if (Printer && Printer->document_started) _spoolss_enddocprinter_internal(p, handle); /* print job was not closed */ @@ -1076,7 +1076,7 @@ NTSTATUS _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPO result = delete_printer_handle(p, handle); - if (NT_STATUS_IS_OK(result)) { + if (W_ERROR_IS_OK(result)) { srv_spoolss_sendnotify(p, handle); } @@ -1124,7 +1124,7 @@ static int get_version_id (char * arch) * --jerry ********************************************************************/ -NTSTATUS _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER *q_u, +WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER *q_u, SPOOL_R_DELETEPRINTERDRIVER *r_u) { fstring driver; @@ -1137,18 +1137,18 @@ NTSTATUS _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV /* check that we have a valid driver name first */ if ((version=get_version_id(arch)) == -1) { - return NT_STATUS_REVISION_MISMATCH; + return WERR_INVALID_ENVIRONMENT; } ZERO_STRUCT(info); if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) { - return NT_STATUS_DRIVER_ORDINAL_NOT_FOUND; + return WERR_UNKNOWN_PRINTER_DRIVER; } if (printer_driver_in_use(arch, driver)) { - return NT_STATUS_NETWORK_BUSY; + return WERR_PRINTER_DRIVER_IN_USE; } return delete_printer_driver(info.info_3); @@ -1293,7 +1293,7 @@ static BOOL getprinterdata_printer(pipes_struct *p, TALLOC_CTX *ctx, POLICY_HND * spoolss_getprinterdata ********************************************************************/ -NTSTATUS _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPOOL_R_GETPRINTERDATA *r_u) +WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPOOL_R_GETPRINTERDATA *r_u) { POLICY_HND *handle = &q_u->handle; UNISTR2 *valuename = &q_u->valuename; @@ -1324,9 +1324,9 @@ NTSTATUS _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, S if (!Printer) { if((*data=(uint8 *)malloc(4*sizeof(uint8))) == NULL) - return NT_STATUS_NO_MEMORY; + return WERR_NOMEM; DEBUG(0,("_spoolss_getprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } unistr2_to_ascii(value, valuename, sizeof(value)-1); @@ -1341,18 +1341,18 @@ NTSTATUS _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, S /* reply this param doesn't exist */ if (*out_size) { if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) - return NT_STATUS_NO_MEMORY; + return WERR_NOMEM; } else { *data = NULL; } - return NT_STATUS_INVALID_PARAMETER; + return WERR_INVALID_PARAM; } if (*needed > *out_size) - return STATUS_MORE_ENTRIES; + return WERR_STATUS_MORE_ENTRIES; else { - return NT_STATUS_OK; + return WERR_OK; } } @@ -1361,7 +1361,7 @@ NTSTATUS _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, S ****************************************************************************/ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle) { - NTSTATUS status; + WERROR status; /* * If it's the first connection, contact the client @@ -1398,7 +1398,7 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin * called from api_spoolss_rffpcnex ********************************************************************/ -NTSTATUS _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNEX *r_u) +WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNEX *r_u) { POLICY_HND *handle = &q_u->handle; uint32 flags = q_u->flags; @@ -1413,7 +1413,7 @@ NTSTATUS _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPC if (!Printer) { DEBUG(0,("_spoolss_rffpcnex: Invalid handle (%s).\n", OUR_HANDLE(handle))); - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } Printer->notify.flags=flags; @@ -1433,7 +1433,7 @@ NTSTATUS _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPC &Printer->notify.client_hnd)) Printer->notify.client_connected=True; - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************* @@ -3906,7 +3906,7 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_startpageprinter(pipes_struct *p, SPOOL_Q_STARTPAGEPRINTER *q_u, SPOOL_R_STARTPAGEPRINTER *r_u) +WERROR _spoolss_startpageprinter(pipes_struct *p, SPOOL_Q_STARTPAGEPRINTER *q_u, SPOOL_R_STARTPAGEPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; @@ -3914,17 +3914,17 @@ NTSTATUS _spoolss_startpageprinter(pipes_struct *p, SPOOL_Q_STARTPAGEPRINTER *q_ if (Printer) { Printer->page_started=True; - return NT_STATUS_OK; + return WERR_OK; } DEBUG(3,("Error in startpageprinter printer handle\n")); - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPOOL_R_ENDPAGEPRINTER *r_u) +WERROR _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPOOL_R_ENDPAGEPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; @@ -3932,12 +3932,12 @@ NTSTATUS _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, S if (!Printer) { DEBUG(0,("_spoolss_endpageprinter: Invalid handle (%s).\n",OUR_HANDLE(handle))); - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } Printer->page_started=False; - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************** @@ -4015,7 +4015,7 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S * ********************************************************************/ -NTSTATUS _spoolss_enddocprinter(pipes_struct *p, SPOOL_Q_ENDDOCPRINTER *q_u, SPOOL_R_ENDDOCPRINTER *r_u) +WERROR _spoolss_enddocprinter(pipes_struct *p, SPOOL_Q_ENDDOCPRINTER *q_u, SPOOL_R_ENDDOCPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; @@ -4025,7 +4025,7 @@ NTSTATUS _spoolss_enddocprinter(pipes_struct *p, SPOOL_Q_ENDDOCPRINTER *q_u, SPO /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R_WRITEPRINTER *r_u) +WERROR _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R_WRITEPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; uint32 buffer_size = q_u->buffer_size; @@ -4037,7 +4037,7 @@ NTSTATUS _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL if (!Printer) { DEBUG(0,("_spoolss_writeprinter: Invalid handle (%s)\n",OUR_HANDLE(handle))); r_u->buffer_written = q_u->buffer_size2; - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } (*buffer_written) = print_job_write(Printer->jobid, (char *)buffer, buffer_size); @@ -4045,7 +4045,7 @@ NTSTATUS _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL r_u->buffer_written = q_u->buffer_size2; - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************** @@ -4608,19 +4608,15 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, /* Call addprinter hook */ - if (*lp_addprinter_cmd() ) - if ( !add_printer_hook(printer) ) { + if (*lp_addprinter_cmd()) { + if (!add_printer_hook(printer)) { result = WERR_ACCESS_DENIED; goto done; } + } /* Update printer info */ - - if (add_a_printer(*printer, 2)!=0) { - /* I don't really know what to return here !!! */ - result = WERR_ACCESS_DENIED; - goto done; - } + result = add_a_printer(*printer, 2); done: free_a_printer(&printer, 2); @@ -4667,7 +4663,7 @@ WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET /**************************************************************************** ****************************************************************************/ -NTSTATUS _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) +WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) { POLICY_HND *handle = &q_u->handle; @@ -4675,7 +4671,7 @@ NTSTATUS _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 NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; } if (Printer->notify.client_connected==True) @@ -4689,7 +4685,7 @@ NTSTATUS _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_OK; + return WERR_OK; } /**************************************************************************** @@ -4840,6 +4836,7 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, NT_PRINTER_INFO_LEVEL *ntprinter = NULL; JOB_INFO_2 *info; int i; + WERROR result; info=(JOB_INFO_2 *)malloc(*returned*sizeof(JOB_INFO_2)); if (info==NULL) { @@ -4847,9 +4844,10 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, return WERR_NOMEM; } - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0) { + result = get_a_printer(&ntprinter, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(result)) { *returned = 0; - return WERR_NOMEM; + return result; } for (i=0; i<*returned; i++) @@ -4978,18 +4976,18 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u case JOB_CONTROL_CANCEL: case JOB_CONTROL_DELETE: if (print_job_delete(&user, jobid, &errcode)) { - errcode = 0; + errcode = WERR_OK; } break; case JOB_CONTROL_PAUSE: if (print_job_pause(&user, jobid, &errcode)) { - errcode = 0; + errcode = WERR_OK; } break; case JOB_CONTROL_RESTART: case JOB_CONTROL_RESUME: if (print_job_resume(&user, jobid, &errcode)) { - errcode = 0; + errcode = WERR_OK; } break; default: @@ -5034,10 +5032,12 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture } for (i=0; iname; nt_forms_struct tmpForm; int count=0; - WERROR ret = 0; + WERROR ret = WERR_OK; nt_forms_struct *list=NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); @@ -6308,7 +6317,7 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE } count = get_ntforms(&list); - if(!delete_a_form(&list, form_name, &count, &ret)) + if (!delete_a_form(&list, form_name, &count, &ret)) return WERR_INVALID_PARAM; safe_free(list); @@ -6640,6 +6649,7 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin BOOL found=False; JOB_INFO_2 *info_2; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; + WERROR ret; info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2)); @@ -6662,9 +6672,10 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin return WERR_OK; } - if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0) { + ret = get_a_printer(&ntprinter, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(ret)) { safe_free(queue); - return WERR_NOMEM; + return ret; } fill_job_info_2(info_2, &(queue[i-1]), i, snum, ntprinter); -- cgit From b04933dfbb891532d08e7de42bdcf2eb9186a018 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 4 Sep 2001 11:18:50 +0000 Subject: a fix for fussy compilers (This used to be commit 78f437b5073207606b23be42960e2b10f785a148) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c12df62913..514aa5b9dd 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3214,7 +3214,7 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ return enumprinters_level5(flags, name, buffer, offered, needed, returned); case 3: case 4: - default: + break; } return WERR_UNKNOWN_LEVEL; } -- cgit From b31055fa74571b9dadd209633ac4547f4ac8368d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 6 Sep 2001 05:24:37 +0000 Subject: Logon workstation checks from Toomas Soome Fixed compile warning. (This used to be commit 3eee66516596835c70c8d652ca633d2e1158fbb7) --- source3/rpc_server/srv_netlog_nt.c | 51 +++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 1a2ef02f2c..455f8d8be5 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -79,7 +79,7 @@ NTSTATUS _net_logon_ctrl(pipes_struct *p, NET_Q_LOGON_CTRL *q_u, /**************************************************************************** Send a message to smbd to do a sam synchronisation **************************************************************************/ -static void send_sync_message() +static void send_sync_message(void) { TDB_CONTEXT *tdb; @@ -599,8 +599,9 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * SAM_ACCOUNT *sampass = NULL; UNISTR2 *uni_samlogon_user = NULL; UNISTR2 *uni_samlogon_domain = NULL; - fstring nt_username; - fstring nt_domain; + UNISTR2 *uni_samlogon_workstation = NULL; + fstring nt_username, nt_domain, nt_workstation; + BOOL ret; usr_info = (NET_USER_INFO_3 *)talloc(p->mem_ctx, sizeof(NET_USER_INFO_3)); @@ -633,12 +634,14 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * case INTERACTIVE_LOGON_TYPE: uni_samlogon_user = &q_u->sam_id.ctr->auth.id1.uni_user_name; uni_samlogon_domain = &q_u->sam_id.ctr->auth.id1.uni_domain_name; + uni_samlogon_workstation = &q_u->sam_id.ctr->auth.id1.uni_wksta_name; DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); break; case NET_LOGON_TYPE: uni_samlogon_user = &q_u->sam_id.ctr->auth.id2.uni_user_name; uni_samlogon_domain = &q_u->sam_id.ctr->auth.id2.uni_domain_name; + uni_samlogon_workstation = &q_u->sam_id.ctr->auth.id2.uni_wksta_name; DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); break; @@ -651,8 +654,10 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * rpcstr_pull(nt_username,uni_samlogon_user->buffer,sizeof(nt_username),uni_samlogon_user->uni_str_len*2,0); rpcstr_pull(nt_domain,uni_samlogon_domain->buffer,sizeof(nt_domain),uni_samlogon_domain->uni_str_len*2,0); + rpcstr_pull(nt_workstation,uni_samlogon_workstation->buffer,sizeof(nt_workstation),uni_samlogon_workstation->uni_str_len*2,0); - DEBUG(3,("User:[%s] Requested Domain:[%s]\n", nt_username, nt_domain)); + DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, + nt_workstation, nt_domain)); /* * Convert to a UNIX username. @@ -676,15 +681,43 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * ret = pdb_getsampwnam(sampass, nt_username); unbecome_root(); - if (ret == False){ + if (ret == False) { pdb_free_sam(sampass); return NT_STATUS_NO_SUCH_USER; } + + /* Test account expire time */ + + if (time(NULL) > sampass->kickoff_time) + return NT_STATUS_ACCOUNT_EXPIRED; + + /* Test workstation. Workstation list is comma separated. */ + + if (sampass->workstations && *sampass->workstations) { + char *s = strdup(sampass->workstations); + BOOL invalid_ws = True; + fstring tok; + + while(next_token(&s, tok, ",", sizeof(tok))) { + if(strequal(tok, nt_workstation)) { + invalid_ws = False; + break; + } + } + + free(s); + + if (invalid_ws) + return NT_STATUS_INVALID_WORKSTATION; + } + + /* Test logon hours. */ + + /* Test must change password. */ - /* 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. - */ + /* 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. */ { DOM_GID *gids = NULL; -- cgit From 9a9ac2739bbdc993ecdfa78298bdd9c059328378 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Sep 2001 22:08:19 +0000 Subject: got rid of USE_TDB_MMAP_FLAG as its not needed any more (This used to be commit c26e0d3f27a05ecc8bd2390f9aab7f9451524e47) --- source3/rpc_server/srv_netlog_nt.c | 2 +- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 455f8d8be5..fd137e6038 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -84,7 +84,7 @@ static void send_sync_message(void) TDB_CONTEXT *tdb; tdb = tdb_open_log(lock_path("connections.tdb"), 0, - USE_TDB_MMAP_FLAG, O_RDONLY, 0); + TDB_DEFAULT, O_RDONLY, 0); if (!tdb) { DEBUG(3, ("send_sync_message(): failed to open connections " diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 5ba460b607..a0ae9050e2 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -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, USE_TDB_MMAP_FLAG, 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) )); -- cgit From c113b5196f28a9af948e8104f543615c0165fd78 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 10 Sep 2001 19:29:00 +0000 Subject: merge from APPLIANCE_HEAD (This used to be commit 55bd514c4576a273dac1ac5c37207a96b41f6572) --- source3/rpc_server/srv_spoolss_nt.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 514aa5b9dd..2a412ccc98 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6154,11 +6154,29 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP convert_specific_param(¶m, 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); + /* + * 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 = ERROR_ACCESS_DENIED; + 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 */ + if (get_specific_param(*printer, 2, param->value, &old_param.data, &old_param.type, (uint32 *)&old_param.data_len)) { @@ -6173,15 +6191,6 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP } } - /* Access check */ - - if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { - DEBUG(3, ("security descriptor change denied by existing " - "security descriptor\n")); - status = WERR_ACCESS_DENIED; - goto done; - } - unlink_specific_param_if_exist(printer->info_2, param); /* -- cgit From cae476a1a2080b2267b7d2efe81b2e80b45a0031 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 10 Sep 2001 19:30:34 +0000 Subject: cut-n-paste error (This used to be commit b2ed211df0cad2013fd8ff67f48bf73962cc1d39) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2a412ccc98..cffdfb0ff9 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6167,7 +6167,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { DEBUG(3, ("security descriptor change denied by existing " "security descriptor\n")); - status = ERROR_ACCESS_DENIED; + status = WERR_ACCESS_DENIED; goto done; } -- cgit From a39d4c052c2787f97957d432c0faa337144778f8 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 12 Sep 2001 01:14:03 +0000 Subject: Converted DFS error returns to WERROR instead of uint32. (This used to be commit 97286570ef6f9151b5fe0be32aa4b294e7db9ab8) --- source3/rpc_server/srv_dfs_nt.c | 60 ++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 27 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 034b1bbe77..ce8d353274 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -34,6 +34,9 @@ extern pstring global_myname; #define MAX_MSDFS_JUNCTIONS 256 +/* This function does not return a WERROR or NTSTATUS code but rather 1 if + dfs exists, or 0 otherwise. */ + uint32 _dfs_exist(pipes_struct *p, DFS_Q_DFS_EXIST *q_u, DFS_R_DFS_EXIST *r_u) { if(lp_host_msdfs()) @@ -42,7 +45,7 @@ uint32 _dfs_exist(pipes_struct *p, DFS_Q_DFS_EXIST *q_u, DFS_R_DFS_EXIST *r_u) return 0; } -uint32 _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) +WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) { struct current_user user; struct junction_map jn; @@ -56,7 +59,7 @@ 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; + return WERR_ACCESS_DENIED; } unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1); @@ -71,7 +74,7 @@ uint32 _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) pstrcat(altpath, sharename); if(!create_junction(dfspath, &jn)) - return NERR_DfsNoSuchServer; + return WERR_DFS_NO_SUCH_SERVER; if(get_referred_path(&jn)) { @@ -88,7 +91,7 @@ uint32 _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) if(jn.referral_list == NULL) { DEBUG(0,("init_reply_dfs_add: talloc failed for referral list!\n")); - return NERR_DfsInternalError; + return WERR_DFS_INTERNAL_ERROR; } if(old_referral_list) @@ -104,12 +107,13 @@ uint32 _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) pstrcpy(jn.referral_list[jn.referral_count-1].alternate_path, altpath); if(!create_msdfs_link(&jn, exists)) - return NERR_DfsCantCreateJunctionPoint; + return WERR_DFS_CANT_CREATE_JUNCT; - return NT_STATUS_OK; + return WERR_OK; } -uint32 _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DFS_R_DFS_REMOVE *r_u) +WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, + DFS_R_DFS_REMOVE *r_u) { struct current_user user; struct junction_map jn; @@ -122,7 +126,7 @@ 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; + return WERR_ACCESS_DENIED; } unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1); @@ -143,16 +147,16 @@ uint32 _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DFS_R_DFS_REMOVE *r_u dfspath, servername, sharename)); if(!create_junction(dfspath, &jn)) - return NERR_DfsNoSuchServer; + return WERR_DFS_NO_SUCH_SERVER; if(!get_referred_path(&jn)) - return NERR_DfsNoSuchVolume; + return WERR_DFS_NO_SUCH_VOL; /* if no server-share pair given, remove the msdfs link completely */ if(!q_u->ptr_ServerName && !q_u->ptr_ShareName) { if(!remove_msdfs_link(&jn)) - return NERR_DfsNoSuchVolume; + return WERR_DFS_NO_SUCH_VOL; } else { @@ -170,22 +174,22 @@ uint32 _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DFS_R_DFS_REMOVE *r_u } } if(!found) - return NERR_DfsNoSuchShare; + return WERR_DFS_NO_SUCH_SHARE; /* Only one referral, remove it */ if(jn.referral_count == 1) { if(!remove_msdfs_link(&jn)) - return NERR_DfsNoSuchVolume; + return WERR_DFS_NO_SUCH_VOL; } else { if(!create_msdfs_link(&jn, True)) - return NERR_DfsCantCreateJunctionPoint; + return WERR_DFS_CANT_CREATE_JUNCT; } } - return NT_STATUS_OK; + return WERR_OK; } static BOOL init_reply_dfs_info_1(struct junction_map* j, DFS_INFO_1* dfs1, int num_j) @@ -270,8 +274,9 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I return True; } -static uint32 init_reply_dfs_ctr(TALLOC_CTX *ctx, uint32 level, DFS_INFO_CTR* ctr, - struct junction_map* jn, int num_jn) +static WERROR init_reply_dfs_ctr(TALLOC_CTX *ctx, uint32 level, + DFS_INFO_CTR* ctr, struct junction_map* jn, + int num_jn) { /* do the levels */ switch(level) @@ -281,7 +286,7 @@ static uint32 init_reply_dfs_ctr(TALLOC_CTX *ctx, uint32 level, DFS_INFO_CTR* ct DFS_INFO_1* dfs1; dfs1 = (DFS_INFO_1*) talloc(ctx, num_jn * sizeof(DFS_INFO_1)); if (!dfs1) - return NT_STATUS_NO_MEMORY; + return WERR_NOMEM; init_reply_dfs_info_1(jn, dfs1, num_jn); ctr->dfs.info1 = dfs1; break; @@ -291,7 +296,7 @@ static uint32 init_reply_dfs_ctr(TALLOC_CTX *ctx, uint32 level, DFS_INFO_CTR* ct DFS_INFO_2* dfs2; dfs2 = (DFS_INFO_2*) talloc(ctx, num_jn * sizeof(DFS_INFO_2)); if (!dfs2) - return NT_STATUS_NO_MEMORY; + return WERR_NOMEM; init_reply_dfs_info_2(jn, dfs2, num_jn); ctr->dfs.info2 = dfs2; break; @@ -301,18 +306,18 @@ static uint32 init_reply_dfs_ctr(TALLOC_CTX *ctx, uint32 level, DFS_INFO_CTR* ct DFS_INFO_3* dfs3; dfs3 = (DFS_INFO_3*) talloc(ctx, num_jn * sizeof(DFS_INFO_3)); if (!dfs3) - return NT_STATUS_NO_MEMORY; + return WERR_NOMEM; init_reply_dfs_info_3(ctx, jn, dfs3, num_jn); ctr->dfs.info3 = dfs3; break; } default: - return NT_STATUS_INVALID_LEVEL; + return WERR_INVALID_PARAM; } - return NT_STATUS_OK; + return WERR_OK; } -uint32 _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u) +WERROR _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u) { uint32 level = q_u->level; struct junction_map jn[MAX_MSDFS_JUNCTIONS]; @@ -331,7 +336,7 @@ uint32 _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u) r_u->ctr = (DFS_INFO_CTR*)talloc(p->mem_ctx, sizeof(DFS_INFO_CTR)); if (!r_u->ctr) - return NT_STATUS_NO_MEMORY; + return WERR_NOMEM; ZERO_STRUCTP(r_u->ctr); r_u->ctr->switch_value = level; r_u->ctr->num_entries = num_jn; @@ -342,7 +347,8 @@ uint32 _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u) return r_u->status; } -uint32 _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u, DFS_R_DFS_GET_INFO *r_u) +WERROR _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u, + DFS_R_DFS_GET_INFO *r_u) { UNISTR2* uni_path = &q_u->uni_path; uint32 level = q_u->level; @@ -351,10 +357,10 @@ uint32 _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u, DFS_R_DFS_GET_INF unistr2_to_ascii(path, uni_path, sizeof(path)-1); if(!create_junction(path, &jn)) - return NERR_DfsNoSuchServer; + return WERR_DFS_NO_SUCH_SERVER; if(!get_referred_path(&jn)) - return NERR_DfsNoSuchVolume; + return WERR_DFS_NO_SUCH_VOL; r_u->level = level; r_u->ptr_ctr = 1; -- cgit From 39d7983a470cc3470dd7126de35697d965817cb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Sep 2001 03:08:51 +0000 Subject: - enable MSDFS by default, there seems no reason not to have it enabled by default in Samba 3.x - got rid of some unused parameters in Makefile.in - declare DEBUGLEVEL in debug.h rather than in each file (This used to be commit b8651acb9c0d7248a6a2e82c33b1e43633fd83fd) --- source3/rpc_server/srv_dfs.c | 7 ------- source3/rpc_server/srv_dfs_nt.c | 5 ----- source3/rpc_server/srv_pipe.c | 2 -- source3/rpc_server/srv_srvsvc_nt.c | 3 --- 4 files changed, 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index fe797e84f6..e2a78782f3 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -32,8 +32,6 @@ extern int DEBUGLEVEL; extern pstring global_myname; -#ifdef WITH_MSDFS - /********************************************************************** api_dfs_exist **********************************************************************/ @@ -179,8 +177,3 @@ BOOL api_netdfs_rpc(pipes_struct *p) return api_rpcTNP(p, "api_netdfs_rpc", api_netdfs_cmds); } -#else - - void dfs_dummy(void) {;} /* So some compilers don't complain. */ - -#endif diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index ce8d353274..58e678f0c4 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -30,8 +30,6 @@ extern int DEBUGLEVEL; extern pstring global_myname; -#ifdef WITH_MSDFS - #define MAX_MSDFS_JUNCTIONS 256 /* This function does not return a WERROR or NTSTATUS code but rather 1 if @@ -368,6 +366,3 @@ WERROR _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u, return r_u->status; } -#else - void dfs_dummy1(void) {;} /* So some compilers don't complain. */ -#endif diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 60250c903f..3570969efc 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -493,9 +493,7 @@ static struct api_cmd api_fd_commands[] = { "NETLOGON", "lsass", api_netlog_rpc }, { "winreg", "winreg", api_reg_rpc }, { "spoolss", "spoolss", api_spoolss_rpc }, -#ifdef WITH_MSDFS { "netdfs", "netdfs" , api_netdfs_rpc }, -#endif { NULL, NULL, NULL } }; diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index a0ae9050e2..0db06754f4 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -409,11 +409,8 @@ static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum) { sh1005->dfs_root_flag = 0; -#ifdef WITH_MSDFS if(lp_host_msdfs() && lp_msdfs_root(snum)) sh1005->dfs_root_flag = 3; -#endif - } /******************************************************************* -- cgit From b800a36b1c81fb37ca963acdc49978ff065fb0d7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 12 Sep 2001 06:39:50 +0000 Subject: Some patches to authentication: - the usersupplied_info now contains a smb_username (as it comes across on the wire) and a unix_username (after being passed through mapping functions) - when doing security={server,domain} use the smb_username, otherwise use the unix_username (This used to be commit d34fd8ec0716127c7a68eeb8e77d1ae8cc07b547) --- source3/rpc_server/srv_netlog_nt.c | 2 +- source3/rpc_server/srv_pipe.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index fd137e6038..26da5ac061 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -505,7 +505,7 @@ static NTSTATUS _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, c smb_username.str = user; smb_username.len = strlen(smb_username.str); - user_info.requested_username = smb_username; /* For the time-being */ + user_info.unix_username = smb_username; /* For the time-being */ user_info.smb_username = smb_username; #if 0 diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 3570969efc..4a09410e81 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -368,7 +368,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm become_root(); p->ntlmssp_auth_validated = - NT_STATUS_IS_OK(pass_check_smb_with_chal(pipe_user_name, domain, + NT_STATUS_IS_OK(pass_check_smb_with_chal(pipe_user_name, NULL, domain, (uchar*)p->challenge, lm_owf, lm_pw_len, nt_owf, nt_pw_len)); -- cgit From cbd99a13c510bd1cdfdd448ab1f1e94686180f50 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 14 Sep 2001 10:31:39 +0000 Subject: Finally commit my fix to this little mess... The same function that adds machines to the system also adds users, and the new 'add user script'/'add machine script' distinction needs to be made correctly. Also introduces a sainity check for correct $ termination. Andrew Bartlett (This used to be commit ef377ea0cc55cb6647ecd7a634cf5983e11cfe99) --- source3/rpc_server/srv_samr_nt.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index dce082d31d..c753764c79 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1899,12 +1899,14 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA /******************************************************************* _api_samr_create_user + Create an account, can be either a normal user or a machine. + This funcion will need to be updated for bdc/domain trusts. ********************************************************************/ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREATE_USER *r_u) { SAM_ACCOUNT *sam_pass=NULL; - fstring mach_acct; + fstring account; pstring err_str; pstring msg_str; int local_flags=0; @@ -1921,22 +1923,22 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ if (!find_policy_by_hnd(p, &dom_pol, NULL)) return NT_STATUS_INVALID_HANDLE; - /* find the machine account: tell the caller if it exists. + /* find the 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... */ - rpcstr_pull(mach_acct, user_account.buffer, sizeof(mach_acct), user_account.uni_str_len*2, 0); - strlower(mach_acct); + rpcstr_pull(account, user_account.buffer, sizeof(account), user_account.uni_str_len*2, 0); + strlower(account); pdb_init_sam(&sam_pass); become_root(); - ret = pdb_getsampwnam(sam_pass, mach_acct); + ret = pdb_getsampwnam(sam_pass, account); unbecome_root(); if (ret == True) { - /* machine account exists: say so */ + /* this account exists: say so */ pdb_free_sam(sam_pass); return NT_STATUS_USER_EXISTS; } @@ -1960,19 +1962,32 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ * * So we go the easy way, only check after if the account exists. * JFM (2/3/2001), to clear any possible bad understanding (-: + * + * We now have seperate script paramaters for adding users/machines so we + * now have some sainity-checking to match. */ - pstrcpy(add_script, lp_addmachine_script()); + DEBUG(10,("checking account %s at pos %d for $ termination\n",account, strlen(account)-1)); + + if ((acb_info & ACB_WSTRUST) && (account[strlen(account)-1] == '$')) { + pstrcpy(add_script, lp_addmachine_script()); + } else if ((!(acb_info & ACB_WSTRUST)) && (account[strlen(account)-1] != '$')) { + pstrcpy(add_script, lp_adduser_script()); + } else { + DEBUG(0, ("_api_samr_create_user: mismatch between trust flags and $ termination\n")); + pdb_free_sam(sam_pass); + return NT_STATUS_UNSUCCESSFUL; + } if(*add_script) { int add_ret; - all_string_sub(add_script, "%u", mach_acct, sizeof(mach_acct)); + all_string_sub(add_script, "%u", account, sizeof(account)); add_ret = smbrun(add_script,NULL); DEBUG(3,("_api_samr_create_user: Running the command `%s' gave %d\n",add_script,add_ret)); } /* add the user in the smbpasswd file or the Samba authority database */ - if (!local_password_change(mach_acct, local_flags, NULL, err_str, + if (!local_password_change(account, local_flags, NULL, err_str, sizeof(err_str), msg_str, sizeof(msg_str))) { DEBUG(0, ("%s\n", err_str)); pdb_free_sam(sam_pass); @@ -1980,7 +1995,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ } become_root(); - ret = pdb_getsampwnam(sam_pass, mach_acct); + ret = pdb_getsampwnam(sam_pass, account); unbecome_root(); if (ret == False) { /* account doesn't exist: say so */ -- cgit From bd7595ec37ab9c2d4290893a99e99856dca0c5cb Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 14 Sep 2001 15:22:49 +0000 Subject: merge from appliance_head (This used to be commit f70b1707e42b3f7aaa38cc5637fcc5cbcdd5a26a) --- source3/rpc_server/srv_spoolss_nt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cffdfb0ff9..5fed46deec 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6148,12 +6148,6 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; - status = get_a_printer(&printer, 2, lp_servicename(snum)); - if (!W_ERROR_IS_OK(status)) - return status; - - convert_specific_param(¶m, value , type, data, real_len); - ZERO_STRUCT(old_param); /* @@ -6177,6 +6171,12 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP 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 (!W_ERROR_IS_OK(status)) + return status; + + convert_specific_param(¶m, value , type, data, real_len); + if (get_specific_param(*printer, 2, param->value, &old_param.data, &old_param.type, (uint32 *)&old_param.data_len)) { -- cgit From 7892c494e7321c64b20bf7e1d794a6b6508fe84a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 15 Sep 2001 12:55:59 +0000 Subject: Kill off the //server/share%user hack in share level security. This should help make much of this code simpiler. Andrew Bartlett (This used to be commit fb0c3629c360fd0c57129500474960e6da6f9ef0) --- source3/rpc_server/srv_srvsvc_nt.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 0db06754f4..9f156a3d95 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1598,7 +1598,7 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE BOOL bad_path; int access_mode; int action; - NTSTATUS ecode; + NTSTATUS nt_status; struct current_user user; fstring user_name; connection_struct *conn = NULL; @@ -1612,14 +1612,11 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE /* Null password is ok - we are already an authenticated user... */ *null_pw = '\0'; - get_current_user(&user, p); - fstrcpy(user_name, uidtoname(user.uid)); - - conn = make_connection(qualname, user_name, null_pw, 0, "A:", user.vuid, &ecode); + conn = make_connection(qualname, null_pw, 0, "A:", user.vuid, &nt_status); if (conn == NULL) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", qualname)); - r_u->status = ecode; + r_u->status = nt_status; goto error_exit; } @@ -1690,7 +1687,7 @@ NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC * BOOL bad_path; int access_mode; int action; - NTSTATUS ecode; + NTSTATUS nt_status; struct current_user user; fstring user_name; connection_struct *conn = NULL; @@ -1705,14 +1702,11 @@ NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC * /* Null password is ok - we are already an authenticated user... */ *null_pw = '\0'; - get_current_user(&user, p); - fstrcpy(user_name, uidtoname(user.uid)); - - conn = make_connection(qualname, user_name, null_pw, 0, "A:", user.vuid, &ecode); + conn = make_connection(qualname, null_pw, 0, "A:", user.vuid, &nt_status); if (conn == NULL) { DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", qualname)); - r_u->status = ecode; + r_u->status = nt_status; goto error_exit; } -- cgit From 06ccf1e499b170e3e9d97ffdf27a8c896c8cf1cd Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 15 Sep 2001 23:32:19 +0000 Subject: Looks like it missed these. make_connection now no longer takes a 'username' argument. (This used to be commit 0e1322227b0a91226b4b85c8e0ff838ebfd9e962) --- source3/rpc_server/srv_srvsvc_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 9f156a3d95..70c6579f38 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1600,7 +1600,6 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE int action; NTSTATUS nt_status; struct current_user user; - fstring user_name; connection_struct *conn = NULL; ZERO_STRUCT(st); @@ -1689,7 +1688,6 @@ NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC * int action; NTSTATUS nt_status; struct current_user user; - fstring user_name; connection_struct *conn = NULL; BOOL became_user = False; -- cgit From dec3cbcaf097a3d6fab9359e001279447a5f4def Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 16 Sep 2001 06:35:35 +0000 Subject: Fix up workstaion and kickoff time checks, moved to auth_smbpasswd.c where they can have general effect. Fixed up workstaion support in the rest of samba, so that we can do these checks. Pass through the workstation for cli_net_logon(), if supplied. (This used to be commit 7f04a139b2ee34b4c282590509cdf21395815a7a) --- source3/rpc_server/srv_netlog_nt.c | 40 +++++--------------------------------- source3/rpc_server/srv_pipe.c | 23 +++++++++------------- 2 files changed, 14 insertions(+), 49 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 26da5ac061..ab5a0ff49e 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -6,6 +6,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. * Copyright (C) Jeremy Allison 1998-2001. + * Copyirht (C) Andrew Bartlett 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -473,7 +474,7 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF _net_logon_any: Use the new authentications subsystem to log in. *************************************************************************/ -static NTSTATUS _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, char *sess_key) +static NTSTATUS _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, char *workstation, char *sess_key) { NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE; @@ -508,12 +509,10 @@ static NTSTATUS _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, c user_info.unix_username = smb_username; /* For the time-being */ user_info.smb_username = smb_username; -#if 0 - user_info.wksta_name.str = cleint_name(); - user_info.wksta_name.len = strlen(client_name()); + user_info.wksta_name.str = workstation; + user_info.wksta_name.len = strlen(workstation); user_info.wksta_name = wksta_name; -#endif DEBUG(10,("_net_logon_any: Attempting validation level %d.\n", ctr->switch_value)); switch (ctr->switch_value) { @@ -667,7 +666,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * DEBUG(10,("Attempting validation level %d for mapped username %s.\n", q_u->sam_id.ctr->switch_value, nt_username)); - status = _net_logon_any(q_u->sam_id.ctr, nt_username, nt_domain, (char *)p->dc.sess_key); + status = _net_logon_any(q_u->sam_id.ctr, nt_username, nt_domain, nt_workstation, (char *)p->dc.sess_key); /* Check account and password */ @@ -686,35 +685,6 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return NT_STATUS_NO_SUCH_USER; } - /* Test account expire time */ - - if (time(NULL) > sampass->kickoff_time) - return NT_STATUS_ACCOUNT_EXPIRED; - - /* Test workstation. Workstation list is comma separated. */ - - if (sampass->workstations && *sampass->workstations) { - char *s = strdup(sampass->workstations); - BOOL invalid_ws = True; - fstring tok; - - while(next_token(&s, tok, ",", sizeof(tok))) { - if(strequal(tok, nt_workstation)) { - invalid_ws = False; - break; - } - } - - free(s); - - if (invalid_ws) - return NT_STATUS_INVALID_WORKSTATION; - } - - /* Test logon hours. */ - - /* Test must change password. */ - /* 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. */ diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 4a09410e81..8629592c4c 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -302,6 +302,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm rpcstr_pull(domain, ntlmssp_resp->domain, sizeof(fstring), ntlmssp_resp->hdr_domain.str_str_len*2, 0); rpcstr_pull(wks, ntlmssp_resp->wks, sizeof(fstring), ntlmssp_resp->hdr_wks.str_str_len*2, 0); } else { + /* What charset are these meant to be in? */ fstrcpy(user_name, ntlmssp_resp->user); fstrcpy(domain, ntlmssp_resp->domain); fstrcpy(wks, ntlmssp_resp->wks); @@ -328,24 +329,24 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm if((strlen(user_name) == 0) && (ntlmssp_resp->hdr_nt_resp.str_str_len==0)) - { + { guest_user = True; - - fstrcpy(pipe_user_name, lp_guestaccount(-1)); + + fstrcpy(pipe_user_name, lp_guestaccount(-1)); DEBUG(100,("Null user in NTLMSSP verification. Using guest = %s\n", pipe_user_name)); smb_passwd_ptr = null_smb_passwd; - + } else { /* * Pass the user through the NT -> unix user mapping * function. */ - + fstrcpy(pipe_user_name, user_name); (void)map_username(pipe_user_name); - + /* * Do the length checking only if user is not NULL. */ @@ -368,7 +369,8 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm become_root(); p->ntlmssp_auth_validated = - NT_STATUS_IS_OK(pass_check_smb_with_chal(pipe_user_name, NULL, domain, + NT_STATUS_IS_OK(pass_check_smb_with_chal(pipe_user_name, NULL, + domain, wks, (uchar*)p->challenge, lm_owf, lm_pw_len, nt_owf, nt_pw_len)); @@ -391,13 +393,6 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name unbecome_root(); - /* 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)); - 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)); pdb_free_sam(sampass); -- cgit From 6ff605c2833940e26d35825db473171b28da986f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 16 Sep 2001 07:32:06 +0000 Subject: Minor tidy-up. (This used to be commit dbb21aedbf10ebc4ef0d549c4f919cf91459eef7) --- source3/rpc_server/srv_netlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index ab5a0ff49e..173c4218cb 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -670,7 +670,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * /* Check account and password */ - if (NT_STATUS_V(status)) + if (NT_STATUS_IS_ERR(status)) return status; pdb_init_sam(&sampass); -- cgit From 87945989c0383bd012be7ab8bc5920b6d03fa105 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 17 Sep 2001 10:26:23 +0000 Subject: move to SAFE_FREE() (This used to be commit 5ceecc7bef71b455ba7c4efd9928e2433dccc961) --- source3/rpc_server/srv_dfs_nt.c | 2 +- source3/rpc_server/srv_lsa_hnd.c | 5 +- source3/rpc_server/srv_lsa_nt.c | 6 +- source3/rpc_server/srv_pipe.c | 4 +- source3/rpc_server/srv_pipe_hnd.c | 8 +- source3/rpc_server/srv_reg_nt.c | 2 +- source3/rpc_server/srv_samr_nt.c | 12 +- source3/rpc_server/srv_spoolss.c | 4 +- source3/rpc_server/srv_spoolss_nt.c | 222 +++++++++++++++++------------------- 9 files changed, 126 insertions(+), 139 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 58e678f0c4..dba8ddd0d8 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -96,7 +96,7 @@ WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) { memcpy(jn.referral_list, old_referral_list, sizeof(struct referral)*jn.referral_count-1); - free(old_referral_list); + SAFE_FREE(old_referral_list); } jn.referral_list[jn.referral_count-1].proximity = 0; diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 393f50a498..ad726f4cfa 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -194,7 +194,7 @@ BOOL close_policy_hnd(pipes_struct *p, POLICY_HND *hnd) ZERO_STRUCTP(pol); - free(pol); + SAFE_FREE(pol); return True; } @@ -217,8 +217,7 @@ void close_policy_by_pipe(pipes_struct *p) p->pipe_handles->Policy = NULL; p->pipe_handles->count = 0; - free(p->pipe_handles); - p->pipe_handles = NULL; + SAFE_FREE(p->pipe_handles); DEBUG(10,("close_policy_by_pipe: deleted handle list for pipe %s\n", p->name )); } } diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index b84293b2f4..98038c2ac7 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -45,7 +45,7 @@ static void free_lsa_info(void *ptr) { struct lsa_info *lsa = (struct lsa_info *)ptr; - safe_free(lsa); + SAFE_FREE(lsa); } /*************************************************************************** @@ -620,7 +620,7 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU sids->sid = (DOM_SID2 *)talloc_zero(p->mem_ctx, (num_entries-q_u->enum_context)*sizeof(DOM_SID2)); if (sids->ptr_sid==NULL || sids->sid==NULL) { - safe_free(map); + SAFE_FREE(map); return NT_STATUS_NO_MEMORY; } @@ -630,7 +630,7 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU j++; } - safe_free(map); + SAFE_FREE(map); init_lsa_r_enum_accounts(r_u, j); diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 8629592c4c..a352cd5eb6 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -285,7 +285,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm /* Set up for non-authenticated user. */ delete_nt_token(&p->pipe_user.nt_user_token); p->pipe_user.ngroups = 0; - safe_free( p->pipe_user.groups); + SAFE_FREE( p->pipe_user.groups); /* * Setup an empty password for a guest user. @@ -1232,7 +1232,7 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, if (data) { prs_uint8s(False, "", &p->in_data.data, 0, (unsigned char *)data, data_len); - free(data); + SAFE_FREE(data); } } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 0111733bb0..082d3a1263 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -159,14 +159,14 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, if ((p->mem_ctx = talloc_init()) == NULL) { DEBUG(0,("open_rpc_pipe_p: talloc_init failed.\n")); - free(p); + SAFE_FREE(p); return NULL; } if (!init_pipe_handle_list(p, pipe_name)) { DEBUG(0,("open_rpc_pipe_p: init_pipe_handles failed.\n")); talloc_destroy(p->mem_ctx); - free(p); + SAFE_FREE(p); return NULL; } @@ -923,11 +923,11 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) DLIST_REMOVE(Pipes, p); delete_nt_token(&p->pipe_user.nt_user_token); - safe_free(p->pipe_user.groups); + SAFE_FREE(p->pipe_user.groups); ZERO_STRUCTP(p); - free(p); + SAFE_FREE(p); return True; } diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 71abdd517f..b1c0e8bc65 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -39,7 +39,7 @@ static void free_reg_info(void *ptr) { struct reg_info *info = (struct reg_info *)ptr; - safe_free(info); + SAFE_FREE(info); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c753764c79..7409acec27 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -52,9 +52,7 @@ struct samr_info { static void free_samr_info(void *ptr) { - struct samr_info *samr = (struct samr_info *)ptr; - - safe_free(samr); + SAFE_FREE(ptr); } /******************************************************************* @@ -820,7 +818,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM } - safe_free(map); + SAFE_FREE(map); } else if (sid_equal(sid, &global_sam_sid) && !lp_hide_local_users()) { char *sep; @@ -931,7 +929,7 @@ static NTSTATUS get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DO *d_grp=(DOMAIN_GRP *)talloc_zero(ctx, num_entries*sizeof(DOMAIN_GRP)); if (num_entries!=0 && *d_grp==NULL){ - safe_free(map); + SAFE_FREE(map); return NT_STATUS_NO_MEMORY; } @@ -942,7 +940,7 @@ static NTSTATUS get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DO (*d_grp)[i].attr=SID_NAME_DOM_GRP; } - safe_free(map); + SAFE_FREE(map); *p_num_entries = num_entries; @@ -3184,7 +3182,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM if(!get_uid_list_of_group(map.gid, &uid, &num_uids)) return NT_STATUS_NO_SUCH_GROUP; init_samr_group_info1(&ctr->group.info1, map.nt_name, map.comment, num_uids); - safe_free(uid); + SAFE_FREE(uid); break; case 4: ctr->switch_value1 = 4; diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index eed24bfe8c..6c65cb078b 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -305,12 +305,12 @@ static BOOL api_spoolss_rfnpcnex(pipes_struct *p) r_u.status = _spoolss_rfnpcnex(p, &q_u, &r_u); if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) { - safe_free(r_u.info.data); + SAFE_FREE(r_u.info.data); DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n")); return False; } - safe_free(r_u.info.data); + SAFE_FREE(r_u.info.data); return True; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5fed46deec..118a2d64c9 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -141,17 +141,11 @@ static int nt_printq_status(int v) static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp) { - SPOOL_NOTIFY_OPTION *sp = *pp; - - *pp = NULL; - - if (!sp) + if (*pp == NULL) return; - if (sp->ctr.type) - safe_free(sp->ctr.type); - - free(sp); + SAFE_FREE((*pp)->ctr.type); + SAFE_FREE(*pp); } /*************************************************************************** @@ -201,7 +195,7 @@ static void free_printer_entry(void *ptr) Printer->notify.option=NULL; Printer->notify.client_connected=False; - safe_free(Printer); + SAFE_FREE(Printer); } /**************************************************************************** @@ -225,7 +219,7 @@ SPOOL_NOTIFY_OPTION *dup_spool_notify_option(SPOOL_NOTIFY_OPTION *sp) new_sp->ctr.type = (SPOOL_NOTIFY_OPTION_TYPE *)memdup(sp->ctr.type, sizeof(SPOOL_NOTIFY_OPTION_TYPE) * sp->ctr.count); if (!new_sp->ctr.type) { - safe_free(new_sp); + SAFE_FREE(new_sp); return NULL; } } @@ -541,7 +535,7 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name) new_printer->notify.option=NULL; if (!create_policy_hnd(p, hnd, free_printer_entry, new_printer)) { - safe_free(new_printer); + SAFE_FREE(new_printer); return False; } @@ -1005,7 +999,7 @@ BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, */ if ((devmode->driverextra != 0) && (devmode->private != NULL)) { - safe_free(nt_devmode->private); + SAFE_FREE(nt_devmode->private); nt_devmode->driverextra=devmode->driverextra; if((nt_devmode->private=(uint8 *)malloc(nt_devmode->driverextra * sizeof(uint8))) == NULL) return False; @@ -1284,7 +1278,7 @@ static BOOL getprinterdata_printer(pipes_struct *p, TALLOC_CTX *ctx, POLICY_HND DEBUG(5,("getprinterdata_printer:copy done\n")); - safe_free(idata); + SAFE_FREE(idata); return True; } @@ -1840,7 +1834,7 @@ static void spoolss_notify_status(int snum, memset(&status, 0, sizeof(status)); print_queue_status(snum, &q, &status); data->notify_data.value[0]=(uint32) status.status; - safe_free(q); + SAFE_FREE(q); } /******************************************************************* @@ -1857,7 +1851,7 @@ static void spoolss_notify_cjobs(int snum, memset(&status, 0, sizeof(status)); data->notify_data.value[0] = print_queue_status(snum, &q, &status); - safe_free(q); + SAFE_FREE(q); } /******************************************************************* @@ -2445,7 +2439,7 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY free_a_printer(&printer, 2); done: - safe_free(queue); + SAFE_FREE(queue); break; } } @@ -2624,7 +2618,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) printer->unknown28 = 0; printer->unknown29 = 0; - safe_free(queue); + SAFE_FREE(queue); free_a_printer(&ntprinter,2); return (True); } @@ -2674,10 +2668,8 @@ static void free_dev_mode(DEVICEMODE *dev) if (dev == NULL) return; - if (dev->private) - safe_free(dev->private); - - safe_free(dev); + SAFE_FREE(dev->private); + SAFE_FREE(dev); } /**************************************************************************** @@ -2828,7 +2820,7 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum) } free_a_printer(&ntprinter, 2); - safe_free(queue); + SAFE_FREE(queue); return True; } @@ -2906,7 +2898,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 if (construct_printer_info_1(flags, ¤t_prt, snum)) { 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); + SAFE_FREE(printers); *returned=0; return WERR_NOMEM; } @@ -2930,7 +2922,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 smb_io_printer_info_1("", buffer, &printers[i], 0); /* clear memory */ - safe_free(printers); + SAFE_FREE(printers); if (*needed > offered) { *returned=0; @@ -3004,7 +2996,7 @@ static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, *needed += spoolss_size_printer_info_1(printer); if (!alloc_buffer_size(buffer, *needed)) { - safe_free(printer); + SAFE_FREE(printer); return WERR_INSUFFICIENT_BUFFER; } @@ -3012,7 +3004,7 @@ static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, smb_io_printer_info_1("", buffer, printer, 0); /* clear memory */ - safe_free(printer); + SAFE_FREE(printer); if (*needed > offered) { *returned=0; @@ -3054,7 +3046,7 @@ static WERROR enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint3 if (construct_printer_info_2(¤t_prt, snum)) { 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); + SAFE_FREE(printers); *returned = 0; return WERR_NOMEM; } @@ -3074,7 +3066,7 @@ static WERROR enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint3 for (i=0; i<*returned; i++) { free_devmode(printers[i].devmode); } - safe_free(printers); + SAFE_FREE(printers); return WERR_INSUFFICIENT_BUFFER; } @@ -3086,7 +3078,7 @@ static WERROR enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint3 for (i=0; i<*returned; i++) { free_devmode(printers[i].devmode); } - safe_free(printers); + SAFE_FREE(printers); if (*needed > offered) { *returned=0; @@ -3234,7 +3226,7 @@ static WERROR getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, u *needed += spoolss_size_printer_info_0(printer); if (!alloc_buffer_size(buffer, *needed)) { - safe_free(printer); + SAFE_FREE(printer); return WERR_INSUFFICIENT_BUFFER; } @@ -3242,7 +3234,7 @@ static WERROR getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, u smb_io_printer_info_0("", buffer, printer, 0); /* clear memory */ - safe_free(printer); + SAFE_FREE(printer); if (*needed > offered) { return WERR_INSUFFICIENT_BUFFER; @@ -3266,7 +3258,7 @@ static WERROR getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, u *needed += spoolss_size_printer_info_1(printer); if (!alloc_buffer_size(buffer, *needed)) { - safe_free(printer); + SAFE_FREE(printer); return WERR_INSUFFICIENT_BUFFER; } @@ -3274,7 +3266,7 @@ static WERROR getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, u smb_io_printer_info_1("", buffer, printer, 0); /* clear memory */ - safe_free(printer); + SAFE_FREE(printer); if (*needed > offered) { return WERR_INSUFFICIENT_BUFFER; @@ -3704,7 +3696,7 @@ static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fst static void free_printer_driver_info_3(DRIVER_INFO_3 *info) { - safe_free(info->dependentfiles); + SAFE_FREE(info->dependentfiles); } /**************************************************************************** @@ -3712,7 +3704,7 @@ static void free_printer_driver_info_3(DRIVER_INFO_3 *info) static void free_printer_driver_info_6(DRIVER_INFO_6 *info) { - safe_free(info->dependentfiles); + SAFE_FREE(info->dependentfiles); } @@ -3728,7 +3720,7 @@ static WERROR getprinterdriver2_level1(fstring servername, fstring architecture, status=construct_printer_driver_info_1(info, snum, servername, architecture, version); if (!W_ERROR_IS_OK(status)) { - safe_free(info); + SAFE_FREE(info); return status; } @@ -3736,7 +3728,7 @@ static WERROR getprinterdriver2_level1(fstring servername, fstring architecture, *needed += spoolss_size_printer_driver_info_1(info); if (!alloc_buffer_size(buffer, *needed)) { - safe_free(info); + SAFE_FREE(info); return WERR_INSUFFICIENT_BUFFER; } @@ -3744,7 +3736,7 @@ static WERROR getprinterdriver2_level1(fstring servername, fstring architecture, smb_io_printer_driver_info_1("", buffer, info, 0); /* clear memory */ - safe_free(info); + SAFE_FREE(info); if (*needed > offered) return WERR_INSUFFICIENT_BUFFER; @@ -3764,7 +3756,7 @@ static WERROR getprinterdriver2_level2(fstring servername, fstring architecture, status=construct_printer_driver_info_2(info, snum, servername, architecture, version); if (!W_ERROR_IS_OK(status)) { - safe_free(info); + SAFE_FREE(info); return status; } @@ -3772,7 +3764,7 @@ static WERROR getprinterdriver2_level2(fstring servername, fstring architecture, *needed += spoolss_size_printer_driver_info_2(info); if (!alloc_buffer_size(buffer, *needed)) { - safe_free(info); + SAFE_FREE(info); return WERR_INSUFFICIENT_BUFFER; } @@ -3780,7 +3772,7 @@ static WERROR getprinterdriver2_level2(fstring servername, fstring architecture, smb_io_printer_driver_info_2("", buffer, info, 0); /* clear memory */ - safe_free(info); + SAFE_FREE(info); if (*needed > offered) return WERR_INSUFFICIENT_BUFFER; @@ -4792,7 +4784,7 @@ static WERROR enumjobs_level1(print_queue_struct *queue, int snum, info=(JOB_INFO_1 *)malloc(*returned*sizeof(JOB_INFO_1)); if (info==NULL) { - safe_free(queue); + SAFE_FREE(queue); *returned=0; return WERR_NOMEM; } @@ -4800,14 +4792,14 @@ static WERROR enumjobs_level1(print_queue_struct *queue, int snum, for (i=0; i<*returned; i++) fill_job_info_1(&info[i], &queue[i], i, snum); - safe_free(queue); + SAFE_FREE(queue); /* check the required size. */ for (i=0; i<*returned; i++) (*needed) += spoolss_size_job_info_1(&info[i]); if (!alloc_buffer_size(buffer, *needed)) { - safe_free(info); + SAFE_FREE(info); return WERR_INSUFFICIENT_BUFFER; } @@ -4816,7 +4808,7 @@ static WERROR enumjobs_level1(print_queue_struct *queue, int snum, smb_io_job_info_1("", buffer, &info[i], 0); /* clear memory */ - safe_free(info); + SAFE_FREE(info); if (*needed > offered) { *returned=0; @@ -4854,14 +4846,14 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter); free_a_printer(&ntprinter, 2); - safe_free(queue); + SAFE_FREE(queue); /* check the required size. */ for (i=0; i<*returned; i++) (*needed) += spoolss_size_job_info_2(&info[i]); if (!alloc_buffer_size(buffer, *needed)) { - safe_free(info); + SAFE_FREE(info); return WERR_INSUFFICIENT_BUFFER; } @@ -4873,7 +4865,7 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, for (i = 0; i < *returned; i++) free_job_info_2(&info[i]); - free(info); + SAFE_FREE(info); if (*needed > offered) { *returned=0; @@ -4920,7 +4912,7 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); if (*returned == 0) { - safe_free(queue); + SAFE_FREE(queue); return WERR_OK; } @@ -4930,7 +4922,7 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO case 2: return enumjobs_level2(queue, snum, buffer, offered, needed, returned); default: - safe_free(queue); + SAFE_FREE(queue); *returned=0; return WERR_UNKNOWN_LEVEL; } @@ -5024,8 +5016,8 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture if(ndrivers != 0) { 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); + SAFE_FREE(driver_info_1); + SAFE_FREE(list); return WERR_NOMEM; } else driver_info_1 = tdi1; @@ -5038,7 +5030,7 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture status = get_a_printer_driver(&driver, 3, list[i], architecture, version); if (!W_ERROR_IS_OK(status)) { - safe_free(list); + SAFE_FREE(list); return status; } fill_printer_driver_info_1(&driver_info_1[*returned+i], driver, servername, architecture ); @@ -5046,7 +5038,7 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture } *returned+=ndrivers; - safe_free(list); + SAFE_FREE(list); } /* check the required size. */ @@ -5056,7 +5048,7 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture } if (!alloc_buffer_size(buffer, *needed)) { - safe_free(driver_info_1); + SAFE_FREE(driver_info_1); return WERR_INSUFFICIENT_BUFFER; } @@ -5066,7 +5058,7 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture smb_io_printer_driver_info_1("", buffer, &driver_info_1[i], 0); } - safe_free(driver_info_1); + SAFE_FREE(driver_info_1); if (*needed > offered) { *returned=0; @@ -5103,8 +5095,8 @@ static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture if(ndrivers != 0) { 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); + SAFE_FREE(driver_info_2); + SAFE_FREE(list); return WERR_NOMEM; } else driver_info_2 = tdi2; @@ -5118,7 +5110,7 @@ static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture status = get_a_printer_driver(&driver, 3, list[i], architecture, version); if (!W_ERROR_IS_OK(status)) { - safe_free(list); + SAFE_FREE(list); return status; } fill_printer_driver_info_2(&driver_info_2[*returned+i], driver, servername); @@ -5126,7 +5118,7 @@ static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture } *returned+=ndrivers; - safe_free(list); + SAFE_FREE(list); } /* check the required size. */ @@ -5136,7 +5128,7 @@ static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture } if (!alloc_buffer_size(buffer, *needed)) { - safe_free(driver_info_2); + SAFE_FREE(driver_info_2); return WERR_INSUFFICIENT_BUFFER; } @@ -5146,7 +5138,7 @@ static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture smb_io_printer_driver_info_2("", buffer, &(driver_info_2[i]), 0); } - safe_free(driver_info_2); + SAFE_FREE(driver_info_2); if (*needed > offered) { *returned=0; @@ -5183,8 +5175,8 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture if(ndrivers != 0) { 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); + SAFE_FREE(driver_info_3); + SAFE_FREE(list); return WERR_NOMEM; } else driver_info_3 = tdi3; @@ -5198,7 +5190,7 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture status = get_a_printer_driver(&driver, 3, list[i], architecture, version); if (!W_ERROR_IS_OK(status)) { - safe_free(list); + SAFE_FREE(list); return status; } fill_printer_driver_info_3(&driver_info_3[*returned+i], driver, servername); @@ -5206,7 +5198,7 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture } *returned+=ndrivers; - safe_free(list); + SAFE_FREE(list); } /* check the required size. */ @@ -5216,7 +5208,7 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture } if (!alloc_buffer_size(buffer, *needed)) { - safe_free(driver_info_3); + SAFE_FREE(driver_info_3); return WERR_INSUFFICIENT_BUFFER; } @@ -5227,9 +5219,9 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture } for (i=0; i<*returned; i++) - safe_free(driver_info_3[i].dependentfiles); + SAFE_FREE(driver_info_3[i].dependentfiles); - safe_free(driver_info_3); + SAFE_FREE(driver_info_3); if (*needed > offered) { *returned=0; @@ -5277,7 +5269,7 @@ WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS return enumprinterdrivers_level3(servername, architecture, buffer, offered, needed, returned); default: *returned=0; - safe_free(list); + SAFE_FREE(list); return WERR_UNKNOWN_LEVEL; } } @@ -5345,14 +5337,14 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF fill_form_1(&forms_1[i], &builtinlist[i]); } - safe_free(builtinlist); + SAFE_FREE(builtinlist); for (; i<*numofforms; i++) { DEBUGADD(6,("Filling form number [%d]\n",i)); fill_form_1(&forms_1[i], &list[i-numbuiltinforms]); } - safe_free(list); + SAFE_FREE(list); /* check the required size. */ for (i=0; i offered) { *numofforms=0; @@ -5391,8 +5383,8 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF return WERR_OK; default: - safe_free(list); - safe_free(builtinlist); + SAFE_FREE(list); + SAFE_FREE(builtinlist); return WERR_UNKNOWN_LEVEL; } @@ -5455,7 +5447,7 @@ WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * } } - safe_free(list); + SAFE_FREE(list); if (i == numofforms) { return WERR_BADFID; } @@ -5479,7 +5471,7 @@ WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * return WERR_OK; default: - safe_free(list); + SAFE_FREE(list); return WERR_UNKNOWN_LEVEL; } } @@ -5572,7 +5564,7 @@ static WERROR enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need } if (!alloc_buffer_size(buffer, *needed)) { - safe_free(ports); + SAFE_FREE(ports); return WERR_INSUFFICIENT_BUFFER; } @@ -5582,7 +5574,7 @@ static WERROR enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need smb_io_port_1("", buffer, &ports[i], 0); } - safe_free(ports); + SAFE_FREE(ports); if (*needed > offered) { *returned=0; @@ -5670,7 +5662,7 @@ static WERROR enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need } if (!alloc_buffer_size(buffer, *needed)) { - safe_free(ports); + SAFE_FREE(ports); return WERR_INSUFFICIENT_BUFFER; } @@ -5680,7 +5672,7 @@ static WERROR enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need smb_io_port_2("", buffer, &ports[i], 0); } - safe_free(ports); + SAFE_FREE(ports); if (*needed > offered) { *returned=0; @@ -5908,13 +5900,13 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen *needed += spoolss_size_driverdir_info_1(info); if (!alloc_buffer_size(buffer, *needed)) { - safe_free(info); + SAFE_FREE(info); return WERR_INSUFFICIENT_BUFFER; } smb_io_driverdir_1("", buffer, info, 0); - safe_free(info); + SAFE_FREE(info); if (*needed > offered) return WERR_INSUFFICIENT_BUFFER; @@ -6026,14 +6018,13 @@ WERROR _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); + SAFE_FREE(data); free_a_printer(&printer, 2); return WERR_NO_MORE_ITEMS; } #endif - safe_free(data); - data = NULL; + SAFE_FREE(data); param_index=0; biggest_valuesize=0; @@ -6045,8 +6036,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S DEBUG(6,("current values: [%d], [%d]\n", biggest_valuesize, biggest_datasize)); - safe_free(data); - data = NULL; + SAFE_FREE(data); param_index++; } @@ -6078,7 +6068,7 @@ WERROR _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); + SAFE_FREE(data); free_a_printer(&printer, 2); return WERR_NO_MORE_ITEMS; } @@ -6096,7 +6086,7 @@ WERROR _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); + SAFE_FREE(data); return WERR_NOMEM; } @@ -6107,14 +6097,14 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S /* the data is counted in bytes */ *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); + SAFE_FREE(data); return WERR_NOMEM; } memcpy(*data_out, data, (size_t)data_len); *out_data_len=data_len; - safe_free(data); + SAFE_FREE(data); return WERR_OK; } @@ -6213,7 +6203,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP free_a_printer(&printer, 2); if (param) free_nt_printer_param(¶m); - safe_free(old_param.data); + SAFE_FREE(old_param.data); return status; } @@ -6295,7 +6285,7 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM return WERR_NOMEM; write_ntforms(&list, count); - safe_free(list); + SAFE_FREE(list); return WERR_OK; } @@ -6329,7 +6319,7 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE if (!delete_a_form(&list, form_name, &count, &ret)) return WERR_INVALID_PARAM; - safe_free(list); + SAFE_FREE(list); return ret; } @@ -6364,7 +6354,7 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * update_a_form(&list, form, count); write_ntforms(&list, count); - safe_free(list); + SAFE_FREE(list); return WERR_OK; } @@ -6390,7 +6380,7 @@ static WERROR enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui smb_io_printprocessor_info_1("", buffer, info_1, 0); - safe_free(info_1); + SAFE_FREE(info_1); if (*needed > offered) { *returned=0; @@ -6458,7 +6448,7 @@ static WERROR enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, smb_io_printprocdatatype_info_1("", buffer, info_1, 0); - safe_free(info_1); + SAFE_FREE(info_1); if (*needed > offered) { *returned=0; @@ -6520,7 +6510,7 @@ static WERROR enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint smb_io_printmonitor_info_1("", buffer, info_1, 0); - safe_free(info_1); + SAFE_FREE(info_1); if (*needed > offered) { *returned=0; @@ -6553,7 +6543,7 @@ static WERROR enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint smb_io_printmonitor_info_2("", buffer, info_2, 0); - safe_free(info_2); + SAFE_FREE(info_2); if (*needed > offered) { *returned=0; @@ -6612,7 +6602,7 @@ static WERROR getjob_level_1(print_queue_struct *queue, int count, int snum, uin info_1=(JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1)); if (info_1 == NULL) { - safe_free(queue); + SAFE_FREE(queue); return WERR_NOMEM; } @@ -6622,26 +6612,26 @@ static WERROR getjob_level_1(print_queue_struct *queue, int count, int snum, uin } if (found==False) { - safe_free(queue); - safe_free(info_1); + SAFE_FREE(queue); + SAFE_FREE(info_1); /* I shoud reply something else ... I can't find the good one */ return WERR_OK; } fill_job_info_1(info_1, &(queue[i-1]), i, snum); - safe_free(queue); + SAFE_FREE(queue); *needed += spoolss_size_job_info_1(info_1); if (!alloc_buffer_size(buffer, *needed)) { - safe_free(info_1); + SAFE_FREE(info_1); return WERR_INSUFFICIENT_BUFFER; } smb_io_job_info_1("", buffer, info_1, 0); - safe_free(info_1); + SAFE_FREE(info_1); if (*needed > offered) return WERR_INSUFFICIENT_BUFFER; @@ -6665,7 +6655,7 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin ZERO_STRUCTP(info_2); if (info_2 == NULL) { - safe_free(queue); + SAFE_FREE(queue); return WERR_NOMEM; } @@ -6675,34 +6665,34 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin } if (found==False) { - safe_free(queue); - safe_free(info_2); + SAFE_FREE(queue); + SAFE_FREE(info_2); /* I shoud reply something else ... I can't find the good one */ return WERR_OK; } ret = get_a_printer(&ntprinter, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(ret)) { - safe_free(queue); + SAFE_FREE(queue); return ret; } fill_job_info_2(info_2, &(queue[i-1]), i, snum, ntprinter); free_a_printer(&ntprinter, 2); - safe_free(queue); + SAFE_FREE(queue); *needed += spoolss_size_job_info_2(info_2); if (!alloc_buffer_size(buffer, *needed)) { - safe_free(info_2); + SAFE_FREE(info_2); return WERR_INSUFFICIENT_BUFFER; } smb_io_job_info_2("", buffer, info_2, 0); free_job_info_2(info_2); - free(info_2); + SAFE_FREE(info_2); if (*needed > offered) return WERR_INSUFFICIENT_BUFFER; @@ -6751,7 +6741,7 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ case 2: return getjob_level_2(queue, count, snum, jobid, buffer, offered, needed); default: - safe_free(queue); + SAFE_FREE(queue); return WERR_UNKNOWN_LEVEL; } } -- cgit From 36939fcd248529efff9fbccdc45942c9b4454b93 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 19 Sep 2001 02:28:15 +0000 Subject: Reverse some of the breakage I commited a day or two ago, as we need to fill out the user_info struct (otherwise we don't have a vuid for make_connection()). Also add a become_user() call, becouse it really looks like it was missing (we must pass it anyway to finish make_connection()). Is there any reason not to be the user when reading an ACL? Finally, fix up some formatting to show that the two functions are almost identical. Andrew Bartlett (This used to be commit 00c667c0ad922a1bf388b8a2b8c6137fc7f0acaa) --- source3/rpc_server/srv_srvsvc_nt.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 70c6579f38..8de20d4abf 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1601,6 +1601,7 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE NTSTATUS nt_status; struct current_user user; connection_struct *conn = NULL; + BOOL became_user = False; ZERO_STRUCT(st); @@ -1611,6 +1612,8 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE /* Null password is ok - we are already an authenticated user... */ *null_pw = '\0'; + get_current_user(&user, p); + conn = make_connection(qualname, null_pw, 0, "A:", user.vuid, &nt_status); if (conn == NULL) { @@ -1619,16 +1622,24 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE 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 = NT_STATUS_ACCESS_DENIED; + 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); + fsp = open_file_shared(conn, filename, &st, SET_OPEN_MODE(DOS_OPEN_RDONLY), - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, 0, &access_mode, &action); + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, 0, &access_mode, &action); if (!fsp) { /* Perhaps it is a directory */ if (errno == EISDIR) fsp = open_directory(conn, filename, &st, - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); if (!fsp) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); @@ -1664,6 +1675,9 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE close_file(fsp, True); } + if (became_user) + unbecome_user(); + if (conn) close_cnum(conn, user.vuid); @@ -1678,9 +1692,9 @@ NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC * SRV_R_NET_FILE_SET_SECDESC *r_u) { BOOL ret; + fstring null_pw; pstring filename; pstring qualname; - fstring null_pw; files_struct *fsp = NULL; SMB_STRUCT_STAT st; BOOL bad_path; @@ -1700,6 +1714,8 @@ NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC * /* Null password is ok - we are already an authenticated user... */ *null_pw = '\0'; + get_current_user(&user, p); + conn = make_connection(qualname, null_pw, 0, "A:", user.vuid, &nt_status); if (conn == NULL) { @@ -1719,13 +1735,13 @@ NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC * unix_convert(filename, conn, NULL, &bad_path, &st); fsp = open_file_shared(conn, filename, &st, SET_OPEN_MODE(DOS_OPEN_RDWR), - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, 0, &access_mode, &action); + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, 0, &access_mode, &action); if (!fsp) { /* Perhaps it is a directory */ if (errno == EISDIR) fsp = open_directory(conn, filename, &st, - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); if (!fsp) { DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename)); -- cgit From 01529e340c607f5ef6acf164283d7f3ee5b05569 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 19 Sep 2001 02:53:14 +0000 Subject: fix debug (This used to be commit d103371e8028efb6eec3c4b917b68734832f5844) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 8de20d4abf..7bc94c5575 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1623,7 +1623,7 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE } if (!become_user(conn, conn->vuid)) { - DEBUG(0,("_srv_net_file_set_secdesc: Can't become connected user!\n")); + DEBUG(0,("_srv_net_file_query_secdesc: Can't become connected user!\n")); r_u->status = NT_STATUS_ACCESS_DENIED; goto error_exit; } -- cgit From 80ad52d5c2c389ae8983f57b34a03d8d2d2ddd88 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 21 Sep 2001 13:22:22 +0000 Subject: fixed character set for user name pull (This used to be commit 374f76fa2d5dcd036943c3f968a94f097a971ac7) --- source3/rpc_server/srv_pipe.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index a352cd5eb6..b3f590a177 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -302,10 +302,9 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm rpcstr_pull(domain, ntlmssp_resp->domain, sizeof(fstring), ntlmssp_resp->hdr_domain.str_str_len*2, 0); rpcstr_pull(wks, ntlmssp_resp->wks, sizeof(fstring), ntlmssp_resp->hdr_wks.str_str_len*2, 0); } else { - /* What charset are these meant to be in? */ - fstrcpy(user_name, ntlmssp_resp->user); - fstrcpy(domain, ntlmssp_resp->domain); - fstrcpy(wks, ntlmssp_resp->wks); + pull_ascii_fstring(user_name, ntlmssp_resp->user); + pull_ascii_fstring(domain, ntlmssp_resp->domain); + pull_ascii_fstring(wks, ntlmssp_resp->wks); } DEBUG(5,("user: %s domain: %s wks: %s\n", user_name, domain, wks)); -- cgit From 008ba27b2884a5553f4c28a2c9c7ae584b61c3a4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 25 Sep 2001 00:50:37 +0000 Subject: Fixed enumeration of large numbers of groups from a Samba DC. Tidied up debug messages in lib/messages.c Jeremy. (This used to be commit dfb58f227609d6c8a255677b85ec853efa19f602) --- source3/rpc_server/srv_samr_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7409acec27..4ffd1c85b5 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -900,6 +900,8 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM DEBUG(10,("get_group_alias_entries: returning %d entries\n", *p_num_entries)); + if (num_entries >= max_entries) + return STATUS_MORE_ENTRIES; return NT_STATUS_OK; } @@ -1007,7 +1009,7 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S /*safe_free(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__)); -- cgit From 0f4281b9b4a4056e9e087deb15e60ea482af7a74 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 26 Sep 2001 00:05:03 +0000 Subject: Added Elrond patch to make se_access_check use NT datastructures, not Samba. Jeremy. (This used to be commit bca6419447e926e51aeecf3e484228f640cecb84) --- source3/rpc_server/srv_srvsvc_nt.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 7bc94c5575..2877b7af05 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -308,8 +308,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; @@ -322,26 +321,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: -- cgit From 6744ca0a369ef85858b6e1a129649cd175187e51 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 26 Sep 2001 11:13:55 +0000 Subject: More updates to prevent account-guessing. This moves the check that ensures that the account being looked up is the same account as the machine logged in as to the front, before we even start with passdb. Merge for 2.2.2? Andrew Bartlett (This used to be commit f7ed0ecc14aeba5ad260f24a76ced70cf52f8e48) --- source3/rpc_server/srv_netlog_nt.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 173c4218cb..bf615682d3 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -391,6 +391,16 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); + /* + * 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)) { + return NT_STATUS_ACCESS_DENIED; + } + pdb_init_sam(&sampass); become_root(); @@ -403,18 +413,6 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * 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)) { - pdb_free_sam(sampass); - return NT_STATUS_ACCESS_DENIED; - } - DEBUG(100,("Server password set : new given value was :\n")); for(i = 0; i < 16; i++) -- cgit From d74d82bddce5d6cf3f554ff014e08f2aeb2c14bc Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 26 Sep 2001 11:51:25 +0000 Subject: Make use of the pdb_set_plaintext_passwd() update to vastly simplify decode_pw_buffer() and the samr password changing routines. And yes, I know that we can lost some information in the Unicode->UTF->Unicode bit of this, but its worth the code cleanup. This also takes into account the possability of multibyte passwords. Andrew Bartlett (This used to be commit 42402c87d6bcff71b700e497b74d2600d7ce8b95) --- source3/rpc_server/srv_samr_nt.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 4ffd1c85b5..4290e24395 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2339,9 +2339,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) { SAM_ACCOUNT *pwd = NULL; SAM_ACCOUNT *new_pwd = NULL; - uint8 nt_hash[16]; - uint8 lm_hash[16]; - pstring buf; + pstring plaintext_buf; uint32 len; uint16 acct_ctrl; @@ -2366,13 +2364,12 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) copy_id23_to_sam_passwd(new_pwd, id23); - if (!decode_pw_buffer((char*)id23->pass, buf, 256, &len, nt_hash, lm_hash)) { + if (!decode_pw_buffer((char*)id23->pass, plaintext_buf, 256, &len)) { pdb_free_sam(new_pwd); return False; } - pdb_set_lanman_passwd (new_pwd, lm_hash); - pdb_set_nt_passwd (new_pwd, nt_hash); + pdb_set_plaintext_passwd (new_pwd, plaintext_buf); /* if it's a trust account, don't update /etc/passwd */ if ( ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || @@ -2382,13 +2379,13 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) } else { /* update the UNIX password */ if (lp_unix_password_sync() ) - if(!chgpasswd(pdb_get_username(new_pwd), "", buf, True)) { + if(!chgpasswd(pdb_get_username(new_pwd), "", plaintext_buf, True)) { pdb_free_sam(new_pwd); return False; } } - memset(buf, 0, sizeof(buf)); + ZERO_STRUCT(plaintext_buf); if(!pdb_update_sam_account(new_pwd, True)) { pdb_free_sam(new_pwd); @@ -2407,10 +2404,8 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) static BOOL set_user_info_pw(char *pass, uint32 rid) { SAM_ACCOUNT *pwd = NULL; - uchar nt_hash[16]; - uchar lm_hash[16]; uint32 len; - pstring buf; + pstring plaintext_buf; uint16 acct_ctrl; pdb_init_sam(&pwd); @@ -2422,15 +2417,14 @@ static BOOL set_user_info_pw(char *pass, uint32 rid) acct_ctrl = pdb_get_acct_ctrl(pwd); - memset(buf, 0, sizeof(buf)); + ZERO_STRUCT(plaintext_buf); - if (!decode_pw_buffer(pass, buf, 256, &len, nt_hash, lm_hash)) { + if (!decode_pw_buffer(pass, plaintext_buf, 256, &len)) { pdb_free_sam(pwd); return False; } - pdb_set_lanman_passwd (pwd, lm_hash); - pdb_set_nt_passwd (pwd, nt_hash); + pdb_set_plaintext_passwd (pwd, plaintext_buf); /* if it's a trust account, don't update /etc/passwd */ if ( ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || @@ -2440,13 +2434,13 @@ static BOOL set_user_info_pw(char *pass, uint32 rid) } else { /* update the UNIX password */ if (lp_unix_password_sync()) - if(!chgpasswd(pdb_get_username(pwd), "", buf, True)) { + if(!chgpasswd(pdb_get_username(pwd), "", plaintext_buf, True)) { pdb_free_sam(pwd); return False; } } - memset(buf, 0, sizeof(buf)); + ZERO_STRUCT(plaintext_buf); DEBUG(5,("set_user_info_pw: pdb_update_sam_account()\n")); -- cgit From 2a9cd3b79af12ad32aafe204b2a964348385eba7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 27 Sep 2001 09:13:26 +0000 Subject: Fix memory leak in get_sampwd_entries(), reindent for clarity. - call pdb_reset_sam() after each getent call. Fix bug in get_group_alias_entries(), were if num_entries was zero this caused talloc() to return NULL, failing a test below with NT_STATUS_NO_MEMORY. Fix pdb_reset_sam() to correctly initalise the sam structure. Move default value code into a single place, likewise for sam freeing code. - should make things easier if we decide to malloc other strings, or get more non-zero default values. Finally, add a function in init a sam struct from a getpwnam() return. Andrew Bartlett (This used to be commit a41fb44f5e90cf8734d57217e836e14f4a80bd47) --- source3/rpc_server/srv_samr_nt.c | 85 ++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 39 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 4290e24395..f7e6317edf 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -106,44 +106,50 @@ static NTSTATUS get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, pdb_free_sam(pwd); return NT_STATUS_ACCESS_DENIED; } - + while (((not_finished = pdb_getsampwent(pwd)) != False) - && (*num_entries) < max_num_entries) + && (*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; - } - - 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 (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); - - 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) )); + pdb_reset_sam(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)); + /* skip the requested number of entries. + not very efficient, but hey... */ + start_idx--; + continue; + } + + 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 (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); + + 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)); + } (*total_entries)++; - } + + pdb_reset_sam(pwd); + } + pdb_endsampwent(); pdb_free_sam(pwd); @@ -807,17 +813,18 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM if (sid_equal(sid, &global_sid_Builtin) && !lp_hide_local_users()) { enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ALL_MAPPED); - - *d_grp=(DOMAIN_GRP *)talloc_zero(ctx, num_entries*sizeof(DOMAIN_GRP)); - if (*d_grp==NULL) - return NT_STATUS_NO_MEMORY; - for(i=0; istatus = NT_STATUS_OK; rpcstr_pull(user_name, q_u->uni_user_name.buffer, sizeof(user_name), q_u->uni_user_name.uni_str_len*2, 0); - rpcstr_pull(wks, q_u->uni_dest_host.buffer, sizeof(wks), q_u->uni_dest_host.uni_str_len,0); + rpcstr_pull(wks, q_u->uni_dest_host.buffer, sizeof(wks), q_u->uni_dest_host.uni_str_len*2,0); DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); -- cgit From 81697d5ebe33ad95dedfc376118fcdf0367cf052 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 29 Sep 2001 13:08:26 +0000 Subject: Fix up a number of intertwined issues: The big one is a global change to allow us to NULLify the free'ed pointer to a former passdb object. This was done to allow idra's SAFE_FREE() macro to do its magic, and to satisfy the input test in pdb_init_sam() for a NULL pointer to start with. This NULL pointer test was what was breaking the adding of accounts up until now, and this code has been reworked to avoid duplicating work - I hope this will avoid a similar mess-up in future. Finally, I fixed a few nasty bugs where the pdb_ fuctions's return codes were being ignored. Some of these functions malloc() and are permitted to fail. Also, this caught a nasty bug where pdb_set_lanman_password(sam, NULL) acheived precisely didilly-squat, just returning False. Now that we check the returns this bug was spotted. This could allow different LM and NT passwords. - the pdbedit code needs to start checking these too, but I havn't had a chance to fix it. I have also fixed up where some of the password changing code was using the pdb_set functions to store *internal* data. I assume this is from a previous lot of mass conversion work... Most likally (and going on past experience) I have missed somthing, probably in the LanMan password change code which I havn't yet been able to test, but this lot is in much better shape than it was before. If all this is too much to swallow (particularly for 2.2.2) then just adding a sam_pass = NULL to the particular line of passdb.c should do the trick for the ovbious bug. Andrew Bartlett (This used to be commit 762c8758a7869809d89b4da9c2a5249678942930) --- source3/rpc_server/srv_netlog_nt.c | 32 +++++++--- source3/rpc_server/srv_pipe.c | 6 +- source3/rpc_server/srv_samr_nt.c | 127 +++++++++++++++++++++---------------- source3/rpc_server/srv_util.c | 8 +-- 4 files changed, 100 insertions(+), 73 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index bf615682d3..fffa5b1ba1 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -203,19 +203,19 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) if (ret==False) { DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); - pdb_free_sam(sampass); + 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); + pdb_free_sam(&sampass); return True; } DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); - pdb_free_sam(sampass); + pdb_free_sam(&sampass); return False; } @@ -410,7 +410,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * /* Ensure the account exists and is a machine account. */ if (ret==False || !(pdb_get_acct_ctrl(sampass) & ACB_WSTRUST)) { - pdb_free_sam(sampass); + pdb_free_sam(&sampass); return NT_STATUS_NO_SUCH_USER; } @@ -422,9 +422,21 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * cred_hash3( pwd, q_u->pwd, p->dc.sess_key, 0); /* lies! nt and lm passwords are _not_ the same: don't care */ - pdb_set_lanman_passwd (sampass, pwd); - pdb_set_nt_passwd (sampass, pwd); - pdb_set_acct_ctrl (sampass, 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; + } + + if (!pdb_set_acct_ctrl (sampass, ACB_WSTRUST)) { + pdb_free_sam(&sampass); + /* Not quite sure what this one qualifies as, but this will do */ + return NT_STATUS_NO_MEMORY; + } become_root(); ret = pdb_update_sam_account (sampass,False); @@ -436,7 +448,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * /* set up the LSA Server Password Set response */ init_net_r_srv_pwset(r_u, &srv_cred, status); - pdb_free_sam(sampass); + pdb_free_sam(&sampass); return r_u->status; } @@ -679,7 +691,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * unbecome_root(); if (ret == False) { - pdb_free_sam(sampass); + pdb_free_sam(&sampass); return NT_STATUS_NO_SUCH_USER; } @@ -736,6 +748,6 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * &global_sam_sid, /* DOM_SID *dom_sid */ NULL); /* char *other_sids */ } - pdb_free_sam(sampass); + pdb_free_sam(&sampass); return status; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index b3f590a177..00acb93cf3 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -385,7 +385,7 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name 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); + pdb_free_sam(&sampass); unbecome_root(); return False; } @@ -394,7 +394,7 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name if(!pdb_get_nt_passwd(sampass)) { DEBUG(1,("Account for user '%s' has no NT password hash.\n", pipe_user_name)); - pdb_free_sam(sampass); + pdb_free_sam(&sampass); return False; } @@ -463,7 +463,7 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name p->ntlmssp_auth_validated = True; - pdb_free_sam(sampass); + pdb_free_sam(&sampass); return True; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f7e6317edf..9748d0e950 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -103,7 +103,7 @@ static NTSTATUS get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, if (!pdb_setsampwent(False)) { DEBUG(0, ("get_sampwd_entries: Unable to open passdb.\n")); - pdb_free_sam(pwd); + pdb_free_sam(&pwd); return NT_STATUS_ACCESS_DENIED; } @@ -151,7 +151,7 @@ static NTSTATUS get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, } pdb_endsampwent(); - pdb_free_sam(pwd); + pdb_free_sam(&pwd); if (not_finished) return STATUS_MORE_ENTRIES; @@ -231,7 +231,7 @@ static NTSTATUS jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, *total_entries = *num_entries; - pdb_free_sam(pwd); + pdb_free_sam(&pwd); if (not_finished) return STATUS_MORE_ENTRIES; @@ -1508,12 +1508,12 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN /* check that the RID exists in our domain. */ if (ret == False) { - pdb_free_sam(sampass); + pdb_free_sam(&sampass); return NT_STATUS_NO_SUCH_USER; } samr_clear_sam_passwd(sampass); - pdb_free_sam(sampass); + pdb_free_sam(&sampass); /* Get the domain SID stored in the domain policy */ if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid)) @@ -1559,7 +1559,7 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) if (ret==False) { DEBUG(4,("User 0x%x not found\n", user_rid)); - pdb_free_sam(smbpass); + pdb_free_sam(&smbpass); return False; } @@ -1569,7 +1569,7 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) init_sam_user_info10(id10, pdb_get_acct_ctrl(smbpass) ); samr_clear_sam_passwd(smbpass); - pdb_free_sam(smbpass); + pdb_free_sam(&smbpass); return True; } @@ -1600,21 +1600,21 @@ static NTSTATUS get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint3 if (ret == False) { DEBUG(4, ("User 0x%x not found\n", user_rid)); - pdb_free_sam(smbpass); + 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", pdb_get_username(smbpass), pdb_get_acct_ctrl(smbpass) )); if ( pdb_get_acct_ctrl(smbpass) & ACB_DISABLED) { - pdb_free_sam(smbpass); + pdb_free_sam(&smbpass); return NT_STATUS_ACCOUNT_DISABLED; } ZERO_STRUCTP(id12); init_sam_user_info12(id12, pdb_get_lanman_passwd(smbpass), pdb_get_nt_passwd(smbpass)); - pdb_free_sam(smbpass); + pdb_free_sam(&smbpass); return NT_STATUS_OK; } @@ -1641,7 +1641,7 @@ static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, uint32 user_rid) if (ret == False) { DEBUG(4,("User 0x%x not found\n", user_rid)); - pdb_free_sam(sampass); + pdb_free_sam(&sampass); return False; } @@ -1652,7 +1652,7 @@ static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, uint32 user_rid) ZERO_STRUCTP(id20); init_sam_user_info20A(id20, sampass); - pdb_free_sam(sampass); + pdb_free_sam(&sampass); return True; } @@ -1679,7 +1679,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) if (ret == False) { DEBUG(4,("User 0x%x not found\n", user_rid)); - pdb_free_sam(sampass); + pdb_free_sam(&sampass); return False; } @@ -1690,7 +1690,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) ZERO_STRUCTP(id21); init_sam_user_info21A(id21, sampass); - pdb_free_sam(sampass); + pdb_free_sam(&sampass); return True; } @@ -1946,7 +1946,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ unbecome_root(); if (ret == True) { /* this account exists: say so */ - pdb_free_sam(sam_pass); + pdb_free_sam(&sam_pass); return NT_STATUS_USER_EXISTS; } @@ -1982,7 +1982,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ pstrcpy(add_script, lp_adduser_script()); } else { DEBUG(0, ("_api_samr_create_user: mismatch between trust flags and $ termination\n")); - pdb_free_sam(sam_pass); + pdb_free_sam(&sam_pass); return NT_STATUS_UNSUCCESSFUL; } @@ -1997,7 +1997,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ if (!local_password_change(account, local_flags, NULL, err_str, sizeof(err_str), msg_str, sizeof(msg_str))) { DEBUG(0, ("%s\n", err_str)); - pdb_free_sam(sam_pass); + pdb_free_sam(&sam_pass); return NT_STATUS_ACCESS_DENIED; } @@ -2006,25 +2006,25 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ unbecome_root(); if (ret == False) { /* account doesn't exist: say so */ - pdb_free_sam(sam_pass); + pdb_free_sam(&sam_pass); return NT_STATUS_ACCESS_DENIED; } /* Get the domain SID stored in the domain policy */ if(!get_lsa_policy_samr_sid(p, &dom_pol, &sid)) { - pdb_free_sam(sam_pass); + 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); + 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); + pdb_free_sam(&sam_pass); return NT_STATUS_NO_MEMORY; } @@ -2033,14 +2033,14 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ /* 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); + 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); + pdb_free_sam(&sam_pass); return NT_STATUS_OK; } @@ -2236,24 +2236,27 @@ static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, uint32 rid) ret = pdb_getsampwrid(pwd, rid); if(ret==False) { - pdb_free_sam(pwd); + pdb_free_sam(&pwd); return False; } if (id10 == NULL) { DEBUG(5, ("set_user_info_10: NULL id10\n")); - pdb_free_sam(pwd); + pdb_free_sam(&pwd); return False; } - pdb_set_acct_ctrl(pwd, id10->acb_info); + if (!pdb_set_acct_ctrl(pwd, id10->acb_info)) { + pdb_free_sam(&pwd); + return False; + } if(!pdb_update_sam_account(pwd, True)) { - pdb_free_sam(pwd); + pdb_free_sam(&pwd); return False; } - pdb_free_sam(pwd); + pdb_free_sam(&pwd); return True; } @@ -2269,25 +2272,31 @@ static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, uint32 rid) pdb_init_sam(&pwd); if(!pdb_getsampwrid(pwd, rid)) { - pdb_free_sam(pwd); + pdb_free_sam(&pwd); return False; } if (id12 == NULL) { DEBUG(2, ("set_user_info_12: id12 is NULL\n")); - pdb_free_sam(pwd); + pdb_free_sam(&pwd); return False; } - pdb_set_lanman_passwd (pwd, id12->lm_pwd); - pdb_set_nt_passwd (pwd, id12->nt_pwd); + 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); + pdb_free_sam(&pwd); return False; } - pdb_free_sam(pwd); + pdb_free_sam(&pwd); return True; } @@ -2309,8 +2318,8 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) pdb_init_sam(&new_pwd); if (!pdb_getsampwrid(pwd, rid)) { - pdb_free_sam(pwd); - pdb_free_sam(new_pwd); + pdb_free_sam(&pwd); + pdb_free_sam(&new_pwd); return False; } @@ -2327,13 +2336,13 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) /* write the change out */ if(!pdb_update_sam_account(new_pwd, True)) { - pdb_free_sam(pwd); - pdb_free_sam(new_pwd); + pdb_free_sam(&pwd); + pdb_free_sam(&new_pwd); return False; } - pdb_free_sam(pwd); - pdb_free_sam(new_pwd); + pdb_free_sam(&pwd); + pdb_free_sam(&new_pwd); return True; } @@ -2359,24 +2368,27 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) pdb_init_sam(&new_pwd); if (!pdb_getsampwrid(pwd, rid)) { - pdb_free_sam(pwd); - pdb_free_sam(new_pwd); + pdb_free_sam(&pwd); + pdb_free_sam(&new_pwd); return False; } acct_ctrl = pdb_get_acct_ctrl(pwd); copy_sam_passwd(new_pwd, pwd); - pdb_free_sam(pwd); + pdb_free_sam(&pwd); copy_id23_to_sam_passwd(new_pwd, id23); if (!decode_pw_buffer((char*)id23->pass, plaintext_buf, 256, &len)) { - pdb_free_sam(new_pwd); + pdb_free_sam(&new_pwd); return False; } - pdb_set_plaintext_passwd (new_pwd, plaintext_buf); + if (!pdb_set_plaintext_passwd (new_pwd, plaintext_buf)) { + pdb_free_sam(&new_pwd); + return False; + } /* if it's a trust account, don't update /etc/passwd */ if ( ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || @@ -2387,7 +2399,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) /* update the UNIX password */ if (lp_unix_password_sync() ) if(!chgpasswd(pdb_get_username(new_pwd), "", plaintext_buf, True)) { - pdb_free_sam(new_pwd); + pdb_free_sam(&new_pwd); return False; } } @@ -2395,11 +2407,11 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) ZERO_STRUCT(plaintext_buf); if(!pdb_update_sam_account(new_pwd, True)) { - pdb_free_sam(new_pwd); + pdb_free_sam(&new_pwd); return False; } - pdb_free_sam(new_pwd); + pdb_free_sam(&new_pwd); return True; } @@ -2418,7 +2430,7 @@ static BOOL set_user_info_pw(char *pass, uint32 rid) pdb_init_sam(&pwd); if (!pdb_getsampwrid(pwd, rid)) { - pdb_free_sam(pwd); + pdb_free_sam(&pwd); return False; } @@ -2427,11 +2439,14 @@ static BOOL set_user_info_pw(char *pass, uint32 rid) ZERO_STRUCT(plaintext_buf); if (!decode_pw_buffer(pass, plaintext_buf, 256, &len)) { - pdb_free_sam(pwd); + pdb_free_sam(&pwd); return False; } - pdb_set_plaintext_passwd (pwd, plaintext_buf); + if (!pdb_set_plaintext_passwd (pwd, plaintext_buf)) { + pdb_free_sam(&pwd); + return False; + } /* if it's a trust account, don't update /etc/passwd */ if ( ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || @@ -2442,7 +2457,7 @@ static BOOL set_user_info_pw(char *pass, uint32 rid) /* update the UNIX password */ if (lp_unix_password_sync()) if(!chgpasswd(pdb_get_username(pwd), "", plaintext_buf, True)) { - pdb_free_sam(pwd); + pdb_free_sam(&pwd); return False; } } @@ -2453,11 +2468,11 @@ static BOOL set_user_info_pw(char *pass, uint32 rid) /* update the SAMBA password */ if(!pdb_update_sam_account(pwd, True)) { - pdb_free_sam(pwd); + pdb_free_sam(&pwd); return False; } - pdb_free_sam(pwd); + pdb_free_sam(&pwd); return True; } @@ -2516,14 +2531,14 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE unbecome_root(); 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); + pdb_free_sam(&sam_pass); return NT_STATUS_ACCESS_DENIED; } memset(sess_key, '\0', 16); mdfour(sess_key, pdb_get_nt_passwd(sam_pass), 16); - pdb_free_sam(sam_pass); + pdb_free_sam(&sam_pass); /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 5393523a78..dc66887ee9 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -274,12 +274,12 @@ NTSTATUS local_lookup_user_name(uint32 rid, char *user_name, uint32 *type) if (ret == True) { fstrcpy(user_name, pdb_get_username(sampwd) ); DEBUG(5,(" = %s\n", user_name)); - pdb_free_sam(sampwd); + pdb_free_sam(&sampwd); return NT_STATUS_OK; } DEBUG(5,(" none mapped\n")); - pdb_free_sam(sampwd); + pdb_free_sam(&sampwd); return NT_STATUS_NONE_MAPPED; } @@ -340,10 +340,10 @@ NTSTATUS local_lookup_user_rid(char *user_name, uint32 *rid) if (ret == True) { (*rid) = pdb_get_user_rid(sampass); - pdb_free_sam(sampass); + pdb_free_sam(&sampass); return NT_STATUS_OK; } - pdb_free_sam(sampass); + pdb_free_sam(&sampass); return NT_STATUS_NONE_MAPPED; } -- cgit From dc1fc3ee8ec2199bc73bb5d7ec711c6800f61d65 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Oct 2001 04:29:50 +0000 Subject: Removed 'extern int DEBUGLEVEL' as it is now in the smb.h header. (This used to be commit 2d0922b0eabfdc0aaf1d0797482fef47ed7fde8e) --- source3/rpc_server/srv_dfs.c | 2 -- source3/rpc_server/srv_dfs_nt.c | 1 - source3/rpc_server/srv_lsa.c | 2 -- source3/rpc_server/srv_lsa_hnd.c | 2 -- source3/rpc_server/srv_lsa_nt.c | 1 - source3/rpc_server/srv_netlog.c | 2 -- source3/rpc_server/srv_netlog_nt.c | 2 -- source3/rpc_server/srv_pipe.c | 2 -- source3/rpc_server/srv_pipe_hnd.c | 3 --- source3/rpc_server/srv_reg.c | 2 -- source3/rpc_server/srv_reg_nt.c | 2 -- source3/rpc_server/srv_samr.c | 2 -- source3/rpc_server/srv_samr_nt.c | 2 -- source3/rpc_server/srv_spoolss.c | 2 -- source3/rpc_server/srv_spoolss_nt.c | 1 - source3/rpc_server/srv_srvsvc.c | 2 -- source3/rpc_server/srv_srvsvc_nt.c | 1 - source3/rpc_server/srv_util.c | 2 -- source3/rpc_server/srv_wkssvc.c | 2 -- source3/rpc_server/srv_wkssvc_nt.c | 1 - 20 files changed, 36 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index e2a78782f3..00a0f58df5 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -29,7 +29,6 @@ #define MAX_MSDFS_JUNCTIONS 256 -extern int DEBUGLEVEL; extern pstring global_myname; /********************************************************************** @@ -176,4 +175,3 @@ BOOL api_netdfs_rpc(pipes_struct *p) { return api_rpcTNP(p, "api_netdfs_rpc", api_netdfs_cmds); } - diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index dba8ddd0d8..e62334c377 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -27,7 +27,6 @@ #include "includes.h" #include "nterr.h" -extern int DEBUGLEVEL; extern pstring global_myname; #define MAX_MSDFS_JUNCTIONS 256 diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 9c934f5023..4331ffca8d 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -26,8 +26,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - /*************************************************************************** api_lsa_open_policy2 ***************************************************************************/ diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index ad726f4cfa..d5f9a52e2f 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -23,8 +23,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - /* This is the max handles across all instances of a pipe name. */ #ifndef MAX_OPEN_POLS #define MAX_OPEN_POLS 1024 diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 98038c2ac7..eeaf9c6347 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -26,7 +26,6 @@ #include "includes.h" -extern int DEBUGLEVEL; extern DOM_SID global_sam_sid; extern fstring global_myworkgroup; extern pstring global_myname; diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 93d7fea554..06e2f75ead 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -26,8 +26,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - /************************************************************************* api_net_req_chal: *************************************************************************/ diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index fffa5b1ba1..678c48ff71 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -27,8 +27,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - extern BOOL sam_logon_in_ssb; extern pstring samlogon_user; extern pstring global_myname; diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 00acb93cf3..2957d7cc95 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -40,8 +40,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) { unsigned char *hash = p->ntlmssp_hash; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 082d3a1263..10d0c3bcb8 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -21,14 +21,11 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include "includes.h" - #define PIPE "\\PIPE\\" #define PIPELEN strlen(PIPE) -extern int DEBUGLEVEL; static pipes_struct *chain_p; static int pipes_open; diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 8aa5c4bddf..1280dc4aa9 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -27,8 +27,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - /******************************************************************* api_reg_close ********************************************************************/ diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index b1c0e8bc65..d934083e6b 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -27,8 +27,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - struct reg_info { /* for use by \PIPE\winreg */ diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index f00ecae3ce..fb7bd4fb25 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -32,8 +32,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - /******************************************************************* api_samr_close_hnd ********************************************************************/ diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9748d0e950..d9cae42145 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -29,8 +29,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - extern fstring global_myworkgroup; extern pstring global_myname; extern DOM_SID global_sam_sid; diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 6c65cb078b..a5ae418cd4 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -24,8 +24,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - /******************************************************************** * api_spoolss_open_printer_ex ********************************************************************/ diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 118a2d64c9..b7ccce92d5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -27,7 +27,6 @@ #include "includes.h" -extern int DEBUGLEVEL; extern pstring global_myname; #ifndef MAX_OPEN_PRINTER_EXS diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index fe008d0dde..35bacc3458 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -26,8 +26,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - /******************************************************************* api_srv_net_srv_get_info ********************************************************************/ diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 2877b7af05..7e82599f28 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -26,7 +26,6 @@ #include "includes.h" -extern int DEBUGLEVEL; extern pstring global_myname; /******************************************************************* diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index dc66887ee9..d441758db2 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -39,8 +39,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - /* * A list of the rids of well known BUILTIN and Domain users * and groups. diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 12e4a8f335..3661824da1 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -25,8 +25,6 @@ #include "includes.h" -extern int DEBUGLEVEL; - /******************************************************************* api_wks_query_info ********************************************************************/ diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 4bbc0e237f..f618531b5f 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -26,7 +26,6 @@ #include "includes.h" -extern int DEBUGLEVEL; extern pstring global_myname; /******************************************************************* -- cgit From a42efb497153dcca1fad227e28f5eaf41ee943c3 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 3 Oct 2001 21:10:29 +0000 Subject: fix some possible memleaks and not tested reallocs spotted by Andreas Moroder (This used to be commit d30939a091b48f4d77f7618c75668ae151a5592e) --- source3/rpc_server/srv_lsa_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index eeaf9c6347..3282fbca9f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -722,6 +722,7 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LS if ( (map.privilege & privs[i].se_priv) == privs[i].se_priv) { set=(LUID_ATTR *)talloc_realloc(p->mem_ctx, set, (count+1)*sizeof(LUID_ATTR)); + if (set == NULL) return NT_STATUS_NO_MEMORY; set[count].luid.low=privs[i].se_priv; set[count].luid.high=1; -- cgit From ed94aa9d611aba4d82e717797565550a4a47270e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 9 Oct 2001 20:54:56 +0000 Subject: Fixes from John Trostel (modified somewhat by me) to ensure that all lookup_XX functions correctly deal with the SID_NAME_TYPE. One fix for connection user lookup in LSA. Jeremy. (This used to be commit 29730027d8118ec7d207c89d0fd7fb24ac173fde) --- source3/rpc_server/srv_lsa_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 3282fbca9f..ceca254a5d 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -649,8 +649,8 @@ NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA 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; -- cgit From a2272cb71f2c48ffeb9a89ce79b3cdbdef7cc249 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 9 Oct 2001 21:22:33 +0000 Subject: Fix bug where removing root from a share SD stops further edit access. Jeremy. (This used to be commit 4d57c7520fa106ef6c29c0678584e1726ded961f) --- source3/rpc_server/srv_srvsvc_nt.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 7e82599f28..f1dabd64a9 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -225,7 +225,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; } @@ -310,6 +310,7 @@ BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 d NT_USER_TOKEN *token = NULL; user_struct *vuser = get_valid_user_struct(vuid); BOOL ret = True; + BOOL is_root = False; mem_ctx = talloc_init(); if (mem_ctx == NULL) @@ -320,12 +321,24 @@ BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 d if (!psd) goto out; - if (vuser) + if (vuser) { token = vuser->nt_user_token; - else + if (vuser->uid == (uid_t)0) + is_root = True; + } else { token = conn->nt_user_token; + if (conn->uid == (uid_t)0) + is_root = True; + } - ret = se_access_check(psd, token, desired_access, &granted, &status); + /* + * Root gets a free pass. + */ + + if (is_root) + ret = True; + else + ret = se_access_check(psd, token, desired_access, &granted, &status); out: -- cgit From de2ece0543bbd0b013310667ebdf33abe78a0ac4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 10 Oct 2001 19:36:53 +0000 Subject: Back-out the share acl fix. Not needed (Gerald has been telling porkies again :-) :-). Jeremy. (This used to be commit 3b56239c51da3bb24d9ac1ee1442717f597c682a) --- source3/rpc_server/srv_srvsvc_nt.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index f1dabd64a9..2ae4a73874 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -310,7 +310,6 @@ BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 d NT_USER_TOKEN *token = NULL; user_struct *vuser = get_valid_user_struct(vuid); BOOL ret = True; - BOOL is_root = False; mem_ctx = talloc_init(); if (mem_ctx == NULL) @@ -321,24 +320,12 @@ BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 d if (!psd) goto out; - if (vuser) { + if (vuser) token = vuser->nt_user_token; - if (vuser->uid == (uid_t)0) - is_root = True; - } else { + else token = conn->nt_user_token; - if (conn->uid == (uid_t)0) - is_root = True; - } - /* - * Root gets a free pass. - */ - - if (is_root) - ret = True; - else - ret = se_access_check(psd, token, desired_access, &granted, &status); + ret = se_access_check(psd, token, desired_access, &granted, &status); out: -- cgit From 375dcb9a8b9bd5774fb4a947b07fd4c9f78f8719 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 16 Oct 2001 22:42:24 +0000 Subject: Fix some unicode string error. I'm wondering if I have to audit *all* the rpc code for that kind of trouble ;-) Oh well I've done it twice already, I can do it a third time ;-) J.F. (This used to be commit 6be8ea28f98d71e04de18b317f4d7a99b55209e8) --- source3/rpc_server/srv_spoolss_nt.c | 73 +++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 31 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b7ccce92d5..0be836c944 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1444,9 +1444,9 @@ static void spoolss_notify_server_name(int snum, slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname); - len = rpcstr_push(temp, temp_name, sizeof(temp)-2, 0); + len = rpcstr_push(temp, temp_name, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len / 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1478,8 +1478,8 @@ static void spoolss_notify_printer_name(int snum, p++; } - len = rpcstr_push(temp, p, sizeof(temp)-2, 0); - data->notify_data.data.length = len / 2 - 1; + len = rpcstr_push(temp, p, sizeof(temp)-2, STR_TERMINATE); + data->notify_data.data.length = len / 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1502,9 +1502,9 @@ static void spoolss_notify_share_name(int snum, pstring temp; uint32 len; - len = rpcstr_push(temp, lp_servicename(snum), sizeof(temp) - 2, 0); + len = rpcstr_push(temp, lp_servicename(snum), sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len / 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1529,9 +1529,9 @@ static void spoolss_notify_port_name(int snum, /* even if it's strange, that's consistant in all the code */ - len = rpcstr_push(temp, printer->info_2->portname, sizeof(temp) - 2, 0); + len = rpcstr_push(temp, printer->info_2->portname, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len / 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1556,8 +1556,8 @@ static void spoolss_notify_driver_name(int snum, pstring temp; uint32 len; - len = rpcstr_push(temp, printer->info_2->drivername, sizeof(temp) - 2, 0); - data->notify_data.data.length = len / 2 - 1; + len = rpcstr_push(temp, printer->info_2->drivername, sizeof(temp)-2, STR_TERMINATE); + data->notify_data.data.length = len / 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1581,12 +1581,12 @@ static void spoolss_notify_comment(int snum, uint32 len; if (*printer->info_2->comment == '\0') - len = rpcstr_push(temp, lp_comment(snum), sizeof(temp) - 2, 0); + len = rpcstr_push(temp, lp_comment(snum), sizeof(temp)-2, STR_TERMINATE); else - len = rpcstr_push(temp, printer->info_2->comment, sizeof(temp) - 2, 0); + len = rpcstr_push(temp, printer->info_2->comment, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len / 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1611,9 +1611,9 @@ static void spoolss_notify_location(int snum, pstring temp; uint32 len; - len = rpcstr_push(temp, printer->info_2->location,sizeof(temp) - 2, 0); + len = rpcstr_push(temp, printer->info_2->location,sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len / 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1650,9 +1650,9 @@ static void spoolss_notify_sepfile(int snum, pstring temp; uint32 len; - len = rpcstr_push(temp, printer->info_2->sepfile, sizeof(temp) - 2, 0); + len = rpcstr_push(temp, printer->info_2->sepfile, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len / 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1676,9 +1676,9 @@ static void spoolss_notify_print_processor(int snum, pstring temp; uint32 len; - len = rpcstr_push(temp, printer->info_2->printprocessor, sizeof(temp) - 2, 0); + len = rpcstr_push(temp, printer->info_2->printprocessor, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len / 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1702,10 +1702,9 @@ static void spoolss_notify_parameters(int snum, pstring temp; uint32 len; - len = rpcstr_push(temp, printer->info_2->parameters, sizeof(temp) - - 2, 0); + len = rpcstr_push(temp, printer->info_2->parameters, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len / 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1729,9 +1728,9 @@ static void spoolss_notify_datatype(int snum, pstring temp; uint32 len; - len = rpcstr_push(temp, printer->info_2->datatype, sizeof(pstring)-2, 0); + len = rpcstr_push(temp, printer->info_2->datatype, sizeof(pstring)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len / 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1768,6 +1767,7 @@ static void spoolss_notify_attributes(int snum, TALLOC_CTX *mem_ctx) { data->notify_data.value[0] = printer->info_2->attributes; + data->notify_data.value[1] = 0; } /******************************************************************* @@ -1780,6 +1780,7 @@ static void spoolss_notify_priority(int snum, TALLOC_CTX *mem_ctx) { data->notify_data.value[0] = printer->info_2->priority; + data->notify_data.value[1] = 0; } /******************************************************************* @@ -1792,6 +1793,7 @@ static void spoolss_notify_default_priority(int snum, TALLOC_CTX *mem_ctx) { data->notify_data.value[0] = printer->info_2->default_priority; + data->notify_data.value[1] = 0; } /******************************************************************* @@ -1804,6 +1806,7 @@ static void spoolss_notify_start_time(int snum, TALLOC_CTX *mem_ctx) { data->notify_data.value[0] = printer->info_2->starttime; + data->notify_data.value[1] = 0; } /******************************************************************* @@ -1816,6 +1819,7 @@ static void spoolss_notify_until_time(int snum, TALLOC_CTX *mem_ctx) { data->notify_data.value[0] = printer->info_2->untiltime; + data->notify_data.value[1] = 0; } /******************************************************************* @@ -1833,6 +1837,7 @@ static void spoolss_notify_status(int snum, memset(&status, 0, sizeof(status)); print_queue_status(snum, &q, &status); data->notify_data.value[0]=(uint32) status.status; + data->notify_data.value[1] = 0; SAFE_FREE(q); } @@ -1850,6 +1855,7 @@ static void spoolss_notify_cjobs(int snum, memset(&status, 0, sizeof(status)); data->notify_data.value[0] = print_queue_status(snum, &q, &status); + data->notify_data.value[1] = 0; SAFE_FREE(q); } @@ -1865,6 +1871,7 @@ static void spoolss_notify_average_ppm(int snum, /* always respond 8 pages per minutes */ /* a little hard ! */ data->notify_data.value[0] = printer->info_2->averageppm; + data->notify_data.value[1] = 0; } /******************************************************************* @@ -1879,10 +1886,10 @@ static void spoolss_notify_username(int snum, pstring temp; uint32 len; - len = rpcstr_push(temp, queue->user, sizeof(temp) - 2, 0); + len = rpcstr_push(temp, queue->user, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len / 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1903,6 +1910,7 @@ static void spoolss_notify_job_status(int snum, TALLOC_CTX *mem_ctx) { data->notify_data.value[0]=nt_printj_status(queue->status); + data->notify_data.value[1] = 0; } /******************************************************************* @@ -1917,9 +1925,9 @@ static void spoolss_notify_job_name(int snum, pstring temp; uint32 len; - len = rpcstr_push(temp, queue->file, sizeof(temp) - 2, 0); + len = rpcstr_push(temp, queue->file, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len / 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1966,9 +1974,9 @@ static void spoolss_notify_job_status_string(int snum, } #endif /* NO LONGER NEEDED. */ - len = rpcstr_push(temp, p, sizeof(temp) - 2, 0); + len = rpcstr_push(temp, p, sizeof(temp) - 2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len / 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1989,6 +1997,7 @@ static void spoolss_notify_job_time(int snum, TALLOC_CTX *mem_ctx) { data->notify_data.value[0]=0x0; + data->notify_data.value[1]=0; } /******************************************************************* @@ -2001,6 +2010,7 @@ static void spoolss_notify_job_size(int snum, TALLOC_CTX *mem_ctx) { data->notify_data.value[0]=queue->size; + data->notify_data.value[1]=0; } /******************************************************************* @@ -2013,6 +2023,7 @@ static void spoolss_notify_job_position(int snum, TALLOC_CTX *mem_ctx) { data->notify_data.value[0]=queue->job; + data->notify_data.value[1]=0; } /******************************************************************* @@ -2032,7 +2043,7 @@ static void spoolss_notify_submitted_time(int snum, len = sizeof(SYSTEMTIME); - data->notify_data.data.length = len/2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { -- cgit From c416ff851b4ecc7a44aee9d00d07dd481d8ae2a7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2001 20:15:12 +0000 Subject: Merge the become_XXX -> change_to_XXX fixes from 2.2.2 to HEAD. Ensure make_conection() can only be called as root. Jeremy. (This used to be commit 8d23a7441b4687458ee021bfe8880558506eddba) --- source3/rpc_server/srv_netlog_nt.c | 2 +- source3/rpc_server/srv_pipe.c | 7 ++----- source3/rpc_server/srv_srvsvc_nt.c | 6 +++++- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 678c48ff71..7a7ff09d71 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -708,7 +708,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * usr_info->ptr_user_info = 0; /* XXXX hack to get standard_sub_basic() to use sam logon username */ - /* possibly a better way would be to do a become_user() call */ + /* possibly a better way would be to do a change_to_user() call */ sam_logon_in_ssb = True; pstrcpy(samlogon_user, nt_username); diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 2957d7cc95..7079cc2ca1 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1135,7 +1135,6 @@ BOOL api_pipe_request(pipes_struct *p) { int i = 0; BOOL ret = False; - BOOL changed_user_id = False; if (p->ntlmssp_auth_validated) { @@ -1143,8 +1142,6 @@ BOOL api_pipe_request(pipes_struct *p) prs_mem_free(&p->out_data.rdata); return False; } - - changed_user_id = True; } for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { @@ -1157,8 +1154,8 @@ BOOL api_pipe_request(pipes_struct *p) } } - if(changed_user_id) - unbecome_authenticated_pipe_user(p); + if(p->ntlmssp_auth_validated) + unbecome_authenticated_pipe_user(); return ret; } diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 2ae4a73874..44e44cfa3a 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1598,7 +1598,9 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE get_current_user(&user, p); + become_root(); conn = make_connection(qualname, null_pw, 0, "A:", user.vuid, &nt_status); + unbecome_root(); if (conn == NULL) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", qualname)); @@ -1649,7 +1651,7 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE psd->dacl->revision = (uint16) NT4_ACL_REVISION; close_file(fsp, True); - + unbecome_user(); close_cnum(conn, user.vuid); return r_u->status; @@ -1700,7 +1702,9 @@ NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC * get_current_user(&user, p); + become_root(); conn = make_connection(qualname, null_pw, 0, "A:", user.vuid, &nt_status); + unbecome_root(); if (conn == NULL) { DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", qualname)); -- cgit From d04824639dbc2864d2c9ad901a4b26e97c442c82 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 27 Oct 2001 07:16:48 +0000 Subject: Raise simultaneous open pipes from 64 to 1024 for large print server environments. Jeremy. (This used to be commit e5f8147d02b57198f684c6686dfa497c6732ff44) --- source3/rpc_server/srv_pipe_hnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 10d0c3bcb8..a47553dcd1 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -30,7 +30,7 @@ static pipes_struct *chain_p; static int pipes_open; #ifndef MAX_OPEN_PIPES -#define MAX_OPEN_PIPES 64 +#define MAX_OPEN_PIPES 1024 #endif static pipes_struct *Pipes; -- cgit From ab5d5cfbe0aee4387ec7ae8805c69b31a1696435 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 29 Oct 2001 07:15:51 +0000 Subject: This commit is number 1 of 4. In particular this commit focusses on: Adding the new 'pass changed now' helper function. While these changes have been mildly tested, and are pretty small, any assistance in this is appreciated. (This used to be commit a8971a5448cf6d203b379c3ed01e331d5263c9ee) --- source3/rpc_server/srv_netlog_nt.c | 6 ++++++ source3/rpc_server/srv_samr_nt.c | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 7a7ff09d71..32a0a02e70 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -436,6 +436,12 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * return NT_STATUS_NO_MEMORY; } + if (!pdb_set_pass_changed_now (sampass)) { + pdb_free_sam(&sampass); + /* Not quite sure what this one qualifies as, but this will do */ + return NT_STATUS_NO_MEMORY; + } + become_root(); ret = pdb_update_sam_account (sampass,False); unbecome_root(); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d9cae42145..7e48d74359 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2288,6 +2288,10 @@ static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, uint32 rid) pdb_free_sam(&pwd); return False; } + if (!pdb_set_pass_changed_now (pwd)) { + pdb_free_sam(&pwd); + return False; + } if(!pdb_update_sam_account(pwd, True)) { pdb_free_sam(&pwd); -- cgit From 2038649e51f48a489aeec49947e1b791f0b3df43 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 29 Oct 2001 07:28:32 +0000 Subject: This commit is number 3 of 4. In particular this commit focuses on: Changing the Get_Pwnam code so that it can work in a const-enforced environment. While these changes have been mildly tested, and are pretty small, any assistance in this is appreciated. ---- These changes allow for 'const' in the Samba tree. There are a number of good reasons to do this: - I want to allow the SAM_ACCOUNT structure to move from wasteful pstrings and fstrings to allocated strings. We can't do that if people are modifying these outputs, as they may well make assumptions about getting pstrings and fstrings - I want --with-pam_smbpass to compile with a slightly sane volume of warnings, currently its pretty bad, even in 2.2 where is compiles at all. - Tridge assures me that he no longer opposes 'const religion' based on the ability to #define const the problem away. - Changed Get_Pwnam(x,y) into two variants (so that the const parameter can work correctly): - Get_Pwnam(const x) and Get_Pwnam_Modify(x). - Reworked smbd/chgpasswd.c to work with these mods, passing around a 'struct passwd' rather than the modified username (This used to be commit e7634f81c5116ff4addfb7e495f54b6bb78e8f77) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7e48d74359..6d57069149 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -864,7 +864,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM } /* Don't return user private groups... */ - if (Get_Pwnam(smap.nt_name, False) != 0) { + if (Get_Pwnam(smap.nt_name) != 0) { DEBUG(10,("get_group_alias_entries: not returing %s, clashes with user.\n", smap.nt_name )); continue; } @@ -1362,7 +1362,7 @@ NTSTATUS _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_ /* * Do any UNIX username case mangling. */ - (void)Get_Pwnam( user_name, True); + (void)Get_Pwnam_Modify( user_name); if (!pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, q_u->nt_newpass.pass, q_u->nt_oldhash.hash)) -- cgit From d9d7f023d8d11943ca0375e1573e6ec9921889bc Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 29 Oct 2001 07:35:11 +0000 Subject: This commit is number 4 of 4. In particular this commit focuses on: Actually adding the 'const' to the passdb interface, and the flow-on changes. Also kill off the 'disp_info' stuff, as its no longer used. While these changes have been mildly tested, and are pretty small, any assistance in this is appreciated. ---- These changes introduces a large dose of 'const' to the Samba tree. There are a number of good reasons to do this: - I want to allow the SAM_ACCOUNT structure to move from wasteful pstrings and fstrings to allocated strings. We can't do that if people are modifying these outputs, as they may well make assumptions about getting pstrings and fstrings - I want --with-pam_smbpass to compile with a slightly sane volume of warnings, currently its pretty bad, even in 2.2 where is compiles at all. - Tridge assures me that he no longer opposes 'const religion' based on the ability to #define const the problem away. - Changed Get_Pwnam(x,y) into two variants (so that the const parameter can work correctly): - Get_Pwnam(const x) and Get_Pwnam_Modify(x). - Reworked smbd/chgpasswd.c to work with these mods, passing around a 'struct passwd' rather than the modified username --- This finishes this line of commits off, your tree should now compile again :-) Andrew Bartlett (This used to be commit c95f5aeb9327347674589ae313b75bee3bf8e317) --- source3/rpc_server/srv_netlog_nt.c | 2 +- source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_util.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 32a0a02e70..cb54d726b3 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -170,7 +170,7 @@ static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, static BOOL get_md4pw(char *md4pw, char *mach_acct) { SAM_ACCOUNT *sampass = NULL; - uint8 *pass; + const uint8 *pass; BOOL ret; #if 0 diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 7079cc2ca1..6f3c050519 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -271,7 +271,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm BOOL guest_user = False; SAM_ACCOUNT *sampass = NULL; uchar null_smb_passwd[16]; - uchar *smb_passwd_ptr = NULL; + const uchar *smb_passwd_ptr = NULL; DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index d441758db2..40831cbad7 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -154,7 +154,7 @@ int make_dom_gids(TALLOC_CTX *ctx, char *gids_str, DOM_GID **ppgids) /******************************************************************* gets a domain user's groups ********************************************************************/ -void get_domain_user_groups(char *domain_groups, char *user) +void get_domain_user_groups(char *domain_groups, const char *user) { pstring tmp; -- cgit From 6f0b8a38ec036a0027e9f938834e241b41db40c5 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 31 Oct 2001 06:20:58 +0000 Subject: Added some extra fields to the auth_serversupplied_info structure. To obtain the full group membership of a user (i.e nested groups on a win2k native mode server) it is necessary to merge this list of groups with the groups returned by winbindd when creating an nt access token. This breaks winbindd linking while AB and I sync up our changes to the authentication subsystem. (This used to be commit 4eeb7bcd783d7cfb3ac232f1faa035773007401d) --- source3/rpc_server/srv_netlog_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index cb54d726b3..0f2b672d38 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -595,6 +595,8 @@ static NTSTATUS _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, c DEBUG(5, ("_net_logon_any: exited with status %s\n", get_nt_error_msg(nt_status))); + free_serversupplied_info(&server_info); /* No info needed */ + return nt_status; } -- cgit From 60f0627afb167faad57385d44f0b587186a7ac2b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 31 Oct 2001 10:46:25 +0000 Subject: This is a farily large patch (3300 lines) and reworks most of the AuthRewrite code. In particular this assists tpot in some of his work, becouse it provides the connection between the authenticaion and the vuid generation. Major Changes: - Fully malloc'ed structures. - Massive rework of the code so that all structures are made and destroyed using malloc and free, rather than hanging around on the stack. - SAM_ACCOUNT unix uids and gids are now pointers to the same, to allow them to be declared 'invalid' without the chance that people might get ROOT by default. - kill off some of the "DOMAIN\user" lookups. These can be readded at a more appropriate place (probably domain_client_validate.c) in the future. They don't belong in session setups. - Massive introduction of DATA_BLOB structures, particularly for passwords. - Use NTLMSSP flags to tell the backend what its getting, rather than magic lenghths. - Fix winbind back up again, but tpot is redoing this soon anyway. - Abstract much of the work in srv_netlog_nt back into auth helper functions. This is a LARGE change, and any assistance is testing it is appriciated. Domain logons are still broken (as far as I can tell) but other functionality seems intact. Needs testing with a wide variety of MS clients. Andrew Bartlett (This used to be commit f70fb819b2f57bd57232b51808345e2319d52f6c) --- source3/rpc_server/srv_netlog_nt.c | 197 ++++++++++--------------------------- source3/rpc_server/srv_pipe.c | 76 +++++++------- source3/rpc_server/srv_srvsvc_nt.c | 12 +-- 3 files changed, 94 insertions(+), 191 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 0f2b672d38..26054117fb 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -484,123 +484,6 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF return r_u->status; } -/************************************************************************* - _net_logon_any: Use the new authentications subsystem to log in. - *************************************************************************/ - -static NTSTATUS _net_logon_any(NET_ID_INFO_CTR *ctr, char *user, char *domain, char *workstation, char *sess_key) -{ - NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE; - - unsigned char local_lm_response[24]; - unsigned char local_nt_response[24]; - - auth_usersupplied_info user_info; - auth_serversupplied_info server_info; - AUTH_STR ourdomain, theirdomain, smb_username, wksta_name; - - DEBUG(5, ("_net_logon_any: entered with user %s and domain %s\n", user, domain)); - - ZERO_STRUCT(user_info); - ZERO_STRUCT(server_info); - ZERO_STRUCT(ourdomain); - ZERO_STRUCT(theirdomain); - ZERO_STRUCT(smb_username); - ZERO_STRUCT(wksta_name); - - ourdomain.str = lp_workgroup(); - ourdomain.len = strlen(ourdomain.str); - - theirdomain.str = domain; - theirdomain.len = strlen(theirdomain.str); - - user_info.requested_domain = theirdomain; - user_info.domain = ourdomain; - - smb_username.str = user; - smb_username.len = strlen(smb_username.str); - - user_info.unix_username = smb_username; /* For the time-being */ - user_info.smb_username = smb_username; - - user_info.wksta_name.str = workstation; - user_info.wksta_name.len = strlen(workstation); - - user_info.wksta_name = wksta_name; - - DEBUG(10,("_net_logon_any: Attempting validation level %d.\n", ctr->switch_value)); - switch (ctr->switch_value) { - case NET_LOGON_TYPE: - /* Standard challange/response authenticaion */ - - user_info.lm_resp.buffer = (uint8 *)ctr->auth.id2.lm_chal_resp.buffer; - user_info.lm_resp.len = ctr->auth.id2.lm_chal_resp.str_str_len; - user_info.nt_resp.buffer = (uint8 *)ctr->auth.id2.nt_chal_resp.buffer; - user_info.nt_resp.len = ctr->auth.id2.nt_chal_resp.str_str_len; - memcpy(user_info.chal, ctr->auth.id2.lm_chal, 8); - break; - case INTERACTIVE_LOGON_TYPE: - /* 'Interactive' autheticaion, supplies the password in its MD4 form, encrypted - with the session key. We will convert this to challange/responce for the - auth subsystem to chew on */ - { - char nt_pwd[16]; - char lm_pwd[16]; - unsigned char key[16]; - - memset(key, 0, 16); - memcpy(key, sess_key, 8); - - memcpy(lm_pwd, ctr->auth.id1.lm_owf.data, 16); - memcpy(nt_pwd, ctr->auth.id1.nt_owf.data, 16); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("key:")); - dump_data(100, (char *)key, 16); - - DEBUG(100,("lm owf password:")); - dump_data(100, lm_pwd, 16); - - DEBUG(100,("nt owf password:")); - dump_data(100, nt_pwd, 16); -#endif - - SamOEMhash((uchar *)lm_pwd, key, 16); - SamOEMhash((uchar *)nt_pwd, key, 16); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("decrypt of lm owf password:")); - dump_data(100, lm_pwd, 16); - - DEBUG(100,("decrypt of nt owf password:")); - dump_data(100, nt_pwd, 16); -#endif - - generate_random_buffer(user_info.chal, 8, False); - SMBOWFencrypt((const unsigned char *)lm_pwd, user_info.chal, local_lm_response); - SMBOWFencrypt((const unsigned char *)nt_pwd, user_info.chal, local_nt_response); - user_info.lm_resp.buffer = (uint8 *)local_lm_response; - user_info.lm_resp.len = 24; - user_info.nt_resp.buffer = (uint8 *)local_nt_response; - user_info.nt_resp.len = 24; - break; - } - default: - DEBUG(2,("SAM Logon: unsupported switch value\n")); - return NT_STATUS_INVALID_INFO_CLASS; - } /* end switch */ - - nt_status = check_password(&user_info, &server_info); - - DEBUG(5, ("_net_logon_any: exited with status %s\n", - get_nt_error_msg(nt_status))); - - free_serversupplied_info(&server_info); /* No info needed */ - - return nt_status; -} - - /************************************************************************* _net_sam_logon @@ -610,15 +493,16 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * { NTSTATUS status = NT_STATUS_OK; NET_USER_INFO_3 *usr_info = NULL; + NET_ID_INFO_CTR *ctr = q_u->sam_id.ctr; DOM_CRED srv_cred; SAM_ACCOUNT *sampass = NULL; UNISTR2 *uni_samlogon_user = NULL; UNISTR2 *uni_samlogon_domain = NULL; UNISTR2 *uni_samlogon_workstation = NULL; fstring nt_username, nt_domain, nt_workstation; - - BOOL ret; - + auth_usersupplied_info *user_info; + auth_serversupplied_info *server_info; + usr_info = (NET_USER_INFO_3 *)talloc(p->mem_ctx, sizeof(NET_USER_INFO_3)); if (!usr_info) return NT_STATUS_NO_MEMORY; @@ -647,16 +531,17 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * switch (q_u->sam_id.logon_level) { case INTERACTIVE_LOGON_TYPE: - uni_samlogon_user = &q_u->sam_id.ctr->auth.id1.uni_user_name; - uni_samlogon_domain = &q_u->sam_id.ctr->auth.id1.uni_domain_name; - uni_samlogon_workstation = &q_u->sam_id.ctr->auth.id1.uni_wksta_name; + uni_samlogon_user = &ctr->auth.id1.uni_user_name; + uni_samlogon_domain = &ctr->auth.id1.uni_domain_name; + + uni_samlogon_workstation = &ctr->auth.id1.uni_wksta_name; DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); break; case NET_LOGON_TYPE: - uni_samlogon_user = &q_u->sam_id.ctr->auth.id2.uni_user_name; - uni_samlogon_domain = &q_u->sam_id.ctr->auth.id2.uni_domain_name; - uni_samlogon_workstation = &q_u->sam_id.ctr->auth.id2.uni_wksta_name; + uni_samlogon_user = &ctr->auth.id2.uni_user_name; + uni_samlogon_domain = &ctr->auth.id2.uni_domain_name; + uni_samlogon_workstation = &ctr->auth.id2.uni_wksta_name; DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); break; @@ -678,29 +563,51 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * * Convert to a UNIX username. */ - map_username(nt_username); + DEBUG(5,("Attempting validation level %d for unmapped username %s.\n", q_u->sam_id.ctr->switch_value, nt_username)); - DEBUG(10,("Attempting validation level %d for mapped username %s.\n", q_u->sam_id.ctr->switch_value, nt_username)); + switch (ctr->switch_value) { + case NET_LOGON_TYPE: + /* Standard challange/response authenticaion */ + make_user_info_netlogon_network(&user_info, + nt_username, nt_domain, + nt_workstation, ctr->auth.id2.lm_chal, + ctr->auth.id2.lm_chal_resp.buffer, + ctr->auth.id2.lm_chal_resp.str_str_len, + ctr->auth.id2.nt_chal_resp.buffer, + ctr->auth.id2.nt_chal_resp.str_str_len); + break; + case INTERACTIVE_LOGON_TYPE: + /* 'Interactive' autheticaion, supplies the password in its MD4 form, encrypted + with the session key. We will convert this to challange/responce for the + auth subsystem to chew on */ + { + make_user_info_netlogon_interactive(&user_info, + nt_username, nt_domain, + nt_workstation, + ctr->auth.id1.lm_owf.data, 16, + ctr->auth.id1.lm_owf.data, 16, + p->dc.sess_key); + break; + } + default: + DEBUG(2,("SAM Logon: unsupported switch value\n")); + return NT_STATUS_INVALID_INFO_CLASS; + } /* end switch */ + + status = check_password(user_info, &server_info); - status = _net_logon_any(q_u->sam_id.ctr, nt_username, nt_domain, nt_workstation, (char *)p->dc.sess_key); + free_user_info(&user_info); + + DEBUG(5, ("_net_sam_logon: exiting with status %s\n", + get_nt_error_msg(status))); /* Check account and password */ - if (NT_STATUS_IS_ERR(status)) + if (NT_STATUS_IS_ERR(status)) { + free_server_info(&server_info); return status; - - pdb_init_sam(&sampass); - - /* get the account information */ - become_root(); - ret = pdb_getsampwnam(sampass, nt_username); - unbecome_root(); - - if (ret == False) { - pdb_free_sam(&sampass); - return NT_STATUS_NO_SUCH_USER; } - + /* 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. */ @@ -748,12 +655,14 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * num_gids, /* uint32 num_groups */ gids , /* DOM_GID *gids */ 0x20 , /* uint32 user_flgs (?) */ - NULL, /* char sess_key[16] */ + NULL, /* uchar sess_key[16] */ my_name , /* char *logon_srv */ my_workgroup, /* char *logon_dom */ &global_sam_sid, /* DOM_SID *dom_sid */ NULL); /* char *other_sids */ } - pdb_free_sam(&sampass); + free_server_info(&server_info); return status; } + + diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 6f3c050519..21de4d3d2b 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -269,10 +269,16 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm fstring domain; fstring wks; BOOL guest_user = False; - SAM_ACCOUNT *sampass = NULL; uchar null_smb_passwd[16]; + const uchar *smb_passwd_ptr = NULL; + auth_usersupplied_info *user_info; + auth_serversupplied_info *server_info; + + uid_t *puid; + uid_t *pgid; + DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); memset(p->user_name, '\0', sizeof(p->user_name)); @@ -336,14 +342,6 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm } else { - /* - * Pass the user through the NT -> unix user mapping - * function. - */ - - fstrcpy(pipe_user_name, user_name); - (void)map_username(pipe_user_name); - /* * Do the length checking only if user is not NULL. */ @@ -362,41 +360,28 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm } if(!guest_user) { + NTSTATUS nt_status; - become_root(); - - p->ntlmssp_auth_validated = - NT_STATUS_IS_OK(pass_check_smb_with_chal(pipe_user_name, NULL, - domain, wks, - (uchar*)p->challenge, - lm_owf, lm_pw_len, - nt_owf, nt_pw_len)); - if (!p->ntlmssp_auth_validated) { - DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ -failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name )); - unbecome_root(); + if (!make_user_info_netlogon_network(&user_info, + user_name, domain, wks, (uchar*)p->challenge, + lm_owf, lm_pw_len, + nt_owf, nt_pw_len)) { + DEBUG(0,("make_user_info_netlogon_network failed! Failing authenticaion.\n")); return False; } - 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; - } + nt_status = check_password(user_info, &server_info); + + free_user_info(&user_info); - unbecome_root(); + p->ntlmssp_auth_validated = NT_STATUS_IS_OK(nt_status); - if(!pdb_get_nt_passwd(sampass)) { - DEBUG(1,("Account for user '%s' has no NT password hash.\n", pipe_user_name)); - pdb_free_sam(&sampass); + if (!p->ntlmssp_auth_validated) { + DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ +failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name )); + free_server_info(&server_info); return False; - } - - smb_passwd_ptr = pdb_get_lanman_passwd(sampass); + } } /* @@ -405,7 +390,7 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name { uchar p24[24]; - NTLMSSPOWFencrypt(smb_passwd_ptr, lm_owf, p24); + NTLMSSPOWFencrypt(server_info->first_8_lm_hash, lm_owf, p24); { unsigned char j = 0; int ind; @@ -447,8 +432,17 @@ 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 = pdb_get_uid(sampass); - p->pipe_user.gid = pdb_get_gid(sampass); + puid = pdb_get_uid(server_info->sam_account); + pgid = pdb_get_gid(server_info->sam_account); + + if (!puid || !pgid) { + DEBUG(0,("Attempted authenticated pipe with invalid user. No uid/gid in SAM_ACCOUNT\n")); + free_server_info(&server_info); + return False; + } + + p->pipe_user.uid = *puid; + p->pipe_user.gid = *pgid; /* Set up pipe user group membership. */ initialise_groups(pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); @@ -461,7 +455,7 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name p->ntlmssp_auth_validated = True; - pdb_free_sam(&sampass); + pdb_free_sam(&server_info->sam_account); return True; } diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 44e44cfa3a..7369c9d37d 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1574,7 +1574,7 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE { SEC_DESC *psd = NULL; size_t sd_size; - fstring null_pw; + DATA_BLOB null_pw; pstring filename; pstring qualname; files_struct *fsp = NULL; @@ -1594,12 +1594,12 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); /* Null password is ok - we are already an authenticated user... */ - *null_pw = '\0'; + null_pw = data_blob(NULL, 0); get_current_user(&user, p); become_root(); - conn = make_connection(qualname, null_pw, 0, "A:", user.vuid, &nt_status); + conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { @@ -1678,7 +1678,7 @@ NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC * SRV_R_NET_FILE_SET_SECDESC *r_u) { BOOL ret; - fstring null_pw; + DATA_BLOB null_pw; pstring filename; pstring qualname; files_struct *fsp = NULL; @@ -1698,12 +1698,12 @@ NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC * unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); /* Null password is ok - we are already an authenticated user... */ - *null_pw = '\0'; + null_pw = data_blob(NULL, 0); get_current_user(&user, p); become_root(); - conn = make_connection(qualname, null_pw, 0, "A:", user.vuid, &nt_status); + conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { -- cgit From b49b7ed1fb6b63d40f6b2aa62f6c8b787a498419 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 31 Oct 2001 11:09:21 +0000 Subject: Small changes for guest authenticated pipes. (This used to be commit 813bf962ae6f29ddcaee4bc8b67d8017f04172b1) --- source3/rpc_server/srv_pipe.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 21de4d3d2b..852dd7de26 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -273,8 +273,8 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm const uchar *smb_passwd_ptr = NULL; - auth_usersupplied_info *user_info; - auth_serversupplied_info *server_info; + auth_usersupplied_info *user_info = NULL; + auth_serversupplied_info *server_info = NULL; uid_t *puid; uid_t *pgid; @@ -295,8 +295,6 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm * Setup an empty password for a guest user. */ - memset(null_smb_passwd,0,16); - /* * We always negotiate UNICODE. */ @@ -338,8 +336,6 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm fstrcpy(pipe_user_name, lp_guestaccount(-1)); DEBUG(100,("Null user in NTLMSSP verification. Using guest = %s\n", pipe_user_name)); - smb_passwd_ptr = null_smb_passwd; - } else { /* @@ -382,6 +378,9 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name free_server_info(&server_info); return False; } + } else { + /* This includes a NULLed out first_8_lm_hash */ + make_server_info_guest(&server_info); } /* @@ -450,8 +449,8 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name /* Create an NT_USER_TOKEN struct for this user. */ p->pipe_user.nt_user_token = create_nt_token(p->pipe_user.uid,p->pipe_user.gid, - p->pipe_user.ngroups, p->pipe_user.groups, - guest_user); + p->pipe_user.ngroups, p->pipe_user.groups, + guest_user); p->ntlmssp_auth_validated = True; -- cgit From abaedd04f273697ab297a0cbbac743f85ea95836 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 31 Oct 2001 11:10:29 +0000 Subject: ... and clean up the unused variables. (This used to be commit e0b56a31480906b39f37761eed20d3cad0d53973) --- source3/rpc_server/srv_pipe.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 852dd7de26..76f4a1ed1e 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -269,10 +269,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm fstring domain; fstring wks; BOOL guest_user = False; - uchar null_smb_passwd[16]; - const uchar *smb_passwd_ptr = NULL; - auth_usersupplied_info *user_info = NULL; auth_serversupplied_info *server_info = NULL; -- cgit From be93100240c4d81e9465015e82d5b71a5e4bf193 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 31 Oct 2001 12:07:59 +0000 Subject: Fix up domain logons. Tested with NT4. (This used to be commit c8b2718adfe114b74a155116c5e74f014d6df887) --- source3/rpc_server/srv_netlog_nt.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 26054117fb..042279c568 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -495,13 +495,12 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * NET_USER_INFO_3 *usr_info = NULL; NET_ID_INFO_CTR *ctr = q_u->sam_id.ctr; DOM_CRED srv_cred; - SAM_ACCOUNT *sampass = NULL; UNISTR2 *uni_samlogon_user = NULL; UNISTR2 *uni_samlogon_domain = NULL; UNISTR2 *uni_samlogon_workstation = NULL; fstring nt_username, nt_domain, nt_workstation; - auth_usersupplied_info *user_info; - auth_serversupplied_info *server_info; + auth_usersupplied_info *user_info = NULL; + auth_serversupplied_info *server_info = NULL; usr_info = (NET_USER_INFO_3 *)talloc(p->mem_ctx, sizeof(NET_USER_INFO_3)); if (!usr_info) @@ -585,7 +584,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * nt_username, nt_domain, nt_workstation, ctr->auth.id1.lm_owf.data, 16, - ctr->auth.id1.lm_owf.data, 16, + ctr->auth.id1.nt_owf.data, 16, p->dc.sess_key); break; } @@ -649,7 +648,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * sam_logon_in_ssb = False; - init_net_user_info3(p->mem_ctx, usr_info, sampass, + init_net_user_info3(p->mem_ctx, usr_info, server_info->sam_account, 0, /* logon_count */ 0, /* bad_pw_count */ num_gids, /* uint32 num_groups */ -- cgit From acb81fe408f0e674088f0952aaba442ddb494b0c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 1 Nov 2001 05:02:41 +0000 Subject: Various post AuthRewrite cleanups, fixups and tidyups. Zero out some of the plaintext passwords for paranoia Fix up some of the other passdb backends with the change to *uid_t rather than uid_t. Make some of the code in srv_netlog_nt.c clearer, is passing an array around, so pass its lenght in is definition, not as a seperate paramater. Use sizeof() rather than magic numbers, it makes things easier to read. Cope with a PAM authenticated user who is not in /etc/passwd - currently by saying NO_SUCH_USER, but this can change in future. Andrew Bartlett (This used to be commit 514c91b16baca639bb04638042bf9894d881172a) --- source3/rpc_server/srv_netlog_nt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 042279c568..d9677519a4 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -581,11 +581,11 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * auth subsystem to chew on */ { make_user_info_netlogon_interactive(&user_info, - nt_username, nt_domain, - nt_workstation, - ctr->auth.id1.lm_owf.data, 16, - ctr->auth.id1.nt_owf.data, 16, - p->dc.sess_key); + nt_username, nt_domain, + nt_workstation, + ctr->auth.id1.lm_owf.data, + ctr->auth.id1.nt_owf.data, + p->dc.sess_key); break; } default: -- cgit From f8e2baf39eb864481dd48f61404136b325cd73c2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Nov 2001 23:34:24 +0000 Subject: Added NT_USER_TOKEN into server_info to fix extra groups problem. Got "medieval on our ass" about const warnings (as many as I could :-). Jeremy. (This used to be commit ee5e7ca547eff016818ba5c43b8ea0c9fa69b808) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 76f4a1ed1e..dfe03c2eb3 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -447,7 +447,7 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name /* Create an NT_USER_TOKEN struct for this user. */ p->pipe_user.nt_user_token = create_nt_token(p->pipe_user.uid,p->pipe_user.gid, p->pipe_user.ngroups, p->pipe_user.groups, - guest_user); + guest_user, NULL); p->ntlmssp_auth_validated = True; -- cgit From 5f5661d21717ee7eea27d4776180dd88635ad8d4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 4 Nov 2001 01:14:15 +0000 Subject: Fix up authenticated pipes in line with vuser changes. This ensures that global groups obtained via a domain logon are respected in the attached NT_USER_TOKEN. This functionality is only available in HEAD, becosue of the way authenticaion has been abstracted. Both vuid logins and authenticated pipes need to use the same code for this in future. Can sombody with the correct facilties check this please?\ Thanks, Andrew Bartlett (This used to be commit caae69fcd096f20aa4c6879b95ec2c275afea041) --- source3/rpc_server/srv_pipe.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index dfe03c2eb3..a718516baa 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -444,10 +444,13 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name initialise_groups(pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); get_current_groups( &p->pipe_user.ngroups, &p->pipe_user.groups); + if (server_info->ptok) + add_supplementary_nt_login_groups(&p->pipe_user.ngroups, &p->pipe_user.groups, &server_info->ptok); + /* Create an NT_USER_TOKEN struct for this user. */ p->pipe_user.nt_user_token = create_nt_token(p->pipe_user.uid,p->pipe_user.gid, p->pipe_user.ngroups, p->pipe_user.groups, - guest_user, NULL); + guest_user, server_info->ptok); p->ntlmssp_auth_validated = True; -- cgit From d876260d885ad991526544756609ea38e4867028 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 5 Nov 2001 00:02:38 +0000 Subject: Don't put a \n on the end of the arg to exit_server() (This used to be commit dfb8566220c3e90ca2b757ea124f53aed103269e) --- source3/rpc_server/srv_pipe_hnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index a47553dcd1..ddc8f3cd2d 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -81,7 +81,7 @@ void init_rpc_pipe_hnd(void) { bmap = bitmap_allocate(MAX_OPEN_PIPES); if (!bmap) - exit_server("out of memory in init_rpc_pipe_hnd\n"); + exit_server("out of memory in init_rpc_pipe_hnd"); } /**************************************************************************** -- cgit From 7623cec4ad5f8eecae1a3c780a7ca89a6a14b93a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 5 Nov 2001 06:15:02 +0000 Subject: Wrote some stubs for new win2k only spoolss rpc commands: GetPrinterDataEx() and SetPrinterDataEx(). Not sure what the command number is for the latter is - I haven't seen it on the wire yet. (This used to be commit 87614c74b3d66cf2ca706b33e6cf0a32b4166e7a) --- source3/rpc_server/srv_spoolss.c | 63 +++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_spoolss_nt.c | 38 ++++++++++++++++++++++ 2 files changed, 101 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index a5ae418cd4..27331e448b 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1199,6 +1199,66 @@ static BOOL api_spoolss_getjob(pipes_struct *p) return True; } +/******************************************************************** + * api_spoolss_getprinterdataex + * + * called from the spoolss dispatcher + ********************************************************************/ + +static BOOL api_spoolss_getprinterdataex(pipes_struct *p) +{ + SPOOL_Q_GETPRINTERDATAEX q_u; + SPOOL_R_GETPRINTERDATAEX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* read the stream and fill the struct */ + if (!spoolss_io_q_getprinterdataex("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_getprinterdataex: unable to unmarshall SPOOL_Q_GETPRINTERDATAEX.\n")); + return False; + } + + r_u.status = _spoolss_getprinterdataex( p, &q_u, &r_u); + + if (!spoolss_io_r_getprinterdataex("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_getprinterdataex: unable to marshall SPOOL_R_GETPRINTERDATAEX.\n")); + return False; + } + + return True; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_setprinterdataex(pipes_struct *p) +{ + SPOOL_Q_SETPRINTERDATAEX q_u; + SPOOL_R_SETPRINTERDATAEX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_setprinterdataex("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_setprinterdataex: unable to unmarshall SPOOL_Q_SETPRINTERDATAEX.\n")); + return False; + } + + r_u.status = _spoolss_setprinterdataex(p, &q_u, &r_u); + + if(!spoolss_io_r_setprinterdataex("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_setprinterdataex: unable to marshall SPOOL_R_SETPRINTERDATAEX.\n")); + return False; + } + + return True; +} + /******************************************************************* \pipe\spoolss commands ********************************************************************/ @@ -1245,6 +1305,9 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors }, {"SPOOLSS_GETJOB", SPOOLSS_GETJOB, api_spoolss_getjob }, {"SPOOLSS_ENUMPRINTPROCDATATYPES", SPOOLSS_ENUMPRINTPROCDATATYPES, api_spoolss_enumprintprocdatatypes }, + {"SPOOLSS_GETPRINTERDATAEX", SPOOLSS_GETPRINTERDATAEX, api_spoolss_getprinterdataex }, + {"SPOOLSS_sETPRINTERDATAEX", SPOOLSS_SETPRINTERDATAEX, api_spoolss_setprinterdataex }, + { NULL, 0, NULL } }; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0be836c944..e5ca373479 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6755,3 +6755,41 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ return WERR_UNKNOWN_LEVEL; } } + +/******************************************************************** + * spoolss_getprinterdataex + ********************************************************************/ + +WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, SPOOL_R_GETPRINTERDATAEX *r_u) +{ + fstring key; + + /* From MSDN documentation of GetPrinterDataEx: pass request to + GetPrinterData if key is "PrinterDriverData" */ + + unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); + + if (strcmp(key, "PrinterDriverData") == 0) + DEBUG(10, ("pass me to getprinterdata\n")); + + return WERR_INVALID_PARAM; +} + +/******************************************************************** + * spoolss_setprinterdata + ********************************************************************/ + +WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, SPOOL_R_SETPRINTERDATAEX *r_u) +{ + fstring key; + + /* From MSDN documentation of SetPrinterDataEx: pass request to + SetPrinterData if key is "PrinterDriverData" */ + + unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); + + if (strcmp(key, "PrinterDriverData") == 0) + DEBUG(10, ("pass me to setprinterdata\n")); + + return WERR_INVALID_PARAM; +} -- cgit From 198612deda878fd5f33b1475154179ecac4645fd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 5 Nov 2001 07:42:55 +0000 Subject: Changed MAX_OPEN_PIPES to 2048. Jeremy. (This used to be commit 591d217ed49b6beca4a87f6b89a81f0c913003dc) --- source3/rpc_server/srv_pipe_hnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index ddc8f3cd2d..cc6415cce7 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -30,7 +30,7 @@ static pipes_struct *chain_p; static int pipes_open; #ifndef MAX_OPEN_PIPES -#define MAX_OPEN_PIPES 1024 +#define MAX_OPEN_PIPES 2048 #endif static pipes_struct *Pipes; -- cgit From 848d01cde5eeb2d445e4a0b5364d9f163aef41fd Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 7 Nov 2001 02:16:22 +0000 Subject: Initilising these variables before appending the domain groups to them (This used to be commit 8004cfea19e10ad942c59f2f6a6bd992791017ba) --- source3/rpc_server/srv_netlog_nt.c | 4 +++- source3/rpc_server/srv_samr_nt.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index d9677519a4..44faefb645 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -637,7 +637,9 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * * rids and then into machine sids for this user. * JRA. */ - + + *domain_groups = 0; + get_domain_user_groups(domain_groups, nt_username); /* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6d57069149..c872c9f99f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1833,6 +1833,8 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S return NT_STATUS_NO_SUCH_USER; } + *groups = 0; + get_domain_user_groups(groups, pdb_get_username(sam_pass)); gids = NULL; num_groups = make_dom_gids(p->mem_ctx, groups, &gids); -- cgit From 55dfb66079333acd8e0aee91c0ee90d0a413a8e6 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 8 Nov 2001 22:19:01 +0000 Subject: Change to guest logon code. This changes the way we process guest logons - we now treat them as normal logons, but set the 'guest' flag. In particular this is needed becouse Win2k will do an NTLMSSP login with username "", therefore missing our previous guest connection code - this is getting a pain to do as a special case all over the shop. Tridge: We don't seem to be setting a guest bit for NTLMSSP, in either the anonymous or authenticated case, can you take a look at this? Also some cleanups in the check_password() code that should make some of the debugs clearer. Various other minor cleanups: - change the session code to just take a vuser, rather than having to do a vuid lookup on vuser.vuid - Change some of the global_client_caps linking - Better debug in authorise_login(): show the vuid. Andrew Bartlett (This used to be commit 62f4e4bd0aef9ade653b3f8d575d2864c166ab4d) --- source3/rpc_server/srv_netlog_nt.c | 9 ++++++- source3/rpc_server/srv_pipe.c | 51 ++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 44faefb645..1aa58f5274 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -597,7 +597,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * free_user_info(&user_info); - DEBUG(5, ("_net_sam_logon: exiting with status %s\n", + DEBUG(5, ("_net_sam_logon: check_password returned status %s\n", get_nt_error_msg(status))); /* Check account and password */ @@ -607,6 +607,13 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return status; } + if (server_info->guest) { + /* We don't like guest domain logons... */ + DEBUG(5,("_net_sam_logon: Attempted domain logon as GUEST denied.\n")); + free_server_info(&server_info); + return NT_STATUS_LOGON_FAILURE; + } + /* 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. */ diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index a718516baa..e3969f7ea8 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -268,7 +268,8 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm fstring pipe_user_name; fstring domain; fstring wks; - BOOL guest_user = False; + + NTSTATUS nt_status; auth_usersupplied_info *user_info = NULL; auth_serversupplied_info *server_info = NULL; @@ -328,8 +329,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm if((strlen(user_name) == 0) && (ntlmssp_resp->hdr_nt_resp.str_str_len==0)) { - guest_user = True; - + fstrcpy(pipe_user_name, lp_guestaccount(-1)); DEBUG(100,("Null user in NTLMSSP verification. Using guest = %s\n", pipe_user_name)); @@ -352,32 +352,25 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm } - if(!guest_user) { - NTSTATUS nt_status; - - if (!make_user_info_netlogon_network(&user_info, - user_name, domain, wks, (uchar*)p->challenge, - lm_owf, lm_pw_len, - nt_owf, nt_pw_len)) { - DEBUG(0,("make_user_info_netlogon_network failed! Failing authenticaion.\n")); - return False; - } - - nt_status = check_password(user_info, &server_info); - - free_user_info(&user_info); - - p->ntlmssp_auth_validated = NT_STATUS_IS_OK(nt_status); - - if (!p->ntlmssp_auth_validated) { - DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ + if (!make_user_info_netlogon_network(&user_info, + user_name, domain, wks, (uchar*)p->challenge, + lm_owf, lm_pw_len, + nt_owf, nt_pw_len)) { + DEBUG(0,("make_user_info_netlogon_network failed! Failing authenticaion.\n")); + return False; + } + + nt_status = check_password(user_info, &server_info); + + free_user_info(&user_info); + + p->ntlmssp_auth_validated = NT_STATUS_IS_OK(nt_status); + + if (!p->ntlmssp_auth_validated) { + DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name )); - free_server_info(&server_info); - return False; - } - } else { - /* This includes a NULLed out first_8_lm_hash */ - make_server_info_guest(&server_info); + free_server_info(&server_info); + return False; } /* @@ -450,7 +443,7 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name /* Create an NT_USER_TOKEN struct for this user. */ p->pipe_user.nt_user_token = create_nt_token(p->pipe_user.uid,p->pipe_user.gid, p->pipe_user.ngroups, p->pipe_user.groups, - guest_user, server_info->ptok); + server_info->guest, server_info->ptok); p->ntlmssp_auth_validated = True; -- cgit From 395aa946cd4fb9d5e07dd2fee418045a8064dfab Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 9 Nov 2001 11:16:06 +0000 Subject: This change updates lp_guestaccount() to be a *global* paramater, rather than per-share. I beleive that almost all the things that this could have done on a per-share basis can be done with other tools, like 'force user'. Almost all the user's of this paramater used it as a global anyway... While this is one step at a time, I hope it will allow me to considerably simplfy the make_connection() code, particularly for the user-level security case. This already removes an absolute truckload of extra attempted password lookups on the guest account. Andrew Bartlett (This used to be commit 8e708332eded210c1d1fe0cebca3c9c19f054b71) --- source3/rpc_server/srv_pipe.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index e3969f7ea8..b9c40e719b 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -265,7 +265,6 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm int nt_pw_len; int lm_pw_len; fstring user_name; - fstring pipe_user_name; fstring domain; fstring wks; @@ -326,14 +325,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm * Allow guest access. Patch from Shirish Kalele . */ - if((strlen(user_name) == 0) && - (ntlmssp_resp->hdr_nt_resp.str_str_len==0)) - { - - fstrcpy(pipe_user_name, lp_guestaccount(-1)); - DEBUG(100,("Null user in NTLMSSP verification. Using guest = %s\n", pipe_user_name)); - - } else { + if (*user_name) { /* * Do the length checking only if user is not NULL. @@ -367,8 +359,8 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm p->ntlmssp_auth_validated = NT_STATUS_IS_OK(nt_status); if (!p->ntlmssp_auth_validated) { - DEBUG(1,("api_pipe_ntlmssp_verify: User %s\\%s from machine %s \ -failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name )); + DEBUG(1,("api_pipe_ntlmssp_verify: User [%s]\\[%s] from machine %s \ +failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); free_server_info(&server_info); return False; } @@ -413,7 +405,7 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name } fstrcpy(p->user_name, user_name); - fstrcpy(p->pipe_user_name, pipe_user_name); + fstrcpy(p->pipe_user_name, pdb_get_username(server_info->sam_account)); fstrcpy(p->domain, domain); fstrcpy(p->wks, wks); @@ -434,7 +426,7 @@ failed authentication on named pipe %s.\n", domain, pipe_user_name, wks, p->name p->pipe_user.gid = *pgid; /* Set up pipe user group membership. */ - initialise_groups(pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); + initialise_groups(p->pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); get_current_groups( &p->pipe_user.ngroups, &p->pipe_user.groups); if (server_info->ptok) -- cgit From e3abad17417bb9f5f1309039aae8e364871c22d8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 9 Nov 2001 20:59:18 +0000 Subject: Fixed a few typos and added the opnum for ADDPRINTERDRIVEREX to the rpc_spoolss.h header file. (This used to be commit d4cafc076be99a66d0660f695995801b4f1d7bfd) --- source3/rpc_server/srv_spoolss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 27331e448b..654e3875ce 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1305,8 +1305,8 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_ENUMMONITORS", SPOOLSS_ENUMMONITORS, api_spoolss_enumprintmonitors }, {"SPOOLSS_GETJOB", SPOOLSS_GETJOB, api_spoolss_getjob }, {"SPOOLSS_ENUMPRINTPROCDATATYPES", SPOOLSS_ENUMPRINTPROCDATATYPES, api_spoolss_enumprintprocdatatypes }, - {"SPOOLSS_GETPRINTERDATAEX", SPOOLSS_GETPRINTERDATAEX, api_spoolss_getprinterdataex }, - {"SPOOLSS_sETPRINTERDATAEX", SPOOLSS_SETPRINTERDATAEX, api_spoolss_setprinterdataex }, + {"SPOOLSS_GETPRINTERDATAEX", SPOOLSS_GETPRINTERDATAEX, api_spoolss_getprinterdataex }, + {"SPOOLSS_SETPRINTERDATAEX", SPOOLSS_SETPRINTERDATAEX, api_spoolss_setprinterdataex }, { NULL, 0, NULL } }; -- cgit From 06ff349e21abd9398eaac521c3a23c2ab7a10cb2 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 15 Nov 2001 05:26:22 +0000 Subject: FALSE -> False (This used to be commit 7c6529c081abe051055be5fbf3016fbea2474752) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e5ca373479..968044b6cd 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5895,7 +5895,7 @@ static WERROR 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) + if (get_short_archi(short_archi, long_archi)==False) return WERR_INVALID_ENVIRONMENT; if((info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1))) == NULL) -- cgit From f741f656737f4ec46cd318e986b6bf412ed309d2 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Mon, 19 Nov 2001 02:49:53 +0000 Subject: Store some path names in global variables initialized to configure default, rather than in preprocessor macros. (This used to be commit 79ec88f0da40faebe1e587f1b3e87b5f2b184f58) --- source3/rpc_server/srv_srvsvc_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 7369c9d37d..5d7ac29aed 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1320,7 +1320,7 @@ NTSTATUS _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, return NT_STATUS_ACCESS_DENIED; slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", - lp_change_share_cmd(), CONFIGFILE, share_name, ptr, comment); + lp_change_share_cmd(), dyn_CONFIGFILE, share_name, ptr, comment); DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command )); if ((ret = smbrun(command, NULL)) != 0) { @@ -1436,7 +1436,7 @@ NTSTATUS _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET string_replace(comment, '"', ' '); slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", - lp_add_share_cmd(), CONFIGFILE, share_name, ptr, comment); + lp_add_share_cmd(), dyn_CONFIGFILE, share_name, ptr, comment); DEBUG(10,("_srv_net_share_add: Running [%s]\n", command )); if ((ret = smbrun(command, NULL)) != 0) { @@ -1502,7 +1502,7 @@ NTSTATUS _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET return NT_STATUS_ACCESS_DENIED; slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", - lp_delete_share_cmd(), CONFIGFILE, lp_servicename(snum)); + lp_delete_share_cmd(), dyn_CONFIGFILE, lp_servicename(snum)); DEBUG(10,("_srv_net_share_del: Running [%s]\n", command )); if ((ret = smbrun(command, NULL)) != 0) { -- cgit From 116740a5df6294b0a4e244f575108ded87452c18 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 22 Nov 2001 05:56:09 +0000 Subject: merge from 2.2 (This used to be commit 96b3a65a73d403a41bf1b3aba79bd743698344ac) --- source3/rpc_server/srv_spoolss.c | 60 ++++++ source3/rpc_server/srv_spoolss_nt.c | 355 ++++++++++++++++++++++++++++++++---- 2 files changed, 382 insertions(+), 33 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 654e3875ce..3a056dcb65 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1259,6 +1259,64 @@ static BOOL api_spoolss_setprinterdataex(pipes_struct *p) return True; } + +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_enumprinterkey(pipes_struct *p) +{ + SPOOL_Q_ENUMPRINTERKEY q_u; + SPOOL_R_ENUMPRINTERKEY r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_enumprinterkey("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_setprinterkey: unable to unmarshall SPOOL_Q_ENUMPRINTERKEY.\n")); + return False; + } + + r_u.status = _spoolss_enumprinterkey(p, &q_u, &r_u); + + if(!spoolss_io_r_enumprinterkey("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_enumprinterkey: unable to marshall SPOOL_R_ENUMPRINTERKEY.\n")); + return False; + } + + return True; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_enumprinterdataex(pipes_struct *p) +{ + SPOOL_Q_ENUMPRINTERDATAEX q_u; + SPOOL_R_ENUMPRINTERDATAEX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_enumprinterdataex("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_enumprinterdataex: unable to unmarshall SPOOL_Q_ENUMPRINTERDATAEX.\n")); + return False; + } + + r_u.status = _spoolss_enumprinterdataex(p, &q_u, &r_u); + + if(!spoolss_io_r_enumprinterdataex("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_enumprinterdataex: unable to marshall SPOOL_R_ENUMPRINTERDATAEX.\n")); + return False; + } + + return True; +} + + /******************************************************************* \pipe\spoolss commands ********************************************************************/ @@ -1307,6 +1365,8 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_ENUMPRINTPROCDATATYPES", SPOOLSS_ENUMPRINTPROCDATATYPES, api_spoolss_enumprintprocdatatypes }, {"SPOOLSS_GETPRINTERDATAEX", SPOOLSS_GETPRINTERDATAEX, api_spoolss_getprinterdataex }, {"SPOOLSS_SETPRINTERDATAEX", SPOOLSS_SETPRINTERDATAEX, api_spoolss_setprinterdataex }, + {"SPOOLSS_ENUMPRINTERKEY", SPOOLSS_ENUMPRINTERKEY, api_spoolss_enumprinterkey }, + {"SPOOLSS_ENUMPRINTERDATAEX", SPOOLSS_ENUMPRINTERDATAEX, api_spoolss_enumprinterdataex }, { NULL, 0, NULL } }; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 968044b6cd..10c022962a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5,7 +5,8 @@ * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Gerald Carter 2000-2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -803,6 +804,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* 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, @@ -1130,6 +1132,7 @@ WERROR _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 WERR_INVALID_ENVIRONMENT; } @@ -1316,7 +1319,7 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO DEBUG(4,("_spoolss_getprinterdata\n")); if (!Printer) { - if((*data=(uint8 *)malloc(4*sizeof(uint8))) == NULL) + if((*data=(uint8 *)talloc_zero(p->mem_ctx, 4*sizeof(uint8))) == NULL) return WERR_NOMEM; DEBUG(0,("_spoolss_getprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); return WERR_BADFID; @@ -1344,9 +1347,8 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO if (*needed > *out_size) return WERR_STATUS_MORE_ENTRIES; - else { + else return WERR_OK; - } } /*************************************************************************** @@ -2235,13 +2237,13 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int if (!search_notify(type, field, &j) ) continue; - + 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); @@ -3180,6 +3182,7 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; + fstring name; /* that's an [in out] buffer */ @@ -3902,6 +3905,7 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ case 6: return getprinterdriver2_level6(servername, architecture, clientmajorversion, snum, buffer, offered, needed); } + return WERR_UNKNOWN_LEVEL; } @@ -4700,9 +4704,9 @@ WERROR _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u r_u->needed = 0; return WERR_INVALID_PARAM; /* this is what a NT server - returns for AddJob. AddJob - must fail on non-local - printers */ + returns for AddJob. AddJob + must fail on non-local + printers */ } /**************************************************************************** @@ -5008,6 +5012,7 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture int ndrivers; uint32 version; fstring *list = NULL; + NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_1 *tdi1, *driver_info_1=NULL; @@ -5087,6 +5092,7 @@ static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture int ndrivers; uint32 version; fstring *list = NULL; + NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_2 *tdi2, *driver_info_2=NULL; @@ -5167,6 +5173,7 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture int ndrivers; uint32 version; fstring *list = NULL; + NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_3 *tdi3, *driver_info_3=NULL; @@ -5776,13 +5783,13 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ return WERR_INVALID_PARAM; } - /* + /* * When a printer is created, the drivername bound to the printer is used - * to lookup previously saved driver initialization info, which is then + * 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 */ err = add_a_printer(*printer, 2); if (!W_ERROR_IS_OK(err)) { @@ -6165,7 +6172,6 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP 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 @@ -6177,6 +6183,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP convert_specific_param(¶m, value , type, data, real_len); + if (get_specific_param(*printer, 2, param->value, &old_param.data, &old_param.type, (uint32 *)&old_param.data_len)) { @@ -6192,7 +6199,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP } unlink_specific_param_if_exist(printer->info_2, param); - + /* * 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 @@ -6208,7 +6215,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP add_a_specific_param(printer->info_2, ¶m); status = mod_a_printer(*printer, 2); } - + done: free_a_printer(&printer, 2); if (param) @@ -6326,7 +6333,7 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE } count = get_ntforms(&list); - if (!delete_a_form(&list, form_name, &count, &ret)) + if(!delete_a_form(&list, form_name, &count, &ret)) return WERR_INVALID_PARAM; SAFE_FREE(list); @@ -6408,9 +6415,9 @@ WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS /* UNISTR2 *name = &q_u->name; - notused. */ /* UNISTR2 *environment = &q_u->environment; - notused. */ uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; - uint32 *needed = &r_u->needed; + uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ @@ -6570,9 +6577,9 @@ WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_ { /* UNISTR2 *name = &q_u->name; - notused. */ uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; - uint32 *needed = &r_u->needed; + uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ @@ -6624,8 +6631,8 @@ static WERROR 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 WERR_OK; + /* NT treats not found as bad param... yet another bad choice */ + return WERR_INVALID_PARAM; } fill_job_info_1(info_1, &(queue[i-1]), i, snum); @@ -6677,8 +6684,8 @@ static WERROR 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 WERR_OK; + /* NT treats not found as bad param... yet another bad choice */ + return WERR_INVALID_PARAM; } ret = get_a_printer(&ntprinter, 2, lp_servicename(snum)); @@ -6762,17 +6769,81 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, SPOOL_R_GETPRINTERDATAEX *r_u) { - fstring key; + POLICY_HND *handle = &q_u->handle; + uint32 in_size = q_u->size; + uint32 *type = &r_u->type; + uint32 *out_size = &r_u->size; + uint8 **data = &r_u->data; + uint32 *needed = &r_u->needed; - /* From MSDN documentation of GetPrinterDataEx: pass request to - GetPrinterData if key is "PrinterDriverData" */ + fstring key, value; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + BOOL found = False; + + DEBUG(4,("_spoolss_getprinterdataex\n")); unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); + unistr2_to_ascii(value, &q_u->valuename, sizeof(value) - 1); - if (strcmp(key, "PrinterDriverData") == 0) - DEBUG(10, ("pass me to getprinterdata\n")); - - return WERR_INVALID_PARAM; + /* in case of problem, return some default values */ + *needed=0; + *type=0; + *out_size=0; + + + if (!Printer) { + if((*data=(uint8 *)talloc_zero(p->mem_ctx, 4*sizeof(uint8))) == NULL) + return WERR_NOMEM; + DEBUG(0,("_spoolss_getprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); + return WERR_BADFID; + } + + + /* Is the handle to a printer or to the server? */ + + if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + { + DEBUG(10,("_spoolss_getprinterdatex: Not implemented for server handles yet\n")); + return WERR_INVALID_PARAM; + } + else + { + /* + * From MSDN documentation of GetPrinterDataEx: pass request + * to GetPrinterData if key is "PrinterDriverData". This is + * the only key we really support. Other keys to implement: + * (a) DsDriver + * (b) DsSpooler + * (c) PnPData + */ + + if (strcmp(key, "PrinterDriverData") != 0) + return WERR_INVALID_PARAM; + + DEBUG(10, ("_spoolss_getprinterdataex: pass me to getprinterdata\n")); + found = getprinterdata_printer(p, p->mem_ctx, handle, value, + type, data, needed, in_size); + + } + + if (!found) { + DEBUG(5, ("value not found, allocating %d\n", *out_size)); + + /* reply this param doesn't exist */ + if (*out_size) { + if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) + return WERR_NOMEM; + } else { + *data = NULL; + } + + return WERR_INVALID_PARAM; + } + + if (*needed > *out_size) + return WERR_MORE_DATA; + else + return WERR_OK; } /******************************************************************** @@ -6781,15 +6852,233 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, SPOOL_R_SETPRINTERDATAEX *r_u) { + SPOOL_Q_SETPRINTERDATA q_u_local; + SPOOL_R_SETPRINTERDATA r_u_local; fstring key; + DEBUG(4,("_spoolss_setprinterdataex\n")); + /* From MSDN documentation of SetPrinterDataEx: pass request to SetPrinterData if key is "PrinterDriverData" */ unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); if (strcmp(key, "PrinterDriverData") == 0) - DEBUG(10, ("pass me to setprinterdata\n")); + return WERR_INVALID_PARAM; + + ZERO_STRUCT(q_u_local); + ZERO_STRUCT(r_u_local); + + /* make a copy to call _spoolss_setprinterdata() */ + + memcpy(&q_u_local.handle, &q_u->handle, sizeof(POLICY_HND)); + copy_unistr2(&q_u_local.value, &q_u->value); + q_u_local.type = q_u->type; + q_u_local.max_len = q_u->max_len; + q_u_local.data = q_u->data; + q_u_local.real_len = q_u->real_len; + q_u_local.numeric_data = q_u->numeric_data; + + return _spoolss_setprinterdata(p, &q_u_local, &r_u_local); +} + +/******************************************************************** + * spoolss_enumprinterkey + ********************************************************************/ + +/* constants for EnumPrinterKey() */ +#define ENUMERATED_KEY_SIZE 19 + +WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPOOL_R_ENUMPRINTERKEY *r_u) +{ + fstring key; + uint16 enumkeys[ENUMERATED_KEY_SIZE+1]; + char* ptr = NULL; + int i; + char *PrinterKey = "PrinterDriverData"; + + DEBUG(4,("_spoolss_enumprinterkey\n")); - return WERR_INVALID_PARAM; + unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); + + /* + * we only support enumating all keys (key == "") + * Of course, the only key we support is the "PrinterDriverData" + * key + */ + if (strlen(key) == 0) + { + r_u->needed = ENUMERATED_KEY_SIZE *2; + if (q_u->size < r_u->needed) + return WERR_MORE_DATA; + + ptr = PrinterKey; + for (i=0; imem_ctx, &r_u->keys, ENUMERATED_KEY_SIZE, enumkeys)) + return WERR_BADFILE; + + return WERR_OK; + } + + /* The "PrinterDriverData" key should have no subkeys */ + if (strcmp(key, PrinterKey) == 0) + { + r_u-> needed = 2; + if (q_u->size < r_u->needed) + return WERR_MORE_DATA; + enumkeys[0] = 0x0; + if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, 1, enumkeys)) + return WERR_BADFILE; + + return WERR_OK; + } + + + /* The return value for an unknown key is documented in MSDN + EnumPrinterKey description */ + return WERR_BADFILE; +} + +/******************************************************************** + * spoolss_enumprinterdataex + ********************************************************************/ + +WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_u, SPOOL_R_ENUMPRINTERDATAEX *r_u) +{ + POLICY_HND *handle = &q_u->handle; + uint32 in_size = q_u->size; + uint32 num_entries, + needed; + NT_PRINTER_INFO_LEVEL *printer = NULL; + PRINTER_ENUM_VALUES *enum_values = NULL; + fstring key, value; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + int snum; + uint32 param_index, + data_len, + type; + WERROR result; + uint8 *data=NULL; + uint32 i; + + + DEBUG(4,("_spoolss_enumprinterdataex\n")); + + if (!Printer) { + DEBUG(0,("_spoolss_enumprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); + return WERR_BADFID; + } + + + /* + * The only key we support is "PrinterDriverData". This should return + > an array of all the key/value pairs returned by EnumPrinterDataSee + * _spoolss_getprinterdataex() for details --jerry + */ + + unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); + if (strcmp(key, "PrinterDriverData") != 0) + { + DEBUG(10,("_spoolss_enumprinterdataex: Unknown keyname [%s]\n", key)); + return WERR_INVALID_PARAM; + } + + + if (!get_printer_snum(p,handle, &snum)) + return WERR_BADFID; + + ZERO_STRUCT(printer); + result = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(result)) + return result; + + + /* + * loop through all params and build the array to pass + * back to the client + */ + result = WERR_OK; + param_index = 0; + needed = 0; + num_entries = 0; + + while (get_specific_param_by_index(*printer, 2, param_index, value, &data, &type, &data_len)) + { + PRINTER_ENUM_VALUES *ptr; + uint32 add_len = 0; + + DEBUG(10,("retrieved value number [%d] [%s]\n", num_entries, value)); + + if ((ptr=talloc_realloc(p->mem_ctx, enum_values, (num_entries+1) * sizeof(PRINTER_ENUM_VALUES))) == NULL) + { + DEBUG(0,("talloc_realloc failed to allocate more memory!\n")); + result = WERR_NOMEM; + goto done; + } + enum_values = ptr; + + /* copy the data */ + init_unistr(&enum_values[num_entries].valuename, value); + enum_values[num_entries].value_len = (strlen(value)+1) * 2; + enum_values[num_entries].type = type; + + /* + * NULL terminate REG_SZ + * FIXME!!! We should not be correctly problems in the way + * we store PrinterData here. Need to investogate + * SetPrinterData[Ex] --jerry + */ + + if (type == REG_SZ) { + /* fix alignment if the string was stored + in a bizarre fashion */ + if ((data_len % 2) == 0) + add_len = 2; + else + add_len = data_len % 2; + } + + if (!(enum_values[num_entries].data=talloc_zero(p->mem_ctx, data_len+add_len))) { + DEBUG(0,("talloc_realloc failed to allocate more memory for data!\n")); + result = WERR_NOMEM; + goto done; + } + memcpy(enum_values[num_entries].data, data, data_len); + enum_values[num_entries].data_len = data_len + add_len; + + /* keep track of the size of the array in bytes */ + + needed += spoolss_size_printer_enum_values(&enum_values[num_entries]); + + num_entries++; + param_index++; + } + + r_u->needed = needed; + r_u->returned = num_entries; + + if (needed > in_size) { + result = WERR_MORE_DATA; + goto done; + } + + /* copy data into the reply */ + + r_u->ctr.size = r_u->needed; + r_u->ctr.size_of_array = r_u->returned; + r_u->ctr.values = enum_values; + + + +done: + free_a_printer(&printer, 2); + + return result; } + + -- cgit From 59b2e772e254aa567b18309e578ea9af6b1ab1e4 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 22 Nov 2001 06:44:05 +0000 Subject: remove unused variables (This used to be commit 90ed3d47e16a511161532f75b98db3f4b10ba685) --- source3/rpc_server/srv_spoolss_nt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 10c022962a..2b8ae2de0b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6964,7 +6964,6 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ type; WERROR result; uint8 *data=NULL; - uint32 i; DEBUG(4,("_spoolss_enumprinterdataex\n")); -- cgit From 2e8ae887857249822b84461fd503105555873508 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Thu, 22 Nov 2001 16:12:43 +0000 Subject: add a command to rpcclient: enumprivs J.F. (This used to be commit fa63cb78e326040f68d858d593ba98e06c26c92e) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index ceca254a5d..b114bd2d57 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -580,7 +580,7 @@ NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, L DEBUG(0,("_lsa_priv_get_dispname: %s", name_asc)); for (i=1; privs[i].se_priv!=SE_PRIV_ALL; i++) { - if ( strcmp(name_asc, privs[i].priv)) { + if ( !strcmp(name_asc, privs[i].priv)) { fstrcpy(desc_asc, privs[i].description); -- cgit From b09d9e3dc5f389c1911649721ee7c33f9c982deb Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Thu, 22 Nov 2001 17:19:59 +0000 Subject: fixing enum_privs and get_dispname server code. That works as expected now. J.F. (This used to be commit f2766932d693fc601b2c3e7853e61f751435ec3c) --- source3/rpc_server/srv_lsa_nt.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index b114bd2d57..da5b866f17 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -545,19 +545,19 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV if (enum_context >= PRIV_ALL_INDEX) return NT_STATUS_UNABLE_TO_FREE_VM; - entries = (LSA_PRIV_ENTRY *)talloc_zero(p->mem_ctx, sizeof(LSA_PRIV_ENTRY) * (PRIV_ALL_INDEX-enum_context)); + entries = (LSA_PRIV_ENTRY *)talloc_zero(p->mem_ctx, sizeof(LSA_PRIV_ENTRY) * (PRIV_ALL_INDEX-enum_context-1)); if (entries==NULL) return NT_STATUS_NO_MEMORY; entry = entries; - for (i = 0; i < PRIV_ALL_INDEX-enum_context; i++, entry++) { + for (i = 0; i < PRIV_ALL_INDEX-enum_context-1; i++, entry++) { init_uni_hdr(&entry->hdr_name, strlen(privs[i+1-enum_context].priv)); init_unistr2(&entry->name, privs[i+1-enum_context].priv, strlen(privs[i+1-enum_context].priv) ); entry->luid_low = privs[i+1-enum_context].se_priv; entry->luid_high = 1; } - init_lsa_r_enum_privs(r_u, i+enum_context, PRIV_ALL_INDEX-enum_context, entries); + init_lsa_r_enum_privs(r_u, i+enum_context, PRIV_ALL_INDEX-enum_context-1, entries); return NT_STATUS_OK; } @@ -570,31 +570,31 @@ NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, L { fstring name_asc; fstring desc_asc; - int i; + int i=1; if (!find_policy_by_hnd(p, &q_u->pol, NULL)) return NT_STATUS_INVALID_HANDLE; unistr2_to_ascii(name_asc, &q_u->name, sizeof(name_asc)); - DEBUG(0,("_lsa_priv_get_dispname: %s", name_asc)); - - for (i=1; privs[i].se_priv!=SE_PRIV_ALL; i++) { - if ( !strcmp(name_asc, privs[i].priv)) { - - fstrcpy(desc_asc, privs[i].description); - - } - } - DEBUG(0,(": %s\n", desc_asc)); - - init_uni_hdr(&r_u->hdr_desc, strlen(desc_asc)); - init_unistr2(&r_u->desc, desc_asc, strlen(desc_asc) ); + DEBUG(10,("_lsa_priv_get_dispname: %s", name_asc)); - r_u->ptr_info=0xdeadbeef; - r_u->lang_id=q_u->lang_id; + while (privs[i].se_priv!=SE_PRIV_ALL && strcmp(name_asc, privs[i].priv)) + i++; + + if (privs[i].se_priv!=SE_PRIV_ALL) { + DEBUG(10,(": %s\n", desc_asc)); + init_uni_hdr(&r_u->hdr_desc, strlen(privs[i].description)); + init_unistr2(&r_u->desc, privs[i].description, strlen(privs[i].description) ); - return NT_STATUS_OK; + r_u->ptr_info=0xdeadbeef; + r_u->lang_id=q_u->lang_id; + return NT_STATUS_OK; + } else { + DEBUG(10,(": doesn't exist\n")); + r_u->ptr_info=0; + return NT_STATUS_NO_SUCH_PRIVILEGE; + } } /*************************************************************************** -- cgit From fbfd27a495afa8673d472957867e58b34499760e Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Thu, 22 Nov 2001 23:50:16 +0000 Subject: added lsa_enum_sids to rpcclient fixed lsa_enum_rpivs server code. This time it works as W2K. fixed smbgroupedit to compile and work. J.F. (This used to be commit 646651018a2736833e49e76f6ca735a4647d9746) --- source3/rpc_server/srv_lsa_nt.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index da5b866f17..f221582d86 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -537,7 +537,7 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV uint32 enum_context=q_u->enum_context; LSA_PRIV_ENTRY *entry; - LSA_PRIV_ENTRY *entries; + LSA_PRIV_ENTRY *entries=NULL; if (!find_policy_by_hnd(p, &q_u->pol, NULL)) return NT_STATUS_INVALID_HANDLE; @@ -545,19 +545,30 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV if (enum_context >= PRIV_ALL_INDEX) return NT_STATUS_UNABLE_TO_FREE_VM; - entries = (LSA_PRIV_ENTRY *)talloc_zero(p->mem_ctx, sizeof(LSA_PRIV_ENTRY) * (PRIV_ALL_INDEX-enum_context-1)); + entries = (LSA_PRIV_ENTRY *)talloc_zero(p->mem_ctx, sizeof(LSA_PRIV_ENTRY) * (PRIV_ALL_INDEX)); if (entries==NULL) return NT_STATUS_NO_MEMORY; entry = entries; - for (i = 0; i < PRIV_ALL_INDEX-enum_context-1; i++, entry++) { - init_uni_hdr(&entry->hdr_name, strlen(privs[i+1-enum_context].priv)); - init_unistr2(&entry->name, privs[i+1-enum_context].priv, strlen(privs[i+1-enum_context].priv) ); - entry->luid_low = privs[i+1-enum_context].se_priv; - entry->luid_high = 1; + + DEBUG(10,("_lsa_enum_privs: enum_context:%d total entries:%d\n", enum_context, PRIV_ALL_INDEX)); + + for (i = 0; i < PRIV_ALL_INDEX; i++, entry++) { + if( ihdr_name, 0); + init_unistr2(&entry->name, NULL, 0 ); + entry->luid_low = 0; + entry->luid_high = 0; + } else { + init_uni_hdr(&entry->hdr_name, strlen(privs[i+1].priv)); + init_unistr2(&entry->name, privs[i+1].priv, strlen(privs[i+1].priv) ); + entry->luid_low = privs[i+1].se_priv; + entry->luid_high = 1; + } } - init_lsa_r_enum_privs(r_u, i+enum_context, PRIV_ALL_INDEX-enum_context-1, entries); + enum_context = PRIV_ALL_INDEX; + init_lsa_r_enum_privs(r_u, enum_context, PRIV_ALL_INDEX, entries); return NT_STATUS_OK; } @@ -569,7 +580,6 @@ _lsa_priv_get_dispname. NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, LSA_R_PRIV_GET_DISPNAME *r_u) { fstring name_asc; - fstring desc_asc; int i=1; if (!find_policy_by_hnd(p, &q_u->pol, NULL)) @@ -583,7 +593,7 @@ NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, L i++; if (privs[i].se_priv!=SE_PRIV_ALL) { - DEBUG(10,(": %s\n", desc_asc)); + DEBUG(10,(": %s\n", privs[i].description)); init_uni_hdr(&r_u->hdr_desc, strlen(privs[i].description)); init_unistr2(&r_u->desc, privs[i].description, strlen(privs[i].description) ); -- cgit From 2527f5ef52400294c98b4f4345a4f18b981ff22f Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 23 Nov 2001 15:11:22 +0000 Subject: Changed how the privileges are stored in the group mapping code. It's now an array of uint32. That's not perfect but that's better. Added more privileges too. Changed the local_lookup_rid/name functions in passdb.c to check if the group is mapped. Makes the LSA rpc calls return correct groups Corrected the return code in the LSA server code enum_sids. Only enumerate well known aliases if they are mapped to real unix groups. Won't confuse user seeing groups not available. Added a short/long view to smbgroupedit. now decoding rpc calls to add/remove privileges to sid. J.F. (This used to be commit f29774e58973f421bfa163c45bfae201a140f28c) --- source3/rpc_server/srv_lsa_nt.c | 12 +++++++----- source3/rpc_server/srv_samr_nt.c | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f221582d86..03d48aa5e7 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -543,7 +543,7 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV return NT_STATUS_INVALID_HANDLE; if (enum_context >= PRIV_ALL_INDEX) - return NT_STATUS_UNABLE_TO_FREE_VM; + return NT_STATUS_NO_MORE_ENTRIES; entries = (LSA_PRIV_ENTRY *)talloc_zero(p->mem_ctx, sizeof(LSA_PRIV_ENTRY) * (PRIV_ALL_INDEX)); if (entries==NULL) @@ -625,6 +625,9 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU if(!enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED)) return NT_STATUS_OK; + if (q_u->enum_context >= num_entries) + return NT_STATUS_NO_MORE_ENTRIES; + sids->ptr_sid = (uint32 *)talloc_zero(p->mem_ctx, (num_entries-q_u->enum_context)*sizeof(uint32)); sids->sid = (DOM_SID2 *)talloc_zero(p->mem_ctx, (num_entries-q_u->enum_context)*sizeof(DOM_SID2)); @@ -707,7 +710,7 @@ NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENAC } /*************************************************************************** - + For a given SID, enumerate all the privilege this account has. ***************************************************************************/ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_R_ENUMPRIVSACCOUNT *r_u) @@ -729,7 +732,7 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LS return NT_STATUS_NO_SUCH_GROUP; for (i=1; privs[i].se_priv!=SE_PRIV_ALL; i++) { - if ( (map.privilege & privs[i].se_priv) == privs[i].se_priv) { + if ( check_priv_in_privilege(map.privileges, privs[i].se_priv)) { set=(LUID_ATTR *)talloc_realloc(p->mem_ctx, set, (count+1)*sizeof(LUID_ATTR)); if (set == NULL) return NT_STATUS_NO_MEMORY; @@ -738,8 +741,7 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LS set[count].luid.high=1; set[count].attr=0; - count++; - + count++; } } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c872c9f99f..f1f3040ba4 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -810,7 +810,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM /* well-known aliases */ if (sid_equal(sid, &global_sid_Builtin) && !lp_hide_local_users()) { - enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ALL_MAPPED); + enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ONLY_MAPPED); if (num_entries != 0) { *d_grp=(DOMAIN_GRP *)talloc_zero(ctx, num_entries*sizeof(DOMAIN_GRP)); -- cgit From 7e1dce1de84ac08cab01b72d83b79c07e808578f Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 23 Nov 2001 15:17:30 +0000 Subject: return NO_MORE_ENTRIES in lsa_enum_trust_dom. UserManager is happier :-) J.F. (This used to be commit 75ee50bbef531a1487c1f8b76b8e70627fbdbdf1) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 03d48aa5e7..bf5d24188e 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -335,7 +335,7 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E /* set up the LSA QUERY INFO response */ 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); + dom_name != NULL ? NT_STATUS_OK : NT_STATUS_NO_MORE_ENTRIES); return r_u->status; } -- cgit From b9a82592f6fe23e5a7342f3174d5d402e3be759d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 23 Nov 2001 19:07:35 +0000 Subject: Sorry. I broke the build, missed on open_directory call. Jeremy. (This used to be commit fe288b14cc7f2bc6b8427438da672e7dd7812027) --- source3/rpc_server/srv_srvsvc_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 5d7ac29aed..9fadba17dd 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1624,7 +1624,7 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE if (!fsp) { /* Perhaps it is a directory */ if (errno == EISDIR) - fsp = open_directory(conn, filename, &st, + fsp = open_directory(conn, filename, &st,0, (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); if (!fsp) { @@ -1728,7 +1728,7 @@ NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC * if (!fsp) { /* Perhaps it is a directory */ if (errno == EISDIR) - fsp = open_directory(conn, filename, &st, + fsp = open_directory(conn, filename, &st,0, (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); if (!fsp) { -- cgit From af1a0238aa106a43006902e8ef593d7853913b0e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 24 Nov 2001 00:36:37 +0000 Subject: Kill off that crazy copy_sam_passwd(). You simply can't do that if the structre contains pointers (well not if you intend of free those pointers at some stage) There is no reason (given the new passdb interface) that you can't modify a SAM_ACCOUNT in any case. Andrew Bartlett (This used to be commit e8e73f7f0fcd86c8c2bfe3fc0b44ea2fd6570cc5) --- source3/rpc_server/srv_samr_nt.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f1f3040ba4..71237a9eec 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2311,7 +2311,6 @@ 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) { SAM_ACCOUNT *pwd = NULL; - SAM_ACCOUNT *new_pwd = NULL; if (id21 == NULL) { DEBUG(5, ("set_user_info_21: NULL id21\n")); @@ -2319,17 +2318,13 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) } pdb_init_sam(&pwd); - pdb_init_sam(&new_pwd); 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); + copy_id21_to_sam_passwd(pwd, id21); /* * The funny part about the previous two calls is @@ -2339,14 +2334,12 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) */ /* write the change out */ - if(!pdb_update_sam_account(new_pwd, True)) { + if(!pdb_update_sam_account(pwd, True)) { pdb_free_sam(&pwd); - pdb_free_sam(&new_pwd); return False; } pdb_free_sam(&pwd); - pdb_free_sam(&new_pwd); return True; } @@ -2358,7 +2351,6 @@ 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) { SAM_ACCOUNT *pwd = NULL; - SAM_ACCOUNT *new_pwd = NULL; pstring plaintext_buf; uint32 len; uint16 acct_ctrl; @@ -2369,28 +2361,23 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) } pdb_init_sam(&pwd); - pdb_init_sam(&new_pwd); if (!pdb_getsampwrid(pwd, rid)) { pdb_free_sam(&pwd); - pdb_free_sam(&new_pwd); return False; } 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); + copy_id23_to_sam_passwd(pwd, id23); if (!decode_pw_buffer((char*)id23->pass, plaintext_buf, 256, &len)) { - pdb_free_sam(&new_pwd); + pdb_free_sam(&pwd); return False; } - if (!pdb_set_plaintext_passwd (new_pwd, plaintext_buf)) { - pdb_free_sam(&new_pwd); + if (!pdb_set_plaintext_passwd (pwd, plaintext_buf)) { + pdb_free_sam(&pwd); return False; } @@ -2402,20 +2389,20 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) } else { /* update the UNIX password */ if (lp_unix_password_sync() ) - if(!chgpasswd(pdb_get_username(new_pwd), "", plaintext_buf, True)) { - pdb_free_sam(&new_pwd); + if(!chgpasswd(pdb_get_username(pwd), "", plaintext_buf, True)) { + pdb_free_sam(&pwd); return False; } } ZERO_STRUCT(plaintext_buf); - if(!pdb_update_sam_account(new_pwd, True)) { - pdb_free_sam(&new_pwd); + if(!pdb_update_sam_account(pwd, True)) { + pdb_free_sam(&pwd); return False; } - pdb_free_sam(&new_pwd); + pdb_free_sam(&pwd); return True; } -- cgit From d0a2faf78d316fec200497f5f7997df4c477a1e1 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 24 Nov 2001 12:12:38 +0000 Subject: This is another rather major change to the samba authenticaion subystem. The particular aim is to modularized the interface - so that we can have arbitrary password back-ends. This code adds one such back-end, a 'winbind' module to authenticate against the winbind_auth_crap functionality. While fully-functional this code is mainly useful as a demonstration, because we don't get back the info3 as we would for direct ntdomain authentication. This commit introduced the new 'auth methods' parameter, in the spirit of the 'auth order' discussed on the lists. It is renamed because not all the methods may be consulted, even if previous methods fail - they may not have a suitable challenge for example. Also, we have a 'local' authentication method, for old-style 'unix if plaintext, sam if encrypted' authentication and a 'guest' module to handle guest logins in a single place. While this current design is not ideal, I feel that it does provide a better infrastructure than the current design, and can be built upon. The following parameters have changed: - use rhosts = This has been replaced by the 'rhosts' authentication method, and can be specified like 'auth methods = guest rhosts' - hosts equiv = This needs both this parameter and an 'auth methods' entry to be effective. (auth methods = guest hostsequiv ....) - plaintext to smbpasswd = This is replaced by specifying 'sam' rather than 'local' in the auth methods. The security = parameter is unchanged, and now provides defaults for the 'auth methods' parameter. The available auth methods are: guest rhosts hostsequiv sam (passdb direct hash access) unix (PAM, crypt() etc) local (the combination of the above, based on encryption) smbserver (old security=server) ntdomain (old security=domain) winbind (use winbind to cache DC connections) Assistance in testing, or the production of new and interesting authentication modules is always appreciated. Andrew Bartlett (This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99) --- source3/rpc_server/srv_netlog_nt.c | 26 ++++++++++++++++++++++---- source3/rpc_server/srv_pipe.c | 8 ++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 1aa58f5274..6f0d2384d5 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -566,26 +566,46 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * switch (ctr->switch_value) { case NET_LOGON_TYPE: + { + auth_authsupplied_info *auth_info = NULL; + make_auth_info_fixed(&auth_info, ctr->auth.id2.lm_chal); /* Standard challange/response authenticaion */ make_user_info_netlogon_network(&user_info, nt_username, nt_domain, - nt_workstation, ctr->auth.id2.lm_chal, + nt_workstation, ctr->auth.id2.lm_chal_resp.buffer, ctr->auth.id2.lm_chal_resp.str_str_len, ctr->auth.id2.nt_chal_resp.buffer, ctr->auth.id2.nt_chal_resp.str_str_len); + + status = check_password(user_info, auth_info, &server_info); + free_auth_info(&auth_info); + break; + } case INTERACTIVE_LOGON_TYPE: /* 'Interactive' autheticaion, supplies the password in its MD4 form, encrypted with the session key. We will convert this to challange/responce for the auth subsystem to chew on */ { + auth_authsupplied_info *auth_info = NULL; + DATA_BLOB chal; + if (!make_auth_info_subsystem(&auth_info)) { + return NT_STATUS_NO_MEMORY; + } + + chal = auth_get_challange(auth_info); + make_user_info_netlogon_interactive(&user_info, nt_username, nt_domain, - nt_workstation, + nt_workstation, chal.data, ctr->auth.id1.lm_owf.data, ctr->auth.id1.nt_owf.data, p->dc.sess_key); + status = check_password(user_info, auth_info, &server_info); + data_blob_free(&chal); + free_auth_info(&auth_info); + break; } default: @@ -593,8 +613,6 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return NT_STATUS_INVALID_INFO_CLASS; } /* end switch */ - status = check_password(user_info, &server_info); - free_user_info(&user_info); DEBUG(5, ("_net_sam_logon: check_password returned status %s\n", diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index b9c40e719b..4b3140b350 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -271,6 +271,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm NTSTATUS nt_status; auth_usersupplied_info *user_info = NULL; + auth_authsupplied_info *auth_info = NULL; auth_serversupplied_info *server_info = NULL; uid_t *puid; @@ -343,17 +344,20 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm return False; } + + make_auth_info_fixed(&auth_info, (uchar*)p->challenge); if (!make_user_info_netlogon_network(&user_info, - user_name, domain, wks, (uchar*)p->challenge, + user_name, domain, wks, lm_owf, lm_pw_len, nt_owf, nt_pw_len)) { DEBUG(0,("make_user_info_netlogon_network failed! Failing authenticaion.\n")); return False; } - nt_status = check_password(user_info, &server_info); + nt_status = check_password(user_info, auth_info, &server_info); + free_auth_info(&auth_info); free_user_info(&user_info); p->ntlmssp_auth_validated = NT_STATUS_IS_OK(nt_status); -- cgit From 97346ea795f43a9d9487d9c1a63af4016a72e753 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 25 Nov 2001 02:30:30 +0000 Subject: Unless the error is exactly NT_STATUS_OK, we might not have a server info, so we need to bail here. (This used to be commit ea0331354e5968aa0a25c0b12379a56c72d7946b) --- source3/rpc_server/srv_netlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 6f0d2384d5..e57c445bb5 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -620,7 +620,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * /* Check account and password */ - if (NT_STATUS_IS_ERR(status)) { + if (!NT_STATUS_IS_OK(status)) { free_server_info(&server_info); return status; } -- cgit From 178f6a64b26d828db6b516392d7072e9c29f6233 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 26 Nov 2001 04:05:28 +0000 Subject: challange -> challenge (This used to be commit d6318add27f6bca5be00cbedf2226b642341297a) --- source3/rpc_server/srv_netlog_nt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index e57c445bb5..5f85d4db9c 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -569,7 +569,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * { auth_authsupplied_info *auth_info = NULL; make_auth_info_fixed(&auth_info, ctr->auth.id2.lm_chal); - /* Standard challange/response authenticaion */ + /* Standard challenge/response authenticaion */ make_user_info_netlogon_network(&user_info, nt_username, nt_domain, nt_workstation, @@ -584,9 +584,10 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * break; } case INTERACTIVE_LOGON_TYPE: - /* 'Interactive' autheticaion, supplies the password in its MD4 form, encrypted - with the session key. We will convert this to challange/responce for the - auth subsystem to chew on */ + /* 'Interactive' autheticaion, supplies the password in its + MD4 form, encrypted with the session key. We will + convert this to chellange/responce for the auth + subsystem to chew on */ { auth_authsupplied_info *auth_info = NULL; DATA_BLOB chal; @@ -594,7 +595,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return NT_STATUS_NO_MEMORY; } - chal = auth_get_challange(auth_info); + chal = auth_get_challenge(auth_info); make_user_info_netlogon_interactive(&user_info, nt_username, nt_domain, -- cgit From d919314390ad51384146797de5268b5c842f039b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Nov 2001 20:01:23 +0000 Subject: Added PRINTER_ALREADY_EXISTS error check from Gerry. Jeremy (This used to be commit c7f1d3d6f776da8619f1221d38619d084ffb990b) --- source3/rpc_server/srv_spoolss_nt.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2b8ae2de0b..71b776f80a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5740,9 +5740,10 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ POLICY_HND *handle) { NT_PRINTER_INFO_LEVEL *printer = NULL; - WERROR err; - fstring name; - int snum; + NT_PRINTER_INFO_LEVEL *old_printer = NULL; + fstring name; + int snum; + WERROR err = WERR_OK; if ((printer = (NT_PRINTER_INFO_LEVEL *)malloc(sizeof(NT_PRINTER_INFO_LEVEL))) == NULL) { DEBUG(0,("spoolss_addprinterex_level_2: malloc fail.\n")); @@ -5754,6 +5755,18 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ /* convert from UNICODE to ASCII - this allocates the info_2 struct inside *printer.*/ convert_printer_info(info, printer, 2); + + /* check to see if the printer already exists */ + err = get_a_printer(&old_printer, 2, printer->info_2->sharename); + + /* did we find a printer? */ + if (W_ERROR_IS_OK(err)) { + DEBUG(5, ("_spoolss_addprinterex: Attempted to add a printer named [%s] when one already existed!\n", + printer->info_2->sharename)); + free_a_printer(&old_printer, 2); + return WERR_PRINTER_ALREADY_EXISTS; + } + if (*lp_addprinter_cmd() ) if ( !add_printer_hook(printer) ) { free_a_printer(&printer,2); -- cgit From e158c4123d6d47cc43472365f5e6215a0851e001 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Wed, 28 Nov 2001 00:06:00 +0000 Subject: added samr_set_domain_info and samr_unknown_2E. We now get the full account policy window in usermanager, and the framework to store all those values. I plan to add a TDB file to store them. oh, and found that the last value in a sam_unknown_info_12_inf struct is an uint16 and not a uint32. andrewb: you hardcoded the MAX_PASSWORD_AGE to 21 days. We can now turn it to a value setable in usermanager. J.F. (This used to be commit 99471d25693f6672d433b90a060378f6faad867f) --- source3/rpc_server/srv_samr.c | 64 ++++++++++++++++++++++++++ source3/rpc_server/srv_samr_nt.c | 98 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index fb7bd4fb25..177ee51d25 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1311,6 +1311,68 @@ static BOOL api_samr_unknown_2d(pipes_struct *p) return True; } +/******************************************************************* + api_samr_query_dom_info + ********************************************************************/ + +static BOOL api_samr_unknown_2e(pipes_struct *p) +{ + SAMR_Q_UNKNOWN_2E q_u; + SAMR_R_UNKNOWN_2E r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the samr unknown 8 command */ + if(!samr_io_q_unknown_2e("", &q_u, data, 0)) { + DEBUG(0,("api_samr_unknown_2e: unable to unmarshall SAMR_Q_UNKNOWN_2E.\n")); + return False; + } + + r_u.status = _samr_unknown_2e(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!samr_io_r_samr_unknown_2e("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_unknown_2e: unable to marshall SAMR_R_UNKNOWN_2E.\n")); + return False; + } + + return True; +} + +/******************************************************************* + api_samr_set_dom_info + ********************************************************************/ + +static BOOL api_samr_set_dom_info(pipes_struct *p) +{ + SAMR_Q_SET_DOMAIN_INFO q_u; + SAMR_R_SET_DOMAIN_INFO r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the samr unknown 8 command */ + if(!samr_io_q_set_domain_info("", &q_u, data, 0)) { + DEBUG(0,("api_samr_set_dom_info: unable to unmarshall SAMR_Q_SET_DOMAIN_INFO.\n")); + return False; + } + + r_u.status = _samr_set_dom_info(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!samr_io_r_set_domain_info("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_set_dom_info: unable to marshall SAMR_R_SET_DOMAIN_INFO.\n")); + return False; + } + + return True; +} + /******************************************************************* array of \PIPE\samr operations ********************************************************************/ @@ -1366,6 +1428,8 @@ static struct api_struct api_samr_cmds [] = {"SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, {"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, + {"SAMR_UNKNOWN_2E" , SAMR_UNKNOWN_2E , api_samr_unknown_2e }, + {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, {NULL , 0 , NULL } }; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 71237a9eec..12b37834d8 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3336,3 +3336,101 @@ NTSTATUS _samr_unknown_2d(pipes_struct *p, SAMR_Q_UNKNOWN_2D *q_u, SAMR_R_UNKNOW DEBUG(0,("_samr_unknown_2d: Not yet implemented.\n")); return NT_STATUS_NOT_IMPLEMENTED; } + +/******************************************************************* + _samr_unknown_2e + ********************************************************************/ + +NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOWN_2E *r_u) +{ + SAM_UNK_CTR *ctr; + + 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_OK; + + DEBUG(5,("_samr_unknown_2e: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (!find_policy_by_hnd(p, &q_u->domain_pol, NULL)) + return NT_STATUS_INVALID_HANDLE; + + switch (q_u->switch_value) { + case 0x01: + init_unk_info1(&ctr->info.inf1); + break; + case 0x02: + /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ + init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL)); + break; + case 0x03: + init_unk_info3(&ctr->info.inf3); + break; + case 0x05: + init_unk_info5(&ctr->info.inf5, global_myname); + break; + case 0x06: + init_unk_info6(&ctr->info.inf6); + break; + case 0x07: + init_unk_info7(&ctr->info.inf7); + break; + case 0x0c: + init_unk_info12(&ctr->info.inf12); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + } + + init_samr_r_samr_unknown_2e(r_u, q_u->switch_value, ctr, NT_STATUS_OK); + + DEBUG(5,("_samr_unknown_2e: %d\n", __LINE__)); + + return r_u->status; +} + +/******************************************************************* + _samr_ + ********************************************************************/ + +NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R_SET_DOMAIN_INFO *r_u) +{ + r_u->status = NT_STATUS_OK; + + DEBUG(5,("_samr_set_dom_info: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (!find_policy_by_hnd(p, &q_u->domain_pol, NULL)) + return NT_STATUS_INVALID_HANDLE; + + DEBUG(0,("_samr_set_dom_info: switch_value: %d\n", q_u->switch_value)); + + switch (q_u->switch_value) { + case 0x01: + break; + case 0x02: + break; + case 0x03: + break; + case 0x05: + break; + case 0x06: + break; + case 0x07: + break; + case 0x0c: + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + } + + init_samr_r_set_domain_info(r_u, NT_STATUS_OK); + + DEBUG(5,("_samr_set_dom_info: %d\n", __LINE__)); + + return r_u->status; +} + -- cgit From bd8e916cb520d89a14a1cd13b2b261253729ac9b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 28 Nov 2001 21:51:11 +0000 Subject: merge from APPLIANCE_HEAD (This used to be commit c60aa6c06f376684b6d6d9a2c14305ca9f4657ef) --- source3/rpc_server/srv_spoolss_nt.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 71b776f80a..3b21726a0f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2959,13 +2959,14 @@ static WERROR enum_all_printers_info_1_local(NEW_BUFFER *buffer, uint32 offered, *********************************************************************/ static WERROR enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - fstring temp; + char *s = name; + DEBUG(4,("enum_all_printers_info_1_name\n")); - fstrcpy(temp, "\\\\"); - fstrcat(temp, global_myname); + if ((name[0] == '\\') && (name[1] == '\\')) + s = name + 2; - if (strequal(name, temp)) { + if (is_myname_or_ipaddr(s)) { return enum_all_printers_info_1(PRINTER_ENUM_ICON8, buffer, offered, needed, returned); } else @@ -3131,20 +3132,16 @@ static WERROR enumprinters_level2( uint32 flags, fstring servername, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - fstring temp; - - fstrcpy(temp, "\\\\"); - fstrcat(temp, global_myname); + char *s = servername; if (flags & PRINTER_ENUM_LOCAL) { - if (strequal(servername, temp)) - return enum_all_printers_info_2(buffer, offered, needed, returned); - else return enum_all_printers_info_2(buffer, offered, needed, returned); } if (flags & PRINTER_ENUM_NAME) { - if (strequal(servername, temp)) + if ((servername[0] == '\\') && (servername[1] == '\\')) + s = servername + 2; + if (is_myname_or_ipaddr(s)) return enum_all_printers_info_2(buffer, offered, needed, returned); else return WERR_INVALID_NAME; -- cgit From fac01bda8bb4f52b930496c362f55aca5b112240 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Thu, 29 Nov 2001 16:05:05 +0000 Subject: Changed again how the privilege list is handled in the group mapping code. This time it's a PRIVILEGE_SET struct instead of a simple uint32 array. It makes much more sense. Also added a uint32 systemaccount to the GROUP_MAP struct as some privilege showing in USRMGR.EXE are not real privs but a bitmask flag. I guess it's an heritage from NT 3.0 ! I could setup an NT 3.1 box to verify, but I'm too lazy (yes I still have my CDs). Added 3 more LSA calls: SetSystemAccount, AddPrivileges and RemovePrivileges, we can manage all this privilege from UserManager. Time to change the NT_USER_TOKEN struct and add checks in all the rpc functions. Fun, fun, fun. J.F. (This used to be commit 3f0a9ef2b8c626cfa2878394bb7b642342342bf3) --- source3/rpc_server/srv_lsa.c | 125 ++++++++++++++++++++++++--- source3/rpc_server/srv_lsa_nt.c | 179 +++++++++++++++++++++++++++++++++++---- source3/rpc_server/srv_samr_nt.c | 63 ++++++++++++-- 3 files changed, 329 insertions(+), 38 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 4331ffca8d..d2b2c60f45 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -481,28 +481,125 @@ static BOOL api_lsa_getsystemaccount(pipes_struct *p) } +/*************************************************************************** + api_lsa_setsystemaccount + ***************************************************************************/ + +static BOOL api_lsa_setsystemaccount(pipes_struct *p) +{ + LSA_Q_SETSYSTEMACCOUNT q_u; + LSA_R_SETSYSTEMACCOUNT r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_setsystemaccount("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_setsystemaccount: failed to unmarshall LSA_Q_SETSYSTEMACCOUNT.\n")); + return False; + } + + r_u.status = _lsa_setsystemaccount(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_setsystemaccount("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_setsystemaccount: Failed to marshall LSA_R_SETSYSTEMACCOUNT.\n")); + return False; + } + + return True; +} + +/*************************************************************************** + api_lsa_addprivs + ***************************************************************************/ + +static BOOL api_lsa_addprivs(pipes_struct *p) +{ + LSA_Q_ADDPRIVS q_u; + LSA_R_ADDPRIVS r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_addprivs("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_addprivs: failed to unmarshall LSA_Q_ADDPRIVS.\n")); + return False; + } + + r_u.status = _lsa_addprivs(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_addprivs("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_addprivs: Failed to marshall LSA_R_ADDPRIVS.\n")); + return False; + } + + return True; +} + +/*************************************************************************** + api_lsa_removeprivs + ***************************************************************************/ + +static BOOL api_lsa_removeprivs(pipes_struct *p) +{ + LSA_Q_REMOVEPRIVS q_u; + LSA_R_REMOVEPRIVS r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_removeprivs("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_removeprivs: failed to unmarshall LSA_Q_REMOVEPRIVS.\n")); + return False; + } + + r_u.status = _lsa_removeprivs(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_removeprivs("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_removeprivs: Failed to marshall LSA_R_REMOVEPRIVS.\n")); + return False; + } + + return True; +} + + /*************************************************************************** \PIPE\ntlsa commands ***************************************************************************/ static struct api_struct api_lsa_cmds[] = { - { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 }, - { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy }, - { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info }, - { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom }, - { "LSA_CLOSE" , LSA_CLOSE , api_lsa_close }, - { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret }, - { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids }, - { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names }, - { "LSA_ENUM_PRIVS" , LSA_ENUM_PRIVS , api_lsa_enum_privs }, + { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 }, + { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy }, + { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info }, + { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom }, + { "LSA_CLOSE" , LSA_CLOSE , api_lsa_close }, + { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret }, + { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids }, + { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names }, + { "LSA_ENUM_PRIVS" , LSA_ENUM_PRIVS , api_lsa_enum_privs }, { "LSA_PRIV_GET_DISPNAME",LSA_PRIV_GET_DISPNAME,api_lsa_priv_get_dispname}, - { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS , api_lsa_enum_accounts }, - { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser}, - { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT , api_lsa_open_account }, + { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS , api_lsa_enum_accounts }, + { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser }, + { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT , api_lsa_open_account }, { "LSA_ENUMPRIVSACCOUNT", LSA_ENUMPRIVSACCOUNT, api_lsa_enum_privsaccount}, - { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT, api_lsa_getsystemaccount}, - { NULL , 0 , NULL } + { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT, api_lsa_getsystemaccount }, + { "LSA_SETSYSTEMACCOUNT", LSA_SETSYSTEMACCOUNT, api_lsa_setsystemaccount }, + { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs }, + { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs }, + { NULL , 0 , NULL } }; /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index bf5d24188e..b16e3836f6 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -563,7 +563,7 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV init_uni_hdr(&entry->hdr_name, strlen(privs[i+1].priv)); init_unistr2(&entry->name, privs[i+1].priv, strlen(privs[i+1].priv) ); entry->luid_low = privs[i+1].se_priv; - entry->luid_high = 1; + entry->luid_high = 0; } } @@ -601,7 +601,7 @@ NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, L r_u->lang_id=q_u->lang_id; return NT_STATUS_OK; } else { - DEBUG(10,(": doesn't exist\n")); + DEBUG(10,("_lsa_priv_get_dispname: doesn't exist\n")); r_u->ptr_info=0; return NT_STATUS_NO_SUCH_PRIVILEGE; } @@ -717,7 +717,6 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LS { struct lsa_info *info=NULL; GROUP_MAP map; - uint32 count=0; int i=0; LUID_ATTR *set=NULL; @@ -731,21 +730,26 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LS if (!get_group_map_from_sid(info->sid, &map)) return NT_STATUS_NO_SUCH_GROUP; - for (i=1; privs[i].se_priv!=SE_PRIV_ALL; i++) { - if ( check_priv_in_privilege(map.privileges, privs[i].se_priv)) { - - set=(LUID_ATTR *)talloc_realloc(p->mem_ctx, set, (count+1)*sizeof(LUID_ATTR)); - if (set == NULL) return NT_STATUS_NO_MEMORY; - - set[count].luid.low=privs[i].se_priv; - set[count].luid.high=1; - set[count].attr=0; - - count++; + DEBUG(10,("_lsa_enum_privsaccount: %d privileges\n", map.priv_set.count)); + if (map.priv_set.count!=0) { + + set=(LUID_ATTR *)talloc(p->mem_ctx, map.priv_set.count*sizeof(LUID_ATTR)); + if (set == NULL) { + free_privilege(&map.priv_set); + return NT_STATUS_NO_MEMORY; + } + + for (i=0; istatus; } @@ -756,13 +760,154 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LS NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA_R_GETSYSTEMACCOUNT *r_u) { + struct lsa_info *info=NULL; + GROUP_MAP map; r_u->status = NT_STATUS_OK; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - r_u->access=3; + if (!get_group_map_from_sid(info->sid, &map)) + return NT_STATUS_NO_SUCH_GROUP; + + /* + 0x01 -> Log on locally + 0x02 -> Access this computer from network + 0x04 -> Log on as a batch job + 0x10 -> Log on as a service + + they can be ORed together + */ + + r_u->access=map.systemaccount; return r_u->status; } + +/*************************************************************************** + update the systemaccount information + ***************************************************************************/ + +NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA_R_SETSYSTEMACCOUNT *r_u) +{ + struct lsa_info *info=NULL; + GROUP_MAP map; + r_u->status = NT_STATUS_OK; + + /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; + + if (!get_group_map_from_sid(info->sid, &map)) + return NT_STATUS_NO_SUCH_GROUP; + + map.systemaccount=q_u->access; + + if(!add_mapping_entry(&map, TDB_REPLACE)) + return NT_STATUS_NO_SUCH_GROUP; + + return r_u->status; +} + +/*************************************************************************** + For a given SID, add some privileges. + ***************************************************************************/ + +NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u) +{ + struct lsa_info *info=NULL; + GROUP_MAP map; + int i=0; + + LUID_ATTR *luid_attr=NULL; + PRIVILEGE_SET *set=NULL; + + r_u->status = NT_STATUS_OK; + + /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; + + if (!get_group_map_from_sid(info->sid, &map)) + return NT_STATUS_NO_SUCH_GROUP; + + set=&q_u->set; + + for (i=0; icount; i++) { + luid_attr=&set->set[i]; + + /* check if the privilege is already there */ + if (check_priv_in_privilege(&map.priv_set, *luid_attr)){ + free_privilege(&map.priv_set); + return NT_STATUS_NO_SUCH_PRIVILEGE; + } + + add_privilege(&map.priv_set, *luid_attr); + } + + if(!add_mapping_entry(&map, TDB_REPLACE)) + return NT_STATUS_NO_SUCH_GROUP; + + free_privilege(&map.priv_set); + + return r_u->status; +} + +/*************************************************************************** + For a given SID, remove some privileges. + ***************************************************************************/ + +NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEPRIVS *r_u) +{ + struct lsa_info *info=NULL; + GROUP_MAP map; + int i=0; + + LUID_ATTR *luid_attr=NULL; + PRIVILEGE_SET *set=NULL; + + r_u->status = NT_STATUS_OK; + + /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; + + if (!get_group_map_from_sid(info->sid, &map)) + return NT_STATUS_NO_SUCH_GROUP; + + if (q_u->allrights!=0) { + /* log it and return, until I see one myself don't do anything */ + DEBUG(5,("_lsa_removeprivs: trying to remove all privileges ?\n")); + return NT_STATUS_OK; + } + + if (q_u->ptr==0) { + /* log it and return, until I see one myself don't do anything */ + DEBUG(5,("_lsa_removeprivs: no privileges to remove ?\n")); + return NT_STATUS_OK; + } + + set=&q_u->set; + + for (i=0; icount; i++) { + luid_attr=&set->set[i]; + + /* if we don't have the privilege, we're trying to remove, give up */ + /* what else can we do ??? JFM. */ + if (!check_priv_in_privilege(&map.priv_set, *luid_attr)){ + free_privilege(&map.priv_set); + return NT_STATUS_NO_SUCH_PRIVILEGE; + } + + remove_privilege(&map.priv_set, *luid_attr); + } + + if(!add_mapping_entry(&map, TDB_REPLACE)) + return NT_STATUS_NO_SUCH_GROUP; + + free_privilege(&map.priv_set); + + return r_u->status; +} + diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 12b37834d8..112b1bb293 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -813,13 +813,16 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ONLY_MAPPED); if (num_entries != 0) { + for (i=0; isid.sid, &rid); uid=pdb_user_rid_to_uid(rid); @@ -2885,6 +2908,8 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD if(!get_domain_group_from_sid(group_sid, &map)) return NT_STATUS_NO_SUCH_GROUP; + free_privilege(&map.priv_set); + if ((pwd=getpwuid(pdb_user_rid_to_uid(q_u->rid))) ==NULL) return NT_STATUS_NO_SUCH_USER; @@ -2968,6 +2993,8 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S if(!get_domain_group_from_sid(group_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; + free_privilege(&map.priv_set); + gid=map.gid; /* check if group really exists */ @@ -3025,6 +3052,8 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S if(!get_local_group_from_sid(alias_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; + free_privilege(&map.priv_set); + gid=map.gid; /* check if group really exists */ @@ -3059,6 +3088,9 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S fstring sid_string; struct group *grp; struct samr_info *info; + PRIVILEGE_SET priv_set; + + init_privilege(&priv_set); /* Find the policy handle. Open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid)) @@ -3085,7 +3117,7 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); /* add the group to the mapping table */ - if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_DOM_GRP, name, NULL, SE_PRIV_NONE)) + if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_DOM_GRP, name, NULL, priv_set, PR_ACCESS_FROM_NETWORK)) return NT_STATUS_ACCESS_DENIED; if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) @@ -3115,6 +3147,9 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S fstring sid_string; struct group *grp; struct samr_info *info; + PRIVILEGE_SET priv_set; + + init_privilege(&priv_set); /* Find the policy handle. Open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid)) @@ -3150,7 +3185,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S sid_to_string(sid_string, &info->sid); /* add the group to the mapping table */ - if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_ALIAS, name, NULL, SE_PRIV_NONE)) + if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_ALIAS, name, NULL, priv_set, PR_ACCESS_FROM_NETWORK)) return NT_STATUS_ACCESS_DENIED; /* get a (unique) handle. open a policy on it. */ @@ -3180,6 +3215,8 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM if (!get_domain_group_from_sid(group_sid, &map)) return NT_STATUS_INVALID_HANDLE; + + free_privilege(&map.priv_set); ctr=(GROUP_INFO_CTR *)talloc_zero(p->mem_ctx, sizeof(GROUP_INFO_CTR)); if (ctr==NULL) @@ -3234,11 +3271,16 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ unistr2_to_ascii(map.comment, &(ctr->group.info4.uni_acct_desc), sizeof(map.comment)-1); break; default: + free_privilege(&map.priv_set); return NT_STATUS_INVALID_INFO_CLASS; } - if(!add_mapping_entry(&map, TDB_REPLACE)) + if(!add_mapping_entry(&map, TDB_REPLACE)) { + free_privilege(&map.priv_set); return NT_STATUS_NO_SUCH_GROUP; + } + + free_privilege(&map.priv_set); return NT_STATUS_OK; } @@ -3268,11 +3310,16 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ unistr2_to_ascii(map.comment, &(ctr->alias.info3.uni_acct_desc), sizeof(map.comment)-1); break; default: + free_privilege(&map.priv_set); return NT_STATUS_INVALID_INFO_CLASS; } - if(!add_mapping_entry(&map, TDB_REPLACE)) + if(!add_mapping_entry(&map, TDB_REPLACE)) { + free_privilege(&map.priv_set); return NT_STATUS_NO_SUCH_GROUP; + } + + free_privilege(&map.priv_set); return NT_STATUS_OK; } @@ -3320,6 +3367,8 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G if (!get_domain_group_from_sid(info->sid, &map)) return NT_STATUS_NO_SUCH_USER; + free_privilege(&map.priv_set); + /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, &r_u->pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; -- cgit From 6d9adfe73c04132ff162d05b0c309395c4a54485 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 30 Nov 2001 01:04:15 +0000 Subject: Renamed sid field in SEC_ACE to trustee to be more in line with MS's definitions. (This used to be commit 9712d3f15a47155f558d0034ef71fd06afb11301) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3b21726a0f..c64a7a218c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4150,7 +4150,7 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, for (i = 0; i < the_acl->num_aces; i++) { fstring sid_str; - sid_to_string(sid_str, &the_acl->ace[i].sid); + sid_to_string(sid_str, &the_acl->ace[i].trustee); DEBUG(10, ("%s 0x%08x\n", sid_str, the_acl->ace[i].info.mask)); @@ -4165,7 +4165,7 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, for (i = 0; i < the_acl->num_aces; i++) { fstring sid_str; - sid_to_string(sid_str, &the_acl->ace[i].sid); + sid_to_string(sid_str, &the_acl->ace[i].trustee); DEBUG(10, ("%s 0x%08x\n", sid_str, the_acl->ace[i].info.mask)); -- cgit From 445ab75ec33db60307a373885efe622ed5c65d02 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 30 Nov 2001 03:38:59 +0000 Subject: Gerald's fix. Jeremy (This used to be commit b0c1fcfc8bae83788c7595931321833bf177ec4b) --- source3/rpc_server/srv_spoolss_nt.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c64a7a218c..3c7948fd7b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5737,7 +5737,6 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ POLICY_HND *handle) { NT_PRINTER_INFO_LEVEL *printer = NULL; - NT_PRINTER_INFO_LEVEL *old_printer = NULL; fstring name; int snum; WERROR err = WERR_OK; @@ -5752,15 +5751,12 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ /* convert from UNICODE to ASCII - this allocates the info_2 struct inside *printer.*/ convert_printer_info(info, printer, 2); - /* check to see if the printer already exists */ - err = get_a_printer(&old_printer, 2, printer->info_2->sharename); - /* did we find a printer? */ - if (W_ERROR_IS_OK(err)) { + if ((snum = print_queue_snum(printer->info_2->sharename)) != -1) { DEBUG(5, ("_spoolss_addprinterex: Attempted to add a printer named [%s] when one already existed!\n", printer->info_2->sharename)); - free_a_printer(&old_printer, 2); + free_a_printer(&printer, 2); return WERR_PRINTER_ALREADY_EXISTS; } -- cgit From 605248abd9cf207d80811e304a61e0417999ac1c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 30 Nov 2001 03:45:21 +0000 Subject: Check error returns. Jeremy. (This used to be commit fc8638e89effb0ebf2e40cee8cd0d7467e49e2a8) --- source3/rpc_server/srv_spoolss_nt.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3c7948fd7b..7f54867eb4 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -908,15 +908,17 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, static BOOL convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni, NT_PRINTER_INFO_LEVEL *printer, uint32 level) { + BOOL ret = True; + switch (level) { case 2: - uni_2_asc_printer_info_2(uni->info_2, &printer->info_2); + ret = uni_2_asc_printer_info_2(uni->info_2, &printer->info_2); break; default: break; } - return True; + return ret; } static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *uni, @@ -4569,7 +4571,10 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, * just read from the tdb in the pointer 'printer'. */ - convert_printer_info(info, printer, level); + if (!convert_printer_info(info, printer, level)) { + result = WERR_NOMEM; + goto done; + } if (info->info_2->devmode_ptr != 0) { /* we have a valid devmode @@ -5749,7 +5754,10 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ ZERO_STRUCTP(printer); /* convert from UNICODE to ASCII - this allocates the info_2 struct inside *printer.*/ - convert_printer_info(info, printer, 2); + if (!convert_printer_info(info, printer, 2)) { + free_a_printer(&printer, 2); + return WERR_NOMEM; + } /* check to see if the printer already exists */ -- cgit From 9cc8cb5134b0a4ebf5e985f7319ded295f308c90 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Nov 2001 20:33:35 +0000 Subject: merge from APPLIANCE_HEAD (This used to be commit f8b18b25944135c196c8134100f601e84c583382) --- source3/rpc_server/srv_spoolss_nt.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7f54867eb4..1d54c92bce 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6006,10 +6006,6 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S ZERO_STRUCT(printer); - *out_max_value_len=0; - *out_value=NULL; - *out_value_len=0; - *out_type=0; *out_max_data_len=0; @@ -6071,18 +6067,6 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S param_index++; } - /* - * I think this is correct, it doesn't break APW and - * allows Gerald's Win32 test programs to work correctly, - * but may need altering.... JRA. - */ - - if (param_index == 0) { - /* No parameters found. */ - free_a_printer(&printer, 2); - return WERR_NO_MORE_ITEMS; - } - /* the value is an UNICODE string but realvaluesize is the length in bytes including the leading 0 */ *out_value_len=2*(1+biggest_valuesize); *out_data_len=biggest_datasize; @@ -6099,8 +6083,28 @@ WERROR _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); + + /* out_value should default to "" or else NT4 has + problems unmarshalling the response */ + + *out_max_value_len=(in_value_len/sizeof(uint16)); + if((*out_value=(uint16 *)malloc(in_value_len*sizeof(uint8))) == NULL) + return WERR_NOMEM; + + ZERO_STRUCTP(*out_value); + *out_value_len = rpcstr_push((char *)*out_value, "", in_value_len, 0); + + /* the data is counted in bytes */ + *out_max_data_len = in_data_len; + *out_data_len = in_data_len; + if((*data_out=(uint8 *)malloc(in_data_len*sizeof(uint8))) == NULL) + return WERR_NOMEM; + + memset(*data_out,'\0',in_data_len); + return WERR_NO_MORE_ITEMS; } -- cgit From 043dfe985c07dfe1ec87f78ef4de71eeb2ae13af Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Sun, 2 Dec 2001 00:06:10 +0000 Subject: there was a bug in samr_lookup_names (my fault) and added comments and some debugs. J.F. (This used to be commit 114eba496fa020a7f491eb549c91fb38ca34dabb) --- source3/rpc_server/srv_samr_nt.c | 119 +++++++++++++++++++++++++-------------- 1 file changed, 77 insertions(+), 42 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 112b1bb293..f791ba2e34 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -643,6 +643,7 @@ static BOOL get_lsa_policy_samr_sid(pipes_struct *p, POLICY_HND *pol, DOM_SID *s NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_QUERY_SEC_OBJ *r_u) { DOM_SID pol_sid; + fstring str_sid; r_u->status = NT_STATUS_OK; @@ -651,6 +652,8 @@ NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &pol_sid)) return NT_STATUS_INVALID_HANDLE; + DEBUG(10,("_samr_query_sec_obj: querying security on SID: %s\n", sid_to_string(str_sid, &pol_sid))); + r_u->status = samr_make_usr_obj_sd(p->mem_ctx, &r_u->buf, &pol_sid); if (NT_STATUS_IS_OK(r_u->status)) @@ -1302,53 +1305,72 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOKUP_NAMES *r_u) { - uint32 rid[MAX_SAM_ENTRIES]; - enum SID_NAME_USE type[MAX_SAM_ENTRIES]; - int i; - int num_rids = q_u->num_names2; - DOM_SID pol_sid; - - r_u->status = NT_STATUS_OK; - - DEBUG(5,("_samr_lookup_names: %d\n", __LINE__)); - - ZERO_ARRAY(rid); - ZERO_ARRAY(type); + uint32 rid[MAX_SAM_ENTRIES]; + uint32 local_rid; + enum SID_NAME_USE type[MAX_SAM_ENTRIES]; + enum SID_NAME_USE local_type; + int i; + int num_rids = q_u->num_names2; + DOM_SID pol_sid; + fstring sid_str; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid)) { - init_samr_r_lookup_names(p->mem_ctx, r_u, 0, NULL, NULL, NT_STATUS_OBJECT_TYPE_MISMATCH); - return r_u->status; - } + r_u->status = NT_STATUS_OK; - if (num_rids > MAX_SAM_ENTRIES) { - num_rids = MAX_SAM_ENTRIES; - DEBUG(5,("_samr_lookup_names: truncating entries to %d\n", num_rids)); - } + DEBUG(5,("_samr_lookup_names: %d\n", __LINE__)); - for (i = 0; i < num_rids; i++) { - fstring name; + ZERO_ARRAY(rid); + ZERO_ARRAY(type); - r_u->status = NT_STATUS_NONE_MAPPED; + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid)) { + init_samr_r_lookup_names(p->mem_ctx, r_u, 0, NULL, NULL, NT_STATUS_OBJECT_TYPE_MISMATCH); + return r_u->status; + } - rid [i] = 0xffffffff; - type[i] = SID_NAME_UNKNOWN; + if (num_rids > MAX_SAM_ENTRIES) { + num_rids = MAX_SAM_ENTRIES; + DEBUG(5,("_samr_lookup_names: truncating entries to %d\n", num_rids)); + } - rpcstr_pull(name, q_u->uni_name[i].buffer, sizeof(name), q_u->uni_name[i].uni_str_len*2, 0); + DEBUG(5,("_samr_lookup_names: looking name on SID %s\n", sid_to_string(sid_str, &pol_sid))); - if(sid_equal(&pol_sid, &global_sam_sid)) { - DOM_SID sid; - if(local_lookup_name(global_myname, name, &sid, &type[i])) { - sid_split_rid( &sid, &rid[i]); - r_u->status = NT_STATUS_OK; - } - } - } + for (i = 0; i < num_rids; i++) { + fstring name; + DOM_SID sid; + + r_u->status = NT_STATUS_NONE_MAPPED; + + rid [i] = 0xffffffff; + type[i] = SID_NAME_UNKNOWN; + + rpcstr_pull(name, q_u->uni_name[i].buffer, sizeof(name), q_u->uni_name[i].uni_str_len*2, 0); + + /* + * we are only looking for a name + * the SID we get back can be outside + * the scope of the pol_sid + * + * in clear: it prevents to reply to domain\group: yes + * when only builtin\group exists. + * + * a cleaner code is to add the sid of the domain we're looking in + * to the local_lookup_name function. + */ + if(local_lookup_name(global_myname, name, &sid, &local_type)) { + sid_split_rid(&sid, &local_rid); + + if (sid_equal(&sid, &pol_sid)) { + rid[i]=local_rid; + type[i]=local_type; + r_u->status = NT_STATUS_OK; + } + } + } - init_samr_r_lookup_names(p->mem_ctx, r_u, num_rids, rid, (uint32 *)type, r_u->status); + init_samr_r_lookup_names(p->mem_ctx, r_u, num_rids, rid, (uint32 *)type, r_u->status); - DEBUG(5,("_samr_lookup_names: %d\n", __LINE__)); + DEBUG(5,("_samr_lookup_names: %d\n", __LINE__)); - return r_u->status; + return r_u->status; } /******************************************************************* @@ -1992,7 +2014,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ */ DEBUG(10,("checking account %s at pos %d for $ termination\n",account, strlen(account)-1)); - +#if 0 if ((acb_info & ACB_WSTRUST) && (account[strlen(account)-1] == '$')) { pstrcpy(add_script, lp_addmachine_script()); } else if ((!(acb_info & ACB_WSTRUST)) && (account[strlen(account)-1] != '$')) { @@ -2002,6 +2024,19 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ pdb_free_sam(&sam_pass); return NT_STATUS_UNSUCCESSFUL; } +#endif + + /* + * we can't check both the ending $ and the acb_info. + * + * UserManager creates trust accounts (ending in $, + * normal that hidden accounts) with the acb_info equals to ACB_NORMAL. + * JFM, 11/29/2001 + */ + if (account[strlen(account)-1] == '$') + pstrcpy(add_script, lp_addmachine_script()); + else + pstrcpy(add_script, lp_adduser_script()); if(*add_script) { int add_ret; @@ -2709,7 +2744,7 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ if (sid_equal(&alias_sid, &global_sid_Builtin)) { DEBUG(10, ("lookup on Builtin SID (S-1-5-32)\n")); - if(!get_builtin_group_from_sid(als_sid, &map)) + if(!get_local_group_from_sid(als_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; } else { if (sid_equal(&alias_sid, &global_sam_sid)) { @@ -2832,7 +2867,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD } else { if (sid_compare(&alias_sid, &global_sid_Builtin)>0) { DEBUG(10, ("adding member on BUILTIN SID\n")); - if( !get_builtin_group_from_sid(alias_sid, &map)) + if( !get_local_group_from_sid(alias_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; } else @@ -3361,11 +3396,11 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G sid_append_rid(&info->sid, q_u->rid_group); sid_to_string(sid_string, &info->sid); - DEBUG(10, ("Opening SID: %s\n", sid_string)); + DEBUG(10, ("_samr_open_group:Opening SID: %s\n", sid_string)); /* check if that group really exists */ if (!get_domain_group_from_sid(info->sid, &map)) - return NT_STATUS_NO_SUCH_USER; + return NT_STATUS_NO_SUCH_GROUP; free_privilege(&map.priv_set); -- cgit From 633ee99afa1f25fcd16796bedec571471f3617ca Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Sun, 2 Dec 2001 01:45:50 +0000 Subject: added queryuseraliases to rpcclient and some comments to the samr server code, to explain what we should return here. J.F. (This used to be commit 06cb20a46d9d9f8abf0d92ba4cfa4d23187ad715) --- source3/rpc_server/srv_samr_nt.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f791ba2e34..8882b0801a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1849,6 +1849,19 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S struct samr_info *info = NULL; BOOL ret; + /* + * from the SID in the request: + * we should send back the list of DOMAIN GROUPS + * the user is a member of + * + * and only the DOMAIN GROUPS + * no ALIASES !!! neither aliases of the domain + * nor aliases of the builtin SID + * + * JFM, 12/2/2001 + */ + + r_u->status = NT_STATUS_OK; DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__)); @@ -2704,6 +2717,26 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, /* until i see a real useraliases query, we fack one up */ + /* I have seen one, JFM 2/12/2001 */ + /* + * Explanation of what this call does: + * for all the SID given in the request: + * return a list of alias (local groups) + * that have those SID as members. + * + * and that's the alias in the domain specified + * in the policy_handle + * + * if the policy handle is on an incorrect sid + * for example a user's sid + * we should reply NT_STATUS_OBJECT_TYPE_MISMATCH + */ + + + + + + rid[0] = BUILTIN_ALIAS_RID_USERS; init_samr_r_query_useraliases(r_u, num_rids, rid, NT_STATUS_OK); -- cgit From cdf9b42754b7e97faa7fc4eb1ec69e32c0bfd1a0 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 3 Dec 2001 17:14:23 +0000 Subject: added a tdb to store the account policy informations. You can change them with either usermanager->policies->account or from a command prompt on NT/W2K: net accounts /domain we can add a rpc accounts to the net command. As the net_rpc.c is still empty, I did not start. How should I add command to it ? Should I take the rpcclient/cmd_xxx functions and call them from there ? alse changed the SAM_UNK_INFO_3 parser, it's an NTTIME. This one is more for jeremy ;-) J.F. (This used to be commit bc28a8eebd9245ce3004ae4b1a359db51f77bf21) --- source3/rpc_server/srv_samr_nt.c | 255 ++++++++++++++++++++++++++------------- 1 file changed, 168 insertions(+), 87 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 8882b0801a..13340d0a60 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1907,53 +1907,84 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR_R_QUERY_DOMAIN_INFO *r_u) { - SAM_UNK_CTR *ctr; + SAM_UNK_CTR *ctr; + uint32 min_pass_len,pass_hist,flag; + time_t u_expire, u_min_age; + NTTIME nt_expire, nt_min_age; + + time_t u_lock_duration, u_reset_time; + NTTIME nt_lock_duration, nt_reset_time; + uint32 lockout; + + time_t u_logout; + NTTIME nt_logout; + if ((ctr = (SAM_UNK_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL) return NT_STATUS_NO_MEMORY; - ZERO_STRUCTP(ctr); + ZERO_STRUCTP(ctr); - r_u->status = NT_STATUS_OK; + r_u->status = NT_STATUS_OK; - DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); + DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); - /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->domain_pol, NULL)) - return NT_STATUS_INVALID_HANDLE; + /* find the policy handle. open a policy on it. */ + if (!find_policy_by_hnd(p, &q_u->domain_pol, NULL)) + return NT_STATUS_INVALID_HANDLE; - switch (q_u->switch_value) { - case 0x01: - init_unk_info1(&ctr->info.inf1); - break; - case 0x02: + switch (q_u->switch_value) { + case 0x01: + account_policy_get(AP_MIN_PASSWORD_LEN, &min_pass_len); + account_policy_get(AP_PASSWORD_HISTORY, &pass_hist); + account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &flag); + account_policy_get(AP_MAX_PASSWORD_AGE, (int *)&u_expire); + account_policy_get(AP_MIN_PASSWORD_AGE, (int *)&u_min_age); + + unix_to_nt_time_abs(&nt_expire, u_expire); + unix_to_nt_time_abs(&nt_min_age, u_min_age); + + init_unk_info1(&ctr->info.inf1, (uint16)min_pass_len, (uint16)pass_hist, + flag, nt_expire, nt_min_age); + break; + case 0x02: /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL)); - break; - case 0x03: - init_unk_info3(&ctr->info.inf3); - break; - case 0x05: - init_unk_info5(&ctr->info.inf5, global_myname); - break; - case 0x06: - init_unk_info6(&ctr->info.inf6); - break; - case 0x07: - init_unk_info7(&ctr->info.inf7); - break; - case 0x0c: - init_unk_info12(&ctr->info.inf12); - break; - default: - return NT_STATUS_INVALID_INFO_CLASS; - } + init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL)); + break; + case 0x03: + account_policy_get(AP_TIME_TO_LOGOUT, (int *)&u_logout); + unix_to_nt_time_abs(&nt_logout, u_logout); + + init_unk_info3(&ctr->info.inf3, nt_logout); + break; + case 0x05: + init_unk_info5(&ctr->info.inf5, global_myname); + break; + case 0x06: + init_unk_info6(&ctr->info.inf6); + break; + case 0x07: + init_unk_info7(&ctr->info.inf7); + break; + case 0x0c: + account_policy_get(AP_LOCK_ACCOUNT_DURATION, (int *)&u_lock_duration); + account_policy_get(AP_RESET_COUNT_TIME, (int *)&u_reset_time); + account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &lockout); + + unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); + unix_to_nt_time_abs(&nt_reset_time, u_reset_time); + + init_unk_info12(&ctr->info.inf12, nt_lock_duration, nt_reset_time, (uint16)lockout); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + } - init_samr_r_query_dom_info(r_u, q_u->switch_value, ctr, NT_STATUS_OK); + 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__)); + DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); - return r_u->status; + return r_u->status; } /******************************************************************* @@ -3460,53 +3491,83 @@ NTSTATUS _samr_unknown_2d(pipes_struct *p, SAMR_Q_UNKNOWN_2D *q_u, SAMR_R_UNKNOW NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOWN_2E *r_u) { - SAM_UNK_CTR *ctr; + SAM_UNK_CTR *ctr; + uint32 min_pass_len,pass_hist,flag; + time_t u_expire, u_min_age; + NTTIME nt_expire, nt_min_age; + + time_t u_lock_duration, u_reset_time; + NTTIME nt_lock_duration, nt_reset_time; + uint32 lockout; + + time_t u_logout; + NTTIME nt_logout; if ((ctr = (SAM_UNK_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL) return NT_STATUS_NO_MEMORY; - ZERO_STRUCTP(ctr); + ZERO_STRUCTP(ctr); - r_u->status = NT_STATUS_OK; + r_u->status = NT_STATUS_OK; - DEBUG(5,("_samr_unknown_2e: %d\n", __LINE__)); + DEBUG(5,("_samr_unknown_2e: %d\n", __LINE__)); - /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->domain_pol, NULL)) - return NT_STATUS_INVALID_HANDLE; + /* find the policy handle. open a policy on it. */ + if (!find_policy_by_hnd(p, &q_u->domain_pol, NULL)) + return NT_STATUS_INVALID_HANDLE; - switch (q_u->switch_value) { - case 0x01: - init_unk_info1(&ctr->info.inf1); - break; - case 0x02: + switch (q_u->switch_value) { + case 0x01: + account_policy_get(AP_MIN_PASSWORD_LEN, &min_pass_len); + account_policy_get(AP_PASSWORD_HISTORY, &pass_hist); + account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &flag); + account_policy_get(AP_MAX_PASSWORD_AGE, (int *)&u_expire); + account_policy_get(AP_MIN_PASSWORD_AGE, (int *)&u_min_age); + + unix_to_nt_time_abs(&nt_expire, u_expire); + unix_to_nt_time_abs(&nt_min_age, u_min_age); + + init_unk_info1(&ctr->info.inf1, (uint16)min_pass_len, (uint16)pass_hist, + flag, nt_expire, nt_min_age); + break; + case 0x02: /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL)); - break; - case 0x03: - init_unk_info3(&ctr->info.inf3); - break; - case 0x05: - init_unk_info5(&ctr->info.inf5, global_myname); - break; - case 0x06: - init_unk_info6(&ctr->info.inf6); - break; - case 0x07: - init_unk_info7(&ctr->info.inf7); - break; - case 0x0c: - init_unk_info12(&ctr->info.inf12); - break; - default: - return NT_STATUS_INVALID_INFO_CLASS; - } + init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL)); + break; + case 0x03: + account_policy_get(AP_TIME_TO_LOGOUT, (int *)&u_logout); + unix_to_nt_time_abs(&nt_logout, u_logout); + + init_unk_info3(&ctr->info.inf3, nt_logout); + break; + case 0x05: + init_unk_info5(&ctr->info.inf5, global_myname); + break; + case 0x06: + init_unk_info6(&ctr->info.inf6); + break; + case 0x07: + init_unk_info7(&ctr->info.inf7); + break; + case 0x0c: + account_policy_get(AP_LOCK_ACCOUNT_DURATION, (int *)&u_lock_duration); + account_policy_get(AP_RESET_COUNT_TIME, (int *)&u_reset_time); + account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &lockout); + + unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); + unix_to_nt_time_abs(&nt_reset_time, u_reset_time); + + init_unk_info12(&ctr->info.inf12, nt_lock_duration, nt_reset_time, (uint16)lockout); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; + } - init_samr_r_samr_unknown_2e(r_u, q_u->switch_value, ctr, NT_STATUS_OK); + init_samr_r_samr_unknown_2e(r_u, q_u->switch_value, ctr, NT_STATUS_OK); - DEBUG(5,("_samr_unknown_2e: %d\n", __LINE__)); + DEBUG(5,("_samr_unknown_2e: %d\n", __LINE__)); - return r_u->status; + return r_u->status; } /******************************************************************* @@ -3515,6 +3576,10 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R_SET_DOMAIN_INFO *r_u) { + time_t u_expire, u_min_age; + time_t u_logout; + time_t u_lock_duration, u_reset_time; + r_u->status = NT_STATUS_OK; DEBUG(5,("_samr_set_dom_info: %d\n", __LINE__)); @@ -3523,25 +3588,41 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R if (!find_policy_by_hnd(p, &q_u->domain_pol, NULL)) return NT_STATUS_INVALID_HANDLE; - DEBUG(0,("_samr_set_dom_info: switch_value: %d\n", q_u->switch_value)); + DEBUG(5,("_samr_set_dom_info: switch_value: %d\n", q_u->switch_value)); switch (q_u->switch_value) { - case 0x01: - break; - case 0x02: - break; - case 0x03: - break; - case 0x05: - break; - case 0x06: - break; - case 0x07: - break; - case 0x0c: - break; - default: - return NT_STATUS_INVALID_INFO_CLASS; + case 0x01: + u_expire=nt_time_to_unix_abs(&q_u->ctr->info.inf1.expire); + u_min_age=nt_time_to_unix_abs(&q_u->ctr->info.inf1.min_passwordage); + + account_policy_set(AP_MIN_PASSWORD_LEN, (uint32)q_u->ctr->info.inf1.min_length_password); + account_policy_set(AP_PASSWORD_HISTORY, (uint32)q_u->ctr->info.inf1.password_history); + account_policy_set(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)q_u->ctr->info.inf1.flag); + account_policy_set(AP_MAX_PASSWORD_AGE, (int)u_expire); + account_policy_set(AP_MIN_PASSWORD_AGE, (int)u_min_age); + break; + case 0x02: + break; + case 0x03: + u_logout=nt_time_to_unix_abs(&q_u->ctr->info.inf3.logout); + account_policy_set(AP_TIME_TO_LOGOUT, (int)u_logout); + break; + case 0x05: + break; + case 0x06: + break; + case 0x07: + break; + case 0x0c: + u_lock_duration=nt_time_to_unix_abs(&q_u->ctr->info.inf12.duration); + u_reset_time=nt_time_to_unix_abs(&q_u->ctr->info.inf12.reset_count); + + account_policy_set(AP_LOCK_ACCOUNT_DURATION, (int)u_lock_duration); + account_policy_set(AP_RESET_COUNT_TIME, (int)u_reset_time); + account_policy_set(AP_BAD_ATTEMPT_LOCKOUT, (uint32)q_u->ctr->info.inf12.bad_attempt_lockout); + break; + default: + return NT_STATUS_INVALID_INFO_CLASS; } init_samr_r_set_domain_info(r_u, NT_STATUS_OK); -- cgit From 922eb763d7365716fd3c20aa069746fc9bfb8ab3 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 4 Dec 2001 21:53:47 +0000 Subject: added a boolean to the group mapping functions to specify if we need or not the privileges. Usually we don't need them, so the memory is free early. lib/util_sid.c: added some helper functions to check an SID. passdb/passdb.c: renamed local_lookup_rid() to local_lookup_sid() and pass an RID all the way. If the group doesn't exist on the domain SID, don't return a faked one as it can collide with a builtin one. Some rpc structures have been badly designed, they return only rids and force the client to do subsequent lsa_lookup_sid() on the domain sid and the builtin sid ! rpc_server/srv_util.c: wrote a new version of get_domain_user_groups(). Only the samr code uses it atm. It uses the group mapping code instead of a bloody hard coded crap. The netlogon code will use it too, but I have to do some test first. J.F. (This used to be commit 6c87e96149101995b7d049657d5c26eefef37d8c) --- source3/rpc_server/srv_lsa_nt.c | 14 +++-- source3/rpc_server/srv_samr_nt.c | 124 +++++++++++++-------------------------- source3/rpc_server/srv_util.c | 77 ++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 90 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index b16e3836f6..da5597132d 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -622,7 +622,7 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU return NT_STATUS_INVALID_HANDLE; /* get the list of mapped groups (domain, local, builtin) */ - if(!enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED)) + if(!enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) return NT_STATUS_OK; if (q_u->enum_context >= num_entries) @@ -727,7 +727,7 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LS if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map)) + if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; DEBUG(10,("_lsa_enum_privsaccount: %d privileges\n", map.priv_set.count)); @@ -768,7 +768,7 @@ NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map)) + if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_GROUP; /* @@ -799,7 +799,7 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map)) + if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; map.systemaccount=q_u->access; @@ -807,6 +807,8 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA if(!add_mapping_entry(&map, TDB_REPLACE)) return NT_STATUS_NO_SUCH_GROUP; + free_privilege(&map.priv_set); + return r_u->status; } @@ -829,7 +831,7 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map)) + if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; set=&q_u->set; @@ -873,7 +875,7 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map)) + if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; if (q_u->allrights!=0) { diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 13340d0a60..cc81bac630 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -539,16 +539,6 @@ NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN return r_u->status; } -static uint32 get_lsa_policy_samr_rid(struct samr_info *info) -{ - if (!info) { - DEBUG(3,("Error getting policy\n")); - return 0xffffffff; - } - - return info->sid.sub_auths[info->sid.num_auths-1]; -} - /******************************************************************* _samr_get_usrdom_pwinfo ********************************************************************/ @@ -560,14 +550,11 @@ NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, 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)) { + if (!find_policy_by_hnd(p, &q_u->user_pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - } - /* find the user's rid */ - if (get_lsa_policy_samr_rid(info) == 0xffffffff) { + if (!sid_check_is_in_our_domain(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - } init_samr_r_get_usrdom_pwinfo(r_u, NT_STATUS_OK); @@ -813,12 +800,9 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM /* well-known aliases */ if (sid_equal(sid, &global_sid_Builtin) && !lp_hide_local_users()) { - enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ONLY_MAPPED); - - if (num_entries != 0) { - for (i=0; inext) { uint32 trid; - if(!get_group_from_gid(grp->gr_gid, &smap)) { + if(!get_group_from_gid(grp->gr_gid, &smap, MAPPING_WITHOUT_PRIV)) continue; - } - - /* - * free early the privilege struct as it's not used - * and prevent leaking mem. - */ - free_privilege(&smap.priv_set); if (smap.sid_name_use!=SID_NAME_ALIAS) { continue; } sid_split_rid(&smap.sid, &trid); + + if (!sid_equal(sid, &smap.sid)) + continue; /* Don't return winbind groups as they are not local! */ if (strchr_m(smap.nt_name, *sep) != NULL) { @@ -937,14 +917,7 @@ static NTSTATUS get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DO *p_num_entries = 0; - enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED); - - /* - * free early the privilege struct as it's not used - * and prevent leaking mem. - */ - for (i=0; istatus = NT_STATUS_OK; @@ -1217,11 +1189,11 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - alias_rid = get_lsa_policy_samr_rid(info); - if(alias_rid == 0xffffffff) - return NT_STATUS_NO_SUCH_ALIAS; + if (!sid_check_is_in_our_domain(&info->sid) && + !sid_check_is_in_builtin(&info->sid)) + return NT_STATUS_OBJECT_TYPE_MISMATCH; - if(!local_lookup_rid(alias_rid, alias, &type)) + if(!local_lookup_sid(&info->sid, alias, &type)) return NT_STATUS_NO_SUCH_ALIAS; switch (q_u->switch_level) { @@ -1748,10 +1720,11 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ 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) + if (!sid_check_is_in_our_domain(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; + sid_peek_rid(&info->sid, &rid); + DEBUG(5,("_samr_query_userinfo: rid:0x%x\n", rid)); ctr = (SAM_USERINFO_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_USERINFO_CTR)); @@ -1861,7 +1834,6 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S * JFM, 12/2/2001 */ - r_u->status = NT_STATUS_OK; DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__)); @@ -1870,10 +1842,11 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S 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) + if (!sid_check_is_in_our_domain(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; + sid_peek_rid(&info->sid, &rid); + pdb_init_sam(&sam_pass); become_root(); @@ -1885,11 +1858,10 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S return NT_STATUS_NO_SUCH_USER; } - *groups = 0; - - get_domain_user_groups(groups, pdb_get_username(sam_pass)); - gids = NULL; - num_groups = make_dom_gids(p->mem_ctx, groups, &gids); + if(!new_get_domain_user_groups(p->mem_ctx, &num_groups, &gids, sam_pass)) { + samr_clear_sam_passwd(sam_pass); + return NT_STATUS_NO_SUCH_GROUP; + } /* construct the response. lkclXXXX: gids are not copied! */ init_samr_r_query_usergroups(r_u, num_groups, gids, r_u->status); @@ -2304,12 +2276,12 @@ NTSTATUS _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OP * JFM. */ - /* 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; + /* 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; - ZERO_STRUCTP(info); - info->sid = sid; + ZERO_STRUCTP(info); + info->sid = sid; /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, alias_pol, free_samr_info, (void *)info)) @@ -2808,18 +2780,16 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ if (sid_equal(&alias_sid, &global_sid_Builtin)) { DEBUG(10, ("lookup on Builtin SID (S-1-5-32)\n")); - if(!get_local_group_from_sid(als_sid, &map)) + if(!get_local_group_from_sid(als_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; } else { if (sid_equal(&alias_sid, &global_sam_sid)) { DEBUG(10, ("lookup on Server SID\n")); - if(!get_local_group_from_sid(als_sid, &map)) + if(!get_local_group_from_sid(als_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; } } - free_privilege(&map.priv_set); - if(!get_uid_list_of_group(map.gid, &uid, &num_uids)) return NT_STATUS_NO_SUCH_ALIAS; @@ -2877,11 +2847,9 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ sid_append_rid(&group_sid, group_rid); DEBUG(10, ("lookup on Domain SID\n")); - if(!get_domain_group_from_sid(group_sid, &map)) + if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_GROUP; - free_privilege(&map.priv_set); - if(!get_uid_list_of_group(map.gid, &uid, &num_uids)) return NT_STATUS_NO_SUCH_GROUP; @@ -2925,21 +2893,19 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD if (sid_compare(&alias_sid, &global_sam_sid)>0) { DEBUG(10, ("adding member on Server SID\n")); - if(!get_local_group_from_sid(alias_sid, &map)) + if(!get_local_group_from_sid(alias_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; } else { if (sid_compare(&alias_sid, &global_sid_Builtin)>0) { DEBUG(10, ("adding member on BUILTIN SID\n")); - if( !get_local_group_from_sid(alias_sid, &map)) + if( !get_local_group_from_sid(alias_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; } else return NT_STATUS_NO_SUCH_ALIAS; } - free_privilege(&map.priv_set); - sid_split_rid(&q_u->sid.sid, &rid); uid=pdb_user_rid_to_uid(rid); @@ -3004,11 +2970,9 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD DEBUG(10, ("lookup on Domain SID\n")); - if(!get_domain_group_from_sid(group_sid, &map)) + if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_GROUP; - free_privilege(&map.priv_set); - if ((pwd=getpwuid(pdb_user_rid_to_uid(q_u->rid))) ==NULL) return NT_STATUS_NO_SUCH_USER; @@ -3089,11 +3053,9 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S DEBUG(10, ("lookup on Domain SID\n")); - if(!get_domain_group_from_sid(group_sid, &map)) + if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; - free_privilege(&map.priv_set); - gid=map.gid; /* check if group really exists */ @@ -3148,11 +3110,9 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S DEBUG(10, ("lookup on Local SID\n")); - if(!get_local_group_from_sid(alias_sid, &map)) + if(!get_local_group_from_sid(alias_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; - free_privilege(&map.priv_set); - gid=map.gid; /* check if group really exists */ @@ -3312,11 +3272,9 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) return NT_STATUS_INVALID_HANDLE; - if (!get_domain_group_from_sid(group_sid, &map)) + if (!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_INVALID_HANDLE; - free_privilege(&map.priv_set); - ctr=(GROUP_INFO_CTR *)talloc_zero(p->mem_ctx, sizeof(GROUP_INFO_CTR)); if (ctr==NULL) return NT_STATUS_NO_MEMORY; @@ -3357,7 +3315,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) return NT_STATUS_INVALID_HANDLE; - if (!get_domain_group_from_sid(group_sid, &map)) + if (!get_domain_group_from_sid(group_sid, &map, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; ctr=q_u->ctr; @@ -3399,7 +3357,7 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid)) return NT_STATUS_INVALID_HANDLE; - if (!get_local_group_from_sid(group_sid, &map)) + if (!get_local_group_from_sid(group_sid, &map, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; ctr=&q_u->ctr; @@ -3463,11 +3421,9 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G DEBUG(10, ("_samr_open_group:Opening SID: %s\n", sid_string)); /* check if that group really exists */ - if (!get_domain_group_from_sid(info->sid, &map)) + if (!get_domain_group_from_sid(info->sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_GROUP; - free_privilege(&map.priv_set); - /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, &r_u->pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 40831cbad7..70ee377e2c 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -150,6 +150,83 @@ int make_dom_gids(TALLOC_CTX *ctx, char *gids_str, DOM_GID **ppgids) return count; } +/******************************************************************* + gets a domain user's groups + ********************************************************************/ +BOOL new_get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids, SAM_ACCOUNT *sam_pass) +{ + GROUP_MAP *map=NULL; + int i, num, num_entries, cur_gid=0; + struct group *grp; + DOM_GID *gids; + fstring user_name; + uint32 grid; + uint32 tmp_rid; + + fstrcpy(user_name, pdb_get_username(sam_pass)); + grid=pdb_get_group_rid(sam_pass); + + DEBUG(10,("new_get_domain_user_groups: searching domain groups [%s] is a member of\n", user_name)); + + /* first get the list of the domain groups */ + if (!enum_group_mapping(SID_NAME_DOM_GRP, &map, &num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) + return False; + DEBUG(10,("new_get_domain_user_groups: there are %d mapped groups\n", num_entries)); + + + /* + * alloc memory. In the worse case, we alloc memory for nothing. + * but I prefer to alloc for nothing + * than reallocing everytime. + */ + gids = (DOM_GID *)talloc(ctx, sizeof(DOM_GID) * num_entries); + + /* for each group, check if the user is a member of*/ + for(i=0; igr_mem[num]!=NULL; num++) { + if(strcmp(grp->gr_mem[num], user_name)==0) { + /* we found the user, add the group to the list */ + sid_peek_rid(&map[i].sid, &(gids[cur_gid].g_rid)); + gids[cur_gid].attr=map[i].sid_name_use; + DEBUG(10,("new_get_domain_user_groups: user found in group %s\n", map[i].nt_name)); + cur_gid++; + break; + } + } + } + + /* we have checked the groups */ + /* we must now check the gid of the user or the primary group rid, that's the same */ + for (i=0; i Date: Wed, 5 Dec 2001 00:54:33 +0000 Subject: Improved efficiency of enumerating print queue's under a particular extreme condition... Jeremy. (This used to be commit 425bb0f40526b4eb17a3033892ca907b1d5293a4) --- source3/rpc_server/srv_spoolss_nt.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1d54c92bce..d49cee0d25 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1835,14 +1835,12 @@ static void spoolss_notify_status(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - print_queue_struct *q=NULL; print_status_struct status; memset(&status, 0, sizeof(status)); - print_queue_status(snum, &q, &status); + print_queue_length(snum, &status); data->notify_data.value[0]=(uint32) status.status; data->notify_data.value[1] = 0; - SAFE_FREE(q); } /******************************************************************* @@ -1854,13 +1852,8 @@ static void spoolss_notify_cjobs(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - print_queue_struct *q=NULL; - print_status_struct status; - - memset(&status, 0, sizeof(status)); - data->notify_data.value[0] = print_queue_status(snum, &q, &status); + data->notify_data.value[0] = print_queue_length(snum, NULL); data->notify_data.value[1] = 0; - SAFE_FREE(q); } /******************************************************************* -- cgit From 105f8a1a0fcce360c427a69fd4201c625cedc7d8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 5 Dec 2001 02:11:03 +0000 Subject: Use print_queue_length() by preference if we don't need a queue as it doesn't do a traversal. Jeremy. (This used to be commit 4bf4ee3f14a690592fa2e1b800fc0344522e6b30) --- source3/rpc_server/srv_spoolss_nt.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d49cee0d25..0e98498fe3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1837,7 +1837,6 @@ static void spoolss_notify_status(int snum, { print_status_struct status; - memset(&status, 0, sizeof(status)); print_queue_length(snum, &status); data->notify_data.value[0]=(uint32) status.status; data->notify_data.value[1] = 0; @@ -2428,7 +2427,6 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY case JOB_NOTIFY_TYPE: { NT_PRINTER_INFO_LEVEL *printer = NULL; - memset(&status, 0, sizeof(status)); count = print_queue_status(snum, &queue, &status); if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, @@ -2534,16 +2532,12 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) uint32 global_counter; struct tm *t; time_t setuptime; - - print_queue_struct *queue=NULL; print_status_struct status; - memset(&status, 0, sizeof(status)); - if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) return False; - count = print_queue_status(snum, &queue, &status); + count = print_queue_length(snum, &status); /* check if we already have a counter for this printer */ session_counter = (counter_printer_0 *)ubi_dlFirst(&counter_list); @@ -2625,7 +2619,6 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) printer->unknown28 = 0; printer->unknown29 = 0; - SAFE_FREE(queue); free_a_printer(&ntprinter,2); return (True); } @@ -2774,15 +2767,12 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum) int count; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; - print_queue_struct *queue=NULL; print_status_struct status; - memset(&status, 0, sizeof(status)); if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) return False; - memset(&status, 0, sizeof(status)); - count = print_queue_status(snum, &queue, &status); + count = print_queue_length(snum, &status); init_unistr(&printer->servername, ntprinter->info_2->servername); /* servername*/ init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/ @@ -2827,7 +2817,6 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum) } free_a_printer(&ntprinter, 2); - SAFE_FREE(queue); return True; } @@ -4900,8 +4889,8 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO uint32 *returned = &r_u->returned; int snum; - print_queue_struct *queue=NULL; print_status_struct prt_status; + print_queue_struct *queue=NULL; /* that's an [in out] buffer */ spoolss_move_buffer(q_u->buffer, &r_u->buffer); @@ -4909,8 +4898,6 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO DEBUG(4,("_spoolss_enumjobs\n")); - ZERO_STRUCT(prt_status); - *needed=0; *returned=0; @@ -4957,12 +4944,9 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u uint32 command = q_u->command; struct current_user user; - print_status_struct prt_status; int snum; WERROR errcode = WERR_BADFUNC; - memset(&prt_status, 0, sizeof(prt_status)); - if (!get_printer_snum(p, handle, &snum)) { return WERR_BADFID; } @@ -6751,8 +6735,6 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ DEBUG(5,("spoolss_getjob\n")); - memset(&prt_status, 0, sizeof(prt_status)); - *needed=0; if (!get_printer_snum(p, handle, &snum)) -- cgit From 95a21460b788775ac81adb7acdf82c92aa5c5525 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 5 Dec 2001 11:32:25 +0000 Subject: fixed a return value (This used to be commit 56bdb152d8617c0a36c0bc25c677a2d98bcb1328) --- source3/rpc_server/srv_util.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 70ee377e2c..497771dcab 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -226,6 +226,7 @@ BOOL new_get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids *pgids=gids; *numgroups=cur_gid; safe_free(map); + return True; } /******************************************************************* -- cgit From 7b53a92f59984211e5ceb731163efa6e767e55a3 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Wed, 5 Dec 2001 15:41:44 +0000 Subject: added samr_queryuseralias(). instead of returning BUILTIN_ALIAS_RID_USERS, now return the alias correctly. time to look at the netlogon case. J.F. (This used to be commit 72ee1791084d09e73d8057e37ced4a79cecffb35) --- source3/rpc_server/srv_samr_nt.c | 64 ++++++++++---- source3/rpc_server/srv_util.c | 180 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 228 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index cc81bac630..5e19fd1e7c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1817,7 +1817,6 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S SAM_ACCOUNT *sam_pass=NULL; DOM_GID *gids = NULL; int num_groups = 0; - pstring groups; uint32 rid; struct samr_info *info = NULL; BOOL ret; @@ -2710,14 +2709,10 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, SAMR_R_QUERY_USERALIASES *r_u) { - 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; - + int num_groups = 0, tmp_num_groups=0; + uint32 *rids=NULL, *new_rids=NULL, *tmp_rids=NULL; + struct samr_info *info = NULL; + int i,j; /* until i see a real useraliases query, we fack one up */ /* I have seen one, JFM 2/12/2001 */ @@ -2735,17 +2730,54 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, * we should reply NT_STATUS_OBJECT_TYPE_MISMATCH */ - - - - + r_u->status = NT_STATUS_OK; - rid[0] = BUILTIN_ALIAS_RID_USERS; + DEBUG(5,("_samr_query_useraliases: %d\n", __LINE__)); - init_samr_r_query_useraliases(r_u, num_rids, rid, NT_STATUS_OK); + /* 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; - return NT_STATUS_OK; + if (!sid_check_is_domain(&info->sid) && + !sid_check_is_builtin(&info->sid)) + return NT_STATUS_OBJECT_TYPE_MISMATCH; + + + for (i=0; inum_sids1; i++) { + + r_u->status=new_get_alias_user_groups(p->mem_ctx, &info->sid, &tmp_num_groups, &tmp_rids, &(q_u->sid[i].sid)); + /* + * if there is an error, we just continue as + * it can be an unfound user or group + */ + if (NT_STATUS_IS_ERR(r_u->status)) { + DEBUG(10,("_samr_query_useraliases: an error occured while getting groups\n")); + continue; + } + + if (tmp_num_groups==0) { + DEBUG(10,("_samr_query_useraliases: no groups found\n")); + continue; + } + + new_rids=(uint32 *)talloc_realloc(p->mem_ctx, rids, (num_groups+tmp_num_groups)*sizeof(uint32)); + if (new_rids==NULL) { + DEBUG(0,("_samr_query_useraliases: could not realloc memory\n")); + return NT_STATUS_NO_MEMORY; + } + rids=new_rids; + + for (j=0; jnext) { + if(!get_group_from_gid(grp->gr_gid, &map, MAPPING_WITHOUT_PRIV)) { + DEBUG(10,("new_get_alias_user_groups: gid %d. not found\n", (int)grp->gr_gid)); + continue; + } + + /* if it's not an alias, continue */ + if (map.sid_name_use!=SID_NAME_ALIAS) { + DEBUG(10,("new_get_alias_user_groups: not returing %s, not an ALIAS group.\n", map.nt_name)); + continue; + } + + sid_copy(&tmp_sid, &map.sid); + sid_split_rid(&tmp_sid, &rid); + + /* if the sid is not in the correct domain, continue */ + if (!sid_equal(&tmp_sid, sid)) { + DEBUG(10,("new_get_alias_user_groups: not returing %s, not in the domain SID.\n", map.nt_name)); + continue; + } + + /* Don't return winbind groups as they are not local! */ + if (strchr_m(map.nt_name, *sep) != NULL) { + DEBUG(10,("new_get_alias_user_groups: not returing %s, not local.\n", map.nt_name)); + continue; + } + + /* Don't return user private groups... */ + if (Get_Pwnam(map.nt_name) != 0) { + DEBUG(10,("new_get_alias_user_groups: not returing %s, clashes with user.\n", map.nt_name)); + continue; + } + + /* the group is fine, we can check if there is the user we're looking for */ + DEBUG(10,("new_get_alias_user_groups: checking if the user is a member of %s.\n", map.nt_name)); + + for(num=0; grp->gr_mem[num]!=NULL; num++) { + if(strcmp(grp->gr_mem[num], user_name)==0) { + /* we found the user, add the group to the list */ + + new_rids=(uint32 *)Realloc(rids, sizeof(uint32)*(cur_rid+1)); + if (new_rids==NULL) { + DEBUG(10,("new_get_alias_user_groups: could not realloc memory\n")); + return NT_STATUS_NO_MEMORY; + } + rids=new_rids; + + sid_peek_rid(&map.sid, &(rids[cur_rid])); + DEBUG(10,("new_get_alias_user_groups: user found in group %s\n", map.nt_name)); + cur_rid++; + break; + } + } + + } + + grent_free(glist); + + /* now check for the user's gid (the primary group rid) */ + for (i=0; i Date: Thu, 6 Dec 2001 13:09:15 +0000 Subject: again an intrusive patch: - removed the ugly as hell sam_logon_in_ssb variable, I changed a bit the definition of standard_sub_basic() to cope with that. - removed the smb.conf: 'domain admin group' and 'domain guest group' parameters ! We're not playing anymore with the user's group RIDs ! - in get_domain_user_groups(), if the user's gid is a group, put it first in the group RID list. I just have to write an HOWTO now ;-) J.F. (This used to be commit fef52c4b96c987115fb1818c00c2352c67790e50) --- source3/rpc_server/srv_netlog_nt.c | 22 +--- source3/rpc_server/srv_samr_nt.c | 7 +- source3/rpc_server/srv_util.c | 208 +++++++++++-------------------------- 3 files changed, 67 insertions(+), 170 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 5f85d4db9c..d15175d4ae 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -27,8 +27,6 @@ #include "includes.h" -extern BOOL sam_logon_in_ssb; -extern pstring samlogon_user; extern pstring global_myname; extern DOM_SID global_sam_sid; @@ -642,16 +640,10 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * int num_gids = 0; pstring my_name; pstring my_workgroup; - pstring domain_groups; /* set up pointer indicating user/password failed to be found */ usr_info->ptr_user_info = 0; - /* XXXX hack to get standard_sub_basic() to use sam logon username */ - /* possibly a better way would be to do a change_to_user() call */ - sam_logon_in_ssb = True; - pstrcpy(samlogon_user, nt_username); - pstrcpy(my_workgroup, lp_workgroup()); pstrcpy(my_name, global_myname); strupper(my_name); @@ -664,17 +656,8 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * * JRA. */ - *domain_groups = 0; - - get_domain_user_groups(domain_groups, nt_username); - - /* - * make_dom_gids allocates the gids array. JRA. - */ - gids = NULL; - num_gids = make_dom_gids(p->mem_ctx, domain_groups, &gids); - - sam_logon_in_ssb = False; + gids = NULL; + get_domain_user_groups(p->mem_ctx, &num_gids, &gids, server_info->sam_account); init_net_user_info3(p->mem_ctx, usr_info, server_info->sam_account, 0, /* logon_count */ @@ -687,6 +670,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * my_workgroup, /* char *logon_dom */ &global_sam_sid, /* DOM_SID *dom_sid */ NULL); /* char *other_sids */ + } free_server_info(&server_info); return status; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 5e19fd1e7c..853a130859 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1854,11 +1854,13 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S if (ret == False) { samr_clear_sam_passwd(sam_pass); + pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } - if(!new_get_domain_user_groups(p->mem_ctx, &num_groups, &gids, sam_pass)) { + if(!get_domain_user_groups(p->mem_ctx, &num_groups, &gids, sam_pass)) { samr_clear_sam_passwd(sam_pass); + pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_GROUP; } @@ -1868,6 +1870,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__)); samr_clear_sam_passwd(sam_pass); + pdb_free_sam(&sam_pass); return r_u->status; } @@ -2745,7 +2748,7 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, for (i=0; inum_sids1; i++) { - r_u->status=new_get_alias_user_groups(p->mem_ctx, &info->sid, &tmp_num_groups, &tmp_rids, &(q_u->sid[i].sid)); + r_u->status=get_alias_user_groups(p->mem_ctx, &info->sid, &tmp_num_groups, &tmp_rids, &(q_u->sid[i].sid)); /* * if there is an error, we just continue as diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 80090cf6e0..5c781c20ae 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -76,84 +76,10 @@ rid_name domain_group_rids[] = { 0 , NULL } }; -int make_dom_gids(TALLOC_CTX *ctx, char *gids_str, DOM_GID **ppgids) -{ - char *ptr; - pstring s2; - int count; - DOM_GID *gids; - - *ppgids = NULL; - - DEBUG(4,("make_dom_gids: %s\n", gids_str)); - - if (gids_str == NULL || *gids_str == 0) - return 0; - - for (count = 0, ptr = gids_str; - next_token(&ptr, s2, NULL, sizeof(s2)); - count++) - ; - - gids = (DOM_GID *)talloc(ctx, sizeof(DOM_GID) * count ); - if(!gids) - { - DEBUG(0,("make_dom_gids: talloc fail !\n")); - return 0; - } - - for (count = 0, ptr = gids_str; - next_token(&ptr, s2, NULL, sizeof(s2)) && - count < LSA_MAX_GROUPS; - count++) - { - /* the entries are of the form GID/ATTR, ATTR being optional.*/ - char *attr; - uint32 rid = 0; - int i; - - attr = strchr_m(s2,'/'); - if (attr) - *attr++ = 0; - - if (!attr || !*attr) - attr = "7"; /* default value for attribute is 7 */ - - /* look up the RID string and see if we can turn it into a rid number */ - for (i = 0; builtin_alias_rids[i].name != NULL; i++) - { - if (strequal(builtin_alias_rids[i].name, s2)) - { - rid = builtin_alias_rids[i].rid; - break; - } - } - - if (rid == 0) - rid = atoi(s2); - - if (rid == 0) - { - DEBUG(1,("make_dom_gids: unknown well-known alias RID %s/%s\n", s2, attr)); - count--; - } - else - { - gids[count].g_rid = rid; - gids[count].attr = atoi(attr); - - DEBUG(5,("group id: %d attr: %d\n", gids[count].g_rid, gids[count].attr)); - } - } - - *ppgids = gids; - return count; -} - /******************************************************************* gets a domain user's groups ********************************************************************/ -NTSTATUS new_get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, uint32 **prids, DOM_SID *q_sid) +NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, uint32 **prids, DOM_SID *q_sid) { SAM_ACCOUNT *sam_pass=NULL; char *sep; @@ -186,7 +112,7 @@ NTSTATUS new_get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups sep = lp_winbind_separator(); - DEBUG(10,("new_get_alias_user_groups: looking if SID %s is a member of groups in the SID domain %s\n", + DEBUG(10,("get_alias_user_groups: looking if SID %s is a member of groups in the SID domain %s\n", sid_to_string(str_qsid, q_sid), sid_to_string(str_domsid, sid))); sid_peek_rid(q_sid, &rid); @@ -195,27 +121,30 @@ NTSTATUS new_get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups become_root(); ret = pdb_getsampwrid(sam_pass, rid); unbecome_root(); - if (ret == False) + if (ret == False) { + pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; + } fstrcpy(user_name, pdb_get_username(sam_pass)); grid=pdb_get_group_rid(sam_pass); gid=pdb_get_gid(sam_pass); grp = glist = getgrent_list(); - if (grp == NULL) + if (grp == NULL) { + pdb_free_sam(&sam_pass); return NT_STATUS_NO_MEMORY; - + } for (; grp != NULL; grp = grp->next) { if(!get_group_from_gid(grp->gr_gid, &map, MAPPING_WITHOUT_PRIV)) { - DEBUG(10,("new_get_alias_user_groups: gid %d. not found\n", (int)grp->gr_gid)); + DEBUG(10,("get_alias_user_groups: gid %d. not found\n", (int)grp->gr_gid)); continue; } /* if it's not an alias, continue */ if (map.sid_name_use!=SID_NAME_ALIAS) { - DEBUG(10,("new_get_alias_user_groups: not returing %s, not an ALIAS group.\n", map.nt_name)); + DEBUG(10,("get_alias_user_groups: not returing %s, not an ALIAS group.\n", map.nt_name)); continue; } @@ -224,24 +153,24 @@ NTSTATUS new_get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups /* if the sid is not in the correct domain, continue */ if (!sid_equal(&tmp_sid, sid)) { - DEBUG(10,("new_get_alias_user_groups: not returing %s, not in the domain SID.\n", map.nt_name)); + DEBUG(10,("get_alias_user_groups: not returing %s, not in the domain SID.\n", map.nt_name)); continue; } /* Don't return winbind groups as they are not local! */ if (strchr_m(map.nt_name, *sep) != NULL) { - DEBUG(10,("new_get_alias_user_groups: not returing %s, not local.\n", map.nt_name)); + DEBUG(10,("get_alias_user_groups: not returing %s, not local.\n", map.nt_name)); continue; } /* Don't return user private groups... */ if (Get_Pwnam(map.nt_name) != 0) { - DEBUG(10,("new_get_alias_user_groups: not returing %s, clashes with user.\n", map.nt_name)); + DEBUG(10,("get_alias_user_groups: not returing %s, clashes with user.\n", map.nt_name)); continue; } /* the group is fine, we can check if there is the user we're looking for */ - DEBUG(10,("new_get_alias_user_groups: checking if the user is a member of %s.\n", map.nt_name)); + DEBUG(10,("get_alias_user_groups: checking if the user is a member of %s.\n", map.nt_name)); for(num=0; grp->gr_mem[num]!=NULL; num++) { if(strcmp(grp->gr_mem[num], user_name)==0) { @@ -249,69 +178,70 @@ NTSTATUS new_get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups new_rids=(uint32 *)Realloc(rids, sizeof(uint32)*(cur_rid+1)); if (new_rids==NULL) { - DEBUG(10,("new_get_alias_user_groups: could not realloc memory\n")); + DEBUG(10,("get_alias_user_groups: could not realloc memory\n")); + pdb_free_sam(&sam_pass); return NT_STATUS_NO_MEMORY; } rids=new_rids; sid_peek_rid(&map.sid, &(rids[cur_rid])); - DEBUG(10,("new_get_alias_user_groups: user found in group %s\n", map.nt_name)); + DEBUG(10,("get_alias_user_groups: user found in group %s\n", map.nt_name)); cur_rid++; break; } } - } - + grent_free(glist); - + /* now check for the user's gid (the primary group rid) */ for (i=0; igr_mem[num], user_name)==0) { /* we found the user, add the group to the list */ sid_peek_rid(&map[i].sid, &(gids[cur_gid].g_rid)); - gids[cur_gid].attr=map[i].sid_name_use; - DEBUG(10,("new_get_domain_user_groups: user found in group %s\n", map[i].nt_name)); + gids[cur_gid].attr=7; + DEBUG(10,("get_domain_user_groups: user found in group %s\n", map[i].nt_name)); cur_gid++; break; } @@ -387,62 +317,42 @@ BOOL new_get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids /* the user's gid is already there */ if (i!=cur_gid) { + /* + * the primary group of the user but be the first one in the list + * don't ask ! JFM. + */ + gids[i].g_rid=gids[0].g_rid; + gids[0].g_rid=grid; goto done; } for(i=0; i Date: Sat, 8 Dec 2001 23:56:58 +0000 Subject: Fix domain logon that I broke 3 days ago. And it's in sync with the docs, %U is really replaced by the name the user asked. Whereas in 2.2 that's false, %U is replaced by the name the user was mapped to. J.F. (This used to be commit 39f2b23347011acabe9dd3ab15025022da352b74) --- source3/rpc_server/srv_netlog_nt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index d15175d4ae..8092488652 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -499,6 +499,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * fstring nt_username, nt_domain, nt_workstation; auth_usersupplied_info *user_info = NULL; auth_serversupplied_info *server_info = NULL; + extern userdom_struct current_user_info; usr_info = (NET_USER_INFO_3 *)talloc(p->mem_ctx, sizeof(NET_USER_INFO_3)); if (!usr_info) @@ -555,7 +556,9 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain)); - + + pstrcpy(current_user_info.smb_name, nt_username); + /* * Convert to a UNIX username. */ -- cgit From 6490fbce6b42277b3a75c060bc4f1c00c89924c3 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Sat, 8 Dec 2001 23:57:35 +0000 Subject: small comment I don't want to loose. J.F. (This used to be commit a0b5ae58228d01ff5099180f16ffba4353bd28a7) --- source3/rpc_server/srv_samr_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 853a130859..3c82924f1e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -560,6 +560,11 @@ NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, DEBUG(5,("_samr_get_usrdom_pwinfo: %d\n", __LINE__)); + /* + * NT sometimes return NT_STATUS_ACCESS_DENIED + * I don't know yet why. + */ + return r_u->status; } -- cgit From 4f53486d78102d8080293eeafd7b4ed701d81a2e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 10 Dec 2001 05:03:17 +0000 Subject: Added client and server code for the GetPrintProcessorDirectory SPOOLSS rpc. This was supposed to fix a printer driver download bug but it didn't but it seemed a shame to trash all this code so I'm commiting it #ifdef'ed out in case someone needs it one day. (This used to be commit bef43656471741c6c10b12e7516c15de9ae76394) --- source3/rpc_server/srv_spoolss.c | 40 ++++++++++++++++- source3/rpc_server/srv_spoolss_nt.c | 86 +++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 3a056dcb65..e71bcd36a9 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1316,6 +1316,40 @@ static BOOL api_spoolss_enumprinterdataex(pipes_struct *p) return True; } +/**************************************************************************** +****************************************************************************/ + +/* Disabled because it doesn't fix the bug I am looking at but it would be + a shame to throw away the code. -tpot */ + +#if 0 + +static BOOL api_spoolss_getprintprocessordirectory(pipes_struct *p) +{ + SPOOL_Q_GETPRINTPROCESSORDIRECTORY q_u; + SPOOL_R_GETPRINTPROCESSORDIRECTORY r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_getprintprocessordirectory("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_getprintprocessordirectory: unable to unmarshall SPOOL_Q_GETPRINTPROCESSORDIRECTORY.\n")); + return False; + } + + r_u.status = _spoolss_getprintprocessordirectory(p, &q_u, &r_u); + + if(!spoolss_io_r_getprintprocessordirectory("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_getprintprocessordirectory: unable to marshall SPOOL_R_GETPRINTPROCESSORDIRECTORY.\n")); + return False; + } + + return True; +} + +#endif /******************************************************************* \pipe\spoolss commands @@ -1367,7 +1401,11 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_SETPRINTERDATAEX", SPOOLSS_SETPRINTERDATAEX, api_spoolss_setprinterdataex }, {"SPOOLSS_ENUMPRINTERKEY", SPOOLSS_ENUMPRINTERKEY, api_spoolss_enumprinterkey }, {"SPOOLSS_ENUMPRINTERDATAEX", SPOOLSS_ENUMPRINTERDATAEX, api_spoolss_enumprinterdataex }, - +#if 0 + /* Disabled because it doesn't fix the bug I am looking at but it would be + a shame to throw away the code. -tpot */ + {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory}, +#endif { NULL, 0, NULL } }; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0e98498fe3..dae3aa09c9 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7,6 +7,7 @@ * Copyright (C) Jean François Micouleau 1998-2000. * Copyright (C) Jeremy Allison 2001. * Copyright (C) Gerald Carter 2000-2001. + * Copyright (C) Tim Potter 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -7073,4 +7074,89 @@ done: return result; } +/**************************************************************************** +****************************************************************************/ + +/* Disabled because it doesn't fix the bug I am looking at but it would be + a shame to throw away the code. -tpot */ + +#if 0 + +static void fill_printprocessordirectory_1(PRINTPROCESSOR_DIRECTORY_1 *info, char *name) +{ + init_unistr(&info->name, name); +} + +static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, + UNISTR2 *environment, + NEW_BUFFER *buffer, + uint32 offered, + uint32 *needed) +{ + pstring path; + pstring long_archi; + pstring short_archi; + PRINTPROCESSOR_DIRECTORY_1 *info=NULL; + + unistr2_to_ascii(long_archi, environment, sizeof(long_archi)-1); + + if (get_short_archi(short_archi, long_archi)==FALSE) + return WERR_INVALID_ENVIRONMENT; + + if((info=(PRINTPROCESSOR_DIRECTORY_1 *)malloc(sizeof(PRINTPROCESSOR_DIRECTORY_1))) == NULL) + return WERR_NOMEM; + + /* Not sure what to return here - are UNC names valid here?. + Windows returns the string: C:\WINNT\System32\spool\PRTPROCS\W32X86 + which is pretty bogus for a RPC. */ + + slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", global_myname, short_archi); + + DEBUG(4,("print processor directory: [%s]\n", path)); + + fill_printprocessordirectory_1(info, path); + + *needed += spoolss_size_printprocessordirectory_info_1(info); + + if (!alloc_buffer_size(buffer, *needed)) { + safe_free(info); + return WERR_INSUFFICIENT_BUFFER; + } + + smb_io_printprocessordirectory_1("", buffer, info, 0); + safe_free(info); + + if (*needed > offered) + return WERR_INSUFFICIENT_BUFFER; + else + return WERR_OK; +} + +WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, SPOOL_R_GETPRINTPROCESSORDIRECTORY *r_u) +{ + uint32 level = q_u->level; + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + + /* that's an [in out] buffer */ + spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + + DEBUG(5,("_spoolss_getprintprocessordirectory\n")); + + *needed=0; + + switch(level) { + case 1: + return getprintprocessordirectory_level_1 + (&q_u->name, &q_u->environment, buffer, offered, needed); + default: + return WERR_UNKNOWN_LEVEL; + } + + return WERR_ACCESS_DENIED; +} + +#endif -- cgit From 0ff1a9568b4bc0220cf90ea78f2657a92682307d Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 10 Dec 2001 15:03:16 +0000 Subject: added info level 3 to samrgetgroupinfo. I don't know what the value is. It's just to keep usermanager happy ;-) clean up a bit samr_query_aliasinfo to return the group description added: samr_del_aliasmem, samr_del_groupmem and samr_del_domuser with the correct scripts, you can now entirely manage the users from usermanager ! Closer to full PDC every day ;-) J.F. (This used to be commit 0a727afc669704cda9b44d44dbac9e989e906ae3) --- source3/rpc_server/srv_samr_nt.c | 176 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 164 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 3c82924f1e..042978495a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1181,10 +1181,8 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_R_QUERY_ALIASINFO *r_u) { - fstring alias_desc = "Local Unix group"; - fstring alias=""; - enum SID_NAME_USE type; struct samr_info *info = NULL; + GROUP_MAP map; r_u->status = NT_STATUS_OK; @@ -1198,14 +1196,14 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM !sid_check_is_in_builtin(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - if(!local_lookup_sid(&info->sid, alias, &type)) + if(!get_local_group_from_sid(info->sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; switch (q_u->switch_level) { case 3: r_u->ptr = 1; r_u->ctr.switch_value1 = 3; - init_samr_alias_info3(&r_u->ctr.alias.info3, alias_desc); + init_samr_alias_info3(&r_u->ctr.alias.info3, map.comment); break; default: return NT_STATUS_INVALID_INFO_CLASS; @@ -2981,8 +2979,62 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DEL_ALIASMEM *r_u) { - DEBUG(0,("_samr_del_aliasmem: Not yet implemented.\n")); - return NT_STATUS_NOT_IMPLEMENTED; + DOM_SID alias_sid; + fstring alias_sid_str; + struct group *grp; + fstring grp_name; + uint32 rid; + GROUP_MAP map; + SAM_ACCOUNT *sam_pass=NULL; + + /* Find the policy handle. Open a policy on it. */ + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid)) + return NT_STATUS_INVALID_HANDLE; + + sid_to_string(alias_sid_str, &alias_sid); + DEBUG(10, ("_samr_del_aliasmem:sid is %s\n", alias_sid_str)); + + if (!sid_check_is_in_our_domain(&alias_sid) && + !sid_check_is_in_builtin(&alias_sid)) { + DEBUG(10, ("_samr_del_aliasmem:invalid alias group\n")); + return NT_STATUS_NO_SUCH_ALIAS; + } + + if( !get_local_group_from_sid(alias_sid, &map, MAPPING_WITHOUT_PRIV)) + return NT_STATUS_NO_SUCH_ALIAS; + + if ((grp=getgrgid(map.gid)) == NULL) + return NT_STATUS_NO_SUCH_ALIAS; + + /* we need to copy the name otherwise it's overloaded in user_in_group_list */ + fstrcpy(grp_name, grp->gr_name); + + sid_peek_rid(&q_u->sid.sid, &rid); + + /* check if the user exists before trying to remove it from the group */ + pdb_init_sam(&sam_pass); + if(!pdb_getsampwrid(sam_pass, rid)) { + DEBUG(5,("_samr_del_aliasmem:User %d doesn't exist.\n", sam_pass->username)); + pdb_free_sam(&sam_pass); + return NT_STATUS_NO_SUCH_USER; + } + + /* if the user is not in the group */ + if(!user_in_group_list(sam_pass->username, grp_name)) { + pdb_free_sam(&sam_pass); + return NT_STATUS_MEMBER_IN_ALIAS; + } + + smb_delete_user_group(grp_name, sam_pass->username); + + /* check if the user has been removed then ... */ + if(user_in_group_list(sam_pass->username, grp_name)) { + pdb_free_sam(&sam_pass); + return NT_STATUS_MEMBER_NOT_IN_ALIAS; /* don't know what to reply else */ + } + + pdb_free_sam(&sam_pass); + return NT_STATUS_OK; } /********************************************************************* @@ -3047,8 +3099,62 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DEL_GROUPMEM *r_u) { - DEBUG(0,("_samr_del_groupmem: Not yet implemented.\n")); - return NT_STATUS_NOT_IMPLEMENTED; + DOM_SID group_sid; + SAM_ACCOUNT *sam_pass=NULL; + uint32 rid; + GROUP_MAP map; + fstring grp_name; + struct group *grp; + + /* + * delete the group member named q_u->rid + * who is a member of the sid associated with the handle + * the rid is a user's rid as the group is a domain group. + */ + + /* Find the policy handle. Open a policy on it. */ + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) + return NT_STATUS_INVALID_HANDLE; + + if(!sid_check_is_in_our_domain(&group_sid)) + return NT_STATUS_NO_SUCH_GROUP; + + rid=q_u->rid; + + if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) + return NT_STATUS_NO_SUCH_GROUP; + + if ((grp=getgrgid(map.gid)) == NULL) + return NT_STATUS_NO_SUCH_GROUP; + + /* we need to copy the name otherwise it's overloaded in user_in_group_list */ + fstrcpy(grp_name, grp->gr_name); + + /* check if the user exists before trying to remove it from the group */ + pdb_init_sam(&sam_pass); + if(!pdb_getsampwrid(sam_pass, rid)) { + DEBUG(5,("User %d doesn't exist.\n", sam_pass->username)); + pdb_free_sam(&sam_pass); + return NT_STATUS_NO_SUCH_USER; + } + + /* if the user is not in the group */ + if(!user_in_group_list(sam_pass->username, grp_name)) { + pdb_free_sam(&sam_pass); + return NT_STATUS_MEMBER_NOT_IN_GROUP; + } + + smb_delete_user_group(grp_name, sam_pass->username); + + /* check if the user has been removed then ... */ + if(user_in_group_list(sam_pass->username, grp_name)) { + pdb_free_sam(&sam_pass); + return NT_STATUS_ACCESS_DENIED; /* don't know what to reply else */ + } + + pdb_free_sam(&sam_pass); + return NT_STATUS_OK; + } /********************************************************************* @@ -3057,8 +3163,50 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAMR_R_DELETE_DOM_USER *r_u ) { - DEBUG(0,("_samr_delete_dom_user: Not yet implemented.\n")); - return NT_STATUS_NOT_IMPLEMENTED; + DOM_SID user_sid; + SAM_ACCOUNT *sam_pass=NULL; + uint32 rid; + + DEBUG(5, ("_samr_delete_dom_user: %d\n", __LINE__)); + + /* Find the policy handle. Open a policy on it. */ + if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &user_sid)) + return NT_STATUS_INVALID_HANDLE; + + if (!sid_check_is_in_our_domain(&user_sid)) + return NT_STATUS_CANNOT_DELETE; + + sid_peek_rid(&user_sid, &rid); + + /* check if the user exists before trying to delete */ + pdb_init_sam(&sam_pass); + if(!pdb_getsampwrid(sam_pass, rid)) { + DEBUG(5,("_samr_delete_dom_user:User %d doesn't exist.\n", sam_pass->username)); + pdb_free_sam(&sam_pass); + return NT_STATUS_NO_SUCH_USER; + } + + /* delete the unix side */ + /* + * note: we don't check if the delete really happened + * as the script is not necessary present + * and maybe the sysadmin doesn't want to delete the unix side + */ + smb_delete_user(sam_pass->username); + + /* and delete the samba side */ + if (!pdb_delete_sam_account(sam_pass->username)) { + DEBUG(5,("_samr_delete_dom_user:Failed to delete entry for user %s.\n", sam_pass->username)); + pdb_free_sam(&sam_pass); + return NT_STATUS_CANNOT_DELETE; + } + + pdb_free_sam(&sam_pass); + + if (!close_policy_hnd(p, &q_u->user_pol)) + return NT_STATUS_OBJECT_NAME_INVALID; + + return NT_STATUS_OK; } /********************************************************************* @@ -3094,7 +3242,7 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S DEBUG(10, ("lookup on Domain SID\n")); if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) - return NT_STATUS_NO_SUCH_ALIAS; + return NT_STATUS_NO_SUCH_GROUP; gid=map.gid; @@ -3327,6 +3475,10 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM init_samr_group_info1(&ctr->group.info1, map.nt_name, map.comment, num_uids); SAFE_FREE(uid); break; + case 3: + ctr->switch_value1 = 3; + init_samr_group_info3(&ctr->group.info3); + break; case 4: ctr->switch_value1 = 4; init_samr_group_info4(&ctr->group.info4, map.comment); -- cgit From 4ad930ad5ea47e9f543fb55a844d1d74fb7912cc Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 13 Dec 2001 16:35:43 +0000 Subject: merge from appliance_head (This used to be commit 423554fd71b3c9718fc3a21006da9ce6371fc845) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index dae3aa09c9..cd47f6a130 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6912,6 +6912,10 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO enumkeys[i] = (uint16)(*ptr); ptr++; } + + /* tag of with 2 '\0's */ + enumkeys[i++] = '\0'; + enumkeys[i] = '\0'; if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, ENUMERATED_KEY_SIZE, enumkeys)) return WERR_BADFILE; -- cgit From 14d7f43590a9384c34d49483c4ee14b4ad3d5fe7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 14 Dec 2001 04:43:31 +0000 Subject: FALSE -> False (This used to be commit dbdbf7cd077a8a20610ee2c62240170b420ebe6c) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cd47f6a130..87d076ae8c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7104,7 +7104,7 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, unistr2_to_ascii(long_archi, environment, sizeof(long_archi)-1); - if (get_short_archi(short_archi, long_archi)==FALSE) + if (get_short_archi(short_archi, long_archi)==False) return WERR_INVALID_ENVIRONMENT; if((info=(PRINTPROCESSOR_DIRECTORY_1 *)malloc(sizeof(PRINTPROCESSOR_DIRECTORY_1))) == NULL) -- cgit From 689144c631da01b4532ade7feb222e94bd8678ac Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 14 Dec 2001 17:31:48 +0000 Subject: add lsa_query_secobj server code. level 4 is the ACL, level 1 is the owner. that's basic stuff. got the POLICY_ define from TNG but they are also in an include file in the NT SDK. J.F. (This used to be commit 84289a9bf42847981926e198ad36c050904fa9ed) --- source3/rpc_server/srv_lsa.c | 31 ++++++++++++++++++ source3/rpc_server/srv_lsa_nt.c | 70 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index d2b2c60f45..b05fb972be 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -574,6 +574,36 @@ static BOOL api_lsa_removeprivs(pipes_struct *p) return True; } +/*************************************************************************** + api_lsa_query_secobj + ***************************************************************************/ + +static BOOL api_lsa_query_secobj(pipes_struct *p) +{ + LSA_Q_QUERY_SEC_OBJ q_u; + LSA_R_QUERY_SEC_OBJ r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_query_sec_obj("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_query_secobj: failed to unmarshall LSA_Q_QUERY_SEC_OBJ.\n")); + return False; + } + + r_u.status = _lsa_query_secobj(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_query_sec_obj("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_query_secobj: Failed to marshall LSA_R_QUERY_SEC_OBJ.\n")); + return False; + } + + return True; +} /*************************************************************************** \PIPE\ntlsa commands @@ -599,6 +629,7 @@ static struct api_struct api_lsa_cmds[] = { "LSA_SETSYSTEMACCOUNT", LSA_SETSYSTEMACCOUNT, api_lsa_setsystemaccount }, { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs }, { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs }, + { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, { NULL , 0 , NULL } }; diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index da5597132d..d5ea156eb6 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -913,3 +913,73 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP return r_u->status; } +/*************************************************************************** + For a given SID, remove some privileges. + ***************************************************************************/ + +NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUERY_SEC_OBJ *r_u) +{ + struct lsa_info *info=NULL; + extern DOM_SID global_sid_World; + extern DOM_SID global_sid_Builtin; + DOM_SID adm_sid; + + SEC_ACE ace[2]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + SEC_DESC *psd = NULL; + size_t sd_size; + + r_u->status = NT_STATUS_OK; + + /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; + + + switch (q_u->sec_info) { + case 1: + /* SD contains only the owner */ + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + if((psd = make_sec_desc(p->mem_ctx, SEC_DESC_REVISION, &adm_sid, NULL, NULL, NULL, &sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + if((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL) + return NT_STATUS_NO_MEMORY; + break; + case 4: + /* SD contains only the ACL */ + + init_sec_access(&mask, POLICY_EXECUTE); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + init_sec_access(&mask, POLICY_ALL_ACCESS); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if((psa = make_sec_acl(p->mem_ctx, NT4_ACL_REVISION, 2, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if((psd = make_sec_desc(p->mem_ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, &sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + if((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL) + return NT_STATUS_NO_MEMORY; + break; + default: + return NT_STATUS_INVALID_LEVEL; + break; + } + + r_u->ptr=1; + + return r_u->status; +} + + -- cgit From abcd1cad3af7ee111f711544407222951e33238e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 14 Dec 2001 20:38:04 +0000 Subject: ChangeID fixe from APPLIANCE_HEAD (This used to be commit 096d06a961e3a3e6f6952754875b83558448f449) --- source3/rpc_server/srv_spoolss_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 87d076ae8c..5794f1de04 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6288,6 +6288,11 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM return WERR_BADFID; } + /* + * FIXME!! Feels like there should be an access check here, but haven't + * had time to verify. --jerry + */ + /* can't add if builtin */ if (get_a_builtin_ntform(&form->name,&tmpForm)) { return WERR_INVALID_PARAM; -- cgit From 6e76486505287124eb62e32c4387a9608364a568 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Mon, 17 Dec 2001 23:03:23 +0000 Subject: there is no unknown field in LSA_SEC_QOS some cleanup of the lsa_open_policy and lsa_open_policy2 parser. the length fields are not correct but that's what NT send. We don't anymore underflow or overflow the decoding. added the domain admins group to the default SD. we are now checking the desired access flag in the lsa_open_policy_X() calls and in most functions also. J.F. (This used to be commit a217c4e4ff4d13122703d22258792fe5e8e9f02f) --- source3/rpc_server/srv_lsa_nt.c | 275 ++++++++++++++++++++++++++++++---------- 1 file changed, 208 insertions(+), 67 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index d5ea156eb6..fa95e9f79f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -36,6 +36,13 @@ struct lsa_info { uint32 access; }; +struct generic_mapping lsa_generic_mapping = { + POLICY_READ, + POLICY_WRITE, + POLICY_EXECUTE, + POLICY_ALL_ACCESS +}; + /******************************************************************* Function to free the per handle data. ********************************************************************/ @@ -290,16 +297,73 @@ static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, r_l->status = NT_STATUS_OK; } +static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *sd_size) +{ + extern DOM_SID global_sid_World; + extern DOM_SID global_sid_Builtin; + DOM_SID local_adm_sid; + DOM_SID adm_sid; + + SEC_ACE ace[3]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + + init_sec_access(&mask, POLICY_EXECUTE); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + sid_copy(&adm_sid, &global_sam_sid); + sid_append_rid(&adm_sid, DOMAIN_GROUP_RID_ADMINS); + init_sec_access(&mask, POLICY_ALL_ACCESS); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + sid_copy(&local_adm_sid, &global_sid_Builtin); + sid_append_rid(&local_adm_sid, BUILTIN_ALIAS_RID_ADMINS); + init_sec_access(&mask, POLICY_ALL_ACCESS); + init_sec_ace(&ace[2], &local_adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if((psa = make_sec_acl(mem_ctx, NT4_ACL_REVISION, 3, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if((*sd = make_sec_desc(mem_ctx, SEC_DESC_REVISION, &adm_sid, NULL, NULL, psa, sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + return NT_STATUS_OK; +} + /*************************************************************************** _lsa_open_policy2. ***************************************************************************/ NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2 *r_u) { - /* lkclXXXX having decoded it, ignore all fields in the open policy! */ + struct lsa_info *info; + SEC_DESC *psd = NULL; + size_t sd_size; + uint32 des_access=q_u->des_access; + uint32 acc_granted; + NTSTATUS status; + + + /* map the generic bits to the lsa policy ones */ + se_map_generic(&des_access, &lsa_generic_mapping); + + /* get the generic lsa policy SD until we store it */ + lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size); + + if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) + return status; + + /* associate the domain SID with the (unique) handle. */ + if ((info = (struct lsa_info *)malloc(sizeof(struct lsa_info))) == NULL) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(info); + info->sid = global_sam_sid; + info->access = acc_granted; /* set up the LSA QUERY INFO response */ - if (!create_policy_hnd(p, &r_u->pol, NULL, NULL)) + if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; return NT_STATUS_OK; @@ -311,10 +375,33 @@ NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL *r_u) { - /* lkclXXXX having decoded it, ignore all fields in the open policy! */ + struct lsa_info *info; + SEC_DESC *psd = NULL; + size_t sd_size; + uint32 des_access=q_u->des_access; + uint32 acc_granted; + NTSTATUS status; + + + /* map the generic bits to the lsa policy ones */ + se_map_generic(&des_access, &lsa_generic_mapping); + + /* get the generic lsa policy SD until we store it */ + lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size); + + if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) + return status; + + /* associate the domain SID with the (unique) handle. */ + if ((info = (struct lsa_info *)malloc(sizeof(struct lsa_info))) == NULL) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(info); + info->sid = global_sam_sid; + info->access = acc_granted; /* set up the LSA QUERY INFO response */ - if (!create_policy_hnd(p, &r_u->pol, NULL, NULL)) + if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; return NT_STATUS_OK; @@ -326,13 +413,18 @@ NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL * NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_ENUM_TRUST_DOM *r_u) { + struct lsa_info *info; uint32 enum_context = 0; char *dom_name = NULL; DOM_SID *dom_sid = NULL; - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; + /* check if the user have enough rights */ + if (!(info->access & POLICY_VIEW_LOCAL_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + /* set up the LSA QUERY INFO response */ init_r_enum_trust_dom(p->mem_ctx, r_u, enum_context, dom_name, dom_sid, dom_name != NULL ? NT_STATUS_OK : NT_STATUS_NO_MORE_ENTRIES); @@ -346,6 +438,7 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO *r_u) { + struct lsa_info *handle; LSA_INFO_UNION *info = &r_u->dom; DOM_SID domain_sid; char *name = NULL; @@ -353,24 +446,32 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF r_u->status = NT_STATUS_OK; - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; switch (q_u->info_class) { case 0x02: { - unsigned int i; - /* fake info: We audit everything. ;) */ - info->id2.auditing_enabled = 1; - info->id2.count1 = 7; - info->id2.count2 = 7; - if ((info->id2.auditsettings = (uint32 *)talloc(p->mem_ctx,7*sizeof(uint32))) == NULL) - return NT_STATUS_NO_MEMORY; - for (i = 0; i < 7; i++) - info->id2.auditsettings[i] = 3; - break; + unsigned int i; + /* check if the user have enough rights */ + if (!(handle->access & POLICY_VIEW_AUDIT_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + + /* fake info: We audit everything. ;) */ + info->id2.auditing_enabled = 1; + info->id2.count1 = 7; + info->id2.count2 = 7; + if ((info->id2.auditsettings = (uint32 *)talloc(p->mem_ctx,7*sizeof(uint32))) == NULL) + return NT_STATUS_NO_MEMORY; + for (i = 0; i < 7; i++) + info->id2.auditsettings[i] = 3; + break; } case 0x03: + /* check if the user have enough rights */ + if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + /* Request PolicyPrimaryDomainInformation. */ switch (lp_server_role()) { case ROLE_DOMAIN_PDC: @@ -397,6 +498,10 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF init_dom_query(&r_u->dom.id3, name, sid); break; case 0x05: + /* check if the user have enough rights */ + if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + /* Request PolicyAccountDomainInformation. */ switch (lp_server_role()) { case ROLE_DOMAIN_PDC: @@ -418,6 +523,10 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF init_dom_query(&r_u->dom.id5, name, sid); break; case 0x06: + /* check if the user have enough rights */ + if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + switch (lp_server_role()) { case ROLE_DOMAIN_BDC: /* @@ -455,15 +564,20 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF NTSTATUS _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_SIDS *r_u) { + struct lsa_info *handle; DOM_SID2 *sid = q_u->sids.sid; int num_entries = q_u->sids.num_entries; DOM_R_REF *ref = NULL; LSA_TRANS_NAME_ENUM *names = NULL; uint32 mapped_count = 0; - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; + /* check if the user have enough rights */ + if (!(handle->access & POLICY_LOOKUP_NAMES)) + return NT_STATUS_ACCESS_DENIED; + ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); names = (LSA_TRANS_NAME_ENUM *)talloc_zero(p->mem_ctx, sizeof(LSA_TRANS_NAME_ENUM)); @@ -483,15 +597,20 @@ lsa_reply_lookup_names NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_NAMES *r_u) { + struct lsa_info *handle; UNISTR2 *names = q_u->uni_name; int num_entries = q_u->num_entries; DOM_R_REF *ref; DOM_RID2 *rids; uint32 mapped_count = 0; - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; + /* check if the user have enough rights */ + if (!(handle->access & POLICY_LOOKUP_NAMES)) + return NT_STATUS_ACCESS_DENIED; + ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); rids = (DOM_RID2 *)talloc_zero(p->mem_ctx, sizeof(DOM_RID2)*MAX_LOOKUP_SIDS); @@ -533,15 +652,24 @@ _lsa_enum_privs. NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIVS *r_u) { + struct lsa_info *handle; uint32 i; uint32 enum_context=q_u->enum_context; LSA_PRIV_ENTRY *entry; LSA_PRIV_ENTRY *entries=NULL; - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; + /* check if the user have enough rights */ + + /* + * I don't know if it's the right one. not documented. + */ + if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + if (enum_context >= PRIV_ALL_INDEX) return NT_STATUS_NO_MORE_ENTRIES; @@ -579,12 +707,21 @@ _lsa_priv_get_dispname. NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, LSA_R_PRIV_GET_DISPNAME *r_u) { + struct lsa_info *handle; fstring name_asc; int i=1; - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; + /* check if the user have enough rights */ + + /* + * I don't know if it's the right one. not documented. + */ + if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + unistr2_to_ascii(name_asc, &q_u->name, sizeof(name_asc)); DEBUG(10,("_lsa_priv_get_dispname: %s", name_asc)); @@ -613,14 +750,23 @@ _lsa_enum_accounts. NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENUM_ACCOUNTS *r_u) { + struct lsa_info *handle; GROUP_MAP *map=NULL; int num_entries=0; LSA_SID_ENUM *sids=&r_u->sids; int i=0,j=0; - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; + /* check if the user have enough rights */ + + /* + * I don't know if it's the right one. not documented. + */ + if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + /* get the list of mapped groups (domain, local, builtin) */ if(!enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) return NT_STATUS_OK; @@ -652,32 +798,32 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u) { - fstring username, domname; - int ulen, dlen; - user_struct *vuser = get_valid_user_struct(p->vuid); + fstring username, domname; + int ulen, dlen; + user_struct *vuser = get_valid_user_struct(p->vuid); - if (vuser == NULL) - return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; + if (vuser == NULL) + return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; - fstrcpy(username, vuser->user.smb_name); - fstrcpy(domname, vuser->user.domain); + fstrcpy(username, vuser->user.smb_name); + fstrcpy(domname, vuser->user.domain); - ulen = strlen(username) + 1; - dlen = strlen(domname) + 1; + ulen = strlen(username) + 1; + dlen = strlen(domname) + 1; - init_uni_hdr(&r_u->hdr_user_name, ulen); - r_u->ptr_user_name = 1; - init_unistr2(&r_u->uni2_user_name, username, ulen); + init_uni_hdr(&r_u->hdr_user_name, ulen); + r_u->ptr_user_name = 1; + init_unistr2(&r_u->uni2_user_name, username, ulen); - r_u->unk1 = 1; + r_u->unk1 = 1; - init_uni_hdr(&r_u->hdr_dom_name, dlen); - r_u->ptr_dom_name = 1; - init_unistr2(&r_u->uni2_dom_name, domname, dlen); + init_uni_hdr(&r_u->hdr_dom_name, dlen); + r_u->ptr_dom_name = 1; + init_unistr2(&r_u->uni2_dom_name, domname, dlen); - r_u->status = NT_STATUS_OK; + r_u->status = NT_STATUS_OK; - return r_u->status; + return r_u->status; } /*************************************************************************** @@ -686,14 +832,24 @@ NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENACCOUNT *r_u) { + struct lsa_info *handle; struct lsa_info *info; r_u->status = NT_STATUS_OK; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; + /* check if the user have enough rights */ + + /* + * I don't know if it's the right one. not documented. + * but guessed with rpcclient. + */ + if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + /* associate the user/group SID with the (unique) handle. */ if ((info = (struct lsa_info *)malloc(sizeof(struct lsa_info))) == NULL) return NT_STATUS_NO_MEMORY; @@ -919,54 +1075,39 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUERY_SEC_OBJ *r_u) { - struct lsa_info *info=NULL; - extern DOM_SID global_sid_World; - extern DOM_SID global_sid_Builtin; - DOM_SID adm_sid; - - SEC_ACE ace[2]; - SEC_ACCESS mask; - - SEC_ACL *psa = NULL; + struct lsa_info *handle=NULL; SEC_DESC *psd = NULL; size_t sd_size; + NTSTATUS status; r_u->status = NT_STATUS_OK; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; + /* check if the user have enough rights */ + if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + switch (q_u->sec_info) { case 1: /* SD contains only the owner */ - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); - - if((psd = make_sec_desc(p->mem_ctx, SEC_DESC_REVISION, &adm_sid, NULL, NULL, NULL, &sd_size)) == NULL) + status=lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size); + if(!NT_STATUS_IS_OK(status)) return NT_STATUS_NO_MEMORY; + if((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL) return NT_STATUS_NO_MEMORY; break; case 4: /* SD contains only the ACL */ - init_sec_access(&mask, POLICY_EXECUTE); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); - - init_sec_access(&mask, POLICY_ALL_ACCESS); - init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - if((psa = make_sec_acl(p->mem_ctx, NT4_ACL_REVISION, 2, ace)) == NULL) - return NT_STATUS_NO_MEMORY; - - if((psd = make_sec_desc(p->mem_ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, &sd_size)) == NULL) + status=lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size); + if(!NT_STATUS_IS_OK(status)) return NT_STATUS_NO_MEMORY; if((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL) -- cgit From e6111117325f286028c08b51ad4f598eeba55c89 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Tue, 18 Dec 2001 00:32:45 +0000 Subject: in lsa_query_info at level 5 in member mode, we must reply our machine name and not our domain name. I thought it has been already fixed ! J.F. (This used to be commit 1fbb01868b489c896ad1c65ded223999b0ee6013) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index fa95e9f79f..7987be5472 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -510,7 +510,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF sid = &global_sam_sid; break; case ROLE_DOMAIN_MEMBER: - name = global_myworkgroup; + name = global_myname; sid = &global_sam_sid; break; case ROLE_STANDALONE: -- cgit From 5d3b81dede7afe92976e7d798e5b85151d3b56a2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Dec 2001 02:17:46 +0000 Subject: I'm pretty sure we need to return our netbios name for LSA_QUERY_INFO level 5 when we're a standalone server. This makes the security dialogs return correct info. JF - please check ! Jeremy. (This used to be commit dd13daf52bc96637ef3d40920cbd3bcadb7e08f5) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 7987be5472..4791e2ac08 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -514,7 +514,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF sid = &global_sam_sid; break; case ROLE_STANDALONE: - name = global_myworkgroup; + name = global_myname; sid = &global_sam_sid; break; default: -- cgit From 140f1ccf1f70f795bb8c208426ed507b06b1f32d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 18 Dec 2001 05:00:07 +0000 Subject: Fixed bad args to debug statements. (This used to be commit 5e0f0716ca9826de110fd9eeaf231970e7c19b42) --- source3/rpc_server/srv_samr_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 042978495a..78535e4c2b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3014,7 +3014,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE /* check if the user exists before trying to remove it from the group */ pdb_init_sam(&sam_pass); if(!pdb_getsampwrid(sam_pass, rid)) { - DEBUG(5,("_samr_del_aliasmem:User %d doesn't exist.\n", sam_pass->username)); + DEBUG(5,("_samr_del_aliasmem:User %s doesn't exist.\n", sam_pass->username)); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } @@ -3133,7 +3133,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE /* check if the user exists before trying to remove it from the group */ pdb_init_sam(&sam_pass); if(!pdb_getsampwrid(sam_pass, rid)) { - DEBUG(5,("User %d doesn't exist.\n", sam_pass->username)); + DEBUG(5,("User %s doesn't exist.\n", sam_pass->username)); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } @@ -3181,7 +3181,7 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM /* check if the user exists before trying to delete */ pdb_init_sam(&sam_pass); if(!pdb_getsampwrid(sam_pass, rid)) { - DEBUG(5,("_samr_delete_dom_user:User %d doesn't exist.\n", sam_pass->username)); + DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n", sam_pass->username)); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } -- cgit From dccc1ed3f8344968129c73104c1bdf8ab8b2a1e5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Dec 2001 19:44:14 +0000 Subject: Fixup JF's weird SID return :-). Jeremy (This used to be commit 7b8fb8d85c406b8755f60cf14dc2377bc59eda53) --- source3/rpc_server/srv_lsa_nt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 4791e2ac08..432f20a40c 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -438,6 +438,7 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO *r_u) { + extern DOM_SID global_sid_nonexistent; struct lsa_info *handle; LSA_INFO_UNION *info = &r_u->dom; DOM_SID domain_sid; @@ -490,7 +491,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF break; case ROLE_STANDALONE: name = global_myworkgroup; - sid = NULL; /* Tell it we're not in a domain. */ + sid = &global_sid_nonexistent; break; default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; -- cgit From ea274ac97ff5c46c5f910c38b463d6a553dea9e6 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Wed, 19 Dec 2001 00:15:29 +0000 Subject: added info level 1 to samr_query_alias() (This used to be commit 589aa4fe226ee5bdae0a244631193714b0b556ac) --- source3/rpc_server/srv_samr_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 78535e4c2b..b918b4dca1 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1200,6 +1200,11 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM return NT_STATUS_NO_SUCH_ALIAS; switch (q_u->switch_level) { + case 1: + r_u->ptr = 1; + r_u->ctr.switch_value1 = 1; + init_samr_alias_info1(&r_u->ctr.alias.info1, map.nt_name, 1, map.comment); + break; case 3: r_u->ptr = 1; r_u->ctr.switch_value1 = 3; -- cgit From bf65820af242786bd66d814fc3e9d89920a49f8e Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Fri, 21 Dec 2001 00:37:49 +0000 Subject: Add an output parameter to message_send_all that says how many messages were sent, so you know how many replies to expect. Const and doc religion. (This used to be commit 22e510ea0d69356be4fd2fa5ad9e9f4e84f62337) --- source3/rpc_server/srv_netlog_nt.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 2 +- source3/rpc_server/srv_srvsvc_nt.c | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 8092488652..634e2540fa 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -91,7 +91,7 @@ static void send_sync_message(void) DEBUG(3, ("sending sam synchronisation message\n")); - message_send_all(tdb, MSG_SMB_SAM_SYNC, NULL, 0, False); + message_send_all(tdb, MSG_SMB_SAM_SYNC, NULL, 0, False, NULL); tdb_close(tdb); } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5794f1de04..3fe21eb968 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -690,7 +690,7 @@ static BOOL srv_spoolss_sendnotify(pipes_struct *p, POLICY_HND *handle) /*srv_spoolss_receive_message(printer);*/ DEBUG(10,("srv_spoolss_sendnotify: Sending message about printer %s\n", printer )); - message_send_all(conn_tdb_ctx(), MSG_PRINTER_NOTIFY, printer, strlen(printer) + 1, False); /* Null terminate... */ + broadcast_printer_notify(printer); return True; } diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 9fadba17dd..06cbbaa2dc 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1329,7 +1329,8 @@ NTSTATUS _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, } /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False); + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, + 0, False, NULL); } else { DEBUG(10,("_srv_net_share_set_info: No change to share name (%s)\n", share_name )); @@ -1451,7 +1452,8 @@ NTSTATUS _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET } /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False); + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, + NULL); /* * We don't call reload_services() here, the message will @@ -1514,7 +1516,8 @@ NTSTATUS _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET delete_share_security(snum); /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False); + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, + NULL); lp_killservice(snum); -- cgit From 595dd015071395bae2ffc61573c72bb9f6a77553 Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 21 Dec 2001 13:36:14 +0000 Subject: re-done all of samr_query_disp_info() instead of enumerating the whole user db or group db every time, we store a in memory copy linked to the handle. that's much faster for large enumeration where the db can't fit in a single rpc packet. And as it's a copy, it's constant between enumeration. still some stuff to clean. But now I can fix the W95 userlist bug, as I've finally found it. J.F. (This used to be commit 3ab45215369e8e93d750f4687e9c1f7d47782590) --- source3/rpc_server/srv_samr_nt.c | 396 ++++++++++++++++++++++++++++++--------- 1 file changed, 310 insertions(+), 86 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b918b4dca1..1cd061369f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -38,10 +38,22 @@ extern rid_name domain_group_rids[]; extern rid_name domain_alias_rids[]; extern rid_name builtin_alias_rids[]; + +typedef struct _disp_info { + BOOL user_dbloaded; + BOOL group_dbloaded; + uint32 num_account; + uint32 total_size; + uint32 last_enum; + DISP_USER_INFO *disp_user_info; + DISP_GROUP_INFO *disp_group_info; +} DISP_INFO; + struct samr_info { - /* for use by the \PIPE\samr policy */ - DOM_SID sid; - uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ + /* for use by the \PIPE\samr policy */ + DOM_SID sid; + uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ + DISP_INFO disp_info; }; /******************************************************************* @@ -50,6 +62,24 @@ struct samr_info { static void free_samr_info(void *ptr) { + int i; + + struct samr_info *info=(struct samr_info *) ptr; + + if (info->disp_info.group_dbloaded) { + for (i=0; idisp_info.num_account; i++) + SAFE_FREE(info->disp_info.disp_group_info[i].grp); + + SAFE_FREE(info->disp_info.disp_group_info); + } + + if (info->disp_info.user_dbloaded){ + for (i=0; idisp_info.num_account; i++) + SAFE_FREE(info->disp_info.disp_user_info[i].sam); + + SAFE_FREE(info->disp_info.disp_user_info); + } + SAFE_FREE(ptr); } @@ -79,6 +109,137 @@ static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) if (sam_pass->nt_pw) memset(sam_pass->nt_pw, '\0', 16); } + +static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) +{ + SAM_ACCOUNT *pwd = NULL; + DISP_USER_INFO *pwd_array = NULL; + + DEBUG(10,("load_sampwd_entries\n")); + + /* if the snapshoot is already loaded, return */ + if (info->disp_info.user_dbloaded==True) { + DEBUG(10,("load_sampwd_entries: already in memory\n")); + return NT_STATUS_OK; + } + + if (!pdb_setsampwent(False)) { + DEBUG(0, ("get_sampwd_entries: Unable to open passdb.\n")); + return NT_STATUS_ACCESS_DENIED; + } + + for (pdb_init_sam(&pwd); pdb_getsampwent(pwd) == True; pwd=NULL, pdb_init_sam(&pwd) ) { + + uint32 len_sam_name, len_sam_full, len_sam_desc; + + if (acb_mask != 0 && !(pwd->acct_ctrl & acb_mask)) { + pdb_free_sam(&pwd); + DEBUG(5,(" acb_mask %x reject\n", acb_mask)); + continue; + } + DEBUG(0,("load_sampwd_entries: entry: %d\n", info->disp_info.num_account)); + + /* Realloc some memory for the array of ptr to the SAM_ACCOUNT structs */ + if (info->disp_info.num_account % MAX_SAM_ENTRIES == 0) { + + DEBUG(0,("load_sampwd_entries: allocating more memory\n")); + + + pwd_array=(DISP_USER_INFO *)Realloc(info->disp_info.disp_user_info, + (info->disp_info.num_account+MAX_SAM_ENTRIES)*sizeof(DISP_USER_INFO)); + + if (pwd_array==NULL) + return NT_STATUS_NO_MEMORY; + + info->disp_info.disp_user_info=pwd_array; + } + + /* link the SAM_ACCOUNT to the array */ + info->disp_info.disp_user_info[info->disp_info.num_account].sam=pwd; + + /* calculate the size needed to store the data */ + len_sam_name = strlen(pdb_get_username(pwd)); + len_sam_full = strlen(pdb_get_fullname(pwd)); + len_sam_desc = strlen(pdb_get_acct_desc(pwd)); + + info->disp_info.disp_user_info[info->disp_info.num_account].size=len_sam_name+ + len_sam_full+ + len_sam_desc; + /* keep the total size up to date too */ + info->disp_info.total_size+=info->disp_info.disp_user_info[info->disp_info.num_account].size; + + /* + * note: the size calculated are smaller than the size sent on the wire + * we add the SAM_ENTRY_x size later + */ + DEBUG(0,("load_sampwd_entries: entry: %d size: %d total: %d\n", info->disp_info.num_account, info->disp_info.disp_user_info[info->disp_info.num_account].size,info->disp_info.total_size)); + + info->disp_info.num_account++; + } + + pdb_endsampwent(); + + /* the snapshoot is in memory, we're ready to enumerate fast */ + + info->disp_info.user_dbloaded=True; + info->disp_info.last_enum=0; + + DEBUG(10,("load_sampwd_entries: done\n")); + + return NT_STATUS_OK; +} + +static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) +{ + GROUP_MAP *map=NULL; + DISP_GROUP_INFO *grp_array = NULL; + uint32 group_entries = 0; + uint32 i; + + DEBUG(10,("load_group_domain_entries\n")); + + /* if the snapshoot is already loaded, return */ + if (info->disp_info.group_dbloaded==True) { + DEBUG(10,("load_group_domain_entries: already in memory\n")); + return NT_STATUS_OK; + } + + enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); + + info->disp_info.num_account=group_entries; + + grp_array=(DISP_GROUP_INFO *)malloc(info->disp_info.num_account*sizeof(DISP_GROUP_INFO)); + + if (group_entries!=0 && grp_array==NULL) { + SAFE_FREE(map); + return NT_STATUS_NO_MEMORY; + } + + info->disp_info.disp_group_info=grp_array; + + for (i=0; iname, map[i].nt_name); + fstrcpy(grp_array[i].grp->comment, map[i].comment); + sid_split_rid(&map[i].sid, &grp_array[i].grp->rid); + grp_array[i].grp->attr=SID_NAME_DOM_GRP; + } + + SAFE_FREE(map); + + /* the snapshoot is in memory, we're ready to enumerate fast */ + + info->disp_info.group_dbloaded=True; + info->disp_info.last_enum=0; + + DEBUG(10,("load_group_domain_entries: done\n")); + + return NT_STATUS_OK; +} + + /******************************************************************* This next function should be replaced with something that dynamically returns the correct user info..... JRA. @@ -1022,91 +1183,147 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S /******************************************************************* samr_reply_query_dispinfo ********************************************************************/ - NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_QUERY_DISPINFO *r_u) { - SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; - DOMAIN_GRP *grps=NULL; - uint16 acb_mask = ACB_NORMAL; - uint32 num_entries = 0; - int orig_num_entries = 0; - int total_entries = 0; - uint32 data_size = 0; - DOM_SID sid; - NTSTATUS disp_ret; + struct samr_info *info = NULL; + uint32 struct_size=0; + uint16 acb_mask; + + uint32 max_entries=q_u->max_entries; + uint32 enum_context=q_u->start_idx; + uint32 max_size=q_u->max_size; + SAM_DISPINFO_CTR *ctr; + uint32 temp_size=0, total_data_size=0; + uint32 i; + NTSTATUS disp_ret; DEBUG(5, ("samr_reply_query_dispinfo: %d\n", __LINE__)); - r_u->status = NT_STATUS_OK; - if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid)) + /* find the policy handle. open a policy on it. */ + if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - /* decide how many entries to get depending on the max_entries - and max_size passed by client */ - - DEBUG(5, ("samr_reply_query_dispinfo: max_entries before %d\n", q_u->max_entries)); + /* + * calculate how many entries we will return. + * based on + * - the number of entries the client asked + * - our limit on that + * - the starting point (enumeration context) + * - the buffer size the client will accept + */ - if(q_u->max_entries > MAX_SAM_ENTRIES) - q_u->max_entries = MAX_SAM_ENTRIES; + /* + * We are a lot more like W2K. Instead of reading the SAM + * each time to find the records we need to send back, + * we read it once and link that copy to the sam handle. + * For large user list (over the MAX_SAM_ENTRIES) + * it's a definitive win. + * second point to notice: between enumerations + * our sam is now the same as it's a snapshoot. + * third point: got rid of the static SAM_USER_21 struct + * no more intermediate. + * con: it uses much more memory, as a full copy is stored + * in memory. + * + * If you want to change it, think twice and think + * of the second point , that's really important. + * + * JFM, 12/20/2001 + */ - DEBUG(5, ("samr_reply_query_dispinfo: max_entries after %d\n", q_u->max_entries)); + /* Get what we need from the password database */ + switch (q_u->switch_level) { + case 0x1: + acb_mask = ACB_NORMAL; + struct_size=0x20; + break; + case 0x2: + acb_mask = ACB_WSTRUST; + struct_size=0x20; + break; + case 0x3: + struct_size=0x20; + break; + case 0x4: + acb_mask = ACB_NORMAL; + struct_size=0x20; + break; + case 0x5: + struct_size=0x20; + break; + default: + DEBUG(0,("_samr_query_dispinfo: Unknown info level (%u)\n", (unsigned int)q_u->switch_level )); + return NT_STATUS_INVALID_INFO_CLASS; + } /* Get what we need from the password database */ switch (q_u->switch_level) { - case 0x2: - acb_mask = ACB_WSTRUST; - /* Fall through */ - case 0x1: - case 0x4: - become_root(); -#if 0 - r_u->status = get_passwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, - MAX_SAM_ENTRIES, acb_mask); -#endif -#if 0 - /* - * Which should we use here ? JRA. - */ - r_u->status = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, - MAX_SAM_ENTRIES, acb_mask); -#endif -#if 1 - r_u->status = jf_get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, - MAX_SAM_ENTRIES, acb_mask); -#endif - unbecome_root(); - if (NT_STATUS_IS_ERR(r_u->status)) { - DEBUG(5, ("get_sampwd_entries: failed\n")); - return r_u->status; - } - break; - case 0x3: - case 0x5: - r_u->status = get_group_domain_entries(p->mem_ctx, &grps, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); - if (NT_STATUS_IS_ERR(r_u->status)) - return r_u->status; - break; - default: - DEBUG(0,("_samr_query_dispinfo: Unknown info level (%u)\n", (unsigned int)q_u->switch_level )); - return NT_STATUS_INVALID_INFO_CLASS; + case 0x1: + case 0x2: + case 0x4: + if (enum_context!=0 && info->disp_info.user_dbloaded==False) + return NT_STATUS_UNSUCCESSFUL; + + become_root(); + r_u->status=load_sampwd_entries(info, acb_mask); + unbecome_root(); + if (NT_STATUS_IS_ERR(r_u->status)) { + DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); + return r_u->status; + } + break; + case 0x3: + case 0x5: + if (enum_context!=0 && info->disp_info.group_dbloaded==False) + return NT_STATUS_UNSUCCESSFUL; + + r_u->status = load_group_domain_entries(info, &info->sid); + if (NT_STATUS_IS_ERR(r_u->status)) + return r_u->status; + break; + default: + DEBUG(0,("_samr_query_dispinfo: Unknown info level (%u)\n", (unsigned int)q_u->switch_level )); + return NT_STATUS_INVALID_INFO_CLASS; + } + + /* first limit the number of entries we will return */ + if(max_entries > MAX_SAM_ENTRIES) { + DEBUG(5, ("samr_reply_query_dispinfo: client requested %d entries, limiting to %d\n", max_entries, MAX_SAM_ENTRIES)); + max_entries = MAX_SAM_ENTRIES; } - orig_num_entries = num_entries; + if (enum_context > info->disp_info.num_account) { + DEBUG(5, ("samr_reply_query_dispinfo: enumeration handle over total entries\n")); + return NT_STATUS_OK; + } - if (num_entries > q_u->max_entries) - num_entries = q_u->max_entries; - if (num_entries > MAX_SAM_ENTRIES) { - num_entries = MAX_SAM_ENTRIES; - DEBUG(5, ("limiting number of entries to %d\n", num_entries)); + /* verify we won't overflow */ + if (max_entries > info->disp_info.num_account-enum_context) { + max_entries = info->disp_info.num_account-enum_context; + DEBUG(5, ("samr_reply_query_dispinfo: only %d entries to return\n", max_entries)); } - /* Ensure password info is never given out here. PARANOIA... JRA */ - samr_clear_passwd_fields(pass, num_entries); - data_size = q_u->max_size; + /* calculate the size */ + if (q_u->switch_level==3 || q_u->switch_level==5) + for (i=enum_context; (idisp_info.disp_group_info[i].size * 2;*/ + temp_size+=struct_size; + } + + else + for (i=enum_context; (idisp_info.disp_user_info[i].size * 2;*/ + temp_size+=struct_size; + } + + if (imem_ctx,sizeof(SAM_DISPINFO_CTR)))) return NT_STATUS_NO_MEMORY; @@ -1116,65 +1333,72 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ /* Now create reply structure */ switch (q_u->switch_level) { case 0x1: - if (num_entries) { - if (!(ctr->sam.info1 = (SAM_DISPINFO_1 *)talloc_zero(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_1)))) + if (max_entries) { + if (!(ctr->sam.info1 = (SAM_DISPINFO_1 *)talloc_zero(p->mem_ctx,max_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); + disp_ret = init_sam_dispinfo_1(p->mem_ctx, ctr->sam.info1, max_entries, enum_context, info->disp_info.disp_user_info); if (NT_STATUS_IS_ERR(disp_ret)) return disp_ret; break; case 0x2: - if (num_entries) { - if (!(ctr->sam.info2 = (SAM_DISPINFO_2 *)talloc_zero(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_2)))) + if (max_entries) { + if (!(ctr->sam.info2 = (SAM_DISPINFO_2 *)talloc_zero(p->mem_ctx,max_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); + disp_ret = init_sam_dispinfo_2(p->mem_ctx, ctr->sam.info2, max_entries, enum_context, info->disp_info.disp_user_info); if (NT_STATUS_IS_ERR(disp_ret)) return disp_ret; break; case 0x3: - if (num_entries) { - if (!(ctr->sam.info3 = (SAM_DISPINFO_3 *)talloc_zero(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_3)))) + if (max_entries) { + if (!(ctr->sam.info3 = (SAM_DISPINFO_3 *)talloc_zero(p->mem_ctx,max_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); + disp_ret = init_sam_dispinfo_3(p->mem_ctx, ctr->sam.info3, max_entries, enum_context, info->disp_info.disp_group_info); if (NT_STATUS_IS_ERR(disp_ret)) return disp_ret; break; case 0x4: - if (num_entries) { - if (!(ctr->sam.info4 = (SAM_DISPINFO_4 *)talloc_zero(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_4)))) + if (max_entries) { + if (!(ctr->sam.info4 = (SAM_DISPINFO_4 *)talloc_zero(p->mem_ctx,max_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); + disp_ret = init_sam_dispinfo_4(p->mem_ctx, ctr->sam.info4, max_entries, enum_context, info->disp_info.disp_user_info); if (NT_STATUS_IS_ERR(disp_ret)) return disp_ret; break; case 0x5: - if (num_entries) { - if (!(ctr->sam.info5 = (SAM_DISPINFO_5 *)talloc_zero(p->mem_ctx,num_entries*sizeof(SAM_DISPINFO_5)))) + if (max_entries) { + if (!(ctr->sam.info5 = (SAM_DISPINFO_5 *)talloc_zero(p->mem_ctx,max_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); + disp_ret = init_sam_dispinfo_5(p->mem_ctx, ctr->sam.info5, max_entries, enum_context, info->disp_info.disp_group_info); if (NT_STATUS_IS_ERR(disp_ret)) return disp_ret; break; + default: ctr->sam.info = NULL; return NT_STATUS_INVALID_INFO_CLASS; } - DEBUG(5, ("_samr_query_dispinfo: %d\n", __LINE__)); + /* calculate the total size */ + /*total_data_size=info->disp_info.total_size+(info->disp_info.num_account*struct_size);*/ + total_data_size=info->disp_info.num_account*struct_size; - if (num_entries < orig_num_entries) - return STATUS_MORE_ENTRIES; + if (enum_context+max_entries < info->disp_info.num_account) + r_u->status = STATUS_MORE_ENTRIES; - init_samr_r_query_dispinfo(r_u, num_entries, data_size, q_u->switch_level, ctr, r_u->status); + DEBUG(5, ("_samr_query_dispinfo: %d\n", __LINE__)); + + init_samr_r_query_dispinfo(r_u, max_entries, total_data_size, temp_size, q_u->switch_level, ctr, r_u->status); return r_u->status; + } + /******************************************************************* samr_reply_query_aliasinfo ********************************************************************/ -- cgit From fff44cc7009da6db0cc6478e0e239324316b4550 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 21 Dec 2001 19:34:32 +0000 Subject: Use pdb_free_sam() to free a SAM_ACCOUNT struct, not safe_free(). There are pointers withing the SAM_ACCOUNT struct that also need freeing. Jeremy. (This used to be commit a7d099cc75f813b4010a5f313c3fa6e6e8284b6d) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1cd061369f..c3d4f826d4 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -75,7 +75,7 @@ static void free_samr_info(void *ptr) if (info->disp_info.user_dbloaded){ for (i=0; idisp_info.num_account; i++) - SAFE_FREE(info->disp_info.disp_user_info[i].sam); + pdb_free_sam(&info->disp_info.disp_user_info[i].sam); SAFE_FREE(info->disp_info.disp_user_info); } -- cgit From 5829284a07463aa560527b38b69570444160e019 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 21 Dec 2001 22:27:20 +0000 Subject: Fixup some DEBUG statements (0 -> 10). Jeremy. (This used to be commit bf65331cb49299189d35ad5834167ec24b3a1ecb) --- source3/rpc_server/srv_samr_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c3d4f826d4..5af797f1cb 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -124,7 +124,7 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) } if (!pdb_setsampwent(False)) { - DEBUG(0, ("get_sampwd_entries: Unable to open passdb.\n")); + DEBUG(0, ("load_sampwd_entries: Unable to open passdb.\n")); return NT_STATUS_ACCESS_DENIED; } @@ -142,7 +142,7 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) /* Realloc some memory for the array of ptr to the SAM_ACCOUNT structs */ if (info->disp_info.num_account % MAX_SAM_ENTRIES == 0) { - DEBUG(0,("load_sampwd_entries: allocating more memory\n")); + DEBUG(10,("load_sampwd_entries: allocating more memory\n")); pwd_array=(DISP_USER_INFO *)Realloc(info->disp_info.disp_user_info, @@ -172,7 +172,7 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) * note: the size calculated are smaller than the size sent on the wire * we add the SAM_ENTRY_x size later */ - DEBUG(0,("load_sampwd_entries: entry: %d size: %d total: %d\n", info->disp_info.num_account, info->disp_info.disp_user_info[info->disp_info.num_account].size,info->disp_info.total_size)); + DEBUG(10,("load_sampwd_entries: entry: %d size: %d total: %d\n", info->disp_info.num_account, info->disp_info.disp_user_info[info->disp_info.num_account].size,info->disp_info.total_size)); info->disp_info.num_account++; } -- cgit From 0e550b2c11bde9a05167b237fb9910e2beccd14c Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 21 Dec 2001 22:34:49 +0000 Subject: doesn't keep track of the struct's size we enumerate. W2K doesn't calculate them and always reply a size of 32 bytes whereas NT4 did the maths. Anyway, it looks like the clients don't complain. in query_dom_info() at level 2, return the real number of users and groups. That's the fix to the W95/98 userlist bug ! as W95/98 does a query_dom_info(2) followed by a query_disp_info(4) on the SAME context handle (err we call it an lsa policy handle ! plain wrong name), I was tempted to keep the snapshoot in memory, to prevent 2 full user db enumerations in a row and just have one shared. But if some client does the 2 calls on two different handles, we would have 2 copies in memory not free'ed before the samr_close(). We still have too many fixed constant and too many magic values in that code. And btw, I really hates how the sequence number is generated ! J.F. (This used to be commit c0178e1a03f8225e5b350feb8fcbfb02f43327b4) --- source3/rpc_server/srv_samr_nt.c | 147 ++++++++++++++++++++------------------- 1 file changed, 76 insertions(+), 71 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 5af797f1cb..a5c6f9a44f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -59,13 +59,10 @@ struct samr_info { /******************************************************************* Function to free the per handle data. ********************************************************************/ - -static void free_samr_info(void *ptr) +static void free_samr_db(struct samr_info *info) { int i; - struct samr_info *info=(struct samr_info *) ptr; - if (info->disp_info.group_dbloaded) { for (i=0; idisp_info.num_account; i++) SAFE_FREE(info->disp_info.disp_group_info[i].grp); @@ -79,7 +76,20 @@ static void free_samr_info(void *ptr) SAFE_FREE(info->disp_info.disp_user_info); } - + + info->disp_info.user_dbloaded=False; + info->disp_info.group_dbloaded=False; + info->disp_info.num_account=0; + info->disp_info.total_size=0; + info->disp_info.last_enum=0; +} + + +static void free_samr_info(void *ptr) +{ + struct samr_info *info=(struct samr_info *) ptr; + + free_samr_db(info); SAFE_FREE(ptr); } @@ -137,14 +147,12 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) DEBUG(5,(" acb_mask %x reject\n", acb_mask)); continue; } - DEBUG(0,("load_sampwd_entries: entry: %d\n", info->disp_info.num_account)); + DEBUG(11,("load_sampwd_entries: entry: %d\n", info->disp_info.num_account)); /* Realloc some memory for the array of ptr to the SAM_ACCOUNT structs */ if (info->disp_info.num_account % MAX_SAM_ENTRIES == 0) { DEBUG(10,("load_sampwd_entries: allocating more memory\n")); - - pwd_array=(DISP_USER_INFO *)Realloc(info->disp_info.disp_user_info, (info->disp_info.num_account+MAX_SAM_ENTRIES)*sizeof(DISP_USER_INFO)); @@ -157,22 +165,7 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) /* link the SAM_ACCOUNT to the array */ info->disp_info.disp_user_info[info->disp_info.num_account].sam=pwd; - /* calculate the size needed to store the data */ - len_sam_name = strlen(pdb_get_username(pwd)); - len_sam_full = strlen(pdb_get_fullname(pwd)); - len_sam_desc = strlen(pdb_get_acct_desc(pwd)); - - info->disp_info.disp_user_info[info->disp_info.num_account].size=len_sam_name+ - len_sam_full+ - len_sam_desc; - /* keep the total size up to date too */ - info->disp_info.total_size+=info->disp_info.disp_user_info[info->disp_info.num_account].size; - - /* - * note: the size calculated are smaller than the size sent on the wire - * we add the SAM_ENTRY_x size later - */ - DEBUG(10,("load_sampwd_entries: entry: %d size: %d total: %d\n", info->disp_info.num_account, info->disp_info.disp_user_info[info->disp_info.num_account].size,info->disp_info.total_size)); + DEBUG(10,("load_sampwd_entries: entry: %d\n", info->disp_info.num_account)); info->disp_info.num_account++; } @@ -184,7 +177,7 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) info->disp_info.user_dbloaded=True; info->disp_info.last_enum=0; - DEBUG(10,("load_sampwd_entries: done\n")); + DEBUG(12,("load_sampwd_entries: done\n")); return NT_STATUS_OK; } @@ -234,7 +227,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) info->disp_info.group_dbloaded=True; info->disp_info.last_enum=0; - DEBUG(10,("load_group_domain_entries: done\n")); + DEBUG(12,("load_group_domain_entries: done\n")); return NT_STATUS_OK; } @@ -1186,7 +1179,7 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_QUERY_DISPINFO *r_u) { struct samr_info *info = NULL; - uint32 struct_size=0; + uint32 struct_size=0x20; /* W2K always reply that, client doesn't care */ uint16 acb_mask; uint32 max_entries=q_u->max_entries; @@ -1234,29 +1227,11 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ */ /* Get what we need from the password database */ - switch (q_u->switch_level) { - case 0x1: - acb_mask = ACB_NORMAL; - struct_size=0x20; - break; - case 0x2: - acb_mask = ACB_WSTRUST; - struct_size=0x20; - break; - case 0x3: - struct_size=0x20; - break; - case 0x4: - acb_mask = ACB_NORMAL; - struct_size=0x20; - break; - case 0x5: - struct_size=0x20; - break; - default: - DEBUG(0,("_samr_query_dispinfo: Unknown info level (%u)\n", (unsigned int)q_u->switch_level )); - return NT_STATUS_INVALID_INFO_CLASS; - } + + if (q_u->switch_level==2) + acb_mask = ACB_WSTRUST; + else + acb_mask = ACB_NORMAL; /* Get what we need from the password database */ switch (q_u->switch_level) { @@ -1299,29 +1274,17 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ return NT_STATUS_OK; } - /* verify we won't overflow */ if (max_entries > info->disp_info.num_account-enum_context) { max_entries = info->disp_info.num_account-enum_context; DEBUG(5, ("samr_reply_query_dispinfo: only %d entries to return\n", max_entries)); } - - /* calculate the size */ - if (q_u->switch_level==3 || q_u->switch_level==5) - for (i=enum_context; (idisp_info.disp_group_info[i].size * 2;*/ - temp_size+=struct_size; - } + /* calculate the size and limit on the number of entries we will return */ + temp_size=(enum_context+max_entries)*struct_size; - else - for (i=enum_context; (idisp_info.disp_user_info[i].size * 2;*/ - temp_size+=struct_size; - } - - if (imax_size) { + max_entries=max_size/struct_size; DEBUG(5, ("samr_reply_query_dispinfo: buffer size limits to only %d entries\n", max_entries)); } @@ -1384,7 +1347,6 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ } /* calculate the total size */ - /*total_data_size=info->disp_info.total_size+(info->disp_info.num_account*struct_size);*/ total_data_size=info->disp_info.num_account*struct_size; if (enum_context+max_entries < info->disp_info.num_account) @@ -2113,6 +2075,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR_R_QUERY_DOMAIN_INFO *r_u) { + struct samr_info *info = NULL; SAM_UNK_CTR *ctr; uint32 min_pass_len,pass_hist,flag; time_t u_expire, u_min_age; @@ -2125,6 +2088,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA time_t u_logout; NTTIME nt_logout; + uint32 num_users=0, num_groups=0, num_aliases=0; if ((ctr = (SAM_UNK_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL) return NT_STATUS_NO_MEMORY; @@ -2136,7 +2100,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->domain_pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; switch (q_u->switch_value) { @@ -2154,8 +2118,27 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA flag, nt_expire, nt_min_age); break; case 0x02: + become_root(); + r_u->status=load_sampwd_entries(info, ACB_NORMAL); + unbecome_root(); + if (NT_STATUS_IS_ERR(r_u->status)) { + DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); + return r_u->status; + } + num_users=info->disp_info.num_account; + free_samr_db(info); + + r_u->status=load_group_domain_entries(info, &global_sam_sid); + if (NT_STATUS_IS_ERR(r_u->status)) { + DEBUG(5, ("_samr_query_dispinfo: load_group_domain_entries failed\n")); + return r_u->status; + } + num_groups=info->disp_info.num_account; + free_samr_db(info); + /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL)); + init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL), + num_users, num_groups, num_aliases); break; case 0x03: account_policy_get(AP_TIME_TO_LOGOUT, (int *)&u_logout); @@ -3868,6 +3851,7 @@ NTSTATUS _samr_unknown_2d(pipes_struct *p, SAMR_Q_UNKNOWN_2D *q_u, SAMR_R_UNKNOW NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOWN_2E *r_u) { + struct samr_info *info = NULL; SAM_UNK_CTR *ctr; uint32 min_pass_len,pass_hist,flag; time_t u_expire, u_min_age; @@ -3880,6 +3864,8 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW time_t u_logout; NTTIME nt_logout; + uint32 num_users=0, num_groups=0, num_aliases=0; + if ((ctr = (SAM_UNK_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL) return NT_STATUS_NO_MEMORY; @@ -3890,7 +3876,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW DEBUG(5,("_samr_unknown_2e: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->domain_pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; switch (q_u->switch_value) { @@ -3908,8 +3894,27 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW flag, nt_expire, nt_min_age); break; case 0x02: + become_root(); + r_u->status=load_sampwd_entries(info, ACB_NORMAL); + unbecome_root(); + if (NT_STATUS_IS_ERR(r_u->status)) { + DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); + return r_u->status; + } + num_users=info->disp_info.num_account; + free_samr_db(info); + + r_u->status=load_group_domain_entries(info, &global_sam_sid); + if (NT_STATUS_IS_ERR(r_u->status)) { + DEBUG(5, ("_samr_query_dispinfo: load_group_domain_entries failed\n")); + return r_u->status; + } + num_groups=info->disp_info.num_account; + free_samr_db(info); + /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL)); + init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL), + num_users, num_groups, num_aliases); break; case 0x03: account_policy_get(AP_TIME_TO_LOGOUT, (int *)&u_logout); -- cgit From 1acf4f67a26a8c51f250bef40630052fb2d4baff Mon Sep 17 00:00:00 2001 From: Jean-François Micouleau Date: Fri, 21 Dec 2001 22:54:53 +0000 Subject: added a copyright notice. J.F. (This used to be commit 87928c4d91940447191af4fe83a2be7ac3477361) --- source3/rpc_server/srv_samr.c | 1 + source3/rpc_server/srv_samr_nt.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 177ee51d25..35fc5dd904 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -6,6 +6,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. * Copyright (C) Marc Jacobsen 1999. + * Copyright (C) Jean François Micouleau 1998-2001. * * Split into interface and implementation modules by, * diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a5c6f9a44f..3f63df660b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -7,6 +7,7 @@ * Copyright (C) Paul Ashton 1997. * Copyright (C) Marc Jacobsen 1999. * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Jean François Micouleau 1998-2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -147,7 +148,6 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) DEBUG(5,(" acb_mask %x reject\n", acb_mask)); continue; } - DEBUG(11,("load_sampwd_entries: entry: %d\n", info->disp_info.num_account)); /* Realloc some memory for the array of ptr to the SAM_ACCOUNT structs */ if (info->disp_info.num_account % MAX_SAM_ENTRIES == 0) { -- cgit From e1e64a26fac829b17d448da1a46d6eb9f9e006a6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 21 Dec 2001 23:25:32 +0000 Subject: The jf_get_sampasswd_entries() is not used anymore. Jeremy. (This used to be commit bf1816099707b816c9b62ad5ab794dc49b833181) --- source3/rpc_server/srv_samr_nt.c | 335 --------------------------------------- 1 file changed, 335 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 3f63df660b..b6ed81407d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -311,341 +311,6 @@ static NTSTATUS get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, return NT_STATUS_OK; } -static NTSTATUS 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) -{ - 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)); - - if (!pdb_setsampwent(False)) { - DEBUG(0, ("jf_get_sampwd_entries: Unable to open passdb.\n")); - return NT_STATUS_ACCESS_DENIED; - } - - 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 && !(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(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(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 = 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 (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); - - 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) )); - - (*num_entries)++; - - pdb_reset_sam(pwd); - } - - pdb_endsampwent(); - - *total_entries = *num_entries; - - pdb_free_sam(&pwd); - - if (not_finished) - return STATUS_MORE_ENTRIES; - else - return NT_STATUS_OK; -} - -#if 0 /* This function appears to be unused! */ - -/******************************************************************* - 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 - map_username() function.) Since more than one DOS name can map - to the UNIX name, to reverse the mapping you have to specify - which corresponding DOS name you want; that's where the name_idx - parameter comes in. Returns the string requested or NULL if it - fails or can't complete the request for any reason. This doesn't - handle group names (starting with '@') or names starting with - '+' or '&'. If they are encountered, they are skipped. -********************************************************************/ - -static char *unmap_unixname(char *unix_user_name, int name_idx) -{ - char *mapfile = lp_username_map(); - char **lines; - static pstring tok; - int i; - - if (!*unix_user_name) return NULL; - if (!*mapfile) return NULL; - - lines = file_lines_load(mapfile, NULL); - if (!lines) { - DEBUG(0,("unmap_unixname: can't open username map %s\n", mapfile)); - return NULL; - } - - DEBUG(5,("unmap_unixname: scanning username map %s, index: %d\n", mapfile, name_idx)); - - for (i=0; lines[i]; i++) { - char *unixname = lines[i]; - char *dosname = strchr_m(unixname,'='); - - if (!dosname) - continue; - - *dosname++ = 0; - - while (isspace(*unixname)) - unixname++; - if ('!' == *unixname) { - unixname++; - while (*unixname && isspace(*unixname)) - unixname++; - } - - if (!*unixname || strchr_m("#;",*unixname)) - continue; - - if (strncmp(unixname, unix_user_name, strlen(unix_user_name))) - continue; - - /* We have matched the UNIX user name */ - - while(next_token(&dosname, tok, LIST_SEP, sizeof(tok))) { - if (!strchr_m("@&+", *tok)) { - name_idx--; - if (name_idx < 0 ) { - break; - } - } - } - - if (name_idx >= 0) { - DEBUG(0,("unmap_unixname: index too high - not that many DOS names\n")); - file_lines_free(lines); - return NULL; - } else { - file_lines_free(lines); - return tok; - } - } - - DEBUG(0,("unmap_unixname: Couldn't find the UNIX user name\n")); - file_lines_free(lines); - return NULL; -} - -#endif /* Unused function */ - -#if 0 /* This function seems to be not used anywhere! */ - -/******************************************************************* - This function sets up a list of users taken from the list of - users that UNIX knows about, as well as all the user names that - Samba maps to a valid UNIX user name. (This should work with - /etc/passwd or NIS.) -********************************************************************/ - -static BOOL get_passwd_entries(SAM_USER_INFO_21 *pw_buf, - int start_idx, - int *total_entries, int *num_entries, - int max_num_entries, - uint16 acb_mask) -{ - static struct passwd *pwd = NULL; - static uint32 pw_rid; - static BOOL orig_done = False; - static int current_idx = 0; - static int mapped_idx = 0; - char *sep; - - DEBUG(5, ("get_passwd_entries: retrieving a list of UNIX users\n")); - - (*num_entries) = 0; - (*total_entries) = 0; - - /* Skip all this stuff if we're in appliance mode */ - - if (lp_hide_local_users()) goto done; - - if (pw_buf == NULL) return False; - - if (current_idx == 0) { - sys_setpwent(); - } - - /* These two cases are inefficient, but should be called very rarely */ - /* they are the cases where the starting index isn't picking up */ - /* where we left off last time. It is efficient when it starts over */ - /* at zero though. */ - if (start_idx > current_idx) { - /* We aren't far enough; advance to start_idx */ - while (current_idx <= start_idx) { - char *unmap_name; - - if(!orig_done) { - if ((pwd = sys_getpwent()) == NULL) break; - current_idx++; - orig_done = True; - } - - while (((unmap_name = unmap_unixname(pwd->pw_name, mapped_idx)) != NULL) && - (current_idx < start_idx)) { - current_idx++; - mapped_idx++; - } - - if (unmap_name == NULL) { - orig_done = False; - mapped_idx = 0; - } - } - } else if (start_idx < current_idx) { - /* We are already too far; start over and advance to start_idx */ - sys_endpwent(); - sys_setpwent(); - current_idx = 0; - mapped_idx = 0; - orig_done = False; - while (current_idx < start_idx) { - char *unmap_name; - - if(!orig_done) { - if ((pwd = sys_getpwent()) == NULL) break; - current_idx++; - orig_done = True; - } - - while (((unmap_name = unmap_unixname(pwd->pw_name, mapped_idx)) != NULL) && - (current_idx < start_idx)) { - current_idx++; - mapped_idx++; - } - - if (unmap_name == NULL) { - orig_done = False; - mapped_idx = 0; - } - } - } - - sep = lp_winbind_separator(); - - /* now current_idx == start_idx */ - while ((*num_entries) < max_num_entries) { - int user_name_len; - char *unmap_name; - - /* This does the original UNIX user itself */ - if(!orig_done) { - if ((pwd = sys_getpwent()) == NULL) break; - - /* Don't enumerate winbind users as they are not local */ - - if (strchr_m(pwd->pw_name, *sep) != NULL) { - continue; - } - - user_name_len = strlen(pwd->pw_name); - - /* skip the trust account stored in the /etc/passwd file */ - if (pwd->pw_name[user_name_len-1]=='$') - continue; - - pw_rid = pdb_uid_to_user_rid(pwd->pw_uid); - ZERO_STRUCTP(&pw_buf[(*num_entries)]); - init_unistr2(&pw_buf[(*num_entries)].uni_user_name, pwd->pw_name, user_name_len); - init_uni_hdr(&pw_buf[(*num_entries)].hdr_user_name, user_name_len); - pw_buf[(*num_entries)].user_rid = pw_rid; - memset((char *)pw_buf[(*num_entries)].nt_pwd, '\0', 16); - - pw_buf[(*num_entries)].acb_info = ACB_NORMAL; - - DEBUG(5, ("get_passwd_entries: entry idx %d user %s, rid 0x%x\n", (*num_entries), pwd->pw_name, pw_rid)); - - (*num_entries)++; - (*total_entries)++; - current_idx++; - orig_done = True; - } - - /* This does all the user names that map to the UNIX user */ - while (((unmap_name = unmap_unixname(pwd->pw_name, mapped_idx)) != NULL) && - (*num_entries < max_num_entries)) { - user_name_len = strlen(unmap_name); - ZERO_STRUCTP(&pw_buf[(*num_entries)]); - init_unistr2(&pw_buf[(*num_entries)].uni_user_name, unmap_name, user_name_len); - init_uni_hdr(&pw_buf[(*num_entries)].hdr_user_name, user_name_len); - pw_buf[(*num_entries)].user_rid = pw_rid; - memset((char *)pw_buf[(*num_entries)].nt_pwd, '\0', 16); - - pw_buf[(*num_entries)].acb_info = ACB_NORMAL; - - DEBUG(5, ("get_passwd_entries: entry idx %d user %s, rid 0x%x\n", (*num_entries), pwd->pw_name, pw_rid)); - - (*num_entries)++; - (*total_entries)++; - current_idx++; - mapped_idx++; - } - - if (unmap_name == NULL) { - /* done with 'aliases', go on to next UNIX user */ - orig_done = False; - mapped_idx = 0; - } - } - - if (pwd == NULL) { - /* totally done, reset everything */ - sys_endpwent(); - current_idx = 0; - mapped_idx = 0; - } - -done: - return (*num_entries) > 0; -} - -#endif /* Unused function */ - /******************************************************************* _samr_close_hnd ********************************************************************/ -- cgit From 7478d27e70722b3c8f280a38ac4698e472db73a4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 21 Dec 2001 23:28:04 +0000 Subject: Removed unused variables. Jeremy. (This used to be commit 621fa227bdf6af15daa13f62287978dc2310c04c) --- source3/rpc_server/srv_samr_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b6ed81407d..6e25da1710 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -141,8 +141,6 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) for (pdb_init_sam(&pwd); pdb_getsampwent(pwd) == True; pwd=NULL, pdb_init_sam(&pwd) ) { - uint32 len_sam_name, len_sam_full, len_sam_desc; - if (acb_mask != 0 && !(pwd->acct_ctrl & acb_mask)) { pdb_free_sam(&pwd); DEBUG(5,(" acb_mask %x reject\n", acb_mask)); -- cgit From 04aff47c716a51a1039b44a81d6ff19eeaa09017 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 27 Dec 2001 06:38:04 +0000 Subject: moving SAM_ACCOUNT to include a bit field for initialized members (such as uid and gid). This way we will be able to keep ourselves from writing out default smb.conf settings when the admin doesn't want to, That part is not done yet. Tested compiles with ldap/tdb/smbpasswd. Tested connection with smbpasswd backend. oh...and smbpasswd doesn'y automatically expire accounts after 21 days from the last password change either now. Just ifdef'd out that code in build_sam_account(). Will merge updates into 2.2 as they are necessary. jerry (This used to be commit f0d43791157d8f04a13a07d029f203ad4384d317) --- source3/rpc_server/srv_pipe.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 4b3140b350..c97619c4b6 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -274,8 +274,8 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm auth_authsupplied_info *auth_info = NULL; auth_serversupplied_info *server_info = NULL; - uid_t *puid; - uid_t *pgid; + uid_t uid; + uid_t gid; DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); @@ -417,17 +417,17 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); * Store the UNIX credential data (uid/gid pair) in the pipe structure. */ - puid = pdb_get_uid(server_info->sam_account); - pgid = pdb_get_gid(server_info->sam_account); - - if (!puid || !pgid) { + if (!IS_SAM_UNIX_USER(server_info->sam_account)) { DEBUG(0,("Attempted authenticated pipe with invalid user. No uid/gid in SAM_ACCOUNT\n")); free_server_info(&server_info); return False; } - p->pipe_user.uid = *puid; - p->pipe_user.gid = *pgid; + uid = pdb_get_uid(server_info->sam_account); + gid = pdb_get_gid(server_info->sam_account); + + p->pipe_user.uid = uid; + p->pipe_user.gid = gid; /* Set up pipe user group membership. */ initialise_groups(p->pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); -- cgit From eb4e10115310b6ed23b92abac2e79454c80930b1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 31 Dec 2001 13:46:26 +0000 Subject: - portablitity fixes for cc -64 on irix - fixed gid* bug in rpc_server (This used to be commit 48aa90c48c5f0e3054c4acdc49668e222e7c0d36) --- source3/rpc_server/srv_lsa_nt.c | 1 - source3/rpc_server/srv_srvsvc_nt.c | 2 +- source3/rpc_server/srv_util.c | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 432f20a40c..9916b99c8a 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1116,7 +1116,6 @@ NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUER break; default: return NT_STATUS_INVALID_LEVEL; - break; } r_u->ptr=1; diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 06cbbaa2dc..57757e28b5 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1827,7 +1827,7 @@ NTSTATUS _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET r_u->disk_enum_ctr.unknown = 0; - r_u->disk_enum_ctr.disk_info_ptr = (uint32) r_u->disk_enum_ctr.disk_info; + r_u->disk_enum_ctr.disk_info_ptr = r_u->disk_enum_ctr.disk_info? 1 : 0; /*allow one DISK_INFO for null terminator*/ diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 5c781c20ae..14caf89e2f 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -86,7 +86,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui struct sys_grent *glist; struct sys_grent *grp; int i, num, cur_rid=0; - gid_t *gid; + gid_t gid; GROUP_MAP map; DOM_SID tmp_sid; fstring user_name; @@ -204,9 +204,9 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui goto done; } - DEBUG(10,("get_alias_user_groups: looking for gid %d of user %s\n", (int)*gid, user_name)); + DEBUG(10,("get_alias_user_groups: looking for gid %d of user %s\n", (int)gid, user_name)); - if(!get_group_from_gid(*gid, &map, MAPPING_WITHOUT_PRIV)) { + if(!get_group_from_gid(gid, &map, MAPPING_WITHOUT_PRIV)) { DEBUG(0,("get_alias_user_groups: gid of user %s doesn't exist. Check your /etc/passwd and /etc/group files\n", user_name)); goto done; } -- cgit From 120607cab1ccd5e10a26a7ef367c53e766ba4293 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 31 Dec 2001 22:37:51 +0000 Subject: Fixed enumeration of a large (<1500) users from a Samba PDC to a W2k member server. Firstly, use the same max enumeration size (0x400) as W2K uses, otherwise W2K won't ask for any more. Secondly, if a enumeration request with a non-zero offset comes in on a handle that hasn't started an enumeration, don't bitch about it (return NT_STATUS_UNSUCCESSFUL), just load the db on that handle and return at that offset. Jeremy. (This used to be commit 0b7da4a50ea02e28ab23e71de1e5f8b9194a9af3) --- source3/rpc_server/srv_samr_nt.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6e25da1710..2c599c9d79 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -901,9 +901,6 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ case 0x1: case 0x2: case 0x4: - if (enum_context!=0 && info->disp_info.user_dbloaded==False) - return NT_STATUS_UNSUCCESSFUL; - become_root(); r_u->status=load_sampwd_entries(info, acb_mask); unbecome_root(); @@ -914,9 +911,6 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ break; case 0x3: case 0x5: - if (enum_context!=0 && info->disp_info.group_dbloaded==False) - return NT_STATUS_UNSUCCESSFUL; - r_u->status = load_group_domain_entries(info, &info->sid); if (NT_STATUS_IS_ERR(r_u->status)) return r_u->status; -- cgit From 38851c64d916c89d494380d13fed8749ee56158b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 31 Dec 2001 23:24:48 +0000 Subject: last_enum not used. Jeremy. (This used to be commit efbec935fe727d5d5bd852c7bae9baf92df18686) --- source3/rpc_server/srv_samr_nt.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2c599c9d79..17d5f2eb6a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -45,7 +45,6 @@ typedef struct _disp_info { BOOL group_dbloaded; uint32 num_account; uint32 total_size; - uint32 last_enum; DISP_USER_INFO *disp_user_info; DISP_GROUP_INFO *disp_group_info; } DISP_INFO; @@ -82,7 +81,6 @@ static void free_samr_db(struct samr_info *info) info->disp_info.group_dbloaded=False; info->disp_info.num_account=0; info->disp_info.total_size=0; - info->disp_info.last_enum=0; } @@ -173,7 +171,6 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) /* the snapshoot is in memory, we're ready to enumerate fast */ info->disp_info.user_dbloaded=True; - info->disp_info.last_enum=0; DEBUG(12,("load_sampwd_entries: done\n")); @@ -223,7 +220,6 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) /* the snapshoot is in memory, we're ready to enumerate fast */ info->disp_info.group_dbloaded=True; - info->disp_info.last_enum=0; DEBUG(12,("load_group_domain_entries: done\n")); -- cgit From 6694109c04dbb97124f4ee73d1534219ed33f2ae Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 1 Jan 2002 00:18:47 +0000 Subject: Named constants are always much better than magic numbers... (I defined the constants when I put in 'net rpc shutdown') Andrew Bartlett (This used to be commit 4d90cc1d991f3894b9f39b2a75078148834701bb) --- source3/rpc_server/srv_reg_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index d934083e6b..5901a783b9 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -202,9 +202,9 @@ NTSTATUS _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u /* timeout */ snprintf(timeout, sizeof(timeout), "%d", q_u->timeout); /* reboot */ - snprintf(r, sizeof(r), (q_u->flags & 0x100)?SHUTDOWN_R_STRING:""); + snprintf(r, sizeof(r), (q_u->flags & REG_REBOOT_ON_SHUTDOWN)?SHUTDOWN_R_STRING:""); /* force */ - snprintf(f, sizeof(f), (q_u->flags & 0x001)?SHUTDOWN_F_STRING:""); + snprintf(f, sizeof(f), (q_u->flags & REG_FORCE_SHUTDOWN)?SHUTDOWN_F_STRING:""); pstrcpy(shutdown_script, lp_shutdown_script()); -- cgit From 71f982c9f2f450d660406d6015ff9756bf317218 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 2 Jan 2002 07:27:33 +0000 Subject: Make user enumeration work for w2k and win9x. This means different return sizes depending on client bugs. This sucks :-(. Jeremy. (This used to be commit f6592628eb526c487069bb3fcd809aca930e668e) --- source3/rpc_server/srv_samr_nt.c | 156 +++++++++++++++++++++------------------ 1 file changed, 85 insertions(+), 71 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 17d5f2eb6a..febbf21f67 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -6,7 +6,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. * Copyright (C) Marc Jacobsen 1999. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Jeremy Allison 2001-2002. * Copyright (C) Jean François Micouleau 1998-2001. * * This program is free software; you can redistribute it and/or modify @@ -42,10 +42,10 @@ extern rid_name builtin_alias_rids[]; typedef struct _disp_info { BOOL user_dbloaded; - BOOL group_dbloaded; - uint32 num_account; - uint32 total_size; + uint32 num_user_account; DISP_USER_INFO *disp_user_info; + BOOL group_dbloaded; + uint32 num_group_account; DISP_GROUP_INFO *disp_group_info; } DISP_INFO; @@ -56,6 +56,28 @@ struct samr_info { DISP_INFO disp_info; }; +/******************************************************************* + Create a samr_info struct. +********************************************************************/ + +static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) +{ + struct samr_info *info; + fstring sid_str; + + if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) + return NULL; + + ZERO_STRUCTP(info); + if (psid) { + DEBUG(10,("get_samr_info_by_sid: created new info for sid %s\n", sid_to_string(sid_str, psid) )); + sid_copy( &info->sid, psid); + } else { + DEBUG(10,("get_samr_info_by_sid: created new info for NULL sid.\n")); + } + return info; +} + /******************************************************************* Function to free the per handle data. ********************************************************************/ @@ -64,14 +86,14 @@ static void free_samr_db(struct samr_info *info) int i; if (info->disp_info.group_dbloaded) { - for (i=0; idisp_info.num_account; i++) + for (i=0; idisp_info.num_group_account; i++) SAFE_FREE(info->disp_info.disp_group_info[i].grp); SAFE_FREE(info->disp_info.disp_group_info); } if (info->disp_info.user_dbloaded){ - for (i=0; idisp_info.num_account; i++) + for (i=0; idisp_info.num_user_account; i++) pdb_free_sam(&info->disp_info.disp_user_info[i].sam); SAFE_FREE(info->disp_info.disp_user_info); @@ -79,8 +101,8 @@ static void free_samr_db(struct samr_info *info) info->disp_info.user_dbloaded=False; info->disp_info.group_dbloaded=False; - info->disp_info.num_account=0; - info->disp_info.total_size=0; + info->disp_info.num_group_account=0; + info->disp_info.num_user_account=0; } @@ -89,7 +111,7 @@ static void free_samr_info(void *ptr) struct samr_info *info=(struct samr_info *) ptr; free_samr_db(info); - SAFE_FREE(ptr); + SAFE_FREE(info); } /******************************************************************* @@ -114,8 +136,10 @@ static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) if (!sam_pass) return; - if (sam_pass->lm_pw) memset(sam_pass->lm_pw, '\0', 16); - if (sam_pass->nt_pw) memset(sam_pass->nt_pw, '\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); } @@ -146,11 +170,11 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) } /* Realloc some memory for the array of ptr to the SAM_ACCOUNT structs */ - if (info->disp_info.num_account % MAX_SAM_ENTRIES == 0) { + if (info->disp_info.num_user_account % MAX_SAM_ENTRIES == 0) { DEBUG(10,("load_sampwd_entries: allocating more memory\n")); pwd_array=(DISP_USER_INFO *)Realloc(info->disp_info.disp_user_info, - (info->disp_info.num_account+MAX_SAM_ENTRIES)*sizeof(DISP_USER_INFO)); + (info->disp_info.num_user_account+MAX_SAM_ENTRIES)*sizeof(DISP_USER_INFO)); if (pwd_array==NULL) return NT_STATUS_NO_MEMORY; @@ -159,11 +183,11 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) } /* link the SAM_ACCOUNT to the array */ - info->disp_info.disp_user_info[info->disp_info.num_account].sam=pwd; + info->disp_info.disp_user_info[info->disp_info.num_user_account].sam=pwd; - DEBUG(10,("load_sampwd_entries: entry: %d\n", info->disp_info.num_account)); + DEBUG(10,("load_sampwd_entries: entry: %d\n", info->disp_info.num_user_account)); - info->disp_info.num_account++; + info->disp_info.num_user_account++; } pdb_endsampwent(); @@ -194,9 +218,9 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); - info->disp_info.num_account=group_entries; + info->disp_info.num_group_account=group_entries; - grp_array=(DISP_GROUP_INFO *)malloc(info->disp_info.num_account*sizeof(DISP_GROUP_INFO)); + grp_array=(DISP_GROUP_INFO *)malloc(info->disp_info.num_group_account*sizeof(DISP_GROUP_INFO)); if (group_entries!=0 && grp_array==NULL) { SAFE_FREE(map); @@ -337,12 +361,9 @@ NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN return NT_STATUS_INVALID_HANDLE; /* associate the domain SID with the (unique) handle. */ - if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) + if ((info = get_samr_info_by_sid(&q_u->dom_sid.sid))==NULL) return NT_STATUS_NO_MEMORY; - ZERO_STRUCTP(info); - info->sid = q_u->dom_sid.sid; - /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, &r_u->domain_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -847,8 +868,12 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ SAM_DISPINFO_CTR *ctr; uint32 temp_size=0, total_data_size=0; - uint32 i; NTSTATUS disp_ret; + uint32 num_account = 0; + enum remote_arch_types ra_type = get_remote_arch(); + int max_sam_entries; + + max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K; DEBUG(5, ("samr_reply_query_dispinfo: %d\n", __LINE__)); r_u->status = NT_STATUS_OK; @@ -904,12 +929,14 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); return r_u->status; } + num_account = info->disp_info.num_user_account; break; case 0x3: case 0x5: r_u->status = load_group_domain_entries(info, &info->sid); if (NT_STATUS_IS_ERR(r_u->status)) return r_u->status; + num_account = info->disp_info.num_group_account; break; default: DEBUG(0,("_samr_query_dispinfo: Unknown info level (%u)\n", (unsigned int)q_u->switch_level )); @@ -917,19 +944,19 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ } /* first limit the number of entries we will return */ - if(max_entries > MAX_SAM_ENTRIES) { - DEBUG(5, ("samr_reply_query_dispinfo: client requested %d entries, limiting to %d\n", max_entries, MAX_SAM_ENTRIES)); - max_entries = MAX_SAM_ENTRIES; + if(max_entries > max_sam_entries) { + DEBUG(5, ("samr_reply_query_dispinfo: client requested %d entries, limiting to %d\n", max_entries, max_sam_entries)); + max_entries = max_sam_entries; } - if (enum_context > info->disp_info.num_account) { + if (enum_context > num_account) { DEBUG(5, ("samr_reply_query_dispinfo: enumeration handle over total entries\n")); return NT_STATUS_OK; } /* verify we won't overflow */ - if (max_entries > info->disp_info.num_account-enum_context) { - max_entries = info->disp_info.num_account-enum_context; + if (max_entries > num_account-enum_context) { + max_entries = num_account-enum_context; DEBUG(5, ("samr_reply_query_dispinfo: only %d entries to return\n", max_entries)); } @@ -1000,9 +1027,9 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ } /* calculate the total size */ - total_data_size=info->disp_info.num_account*struct_size; + total_data_size=num_account*struct_size; - if (enum_context+max_entries < info->disp_info.num_account) + if (enum_context+max_entries < num_account) r_u->status = STATUS_MORE_ENTRIES; DEBUG(5, ("_samr_query_dispinfo: %d\n", __LINE__)); @@ -1013,7 +1040,6 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ } - /******************************************************************* samr_reply_query_aliasinfo ********************************************************************/ @@ -1380,12 +1406,9 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN 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) + if ((info = get_samr_info_by_sid(&sid)) == NULL) 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)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -1778,7 +1801,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); return r_u->status; } - num_users=info->disp_info.num_account; + num_users=info->disp_info.num_user_account; free_samr_db(info); r_u->status=load_group_domain_entries(info, &global_sam_sid); @@ -1786,7 +1809,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA DEBUG(5, ("_samr_query_dispinfo: load_group_domain_entries failed\n")); return r_u->status; } - num_groups=info->disp_info.num_account; + num_groups=info->disp_info.num_group_account; free_samr_db(info); /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ @@ -1961,7 +1984,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ } /* associate the user's SID with the new handle. */ - if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) { + if ((info = get_samr_info_by_sid(&sid)) == NULL) { pdb_free_sam(&sam_pass); return NT_STATUS_NO_MEMORY; } @@ -1996,10 +2019,9 @@ NTSTATUS _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CO 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) + if ((info = get_samr_info_by_sid(NULL)) == NULL) return NT_STATUS_NO_MEMORY; - ZERO_STRUCTP(info); info->status = q_u->unknown_0; /* get a (unique) handle. open a policy on it. */ @@ -2022,10 +2044,9 @@ NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u 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) + if ((info = get_samr_info_by_sid(NULL)) == NULL) return NT_STATUS_NO_MEMORY; - ZERO_STRUCTP(info); info->status = q_u->access_mask; /* get a (unique) handle. open a policy on it. */ @@ -2147,12 +2168,9 @@ NTSTATUS _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OP */ /* associate the user's SID with the new handle. */ - if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) + if ((info = get_samr_info_by_sid(&sid)) == NULL) 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, alias_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -3229,18 +3247,16 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); /* add the group to the mapping table */ + sid_copy(&info_sid, &global_sam_sid); + sid_append_rid(&info_sid, r_u->rid); + sid_to_string(sid_string, &info_sid); + if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_DOM_GRP, name, NULL, priv_set, PR_ACCESS_FROM_NETWORK)) return NT_STATUS_ACCESS_DENIED; - if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) + if ((info = get_samr_info_by_sid(&info_sid)) == NULL) return NT_STATUS_NO_MEMORY; - ZERO_STRUCTP(info); - - sid_copy(&info_sid, &global_sam_sid); - sid_append_rid(&info->sid, r_u->rid); - sid_to_string(sid_string, &info->sid); - /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, &r_u->pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -3255,6 +3271,7 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, SAMR_R_CREATE_DOM_ALIAS *r_u) { DOM_SID dom_sid; + DOM_SID info_sid; fstring name; fstring sid_string; struct group *grp; @@ -3287,19 +3304,17 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); - if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) - return NT_STATUS_NO_MEMORY; - - ZERO_STRUCTP(info); - - sid_copy(&info->sid, &global_sam_sid); - sid_append_rid(&info->sid, r_u->rid); - sid_to_string(sid_string, &info->sid); + sid_copy(&info_sid, &global_sam_sid); + sid_append_rid(&info_sid, r_u->rid); + sid_to_string(sid_string, &info_sid); /* add the group to the mapping table */ if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_ALIAS, name, NULL, priv_set, PR_ACCESS_FROM_NETWORK)) return NT_STATUS_ACCESS_DENIED; + if ((info = get_samr_info_by_sid(&info_sid)) == NULL) + return NT_STATUS_NO_MEMORY; + /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, &r_u->alias_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -3455,6 +3470,7 @@ NTSTATUS _samr_get_dom_pwinfo(pipes_struct *p, SAMR_Q_GET_DOM_PWINFO *q_u, SAMR_ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_GROUP *r_u) { DOM_SID sid; + DOM_SID info_sid; GROUP_MAP map; struct samr_info *info; fstring sid_string; @@ -3466,14 +3482,12 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G if (!sid_equal(&sid, &global_sam_sid)) return NT_STATUS_ACCESS_DENIED; - if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) - return NT_STATUS_NO_MEMORY; - - ZERO_STRUCTP(info); + sid_copy(&info_sid, &global_sam_sid); + sid_append_rid(&info_sid, q_u->rid_group); + sid_to_string(sid_string, &info_sid); - sid_copy(&info->sid, &global_sam_sid); - sid_append_rid(&info->sid, q_u->rid_group); - sid_to_string(sid_string, &info->sid); + if ((info = get_samr_info_by_sid(&info_sid)) == NULL) + return NT_STATUS_NO_MEMORY; DEBUG(10, ("_samr_open_group:Opening SID: %s\n", sid_string)); @@ -3554,7 +3568,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); return r_u->status; } - num_users=info->disp_info.num_account; + num_users=info->disp_info.num_user_account; free_samr_db(info); r_u->status=load_group_domain_entries(info, &global_sam_sid); @@ -3562,7 +3576,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW DEBUG(5, ("_samr_query_dispinfo: load_group_domain_entries failed\n")); return r_u->status; } - num_groups=info->disp_info.num_account; + num_groups=info->disp_info.num_group_account; free_samr_db(info); /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ -- cgit From a3f891dbd2e9ee1681e3c8295cd62a877c727d4f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 2 Jan 2002 07:41:54 +0000 Subject: Actually enforce the passdb API. Thou shalt not reference SAM_ACCOUNT members directly - always use pdb_get/pdb_set. This is achived by making the whole of SAM_ACCOUNT have a .private member, where the real members live. This caught a pile of examples, and these have beeen fixed. The pdb_get..() functions are 'const' (have been for some time) and this required a few small changes to constify other functions. I've also added some debugs to the pdb get and set, they can be removed if requested. I've rewritten the copy_id2x_to_sam_pass() functions to use the new passdb interface, but I need the flags info to do it properly. The pdb_free_sam() funciton now blanks out the LM and NT hashes, and as such I have removed many extra 'samr_clear_sam_passwd(smbpass)' calls as a result. Finally, any and all testing is always appriciated - but the basics seem to work. Andrew Bartlett (This used to be commit d3dd28f6c443187b8d820d5a39c7c5b3be2fa95c) --- source3/rpc_server/srv_samr_nt.c | 46 ++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 25 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index febbf21f67..a54bf0d175 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -133,13 +133,14 @@ static void samr_clear_passwd_fields( SAM_USER_INFO_21 *pass, int num_entries) static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) { + if (!sam_pass) return; - if (sam_pass->lm_pw) - memset(sam_pass->lm_pw, '\0', 16); - if (sam_pass->nt_pw) - memset(sam_pass->nt_pw, '\0', 16); + /* These now zero out the old password */ + + pdb_set_lanman_passwd(sam_pass, NULL); + pdb_set_nt_passwd(sam_pass, NULL); } @@ -163,7 +164,7 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) for (pdb_init_sam(&pwd); pdb_getsampwent(pwd) == True; pwd=NULL, pdb_init_sam(&pwd) ) { - if (acb_mask != 0 && !(pwd->acct_ctrl & acb_mask)) { + if (acb_mask != 0 && !(pdb_get_acct_ctrl(pwd) & acb_mask)) { pdb_free_sam(&pwd); DEBUG(5,(" acb_mask %x reject\n", acb_mask)); continue; @@ -295,7 +296,7 @@ static NTSTATUS get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, 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; + 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. */ @@ -307,7 +308,7 @@ static NTSTATUS get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, 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)) { + if (acb_mask == 0 || (pdb_get_acct_ctrl(pwd) & acb_mask)) { DEBUG(5,(" acb_mask %x accepts\n", acb_mask)); (*num_entries)++; } else { @@ -1394,7 +1395,6 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN return NT_STATUS_NO_SUCH_USER; } - samr_clear_sam_passwd(sampass); pdb_free_sam(&sampass); /* Get the domain SID stored in the domain policy */ @@ -1447,7 +1447,6 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) ZERO_STRUCTP(id10); init_sam_user_info10(id10, pdb_get_acct_ctrl(smbpass) ); - samr_clear_sam_passwd(smbpass); pdb_free_sam(&smbpass); return True; @@ -1723,13 +1722,11 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S unbecome_root(); if (ret == False) { - samr_clear_sam_passwd(sam_pass); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } if(!get_domain_user_groups(p->mem_ctx, &num_groups, &gids, sam_pass)) { - samr_clear_sam_passwd(sam_pass); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_GROUP; } @@ -1739,7 +1736,6 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__)); - samr_clear_sam_passwd(sam_pass); pdb_free_sam(&sam_pass); return r_u->status; @@ -1998,7 +1994,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ return NT_STATUS_OBJECT_NAME_NOT_FOUND; } - r_u->user_rid=sam_pass->user_rid; + r_u->user_rid=pdb_get_user_rid(sam_pass); r_u->unknown_0 = 0x000703ff; pdb_free_sam(&sam_pass); @@ -2897,21 +2893,21 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE /* check if the user exists before trying to remove it from the group */ pdb_init_sam(&sam_pass); if(!pdb_getsampwrid(sam_pass, rid)) { - DEBUG(5,("_samr_del_aliasmem:User %s doesn't exist.\n", sam_pass->username)); + DEBUG(5,("_samr_del_aliasmem:User %s doesn't exist.\n", pdb_get_username(sam_pass))); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } /* if the user is not in the group */ - if(!user_in_group_list(sam_pass->username, grp_name)) { + if(!user_in_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_MEMBER_IN_ALIAS; } - smb_delete_user_group(grp_name, sam_pass->username); + smb_delete_user_group(grp_name, pdb_get_username(sam_pass)); /* check if the user has been removed then ... */ - if(user_in_group_list(sam_pass->username, grp_name)) { + if(user_in_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_MEMBER_NOT_IN_ALIAS; /* don't know what to reply else */ } @@ -3016,21 +3012,21 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE /* check if the user exists before trying to remove it from the group */ pdb_init_sam(&sam_pass); if(!pdb_getsampwrid(sam_pass, rid)) { - DEBUG(5,("User %s doesn't exist.\n", sam_pass->username)); + DEBUG(5,("User %s doesn't exist.\n", pdb_get_username(sam_pass))); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } /* if the user is not in the group */ - if(!user_in_group_list(sam_pass->username, grp_name)) { + if(!user_in_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_MEMBER_NOT_IN_GROUP; } - smb_delete_user_group(grp_name, sam_pass->username); + smb_delete_user_group(grp_name, pdb_get_username(sam_pass)); /* check if the user has been removed then ... */ - if(user_in_group_list(sam_pass->username, grp_name)) { + if(user_in_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_ACCESS_DENIED; /* don't know what to reply else */ } @@ -3064,7 +3060,7 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM /* check if the user exists before trying to delete */ pdb_init_sam(&sam_pass); if(!pdb_getsampwrid(sam_pass, rid)) { - DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n", sam_pass->username)); + DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n", pdb_get_username(sam_pass))); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } @@ -3075,11 +3071,11 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM * as the script is not necessary present * and maybe the sysadmin doesn't want to delete the unix side */ - smb_delete_user(sam_pass->username); + smb_delete_user(pdb_get_username(sam_pass)); /* and delete the samba side */ - if (!pdb_delete_sam_account(sam_pass->username)) { - DEBUG(5,("_samr_delete_dom_user:Failed to delete entry for user %s.\n", sam_pass->username)); + if (!pdb_delete_sam_account(pdb_get_username(sam_pass))) { + DEBUG(5,("_samr_delete_dom_user:Failed to delete entry for user %s.\n", pdb_get_username(sam_pass))); pdb_free_sam(&sam_pass); return NT_STATUS_CANNOT_DELETE; } -- cgit From eca99f5c226f9518d1ab5c0ba3e586e3d59564d7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 3 Jan 2002 22:48:48 +0000 Subject: Fixed nasty cast of tdb_delete in traversals. Jeremy. (This used to be commit a0cdec3acc82d1ce0292fadd4b8dac23638450f3) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 57757e28b5..f37096fec3 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -136,7 +136,7 @@ BOOL share_info_db_init(void) /* handle a Samba upgrade */ tdb_lock_bystring(share_tdb, vstring); if (tdb_fetch_int(share_tdb, vstring) != SHARE_DATABASE_VERSION) { - tdb_traverse(share_tdb, (tdb_traverse_func)tdb_delete, NULL); + tdb_traverse(share_tdb, tdb_traverse_delete_fn, NULL); tdb_store_int(share_tdb, vstring, SHARE_DATABASE_VERSION); } tdb_unlock_bystring(share_tdb, vstring); -- cgit From 2e28f8ff0e3bb50ac5b2742c7678c39cb65bcd95 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 5 Jan 2002 04:55:41 +0000 Subject: I've decided to move the auth code around a bit more... The auth_authsupplied_info typedef is now just a plain struct - auth_context, but it has been modified to contain the function pointers to the rest of the auth subsystem's components. (Who needs non-static functions anyway?) In working all this mess out, I fixed a number of memory leaks and moved the entire auth subsystem over to talloc(). Note that the TALLOC_CTX attached to the auth_context can be rather long-lived, it is provided for things that are intended to live as long. (The global_negprot_auth_context lasts the whole life of the smbd). I've also adjusted a few things in auth_domain.c, mainly passing the domain as a paramater to a few functions instead of looking up lp_workgroup(). I'm hopign to make this entire thing a bit more trusted domains (as PDC) freindly in the near future. Other than that, I moved a bit of the code around, hence the rather messy diff. Andrew Bartlett (This used to be commit 12f5515f556cf39fea98134fe3e2ac4540501048) --- source3/rpc_server/srv_netlog_nt.c | 62 +++++++++++++++++++++----------------- source3/rpc_server/srv_pipe.c | 8 ++--- 2 files changed, 39 insertions(+), 31 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 634e2540fa..fbab46022c 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -568,19 +568,24 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * switch (ctr->switch_value) { case NET_LOGON_TYPE: { - auth_authsupplied_info *auth_info = NULL; - make_auth_info_fixed(&auth_info, ctr->auth.id2.lm_chal); + struct auth_context *auth_context = NULL; + if (!NT_STATUS_IS_OK(status = make_auth_context_fixed(&auth_context, ctr->auth.id2.lm_chal))) { + return status; + } + /* Standard challenge/response authenticaion */ - make_user_info_netlogon_network(&user_info, - nt_username, nt_domain, - nt_workstation, - ctr->auth.id2.lm_chal_resp.buffer, - ctr->auth.id2.lm_chal_resp.str_str_len, - ctr->auth.id2.nt_chal_resp.buffer, - ctr->auth.id2.nt_chal_resp.str_str_len); - - status = check_password(user_info, auth_info, &server_info); - free_auth_info(&auth_info); + if (!make_user_info_netlogon_network(&user_info, + nt_username, nt_domain, + nt_workstation, + ctr->auth.id2.lm_chal_resp.buffer, + ctr->auth.id2.lm_chal_resp.str_str_len, + ctr->auth.id2.nt_chal_resp.buffer, + ctr->auth.id2.nt_chal_resp.str_str_len)) { + status = NT_STATUS_NO_MEMORY; + } else { + status = auth_context->check_ntlm_password(auth_context, user_info, &server_info); + } + auth_context->free(&auth_context); break; } @@ -590,23 +595,26 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * convert this to chellange/responce for the auth subsystem to chew on */ { - auth_authsupplied_info *auth_info = NULL; - DATA_BLOB chal; - if (!make_auth_info_subsystem(&auth_info)) { - return NT_STATUS_NO_MEMORY; + struct auth_context *auth_context = NULL; + const uint8 *chal; + if (!NT_STATUS_IS_OK(status = make_auth_context_subsystem(&auth_context))) { + return status; } - chal = auth_get_challenge(auth_info); - - make_user_info_netlogon_interactive(&user_info, - nt_username, nt_domain, - nt_workstation, chal.data, - ctr->auth.id1.lm_owf.data, - ctr->auth.id1.nt_owf.data, - p->dc.sess_key); - status = check_password(user_info, auth_info, &server_info); - data_blob_free(&chal); - free_auth_info(&auth_info); + chal = auth_context->get_ntlm_challenge(auth_context); + + if (!make_user_info_netlogon_interactive(&user_info, + nt_username, nt_domain, + nt_workstation, chal, + ctr->auth.id1.lm_owf.data, + ctr->auth.id1.nt_owf.data, + p->dc.sess_key)) { + status = NT_STATUS_NO_MEMORY; + } else { + status = auth_context->check_ntlm_password(auth_context, user_info, &server_info); + } + + auth_context->free(&auth_context); break; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index c97619c4b6..36ca7e0686 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -270,8 +270,8 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm NTSTATUS nt_status; + struct auth_context *auth_context = NULL; auth_usersupplied_info *user_info = NULL; - auth_authsupplied_info *auth_info = NULL; auth_serversupplied_info *server_info = NULL; uid_t uid; @@ -345,7 +345,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm } - make_auth_info_fixed(&auth_info, (uchar*)p->challenge); + make_auth_context_fixed(&auth_context, (uchar*)p->challenge); if (!make_user_info_netlogon_network(&user_info, user_name, domain, wks, @@ -355,9 +355,9 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm return False; } - nt_status = check_password(user_info, auth_info, &server_info); + nt_status = auth_context->check_ntlm_password(auth_context, user_info, &server_info); - free_auth_info(&auth_info); + auth_context->free(&auth_context); free_user_info(&user_info); p->ntlmssp_auth_validated = NT_STATUS_IS_OK(nt_status); -- cgit From 4702494dce15d4158fd17720d843ff5211ce1715 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 8 Jan 2002 00:46:56 +0000 Subject: Added get_called_name() function, which replaces global_myname in printing code (one less global, hurrah !) - to allow NetBIOS aliasing to be used with point and print. Jeremy. (This used to be commit 10d72f0b01e5950c667f3f73dff1b4da5b675ea3) --- source3/rpc_server/srv_spoolss_nt.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3fe21eb968..96f44c4b8b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -29,8 +29,6 @@ #include "includes.h" -extern pstring global_myname; - #ifndef MAX_OPEN_PRINTER_EXS #define MAX_OPEN_PRINTER_EXS 50 #endif @@ -1447,7 +1445,7 @@ static void spoolss_notify_server_name(int snum, pstring temp_name, temp; uint32 len; - slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname); + slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", get_called_name()); len = rpcstr_push(temp, temp_name, sizeof(temp)-2, STR_TERMINATE); @@ -2573,7 +2571,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) init_unistr(&printer->printername, chaine); - slprintf(chaine,sizeof(chaine)-1,"\\\\%s", global_myname); + slprintf(chaine,sizeof(chaine)-1,"\\\\%s", get_called_name()); init_unistr(&printer->servername, chaine); printer->cjobs = count; @@ -2641,12 +2639,12 @@ static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int if (*ntprinter->info_2->comment == '\0') { init_unistr(&printer->comment, lp_comment(snum)); - slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",global_myname, ntprinter->info_2->printername, + slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",get_called_name(), ntprinter->info_2->printername, ntprinter->info_2->drivername, lp_comment(snum)); } else { init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ - slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",global_myname, ntprinter->info_2->printername, + slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",get_called_name(), ntprinter->info_2->printername, ntprinter->info_2->drivername, ntprinter->info_2->comment); } @@ -2981,8 +2979,8 @@ static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, *returned=1; - slprintf(printername, sizeof(printername)-1,"Windows NT Remote Printers!!\\\\%s", global_myname); - slprintf(desc, sizeof(desc)-1,"%s", global_myname); + slprintf(printername, sizeof(printername)-1,"Windows NT Remote Printers!!\\\\%s", get_called_name()); + slprintf(desc, sizeof(desc)-1,"%s", get_called_name()); slprintf(comment, sizeof(comment)-1, "Logged on Domain"); init_unistr(&printer->description, desc); @@ -3871,7 +3869,7 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ *servermajorversion=0; *serverminorversion=0; - pstrcpy(servername, global_myname); + pstrcpy(servername, get_called_name()); unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); if (!get_printer_snum(p, handle, &snum)) @@ -4200,9 +4198,9 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) info->servername, info->printername, info->sharename, info->portname, info->drivername, info->comment, info->location)); /* we force some elements to "correct" values */ - slprintf(info->servername, sizeof(info->servername)-1, "\\\\%s", global_myname); + slprintf(info->servername, sizeof(info->servername)-1, "\\\\%s", get_called_name()); slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s", - global_myname, lp_servicename(snum)); + get_called_name(), lp_servicename(snum)); fstrcpy(info->sharename, lp_servicename(snum)); info->attributes = PRINTER_ATTRIBUTE_SHARED \ | PRINTER_ATTRIBUTE_LOCAL \ @@ -4226,7 +4224,7 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) /* build driver path... only 9X architecture is needed for legacy reasons */ slprintf(driverlocation, sizeof(driverlocation)-1, "\\\\%s\\print$\\WIN40\\0", - global_myname); + get_called_name()); /* change \ to \\ for the shell */ all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring)); @@ -4704,7 +4702,7 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, struct tm *t; t=gmtime(&queue->time); - slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname); + slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", get_called_name()); job_info->jobid=queue->job; init_unistr(&job_info->printername, lp_servicename(snum)); @@ -4733,11 +4731,11 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, struct tm *t; t=gmtime(&queue->time); - slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname); + slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", get_called_name()); job_info->jobid=queue->job; - slprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", global_myname, ntprinter->info_2->printername); + slprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", get_called_name(), ntprinter->info_2->printername); init_unistr(&job_info->printername, chaine); @@ -5251,7 +5249,7 @@ WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS buffer = r_u->buffer; DEBUG(4,("_spoolss_enumprinterdrivers\n")); - fstrcpy(servername, global_myname); + fstrcpy(servername, get_called_name()); *needed=0; *returned=0; @@ -5752,7 +5750,7 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ return WERR_ACCESS_DENIED; } - slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname, + slprintf(name, sizeof(name)-1, "\\\\%s\\%s", get_called_name(), printer->info_2->sharename); if ((snum = print_queue_snum(printer->info_2->sharename)) == -1) { @@ -5900,7 +5898,7 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen if((info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1))) == NULL) return WERR_NOMEM; - slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", global_myname, short_archi); + slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", get_called_name(), short_archi); DEBUG(4,("printer driver directory: [%s]\n", path)); @@ -7119,7 +7117,7 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, Windows returns the string: C:\WINNT\System32\spool\PRTPROCS\W32X86 which is pretty bogus for a RPC. */ - slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", global_myname, short_archi); + slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", get_called_name(), short_archi); DEBUG(4,("print processor directory: [%s]\n", path)); -- cgit From 91536cc901088232074ad8dd7ae16e0f6026f25e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 9 Jan 2002 04:13:30 +0000 Subject: Fixed all uses of tdb_fetch/store/_int to use explicit int32 little endian in tdb's. All except winbindd_idmap.... Hmmmmmm. Jeremy. (This used to be commit ec71f1732b6b27bd2d65b250a6f3720a235dc38d) --- source3/rpc_server/srv_srvsvc_nt.c | 47 +++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index f37096fec3..57013829c5 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -120,30 +120,41 @@ static TDB_CONTEXT *share_tdb; /* used for share security descriptors */ BOOL share_info_db_init(void) { - static pid_t local_pid; - char *vstring = "INFO/version"; + static pid_t local_pid; + char *vstring = "INFO/version"; + int32 vers_id; - if (share_tdb && local_pid == sys_getpid()) return True; - 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) )); - return False; - } + if (share_tdb && local_pid == sys_getpid()) + return True; + 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) )); + return False; + } - local_pid = sys_getpid(); + local_pid = sys_getpid(); - /* handle a Samba upgrade */ - tdb_lock_bystring(share_tdb, vstring); - if (tdb_fetch_int(share_tdb, vstring) != SHARE_DATABASE_VERSION) { - tdb_traverse(share_tdb, tdb_traverse_delete_fn, NULL); - tdb_store_int(share_tdb, vstring, SHARE_DATABASE_VERSION); - } - tdb_unlock_bystring(share_tdb, vstring); + /* handle a Samba upgrade */ + tdb_lock_bystring(share_tdb, vstring); + + /* Cope with byte-reversed older versions of the db. */ + vers_id = tdb_fetch_int32(share_tdb, vstring); + if ((vers_id != SHARE_DATABASE_VERSION) && (IREV(vers_id) == SHARE_DATABASE_VERSION)) { + /* Written on a bigendian machine with old fetch_int code. Save as le. */ + tdb_store_int32(share_tdb, vstring, SHARE_DATABASE_VERSION); + vers_id = SHARE_DATABASE_VERSION; + } + + if (vers_id != SHARE_DATABASE_VERSION) { + tdb_traverse(share_tdb, tdb_traverse_delete_fn, NULL); + tdb_store_int32(share_tdb, vstring, SHARE_DATABASE_VERSION); + } + tdb_unlock_bystring(share_tdb, vstring); message_register(MSG_SMB_CONF_UPDATED, smb_conf_updated); - return True; + return True; } /******************************************************************* -- cgit From a842a3d4582b556c77fcfb593af193b4d1225751 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 9 Jan 2002 05:24:07 +0000 Subject: When re-writing tdb version numbers as little endian int32, we must change the version number also. Jeremy. (This used to be commit 3dec9cf99a82bd15626eb99e7d937ff00183cc05) --- source3/rpc_server/srv_srvsvc_nt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 57013829c5..67442a7761 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -116,7 +116,8 @@ static void smb_conf_updated(int msg_type, pid_t src, void *buf, size_t len) ********************************************************************/ static TDB_CONTEXT *share_tdb; /* used for share security descriptors */ -#define SHARE_DATABASE_VERSION 1 +#define SHARE_DATABASE_VERSION_V1 1 +#define SHARE_DATABASE_VERSION_V2 2 /* version id in little endian. */ BOOL share_info_db_init(void) { @@ -140,15 +141,15 @@ BOOL share_info_db_init(void) /* Cope with byte-reversed older versions of the db. */ vers_id = tdb_fetch_int32(share_tdb, vstring); - if ((vers_id != SHARE_DATABASE_VERSION) && (IREV(vers_id) == SHARE_DATABASE_VERSION)) { + if ((vers_id == SHARE_DATABASE_VERSION_V1) || (IREV(vers_id) == SHARE_DATABASE_VERSION_V1)) { /* Written on a bigendian machine with old fetch_int code. Save as le. */ - tdb_store_int32(share_tdb, vstring, SHARE_DATABASE_VERSION); - vers_id = SHARE_DATABASE_VERSION; + tdb_store_int32(share_tdb, vstring, SHARE_DATABASE_VERSION_V2); + vers_id = SHARE_DATABASE_VERSION_V2; } - if (vers_id != SHARE_DATABASE_VERSION) { + if (vers_id != SHARE_DATABASE_VERSION_V2) { tdb_traverse(share_tdb, tdb_traverse_delete_fn, NULL); - tdb_store_int32(share_tdb, vstring, SHARE_DATABASE_VERSION); + tdb_store_int32(share_tdb, vstring, SHARE_DATABASE_VERSION_V2); } tdb_unlock_bystring(share_tdb, vstring); -- cgit From f5bc0e92a66b418b2bd8f3669a9642b4d46bc8d1 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Wed, 9 Jan 2002 07:52:51 +0000 Subject: Better explanation message for dmalloc. Also more insertion of parenthesis to handle struct members called 'free'. You can now get useful dmalloc output, as long as it is compatible with your C library. On RH7.1 it looks like you have to rebuild dmalloc to allow free(0) by default, because something in libcrypt does that. (sigh) (This used to be commit 391cbb690196537c8b6292b42c2e27408cc7e249) --- source3/rpc_server/srv_netlog_nt.c | 4 ++-- source3/rpc_server/srv_pipe.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index fbab46022c..a07ebc9a3f 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -585,7 +585,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * } else { status = auth_context->check_ntlm_password(auth_context, user_info, &server_info); } - auth_context->free(&auth_context); + (auth_context->free)(&auth_context); break; } @@ -614,7 +614,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * status = auth_context->check_ntlm_password(auth_context, user_info, &server_info); } - auth_context->free(&auth_context); + (auth_context->free)(&auth_context); break; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 36ca7e0686..a38b86f826 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -357,7 +357,7 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm nt_status = auth_context->check_ntlm_password(auth_context, user_info, &server_info); - auth_context->free(&auth_context); + (auth_context->free)(&auth_context); free_user_info(&user_info); p->ntlmssp_auth_validated = NT_STATUS_IS_OK(nt_status); -- cgit From 1d40138232a22b78f088847d0d72d6ddec17a65e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 11 Jan 2002 23:33:12 +0000 Subject: Round and round we go.... Jeremy. (This used to be commit 2603ab3c6870f3697751b887e940910713f08985) --- source3/rpc_server/srv_spoolss_nt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 96f44c4b8b..adc9546530 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6177,7 +6177,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP convert_specific_param(¶m, value , type, data, real_len); - +#if 0 if (get_specific_param(*printer, 2, param->value, &old_param.data, &old_param.type, (uint32 *)&old_param.data_len)) { @@ -6191,6 +6191,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP goto done; } } +#endif unlink_specific_param_if_exist(printer->info_2, param); -- cgit From c9d350a736ca71f838cf19386b04e972200ee595 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 12 Jan 2002 02:37:54 +0000 Subject: Added PRINTER_INFO_4/PRINTER_INFO_5, we're seeing level 5 requested on the wire... so. Jeremy. (This used to be commit b63b76297835ab8227b98925fa8120ffce1a37d9) --- source3/rpc_server/srv_spoolss_nt.c | 113 ++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index adc9546530..94444e0b13 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2873,6 +2873,49 @@ static BOOL construct_printer_info_3(PRINTER_INFO_3 **pp_printer, int snum) return True; } +/******************************************************************** + * construct_printer_info_4 + * fill a printer_info_4 struct + ********************************************************************/ + +static BOOL construct_printer_info_4(PRINTER_INFO_4 *printer, int snum) +{ + NT_PRINTER_INFO_LEVEL *ntprinter = NULL; + + if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) + return False; + + init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/ + init_unistr(&printer->servername, ntprinter->info_2->servername); /* servername*/ + printer->attributes = ntprinter->info_2->attributes; + + free_a_printer(&ntprinter, 2); + return True; +} + +/******************************************************************** + * construct_printer_info_5 + * fill a printer_info_5 struct + ********************************************************************/ + +static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum) +{ + NT_PRINTER_INFO_LEVEL *ntprinter = NULL; + + if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) + return False; + + init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/ + init_unistr(&printer->portname, ntprinter->info_2->portname); /* portname */ + printer->attributes = ntprinter->info_2->attributes; + printer->device_not_selected_timeout = 0x3a98; + printer->transmission_retry_timeout = 0xafc8; + + free_a_printer(&ntprinter, 2); + return True; +} + + /******************************************************************** Spoolss_enumprinters. ********************************************************************/ @@ -3333,6 +3376,72 @@ static WERROR getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, u return WERR_OK; } +/**************************************************************************** +****************************************************************************/ +static WERROR getprinter_level_4(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + PRINTER_INFO_4 *printer=NULL; + + if((printer=(PRINTER_INFO_4*)malloc(sizeof(PRINTER_INFO_4)))==NULL) + return WERR_NOMEM; + + if (!construct_printer_info_4(printer, snum)) + return WERR_NOMEM; + + /* check the required size. */ + *needed += spoolss_size_printer_info_4(printer); + + if (!alloc_buffer_size(buffer, *needed)) { + free_printer_info_4(printer); + return WERR_INSUFFICIENT_BUFFER; + } + + /* fill the buffer with the structures */ + smb_io_printer_info_4("", buffer, printer, 0); + + /* clear memory */ + free_printer_info_4(printer); + + if (*needed > offered) { + return WERR_INSUFFICIENT_BUFFER; + } + + return WERR_OK; +} + +/**************************************************************************** +****************************************************************************/ +static WERROR getprinter_level_5(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + PRINTER_INFO_5 *printer=NULL; + + if((printer=(PRINTER_INFO_5*)malloc(sizeof(PRINTER_INFO_5)))==NULL) + return WERR_NOMEM; + + if (!construct_printer_info_5(printer, snum)) + return WERR_NOMEM; + + /* check the required size. */ + *needed += spoolss_size_printer_info_5(printer); + + if (!alloc_buffer_size(buffer, *needed)) { + free_printer_info_5(printer); + return WERR_INSUFFICIENT_BUFFER; + } + + /* fill the buffer with the structures */ + smb_io_printer_info_5("", buffer, printer, 0); + + /* clear memory */ + free_printer_info_5(printer); + + if (*needed > offered) { + return WERR_INSUFFICIENT_BUFFER; + } + + return WERR_OK; +} + /**************************************************************************** ****************************************************************************/ @@ -3364,6 +3473,10 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET return getprinter_level_2(snum, buffer, offered, needed); case 3: return getprinter_level_3(snum, buffer, offered, needed); + case 4: + return getprinter_level_4(snum, buffer, offered, needed); + case 5: + return getprinter_level_5(snum, buffer, offered, needed); } return WERR_UNKNOWN_LEVEL; } -- cgit From dbee612f7150ee2921c37fa331b38b86d2d63937 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 15 Jan 2002 01:02:13 +0000 Subject: Change the passdb interface to use allocated strings. These strings are allocated using talloc(), either using its own memory context stored on the SAM_ACCOUNT or one supplied by the caller. The pdb_init_sam() and pdb_free_sam() function have been modifed so that a call to pdb_free_sam() will either clean up (remove hashes from memory) and destroy the TALLOC_CTX or just clean up depending on who supplied it. The pdb_init_sam and pdb_free_sam functions now also return an NTSTATUS, and I have modified the 3 places that actually checked these returns. The only nasty thing about this patch is the small measure needed to maintin interface compatability - strings set to NULL are actually set to "". This is becouse there are too many places in Samba that do strlen() on these strings without checking if they are NULL pointers. A supp patch will follow to set all strings to "" in pdb_default_sam(). Andrew Bartlett (This used to be commit 144345b41d39a6f68d01f62b7aee64ca0d328085) --- source3/rpc_server/srv_netlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index a07ebc9a3f..1ae1b65fdd 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -189,7 +189,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) } #endif /* 0 */ - if(!pdb_init_sam(&sampass)) + if(!NT_STATUS_IS_OK(pdb_init_sam(&sampass))) return False; /* JRA. This is ok as it is only used for generating the challenge. */ -- cgit From 5fa0da0ba5e466eb5fe5f423393ae45dcd4d7237 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 15 Jan 2002 16:20:25 +0000 Subject: Missing assign fix from Bernt Nilsson bkn@ida.liu.se. Jeremy. (This used to be commit adf24a90e8b4d970d71fa8a6854edcf6deff9688) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 94444e0b13..2b41efcbf6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -633,7 +633,7 @@ static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size */ hl = NULL; - for ( p = get_first_pipe(); p; get_next_pipe(p)) { + for ( p = get_first_pipe(); p; p = get_next_pipe(p)) { if (strequal(p->name, "spoolss")) { hl = p->pipe_handles; break; -- cgit From c311d24ce32d2a8aa244f126bcec67ec03549727 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 17 Jan 2002 08:45:58 +0000 Subject: A nice *big* change to the fundemental way we do things. Samba (ab)uses the returns from getpwnam() a lot - in particular it keeps them around for a long time - often past the next call... This adds a getpwnam_alloc and a getpwuid_alloc to the collection. These function as expected, returning a malloced structure that can be free()ed with passwd_free(&passwd). This patch also cuts down on the number of calls to getpwnam - mostly by taking advantage of the fact that the passdb interface is already case-insensiteve. With this patch most of the recursive cases have been removed (that I know of) and the problems are reduced further by not using the sys_ interface in the new code. This means that pointers to the cache won't be affected. (This is a tempoary HACK, I intend to kill the password cache entirly). The only change I'm a little worried about is the change to rpc_server/srv_samr_nt.c for private groups. In this case we are getting groups from the new group mapping DB. Do we still need to check for private groups? I've toned down the check to a case sensitve match with the new code, but we might be able to kill it entirly. I've also added a make_modifyable_passwd() function, that copies a passwd struct into the form that the old sys_getpw* code provided. As far as I can tell this is only actually used in the pass_check.c crazies, where I moved the final 'special case' for shadow passwords (out of _Get_Pwnam()). The matching case for getpwent() is dealt with already, in lib/util_getent.c Also included in here is a small change to register the [homes] share at vuid creation rather than just in one varient of the session setup. (This picks up the SPNEGO cases). The home directory is now stored on the vuid, and I am hoping this might provide a saner way to do %H substitions. TODO: Kill off remaining Get_Pwnam_Modify calls (they are not needed), change the remaining sys_getpwnam() callers to use getpwnam_alloc() and move Get_Pwnam to return an allocated struct. Andrew Bartlett (This used to be commit 1d86c7f94230bc53daebd4d2cd829da6292e05da) --- source3/rpc_server/srv_samr_nt.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a54bf0d175..c17e22ada2 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -659,6 +659,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM char *sep; struct sys_grent *glist; struct sys_grent *grp; + struct passwd *pw; sep = lp_winbind_separator(); @@ -696,8 +697,18 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM } /* Don't return user private groups... */ - if (Get_Pwnam(smap.nt_name) != 0) { + + /* + * We used to do a Get_Pwnam() here, but this has been + * trimmed back to the common case for private groups + * to save lookups and to use the _alloc interface. + * + * This also matches the group mapping code + */ + + if ((pw = getpwnam_alloc(smap.nt_name)) != 0) { DEBUG(10,("get_group_alias_entries: not returing %s, clashes with user.\n", smap.nt_name )); + passwd_free(&pw); continue; } @@ -1245,9 +1256,9 @@ NTSTATUS _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_ (void)map_username(user_name); /* - * Do any UNIX username case mangling. + * UNIX username case mangling not required, pass_oem_change + * is case insensitive. */ - (void)Get_Pwnam_Modify( user_name); if (!pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, q_u->nt_newpass.pass, q_u->nt_oldhash.hash)) -- cgit From 93a8358910d2b8788ffea33c04244ffd5ffecabf Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 20 Jan 2002 01:24:59 +0000 Subject: This patch makes the 'winbind use default domain' code interact better with smbd, and also makes it much cleaner inside winbindd. It is mostly my code, with a few changes and testing performed by Alexander Bokovoy . ab has tested it in security=domain and security=ads, but more testing is always appricatiated. The idea is that we no longer cart around a 'domain\user' string, we keep them seperate until the last moment - when we push that string into a pwent on onto the socket. This removes the need to be constantly parsing that string - the domain prefix is almost always already provided, (only a couple of functions actually changed arguments in all this). Some consequential changes to the RPC client code, to stop it concatonating the two strings (it now passes them both back as params). I havn't changed the cache code, however the usernames will no longer have a double domain prefix in the key string. The actual structures are unchanged - but the meaning of 'username' in the 'rid' will have changed. (The cache is invalidated at startup, so on-disk formats are not an issue here). Andrew Bartlett (This used to be commit e870f0e727952aeb8599cf93ad2650ae56eca033) --- source3/rpc_server/srv_samr_nt.c | 6 +++--- source3/rpc_server/srv_util.c | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c17e22ada2..6ac71298fa 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -656,12 +656,12 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM SAFE_FREE(map); } else if (sid_equal(sid, &global_sam_sid) && !lp_hide_local_users()) { - char *sep; struct sys_grent *glist; struct sys_grent *grp; struct passwd *pw; + gid_t winbind_gid_low, winbind_gid_high; - sep = lp_winbind_separator(); + lp_winbind_gid(&winbind_gid_low, &winbind_gid_high); /* local aliases */ /* we return the UNIX groups here. This seems to be the right */ @@ -691,7 +691,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM continue; /* Don't return winbind groups as they are not local! */ - if (strchr_m(smap.nt_name, *sep) != NULL) { + if ((grp->gr_gid >= winbind_gid_low)&&(grp->gr_gid <= winbind_gid_high)) { DEBUG(10,("get_group_alias_entries: not returing %s, not local.\n", smap.nt_name )); continue; } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 14caf89e2f..1788512db7 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -82,7 +82,6 @@ rid_name domain_group_rids[] = NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, uint32 **prids, DOM_SID *q_sid) { SAM_ACCOUNT *sam_pass=NULL; - char *sep; struct sys_grent *glist; struct sys_grent *grp; int i, num, cur_rid=0; @@ -93,6 +92,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui fstring str_domsid, str_qsid; uint32 rid,grid; uint32 *rids=NULL, *new_rids=NULL; + gid_t winbind_gid_low, winbind_gid_high; BOOL ret; /* @@ -109,7 +109,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui *prids=NULL; *numgroups=0; - sep = lp_winbind_separator(); + lp_winbind_gid(&winbind_gid_low, &winbind_gid_high); DEBUG(10,("get_alias_user_groups: looking if SID %s is a member of groups in the SID domain %s\n", @@ -158,7 +158,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui } /* Don't return winbind groups as they are not local! */ - if (strchr_m(map.nt_name, *sep) != NULL) { + if ((grp->gr_gid >= winbind_gid_low) && (grp->gr_gid <= winbind_gid_high)) { DEBUG(10,("get_alias_user_groups: not returing %s, not local.\n", map.nt_name)); continue; } @@ -227,7 +227,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui } /* Don't return winbind groups as they are not local! */ - if (strchr_m(map.nt_name, *sep) != NULL) { + if ((gid >= winbind_gid_low) && (gid <= winbind_gid_high)) { DEBUG(10,("get_alias_user_groups: not returing %s, not local.\n", map.nt_name )); goto done; } @@ -271,7 +271,7 @@ BOOL get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids, SA uint32 grid; uint32 tmp_rid; - *numgroups=0; + *numgroups= 0; fstrcpy(user_name, pdb_get_username(sam_pass)); grid=pdb_get_group_rid(sam_pass); -- cgit From bb6af711b8f9a525b74198abbe7f1c37014ca6f7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 20 Jan 2002 02:40:05 +0000 Subject: This is the current patch from Luke Leighton to add a degree of seperation betwen reading/writing the raw NamedPipe SMB packets and the matching operations inside smbd's RPC components. This patch is designed for no change in behaviour, and my tests hold that to be true. This patch does however allow for the future loadable modules interface to specify function pointers in replacement of the fixed state. The pipes_struct has been split into two peices, with smb_np_struct taking the information that should be generic to where the data ends up. Some other minor changes are made: we get another small helper function in util_sock.c and some of the original code has better failure debugs and variable use. (As per on-list comments). Andrew Bartlett (This used to be commit 8ef13cabdddf58b741886782297fb64b2fb7e489) --- source3/rpc_server/srv_lsa_hnd.c | 4 +- source3/rpc_server/srv_pipe_hnd.c | 264 ++++++++++++++++++++++++++++-------- source3/rpc_server/srv_spoolss_nt.c | 2 +- 3 files changed, 210 insertions(+), 60 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index d5f9a52e2f..e4a00443a1 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -35,10 +35,10 @@ BOOL init_pipe_handle_list(pipes_struct *p, char *pipe_name) { - pipes_struct *plist = get_first_pipe(); + pipes_struct *plist = get_first_internal_pipe(); struct handle_list *hl = NULL; - for (plist = get_first_pipe(); plist; plist = get_next_pipe(plist)) { + for (plist = get_first_internal_pipe(); plist; plist = get_next_internal_pipe(plist)) { if (strequal( plist->name, pipe_name)) { if (!plist->pipe_handles) { pstring msg; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index cc6415cce7..a98bcdc6bb 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -26,26 +26,58 @@ #define PIPE "\\PIPE\\" #define PIPELEN strlen(PIPE) -static pipes_struct *chain_p; +static smb_np_struct *chain_p; static int pipes_open; #ifndef MAX_OPEN_PIPES #define MAX_OPEN_PIPES 2048 #endif -static pipes_struct *Pipes; +static smb_np_struct *Pipes; +static pipes_struct *InternalPipes; static struct bitmap *bmap; +/* TODO + * the following prototypes are declared here to avoid + * code being moved about too much for a patch to be + * disrupted / less obvious. + * + * these functions, and associated functions that they + * call, should be moved behind a .so module-loading + * system _anyway_. so that's the next step... + */ + +static ssize_t read_from_internal_pipe(void *np_conn, char *data, size_t n, + BOOL *is_data_outstanding); +static ssize_t write_to_internal_pipe(void *np_conn, char *data, size_t n); +static BOOL close_internal_rpc_pipe_hnd(void *np_conn); +static void *make_internal_rpc_pipe_p(char *pipe_name, + connection_struct *conn, uint16 vuid); + /**************************************************************************** Pipe iterator functions. ****************************************************************************/ -pipes_struct *get_first_pipe(void) +smb_np_struct *get_first_pipe(void) { return Pipes; } -pipes_struct *get_next_pipe(pipes_struct *p) +smb_np_struct *get_next_pipe(smb_np_struct *p) +{ + return p->next; +} + +/**************************************************************************** + Internal Pipe iterator functions. +****************************************************************************/ + +pipes_struct *get_first_internal_pipe(void) +{ + return InternalPipes; +} + +pipes_struct *get_next_internal_pipe(pipes_struct *p) { return p->next; } @@ -118,11 +150,11 @@ static BOOL pipe_init_outgoing_data(pipes_struct *p) Find first available pipe slot. ****************************************************************************/ -pipes_struct *open_rpc_pipe_p(char *pipe_name, +smb_np_struct *open_rpc_pipe_p(char *pipe_name, connection_struct *conn, uint16 vuid) { int i; - pipes_struct *p; + smb_np_struct *p, *p_it; static int next_pipe; DEBUG(4,("Open pipe requested %s (pipes_open=%d)\n", @@ -147,22 +179,28 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, for (p = Pipes; p; p = p->next) DEBUG(5,("open_rpc_pipe_p: name %s pnum=%x\n", p->name, p->pnum)); - p = (pipes_struct *)malloc(sizeof(*p)); + p = (smb_np_struct *)malloc(sizeof(*p)); if (!p) + { + DEBUG(0,("ERROR! no memory for pipes_struct!\n")); return NULL; + } ZERO_STRUCTP(p); - if ((p->mem_ctx = talloc_init()) == NULL) { - DEBUG(0,("open_rpc_pipe_p: talloc_init failed.\n")); - SAFE_FREE(p); - return NULL; - } + /* add a dso mechanism instead of this, here */ - if (!init_pipe_handle_list(p, pipe_name)) { - DEBUG(0,("open_rpc_pipe_p: init_pipe_handles failed.\n")); - talloc_destroy(p->mem_ctx); + p->namedpipe_create = make_internal_rpc_pipe_p; + p->namedpipe_read = read_from_internal_pipe; + p->namedpipe_write = write_to_internal_pipe; + p->namedpipe_close = close_internal_rpc_pipe_hnd; + + p->np_state = p->namedpipe_create(pipe_name, conn, vuid); + + if (p->np_state == NULL) { + + DEBUG(0,("open_rpc_pipe_p: make_internal_rpc_pipe_p failed.\n")); SAFE_FREE(p); return NULL; } @@ -177,11 +215,6 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, * change the type to UNMARSALLING before processing the stream. */ - if(!prs_init(&p->in_data.data, MAX_PDU_FRAG_LEN, p->mem_ctx, MARSHALL)) { - DEBUG(0,("open_rpc_pipe_p: malloc fail for in_data struct.\n")); - return NULL; - } - bitmap_set(bmap, i); i += pipe_handle_offset; @@ -197,6 +230,71 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->max_trans_reply = 0; + fstrcpy(p->name, pipe_name); + + DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n", + pipe_name, i, pipes_open)); + + chain_p = p; + + /* Iterate over p_it as a temp variable, to display all open pipes */ + for (p_it = Pipes; p_it; p_it = p_it->next) + DEBUG(5,("open pipes: name %s pnum=%x\n", p_it->name, p_it->pnum)); + + return chain_p; +} + +/**************************************************************************** + * make an internal namedpipes structure +****************************************************************************/ + +static void *make_internal_rpc_pipe_p(char *pipe_name, + connection_struct *conn, uint16 vuid) +{ + pipes_struct *p; + + DEBUG(4,("Create pipe requested %s\n", pipe_name)); + + p = (pipes_struct *)malloc(sizeof(*p)); + + if (!p) + { + DEBUG(0,("ERROR! no memory for pipes_struct!\n")); + return NULL; + } + + ZERO_STRUCTP(p); + + if ((p->mem_ctx = talloc_init()) == NULL) { + DEBUG(0,("open_rpc_pipe_p: talloc_init failed.\n")); + SAFE_FREE(p); + return NULL; + } + + if (!init_pipe_handle_list(p, pipe_name)) { + DEBUG(0,("open_rpc_pipe_p: init_pipe_handles failed.\n")); + talloc_destroy(p->mem_ctx); + SAFE_FREE(p); + return NULL; + } + + /* + * Initialize the incoming RPC data buffer with one PDU worth of memory. + * We cheat here and say we're marshalling, as we intend to add incoming + * data directly into the prs_struct and we want it to auto grow. We will + * change the type to UNMARSALLING before processing the stream. + */ + + if(!prs_init(&p->in_data.data, MAX_PDU_FRAG_LEN, p->mem_ctx, MARSHALL)) { + DEBUG(0,("open_rpc_pipe_p: malloc fail for in_data struct.\n")); + return NULL; + } + + DLIST_ADD(InternalPipes, p); + + p->conn = conn; + p->vuid = vuid; + p->ntlmssp_chal_flags = 0; p->ntlmssp_auth_validated = False; p->ntlmssp_auth_requested = False; @@ -205,6 +303,11 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, p->fault_state = False; p->endian = RPC_LITTLE_ENDIAN; + ZERO_STRUCT(p->pipe_user); + + p->pipe_user.uid = (uid_t)-1; + p->pipe_user.gid = (gid_t)-1; + /* * Initialize the incoming RPC struct. */ @@ -225,23 +328,12 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name, */ prs_init(&p->out_data.rdata, 0, p->mem_ctx, MARSHALL); - ZERO_STRUCT(p->pipe_user); - - p->pipe_user.uid = (uid_t)-1; - p->pipe_user.gid = (gid_t)-1; - fstrcpy(p->name, pipe_name); - DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n", - pipe_name, i, pipes_open)); - - chain_p = p; - - /* OVERWRITE p as a temp variable, to display all open pipes */ - for (p = Pipes; p; p = p->next) - DEBUG(5,("open pipes: name %s pnum=%x\n", p->name, p->pnum)); + DEBUG(4,("Created internal pipe %s (pipes_open=%d)\n", + pipe_name, pipes_open)); - return chain_p; + return (void*)p; } /**************************************************************************** @@ -254,8 +346,8 @@ static void set_incoming_fault(pipes_struct *p) p->in_data.pdu_needed_len = 0; p->in_data.pdu_received_len = 0; p->fault_state = True; - DEBUG(10,("set_incoming_fault: Setting fault state on pipe %s : pnum = 0x%x\n", - p->name, p->pnum )); + DEBUG(10,("set_incoming_fault: Setting fault state on pipe %s : vuid = 0x%x\n", + p->name, p->vuid )); } /**************************************************************************** @@ -712,10 +804,8 @@ incoming data size = %u\n", (unsigned int)p->in_data.pdu_received_len, (unsigned Accepts incoming data on an rpc pipe. ****************************************************************************/ -ssize_t write_to_pipe(pipes_struct *p, char *data, size_t n) +ssize_t write_to_pipe(smb_np_struct *p, char *data, size_t n) { - size_t data_left = n; - DEBUG(6,("write_to_pipe: %x", p->pnum)); DEBUG(6,(" name: %s open: %s len: %d\n", @@ -723,6 +813,18 @@ ssize_t write_to_pipe(pipes_struct *p, char *data, size_t n) dump_data(50, data, n); + return p->namedpipe_write(p->np_state, data, n); +} + +/**************************************************************************** + Accepts incoming data on an internal rpc pipe. +****************************************************************************/ + +static ssize_t write_to_internal_pipe(void *np_conn, char *data, size_t n) +{ + pipes_struct *p = (pipes_struct*)np_conn; + size_t data_left = n; + while(data_left) { ssize_t data_used; @@ -753,11 +855,9 @@ ssize_t write_to_pipe(pipes_struct *p, char *data, size_t n) have been prepared into arrays of headers + data stream sections. ****************************************************************************/ -ssize_t read_from_pipe(pipes_struct *p, char *data, size_t n) +ssize_t read_from_pipe(smb_np_struct *p, char *data, size_t n, + BOOL *is_data_outstanding) { - uint32 pdu_remaining = 0; - ssize_t data_returned = 0; - if (!p || !p->open) { DEBUG(0,("read_from_pipe: pipe not open\n")); return -1; @@ -765,6 +865,32 @@ ssize_t read_from_pipe(pipes_struct *p, char *data, size_t n) DEBUG(6,("read_from_pipe: %x", p->pnum)); + return p->namedpipe_read(p->np_state, data, n, is_data_outstanding); +} + +/**************************************************************************** + Replies to a request to read data from a pipe. + + Headers are interspersed with the data at PDU intervals. By the time + this function is called, the start of the data could possibly have been + read by an SMBtrans (file_offset != 0). + + Calling create_rpc_reply() here is a hack. The data should already + have been prepared into arrays of headers + data stream sections. +****************************************************************************/ + +static ssize_t read_from_internal_pipe(void *np_conn, char *data, size_t n, + BOOL *is_data_outstanding) +{ + pipes_struct *p = (pipes_struct*)np_conn; + uint32 pdu_remaining = 0; + ssize_t data_returned = 0; + + if (!p) { + DEBUG(0,("read_from_pipe: pipe not open\n")); + return -1; + } + DEBUG(6,(" name: %s len: %u\n", p->name, (unsigned int)n)); /* @@ -839,6 +965,7 @@ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, out: + (*is_data_outstanding) = p->out_data.current_pdu_len > n; return data_returned; } @@ -846,7 +973,7 @@ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, Wait device state on a pipe. Exactly what this is for is unknown... ****************************************************************************/ -BOOL wait_rpc_pipe_hnd_state(pipes_struct *p, uint16 priority) +BOOL wait_rpc_pipe_hnd_state(smb_np_struct *p, uint16 priority) { if (p == NULL) return False; @@ -870,7 +997,7 @@ BOOL wait_rpc_pipe_hnd_state(pipes_struct *p, uint16 priority) Set device state on a pipe. Exactly what this is for is unknown... ****************************************************************************/ -BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state) +BOOL set_rpc_pipe_hnd_state(smb_np_struct *p, uint16 device_state) { if (p == NULL) return False; @@ -894,21 +1021,14 @@ BOOL set_rpc_pipe_hnd_state(pipes_struct *p, uint16 device_state) Close an rpc pipe. ****************************************************************************/ -BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) +BOOL close_rpc_pipe_hnd(smb_np_struct *p) { if (!p) { DEBUG(0,("Invalid pipe in close_rpc_pipe_hnd\n")); return False; } - prs_mem_free(&p->out_data.rdata); - prs_mem_free(&p->in_data.data); - - if (p->mem_ctx) - talloc_destroy(p->mem_ctx); - - /* Free the handles database. */ - close_policy_by_pipe(p); + p->namedpipe_close(p->np_state); bitmap_clear(bmap, p->pnum - pipe_handle_offset); @@ -919,9 +1039,39 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) DLIST_REMOVE(Pipes, p); + ZERO_STRUCTP(p); + + SAFE_FREE(p); + + return True; +} + +/**************************************************************************** + Close an rpc pipe. +****************************************************************************/ + +static BOOL close_internal_rpc_pipe_hnd(void *np_conn) +{ + pipes_struct *p = (pipes_struct *)np_conn; + if (!p) { + DEBUG(0,("Invalid pipe in close_internal_rpc_pipe_hnd\n")); + return False; + } + + prs_mem_free(&p->out_data.rdata); + prs_mem_free(&p->in_data.data); + + if (p->mem_ctx) + talloc_destroy(p->mem_ctx); + + /* Free the handles database. */ + close_policy_by_pipe(p); + delete_nt_token(&p->pipe_user.nt_user_token); SAFE_FREE(p->pipe_user.groups); + DLIST_REMOVE(InternalPipes, p); + ZERO_STRUCTP(p); SAFE_FREE(p); @@ -933,7 +1083,7 @@ BOOL close_rpc_pipe_hnd(pipes_struct *p, connection_struct *conn) Find an rpc pipe given a pipe handle in a buffer and an offset. ****************************************************************************/ -pipes_struct *get_rpc_pipe_p(char *buf, int where) +smb_np_struct *get_rpc_pipe_p(char *buf, int where) { int pnum = SVAL(buf,where); @@ -947,9 +1097,9 @@ pipes_struct *get_rpc_pipe_p(char *buf, int where) Find an rpc pipe given a pipe handle. ****************************************************************************/ -pipes_struct *get_rpc_pipe(int pnum) +smb_np_struct *get_rpc_pipe(int pnum) { - pipes_struct *p; + smb_np_struct *p; DEBUG(4,("search for pipe pnum=%x\n", pnum)); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2b41efcbf6..bdd2bbf31b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -633,7 +633,7 @@ static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size */ hl = NULL; - for ( p = get_first_pipe(); p; p = get_next_pipe(p)) { + for ( p = get_first_internal_pipe(); p; get_next_internal_pipe(p)) { if (strequal(p->name, "spoolss")) { hl = p->pipe_handles; break; -- cgit From 32101155d4a0c80faf392f56a6baa7b91847dd99 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 20 Jan 2002 13:26:31 +0000 Subject: Kill off another ugly wart from the side of the passdb subsystem. This time its the pdb_getsampwuid() function - which was only being used by the SAMR rpc subsystem to gain a 'user session key'. This 'user session key' is actually generated at login time, and the other changes here simply move that data around. This also means that (when I check some details) we will be able to use the user session key, even when we are not actually the DC, becouse its one of the components of the info3 struct returned on logon. Andrew Bartlett (This used to be commit 799ac01fe08a338e4e94289f5d6767ebf905c1fa) --- source3/rpc_server/srv_pipe.c | 2 ++ source3/rpc_server/srv_pipe_hnd.c | 11 +++++++++++ source3/rpc_server/srv_samr_nt.c | 39 +++------------------------------------ 3 files changed, 16 insertions(+), 36 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index a38b86f826..2630729281 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -423,6 +423,8 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); return False; } + memcpy(p->session_key, server_info->session_key, sizeof(p->session_key)); + uid = pdb_get_uid(server_info->sam_account); gid = pdb_get_gid(server_info->sam_account); diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index a98bcdc6bb..1b3d66bf49 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -252,9 +252,15 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, connection_struct *conn, uint16 vuid) { pipes_struct *p; + user_struct *vuser = get_valid_user_struct(vuid); DEBUG(4,("Create pipe requested %s\n", pipe_name)); + if (!vuser && vuid != UID_FIELD_INVALID) { + DEBUG(0,("ERROR! vuid %d did not map to a valid vuser struct!\n", vuid)); + return NULL; + } + p = (pipes_struct *)malloc(sizeof(*p)); if (!p) @@ -308,6 +314,11 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, p->pipe_user.uid = (uid_t)-1; p->pipe_user.gid = (gid_t)-1; + /* Store the session key */ + if (vuser) { + memcpy(p->session_key, vuser->session_key, sizeof(p->session_key)); + } + /* * Initialize the incoming RPC struct. */ diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6ac71298fa..cf9be78f3d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2439,9 +2439,6 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE { uint32 rid = 0x0; DOM_SID sid; - struct current_user user; - 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; @@ -2451,13 +2448,6 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE r_u->status = NT_STATUS_OK; - if (p->ntlmssp_auth_validated) { - memcpy(&user, &p->pipe_user, sizeof(user)); - } else { - extern struct current_user current_user; - memcpy(&user, ¤t_user, sizeof(user)); - } - /* find the policy handle. open a policy on it. */ if (!get_lsa_policy_samr_sid(p, pol, &sid)) return NT_STATUS_INVALID_HANDLE; @@ -2471,29 +2461,6 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE return NT_STATUS_INVALID_INFO_CLASS; } - - 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" - * This "user session key" is in turn used to encrypt/decrypt the user's password. - */ - - become_root(); - ret = pdb_getsampwuid(sam_pass, user.uid); - unbecome_root(); - 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; - } - - memset(sess_key, '\0', 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) { case 0x12: @@ -2502,7 +2469,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE break; case 24: - SamOEMhash(ctr->info.id24->pass, sess_key, 516); + SamOEMhash(ctr->info.id24->pass, p->session_key, 516); dump_data(100, (char *)ctr->info.id24->pass, 516); @@ -2520,7 +2487,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE * info level and W2K SP2 drops down to level 23... JRA. */ - SamOEMhash(ctr->info.id25->pass, sess_key, 532); + SamOEMhash(ctr->info.id25->pass, p->session_key, 532); dump_data(100, (char *)ctr->info.id25->pass, 532); @@ -2531,7 +2498,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE return NT_STATUS_INVALID_INFO_CLASS; case 23: - SamOEMhash(ctr->info.id23->pass, sess_key, 516); + SamOEMhash(ctr->info.id23->pass, p->session_key, 516); dump_data(100, (char *)ctr->info.id23->pass, 516); -- cgit From 1a74d8d1f0758d15c5c35d20e33d9868565812cf Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 20 Jan 2002 14:30:58 +0000 Subject: This is another *BIG* change... Samba now features a pluggable passdb interface, along the same lines as the one in use in the auth subsystem. In this case, only one backend may be active at a time by the 'normal' interface, and only one backend per passdb_context is permitted outside that. This pluggable interface is designed to allow any number of passdb backends to be compiled in, with the selection at runtime. The 'passdb backend' paramater has been created (and documented!) to support this. As such, configure has been modfied to allow (for example) --with-ldap and the old smbpasswd to be selected at the same time. This patch also introduces two new backends: smbpasswd_nua and tdbsam_nua. These two backends accept 'non unix accounts', where the user does *not* exist in /etc/passwd. These accounts' don't have UIDs in the unix sense, but to avoid conflicts in the algroitmic mapping of RIDs, they use the values specified in the 'non unix account range' paramter - in the same way as the winbind ranges are specifed. While I was at it, I cleaned up some of the code in pdb_tdb (code copied directly from smbpasswd and not really considered properly). Most of this was to do with % macro expansion on stored data. It isn't easy to get the macros into the tdb, and the first password change will 'expand' them. tdbsam needs to use a similar system to pdb_ldap in this regard. This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I don't have the test facilities for these. I plan to incoroprate at least pdb_ldap into this scheme after consultation with Jerry. Each (converted) passdb module now no longer has any 'static' variables, and only exports 1 init function outside its .c file. The non-unix-account support in this patch has been proven! It is now possible to join a win2k machine to a Samba PDC without an account in /etc/passwd! Other changes: Minor interface adjustments: pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*. pdb_update_sam_account() no longer takes the 'override' argument that was being ignored so often (every other passdb backend). Extra checks have been added in some places. Minor code changes: smbpasswd no longer attempts to initialise the passdb at startup, this is now done on first use. pdbedit has lost some of its 'machine account' logic, as this behaviour is now controlled by the passdb subsystem directly. The samr subsystem no longer calls 'local password change', but does the pdb interactions directly. This allow the ACB_ flags specifed to be transferred direct to the backend, without interference. Doco: I've updated the doco to reflect some of the changes, and removed some paramters no longer applicable to HEAD. (This used to be commit ff354c99c585068af6dc1ff35a1f109a806b326b) --- source3/rpc_server/srv_netlog_nt.c | 7 ++- source3/rpc_server/srv_samr_nt.c | 116 +++++++++++++++++++++++-------------- 2 files changed, 78 insertions(+), 45 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 1ae1b65fdd..077dbb0e2b 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -410,6 +410,11 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * return NT_STATUS_NO_SUCH_USER; } + if (!(pdb_get_acct_ctrl(sampass) & ACB_DISABLED)) { + pdb_free_sam(&sampass); + return NT_STATUS_ACCOUNT_DISABLED; + } + DEBUG(100,("Server password set : new given value was :\n")); for(i = 0; i < 16; i++) DEBUG(100,("%02X ", q_u->pwd[i])); @@ -441,7 +446,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * } become_root(); - ret = pdb_update_sam_account (sampass,False); + ret = pdb_update_sam_account (sampass); unbecome_root(); if (ret) diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index cf9be78f3d..d079403455 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1869,9 +1869,6 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ { SAM_ACCOUNT *sam_pass=NULL; fstring account; - pstring err_str; - pstring msg_str; - int local_flags=0; DOM_SID sid; pstring add_script; POLICY_HND dom_pol = q_u->domain_pol; @@ -1880,6 +1877,8 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ POLICY_HND *user_pol = &r_u->user_pol; struct samr_info *info = NULL; BOOL ret; + NTSTATUS nt_status; + struct passwd *pw; /* find the policy handle. open a policy on it. */ if (!find_policy_by_hnd(p, &dom_pol, NULL)) @@ -1905,8 +1904,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ return NT_STATUS_USER_EXISTS; } - local_flags=LOCAL_ADD_USER|LOCAL_DISABLE_USER|LOCAL_SET_NO_PASSWORD; - local_flags|= (acb_info & ACB_WSTRUST) ? LOCAL_TRUST_ACCOUNT:0; + pdb_free_sam(&sam_pass); /* * NB. VERY IMPORTANT ! This call must be done as the current pipe user, @@ -1955,32 +1953,54 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ pstrcpy(add_script, lp_adduser_script()); if(*add_script) { - int add_ret; - all_string_sub(add_script, "%u", account, sizeof(account)); - add_ret = smbrun(add_script,NULL); - DEBUG(3,("_api_samr_create_user: Running the command `%s' gave %d\n",add_script,add_ret)); - } + int add_ret; + all_string_sub(add_script, "%u", account, sizeof(account)); + add_ret = smbrun(add_script,NULL); + DEBUG(3,("_api_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); + } + + pw = getpwnam_alloc(account); - /* add the user in the smbpasswd file or the Samba authority database */ - if (!local_password_change(account, 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; + if (pw) { + if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam_pw(&sam_pass, pw))) { + passwd_free(&pw); + return nt_status; + } + passwd_free(&pw); /* done with this now */ + } else { + DEBUG(3,("attempting to create non-unix account %s\n", account)); + + if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&sam_pass))) { + return nt_status; + } + + if (!pdb_set_username(sam_pass, account)) { + pdb_free_sam(&sam_pass); + return NT_STATUS_NO_MEMORY; + } } - become_root(); - ret = pdb_getsampwnam(sam_pass, account); - unbecome_root(); - if (ret == False) { - /* account doesn't exist: say so */ - pdb_free_sam(&sam_pass); - return NT_STATUS_ACCESS_DENIED; - } + pdb_set_acct_ctrl(sam_pass, acb_info); + + if (!pdb_add_sam_account(sam_pass)) { + pdb_free_sam(&sam_pass); + DEBUG(0, ("could not add user/computer %s to passdb. Check permissions?\n", + account)); + return NT_STATUS_ACCESS_DENIED; + } - /* Get the domain SID stored in the domain policy */ - if(!get_lsa_policy_samr_sid(p, &dom_pol, &sid)) { - pdb_free_sam(&sam_pass); + pdb_reset_sam(sam_pass); + + if (!pdb_getsampwnam(sam_pass, account)) { + pdb_free_sam(&sam_pass); + DEBUG(0, ("could not find user/computer %s just added to passdb?!?\n", + account)); + return NT_STATUS_ACCESS_DENIED; + } + + /* 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; } @@ -2214,7 +2234,7 @@ static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, uint32 rid) return False; } - if(!pdb_update_sam_account(pwd, True)) { + if(!pdb_update_sam_account(pwd)) { pdb_free_sam(&pwd); return False; } @@ -2258,7 +2278,7 @@ static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, uint32 rid) return False; } - if(!pdb_update_sam_account(pwd, True)) { + if(!pdb_update_sam_account(pwd)) { pdb_free_sam(&pwd); return False; } @@ -2297,7 +2317,7 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) */ /* write the change out */ - if(!pdb_update_sam_account(pwd, True)) { + if(!pdb_update_sam_account(pwd)) { pdb_free_sam(&pwd); return False; } @@ -2330,6 +2350,9 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) return False; } + DEBUG(5, ("Attempting administrator password change (level 23) for user %s\n", + pdb_get_username(pwd))); + acct_ctrl = pdb_get_acct_ctrl(pwd); copy_id23_to_sam_passwd(pwd, id23); @@ -2345,10 +2368,11 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) } /* if it's a trust account, don't update /etc/passwd */ - 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")); + if ( (!IS_SAM_UNIX_USER(pwd)) || + ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || + ( (acct_ctrl & ACB_WSTRUST) == ACB_WSTRUST) || + ( (acct_ctrl & ACB_SVRTRUST) == ACB_SVRTRUST) ) { + DEBUG(5, ("Changing trust account or non-unix-user password, not updating /etc/passwd\n")); } else { /* update the UNIX password */ if (lp_unix_password_sync() ) @@ -2360,7 +2384,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) ZERO_STRUCT(plaintext_buf); - if(!pdb_update_sam_account(pwd, True)) { + if(!pdb_update_sam_account(pwd)) { pdb_free_sam(&pwd); return False; } @@ -2388,6 +2412,9 @@ static BOOL set_user_info_pw(char *pass, uint32 rid) return False; } + DEBUG(5, ("Attempting administrator password change for user %s\n", + pdb_get_username(pwd))); + acct_ctrl = pdb_get_acct_ctrl(pwd); ZERO_STRUCT(plaintext_buf); @@ -2403,25 +2430,27 @@ static BOOL set_user_info_pw(char *pass, uint32 rid) } /* if it's a trust account, don't update /etc/passwd */ - 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")); + if ( (!IS_SAM_UNIX_USER(pwd)) || + ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || + ( (acct_ctrl & ACB_WSTRUST) == ACB_WSTRUST) || + ( (acct_ctrl & ACB_SVRTRUST) == ACB_SVRTRUST) ) { + DEBUG(5, ("Changing trust account or non-unix-user password, not updating /etc/passwd\n")); } else { /* update the UNIX password */ - if (lp_unix_password_sync()) + if (lp_unix_password_sync()) { if(!chgpasswd(pdb_get_username(pwd), "", plaintext_buf, True)) { pdb_free_sam(&pwd); return False; } + } } ZERO_STRUCT(plaintext_buf); - DEBUG(5,("set_user_info_pw: pdb_update_sam_account()\n")); + DEBUG(5,("set_user_info_pw: pdb_update_pwd()\n")); /* update the SAMBA password */ - if(!pdb_update_sam_account(pwd, True)) { + if(!pdb_update_sam_account(pwd)) { pdb_free_sam(&pwd); return False; } @@ -2442,7 +2471,6 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE 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__)); @@ -3052,7 +3080,7 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM smb_delete_user(pdb_get_username(sam_pass)); /* and delete the samba side */ - if (!pdb_delete_sam_account(pdb_get_username(sam_pass))) { + if (!pdb_delete_sam_account(sam_pass)) { DEBUG(5,("_samr_delete_dom_user:Failed to delete entry for user %s.\n", pdb_get_username(sam_pass))); pdb_free_sam(&sam_pass); return NT_STATUS_CANNOT_DELETE; -- cgit From 5b5b6771a84caddd8ebdbb6ad24f5b10b15fce3e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 20 Jan 2002 23:05:23 +0000 Subject: Fix the negation of the extra parinoia check on machine password changes. I *love* automated testing - this one got picked up by the build farm. Andew Bartlett (This used to be commit b19296172a75449a27eb9f674c74c462b146e717) --- source3/rpc_server/srv_netlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 077dbb0e2b..75a64b3039 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -410,7 +410,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * return NT_STATUS_NO_SUCH_USER; } - if (!(pdb_get_acct_ctrl(sampass) & ACB_DISABLED)) { + if (pdb_get_acct_ctrl(sampass) & ACB_DISABLED) { pdb_free_sam(&sampass); return NT_STATUS_ACCOUNT_DISABLED; } -- cgit From e24937d9a20649f73305ecd1a27fdde8c2be59b4 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 22 Jan 2002 18:19:00 +0000 Subject: merge from appliance_head (This used to be commit 38d2d26af9ef4d90dcb57fa940267f7136876191) --- source3/rpc_server/srv_pipe_hnd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 1b3d66bf49..a0afa0e548 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -574,10 +574,13 @@ authentication failed. Denying the request.\n", p->name)); } /* - * Check the data length doesn't go over the 10Mb limit. + * Check the data length doesn't go over the 15Mb limit. + * increased after observing a bug in the Windows NT 4.0 SP6a + * spoolsv.exe when the response to a GETPRINTERDRIVER2 RPC + * will not fit in the initial buffer of size 0x1068 --jerry 22/01/2002 */ - if(prs_data_size(&p->in_data.data) + data_len > 10*1024*1024) { + if(prs_data_size(&p->in_data.data) + data_len > 15*1024*1024) { DEBUG(0,("process_request_pdu: rpc data buffer too large (%u) + (%u)\n", (unsigned int)prs_data_size(&p->in_data.data), (unsigned int)data_len )); set_incoming_fault(p); -- cgit From 1182b7cd8cdfcb5065ed5ca65be4ebfd84f44b2a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 22 Jan 2002 19:45:17 +0000 Subject: Merge of fixes from 2.2. Jeremy. (This used to be commit 6406a42d012184f5289d4a2b1c07a55556635fe4) --- source3/rpc_server/srv_lsa_hnd.c | 19 ++++++++++--------- source3/rpc_server/srv_reg_nt.c | 9 ++++----- source3/rpc_server/srv_spoolss_nt.c | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index e4a00443a1..5affa9f5b0 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -110,15 +110,16 @@ BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *) pol->data_ptr = data_ptr; pol->free_fn = free_fn; - pol_hnd_low++; - if (pol_hnd_low == 0) (pol_hnd_high)++; - - SIVAL(&pol->pol_hnd.data1, 0 , 0); /* first bit must be null */ - SIVAL(&pol->pol_hnd.data2, 0 , pol_hnd_low ); /* second bit is incrementing */ - SSVAL(&pol->pol_hnd.data3, 0 , pol_hnd_high); /* second bit is incrementing */ - SSVAL(&pol->pol_hnd.data4, 0 , (pol_hnd_high>>16)); /* second bit is incrementing */ - SIVAL(pol->pol_hnd.data5, 0, time(NULL)); /* something random */ - SIVAL(pol->pol_hnd.data5, 4, sys_getpid()); /* something more random */ + pol_hnd_low++; + if (pol_hnd_low == 0) + (pol_hnd_high)++; + + SIVAL(&pol->pol_hnd.data1, 0 , 0); /* first bit must be null */ + SIVAL(&pol->pol_hnd.data2, 0 , pol_hnd_low ); /* second bit is incrementing */ + SSVAL(&pol->pol_hnd.data3, 0 , pol_hnd_high); /* second bit is incrementing */ + SSVAL(&pol->pol_hnd.data4, 0 , (pol_hnd_high>>16)); /* second bit is incrementing */ + SIVAL(pol->pol_hnd.data5, 0, time(NULL)); /* something random */ + SIVAL(pol->pol_hnd.data5, 4, sys_getpid()); /* something more random */ DLIST_ADD(p->pipe_handles->Policy, pol); p->pipe_handles->count++; diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 5901a783b9..ad47fe2d4e 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -27,10 +27,9 @@ #include "includes.h" -struct reg_info -{ - /* for use by \PIPE\winreg */ - fstring name; /* name of registry key */ +struct reg_info { + /* for use by \PIPE\winreg */ + fstring name; /* name of registry key */ }; static void free_reg_info(void *ptr) @@ -124,7 +123,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) DEBUG(5,("_reg_info: %d\n", __LINE__)); - if (find_policy_by_hnd(p, &q_u->pol, NULL) == -1) + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) return NT_STATUS_INVALID_HANDLE; rpcstr_pull(name, q_u->uni_type.buffer, sizeof(name), q_u->uni_type.uni_str_len*2, 0); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index bdd2bbf31b..cffd88c3aa 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -316,7 +316,7 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) } return WERR_OK; -} +} /**************************************************************************** return the snum of a printer corresponding to an handle -- cgit From f0fe8ff18ad49ed9dee98a8a68cdb58275eb7beb Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 23 Jan 2002 11:47:19 +0000 Subject: Sync up startpageprinter with appliance. (This used to be commit 6025ab201aa34bbf4a7e897149ef6ba370a89703) --- source3/rpc_server/srv_spoolss_nt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cffd88c3aa..57521dc144 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4011,13 +4011,13 @@ WERROR _spoolss_startpageprinter(pipes_struct *p, SPOOL_Q_STARTPAGEPRINTER *q_u, Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - if (Printer) { - Printer->page_started=True; - return WERR_OK; + if (!Printer) { + DEBUG(3,("Error in startpageprinter printer handle\n")); + return WERR_BADFID; } - DEBUG(3,("Error in startpageprinter printer handle\n")); - return WERR_BADFID; + Printer->page_started=True; + return WERR_OK; } /**************************************************************************** -- cgit From 565b9cc1572e284ed5d9324f232249a32b76f164 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 25 Jan 2002 05:28:37 +0000 Subject: Return correct RPC fault PDU on bad handle incoming. Jeremy. (This used to be commit 0db93d8752197e213f0974edae53e2dafdd77b51) --- source3/rpc_server/srv_lsa_hnd.c | 2 ++ source3/rpc_server/srv_pipe.c | 7 +++++++ 2 files changed, 9 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 5affa9f5b0..65f43c82e2 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -157,6 +157,8 @@ static struct policy *find_policy_by_hnd_internal(pipes_struct *p, POLICY_HND *h DEBUG(4,("Policy not found: ")); dump_data(4, (char *)hnd, sizeof(*hnd)); + p->bad_handle_fault_state = True; + return NULL; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 2630729281..45e5567d1b 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1188,6 +1188,13 @@ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, return False; } + if (p->bad_handle_fault_state) { + DEBUG(4,("api_rpcTNP: bad handle fault return.\n")); + p->bad_handle_fault_state = False; + setup_fault_pdu(p, NT_STATUS(0x1C00001A)); + return True; + } + slprintf(name, sizeof(name)-1, "out_%s", rpc_name); offset2 = prs_offset(&p->out_data.rdata); prs_set_offset(&p->out_data.rdata, offset1); -- cgit From b3e5d34171b8e5e6320c28379cb0021bf857efa5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 25 Jan 2002 18:27:40 +0000 Subject: Make systemtime work for spooling on bigendian systems. Fix from Benjamin (Bj) Kuit bj@it.uts.edu.au. Jeremy. (This used to be commit 5f4de275a3a63a95e76d077ffc94321a078833bf) --- source3/rpc_server/srv_spoolss_nt.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 57521dc144..8a13ebe19e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2009,8 +2009,9 @@ static void spoolss_notify_job_size(int snum, } /******************************************************************* - * fill a notify_info_data with job position + Fill a notify_info_data with job position. ********************************************************************/ + static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -2022,8 +2023,9 @@ static void spoolss_notify_job_position(int snum, } /******************************************************************* - * fill a notify_info_data with submitted time + Fill a notify_info_data with submitted time. ********************************************************************/ + static void spoolss_notify_submitted_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -2033,6 +2035,7 @@ static void spoolss_notify_submitted_time(int snum, struct tm *t; uint32 len; SYSTEMTIME st; + char *p; t=gmtime(&queue->time); @@ -2047,7 +2050,21 @@ static void spoolss_notify_submitted_time(int snum, } make_systemtime(&st, t); - memcpy(data->notify_data.data.string,&st,len); + + /* + * Systemtime must be linearized as a set of UINT16's. + * Fix from Benjamin (Bj) Kuit bj@it.uts.edu.au + */ + + p = (char *)data->notify_data.data.string; + SSVAL(p, 0, st.year); + SSVAL(p, 2, st.month); + SSVAL(p, 4, st.dayofweek); + SSVAL(p, 6, st.day); + SSVAL(p, 8, st.hour); + SSVAL(p, 10, st.minute); + SSVAL(p, 12, st.second); + SSVAL(p, 14, st.milliseconds); } #define END 65535 -- cgit From 5b0dca4998837231b931aa9a4a546079454d780e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 26 Jan 2002 01:20:38 +0000 Subject: Fixed ADDPRINTEREX to take a devmode and a security descriptor... Jeremy. (This used to be commit 27f65b3aad13ecd33bbb84048d70e3dde212f278) --- source3/rpc_server/srv_spoolss_nt.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8a13ebe19e..c96612eef2 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5843,7 +5843,7 @@ WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUM ****************************************************************************/ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_srv_name, const SPOOL_PRINTER_INFO_LEVEL *info, - uint32 unk0, uint32 unk1, uint32 unk2, uint32 unk3, + DEVICEMODE *devmode, SEC_DESC_BUF *sec_desc_buf, uint32 user_switch, const SPOOL_USER_CTR *user, POLICY_HND *handle) { @@ -5939,10 +5939,8 @@ WERROR _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_ UNISTR2 *uni_srv_name = &q_u->server_name; uint32 level = q_u->level; SPOOL_PRINTER_INFO_LEVEL *info = &q_u->info; - uint32 unk0 = q_u->unk0; - uint32 unk1 = q_u->unk1; - uint32 unk2 = q_u->unk2; - uint32 unk3 = q_u->unk3; + DEVICEMODE *devmode = q_u->devmode_ctr.devmode; + SEC_DESC_BUF *sdb = q_u->secdesc_ctr; uint32 user_switch = q_u->user_switch; SPOOL_USER_CTR *user = &q_u->user_ctr; POLICY_HND *handle = &r_u->handle; @@ -5954,7 +5952,7 @@ WERROR _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_ return WERR_UNKNOWN_LEVEL; case 2: return spoolss_addprinterex_level_2(p, uni_srv_name, info, - unk0, unk1, unk2, unk3, + devmode, sdb, user_switch, user, handle); default: return WERR_UNKNOWN_LEVEL; -- cgit From 29ad4a76cd629ba28087926080558f57417aa00c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 26 Jan 2002 05:52:20 +0000 Subject: Try to move towards slightly sane linking for Samba by removing some pdb_...() calls from rpc_parse/parse_net.c - instead these values are passed as a paramater. Unfortunetly some there is still some samr work to be done before this is actually useful. Andrew Bartlett (This used to be commit 4fc9e16ad7a77cf2e37b27640c0dec2052e9cda0) --- source3/rpc_server/srv_netlog_nt.c | 42 +++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 75a64b3039..7a1c69fb25 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -505,6 +505,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * auth_usersupplied_info *user_info = NULL; auth_serversupplied_info *server_info = NULL; extern userdom_struct current_user_info; + SAM_ACCOUNT *sampw; usr_info = (NET_USER_INFO_3 *)talloc(p->mem_ctx, sizeof(NET_USER_INFO_3)); if (!usr_info) @@ -675,18 +676,35 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * gids = NULL; get_domain_user_groups(p->mem_ctx, &num_gids, &gids, server_info->sam_account); - init_net_user_info3(p->mem_ctx, usr_info, server_info->sam_account, - 0, /* logon_count */ - 0, /* bad_pw_count */ - num_gids, /* uint32 num_groups */ - gids , /* DOM_GID *gids */ - 0x20 , /* uint32 user_flgs (?) */ - NULL, /* uchar sess_key[16] */ - my_name , /* char *logon_srv */ - my_workgroup, /* char *logon_dom */ - &global_sam_sid, /* DOM_SID *dom_sid */ - NULL); /* char *other_sids */ - + sampw = server_info->sam_account; + + init_net_user_info3(p->mem_ctx, usr_info, + pdb_get_user_rid(sampw), + pdb_get_group_rid(sampw), + + pdb_get_username(sampw), + pdb_get_fullname(sampw), + pdb_get_homedir(sampw), + pdb_get_dirdrive(sampw), + pdb_get_logon_script(sampw), + pdb_get_profile_path(sampw), + pdb_get_logon_time(sampw), + pdb_get_logoff_time(sampw), + pdb_get_kickoff_time(sampw), + pdb_get_pass_last_set_time(sampw), + pdb_get_pass_can_change_time(sampw), + pdb_get_pass_must_change_time(sampw), + + 0, /* logon_count */ + 0, /* bad_pw_count */ + num_gids, /* uint32 num_groups */ + gids , /* DOM_GID *gids */ + 0x20 , /* uint32 user_flgs (?) */ + NULL, /* uchar sess_key[16] */ + my_name , /* char *logon_srv */ + my_workgroup, /* char *logon_dom */ + &global_sam_sid, /* DOM_SID *dom_sid */ + NULL); /* char *other_sids */ } free_server_info(&server_info); return status; -- cgit From 965f440983f953d77d5771d24907d3907ab0b463 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 26 Jan 2002 10:02:23 +0000 Subject: Move the lsa code across to the changed args for lookup_name, and surround it in become_root()/unbecome_root(). Also only allocate the memory the client reqests - and don't allow the client to trigger an SMB_ASSERT if they ask for 'more'. Up the maximum number of sids allowed, and note that this is an arbiary guess, and can be raised without consequence. Andrew Bartlett (This used to be commit 6e7667125d142670db7393ed7a48386f3821d896) --- source3/rpc_server/srv_lsa_nt.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 9916b99c8a..412d0e775e 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -140,6 +140,8 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS); + become_root(); /* lookup_name can require root privs */ + for (i = 0; i < num_entries; i++) { BOOL status = False; DOM_SID sid; @@ -158,7 +160,7 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, DEBUG(5, ("init_lsa_rid2s: looking up name %s\n", full_name)); - status = lookup_name(full_name, &sid, &name_type); + status = lookup_name(dom_name, user, &sid, &name_type); DEBUG(5, ("init_lsa_rid2s: %s\n", status ? "found" : "not found")); @@ -176,6 +178,8 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, init_dom_rid2(&rid2[total], rid, name_type, dom_idx); total++; } + + unbecome_root(); } /*************************************************************************** @@ -612,8 +616,13 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP if (!(handle->access & POLICY_LOOKUP_NAMES)) return NT_STATUS_ACCESS_DENIED; + if (num_entries > MAX_LOOKUP_SIDS) { + num_entries = MAX_LOOKUP_SIDS; + DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries)); + } + ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); - rids = (DOM_RID2 *)talloc_zero(p->mem_ctx, sizeof(DOM_RID2)*MAX_LOOKUP_SIDS); + rids = (DOM_RID2 *)talloc_zero(p->mem_ctx, sizeof(DOM_RID2)*num_entries); if (!ref || !rids) return NT_STATUS_NO_MEMORY; -- cgit From abd7df24dcabb54cb22c0e088f8d71f84bbef2d7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 26 Jan 2002 10:03:25 +0000 Subject: Add the become_root()/unbecome_root() wrapper around the lookup_name() call, and its new args. (This used to be commit e7b3d64f6055b5d3b036f525f0ece3c9479d4f7a) --- source3/rpc_server/srv_samr_nt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d079403455..bd75eceb6b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1189,6 +1189,8 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO } DEBUG(5,("_samr_lookup_names: looking name on SID %s\n", sid_to_string(sid_str, &pol_sid))); + + become_root(); /* local_lookup_name can require root privs */ for (i = 0; i < num_rids; i++) { fstring name; @@ -1212,7 +1214,7 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO * a cleaner code is to add the sid of the domain we're looking in * to the local_lookup_name function. */ - if(local_lookup_name(global_myname, name, &sid, &local_type)) { + if(local_lookup_name(name, &sid, &local_type)) { sid_split_rid(&sid, &local_rid); if (sid_equal(&sid, &pol_sid)) { @@ -1223,6 +1225,8 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO } } + unbecome_root(); + init_samr_r_lookup_names(p->mem_ctx, r_u, num_rids, rid, (uint32 *)type, r_u->status); DEBUG(5,("_samr_lookup_names: %d\n", __LINE__)); @@ -1342,6 +1346,8 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK r_u->status = NT_STATUS_NONE_MAPPED; + become_root(); /* lookup_sid can require root privs */ + for (i = 0; i < num_rids; i++) { fstring tmpname; fstring domname; @@ -1364,6 +1370,8 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK } } + unbecome_root(); + if(!make_samr_lookup_rids(p->mem_ctx, num_rids, group_names, &hdr_name, &uni_name)) return NT_STATUS_NO_MEMORY; -- cgit From 485b4ff5ecf40620a0a6fedc0929dacdb28876a2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 26 Jan 2002 22:27:12 +0000 Subject: merge from APPLIANCE_HEAD (This used to be commit e3b87ffc8c26f9fd4c3e8181897b8812b7dc4ab6) --- source3/rpc_server/srv_spoolss_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c96612eef2..02f7085119 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4597,7 +4597,7 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, PI_CHECK_INT(averageppm); /* Yuck - don't check the printername or servername as the - add_a_printer() code plays games with them. You can't + mod_a_printer() code plays games with them. You can't change the printername or the sharename through this interface in Samba. */ @@ -4735,7 +4735,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, } /* Update printer info */ - result = add_a_printer(*printer, 2); + result = mod_a_printer(*printer, 2); done: free_a_printer(&printer, 2); @@ -5911,7 +5911,7 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ set_driver_init(printer, 2); /* write the ASCII on disk */ - err = add_a_printer(*printer, 2); + err = mod_a_printer(*printer, 2); if (!W_ERROR_IS_OK(err)) { free_a_printer(&printer,2); return err; -- cgit From cd68afe31256ad60748b34f7318a180cfc2127cc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Jan 2002 06:08:46 +0000 Subject: Removed version number from file header. Changed "SMB/Netbios" to "SMB/CIFS" in file header. (This used to be commit 6a58c9bd06d0d7502a24bf5ce5a2faf0a146edfa) --- source3/rpc_server/srv_dfs.c | 3 +-- source3/rpc_server/srv_dfs_nt.c | 3 +-- source3/rpc_server/srv_lsa.c | 3 +-- source3/rpc_server/srv_lsa_hnd.c | 3 +-- source3/rpc_server/srv_lsa_nt.c | 3 +-- source3/rpc_server/srv_netlog.c | 3 +-- source3/rpc_server/srv_netlog_nt.c | 3 +-- source3/rpc_server/srv_pipe.c | 3 +-- source3/rpc_server/srv_pipe_hnd.c | 3 +-- source3/rpc_server/srv_reg.c | 3 +-- source3/rpc_server/srv_reg_nt.c | 3 +-- source3/rpc_server/srv_samr.c | 3 +-- source3/rpc_server/srv_samr_nt.c | 3 +-- source3/rpc_server/srv_spoolss.c | 3 +-- source3/rpc_server/srv_spoolss_nt.c | 3 +-- source3/rpc_server/srv_srvsvc.c | 3 +-- source3/rpc_server/srv_srvsvc_nt.c | 3 +-- source3/rpc_server/srv_util.c | 3 +-- source3/rpc_server/srv_wkssvc.c | 3 +-- source3/rpc_server/srv_wkssvc_nt.c | 3 +-- 20 files changed, 20 insertions(+), 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 00a0f58df5..4351fd088e 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines for Dfs * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index e62334c377..4db6c61a3c 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines for Dfs * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index b05fb972be..fcd4be0212 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 65f43c82e2..0e06a04177 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 412d0e775e..97361cab4c 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 06e2f75ead..dfd270ff7d 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 7a1c69fb25..d382f12fcf 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 45e5567d1b..70574b4cdd 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1998 * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index a0afa0e548..07dc2210c1 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1998, * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 1280dc4aa9..569f3fb8b1 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index ad47fe2d4e..adedd4a8fa 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 35fc5dd904..c555305bce 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index bd75eceb6b..552623306f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index e71bcd36a9..3f3c6039c9 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 02f7085119..bba7c54b81 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 35bacc3458..ee4ec8aa0a 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 67442a7761..148bcb4d1e 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 1788512db7..53bbebb95e 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1998 * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 3661824da1..8eb5b3002e 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index f618531b5f..637c95af69 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, -- cgit From b48750fba603f9e04b08e346744bcc9c6a49a1af Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 31 Jan 2002 09:37:26 +0000 Subject: this fixes the problem of not being able to add a SD to a file on a non-domain Samba server from a NT4 client. Note that this exactly reverses a change by Jeremy on the 18th of December 2001, reverting the code back to what JF originally wrote. I have looked carefully with a sniffer and JFs original NULL sid is correct (ie. it matches what NT4 does) and also fixes the problem. Sending a blank sid (which is what jeremy's patch did) causes NT4 to give a classic "parameter is incorrect error" and prevents the addition of new ACLs. (This used to be commit 9930cf97330dd93985c5558cec6b24406e90c228) --- source3/rpc_server/srv_lsa_nt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 97361cab4c..c044340456 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -441,7 +441,6 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO *r_u) { - extern DOM_SID global_sid_nonexistent; struct lsa_info *handle; LSA_INFO_UNION *info = &r_u->dom; DOM_SID domain_sid; @@ -494,7 +493,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF break; case ROLE_STANDALONE: name = global_myworkgroup; - sid = &global_sid_nonexistent; + sid = NULL; break; default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; -- cgit From 8fff9a4b9e9104815ac83a768e0ab258e788cf5a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 31 Jan 2002 11:44:00 +0000 Subject: Added administrator access check for server side add, delete and setform rpcs. The only one I have been able to verify is addform - can't get the client side routines working properly yet. )-: (This used to be commit 3cd97d65dea428382104ebde63eaf660aa3942fb) --- source3/rpc_server/srv_spoolss_nt.c | 44 ++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index bba7c54b81..69ecf5cc77 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6402,8 +6402,7 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM /* uint32 level = q_u->level; - notused. */ FORM *form = &q_u->form; nt_forms_struct tmpForm; - - int count=0; + int count=0, snum; nt_forms_struct *list=NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); @@ -6414,14 +6413,19 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM return WERR_BADFID; } - /* - * FIXME!! Feels like there should be an access check here, but haven't - * had time to verify. --jerry - */ + /* Must be administrator to add a form */ + + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + + if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { + DEBUG(0, ("_spoolss_addform: Access denied\n")); + return WERR_ACCESS_DENIED; + } /* can't add if builtin */ if (get_a_builtin_ntform(&form->name,&tmpForm)) { - return WERR_INVALID_PARAM; + return WERR_FILE_EXISTS; } count=get_ntforms(&list); @@ -6442,7 +6446,7 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE POLICY_HND *handle = &q_u->handle; UNISTR2 *form_name = &q_u->name; nt_forms_struct tmpForm; - int count=0; + int count=0, snum; WERROR ret = WERR_OK; nt_forms_struct *list=NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); @@ -6454,6 +6458,16 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE return WERR_BADFID; } + /* Must be administrator to set a form */ + + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + + if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { + DEBUG(0, ("_spoolss_addform: Access denied\n")); + return WERR_ACCESS_DENIED; + } + /* can't delete if builtin */ if (get_a_builtin_ntform(form_name,&tmpForm)) { return WERR_INVALID_PARAM; @@ -6478,8 +6492,7 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * /* uint32 level = q_u->level; - notused. */ FORM *form = &q_u->form; nt_forms_struct tmpForm; - - int count=0; + int count=0, snum; nt_forms_struct *list=NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); @@ -6489,6 +6502,17 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * DEBUG(0,("_spoolss_setform: Invalid handle (%s).\n", OUR_HANDLE(handle))); return WERR_BADFID; } + + /* Must be administrator to set a form */ + + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + + if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { + DEBUG(0, ("_spoolss_addform: Access denied\n")); + return WERR_ACCESS_DENIED; + } + /* can't set if builtin */ if (get_a_builtin_ntform(&form->name,&tmpForm)) { return WERR_INVALID_PARAM; -- cgit From 7dbaaa09643db9e4f7eb129a9d38816e17e3b80c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 8 Feb 2002 21:51:40 +0000 Subject: merge from APPLIANCE_HEAD (This used to be commit e734c1971d2841b2cfe37414fe4893f4a66b22a9) --- source3/rpc_server/srv_pipe_hnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 07dc2210c1..44dd5fac65 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -579,7 +579,7 @@ authentication failed. Denying the request.\n", p->name)); * will not fit in the initial buffer of size 0x1068 --jerry 22/01/2002 */ - if(prs_data_size(&p->in_data.data) + data_len > 15*1024*1024) { + if(prs_offset(&p->in_data.data) + data_len > 15*1024*1024) { DEBUG(0,("process_request_pdu: rpc data buffer too large (%u) + (%u)\n", (unsigned int)prs_data_size(&p->in_data.data), (unsigned int)data_len )); set_incoming_fault(p); -- cgit From 03cfb31ad931c65ca8c5b97c620f6e71bf5cac82 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 9 Feb 2002 04:10:24 +0000 Subject: Bring printing in HEAD inline with 2.2.x and app-head. Jeremy. (This used to be commit 771ef92fc6e43725b7cc351079998a8acb74abef) --- source3/rpc_server/srv_spoolss_nt.c | 491 +++++++++++++++++++++++------------- 1 file changed, 320 insertions(+), 171 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 69ecf5cc77..f76b78f116 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1,12 +1,12 @@ /* - * Unix SMB/CIFS implementation. + * Unix SMB/Netbios implementation. + * Version 1.9. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000. * Copyright (C) Jeremy Allison 2001. * Copyright (C) Gerald Carter 2000-2001. - * Copyright (C) Tim Potter 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,6 +32,7 @@ #define MAX_OPEN_PRINTER_EXS 50 #endif +#define MAGIC_DISPLAY_FREQUENCY 0xfade2bad #define PHANTOM_DEVMODE_KEY "_p_f_a_n_t_0_m_" #define PRINTER_HANDLE_IS_PRINTER 0 #define PRINTER_HANDLE_IS_PRINTSERVER 1 @@ -48,9 +49,10 @@ struct table_node { /* and the notify info asked about */ /* that's the central struct */ typedef struct _Printer{ + struct _Printer *prev, *next; BOOL document_started; BOOL page_started; - int jobid; /* jobid in printing backend */ + int jobid; /* jobid in printing backend */ BOOL printer_type; union { fstring handlename; @@ -73,6 +75,8 @@ typedef struct _Printer{ } client; } Printer_entry; +static Printer_entry *printers_list; + typedef struct _counter_printer_0 { ubi_dlNode Next; ubi_dlNode Prev; @@ -86,7 +90,8 @@ static ubi_dlList counter_list; static struct cli_state cli; static uint32 smb_connections=0; -#define OUR_HANDLE(hnd) ((hnd==NULL)?"NULL":(IVAL(hnd->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")) +#define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ +((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) /* translate between internal status numbers and NT status numbers */ static int nt_printj_status(int v) @@ -193,6 +198,9 @@ static void free_printer_entry(void *ptr) Printer->notify.option=NULL; Printer->notify.client_connected=False; + /* Remove from the internal list. */ + DLIST_REMOVE(printers_list, Printer); + SAFE_FREE(Printer); } @@ -234,7 +242,7 @@ static Printer_entry *find_printer_index_by_hnd(pipes_struct *p, POLICY_HND *hnd Printer_entry *find_printer = NULL; if(!find_policy_by_hnd(p,hnd,(void **)&find_printer)) { - DEBUG(3,("find_printer_index_by_hnd: Printer handle not found: ")); + DEBUG(2,("find_printer_index_by_hnd: Printer handle not found: ")); return NULL; } @@ -242,7 +250,7 @@ static Printer_entry *find_printer_index_by_hnd(pipes_struct *p, POLICY_HND *hnd } /**************************************************************************** - close printer index by handle + Close printer index by handle. ****************************************************************************/ static BOOL close_printer_handle(pipes_struct *p, POLICY_HND *hnd) @@ -250,7 +258,7 @@ static BOOL close_printer_handle(pipes_struct *p, POLICY_HND *hnd) Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); if (!Printer) { - DEBUG(0,("close_printer_handle: Invalid handle (%s)\n", OUR_HANDLE(hnd))); + DEBUG(2,("close_printer_handle: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(hnd))); return False; } @@ -260,14 +268,15 @@ static BOOL close_printer_handle(pipes_struct *p, POLICY_HND *hnd) } /**************************************************************************** - delete a printer given a handle + Delete a printer given a handle. ****************************************************************************/ + static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) { Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); if (!Printer) { - DEBUG(0,("delete_printer_handle: Invalid handle (%s)\n", OUR_HANDLE(hnd))); + DEBUG(2,("delete_printer_handle: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(hnd))); return WERR_BADFID; } @@ -325,7 +334,7 @@ static BOOL get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number) Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); if (!Printer) { - DEBUG(0,("get_printer_snum: Invalid handle (%s)\n", OUR_HANDLE(hnd))); + DEBUG(2,("get_printer_snum: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(hnd))); return False; } @@ -349,7 +358,7 @@ static BOOL set_printer_hnd_accesstype(pipes_struct *p, POLICY_HND *hnd, uint32 Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); if (!Printer) { - DEBUG(0,("set_printer_hnd_accesstype: Invalid handle (%s)", OUR_HANDLE(hnd))); + DEBUG(2,("set_printer_hnd_accesstype: Invalid handle (%s:%u:%u)", OUR_HANDLE(hnd))); return False; } @@ -532,6 +541,9 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name) new_printer->notify.option=NULL; + /* Add to the internal list. */ + DLIST_ADD(printers_list, new_printer); + if (!create_policy_hnd(p, hnd, free_printer_entry, new_printer)) { SAFE_FREE(new_printer); return False; @@ -553,7 +565,7 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name) } /******************************************************************** - Return True is the handle is a print server. + Return True if the handle is a print server. ********************************************************************/ static BOOL handle_is_printserver(pipes_struct *p, POLICY_HND *handle) @@ -604,91 +616,62 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) } /*************************************************************************** - receive the notify message + Receive the notify message. ****************************************************************************/ static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) { - fstring printer; + Printer_entry *find_printer; WERROR status; - struct pipes_struct *p; - struct policy *pol; - struct handle_list *hl; - - *printer = '\0'; - fstrcpy(printer,buf); + char msg[8]; + uint32 low, high; - if (len == 0) { - DEBUG(0,("srv_spoolss_receive_message: got null message !\n")); + if (len != sizeof(msg)) { + DEBUG(2,("srv_spoolss_receive_message: got incorrect message size (%u)!\n", (unsigned int)len)); return; } - DEBUG(10,("srv_spoolss_receive_message: Got message about printer %s\n", printer )); - - /* - * We need to enumerate all printers. The handle list is shared - * across pipes of the same name, so just find the first open - * spoolss pipe. - */ - - hl = NULL; - for ( p = get_first_internal_pipe(); p; get_next_internal_pipe(p)) { - if (strequal(p->name, "spoolss")) { - hl = p->pipe_handles; - break; - } - } + memcpy(msg, buf, len); + low = IVAL(msg,0); + high = IVAL(msg,4); - if (!hl) { - DEBUG(0,("srv_spoolss_receive_message: no handle list on spoolss pipe !\n")); - return; - } + DEBUG(10,("srv_spoolss_receive_message: Got message printer change low=0x%x high=0x%x\n", (unsigned int)low, + (unsigned int)high )); - /* Iterate the printer list on this pipe. */ - for (pol = hl->Policy; pol; pol = pol->next ) { - Printer_entry *find_printer = (Printer_entry *)pol->data_ptr; + find_printer = printers_list; - if (!find_printer) - continue; + /* Iterate the printer list */ + for(; find_printer; find_printer = find_printer->next) { /* - * if the entry is the given printer or if it's a printerserver - * we send the message + * If the entry has a connected client we send the message. */ - if (find_printer->printer_type==PRINTER_HANDLE_IS_PRINTER) - if (strcmp(find_printer->dev.handlename, printer)) - continue; - if (find_printer->notify.client_connected==True) - cli_spoolss_reply_rrpcn(&cli, &find_printer->notify.client_hnd, PRINTER_CHANGE_ALL, 0x0, &status); + if (find_printer->notify.client_connected==True) { + DEBUG(10,("srv_spoolss_receive_message: printerserver [%s]\n", find_printer->dev.printerservername )); + if (cli_spoolss_reply_rrpcn(&cli, &find_printer->notify.client_hnd, low, high, &status)) + DEBUG(10,("srv_spoolss_receive_message: cli_spoolss_reply_rrpcn status = 0x%x\n", + (unsigned int)W_ERROR_V(status))); + else + DEBUG(10,("srv_spoolss_receive_message: cli_spoolss_reply_rrpcn failed\n")); + } } } /*************************************************************************** - send a notify event + Send a notify event. ****************************************************************************/ -static BOOL srv_spoolss_sendnotify(pipes_struct *p, POLICY_HND *handle) -{ - fstring printer; - - Printer_entry *Printer=find_printer_index_by_hnd(p, handle); - - if (!Printer) { - DEBUG(0,("srv_spoolss_sendnotify: Invalid handle (%s).\n", OUR_HANDLE(handle))); - return False; - } - if (Printer->printer_type==PRINTER_HANDLE_IS_PRINTER) - fstrcpy(printer, Printer->dev.handlename); - else - fstrcpy(printer, ""); - - /*srv_spoolss_receive_message(printer);*/ - DEBUG(10,("srv_spoolss_sendnotify: Sending message about printer %s\n", printer )); +static BOOL srv_spoolss_sendnotify(uint32 high, uint32 low) +{ + char msg[8]; - broadcast_printer_notify(printer); + SIVAL(msg,0,low); + SIVAL(msg,4,high); + DEBUG(10,("srv_spoolss_sendnotify: printer change low=0x%x high=0x%x\n", low, high)); + message_send_all(conn_tdb_ctx(), MSG_PRINTER_NOTIFY, msg, sizeof(msg), False, NULL); return True; } @@ -1021,7 +1004,7 @@ static WERROR _spoolss_enddocprinter_internal(pipes_struct *p, POLICY_HND *handl Printer_entry *Printer=find_printer_index_by_hnd(p, handle); if (!Printer) { - DEBUG(0,("_spoolss_enddocprinter_internal: Invalid handle (%s)\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_enddocprinter_internal: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle))); return WERR_BADFID; } @@ -1045,11 +1028,16 @@ WERROR _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL_R if (Printer && Printer->document_started) _spoolss_enddocprinter_internal(p, handle); /* print job was not closed */ - memcpy(&r_u->handle, &q_u->handle, sizeof(r_u->handle)); - if (!close_printer_handle(p, handle)) return WERR_BADFID; + /* clear the returned printer handle. Observed behavior + from Win2k server. Don't think this really matters. + Previous code just copied the value of the closed + handle. --jerry */ + + memset(&r_u->handle, '\0', sizeof(r_u->handle)); + return WERR_OK; } @@ -1071,8 +1059,10 @@ WERROR _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL result = delete_printer_handle(p, handle); + update_c_setprinter(FALSE); + if (W_ERROR_IS_OK(result)) { - srv_spoolss_sendnotify(p, handle); + srv_spoolss_sendnotify(0, PRINTER_CHANGE_DELETE_PRINTER); } return result; @@ -1160,6 +1150,14 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 DEBUG(8,("getprinterdata_printer_server:%s\n", value)); + if (!strcmp(value, "W3SvcInstalled")) { + *type = 0x4; + if((*data = (uint8 *)talloc_zero(ctx, 4*sizeof(uint8) )) == NULL) + return False; + *needed = 0x4; + return True; + } + if (!strcmp(value, "BeepEnabled")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) @@ -1245,7 +1243,7 @@ static BOOL getprinterdata_printer(pipes_struct *p, TALLOC_CTX *ctx, POLICY_HND DEBUG(5,("getprinterdata_printer\n")); if (!Printer) { - DEBUG(0,("getprinterdata_printer: Invalid handle (%s).\n", OUR_HANDLE(handle))); + DEBUG(2,("getprinterdata_printer: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return False; } @@ -1321,7 +1319,7 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO if (!Printer) { if((*data=(uint8 *)talloc_zero(p->mem_ctx, 4*sizeof(uint8))) == NULL) return WERR_NOMEM; - DEBUG(0,("_spoolss_getprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_getprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } @@ -1407,7 +1405,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE Printer_entry *Printer=find_printer_index_by_hnd(p, handle); if (!Printer) { - DEBUG(0,("_spoolss_rffpcnex: Invalid handle (%s).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_rffpcnex: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } @@ -1448,7 +1446,7 @@ static void spoolss_notify_server_name(int snum, len = rpcstr_push(temp, temp_name, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2; + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1472,7 +1470,7 @@ static void spoolss_notify_printer_name(int snum, uint32 len; /* the notify name should not contain the \\server\ part */ - char *p = strrchr_m(printer->info_2->printername, '\\'); + char *p = strrchr(printer->info_2->printername, '\\'); if (!p) { p = printer->info_2->printername; @@ -1481,7 +1479,8 @@ static void spoolss_notify_printer_name(int snum, } len = rpcstr_push(temp, p, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2; + + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1506,7 +1505,7 @@ static void spoolss_notify_share_name(int snum, len = rpcstr_push(temp, lp_servicename(snum), sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2; + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1533,7 +1532,7 @@ static void spoolss_notify_port_name(int snum, len = rpcstr_push(temp, printer->info_2->portname, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2; + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1559,7 +1558,7 @@ static void spoolss_notify_driver_name(int snum, uint32 len; len = rpcstr_push(temp, printer->info_2->drivername, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2; + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1584,11 +1583,10 @@ static void spoolss_notify_comment(int snum, if (*printer->info_2->comment == '\0') len = rpcstr_push(temp, lp_comment(snum), sizeof(temp)-2, STR_TERMINATE); - else len = rpcstr_push(temp, printer->info_2->comment, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2; + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1615,7 +1613,7 @@ static void spoolss_notify_location(int snum, len = rpcstr_push(temp, printer->info_2->location,sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2; + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1654,7 +1652,7 @@ static void spoolss_notify_sepfile(int snum, len = rpcstr_push(temp, printer->info_2->sepfile, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2; + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1680,7 +1678,7 @@ static void spoolss_notify_print_processor(int snum, len = rpcstr_push(temp, printer->info_2->printprocessor, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2; + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1706,7 +1704,7 @@ static void spoolss_notify_parameters(int snum, len = rpcstr_push(temp, printer->info_2->parameters, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2; + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1732,7 +1730,7 @@ static void spoolss_notify_datatype(int snum, len = rpcstr_push(temp, printer->info_2->datatype, sizeof(pstring)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2; + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1882,8 +1880,7 @@ static void spoolss_notify_username(int snum, len = rpcstr_push(temp, queue->user, sizeof(temp)-2, STR_TERMINATE); - - data->notify_data.data.length = len / 2; + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1920,8 +1917,8 @@ static void spoolss_notify_job_name(int snum, uint32 len; len = rpcstr_push(temp, queue->file, sizeof(temp)-2, STR_TERMINATE); - - data->notify_data.data.length = len / 2; + + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1970,7 +1967,7 @@ static void spoolss_notify_job_status_string(int snum, len = rpcstr_push(temp, p, sizeof(temp) - 2, STR_TERMINATE); - data->notify_data.data.length = len / 2; + data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -2248,7 +2245,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int continue; 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")); + DEBUG(2,("construct_notify_printer_info: failed to enlarge buffer info->data!\n")); return False; } else info->data = tid; @@ -2303,7 +2300,7 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, continue; 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")); + DEBUG(2,("construct_notify_jobs_info: failed to enlarg buffer info->data!\n")); return False; } else info->data = tid; @@ -2363,6 +2360,9 @@ static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, DEBUG(4,("printserver_notify_info\n")); + if (!Printer) + return WERR_BADFID; + option=Printer->notify.option; id=1; info->version=2; @@ -2420,6 +2420,9 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY DEBUG(4,("printer_notify_info\n")); + if (!Printer) + return WERR_BADFID; + option=Printer->notify.option; id=0xffffffff; info->version=2; @@ -2500,7 +2503,7 @@ WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN r_u->info_ptr=0x1; if (!Printer) { - DEBUG(0,("_spoolss_rfnpcnex: Invalid handle (%s).\n", + DEBUG(2,("_spoolss_rfnpcnex: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); goto done; } @@ -2624,7 +2627,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) printer->unknown18 = 0x0; printer->status = nt_printq_status(status.status); printer->unknown20 = 0x0; - printer->c_setprinter = ntprinter->info_2->c_setprinter; /* how many times setprinter has been called */ + printer->c_setprinter = get_c_setprinter(); /* monotonically increasing sum of delta printer counts */ printer->unknown22 = 0x0; printer->unknown23 = 0x6; /* 6 ???*/ printer->unknown24 = 0; /* unknown 24 to 26 are always 0 */ @@ -2683,7 +2686,7 @@ static void free_dev_mode(DEVICEMODE *dev) if (dev == NULL) return; - SAFE_FREE(dev->private); + SAFE_FREE(dev->private); SAFE_FREE(dev); } @@ -2704,7 +2707,7 @@ static DEVICEMODE *construct_dev_mode(int snum) DEBUGADD(8,("getting printer characteristics\n")); if ((devmode = (DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL) { - DEBUG(0,("construct_dev_mode: malloc fail.\n")); + DEBUG(2,("construct_dev_mode: malloc fail.\n")); return NULL; } @@ -2849,7 +2852,7 @@ static BOOL construct_printer_info_3(PRINTER_INFO_3 **pp_printer, int snum) *pp_printer = NULL; if ((printer = (PRINTER_INFO_3 *)malloc(sizeof(PRINTER_INFO_3))) == NULL) { - DEBUG(0,("construct_printer_info_3: malloc fail.\n")); + DEBUG(2,("construct_printer_info_3: malloc fail.\n")); return False; } @@ -2951,7 +2954,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 if (construct_printer_info_1(flags, ¤t_prt, snum)) { if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) { - DEBUG(0,("enum_all_printers_info_1: failed to enlarge printers buffer!\n")); + DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n")); SAFE_FREE(printers); *returned=0; return WERR_NOMEM; @@ -3007,7 +3010,7 @@ static WERROR enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, ui if ((name[0] == '\\') && (name[1] == '\\')) s = name + 2; - + if (is_myname_or_ipaddr(s)) { return enum_all_printers_info_1(PRINTER_ENUM_ICON8, buffer, offered, needed, returned); } @@ -3100,7 +3103,7 @@ static WERROR enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint3 if (construct_printer_info_2(¤t_prt, snum)) { if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2))) == NULL) { - DEBUG(0,("enum_all_printers_info_2: failed to enlarge printers buffer!\n")); + DEBUG(2,("enum_all_printers_info_2: failed to enlarge printers buffer!\n")); SAFE_FREE(printers); *returned = 0; return WERR_NOMEM; @@ -3613,10 +3616,10 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser slprintf(line, sizeof(line)-1, "\\\\%s%s", servername, v); DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); if((tuary=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL) { - DEBUG(0,("init_unistr_array: Realloc error\n" )); + DEBUG(2,("init_unistr_array: Realloc error\n" )); return; - } - else *uni_array = tuary; + } else + *uni_array = tuary; j += (rpcstr_push((*uni_array+j), line, sizeof(uint16)*strlen(line)+2, 0)/ sizeof(uint16)); i++; } @@ -3692,10 +3695,38 @@ static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); DEBUG(8,("construct_printer_driver_info_3: status: %s\n", werror_str(status))); + +#if 0 /* JERRY */ + + /* + * I put this code in during testing. Helpful when commenting out the + * support for DRIVER_INFO_6 in regards to win2k. Not needed in general + * as win2k always queries the driver using an infor level of 6. + * I've left it in (but ifdef'd out) because I'll probably + * use it in experimentation again in the future. --jerry 22/01/2002 + */ + if (!W_ERROR_IS_OK(status)) { - free_a_printer(&printer,2); - return WERR_UNKNOWN_PRINTER_DRIVER; + /* + * Is this a W2k client ? + */ + if (version == 3) { + /* Yes - try again with a WinNT driver. */ + version = 2; + status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); + DEBUG(8,("construct_printer_driver_info_3: status: %s\n", werror_str(status))); + } +#endif + + if (!W_ERROR_IS_OK(status)) { + free_a_printer(&printer,2); + return WERR_UNKNOWN_PRINTER_DRIVER; + } + +#if 0 /* JERRY */ } +#endif + fill_printer_driver_info_3(info, driver, servername); @@ -4046,7 +4077,7 @@ WERROR _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPO Printer_entry *Printer = find_printer_index_by_hnd(p, handle); if (!Printer) { - DEBUG(0,("_spoolss_endpageprinter: Invalid handle (%s).\n",OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_endpageprinter: Invalid handle (%s:%u:%u).\n",OUR_HANDLE(handle))); return WERR_BADFID; } @@ -4076,7 +4107,7 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S struct current_user user; if (!Printer) { - DEBUG(0,("_spoolss_startdocprinter: Invalid handle (%s)\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_startdocprinter: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle))); return WERR_BADFID; } @@ -4150,7 +4181,7 @@ WERROR _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R Printer_entry *Printer = find_printer_index_by_hnd(p, handle); if (!Printer) { - DEBUG(0,("_spoolss_writeprinter: Invalid handle (%s)\n",OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_writeprinter: Invalid handle (%s:%u:%u)\n",OUR_HANDLE(handle))); r_u->buffer_written = q_u->buffer_size2; return WERR_BADFID; } @@ -4179,7 +4210,7 @@ static WERROR control_printer(POLICY_HND *handle, uint32 command, get_current_user(&user, p); if (!Printer) { - DEBUG(0,("control_printer: Invalid handle (%s)\n", OUR_HANDLE(handle))); + DEBUG(2,("control_printer: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle))); return WERR_BADFID; } @@ -4237,7 +4268,7 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, Printer_entry *Printer = find_printer_index_by_hnd(p, handle); if (!Printer || !get_printer_snum(p, handle, &snum)) { - DEBUG(0,("update_printer_sec: Invalid handle (%s)\n", + DEBUG(2,("update_printer_sec: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle))); result = WERR_BADFID; @@ -4331,10 +4362,7 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s", get_called_name(), lp_servicename(snum)); fstrcpy(info->sharename, lp_servicename(snum)); - info->attributes = PRINTER_ATTRIBUTE_SHARED \ - | PRINTER_ATTRIBUTE_LOCAL \ - | PRINTER_ATTRIBUTE_RAW_ONLY \ - | PRINTER_ATTRIBUTE_QUEUED ; + info->attributes = PRINTER_ATTRIBUTE_SHARED | PRINTER_ATTRIBUTE_NETWORK; return True; } @@ -4350,6 +4378,7 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) int numlines; int ret; int fd; + fstring remote_machine = "%m"; /* build driver path... only 9X architecture is needed for legacy reasons */ slprintf(driverlocation, sizeof(driverlocation)-1, "\\\\%s\\print$\\WIN40\\0", @@ -4357,11 +4386,12 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) /* change \ to \\ for the shell */ all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring)); - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", cmd, printer->info_2->printername, printer->info_2->sharename, printer->info_2->portname, printer->info_2->drivername, - printer->info_2->location, driverlocation); + printer->info_2->location, driverlocation, remote_machine); + /* Convert script args to unix-codepage */ DEBUG(10,("Running [%s]\n", command)); ret = smbrun(command, &fd); DEBUGADD(10,("returned [%d]\n", ret)); @@ -4633,8 +4663,8 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, } /******************************************************************** - * called by spoolss_api_setprinter - * when updating a printer description + * Called by spoolss_api_setprinter + * when updating a printer description. ********************************************************************/ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, @@ -4651,7 +4681,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, result = WERR_OK; if (level!=2) { - DEBUG(0,("Send a mail to samba@samba.org\n")); + DEBUG(0,("update_printer: Send a mail to samba@samba.org\n")); DEBUGADD(0,("with the following message: update_printer: level!=2\n")); result = WERR_UNKNOWN_LEVEL; goto done; @@ -4690,7 +4720,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, /* we have a valid devmode convert it and link it*/ - DEBUGADD(8,("Converting the devicemode struct\n")); + DEBUGADD(8,("update_printer: Converting the devicemode struct\n")); if (!convert_devicemode(printer->info_2->printername, devmode, &printer->info_2->devmode)) { result = WERR_NOMEM; @@ -4710,7 +4740,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, annoying permission denied dialog box. */ if (nt_printer_info_level_equal(printer, old_printer)) { - DEBUG(3, ("printer info has not changed\n")); + DEBUG(3, ("update_printer: printer info has not changed\n")); result = WERR_OK; goto done; } @@ -4718,8 +4748,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, /* Check calling user has permission to update printer description */ if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { - DEBUG(3, ("printer property change denied by security " - "descriptor\n")); + DEBUG(3, ("update_printer: printer property change denied by security descriptor\n")); result = WERR_ACCESS_DENIED; goto done; } @@ -4727,12 +4756,38 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, /* Call addprinter hook */ if (*lp_addprinter_cmd()) { - if (!add_printer_hook(printer)) { + if ( !add_printer_hook(printer) ) { result = WERR_ACCESS_DENIED; goto done; } } + /* + * Set the DRIVER_INIT info in the tdb; trigger on magic value for the + * DEVMODE.displayfrequency, which is not used for printer drivers. This + * requires Win32 client code (see other notes elsewhere in the code). + */ + if (printer->info_2->devmode && + printer->info_2->devmode->displayfrequency == MAGIC_DISPLAY_FREQUENCY) { + + DEBUG(10,("update_printer: Save printer driver init data\n")); + printer->info_2->devmode->displayfrequency = 0; + + if (update_driver_init(*printer, 2)!=0) { + DEBUG(10,("update_printer: error updating printer driver init DEVMODE\n")); + result = WERR_ACCESS_DENIED; + goto done; + } + } else { + /* + * When a *new* driver is bound to a printer, the drivername is used to + * lookup previously saved driver initialization info, which is then + * bound to the printer, simulating what happens in the Windows arch. + */ + if (strequal(printer->info_2->drivername, old_printer->info_2->drivername)) + set_driver_init(printer, 2); + } + /* Update printer info */ result = mod_a_printer(*printer, 2); @@ -4740,7 +4795,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, free_a_printer(&printer, 2); free_a_printer(&old_printer, 2); - srv_spoolss_sendnotify(p, handle); + srv_spoolss_sendnotify(0, PRINTER_CHANGE_SET_PRINTER); return result; } @@ -4760,7 +4815,7 @@ WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET Printer_entry *Printer = find_printer_index_by_hnd(p, handle); if (!Printer) { - DEBUG(0,("_spoolss_setprinter: Invalid handle (%s)\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_setprinter: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle))); return WERR_BADFID; } @@ -4788,7 +4843,7 @@ WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) Printer_entry *Printer= find_printer_index_by_hnd(p, handle); if (!Printer) { - DEBUG(0,("_spoolss_fcpn: Invalid handle (%s)\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_fcpn: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle))); return WERR_BADFID; } @@ -5902,11 +5957,24 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ return WERR_INVALID_PARAM; } - /* + /* * 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. */ + + if (!devmode) + set_driver_init(printer, 2); + else { + /* A valid devmode was included, convert and link it + */ + DEBUGADD(10, ("spoolss_addprinterex_level_2: devmode included, converting\n")); + + if (!convert_devicemode(printer->info_2->printername, devmode, + &printer->info_2->devmode)) + return WERR_NOMEM; + } + set_driver_init(printer, 2); /* write the ASCII on disk */ @@ -5925,7 +5993,9 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ free_a_printer(&printer,2); - srv_spoolss_sendnotify(p, handle); + update_c_setprinter(False); + + srv_spoolss_sendnotify(0, PRINTER_CHANGE_ADD_PRINTER); return WERR_OK; } @@ -6016,7 +6086,9 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen pstring long_archi; pstring short_archi; DRIVER_DIRECTORY_1 *info=NULL; - +#if 0 + fstring asc_name, servername; +#endif unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); if (get_short_archi(short_archi, long_archi)==False) @@ -6025,6 +6097,20 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen if((info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1))) == NULL) return WERR_NOMEM; +#if 0 /* JERRY */ + /* use the name the client sent us */ + + unistr2_to_ascii(asc_name, name, sizeof(asc_name)-1); + if (asc_name[0] == '\\' && asc_name[1] == '\\') + fstrcpy(servername, asc_name); + else { + fstrcpy(servername, "\\\\"); + fstrcat(servername, asc_name); + } + + slprintf(path, sizeof(path)-1, "%s\\print$\\%s", servername, short_archi); +#endif + slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", get_called_name(), short_archi); DEBUG(4,("printer driver directory: [%s]\n", path)); @@ -6118,7 +6204,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S DEBUG(5,("spoolss_enumprinterdata\n")); if (!Printer) { - DEBUG(0,("_spoolss_enumprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_enumprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } @@ -6194,20 +6280,17 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S problems unmarshalling the response */ *out_max_value_len=(in_value_len/sizeof(uint16)); - if((*out_value=(uint16 *)malloc(in_value_len*sizeof(uint8))) == NULL) + if((*out_value=(uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL) return WERR_NOMEM; - ZERO_STRUCTP(*out_value); *out_value_len = rpcstr_push((char *)*out_value, "", in_value_len, 0); /* the data is counted in bytes */ *out_max_data_len = in_data_len; *out_data_len = in_data_len; - if((*data_out=(uint8 *)malloc(in_data_len*sizeof(uint8))) == NULL) + if((*data_out=(uint8 *)talloc_zero(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) return WERR_NOMEM; - memset(*data_out,'\0',in_data_len); - return WERR_NO_MORE_ITEMS; } @@ -6269,7 +6352,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP DEBUG(5,("spoolss_setprinterdata\n")); if (!Printer) { - DEBUG(0,("_spoolss_setprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_setprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } @@ -6305,6 +6388,8 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP convert_specific_param(¶m, value , type, data, real_len); #if 0 + /* JRA. W2K always changes changeid. */ + if (get_specific_param(*printer, 2, param->value, &old_param.data, &old_param.type, (uint32 *)&old_param.data_len)) { @@ -6344,6 +6429,11 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP free_nt_printer_param(¶m); SAFE_FREE(old_param.data); +#if 0 + /* Is this correct. JRA ? */ + srv_spoolss_sendnotify(0, PRINTER_CHANGE_SET_PRINTER); +#endif + return status; } @@ -6364,7 +6454,7 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ DEBUG(5,("spoolss_deleteprinterdata\n")); if (!Printer) { - DEBUG(0,("_spoolss_deleteprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_deleteprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } @@ -6402,40 +6492,60 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM /* uint32 level = q_u->level; - notused. */ FORM *form = &q_u->form; nt_forms_struct tmpForm; - int count=0, snum; + int snum; + WERROR status = WERR_OK; + NT_PRINTER_INFO_LEVEL *printer = NULL; + + int count=0; nt_forms_struct *list=NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); DEBUG(5,("spoolss_addform\n")); if (!Printer) { - DEBUG(0,("_spoolss_addform: Invalid handle (%s).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_addform: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } - /* Must be administrator to add a form */ - - if (!get_printer_snum(p, handle, &snum)) - return WERR_BADFID; + /* + * FIXME!! Feels like there should be an access check here, but haven't + * had time to verify. --jerry + */ - if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { - DEBUG(0, ("_spoolss_addform: Access denied\n")); - return WERR_ACCESS_DENIED; - } + if (!get_printer_snum(p,handle, &snum)) + return WERR_BADFID; + /* can't add if builtin */ if (get_a_builtin_ntform(&form->name,&tmpForm)) { - return WERR_FILE_EXISTS; + return WERR_ALREADY_EXISTS; } count=get_ntforms(&list); if(!add_a_form(&list, form, &count)) return WERR_NOMEM; write_ntforms(&list, count); + + /* + * ChangeID must always be set + */ + + if (!get_printer_snum(p,handle, &snum)) + return WERR_BADFID; + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + goto done; + + status = mod_a_printer(*printer, 2); + if (!W_ERROR_IS_OK(status)) + goto done; + +done: + free_a_printer(&printer, 2); SAFE_FREE(list); - return WERR_OK; + return status; } /**************************************************************************** @@ -6446,25 +6556,27 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE POLICY_HND *handle = &q_u->handle; UNISTR2 *form_name = &q_u->name; nt_forms_struct tmpForm; - int count=0, snum; + int count=0; WERROR ret = WERR_OK; nt_forms_struct *list=NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + int snum; + WERROR status = WERR_OK; + NT_PRINTER_INFO_LEVEL *printer = NULL; DEBUG(5,("spoolss_deleteform\n")); if (!Printer) { - DEBUG(0,("_spoolss_deleteform: Invalid handle (%s).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_deleteform: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } - /* Must be administrator to set a form */ - - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { - DEBUG(0, ("_spoolss_addform: Access denied\n")); + DEBUG(3, ("security descriptor change denied by existing " + "security descriptor\n")); return WERR_ACCESS_DENIED; } @@ -6477,6 +6589,23 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE if(!delete_a_form(&list, form_name, &count, &ret)) return WERR_INVALID_PARAM; + /* + * ChangeID must always be set + */ + + if (!get_printer_snum(p,handle, &snum)) + return WERR_BADFID; + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + goto done; + + status = mod_a_printer(*printer, 2); + if (!W_ERROR_IS_OK(status)) + goto done; + +done: + free_a_printer(&printer, 2); SAFE_FREE(list); return ret; @@ -6492,24 +6621,27 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * /* uint32 level = q_u->level; - notused. */ FORM *form = &q_u->form; nt_forms_struct tmpForm; - int count=0, snum; + int snum; + WERROR status = WERR_OK; + NT_PRINTER_INFO_LEVEL *printer = NULL; + + int count=0; nt_forms_struct *list=NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); DEBUG(5,("spoolss_setform\n")); if (!Printer) { - DEBUG(0,("_spoolss_setform: Invalid handle (%s).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_setform: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } - /* Must be administrator to set a form */ - if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { - DEBUG(0, ("_spoolss_addform: Access denied\n")); + DEBUG(3, ("security descriptor change denied by existing " + "security descriptor\n")); return WERR_ACCESS_DENIED; } @@ -6522,6 +6654,23 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * update_a_form(&list, form, count); write_ntforms(&list, count); + /* + * ChangeID must always be set + */ + + if (!get_printer_snum(p,handle, &snum)) + return WERR_BADFID; + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + goto done; + + status = mod_a_printer(*printer, 2); + if (!W_ERROR_IS_OK(status)) + goto done; + +done: + free_a_printer(&printer, 2); SAFE_FREE(list); return WERR_OK; @@ -6943,7 +7092,7 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, if (!Printer) { if((*data=(uint8 *)talloc_zero(p->mem_ctx, 4*sizeof(uint8))) == NULL) return WERR_NOMEM; - DEBUG(0,("_spoolss_getprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_getprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } @@ -7122,7 +7271,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ DEBUG(4,("_spoolss_enumprinterdataex\n")); if (!Printer) { - DEBUG(0,("_spoolss_enumprinterdata: Invalid handle (%s).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_enumprinterdata: Invalid handle (%s:%u:%u1<).\n", OUR_HANDLE(handle))); return WERR_BADFID; } @@ -7259,7 +7408,7 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, unistr2_to_ascii(long_archi, environment, sizeof(long_archi)-1); - if (get_short_archi(short_archi, long_archi)==False) + if (get_short_archi(short_archi, long_archi)==FALSE) return WERR_INVALID_ENVIRONMENT; if((info=(PRINTPROCESSOR_DIRECTORY_1 *)malloc(sizeof(PRINTPROCESSOR_DIRECTORY_1))) == NULL) -- cgit From 51e205c92acce4d9374cc6b9e5ae234219037626 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 12 Feb 2002 19:16:14 +0000 Subject: merge from 2.2 (This used to be commit 09fc979172327d6396642e824f6d482c6f986850) --- source3/rpc_server/srv_spoolss_nt.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f76b78f116..1be11f6a18 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4422,6 +4422,8 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) return True; } +#if 0 /* JERRY */ + /* Return true if two devicemodes are equal */ #define DEVMODE_CHECK_INT(field) \ @@ -4431,6 +4433,10 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) return False; \ } +/************************************************************************ + Handy, but currently unused functions + ***********************************************************************/ + static BOOL nt_devicemode_equal(NT_DEVICEMODE *d1, NT_DEVICEMODE *d2) { if (!d1 && !d2) goto equal; /* if both are NULL they are equal */ @@ -4662,6 +4668,8 @@ static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, return True; } +#endif + /******************************************************************** * Called by spoolss_api_setprinter * when updating a printer description. @@ -4735,9 +4743,13 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, goto done; } - /* NT likes to call this function even though nothing has actually - changed. Check this so the user doesn't end up with an - annoying permission denied dialog box. */ +#if 0 /* JERRY */ + + /* + * Another one of those historical misunderstandings... + * This is reminisent of a similar call we had in _spoolss_setprinterdata() + * I'm leaving it here as a reminder. --jerry + */ if (nt_printer_info_level_equal(printer, old_printer)) { DEBUG(3, ("update_printer: printer info has not changed\n")); @@ -4745,6 +4757,8 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, goto done; } +#endif + /* Check calling user has permission to update printer description */ if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { @@ -4784,7 +4798,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, * lookup previously saved driver initialization info, which is then * bound to the printer, simulating what happens in the Windows arch. */ - if (strequal(printer->info_2->drivername, old_printer->info_2->drivername)) + if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)) set_driver_init(printer, 2); } -- cgit From 1f6df6c9ce93cca5ee0d0ad13fb8f2ee4b782c63 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 12 Feb 2002 22:31:18 +0000 Subject: merge from 2.2 (This used to be commit e18a7c26476e05f95850ac2bbeb42c2588115741) --- source3/rpc_server/srv_spoolss_nt.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1be11f6a18..088945fb79 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6521,14 +6521,15 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM return WERR_BADFID; } - /* - * FIXME!! Feels like there should be an access check here, but haven't - * had time to verify. --jerry - */ - - if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; + + if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { + DEBUG(3, ("security descriptor change denied by existing " + "security descriptor\n")); + status = WERR_ACCESS_DENIED; + goto done; + } /* can't add if builtin */ if (get_a_builtin_ntform(&form->name,&tmpForm)) { @@ -6544,9 +6545,6 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM * ChangeID must always be set */ - if (!get_printer_snum(p,handle, &snum)) - return WERR_BADFID; - status = get_a_printer(&printer, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(status)) goto done; @@ -6607,9 +6605,6 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE * ChangeID must always be set */ - if (!get_printer_snum(p,handle, &snum)) - return WERR_BADFID; - status = get_a_printer(&printer, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(status)) goto done; @@ -6672,9 +6667,6 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * * ChangeID must always be set */ - if (!get_printer_snum(p,handle, &snum)) - return WERR_BADFID; - status = get_a_printer(&printer, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(status)) goto done; -- cgit From 83bc6cdd55b6be4001bff2ac758c7a3396740687 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 15 Feb 2002 18:59:34 +0000 Subject: merge from APPLIANCE_HEAD (This used to be commit 696d439515016e4c2bc5ad085e443abe43c95136) --- source3/rpc_server/srv_spoolss_nt.c | 93 +++++++------------------------------ 1 file changed, 18 insertions(+), 75 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 088945fb79..754390b7b6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -401,10 +401,10 @@ static BOOL set_printer_hnd_printertype(Printer_entry *Printer, char *handlename static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) { - NT_PRINTER_INFO_LEVEL *printer = NULL; int snum; int n_services=lp_numservices(); char *aprinter; + fstring sname; BOOL found=False; DEBUG(4,("Setting printer name=%s (len=%d)\n", handlename, strlen(handlename))); @@ -429,97 +429,40 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) DEBUGADD(5,("searching for [%s] (len=%d)\n", aprinter, strlen(aprinter))); /* - * store the Samba share name in it - * in back we have the long printer name - * need to iterate all the snum and do a - * get_a_printer each time to find the printer - * faster to do it here than later. + * The original code allowed smbd to store a printer name that + * was different from the share name. This is not possible + * anymore, so I've simplified this loop greatly. Here + * we are just verifying that the printer name is a valid + * printer service defined in smb.conf + * --jerry [Fri Feb 15 11:17:46 CST 2002] */ - for (snum=0;snuminfo_2->printername+2, '\\'); - printername++; - - DEBUG(10,("set_printer_hnd_name: name [%s], aprinter [%s]\n", - printer->info_2->printername, aprinter )); + fstrcpy(sname, lp_servicename(snum)); - if ( strlen(printername) != strlen(aprinter) ) { - free_a_printer(&printer, 2); - continue; - } + DEBUGADD(5,("share:%s\n",sname)); - if ( strncasecmp(printername, aprinter, strlen(aprinter))) { - free_a_printer(&printer, 2); - continue; + if (! StrCaseCmp(sname, aprinter)) { + found = True; + break; } - - found=True; - } - - /* - * if we haven't found a printer with the given handlename - * then it can be a share name as you can open both \\server\printer and - * \\server\share - */ - - /* - * we still check if the printer description file exists as NT won't be happy - * if we reply OK in the openprinter call and can't reply in the subsequent RPC calls - */ - - if (found==False) { - DEBUGADD(5,("Printer not found, checking for share now\n")); - - for (snum=0;snuminfo_2->printername, aprinter )); - - if ( strlen(lp_servicename(snum)) != strlen(aprinter) ) { - free_a_printer(&printer, 2); - continue; - } - - if ( strncasecmp(lp_servicename(snum), aprinter, strlen(aprinter))) { - free_a_printer(&printer, 2); - continue; - } - - found=True; - } } + - if (found==False) { + if (!found) { DEBUGADD(4,("Printer not found\n")); return False; } - snum--; - DEBUGADD(4,("set_printer_hnd_name: Printer found: %s -> %s[%x]\n", - printer->info_2->printername, lp_servicename(snum),snum)); + DEBUGADD(4,("set_printer_hnd_name: Printer found: %s -> %s\n", aprinter, sname)); ZERO_STRUCT(Printer->dev.handlename); - strncpy(Printer->dev.handlename, lp_servicename(snum), strlen(lp_servicename(snum))); - - free_a_printer(&printer, 2); + fstrcpy(Printer->dev.handlename, sname); return True; } -- cgit From cef4f9215f752243d1c429e3b056344af3fe50f8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 20 Feb 2002 23:36:23 +0000 Subject: merge from 2.2 (This used to be commit 25fb4a8d110bcdcbe7822a833cab9cfdec8a1fb2) --- source3/rpc_server/srv_spoolss_nt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 754390b7b6..86efc2fb94 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1105,7 +1105,7 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return False; - SIVAL(*data, 0, 0x01); + SIVAL(*data, 0, 0x00); *needed = 0x4; return True; } @@ -1114,7 +1114,8 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return False; - SIVAL(*data, 0, 0x1B); + /* formally was 0x1b */ + SIVAL(*data, 0, 0x0); *needed = 0x4; return True; } @@ -1123,7 +1124,7 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return False; - SIVAL(*data, 0, 0x01); + SIVAL(*data, 0, 0x00); *needed = 0x4; return True; } @@ -1137,8 +1138,10 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 return True; } - if (!strcmp(value, "DefaultSpoolDirectory")) { - pstring string="You are using a Samba server"; + if (!strcmp(value, "DefaultSpoolDirectory")) { + fstring string; + + fstrcpy(string, string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); *type = 0x1; *needed = 2*(strlen(string)+1); if((*data = (uint8 *)talloc(ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) -- cgit From 84b18178a99b4eeb081f09ce4bd09428ad57b5a2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 21 Feb 2002 00:55:01 +0000 Subject: merge from 2.2 (This used to be commit 63ab947fd9dd17a4c370402e74b389458bbd3a60) --- source3/rpc_server/srv_spoolss_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 86efc2fb94..b2de688b74 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7280,6 +7280,10 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ enum_values[num_entries].value_len = (strlen(value)+1) * 2; enum_values[num_entries].type = type; +#if 0 /* JERRY - I think think was a bad assumption based on bad + offset values when I first implemented it. Commented out. + We should not be adding an extra NULL to the end of a string + just send what the client set in the first place. */ /* * NULL terminate REG_SZ * FIXME!!! We should not be correctly problems in the way @@ -7295,6 +7299,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ else add_len = data_len % 2; } +#endif if (!(enum_values[num_entries].data=talloc_zero(p->mem_ctx, data_len+add_len))) { DEBUG(0,("talloc_realloc failed to allocate more memory for data!\n")); -- cgit From 5dbe33e3ee3615260036b2dc89bfd164b62a6296 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 21 Feb 2002 17:30:58 +0000 Subject: merge from 2.2 (This used to be commit 505119f0a7c6f10fd7e580edfe1bd0fb6ec36428) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b2de688b74..cdddb8b564 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7113,7 +7113,7 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); - if (strcmp(key, "PrinterDriverData") == 0) + if (strcmp(key, "PrinterDriverData") != 0) return WERR_INVALID_PARAM; ZERO_STRUCT(q_u_local); -- cgit From 2f8452fd49dd34da5cd07629dcba937861dd0731 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 25 Feb 2002 23:18:05 +0000 Subject: Merge of printing performance fixes from appliance. (This used to be commit c8dc59dfe877f63bea6976b7d7fd448e0c8722ba) --- source3/rpc_server/srv_spoolss_nt.c | 101 ++++++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cdddb8b564..6f46b4bc42 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4868,7 +4868,8 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, ****************************************************************************/ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, int position, int snum, - NT_PRINTER_INFO_LEVEL *ntprinter) + NT_PRINTER_INFO_LEVEL *ntprinter, + DEVICEMODE *devmode) { pstring temp_name; pstring chaine; @@ -4906,9 +4907,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, job_info->timeelapsed=0; job_info->pagesprinted=0; - if((job_info->devmode = construct_dev_mode(snum)) == NULL) { - return False; - } + job_info->devmode = devmode; return (True); } @@ -4967,24 +4966,33 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, uint32 *needed, uint32 *returned) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; - JOB_INFO_2 *info; + JOB_INFO_2 *info = NULL; int i; WERROR result; + DEVICEMODE *devmode = NULL; info=(JOB_INFO_2 *)malloc(*returned*sizeof(JOB_INFO_2)); if (info==NULL) { *returned=0; - return WERR_NOMEM; + result = WERR_NOMEM; + goto done; } result = get_a_printer(&ntprinter, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(result)) { *returned = 0; - return result; + goto done; } - + + if (!(devmode = construct_dev_mode(snum))) { + *returned = 0; + result = WERR_NOMEM; + goto done; + } + for (i=0; i<*returned; i++) - fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter); + fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter, + devmode); free_a_printer(&ntprinter, 2); SAFE_FREE(queue); @@ -4993,27 +5001,30 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, for (i=0; i<*returned; i++) (*needed) += spoolss_size_job_info_2(&info[i]); + if (*needed > offered) { + *returned=0; + result = WERR_INSUFFICIENT_BUFFER; + goto done; + } + if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(info); - return WERR_INSUFFICIENT_BUFFER; + result = WERR_INSUFFICIENT_BUFFER; + goto done; } /* fill the buffer with the structures */ for (i=0; i<*returned; i++) smb_io_job_info_2("", buffer, &info[i], 0); - /* clear memory */ - for (i = 0; i < *returned; i++) - free_job_info_2(&info[i]); + result = WERR_OK; + done: + free_a_printer(&ntprinter, 2); + free_devmode(devmode); + SAFE_FREE(queue); SAFE_FREE(info); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } - - return WERR_OK; + return result; } /**************************************************************************** @@ -6918,14 +6929,15 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin JOB_INFO_2 *info_2; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; WERROR ret; + DEVICEMODE *devmode = NULL; info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2)); ZERO_STRUCTP(info_2); if (info_2 == NULL) { - SAFE_FREE(queue); - return WERR_NOMEM; + ret = WERR_NOMEM; + goto done; } for (i=0; i offered) { + ret = WERR_INSUFFICIENT_BUFFER; + goto done; + } - if (*needed > offered) - return WERR_INSUFFICIENT_BUFFER; + ret = WERR_OK; + + done: + /* Cleanup allocated memory */ - return WERR_OK; + SAFE_FREE(queue); + free_job_info_2(info_2); /* Also frees devmode */ + SAFE_FREE(info_2); + free_a_printer(&ntprinter, 2); + + return ret; } /**************************************************************************** -- cgit From 2ff93902451a234e78490a1b18c2fae43d997b01 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 26 Feb 2002 03:12:09 +0000 Subject: Fixup the sending of printer change messages from job changes. Jeremy. (This used to be commit 28d4e7a3e2bd8f15ef807b821e4300a72bbc6904) --- source3/rpc_server/srv_spoolss_nt.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 6f46b4bc42..c7b4df9d82 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -566,33 +566,39 @@ static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size { Printer_entry *find_printer; WERROR status; + fstring printer_name; char msg[8]; + char *buf_ptr = (char *)buf; uint32 low, high; - if (len != sizeof(msg)) { + if (len < sizeof(msg) + 2) { DEBUG(2,("srv_spoolss_receive_message: got incorrect message size (%u)!\n", (unsigned int)len)); return; } - memcpy(msg, buf, len); + memcpy(msg, buf_ptr, sizeof(msg)); low = IVAL(msg,0); high = IVAL(msg,4); + fstrcpy(printer_name, buf_ptr + sizeof(msg)); - DEBUG(10,("srv_spoolss_receive_message: Got message printer change low=0x%x high=0x%x\n", (unsigned int)low, - (unsigned int)high )); - - find_printer = printers_list; + DEBUG(10,("srv_spoolss_receive_message: Got message printer change name [%s] low=0x%x high=0x%x\n", + printer_name, (unsigned int)low, (unsigned int)high )); /* Iterate the printer list */ - for(; find_printer; find_printer = find_printer->next) { + for(find_printer = printers_list; find_printer; find_printer = find_printer->next) { /* * If the entry has a connected client we send the message. */ - if (find_printer->notify.client_connected==True) { DEBUG(10,("srv_spoolss_receive_message: printerserver [%s]\n", find_printer->dev.printerservername )); + if (*printer_name && !strequal(printer_name, find_printer->dev.handlename)) { + DEBUG(10,("srv_spoolss_receive_message: ignoring message sent to %s [%s]\n", + printer_name, find_printer->dev.handlename )); + continue; + } + if (cli_spoolss_reply_rrpcn(&cli, &find_printer->notify.client_hnd, low, high, &status)) DEBUG(10,("srv_spoolss_receive_message: cli_spoolss_reply_rrpcn status = 0x%x\n", (unsigned int)W_ERROR_V(status))); @@ -608,8 +614,9 @@ static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size static BOOL srv_spoolss_sendnotify(uint32 high, uint32 low) { - char msg[8]; + char msg[10]; + ZERO_STRUCT(msg); SIVAL(msg,0,low); SIVAL(msg,4,high); DEBUG(10,("srv_spoolss_sendnotify: printer change low=0x%x high=0x%x\n", low, high)); -- cgit From a07e040c8c8515d0ffc2a6cce31a4f0124e42023 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 1 Mar 2002 22:45:23 +0000 Subject: SECURITY FIXES: Remove a stray 'unbecome_root()' in the ntdomain an auth failure case. Only allow trust accounts to request a challange in srv_netlogon_nt.c. Currently any user can be the 'machine' for the domain logon. MERGE for 2.2. Andrew Bartlett (This used to be commit 0242d0e17827b05d8cd270f675d2595fa67fd5b9) --- source3/rpc_server/srv_netlog_nt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index d382f12fcf..07f414e8fc 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -169,6 +169,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) SAM_ACCOUNT *sampass = NULL; const uint8 *pass; BOOL ret; + uint32 acct_ctrl; #if 0 /* @@ -202,7 +203,12 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) return False; } - if (!(pdb_get_acct_ctrl(sampass) & ACB_DISABLED) && ((pass=pdb_get_nt_passwd(sampass)) != NULL)) { + acct_ctrl = pdb_get_acct_ctrl(sampass); + if (!(acct_ctrl & ACB_DISABLED) && + ((acct_ctrl & ACB_DOMTRUST) || + (acct_ctrl & ACB_WSTRUST) || + (acct_ctrl & ACB_SVRTRUST)) && + ((pass=pdb_get_nt_passwd(sampass)) != NULL)) { memcpy(md4pw, pass, 16); dump_data(5, md4pw, 16); pdb_free_sam(&sampass); -- cgit From 4941e64fe043d755ec0068b540a9ed7264a9a38d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 3 Mar 2002 03:56:53 +0000 Subject: This patch allows NT4 domains to trust Samba. Simply add an account (smbpasswd -a -i REMOTEDOM) and join with 'user manager' on the remote domain. The only issue (at the auth level at least) that prevented NT4 domains from trusting Samba was that our netlogon code was based on what appear to be invalid assumptions. The netlogon code appears to assume that the 'client name' specified corrosponds to an account of the same form. This doesn't apply in trusted domains, becouse the account is in the form domain$ Now that we use the supplied account name, and no longer make our access control checks at the challange stage (where this info is unavailable) we match the Win2k behaviour for invalid machine logins, and don't need to know the names of PDCs/BDCs in trusting domains. We also kill off the 'you logged on with a machine account, use your user account' error message, becouse the previous NT_STATUS return was compleatly bogus. (The ACCESS_DENIED we now return matches Win2k, and gives snane error messages on the client). TNG doesn't use this and has to do magic password syncs between the various accounts for domain/pdc/bdc. This patch feels like the much more natural way of doing things, and has been mildly tested. Andrew Bartlett (This used to be commit 542673fcd6654a1d0966dddadde177a4c4ce135d) --- source3/rpc_server/srv_netlog_nt.c | 165 ++++++++++++++++++------------------- 1 file changed, 81 insertions(+), 84 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 07f414e8fc..df636fd679 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -228,45 +228,25 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) NTSTATUS _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u) { NTSTATUS status = NT_STATUS_OK; - fstring mach_acct; - - if (!get_valid_user_struct(p->vuid)) - return NT_STATUS_NO_SUCH_USER; - - rpcstr_pull(mach_acct,q_u->uni_logon_clnt.buffer,sizeof(fstring),q_u->uni_logon_clnt.uni_str_len*2,0); - - strlower(mach_acct); - fstrcat(mach_acct, "$"); - - if (get_md4pw((char *)p->dc.md4pw, mach_acct)) { - /* copy the client credentials */ - memcpy(p->dc.clnt_chal.data , q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); - memcpy(p->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); - - /* create a server challenge for the client */ - /* Set these to random values. */ - generate_random_buffer(p->dc.srv_chal.data, 8, False); - - memcpy(p->dc.srv_cred.challenge.data, p->dc.srv_chal.data, 8); - memset((char *)p->dc.sess_key, '\0', sizeof(p->dc.sess_key)); + rpcstr_pull(p->dc.remote_machine,q_u->uni_logon_clnt.buffer,sizeof(fstring),q_u->uni_logon_clnt.uni_str_len*2,0); - /* from client / server challenges and md4 password, generate sess key */ - cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal, - (char *)p->dc.md4pw, p->dc.sess_key); + /* create a server challenge for the client */ + /* Set these to random values. */ + generate_random_buffer(p->dc.srv_chal.data, 8, False); + + memcpy(p->dc.srv_cred.challenge.data, p->dc.srv_chal.data, 8); - /* Save the machine account name. */ - fstrcpy(p->dc.mach_acct, mach_acct); + memcpy(p->dc.clnt_chal.data , q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + memcpy(p->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); - } else { - /* lkclXXXX take a guess at a good error message to return :-) */ - status = NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT; - } + memset((char *)p->dc.sess_key, '\0', sizeof(p->dc.sess_key)); + p->dc.challange_sent = True; /* set up the LSA REQUEST CHALLENGE response */ init_net_r_req_chal(r_u, &p->dc.srv_chal, status); - - return r_u->status; + + return status; } /************************************************************************* @@ -288,26 +268,37 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) NTSTATUS status = NT_STATUS_OK; DOM_CHAL srv_cred; UTIME srv_time; - - if (!get_valid_user_struct(p->vuid)) - return NT_STATUS_NO_SUCH_USER; + fstring mach_acct; srv_time.time = 0; - /* check that the client credentials are valid */ - if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) { + rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring),q_u->clnt_id.uni_acct_name.uni_str_len*2,0); + if (p->dc.challange_sent && get_md4pw((char *)p->dc.md4pw, mach_acct)) { + /* copy the client credentials */ + /* create server challenge for inclusion in the reply */ cred_create(p->dc.sess_key, &p->dc.srv_cred.challenge, srv_time, &srv_cred); - - /* copy the received client credentials for use next time */ - memcpy(p->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); - memcpy(p->dc.srv_cred .challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + + /* check that the client credentials are valid */ + if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) { + + /* copy the received client credentials for use next time */ + memcpy(p->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + memcpy(p->dc.srv_cred .challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + + /* Save the machine account name. */ + fstrcpy(p->dc.mach_acct, mach_acct); + + p->dc.authenticated = True; + } else { + status = NT_STATUS_ACCESS_DENIED; + } } else { status = NT_STATUS_ACCESS_DENIED; } - - /* set up the LSA AUTH 2 response */ + + /* set up the LSA AUTH response */ init_net_r_auth(r_u, &srv_cred, status); return r_u->status; @@ -335,25 +326,44 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) DOM_CHAL srv_cred; UTIME srv_time; NEG_FLAGS srv_flgs; - - if (!get_valid_user_struct(p->vuid)) - return NT_STATUS_NO_SUCH_USER; + fstring mach_acct; srv_time.time = 0; - /* check that the client credentials are valid */ - if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) { + rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring),q_u->clnt_id.uni_acct_name.uni_str_len*2,0); + if (p->dc.challange_sent && get_md4pw((char *)p->dc.md4pw, mach_acct)) { + /* copy the client credentials */ + + /* from client / server challenges and md4 password, generate sess key */ + cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal, + (char *)p->dc.md4pw, p->dc.sess_key); + /* create server challenge for inclusion in the reply */ cred_create(p->dc.sess_key, &p->dc.srv_cred.challenge, srv_time, &srv_cred); + + /* check that the client credentials are valid */ + if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) { + + /* create server challenge for inclusion in the reply */ + cred_create(p->dc.sess_key, &p->dc.srv_cred.challenge, srv_time, &srv_cred); + + /* copy the received client credentials for use next time */ + memcpy(p->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + memcpy(p->dc.srv_cred .challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + + /* Save the machine account name. */ + fstrcpy(p->dc.mach_acct, mach_acct); + + p->dc.authenticated = True; - /* copy the received client credentials for use next time */ - memcpy(p->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); - memcpy(p->dc.srv_cred .challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + } else { + status = NT_STATUS_ACCESS_DENIED; + } } else { status = NT_STATUS_ACCESS_DENIED; } - + srv_flgs.neg_flags = 0x000001ff; /* set up the LSA AUTH 2 response */ @@ -370,47 +380,40 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * { NTSTATUS status = NT_STATUS_WRONG_PASSWORD; DOM_CRED srv_cred; - pstring mach_acct; + pstring workstation; SAM_ACCOUNT *sampass=NULL; BOOL ret = False; unsigned char pwd[16]; int i; - - if (!get_valid_user_struct(p->vuid)) - return NT_STATUS_NO_SUCH_USER; + uint32 acct_ctrl; /* checks and updates credentials. creates reply credentials */ - if (!deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->clnt_id.cred, &srv_cred)) + if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->clnt_id.cred, &srv_cred))) return NT_STATUS_INVALID_HANDLE; memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); - rpcstr_pull(mach_acct,q_u->clnt_id.login.uni_acct_name.buffer, - sizeof(mach_acct),q_u->clnt_id.login.uni_acct_name.uni_str_len*2,0); + rpcstr_pull(workstation,q_u->clnt_id.login.uni_acct_name.buffer, + sizeof(workstation),q_u->clnt_id.login.uni_acct_name.uni_str_len*2,0); - DEBUG(3,("Server Password Set Wksta:[%s]\n", mach_acct)); + DEBUG(3,("Server Password Set by Wksta:[%s] on account [%s]\n", workstation, p->dc.mach_acct)); - /* - * 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)) { - return NT_STATUS_ACCESS_DENIED; - } - pdb_init_sam(&sampass); become_root(); - ret=pdb_getsampwnam(sampass, mach_acct); + ret=pdb_getsampwnam(sampass, p->dc.mach_acct); unbecome_root(); /* Ensure the account exists and is a machine account. */ + + acct_ctrl = pdb_get_acct_ctrl(sampass); - if (ret==False || !(pdb_get_acct_ctrl(sampass) & ACB_WSTRUST)) { + if (!(ret + && (acct_ctrl & ACB_WSTRUST || + acct_ctrl & ACB_SVRTRUST || + acct_ctrl & ACB_DOMTRUST))) { pdb_free_sam(&sampass); return NT_STATUS_NO_SUCH_USER; } @@ -438,16 +441,10 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * return NT_STATUS_NO_MEMORY; } - if (!pdb_set_acct_ctrl (sampass, ACB_WSTRUST)) { - pdb_free_sam(&sampass); - /* Not quite sure what this one qualifies as, but this will do */ - return NT_STATUS_NO_MEMORY; - } - if (!pdb_set_pass_changed_now (sampass)) { pdb_free_sam(&sampass); /* Not quite sure what this one qualifies as, but this will do */ - return NT_STATUS_NO_MEMORY; + return NT_STATUS_UNSUCCESSFUL; } become_root(); @@ -477,8 +474,8 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF return NT_STATUS_NO_SUCH_USER; /* checks and updates credentials. creates reply credentials */ - if (!deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, - &q_u->sam_id.client.cred, &srv_cred)) + if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, + &q_u->sam_id.client.cred, &srv_cred))) return NT_STATUS_INVALID_HANDLE; memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); @@ -522,10 +519,10 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return NT_STATUS_NO_SUCH_USER; /* checks and updates credentials. creates reply credentials */ - if (!deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred)) + if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred))) return NT_STATUS_INVALID_HANDLE; - else - memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); + + memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); r_u->buffer_creds = 1; /* yes, we have valid server credentials */ memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds)); -- cgit From 309818b2a19d4047abe86560897325f952dc4929 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 3 Mar 2002 04:25:29 +0000 Subject: Some more fixes to enusre we execute the same code pathes as before this change, just in different packets. (This used to be commit ffa6c61f0bb0c413d4bcc46da3bc879c40a40569) --- source3/rpc_server/srv_netlog_nt.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index df636fd679..72b8569b43 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -275,14 +275,17 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring),q_u->clnt_id.uni_acct_name.uni_str_len*2,0); if (p->dc.challange_sent && get_md4pw((char *)p->dc.md4pw, mach_acct)) { - /* copy the client credentials */ - - /* create server challenge for inclusion in the reply */ - cred_create(p->dc.sess_key, &p->dc.srv_cred.challenge, srv_time, &srv_cred); + + /* from client / server challenges and md4 password, generate sess key */ + cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal, + (char *)p->dc.md4pw, p->dc.sess_key); /* check that the client credentials are valid */ if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) { + /* create server challenge for inclusion in the reply */ + cred_create(p->dc.sess_key, &p->dc.srv_cred.challenge, srv_time, &srv_cred); + /* copy the received client credentials for use next time */ memcpy(p->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); memcpy(p->dc.srv_cred .challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); @@ -291,6 +294,7 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) fstrcpy(p->dc.mach_acct, mach_acct); p->dc.authenticated = True; + } else { status = NT_STATUS_ACCESS_DENIED; } @@ -333,15 +337,11 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring),q_u->clnt_id.uni_acct_name.uni_str_len*2,0); if (p->dc.challange_sent && get_md4pw((char *)p->dc.md4pw, mach_acct)) { - /* copy the client credentials */ /* from client / server challenges and md4 password, generate sess key */ cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal, (char *)p->dc.md4pw, p->dc.sess_key); - /* create server challenge for inclusion in the reply */ - cred_create(p->dc.sess_key, &p->dc.srv_cred.challenge, srv_time, &srv_cred); - /* check that the client credentials are valid */ if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) { -- cgit From 308b222ffd4705d8f4ff53fbb76fc7c1db29bd27 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 5 Mar 2002 00:53:46 +0000 Subject: Spelling fixes. (This used to be commit a7fa0733badad66ae610eac5e01569cf264976f3) --- source3/rpc_server/srv_netlog_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 72b8569b43..92ebfd97c5 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -242,7 +242,7 @@ NTSTATUS _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u memset((char *)p->dc.sess_key, '\0', sizeof(p->dc.sess_key)); - p->dc.challange_sent = True; + p->dc.challenge_sent = True; /* set up the LSA REQUEST CHALLENGE response */ init_net_r_req_chal(r_u, &p->dc.srv_chal, status); @@ -274,7 +274,7 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring),q_u->clnt_id.uni_acct_name.uni_str_len*2,0); - if (p->dc.challange_sent && get_md4pw((char *)p->dc.md4pw, mach_acct)) { + if (p->dc.challenge_sent && get_md4pw((char *)p->dc.md4pw, mach_acct)) { /* from client / server challenges and md4 password, generate sess key */ cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal, @@ -336,7 +336,7 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring),q_u->clnt_id.uni_acct_name.uni_str_len*2,0); - if (p->dc.challange_sent && get_md4pw((char *)p->dc.md4pw, mach_acct)) { + if (p->dc.challenge_sent && get_md4pw((char *)p->dc.md4pw, mach_acct)) { /* from client / server challenges and md4 password, generate sess key */ cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal, -- cgit From aa785249438587f32e129972c82096839f7ed798 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 5 Mar 2002 02:12:00 +0000 Subject: Fix the NTSTATUS -> WERROR for srvsvc pipe. Jeremy. (This used to be commit 2b85d3570c2b149049482c3878c50cf8f5bfca61) --- source3/rpc_server/srv_srvsvc_nt.c | 265 ++++++++++++++++++------------------- 1 file changed, 128 insertions(+), 137 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 148bcb4d1e..09f33b9a88 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1,9 +1,7 @@ /* - * Unix SMB/CIFS implementation. + * Unix SMB/Netbios implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. * Copyright (C) Jeremy Allison 2001. * * This program is free software; you can redistribute it and/or modify @@ -173,8 +171,8 @@ static SEC_DESC *get_share_security_default( TALLOC_CTX *ctx, int snum, size_t * se_map_generic(&def_access, &file_generic_mapping); - init_sec_access(&sa, GENERIC_ALL_ACCESS | def_access ); - init_sec_ace(&ace, &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, sa, 0); + init_sec_access(&sa, GENERIC_ALL_ACCESS | def_access ); + init_sec_ace(&ace, &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, sa, 0); if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 1, &ace)) != NULL) { psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, psize); @@ -204,13 +202,13 @@ static SEC_DESC *get_share_security( TALLOC_CTX *ctx, int snum, size_t *psize) slprintf(key, sizeof(key)-1, "SECDESC/%s", lp_servicename(snum)); - if (tdb_prs_fetch(share_tdb, key, &ps, ctx)!=0 || - !sec_io_desc("get_share_security", &psd, &ps, 1)) { + if (tdb_prs_fetch(share_tdb, key, &ps, ctx)!=0 || + !sec_io_desc("get_share_security", &psd, &ps, 1)) { - DEBUG(4,("get_share_security: using default secdesc for %s\n", lp_servicename(snum) )); + DEBUG(4,("get_share_security: using default secdesc for %s\n", lp_servicename(snum) )); - return get_share_security_default(ctx, snum, psize); - } + return get_share_security_default(ctx, snum, psize); + } if (psd) *psize = sec_desc_size(psd); @@ -236,27 +234,26 @@ 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("share_security", &psd, &ps, 1)) { - goto out; - } + if (!sec_io_desc("share_security", &psd, &ps, 1)) + goto out; slprintf(key, sizeof(key)-1, "SECDESC/%s", share_name); - if (tdb_prs_store(share_tdb, key, &ps)==0) { - ret = True; - DEBUG(5,("set_share_security: stored secdesc for %s\n", share_name )); - } else { - DEBUG(1,("set_share_security: Failed to store secdesc for %s\n", share_name )); - } - - /* Free malloc'ed memory */ + if (tdb_prs_store(share_tdb, key, &ps)==0) { + ret = True; + DEBUG(5,("set_share_security: stored secdesc for %s\n", share_name )); + } else { + DEBUG(1,("set_share_security: Failed to store secdesc for %s\n", share_name )); + } + + /* Free malloc'ed memory */ out: - prs_mem_free(&ps); - if (mem_ctx) - talloc_destroy(mem_ctx); - return ret; + prs_mem_free(&ps); + if (mem_ctx) + talloc_destroy(mem_ctx); + return ret; } /******************************************************************* @@ -523,9 +520,9 @@ static void init_srv_r_net_share_enum(pipes_struct *p, SRV_R_NET_SHARE_ENUM *r_n if (init_srv_share_info_ctr(p, &r_n->ctr, info_level, &resume_hnd, &r_n->total_entries, all)) { - r_n->status = NT_STATUS_OK; + r_n->status = WERR_OK; } else { - r_n->status = NT_STATUS_INVALID_INFO_CLASS; + r_n->status = WERR_UNKNOWN_LEVEL; } init_enum_hnd(&r_n->enum_hnd, resume_hnd); @@ -538,7 +535,7 @@ static void init_srv_r_net_share_enum(pipes_struct *p, SRV_R_NET_SHARE_ENUM *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) { - NTSTATUS status = NT_STATUS_OK; + WERROR status = WERR_OK; int snum; DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__)); @@ -563,14 +560,14 @@ static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_I break; default: DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level)); - status = NT_STATUS_INVALID_INFO_CLASS; + status = WERR_UNKNOWN_LEVEL; break; } } else { - status = NT_STATUS_BAD_NETWORK_NAME; + status = WERR_INVALID_NAME; } - r_n->info.ptr_share_ctr = NT_STATUS_IS_OK(status) ? 1 : 0; + r_n->info.ptr_share_ctr = W_ERROR_IS_OK(status) ? 1 : 0; r_n->status = status; } @@ -687,10 +684,10 @@ static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto makes a SRV_R_NET_SESS_ENUM structure. ********************************************************************/ -static NTSTATUS init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, +static WERROR init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { - NTSTATUS status = NT_STATUS_OK; + WERROR status = WERR_OK; DEBUG(5,("init_srv_sess_info_ctr: %d\n", __LINE__)); ctr->switch_value = switch_value; @@ -709,7 +706,7 @@ static NTSTATUS init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, (*resume_hnd) = 0; (*total_entries) = 0; ctr->ptr_sess_ctr = 0; - status = NT_STATUS_INVALID_INFO_CLASS; + status = WERR_UNKNOWN_LEVEL; break; } @@ -728,11 +725,11 @@ static void init_srv_r_net_sess_enum(SRV_R_NET_SESS_ENUM *r_n, r_n->sess_level = sess_level; if (sess_level == -1) - r_n->status = NT_STATUS_INVALID_INFO_CLASS; + r_n->status = WERR_UNKNOWN_LEVEL; else r_n->status = init_srv_sess_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); - if (NT_STATUS_IS_ERR(r_n->status)) + if (!W_ERROR_IS_OK(r_n->status)) resume_hnd = 0; init_enum_hnd(&r_n->enum_hnd, resume_hnd); @@ -843,10 +840,10 @@ static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto makes a SRV_R_NET_CONN_ENUM structure. ********************************************************************/ -static NTSTATUS init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, +static WERROR init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { - NTSTATUS status = NT_STATUS_OK; + WERROR status = WERR_OK; DEBUG(5,("init_srv_conn_info_ctr: %d\n", __LINE__)); ctr->switch_value = switch_value; @@ -865,7 +862,7 @@ static NTSTATUS init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, (*resume_hnd = 0); (*total_entries) = 0; ctr->ptr_conn_ctr = 0; - status = NT_STATUS_INVALID_INFO_CLASS; + status = WERR_UNKNOWN_LEVEL; break; } @@ -883,11 +880,11 @@ static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, r_n->conn_level = conn_level; if (conn_level == -1) - r_n->status = NT_STATUS_INVALID_INFO_CLASS; + r_n->status = WERR_UNKNOWN_LEVEL; else r_n->status = init_srv_conn_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); - if (NT_STATUS_IS_ERR(r_n->status)) + if (!W_ERROR_IS_OK(r_n->status)) resume_hnd = 0; init_enum_hnd(&r_n->enum_hnd, resume_hnd); @@ -943,10 +940,10 @@ static void init_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *fto makes a SRV_R_NET_FILE_ENUM structure. ********************************************************************/ -static NTSTATUS init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, +static WERROR init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { - NTSTATUS status = NT_STATUS_OK; + WERROR status = WERR_OK; DEBUG(5,("init_srv_file_info_ctr: %d\n", __LINE__)); ctr->switch_value = switch_value; @@ -961,7 +958,7 @@ static NTSTATUS init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, (*resume_hnd = 0); (*total_entries) = 0; ctr->ptr_file_ctr = 0; - status = NT_STATUS_INVALID_INFO_CLASS; + status = WERR_UNKNOWN_LEVEL; break; } @@ -979,11 +976,11 @@ static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n, r_n->file_level = file_level; if (file_level == 0) - r_n->status = NT_STATUS_INVALID_INFO_CLASS; + r_n->status = WERR_UNKNOWN_LEVEL; else r_n->status = init_srv_file_info_ctr(r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries)); - if (NT_STATUS_IS_ERR(r_n->status)) + if (!W_ERROR_IS_OK(r_n->status)) resume_hnd = 0; init_enum_hnd(&r_n->enum_hnd, resume_hnd); @@ -993,13 +990,13 @@ static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n, net server get info ********************************************************************/ -NTSTATUS _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R_NET_SRV_GET_INFO *r_u) +WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R_NET_SRV_GET_INFO *r_u) { - NTSTATUS status = NT_STATUS_OK; + WERROR status = WERR_OK; SRV_INFO_CTR *ctr = (SRV_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_INFO_CTR)); if (!ctr) - return NT_STATUS_NO_MEMORY; + return WERR_NOMEM; ZERO_STRUCTP(ctr); @@ -1031,7 +1028,7 @@ NTSTATUS _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV init_srv_info_100(&ctr->srv.sv100, 500, global_myname); break; default: - status = NT_STATUS_INVALID_INFO_CLASS; + status = WERR_UNKNOWN_LEVEL; break; } @@ -1047,12 +1044,9 @@ NTSTATUS _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV net server set info ********************************************************************/ -NTSTATUS _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R_NET_SRV_SET_INFO *r_u) +WERROR _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R_NET_SRV_SET_INFO *r_u) { - /* NT gives "Windows NT error 0xc00000022" if we return - NT_STATUS_ACCESS_DENIED here so just pretend everything is OK. */ - - NTSTATUS status = NT_STATUS_OK; + WERROR status = WERR_OK; DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__)); @@ -1069,11 +1063,11 @@ NTSTATUS _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV net file enum ********************************************************************/ -NTSTATUS _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) +WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) { r_u->ctr = (SRV_FILE_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_FILE_INFO_CTR)); if (!r_u->ctr) - return NT_STATUS_NO_MEMORY; + return WERR_NOMEM; ZERO_STRUCTP(r_u->ctr); @@ -1094,13 +1088,13 @@ NTSTATUS _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET net conn enum ********************************************************************/ -NTSTATUS _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_CONN_ENUM *r_u) +WERROR _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_CONN_ENUM *r_u) { DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); r_u->ctr = (SRV_CONN_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_CONN_INFO_CTR)); if (!r_u->ctr) - return NT_STATUS_NO_MEMORY; + return WERR_NOMEM; ZERO_STRUCTP(r_u->ctr); @@ -1119,13 +1113,13 @@ NTSTATUS _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET net sess enum ********************************************************************/ -NTSTATUS _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_SESS_ENUM *r_u) +WERROR _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_SESS_ENUM *r_u) { DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__)); r_u->ctr = (SRV_SESS_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_SESS_INFO_CTR)); if (!r_u->ctr) - return NT_STATUS_NO_MEMORY; + return WERR_NOMEM; ZERO_STRUCTP(r_u->ctr); @@ -1144,7 +1138,7 @@ NTSTATUS _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET Net share enum all. ********************************************************************/ -NTSTATUS _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) +WERROR _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) { DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); @@ -1162,7 +1156,7 @@ NTSTATUS _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV Net share enum. ********************************************************************/ -NTSTATUS _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) +WERROR _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) { DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); @@ -1180,7 +1174,7 @@ NTSTATUS _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_N Net share get info. ********************************************************************/ -NTSTATUS _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, SRV_R_NET_SHARE_GET_INFO *r_u) +WERROR _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, SRV_R_NET_SHARE_GET_INFO *r_u) { fstring share_name; @@ -1240,7 +1234,7 @@ static char *valid_share_pathname(char *dos_pathname) Net share set info. Modify share details. ********************************************************************/ -NTSTATUS _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) +WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) { struct current_user user; pstring command; @@ -1260,27 +1254,27 @@ NTSTATUS _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, r_u->switch_value = 0; if (strequal(share_name,"IPC$") || strequal(share_name,"ADMIN$") || strequal(share_name,"global")) - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; snum = find_service(share_name); /* Does this share exist ? */ if (snum < 0) - return NT_STATUS_BAD_NETWORK_NAME; + return WERR_INVALID_NAME; /* No change to printer shares. */ if (lp_print_ok(snum)) - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; get_current_user(&user,p); if (user.uid != 0) - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; switch (q_u->info_level) { case 1: /* Not enough info in a level 1 to do anything. */ - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; 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)); @@ -1295,7 +1289,7 @@ NTSTATUS _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, map_generic_share_sd_bits(psd); break; case 1005: - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; case 1501: fstrcpy(pathname, lp_pathname(snum)); fstrcpy(comment, lp_comment(snum)); @@ -1305,16 +1299,16 @@ NTSTATUS _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, break; default: DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", q_u->info_level)); - return NT_STATUS_INVALID_INFO_CLASS; + return WERR_UNKNOWN_LEVEL; } /* We can only modify disk shares. */ if (type != STYPE_DISKTREE) - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; /* Check if the pathname is valid. */ if (!(ptr = valid_share_pathname( pathname ))) - return NT_STATUS_OBJECT_PATH_INVALID; + return WERR_OBJECT_PATH_INVALID; /* Ensure share name, pathname and comment don't contain '"' characters. */ string_replace(share_name, '"', ' '); @@ -1328,7 +1322,7 @@ NTSTATUS _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, if (strcmp(ptr, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) ) { if (!lp_change_share_cmd() || !*lp_change_share_cmd()) - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", lp_change_share_cmd(), dyn_CONFIGFILE, share_name, ptr, comment); @@ -1336,12 +1330,11 @@ NTSTATUS _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, 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 NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, - 0, False, NULL); + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); } else { DEBUG(10,("_srv_net_share_set_info: No change to share name (%s)\n", share_name )); @@ -1363,14 +1356,14 @@ NTSTATUS _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************* Net share add. Call 'add_share_command "sharename" "pathname" "comment" "read only = xxx"' ********************************************************************/ -NTSTATUS _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) +WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) { struct current_user user; pstring command; @@ -1391,18 +1384,18 @@ NTSTATUS _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET if (user.uid != 0) { DEBUG(10,("_srv_net_share_add: uid != 0. Access denied.\n")); - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } if (!lp_add_share_cmd() || !*lp_add_share_cmd()) { DEBUG(10,("_srv_net_share_add: No add share command\n")); - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } switch (q_u->info_level) { case 1: /* Not enough info in a level 1 to do anything. */ - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; 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)); @@ -1419,28 +1412,28 @@ NTSTATUS _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET break; case 1005: /* DFS only level. */ - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; default: DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", q_u->info_level)); - return NT_STATUS_INVALID_INFO_CLASS; + return WERR_UNKNOWN_LEVEL; } if (strequal(share_name,"IPC$") || strequal(share_name,"ADMIN$") || strequal(share_name,"global")) - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; snum = find_service(share_name); /* Share already exists. */ if (snum >= 0) - return NT_STATUS_OBJECT_NAME_COLLISION; + return WERR_ALREADY_EXISTS; /* We can only add disk shares. */ if (type != STYPE_DISKTREE) - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; /* Check if the pathname is valid. */ if (!(ptr = valid_share_pathname( pathname ))) - return NT_STATUS_OBJECT_PATH_INVALID; + return WERR_OBJECT_PATH_INVALID; /* Ensure share name, pathname and comment don't contain '"' characters. */ string_replace(share_name, '"', ' '); @@ -1453,7 +1446,7 @@ NTSTATUS _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET 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 NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } if (psd) { @@ -1463,8 +1456,7 @@ NTSTATUS _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET } /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, - NULL); + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); /* * We don't call reload_services() here, the message will @@ -1474,7 +1466,7 @@ NTSTATUS _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************* @@ -1482,7 +1474,7 @@ NTSTATUS _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET a parameter. ********************************************************************/ -NTSTATUS _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) +WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) { struct current_user user; pstring command; @@ -1495,24 +1487,24 @@ NTSTATUS _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET 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 NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; snum = find_service(share_name); if (snum < 0) - return NT_STATUS_BAD_NETWORK_NAME; + return WERR_NO_SUCH_SHARE; /* No change to printer shares. */ if (lp_print_ok(snum)) - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; get_current_user(&user,p); if (user.uid != 0) - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", lp_delete_share_cmd(), dyn_CONFIGFILE, lp_servicename(snum)); @@ -1520,26 +1512,25 @@ NTSTATUS _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET 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 NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } /* Delete the SD in the database. */ delete_share_security(snum); /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, - NULL); + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); lp_killservice(snum); - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************* time of day ********************************************************************/ -NTSTATUS _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET_REMOTE_TOD *r_u) +WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET_REMOTE_TOD *r_u) { TIME_OF_DAY_INFO *tod; struct tm *t; @@ -1547,13 +1538,13 @@ NTSTATUS _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_N tod = (TIME_OF_DAY_INFO *)talloc(p->mem_ctx, sizeof(TIME_OF_DAY_INFO)); if (!tod) - return NT_STATUS_NO_MEMORY; + return WERR_NOMEM; ZERO_STRUCTP(tod); r_u->tod = tod; r_u->ptr_srv_tod = 0x1; - r_u->status = NT_STATUS_OK; + r_u->status = WERR_OK; DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); @@ -1583,7 +1574,7 @@ NTSTATUS _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_N Win9x NT tools get security descriptor. ***********************************************************************************/ -NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC *q_u, +WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC *q_u, SRV_R_NET_FILE_QUERY_SECDESC *r_u) { SEC_DESC *psd = NULL; @@ -1599,51 +1590,50 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE NTSTATUS nt_status; struct current_user user; connection_struct *conn = NULL; - BOOL became_user = False; + BOOL became_user = False; ZERO_STRUCT(st); - r_u->status = NT_STATUS_OK; + r_u->status = WERR_OK; unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); /* Null password is ok - we are already an authenticated user... */ null_pw = data_blob(NULL, 0); - get_current_user(&user, p); - + get_current_user(&user, p); + become_root(); conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", qualname)); - r_u->status = nt_status; + r_u->status = ntstatus_to_werror(nt_status); goto error_exit; } if (!become_user(conn, conn->vuid)) { DEBUG(0,("_srv_net_file_query_secdesc: Can't become connected user!\n")); - r_u->status = NT_STATUS_ACCESS_DENIED; + r_u->status = WERR_ACCESS_DENIED; goto error_exit; } - became_user = True; + became_user = True; unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename)); unix_convert(filename, conn, NULL, &bad_path, &st); - fsp = open_file_shared(conn, filename, &st, SET_OPEN_MODE(DOS_OPEN_RDONLY), - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, 0, &access_mode, &action); + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, 0, &access_mode, &action); if (!fsp) { /* Perhaps it is a directory */ if (errno == EISDIR) fsp = open_directory(conn, filename, &st,0, - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); if (!fsp) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); - r_u->status = NT_STATUS_ACCESS_DENIED; + r_u->status = WERR_ACCESS_DENIED; goto error_exit; } } @@ -1652,7 +1642,7 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE if (sd_size == 0) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", filename)); - r_u->status = NT_STATUS_ACCESS_DENIED; + r_u->status = WERR_ACCESS_DENIED; goto error_exit; } @@ -1688,13 +1678,13 @@ NTSTATUS _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDE Win9x NT tools set security descriptor. ***********************************************************************************/ -NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_u, +WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_u, SRV_R_NET_FILE_SET_SECDESC *r_u) { BOOL ret; - DATA_BLOB null_pw; pstring filename; pstring qualname; + DATA_BLOB null_pw; files_struct *fsp = NULL; SMB_STRUCT_STAT st; BOOL bad_path; @@ -1702,33 +1692,34 @@ NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC * int action; NTSTATUS nt_status; struct current_user user; + fstring user_name; connection_struct *conn = NULL; BOOL became_user = False; ZERO_STRUCT(st); - r_u->status = NT_STATUS_OK; + r_u->status = WERR_OK; unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); /* Null password is ok - we are already an authenticated user... */ null_pw = data_blob(NULL, 0); - get_current_user(&user, p); - + get_current_user(&user, p); + become_root(); conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", qualname)); - r_u->status = nt_status; + r_u->status = ntstatus_to_werror(nt_status); 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 = NT_STATUS_ACCESS_DENIED; + r_u->status = WERR_ACCESS_DENIED; goto error_exit; } became_user = True; @@ -1737,17 +1728,17 @@ NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC * unix_convert(filename, conn, NULL, &bad_path, &st); fsp = open_file_shared(conn, filename, &st, SET_OPEN_MODE(DOS_OPEN_RDWR), - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, 0, &access_mode, &action); + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, 0, &access_mode, &action); if (!fsp) { /* Perhaps it is a directory */ if (errno == EISDIR) fsp = open_directory(conn, filename, &st,0, - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); if (!fsp) { DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename)); - r_u->status = NT_STATUS_ACCESS_DENIED; + r_u->status = WERR_ACCESS_DENIED; goto error_exit; } } @@ -1756,7 +1747,7 @@ NTSTATUS _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC * if (ret == False) { DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", filename)); - r_u->status = NT_STATUS_ACCESS_DENIED; + r_u->status = WERR_ACCESS_DENIED; goto error_exit; } @@ -1826,19 +1817,19 @@ static const char *next_server_disk_enum(uint32 *resume) return disk; } -NTSTATUS _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_DISK_ENUM *r_u) +WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_DISK_ENUM *r_u) { uint32 i; const char *disk_name; uint32 resume=get_enum_hnd(&q_u->enum_hnd); - r_u->status=NT_STATUS_OK; + r_u->status=WERR_OK; r_u->total_entries = init_server_disk_enum(&resume); r_u->disk_enum_ctr.unknown = 0; - r_u->disk_enum_ctr.disk_info_ptr = r_u->disk_enum_ctr.disk_info? 1 : 0; + r_u->disk_enum_ctr.disk_info_ptr = r_u->disk_enum_ctr.disk_info ? 1 : 0; /*allow one DISK_INFO for null terminator*/ @@ -1862,12 +1853,12 @@ NTSTATUS _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET return r_u->status; } -NTSTATUS _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV_R_NET_NAME_VALIDATE *r_u) +WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV_R_NET_NAME_VALIDATE *r_u) { int snum; fstring share_name; - r_u->status=NT_STATUS_OK; + r_u->status=WERR_OK; switch(q_u->type) { @@ -1881,12 +1872,12 @@ NTSTATUS _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, S /* Share already exists. */ if (snum >= 0) - r_u->status = NT_STATUS_OBJECT_NAME_INVALID; + r_u->status = WERR_ALREADY_EXISTS; break; default: /*unsupported type*/ - r_u->status = NT_STATUS_INVALID_LEVEL; + r_u->status = WERR_UNKNOWN_LEVEL; break; } -- cgit From 43ca6e3ef80f89a0e188a6aa86c6979e01804af2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 7 Mar 2002 01:02:48 +0000 Subject: Merge in the change to do per-handle access checks on setdata/setform etc. Should allow the buggy spoolss code on NT to work against us. Jeremy. (This used to be commit 2b3609a7dd55d96f5aafe137fff1ac2da0434867) --- source3/rpc_server/srv_spoolss_nt.c | 208 ++++++++++++++++++++++++------------ 1 file changed, 138 insertions(+), 70 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c7b4df9d82..eb10de3253 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -59,7 +59,7 @@ typedef struct _Printer{ fstring printerservername; } dev; uint32 type; - uint32 access; + uint32 access_granted; struct { uint32 flags; uint32 options; @@ -327,8 +327,9 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) } /**************************************************************************** - return the snum of a printer corresponding to an handle + Return the snum of a printer corresponding to an handle. ****************************************************************************/ + static BOOL get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number) { Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); @@ -350,23 +351,6 @@ static BOOL get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number) } } -/**************************************************************************** - set printer handle type. -****************************************************************************/ -static BOOL set_printer_hnd_accesstype(pipes_struct *p, POLICY_HND *hnd, uint32 access_required) -{ - Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); - - if (!Printer) { - DEBUG(2,("set_printer_hnd_accesstype: Invalid handle (%s:%u:%u)", OUR_HANDLE(hnd))); - return False; - } - - DEBUG(4,("Setting printer access=%x\n", access_required)); - Printer->access = access_required; - return True; -} - /**************************************************************************** Set printer handle type. Check if it's \\server or \\server\printer @@ -468,10 +452,10 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) } /**************************************************************************** - find first available printer slot. creates a printer handle for you. + Find first available printer slot. creates a printer handle for you. ****************************************************************************/ -static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name) +static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint32 access_granted) { Printer_entry *new_printer; @@ -502,31 +486,17 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name) return False; } - DEBUG(5, ("%d printer handles active\n", (int)p->pipe_handles->count )); + new_printer->access_granted = access_granted; - return True; -} - -/******************************************************************** - Return True if the handle is a print server. - ********************************************************************/ - -static BOOL handle_is_printserver(pipes_struct *p, POLICY_HND *handle) -{ - Printer_entry *Printer=find_printer_index_by_hnd(p,handle); + DEBUG(5, ("%d printer handles active\n", (int)p->pipe_handles->count )); - if (!Printer) - return False; - - if (Printer->printer_type != PRINTER_HANDLE_IS_PRINTSERVER) - return False; - return True; } /**************************************************************************** - allocate more memory for a BUFFER. + Allocate more memory for a BUFFER. ****************************************************************************/ + static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) { prs_struct *ps; @@ -646,6 +616,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, fstring name; int snum; struct current_user user; + Printer_entry *Printer=NULL; if (q_u->printername_ptr != 0) printername = &q_u->printername; @@ -659,9 +630,17 @@ WERROR _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)) + if (!open_printer_hnd(p, handle, name, 0)) return WERR_INVALID_PRINTER_NAME; + Printer=find_printer_index_by_hnd(p, handle); + if (!Printer) { + DEBUG(0,(" _spoolss_open_printer_ex: logic error. \ +Can't find printer handle we created for priunter %s\n", name )); + close_printer_handle(p,handle); + return WERR_INVALID_PRINTER_NAME; + } + /* if (printer_default->datatype_ptr != NULL) { @@ -672,11 +651,6 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, set_printer_hnd_datatype(handle, ""); */ - if (!set_printer_hnd_accesstype(p, handle, printer_default->access_required)) { - close_printer_handle(p, handle); - return WERR_ACCESS_DENIED; - } - /* First case: the user is opening the print server: @@ -702,7 +676,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, get_current_user(&user, p); - if (handle_is_printserver(p, handle)) { + if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) { if (printer_default->access_required == 0) { return WERR_OK; } @@ -755,6 +729,21 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, return WERR_ACCESS_DENIED; } + /* + * An admin user always has access. + */ + + if (user.uid == 0 || user_in_list(uidtoname(user.uid), lp_printer_admin(snum))) + printer_default->access_required = PRINTER_ACCESS_ADMINISTER; + + if (printer_default->access_required & PRINTER_ACCESS_ADMINISTER) + printer_default->access_required = PRINTER_ACCESS_ADMINISTER; + else + printer_default->access_required = PRINTER_ACCESS_USE; + + DEBUG(4,("Setting printer access=%x\n", printer_default->access_required)); + Printer->access_granted = printer_default->access_required; + /* * If we have a default device pointer in the * printer_default struct, then we need to get @@ -836,6 +825,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /**************************************************************************** ****************************************************************************/ + static BOOL convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni, NT_PRINTER_INFO_LEVEL *printer, uint32 level) { @@ -1022,6 +1012,7 @@ WERROR _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL * static function to lookup the version id corresponding to an * long architecture string ******************************************************************/ + static int get_version_id (char * arch) { int i; @@ -1090,10 +1081,10 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER return delete_printer_driver(info.info_3); } - /******************************************************************** GetPrinterData on a printer server Handle. ********************************************************************/ + static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size) { int i; @@ -1183,6 +1174,7 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 /******************************************************************** GetPrinterData on a printer Handle. ********************************************************************/ + static BOOL getprinterdata_printer(pipes_struct *p, TALLOC_CTX *ctx, POLICY_HND *handle, fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size ) @@ -1303,8 +1295,9 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO } /*************************************************************************** - connect to the client + Connect to the client. ****************************************************************************/ + static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle) { WERROR status; @@ -1413,6 +1406,7 @@ static void spoolss_notify_server_name(int snum, /******************************************************************* * fill a notify_info_data with the printername (not including the servername). ********************************************************************/ + static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1447,6 +1441,7 @@ static void spoolss_notify_printer_name(int snum, /******************************************************************* * fill a notify_info_data with the servicename ********************************************************************/ + static void spoolss_notify_share_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1472,6 +1467,7 @@ static void spoolss_notify_share_name(int snum, /******************************************************************* * fill a notify_info_data with the port name ********************************************************************/ + static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1501,6 +1497,7 @@ static void spoolss_notify_port_name(int snum, * jfmxxxx: it's incorrect, should be lp_printerdrivername() * but it doesn't exist, have to see what to do ********************************************************************/ + static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1525,6 +1522,7 @@ static void spoolss_notify_driver_name(int snum, /******************************************************************* * fill a notify_info_data with the comment ********************************************************************/ + static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1555,6 +1553,7 @@ static void spoolss_notify_comment(int snum, * jfm:xxxx incorrect, have to create a new smb.conf option * location = "Room 1, floor 2, building 3" ********************************************************************/ + static void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1581,6 +1580,7 @@ static void spoolss_notify_location(int snum, * fill a notify_info_data with the device mode * jfm:xxxx don't to it for know but that's a real problem !!! ********************************************************************/ + static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1594,6 +1594,7 @@ static void spoolss_notify_devmode(int snum, * jfm:xxxx just return no file could add an option to smb.conf * separator file = "separator.txt" ********************************************************************/ + static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1620,6 +1621,7 @@ static void spoolss_notify_sepfile(int snum, * fill a notify_info_data with the print processor * jfm:xxxx return always winprint to indicate we don't do anything to it ********************************************************************/ + static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1646,6 +1648,7 @@ static void spoolss_notify_print_processor(int snum, * fill a notify_info_data with the print processor options * jfm:xxxx send an empty string ********************************************************************/ + static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1672,6 +1675,7 @@ static void spoolss_notify_parameters(int snum, * fill a notify_info_data with the data type * jfm:xxxx always send RAW as data type ********************************************************************/ + static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1699,6 +1703,7 @@ static void spoolss_notify_datatype(int snum, * jfm:xxxx send an null pointer to say no security desc * have to implement security before ! ********************************************************************/ + static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1713,6 +1718,7 @@ static void spoolss_notify_security_desc(int snum, * fill a notify_info_data with the attributes * jfm:xxxx a samba printer is always shared ********************************************************************/ + static void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1726,6 +1732,7 @@ static void spoolss_notify_attributes(int snum, /******************************************************************* * fill a notify_info_data with the priority ********************************************************************/ + static void spoolss_notify_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1739,6 +1746,7 @@ static void spoolss_notify_priority(int snum, /******************************************************************* * fill a notify_info_data with the default priority ********************************************************************/ + static void spoolss_notify_default_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1752,6 +1760,7 @@ static void spoolss_notify_default_priority(int snum, /******************************************************************* * fill a notify_info_data with the start time ********************************************************************/ + static void spoolss_notify_start_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1765,6 +1774,7 @@ static void spoolss_notify_start_time(int snum, /******************************************************************* * fill a notify_info_data with the until time ********************************************************************/ + static void spoolss_notify_until_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1778,6 +1788,7 @@ static void spoolss_notify_until_time(int snum, /******************************************************************* * fill a notify_info_data with the status ********************************************************************/ + static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1794,6 +1805,7 @@ static void spoolss_notify_status(int snum, /******************************************************************* * fill a notify_info_data with the number of jobs queued ********************************************************************/ + static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1807,6 +1819,7 @@ static void spoolss_notify_cjobs(int snum, /******************************************************************* * fill a notify_info_data with the average ppm ********************************************************************/ + static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1822,6 +1835,7 @@ static void spoolss_notify_average_ppm(int snum, /******************************************************************* * fill a notify_info_data with username ********************************************************************/ + static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1847,6 +1861,7 @@ static void spoolss_notify_username(int snum, /******************************************************************* * fill a notify_info_data with job status ********************************************************************/ + static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1860,6 +1875,7 @@ static void spoolss_notify_job_status(int snum, /******************************************************************* * fill a notify_info_data with job name ********************************************************************/ + static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1885,6 +1901,7 @@ static void spoolss_notify_job_name(int snum, /******************************************************************* * fill a notify_info_data with job status ********************************************************************/ + static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1934,6 +1951,7 @@ static void spoolss_notify_job_status_string(int snum, /******************************************************************* * fill a notify_info_data with job time ********************************************************************/ + static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -1947,6 +1965,7 @@ static void spoolss_notify_job_time(int snum, /******************************************************************* * fill a notify_info_data with job size ********************************************************************/ + static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -2085,8 +2104,9 @@ struct s_notify_info_data_table notify_info_data_table[] = }; /******************************************************************* -return the size of info_data structure + Return the size of info_data structure. ********************************************************************/ + static uint32 size_of_notify_info_data(uint16 type, uint16 field) { int i=0; @@ -2104,8 +2124,9 @@ static uint32 size_of_notify_info_data(uint16 type, uint16 field) } /******************************************************************* -return the type of notify_info_data + Return the type of notify_info_data. ********************************************************************/ + static BOOL type_of_notify_info_data(uint16 type, uint16 field) { int i=0; @@ -2131,6 +2152,7 @@ static BOOL type_of_notify_info_data(uint16 type, uint16 field) /**************************************************************************** ****************************************************************************/ + static int search_notify(uint16 type, uint16 field, int *value) { int j; @@ -2152,6 +2174,7 @@ static int search_notify(uint16 type, uint16 field, int *value) /**************************************************************************** ****************************************************************************/ + static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 field, int id) { info_data->type = type; @@ -2168,6 +2191,7 @@ static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, * fill a notify_info struct with info asked * ********************************************************************/ + static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id, @@ -2225,6 +2249,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int * fill a notify_info struct with info asked * ********************************************************************/ + static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, NT_PRINTER_INFO_LEVEL *printer, @@ -2358,6 +2383,7 @@ static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, * fill a notify_info struct with info asked * ********************************************************************/ + static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, TALLOC_CTX *mem_ctx) { @@ -2494,6 +2520,7 @@ WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN * construct_printer_info_0 * fill a printer_info_0 struct ********************************************************************/ + static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) { pstring chaine; @@ -2598,6 +2625,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) * construct_printer_info_1 * fill a printer_info_1 struct ********************************************************************/ + static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int snum) { pstring chaine; @@ -2795,6 +2823,7 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum) * construct_printer_info_3 * fill a printer_info_3 struct ********************************************************************/ + static BOOL construct_printer_info_3(PRINTER_INFO_3 **pp_printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; @@ -2887,10 +2916,10 @@ static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum) return True; } - /******************************************************************** Spoolss_enumprinters. ********************************************************************/ + static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int snum; @@ -2945,6 +2974,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 /******************************************************************** enum_all_printers_info_1_local. *********************************************************************/ + static WERROR enum_all_printers_info_1_local(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { DEBUG(4,("enum_all_printers_info_1_local\n")); @@ -2955,6 +2985,7 @@ static WERROR enum_all_printers_info_1_local(NEW_BUFFER *buffer, uint32 offered, /******************************************************************** enum_all_printers_info_1_name. *********************************************************************/ + static WERROR enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { char *s = name; @@ -2974,6 +3005,7 @@ static WERROR enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, ui /******************************************************************** enum_all_printers_info_1_remote. *********************************************************************/ + static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTER_INFO_1 *printer; @@ -3102,6 +3134,7 @@ static WERROR enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint3 /******************************************************************** * handle enumeration of printers at level 1 ********************************************************************/ + static WERROR enumprinters_level1( uint32 flags, fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) @@ -3126,6 +3159,7 @@ static WERROR enumprinters_level1( uint32 flags, fstring name, /******************************************************************** * handle enumeration of printers at level 2 ********************************************************************/ + static WERROR enumprinters_level2( uint32 flags, fstring servername, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) @@ -3154,6 +3188,7 @@ static WERROR enumprinters_level2( uint32 flags, fstring servername, /******************************************************************** * handle enumeration of printers at level 5 ********************************************************************/ + static WERROR enumprinters_level5( uint32 flags, fstring servername, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) @@ -3221,6 +3256,7 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ /**************************************************************************** ****************************************************************************/ + static WERROR getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_0 *printer=NULL; @@ -3253,6 +3289,7 @@ static WERROR getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ + static WERROR getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_1 *printer=NULL; @@ -3285,6 +3322,7 @@ static WERROR getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ + static WERROR getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_2 *printer=NULL; @@ -3320,6 +3358,7 @@ static WERROR getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ + static WERROR getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_3 *printer=NULL; @@ -3350,6 +3389,7 @@ static WERROR getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ + static WERROR getprinter_level_4(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_4 *printer=NULL; @@ -3383,6 +3423,7 @@ static WERROR getprinter_level_4(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ + static WERROR getprinter_level_5(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_5 *printer=NULL; @@ -3456,6 +3497,7 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET /******************************************************************** * fill a DRIVER_INFO_1 struct ********************************************************************/ + static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername, fstring architecture) { init_unistr( &info->name, driver.info_3->name); @@ -3464,6 +3506,7 @@ static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_IN /******************************************************************** * construct_printer_driver_info_1 ********************************************************************/ + static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; @@ -3488,6 +3531,7 @@ static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fst * construct_printer_driver_info_2 * fill a printer_info_2 struct ********************************************************************/ + static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) { pstring temp; @@ -3521,6 +3565,7 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_IN * construct_printer_driver_info_2 * fill a printer_info_2 struct ********************************************************************/ + static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; @@ -3547,6 +3592,7 @@ static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fst * * convert an array of ascii string to a UNICODE string ********************************************************************/ + static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *servername) { int i=0; @@ -3588,6 +3634,7 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser * construct_printer_info_3 * fill a printer_info_3 struct ********************************************************************/ + static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) { pstring temp; @@ -3634,6 +3681,7 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN * construct_printer_info_3 * fill a printer_info_3 struct ********************************************************************/ + static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; @@ -3756,6 +3804,7 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN * construct_printer_info_6 * fill a printer_info_6 struct ********************************************************************/ + static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fstring servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; @@ -3816,6 +3865,7 @@ static void free_printer_driver_info_6(DRIVER_INFO_6 *info) /**************************************************************************** ****************************************************************************/ + static WERROR getprinterdriver2_level1(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_1 *info=NULL; @@ -3852,6 +3902,7 @@ static WERROR getprinterdriver2_level1(fstring servername, fstring architecture, /**************************************************************************** ****************************************************************************/ + static WERROR getprinterdriver2_level2(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_2 *info=NULL; @@ -3888,6 +3939,7 @@ static WERROR getprinterdriver2_level2(fstring servername, fstring architecture, /**************************************************************************** ****************************************************************************/ + static WERROR getprinterdriver2_level3(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_3 info; @@ -3921,6 +3973,7 @@ static WERROR getprinterdriver2_level3(fstring servername, fstring architecture, /**************************************************************************** ****************************************************************************/ + static WERROR getprinterdriver2_level6(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_6 info; @@ -4152,6 +4205,7 @@ WERROR _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R * called from the spoolss dispatcher * ********************************************************************/ + static WERROR control_printer(POLICY_HND *handle, uint32 command, pipes_struct *p) { @@ -4209,6 +4263,7 @@ WERROR _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R * called by spoolss_api_setprinter * when updating a printer description ********************************************************************/ + static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, pipes_struct *p, SEC_DESC_BUF *secdesc_ctr) @@ -4322,6 +4377,7 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) /**************************************************************************** ****************************************************************************/ + static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) { char *cmd = lp_addprinter_cmd(); @@ -4714,8 +4770,8 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, /* Check calling user has permission to update printer description */ - if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { - DEBUG(3, ("update_printer: printer property change denied by security descriptor\n")); + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + DEBUG(3, ("update_printer: printer property change denied by handle\n")); result = WERR_ACCESS_DENIED; goto done; } @@ -4845,6 +4901,7 @@ WERROR _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u /**************************************************************************** ****************************************************************************/ + static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, int position, int snum) { @@ -4873,6 +4930,7 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, /**************************************************************************** ****************************************************************************/ + static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, int position, int snum, NT_PRINTER_INFO_LEVEL *ntprinter, @@ -4922,6 +4980,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, /**************************************************************************** Enumjobs at level 1. ****************************************************************************/ + static WERROR enumjobs_level1(print_queue_struct *queue, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) @@ -4968,6 +5027,7 @@ static WERROR enumjobs_level1(print_queue_struct *queue, int snum, /**************************************************************************** Enumjobs at level 2. ****************************************************************************/ + static WERROR enumjobs_level2(print_queue_struct *queue, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) @@ -5146,6 +5206,7 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u /**************************************************************************** Enumerates all printer drivers at level 1. ****************************************************************************/ + static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; @@ -5226,6 +5287,7 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture /**************************************************************************** Enumerates all printer drivers at level 2. ****************************************************************************/ + static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; @@ -5307,6 +5369,7 @@ static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture /**************************************************************************** Enumerates all printer drivers at level 3. ****************************************************************************/ + static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; @@ -5635,6 +5698,7 @@ WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * /**************************************************************************** ****************************************************************************/ + static void fill_port_1(PORT_INFO_1 *port, char *name) { init_unistr(&port->port_name, name); @@ -5642,6 +5706,7 @@ static void fill_port_1(PORT_INFO_1 *port, char *name) /**************************************************************************** ****************************************************************************/ + static void fill_port_2(PORT_INFO_2 *port, char *name) { init_unistr(&port->port_name, name); @@ -5655,6 +5720,7 @@ static void fill_port_2(PORT_INFO_2 *port, char *name) /**************************************************************************** enumports level 1. ****************************************************************************/ + static WERROR enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PORT_INFO_1 *ports=NULL; @@ -5873,6 +5939,7 @@ WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUM /**************************************************************************** ****************************************************************************/ + static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_srv_name, const SPOOL_PRINTER_INFO_LEVEL *info, DEVICEMODE *devmode, SEC_DESC_BUF *sec_desc_buf, @@ -5962,7 +6029,7 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ return err; } - if (!open_printer_hnd(p, handle, name)) { + if (!open_printer_hnd(p, handle, name, PRINTER_ACCESS_ADMINISTER)) { /* Handle open failed - remove addition. */ del_a_printer(printer->info_2->sharename); free_a_printer(&printer,2); @@ -6051,6 +6118,7 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, /**************************************************************************** ****************************************************************************/ + static void fill_driverdir_1(DRIVER_DIRECTORY_1 *info, char *name) { init_unistr(&info->name, name); @@ -6058,6 +6126,7 @@ static void fill_driverdir_1(DRIVER_DIRECTORY_1 *info, char *name) /**************************************************************************** ****************************************************************************/ + static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environment, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { pstring path; @@ -6347,9 +6416,8 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP * 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")); + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + DEBUG(3, ("_spoolss_setprinterdata: change denied by handle access permissions\n")); status = WERR_ACCESS_DENIED; goto done; } @@ -6439,9 +6507,8 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; - if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { - DEBUG(3, ("_spoolss_deleteprinterdata: printer properties " - "change denied by existing security descriptor\n")); + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + DEBUG(3, ("_spoolss_deleteprinterdata: printer properties change denied by handle\n")); return WERR_ACCESS_DENIED; } @@ -6488,9 +6555,8 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; - if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { - DEBUG(3, ("security descriptor change denied by existing " - "security descriptor\n")); + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + DEBUG(2,("_spoolss_addform: denied by handle permissions.\n")); status = WERR_ACCESS_DENIED; goto done; } @@ -6550,9 +6616,8 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; - if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { - DEBUG(3, ("security descriptor change denied by existing " - "security descriptor\n")); + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + DEBUG(2,("_spoolss_deleteform: denied by handle permissions\n")); return WERR_ACCESS_DENIED; } @@ -6612,9 +6677,8 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; - if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) { - DEBUG(3, ("security descriptor change denied by existing " - "security descriptor\n")); + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + DEBUG(2,("_spoolss_setform: denied by handle permissions\n")); return WERR_ACCESS_DENIED; } @@ -6649,6 +6713,7 @@ done: /**************************************************************************** enumprintprocessors level 1. ****************************************************************************/ + static WERROR enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTPROCESSOR_1 *info_1=NULL; @@ -6717,6 +6782,7 @@ WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS /**************************************************************************** enumprintprocdatatypes level 1. ****************************************************************************/ + static WERROR enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTPROCDATATYPE_1 *info_1=NULL; @@ -6810,6 +6876,7 @@ static WERROR enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint /**************************************************************************** enumprintmonitors level 2. ****************************************************************************/ + static WERROR enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTMONITOR_2 *info_2=NULL; @@ -6880,6 +6947,7 @@ WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_ /**************************************************************************** ****************************************************************************/ + static WERROR getjob_level_1(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { int i=0; @@ -6926,9 +6994,9 @@ static WERROR getjob_level_1(print_queue_struct *queue, int count, int snum, uin return WERR_OK; } - /**************************************************************************** ****************************************************************************/ + static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { int i=0; -- cgit From 194e39b179efc040c3db65996edaf9e785ef6d78 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 8 Mar 2002 00:26:18 +0000 Subject: Turns out an Admin user shouldn't always have access on a handle. Jeremy. (This used to be commit d31d2dcd22e1be2c26ea315e1b0e8442822a9a0f) --- source3/rpc_server/srv_spoolss_nt.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index eb10de3253..7319356568 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -729,13 +729,6 @@ Can't find printer handle we created for priunter %s\n", name )); return WERR_ACCESS_DENIED; } - /* - * An admin user always has access. - */ - - if (user.uid == 0 || user_in_list(uidtoname(user.uid), lp_printer_admin(snum))) - printer_default->access_required = PRINTER_ACCESS_ADMINISTER; - if (printer_default->access_required & PRINTER_ACCESS_ADMINISTER) printer_default->access_required = PRINTER_ACCESS_ADMINISTER; else -- cgit From c3e813945c5c44a846efa522632e2b1e724d0bd9 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 8 Mar 2002 21:57:53 +0000 Subject: merge from 2.2 (This used to be commit 4960692e958c986ca7f71e091333300310b0e0b2) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7319356568..294d9d5535 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1282,7 +1282,7 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO } if (*needed > *out_size) - return WERR_STATUS_MORE_ENTRIES; + return WERR_MORE_DATA; else return WERR_OK; } @@ -7176,7 +7176,7 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, *data = NULL; } - return WERR_INVALID_PARAM; + return WERR_BADFILE; } if (*needed > *out_size) -- cgit From 8fa6b34e08e21546082892f27e3d70bae211c371 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 8 Mar 2002 22:07:18 +0000 Subject: merge from 2.2 (This used to be commit 66eb969ade0dfde355df3e308dccbc9522087eef) --- source3/rpc_server/srv_spoolss_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 294d9d5535..f489802f77 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1124,7 +1124,7 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return False; - SIVAL(*data, 0, 0x02); + SIVAL(*data, 0, 0x03); *needed = 0x4; return True; } @@ -7157,7 +7157,7 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, */ if (strcmp(key, "PrinterDriverData") != 0) - return WERR_INVALID_PARAM; + return WERR_BADFILE; DEBUG(10, ("_spoolss_getprinterdataex: pass me to getprinterdata\n")); found = getprinterdata_printer(p, p->mem_ctx, handle, value, @@ -7176,7 +7176,7 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, *data = NULL; } - return WERR_BADFILE; + return WERR_INVALID_PARAM; } if (*needed > *out_size) -- cgit From 664fa8e572b4ed3db6d1eb2b5023cce4ed25659c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Mar 2002 01:45:49 +0000 Subject: return the correct SID and domain name for the samr enum_domain and lookup_domain calls. We were incorrectly returning the PDCs domain nameand SID when we are a domain member. We should only do that when we are the DC (This used to be commit f56d689497eaa670cbfb214486ba88d5972129db) --- source3/rpc_server/srv_samr_nt.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 552623306f..eb8ec16f45 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2098,16 +2098,27 @@ NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u NTSTATUS _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_LOOKUP_DOMAIN *r_u) { - r_u->status = NT_STATUS_OK; + fstring domain_name; + DOM_SID sid; + + r_u->status = NT_STATUS_OK; - if (!find_policy_by_hnd(p, &q_u->connect_pol, NULL)) - return NT_STATUS_INVALID_HANDLE; + if (!find_policy_by_hnd(p, &q_u->connect_pol, NULL)) + return NT_STATUS_INVALID_HANDLE; - /* assume the domain name sent is our global_myname and - send global_sam_sid */ - init_samr_r_lookup_domain(r_u, &global_sam_sid, r_u->status); + rpcstr_pull(domain_name, q_u->uni_domain.buffer, sizeof(domain_name), q_u->uni_domain.uni_str_len*2, 0); - return r_u->status; + ZERO_STRUCT(sid); + + if (!secrets_fetch_domain_sid(domain_name, &sid)) { + r_u->status = NT_STATUS_NO_SUCH_DOMAIN; + } + + DEBUG(2,("Returning domain sid for domain %s -> %s\n", domain_name, sid_string_static(&sid))); + + init_samr_r_lookup_domain(r_u, &sid, r_u->status); + + return r_u->status; } /****************************************************************** @@ -2156,10 +2167,21 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN { uint32 num_entries = 2; fstring dom[2]; + char *name; r_u->status = NT_STATUS_OK; - fstrcpy(dom[0],global_myworkgroup); + switch (lp_server_role()) { + case ROLE_DOMAIN_PDC: + case ROLE_DOMAIN_BDC: + name = global_myworkgroup; + break; + default: + name = global_myname; + } + + fstrcpy(dom[0],name); + strupper(dom[0]); fstrcpy(dom[1],"Builtin"); if (!make_enum_domains(p->mem_ctx, &r_u->sam, &r_u->uni_dom_name, num_entries, dom)) -- cgit From 92e59edc410a1de09a3d1eaba09cd46f4db1367f Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 12 Mar 2002 00:16:03 +0000 Subject: Merge of enumprinters vs getprinter naming patch from 2.2 (This used to be commit dfd51bc8d0714473880bf50369f7994304c1d83f) --- source3/rpc_server/srv_spoolss_nt.c | 44 +++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f489802f77..f0ea088dc3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4,9 +4,10 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, - * Copyright (C) Jean François Micouleau 1998-2000. - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Gerald Carter 2000-2001. + * Copyright (C) Jean François Micouleau 1998-2000, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Gerald Carter 2000-2001, + * Copyright (C) Tim Potter 2001-2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2617,9 +2618,13 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) /******************************************************************** * construct_printer_info_1 * fill a printer_info_1 struct + * + * The is_enum parameter says whether the PRINTER_INFO_1 returned is + * to be used in an enumprinters call. This affects whether the netbios + * name of the server is prefixed to the printer and server names. ********************************************************************/ - -static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int snum) +static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, + int snum, BOOL is_enum) { pstring chaine; pstring chaine2; @@ -2632,13 +2637,23 @@ static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int if (*ntprinter->info_2->comment == '\0') { init_unistr(&printer->comment, lp_comment(snum)); - slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",get_called_name(), ntprinter->info_2->printername, - ntprinter->info_2->drivername, lp_comment(snum)); - } - else { + if (is_enum) { + char *p; + + p = strchr(ntprinter->info_2->printername + 2, '\\'); + + if (p) + fstrcpy(ntprinter->info_2->printername, p + 1); + } + slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s", + ntprinter->info_2->printername, + ntprinter->info_2->drivername, lp_comment(snum)); + } else { init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ - slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",get_called_name(), ntprinter->info_2->printername, - ntprinter->info_2->drivername, ntprinter->info_2->comment); + slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s", + ntprinter->info_2->printername, + ntprinter->info_2->drivername, + ntprinter->info_2->comment); } slprintf(chaine2,sizeof(chaine)-1,"%s", ntprinter->info_2->printername); @@ -2926,8 +2941,8 @@ static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 for (snum=0; snum Date: Thu, 14 Mar 2002 01:48:59 +0000 Subject: Backed out enumprinters stuff - leave it for another day. (This used to be commit d7efc5dd3dd712e7138b5c79eea9756125757175) --- source3/rpc_server/srv_spoolss_nt.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f0ea088dc3..3479e47f76 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2618,13 +2618,9 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) /******************************************************************** * construct_printer_info_1 * fill a printer_info_1 struct - * - * The is_enum parameter says whether the PRINTER_INFO_1 returned is - * to be used in an enumprinters call. This affects whether the netbios - * name of the server is prefixed to the printer and server names. ********************************************************************/ -static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, - int snum, BOOL is_enum) + +static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int snum) { pstring chaine; pstring chaine2; @@ -2637,23 +2633,13 @@ static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, if (*ntprinter->info_2->comment == '\0') { init_unistr(&printer->comment, lp_comment(snum)); - if (is_enum) { - char *p; - - p = strchr(ntprinter->info_2->printername + 2, '\\'); - - if (p) - fstrcpy(ntprinter->info_2->printername, p + 1); - } - slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s", - ntprinter->info_2->printername, - ntprinter->info_2->drivername, lp_comment(snum)); - } else { + slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",get_called_name(), ntprinter->info_2->printername, + ntprinter->info_2->drivername, lp_comment(snum)); + } + else { init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ - slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s", - ntprinter->info_2->printername, - ntprinter->info_2->drivername, - ntprinter->info_2->comment); + slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",get_called_name(), ntprinter->info_2->printername, + ntprinter->info_2->drivername, ntprinter->info_2->comment); } slprintf(chaine2,sizeof(chaine)-1,"%s", ntprinter->info_2->printername); @@ -2942,7 +2928,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); - if (construct_printer_info_1(flags, ¤t_prt, snum, True)) { + if (construct_printer_info_1(flags, ¤t_prt, snum)) { if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) { DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n")); SAFE_FREE(printers); @@ -3306,7 +3292,7 @@ static WERROR getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, u if((printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1))) == NULL) return WERR_NOMEM; - construct_printer_info_1(PRINTER_ENUM_ICON8, printer, snum, False); + construct_printer_info_1(PRINTER_ENUM_ICON8, printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_1(printer); -- cgit From 65c007b583e2107f5ad1ba6733d3e578a143863e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 15 Mar 2002 08:14:10 +0000 Subject: syncing up printing code with SAMBA_2_2 (already done some merges in the reverse). * add in new printer change notify code from SAMBA_2_2 * add in se_map_standard() from 2.2 in _spoolss_open_printer_ex() * sync up the _print_queue_struct in smb.h (why did someone change the user/file names in fs_user/fs_file (or vice-versa) ? ) * sync up some cli_spoolss_XXX functions (This used to be commit 5760315c1de4033fdc22684c940f18010010924f) --- source3/rpc_server/srv_spoolss.c | 34 ++- source3/rpc_server/srv_spoolss_nt.c | 432 ++++++++++++++++++++++++------------ 2 files changed, 317 insertions(+), 149 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 3f3c6039c9..3838632021 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -975,7 +975,33 @@ static BOOL api_spoolss_setprinterdata(pipes_struct *p) /**************************************************************************** ****************************************************************************/ +static BOOL api_spoolss_reset_printer(pipes_struct *p) +{ + SPOOL_Q_RESETPRINTER q_u; + SPOOL_R_RESETPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_resetprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n")); + return False; + } + + r_u.status = _spoolss_resetprinter(p, &q_u, &r_u); + + if(!spoolss_io_r_resetprinter("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_RESETPRINTER.\n")); + return False; + } + + return True; +} +/**************************************************************************** +****************************************************************************/ static BOOL api_spoolss_addform(pipes_struct *p) { SPOOL_Q_ADDFORM q_u; @@ -1318,11 +1344,6 @@ static BOOL api_spoolss_enumprinterdataex(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -/* Disabled because it doesn't fix the bug I am looking at but it would be - a shame to throw away the code. -tpot */ - -#if 0 - static BOOL api_spoolss_getprintprocessordirectory(pipes_struct *p) { SPOOL_Q_GETPRINTPROCESSORDIRECTORY q_u; @@ -1348,8 +1369,6 @@ static BOOL api_spoolss_getprintprocessordirectory(pipes_struct *p) return True; } -#endif - /******************************************************************* \pipe\spoolss commands ********************************************************************/ @@ -1386,6 +1405,7 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory }, {"SPOOLSS_ENUMPRINTERDATA", SPOOLSS_ENUMPRINTERDATA, api_spoolss_enumprinterdata }, {"SPOOLSS_SETPRINTERDATA", SPOOLSS_SETPRINTERDATA, api_spoolss_setprinterdata }, + {"SPOOLSS_RESETPRINTER", SPOOLSS_RESETPRINTER, api_spoolss_reset_printer }, {"SPOOLSS_DELETEPRINTERDATA", SPOOLSS_DELETEPRINTERDATA, api_spoolss_deleteprinterdata }, {"SPOOLSS_ADDFORM", SPOOLSS_ADDFORM, api_spoolss_addform }, {"SPOOLSS_DELETEFORM", SPOOLSS_DELETEFORM, api_spoolss_deleteform }, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3479e47f76..a6c0f9368c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -91,6 +91,10 @@ static ubi_dlList counter_list; static struct cli_state cli; static uint32 smb_connections=0; + +/* in printing/nt_printing.c */ +extern STANDARD_MAPPING printer_std_mapping; + #define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ ((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) @@ -158,7 +162,7 @@ static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp) static void srv_spoolss_replycloseprinter(POLICY_HND *handle) { - WERROR status; + NTSTATUS result; /* weird if the test succeds !!! */ if (smb_connections==0) { @@ -166,7 +170,9 @@ static void srv_spoolss_replycloseprinter(POLICY_HND *handle) return; } - if(!cli_spoolss_reply_close_printer(&cli, handle, &status)) + result = cli_spoolss_reply_close_printer(&cli, cli.mem_ctx, handle); + + if (!NT_STATUS_IS_OK(result)) DEBUG(0,("srv_spoolss_replycloseprinter: reply_close_printer failed.\n")); /* if it's the last connection, deconnect the IPC$ share */ @@ -528,71 +534,233 @@ static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) return True; } +/*************************************************************************** + Always give preference Printer_entry.notify.option over + Printer_entry.notify.flags. Return True if we should send notification + events using SPOOLSS_RRPCN. False means that we should use + SPOOLSS_ROUTERREPLYPRINTER. + **************************************************************************/ +static BOOL valid_notify_options(Printer_entry *printer) +{ + if (printer->notify.option == NULL) + return False; + + return True; +} /*************************************************************************** - Receive the notify message. -****************************************************************************/ + Simple check to see if the client motify handle is set to watch for events + represented by 'flags' + + FIXME!!!! only a stub right now --jerry + **************************************************************************/ + +static BOOL is_client_monitoring_event(Printer_entry *p, uint32 flags) +{ -static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) + return True; +} + +/*************************************************************************** + Server wrapper for cli_spoolss_routerreplyprinter() since the client + function can only send a single change notification at a time. + + FIXME!!! only handles one change currently (PRINTER_CHANGE_SET_PRINTER_DRIVER) + --jerry + **************************************************************************/ + +static NTSTATUS srv_spoolss_routerreplyprinter (struct cli_state *cli, TALLOC_CTX *mem_ctx, + POLICY_HND *pol, PRINTER_MESSAGE_INFO *info, + NT_PRINTER_INFO_LEVEL *printer) { - Printer_entry *find_printer; - WERROR status; - fstring printer_name; - char msg[8]; - char *buf_ptr = (char *)buf; - uint32 low, high; + NTSTATUS result; + uint32 condition = 0x0; + + if (info->flags & PRINTER_MESSAGE_DRIVER) + condition = PRINTER_CHANGE_SET_PRINTER_DRIVER; + + result = cli_spoolss_routerreplyprinter(cli, mem_ctx, pol, condition, + printer->info_2->changeid); - if (len < sizeof(msg) + 2) { - DEBUG(2,("srv_spoolss_receive_message: got incorrect message size (%u)!\n", (unsigned int)len)); - return; + return result; +} + +/*********************************************************************** + Wrapper around the decision of which RPC use to in the change + notification + **********************************************************************/ + +static NTSTATUS srv_spoolss_send_event_to_client(Printer_entry* Printer, + struct cli_state *cli, PRINTER_MESSAGE_INFO *msg, + NT_PRINTER_INFO_LEVEL *info) +{ + NTSTATUS result; + + if (valid_notify_options(Printer)) { + /* This is a single call that can send information about multiple changes */ + if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + msg->flags |= PRINTER_MESSAGE_ATTRIBUTES; + result = cli_spoolss_reply_rrpcn(cli, cli->mem_ctx, &Printer->notify.client_hnd, + msg, info); } + else { + /* This requires that the server send an individual event notification for each change */ + result = srv_spoolss_routerreplyprinter(cli, cli->mem_ctx, &Printer->notify.client_hnd, + msg, info); + } + + return result; +} - memcpy(msg, buf_ptr, sizeof(msg)); - low = IVAL(msg,0); - high = IVAL(msg,4); - fstrcpy(printer_name, buf_ptr + sizeof(msg)); - DEBUG(10,("srv_spoolss_receive_message: Got message printer change name [%s] low=0x%x high=0x%x\n", - printer_name, (unsigned int)low, (unsigned int)high )); +/*********************************************************************** + Send a change notication message on all handles which have a call + back registered + **********************************************************************/ + +static void send_spoolss_event_notification(PRINTER_MESSAGE_INFO *msg) +{ + Printer_entry *find_printer; + NTSTATUS result; + WERROR wresult; + NT_PRINTER_INFO_LEVEL *printer = NULL; + + if (!msg) { + DEBUG(0,("send_spoolss_event_notification: NULL msg pointer!\n")); + return; + } - /* Iterate the printer list */ for(find_printer = printers_list; find_printer; find_printer = find_printer->next) { /* - * If the entry has a connected client we send the message. + * If the entry has a connected client we send the message. There should + * only be one of these normally when dealing with the NT/2k spooler. + * However, iterate over all to make sure we deal with user applications + * in addition to spooler service. + * + * While we are only maintaining a single connection to the client, + * the FindFirstPrinterChangeNotification() call is made on a printer + * handle, so "client_connected" represents the whether or not the + * client asked for change notication on this handle. + * + * --jerry */ if (find_printer->notify.client_connected==True) { - DEBUG(10,("srv_spoolss_receive_message: printerserver [%s]\n", find_printer->dev.printerservername )); - if (*printer_name && !strequal(printer_name, find_printer->dev.handlename)) { - DEBUG(10,("srv_spoolss_receive_message: ignoring message sent to %s [%s]\n", - printer_name, find_printer->dev.handlename )); + + /* does the client care about what changed? */ + + if (msg->flags && !is_client_monitoring_event(find_printer, msg->flags)) { + DEBUG(10,("send_spoolss_event_notification: Client [%s] not monitoring these events\n", + find_printer->client.machine)); continue; } - if (cli_spoolss_reply_rrpcn(&cli, &find_printer->notify.client_hnd, low, high, &status)) - DEBUG(10,("srv_spoolss_receive_message: cli_spoolss_reply_rrpcn status = 0x%x\n", - (unsigned int)W_ERROR_V(status))); + if (find_printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + DEBUG(10,("send_spoolss_event_notification: printserver [%s]\n", find_printer->dev.printerservername )); else - DEBUG(10,("srv_spoolss_receive_message: cli_spoolss_reply_rrpcn failed\n")); + DEBUG(10,("send_spoolss_event_notification: printer [%s]\n", find_printer->dev.handlename)); + + /* + * if handle is a printer, only send if the printer_name matches. + * ...else if handle is a printerserver, send to all + */ + + if (*msg->printer_name && (find_printer->printer_type==PRINTER_HANDLE_IS_PRINTER) + && !strequal(msg->printer_name, find_printer->dev.handlename)) + { + DEBUG(10,("send_spoolss_event_notification: ignoring message sent to %s [%s]\n", + msg->printer_name, find_printer->dev.handlename )); + continue; + } + + + /* lookup the printer if we have a name if we don't already have a + valid NT_PRINTER_INFO_LEVEL structure. And yes I'm assuming we + will always have a non-empty msg.printer_name */ + + if (!printer || !printer->info_2 || strcmp(msg->printer_name, printer->info_2->printername)) + { + + if (printer) { + free_a_printer(&printer, 2); + printer = NULL; + } + + wresult = get_a_printer(&printer, 2, msg->printer_name); + if (! W_ERROR_IS_OK(wresult)) + continue; + } + + /* issue the client call */ + + result = srv_spoolss_send_event_to_client(find_printer, &cli, msg, printer); + + if (!NT_STATUS_IS_OK(result)) { + DEBUG(10,("send_spoolss_event_notification: Event notification failed [%s]\n", + get_nt_error_msg(result))); } } } + return; +} +/*************************************************************************** + Receive the notify message and decode the message. Do not send + notification if we sent this originally as that would result in + duplicates. +****************************************************************************/ + +static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) +{ + PRINTER_MESSAGE_INFO msg; + pid_t my_pid = sys_getpid(); + + if (len < sizeof(msg)) { + DEBUG(2,("srv_spoolss_receive_message: got incorrect message size (%u)!\n", (unsigned int)len)); + return; + } + + memcpy(&msg, buf, sizeof(PRINTER_MESSAGE_INFO)); + + if (my_pid == src) { + DEBUG(10,("srv_spoolss_receive_message: Skipping message to myself\n")); + return; + } + + DEBUG(10,("srv_spoolss_receive_message: Got message printer change [queue = %s] low=0x%x high=0x%x flags=0x%x\n", + msg.printer_name, (unsigned int)msg.low, (unsigned int)msg.high, msg.flags )); + + /* Iterate the printer list */ + + send_spoolss_event_notification(&msg); + +} + /*************************************************************************** Send a notify event. ****************************************************************************/ -static BOOL srv_spoolss_sendnotify(uint32 high, uint32 low) +static BOOL srv_spoolss_sendnotify(char* printer_name, uint32 high, uint32 low, uint32 flags) { - char msg[10]; + char msg[sizeof(PRINTER_MESSAGE_INFO)]; + PRINTER_MESSAGE_INFO info; + + ZERO_STRUCT(info); - ZERO_STRUCT(msg); - SIVAL(msg,0,low); - SIVAL(msg,4,high); - DEBUG(10,("srv_spoolss_sendnotify: printer change low=0x%x high=0x%x\n", low, high)); + info.low = low; + info.high = high; + info.flags = flags; + fstrcpy(info.printer_name, printer_name); + + memcpy(msg, &info, sizeof(PRINTER_MESSAGE_INFO)); + + DEBUG(10,("srv_spoolss_sendnotify: printer change low=0x%x high=0x%x [%s], flags=0x%x\n", + low, high, printer_name, flags)); + + message_send_all(conn_tdb_ctx(), MSG_PRINTER_NOTIFY, msg, sizeof(PRINTER_MESSAGE_INFO), + False, NULL); - message_send_all(conn_tdb_ctx(), MSG_PRINTER_NOTIFY, msg, sizeof(msg), False, NULL); return True; } @@ -707,6 +875,8 @@ Can't find printer handle we created for priunter %s\n", name )); if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; + se_map_standard(&printer_default->access_required, &printer_std_mapping); + /* map an empty access mask to the minimum access mask */ if (printer_default->access_required == 0x0) printer_default->access_required = PRINTER_ACCESS_USE; @@ -993,10 +1163,10 @@ WERROR _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL result = delete_printer_handle(p, handle); - update_c_setprinter(FALSE); + update_c_setprinter(False); if (W_ERROR_IS_OK(result)) { - srv_spoolss_sendnotify(0, PRINTER_CHANGE_DELETE_PRINTER); + srv_spoolss_sendnotify(Printer->dev.handlename, 0, PRINTER_CHANGE_DELETE_PRINTER, 0x0); } return result; @@ -1294,7 +1464,7 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle) { - WERROR status; + NTSTATUS result; /* * If it's the first connection, contact the client @@ -1313,10 +1483,10 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin smb_connections++; - if(!cli_spoolss_reply_open_printer(&cli, printer, localprinter, type, &status, handle)) - return False; + result = cli_spoolss_reply_open_printer(&cli, cli.mem_ctx, printer, localprinter, + type, handle); - return True; + return (NT_STATUS_IS_OK(result)); } /******************************************************************** @@ -1364,7 +1534,9 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE if(srv_spoolss_replyopenprinter(Printer->notify.localmachine, Printer->notify.printerlocal, 1, &Printer->notify.client_hnd)) + { Printer->notify.client_connected=True; + } return WERR_OK; } @@ -1373,7 +1545,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE * fill a notify_info_data with the servername ********************************************************************/ -static void spoolss_notify_server_name(int snum, +void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -1401,7 +1573,7 @@ static void spoolss_notify_server_name(int snum, * fill a notify_info_data with the printername (not including the servername). ********************************************************************/ -static void spoolss_notify_printer_name(int snum, +void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -1436,7 +1608,7 @@ static void spoolss_notify_printer_name(int snum, * fill a notify_info_data with the servicename ********************************************************************/ -static void spoolss_notify_share_name(int snum, +void spoolss_notify_share_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -1462,7 +1634,7 @@ static void spoolss_notify_share_name(int snum, * fill a notify_info_data with the port name ********************************************************************/ -static void spoolss_notify_port_name(int snum, +void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -1488,11 +1660,10 @@ static void spoolss_notify_port_name(int snum, /******************************************************************* * fill a notify_info_data with the printername - * jfmxxxx: it's incorrect, should be lp_printerdrivername() * but it doesn't exist, have to see what to do ********************************************************************/ -static void spoolss_notify_driver_name(int snum, +void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -1517,7 +1688,7 @@ static void spoolss_notify_driver_name(int snum, * fill a notify_info_data with the comment ********************************************************************/ -static void spoolss_notify_comment(int snum, +void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -1544,11 +1715,10 @@ static void spoolss_notify_comment(int snum, /******************************************************************* * fill a notify_info_data with the comment - * jfm:xxxx incorrect, have to create a new smb.conf option * location = "Room 1, floor 2, building 3" ********************************************************************/ -static void spoolss_notify_location(int snum, +void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -1585,11 +1755,9 @@ static void spoolss_notify_devmode(int snum, /******************************************************************* * fill a notify_info_data with the separator file name - * jfm:xxxx just return no file could add an option to smb.conf - * separator file = "separator.txt" ********************************************************************/ -static void spoolss_notify_sepfile(int snum, +void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -1616,7 +1784,7 @@ static void spoolss_notify_sepfile(int snum, * jfm:xxxx return always winprint to indicate we don't do anything to it ********************************************************************/ -static void spoolss_notify_print_processor(int snum, +void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -1643,7 +1811,7 @@ static void spoolss_notify_print_processor(int snum, * jfm:xxxx send an empty string ********************************************************************/ -static void spoolss_notify_parameters(int snum, +void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -1670,7 +1838,7 @@ static void spoolss_notify_parameters(int snum, * jfm:xxxx always send RAW as data type ********************************************************************/ -static void spoolss_notify_datatype(int snum, +void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -1713,7 +1881,7 @@ static void spoolss_notify_security_desc(int snum, * jfm:xxxx a samba printer is always shared ********************************************************************/ -static void spoolss_notify_attributes(int snum, +void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -1800,7 +1968,7 @@ static void spoolss_notify_status(int snum, * fill a notify_info_data with the number of jobs queued ********************************************************************/ -static void spoolss_notify_cjobs(int snum, +void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -1839,7 +2007,7 @@ static void spoolss_notify_username(int snum, pstring temp; uint32 len; - len = rpcstr_push(temp, queue->user, sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push(temp, queue->fs_user, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -1879,7 +2047,7 @@ static void spoolss_notify_job_name(int snum, pstring temp; uint32 len; - len = rpcstr_push(temp, queue->file, sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push(temp, queue->fs_file, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len / 2 - 1; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -2169,7 +2337,7 @@ static int search_notify(uint16 type, uint16 field, int *value) /**************************************************************************** ****************************************************************************/ -static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 field, int id) +void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 field, int id) { info_data->type = type; info_data->field = field; @@ -2397,7 +2565,7 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY return WERR_BADFID; option=Printer->notify.option; - id=0xffffffff; + id = 0x0; info->version=2; info->data=NULL; info->count=0; @@ -2585,8 +2753,13 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) printer->global_counter = global_counter; printer->total_pages = 0; +#if 0 /* JERRY */ printer->major_version = 0x0004; /* NT 4 */ printer->build_version = 0x0565; /* build 1381 */ +#else + printer->major_version = 0x0005; /* NT 5 */ + printer->build_version = 0x0893; /* build 2195 */ +#endif printer->unknown7 = 0x1; printer->unknown8 = 0x0; printer->unknown9 = 0x0; @@ -4362,9 +4535,9 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) /* we force some elements to "correct" values */ slprintf(info->servername, sizeof(info->servername)-1, "\\\\%s", get_called_name()); - slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s", - get_called_name(), lp_servicename(snum)); fstrcpy(info->sharename, lp_servicename(snum)); + slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s", + get_called_name(), info->sharename); info->attributes = PRINTER_ATTRIBUTE_SHARED | PRINTER_ATTRIBUTE_NETWORK; return True; @@ -4686,10 +4859,13 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, int snum; NT_PRINTER_INFO_LEVEL *printer = NULL, *old_printer = NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + PRINTER_MESSAGE_INFO msg; WERROR result; DEBUG(8,("update_printer\n")); + ZERO_STRUCT(msg); + result = WERR_OK; if (level!=2) { @@ -4802,18 +4978,49 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, * lookup previously saved driver initialization info, which is then * bound to the printer, simulating what happens in the Windows arch. */ - if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)) + if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)){ set_driver_init(printer, 2); + msg.flags |= PRINTER_MESSAGE_DRIVER; + } } /* Update printer info */ result = mod_a_printer(*printer, 2); + /* flag which changes actually occured. This is a small subset of + all the possible changes */ + + if (!strequal(printer->info_2->comment, old_printer->info_2->comment)) + msg.flags |= PRINTER_MESSAGE_COMMENT; + + if (!strequal(printer->info_2->sharename, old_printer->info_2->sharename)) + msg.flags |= PRINTER_MESSAGE_SHARENAME; + + if (!strequal(printer->info_2->portname, old_printer->info_2->portname)) + msg.flags |= PRINTER_MESSAGE_PORT; + + if (!strequal(printer->info_2->location, old_printer->info_2->location)) + msg.flags |= PRINTER_MESSAGE_LOCATION; + + ZERO_STRUCT(msg); + + msg.low = PRINTER_CHANGE_ADD_PRINTER; + fstrcpy(msg.printer_name, printer->info_2->printername); + + /* only send a notify if something changed */ + if (msg.flags) + { + /* send to myself before replying to SetPrinter() */ + send_spoolss_event_notification(&msg); + + /* send to other smbd's */ + srv_spoolss_sendnotify(msg.printer_name, 0, PRINTER_CHANGE_ADD_PRINTER, msg.flags); + } + done: free_a_printer(&printer, 2); free_a_printer(&old_printer, 2); - srv_spoolss_sendnotify(0, PRINTER_CHANGE_SET_PRINTER); return result; } @@ -4910,8 +5117,8 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, job_info->jobid=queue->job; init_unistr(&job_info->printername, lp_servicename(snum)); init_unistr(&job_info->machinename, temp_name); - init_unistr(&job_info->username, queue->user); - init_unistr(&job_info->document, queue->file); + init_unistr(&job_info->username, queue->fs_user); + init_unistr(&job_info->document, queue->fs_file); init_unistr(&job_info->datatype, "RAW"); init_unistr(&job_info->text_status, ""); job_info->status=nt_printj_status(queue->status); @@ -4945,9 +5152,9 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, init_unistr(&job_info->printername, chaine); init_unistr(&job_info->machinename, temp_name); - init_unistr(&job_info->username, queue->user); - init_unistr(&job_info->document, queue->file); - init_unistr(&job_info->notifyname, queue->user); + init_unistr(&job_info->username, queue->fs_user); + init_unistr(&job_info->document, queue->fs_file); + init_unistr(&job_info->notifyname, queue->fs_user); init_unistr(&job_info->datatype, "RAW"); init_unistr(&job_info->printprocessor, "winprint"); init_unistr(&job_info->parameters, ""); @@ -5070,6 +5277,7 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, } if (!alloc_buffer_size(buffer, *needed)) { + SAFE_FREE(info); result = WERR_INSUFFICIENT_BUFFER; goto done; } @@ -6031,11 +6239,12 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ return WERR_ACCESS_DENIED; } + srv_spoolss_sendnotify(printer->info_2->printername, 0, PRINTER_CHANGE_ADD_PRINTER, 0x0); + free_a_printer(&printer,2); update_c_setprinter(False); - srv_spoolss_sendnotify(0, PRINTER_CHANGE_ADD_PRINTER); return WERR_OK; } @@ -6128,9 +6337,7 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen pstring long_archi; pstring short_archi; DRIVER_DIRECTORY_1 *info=NULL; -#if 0 - fstring asc_name, servername; -#endif + unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); if (get_short_archi(short_archi, long_archi)==False) @@ -6139,20 +6346,6 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen if((info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1))) == NULL) return WERR_NOMEM; -#if 0 /* JERRY */ - /* use the name the client sent us */ - - unistr2_to_ascii(asc_name, name, sizeof(asc_name)-1); - if (asc_name[0] == '\\' && asc_name[1] == '\\') - fstrcpy(servername, asc_name); - else { - fstrcpy(servername, "\\\\"); - fstrcat(servername, asc_name); - } - - slprintf(path, sizeof(path)-1, "%s\\print$\\%s", servername, short_archi); -#endif - slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", get_called_name(), short_archi); DEBUG(4,("printer driver directory: [%s]\n", path)); @@ -6428,24 +6621,6 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP convert_specific_param(¶m, value , type, data, real_len); -#if 0 - /* JRA. W2K always changes changeid. */ - - if (get_specific_param(*printer, 2, param->value, &old_param.data, - &old_param.type, (uint32 *)&old_param.data_len)) { - - if (param->type == old_param.type && - param->data_len == old_param.data_len && - memcmp(param->data, old_param.data, - old_param.data_len) == 0) { - - DEBUG(3, ("setprinterdata hasn't changed\n")); - status = WERR_OK; - goto done; - } - } -#endif - unlink_specific_param_if_exist(printer->info_2, param); /* @@ -6470,17 +6645,18 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP free_nt_printer_param(¶m); SAFE_FREE(old_param.data); -#if 0 - /* Is this correct. JRA ? */ - srv_spoolss_sendnotify(0, PRINTER_CHANGE_SET_PRINTER); -#endif - return status; } /**************************************************************************** ****************************************************************************/ +WERROR _spoolss_resetprinter(pipes_struct *p, SPOOL_Q_RESETPRINTER *q_u, SPOOL_R_RESETPRINTER *r_u) +{ + return WERR_OK; +} + + WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_u, SPOOL_R_DELETEPRINTERDATA *r_u) { POLICY_HND *handle = &q_u->handle; @@ -7025,7 +7201,6 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin ret = get_a_printer(&ntprinter, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(ret)) goto done; - if (construct_dev_mode(snum) == NULL) { ret = WERR_NOMEM; goto done; @@ -7371,27 +7546,6 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ enum_values[num_entries].value_len = (strlen(value)+1) * 2; enum_values[num_entries].type = type; -#if 0 /* JERRY - I think think was a bad assumption based on bad - offset values when I first implemented it. Commented out. - We should not be adding an extra NULL to the end of a string - just send what the client set in the first place. */ - /* - * NULL terminate REG_SZ - * FIXME!!! We should not be correctly problems in the way - * we store PrinterData here. Need to investogate - * SetPrinterData[Ex] --jerry - */ - - if (type == REG_SZ) { - /* fix alignment if the string was stored - in a bizarre fashion */ - if ((data_len % 2) == 0) - add_len = 2; - else - add_len = data_len % 2; - } -#endif - if (!(enum_values[num_entries].data=talloc_zero(p->mem_ctx, data_len+add_len))) { DEBUG(0,("talloc_realloc failed to allocate more memory for data!\n")); result = WERR_NOMEM; @@ -7433,11 +7587,6 @@ done: /**************************************************************************** ****************************************************************************/ -/* Disabled because it doesn't fix the bug I am looking at but it would be - a shame to throw away the code. -tpot */ - -#if 0 - static void fill_printprocessordirectory_1(PRINTPROCESSOR_DIRECTORY_1 *info, char *name) { init_unistr(&info->name, name); @@ -7515,4 +7664,3 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC return WERR_ACCESS_DENIED; } -#endif -- cgit From ab13654dc9ac23872e4d1384e1c54e336f113009 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 17 Mar 2002 04:36:35 +0000 Subject: Renamed get_nt_error_msg() to nt_errstr(). (This used to be commit 1f007d3ed41c1b71a89fa6be7d173e67e927c302) --- source3/rpc_server/srv_netlog_nt.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 92ebfd97c5..5b9c136253 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -634,7 +634,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * free_user_info(&user_info); DEBUG(5, ("_net_sam_logon: check_password returned status %s\n", - get_nt_error_msg(status))); + nt_errstr(status))); /* Check account and password */ diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a6c0f9368c..a861aa1905 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -698,7 +698,7 @@ static void send_spoolss_event_notification(PRINTER_MESSAGE_INFO *msg) if (!NT_STATUS_IS_OK(result)) { DEBUG(10,("send_spoolss_event_notification: Event notification failed [%s]\n", - get_nt_error_msg(result))); + nt_errstr(result))); } } } -- cgit From a4cce223d6873400b053872a6e3b2eb8621eea45 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 17 Mar 2002 06:04:15 +0000 Subject: Added dos_errstr() function. Not all errors in list yet. (This used to be commit ddb5753e36b8c5efb48ce5c82c16d970fb8e76b6) --- source3/rpc_server/srv_spoolss_nt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a861aa1905..850d428165 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3858,12 +3858,12 @@ static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst ZERO_STRUCT(driver); status=get_a_printer(&printer, 2, lp_servicename(snum) ); - DEBUG(8,("construct_printer_driver_info_3: status: %s\n", werror_str(status))); + DEBUG(8,("construct_printer_driver_info_3: status: %s\n", dos_errstr(status))); if (!W_ERROR_IS_OK(status)) return WERR_INVALID_PRINTER_NAME; status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); - DEBUG(8,("construct_printer_driver_info_3: status: %s\n", werror_str(status))); + DEBUG(8,("construct_printer_driver_info_3: status: %s\n", dos_errstr(status))); #if 0 /* JERRY */ @@ -3883,7 +3883,7 @@ static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst /* Yes - try again with a WinNT driver. */ version = 2; status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); - DEBUG(8,("construct_printer_driver_info_3: status: %s\n", werror_str(status))); + DEBUG(8,("construct_printer_driver_info_3: status: %s\n", dos_errstr(status))); } #endif @@ -3981,12 +3981,12 @@ static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fst ZERO_STRUCT(driver); status=get_a_printer(&printer, 2, lp_servicename(snum) ); - DEBUG(8,("construct_printer_driver_info_6: status: %s\n", werror_str(status))); + DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status))); if (!W_ERROR_IS_OK(status)) return WERR_INVALID_PRINTER_NAME; status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); - DEBUG(8,("construct_printer_driver_info_6: status: %s\n", werror_str(status))); + DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status))); if (!W_ERROR_IS_OK(status)) { /* * Is this a W2k client ? @@ -4000,7 +4000,7 @@ static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fst /* Yes - try again with a WinNT driver. */ version = 2; status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); - DEBUG(8,("construct_printer_driver_info_6: status: %s\n", werror_str(status))); + DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status))); if (!W_ERROR_IS_OK(status)) { free_a_printer(&printer,2); return WERR_UNKNOWN_PRINTER_DRIVER; @@ -5957,7 +5957,7 @@ static WERROR 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 WERR_NOMEM [%s]\n", - werror_str(WERR_NOMEM))); + dos_errstr(WERR_NOMEM))); file_lines_free(qlines); return WERR_NOMEM; } -- cgit From 32334bc6553c25b706e60a321f9c16f8931f94c1 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 18 Mar 2002 23:57:14 +0000 Subject: more verbose checking in talloc and util_pw fixed tdbsam memory corruption (and segfault) reducing calls to pdb_uid_to_user_rid and countrary to 0 to move to a non alghoritmic rid allocation with some passdb modules. (This used to be commit 9836af7cd623357feaec07bc49cfb78f0aa01fc3) --- source3/rpc_server/srv_samr_nt.c | 44 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index eb8ec16f45..542e4796c2 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2835,6 +2835,9 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD fstring grp_name; uint32 rid; GROUP_MAP map; + NTSTATUS ret; + SAM_ACCOUNT *sam_user; + BOOL check; /* Find the policy handle. Open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid)) @@ -2859,7 +2862,23 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD } sid_split_rid(&q_u->sid.sid, &rid); - uid=pdb_user_rid_to_uid(rid); + + ret = pdb_init_sam(&sam_user); + if (NT_STATUS_IS_ERR(ret)) + return ret; + + become_root(); + check = pdb_getsampwrid(sam_user, rid); + unbecome_root(); + + if (check != True) + return NT_STATUS_NO_SUCH_USER; + + uid = pdb_get_uid(sam_user); + if (uid == -1) + return NT_STATUS_NO_SUCH_USER; + + pdb_free_sam(&sam_user); if ((pwd=getpwuid(uid)) == NULL) return NT_STATUS_NO_SUCH_USER; @@ -2963,6 +2982,10 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD struct group *grp; fstring grp_name; GROUP_MAP map; + uid_t uid; + NTSTATUS ret; + SAM_ACCOUNT *sam_user; + BOOL check; /* Find the policy handle. Open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) @@ -2979,7 +3002,24 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_GROUP; - if ((pwd=getpwuid(pdb_user_rid_to_uid(q_u->rid))) ==NULL) + ret = pdb_init_sam(&sam_user); + if (NT_STATUS_IS_ERR(ret)) + return ret; + + become_root(); + check = pdb_getsampwrid(sam_user, q_u->rid); + unbecome_root(); + + if (check != True) + return NT_STATUS_NO_SUCH_USER; + + uid = pdb_get_uid(sam_user); + if (uid == -1) + return NT_STATUS_NO_SUCH_USER; + + pdb_free_sam(&sam_user); + + if ((pwd=getpwuid(uid)) == NULL) return NT_STATUS_NO_SUCH_USER; if ((grp=getgrgid(map.gid)) == NULL) -- cgit From 72eb7dbd40b4faf3438951c297fb1fbf6f9011ac Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 19 Mar 2002 02:35:12 +0000 Subject: Merge in JohnR's page count fixes. Jeremy. (This used to be commit 2e3133fbe5531b9bbc9bf46a04b27fa58e555f5a) --- source3/rpc_server/srv_spoolss_nt.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 850d428165..e351f125bf 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2138,6 +2138,32 @@ static void spoolss_notify_job_size(int snum, data->notify_data.value[1]=0; } +/******************************************************************* + * fill a notify_info_data with page info + ********************************************************************/ +static void spoolss_notify_total_pages(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) +{ + data->notify_data.value[0]=queue->page_count; + data->notify_data.value[1]=0; +} + +/******************************************************************* + * fill a notify_info_data with pages printed info. + ********************************************************************/ +static void spoolss_notify_pages_printed(int snum, + SPOOL_NOTIFY_INFO_DATA *data, + print_queue_struct *queue, + NT_PRINTER_INFO_LEVEL *printer, + TALLOC_CTX *mem_ctx) +{ + data->notify_data.value[0]=0; /* Add code when back-end tracks this */ + data->notify_data.value[1]=0; +} + /******************************************************************* Fill a notify_info_data with job position. ********************************************************************/ @@ -2258,8 +2284,8 @@ struct s_notify_info_data_table notify_info_data_table[] = { JOB_NOTIFY_TYPE, JOB_NOTIFY_START_TIME, "JOB_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_UNTIL_TIME, "JOB_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_TIME, "JOB_NOTIFY_TIME", ONE_VALUE, spoolss_notify_job_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", ONE_VALUE, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", ONE_VALUE, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", ONE_VALUE, spoolss_notify_total_pages }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", ONE_VALUE, spoolss_notify_pages_printed }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_BYTES, "JOB_NOTIFY_TOTAL_BYTES", ONE_VALUE, spoolss_notify_job_size }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_BYTES_PRINTED, "JOB_NOTIFY_BYTES_PRINTED", ONE_VALUE, NULL }, { END, END, "", END, NULL } @@ -4256,6 +4282,7 @@ WERROR _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPO } Printer->page_started=False; + print_job_endpage(Printer->jobid); return WERR_OK; } @@ -5124,7 +5151,7 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, job_info->status=nt_printj_status(queue->status); job_info->priority=queue->priority; job_info->position=position; - job_info->totalpages=0; + job_info->totalpages=queue->page_count; job_info->pagesprinted=0; make_systemtime(&job_info->submitted, t); @@ -5168,7 +5195,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, job_info->position=position; job_info->starttime=0; job_info->untiltime=0; - job_info->totalpages=0; + job_info->totalpages=queue->page_count; job_info->size=queue->size; make_systemtime(&(job_info->submitted), t); job_info->timeelapsed=0; -- cgit From 050b80356edea52f1bbb0a27599186ad84c18b73 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 19 Mar 2002 13:57:53 +0000 Subject: second step to gain free uid<->rid mapping we still need to free gid<->rid mapping and few other stuff (This used to be commit aa4b6f8181f34196a28951264dd8b631a5deef7f) --- source3/rpc_server/srv_samr_nt.c | 92 +++++++++++++++++++++++++++++++++++----- 1 file changed, 82 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 542e4796c2..d6aea7cd63 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2719,6 +2719,8 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ fstring alias_sid_str; DOM_SID temp_sid; + SAM_ACCOUNT *sam_user; + BOOL check; /* find the policy handle. open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid)) @@ -2751,8 +2753,40 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ return NT_STATUS_NO_MEMORY; for (i = 0; i < num_uids; i++) { + struct passwd *pass; + uint32 rid; + sid_copy(&temp_sid, &global_sam_sid); - sid_append_rid(&temp_sid, pdb_uid_to_user_rid(uid[i])); + + pass = getpwuid_alloc(uid[i]); + if (!pass) continue; + + if (NT_STATUS_IS_ERR(pdb_init_sam(&sam_user))) { + passwd_free(&pass); + continue; + } + + become_root(); + check = pdb_getsampwnam(sam_user, pass->pw_name); + unbecome_root(); + + if (check != True) { + pdb_free_sam(&sam_user); + passwd_free(&pass); + continue; + } + + rid = pdb_get_user_rid(sam_user); + if (rid == 0) { + pdb_free_sam(&sam_user); + passwd_free(&pass); + continue; + } + + pdb_free_sam(&sam_user); + passwd_free(&pass); + + sid_append_rid(&temp_sid, rid); init_dom_sid2(&sid[i], &temp_sid); } @@ -2781,6 +2815,9 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ uint32 *rid=NULL; uint32 *attr=NULL; + SAM_ACCOUNT *sam_user; + BOOL check; + /* find the policy handle. open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid)) @@ -2812,7 +2849,38 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ return NT_STATUS_NO_MEMORY; for (i=0; ipw_name); + unbecome_root(); + + if (check != True) { + pdb_free_sam(&sam_user); + passwd_free(&pass); + continue; + } + + urid = pdb_get_user_rid(sam_user); + if (urid == 0) { + pdb_free_sam(&sam_user); + passwd_free(&pass); + continue; + } + + pdb_free_sam(&sam_user); + passwd_free(&pass); + + rid[i] = urid; attr[i] = SID_NAME_USER; } @@ -2867,16 +2935,18 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD if (NT_STATUS_IS_ERR(ret)) return ret; - become_root(); check = pdb_getsampwrid(sam_user, rid); - unbecome_root(); - if (check != True) + if (check != True) { + pdb_free_sam(&sam_user); return NT_STATUS_NO_SUCH_USER; + } uid = pdb_get_uid(sam_user); - if (uid == -1) + if (uid == -1) { + pdb_free_sam(&sam_user); return NT_STATUS_NO_SUCH_USER; + } pdb_free_sam(&sam_user); @@ -3006,16 +3076,18 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD if (NT_STATUS_IS_ERR(ret)) return ret; - become_root(); check = pdb_getsampwrid(sam_user, q_u->rid); - unbecome_root(); - if (check != True) + if (check != True) { + pdb_free_sam(&sam_user); return NT_STATUS_NO_SUCH_USER; + } uid = pdb_get_uid(sam_user); - if (uid == -1) + if (uid == -1) { + pdb_free_sam(&sam_user); return NT_STATUS_NO_SUCH_USER; + } pdb_free_sam(&sam_user); -- cgit From 0cd5dd67ce12f02d3d20568e901ef7666caa8472 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 20 Mar 2002 00:24:35 +0000 Subject: Merge from app-head: > Don't put two copies of the server name in construct_printer_info_1() (This used to be commit 47b1003bc5a069e84cb20df507022e5ff3e93832) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e351f125bf..c4a2334c16 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2832,12 +2832,12 @@ static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int if (*ntprinter->info_2->comment == '\0') { init_unistr(&printer->comment, lp_comment(snum)); - slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",get_called_name(), ntprinter->info_2->printername, + slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s", ntprinter->info_2->printername, ntprinter->info_2->drivername, lp_comment(snum)); } else { init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ - slprintf(chaine,sizeof(chaine)-1,"%s%s,%s,%s",get_called_name(), ntprinter->info_2->printername, + slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s", ntprinter->info_2->printername, ntprinter->info_2->drivername, ntprinter->info_2->comment); } -- cgit From 826f3fb86b954b29b4f152d8785860a227798975 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 20 Mar 2002 03:37:27 +0000 Subject: resetprinter merge from SAMBA_2_2 (This used to be commit 88d8897e21749f177952b264031aa386bbbeaaeb) --- source3/rpc_server/srv_spoolss_nt.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c4a2334c16..b23cbaa9ae 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6680,6 +6680,28 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP WERROR _spoolss_resetprinter(pipes_struct *p, SPOOL_Q_RESETPRINTER *q_u, SPOOL_R_RESETPRINTER *r_u) { + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); + int snum; + + DEBUG(5,("_spoolss_resetprinter\n")); + + /* + * All we do is to check to see if the handle and queue is valid. + * This call really doesn't mean anything to us because we only + * support RAW printing. --jerry + */ + + if (!Printer) { + DEBUG(2,("_spoolss_resetprinter: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); + return WERR_BADFID; + } + + if (!get_printer_snum(p,handle, &snum)) + return WERR_BADFID; + + + /* blindly return success */ return WERR_OK; } -- cgit From 9529a4827c203eb4e42a166e6d2c1281e73b4254 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 20 Mar 2002 23:09:34 +0000 Subject: merge from APPLIANCE_HEAD (This used to be commit 9282aa02d44ae7a7688e8399b397aae35f73ddd1) --- source3/rpc_server/srv_spoolss_nt.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b23cbaa9ae..8e3ada5a8d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -714,7 +714,6 @@ static void send_spoolss_event_notification(PRINTER_MESSAGE_INFO *msg) static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) { PRINTER_MESSAGE_INFO msg; - pid_t my_pid = sys_getpid(); if (len < sizeof(msg)) { DEBUG(2,("srv_spoolss_receive_message: got incorrect message size (%u)!\n", (unsigned int)len)); @@ -723,11 +722,6 @@ static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size memcpy(&msg, buf, sizeof(PRINTER_MESSAGE_INFO)); - if (my_pid == src) { - DEBUG(10,("srv_spoolss_receive_message: Skipping message to myself\n")); - return; - } - DEBUG(10,("srv_spoolss_receive_message: Got message printer change [queue = %s] low=0x%x high=0x%x flags=0x%x\n", msg.printer_name, (unsigned int)msg.low, (unsigned int)msg.high, msg.flags )); @@ -5035,12 +5029,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, fstrcpy(msg.printer_name, printer->info_2->printername); /* only send a notify if something changed */ - if (msg.flags) - { - /* send to myself before replying to SetPrinter() */ - send_spoolss_event_notification(&msg); - - /* send to other smbd's */ + if (msg.flags) { srv_spoolss_sendnotify(msg.printer_name, 0, PRINTER_CHANGE_ADD_PRINTER, msg.flags); } -- cgit From 93d25c293ff1a763f275e1769cabf68058f09a4e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 21 Mar 2002 03:53:44 +0000 Subject: Make sure to initaliase SAM_ACCOUNT pointers to NULL, otherwise pdb_init_sam() fails. Andrew Bartlett (This used to be commit 56009ffbaa00259d15f286248a7ab73c55371819) --- source3/rpc_server/srv_samr_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d6aea7cd63..e47619eb74 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2719,7 +2719,7 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ fstring alias_sid_str; DOM_SID temp_sid; - SAM_ACCOUNT *sam_user; + SAM_ACCOUNT *sam_user = NULL; BOOL check; /* find the policy handle. open a policy on it. */ @@ -2815,7 +2815,7 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ uint32 *rid=NULL; uint32 *attr=NULL; - SAM_ACCOUNT *sam_user; + SAM_ACCOUNT *sam_user = NULL; BOOL check; @@ -2904,7 +2904,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD uint32 rid; GROUP_MAP map; NTSTATUS ret; - SAM_ACCOUNT *sam_user; + SAM_ACCOUNT *sam_user = NULL; BOOL check; /* Find the policy handle. Open a policy on it. */ -- cgit From ce236d1dbf2673e2ff921683554cee41fca33249 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 22 Mar 2002 06:24:38 +0000 Subject: Stomped on some header file version numbers that have crept back in. (This used to be commit e66bdf1229ba84f64c19e817e2c4081dbbf0bee8) --- source3/rpc_server/srv_spoolss_nt.c | 3 +-- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8e3ada5a8d..717e51462b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1,6 +1,5 @@ /* - * Unix SMB/Netbios implementation. - * Version 1.9. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 09f33b9a88..db94b8dc94 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1,5 +1,5 @@ /* - * Unix SMB/Netbios implementation. + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Jeremy Allison 2001. -- cgit From c90cd26e9430b2fc065f620bdb6aaf4be0372fcc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 23 Mar 2002 02:57:44 +0000 Subject: Fix the mp3 rename bug - also tidy up our open code and remove the special cases for rename and unlink. Had to add desired_access into the share mode record. Jeremy. (This used to be commit 3b1b8ac43535fb0839c5474fa55bf7150f6cde31) --- source3/rpc_server/srv_srvsvc_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index db94b8dc94..cfd4a0bf1f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1628,7 +1628,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC if (!fsp) { /* Perhaps it is a directory */ if (errno == EISDIR) - fsp = open_directory(conn, filename, &st,0, + fsp = open_directory(conn, filename, &st,FILE_READ_ATTRIBUTES,0, (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); if (!fsp) { @@ -1733,7 +1733,7 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ if (!fsp) { /* Perhaps it is a directory */ if (errno == EISDIR) - fsp = open_directory(conn, filename, &st,0, + fsp = open_directory(conn, filename, &st,FILE_READ_ATTRIBUTES,0, (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); if (!fsp) { -- cgit From 737423f06ea08c38592b408faa12a55a95b9d696 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 26 Mar 2002 03:15:30 +0000 Subject: OpenPrinter() merge from 2.2 (This used to be commit 619397cc90549d4602ecddc25ee50eb247c913ee) --- source3/rpc_server/srv_spoolss.c | 31 +++++++++ source3/rpc_server/srv_spoolss_nt.c | 132 ++++++++++++++++++++++++++++++++++-- 2 files changed, 156 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 3838632021..e6c152c668 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -23,6 +23,36 @@ #include "includes.h" +/******************************************************************** + * api_spoolss_open_printer_ex (rarely seen - older call) + ********************************************************************/ + +static BOOL api_spoolss_open_printer(pipes_struct *p) +{ + SPOOL_Q_OPEN_PRINTER q_u; + SPOOL_R_OPEN_PRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!spoolss_io_q_open_printer("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_open_printer: unable to unmarshall SPOOL_Q_OPEN_PRINTER.\n")); + return False; + } + + r_u.status = _spoolss_open_printer( p, &q_u, &r_u); + + if (!spoolss_io_r_open_printer("",&r_u,rdata,0)){ + DEBUG(0,("spoolss_io_r_open_printer: unable to marshall SPOOL_R_OPEN_PRINTER.\n")); + return False; + } + + return True; +} + + /******************************************************************** * api_spoolss_open_printer_ex ********************************************************************/ @@ -1375,6 +1405,7 @@ static BOOL api_spoolss_getprintprocessordirectory(pipes_struct *p) struct api_struct api_spoolss_cmds[] = { + {"SPOOLSS_OPENPRINTER", SPOOLSS_OPENPRINTER, api_spoolss_open_printer }, {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex }, {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata }, {"SPOOLSS_CLOSEPRINTER", SPOOLSS_CLOSEPRINTER, api_spoolss_closeprinter }, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 717e51462b..e119825f31 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -757,18 +757,137 @@ static BOOL srv_spoolss_sendnotify(char* printer_name, uint32 high, uint32 low, return True; } +/******************************************************************** + Copy routines used by convert_to_openprinterex() + *******************************************************************/ + +static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode) +{ + DEVICEMODE *d; + int len; + + if (!devmode) + return NULL; + + DEBUG (8,("dup_devmode\n")); + + /* bulk copy first */ + + d = talloc_memdup(ctx, devmode, sizeof(DEVICEMODE)); + if (!d) + return NULL; + + /* dup the pointer members separately */ + + len = unistrlen(devmode->devicename.buffer); + if (len != -1) { + d->devicename.buffer = talloc(ctx, len*2); + if (unistrcpy(d->devicename.buffer, devmode->devicename.buffer) != len) + return NULL; + } + + + len = unistrlen(devmode->formname.buffer); + if (len != -1) { + d->devicename.buffer = talloc(ctx, len*2); + if (unistrcpy(d->formname.buffer, devmode->formname.buffer) != len) + return NULL; + } + + d->private = talloc_memdup(ctx, devmode->private, devmode->driverextra); + + return d; +} + +static void copy_devmode_ctr(TALLOC_CTX *ctx, DEVMODE_CTR *new_ctr, DEVMODE_CTR *ctr) +{ + if (!new_ctr || !ctr) + return; + + DEBUG(8,("copy_devmode_ctr\n")); + + new_ctr->size = ctr->size; + new_ctr->devmode_ptr = ctr->devmode_ptr; + + if(ctr->devmode_ptr) + new_ctr->devmode = dup_devicemode(ctx, ctr->devmode); +} + +static void copy_printer_default(TALLOC_CTX *ctx, PRINTER_DEFAULT *new_def, PRINTER_DEFAULT *def) +{ + if (!new_def || !def) + return; + + DEBUG(8,("copy_printer_defaults\n")); + + new_def->datatype_ptr = def->datatype_ptr; + + if (def->datatype_ptr) + copy_unistr2(&new_def->datatype, &def->datatype); + + copy_devmode_ctr(ctx, &new_def->devmode_cont, &def->devmode_cont); + + new_def->access_required = def->access_required; +} + +/******************************************************************** + * Convert a SPOOL_Q_OPEN_PRINTER structure to a + * SPOOL_Q_OPEN_PRINTER_EX structure + ********************************************************************/ + +static void convert_to_openprinterex(TALLOC_CTX *ctx, SPOOL_Q_OPEN_PRINTER_EX *q_u_ex, SPOOL_Q_OPEN_PRINTER *q_u) +{ + if (!q_u_ex || !q_u) + return; + + DEBUG(8,("convert_to_openprinterex\n")); + + q_u_ex->printername_ptr = q_u->printername_ptr; + + if (q_u->printername_ptr) + copy_unistr2(&q_u_ex->printername, &q_u->printername); + + copy_printer_default(ctx, &q_u_ex->printer_default, &q_u->printer_default); +} + /******************************************************************** * spoolss_open_printer * * called from the spoolss dispatcher ********************************************************************/ -WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, SPOOL_R_OPEN_PRINTER_EX *r_u) +WERROR _spoolss_open_printer(pipes_struct *p, SPOOL_Q_OPEN_PRINTER *q_u, SPOOL_R_OPEN_PRINTER *r_u) { -#if 0 - WERROR result = WERR_OK; -#endif + SPOOL_Q_OPEN_PRINTER_EX q_u_ex; + SPOOL_R_OPEN_PRINTER_EX r_u_ex; + + if (!q_u || !r_u) + return WERR_NOMEM; + + ZERO_STRUCT(q_u_ex); + ZERO_STRUCT(r_u_ex); + + /* convert the OpenPrinter() call to OpenPrinterEx() */ + + convert_to_openprinterex(p->mem_ctx, &q_u_ex, q_u); + + r_u_ex.status = _spoolss_open_printer_ex(p, &q_u_ex, &r_u_ex); + + /* convert back to OpenPrinter() */ + + memcpy(r_u, &r_u_ex, sizeof(*r_u)); + + return r_u->status; +} + +/******************************************************************** + * spoolss_open_printer + * + * called from the spoolss dispatcher + ********************************************************************/ +WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, SPOOL_R_OPEN_PRINTER_EX *r_u) +{ UNISTR2 *printername = NULL; PRINTER_DEFAULT *printer_default = &q_u->printer_default; /* uint32 user_switch = q_u->user_switch; - notused */ @@ -6254,13 +6373,12 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ return WERR_ACCESS_DENIED; } + update_c_setprinter(False); + srv_spoolss_sendnotify(printer->info_2->printername, 0, PRINTER_CHANGE_ADD_PRINTER, 0x0); free_a_printer(&printer,2); - update_c_setprinter(False); - - return WERR_OK; } -- cgit From c6cd39d4f706ac1b081c998064263c2728dbc765 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 27 Mar 2002 17:39:01 +0000 Subject: merge from SAMBA_2_2 (This used to be commit fe099006bbd1103edb5804d70743b211bbc584fb) --- source3/rpc_server/srv_netlog_nt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 5b9c136253..bdb064c81d 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -514,6 +514,12 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(usr_info); + + /* store the user information, if there is any. */ + r_u->user = usr_info; + r_u->switch_value = 0; /* indicates no info */ + r_u->auth_resp = 1; /* authoritative response */ + r_u->switch_value = 3; /* indicates type of validation user info */ if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; @@ -527,12 +533,6 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * r_u->buffer_creds = 1; /* yes, we have valid server credentials */ memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds)); - /* store the user information, if there is any. */ - r_u->user = usr_info; - r_u->switch_value = 0; /* indicates no info */ - r_u->auth_resp = 1; /* authoritative response */ - r_u->switch_value = 3; /* indicates type of validation user info */ - /* find the username */ switch (q_u->sam_id.logon_level) { -- cgit From 16c3f6c7d0c925676bbc259fde79fff3a286c77d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 28 Mar 2002 16:44:26 +0000 Subject: merge from SAMBA_2_2 (This used to be commit 606450f3cbe028a526ec6db9cea59d65324c3314) --- source3/rpc_server/srv_spoolss_nt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e119825f31..60c8fdfb7b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1561,7 +1561,12 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO *data = NULL; } - return WERR_INVALID_PARAM; + /* error depends on handle type */ + + if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + return WERR_INVALID_PARAM; + else + return WERR_BADFILE; } if (*needed > *out_size) -- cgit From 9a8b5fdd379da27f37d0960ad6125514e369a4cd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 29 Mar 2002 20:37:56 +0000 Subject: Ensure we return a parseable value if invalid handle given. Jeremy. (This used to be commit f169f3f4df81537426f708d68da44e0fc40ad15e) --- source3/rpc_server/srv_lsa_nt.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c044340456..e6fc66b672 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -574,6 +574,9 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_ LSA_TRANS_NAME_ENUM *names = NULL; uint32 mapped_count = 0; + ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); + names = (LSA_TRANS_NAME_ENUM *)talloc_zero(p->mem_ctx, sizeof(LSA_TRANS_NAME_ENUM)); + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; @@ -581,9 +584,6 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_ if (!(handle->access & POLICY_LOOKUP_NAMES)) return NT_STATUS_ACCESS_DENIED; - ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); - names = (LSA_TRANS_NAME_ENUM *)talloc_zero(p->mem_ctx, sizeof(LSA_TRANS_NAME_ENUM)); - if (!ref || !names) return NT_STATUS_NO_MEMORY; @@ -607,13 +607,6 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP DOM_RID2 *rids; uint32 mapped_count = 0; - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) - return NT_STATUS_INVALID_HANDLE; - - /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) - return NT_STATUS_ACCESS_DENIED; - if (num_entries > MAX_LOOKUP_SIDS) { num_entries = MAX_LOOKUP_SIDS; DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries)); @@ -622,6 +615,13 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); rids = (DOM_RID2 *)talloc_zero(p->mem_ctx, sizeof(DOM_RID2)*num_entries); + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) + return NT_STATUS_INVALID_HANDLE; + + /* check if the user have enough rights */ + if (!(handle->access & POLICY_LOOKUP_NAMES)) + return NT_STATUS_ACCESS_DENIED; + if (!ref || !rids) return NT_STATUS_NO_MEMORY; @@ -667,6 +667,13 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV LSA_PRIV_ENTRY *entry; LSA_PRIV_ENTRY *entries=NULL; + if (enum_context >= PRIV_ALL_INDEX) + return NT_STATUS_NO_MORE_ENTRIES; + + entries = (LSA_PRIV_ENTRY *)talloc_zero(p->mem_ctx, sizeof(LSA_PRIV_ENTRY) * (PRIV_ALL_INDEX)); + if (entries==NULL) + return NT_STATUS_NO_MEMORY; + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; @@ -678,13 +685,6 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - if (enum_context >= PRIV_ALL_INDEX) - return NT_STATUS_NO_MORE_ENTRIES; - - entries = (LSA_PRIV_ENTRY *)talloc_zero(p->mem_ctx, sizeof(LSA_PRIV_ENTRY) * (PRIV_ALL_INDEX)); - if (entries==NULL) - return NT_STATUS_NO_MEMORY; - entry = entries; DEBUG(10,("_lsa_enum_privs: enum_context:%d total entries:%d\n", enum_context, PRIV_ALL_INDEX)); -- cgit From a5dc8cb59145b400b6145b9f13231efdb7ff047c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 29 Mar 2002 21:50:21 +0000 Subject: Don't core dump listing thousands of users in usrmgr. Jeremy. (This used to be commit c6566fa5fadf37a2b133e7be1f13c0de93efab34) --- source3/rpc_server/srv_lsa_nt.c | 29 ++++++++++++++++++++--------- source3/rpc_server/srv_samr_nt.c | 4 ++-- 2 files changed, 22 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index e6fc66b672..af02a97769 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -577,16 +577,21 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_ ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); names = (LSA_TRANS_NAME_ENUM *)talloc_zero(p->mem_ctx, sizeof(LSA_TRANS_NAME_ENUM)); - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) - return NT_STATUS_INVALID_HANDLE; + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) { + r_u->status = NT_STATUS_INVALID_HANDLE; + goto done; + } /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) - return NT_STATUS_ACCESS_DENIED; - + if (!(handle->access & POLICY_LOOKUP_NAMES)) { + r_u->status = NT_STATUS_ACCESS_DENIED; + goto done; + } if (!ref || !names) return NT_STATUS_NO_MEMORY; +done: + /* set up the LSA Lookup SIDs response */ init_lsa_trans_names(p->mem_ctx, ref, names, num_entries, sid, &mapped_count); init_reply_lookup_sids(r_u, ref, names, mapped_count); @@ -615,16 +620,22 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); rids = (DOM_RID2 *)talloc_zero(p->mem_ctx, sizeof(DOM_RID2)*num_entries); - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) - return NT_STATUS_INVALID_HANDLE; + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) { + r_u->status = NT_STATUS_INVALID_HANDLE; + goto done; + } /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) - return NT_STATUS_ACCESS_DENIED; + if (!(handle->access & POLICY_LOOKUP_NAMES)) { + r_u->status = NT_STATUS_ACCESS_DENIED; + goto done; + } if (!ref || !rids) return NT_STATUS_NO_MEMORY; +done: + /* set up the LSA Lookup RIDs response */ init_lsa_rid2s(ref, rids, num_entries, names, &mapped_count, p->endian); init_reply_lookup_names(r_u, ref, num_entries, rids, mapped_count); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e47619eb74..c83f6b3d8d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -972,10 +972,10 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ } /* calculate the size and limit on the number of entries we will return */ - temp_size=(enum_context+max_entries)*struct_size; + temp_size=max_entries*struct_size; if (temp_size>max_size) { - max_entries=max_size/struct_size; + max_entries=MIN((max_size/struct_size),max_entries);; DEBUG(5, ("samr_reply_query_dispinfo: buffer size limits to only %d entries\n", max_entries)); } -- cgit From 846670fa0e280b32e70d14048c75d9af70a61225 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 30 Mar 2002 00:45:26 +0000 Subject: Hack to share pipe handles between lsa and samr pipes as NT4.x usrmgr insists on re-using an lsa handle opened on a pipe then closed - this keeps them around so long as a samr pipe is also open. Jeremy. (This used to be commit f029bd348c8c16a8774c3fb4f7f1d76470c7688f) --- source3/rpc_server/srv_lsa_hnd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 0e06a04177..84c3c5a959 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -27,6 +27,16 @@ #define MAX_OPEN_POLS 1024 #endif +/**************************************************************************** + Hack as handles need to be persisant over lsa pipe closes so long as a samr + pipe is open. JRA. +****************************************************************************/ + +static BOOL is_samr_lsa_pipe(const char *pipe_name) +{ + return (strstr(pipe_name, "samr") || strstr(pipe_name, "lsa")); +} + /**************************************************************************** Initialise a policy handle list on a pipe. Handle list is shared between all pipes of the same name. @@ -38,7 +48,8 @@ BOOL init_pipe_handle_list(pipes_struct *p, char *pipe_name) struct handle_list *hl = NULL; for (plist = get_first_internal_pipe(); plist; plist = get_next_internal_pipe(plist)) { - if (strequal( plist->name, pipe_name)) { + if (strequal( plist->name, pipe_name) || + (is_samr_lsa_pipe(plist->name) && is_samr_lsa_pipe(pipe_name))) { if (!plist->pipe_handles) { pstring msg; slprintf(msg, sizeof(msg)-1, "init_pipe_handles: NULL pipe_handle pointer in pipe %s", -- cgit From 510d470e1e9cc30a71ac9df556420308635370c4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 31 Mar 2002 06:00:37 +0000 Subject: Removed unused variable. (This used to be commit 3e58e9dbabc4e4a1289ff6a43ddbb5de37b02515) --- source3/rpc_server/srv_srvsvc_nt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index cfd4a0bf1f..295c733ab5 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1692,7 +1692,6 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ int action; NTSTATUS nt_status; struct current_user user; - fstring user_name; connection_struct *conn = NULL; BOOL became_user = False; -- cgit From ca43b0da79557818b0486d5047667a981fd3e3e6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 5 Apr 2002 22:41:39 +0000 Subject: Fix Gerry bug - MajorVersion should be 2 not 3. Jeremy. (This used to be commit b8b88e863e3964231a85b4643a197d6d4d6b8f99) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 60c8fdfb7b..d1b92cf646 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1407,7 +1407,7 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return False; - SIVAL(*data, 0, 0x03); + SIVAL(*data, 0, 2); *needed = 0x4; return True; } -- cgit From 5cdc9e1685200a51aa970051057eb6da8221845e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 9 Apr 2002 04:59:34 +0000 Subject: Add a become_root()/unbecome_root() pair to allow acces to the passdb for SID lookup. This fixes a bug where SIDs (rather than names) are displayed in windows ACL lists (This used to be commit e60c509813a9113cd76135b6ded3018ff04d49f2) --- source3/rpc_server/srv_lsa_nt.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index af02a97769..84ab44bc30 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -233,6 +233,8 @@ static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME } } + become_root(); /* Need root to get to passdb to for local sids */ + for (i = 0; i < num_entries; i++) { BOOL status = False; DOM_SID find_sid = sid[i].sid; @@ -276,6 +278,8 @@ static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME total++; } + unbecome_root(); + trn->num_entries = total; trn->ptr_trans_names = 1; trn->num_entries2 = total; -- cgit From bcb842be57a0fe69f6c7374bae741c9e26ba1b45 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 9 Apr 2002 05:59:46 +0000 Subject: Fixed some compiler warnings. (This used to be commit be6f955107429f1431c49c8b45fd623406a9d641) --- source3/rpc_server/srv_spoolss_nt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d1b92cf646..2e96622118 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -568,7 +568,7 @@ static BOOL is_client_monitoring_event(Printer_entry *p, uint32 flags) --jerry **************************************************************************/ -static NTSTATUS srv_spoolss_routerreplyprinter (struct cli_state *cli, TALLOC_CTX *mem_ctx, +static NTSTATUS srv_spoolss_routerreplyprinter (struct cli_state *reply_cli, TALLOC_CTX *mem_ctx, POLICY_HND *pol, PRINTER_MESSAGE_INFO *info, NT_PRINTER_INFO_LEVEL *printer) { @@ -578,7 +578,7 @@ static NTSTATUS srv_spoolss_routerreplyprinter (struct cli_state *cli, TALLOC_CT if (info->flags & PRINTER_MESSAGE_DRIVER) condition = PRINTER_CHANGE_SET_PRINTER_DRIVER; - result = cli_spoolss_routerreplyprinter(cli, mem_ctx, pol, condition, + result = cli_spoolss_routerreplyprinter(reply_cli, mem_ctx, pol, condition, printer->info_2->changeid); return result; @@ -590,7 +590,7 @@ static NTSTATUS srv_spoolss_routerreplyprinter (struct cli_state *cli, TALLOC_CT **********************************************************************/ static NTSTATUS srv_spoolss_send_event_to_client(Printer_entry* Printer, - struct cli_state *cli, PRINTER_MESSAGE_INFO *msg, + struct cli_state *send_cli, PRINTER_MESSAGE_INFO *msg, NT_PRINTER_INFO_LEVEL *info) { NTSTATUS result; @@ -599,12 +599,12 @@ static NTSTATUS srv_spoolss_send_event_to_client(Printer_entry* Printer, /* This is a single call that can send information about multiple changes */ if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) msg->flags |= PRINTER_MESSAGE_ATTRIBUTES; - result = cli_spoolss_reply_rrpcn(cli, cli->mem_ctx, &Printer->notify.client_hnd, + result = cli_spoolss_reply_rrpcn(send_cli, send_cli->mem_ctx, &Printer->notify.client_hnd, msg, info); } else { /* This requires that the server send an individual event notification for each change */ - result = srv_spoolss_routerreplyprinter(cli, cli->mem_ctx, &Printer->notify.client_hnd, + result = srv_spoolss_routerreplyprinter(send_cli, send_cli->mem_ctx, &Printer->notify.client_hnd, msg, info); } -- cgit From d0d61ba689694a11165076b58c7ac0731333c0df Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 9 Apr 2002 06:19:42 +0000 Subject: Fixed typo in debug statement. (This used to be commit 49e429a97ff2b6b1889937c998f67d73d35829e1) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2e96622118..3022b99afa 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -917,7 +917,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, Printer=find_printer_index_by_hnd(p, handle); if (!Printer) { DEBUG(0,(" _spoolss_open_printer_ex: logic error. \ -Can't find printer handle we created for priunter %s\n", name )); +Can't find printer handle we created for printer %s\n", name )); close_printer_handle(p,handle); return WERR_INVALID_PRINTER_NAME; } -- cgit From 4ad0ff29bf44e2506311f672bf912e7a2d39048a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 10 Apr 2002 01:04:13 +0000 Subject: Added Shirish's client side caching policy change. Jeremy. (This used to be commit 16015c07eab2e57fa3771051e3e08fde21757cfa) --- source3/rpc_server/srv_srvsvc_nt.c | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 295c733ab5..6416cfc4ac 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -342,6 +342,38 @@ BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 d return ret; } +/******************************************************************* + Fill in a share info level 501 structure. +********************************************************************/ + +static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum) +{ + int len_net_name; + pstring net_name; + pstring remark; + uint32 type; + uint32 csc_policy; + + pstrcpy(net_name, lp_servicename(snum)); + pstrcpy(remark, lp_comment(snum)); + standard_sub_conn(p->conn, remark); + + len_net_name = strlen(net_name); + + /* work out the share type */ + type = STYPE_DISKTREE; + + if (lp_print_ok(snum)) + type = STYPE_PRINTQ; + if (strequal("IPC$", net_name) || strequal("ADMIN$", net_name)) + type = STYPE_IPC; + if (net_name[len_net_name] == '$') + type |= STYPE_HIDDEN; + + init_srv_share_info501(&sh501->info_501, net_name, type, remark, (lp_csc_policy(snum) << 4)); + init_srv_share_info501_str(&sh501->info_501_str, net_name, remark); +} + /******************************************************************* Fill in a share info level 502 structure. ********************************************************************/ @@ -484,6 +516,23 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, break; } + case 501: + { + SRV_SHARE_INFO_501 *info501; + int i = 0; + + info501 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_501)); + + 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_501(p, &info501[i++], snum); + } + } + + ctr->share.info501 = info501; + break; + } + case 502: { SRV_SHARE_INFO_502 *info502; @@ -552,6 +601,9 @@ static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_I case 2: init_srv_share_info_2(p, &r_n->info.share.info2, snum); break; + case 501: + init_srv_share_info_501(p, &r_n->info.share.info501, snum); + break; case 502: init_srv_share_info_502(p, &r_n->info.share.info502, snum); break; -- cgit From 83ece079956907e07c1018e5231dda1d0202f1a5 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 11 Apr 2002 01:50:18 +0000 Subject: WERROR merge from SAMBA_2_2 (This used to be commit 32dc5dbbfb16cb9fd6f953dbb8148f5228b453a4) --- source3/rpc_server/srv_spoolss_nt.c | 38 +++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3022b99afa..dff1186e1e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -161,7 +161,7 @@ static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp) static void srv_spoolss_replycloseprinter(POLICY_HND *handle) { - NTSTATUS result; + WERROR result; /* weird if the test succeds !!! */ if (smb_connections==0) { @@ -171,8 +171,9 @@ static void srv_spoolss_replycloseprinter(POLICY_HND *handle) result = cli_spoolss_reply_close_printer(&cli, cli.mem_ctx, handle); - if (!NT_STATUS_IS_OK(result)) - DEBUG(0,("srv_spoolss_replycloseprinter: reply_close_printer failed.\n")); + if (!W_ERROR_IS_OK(result)) + DEBUG(0,("srv_spoolss_replycloseprinter: reply_close_printer failed [%s].\n", + werror_str(result))); /* if it's the last connection, deconnect the IPC$ share */ if (smb_connections==1) { @@ -568,11 +569,11 @@ static BOOL is_client_monitoring_event(Printer_entry *p, uint32 flags) --jerry **************************************************************************/ -static NTSTATUS srv_spoolss_routerreplyprinter (struct cli_state *reply_cli, TALLOC_CTX *mem_ctx, +static WERROR srv_spoolss_routerreplyprinter (struct cli_state *reply_cli, TALLOC_CTX *mem_ctx, POLICY_HND *pol, PRINTER_MESSAGE_INFO *info, NT_PRINTER_INFO_LEVEL *printer) { - NTSTATUS result; + WERROR result; uint32 condition = 0x0; if (info->flags & PRINTER_MESSAGE_DRIVER) @@ -589,16 +590,17 @@ static NTSTATUS srv_spoolss_routerreplyprinter (struct cli_state *reply_cli, TAL notification **********************************************************************/ -static NTSTATUS srv_spoolss_send_event_to_client(Printer_entry* Printer, +static WERROR srv_spoolss_send_event_to_client(Printer_entry* Printer, struct cli_state *send_cli, PRINTER_MESSAGE_INFO *msg, NT_PRINTER_INFO_LEVEL *info) { - NTSTATUS result; + WERROR result; if (valid_notify_options(Printer)) { /* This is a single call that can send information about multiple changes */ if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) msg->flags |= PRINTER_MESSAGE_ATTRIBUTES; + result = cli_spoolss_reply_rrpcn(send_cli, send_cli->mem_ctx, &Printer->notify.client_hnd, msg, info); } @@ -620,8 +622,7 @@ static NTSTATUS srv_spoolss_send_event_to_client(Printer_entry* Printer, static void send_spoolss_event_notification(PRINTER_MESSAGE_INFO *msg) { Printer_entry *find_printer; - NTSTATUS result; - WERROR wresult; + WERROR result; NT_PRINTER_INFO_LEVEL *printer = NULL; if (!msg) { @@ -686,8 +687,8 @@ static void send_spoolss_event_notification(PRINTER_MESSAGE_INFO *msg) printer = NULL; } - wresult = get_a_printer(&printer, 2, msg->printer_name); - if (! W_ERROR_IS_OK(wresult)) + result = get_a_printer(&printer, 2, msg->printer_name); + if (!W_ERROR_IS_OK(result)) continue; } @@ -695,9 +696,9 @@ static void send_spoolss_event_notification(PRINTER_MESSAGE_INFO *msg) result = srv_spoolss_send_event_to_client(find_printer, &cli, msg, printer); - if (!NT_STATUS_IS_OK(result)) { - DEBUG(10,("send_spoolss_event_notification: Event notification failed [%s]\n", - nt_errstr(result))); + if (!W_ERROR_IS_OK(result)) { + DEBUG(5,("send_spoolss_event_notification: Event notification failed [%s]\n", + werror_str(result))); } } } @@ -1581,7 +1582,7 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle) { - NTSTATUS result; + WERROR result; /* * If it's the first connection, contact the client @@ -1594,6 +1595,7 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin if(!spoolss_connect_to_client(&cli, unix_printer)) return False; + message_register(MSG_PRINTER_NOTIFY, srv_spoolss_receive_message); } @@ -1603,7 +1605,11 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin result = cli_spoolss_reply_open_printer(&cli, cli.mem_ctx, printer, localprinter, type, handle); - return (NT_STATUS_IS_OK(result)); + if (!W_ERROR_IS_OK(result)) + DEBUG(5,("srv_spoolss_reply_open_printer: Client RPC returned [%s]\n", + werror_str(result))); + + return (W_ERROR_IS_OK(result)); } /******************************************************************** -- cgit From ed72efbd3bb492b18552cd27860ebac4bf29f47d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 11 Apr 2002 02:08:36 +0000 Subject: merge from 2.2 (This used to be commit 7db47c6647d764739e395948699cf115c4da4c8d) --- source3/rpc_server/srv_srvsvc_nt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 6416cfc4ac..1f3b1945e3 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -352,7 +352,6 @@ static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, pstring net_name; pstring remark; uint32 type; - uint32 csc_policy; pstrcpy(net_name, lp_servicename(snum)); pstrcpy(remark, lp_comment(snum)); -- cgit From d3fa6d5de64f022eafd99b83d4853c86f8b2f46c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 11 Apr 2002 02:13:56 +0000 Subject: s/werror_str/dos_errstr/g to fix compile (This used to be commit d7c9b00253499da047f30f71660dede3676d40ad) --- source3/rpc_server/srv_spoolss_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index dff1186e1e..23754602fb 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -173,7 +173,7 @@ static void srv_spoolss_replycloseprinter(POLICY_HND *handle) if (!W_ERROR_IS_OK(result)) DEBUG(0,("srv_spoolss_replycloseprinter: reply_close_printer failed [%s].\n", - werror_str(result))); + dos_errstr(result))); /* if it's the last connection, deconnect the IPC$ share */ if (smb_connections==1) { @@ -698,7 +698,7 @@ static void send_spoolss_event_notification(PRINTER_MESSAGE_INFO *msg) if (!W_ERROR_IS_OK(result)) { DEBUG(5,("send_spoolss_event_notification: Event notification failed [%s]\n", - werror_str(result))); + dos_errstr(result))); } } } @@ -1607,7 +1607,7 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin if (!W_ERROR_IS_OK(result)) DEBUG(5,("srv_spoolss_reply_open_printer: Client RPC returned [%s]\n", - werror_str(result))); + dos_errstr(result))); return (W_ERROR_IS_OK(result)); } -- cgit From 8e2f3ec1d175ae530842b502c4f0431b50dd364e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 11 Apr 2002 02:59:31 +0000 Subject: Correctly emulate NT in printer handle opening access rights. Jeremy. (This used to be commit 42ae2334f21402c347aee560f08fd8e730481169) --- source3/rpc_server/srv_spoolss_nt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 23754602fb..3bc91c2472 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -993,7 +993,6 @@ Can't find printer handle we created for printer %s\n", name )); /* 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, @@ -1013,6 +1012,12 @@ Can't find printer handle we created for printer %s\n", name )); return WERR_ACCESS_DENIED; } + if ((printer_default->access_required & SPECIFIC_RIGHTS_MASK)& ~(PRINTER_ACCESS_ADMINISTER|PRINTER_ACCESS_USE)) { + DEBUG(3, ("access DENIED for printer open - unknown bits\n")); + close_printer_handle(p, handle); + return WERR_ACCESS_DENIED; + } + if (printer_default->access_required & PRINTER_ACCESS_ADMINISTER) printer_default->access_required = PRINTER_ACCESS_ADMINISTER; else -- cgit From 4c0399915cde591cb06f99b50acd5e5bf48bc6cb Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 11 Apr 2002 23:43:40 +0000 Subject: Much better support for both non-algorithic RIDs (where the RID is stored in the passdb) and RIDs not in the passdb, due to being NIS users etc. The main fix here is to add become_root()/unbecome_root() at critical places. This (finally) fixes the bug where you could not see local users's names in a file's security properties as non-root. Tested. The similar bug in uid_to_sid is also fixed, but is not (yet) Tested. Andrew Bartlett (This used to be commit 79327a305e20d78ab5ca21d01c39b5f49dc0d632) --- source3/rpc_server/srv_samr_nt.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c83f6b3d8d..106d7c1923 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1443,11 +1443,6 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) 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; - } - pdb_init_sam(&smbpass); become_root(); @@ -1524,11 +1519,6 @@ static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, uint32 user_rid) 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; - } - pdb_init_sam(&sampass); become_root(); @@ -1562,11 +1552,6 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) 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; - } - pdb_init_sam(&sampass); become_root(); -- cgit From 4023a61892278c9e09acd035166a55ff2b3d4f30 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 12 Apr 2002 10:18:46 +0000 Subject: merged the mangling test and passdb bugfixes into SAMBA_3_0 (This used to be commit 97eb3a121d33200ee7559b2413d6252efc04ebaf) --- source3/rpc_server/srv_samr_nt.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c83f6b3d8d..106d7c1923 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1443,11 +1443,6 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) 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; - } - pdb_init_sam(&smbpass); become_root(); @@ -1524,11 +1519,6 @@ static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, uint32 user_rid) 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; - } - pdb_init_sam(&sampass); become_root(); @@ -1562,11 +1552,6 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) 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; - } - pdb_init_sam(&sampass); become_root(); -- cgit From 07e6ff5fcfe337bb65a7c3a4493a92a7761cf2ed Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 14 Apr 2002 09:44:16 +0000 Subject: Partly based on the work by mimir (Rafal Szczesniak ) this patch allows samba to correctly enumerate its trusted domains - by exaimining the keys in the secrets.tdb file. This patch has been tested with both NT4 and rpcclient/wbinfo, and adds some extra functionality to talloc and rpc_parse to allow it to deal with already unicode strings. Finally, this cleans up some const warnings that were in net_rpc.c by pushing another dash of const into the rpc client code. Andrew Bartlett (This used to be commit 0bdd94cb992b40942aaf2e5e0efd2868b4686296) --- source3/rpc_server/srv_lsa.c | 2 ++ source3/rpc_server/srv_lsa_nt.c | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index fcd4be0212..3914556e88 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -105,8 +105,10 @@ static BOOL api_lsa_enum_trust_dom(pipes_struct *p) if(!lsa_io_q_enum_trust_dom("", &q_u, data, 0)) return False; + /* get required trusted domains information */ r_u.status = _lsa_enum_trust_dom(p, &q_u, &r_u); + /* prepare the response */ if(!lsa_io_r_enum_trust_dom("", &r_u, rdata, 0)) return False; diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 84ab44bc30..c564323803 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -416,14 +416,18 @@ NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL * /*************************************************************************** _lsa_enum_trust_dom - this needs fixing to do more than return NULL ! JRA. + ufff, done :) mimir ***************************************************************************/ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_ENUM_TRUST_DOM *r_u) { struct lsa_info *info; - uint32 enum_context = 0; - char *dom_name = NULL; - DOM_SID *dom_sid = NULL; + uint32 enum_context = q_u->enum_context; + /* it's set to 10 as a "our" preferred length */ + uint32 max_num_domains = q_u->preferred_len < 10 ? q_u->preferred_len : 10; + TRUSTDOM **trust_doms; + uint32 num_domains; + NTSTATUS nt_status; if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; @@ -432,9 +436,13 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E if (!(info->access & POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - /* set up the LSA QUERY INFO response */ - init_r_enum_trust_dom(p->mem_ctx, r_u, enum_context, dom_name, dom_sid, - dom_name != NULL ? NT_STATUS_OK : NT_STATUS_NO_MORE_ENTRIES); + nt_status = secrets_get_trusted_domains(p->mem_ctx, enum_context, max_num_domains, &num_domains, &trust_doms); + if (!NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } + + /* set up the lsa_enum_trust_dom response */ + init_r_enum_trust_dom(p->mem_ctx, r_u, enum_context, max_num_domains, num_domains, trust_doms); return r_u->status; } -- cgit From fea03cef2be825037b0c610964ca6e296ed6e33d Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 15 Apr 2002 03:49:53 +0000 Subject: Merge of print server permission handling fixes from HEAD. (This used to be commit 62ee1f8c3fbcf83641bed881143a1a8c70f836ba) --- source3/rpc_server/srv_spoolss_nt.c | 53 ++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3bc91c2472..80bfd74b47 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -92,7 +92,8 @@ static uint32 smb_connections=0; /* in printing/nt_printing.c */ -extern STANDARD_MAPPING printer_std_mapping; + +extern STANDARD_MAPPING printer_std_mapping, printserver_std_mapping; #define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ ((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) @@ -959,26 +960,54 @@ Can't find printer handle we created for printer %s\n", name )); get_current_user(&user, p); if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) { - if (printer_default->access_required == 0) { - return WERR_OK; + + /* Printserver handles use global struct... */ + + snum = -1; + + /* Map standard access rights to object specific access + rights */ + + se_map_standard(&printer_default->access_required, + &printserver_std_mapping); + + /* Deny any object specific bits that don't apply to print + servers (i.e printer and job specific bits) */ + + printer_default->access_required &= SPECIFIC_RIGHTS_MASK; + + if (printer_default->access_required & + ~(SERVER_ACCESS_ADMINISTER | SERVER_ACCESS_ENUMERATE)) { + DEBUG(3, ("access DENIED for non-printserver bits")); + close_printer_handle(p, handle); + return WERR_ACCESS_DENIED; } - else if ((printer_default->access_required & SERVER_ACCESS_ADMINISTER ) == SERVER_ACCESS_ADMINISTER) { - /* Printserver handles use global struct... */ - snum = -1; + /* Allow admin access */ + + if (printer_default->access_required & + SERVER_ACCESS_ADMINISTER) { if (!lp_ms_add_printer_wizard()) { close_printer_handle(p, handle); return WERR_ACCESS_DENIED; } - else if (user.uid == 0 || user_in_list(uidtoname(user.uid), lp_printer_admin(snum))) { + + if (user.uid == 0 || + user_in_list(uidtoname(user.uid), + lp_printer_admin(snum))) return WERR_OK; - } - else { - close_printer_handle(p, handle); - return WERR_ACCESS_DENIED; - } + + DEBUG(0, ("** denied 0x%08x to user %s\n", + printer_default->access_required, + uidtoname(user.uid))); + + close_printer_handle(p, handle); + return WERR_ACCESS_DENIED; } + + /* We fall through to return WERR_OK */ + } else { -- cgit From 59a04032c86a9304156946c6f71bb4b1375ab81b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 15 Apr 2002 04:00:27 +0000 Subject: Whoops, removed debug 0 that snuck in. (This used to be commit dd1fb1b90b143c41238eb1f342d86d8fd406a4ef) --- source3/rpc_server/srv_spoolss_nt.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 80bfd74b47..6572e23fbb 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -998,10 +998,6 @@ Can't find printer handle we created for printer %s\n", name )); lp_printer_admin(snum))) return WERR_OK; - DEBUG(0, ("** denied 0x%08x to user %s\n", - printer_default->access_required, - uidtoname(user.uid))); - close_printer_handle(p, handle); return WERR_ACCESS_DENIED; } -- cgit From 1667a821060b8bbc1cef3db473f6967cd02f5886 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 15 Apr 2002 04:07:13 +0000 Subject: Merge of print server permission handling fixes from HEAD. Unit tests rock! (This used to be commit bc673c42045ceb46d9569bc4d88f9c64897fc85a) --- source3/rpc_server/srv_spoolss_nt.c | 49 ++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3bc91c2472..a8552cd14d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -92,7 +92,8 @@ static uint32 smb_connections=0; /* in printing/nt_printing.c */ -extern STANDARD_MAPPING printer_std_mapping; + +extern STANDARD_MAPPING printer_std_mapping, printserver_std_mapping; #define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ ((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) @@ -959,26 +960,50 @@ Can't find printer handle we created for printer %s\n", name )); get_current_user(&user, p); if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) { - if (printer_default->access_required == 0) { - return WERR_OK; + + /* Printserver handles use global struct... */ + + snum = -1; + + /* Map standard access rights to object specific access + rights */ + + se_map_standard(&printer_default->access_required, + &printserver_std_mapping); + + /* Deny any object specific bits that don't apply to print + servers (i.e printer and job specific bits) */ + + printer_default->access_required &= SPECIFIC_RIGHTS_MASK; + + if (printer_default->access_required & + ~(SERVER_ACCESS_ADMINISTER | SERVER_ACCESS_ENUMERATE)) { + DEBUG(3, ("access DENIED for non-printserver bits")); + close_printer_handle(p, handle); + return WERR_ACCESS_DENIED; } - else if ((printer_default->access_required & SERVER_ACCESS_ADMINISTER ) == SERVER_ACCESS_ADMINISTER) { - /* Printserver handles use global struct... */ - snum = -1; + /* Allow admin access */ + + if (printer_default->access_required & + SERVER_ACCESS_ADMINISTER) { if (!lp_ms_add_printer_wizard()) { close_printer_handle(p, handle); return WERR_ACCESS_DENIED; } - else if (user.uid == 0 || user_in_list(uidtoname(user.uid), lp_printer_admin(snum))) { + + if (user.uid == 0 || + user_in_list(uidtoname(user.uid), + lp_printer_admin(snum))) return WERR_OK; - } - else { - close_printer_handle(p, handle); - return WERR_ACCESS_DENIED; - } + + close_printer_handle(p, handle); + return WERR_ACCESS_DENIED; } + + /* We fall through to return WERR_OK */ + } else { -- cgit From e9be6c4db4ad5a5caefed5a97df13880ca3262f4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Apr 2002 01:48:45 +0000 Subject: Fix found by Li Shao @ HP - XP clients don't bother to set the devmode_ptr in the SetPrinter() call - they send it in the devmode_ctr instead. Jeremy. (This used to be commit f988a1af034b4cea2412171a257a752192afaece) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a8552cd14d..5fa45b0b44 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5084,7 +5084,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, goto done; } - if (info->info_2->devmode_ptr != 0) { + if (devmode) { /* we have a valid devmode convert it and link it*/ -- cgit From dde9187728936df5825cf19bda74fce1185ffb21 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 22 Apr 2002 18:47:36 +0000 Subject: merge from SAMBA_2_2 (This used to be commit 5e381abbbfaa15f3ebd89cba3cd9bb6de8e4ff4e) --- source3/rpc_server/srv_spoolss.c | 4 ---- source3/rpc_server/srv_spoolss_nt.c | 8 +------- 2 files changed, 1 insertion(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index e6c152c668..c7dc5d27ff 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1451,11 +1451,7 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_SETPRINTERDATAEX", SPOOLSS_SETPRINTERDATAEX, api_spoolss_setprinterdataex }, {"SPOOLSS_ENUMPRINTERKEY", SPOOLSS_ENUMPRINTERKEY, api_spoolss_enumprinterkey }, {"SPOOLSS_ENUMPRINTERDATAEX", SPOOLSS_ENUMPRINTERDATAEX, api_spoolss_enumprinterdataex }, -#if 0 - /* Disabled because it doesn't fix the bug I am looking at but it would be - a shame to throw away the code. -tpot */ {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory}, -#endif { NULL, 0, NULL } }; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5fa45b0b44..d6ce065548 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7807,13 +7807,7 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, if((info=(PRINTPROCESSOR_DIRECTORY_1 *)malloc(sizeof(PRINTPROCESSOR_DIRECTORY_1))) == NULL) return WERR_NOMEM; - /* Not sure what to return here - are UNC names valid here?. - Windows returns the string: C:\WINNT\System32\spool\PRTPROCS\W32X86 - which is pretty bogus for a RPC. */ - - slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", get_called_name(), short_archi); - - DEBUG(4,("print processor directory: [%s]\n", path)); + pstrcpy(path, "C:\\WINNT\\System32\\spool\\PRTPROCS\\W32X86"); fill_printprocessordirectory_1(info, path); -- cgit From 2699f9b9df3f974a34e40761141361e997638b6c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 22 Apr 2002 18:48:45 +0000 Subject: printing merge from HEAD (This used to be commit d3aed37dd87d425f51bcdc4e5151f0b0fe8f9c6b) --- source3/rpc_server/srv_spoolss.c | 4 ---- source3/rpc_server/srv_spoolss_nt.c | 10 ++-------- 2 files changed, 2 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index e6c152c668..c7dc5d27ff 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1451,11 +1451,7 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_SETPRINTERDATAEX", SPOOLSS_SETPRINTERDATAEX, api_spoolss_setprinterdataex }, {"SPOOLSS_ENUMPRINTERKEY", SPOOLSS_ENUMPRINTERKEY, api_spoolss_enumprinterkey }, {"SPOOLSS_ENUMPRINTERDATAEX", SPOOLSS_ENUMPRINTERDATAEX, api_spoolss_enumprinterdataex }, -#if 0 - /* Disabled because it doesn't fix the bug I am looking at but it would be - a shame to throw away the code. -tpot */ {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory}, -#endif { NULL, 0, NULL } }; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 6572e23fbb..322efa22b5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5084,7 +5084,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, goto done; } - if (info->info_2->devmode_ptr != 0) { + if (devmode) { /* we have a valid devmode convert it and link it*/ @@ -7807,13 +7807,7 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, if((info=(PRINTPROCESSOR_DIRECTORY_1 *)malloc(sizeof(PRINTPROCESSOR_DIRECTORY_1))) == NULL) return WERR_NOMEM; - /* Not sure what to return here - are UNC names valid here?. - Windows returns the string: C:\WINNT\System32\spool\PRTPROCS\W32X86 - which is pretty bogus for a RPC. */ - - slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", get_called_name(), short_archi); - - DEBUG(4,("print processor directory: [%s]\n", path)); + pstrcpy(path, "C:\\WINNT\\System32\\spool\\PRTPROCS\\W32X86"); fill_printprocessordirectory_1(info, path); -- cgit From 569fa9b3dd31b72b35e224ffffe65715a858b7c3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 23 Apr 2002 02:16:48 +0000 Subject: Fix for a bug Jerry found with printing where a smbd connection may be idled even with an open pipe. Jeremy. (This used to be commit 3a93c5daeca3edd4f319199c8a6068d25cb6750e) --- source3/rpc_server/srv_pipe_hnd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 44dd5fac65..4b20ee5558 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -240,6 +240,9 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, for (p_it = Pipes; p_it; p_it = p_it->next) DEBUG(5,("open pipes: name %s pnum=%x\n", p_it->name, p_it->pnum)); + /* Ensure the connection isn't idled whilst this pipe is open. */ + conn->num_files_open++; + return chain_p; } @@ -1055,7 +1058,9 @@ BOOL close_rpc_pipe_hnd(smb_np_struct *p) ZERO_STRUCTP(p); SAFE_FREE(p); - + + conn->num_files_open--; + return True; } -- cgit From fd99accdb55ea7e6be8f61155efad88c9d5edaf6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 23 Apr 2002 18:34:52 +0000 Subject: Fix my stupid compile bug in num_files_open. Jeremy. (This used to be commit 7c02db7c4f0d04b7c45a9c580f3e85f52fa505d5) --- source3/rpc_server/srv_pipe_hnd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 4b20ee5558..a4a9e85ae4 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -240,9 +240,6 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, for (p_it = Pipes; p_it; p_it = p_it->next) DEBUG(5,("open pipes: name %s pnum=%x\n", p_it->name, p_it->pnum)); - /* Ensure the connection isn't idled whilst this pipe is open. */ - conn->num_files_open++; - return chain_p; } @@ -301,6 +298,10 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, DLIST_ADD(InternalPipes, p); p->conn = conn; + + /* Ensure the connection isn't idled whilst this pipe is open. */ + p->conn->num_files_open++; + p->vuid = vuid; p->ntlmssp_chal_flags = 0; @@ -1059,8 +1060,6 @@ BOOL close_rpc_pipe_hnd(smb_np_struct *p) SAFE_FREE(p); - conn->num_files_open--; - return True; } @@ -1090,6 +1089,8 @@ static BOOL close_internal_rpc_pipe_hnd(void *np_conn) DLIST_REMOVE(InternalPipes, p); + p->conn->num_files_open--; + ZERO_STRUCTP(p); SAFE_FREE(p); -- cgit From 800185c33f596f071881700543f256f06b1487ac Mon Sep 17 00:00:00 2001 From: Shirish Kalele Date: Thu, 9 May 2002 04:43:05 +0000 Subject: Sync'ing SAMBA_2_2 with HEAD. (This used to be commit d926cc989690684ec4799ebb3a3a01e8d4173de6) --- source3/rpc_server/srv_dfs_nt.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 4db6c61a3c..5732af7e9a 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -69,10 +69,7 @@ WERROR _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 WERR_DFS_NO_SUCH_SERVER; - - if(get_referred_path(&jn)) + if(get_referred_path(dfspath, &jn, NULL, NULL)) { exists = True; jn.referral_count += 1; @@ -137,16 +134,14 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_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 WERR_DFS_NO_SUCH_SERVER; - - if(!get_referred_path(&jn)) - return WERR_DFS_NO_SUCH_VOL; + if(!get_referred_path(dfspath, &jn, NULL, NULL)) + return WERR_DFS_NO_SUCH_VOL; /* if no server-share pair given, remove the msdfs link completely */ if(!q_u->ptr_ServerName && !q_u->ptr_ShareName) @@ -158,14 +153,18 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_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;ilevel = level; r_u->ptr_ctr = 1; -- cgit From 059da8fb3b7197bd6a9bfe57940a96a2546e63a5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 9 May 2002 19:54:47 +0000 Subject: Merged in printing fixes... There were many missing ! Jeremy (This used to be commit 32fa089adead6ff3279172fd36560f4f9e2aeef0) --- source3/rpc_server/srv_spoolss_nt.c | 112 +++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d6ce065548..8419152cf2 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -37,6 +37,15 @@ #define PRINTER_HANDLE_IS_PRINTER 0 #define PRINTER_HANDLE_IS_PRINTSERVER 1 +/* Table to map the driver version */ +/* to OS */ +char * drv_ver_to_os[] = { + "WIN9X", /* driver version/cversion 0 */ + "", /* unused ? */ + "WINNT", /* driver version/cversion 2 */ + "WIN2K", /* driver version/cversion 3 */ +}; + struct table_node { char *long_archi; char *short_archi; @@ -759,6 +768,69 @@ static BOOL srv_spoolss_sendnotify(char* printer_name, uint32 high, uint32 low, return True; } +/******************************************************************** + Send a message to ourself about new driver being installed + so we can upgrade the information for each printer bound to this + driver +********************************************************************/ + +static BOOL srv_spoolss_drv_upgrade_printer(char* drivername) +{ + int len = strlen(drivername); + + if (!len) + return False; + + DEBUG(10,("srv_spoolss_drv_upgrade_printer: Sending message about driver upgrade [%s]\n", + drivername)); + + message_send_pid(sys_getpid(), MSG_PRINTER_DRVUPGRADE, drivername, len+1, False); + return True; +} + +/********************************************************************** + callback to receive a MSG_PRINTER_DRVUPGRADE message and interate + over all printers, upgrading ones as neessary +**********************************************************************/ + +void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) +{ + fstring drivername; + int snum; + int n_services = lp_numservices(); + + len = MIN(len,sizeof(drivername)-1); + strncpy(drivername, buf, len); + + DEBUG(10,("do_drv_upgrade_printer: Got message for new driver [%s]\n", drivername )); + + /* Iterate the printer list */ + + for (snum=0; snuminfo_2 && !strcmp(drivername, printer->info_2->drivername)) { + DEBUG(6,("Updating printer [%s]\n", printer->info_2->printername)); + /* all we care about currently is the change_id */ + result = mod_a_printer(*printer, 2); + if (!W_ERROR_IS_OK(result)) { + DEBUG(3,("do_drv_upgrade_printer: mod_a_printer() failed with status [%s]\n", + dos_errstr(result))); + } + } + free_a_printer(&printer, 2); + } + } + + /* all done */ +} + /******************************************************************** Copy routines used by convert_to_openprinterex() *******************************************************************/ @@ -6462,7 +6534,8 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, WERROR err = WERR_OK; NT_PRINTER_DRIVER_INFO_LEVEL driver; struct current_user user; - + fstring driver_name; + ZERO_STRUCT(driver); get_current_user(&user, p); @@ -6489,6 +6562,43 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, goto done; } + /* BEGIN_ADMIN_LOG */ + switch(level) { + case 3: + sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", + driver.info_3->name,drv_ver_to_os[driver.info_3->cversion],uidtoname(user.uid)); + fstrcpy(driver_name, driver.info_3->name); + break; + case 6: + sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", + driver.info_6->name,drv_ver_to_os[driver.info_6->version],uidtoname(user.uid)); + fstrcpy(driver_name, driver.info_6->name); + break; + } + /* END_ADMIN_LOG */ + + /* + * I think this is where he DrvUpgradePrinter() hook would be + * be called in a driver's interface DLL on a Windows NT 4.0/2k + * server. Right now, we just need to send ourselves a message + * to update each printer bound to this driver. --jerry + */ + + if (!srv_spoolss_drv_upgrade_printer(driver_name)) { + DEBUG(0,("_spoolss_addprinterdriver: Failed to send message about upgrading driver [%s]!\n", + driver_name)); + } + + /* if driver is not 9x, delete existing driver init data */ + + if ((level == 3 && driver.info_3->cversion != 0) || + (level == 6 && driver.info_6->version != 0)) { + if (!del_driver_init(driver_name)) + DEBUG(3,("_spoolss_addprinterdriver: del_driver_init(%s) failed!\n", driver_name)); + } else { + DEBUG(10,("_spoolss_addprinterdriver: init data not deleted for 9x driver [%s]\n", driver_name)); + } + done: free_a_printer_driver(driver, level); return err; -- cgit From 2586abb599c7266f1c2a729ddd1b75b55ec51bc7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 10 May 2002 01:15:36 +0000 Subject: Fix the bug that refused to allow IPC$ connection to be idled if a pipe was open - we now only refuse to allow IPC$ connection to be idled if a handle is open on a pipe. Jeremy. (This used to be commit fc043110bc42d56c8686b9b64c46af7be2fd236e) --- source3/rpc_server/srv_lsa_hnd.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 84c3c5a959..62af0ecac8 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -134,6 +134,14 @@ BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *) DLIST_ADD(p->pipe_handles->Policy, pol); p->pipe_handles->count++; + /* + * Ensure we don't idle this connection if a handle is open. + * Increment the number of files open on the first handle create. + */ + + if (p->pipe_handles->count == 1) + p->conn->num_files_open++; + *hnd = pol->pol_hnd; DEBUG(4,("Opened policy hnd[%d] ", (int)p->pipe_handles->count)); @@ -201,6 +209,15 @@ BOOL close_policy_hnd(pipes_struct *p, POLICY_HND *hnd) p->pipe_handles->count--; + /* + * Ensure we can idle this connection if this is the last handle. + * Decrement the number of files open on the last handle delete. + */ + + if (p->pipe_handles->count == 0) + p->conn->num_files_open--; + + DLIST_REMOVE(p->pipe_handles->Policy, pol); ZERO_STRUCTP(pol); -- cgit From 3fe27b7f9df7d2bb2f7799fd46b79928f0e614b0 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 17 May 2002 13:49:01 +0000 Subject: A few more trusted domains updates from mimir. I think we may still need to look at our server enumeration code, but other than that, its much better in the tree than out. Andrew Bartlett (This used to be commit d57a1b4629d12a0374cc6d74dfc6f5d4793fcef8) --- source3/rpc_server/srv_lsa_nt.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c564323803..c4adc26360 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -3,8 +3,9 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Rafal Szczesniak 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -423,8 +424,12 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E { struct lsa_info *info; uint32 enum_context = q_u->enum_context; - /* it's set to 10 as a "our" preferred length */ - uint32 max_num_domains = q_u->preferred_len < 10 ? q_u->preferred_len : 10; + + /* + * preferred length is set to 5 as a "our" preferred length + * nt sets this parameter to 2 + */ + uint32 max_num_domains = q_u->preferred_len < 5 ? q_u->preferred_len : 10; TRUSTDOM **trust_doms; uint32 num_domains; NTSTATUS nt_status; @@ -436,9 +441,14 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E if (!(info->access & POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - nt_status = secrets_get_trusted_domains(p->mem_ctx, enum_context, max_num_domains, &num_domains, &trust_doms); - if (!NT_STATUS_IS_OK(nt_status)) { + nt_status = secrets_get_trusted_domains(p->mem_ctx, &enum_context, max_num_domains, &num_domains, &trust_doms); + + if (!NT_STATUS_IS_OK(nt_status) && + !NT_STATUS_EQUAL(nt_status, STATUS_MORE_ENTRIES) && + !NT_STATUS_EQUAL(nt_status, NT_STATUS_NO_MORE_ENTRIES)) { return nt_status; + } else { + r_u->status = nt_status; } /* set up the lsa_enum_trust_dom response */ -- cgit From 58e1fe62cc955c6b8449332447a6879c6fab64e7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 18 May 2002 05:52:52 +0000 Subject: A few things in this commit: cleanup some of the code in net_rpc_join re const warnings and fstrings. Passdb: Make the %u and %U substituions in passdb work. This is done by declaring these paramters to be 'const' and doing the substitution manually. I'm told this is us going full circle, but I can't really see a better way. Finally these things actually seem to work properly... Make the lanman code use the pdb's recorded values for homedir etc rather than the values from lp_*() Add code to set the plaintext password in the passdb, where it can decide how to store/set it. For use with a future 'ldap password change' option, or somthing like that... Add pdb_unix, so as to remove the 'not in passdb' special cases from the local_lookup_*() code. Quite small, as it uses the new 'struct passwd -> SAM_ACCOUNT' code that is now in just one place. (also used by pdb_smbpasswd) Other: Fix up the adding of [homes] at session setup time to actually pass the right string, that is the unix homedir, not the UNC path. Fix up [homes] so that for winbind users is picks the correct name. (bad interactions with the default domain code previously) Change the rpc_server/srv_lsa_nt.c code to match NT when for the SATUS_NONE_MAPPED reply: This was only being triggered on no queries, now it is on the 'no mappings' (ie all mappings failed). Checked against Win2k. Policy Question: Should SID -> unix_user.234/unix_group.364 be considered a mapping or not? Currently it isn't. Andrew Bartlett (This used to be commit c28668068b5a3b3cf3c4317e5fb32ec9957f3e34) --- source3/rpc_server/srv_lsa_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c4adc26360..a5e3f5003c 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -259,6 +259,8 @@ static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME if (!status) { sid_name_use = SID_NAME_UNKNOWN; + } else { + (*mapped_count)++; } /* Store domain sid in ref array */ @@ -272,8 +274,6 @@ static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME DEBUG(10,("init_lsa_trans_names: added user '%s\\%s' to " "referenced list.\n", dom_name, name )); - (*mapped_count)++; - init_lsa_trans_name(&trn->name[total], &trn->uni_name[total], sid_name_use, name, dom_idx); total++; -- cgit From d4dac178df1ff7dba83e3adddb55770b0b26e530 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 18 May 2002 09:06:23 +0000 Subject: Passdb: Kill off the silly code that attempts to do NT -> Unix username mapping. This is done well before here, no need to repeat it. Add some small fixes and extra debugs, trying to track down current build farm failures. pdb_unix: When 'updating' a pdb_unix account, instead add it to the default passdb. This means that you don't need to specify '-a' to smbpasswd any more when messing with an existing unix user, the account is simply 'upgraded'. The idea here is that these accounts are just as 'real' as any other, they just don't have the extra attributes an smbpasswd file does. I'm open for debate on the pdb_unix issue, and will remove it if given good reason. (without this, an attempt to add an account already in pdb_unix to smbpasswd would fail, as it would fail to update pdb_unix). rpc_server/srv_netlog_nt.c Change a couple of things around, so as to show the client workstation etc. WRONG_PASSWORD is certainly not the right default error. Try ACCESS_DENIED for now. Andrew Bartlett (This used to be commit d78b74b338df9accd9ad84c56a49fa4f787425e2) --- source3/rpc_server/srv_netlog_nt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index bdb064c81d..21ad86b0dc 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -150,7 +150,7 @@ NTSTATUS _net_trust_dom_list(pipes_struct *p, NET_Q_TRUST_DOM_LIST *q_u, NET_R_T ***********************************************************************************/ static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, - DOM_CRED *srv_cred, NTSTATUS status) + DOM_CRED *srv_cred, NTSTATUS status) { DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); @@ -378,7 +378,7 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_u) { - NTSTATUS status = NT_STATUS_WRONG_PASSWORD; + NTSTATUS status = NT_STATUS_ACCESS_DENIED; DOM_CRED srv_cred; pstring workstation; SAM_ACCOUNT *sampass=NULL; @@ -395,8 +395,8 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); - rpcstr_pull(workstation,q_u->clnt_id.login.uni_acct_name.buffer, - sizeof(workstation),q_u->clnt_id.login.uni_acct_name.uni_str_len*2,0); + rpcstr_pull(workstation,q_u->clnt_id.login.uni_comp_name.buffer, + sizeof(workstation),q_u->clnt_id.login.uni_comp_name.uni_str_len*2,0); DEBUG(3,("Server Password Set by Wksta:[%s] on account [%s]\n", workstation, p->dc.mach_acct)); -- cgit From b8618865df8adbd9d22c6a2a61be8ed373a75aa4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 19 May 2002 12:06:45 +0000 Subject: Patch to only set SV_TYPE_PRINTQ_SERVER in default_server_announce if a print share is exported. Needs some more testing. (This used to be commit 92b36482fd6aa5103c30dad40fe799c07dd2d8d7) --- source3/rpc_server/srv_spoolss_nt.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8419152cf2..c4a8d3917c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4848,6 +4848,9 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) } file_lines_free(qlines); + + update_server_announce_as_printserver(); + return True; } -- cgit From b87eee983612c0d21b0c6f1346ba15ace797fe9e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 22 May 2002 12:44:45 +0000 Subject: Add a bit more const, and kill of (finally!) sys_getpwnam and sys_getpwuid. These might be reimplmented as simple pass-through functions, but all users really should be doing 'getpwnam_alloc' or 'getpwuid_alloc' to ensure that there are not shared static buffers. I don't beleive we actually need a getpw*() cache inside samba - if we do then I think we should look at our code design first. (some of these changes are for platforms I don't have access to, but they look sane) Andrew Bartlett (This used to be commit 9d8431b04f41dceffe4c45cc969472ee59f7282f) --- source3/rpc_server/srv_samr_nt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 106d7c1923..6a623bd2a0 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2935,8 +2935,11 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD pdb_free_sam(&sam_user); - if ((pwd=getpwuid(uid)) == NULL) + if ((pwd=getpwuid_alloc(uid)) == NULL) { return NT_STATUS_NO_SUCH_USER; + } else { + passwd_free(&pwd); + } if ((grp=getgrgid(map.gid)) == NULL) return NT_STATUS_NO_SUCH_ALIAS; @@ -3076,8 +3079,11 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD pdb_free_sam(&sam_user); - if ((pwd=getpwuid(uid)) == NULL) + if ((pwd=getpwuid_alloc(uid)) == NULL) { return NT_STATUS_NO_SUCH_USER; + } else { + passwd_free(&pwd); + } if ((grp=getgrgid(map.gid)) == NULL) return NT_STATUS_NO_SUCH_GROUP; -- cgit From 5b76d846f87fa138e64e0526925bad5a4a51a263 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 24 May 2002 16:27:54 +0000 Subject: merge from SAMBA_2_2. Tim, please check the prs_align() removed from sec_io_desc() and make sure it doesn't break anything else. I know it is right for the printing needs and I have tested some other general things like viewing acls on directories, but I would feel more comfortable if you would have a look as well. jerry (This used to be commit 83f109c940f30d9b35176540d8bdccbb22ffa3a1) --- source3/rpc_server/srv_spoolss_nt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c4a8d3917c..3f86768379 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1510,7 +1510,11 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return False; +#ifndef EMULATE_WIN2K_HACK /* JERRY */ SIVAL(*data, 0, 2); +#else + SIVAL(*data, 0, 3); +#endif *needed = 0x4; return True; } @@ -3004,7 +3008,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) printer->global_counter = global_counter; printer->total_pages = 0; -#if 0 /* JERRY */ +#ifndef EMULATE_WIN2K_HACK /* JERRY */ printer->major_version = 0x0004; /* NT 4 */ printer->build_version = 0x0565; /* build 1381 */ #else @@ -5257,8 +5261,6 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, if (!strequal(printer->info_2->location, old_printer->info_2->location)) msg.flags |= PRINTER_MESSAGE_LOCATION; - ZERO_STRUCT(msg); - msg.low = PRINTER_CHANGE_ADD_PRINTER; fstrcpy(msg.printer_name, printer->info_2->printername); -- cgit From 73bc5782d4832b05379f539057fba8bf510a9ee9 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 24 May 2002 19:17:27 +0000 Subject: merge from SAMBA_2_2 (This used to be commit f0226a1d836b69d179a1a2eda79fa26911b78096) --- source3/rpc_server/srv_spoolss_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3f86768379..1a436f8c7c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1103,7 +1103,9 @@ Can't find printer handle we created for printer %s\n", name )); printer_default->access_required = PRINTER_ACCESS_USE; } - if (!print_access_check(&user, snum, printer_default->access_required)) { + /* check smb.conf parameters and the the sec_desc */ + + if (!user_ok(uidtoname(user.uid), snum) || !print_access_check(&user, snum, printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); close_printer_handle(p, handle); return WERR_ACCESS_DENIED; -- cgit From 20efe2fe6cbc4b5cf861a3296e29f5495637f79c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 25 May 2002 07:37:44 +0000 Subject: Clean up a few unused functions, add a bit of static etc. Importantly: The removal of the silly 'delete user script' behaviour when secuity=domain. I have left the name the same - as it still does the (previously documented, but not in smb.conf(5)) sane behaviour of deleting users on request. When we decide what to do with the 'add user' functionality, we might rename it. Andrew Bartlett (This used to be commit cdcfe3671eb7570e15649b77f708e6579055e7bc) --- source3/rpc_server/srv_samr_nt.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6a623bd2a0..c889581fae 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3174,6 +3174,24 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE } +/**************************************************************************** + Delete a UNIX user on demand. +****************************************************************************/ + +static int smb_delete_user(const char *unix_user) +{ + pstring del_script; + int ret; + + pstrcpy(del_script, lp_deluser_script()); + if (! *del_script) + return -1; + all_string_sub(del_script, "%u", unix_user, sizeof(pstring)); + ret = smbrun(del_script,NULL); + DEBUG(3,("smb_delete_user: Running the command `%s' gave %d\n",del_script,ret)); + return ret; +} + /********************************************************************* _samr_delete_dom_user *********************************************************************/ -- cgit From a27a0e01e2f0c48a4a8d84b17693390a268310f8 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 26 May 2002 19:11:52 +0000 Subject: change: pdb_getsampwrid() ->pdb_getsampwsid() passdb interface change, now the passdb modules will be asked for SID not for rid, the modules have been updated with a passthrough function that calls the old getsampwrid() functions. srv_samr_nt.c functions that made use of the pdb_getsampwrid funcion has been updated to use the SID one. (This used to be commit f5c6496c33fa7f5c2826540ffb4a49d8a5790fb3) --- source3/rpc_server/srv_samr_nt.c | 135 +++++++++++++++++---------------------- source3/rpc_server/srv_util.c | 8 ++- 2 files changed, 64 insertions(+), 79 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c889581fae..7c16bc7128 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1390,7 +1390,6 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN 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; @@ -1401,13 +1400,21 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN if (!find_policy_by_hnd(p, &domain_pol, NULL)) return NT_STATUS_INVALID_HANDLE; + /* Get the domain SID stored in the domain policy */ + if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid)) + return NT_STATUS_INVALID_HANDLE; + + /* append the user's RID to it */ + if(!sid_append_rid(&sid, q_u->user_rid)) + return NT_STATUS_NO_SUCH_USER; + pdb_init_sam(&sampass); become_root(); - ret=pdb_getsampwrid(sampass, user_rid); + ret=pdb_getsampwsid(sampass, &sid); unbecome_root(); - /* check that the RID exists in our domain. */ + /* check that the SID exists in our domain. */ if (ret == False) { pdb_free_sam(&sampass); return NT_STATUS_NO_SUCH_USER; @@ -1415,14 +1422,6 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN pdb_free_sam(&sampass); - /* Get the domain SID stored in the domain policy */ - if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid)) - return NT_STATUS_INVALID_HANDLE; - - /* append the user's RID to it */ - if(!sid_append_rid(&sid, user_rid)) - return NT_STATUS_NO_SUCH_USER; - /* associate the user's SID with the new handle. */ if ((info = get_samr_info_by_sid(&sid)) == NULL) return NT_STATUS_NO_MEMORY; @@ -1438,7 +1437,7 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN get_user_info_10. Safe. Only gives out acb bits. *************************************************************************/ -static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) +static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, DOM_SID *user_sid) { SAM_ACCOUNT *smbpass=NULL; BOOL ret; @@ -1446,11 +1445,11 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) pdb_init_sam(&smbpass); become_root(); - ret = pdb_getsampwrid(smbpass, user_rid); + ret = pdb_getsampwsid(smbpass, user_sid); unbecome_root(); if (ret==False) { - DEBUG(4,("User 0x%x not found\n", user_rid)); + DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); pdb_free_sam(&smbpass); return False; } @@ -1471,7 +1470,7 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) user. JRA. *************************************************************************/ -static NTSTATUS get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint32 user_rid) +static NTSTATUS get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, DOM_SID *user_sid) { SAM_ACCOUNT *smbpass=NULL; BOOL ret; @@ -1487,10 +1486,10 @@ static NTSTATUS get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint3 */ pdb_init_sam(&smbpass); - ret = pdb_getsampwrid(smbpass, user_rid); + ret = pdb_getsampwsid(smbpass, user_sid); if (ret == False) { - DEBUG(4, ("User 0x%x not found\n", user_rid)); + DEBUG(4, ("User %s not found\n", sid_string_static(user_sid))); pdb_free_sam(&smbpass); return (geteuid() == (uid_t)0) ? NT_STATUS_NO_SUCH_USER : NT_STATUS_ACCESS_DENIED; } @@ -1514,7 +1513,7 @@ static NTSTATUS get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint3 get_user_info_20 *************************************************************************/ -static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, uint32 user_rid) +static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, DOM_SID *user_sid) { SAM_ACCOUNT *sampass=NULL; BOOL ret; @@ -1522,11 +1521,11 @@ static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, uint32 user_rid) pdb_init_sam(&sampass); become_root(); - ret = pdb_getsampwrid(sampass, user_rid); + ret = pdb_getsampwsid(sampass, user_sid); unbecome_root(); if (ret == False) { - DEBUG(4,("User 0x%x not found\n", user_rid)); + DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); pdb_free_sam(&sampass); return False; } @@ -1547,7 +1546,7 @@ static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, uint32 user_rid) get_user_info_21 *************************************************************************/ -static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) +static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, DOM_SID *user_sid) { SAM_ACCOUNT *sampass=NULL; BOOL ret; @@ -1555,11 +1554,11 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) pdb_init_sam(&sampass); become_root(); - ret = pdb_getsampwrid(sampass, user_rid); + ret = pdb_getsampwsid(sampass, user_sid); unbecome_root(); if (ret == False) { - DEBUG(4,("User 0x%x not found\n", user_rid)); + DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); pdb_free_sam(&sampass); return False; } @@ -1583,7 +1582,6 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_QUERY_USERINFO *r_u) { SAM_USERINFO_CTR *ctr; - uint32 rid = 0; struct samr_info *info = NULL; r_u->status=NT_STATUS_OK; @@ -1595,9 +1593,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ if (!sid_check_is_in_our_domain(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - sid_peek_rid(&info->sid, &rid); - - DEBUG(5,("_samr_query_userinfo: rid:0x%x\n", rid)); + DEBUG(5,("_samr_query_userinfo: sid:%s\n", sid_string_static(&info->sid))); ctr = (SAM_USERINFO_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_USERINFO_CTR)); if (!ctr) @@ -1614,7 +1610,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ if (ctr->info.id10 == NULL) return NT_STATUS_NO_MEMORY; - if (!get_user_info_10(ctr->info.id10, rid)) + if (!get_user_info_10(ctr->info.id10, &info->sid)) return NT_STATUS_NO_SUCH_USER; break; @@ -1649,7 +1645,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ if (ctr->info.id12 == NULL) return NT_STATUS_NO_MEMORY; - if (NT_STATUS_IS_ERR(r_u->status = get_user_info_12(p, ctr->info.id12, rid))) + if (NT_STATUS_IS_ERR(r_u->status = get_user_info_12(p, ctr->info.id12, &info->sid))) return r_u->status; break; @@ -1657,7 +1653,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ ctr->info.id20 = (SAM_USER_INFO_20 *)talloc_zero(p->mem_ctx,sizeof(SAM_USER_INFO_20)); if (ctr->info.id20 == NULL) return NT_STATUS_NO_MEMORY; - if (!get_user_info_20(ctr->info.id20, rid)) + if (!get_user_info_20(ctr->info.id20, &info->sid)) return NT_STATUS_NO_SUCH_USER; break; @@ -1665,7 +1661,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ 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)) + if (!get_user_info_21(ctr->info.id21, &info->sid)) return NT_STATUS_NO_SUCH_USER; break; @@ -1689,7 +1685,6 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S SAM_ACCOUNT *sam_pass=NULL; DOM_GID *gids = NULL; int num_groups = 0; - uint32 rid; struct samr_info *info = NULL; BOOL ret; @@ -1716,12 +1711,10 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S if (!sid_check_is_in_our_domain(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - sid_peek_rid(&info->sid, &rid); - pdb_init_sam(&sam_pass); become_root(); - ret = pdb_getsampwrid(sam_pass, rid); + ret = pdb_getsampwsid(sam_pass, &info->sid); unbecome_root(); if (ret == False) { @@ -2223,14 +2216,14 @@ NTSTATUS _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OP set_user_info_10 ********************************************************************/ -static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, uint32 rid) +static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, DOM_SID *sid) { SAM_ACCOUNT *pwd =NULL; BOOL ret; pdb_init_sam(&pwd); - ret = pdb_getsampwrid(pwd, rid); + ret = pdb_getsampwsid(pwd, sid); if(ret==False) { pdb_free_sam(&pwd); @@ -2262,13 +2255,13 @@ static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, uint32 rid) set_user_info_12 ********************************************************************/ -static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, uint32 rid) +static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, DOM_SID *sid) { SAM_ACCOUNT *pwd = NULL; pdb_init_sam(&pwd); - if(!pdb_getsampwrid(pwd, rid)) { + if(!pdb_getsampwsid(pwd, sid)) { pdb_free_sam(&pwd); return False; } @@ -2305,7 +2298,7 @@ static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, uint32 rid) set_user_info_21 ********************************************************************/ -static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) +static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, DOM_SID *sid) { SAM_ACCOUNT *pwd = NULL; @@ -2316,7 +2309,7 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) pdb_init_sam(&pwd); - if (!pdb_getsampwrid(pwd, rid)) { + if (!pdb_getsampwsid(pwd, sid)) { pdb_free_sam(&pwd); return False; } @@ -2345,7 +2338,7 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) set_user_info_23 ********************************************************************/ -static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) +static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) { SAM_ACCOUNT *pwd = NULL; pstring plaintext_buf; @@ -2359,7 +2352,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) pdb_init_sam(&pwd); - if (!pdb_getsampwrid(pwd, rid)) { + if (!pdb_getsampwsid(pwd, sid)) { pdb_free_sam(&pwd); return False; } @@ -2412,7 +2405,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) set_user_info_pw ********************************************************************/ -static BOOL set_user_info_pw(char *pass, uint32 rid) +static BOOL set_user_info_pw(char *pass, DOM_SID *sid) { SAM_ACCOUNT *pwd = NULL; uint32 len; @@ -2421,7 +2414,7 @@ static BOOL set_user_info_pw(char *pass, uint32 rid) pdb_init_sam(&pwd); - if (!pdb_getsampwrid(pwd, rid)) { + if (!pdb_getsampwsid(pwd, sid)) { pdb_free_sam(&pwd); return False; } @@ -2480,7 +2473,6 @@ static BOOL set_user_info_pw(char *pass, uint32 rid) NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_USERINFO *r_u) { - uint32 rid = 0x0; DOM_SID sid; POLICY_HND *pol = &q_u->pol; uint16 switch_value = q_u->switch_value; @@ -2494,9 +2486,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE if (!get_lsa_policy_samr_sid(p, pol, &sid)) return NT_STATUS_INVALID_HANDLE; - sid_split_rid(&sid, &rid); - - DEBUG(5, ("_samr_set_userinfo: rid:0x%x, level:%d\n", rid, switch_value)); + DEBUG(5, ("_samr_set_userinfo: sid:%s, level:%d\n", sid_string_static(&sid), switch_value)); if (ctr == NULL) { DEBUG(5, ("_samr_set_userinfo: NULL info level\n")); @@ -2506,7 +2496,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { case 0x12: - if (!set_user_info_12(ctr->info.id12, rid)) + if (!set_user_info_12(ctr->info.id12, &sid)) return NT_STATUS_ACCESS_DENIED; break; @@ -2515,7 +2505,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE 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, &sid)) return NT_STATUS_ACCESS_DENIED; break; @@ -2533,7 +2523,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE dump_data(100, (char *)ctr->info.id25->pass, 532); - if (!set_user_info_pw(ctr->info.id25->pass, rid)) + if (!set_user_info_pw(ctr->info.id25->pass, &sid)) return NT_STATUS_ACCESS_DENIED; break; #endif @@ -2544,7 +2534,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE dump_data(100, (char *)ctr->info.id23->pass, 516); - if (!set_user_info_23(ctr->info.id23, rid)) + if (!set_user_info_23(ctr->info.id23, &sid)) return NT_STATUS_ACCESS_DENIED; break; @@ -2562,7 +2552,6 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SET_USERINFO2 *r_u) { DOM_SID sid; - uint32 rid = 0x0; SAM_USERINFO_CTR *ctr = q_u->ctr; POLICY_HND *pol = &q_u->pol; uint16 switch_value = q_u->switch_value; @@ -2575,9 +2564,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, pol, &sid)) return NT_STATUS_INVALID_HANDLE; - sid_split_rid(&sid, &rid); - - DEBUG(5, ("samr_reply_set_userinfo2: rid:0x%x\n", rid)); + DEBUG(5, ("samr_reply_set_userinfo2: sid:%s\n", sid_string_static(&sid))); if (ctr == NULL) { DEBUG(5, ("samr_reply_set_userinfo2: NULL info level\n")); @@ -2589,16 +2576,16 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { case 21: - if (!set_user_info_21(ctr->info.id21, rid)) + if (!set_user_info_21(ctr->info.id21, &sid)) return NT_STATUS_ACCESS_DENIED; break; case 16: - if (!set_user_info_10(ctr->info.id10, rid)) + if (!set_user_info_10(ctr->info.id10, &sid)) return NT_STATUS_ACCESS_DENIED; break; case 18: /* Used by AS/U JRA. */ - if (!set_user_info_12(ctr->info.id12, rid)) + if (!set_user_info_12(ctr->info.id12, &sid)) return NT_STATUS_ACCESS_DENIED; break; default: @@ -2886,7 +2873,6 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD struct passwd *pwd; struct group *grp; fstring grp_name; - uint32 rid; GROUP_MAP map; NTSTATUS ret; SAM_ACCOUNT *sam_user = NULL; @@ -2914,13 +2900,11 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD return NT_STATUS_NO_SUCH_ALIAS; } - sid_split_rid(&q_u->sid.sid, &rid); - ret = pdb_init_sam(&sam_user); if (NT_STATUS_IS_ERR(ret)) return ret; - check = pdb_getsampwrid(sam_user, rid); + check = pdb_getsampwsid(sam_user, &q_u->sid.sid); if (check != True) { pdb_free_sam(&sam_user); @@ -2974,7 +2958,6 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE fstring alias_sid_str; struct group *grp; fstring grp_name; - uint32 rid; GROUP_MAP map; SAM_ACCOUNT *sam_pass=NULL; @@ -3000,11 +2983,9 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE /* we need to copy the name otherwise it's overloaded in user_in_group_list */ fstrcpy(grp_name, grp->gr_name); - sid_peek_rid(&q_u->sid.sid, &rid); - /* check if the user exists before trying to remove it from the group */ pdb_init_sam(&sam_pass); - if(!pdb_getsampwrid(sam_pass, rid)) { + if(!pdb_getsampwsid(sam_pass, &q_u->sid.sid)) { DEBUG(5,("_samr_del_aliasmem:User %s doesn't exist.\n", pdb_get_username(sam_pass))); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; @@ -3035,6 +3016,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_ADD_GROUPMEM *r_u) { DOM_SID group_sid; + DOM_SID user_sid; fstring group_sid_str; struct passwd *pwd; struct group *grp; @@ -3060,11 +3042,14 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_GROUP; + sid_copy(&user_sid, &global_sam_sid); + sid_append_rid(&user_sid, q_u->rid); + ret = pdb_init_sam(&sam_user); if (NT_STATUS_IS_ERR(ret)) return ret; - check = pdb_getsampwrid(sam_user, q_u->rid); + check = pdb_getsampwsid(sam_user, &user_sid); if (check != True) { pdb_free_sam(&sam_user); @@ -3117,8 +3102,8 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DEL_GROUPMEM *r_u) { DOM_SID group_sid; + DOM_SID user_sid; SAM_ACCOUNT *sam_pass=NULL; - uint32 rid; GROUP_MAP map; fstring grp_name; struct group *grp; @@ -3136,7 +3121,8 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE if(!sid_check_is_in_our_domain(&group_sid)) return NT_STATUS_NO_SUCH_GROUP; - rid=q_u->rid; + sid_copy(&user_sid, &global_sam_sid); + sid_append_rid(&user_sid, q_u->rid); if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_GROUP; @@ -3149,7 +3135,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE /* check if the user exists before trying to remove it from the group */ pdb_init_sam(&sam_pass); - if(!pdb_getsampwrid(sam_pass, rid)) { + if(!pdb_getsampwsid(sam_pass, &user_sid)) { DEBUG(5,("User %s doesn't exist.\n", pdb_get_username(sam_pass))); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; @@ -3200,7 +3186,6 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM { DOM_SID user_sid; SAM_ACCOUNT *sam_pass=NULL; - uint32 rid; DEBUG(5, ("_samr_delete_dom_user: %d\n", __LINE__)); @@ -3211,11 +3196,9 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM if (!sid_check_is_in_our_domain(&user_sid)) return NT_STATUS_CANNOT_DELETE; - sid_peek_rid(&user_sid, &rid); - /* check if the user exists before trying to delete */ pdb_init_sam(&sam_pass); - if(!pdb_getsampwrid(sam_pass, rid)) { + if(!pdb_getsampwsid(sam_pass, &user_sid)) { DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n", pdb_get_username(sam_pass))); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 53bbebb95e..af653ba0e8 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -114,11 +114,9 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui DEBUG(10,("get_alias_user_groups: looking if SID %s is a member of groups in the SID domain %s\n", sid_to_string(str_qsid, q_sid), sid_to_string(str_domsid, sid))); - sid_peek_rid(q_sid, &rid); - pdb_init_sam(&sam_pass); become_root(); - ret = pdb_getsampwrid(sam_pass, rid); + ret = pdb_getsampwsid(sam_pass, q_sid); unbecome_root(); if (ret == False) { pdb_free_sam(&sam_pass); @@ -404,6 +402,8 @@ NTSTATUS local_lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) return NT_STATUS_NONE_MAPPED; } + +#if 0 /*Nobody uses this function just now*/ /******************************************************************* Look up a local user rid and return a name and type. ********************************************************************/ @@ -448,6 +448,8 @@ NTSTATUS local_lookup_user_name(uint32 rid, char *user_name, uint32 *type) return NT_STATUS_NONE_MAPPED; } +#endif + /******************************************************************* Look up a local (domain) group name and return a rid ********************************************************************/ -- cgit From 43b35364ffda5c779452fb41c015b280fefc6ab6 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 29 May 2002 00:49:26 +0000 Subject: Cleaned up srvsvc constants a bit. (This used to be commit ca61f68d5ca8791bea34732bd358cfb63273fc5c) --- source3/rpc_server/srv_srvsvc.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index ee4ec8aa0a..b09df1e204 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -494,23 +494,23 @@ static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) struct api_struct api_srv_cmds[] = { - { "SRV_NETCONNENUM" , SRV_NETCONNENUM , api_srv_net_conn_enum }, - { "SRV_NETSESSENUM" , SRV_NETSESSENUM , api_srv_net_sess_enum }, - { "SRV_NETSHAREENUM_ALL" , SRV_NETSHAREENUM_ALL , api_srv_net_share_enum_all }, - { "SRV_NETSHAREENUM" , SRV_NETSHAREENUM , api_srv_net_share_enum }, - { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, - { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del }, - { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info }, - { "SRV_NET_SHARE_SET_INFO", SRV_NET_SHARE_SET_INFO, api_srv_net_share_set_info }, - { "SRV_NETFILEENUM" , SRV_NETFILEENUM , api_srv_net_file_enum }, - { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, - { "SRV_NET_SRV_SET_INFO" , SRV_NET_SRV_SET_INFO , api_srv_net_srv_set_info }, - { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, - { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, - { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate}, - { "SRV_NETFILEQUERYSECDESC",SRV_NETFILEQUERYSECDESC,api_srv_net_file_query_secdesc}, - { "SRV_NETFILESETSECDESC" , SRV_NETFILESETSECDESC , api_srv_net_file_set_secdesc}, - { NULL , 0 , NULL } + { "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum }, + { "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum }, + { "SRV_NET_SHARE_ENUM_ALL" , SRV_NET_SHARE_ENUM_ALL , api_srv_net_share_enum_all }, + { "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum }, + { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, + { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del }, + { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info }, + { "SRV_NET_SHARE_SET_INFO", SRV_NET_SHARE_SET_INFO, api_srv_net_share_set_info }, + { "SRV_NET_FILE_ENUM" , SRV_NET_FILE_ENUM , api_srv_net_file_enum }, + { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, + { "SRV_NET_SRV_SET_INFO" , SRV_NET_SRV_SET_INFO , api_srv_net_srv_set_info }, + { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, + { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, + { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate}, + { "SRV_NET_FILE_QUERY_SECDESC",SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc}, + { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc}, + { NULL , 0 , NULL } }; /******************************************************************* -- cgit From c3fb0cd9edd8944d7278cb716b52fbf16939f044 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 31 May 2002 00:48:40 +0000 Subject: Return access denied for net_share_enum when restrict anonymous > 0 (This used to be commit 5df1aa9f20ae2036848b7e46703bfd3a923d7b4f) --- source3/rpc_server/srv_srvsvc_nt.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 1f3b1945e3..f14928f9f2 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -564,8 +564,25 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, 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) { + user_struct *user; + DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__)); + /* Don't let anonymous users access this RPC */ + + if (!(user = get_valid_user_struct(p->vuid))) { + DEBUG(3, ("invalid vuid %d in init_srv_r_net_share_enum()\n", + p->vuid)); + r_n->status = WERR_ACCESS_DENIED; + return; + } + + if (lp_restrict_anonymous() > 0 && user->guest) { + DEBUG(5, ("access denied to anonymous connection")); + r_n->status = WERR_ACCESS_DENIED; + return; + } + if (init_srv_share_info_ctr(p, &r_n->ctr, info_level, &resume_hnd, &r_n->total_entries, all)) { r_n->status = WERR_OK; -- cgit From e422b271da0c07f5c5cfd41df01bb2910d484abc Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 31 May 2002 17:02:09 +0000 Subject: Update netfileenum on both client and server sides to do an arbitrary number of files. This was done to better enable net rpc file. Perhaps we can start giving back real info this way, too. (This used to be commit b3fea72ee9abd2441a49c35442c54819e4ba16ba) --- source3/rpc_server/srv_srvsvc_nt.c | 88 ++++++++++++-------------------------- 1 file changed, 27 insertions(+), 61 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index f14928f9f2..967c7a8747 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -958,74 +958,46 @@ static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, init_enum_hnd(&r_n->enum_hnd, resume_hnd); } -/******************************************************************* - fill in a file info level 3 structure. - ********************************************************************/ - -static void init_srv_file_3_info(FILE_INFO_3 *fl3, FILE_INFO_3_STR *str3, - uint32 fnum, uint32 perms, uint32 num_locks, - char *path_name, char *user_name) -{ - init_srv_file_info3(fl3 , fnum, perms, num_locks, path_name, user_name); - init_srv_file_info3_str(str3, path_name, user_name); -} - -/******************************************************************* - fill in a file info level 3 structure. - ********************************************************************/ - -static void init_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *ftot) -{ - uint32 num_entries = 0; - (*ftot) = 1; - - if (fl3 == NULL) { - (*fnum) = 0; - return; - } - - DEBUG(5,("init_srv_file_3_fl3\n")); - - for (; (*fnum) < (*ftot) && num_entries < MAX_FILE_ENTRIES; (*fnum)++) { - init_srv_file_3_info(&fl3->info_3[num_entries], - &fl3->info_3_str[num_entries], - (*fnum), 0x35, 0, "\\PIPE\\samr", "dummy user"); - - /* move on to creating next file */ - num_entries++; - } - - fl3->num_entries_read = num_entries; - fl3->ptr_file_info = num_entries > 0 ? 1 : 0; - fl3->num_entries_read2 = num_entries; - - if ((*fnum) >= (*ftot)) { - (*fnum) = 0; - } -} - /******************************************************************* makes a SRV_R_NET_FILE_ENUM structure. ********************************************************************/ -static WERROR init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, +static WERROR init_srv_file_info_ctr(pipes_struct *p, SRV_FILE_INFO_CTR *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { WERROR status = WERR_OK; + TALLOC_CTX *ctx = p->mem_ctx; DEBUG(5,("init_srv_file_info_ctr: %d\n", __LINE__)); + *total_entries = 1; /* dummy entries only, for */ ctr->switch_value = switch_value; + ctr->num_entries = *total_entries - *resume_hnd; + if (ctr->num_entries < 0) + ctr->num_entries = 0; + ctr->num_entries2 = ctr->num_entries; switch (switch_value) { - case 3: - init_srv_file_info_3(&ctr->file.info3, resume_hnd, total_entries); - ctr->ptr_file_ctr = 1; + case 3: { + int i; + if (total_entries > 0) { + ctr->ptr_entries = 1; + ctr->file.info3 = talloc(ctx, ctr->num_entries * + sizeof(SRV_FILE_INFO_3)); + } + for (i=0 ;inum_entries;i++) { + init_srv_file_info3(&ctr->file.info3[i].info_3, i+*resume_hnd, 0x35, 0, "\\PIPE\\samr", "dummy user"); + init_srv_file_info3_str(&ctr->file.info3[i].info_3_str, "\\PIPE\\samr", "dummy user"); + + } + ctr->ptr_file_info = 1; + *resume_hnd = 0; break; + } default: DEBUG(5,("init_srv_file_info_ctr: unsupported switch value %d\n", switch_value)); (*resume_hnd = 0); (*total_entries) = 0; - ctr->ptr_file_ctr = 0; + ctr->ptr_entries = 0; status = WERR_UNKNOWN_LEVEL; break; } @@ -1037,7 +1009,7 @@ static WERROR init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, makes a SRV_R_NET_FILE_ENUM structure. ********************************************************************/ -static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n, +static void init_srv_r_net_file_enum(pipes_struct *p, SRV_R_NET_FILE_ENUM *r_n, uint32 resume_hnd, int file_level, int switch_value) { DEBUG(5,("init_srv_r_net_file_enum: %d\n", __LINE__)); @@ -1046,7 +1018,7 @@ static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n, if (file_level == 0) r_n->status = WERR_UNKNOWN_LEVEL; else - r_n->status = init_srv_file_info_ctr(r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries)); + r_n->status = init_srv_file_info_ctr(p, &r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries)); if (!W_ERROR_IS_OK(r_n->status)) resume_hnd = 0; @@ -1133,19 +1105,13 @@ net file enum WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) { - r_u->ctr = (SRV_FILE_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_FILE_INFO_CTR)); - if (!r_u->ctr) - return WERR_NOMEM; - - ZERO_STRUCTP(r_u->ctr); - DEBUG(5,("srv_net_file_enum: %d\n", __LINE__)); /* set up the */ - init_srv_r_net_file_enum(r_u, + init_srv_r_net_file_enum(p, r_u, get_enum_hnd(&q_u->enum_hnd), q_u->file_level, - q_u->ctr->switch_value); + q_u->ctr.switch_value); DEBUG(5,("srv_net_file_enum: %d\n", __LINE__)); -- cgit From d706b5dc555bd61670359955770cb85ed0ce2896 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 3 Jun 2002 02:55:16 +0000 Subject: Move restrict anonymous checks into a general function called pipe_access_check(). Eventually this can take a security descriptor as an argument as well. (This used to be commit 8bbdc674afef32621bf473ba1af76bae7270b818) --- source3/rpc_server/srv_lsa_hnd.c | 28 +++++++++++++++++++++++++++ source3/rpc_server/srv_srvsvc_nt.c | 39 ++++++++++++++++++++------------------ 2 files changed, 49 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 62af0ecac8..5af1e8c265 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -249,3 +249,31 @@ void close_policy_by_pipe(pipes_struct *p) DEBUG(10,("close_policy_by_pipe: deleted handle list for pipe %s\n", p->name )); } } + +/******************************************************************* +Shall we allow access to this rpc? Currently this function +implements the 'restrict anonymous' setting by denying access to +anonymous users if the restrict anonymous level is > 0. Further work +will be checking a security descriptor to determine whether a user +token has enough access to access the pipe. +********************************************************************/ + +BOOL pipe_access_check(pipes_struct *p) +{ + /* Don't let anonymous users access this RPC if restrict + anonymous > 0 */ + + if (lp_restrict_anonymous() > 0) { + user_struct *user = get_valid_user_struct(p->vuid); + + if (!user) { + DEBUG(3, ("invalid vuid %d\n", p->vuid)); + return False; + } + + if (user->guest) + return False; + } + + return True; +} diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 967c7a8747..8965b11fe5 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -564,25 +564,8 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, 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) { - user_struct *user; - DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__)); - /* Don't let anonymous users access this RPC */ - - if (!(user = get_valid_user_struct(p->vuid))) { - DEBUG(3, ("invalid vuid %d in init_srv_r_net_share_enum()\n", - p->vuid)); - r_n->status = WERR_ACCESS_DENIED; - return; - } - - if (lp_restrict_anonymous() > 0 && user->guest) { - DEBUG(5, ("access denied to anonymous connection")); - r_n->status = WERR_ACCESS_DENIED; - return; - } - if (init_srv_share_info_ctr(p, &r_n->ctr, info_level, &resume_hnd, &r_n->total_entries, all)) { r_n->status = WERR_OK; @@ -1042,11 +1025,21 @@ WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to srv_net_srv_get_info\n")); + return WERR_ACCESS_DENIED; + } + switch (q_u->switch_value) { + + /* Technically level 102 should only be available to + Administrators but there isn't anything super-secret + here, as most of it is made up. */ + case 102: init_srv_info_102(&ctr->srv.sv102, 500, global_myname, - string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), + string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), lp_major_announce_version(), lp_minor_announce_version(), lp_default_server_announce(), 0xffffffff, /* users */ @@ -1176,6 +1169,11 @@ WERROR _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__)); + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to srv_net_share_enum_all\n")); + return WERR_ACCESS_DENIED; + } + /* Create the list of shares for the response. */ init_srv_r_net_share_enum(p, r_u, q_u->ctr.info_level, @@ -1194,6 +1192,11 @@ WERROR _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__)); + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to srv_net_share_enum\n")); + return WERR_ACCESS_DENIED; + } + /* Create the list of shares for the response. */ init_srv_r_net_share_enum(p, r_u, q_u->ctr.info_level, -- cgit From c3bd192703c6a0360f6fa7eef9e13bc32949c5eb Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 3 Jun 2002 03:02:39 +0000 Subject: Restrict anonymous checks for the SAMR pipe. This is done by returning access denied for a SAMR_CONNECT by an anonymous user which seems to be the way 2K does it rather than blocking individual RPC calls like NT. Also checked is the SAMR_GET_DOM_PWINFO rpc which for some reason doesn't require a policy handle to return information. No idea what it's actually used. (This used to be commit 40c68fa85c31c1baf7ba2c8ed62cd06c34711913) --- source3/rpc_server/srv_samr_nt.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7c16bc7128..066a293414 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2026,6 +2026,14 @@ NTSTATUS _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CO { struct samr_info *info = NULL; + /* Access check */ + + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to samr_connect_anon\n")); + r_u->status = NT_STATUS_ACCESS_DENIED; + return r_u->status; + } + /* set up the SAMR connect_anon response */ r_u->status = NT_STATUS_OK; @@ -2053,6 +2061,14 @@ NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u DEBUG(5,("_samr_connect: %d\n", __LINE__)); + /* Access check */ + + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to samr_connect\n")); + r_u->status = NT_STATUS_ACCESS_DENIED; + return r_u->status; + } + r_u->status = NT_STATUS_OK; /* associate the user's SID with the new handle. */ @@ -3594,7 +3610,18 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ NTSTATUS _samr_get_dom_pwinfo(pipes_struct *p, SAMR_Q_GET_DOM_PWINFO *q_u, SAMR_R_GET_DOM_PWINFO *r_u) { + /* Perform access check. Since this rpc does not require a + policy handle it will not be caught by the access checks on + SAMR_CONNECT or SAMR_CONNECT_ANON. */ + + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to samr_get_dom_pwinfo\n")); + r_u->status = NT_STATUS_ACCESS_DENIED; + return r_u->status; + } + /* Actually, returning zeros here works quite well :-). */ + return NT_STATUS_OK; } -- cgit From e142b4b324db501ec6a0d078c541aa3f5d9e185b Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Mon, 3 Jun 2002 22:14:43 +0000 Subject: Fix netsessenum RPC. Correctly respond with as much info as we can. (This used to be commit c8781a3fdaa4d8cb81233582f29159ace7e436ac) --- source3/rpc_server/srv_srvsvc_nt.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 8965b11fe5..f99827ea19 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -638,11 +638,13 @@ static void init_srv_sess_0_info(SESS_INFO_0 *se0, SESS_INFO_0_STR *str0, char * static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot) { + struct sessionid *session_list; uint32 num_entries = 0; - (*stot) = 1; + (*stot) = list_sessions(&session_list); if (ss0 == NULL) { (*snum) = 0; + SAFE_FREE(session_list); return; } @@ -651,7 +653,7 @@ static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *sto if (snum) { for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { init_srv_sess_0_info(&ss0->info_0[num_entries], - &ss0->info_0_str[num_entries], "MACHINE"); + &ss0->info_0_str[num_entries], session_list[(*snum)].remote_machine); /* move on to creating next session */ /* move on to creating next sess */ @@ -671,6 +673,7 @@ static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *sto ss0->ptr_sess_info = 0; ss0->num_entries_read2 = 0; } + SAFE_FREE(session_list); } /******************************************************************* @@ -693,11 +696,13 @@ static void init_srv_sess_1_info(SESS_INFO_1 *se1, SESS_INFO_1_STR *str1, static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot) { + struct sessionid *session_list; uint32 num_entries = 0; - (*stot) = 1; + (*stot) = list_sessions(&session_list); if (ss1 == NULL) { (*snum) = 0; + SAFE_FREE(session_list); return; } @@ -706,8 +711,10 @@ static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto if (snum) { for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { init_srv_sess_1_info(&ss1->info_1[num_entries], - &ss1->info_1_str[num_entries], - "MACHINE", "dummy_user", 1, 10, 5, 0); + &ss1->info_1_str[num_entries], + session_list[*snum].remote_machine, + session_list[*snum].username, + 1, 10, 5, 0); /* move on to creating next session */ /* move on to creating next sess */ -- cgit From ebe58d85692ee5a8088762908ffaeb3e19ff45f3 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 4 Jun 2002 23:10:02 +0000 Subject: Update the SAMR pipe for more use of NTSTATUS and to talloc the stored list of users/groups for better memory accounting. Andrew Bartlett (This used to be commit fe7c5efe91ab77784af9dbb56716170f4c6fd057) --- source3/rpc_server/srv_samr_nt.c | 237 +++++++++++++++++++++++---------------- 1 file changed, 141 insertions(+), 96 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 066a293414..71b48210e4 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -53,6 +53,8 @@ struct samr_info { DOM_SID sid; uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ DISP_INFO disp_info; + + TALLOC_CTX *mem_ctx; }; /******************************************************************* @@ -63,17 +65,27 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) { struct samr_info *info; fstring sid_str; + TALLOC_CTX *mem_ctx; + + if (psid) { + sid_to_string(sid_str, psid); + } else { + fstrcpy(sid_str,"(NULL)"); + } + + mem_ctx = talloc_init_named("samr_info for domain sid %s", sid_str); - if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) + if ((info = (struct samr_info *)talloc(mem_ctx, sizeof(struct samr_info))) == NULL) return NULL; ZERO_STRUCTP(info); + DEBUG(10,("get_samr_info_by_sid: created new info for sid %s\n", sid_str)); if (psid) { - DEBUG(10,("get_samr_info_by_sid: created new info for sid %s\n", sid_to_string(sid_str, psid) )); sid_copy( &info->sid, psid); } else { DEBUG(10,("get_samr_info_by_sid: created new info for NULL sid.\n")); } + info->mem_ctx = mem_ctx; return info; } @@ -84,18 +96,13 @@ static void free_samr_db(struct samr_info *info) { int i; - if (info->disp_info.group_dbloaded) { - for (i=0; idisp_info.num_group_account; i++) - SAFE_FREE(info->disp_info.disp_group_info[i].grp); - - SAFE_FREE(info->disp_info.disp_group_info); - } + /* Groups are talloced */ if (info->disp_info.user_dbloaded){ - for (i=0; idisp_info.num_user_account; i++) + for (i=0; idisp_info.num_user_account; i++) { + /* Not really a free, actually a 'clear' */ pdb_free_sam(&info->disp_info.disp_user_info[i].sam); - - SAFE_FREE(info->disp_info.disp_user_info); + } } info->disp_info.user_dbloaded=False; @@ -110,7 +117,7 @@ static void free_samr_info(void *ptr) struct samr_info *info=(struct samr_info *) ptr; free_samr_db(info); - SAFE_FREE(info); + talloc_destroy(info->mem_ctx); } /******************************************************************* @@ -147,6 +154,8 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) { SAM_ACCOUNT *pwd = NULL; DISP_USER_INFO *pwd_array = NULL; + NTSTATUS nt_status = NT_STATUS_OK; + TALLOC_CTX *mem_ctx = info->mem_ctx; DEBUG(10,("load_sampwd_entries\n")); @@ -161,7 +170,8 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) return NT_STATUS_ACCESS_DENIED; } - for (pdb_init_sam(&pwd); pdb_getsampwent(pwd) == True; pwd=NULL, pdb_init_sam(&pwd) ) { + for (; (NT_STATUS_IS_OK(nt_status = pdb_init_sam_talloc(mem_ctx, &pwd))) + && pdb_getsampwent(pwd) == True; pwd=NULL) { if (acb_mask != 0 && !(pdb_get_acct_ctrl(pwd) & acb_mask)) { pdb_free_sam(&pwd); @@ -173,7 +183,7 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) if (info->disp_info.num_user_account % MAX_SAM_ENTRIES == 0) { DEBUG(10,("load_sampwd_entries: allocating more memory\n")); - pwd_array=(DISP_USER_INFO *)Realloc(info->disp_info.disp_user_info, + pwd_array=(DISP_USER_INFO *)talloc_realloc(mem_ctx, info->disp_info.disp_user_info, (info->disp_info.num_user_account+MAX_SAM_ENTRIES)*sizeof(DISP_USER_INFO)); if (pwd_array==NULL) @@ -198,7 +208,7 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) DEBUG(12,("load_sampwd_entries: done\n")); - return NT_STATUS_OK; + return nt_status; } static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) @@ -207,6 +217,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) DISP_GROUP_INFO *grp_array = NULL; uint32 group_entries = 0; uint32 i; + TALLOC_CTX *mem_ctx = info->mem_ctx; DEBUG(10,("load_group_domain_entries\n")); @@ -220,7 +231,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) info->disp_info.num_group_account=group_entries; - grp_array=(DISP_GROUP_INFO *)malloc(info->disp_info.num_group_account*sizeof(DISP_GROUP_INFO)); + grp_array=(DISP_GROUP_INFO *)talloc(mem_ctx, info->disp_info.num_group_account*sizeof(DISP_GROUP_INFO)); if (group_entries!=0 && grp_array==NULL) { SAFE_FREE(map); @@ -231,7 +242,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) for (i=0; iname, map[i].nt_name); fstrcpy(grp_array[i].grp->comment, map[i].comment); @@ -262,14 +273,17 @@ static NTSTATUS get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, { SAM_ACCOUNT *pwd = NULL; BOOL not_finished = True; - + NTSTATUS nt_status; + (*num_entries) = 0; (*total_entries) = 0; if (pw_buf == NULL) return NT_STATUS_NO_MEMORY; - pdb_init_sam(&pwd); + if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&pwd))) { + return nt_status; + } if (!pdb_setsampwent(False)) { DEBUG(0, ("get_sampwd_entries: Unable to open passdb.\n")); @@ -281,10 +295,16 @@ static NTSTATUS get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, && (*num_entries) < max_num_entries) { int user_name_len; - + const char *user_name; + if (start_idx > 0) { - pdb_reset_sam(pwd); + pdb_free_sam(&pwd); + + if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&pwd))) { + pdb_endsampwent(); + return nt_status; + } /* skip the requested number of entries. not very efficient, but hey... */ @@ -292,31 +312,41 @@ static NTSTATUS get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx, continue; } - 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 = 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 (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); - - 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 || (pdb_get_acct_ctrl(pwd) & acb_mask)) { + user_name = pdb_get_username(pwd); + + if (!user_name) { + DEBUG(2, ("account had NULL username!\n")); + } else if (!(acb_mask == 0 || (pdb_get_acct_ctrl(pwd) & acb_mask))) { + DEBUG(5,(" acb_mask %x rejects\n", acb_mask)); + } else { DEBUG(5,(" acb_mask %x accepts\n", acb_mask)); + + user_name_len = strlen(user_name)+1; + init_unistr2(&pw_buf[(*num_entries)].uni_user_name, user_name, user_name_len); + init_uni_hdr(&pw_buf[(*num_entries)].hdr_user_name, user_name_len); + 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 (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); + + 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) )); + (*num_entries)++; - } else { - DEBUG(5,(" acb_mask %x rejects\n", acb_mask)); } (*total_entries)++; - pdb_reset_sam(pwd); + pdb_free_sam(&pwd); + + if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&pwd))) { + pdb_endsampwent(); + return nt_status; + } } @@ -936,7 +966,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ become_root(); r_u->status=load_sampwd_entries(info, acb_mask); unbecome_root(); - if (NT_STATUS_IS_ERR(r_u->status)) { + if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); return r_u->status; } @@ -945,7 +975,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ case 0x3: case 0x5: r_u->status = load_group_domain_entries(info, &info->sid); - if (NT_STATUS_IS_ERR(r_u->status)) + if (!NT_STATUS_IS_OK(r_u->status)) return r_u->status; num_account = info->disp_info.num_group_account; break; @@ -992,7 +1022,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ return NT_STATUS_NO_MEMORY; } disp_ret = init_sam_dispinfo_1(p->mem_ctx, ctr->sam.info1, max_entries, enum_context, info->disp_info.disp_user_info); - if (NT_STATUS_IS_ERR(disp_ret)) + if (!NT_STATUS_IS_OK(disp_ret)) return disp_ret; break; case 0x2: @@ -1001,7 +1031,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ return NT_STATUS_NO_MEMORY; } disp_ret = init_sam_dispinfo_2(p->mem_ctx, ctr->sam.info2, max_entries, enum_context, info->disp_info.disp_user_info); - if (NT_STATUS_IS_ERR(disp_ret)) + if (!NT_STATUS_IS_OK(disp_ret)) return disp_ret; break; case 0x3: @@ -1010,7 +1040,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ return NT_STATUS_NO_MEMORY; } disp_ret = init_sam_dispinfo_3(p->mem_ctx, ctr->sam.info3, max_entries, enum_context, info->disp_info.disp_group_info); - if (NT_STATUS_IS_ERR(disp_ret)) + if (!NT_STATUS_IS_OK(disp_ret)) return disp_ret; break; case 0x4: @@ -1019,7 +1049,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ return NT_STATUS_NO_MEMORY; } disp_ret = init_sam_dispinfo_4(p->mem_ctx, ctr->sam.info4, max_entries, enum_context, info->disp_info.disp_user_info); - if (NT_STATUS_IS_ERR(disp_ret)) + if (!NT_STATUS_IS_OK(disp_ret)) return disp_ret; break; case 0x5: @@ -1028,7 +1058,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ return NT_STATUS_NO_MEMORY; } disp_ret = init_sam_dispinfo_5(p->mem_ctx, ctr->sam.info5, max_entries, enum_context, info->disp_info.disp_group_info); - if (NT_STATUS_IS_ERR(disp_ret)) + if (!NT_STATUS_IS_OK(disp_ret)) return disp_ret; break; @@ -1393,6 +1423,7 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN POLICY_HND *user_pol = &r_u->user_pol; struct samr_info *info = NULL; BOOL ret; + NTSTATUS nt_status; r_u->status = NT_STATUS_OK; @@ -1400,6 +1431,11 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN if (!find_policy_by_hnd(p, &domain_pol, NULL)) return NT_STATUS_INVALID_HANDLE; + nt_status = pdb_init_sam_talloc(p->mem_ctx, &sampass); + if (!NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } + /* Get the domain SID stored in the domain policy */ if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid)) return NT_STATUS_INVALID_HANDLE; @@ -1408,15 +1444,12 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN if(!sid_append_rid(&sid, q_u->user_rid)) return NT_STATUS_NO_SUCH_USER; - pdb_init_sam(&sampass); - become_root(); ret=pdb_getsampwsid(sampass, &sid); unbecome_root(); /* check that the SID exists in our domain. */ if (ret == False) { - pdb_free_sam(&sampass); return NT_STATUS_NO_SUCH_USER; } @@ -1437,12 +1470,17 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN get_user_info_10. Safe. Only gives out acb bits. *************************************************************************/ -static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, DOM_SID *user_sid) +static NTSTATUS get_user_info_10(TALLOC_CTX *mem_ctx, SAM_USER_INFO_10 *id10, DOM_SID *user_sid) { SAM_ACCOUNT *smbpass=NULL; BOOL ret; + NTSTATUS nt_status; - pdb_init_sam(&smbpass); + nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass); + + if (!NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } become_root(); ret = pdb_getsampwsid(smbpass, user_sid); @@ -1450,8 +1488,7 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, DOM_SID *user_sid) if (ret==False) { DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); - pdb_free_sam(&smbpass); - return False; + return NT_STATUS_NO_SUCH_USER; } DEBUG(3,("User:[%s]\n", pdb_get_username(smbpass) )); @@ -1461,7 +1498,7 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, DOM_SID *user_sid) pdb_free_sam(&smbpass); - return True; + return NT_STATUS_OK; } /************************************************************************* @@ -1470,10 +1507,11 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, DOM_SID *user_sid) user. JRA. *************************************************************************/ -static NTSTATUS get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, DOM_SID *user_sid) +static NTSTATUS get_user_info_12(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_INFO_12 * id12, DOM_SID *user_sid) { SAM_ACCOUNT *smbpass=NULL; BOOL ret; + NTSTATUS nt_status; if (!p->ntlmssp_auth_validated) return NT_STATUS_ACCESS_DENIED; @@ -1484,7 +1522,12 @@ static NTSTATUS get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, DOM_S /* * Do *NOT* do become_root()/unbecome_root() here ! JRA. */ - pdb_init_sam(&smbpass); + + nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass); + + if (!NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } ret = pdb_getsampwsid(smbpass, user_sid); @@ -1513,12 +1556,12 @@ static NTSTATUS get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, DOM_S get_user_info_20 *************************************************************************/ -static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, DOM_SID *user_sid) +static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, SAM_USER_INFO_20 *id20, DOM_SID *user_sid) { SAM_ACCOUNT *sampass=NULL; BOOL ret; - pdb_init_sam(&sampass); + pdb_init_sam_talloc(mem_ctx, &sampass); become_root(); ret = pdb_getsampwsid(sampass, user_sid); @@ -1526,8 +1569,7 @@ static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, DOM_SID *user_sid) if (ret == False) { DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); - pdb_free_sam(&sampass); - return False; + return NT_STATUS_NO_SUCH_USER; } samr_clear_sam_passwd(sampass); @@ -1539,19 +1581,23 @@ static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, DOM_SID *user_sid) pdb_free_sam(&sampass); - return True; + return NT_STATUS_OK; } /************************************************************************* get_user_info_21 *************************************************************************/ -static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, DOM_SID *user_sid) +static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, DOM_SID *user_sid) { SAM_ACCOUNT *sampass=NULL; BOOL ret; + NTSTATUS nt_status; - pdb_init_sam(&sampass); + nt_status = pdb_init_sam_talloc(mem_ctx, &sampass); + if (!NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } become_root(); ret = pdb_getsampwsid(sampass, user_sid); @@ -1559,8 +1605,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, DOM_SID *user_sid) if (ret == False) { DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); - pdb_free_sam(&sampass); - return False; + return NT_STATUS_NO_SUCH_USER; } samr_clear_sam_passwd(sampass); @@ -1572,7 +1617,7 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, DOM_SID *user_sid) pdb_free_sam(&sampass); - return True; + return NT_STATUS_OK; } /******************************************************************* @@ -1610,8 +1655,8 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ if (ctr->info.id10 == NULL) return NT_STATUS_NO_MEMORY; - if (!get_user_info_10(ctr->info.id10, &info->sid)) - return NT_STATUS_NO_SUCH_USER; + if (!NT_STATUS_IS_OK(r_u->status = get_user_info_10(p->mem_ctx, ctr->info.id10, &info->sid))) + return r_u->status; break; #if 0 @@ -1645,24 +1690,24 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ if (ctr->info.id12 == NULL) return NT_STATUS_NO_MEMORY; - if (NT_STATUS_IS_ERR(r_u->status = get_user_info_12(p, ctr->info.id12, &info->sid))) + if (!NT_STATUS_IS_OK(r_u->status = get_user_info_12(p, p->mem_ctx, ctr->info.id12, &info->sid))) return r_u->status; break; - + case 20: ctr->info.id20 = (SAM_USER_INFO_20 *)talloc_zero(p->mem_ctx,sizeof(SAM_USER_INFO_20)); if (ctr->info.id20 == NULL) return NT_STATUS_NO_MEMORY; - if (!get_user_info_20(ctr->info.id20, &info->sid)) - return NT_STATUS_NO_SUCH_USER; + if (!NT_STATUS_IS_OK(r_u->status = get_user_info_20(p->mem_ctx, ctr->info.id20, &info->sid))) + return r_u->status; break; case 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, &info->sid)) - return NT_STATUS_NO_SUCH_USER; + if (!NT_STATUS_IS_OK(r_u->status = get_user_info_21(p->mem_ctx, ctr->info.id21, &info->sid))) + return r_u->status; break; default: @@ -1672,7 +1717,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ init_samr_r_query_userinfo(r_u, ctr, r_u->status); DEBUG(5,("_samr_query_userinfo: %d\n", __LINE__)); - + return r_u->status; } @@ -1712,7 +1757,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S return NT_STATUS_OBJECT_TYPE_MISMATCH; pdb_init_sam(&sam_pass); - + become_root(); ret = pdb_getsampwsid(sam_pass, &info->sid); unbecome_root(); @@ -1721,19 +1766,19 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } - + if(!get_domain_user_groups(p->mem_ctx, &num_groups, &gids, sam_pass)) { pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_GROUP; } - + /* 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__)); pdb_free_sam(&sam_pass); - + return r_u->status; } @@ -1764,13 +1809,13 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA ZERO_STRUCTP(ctr); r_u->status = NT_STATUS_OK; - + DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); - + /* find the policy handle. open a policy on it. */ if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - + switch (q_u->switch_value) { case 0x01: account_policy_get(AP_MIN_PASSWORD_LEN, &min_pass_len); @@ -1789,7 +1834,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA become_root(); r_u->status=load_sampwd_entries(info, ACB_NORMAL); unbecome_root(); - if (NT_STATUS_IS_ERR(r_u->status)) { + if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); return r_u->status; } @@ -1797,7 +1842,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA free_samr_db(info); r_u->status=load_group_domain_entries(info, &global_sam_sid); - if (NT_STATUS_IS_ERR(r_u->status)) { + if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_group_domain_entries failed\n")); return r_u->status; } @@ -1835,12 +1880,12 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA break; default: return NT_STATUS_INVALID_INFO_CLASS; - } - + } + 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__)); - + return r_u->status; } @@ -2659,7 +2704,7 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, * if there is an error, we just continue as * it can be an unfound user or group */ - if (NT_STATUS_IS_ERR(r_u->status)) { + if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(10,("_samr_query_useraliases: an error occured while getting groups\n")); continue; } @@ -2749,7 +2794,7 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ pass = getpwuid_alloc(uid[i]); if (!pass) continue; - if (NT_STATUS_IS_ERR(pdb_init_sam(&sam_user))) { + if (!NT_STATUS_IS_OK(pdb_init_sam(&sam_user))) { passwd_free(&pass); continue; } @@ -2843,7 +2888,7 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ pass = getpwuid_alloc(uid[i]); if (!pass) continue; - if (NT_STATUS_IS_ERR(pdb_init_sam(&sam_user))) { + if (!NT_STATUS_IS_OK(pdb_init_sam(&sam_user))) { passwd_free(&pass); continue; } @@ -2917,7 +2962,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD } ret = pdb_init_sam(&sam_user); - if (NT_STATUS_IS_ERR(ret)) + if (!NT_STATUS_IS_OK(ret)) return ret; check = pdb_getsampwsid(sam_user, &q_u->sid.sid); @@ -3062,7 +3107,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD sid_append_rid(&user_sid, q_u->rid); ret = pdb_init_sam(&sam_user); - if (NT_STATUS_IS_ERR(ret)) + if (!NT_STATUS_IS_OK(ret)) return ret; check = pdb_getsampwsid(sam_user, &user_sid); @@ -3726,7 +3771,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW become_root(); r_u->status=load_sampwd_entries(info, ACB_NORMAL); unbecome_root(); - if (NT_STATUS_IS_ERR(r_u->status)) { + if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); return r_u->status; } -- cgit From bfa2dfaba846bd91fd084e9358f5ff8cd0d7dc4b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 6 Jun 2002 00:59:52 +0000 Subject: Fixed out of date comment for _spoolss_rffpcnex() (This used to be commit 7d9b8c58a63cf20d00dd7cf88cfb82aed3a47d12) --- source3/rpc_server/srv_spoolss_nt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1a436f8c7c..40ad3e89fe 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1724,9 +1724,8 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin * _spoolss_rffpcnex * ReplyFindFirstPrinterChangeNotifyEx * - * jfmxxxx: before replying OK: status=0 - * should do a rpc call to the workstation asking ReplyOpenPrinter - * have to code it, later. + * before replying OK: status=0 a rpc call is made to the workstation + * asking ReplyOpenPrinter * * in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe * called from api_spoolss_rffpcnex @@ -7970,4 +7969,3 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC return WERR_ACCESS_DENIED; } - -- cgit From 617a551c4255aafc4612939ac05779e495f370ac Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 6 Jun 2002 01:19:56 +0000 Subject: Moved some notify related constants into srv_spoolss_nt.c since they're only used there. Added a PRINTER_NOTIFY_VERSION constant. (This used to be commit 9d3933a59219388c209d8be4ae6decfa337d229f) --- source3/rpc_server/srv_spoolss_nt.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 40ad3e89fe..f35f089535 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2466,6 +2466,14 @@ struct s_notify_info_data_table NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx); }; +/* A table describing the various print notification constants and + whether the notification data is a pointer to a variable sized + buffer, a one value uint32 or a two value uint32. */ + +#define ONE_VALUE 1 +#define TWO_VALUE 2 +#define POINTER 3 + struct s_notify_info_data_table notify_info_data_table[] = { { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", POINTER, spoolss_notify_server_name }, -- cgit From 89e9f7530a69eaebde3fb3a55ccbb46fc58fb642 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 6 Jun 2002 01:34:04 +0000 Subject: Fix compile error - doh! (This used to be commit e80e6637064a39635faba5311f774a90b1d5ab43) --- source3/rpc_server/srv_spoolss_nt.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f35f089535..7b7c80f33a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2470,10 +2470,6 @@ struct s_notify_info_data_table whether the notification data is a pointer to a variable sized buffer, a one value uint32 or a two value uint32. */ -#define ONE_VALUE 1 -#define TWO_VALUE 2 -#define POINTER 3 - struct s_notify_info_data_table notify_info_data_table[] = { { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", POINTER, spoolss_notify_server_name }, -- cgit From b0ffabdcca53507a99ce8f00fccf2d4cac78fd6d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 7 Jun 2002 14:33:33 +0000 Subject: Globally replace 'global_sam_sid' with get_global_sam_sid(), a self initialising function. This patch thanks to the work of "Stefan (metze) Metzmacher" This is partly to enable the transition to SIDs in the the passdb. Andrew Bartlett (This used to be commit 96afea638e15d4cbadc57023a511094a770c6adc) --- source3/rpc_server/srv_lsa_nt.c | 15 +++++++-------- source3/rpc_server/srv_netlog_nt.c | 5 +++-- source3/rpc_server/srv_samr_nt.c | 39 +++++++++++++++++++------------------- 3 files changed, 29 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index a5e3f5003c..c74f25f77a 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -26,7 +26,6 @@ #include "includes.h" -extern DOM_SID global_sam_sid; extern fstring global_myworkgroup; extern pstring global_myname; extern PRIVS privs[]; @@ -320,7 +319,7 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s init_sec_access(&mask, POLICY_EXECUTE); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - sid_copy(&adm_sid, &global_sam_sid); + sid_copy(&adm_sid, get_global_sam_sid()); sid_append_rid(&adm_sid, DOMAIN_GROUP_RID_ADMINS); init_sec_access(&mask, POLICY_ALL_ACCESS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); @@ -367,7 +366,7 @@ NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(info); - info->sid = global_sam_sid; + sid_copy(&info->sid,get_global_sam_sid()); info->access = acc_granted; /* set up the LSA QUERY INFO response */ @@ -405,7 +404,7 @@ NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL * return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(info); - info->sid = global_sam_sid; + sid_copy(&info->sid,get_global_sam_sid()); info->access = acc_granted; /* set up the LSA QUERY INFO response */ @@ -502,7 +501,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: name = global_myworkgroup; - sid = &global_sam_sid; + sid = get_global_sam_sid(); break; case ROLE_DOMAIN_MEMBER: name = global_myworkgroup; @@ -532,15 +531,15 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: name = global_myworkgroup; - sid = &global_sam_sid; + sid = get_global_sam_sid(); break; case ROLE_DOMAIN_MEMBER: name = global_myname; - sid = &global_sam_sid; + sid = get_global_sam_sid(); break; case ROLE_STANDALONE: name = global_myname; - sid = &global_sam_sid; + sid = get_global_sam_sid(); break; default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 21ad86b0dc..9b917cdda5 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -27,7 +27,6 @@ #include "includes.h" extern pstring global_myname; -extern DOM_SID global_sam_sid; /************************************************************************* init_net_r_req_chal: @@ -705,7 +704,9 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * NULL, /* uchar sess_key[16] */ my_name , /* char *logon_srv */ my_workgroup, /* char *logon_dom */ - &global_sam_sid, /* DOM_SID *dom_sid */ + get_global_sam_sid(), /* DOM_SID *dom_sid */ + /* Should be users domain sid, not servers - for trusted domains */ + NULL); /* char *other_sids */ } free_server_info(&server_info); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 71b48210e4..0b4fa1cf2d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -31,7 +31,6 @@ extern fstring global_myworkgroup; extern pstring global_myname; -extern DOM_SID global_sam_sid; extern DOM_SID global_sid_Builtin; extern rid_name domain_group_rids[]; @@ -684,7 +683,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM } SAFE_FREE(map); - } else if (sid_equal(sid, &global_sam_sid) && !lp_hide_local_users()) { + } else if (sid_equal(sid, get_global_sam_sid()) && !lp_hide_local_users()) { struct sys_grent *glist; struct sys_grent *grp; struct passwd *pw; @@ -1386,7 +1385,7 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK group_attrs[i] = SID_NAME_UNKNOWN; *group_names[i] = '\0'; - if (sid_equal(&pol_sid, &global_sam_sid)) { + if (sid_equal(&pol_sid, get_global_sam_sid())) { sid_copy(&sid, &pol_sid); sid_append_rid(&sid, q_u->rid[i]); @@ -1841,7 +1840,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA num_users=info->disp_info.num_user_account; free_samr_db(info); - r_u->status=load_group_domain_entries(info, &global_sam_sid); + r_u->status=load_group_domain_entries(info, get_global_sam_sid()); if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_group_domain_entries failed\n")); return r_u->status; @@ -2770,7 +2769,7 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ if(!get_local_group_from_sid(als_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; } else { - if (sid_equal(&alias_sid, &global_sam_sid)) { + if (sid_equal(&alias_sid, get_global_sam_sid())) { DEBUG(10, ("lookup on Server SID\n")); if(!get_local_group_from_sid(als_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; @@ -2789,7 +2788,7 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ struct passwd *pass; uint32 rid; - sid_copy(&temp_sid, &global_sam_sid); + sid_copy(&temp_sid, get_global_sam_sid()); pass = getpwuid_alloc(uid[i]); if (!pass) continue; @@ -2863,7 +2862,7 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ DEBUG(10, ("sid is %s\n", group_sid_str)); /* can we get a query for an SID outside our domain ? */ - if (!sid_equal(&group_sid, &global_sam_sid)) + if (!sid_equal(&group_sid, get_global_sam_sid())) return NT_STATUS_NO_SUCH_GROUP; sid_append_rid(&group_sid, group_rid); @@ -2946,7 +2945,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD sid_to_string(alias_sid_str, &alias_sid); DEBUG(10, ("sid is %s\n", alias_sid_str)); - if (sid_compare(&alias_sid, &global_sam_sid)>0) { + if (sid_compare(&alias_sid, get_global_sam_sid())>0) { DEBUG(10, ("adding member on Server SID\n")); if(!get_local_group_from_sid(alias_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; @@ -3095,7 +3094,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD sid_to_string(group_sid_str, &group_sid); DEBUG(10, ("sid is %s\n", group_sid_str)); - if (sid_compare(&group_sid, &global_sam_sid)<=0) + if (sid_compare(&group_sid, get_global_sam_sid())<=0) return NT_STATUS_NO_SUCH_GROUP; DEBUG(10, ("lookup on Domain SID\n")); @@ -3103,7 +3102,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_GROUP; - sid_copy(&user_sid, &global_sam_sid); + sid_copy(&user_sid, get_global_sam_sid()); sid_append_rid(&user_sid, q_u->rid); ret = pdb_init_sam(&sam_user); @@ -3182,7 +3181,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE if(!sid_check_is_in_our_domain(&group_sid)) return NT_STATUS_NO_SUCH_GROUP; - sid_copy(&user_sid, &global_sam_sid); + sid_copy(&user_sid, get_global_sam_sid()); sid_append_rid(&user_sid, q_u->rid); if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) @@ -3315,7 +3314,7 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S DEBUG(10, ("sid is %s\n", group_sid_str)); /* we check if it's our SID before deleting */ - if (!sid_equal(&dom_sid, &global_sam_sid)) + if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_NO_SUCH_GROUP; DEBUG(10, ("lookup on Domain SID\n")); @@ -3372,7 +3371,7 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S DEBUG(10, ("sid is %s\n", alias_sid_str)); /* we check if it's our SID before deleting */ - if (!sid_equal(&dom_sid, &global_sam_sid)) + if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_NO_SUCH_ALIAS; DEBUG(10, ("lookup on Local SID\n")); @@ -3422,7 +3421,7 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid)) return NT_STATUS_INVALID_HANDLE; - if (!sid_equal(&dom_sid, &global_sam_sid)) + if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; /* TODO: check if allowed to create group and add a become_root/unbecome_root pair.*/ @@ -3443,7 +3442,7 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); /* add the group to the mapping table */ - sid_copy(&info_sid, &global_sam_sid); + sid_copy(&info_sid, get_global_sam_sid()); sid_append_rid(&info_sid, r_u->rid); sid_to_string(sid_string, &info_sid); @@ -3480,7 +3479,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid)) return NT_STATUS_INVALID_HANDLE; - if (!sid_equal(&dom_sid, &global_sam_sid)) + if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; /* TODO: check if allowed to create group and add a become_root/unbecome_root pair.*/ @@ -3500,7 +3499,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); - sid_copy(&info_sid, &global_sam_sid); + sid_copy(&info_sid, get_global_sam_sid()); sid_append_rid(&info_sid, r_u->rid); sid_to_string(sid_string, &info_sid); @@ -3686,10 +3685,10 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G return NT_STATUS_INVALID_HANDLE; /* this should not be hard-coded like this */ - if (!sid_equal(&sid, &global_sam_sid)) + if (!sid_equal(&sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; - sid_copy(&info_sid, &global_sam_sid); + sid_copy(&info_sid, get_global_sam_sid()); sid_append_rid(&info_sid, q_u->rid_group); sid_to_string(sid_string, &info_sid); @@ -3778,7 +3777,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW num_users=info->disp_info.num_user_account; free_samr_db(info); - r_u->status=load_group_domain_entries(info, &global_sam_sid); + r_u->status=load_group_domain_entries(info, get_global_sam_sid()); if (NT_STATUS_IS_ERR(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_group_domain_entries failed\n")); return r_u->status; -- cgit From ae6bdb2cd525faa5033931ec437e164d624849c4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 9 Jun 2002 08:45:35 +0000 Subject: This (hopefully) fixes a bug reported by Kai Krueger involving the use of lp_winbind_gid() without checking if they have been set. Also revert the 'clashing user' check back to a Get_Pwnam() - I probably should never have changed it. Andrew Bartlett (This used to be commit 1d6ba405589cee4e1582bc91cf659b89564899d4) --- source3/rpc_server/srv_samr_nt.c | 20 ++++++-------------- source3/rpc_server/srv_util.c | 7 ++++--- 2 files changed, 10 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 0b4fa1cf2d..daa39b215f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -226,7 +226,9 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) return NT_STATUS_OK; } - enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); + if (!enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) { + return NT_STATUS_NO_MEMORY; + } info->disp_info.num_group_account=group_entries; @@ -688,8 +690,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM struct sys_grent *grp; struct passwd *pw; gid_t winbind_gid_low, winbind_gid_high; - - lp_winbind_gid(&winbind_gid_low, &winbind_gid_high); + BOOL winbind_groups_exist = lp_winbind_gid(&winbind_gid_low, &winbind_gid_high); /* local aliases */ /* we return the UNIX groups here. This seems to be the right */ @@ -719,24 +720,15 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM continue; /* Don't return winbind groups as they are not local! */ - if ((grp->gr_gid >= winbind_gid_low)&&(grp->gr_gid <= winbind_gid_high)) { + if (winbind_groups_exist && (grp->gr_gid >= winbind_gid_low)&&(grp->gr_gid <= winbind_gid_high)) { DEBUG(10,("get_group_alias_entries: not returing %s, not local.\n", smap.nt_name )); continue; } /* Don't return user private groups... */ - - /* - * We used to do a Get_Pwnam() here, but this has been - * trimmed back to the common case for private groups - * to save lookups and to use the _alloc interface. - * - * This also matches the group mapping code - */ - if ((pw = getpwnam_alloc(smap.nt_name)) != 0) { + if ((pw = Get_Pwnam(smap.nt_name)) != 0) { DEBUG(10,("get_group_alias_entries: not returing %s, clashes with user.\n", smap.nt_name )); - passwd_free(&pw); continue; } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index af653ba0e8..7500ec361f 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -93,6 +93,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui uint32 *rids=NULL, *new_rids=NULL; gid_t winbind_gid_low, winbind_gid_high; BOOL ret; + BOOL winbind_groups_exist; /* * this code is far from perfect. @@ -108,7 +109,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui *prids=NULL; *numgroups=0; - lp_winbind_gid(&winbind_gid_low, &winbind_gid_high); + winbind_groups_exist = lp_winbind_gid(&winbind_gid_low, &winbind_gid_high); DEBUG(10,("get_alias_user_groups: looking if SID %s is a member of groups in the SID domain %s\n", @@ -155,7 +156,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui } /* Don't return winbind groups as they are not local! */ - if ((grp->gr_gid >= winbind_gid_low) && (grp->gr_gid <= winbind_gid_high)) { + if (winbind_groups_exist && (grp->gr_gid >= winbind_gid_low) && (grp->gr_gid <= winbind_gid_high)) { DEBUG(10,("get_alias_user_groups: not returing %s, not local.\n", map.nt_name)); continue; } @@ -224,7 +225,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui } /* Don't return winbind groups as they are not local! */ - if ((gid >= winbind_gid_low) && (gid <= winbind_gid_high)) { + if (winbind_groups_exist && (gid >= winbind_gid_low) && (gid <= winbind_gid_high)) { DEBUG(10,("get_alias_user_groups: not returing %s, not local.\n", map.nt_name )); goto done; } -- cgit From 366a649d043346a3302516465d41c5151d991b53 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 11 Jun 2002 03:22:32 +0000 Subject: merge from 2.2 (This used to be commit 30a0e72572b25ddd99438b92b8ddf7f06e9ad819) --- source3/rpc_server/srv_spoolss_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7b7c80f33a..76e7967e25 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4823,6 +4823,7 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) get_called_name()); /* change \ to \\ for the shell */ all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring)); + standard_sub_basic("", remote_machine); slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", cmd, printer->info_2->printername, printer->info_2->sharename, -- cgit From bad738e6536e983064eee7647229354bc9028183 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 13 Jun 2002 14:06:08 +0000 Subject: Latest patch from metze to move most of samba across to using SIDs instead of RIDs. The new funciton sid_peek_check_rid() takes an 'expected domain sid' argument. The idea here is to prevent mistakes where the SID is implict, but isn't the same one that we have in the struct. Andrew Bartlett (This used to be commit 04f9a8ff4c7982f6597c0f6748f85d66d4784901) --- source3/rpc_server/srv_samr_nt.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index daa39b215f..a6f936feca 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2019,18 +2019,9 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ return NT_STATUS_ACCESS_DENIED; } - /* 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; - } - + /* Get the user's SID */ + sid_copy(&sid, (DOM_SID *) pdb_get_user_sid(sam_pass)); + /* associate the user's SID with the new handle. */ if ((info = get_samr_info_by_sid(&sid)) == NULL) { pdb_free_sam(&sam_pass); -- cgit From baef1358d2b5a98a592f0247911a31d79148dcba Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 14 Jun 2002 00:47:08 +0000 Subject: Add const, kill of useless casts and therefore eliminate warnings. Andrew Bartlett (This used to be commit 29490f214750acd44cee6c4ab1354722d82d853a) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a6f936feca..94be26b16c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2020,7 +2020,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ } /* Get the user's SID */ - sid_copy(&sid, (DOM_SID *) pdb_get_user_sid(sam_pass)); + sid_copy(&sid, pdb_get_user_sid(sam_pass)); /* associate the user's SID with the new handle. */ if ((info = get_samr_info_by_sid(&sid)) == NULL) { -- cgit From 843a467f21b48c5fc77c6c2d2db6553e5066a0c5 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 15 Jun 2002 11:40:25 +0000 Subject: Update the netlogon code to better cope with trusted domains, where things like the domain name and SID come from the remote domain, not the local one. These are filled out by the code from the previous commit (auth_util.c, the make_server_info_info3() fn) and read back here. Andrew Bartlett (This used to be commit 6872de2e5b27fd2de61ed14c85475a0eacd637ca) --- source3/rpc_server/srv_netlog_nt.c | 39 ++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 9b917cdda5..49b9fcd0f2 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -655,14 +655,35 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * { DOM_GID *gids = NULL; + const DOM_SID *user_sid = NULL; + const DOM_SID *group_sid = NULL; + DOM_SID domain_sid; + uint32 user_rid, group_rid; + int num_gids = 0; pstring my_name; - pstring my_workgroup; - + fstring user_sid_string; + fstring group_sid_string; + + sampw = server_info->sam_account; + /* set up pointer indicating user/password failed to be found */ usr_info->ptr_user_info = 0; - - pstrcpy(my_workgroup, lp_workgroup()); + + user_sid = pdb_get_user_sid(sampw); + group_sid = pdb_get_group_sid(sampw); + + sid_copy(&domain_sid, user_sid); + sid_split_rid(&domain_sid, &user_rid); + + if (!sid_peek_check_rid(&domain_sid, group_sid, &group_rid)) { + DEBUG(1, ("_net_sam_logon: user %s\\%s has user sid %s\n but group sid %s.\nThe conflicting domain portions are not supported for NETLOGON calls\n", + pdb_get_domain(sampw), pdb_get_username(sampw), + sid_to_string(user_sid_string, user_sid), + sid_to_string(group_sid_string, group_sid))); + return NT_STATUS_UNSUCCESSFUL; + } + pstrcpy(my_name, global_myname); strupper(my_name); @@ -676,12 +697,10 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * gids = NULL; get_domain_user_groups(p->mem_ctx, &num_gids, &gids, server_info->sam_account); - - sampw = server_info->sam_account; init_net_user_info3(p->mem_ctx, usr_info, - pdb_get_user_rid(sampw), - pdb_get_group_rid(sampw), + user_rid, + group_rid, pdb_get_username(sampw), pdb_get_fullname(sampw), @@ -703,8 +722,8 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * 0x20 , /* uint32 user_flgs (?) */ NULL, /* uchar sess_key[16] */ my_name , /* char *logon_srv */ - my_workgroup, /* char *logon_dom */ - get_global_sam_sid(), /* DOM_SID *dom_sid */ + pdb_get_domain(sampw), + &domain_sid, /* DOM_SID *dom_sid */ /* Should be users domain sid, not servers - for trusted domains */ NULL); /* char *other_sids */ -- cgit From ac08646c374cd70e47301bce3e031b35cb220347 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 15 Jun 2002 12:38:13 +0000 Subject: Rework much of the service.c code: The aim of this execise is to give the 'security>=user' code a straight paper path. Security=share will sill call authorise_login(), but otherwise we avoid that mess. This allow *much* more accurate error code reporting, beocuse we don't start pretending that we can use the (nonexistant) password etc. Also in this patch is code to create the 'homes' share at session setup time (as we have done in the past - been broken recently) and to record this on the user's vuser struct for later reference. The changes here should also allow for much better use of %H (some more changes to come here). The service.c changes move a lot of code around, but are not as drastric as they look... (Also included is a fix to srv_srvsvc_nt.c where 'total_entries' not '*total_entries' was compared). This code is needs testing, but passes my basic tests. I expect we have lost some functionality, but the stuff I had expected to loose was already broken before I started. In particular, we don't 'fall back' to guest if the user cannot access a share (for security=user). If you want this kind of stuff then you really want security=share anyway. Andrew Bartlett (This used to be commit 4c0cbcaed95231f8cf11edb43f6adbec9a0d0b5c) --- source3/rpc_server/srv_srvsvc_nt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index f99827ea19..f5b9959b2c 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -308,7 +308,7 @@ void map_generic_share_sd_bits(SEC_DESC *psd) Can this user access with share with the required permissions ? ********************************************************************/ -BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 desired_access) +BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, uint32 desired_access) { uint32 granted; NTSTATUS status; @@ -316,7 +316,6 @@ BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 d SEC_DESC *psd = NULL; size_t sd_size; NT_USER_TOKEN *token = NULL; - user_struct *vuser = get_valid_user_struct(vuid); BOOL ret = True; mem_ctx = talloc_init(); @@ -969,7 +968,7 @@ static WERROR init_srv_file_info_ctr(pipes_struct *p, SRV_FILE_INFO_CTR *ctr, switch (switch_value) { case 3: { int i; - if (total_entries > 0) { + if (*total_entries > 0) { ctr->ptr_entries = 1; ctr->file.info3 = talloc(ctx, ctr->num_entries * sizeof(SRV_FILE_INFO_3)); -- cgit From a60e37096d6576dcf749237df99e7c2c96359834 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 18 Jun 2002 09:20:13 +0000 Subject: more debug classess activated (This used to be commit 897e64d2e0c1d04ab93441ccaffe369bf43be46e) --- source3/rpc_server/srv_dfs.c | 3 +++ source3/rpc_server/srv_dfs_nt.c | 3 +++ source3/rpc_server/srv_lsa.c | 3 +++ source3/rpc_server/srv_lsa_hnd.c | 3 +++ source3/rpc_server/srv_lsa_nt.c | 3 +++ source3/rpc_server/srv_netlog.c | 3 +++ source3/rpc_server/srv_netlog_nt.c | 3 +++ source3/rpc_server/srv_pipe.c | 3 +++ source3/rpc_server/srv_pipe_hnd.c | 3 +++ source3/rpc_server/srv_reg.c | 3 +++ source3/rpc_server/srv_reg_nt.c | 3 +++ source3/rpc_server/srv_samr.c | 3 +++ source3/rpc_server/srv_samr_nt.c | 3 +++ source3/rpc_server/srv_spoolss.c | 3 +++ source3/rpc_server/srv_spoolss_nt.c | 3 +++ source3/rpc_server/srv_srvsvc.c | 3 +++ source3/rpc_server/srv_srvsvc_nt.c | 3 +++ source3/rpc_server/srv_util.c | 3 +++ source3/rpc_server/srv_wkssvc.c | 3 +++ source3/rpc_server/srv_wkssvc_nt.c | 3 +++ 20 files changed, 60 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 4351fd088e..5edc1222a8 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -28,6 +28,9 @@ #define MAX_MSDFS_JUNCTIONS 256 +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + extern pstring global_myname; /********************************************************************** diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 5732af7e9a..65e387176d 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -26,6 +26,9 @@ #include "includes.h" #include "nterr.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + extern pstring global_myname; #define MAX_MSDFS_JUNCTIONS 256 diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 3914556e88..e5a4d3b46d 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -25,6 +25,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /*************************************************************************** api_lsa_open_policy2 ***************************************************************************/ diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 5af1e8c265..2d04d72323 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -22,6 +22,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /* This is the max handles across all instances of a pipe name. */ #ifndef MAX_OPEN_POLS #define MAX_OPEN_POLS 1024 diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c74f25f77a..f2f91d2d9a 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -26,6 +26,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + extern fstring global_myworkgroup; extern pstring global_myname; extern PRIVS privs[]; diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index dfd270ff7d..f96a0e2f2d 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -25,6 +25,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /************************************************************************* api_net_req_chal: *************************************************************************/ diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 49b9fcd0f2..4ab9c470d0 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -26,6 +26,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + extern pstring global_myname; /************************************************************************* diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 70574b4cdd..157d756607 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -39,6 +39,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) { unsigned char *hash = p->ntlmssp_hash; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index a4a9e85ae4..c55e05fe8d 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -22,6 +22,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + #define PIPE "\\PIPE\\" #define PIPELEN strlen(PIPE) diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 569f3fb8b1..e024ba74e7 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -26,6 +26,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /******************************************************************* api_reg_close ********************************************************************/ diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index adedd4a8fa..03aae14b53 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -26,6 +26,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + struct reg_info { /* for use by \PIPE\winreg */ fstring name; /* name of registry key */ diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index c555305bce..1c4fab5312 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -32,6 +32,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /******************************************************************* api_samr_close_hnd ********************************************************************/ diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 94be26b16c..94d8e99576 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -29,6 +29,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + extern fstring global_myworkgroup; extern pstring global_myname; extern DOM_SID global_sid_Builtin; diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index c7dc5d27ff..fa013fe897 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -23,6 +23,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /******************************************************************** * api_spoolss_open_printer_ex (rarely seen - older call) ********************************************************************/ diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 76e7967e25..fc63275869 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -28,6 +28,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + #ifndef MAX_OPEN_PRINTER_EXS #define MAX_OPEN_PRINTER_EXS 50 #endif diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index b09df1e204..96e6172366 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -25,6 +25,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /******************************************************************* api_srv_net_srv_get_info ********************************************************************/ diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index f5b9959b2c..d99b45f3e6 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -23,6 +23,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + extern pstring global_myname; /******************************************************************* diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 7500ec361f..f896d1d9d8 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -38,6 +38,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /* * A list of the rids of well known BUILTIN and Domain users * and groups. diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 8eb5b3002e..0138848440 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -24,6 +24,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /******************************************************************* api_wks_query_info ********************************************************************/ diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 637c95af69..7687e7b00a 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -25,6 +25,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + extern pstring global_myname; /******************************************************************* -- cgit From 900fb62238be30cdc87bfd2bede6fdff611ebae5 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 24 Jun 2002 19:51:23 +0000 Subject: printing merge from SAMBA_2_2. Ther server code looks to be in sync now. Mostly formatting and s/free/SAFE_FREE/g changes with the two exceptions being * John driver init changes * Tim's printer enumeration bug fix (This used to be commit f7536762863811f96364e8acd3716bdb7d665bbf) --- source3/rpc_server/srv_spoolss_nt.c | 137 +++++++++++++++++++++++++----------- 1 file changed, 95 insertions(+), 42 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index fc63275869..56806823d1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -809,8 +809,10 @@ void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) /* Iterate the printer list */ - for (snum=0; snuminfo_2 && !strcmp(drivername, printer->info_2->drivername)) { + if (printer && printer->info_2 && !strcmp(drivername, printer->info_2->drivername)) + { DEBUG(6,("Updating printer [%s]\n", printer->info_2->printername)); + /* all we care about currently is the change_id */ + result = mod_a_printer(*printer, 2); if (!W_ERROR_IS_OK(result)) { DEBUG(3,("do_drv_upgrade_printer: mod_a_printer() failed with status [%s]\n", dos_errstr(result))); } } + free_a_printer(&printer, 2); } } @@ -1000,16 +1006,6 @@ Can't find printer handle we created for printer %s\n", name )); } /* - if (printer_default->datatype_ptr != NULL) - { - unistr2_to_ascii(datatype, printer_default->datatype, sizeof(datatype)-1); - set_printer_hnd_datatype(handle, datatype); - } - else - set_printer_hnd_datatype(handle, ""); -*/ - - /* First case: the user is opening the print server: Disallow MS AddPrinterWizard if parameter disables it. A Win2k @@ -3492,10 +3488,26 @@ static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, enum_all_printers_info_1_network. *********************************************************************/ -static WERROR enum_all_printers_info_1_network(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enum_all_printers_info_1_network(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { + char *s = name; + DEBUG(4,("enum_all_printers_info_1_network\n")); + /* If we respond to a enum_printers level 1 on our name with flags + set to PRINTER_ENUM_REMOTE with a list of printers then these + printers incorrectly appear in the APW browse list. + Specifically the printers for the server appear at the workgroup + level where all the other servers in the domain are + listed. Windows responds to this call with a + WERR_CAN_NOT_COMPLETE so we should do the same. */ + + if (name[0] == '\\' && name[1] == '\\') + s = name + 2; + + if (is_myname_or_ipaddr(s)) + return WERR_CAN_NOT_COMPLETE; + return enum_all_printers_info_1(PRINTER_ENUM_UNKNOWN_8, buffer, offered, needed, returned); } @@ -3582,7 +3594,7 @@ static WERROR enumprinters_level1( uint32 flags, fstring name, return enum_all_printers_info_1_remote(name, buffer, offered, needed, returned); if (flags & PRINTER_ENUM_NETWORK) - return enum_all_printers_info_1_network(buffer, offered, needed, returned); + return enum_all_printers_info_1_network(name, buffer, offered, needed, returned); return WERR_OK; /* NT4sp5 does that */ } @@ -5247,7 +5259,10 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, * bound to the printer, simulating what happens in the Windows arch. */ if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)){ - set_driver_init(printer, 2); + if (!set_driver_init(printer, 2)) { + DEBUG(5,("update_printer: Error restoring driver initialization data for driver [%s]!\n", + printer->info_2->drivername)); + } msg.flags |= PRINTER_MESSAGE_DRIVER; } } @@ -6603,16 +6618,70 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, driver_name)); } - /* if driver is not 9x, delete existing driver init data */ + /* + * Based on the version (e.g. driver destination dir: 0=9x,2=Nt/2k,3=2k/Xp), + * decide if the driver init data should be deleted. The rules are: + * 1) never delete init data if it is a 9x driver, they don't use it anyway + * 2) delete init data only if there is no 2k/Xp driver + * 3) always delete init data + * The generalized rule is always use init data from the highest order driver. + * It is necessary to follow the driver install by an initialization step to + * finish off this process. + */ + if (level == 3) + version = driver.info_3->cversion; + else if (level == 6) + version = driver.info_6->version; + else + version = -1; + switch (version) { + /* + * 9x printer driver - never delete init data + */ + case 0: + DEBUG(10,("_spoolss_addprinterdriver: init data not deleted for 9x driver [%s]\n", + driver_name)); + break; + + /* + * Nt or 2k (compatiblity mode) printer driver - only delete init data if + * there is no 2k/Xp driver init data for this driver name. + */ + case 2: + { + NT_PRINTER_DRIVER_INFO_LEVEL driver1; - if ((level == 3 && driver.info_3->cversion != 0) || - (level == 6 && driver.info_6->version != 0)) { + if (!W_ERROR_IS_OK(get_a_printer_driver(&driver1, 3, driver_name, "Windows NT x86", 3))) { + /* + * No 2k/Xp driver found, delete init data (if any) for the new Nt driver. + */ if (!del_driver_init(driver_name)) - DEBUG(3,("_spoolss_addprinterdriver: del_driver_init(%s) failed!\n", driver_name)); + DEBUG(6,("_spoolss_addprinterdriver: del_driver_init(%s) Nt failed!\n", driver_name)); } else { - DEBUG(10,("_spoolss_addprinterdriver: init data not deleted for 9x driver [%s]\n", driver_name)); + /* + * a 2k/Xp driver was found, don't delete init data because Nt driver will use it. + */ + free_a_printer_driver(driver1,3); + DEBUG(10,("_spoolss_addprinterdriver: init data not deleted for Nt driver [%s]\n", + driver_name)); + } + } + break; + + /* + * 2k or Xp printer driver - always delete init data + */ + case 3: + if (!del_driver_init(driver_name)) + DEBUG(6,("_spoolss_addprinterdriver: del_driver_init(%s) 2k/Xp failed!\n", driver_name)); + break; + + default: + DEBUG(0,("_spoolss_addprinterdriver: invalid level=%d\n", level)); + break; } + done: free_a_printer_driver(driver, level); return err; @@ -6756,23 +6825,6 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S if ( (in_value_len==0) && (in_data_len==0) ) { DEBUGADD(6,("Activating NT mega-hack to find sizes\n")); -#if 0 - /* - * NT can ask for a specific parameter size - we need to return NO_MORE_ITEMS - * if this parameter size doesn't exist. - * Ok - my opinion here is that the client is not asking for the greatest - * possible size of all the parameters, but is asking specifically for the size needed - * for this specific parameter. In that case we can remove the loop below and - * simplify this lookup code considerably. JF - comments welcome. JRA. - */ - - if (!get_specific_param_by_index(*printer, 2, idx, value, &data, &type, &data_len)) { - SAFE_FREE(data); - free_a_printer(&printer, 2); - return WERR_NO_MORE_ITEMS; - } -#endif - SAFE_FREE(data); param_index=0; @@ -7925,7 +7977,7 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, unistr2_to_ascii(long_archi, environment, sizeof(long_archi)-1); - if (get_short_archi(short_archi, long_archi)==FALSE) + if (get_short_archi(short_archi, long_archi)==False) return WERR_INVALID_ENVIRONMENT; if((info=(PRINTPROCESSOR_DIRECTORY_1 *)malloc(sizeof(PRINTPROCESSOR_DIRECTORY_1))) == NULL) @@ -7958,6 +8010,7 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; + WERROR result; /* that's an [in out] buffer */ spoolss_move_buffer(q_u->buffer, &r_u->buffer); @@ -7969,11 +8022,11 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC switch(level) { case 1: - return getprintprocessordirectory_level_1 + result = getprintprocessordirectory_level_1 (&q_u->name, &q_u->environment, buffer, offered, needed); default: - return WERR_UNKNOWN_LEVEL; + result = WERR_UNKNOWN_LEVEL; } - return WERR_ACCESS_DENIED; + return result; } -- cgit From 2e148c865acb5515340f4f1156fd49bea356e597 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 24 Jun 2002 20:09:34 +0000 Subject: compile fix (This used to be commit b07d6d4cebecd77314b123d83c7c2265eb62e1c1) --- source3/rpc_server/srv_spoolss_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 56806823d1..af8f1c48a6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6564,6 +6564,7 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, NT_PRINTER_DRIVER_INFO_LEVEL driver; struct current_user user; fstring driver_name; + uint32 version; ZERO_STRUCT(driver); -- cgit From 8e387b8178416552e9b7e504c7eb8e1b16b5edcb Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 25 Jun 2002 11:21:41 +0000 Subject: I'm going to try and check this against Win2k shortly, but I'm certain that 'NT_STATUS_OK' is not the right answer here. Try NO_MORE_ENTRIES for now. Andrew Bartlett (This used to be commit c98b9a965905f1876b4884f932ff2e0237d85b03) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 94d8e99576..9e826436f6 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -986,7 +986,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ if (enum_context > num_account) { DEBUG(5, ("samr_reply_query_dispinfo: enumeration handle over total entries\n")); - return NT_STATUS_OK; + return NT_STATUS_NO_MORE_ENTRIES; } /* verify we won't overflow */ -- cgit From 452eb38df0553886313c9b19a945385d853e19ab Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 28 Jun 2002 00:17:15 +0000 Subject: Proper merge of all the working printing stuff from APPLIANCE_HEAD. Now let's keep this in sync ! Jeremy. (This used to be commit 3603cd4947df2c10df604447dc542932cb9e5d5a) --- source3/rpc_server/srv_spoolss_nt.c | 884 ++++++++++++++++++++++-------------- 1 file changed, 540 insertions(+), 344 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index af8f1c48a6..0b172aa0e5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -30,6 +30,7 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +/* #define EMULATE_WIN2K_HACK 1 */ #ifndef MAX_OPEN_PRINTER_EXS #define MAX_OPEN_PRINTER_EXS 50 @@ -80,6 +81,7 @@ typedef struct _Printer{ SPOOL_NOTIFY_OPTION *option; POLICY_HND client_hnd; uint32 client_connected; + uint32 change; } notify; struct { fstring machine; @@ -190,10 +192,10 @@ static void srv_spoolss_replycloseprinter(POLICY_HND *handle) /* if it's the last connection, deconnect the IPC$ share */ if (smb_connections==1) { - if(!spoolss_disconnect_from_client(&cli)) - return; - - message_deregister(MSG_PRINTER_NOTIFY); + cli_nt_session_close(&cli); + cli_ulogoff(&cli); + cli_shutdown(&cli); + message_deregister(MSG_PRINTER_NOTIFY2); } smb_connections--; @@ -438,7 +440,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) * anymore, so I've simplified this loop greatly. Here * we are just verifying that the printer name is a valid * printer service defined in smb.conf - * --jerry [Fri Feb 15 11:17:46 CST 2002] + * --jerry [Fri Feb 15 11:17:46 CST 2002] */ for (snum=0; snumnotify.option == NULL) - return False; - return True; } -/*************************************************************************** - Simple check to see if the client motify handle is set to watch for events - represented by 'flags' - - FIXME!!!! only a stub right now --jerry - **************************************************************************/ - -static BOOL is_client_monitoring_event(Printer_entry *p, uint32 flags) +static BOOL is_monitoring_event(Printer_entry *p, uint16 notify_type, + uint16 notify_field) { + SPOOL_NOTIFY_OPTION *option = p->notify.option; + uint32 i, j; + + if (p->notify.flags) + return is_monitoring_event_flags( + p->notify.flags, notify_type, notify_field); - return True; -} + for (i = 0; i < option->count; i++) { + + /* Check match for notify_type */ + + if (option->ctr.type[i].type != notify_type) + continue; -/*************************************************************************** - Server wrapper for cli_spoolss_routerreplyprinter() since the client - function can only send a single change notification at a time. - - FIXME!!! only handles one change currently (PRINTER_CHANGE_SET_PRINTER_DRIVER) - --jerry - **************************************************************************/ - -static WERROR srv_spoolss_routerreplyprinter (struct cli_state *reply_cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, PRINTER_MESSAGE_INFO *info, - NT_PRINTER_INFO_LEVEL *printer) -{ - WERROR result; - uint32 condition = 0x0; + /* Check match for field */ + + for (j = 0; j < option->ctr.type[i].count; j++) { + if (option->ctr.type[i].fields[j] == notify_field) { + return True; + } + } + } - if (info->flags & PRINTER_MESSAGE_DRIVER) - condition = PRINTER_CHANGE_SET_PRINTER_DRIVER; + DEBUG(10, ("%s is not monitoring 0x%02x/0x%02x\n", + (p->printer_type == PRINTER_HANDLE_IS_PRINTER) ? + p->dev.handlename : p->dev.printerservername, + notify_type, notify_field)); - result = cli_spoolss_routerreplyprinter(reply_cli, mem_ctx, pol, condition, - printer->info_2->changeid); + return False; +} - return result; +/* Convert a notification message to a SPOOL_NOTIFY_INFO_DATA struct */ + +static void notify_one_value(struct spoolss_notify_msg *msg, + SPOOL_NOTIFY_INFO_DATA *data, + TALLOC_CTX *mem_ctx) +{ + data->notify_data.value[0] = msg->notify.value[0]; + data->notify_data.value[1] = 0; } -/*********************************************************************** - Wrapper around the decision of which RPC use to in the change - notification - **********************************************************************/ - -static WERROR srv_spoolss_send_event_to_client(Printer_entry* Printer, - struct cli_state *send_cli, PRINTER_MESSAGE_INFO *msg, - NT_PRINTER_INFO_LEVEL *info) +static void notify_string(struct spoolss_notify_msg *msg, + SPOOL_NOTIFY_INFO_DATA *data, + TALLOC_CTX *mem_ctx) { - WERROR result; + UNISTR2 unistr; - if (valid_notify_options(Printer)) { - /* This is a single call that can send information about multiple changes */ - if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) - msg->flags |= PRINTER_MESSAGE_ATTRIBUTES; + /* The length of the message includes the trailing \0 */ - result = cli_spoolss_reply_rrpcn(send_cli, send_cli->mem_ctx, &Printer->notify.client_hnd, - msg, info); - } - else { - /* This requires that the server send an individual event notification for each change */ - result = srv_spoolss_routerreplyprinter(send_cli, send_cli->mem_ctx, &Printer->notify.client_hnd, - msg, info); + init_unistr2(&unistr, msg->notify.data, msg->len); + + data->notify_data.data.length = msg->len * 2; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, msg->len * 2); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; } - return result; + memcpy(data->notify_data.data.string, unistr.buffer, msg->len * 2); +} + +static void notify_system_time(struct spoolss_notify_msg *msg, + SPOOL_NOTIFY_INFO_DATA *data, + TALLOC_CTX *mem_ctx) +{ + SYSTEMTIME systime; + prs_struct ps; + + if (msg->len != sizeof(time_t)) { + DEBUG(5, ("notify_system_time: received wrong sized message (%d)\n", + msg->len)); + return; + } + + if (!prs_init(&ps, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL)) { + DEBUG(5, ("notify_system_time: prs_init() failed\n")); + return; + } + + if (!make_systemtime(&systime, localtime((time_t *)msg->notify.data))) { + DEBUG(5, ("notify_system_time: unable to make systemtime\n")); + return; + } + + if (!spoolss_io_system_time("", &ps, 0, &systime)) + return; + + data->notify_data.data.length = prs_offset(&ps); + data->notify_data.data.string = + talloc(mem_ctx, prs_offset(&ps)); + + memcpy(data->notify_data.data.string, prs_data_p(&ps), prs_offset(&ps)); + + prs_mem_free(&ps); } +struct notify2_message_table { + char *name; + void (*fn)(struct spoolss_notify_msg *msg, + SPOOL_NOTIFY_INFO_DATA *data, TALLOC_CTX *mem_ctx); +}; + +static struct notify2_message_table printer_notify_table[] = { + /* 0x00 */ { "PRINTER_NOTIFY_SERVER_NAME", NULL }, + /* 0x01 */ { "PRINTER_NOTIFY_PRINTER_NAME", NULL }, + /* 0x02 */ { "PRINTER_NOTIFY_SHARE_NAME", NULL }, + /* 0x03 */ { "PRINTER_NOTIFY_PORT_NAME", NULL }, + /* 0x04 */ { "PRINTER_NOTIFY_DRIVER_NAME", NULL }, + /* 0x05 */ { "PRINTER_NOTIFY_COMMENT", NULL }, + /* 0x06 */ { "PRINTER_NOTIFY_LOCATION", NULL }, + /* 0x07 */ { "PRINTER_NOTIFY_DEVMODE", NULL }, + /* 0x08 */ { "PRINTER_NOTIFY_SEPFILE", NULL }, + /* 0x09 */ { "PRINTER_NOTIFY_PRINT_PROCESSOR", NULL }, + /* 0x0a */ { "PRINTER_NOTIFY_PARAMETERS", NULL }, + /* 0x0b */ { "PRINTER_NOTIFY_DATATYPE", NULL }, + /* 0x0c */ { "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", NULL }, + /* 0x0d */ { "PRINTER_NOTIFY_ATTRIBUTES", NULL }, + /* 0x0e */ { "PRINTER_NOTIFY_PRIORITY", NULL }, + /* 0x0f */ { "PRINTER_NOTIFY_DEFAULT_PRIORITY", NULL }, + /* 0x10 */ { "PRINTER_NOTIFY_START_TIME", NULL }, + /* 0x11 */ { "PRINTER_NOTIFY_UNTIL_TIME", NULL }, + /* 0x12 */ { "PRINTER_NOTIFY_STATUS", notify_one_value }, +}; + +static struct notify2_message_table job_notify_table[] = { + /* 0x00 */ { "JOB_NOTIFY_PRINTER_NAME", NULL }, + /* 0x01 */ { "JOB_NOTIFY_MACHINE_NAME", NULL }, + /* 0x02 */ { "JOB_NOTIFY_PORT_NAME", NULL }, + /* 0x03 */ { "JOB_NOTIFY_USER_NAME", notify_string }, + /* 0x04 */ { "JOB_NOTIFY_NOTIFY_NAME", NULL }, + /* 0x05 */ { "JOB_NOTIFY_DATATYPE", NULL }, + /* 0x06 */ { "JOB_NOTIFY_PRINT_PROCESSOR", NULL }, + /* 0x07 */ { "JOB_NOTIFY_PARAMETERS", NULL }, + /* 0x08 */ { "JOB_NOTIFY_DRIVER_NAME", NULL }, + /* 0x09 */ { "JOB_NOTIFY_DEVMODE", NULL }, + /* 0x0a */ { "JOB_NOTIFY_STATUS", notify_one_value }, + /* 0x0b */ { "JOB_NOTIFY_STATUS_STRING", NULL }, + /* 0x0c */ { "JOB_NOTIFY_SECURITY_DESCRIPTOR", NULL }, + /* 0x0d */ { "JOB_NOTIFY_DOCUMENT", notify_string }, + /* 0x0e */ { "JOB_NOTIFY_PRIORITY", NULL }, + /* 0x0f */ { "JOB_NOTIFY_POSITION", NULL }, + /* 0x10 */ { "JOB_NOTIFY_SUBMITTED", notify_system_time }, + /* 0x11 */ { "JOB_NOTIFY_START_TIME", NULL }, + /* 0x12 */ { "JOB_NOTIFY_UNTIL_TIME", NULL }, + /* 0x13 */ { "JOB_NOTIFY_TIME", NULL }, + /* 0x14 */ { "JOB_NOTIFY_TOTAL_PAGES", notify_one_value }, + /* 0x15 */ { "JOB_NOTIFY_PAGES_PRINTED", NULL }, + /* 0x16 */ { "JOB_NOTIFY_TOTAL_BYTES", notify_one_value }, + /* 0x17 */ { "JOB_NOTIFY_BYTES_PRINTED", NULL }, +}; /*********************************************************************** Send a change notication message on all handles which have a call back registered **********************************************************************/ -static void send_spoolss_event_notification(PRINTER_MESSAGE_INFO *msg) +static void process_notify2_message(struct spoolss_notify_msg *msg, + TALLOC_CTX *mem_ctx) { - Printer_entry *find_printer; - WERROR result; - NT_PRINTER_INFO_LEVEL *printer = NULL; + Printer_entry *p; - if (!msg) { - DEBUG(0,("send_spoolss_event_notification: NULL msg pointer!\n")); - return; - } + for (p = printers_list; p; p = p->next) { + SPOOL_NOTIFY_INFO_DATA *data; + uint32 data_len = 1; + uint32 id; - for(find_printer = printers_list; find_printer; find_printer = find_printer->next) { + /* Is there notification on this handle? */ - /* - * If the entry has a connected client we send the message. There should - * only be one of these normally when dealing with the NT/2k spooler. - * However, iterate over all to make sure we deal with user applications - * in addition to spooler service. - * - * While we are only maintaining a single connection to the client, - * the FindFirstPrinterChangeNotification() call is made on a printer - * handle, so "client_connected" represents the whether or not the - * client asked for change notication on this handle. - * - * --jerry - */ + if (!p->notify.client_connected) + continue; - if (find_printer->notify.client_connected==True) { - - /* does the client care about what changed? */ + /* For this printer? Print servers always receive + notifications. */ - if (msg->flags && !is_client_monitoring_event(find_printer, msg->flags)) { - DEBUG(10,("send_spoolss_event_notification: Client [%s] not monitoring these events\n", - find_printer->client.machine)); - continue; - } + if (p->printer_type == PRINTER_HANDLE_IS_PRINTER && + !strequal(msg->printer, p->dev.handlename)) + continue; - if (find_printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) - DEBUG(10,("send_spoolss_event_notification: printserver [%s]\n", find_printer->dev.printerservername )); - else - DEBUG(10,("send_spoolss_event_notification: printer [%s]\n", find_printer->dev.handlename)); + /* Are we monitoring this event? */ - /* - * if handle is a printer, only send if the printer_name matches. - * ...else if handle is a printerserver, send to all - */ + if (!is_monitoring_event(p, msg->type, msg->field)) + continue; - if (*msg->printer_name && (find_printer->printer_type==PRINTER_HANDLE_IS_PRINTER) - && !strequal(msg->printer_name, find_printer->dev.handlename)) - { - DEBUG(10,("send_spoolss_event_notification: ignoring message sent to %s [%s]\n", - msg->printer_name, find_printer->dev.handlename )); - continue; + /* OK - send the event to the client */ + + data = talloc(mem_ctx, sizeof(SPOOL_NOTIFY_INFO_DATA)); + + ZERO_STRUCTP(data); + + /* Convert unix jobid to smb jobid */ + + id = msg->id; + + if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) { + + id = sysjob_to_jobid(msg->id); + + if (id == -1) { + DEBUG(3, ("no such unix jobid %d\n", msg->id)); + goto done; } + } + construct_info_data(data, msg->type, msg->field, id); - /* lookup the printer if we have a name if we don't already have a - valid NT_PRINTER_INFO_LEVEL structure. And yes I'm assuming we - will always have a non-empty msg.printer_name */ - - if (!printer || !printer->info_2 || strcmp(msg->printer_name, printer->info_2->printername)) - { - - if (printer) { - free_a_printer(&printer, 2); - printer = NULL; - } - - result = get_a_printer(&printer, 2, msg->printer_name); - if (!W_ERROR_IS_OK(result)) - continue; + switch(msg->type) { + case PRINTER_NOTIFY_TYPE: + if (printer_notify_table[msg->field].fn) + printer_notify_table[msg->field].fn( + msg, data, mem_ctx); + else + goto done; + break; + case JOB_NOTIFY_TYPE: + if (job_notify_table[msg->field].fn) + job_notify_table[msg->field].fn( + msg, data, mem_ctx); + else + goto done; + break; + default: + DEBUG(5, ("Unknown notification type %d\n", + msg->type)); + goto done; + } + + if (!p->notify.flags) + cli_spoolss_rrpcn( + &cli, mem_ctx, &p->notify.client_hnd, + data_len, data, p->notify.change, 0); + else { + NT_PRINTER_INFO_LEVEL *printer = NULL; + + get_a_printer(&printer, 2, msg->printer); + + if (!printer) { + DEBUG(5, ("unable to load info2 for %s\n", + msg->printer)); + goto done; } - /* issue the client call */ + /* XXX: This needs to be updated for + PRINTER_CHANGE_SET_PRINTER_DRIVER. */ - result = srv_spoolss_send_event_to_client(find_printer, &cli, msg, printer); - - if (!W_ERROR_IS_OK(result)) { - DEBUG(5,("send_spoolss_event_notification: Event notification failed [%s]\n", - dos_errstr(result))); + cli_spoolss_routerreplyprinter( + &cli, mem_ctx, &p->notify.client_hnd, + 0, printer->info_2->changeid); + + free_a_printer(&printer, 2); } } -} - +done: return; } -/*************************************************************************** - Receive the notify message and decode the message. Do not send - notification if we sent this originally as that would result in - duplicates. -****************************************************************************/ -static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) +/* Receive a notify2 message */ + +static void receive_notify2_message(int msg_type, pid_t src, void *buf, + size_t len) { - PRINTER_MESSAGE_INFO msg; - - if (len < sizeof(msg)) { - DEBUG(2,("srv_spoolss_receive_message: got incorrect message size (%u)!\n", (unsigned int)len)); - return; - } + struct spoolss_notify_msg msg; + int offset = 0; + TALLOC_CTX *mem_ctx = talloc_init(); - memcpy(&msg, buf, sizeof(PRINTER_MESSAGE_INFO)); - - DEBUG(10,("srv_spoolss_receive_message: Got message printer change [queue = %s] low=0x%x high=0x%x flags=0x%x\n", - msg.printer_name, (unsigned int)msg.low, (unsigned int)msg.high, msg.flags )); + /* Unpack message */ - /* Iterate the printer list */ - - send_spoolss_event_notification(&msg); + ZERO_STRUCT(msg); + + offset += tdb_unpack((char *)buf + offset, len - offset, "f", + msg.printer); + offset += tdb_unpack((char *)buf + offset, len - offset, "ddddd", + &msg.type, &msg.field, &msg.id, &msg.len, &msg.flags); + + if (msg.len == 0) + tdb_unpack((char *)buf + offset, len - offset, "dd", + &msg.notify.value[0], &msg.notify.value[1]); + else + tdb_unpack((char *)buf + offset, len - offset, "B", + &msg.len, &msg.notify.data); + + DEBUG(3, ("got NOTIFY2 message, type %d, field 0x%02x, flags 0x%04x\n", + msg.type, msg.field, msg.flags)); + + if (msg.len == 0) + DEBUG(3, ("value1 = %d, value2 = %d\n", msg.notify.value[0], + msg.notify.value[1])); + else + dump_data(3, msg.notify.data, msg.len); + + /* Process message */ + + process_notify2_message(&msg, mem_ctx); + + /* Free message */ + + if (msg.len > 0) + free(msg.notify.data); + + talloc_destroy(mem_ctx); } /*************************************************************************** - Send a notify event. -****************************************************************************/ - -static BOOL srv_spoolss_sendnotify(char* printer_name, uint32 high, uint32 low, uint32 flags) + Server wrapper for cli_spoolss_routerreplyprinter() since the client + function can only send a single change notification at a time. + + FIXME!!! only handles one change currently (PRINTER_CHANGE_SET_PRINTER_DRIVER) + --jerry + **************************************************************************/ + +static WERROR srv_spoolss_routerreplyprinter (struct cli_state *reply_cli, TALLOC_CTX *mem_ctx, + POLICY_HND *pol, PRINTER_MESSAGE_INFO *info, + NT_PRINTER_INFO_LEVEL *printer) { - char msg[sizeof(PRINTER_MESSAGE_INFO)]; - PRINTER_MESSAGE_INFO info; + WERROR result; + uint32 condition = 0x0; - ZERO_STRUCT(info); - - info.low = low; - info.high = high; - info.flags = flags; - fstrcpy(info.printer_name, printer_name); + if (info->flags & PRINTER_MESSAGE_DRIVER) + condition = PRINTER_CHANGE_SET_PRINTER_DRIVER; - memcpy(msg, &info, sizeof(PRINTER_MESSAGE_INFO)); - - DEBUG(10,("srv_spoolss_sendnotify: printer change low=0x%x high=0x%x [%s], flags=0x%x\n", - low, high, printer_name, flags)); - - message_send_all(conn_tdb_ctx(), MSG_PRINTER_NOTIFY, msg, sizeof(PRINTER_MESSAGE_INFO), - False, NULL); + result = cli_spoolss_routerreplyprinter(reply_cli, mem_ctx, pol, condition, + printer->info_2->changeid); - return True; -} + return result; +} /******************************************************************** Send a message to ourself about new driver being installed so we can upgrade the information for each printer bound to this driver -********************************************************************/ - + ********************************************************************/ + static BOOL srv_spoolss_drv_upgrade_printer(char* drivername) { int len = strlen(drivername); - + if (!len) return False; DEBUG(10,("srv_spoolss_drv_upgrade_printer: Sending message about driver upgrade [%s]\n", drivername)); - + message_send_pid(sys_getpid(), MSG_PRINTER_DRVUPGRADE, drivername, len+1, False); + return True; } /********************************************************************** callback to receive a MSG_PRINTER_DRVUPGRADE message and interate - over all printers, upgrading ones as neessary -**********************************************************************/ - + over all printers, upgrading ones as neessary + **********************************************************************/ + void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) { fstring drivername; int snum; int n_services = lp_numservices(); - + len = MIN(len,sizeof(drivername)-1); strncpy(drivername, buf, len); - + DEBUG(10,("do_drv_upgrade_printer: Got message for new driver [%s]\n", drivername )); /* Iterate the printer list */ - + for (snum=0; snuminfo_2 && !strcmp(drivername, printer->info_2->drivername)) { DEBUG(6,("Updating printer [%s]\n", printer->info_2->printername)); @@ -828,16 +949,16 @@ void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) result = mod_a_printer(*printer, 2); if (!W_ERROR_IS_OK(result)) { - DEBUG(3,("do_drv_upgrade_printer: mod_a_printer() failed with status [%s]\n", - dos_errstr(result))); + DEBUG(3,("do_drv_upgrade_printer: mod_a_printer() failed with status [%s]\n", + dos_errstr(result))); } } - free_a_printer(&printer, 2); + free_a_printer(&printer, 2); } } - - /* all done */ + + /* all done */ } /******************************************************************** @@ -1005,7 +1126,7 @@ Can't find printer handle we created for printer %s\n", name )); return WERR_INVALID_PRINTER_NAME; } -/* + /* First case: the user is opening the print server: Disallow MS AddPrinterWizard if parameter disables it. A Win2k @@ -1381,10 +1502,6 @@ WERROR _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL update_c_setprinter(False); - if (W_ERROR_IS_OK(result)) { - srv_spoolss_sendnotify(Printer->dev.handlename, 0, PRINTER_CHANGE_DELETE_PRINTER, 0x0); - } - return result; } @@ -1683,6 +1800,96 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO return WERR_OK; } +/********************************************************* + Connect to the client machine. +**********************************************************/ + +static BOOL spoolss_connect_to_client(struct cli_state *the_cli, char *remote_machine) +{ + extern pstring global_myname; + + ZERO_STRUCTP(the_cli); + if(cli_initialise(the_cli) == NULL) { + DEBUG(0,("connect_to_client: unable to initialize client connection.\n")); + return False; + } + + if(!resolve_name( remote_machine, &the_cli->dest_ip, 0x20)) { + DEBUG(0,("connect_to_client: Can't resolve address for %s\n", remote_machine)); + cli_shutdown(the_cli); + return False; + } + + if (ismyip(the_cli->dest_ip)) { + DEBUG(0,("connect_to_client: Machine %s is one of our addresses. Cannot add to ourselves.\n", remote_machine)); + cli_shutdown(the_cli); + return False; + } + + if (!cli_connect(the_cli, remote_machine, &the_cli->dest_ip)) { + DEBUG(0,("connect_to_client: unable to connect to SMB server on machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + cli_shutdown(the_cli); + return False; + } + + if (!attempt_netbios_session_request(the_cli, global_myname, remote_machine, &the_cli->dest_ip)) { + DEBUG(0,("connect_to_client: machine %s rejected the NetBIOS session request.\n", + remote_machine)); + return False; + } + + the_cli->protocol = PROTOCOL_NT1; + + if (!cli_negprot(the_cli)) { + DEBUG(0,("connect_to_client: machine %s rejected the negotiate protocol. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + cli_shutdown(the_cli); + return False; + } + + if (the_cli->protocol != PROTOCOL_NT1) { + DEBUG(0,("connect_to_client: machine %s didn't negotiate NT protocol.\n", remote_machine)); + cli_shutdown(the_cli); + return False; + } + + /* + * Do an anonymous session setup. + */ + + if (!cli_session_setup(the_cli, "", "", 0, "", 0, "")) { + DEBUG(0,("connect_to_client: machine %s rejected the session setup. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + cli_shutdown(the_cli); + return False; + } + + if (!(the_cli->sec_mode & 1)) { + DEBUG(0,("connect_to_client: machine %s isn't in user level security mode\n", remote_machine)); + cli_shutdown(the_cli); + return False; + } + + if (!cli_send_tconX(the_cli, "IPC$", "IPC", "", 1)) { + DEBUG(0,("connect_to_client: machine %s rejected the tconX on the IPC$ share. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + cli_shutdown(the_cli); + return False; + } + + /* + * Ok - we have an anonymous connection to the IPC$ share. + * Now start the NT Domain stuff :-). + */ + + if(cli_nt_session_open(the_cli, PIPE_SPOOLSS) == False) { + DEBUG(0,("connect_to_client: unable to open the domain client session to machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli))); + cli_nt_session_close(the_cli); + cli_ulogoff(the_cli); + cli_shutdown(the_cli); + return False; + } + + return True; +} + /*************************************************************************** Connect to the client. ****************************************************************************/ @@ -1703,15 +1910,14 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin if(!spoolss_connect_to_client(&cli, unix_printer)) return False; - message_register(MSG_PRINTER_NOTIFY, srv_spoolss_receive_message); - + message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message); } smb_connections++; result = cli_spoolss_reply_open_printer(&cli, cli.mem_ctx, printer, localprinter, type, handle); - + if (!W_ERROR_IS_OK(result)) DEBUG(5,("srv_spoolss_reply_open_printer: Client RPC returned [%s]\n", dos_errstr(result))); @@ -1757,15 +1963,17 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE Printer->notify.option=dup_spool_notify_option(option); - unistr2_to_ascii(Printer->notify.localmachine, localmachine, sizeof(Printer->notify.localmachine)-1); + unistr2_to_ascii(Printer->notify.localmachine, localmachine, + sizeof(Printer->notify.localmachine)-1); + + /* Connect to the client machine and send a ReplyOpenPrinter */ - /* connect to the client machine and send a ReplyOpenPrinter */ - if(srv_spoolss_replyopenprinter(Printer->notify.localmachine, + if(!srv_spoolss_replyopenprinter(Printer->notify.localmachine, Printer->notify.printerlocal, 1, &Printer->notify.client_hnd)) - { - Printer->notify.client_connected=True; - } + return WERR_SERVER_UNAVAILABLE; + + Printer->notify.client_connected=True; return WERR_OK; } @@ -1787,7 +1995,7 @@ void spoolss_notify_server_name(int snum, len = rpcstr_push(temp, temp_name, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1822,7 +2030,7 @@ void spoolss_notify_printer_name(int snum, len = rpcstr_push(temp, p, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1848,7 +2056,7 @@ void spoolss_notify_share_name(int snum, len = rpcstr_push(temp, lp_servicename(snum), sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1876,7 +2084,7 @@ void spoolss_notify_port_name(int snum, len = rpcstr_push(temp, printer->info_2->portname, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1902,7 +2110,8 @@ void spoolss_notify_driver_name(int snum, uint32 len; len = rpcstr_push(temp, printer->info_2->drivername, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1931,7 +2140,7 @@ void spoolss_notify_comment(int snum, else len = rpcstr_push(temp, printer->info_2->comment, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1958,7 +2167,7 @@ void spoolss_notify_location(int snum, len = rpcstr_push(temp, printer->info_2->location,sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1997,7 +2206,7 @@ void spoolss_notify_sepfile(int snum, len = rpcstr_push(temp, printer->info_2->sepfile, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -2024,7 +2233,7 @@ void spoolss_notify_print_processor(int snum, len = rpcstr_push(temp, printer->info_2->printprocessor, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -2051,7 +2260,7 @@ void spoolss_notify_parameters(int snum, len = rpcstr_push(temp, printer->info_2->parameters, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -2078,7 +2287,7 @@ void spoolss_notify_datatype(int snum, len = rpcstr_push(temp, printer->info_2->datatype, sizeof(pstring)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -2238,7 +2447,7 @@ static void spoolss_notify_username(int snum, len = rpcstr_push(temp, queue->fs_user, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -2278,7 +2487,7 @@ static void spoolss_notify_job_name(int snum, len = rpcstr_push(temp, queue->fs_file, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -2328,7 +2537,7 @@ static void spoolss_notify_job_status_string(int snum, len = rpcstr_push(temp, p, sizeof(temp) - 2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -2452,8 +2661,6 @@ static void spoolss_notify_submitted_time(int snum, SSVAL(p, 14, st.milliseconds); } -#define END 65535 - struct s_notify_info_data_table { uint16 type; @@ -2471,18 +2678,18 @@ struct s_notify_info_data_table struct s_notify_info_data_table notify_info_data_table[] = { -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", POINTER, spoolss_notify_server_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, "PRINTER_NOTIFY_PRINTER_NAME", POINTER, spoolss_notify_printer_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SHARE_NAME, "PRINTER_NOTIFY_SHARE_NAME", POINTER, spoolss_notify_share_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PORT_NAME, "PRINTER_NOTIFY_PORT_NAME", POINTER, spoolss_notify_port_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DRIVER_NAME, "PRINTER_NOTIFY_DRIVER_NAME", POINTER, spoolss_notify_driver_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_COMMENT, "PRINTER_NOTIFY_COMMENT", POINTER, spoolss_notify_comment }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_LOCATION, "PRINTER_NOTIFY_LOCATION", POINTER, spoolss_notify_location }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", STRING, spoolss_notify_server_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, "PRINTER_NOTIFY_PRINTER_NAME", STRING, spoolss_notify_printer_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SHARE_NAME, "PRINTER_NOTIFY_SHARE_NAME", STRING, spoolss_notify_share_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PORT_NAME, "PRINTER_NOTIFY_PORT_NAME", STRING, spoolss_notify_port_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DRIVER_NAME, "PRINTER_NOTIFY_DRIVER_NAME", STRING, spoolss_notify_driver_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_COMMENT, "PRINTER_NOTIFY_COMMENT", STRING, spoolss_notify_comment }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_LOCATION, "PRINTER_NOTIFY_LOCATION", STRING, spoolss_notify_location }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEVMODE, "PRINTER_NOTIFY_DEVMODE", POINTER, spoolss_notify_devmode }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SEPFILE, "PRINTER_NOTIFY_SEPFILE", POINTER, spoolss_notify_sepfile }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINT_PROCESSOR, "PRINTER_NOTIFY_PRINT_PROCESSOR", POINTER, spoolss_notify_print_processor }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PARAMETERS, "PRINTER_NOTIFY_PARAMETERS", POINTER, spoolss_notify_parameters }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DATATYPE, "PRINTER_NOTIFY_DATATYPE", POINTER, spoolss_notify_datatype }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SEPFILE, "PRINTER_NOTIFY_SEPFILE", STRING, spoolss_notify_sepfile }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINT_PROCESSOR, "PRINTER_NOTIFY_PRINT_PROCESSOR", STRING, spoolss_notify_print_processor }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PARAMETERS, "PRINTER_NOTIFY_PARAMETERS", STRING, spoolss_notify_parameters }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DATATYPE, "PRINTER_NOTIFY_DATATYPE", STRING, spoolss_notify_datatype }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SECURITY_DESCRIPTOR, "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", POINTER, spoolss_notify_security_desc }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_ATTRIBUTES, "PRINTER_NOTIFY_ATTRIBUTES", ONE_VALUE, spoolss_notify_attributes }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRIORITY, "PRINTER_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, @@ -2497,20 +2704,20 @@ struct s_notify_info_data_table notify_info_data_table[] = { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PAGES_PRINTED, "PRINTER_NOTIFY_PAGES_PRINTED", POINTER, NULL }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_BYTES, "PRINTER_NOTIFY_TOTAL_BYTES", POINTER, NULL }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_BYTES_PRINTED, "PRINTER_NOTIFY_BYTES_PRINTED", POINTER, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINTER_NAME, "JOB_NOTIFY_PRINTER_NAME", POINTER, spoolss_notify_printer_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_MACHINE_NAME, "JOB_NOTIFY_MACHINE_NAME", POINTER, spoolss_notify_server_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PORT_NAME, "JOB_NOTIFY_PORT_NAME", POINTER, spoolss_notify_port_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_USER_NAME, "JOB_NOTIFY_USER_NAME", POINTER, spoolss_notify_username }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_NOTIFY_NAME, "JOB_NOTIFY_NOTIFY_NAME", POINTER, spoolss_notify_username }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DATATYPE, "JOB_NOTIFY_DATATYPE", POINTER, spoolss_notify_datatype }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINT_PROCESSOR, "JOB_NOTIFY_PRINT_PROCESSOR", POINTER, spoolss_notify_print_processor }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PARAMETERS, "JOB_NOTIFY_PARAMETERS", POINTER, spoolss_notify_parameters }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DRIVER_NAME, "JOB_NOTIFY_DRIVER_NAME", POINTER, spoolss_notify_driver_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINTER_NAME, "JOB_NOTIFY_PRINTER_NAME", STRING, spoolss_notify_printer_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_MACHINE_NAME, "JOB_NOTIFY_MACHINE_NAME", STRING, spoolss_notify_server_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PORT_NAME, "JOB_NOTIFY_PORT_NAME", STRING, spoolss_notify_port_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_USER_NAME, "JOB_NOTIFY_USER_NAME", STRING, spoolss_notify_username }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_NOTIFY_NAME, "JOB_NOTIFY_NOTIFY_NAME", STRING, spoolss_notify_username }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DATATYPE, "JOB_NOTIFY_DATATYPE", STRING, spoolss_notify_datatype }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINT_PROCESSOR, "JOB_NOTIFY_PRINT_PROCESSOR", STRING, spoolss_notify_print_processor }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PARAMETERS, "JOB_NOTIFY_PARAMETERS", STRING, spoolss_notify_parameters }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DRIVER_NAME, "JOB_NOTIFY_DRIVER_NAME", STRING, spoolss_notify_driver_name }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_DEVMODE, "JOB_NOTIFY_DEVMODE", POINTER, spoolss_notify_devmode }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS, "JOB_NOTIFY_STATUS", ONE_VALUE, spoolss_notify_job_status }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS_STRING, "JOB_NOTIFY_STATUS_STRING", POINTER, spoolss_notify_job_status_string }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS_STRING, "JOB_NOTIFY_STATUS_STRING", STRING, spoolss_notify_job_status_string }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_SECURITY_DESCRIPTOR, "JOB_NOTIFY_SECURITY_DESCRIPTOR", POINTER, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DOCUMENT, "JOB_NOTIFY_DOCUMENT", POINTER, spoolss_notify_job_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DOCUMENT, "JOB_NOTIFY_DOCUMENT", STRING, spoolss_notify_job_name }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_PRIORITY, "JOB_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_POSITION, "JOB_NOTIFY_POSITION", ONE_VALUE, spoolss_notify_job_position }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_SUBMITTED, "JOB_NOTIFY_SUBMITTED", POINTER, spoolss_notify_submitted_time }, @@ -2520,8 +2727,6 @@ struct s_notify_info_data_table notify_info_data_table[] = { JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", ONE_VALUE, spoolss_notify_total_pages }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", ONE_VALUE, spoolss_notify_pages_printed }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_BYTES, "JOB_NOTIFY_TOTAL_BYTES", ONE_VALUE, spoolss_notify_job_size }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_BYTES_PRINTED, "JOB_NOTIFY_BYTES_PRINTED", ONE_VALUE, NULL }, -{ END, END, "", END, NULL } }; /******************************************************************* @@ -2532,43 +2737,46 @@ static uint32 size_of_notify_info_data(uint16 type, uint16 field) { int i=0; - while (notify_info_data_table[i].type != END) - { - if ( (notify_info_data_table[i].type == type ) && - (notify_info_data_table[i].field == field ) ) - { - return (notify_info_data_table[i].size); + for (i = 0; i < sizeof(notify_info_data_table); i++) { + if (notify_info_data_table[i].type == type && + notify_info_data_table[i].field == field) { + switch(notify_info_data_table[i].size) { + case ONE_VALUE: + case TWO_VALUE: + return 1; + case STRING: + return 2; + + /* The only pointer notify data I have seen on + the wire is the submitted time and this has + the notify size set to 4. -tpot */ + + case POINTER: + return 4; + } } - i++; } - return (65535); + + DEBUG(5, ("invalid notify data type %d/%d\n", type, field)); + + return 0; } /******************************************************************* Return the type of notify_info_data. ********************************************************************/ -static BOOL type_of_notify_info_data(uint16 type, uint16 field) +static int type_of_notify_info_data(uint16 type, uint16 field) { int i=0; - while (notify_info_data_table[i].type != END) - { - if ( (notify_info_data_table[i].type == type ) && - (notify_info_data_table[i].field == field ) ) - { - if (notify_info_data_table[i].size == POINTER) - { - return (False); - } - else - { - return (True); - } - } - i++; + for (i = 0; i < sizeof(notify_info_data_table); i++) { + if (notify_info_data_table[i].type == type && + notify_info_data_table[i].field == field) + return notify_info_data_table[i].size; } - return (False); + + return False; } /**************************************************************************** @@ -2576,21 +2784,18 @@ static BOOL type_of_notify_info_data(uint16 type, uint16 field) static int search_notify(uint16 type, uint16 field, int *value) { - int j; - BOOL found; + int i; - for (j=0, found=False; found==False && notify_info_data_table[j].type != END ; j++) - { - if ( (notify_info_data_table[j].type == type ) && - (notify_info_data_table[j].field == field ) ) - found=True; + for (i = 0; i < sizeof(notify_info_data_table); i++) { + if (notify_info_data_table[i].type == type && + notify_info_data_table[i].field == field && + notify_info_data_table[i].fn != NULL) { + *value = i; + return True; + } } - *value=--j; - - if ( found && (notify_info_data_table[j].fn != NULL) ) - return True; - else - return False; + + return False; } /**************************************************************************** @@ -2601,7 +2806,12 @@ void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 info_data->type = type; info_data->field = field; info_data->reserved = 0; - info_data->id = id; + + if (type == JOB_NOTIFY_TYPE) + info_data->id = id; + else + info_data->id = 0; + info_data->size = size_of_notify_info_data(type, field); info_data->enc_type = type_of_notify_info_data(type, field); } @@ -2650,7 +2860,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int current_data=&info->data[info->count]; - construct_info_data(current_data, type, field, id); + construct_info_data(current_data, type, field, id); DEBUG(10,("construct_notify_printer_info: calling [%s] snum=%d printername=[%s])\n", notify_info_data_table[j].name, snum, printer->info_2->printername )); @@ -2892,7 +3102,6 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCNEX *r_u) { POLICY_HND *handle = &q_u->handle; -/* uint32 change = q_u->change; - notused. */ /* SPOOL_NOTIFY_OPTION *option = q_u->option; - notused. */ SPOOL_NOTIFY_INFO *info = &r_u->info; @@ -2910,17 +3119,19 @@ WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN DEBUG(4,("Printer type %x\n",Printer->printer_type)); - /* jfm: the change value isn't used right now. - * we will honour it when - * a) we'll be able to send notification to the client - * b) we'll have a way to communicate between the spoolss process. - * - * same thing for option->flags + /* + * We are now using the change value, and * I should check for PRINTER_NOTIFY_OPTIONS_REFRESH but as * I don't have a global notification system, I'm sending back all the * informations even when _NOTHING_ has changed. */ + /* We need to keep track of the change value to send back in + RRPCN replies otherwise our updates are ignored. */ + + if (Printer->notify.client_connected) + Printer->notify.change = q_u->change; + /* just ignore the SPOOL_NOTIFY_OPTION */ switch (Printer->printer_type) { @@ -3051,7 +3262,6 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) * construct_printer_info_1 * fill a printer_info_1 struct ********************************************************************/ - static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int snum) { pstring chaine; @@ -3126,8 +3336,10 @@ static DEVICEMODE *construct_dev_mode(int snum) if (printer->info_2->devmode) ntdevmode = dup_nt_devicemode(printer->info_2->devmode); - if (ntdevmode == NULL) + if (ntdevmode == NULL) { + DEBUG(5, ("BONG! There was no device mode!\n")); goto fail; + } DEBUGADD(8,("loading DEVICEMODE\n")); @@ -3545,9 +3757,9 @@ static WERROR enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint3 } /* check the required size. */ - for (i=0; i<*returned; i++) + for (i=0; i<*returned; i++) (*needed) += spoolss_size_printer_info_2(&printers[i]); - + if (!alloc_buffer_size(buffer, *needed)) { for (i=0; i<*returned; i++) { free_devmode(printers[i].devmode); @@ -3777,7 +3989,7 @@ static WERROR getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, u /* check the required size. */ *needed += spoolss_size_printer_info_2(printer); - + if (!alloc_buffer_size(buffer, *needed)) { free_printer_info_2(printer); return WERR_INSUFFICIENT_BUFFER; @@ -4824,6 +5036,7 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) { + extern userdom_struct current_user_info; char *cmd = lp_addprinter_cmd(); char **qlines; pstring command; @@ -4838,14 +5051,13 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) get_called_name()); /* change \ to \\ for the shell */ all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring)); - standard_sub_basic("", remote_machine); - + standard_sub_basic(current_user_info.smb_name, remote_machine); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", cmd, printer->info_2->printername, printer->info_2->sharename, printer->info_2->portname, printer->info_2->drivername, printer->info_2->location, driverlocation, remote_machine); - /* Convert script args to unix-codepage */ DEBUG(10,("Running [%s]\n", command)); ret = smbrun(command, &fd); DEBUGADD(10,("returned [%d]\n", ret)); @@ -4873,9 +5085,6 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) } file_lines_free(qlines); - - update_server_announce_as_printserver(); - return True; } @@ -5139,13 +5348,10 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, int snum; NT_PRINTER_INFO_LEVEL *printer = NULL, *old_printer = NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - PRINTER_MESSAGE_INFO msg; WERROR result; DEBUG(8,("update_printer\n")); - - ZERO_STRUCT(msg); - + result = WERR_OK; if (level!=2) { @@ -5263,7 +5469,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, DEBUG(5,("update_printer: Error restoring driver initialization data for driver [%s]!\n", printer->info_2->drivername)); } - msg.flags |= PRINTER_MESSAGE_DRIVER; + notify_printer_driver(snum, printer->info_2->drivername); } } @@ -5274,26 +5480,18 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, all the possible changes */ if (!strequal(printer->info_2->comment, old_printer->info_2->comment)) - msg.flags |= PRINTER_MESSAGE_COMMENT; + notify_printer_comment(snum, printer->info_2->comment); if (!strequal(printer->info_2->sharename, old_printer->info_2->sharename)) - msg.flags |= PRINTER_MESSAGE_SHARENAME; + notify_printer_sharename(snum, printer->info_2->sharename); if (!strequal(printer->info_2->portname, old_printer->info_2->portname)) - msg.flags |= PRINTER_MESSAGE_PORT; + notify_printer_port(snum, printer->info_2->portname); if (!strequal(printer->info_2->location, old_printer->info_2->location)) - msg.flags |= PRINTER_MESSAGE_LOCATION; - - msg.low = PRINTER_CHANGE_ADD_PRINTER; - fstrcpy(msg.printer_name, printer->info_2->printername); + notify_printer_location(snum, printer->info_2->location); - /* only send a notify if something changed */ - if (msg.flags) { - srv_spoolss_sendnotify(msg.printer_name, 0, PRINTER_CHANGE_ADD_PRINTER, msg.flags); - } - - done: +done: free_a_printer(&printer, 2); free_a_printer(&old_printer, 2); @@ -5411,7 +5609,7 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, int position, int snum, - NT_PRINTER_INFO_LEVEL *ntprinter, + NT_PRINTER_INFO_LEVEL *ntprinter, DEVICEMODE *devmode) { pstring temp_name; @@ -5528,7 +5726,7 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, *returned = 0; goto done; } - + if (!(devmode = construct_dev_mode(snum))) { *returned = 0; result = WERR_NOMEM; @@ -5571,6 +5769,7 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, SAFE_FREE(info); return result; + } /**************************************************************************** @@ -6516,9 +6715,6 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ } update_c_setprinter(False); - - srv_spoolss_sendnotify(printer->info_2->printername, 0, PRINTER_CHANGE_ADD_PRINTER, 0x0); - free_a_printer(&printer,2); return WERR_OK; @@ -6593,27 +6789,27 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, } /* BEGIN_ADMIN_LOG */ - switch(level) { - case 3: - sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", - driver.info_3->name,drv_ver_to_os[driver.info_3->cversion],uidtoname(user.uid)); - fstrcpy(driver_name, driver.info_3->name); - break; - case 6: - sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", - driver.info_6->name,drv_ver_to_os[driver.info_6->version],uidtoname(user.uid)); - fstrcpy(driver_name, driver.info_6->name); - break; - } + switch(level) { + case 3: + sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", + driver.info_3->name,drv_ver_to_os[driver.info_3->cversion],uidtoname(user.uid)); + fstrcpy(driver_name, driver.info_3->name); + break; + case 6: + sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", + driver.info_6->name,drv_ver_to_os[driver.info_6->version],uidtoname(user.uid)); + fstrcpy(driver_name, driver.info_6->name); + break; + } /* END_ADMIN_LOG */ - /* + /* * I think this is where he DrvUpgradePrinter() hook would be * be called in a driver's interface DLL on a Windows NT 4.0/2k * server. Right now, we just need to send ourselves a message - * to update each printer bound to this driver. --jerry + * to update each printer bound to this driver. --jerry */ - + if (!srv_spoolss_drv_upgrade_printer(driver_name)) { DEBUG(0,("_spoolss_addprinterdriver: Failed to send message about upgrading driver [%s]!\n", driver_name)); @@ -6656,9 +6852,9 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, /* * No 2k/Xp driver found, delete init data (if any) for the new Nt driver. */ - if (!del_driver_init(driver_name)) + if (!del_driver_init(driver_name)) DEBUG(6,("_spoolss_addprinterdriver: del_driver_init(%s) Nt failed!\n", driver_name)); - } else { + } else { /* * a 2k/Xp driver was found, don't delete init data because Nt driver will use it. */ @@ -6680,10 +6876,10 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, default: DEBUG(0,("_spoolss_addprinterdriver: invalid level=%d\n", level)); break; - } + } - done: +done: free_a_printer_driver(driver, level); return err; } @@ -6869,7 +7065,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S if((*out_value=(uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL) return WERR_NOMEM; - *out_value_len = rpcstr_push((char *)*out_value, "", in_value_len, 0); + *out_value_len = (uint32)rpcstr_push((char *)*out_value, "", in_value_len, 0); /* the data is counted in bytes */ *out_max_data_len = in_data_len; @@ -6897,7 +7093,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S return WERR_NOMEM; } - *out_value_len = rpcstr_push((char *)*out_value,value, in_value_len, 0); + *out_value_len = (uint32)rpcstr_push((char *)*out_value,value, in_value_len, 0); *out_type=type; @@ -7604,7 +7800,7 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin free_job_info_2(info_2); /* Also frees devmode */ SAFE_FREE(info_2); free_a_printer(&ntprinter, 2); - + return ret; } -- cgit From f201450f39c8a44c0da04a9289b245d5de5290c8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 28 Jun 2002 19:41:17 +0000 Subject: Added limit on SPOOLSS pipes from 2.2.x Jeremy. (This used to be commit b35fc30c37fa894acea3fcb7b48ee9841d1bd5e8) --- source3/rpc_server/srv_pipe_hnd.c | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index c55e05fe8d..d4d45c230c 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -35,6 +35,23 @@ static int pipes_open; #define MAX_OPEN_PIPES 2048 #endif +/* + * Sometimes I can't decide if I hate Windows printer driver + * writers more than I hate the Windows spooler service driver + * writers. This gets around a combination of bugs in the spooler + * and the HP 8500 PCL driver that causes a spooler spin. JRA. + * + * bumped up from 20 -> 64 after viewing traffic from WordPerfect + * 2002 running on NT 4.- SP6 + * bumped up from 64 -> 256 after viewing traffic from con2prt + * for lots of printers on a WinNT 4.x SP6 box. + */ + +#ifndef MAX_OPEN_SPOOLSS_PIPES +#define MAX_OPEN_SPOOLSS_PIPES 256 +#endif +static int current_spoolss_pipes_open; + static smb_np_struct *Pipes; static pipes_struct *InternalPipes; static struct bitmap *bmap; @@ -102,6 +119,7 @@ void set_pipe_handle_offset(int max_open_files) /**************************************************************************** Reset pipe chain handle number. ****************************************************************************/ + void reset_chain_p(void) { chain_p = NULL; @@ -158,11 +176,20 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, int i; smb_np_struct *p, *p_it; static int next_pipe; + BOOL is_spoolss_pipe = False; DEBUG(4,("Open pipe requested %s (pipes_open=%d)\n", pipe_name, pipes_open)); - + if (strstr(pipe_name, "spoolss")) + is_spoolss_pipe = True; + + if (is_spoolss_pipe && current_spoolss_pipes_open >= MAX_OPEN_SPOOLSS_PIPES) { + DEBUG(10,("open_rpc_pipe_p: spooler bug workaround. Denying open on pipe %s\n", + pipe_name )); + return NULL; + } + /* not repeating pipe numbers makes it easier to track things in log files and prevents client bugs where pipe numbers are reused over connection restarts */ @@ -183,8 +210,7 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, p = (smb_np_struct *)malloc(sizeof(*p)); - if (!p) - { + if (!p) { DEBUG(0,("ERROR! no memory for pipes_struct!\n")); return NULL; } @@ -201,13 +227,11 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, p->np_state = p->namedpipe_create(pipe_name, conn, vuid); if (p->np_state == NULL) { - DEBUG(0,("open_rpc_pipe_p: make_internal_rpc_pipe_p failed.\n")); SAFE_FREE(p); return NULL; } - DLIST_ADD(Pipes, p); /* @@ -247,7 +271,7 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, } /**************************************************************************** - * make an internal namedpipes structure + Make an internal namedpipes structure ****************************************************************************/ static void *make_internal_rpc_pipe_p(char *pipe_name, @@ -321,9 +345,8 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, p->pipe_user.gid = (gid_t)-1; /* Store the session key */ - if (vuser) { + if (vuser) memcpy(p->session_key, vuser->session_key, sizeof(p->session_key)); - } /* * Initialize the incoming RPC struct. -- cgit From 9930b0b0650ae3e38c033c28672398425dd8228c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 1 Jul 2002 09:12:41 +0000 Subject: used findstatic.pl to make some variables static and remove some dead code (This used to be commit 91ad9041e9507d36eb3f40c23c5d4df61f139ef0) --- source3/rpc_server/srv_srvsvc.c | 2 +- source3/rpc_server/srv_srvsvc_nt.c | 2 +- source3/rpc_server/srv_wkssvc.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 96e6172366..5e1c005d54 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -495,7 +495,7 @@ static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) \PIPE\srvsvc commands ********************************************************************/ -struct api_struct api_srv_cmds[] = +static const struct api_struct api_srv_cmds[] = { { "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum }, { "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum }, diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index d99b45f3e6..e8fe603ed8 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1824,7 +1824,7 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ "Nigel Williams" . ***********************************************************************************/ -const char *server_disks[] = {"C:"}; +static const char *server_disks[] = {"C:"}; static uint32 get_server_disk_count(void) { diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 0138848440..c783becbbe 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -58,7 +58,7 @@ static BOOL api_wks_query_info(pipes_struct *p) /******************************************************************* \PIPE\wkssvc commands ********************************************************************/ -struct api_struct api_wks_cmds[] = +static struct api_struct api_wks_cmds[] = { { "WKS_Q_QUERY_INFO", WKS_QUERY_INFO, api_wks_query_info }, { NULL , 0 , NULL } -- cgit From 5106ead0e041391b9eaa583894cc539e61a0ab5a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Jul 2002 04:07:32 +0000 Subject: Merge of constant renames from APPLIANCE_HEAD. (This used to be commit daf4c6a013ffa474d768055e73a1cb31ee941e80) --- source3/rpc_server/srv_spoolss_nt.c | 106 ++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 53 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0b172aa0e5..7e793c1e1d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2678,55 +2678,55 @@ struct s_notify_info_data_table struct s_notify_info_data_table notify_info_data_table[] = { -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", STRING, spoolss_notify_server_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, "PRINTER_NOTIFY_PRINTER_NAME", STRING, spoolss_notify_printer_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SHARE_NAME, "PRINTER_NOTIFY_SHARE_NAME", STRING, spoolss_notify_share_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PORT_NAME, "PRINTER_NOTIFY_PORT_NAME", STRING, spoolss_notify_port_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DRIVER_NAME, "PRINTER_NOTIFY_DRIVER_NAME", STRING, spoolss_notify_driver_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_COMMENT, "PRINTER_NOTIFY_COMMENT", STRING, spoolss_notify_comment }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_LOCATION, "PRINTER_NOTIFY_LOCATION", STRING, spoolss_notify_location }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEVMODE, "PRINTER_NOTIFY_DEVMODE", POINTER, spoolss_notify_devmode }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SEPFILE, "PRINTER_NOTIFY_SEPFILE", STRING, spoolss_notify_sepfile }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINT_PROCESSOR, "PRINTER_NOTIFY_PRINT_PROCESSOR", STRING, spoolss_notify_print_processor }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PARAMETERS, "PRINTER_NOTIFY_PARAMETERS", STRING, spoolss_notify_parameters }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DATATYPE, "PRINTER_NOTIFY_DATATYPE", STRING, spoolss_notify_datatype }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SECURITY_DESCRIPTOR, "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", POINTER, spoolss_notify_security_desc }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_ATTRIBUTES, "PRINTER_NOTIFY_ATTRIBUTES", ONE_VALUE, spoolss_notify_attributes }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRIORITY, "PRINTER_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEFAULT_PRIORITY, "PRINTER_NOTIFY_DEFAULT_PRIORITY", ONE_VALUE, spoolss_notify_default_priority }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_START_TIME, "PRINTER_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_UNTIL_TIME, "PRINTER_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS, "PRINTER_NOTIFY_STATUS", ONE_VALUE, spoolss_notify_status }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS_STRING, "PRINTER_NOTIFY_STATUS_STRING", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_CJOBS, "PRINTER_NOTIFY_CJOBS", ONE_VALUE, spoolss_notify_cjobs }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_AVERAGE_PPM, "PRINTER_NOTIFY_AVERAGE_PPM", ONE_VALUE, spoolss_notify_average_ppm }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_PAGES, "PRINTER_NOTIFY_TOTAL_PAGES", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PAGES_PRINTED, "PRINTER_NOTIFY_PAGES_PRINTED", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_BYTES, "PRINTER_NOTIFY_TOTAL_BYTES", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_BYTES_PRINTED, "PRINTER_NOTIFY_BYTES_PRINTED", POINTER, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINTER_NAME, "JOB_NOTIFY_PRINTER_NAME", STRING, spoolss_notify_printer_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_MACHINE_NAME, "JOB_NOTIFY_MACHINE_NAME", STRING, spoolss_notify_server_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PORT_NAME, "JOB_NOTIFY_PORT_NAME", STRING, spoolss_notify_port_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_USER_NAME, "JOB_NOTIFY_USER_NAME", STRING, spoolss_notify_username }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_NOTIFY_NAME, "JOB_NOTIFY_NOTIFY_NAME", STRING, spoolss_notify_username }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DATATYPE, "JOB_NOTIFY_DATATYPE", STRING, spoolss_notify_datatype }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINT_PROCESSOR, "JOB_NOTIFY_PRINT_PROCESSOR", STRING, spoolss_notify_print_processor }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PARAMETERS, "JOB_NOTIFY_PARAMETERS", STRING, spoolss_notify_parameters }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DRIVER_NAME, "JOB_NOTIFY_DRIVER_NAME", STRING, spoolss_notify_driver_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DEVMODE, "JOB_NOTIFY_DEVMODE", POINTER, spoolss_notify_devmode }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS, "JOB_NOTIFY_STATUS", ONE_VALUE, spoolss_notify_job_status }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS_STRING, "JOB_NOTIFY_STATUS_STRING", STRING, spoolss_notify_job_status_string }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SECURITY_DESCRIPTOR, "JOB_NOTIFY_SECURITY_DESCRIPTOR", POINTER, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DOCUMENT, "JOB_NOTIFY_DOCUMENT", STRING, spoolss_notify_job_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRIORITY, "JOB_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_POSITION, "JOB_NOTIFY_POSITION", ONE_VALUE, spoolss_notify_job_position }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SUBMITTED, "JOB_NOTIFY_SUBMITTED", POINTER, spoolss_notify_submitted_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_START_TIME, "JOB_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_UNTIL_TIME, "JOB_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TIME, "JOB_NOTIFY_TIME", ONE_VALUE, spoolss_notify_job_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", ONE_VALUE, spoolss_notify_total_pages }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", ONE_VALUE, spoolss_notify_pages_printed }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_BYTES, "JOB_NOTIFY_TOTAL_BYTES", ONE_VALUE, spoolss_notify_job_size }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", NOTIFY_STRING, spoolss_notify_server_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, "PRINTER_NOTIFY_PRINTER_NAME", NOTIFY_STRING, spoolss_notify_printer_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SHARE_NAME, "PRINTER_NOTIFY_SHARE_NAME", NOTIFY_STRING, spoolss_notify_share_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PORT_NAME, "PRINTER_NOTIFY_PORT_NAME", NOTIFY_STRING, spoolss_notify_port_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DRIVER_NAME, "PRINTER_NOTIFY_DRIVER_NAME", NOTIFY_STRING, spoolss_notify_driver_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_COMMENT, "PRINTER_NOTIFY_COMMENT", NOTIFY_STRING, spoolss_notify_comment }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_LOCATION, "PRINTER_NOTIFY_LOCATION", NOTIFY_STRING, spoolss_notify_location }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEVMODE, "PRINTER_NOTIFY_DEVMODE", NOTIFY_POINTER, spoolss_notify_devmode }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SEPFILE, "PRINTER_NOTIFY_SEPFILE", NOTIFY_STRING, spoolss_notify_sepfile }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINT_PROCESSOR, "PRINTER_NOTIFY_PRINT_PROCESSOR", NOTIFY_STRING, spoolss_notify_print_processor }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PARAMETERS, "PRINTER_NOTIFY_PARAMETERS", NOTIFY_STRING, spoolss_notify_parameters }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DATATYPE, "PRINTER_NOTIFY_DATATYPE", NOTIFY_STRING, spoolss_notify_datatype }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SECURITY_DESCRIPTOR, "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", NOTIFY_POINTER, spoolss_notify_security_desc }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_ATTRIBUTES, "PRINTER_NOTIFY_ATTRIBUTES", NOTIFY_ONE_VALUE, spoolss_notify_attributes }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRIORITY, "PRINTER_NOTIFY_PRIORITY", NOTIFY_ONE_VALUE, spoolss_notify_priority }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEFAULT_PRIORITY, "PRINTER_NOTIFY_DEFAULT_PRIORITY", NOTIFY_ONE_VALUE, spoolss_notify_default_priority }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_START_TIME, "PRINTER_NOTIFY_START_TIME", NOTIFY_ONE_VALUE, spoolss_notify_start_time }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_UNTIL_TIME, "PRINTER_NOTIFY_UNTIL_TIME", NOTIFY_ONE_VALUE, spoolss_notify_until_time }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS, "PRINTER_NOTIFY_STATUS", NOTIFY_ONE_VALUE, spoolss_notify_status }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS_STRING, "PRINTER_NOTIFY_STATUS_STRING", NOTIFY_POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_CJOBS, "PRINTER_NOTIFY_CJOBS", NOTIFY_ONE_VALUE, spoolss_notify_cjobs }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_AVERAGE_PPM, "PRINTER_NOTIFY_AVERAGE_PPM", NOTIFY_ONE_VALUE, spoolss_notify_average_ppm }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_PAGES, "PRINTER_NOTIFY_TOTAL_PAGES", NOTIFY_POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PAGES_PRINTED, "PRINTER_NOTIFY_PAGES_PRINTED", NOTIFY_POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_BYTES, "PRINTER_NOTIFY_TOTAL_BYTES", NOTIFY_POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_BYTES_PRINTED, "PRINTER_NOTIFY_BYTES_PRINTED", NOTIFY_POINTER, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINTER_NAME, "JOB_NOTIFY_PRINTER_NAME", NOTIFY_STRING, spoolss_notify_printer_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_MACHINE_NAME, "JOB_NOTIFY_MACHINE_NAME", NOTIFY_STRING, spoolss_notify_server_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PORT_NAME, "JOB_NOTIFY_PORT_NAME", NOTIFY_STRING, spoolss_notify_port_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_USER_NAME, "JOB_NOTIFY_USER_NAME", NOTIFY_STRING, spoolss_notify_username }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_NOTIFY_NAME, "JOB_NOTIFY_NOTIFY_NAME", NOTIFY_STRING, spoolss_notify_username }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DATATYPE, "JOB_NOTIFY_DATATYPE", NOTIFY_STRING, spoolss_notify_datatype }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINT_PROCESSOR, "JOB_NOTIFY_PRINT_PROCESSOR", NOTIFY_STRING, spoolss_notify_print_processor }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PARAMETERS, "JOB_NOTIFY_PARAMETERS", NOTIFY_STRING, spoolss_notify_parameters }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DRIVER_NAME, "JOB_NOTIFY_DRIVER_NAME", NOTIFY_STRING, spoolss_notify_driver_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DEVMODE, "JOB_NOTIFY_DEVMODE", NOTIFY_POINTER, spoolss_notify_devmode }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS, "JOB_NOTIFY_STATUS", NOTIFY_ONE_VALUE, spoolss_notify_job_status }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS_STRING, "JOB_NOTIFY_STATUS_STRING", NOTIFY_STRING, spoolss_notify_job_status_string }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SECURITY_DESCRIPTOR, "JOB_NOTIFY_SECURITY_DESCRIPTOR", NOTIFY_POINTER, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DOCUMENT, "JOB_NOTIFY_DOCUMENT", NOTIFY_STRING, spoolss_notify_job_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRIORITY, "JOB_NOTIFY_PRIORITY", NOTIFY_ONE_VALUE, spoolss_notify_priority }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_POSITION, "JOB_NOTIFY_POSITION", NOTIFY_ONE_VALUE, spoolss_notify_job_position }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SUBMITTED, "JOB_NOTIFY_SUBMITTED", NOTIFY_POINTER, spoolss_notify_submitted_time }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_START_TIME, "JOB_NOTIFY_START_TIME", NOTIFY_ONE_VALUE, spoolss_notify_start_time }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_UNTIL_TIME, "JOB_NOTIFY_UNTIL_TIME", NOTIFY_ONE_VALUE, spoolss_notify_until_time }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TIME, "JOB_NOTIFY_TIME", NOTIFY_ONE_VALUE, spoolss_notify_job_time }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", NOTIFY_ONE_VALUE, spoolss_notify_total_pages }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", NOTIFY_ONE_VALUE, spoolss_notify_pages_printed }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_BYTES, "JOB_NOTIFY_TOTAL_BYTES", NOTIFY_ONE_VALUE, spoolss_notify_job_size }, }; /******************************************************************* @@ -2741,17 +2741,17 @@ static uint32 size_of_notify_info_data(uint16 type, uint16 field) if (notify_info_data_table[i].type == type && notify_info_data_table[i].field == field) { switch(notify_info_data_table[i].size) { - case ONE_VALUE: - case TWO_VALUE: + case NOTIFY_ONE_VALUE: + case NOTIFY_TWO_VALUE: return 1; - case STRING: + case NOTIFY_STRING: return 2; /* The only pointer notify data I have seen on the wire is the submitted time and this has the notify size set to 4. -tpot */ - case POINTER: + case NOTIFY_POINTER: return 4; } } -- cgit From 82176f4d85225c2aae15f9ce3e03730f019934f5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 2 Jul 2002 06:34:27 +0000 Subject: Address the string_sub problem by changing len = 0 to mean "no expand". Went through and checked all string_subs I could to ensure they're being used correctly. Jeremy. (This used to be commit 17cae0d683be404be69554cd0e84117bdcc56c87) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- source3/rpc_server/srv_srvsvc_nt.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7e793c1e1d..9b17bdb7ee 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5051,7 +5051,7 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) get_called_name()); /* change \ to \\ for the shell */ all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring)); - standard_sub_basic(current_user_info.smb_name, remote_machine); + standard_sub_basic(current_user_info.smb_name, remote_machine,sizeof(remote_machine)); slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", cmd, printer->info_2->printername, printer->info_2->sharename, diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index e8fe603ed8..b5f6bd2f07 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -41,7 +41,7 @@ static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int sn pstrcpy(net_name, lp_servicename(snum)); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark); + standard_sub_conn(p->conn, remark,sizeof(remark)); len_net_name = strlen(net_name); /* work out the share type */ @@ -73,7 +73,7 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int sn pstrcpy(net_name, lp_servicename(snum)); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark); + standard_sub_conn(p->conn, remark,sizeof(remark)); pstrcpy(path, "C:"); pstrcat(path, lp_pathname(snum)); @@ -357,7 +357,7 @@ static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, pstrcpy(net_name, lp_servicename(snum)); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark); + standard_sub_conn(p->conn, remark, sizeof(remark)); len_net_name = strlen(net_name); @@ -396,7 +396,7 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, pstrcpy(net_name, lp_servicename(snum)); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark); + standard_sub_conn(p->conn, remark,sizeof(remark)); pstrcpy(path, "C:"); pstrcat(path, lp_pathname(snum)); -- cgit From 8e52737efc9cf746d7e9fd1f07bc42201dccbfba Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 3 Jul 2002 07:37:54 +0000 Subject: Break up the passdb objects (to allow RPC clients to link without brining in *.o) and implment new enum_dom_users code in the SAMR RPC subsystem. Incresingly, we are using the pdb_get_{user,group}_sid() functions, in the eventual hope that we might one day support muliple domains off a single passdb. To extract the RID, we use sid_peek_check_rid(), and supply an 'expected' domain SID. The id21 -> SAM_ACCOUNT and id23 -> SAM_ACCOUNT code has been moved to srv_samr_util.c, to ease linking in passdb users. Compatiblity code that uses 'get_global_sam_sid()' for the 'expected' sid is in pdb_compat.c Andrew Bartlett (This used to be commit 5a2a6f1ba316489d118a8bdd9551b155226de94f) --- source3/rpc_server/srv_samr_nt.c | 259 ++++++++++++++++--------------------- source3/rpc_server/srv_samr_util.c | 143 ++++++++++++++++++++ 2 files changed, 254 insertions(+), 148 deletions(-) create mode 100644 source3/rpc_server/srv_samr_util.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9e826436f6..9393917cde 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -126,19 +126,6 @@ static void free_samr_info(void *ptr) Ensure password info is never given out. Paranioa... JRA. ********************************************************************/ -static void samr_clear_passwd_fields( SAM_USER_INFO_21 *pass, int num_entries) -{ - int i; - - if (!pass) - return; - - for (i = 0; i < num_entries; i++) { - memset(&pass[i].lm_pwd, '\0', sizeof(pass[i].lm_pwd)); - memset(&pass[i].nt_pwd, '\0', sizeof(pass[i].nt_pwd)); - } -} - static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) { @@ -266,103 +253,6 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) } -/******************************************************************* - This next function should be replaced with something that - dynamically returns the correct user info..... JRA. - ********************************************************************/ - -static NTSTATUS 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) -{ - SAM_ACCOUNT *pwd = NULL; - BOOL not_finished = True; - NTSTATUS nt_status; - - (*num_entries) = 0; - (*total_entries) = 0; - - if (pw_buf == NULL) - return NT_STATUS_NO_MEMORY; - - if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&pwd))) { - return nt_status; - } - - 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; - const char *user_name; - - if (start_idx > 0) { - - pdb_free_sam(&pwd); - - if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&pwd))) { - pdb_endsampwent(); - return nt_status; - } - - /* skip the requested number of entries. - not very efficient, but hey... */ - start_idx--; - continue; - } - - user_name = pdb_get_username(pwd); - - if (!user_name) { - DEBUG(2, ("account had NULL username!\n")); - } else if (!(acb_mask == 0 || (pdb_get_acct_ctrl(pwd) & acb_mask))) { - DEBUG(5,(" acb_mask %x rejects\n", acb_mask)); - } else { - DEBUG(5,(" acb_mask %x accepts\n", acb_mask)); - - user_name_len = strlen(user_name)+1; - init_unistr2(&pw_buf[(*num_entries)].uni_user_name, user_name, user_name_len); - init_uni_hdr(&pw_buf[(*num_entries)].hdr_user_name, user_name_len); - 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 (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); - - 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) )); - - (*num_entries)++; - } - - (*total_entries)++; - - pdb_free_sam(&pwd); - - if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&pwd))) { - pdb_endsampwent(); - return nt_status; - } - - } - - pdb_endsampwent(); - pdb_free_sam(&pwd); - - if (not_finished) - return STATUS_MORE_ENTRIES; - else - return NT_STATUS_OK; -} - /******************************************************************* _samr_close_hnd ********************************************************************/ @@ -526,69 +416,118 @@ NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_ makes a SAM_ENTRY / UNISTR2* structure from a user list. ********************************************************************/ -static void make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNISTR2 **uni_name_pp, - uint32 num_sam_entries, SAM_USER_INFO_21 *pass) +static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNISTR2 **uni_name_pp, + uint32 num_entries, uint32 start_idx, DISP_USER_INFO *disp_user_info, + DOM_SID *domain_sid) { uint32 i; SAM_ENTRY *sam; UNISTR2 *uni_name; - + SAM_ACCOUNT *pwd = NULL; + UNISTR2 uni_temp_name; + const char *temp_name; + const DOM_SID *user_sid; + uint32 user_rid; + fstring user_sid_string; + fstring domain_sid_string; + *sam_pp = NULL; *uni_name_pp = NULL; - if (num_sam_entries == 0) - return; + if (num_entries == 0) + return NT_STATUS_OK; - sam = (SAM_ENTRY *)talloc_zero(ctx, sizeof(SAM_ENTRY)*num_sam_entries); + sam = (SAM_ENTRY *)talloc_zero(ctx, sizeof(SAM_ENTRY)*num_entries); - uni_name = (UNISTR2 *)talloc_zero(ctx, sizeof(UNISTR2)*num_sam_entries); + uni_name = (UNISTR2 *)talloc_zero(ctx, sizeof(UNISTR2)*num_entries); if (sam == NULL || uni_name == NULL) { - DEBUG(0, ("NULL pointers in SAMR_R_QUERY_DISPINFO\n")); - return; + DEBUG(0, ("make_user_sam_entry_list: talloc_zero failed!\n")); + return NT_STATUS_NO_MEMORY; } - ZERO_STRUCTP(sam); - ZERO_STRUCTP(uni_name); - - for (i = 0; i < num_sam_entries; i++) { - int len = pass[i].uni_user_name.uni_str_len; + for (i = 0; i < num_entries; i++) { + int len = uni_temp_name.uni_str_len; + + pwd = disp_user_info[i+start_idx].sam; + temp_name = pdb_get_username(pwd); + init_unistr2(&uni_temp_name, temp_name, strlen(temp_name)+1); + user_sid = pdb_get_user_sid(pwd); + + if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { + DEBUG(0, ("make_user_sam_entry_list: User %s has SID %s, which conflicts with " + "the domain sid %s. Failing operation.\n", + temp_name, + sid_to_string(user_sid_string, user_sid), + sid_to_string(domain_sid_string, domain_sid))); + return NT_STATUS_UNSUCCESSFUL; + } - init_sam_entry(&sam[i], len, pass[i].user_rid); - copy_unistr2(&uni_name[i], &pass[i].uni_user_name); + init_sam_entry(&sam[i], len, user_rid); + copy_unistr2(&uni_name[i], &uni_temp_name); } *sam_pp = sam; *uni_name_pp = uni_name; + return NT_STATUS_OK; } /******************************************************************* samr_reply_enum_dom_users ********************************************************************/ -NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_R_ENUM_DOM_USERS *r_u) +NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, + SAMR_R_ENUM_DOM_USERS *r_u) { - SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; - int num_entries = 0; - int total_entries = 0; + struct samr_info *info = NULL; + uint32 struct_size=0x20; /* W2K always reply that, client doesn't care */ + int num_account; + uint32 enum_context=q_u->start_idx; + uint32 max_size=q_u->max_size; + uint32 temp_size; + enum remote_arch_types ra_type = get_remote_arch(); + int max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K; + uint32 max_entries = max_sam_entries; + DOM_SID domain_sid; 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)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; + + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &domain_sid)) return NT_STATUS_INVALID_HANDLE; DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); become_root(); - r_u->status = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, - MAX_SAM_ENTRIES, q_u->acb_mask); + r_u->status=load_sampwd_entries(info, q_u->acb_mask); unbecome_root(); - - if (NT_STATUS_IS_ERR(r_u->status)) + + if (!NT_STATUS_IS_OK(r_u->status)) return r_u->status; - samr_clear_passwd_fields(pass, num_entries); + num_account = info->disp_info.num_user_account; + + if (enum_context > num_account) { + DEBUG(5, ("_samr_enum_dom_users: enumeration handle over total entries\n")); + return NT_STATUS_OK; + } + + /* verify we won't overflow */ + if (max_entries > num_account-enum_context) { + max_entries = num_account-enum_context; + DEBUG(5, ("_samr_enum_dom_users: only %d entries to return\n", max_entries)); + } + + /* calculate the size and limit on the number of entries we will return */ + temp_size=max_entries*struct_size; + + if (temp_size>max_size) { + max_entries=MIN((max_size/struct_size),max_entries);; + DEBUG(5, ("_samr_enum_dom_users: buffer size limits to only %d entries\n", max_entries)); + } /* * Note from JRA. total_entries is not being used here. Currently if there is a @@ -603,9 +542,20 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_ * value (again I think this is wrong). */ - make_user_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_acct_name, num_entries, pass); + r_u->status = make_user_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_acct_name, + max_entries, enum_context, + info->disp_info.disp_user_info, + &domain_sid); + + if (!NT_STATUS_IS_OK(r_u->status)) + return r_u->status; + + if (enum_context+max_entries < num_account) + r_u->status = STATUS_MORE_ENTRIES; + + DEBUG(5, ("_samr_enum_dom_users: %d\n", __LINE__)); - init_samr_r_enum_dom_users(r_u, q_u->start_idx + num_entries, num_entries); + init_samr_r_enum_dom_users(r_u, q_u->start_idx + max_entries, max_entries); DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); @@ -891,7 +841,8 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S /******************************************************************* samr_reply_query_dispinfo ********************************************************************/ -NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_QUERY_DISPINFO *r_u) +NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, + SAMR_R_QUERY_DISPINFO *r_u) { struct samr_info *info = NULL; uint32 struct_size=0x20; /* W2K always reply that, client doesn't care */ @@ -906,9 +857,8 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ NTSTATUS disp_ret; uint32 num_account = 0; enum remote_arch_types ra_type = get_remote_arch(); - int max_sam_entries; - - max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K; + int max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K; + DOM_SID domain_sid; DEBUG(5, ("samr_reply_query_dispinfo: %d\n", __LINE__)); r_u->status = NT_STATUS_OK; @@ -917,6 +867,9 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; + if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &domain_sid)) + return NT_STATUS_INVALID_HANDLE; + /* * calculate how many entries we will return. * based on @@ -1015,7 +968,8 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ if (!(ctr->sam.info1 = (SAM_DISPINFO_1 *)talloc_zero(p->mem_ctx,max_entries*sizeof(SAM_DISPINFO_1)))) return NT_STATUS_NO_MEMORY; } - disp_ret = init_sam_dispinfo_1(p->mem_ctx, ctr->sam.info1, max_entries, enum_context, info->disp_info.disp_user_info); + disp_ret = init_sam_dispinfo_1(p->mem_ctx, ctr->sam.info1, max_entries, enum_context, + info->disp_info.disp_user_info, &domain_sid); if (!NT_STATUS_IS_OK(disp_ret)) return disp_ret; break; @@ -1024,7 +978,8 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ if (!(ctr->sam.info2 = (SAM_DISPINFO_2 *)talloc_zero(p->mem_ctx,max_entries*sizeof(SAM_DISPINFO_2)))) return NT_STATUS_NO_MEMORY; } - disp_ret = init_sam_dispinfo_2(p->mem_ctx, ctr->sam.info2, max_entries, enum_context, info->disp_info.disp_user_info); + disp_ret = init_sam_dispinfo_2(p->mem_ctx, ctr->sam.info2, max_entries, enum_context, + info->disp_info.disp_user_info, &domain_sid); if (!NT_STATUS_IS_OK(disp_ret)) return disp_ret; break; @@ -1582,7 +1537,8 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, SAM_USER_INFO_20 *id20, DO get_user_info_21 *************************************************************************/ -static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, DOM_SID *user_sid) +static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, + DOM_SID *user_sid, DOM_SID *domain_sid) { SAM_ACCOUNT *sampass=NULL; BOOL ret; @@ -1607,7 +1563,7 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, DO DEBUG(3,("User:[%s]\n", pdb_get_username(sampass) )); ZERO_STRUCTP(id21); - init_sam_user_info21A(id21, sampass); + nt_status = init_sam_user_info21A(id21, sampass, domain_sid); pdb_free_sam(&sampass); @@ -1622,13 +1578,19 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ { SAM_USERINFO_CTR *ctr; struct samr_info *info = NULL; - + DOM_SID domain_sid; + uint32 rid; + r_u->status=NT_STATUS_OK; /* search for the handle */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; + domain_sid = info->sid; + + sid_split_rid(&domain_sid, &rid); + if (!sid_check_is_in_our_domain(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; @@ -1700,7 +1662,8 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ 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 (!NT_STATUS_IS_OK(r_u->status = get_user_info_21(p->mem_ctx, ctr->info.id21, &info->sid))) + if (!NT_STATUS_IS_OK(r_u->status = get_user_info_21(p->mem_ctx, ctr->info.id21, + &info->sid, &domain_sid))) return r_u->status; break; diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c new file mode 100644 index 0000000000..7a5b1e5f46 --- /dev/null +++ b/source3/rpc_server/srv_samr_util.c @@ -0,0 +1,143 @@ +/* + Unix SMB/CIFS implementation. + SAMR Pipe utility functions. + Copyright (C) Jeremy Allison 1996-2001 + Copyright (C) Luke Kenneth Casson Leighton 1996-1998 + Copyright (C) Gerald (Jerry) Carter 2000-2001 + Copyright (C) Andrew Bartlett 2001-2002 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +/************************************************************* + Copies a SAM_USER_INFO_23 to a SAM_ACCOUNT + **************************************************************/ + +void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) +{ + + if (from == NULL || to == NULL) + return; + + pdb_set_logon_time(to,nt_time_to_unix(&from->logon_time), True); + pdb_set_logoff_time(to,nt_time_to_unix(&from->logoff_time), True); + pdb_set_kickoff_time(to, nt_time_to_unix(&from->kickoff_time), True); + pdb_set_pass_can_change_time(to, nt_time_to_unix(&from->pass_can_change_time), True); + pdb_set_pass_must_change_time(to, nt_time_to_unix(&from->pass_must_change_time), True); + + pdb_set_pass_last_set_time(to, nt_time_to_unix(&from->pass_last_set_time)); + + if (from->uni_user_name.buffer) + pdb_set_username(to , pdb_unistr2_convert(&from->uni_user_name )); + if (from->uni_full_name.buffer) + pdb_set_fullname(to , pdb_unistr2_convert(&from->uni_full_name )); + if (from->uni_home_dir.buffer) + pdb_set_homedir(to , pdb_unistr2_convert(&from->uni_home_dir ), True); + if (from->uni_dir_drive.buffer) + pdb_set_dir_drive(to , pdb_unistr2_convert(&from->uni_dir_drive ), True); + if (from->uni_logon_script.buffer) + pdb_set_logon_script(to , pdb_unistr2_convert(&from->uni_logon_script), True); + if (from->uni_profile_path.buffer) + pdb_set_profile_path(to , pdb_unistr2_convert(&from->uni_profile_path), True); + if (from->uni_acct_desc.buffer) + pdb_set_acct_desc(to , pdb_unistr2_convert(&from->uni_acct_desc )); + if (from->uni_workstations.buffer) + pdb_set_workstations(to , pdb_unistr2_convert(&from->uni_workstations)); + if (from->uni_unknown_str.buffer) + pdb_set_unknown_str(to , pdb_unistr2_convert(&from->uni_unknown_str )); + if (from->uni_munged_dial.buffer) + pdb_set_munged_dial(to , pdb_unistr2_convert(&from->uni_munged_dial )); + + if (from->user_rid) + pdb_set_user_sid_from_rid(to, from->user_rid); + if (from->group_rid) + pdb_set_group_sid_from_rid(to, from->group_rid); + + pdb_set_acct_ctrl(to, from->acb_info); + pdb_set_unknown_3(to, from->unknown_3); + + pdb_set_logon_divs(to, from->logon_divs); + pdb_set_hours_len(to, from->logon_hrs.len); + pdb_set_hours(to, from->logon_hrs.hours); + + pdb_set_unknown_5(to, from->unknown_5); + pdb_set_unknown_6(to, from->unknown_6); +} + + +/************************************************************* + Copies a sam passwd. + **************************************************************/ + +void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) +{ + if (from == NULL || to == NULL) + return; + + pdb_set_logon_time(to,nt_time_to_unix(&from->logon_time), True); + pdb_set_logoff_time(to,nt_time_to_unix(&from->logoff_time), True); + pdb_set_kickoff_time(to, nt_time_to_unix(&from->kickoff_time), True); + pdb_set_pass_can_change_time(to, nt_time_to_unix(&from->pass_can_change_time), True); + pdb_set_pass_must_change_time(to, nt_time_to_unix(&from->pass_must_change_time), True); + + pdb_set_pass_last_set_time(to, nt_time_to_unix(&from->pass_last_set_time)); + + if (from->uni_user_name.buffer) + pdb_set_username(to , pdb_unistr2_convert(&from->uni_user_name )); + if (from->uni_full_name.buffer) + pdb_set_fullname(to , pdb_unistr2_convert(&from->uni_full_name )); + if (from->uni_home_dir.buffer) + pdb_set_homedir(to , pdb_unistr2_convert(&from->uni_home_dir ), True); + if (from->uni_dir_drive.buffer) + pdb_set_dir_drive(to , pdb_unistr2_convert(&from->uni_dir_drive ), True); + if (from->uni_logon_script.buffer) + pdb_set_logon_script(to , pdb_unistr2_convert(&from->uni_logon_script), True); + if (from->uni_profile_path.buffer) + pdb_set_profile_path(to , pdb_unistr2_convert(&from->uni_profile_path), True); + if (from->uni_acct_desc.buffer) + pdb_set_acct_desc(to , pdb_unistr2_convert(&from->uni_acct_desc )); + if (from->uni_workstations.buffer) + pdb_set_workstations(to , pdb_unistr2_convert(&from->uni_workstations)); + if (from->uni_unknown_str.buffer) + pdb_set_unknown_str(to , pdb_unistr2_convert(&from->uni_unknown_str )); + if (from->uni_munged_dial.buffer) + pdb_set_munged_dial(to , pdb_unistr2_convert(&from->uni_munged_dial )); + + if (from->user_rid) + pdb_set_user_sid_from_rid(to, from->user_rid); + if (from->group_rid) + pdb_set_group_sid_from_rid(to, from->group_rid); + + /* FIXME!! Do we need to copy the passwords here as well? + I don't know. Need to figure this out --jerry */ + + /* Passwords dealt with in caller --abartlet */ + + pdb_set_acct_ctrl(to, from->acb_info); + pdb_set_unknown_3(to, from->unknown_3); + + pdb_set_logon_divs(to, from->logon_divs); + pdb_set_hours_len(to, from->logon_hrs.len); + pdb_set_hours(to, from->logon_hrs.hours); + + pdb_set_unknown_5(to, from->unknown_5); + pdb_set_unknown_6(to, from->unknown_6); +} + -- cgit From a3c3960edc63eb242620bbda373cfd9ba8e7ad65 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 3 Jul 2002 19:15:26 +0000 Subject: first cut at implementing support for browsing printer and driver driver via regedt32.exe. The regsitry.tdb is only a framework. It is not intended to store values, only key/subkey structure. The data will be retrieved from nt*tdb (for printers) creating a virtual view of the data. You can currently connect to a Samba box using regedt32.exe (haven't tried regedit.exe). Some basic keys are created in registry.tdb for use. There are two problems.... * something is getting freed in the winreg code that causes heap corruption later on. As long as you don't play with the winreg server functionality, I don't think you'll be bitten by this. * no access controls are currently implemented * I can't browse HKLM because regedt32 greys out the SYSTEM subkey. ok so that was three.... (This used to be commit 542d3c93a998083c07b2afa91a7c927c376caf54) --- source3/rpc_server/srv_reg.c | 135 ++++++++- source3/rpc_server/srv_reg_nt.c | 655 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 734 insertions(+), 56 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index e024ba74e7..a096325860 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -1,11 +1,12 @@ -/* +/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. - * Copyright (C) Marc Jacobsen 2000. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Marc Jacobsen 2000. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Gerald Carter 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,10 +57,10 @@ static BOOL api_reg_close(pipes_struct *p) } /******************************************************************* - api_reg_open + api_reg_open_khlm ********************************************************************/ -static BOOL api_reg_open(pipes_struct *p) +static BOOL api_reg_open_hklm(pipes_struct *p) { REG_Q_OPEN_HKLM q_u; REG_R_OPEN_HKLM r_u; @@ -73,7 +74,7 @@ static BOOL api_reg_open(pipes_struct *p) if(!reg_io_q_open_hklm("", &q_u, data, 0)) return False; - r_u.status = _reg_open(p, &q_u, &r_u); + r_u.status = _reg_open_hklm(p, &q_u, &r_u); if(!reg_io_r_open_hklm("", &r_u, rdata, 0)) return False; @@ -81,6 +82,33 @@ static BOOL api_reg_open(pipes_struct *p) return True; } +/******************************************************************* + api_reg_open_khlm + ********************************************************************/ + +static BOOL api_reg_open_hku(pipes_struct *p) +{ + REG_Q_OPEN_HKU q_u; + REG_R_OPEN_HKU r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the reg open */ + if(!reg_io_q_open_hku("", &q_u, data, 0)) + return False; + + r_u.status = _reg_open_hku(p, &q_u, &r_u); + + if(!reg_io_r_open_hku("", &r_u, rdata, 0)) + return False; + + return True; +} + + /******************************************************************* api_reg_open_entry ********************************************************************/ @@ -187,18 +215,99 @@ static BOOL api_reg_abort_shutdown(pipes_struct *p) } +/******************************************************************* + api_reg_query_key + ********************************************************************/ + +static BOOL api_reg_query_key(pipes_struct *p) +{ + REG_Q_QUERY_KEY q_u; + REG_R_QUERY_KEY r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_query_key("", &q_u, data, 0)) + return False; + + r_u.status = _reg_query_key(p, &q_u, &r_u); + + if(!reg_io_r_query_key("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + api_reg_unknown_1a + ********************************************************************/ + +static BOOL api_reg_unknown_1a(pipes_struct *p) +{ + REG_Q_UNKNOWN_1A q_u; + REG_R_UNKNOWN_1A r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_unknown_1a("", &q_u, data, 0)) + return False; + + r_u.status = _reg_unknown_1a(p, &q_u, &r_u); + + if(!reg_io_r_unknown_1a("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + api_reg_enum_key + ********************************************************************/ + +static BOOL api_reg_enum_key(pipes_struct *p) +{ + REG_Q_ENUM_KEY q_u; + REG_R_ENUM_KEY r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_enum_key("", &q_u, data, 0)) + return False; + + r_u.status = _reg_enum_key(p, &q_u, &r_u); + + if(!reg_io_r_enum_key("", &r_u, rdata, 0)) + return False; + + return True; +} + + + /******************************************************************* array of \PIPE\reg operations ********************************************************************/ static struct api_struct api_reg_cmds[] = { - { "REG_CLOSE" , REG_CLOSE , api_reg_close }, - { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, - { "REG_OPEN" , REG_OPEN_HKLM , api_reg_open }, - { "REG_INFO" , REG_INFO , api_reg_info }, - { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, - { "REG_ABORT_SHUTDOWN", REG_ABORT_SHUTDOWN, api_reg_abort_shutdown }, - { NULL, 0 , NULL } + { "REG_CLOSE" , REG_CLOSE , api_reg_close }, + { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, + { "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm }, + { "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku }, + { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key }, + { "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key }, + { "REG_INFO" , REG_INFO , api_reg_info }, + { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, + { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, + { "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a }, + { NULL , 0 , NULL } }; /******************************************************************* diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 03aae14b53..0569d68cae 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -5,7 +5,8 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. * Copyright (C) Hewlett-Packard Company 1999. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Gerald Carter 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,20 +30,473 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -struct reg_info { - /* for use by \PIPE\winreg */ +#define KEY_HKLM "HKLM" +#define KEY_HKU "HKU" + +#define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ +((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) + +/* structure to store the registry handles */ + +typedef struct _RegistryKey { + struct _RegistryKey *prev, *next; + fstring name; /* name of registry key */ -}; + POLICY_HND hnd; + +} Registry_Key; + +static Registry_Key *regkeys_list; +static TDB_CONTEXT *tdb_reg; + +/*********************************************************************** + Add subkey strings to the registry tdb under a defined key + fmt is the same format as tdb_pack except this function only supports + fstrings + ***********************************************************************/ + +static BOOL store_reg_keys( TDB_CONTEXT *tdb, char *keyname, char **subkeys, uint32 num_subkeys ) +{ + TDB_DATA kbuf, dbuf; + void *buffer, *tmpbuf; + int i = 0; + uint32 len, buflen; + BOOL ret = True; + + if ( !keyname ) + return False; + + /* allocate some initial memory */ + + buffer = malloc(sizeof(pstring)); + buflen = sizeof(pstring); + len = 0; + + /* store the number of subkeys */ + + len += tdb_pack(buffer+len, buflen-len, "d", num_subkeys); + + /* pack all the strings */ + + for (i=0; i buflen ) { + /* allocate some extra space */ + if ((tmpbuf = Realloc( buffer, len*2 )) == NULL) { + DEBUG(0,("store_reg_keys: Failed to realloc memory of size [%d]\n", len*2)); + ret = False; + goto done; + } + buffer = tmpbuf; + buflen = len*2; + + len = tdb_pack(buffer+len, buflen-len, "f", subkeys[i]); + } + } + + /* finally write out the data */ + + kbuf.dptr = keyname; + kbuf.dsize = strlen(keyname)+1; + dbuf.dptr = buffer; + dbuf.dsize = len; + if ( tdb_store( tdb, kbuf, dbuf, TDB_REPLACE ) == -1) { + ret = False; + goto done; + } + +done: + SAFE_FREE( buffer ); + return ret; +} + +/*********************************************************************** + Retrieve an array of strings containing subkeys. Memory should be + released by the caller. The subkeys are stored in a catenated string + of null terminated character strings + ***********************************************************************/ + +static int fetch_reg_keys( TDB_CONTEXT *tdb, char* key, char **subkeys ) +{ + pstring path; + uint32 num_items; + TDB_DATA dbuf; + void *buf; + uint32 buflen, len; + int i; + char *s; + + + pstrcpy( path, key ); + + /* convert to key format */ + pstring_sub( path, "\\", "/" ); + + dbuf = tdb_fetch_by_string( tdb, path ); + + buf = dbuf.dptr; + buflen = dbuf.dsize; + + if ( !buf ) { + DEBUG(5,("fetch_reg_keys: Failed to fetch any subkeys for [%s]\n", key)); + return -1; + } + + len = tdb_unpack( buf, buflen, "d", &num_items); + if (num_items) { + if ( (*subkeys = (char*)malloc(sizeof(fstring)*num_items)) == NULL ) { + DEBUG(0,("fetch_reg_keys: Failed to malloc memory for subkey array containing [%d] items!\n", + num_items)); + num_items = -1; + goto done; + } + } + + s = *subkeys; + for (i=0; iname, name ); + + DEBUG(7,("open_registry_key: exit\n")); + + return create_policy_hnd( p, hnd, free_reg_info, regkey ); +} + +/******************************************************************* + Function for open a new registry handle and creating a handle + Note that P should be valid & hnd should already have space + *******************************************************************/ + +static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd) +{ + Registry_Key *regkey = find_regkey_index_by_hnd(p, hnd); + + if ( !regkey ) { + DEBUG(2,("close_registry_key: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(hnd))); + return False; + } + + close_policy_hnd(p, hnd); + + return True; +} + +/******************************************************************** + retrieve information about the subkeys + *******************************************************************/ + +static BOOL get_subkey_information( Registry_Key *key, uint32 *maxnum, uint32 *maxlen ) +{ + int num_subkeys, i; + uint32 max_len; + char *subkeys = NULL; + uint32 len; + char *s; + + if ( !key ) + return False; + + num_subkeys = fetch_reg_keys( tdb_reg, key->name, &subkeys ); + if ( num_subkeys == -1 ) + return False; + + /* find the longest string */ + + max_len = 0; + s = subkeys; + for ( i=0; iname, KEY_HKLM) || !strcmp(key->name, KEY_HKU) ) + { + *maxnum = 0; + *maxlen = 0; + *maxsize = 0; + return True; + } + + /* + * FIXME!!! Need to add routines to look up values in other + * databases --jerry + */ + + return False; +} + +/******************************************************************** + reg_close ********************************************************************/ NTSTATUS _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) @@ -51,7 +505,7 @@ NTSTATUS _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) ZERO_STRUCT(r_u->pol); /* close the policy handle */ - if (!close_policy_hnd(p, &q_u->pol)) + if (!close_registry_key(p, &q_u->pol)) return NT_STATUS_OBJECT_NAME_INVALID; return NT_STATUS_OK; @@ -61,9 +515,21 @@ NTSTATUS _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) reg_reply_open ********************************************************************/ -NTSTATUS _reg_open(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u) +NTSTATUS _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u) +{ + if (!open_registry_key(p, &r_u->pol, KEY_HKLM, 0x0)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + return NT_STATUS_OK; +} + +/******************************************************************* + reg_reply_open + ********************************************************************/ + +NTSTATUS _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HKU *q_u, REG_R_OPEN_HKU *r_u) { - if (!create_policy_hnd(p, &r_u->pol, free_reg_info, NULL)) + if (!open_registry_key(p, &r_u->pol, KEY_HKU, 0x0)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; return NT_STATUS_OK; @@ -77,34 +543,36 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR { POLICY_HND pol; fstring name; - struct reg_info *info = NULL; + pstring path; + int num_subkeys; + Registry_Key *key = find_regkey_index_by_hnd(p, &q_u->pol); - DEBUG(5,("reg_open_entry: %d\n", __LINE__)); + DEBUG(5,("reg_open_entry: Enter\n")); - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if ( !key ) return NT_STATUS_INVALID_HANDLE; rpcstr_pull(name,q_u->uni_name.buffer,sizeof(name),q_u->uni_name.uni_str_len*2,0); - DEBUG(5,("reg_open_entry: %s\n", name)); - - /* lkcl XXXX do a check on the name, here */ - if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions") && - !strequal(name, "System\\CurrentControlSet\\services\\Netlogon\\parameters\\")) - return NT_STATUS_ACCESS_DENIED; + /* store the full path in the regkey_list */ + + pstrcpy( path, key->name ); + pstrcat( path, "\\" ); + pstrcat( path, name ); - if ((info = (struct reg_info *)malloc(sizeof(struct reg_info))) == NULL) - return NT_STATUS_NO_MEMORY; + DEBUG(5,("reg_open_entry: %s\n", path)); - ZERO_STRUCTP(info); - fstrcpy(info->name, name); + /* do a check on the name, here */ + + if ( (num_subkeys=fetch_reg_keys_count( tdb_reg, path )) == -1 ) + return NT_STATUS_ACCESS_DENIED; - if (!create_policy_hnd(p, &pol, free_reg_info, (void *)info)) - return NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ + if (!open_registry_key(p, &pol, path, 0x0)) + return NT_STATUS_TOO_MANY_SECRETS; init_reg_r_open_entry(r_u, &pol, NT_STATUS_OK); - DEBUG(5,("reg_open_entry: %d\n", __LINE__)); + DEBUG(5,("reg_open_entry: Exitn")); return r_u->status; } @@ -116,21 +584,23 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) { NTSTATUS status = NT_STATUS_OK; - char *key = NULL; - uint32 type=0x1; /* key type: REG_SZ */ - + char *value = NULL; + uint32 type = 0x1; /* key type: REG_SZ */ UNISTR2 *uni_key = NULL; BUFFER2 *buf = NULL; fstring name; + Registry_Key *key = find_regkey_index_by_hnd( p, &q_u->pol ); - DEBUG(5,("_reg_info: %d\n", __LINE__)); + DEBUG(5,("_reg_info: Enter\n")); - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if ( !key ) return NT_STATUS_INVALID_HANDLE; + + DEBUG(7,("_reg_info: policy key name = [%s]\n", key->name)); rpcstr_pull(name, q_u->uni_type.buffer, sizeof(name), q_u->uni_type.uni_str_len*2, 0); - DEBUG(5,("reg_info: checking key: %s\n", name)); + DEBUG(5,("reg_info: checking subkey: %s\n", name)); uni_key = (UNISTR2 *)talloc_zero(p->mem_ctx, sizeof(UNISTR2)); buf = (BUFFER2 *)talloc_zero(p->mem_ctx, sizeof(BUFFER2)); @@ -150,33 +620,126 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) } switch (lp_server_role()) { - case ROLE_DOMAIN_PDC: - case ROLE_DOMAIN_BDC: - key = "LanmanNT"; - break; - case ROLE_STANDALONE: - key = "ServerNT"; - break; - case ROLE_DOMAIN_MEMBER: - key = "WinNT"; - break; + case ROLE_DOMAIN_PDC: + case ROLE_DOMAIN_BDC: + value = "LanmanNT"; + break; + case ROLE_STANDALONE: + value = "ServerNT"; + break; + case ROLE_DOMAIN_MEMBER: + value = "WinNT"; + break; } /* This makes the server look like a member server to clients */ /* which tells clients that we have our own local user and */ /* group databases and helps with ACL support. */ - init_unistr2(uni_key, key, strlen(key)+1); + init_unistr2(uni_key, value, strlen(value)+1); init_buffer2(buf, (uint8*)uni_key->buffer, uni_key->uni_str_len*2); out: init_reg_r_info(q_u->ptr_buf, r_u, buf, type, status); - DEBUG(5,("reg_open_entry: %d\n", __LINE__)); + DEBUG(5,("reg_open_entry: Exit\n")); + + return status; +} + + +/***************************************************************************** + Implementation of REG_QUERY_KEY + ****************************************************************************/ + +NTSTATUS _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_u) +{ + NTSTATUS status = NT_STATUS_OK; + Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + + DEBUG(5,("_reg_query_key: Enter\n")); + + if ( !regkey ) + return NT_STATUS_INVALID_HANDLE; + + if ( !get_subkey_information( regkey, &r_u->num_subkeys, &r_u->max_subkeylen ) ) + return NT_STATUS_ACCESS_DENIED; + + if ( !get_value_information( regkey, &r_u->num_values, &r_u->max_valnamelen, &r_u->max_valbufsize ) ) + return NT_STATUS_ACCESS_DENIED; + + r_u->sec_desc = 0x0; /* size for key's sec_desc */ + + /* Win9x set this to 0x0 since it does not keep timestamps. + Doing the same here for simplicity --jerry */ + + ZERO_STRUCT(r_u->mod_time); + + DEBUG(5,("_reg_query_key: Exit\n")); + + return status; +} + + +/***************************************************************************** + Implementation of REG_UNKNOWN_1A + ****************************************************************************/ + +NTSTATUS _reg_unknown_1a(pipes_struct *p, REG_Q_UNKNOWN_1A *q_u, REG_R_UNKNOWN_1A *r_u) +{ + NTSTATUS status = NT_STATUS_OK; + Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + + DEBUG(5,("_reg_unknown_1a: Enter\n")); + + if ( !regkey ) + return NT_STATUS_INVALID_HANDLE; + + r_u->unknown = 0x05000000; /* seems to be consistent...no idea what it means */ + + DEBUG(5,("_reg_unknown_1a: Exit\n")); + + return status; +} + +/***************************************************************************** + Implementation of REG_ENUM_KEY + ****************************************************************************/ + +NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u) +{ + NTSTATUS status = NT_STATUS_OK; + Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + fstring subkey; + + + DEBUG(5,("_reg_enum_key: Enter\n")); + + if ( !regkey ) + return NT_STATUS_INVALID_HANDLE; + + DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", regkey->name)); + + if ( !fetch_reg_keys_specific( tdb_reg, regkey->name, subkey, q_u->key_index ) ) + { + status = werror_to_ntstatus( WERR_NO_MORE_ITEMS ); + goto done; + } + + DEBUG(10,("_reg_enum_key: retrieved subkey named [%s]\n", subkey)); + + /* subkey has the string name now */ + + init_reg_r_enum_key( r_u, subkey, q_u->unknown_1, q_u->unknown_2 ); + + DEBUG(5,("_reg_enum_key: Exit\n")); + +done: return status; } + /******************************************************************* reg_shutdwon ********************************************************************/ @@ -222,6 +785,10 @@ NTSTATUS _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u return status; } +/******************************************************************* + reg_abort_shutdwon + ********************************************************************/ + NTSTATUS _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABORT_SHUTDOWN *r_u) { NTSTATUS status = NT_STATUS_OK; @@ -237,3 +804,5 @@ NTSTATUS _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_A return status; } + + -- cgit From cd383bdc309a0585e656c373e7d1b9d66f6395e1 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 4 Jul 2002 08:45:45 +0000 Subject: Patch to add security descriptors to the SAMR pipe. This is not the final solution, I think this will probably changed with the move to the new SAM subsystem, but it allows some research and gives us somthing to start with. It should also help with getting proper NT_TOKEN passing set-up. Original patch by "Kai Krueger" , which I have modified to pass back NTSTATUS returns in more places and to use a little more common code. Andrew Bartlett (This used to be commit 43b72493708e74e089989db42a003a3862c793e6) --- source3/rpc_server/srv_samr_nt.c | 723 ++++++++++++++++++++++++++++++++------- 1 file changed, 602 insertions(+), 121 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9393917cde..7a23a55b2a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -54,11 +54,69 @@ struct samr_info { /* for use by the \PIPE\samr policy */ DOM_SID sid; uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ + uint32 acc_granted; DISP_INFO disp_info; TALLOC_CTX *mem_ctx; }; +struct generic_mapping sam_generic_mapping = {SAMR_READ, SAMR_WRITE, SAMR_EXECUTE, SAMR_ALL_ACCESS}; +struct generic_mapping dom_generic_mapping = {DOMAIN_READ, DOMAIN_WRITE, DOMAIN_EXECUTE, DOMAIN_ALL_ACCESS}; +struct generic_mapping usr_generic_mapping = {USER_READ, USER_WRITE, USER_EXECUTE, USER_ALL_ACCESS}; +struct generic_mapping grp_generic_mapping = {GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, GROUP_ALL_ACCESS}; +struct generic_mapping ali_generic_mapping = {ALIAS_READ, ALIAS_WRITE, ALIAS_EXECUTE, ALIAS_ALL_ACCESS}; + +static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *d_size); + + +/******************************************************************* + Checks if access to an object should be granted, and returns that + level of access for further checks. +********************************************************************/ + +NTSTATUS access_check_samr_object(SEC_DESC *psd, NT_USER_TOKEN *nt_user_token, uint32 des_access, + uint32 *acc_granted, const char *debug) +{ + NTSTATUS status = NT_STATUS_ACCESS_DENIED; + + if (!se_access_check(psd, nt_user_token, des_access, acc_granted, &status)) { + if (geteuid() == sec_initial_uid()) { + DEBUG(4,("%s: ACCESS should be DENIED (requested: %#010x)\n", + debug, des_access)); + DEBUGADD(4,("but overritten by euid == sec_initial_uid()\n")); + status = NT_STATUS_OK; + } + else { + DEBUG(2,("%s: ACCESS DENIED (requested: %#010x)\n", + debug, des_access)); + } + } + return status; +} + +/******************************************************************* + Checks if access to a function can be granted +********************************************************************/ + +NTSTATUS access_check_samr_function(uint32 acc_granted, uint32 acc_required, const char *debug) +{ + DEBUG(5,("%s: access check ((granted: %#010x; required: %#010x)\n", + debug, acc_granted, acc_required)); + if ((acc_granted & acc_required) != acc_required) { + if (geteuid() == sec_initial_uid()) { + DEBUG(4,("%s: ACCESS should be DENIED (granted: %#010x; required: %#010x)\n", + debug, acc_granted, acc_required)); + DEBUGADD(4,("but overwritten by euid == 0\n")); + return NT_STATUS_OK; + } + DEBUG(2,("%s: ACCESS DENIED (granted: %#010x; required: %#010x)\n", + debug, acc_granted, acc_required)); + return NT_STATUS_ACCESS_DENIED; + } + return NT_STATUS_OK; +} + + /******************************************************************* Create a samr_info struct. ********************************************************************/ @@ -276,17 +334,37 @@ NTSTATUS _samr_close_hnd(pipes_struct *p, SAMR_Q_CLOSE_HND *q_u, SAMR_R_CLOSE_HN NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN_DOMAIN *r_u) { - struct samr_info *info; + struct samr_info *info; + SEC_DESC *psd = NULL; + uint32 acc_granted; + uint32 des_access = q_u->flags; + size_t sd_size; + NTSTATUS status; r_u->status = NT_STATUS_OK; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->pol, (void**)&info)) return NT_STATUS_INVALID_HANDLE; + if (!NT_STATUS_IS_OK(status = access_check_samr_function(info->acc_granted, SAMR_ACCESS_OPEN_DOMAIN,"_samr_open_domain"))) { + return status; + } + + /*check if access can be granted as requested by client. */ + samr_make_dom_obj_sd(p->mem_ctx, &psd, &sd_size); + se_map_generic(&des_access,&dom_generic_mapping); + + if (!NT_STATUS_IS_OK(status = + access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_open_domain"))) { + return status; + } + /* associate the domain SID with the (unique) handle. */ if ((info = get_samr_info_by_sid(&q_u->dom_sid.sid))==NULL) return NT_STATUS_NO_MEMORY; + info->acc_granted = acc_granted; /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, &r_u->domain_pol, free_samr_info, (void *)info)) @@ -326,11 +404,90 @@ NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, return r_u->status; } + +/******************************************************************* + samr_make_sam_obj_sd + ********************************************************************/ + +static NTSTATUS samr_make_sam_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +{ + extern DOM_SID global_sid_World; + DOM_SID adm_sid; + DOM_SID act_sid; + + SEC_ACE ace[3]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + sid_copy(&act_sid, &global_sid_Builtin); + sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + + /*basic access for every one*/ + init_sec_access(&mask, SAMR_EXECUTE | SAMR_READ); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, SAMR_ALL_ACCESS); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + return NT_STATUS_OK; +} + +/******************************************************************* + samr_make_dom_obj_sd + ********************************************************************/ + +static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +{ + extern DOM_SID global_sid_World; + DOM_SID adm_sid; + DOM_SID act_sid; + + SEC_ACE ace[3]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + sid_copy(&act_sid, &global_sid_Builtin); + sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + + /*basic access for every one*/ + init_sec_access(&mask, DOMAIN_EXECUTE | DOMAIN_READ); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, DOMAIN_ALL_ACCESS); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + return NT_STATUS_OK; +} + /******************************************************************* samr_make_usr_obj_sd ********************************************************************/ -static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC_BUF **buf, DOM_SID *usr_sid) +static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size, DOM_SID *usr_sid) { extern DOM_SID global_sid_World; DOM_SID adm_sid; @@ -340,8 +497,6 @@ static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC_BUF **buf, DOM_SI SEC_ACCESS mask; SEC_ACL *psa = NULL; - SEC_DESC *psd = NULL; - size_t sd_size; sid_copy(&adm_sid, &global_sid_Builtin); sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); @@ -349,29 +504,107 @@ static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC_BUF **buf, DOM_SI sid_copy(&act_sid, &global_sid_Builtin); sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); - init_sec_access(&mask, 0x2035b); + /*basic access for every one*/ + init_sec_access(&mask, USER_EXECUTE | USER_READ); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_access(&mask, 0xf07ff); + /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, USER_ALL_ACCESS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_access(&mask,0x20044); + /*extended access for the user*/ + init_sec_access(&mask,READ_CONTROL_ACCESS | USER_ACCESS_CHANGE_PASSWORD | USER_ACCESS_SET_LOC_COM); init_sec_ace(&ace[3], usr_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - if((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 4, ace)) == NULL) + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 4, ace)) == NULL) return NT_STATUS_NO_MEMORY; - if((psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, &sd_size)) == NULL) + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + return NT_STATUS_OK; +} + +/******************************************************************* + samr_make_grp_obj_sd + ********************************************************************/ + +static NTSTATUS samr_make_grp_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +{ + extern DOM_SID global_sid_World; + DOM_SID adm_sid; + DOM_SID act_sid; + + SEC_ACE ace[3]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + sid_copy(&act_sid, &global_sid_Builtin); + sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + + /*basic access for every one*/ + init_sec_access(&mask, GROUP_EXECUTE | GROUP_READ); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, GROUP_ALL_ACCESS); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) return NT_STATUS_NO_MEMORY; - if((*buf = make_sec_desc_buf(ctx, sd_size, psd)) == NULL) + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) return NT_STATUS_NO_MEMORY; return NT_STATUS_OK; } -static BOOL get_lsa_policy_samr_sid(pipes_struct *p, POLICY_HND *pol, DOM_SID *sid) +/******************************************************************* + samr_make_ali_obj_sd + ********************************************************************/ + +static NTSTATUS samr_make_ali_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +{ + extern DOM_SID global_sid_World; + DOM_SID adm_sid; + DOM_SID act_sid; + + SEC_ACE ace[3]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + sid_copy(&act_sid, &global_sid_Builtin); + sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + + /*basic access for every one*/ + init_sec_access(&mask, ALIAS_EXECUTE | ALIAS_READ); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, ALIAS_ALL_ACCESS); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + return NT_STATUS_OK; +} + +static BOOL get_lsa_policy_samr_sid(pipes_struct *p, POLICY_HND *pol, DOM_SID *sid, uint32 *acc_granted) { struct samr_info *info = NULL; @@ -383,6 +616,7 @@ static BOOL get_lsa_policy_samr_sid(pipes_struct *p, POLICY_HND *pol, DOM_SID *s return False; *sid = info->sid; + *acc_granted = info->acc_granted; return True; } @@ -394,17 +628,52 @@ NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_ { DOM_SID pol_sid; fstring str_sid; + SEC_DESC * psd = NULL; + size_t sd_size; + uint32 acc_granted; r_u->status = NT_STATUS_OK; /* Get the SID. */ - - if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &pol_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &pol_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + DEBUG(10,("_samr_query_sec_obj: querying security on SID: %s\n", sid_to_string(str_sid, &pol_sid))); - r_u->status = samr_make_usr_obj_sd(p->mem_ctx, &r_u->buf, &pol_sid); + /* Check what typ of SID is beeing queried (e.g Domain SID, User SID, Group SID) */ + + /* To query the security of the SAM it self an invalid SID with S-0-0 is passed to this function */ + if (pol_sid.sid_rev_num == 0) + { + DEBUG(5,("_samr_query_sec_obj: querying security on SAM\n")); + r_u->status = samr_make_sam_obj_sd(p->mem_ctx, &psd, &sd_size); + } + else if (sid_equal(&pol_sid,get_global_sam_sid())) //check if it is our domain SID + + { + DEBUG(5,("_samr_query_sec_obj: querying security on Domain with SID: %s\n", sid_to_string(str_sid, &pol_sid))); + r_u->status = samr_make_dom_obj_sd(p->mem_ctx, &psd, &sd_size); + } + else if (sid_equal(&pol_sid,&global_sid_Builtin)) //check if it is the Builtin Domain + { + /* TODO: Builtin probably needs a different SD with restricted write access*/ + DEBUG(5,("_samr_query_sec_obj: querying security on Builtin Domain with SID: %s\n", sid_to_string(str_sid, &pol_sid))); + r_u->status = samr_make_dom_obj_sd(p->mem_ctx, &psd, &sd_size); + } + else if (sid_check_is_in_our_domain(&pol_sid) || + sid_check_is_in_builtin(&pol_sid)) + { + /* TODO: different SDs have to be generated for aliases groups and users. + Currently all three get a default user SD */ + DEBUG(10,("_samr_query_sec_obj: querying security on Object with SID: %s\n", sid_to_string(str_sid, &pol_sid))); + r_u->status = samr_make_usr_obj_sd(p->mem_ctx, &psd,&sd_size, &pol_sid); + } + else return NT_STATUS_OBJECT_TYPE_MISMATCH; + + if ((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL) + return NT_STATUS_NO_MEMORY; if (NT_STATUS_IS_OK(r_u->status)) r_u->ptr = 1; @@ -496,9 +765,14 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &domain_sid)) - return NT_STATUS_INVALID_HANDLE; + domain_sid = info->sid; + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, + DOMAIN_ACCESS_ENUM_ACCOUNTS, + "_samr_enum_dom_users"))) { + return r_u->status; + } + DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); become_root(); @@ -782,11 +1056,16 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM DOMAIN_GRP *grp=NULL; uint32 num_entries; DOM_SID sid; + uint32 acc_granted; r_u->status = NT_STATUS_OK; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_ENUM_ACCOUNTS, "_samr_enum_dom_groups"))) { + return r_u->status; + } DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); @@ -814,12 +1093,17 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S fstring sid_str; DOM_SID sid; NTSTATUS status; + uint32 acc_granted; r_u->status = NT_STATUS_OK; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_ENUM_ACCOUNTS, "_samr_enum_dom_aliases"))) { + return r_u->status; + } + sid_to_string(sid_str, &sid); DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", sid_str)); @@ -867,8 +1151,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &domain_sid)) - return NT_STATUS_INVALID_HANDLE; + domain_sid = info->sid; /* * calculate how many entries we will return. @@ -1036,22 +1319,26 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_R_QUERY_ALIASINFO *r_u) { - struct samr_info *info = NULL; + DOM_SID sid; GROUP_MAP map; + uint32 acc_granted; r_u->status = NT_STATUS_OK; DEBUG(5,("_samr_query_aliasinfo: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_LOOKUP_INFO, "_samr_query_aliasinfo"))) { + return r_u->status; + } - if (!sid_check_is_in_our_domain(&info->sid) && - !sid_check_is_in_builtin(&info->sid)) + if (!sid_check_is_in_our_domain(&sid) && + !sid_check_is_in_builtin(&sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - if(!get_local_group_from_sid(info->sid, &map, MAPPING_WITHOUT_PRIV)) + if (!get_local_group_from_sid(sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; switch (q_u->switch_level) { @@ -1148,6 +1435,7 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO int num_rids = q_u->num_names2; DOM_SID pol_sid; fstring sid_str; + uint32 acc_granted; r_u->status = NT_STATUS_OK; @@ -1156,10 +1444,14 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO ZERO_ARRAY(rid); ZERO_ARRAY(type); - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid)) { + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid, &acc_granted)) { init_samr_r_lookup_names(p->mem_ctx, r_u, 0, NULL, NULL, NT_STATUS_OBJECT_TYPE_MISMATCH); return r_u->status; } + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, 0, "_samr_lookup_names"))) { /* Don't know the acc_bits yet */ + return r_u->status; + } if (num_rids > MAX_SAM_ENTRIES) { num_rids = MAX_SAM_ENTRIES; @@ -1303,13 +1595,14 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK DOM_SID pol_sid; int num_rids = q_u->num_rids1; int i; + uint32 acc_granted; r_u->status = NT_STATUS_OK; DEBUG(5,("_samr_lookup_rids: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; if (num_rids > MAX_SAM_ENTRIES) { @@ -1371,27 +1664,40 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN POLICY_HND domain_pol = q_u->domain_pol; POLICY_HND *user_pol = &r_u->user_pol; struct samr_info *info = NULL; + SEC_DESC *psd = NULL; + uint32 acc_granted; + uint32 des_access = q_u->access_mask; + size_t sd_size; BOOL ret; NTSTATUS nt_status; r_u->status = NT_STATUS_OK; - /* find the domain policy handle. */ - if (!find_policy_by_hnd(p, &domain_pol, NULL)) + /* find the domain policy handle and get domain SID / access bits in the domain policy. */ + if (!get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_open_user"))) { + return nt_status; + } nt_status = pdb_init_sam_talloc(p->mem_ctx, &sampass); if (!NT_STATUS_IS_OK(nt_status)) { return nt_status; } - /* Get the domain SID stored in the domain policy */ - if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid)) - return NT_STATUS_INVALID_HANDLE; - /* append the user's RID to it */ - if(!sid_append_rid(&sid, q_u->user_rid)) + if (!sid_append_rid(&sid, q_u->user_rid)) return NT_STATUS_NO_SUCH_USER; + + /* check if access can be granted as requested by client. */ + samr_make_usr_obj_sd(p->mem_ctx, &psd, &sd_size, &sid); + se_map_generic(&des_access, &usr_generic_mapping); + if (!NT_STATUS_IS_OK(nt_status = + access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_open_user"))) { + return nt_status; + } become_root(); ret=pdb_getsampwsid(sampass, &sid); @@ -1404,9 +1710,10 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN pdb_free_sam(&sampass); - /* associate the user's SID with the new handle. */ + /* associate the user's SID and access bits with the new handle. */ if ((info = get_samr_info_by_sid(&sid)) == NULL) return NT_STATUS_NO_MEMORY; + info->acc_granted = acc_granted; /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, user_pol, free_samr_info, (void *)info)) @@ -1685,9 +1992,10 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAMR_R_QUERY_USERGROUPS *r_u) { SAM_ACCOUNT *sam_pass=NULL; + DOM_SID sid; DOM_GID *gids = NULL; int num_groups = 0; - struct samr_info *info = NULL; + uint32 acc_granted; BOOL ret; /* @@ -1707,16 +2015,20 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S 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)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, USER_ACCESS_GET_GROUPS, "_samr_query_usergroups"))) { + return r_u->status; + } - if (!sid_check_is_in_our_domain(&info->sid)) + if (!sid_check_is_in_our_domain(&sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; pdb_init_sam(&sam_pass); become_root(); - ret = pdb_getsampwsid(sam_pass, &info->sid); + ret = pdb_getsampwsid(sam_pass, &sid); unbecome_root(); if (ret == False) { @@ -1866,11 +2178,19 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ BOOL ret; NTSTATUS nt_status; struct passwd *pw; + uint32 acc_granted; + SEC_DESC *psd; + size_t sd_size; + uint32 des_access; - /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &dom_pol, NULL)) + /* Get the domain SID stored in the domain policy */ + if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_CREATE_USER, "_samr_create_user"))) { + return nt_status; + } + /* find the 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 @@ -1939,7 +2259,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ else pstrcpy(add_script, lp_adduser_script()); - if(*add_script) { + if (*add_script) { int add_ret; all_string_sub(add_script, "%u", account, sizeof(account)); add_ret = smbrun(add_script,NULL); @@ -1988,6 +2308,14 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ /* Get the user's SID */ sid_copy(&sid, pdb_get_user_sid(sam_pass)); + samr_make_usr_obj_sd(p->mem_ctx, &psd, &sd_size, &sid); + se_map_generic(&des_access, &usr_generic_mapping); + if (!NT_STATUS_IS_OK(nt_status = + access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_create_user"))) { + return nt_status; + } + /* associate the user's SID with the new handle. */ if ((info = get_samr_info_by_sid(&sid)) == NULL) { pdb_free_sam(&sam_pass); @@ -1996,6 +2324,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ ZERO_STRUCTP(info); info->sid = sid; + info->acc_granted = acc_granted; /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, user_pol, free_samr_info, (void *)info)) { @@ -2019,29 +2348,29 @@ NTSTATUS _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CO { struct samr_info *info = NULL; - /* Access check */ + /* Access check */ - if (!pipe_access_check(p)) { - DEBUG(3, ("access denied to samr_connect_anon\n")); - r_u->status = NT_STATUS_ACCESS_DENIED; - return r_u->status; - } + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to samr_connect_anon\n")); + r_u->status = NT_STATUS_ACCESS_DENIED; + return r_u->status; + } - /* set up the SAMR connect_anon response */ + /* set up the SAMR connect_anon response */ - r_u->status = NT_STATUS_OK; + r_u->status = NT_STATUS_OK; - /* associate the user's SID with the new handle. */ - if ((info = get_samr_info_by_sid(NULL)) == NULL) - return NT_STATUS_NO_MEMORY; + /* associate the user's SID with the new handle. */ + if ((info = get_samr_info_by_sid(NULL)) == NULL) + return NT_STATUS_NO_MEMORY; - info->status = q_u->unknown_0; + info->status = q_u->unknown_0; - /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; - return r_u->status; + return r_u->status; } /******************************************************************* @@ -2051,32 +2380,47 @@ NTSTATUS _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CO NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u) { struct samr_info *info = NULL; + SEC_DESC *psd = NULL; + uint32 acc_granted; + uint32 des_access = q_u->access_mask; + size_t sd_size; + NTSTATUS nt_status; - DEBUG(5,("_samr_connect: %d\n", __LINE__)); - /* Access check */ + DEBUG(5,("_samr_connect: %d\n", __LINE__)); - if (!pipe_access_check(p)) { - DEBUG(3, ("access denied to samr_connect\n")); - r_u->status = NT_STATUS_ACCESS_DENIED; - return r_u->status; - } + /* Access check */ - r_u->status = NT_STATUS_OK; + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to samr_connect\n")); + r_u->status = NT_STATUS_ACCESS_DENIED; + return r_u->status; + } + + samr_make_sam_obj_sd(p->mem_ctx, &psd, &sd_size); + se_map_generic(&des_access, &sam_generic_mapping); + if (!NT_STATUS_IS_OK(nt_status = + access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_connect"))) { + return nt_status; + } + + r_u->status = NT_STATUS_OK; - /* associate the user's SID with the new handle. */ + /* associate the user's SID and access granted with the new handle. */ if ((info = get_samr_info_by_sid(NULL)) == NULL) - return NT_STATUS_NO_MEMORY; + return NT_STATUS_NO_MEMORY; - info->status = q_u->access_mask; + info->acc_granted = acc_granted; + info->status = q_u->access_mask; - /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; - DEBUG(5,("_samr_connect: %d\n", __LINE__)); + DEBUG(5,("_samr_connect: %d\n", __LINE__)); - return r_u->status; + return r_u->status; } /********************************************************************** @@ -2085,14 +2429,19 @@ NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u NTSTATUS _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_LOOKUP_DOMAIN *r_u) { + struct samr_info *info; fstring domain_name; DOM_SID sid; r_u->status = NT_STATUS_OK; - if (!find_policy_by_hnd(p, &q_u->connect_pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->connect_pol, (void**)&info)) return NT_STATUS_INVALID_HANDLE; + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SAMR_ACCESS_OPEN_DOMAIN, "_samr_lookup_domain"))) { + return r_u->status; + } + rpcstr_pull(domain_name, q_u->uni_domain.buffer, sizeof(domain_name), q_u->uni_domain.uni_str_len*2, 0); ZERO_STRUCT(sid); @@ -2152,11 +2501,19 @@ static BOOL make_enum_domains(TALLOC_CTX *ctx, SAM_ENTRY **pp_sam, NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_ENUM_DOMAINS *r_u) { + struct samr_info *info; uint32 num_entries = 2; fstring dom[2]; char *name; r_u->status = NT_STATUS_OK; + + if (!find_policy_by_hnd(p, &q_u->pol, (void**)&info)) + return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SAMR_ACCESS_ENUM_DOMAINS, "_samr_enum_domains"))) { + return r_u->status; + } switch (lp_server_role()) { case ROLE_DOMAIN_PDC: @@ -2189,21 +2546,35 @@ NTSTATUS _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OP POLICY_HND domain_pol = q_u->dom_pol; uint32 alias_rid = q_u->rid_alias; POLICY_HND *alias_pol = &r_u->pol; - struct samr_info *info = NULL; + struct samr_info *info = NULL; + SEC_DESC *psd = NULL; + uint32 acc_granted; + uint32 des_access = q_u->access_mask; + size_t sd_size; + NTSTATUS status; r_u->status = NT_STATUS_OK; - /* get the domain policy. */ - if (!find_policy_by_hnd(p, &domain_pol, NULL)) - return NT_STATUS_INVALID_HANDLE; - - /* Get the domain SID stored in the domain policy */ - if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid)) + /* find the domain policy and get the SID / access bits stored in the domain policy */ + if (!get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_open_alias"))) { + return status; + } /* append the alias' RID to it */ - if(!sid_append_rid(&sid, alias_rid)) + if (!sid_append_rid(&sid, alias_rid)) return NT_STATUS_NO_SUCH_USER; + + /*check if access can be granted as requested by client. */ + samr_make_ali_obj_sd(p->mem_ctx, &psd, &sd_size); + se_map_generic(&des_access,&ali_generic_mapping); + if (!NT_STATUS_IS_OK(status = + access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_open_alias"))) { + return status; + } /* * we should check if the rid really exist !!! @@ -2213,6 +2584,8 @@ NTSTATUS _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OP /* associate the user's SID with the new handle. */ if ((info = get_samr_info_by_sid(&sid)) == NULL) return NT_STATUS_NO_MEMORY; + + info->acc_granted = acc_granted; /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, alias_pol, free_samr_info, (void *)info)) @@ -2486,15 +2859,22 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE POLICY_HND *pol = &q_u->pol; uint16 switch_value = q_u->switch_value; SAM_USERINFO_CTR *ctr = q_u->ctr; + uint32 acc_granted; + uint32 acc_required; DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); r_u->status = NT_STATUS_OK; /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, pol, &sid)) + if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + acc_required = USER_ACCESS_SET_LOC_COM | USER_ACCESS_SET_ATTRIBUTES; /* This is probably wrong */ + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo"))) { + return r_u->status; + } + DEBUG(5, ("_samr_set_userinfo: sid:%s, level:%d\n", sid_string_static(&sid), switch_value)); if (ctr == NULL) { @@ -2564,14 +2944,21 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ SAM_USERINFO_CTR *ctr = q_u->ctr; POLICY_HND *pol = &q_u->pol; uint16 switch_value = q_u->switch_value; + uint32 acc_granted; + uint32 acc_required; DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__)); r_u->status = NT_STATUS_OK; /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, pol, &sid)) + if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + acc_required = USER_ACCESS_SET_LOC_COM | USER_ACCESS_SET_ATTRIBUTES; /* This is probably wrong */ + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo2"))) { + return r_u->status; + } DEBUG(5, ("samr_reply_set_userinfo2: sid:%s\n", sid_string_static(&sid))); @@ -2638,6 +3025,10 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, /* 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; + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, USER_ACCESS_GET_GROUPS, "_samr_query_useraliases"))) { + return r_u->status; + } if (!sid_check_is_domain(&info->sid) && !sid_check_is_builtin(&info->sid)) @@ -2702,11 +3093,16 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ SAM_ACCOUNT *sam_user = NULL; BOOL check; + uint32 acc_granted; /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_GET_MEMBERS, "_samr_query_aliasmem"))) { + return r_u->status; + } + sid_copy(&als_sid, &alias_sid); sid_to_string(alias_sid_str, &alias_sid); sid_split_rid(&alias_sid, &alias_rid); @@ -2798,12 +3194,16 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ SAM_ACCOUNT *sam_user = NULL; BOOL check; - + uint32 acc_granted; /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_GET_MEMBERS, "_samr_query_groupmem"))) { + return r_u->status; + } + /* todo: change to use sid_compare_front */ sid_split_rid(&group_sid, &group_rid); @@ -2886,11 +3286,16 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD NTSTATUS ret; SAM_ACCOUNT *sam_user = NULL; BOOL check; + uint32 acc_granted; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_ADD_MEMBER, "_samr_add_aliasmem"))) { + return r_u->status; + } + sid_to_string(alias_sid_str, &alias_sid); DEBUG(10, ("sid is %s\n", alias_sid_str)); @@ -2969,11 +3374,16 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE fstring grp_name; GROUP_MAP map; SAM_ACCOUNT *sam_pass=NULL; + uint32 acc_granted; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_REMOVE_MEMBER, "_samr_del_aliasmem"))) { + return r_u->status; + } + sid_to_string(alias_sid_str, &alias_sid); DEBUG(10, ("_samr_del_aliasmem:sid is %s\n", alias_sid_str)); @@ -3035,10 +3445,15 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD NTSTATUS ret; SAM_ACCOUNT *sam_user; BOOL check; + uint32 acc_granted; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_ADD_MEMBER, "_samr_add_groupmem"))) { + return r_u->status; + } sid_to_string(group_sid_str, &group_sid); DEBUG(10, ("sid is %s\n", group_sid_str)); @@ -3116,6 +3531,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE GROUP_MAP map; fstring grp_name; struct group *grp; + uint32 acc_granted; /* * delete the group member named q_u->rid @@ -3124,16 +3540,20 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE */ /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - - if(!sid_check_is_in_our_domain(&group_sid)) + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_REMOVE_MEMBER, "_samr_del_groupmem"))) { + return r_u->status; + } + + if (!sid_check_is_in_our_domain(&group_sid)) return NT_STATUS_NO_SUCH_GROUP; sid_copy(&user_sid, get_global_sam_sid()); sid_append_rid(&user_sid, q_u->rid); - if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) + if (!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_GROUP; if ((grp=getgrgid(map.gid)) == NULL) @@ -3144,14 +3564,14 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE /* check if the user exists before trying to remove it from the group */ pdb_init_sam(&sam_pass); - if(!pdb_getsampwsid(sam_pass, &user_sid)) { + if (!pdb_getsampwsid(sam_pass, &user_sid)) { DEBUG(5,("User %s doesn't exist.\n", pdb_get_username(sam_pass))); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } /* if the user is not in the group */ - if(!user_in_group_list(pdb_get_username(sam_pass), grp_name)) { + if (!user_in_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_MEMBER_NOT_IN_GROUP; } @@ -3159,7 +3579,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE smb_delete_user_group(grp_name, pdb_get_username(sam_pass)); /* check if the user has been removed then ... */ - if(user_in_group_list(pdb_get_username(sam_pass), grp_name)) { + if (user_in_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_ACCESS_DENIED; /* don't know what to reply else */ } @@ -3195,13 +3615,18 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM { DOM_SID user_sid; SAM_ACCOUNT *sam_pass=NULL; + uint32 acc_granted; DEBUG(5, ("_samr_delete_dom_user: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &user_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &user_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DELETE_ACCESS, "_samr_delete_dom_user"))) { + return r_u->status; + } + if (!sid_check_is_in_our_domain(&user_sid)) return NT_STATUS_CANNOT_DELETE; @@ -3249,13 +3674,18 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S gid_t gid; struct group *grp; GROUP_MAP map; + uint32 acc_granted; DEBUG(5, ("samr_delete_dom_group: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DELETE_ACCESS, "_samr_delete_dom_group"))) { + return r_u->status; + } + sid_copy(&dom_sid, &group_sid); sid_to_string(group_sid_str, &dom_sid); sid_split_rid(&dom_sid, &group_rid); @@ -3306,13 +3736,18 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S gid_t gid; struct group *grp; GROUP_MAP map; + uint32 acc_granted; DEBUG(5, ("_samr_delete_dom_alias: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DELETE_ACCESS, "_samr_delete_dom_alias"))) { + return r_u->status; + } + sid_copy(&dom_sid, &alias_sid); sid_to_string(alias_sid_str, &dom_sid); sid_split_rid(&dom_sid, &alias_rid); @@ -3363,13 +3798,18 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S struct group *grp; struct samr_info *info; PRIVILEGE_SET priv_set; + uint32 acc_granted; init_privilege(&priv_set); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_CREATE_GROUP, "_samr_create_dom_group"))) { + return r_u->status; + } + if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; @@ -3421,13 +3861,18 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S struct group *grp; struct samr_info *info; PRIVILEGE_SET priv_set; + uint32 acc_granted; init_privilege(&priv_set); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_CREATE_ALIAS, "_samr_create_alias"))) { + return r_u->status; + } + if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; @@ -3480,10 +3925,15 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM uid_t *uid=NULL; int num_uids=0; GROUP_INFO_CTR *ctr; + uint32 acc_granted; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_LOOKUP_INFO, "_samr_query_groupinfo"))) { + return r_u->status; + } + if (!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_INVALID_HANDLE; @@ -3527,10 +3977,15 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ DOM_SID group_sid; GROUP_MAP map; GROUP_INFO_CTR *ctr; + uint32 acc_granted; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_SET_INFO, "_samr_set_groupinfo"))) { + return r_u->status; + } + if (!get_domain_group_from_sid(group_sid, &map, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; @@ -3569,10 +4024,15 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ DOM_SID group_sid; GROUP_MAP map; ALIAS_INFO_CTR *ctr; + uint32 acc_granted; - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_SET_INFO, "_samr_set_aliasinfo"))) { + return r_u->status; + } + if (!get_local_group_from_sid(group_sid, &map, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; @@ -3628,10 +4088,29 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G DOM_SID info_sid; GROUP_MAP map; struct samr_info *info; + SEC_DESC *psd = NULL; + uint32 acc_granted; + uint32 des_access; + size_t sd_size; + NTSTATUS status; fstring sid_string; - if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_open_group"))) { + return status; + } + + /*check if access can be granted as requested by client. */ + samr_make_grp_obj_sd(p->mem_ctx, &psd, &sd_size); + se_map_generic(&des_access,&grp_generic_mapping); + if (!NT_STATUS_IS_OK(status = + access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_open_group"))) { + return status; + } + /* this should not be hard-coded like this */ if (!sid_equal(&sid, get_global_sam_sid())) @@ -3643,6 +4122,8 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G if ((info = get_samr_info_by_sid(&info_sid)) == NULL) return NT_STATUS_NO_MEMORY; + + info->acc_granted = acc_granted; DEBUG(10, ("_samr_open_group:Opening SID: %s\n", sid_string)); -- cgit From fafecde33ac6f6b95a588227ad56bdf90524947e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 4 Jul 2002 12:51:26 +0000 Subject: * fix seg fault caused by missing DLIST_REMOVE in free_fn() * fixed constant vaolued returned by REG_UNKNOWN_1A (This used to be commit 3b934e6a8550a03028eed9fe65c28401f429d591) --- source3/rpc_server/srv_reg_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 0569d68cae..951e100486 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -372,6 +372,8 @@ static Registry_Key *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) static void free_reg_info(void *ptr) { Registry_Key *info = (Registry_Key*)ptr; + + DLIST_REMOVE(regkeys_list, info); SAFE_FREE(info); } @@ -695,7 +697,7 @@ NTSTATUS _reg_unknown_1a(pipes_struct *p, REG_Q_UNKNOWN_1A *q_u, REG_R_UNKNOWN_1 if ( !regkey ) return NT_STATUS_INVALID_HANDLE; - r_u->unknown = 0x05000000; /* seems to be consistent...no idea what it means */ + r_u->unknown = 0x00000005; /* seems to be consistent...no idea what it means */ DEBUG(5,("_reg_unknown_1a: Exit\n")); -- cgit From e48b3fe83c13aa9b061a880852d8ddd6623c29d6 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 4 Jul 2002 13:11:54 +0000 Subject: More code from "Kai Krueger" , this time starting to make the 'user cannot change password' button work. Needs help from a future SAM backend, but at least this parses the data, and returns an error. Andrew Bartlett (This used to be commit 0c4afe075aa018ec2be10f36fd3f0a5af2a032f1) --- source3/rpc_server/srv_samr.c | 32 ++++++++++++++++++++++++++++++++ source3/rpc_server/srv_samr_nt.c | 11 +++++++++++ 2 files changed, 43 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 1c4fab5312..f002a7d1c9 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -126,6 +126,37 @@ static BOOL api_samr_get_usrdom_pwinfo(pipes_struct *p) return True; } +/******************************************************************* + api_samr_set_sec_obj + ********************************************************************/ + +static BOOL api_samr_set_sec_obj(pipes_struct *p) +{ + SAMR_Q_SET_SEC_OBJ q_u; + SAMR_R_SET_SEC_OBJ r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!samr_io_q_set_sec_obj("", &q_u, data, 0)) { + DEBUG(0,("api_samr_set_sec_obj: unable to unmarshall SAMR_Q_SET_SEC_OBJ.\n")); + return False; + } + + r_u.status = _samr_set_sec_obj(p, &q_u, &r_u); + + if(!samr_io_r_set_sec_obj("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_set_sec_obj: unable to marshall SAMR_R_SET_SEC_OBJ.\n")); + return False; + } + + + return True; +} + /******************************************************************* api_samr_query_sec_obj ********************************************************************/ @@ -1430,6 +1461,7 @@ static struct api_struct api_samr_cmds [] = {"SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, {"SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, + {"SAMR_SET_SEC_OBJECT" , SAMR_SET_SEC_OBJECT , api_samr_set_sec_obj }, {"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, {"SAMR_UNKNOWN_2E" , SAMR_UNKNOWN_2E , api_samr_unknown_2e }, {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7a23a55b2a..4284c96f20 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -620,6 +620,17 @@ static BOOL get_lsa_policy_samr_sid(pipes_struct *p, POLICY_HND *pol, DOM_SID *s return True; } +/******************************************************************* + _samr_set_sec_obj + ********************************************************************/ + +NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_SEC_OBJ *r_u) +{ + DEBUG(0,("_samr_set_sec_obj: Not yet implemented!\n")); + return NT_STATUS_NOT_IMPLEMENTED; +} + + /******************************************************************* _samr_query_sec_obj ********************************************************************/ -- cgit From 26d161ff85a3a551990a6cb44f37ef28bd8dcdd6 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 4 Jul 2002 13:18:56 +0000 Subject: fixed the geyed out registry keys. Stupid typo on my part. Now on to plug in the printing tdbs to the registry view.... jerry (This used to be commit 2a68e4529ad884e8c3800f9006bb1c2b18cfada4) --- source3/rpc_server/srv_reg_nt.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 951e100486..1960ebc821 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -139,7 +139,7 @@ static int fetch_reg_keys( TDB_CONTEXT *tdb, char* key, char **subkeys ) if ( !buf ) { DEBUG(5,("fetch_reg_keys: Failed to fetch any subkeys for [%s]\n", key)); - return -1; + return 0; } len = tdb_unpack( buf, buflen, "d", &num_items); @@ -188,7 +188,7 @@ static int fetch_reg_keys_count( TDB_CONTEXT *tdb, char* key ) if ( !buf ) { DEBUG(5,("fetch_reg_keys: Failed to fetch any subkeys for [%s]\n", key)); - return -1; + return 0; } len = tdb_unpack( buf, buflen, "d", &num_items); @@ -480,21 +480,21 @@ static BOOL get_value_information( Registry_Key *key, uint32 *maxnum, return False; /* Hard coded key names first */ - - if ( !strcmp(key->name, KEY_HKLM) || !strcmp(key->name, KEY_HKU) ) - { - *maxnum = 0; - *maxlen = 0; - *maxsize = 0; - return True; - } - + /* nothing has valuies right now */ + + *maxnum = 0; + *maxlen = 0; + *maxsize = 0; + return True; + +#if 0 /* JERRY */ /* * FIXME!!! Need to add routines to look up values in other * databases --jerry */ return False; +#endif } /******************************************************************** @@ -670,7 +670,7 @@ NTSTATUS _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY * if ( !get_value_information( regkey, &r_u->num_values, &r_u->max_valnamelen, &r_u->max_valbufsize ) ) return NT_STATUS_ACCESS_DENIED; - r_u->sec_desc = 0x0; /* size for key's sec_desc */ + r_u->sec_desc = 0x00000078; /* size for key's sec_desc */ /* Win9x set this to 0x0 since it does not keep timestamps. Doing the same here for simplicity --jerry */ -- cgit From b1aec128e44c3728a2fa92896018dbf38f634d25 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 5 Jul 2002 04:08:32 +0000 Subject: Remove C++ comments. (This used to be commit 180374c4440765f3d08e5690967beb387ae3b54d) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 4284c96f20..88d728d810 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -661,13 +661,13 @@ NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_ DEBUG(5,("_samr_query_sec_obj: querying security on SAM\n")); r_u->status = samr_make_sam_obj_sd(p->mem_ctx, &psd, &sd_size); } - else if (sid_equal(&pol_sid,get_global_sam_sid())) //check if it is our domain SID + else if (sid_equal(&pol_sid,get_global_sam_sid())) /* check if it is our domain SID */ { DEBUG(5,("_samr_query_sec_obj: querying security on Domain with SID: %s\n", sid_to_string(str_sid, &pol_sid))); r_u->status = samr_make_dom_obj_sd(p->mem_ctx, &psd, &sd_size); } - else if (sid_equal(&pol_sid,&global_sid_Builtin)) //check if it is the Builtin Domain + else if (sid_equal(&pol_sid,&global_sid_Builtin)) /* check if it is the Builtin Domain */ { /* TODO: Builtin probably needs a different SD with restricted write access*/ DEBUG(5,("_samr_query_sec_obj: querying security on Builtin Domain with SID: %s\n", sid_to_string(str_sid, &pol_sid))); -- cgit From 48316a8c0e6b0ce6d4db966d319517a844194fce Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 6 Jul 2002 05:08:35 +0000 Subject: Copy the NT_TOKEN to the pipe, so the SAMR can use it for access control. Andrew Bartlett (This used to be commit 685a205445f5505c105ea421712c4b0468bbc127) --- source3/rpc_server/srv_pipe_hnd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index d4d45c230c..cc6e4b95f9 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -344,9 +344,11 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, p->pipe_user.uid = (uid_t)-1; p->pipe_user.gid = (gid_t)-1; - /* Store the session key */ - if (vuser) + /* Store the session key and NT_TOKEN */ + if (vuser) { memcpy(p->session_key, vuser->session_key, sizeof(p->session_key)); + p->pipe_user.nt_user_token = dup_nt_token(vuser->nt_user_token); + } /* * Initialize the incoming RPC struct. -- cgit From d29d29e4a2ecee741bdb3d37be77aeeab48f185f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 7 Jul 2002 03:34:24 +0000 Subject: Updates to the 'name -> sid' code: Correct the 'none mapped' behaviour, (so that it matches Win2k) and add a function to make the SID types appear as text strings in logs/rpcclient. Also, remove a silly case that would cause 'failure' to be 'success'. (Might look at this a bit more in future). Andrew Bartlett (This used to be commit c20d057f8821d13d3de61b319de44db23773516b) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f2f91d2d9a..d072061a5f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -167,7 +167,7 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, DEBUG(5, ("init_lsa_rid2s: %s\n", status ? "found" : "not found")); - if (status) { + if (status && name_type != SID_NAME_UNKNOWN) { sid_split_rid(&sid, &rid); dom_idx = init_dom_ref(ref, dom_name, &sid); (*mapped_count)++; -- cgit From b2be8917e0af1883405cc190357b3e1e0ccd7683 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 8 Jul 2002 01:06:38 +0000 Subject: Jerry: Sorry if I am stepping on toes here, but this should fix the compile on solaris CC (void* arithmatic) and fixes the other warnings (global variable shadows) that gcc has with this file. Andrew Bartlett (This used to be commit 7ac6517bec0f425f99f419f6efd2a673b4ec0f83) --- source3/rpc_server/srv_reg_nt.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 1960ebc821..3f07e4aaea 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -58,7 +58,7 @@ static TDB_CONTEXT *tdb_reg; static BOOL store_reg_keys( TDB_CONTEXT *tdb, char *keyname, char **subkeys, uint32 num_subkeys ) { TDB_DATA kbuf, dbuf; - void *buffer, *tmpbuf; + char *buffer, *tmpbuf; int i = 0; uint32 len, buflen; BOOL ret = True; @@ -121,7 +121,7 @@ static int fetch_reg_keys( TDB_CONTEXT *tdb, char* key, char **subkeys ) pstring path; uint32 num_items; TDB_DATA dbuf; - void *buf; + char *buf; uint32 buflen, len; int i; char *s; @@ -172,7 +172,7 @@ static int fetch_reg_keys_count( TDB_CONTEXT *tdb, char* key ) pstring path; uint32 num_items; TDB_DATA dbuf; - void *buf; + char *buf; uint32 buflen, len; @@ -203,7 +203,8 @@ static int fetch_reg_keys_count( TDB_CONTEXT *tdb, char* key ) is assumed to be an fstring. ***********************************************************************/ -static BOOL fetch_reg_keys_specific( TDB_CONTEXT *tdb, char* key, char* subkey, uint32 index ) +static BOOL fetch_reg_keys_specific( TDB_CONTEXT *tdb, char* key, char* subkey, + uint32 key_index ) { int num_subkeys, i; char *subkeys = NULL; @@ -216,7 +217,7 @@ static BOOL fetch_reg_keys_specific( TDB_CONTEXT *tdb, char* key, char* subkey, s = subkeys; for ( i=0; i Date: Mon, 8 Jul 2002 02:14:57 +0000 Subject: Kill off const warnings - add a pile of const to various places. (This used to be commit 1de04ec4735c19ec21cdef6e679cea17c734c5f6) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 157d756607..1d2c0c2713 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1151,7 +1151,7 @@ BOOL api_pipe_request(pipes_struct *p) ********************************************************************/ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, - struct api_struct *api_rpc_cmds) + const struct api_struct *api_rpc_cmds) { int fn_num; fstring name; -- cgit From 100b8986ea185817c575a3c0f475126f64b520b1 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 8 Jul 2002 18:34:55 +0000 Subject: * basic implementation of SPOOLSS_DELETEPRINTERDATAEX and SPOOLSS_DELETEPRINTERKEY * stub funnctions for SPOOLSS_ADDPRINTERDRIVEREX and SPOOLSS_DELETEPRINTERDRIVEREX (This used to be commit d675974d0c04a68d48d90492005056d96697c96c) --- source3/rpc_server/srv_spoolss.c | 125 +++++++++++++++++++++++++++++++++++- source3/rpc_server/srv_spoolss_nt.c | 70 ++++++++++++++++++++ 2 files changed, 194 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index fa013fe897..2c0b310af6 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1402,6 +1402,123 @@ static BOOL api_spoolss_getprintprocessordirectory(pipes_struct *p) return True; } +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_deleteprinterdataex(pipes_struct *p) +{ + SPOOL_Q_DELETEPRINTERDATAEX q_u; + SPOOL_R_DELETEPRINTERDATAEX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_deleteprinterdataex("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_deleteprinterdataex: unable to unmarshall SPOOL_Q_DELETEPRINTERDATAEX.\n")); + return False; + } + + r_u.status = _spoolss_deleteprinterdataex(p, &q_u, &r_u); + + if(!spoolss_io_r_deleteprinterdataex("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_deleteprinterdataex: unable to marshall SPOOL_R_DELETEPRINTERDATAEX.\n")); + return False; + } + + return True; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_deleteprinterkey(pipes_struct *p) +{ + SPOOL_Q_DELETEPRINTERKEY q_u; + SPOOL_R_DELETEPRINTERKEY r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_deleteprinterkey("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_deleteprinterkey: unable to unmarshall SPOOL_Q_DELETEPRINTERKEY.\n")); + return False; + } + + r_u.status = _spoolss_deleteprinterkey(p, &q_u, &r_u); + + if(!spoolss_io_r_deleteprinterkey("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_deleteprinterkey: unable to marshall SPOOL_R_DELETEPRINTERKEY.\n")); + return False; + } + + return True; +} + +#if 0 /* JERRY */ +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_addprinterdrriverex(pipes_struct *p) +{ + SPOOL_Q_ADDPRINTERDRIVEREX q_u; + SPOOL_R_ADDPRINTERDRIVEREX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_addprinterdriverex("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_addprinterdriverex: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVEREX.\n")); + return False; + } + + r_u.status = _spoolss_addprinterdriverex(p, &q_u, &r_u); + + if(!spoolss_io_r_addprinterdriverex("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_addprinterdriverex: unable to marshall SPOOL_R_ADDPRINTERDRIVEREX.\n")); + return False; + } + + return True; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_deleteprinterdriverex(pipes_struct *p) +{ + SPOOL_Q_DELETEPRINTERDRIVEREX q_u; + SPOOL_R_DELETEPRINTERDRIVEREX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_deleteprinterdriverex("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_deleteprinterdriverex: unable to unmarshall SPOOL_Q_DELETEPRINTERDRIVEREX.\n")); + return False; + } + + r_u.status = _spoolss_deleteprinterdriverex(p, &q_u, &r_u); + + if(!spoolss_io_r_deleteprinterdriverex("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_deleteprinterdriverex: unable to marshall SPOOL_R_DELETEPRINTERDRIVEREX.\n")); + return False; + } + + return True; +} + + +#endif /* JERRY */ + + /******************************************************************* \pipe\spoolss commands ********************************************************************/ @@ -1452,9 +1569,15 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_ENUMPRINTPROCDATATYPES", SPOOLSS_ENUMPRINTPROCDATATYPES, api_spoolss_enumprintprocdatatypes }, {"SPOOLSS_GETPRINTERDATAEX", SPOOLSS_GETPRINTERDATAEX, api_spoolss_getprinterdataex }, {"SPOOLSS_SETPRINTERDATAEX", SPOOLSS_SETPRINTERDATAEX, api_spoolss_setprinterdataex }, - {"SPOOLSS_ENUMPRINTERKEY", SPOOLSS_ENUMPRINTERKEY, api_spoolss_enumprinterkey }, + {"SPOOLSS_DELETEPRINTERDATAEX", SPOOLSS_DELETEPRINTERDATAEX, api_spoolss_deleteprinterdataex }, {"SPOOLSS_ENUMPRINTERDATAEX", SPOOLSS_ENUMPRINTERDATAEX, api_spoolss_enumprinterdataex }, + {"SPOOLSS_ENUMPRINTERKEY", SPOOLSS_ENUMPRINTERKEY, api_spoolss_enumprinterkey }, + {"SPOOLSS_DELETEPRINTERKEY", SPOOLSS_DELETEPRINTERKEY, api_spoolss_deleteprinterkey }, {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory}, +#if 0 /* JERRY */ + {"SPOOLSS_ADDPRINTERDRIVEREX", SPOOLSS_ADDPRINTERDRIVEREX, api_spoolss_addprinterdriverex }, + {"SPOOLSS_DELETEPRINTERDRIVEREX", SPOOLSS_DELETEPRINTERDRIVEREX, api_spoolss_deleteprinterdriverex }, +#endif { NULL, 0, NULL } }; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 9b17bdb7ee..0e209c6064 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7967,6 +7967,34 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, return _spoolss_setprinterdata(p, &q_u_local, &r_u_local); } + +/******************************************************************** + * spoolss_deleteprinterdataex + ********************************************************************/ + +WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX *q_u, SPOOL_R_DELETEPRINTERDATAEX *r_u) +{ + SPOOL_Q_DELETEPRINTERDATA q_u_local; + SPOOL_R_DELETEPRINTERDATA r_u_local; + fstring key; + + /* From MSDN documentation of SetPrinterDataEx: pass request to + SetPrinterData if key is "PrinterDriverData" */ + + unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); + + if (strcmp(key, "PrinterDriverData") != 0) + return WERR_INVALID_PARAM; + + memcpy(&q_u_local.handle, &q_u->handle, sizeof(POLICY_HND)); + copy_unistr2(&q_u_local.valuename, &q_u->valuename); + + return _spoolss_deleteprinterdata( p, &q_u_local, &r_u_local ); +} + + + + /******************************************************************** * spoolss_enumprinterkey ********************************************************************/ @@ -8227,3 +8255,45 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC return result; } + +/******************************************************************** + * spoolss_addprinterdriverex + ********************************************************************/ + +WERROR _spoolss_addprinterdriverex(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVEREX *q_u, SPOOL_R_ADDPRINTERDRIVEREX *r_u) +{ + return WERR_OK; +} + +/******************************************************************** + * spoolss_deleteprinterdriverex + ********************************************************************/ + +WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVEREX *q_u, SPOOL_R_DELETEPRINTERDRIVEREX *r_u) +{ + return WERR_OK; +} + +/******************************************************************** + * spoolss_deleteprinterkey + ********************************************************************/ + +WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, SPOOL_R_DELETEPRINTERKEY *r_u) +{ + fstring key; + + unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); + + if (strcmp(key, "PrinterDriverData") != 0) + return WERR_INVALID_PARAM; + + /* + * this is what 2k returns when you try to delete the "PrinterDriverData" + * key + */ + + return WERR_ACCESS_DENIED; +} + + + -- cgit From e247cb8239275be517802f80bc82462fbfc1f5c3 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 8 Jul 2002 20:15:47 +0000 Subject: added parsing routines for SPOOLSS_ADDPRINTERDRIVEREX and SPOOLSS_DELETEPRINTERDRIVEREX. Ran them through some testing. I know I'm off by 2 x uint32's in the former RPC. (This used to be commit 55fbfd02ba917b74fd4df7a1aa8cc8c5a91e3e07) --- source3/rpc_server/srv_spoolss.c | 8 +- source3/rpc_server/srv_spoolss_nt.c | 154 ++++++++++++++++++++++-------------- 2 files changed, 96 insertions(+), 66 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 2c0b310af6..70b039c37f 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1458,11 +1458,10 @@ static BOOL api_spoolss_deleteprinterkey(pipes_struct *p) return True; } -#if 0 /* JERRY */ /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addprinterdrriverex(pipes_struct *p) +static BOOL api_spoolss_addprinterdriverex(pipes_struct *p) { SPOOL_Q_ADDPRINTERDRIVEREX q_u; SPOOL_R_ADDPRINTERDRIVEREX r_u; @@ -1516,9 +1515,6 @@ static BOOL api_spoolss_deleteprinterdriverex(pipes_struct *p) } -#endif /* JERRY */ - - /******************************************************************* \pipe\spoolss commands ********************************************************************/ @@ -1574,10 +1570,8 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_ENUMPRINTERKEY", SPOOLSS_ENUMPRINTERKEY, api_spoolss_enumprinterkey }, {"SPOOLSS_DELETEPRINTERKEY", SPOOLSS_DELETEPRINTERKEY, api_spoolss_deleteprinterkey }, {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory}, -#if 0 /* JERRY */ {"SPOOLSS_ADDPRINTERDRIVEREX", SPOOLSS_ADDPRINTERDRIVEREX, api_spoolss_addprinterdriverex }, {"SPOOLSS_DELETEPRINTERDRIVEREX", SPOOLSS_DELETEPRINTERDRIVEREX, api_spoolss_deleteprinterdriverex }, -#endif { NULL, 0, NULL } }; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0e209c6064..d66c023ba6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1547,8 +1547,7 @@ static int get_version_id (char * arch) * --jerry ********************************************************************/ -WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER *q_u, - SPOOL_R_DELETEPRINTERDRIVER *r_u) +WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER *q_u, SPOOL_R_DELETEPRINTERDRIVER *r_u) { fstring driver; fstring arch; @@ -1565,19 +1564,51 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER } ZERO_STRUCT(info); - if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) { + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) return WERR_UNKNOWN_PRINTER_DRIVER; - } if (printer_driver_in_use(arch, driver)) - { return WERR_PRINTER_DRIVER_IN_USE; + + return delete_printer_driver(info.info_3); +} + +/******************************************************************** + * spoolss_deleteprinterdriverex + ********************************************************************/ + +WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVEREX *q_u, SPOOL_R_DELETEPRINTERDRIVEREX *r_u) +{ + fstring driver; + fstring arch; + NT_PRINTER_DRIVER_INFO_LEVEL info; + int version; + + unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)-1 ); + unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)-1 ); + + /* check that we have a valid driver name first */ + if ((version=get_version_id(arch)) == -1) { + /* this is what NT returns */ + return WERR_INVALID_ENVIRONMENT; } + + if (q_u->delete_flags & DPD_DELETE_SPECIFIC_VERSION) + version = q_u->version; + + ZERO_STRUCT(info); + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) + return WERR_UNKNOWN_PRINTER_DRIVER; + + + if (printer_driver_in_use(arch, driver)) + return WERR_PRINTER_DRIVER_IN_USE; - return delete_printer_driver(info.info_3); + return delete_printer_driver(info.info_3); } + /******************************************************************** GetPrinterData on a printer server Handle. ********************************************************************/ @@ -6884,6 +6915,32 @@ done: return err; } +/******************************************************************** + * spoolss_addprinterdriverex + ********************************************************************/ + +WERROR _spoolss_addprinterdriverex(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVEREX *q_u, SPOOL_R_ADDPRINTERDRIVEREX *r_u) +{ + SPOOL_Q_ADDPRINTERDRIVER q_u_local; + SPOOL_R_ADDPRINTERDRIVER r_u_local; + + /* + * we only support the semantics of AddPrinterDriver() + * i.e. only copy files that are newer than existing ones + */ + + if ( q_u->copy_flags != APD_COPY_NEW_FILES ) + return WERR_ACCESS_DENIED; + + /* just pass the information off to _spoolss_addprinterdriver() */ + q_u_local.server_name_ptr = q_u->server_name_ptr; + copy_unistr2(&q_u_local.server_name, &q_u->server_name); + q_u_local.level = q_u->level; + memcpy( &q_u_local.info, &q_u->info, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL) ); + + return _spoolss_addprinterdriver( p, &q_u_local, &r_u_local ); +} + /**************************************************************************** ****************************************************************************/ @@ -7120,10 +7177,8 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP POLICY_HND *handle = &q_u->handle; UNISTR2 *value = &q_u->value; uint32 type = q_u->type; -/* uint32 max_len = q_u->max_len; - notused. */ uint8 *data = q_u->data; uint32 real_len = q_u->real_len; -/* uint32 numeric_data = q_u->numeric_data; - notused. */ NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_PARAM *param = NULL, old_param; @@ -7395,8 +7450,6 @@ done: WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM *r_u) { POLICY_HND *handle = &q_u->handle; -/* UNISTR2 *uni_name = &q_u->name; - notused. */ -/* uint32 level = q_u->level; - notused. */ FORM *form = &q_u->form; nt_forms_struct tmpForm; int snum; @@ -7487,12 +7540,10 @@ static WERROR enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, SPOOL_R_ENUMPRINTPROCESSORS *r_u) { -/* UNISTR2 *name = &q_u->name; - notused. */ -/* UNISTR2 *environment = &q_u->environment; - notused. */ uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; - uint32 *needed = &r_u->needed; + uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ @@ -7556,8 +7607,6 @@ static WERROR enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, WERROR _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u) { -/* UNISTR2 *name = &q_u->name; - notused. */ -/* UNISTR2 *processor = &q_u->processor; - notused. */ uint32 level = q_u->level; NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; @@ -7652,11 +7701,10 @@ static WERROR enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_u, SPOOL_R_ENUMPRINTMONITORS *r_u) { -/* UNISTR2 *name = &q_u->name; - notused. */ uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; - uint32 *needed = &r_u->needed; + uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ @@ -8061,6 +8109,34 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO return WERR_BADFILE; } +/******************************************************************** + * spoolss_deleteprinterkey + ********************************************************************/ + +WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, SPOOL_R_DELETEPRINTERKEY *r_u) +{ + Printer_entry *Printer = find_printer_index_by_hnd(p, &q_u->handle); + fstring key; + + if (!Printer) { + DEBUG(2,("_spoolss_deleteprinterkey: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); + return WERR_BADFID; + } + + unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); + + if (strcmp(key, "PrinterDriverData") != 0) + return WERR_INVALID_PARAM; + + /* + * this is what 2k returns when you try to delete the "PrinterDriverData" + * key + */ + + return WERR_ACCESS_DENIED; +} + + /******************************************************************** * spoolss_enumprinterdataex ********************************************************************/ @@ -8256,44 +8332,4 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC return result; } -/******************************************************************** - * spoolss_addprinterdriverex - ********************************************************************/ - -WERROR _spoolss_addprinterdriverex(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVEREX *q_u, SPOOL_R_ADDPRINTERDRIVEREX *r_u) -{ - return WERR_OK; -} - -/******************************************************************** - * spoolss_deleteprinterdriverex - ********************************************************************/ - -WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVEREX *q_u, SPOOL_R_DELETEPRINTERDRIVEREX *r_u) -{ - return WERR_OK; -} - -/******************************************************************** - * spoolss_deleteprinterkey - ********************************************************************/ - -WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, SPOOL_R_DELETEPRINTERKEY *r_u) -{ - fstring key; - - unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); - - if (strcmp(key, "PrinterDriverData") != 0) - return WERR_INVALID_PARAM; - - /* - * this is what 2k returns when you try to delete the "PrinterDriverData" - * key - */ - - return WERR_ACCESS_DENIED; -} - - -- cgit From 18742edd2acc4848bacf2af6008bf9fea5f82f6b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 8 Jul 2002 20:30:54 +0000 Subject: fix typo (This used to be commit be926c3a1a7fc79af62dd1830c56e9503f89f9dd) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d66c023ba6..70964ce668 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8119,7 +8119,7 @@ WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, fstring key; if (!Printer) { - DEBUG(2,("_spoolss_deleteprinterkey: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_deleteprinterkey: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(&q_u->handle))); return WERR_BADFID; } -- cgit From 496e85dd812b932caf5e6169e03df6b31a378966 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 11 Jul 2002 01:54:26 +0000 Subject: intermediate work on DeletePrinterDriverEx(). This call will actually delete driver files ( not yet though I don't think). Just wanted to get it in since Jeremy and I are both working on nt_printing.c (This used to be commit 3fa6c3132950c9ff1c6a532d8264ee34a6b2b0ff) --- source3/rpc_server/srv_spoolss_nt.c | 43 +++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 70964ce668..8acdd9d5ab 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1562,16 +1562,21 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER /* this is what NT returns */ return WERR_INVALID_ENVIRONMENT; } + + /* if they said "Windows NT x86", then try for version 2 & 3 */ + + if ( version == 2 ) + version = DRIVER_ANY_VERSION; ZERO_STRUCT(info); + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) return WERR_UNKNOWN_PRINTER_DRIVER; - - if (printer_driver_in_use(arch, driver)) + if (printer_driver_in_use(info.info_3)) return WERR_PRINTER_DRIVER_IN_USE; - return delete_printer_driver(info.info_3); + return delete_printer_driver(info.info_3, False); } /******************************************************************** @@ -1584,6 +1589,7 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV fstring arch; NT_PRINTER_DRIVER_INFO_LEVEL info; int version; + uint32 flags = q_u->delete_flags; unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)-1 ); unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)-1 ); @@ -1594,18 +1600,25 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV return WERR_INVALID_ENVIRONMENT; } - if (q_u->delete_flags & DPD_DELETE_SPECIFIC_VERSION) + if ( flags & DPD_DELETE_SPECIFIC_VERSION ) version = q_u->version; + else if ( version == 2 ) + /* if they said "Windows NT x86", then try for version 2 & 3 */ + version = DRIVER_ANY_VERSION; ZERO_STRUCT(info); - if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) - return WERR_UNKNOWN_PRINTER_DRIVER; + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) + return WERR_UNKNOWN_PRINTER_DRIVER; - if (printer_driver_in_use(arch, driver)) + if ( printer_driver_in_use(info.info_3) ) return WERR_PRINTER_DRIVER_IN_USE; + + if ( printer_driver_files_in_use(info.info_3) ) + /* no idea of the correct error here */ + return WERR_ACCESS_DENIED; - return delete_printer_driver(info.info_3); + return delete_printer_driver(info.info_3, True); } @@ -5869,8 +5882,6 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u { POLICY_HND *handle = &q_u->handle; uint32 jobid = q_u->jobid; -/* uint32 level = q_u->level; - notused. */ -/* JOB_INFO *ctr = &q_u->ctr; - notused. */ uint32 command = q_u->command; struct current_user user; @@ -5928,9 +5939,7 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture *returned=0; -#define MAX_VERSION 4 - - for (version=0; version Date: Thu, 11 Jul 2002 03:27:12 +0000 Subject: all that is left to do is to actually perform the file deletion now. I have the file list. One more commit should do it. (This used to be commit 7207662504f585352b0ceeb99f8998ef58db7f15) --- source3/rpc_server/srv_spoolss_nt.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8acdd9d5ab..a37d8e9c19 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1590,6 +1590,7 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV NT_PRINTER_DRIVER_INFO_LEVEL info; int version; uint32 flags = q_u->delete_flags; + BOOL delete_files; unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)-1 ); unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)-1 ); @@ -1614,11 +1615,30 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV if ( printer_driver_in_use(info.info_3) ) return WERR_PRINTER_DRIVER_IN_USE; - if ( printer_driver_files_in_use(info.info_3) ) - /* no idea of the correct error here */ - return WERR_ACCESS_DENIED; + /* + * we have a couple of cases to consider. + * (1) Are any files in use? If so and DPD_DELTE_ALL_FILE is set, + * then the delete should fail if **any** files overlap with + * other drivers + * (2) If DPD_DELTE_UNUSED_FILES is sert, then delete all + * non-overlapping files + * (3) If neither DPD_DELTE_ALL_FILE nor DPD_DELTE_ALL_FILES + * is set, the do not delete any files + * Refer to MSDN docs on DeletePrinterDriverEx() for details. + */ + + delete_files = flags & (DPD_DELETE_ALL_FILES|DPD_DELETE_UNUSED_FILES); + + if ( delete_files ) + { + /* fail if any files are in use and DPD_DELETE_ALL_FILES is set */ + + if ( printer_driver_files_in_use(info.info_3) & (flags&DPD_DELETE_ALL_FILES) ) + /* no idea of the correct error here */ + return WERR_ACCESS_DENIED; + } - return delete_printer_driver(info.info_3, True); + return delete_printer_driver(info.info_3, delete_files); } -- cgit From 137570cb037f75131241c3ae13a372803d21fbe1 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 11 Jul 2002 04:53:39 +0000 Subject: last check in for tonight. * DeletePrinterDriverEx() now has the ability to delete driver files. I need to do some more testing tro veriofy that we are in fact not deleting a file out from under another driver, but it looks ok so far. * DeletePrinterDriver() noiw deletes all versions of the specified driver (cversion == 0, 1, 2, 3) (This used to be commit 17bb780e1327663fa2fcd6a3cb25dd461a29c537) --- source3/rpc_server/srv_spoolss_nt.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a37d8e9c19..f7f191522f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1534,17 +1534,6 @@ static int get_version_id (char * arch) /******************************************************************** * _spoolss_deleteprinterdriver - * - * We currently delete the driver for the architecture only. - * This can leave the driver for other archtectures. However, - * since every printer associates a "Windows NT x86" driver name - * and we cannot delete that one while it is in use, **and** since - * it is impossible to assign a driver to a Samba printer without - * having the "Windows NT x86" driver installed,... - * - * ....we should not get into trouble here. - * - * --jerry ********************************************************************/ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER *q_u, SPOOL_R_DELETEPRINTERDRIVER *r_u) @@ -1553,6 +1542,9 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER fstring arch; NT_PRINTER_DRIVER_INFO_LEVEL info; int version; + struct current_user user; + + get_current_user(&user, p); unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)-1 ); unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)-1 ); @@ -1576,7 +1568,7 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER if (printer_driver_in_use(info.info_3)) return WERR_PRINTER_DRIVER_IN_USE; - return delete_printer_driver(info.info_3, False); + return delete_printer_driver(info.info_3, &user, DRIVER_ANY_VERSION, False); } /******************************************************************** @@ -1591,6 +1583,9 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV int version; uint32 flags = q_u->delete_flags; BOOL delete_files; + struct current_user user; + + get_current_user(&user, p); unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)-1 ); unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)-1 ); @@ -1611,7 +1606,7 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) return WERR_UNKNOWN_PRINTER_DRIVER; - + if ( printer_driver_in_use(info.info_3) ) return WERR_PRINTER_DRIVER_IN_USE; @@ -1638,7 +1633,7 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV return WERR_ACCESS_DENIED; } - return delete_printer_driver(info.info_3, delete_files); + return delete_printer_driver(info.info_3, &user, version, delete_files); } @@ -6820,7 +6815,7 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, ZERO_STRUCT(driver); - get_current_user(&user, p); + get_current_user(&user, p); if (!convert_printer_driver_info(info, &driver, level)) { err = WERR_NOMEM; -- cgit From bdfe11eaeadee6e9f6050511203b36f0c62ecfc4 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 11 Jul 2002 13:17:57 +0000 Subject: added copyright (This used to be commit dcb6d70706a0e86881588c3828ff5bd4d63d415f) --- source3/rpc_server/srv_spoolss.c | 3 ++- source3/rpc_server/srv_spoolss_nt.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 70b039c37f..6e3463e79b 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -4,7 +4,8 @@ * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Gerald Carter 2001-2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f7f191522f..32b2dc8b9e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000, * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Gerald Carter 2000-2001, + * Copyright (C) Gerald Carter 2000-2002, * Copyright (C) Tim Potter 2001-2002. * * This program is free software; you can redistribute it and/or modify -- cgit From 8ba2c4e55d783587a5a6064dc2d48e4deff16fd3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 12 Jul 2002 18:10:24 +0000 Subject: We must ZERO_STRUCT before using the buffer in copy_unistr2. Fixes addprinterdriverex. Jeremy. (This used to be commit d3c73e59708eeb1ee4642fb31fcfc0ec2fd28070) --- source3/rpc_server/srv_spoolss_nt.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 32b2dc8b9e..68c792f8b0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6953,6 +6953,9 @@ WERROR _spoolss_addprinterdriverex(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVEREX * return WERR_ACCESS_DENIED; /* just pass the information off to _spoolss_addprinterdriver() */ + ZERO_STRUCT(q_u_local); + ZERO_STRUCT(r_u_local); + q_u_local.server_name_ptr = q_u->server_name_ptr; copy_unistr2(&q_u_local.server_name, &q_u->server_name); q_u_local.level = q_u->level; -- cgit From 369040ac5d7220a301b09c16b0a6f4a3ce14c8b6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Jul 2002 03:59:14 +0000 Subject: fixed a problem with getgroups() where it could include our current effective gid which could mean that the user gets group 0 in their group list for acl interpretation this is a replacement fix for the one richard did in 2.2 (which didn't cope wiith variable behaviour depending on which nss module was in use) (This used to be commit cfc5ca3416cea5ea5d2ac34f5521cb6367e42cd2) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 1d2c0c2713..b7be415abc 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -435,7 +435,7 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); /* Set up pipe user group membership. */ initialise_groups(p->pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); - get_current_groups( &p->pipe_user.ngroups, &p->pipe_user.groups); + get_current_groups(p->pipe_user.gid, &p->pipe_user.ngroups, &p->pipe_user.groups); if (server_info->ptok) add_supplementary_nt_login_groups(&p->pipe_user.ngroups, &p->pipe_user.groups, &server_info->ptok); -- cgit From e90b65284812aaa5ff9e9935ce9bbad7791cbbcd Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Jul 2002 10:35:28 +0000 Subject: updated the 3.0 branch from the head branch - ready for alpha18 (This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce) --- source3/rpc_server/srv_dfs.c | 3 + source3/rpc_server/srv_dfs_nt.c | 33 +- source3/rpc_server/srv_lsa.c | 5 + source3/rpc_server/srv_lsa_hnd.c | 48 ++ source3/rpc_server/srv_lsa_nt.c | 58 +- source3/rpc_server/srv_netlog.c | 3 + source3/rpc_server/srv_netlog_nt.c | 53 +- source3/rpc_server/srv_pipe.c | 7 +- source3/rpc_server/srv_pipe_hnd.c | 50 +- source3/rpc_server/srv_reg.c | 138 +++- source3/rpc_server/srv_reg_nt.c | 661 +++++++++++++++-- source3/rpc_server/srv_samr.c | 35 + source3/rpc_server/srv_samr_nt.c | 1339 ++++++++++++++++++++++----------- source3/rpc_server/srv_spoolss.c | 125 +++- source3/rpc_server/srv_spoolss_nt.c | 1384 ++++++++++++++++++++++++----------- source3/rpc_server/srv_srvsvc.c | 39 +- source3/rpc_server/srv_srvsvc_nt.c | 143 ++-- source3/rpc_server/srv_util.c | 18 +- source3/rpc_server/srv_wkssvc.c | 5 +- source3/rpc_server/srv_wkssvc_nt.c | 3 + 20 files changed, 3085 insertions(+), 1065 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 4351fd088e..5edc1222a8 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -28,6 +28,9 @@ #define MAX_MSDFS_JUNCTIONS 256 +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + extern pstring global_myname; /********************************************************************** diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 4db6c61a3c..65e387176d 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -26,6 +26,9 @@ #include "includes.h" #include "nterr.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + extern pstring global_myname; #define MAX_MSDFS_JUNCTIONS 256 @@ -69,10 +72,7 @@ WERROR _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 WERR_DFS_NO_SUCH_SERVER; - - if(get_referred_path(&jn)) + if(get_referred_path(dfspath, &jn, NULL, NULL)) { exists = True; jn.referral_count += 1; @@ -137,16 +137,14 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_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 WERR_DFS_NO_SUCH_SERVER; - - if(!get_referred_path(&jn)) - return WERR_DFS_NO_SUCH_VOL; + if(!get_referred_path(dfspath, &jn, NULL, NULL)) + return WERR_DFS_NO_SUCH_VOL; /* if no server-share pair given, remove the msdfs link completely */ if(!q_u->ptr_ServerName && !q_u->ptr_ShareName) @@ -158,14 +156,18 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_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;ilevel = level; r_u->ptr_ctr = 1; diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index fcd4be0212..e5a4d3b46d 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -25,6 +25,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /*************************************************************************** api_lsa_open_policy2 ***************************************************************************/ @@ -105,8 +108,10 @@ static BOOL api_lsa_enum_trust_dom(pipes_struct *p) if(!lsa_io_q_enum_trust_dom("", &q_u, data, 0)) return False; + /* get required trusted domains information */ r_u.status = _lsa_enum_trust_dom(p, &q_u, &r_u); + /* prepare the response */ if(!lsa_io_r_enum_trust_dom("", &r_u, rdata, 0)) return False; diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 84c3c5a959..2d04d72323 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -22,6 +22,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /* This is the max handles across all instances of a pipe name. */ #ifndef MAX_OPEN_POLS #define MAX_OPEN_POLS 1024 @@ -134,6 +137,14 @@ BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *) DLIST_ADD(p->pipe_handles->Policy, pol); p->pipe_handles->count++; + /* + * Ensure we don't idle this connection if a handle is open. + * Increment the number of files open on the first handle create. + */ + + if (p->pipe_handles->count == 1) + p->conn->num_files_open++; + *hnd = pol->pol_hnd; DEBUG(4,("Opened policy hnd[%d] ", (int)p->pipe_handles->count)); @@ -201,6 +212,15 @@ BOOL close_policy_hnd(pipes_struct *p, POLICY_HND *hnd) p->pipe_handles->count--; + /* + * Ensure we can idle this connection if this is the last handle. + * Decrement the number of files open on the last handle delete. + */ + + if (p->pipe_handles->count == 0) + p->conn->num_files_open--; + + DLIST_REMOVE(p->pipe_handles->Policy, pol); ZERO_STRUCTP(pol); @@ -232,3 +252,31 @@ void close_policy_by_pipe(pipes_struct *p) DEBUG(10,("close_policy_by_pipe: deleted handle list for pipe %s\n", p->name )); } } + +/******************************************************************* +Shall we allow access to this rpc? Currently this function +implements the 'restrict anonymous' setting by denying access to +anonymous users if the restrict anonymous level is > 0. Further work +will be checking a security descriptor to determine whether a user +token has enough access to access the pipe. +********************************************************************/ + +BOOL pipe_access_check(pipes_struct *p) +{ + /* Don't let anonymous users access this RPC if restrict + anonymous > 0 */ + + if (lp_restrict_anonymous() > 0) { + user_struct *user = get_valid_user_struct(p->vuid); + + if (!user) { + DEBUG(3, ("invalid vuid %d\n", p->vuid)); + return False; + } + + if (user->guest) + return False; + } + + return True; +} diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 84ab44bc30..d072061a5f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -3,8 +3,9 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Rafal Szczesniak 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,7 +26,9 @@ #include "includes.h" -extern DOM_SID global_sam_sid; +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + extern fstring global_myworkgroup; extern pstring global_myname; extern PRIVS privs[]; @@ -164,7 +167,7 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, DEBUG(5, ("init_lsa_rid2s: %s\n", status ? "found" : "not found")); - if (status) { + if (status && name_type != SID_NAME_UNKNOWN) { sid_split_rid(&sid, &rid); dom_idx = init_dom_ref(ref, dom_name, &sid); (*mapped_count)++; @@ -258,6 +261,8 @@ static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME if (!status) { sid_name_use = SID_NAME_UNKNOWN; + } else { + (*mapped_count)++; } /* Store domain sid in ref array */ @@ -271,8 +276,6 @@ static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME DEBUG(10,("init_lsa_trans_names: added user '%s\\%s' to " "referenced list.\n", dom_name, name )); - (*mapped_count)++; - init_lsa_trans_name(&trn->name[total], &trn->uni_name[total], sid_name_use, name, dom_idx); total++; @@ -319,7 +322,7 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s init_sec_access(&mask, POLICY_EXECUTE); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - sid_copy(&adm_sid, &global_sam_sid); + sid_copy(&adm_sid, get_global_sam_sid()); sid_append_rid(&adm_sid, DOMAIN_GROUP_RID_ADMINS); init_sec_access(&mask, POLICY_ALL_ACCESS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); @@ -366,7 +369,7 @@ NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(info); - info->sid = global_sam_sid; + sid_copy(&info->sid,get_global_sam_sid()); info->access = acc_granted; /* set up the LSA QUERY INFO response */ @@ -404,7 +407,7 @@ NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL * return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(info); - info->sid = global_sam_sid; + sid_copy(&info->sid,get_global_sam_sid()); info->access = acc_granted; /* set up the LSA QUERY INFO response */ @@ -416,14 +419,22 @@ NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL * /*************************************************************************** _lsa_enum_trust_dom - this needs fixing to do more than return NULL ! JRA. + ufff, done :) mimir ***************************************************************************/ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_ENUM_TRUST_DOM *r_u) { struct lsa_info *info; - uint32 enum_context = 0; - char *dom_name = NULL; - DOM_SID *dom_sid = NULL; + uint32 enum_context = q_u->enum_context; + + /* + * preferred length is set to 5 as a "our" preferred length + * nt sets this parameter to 2 + */ + uint32 max_num_domains = q_u->preferred_len < 5 ? q_u->preferred_len : 10; + TRUSTDOM **trust_doms; + uint32 num_domains; + NTSTATUS nt_status; if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; @@ -432,9 +443,18 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E if (!(info->access & POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - /* set up the LSA QUERY INFO response */ - init_r_enum_trust_dom(p->mem_ctx, r_u, enum_context, dom_name, dom_sid, - dom_name != NULL ? NT_STATUS_OK : NT_STATUS_NO_MORE_ENTRIES); + nt_status = secrets_get_trusted_domains(p->mem_ctx, &enum_context, max_num_domains, &num_domains, &trust_doms); + + if (!NT_STATUS_IS_OK(nt_status) && + !NT_STATUS_EQUAL(nt_status, STATUS_MORE_ENTRIES) && + !NT_STATUS_EQUAL(nt_status, NT_STATUS_NO_MORE_ENTRIES)) { + return nt_status; + } else { + r_u->status = nt_status; + } + + /* set up the lsa_enum_trust_dom response */ + init_r_enum_trust_dom(p->mem_ctx, r_u, enum_context, max_num_domains, num_domains, trust_doms); return r_u->status; } @@ -484,7 +504,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: name = global_myworkgroup; - sid = &global_sam_sid; + sid = get_global_sam_sid(); break; case ROLE_DOMAIN_MEMBER: name = global_myworkgroup; @@ -514,15 +534,15 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: name = global_myworkgroup; - sid = &global_sam_sid; + sid = get_global_sam_sid(); break; case ROLE_DOMAIN_MEMBER: name = global_myname; - sid = &global_sam_sid; + sid = get_global_sam_sid(); break; case ROLE_STANDALONE: name = global_myname; - sid = &global_sam_sid; + sid = get_global_sam_sid(); break; default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index dfd270ff7d..f96a0e2f2d 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -25,6 +25,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /************************************************************************* api_net_req_chal: *************************************************************************/ diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index bdb064c81d..4ab9c470d0 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -26,8 +26,10 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + extern pstring global_myname; -extern DOM_SID global_sam_sid; /************************************************************************* init_net_r_req_chal: @@ -150,7 +152,7 @@ NTSTATUS _net_trust_dom_list(pipes_struct *p, NET_Q_TRUST_DOM_LIST *q_u, NET_R_T ***********************************************************************************/ static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, - DOM_CRED *srv_cred, NTSTATUS status) + DOM_CRED *srv_cred, NTSTATUS status) { DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); @@ -378,7 +380,7 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_u) { - NTSTATUS status = NT_STATUS_WRONG_PASSWORD; + NTSTATUS status = NT_STATUS_ACCESS_DENIED; DOM_CRED srv_cred; pstring workstation; SAM_ACCOUNT *sampass=NULL; @@ -395,8 +397,8 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); - rpcstr_pull(workstation,q_u->clnt_id.login.uni_acct_name.buffer, - sizeof(workstation),q_u->clnt_id.login.uni_acct_name.uni_str_len*2,0); + rpcstr_pull(workstation,q_u->clnt_id.login.uni_comp_name.buffer, + sizeof(workstation),q_u->clnt_id.login.uni_comp_name.uni_str_len*2,0); DEBUG(3,("Server Password Set by Wksta:[%s] on account [%s]\n", workstation, p->dc.mach_acct)); @@ -656,14 +658,35 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * { DOM_GID *gids = NULL; + const DOM_SID *user_sid = NULL; + const DOM_SID *group_sid = NULL; + DOM_SID domain_sid; + uint32 user_rid, group_rid; + int num_gids = 0; pstring my_name; - pstring my_workgroup; - + fstring user_sid_string; + fstring group_sid_string; + + sampw = server_info->sam_account; + /* set up pointer indicating user/password failed to be found */ usr_info->ptr_user_info = 0; - - pstrcpy(my_workgroup, lp_workgroup()); + + user_sid = pdb_get_user_sid(sampw); + group_sid = pdb_get_group_sid(sampw); + + sid_copy(&domain_sid, user_sid); + sid_split_rid(&domain_sid, &user_rid); + + if (!sid_peek_check_rid(&domain_sid, group_sid, &group_rid)) { + DEBUG(1, ("_net_sam_logon: user %s\\%s has user sid %s\n but group sid %s.\nThe conflicting domain portions are not supported for NETLOGON calls\n", + pdb_get_domain(sampw), pdb_get_username(sampw), + sid_to_string(user_sid_string, user_sid), + sid_to_string(group_sid_string, group_sid))); + return NT_STATUS_UNSUCCESSFUL; + } + pstrcpy(my_name, global_myname); strupper(my_name); @@ -677,12 +700,10 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * gids = NULL; get_domain_user_groups(p->mem_ctx, &num_gids, &gids, server_info->sam_account); - - sampw = server_info->sam_account; init_net_user_info3(p->mem_ctx, usr_info, - pdb_get_user_rid(sampw), - pdb_get_group_rid(sampw), + user_rid, + group_rid, pdb_get_username(sampw), pdb_get_fullname(sampw), @@ -704,8 +725,10 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * 0x20 , /* uint32 user_flgs (?) */ NULL, /* uchar sess_key[16] */ my_name , /* char *logon_srv */ - my_workgroup, /* char *logon_dom */ - &global_sam_sid, /* DOM_SID *dom_sid */ + pdb_get_domain(sampw), + &domain_sid, /* DOM_SID *dom_sid */ + /* Should be users domain sid, not servers - for trusted domains */ + NULL); /* char *other_sids */ } free_server_info(&server_info); diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 70574b4cdd..b7be415abc 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -39,6 +39,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) { unsigned char *hash = p->ntlmssp_hash; @@ -432,7 +435,7 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); /* Set up pipe user group membership. */ initialise_groups(p->pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); - get_current_groups( &p->pipe_user.ngroups, &p->pipe_user.groups); + get_current_groups(p->pipe_user.gid, &p->pipe_user.ngroups, &p->pipe_user.groups); if (server_info->ptok) add_supplementary_nt_login_groups(&p->pipe_user.ngroups, &p->pipe_user.groups, &server_info->ptok); @@ -1148,7 +1151,7 @@ BOOL api_pipe_request(pipes_struct *p) ********************************************************************/ BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, - struct api_struct *api_rpc_cmds) + const struct api_struct *api_rpc_cmds) { int fn_num; fstring name; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 44dd5fac65..cc6e4b95f9 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -22,6 +22,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + #define PIPE "\\PIPE\\" #define PIPELEN strlen(PIPE) @@ -32,6 +35,23 @@ static int pipes_open; #define MAX_OPEN_PIPES 2048 #endif +/* + * Sometimes I can't decide if I hate Windows printer driver + * writers more than I hate the Windows spooler service driver + * writers. This gets around a combination of bugs in the spooler + * and the HP 8500 PCL driver that causes a spooler spin. JRA. + * + * bumped up from 20 -> 64 after viewing traffic from WordPerfect + * 2002 running on NT 4.- SP6 + * bumped up from 64 -> 256 after viewing traffic from con2prt + * for lots of printers on a WinNT 4.x SP6 box. + */ + +#ifndef MAX_OPEN_SPOOLSS_PIPES +#define MAX_OPEN_SPOOLSS_PIPES 256 +#endif +static int current_spoolss_pipes_open; + static smb_np_struct *Pipes; static pipes_struct *InternalPipes; static struct bitmap *bmap; @@ -99,6 +119,7 @@ void set_pipe_handle_offset(int max_open_files) /**************************************************************************** Reset pipe chain handle number. ****************************************************************************/ + void reset_chain_p(void) { chain_p = NULL; @@ -155,11 +176,20 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, int i; smb_np_struct *p, *p_it; static int next_pipe; + BOOL is_spoolss_pipe = False; DEBUG(4,("Open pipe requested %s (pipes_open=%d)\n", pipe_name, pipes_open)); - + if (strstr(pipe_name, "spoolss")) + is_spoolss_pipe = True; + + if (is_spoolss_pipe && current_spoolss_pipes_open >= MAX_OPEN_SPOOLSS_PIPES) { + DEBUG(10,("open_rpc_pipe_p: spooler bug workaround. Denying open on pipe %s\n", + pipe_name )); + return NULL; + } + /* not repeating pipe numbers makes it easier to track things in log files and prevents client bugs where pipe numbers are reused over connection restarts */ @@ -180,8 +210,7 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, p = (smb_np_struct *)malloc(sizeof(*p)); - if (!p) - { + if (!p) { DEBUG(0,("ERROR! no memory for pipes_struct!\n")); return NULL; } @@ -198,13 +227,11 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, p->np_state = p->namedpipe_create(pipe_name, conn, vuid); if (p->np_state == NULL) { - DEBUG(0,("open_rpc_pipe_p: make_internal_rpc_pipe_p failed.\n")); SAFE_FREE(p); return NULL; } - DLIST_ADD(Pipes, p); /* @@ -244,7 +271,7 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, } /**************************************************************************** - * make an internal namedpipes structure + Make an internal namedpipes structure ****************************************************************************/ static void *make_internal_rpc_pipe_p(char *pipe_name, @@ -298,6 +325,10 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, DLIST_ADD(InternalPipes, p); p->conn = conn; + + /* Ensure the connection isn't idled whilst this pipe is open. */ + p->conn->num_files_open++; + p->vuid = vuid; p->ntlmssp_chal_flags = 0; @@ -313,9 +344,10 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, p->pipe_user.uid = (uid_t)-1; p->pipe_user.gid = (gid_t)-1; - /* Store the session key */ + /* Store the session key and NT_TOKEN */ if (vuser) { memcpy(p->session_key, vuser->session_key, sizeof(p->session_key)); + p->pipe_user.nt_user_token = dup_nt_token(vuser->nt_user_token); } /* @@ -1055,7 +1087,7 @@ BOOL close_rpc_pipe_hnd(smb_np_struct *p) ZERO_STRUCTP(p); SAFE_FREE(p); - + return True; } @@ -1085,6 +1117,8 @@ static BOOL close_internal_rpc_pipe_hnd(void *np_conn) DLIST_REMOVE(InternalPipes, p); + p->conn->num_files_open--; + ZERO_STRUCTP(p); SAFE_FREE(p); diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 569f3fb8b1..a096325860 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -1,11 +1,12 @@ -/* +/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. - * Copyright (C) Marc Jacobsen 2000. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Marc Jacobsen 2000. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Gerald Carter 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,6 +27,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /******************************************************************* api_reg_close ********************************************************************/ @@ -53,10 +57,10 @@ static BOOL api_reg_close(pipes_struct *p) } /******************************************************************* - api_reg_open + api_reg_open_khlm ********************************************************************/ -static BOOL api_reg_open(pipes_struct *p) +static BOOL api_reg_open_hklm(pipes_struct *p) { REG_Q_OPEN_HKLM q_u; REG_R_OPEN_HKLM r_u; @@ -70,7 +74,7 @@ static BOOL api_reg_open(pipes_struct *p) if(!reg_io_q_open_hklm("", &q_u, data, 0)) return False; - r_u.status = _reg_open(p, &q_u, &r_u); + r_u.status = _reg_open_hklm(p, &q_u, &r_u); if(!reg_io_r_open_hklm("", &r_u, rdata, 0)) return False; @@ -78,6 +82,33 @@ static BOOL api_reg_open(pipes_struct *p) return True; } +/******************************************************************* + api_reg_open_khlm + ********************************************************************/ + +static BOOL api_reg_open_hku(pipes_struct *p) +{ + REG_Q_OPEN_HKU q_u; + REG_R_OPEN_HKU r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the reg open */ + if(!reg_io_q_open_hku("", &q_u, data, 0)) + return False; + + r_u.status = _reg_open_hku(p, &q_u, &r_u); + + if(!reg_io_r_open_hku("", &r_u, rdata, 0)) + return False; + + return True; +} + + /******************************************************************* api_reg_open_entry ********************************************************************/ @@ -184,18 +215,99 @@ static BOOL api_reg_abort_shutdown(pipes_struct *p) } +/******************************************************************* + api_reg_query_key + ********************************************************************/ + +static BOOL api_reg_query_key(pipes_struct *p) +{ + REG_Q_QUERY_KEY q_u; + REG_R_QUERY_KEY r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_query_key("", &q_u, data, 0)) + return False; + + r_u.status = _reg_query_key(p, &q_u, &r_u); + + if(!reg_io_r_query_key("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + api_reg_unknown_1a + ********************************************************************/ + +static BOOL api_reg_unknown_1a(pipes_struct *p) +{ + REG_Q_UNKNOWN_1A q_u; + REG_R_UNKNOWN_1A r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_unknown_1a("", &q_u, data, 0)) + return False; + + r_u.status = _reg_unknown_1a(p, &q_u, &r_u); + + if(!reg_io_r_unknown_1a("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + api_reg_enum_key + ********************************************************************/ + +static BOOL api_reg_enum_key(pipes_struct *p) +{ + REG_Q_ENUM_KEY q_u; + REG_R_ENUM_KEY r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_enum_key("", &q_u, data, 0)) + return False; + + r_u.status = _reg_enum_key(p, &q_u, &r_u); + + if(!reg_io_r_enum_key("", &r_u, rdata, 0)) + return False; + + return True; +} + + + /******************************************************************* array of \PIPE\reg operations ********************************************************************/ static struct api_struct api_reg_cmds[] = { - { "REG_CLOSE" , REG_CLOSE , api_reg_close }, - { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, - { "REG_OPEN" , REG_OPEN_HKLM , api_reg_open }, - { "REG_INFO" , REG_INFO , api_reg_info }, - { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, - { "REG_ABORT_SHUTDOWN", REG_ABORT_SHUTDOWN, api_reg_abort_shutdown }, - { NULL, 0 , NULL } + { "REG_CLOSE" , REG_CLOSE , api_reg_close }, + { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, + { "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm }, + { "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku }, + { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key }, + { "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key }, + { "REG_INFO" , REG_INFO , api_reg_info }, + { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, + { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, + { "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a }, + { NULL , 0 , NULL } }; /******************************************************************* diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index adedd4a8fa..3f07e4aaea 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -5,7 +5,8 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. * Copyright (C) Hewlett-Packard Company 1999. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Gerald Carter 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,20 +27,479 @@ #include "includes.h" -struct reg_info { - /* for use by \PIPE\winreg */ +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +#define KEY_HKLM "HKLM" +#define KEY_HKU "HKU" + +#define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ +((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) + +/* structure to store the registry handles */ + +typedef struct _RegistryKey { + struct _RegistryKey *prev, *next; + fstring name; /* name of registry key */ -}; + POLICY_HND hnd; + +} Registry_Key; + +static Registry_Key *regkeys_list; +static TDB_CONTEXT *tdb_reg; + +/*********************************************************************** + Add subkey strings to the registry tdb under a defined key + fmt is the same format as tdb_pack except this function only supports + fstrings + ***********************************************************************/ + +static BOOL store_reg_keys( TDB_CONTEXT *tdb, char *keyname, char **subkeys, uint32 num_subkeys ) +{ + TDB_DATA kbuf, dbuf; + char *buffer, *tmpbuf; + int i = 0; + uint32 len, buflen; + BOOL ret = True; + + if ( !keyname ) + return False; + + /* allocate some initial memory */ + + buffer = malloc(sizeof(pstring)); + buflen = sizeof(pstring); + len = 0; + + /* store the number of subkeys */ + + len += tdb_pack(buffer+len, buflen-len, "d", num_subkeys); + + /* pack all the strings */ + + for (i=0; i buflen ) { + /* allocate some extra space */ + if ((tmpbuf = Realloc( buffer, len*2 )) == NULL) { + DEBUG(0,("store_reg_keys: Failed to realloc memory of size [%d]\n", len*2)); + ret = False; + goto done; + } + buffer = tmpbuf; + buflen = len*2; + + len = tdb_pack(buffer+len, buflen-len, "f", subkeys[i]); + } + } + + /* finally write out the data */ + + kbuf.dptr = keyname; + kbuf.dsize = strlen(keyname)+1; + dbuf.dptr = buffer; + dbuf.dsize = len; + if ( tdb_store( tdb, kbuf, dbuf, TDB_REPLACE ) == -1) { + ret = False; + goto done; + } + +done: + SAFE_FREE( buffer ); + return ret; +} + +/*********************************************************************** + Retrieve an array of strings containing subkeys. Memory should be + released by the caller. The subkeys are stored in a catenated string + of null terminated character strings + ***********************************************************************/ + +static int fetch_reg_keys( TDB_CONTEXT *tdb, char* key, char **subkeys ) +{ + pstring path; + uint32 num_items; + TDB_DATA dbuf; + char *buf; + uint32 buflen, len; + int i; + char *s; + + + pstrcpy( path, key ); + + /* convert to key format */ + pstring_sub( path, "\\", "/" ); + + dbuf = tdb_fetch_by_string( tdb, path ); + + buf = dbuf.dptr; + buflen = dbuf.dsize; + + if ( !buf ) { + DEBUG(5,("fetch_reg_keys: Failed to fetch any subkeys for [%s]\n", key)); + return 0; + } + + len = tdb_unpack( buf, buflen, "d", &num_items); + if (num_items) { + if ( (*subkeys = (char*)malloc(sizeof(fstring)*num_items)) == NULL ) { + DEBUG(0,("fetch_reg_keys: Failed to malloc memory for subkey array containing [%d] items!\n", + num_items)); + num_items = -1; + goto done; + } + } + + s = *subkeys; + for (i=0; iname, name ); + + DEBUG(7,("open_registry_key: exit\n")); + + return create_policy_hnd( p, hnd, free_reg_info, regkey ); +} + +/******************************************************************* + Function for open a new registry handle and creating a handle + Note that P should be valid & hnd should already have space + *******************************************************************/ + +static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd) +{ + Registry_Key *regkey = find_regkey_index_by_hnd(p, hnd); + + if ( !regkey ) { + DEBUG(2,("close_registry_key: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(hnd))); + return False; + } + + close_policy_hnd(p, hnd); + + return True; +} + +/******************************************************************** + retrieve information about the subkeys + *******************************************************************/ + +static BOOL get_subkey_information( Registry_Key *key, uint32 *maxnum, uint32 *maxlen ) +{ + int num_subkeys, i; + uint32 max_len; + char *subkeys = NULL; + uint32 len; + char *s; + + if ( !key ) + return False; + + num_subkeys = fetch_reg_keys( tdb_reg, key->name, &subkeys ); + if ( num_subkeys == -1 ) + return False; + + /* find the longest string */ + + max_len = 0; + s = subkeys; + for ( i=0; ipol); /* close the policy handle */ - if (!close_policy_hnd(p, &q_u->pol)) + if (!close_registry_key(p, &q_u->pol)) return NT_STATUS_OBJECT_NAME_INVALID; return NT_STATUS_OK; @@ -58,9 +518,21 @@ NTSTATUS _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) reg_reply_open ********************************************************************/ -NTSTATUS _reg_open(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u) +NTSTATUS _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u) +{ + if (!open_registry_key(p, &r_u->pol, KEY_HKLM, 0x0)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + return NT_STATUS_OK; +} + +/******************************************************************* + reg_reply_open + ********************************************************************/ + +NTSTATUS _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HKU *q_u, REG_R_OPEN_HKU *r_u) { - if (!create_policy_hnd(p, &r_u->pol, free_reg_info, NULL)) + if (!open_registry_key(p, &r_u->pol, KEY_HKU, 0x0)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; return NT_STATUS_OK; @@ -74,34 +546,36 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR { POLICY_HND pol; fstring name; - struct reg_info *info = NULL; + pstring path; + int num_subkeys; + Registry_Key *key = find_regkey_index_by_hnd(p, &q_u->pol); - DEBUG(5,("reg_open_entry: %d\n", __LINE__)); + DEBUG(5,("reg_open_entry: Enter\n")); - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if ( !key ) return NT_STATUS_INVALID_HANDLE; rpcstr_pull(name,q_u->uni_name.buffer,sizeof(name),q_u->uni_name.uni_str_len*2,0); - DEBUG(5,("reg_open_entry: %s\n", name)); - - /* lkcl XXXX do a check on the name, here */ - if (!strequal(name, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions") && - !strequal(name, "System\\CurrentControlSet\\services\\Netlogon\\parameters\\")) - return NT_STATUS_ACCESS_DENIED; + /* store the full path in the regkey_list */ + + pstrcpy( path, key->name ); + pstrcat( path, "\\" ); + pstrcat( path, name ); - if ((info = (struct reg_info *)malloc(sizeof(struct reg_info))) == NULL) - return NT_STATUS_NO_MEMORY; + DEBUG(5,("reg_open_entry: %s\n", path)); - ZERO_STRUCTP(info); - fstrcpy(info->name, name); + /* do a check on the name, here */ + + if ( (num_subkeys=fetch_reg_keys_count( tdb_reg, path )) == -1 ) + return NT_STATUS_ACCESS_DENIED; - if (!create_policy_hnd(p, &pol, free_reg_info, (void *)info)) - return NT_STATUS_TOO_MANY_SECRETS; /* ha ha very droll */ + if (!open_registry_key(p, &pol, path, 0x0)) + return NT_STATUS_TOO_MANY_SECRETS; init_reg_r_open_entry(r_u, &pol, NT_STATUS_OK); - DEBUG(5,("reg_open_entry: %d\n", __LINE__)); + DEBUG(5,("reg_open_entry: Exitn")); return r_u->status; } @@ -113,21 +587,23 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) { NTSTATUS status = NT_STATUS_OK; - char *key = NULL; - uint32 type=0x1; /* key type: REG_SZ */ - + char *value = NULL; + uint32 type = 0x1; /* key type: REG_SZ */ UNISTR2 *uni_key = NULL; BUFFER2 *buf = NULL; fstring name; + Registry_Key *key = find_regkey_index_by_hnd( p, &q_u->pol ); - DEBUG(5,("_reg_info: %d\n", __LINE__)); + DEBUG(5,("_reg_info: Enter\n")); - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if ( !key ) return NT_STATUS_INVALID_HANDLE; + + DEBUG(7,("_reg_info: policy key name = [%s]\n", key->name)); rpcstr_pull(name, q_u->uni_type.buffer, sizeof(name), q_u->uni_type.uni_str_len*2, 0); - DEBUG(5,("reg_info: checking key: %s\n", name)); + DEBUG(5,("reg_info: checking subkey: %s\n", name)); uni_key = (UNISTR2 *)talloc_zero(p->mem_ctx, sizeof(UNISTR2)); buf = (BUFFER2 *)talloc_zero(p->mem_ctx, sizeof(BUFFER2)); @@ -147,33 +623,126 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) } switch (lp_server_role()) { - case ROLE_DOMAIN_PDC: - case ROLE_DOMAIN_BDC: - key = "LanmanNT"; - break; - case ROLE_STANDALONE: - key = "ServerNT"; - break; - case ROLE_DOMAIN_MEMBER: - key = "WinNT"; - break; + case ROLE_DOMAIN_PDC: + case ROLE_DOMAIN_BDC: + value = "LanmanNT"; + break; + case ROLE_STANDALONE: + value = "ServerNT"; + break; + case ROLE_DOMAIN_MEMBER: + value = "WinNT"; + break; } /* This makes the server look like a member server to clients */ /* which tells clients that we have our own local user and */ /* group databases and helps with ACL support. */ - init_unistr2(uni_key, key, strlen(key)+1); + init_unistr2(uni_key, value, strlen(value)+1); init_buffer2(buf, (uint8*)uni_key->buffer, uni_key->uni_str_len*2); out: init_reg_r_info(q_u->ptr_buf, r_u, buf, type, status); - DEBUG(5,("reg_open_entry: %d\n", __LINE__)); + DEBUG(5,("reg_open_entry: Exit\n")); + + return status; +} + + +/***************************************************************************** + Implementation of REG_QUERY_KEY + ****************************************************************************/ + +NTSTATUS _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_u) +{ + NTSTATUS status = NT_STATUS_OK; + Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + + DEBUG(5,("_reg_query_key: Enter\n")); + + if ( !regkey ) + return NT_STATUS_INVALID_HANDLE; + + if ( !get_subkey_information( regkey, &r_u->num_subkeys, &r_u->max_subkeylen ) ) + return NT_STATUS_ACCESS_DENIED; + + if ( !get_value_information( regkey, &r_u->num_values, &r_u->max_valnamelen, &r_u->max_valbufsize ) ) + return NT_STATUS_ACCESS_DENIED; + + r_u->sec_desc = 0x00000078; /* size for key's sec_desc */ + + /* Win9x set this to 0x0 since it does not keep timestamps. + Doing the same here for simplicity --jerry */ + + ZERO_STRUCT(r_u->mod_time); + + DEBUG(5,("_reg_query_key: Exit\n")); + + return status; +} + + +/***************************************************************************** + Implementation of REG_UNKNOWN_1A + ****************************************************************************/ + +NTSTATUS _reg_unknown_1a(pipes_struct *p, REG_Q_UNKNOWN_1A *q_u, REG_R_UNKNOWN_1A *r_u) +{ + NTSTATUS status = NT_STATUS_OK; + Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + + DEBUG(5,("_reg_unknown_1a: Enter\n")); + + if ( !regkey ) + return NT_STATUS_INVALID_HANDLE; + + r_u->unknown = 0x00000005; /* seems to be consistent...no idea what it means */ + + DEBUG(5,("_reg_unknown_1a: Exit\n")); + + return status; +} + +/***************************************************************************** + Implementation of REG_ENUM_KEY + ****************************************************************************/ + +NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u) +{ + NTSTATUS status = NT_STATUS_OK; + Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + fstring subkey; + + + DEBUG(5,("_reg_enum_key: Enter\n")); + + if ( !regkey ) + return NT_STATUS_INVALID_HANDLE; + + DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", regkey->name)); + + if ( !fetch_reg_keys_specific( tdb_reg, regkey->name, subkey, q_u->key_index ) ) + { + status = werror_to_ntstatus( WERR_NO_MORE_ITEMS ); + goto done; + } + + DEBUG(10,("_reg_enum_key: retrieved subkey named [%s]\n", subkey)); + + /* subkey has the string name now */ + + init_reg_r_enum_key( r_u, subkey, q_u->unknown_1, q_u->unknown_2 ); + + DEBUG(5,("_reg_enum_key: Exit\n")); + +done: return status; } + /******************************************************************* reg_shutdwon ********************************************************************/ @@ -219,6 +788,10 @@ NTSTATUS _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u return status; } +/******************************************************************* + reg_abort_shutdwon + ********************************************************************/ + NTSTATUS _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABORT_SHUTDOWN *r_u) { NTSTATUS status = NT_STATUS_OK; @@ -234,3 +807,5 @@ NTSTATUS _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_A return status; } + + diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index c555305bce..f002a7d1c9 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -32,6 +32,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /******************************************************************* api_samr_close_hnd ********************************************************************/ @@ -123,6 +126,37 @@ static BOOL api_samr_get_usrdom_pwinfo(pipes_struct *p) return True; } +/******************************************************************* + api_samr_set_sec_obj + ********************************************************************/ + +static BOOL api_samr_set_sec_obj(pipes_struct *p) +{ + SAMR_Q_SET_SEC_OBJ q_u; + SAMR_R_SET_SEC_OBJ r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!samr_io_q_set_sec_obj("", &q_u, data, 0)) { + DEBUG(0,("api_samr_set_sec_obj: unable to unmarshall SAMR_Q_SET_SEC_OBJ.\n")); + return False; + } + + r_u.status = _samr_set_sec_obj(p, &q_u, &r_u); + + if(!samr_io_r_set_sec_obj("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_set_sec_obj: unable to marshall SAMR_R_SET_SEC_OBJ.\n")); + return False; + } + + + return True; +} + /******************************************************************* api_samr_query_sec_obj ********************************************************************/ @@ -1427,6 +1461,7 @@ static struct api_struct api_samr_cmds [] = {"SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, {"SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, + {"SAMR_SET_SEC_OBJECT" , SAMR_SET_SEC_OBJECT , api_samr_set_sec_obj }, {"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, {"SAMR_UNKNOWN_2E" , SAMR_UNKNOWN_2E , api_samr_unknown_2e }, {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 106d7c1923..88d728d810 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -29,9 +29,11 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + extern fstring global_myworkgroup; extern pstring global_myname; -extern DOM_SID global_sam_sid; extern DOM_SID global_sid_Builtin; extern rid_name domain_group_rids[]; @@ -52,9 +54,69 @@ struct samr_info { /* for use by the \PIPE\samr policy */ DOM_SID sid; uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ + uint32 acc_granted; DISP_INFO disp_info; + + TALLOC_CTX *mem_ctx; }; +struct generic_mapping sam_generic_mapping = {SAMR_READ, SAMR_WRITE, SAMR_EXECUTE, SAMR_ALL_ACCESS}; +struct generic_mapping dom_generic_mapping = {DOMAIN_READ, DOMAIN_WRITE, DOMAIN_EXECUTE, DOMAIN_ALL_ACCESS}; +struct generic_mapping usr_generic_mapping = {USER_READ, USER_WRITE, USER_EXECUTE, USER_ALL_ACCESS}; +struct generic_mapping grp_generic_mapping = {GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, GROUP_ALL_ACCESS}; +struct generic_mapping ali_generic_mapping = {ALIAS_READ, ALIAS_WRITE, ALIAS_EXECUTE, ALIAS_ALL_ACCESS}; + +static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *d_size); + + +/******************************************************************* + Checks if access to an object should be granted, and returns that + level of access for further checks. +********************************************************************/ + +NTSTATUS access_check_samr_object(SEC_DESC *psd, NT_USER_TOKEN *nt_user_token, uint32 des_access, + uint32 *acc_granted, const char *debug) +{ + NTSTATUS status = NT_STATUS_ACCESS_DENIED; + + if (!se_access_check(psd, nt_user_token, des_access, acc_granted, &status)) { + if (geteuid() == sec_initial_uid()) { + DEBUG(4,("%s: ACCESS should be DENIED (requested: %#010x)\n", + debug, des_access)); + DEBUGADD(4,("but overritten by euid == sec_initial_uid()\n")); + status = NT_STATUS_OK; + } + else { + DEBUG(2,("%s: ACCESS DENIED (requested: %#010x)\n", + debug, des_access)); + } + } + return status; +} + +/******************************************************************* + Checks if access to a function can be granted +********************************************************************/ + +NTSTATUS access_check_samr_function(uint32 acc_granted, uint32 acc_required, const char *debug) +{ + DEBUG(5,("%s: access check ((granted: %#010x; required: %#010x)\n", + debug, acc_granted, acc_required)); + if ((acc_granted & acc_required) != acc_required) { + if (geteuid() == sec_initial_uid()) { + DEBUG(4,("%s: ACCESS should be DENIED (granted: %#010x; required: %#010x)\n", + debug, acc_granted, acc_required)); + DEBUGADD(4,("but overwritten by euid == 0\n")); + return NT_STATUS_OK; + } + DEBUG(2,("%s: ACCESS DENIED (granted: %#010x; required: %#010x)\n", + debug, acc_granted, acc_required)); + return NT_STATUS_ACCESS_DENIED; + } + return NT_STATUS_OK; +} + + /******************************************************************* Create a samr_info struct. ********************************************************************/ @@ -63,17 +125,27 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) { struct samr_info *info; fstring sid_str; + TALLOC_CTX *mem_ctx; + + if (psid) { + sid_to_string(sid_str, psid); + } else { + fstrcpy(sid_str,"(NULL)"); + } + + mem_ctx = talloc_init_named("samr_info for domain sid %s", sid_str); - if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL) + if ((info = (struct samr_info *)talloc(mem_ctx, sizeof(struct samr_info))) == NULL) return NULL; ZERO_STRUCTP(info); + DEBUG(10,("get_samr_info_by_sid: created new info for sid %s\n", sid_str)); if (psid) { - DEBUG(10,("get_samr_info_by_sid: created new info for sid %s\n", sid_to_string(sid_str, psid) )); sid_copy( &info->sid, psid); } else { DEBUG(10,("get_samr_info_by_sid: created new info for NULL sid.\n")); } + info->mem_ctx = mem_ctx; return info; } @@ -84,18 +156,13 @@ static void free_samr_db(struct samr_info *info) { int i; - if (info->disp_info.group_dbloaded) { - for (i=0; idisp_info.num_group_account; i++) - SAFE_FREE(info->disp_info.disp_group_info[i].grp); - - SAFE_FREE(info->disp_info.disp_group_info); - } + /* Groups are talloced */ if (info->disp_info.user_dbloaded){ - for (i=0; idisp_info.num_user_account; i++) + for (i=0; idisp_info.num_user_account; i++) { + /* Not really a free, actually a 'clear' */ pdb_free_sam(&info->disp_info.disp_user_info[i].sam); - - SAFE_FREE(info->disp_info.disp_user_info); + } } info->disp_info.user_dbloaded=False; @@ -110,26 +177,13 @@ static void free_samr_info(void *ptr) struct samr_info *info=(struct samr_info *) ptr; free_samr_db(info); - SAFE_FREE(info); + talloc_destroy(info->mem_ctx); } /******************************************************************* Ensure password info is never given out. Paranioa... JRA. ********************************************************************/ -static void samr_clear_passwd_fields( SAM_USER_INFO_21 *pass, int num_entries) -{ - int i; - - if (!pass) - return; - - for (i = 0; i < num_entries; i++) { - memset(&pass[i].lm_pwd, '\0', sizeof(pass[i].lm_pwd)); - memset(&pass[i].nt_pwd, '\0', sizeof(pass[i].nt_pwd)); - } -} - static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) { @@ -147,6 +201,8 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) { SAM_ACCOUNT *pwd = NULL; DISP_USER_INFO *pwd_array = NULL; + NTSTATUS nt_status = NT_STATUS_OK; + TALLOC_CTX *mem_ctx = info->mem_ctx; DEBUG(10,("load_sampwd_entries\n")); @@ -161,7 +217,8 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) return NT_STATUS_ACCESS_DENIED; } - for (pdb_init_sam(&pwd); pdb_getsampwent(pwd) == True; pwd=NULL, pdb_init_sam(&pwd) ) { + for (; (NT_STATUS_IS_OK(nt_status = pdb_init_sam_talloc(mem_ctx, &pwd))) + && pdb_getsampwent(pwd) == True; pwd=NULL) { if (acb_mask != 0 && !(pdb_get_acct_ctrl(pwd) & acb_mask)) { pdb_free_sam(&pwd); @@ -173,7 +230,7 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) if (info->disp_info.num_user_account % MAX_SAM_ENTRIES == 0) { DEBUG(10,("load_sampwd_entries: allocating more memory\n")); - pwd_array=(DISP_USER_INFO *)Realloc(info->disp_info.disp_user_info, + pwd_array=(DISP_USER_INFO *)talloc_realloc(mem_ctx, info->disp_info.disp_user_info, (info->disp_info.num_user_account+MAX_SAM_ENTRIES)*sizeof(DISP_USER_INFO)); if (pwd_array==NULL) @@ -198,7 +255,7 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) DEBUG(12,("load_sampwd_entries: done\n")); - return NT_STATUS_OK; + return nt_status; } static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) @@ -207,6 +264,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) DISP_GROUP_INFO *grp_array = NULL; uint32 group_entries = 0; uint32 i; + TALLOC_CTX *mem_ctx = info->mem_ctx; DEBUG(10,("load_group_domain_entries\n")); @@ -216,11 +274,13 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) return NT_STATUS_OK; } - enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); + if (!enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) { + return NT_STATUS_NO_MEMORY; + } info->disp_info.num_group_account=group_entries; - grp_array=(DISP_GROUP_INFO *)malloc(info->disp_info.num_group_account*sizeof(DISP_GROUP_INFO)); + grp_array=(DISP_GROUP_INFO *)talloc(mem_ctx, info->disp_info.num_group_account*sizeof(DISP_GROUP_INFO)); if (group_entries!=0 && grp_array==NULL) { SAFE_FREE(map); @@ -231,7 +291,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) for (i=0; iname, map[i].nt_name); fstrcpy(grp_array[i].grp->comment, map[i].comment); @@ -251,84 +311,6 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) } -/******************************************************************* - This next function should be replaced with something that - dynamically returns the correct user info..... JRA. - ********************************************************************/ - -static NTSTATUS 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) -{ - SAM_ACCOUNT *pwd = NULL; - BOOL not_finished = True; - - (*num_entries) = 0; - (*total_entries) = 0; - - if (pw_buf == NULL) - return NT_STATUS_NO_MEMORY; - - pdb_init_sam(&pwd); - - 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) { - - pdb_reset_sam(pwd); - - /* skip the requested number of entries. - not very efficient, but hey... */ - start_idx--; - continue; - } - - 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 = 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 (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); - - 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 || (pdb_get_acct_ctrl(pwd) & 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)++; - - pdb_reset_sam(pwd); - - } - - pdb_endsampwent(); - pdb_free_sam(&pwd); - - if (not_finished) - return STATUS_MORE_ENTRIES; - else - return NT_STATUS_OK; -} - /******************************************************************* _samr_close_hnd ********************************************************************/ @@ -352,17 +334,37 @@ NTSTATUS _samr_close_hnd(pipes_struct *p, SAMR_Q_CLOSE_HND *q_u, SAMR_R_CLOSE_HN NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN_DOMAIN *r_u) { - struct samr_info *info; + struct samr_info *info; + SEC_DESC *psd = NULL; + uint32 acc_granted; + uint32 des_access = q_u->flags; + size_t sd_size; + NTSTATUS status; r_u->status = NT_STATUS_OK; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->pol, (void**)&info)) return NT_STATUS_INVALID_HANDLE; + if (!NT_STATUS_IS_OK(status = access_check_samr_function(info->acc_granted, SAMR_ACCESS_OPEN_DOMAIN,"_samr_open_domain"))) { + return status; + } + + /*check if access can be granted as requested by client. */ + samr_make_dom_obj_sd(p->mem_ctx, &psd, &sd_size); + se_map_generic(&des_access,&dom_generic_mapping); + + if (!NT_STATUS_IS_OK(status = + access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_open_domain"))) { + return status; + } + /* associate the domain SID with the (unique) handle. */ if ((info = get_samr_info_by_sid(&q_u->dom_sid.sid))==NULL) return NT_STATUS_NO_MEMORY; + info->acc_granted = acc_granted; /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, &r_u->domain_pol, free_samr_info, (void *)info)) @@ -402,11 +404,90 @@ NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, return r_u->status; } + +/******************************************************************* + samr_make_sam_obj_sd + ********************************************************************/ + +static NTSTATUS samr_make_sam_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +{ + extern DOM_SID global_sid_World; + DOM_SID adm_sid; + DOM_SID act_sid; + + SEC_ACE ace[3]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + sid_copy(&act_sid, &global_sid_Builtin); + sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + + /*basic access for every one*/ + init_sec_access(&mask, SAMR_EXECUTE | SAMR_READ); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, SAMR_ALL_ACCESS); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + return NT_STATUS_OK; +} + +/******************************************************************* + samr_make_dom_obj_sd + ********************************************************************/ + +static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +{ + extern DOM_SID global_sid_World; + DOM_SID adm_sid; + DOM_SID act_sid; + + SEC_ACE ace[3]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + sid_copy(&act_sid, &global_sid_Builtin); + sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + + /*basic access for every one*/ + init_sec_access(&mask, DOMAIN_EXECUTE | DOMAIN_READ); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, DOMAIN_ALL_ACCESS); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + return NT_STATUS_OK; +} + /******************************************************************* samr_make_usr_obj_sd ********************************************************************/ -static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC_BUF **buf, DOM_SID *usr_sid) +static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size, DOM_SID *usr_sid) { extern DOM_SID global_sid_World; DOM_SID adm_sid; @@ -416,8 +497,6 @@ static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC_BUF **buf, DOM_SI SEC_ACCESS mask; SEC_ACL *psa = NULL; - SEC_DESC *psd = NULL; - size_t sd_size; sid_copy(&adm_sid, &global_sid_Builtin); sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); @@ -425,29 +504,107 @@ static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC_BUF **buf, DOM_SI sid_copy(&act_sid, &global_sid_Builtin); sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); - init_sec_access(&mask, 0x2035b); + /*basic access for every one*/ + init_sec_access(&mask, USER_EXECUTE | USER_READ); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_access(&mask, 0xf07ff); + /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, USER_ALL_ACCESS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_access(&mask,0x20044); + /*extended access for the user*/ + init_sec_access(&mask,READ_CONTROL_ACCESS | USER_ACCESS_CHANGE_PASSWORD | USER_ACCESS_SET_LOC_COM); init_sec_ace(&ace[3], usr_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - if((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 4, ace)) == NULL) + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 4, ace)) == NULL) return NT_STATUS_NO_MEMORY; - if((psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, &sd_size)) == NULL) + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) return NT_STATUS_NO_MEMORY; - if((*buf = make_sec_desc_buf(ctx, sd_size, psd)) == NULL) + return NT_STATUS_OK; +} + +/******************************************************************* + samr_make_grp_obj_sd + ********************************************************************/ + +static NTSTATUS samr_make_grp_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +{ + extern DOM_SID global_sid_World; + DOM_SID adm_sid; + DOM_SID act_sid; + + SEC_ACE ace[3]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + sid_copy(&act_sid, &global_sid_Builtin); + sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + + /*basic access for every one*/ + init_sec_access(&mask, GROUP_EXECUTE | GROUP_READ); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, GROUP_ALL_ACCESS); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) return NT_STATUS_NO_MEMORY; return NT_STATUS_OK; } -static BOOL get_lsa_policy_samr_sid(pipes_struct *p, POLICY_HND *pol, DOM_SID *sid) +/******************************************************************* + samr_make_ali_obj_sd + ********************************************************************/ + +static NTSTATUS samr_make_ali_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +{ + extern DOM_SID global_sid_World; + DOM_SID adm_sid; + DOM_SID act_sid; + + SEC_ACE ace[3]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + sid_copy(&act_sid, &global_sid_Builtin); + sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + + /*basic access for every one*/ + init_sec_access(&mask, ALIAS_EXECUTE | ALIAS_READ); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, ALIAS_ALL_ACCESS); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + return NT_STATUS_OK; +} + +static BOOL get_lsa_policy_samr_sid(pipes_struct *p, POLICY_HND *pol, DOM_SID *sid, uint32 *acc_granted) { struct samr_info *info = NULL; @@ -459,9 +616,21 @@ static BOOL get_lsa_policy_samr_sid(pipes_struct *p, POLICY_HND *pol, DOM_SID *s return False; *sid = info->sid; + *acc_granted = info->acc_granted; return True; } +/******************************************************************* + _samr_set_sec_obj + ********************************************************************/ + +NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_SEC_OBJ *r_u) +{ + DEBUG(0,("_samr_set_sec_obj: Not yet implemented!\n")); + return NT_STATUS_NOT_IMPLEMENTED; +} + + /******************************************************************* _samr_query_sec_obj ********************************************************************/ @@ -470,17 +639,52 @@ NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_ { DOM_SID pol_sid; fstring str_sid; + SEC_DESC * psd = NULL; + size_t sd_size; + uint32 acc_granted; r_u->status = NT_STATUS_OK; /* Get the SID. */ - - if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &pol_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &pol_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + DEBUG(10,("_samr_query_sec_obj: querying security on SID: %s\n", sid_to_string(str_sid, &pol_sid))); - r_u->status = samr_make_usr_obj_sd(p->mem_ctx, &r_u->buf, &pol_sid); + /* Check what typ of SID is beeing queried (e.g Domain SID, User SID, Group SID) */ + + /* To query the security of the SAM it self an invalid SID with S-0-0 is passed to this function */ + if (pol_sid.sid_rev_num == 0) + { + DEBUG(5,("_samr_query_sec_obj: querying security on SAM\n")); + r_u->status = samr_make_sam_obj_sd(p->mem_ctx, &psd, &sd_size); + } + else if (sid_equal(&pol_sid,get_global_sam_sid())) /* check if it is our domain SID */ + + { + DEBUG(5,("_samr_query_sec_obj: querying security on Domain with SID: %s\n", sid_to_string(str_sid, &pol_sid))); + r_u->status = samr_make_dom_obj_sd(p->mem_ctx, &psd, &sd_size); + } + else if (sid_equal(&pol_sid,&global_sid_Builtin)) /* check if it is the Builtin Domain */ + { + /* TODO: Builtin probably needs a different SD with restricted write access*/ + DEBUG(5,("_samr_query_sec_obj: querying security on Builtin Domain with SID: %s\n", sid_to_string(str_sid, &pol_sid))); + r_u->status = samr_make_dom_obj_sd(p->mem_ctx, &psd, &sd_size); + } + else if (sid_check_is_in_our_domain(&pol_sid) || + sid_check_is_in_builtin(&pol_sid)) + { + /* TODO: different SDs have to be generated for aliases groups and users. + Currently all three get a default user SD */ + DEBUG(10,("_samr_query_sec_obj: querying security on Object with SID: %s\n", sid_to_string(str_sid, &pol_sid))); + r_u->status = samr_make_usr_obj_sd(p->mem_ctx, &psd,&sd_size, &pol_sid); + } + else return NT_STATUS_OBJECT_TYPE_MISMATCH; + + if ((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL) + return NT_STATUS_NO_MEMORY; if (NT_STATUS_IS_OK(r_u->status)) r_u->ptr = 1; @@ -492,69 +696,123 @@ NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_ makes a SAM_ENTRY / UNISTR2* structure from a user list. ********************************************************************/ -static void make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNISTR2 **uni_name_pp, - uint32 num_sam_entries, SAM_USER_INFO_21 *pass) +static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNISTR2 **uni_name_pp, + uint32 num_entries, uint32 start_idx, DISP_USER_INFO *disp_user_info, + DOM_SID *domain_sid) { uint32 i; SAM_ENTRY *sam; UNISTR2 *uni_name; - + SAM_ACCOUNT *pwd = NULL; + UNISTR2 uni_temp_name; + const char *temp_name; + const DOM_SID *user_sid; + uint32 user_rid; + fstring user_sid_string; + fstring domain_sid_string; + *sam_pp = NULL; *uni_name_pp = NULL; - if (num_sam_entries == 0) - return; + if (num_entries == 0) + return NT_STATUS_OK; - sam = (SAM_ENTRY *)talloc_zero(ctx, sizeof(SAM_ENTRY)*num_sam_entries); + sam = (SAM_ENTRY *)talloc_zero(ctx, sizeof(SAM_ENTRY)*num_entries); - uni_name = (UNISTR2 *)talloc_zero(ctx, sizeof(UNISTR2)*num_sam_entries); + uni_name = (UNISTR2 *)talloc_zero(ctx, sizeof(UNISTR2)*num_entries); if (sam == NULL || uni_name == NULL) { - DEBUG(0, ("NULL pointers in SAMR_R_QUERY_DISPINFO\n")); - return; + DEBUG(0, ("make_user_sam_entry_list: talloc_zero failed!\n")); + return NT_STATUS_NO_MEMORY; } - ZERO_STRUCTP(sam); - ZERO_STRUCTP(uni_name); - - for (i = 0; i < num_sam_entries; i++) { - int len = pass[i].uni_user_name.uni_str_len; + for (i = 0; i < num_entries; i++) { + int len = uni_temp_name.uni_str_len; + + pwd = disp_user_info[i+start_idx].sam; + temp_name = pdb_get_username(pwd); + init_unistr2(&uni_temp_name, temp_name, strlen(temp_name)+1); + user_sid = pdb_get_user_sid(pwd); + + if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { + DEBUG(0, ("make_user_sam_entry_list: User %s has SID %s, which conflicts with " + "the domain sid %s. Failing operation.\n", + temp_name, + sid_to_string(user_sid_string, user_sid), + sid_to_string(domain_sid_string, domain_sid))); + return NT_STATUS_UNSUCCESSFUL; + } - init_sam_entry(&sam[i], len, pass[i].user_rid); - copy_unistr2(&uni_name[i], &pass[i].uni_user_name); + init_sam_entry(&sam[i], len, user_rid); + copy_unistr2(&uni_name[i], &uni_temp_name); } *sam_pp = sam; *uni_name_pp = uni_name; + return NT_STATUS_OK; } /******************************************************************* samr_reply_enum_dom_users ********************************************************************/ -NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_R_ENUM_DOM_USERS *r_u) +NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, + SAMR_R_ENUM_DOM_USERS *r_u) { - SAM_USER_INFO_21 pass[MAX_SAM_ENTRIES]; - int num_entries = 0; - int total_entries = 0; + struct samr_info *info = NULL; + uint32 struct_size=0x20; /* W2K always reply that, client doesn't care */ + int num_account; + uint32 enum_context=q_u->start_idx; + uint32 max_size=q_u->max_size; + uint32 temp_size; + enum remote_arch_types ra_type = get_remote_arch(); + int max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K; + uint32 max_entries = max_sam_entries; + DOM_SID domain_sid; 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)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; + domain_sid = info->sid; + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, + DOMAIN_ACCESS_ENUM_ACCOUNTS, + "_samr_enum_dom_users"))) { + return r_u->status; + } + DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); become_root(); - r_u->status = get_sampwd_entries(pass, q_u->start_idx, &total_entries, &num_entries, - MAX_SAM_ENTRIES, q_u->acb_mask); + r_u->status=load_sampwd_entries(info, q_u->acb_mask); unbecome_root(); - - if (NT_STATUS_IS_ERR(r_u->status)) + + if (!NT_STATUS_IS_OK(r_u->status)) return r_u->status; - samr_clear_passwd_fields(pass, num_entries); + num_account = info->disp_info.num_user_account; + + if (enum_context > num_account) { + DEBUG(5, ("_samr_enum_dom_users: enumeration handle over total entries\n")); + return NT_STATUS_OK; + } + + /* verify we won't overflow */ + if (max_entries > num_account-enum_context) { + max_entries = num_account-enum_context; + DEBUG(5, ("_samr_enum_dom_users: only %d entries to return\n", max_entries)); + } + + /* calculate the size and limit on the number of entries we will return */ + temp_size=max_entries*struct_size; + + if (temp_size>max_size) { + max_entries=MIN((max_size/struct_size),max_entries);; + DEBUG(5, ("_samr_enum_dom_users: buffer size limits to only %d entries\n", max_entries)); + } /* * Note from JRA. total_entries is not being used here. Currently if there is a @@ -569,9 +827,20 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_ * value (again I think this is wrong). */ - make_user_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_acct_name, num_entries, pass); + r_u->status = make_user_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_acct_name, + max_entries, enum_context, + info->disp_info.disp_user_info, + &domain_sid); + + if (!NT_STATUS_IS_OK(r_u->status)) + return r_u->status; + + if (enum_context+max_entries < num_account) + r_u->status = STATUS_MORE_ENTRIES; - init_samr_r_enum_dom_users(r_u, q_u->start_idx + num_entries, num_entries); + DEBUG(5, ("_samr_enum_dom_users: %d\n", __LINE__)); + + init_samr_r_enum_dom_users(r_u, q_u->start_idx + max_entries, max_entries); DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); @@ -654,13 +923,12 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM } SAFE_FREE(map); - } else if (sid_equal(sid, &global_sam_sid) && !lp_hide_local_users()) { + } else if (sid_equal(sid, get_global_sam_sid()) && !lp_hide_local_users()) { struct sys_grent *glist; struct sys_grent *grp; struct passwd *pw; gid_t winbind_gid_low, winbind_gid_high; - - lp_winbind_gid(&winbind_gid_low, &winbind_gid_high); + BOOL winbind_groups_exist = lp_winbind_gid(&winbind_gid_low, &winbind_gid_high); /* local aliases */ /* we return the UNIX groups here. This seems to be the right */ @@ -690,24 +958,15 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM continue; /* Don't return winbind groups as they are not local! */ - if ((grp->gr_gid >= winbind_gid_low)&&(grp->gr_gid <= winbind_gid_high)) { + if (winbind_groups_exist && (grp->gr_gid >= winbind_gid_low)&&(grp->gr_gid <= winbind_gid_high)) { DEBUG(10,("get_group_alias_entries: not returing %s, not local.\n", smap.nt_name )); continue; } /* Don't return user private groups... */ - - /* - * We used to do a Get_Pwnam() here, but this has been - * trimmed back to the common case for private groups - * to save lookups and to use the _alloc interface. - * - * This also matches the group mapping code - */ - if ((pw = getpwnam_alloc(smap.nt_name)) != 0) { + if ((pw = Get_Pwnam(smap.nt_name)) != 0) { DEBUG(10,("get_group_alias_entries: not returing %s, clashes with user.\n", smap.nt_name )); - passwd_free(&pw); continue; } @@ -808,11 +1067,16 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM DOMAIN_GRP *grp=NULL; uint32 num_entries; DOM_SID sid; + uint32 acc_granted; r_u->status = NT_STATUS_OK; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_ENUM_ACCOUNTS, "_samr_enum_dom_groups"))) { + return r_u->status; + } DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); @@ -840,12 +1104,17 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S fstring sid_str; DOM_SID sid; NTSTATUS status; + uint32 acc_granted; r_u->status = NT_STATUS_OK; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_ENUM_ACCOUNTS, "_samr_enum_dom_aliases"))) { + return r_u->status; + } + sid_to_string(sid_str, &sid); DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", sid_str)); @@ -867,7 +1136,8 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S /******************************************************************* samr_reply_query_dispinfo ********************************************************************/ -NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_QUERY_DISPINFO *r_u) +NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, + SAMR_R_QUERY_DISPINFO *r_u) { struct samr_info *info = NULL; uint32 struct_size=0x20; /* W2K always reply that, client doesn't care */ @@ -882,9 +1152,8 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ NTSTATUS disp_ret; uint32 num_account = 0; enum remote_arch_types ra_type = get_remote_arch(); - int max_sam_entries; - - max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K; + int max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K; + DOM_SID domain_sid; DEBUG(5, ("samr_reply_query_dispinfo: %d\n", __LINE__)); r_u->status = NT_STATUS_OK; @@ -893,6 +1162,8 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; + domain_sid = info->sid; + /* * calculate how many entries we will return. * based on @@ -936,7 +1207,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ become_root(); r_u->status=load_sampwd_entries(info, acb_mask); unbecome_root(); - if (NT_STATUS_IS_ERR(r_u->status)) { + if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); return r_u->status; } @@ -945,7 +1216,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ case 0x3: case 0x5: r_u->status = load_group_domain_entries(info, &info->sid); - if (NT_STATUS_IS_ERR(r_u->status)) + if (!NT_STATUS_IS_OK(r_u->status)) return r_u->status; num_account = info->disp_info.num_group_account; break; @@ -962,7 +1233,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ if (enum_context > num_account) { DEBUG(5, ("samr_reply_query_dispinfo: enumeration handle over total entries\n")); - return NT_STATUS_OK; + return NT_STATUS_NO_MORE_ENTRIES; } /* verify we won't overflow */ @@ -991,8 +1262,9 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ if (!(ctr->sam.info1 = (SAM_DISPINFO_1 *)talloc_zero(p->mem_ctx,max_entries*sizeof(SAM_DISPINFO_1)))) return NT_STATUS_NO_MEMORY; } - disp_ret = init_sam_dispinfo_1(p->mem_ctx, ctr->sam.info1, max_entries, enum_context, info->disp_info.disp_user_info); - if (NT_STATUS_IS_ERR(disp_ret)) + disp_ret = init_sam_dispinfo_1(p->mem_ctx, ctr->sam.info1, max_entries, enum_context, + info->disp_info.disp_user_info, &domain_sid); + if (!NT_STATUS_IS_OK(disp_ret)) return disp_ret; break; case 0x2: @@ -1000,8 +1272,9 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ if (!(ctr->sam.info2 = (SAM_DISPINFO_2 *)talloc_zero(p->mem_ctx,max_entries*sizeof(SAM_DISPINFO_2)))) return NT_STATUS_NO_MEMORY; } - disp_ret = init_sam_dispinfo_2(p->mem_ctx, ctr->sam.info2, max_entries, enum_context, info->disp_info.disp_user_info); - if (NT_STATUS_IS_ERR(disp_ret)) + disp_ret = init_sam_dispinfo_2(p->mem_ctx, ctr->sam.info2, max_entries, enum_context, + info->disp_info.disp_user_info, &domain_sid); + if (!NT_STATUS_IS_OK(disp_ret)) return disp_ret; break; case 0x3: @@ -1010,7 +1283,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ return NT_STATUS_NO_MEMORY; } disp_ret = init_sam_dispinfo_3(p->mem_ctx, ctr->sam.info3, max_entries, enum_context, info->disp_info.disp_group_info); - if (NT_STATUS_IS_ERR(disp_ret)) + if (!NT_STATUS_IS_OK(disp_ret)) return disp_ret; break; case 0x4: @@ -1019,7 +1292,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ return NT_STATUS_NO_MEMORY; } disp_ret = init_sam_dispinfo_4(p->mem_ctx, ctr->sam.info4, max_entries, enum_context, info->disp_info.disp_user_info); - if (NT_STATUS_IS_ERR(disp_ret)) + if (!NT_STATUS_IS_OK(disp_ret)) return disp_ret; break; case 0x5: @@ -1028,7 +1301,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ return NT_STATUS_NO_MEMORY; } disp_ret = init_sam_dispinfo_5(p->mem_ctx, ctr->sam.info5, max_entries, enum_context, info->disp_info.disp_group_info); - if (NT_STATUS_IS_ERR(disp_ret)) + if (!NT_STATUS_IS_OK(disp_ret)) return disp_ret; break; @@ -1057,22 +1330,26 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_R_QUERY_ALIASINFO *r_u) { - struct samr_info *info = NULL; + DOM_SID sid; GROUP_MAP map; + uint32 acc_granted; r_u->status = NT_STATUS_OK; DEBUG(5,("_samr_query_aliasinfo: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_LOOKUP_INFO, "_samr_query_aliasinfo"))) { + return r_u->status; + } - if (!sid_check_is_in_our_domain(&info->sid) && - !sid_check_is_in_builtin(&info->sid)) + if (!sid_check_is_in_our_domain(&sid) && + !sid_check_is_in_builtin(&sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - if(!get_local_group_from_sid(info->sid, &map, MAPPING_WITHOUT_PRIV)) + if (!get_local_group_from_sid(sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; switch (q_u->switch_level) { @@ -1169,6 +1446,7 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO int num_rids = q_u->num_names2; DOM_SID pol_sid; fstring sid_str; + uint32 acc_granted; r_u->status = NT_STATUS_OK; @@ -1177,10 +1455,14 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO ZERO_ARRAY(rid); ZERO_ARRAY(type); - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid)) { + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid, &acc_granted)) { init_samr_r_lookup_names(p->mem_ctx, r_u, 0, NULL, NULL, NT_STATUS_OBJECT_TYPE_MISMATCH); return r_u->status; } + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, 0, "_samr_lookup_names"))) { /* Don't know the acc_bits yet */ + return r_u->status; + } if (num_rids > MAX_SAM_ENTRIES) { num_rids = MAX_SAM_ENTRIES; @@ -1324,13 +1606,14 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK DOM_SID pol_sid; int num_rids = q_u->num_rids1; int i; + uint32 acc_granted; r_u->status = NT_STATUS_OK; DEBUG(5,("_samr_lookup_rids: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; if (num_rids > MAX_SAM_ENTRIES) { @@ -1356,7 +1639,7 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK group_attrs[i] = SID_NAME_UNKNOWN; *group_names[i] = '\0'; - if (sid_equal(&pol_sid, &global_sam_sid)) { + if (sid_equal(&pol_sid, get_global_sam_sid())) { sid_copy(&sid, &pol_sid); sid_append_rid(&sid, q_u->rid[i]); @@ -1390,42 +1673,58 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN 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; + SEC_DESC *psd = NULL; + uint32 acc_granted; + uint32 des_access = q_u->access_mask; + size_t sd_size; BOOL ret; + NTSTATUS nt_status; r_u->status = NT_STATUS_OK; - /* find the domain policy handle. */ - if (!find_policy_by_hnd(p, &domain_pol, NULL)) + /* find the domain policy handle and get domain SID / access bits in the domain policy. */ + if (!get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_open_user"))) { + return nt_status; + } + + nt_status = pdb_init_sam_talloc(p->mem_ctx, &sampass); + if (!NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } - pdb_init_sam(&sampass); + /* append the user's RID to it */ + if (!sid_append_rid(&sid, q_u->user_rid)) + return NT_STATUS_NO_SUCH_USER; + + /* check if access can be granted as requested by client. */ + samr_make_usr_obj_sd(p->mem_ctx, &psd, &sd_size, &sid); + se_map_generic(&des_access, &usr_generic_mapping); + if (!NT_STATUS_IS_OK(nt_status = + access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_open_user"))) { + return nt_status; + } become_root(); - ret=pdb_getsampwrid(sampass, user_rid); + ret=pdb_getsampwsid(sampass, &sid); unbecome_root(); - /* check that the RID exists in our domain. */ + /* check that the SID exists in our domain. */ if (ret == False) { - pdb_free_sam(&sampass); return NT_STATUS_NO_SUCH_USER; } pdb_free_sam(&sampass); - /* Get the domain SID stored in the domain policy */ - if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid)) - return NT_STATUS_INVALID_HANDLE; - - /* append the user's RID to it */ - if(!sid_append_rid(&sid, user_rid)) - return NT_STATUS_NO_SUCH_USER; - - /* associate the user's SID with the new handle. */ + /* associate the user's SID and access bits with the new handle. */ if ((info = get_samr_info_by_sid(&sid)) == NULL) return NT_STATUS_NO_MEMORY; + info->acc_granted = acc_granted; /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, user_pol, free_samr_info, (void *)info)) @@ -1438,21 +1737,25 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN get_user_info_10. Safe. Only gives out acb bits. *************************************************************************/ -static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) +static NTSTATUS get_user_info_10(TALLOC_CTX *mem_ctx, SAM_USER_INFO_10 *id10, DOM_SID *user_sid) { SAM_ACCOUNT *smbpass=NULL; BOOL ret; + NTSTATUS nt_status; - pdb_init_sam(&smbpass); + nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass); + + if (!NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } become_root(); - ret = pdb_getsampwrid(smbpass, user_rid); + ret = pdb_getsampwsid(smbpass, user_sid); unbecome_root(); if (ret==False) { - DEBUG(4,("User 0x%x not found\n", user_rid)); - pdb_free_sam(&smbpass); - return False; + DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); + return NT_STATUS_NO_SUCH_USER; } DEBUG(3,("User:[%s]\n", pdb_get_username(smbpass) )); @@ -1462,7 +1765,7 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) pdb_free_sam(&smbpass); - return True; + return NT_STATUS_OK; } /************************************************************************* @@ -1471,10 +1774,11 @@ static BOOL get_user_info_10(SAM_USER_INFO_10 *id10, uint32 user_rid) user. JRA. *************************************************************************/ -static NTSTATUS get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint32 user_rid) +static NTSTATUS get_user_info_12(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_INFO_12 * id12, DOM_SID *user_sid) { SAM_ACCOUNT *smbpass=NULL; BOOL ret; + NTSTATUS nt_status; if (!p->ntlmssp_auth_validated) return NT_STATUS_ACCESS_DENIED; @@ -1485,12 +1789,17 @@ static NTSTATUS get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint3 /* * Do *NOT* do become_root()/unbecome_root() here ! JRA. */ - pdb_init_sam(&smbpass); - ret = pdb_getsampwrid(smbpass, user_rid); + nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass); + + if (!NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } + + ret = pdb_getsampwsid(smbpass, user_sid); if (ret == False) { - DEBUG(4, ("User 0x%x not found\n", user_rid)); + DEBUG(4, ("User %s not found\n", sid_string_static(user_sid))); pdb_free_sam(&smbpass); return (geteuid() == (uid_t)0) ? NT_STATUS_NO_SUCH_USER : NT_STATUS_ACCESS_DENIED; } @@ -1514,21 +1823,20 @@ static NTSTATUS get_user_info_12(pipes_struct *p, SAM_USER_INFO_12 * id12, uint3 get_user_info_20 *************************************************************************/ -static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, uint32 user_rid) +static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, SAM_USER_INFO_20 *id20, DOM_SID *user_sid) { SAM_ACCOUNT *sampass=NULL; BOOL ret; - pdb_init_sam(&sampass); + pdb_init_sam_talloc(mem_ctx, &sampass); become_root(); - ret = pdb_getsampwrid(sampass, user_rid); + ret = pdb_getsampwsid(sampass, user_sid); unbecome_root(); if (ret == False) { - DEBUG(4,("User 0x%x not found\n", user_rid)); - pdb_free_sam(&sampass); - return False; + DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); + return NT_STATUS_NO_SUCH_USER; } samr_clear_sam_passwd(sampass); @@ -1540,28 +1848,32 @@ static BOOL get_user_info_20(SAM_USER_INFO_20 *id20, uint32 user_rid) pdb_free_sam(&sampass); - return True; + return NT_STATUS_OK; } /************************************************************************* get_user_info_21 *************************************************************************/ -static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) +static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, + DOM_SID *user_sid, DOM_SID *domain_sid) { SAM_ACCOUNT *sampass=NULL; BOOL ret; + NTSTATUS nt_status; - pdb_init_sam(&sampass); + nt_status = pdb_init_sam_talloc(mem_ctx, &sampass); + if (!NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } become_root(); - ret = pdb_getsampwrid(sampass, user_rid); + ret = pdb_getsampwsid(sampass, user_sid); unbecome_root(); if (ret == False) { - DEBUG(4,("User 0x%x not found\n", user_rid)); - pdb_free_sam(&sampass); - return False; + DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); + return NT_STATUS_NO_SUCH_USER; } samr_clear_sam_passwd(sampass); @@ -1569,11 +1881,11 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) DEBUG(3,("User:[%s]\n", pdb_get_username(sampass) )); ZERO_STRUCTP(id21); - init_sam_user_info21A(id21, sampass); + nt_status = init_sam_user_info21A(id21, sampass, domain_sid); pdb_free_sam(&sampass); - return True; + return NT_STATUS_OK; } /******************************************************************* @@ -1583,21 +1895,24 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid) NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_QUERY_USERINFO *r_u) { SAM_USERINFO_CTR *ctr; - uint32 rid = 0; struct samr_info *info = NULL; - + DOM_SID domain_sid; + uint32 rid; + r_u->status=NT_STATUS_OK; /* search for the handle */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; + domain_sid = info->sid; + + sid_split_rid(&domain_sid, &rid); + if (!sid_check_is_in_our_domain(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - sid_peek_rid(&info->sid, &rid); - - DEBUG(5,("_samr_query_userinfo: rid:0x%x\n", rid)); + DEBUG(5,("_samr_query_userinfo: sid:%s\n", sid_string_static(&info->sid))); ctr = (SAM_USERINFO_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_USERINFO_CTR)); if (!ctr) @@ -1614,8 +1929,8 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ if (ctr->info.id10 == NULL) return NT_STATUS_NO_MEMORY; - if (!get_user_info_10(ctr->info.id10, rid)) - return NT_STATUS_NO_SUCH_USER; + if (!NT_STATUS_IS_OK(r_u->status = get_user_info_10(p->mem_ctx, ctr->info.id10, &info->sid))) + return r_u->status; break; #if 0 @@ -1649,24 +1964,25 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ if (ctr->info.id12 == NULL) return NT_STATUS_NO_MEMORY; - if (NT_STATUS_IS_ERR(r_u->status = get_user_info_12(p, ctr->info.id12, rid))) + if (!NT_STATUS_IS_OK(r_u->status = get_user_info_12(p, p->mem_ctx, ctr->info.id12, &info->sid))) return r_u->status; break; - + case 20: ctr->info.id20 = (SAM_USER_INFO_20 *)talloc_zero(p->mem_ctx,sizeof(SAM_USER_INFO_20)); if (ctr->info.id20 == NULL) return NT_STATUS_NO_MEMORY; - if (!get_user_info_20(ctr->info.id20, rid)) - return NT_STATUS_NO_SUCH_USER; + if (!NT_STATUS_IS_OK(r_u->status = get_user_info_20(p->mem_ctx, ctr->info.id20, &info->sid))) + return r_u->status; break; case 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)) - return NT_STATUS_NO_SUCH_USER; + if (!NT_STATUS_IS_OK(r_u->status = get_user_info_21(p->mem_ctx, ctr->info.id21, + &info->sid, &domain_sid))) + return r_u->status; break; default: @@ -1676,7 +1992,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ init_samr_r_query_userinfo(r_u, ctr, r_u->status); DEBUG(5,("_samr_query_userinfo: %d\n", __LINE__)); - + return r_u->status; } @@ -1687,10 +2003,10 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAMR_R_QUERY_USERGROUPS *r_u) { SAM_ACCOUNT *sam_pass=NULL; + DOM_SID sid; DOM_GID *gids = NULL; int num_groups = 0; - uint32 rid; - struct samr_info *info = NULL; + uint32 acc_granted; BOOL ret; /* @@ -1710,37 +2026,39 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S 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)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, USER_ACCESS_GET_GROUPS, "_samr_query_usergroups"))) { + return r_u->status; + } - if (!sid_check_is_in_our_domain(&info->sid)) + if (!sid_check_is_in_our_domain(&sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - sid_peek_rid(&info->sid, &rid); - pdb_init_sam(&sam_pass); - + become_root(); - ret = pdb_getsampwrid(sam_pass, rid); + ret = pdb_getsampwsid(sam_pass, &sid); unbecome_root(); if (ret == False) { pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } - + if(!get_domain_user_groups(p->mem_ctx, &num_groups, &gids, sam_pass)) { pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_GROUP; } - + /* 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__)); pdb_free_sam(&sam_pass); - + return r_u->status; } @@ -1771,13 +2089,13 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA ZERO_STRUCTP(ctr); r_u->status = NT_STATUS_OK; - + DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); - + /* find the policy handle. open a policy on it. */ if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - + switch (q_u->switch_value) { case 0x01: account_policy_get(AP_MIN_PASSWORD_LEN, &min_pass_len); @@ -1796,15 +2114,15 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA become_root(); r_u->status=load_sampwd_entries(info, ACB_NORMAL); unbecome_root(); - if (NT_STATUS_IS_ERR(r_u->status)) { + if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); return r_u->status; } num_users=info->disp_info.num_user_account; free_samr_db(info); - r_u->status=load_group_domain_entries(info, &global_sam_sid); - if (NT_STATUS_IS_ERR(r_u->status)) { + r_u->status=load_group_domain_entries(info, get_global_sam_sid()); + if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_group_domain_entries failed\n")); return r_u->status; } @@ -1842,12 +2160,12 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA break; default: return NT_STATUS_INVALID_INFO_CLASS; - } - + } + 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__)); - + return r_u->status; } @@ -1871,11 +2189,19 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ BOOL ret; NTSTATUS nt_status; struct passwd *pw; + uint32 acc_granted; + SEC_DESC *psd; + size_t sd_size; + uint32 des_access; - /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &dom_pol, NULL)) + /* Get the domain SID stored in the domain policy */ + if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_CREATE_USER, "_samr_create_user"))) { + return nt_status; + } + /* find the 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 @@ -1944,7 +2270,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ else pstrcpy(add_script, lp_adduser_script()); - if(*add_script) { + if (*add_script) { int add_ret; all_string_sub(add_script, "%u", account, sizeof(account)); add_ret = smbrun(add_script,NULL); @@ -1990,16 +2316,15 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ return NT_STATUS_ACCESS_DENIED; } - /* 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; + /* Get the user's SID */ + sid_copy(&sid, pdb_get_user_sid(sam_pass)); + + samr_make_usr_obj_sd(p->mem_ctx, &psd, &sd_size, &sid); + se_map_generic(&des_access, &usr_generic_mapping); + if (!NT_STATUS_IS_OK(nt_status = + access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_create_user"))) { + return nt_status; } /* associate the user's SID with the new handle. */ @@ -2010,6 +2335,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ ZERO_STRUCTP(info); info->sid = sid; + info->acc_granted = acc_granted; /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, user_pol, free_samr_info, (void *)info)) { @@ -2033,21 +2359,29 @@ NTSTATUS _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CO { struct samr_info *info = NULL; - /* set up the SAMR connect_anon response */ + /* Access check */ - r_u->status = NT_STATUS_OK; + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to samr_connect_anon\n")); + r_u->status = NT_STATUS_ACCESS_DENIED; + return r_u->status; + } + + /* set up the SAMR connect_anon response */ - /* associate the user's SID with the new handle. */ - if ((info = get_samr_info_by_sid(NULL)) == NULL) - return NT_STATUS_NO_MEMORY; + r_u->status = NT_STATUS_OK; + + /* associate the user's SID with the new handle. */ + if ((info = get_samr_info_by_sid(NULL)) == NULL) + return NT_STATUS_NO_MEMORY; - info->status = q_u->unknown_0; + info->status = q_u->unknown_0; - /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; - return r_u->status; + return r_u->status; } /******************************************************************* @@ -2057,24 +2391,47 @@ NTSTATUS _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CO NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u) { struct samr_info *info = NULL; + SEC_DESC *psd = NULL; + uint32 acc_granted; + uint32 des_access = q_u->access_mask; + size_t sd_size; + NTSTATUS nt_status; - DEBUG(5,("_samr_connect: %d\n", __LINE__)); - r_u->status = NT_STATUS_OK; + DEBUG(5,("_samr_connect: %d\n", __LINE__)); + + /* Access check */ + + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to samr_connect\n")); + r_u->status = NT_STATUS_ACCESS_DENIED; + return r_u->status; + } + + samr_make_sam_obj_sd(p->mem_ctx, &psd, &sd_size); + se_map_generic(&des_access, &sam_generic_mapping); + if (!NT_STATUS_IS_OK(nt_status = + access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_connect"))) { + return nt_status; + } + + r_u->status = NT_STATUS_OK; - /* associate the user's SID with the new handle. */ + /* associate the user's SID and access granted with the new handle. */ if ((info = get_samr_info_by_sid(NULL)) == NULL) - return NT_STATUS_NO_MEMORY; + return NT_STATUS_NO_MEMORY; - info->status = q_u->access_mask; + info->acc_granted = acc_granted; + info->status = q_u->access_mask; - /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; - DEBUG(5,("_samr_connect: %d\n", __LINE__)); + DEBUG(5,("_samr_connect: %d\n", __LINE__)); - return r_u->status; + return r_u->status; } /********************************************************************** @@ -2083,14 +2440,19 @@ NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u NTSTATUS _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_LOOKUP_DOMAIN *r_u) { + struct samr_info *info; fstring domain_name; DOM_SID sid; r_u->status = NT_STATUS_OK; - if (!find_policy_by_hnd(p, &q_u->connect_pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->connect_pol, (void**)&info)) return NT_STATUS_INVALID_HANDLE; + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SAMR_ACCESS_OPEN_DOMAIN, "_samr_lookup_domain"))) { + return r_u->status; + } + rpcstr_pull(domain_name, q_u->uni_domain.buffer, sizeof(domain_name), q_u->uni_domain.uni_str_len*2, 0); ZERO_STRUCT(sid); @@ -2150,11 +2512,19 @@ static BOOL make_enum_domains(TALLOC_CTX *ctx, SAM_ENTRY **pp_sam, NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_ENUM_DOMAINS *r_u) { + struct samr_info *info; uint32 num_entries = 2; fstring dom[2]; char *name; r_u->status = NT_STATUS_OK; + + if (!find_policy_by_hnd(p, &q_u->pol, (void**)&info)) + return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SAMR_ACCESS_ENUM_DOMAINS, "_samr_enum_domains"))) { + return r_u->status; + } switch (lp_server_role()) { case ROLE_DOMAIN_PDC: @@ -2187,21 +2557,35 @@ NTSTATUS _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OP POLICY_HND domain_pol = q_u->dom_pol; uint32 alias_rid = q_u->rid_alias; POLICY_HND *alias_pol = &r_u->pol; - struct samr_info *info = NULL; + struct samr_info *info = NULL; + SEC_DESC *psd = NULL; + uint32 acc_granted; + uint32 des_access = q_u->access_mask; + size_t sd_size; + NTSTATUS status; r_u->status = NT_STATUS_OK; - /* get the domain policy. */ - if (!find_policy_by_hnd(p, &domain_pol, NULL)) - return NT_STATUS_INVALID_HANDLE; - - /* Get the domain SID stored in the domain policy */ - if(!get_lsa_policy_samr_sid(p, &domain_pol, &sid)) + /* find the domain policy and get the SID / access bits stored in the domain policy */ + if (!get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_open_alias"))) { + return status; + } /* append the alias' RID to it */ - if(!sid_append_rid(&sid, alias_rid)) + if (!sid_append_rid(&sid, alias_rid)) return NT_STATUS_NO_SUCH_USER; + + /*check if access can be granted as requested by client. */ + samr_make_ali_obj_sd(p->mem_ctx, &psd, &sd_size); + se_map_generic(&des_access,&ali_generic_mapping); + if (!NT_STATUS_IS_OK(status = + access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_open_alias"))) { + return status; + } /* * we should check if the rid really exist !!! @@ -2211,6 +2595,8 @@ NTSTATUS _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OP /* associate the user's SID with the new handle. */ if ((info = get_samr_info_by_sid(&sid)) == NULL) return NT_STATUS_NO_MEMORY; + + info->acc_granted = acc_granted; /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, alias_pol, free_samr_info, (void *)info)) @@ -2223,14 +2609,14 @@ NTSTATUS _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OP set_user_info_10 ********************************************************************/ -static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, uint32 rid) +static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, DOM_SID *sid) { SAM_ACCOUNT *pwd =NULL; BOOL ret; pdb_init_sam(&pwd); - ret = pdb_getsampwrid(pwd, rid); + ret = pdb_getsampwsid(pwd, sid); if(ret==False) { pdb_free_sam(&pwd); @@ -2262,13 +2648,13 @@ static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, uint32 rid) set_user_info_12 ********************************************************************/ -static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, uint32 rid) +static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, DOM_SID *sid) { SAM_ACCOUNT *pwd = NULL; pdb_init_sam(&pwd); - if(!pdb_getsampwrid(pwd, rid)) { + if(!pdb_getsampwsid(pwd, sid)) { pdb_free_sam(&pwd); return False; } @@ -2305,7 +2691,7 @@ static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, uint32 rid) set_user_info_21 ********************************************************************/ -static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) +static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, DOM_SID *sid) { SAM_ACCOUNT *pwd = NULL; @@ -2316,7 +2702,7 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) pdb_init_sam(&pwd); - if (!pdb_getsampwrid(pwd, rid)) { + if (!pdb_getsampwsid(pwd, sid)) { pdb_free_sam(&pwd); return False; } @@ -2345,7 +2731,7 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, uint32 rid) set_user_info_23 ********************************************************************/ -static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) +static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) { SAM_ACCOUNT *pwd = NULL; pstring plaintext_buf; @@ -2359,7 +2745,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) pdb_init_sam(&pwd); - if (!pdb_getsampwrid(pwd, rid)) { + if (!pdb_getsampwsid(pwd, sid)) { pdb_free_sam(&pwd); return False; } @@ -2412,7 +2798,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, uint32 rid) set_user_info_pw ********************************************************************/ -static BOOL set_user_info_pw(char *pass, uint32 rid) +static BOOL set_user_info_pw(char *pass, DOM_SID *sid) { SAM_ACCOUNT *pwd = NULL; uint32 len; @@ -2421,7 +2807,7 @@ static BOOL set_user_info_pw(char *pass, uint32 rid) pdb_init_sam(&pwd); - if (!pdb_getsampwrid(pwd, rid)) { + if (!pdb_getsampwsid(pwd, sid)) { pdb_free_sam(&pwd); return False; } @@ -2480,23 +2866,27 @@ static BOOL set_user_info_pw(char *pass, uint32 rid) NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_USERINFO *r_u) { - uint32 rid = 0x0; DOM_SID sid; POLICY_HND *pol = &q_u->pol; uint16 switch_value = q_u->switch_value; SAM_USERINFO_CTR *ctr = q_u->ctr; + uint32 acc_granted; + uint32 acc_required; DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); r_u->status = NT_STATUS_OK; /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, pol, &sid)) + if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - - sid_split_rid(&sid, &rid); - - DEBUG(5, ("_samr_set_userinfo: rid:0x%x, level:%d\n", rid, switch_value)); + + acc_required = USER_ACCESS_SET_LOC_COM | USER_ACCESS_SET_ATTRIBUTES; /* This is probably wrong */ + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo"))) { + return r_u->status; + } + + DEBUG(5, ("_samr_set_userinfo: sid:%s, level:%d\n", sid_string_static(&sid), switch_value)); if (ctr == NULL) { DEBUG(5, ("_samr_set_userinfo: NULL info level\n")); @@ -2506,7 +2896,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { case 0x12: - if (!set_user_info_12(ctr->info.id12, rid)) + if (!set_user_info_12(ctr->info.id12, &sid)) return NT_STATUS_ACCESS_DENIED; break; @@ -2515,7 +2905,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE 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, &sid)) return NT_STATUS_ACCESS_DENIED; break; @@ -2533,7 +2923,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE dump_data(100, (char *)ctr->info.id25->pass, 532); - if (!set_user_info_pw(ctr->info.id25->pass, rid)) + if (!set_user_info_pw(ctr->info.id25->pass, &sid)) return NT_STATUS_ACCESS_DENIED; break; #endif @@ -2544,7 +2934,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE dump_data(100, (char *)ctr->info.id23->pass, 516); - if (!set_user_info_23(ctr->info.id23, rid)) + if (!set_user_info_23(ctr->info.id23, &sid)) return NT_STATUS_ACCESS_DENIED; break; @@ -2562,22 +2952,26 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SET_USERINFO2 *r_u) { DOM_SID sid; - uint32 rid = 0x0; SAM_USERINFO_CTR *ctr = q_u->ctr; POLICY_HND *pol = &q_u->pol; uint16 switch_value = q_u->switch_value; + uint32 acc_granted; + uint32 acc_required; DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__)); r_u->status = NT_STATUS_OK; /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, pol, &sid)) + if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + acc_required = USER_ACCESS_SET_LOC_COM | USER_ACCESS_SET_ATTRIBUTES; /* This is probably wrong */ + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo2"))) { + return r_u->status; + } - sid_split_rid(&sid, &rid); - - DEBUG(5, ("samr_reply_set_userinfo2: rid:0x%x\n", rid)); + DEBUG(5, ("samr_reply_set_userinfo2: sid:%s\n", sid_string_static(&sid))); if (ctr == NULL) { DEBUG(5, ("samr_reply_set_userinfo2: NULL info level\n")); @@ -2589,16 +2983,16 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { case 21: - if (!set_user_info_21(ctr->info.id21, rid)) + if (!set_user_info_21(ctr->info.id21, &sid)) return NT_STATUS_ACCESS_DENIED; break; case 16: - if (!set_user_info_10(ctr->info.id10, rid)) + if (!set_user_info_10(ctr->info.id10, &sid)) return NT_STATUS_ACCESS_DENIED; break; case 18: /* Used by AS/U JRA. */ - if (!set_user_info_12(ctr->info.id12, rid)) + if (!set_user_info_12(ctr->info.id12, &sid)) return NT_STATUS_ACCESS_DENIED; break; default: @@ -2642,6 +3036,10 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, /* 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; + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, USER_ACCESS_GET_GROUPS, "_samr_query_useraliases"))) { + return r_u->status; + } if (!sid_check_is_domain(&info->sid) && !sid_check_is_builtin(&info->sid)) @@ -2656,7 +3054,7 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, * if there is an error, we just continue as * it can be an unfound user or group */ - if (NT_STATUS_IS_ERR(r_u->status)) { + if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(10,("_samr_query_useraliases: an error occured while getting groups\n")); continue; } @@ -2706,11 +3104,16 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ SAM_ACCOUNT *sam_user = NULL; BOOL check; + uint32 acc_granted; /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_GET_MEMBERS, "_samr_query_aliasmem"))) { + return r_u->status; + } + sid_copy(&als_sid, &alias_sid); sid_to_string(alias_sid_str, &alias_sid); sid_split_rid(&alias_sid, &alias_rid); @@ -2722,7 +3125,7 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ if(!get_local_group_from_sid(als_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; } else { - if (sid_equal(&alias_sid, &global_sam_sid)) { + if (sid_equal(&alias_sid, get_global_sam_sid())) { DEBUG(10, ("lookup on Server SID\n")); if(!get_local_group_from_sid(als_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; @@ -2741,12 +3144,12 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ struct passwd *pass; uint32 rid; - sid_copy(&temp_sid, &global_sam_sid); + sid_copy(&temp_sid, get_global_sam_sid()); pass = getpwuid_alloc(uid[i]); if (!pass) continue; - if (NT_STATUS_IS_ERR(pdb_init_sam(&sam_user))) { + if (!NT_STATUS_IS_OK(pdb_init_sam(&sam_user))) { passwd_free(&pass); continue; } @@ -2802,12 +3205,16 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ SAM_ACCOUNT *sam_user = NULL; BOOL check; - + uint32 acc_granted; /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_GET_MEMBERS, "_samr_query_groupmem"))) { + return r_u->status; + } + /* todo: change to use sid_compare_front */ sid_split_rid(&group_sid, &group_rid); @@ -2815,7 +3222,7 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ DEBUG(10, ("sid is %s\n", group_sid_str)); /* can we get a query for an SID outside our domain ? */ - if (!sid_equal(&group_sid, &global_sam_sid)) + if (!sid_equal(&group_sid, get_global_sam_sid())) return NT_STATUS_NO_SUCH_GROUP; sid_append_rid(&group_sid, group_rid); @@ -2840,7 +3247,7 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ pass = getpwuid_alloc(uid[i]); if (!pass) continue; - if (NT_STATUS_IS_ERR(pdb_init_sam(&sam_user))) { + if (!NT_STATUS_IS_OK(pdb_init_sam(&sam_user))) { passwd_free(&pass); continue; } @@ -2886,20 +3293,24 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD struct passwd *pwd; struct group *grp; fstring grp_name; - uint32 rid; GROUP_MAP map; NTSTATUS ret; SAM_ACCOUNT *sam_user = NULL; BOOL check; + uint32 acc_granted; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_ADD_MEMBER, "_samr_add_aliasmem"))) { + return r_u->status; + } + sid_to_string(alias_sid_str, &alias_sid); DEBUG(10, ("sid is %s\n", alias_sid_str)); - if (sid_compare(&alias_sid, &global_sam_sid)>0) { + if (sid_compare(&alias_sid, get_global_sam_sid())>0) { DEBUG(10, ("adding member on Server SID\n")); if(!get_local_group_from_sid(alias_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; @@ -2914,13 +3325,11 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD return NT_STATUS_NO_SUCH_ALIAS; } - sid_split_rid(&q_u->sid.sid, &rid); - ret = pdb_init_sam(&sam_user); - if (NT_STATUS_IS_ERR(ret)) + if (!NT_STATUS_IS_OK(ret)) return ret; - check = pdb_getsampwrid(sam_user, rid); + check = pdb_getsampwsid(sam_user, &q_u->sid.sid); if (check != True) { pdb_free_sam(&sam_user); @@ -2935,8 +3344,11 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD pdb_free_sam(&sam_user); - if ((pwd=getpwuid(uid)) == NULL) + if ((pwd=getpwuid_alloc(uid)) == NULL) { return NT_STATUS_NO_SUCH_USER; + } else { + passwd_free(&pwd); + } if ((grp=getgrgid(map.gid)) == NULL) return NT_STATUS_NO_SUCH_ALIAS; @@ -2971,14 +3383,18 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE fstring alias_sid_str; struct group *grp; fstring grp_name; - uint32 rid; GROUP_MAP map; SAM_ACCOUNT *sam_pass=NULL; + uint32 acc_granted; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_REMOVE_MEMBER, "_samr_del_aliasmem"))) { + return r_u->status; + } + sid_to_string(alias_sid_str, &alias_sid); DEBUG(10, ("_samr_del_aliasmem:sid is %s\n", alias_sid_str)); @@ -2997,11 +3413,9 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE /* we need to copy the name otherwise it's overloaded in user_in_group_list */ fstrcpy(grp_name, grp->gr_name); - sid_peek_rid(&q_u->sid.sid, &rid); - /* check if the user exists before trying to remove it from the group */ pdb_init_sam(&sam_pass); - if(!pdb_getsampwrid(sam_pass, rid)) { + if(!pdb_getsampwsid(sam_pass, &q_u->sid.sid)) { DEBUG(5,("_samr_del_aliasmem:User %s doesn't exist.\n", pdb_get_username(sam_pass))); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; @@ -3032,6 +3446,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_ADD_GROUPMEM *r_u) { DOM_SID group_sid; + DOM_SID user_sid; fstring group_sid_str; struct passwd *pwd; struct group *grp; @@ -3041,15 +3456,20 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD NTSTATUS ret; SAM_ACCOUNT *sam_user; BOOL check; + uint32 acc_granted; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_ADD_MEMBER, "_samr_add_groupmem"))) { + return r_u->status; + } sid_to_string(group_sid_str, &group_sid); DEBUG(10, ("sid is %s\n", group_sid_str)); - if (sid_compare(&group_sid, &global_sam_sid)<=0) + if (sid_compare(&group_sid, get_global_sam_sid())<=0) return NT_STATUS_NO_SUCH_GROUP; DEBUG(10, ("lookup on Domain SID\n")); @@ -3057,11 +3477,14 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_GROUP; + sid_copy(&user_sid, get_global_sam_sid()); + sid_append_rid(&user_sid, q_u->rid); + ret = pdb_init_sam(&sam_user); - if (NT_STATUS_IS_ERR(ret)) + if (!NT_STATUS_IS_OK(ret)) return ret; - check = pdb_getsampwrid(sam_user, q_u->rid); + check = pdb_getsampwsid(sam_user, &user_sid); if (check != True) { pdb_free_sam(&sam_user); @@ -3076,8 +3499,11 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD pdb_free_sam(&sam_user); - if ((pwd=getpwuid(uid)) == NULL) + if ((pwd=getpwuid_alloc(uid)) == NULL) { return NT_STATUS_NO_SUCH_USER; + } else { + passwd_free(&pwd); + } if ((grp=getgrgid(map.gid)) == NULL) return NT_STATUS_NO_SUCH_GROUP; @@ -3111,11 +3537,12 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DEL_GROUPMEM *r_u) { DOM_SID group_sid; + DOM_SID user_sid; SAM_ACCOUNT *sam_pass=NULL; - uint32 rid; GROUP_MAP map; fstring grp_name; struct group *grp; + uint32 acc_granted; /* * delete the group member named q_u->rid @@ -3124,15 +3551,20 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE */ /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - - if(!sid_check_is_in_our_domain(&group_sid)) + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_REMOVE_MEMBER, "_samr_del_groupmem"))) { + return r_u->status; + } + + if (!sid_check_is_in_our_domain(&group_sid)) return NT_STATUS_NO_SUCH_GROUP; - rid=q_u->rid; + sid_copy(&user_sid, get_global_sam_sid()); + sid_append_rid(&user_sid, q_u->rid); - if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) + if (!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_GROUP; if ((grp=getgrgid(map.gid)) == NULL) @@ -3143,14 +3575,14 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE /* check if the user exists before trying to remove it from the group */ pdb_init_sam(&sam_pass); - if(!pdb_getsampwrid(sam_pass, rid)) { + if (!pdb_getsampwsid(sam_pass, &user_sid)) { DEBUG(5,("User %s doesn't exist.\n", pdb_get_username(sam_pass))); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } /* if the user is not in the group */ - if(!user_in_group_list(pdb_get_username(sam_pass), grp_name)) { + if (!user_in_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_MEMBER_NOT_IN_GROUP; } @@ -3158,7 +3590,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE smb_delete_user_group(grp_name, pdb_get_username(sam_pass)); /* check if the user has been removed then ... */ - if(user_in_group_list(pdb_get_username(sam_pass), grp_name)) { + if (user_in_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_ACCESS_DENIED; /* don't know what to reply else */ } @@ -3168,6 +3600,24 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE } +/**************************************************************************** + Delete a UNIX user on demand. +****************************************************************************/ + +static int smb_delete_user(const char *unix_user) +{ + pstring del_script; + int ret; + + pstrcpy(del_script, lp_deluser_script()); + if (! *del_script) + return -1; + all_string_sub(del_script, "%u", unix_user, sizeof(pstring)); + ret = smbrun(del_script,NULL); + DEBUG(3,("smb_delete_user: Running the command `%s' gave %d\n",del_script,ret)); + return ret; +} + /********************************************************************* _samr_delete_dom_user *********************************************************************/ @@ -3176,22 +3626,24 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM { DOM_SID user_sid; SAM_ACCOUNT *sam_pass=NULL; - uint32 rid; + uint32 acc_granted; DEBUG(5, ("_samr_delete_dom_user: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &user_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &user_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DELETE_ACCESS, "_samr_delete_dom_user"))) { + return r_u->status; + } + if (!sid_check_is_in_our_domain(&user_sid)) return NT_STATUS_CANNOT_DELETE; - sid_peek_rid(&user_sid, &rid); - /* check if the user exists before trying to delete */ pdb_init_sam(&sam_pass); - if(!pdb_getsampwrid(sam_pass, rid)) { + if(!pdb_getsampwsid(sam_pass, &user_sid)) { DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n", pdb_get_username(sam_pass))); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; @@ -3233,13 +3685,18 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S gid_t gid; struct group *grp; GROUP_MAP map; + uint32 acc_granted; DEBUG(5, ("samr_delete_dom_group: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DELETE_ACCESS, "_samr_delete_dom_group"))) { + return r_u->status; + } + sid_copy(&dom_sid, &group_sid); sid_to_string(group_sid_str, &dom_sid); sid_split_rid(&dom_sid, &group_rid); @@ -3247,7 +3704,7 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S DEBUG(10, ("sid is %s\n", group_sid_str)); /* we check if it's our SID before deleting */ - if (!sid_equal(&dom_sid, &global_sam_sid)) + if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_NO_SUCH_GROUP; DEBUG(10, ("lookup on Domain SID\n")); @@ -3290,13 +3747,18 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S gid_t gid; struct group *grp; GROUP_MAP map; + uint32 acc_granted; DEBUG(5, ("_samr_delete_dom_alias: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DELETE_ACCESS, "_samr_delete_dom_alias"))) { + return r_u->status; + } + sid_copy(&dom_sid, &alias_sid); sid_to_string(alias_sid_str, &dom_sid); sid_split_rid(&dom_sid, &alias_rid); @@ -3304,7 +3766,7 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S DEBUG(10, ("sid is %s\n", alias_sid_str)); /* we check if it's our SID before deleting */ - if (!sid_equal(&dom_sid, &global_sam_sid)) + if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_NO_SUCH_ALIAS; DEBUG(10, ("lookup on Local SID\n")); @@ -3347,14 +3809,19 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S struct group *grp; struct samr_info *info; PRIVILEGE_SET priv_set; + uint32 acc_granted; init_privilege(&priv_set); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - - if (!sid_equal(&dom_sid, &global_sam_sid)) + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_CREATE_GROUP, "_samr_create_dom_group"))) { + return r_u->status; + } + + if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; /* TODO: check if allowed to create group and add a become_root/unbecome_root pair.*/ @@ -3375,7 +3842,7 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); /* add the group to the mapping table */ - sid_copy(&info_sid, &global_sam_sid); + sid_copy(&info_sid, get_global_sam_sid()); sid_append_rid(&info_sid, r_u->rid); sid_to_string(sid_string, &info_sid); @@ -3405,14 +3872,19 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S struct group *grp; struct samr_info *info; PRIVILEGE_SET priv_set; + uint32 acc_granted; init_privilege(&priv_set); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - - if (!sid_equal(&dom_sid, &global_sam_sid)) + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_CREATE_ALIAS, "_samr_create_alias"))) { + return r_u->status; + } + + if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; /* TODO: check if allowed to create group and add a become_root/unbecome_root pair.*/ @@ -3432,7 +3904,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); - sid_copy(&info_sid, &global_sam_sid); + sid_copy(&info_sid, get_global_sam_sid()); sid_append_rid(&info_sid, r_u->rid); sid_to_string(sid_string, &info_sid); @@ -3464,10 +3936,15 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM uid_t *uid=NULL; int num_uids=0; GROUP_INFO_CTR *ctr; + uint32 acc_granted; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_LOOKUP_INFO, "_samr_query_groupinfo"))) { + return r_u->status; + } + if (!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_INVALID_HANDLE; @@ -3511,10 +3988,15 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ DOM_SID group_sid; GROUP_MAP map; GROUP_INFO_CTR *ctr; + uint32 acc_granted; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_SET_INFO, "_samr_set_groupinfo"))) { + return r_u->status; + } + if (!get_domain_group_from_sid(group_sid, &map, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; @@ -3553,10 +4035,15 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ DOM_SID group_sid; GROUP_MAP map; ALIAS_INFO_CTR *ctr; + uint32 acc_granted; - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_SET_INFO, "_samr_set_aliasinfo"))) { + return r_u->status; + } + if (!get_local_group_from_sid(group_sid, &map, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; @@ -3587,7 +4074,18 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ NTSTATUS _samr_get_dom_pwinfo(pipes_struct *p, SAMR_Q_GET_DOM_PWINFO *q_u, SAMR_R_GET_DOM_PWINFO *r_u) { + /* Perform access check. Since this rpc does not require a + policy handle it will not be caught by the access checks on + SAMR_CONNECT or SAMR_CONNECT_ANON. */ + + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to samr_get_dom_pwinfo\n")); + r_u->status = NT_STATUS_ACCESS_DENIED; + return r_u->status; + } + /* Actually, returning zeros here works quite well :-). */ + return NT_STATUS_OK; } @@ -3601,21 +4099,42 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G DOM_SID info_sid; GROUP_MAP map; struct samr_info *info; + SEC_DESC *psd = NULL; + uint32 acc_granted; + uint32 des_access; + size_t sd_size; + NTSTATUS status; fstring sid_string; - if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid)) + if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_open_group"))) { + return status; + } + + /*check if access can be granted as requested by client. */ + samr_make_grp_obj_sd(p->mem_ctx, &psd, &sd_size); + se_map_generic(&des_access,&grp_generic_mapping); + if (!NT_STATUS_IS_OK(status = + access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_open_group"))) { + return status; + } + /* this should not be hard-coded like this */ - if (!sid_equal(&sid, &global_sam_sid)) + if (!sid_equal(&sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; - sid_copy(&info_sid, &global_sam_sid); + sid_copy(&info_sid, get_global_sam_sid()); sid_append_rid(&info_sid, q_u->rid_group); sid_to_string(sid_string, &info_sid); if ((info = get_samr_info_by_sid(&info_sid)) == NULL) return NT_STATUS_NO_MEMORY; + + info->acc_granted = acc_granted; DEBUG(10, ("_samr_open_group:Opening SID: %s\n", sid_string)); @@ -3692,14 +4211,14 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW become_root(); r_u->status=load_sampwd_entries(info, ACB_NORMAL); unbecome_root(); - if (NT_STATUS_IS_ERR(r_u->status)) { + if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); return r_u->status; } num_users=info->disp_info.num_user_account; free_samr_db(info); - r_u->status=load_group_domain_entries(info, &global_sam_sid); + r_u->status=load_group_domain_entries(info, get_global_sam_sid()); if (NT_STATUS_IS_ERR(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_group_domain_entries failed\n")); return r_u->status; diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index c7dc5d27ff..6e3463e79b 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -4,7 +4,8 @@ * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Gerald Carter 2001-2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +24,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /******************************************************************** * api_spoolss_open_printer_ex (rarely seen - older call) ********************************************************************/ @@ -1399,6 +1403,119 @@ static BOOL api_spoolss_getprintprocessordirectory(pipes_struct *p) return True; } +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_deleteprinterdataex(pipes_struct *p) +{ + SPOOL_Q_DELETEPRINTERDATAEX q_u; + SPOOL_R_DELETEPRINTERDATAEX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_deleteprinterdataex("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_deleteprinterdataex: unable to unmarshall SPOOL_Q_DELETEPRINTERDATAEX.\n")); + return False; + } + + r_u.status = _spoolss_deleteprinterdataex(p, &q_u, &r_u); + + if(!spoolss_io_r_deleteprinterdataex("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_deleteprinterdataex: unable to marshall SPOOL_R_DELETEPRINTERDATAEX.\n")); + return False; + } + + return True; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_deleteprinterkey(pipes_struct *p) +{ + SPOOL_Q_DELETEPRINTERKEY q_u; + SPOOL_R_DELETEPRINTERKEY r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_deleteprinterkey("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_deleteprinterkey: unable to unmarshall SPOOL_Q_DELETEPRINTERKEY.\n")); + return False; + } + + r_u.status = _spoolss_deleteprinterkey(p, &q_u, &r_u); + + if(!spoolss_io_r_deleteprinterkey("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_deleteprinterkey: unable to marshall SPOOL_R_DELETEPRINTERKEY.\n")); + return False; + } + + return True; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_addprinterdriverex(pipes_struct *p) +{ + SPOOL_Q_ADDPRINTERDRIVEREX q_u; + SPOOL_R_ADDPRINTERDRIVEREX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_addprinterdriverex("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_addprinterdriverex: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVEREX.\n")); + return False; + } + + r_u.status = _spoolss_addprinterdriverex(p, &q_u, &r_u); + + if(!spoolss_io_r_addprinterdriverex("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_addprinterdriverex: unable to marshall SPOOL_R_ADDPRINTERDRIVEREX.\n")); + return False; + } + + return True; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_deleteprinterdriverex(pipes_struct *p) +{ + SPOOL_Q_DELETEPRINTERDRIVEREX q_u; + SPOOL_R_DELETEPRINTERDRIVEREX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_deleteprinterdriverex("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_deleteprinterdriverex: unable to unmarshall SPOOL_Q_DELETEPRINTERDRIVEREX.\n")); + return False; + } + + r_u.status = _spoolss_deleteprinterdriverex(p, &q_u, &r_u); + + if(!spoolss_io_r_deleteprinterdriverex("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_deleteprinterdriverex: unable to marshall SPOOL_R_DELETEPRINTERDRIVEREX.\n")); + return False; + } + + return True; +} + + /******************************************************************* \pipe\spoolss commands ********************************************************************/ @@ -1449,9 +1566,13 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_ENUMPRINTPROCDATATYPES", SPOOLSS_ENUMPRINTPROCDATATYPES, api_spoolss_enumprintprocdatatypes }, {"SPOOLSS_GETPRINTERDATAEX", SPOOLSS_GETPRINTERDATAEX, api_spoolss_getprinterdataex }, {"SPOOLSS_SETPRINTERDATAEX", SPOOLSS_SETPRINTERDATAEX, api_spoolss_setprinterdataex }, - {"SPOOLSS_ENUMPRINTERKEY", SPOOLSS_ENUMPRINTERKEY, api_spoolss_enumprinterkey }, + {"SPOOLSS_DELETEPRINTERDATAEX", SPOOLSS_DELETEPRINTERDATAEX, api_spoolss_deleteprinterdataex }, {"SPOOLSS_ENUMPRINTERDATAEX", SPOOLSS_ENUMPRINTERDATAEX, api_spoolss_enumprinterdataex }, + {"SPOOLSS_ENUMPRINTERKEY", SPOOLSS_ENUMPRINTERKEY, api_spoolss_enumprinterkey }, + {"SPOOLSS_DELETEPRINTERKEY", SPOOLSS_DELETEPRINTERKEY, api_spoolss_deleteprinterkey }, {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory}, + {"SPOOLSS_ADDPRINTERDRIVEREX", SPOOLSS_ADDPRINTERDRIVEREX, api_spoolss_addprinterdriverex }, + {"SPOOLSS_DELETEPRINTERDRIVEREX", SPOOLSS_DELETEPRINTERDRIVEREX, api_spoolss_deleteprinterdriverex }, { NULL, 0, NULL } }; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 322efa22b5..68c792f8b0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000, * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Gerald Carter 2000-2001, + * Copyright (C) Gerald Carter 2000-2002, * Copyright (C) Tim Potter 2001-2002. * * This program is free software; you can redistribute it and/or modify @@ -28,6 +28,10 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV +/* #define EMULATE_WIN2K_HACK 1 */ + #ifndef MAX_OPEN_PRINTER_EXS #define MAX_OPEN_PRINTER_EXS 50 #endif @@ -37,6 +41,15 @@ #define PRINTER_HANDLE_IS_PRINTER 0 #define PRINTER_HANDLE_IS_PRINTSERVER 1 +/* Table to map the driver version */ +/* to OS */ +char * drv_ver_to_os[] = { + "WIN9X", /* driver version/cversion 0 */ + "", /* unused ? */ + "WINNT", /* driver version/cversion 2 */ + "WIN2K", /* driver version/cversion 3 */ +}; + struct table_node { char *long_archi; char *short_archi; @@ -68,6 +81,7 @@ typedef struct _Printer{ SPOOL_NOTIFY_OPTION *option; POLICY_HND client_hnd; uint32 client_connected; + uint32 change; } notify; struct { fstring machine; @@ -178,10 +192,10 @@ static void srv_spoolss_replycloseprinter(POLICY_HND *handle) /* if it's the last connection, deconnect the IPC$ share */ if (smb_connections==1) { - if(!spoolss_disconnect_from_client(&cli)) - return; - - message_deregister(MSG_PRINTER_NOTIFY); + cli_nt_session_close(&cli); + cli_ulogoff(&cli); + cli_shutdown(&cli); + message_deregister(MSG_PRINTER_NOTIFY2); } smb_connections--; @@ -426,7 +440,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) * anymore, so I've simplified this loop greatly. Here * we are just verifying that the printer name is a valid * printer service defined in smb.conf - * --jerry [Fri Feb 15 11:17:46 CST 2002] + * --jerry [Fri Feb 15 11:17:46 CST 2002] */ for (snum=0; snumnotify.option == NULL) - return False; - return True; } -/*************************************************************************** - Simple check to see if the client motify handle is set to watch for events - represented by 'flags' - - FIXME!!!! only a stub right now --jerry - **************************************************************************/ - -static BOOL is_client_monitoring_event(Printer_entry *p, uint32 flags) +static BOOL is_monitoring_event(Printer_entry *p, uint16 notify_type, + uint16 notify_field) { + SPOOL_NOTIFY_OPTION *option = p->notify.option; + uint32 i, j; + + if (p->notify.flags) + return is_monitoring_event_flags( + p->notify.flags, notify_type, notify_field); - return True; -} + for (i = 0; i < option->count; i++) { + + /* Check match for notify_type */ + + if (option->ctr.type[i].type != notify_type) + continue; -/*************************************************************************** - Server wrapper for cli_spoolss_routerreplyprinter() since the client - function can only send a single change notification at a time. - - FIXME!!! only handles one change currently (PRINTER_CHANGE_SET_PRINTER_DRIVER) - --jerry - **************************************************************************/ - -static WERROR srv_spoolss_routerreplyprinter (struct cli_state *reply_cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, PRINTER_MESSAGE_INFO *info, - NT_PRINTER_INFO_LEVEL *printer) -{ - WERROR result; - uint32 condition = 0x0; + /* Check match for field */ + + for (j = 0; j < option->ctr.type[i].count; j++) { + if (option->ctr.type[i].fields[j] == notify_field) { + return True; + } + } + } - if (info->flags & PRINTER_MESSAGE_DRIVER) - condition = PRINTER_CHANGE_SET_PRINTER_DRIVER; + DEBUG(10, ("%s is not monitoring 0x%02x/0x%02x\n", + (p->printer_type == PRINTER_HANDLE_IS_PRINTER) ? + p->dev.handlename : p->dev.printerservername, + notify_type, notify_field)); - result = cli_spoolss_routerreplyprinter(reply_cli, mem_ctx, pol, condition, - printer->info_2->changeid); + return False; +} - return result; +/* Convert a notification message to a SPOOL_NOTIFY_INFO_DATA struct */ + +static void notify_one_value(struct spoolss_notify_msg *msg, + SPOOL_NOTIFY_INFO_DATA *data, + TALLOC_CTX *mem_ctx) +{ + data->notify_data.value[0] = msg->notify.value[0]; + data->notify_data.value[1] = 0; } -/*********************************************************************** - Wrapper around the decision of which RPC use to in the change - notification - **********************************************************************/ - -static WERROR srv_spoolss_send_event_to_client(Printer_entry* Printer, - struct cli_state *send_cli, PRINTER_MESSAGE_INFO *msg, - NT_PRINTER_INFO_LEVEL *info) +static void notify_string(struct spoolss_notify_msg *msg, + SPOOL_NOTIFY_INFO_DATA *data, + TALLOC_CTX *mem_ctx) { - WERROR result; + UNISTR2 unistr; - if (valid_notify_options(Printer)) { - /* This is a single call that can send information about multiple changes */ - if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) - msg->flags |= PRINTER_MESSAGE_ATTRIBUTES; + /* The length of the message includes the trailing \0 */ - result = cli_spoolss_reply_rrpcn(send_cli, send_cli->mem_ctx, &Printer->notify.client_hnd, - msg, info); - } - else { - /* This requires that the server send an individual event notification for each change */ - result = srv_spoolss_routerreplyprinter(send_cli, send_cli->mem_ctx, &Printer->notify.client_hnd, - msg, info); + init_unistr2(&unistr, msg->notify.data, msg->len); + + data->notify_data.data.length = msg->len * 2; + data->notify_data.data.string = (uint16 *)talloc(mem_ctx, msg->len * 2); + + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; } - return result; + memcpy(data->notify_data.data.string, unistr.buffer, msg->len * 2); } +static void notify_system_time(struct spoolss_notify_msg *msg, + SPOOL_NOTIFY_INFO_DATA *data, + TALLOC_CTX *mem_ctx) +{ + SYSTEMTIME systime; + prs_struct ps; + + if (msg->len != sizeof(time_t)) { + DEBUG(5, ("notify_system_time: received wrong sized message (%d)\n", + msg->len)); + return; + } + + if (!prs_init(&ps, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL)) { + DEBUG(5, ("notify_system_time: prs_init() failed\n")); + return; + } + + if (!make_systemtime(&systime, localtime((time_t *)msg->notify.data))) { + DEBUG(5, ("notify_system_time: unable to make systemtime\n")); + return; + } + + if (!spoolss_io_system_time("", &ps, 0, &systime)) + return; + + data->notify_data.data.length = prs_offset(&ps); + data->notify_data.data.string = + talloc(mem_ctx, prs_offset(&ps)); + + memcpy(data->notify_data.data.string, prs_data_p(&ps), prs_offset(&ps)); + + prs_mem_free(&ps); +} + +struct notify2_message_table { + char *name; + void (*fn)(struct spoolss_notify_msg *msg, + SPOOL_NOTIFY_INFO_DATA *data, TALLOC_CTX *mem_ctx); +}; + +static struct notify2_message_table printer_notify_table[] = { + /* 0x00 */ { "PRINTER_NOTIFY_SERVER_NAME", NULL }, + /* 0x01 */ { "PRINTER_NOTIFY_PRINTER_NAME", NULL }, + /* 0x02 */ { "PRINTER_NOTIFY_SHARE_NAME", NULL }, + /* 0x03 */ { "PRINTER_NOTIFY_PORT_NAME", NULL }, + /* 0x04 */ { "PRINTER_NOTIFY_DRIVER_NAME", NULL }, + /* 0x05 */ { "PRINTER_NOTIFY_COMMENT", NULL }, + /* 0x06 */ { "PRINTER_NOTIFY_LOCATION", NULL }, + /* 0x07 */ { "PRINTER_NOTIFY_DEVMODE", NULL }, + /* 0x08 */ { "PRINTER_NOTIFY_SEPFILE", NULL }, + /* 0x09 */ { "PRINTER_NOTIFY_PRINT_PROCESSOR", NULL }, + /* 0x0a */ { "PRINTER_NOTIFY_PARAMETERS", NULL }, + /* 0x0b */ { "PRINTER_NOTIFY_DATATYPE", NULL }, + /* 0x0c */ { "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", NULL }, + /* 0x0d */ { "PRINTER_NOTIFY_ATTRIBUTES", NULL }, + /* 0x0e */ { "PRINTER_NOTIFY_PRIORITY", NULL }, + /* 0x0f */ { "PRINTER_NOTIFY_DEFAULT_PRIORITY", NULL }, + /* 0x10 */ { "PRINTER_NOTIFY_START_TIME", NULL }, + /* 0x11 */ { "PRINTER_NOTIFY_UNTIL_TIME", NULL }, + /* 0x12 */ { "PRINTER_NOTIFY_STATUS", notify_one_value }, +}; + +static struct notify2_message_table job_notify_table[] = { + /* 0x00 */ { "JOB_NOTIFY_PRINTER_NAME", NULL }, + /* 0x01 */ { "JOB_NOTIFY_MACHINE_NAME", NULL }, + /* 0x02 */ { "JOB_NOTIFY_PORT_NAME", NULL }, + /* 0x03 */ { "JOB_NOTIFY_USER_NAME", notify_string }, + /* 0x04 */ { "JOB_NOTIFY_NOTIFY_NAME", NULL }, + /* 0x05 */ { "JOB_NOTIFY_DATATYPE", NULL }, + /* 0x06 */ { "JOB_NOTIFY_PRINT_PROCESSOR", NULL }, + /* 0x07 */ { "JOB_NOTIFY_PARAMETERS", NULL }, + /* 0x08 */ { "JOB_NOTIFY_DRIVER_NAME", NULL }, + /* 0x09 */ { "JOB_NOTIFY_DEVMODE", NULL }, + /* 0x0a */ { "JOB_NOTIFY_STATUS", notify_one_value }, + /* 0x0b */ { "JOB_NOTIFY_STATUS_STRING", NULL }, + /* 0x0c */ { "JOB_NOTIFY_SECURITY_DESCRIPTOR", NULL }, + /* 0x0d */ { "JOB_NOTIFY_DOCUMENT", notify_string }, + /* 0x0e */ { "JOB_NOTIFY_PRIORITY", NULL }, + /* 0x0f */ { "JOB_NOTIFY_POSITION", NULL }, + /* 0x10 */ { "JOB_NOTIFY_SUBMITTED", notify_system_time }, + /* 0x11 */ { "JOB_NOTIFY_START_TIME", NULL }, + /* 0x12 */ { "JOB_NOTIFY_UNTIL_TIME", NULL }, + /* 0x13 */ { "JOB_NOTIFY_TIME", NULL }, + /* 0x14 */ { "JOB_NOTIFY_TOTAL_PAGES", notify_one_value }, + /* 0x15 */ { "JOB_NOTIFY_PAGES_PRINTED", NULL }, + /* 0x16 */ { "JOB_NOTIFY_TOTAL_BYTES", notify_one_value }, + /* 0x17 */ { "JOB_NOTIFY_BYTES_PRINTED", NULL }, +}; /*********************************************************************** Send a change notication message on all handles which have a call back registered **********************************************************************/ -static void send_spoolss_event_notification(PRINTER_MESSAGE_INFO *msg) +static void process_notify2_message(struct spoolss_notify_msg *msg, + TALLOC_CTX *mem_ctx) { - Printer_entry *find_printer; - WERROR result; - NT_PRINTER_INFO_LEVEL *printer = NULL; + Printer_entry *p; - if (!msg) { - DEBUG(0,("send_spoolss_event_notification: NULL msg pointer!\n")); - return; - } + for (p = printers_list; p; p = p->next) { + SPOOL_NOTIFY_INFO_DATA *data; + uint32 data_len = 1; + uint32 id; - for(find_printer = printers_list; find_printer; find_printer = find_printer->next) { + /* Is there notification on this handle? */ - /* - * If the entry has a connected client we send the message. There should - * only be one of these normally when dealing with the NT/2k spooler. - * However, iterate over all to make sure we deal with user applications - * in addition to spooler service. - * - * While we are only maintaining a single connection to the client, - * the FindFirstPrinterChangeNotification() call is made on a printer - * handle, so "client_connected" represents the whether or not the - * client asked for change notication on this handle. - * - * --jerry - */ + if (!p->notify.client_connected) + continue; - if (find_printer->notify.client_connected==True) { - - /* does the client care about what changed? */ + /* For this printer? Print servers always receive + notifications. */ - if (msg->flags && !is_client_monitoring_event(find_printer, msg->flags)) { - DEBUG(10,("send_spoolss_event_notification: Client [%s] not monitoring these events\n", - find_printer->client.machine)); - continue; - } + if (p->printer_type == PRINTER_HANDLE_IS_PRINTER && + !strequal(msg->printer, p->dev.handlename)) + continue; - if (find_printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) - DEBUG(10,("send_spoolss_event_notification: printserver [%s]\n", find_printer->dev.printerservername )); - else - DEBUG(10,("send_spoolss_event_notification: printer [%s]\n", find_printer->dev.handlename)); + /* Are we monitoring this event? */ + + if (!is_monitoring_event(p, msg->type, msg->field)) + continue; - /* - * if handle is a printer, only send if the printer_name matches. - * ...else if handle is a printerserver, send to all - */ + /* OK - send the event to the client */ - if (*msg->printer_name && (find_printer->printer_type==PRINTER_HANDLE_IS_PRINTER) - && !strequal(msg->printer_name, find_printer->dev.handlename)) - { - DEBUG(10,("send_spoolss_event_notification: ignoring message sent to %s [%s]\n", - msg->printer_name, find_printer->dev.handlename )); - continue; + data = talloc(mem_ctx, sizeof(SPOOL_NOTIFY_INFO_DATA)); + + ZERO_STRUCTP(data); + + /* Convert unix jobid to smb jobid */ + + id = msg->id; + + if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) { + + id = sysjob_to_jobid(msg->id); + + if (id == -1) { + DEBUG(3, ("no such unix jobid %d\n", msg->id)); + goto done; } + } + construct_info_data(data, msg->type, msg->field, id); - /* lookup the printer if we have a name if we don't already have a - valid NT_PRINTER_INFO_LEVEL structure. And yes I'm assuming we - will always have a non-empty msg.printer_name */ - - if (!printer || !printer->info_2 || strcmp(msg->printer_name, printer->info_2->printername)) - { - - if (printer) { - free_a_printer(&printer, 2); - printer = NULL; - } - - result = get_a_printer(&printer, 2, msg->printer_name); - if (!W_ERROR_IS_OK(result)) - continue; + switch(msg->type) { + case PRINTER_NOTIFY_TYPE: + if (printer_notify_table[msg->field].fn) + printer_notify_table[msg->field].fn( + msg, data, mem_ctx); + else + goto done; + break; + case JOB_NOTIFY_TYPE: + if (job_notify_table[msg->field].fn) + job_notify_table[msg->field].fn( + msg, data, mem_ctx); + else + goto done; + break; + default: + DEBUG(5, ("Unknown notification type %d\n", + msg->type)); + goto done; + } + + if (!p->notify.flags) + cli_spoolss_rrpcn( + &cli, mem_ctx, &p->notify.client_hnd, + data_len, data, p->notify.change, 0); + else { + NT_PRINTER_INFO_LEVEL *printer = NULL; + + get_a_printer(&printer, 2, msg->printer); + + if (!printer) { + DEBUG(5, ("unable to load info2 for %s\n", + msg->printer)); + goto done; } - /* issue the client call */ + /* XXX: This needs to be updated for + PRINTER_CHANGE_SET_PRINTER_DRIVER. */ - result = srv_spoolss_send_event_to_client(find_printer, &cli, msg, printer); - - if (!W_ERROR_IS_OK(result)) { - DEBUG(5,("send_spoolss_event_notification: Event notification failed [%s]\n", - dos_errstr(result))); + cli_spoolss_routerreplyprinter( + &cli, mem_ctx, &p->notify.client_hnd, + 0, printer->info_2->changeid); + + free_a_printer(&printer, 2); } } -} - +done: return; } -/*************************************************************************** - Receive the notify message and decode the message. Do not send - notification if we sent this originally as that would result in - duplicates. -****************************************************************************/ -static void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len) +/* Receive a notify2 message */ + +static void receive_notify2_message(int msg_type, pid_t src, void *buf, + size_t len) { - PRINTER_MESSAGE_INFO msg; - - if (len < sizeof(msg)) { - DEBUG(2,("srv_spoolss_receive_message: got incorrect message size (%u)!\n", (unsigned int)len)); - return; - } + struct spoolss_notify_msg msg; + int offset = 0; + TALLOC_CTX *mem_ctx = talloc_init(); - memcpy(&msg, buf, sizeof(PRINTER_MESSAGE_INFO)); - - DEBUG(10,("srv_spoolss_receive_message: Got message printer change [queue = %s] low=0x%x high=0x%x flags=0x%x\n", - msg.printer_name, (unsigned int)msg.low, (unsigned int)msg.high, msg.flags )); + /* Unpack message */ - /* Iterate the printer list */ - - send_spoolss_event_notification(&msg); + ZERO_STRUCT(msg); + + offset += tdb_unpack((char *)buf + offset, len - offset, "f", + msg.printer); + offset += tdb_unpack((char *)buf + offset, len - offset, "ddddd", + &msg.type, &msg.field, &msg.id, &msg.len, &msg.flags); + + if (msg.len == 0) + tdb_unpack((char *)buf + offset, len - offset, "dd", + &msg.notify.value[0], &msg.notify.value[1]); + else + tdb_unpack((char *)buf + offset, len - offset, "B", + &msg.len, &msg.notify.data); + + DEBUG(3, ("got NOTIFY2 message, type %d, field 0x%02x, flags 0x%04x\n", + msg.type, msg.field, msg.flags)); + + if (msg.len == 0) + DEBUG(3, ("value1 = %d, value2 = %d\n", msg.notify.value[0], + msg.notify.value[1])); + else + dump_data(3, msg.notify.data, msg.len); + + /* Process message */ + + process_notify2_message(&msg, mem_ctx); + + /* Free message */ + + if (msg.len > 0) + free(msg.notify.data); + + talloc_destroy(mem_ctx); } /*************************************************************************** - Send a notify event. -****************************************************************************/ - -static BOOL srv_spoolss_sendnotify(char* printer_name, uint32 high, uint32 low, uint32 flags) + Server wrapper for cli_spoolss_routerreplyprinter() since the client + function can only send a single change notification at a time. + + FIXME!!! only handles one change currently (PRINTER_CHANGE_SET_PRINTER_DRIVER) + --jerry + **************************************************************************/ + +static WERROR srv_spoolss_routerreplyprinter (struct cli_state *reply_cli, TALLOC_CTX *mem_ctx, + POLICY_HND *pol, PRINTER_MESSAGE_INFO *info, + NT_PRINTER_INFO_LEVEL *printer) { - char msg[sizeof(PRINTER_MESSAGE_INFO)]; - PRINTER_MESSAGE_INFO info; + WERROR result; + uint32 condition = 0x0; - ZERO_STRUCT(info); + if (info->flags & PRINTER_MESSAGE_DRIVER) + condition = PRINTER_CHANGE_SET_PRINTER_DRIVER; + + result = cli_spoolss_routerreplyprinter(reply_cli, mem_ctx, pol, condition, + printer->info_2->changeid); - info.low = low; - info.high = high; - info.flags = flags; - fstrcpy(info.printer_name, printer_name); + return result; +} + +/******************************************************************** + Send a message to ourself about new driver being installed + so we can upgrade the information for each printer bound to this + driver + ********************************************************************/ + +static BOOL srv_spoolss_drv_upgrade_printer(char* drivername) +{ + int len = strlen(drivername); - memcpy(msg, &info, sizeof(PRINTER_MESSAGE_INFO)); + if (!len) + return False; - DEBUG(10,("srv_spoolss_sendnotify: printer change low=0x%x high=0x%x [%s], flags=0x%x\n", - low, high, printer_name, flags)); + DEBUG(10,("srv_spoolss_drv_upgrade_printer: Sending message about driver upgrade [%s]\n", + drivername)); - message_send_all(conn_tdb_ctx(), MSG_PRINTER_NOTIFY, msg, sizeof(PRINTER_MESSAGE_INFO), - False, NULL); + message_send_pid(sys_getpid(), MSG_PRINTER_DRVUPGRADE, drivername, len+1, False); return True; -} +} + +/********************************************************************** + callback to receive a MSG_PRINTER_DRVUPGRADE message and interate + over all printers, upgrading ones as neessary + **********************************************************************/ + +void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) +{ + fstring drivername; + int snum; + int n_services = lp_numservices(); + + len = MIN(len,sizeof(drivername)-1); + strncpy(drivername, buf, len); + + DEBUG(10,("do_drv_upgrade_printer: Got message for new driver [%s]\n", drivername )); + + /* Iterate the printer list */ + + for (snum=0; snuminfo_2 && !strcmp(drivername, printer->info_2->drivername)) + { + DEBUG(6,("Updating printer [%s]\n", printer->info_2->printername)); + + /* all we care about currently is the change_id */ + + result = mod_a_printer(*printer, 2); + if (!W_ERROR_IS_OK(result)) { + DEBUG(3,("do_drv_upgrade_printer: mod_a_printer() failed with status [%s]\n", + dos_errstr(result))); + } + } + + free_a_printer(&printer, 2); + } + } + + /* all done */ +} /******************************************************************** Copy routines used by convert_to_openprinterex() @@ -924,16 +1126,6 @@ Can't find printer handle we created for printer %s\n", name )); return WERR_INVALID_PRINTER_NAME; } -/* - if (printer_default->datatype_ptr != NULL) - { - unistr2_to_ascii(datatype, printer_default->datatype, sizeof(datatype)-1); - set_printer_hnd_datatype(handle, datatype); - } - else - set_printer_hnd_datatype(handle, ""); -*/ - /* First case: the user is opening the print server: @@ -997,7 +1189,7 @@ Can't find printer handle we created for printer %s\n", name )); user_in_list(uidtoname(user.uid), lp_printer_admin(snum))) return WERR_OK; - + close_printer_handle(p, handle); return WERR_ACCESS_DENIED; } @@ -1031,7 +1223,9 @@ Can't find printer handle we created for printer %s\n", name )); printer_default->access_required = PRINTER_ACCESS_USE; } - if (!print_access_check(&user, snum, printer_default->access_required)) { + /* check smb.conf parameters and the the sec_desc */ + + if (!user_ok(uidtoname(user.uid), snum) || !print_access_check(&user, snum, printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); close_printer_handle(p, handle); return WERR_ACCESS_DENIED; @@ -1308,10 +1502,6 @@ WERROR _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL update_c_setprinter(False); - if (W_ERROR_IS_OK(result)) { - srv_spoolss_sendnotify(Printer->dev.handlename, 0, PRINTER_CHANGE_DELETE_PRINTER, 0x0); - } - return result; } @@ -1344,26 +1534,17 @@ static int get_version_id (char * arch) /******************************************************************** * _spoolss_deleteprinterdriver - * - * We currently delete the driver for the architecture only. - * This can leave the driver for other archtectures. However, - * since every printer associates a "Windows NT x86" driver name - * and we cannot delete that one while it is in use, **and** since - * it is impossible to assign a driver to a Samba printer without - * having the "Windows NT x86" driver installed,... - * - * ....we should not get into trouble here. - * - * --jerry ********************************************************************/ -WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER *q_u, - SPOOL_R_DELETEPRINTERDRIVER *r_u) +WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER *q_u, SPOOL_R_DELETEPRINTERDRIVER *r_u) { fstring driver; fstring arch; NT_PRINTER_DRIVER_INFO_LEVEL info; int version; + struct current_user user; + + get_current_user(&user, p); unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)-1 ); unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)-1 ); @@ -1373,21 +1554,89 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER /* this is what NT returns */ return WERR_INVALID_ENVIRONMENT; } + + /* if they said "Windows NT x86", then try for version 2 & 3 */ + + if ( version == 2 ) + version = DRIVER_ANY_VERSION; ZERO_STRUCT(info); - if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) { + + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) return WERR_UNKNOWN_PRINTER_DRIVER; - } + if (printer_driver_in_use(info.info_3)) + return WERR_PRINTER_DRIVER_IN_USE; - if (printer_driver_in_use(arch, driver)) - { + return delete_printer_driver(info.info_3, &user, DRIVER_ANY_VERSION, False); +} + +/******************************************************************** + * spoolss_deleteprinterdriverex + ********************************************************************/ + +WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVEREX *q_u, SPOOL_R_DELETEPRINTERDRIVEREX *r_u) +{ + fstring driver; + fstring arch; + NT_PRINTER_DRIVER_INFO_LEVEL info; + int version; + uint32 flags = q_u->delete_flags; + BOOL delete_files; + struct current_user user; + + get_current_user(&user, p); + + unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)-1 ); + unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)-1 ); + + /* check that we have a valid driver name first */ + if ((version=get_version_id(arch)) == -1) { + /* this is what NT returns */ + return WERR_INVALID_ENVIRONMENT; + } + + if ( flags & DPD_DELETE_SPECIFIC_VERSION ) + version = q_u->version; + else if ( version == 2 ) + /* if they said "Windows NT x86", then try for version 2 & 3 */ + version = DRIVER_ANY_VERSION; + + ZERO_STRUCT(info); + + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) + return WERR_UNKNOWN_PRINTER_DRIVER; + + if ( printer_driver_in_use(info.info_3) ) return WERR_PRINTER_DRIVER_IN_USE; + + /* + * we have a couple of cases to consider. + * (1) Are any files in use? If so and DPD_DELTE_ALL_FILE is set, + * then the delete should fail if **any** files overlap with + * other drivers + * (2) If DPD_DELTE_UNUSED_FILES is sert, then delete all + * non-overlapping files + * (3) If neither DPD_DELTE_ALL_FILE nor DPD_DELTE_ALL_FILES + * is set, the do not delete any files + * Refer to MSDN docs on DeletePrinterDriverEx() for details. + */ + + delete_files = flags & (DPD_DELETE_ALL_FILES|DPD_DELETE_UNUSED_FILES); + + if ( delete_files ) + { + /* fail if any files are in use and DPD_DELETE_ALL_FILES is set */ + + if ( printer_driver_files_in_use(info.info_3) & (flags&DPD_DELETE_ALL_FILES) ) + /* no idea of the correct error here */ + return WERR_ACCESS_DENIED; } - return delete_printer_driver(info.info_3); + return delete_printer_driver(info.info_3, &user, version, delete_files); } + /******************************************************************** GetPrinterData on a printer server Handle. ********************************************************************/ @@ -1438,7 +1687,11 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return False; +#ifndef EMULATE_WIN2K_HACK /* JERRY */ SIVAL(*data, 0, 2); +#else + SIVAL(*data, 0, 3); +#endif *needed = 0x4; return True; } @@ -1574,36 +1827,126 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO DEBUG(2,("_spoolss_getprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } - - unistr2_to_ascii(value, valuename, sizeof(value)-1); - - if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) - found=getprinterdata_printer_server(p->mem_ctx, value, type, data, needed, *out_size); - else - found= getprinterdata_printer(p, p->mem_ctx, handle, value, type, data, needed, *out_size); + + unistr2_to_ascii(value, valuename, sizeof(value)-1); + + if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + found=getprinterdata_printer_server(p->mem_ctx, value, type, data, needed, *out_size); + else + found= getprinterdata_printer(p, p->mem_ctx, handle, value, type, data, needed, *out_size); + + if (found==False) { + DEBUG(5, ("value not found, allocating %d\n", *out_size)); + /* reply this param doesn't exist */ + if (*out_size) { + if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) + return WERR_NOMEM; + } else { + *data = NULL; + } + + /* error depends on handle type */ + + if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + return WERR_INVALID_PARAM; + else + return WERR_BADFILE; + } + + if (*needed > *out_size) + return WERR_MORE_DATA; + else + return WERR_OK; +} + +/********************************************************* + Connect to the client machine. +**********************************************************/ + +static BOOL spoolss_connect_to_client(struct cli_state *the_cli, char *remote_machine) +{ + extern pstring global_myname; + + ZERO_STRUCTP(the_cli); + if(cli_initialise(the_cli) == NULL) { + DEBUG(0,("connect_to_client: unable to initialize client connection.\n")); + return False; + } + + if(!resolve_name( remote_machine, &the_cli->dest_ip, 0x20)) { + DEBUG(0,("connect_to_client: Can't resolve address for %s\n", remote_machine)); + cli_shutdown(the_cli); + return False; + } + + if (ismyip(the_cli->dest_ip)) { + DEBUG(0,("connect_to_client: Machine %s is one of our addresses. Cannot add to ourselves.\n", remote_machine)); + cli_shutdown(the_cli); + return False; + } + + if (!cli_connect(the_cli, remote_machine, &the_cli->dest_ip)) { + DEBUG(0,("connect_to_client: unable to connect to SMB server on machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + cli_shutdown(the_cli); + return False; + } + + if (!attempt_netbios_session_request(the_cli, global_myname, remote_machine, &the_cli->dest_ip)) { + DEBUG(0,("connect_to_client: machine %s rejected the NetBIOS session request.\n", + remote_machine)); + return False; + } + + the_cli->protocol = PROTOCOL_NT1; + + if (!cli_negprot(the_cli)) { + DEBUG(0,("connect_to_client: machine %s rejected the negotiate protocol. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + cli_shutdown(the_cli); + return False; + } + + if (the_cli->protocol != PROTOCOL_NT1) { + DEBUG(0,("connect_to_client: machine %s didn't negotiate NT protocol.\n", remote_machine)); + cli_shutdown(the_cli); + return False; + } + + /* + * Do an anonymous session setup. + */ + + if (!cli_session_setup(the_cli, "", "", 0, "", 0, "")) { + DEBUG(0,("connect_to_client: machine %s rejected the session setup. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + cli_shutdown(the_cli); + return False; + } + + if (!(the_cli->sec_mode & 1)) { + DEBUG(0,("connect_to_client: machine %s isn't in user level security mode\n", remote_machine)); + cli_shutdown(the_cli); + return False; + } + + if (!cli_send_tconX(the_cli, "IPC$", "IPC", "", 1)) { + DEBUG(0,("connect_to_client: machine %s rejected the tconX on the IPC$ share. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + cli_shutdown(the_cli); + return False; + } - if (found==False) { - DEBUG(5, ("value not found, allocating %d\n", *out_size)); - /* reply this param doesn't exist */ - if (*out_size) { - if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) - return WERR_NOMEM; - } else { - *data = NULL; - } + /* + * Ok - we have an anonymous connection to the IPC$ share. + * Now start the NT Domain stuff :-). + */ - /* error depends on handle type */ + if(cli_nt_session_open(the_cli, PIPE_SPOOLSS) == False) { + DEBUG(0,("connect_to_client: unable to open the domain client session to machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli))); + cli_nt_session_close(the_cli); + cli_ulogoff(the_cli); + cli_shutdown(the_cli); + return False; + } - if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) - return WERR_INVALID_PARAM; - else - return WERR_BADFILE; - } - - if (*needed > *out_size) - return WERR_MORE_DATA; - else - return WERR_OK; + return True; } /*************************************************************************** @@ -1626,15 +1969,14 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin if(!spoolss_connect_to_client(&cli, unix_printer)) return False; - message_register(MSG_PRINTER_NOTIFY, srv_spoolss_receive_message); - + message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message); } smb_connections++; result = cli_spoolss_reply_open_printer(&cli, cli.mem_ctx, printer, localprinter, type, handle); - + if (!W_ERROR_IS_OK(result)) DEBUG(5,("srv_spoolss_reply_open_printer: Client RPC returned [%s]\n", dos_errstr(result))); @@ -1646,9 +1988,8 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin * _spoolss_rffpcnex * ReplyFindFirstPrinterChangeNotifyEx * - * jfmxxxx: before replying OK: status=0 - * should do a rpc call to the workstation asking ReplyOpenPrinter - * have to code it, later. + * before replying OK: status=0 a rpc call is made to the workstation + * asking ReplyOpenPrinter * * in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe * called from api_spoolss_rffpcnex @@ -1681,15 +2022,17 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE Printer->notify.option=dup_spool_notify_option(option); - unistr2_to_ascii(Printer->notify.localmachine, localmachine, sizeof(Printer->notify.localmachine)-1); + unistr2_to_ascii(Printer->notify.localmachine, localmachine, + sizeof(Printer->notify.localmachine)-1); + + /* Connect to the client machine and send a ReplyOpenPrinter */ - /* connect to the client machine and send a ReplyOpenPrinter */ - if(srv_spoolss_replyopenprinter(Printer->notify.localmachine, + if(!srv_spoolss_replyopenprinter(Printer->notify.localmachine, Printer->notify.printerlocal, 1, &Printer->notify.client_hnd)) - { - Printer->notify.client_connected=True; - } + return WERR_SERVER_UNAVAILABLE; + + Printer->notify.client_connected=True; return WERR_OK; } @@ -1711,7 +2054,7 @@ void spoolss_notify_server_name(int snum, len = rpcstr_push(temp, temp_name, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1746,7 +2089,7 @@ void spoolss_notify_printer_name(int snum, len = rpcstr_push(temp, p, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1772,7 +2115,7 @@ void spoolss_notify_share_name(int snum, len = rpcstr_push(temp, lp_servicename(snum), sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1800,7 +2143,7 @@ void spoolss_notify_port_name(int snum, len = rpcstr_push(temp, printer->info_2->portname, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1826,7 +2169,8 @@ void spoolss_notify_driver_name(int snum, uint32 len; len = rpcstr_push(temp, printer->info_2->drivername, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1855,7 +2199,7 @@ void spoolss_notify_comment(int snum, else len = rpcstr_push(temp, printer->info_2->comment, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1882,7 +2226,7 @@ void spoolss_notify_location(int snum, len = rpcstr_push(temp, printer->info_2->location,sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1921,7 +2265,7 @@ void spoolss_notify_sepfile(int snum, len = rpcstr_push(temp, printer->info_2->sepfile, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1948,7 +2292,7 @@ void spoolss_notify_print_processor(int snum, len = rpcstr_push(temp, printer->info_2->printprocessor, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -1975,7 +2319,7 @@ void spoolss_notify_parameters(int snum, len = rpcstr_push(temp, printer->info_2->parameters, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -2002,7 +2346,7 @@ void spoolss_notify_datatype(int snum, len = rpcstr_push(temp, printer->info_2->datatype, sizeof(pstring)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -2162,7 +2506,7 @@ static void spoolss_notify_username(int snum, len = rpcstr_push(temp, queue->fs_user, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -2202,7 +2546,7 @@ static void spoolss_notify_job_name(int snum, len = rpcstr_push(temp, queue->fs_file, sizeof(temp)-2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -2252,7 +2596,7 @@ static void spoolss_notify_job_status_string(int snum, len = rpcstr_push(temp, p, sizeof(temp) - 2, STR_TERMINATE); - data->notify_data.data.length = len / 2 - 1; + data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); if (!data->notify_data.data.string) { @@ -2376,8 +2720,6 @@ static void spoolss_notify_submitted_time(int snum, SSVAL(p, 14, st.milliseconds); } -#define END 65535 - struct s_notify_info_data_table { uint16 type; @@ -2389,59 +2731,61 @@ struct s_notify_info_data_table NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx); }; +/* A table describing the various print notification constants and + whether the notification data is a pointer to a variable sized + buffer, a one value uint32 or a two value uint32. */ + struct s_notify_info_data_table notify_info_data_table[] = { -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", POINTER, spoolss_notify_server_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, "PRINTER_NOTIFY_PRINTER_NAME", POINTER, spoolss_notify_printer_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SHARE_NAME, "PRINTER_NOTIFY_SHARE_NAME", POINTER, spoolss_notify_share_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PORT_NAME, "PRINTER_NOTIFY_PORT_NAME", POINTER, spoolss_notify_port_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DRIVER_NAME, "PRINTER_NOTIFY_DRIVER_NAME", POINTER, spoolss_notify_driver_name }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_COMMENT, "PRINTER_NOTIFY_COMMENT", POINTER, spoolss_notify_comment }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_LOCATION, "PRINTER_NOTIFY_LOCATION", POINTER, spoolss_notify_location }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEVMODE, "PRINTER_NOTIFY_DEVMODE", POINTER, spoolss_notify_devmode }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SEPFILE, "PRINTER_NOTIFY_SEPFILE", POINTER, spoolss_notify_sepfile }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINT_PROCESSOR, "PRINTER_NOTIFY_PRINT_PROCESSOR", POINTER, spoolss_notify_print_processor }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PARAMETERS, "PRINTER_NOTIFY_PARAMETERS", POINTER, spoolss_notify_parameters }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DATATYPE, "PRINTER_NOTIFY_DATATYPE", POINTER, spoolss_notify_datatype }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SECURITY_DESCRIPTOR, "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", POINTER, spoolss_notify_security_desc }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_ATTRIBUTES, "PRINTER_NOTIFY_ATTRIBUTES", ONE_VALUE, spoolss_notify_attributes }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRIORITY, "PRINTER_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEFAULT_PRIORITY, "PRINTER_NOTIFY_DEFAULT_PRIORITY", ONE_VALUE, spoolss_notify_default_priority }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_START_TIME, "PRINTER_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_UNTIL_TIME, "PRINTER_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS, "PRINTER_NOTIFY_STATUS", ONE_VALUE, spoolss_notify_status }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS_STRING, "PRINTER_NOTIFY_STATUS_STRING", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_CJOBS, "PRINTER_NOTIFY_CJOBS", ONE_VALUE, spoolss_notify_cjobs }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_AVERAGE_PPM, "PRINTER_NOTIFY_AVERAGE_PPM", ONE_VALUE, spoolss_notify_average_ppm }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_PAGES, "PRINTER_NOTIFY_TOTAL_PAGES", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PAGES_PRINTED, "PRINTER_NOTIFY_PAGES_PRINTED", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_BYTES, "PRINTER_NOTIFY_TOTAL_BYTES", POINTER, NULL }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_BYTES_PRINTED, "PRINTER_NOTIFY_BYTES_PRINTED", POINTER, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINTER_NAME, "JOB_NOTIFY_PRINTER_NAME", POINTER, spoolss_notify_printer_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_MACHINE_NAME, "JOB_NOTIFY_MACHINE_NAME", POINTER, spoolss_notify_server_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PORT_NAME, "JOB_NOTIFY_PORT_NAME", POINTER, spoolss_notify_port_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_USER_NAME, "JOB_NOTIFY_USER_NAME", POINTER, spoolss_notify_username }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_NOTIFY_NAME, "JOB_NOTIFY_NOTIFY_NAME", POINTER, spoolss_notify_username }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DATATYPE, "JOB_NOTIFY_DATATYPE", POINTER, spoolss_notify_datatype }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINT_PROCESSOR, "JOB_NOTIFY_PRINT_PROCESSOR", POINTER, spoolss_notify_print_processor }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PARAMETERS, "JOB_NOTIFY_PARAMETERS", POINTER, spoolss_notify_parameters }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DRIVER_NAME, "JOB_NOTIFY_DRIVER_NAME", POINTER, spoolss_notify_driver_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DEVMODE, "JOB_NOTIFY_DEVMODE", POINTER, spoolss_notify_devmode }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS, "JOB_NOTIFY_STATUS", ONE_VALUE, spoolss_notify_job_status }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS_STRING, "JOB_NOTIFY_STATUS_STRING", POINTER, spoolss_notify_job_status_string }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SECURITY_DESCRIPTOR, "JOB_NOTIFY_SECURITY_DESCRIPTOR", POINTER, NULL }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DOCUMENT, "JOB_NOTIFY_DOCUMENT", POINTER, spoolss_notify_job_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRIORITY, "JOB_NOTIFY_PRIORITY", ONE_VALUE, spoolss_notify_priority }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_POSITION, "JOB_NOTIFY_POSITION", ONE_VALUE, spoolss_notify_job_position }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SUBMITTED, "JOB_NOTIFY_SUBMITTED", POINTER, spoolss_notify_submitted_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_START_TIME, "JOB_NOTIFY_START_TIME", ONE_VALUE, spoolss_notify_start_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_UNTIL_TIME, "JOB_NOTIFY_UNTIL_TIME", ONE_VALUE, spoolss_notify_until_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TIME, "JOB_NOTIFY_TIME", ONE_VALUE, spoolss_notify_job_time }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", ONE_VALUE, spoolss_notify_total_pages }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", ONE_VALUE, spoolss_notify_pages_printed }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_BYTES, "JOB_NOTIFY_TOTAL_BYTES", ONE_VALUE, spoolss_notify_job_size }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_BYTES_PRINTED, "JOB_NOTIFY_BYTES_PRINTED", ONE_VALUE, NULL }, -{ END, END, "", END, NULL } +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", NOTIFY_STRING, spoolss_notify_server_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, "PRINTER_NOTIFY_PRINTER_NAME", NOTIFY_STRING, spoolss_notify_printer_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SHARE_NAME, "PRINTER_NOTIFY_SHARE_NAME", NOTIFY_STRING, spoolss_notify_share_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PORT_NAME, "PRINTER_NOTIFY_PORT_NAME", NOTIFY_STRING, spoolss_notify_port_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DRIVER_NAME, "PRINTER_NOTIFY_DRIVER_NAME", NOTIFY_STRING, spoolss_notify_driver_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_COMMENT, "PRINTER_NOTIFY_COMMENT", NOTIFY_STRING, spoolss_notify_comment }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_LOCATION, "PRINTER_NOTIFY_LOCATION", NOTIFY_STRING, spoolss_notify_location }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEVMODE, "PRINTER_NOTIFY_DEVMODE", NOTIFY_POINTER, spoolss_notify_devmode }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SEPFILE, "PRINTER_NOTIFY_SEPFILE", NOTIFY_STRING, spoolss_notify_sepfile }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINT_PROCESSOR, "PRINTER_NOTIFY_PRINT_PROCESSOR", NOTIFY_STRING, spoolss_notify_print_processor }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PARAMETERS, "PRINTER_NOTIFY_PARAMETERS", NOTIFY_STRING, spoolss_notify_parameters }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DATATYPE, "PRINTER_NOTIFY_DATATYPE", NOTIFY_STRING, spoolss_notify_datatype }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SECURITY_DESCRIPTOR, "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", NOTIFY_POINTER, spoolss_notify_security_desc }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_ATTRIBUTES, "PRINTER_NOTIFY_ATTRIBUTES", NOTIFY_ONE_VALUE, spoolss_notify_attributes }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRIORITY, "PRINTER_NOTIFY_PRIORITY", NOTIFY_ONE_VALUE, spoolss_notify_priority }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEFAULT_PRIORITY, "PRINTER_NOTIFY_DEFAULT_PRIORITY", NOTIFY_ONE_VALUE, spoolss_notify_default_priority }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_START_TIME, "PRINTER_NOTIFY_START_TIME", NOTIFY_ONE_VALUE, spoolss_notify_start_time }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_UNTIL_TIME, "PRINTER_NOTIFY_UNTIL_TIME", NOTIFY_ONE_VALUE, spoolss_notify_until_time }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS, "PRINTER_NOTIFY_STATUS", NOTIFY_ONE_VALUE, spoolss_notify_status }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_STATUS_STRING, "PRINTER_NOTIFY_STATUS_STRING", NOTIFY_POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_CJOBS, "PRINTER_NOTIFY_CJOBS", NOTIFY_ONE_VALUE, spoolss_notify_cjobs }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_AVERAGE_PPM, "PRINTER_NOTIFY_AVERAGE_PPM", NOTIFY_ONE_VALUE, spoolss_notify_average_ppm }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_PAGES, "PRINTER_NOTIFY_TOTAL_PAGES", NOTIFY_POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PAGES_PRINTED, "PRINTER_NOTIFY_PAGES_PRINTED", NOTIFY_POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_BYTES, "PRINTER_NOTIFY_TOTAL_BYTES", NOTIFY_POINTER, NULL }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_BYTES_PRINTED, "PRINTER_NOTIFY_BYTES_PRINTED", NOTIFY_POINTER, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINTER_NAME, "JOB_NOTIFY_PRINTER_NAME", NOTIFY_STRING, spoolss_notify_printer_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_MACHINE_NAME, "JOB_NOTIFY_MACHINE_NAME", NOTIFY_STRING, spoolss_notify_server_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PORT_NAME, "JOB_NOTIFY_PORT_NAME", NOTIFY_STRING, spoolss_notify_port_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_USER_NAME, "JOB_NOTIFY_USER_NAME", NOTIFY_STRING, spoolss_notify_username }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_NOTIFY_NAME, "JOB_NOTIFY_NOTIFY_NAME", NOTIFY_STRING, spoolss_notify_username }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DATATYPE, "JOB_NOTIFY_DATATYPE", NOTIFY_STRING, spoolss_notify_datatype }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINT_PROCESSOR, "JOB_NOTIFY_PRINT_PROCESSOR", NOTIFY_STRING, spoolss_notify_print_processor }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PARAMETERS, "JOB_NOTIFY_PARAMETERS", NOTIFY_STRING, spoolss_notify_parameters }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DRIVER_NAME, "JOB_NOTIFY_DRIVER_NAME", NOTIFY_STRING, spoolss_notify_driver_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DEVMODE, "JOB_NOTIFY_DEVMODE", NOTIFY_POINTER, spoolss_notify_devmode }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS, "JOB_NOTIFY_STATUS", NOTIFY_ONE_VALUE, spoolss_notify_job_status }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_STATUS_STRING, "JOB_NOTIFY_STATUS_STRING", NOTIFY_STRING, spoolss_notify_job_status_string }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SECURITY_DESCRIPTOR, "JOB_NOTIFY_SECURITY_DESCRIPTOR", NOTIFY_POINTER, NULL }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_DOCUMENT, "JOB_NOTIFY_DOCUMENT", NOTIFY_STRING, spoolss_notify_job_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PRIORITY, "JOB_NOTIFY_PRIORITY", NOTIFY_ONE_VALUE, spoolss_notify_priority }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_POSITION, "JOB_NOTIFY_POSITION", NOTIFY_ONE_VALUE, spoolss_notify_job_position }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_SUBMITTED, "JOB_NOTIFY_SUBMITTED", NOTIFY_POINTER, spoolss_notify_submitted_time }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_START_TIME, "JOB_NOTIFY_START_TIME", NOTIFY_ONE_VALUE, spoolss_notify_start_time }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_UNTIL_TIME, "JOB_NOTIFY_UNTIL_TIME", NOTIFY_ONE_VALUE, spoolss_notify_until_time }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TIME, "JOB_NOTIFY_TIME", NOTIFY_ONE_VALUE, spoolss_notify_job_time }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", NOTIFY_ONE_VALUE, spoolss_notify_total_pages }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", NOTIFY_ONE_VALUE, spoolss_notify_pages_printed }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_BYTES, "JOB_NOTIFY_TOTAL_BYTES", NOTIFY_ONE_VALUE, spoolss_notify_job_size }, }; /******************************************************************* @@ -2452,43 +2796,46 @@ static uint32 size_of_notify_info_data(uint16 type, uint16 field) { int i=0; - while (notify_info_data_table[i].type != END) - { - if ( (notify_info_data_table[i].type == type ) && - (notify_info_data_table[i].field == field ) ) - { - return (notify_info_data_table[i].size); + for (i = 0; i < sizeof(notify_info_data_table); i++) { + if (notify_info_data_table[i].type == type && + notify_info_data_table[i].field == field) { + switch(notify_info_data_table[i].size) { + case NOTIFY_ONE_VALUE: + case NOTIFY_TWO_VALUE: + return 1; + case NOTIFY_STRING: + return 2; + + /* The only pointer notify data I have seen on + the wire is the submitted time and this has + the notify size set to 4. -tpot */ + + case NOTIFY_POINTER: + return 4; + } } - i++; } - return (65535); + + DEBUG(5, ("invalid notify data type %d/%d\n", type, field)); + + return 0; } /******************************************************************* Return the type of notify_info_data. ********************************************************************/ -static BOOL type_of_notify_info_data(uint16 type, uint16 field) +static int type_of_notify_info_data(uint16 type, uint16 field) { int i=0; - while (notify_info_data_table[i].type != END) - { - if ( (notify_info_data_table[i].type == type ) && - (notify_info_data_table[i].field == field ) ) - { - if (notify_info_data_table[i].size == POINTER) - { - return (False); - } - else - { - return (True); - } - } - i++; + for (i = 0; i < sizeof(notify_info_data_table); i++) { + if (notify_info_data_table[i].type == type && + notify_info_data_table[i].field == field) + return notify_info_data_table[i].size; } - return (False); + + return False; } /**************************************************************************** @@ -2496,21 +2843,18 @@ static BOOL type_of_notify_info_data(uint16 type, uint16 field) static int search_notify(uint16 type, uint16 field, int *value) { - int j; - BOOL found; + int i; - for (j=0, found=False; found==False && notify_info_data_table[j].type != END ; j++) - { - if ( (notify_info_data_table[j].type == type ) && - (notify_info_data_table[j].field == field ) ) - found=True; + for (i = 0; i < sizeof(notify_info_data_table); i++) { + if (notify_info_data_table[i].type == type && + notify_info_data_table[i].field == field && + notify_info_data_table[i].fn != NULL) { + *value = i; + return True; + } } - *value=--j; - - if ( found && (notify_info_data_table[j].fn != NULL) ) - return True; - else - return False; + + return False; } /**************************************************************************** @@ -2521,7 +2865,12 @@ void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 info_data->type = type; info_data->field = field; info_data->reserved = 0; - info_data->id = id; + + if (type == JOB_NOTIFY_TYPE) + info_data->id = id; + else + info_data->id = 0; + info_data->size = size_of_notify_info_data(type, field); info_data->enc_type = type_of_notify_info_data(type, field); } @@ -2570,7 +2919,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int current_data=&info->data[info->count]; - construct_info_data(current_data, type, field, id); + construct_info_data(current_data, type, field, id); DEBUG(10,("construct_notify_printer_info: calling [%s] snum=%d printername=[%s])\n", notify_info_data_table[j].name, snum, printer->info_2->printername )); @@ -2812,7 +3161,6 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCNEX *r_u) { POLICY_HND *handle = &q_u->handle; -/* uint32 change = q_u->change; - notused. */ /* SPOOL_NOTIFY_OPTION *option = q_u->option; - notused. */ SPOOL_NOTIFY_INFO *info = &r_u->info; @@ -2830,17 +3178,19 @@ WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN DEBUG(4,("Printer type %x\n",Printer->printer_type)); - /* jfm: the change value isn't used right now. - * we will honour it when - * a) we'll be able to send notification to the client - * b) we'll have a way to communicate between the spoolss process. - * - * same thing for option->flags + /* + * We are now using the change value, and * I should check for PRINTER_NOTIFY_OPTIONS_REFRESH but as * I don't have a global notification system, I'm sending back all the * informations even when _NOTHING_ has changed. */ + /* We need to keep track of the change value to send back in + RRPCN replies otherwise our updates are ignored. */ + + if (Printer->notify.client_connected) + Printer->notify.change = q_u->change; + /* just ignore the SPOOL_NOTIFY_OPTION */ switch (Printer->printer_type) { @@ -2932,7 +3282,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) printer->global_counter = global_counter; printer->total_pages = 0; -#if 0 /* JERRY */ +#ifndef EMULATE_WIN2K_HACK /* JERRY */ printer->major_version = 0x0004; /* NT 4 */ printer->build_version = 0x0565; /* build 1381 */ #else @@ -2971,7 +3321,6 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum) * construct_printer_info_1 * fill a printer_info_1 struct ********************************************************************/ - static BOOL construct_printer_info_1(uint32 flags, PRINTER_INFO_1 *printer, int snum) { pstring chaine; @@ -3046,8 +3395,10 @@ static DEVICEMODE *construct_dev_mode(int snum) if (printer->info_2->devmode) ntdevmode = dup_nt_devicemode(printer->info_2->devmode); - if (ntdevmode == NULL) + if (ntdevmode == NULL) { + DEBUG(5, ("BONG! There was no device mode!\n")); goto fail; + } DEBUGADD(8,("loading DEVICEMODE\n")); @@ -3408,10 +3759,26 @@ static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, enum_all_printers_info_1_network. *********************************************************************/ -static WERROR enum_all_printers_info_1_network(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enum_all_printers_info_1_network(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { + char *s = name; + DEBUG(4,("enum_all_printers_info_1_network\n")); + /* If we respond to a enum_printers level 1 on our name with flags + set to PRINTER_ENUM_REMOTE with a list of printers then these + printers incorrectly appear in the APW browse list. + Specifically the printers for the server appear at the workgroup + level where all the other servers in the domain are + listed. Windows responds to this call with a + WERR_CAN_NOT_COMPLETE so we should do the same. */ + + if (name[0] == '\\' && name[1] == '\\') + s = name + 2; + + if (is_myname_or_ipaddr(s)) + return WERR_CAN_NOT_COMPLETE; + return enum_all_printers_info_1(PRINTER_ENUM_UNKNOWN_8, buffer, offered, needed, returned); } @@ -3449,9 +3816,9 @@ static WERROR enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint3 } /* check the required size. */ - for (i=0; i<*returned; i++) + for (i=0; i<*returned; i++) (*needed) += spoolss_size_printer_info_2(&printers[i]); - + if (!alloc_buffer_size(buffer, *needed)) { for (i=0; i<*returned; i++) { free_devmode(printers[i].devmode); @@ -3498,7 +3865,7 @@ static WERROR enumprinters_level1( uint32 flags, fstring name, return enum_all_printers_info_1_remote(name, buffer, offered, needed, returned); if (flags & PRINTER_ENUM_NETWORK) - return enum_all_printers_info_1_network(buffer, offered, needed, returned); + return enum_all_printers_info_1_network(name, buffer, offered, needed, returned); return WERR_OK; /* NT4sp5 does that */ } @@ -3681,7 +4048,7 @@ static WERROR getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, u /* check the required size. */ *needed += spoolss_size_printer_info_2(printer); - + if (!alloc_buffer_size(buffer, *needed)) { free_printer_info_2(printer); return WERR_INSUFFICIENT_BUFFER; @@ -4728,6 +5095,7 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) { + extern userdom_struct current_user_info; char *cmd = lp_addprinter_cmd(); char **qlines; pstring command; @@ -4742,13 +5110,13 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) get_called_name()); /* change \ to \\ for the shell */ all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring)); - + standard_sub_basic(current_user_info.smb_name, remote_machine,sizeof(remote_machine)); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", cmd, printer->info_2->printername, printer->info_2->sharename, printer->info_2->portname, printer->info_2->drivername, printer->info_2->location, driverlocation, remote_machine); - /* Convert script args to unix-codepage */ DEBUG(10,("Running [%s]\n", command)); ret = smbrun(command, &fd); DEBUGADD(10,("returned [%d]\n", ret)); @@ -5039,13 +5407,10 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, int snum; NT_PRINTER_INFO_LEVEL *printer = NULL, *old_printer = NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - PRINTER_MESSAGE_INFO msg; WERROR result; DEBUG(8,("update_printer\n")); - - ZERO_STRUCT(msg); - + result = WERR_OK; if (level!=2) { @@ -5159,8 +5524,11 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, * bound to the printer, simulating what happens in the Windows arch. */ if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)){ - set_driver_init(printer, 2); - msg.flags |= PRINTER_MESSAGE_DRIVER; + if (!set_driver_init(printer, 2)) { + DEBUG(5,("update_printer: Error restoring driver initialization data for driver [%s]!\n", + printer->info_2->drivername)); + } + notify_printer_driver(snum, printer->info_2->drivername); } } @@ -5171,28 +5539,18 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, all the possible changes */ if (!strequal(printer->info_2->comment, old_printer->info_2->comment)) - msg.flags |= PRINTER_MESSAGE_COMMENT; + notify_printer_comment(snum, printer->info_2->comment); if (!strequal(printer->info_2->sharename, old_printer->info_2->sharename)) - msg.flags |= PRINTER_MESSAGE_SHARENAME; + notify_printer_sharename(snum, printer->info_2->sharename); if (!strequal(printer->info_2->portname, old_printer->info_2->portname)) - msg.flags |= PRINTER_MESSAGE_PORT; + notify_printer_port(snum, printer->info_2->portname); if (!strequal(printer->info_2->location, old_printer->info_2->location)) - msg.flags |= PRINTER_MESSAGE_LOCATION; - - ZERO_STRUCT(msg); - - msg.low = PRINTER_CHANGE_ADD_PRINTER; - fstrcpy(msg.printer_name, printer->info_2->printername); - - /* only send a notify if something changed */ - if (msg.flags) { - srv_spoolss_sendnotify(msg.printer_name, 0, PRINTER_CHANGE_ADD_PRINTER, msg.flags); - } + notify_printer_location(snum, printer->info_2->location); - done: +done: free_a_printer(&printer, 2); free_a_printer(&old_printer, 2); @@ -5310,7 +5668,7 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, int position, int snum, - NT_PRINTER_INFO_LEVEL *ntprinter, + NT_PRINTER_INFO_LEVEL *ntprinter, DEVICEMODE *devmode) { pstring temp_name; @@ -5427,7 +5785,7 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, *returned = 0; goto done; } - + if (!(devmode = construct_dev_mode(snum))) { *returned = 0; result = WERR_NOMEM; @@ -5470,6 +5828,7 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, SAFE_FREE(info); return result; + } /**************************************************************************** @@ -5538,8 +5897,6 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u { POLICY_HND *handle = &q_u->handle; uint32 jobid = q_u->jobid; -/* uint32 level = q_u->level; - notused. */ -/* JOB_INFO *ctr = &q_u->ctr; - notused. */ uint32 command = q_u->command; struct current_user user; @@ -5597,9 +5954,7 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture *returned=0; -#define MAX_VERSION 4 - - for (version=0; versioninfo_2->printername, 0, PRINTER_CHANGE_ADD_PRINTER, 0x0); - free_a_printer(&printer,2); return WERR_OK; @@ -6462,10 +6810,12 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, WERROR err = WERR_OK; NT_PRINTER_DRIVER_INFO_LEVEL driver; struct current_user user; - + fstring driver_name; + uint32 version; + ZERO_STRUCT(driver); - get_current_user(&user, p); + get_current_user(&user, p); if (!convert_printer_driver_info(info, &driver, level)) { err = WERR_NOMEM; @@ -6489,11 +6839,131 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, goto done; } - done: + /* BEGIN_ADMIN_LOG */ + switch(level) { + case 3: + sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", + driver.info_3->name,drv_ver_to_os[driver.info_3->cversion],uidtoname(user.uid)); + fstrcpy(driver_name, driver.info_3->name); + break; + case 6: + sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", + driver.info_6->name,drv_ver_to_os[driver.info_6->version],uidtoname(user.uid)); + fstrcpy(driver_name, driver.info_6->name); + break; + } + /* END_ADMIN_LOG */ + + /* + * I think this is where he DrvUpgradePrinter() hook would be + * be called in a driver's interface DLL on a Windows NT 4.0/2k + * server. Right now, we just need to send ourselves a message + * to update each printer bound to this driver. --jerry + */ + + if (!srv_spoolss_drv_upgrade_printer(driver_name)) { + DEBUG(0,("_spoolss_addprinterdriver: Failed to send message about upgrading driver [%s]!\n", + driver_name)); + } + + /* + * Based on the version (e.g. driver destination dir: 0=9x,2=Nt/2k,3=2k/Xp), + * decide if the driver init data should be deleted. The rules are: + * 1) never delete init data if it is a 9x driver, they don't use it anyway + * 2) delete init data only if there is no 2k/Xp driver + * 3) always delete init data + * The generalized rule is always use init data from the highest order driver. + * It is necessary to follow the driver install by an initialization step to + * finish off this process. + */ + if (level == 3) + version = driver.info_3->cversion; + else if (level == 6) + version = driver.info_6->version; + else + version = -1; + switch (version) { + /* + * 9x printer driver - never delete init data + */ + case 0: + DEBUG(10,("_spoolss_addprinterdriver: init data not deleted for 9x driver [%s]\n", + driver_name)); + break; + + /* + * Nt or 2k (compatiblity mode) printer driver - only delete init data if + * there is no 2k/Xp driver init data for this driver name. + */ + case 2: + { + NT_PRINTER_DRIVER_INFO_LEVEL driver1; + + if (!W_ERROR_IS_OK(get_a_printer_driver(&driver1, 3, driver_name, "Windows NT x86", 3))) { + /* + * No 2k/Xp driver found, delete init data (if any) for the new Nt driver. + */ + if (!del_driver_init(driver_name)) + DEBUG(6,("_spoolss_addprinterdriver: del_driver_init(%s) Nt failed!\n", driver_name)); + } else { + /* + * a 2k/Xp driver was found, don't delete init data because Nt driver will use it. + */ + free_a_printer_driver(driver1,3); + DEBUG(10,("_spoolss_addprinterdriver: init data not deleted for Nt driver [%s]\n", + driver_name)); + } + } + break; + + /* + * 2k or Xp printer driver - always delete init data + */ + case 3: + if (!del_driver_init(driver_name)) + DEBUG(6,("_spoolss_addprinterdriver: del_driver_init(%s) 2k/Xp failed!\n", driver_name)); + break; + + default: + DEBUG(0,("_spoolss_addprinterdriver: invalid level=%d\n", level)); + break; + } + + +done: free_a_printer_driver(driver, level); return err; } +/******************************************************************** + * spoolss_addprinterdriverex + ********************************************************************/ + +WERROR _spoolss_addprinterdriverex(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVEREX *q_u, SPOOL_R_ADDPRINTERDRIVEREX *r_u) +{ + SPOOL_Q_ADDPRINTERDRIVER q_u_local; + SPOOL_R_ADDPRINTERDRIVER r_u_local; + + /* + * we only support the semantics of AddPrinterDriver() + * i.e. only copy files that are newer than existing ones + */ + + if ( q_u->copy_flags != APD_COPY_NEW_FILES ) + return WERR_ACCESS_DENIED; + + /* just pass the information off to _spoolss_addprinterdriver() */ + ZERO_STRUCT(q_u_local); + ZERO_STRUCT(r_u_local); + + q_u_local.server_name_ptr = q_u->server_name_ptr; + copy_unistr2(&q_u_local.server_name, &q_u->server_name); + q_u_local.level = q_u->level; + memcpy( &q_u_local.info, &q_u->info, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL) ); + + return _spoolss_addprinterdriver( p, &q_u_local, &r_u_local ); +} + /**************************************************************************** ****************************************************************************/ @@ -6632,23 +7102,6 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S if ( (in_value_len==0) && (in_data_len==0) ) { DEBUGADD(6,("Activating NT mega-hack to find sizes\n")); -#if 0 - /* - * NT can ask for a specific parameter size - we need to return NO_MORE_ITEMS - * if this parameter size doesn't exist. - * Ok - my opinion here is that the client is not asking for the greatest - * possible size of all the parameters, but is asking specifically for the size needed - * for this specific parameter. In that case we can remove the loop below and - * simplify this lookup code considerably. JF - comments welcome. JRA. - */ - - if (!get_specific_param_by_index(*printer, 2, idx, value, &data, &type, &data_len)) { - SAFE_FREE(data); - free_a_printer(&printer, 2); - return WERR_NO_MORE_ITEMS; - } -#endif - SAFE_FREE(data); param_index=0; @@ -6692,7 +7145,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S if((*out_value=(uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL) return WERR_NOMEM; - *out_value_len = rpcstr_push((char *)*out_value, "", in_value_len, 0); + *out_value_len = (uint32)rpcstr_push((char *)*out_value, "", in_value_len, 0); /* the data is counted in bytes */ *out_max_data_len = in_data_len; @@ -6720,7 +7173,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S return WERR_NOMEM; } - *out_value_len = rpcstr_push((char *)*out_value,value, in_value_len, 0); + *out_value_len = (uint32)rpcstr_push((char *)*out_value,value, in_value_len, 0); *out_type=type; @@ -6747,10 +7200,8 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP POLICY_HND *handle = &q_u->handle; UNISTR2 *value = &q_u->value; uint32 type = q_u->type; -/* uint32 max_len = q_u->max_len; - notused. */ uint8 *data = q_u->data; uint32 real_len = q_u->real_len; -/* uint32 numeric_data = q_u->numeric_data; - notused. */ NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_PARAM *param = NULL, old_param; @@ -7022,8 +7473,6 @@ done: WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM *r_u) { POLICY_HND *handle = &q_u->handle; -/* UNISTR2 *uni_name = &q_u->name; - notused. */ -/* uint32 level = q_u->level; - notused. */ FORM *form = &q_u->form; nt_forms_struct tmpForm; int snum; @@ -7114,12 +7563,10 @@ static WERROR enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, SPOOL_R_ENUMPRINTPROCESSORS *r_u) { -/* UNISTR2 *name = &q_u->name; - notused. */ -/* UNISTR2 *environment = &q_u->environment; - notused. */ uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; - uint32 *needed = &r_u->needed; + uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ @@ -7183,8 +7630,6 @@ static WERROR enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, WERROR _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u) { -/* UNISTR2 *name = &q_u->name; - notused. */ -/* UNISTR2 *processor = &q_u->processor; - notused. */ uint32 level = q_u->level; NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; @@ -7279,11 +7724,10 @@ static WERROR enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_u, SPOOL_R_ENUMPRINTMONITORS *r_u) { -/* UNISTR2 *name = &q_u->name; - notused. */ uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; - uint32 *needed = &r_u->needed; + uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ @@ -7427,7 +7871,7 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin free_job_info_2(info_2); /* Also frees devmode */ SAFE_FREE(info_2); free_a_printer(&ntprinter, 2); - + return ret; } @@ -7594,6 +8038,34 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, return _spoolss_setprinterdata(p, &q_u_local, &r_u_local); } + +/******************************************************************** + * spoolss_deleteprinterdataex + ********************************************************************/ + +WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX *q_u, SPOOL_R_DELETEPRINTERDATAEX *r_u) +{ + SPOOL_Q_DELETEPRINTERDATA q_u_local; + SPOOL_R_DELETEPRINTERDATA r_u_local; + fstring key; + + /* From MSDN documentation of SetPrinterDataEx: pass request to + SetPrinterData if key is "PrinterDriverData" */ + + unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); + + if (strcmp(key, "PrinterDriverData") != 0) + return WERR_INVALID_PARAM; + + memcpy(&q_u_local.handle, &q_u->handle, sizeof(POLICY_HND)); + copy_unistr2(&q_u_local.valuename, &q_u->valuename); + + return _spoolss_deleteprinterdata( p, &q_u_local, &r_u_local ); +} + + + + /******************************************************************** * spoolss_enumprinterkey ********************************************************************/ @@ -7660,6 +8132,34 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO return WERR_BADFILE; } +/******************************************************************** + * spoolss_deleteprinterkey + ********************************************************************/ + +WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, SPOOL_R_DELETEPRINTERKEY *r_u) +{ + Printer_entry *Printer = find_printer_index_by_hnd(p, &q_u->handle); + fstring key; + + if (!Printer) { + DEBUG(2,("_spoolss_deleteprinterkey: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(&q_u->handle))); + return WERR_BADFID; + } + + unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); + + if (strcmp(key, "PrinterDriverData") != 0) + return WERR_INVALID_PARAM; + + /* + * this is what 2k returns when you try to delete the "PrinterDriverData" + * key + */ + + return WERR_ACCESS_DENIED; +} + + /******************************************************************** * spoolss_enumprinterdataex ********************************************************************/ @@ -7801,7 +8301,7 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, unistr2_to_ascii(long_archi, environment, sizeof(long_archi)-1); - if (get_short_archi(short_archi, long_archi)==FALSE) + if (get_short_archi(short_archi, long_archi)==False) return WERR_INVALID_ENVIRONMENT; if((info=(PRINTPROCESSOR_DIRECTORY_1 *)malloc(sizeof(PRINTPROCESSOR_DIRECTORY_1))) == NULL) @@ -7834,6 +8334,7 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; + WERROR result; /* that's an [in out] buffer */ spoolss_move_buffer(q_u->buffer, &r_u->buffer); @@ -7845,12 +8346,13 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC switch(level) { case 1: - return getprintprocessordirectory_level_1 + result = getprintprocessordirectory_level_1 (&q_u->name, &q_u->environment, buffer, offered, needed); default: - return WERR_UNKNOWN_LEVEL; + result = WERR_UNKNOWN_LEVEL; } - return WERR_ACCESS_DENIED; + return result; } + diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index ee4ec8aa0a..5e1c005d54 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -25,6 +25,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /******************************************************************* api_srv_net_srv_get_info ********************************************************************/ @@ -492,25 +495,25 @@ static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) \PIPE\srvsvc commands ********************************************************************/ -struct api_struct api_srv_cmds[] = +static const struct api_struct api_srv_cmds[] = { - { "SRV_NETCONNENUM" , SRV_NETCONNENUM , api_srv_net_conn_enum }, - { "SRV_NETSESSENUM" , SRV_NETSESSENUM , api_srv_net_sess_enum }, - { "SRV_NETSHAREENUM_ALL" , SRV_NETSHAREENUM_ALL , api_srv_net_share_enum_all }, - { "SRV_NETSHAREENUM" , SRV_NETSHAREENUM , api_srv_net_share_enum }, - { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, - { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del }, - { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info }, - { "SRV_NET_SHARE_SET_INFO", SRV_NET_SHARE_SET_INFO, api_srv_net_share_set_info }, - { "SRV_NETFILEENUM" , SRV_NETFILEENUM , api_srv_net_file_enum }, - { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, - { "SRV_NET_SRV_SET_INFO" , SRV_NET_SRV_SET_INFO , api_srv_net_srv_set_info }, - { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, - { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, - { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate}, - { "SRV_NETFILEQUERYSECDESC",SRV_NETFILEQUERYSECDESC,api_srv_net_file_query_secdesc}, - { "SRV_NETFILESETSECDESC" , SRV_NETFILESETSECDESC , api_srv_net_file_set_secdesc}, - { NULL , 0 , NULL } + { "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum }, + { "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum }, + { "SRV_NET_SHARE_ENUM_ALL" , SRV_NET_SHARE_ENUM_ALL , api_srv_net_share_enum_all }, + { "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum }, + { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, + { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del }, + { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info }, + { "SRV_NET_SHARE_SET_INFO", SRV_NET_SHARE_SET_INFO, api_srv_net_share_set_info }, + { "SRV_NET_FILE_ENUM" , SRV_NET_FILE_ENUM , api_srv_net_file_enum }, + { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, + { "SRV_NET_SRV_SET_INFO" , SRV_NET_SRV_SET_INFO , api_srv_net_srv_set_info }, + { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, + { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, + { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate}, + { "SRV_NET_FILE_QUERY_SECDESC",SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc}, + { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc}, + { NULL , 0 , NULL } }; /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 1f3b1945e3..b5f6bd2f07 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -23,6 +23,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + extern pstring global_myname; /******************************************************************* @@ -38,7 +41,7 @@ static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int sn pstrcpy(net_name, lp_servicename(snum)); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark); + standard_sub_conn(p->conn, remark,sizeof(remark)); len_net_name = strlen(net_name); /* work out the share type */ @@ -70,7 +73,7 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int sn pstrcpy(net_name, lp_servicename(snum)); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark); + standard_sub_conn(p->conn, remark,sizeof(remark)); pstrcpy(path, "C:"); pstrcat(path, lp_pathname(snum)); @@ -308,7 +311,7 @@ void map_generic_share_sd_bits(SEC_DESC *psd) Can this user access with share with the required permissions ? ********************************************************************/ -BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 desired_access) +BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, uint32 desired_access) { uint32 granted; NTSTATUS status; @@ -316,7 +319,6 @@ BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 d SEC_DESC *psd = NULL; size_t sd_size; NT_USER_TOKEN *token = NULL; - user_struct *vuser = get_valid_user_struct(vuid); BOOL ret = True; mem_ctx = talloc_init(); @@ -355,7 +357,7 @@ static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, pstrcpy(net_name, lp_servicename(snum)); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark); + standard_sub_conn(p->conn, remark, sizeof(remark)); len_net_name = strlen(net_name); @@ -394,7 +396,7 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, pstrcpy(net_name, lp_servicename(snum)); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark); + standard_sub_conn(p->conn, remark,sizeof(remark)); pstrcpy(path, "C:"); pstrcat(path, lp_pathname(snum)); @@ -638,11 +640,13 @@ static void init_srv_sess_0_info(SESS_INFO_0 *se0, SESS_INFO_0_STR *str0, char * static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot) { + struct sessionid *session_list; uint32 num_entries = 0; - (*stot) = 1; + (*stot) = list_sessions(&session_list); if (ss0 == NULL) { (*snum) = 0; + SAFE_FREE(session_list); return; } @@ -651,7 +655,7 @@ static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *sto if (snum) { for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { init_srv_sess_0_info(&ss0->info_0[num_entries], - &ss0->info_0_str[num_entries], "MACHINE"); + &ss0->info_0_str[num_entries], session_list[(*snum)].remote_machine); /* move on to creating next session */ /* move on to creating next sess */ @@ -671,6 +675,7 @@ static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *sto ss0->ptr_sess_info = 0; ss0->num_entries_read2 = 0; } + SAFE_FREE(session_list); } /******************************************************************* @@ -693,11 +698,13 @@ static void init_srv_sess_1_info(SESS_INFO_1 *se1, SESS_INFO_1_STR *str1, static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot) { + struct sessionid *session_list; uint32 num_entries = 0; - (*stot) = 1; + (*stot) = list_sessions(&session_list); if (ss1 == NULL) { (*snum) = 0; + SAFE_FREE(session_list); return; } @@ -706,8 +713,10 @@ static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto if (snum) { for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { init_srv_sess_1_info(&ss1->info_1[num_entries], - &ss1->info_1_str[num_entries], - "MACHINE", "dummy_user", 1, 10, 5, 0); + &ss1->info_1_str[num_entries], + session_list[*snum].remote_machine, + session_list[*snum].username, + 1, 10, 5, 0); /* move on to creating next session */ /* move on to creating next sess */ @@ -941,74 +950,46 @@ static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, init_enum_hnd(&r_n->enum_hnd, resume_hnd); } -/******************************************************************* - fill in a file info level 3 structure. - ********************************************************************/ - -static void init_srv_file_3_info(FILE_INFO_3 *fl3, FILE_INFO_3_STR *str3, - uint32 fnum, uint32 perms, uint32 num_locks, - char *path_name, char *user_name) -{ - init_srv_file_info3(fl3 , fnum, perms, num_locks, path_name, user_name); - init_srv_file_info3_str(str3, path_name, user_name); -} - -/******************************************************************* - fill in a file info level 3 structure. - ********************************************************************/ - -static void init_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *ftot) -{ - uint32 num_entries = 0; - (*ftot) = 1; - - if (fl3 == NULL) { - (*fnum) = 0; - return; - } - - DEBUG(5,("init_srv_file_3_fl3\n")); - - for (; (*fnum) < (*ftot) && num_entries < MAX_FILE_ENTRIES; (*fnum)++) { - init_srv_file_3_info(&fl3->info_3[num_entries], - &fl3->info_3_str[num_entries], - (*fnum), 0x35, 0, "\\PIPE\\samr", "dummy user"); - - /* move on to creating next file */ - num_entries++; - } - - fl3->num_entries_read = num_entries; - fl3->ptr_file_info = num_entries > 0 ? 1 : 0; - fl3->num_entries_read2 = num_entries; - - if ((*fnum) >= (*ftot)) { - (*fnum) = 0; - } -} - /******************************************************************* makes a SRV_R_NET_FILE_ENUM structure. ********************************************************************/ -static WERROR init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, +static WERROR init_srv_file_info_ctr(pipes_struct *p, SRV_FILE_INFO_CTR *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { WERROR status = WERR_OK; + TALLOC_CTX *ctx = p->mem_ctx; DEBUG(5,("init_srv_file_info_ctr: %d\n", __LINE__)); + *total_entries = 1; /* dummy entries only, for */ ctr->switch_value = switch_value; + ctr->num_entries = *total_entries - *resume_hnd; + if (ctr->num_entries < 0) + ctr->num_entries = 0; + ctr->num_entries2 = ctr->num_entries; switch (switch_value) { - case 3: - init_srv_file_info_3(&ctr->file.info3, resume_hnd, total_entries); - ctr->ptr_file_ctr = 1; + case 3: { + int i; + if (*total_entries > 0) { + ctr->ptr_entries = 1; + ctr->file.info3 = talloc(ctx, ctr->num_entries * + sizeof(SRV_FILE_INFO_3)); + } + for (i=0 ;inum_entries;i++) { + init_srv_file_info3(&ctr->file.info3[i].info_3, i+*resume_hnd, 0x35, 0, "\\PIPE\\samr", "dummy user"); + init_srv_file_info3_str(&ctr->file.info3[i].info_3_str, "\\PIPE\\samr", "dummy user"); + + } + ctr->ptr_file_info = 1; + *resume_hnd = 0; break; + } default: DEBUG(5,("init_srv_file_info_ctr: unsupported switch value %d\n", switch_value)); (*resume_hnd = 0); (*total_entries) = 0; - ctr->ptr_file_ctr = 0; + ctr->ptr_entries = 0; status = WERR_UNKNOWN_LEVEL; break; } @@ -1020,7 +1001,7 @@ static WERROR init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr, makes a SRV_R_NET_FILE_ENUM structure. ********************************************************************/ -static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n, +static void init_srv_r_net_file_enum(pipes_struct *p, SRV_R_NET_FILE_ENUM *r_n, uint32 resume_hnd, int file_level, int switch_value) { DEBUG(5,("init_srv_r_net_file_enum: %d\n", __LINE__)); @@ -1029,7 +1010,7 @@ static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n, if (file_level == 0) r_n->status = WERR_UNKNOWN_LEVEL; else - r_n->status = init_srv_file_info_ctr(r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries)); + r_n->status = init_srv_file_info_ctr(p, &r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries)); if (!W_ERROR_IS_OK(r_n->status)) resume_hnd = 0; @@ -1053,11 +1034,21 @@ WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to srv_net_srv_get_info\n")); + return WERR_ACCESS_DENIED; + } + switch (q_u->switch_value) { + + /* Technically level 102 should only be available to + Administrators but there isn't anything super-secret + here, as most of it is made up. */ + case 102: init_srv_info_102(&ctr->srv.sv102, 500, global_myname, - string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), + string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), lp_major_announce_version(), lp_minor_announce_version(), lp_default_server_announce(), 0xffffffff, /* users */ @@ -1116,19 +1107,13 @@ net file enum WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) { - r_u->ctr = (SRV_FILE_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_FILE_INFO_CTR)); - if (!r_u->ctr) - return WERR_NOMEM; - - ZERO_STRUCTP(r_u->ctr); - DEBUG(5,("srv_net_file_enum: %d\n", __LINE__)); /* set up the */ - init_srv_r_net_file_enum(r_u, + init_srv_r_net_file_enum(p, r_u, get_enum_hnd(&q_u->enum_hnd), q_u->file_level, - q_u->ctr->switch_value); + q_u->ctr.switch_value); DEBUG(5,("srv_net_file_enum: %d\n", __LINE__)); @@ -1193,6 +1178,11 @@ WERROR _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__)); + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to srv_net_share_enum_all\n")); + return WERR_ACCESS_DENIED; + } + /* Create the list of shares for the response. */ init_srv_r_net_share_enum(p, r_u, q_u->ctr.info_level, @@ -1211,6 +1201,11 @@ WERROR _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__)); + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to srv_net_share_enum\n")); + return WERR_ACCESS_DENIED; + } + /* Create the list of shares for the response. */ init_srv_r_net_share_enum(p, r_u, q_u->ctr.info_level, @@ -1829,7 +1824,7 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ "Nigel Williams" . ***********************************************************************************/ -const char *server_disks[] = {"C:"}; +static const char *server_disks[] = {"C:"}; static uint32 get_server_disk_count(void) { diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 53bbebb95e..f896d1d9d8 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -38,6 +38,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /* * A list of the rids of well known BUILTIN and Domain users * and groups. @@ -93,6 +96,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui uint32 *rids=NULL, *new_rids=NULL; gid_t winbind_gid_low, winbind_gid_high; BOOL ret; + BOOL winbind_groups_exist; /* * this code is far from perfect. @@ -108,17 +112,15 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui *prids=NULL; *numgroups=0; - lp_winbind_gid(&winbind_gid_low, &winbind_gid_high); + winbind_groups_exist = lp_winbind_gid(&winbind_gid_low, &winbind_gid_high); DEBUG(10,("get_alias_user_groups: looking if SID %s is a member of groups in the SID domain %s\n", sid_to_string(str_qsid, q_sid), sid_to_string(str_domsid, sid))); - sid_peek_rid(q_sid, &rid); - pdb_init_sam(&sam_pass); become_root(); - ret = pdb_getsampwrid(sam_pass, rid); + ret = pdb_getsampwsid(sam_pass, q_sid); unbecome_root(); if (ret == False) { pdb_free_sam(&sam_pass); @@ -157,7 +159,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui } /* Don't return winbind groups as they are not local! */ - if ((grp->gr_gid >= winbind_gid_low) && (grp->gr_gid <= winbind_gid_high)) { + if (winbind_groups_exist && (grp->gr_gid >= winbind_gid_low) && (grp->gr_gid <= winbind_gid_high)) { DEBUG(10,("get_alias_user_groups: not returing %s, not local.\n", map.nt_name)); continue; } @@ -226,7 +228,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui } /* Don't return winbind groups as they are not local! */ - if ((gid >= winbind_gid_low) && (gid <= winbind_gid_high)) { + if (winbind_groups_exist && (gid >= winbind_gid_low) && (gid <= winbind_gid_high)) { DEBUG(10,("get_alias_user_groups: not returing %s, not local.\n", map.nt_name )); goto done; } @@ -404,6 +406,8 @@ NTSTATUS local_lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) return NT_STATUS_NONE_MAPPED; } + +#if 0 /*Nobody uses this function just now*/ /******************************************************************* Look up a local user rid and return a name and type. ********************************************************************/ @@ -448,6 +452,8 @@ NTSTATUS local_lookup_user_name(uint32 rid, char *user_name, uint32 *type) return NT_STATUS_NONE_MAPPED; } +#endif + /******************************************************************* Look up a local (domain) group name and return a rid ********************************************************************/ diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 8eb5b3002e..c783becbbe 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -24,6 +24,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + /******************************************************************* api_wks_query_info ********************************************************************/ @@ -55,7 +58,7 @@ static BOOL api_wks_query_info(pipes_struct *p) /******************************************************************* \PIPE\wkssvc commands ********************************************************************/ -struct api_struct api_wks_cmds[] = +static struct api_struct api_wks_cmds[] = { { "WKS_Q_QUERY_INFO", WKS_QUERY_INFO, api_wks_query_info }, { NULL , 0 , NULL } diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 637c95af69..7687e7b00a 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -25,6 +25,9 @@ #include "includes.h" +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + extern pstring global_myname; /******************************************************************* -- cgit From 159118de5ce0999b96ebe7cd7dc823087b0cccf5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Jul 2002 10:54:35 +0000 Subject: fixed a number of real bugs found by warnings on the 64 bit irix compiler (This used to be commit 04de6bbc8055e5547af41b10e284b722f40e726d) --- source3/rpc_server/srv_srvsvc_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index b5f6bd2f07..202e869d35 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -964,8 +964,6 @@ static WERROR init_srv_file_info_ctr(pipes_struct *p, SRV_FILE_INFO_CTR *ctr, ctr->switch_value = switch_value; ctr->num_entries = *total_entries - *resume_hnd; - if (ctr->num_entries < 0) - ctr->num_entries = 0; ctr->num_entries2 = ctr->num_entries; switch (switch_value) { -- cgit From b0b28531c8cd76d3fcd95da08389d8a4d2e631a3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 15 Jul 2002 11:16:26 +0000 Subject: more bug updates from head (This used to be commit 8b769bf5bbbe54b1a39fd85cc24db09c1ab7faab) --- source3/rpc_server/srv_srvsvc_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index b5f6bd2f07..202e869d35 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -964,8 +964,6 @@ static WERROR init_srv_file_info_ctr(pipes_struct *p, SRV_FILE_INFO_CTR *ctr, ctr->switch_value = switch_value; ctr->num_entries = *total_entries - *resume_hnd; - if (ctr->num_entries < 0) - ctr->num_entries = 0; ctr->num_entries2 = ctr->num_entries; switch (switch_value) { -- cgit From 78750803d09fdef3e878e73da98d3e7bc338fcb5 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 15 Jul 2002 22:27:07 +0000 Subject: splitting off storage/retrieval routines for abstracting the registry view front end. Now to plug in the various hooks. (This used to be commit 9772acd9ad44af2800dfb9d8610c2d5c23eaceb4) --- source3/rpc_server/srv_reg_nt.c | 334 ++-------------------------------------- 1 file changed, 11 insertions(+), 323 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 3f07e4aaea..b5511cfceb 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -4,7 +4,6 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. - * Copyright (C) Hewlett-Packard Company 1999. * Copyright (C) Jeremy Allison 2001. * Copyright (C) Gerald Carter 2002. * @@ -30,323 +29,24 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -#define KEY_HKLM "HKLM" -#define KEY_HKU "HKU" - #define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ ((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) -/* structure to store the registry handles */ - -typedef struct _RegistryKey { - struct _RegistryKey *prev, *next; - - fstring name; /* name of registry key */ - POLICY_HND hnd; - -} Registry_Key; static Registry_Key *regkeys_list; -static TDB_CONTEXT *tdb_reg; - -/*********************************************************************** - Add subkey strings to the registry tdb under a defined key - fmt is the same format as tdb_pack except this function only supports - fstrings - ***********************************************************************/ - -static BOOL store_reg_keys( TDB_CONTEXT *tdb, char *keyname, char **subkeys, uint32 num_subkeys ) -{ - TDB_DATA kbuf, dbuf; - char *buffer, *tmpbuf; - int i = 0; - uint32 len, buflen; - BOOL ret = True; - - if ( !keyname ) - return False; - - /* allocate some initial memory */ - - buffer = malloc(sizeof(pstring)); - buflen = sizeof(pstring); - len = 0; - - /* store the number of subkeys */ - - len += tdb_pack(buffer+len, buflen-len, "d", num_subkeys); - - /* pack all the strings */ - - for (i=0; i buflen ) { - /* allocate some extra space */ - if ((tmpbuf = Realloc( buffer, len*2 )) == NULL) { - DEBUG(0,("store_reg_keys: Failed to realloc memory of size [%d]\n", len*2)); - ret = False; - goto done; - } - buffer = tmpbuf; - buflen = len*2; - - len = tdb_pack(buffer+len, buflen-len, "f", subkeys[i]); - } - } - - /* finally write out the data */ - - kbuf.dptr = keyname; - kbuf.dsize = strlen(keyname)+1; - dbuf.dptr = buffer; - dbuf.dsize = len; - if ( tdb_store( tdb, kbuf, dbuf, TDB_REPLACE ) == -1) { - ret = False; - goto done; - } - -done: - SAFE_FREE( buffer ); - return ret; -} - -/*********************************************************************** - Retrieve an array of strings containing subkeys. Memory should be - released by the caller. The subkeys are stored in a catenated string - of null terminated character strings - ***********************************************************************/ -static int fetch_reg_keys( TDB_CONTEXT *tdb, char* key, char **subkeys ) -{ - pstring path; - uint32 num_items; - TDB_DATA dbuf; - char *buf; - uint32 buflen, len; - int i; - char *s; - - pstrcpy( path, key ); - - /* convert to key format */ - pstring_sub( path, "\\", "/" ); - - dbuf = tdb_fetch_by_string( tdb, path ); - - buf = dbuf.dptr; - buflen = dbuf.dsize; - - if ( !buf ) { - DEBUG(5,("fetch_reg_keys: Failed to fetch any subkeys for [%s]\n", key)); - return 0; - } - - len = tdb_unpack( buf, buflen, "d", &num_items); - if (num_items) { - if ( (*subkeys = (char*)malloc(sizeof(fstring)*num_items)) == NULL ) { - DEBUG(0,("fetch_reg_keys: Failed to malloc memory for subkey array containing [%d] items!\n", - num_items)); - num_items = -1; - goto done; - } - } - - s = *subkeys; - for (i=0; iname, &subkeys ); + num_subkeys = fetch_reg_keys( key->name, &subkeys ); if ( num_subkeys == -1 ) return False; @@ -498,6 +185,7 @@ static BOOL get_value_information( Registry_Key *key, uint32 *maxnum, #endif } + /******************************************************************** reg_close ********************************************************************/ @@ -567,7 +255,7 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR /* do a check on the name, here */ - if ( (num_subkeys=fetch_reg_keys_count( tdb_reg, path )) == -1 ) + if ( (num_subkeys=fetch_reg_keys_count( path )) == -1 ) return NT_STATUS_ACCESS_DENIED; if (!open_registry_key(p, &pol, path, 0x0)) @@ -724,7 +412,7 @@ NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", regkey->name)); - if ( !fetch_reg_keys_specific( tdb_reg, regkey->name, subkey, q_u->key_index ) ) + if ( !fetch_reg_keys_specific( regkey->name, subkey, q_u->key_index ) ) { status = werror_to_ntstatus( WERR_NO_MORE_ITEMS ); goto done; -- cgit From 29426b4a50275e24020ae67898cd7d156a341a7f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 17 Jul 2002 19:12:17 +0000 Subject: Gone back to explicit queue number passing as snum - removed encoding of queueid in job number. This means we must have an internal tdb to store mapping from 16 bit RAP jobid's to 32 bit RPC jobids. Jeremy. (This used to be commit 4ff64f69706cc94d5dba7762754d00790c476963) --- source3/rpc_server/srv_spoolss_nt.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 68c792f8b0..ca5557a0db 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -65,7 +65,7 @@ typedef struct _Printer{ struct _Printer *prev, *next; BOOL document_started; BOOL page_started; - int jobid; /* jobid in printing backend */ + uint32 jobid; /* jobid in printing backend */ BOOL printer_type; union { fstring handlename; @@ -1443,14 +1443,18 @@ BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, static WERROR _spoolss_enddocprinter_internal(pipes_struct *p, POLICY_HND *handle) { Printer_entry *Printer=find_printer_index_by_hnd(p, handle); - + int snum; + if (!Printer) { DEBUG(2,("_spoolss_enddocprinter_internal: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle))); return WERR_BADFID; } + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + Printer->document_started=False; - print_job_end(Printer->jobid,True); + print_job_end(snum, Printer->jobid,True); /* error codes unhandled so far ... */ return WERR_OK; @@ -4793,6 +4797,7 @@ WERROR _spoolss_startpageprinter(pipes_struct *p, SPOOL_Q_STARTPAGEPRINTER *q_u, WERROR _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPOOL_R_ENDPAGEPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; + int snum; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); @@ -4801,8 +4806,11 @@ WERROR _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPO return WERR_BADFID; } + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + Printer->page_started=False; - print_job_endpage(Printer->jobid); + print_job_endpage(snum, Printer->jobid); return WERR_OK; } @@ -4819,7 +4827,6 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S /* uint32 level = q_u->doc_info_container.level; - notused. */ DOC_INFO *docinfo = &q_u->doc_info_container.docinfo; uint32 *jobid = &r_u->jobid; - DOC_INFO_1 *info_1 = &docinfo->doc_info_1; int snum; pstring jobname; @@ -4898,7 +4905,7 @@ WERROR _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R uint32 buffer_size = q_u->buffer_size; uint8 *buffer = q_u->buffer; uint32 *buffer_written = &q_u->buffer_size2; - + int snum; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); if (!Printer) { @@ -4907,8 +4914,10 @@ WERROR _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R return WERR_BADFID; } - (*buffer_written) = print_job_write(Printer->jobid, (char *)buffer, buffer_size); + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + (*buffer_written) = print_job_write(snum, Printer->jobid, (char *)buffer, buffer_size); r_u->buffer_written = q_u->buffer_size2; @@ -5907,7 +5916,7 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u return WERR_BADFID; } - if (!print_job_exists(jobid)) { + if (!print_job_exists(snum, jobid)) { return WERR_INVALID_PRINTER_NAME; } @@ -5916,18 +5925,18 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u switch (command) { case JOB_CONTROL_CANCEL: case JOB_CONTROL_DELETE: - if (print_job_delete(&user, jobid, &errcode)) { + if (print_job_delete(&user, snum, jobid, &errcode)) { errcode = WERR_OK; } break; case JOB_CONTROL_PAUSE: - if (print_job_pause(&user, jobid, &errcode)) { + if (print_job_pause(&user, snum, jobid, &errcode)) { errcode = WERR_OK; } break; case JOB_CONTROL_RESTART: case JOB_CONTROL_RESUME: - if (print_job_resume(&user, jobid, &errcode)) { + if (print_job_resume(&user, snum, jobid, &errcode)) { errcode = WERR_OK; } break; -- cgit From 06ae9ac5d98a752d8ca17686a4a3b1786fbe520d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 18 Jul 2002 23:00:24 +0000 Subject: virtual registry framework with initial printing hooks. (This used to be commit a43d9788fa8823d678ee72470421b980165ec2b0) --- source3/rpc_server/srv_reg_nt.c | 198 +++++++++++++++++++++++++--------------- 1 file changed, 123 insertions(+), 75 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index b5511cfceb..d5b2394b40 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -1,11 +1,11 @@ /* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Gerald Carter 2002. + * Copyright (C) Andrew Tridgell 1992-1997. + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997. + * Copyright (C) Paul Ashton 1997. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Gerald Carter 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,16 +33,16 @@ ((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) -static Registry_Key *regkeys_list; +static REGISTRY_KEY *regkeys_list; /****************************************************************** - free() function for Registry_Key + free() function for REGISTRY_KEY *****************************************************************/ static void free_reg_info(void *ptr) { - Registry_Key *info = (Registry_Key*)ptr; + REGISTRY_KEY *info = (REGISTRY_KEY*)ptr; DLIST_REMOVE(regkeys_list, info); @@ -50,12 +50,12 @@ static void free_reg_info(void *ptr) } /****************************************************************** - Find a registry key handle and return a Registry_Key + Find a registry key handle and return a REGISTRY_KEY *****************************************************************/ -static Registry_Key *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) +static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) { - Registry_Key *regkey = NULL; + REGISTRY_KEY *regkey = NULL; if(!find_policy_by_hnd(p,hnd,(void **)®key)) { DEBUG(2,("find_regkey_index_by_hnd: Registry Key not found: ")); @@ -69,34 +69,87 @@ static Registry_Key *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) /******************************************************************* Function for open a new registry handle and creating a handle Note that P should be valid & hnd should already have space + + When we open a key, we store the full path to the key as + HK[LM|U]\\\... *******************************************************************/ -static BOOL open_registry_key(pipes_struct *p, POLICY_HND *hnd, char *name, - uint32 access_granted) +static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY *parent, + char *subkeyname, uint32 access_granted ) { - Registry_Key *regkey = NULL; + REGISTRY_KEY *regkey = NULL; + pstring parent_keyname; + NTSTATUS result = NT_STATUS_OK; + int num_subkeys; + char *subkeys = NULL; + + if ( parent ) { + pstrcpy( parent_keyname, parent->name ); + pstrcat( parent_keyname, "\\" ); + } + else + *parent_keyname = '\0'; + - DEBUG(7,("open_registry_key: name = [%s]\n", name)); + DEBUG(7,("open_registry_key: name = [%s][%s]\n", parent_keyname, subkeyname)); /* All registry keys **must** have a name of non-zero length */ - if (!name || !*name ) - return False; + if (!subkeyname || !*subkeyname ) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; - if ((regkey=(Registry_Key*)malloc(sizeof(Registry_Key))) == NULL) - return False; + if ((regkey=(REGISTRY_KEY*)malloc(sizeof(REGISTRY_KEY))) == NULL) + return NT_STATUS_NO_MEMORY; ZERO_STRUCTP( regkey ); DLIST_ADD( regkeys_list, regkey ); - /* copy the name and obtain a handle */ + /* copy the name */ + + pstrcpy( regkey->name, parent_keyname ); + pstrcat( regkey->name, subkeyname ); + + /* try to use en existing hook. Otherwise, try to lookup our own */ + + if ( parent && parent->hook ) + regkey->hook = parent->hook; + else + regkey->hook = reghook_cache_find( regkey->name ); + + if ( regkey->hook ) { + DEBUG(10,("open_registry_key: Assigned REGISTRY_HOOK to [%s]\n", + regkey->name )); + } + + /* check if the path really exists...num_subkeys should be >= 0 */ - fstrcpy( regkey->name, name ); + num_subkeys = fetch_reg_keys( regkey, &subkeys ); + + /* if the subkey count failed, bail out */ + + if ( num_subkeys == -1 ) { + SAFE_FREE( regkey ); + + /* don't really know what to return here */ + + result = NT_STATUS_ACCESS_DENIED; + } + else { + /* + * This would previously return NT_STATUS_TOO_MANY_SECRETS + * that doesn't sound quite right to me --jerry + */ + + if ( !create_policy_hnd( p, hnd, free_reg_info, regkey ) ) + result = NT_STATUS_OBJECT_NAME_NOT_FOUND; + } DEBUG(7,("open_registry_key: exit\n")); - return create_policy_hnd( p, hnd, free_reg_info, regkey ); + SAFE_FREE( subkeys ); + + return result; } /******************************************************************* @@ -106,7 +159,7 @@ static BOOL open_registry_key(pipes_struct *p, POLICY_HND *hnd, char *name, static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd) { - Registry_Key *regkey = find_regkey_index_by_hnd(p, hnd); + REGISTRY_KEY *regkey = find_regkey_index_by_hnd(p, hnd); if ( !regkey ) { DEBUG(2,("close_registry_key: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(hnd))); @@ -122,7 +175,7 @@ static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd) retrieve information about the subkeys *******************************************************************/ -static BOOL get_subkey_information( Registry_Key *key, uint32 *maxnum, uint32 *maxlen ) +static BOOL get_subkey_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *maxlen ) { int num_subkeys, i; uint32 max_len; @@ -133,7 +186,11 @@ static BOOL get_subkey_information( Registry_Key *key, uint32 *maxnum, uint32 *m if ( !key ) return False; - num_subkeys = fetch_reg_keys( key->name, &subkeys ); + /* first use any registry hook available. + Fall back to tdb if non available */ + + num_subkeys = fetch_reg_keys( key, &subkeys ); + if ( num_subkeys == -1 ) return False; @@ -161,28 +218,36 @@ static BOOL get_subkey_information( Registry_Key *key, uint32 *maxnum, uint32 *m Samba tdb's (such as ntdrivers.tdb). *******************************************************************/ -static BOOL get_value_information( Registry_Key *key, uint32 *maxnum, +static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *maxlen, uint32 *maxsize ) { + REGISTRY_VALUE *val = NULL; + uint32 i, sizemax, lenmax; + int num_values; + if ( !key ) return False; - /* Hard coded key names first */ - /* nothing has valuies right now */ + num_values = fetch_reg_values( key, &val ); + + if ( num_values == -1 ) + return False; + + + lenmax = sizemax = 0; - *maxnum = 0; - *maxlen = 0; - *maxsize = 0; + for ( i=0; ipol, KEY_HKLM, 0x0)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - - return NT_STATUS_OK; + return open_registry_key( p, &r_u->pol, NULL, KEY_HKLM, 0x0 ); } /******************************************************************* @@ -220,10 +282,7 @@ NTSTATUS _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM * NTSTATUS _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HKU *q_u, REG_R_OPEN_HKU *r_u) { - if (!open_registry_key(p, &r_u->pol, KEY_HKU, 0x0)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - - return NT_STATUS_OK; + return open_registry_key( p, &r_u->pol, NULL, KEY_HKU, 0x0 ); } /******************************************************************* @@ -234,9 +293,8 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR { POLICY_HND pol; fstring name; - pstring path; - int num_subkeys; - Registry_Key *key = find_regkey_index_by_hnd(p, &q_u->pol); + REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->pol); + NTSTATUS result; DEBUG(5,("reg_open_entry: Enter\n")); @@ -244,26 +302,14 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR return NT_STATUS_INVALID_HANDLE; rpcstr_pull(name,q_u->uni_name.buffer,sizeof(name),q_u->uni_name.uni_str_len*2,0); - - /* store the full path in the regkey_list */ - pstrcpy( path, key->name ); - pstrcat( path, "\\" ); - pstrcat( path, name ); - - DEBUG(5,("reg_open_entry: %s\n", path)); - - /* do a check on the name, here */ + DEBUG(5,("reg_open_entry: Enter\n")); - if ( (num_subkeys=fetch_reg_keys_count( path )) == -1 ) - return NT_STATUS_ACCESS_DENIED; - - if (!open_registry_key(p, &pol, path, 0x0)) - return NT_STATUS_TOO_MANY_SECRETS; - - init_reg_r_open_entry(r_u, &pol, NT_STATUS_OK); + result = open_registry_key( p, &pol, key, name, 0x0 ); + + init_reg_r_open_entry( r_u, &pol, result ); - DEBUG(5,("reg_open_entry: Exitn")); + DEBUG(5,("reg_open_entry: Exit\n")); return r_u->status; } @@ -280,7 +326,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) UNISTR2 *uni_key = NULL; BUFFER2 *buf = NULL; fstring name; - Registry_Key *key = find_regkey_index_by_hnd( p, &q_u->pol ); + REGISTRY_KEY *key = find_regkey_index_by_hnd( p, &q_u->pol ); DEBUG(5,("_reg_info: Enter\n")); @@ -346,7 +392,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) NTSTATUS _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_u) { NTSTATUS status = NT_STATUS_OK; - Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); DEBUG(5,("_reg_query_key: Enter\n")); @@ -358,6 +404,7 @@ NTSTATUS _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY * if ( !get_value_information( regkey, &r_u->num_values, &r_u->max_valnamelen, &r_u->max_valbufsize ) ) return NT_STATUS_ACCESS_DENIED; + r_u->sec_desc = 0x00000078; /* size for key's sec_desc */ @@ -379,7 +426,7 @@ NTSTATUS _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY * NTSTATUS _reg_unknown_1a(pipes_struct *p, REG_Q_UNKNOWN_1A *q_u, REG_R_UNKNOWN_1A *r_u) { NTSTATUS status = NT_STATUS_OK; - Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); DEBUG(5,("_reg_unknown_1a: Enter\n")); @@ -401,8 +448,8 @@ NTSTATUS _reg_unknown_1a(pipes_struct *p, REG_Q_UNKNOWN_1A *q_u, REG_R_UNKNOWN_1 NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u) { NTSTATUS status = NT_STATUS_OK; - Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - fstring subkey; + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + char *subkey; DEBUG(5,("_reg_enum_key: Enter\n")); @@ -412,9 +459,9 @@ NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", regkey->name)); - if ( !fetch_reg_keys_specific( regkey->name, subkey, q_u->key_index ) ) + if ( !fetch_reg_keys_specific( regkey, &subkey, q_u->key_index ) ) { - status = werror_to_ntstatus( WERR_NO_MORE_ITEMS ); + status = NT_STATUS_NO_MORE_ENTRIES; goto done; } @@ -427,6 +474,7 @@ NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u DEBUG(5,("_reg_enum_key: Exit\n")); done: + SAFE_FREE( subkey ); return status; } -- cgit From 9fe3bd1259e7bda901f7a264bd7fc88c72d2112f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 19 Jul 2002 18:49:44 +0000 Subject: * refactored registry operations some. subkey lists and registry values are now passed around in containers (REGSUBKEY_CTR & REGVAL_CTR) which each possess a TALLOC_CTX. * removed subkey_specific_fn() from REGISTRY_OPS. Is implemented in the form of a wrapper * temporarily broke the printing registry ops. * implemented inheritence for the data_p of nodes in a SORTED_TREE * All REGISTRY_KEY instances now store a valid REGISTRY_HOOK since the default REGOSTRY_OPS structure is stored in the root of the cache_tree. * Probably some other change I forgot.... T (This used to be commit e7b55e8f017e638342d9c8c1a9259000745a0298) --- source3/rpc_server/srv_reg_nt.c | 93 +++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 46 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index d5b2394b40..ebed13edfe 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -40,7 +40,7 @@ static REGISTRY_KEY *regkeys_list; free() function for REGISTRY_KEY *****************************************************************/ -static void free_reg_info(void *ptr) +static void free_regkey_info(void *ptr) { REGISTRY_KEY *info = (REGISTRY_KEY*)ptr; @@ -77,11 +77,10 @@ static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY *parent, char *subkeyname, uint32 access_granted ) { - REGISTRY_KEY *regkey = NULL; - pstring parent_keyname; - NTSTATUS result = NT_STATUS_OK; - int num_subkeys; - char *subkeys = NULL; + REGISTRY_KEY *regkey = NULL; + pstring parent_keyname; + NTSTATUS result = NT_STATUS_OK; + REGSUBKEY_CTR subkeys; if ( parent ) { pstrcpy( parent_keyname, parent->name ); @@ -110,27 +109,23 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY pstrcpy( regkey->name, parent_keyname ); pstrcat( regkey->name, subkeyname ); - /* try to use en existing hook. Otherwise, try to lookup our own */ + /* Look up the table of registry I/O operations */ - if ( parent && parent->hook ) - regkey->hook = parent->hook; - else - regkey->hook = reghook_cache_find( regkey->name ); - - if ( regkey->hook ) { - DEBUG(10,("open_registry_key: Assigned REGISTRY_HOOK to [%s]\n", + if ( !(regkey->hook = reghook_cache_find( regkey->name )) ) { + DEBUG(0,("open_registry_key: Failed to assigned a REGISTRY_HOOK to [%s]\n", regkey->name )); + return NT_STATUS_OBJECT_PATH_NOT_FOUND; } - /* check if the path really exists...num_subkeys should be >= 0 */ + /* check if the path really exists; failed is indicated by -1 */ + /* if the subkey count failed, bail out */ + + ZERO_STRUCTP( &subkeys ); - num_subkeys = fetch_reg_keys( regkey, &subkeys ); + regsubkey_ctr_init( &subkeys ); - /* if the subkey count failed, bail out */ + if ( fetch_reg_keys( regkey, &subkeys ) == -1 ) { - if ( num_subkeys == -1 ) { - SAFE_FREE( regkey ); - /* don't really know what to return here */ result = NT_STATUS_ACCESS_DENIED; @@ -141,13 +136,18 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY * that doesn't sound quite right to me --jerry */ - if ( !create_policy_hnd( p, hnd, free_reg_info, regkey ) ) + if ( !create_policy_hnd( p, hnd, free_regkey_info, regkey ) ) result = NT_STATUS_OBJECT_NAME_NOT_FOUND; } DEBUG(7,("open_registry_key: exit\n")); - SAFE_FREE( subkeys ); + /* clean up */ + + regsubkey_ctr_destroy( &subkeys ); + + if ( ! NT_STATUS_IS_OK(result) ) + SAFE_FREE( regkey ); return result; } @@ -177,37 +177,35 @@ static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd) static BOOL get_subkey_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *maxlen ) { - int num_subkeys, i; - uint32 max_len; - char *subkeys = NULL; - uint32 len; - char *s; + int num_subkeys, i; + uint32 max_len; + REGSUBKEY_CTR subkeys; + uint32 len; if ( !key ) return False; + + ZERO_STRUCTP( &subkeys ); - /* first use any registry hook available. - Fall back to tdb if non available */ + regsubkey_ctr_init( &subkeys ); - num_subkeys = fetch_reg_keys( key, &subkeys ); - - if ( num_subkeys == -1 ) + if ( fetch_reg_keys( key, &subkeys ) == -1 ) return False; /* find the longest string */ max_len = 0; - s = subkeys; + num_subkeys = regsubkey_ctr_numkeys( &subkeys ); + for ( i=0; i Date: Sat, 20 Jul 2002 04:27:30 +0000 Subject: enumeration of printers keys ( no data yet ) via the registry functions now works :-) (This used to be commit c5768538f6cf6ee824bc6e105a3391bbc2ea8e46) --- source3/rpc_server/srv_reg_nt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index ebed13edfe..580ab78f74 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -88,7 +88,6 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY } else *parent_keyname = '\0'; - DEBUG(7,("open_registry_key: name = [%s][%s]\n", parent_keyname, subkeyname)); @@ -102,8 +101,6 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY ZERO_STRUCTP( regkey ); - DLIST_ADD( regkeys_list, regkey ); - /* copy the name */ pstrcpy( regkey->name, parent_keyname ); @@ -140,14 +137,17 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY result = NT_STATUS_OBJECT_NAME_NOT_FOUND; } - DEBUG(7,("open_registry_key: exit\n")); - /* clean up */ regsubkey_ctr_destroy( &subkeys ); if ( ! NT_STATUS_IS_OK(result) ) SAFE_FREE( regkey ); + else + DLIST_ADD( regkeys_list, regkey ); + + + DEBUG(7,("open_registry_key: exit\n")); return result; } @@ -380,7 +380,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) out: init_reg_r_info(q_u->ptr_buf, r_u, buf, type, status); - DEBUG(5,("reg_open_entry: Exit\n")); + DEBUG(5,("_reg_info: Exit\n")); return status; } -- cgit From ea9d3057e9cbd615176a7b98bcd935b6f9b434cb Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 20 Jul 2002 11:58:06 +0000 Subject: Try to fix up warnings - particularly on the IRIX 64 bit compiler (which had a distinction between uchar and char). Lots of const etc. Andrew Bartlett (This used to be commit 8196ee908e10db2119e480fe1b0a71b31a16febc) --- source3/rpc_server/srv_netlog_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 4ab9c470d0..1f684bd929 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -280,7 +280,7 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) /* from client / server challenges and md4 password, generate sess key */ cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal, - (char *)p->dc.md4pw, p->dc.sess_key); + p->dc.md4pw, p->dc.sess_key); /* check that the client credentials are valid */ if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) { @@ -342,7 +342,7 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) /* from client / server challenges and md4 password, generate sess key */ cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal, - (char *)p->dc.md4pw, p->dc.sess_key); + p->dc.md4pw, p->dc.sess_key); /* check that the client credentials are valid */ if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) { -- cgit From 29075c97d3b7111e2565ede1cd0f000fd2534375 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 20 Jul 2002 13:02:47 +0000 Subject: More fixes towards warnings on the IRIX compiler (and yes, some of these are real bugs) In particular, the samr code was doing an &foo of various types, to a function that assumed uint32. If time_t isn't 32 bits long, that broke. They are assignment compatible however, so use that and an intermediate variable. Andrew Bartlett (This used to be commit 30d0998c8c1a1d4de38ef0fbc83c2b763e05a3e6) --- source3/rpc_server/srv_samr_nt.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 88d728d810..96960611b7 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2081,6 +2081,8 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA time_t u_logout; NTTIME nt_logout; + uint32 account_policy_temp; + uint32 num_users=0, num_groups=0, num_aliases=0; if ((ctr = (SAM_UNK_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL) @@ -2098,12 +2100,22 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA switch (q_u->switch_value) { case 0x01: - account_policy_get(AP_MIN_PASSWORD_LEN, &min_pass_len); - account_policy_get(AP_PASSWORD_HISTORY, &pass_hist); - account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &flag); - account_policy_get(AP_MAX_PASSWORD_AGE, (int *)&u_expire); - account_policy_get(AP_MIN_PASSWORD_AGE, (int *)&u_min_age); + + account_policy_get(AP_MIN_PASSWORD_LEN, &account_policy_temp); + min_pass_len = account_policy_temp; + + account_policy_get(AP_PASSWORD_HISTORY, &account_policy_temp); + pass_hist = account_policy_temp; + + account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); + flag = account_policy_temp; + account_policy_get(AP_MAX_PASSWORD_AGE, &account_policy_temp); + u_expire = account_policy_temp; + + account_policy_get(AP_MIN_PASSWORD_AGE, &account_policy_temp); + u_min_age = account_policy_temp; + unix_to_nt_time_abs(&nt_expire, u_expire); unix_to_nt_time_abs(&nt_min_age, u_min_age); @@ -2149,10 +2161,15 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA init_unk_info7(&ctr->info.inf7); break; case 0x0c: - account_policy_get(AP_LOCK_ACCOUNT_DURATION, (int *)&u_lock_duration); - account_policy_get(AP_RESET_COUNT_TIME, (int *)&u_reset_time); - account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &lockout); - + account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); + u_lock_duration = account_policy_temp; + + account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp); + u_reset_time = account_policy_temp; + + account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); + lockout = account_policy_temp; + unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); unix_to_nt_time_abs(&nt_reset_time, u_reset_time); -- cgit From 6dd9f24d05e5db92e15dc53399a0f78ccb69f718 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 20 Jul 2002 13:23:57 +0000 Subject: another intermediate checkin on the way to enumerating forms via the registry. There is a seg fault here which shouldn't bother anyone until I can get it fixed. I just need a check point in case I need to roll back to this version later on. (This used to be commit e62ae94823461e142978a786b2860ea97906cfb3) --- source3/rpc_server/srv_reg_nt.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 580ab78f74..72e0631e8b 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -219,34 +219,35 @@ static BOOL get_subkey_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *m static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *maxlen, uint32 *maxsize ) { - REGVAL_CTR val; + REGVAL_CTR values; + REGISTRY_VALUE *val; uint32 sizemax, lenmax; - int num_values; + int i, num_values; if ( !key ) return False; ZERO_STRUCTP( &val ); - regval_ctr_init( &val ); + regval_ctr_init( &values ); - if ( fetch_reg_values( key, &val ) == -1 ) + if ( fetch_reg_values( key, &values ) == -1 ) return False; lenmax = sizemax = 0; - num_values = regval_ctr_numvals( &val ); + num_values = regval_ctr_numvals( &values ); -#if 0 /* JERRY */ - for ( i=0; i Date: Sun, 21 Jul 2002 00:08:16 +0000 Subject: More use of intermediate variables to avoid issues with pointer size and casts. Andrew Bartlett (This used to be commit 88b68f79721b5fea7ddcad5a83b9555528c75c20) --- source3/rpc_server/srv_samr_nt.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 96960611b7..eb74acf35b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4197,6 +4197,8 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW uint32 num_users=0, num_groups=0, num_aliases=0; + uint32 account_policy_temp; + if ((ctr = (SAM_UNK_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL) return NT_STATUS_NO_MEMORY; @@ -4212,11 +4214,20 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW switch (q_u->switch_value) { case 0x01: - account_policy_get(AP_MIN_PASSWORD_LEN, &min_pass_len); - account_policy_get(AP_PASSWORD_HISTORY, &pass_hist); - account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &flag); - account_policy_get(AP_MAX_PASSWORD_AGE, (int *)&u_expire); - account_policy_get(AP_MIN_PASSWORD_AGE, (int *)&u_min_age); + account_policy_get(AP_MIN_PASSWORD_LEN, &account_policy_temp); + min_pass_len = account_policy_temp; + + account_policy_get(AP_PASSWORD_HISTORY, &account_policy_temp); + pass_hist = account_policy_temp; + + account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); + flag = account_policy_temp; + + account_policy_get(AP_MAX_PASSWORD_AGE, &account_policy_temp); + u_expire = account_policy_temp; + + account_policy_get(AP_MIN_PASSWORD_AGE, &account_policy_temp); + u_min_age = account_policy_temp; unix_to_nt_time_abs(&nt_expire, u_expire); unix_to_nt_time_abs(&nt_min_age, u_min_age); @@ -4248,7 +4259,9 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW num_users, num_groups, num_aliases); break; case 0x03: - account_policy_get(AP_TIME_TO_LOGOUT, (int *)&u_logout); + account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); + u_logout = account_policy_temp; + unix_to_nt_time_abs(&nt_logout, u_logout); init_unk_info3(&ctr->info.inf3, nt_logout); @@ -4263,9 +4276,14 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW init_unk_info7(&ctr->info.inf7); break; case 0x0c: - account_policy_get(AP_LOCK_ACCOUNT_DURATION, (int *)&u_lock_duration); - account_policy_get(AP_RESET_COUNT_TIME, (int *)&u_reset_time); - account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &lockout); + account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); + u_lock_duration = account_policy_temp; + + account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp); + u_reset_time = account_policy_temp; + + account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); + lockout = account_policy_temp; unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); unix_to_nt_time_abs(&nt_reset_time, u_reset_time); -- cgit From c0f66c1786cfbbff416a59b38930788cbe86f686 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 21 Jul 2002 04:55:11 +0000 Subject: Name get and set dir drive functions consistently. (This used to be commit 290a304d2c1b70d20129236e20a0ff664179023e) --- source3/rpc_server/srv_netlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 1f684bd929..8f6011826a 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -708,7 +708,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * pdb_get_username(sampw), pdb_get_fullname(sampw), pdb_get_homedir(sampw), - pdb_get_dirdrive(sampw), + pdb_get_dir_drive(sampw), pdb_get_logon_script(sampw), pdb_get_profile_path(sampw), pdb_get_logon_time(sampw), -- cgit From fb5153a93be4427d288e8b0bd2f44d53227f3965 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 22 Jul 2002 21:40:45 +0000 Subject: Merge from APPLIANCE_HEAD. (This used to be commit 825cdc49dbc3e6b9d08b8e722c82cc09e2479fa1) --- source3/rpc_server/srv_spoolss_nt.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ca5557a0db..822800de11 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -101,7 +101,7 @@ typedef struct _counter_printer_0 { static ubi_dlList counter_list; -static struct cli_state cli; +static struct cli_state notify_cli; /* print notify back-channel */ static uint32 smb_connections=0; @@ -184,7 +184,7 @@ static void srv_spoolss_replycloseprinter(POLICY_HND *handle) return; } - result = cli_spoolss_reply_close_printer(&cli, cli.mem_ctx, handle); + result = cli_spoolss_reply_close_printer(¬ify_cli, notify_cli.mem_ctx, handle); if (!W_ERROR_IS_OK(result)) DEBUG(0,("srv_spoolss_replycloseprinter: reply_close_printer failed [%s].\n", @@ -192,9 +192,9 @@ static void srv_spoolss_replycloseprinter(POLICY_HND *handle) /* if it's the last connection, deconnect the IPC$ share */ if (smb_connections==1) { - cli_nt_session_close(&cli); - cli_ulogoff(&cli); - cli_shutdown(&cli); + cli_nt_session_close(¬ify_cli); + cli_ulogoff(¬ify_cli); + cli_shutdown(¬ify_cli); message_deregister(MSG_PRINTER_NOTIFY2); } @@ -793,7 +793,7 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, if (!p->notify.flags) cli_spoolss_rrpcn( - &cli, mem_ctx, &p->notify.client_hnd, + ¬ify_cli, mem_ctx, &p->notify.client_hnd, data_len, data, p->notify.change, 0); else { NT_PRINTER_INFO_LEVEL *printer = NULL; @@ -810,7 +810,7 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, PRINTER_CHANGE_SET_PRINTER_DRIVER. */ cli_spoolss_routerreplyprinter( - &cli, mem_ctx, &p->notify.client_hnd, + ¬ify_cli, mem_ctx, &p->notify.client_hnd, 0, printer->info_2->changeid); free_a_printer(&printer, 2); @@ -1970,7 +1970,7 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin fstrcpy(unix_printer, printer+2); /* the +2 is to strip the leading 2 backslashs */ - if(!spoolss_connect_to_client(&cli, unix_printer)) + if(!spoolss_connect_to_client(¬ify_cli, unix_printer)) return False; message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message); @@ -1978,7 +1978,7 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin smb_connections++; - result = cli_spoolss_reply_open_printer(&cli, cli.mem_ctx, printer, localprinter, + result = cli_spoolss_reply_open_printer(¬ify_cli, notify_cli.mem_ctx, printer, localprinter, type, handle); if (!W_ERROR_IS_OK(result)) -- cgit From ff667e0983a4ec7009f53ba533490d9f766b75be Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 22 Jul 2002 21:53:36 +0000 Subject: Sync with APPLIANCE_HEAD branch (whitespace, const only) (This used to be commit 11229aa88b60d820ba714f2c793fe6932ec67a6b) --- source3/rpc_server/srv_spoolss_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 822800de11..bc58655f71 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8363,5 +8363,3 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC return result; } - - -- cgit From e8177d1104c8f7a1035f5c9c340ae5c9b594a729 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 23 Jul 2002 04:55:06 +0000 Subject: * changed structure of REG_R_ENUM_VALUE structure since the BUFFER2 is not and [in/out] buffer * registry value enumeration is working now for the Print\Forms key. The format of the binary data is not quite right yet but all installed forms are listed (This used to be commit 998eb9c7312c3c9a9ed1e9ec294593503c0304bf) --- source3/rpc_server/srv_reg.c | 26 ++++++++++++++++++++++ source3/rpc_server/srv_reg_nt.c | 49 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 72 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index a096325860..ee873e32e9 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -290,6 +290,31 @@ static BOOL api_reg_enum_key(pipes_struct *p) return True; } +/******************************************************************* + api_reg_enum_value + ********************************************************************/ + +static BOOL api_reg_enum_value(pipes_struct *p) +{ + REG_Q_ENUM_VALUE q_u; + REG_R_ENUM_VALUE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_enum_val("", &q_u, data, 0)) + return False; + + r_u.status = _reg_enum_value(p, &q_u, &r_u); + + if(!reg_io_r_enum_val("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* @@ -302,6 +327,7 @@ static struct api_struct api_reg_cmds[] = { "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm }, { "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku }, { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key }, + { "REG_ENUM_VALUE" , REG_ENUM_VALUE , api_reg_enum_value }, { "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key }, { "REG_INFO" , REG_INFO , api_reg_info }, { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 72e0631e8b..99439bcc38 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -237,10 +237,14 @@ static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum, lenmax = sizemax = 0; num_values = regval_ctr_numvals( &values ); - for ( i=0; ivaluename)+1 ); + sizemax = MAX(sizemax, val->size ); + val = regval_ctr_specific_value( &values, i ); - lenmax = MAX(lenmax, strlen(val[i].valuename)+1 ); - sizemax = MAX(sizemax, val[i].size ); } *maxnum = num_values; @@ -480,6 +484,45 @@ done: return status; } +/***************************************************************************** + Implementation of REG_ENUM_VALUE + ****************************************************************************/ + +NTSTATUS _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE *r_u) +{ + NTSTATUS status = NT_STATUS_OK; + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + REGISTRY_VALUE *val; + + + DEBUG(5,("_reg_enum_value: Enter\n")); + + if ( !regkey ) + return NT_STATUS_INVALID_HANDLE; + + DEBUG(8,("_reg_enum_key: enumerating values for key [%s]\n", regkey->name)); + + if ( !fetch_reg_values_specific( regkey, &val, q_u->val_index ) ) + { + status = NT_STATUS_NO_MORE_ENTRIES; + goto done; + } + + DEBUG(10,("_reg_enum_value: retrieved value named [%s]\n", val->valuename)); + + /* subkey has the string name now */ + + init_reg_r_enum_val( r_u, val ); + + + DEBUG(5,("_reg_enum_value: Exit\n")); + +done: + SAFE_FREE( val ); + + return status; +} + /******************************************************************* reg_shutdwon -- cgit From fef9d6187ece53ae12670cc56b360e913e08f3bb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 23 Jul 2002 09:22:29 +0000 Subject: implemented getgrouplist() for systems that don't have it and use it in get_alias_user_groups(). The old method used getgrent() which is extremely slow when the number of groups is large (This used to be commit 44e92b6523ca2c119c2562df22eb71138dca9d9d) --- source3/rpc_server/srv_util.c | 62 ++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 33 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index f896d1d9d8..50bf5db4fd 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -84,10 +84,10 @@ rid_name domain_group_rids[] = NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, uint32 **prids, DOM_SID *q_sid) { SAM_ACCOUNT *sam_pass=NULL; - struct sys_grent *glist; - struct sys_grent *grp; - int i, num, cur_rid=0; + int i, cur_rid=0; gid_t gid; + gid_t *groups = NULL; + int num_groups; GROUP_MAP map; DOM_SID tmp_sid; fstring user_name; @@ -130,16 +130,21 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui fstrcpy(user_name, pdb_get_username(sam_pass)); grid=pdb_get_group_rid(sam_pass); gid=pdb_get_gid(sam_pass); - - grp = glist = getgrent_list(); - if (grp == NULL) { + + become_root(); + /* on some systems this must run as root */ + num_groups = getgroups_user(user_name, &groups); + unbecome_root(); + if (num_groups == -1) { + /* this should never happen */ + DEBUG(2,("get_alias_user_groups: getgroups_user failed\n")); pdb_free_sam(&sam_pass); - return NT_STATUS_NO_MEMORY; + return NT_STATUS_UNSUCCESSFUL; } - - for (; grp != NULL; grp = grp->next) { - if(!get_group_from_gid(grp->gr_gid, &map, MAPPING_WITHOUT_PRIV)) { - DEBUG(10,("get_alias_user_groups: gid %d. not found\n", (int)grp->gr_gid)); + + for (i=0;igr_gid >= winbind_gid_low) && (grp->gr_gid <= winbind_gid_high)) { + if (winbind_groups_exist && (groups[i] >= winbind_gid_low) && (groups[i] <= winbind_gid_high)) { DEBUG(10,("get_alias_user_groups: not returing %s, not local.\n", map.nt_name)); continue; } @@ -170,30 +175,21 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui continue; } - /* the group is fine, we can check if there is the user we're looking for */ - DEBUG(10,("get_alias_user_groups: checking if the user is a member of %s.\n", map.nt_name)); - - for(num=0; grp->gr_mem[num]!=NULL; num++) { - if(strcmp(grp->gr_mem[num], user_name)==0) { - /* we found the user, add the group to the list */ - - new_rids=(uint32 *)Realloc(rids, sizeof(uint32)*(cur_rid+1)); - if (new_rids==NULL) { - DEBUG(10,("get_alias_user_groups: could not realloc memory\n")); - pdb_free_sam(&sam_pass); - return NT_STATUS_NO_MEMORY; - } - rids=new_rids; - - sid_peek_rid(&map.sid, &(rids[cur_rid])); - DEBUG(10,("get_alias_user_groups: user found in group %s\n", map.nt_name)); - cur_rid++; - break; - } + new_rids=(uint32 *)Realloc(rids, sizeof(uint32)*(cur_rid+1)); + if (new_rids==NULL) { + DEBUG(10,("get_alias_user_groups: could not realloc memory\n")); + pdb_free_sam(&sam_pass); + free(groups); + return NT_STATUS_NO_MEMORY; } + rids=new_rids; + + sid_peek_rid(&map.sid, &(rids[cur_rid])); + cur_rid++; + break; } - grent_free(glist); + free(groups); /* now check for the user's gid (the primary group rid) */ for (i=0; i Date: Wed, 24 Jul 2002 06:42:09 +0000 Subject: several changes in this checkin * added REG_OPEN_HKCR for supporting regedit.exe * All data n a REGISTRY_VALUE is stored to a pointer now * fixed REG_INFO to correctly display data when double clicking on and entry in the registry editor * Will now enumerate installed driver_info_3 data * fixed numerous bugs related to pointer offsets, memory issues, etc.. in the registry routines * added a simple caching mechanism to fetch_reg_[keys|values]_specific() All that is left now is to enumerate PrinterData and I will have finished what I started out to do.... (This used to be commit 419d7208e8384e4ad2c4dd328ad5e630971bc76c) --- source3/rpc_server/srv_reg.c | 29 +++++++- source3/rpc_server/srv_reg_nt.c | 154 ++++++++++++++++++++++++---------------- 2 files changed, 119 insertions(+), 64 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index ee873e32e9..cb96005db1 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -83,7 +83,7 @@ static BOOL api_reg_open_hklm(pipes_struct *p) } /******************************************************************* - api_reg_open_khlm + api_reg_open_khu ********************************************************************/ static BOOL api_reg_open_hku(pipes_struct *p) @@ -108,6 +108,32 @@ static BOOL api_reg_open_hku(pipes_struct *p) return True; } +/******************************************************************* + api_reg_open_khcr + ********************************************************************/ + +static BOOL api_reg_open_hkcr(pipes_struct *p) +{ + REG_Q_OPEN_HKCR q_u; + REG_R_OPEN_HKCR r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the reg open */ + if(!reg_io_q_open_hkcr("", &q_u, data, 0)) + return False; + + r_u.status = _reg_open_hkcr(p, &q_u, &r_u); + + if(!reg_io_r_open_hkcr("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* api_reg_open_entry @@ -324,6 +350,7 @@ static struct api_struct api_reg_cmds[] = { { "REG_CLOSE" , REG_CLOSE , api_reg_close }, { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, + { "REG_OPEN_HKCR" , REG_OPEN_HKCR , api_reg_open_hkcr }, { "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm }, { "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku }, { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key }, diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 99439bcc38..3afb2a2c81 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -78,33 +78,35 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY char *subkeyname, uint32 access_granted ) { REGISTRY_KEY *regkey = NULL; - pstring parent_keyname; NTSTATUS result = NT_STATUS_OK; REGSUBKEY_CTR subkeys; - if ( parent ) { - pstrcpy( parent_keyname, parent->name ); - pstrcat( parent_keyname, "\\" ); - } - else - *parent_keyname = '\0'; - - DEBUG(7,("open_registry_key: name = [%s][%s]\n", parent_keyname, subkeyname)); + DEBUG(7,("open_registry_key: name = [%s][%s]\n", + parent ? parent->name : "NULL", subkeyname)); - /* All registry keys **must** have a name of non-zero length */ - - if (!subkeyname || !*subkeyname ) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - if ((regkey=(REGISTRY_KEY*)malloc(sizeof(REGISTRY_KEY))) == NULL) return NT_STATUS_NO_MEMORY; ZERO_STRUCTP( regkey ); - /* copy the name */ + /* + * very crazy, but regedit.exe on Win2k will attempt to call + * REG_OPEN_ENTRY with a keyname of "". We should return a new + * (second) handle here on the key->name. regedt32.exe does + * not do this stupidity. --jerry + */ - pstrcpy( regkey->name, parent_keyname ); - pstrcat( regkey->name, subkeyname ); + if (!subkeyname || !*subkeyname ) { + pstrcpy( regkey->name, parent->name ); + } + else { + pstrcpy( regkey->name, "" ); + if ( parent ) { + pstrcat( regkey->name, parent->name ); + pstrcat( regkey->name, "\\" ); + } + pstrcat( regkey->name, subkeyname ); + } /* Look up the table of registry I/O operations */ @@ -227,7 +229,8 @@ static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum, if ( !key ) return False; - ZERO_STRUCTP( &val ); + + ZERO_STRUCTP( &values ); regval_ctr_init( &values ); @@ -274,7 +277,6 @@ NTSTATUS _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) } /******************************************************************* - reg_reply_open ********************************************************************/ NTSTATUS _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u) @@ -283,7 +285,14 @@ NTSTATUS _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM * } /******************************************************************* - reg_reply_open + ********************************************************************/ + +NTSTATUS _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HKCR *q_u, REG_R_OPEN_HKCR *r_u) +{ + return open_registry_key( p, &r_u->pol, NULL, KEY_HKCR, 0x0 ); +} + +/******************************************************************* ********************************************************************/ NTSTATUS _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HKU *q_u, REG_R_OPEN_HKU *r_u) @@ -310,7 +319,7 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR rpcstr_pull(name,q_u->uni_name.buffer,sizeof(name),q_u->uni_name.uni_str_len*2,0); DEBUG(5,("reg_open_entry: Enter\n")); - + result = open_registry_key( p, &pol, key, name, 0x0 ); init_reg_r_open_entry( r_u, &pol, result ); @@ -326,64 +335,83 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) { - NTSTATUS status = NT_STATUS_OK; - char *value = NULL; - uint32 type = 0x1; /* key type: REG_SZ */ - UNISTR2 *uni_key = NULL; - BUFFER2 *buf = NULL; - fstring name; - REGISTRY_KEY *key = find_regkey_index_by_hnd( p, &q_u->pol ); + NTSTATUS status = NT_STATUS_NO_SUCH_FILE; + fstring name; + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + REGISTRY_VALUE *val = NULL; + REGISTRY_VALUE emptyval; + REGVAL_CTR regvals; + int i; DEBUG(5,("_reg_info: Enter\n")); - if ( !key ) + if ( !regkey ) return NT_STATUS_INVALID_HANDLE; - DEBUG(7,("_reg_info: policy key name = [%s]\n", key->name)); - + DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); + rpcstr_pull(name, q_u->uni_type.buffer, sizeof(name), q_u->uni_type.uni_str_len*2, 0); - DEBUG(5,("reg_info: checking subkey: %s\n", name)); - - uni_key = (UNISTR2 *)talloc_zero(p->mem_ctx, sizeof(UNISTR2)); - buf = (BUFFER2 *)talloc_zero(p->mem_ctx, sizeof(BUFFER2)); + DEBUG(5,("reg_info: looking up value: [%s]\n", name)); - if (!uni_key || !buf) - return NT_STATUS_NO_MEMORY; + ZERO_STRUCTP( ®vals ); + + regval_ctr_init( ®vals ); + /* couple of hard coded registry values */ + if ( strequal(name, "RefusePasswordChange") ) { - type=0xF770; - status = NT_STATUS_NO_SUCH_FILE; - init_unistr2(uni_key, "", 0); - init_buffer2(buf, (uint8*) uni_key->buffer, uni_key->uni_str_len*2); - - buf->buf_max_len=4; + ZERO_STRUCTP( &emptyval ); + val = &emptyval; + + goto out; + } + if ( strequal(name, "ProductType") ) { + /* This makes the server look like a member server to clients */ + /* which tells clients that we have our own local user and */ + /* group databases and helps with ACL support. */ + + switch (lp_server_role()) { + case ROLE_DOMAIN_PDC: + case ROLE_DOMAIN_BDC: + regval_ctr_addvalue( ®vals, "ProductType", REG_SZ, "LanmanNT", strlen("LanmanNT")+1 ); + break; + case ROLE_STANDALONE: + regval_ctr_addvalue( ®vals, "ProductType", REG_SZ, "ServerNT", strlen("ServerNT")+1 ); + break; + case ROLE_DOMAIN_MEMBER: + regval_ctr_addvalue( ®vals, "ProductType", REG_SZ, "WinNT", strlen("WinNT")+1 ); + break; + } + + val = regval_ctr_specific_value( ®vals, 0 ); + + status = NT_STATUS_OK; + goto out; } - switch (lp_server_role()) { - case ROLE_DOMAIN_PDC: - case ROLE_DOMAIN_BDC: - value = "LanmanNT"; - break; - case ROLE_STANDALONE: - value = "ServerNT"; - break; - case ROLE_DOMAIN_MEMBER: - value = "WinNT"; + /* else fall back to actually looking up the value */ + + for ( i=0; fetch_reg_values_specific(regkey, &val, i); i++ ) + { + DEBUG(10,("_reg_info: Testing value [%s]\n", val->valuename)); + if ( StrCaseCmp( val->valuename, name ) == 0 ) { + DEBUG(10,("_reg_info: Found match for value [%s]\n", name)); + status = NT_STATUS_OK; break; + } + + free_registry_value( val ); } - /* This makes the server look like a member server to clients */ - /* which tells clients that we have our own local user and */ - /* group databases and helps with ACL support. */ - - init_unistr2(uni_key, value, strlen(value)+1); - init_buffer2(buf, (uint8*)uni_key->buffer, uni_key->uni_str_len*2); - out: - init_reg_r_info(q_u->ptr_buf, r_u, buf, type, status); +out: + new_init_reg_r_info(q_u->ptr_buf, r_u, val, status); + + regval_ctr_destroy( ®vals ); + free_registry_value( val ); DEBUG(5,("_reg_info: Exit\n")); @@ -455,7 +483,7 @@ NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u { NTSTATUS status = NT_STATUS_OK; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - char *subkey; + char *subkey = NULL; DEBUG(5,("_reg_enum_key: Enter\n")); @@ -518,7 +546,7 @@ NTSTATUS _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALU DEBUG(5,("_reg_enum_value: Exit\n")); done: - SAFE_FREE( val ); + free_registry_value( val ); return status; } -- cgit From a12ed7f506263c6ec34c7df6bbcb3e8434841403 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 24 Jul 2002 08:58:03 +0000 Subject: done! printer_info_2, devicemode, sec_desc, & printer data all enumerate and display correctly in regedit.exe. Not sure about REG_SZ values in PrinterDriverData. If we store these in UNICODE, I'll have to fix up a few things. REG_BINARY & REG_DWORD are fine. (This used to be commit 2a30c243ec28734bbc721dfc01b743faa6f73788) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index bc58655f71..46aebbe3a3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3374,7 +3374,7 @@ static void free_dev_mode(DEVICEMODE *dev) Create a DEVMODE struct. Returns malloced memory. ****************************************************************************/ -static DEVICEMODE *construct_dev_mode(int snum) +DEVICEMODE *construct_dev_mode(int snum) { char adevice[32]; char aform[32]; -- cgit From f1ed55d9032200eae68fc88bfb464e653497f315 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 24 Jul 2002 19:53:49 +0000 Subject: * fix return code so we don't let a client just open any key it wants (even nonexistent ones). This gets rid of the Scheduling Agent icon. * fix NT_STATUS return code for bad registry path (NT_STATUS_NO_SUCH_FILE) (This used to be commit 915ee5c0ec0467fea23be8f309bcaa085c6ed9dd) --- source3/rpc_server/srv_reg_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 3afb2a2c81..2154b5a38a 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -127,7 +127,7 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY /* don't really know what to return here */ - result = NT_STATUS_ACCESS_DENIED; + result = NT_STATUS_NO_SUCH_FILE; } else { /* -- cgit From a56490007479b3f23f5159bfb7545136c40dd1fd Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 26 Jul 2002 13:05:29 +0000 Subject: Mimir has been busy with patches again, and sent in the following patches: Andrew Bartlett From his e-mail: Below I attach the following patches as a result of my work on trusted domains support: 1) srv_samr_nt.c.diff This fixes a bug which caused to return null string as the first entry of enumerated accounts list (no matter what entry, it was always null string and rid) and possibly spoiled further names, depeding on their length. I found that while testing my 'net rpc trustdom list' against nt servers and samba server. 2) libsmb.diff Now, fallback to anonymous connection works correctly. 3) smbpasswd.c.diff Just a little fix which actually allows one to create a trusting domain account using smbpasswd 4) typos.diff As the name suggests, it's just a few typos fix :) (This used to be commit 888d595fab4f6b28318b743f47378cb7ca35d479) --- source3/rpc_server/srv_samr_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index eb74acf35b..2a7a5518cd 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -727,8 +727,6 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UN } for (i = 0; i < num_entries; i++) { - int len = uni_temp_name.uni_str_len; - pwd = disp_user_info[i+start_idx].sam; temp_name = pdb_get_username(pwd); init_unistr2(&uni_temp_name, temp_name, strlen(temp_name)+1); @@ -743,7 +741,7 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UN return NT_STATUS_UNSUCCESSFUL; } - init_sam_entry(&sam[i], len, user_rid); + init_sam_entry(&sam[i], uni_temp_name.uni_str_len, user_rid); copy_unistr2(&uni_name[i], &uni_temp_name); } -- cgit From a23e96316ebf5086a27365d4a9fb63b0e4533f6f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 26 Jul 2002 22:40:06 +0000 Subject: 3 things: * normalize all registry key strings before storing or looking up paths in the registry tdb * return the current buffer size for REG_INFO even when not returning actual data * fix a segfault report by metze on #samba-technical so that the user/group object picker works again (was the "ProductType" key lookup that was failing). (This used to be commit 5640e6cdb213502d95fff33e06eaeed5ce3aeb76) --- source3/rpc_server/srv_reg_nt.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 2154b5a38a..7ebf940588 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -29,6 +29,11 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +#define REGSTR_PRODUCTTYPE "ProductType" +#define REG_PT_WINNT "WinNT" +#define REG_PT_LANMANNT "LanmanNT" +#define REG_PT_SERVERNT "ServerNT" + #define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ ((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) @@ -367,7 +372,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) goto out; } - if ( strequal(name, "ProductType") ) { + if ( strequal(name, REGSTR_PRODUCTTYPE) ) { /* This makes the server look like a member server to clients */ /* which tells clients that we have our own local user and */ /* group databases and helps with ACL support. */ @@ -375,17 +380,17 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - regval_ctr_addvalue( ®vals, "ProductType", REG_SZ, "LanmanNT", strlen("LanmanNT")+1 ); + regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_LANMANNT, strlen(REG_PT_LANMANNT)+1 ); break; case ROLE_STANDALONE: - regval_ctr_addvalue( ®vals, "ProductType", REG_SZ, "ServerNT", strlen("ServerNT")+1 ); + regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_SERVERNT, strlen(REG_PT_SERVERNT)+1 ); break; case ROLE_DOMAIN_MEMBER: - regval_ctr_addvalue( ®vals, "ProductType", REG_SZ, "WinNT", strlen("WinNT")+1 ); + regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_WINNT, strlen(REG_PT_WINNT)+1 ); break; } - val = regval_ctr_specific_value( ®vals, 0 ); + val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); status = NT_STATUS_OK; -- cgit From 7ce66f79ea84d77f186bbf6e7831dc71cc6ec46a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 27 Jul 2002 11:48:55 +0000 Subject: A very long time ago (actually 6 months ago) I promised to commit this code to the Samba tree. Originally written by Nigel Williams" , I've been trying to keep it in some form of shape for the last 6 months. In particular I think some of the code got committed a few months ago, and others have made changes to the CVS version over time. anyway, its finally in - and doesn't appear to have broken anything. Now to try the client-side patches :-) Andrew Bartlett (This used to be commit f9bac7c5c2c4ddf0bf39d596a7b922fbb17c6b16) --- source3/rpc_server/srv_srvsvc.c | 31 +++ source3/rpc_server/srv_srvsvc_nt.c | 394 +++++++++++++++++++++++++++++-------- 2 files changed, 338 insertions(+), 87 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 5e1c005d54..4a372de089 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -344,6 +344,36 @@ static BOOL api_srv_net_share_del(pipes_struct *p) return True; } +/******************************************************************* + RPC to delete share information. +********************************************************************/ + +static BOOL api_srv_net_share_del_sticky(pipes_struct *p) +{ + SRV_Q_NET_SHARE_DEL q_u; + SRV_R_NET_SHARE_DEL r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server del info. */ + if(!srv_io_q_net_share_del("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_share_del_sticky: Failed to unmarshall SRV_Q_NET_SHARE_DEL.\n")); + return False; + } + + r_u.status = _srv_net_share_del_sticky(p, &q_u, &r_u); + + if(!srv_io_r_net_share_del("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_del_sticky: Failed to marshall SRV_R_NET_SHARE_DEL.\n")); + return False; + } + + return True; +} + /******************************************************************* api_srv_net_remote_tod ********************************************************************/ @@ -503,6 +533,7 @@ static const struct api_struct api_srv_cmds[] = { "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum }, { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del }, + { "SRV_NET_SHARE_DEL_STICKY", SRV_NET_SHARE_DEL_STICKY, api_srv_net_share_del_sticky }, { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info }, { "SRV_NET_SHARE_SET_INFO", SRV_NET_SHARE_SET_INFO, api_srv_net_share_set_info }, { "SRV_NET_FILE_ENUM" , SRV_NET_FILE_ENUM , api_srv_net_file_enum }, diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 202e869d35..b68dcce672 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -3,6 +3,7 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Nigel Williams 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,33 +29,54 @@ extern pstring global_myname; +/******************************************************************* + Utility function to get the 'type' of a share from an snum. + ********************************************************************/ +static uint32 get_share_type(int snum) +{ + char *net_name = lp_servicename(snum); + int len_net_name = strlen(net_name); + + /* work out the share type */ + uint32 type = STYPE_DISKTREE; + + if (lp_print_ok(snum)) + type = STYPE_PRINTQ; + if (strequal(lp_fstype(snum), "IPC")) + type = STYPE_IPC; + if (net_name[len_net_name] == '$') + type |= STYPE_HIDDEN; + + return type; +} + +/******************************************************************* + Fill in a share info level 0 structure. + ********************************************************************/ + +static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int snum) +{ + pstring net_name; + + pstrcpy(net_name, lp_servicename(snum)); + + init_srv_share_info0(&sh0->info_0, net_name); + init_srv_share_info0_str(&sh0->info_0_str, net_name); +} + /******************************************************************* Fill in a share info level 1 structure. ********************************************************************/ static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum) { - int len_net_name; - pstring net_name; pstring remark; - uint32 type; - pstrcpy(net_name, lp_servicename(snum)); + char *net_name = lp_servicename(snum); pstrcpy(remark, lp_comment(snum)); standard_sub_conn(p->conn, remark,sizeof(remark)); - len_net_name = strlen(net_name); - /* work out the share type */ - type = STYPE_DISKTREE; - - if (lp_print_ok(snum)) - type = STYPE_PRINTQ; - if (strequal("IPC$", net_name) || strequal("ADMIN$", net_name)) - type = STYPE_IPC; - if (net_name[len_net_name] == '$') - type |= STYPE_HIDDEN; - - init_srv_share_info1(&sh1->info_1, net_name, type, remark); + init_srv_share_info1(&sh1->info_1, net_name, get_share_type(snum), remark); init_srv_share_info1_str(&sh1->info_1_str, net_name, remark); } @@ -64,14 +86,11 @@ static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int sn static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int snum) { - int len_net_name; - pstring net_name; pstring remark; pstring path; pstring passwd; - uint32 type; - pstrcpy(net_name, lp_servicename(snum)); + char *net_name = lp_servicename(snum); pstrcpy(remark, lp_comment(snum)); standard_sub_conn(p->conn, remark,sizeof(remark)); pstrcpy(path, "C:"); @@ -85,19 +104,8 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int sn string_replace(path, '/', '\\'); pstrcpy(passwd, ""); - len_net_name = strlen(net_name); - /* work out the share type */ - type = STYPE_DISKTREE; - - if (lp_print_ok(snum)) - type = STYPE_PRINTQ; - if (strequal("IPC$", net_name) || strequal("ADMIN$", net_name)) - type = STYPE_IPC; - if (net_name[len_net_name] == '$') - type |= STYPE_HIDDEN; - - init_srv_share_info2(&sh2->info_2, net_name, type, remark, 0, 0xffffffff, 1, path, passwd); + init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd); init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); } @@ -251,7 +259,7 @@ static BOOL set_share_security(TALLOC_CTX *ctx, const char *share_name, SEC_DESC /* Free malloc'ed memory */ - out: +out: prs_mem_free(&ps); if (mem_ctx) @@ -337,7 +345,7 @@ BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, u ret = se_access_check(psd, token, desired_access, &granted, &status); - out: +out: talloc_destroy(mem_ctx); @@ -351,27 +359,15 @@ BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, u static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum) { int len_net_name; - pstring net_name; pstring remark; - uint32 type; - pstrcpy(net_name, lp_servicename(snum)); + char *net_name = lp_servicename(snum); pstrcpy(remark, lp_comment(snum)); standard_sub_conn(p->conn, remark, sizeof(remark)); len_net_name = strlen(net_name); - /* work out the share type */ - type = STYPE_DISKTREE; - - if (lp_print_ok(snum)) - type = STYPE_PRINTQ; - if (strequal("IPC$", net_name) || strequal("ADMIN$", net_name)) - type = STYPE_IPC; - if (net_name[len_net_name] == '$') - type |= STYPE_HIDDEN; - - init_srv_share_info501(&sh501->info_501, net_name, type, remark, (lp_csc_policy(snum) << 4)); + init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), remark, (lp_csc_policy(snum) << 4)); init_srv_share_info501_str(&sh501->info_501_str, net_name, remark); } @@ -386,7 +382,6 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, pstring remark; pstring path; pstring passwd; - uint32 type; SEC_DESC *sd; size_t sd_size; TALLOC_CTX *ctx = p->mem_ctx; @@ -410,39 +405,86 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, pstrcpy(passwd, ""); len_net_name = strlen(net_name); - /* work out the share type */ - type = STYPE_DISKTREE; - - if (lp_print_ok(snum)) - type = STYPE_PRINTQ; - if (strequal("IPC$", net_name)) - type = STYPE_IPC; - if (net_name[len_net_name] == '$') - type |= STYPE_HIDDEN; - sd = get_share_security(ctx, snum, &sd_size); - init_srv_share_info502(&sh502->info_502, net_name, type, remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size); - init_srv_share_info502_str(&sh502->info_502_str, &sh502->info_502, net_name, remark, path, passwd, sd, sd_size); + init_srv_share_info502(&sh502->info_502, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size); + init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, path, passwd, sd, sd_size); +} + +/*************************************************************************** + Fill in a share info level 1004 structure. + ***************************************************************************/ + +static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh1004, int snum) +{ + pstring remark; + + pstrcpy(remark, lp_comment(snum)); + standard_sub_conn(p->conn, remark, sizeof(remark)); + + ZERO_STRUCTP(sh1004); + + init_srv_share_info1004(&sh1004->info_1004, remark); + init_srv_share_info1004_str(&sh1004->info_1004_str, remark); } /*************************************************************************** Fill in a share info level 1005 structure. ***************************************************************************/ -static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum) +static void init_srv_share_info_1005(pipes_struct *p, SRV_SHARE_INFO_1005* sh1005, int snum) { sh1005->dfs_root_flag = 0; if(lp_host_msdfs() && lp_msdfs_root(snum)) sh1005->dfs_root_flag = 3; } +/*************************************************************************** + Fill in a share info level 1006 structure. + ***************************************************************************/ + +static void init_srv_share_info_1006(pipes_struct *p, SRV_SHARE_INFO_1006* sh1006, int snum) +{ + sh1006->max_uses = -1; +} + +/*************************************************************************** + Fill in a share info level 1007 structure. + ***************************************************************************/ + +static void init_srv_share_info_1007(pipes_struct *p, SRV_SHARE_INFO_1007* sh1007, int snum) +{ + pstring alternate_directory_name = ""; + uint32 flags = 0; + + ZERO_STRUCTP(sh1007); + + init_srv_share_info1007(&sh1007->info_1007, flags, alternate_directory_name); + init_srv_share_info1007_str(&sh1007->info_1007_str, alternate_directory_name); +} + +/******************************************************************* + Fill in a share info level 1501 structure. + ********************************************************************/ + +static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh1501, int snum) +{ + SEC_DESC *sd; + size_t sd_size; + TALLOC_CTX *ctx = p->mem_ctx; + + ZERO_STRUCTP(sh1501); + + sd = get_share_security(ctx, snum, &sd_size); + + sh1501->sdb = make_sec_desc_buf(p->mem_ctx, sd_size, sd); +} /******************************************************************* True if it ends in '$'. ********************************************************************/ -static BOOL is_admin_share(int snum) +static BOOL is_hidden_share(int snum) { pstring net_name; @@ -471,7 +513,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, /* Count the number of entries. */ for (snum = 0; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) num_entries++; } @@ -483,6 +525,24 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, return True; switch (info_level) { + case 0: + { + SRV_SHARE_INFO_0 *info0; + int i = 0; + + info0 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_0)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_0(p, &info0[i++], snum); + } + } + + ctr->share.info0 = info0; + break; + + } + case 1: { SRV_SHARE_INFO_1 *info1; @@ -491,7 +551,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, info1 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1)); for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { init_srv_share_info_1(p, &info1[i++], snum); } } @@ -508,7 +568,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, info2 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_2)); for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { init_srv_share_info_2(p, &info2[i++], snum); } } @@ -525,7 +585,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, info501 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_501)); for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { init_srv_share_info_501(p, &info501[i++], snum); } } @@ -542,7 +602,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, info502 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_502)); for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { init_srv_share_info_502(p, &info502[i++], snum); } } @@ -551,6 +611,92 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, break; } + /* here for completeness but not currently used with enum (1004 - 1501)*/ + + case 1004: + { + SRV_SHARE_INFO_1004 *info1004; + int i = 0; + + info1004 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1004)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1004(p, &info1004[i++], snum); + } + } + + ctr->share.info1004 = info1004; + break; + } + + case 1005: + { + SRV_SHARE_INFO_1005 *info1005; + int i = 0; + + info1005 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1005)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1005(p, &info1005[i++], snum); + } + } + + ctr->share.info1005 = info1005; + break; + } + + case 1006: + { + SRV_SHARE_INFO_1006 *info1006; + int i = 0; + + info1006 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1006)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1006(p, &info1006[i++], snum); + } + } + + ctr->share.info1006 = info1006; + break; + } + + case 1007: + { + SRV_SHARE_INFO_1007 *info1007; + int i = 0; + + info1007 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1007)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1007(p, &info1007[i++], snum); + } + } + + ctr->share.info1007 = info1007; + break; + } + + case 1501: + { + SRV_SHARE_INFO_1501 *info1501; + int i = 0; + + info1501 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1501)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1501(p, &info1501[i++], snum); + } + } + + ctr->share.info1501 = info1501; + break; + } default: DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level)); return False; @@ -596,6 +742,9 @@ static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_I if (snum >= 0) { switch (info_level) { + case 0: + init_srv_share_info_0(p, &r_n->info.share.info0, snum); + break; case 1: init_srv_share_info_1(p, &r_n->info.share.info1, snum); break; @@ -608,8 +757,24 @@ static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_I case 502: init_srv_share_info_502(p, &r_n->info.share.info502, snum); break; + + /* here for completeness */ + case 1004: + init_srv_share_info_1004(p, &r_n->info.share.info1004, snum); + break; case 1005: - init_srv_share_info_1005(&r_n->info.share.info1005, snum); + init_srv_share_info_1005(p, &r_n->info.share.info1005, snum); + break; + + /* here for completeness 1006 - 1501 */ + case 1006: + init_srv_share_info_1006(p, &r_n->info.share.info1006, snum); + break; + case 1007: + init_srv_share_info_1007(p, &r_n->info.share.info1007, snum); + break; + case 1501: + init_srv_share_info_1501(p, &r_n->info.share.info1501, snum); break; default: DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level)); @@ -955,7 +1120,8 @@ static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, ********************************************************************/ static WERROR init_srv_file_info_ctr(pipes_struct *p, SRV_FILE_INFO_CTR *ctr, - int switch_value, uint32 *resume_hnd, uint32 *total_entries) + int switch_value, uint32 *resume_hnd, + uint32 *total_entries) { WERROR status = WERR_OK; TALLOC_CTX *ctx = p->mem_ctx; @@ -1206,8 +1372,8 @@ WERROR _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET /* Create the list of shares for the response. */ init_srv_r_net_share_enum(p, r_u, - q_u->ctr.info_level, - get_enum_hnd(&q_u->enum_hnd), False); + q_u->ctr.info_level, + get_enum_hnd(&q_u->enum_hnd), False); DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); @@ -1295,7 +1461,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); - r_u->switch_value = 0; + r_u->parm_error = 0; if (strequal(share_name,"IPC$") || strequal(share_name,"ADMIN$") || strequal(share_name,"global")) return WERR_ACCESS_DENIED; @@ -1312,28 +1478,47 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S get_current_user(&user,p); - if (user.uid != 0) + if (user.uid != sec_initial_uid()) return WERR_ACCESS_DENIED; switch (q_u->info_level) { case 1: - /* Not enough info in a level 1 to do anything. */ - return WERR_ACCESS_DENIED; + fstrcpy(pathname, lp_pathname(snum)); + unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); + type = q_u->info.share.info2.info_2.type; + psd = NULL; + break; 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)); + unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); + unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(pathname)); type = q_u->info.share.info2.info_2.type; psd = NULL; break; +#if 0 + /* not supported on set but here for completeness */ + case 501: + unistr2_to_ascii(comment, &q_u->info.share.info501.info_501_str.uni_remark, sizeof(comment)); + type = q_u->info.share.info501.info_501.type; + psd = NULL; + break; +#endif case 502: - unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name)); - unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name)); + unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(comment)); + unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(pathname)); type = q_u->info.share.info502.info_502.type; psd = q_u->info.share.info502.info_502_str.sd; map_generic_share_sd_bits(psd); break; + case 1004: + fstrcpy(pathname, lp_pathname(snum)); + unistr2_to_ascii(comment, &q_u->info.share.info1004.info_1004_str.uni_remark, sizeof(comment)); + type = STYPE_DISKTREE; + break; case 1005: + case 1006: + case 1007: return WERR_ACCESS_DENIED; + break; case 1501: fstrcpy(pathname, lp_pathname(snum)); fstrcpy(comment, lp_comment(snum)); @@ -1422,12 +1607,12 @@ WERROR _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__)); - r_u->switch_value = 0; + r_u->parm_error = 0; get_current_user(&user,p); - if (user.uid != 0) { - DEBUG(10,("_srv_net_share_add: uid != 0. Access denied.\n")); + if (user.uid != sec_initial_uid()) { + DEBUG(10,("_srv_net_share_add: uid != sec_initial_uid(). Access denied.\n")); return WERR_ACCESS_DENIED; } @@ -1437,6 +1622,9 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S } switch (q_u->info_level) { + case 0: + /* No path. Not enough info in a level 0 to do anything. */ + return WERR_ACCESS_DENIED; case 1: /* Not enough info in a level 1 to do anything. */ return WERR_ACCESS_DENIED; @@ -1446,6 +1634,9 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name)); type = q_u->info.share.info2.info_2.type; break; + case 501: + /* No path. Not enough info in a level 501 to do anything. */ + return WERR_ACCESS_DENIED; case 502: unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name)); unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name)); @@ -1454,7 +1645,16 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S psd = q_u->info.share.info502.info_502_str.sd; map_generic_share_sd_bits(psd); break; + + /* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */ + + case 1004: case 1005: + case 1006: + case 1007: + return WERR_ACCESS_DENIED; + break; + case 1501: /* DFS only level. */ return WERR_ACCESS_DENIED; default: @@ -1544,7 +1744,7 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S get_current_user(&user,p); - if (user.uid != 0) + if (user.uid != sec_initial_uid()) return WERR_ACCESS_DENIED; if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) @@ -1570,6 +1770,13 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S return WERR_OK; } +WERROR _srv_net_share_del_sticky(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) +{ + DEBUG(5,("_srv_net_share_del_stick: %d\n", __LINE__)); + + return _srv_net_share_del(p, q_u, r_u); +} + /******************************************************************* time of day ********************************************************************/ @@ -1703,7 +1910,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC close_cnum(conn, user.vuid); return r_u->status; - error_exit: +error_exit: if(fsp) { close_file(fsp, True); @@ -1799,7 +2006,7 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ close_cnum(conn, user.vuid); return r_u->status; - error_exit: +error_exit: if(fsp) { close_file(fsp, True); @@ -1864,6 +2071,7 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D { uint32 i; const char *disk_name; + TALLOC_CTX *ctx = p->mem_ctx; uint32 resume=get_enum_hnd(&q_u->enum_hnd); r_u->status=WERR_OK; @@ -1872,6 +2080,18 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D r_u->disk_enum_ctr.unknown = 0; + { + DISK_INFO *dinfo; + + int dinfo_size = MAX_SERVER_DISK_ENTRIES * sizeof(*dinfo); + + if(!(dinfo = talloc(ctx, dinfo_size))) { + + } + + r_u->disk_enum_ctr.disk_info = dinfo; + } + r_u->disk_enum_ctr.disk_info_ptr = r_u->disk_enum_ctr.disk_info ? 1 : 0; /*allow one DISK_INFO for null terminator*/ @@ -1885,7 +2105,7 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name); } - /*add a terminating null string. Is this there if there is more data to come?*/ + /* add a terminating null string. Is this there if there is more data to come? */ r_u->disk_enum_ctr.entries_read++; -- cgit From 86b7abe54cff1aa3494656f7f3f547f2747e4fce Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 28 Jul 2002 03:41:50 +0000 Subject: Fix a missing 'no memory' return in last night's svrsvc code, and use sys_dup2() in a couple more places. Andrew Bartlett (This used to be commit e69b476626c802b1e1920f241733d0dd6d06a06e) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index b68dcce672..5c1038949b 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2086,7 +2086,7 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D int dinfo_size = MAX_SERVER_DISK_ENTRIES * sizeof(*dinfo); if(!(dinfo = talloc(ctx, dinfo_size))) { - + return WERR_NOMEM; } r_u->disk_enum_ctr.disk_info = dinfo; -- cgit From d7ad31cdea8fa2ad1f71968388305960076e387f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 29 Jul 2002 13:24:56 +0000 Subject: merge from SAMBA_2_2 (This used to be commit c268ae460e7e6fe25b6ac1583ea6d2f233c27d0f) --- source3/rpc_server/srv_spoolss_nt.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 46aebbe3a3..4691cbee01 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8234,7 +8234,6 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ while (get_specific_param_by_index(*printer, 2, param_index, value, &data, &type, &data_len)) { PRINTER_ENUM_VALUES *ptr; - uint32 add_len = 0; DEBUG(10,("retrieved value number [%d] [%s]\n", num_entries, value)); @@ -8245,19 +8244,26 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ goto done; } enum_values = ptr; + + ZERO_STRUCTP( &enum_values[num_entries] ); /* copy the data */ + init_unistr(&enum_values[num_entries].valuename, value); enum_values[num_entries].value_len = (strlen(value)+1) * 2; enum_values[num_entries].type = type; - if (!(enum_values[num_entries].data=talloc_zero(p->mem_ctx, data_len+add_len))) { - DEBUG(0,("talloc_realloc failed to allocate more memory for data!\n")); - result = WERR_NOMEM; - goto done; + if ( data_len ) + { + if ( !(enum_values[num_entries].data = talloc_zero(p->mem_ctx, data_len)) ) { + DEBUG(0,("talloc_realloc failed to allocate more memory [data_len=%d] for data!\n", data_len )); + result = WERR_NOMEM; + goto done; + } + memcpy(enum_values[num_entries].data, data, data_len); } - memcpy(enum_values[num_entries].data, data, data_len); - enum_values[num_entries].data_len = data_len + add_len; + + enum_values[num_entries].data_len = data_len; /* keep track of the size of the array in bytes */ -- cgit From 9f7e67c6f9eec4f21d5afbe323dc1c664ff52b54 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 29 Jul 2002 18:10:59 +0000 Subject: couple of minor formatting fixes to help me see better. (This used to be commit 26027ee42ae378eef59a8ae46f5e4e44bf2d4af0) --- source3/rpc_server/srv_spoolss_nt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4691cbee01..20a586a6fb 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6813,7 +6813,6 @@ WERROR _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, SPOOL_R_ADDPRINTERDRIVER *r_u) { -/* UNISTR2 *server_name = &q_u->server_name; - notused. */ uint32 level = q_u->level; SPOOL_PRINTER_DRIVER_INFO_LEVEL *info = &q_u->info; WERROR err = WERR_OK; @@ -6891,7 +6890,9 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, version = driver.info_6->version; else version = -1; - switch (version) { + + switch (version) + { /* * 9x printer driver - never delete init data */ @@ -6962,12 +6963,14 @@ WERROR _spoolss_addprinterdriverex(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVEREX * return WERR_ACCESS_DENIED; /* just pass the information off to _spoolss_addprinterdriver() */ + ZERO_STRUCT(q_u_local); ZERO_STRUCT(r_u_local); q_u_local.server_name_ptr = q_u->server_name_ptr; copy_unistr2(&q_u_local.server_name, &q_u->server_name); q_u_local.level = q_u->level; + memcpy( &q_u_local.info, &q_u->info, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL) ); return _spoolss_addprinterdriver( p, &q_u_local, &r_u_local ); -- cgit From c17dc6c55c3a5a2912028a1d6a713f26b3b91c63 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 29 Jul 2002 19:45:15 +0000 Subject: add another registry rpc (opnum 0x14). Have no idea what it's real name is. I'm calling it REG_SAVE_KEY, because 2k preps a regedt32.exe Registry->Save Key with this call. Done in the process of tracking down a PrinterDriverData issue. (This used to be commit 66104a361424f10cc986c597b91afa6f12b3cd8a) --- source3/rpc_server/srv_reg.c | 26 ++++++++++++++++++++++++++ source3/rpc_server/srv_reg_nt.c | 24 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index cb96005db1..d0aaf0199b 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -341,6 +341,31 @@ static BOOL api_reg_enum_value(pipes_struct *p) return True; } +/******************************************************************* + api_reg_save_key + ********************************************************************/ + +static BOOL api_reg_save_key(pipes_struct *p) +{ + REG_Q_SAVE_KEY q_u; + REG_R_SAVE_KEY r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_save_key("", &q_u, data, 0)) + return False; + + r_u.status = _reg_save_key(p, &q_u, &r_u); + + if(!reg_io_r_save_key("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* @@ -360,6 +385,7 @@ static struct api_struct api_reg_cmds[] = { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, { "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a }, + { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key }, { NULL , 0 , NULL } }; diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 7ebf940588..cd9596d2a7 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -622,4 +622,28 @@ NTSTATUS _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_A return status; } +/******************************************************************* + REG_SAVE_KEY (0x14) + ********************************************************************/ + +NTSTATUS _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) +{ + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + + DEBUG(5,("_reg_save_key: Enter\n")); + + /* + * basically this is a no op function which just gverifies + * that the client gave us a valid registry key handle + */ + + if ( !regkey ) + return NT_STATUS_INVALID_HANDLE; + + DEBUG(8,("_reg_save_key: berifying backup of key [%s]\n", regkey->name)); + + + return NT_STATUS_OK; +} + -- cgit From 89d46eeb33c2d8e2b9b5a06ebe3a369675ae3657 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Tue, 30 Jul 2002 17:23:07 +0000 Subject: Add LSA RPC 0x2E, lsa_query_info2. Only level implemented is 0x0c, which is netbios and dns domain info. Also add code to set/fetch the domain GUID from secrets.tdb (although set is not yet called by anyone). (This used to be commit 31d7168530ccce2c5e9e7f96464b47f4d9771a25) --- source3/rpc_server/srv_lsa.c | 37 +++++++++++++++- source3/rpc_server/srv_lsa_nt.c | 97 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 131 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index e5a4d3b46d..e3495576c9 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -3,8 +3,9 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Jim McDonough 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -609,6 +610,37 @@ static BOOL api_lsa_query_secobj(pipes_struct *p) return True; } +/*************************************************************************** + api_lsa_query_dnsdomainfo + ***************************************************************************/ + +static BOOL api_lsa_query_info2(pipes_struct *p) +{ + LSA_Q_QUERY_INFO2 q_u; + LSA_R_QUERY_INFO2 r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_query_info2("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_query_info2: failed to unmarshall LSA_Q_QUERY_INFO2.\n")); + return False; + } + + r_u.status = _lsa_query_info2(p, &q_u, &r_u); + + if (!lsa_io_r_query_info2("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_query_info2: failed to marshall LSA_R_QUERY_INFO2.\n")); + return False; + } + + return True; +} + + /*************************************************************************** \PIPE\ntlsa commands ***************************************************************************/ @@ -634,6 +666,7 @@ static struct api_struct api_lsa_cmds[] = { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs }, { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs }, { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, + { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 }, { NULL , 0 , NULL } }; diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index d072061a5f..f28441886a 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -5,7 +5,8 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Rafal Szczesniak 2002. + * Copyright (C) Rafal Szczesniak 2002, + * Copyright (C) Jim McDonough 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -341,6 +342,48 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s return NT_STATUS_OK; } +/*************************************************************************** + init_dns_dom_info. + ***************************************************************************/ +static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, char *nb_name, + char *dns_name, char *forest_name, + GUID *dom_guid, DOM_SID *dom_sid) +{ + if (nb_name && *nb_name) { + init_uni_hdr(&r_l->hdr_nb_dom_name, strlen(nb_name)); + init_unistr2(&r_l->uni_nb_dom_name, nb_name, + strlen(nb_name)); + r_l->hdr_nb_dom_name.uni_max_len += 2; + r_l->uni_nb_dom_name.uni_max_len += 1; + } + + if (dns_name && *dns_name) { + init_uni_hdr(&r_l->hdr_dns_dom_name, strlen(dns_name)); + init_unistr2(&r_l->uni_dns_dom_name, dns_name, + strlen(dns_name)); + r_l->hdr_dns_dom_name.uni_max_len += 2; + r_l->uni_dns_dom_name.uni_max_len += 1; + } + + if (forest_name && *forest_name) { + init_uni_hdr(&r_l->hdr_forest_name, strlen(forest_name)); + init_unistr2(&r_l->uni_forest_name, forest_name, + strlen(forest_name)); + r_l->hdr_forest_name.uni_max_len += 2; + r_l->uni_forest_name.uni_max_len += 1; + } + + /* how do we init the guid ? probably should write an init fn */ + if (dom_guid) { + memcpy(&r_l->dom_guid, dom_guid, sizeof(GUID)); + } + + if (dom_sid) { + r_l->ptr_dom_sid = 1; + init_dom_sid2(&r_l->dom_sid, dom_sid); + } +} + /*************************************************************************** _lsa_open_policy2. ***************************************************************************/ @@ -1166,3 +1209,55 @@ NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUER } +NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_INFO2 *r_u) +{ + struct lsa_info *handle; + char *nb_name = NULL; + char *dns_name = NULL; + char *forest_name = NULL; + DOM_SID *sid = NULL; + GUID guid; + + ZERO_STRUCT(guid); + r_u->status = NT_STATUS_OK; + + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) + return NT_STATUS_INVALID_HANDLE; + + switch (q_u->info_class) { + case 0x0c: + /* check if the user have enough rights */ + if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + + /* Request PolicyPrimaryDomainInformation. */ + switch (lp_server_role()) { + case ROLE_DOMAIN_PDC: + case ROLE_DOMAIN_BDC: + nb_name = global_myworkgroup; + /* ugly temp hack for these next two */ + dns_name = lp_realm(); + forest_name = lp_realm(); + sid = get_global_sam_sid(); + secrets_fetch_domain_guid(global_myworkgroup, + &guid); + break; + default: + return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; + } + init_dns_dom_info(&r_u->info.dns_dom_info, nb_name, dns_name, + forest_name,&guid,sid); + break; + default: + DEBUG(0,("_lsa_query_info2: unknown info level in Lsa Query: %d\n", q_u->info_class)); + r_u->status = NT_STATUS_INVALID_INFO_CLASS; + break; + } + + if (NT_STATUS_IS_OK(r_u->status)) { + r_u->ptr = 0x1; + r_u->info_class = q_u->info_class; + } + + return r_u->status; +} -- cgit From 5e42dcfe467d48fa7e8d87b88ae2bb2f54e5d28d Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Tue, 6 Aug 2002 18:02:56 +0000 Subject: Add SAMR 0x3e, which is samr_connect4. Seems to be the same as our existing connect (which I've been told is really connect2), with one extra dword. We've only seen 0x00000002 there... (This used to be commit 266344634944dff30f56453f9d86c490e7ac7a55) --- source3/rpc_server/srv_samr.c | 40 +++++++++++++++++++++++++-- source3/rpc_server/srv_samr_nt.c | 60 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 93 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index f002a7d1c9..bc3b8970d6 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -3,9 +3,11 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Marc Jacobsen 1999. - * Copyright (C) Jean François Micouleau 1998-2001. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Marc Jacobsen 1999, + * Copyright (C) Jean François Micouleau 1998-2001, + * Copyright (C) Anthony Liguori 2002, + * Copyright (C) Jim McDonough 2002. * * Split into interface and implementation modules by, * @@ -652,6 +654,37 @@ static BOOL api_samr_connect(pipes_struct *p) return True; } +/******************************************************************* + api_samr_connect4 + ********************************************************************/ + +static BOOL api_samr_connect4(pipes_struct *p) +{ + SAMR_Q_CONNECT4 q_u; + SAMR_R_CONNECT4 r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the samr open policy */ + if(!samr_io_q_connect4("", &q_u, data, 0)) { + DEBUG(0,("api_samr_connect4: unable to unmarshall SAMR_Q_CONNECT4.\n")); + return False; + } + + r_u.status = _samr_connect4(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!samr_io_r_connect4("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_connect4: unable to marshall SAMR_R_CONNECT4.\n")); + return False; + } + + return True; +} + /********************************************************************** api_samr_lookup_domain **********************************************************************/ @@ -1465,6 +1498,7 @@ static struct api_struct api_samr_cmds [] = {"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, {"SAMR_UNKNOWN_2E" , SAMR_UNKNOWN_2E , api_samr_unknown_2e }, {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, + {"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 }, {NULL , 0 , NULL } }; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2a7a5518cd..f427eb7046 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3,10 +3,12 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Marc Jacobsen 1999. - * Copyright (C) Jeremy Allison 2001-2002. - * Copyright (C) Jean François Micouleau 1998-2001. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Marc Jacobsen 1999, + * Copyright (C) Jeremy Allison 2001-2002, + * Copyright (C) Jean François Micouleau 1998-2001, + * Copyright (C) Anthony Liguori 2002, + * Copyright (C) Jim McDonough 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2449,6 +2451,56 @@ NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u return r_u->status; } +/******************************************************************* + samr_connect4 + ********************************************************************/ + +NTSTATUS _samr_connect4(pipes_struct *p, SAMR_Q_CONNECT4 *q_u, SAMR_R_CONNECT4 *r_u) +{ + struct samr_info *info = NULL; + SEC_DESC *psd = NULL; + uint32 acc_granted; + uint32 des_access = q_u->access_mask; + size_t sd_size; + NTSTATUS nt_status; + + + DEBUG(5,("_samr_connect4: %d\n", __LINE__)); + + /* Access check */ + + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to samr_connect4\n")); + r_u->status = NT_STATUS_ACCESS_DENIED; + return r_u->status; + } + + samr_make_sam_obj_sd(p->mem_ctx, &psd, &sd_size); + se_map_generic(&des_access, &sam_generic_mapping); + if (!NT_STATUS_IS_OK(nt_status = + access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_connect"))) { + return nt_status; + } + + r_u->status = NT_STATUS_OK; + + /* associate the user's SID and access granted with the new handle. */ + if ((info = get_samr_info_by_sid(NULL)) == NULL) + return NT_STATUS_NO_MEMORY; + + info->acc_granted = acc_granted; + info->status = q_u->access_mask; + + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + DEBUG(5,("_samr_connect: %d\n", __LINE__)); + + return r_u->status; +} + /********************************************************************** api_samr_lookup_domain **********************************************************************/ -- cgit From 335aa54b466896d6623ec2e61c1ca38442cddb6f Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 8 Aug 2002 04:58:19 +0000 Subject: Merge of incomplete rffpcnex testing code from APPLIANCE_HEAD. (This used to be commit fe43c2ac2d2e1dd3b3a25c807d4dd379c5ac4960) --- source3/rpc_server/srv_spoolss.c | 63 +++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_spoolss_nt.c | 21 +++++++++++++ 2 files changed, 84 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 6e3463e79b..5924c5831b 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1515,6 +1515,65 @@ static BOOL api_spoolss_deleteprinterdriverex(pipes_struct *p) return True; } +#if 0 + +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_replyopenprinter(pipes_struct *p) +{ + SPOOL_Q_REPLYOPENPRINTER q_u; + SPOOL_R_REPLYOPENPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_replyopenprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_replyopenprinter: unable to unmarshall SPOOL_Q_REPLYOPENPRINTER.\n")); + return False; + } + + r_u.status = _spoolss_replyopenprinter(p, &q_u, &r_u); + + if(!spoolss_io_r_replyopenprinter("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_replyopenprinter: unable to marshall SPOOL_R_REPLYOPENPRINTER.\n")); + return False; + } + + return True; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_replycloseprinter(pipes_struct *p) +{ + SPOOL_Q_REPLYCLOSEPRINTER q_u; + SPOOL_R_REPLYCLOSEPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_replycloseprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_replycloseprinter: unable to unmarshall SPOOL_Q_REPLYCLOSEPRINTER.\n")); + return False; + } + + r_u.status = _spoolss_replycloseprinter(p, &q_u, &r_u); + + if(!spoolss_io_r_replycloseprinter("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_replycloseprinter: unable to marshall SPOOL_R_REPLYCLOSEPRINTER.\n")); + return False; + } + + return True; +} + +#endif /******************************************************************* \pipe\spoolss commands @@ -1573,6 +1632,10 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory}, {"SPOOLSS_ADDPRINTERDRIVEREX", SPOOLSS_ADDPRINTERDRIVEREX, api_spoolss_addprinterdriverex }, {"SPOOLSS_DELETEPRINTERDRIVEREX", SPOOLSS_DELETEPRINTERDRIVEREX, api_spoolss_deleteprinterdriverex }, +#if 0 + {"SPOOLSS_REPLYOPENPRINTER", SPOOLSS_REPLYOPENPRINTER, api_spoolss_replyopenprinter }, + {"SPOOLSS_REPLYCLOSEPRINTER", SPOOLSS_REPLYCLOSEPRINTER, api_spoolss_replycloseprinter }, +#endif { NULL, 0, NULL } }; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 20a586a6fb..558a7a47d7 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8372,3 +8372,24 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC return result; } + +#if 0 + +WERROR _spoolss_replyopenprinter(pipes_struct *p, SPOOL_Q_REPLYOPENPRINTER *q_u, + SPOOL_R_REPLYOPENPRINTER *r_u) +{ + DEBUG(5,("_spoolss_replyopenprinter\n")); + + DEBUG(10, ("replyopenprinter for localprinter %d\n", q_u->printer)); + + return WERR_OK; +} + +WERROR _spoolss_replycloseprinter(pipes_struct *p, SPOOL_Q_REPLYCLOSEPRINTER *q_u, + SPOOL_R_REPLYCLOSEPRINTER *r_u) +{ + DEBUG(5,("_spoolss_replycloseprinter\n")); + return WERR_OK; +} + +#endif -- cgit From 14d385439d99f0eadca5296aeef800c67038916b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 8 Aug 2002 20:54:37 +0000 Subject: printing change notification merge from APPLIANCE_HEAD (This used to be commit 11ddfd9cfa550dcd3186c8aaf0cc038ce7f1791f) --- source3/rpc_server/srv_spoolss_nt.c | 280 ++++++++++++++++++++++-------------- 1 file changed, 171 insertions(+), 109 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 558a7a47d7..d04aff8b15 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -668,21 +668,21 @@ struct notify2_message_table { }; static struct notify2_message_table printer_notify_table[] = { - /* 0x00 */ { "PRINTER_NOTIFY_SERVER_NAME", NULL }, - /* 0x01 */ { "PRINTER_NOTIFY_PRINTER_NAME", NULL }, - /* 0x02 */ { "PRINTER_NOTIFY_SHARE_NAME", NULL }, - /* 0x03 */ { "PRINTER_NOTIFY_PORT_NAME", NULL }, - /* 0x04 */ { "PRINTER_NOTIFY_DRIVER_NAME", NULL }, - /* 0x05 */ { "PRINTER_NOTIFY_COMMENT", NULL }, - /* 0x06 */ { "PRINTER_NOTIFY_LOCATION", NULL }, + /* 0x00 */ { "PRINTER_NOTIFY_SERVER_NAME", notify_string }, + /* 0x01 */ { "PRINTER_NOTIFY_PRINTER_NAME", notify_string }, + /* 0x02 */ { "PRINTER_NOTIFY_SHARE_NAME", notify_string }, + /* 0x03 */ { "PRINTER_NOTIFY_PORT_NAME", notify_string }, + /* 0x04 */ { "PRINTER_NOTIFY_DRIVER_NAME", notify_string }, + /* 0x05 */ { "PRINTER_NOTIFY_COMMENT", notify_string }, + /* 0x06 */ { "PRINTER_NOTIFY_LOCATION", notify_string }, /* 0x07 */ { "PRINTER_NOTIFY_DEVMODE", NULL }, - /* 0x08 */ { "PRINTER_NOTIFY_SEPFILE", NULL }, - /* 0x09 */ { "PRINTER_NOTIFY_PRINT_PROCESSOR", NULL }, + /* 0x08 */ { "PRINTER_NOTIFY_SEPFILE", notify_string }, + /* 0x09 */ { "PRINTER_NOTIFY_PRINT_PROCESSOR", notify_string }, /* 0x0a */ { "PRINTER_NOTIFY_PARAMETERS", NULL }, - /* 0x0b */ { "PRINTER_NOTIFY_DATATYPE", NULL }, + /* 0x0b */ { "PRINTER_NOTIFY_DATATYPE", notify_string }, /* 0x0c */ { "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", NULL }, - /* 0x0d */ { "PRINTER_NOTIFY_ATTRIBUTES", NULL }, - /* 0x0e */ { "PRINTER_NOTIFY_PRIORITY", NULL }, + /* 0x0d */ { "PRINTER_NOTIFY_ATTRIBUTES", notify_one_value }, + /* 0x0e */ { "PRINTER_NOTIFY_PRIORITY", notify_one_value }, /* 0x0f */ { "PRINTER_NOTIFY_DEFAULT_PRIORITY", NULL }, /* 0x10 */ { "PRINTER_NOTIFY_START_TIME", NULL }, /* 0x11 */ { "PRINTER_NOTIFY_UNTIL_TIME", NULL }, @@ -726,6 +726,8 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, { Printer_entry *p; + DEBUG(8,("process_notify2_message: Enter...[%s]\n", msg->printer)); + for (p = printers_list; p; p = p->next) { SPOOL_NOTIFY_INFO_DATA *data; uint32 data_len = 1; @@ -736,28 +738,52 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, if (!p->notify.client_connected) continue; + DEBUG(10,("Client connected! [%s]\n", p->dev.handlename)); + /* For this printer? Print servers always receive notifications. */ - if (p->printer_type == PRINTER_HANDLE_IS_PRINTER && - !strequal(msg->printer, p->dev.handlename)) + if ( ( p->printer_type == PRINTER_HANDLE_IS_PRINTER ) && + ( !strequal(msg->printer, p->dev.handlename) ) ) continue; + DEBUG(10,("Our printer\n")); + /* Are we monitoring this event? */ if (!is_monitoring_event(p, msg->type, msg->field)) continue; + DEBUG(10,("process_notify2_message: Sending message type [%x] field [%x] for printer [%s]\n", + msg->type, msg->field, p->dev.handlename)); + /* OK - send the event to the client */ data = talloc(mem_ctx, sizeof(SPOOL_NOTIFY_INFO_DATA)); ZERO_STRUCTP(data); - /* Convert unix jobid to smb jobid */ + /* + * if the is a printer notification handle and not a job notification + * type, then set the id to 0. Other wise just use what was specified + * in the message. + * + * When registering change notification on a print server handle + * we always need to send back the id (snum) matching the printer + * for which the change took place. For change notify registered + * on a printer handle, this does not matter and the id should be 0. + * + * --jerry + */ + if ( ( p->printer_type == PRINTER_HANDLE_IS_PRINTER ) && ( msg->type == PRINTER_NOTIFY_TYPE ) ) + id = 0; + else id = msg->id; + + /* Convert unix jobid to smb jobid */ + if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) { id = sysjob_to_jobid(msg->id); @@ -772,51 +798,31 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, switch(msg->type) { case PRINTER_NOTIFY_TYPE: - if (printer_notify_table[msg->field].fn) - printer_notify_table[msg->field].fn( - msg, data, mem_ctx); - else + if ( !printer_notify_table[msg->field].fn ) goto done; + + printer_notify_table[msg->field].fn(msg, data, mem_ctx); + break; + case JOB_NOTIFY_TYPE: - if (job_notify_table[msg->field].fn) - job_notify_table[msg->field].fn( - msg, data, mem_ctx); - else + if ( !job_notify_table[msg->field].fn ) goto done; - break; - default: - DEBUG(5, ("Unknown notification type %d\n", - msg->type)); - goto done; - } - if (!p->notify.flags) - cli_spoolss_rrpcn( - ¬ify_cli, mem_ctx, &p->notify.client_hnd, - data_len, data, p->notify.change, 0); - else { - NT_PRINTER_INFO_LEVEL *printer = NULL; + job_notify_table[msg->field].fn(msg, data, mem_ctx); - get_a_printer(&printer, 2, msg->printer); + break; - if (!printer) { - DEBUG(5, ("unable to load info2 for %s\n", - msg->printer)); + default: + DEBUG(5, ("Unknown notification type %d\n", msg->type)); goto done; } - /* XXX: This needs to be updated for - PRINTER_CHANGE_SET_PRINTER_DRIVER. */ - - cli_spoolss_routerreplyprinter( - ¬ify_cli, mem_ctx, &p->notify.client_hnd, - 0, printer->info_2->changeid); - - free_a_printer(&printer, 2); - } + cli_spoolss_rrpcn( ¬ify_cli, mem_ctx, &p->notify.client_hnd, + data_len, data, p->notify.change, 0 ); } done: + DEBUG(8,("process_notify2_message: Exit...\n")); return; } @@ -867,30 +873,6 @@ static void receive_notify2_message(int msg_type, pid_t src, void *buf, talloc_destroy(mem_ctx); } -/*************************************************************************** - Server wrapper for cli_spoolss_routerreplyprinter() since the client - function can only send a single change notification at a time. - - FIXME!!! only handles one change currently (PRINTER_CHANGE_SET_PRINTER_DRIVER) - --jerry - **************************************************************************/ - -static WERROR srv_spoolss_routerreplyprinter (struct cli_state *reply_cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, PRINTER_MESSAGE_INFO *info, - NT_PRINTER_INFO_LEVEL *printer) -{ - WERROR result; - uint32 condition = 0x0; - - if (info->flags & PRINTER_MESSAGE_DRIVER) - condition = PRINTER_CHANGE_SET_PRINTER_DRIVER; - - result = cli_spoolss_routerreplyprinter(reply_cli, mem_ctx, pol, condition, - printer->info_2->changeid); - - return result; -} - /******************************************************************** Send a message to ourself about new driver being installed so we can upgrade the information for each printer bound to this @@ -961,6 +943,80 @@ void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) /* all done */ } +/******************************************************************** + Send a message to ourself about new driver being installed + so we can upgrade the information for each printer bound to this + driver + ********************************************************************/ + +static BOOL srv_spoolss_reset_printerdata(char* drivername) +{ + int len = strlen(drivername); + + if (!len) + return False; + + DEBUG(10,("srv_spoolss_reset_printerdata: Sending message about resetting printerdata [%s]\n", + drivername)); + + message_send_pid(sys_getpid(), MSG_PRINTERDATA_INIT_RESET, drivername, len+1, False); + + return True; +} + +/********************************************************************** + callback to receive a MSG_PRINTERDATA_INIT_RESET message and interate + over all printers, resetting printer data as neessary + **********************************************************************/ + +void reset_all_printerdata(int msg_type, pid_t src, void *buf, size_t len) +{ + fstring drivername; + int snum; + int n_services = lp_numservices(); + + len = MIN( len, sizeof(drivername)-1 ); + strncpy( drivername, buf, len ); + + DEBUG(10,("reset_all_printerdata: Got message for new driver [%s]\n", drivername )); + + /* Iterate the printer list */ + + for ( snum=0; snuminfo_2 && !strcmp(drivername, printer->info_2->drivername) ) + { + DEBUG(6,("reset_all_printerdata: Updating printer [%s]\n", printer->info_2->printername)); + + if ( !set_driver_init(printer, 2) ) { + DEBUG(5,("reset_all_printerdata: Error resetting printer data for printer [%s], driver [%s]!\n", + printer->info_2->printername, printer->info_2->drivername)); + } + } + + free_a_printer( &printer, 2 ); + } + } + + /* all done */ + + return; +} + /******************************************************************** Copy routines used by convert_to_openprinterex() *******************************************************************/ @@ -1094,8 +1150,6 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, { UNISTR2 *printername = NULL; PRINTER_DEFAULT *printer_default = &q_u->printer_default; -/* uint32 user_switch = q_u->user_switch; - notused */ -/* SPOOL_USER_CTR user_ctr = q_u->user_ctr; - notused */ POLICY_HND *handle = &r_u->handle; fstring name; @@ -2753,7 +2807,7 @@ struct s_notify_info_data_table notify_info_data_table[] = { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINT_PROCESSOR, "PRINTER_NOTIFY_PRINT_PROCESSOR", NOTIFY_STRING, spoolss_notify_print_processor }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PARAMETERS, "PRINTER_NOTIFY_PARAMETERS", NOTIFY_STRING, spoolss_notify_parameters }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DATATYPE, "PRINTER_NOTIFY_DATATYPE", NOTIFY_STRING, spoolss_notify_datatype }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SECURITY_DESCRIPTOR, "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", NOTIFY_POINTER, spoolss_notify_security_desc }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SECURITY_DESCRIPTOR, "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", NOTIFY_SECDESC, spoolss_notify_security_desc }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_ATTRIBUTES, "PRINTER_NOTIFY_ATTRIBUTES", NOTIFY_ONE_VALUE, spoolss_notify_attributes }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRIORITY, "PRINTER_NOTIFY_PRIORITY", NOTIFY_ONE_VALUE, spoolss_notify_priority }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEFAULT_PRIORITY, "PRINTER_NOTIFY_DEFAULT_PRIORITY", NOTIFY_ONE_VALUE, spoolss_notify_default_priority }, @@ -2800,10 +2854,13 @@ static uint32 size_of_notify_info_data(uint16 type, uint16 field) { int i=0; - for (i = 0; i < sizeof(notify_info_data_table); i++) { - if (notify_info_data_table[i].type == type && - notify_info_data_table[i].field == field) { - switch(notify_info_data_table[i].size) { + for (i = 0; i < sizeof(notify_info_data_table); i++) + { + if ( (notify_info_data_table[i].type == type) + && (notify_info_data_table[i].field == field) ) + { + switch(notify_info_data_table[i].size) + { case NOTIFY_ONE_VALUE: case NOTIFY_TWO_VALUE: return 1; @@ -2816,6 +2873,9 @@ static uint32 size_of_notify_info_data(uint16 type, uint16 field) case NOTIFY_POINTER: return 4; + + case NOTIFY_SECDESC: + return 5; } } } @@ -2870,13 +2930,11 @@ void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 info_data->field = field; info_data->reserved = 0; - if (type == JOB_NOTIFY_TYPE) - info_data->id = id; - else - info_data->id = 0; - info_data->size = size_of_notify_info_data(type, field); info_data->enc_type = type_of_notify_info_data(type, field); + + info_data->id = id; + } @@ -2908,20 +2966,24 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) return False; - for(field_num=0; field_numcount; field_num++) { + for(field_num=0; field_numcount; field_num++) + { field = option_type->fields[field_num]; + DEBUG(4,("construct_notify_printer_info: notify [%d]: type [%x], field [%x]\n", field_num, type, field)); if (!search_notify(type, field, &j) ) continue; - if((tid=(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(2,("construct_notify_printer_info: failed to enlarge buffer info->data!\n")); return False; } - else info->data = tid; + else + info->data = tid; - current_data=&info->data[info->count]; + current_data = &info->data[info->count]; construct_info_data(current_data, type, field, id); @@ -3048,16 +3110,17 @@ static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, continue; for (snum=0; snumversion:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); DEBUGADD(1,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); @@ -3067,7 +3130,7 @@ static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, i, info->data[i].type, info->data[i].field, info->data[i].reserved, info->data[i].id, info->data[i].size, info->data[i].enc_type)); } - */ +#endif return WERR_OK; } @@ -3165,7 +3228,6 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCNEX *r_u) { POLICY_HND *handle = &q_u->handle; -/* SPOOL_NOTIFY_OPTION *option = q_u->option; - notused. */ SPOOL_NOTIFY_INFO *info = &r_u->info; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); @@ -3192,8 +3254,10 @@ WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN /* We need to keep track of the change value to send back in RRPCN replies otherwise our updates are ignored. */ - if (Printer->notify.client_connected) + if (Printer->notify.client_connected) { + DEBUG(10,("_spoolss_rfnpcnex: Saving change value in request [%x]\n", q_u->change)); Printer->notify.change = q_u->change; + } /* just ignore the SPOOL_NOTIFY_OPTION */ @@ -4732,7 +4796,6 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ UNISTR2 *uni_arch = &q_u->architecture; uint32 level = q_u->level; uint32 clientmajorversion = q_u->clientmajorversion; -/* uint32 clientminorversion = q_u->clientminorversion; - notused. */ NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; @@ -4824,9 +4887,9 @@ WERROR _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPO WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, SPOOL_R_STARTDOCPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; -/* uint32 level = q_u->doc_info_container.level; - notused. */ DOC_INFO *docinfo = &q_u->doc_info_container.docinfo; uint32 *jobid = &r_u->jobid; + DOC_INFO_1 *info_1 = &docinfo->doc_info_1; int snum; pstring jobname; @@ -5526,6 +5589,12 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, result = WERR_ACCESS_DENIED; goto done; } + + /* we need to reset all driver init data for all printers + bound to this driver */ + + srv_spoolss_reset_printerdata( printer->info_2->drivername ); + } else { /* * When a *new* driver is bound to a printer, the drivername is used to @@ -5537,6 +5606,9 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, DEBUG(5,("update_printer: Error restoring driver initialization data for driver [%s]!\n", printer->info_2->drivername)); } + + DEBUG(10,("update_printer: changing driver [%s]! Sending event!\n", + printer->info_2->drivername)); notify_printer_driver(snum, printer->info_2->drivername); } } @@ -5847,8 +5919,6 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJOBS *r_u) { POLICY_HND *handle = &q_u->handle; -/* uint32 firstjob = q_u->firstjob; - notused. */ -/* uint32 numofjobs = q_u->numofjobs; - notused. */ uint32 level = q_u->level; NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; @@ -6195,7 +6265,6 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, SPOOL_R_ENUMPRINTERDRIVERS *r_u) { -/* UNISTR2 *name = &q_u->name; - notused. */ UNISTR2 *environment = &q_u->environment; uint32 level = q_u->level; NEW_BUFFER *buffer = NULL; @@ -6252,7 +6321,6 @@ static void fill_form_1(FORM_1 *form, nt_forms_struct *list) WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u) { -/* POLICY_HND *handle = &q_u->handle; - notused. */ uint32 level = q_u->level; NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; @@ -6353,7 +6421,6 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM *r_u) { -/* POLICY_HND *handle = &q_u->handle; - notused. */ uint32 level = q_u->level; UNISTR2 *uni_formname = &q_u->formname; NEW_BUFFER *buffer = NULL; @@ -6649,7 +6716,6 @@ static WERROR enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u) { -/* UNISTR2 *name = &q_u->name; - notused. */ uint32 level = q_u->level; NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; @@ -6890,9 +6956,7 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, version = driver.info_6->version; else version = -1; - - switch (version) - { + switch (version) { /* * 9x printer driver - never delete init data */ @@ -6962,15 +7026,13 @@ WERROR _spoolss_addprinterdriverex(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVEREX * if ( q_u->copy_flags != APD_COPY_NEW_FILES ) return WERR_ACCESS_DENIED; - /* just pass the information off to _spoolss_addprinterdriver() */ - ZERO_STRUCT(q_u_local); ZERO_STRUCT(r_u_local); + /* just pass the information off to _spoolss_addprinterdriver() */ q_u_local.server_name_ptr = q_u->server_name_ptr; copy_unistr2(&q_u_local.server_name, &q_u->server_name); q_u_local.level = q_u->level; - memcpy( &q_u_local.info, &q_u->info, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL) ); return _spoolss_addprinterdriver( p, &q_u_local, &r_u_local ); -- cgit From 9b38f76ab10a015ade9da2c5c9bafd43e3ef258c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 15 Aug 2002 19:40:34 +0000 Subject: Rename unknown_0 field in create_user2 reply in the actual struct. (This used to be commit 482d873c26bf02e27ffcd92042b476eda765a5ff) --- source3/rpc_server/srv_samr_nt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f427eb7046..1a09917ac7 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2361,7 +2361,10 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ } r_u->user_rid=pdb_get_user_rid(sam_pass); - r_u->unknown_0 = 0x000703ff; + + /* This should probably be some subset of q_u->access_mask */ + + r_u->access_granted = 0x000703ff; pdb_free_sam(&sam_pass); -- cgit From b84315e2d583ad4bf06b5e43c3c1046a751326b6 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 16 Aug 2002 08:47:10 +0000 Subject: Return the error if get_group_domain_entries() fails. (This used to be commit bc9e9e3e2e0d861f34de26a9ef8b627a86c9954d) --- source3/rpc_server/srv_samr_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1a09917ac7..ee40453482 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1081,7 +1081,9 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); /* the domain group array is being allocated in the function below */ - get_group_domain_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); + if (!NT_STATUS_IS_OK(r_u->status = get_group_domain_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES))) { + return r_u->status; + } make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp); -- cgit From 4ed429481c6aa2517b8b1615f95900d7db372cd6 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 16 Aug 2002 15:36:37 +0000 Subject: Fairly large change to printing code. * removed support for PHANTOM_DEVMODE printer data * s/NT_PRINTER_PARAM/REGISTRY_VALUE/g - This was a good bit of work. Everything seems stable, but is not complete. * support for printer data keys other than PrinterDriverData in the store and fetch routines. Still needs to be plugged into the XxxPrinterDataEx() calls. Tested against NT4.0 & 2k. Like I said, it's not done, but doesn't crash so it shouldn't upset anyone (unless you're trying to build a Samba printer server off of HEAD). More work to come. Should settle by Monday. jerry (This used to be commit 7ba7c04c0e961618c82c2112b9627af114c6cc42) --- source3/rpc_server/srv_spoolss_nt.c | 710 +++++++++++++----------------------- 1 file changed, 244 insertions(+), 466 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d04aff8b15..2aa11530f8 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1798,51 +1798,56 @@ static BOOL getprinterdata_printer(pipes_struct *p, TALLOC_CTX *ctx, POLICY_HND uint8 **data, uint32 *needed, uint32 in_size ) { NT_PRINTER_INFO_LEVEL *printer = NULL; - int snum=0; - uint8 *idata=NULL; - uint32 len; - Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + int snum=0; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + REGISTRY_VALUE *val; + int size = 0; DEBUG(5,("getprinterdata_printer\n")); - if (!Printer) { + if ( !Printer ) { DEBUG(2,("getprinterdata_printer: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return False; } - if(!get_printer_snum(p, handle, &snum)) + if ( !get_printer_snum(p, handle, &snum) ) return False; - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) + if ( !W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum))) ) return False; - if (!get_specific_param(*printer, 2, value, &idata, type, &len)) { + if ( !(val = get_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, value)) ) + { free_a_printer(&printer, 2); return False; } + + *type = regval_type( val ); - free_a_printer(&printer, 2); DEBUG(5,("getprinterdata_printer:allocating %d\n", in_size)); - if (in_size) { - if((*data = (uint8 *)talloc(ctx, in_size *sizeof(uint8) )) == NULL) { + if (in_size) + { + if ( (*data = (uint8 *)talloc(ctx, in_size * sizeof(uint8))) == NULL ) return False; - } - memset(*data, 0, in_size *sizeof(uint8)); + memset( *data, 0, in_size *sizeof(uint8) ); + /* copy the min(in_size, len) */ - memcpy(*data, idata, (len>in_size)?in_size:len *sizeof(uint8)); - } else { - *data = NULL; + + size = regval_size( val ); + memcpy( *data, regval_data_p(val), (size > in_size) ? in_size : size*sizeof(uint8) ); } + else + *data = NULL; - *needed = len; + *needed = size; DEBUG(5,("getprinterdata_printer:copy done\n")); - SAFE_FREE(idata); + free_a_printer(&printer, 2); return True; } @@ -1871,11 +1876,12 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO * JFM, 4/19/1999 */ - *out_size=in_size; + *out_size = in_size; /* in case of problem, return some default values */ - *needed=0; - *type=0; + + *needed = 0; + *type = 0; DEBUG(4,("_spoolss_getprinterdata\n")); @@ -1889,13 +1895,16 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO unistr2_to_ascii(value, valuename, sizeof(value)-1); if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) - found=getprinterdata_printer_server(p->mem_ctx, value, type, data, needed, *out_size); + found = getprinterdata_printer_server(p->mem_ctx, value, type, data, needed, *out_size); else - found= getprinterdata_printer(p, p->mem_ctx, handle, value, type, data, needed, *out_size); + found = getprinterdata_printer(p, p->mem_ctx, handle, value, type, data, needed, *out_size); - if (found==False) { + if ( !found ) + { DEBUG(5, ("value not found, allocating %d\n", *out_size)); + /* reply this param doesn't exist */ + if (*out_size) { if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) return WERR_NOMEM; @@ -5219,254 +5228,6 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) return True; } -#if 0 /* JERRY */ - -/* Return true if two devicemodes are equal */ - -#define DEVMODE_CHECK_INT(field) \ - if (d1->field != d2->field) { \ - DEBUG(10, ("nt_devicemode_equal(): " #field " not equal (%d != %d)\n", \ - d1->field, d2->field)); \ - return False; \ - } - -/************************************************************************ - Handy, but currently unused functions - ***********************************************************************/ - -static BOOL nt_devicemode_equal(NT_DEVICEMODE *d1, NT_DEVICEMODE *d2) -{ - if (!d1 && !d2) goto equal; /* if both are NULL they are equal */ - - if (!d1 ^ !d2) { - DEBUG(10, ("nt_devicemode_equal(): pointers not equal\n")); - return False; /* if either is exclusively NULL are not equal */ - } - - if (!strequal(d1->devicename, d2->devicename)) { - DEBUG(10, ("nt_devicemode_equal(): device not equal (%s != %s)\n", d1->devicename, d2->devicename)); - return False; - } - - if (!strequal(d1->formname, d2->formname)) { - DEBUG(10, ("nt_devicemode_equal(): formname not equal (%s != %s)\n", d1->formname, d2->formname)); - return False; - } - - DEVMODE_CHECK_INT(specversion); - DEVMODE_CHECK_INT(driverversion); - DEVMODE_CHECK_INT(driverextra); - DEVMODE_CHECK_INT(orientation); - DEVMODE_CHECK_INT(papersize); - DEVMODE_CHECK_INT(paperlength); - DEVMODE_CHECK_INT(paperwidth); - DEVMODE_CHECK_INT(scale); - DEVMODE_CHECK_INT(copies); - DEVMODE_CHECK_INT(defaultsource); - DEVMODE_CHECK_INT(printquality); - DEVMODE_CHECK_INT(color); - DEVMODE_CHECK_INT(duplex); - DEVMODE_CHECK_INT(yresolution); - DEVMODE_CHECK_INT(ttoption); - DEVMODE_CHECK_INT(collate); - DEVMODE_CHECK_INT(logpixels); - - DEVMODE_CHECK_INT(fields); - DEVMODE_CHECK_INT(bitsperpel); - DEVMODE_CHECK_INT(pelswidth); - DEVMODE_CHECK_INT(pelsheight); - DEVMODE_CHECK_INT(displayflags); - DEVMODE_CHECK_INT(displayfrequency); - DEVMODE_CHECK_INT(icmmethod); - DEVMODE_CHECK_INT(icmintent); - DEVMODE_CHECK_INT(mediatype); - DEVMODE_CHECK_INT(dithertype); - DEVMODE_CHECK_INT(reserved1); - DEVMODE_CHECK_INT(reserved2); - DEVMODE_CHECK_INT(panningwidth); - DEVMODE_CHECK_INT(panningheight); - - /* compare the private data if it exists */ - if (!d1->driverextra && !d2->driverextra) goto equal; - - - DEVMODE_CHECK_INT(driverextra); - - if (memcmp(d1->private, d2->private, d1->driverextra)) { - DEBUG(10, ("nt_devicemode_equal(): private data not equal\n")); - return False; - } - - equal: - DEBUG(10, ("nt_devicemode_equal(): devicemodes identical\n")); - return True; -} - -/* Return true if two NT_PRINTER_PARAM structures are equal */ - -static BOOL nt_printer_param_equal(NT_PRINTER_PARAM *p1, - NT_PRINTER_PARAM *p2) -{ - if (!p1 && !p2) goto equal; - - if ((!p1 && p2) || (p1 && !p2)) { - DEBUG(10, ("nt_printer_param_equal(): pointers differ\n")); - return False; - } - - /* Compare lists of printer parameters */ - - while (p1) { - BOOL found = False; - NT_PRINTER_PARAM *q = p1; - - /* Find the parameter in the second structure */ - - while(q) { - - if (strequal(p1->value, q->value)) { - - if (p1->type != q->type) { - DEBUG(10, ("nt_printer_param_equal():" - "types for %s differ (%d != %d)\n", - p1->value, p1->type, - q->type)); - break; - } - - if (p1->data_len != q->data_len) { - DEBUG(10, ("nt_printer_param_equal():" - "len for %s differs (%d != %d)\n", - p1->value, p1->data_len, - q->data_len)); - break; - } - - if (memcmp(p1->data, q->data, p1->data_len) == 0) { - found = True; - } else { - DEBUG(10, ("nt_printer_param_equal():" - "data for %s differs\n", p1->value)); - } - - break; - } - - q = q->next; - } - - if (!found) { - DEBUG(10, ("nt_printer_param_equal(): param %s " - "does not exist\n", p1->value)); - return False; - } - - p1 = p1->next; - } - - equal: - - DEBUG(10, ("nt_printer_param_equal(): printer params identical\n")); - return True; -} - -/******************************************************************** - * Called by update_printer when trying to work out whether to - * actually update printer info. - ********************************************************************/ - -#define PI_CHECK_INT(field) \ - if (pi1->field != pi2->field) { \ - DEBUG(10, ("nt_printer_info_level_equal(): " #field " not equal (%d != %d)\n", \ - pi1->field, pi2->field)); \ - return False; \ - } - -#define PI_CHECK_STR(field) \ - if (!strequal(pi1->field, pi2->field)) { \ - DEBUG(10, ("nt_printer_info_level_equal(): " #field " not equal (%s != %s)\n", \ - pi1->field, pi2->field)); \ - return False; \ - } - -static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, - NT_PRINTER_INFO_LEVEL *p2) -{ - NT_PRINTER_INFO_LEVEL_2 *pi1, *pi2; - - /* Trivial conditions */ - - if ((!p1 && !p2) || (!p1->info_2 && !p2->info_2)) { - goto equal; - } - - if ((!p1 && p2) || (p1 && !p2) || - (!p1->info_2 && p2->info_2) || - (p1->info_2 && !p2->info_2)) { - DEBUG(10, ("nt_printer_info_level_equal(): info levels " - "differ\n")); - return False; - } - - /* Compare two nt_printer_info_level structures. Don't compare - status or cjobs as they seem to have something to do with the - printer queue. */ - - pi1 = p1->info_2; - pi2 = p2->info_2; - - /* Don't check the attributes as we stomp on the value in - check_printer_ok() anyway. */ - -#if 0 - PI_CHECK_INT(attributes); -#endif - - PI_CHECK_INT(priority); - PI_CHECK_INT(default_priority); - PI_CHECK_INT(starttime); - PI_CHECK_INT(untiltime); - PI_CHECK_INT(averageppm); - - /* Yuck - don't check the printername or servername as the - mod_a_printer() code plays games with them. You can't - change the printername or the sharename through this interface - in Samba. */ - - PI_CHECK_STR(sharename); - PI_CHECK_STR(portname); - PI_CHECK_STR(drivername); - PI_CHECK_STR(comment); - PI_CHECK_STR(location); - - if (!nt_devicemode_equal(pi1->devmode, pi2->devmode)) { - return False; - } - - PI_CHECK_STR(sepfile); - PI_CHECK_STR(printprocessor); - PI_CHECK_STR(datatype); - PI_CHECK_STR(parameters); - - if (!nt_printer_param_equal(pi1->specific, pi2->specific)) { - return False; - } - - if (!sec_desc_equal(pi1->secdesc_buf->sec, pi2->secdesc_buf->sec)) { - return False; - } - - PI_CHECK_INT(changeid); - PI_CHECK_INT(c_setprinter); - PI_CHECK_INT(setuptime); - - equal: - DEBUG(10, ("nt_printer_info_level_equal(): infos are identical\n")); - return True; -} - -#endif - /******************************************************************** * Called by spoolss_api_setprinter * when updating a printer description. @@ -7121,38 +6882,38 @@ WERROR _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRI WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, SPOOL_R_ENUMPRINTERDATA *r_u) { POLICY_HND *handle = &q_u->handle; - uint32 idx = q_u->index; - uint32 in_value_len = q_u->valuesize; - uint32 in_data_len = q_u->datasize; - uint32 *out_max_value_len = &r_u->valuesize; - uint16 **out_value = &r_u->value; - uint32 *out_value_len = &r_u->realvaluesize; - uint32 *out_type = &r_u->type; + uint32 idx = q_u->index; + uint32 in_value_len = q_u->valuesize; + uint32 in_data_len = q_u->datasize; + uint32 *out_max_value_len= &r_u->valuesize; + uint16 **out_value = &r_u->value; + uint32 *out_value_len = &r_u->realvaluesize; + uint32 *out_type = &r_u->type; uint32 *out_max_data_len = &r_u->datasize; - uint8 **data_out = &r_u->data; - uint32 *out_data_len = &r_u->realdatasize; + uint8 **data_out = &r_u->data; + uint32 *out_data_len = &r_u->realdatasize; NT_PRINTER_INFO_LEVEL *printer = NULL; - fstring value; + uint32 param_index; + uint32 biggest_valuesize; + uint32 biggest_datasize; + uint32 data_len; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + int snum; + WERROR result; + REGISTRY_VALUE *val; + NT_PRINTER_DATA *p_data; + int i, key_index, num_values; + int name_length; - uint32 param_index; - uint32 biggest_valuesize; - uint32 biggest_datasize; - uint32 data_len; - Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - int snum; - uint8 *data=NULL; - uint32 type; - WERROR result; - - ZERO_STRUCT(printer); + ZERO_STRUCT( printer ); - *out_type=0; + *out_type = 0; - *out_max_data_len=0; - *data_out=NULL; - *out_data_len=0; + *out_max_data_len = 0; + *data_out = NULL; + *out_data_len = 0; DEBUG(5,("spoolss_enumprinterdata\n")); @@ -7167,103 +6928,133 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S result = get_a_printer(&printer, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(result)) return result; + + p_data = &printer->info_2->data; + key_index = lookup_printerkey( p_data, SPOOL_PRINTERDATA_KEY ); + + result = WERR_OK; /* * The NT machine wants to know the biggest size of value and data * * cf: MSDN EnumPrinterData remark section */ - if ( (in_value_len==0) && (in_data_len==0) ) { + + if ( !in_value_len && !in_data_len ) + { DEBUGADD(6,("Activating NT mega-hack to find sizes\n")); - SAFE_FREE(data); - - param_index=0; - biggest_valuesize=0; - biggest_datasize=0; + param_index = 0; + biggest_valuesize = 0; + biggest_datasize = 0; + + num_values = regval_ctr_numvals( &p_data->keys[key_index].values ); - while (get_specific_param_by_index(*printer, 2, param_index, value, &data, &type, &data_len)) { - if (strlen(value) > biggest_valuesize) biggest_valuesize=strlen(value); - if (data_len > biggest_datasize) biggest_datasize=data_len; - - DEBUG(6,("current values: [%d], [%d]\n", biggest_valuesize, biggest_datasize)); - - SAFE_FREE(data); - param_index++; + for ( i=0; ikeys[key_index].values, i ); + + name_length = strlen(val->valuename); + if ( strlen(val->valuename) > biggest_valuesize ) + biggest_valuesize = name_length; + + if ( val->size > biggest_datasize ) + biggest_datasize = val->size; + + DEBUG(6,("current values: [%d], [%d]\n", biggest_valuesize, + biggest_datasize)); } - /* the value is an UNICODE string but realvaluesize is the length in bytes including the leading 0 */ - *out_value_len=2*(1+biggest_valuesize); - *out_data_len=biggest_datasize; + /* the value is an UNICODE string but real_value_size is the length + in bytes including the trailing 0 */ + + *out_value_len = 2 * (1+biggest_valuesize); + *out_data_len = biggest_datasize; DEBUG(6,("final values: [%d], [%d]\n", *out_value_len, *out_data_len)); - free_a_printer(&printer, 2); - return WERR_OK; + goto done; } /* * the value len is wrong in NT sp3 * that's the number of bytes not the number of unicode chars */ + + val = regval_ctr_specific_value( &p_data->keys[key_index].values, idx ); - if (!get_specific_param_by_index(*printer, 2, idx, value, &data, &type, &data_len)) { - - SAFE_FREE(data); - free_a_printer(&printer, 2); + if ( !val ) + { /* out_value should default to "" or else NT4 has problems unmarshalling the response */ - *out_max_value_len=(in_value_len/sizeof(uint16)); - if((*out_value=(uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL) - return WERR_NOMEM; + *out_max_value_len = (in_value_len/sizeof(uint16)); + + if ( (*out_value=(uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL ) + { + result = WERR_NOMEM; + goto done; + } *out_value_len = (uint32)rpcstr_push((char *)*out_value, "", in_value_len, 0); /* the data is counted in bytes */ + *out_max_data_len = in_data_len; - *out_data_len = in_data_len; - if((*data_out=(uint8 *)talloc_zero(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) - return WERR_NOMEM; + *out_data_len = in_data_len; + + /* only allocate when given a non-zero data_len */ + + if ( in_data_len && ((*data_out=(uint8 *)talloc_zero(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) ) + { + result = WERR_NOMEM; + goto done; + } - return WERR_NO_MORE_ITEMS; + result = WERR_NO_MORE_ITEMS; } - - free_a_printer(&printer, 2); - - /* - * the value is: - * - counted in bytes in the request - * - counted in UNICODE chars in the max reply - * - counted in bytes in the real size - * - * take a pause *before* coding not *during* coding - */ + else + { + /* + * the value is: + * - counted in bytes in the request + * - counted in UNICODE chars in the max reply + * - counted in bytes in the real size + * + * take a pause *before* coding not *during* coding + */ - *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 WERR_NOMEM; - } + /* name */ + *out_max_value_len = ( in_value_len / sizeof(uint16) ); + if ( (*out_value = (uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL ) + { + result = WERR_NOMEM; + goto done; + } - *out_value_len = (uint32)rpcstr_push((char *)*out_value,value, in_value_len, 0); + *out_value_len = (uint32)rpcstr_push((char *)*out_value, regval_name(val), in_value_len, 0); + + /* type */ + + *out_type = regval_type( val ); - *out_type=type; + /* data - counted in bytes */ - /* the data is counted in bytes */ - *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 WERR_NOMEM; + *out_max_data_len = in_data_len; + if ( (*data_out = (uint8 *)talloc_zero(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) + { + result = WERR_NOMEM; + goto done; + } + data_len = (size_t)regval_size(val); + memcpy( *data_out, regval_data_p(val), data_len ); + *out_data_len = data_len; } - - memcpy(*data_out, data, (size_t)data_len); - *out_data_len=data_len; - SAFE_FREE(data); - - return WERR_OK; +done: + free_a_printer(&printer, 2); + return result; } /**************************************************************************** @@ -7271,17 +7062,17 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SPOOL_R_SETPRINTERDATA *r_u) { - POLICY_HND *handle = &q_u->handle; - UNISTR2 *value = &q_u->value; - uint32 type = q_u->type; - uint8 *data = q_u->data; - uint32 real_len = q_u->real_len; + POLICY_HND *handle = &q_u->handle; + UNISTR2 *value = &q_u->value; + uint32 type = q_u->type; + uint8 *data = q_u->data; + uint32 real_len = q_u->real_len; - NT_PRINTER_INFO_LEVEL *printer = NULL; - NT_PRINTER_PARAM *param = NULL, old_param; - int snum=0; - WERROR status = WERR_OK; - Printer_entry *Printer=find_printer_index_by_hnd(p, handle); + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum=0; + WERROR status = WERR_OK; + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); + fstring valuename; DEBUG(5,("spoolss_setprinterdata\n")); @@ -7293,8 +7084,6 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; - ZERO_STRUCT(old_param); - /* * Access check : NT returns "access denied" if you make a * SetPrinterData call without the necessary privildge. @@ -7309,40 +7098,22 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP 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 (!W_ERROR_IS_OK(status)) return status; - convert_specific_param(¶m, value , type, data, real_len); + /* save the registry data */ + + unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); + delete_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, valuename ); + add_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, valuename, type, data, real_len ); - unlink_specific_param_if_exist(printer->info_2, param); + /* write the **entire** printer out to disk.... :-( */ - /* - * 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, ¶m); - status = mod_a_printer(*printer, 2); - } + status = mod_a_printer(*printer, 2); - done: +done: free_a_printer(&printer, 2); - if (param) - free_nt_printer_param(¶m); - SAFE_FREE(old_param.data); return status; } @@ -7352,9 +7123,9 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP WERROR _spoolss_resetprinter(pipes_struct *p, SPOOL_Q_RESETPRINTER *q_u, SPOOL_R_RESETPRINTER *r_u) { - POLICY_HND *handle = &q_u->handle; - Printer_entry *Printer=find_printer_index_by_hnd(p, handle); - int snum; + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); + int snum; DEBUG(5,("_spoolss_resetprinter\n")); @@ -7378,16 +7149,19 @@ WERROR _spoolss_resetprinter(pipes_struct *p, SPOOL_Q_RESETPRINTER *q_u, SPOOL_R } +/**************************************************************************** +****************************************************************************/ + WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_u, SPOOL_R_DELETEPRINTERDATA *r_u) { - POLICY_HND *handle = &q_u->handle; - UNISTR2 *value = &q_u->valuename; + POLICY_HND *handle = &q_u->handle; + UNISTR2 *value = &q_u->valuename; - NT_PRINTER_INFO_LEVEL *printer = NULL; - NT_PRINTER_PARAM param; - int snum=0; - WERROR status = WERR_OK; - Printer_entry *Printer=find_printer_index_by_hnd(p, handle); + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum=0; + WERROR status = WERR_OK; + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); + pstring valuename; DEBUG(5,("spoolss_deleteprinterdata\n")); @@ -7408,15 +7182,14 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ if (!W_ERROR_IS_OK(status)) return status; - ZERO_STRUCTP(¶m); - unistr2_to_ascii(param.value, value, sizeof(param.value)-1); + unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); - if(!unlink_specific_param_if_exist(printer->info_2, ¶m)) - status = WERR_INVALID_PARAM; - else + status = delete_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, valuename ); + if ( NT_STATUS_IS_OK(status) ) status = mod_a_printer(*printer, 2); free_a_printer(&printer, 2); + return status; } @@ -7426,7 +7199,6 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM *r_u) { POLICY_HND *handle = &q_u->handle; -/* uint32 level = q_u->level; - notused. */ FORM *form = &q_u->form; nt_forms_struct tmpForm; int snum; @@ -8045,9 +7817,10 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, * (a) DsDriver * (b) DsSpooler * (c) PnPData + * (d) DsUser */ - if (strcmp(key, "PrinterDriverData") != 0) + if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) return WERR_BADFILE; DEBUG(10, ("_spoolss_getprinterdataex: pass me to getprinterdata\n")); @@ -8093,7 +7866,7 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); - if (strcmp(key, "PrinterDriverData") != 0) + if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) return WERR_INVALID_PARAM; ZERO_STRUCT(q_u_local); @@ -8128,7 +7901,7 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); - if (strcmp(key, "PrinterDriverData") != 0) + if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) return WERR_INVALID_PARAM; memcpy(&q_u_local.handle, &q_u->handle, sizeof(POLICY_HND)); @@ -8153,7 +7926,7 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO uint16 enumkeys[ENUMERATED_KEY_SIZE+1]; char* ptr = NULL; int i; - char *PrinterKey = "PrinterDriverData"; + char *PrinterKey = SPOOL_PRINTERDATA_KEY; DEBUG(4,("_spoolss_enumprinterkey\n")); @@ -8222,7 +7995,7 @@ WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); - if (strcmp(key, "PrinterDriverData") != 0) + if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) return WERR_INVALID_PARAM; /* @@ -8246,14 +8019,16 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ needed; NT_PRINTER_INFO_LEVEL *printer = NULL; PRINTER_ENUM_VALUES *enum_values = NULL; - fstring key, value; + NT_PRINTER_DATA *p_data; + fstring key; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); int snum; - uint32 param_index, - data_len, - type; WERROR result; - uint8 *data=NULL; + int key_index; + int i; + REGISTRY_VALUE *val; + char *value_name; + int data_len; DEBUG(4,("_spoolss_enumprinterdataex\n")); @@ -8264,20 +8039,8 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ } - /* - * The only key we support is "PrinterDriverData". This should return - > an array of all the key/value pairs returned by EnumPrinterDataSee - * _spoolss_getprinterdataex() for details --jerry - */ - - unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); - if (strcmp(key, "PrinterDriverData") != 0) - { - DEBUG(10,("_spoolss_enumprinterdataex: Unknown keyname [%s]\n", key)); - return WERR_INVALID_PARAM; - } - - + /* first get the printer off of disk */ + if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; @@ -8285,61 +8048,76 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ result = get_a_printer(&printer, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(result)) return result; - - /* - * loop through all params and build the array to pass - * back to the client - */ + /* now look for a match on the key name */ + + p_data = &printer->info_2->data; + + unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); + if ( (key_index = lookup_printerkey( p_data, key)) == -1 ) + { + DEBUG(10,("_spoolss_enumprinterdataex: Unknown keyname [%s]\n", key)); + result = WERR_INVALID_PARAM; + goto done; + } + result = WERR_OK; - param_index = 0; - needed = 0; - num_entries = 0; + needed = 0; - while (get_specific_param_by_index(*printer, 2, param_index, value, &data, &type, &data_len)) + /* allocate the memory for the array of pointers -- if necessary */ + + num_entries = regval_ctr_numvals( &p_data->keys[key_index].values ); + if ( num_entries ) { - PRINTER_ENUM_VALUES *ptr; - - DEBUG(10,("retrieved value number [%d] [%s]\n", num_entries, value)); - - if ((ptr=talloc_realloc(p->mem_ctx, enum_values, (num_entries+1) * sizeof(PRINTER_ENUM_VALUES))) == NULL) + if ( (enum_values=talloc(p->mem_ctx, num_entries*sizeof(PRINTER_ENUM_VALUES))) == NULL ) { - DEBUG(0,("talloc_realloc failed to allocate more memory!\n")); + DEBUG(0,("_spoolss_enumprinterdataex: talloc() failed to allocate memory for [%d] bytes!\n", + num_entries*sizeof(PRINTER_ENUM_VALUES))); result = WERR_NOMEM; goto done; } - enum_values = ptr; + + memset( enum_values, 0x0, num_entries*sizeof(PRINTER_ENUM_VALUES) ); + } + + /* + * loop through all params and build the array to pass + * back to the client + */ + + for ( i=0; ikeys[key_index].values, i ); + DEBUG(10,("retrieved value number [%d] [%s]\n", i, regval_name(val) )); /* copy the data */ - init_unistr(&enum_values[num_entries].valuename, value); - enum_values[num_entries].value_len = (strlen(value)+1) * 2; - enum_values[num_entries].type = type; + value_name = regval_name( val ); + init_unistr( &enum_values[i].valuename, value_name ); + enum_values[i].value_len = (strlen(value_name)+1) * 2; + enum_values[i].type = regval_type( val ); - if ( data_len ) - { - if ( !(enum_values[num_entries].data = talloc_zero(p->mem_ctx, data_len)) ) { - DEBUG(0,("talloc_realloc failed to allocate more memory [data_len=%d] for data!\n", data_len )); + data_len = regval_size( val ); + if ( data_len ) { + if ( !(enum_values[i].data = talloc_memdup(p->mem_ctx, regval_data_p(val), data_len)) ) + { + DEBUG(0,("talloc_memdup failed to allocate memory [data_len=%d] for data!\n", + data_len )); result = WERR_NOMEM; goto done; } - memcpy(enum_values[num_entries].data, data, data_len); } - - enum_values[num_entries].data_len = data_len; + enum_values[i].data_len = data_len; /* keep track of the size of the array in bytes */ needed += spoolss_size_printer_enum_values(&enum_values[num_entries]); - - num_entries++; - param_index++; } - r_u->needed = needed; - r_u->returned = num_entries; + r_u->needed = needed; + r_u->returned = num_entries; if (needed > in_size) { result = WERR_MORE_DATA; -- cgit From 31514f67ae28844deb85a031fb707bff12dc7b76 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 16 Aug 2002 16:46:50 +0000 Subject: fix small bug in enumprinterdataex due to my changes (still more lurking though). (This used to be commit 2feb89601fc45dea13fe45a55a9c058726a5de84) --- source3/rpc_server/srv_spoolss_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2aa11530f8..b6a7eeee6c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8113,9 +8113,11 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ /* keep track of the size of the array in bytes */ - needed += spoolss_size_printer_enum_values(&enum_values[num_entries]); + needed += spoolss_size_printer_enum_values(&enum_values[i]); } + /* housekeeping information in the reply */ + r_u->needed = needed; r_u->returned = num_entries; -- cgit From 3a226d149db5ddca14448640818f2d51380a331c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 16 Aug 2002 17:35:38 +0000 Subject: Return access granted in create_user2. (This used to be commit 8ebc295f4a487993474390e0686d2aa9313be8d1) --- source3/rpc_server/srv_samr_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ee40453482..a30622c600 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2364,9 +2364,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ r_u->user_rid=pdb_get_user_rid(sam_pass); - /* This should probably be some subset of q_u->access_mask */ - - r_u->access_granted = 0x000703ff; + r_u->access_granted = acc_granted; pdb_free_sam(&sam_pass); -- cgit From f56e06476fed5dda04ce12734aeb6efc9bf2d0a4 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 17 Aug 2002 00:38:20 +0000 Subject: fix seg fault in _spoolss_enumprinterkey after changes... add SPOOL_PNPDATA_KEY define (This used to be commit cdaa3f55e1fcc38b1d7a63d502a9fea3b92bf193) --- source3/rpc_server/srv_spoolss_nt.c | 48 ++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b6a7eeee6c..2c1dbefd8b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7917,57 +7917,66 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX * spoolss_enumprinterkey ********************************************************************/ -/* constants for EnumPrinterKey() */ -#define ENUMERATED_KEY_SIZE 19 WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPOOL_R_ENUMPRINTERKEY *r_u) { fstring key; - uint16 enumkeys[ENUMERATED_KEY_SIZE+1]; + uint16 *enumkeys = NULL; char* ptr = NULL; int i; - char *PrinterKey = SPOOL_PRINTERDATA_KEY; + int printerkey_len = strlen(SPOOL_PRINTERDATA_KEY)+1; DEBUG(4,("_spoolss_enumprinterkey\n")); - unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); + unistr2_to_ascii( key, &q_u->key, sizeof(key)-1 ); /* * we only support enumating all keys (key == "") * Of course, the only key we support is the "PrinterDriverData" * key - */ - if (strlen(key) == 0) + */ + + if ( !strlen( key ) ) { - r_u->needed = ENUMERATED_KEY_SIZE *2; - if (q_u->size < r_u->needed) + r_u->needed = printerkey_len*2; + + if ( q_u->size < r_u->needed ) return WERR_MORE_DATA; - ptr = PrinterKey; - for (i=0; imem_ctx, printerkey_len*2 )) ) { + DEBUG(0,("_spoolss_enumprinterkey: talloc() failed for [%d] bytes!\n", + printerkey_len)); + return WERR_NOMEM; + } + + ptr = SPOOL_PRINTERDATA_KEY; + for ( i=0; i<(printerkey_len-1); i++ ) { enumkeys[i] = (uint16)(*ptr); ptr++; } - /* tag of with 2 '\0's */ - enumkeys[i++] = '\0'; - enumkeys[i] = '\0'; + /* tag of '\0's */ + + enumkeys[i] = 0x0; - if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, ENUMERATED_KEY_SIZE, enumkeys)) + if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, printerkey_len, enumkeys)) return WERR_BADFILE; return WERR_OK; } /* The "PrinterDriverData" key should have no subkeys */ - if (strcmp(key, PrinterKey) == 0) + if ( strcmp(key, SPOOL_PRINTERDATA_KEY) == 0 ) { - r_u-> needed = 2; + uint16 dummy_key = 0; + + r_u->needed = 2; + if (q_u->size < r_u->needed) return WERR_MORE_DATA; - enumkeys[0] = 0x0; - if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, 1, enumkeys)) + + if ( !make_spoolss_buffer5(p->mem_ctx, &r_u->keys, 1, &dummy_key ) ) return WERR_BADFILE; return WERR_OK; @@ -7976,6 +7985,7 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO /* The return value for an unknown key is documented in MSDN EnumPrinterKey description */ + return WERR_BADFILE; } -- cgit From cb36e520b38edf063157024b46d9e58f8a341028 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 17 Aug 2002 13:17:41 +0000 Subject: * the printing code should now be back to the working state it was before the swap from NT_PRINTER_PARAM to REGISTRY_VALUE. * XxxPrinterDataEx() functions have not been expanded to support keys other than SPOOL_PRINTERDATA_KEY yet * fixed apparent long standing bug regarding the dependentfiles list in the DRIVER_INFO struct (This used to be commit d59b0eb1236cf5bb9371030a94eb60d4131c15fb) --- source3/rpc_server/srv_spoolss_nt.c | 56 +++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2c1dbefd8b..7aceaa548f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4395,22 +4395,29 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser DEBUG(6,("init_unistr_array\n")); *uni_array=NULL; - while (1) { + while (True) + { if (char_array == NULL) v = ""; else { v = char_array[i]; if (!v) v = ""; /* hack to handle null lists */ } - if (strlen(v) == 0) break; + + if ( !strlen(v) ) + break; + slprintf(line, sizeof(line)-1, "\\\\%s%s", servername, v); + DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); + if((tuary=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL) { DEBUG(2,("init_unistr_array: Realloc error\n" )); return; } else *uni_array = tuary; - j += (rpcstr_push((*uni_array+j), line, sizeof(uint16)*strlen(line)+2, 0)/ sizeof(uint16)); + + j += (rpcstr_push((*uni_array+j), line, sizeof(uint16)*strlen(line)+2, STR_TERMINATE) / sizeof(uint16)); i++; } @@ -4572,8 +4579,8 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->monitorname, driver.info_3->monitorname ); init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype ); - info->dependentfiles=NULL; - init_unistr_array(&info->dependentfiles, driver.info_3->dependentfiles, servername); + info->dependentfiles = NULL; + init_unistr_array( &info->dependentfiles, driver.info_3->dependentfiles, servername ); info->previousdrivernames=NULL; init_unistr_array(&info->previousdrivernames, &nullstr, servername); @@ -4596,21 +4603,28 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN * fill a printer_info_6 struct ********************************************************************/ -static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fstring servername, fstring architecture, uint32 version) +static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, + fstring servername, fstring architecture, uint32 version) { - NT_PRINTER_INFO_LEVEL *printer = NULL; - NT_PRINTER_DRIVER_INFO_LEVEL driver; - WERROR status; + NT_PRINTER_INFO_LEVEL *printer = NULL; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + WERROR status; + ZERO_STRUCT(driver); status=get_a_printer(&printer, 2, lp_servicename(snum) ); + DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status))); + if (!W_ERROR_IS_OK(status)) return WERR_INVALID_PRINTER_NAME; - status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); + status = get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); + DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status))); - if (!W_ERROR_IS_OK(status)) { + + if (!W_ERROR_IS_OK(status)) + { /* * Is this a W2k client ? */ @@ -4821,9 +4835,9 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ DEBUG(4,("_spoolss_getprinterdriver2\n")); - *needed=0; - *servermajorversion=0; - *serverminorversion=0; + *needed = 0; + *servermajorversion = 0; + *serverminorversion = 0; pstrcpy(servername, get_called_name()); unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); @@ -5340,7 +5354,8 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, * requires Win32 client code (see other notes elsewhere in the code). */ if (printer->info_2->devmode && - printer->info_2->devmode->displayfrequency == MAGIC_DISPLAY_FREQUENCY) { + printer->info_2->devmode->displayfrequency == MAGIC_DISPLAY_FREQUENCY) + { DEBUG(10,("update_printer: Save printer driver init data\n")); printer->info_2->devmode->displayfrequency = 0; @@ -5356,20 +5371,25 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, srv_spoolss_reset_printerdata( printer->info_2->drivername ); - } else { + } + else + { /* * When a *new* driver is bound to a printer, the drivername is used to * lookup previously saved driver initialization info, which is then * bound to the printer, simulating what happens in the Windows arch. */ - if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)){ - if (!set_driver_init(printer, 2)) { + if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)) + { + if (!set_driver_init(printer, 2)) + { DEBUG(5,("update_printer: Error restoring driver initialization data for driver [%s]!\n", printer->info_2->drivername)); } DEBUG(10,("update_printer: changing driver [%s]! Sending event!\n", printer->info_2->drivername)); + notify_printer_driver(snum, printer->info_2->drivername); } } -- cgit From 8c53b214da14e7fbfeee3ccf28bddedb55592ab8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 17 Aug 2002 15:34:15 +0000 Subject: Sync 3.0 branch with HEAD (This used to be commit e01596853e3eea533baa08c33f26ded75f33fdd4) --- source3/rpc_server/srv_lsa.c | 37 +- source3/rpc_server/srv_lsa_nt.c | 97 ++- source3/rpc_server/srv_netlog_nt.c | 6 +- source3/rpc_server/srv_reg.c | 81 ++- source3/rpc_server/srv_reg_nt.c | 730 +++++++++------------- source3/rpc_server/srv_samr.c | 40 +- source3/rpc_server/srv_samr_nt.c | 142 ++++- source3/rpc_server/srv_spoolss.c | 63 ++ source3/rpc_server/srv_spoolss_nt.c | 1159 ++++++++++++++++------------------- source3/rpc_server/srv_srvsvc.c | 31 + source3/rpc_server/srv_srvsvc_nt.c | 394 +++++++++--- source3/rpc_server/srv_util.c | 62 +- 12 files changed, 1614 insertions(+), 1228 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index e5a4d3b46d..e3495576c9 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -3,8 +3,9 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Jim McDonough 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -609,6 +610,37 @@ static BOOL api_lsa_query_secobj(pipes_struct *p) return True; } +/*************************************************************************** + api_lsa_query_dnsdomainfo + ***************************************************************************/ + +static BOOL api_lsa_query_info2(pipes_struct *p) +{ + LSA_Q_QUERY_INFO2 q_u; + LSA_R_QUERY_INFO2 r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_query_info2("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_query_info2: failed to unmarshall LSA_Q_QUERY_INFO2.\n")); + return False; + } + + r_u.status = _lsa_query_info2(p, &q_u, &r_u); + + if (!lsa_io_r_query_info2("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_query_info2: failed to marshall LSA_R_QUERY_INFO2.\n")); + return False; + } + + return True; +} + + /*************************************************************************** \PIPE\ntlsa commands ***************************************************************************/ @@ -634,6 +666,7 @@ static struct api_struct api_lsa_cmds[] = { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs }, { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs }, { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, + { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 }, { NULL , 0 , NULL } }; diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index d072061a5f..f28441886a 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -5,7 +5,8 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Rafal Szczesniak 2002. + * Copyright (C) Rafal Szczesniak 2002, + * Copyright (C) Jim McDonough 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -341,6 +342,48 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s return NT_STATUS_OK; } +/*************************************************************************** + init_dns_dom_info. + ***************************************************************************/ +static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, char *nb_name, + char *dns_name, char *forest_name, + GUID *dom_guid, DOM_SID *dom_sid) +{ + if (nb_name && *nb_name) { + init_uni_hdr(&r_l->hdr_nb_dom_name, strlen(nb_name)); + init_unistr2(&r_l->uni_nb_dom_name, nb_name, + strlen(nb_name)); + r_l->hdr_nb_dom_name.uni_max_len += 2; + r_l->uni_nb_dom_name.uni_max_len += 1; + } + + if (dns_name && *dns_name) { + init_uni_hdr(&r_l->hdr_dns_dom_name, strlen(dns_name)); + init_unistr2(&r_l->uni_dns_dom_name, dns_name, + strlen(dns_name)); + r_l->hdr_dns_dom_name.uni_max_len += 2; + r_l->uni_dns_dom_name.uni_max_len += 1; + } + + if (forest_name && *forest_name) { + init_uni_hdr(&r_l->hdr_forest_name, strlen(forest_name)); + init_unistr2(&r_l->uni_forest_name, forest_name, + strlen(forest_name)); + r_l->hdr_forest_name.uni_max_len += 2; + r_l->uni_forest_name.uni_max_len += 1; + } + + /* how do we init the guid ? probably should write an init fn */ + if (dom_guid) { + memcpy(&r_l->dom_guid, dom_guid, sizeof(GUID)); + } + + if (dom_sid) { + r_l->ptr_dom_sid = 1; + init_dom_sid2(&r_l->dom_sid, dom_sid); + } +} + /*************************************************************************** _lsa_open_policy2. ***************************************************************************/ @@ -1166,3 +1209,55 @@ NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUER } +NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_INFO2 *r_u) +{ + struct lsa_info *handle; + char *nb_name = NULL; + char *dns_name = NULL; + char *forest_name = NULL; + DOM_SID *sid = NULL; + GUID guid; + + ZERO_STRUCT(guid); + r_u->status = NT_STATUS_OK; + + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) + return NT_STATUS_INVALID_HANDLE; + + switch (q_u->info_class) { + case 0x0c: + /* check if the user have enough rights */ + if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + + /* Request PolicyPrimaryDomainInformation. */ + switch (lp_server_role()) { + case ROLE_DOMAIN_PDC: + case ROLE_DOMAIN_BDC: + nb_name = global_myworkgroup; + /* ugly temp hack for these next two */ + dns_name = lp_realm(); + forest_name = lp_realm(); + sid = get_global_sam_sid(); + secrets_fetch_domain_guid(global_myworkgroup, + &guid); + break; + default: + return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; + } + init_dns_dom_info(&r_u->info.dns_dom_info, nb_name, dns_name, + forest_name,&guid,sid); + break; + default: + DEBUG(0,("_lsa_query_info2: unknown info level in Lsa Query: %d\n", q_u->info_class)); + r_u->status = NT_STATUS_INVALID_INFO_CLASS; + break; + } + + if (NT_STATUS_IS_OK(r_u->status)) { + r_u->ptr = 0x1; + r_u->info_class = q_u->info_class; + } + + return r_u->status; +} diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 4ab9c470d0..8f6011826a 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -280,7 +280,7 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) /* from client / server challenges and md4 password, generate sess key */ cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal, - (char *)p->dc.md4pw, p->dc.sess_key); + p->dc.md4pw, p->dc.sess_key); /* check that the client credentials are valid */ if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) { @@ -342,7 +342,7 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) /* from client / server challenges and md4 password, generate sess key */ cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal, - (char *)p->dc.md4pw, p->dc.sess_key); + p->dc.md4pw, p->dc.sess_key); /* check that the client credentials are valid */ if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) { @@ -708,7 +708,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * pdb_get_username(sampw), pdb_get_fullname(sampw), pdb_get_homedir(sampw), - pdb_get_dirdrive(sampw), + pdb_get_dir_drive(sampw), pdb_get_logon_script(sampw), pdb_get_profile_path(sampw), pdb_get_logon_time(sampw), diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index a096325860..d0aaf0199b 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -83,7 +83,7 @@ static BOOL api_reg_open_hklm(pipes_struct *p) } /******************************************************************* - api_reg_open_khlm + api_reg_open_khu ********************************************************************/ static BOOL api_reg_open_hku(pipes_struct *p) @@ -108,6 +108,32 @@ static BOOL api_reg_open_hku(pipes_struct *p) return True; } +/******************************************************************* + api_reg_open_khcr + ********************************************************************/ + +static BOOL api_reg_open_hkcr(pipes_struct *p) +{ + REG_Q_OPEN_HKCR q_u; + REG_R_OPEN_HKCR r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the reg open */ + if(!reg_io_q_open_hkcr("", &q_u, data, 0)) + return False; + + r_u.status = _reg_open_hkcr(p, &q_u, &r_u); + + if(!reg_io_r_open_hkcr("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* api_reg_open_entry @@ -290,6 +316,56 @@ static BOOL api_reg_enum_key(pipes_struct *p) return True; } +/******************************************************************* + api_reg_enum_value + ********************************************************************/ + +static BOOL api_reg_enum_value(pipes_struct *p) +{ + REG_Q_ENUM_VALUE q_u; + REG_R_ENUM_VALUE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_enum_val("", &q_u, data, 0)) + return False; + + r_u.status = _reg_enum_value(p, &q_u, &r_u); + + if(!reg_io_r_enum_val("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + api_reg_save_key + ********************************************************************/ + +static BOOL api_reg_save_key(pipes_struct *p) +{ + REG_Q_SAVE_KEY q_u; + REG_R_SAVE_KEY r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_save_key("", &q_u, data, 0)) + return False; + + r_u.status = _reg_save_key(p, &q_u, &r_u); + + if(!reg_io_r_save_key("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* @@ -299,14 +375,17 @@ static struct api_struct api_reg_cmds[] = { { "REG_CLOSE" , REG_CLOSE , api_reg_close }, { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, + { "REG_OPEN_HKCR" , REG_OPEN_HKCR , api_reg_open_hkcr }, { "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm }, { "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku }, { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key }, + { "REG_ENUM_VALUE" , REG_ENUM_VALUE , api_reg_enum_value }, { "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key }, { "REG_INFO" , REG_INFO , api_reg_info }, { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, { "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a }, + { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key }, { NULL , 0 , NULL } }; diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 3f07e4aaea..cd9596d2a7 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -1,12 +1,11 @@ /* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Hewlett-Packard Company 1999. - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Gerald Carter 2002. + * Copyright (C) Andrew Tridgell 1992-1997. + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997. + * Copyright (C) Paul Ashton 1997. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Gerald Carter 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,386 +29,134 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -#define KEY_HKLM "HKLM" -#define KEY_HKU "HKU" +#define REGSTR_PRODUCTTYPE "ProductType" +#define REG_PT_WINNT "WinNT" +#define REG_PT_LANMANNT "LanmanNT" +#define REG_PT_SERVERNT "ServerNT" #define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ ((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) -/* structure to store the registry handles */ -typedef struct _RegistryKey { - struct _RegistryKey *prev, *next; +static REGISTRY_KEY *regkeys_list; - fstring name; /* name of registry key */ - POLICY_HND hnd; - -} Registry_Key; - -static Registry_Key *regkeys_list; -static TDB_CONTEXT *tdb_reg; -/*********************************************************************** - Add subkey strings to the registry tdb under a defined key - fmt is the same format as tdb_pack except this function only supports - fstrings - ***********************************************************************/ +/****************************************************************** + free() function for REGISTRY_KEY + *****************************************************************/ -static BOOL store_reg_keys( TDB_CONTEXT *tdb, char *keyname, char **subkeys, uint32 num_subkeys ) +static void free_regkey_info(void *ptr) { - TDB_DATA kbuf, dbuf; - char *buffer, *tmpbuf; - int i = 0; - uint32 len, buflen; - BOOL ret = True; - - if ( !keyname ) - return False; - - /* allocate some initial memory */ - - buffer = malloc(sizeof(pstring)); - buflen = sizeof(pstring); - len = 0; - - /* store the number of subkeys */ - - len += tdb_pack(buffer+len, buflen-len, "d", num_subkeys); - - /* pack all the strings */ - - for (i=0; i buflen ) { - /* allocate some extra space */ - if ((tmpbuf = Realloc( buffer, len*2 )) == NULL) { - DEBUG(0,("store_reg_keys: Failed to realloc memory of size [%d]\n", len*2)); - ret = False; - goto done; - } - buffer = tmpbuf; - buflen = len*2; - - len = tdb_pack(buffer+len, buflen-len, "f", subkeys[i]); - } - } - - /* finally write out the data */ + REGISTRY_KEY *info = (REGISTRY_KEY*)ptr; - kbuf.dptr = keyname; - kbuf.dsize = strlen(keyname)+1; - dbuf.dptr = buffer; - dbuf.dsize = len; - if ( tdb_store( tdb, kbuf, dbuf, TDB_REPLACE ) == -1) { - ret = False; - goto done; - } + DLIST_REMOVE(regkeys_list, info); -done: - SAFE_FREE( buffer ); - return ret; + SAFE_FREE(info); } -/*********************************************************************** - Retrieve an array of strings containing subkeys. Memory should be - released by the caller. The subkeys are stored in a catenated string - of null terminated character strings - ***********************************************************************/ +/****************************************************************** + Find a registry key handle and return a REGISTRY_KEY + *****************************************************************/ -static int fetch_reg_keys( TDB_CONTEXT *tdb, char* key, char **subkeys ) +static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) { - pstring path; - uint32 num_items; - TDB_DATA dbuf; - char *buf; - uint32 buflen, len; - int i; - char *s; - - - pstrcpy( path, key ); - - /* convert to key format */ - pstring_sub( path, "\\", "/" ); - - dbuf = tdb_fetch_by_string( tdb, path ); - - buf = dbuf.dptr; - buflen = dbuf.dsize; - - if ( !buf ) { - DEBUG(5,("fetch_reg_keys: Failed to fetch any subkeys for [%s]\n", key)); - return 0; - } - - len = tdb_unpack( buf, buflen, "d", &num_items); - if (num_items) { - if ( (*subkeys = (char*)malloc(sizeof(fstring)*num_items)) == NULL ) { - DEBUG(0,("fetch_reg_keys: Failed to malloc memory for subkey array containing [%d] items!\n", - num_items)); - num_items = -1; - goto done; - } - } - - s = *subkeys; - for (i=0; i\\... + *******************************************************************/ + +static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY *parent, + char *subkeyname, uint32 access_granted ) { - pstring keyname; - char *subkeys[3]; - - /* HKEY_LOCAL_MACHINE */ + REGISTRY_KEY *regkey = NULL; + NTSTATUS result = NT_STATUS_OK; + REGSUBKEY_CTR subkeys; - pstrcpy( keyname, KEY_HKLM ); - subkeys[0] = "SYSTEM"; - if ( !store_reg_keys( registry_tdb, keyname, subkeys, 1 )) - return False; - - pstrcpy( keyname, KEY_HKLM ); - pstrcat( keyname, "/SYSTEM" ); - subkeys[0] = "CurrentControlSet"; - if ( !store_reg_keys( registry_tdb, keyname, subkeys, 1 )) - return False; - - pstrcpy( keyname, KEY_HKLM ); - pstrcat( keyname, "/SYSTEM/CurrentControlSet" ); - subkeys[0] = "Control"; - subkeys[1] = "services"; - if ( !store_reg_keys( registry_tdb, keyname, subkeys, 2 )) - return False; - - pstrcpy( keyname, KEY_HKLM ); - pstrcat( keyname, "/SYSTEM/CurrentControlSet/Control" ); - subkeys[0] = "Print"; - subkeys[1] = "ProduceOptions"; - if ( !store_reg_keys( registry_tdb, keyname, subkeys, 2 )) - return False; - - pstrcpy( keyname, KEY_HKLM ); - pstrcat( keyname, "/SYSTEM/CurrentControlSet/Control/Print" ); - subkeys[0] = "Environments"; - subkeys[1] = "Forms"; - subkeys[2] = "Printers"; - if ( !store_reg_keys( registry_tdb, keyname, subkeys, 3 )) - return False; - - pstrcpy( keyname, KEY_HKLM ); - pstrcat( keyname, "/SYSTEM/CurrentControlSet/Control/ProductOptions" ); - if ( !store_reg_keys( registry_tdb, keyname, subkeys, 0 )) - return False; - - pstrcpy( keyname, KEY_HKLM ); - pstrcat( keyname, "/SYSTEM/CurrentControlSet/services" ); - subkeys[0] = "Netlogon"; - if ( !store_reg_keys( registry_tdb, keyname, subkeys, 1 )) - return False; - - pstrcpy( keyname, KEY_HKLM ); - pstrcat( keyname, "/SYSTEM/CurrentControlSet/services/Netlogon" ); - subkeys[0] = "parameters"; - if ( !store_reg_keys( registry_tdb, keyname, subkeys, 1 )) - return False; - - pstrcpy( keyname, KEY_HKLM ); - pstrcat( keyname, "/SYSTEM/CurrentControlSet/services/Netlogon/parameters" ); - if ( !store_reg_keys( registry_tdb, keyname, subkeys, 0 )) - return False; + DEBUG(7,("open_registry_key: name = [%s][%s]\n", + parent ? parent->name : "NULL", subkeyname)); - - /* HKEY_USER */ - - pstrcpy( keyname, KEY_HKU ); - if ( !store_reg_keys( registry_tdb, keyname, subkeys, 0 ) ) - return False; + if ((regkey=(REGISTRY_KEY*)malloc(sizeof(REGISTRY_KEY))) == NULL) + return NT_STATUS_NO_MEMORY; - return True; -} - -/*********************************************************************** - Open the registry database - ***********************************************************************/ - -BOOL init_registry( void ) -{ - static pid_t local_pid; - + ZERO_STRUCTP( regkey ); - if (tdb_reg && local_pid == sys_getpid()) - return True; - /* - * try to open first without creating so we can determine - * if we need to init the data in the registry + * very crazy, but regedit.exe on Win2k will attempt to call + * REG_OPEN_ENTRY with a keyname of "". We should return a new + * (second) handle here on the key->name. regedt32.exe does + * not do this stupidity. --jerry */ - tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600); - if ( !tdb_reg ) - { - tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); - if ( !tdb_reg ) { - DEBUG(0,("init_registry: Failed to open registry %s (%s)\n", - lock_path("registry.tdb"), strerror(errno) )); - return False; - } - - DEBUG(10,("init_registry: Successfully created registry tdb\n")); - - /* create the registry here */ - if ( !init_registry_data( tdb_reg ) ) { - DEBUG(0,("init_registry: Failed to initiailize data in registry!\n")); - return False; + if (!subkeyname || !*subkeyname ) { + pstrcpy( regkey->name, parent->name ); + } + else { + pstrcpy( regkey->name, "" ); + if ( parent ) { + pstrcat( regkey->name, parent->name ); + pstrcat( regkey->name, "\\" ); } + pstrcat( regkey->name, subkeyname ); } - - local_pid = sys_getpid(); - return True; -} + /* Look up the table of registry I/O operations */ -/****************************************************************** - Find a registry key handle and return a Registry_Key - *****************************************************************/ - -static Registry_Key *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) -{ - Registry_Key *regkey = NULL; - - if(!find_policy_by_hnd(p,hnd,(void **)®key)) { - DEBUG(2,("find_regkey_index_by_hnd: Registry Key not found: ")); - return NULL; + if ( !(regkey->hook = reghook_cache_find( regkey->name )) ) { + DEBUG(0,("open_registry_key: Failed to assigned a REGISTRY_HOOK to [%s]\n", + regkey->name )); + return NT_STATUS_OBJECT_PATH_NOT_FOUND; } - - return regkey; -} - - -/****************************************************************** - free() function for Registry_Key - *****************************************************************/ - -static void free_reg_info(void *ptr) -{ - Registry_Key *info = (Registry_Key*)ptr; - DLIST_REMOVE(regkeys_list, info); - - SAFE_FREE(info); -} - -/******************************************************************* - Function for open a new registry handle and creating a handle - Note that P should be valid & hnd should already have space - *******************************************************************/ - -static BOOL open_registry_key(pipes_struct *p, POLICY_HND *hnd, char *name, - uint32 access_granted) -{ - Registry_Key *regkey = NULL; - - DEBUG(7,("open_registry_key: name = [%s]\n", name)); + /* check if the path really exists; failed is indicated by -1 */ + /* if the subkey count failed, bail out */ - /* All registry keys **must** have a name of non-zero length */ + ZERO_STRUCTP( &subkeys ); - if (!name || !*name ) - return False; - - if ((regkey=(Registry_Key*)malloc(sizeof(Registry_Key))) == NULL) - return False; + regsubkey_ctr_init( &subkeys ); + + if ( fetch_reg_keys( regkey, &subkeys ) == -1 ) { + + /* don't really know what to return here */ - ZERO_STRUCTP( regkey ); + result = NT_STATUS_NO_SUCH_FILE; + } + else { + /* + * This would previously return NT_STATUS_TOO_MANY_SECRETS + * that doesn't sound quite right to me --jerry + */ + + if ( !create_policy_hnd( p, hnd, free_regkey_info, regkey ) ) + result = NT_STATUS_OBJECT_NAME_NOT_FOUND; + } - DLIST_ADD( regkeys_list, regkey ); + /* clean up */ - /* copy the name and obtain a handle */ + regsubkey_ctr_destroy( &subkeys ); - fstrcpy( regkey->name, name ); + if ( ! NT_STATUS_IS_OK(result) ) + SAFE_FREE( regkey ); + else + DLIST_ADD( regkeys_list, regkey ); + DEBUG(7,("open_registry_key: exit\n")); - - return create_policy_hnd( p, hnd, free_reg_info, regkey ); + + return result; } /******************************************************************* @@ -419,7 +166,7 @@ static BOOL open_registry_key(pipes_struct *p, POLICY_HND *hnd, char *name, static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd) { - Registry_Key *regkey = find_regkey_index_by_hnd(p, hnd); + REGISTRY_KEY *regkey = find_regkey_index_by_hnd(p, hnd); if ( !regkey ) { DEBUG(2,("close_registry_key: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(hnd))); @@ -435,35 +182,37 @@ static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd) retrieve information about the subkeys *******************************************************************/ -static BOOL get_subkey_information( Registry_Key *key, uint32 *maxnum, uint32 *maxlen ) +static BOOL get_subkey_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *maxlen ) { - int num_subkeys, i; - uint32 max_len; - char *subkeys = NULL; - uint32 len; - char *s; + int num_subkeys, i; + uint32 max_len; + REGSUBKEY_CTR subkeys; + uint32 len; if ( !key ) return False; + + ZERO_STRUCTP( &subkeys ); - num_subkeys = fetch_reg_keys( tdb_reg, key->name, &subkeys ); - if ( num_subkeys == -1 ) + regsubkey_ctr_init( &subkeys ); + + if ( fetch_reg_keys( key, &subkeys ) == -1 ) return False; /* find the longest string */ max_len = 0; - s = subkeys; + num_subkeys = regsubkey_ctr_numkeys( &subkeys ); + for ( i=0; ivaluename)+1 ); + sizemax = MAX(sizemax, val->size ); + + val = regval_ctr_specific_value( &values, i ); + } - return False; -#endif + *maxnum = num_values; + *maxlen = lenmax; + *maxsize = sizemax; + + regval_ctr_destroy( &values ); + + return True; } + /******************************************************************** reg_close ********************************************************************/ @@ -515,27 +282,27 @@ NTSTATUS _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) } /******************************************************************* - reg_reply_open ********************************************************************/ NTSTATUS _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u) { - if (!open_registry_key(p, &r_u->pol, KEY_HKLM, 0x0)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; + return open_registry_key( p, &r_u->pol, NULL, KEY_HKLM, 0x0 ); +} - return NT_STATUS_OK; +/******************************************************************* + ********************************************************************/ + +NTSTATUS _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HKCR *q_u, REG_R_OPEN_HKCR *r_u) +{ + return open_registry_key( p, &r_u->pol, NULL, KEY_HKCR, 0x0 ); } /******************************************************************* - reg_reply_open ********************************************************************/ NTSTATUS _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HKU *q_u, REG_R_OPEN_HKU *r_u) { - if (!open_registry_key(p, &r_u->pol, KEY_HKU, 0x0)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - - return NT_STATUS_OK; + return open_registry_key( p, &r_u->pol, NULL, KEY_HKU, 0x0 ); } /******************************************************************* @@ -546,9 +313,8 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR { POLICY_HND pol; fstring name; - pstring path; - int num_subkeys; - Registry_Key *key = find_regkey_index_by_hnd(p, &q_u->pol); + REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->pol); + NTSTATUS result; DEBUG(5,("reg_open_entry: Enter\n")); @@ -556,26 +322,14 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR return NT_STATUS_INVALID_HANDLE; rpcstr_pull(name,q_u->uni_name.buffer,sizeof(name),q_u->uni_name.uni_str_len*2,0); - - /* store the full path in the regkey_list */ - pstrcpy( path, key->name ); - pstrcat( path, "\\" ); - pstrcat( path, name ); - - DEBUG(5,("reg_open_entry: %s\n", path)); - - /* do a check on the name, here */ + DEBUG(5,("reg_open_entry: Enter\n")); + + result = open_registry_key( p, &pol, key, name, 0x0 ); - if ( (num_subkeys=fetch_reg_keys_count( tdb_reg, path )) == -1 ) - return NT_STATUS_ACCESS_DENIED; - - if (!open_registry_key(p, &pol, path, 0x0)) - return NT_STATUS_TOO_MANY_SECRETS; + init_reg_r_open_entry( r_u, &pol, result ); - init_reg_r_open_entry(r_u, &pol, NT_STATUS_OK); - - DEBUG(5,("reg_open_entry: Exitn")); + DEBUG(5,("reg_open_entry: Exit\n")); return r_u->status; } @@ -586,66 +340,85 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) { - NTSTATUS status = NT_STATUS_OK; - char *value = NULL; - uint32 type = 0x1; /* key type: REG_SZ */ - UNISTR2 *uni_key = NULL; - BUFFER2 *buf = NULL; - fstring name; - Registry_Key *key = find_regkey_index_by_hnd( p, &q_u->pol ); + NTSTATUS status = NT_STATUS_NO_SUCH_FILE; + fstring name; + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + REGISTRY_VALUE *val = NULL; + REGISTRY_VALUE emptyval; + REGVAL_CTR regvals; + int i; DEBUG(5,("_reg_info: Enter\n")); - if ( !key ) + if ( !regkey ) return NT_STATUS_INVALID_HANDLE; - DEBUG(7,("_reg_info: policy key name = [%s]\n", key->name)); - + DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); + rpcstr_pull(name, q_u->uni_type.buffer, sizeof(name), q_u->uni_type.uni_str_len*2, 0); - DEBUG(5,("reg_info: checking subkey: %s\n", name)); + DEBUG(5,("reg_info: looking up value: [%s]\n", name)); - uni_key = (UNISTR2 *)talloc_zero(p->mem_ctx, sizeof(UNISTR2)); - buf = (BUFFER2 *)talloc_zero(p->mem_ctx, sizeof(BUFFER2)); - - if (!uni_key || !buf) - return NT_STATUS_NO_MEMORY; + ZERO_STRUCTP( ®vals ); + + regval_ctr_init( ®vals ); + /* couple of hard coded registry values */ + if ( strequal(name, "RefusePasswordChange") ) { - type=0xF770; - status = NT_STATUS_NO_SUCH_FILE; - init_unistr2(uni_key, "", 0); - init_buffer2(buf, (uint8*) uni_key->buffer, uni_key->uni_str_len*2); - - buf->buf_max_len=4; + ZERO_STRUCTP( &emptyval ); + val = &emptyval; + + goto out; + } + if ( strequal(name, REGSTR_PRODUCTTYPE) ) { + /* This makes the server look like a member server to clients */ + /* which tells clients that we have our own local user and */ + /* group databases and helps with ACL support. */ + + switch (lp_server_role()) { + case ROLE_DOMAIN_PDC: + case ROLE_DOMAIN_BDC: + regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_LANMANNT, strlen(REG_PT_LANMANNT)+1 ); + break; + case ROLE_STANDALONE: + regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_SERVERNT, strlen(REG_PT_SERVERNT)+1 ); + break; + case ROLE_DOMAIN_MEMBER: + regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_WINNT, strlen(REG_PT_WINNT)+1 ); + break; + } + + val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); + + status = NT_STATUS_OK; + goto out; } - switch (lp_server_role()) { - case ROLE_DOMAIN_PDC: - case ROLE_DOMAIN_BDC: - value = "LanmanNT"; - break; - case ROLE_STANDALONE: - value = "ServerNT"; - break; - case ROLE_DOMAIN_MEMBER: - value = "WinNT"; + /* else fall back to actually looking up the value */ + + for ( i=0; fetch_reg_values_specific(regkey, &val, i); i++ ) + { + DEBUG(10,("_reg_info: Testing value [%s]\n", val->valuename)); + if ( StrCaseCmp( val->valuename, name ) == 0 ) { + DEBUG(10,("_reg_info: Found match for value [%s]\n", name)); + status = NT_STATUS_OK; break; + } + + free_registry_value( val ); } - /* This makes the server look like a member server to clients */ - /* which tells clients that we have our own local user and */ - /* group databases and helps with ACL support. */ - - init_unistr2(uni_key, value, strlen(value)+1); - init_buffer2(buf, (uint8*)uni_key->buffer, uni_key->uni_str_len*2); - out: - init_reg_r_info(q_u->ptr_buf, r_u, buf, type, status); +out: + new_init_reg_r_info(q_u->ptr_buf, r_u, val, status); + + regval_ctr_destroy( ®vals ); + free_registry_value( val ); - DEBUG(5,("reg_open_entry: Exit\n")); + DEBUG(5,("_reg_info: Exit\n")); return status; } @@ -658,7 +431,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) NTSTATUS _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_u) { NTSTATUS status = NT_STATUS_OK; - Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); DEBUG(5,("_reg_query_key: Enter\n")); @@ -670,6 +443,7 @@ NTSTATUS _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY * if ( !get_value_information( regkey, &r_u->num_values, &r_u->max_valnamelen, &r_u->max_valbufsize ) ) return NT_STATUS_ACCESS_DENIED; + r_u->sec_desc = 0x00000078; /* size for key's sec_desc */ @@ -691,7 +465,7 @@ NTSTATUS _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY * NTSTATUS _reg_unknown_1a(pipes_struct *p, REG_Q_UNKNOWN_1A *q_u, REG_R_UNKNOWN_1A *r_u) { NTSTATUS status = NT_STATUS_OK; - Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); DEBUG(5,("_reg_unknown_1a: Enter\n")); @@ -713,8 +487,8 @@ NTSTATUS _reg_unknown_1a(pipes_struct *p, REG_Q_UNKNOWN_1A *q_u, REG_R_UNKNOWN_1 NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u) { NTSTATUS status = NT_STATUS_OK; - Registry_Key *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - fstring subkey; + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + char *subkey = NULL; DEBUG(5,("_reg_enum_key: Enter\n")); @@ -724,9 +498,9 @@ NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", regkey->name)); - if ( !fetch_reg_keys_specific( tdb_reg, regkey->name, subkey, q_u->key_index ) ) + if ( !fetch_reg_keys_specific( regkey, &subkey, q_u->key_index ) ) { - status = werror_to_ntstatus( WERR_NO_MORE_ITEMS ); + status = NT_STATUS_NO_MORE_ENTRIES; goto done; } @@ -739,6 +513,46 @@ NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u DEBUG(5,("_reg_enum_key: Exit\n")); done: + SAFE_FREE( subkey ); + return status; +} + +/***************************************************************************** + Implementation of REG_ENUM_VALUE + ****************************************************************************/ + +NTSTATUS _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE *r_u) +{ + NTSTATUS status = NT_STATUS_OK; + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + REGISTRY_VALUE *val; + + + DEBUG(5,("_reg_enum_value: Enter\n")); + + if ( !regkey ) + return NT_STATUS_INVALID_HANDLE; + + DEBUG(8,("_reg_enum_key: enumerating values for key [%s]\n", regkey->name)); + + if ( !fetch_reg_values_specific( regkey, &val, q_u->val_index ) ) + { + status = NT_STATUS_NO_MORE_ENTRIES; + goto done; + } + + DEBUG(10,("_reg_enum_value: retrieved value named [%s]\n", val->valuename)); + + /* subkey has the string name now */ + + init_reg_r_enum_val( r_u, val ); + + + DEBUG(5,("_reg_enum_value: Exit\n")); + +done: + free_registry_value( val ); + return status; } @@ -808,4 +622,28 @@ NTSTATUS _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_A return status; } +/******************************************************************* + REG_SAVE_KEY (0x14) + ********************************************************************/ + +NTSTATUS _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) +{ + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + + DEBUG(5,("_reg_save_key: Enter\n")); + + /* + * basically this is a no op function which just gverifies + * that the client gave us a valid registry key handle + */ + + if ( !regkey ) + return NT_STATUS_INVALID_HANDLE; + + DEBUG(8,("_reg_save_key: berifying backup of key [%s]\n", regkey->name)); + + + return NT_STATUS_OK; +} + diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index f002a7d1c9..bc3b8970d6 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -3,9 +3,11 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Marc Jacobsen 1999. - * Copyright (C) Jean François Micouleau 1998-2001. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Marc Jacobsen 1999, + * Copyright (C) Jean François Micouleau 1998-2001, + * Copyright (C) Anthony Liguori 2002, + * Copyright (C) Jim McDonough 2002. * * Split into interface and implementation modules by, * @@ -652,6 +654,37 @@ static BOOL api_samr_connect(pipes_struct *p) return True; } +/******************************************************************* + api_samr_connect4 + ********************************************************************/ + +static BOOL api_samr_connect4(pipes_struct *p) +{ + SAMR_Q_CONNECT4 q_u; + SAMR_R_CONNECT4 r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the samr open policy */ + if(!samr_io_q_connect4("", &q_u, data, 0)) { + DEBUG(0,("api_samr_connect4: unable to unmarshall SAMR_Q_CONNECT4.\n")); + return False; + } + + r_u.status = _samr_connect4(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!samr_io_r_connect4("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_connect4: unable to marshall SAMR_R_CONNECT4.\n")); + return False; + } + + return True; +} + /********************************************************************** api_samr_lookup_domain **********************************************************************/ @@ -1465,6 +1498,7 @@ static struct api_struct api_samr_cmds [] = {"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, {"SAMR_UNKNOWN_2E" , SAMR_UNKNOWN_2E , api_samr_unknown_2e }, {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, + {"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 }, {NULL , 0 , NULL } }; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 88d728d810..a30622c600 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3,10 +3,12 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Marc Jacobsen 1999. - * Copyright (C) Jeremy Allison 2001-2002. - * Copyright (C) Jean François Micouleau 1998-2001. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Marc Jacobsen 1999, + * Copyright (C) Jeremy Allison 2001-2002, + * Copyright (C) Jean François Micouleau 1998-2001, + * Copyright (C) Anthony Liguori 2002, + * Copyright (C) Jim McDonough 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -727,8 +729,6 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UN } for (i = 0; i < num_entries; i++) { - int len = uni_temp_name.uni_str_len; - pwd = disp_user_info[i+start_idx].sam; temp_name = pdb_get_username(pwd); init_unistr2(&uni_temp_name, temp_name, strlen(temp_name)+1); @@ -743,7 +743,7 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UN return NT_STATUS_UNSUCCESSFUL; } - init_sam_entry(&sam[i], len, user_rid); + init_sam_entry(&sam[i], uni_temp_name.uni_str_len, user_rid); copy_unistr2(&uni_name[i], &uni_temp_name); } @@ -1081,7 +1081,9 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); /* the domain group array is being allocated in the function below */ - get_group_domain_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES); + if (!NT_STATUS_IS_OK(r_u->status = get_group_domain_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES))) { + return r_u->status; + } make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp); @@ -2081,6 +2083,8 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA time_t u_logout; NTTIME nt_logout; + uint32 account_policy_temp; + uint32 num_users=0, num_groups=0, num_aliases=0; if ((ctr = (SAM_UNK_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL) @@ -2098,12 +2102,22 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA switch (q_u->switch_value) { case 0x01: - account_policy_get(AP_MIN_PASSWORD_LEN, &min_pass_len); - account_policy_get(AP_PASSWORD_HISTORY, &pass_hist); - account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &flag); - account_policy_get(AP_MAX_PASSWORD_AGE, (int *)&u_expire); - account_policy_get(AP_MIN_PASSWORD_AGE, (int *)&u_min_age); + + account_policy_get(AP_MIN_PASSWORD_LEN, &account_policy_temp); + min_pass_len = account_policy_temp; + account_policy_get(AP_PASSWORD_HISTORY, &account_policy_temp); + pass_hist = account_policy_temp; + + account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); + flag = account_policy_temp; + + account_policy_get(AP_MAX_PASSWORD_AGE, &account_policy_temp); + u_expire = account_policy_temp; + + account_policy_get(AP_MIN_PASSWORD_AGE, &account_policy_temp); + u_min_age = account_policy_temp; + unix_to_nt_time_abs(&nt_expire, u_expire); unix_to_nt_time_abs(&nt_min_age, u_min_age); @@ -2149,10 +2163,15 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA init_unk_info7(&ctr->info.inf7); break; case 0x0c: - account_policy_get(AP_LOCK_ACCOUNT_DURATION, (int *)&u_lock_duration); - account_policy_get(AP_RESET_COUNT_TIME, (int *)&u_reset_time); - account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &lockout); - + account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); + u_lock_duration = account_policy_temp; + + account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp); + u_reset_time = account_policy_temp; + + account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); + lockout = account_policy_temp; + unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); unix_to_nt_time_abs(&nt_reset_time, u_reset_time); @@ -2344,7 +2363,8 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ } r_u->user_rid=pdb_get_user_rid(sam_pass); - r_u->unknown_0 = 0x000703ff; + + r_u->access_granted = acc_granted; pdb_free_sam(&sam_pass); @@ -2434,6 +2454,56 @@ NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u return r_u->status; } +/******************************************************************* + samr_connect4 + ********************************************************************/ + +NTSTATUS _samr_connect4(pipes_struct *p, SAMR_Q_CONNECT4 *q_u, SAMR_R_CONNECT4 *r_u) +{ + struct samr_info *info = NULL; + SEC_DESC *psd = NULL; + uint32 acc_granted; + uint32 des_access = q_u->access_mask; + size_t sd_size; + NTSTATUS nt_status; + + + DEBUG(5,("_samr_connect4: %d\n", __LINE__)); + + /* Access check */ + + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to samr_connect4\n")); + r_u->status = NT_STATUS_ACCESS_DENIED; + return r_u->status; + } + + samr_make_sam_obj_sd(p->mem_ctx, &psd, &sd_size); + se_map_generic(&des_access, &sam_generic_mapping); + if (!NT_STATUS_IS_OK(nt_status = + access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_connect"))) { + return nt_status; + } + + r_u->status = NT_STATUS_OK; + + /* associate the user's SID and access granted with the new handle. */ + if ((info = get_samr_info_by_sid(NULL)) == NULL) + return NT_STATUS_NO_MEMORY; + + info->acc_granted = acc_granted; + info->status = q_u->access_mask; + + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + DEBUG(5,("_samr_connect: %d\n", __LINE__)); + + return r_u->status; +} + /********************************************************************** api_samr_lookup_domain **********************************************************************/ @@ -4180,6 +4250,8 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW uint32 num_users=0, num_groups=0, num_aliases=0; + uint32 account_policy_temp; + if ((ctr = (SAM_UNK_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL) return NT_STATUS_NO_MEMORY; @@ -4195,11 +4267,20 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW switch (q_u->switch_value) { case 0x01: - account_policy_get(AP_MIN_PASSWORD_LEN, &min_pass_len); - account_policy_get(AP_PASSWORD_HISTORY, &pass_hist); - account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &flag); - account_policy_get(AP_MAX_PASSWORD_AGE, (int *)&u_expire); - account_policy_get(AP_MIN_PASSWORD_AGE, (int *)&u_min_age); + account_policy_get(AP_MIN_PASSWORD_LEN, &account_policy_temp); + min_pass_len = account_policy_temp; + + account_policy_get(AP_PASSWORD_HISTORY, &account_policy_temp); + pass_hist = account_policy_temp; + + account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); + flag = account_policy_temp; + + account_policy_get(AP_MAX_PASSWORD_AGE, &account_policy_temp); + u_expire = account_policy_temp; + + account_policy_get(AP_MIN_PASSWORD_AGE, &account_policy_temp); + u_min_age = account_policy_temp; unix_to_nt_time_abs(&nt_expire, u_expire); unix_to_nt_time_abs(&nt_min_age, u_min_age); @@ -4231,7 +4312,9 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW num_users, num_groups, num_aliases); break; case 0x03: - account_policy_get(AP_TIME_TO_LOGOUT, (int *)&u_logout); + account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); + u_logout = account_policy_temp; + unix_to_nt_time_abs(&nt_logout, u_logout); init_unk_info3(&ctr->info.inf3, nt_logout); @@ -4246,9 +4329,14 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW init_unk_info7(&ctr->info.inf7); break; case 0x0c: - account_policy_get(AP_LOCK_ACCOUNT_DURATION, (int *)&u_lock_duration); - account_policy_get(AP_RESET_COUNT_TIME, (int *)&u_reset_time); - account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &lockout); + account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); + u_lock_duration = account_policy_temp; + + account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp); + u_reset_time = account_policy_temp; + + account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); + lockout = account_policy_temp; unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); unix_to_nt_time_abs(&nt_reset_time, u_reset_time); diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 6e3463e79b..5924c5831b 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1515,6 +1515,65 @@ static BOOL api_spoolss_deleteprinterdriverex(pipes_struct *p) return True; } +#if 0 + +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_replyopenprinter(pipes_struct *p) +{ + SPOOL_Q_REPLYOPENPRINTER q_u; + SPOOL_R_REPLYOPENPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_replyopenprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_replyopenprinter: unable to unmarshall SPOOL_Q_REPLYOPENPRINTER.\n")); + return False; + } + + r_u.status = _spoolss_replyopenprinter(p, &q_u, &r_u); + + if(!spoolss_io_r_replyopenprinter("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_replyopenprinter: unable to marshall SPOOL_R_REPLYOPENPRINTER.\n")); + return False; + } + + return True; +} + +/**************************************************************************** +****************************************************************************/ + +static BOOL api_spoolss_replycloseprinter(pipes_struct *p) +{ + SPOOL_Q_REPLYCLOSEPRINTER q_u; + SPOOL_R_REPLYCLOSEPRINTER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!spoolss_io_q_replycloseprinter("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_replycloseprinter: unable to unmarshall SPOOL_Q_REPLYCLOSEPRINTER.\n")); + return False; + } + + r_u.status = _spoolss_replycloseprinter(p, &q_u, &r_u); + + if(!spoolss_io_r_replycloseprinter("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_replycloseprinter: unable to marshall SPOOL_R_REPLYCLOSEPRINTER.\n")); + return False; + } + + return True; +} + +#endif /******************************************************************* \pipe\spoolss commands @@ -1573,6 +1632,10 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory}, {"SPOOLSS_ADDPRINTERDRIVEREX", SPOOLSS_ADDPRINTERDRIVEREX, api_spoolss_addprinterdriverex }, {"SPOOLSS_DELETEPRINTERDRIVEREX", SPOOLSS_DELETEPRINTERDRIVEREX, api_spoolss_deleteprinterdriverex }, +#if 0 + {"SPOOLSS_REPLYOPENPRINTER", SPOOLSS_REPLYOPENPRINTER, api_spoolss_replyopenprinter }, + {"SPOOLSS_REPLYCLOSEPRINTER", SPOOLSS_REPLYCLOSEPRINTER, api_spoolss_replycloseprinter }, +#endif { NULL, 0, NULL } }; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 68c792f8b0..7aceaa548f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -65,7 +65,7 @@ typedef struct _Printer{ struct _Printer *prev, *next; BOOL document_started; BOOL page_started; - int jobid; /* jobid in printing backend */ + uint32 jobid; /* jobid in printing backend */ BOOL printer_type; union { fstring handlename; @@ -101,7 +101,7 @@ typedef struct _counter_printer_0 { static ubi_dlList counter_list; -static struct cli_state cli; +static struct cli_state notify_cli; /* print notify back-channel */ static uint32 smb_connections=0; @@ -184,7 +184,7 @@ static void srv_spoolss_replycloseprinter(POLICY_HND *handle) return; } - result = cli_spoolss_reply_close_printer(&cli, cli.mem_ctx, handle); + result = cli_spoolss_reply_close_printer(¬ify_cli, notify_cli.mem_ctx, handle); if (!W_ERROR_IS_OK(result)) DEBUG(0,("srv_spoolss_replycloseprinter: reply_close_printer failed [%s].\n", @@ -192,9 +192,9 @@ static void srv_spoolss_replycloseprinter(POLICY_HND *handle) /* if it's the last connection, deconnect the IPC$ share */ if (smb_connections==1) { - cli_nt_session_close(&cli); - cli_ulogoff(&cli); - cli_shutdown(&cli); + cli_nt_session_close(¬ify_cli); + cli_ulogoff(¬ify_cli); + cli_shutdown(¬ify_cli); message_deregister(MSG_PRINTER_NOTIFY2); } @@ -668,21 +668,21 @@ struct notify2_message_table { }; static struct notify2_message_table printer_notify_table[] = { - /* 0x00 */ { "PRINTER_NOTIFY_SERVER_NAME", NULL }, - /* 0x01 */ { "PRINTER_NOTIFY_PRINTER_NAME", NULL }, - /* 0x02 */ { "PRINTER_NOTIFY_SHARE_NAME", NULL }, - /* 0x03 */ { "PRINTER_NOTIFY_PORT_NAME", NULL }, - /* 0x04 */ { "PRINTER_NOTIFY_DRIVER_NAME", NULL }, - /* 0x05 */ { "PRINTER_NOTIFY_COMMENT", NULL }, - /* 0x06 */ { "PRINTER_NOTIFY_LOCATION", NULL }, + /* 0x00 */ { "PRINTER_NOTIFY_SERVER_NAME", notify_string }, + /* 0x01 */ { "PRINTER_NOTIFY_PRINTER_NAME", notify_string }, + /* 0x02 */ { "PRINTER_NOTIFY_SHARE_NAME", notify_string }, + /* 0x03 */ { "PRINTER_NOTIFY_PORT_NAME", notify_string }, + /* 0x04 */ { "PRINTER_NOTIFY_DRIVER_NAME", notify_string }, + /* 0x05 */ { "PRINTER_NOTIFY_COMMENT", notify_string }, + /* 0x06 */ { "PRINTER_NOTIFY_LOCATION", notify_string }, /* 0x07 */ { "PRINTER_NOTIFY_DEVMODE", NULL }, - /* 0x08 */ { "PRINTER_NOTIFY_SEPFILE", NULL }, - /* 0x09 */ { "PRINTER_NOTIFY_PRINT_PROCESSOR", NULL }, + /* 0x08 */ { "PRINTER_NOTIFY_SEPFILE", notify_string }, + /* 0x09 */ { "PRINTER_NOTIFY_PRINT_PROCESSOR", notify_string }, /* 0x0a */ { "PRINTER_NOTIFY_PARAMETERS", NULL }, - /* 0x0b */ { "PRINTER_NOTIFY_DATATYPE", NULL }, + /* 0x0b */ { "PRINTER_NOTIFY_DATATYPE", notify_string }, /* 0x0c */ { "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", NULL }, - /* 0x0d */ { "PRINTER_NOTIFY_ATTRIBUTES", NULL }, - /* 0x0e */ { "PRINTER_NOTIFY_PRIORITY", NULL }, + /* 0x0d */ { "PRINTER_NOTIFY_ATTRIBUTES", notify_one_value }, + /* 0x0e */ { "PRINTER_NOTIFY_PRIORITY", notify_one_value }, /* 0x0f */ { "PRINTER_NOTIFY_DEFAULT_PRIORITY", NULL }, /* 0x10 */ { "PRINTER_NOTIFY_START_TIME", NULL }, /* 0x11 */ { "PRINTER_NOTIFY_UNTIL_TIME", NULL }, @@ -726,6 +726,8 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, { Printer_entry *p; + DEBUG(8,("process_notify2_message: Enter...[%s]\n", msg->printer)); + for (p = printers_list; p; p = p->next) { SPOOL_NOTIFY_INFO_DATA *data; uint32 data_len = 1; @@ -736,28 +738,52 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, if (!p->notify.client_connected) continue; + DEBUG(10,("Client connected! [%s]\n", p->dev.handlename)); + /* For this printer? Print servers always receive notifications. */ - if (p->printer_type == PRINTER_HANDLE_IS_PRINTER && - !strequal(msg->printer, p->dev.handlename)) + if ( ( p->printer_type == PRINTER_HANDLE_IS_PRINTER ) && + ( !strequal(msg->printer, p->dev.handlename) ) ) continue; + DEBUG(10,("Our printer\n")); + /* Are we monitoring this event? */ if (!is_monitoring_event(p, msg->type, msg->field)) continue; + DEBUG(10,("process_notify2_message: Sending message type [%x] field [%x] for printer [%s]\n", + msg->type, msg->field, p->dev.handlename)); + /* OK - send the event to the client */ data = talloc(mem_ctx, sizeof(SPOOL_NOTIFY_INFO_DATA)); ZERO_STRUCTP(data); - /* Convert unix jobid to smb jobid */ + /* + * if the is a printer notification handle and not a job notification + * type, then set the id to 0. Other wise just use what was specified + * in the message. + * + * When registering change notification on a print server handle + * we always need to send back the id (snum) matching the printer + * for which the change took place. For change notify registered + * on a printer handle, this does not matter and the id should be 0. + * + * --jerry + */ + if ( ( p->printer_type == PRINTER_HANDLE_IS_PRINTER ) && ( msg->type == PRINTER_NOTIFY_TYPE ) ) + id = 0; + else id = msg->id; + + /* Convert unix jobid to smb jobid */ + if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) { id = sysjob_to_jobid(msg->id); @@ -772,51 +798,31 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, switch(msg->type) { case PRINTER_NOTIFY_TYPE: - if (printer_notify_table[msg->field].fn) - printer_notify_table[msg->field].fn( - msg, data, mem_ctx); - else + if ( !printer_notify_table[msg->field].fn ) goto done; + + printer_notify_table[msg->field].fn(msg, data, mem_ctx); + break; + case JOB_NOTIFY_TYPE: - if (job_notify_table[msg->field].fn) - job_notify_table[msg->field].fn( - msg, data, mem_ctx); - else + if ( !job_notify_table[msg->field].fn ) goto done; - break; - default: - DEBUG(5, ("Unknown notification type %d\n", - msg->type)); - goto done; - } - if (!p->notify.flags) - cli_spoolss_rrpcn( - &cli, mem_ctx, &p->notify.client_hnd, - data_len, data, p->notify.change, 0); - else { - NT_PRINTER_INFO_LEVEL *printer = NULL; + job_notify_table[msg->field].fn(msg, data, mem_ctx); - get_a_printer(&printer, 2, msg->printer); + break; - if (!printer) { - DEBUG(5, ("unable to load info2 for %s\n", - msg->printer)); + default: + DEBUG(5, ("Unknown notification type %d\n", msg->type)); goto done; } - /* XXX: This needs to be updated for - PRINTER_CHANGE_SET_PRINTER_DRIVER. */ - - cli_spoolss_routerreplyprinter( - &cli, mem_ctx, &p->notify.client_hnd, - 0, printer->info_2->changeid); - - free_a_printer(&printer, 2); - } + cli_spoolss_rrpcn( ¬ify_cli, mem_ctx, &p->notify.client_hnd, + data_len, data, p->notify.change, 0 ); } done: + DEBUG(8,("process_notify2_message: Exit...\n")); return; } @@ -867,30 +873,6 @@ static void receive_notify2_message(int msg_type, pid_t src, void *buf, talloc_destroy(mem_ctx); } -/*************************************************************************** - Server wrapper for cli_spoolss_routerreplyprinter() since the client - function can only send a single change notification at a time. - - FIXME!!! only handles one change currently (PRINTER_CHANGE_SET_PRINTER_DRIVER) - --jerry - **************************************************************************/ - -static WERROR srv_spoolss_routerreplyprinter (struct cli_state *reply_cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, PRINTER_MESSAGE_INFO *info, - NT_PRINTER_INFO_LEVEL *printer) -{ - WERROR result; - uint32 condition = 0x0; - - if (info->flags & PRINTER_MESSAGE_DRIVER) - condition = PRINTER_CHANGE_SET_PRINTER_DRIVER; - - result = cli_spoolss_routerreplyprinter(reply_cli, mem_ctx, pol, condition, - printer->info_2->changeid); - - return result; -} - /******************************************************************** Send a message to ourself about new driver being installed so we can upgrade the information for each printer bound to this @@ -961,6 +943,80 @@ void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) /* all done */ } +/******************************************************************** + Send a message to ourself about new driver being installed + so we can upgrade the information for each printer bound to this + driver + ********************************************************************/ + +static BOOL srv_spoolss_reset_printerdata(char* drivername) +{ + int len = strlen(drivername); + + if (!len) + return False; + + DEBUG(10,("srv_spoolss_reset_printerdata: Sending message about resetting printerdata [%s]\n", + drivername)); + + message_send_pid(sys_getpid(), MSG_PRINTERDATA_INIT_RESET, drivername, len+1, False); + + return True; +} + +/********************************************************************** + callback to receive a MSG_PRINTERDATA_INIT_RESET message and interate + over all printers, resetting printer data as neessary + **********************************************************************/ + +void reset_all_printerdata(int msg_type, pid_t src, void *buf, size_t len) +{ + fstring drivername; + int snum; + int n_services = lp_numservices(); + + len = MIN( len, sizeof(drivername)-1 ); + strncpy( drivername, buf, len ); + + DEBUG(10,("reset_all_printerdata: Got message for new driver [%s]\n", drivername )); + + /* Iterate the printer list */ + + for ( snum=0; snuminfo_2 && !strcmp(drivername, printer->info_2->drivername) ) + { + DEBUG(6,("reset_all_printerdata: Updating printer [%s]\n", printer->info_2->printername)); + + if ( !set_driver_init(printer, 2) ) { + DEBUG(5,("reset_all_printerdata: Error resetting printer data for printer [%s], driver [%s]!\n", + printer->info_2->printername, printer->info_2->drivername)); + } + } + + free_a_printer( &printer, 2 ); + } + } + + /* all done */ + + return; +} + /******************************************************************** Copy routines used by convert_to_openprinterex() *******************************************************************/ @@ -1094,8 +1150,6 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, { UNISTR2 *printername = NULL; PRINTER_DEFAULT *printer_default = &q_u->printer_default; -/* uint32 user_switch = q_u->user_switch; - notused */ -/* SPOOL_USER_CTR user_ctr = q_u->user_ctr; - notused */ POLICY_HND *handle = &r_u->handle; fstring name; @@ -1443,14 +1497,18 @@ BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, static WERROR _spoolss_enddocprinter_internal(pipes_struct *p, POLICY_HND *handle) { Printer_entry *Printer=find_printer_index_by_hnd(p, handle); - + int snum; + if (!Printer) { DEBUG(2,("_spoolss_enddocprinter_internal: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle))); return WERR_BADFID; } + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + Printer->document_started=False; - print_job_end(Printer->jobid,True); + print_job_end(snum, Printer->jobid,True); /* error codes unhandled so far ... */ return WERR_OK; @@ -1740,51 +1798,56 @@ static BOOL getprinterdata_printer(pipes_struct *p, TALLOC_CTX *ctx, POLICY_HND uint8 **data, uint32 *needed, uint32 in_size ) { NT_PRINTER_INFO_LEVEL *printer = NULL; - int snum=0; - uint8 *idata=NULL; - uint32 len; - Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + int snum=0; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + REGISTRY_VALUE *val; + int size = 0; DEBUG(5,("getprinterdata_printer\n")); - if (!Printer) { + if ( !Printer ) { DEBUG(2,("getprinterdata_printer: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return False; } - if(!get_printer_snum(p, handle, &snum)) + if ( !get_printer_snum(p, handle, &snum) ) return False; - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) + if ( !W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum))) ) return False; - if (!get_specific_param(*printer, 2, value, &idata, type, &len)) { + if ( !(val = get_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, value)) ) + { free_a_printer(&printer, 2); return False; } + + *type = regval_type( val ); - free_a_printer(&printer, 2); DEBUG(5,("getprinterdata_printer:allocating %d\n", in_size)); - if (in_size) { - if((*data = (uint8 *)talloc(ctx, in_size *sizeof(uint8) )) == NULL) { + if (in_size) + { + if ( (*data = (uint8 *)talloc(ctx, in_size * sizeof(uint8))) == NULL ) return False; - } - memset(*data, 0, in_size *sizeof(uint8)); + memset( *data, 0, in_size *sizeof(uint8) ); + /* copy the min(in_size, len) */ - memcpy(*data, idata, (len>in_size)?in_size:len *sizeof(uint8)); - } else { - *data = NULL; + + size = regval_size( val ); + memcpy( *data, regval_data_p(val), (size > in_size) ? in_size : size*sizeof(uint8) ); } + else + *data = NULL; - *needed = len; + *needed = size; DEBUG(5,("getprinterdata_printer:copy done\n")); - SAFE_FREE(idata); + free_a_printer(&printer, 2); return True; } @@ -1813,11 +1876,12 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO * JFM, 4/19/1999 */ - *out_size=in_size; + *out_size = in_size; /* in case of problem, return some default values */ - *needed=0; - *type=0; + + *needed = 0; + *type = 0; DEBUG(4,("_spoolss_getprinterdata\n")); @@ -1831,13 +1895,16 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO unistr2_to_ascii(value, valuename, sizeof(value)-1); if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) - found=getprinterdata_printer_server(p->mem_ctx, value, type, data, needed, *out_size); + found = getprinterdata_printer_server(p->mem_ctx, value, type, data, needed, *out_size); else - found= getprinterdata_printer(p, p->mem_ctx, handle, value, type, data, needed, *out_size); + found = getprinterdata_printer(p, p->mem_ctx, handle, value, type, data, needed, *out_size); - if (found==False) { + if ( !found ) + { DEBUG(5, ("value not found, allocating %d\n", *out_size)); + /* reply this param doesn't exist */ + if (*out_size) { if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) return WERR_NOMEM; @@ -1966,7 +2033,7 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin fstrcpy(unix_printer, printer+2); /* the +2 is to strip the leading 2 backslashs */ - if(!spoolss_connect_to_client(&cli, unix_printer)) + if(!spoolss_connect_to_client(¬ify_cli, unix_printer)) return False; message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message); @@ -1974,7 +2041,7 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin smb_connections++; - result = cli_spoolss_reply_open_printer(&cli, cli.mem_ctx, printer, localprinter, + result = cli_spoolss_reply_open_printer(¬ify_cli, notify_cli.mem_ctx, printer, localprinter, type, handle); if (!W_ERROR_IS_OK(result)) @@ -2749,7 +2816,7 @@ struct s_notify_info_data_table notify_info_data_table[] = { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINT_PROCESSOR, "PRINTER_NOTIFY_PRINT_PROCESSOR", NOTIFY_STRING, spoolss_notify_print_processor }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PARAMETERS, "PRINTER_NOTIFY_PARAMETERS", NOTIFY_STRING, spoolss_notify_parameters }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DATATYPE, "PRINTER_NOTIFY_DATATYPE", NOTIFY_STRING, spoolss_notify_datatype }, -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SECURITY_DESCRIPTOR, "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", NOTIFY_POINTER, spoolss_notify_security_desc }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SECURITY_DESCRIPTOR, "PRINTER_NOTIFY_SECURITY_DESCRIPTOR", NOTIFY_SECDESC, spoolss_notify_security_desc }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_ATTRIBUTES, "PRINTER_NOTIFY_ATTRIBUTES", NOTIFY_ONE_VALUE, spoolss_notify_attributes }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRIORITY, "PRINTER_NOTIFY_PRIORITY", NOTIFY_ONE_VALUE, spoolss_notify_priority }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DEFAULT_PRIORITY, "PRINTER_NOTIFY_DEFAULT_PRIORITY", NOTIFY_ONE_VALUE, spoolss_notify_default_priority }, @@ -2796,10 +2863,13 @@ static uint32 size_of_notify_info_data(uint16 type, uint16 field) { int i=0; - for (i = 0; i < sizeof(notify_info_data_table); i++) { - if (notify_info_data_table[i].type == type && - notify_info_data_table[i].field == field) { - switch(notify_info_data_table[i].size) { + for (i = 0; i < sizeof(notify_info_data_table); i++) + { + if ( (notify_info_data_table[i].type == type) + && (notify_info_data_table[i].field == field) ) + { + switch(notify_info_data_table[i].size) + { case NOTIFY_ONE_VALUE: case NOTIFY_TWO_VALUE: return 1; @@ -2812,6 +2882,9 @@ static uint32 size_of_notify_info_data(uint16 type, uint16 field) case NOTIFY_POINTER: return 4; + + case NOTIFY_SECDESC: + return 5; } } } @@ -2866,13 +2939,11 @@ void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 info_data->field = field; info_data->reserved = 0; - if (type == JOB_NOTIFY_TYPE) - info_data->id = id; - else - info_data->id = 0; - info_data->size = size_of_notify_info_data(type, field); info_data->enc_type = type_of_notify_info_data(type, field); + + info_data->id = id; + } @@ -2904,20 +2975,24 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) return False; - for(field_num=0; field_numcount; field_num++) { + for(field_num=0; field_numcount; field_num++) + { field = option_type->fields[field_num]; + DEBUG(4,("construct_notify_printer_info: notify [%d]: type [%x], field [%x]\n", field_num, type, field)); if (!search_notify(type, field, &j) ) continue; - if((tid=(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(2,("construct_notify_printer_info: failed to enlarge buffer info->data!\n")); return False; } - else info->data = tid; + else + info->data = tid; - current_data=&info->data[info->count]; + current_data = &info->data[info->count]; construct_info_data(current_data, type, field, id); @@ -3044,16 +3119,17 @@ static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, continue; for (snum=0; snumversion:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); DEBUGADD(1,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); @@ -3063,7 +3139,7 @@ static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, i, info->data[i].type, info->data[i].field, info->data[i].reserved, info->data[i].id, info->data[i].size, info->data[i].enc_type)); } - */ +#endif return WERR_OK; } @@ -3161,7 +3237,6 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCNEX *r_u) { POLICY_HND *handle = &q_u->handle; -/* SPOOL_NOTIFY_OPTION *option = q_u->option; - notused. */ SPOOL_NOTIFY_INFO *info = &r_u->info; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); @@ -3188,8 +3263,10 @@ WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN /* We need to keep track of the change value to send back in RRPCN replies otherwise our updates are ignored. */ - if (Printer->notify.client_connected) + if (Printer->notify.client_connected) { + DEBUG(10,("_spoolss_rfnpcnex: Saving change value in request [%x]\n", q_u->change)); Printer->notify.change = q_u->change; + } /* just ignore the SPOOL_NOTIFY_OPTION */ @@ -3370,7 +3447,7 @@ static void free_dev_mode(DEVICEMODE *dev) Create a DEVMODE struct. Returns malloced memory. ****************************************************************************/ -static DEVICEMODE *construct_dev_mode(int snum) +DEVICEMODE *construct_dev_mode(int snum) { char adevice[32]; char aform[32]; @@ -4318,22 +4395,29 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser DEBUG(6,("init_unistr_array\n")); *uni_array=NULL; - while (1) { + while (True) + { if (char_array == NULL) v = ""; else { v = char_array[i]; if (!v) v = ""; /* hack to handle null lists */ } - if (strlen(v) == 0) break; + + if ( !strlen(v) ) + break; + slprintf(line, sizeof(line)-1, "\\\\%s%s", servername, v); + DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); + if((tuary=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL) { DEBUG(2,("init_unistr_array: Realloc error\n" )); return; } else *uni_array = tuary; - j += (rpcstr_push((*uni_array+j), line, sizeof(uint16)*strlen(line)+2, 0)/ sizeof(uint16)); + + j += (rpcstr_push((*uni_array+j), line, sizeof(uint16)*strlen(line)+2, STR_TERMINATE) / sizeof(uint16)); i++; } @@ -4495,8 +4579,8 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->monitorname, driver.info_3->monitorname ); init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype ); - info->dependentfiles=NULL; - init_unistr_array(&info->dependentfiles, driver.info_3->dependentfiles, servername); + info->dependentfiles = NULL; + init_unistr_array( &info->dependentfiles, driver.info_3->dependentfiles, servername ); info->previousdrivernames=NULL; init_unistr_array(&info->previousdrivernames, &nullstr, servername); @@ -4519,21 +4603,28 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN * fill a printer_info_6 struct ********************************************************************/ -static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fstring servername, fstring architecture, uint32 version) +static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, + fstring servername, fstring architecture, uint32 version) { - NT_PRINTER_INFO_LEVEL *printer = NULL; - NT_PRINTER_DRIVER_INFO_LEVEL driver; - WERROR status; + NT_PRINTER_INFO_LEVEL *printer = NULL; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + WERROR status; + ZERO_STRUCT(driver); status=get_a_printer(&printer, 2, lp_servicename(snum) ); + DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status))); + if (!W_ERROR_IS_OK(status)) return WERR_INVALID_PRINTER_NAME; - status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); + status = get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); + DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status))); - if (!W_ERROR_IS_OK(status)) { + + if (!W_ERROR_IS_OK(status)) + { /* * Is this a W2k client ? */ @@ -4728,7 +4819,6 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ UNISTR2 *uni_arch = &q_u->architecture; uint32 level = q_u->level; uint32 clientmajorversion = q_u->clientmajorversion; -/* uint32 clientminorversion = q_u->clientminorversion; - notused. */ NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; @@ -4745,9 +4835,9 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ DEBUG(4,("_spoolss_getprinterdriver2\n")); - *needed=0; - *servermajorversion=0; - *serverminorversion=0; + *needed = 0; + *servermajorversion = 0; + *serverminorversion = 0; pstrcpy(servername, get_called_name()); unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); @@ -4793,6 +4883,7 @@ WERROR _spoolss_startpageprinter(pipes_struct *p, SPOOL_Q_STARTPAGEPRINTER *q_u, WERROR _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPOOL_R_ENDPAGEPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; + int snum; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); @@ -4801,8 +4892,11 @@ WERROR _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPO return WERR_BADFID; } + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + Printer->page_started=False; - print_job_endpage(Printer->jobid); + print_job_endpage(snum, Printer->jobid); return WERR_OK; } @@ -4816,7 +4910,6 @@ WERROR _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPO WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, SPOOL_R_STARTDOCPRINTER *r_u) { POLICY_HND *handle = &q_u->handle; -/* uint32 level = q_u->doc_info_container.level; - notused. */ DOC_INFO *docinfo = &q_u->doc_info_container.docinfo; uint32 *jobid = &r_u->jobid; @@ -4898,7 +4991,7 @@ WERROR _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R uint32 buffer_size = q_u->buffer_size; uint8 *buffer = q_u->buffer; uint32 *buffer_written = &q_u->buffer_size2; - + int snum; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); if (!Printer) { @@ -4907,8 +5000,10 @@ WERROR _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R return WERR_BADFID; } - (*buffer_written) = print_job_write(Printer->jobid, (char *)buffer, buffer_size); + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + (*buffer_written) = print_job_write(snum, Printer->jobid, (char *)buffer, buffer_size); r_u->buffer_written = q_u->buffer_size2; @@ -5147,254 +5242,6 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) return True; } -#if 0 /* JERRY */ - -/* Return true if two devicemodes are equal */ - -#define DEVMODE_CHECK_INT(field) \ - if (d1->field != d2->field) { \ - DEBUG(10, ("nt_devicemode_equal(): " #field " not equal (%d != %d)\n", \ - d1->field, d2->field)); \ - return False; \ - } - -/************************************************************************ - Handy, but currently unused functions - ***********************************************************************/ - -static BOOL nt_devicemode_equal(NT_DEVICEMODE *d1, NT_DEVICEMODE *d2) -{ - if (!d1 && !d2) goto equal; /* if both are NULL they are equal */ - - if (!d1 ^ !d2) { - DEBUG(10, ("nt_devicemode_equal(): pointers not equal\n")); - return False; /* if either is exclusively NULL are not equal */ - } - - if (!strequal(d1->devicename, d2->devicename)) { - DEBUG(10, ("nt_devicemode_equal(): device not equal (%s != %s)\n", d1->devicename, d2->devicename)); - return False; - } - - if (!strequal(d1->formname, d2->formname)) { - DEBUG(10, ("nt_devicemode_equal(): formname not equal (%s != %s)\n", d1->formname, d2->formname)); - return False; - } - - DEVMODE_CHECK_INT(specversion); - DEVMODE_CHECK_INT(driverversion); - DEVMODE_CHECK_INT(driverextra); - DEVMODE_CHECK_INT(orientation); - DEVMODE_CHECK_INT(papersize); - DEVMODE_CHECK_INT(paperlength); - DEVMODE_CHECK_INT(paperwidth); - DEVMODE_CHECK_INT(scale); - DEVMODE_CHECK_INT(copies); - DEVMODE_CHECK_INT(defaultsource); - DEVMODE_CHECK_INT(printquality); - DEVMODE_CHECK_INT(color); - DEVMODE_CHECK_INT(duplex); - DEVMODE_CHECK_INT(yresolution); - DEVMODE_CHECK_INT(ttoption); - DEVMODE_CHECK_INT(collate); - DEVMODE_CHECK_INT(logpixels); - - DEVMODE_CHECK_INT(fields); - DEVMODE_CHECK_INT(bitsperpel); - DEVMODE_CHECK_INT(pelswidth); - DEVMODE_CHECK_INT(pelsheight); - DEVMODE_CHECK_INT(displayflags); - DEVMODE_CHECK_INT(displayfrequency); - DEVMODE_CHECK_INT(icmmethod); - DEVMODE_CHECK_INT(icmintent); - DEVMODE_CHECK_INT(mediatype); - DEVMODE_CHECK_INT(dithertype); - DEVMODE_CHECK_INT(reserved1); - DEVMODE_CHECK_INT(reserved2); - DEVMODE_CHECK_INT(panningwidth); - DEVMODE_CHECK_INT(panningheight); - - /* compare the private data if it exists */ - if (!d1->driverextra && !d2->driverextra) goto equal; - - - DEVMODE_CHECK_INT(driverextra); - - if (memcmp(d1->private, d2->private, d1->driverextra)) { - DEBUG(10, ("nt_devicemode_equal(): private data not equal\n")); - return False; - } - - equal: - DEBUG(10, ("nt_devicemode_equal(): devicemodes identical\n")); - return True; -} - -/* Return true if two NT_PRINTER_PARAM structures are equal */ - -static BOOL nt_printer_param_equal(NT_PRINTER_PARAM *p1, - NT_PRINTER_PARAM *p2) -{ - if (!p1 && !p2) goto equal; - - if ((!p1 && p2) || (p1 && !p2)) { - DEBUG(10, ("nt_printer_param_equal(): pointers differ\n")); - return False; - } - - /* Compare lists of printer parameters */ - - while (p1) { - BOOL found = False; - NT_PRINTER_PARAM *q = p1; - - /* Find the parameter in the second structure */ - - while(q) { - - if (strequal(p1->value, q->value)) { - - if (p1->type != q->type) { - DEBUG(10, ("nt_printer_param_equal():" - "types for %s differ (%d != %d)\n", - p1->value, p1->type, - q->type)); - break; - } - - if (p1->data_len != q->data_len) { - DEBUG(10, ("nt_printer_param_equal():" - "len for %s differs (%d != %d)\n", - p1->value, p1->data_len, - q->data_len)); - break; - } - - if (memcmp(p1->data, q->data, p1->data_len) == 0) { - found = True; - } else { - DEBUG(10, ("nt_printer_param_equal():" - "data for %s differs\n", p1->value)); - } - - break; - } - - q = q->next; - } - - if (!found) { - DEBUG(10, ("nt_printer_param_equal(): param %s " - "does not exist\n", p1->value)); - return False; - } - - p1 = p1->next; - } - - equal: - - DEBUG(10, ("nt_printer_param_equal(): printer params identical\n")); - return True; -} - -/******************************************************************** - * Called by update_printer when trying to work out whether to - * actually update printer info. - ********************************************************************/ - -#define PI_CHECK_INT(field) \ - if (pi1->field != pi2->field) { \ - DEBUG(10, ("nt_printer_info_level_equal(): " #field " not equal (%d != %d)\n", \ - pi1->field, pi2->field)); \ - return False; \ - } - -#define PI_CHECK_STR(field) \ - if (!strequal(pi1->field, pi2->field)) { \ - DEBUG(10, ("nt_printer_info_level_equal(): " #field " not equal (%s != %s)\n", \ - pi1->field, pi2->field)); \ - return False; \ - } - -static BOOL nt_printer_info_level_equal(NT_PRINTER_INFO_LEVEL *p1, - NT_PRINTER_INFO_LEVEL *p2) -{ - NT_PRINTER_INFO_LEVEL_2 *pi1, *pi2; - - /* Trivial conditions */ - - if ((!p1 && !p2) || (!p1->info_2 && !p2->info_2)) { - goto equal; - } - - if ((!p1 && p2) || (p1 && !p2) || - (!p1->info_2 && p2->info_2) || - (p1->info_2 && !p2->info_2)) { - DEBUG(10, ("nt_printer_info_level_equal(): info levels " - "differ\n")); - return False; - } - - /* Compare two nt_printer_info_level structures. Don't compare - status or cjobs as they seem to have something to do with the - printer queue. */ - - pi1 = p1->info_2; - pi2 = p2->info_2; - - /* Don't check the attributes as we stomp on the value in - check_printer_ok() anyway. */ - -#if 0 - PI_CHECK_INT(attributes); -#endif - - PI_CHECK_INT(priority); - PI_CHECK_INT(default_priority); - PI_CHECK_INT(starttime); - PI_CHECK_INT(untiltime); - PI_CHECK_INT(averageppm); - - /* Yuck - don't check the printername or servername as the - mod_a_printer() code plays games with them. You can't - change the printername or the sharename through this interface - in Samba. */ - - PI_CHECK_STR(sharename); - PI_CHECK_STR(portname); - PI_CHECK_STR(drivername); - PI_CHECK_STR(comment); - PI_CHECK_STR(location); - - if (!nt_devicemode_equal(pi1->devmode, pi2->devmode)) { - return False; - } - - PI_CHECK_STR(sepfile); - PI_CHECK_STR(printprocessor); - PI_CHECK_STR(datatype); - PI_CHECK_STR(parameters); - - if (!nt_printer_param_equal(pi1->specific, pi2->specific)) { - return False; - } - - if (!sec_desc_equal(pi1->secdesc_buf->sec, pi2->secdesc_buf->sec)) { - return False; - } - - PI_CHECK_INT(changeid); - PI_CHECK_INT(c_setprinter); - PI_CHECK_INT(setuptime); - - equal: - DEBUG(10, ("nt_printer_info_level_equal(): infos are identical\n")); - return True; -} - -#endif - /******************************************************************** * Called by spoolss_api_setprinter * when updating a printer description. @@ -5507,7 +5354,8 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, * requires Win32 client code (see other notes elsewhere in the code). */ if (printer->info_2->devmode && - printer->info_2->devmode->displayfrequency == MAGIC_DISPLAY_FREQUENCY) { + printer->info_2->devmode->displayfrequency == MAGIC_DISPLAY_FREQUENCY) + { DEBUG(10,("update_printer: Save printer driver init data\n")); printer->info_2->devmode->displayfrequency = 0; @@ -5517,17 +5365,31 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, result = WERR_ACCESS_DENIED; goto done; } - } else { + + /* we need to reset all driver init data for all printers + bound to this driver */ + + srv_spoolss_reset_printerdata( printer->info_2->drivername ); + + } + else + { /* * When a *new* driver is bound to a printer, the drivername is used to * lookup previously saved driver initialization info, which is then * bound to the printer, simulating what happens in the Windows arch. */ - if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)){ - if (!set_driver_init(printer, 2)) { + if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)) + { + if (!set_driver_init(printer, 2)) + { DEBUG(5,("update_printer: Error restoring driver initialization data for driver [%s]!\n", printer->info_2->drivername)); } + + DEBUG(10,("update_printer: changing driver [%s]! Sending event!\n", + printer->info_2->drivername)); + notify_printer_driver(snum, printer->info_2->drivername); } } @@ -5838,8 +5700,6 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJOBS *r_u) { POLICY_HND *handle = &q_u->handle; -/* uint32 firstjob = q_u->firstjob; - notused. */ -/* uint32 numofjobs = q_u->numofjobs; - notused. */ uint32 level = q_u->level; NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; @@ -5907,7 +5767,7 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u return WERR_BADFID; } - if (!print_job_exists(jobid)) { + if (!print_job_exists(snum, jobid)) { return WERR_INVALID_PRINTER_NAME; } @@ -5916,18 +5776,18 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u switch (command) { case JOB_CONTROL_CANCEL: case JOB_CONTROL_DELETE: - if (print_job_delete(&user, jobid, &errcode)) { + if (print_job_delete(&user, snum, jobid, &errcode)) { errcode = WERR_OK; } break; case JOB_CONTROL_PAUSE: - if (print_job_pause(&user, jobid, &errcode)) { + if (print_job_pause(&user, snum, jobid, &errcode)) { errcode = WERR_OK; } break; case JOB_CONTROL_RESTART: case JOB_CONTROL_RESUME: - if (print_job_resume(&user, jobid, &errcode)) { + if (print_job_resume(&user, snum, jobid, &errcode)) { errcode = WERR_OK; } break; @@ -6186,7 +6046,6 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, SPOOL_R_ENUMPRINTERDRIVERS *r_u) { -/* UNISTR2 *name = &q_u->name; - notused. */ UNISTR2 *environment = &q_u->environment; uint32 level = q_u->level; NEW_BUFFER *buffer = NULL; @@ -6243,7 +6102,6 @@ static void fill_form_1(FORM_1 *form, nt_forms_struct *list) WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u) { -/* POLICY_HND *handle = &q_u->handle; - notused. */ uint32 level = q_u->level; NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; @@ -6344,7 +6202,6 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM *r_u) { -/* POLICY_HND *handle = &q_u->handle; - notused. */ uint32 level = q_u->level; UNISTR2 *uni_formname = &q_u->formname; NEW_BUFFER *buffer = NULL; @@ -6640,7 +6497,6 @@ static WERROR enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u) { -/* UNISTR2 *name = &q_u->name; - notused. */ uint32 level = q_u->level; NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; @@ -6804,7 +6660,6 @@ WERROR _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, SPOOL_R_ADDPRINTERDRIVER *r_u) { -/* UNISTR2 *server_name = &q_u->server_name; - notused. */ uint32 level = q_u->level; SPOOL_PRINTER_DRIVER_INFO_LEVEL *info = &q_u->info; WERROR err = WERR_OK; @@ -6952,10 +6807,10 @@ WERROR _spoolss_addprinterdriverex(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVEREX * if ( q_u->copy_flags != APD_COPY_NEW_FILES ) return WERR_ACCESS_DENIED; - /* just pass the information off to _spoolss_addprinterdriver() */ ZERO_STRUCT(q_u_local); ZERO_STRUCT(r_u_local); + /* just pass the information off to _spoolss_addprinterdriver() */ q_u_local.server_name_ptr = q_u->server_name_ptr; copy_unistr2(&q_u_local.server_name, &q_u->server_name); q_u_local.level = q_u->level; @@ -7047,38 +6902,38 @@ WERROR _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRI WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, SPOOL_R_ENUMPRINTERDATA *r_u) { POLICY_HND *handle = &q_u->handle; - uint32 idx = q_u->index; - uint32 in_value_len = q_u->valuesize; - uint32 in_data_len = q_u->datasize; - uint32 *out_max_value_len = &r_u->valuesize; - uint16 **out_value = &r_u->value; - uint32 *out_value_len = &r_u->realvaluesize; - uint32 *out_type = &r_u->type; + uint32 idx = q_u->index; + uint32 in_value_len = q_u->valuesize; + uint32 in_data_len = q_u->datasize; + uint32 *out_max_value_len= &r_u->valuesize; + uint16 **out_value = &r_u->value; + uint32 *out_value_len = &r_u->realvaluesize; + uint32 *out_type = &r_u->type; uint32 *out_max_data_len = &r_u->datasize; - uint8 **data_out = &r_u->data; - uint32 *out_data_len = &r_u->realdatasize; + uint8 **data_out = &r_u->data; + uint32 *out_data_len = &r_u->realdatasize; NT_PRINTER_INFO_LEVEL *printer = NULL; - fstring value; + uint32 param_index; + uint32 biggest_valuesize; + uint32 biggest_datasize; + uint32 data_len; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + int snum; + WERROR result; + REGISTRY_VALUE *val; + NT_PRINTER_DATA *p_data; + int i, key_index, num_values; + int name_length; - uint32 param_index; - uint32 biggest_valuesize; - uint32 biggest_datasize; - uint32 data_len; - Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - int snum; - uint8 *data=NULL; - uint32 type; - WERROR result; - - ZERO_STRUCT(printer); + ZERO_STRUCT( printer ); - *out_type=0; + *out_type = 0; - *out_max_data_len=0; - *data_out=NULL; - *out_data_len=0; + *out_max_data_len = 0; + *data_out = NULL; + *out_data_len = 0; DEBUG(5,("spoolss_enumprinterdata\n")); @@ -7093,103 +6948,133 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S result = get_a_printer(&printer, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(result)) return result; + + p_data = &printer->info_2->data; + key_index = lookup_printerkey( p_data, SPOOL_PRINTERDATA_KEY ); + + result = WERR_OK; /* * The NT machine wants to know the biggest size of value and data * * cf: MSDN EnumPrinterData remark section */ - if ( (in_value_len==0) && (in_data_len==0) ) { + + if ( !in_value_len && !in_data_len ) + { DEBUGADD(6,("Activating NT mega-hack to find sizes\n")); - SAFE_FREE(data); - - param_index=0; - biggest_valuesize=0; - biggest_datasize=0; + param_index = 0; + biggest_valuesize = 0; + biggest_datasize = 0; + + num_values = regval_ctr_numvals( &p_data->keys[key_index].values ); - while (get_specific_param_by_index(*printer, 2, param_index, value, &data, &type, &data_len)) { - if (strlen(value) > biggest_valuesize) biggest_valuesize=strlen(value); - if (data_len > biggest_datasize) biggest_datasize=data_len; - - DEBUG(6,("current values: [%d], [%d]\n", biggest_valuesize, biggest_datasize)); - - SAFE_FREE(data); - param_index++; + for ( i=0; ikeys[key_index].values, i ); + + name_length = strlen(val->valuename); + if ( strlen(val->valuename) > biggest_valuesize ) + biggest_valuesize = name_length; + + if ( val->size > biggest_datasize ) + biggest_datasize = val->size; + + DEBUG(6,("current values: [%d], [%d]\n", biggest_valuesize, + biggest_datasize)); } - /* the value is an UNICODE string but realvaluesize is the length in bytes including the leading 0 */ - *out_value_len=2*(1+biggest_valuesize); - *out_data_len=biggest_datasize; + /* the value is an UNICODE string but real_value_size is the length + in bytes including the trailing 0 */ + + *out_value_len = 2 * (1+biggest_valuesize); + *out_data_len = biggest_datasize; DEBUG(6,("final values: [%d], [%d]\n", *out_value_len, *out_data_len)); - free_a_printer(&printer, 2); - return WERR_OK; + goto done; } /* * the value len is wrong in NT sp3 * that's the number of bytes not the number of unicode chars */ + + val = regval_ctr_specific_value( &p_data->keys[key_index].values, idx ); - if (!get_specific_param_by_index(*printer, 2, idx, value, &data, &type, &data_len)) { - - SAFE_FREE(data); - free_a_printer(&printer, 2); + if ( !val ) + { /* out_value should default to "" or else NT4 has problems unmarshalling the response */ - *out_max_value_len=(in_value_len/sizeof(uint16)); - if((*out_value=(uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL) - return WERR_NOMEM; + *out_max_value_len = (in_value_len/sizeof(uint16)); + + if ( (*out_value=(uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL ) + { + result = WERR_NOMEM; + goto done; + } *out_value_len = (uint32)rpcstr_push((char *)*out_value, "", in_value_len, 0); /* the data is counted in bytes */ + *out_max_data_len = in_data_len; - *out_data_len = in_data_len; - if((*data_out=(uint8 *)talloc_zero(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) - return WERR_NOMEM; + *out_data_len = in_data_len; + + /* only allocate when given a non-zero data_len */ + + if ( in_data_len && ((*data_out=(uint8 *)talloc_zero(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) ) + { + result = WERR_NOMEM; + goto done; + } - return WERR_NO_MORE_ITEMS; + result = WERR_NO_MORE_ITEMS; } - - free_a_printer(&printer, 2); - - /* - * the value is: - * - counted in bytes in the request - * - counted in UNICODE chars in the max reply - * - counted in bytes in the real size - * - * take a pause *before* coding not *during* coding - */ + else + { + /* + * the value is: + * - counted in bytes in the request + * - counted in UNICODE chars in the max reply + * - counted in bytes in the real size + * + * take a pause *before* coding not *during* coding + */ - *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 WERR_NOMEM; - } + /* name */ + *out_max_value_len = ( in_value_len / sizeof(uint16) ); + if ( (*out_value = (uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL ) + { + result = WERR_NOMEM; + goto done; + } - *out_value_len = (uint32)rpcstr_push((char *)*out_value,value, in_value_len, 0); + *out_value_len = (uint32)rpcstr_push((char *)*out_value, regval_name(val), in_value_len, 0); - *out_type=type; + /* type */ + + *out_type = regval_type( val ); - /* the data is counted in bytes */ - *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 WERR_NOMEM; + /* data - counted in bytes */ + + *out_max_data_len = in_data_len; + if ( (*data_out = (uint8 *)talloc_zero(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) + { + result = WERR_NOMEM; + goto done; + } + data_len = (size_t)regval_size(val); + memcpy( *data_out, regval_data_p(val), data_len ); + *out_data_len = data_len; } - - memcpy(*data_out, data, (size_t)data_len); - *out_data_len=data_len; - SAFE_FREE(data); - - return WERR_OK; +done: + free_a_printer(&printer, 2); + return result; } /**************************************************************************** @@ -7197,17 +7082,17 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SPOOL_R_SETPRINTERDATA *r_u) { - POLICY_HND *handle = &q_u->handle; - UNISTR2 *value = &q_u->value; - uint32 type = q_u->type; - uint8 *data = q_u->data; - uint32 real_len = q_u->real_len; + POLICY_HND *handle = &q_u->handle; + UNISTR2 *value = &q_u->value; + uint32 type = q_u->type; + uint8 *data = q_u->data; + uint32 real_len = q_u->real_len; - NT_PRINTER_INFO_LEVEL *printer = NULL; - NT_PRINTER_PARAM *param = NULL, old_param; - int snum=0; - WERROR status = WERR_OK; - Printer_entry *Printer=find_printer_index_by_hnd(p, handle); + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum=0; + WERROR status = WERR_OK; + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); + fstring valuename; DEBUG(5,("spoolss_setprinterdata\n")); @@ -7219,8 +7104,6 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; - ZERO_STRUCT(old_param); - /* * Access check : NT returns "access denied" if you make a * SetPrinterData call without the necessary privildge. @@ -7235,40 +7118,22 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP 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 (!W_ERROR_IS_OK(status)) return status; - convert_specific_param(¶m, value , type, data, real_len); + /* save the registry data */ + + unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); + delete_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, valuename ); + add_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, valuename, type, data, real_len ); - unlink_specific_param_if_exist(printer->info_2, param); + /* write the **entire** printer out to disk.... :-( */ - /* - * 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, ¶m); - status = mod_a_printer(*printer, 2); - } + status = mod_a_printer(*printer, 2); - done: +done: free_a_printer(&printer, 2); - if (param) - free_nt_printer_param(¶m); - SAFE_FREE(old_param.data); return status; } @@ -7278,9 +7143,9 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP WERROR _spoolss_resetprinter(pipes_struct *p, SPOOL_Q_RESETPRINTER *q_u, SPOOL_R_RESETPRINTER *r_u) { - POLICY_HND *handle = &q_u->handle; - Printer_entry *Printer=find_printer_index_by_hnd(p, handle); - int snum; + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); + int snum; DEBUG(5,("_spoolss_resetprinter\n")); @@ -7304,16 +7169,19 @@ WERROR _spoolss_resetprinter(pipes_struct *p, SPOOL_Q_RESETPRINTER *q_u, SPOOL_R } +/**************************************************************************** +****************************************************************************/ + WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_u, SPOOL_R_DELETEPRINTERDATA *r_u) { - POLICY_HND *handle = &q_u->handle; - UNISTR2 *value = &q_u->valuename; + POLICY_HND *handle = &q_u->handle; + UNISTR2 *value = &q_u->valuename; - NT_PRINTER_INFO_LEVEL *printer = NULL; - NT_PRINTER_PARAM param; - int snum=0; - WERROR status = WERR_OK; - Printer_entry *Printer=find_printer_index_by_hnd(p, handle); + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum=0; + WERROR status = WERR_OK; + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); + pstring valuename; DEBUG(5,("spoolss_deleteprinterdata\n")); @@ -7334,15 +7202,14 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ if (!W_ERROR_IS_OK(status)) return status; - ZERO_STRUCTP(¶m); - unistr2_to_ascii(param.value, value, sizeof(param.value)-1); + unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); - if(!unlink_specific_param_if_exist(printer->info_2, ¶m)) - status = WERR_INVALID_PARAM; - else + status = delete_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, valuename ); + if ( NT_STATUS_IS_OK(status) ) status = mod_a_printer(*printer, 2); free_a_printer(&printer, 2); + return status; } @@ -7352,7 +7219,6 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM *r_u) { POLICY_HND *handle = &q_u->handle; -/* uint32 level = q_u->level; - notused. */ FORM *form = &q_u->form; nt_forms_struct tmpForm; int snum; @@ -7971,9 +7837,10 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, * (a) DsDriver * (b) DsSpooler * (c) PnPData + * (d) DsUser */ - if (strcmp(key, "PrinterDriverData") != 0) + if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) return WERR_BADFILE; DEBUG(10, ("_spoolss_getprinterdataex: pass me to getprinterdata\n")); @@ -8019,7 +7886,7 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); - if (strcmp(key, "PrinterDriverData") != 0) + if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) return WERR_INVALID_PARAM; ZERO_STRUCT(q_u_local); @@ -8054,7 +7921,7 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); - if (strcmp(key, "PrinterDriverData") != 0) + if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) return WERR_INVALID_PARAM; memcpy(&q_u_local.handle, &q_u->handle, sizeof(POLICY_HND)); @@ -8070,57 +7937,66 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX * spoolss_enumprinterkey ********************************************************************/ -/* constants for EnumPrinterKey() */ -#define ENUMERATED_KEY_SIZE 19 WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPOOL_R_ENUMPRINTERKEY *r_u) { fstring key; - uint16 enumkeys[ENUMERATED_KEY_SIZE+1]; + uint16 *enumkeys = NULL; char* ptr = NULL; int i; - char *PrinterKey = "PrinterDriverData"; + int printerkey_len = strlen(SPOOL_PRINTERDATA_KEY)+1; DEBUG(4,("_spoolss_enumprinterkey\n")); - unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); + unistr2_to_ascii( key, &q_u->key, sizeof(key)-1 ); /* * we only support enumating all keys (key == "") * Of course, the only key we support is the "PrinterDriverData" * key - */ - if (strlen(key) == 0) + */ + + if ( !strlen( key ) ) { - r_u->needed = ENUMERATED_KEY_SIZE *2; - if (q_u->size < r_u->needed) + r_u->needed = printerkey_len*2; + + if ( q_u->size < r_u->needed ) return WERR_MORE_DATA; - ptr = PrinterKey; - for (i=0; imem_ctx, printerkey_len*2 )) ) { + DEBUG(0,("_spoolss_enumprinterkey: talloc() failed for [%d] bytes!\n", + printerkey_len)); + return WERR_NOMEM; + } + + ptr = SPOOL_PRINTERDATA_KEY; + for ( i=0; i<(printerkey_len-1); i++ ) { enumkeys[i] = (uint16)(*ptr); ptr++; } - /* tag of with 2 '\0's */ - enumkeys[i++] = '\0'; - enumkeys[i] = '\0'; + /* tag of '\0's */ + + enumkeys[i] = 0x0; - if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, ENUMERATED_KEY_SIZE, enumkeys)) + if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, printerkey_len, enumkeys)) return WERR_BADFILE; return WERR_OK; } /* The "PrinterDriverData" key should have no subkeys */ - if (strcmp(key, PrinterKey) == 0) + if ( strcmp(key, SPOOL_PRINTERDATA_KEY) == 0 ) { - r_u-> needed = 2; + uint16 dummy_key = 0; + + r_u->needed = 2; + if (q_u->size < r_u->needed) return WERR_MORE_DATA; - enumkeys[0] = 0x0; - if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, 1, enumkeys)) + + if ( !make_spoolss_buffer5(p->mem_ctx, &r_u->keys, 1, &dummy_key ) ) return WERR_BADFILE; return WERR_OK; @@ -8129,6 +8005,7 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO /* The return value for an unknown key is documented in MSDN EnumPrinterKey description */ + return WERR_BADFILE; } @@ -8148,7 +8025,7 @@ WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); - if (strcmp(key, "PrinterDriverData") != 0) + if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) return WERR_INVALID_PARAM; /* @@ -8172,14 +8049,16 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ needed; NT_PRINTER_INFO_LEVEL *printer = NULL; PRINTER_ENUM_VALUES *enum_values = NULL; - fstring key, value; + NT_PRINTER_DATA *p_data; + fstring key; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); int snum; - uint32 param_index, - data_len, - type; WERROR result; - uint8 *data=NULL; + int key_index; + int i; + REGISTRY_VALUE *val; + char *value_name; + int data_len; DEBUG(4,("_spoolss_enumprinterdataex\n")); @@ -8190,20 +8069,8 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ } - /* - * The only key we support is "PrinterDriverData". This should return - > an array of all the key/value pairs returned by EnumPrinterDataSee - * _spoolss_getprinterdataex() for details --jerry - */ - - unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); - if (strcmp(key, "PrinterDriverData") != 0) - { - DEBUG(10,("_spoolss_enumprinterdataex: Unknown keyname [%s]\n", key)); - return WERR_INVALID_PARAM; - } - - + /* first get the printer off of disk */ + if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; @@ -8211,55 +8078,78 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ result = get_a_printer(&printer, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(result)) return result; - - /* - * loop through all params and build the array to pass - * back to the client - */ + /* now look for a match on the key name */ + + p_data = &printer->info_2->data; + + unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); + if ( (key_index = lookup_printerkey( p_data, key)) == -1 ) + { + DEBUG(10,("_spoolss_enumprinterdataex: Unknown keyname [%s]\n", key)); + result = WERR_INVALID_PARAM; + goto done; + } + result = WERR_OK; - param_index = 0; - needed = 0; - num_entries = 0; + needed = 0; - while (get_specific_param_by_index(*printer, 2, param_index, value, &data, &type, &data_len)) + /* allocate the memory for the array of pointers -- if necessary */ + + num_entries = regval_ctr_numvals( &p_data->keys[key_index].values ); + if ( num_entries ) { - PRINTER_ENUM_VALUES *ptr; - uint32 add_len = 0; - - DEBUG(10,("retrieved value number [%d] [%s]\n", num_entries, value)); - - if ((ptr=talloc_realloc(p->mem_ctx, enum_values, (num_entries+1) * sizeof(PRINTER_ENUM_VALUES))) == NULL) + if ( (enum_values=talloc(p->mem_ctx, num_entries*sizeof(PRINTER_ENUM_VALUES))) == NULL ) { - DEBUG(0,("talloc_realloc failed to allocate more memory!\n")); + DEBUG(0,("_spoolss_enumprinterdataex: talloc() failed to allocate memory for [%d] bytes!\n", + num_entries*sizeof(PRINTER_ENUM_VALUES))); result = WERR_NOMEM; goto done; } - enum_values = ptr; + + memset( enum_values, 0x0, num_entries*sizeof(PRINTER_ENUM_VALUES) ); + } + + /* + * loop through all params and build the array to pass + * back to the client + */ + + for ( i=0; ikeys[key_index].values, i ); + DEBUG(10,("retrieved value number [%d] [%s]\n", i, regval_name(val) )); /* copy the data */ - init_unistr(&enum_values[num_entries].valuename, value); - enum_values[num_entries].value_len = (strlen(value)+1) * 2; - enum_values[num_entries].type = type; - if (!(enum_values[num_entries].data=talloc_zero(p->mem_ctx, data_len+add_len))) { - DEBUG(0,("talloc_realloc failed to allocate more memory for data!\n")); - result = WERR_NOMEM; - goto done; + value_name = regval_name( val ); + init_unistr( &enum_values[i].valuename, value_name ); + enum_values[i].value_len = (strlen(value_name)+1) * 2; + enum_values[i].type = regval_type( val ); + + data_len = regval_size( val ); + if ( data_len ) { + if ( !(enum_values[i].data = talloc_memdup(p->mem_ctx, regval_data_p(val), data_len)) ) + { + DEBUG(0,("talloc_memdup failed to allocate memory [data_len=%d] for data!\n", + data_len )); + result = WERR_NOMEM; + goto done; + } } - memcpy(enum_values[num_entries].data, data, data_len); - enum_values[num_entries].data_len = data_len + add_len; + enum_values[i].data_len = data_len; /* keep track of the size of the array in bytes */ - needed += spoolss_size_printer_enum_values(&enum_values[num_entries]); - - num_entries++; - param_index++; + needed += spoolss_size_printer_enum_values(&enum_values[i]); } - r_u->needed = needed; - r_u->returned = num_entries; + /* housekeeping information in the reply */ + + r_u->needed = needed; + r_u->returned = num_entries; if (needed > in_size) { result = WERR_MORE_DATA; @@ -8355,4 +8245,23 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC return result; } +#if 0 + +WERROR _spoolss_replyopenprinter(pipes_struct *p, SPOOL_Q_REPLYOPENPRINTER *q_u, + SPOOL_R_REPLYOPENPRINTER *r_u) +{ + DEBUG(5,("_spoolss_replyopenprinter\n")); + + DEBUG(10, ("replyopenprinter for localprinter %d\n", q_u->printer)); + + return WERR_OK; +} + +WERROR _spoolss_replycloseprinter(pipes_struct *p, SPOOL_Q_REPLYCLOSEPRINTER *q_u, + SPOOL_R_REPLYCLOSEPRINTER *r_u) +{ + DEBUG(5,("_spoolss_replycloseprinter\n")); + return WERR_OK; +} +#endif diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 5e1c005d54..4a372de089 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -344,6 +344,36 @@ static BOOL api_srv_net_share_del(pipes_struct *p) return True; } +/******************************************************************* + RPC to delete share information. +********************************************************************/ + +static BOOL api_srv_net_share_del_sticky(pipes_struct *p) +{ + SRV_Q_NET_SHARE_DEL q_u; + SRV_R_NET_SHARE_DEL r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server del info. */ + if(!srv_io_q_net_share_del("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_share_del_sticky: Failed to unmarshall SRV_Q_NET_SHARE_DEL.\n")); + return False; + } + + r_u.status = _srv_net_share_del_sticky(p, &q_u, &r_u); + + if(!srv_io_r_net_share_del("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_del_sticky: Failed to marshall SRV_R_NET_SHARE_DEL.\n")); + return False; + } + + return True; +} + /******************************************************************* api_srv_net_remote_tod ********************************************************************/ @@ -503,6 +533,7 @@ static const struct api_struct api_srv_cmds[] = { "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum }, { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del }, + { "SRV_NET_SHARE_DEL_STICKY", SRV_NET_SHARE_DEL_STICKY, api_srv_net_share_del_sticky }, { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info }, { "SRV_NET_SHARE_SET_INFO", SRV_NET_SHARE_SET_INFO, api_srv_net_share_set_info }, { "SRV_NET_FILE_ENUM" , SRV_NET_FILE_ENUM , api_srv_net_file_enum }, diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 202e869d35..5c1038949b 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -3,6 +3,7 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Nigel Williams 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,33 +29,54 @@ extern pstring global_myname; +/******************************************************************* + Utility function to get the 'type' of a share from an snum. + ********************************************************************/ +static uint32 get_share_type(int snum) +{ + char *net_name = lp_servicename(snum); + int len_net_name = strlen(net_name); + + /* work out the share type */ + uint32 type = STYPE_DISKTREE; + + if (lp_print_ok(snum)) + type = STYPE_PRINTQ; + if (strequal(lp_fstype(snum), "IPC")) + type = STYPE_IPC; + if (net_name[len_net_name] == '$') + type |= STYPE_HIDDEN; + + return type; +} + +/******************************************************************* + Fill in a share info level 0 structure. + ********************************************************************/ + +static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int snum) +{ + pstring net_name; + + pstrcpy(net_name, lp_servicename(snum)); + + init_srv_share_info0(&sh0->info_0, net_name); + init_srv_share_info0_str(&sh0->info_0_str, net_name); +} + /******************************************************************* Fill in a share info level 1 structure. ********************************************************************/ static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum) { - int len_net_name; - pstring net_name; pstring remark; - uint32 type; - pstrcpy(net_name, lp_servicename(snum)); + char *net_name = lp_servicename(snum); pstrcpy(remark, lp_comment(snum)); standard_sub_conn(p->conn, remark,sizeof(remark)); - len_net_name = strlen(net_name); - - /* work out the share type */ - type = STYPE_DISKTREE; - - if (lp_print_ok(snum)) - type = STYPE_PRINTQ; - if (strequal("IPC$", net_name) || strequal("ADMIN$", net_name)) - type = STYPE_IPC; - if (net_name[len_net_name] == '$') - type |= STYPE_HIDDEN; - init_srv_share_info1(&sh1->info_1, net_name, type, remark); + init_srv_share_info1(&sh1->info_1, net_name, get_share_type(snum), remark); init_srv_share_info1_str(&sh1->info_1_str, net_name, remark); } @@ -64,14 +86,11 @@ static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int sn static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int snum) { - int len_net_name; - pstring net_name; pstring remark; pstring path; pstring passwd; - uint32 type; - pstrcpy(net_name, lp_servicename(snum)); + char *net_name = lp_servicename(snum); pstrcpy(remark, lp_comment(snum)); standard_sub_conn(p->conn, remark,sizeof(remark)); pstrcpy(path, "C:"); @@ -85,19 +104,8 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int sn string_replace(path, '/', '\\'); pstrcpy(passwd, ""); - len_net_name = strlen(net_name); - /* work out the share type */ - type = STYPE_DISKTREE; - - if (lp_print_ok(snum)) - type = STYPE_PRINTQ; - if (strequal("IPC$", net_name) || strequal("ADMIN$", net_name)) - type = STYPE_IPC; - if (net_name[len_net_name] == '$') - type |= STYPE_HIDDEN; - - init_srv_share_info2(&sh2->info_2, net_name, type, remark, 0, 0xffffffff, 1, path, passwd); + init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd); init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); } @@ -251,7 +259,7 @@ static BOOL set_share_security(TALLOC_CTX *ctx, const char *share_name, SEC_DESC /* Free malloc'ed memory */ - out: +out: prs_mem_free(&ps); if (mem_ctx) @@ -337,7 +345,7 @@ BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, u ret = se_access_check(psd, token, desired_access, &granted, &status); - out: +out: talloc_destroy(mem_ctx); @@ -351,27 +359,15 @@ BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, u static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum) { int len_net_name; - pstring net_name; pstring remark; - uint32 type; - pstrcpy(net_name, lp_servicename(snum)); + char *net_name = lp_servicename(snum); pstrcpy(remark, lp_comment(snum)); standard_sub_conn(p->conn, remark, sizeof(remark)); len_net_name = strlen(net_name); - /* work out the share type */ - type = STYPE_DISKTREE; - - if (lp_print_ok(snum)) - type = STYPE_PRINTQ; - if (strequal("IPC$", net_name) || strequal("ADMIN$", net_name)) - type = STYPE_IPC; - if (net_name[len_net_name] == '$') - type |= STYPE_HIDDEN; - - init_srv_share_info501(&sh501->info_501, net_name, type, remark, (lp_csc_policy(snum) << 4)); + init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), remark, (lp_csc_policy(snum) << 4)); init_srv_share_info501_str(&sh501->info_501_str, net_name, remark); } @@ -386,7 +382,6 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, pstring remark; pstring path; pstring passwd; - uint32 type; SEC_DESC *sd; size_t sd_size; TALLOC_CTX *ctx = p->mem_ctx; @@ -410,39 +405,86 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, pstrcpy(passwd, ""); len_net_name = strlen(net_name); - /* work out the share type */ - type = STYPE_DISKTREE; - - if (lp_print_ok(snum)) - type = STYPE_PRINTQ; - if (strequal("IPC$", net_name)) - type = STYPE_IPC; - if (net_name[len_net_name] == '$') - type |= STYPE_HIDDEN; - sd = get_share_security(ctx, snum, &sd_size); - init_srv_share_info502(&sh502->info_502, net_name, type, remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size); - init_srv_share_info502_str(&sh502->info_502_str, &sh502->info_502, net_name, remark, path, passwd, sd, sd_size); + init_srv_share_info502(&sh502->info_502, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size); + init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, path, passwd, sd, sd_size); +} + +/*************************************************************************** + Fill in a share info level 1004 structure. + ***************************************************************************/ + +static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh1004, int snum) +{ + pstring remark; + + pstrcpy(remark, lp_comment(snum)); + standard_sub_conn(p->conn, remark, sizeof(remark)); + + ZERO_STRUCTP(sh1004); + + init_srv_share_info1004(&sh1004->info_1004, remark); + init_srv_share_info1004_str(&sh1004->info_1004_str, remark); } /*************************************************************************** Fill in a share info level 1005 structure. ***************************************************************************/ -static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum) +static void init_srv_share_info_1005(pipes_struct *p, SRV_SHARE_INFO_1005* sh1005, int snum) { sh1005->dfs_root_flag = 0; if(lp_host_msdfs() && lp_msdfs_root(snum)) sh1005->dfs_root_flag = 3; } +/*************************************************************************** + Fill in a share info level 1006 structure. + ***************************************************************************/ + +static void init_srv_share_info_1006(pipes_struct *p, SRV_SHARE_INFO_1006* sh1006, int snum) +{ + sh1006->max_uses = -1; +} + +/*************************************************************************** + Fill in a share info level 1007 structure. + ***************************************************************************/ + +static void init_srv_share_info_1007(pipes_struct *p, SRV_SHARE_INFO_1007* sh1007, int snum) +{ + pstring alternate_directory_name = ""; + uint32 flags = 0; + + ZERO_STRUCTP(sh1007); + + init_srv_share_info1007(&sh1007->info_1007, flags, alternate_directory_name); + init_srv_share_info1007_str(&sh1007->info_1007_str, alternate_directory_name); +} + +/******************************************************************* + Fill in a share info level 1501 structure. + ********************************************************************/ + +static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh1501, int snum) +{ + SEC_DESC *sd; + size_t sd_size; + TALLOC_CTX *ctx = p->mem_ctx; + + ZERO_STRUCTP(sh1501); + + sd = get_share_security(ctx, snum, &sd_size); + + sh1501->sdb = make_sec_desc_buf(p->mem_ctx, sd_size, sd); +} /******************************************************************* True if it ends in '$'. ********************************************************************/ -static BOOL is_admin_share(int snum) +static BOOL is_hidden_share(int snum) { pstring net_name; @@ -471,7 +513,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, /* Count the number of entries. */ for (snum = 0; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) num_entries++; } @@ -483,6 +525,24 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, return True; switch (info_level) { + case 0: + { + SRV_SHARE_INFO_0 *info0; + int i = 0; + + info0 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_0)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_0(p, &info0[i++], snum); + } + } + + ctr->share.info0 = info0; + break; + + } + case 1: { SRV_SHARE_INFO_1 *info1; @@ -491,7 +551,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, info1 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1)); for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { init_srv_share_info_1(p, &info1[i++], snum); } } @@ -508,7 +568,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, info2 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_2)); for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { init_srv_share_info_2(p, &info2[i++], snum); } } @@ -525,7 +585,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, info501 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_501)); for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { init_srv_share_info_501(p, &info501[i++], snum); } } @@ -542,7 +602,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, info502 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_502)); for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { init_srv_share_info_502(p, &info502[i++], snum); } } @@ -551,6 +611,92 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, break; } + /* here for completeness but not currently used with enum (1004 - 1501)*/ + + case 1004: + { + SRV_SHARE_INFO_1004 *info1004; + int i = 0; + + info1004 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1004)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1004(p, &info1004[i++], snum); + } + } + + ctr->share.info1004 = info1004; + break; + } + + case 1005: + { + SRV_SHARE_INFO_1005 *info1005; + int i = 0; + + info1005 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1005)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1005(p, &info1005[i++], snum); + } + } + + ctr->share.info1005 = info1005; + break; + } + + case 1006: + { + SRV_SHARE_INFO_1006 *info1006; + int i = 0; + + info1006 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1006)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1006(p, &info1006[i++], snum); + } + } + + ctr->share.info1006 = info1006; + break; + } + + case 1007: + { + SRV_SHARE_INFO_1007 *info1007; + int i = 0; + + info1007 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1007)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1007(p, &info1007[i++], snum); + } + } + + ctr->share.info1007 = info1007; + break; + } + + case 1501: + { + SRV_SHARE_INFO_1501 *info1501; + int i = 0; + + info1501 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1501)); + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1501(p, &info1501[i++], snum); + } + } + + ctr->share.info1501 = info1501; + break; + } default: DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level)); return False; @@ -596,6 +742,9 @@ static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_I if (snum >= 0) { switch (info_level) { + case 0: + init_srv_share_info_0(p, &r_n->info.share.info0, snum); + break; case 1: init_srv_share_info_1(p, &r_n->info.share.info1, snum); break; @@ -608,8 +757,24 @@ static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_I case 502: init_srv_share_info_502(p, &r_n->info.share.info502, snum); break; + + /* here for completeness */ + case 1004: + init_srv_share_info_1004(p, &r_n->info.share.info1004, snum); + break; case 1005: - init_srv_share_info_1005(&r_n->info.share.info1005, snum); + init_srv_share_info_1005(p, &r_n->info.share.info1005, snum); + break; + + /* here for completeness 1006 - 1501 */ + case 1006: + init_srv_share_info_1006(p, &r_n->info.share.info1006, snum); + break; + case 1007: + init_srv_share_info_1007(p, &r_n->info.share.info1007, snum); + break; + case 1501: + init_srv_share_info_1501(p, &r_n->info.share.info1501, snum); break; default: DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level)); @@ -955,7 +1120,8 @@ static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, ********************************************************************/ static WERROR init_srv_file_info_ctr(pipes_struct *p, SRV_FILE_INFO_CTR *ctr, - int switch_value, uint32 *resume_hnd, uint32 *total_entries) + int switch_value, uint32 *resume_hnd, + uint32 *total_entries) { WERROR status = WERR_OK; TALLOC_CTX *ctx = p->mem_ctx; @@ -1206,8 +1372,8 @@ WERROR _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET /* Create the list of shares for the response. */ init_srv_r_net_share_enum(p, r_u, - q_u->ctr.info_level, - get_enum_hnd(&q_u->enum_hnd), False); + q_u->ctr.info_level, + get_enum_hnd(&q_u->enum_hnd), False); DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); @@ -1295,7 +1461,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); - r_u->switch_value = 0; + r_u->parm_error = 0; if (strequal(share_name,"IPC$") || strequal(share_name,"ADMIN$") || strequal(share_name,"global")) return WERR_ACCESS_DENIED; @@ -1312,28 +1478,47 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S get_current_user(&user,p); - if (user.uid != 0) + if (user.uid != sec_initial_uid()) return WERR_ACCESS_DENIED; switch (q_u->info_level) { case 1: - /* Not enough info in a level 1 to do anything. */ - return WERR_ACCESS_DENIED; + fstrcpy(pathname, lp_pathname(snum)); + unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); + type = q_u->info.share.info2.info_2.type; + psd = NULL; + break; 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)); + unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); + unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(pathname)); type = q_u->info.share.info2.info_2.type; psd = NULL; break; +#if 0 + /* not supported on set but here for completeness */ + case 501: + unistr2_to_ascii(comment, &q_u->info.share.info501.info_501_str.uni_remark, sizeof(comment)); + type = q_u->info.share.info501.info_501.type; + psd = NULL; + break; +#endif case 502: - unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name)); - unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name)); + unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(comment)); + unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(pathname)); type = q_u->info.share.info502.info_502.type; psd = q_u->info.share.info502.info_502_str.sd; map_generic_share_sd_bits(psd); break; + case 1004: + fstrcpy(pathname, lp_pathname(snum)); + unistr2_to_ascii(comment, &q_u->info.share.info1004.info_1004_str.uni_remark, sizeof(comment)); + type = STYPE_DISKTREE; + break; case 1005: + case 1006: + case 1007: return WERR_ACCESS_DENIED; + break; case 1501: fstrcpy(pathname, lp_pathname(snum)); fstrcpy(comment, lp_comment(snum)); @@ -1422,12 +1607,12 @@ WERROR _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__)); - r_u->switch_value = 0; + r_u->parm_error = 0; get_current_user(&user,p); - if (user.uid != 0) { - DEBUG(10,("_srv_net_share_add: uid != 0. Access denied.\n")); + if (user.uid != sec_initial_uid()) { + DEBUG(10,("_srv_net_share_add: uid != sec_initial_uid(). Access denied.\n")); return WERR_ACCESS_DENIED; } @@ -1437,6 +1622,9 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S } switch (q_u->info_level) { + case 0: + /* No path. Not enough info in a level 0 to do anything. */ + return WERR_ACCESS_DENIED; case 1: /* Not enough info in a level 1 to do anything. */ return WERR_ACCESS_DENIED; @@ -1446,6 +1634,9 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name)); type = q_u->info.share.info2.info_2.type; break; + case 501: + /* No path. Not enough info in a level 501 to do anything. */ + return WERR_ACCESS_DENIED; case 502: unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name)); unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name)); @@ -1454,7 +1645,16 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S psd = q_u->info.share.info502.info_502_str.sd; map_generic_share_sd_bits(psd); break; + + /* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */ + + case 1004: case 1005: + case 1006: + case 1007: + return WERR_ACCESS_DENIED; + break; + case 1501: /* DFS only level. */ return WERR_ACCESS_DENIED; default: @@ -1544,7 +1744,7 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S get_current_user(&user,p); - if (user.uid != 0) + if (user.uid != sec_initial_uid()) return WERR_ACCESS_DENIED; if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) @@ -1570,6 +1770,13 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S return WERR_OK; } +WERROR _srv_net_share_del_sticky(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) +{ + DEBUG(5,("_srv_net_share_del_stick: %d\n", __LINE__)); + + return _srv_net_share_del(p, q_u, r_u); +} + /******************************************************************* time of day ********************************************************************/ @@ -1703,7 +1910,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC close_cnum(conn, user.vuid); return r_u->status; - error_exit: +error_exit: if(fsp) { close_file(fsp, True); @@ -1799,7 +2006,7 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ close_cnum(conn, user.vuid); return r_u->status; - error_exit: +error_exit: if(fsp) { close_file(fsp, True); @@ -1864,6 +2071,7 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D { uint32 i; const char *disk_name; + TALLOC_CTX *ctx = p->mem_ctx; uint32 resume=get_enum_hnd(&q_u->enum_hnd); r_u->status=WERR_OK; @@ -1872,6 +2080,18 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D r_u->disk_enum_ctr.unknown = 0; + { + DISK_INFO *dinfo; + + int dinfo_size = MAX_SERVER_DISK_ENTRIES * sizeof(*dinfo); + + if(!(dinfo = talloc(ctx, dinfo_size))) { + return WERR_NOMEM; + } + + r_u->disk_enum_ctr.disk_info = dinfo; + } + r_u->disk_enum_ctr.disk_info_ptr = r_u->disk_enum_ctr.disk_info ? 1 : 0; /*allow one DISK_INFO for null terminator*/ @@ -1885,7 +2105,7 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name); } - /*add a terminating null string. Is this there if there is more data to come?*/ + /* add a terminating null string. Is this there if there is more data to come? */ r_u->disk_enum_ctr.entries_read++; diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index f896d1d9d8..50bf5db4fd 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -84,10 +84,10 @@ rid_name domain_group_rids[] = NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, uint32 **prids, DOM_SID *q_sid) { SAM_ACCOUNT *sam_pass=NULL; - struct sys_grent *glist; - struct sys_grent *grp; - int i, num, cur_rid=0; + int i, cur_rid=0; gid_t gid; + gid_t *groups = NULL; + int num_groups; GROUP_MAP map; DOM_SID tmp_sid; fstring user_name; @@ -130,16 +130,21 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui fstrcpy(user_name, pdb_get_username(sam_pass)); grid=pdb_get_group_rid(sam_pass); gid=pdb_get_gid(sam_pass); - - grp = glist = getgrent_list(); - if (grp == NULL) { + + become_root(); + /* on some systems this must run as root */ + num_groups = getgroups_user(user_name, &groups); + unbecome_root(); + if (num_groups == -1) { + /* this should never happen */ + DEBUG(2,("get_alias_user_groups: getgroups_user failed\n")); pdb_free_sam(&sam_pass); - return NT_STATUS_NO_MEMORY; + return NT_STATUS_UNSUCCESSFUL; } - - for (; grp != NULL; grp = grp->next) { - if(!get_group_from_gid(grp->gr_gid, &map, MAPPING_WITHOUT_PRIV)) { - DEBUG(10,("get_alias_user_groups: gid %d. not found\n", (int)grp->gr_gid)); + + for (i=0;igr_gid >= winbind_gid_low) && (grp->gr_gid <= winbind_gid_high)) { + if (winbind_groups_exist && (groups[i] >= winbind_gid_low) && (groups[i] <= winbind_gid_high)) { DEBUG(10,("get_alias_user_groups: not returing %s, not local.\n", map.nt_name)); continue; } @@ -170,30 +175,21 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui continue; } - /* the group is fine, we can check if there is the user we're looking for */ - DEBUG(10,("get_alias_user_groups: checking if the user is a member of %s.\n", map.nt_name)); - - for(num=0; grp->gr_mem[num]!=NULL; num++) { - if(strcmp(grp->gr_mem[num], user_name)==0) { - /* we found the user, add the group to the list */ - - new_rids=(uint32 *)Realloc(rids, sizeof(uint32)*(cur_rid+1)); - if (new_rids==NULL) { - DEBUG(10,("get_alias_user_groups: could not realloc memory\n")); - pdb_free_sam(&sam_pass); - return NT_STATUS_NO_MEMORY; - } - rids=new_rids; - - sid_peek_rid(&map.sid, &(rids[cur_rid])); - DEBUG(10,("get_alias_user_groups: user found in group %s\n", map.nt_name)); - cur_rid++; - break; - } + new_rids=(uint32 *)Realloc(rids, sizeof(uint32)*(cur_rid+1)); + if (new_rids==NULL) { + DEBUG(10,("get_alias_user_groups: could not realloc memory\n")); + pdb_free_sam(&sam_pass); + free(groups); + return NT_STATUS_NO_MEMORY; } + rids=new_rids; + + sid_peek_rid(&map.sid, &(rids[cur_rid])); + cur_rid++; + break; } - grent_free(glist); + free(groups); /* now check for the user's gid (the primary group rid) */ for (i=0; i Date: Sun, 18 Aug 2002 00:59:47 +0000 Subject: * fix Get/SetPrinterDataEx() to work with printer key other than SPOOL_PRINTERDATA_KEY * created an internal set/get_printer_dataex() call for reuse in Set/GetPrinterData() (This used to be commit 4eb8ffba032971cf83a0fcec7ca3730b4ded0bf0) --- source3/rpc_server/srv_spoolss_nt.c | 336 +++++++++++++++++++++++------------- 1 file changed, 217 insertions(+), 119 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7aceaa548f..02bd0ef45b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1231,8 +1231,8 @@ Can't find printer handle we created for printer %s\n", name )); /* Allow admin access */ - if (printer_default->access_required & - SERVER_ACCESS_ADMINISTER) { + if ( printer_default->access_required & SERVER_ACCESS_ADMINISTER ) + { if (!lp_ms_add_printer_wizard()) { close_printer_handle(p, handle); @@ -1296,7 +1296,9 @@ Can't find printer handle we created for printer %s\n", name )); else printer_default->access_required = PRINTER_ACCESS_USE; - DEBUG(4,("Setting printer access=%x\n", printer_default->access_required)); + DEBUG(4,("Setting printer access = %s\n", (printer_default->access_required == PRINTER_ACCESS_ADMINISTER) + ? "PRINTER_ACCESS_ADMINSTER" : "PRINTER_ACCESS_USE" )); + Printer->access_granted = printer_default->access_required; /* @@ -1695,11 +1697,62 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV } +/**************************************************************************** + Internal routine for retreiving printerdata + ***************************************************************************/ + +static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printer, + char *key, char *value, uint32 *type, uint8 **data, + uint32 *needed, uint32 in_size ) +{ + REGISTRY_VALUE *val; + int size, data_len; + + if ( !(val = get_printer_data( printer->info_2, key, value)) ) + return WERR_BADFILE; + + *type = regval_type( val ); + + DEBUG(5,("getprinterdata_printer:allocating %d\n", in_size)); + + size = regval_size( val ); + + /* copy the min(in_size, len) */ + + if ( in_size ) { + data_len = (size > in_size) ? in_size : size*sizeof(uint8); + if ( (*data = (uint8 *)talloc_memdup(ctx, regval_data_p(val), data_len)) == NULL ) + return WERR_NOMEM; + } + else + *data = NULL; + + *needed = size; + + DEBUG(5,("getprinterdata_printer:copy done\n")); + + return WERR_OK; +} + +/**************************************************************************** + Internal routine for storing printerdata + ***************************************************************************/ + +static WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, char *key, char *value, + uint32 type, uint8 *data, int real_len ) +{ + delete_printer_data( printer->info_2, key, value ); + + add_printer_data( printer->info_2, key, value, type, data, real_len ); + + return mod_a_printer(*printer, 2); +} + /******************************************************************** GetPrinterData on a printer server Handle. ********************************************************************/ -static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size) +static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size) { int i; @@ -1708,50 +1761,50 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 if (!strcmp(value, "W3SvcInstalled")) { *type = 0x4; if((*data = (uint8 *)talloc_zero(ctx, 4*sizeof(uint8) )) == NULL) - return False; - *needed = 0x4; - return True; + return WERR_NOMEM; + *needed = 0x4; + return WERR_OK; } if (!strcmp(value, "BeepEnabled")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) - return False; + return WERR_NOMEM; SIVAL(*data, 0, 0x00); *needed = 0x4; - return True; + return WERR_OK; } if (!strcmp(value, "EventLog")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) - return False; + return WERR_NOMEM; /* formally was 0x1b */ SIVAL(*data, 0, 0x0); *needed = 0x4; - return True; + return WERR_OK; } if (!strcmp(value, "NetPopup")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) - return False; + return WERR_NOMEM; SIVAL(*data, 0, 0x00); *needed = 0x4; - return True; + return WERR_OK; } if (!strcmp(value, "MajorVersion")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) - return False; + return WERR_NOMEM; #ifndef EMULATE_WIN2K_HACK /* JERRY */ SIVAL(*data, 0, 2); #else SIVAL(*data, 0, 3); #endif *needed = 0x4; - return True; + return WERR_OK; } if (!strcmp(value, "DefaultSpoolDirectory")) { @@ -1761,7 +1814,7 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type = 0x1; *needed = 2*(strlen(string)+1); if((*data = (uint8 *)talloc(ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) - return False; + return WERR_NOMEM; memset(*data, 0, (*needed > in_size) ? *needed:in_size); /* it's done by hand ready to go on the wire */ @@ -1769,7 +1822,7 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 (*data)[2*i]=string[i]; (*data)[2*i+1]='\0'; } - return True; + return WERR_OK; } if (!strcmp(value, "Architecture")) { @@ -1777,16 +1830,16 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type = 0x1; *needed = 2*(strlen(string)+1); if((*data = (uint8 *)talloc(ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) - return False; + return WERR_NOMEM; memset(*data, 0, (*needed > in_size) ? *needed:in_size); for (i=0; ihandle; - UNISTR2 *valuename = &q_u->valuename; - uint32 in_size = q_u->size; - uint32 *type = &r_u->type; - uint32 *out_size = &r_u->size; - uint8 **data = &r_u->data; - uint32 *needed = &r_u->needed; - - fstring value; - BOOL found=False; - Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + POLICY_HND *handle = &q_u->handle; + UNISTR2 *valuename = &q_u->valuename; + uint32 in_size = q_u->size; + uint32 *type = &r_u->type; + uint32 *out_size = &r_u->size; + uint8 **data = &r_u->data; + uint32 *needed = &r_u->needed; + WERROR status; + fstring value; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum = 0; /* * Reminder: when it's a string, the length is in BYTES @@ -1885,45 +1939,49 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO DEBUG(4,("_spoolss_getprinterdata\n")); - if (!Printer) { + if ( !Printer ) { if((*data=(uint8 *)talloc_zero(p->mem_ctx, 4*sizeof(uint8))) == NULL) return WERR_NOMEM; DEBUG(2,("_spoolss_getprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } + if ( !get_printer_snum(p,handle, &snum) ) + return WERR_BADFID; + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if ( !W_ERROR_IS_OK(status) ) + return status; + unistr2_to_ascii(value, valuename, sizeof(value)-1); - if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) - found = getprinterdata_printer_server(p->mem_ctx, value, type, data, needed, *out_size); + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER ) + status = getprinterdata_printer_server( p->mem_ctx, value, type, data, needed, *out_size ); else - found = getprinterdata_printer(p, p->mem_ctx, handle, value, type, data, needed, *out_size); + status = get_printer_dataex( p->mem_ctx, printer, SPOOL_PRINTERDATA_KEY, value, type, data, needed, in_size ); - if ( !found ) + if ( !W_ERROR_IS_OK(status) ) { DEBUG(5, ("value not found, allocating %d\n", *out_size)); /* reply this param doesn't exist */ - if (*out_size) { + if ( *out_size ) { if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) return WERR_NOMEM; - } else { + } + else *data = NULL; - } - - /* error depends on handle type */ - - if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) - return WERR_INVALID_PARAM; - else - return WERR_BADFILE; } if (*needed > *out_size) - return WERR_MORE_DATA; - else - return WERR_OK; + status = WERR_MORE_DATA; + + /* cleanup & exit */ + + free_a_printer( &printer, 2 ); + + return status; } /********************************************************* @@ -7112,7 +7170,8 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP * when connecting to a printer --jerry */ - if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) + { DEBUG(3, ("_spoolss_setprinterdata: change denied by handle access permissions\n")); status = WERR_ACCESS_DENIED; goto done; @@ -7122,15 +7181,12 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP if (!W_ERROR_IS_OK(status)) return status; - /* save the registry data */ - unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); - delete_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, valuename ); - add_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, valuename, type, data, real_len ); - - /* write the **entire** printer out to disk.... :-( */ - status = mod_a_printer(*printer, 2); + /* save the registry data */ + + status = set_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, valuename, + type, data, real_len ); done: free_a_printer(&printer, 2); @@ -7786,7 +7842,10 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ } /******************************************************************** - * spoolss_getprinterdataex + spoolss_getprinterdataex + + From MSDN documentation of GetPrinterDataEx: pass request + to GetPrinterData if key is "PrinterDriverData". ********************************************************************/ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, SPOOL_R_GETPRINTERDATAEX *r_u) @@ -7797,76 +7856,90 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, uint32 *out_size = &r_u->size; uint8 **data = &r_u->data; uint32 *needed = &r_u->needed; - - fstring key, value; + fstring keyname, valuename; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - BOOL found = False; + + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum = 0; + WERROR status = WERR_OK; DEBUG(4,("_spoolss_getprinterdataex\n")); - unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); - unistr2_to_ascii(value, &q_u->valuename, sizeof(value) - 1); + unistr2_to_ascii(keyname, &q_u->keyname, sizeof(keyname) - 1); + unistr2_to_ascii(valuename, &q_u->valuename, sizeof(valuename) - 1); + + DEBUG(10, ("_spoolss_getprinterdataex: key => [%s], value => [%s]\n", + keyname, valuename)); /* in case of problem, return some default values */ - *needed=0; - *type=0; - *out_size=0; + + *needed = 0; + *type = 0; + *out_size = in_size; - if (!Printer) { if((*data=(uint8 *)talloc_zero(p->mem_ctx, 4*sizeof(uint8))) == NULL) return WERR_NOMEM; - DEBUG(2,("_spoolss_getprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_getprinterdataex: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } - /* Is the handle to a printer or to the server? */ - if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER ) { DEBUG(10,("_spoolss_getprinterdatex: Not implemented for server handles yet\n")); return WERR_INVALID_PARAM; } - else - { - /* - * From MSDN documentation of GetPrinterDataEx: pass request - * to GetPrinterData if key is "PrinterDriverData". This is - * the only key we really support. Other keys to implement: - * (a) DsDriver - * (b) DsSpooler - * (c) PnPData - * (d) DsUser - */ - - if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) - return WERR_BADFILE; + + if ( !get_printer_snum(p,handle, &snum) ) + return WERR_BADFID; - DEBUG(10, ("_spoolss_getprinterdataex: pass me to getprinterdata\n")); - found = getprinterdata_printer(p, p->mem_ctx, handle, value, - type, data, needed, in_size); - + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if ( !W_ERROR_IS_OK(status) ) + return status; + + /* check to see if the keyname is valid */ + if ( !strlen(keyname) ) { + status = WERR_INVALID_PARAM; + goto done; } - - if (!found) { + + if ( lookup_printerkey( &printer->info_2->data, keyname ) == -1 ) { + DEBUG(4,("_spoolss_getprinterdataex: Invalid keyname [%s]\n", keyname )); + status = WERR_BADFILE; + goto done; + } + + /* When given a new keyname, we should just create it */ + + status = get_printer_dataex( p->mem_ctx, printer, keyname, valuename, type, data, needed, in_size ); + + if ( !W_ERROR_IS_OK(status) ) + { DEBUG(5, ("value not found, allocating %d\n", *out_size)); /* reply this param doesn't exist */ - if (*out_size) { - if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) - return WERR_NOMEM; - } else { + + if ( *out_size ) + { + if( (*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL ) { + status = WERR_NOMEM; + goto done; + } + } + else *data = NULL; - } - - return WERR_INVALID_PARAM; } if (*needed > *out_size) - return WERR_MORE_DATA; - else - return WERR_OK; + status = WERR_MORE_DATA; + +done: + free_a_printer( &printer, 2 ); + + return status; } /******************************************************************** @@ -7875,34 +7948,59 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, SPOOL_R_SETPRINTERDATAEX *r_u) { - SPOOL_Q_SETPRINTERDATA q_u_local; - SPOOL_R_SETPRINTERDATA r_u_local; - fstring key; + POLICY_HND *handle = &q_u->handle; + uint32 type = q_u->type; + uint8 *data = q_u->data; + uint32 real_len = q_u->real_len; + + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum = 0; + WERROR status = WERR_OK; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + fstring valuename; + fstring keyname; DEBUG(4,("_spoolss_setprinterdataex\n")); /* From MSDN documentation of SetPrinterDataEx: pass request to SetPrinterData if key is "PrinterDriverData" */ - unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); + if (!Printer) { + DEBUG(2,("_spoolss_setprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); + return WERR_BADFID; + } - if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) - return WERR_INVALID_PARAM; - - ZERO_STRUCT(q_u_local); - ZERO_STRUCT(r_u_local); + if ( !get_printer_snum(p,handle, &snum) ) + return WERR_BADFID; + + /* + * 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 (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) + { + DEBUG(3, ("_spoolss_setprinterdataex: change denied by handle access permissions\n")); + return WERR_ACCESS_DENIED; + } + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + return status; + + unistr2_to_ascii( valuename, &q_u->value, sizeof(valuename) - 1); + unistr2_to_ascii( keyname, &q_u->key, sizeof(keyname) - 1); + + /* save the registry data */ - /* make a copy to call _spoolss_setprinterdata() */ + status = set_printer_dataex( printer, keyname, valuename, type, data, real_len ); - memcpy(&q_u_local.handle, &q_u->handle, sizeof(POLICY_HND)); - copy_unistr2(&q_u_local.value, &q_u->value); - q_u_local.type = q_u->type; - q_u_local.max_len = q_u->max_len; - q_u_local.data = q_u->data; - q_u_local.real_len = q_u->real_len; - q_u_local.numeric_data = q_u->numeric_data; - - return _spoolss_setprinterdata(p, &q_u_local, &r_u_local); + free_a_printer(&printer, 2); + + return status; } -- cgit From 409d7ff3f565b853ac70f92d75a911019c0f254e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sun, 18 Aug 2002 01:02:32 +0000 Subject: fixed up a few comments removed now unused getprinterdata)printer() function (This used to be commit 2d5e4cdc3a4128c6747350d8f66b783218045ce2) --- source3/rpc_server/srv_spoolss_nt.c | 66 ++----------------------------------- 1 file changed, 2 insertions(+), 64 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 02bd0ef45b..b9224dea27 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1713,7 +1713,7 @@ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printe *type = regval_type( val ); - DEBUG(5,("getprinterdata_printer:allocating %d\n", in_size)); + DEBUG(5,("get_printer_dataex: allocating %d\n", in_size)); size = regval_size( val ); @@ -1729,7 +1729,7 @@ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printe *needed = size; - DEBUG(5,("getprinterdata_printer:copy done\n")); + DEBUG(5,("get_printer_dataex: copy done\n")); return WERR_OK; } @@ -1842,68 +1842,6 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint return WERR_INVALID_PARAM; } -/******************************************************************** - GetPrinterData on a printer Handle. -********************************************************************/ - -static BOOL getprinterdata_printer(pipes_struct *p, TALLOC_CTX *ctx, POLICY_HND *handle, - fstring value, uint32 *type, - uint8 **data, uint32 *needed, uint32 in_size ) -{ - NT_PRINTER_INFO_LEVEL *printer = NULL; - int snum=0; - Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - REGISTRY_VALUE *val; - int size = 0; - - DEBUG(5,("getprinterdata_printer\n")); - - if ( !Printer ) { - DEBUG(2,("getprinterdata_printer: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); - return False; - } - - if ( !get_printer_snum(p, handle, &snum) ) - return False; - - if ( !W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum))) ) - return False; - - if ( !(val = get_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, value)) ) - { - free_a_printer(&printer, 2); - return False; - } - - *type = regval_type( val ); - - - DEBUG(5,("getprinterdata_printer:allocating %d\n", in_size)); - - if (in_size) - { - if ( (*data = (uint8 *)talloc(ctx, in_size * sizeof(uint8))) == NULL ) - return False; - - memset( *data, 0, in_size *sizeof(uint8) ); - - /* copy the min(in_size, len) */ - - size = regval_size( val ); - memcpy( *data, regval_data_p(val), (size > in_size) ? in_size : size*sizeof(uint8) ); - } - else - *data = NULL; - - *needed = size; - - DEBUG(5,("getprinterdata_printer:copy done\n")); - - - free_a_printer(&printer, 2); - return True; -} - /******************************************************************** * spoolss_getprinterdata ********************************************************************/ -- cgit From caf8f949b6876c6c6ebab135a8403ba550e27d6d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sun, 18 Aug 2002 02:10:07 +0000 Subject: * small formatting fixes * Fix EnumPrinterKey() to enumerate all printer keys ( this will break if we have more than one level deep of printer keys ) (This used to be commit e72184ce13a5645dc1e1a137468207270ed20ed6) --- source3/rpc_server/srv_spoolss_nt.c | 136 +++++++++++++++++++++--------------- 1 file changed, 79 insertions(+), 57 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b9224dea27..cbafe982be 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4380,7 +4380,7 @@ static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fst * convert an array of ascii string to a UNICODE string ********************************************************************/ -static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *servername) +static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, char *servername) { int i=0; int j=0; @@ -4393,23 +4393,31 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser while (True) { - if (char_array == NULL) + if ( !char_array ) v = ""; - else { + else + { v = char_array[i]; - if (!v) v = ""; /* hack to handle null lists */ + if (!v) + v = ""; /* hack to handle null lists */ } if ( !strlen(v) ) break; - - slprintf(line, sizeof(line)-1, "\\\\%s%s", servername, v); + /* hack to allow this to be used in places other than when generating + the list of dependent files */ + + if ( servername ) + slprintf( line, sizeof(line)-1, "\\\\%s%s", servername, v ); + else + pstrcpy( line, v ); + DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); - if((tuary=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL) { + if ( (tuary=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL ) { DEBUG(2,("init_unistr_array: Realloc error\n" )); - return; + return 0; } else *uni_array = tuary; @@ -4422,6 +4430,10 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser } DEBUGADD(6,("last one:done\n")); + + /* return size of array in uint16's */ + + return j+1; } /******************************************************************** @@ -4440,29 +4452,29 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->name, driver.info_3->name ); init_unistr( &info->architecture, driver.info_3->environment ); - if (strlen(driver.info_3->driverpath)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); - init_unistr( &info->driverpath, temp ); - } else - init_unistr( &info->driverpath, "" ); + if (strlen(driver.info_3->driverpath)) { + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + init_unistr( &info->driverpath, temp ); + } else + init_unistr( &info->driverpath, "" ); - if (strlen(driver.info_3->datafile)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); - init_unistr( &info->datafile, temp ); - } else - init_unistr( &info->datafile, "" ); + if (strlen(driver.info_3->datafile)) { + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); + init_unistr( &info->datafile, temp ); + } else + init_unistr( &info->datafile, "" ); - if (strlen(driver.info_3->configfile)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); - init_unistr( &info->configfile, temp ); - } else - init_unistr( &info->configfile, "" ); + if (strlen(driver.info_3->configfile)) { + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); + init_unistr( &info->configfile, temp ); + } else + init_unistr( &info->configfile, "" ); - if (strlen(driver.info_3->helpfile)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile); - init_unistr( &info->helpfile, temp ); - } else - init_unistr( &info->helpfile, "" ); + if (strlen(driver.info_3->helpfile)) { + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile); + init_unistr( &info->helpfile, temp ); + } else + init_unistr( &info->helpfile, "" ); init_unistr( &info->monitorname, driver.info_3->monitorname ); init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype ); @@ -7976,46 +7988,56 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPOOL_R_ENUMPRINTERKEY *r_u) { - fstring key; - uint16 *enumkeys = NULL; - char* ptr = NULL; - int i; - int printerkey_len = strlen(SPOOL_PRINTERDATA_KEY)+1; - + fstring key; + fstring *keynames; + uint16 *enumkeys = NULL; + int printerkey_len; + int i; + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + NT_PRINTER_DATA *data; + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum = 0; + WERROR status; + + DEBUG(4,("_spoolss_enumprinterkey\n")); + if (!Printer) { + DEBUG(2,("_spoolss_enumprinterkey: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); + return WERR_BADFID; + } + + if ( !get_printer_snum(p,handle, &snum) ) + return WERR_BADFID; + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + return status; + unistr2_to_ascii( key, &q_u->key, sizeof(key)-1 ); - /* - * we only support enumating all keys (key == "") - * Of course, the only key we support is the "PrinterDriverData" - * key - */ + /* enumerating all keys if (key == "") */ + data = &printer->info_2->data; + if ( !strlen( key ) ) { + keynames = talloc_zero( p->mem_ctx, (data->num_keys+1)*sizeof(fstring) ); + + /* make an array of all the keynames */ + + for ( i=0; inum_keys; i++ ) + fstrcpy( keynames[i], data->keys[i].name ); + fstrcpy( keynames[i], "" ); + + printerkey_len = init_unistr_array( &enumkeys, keynames, NULL ); + r_u->needed = printerkey_len*2; if ( q_u->size < r_u->needed ) return WERR_MORE_DATA; - - if ( !(enumkeys = talloc( p->mem_ctx, printerkey_len*2 )) ) { - DEBUG(0,("_spoolss_enumprinterkey: talloc() failed for [%d] bytes!\n", - printerkey_len)); - return WERR_NOMEM; - } - - ptr = SPOOL_PRINTERDATA_KEY; - for ( i=0; i<(printerkey_len-1); i++ ) - { - enumkeys[i] = (uint16)(*ptr); - ptr++; - } - - /* tag of '\0's */ - - enumkeys[i] = 0x0; - + if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, printerkey_len, enumkeys)) return WERR_BADFILE; -- cgit From 50d224a898fa130460bba4009e18fb54b1390168 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sun, 18 Aug 2002 11:11:48 +0000 Subject: fix to allow EnumPrinterKey() to enumerate multiple levels of subkeys. Works on the top level. Needs more testing for levels > 1. (This used to be commit 32a7083843f2bf9a3f32027189dbb0ff92927cd4) --- source3/rpc_server/srv_spoolss_nt.c | 87 +++++++++++++++---------------------- 1 file changed, 36 insertions(+), 51 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cbafe982be..7286fef528 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4402,9 +4402,6 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, char *s v = ""; /* hack to handle null lists */ } - if ( !strlen(v) ) - break; - /* hack to allow this to be used in places other than when generating the list of dependent files */ @@ -4421,6 +4418,9 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, char *s } else *uni_array = tuary; + if ( !strlen(v) ) + break; + j += (rpcstr_push((*uni_array+j), line, sizeof(uint16)*strlen(line)+2, STR_TERMINATE) / sizeof(uint16)); i++; } @@ -7989,16 +7989,16 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPOOL_R_ENUMPRINTERKEY *r_u) { fstring key; - fstring *keynames; + fstring *keynames = NULL; uint16 *enumkeys = NULL; + int num_keys; int printerkey_len; - int i; POLICY_HND *handle = &q_u->handle; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); NT_PRINTER_DATA *data; NT_PRINTER_INFO_LEVEL *printer = NULL; int snum = 0; - WERROR status; + WERROR status = WERR_BADFILE; DEBUG(4,("_spoolss_enumprinterkey\n")); @@ -8015,56 +8015,42 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO if (!W_ERROR_IS_OK(status)) return status; + /* get the list of subkey names */ + unistr2_to_ascii( key, &q_u->key, sizeof(key)-1 ); + data = &printer->info_2->data; - /* enumerating all keys if (key == "") */ + num_keys = get_printer_subkeys( data, key, &keynames ); - data = &printer->info_2->data; - - if ( !strlen( key ) ) - { - keynames = talloc_zero( p->mem_ctx, (data->num_keys+1)*sizeof(fstring) ); - - /* make an array of all the keynames */ - - for ( i=0; inum_keys; i++ ) - fstrcpy( keynames[i], data->keys[i].name ); - fstrcpy( keynames[i], "" ); - - printerkey_len = init_unistr_array( &enumkeys, keynames, NULL ); - - r_u->needed = printerkey_len*2; - - if ( q_u->size < r_u->needed ) - return WERR_MORE_DATA; - - if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, printerkey_len, enumkeys)) - return WERR_BADFILE; - - return WERR_OK; + if ( num_keys == -1 ) { + status = WERR_BADFILE; + goto done; } - - /* The "PrinterDriverData" key should have no subkeys */ - if ( strcmp(key, SPOOL_PRINTERDATA_KEY) == 0 ) - { - uint16 dummy_key = 0; - - r_u->needed = 2; - - if (q_u->size < r_u->needed) - return WERR_MORE_DATA; - - if ( !make_spoolss_buffer5(p->mem_ctx, &r_u->keys, 1, &dummy_key ) ) - return WERR_BADFILE; - - return WERR_OK; + + printerkey_len = init_unistr_array( &enumkeys, keynames, NULL ); + + r_u->needed = printerkey_len*2; + + if ( q_u->size < r_u->needed ) { + status = WERR_MORE_DATA; + goto done; } - - /* The return value for an unknown key is documented in MSDN - EnumPrinterKey description */ - - return WERR_BADFILE; + if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, printerkey_len, enumkeys)) { + status = WERR_NOMEM; + goto done; + } + + status = WERR_OK; + + if ( q_u->size < r_u->needed ) + status = WERR_MORE_DATA; + +done: + free_a_printer( &printer, 2 ); + SAFE_FREE( keynames ); + + return status; } /******************************************************************** @@ -8126,7 +8112,6 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ return WERR_BADFID; } - /* first get the printer off of disk */ if (!get_printer_snum(p,handle, &snum)) -- cgit From 12be900eceab860ff32d34cdd0cf8da8543c1082 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sun, 18 Aug 2002 16:52:51 +0000 Subject: * Fix DeletePrinterDataEx() to work with arbitrary registry keys * Fix delete_all_printer_data() to accept a key name for partial tree deletions * Fix EnumPrinterKey() to work with subkeys * Fix DeletePrinterKey() to work with ful or partial registry trees * Fix get_printer_subkeys() to return a list of unique keynames ( some were getting added twice due to subkeys names ) * fix a couple of typos for good measure (This used to be commit b6ceb8c2e50b7fcdc614a3b6782db05b60689a85) --- source3/rpc_server/srv_spoolss_nt.c | 101 +++++++++++++++++++++++++----------- 1 file changed, 72 insertions(+), 29 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7286fef528..2cf73d7118 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1297,7 +1297,7 @@ Can't find printer handle we created for printer %s\n", name )); printer_default->access_required = PRINTER_ACCESS_USE; DEBUG(4,("Setting printer access = %s\n", (printer_default->access_required == PRINTER_ACCESS_ADMINISTER) - ? "PRINTER_ACCESS_ADMINSTER" : "PRINTER_ACCESS_USE" )); + ? "PRINTER_ACCESS_ADMINISTER" : "PRINTER_ACCESS_USE" )); Printer->access_granted = printer_default->access_required; @@ -7211,7 +7211,7 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); status = delete_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, valuename ); - if ( NT_STATUS_IS_OK(status) ) + if ( W_ERROR_IS_OK(status) ) status = mod_a_printer(*printer, 2); free_a_printer(&printer, 2); @@ -7960,26 +7960,46 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX *q_u, SPOOL_R_DELETEPRINTERDATAEX *r_u) { - SPOOL_Q_DELETEPRINTERDATA q_u_local; - SPOOL_R_DELETEPRINTERDATA r_u_local; - fstring key; - - /* From MSDN documentation of SetPrinterDataEx: pass request to - SetPrinterData if key is "PrinterDriverData" */ - - unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); + POLICY_HND *handle = &q_u->handle; + UNISTR2 *value = &q_u->valuename; + UNISTR2 *key = &q_u->keyname; - if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) - return WERR_INVALID_PARAM; + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum=0; + WERROR status = WERR_OK; + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); + pstring valuename, keyname; - memcpy(&q_u_local.handle, &q_u->handle, sizeof(POLICY_HND)); - copy_unistr2(&q_u_local.valuename, &q_u->valuename); + DEBUG(5,("spoolss_deleteprinterdataex\n")); - return _spoolss_deleteprinterdata( p, &q_u_local, &r_u_local ); -} + if (!Printer) { + DEBUG(2,("_spoolss_deleteprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); + return WERR_BADFID; + } + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + DEBUG(3, ("_spoolss_deleteprinterdataex: printer properties change denied by handle\n")); + return WERR_ACCESS_DENIED; + } + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + return status; + + unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); + unistr2_to_ascii( keyname, key, sizeof(keyname)-1 ); + + status = delete_printer_data( printer->info_2, keyname, valuename ); + if ( W_ERROR_IS_OK(status) ) + status = mod_a_printer(*printer, 2); + + free_a_printer(&printer, 2); + return status; +} /******************************************************************** * spoolss_enumprinterkey @@ -8059,25 +8079,48 @@ done: WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, SPOOL_R_DELETEPRINTERKEY *r_u) { - Printer_entry *Printer = find_printer_index_by_hnd(p, &q_u->handle); - fstring key; + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer = find_printer_index_by_hnd(p, &q_u->handle); + fstring key; + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum=0; + WERROR status; + + DEBUG(5,("spoolss_deleteprinterkey\n")); if (!Printer) { - DEBUG(2,("_spoolss_deleteprinterkey: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(&q_u->handle))); + DEBUG(2,("_spoolss_deleteprinterkey: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } - - unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); - if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) - return WERR_INVALID_PARAM; + /* if keyname == NULL, return error */ + + if ( !q_u->keyname.buffer ) + return WERR_INVALID_PARAM; - /* - * this is what 2k returns when you try to delete the "PrinterDriverData" - * key - */ - - return WERR_ACCESS_DENIED; + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + DEBUG(3, ("_spoolss_deleteprinterkey: printer properties change denied by handle\n")); + return WERR_ACCESS_DENIED; + } + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + return status; + + /* delete the key and all subneys */ + + unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); + + status = delete_all_printer_data( printer->info_2, key ); + if ( W_ERROR_IS_OK(status) ) + status = mod_a_printer(*printer, 2); + + free_a_printer( &printer, 2 ); + + return status; } -- cgit From 0231bb451d16ac8cc2734969542eb46d1b9028c3 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 19 Aug 2002 01:56:15 +0000 Subject: change notify fix left out of merge by APP_HEAD by accident (This used to be commit a413ff8b494e63b42fab213f12b44df6a5f0c34c) --- source3/rpc_server/srv_spoolss_nt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2cf73d7118..834ad7f61a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2432,8 +2432,9 @@ static void spoolss_notify_security_desc(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - data->notify_data.data.length=0; data->notify_data.data.string = NULL; + data->notify_data.sd.size = printer->info_2->secdesc_buf->len; + data->notify_data.sd.desc = dup_sec_desc( mem_ctx, printer->info_2->secdesc_buf->sec ) ; } /******************************************************************* -- cgit From 2b93ecc90b79d95455b19e46082f1b0039b71e35 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 19 Aug 2002 02:18:48 +0000 Subject: added wrapper for delete_printer_data() that write the printer out to disk. (This used to be commit 113d960d77fc9e3671a448d093237ced25c2e18c) --- source3/rpc_server/srv_spoolss_nt.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 834ad7f61a..ae478d7c68 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1734,6 +1734,17 @@ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printe return WERR_OK; } +/**************************************************************************** + Internal routine for removing printerdata + ***************************************************************************/ + +static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, char *key, char *value ) +{ + delete_printer_data( printer->info_2, key, value ); + + return mod_a_printer(*printer, 2); +} + /**************************************************************************** Internal routine for storing printerdata ***************************************************************************/ @@ -7211,9 +7222,7 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); - status = delete_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, valuename ); - if ( W_ERROR_IS_OK(status) ) - status = mod_a_printer(*printer, 2); + status = delete_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, valuename ); free_a_printer(&printer, 2); @@ -7894,7 +7903,7 @@ done: } /******************************************************************** - * spoolss_setprinterdata + * spoolss_setprinterdataex ********************************************************************/ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, SPOOL_R_SETPRINTERDATAEX *r_u) @@ -7993,9 +8002,7 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); unistr2_to_ascii( keyname, key, sizeof(keyname)-1 ); - status = delete_printer_data( printer->info_2, keyname, valuename ); - if ( W_ERROR_IS_OK(status) ) - status = mod_a_printer(*printer, 2); + status = delete_printer_dataex( printer, keyname, valuename ); free_a_printer(&printer, 2); @@ -8116,6 +8123,7 @@ WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); status = delete_all_printer_data( printer->info_2, key ); + if ( W_ERROR_IS_OK(status) ) status = mod_a_printer(*printer, 2); -- cgit From 11b71419b0bcefc90c1567f31268151aee81098c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 19 Aug 2002 21:17:22 +0000 Subject: add support for the "value,OID" format described in MSDN. I've not seen this on a real network, but we support it now :-) (This used to be commit 1ed6f68f6f29e1a62b12764ec5e84de8351efbd3) --- source3/rpc_server/srv_spoolss_nt.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ae478d7c68..ae7cf2d953 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7919,7 +7919,9 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, Printer_entry *Printer = find_printer_index_by_hnd(p, handle); fstring valuename; fstring keyname; - + char *oid_string; + UNISTR2 uni_oid; + DEBUG(4,("_spoolss_setprinterdataex\n")); /* From MSDN documentation of SetPrinterDataEx: pass request to @@ -7953,11 +7955,39 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, unistr2_to_ascii( valuename, &q_u->value, sizeof(valuename) - 1); unistr2_to_ascii( keyname, &q_u->key, sizeof(keyname) - 1); + + /* check for OID in valuename */ + + if ( (oid_string = strchr( valuename, ',' )) != NULL ) + { + *oid_string = '\0'; + oid_string++; + } /* save the registry data */ status = set_printer_dataex( printer, keyname, valuename, type, data, real_len ); + + /* save the OID if one was specified and the previous set call succeeded */ + + if ( W_ERROR_IS_OK(status) && oid_string ) + { + fstrcat( keyname, "\\" ); + fstrcat( keyname, SPOOL_OID_KEY ); + + /* + * I'm not checking the status here on purpose. Don't know + * if this is right, but I'm returning the status from the + * previous set_printer_dataex() call. I have no idea if + * this is right. --jerry + */ + + init_unistr2( &uni_oid, oid_string, strlen(oid_string)+1 ); + set_printer_dataex( printer, keyname, valuename, + REG_SZ, (void*)uni_oid.buffer, uni_oid.uni_str_len*sizeof(uint16) ); + } + free_a_printer(&printer, 2); return status; -- cgit From 8674440d81f703cb59979426c92ed54de8e5f2ed Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 20 Aug 2002 01:54:28 +0000 Subject: Based orginally by work by Kai, this patch moves our NT_TOKEN generation into our authenticaion code - removing some of the duplication from the current code. This also gets us *much* closer to supporting a real SAM backend, becouse the SAM can give us the right info then. This also changes our service.c code, so that we do a VUID (rather than uid) cache on the connection struct, and do full NT ACL/NT_TOKEN checks (or cached equivilant) on every packet, for the same r or rw mode the whole share was open for. Andrew Bartlett (This used to be commit d8122cee059fc7098bfa7e42e638a9958b3ac902) --- source3/rpc_server/srv_pipe.c | 35 +++++++++++++++++++---------------- source3/rpc_server/srv_srvsvc_nt.c | 6 +++--- 2 files changed, 22 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index b7be415abc..62e10c9965 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -427,27 +427,30 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); memcpy(p->session_key, server_info->session_key, sizeof(p->session_key)); - uid = pdb_get_uid(server_info->sam_account); - gid = pdb_get_gid(server_info->sam_account); - - p->pipe_user.uid = uid; - p->pipe_user.gid = gid; - - /* Set up pipe user group membership. */ - initialise_groups(p->pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); - get_current_groups(p->pipe_user.gid, &p->pipe_user.ngroups, &p->pipe_user.groups); + p->pipe_user.uid = pdb_get_uid(server_info->sam_account); + p->pipe_user.gid = pdb_get_gid(server_info->sam_account); + + p->pipe_user.ngroups = server_info->n_groups; + if (p->pipe_user.ngroups) { + if (!(p->pipe_user.groups = memdup(server_info->groups, sizeof(gid_t) * p->pipe_user.ngroups))) { + DEBUG(0,("failed to memdup group list to p->pipe_user.groups\n")); + free_server_info(&server_info); + return False; + } + } if (server_info->ptok) - add_supplementary_nt_login_groups(&p->pipe_user.ngroups, &p->pipe_user.groups, &server_info->ptok); - - /* Create an NT_USER_TOKEN struct for this user. */ - p->pipe_user.nt_user_token = create_nt_token(p->pipe_user.uid,p->pipe_user.gid, - p->pipe_user.ngroups, p->pipe_user.groups, - server_info->guest, server_info->ptok); + p->pipe_user.nt_user_token = dup_nt_token(server_info->ptok); + else { + DEBUG(1,("Error: Authmodule failed to provide nt_user_token\n")); + p->pipe_user.nt_user_token = NULL; + free_server_info(&server_info); + return False; + } p->ntlmssp_auth_validated = True; - pdb_free_sam(&server_info->sam_account); + free_server_info(&server_info); return True; } diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 5c1038949b..69945b50b8 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -338,10 +338,10 @@ BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, u if (!psd) goto out; - if (vuser) - token = vuser->nt_user_token; - else + if (conn->nt_user_token) token = conn->nt_user_token; + else + token = vuser->nt_user_token; ret = se_access_check(psd, token, desired_access, &granted, &status); -- cgit From 42045afda9853351af14a95d711ebbb64e532330 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 20 Aug 2002 03:01:37 +0000 Subject: segfault fixes merged from APP_HEAD (This used to be commit cd9ee27d89a5cd489efac2029c22797ec9c383ca) --- source3/rpc_server/srv_spoolss_nt.c | 74 +++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ae7cf2d953..5373eeed63 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1889,46 +1889,55 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO DEBUG(4,("_spoolss_getprinterdata\n")); if ( !Printer ) { - if((*data=(uint8 *)talloc_zero(p->mem_ctx, 4*sizeof(uint8))) == NULL) - return WERR_NOMEM; DEBUG(2,("_spoolss_getprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); - return WERR_BADFID; + status = WERR_BADFID; + goto done; } - if ( !get_printer_snum(p,handle, &snum) ) - return WERR_BADFID; - - status = get_a_printer(&printer, 2, lp_servicename(snum)); - if ( !W_ERROR_IS_OK(status) ) - return status; - unistr2_to_ascii(value, valuename, sizeof(value)-1); if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER ) status = getprinterdata_printer_server( p->mem_ctx, value, type, data, needed, *out_size ); else - status = get_printer_dataex( p->mem_ctx, printer, SPOOL_PRINTERDATA_KEY, value, type, data, needed, in_size ); + { + if ( !get_printer_snum(p,handle, &snum) ) { + status = WERR_BADFID; + goto done; + } + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if ( !W_ERROR_IS_OK(status) ) + goto done; + + status = get_printer_dataex( p->mem_ctx, printer, SPOOL_PRINTERDATA_KEY, value, type, data, needed, *out_size ); + } + + if (*needed > *out_size) + status = WERR_MORE_DATA; + +done: if ( !W_ERROR_IS_OK(status) ) { - DEBUG(5, ("value not found, allocating %d\n", *out_size)); + DEBUG(5, ("error: allocating %d\n", *out_size)); /* reply this param doesn't exist */ if ( *out_size ) { - if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) + if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) { + if ( printer ) + free_a_printer( &printer, 2 ); return WERR_NOMEM; } - else + } + else { *data = NULL; + } } - if (*needed > *out_size) - status = WERR_MORE_DATA; - /* cleanup & exit */ - free_a_printer( &printer, 2 ); + if ( printer ) + free_a_printer( &printer, 2 ); return status; } @@ -2443,7 +2452,6 @@ static void spoolss_notify_security_desc(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - data->notify_data.data.string = NULL; data->notify_data.sd.size = printer->info_2->secdesc_buf->len; data->notify_data.sd.desc = dup_sec_desc( mem_ctx, printer->info_2->secdesc_buf->sec ) ; } @@ -7839,18 +7847,17 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, *out_size = in_size; if (!Printer) { - if((*data=(uint8 *)talloc_zero(p->mem_ctx, 4*sizeof(uint8))) == NULL) - return WERR_NOMEM; DEBUG(2,("_spoolss_getprinterdataex: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); - return WERR_BADFID; + status = WERR_BADFID; + goto done; } /* Is the handle to a printer or to the server? */ - if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER ) - { + if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) { DEBUG(10,("_spoolss_getprinterdatex: Not implemented for server handles yet\n")); - return WERR_INVALID_PARAM; + status = WERR_INVALID_PARAM; + goto done; } if ( !get_printer_snum(p,handle, &snum) ) @@ -7858,7 +7865,7 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, status = get_a_printer(&printer, 2, lp_servicename(snum)); if ( !W_ERROR_IS_OK(status) ) - return status; + goto done; /* check to see if the keyname is valid */ if ( !strlen(keyname) ) { @@ -7868,6 +7875,7 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, if ( lookup_printerkey( &printer->info_2->data, keyname ) == -1 ) { DEBUG(4,("_spoolss_getprinterdataex: Invalid keyname [%s]\n", keyname )); + free_a_printer( &printer, 2 ); status = WERR_BADFILE; goto done; } @@ -7876,9 +7884,13 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, status = get_printer_dataex( p->mem_ctx, printer, keyname, valuename, type, data, needed, in_size ); + if (*needed > *out_size) + status = WERR_MORE_DATA; + +done: if ( !W_ERROR_IS_OK(status) ) { - DEBUG(5, ("value not found, allocating %d\n", *out_size)); + DEBUG(5, ("error: allocating %d\n", *out_size)); /* reply this param doesn't exist */ @@ -7889,14 +7901,12 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, goto done; } } - else + else { *data = NULL; } + } - if (*needed > *out_size) - status = WERR_MORE_DATA; - -done: + if ( printer ) free_a_printer( &printer, 2 ); return status; -- cgit From 85b7d9904e964f3038ad9d317518ae3bc6235545 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 21 Aug 2002 01:47:29 +0000 Subject: addform fix from SAMBA_2_2 (This used to be commit db286e66ec4788b40e279fd230b2013f311e44ec) --- source3/rpc_server/srv_spoolss_nt.c | 46 +++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5373eeed63..296d9a8ca2 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7259,40 +7259,52 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM DEBUG(2,("_spoolss_addform: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } - - if (!get_printer_snum(p,handle, &snum)) - return WERR_BADFID; + + + /* forms can be added on printer of on the print server handle */ + + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + { + if (!get_printer_snum(p,handle, &snum)) + return WERR_BADFID; + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + goto done; + } if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { DEBUG(2,("_spoolss_addform: denied by handle permissions.\n")); status = WERR_ACCESS_DENIED; goto done; } - + /* can't add if builtin */ + if (get_a_builtin_ntform(&form->name,&tmpForm)) { - return WERR_ALREADY_EXISTS; + status = WERR_ALREADY_EXISTS; + goto done; } - count=get_ntforms(&list); - if(!add_a_form(&list, form, &count)) - return WERR_NOMEM; + count = get_ntforms(&list); + + if(!add_a_form(&list, form, &count)) { + status = WERR_NOMEM; + goto done; + } + write_ntforms(&list, count); /* - * ChangeID must always be set + * ChangeID must always be set if this is a printer */ - status = get_a_printer(&printer, 2, lp_servicename(snum)); - if (!W_ERROR_IS_OK(status)) - goto done; - - status = mod_a_printer(*printer, 2); - if (!W_ERROR_IS_OK(status)) - goto done; + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + status = mod_a_printer(*printer, 2); done: - free_a_printer(&printer, 2); + if ( printer ) + free_a_printer(&printer, 2); SAFE_FREE(list); return status; -- cgit From c9c404b26cb82b155f9170bc0dc2b6ba934531e4 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 22 Aug 2002 03:12:10 +0000 Subject: get the access check in addform() correct this time. Needed to modify OpenPrinter() to store the access granted to on the print server handle as well. (This used to be commit 08b3f9688c6c3c83ad8949e6346d8fab5e563df4) --- source3/rpc_server/srv_spoolss_nt.c | 205 +++++++++++++++++------------------- 1 file changed, 94 insertions(+), 111 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 296d9a8ca2..a9c09b9107 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1143,7 +1143,58 @@ WERROR _spoolss_open_printer(pipes_struct *p, SPOOL_Q_OPEN_PRINTER *q_u, SPOOL_R /******************************************************************** * spoolss_open_printer * - * called from the spoolss dispatcher + * If the openprinterex rpc call contains a devmode, + * it's a per-user one. This per-user devmode is derivated + * from the global devmode. Openprinterex() contains a per-user + * devmode for when you do EMF printing and spooling. + * In the EMF case, the NT workstation is only doing half the job + * of rendering the page. The other half is done by running the printer + * driver on the server. + * The EMF file doesn't contain the page description (paper size, orientation, ...). + * The EMF file only contains what is to be printed on the page. + * So in order for the server to know how to print, the NT client sends + * a devicemode attached to the openprinterex call. + * But this devicemode is short lived, it's only valid for the current print job. + * + * If Samba would have supported EMF spooling, this devicemode would + * have been attached to the handle, to sent it to the driver to correctly + * rasterize the EMF file. + * + * As Samba only supports RAW spooling, we only receive a ready-to-print file, + * we just act as a pass-thru between windows and the printer. + * + * In order to know that Samba supports only RAW spooling, NT has to call + * getprinter() at level 2 (attribute field) or NT has to call startdoc() + * and until NT sends a RAW job, we refuse it. + * + * But to call getprinter() or startdoc(), you first need a valid handle, + * and to get an handle you have to call openprintex(). Hence why you have + * a devicemode in the openprinterex() call. + * + * + * Differences between NT4 and NT 2000. + * NT4: + * --- + * On NT4, you only have a global devicemode. This global devicemode can be changed + * by the administrator (or by a user with enough privs). Everytime a user + * wants to print, the devicemode is resetted to the default. In Word, everytime + * you print, the printer's characteristics are always reset to the global devicemode. + * + * NT 2000: + * ------- + * In W2K, there is the notion of per-user devicemode. The first time you use + * a printer, a per-user devicemode is build from the global devicemode. + * If you change your per-user devicemode, it is saved in the registry, under the + * H_KEY_CURRENT_KEY sub_tree. So that everytime you print, you have your default + * printer preferences available. + * + * To change the per-user devicemode: it's the "Printing Preferences ..." button + * on the General Tab of the printer properties windows. + * + * To change the global devicemode: it's the "Printing Defaults..." button + * on the Advanced Tab of the printer properties window. + * + * JFM. ********************************************************************/ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, SPOOL_R_OPEN_PRINTER_EX *r_u) @@ -1180,39 +1231,36 @@ Can't find printer handle we created for printer %s\n", name )); return WERR_INVALID_PRINTER_NAME; } - /* - First case: the user is opening the print server: - - Disallow MS AddPrinterWizard if parameter disables it. A Win2k - client 1st tries an OpenPrinterEx with access==0, MUST be allowed. - - Then both Win2k and WinNT clients try an OpenPrinterEx with - SERVER_ALL_ACCESS, which we allow only if the user is root (uid=0) - or if the user is listed in the smb.conf printer admin parameter. - - Then they try OpenPrinterEx with SERVER_READ which we allow. This lets the - client view printer folder, but does not show the MSAPW. - - Note: this test needs code to check access rights here too. Jeremy - could you look at this? - - - Second case: the user is opening a printer: - NT doesn't let us connect to a printer if the connecting user - doesn't have print permission. - - */ - get_current_user(&user, p); - if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) { + /* + * First case: the user is opening the print server: + * + * Disallow MS AddPrinterWizard if parameter disables it. A Win2k + * client 1st tries an OpenPrinterEx with access==0, MUST be allowed. + * + * Then both Win2k and WinNT clients try an OpenPrinterEx with + * SERVER_ALL_ACCESS, which we allow only if the user is root (uid=0) + * or if the user is listed in the smb.conf printer admin parameter. + * + * Then they try OpenPrinterEx with SERVER_READ which we allow. This lets the + * client view printer folder, but does not show the MSAPW. + * + * Note: this test needs code to check access rights here too. Jeremy + * could you look at this? + * + * Second case: the user is opening a printer: + * NT doesn't let us connect to a printer if the connecting user + * doesn't have print permission. + */ + if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + { /* Printserver handles use global struct... */ snum = -1; - /* Map standard access rights to object specific access - rights */ + /* Map standard access rights to object specific access rights */ se_map_standard(&printer_default->access_required, &printserver_std_mapping); @@ -1233,21 +1281,30 @@ Can't find printer handle we created for printer %s\n", name )); if ( printer_default->access_required & SERVER_ACCESS_ADMINISTER ) { - if (!lp_ms_add_printer_wizard()) { close_printer_handle(p, handle); return WERR_ACCESS_DENIED; } - if (user.uid == 0 || - user_in_list(uidtoname(user.uid), - lp_printer_admin(snum))) - return WERR_OK; + /* if the user is not root and not a printer admin, then fail */ - close_printer_handle(p, handle); - return WERR_ACCESS_DENIED; + if ( user.uid != 0 + && !user_in_list(uidtoname(user.uid), lp_printer_admin(snum)) ) + { + close_printer_handle(p, handle); + return WERR_ACCESS_DENIED; + } + + printer_default->access_required = SERVER_ACCESS_ADMINISTER; + } + else + { + printer_default->access_required = SERVER_ACCESS_ENUMERATE; } + DEBUG(4,("Setting print server access = %s\n", (printer_default->access_required == SERVER_ACCESS_ADMINISTER) + ? "SERVER_ACCESS_ADMINISTER" : "SERVER_ACCESS_ENUMERATE" )); + /* We fall through to return WERR_OK */ } @@ -1299,83 +1356,9 @@ Can't find printer handle we created for printer %s\n", name )); DEBUG(4,("Setting printer access = %s\n", (printer_default->access_required == PRINTER_ACCESS_ADMINISTER) ? "PRINTER_ACCESS_ADMINISTER" : "PRINTER_ACCESS_USE" )); - Printer->access_granted = printer_default->access_required; - - /* - * If we have a default device pointer in the - * printer_default struct, then we need to get - * the printer info from the tdb and if there is - * no default devicemode there then we do a *SET* - * here ! This is insanity.... JRA. - */ - - /* - * If the openprinterex rpc call contains a devmode, - * it's a per-user one. This per-user devmode is derivated - * from the global devmode. Openprinterex() contains a per-user - * devmode for when you do EMF printing and spooling. - * In the EMF case, the NT workstation is only doing half the job - * of rendering the page. The other half is done by running the printer - * driver on the server. - * The EMF file doesn't contain the page description (paper size, orientation, ...). - * The EMF file only contains what is to be printed on the page. - * So in order for the server to know how to print, the NT client sends - * a devicemode attached to the openprinterex call. - * But this devicemode is short lived, it's only valid for the current print job. - * - * If Samba would have supported EMF spooling, this devicemode would - * have been attached to the handle, to sent it to the driver to correctly - * rasterize the EMF file. - * - * As Samba only supports RAW spooling, we only receive a ready-to-print file, - * we just act as a pass-thru between windows and the printer. - * - * In order to know that Samba supports only RAW spooling, NT has to call - * getprinter() at level 2 (attribute field) or NT has to call startdoc() - * and until NT sends a RAW job, we refuse it. - * - * But to call getprinter() or startdoc(), you first need a valid handle, - * and to get an handle you have to call openprintex(). Hence why you have - * a devicemode in the openprinterex() call. - * - * - * Differences between NT4 and NT 2000. - * NT4: - * --- - * On NT4, you only have a global devicemode. This global devicemode can be changed - * by the administrator (or by a user with enough privs). Everytime a user - * wants to print, the devicemode is resetted to the default. In Word, everytime - * you print, the printer's characteristics are always reset to the global devicemode. - * - * NT 2000: - * ------- - * In W2K, there is the notion of per-user devicemode. The first time you use - * a printer, a per-user devicemode is build from the global devicemode. - * If you change your per-user devicemode, it is saved in the registry, under the - * H_KEY_CURRENT_KEY sub_tree. So that everytime you print, you have your default - * printer preferences available. - * - * To change the per-user devicemode: it's the "Printing Preferences ..." button - * on the General Tab of the printer properties windows. - * - * To change the global devicemode: it's the "Printing Defaults..." button - * on the Advanced Tab of the printer properties window. - * - * JFM. - */ - - - -#if 0 - if (printer_default->devmode_cont.devmode != NULL) { - result = printer_write_default_dev( snum, printer_default); - if (result != 0) { - close_printer_handle(p, handle); - return result; - } - } -#endif } + + Printer->access_granted = printer_default->access_required; return WERR_OK; } @@ -7273,7 +7256,7 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM goto done; } - if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + if ( !(Printer->access_granted & (PRINTER_ACCESS_ADMINISTER|SERVER_ACCESS_ADMINISTER)) ) { DEBUG(2,("_spoolss_addform: denied by handle permissions.\n")); status = WERR_ACCESS_DENIED; goto done; -- cgit From 752f2adec593170b3711736b584c28b7daf82be4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 22 Aug 2002 17:43:27 +0000 Subject: Fix compile warnings. (This used to be commit e84f47a234d31e98b0dc28c51f3ec337458e48d1) --- source3/rpc_server/srv_pipe.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 62e10c9965..1947d5514e 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -276,9 +276,6 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm auth_usersupplied_info *user_info = NULL; auth_serversupplied_info *server_info = NULL; - uid_t uid; - uid_t gid; - DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); memset(p->user_name, '\0', sizeof(p->user_name)); -- cgit From 2bd75e4714f664a4cddf406a18f665b5cd590f29 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 22 Aug 2002 21:16:11 +0000 Subject: fix registry editor API for printing backend after I changed the NT_PRINTER_PARAM to a REGISTRY_VALUE (This used to be commit 8d510abe125e15a8d71c58a13d170dc3d6371368) --- source3/rpc_server/srv_spoolss_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a9c09b9107..1c60e7024e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7925,7 +7925,6 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, fstring valuename; fstring keyname; char *oid_string; - UNISTR2 uni_oid; DEBUG(4,("_spoolss_setprinterdataex\n")); @@ -7988,9 +7987,8 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, * this is right. --jerry */ - init_unistr2( &uni_oid, oid_string, strlen(oid_string)+1 ); set_printer_dataex( printer, keyname, valuename, - REG_SZ, (void*)uni_oid.buffer, uni_oid.uni_str_len*sizeof(uint16) ); + REG_SZ, (void*)oid_string, strlen(oid_string)+1 ); } free_a_printer(&printer, 2); -- cgit From 68d5ab9a656234c1605046562b63d1eaa8108132 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 26 Aug 2002 16:43:29 +0000 Subject: merge from APP_HEAD (This used to be commit 4689e7ea5e55e22e1e4293c91ba69fee53436143) --- source3/rpc_server/srv_spoolss_nt.c | 95 +++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 35 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1c60e7024e..383736d1f6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -566,7 +566,14 @@ static BOOL is_monitoring_event(Printer_entry *p, uint16 notify_type, { SPOOL_NOTIFY_OPTION *option = p->notify.option; uint32 i, j; - + + /* + * Flags should always be zero when the change notify + * is registered by the cliebnt's spooler. A user Win32 app + * might use the flags though instead of the NOTIFY_OPTION_INFO + * --jerry + */ + if (p->notify.flags) return is_monitoring_event_flags( p->notify.flags, notify_type, notify_field); @@ -826,7 +833,9 @@ done: return; } -/* Receive a notify2 message */ +/******************************************************************** + Receive a notify2 message + ********************************************************************/ static void receive_notify2_message(int msg_type, pid_t src, void *buf, size_t len) @@ -7302,7 +7311,6 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE UNISTR2 *form_name = &q_u->name; nt_forms_struct tmpForm; int count=0; - WERROR ret = WERR_OK; nt_forms_struct *list=NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); int snum; @@ -7316,40 +7324,49 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) - return WERR_BADFID; + /* forms can be deleted on printer of on the print server handle */ + + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + { + if (!get_printer_snum(p,handle, &snum)) + return WERR_BADFID; + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + goto done; + } - if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { - DEBUG(2,("_spoolss_deleteform: denied by handle permissions\n")); - return WERR_ACCESS_DENIED; + if ( !(Printer->access_granted & (PRINTER_ACCESS_ADMINISTER|SERVER_ACCESS_ADMINISTER)) ) { + DEBUG(2,("_spoolss_deleteform: denied by handle permissions.\n")); + status = WERR_ACCESS_DENIED; + goto done; } /* can't delete if builtin */ + if (get_a_builtin_ntform(form_name,&tmpForm)) { - return WERR_INVALID_PARAM; + status = WERR_INVALID_PARAM; + goto done; } count = get_ntforms(&list); - if(!delete_a_form(&list, form_name, &count, &ret)) - return WERR_INVALID_PARAM; + + if ( !delete_a_form(&list, form_name, &count, &status )) + goto done; /* - * ChangeID must always be set + * ChangeID must always be set if this is a printer */ - status = get_a_printer(&printer, 2, lp_servicename(snum)); - if (!W_ERROR_IS_OK(status)) - goto done; - - status = mod_a_printer(*printer, 2); - if (!W_ERROR_IS_OK(status)) - goto done; + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + status = mod_a_printer(*printer, 2); done: - free_a_printer(&printer, 2); + if ( printer ) + free_a_printer(&printer, 2); SAFE_FREE(list); - return ret; + return status; } /**************************************************************************** @@ -7375,37 +7392,45 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) - return WERR_BADFID; + /* forms can be modified on printer of on the print server handle */ + + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + { + if (!get_printer_snum(p,handle, &snum)) + return WERR_BADFID; + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + goto done; + } - if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + if ( !(Printer->access_granted & (PRINTER_ACCESS_ADMINISTER|SERVER_ACCESS_ADMINISTER)) ) { DEBUG(2,("_spoolss_setform: denied by handle permissions\n")); - return WERR_ACCESS_DENIED; + status = WERR_ACCESS_DENIED; + goto done; } /* can't set if builtin */ if (get_a_builtin_ntform(&form->name,&tmpForm)) { - return WERR_INVALID_PARAM; + status = WERR_INVALID_PARAM; + goto done; } - count=get_ntforms(&list); + count = get_ntforms(&list); update_a_form(&list, form, count); write_ntforms(&list, count); /* - * ChangeID must always be set + * ChangeID must always be set if this is a printer */ - status = get_a_printer(&printer, 2, lp_servicename(snum)); - if (!W_ERROR_IS_OK(status)) - goto done; + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + status = mod_a_printer(*printer, 2); - status = mod_a_printer(*printer, 2); - if (!W_ERROR_IS_OK(status)) - goto done; done: - free_a_printer(&printer, 2); + if ( printer ) + free_a_printer(&printer, 2); SAFE_FREE(list); return WERR_OK; -- cgit From 6dad13d80124b181b35684ea25c0eb0eb28316ac Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 26 Aug 2002 16:57:35 +0000 Subject: merge from APP_HEAD (This used to be commit ebe89453b63467c87263c24f4380544fef1124a6) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 383736d1f6..de87954fea 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7433,7 +7433,7 @@ done: free_a_printer(&printer, 2); SAFE_FREE(list); - return WERR_OK; + return status; } /**************************************************************************** -- cgit From 2b2b0f7119fe043f61259579ce70e782f5f9ec5f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 28 Aug 2002 04:54:43 +0000 Subject: Put in intermediate version of new SAM system. It's not stable yet, code might be ugly, etc - please don't blame me for anything but instead try to fix the code :-). Compiling of the new sam system can be enabled with the configure option --with-sam Removing passdb/passgrp.c as it's unused fix typo in utils/testparm.c (This used to be commit 4b7de5ee236c043e6169f137992baf09a95c6f2c) --- source3/rpc_server/srv_samr_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a30622c600..044a904250 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -68,8 +68,6 @@ struct generic_mapping usr_generic_mapping = {USER_READ, USER_WRITE, USER_EXECUT struct generic_mapping grp_generic_mapping = {GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, GROUP_ALL_ACCESS}; struct generic_mapping ali_generic_mapping = {ALIAS_READ, ALIAS_WRITE, ALIAS_EXECUTE, ALIAS_ALL_ACCESS}; -static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *d_size); - /******************************************************************* Checks if access to an object should be granted, and returns that @@ -411,7 +409,7 @@ NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, samr_make_sam_obj_sd ********************************************************************/ -static NTSTATUS samr_make_sam_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +NTSTATUS samr_make_sam_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) { extern DOM_SID global_sid_World; DOM_SID adm_sid; -- cgit From b294ce998669699233dfc1adf8a90feb94a4c4f3 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Wed, 28 Aug 2002 14:19:40 +0000 Subject: add proto for forward reference (This used to be commit 7573fd1746dfe5034deb51a6d205e15af6ff81de) --- source3/rpc_server/srv_samr_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 044a904250..82b83403eb 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -68,6 +68,7 @@ struct generic_mapping usr_generic_mapping = {USER_READ, USER_WRITE, USER_EXECUT struct generic_mapping grp_generic_mapping = {GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, GROUP_ALL_ACCESS}; struct generic_mapping ali_generic_mapping = {ALIAS_READ, ALIAS_WRITE, ALIAS_EXECUTE, ALIAS_ALL_ACCESS}; +static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size); /******************************************************************* Checks if access to an object should be granted, and returns that -- cgit From 8e729a4d846f8cd4ee5bea549c1abbcf1653b3b3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 Aug 2002 16:38:43 +0000 Subject: Move samr_make_sam_obj_sd to lib/util_seaccess.c. samtest now compiles and links successfully! (This used to be commit 0ea4bcb6b772a0d95d20f7c1a2a0c08a0ba9e466) --- source3/rpc_server/srv_samr_nt.c | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 82b83403eb..0d6808d08c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -405,46 +405,6 @@ NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, return r_u->status; } - -/******************************************************************* - samr_make_sam_obj_sd - ********************************************************************/ - -NTSTATUS samr_make_sam_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) -{ - extern DOM_SID global_sid_World; - DOM_SID adm_sid; - DOM_SID act_sid; - - SEC_ACE ace[3]; - SEC_ACCESS mask; - - SEC_ACL *psa = NULL; - - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); - - sid_copy(&act_sid, &global_sid_Builtin); - sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); - - /*basic access for every one*/ - init_sec_access(&mask, SAMR_EXECUTE | SAMR_READ); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, SAMR_ALL_ACCESS); - init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) - return NT_STATUS_NO_MEMORY; - - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) - return NT_STATUS_NO_MEMORY; - - return NT_STATUS_OK; -} - /******************************************************************* samr_make_dom_obj_sd ********************************************************************/ -- cgit From 1f02551bb19bab89083bfa1819a701a892d241df Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 30 Aug 2002 08:24:26 +0000 Subject: Removed some misleading comment. Volker (This used to be commit 70cf2f1e2f0187c546a0193824ab85a416c5236c) --- source3/rpc_server/srv_samr_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 0d6808d08c..ee4335cb0a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1017,8 +1017,6 @@ static NTSTATUS get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DO /******************************************************************* samr_reply_enum_dom_groups - Only reply with one group - domain admins. This must be fixed for - a real PDC. JRA. ********************************************************************/ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_R_ENUM_DOM_GROUPS *r_u) -- cgit From de3d0310e2622c068d6ae6fb4698752128068924 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Aug 2002 10:47:34 +0000 Subject: merge of phant0m key fix from APP_HEAD (This used to be commit cb13d334a53f27713665570d85607d57eb407f9f) --- source3/rpc_server/srv_spoolss_nt.c | 91 +++++++++++++------------------------ 1 file changed, 32 insertions(+), 59 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index de87954fea..d1f92aef13 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5335,22 +5335,6 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, goto done; } -#if 0 /* JERRY */ - - /* - * Another one of those historical misunderstandings... - * This is reminisent of a similar call we had in _spoolss_setprinterdata() - * I'm leaving it here as a reminder. --jerry - */ - - if (nt_printer_info_level_equal(printer, old_printer)) { - DEBUG(3, ("update_printer: printer info has not changed\n")); - result = WERR_OK; - goto done; - } - -#endif - /* Check calling user has permission to update printer description */ if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { @@ -5369,49 +5353,22 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, } /* - * Set the DRIVER_INIT info in the tdb; trigger on magic value for the - * DEVMODE.displayfrequency, which is not used for printer drivers. This - * requires Win32 client code (see other notes elsewhere in the code). + * When a *new* driver is bound to a printer, the drivername is used to + * lookup previously saved driver initialization info, which is then + * bound to the printer, simulating what happens in the Windows arch. */ - if (printer->info_2->devmode && - printer->info_2->devmode->displayfrequency == MAGIC_DISPLAY_FREQUENCY) - { - - DEBUG(10,("update_printer: Save printer driver init data\n")); - printer->info_2->devmode->displayfrequency = 0; - - if (update_driver_init(*printer, 2)!=0) { - DEBUG(10,("update_printer: error updating printer driver init DEVMODE\n")); - result = WERR_ACCESS_DENIED; - goto done; - } - - /* we need to reset all driver init data for all printers - bound to this driver */ - - srv_spoolss_reset_printerdata( printer->info_2->drivername ); - - } - else + if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)) { - /* - * When a *new* driver is bound to a printer, the drivername is used to - * lookup previously saved driver initialization info, which is then - * bound to the printer, simulating what happens in the Windows arch. - */ - if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)) + if (!set_driver_init(printer, 2)) { - if (!set_driver_init(printer, 2)) - { - DEBUG(5,("update_printer: Error restoring driver initialization data for driver [%s]!\n", - printer->info_2->drivername)); - } - - DEBUG(10,("update_printer: changing driver [%s]! Sending event!\n", + DEBUG(5,("update_printer: Error restoring driver initialization data for driver [%s]!\n", printer->info_2->drivername)); - - notify_printer_driver(snum, printer->info_2->drivername); } + + DEBUG(10,("update_printer: changing driver [%s]! Sending event!\n", + printer->info_2->drivername)); + + notify_printer_driver(snum, printer->info_2->drivername); } /* Update printer info */ @@ -6614,8 +6571,11 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ */ if (!devmode) + { set_driver_init(printer, 2); - else { + } + else + { /* A valid devmode was included, convert and link it */ DEBUGADD(10, ("spoolss_addprinterex_level_2: devmode included, converting\n")); @@ -6625,8 +6585,6 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ return WERR_NOMEM; } - set_driver_init(printer, 2); - /* write the ASCII on disk */ err = mod_a_printer(*printer, 2); if (!W_ERROR_IS_OK(err)) { @@ -6925,7 +6883,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S uint32 idx = q_u->index; uint32 in_value_len = q_u->valuesize; uint32 in_data_len = q_u->datasize; - uint32 *out_max_value_len= &r_u->valuesize; + uint32 *out_max_value_len = &r_u->valuesize; uint16 **out_value = &r_u->value; uint32 *out_value_len = &r_u->realvaluesize; uint32 *out_type = &r_u->type; @@ -7145,10 +7103,25 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); - /* save the registry data */ + /* + * 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 ( (type == REG_BINARY) && strequal( valuename, PHANTOM_DEVMODE_KEY)) + { + /* Set devmode and printer initialization info */ + status = save_driver_init( printer, 2, data, real_len ); + srv_spoolss_reset_printerdata( printer->info_2->drivername ); + } + else + { status = set_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, valuename, type, data, real_len ); + if ( W_ERROR_IS_OK(status) ) + status = mod_a_printer(*printer, 2); + } done: free_a_printer(&printer, 2); -- cgit From 3cbe8922762817d38b6408154994714ca35f3734 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Aug 2002 14:48:33 +0000 Subject: fix up print portion of registry. Merge from APP_HEAD. (This used to be commit ec37633548ed329c05b93499f75883d987b78f1e) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d1f92aef13..c4105f9780 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7911,7 +7911,7 @@ done: WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, SPOOL_R_SETPRINTERDATAEX *r_u) { - POLICY_HND *handle = &q_u->handle; + POLICY_HND *handle = &q_u->handle; uint32 type = q_u->type; uint8 *data = q_u->data; uint32 real_len = q_u->real_len; -- cgit From 724d1c3d2d04f706c4d0f13c0b59b598bdb10807 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 30 Aug 2002 23:56:37 +0000 Subject: Add a fix for 'query_disp_info level 2', which should return all machines in the DC's SAM. We were only returning workstations, not PDCs or BDCs. Win2k's 'Computer Manager' tool uses this to list all computers in the domain (as opposed to using NetBIOS). Andrew Bartlett (This used to be commit 004090edffef6cc04c286b9924b8c47ea3260ef2) --- source3/rpc_server/srv_samr_nt.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ee4335cb0a..927acb24b8 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -198,7 +198,7 @@ static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) } -static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) +static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOOL all_machines) { SAM_ACCOUNT *pwd = NULL; DISP_USER_INFO *pwd_array = NULL; @@ -221,10 +221,19 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) for (; (NT_STATUS_IS_OK(nt_status = pdb_init_sam_talloc(mem_ctx, &pwd))) && pdb_getsampwent(pwd) == True; pwd=NULL) { - if (acb_mask != 0 && !(pdb_get_acct_ctrl(pwd) & acb_mask)) { - pdb_free_sam(&pwd); - DEBUG(5,(" acb_mask %x reject\n", acb_mask)); - continue; + if (all_machines) { + if (!((pdb_get_acct_ctrl(pwd) & ACB_WSTRUST) + || (pdb_get_acct_ctrl(pwd) & ACB_SVRTRUST))) { + DEBUG(5,("load_sampwd_entries: '%s' is not a machine account - ACB: %x - skipping\n", pdb_get_username(pwd), acb_mask)); + pdb_free_sam(&pwd); + continue; + } + } else { + if (acb_mask != 0 && !(pdb_get_acct_ctrl(pwd) & acb_mask)) { + pdb_free_sam(&pwd); + DEBUG(5,(" acb_mask %x reject\n", acb_mask)); + continue; + } } /* Realloc some memory for the array of ptr to the SAM_ACCOUNT structs */ @@ -746,7 +755,7 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); become_root(); - r_u->status=load_sampwd_entries(info, q_u->acb_mask); + r_u->status=load_sampwd_entries(info, q_u->acb_mask, False); unbecome_root(); if (!NT_STATUS_IS_OK(r_u->status)) @@ -1100,7 +1109,6 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, { struct samr_info *info = NULL; uint32 struct_size=0x20; /* W2K always reply that, client doesn't care */ - uint16 acb_mask; uint32 max_entries=q_u->max_entries; uint32 enum_context=q_u->start_idx; @@ -1151,20 +1159,14 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, * JFM, 12/20/2001 */ - /* Get what we need from the password database */ - - if (q_u->switch_level==2) - acb_mask = ACB_WSTRUST; - else - acb_mask = ACB_NORMAL; - /* Get what we need from the password database */ switch (q_u->switch_level) { case 0x1: case 0x2: case 0x4: become_root(); - r_u->status=load_sampwd_entries(info, acb_mask); + /* Level 2 is for all machines, otherwise only 'normal' users */ + r_u->status=load_sampwd_entries(info, ACB_NORMAL, q_u->switch_level==2); unbecome_root(); if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); @@ -2083,7 +2085,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA break; case 0x02: become_root(); - r_u->status=load_sampwd_entries(info, ACB_NORMAL); + r_u->status=load_sampwd_entries(info, ACB_NORMAL, False); unbecome_root(); if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); @@ -4247,10 +4249,10 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW break; case 0x02: become_root(); - r_u->status=load_sampwd_entries(info, ACB_NORMAL); + r_u->status=load_sampwd_entries(info, ACB_NORMAL, False); unbecome_root(); if (!NT_STATUS_IS_OK(r_u->status)) { - DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); + DEBUG(5, ("_samr_unknown_2e: load_sampwd_entries failed\n")); return r_u->status; } num_users=info->disp_info.num_user_account; @@ -4258,7 +4260,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW r_u->status=load_group_domain_entries(info, get_global_sam_sid()); if (NT_STATUS_IS_ERR(r_u->status)) { - DEBUG(5, ("_samr_query_dispinfo: load_group_domain_entries failed\n")); + DEBUG(5, ("_samr_unknown_2e: load_group_domain_entries failed\n")); return r_u->status; } num_groups=info->disp_info.num_group_account; -- cgit From e0a8b7e0d0705c8f1597cc24cf62d830a5dea2ca Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 2 Sep 2002 13:47:51 +0000 Subject: usrmgr expects unicode as ProductType. This looks a bit like a hack ;-) Volker (This used to be commit f673eac06ab4af97a4d28427f7444696402ae680) --- source3/rpc_server/srv_reg_nt.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index cd9596d2a7..f96de7e533 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -342,6 +342,9 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) { NTSTATUS status = NT_STATUS_NO_SUCH_FILE; fstring name; + char *value_ascii = ""; + fstring value; + int value_length; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); REGISTRY_VALUE *val = NULL; REGISTRY_VALUE emptyval; @@ -380,15 +383,20 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_LANMANNT, strlen(REG_PT_LANMANNT)+1 ); + value_ascii = REG_PT_LANMANNT; break; case ROLE_STANDALONE: - regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_SERVERNT, strlen(REG_PT_SERVERNT)+1 ); + value_ascii = REG_PT_SERVERNT; break; case ROLE_DOMAIN_MEMBER: - regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_WINNT, strlen(REG_PT_WINNT)+1 ); + value_ascii = REG_PT_WINNT; break; } + value_length = push_ucs2(value, value, value_ascii, + sizeof(value), + STR_TERMINATE|STR_NOALIGN); + regval_ctr_addvalue(®vals, REGSTR_PRODUCTTYPE, REG_SZ, + value, value_length); val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); -- cgit From 59f40f31edfd50d76ef72295dd92327614e4e2ac Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 4 Sep 2002 01:14:24 +0000 Subject: DeletePrinterDriver[Ex]() fixes from APP_HEAD (This used to be commit 04874134ed83847988bad5fcad3463395dc283fb) --- source3/rpc_server/srv_spoolss_nt.c | 137 +++++++++++++++++++++++++++++------- 1 file changed, 113 insertions(+), 24 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c4105f9780..37f8071e69 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1593,8 +1593,11 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER fstring driver; fstring arch; NT_PRINTER_DRIVER_INFO_LEVEL info; + NT_PRINTER_DRIVER_INFO_LEVEL info_win2k; int version; struct current_user user; + WERROR status; + WERROR status_win2k = WERR_ACCESS_DENIED; get_current_user(&user, p); @@ -1602,25 +1605,58 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)-1 ); /* check that we have a valid driver name first */ - if ((version=get_version_id(arch)) == -1) { - /* this is what NT returns */ + + if ((version=get_version_id(arch)) == -1) return WERR_INVALID_ENVIRONMENT; + + ZERO_STRUCT(info); + ZERO_STRUCT(info_win2k); + + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) + { + /* try for Win2k driver if "Windows NT x86" */ + + if ( version == 2 ) { + version = 3; + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) { + status = WERR_UNKNOWN_PRINTER_DRIVER; + goto done; + } + } } - /* if they said "Windows NT x86", then try for version 2 & 3 */ + if (printer_driver_in_use(info.info_3)) { + status = WERR_PRINTER_DRIVER_IN_USE; + goto done; + } if ( version == 2 ) - version = DRIVER_ANY_VERSION; + { + if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3, driver, arch, 3))) + { + /* if we get to here, we now have 2 driver info structures to remove */ + /* remove the Win2k driver first*/ - ZERO_STRUCT(info); + status_win2k = delete_printer_driver(info_win2k.info_3, &user, 3, False ); + free_a_printer_driver( info_win2k, 3 ); + + /* this should not have failed---if it did, report to client */ + if ( !W_ERROR_IS_OK(status_win2k) ) + goto done; + } + } - if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) - return WERR_UNKNOWN_PRINTER_DRIVER; + status = delete_printer_driver(info.info_3, &user, version, False); + + /* if at least one of the deletes succeeded return OK */ - if (printer_driver_in_use(info.info_3)) - return WERR_PRINTER_DRIVER_IN_USE; + if ( W_ERROR_IS_OK(status) || W_ERROR_IS_OK(status_win2k) ) + status = WERR_OK; + +done: + free_a_printer_driver( info, 3 ); - return delete_printer_driver(info.info_3, &user, DRIVER_ANY_VERSION, False); + return status; } /******************************************************************** @@ -1632,10 +1668,13 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV fstring driver; fstring arch; NT_PRINTER_DRIVER_INFO_LEVEL info; + NT_PRINTER_DRIVER_INFO_LEVEL info_win2k; int version; uint32 flags = q_u->delete_flags; BOOL delete_files; struct current_user user; + WERROR status; + WERROR status_win2k = WERR_ACCESS_DENIED; get_current_user(&user, p); @@ -1650,17 +1689,35 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV if ( flags & DPD_DELETE_SPECIFIC_VERSION ) version = q_u->version; - else if ( version == 2 ) - /* if they said "Windows NT x86", then try for version 2 & 3 */ - version = DRIVER_ANY_VERSION; ZERO_STRUCT(info); + ZERO_STRUCT(info_win2k); + + status = get_a_printer_driver(&info, 3, driver, arch, version); - if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) - return WERR_UNKNOWN_PRINTER_DRIVER; + if ( !W_ERROR_IS_OK(status) ) + { + /* if the client asked for a specific version, then we've failed */ - if ( printer_driver_in_use(info.info_3) ) - return WERR_PRINTER_DRIVER_IN_USE; + if ( flags & DPD_DELETE_SPECIFIC_VERSION ) + goto done; + + /* try for Win2k driver if "Windows NT x86" */ + + if ( version == 2 ) + { + version = 3; + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) { + status = WERR_UNKNOWN_PRINTER_DRIVER; + goto done; + } + } + } + + if ( printer_driver_in_use(info.info_3) ) { + status = WERR_PRINTER_DRIVER_IN_USE; + goto done; + } /* * we have a couple of cases to consider. @@ -1676,16 +1733,48 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV delete_files = flags & (DPD_DELETE_ALL_FILES|DPD_DELETE_UNUSED_FILES); - if ( delete_files ) - { - /* fail if any files are in use and DPD_DELETE_ALL_FILES is set */ + /* fail if any files are in use and DPD_DELETE_ALL_FILES is set */ + + if ( delete_files && printer_driver_files_in_use(info.info_3) & (flags&DPD_DELETE_ALL_FILES) ) { + /* no idea of the correct error here */ + status = WERR_ACCESS_DENIED; + goto done; + } + + + /* also check for W32X86/3 if necessary; maybe we already have? */ + + if ( (version == 2) && ((flags&DPD_DELETE_SPECIFIC_VERSION) != DPD_DELETE_SPECIFIC_VERSION) ) { + if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3, driver, arch, 3))) + { + + if ( delete_files && printer_driver_files_in_use(info_win2k.info_3) & (flags&DPD_DELETE_ALL_FILES) ) { + /* no idea of the correct error here */ + status = WERR_ACCESS_DENIED; + goto done; + } - if ( printer_driver_files_in_use(info.info_3) & (flags&DPD_DELETE_ALL_FILES) ) - /* no idea of the correct error here */ - return WERR_ACCESS_DENIED; + /* if we get to here, we now have 2 driver info structures to remove */ + /* remove the Win2k driver first*/ + + status_win2k = delete_printer_driver(info.info_3, &user, 3, delete_files); + free_a_printer_driver( info_win2k, 3 ); + + /* this should not have failed---if it did, report to client */ + + if ( !W_ERROR_IS_OK(status_win2k) ) + goto done; + } } - return delete_printer_driver(info.info_3, &user, version, delete_files); + status = delete_printer_driver(info.info_3, &user, version, delete_files); + + if ( W_ERROR_IS_OK(status) || W_ERROR_IS_OK(status_win2k) ) + status = WERR_OK; +done: + free_a_printer_driver( info, 3 ); + + return status; } -- cgit From cbaa14857b6fd2704fa920c1fb15011e70b7df0f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 4 Sep 2002 21:59:38 +0000 Subject: Merge of (apparently working :-) new printing notify code. Jeremy. (This used to be commit 8595c6ce4d74539089b600b3b0ff858a04b793ff) --- source3/rpc_server/srv_spoolss_nt.c | 59 +++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 37f8071e69..a20fa615fd 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -220,6 +220,9 @@ static void free_printer_entry(void *ptr) Printer->notify.option=NULL; Printer->notify.client_connected=False; + /* Tell the connections db we're not interested in printer notify messages. */ + register_message_flags(False, FLAG_MSG_PRINTING); + /* Remove from the internal list. */ DLIST_REMOVE(printers_list, Printer); @@ -728,8 +731,7 @@ static struct notify2_message_table job_notify_table[] = { back registered **********************************************************************/ -static void process_notify2_message(struct spoolss_notify_msg *msg, - TALLOC_CTX *mem_ctx) +static void process_notify2_message(struct spoolss_notify_msg *msg, TALLOC_CTX *mem_ctx) { Printer_entry *p; @@ -837,8 +839,7 @@ done: Receive a notify2 message ********************************************************************/ -static void receive_notify2_message(int msg_type, pid_t src, void *buf, - size_t len) +static void receive_notify2_message(void *buf, size_t len) { struct spoolss_notify_msg msg; int offset = 0; @@ -882,6 +883,49 @@ static void receive_notify2_message(int msg_type, pid_t src, void *buf, talloc_destroy(mem_ctx); } +/******************************************************************** + Receive a notify2 message list + ********************************************************************/ + +static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, size_t len) +{ + size_t msg_count, i; + char *buf = (char *)msg; + char *msg_ptr; + + if (len < 4) + goto bad_msg; + + msg_count = IVAL(buf, 0); + msg_ptr = buf + 4; + + if (msg_count == 0) + goto bad_msg; + + for (i = 0; i < msg_count; i++) { + size_t msg_len; + + if (msg_ptr + 4 - buf > len) + goto bad_msg; + + msg_len = IVAL(msg_ptr,0); + msg_ptr += 4; + + if (msg_ptr + msg_len - buf > len) + goto bad_msg; + receive_notify2_message(msg_ptr, msg_len); + msg_ptr += msg_len; + } + + DEBUG(10,("receive_notify2_message_list: processed %u messages\n", + (unsigned int)msg_count )); + return; + + bad_msg: + + DEBUG(0,("receive_notify2_message_list: bad message format !\n")); +} + /******************************************************************** Send a message to ourself about new driver being installed so we can upgrade the information for each printer bound to this @@ -2133,7 +2177,7 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin if(!spoolss_connect_to_client(¬ify_cli, unix_printer)) return False; - message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message); + message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message_list); } smb_connections++; @@ -2196,6 +2240,8 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE &Printer->notify.client_hnd)) return WERR_SERVER_UNAVAILABLE; + /* Tell the connections db we're interested in printer notify messages. */ + register_message_flags(True, FLAG_MSG_PRINTING); Printer->notify.client_connected=True; return WERR_OK; @@ -5544,6 +5590,9 @@ WERROR _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; + /* Tell the connections db we're not interested in printer notify messages. */ + register_message_flags(False, FLAG_MSG_PRINTING); + return WERR_OK; } -- cgit From cc5088b5f4174a7f44004746d3c7d395d51441ff Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 4 Sep 2002 22:02:53 +0000 Subject: Only cache the user list on the SAMR handle for a particular acb_mask/all_machines flag combination. The avoids a bug where we were listing users in the 'trusting domains' dialog in usrmgr. We might also need to invalidate the cache for some other SAMR actions. Andrew Bartlett (This used to be commit 65047aee7fefefaecded9772184a54c046ab1784) --- source3/rpc_server/srv_samr_nt.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 927acb24b8..e2336aca55 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -57,6 +57,8 @@ struct samr_info { DOM_SID sid; uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ uint32 acc_granted; + uint16 acb_mask; + BOOL all_machines; DISP_INFO disp_info; TALLOC_CTX *mem_ctx; @@ -150,26 +152,36 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) return info; } + /******************************************************************* Function to free the per handle data. ********************************************************************/ -static void free_samr_db(struct samr_info *info) +static void free_samr_users(struct samr_info *info) { int i; - /* Groups are talloced */ - if (info->disp_info.user_dbloaded){ for (i=0; idisp_info.num_user_account; i++) { /* Not really a free, actually a 'clear' */ pdb_free_sam(&info->disp_info.disp_user_info[i].sam); } } - info->disp_info.user_dbloaded=False; + info->disp_info.num_user_account=0; +} + + +/******************************************************************* + Function to free the per handle data. + ********************************************************************/ +static void free_samr_db(struct samr_info *info) +{ + /* Groups are talloced */ + + free_samr_users(info); + info->disp_info.group_dbloaded=False; info->disp_info.num_group_account=0; - info->disp_info.num_user_account=0; } @@ -208,11 +220,15 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOO DEBUG(10,("load_sampwd_entries\n")); /* if the snapshoot is already loaded, return */ - if (info->disp_info.user_dbloaded==True) { + if ((info->disp_info.user_dbloaded==True) + && (info->acb_mask == acb_mask) + && (info->all_machines == all_machines)) { DEBUG(10,("load_sampwd_entries: already in memory\n")); return NT_STATUS_OK; } + free_samr_users(info); + if (!pdb_setsampwent(False)) { DEBUG(0, ("load_sampwd_entries: Unable to open passdb.\n")); return NT_STATUS_ACCESS_DENIED; @@ -261,6 +277,8 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOO /* the snapshoot is in memory, we're ready to enumerate fast */ + info->acb_mask = acb_mask; + info->all_machines = all_machines; info->disp_info.user_dbloaded=True; DEBUG(12,("load_sampwd_entries: done\n")); -- cgit From 2658e4ee23600e49a4231bc2b40c20a571c3f826 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 4 Sep 2002 23:40:49 +0000 Subject: Added better error code on out of space. Removed total jobs check - not applicable any more. Jeremy. (This used to be commit 8828e2ea3c668aab6cda1b4be9a7e4ce1c23ca81) --- source3/rpc_server/srv_spoolss_nt.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a20fa615fd..0236057475 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5159,6 +5159,13 @@ WERROR _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R return WERR_BADFID; (*buffer_written) = print_job_write(snum, Printer->jobid, (char *)buffer, buffer_size); + if (*buffer_written == -1) { + r_u->buffer_written = 0; + if (errno == ENOSPC) + return WERR_NO_SPOOL_SPACE; + else + return WERR_ACCESS_DENIED; + } r_u->buffer_written = q_u->buffer_size2; -- cgit From 481c0db0acf6bf305a630aae9751a6d9655e0cda Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 5 Sep 2002 04:22:16 +0000 Subject: Roussed on Jeremy for not putting in enough debugs in the new print notify stuff. (-: (This used to be commit 87c156704f5d8913cf7bf3134ec5ba6403d36cca) --- source3/rpc_server/srv_spoolss_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0236057475..3a2bde2d05 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -899,6 +899,8 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz msg_count = IVAL(buf, 0); msg_ptr = buf + 4; + DEBUG(5, ("receive_notify2_message_list: got %d messages in list\n", msg_count)); + if (msg_count == 0) goto bad_msg; -- cgit From 9f43ccb98e32b343b021f9ea6a8eeef7e1fe5c89 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 5 Sep 2002 06:49:08 +0000 Subject: Delivery notify messages over the back channel in *reverse* order in which they are sent in the message. This is because a DLIST_ADD is used by the message sender which results in the first (post!) message being at the end of the list. Notify messages must be delivered in the order the events occur in otherwise the port monitor gets confused. (This used to be commit d41ff1f1a6cfad71ef35698d45e9fb97d9100898) --- source3/rpc_server/srv_spoolss_nt.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3a2bde2d05..aa63284322 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -889,9 +889,9 @@ static void receive_notify2_message(void *buf, size_t len) static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, size_t len) { - size_t msg_count, i; + size_t msg_count, *msg_len_array, i; char *buf = (char *)msg; - char *msg_ptr; + char *msg_ptr, **msg_ptr_array; if (len < 4) goto bad_msg; @@ -904,6 +904,24 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz if (msg_count == 0) goto bad_msg; + /* Process notifies in *reverse* order in which they are sent + in the message. This is because a DLIST_ADD is used by the + message sender which results in the first (post!) message + being at the end of the list. Notify messages must be + delivered in the order the events occur in otherwise the + port monitor gets confused. */ + + if (!(msg_len_array = (size_t *)malloc(sizeof(size_t) * msg_count))) { + DEBUG(0, ("receive_notify2_message_list: out of memory\n")); + return; + } + + if (!(msg_ptr_array = (char **)malloc(sizeof(char *) * msg_count))) { + SAFE_FREE(msg_len_array); + DEBUG(0, ("receive_notify2_message_list: out of memory\n")); + return; + } + for (i = 0; i < msg_count; i++) { size_t msg_len; @@ -915,10 +933,19 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz if (msg_ptr + msg_len - buf > len) goto bad_msg; - receive_notify2_message(msg_ptr, msg_len); + + msg_len_array[i] = msg_len; + msg_ptr_array[i] = msg_ptr; + msg_ptr += msg_len; } + for(i = msg_count; i > 0; i--) + receive_notify2_message(msg_ptr_array[i - 1], msg_len_array[i - 1]); + + SAFE_FREE(msg_len_array); + SAFE_FREE(msg_ptr_array); + DEBUG(10,("receive_notify2_message_list: processed %u messages\n", (unsigned int)msg_count )); return; -- cgit From 4cf52385994b62de71240b894b37f82b6daa6ee2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 Sep 2002 12:55:56 +0000 Subject: Revert the "reverse" change to rpc_server/srv_spoolss_nt.c, simply add then entries to the end of the list in printing/notify.c using DLIST_ADD_END. Jeremy. (This used to be commit 047d6a05fb60172a2607bb7d7d03dda5403c61fa) --- source3/rpc_server/srv_spoolss_nt.c | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index aa63284322..3a2bde2d05 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -889,9 +889,9 @@ static void receive_notify2_message(void *buf, size_t len) static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, size_t len) { - size_t msg_count, *msg_len_array, i; + size_t msg_count, i; char *buf = (char *)msg; - char *msg_ptr, **msg_ptr_array; + char *msg_ptr; if (len < 4) goto bad_msg; @@ -904,24 +904,6 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz if (msg_count == 0) goto bad_msg; - /* Process notifies in *reverse* order in which they are sent - in the message. This is because a DLIST_ADD is used by the - message sender which results in the first (post!) message - being at the end of the list. Notify messages must be - delivered in the order the events occur in otherwise the - port monitor gets confused. */ - - if (!(msg_len_array = (size_t *)malloc(sizeof(size_t) * msg_count))) { - DEBUG(0, ("receive_notify2_message_list: out of memory\n")); - return; - } - - if (!(msg_ptr_array = (char **)malloc(sizeof(char *) * msg_count))) { - SAFE_FREE(msg_len_array); - DEBUG(0, ("receive_notify2_message_list: out of memory\n")); - return; - } - for (i = 0; i < msg_count; i++) { size_t msg_len; @@ -933,19 +915,10 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz if (msg_ptr + msg_len - buf > len) goto bad_msg; - - msg_len_array[i] = msg_len; - msg_ptr_array[i] = msg_ptr; - + receive_notify2_message(msg_ptr, msg_len); msg_ptr += msg_len; } - for(i = msg_count; i > 0; i--) - receive_notify2_message(msg_ptr_array[i - 1], msg_len_array[i - 1]); - - SAFE_FREE(msg_len_array); - SAFE_FREE(msg_ptr_array); - DEBUG(10,("receive_notify2_message_list: processed %u messages\n", (unsigned int)msg_count )); return; -- cgit From 789d51b42ceb2d99658c72bf55904083d451fcab Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 6 Sep 2002 13:37:11 +0000 Subject: This is the 'easy' parts of the trusted domains patch n+3 patch from Rafal Szczesniak It includes a conversion of make_user_info*() to NTSTATUS and some minor changes to other files. It also picks up on a nasty segfault that can occour in some security=domain cases. Andrew Bartlett (This used to be commit d1e1fc3e4bf72717b3593685f0ea5750d676952a) --- source3/rpc_server/srv_lsa_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f28441886a..e187e1556e 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -473,6 +473,8 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E /* * preferred length is set to 5 as a "our" preferred length * nt sets this parameter to 2 + * update (20.08.2002): it's not preferred length, but preferred size! + * it needs further investigation how to optimally choose this value */ uint32 max_num_domains = q_u->preferred_len < 5 ? q_u->preferred_len : 10; TRUSTDOM **trust_doms; -- cgit From 2968f8a6be77db036bad42e1a8489ca7e8dfd9bc Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 7 Sep 2002 17:08:59 +0000 Subject: merge of printer change notify fix from APP_HEAD (This used to be commit 6a53a9cb7c56927423dea125c65d66605fae566f) --- source3/rpc_server/srv_spoolss_nt.c | 48 ++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3a2bde2d05..795a420a23 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -170,6 +170,41 @@ static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp) SAFE_FREE(*pp); } +/**************************************************************************** + wrapper function to maintain a reference count to the number of + open change notification handles we have +****************************************************************************/ + +static BOOL spooler_message_flags( BOOL doreg ) +{ + static uint32 ref_count = 0; + BOOL result = True; + + /* + * check for boundary counditions .... + * if ref_count == 0 and we want to register OR + * if ref_count == 1 and we want to deregister, THEN + * OK. + */ + + if ( ((ref_count == 0) && doreg) || ((ref_count == 1) && !doreg) ) + result = register_message_flags( doreg, FLAG_MSG_PRINTING ); + + /* increment/decrement reference count */ + + if ( doreg ) + ref_count++; + else { + /* minimum is always 0 */ + if ( ref_count ) + ref_count--; + } + + DEBUG(10,("spooler_message_flags: ref_count == %d\n", ref_count)); + + return result; +} + /*************************************************************************** Disconnect from the client ****************************************************************************/ @@ -198,6 +233,11 @@ static void srv_spoolss_replycloseprinter(POLICY_HND *handle) message_deregister(MSG_PRINTER_NOTIFY2); } + /* Tell the connections db we're not interested in printer notify messages. */ + /* reference count is handled by spooler_message_flags() */ + + spooler_message_flags( False ); + smb_connections--; } @@ -220,9 +260,6 @@ static void free_printer_entry(void *ptr) Printer->notify.option=NULL; Printer->notify.client_connected=False; - /* Tell the connections db we're not interested in printer notify messages. */ - register_message_flags(False, FLAG_MSG_PRINTING); - /* Remove from the internal list. */ DLIST_REMOVE(printers_list, Printer); @@ -2242,8 +2279,6 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE &Printer->notify.client_hnd)) return WERR_SERVER_UNAVAILABLE; - /* Tell the connections db we're interested in printer notify messages. */ - register_message_flags(True, FLAG_MSG_PRINTING); Printer->notify.client_connected=True; return WERR_OK; @@ -5599,9 +5634,6 @@ WERROR _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; - /* Tell the connections db we're not interested in printer notify messages. */ - register_message_flags(False, FLAG_MSG_PRINTING); - return WERR_OK; } -- cgit From 4c471811a439bd9774835496ee9a418a32ae4519 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Sep 2002 06:44:29 +0000 Subject: Actually, I think Jerrys patch was incorrect as it didn't ever add the printing msg flag, only remove it. Also, we already refcount the printer backchannel connection to add the connection tdb flag just before after we register/deregister the notification message handler. Jerry please check ! Jeremy. (This used to be commit c45364ae82e06364cbb11545d1262032e12a21b1) --- source3/rpc_server/srv_spoolss_nt.c | 48 +++++++------------------------------ 1 file changed, 8 insertions(+), 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 795a420a23..a464f073fd 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4,7 +4,7 @@ * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000, - * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Jeremy Allison 2001-2002, * Copyright (C) Gerald Carter 2000-2002, * Copyright (C) Tim Potter 2001-2002. * @@ -170,41 +170,6 @@ static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp) SAFE_FREE(*pp); } -/**************************************************************************** - wrapper function to maintain a reference count to the number of - open change notification handles we have -****************************************************************************/ - -static BOOL spooler_message_flags( BOOL doreg ) -{ - static uint32 ref_count = 0; - BOOL result = True; - - /* - * check for boundary counditions .... - * if ref_count == 0 and we want to register OR - * if ref_count == 1 and we want to deregister, THEN - * OK. - */ - - if ( ((ref_count == 0) && doreg) || ((ref_count == 1) && !doreg) ) - result = register_message_flags( doreg, FLAG_MSG_PRINTING ); - - /* increment/decrement reference count */ - - if ( doreg ) - ref_count++; - else { - /* minimum is always 0 */ - if ( ref_count ) - ref_count--; - } - - DEBUG(10,("spooler_message_flags: ref_count == %d\n", ref_count)); - - return result; -} - /*************************************************************************** Disconnect from the client ****************************************************************************/ @@ -231,12 +196,12 @@ static void srv_spoolss_replycloseprinter(POLICY_HND *handle) cli_ulogoff(¬ify_cli); cli_shutdown(¬ify_cli); message_deregister(MSG_PRINTER_NOTIFY2); - } - /* Tell the connections db we're not interested in printer notify messages. */ - /* reference count is handled by spooler_message_flags() */ + /* Tell the connections db we're no longer interested in + * printer notify messages. */ - spooler_message_flags( False ); + register_message_flags( False, FLAG_MSG_PRINTING ); + } smb_connections--; } @@ -2217,6 +2182,9 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin return False; message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message_list); + /* Tell the connections db we're now interested in printer + * notify messages. */ + register_message_flags( True, FLAG_MSG_PRINTING ); } smb_connections++; -- cgit From 5793e15a27bf9f3bd00120ab0ff000b3935b19bf Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 10 Sep 2002 02:38:15 +0000 Subject: change notify merge from APP_HEAD (This used to be commit b5227f0a645fdf2358fcb880f22e4662efdfe8e3) --- source3/rpc_server/srv_spoolss_nt.c | 340 ++++++++++++++++++++++++++++-------- 1 file changed, 265 insertions(+), 75 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a464f073fd..ff9ac2ce50 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -728,25 +728,177 @@ static struct notify2_message_table job_notify_table[] = { /* 0x17 */ { "JOB_NOTIFY_BYTES_PRINTED", NULL }, }; + +/*********************************************************************** + Allocate talloc context for container object + **********************************************************************/ + +static void notify_msg_ctr_init( SPOOLSS_NOTIFY_MSG_CTR *ctr ) +{ + if ( !ctr ) + return; + + ctr->ctx = talloc_init(); + + return; +} + +/*********************************************************************** + release all allocated memory and zero out structure + **********************************************************************/ + +static void notify_msg_ctr_destroy( SPOOLSS_NOTIFY_MSG_CTR *ctr ) +{ + if ( !ctr ) + return; + + if ( ctr->ctx ) + talloc_destroy(ctr->ctx); + + ZERO_STRUCTP(ctr); + + return; +} + +/*********************************************************************** + **********************************************************************/ + +static TALLOC_CTX* notify_ctr_getctx( SPOOLSS_NOTIFY_MSG_CTR *ctr ) +{ + if ( !ctr ) + return NULL; + + return ctr->ctx; +} + +/*********************************************************************** + **********************************************************************/ + +static SPOOLSS_NOTIFY_MSG_GROUP* notify_ctr_getgroup( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 index ) +{ + if ( !ctr || !ctr->msg_groups ) + return NULL; + + if ( index >= ctr->num_groups ) + return NULL; + + return &ctr->msg_groups[index]; + +} + +/*********************************************************************** + How many groups of change messages do we have ? + **********************************************************************/ + +static int notify_msg_ctr_numgroups( SPOOLSS_NOTIFY_MSG_CTR *ctr ) +{ + if ( !ctr ) + return 0; + + return ctr->num_groups; +} + +/*********************************************************************** + Add a SPOOLSS_NOTIFY_MSG_CTR to the correct group + **********************************************************************/ + +static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MSG *msg ) +{ + SPOOLSS_NOTIFY_MSG_GROUP *groups = NULL; + SPOOLSS_NOTIFY_MSG_GROUP *msg_grp = NULL; + SPOOLSS_NOTIFY_MSG *msg_list = NULL; + int i, new_slot; + + if ( !ctr || !msg ) + return 0; + + /* loop over all groups looking for a matching printer name */ + + for ( i=0; inum_groups; i++ ) { + if ( strcmp(ctr->msg_groups[i].printername, msg->printer) == 0 ) + break; + } + + /* add a new group? */ + + if ( i == ctr->num_groups ) + { + ctr->num_groups++; + + if ( !(groups = talloc_realloc( ctr->ctx, ctr->msg_groups, sizeof(SPOOLSS_NOTIFY_MSG_GROUP)*ctr->num_groups)) ) { + DEBUG(0,("notify_msg_ctr_addmsg: talloc_realloc() failed!\n")); + return 0; + } + ctr->msg_groups = groups; + + /* clear the new entry and set the printer name */ + + ZERO_STRUCT( ctr->msg_groups[ctr->num_groups-1] ); + fstrcpy( ctr->msg_groups[ctr->num_groups-1].printername, msg->printer ); + } + + /* add the change messages; 'i' is the correct index now regardless */ + + msg_grp = &ctr->msg_groups[i]; + + msg_grp->num_msgs++; + + if ( !(msg_list = talloc_realloc( ctr->ctx, msg_grp->msgs, sizeof(SPOOLSS_NOTIFY_MSG)*msg_grp->num_msgs )) ) { + DEBUG(0,("notify_msg_ctr_addmsg: talloc_realloc() failed for new message [%d]!\n", msg_grp->num_msgs)); + return 0; + } + msg_grp->msgs = msg_list; + + new_slot = msg_grp->num_msgs-1; + memcpy( &msg_grp->msgs[new_slot], msg, sizeof(SPOOLSS_NOTIFY_MSG) ); + + /* need to allocate own copy of data */ + + if ( msg->len != 0 ) + msg_grp->msgs[new_slot].notify.data = talloc_memdup( ctr->ctx, msg->notify.data, msg->len ); + + return ctr->num_groups; +} + /*********************************************************************** Send a change notication message on all handles which have a call back registered **********************************************************************/ -static void process_notify2_message(struct spoolss_notify_msg *msg, TALLOC_CTX *mem_ctx) +static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 index ) { - Printer_entry *p; - - DEBUG(8,("process_notify2_message: Enter...[%s]\n", msg->printer)); + Printer_entry *p; + TALLOC_CTX *mem_ctx = notify_ctr_getctx( ctr ); + SPOOLSS_NOTIFY_MSG_GROUP *msg_group = notify_ctr_getgroup( ctr, index ); + SPOOLSS_NOTIFY_MSG *messages; + + + if ( !msg_group ) { + DEBUG(5,("send_notify2_changes() called with no msg group!\n")); + return; + } + + messages = msg_group->msgs; - for (p = printers_list; p; p = p->next) { + if ( !messages ) { + DEBUG(5,("send_notify2_changes() called with no messages!\n")); + return; + } + + DEBUG(8,("send_notify2_changes: Enter...[%s]\n", msg_group->printername)); + + /* loop over all printers */ + + for (p = printers_list; p; p = p->next) + { SPOOL_NOTIFY_INFO_DATA *data; - uint32 data_len = 1; - uint32 id; + uint32 data_len = 0; + uint32 id; + int i; /* Is there notification on this handle? */ - if (!p->notify.client_connected) + if ( !p->notify.client_connected ) continue; DEBUG(10,("Client connected! [%s]\n", p->dev.handlename)); @@ -755,25 +907,31 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, TALLOC_CTX * notifications. */ if ( ( p->printer_type == PRINTER_HANDLE_IS_PRINTER ) && - ( !strequal(msg->printer, p->dev.handlename) ) ) + ( !strequal(msg_group->printername, p->dev.handlename) ) ) continue; DEBUG(10,("Our printer\n")); + /* allocate the max entries possible */ + + data = talloc( mem_ctx, msg_group->num_msgs*sizeof(SPOOL_NOTIFY_INFO_DATA) ); + ZERO_STRUCTP(data); + + /* build the array of change notifications */ + + for ( i=0; inum_msgs; i++ ) + { + SPOOLSS_NOTIFY_MSG *msg = &messages[i]; + /* Are we monitoring this event? */ if (!is_monitoring_event(p, msg->type, msg->field)) continue; + DEBUG(10,("process_notify2_message: Sending message type [%x] field [%x] for printer [%s]\n", msg->type, msg->field, p->dev.handlename)); - /* OK - send the event to the client */ - - data = talloc(mem_ctx, sizeof(SPOOL_NOTIFY_INFO_DATA)); - - ZERO_STRUCTP(data); - /* * if the is a printer notification handle and not a job notification * type, then set the id to 0. Other wise just use what was specified @@ -795,8 +953,8 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, TALLOC_CTX * /* Convert unix jobid to smb jobid */ - if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) { - + if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) + { id = sysjob_to_jobid(msg->id); if (id == -1) { @@ -805,22 +963,20 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, TALLOC_CTX * } } - construct_info_data(data, msg->type, msg->field, id); + construct_info_data( &data[data_len], msg->type, msg->field, id ); switch(msg->type) { case PRINTER_NOTIFY_TYPE: if ( !printer_notify_table[msg->field].fn ) goto done; - - printer_notify_table[msg->field].fn(msg, data, mem_ctx); + printer_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); break; case JOB_NOTIFY_TYPE: if ( !job_notify_table[msg->field].fn ) goto done; - - job_notify_table[msg->field].fn(msg, data, mem_ctx); + job_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); break; @@ -829,60 +985,51 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, TALLOC_CTX * goto done; } + data_len++; + } + cli_spoolss_rrpcn( ¬ify_cli, mem_ctx, &p->notify.client_hnd, data_len, data, p->notify.change, 0 ); } + done: - DEBUG(8,("process_notify2_message: Exit...\n")); + DEBUG(8,("send_notify2_changes: Exit...\n")); return; } -/******************************************************************** - Receive a notify2 message - ********************************************************************/ +/*********************************************************************** + **********************************************************************/ -static void receive_notify2_message(void *buf, size_t len) +static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, void *buf, size_t len ) { - struct spoolss_notify_msg msg; + int offset = 0; - TALLOC_CTX *mem_ctx = talloc_init(); /* Unpack message */ - ZERO_STRUCT(msg); - offset += tdb_unpack((char *)buf + offset, len - offset, "f", - msg.printer); + msg->printer); offset += tdb_unpack((char *)buf + offset, len - offset, "ddddd", - &msg.type, &msg.field, &msg.id, &msg.len, &msg.flags); + &msg->type, &msg->field, &msg->id, &msg->len, &msg->flags); - if (msg.len == 0) + if (msg->len == 0) tdb_unpack((char *)buf + offset, len - offset, "dd", - &msg.notify.value[0], &msg.notify.value[1]); + &msg->notify.value[0], &msg->notify.value[1]); else tdb_unpack((char *)buf + offset, len - offset, "B", - &msg.len, &msg.notify.data); + &msg->len, &msg->notify.data); - DEBUG(3, ("got NOTIFY2 message, type %d, field 0x%02x, flags 0x%04x\n", - msg.type, msg.field, msg.flags)); + DEBUG(3, ("notify2_unpack_msg: got NOTIFY2 message, type %d, field 0x%02x, flags 0x%04x\n", + msg->type, msg->field, msg->flags)); - if (msg.len == 0) - DEBUG(3, ("value1 = %d, value2 = %d\n", msg.notify.value[0], - msg.notify.value[1])); + if (msg->len == 0) + DEBUG(3, ("notify2_unpack_msg: value1 = %d, value2 = %d\n", msg->notify.value[0], + msg->notify.value[1])); else - dump_data(3, msg.notify.data, msg.len); - - /* Process message */ - - process_notify2_message(&msg, mem_ctx); - - /* Free message */ + dump_data(3, msg->notify.data, msg->len); - if (msg.len > 0) - free(msg.notify.data); - - talloc_destroy(mem_ctx); + return True; } /******************************************************************** @@ -891,43 +1038,86 @@ static void receive_notify2_message(void *buf, size_t len) static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, size_t len) { - size_t msg_count, i; - char *buf = (char *)msg; - char *msg_ptr; - - if (len < 4) - goto bad_msg; + size_t msg_count, i; + char *buf = (char *)msg; + char *msg_ptr; + size_t msg_len; + SPOOLSS_NOTIFY_MSG notify; + SPOOLSS_NOTIFY_MSG_CTR messages; + int num_groups; + if (len < 4) { + DEBUG(0,("receive_notify2_message_list: bad message format (len < 4)!\n")); + return; + } + msg_count = IVAL(buf, 0); msg_ptr = buf + 4; DEBUG(5, ("receive_notify2_message_list: got %d messages in list\n", msg_count)); - if (msg_count == 0) - goto bad_msg; - - for (i = 0; i < msg_count; i++) { - size_t msg_len; + if (msg_count == 0) { + DEBUG(0,("receive_notify2_message_list: bad message format (msg_count == 0) !\n")); + return; + } - if (msg_ptr + 4 - buf > len) - goto bad_msg; + /* initialize the container */ + + ZERO_STRUCT( messages ); + notify_msg_ctr_init( &messages ); + + /* + * build message groups for each printer identified + * in a change_notify msg. Remember that a PCN message + * includes the handle returned for the srv_spoolss_replyopenprinter() + * call. Therefore messages are grouped according to printer handle. + */ + + for ( i=0; i len) { + DEBUG(0,("receive_notify2_message_list: bad message format (len > buf_size) !\n")); + return; + } msg_len = IVAL(msg_ptr,0); msg_ptr += 4; - if (msg_ptr + msg_len - buf > len) - goto bad_msg; - receive_notify2_message(msg_ptr, msg_len); + if (msg_ptr + msg_len - buf > len) { + DEBUG(0,("receive_notify2_message_list: bad message format (bad len) !\n")); + return; + } + + /* unpack messages */ + + ZERO_STRUCT( notify ); + notify2_unpack_msg( ¬ify, msg_ptr, msg_len ); msg_ptr += msg_len; + + /* add to correct list in container */ + + notify_msg_ctr_addmsg( &messages, ¬ify ); + + /* free memory that might have been allocated by notify2_unpack_msg() */ + + if ( notify.len != 0 ) + SAFE_FREE( notify.notify.data ); } - - DEBUG(10,("receive_notify2_message_list: processed %u messages\n", - (unsigned int)msg_count )); + + /* process each group of messages */ + + num_groups = notify_msg_ctr_numgroups( &messages ); + for ( i=0; i Date: Tue, 10 Sep 2002 21:37:53 +0000 Subject: AbortPrinter() fix merged from APP_HEAD. (This used to be commit 97ede49e1271fa00c6ffdf9e6e3c2330ea935461) --- source3/rpc_server/srv_spoolss_nt.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ff9ac2ce50..07c22b063a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5417,13 +5417,31 @@ static WERROR control_printer(POLICY_HND *handle, uint32 command, /******************************************************************** * api_spoolss_abortprinter + * From MSDN: "Deletes printer's spool file if printer is configured + * for spooling" ********************************************************************/ WERROR _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R_ABORTPRINTER *r_u) { - POLICY_HND *handle = &q_u->handle; - - return control_printer(handle, PRINTER_CONTROL_PURGE, p); + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + int snum; + struct current_user user; + WERROR errcode = WERR_OK; + + if (!Printer) { + DEBUG(2,("_spoolss_abortprinter: Invalid handle (%s:%u:%u)\n",OUR_HANDLE(handle))); + return WERR_BADFID; + } + + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + + get_current_user( &user, p ); + + print_job_delete( &user, snum, Printer->jobid, &errcode ); + + return errcode; } /******************************************************************** -- cgit From f1be21f211143b0108fc814c01c10f6d36635929 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 10 Sep 2002 21:41:25 +0000 Subject: removed warning about shadowed globals (This used to be commit 8021bbbd0c5fad6db45a4c862848ea667cad0b79) --- source3/rpc_server/srv_spoolss_nt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 07c22b063a..8b5dcd3b6c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -774,15 +774,15 @@ static TALLOC_CTX* notify_ctr_getctx( SPOOLSS_NOTIFY_MSG_CTR *ctr ) /*********************************************************************** **********************************************************************/ -static SPOOLSS_NOTIFY_MSG_GROUP* notify_ctr_getgroup( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 index ) +static SPOOLSS_NOTIFY_MSG_GROUP* notify_ctr_getgroup( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) { if ( !ctr || !ctr->msg_groups ) return NULL; - if ( index >= ctr->num_groups ) + if ( idx >= ctr->num_groups ) return NULL; - return &ctr->msg_groups[index]; + return &ctr->msg_groups[idx]; } @@ -865,11 +865,11 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS back registered **********************************************************************/ -static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 index ) +static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) { Printer_entry *p; TALLOC_CTX *mem_ctx = notify_ctr_getctx( ctr ); - SPOOLSS_NOTIFY_MSG_GROUP *msg_group = notify_ctr_getgroup( ctr, index ); + SPOOLSS_NOTIFY_MSG_GROUP *msg_group = notify_ctr_getgroup( ctr, idx ); SPOOLSS_NOTIFY_MSG *messages; -- cgit From 66f90f97bf13d7f1b9aa18cc59ba1d15b2d8d4b8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 11 Sep 2002 15:18:53 +0000 Subject: Merge the cli_shutdown change from 2_2. All except one call to attempt_netbios_... assumed that cli_shutdown was _not_ called on error anyway... Volker (This used to be commit f0c741594f0dad2da16b1d5692dd56a48b4157f1) --- source3/rpc_server/srv_spoolss_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8b5dcd3b6c..5231e9e681 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2296,6 +2296,7 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, char *remote_ma if (!attempt_netbios_session_request(the_cli, global_myname, remote_machine, &the_cli->dest_ip)) { DEBUG(0,("connect_to_client: machine %s rejected the NetBIOS session request.\n", remote_machine)); + cli_shutdown(the_cli); return False; } -- cgit From c989eaf48d18ed7547880a57a934690dc2519e90 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 11 Sep 2002 17:35:12 +0000 Subject: DelPrinterDrvEx() fix from APP_HEAD (This used to be commit 7841753a03f7fdbd2f7f22e1b184dc1891118283) --- source3/rpc_server/srv_spoolss_nt.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5231e9e681..ae5f132508 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1935,20 +1935,21 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV if ( !W_ERROR_IS_OK(status) ) { - /* if the client asked for a specific version, then we've failed */ + /* + * if the client asked for a specific version, + * or this is something other than Windows NT x86, + * then we've failed + */ - if ( flags & DPD_DELETE_SPECIFIC_VERSION ) + if ( (flags&DPD_DELETE_SPECIFIC_VERSION) || (version !=2) ) goto done; /* try for Win2k driver if "Windows NT x86" */ - if ( version == 2 ) - { - version = 3; - if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) { - status = WERR_UNKNOWN_PRINTER_DRIVER; - goto done; - } + version = 3; + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) { + status = WERR_UNKNOWN_PRINTER_DRIVER; + goto done; } } @@ -1988,6 +1989,7 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV if ( delete_files && printer_driver_files_in_use(info_win2k.info_3) & (flags&DPD_DELETE_ALL_FILES) ) { /* no idea of the correct error here */ + free_a_printer_driver( info_win2k, 3 ); status = WERR_ACCESS_DENIED; goto done; } @@ -1995,7 +1997,7 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV /* if we get to here, we now have 2 driver info structures to remove */ /* remove the Win2k driver first*/ - status_win2k = delete_printer_driver(info.info_3, &user, 3, delete_files); + status_win2k = delete_printer_driver(info_win2k.info_3, &user, 3, delete_files); free_a_printer_driver( info_win2k, 3 ); /* this should not have failed---if it did, report to client */ -- cgit From 88b1f6810b27717146643de96e56cee60ea11b0a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 11 Sep 2002 19:29:02 +0000 Subject: merge from APP_HEAD for GetJob() (This used to be commit 3524a4a348686ae5144a744696606123e4a66622) --- source3/rpc_server/srv_spoolss_nt.c | 38 ++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ae5f132508..bcba89c2cc 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8027,8 +8027,6 @@ static WERROR getjob_level_1(print_queue_struct *queue, int count, int snum, uin fill_job_info_1(info_1, &(queue[i-1]), i, snum); - SAFE_FREE(queue); - *needed += spoolss_size_job_info_1(info_1); if (!alloc_buffer_size(buffer, *needed)) { @@ -8067,12 +8065,14 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin goto done; } - for (i=0; ioffered; uint32 *needed = &r_u->needed; + WERROR wstatus = WERR_OK; int snum; int count; - print_queue_struct *queue=NULL; + print_queue_struct *queue = NULL; print_status_struct prt_status; /* that's an [in out] buffer */ @@ -8139,7 +8140,7 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ DEBUG(5,("spoolss_getjob\n")); - *needed=0; + *needed = 0; if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; @@ -8149,15 +8150,22 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ DEBUGADD(4,("count:[%d], prt_status:[%d], [%s]\n", count, prt_status.status, prt_status.message)); - switch (level) { + switch ( level ) { case 1: - return getjob_level_1(queue, count, snum, jobid, buffer, offered, needed); + wstatus = getjob_level_1(queue, count, snum, jobid, + buffer, offered, needed); + break; case 2: - return getjob_level_2(queue, count, snum, jobid, buffer, offered, needed); + wstatus = getjob_level_2(queue, count, snum, jobid, + buffer, offered, needed); + break; default: - SAFE_FREE(queue); - return WERR_UNKNOWN_LEVEL; + wstatus = WERR_UNKNOWN_LEVEL; + break; } + + SAFE_FREE(queue); + return wstatus; } /******************************************************************** -- cgit From aad3c35ac1197a70c04eccaf7d4fee804a210954 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 18 Sep 2002 19:06:58 +0000 Subject: printjob merge from APP_HEAD regarding device modes (This used to be commit aa52351384abace54a89c9fbfa5e4c31a8464c91) --- source3/rpc_server/srv_spoolss_nt.c | 156 +++++++++++++++++++++--------------- 1 file changed, 93 insertions(+), 63 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index bcba89c2cc..6953ec3663 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -87,6 +87,10 @@ typedef struct _Printer{ fstring machine; fstring user; } client; + + /* devmode sent in the OpenPrinter() call */ + NT_DEVICEMODE *nt_devmode; + } Printer_entry; static Printer_entry *printers_list; @@ -224,6 +228,8 @@ static void free_printer_entry(void *ptr) free_spool_notify_option(&Printer->notify.option); Printer->notify.option=NULL; Printer->notify.client_connected=False; + + free_nt_devicemode( &Printer->nt_devmode ); /* Remove from the internal list. */ DLIST_REMOVE(printers_list, Printer); @@ -1446,9 +1452,9 @@ WERROR _spoolss_open_printer(pipes_struct *p, SPOOL_Q_OPEN_PRINTER *q_u, SPOOL_R WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, SPOOL_R_OPEN_PRINTER_EX *r_u) { - UNISTR2 *printername = NULL; - PRINTER_DEFAULT *printer_default = &q_u->printer_default; - POLICY_HND *handle = &r_u->handle; + UNISTR2 *printername = NULL; + PRINTER_DEFAULT *printer_default = &q_u->printer_default; + POLICY_HND *handle = &r_u->handle; fstring name; int snum; @@ -1606,6 +1612,18 @@ Can't find printer handle we created for printer %s\n", name )); } Printer->access_granted = printer_default->access_required; + + /* + * If the client sent a devmode in the OpenPrinter() call, then + * save it here in case we get a job submission on this handle + */ + + if ( (Printer->printer_type != PRINTER_HANDLE_IS_PRINTSERVER) + && q_u->printer_default.devmode_cont.devmode_ptr ) + { + convert_devicemode( Printer->dev.handlename, q_u->printer_default.devmode_cont.devmode, + &Printer->nt_devmode ); + } return WERR_OK; } @@ -3784,47 +3802,20 @@ static void free_dev_mode(DEVICEMODE *dev) SAFE_FREE(dev); } + /**************************************************************************** - Create a DEVMODE struct. Returns malloced memory. + Convert an NT_DEVICEMODE to a DEVICEMODE structure. Both pointers + should be valid upon entry ****************************************************************************/ -DEVICEMODE *construct_dev_mode(int snum) +static BOOL convert_nt_devicemode( DEVICEMODE *devmode, NT_DEVICEMODE *ntdevmode ) { - char adevice[32]; - char aform[32]; - NT_PRINTER_INFO_LEVEL *printer = NULL; - NT_DEVICEMODE *ntdevmode = NULL; - DEVICEMODE *devmode = NULL; - - DEBUG(7,("construct_dev_mode\n")); - - DEBUGADD(8,("getting printer characteristics\n")); - - if ((devmode = (DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL) { - DEBUG(2,("construct_dev_mode: malloc fail.\n")); - return NULL; - } - - ZERO_STRUCTP(devmode); - - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) - goto fail; - - if (printer->info_2->devmode) - ntdevmode = dup_nt_devicemode(printer->info_2->devmode); - - if (ntdevmode == NULL) { - DEBUG(5, ("BONG! There was no device mode!\n")); - goto fail; - } - - DEBUGADD(8,("loading DEVICEMODE\n")); - - slprintf(adevice, sizeof(adevice)-1, printer->info_2->printername); - init_unistr(&devmode->devicename, adevice); + if ( !devmode || !ntdevmode ) + return False; + + init_unistr(&devmode->devicename, ntdevmode->devicename); - slprintf(aform, sizeof(aform)-1, ntdevmode->formname); - init_unistr(&devmode->formname, aform); + init_unistr(&devmode->formname, ntdevmode->formname); devmode->specversion = ntdevmode->specversion; devmode->driverversion = ntdevmode->driverversion; @@ -3852,23 +3843,51 @@ DEVICEMODE *construct_dev_mode(int snum) if (ntdevmode->private != NULL) { if ((devmode->private=(uint8 *)memdup(ntdevmode->private, ntdevmode->driverextra)) == NULL) - goto fail; + return False; } + + return True; +} - free_nt_devicemode(&ntdevmode); - free_a_printer(&printer,2); +/**************************************************************************** + Create a DEVMODE struct. Returns malloced memory. +****************************************************************************/ - return devmode; +DEVICEMODE *construct_dev_mode(int snum) +{ + NT_PRINTER_INFO_LEVEL *printer = NULL; + DEVICEMODE *devmode = NULL; + + DEBUG(7,("construct_dev_mode\n")); + + DEBUGADD(8,("getting printer characteristics\n")); - fail: + if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) + return NULL; - if (ntdevmode) - free_nt_devicemode(&ntdevmode); - if (printer) - free_a_printer(&printer,2); - free_dev_mode(devmode); + if ( !printer->info_2->devmode ) { + DEBUG(5, ("BONG! There was no device mode!\n")); + goto done; + } + + if ((devmode = (DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL) { + DEBUG(2,("construct_dev_mode: malloc fail.\n")); + goto done; + } + + ZERO_STRUCTP(devmode); + + DEBUGADD(8,("loading DEVICEMODE\n")); + + if ( !convert_nt_devicemode( devmode, printer->info_2->devmode ) ) { + free_dev_mode( devmode ); + devmode = NULL; + } - return NULL; +done: + free_a_printer(&printer,2); + + return devmode; } /******************************************************************** @@ -5286,10 +5305,6 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S * in EMF format. * * So I add checks like in NT Server ... - * - * lkclXXXX jean-francois, i love this kind of thing. oh, well, - * there's a bug in NT client-side code, so we'll fix it in the - * server-side code. *nnnnnggggh!* */ if (info_1->p_datatype != 0) { @@ -5307,7 +5322,7 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S unistr2_to_ascii(jobname, &info_1->docname, sizeof(jobname)); - Printer->jobid = print_job_start(&user, snum, jobname); + Printer->jobid = print_job_start(&user, snum, jobname, Printer->nt_devmode); /* An error occured in print_job_start() so return an appropriate NT error code. */ @@ -8013,7 +8028,7 @@ static WERROR getjob_level_1(print_queue_struct *queue, int count, int snum, uin return WERR_NOMEM; } - for (i=0; i Date: Thu, 19 Sep 2002 12:34:39 +0000 Subject: trivial comment fix (This used to be commit 9d6331524089d76c5832b9ba001fb0e8a05f39d7) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e2336aca55..fd1111d5dc 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4072,9 +4072,9 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ } /********************************************************************* - _samr_set_groupinfo + _samr_set_aliasinfo - update a domain group's comment. + update an alias's comment. *********************************************************************/ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_SET_ALIASINFO *r_u) -- cgit From 06ce201a29bb90a428a59a3d85752ccf2dca1bdd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 23 Sep 2002 16:21:01 +0000 Subject: Ok, getting a bit more ambitious. Stop me, if this is wrong. ;-) When creating a group you have to take care of the fact that the underlying unix might not like the group name. This change gets around that problem by giving the add group script the chance to invent a group name. It then must only return the newly created numerical gid. Volker (This used to be commit b959419ed38e66a12b63cad3e5fbfa849f952acc) --- source3/rpc_server/srv_samr_nt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index fd1111d5dc..ea631838da 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3857,6 +3857,7 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S struct samr_info *info; PRIVILEGE_SET priv_set; uint32 acc_granted; + gid_t gid; init_privilege(&priv_set); @@ -3880,10 +3881,11 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S return NT_STATUS_GROUP_EXISTS; /* we can create the UNIX group */ - smb_create_group(name); + if (smb_create_group(name, &gid) != 0) + return NT_STATUS_ACCESS_DENIED; /* check if the group has been successfully created */ - if ((grp=getgrnam(name)) == NULL) + if ((grp=getgrgid(gid)) == NULL) return NT_STATUS_ACCESS_DENIED; r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); @@ -3920,6 +3922,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S struct samr_info *info; PRIVILEGE_SET priv_set; uint32 acc_granted; + gid_t gid; init_privilege(&priv_set); @@ -3943,10 +3946,11 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S return NT_STATUS_GROUP_EXISTS; /* we can create the UNIX group */ - smb_create_group(name); + if (smb_create_group(name, &gid) != 0) + return NT_STATUS_ACCESS_DENIED; /* check if the group has been successfully created */ - if ((grp=getgrnam(name)) == NULL) + if ((grp=getgrgid(gid)) == NULL) return NT_STATUS_ACCESS_DENIED; r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); -- cgit From 2b6057ef1f9fbfb583a2f77e3b5d3aee2c115fe4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 23 Sep 2002 17:50:04 +0000 Subject: Ok, what's this? Samba as a PDC wants to authenticate a user coming in to a native NT member server. If the logoff time in the samlogon reply is set to something else but infinity, the tree connect to the member server comes back with 'bad uid'. In my traces, NT PDC sends 0x7fff.. always. Weird, but true. I would really like others to double-check this. If you have questions regarding the setup, feel free to ask! Thanks! Volker (This used to be commit 066b163bde9419d32fe8ffe00c1841107357c138) --- source3/rpc_server/srv_netlog_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 8f6011826a..4478729e4d 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -712,8 +712,8 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * pdb_get_logon_script(sampw), pdb_get_profile_path(sampw), pdb_get_logon_time(sampw), - pdb_get_logoff_time(sampw), - pdb_get_kickoff_time(sampw), + get_time_t_max(), + get_time_t_max(), pdb_get_pass_last_set_time(sampw), pdb_get_pass_can_change_time(sampw), pdb_get_pass_must_change_time(sampw), -- cgit From 4912dd90eeebc0c35240703cdae8ce98e572a47b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 25 Sep 2002 05:01:51 +0000 Subject: merge from APP_HEAD (This used to be commit 930c6710fe076b52ad21addf5fcda834f85e15a9) --- source3/rpc_server/srv_spoolss_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 6953ec3663..2190215107 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5421,11 +5421,13 @@ static WERROR control_printer(POLICY_HND *handle, uint32 command, errcode = WERR_OK; } break; +#if 0 /* JERRY - Never called */ case PRINTER_CONTROL_PURGE: if (print_queue_purge(&user, snum, &errcode)) { errcode = WERR_OK; } break; +#endif default: return WERR_UNKNOWN_LEVEL; } -- cgit From a834a73e341059be154426390304a42e4a011f72 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 25 Sep 2002 15:19:00 +0000 Subject: sync'ing up for 3.0alpha20 release (This used to be commit 65e7b5273bb58802bf0c389b77f7fcae0a1f6139) --- source3/rpc_server/srv_lsa_nt.c | 2 + source3/rpc_server/srv_netlog_nt.c | 4 +- source3/rpc_server/srv_pipe.c | 38 +- source3/rpc_server/srv_reg_nt.c | 14 +- source3/rpc_server/srv_samr_nt.c | 131 ++- source3/rpc_server/srv_spoolss_nt.c | 1898 ++++++++++++++++++++++------------- source3/rpc_server/srv_srvsvc_nt.c | 6 +- 7 files changed, 1304 insertions(+), 789 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f28441886a..e187e1556e 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -473,6 +473,8 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E /* * preferred length is set to 5 as a "our" preferred length * nt sets this parameter to 2 + * update (20.08.2002): it's not preferred length, but preferred size! + * it needs further investigation how to optimally choose this value */ uint32 max_num_domains = q_u->preferred_len < 5 ? q_u->preferred_len : 10; TRUSTDOM **trust_doms; diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 8f6011826a..4478729e4d 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -712,8 +712,8 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * pdb_get_logon_script(sampw), pdb_get_profile_path(sampw), pdb_get_logon_time(sampw), - pdb_get_logoff_time(sampw), - pdb_get_kickoff_time(sampw), + get_time_t_max(), + get_time_t_max(), pdb_get_pass_last_set_time(sampw), pdb_get_pass_can_change_time(sampw), pdb_get_pass_must_change_time(sampw), diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index b7be415abc..1947d5514e 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -276,9 +276,6 @@ static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlm auth_usersupplied_info *user_info = NULL; auth_serversupplied_info *server_info = NULL; - uid_t uid; - uid_t gid; - DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); memset(p->user_name, '\0', sizeof(p->user_name)); @@ -427,27 +424,30 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); memcpy(p->session_key, server_info->session_key, sizeof(p->session_key)); - uid = pdb_get_uid(server_info->sam_account); - gid = pdb_get_gid(server_info->sam_account); - - p->pipe_user.uid = uid; - p->pipe_user.gid = gid; - - /* Set up pipe user group membership. */ - initialise_groups(p->pipe_user_name, p->pipe_user.uid, p->pipe_user.gid); - get_current_groups(p->pipe_user.gid, &p->pipe_user.ngroups, &p->pipe_user.groups); + p->pipe_user.uid = pdb_get_uid(server_info->sam_account); + p->pipe_user.gid = pdb_get_gid(server_info->sam_account); + + p->pipe_user.ngroups = server_info->n_groups; + if (p->pipe_user.ngroups) { + if (!(p->pipe_user.groups = memdup(server_info->groups, sizeof(gid_t) * p->pipe_user.ngroups))) { + DEBUG(0,("failed to memdup group list to p->pipe_user.groups\n")); + free_server_info(&server_info); + return False; + } + } if (server_info->ptok) - add_supplementary_nt_login_groups(&p->pipe_user.ngroups, &p->pipe_user.groups, &server_info->ptok); - - /* Create an NT_USER_TOKEN struct for this user. */ - p->pipe_user.nt_user_token = create_nt_token(p->pipe_user.uid,p->pipe_user.gid, - p->pipe_user.ngroups, p->pipe_user.groups, - server_info->guest, server_info->ptok); + p->pipe_user.nt_user_token = dup_nt_token(server_info->ptok); + else { + DEBUG(1,("Error: Authmodule failed to provide nt_user_token\n")); + p->pipe_user.nt_user_token = NULL; + free_server_info(&server_info); + return False; + } p->ntlmssp_auth_validated = True; - pdb_free_sam(&server_info->sam_account); + free_server_info(&server_info); return True; } diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index cd9596d2a7..f96de7e533 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -342,6 +342,9 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) { NTSTATUS status = NT_STATUS_NO_SUCH_FILE; fstring name; + char *value_ascii = ""; + fstring value; + int value_length; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); REGISTRY_VALUE *val = NULL; REGISTRY_VALUE emptyval; @@ -380,15 +383,20 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_LANMANNT, strlen(REG_PT_LANMANNT)+1 ); + value_ascii = REG_PT_LANMANNT; break; case ROLE_STANDALONE: - regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_SERVERNT, strlen(REG_PT_SERVERNT)+1 ); + value_ascii = REG_PT_SERVERNT; break; case ROLE_DOMAIN_MEMBER: - regval_ctr_addvalue( ®vals, REGSTR_PRODUCTTYPE, REG_SZ, REG_PT_WINNT, strlen(REG_PT_WINNT)+1 ); + value_ascii = REG_PT_WINNT; break; } + value_length = push_ucs2(value, value, value_ascii, + sizeof(value), + STR_TERMINATE|STR_NOALIGN); + regval_ctr_addvalue(®vals, REGSTR_PRODUCTTYPE, REG_SZ, + value, value_length); val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a30622c600..ea631838da 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -57,6 +57,8 @@ struct samr_info { DOM_SID sid; uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ uint32 acc_granted; + uint16 acb_mask; + BOOL all_machines; DISP_INFO disp_info; TALLOC_CTX *mem_ctx; @@ -68,8 +70,7 @@ struct generic_mapping usr_generic_mapping = {USER_READ, USER_WRITE, USER_EXECUT struct generic_mapping grp_generic_mapping = {GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, GROUP_ALL_ACCESS}; struct generic_mapping ali_generic_mapping = {ALIAS_READ, ALIAS_WRITE, ALIAS_EXECUTE, ALIAS_ALL_ACCESS}; -static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *d_size); - +static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size); /******************************************************************* Checks if access to an object should be granted, and returns that @@ -151,26 +152,36 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) return info; } + /******************************************************************* Function to free the per handle data. ********************************************************************/ -static void free_samr_db(struct samr_info *info) +static void free_samr_users(struct samr_info *info) { int i; - /* Groups are talloced */ - if (info->disp_info.user_dbloaded){ for (i=0; idisp_info.num_user_account; i++) { /* Not really a free, actually a 'clear' */ pdb_free_sam(&info->disp_info.disp_user_info[i].sam); } } - info->disp_info.user_dbloaded=False; + info->disp_info.num_user_account=0; +} + + +/******************************************************************* + Function to free the per handle data. + ********************************************************************/ +static void free_samr_db(struct samr_info *info) +{ + /* Groups are talloced */ + + free_samr_users(info); + info->disp_info.group_dbloaded=False; info->disp_info.num_group_account=0; - info->disp_info.num_user_account=0; } @@ -199,7 +210,7 @@ static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) } -static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) +static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOOL all_machines) { SAM_ACCOUNT *pwd = NULL; DISP_USER_INFO *pwd_array = NULL; @@ -209,11 +220,15 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) DEBUG(10,("load_sampwd_entries\n")); /* if the snapshoot is already loaded, return */ - if (info->disp_info.user_dbloaded==True) { + if ((info->disp_info.user_dbloaded==True) + && (info->acb_mask == acb_mask) + && (info->all_machines == all_machines)) { DEBUG(10,("load_sampwd_entries: already in memory\n")); return NT_STATUS_OK; } + free_samr_users(info); + if (!pdb_setsampwent(False)) { DEBUG(0, ("load_sampwd_entries: Unable to open passdb.\n")); return NT_STATUS_ACCESS_DENIED; @@ -222,10 +237,19 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) for (; (NT_STATUS_IS_OK(nt_status = pdb_init_sam_talloc(mem_ctx, &pwd))) && pdb_getsampwent(pwd) == True; pwd=NULL) { - if (acb_mask != 0 && !(pdb_get_acct_ctrl(pwd) & acb_mask)) { - pdb_free_sam(&pwd); - DEBUG(5,(" acb_mask %x reject\n", acb_mask)); - continue; + if (all_machines) { + if (!((pdb_get_acct_ctrl(pwd) & ACB_WSTRUST) + || (pdb_get_acct_ctrl(pwd) & ACB_SVRTRUST))) { + DEBUG(5,("load_sampwd_entries: '%s' is not a machine account - ACB: %x - skipping\n", pdb_get_username(pwd), acb_mask)); + pdb_free_sam(&pwd); + continue; + } + } else { + if (acb_mask != 0 && !(pdb_get_acct_ctrl(pwd) & acb_mask)) { + pdb_free_sam(&pwd); + DEBUG(5,(" acb_mask %x reject\n", acb_mask)); + continue; + } } /* Realloc some memory for the array of ptr to the SAM_ACCOUNT structs */ @@ -253,6 +277,8 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask) /* the snapshoot is in memory, we're ready to enumerate fast */ + info->acb_mask = acb_mask; + info->all_machines = all_machines; info->disp_info.user_dbloaded=True; DEBUG(12,("load_sampwd_entries: done\n")); @@ -406,46 +432,6 @@ NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, return r_u->status; } - -/******************************************************************* - samr_make_sam_obj_sd - ********************************************************************/ - -static NTSTATUS samr_make_sam_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) -{ - extern DOM_SID global_sid_World; - DOM_SID adm_sid; - DOM_SID act_sid; - - SEC_ACE ace[3]; - SEC_ACCESS mask; - - SEC_ACL *psa = NULL; - - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); - - sid_copy(&act_sid, &global_sid_Builtin); - sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); - - /*basic access for every one*/ - init_sec_access(&mask, SAMR_EXECUTE | SAMR_READ); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, SAMR_ALL_ACCESS); - init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) - return NT_STATUS_NO_MEMORY; - - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) - return NT_STATUS_NO_MEMORY; - - return NT_STATUS_OK; -} - /******************************************************************* samr_make_dom_obj_sd ********************************************************************/ @@ -787,7 +773,7 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); become_root(); - r_u->status=load_sampwd_entries(info, q_u->acb_mask); + r_u->status=load_sampwd_entries(info, q_u->acb_mask, False); unbecome_root(); if (!NT_STATUS_IS_OK(r_u->status)) @@ -1058,8 +1044,6 @@ static NTSTATUS get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DO /******************************************************************* samr_reply_enum_dom_groups - Only reply with one group - domain admins. This must be fixed for - a real PDC. JRA. ********************************************************************/ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_R_ENUM_DOM_GROUPS *r_u) @@ -1143,7 +1127,6 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, { struct samr_info *info = NULL; uint32 struct_size=0x20; /* W2K always reply that, client doesn't care */ - uint16 acb_mask; uint32 max_entries=q_u->max_entries; uint32 enum_context=q_u->start_idx; @@ -1194,20 +1177,14 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, * JFM, 12/20/2001 */ - /* Get what we need from the password database */ - - if (q_u->switch_level==2) - acb_mask = ACB_WSTRUST; - else - acb_mask = ACB_NORMAL; - /* Get what we need from the password database */ switch (q_u->switch_level) { case 0x1: case 0x2: case 0x4: become_root(); - r_u->status=load_sampwd_entries(info, acb_mask); + /* Level 2 is for all machines, otherwise only 'normal' users */ + r_u->status=load_sampwd_entries(info, ACB_NORMAL, q_u->switch_level==2); unbecome_root(); if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); @@ -2126,7 +2103,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA break; case 0x02: become_root(); - r_u->status=load_sampwd_entries(info, ACB_NORMAL); + r_u->status=load_sampwd_entries(info, ACB_NORMAL, False); unbecome_root(); if (!NT_STATUS_IS_OK(r_u->status)) { DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); @@ -3880,6 +3857,7 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S struct samr_info *info; PRIVILEGE_SET priv_set; uint32 acc_granted; + gid_t gid; init_privilege(&priv_set); @@ -3903,10 +3881,11 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S return NT_STATUS_GROUP_EXISTS; /* we can create the UNIX group */ - smb_create_group(name); + if (smb_create_group(name, &gid) != 0) + return NT_STATUS_ACCESS_DENIED; /* check if the group has been successfully created */ - if ((grp=getgrnam(name)) == NULL) + if ((grp=getgrgid(gid)) == NULL) return NT_STATUS_ACCESS_DENIED; r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); @@ -3943,6 +3922,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S struct samr_info *info; PRIVILEGE_SET priv_set; uint32 acc_granted; + gid_t gid; init_privilege(&priv_set); @@ -3966,10 +3946,11 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S return NT_STATUS_GROUP_EXISTS; /* we can create the UNIX group */ - smb_create_group(name); + if (smb_create_group(name, &gid) != 0) + return NT_STATUS_ACCESS_DENIED; /* check if the group has been successfully created */ - if ((grp=getgrnam(name)) == NULL) + if ((grp=getgrgid(gid)) == NULL) return NT_STATUS_ACCESS_DENIED; r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); @@ -4095,9 +4076,9 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ } /********************************************************************* - _samr_set_groupinfo + _samr_set_aliasinfo - update a domain group's comment. + update an alias's comment. *********************************************************************/ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_SET_ALIASINFO *r_u) @@ -4290,10 +4271,10 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW break; case 0x02: become_root(); - r_u->status=load_sampwd_entries(info, ACB_NORMAL); + r_u->status=load_sampwd_entries(info, ACB_NORMAL, False); unbecome_root(); if (!NT_STATUS_IS_OK(r_u->status)) { - DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); + DEBUG(5, ("_samr_unknown_2e: load_sampwd_entries failed\n")); return r_u->status; } num_users=info->disp_info.num_user_account; @@ -4301,7 +4282,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW r_u->status=load_group_domain_entries(info, get_global_sam_sid()); if (NT_STATUS_IS_ERR(r_u->status)) { - DEBUG(5, ("_samr_query_dispinfo: load_group_domain_entries failed\n")); + DEBUG(5, ("_samr_unknown_2e: load_group_domain_entries failed\n")); return r_u->status; } num_groups=info->disp_info.num_group_account; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7aceaa548f..2190215107 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4,7 +4,7 @@ * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000, - * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Jeremy Allison 2001-2002, * Copyright (C) Gerald Carter 2000-2002, * Copyright (C) Tim Potter 2001-2002. * @@ -87,6 +87,10 @@ typedef struct _Printer{ fstring machine; fstring user; } client; + + /* devmode sent in the OpenPrinter() call */ + NT_DEVICEMODE *nt_devmode; + } Printer_entry; static Printer_entry *printers_list; @@ -196,6 +200,11 @@ static void srv_spoolss_replycloseprinter(POLICY_HND *handle) cli_ulogoff(¬ify_cli); cli_shutdown(¬ify_cli); message_deregister(MSG_PRINTER_NOTIFY2); + + /* Tell the connections db we're no longer interested in + * printer notify messages. */ + + register_message_flags( False, FLAG_MSG_PRINTING ); } smb_connections--; @@ -219,6 +228,8 @@ static void free_printer_entry(void *ptr) free_spool_notify_option(&Printer->notify.option); Printer->notify.option=NULL; Printer->notify.client_connected=False; + + free_nt_devicemode( &Printer->nt_devmode ); /* Remove from the internal list. */ DLIST_REMOVE(printers_list, Printer); @@ -566,7 +577,14 @@ static BOOL is_monitoring_event(Printer_entry *p, uint16 notify_type, { SPOOL_NOTIFY_OPTION *option = p->notify.option; uint32 i, j; - + + /* + * Flags should always be zero when the change notify + * is registered by the cliebnt's spooler. A user Win32 app + * might use the flags though instead of the NOTIFY_OPTION_INFO + * --jerry + */ + if (p->notify.flags) return is_monitoring_event_flags( p->notify.flags, notify_type, notify_field); @@ -716,26 +734,177 @@ static struct notify2_message_table job_notify_table[] = { /* 0x17 */ { "JOB_NOTIFY_BYTES_PRINTED", NULL }, }; + +/*********************************************************************** + Allocate talloc context for container object + **********************************************************************/ + +static void notify_msg_ctr_init( SPOOLSS_NOTIFY_MSG_CTR *ctr ) +{ + if ( !ctr ) + return; + + ctr->ctx = talloc_init(); + + return; +} + +/*********************************************************************** + release all allocated memory and zero out structure + **********************************************************************/ + +static void notify_msg_ctr_destroy( SPOOLSS_NOTIFY_MSG_CTR *ctr ) +{ + if ( !ctr ) + return; + + if ( ctr->ctx ) + talloc_destroy(ctr->ctx); + + ZERO_STRUCTP(ctr); + + return; +} + +/*********************************************************************** + **********************************************************************/ + +static TALLOC_CTX* notify_ctr_getctx( SPOOLSS_NOTIFY_MSG_CTR *ctr ) +{ + if ( !ctr ) + return NULL; + + return ctr->ctx; +} + +/*********************************************************************** + **********************************************************************/ + +static SPOOLSS_NOTIFY_MSG_GROUP* notify_ctr_getgroup( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) +{ + if ( !ctr || !ctr->msg_groups ) + return NULL; + + if ( idx >= ctr->num_groups ) + return NULL; + + return &ctr->msg_groups[idx]; + +} + +/*********************************************************************** + How many groups of change messages do we have ? + **********************************************************************/ + +static int notify_msg_ctr_numgroups( SPOOLSS_NOTIFY_MSG_CTR *ctr ) +{ + if ( !ctr ) + return 0; + + return ctr->num_groups; +} + +/*********************************************************************** + Add a SPOOLSS_NOTIFY_MSG_CTR to the correct group + **********************************************************************/ + +static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MSG *msg ) +{ + SPOOLSS_NOTIFY_MSG_GROUP *groups = NULL; + SPOOLSS_NOTIFY_MSG_GROUP *msg_grp = NULL; + SPOOLSS_NOTIFY_MSG *msg_list = NULL; + int i, new_slot; + + if ( !ctr || !msg ) + return 0; + + /* loop over all groups looking for a matching printer name */ + + for ( i=0; inum_groups; i++ ) { + if ( strcmp(ctr->msg_groups[i].printername, msg->printer) == 0 ) + break; + } + + /* add a new group? */ + + if ( i == ctr->num_groups ) + { + ctr->num_groups++; + + if ( !(groups = talloc_realloc( ctr->ctx, ctr->msg_groups, sizeof(SPOOLSS_NOTIFY_MSG_GROUP)*ctr->num_groups)) ) { + DEBUG(0,("notify_msg_ctr_addmsg: talloc_realloc() failed!\n")); + return 0; + } + ctr->msg_groups = groups; + + /* clear the new entry and set the printer name */ + + ZERO_STRUCT( ctr->msg_groups[ctr->num_groups-1] ); + fstrcpy( ctr->msg_groups[ctr->num_groups-1].printername, msg->printer ); + } + + /* add the change messages; 'i' is the correct index now regardless */ + + msg_grp = &ctr->msg_groups[i]; + + msg_grp->num_msgs++; + + if ( !(msg_list = talloc_realloc( ctr->ctx, msg_grp->msgs, sizeof(SPOOLSS_NOTIFY_MSG)*msg_grp->num_msgs )) ) { + DEBUG(0,("notify_msg_ctr_addmsg: talloc_realloc() failed for new message [%d]!\n", msg_grp->num_msgs)); + return 0; + } + msg_grp->msgs = msg_list; + + new_slot = msg_grp->num_msgs-1; + memcpy( &msg_grp->msgs[new_slot], msg, sizeof(SPOOLSS_NOTIFY_MSG) ); + + /* need to allocate own copy of data */ + + if ( msg->len != 0 ) + msg_grp->msgs[new_slot].notify.data = talloc_memdup( ctr->ctx, msg->notify.data, msg->len ); + + return ctr->num_groups; +} + /*********************************************************************** Send a change notication message on all handles which have a call back registered **********************************************************************/ -static void process_notify2_message(struct spoolss_notify_msg *msg, - TALLOC_CTX *mem_ctx) +static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) { - Printer_entry *p; - - DEBUG(8,("process_notify2_message: Enter...[%s]\n", msg->printer)); + Printer_entry *p; + TALLOC_CTX *mem_ctx = notify_ctr_getctx( ctr ); + SPOOLSS_NOTIFY_MSG_GROUP *msg_group = notify_ctr_getgroup( ctr, idx ); + SPOOLSS_NOTIFY_MSG *messages; + + + if ( !msg_group ) { + DEBUG(5,("send_notify2_changes() called with no msg group!\n")); + return; + } + + messages = msg_group->msgs; - for (p = printers_list; p; p = p->next) { + if ( !messages ) { + DEBUG(5,("send_notify2_changes() called with no messages!\n")); + return; + } + + DEBUG(8,("send_notify2_changes: Enter...[%s]\n", msg_group->printername)); + + /* loop over all printers */ + + for (p = printers_list; p; p = p->next) + { SPOOL_NOTIFY_INFO_DATA *data; - uint32 data_len = 1; - uint32 id; + uint32 data_len = 0; + uint32 id; + int i; /* Is there notification on this handle? */ - if (!p->notify.client_connected) + if ( !p->notify.client_connected ) continue; DEBUG(10,("Client connected! [%s]\n", p->dev.handlename)); @@ -744,25 +913,31 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, notifications. */ if ( ( p->printer_type == PRINTER_HANDLE_IS_PRINTER ) && - ( !strequal(msg->printer, p->dev.handlename) ) ) + ( !strequal(msg_group->printername, p->dev.handlename) ) ) continue; DEBUG(10,("Our printer\n")); + /* allocate the max entries possible */ + + data = talloc( mem_ctx, msg_group->num_msgs*sizeof(SPOOL_NOTIFY_INFO_DATA) ); + ZERO_STRUCTP(data); + + /* build the array of change notifications */ + + for ( i=0; inum_msgs; i++ ) + { + SPOOLSS_NOTIFY_MSG *msg = &messages[i]; + /* Are we monitoring this event? */ if (!is_monitoring_event(p, msg->type, msg->field)) continue; + DEBUG(10,("process_notify2_message: Sending message type [%x] field [%x] for printer [%s]\n", msg->type, msg->field, p->dev.handlename)); - /* OK - send the event to the client */ - - data = talloc(mem_ctx, sizeof(SPOOL_NOTIFY_INFO_DATA)); - - ZERO_STRUCTP(data); - /* * if the is a printer notification handle and not a job notification * type, then set the id to 0. Other wise just use what was specified @@ -784,8 +959,8 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, /* Convert unix jobid to smb jobid */ - if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) { - + if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) + { id = sysjob_to_jobid(msg->id); if (id == -1) { @@ -794,22 +969,20 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, } } - construct_info_data(data, msg->type, msg->field, id); + construct_info_data( &data[data_len], msg->type, msg->field, id ); switch(msg->type) { case PRINTER_NOTIFY_TYPE: if ( !printer_notify_table[msg->field].fn ) goto done; - - printer_notify_table[msg->field].fn(msg, data, mem_ctx); + printer_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); break; case JOB_NOTIFY_TYPE: if ( !job_notify_table[msg->field].fn ) goto done; - - job_notify_table[msg->field].fn(msg, data, mem_ctx); + job_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); break; @@ -818,59 +991,139 @@ static void process_notify2_message(struct spoolss_notify_msg *msg, goto done; } + data_len++; + } + cli_spoolss_rrpcn( ¬ify_cli, mem_ctx, &p->notify.client_hnd, data_len, data, p->notify.change, 0 ); } + done: - DEBUG(8,("process_notify2_message: Exit...\n")); + DEBUG(8,("send_notify2_changes: Exit...\n")); return; } -/* Receive a notify2 message */ +/*********************************************************************** + **********************************************************************/ -static void receive_notify2_message(int msg_type, pid_t src, void *buf, - size_t len) +static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, void *buf, size_t len ) { - struct spoolss_notify_msg msg; + int offset = 0; - TALLOC_CTX *mem_ctx = talloc_init(); /* Unpack message */ - ZERO_STRUCT(msg); - offset += tdb_unpack((char *)buf + offset, len - offset, "f", - msg.printer); + msg->printer); offset += tdb_unpack((char *)buf + offset, len - offset, "ddddd", - &msg.type, &msg.field, &msg.id, &msg.len, &msg.flags); + &msg->type, &msg->field, &msg->id, &msg->len, &msg->flags); - if (msg.len == 0) + if (msg->len == 0) tdb_unpack((char *)buf + offset, len - offset, "dd", - &msg.notify.value[0], &msg.notify.value[1]); + &msg->notify.value[0], &msg->notify.value[1]); else tdb_unpack((char *)buf + offset, len - offset, "B", - &msg.len, &msg.notify.data); + &msg->len, &msg->notify.data); - DEBUG(3, ("got NOTIFY2 message, type %d, field 0x%02x, flags 0x%04x\n", - msg.type, msg.field, msg.flags)); + DEBUG(3, ("notify2_unpack_msg: got NOTIFY2 message, type %d, field 0x%02x, flags 0x%04x\n", + msg->type, msg->field, msg->flags)); - if (msg.len == 0) - DEBUG(3, ("value1 = %d, value2 = %d\n", msg.notify.value[0], - msg.notify.value[1])); + if (msg->len == 0) + DEBUG(3, ("notify2_unpack_msg: value1 = %d, value2 = %d\n", msg->notify.value[0], + msg->notify.value[1])); else - dump_data(3, msg.notify.data, msg.len); + dump_data(3, msg->notify.data, msg->len); + + return True; +} + +/******************************************************************** + Receive a notify2 message list + ********************************************************************/ + +static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, size_t len) +{ + size_t msg_count, i; + char *buf = (char *)msg; + char *msg_ptr; + size_t msg_len; + SPOOLSS_NOTIFY_MSG notify; + SPOOLSS_NOTIFY_MSG_CTR messages; + int num_groups; + + if (len < 4) { + DEBUG(0,("receive_notify2_message_list: bad message format (len < 4)!\n")); + return; + } + + msg_count = IVAL(buf, 0); + msg_ptr = buf + 4; - /* Process message */ + DEBUG(5, ("receive_notify2_message_list: got %d messages in list\n", msg_count)); - process_notify2_message(&msg, mem_ctx); + if (msg_count == 0) { + DEBUG(0,("receive_notify2_message_list: bad message format (msg_count == 0) !\n")); + return; + } - /* Free message */ + /* initialize the container */ + + ZERO_STRUCT( messages ); + notify_msg_ctr_init( &messages ); + + /* + * build message groups for each printer identified + * in a change_notify msg. Remember that a PCN message + * includes the handle returned for the srv_spoolss_replyopenprinter() + * call. Therefore messages are grouped according to printer handle. + */ + + for ( i=0; i len) { + DEBUG(0,("receive_notify2_message_list: bad message format (len > buf_size) !\n")); + return; + } - if (msg.len > 0) - free(msg.notify.data); + msg_len = IVAL(msg_ptr,0); + msg_ptr += 4; - talloc_destroy(mem_ctx); + if (msg_ptr + msg_len - buf > len) { + DEBUG(0,("receive_notify2_message_list: bad message format (bad len) !\n")); + return; + } + + /* unpack messages */ + + ZERO_STRUCT( notify ); + notify2_unpack_msg( ¬ify, msg_ptr, msg_len ); + msg_ptr += msg_len; + + /* add to correct list in container */ + + notify_msg_ctr_addmsg( &messages, ¬ify ); + + /* free memory that might have been allocated by notify2_unpack_msg() */ + + if ( notify.len != 0 ) + SAFE_FREE( notify.notify.data ); + } + + /* process each group of messages */ + + num_groups = notify_msg_ctr_numgroups( &messages ); + for ( i=0; iprinter_default; - POLICY_HND *handle = &r_u->handle; + UNISTR2 *printername = NULL; + PRINTER_DEFAULT *printer_default = &q_u->printer_default; + POLICY_HND *handle = &r_u->handle; fstring name; int snum; @@ -1180,39 +1484,36 @@ Can't find printer handle we created for printer %s\n", name )); return WERR_INVALID_PRINTER_NAME; } - /* - First case: the user is opening the print server: - - Disallow MS AddPrinterWizard if parameter disables it. A Win2k - client 1st tries an OpenPrinterEx with access==0, MUST be allowed. - - Then both Win2k and WinNT clients try an OpenPrinterEx with - SERVER_ALL_ACCESS, which we allow only if the user is root (uid=0) - or if the user is listed in the smb.conf printer admin parameter. - - Then they try OpenPrinterEx with SERVER_READ which we allow. This lets the - client view printer folder, but does not show the MSAPW. - - Note: this test needs code to check access rights here too. Jeremy - could you look at this? - - - Second case: the user is opening a printer: - NT doesn't let us connect to a printer if the connecting user - doesn't have print permission. - - */ - get_current_user(&user, p); - if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) { + /* + * First case: the user is opening the print server: + * + * Disallow MS AddPrinterWizard if parameter disables it. A Win2k + * client 1st tries an OpenPrinterEx with access==0, MUST be allowed. + * + * Then both Win2k and WinNT clients try an OpenPrinterEx with + * SERVER_ALL_ACCESS, which we allow only if the user is root (uid=0) + * or if the user is listed in the smb.conf printer admin parameter. + * + * Then they try OpenPrinterEx with SERVER_READ which we allow. This lets the + * client view printer folder, but does not show the MSAPW. + * + * Note: this test needs code to check access rights here too. Jeremy + * could you look at this? + * + * Second case: the user is opening a printer: + * NT doesn't let us connect to a printer if the connecting user + * doesn't have print permission. + */ + if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + { /* Printserver handles use global struct... */ snum = -1; - /* Map standard access rights to object specific access - rights */ + /* Map standard access rights to object specific access rights */ se_map_standard(&printer_default->access_required, &printserver_std_mapping); @@ -1231,23 +1532,32 @@ Can't find printer handle we created for printer %s\n", name )); /* Allow admin access */ - if (printer_default->access_required & - SERVER_ACCESS_ADMINISTER) { - + if ( printer_default->access_required & SERVER_ACCESS_ADMINISTER ) + { if (!lp_ms_add_printer_wizard()) { close_printer_handle(p, handle); return WERR_ACCESS_DENIED; } - if (user.uid == 0 || - user_in_list(uidtoname(user.uid), - lp_printer_admin(snum))) - return WERR_OK; + /* if the user is not root and not a printer admin, then fail */ - close_printer_handle(p, handle); - return WERR_ACCESS_DENIED; + if ( user.uid != 0 + && !user_in_list(uidtoname(user.uid), lp_printer_admin(snum)) ) + { + close_printer_handle(p, handle); + return WERR_ACCESS_DENIED; + } + + printer_default->access_required = SERVER_ACCESS_ADMINISTER; + } + else + { + printer_default->access_required = SERVER_ACCESS_ENUMERATE; } + DEBUG(4,("Setting print server access = %s\n", (printer_default->access_required == SERVER_ACCESS_ADMINISTER) + ? "SERVER_ACCESS_ADMINISTER" : "SERVER_ACCESS_ENUMERATE" )); + /* We fall through to return WERR_OK */ } @@ -1296,84 +1606,24 @@ Can't find printer handle we created for printer %s\n", name )); else printer_default->access_required = PRINTER_ACCESS_USE; - DEBUG(4,("Setting printer access=%x\n", printer_default->access_required)); - Printer->access_granted = printer_default->access_required; - - /* - * If we have a default device pointer in the - * printer_default struct, then we need to get - * the printer info from the tdb and if there is - * no default devicemode there then we do a *SET* - * here ! This is insanity.... JRA. - */ - - /* - * If the openprinterex rpc call contains a devmode, - * it's a per-user one. This per-user devmode is derivated - * from the global devmode. Openprinterex() contains a per-user - * devmode for when you do EMF printing and spooling. - * In the EMF case, the NT workstation is only doing half the job - * of rendering the page. The other half is done by running the printer - * driver on the server. - * The EMF file doesn't contain the page description (paper size, orientation, ...). - * The EMF file only contains what is to be printed on the page. - * So in order for the server to know how to print, the NT client sends - * a devicemode attached to the openprinterex call. - * But this devicemode is short lived, it's only valid for the current print job. - * - * If Samba would have supported EMF spooling, this devicemode would - * have been attached to the handle, to sent it to the driver to correctly - * rasterize the EMF file. - * - * As Samba only supports RAW spooling, we only receive a ready-to-print file, - * we just act as a pass-thru between windows and the printer. - * - * In order to know that Samba supports only RAW spooling, NT has to call - * getprinter() at level 2 (attribute field) or NT has to call startdoc() - * and until NT sends a RAW job, we refuse it. - * - * But to call getprinter() or startdoc(), you first need a valid handle, - * and to get an handle you have to call openprintex(). Hence why you have - * a devicemode in the openprinterex() call. - * - * - * Differences between NT4 and NT 2000. - * NT4: - * --- - * On NT4, you only have a global devicemode. This global devicemode can be changed - * by the administrator (or by a user with enough privs). Everytime a user - * wants to print, the devicemode is resetted to the default. In Word, everytime - * you print, the printer's characteristics are always reset to the global devicemode. - * - * NT 2000: - * ------- - * In W2K, there is the notion of per-user devicemode. The first time you use - * a printer, a per-user devicemode is build from the global devicemode. - * If you change your per-user devicemode, it is saved in the registry, under the - * H_KEY_CURRENT_KEY sub_tree. So that everytime you print, you have your default - * printer preferences available. - * - * To change the per-user devicemode: it's the "Printing Preferences ..." button - * on the General Tab of the printer properties windows. - * - * To change the global devicemode: it's the "Printing Defaults..." button - * on the Advanced Tab of the printer properties window. - * - * JFM. - */ + DEBUG(4,("Setting printer access = %s\n", (printer_default->access_required == PRINTER_ACCESS_ADMINISTER) + ? "PRINTER_ACCESS_ADMINISTER" : "PRINTER_ACCESS_USE" )); - - -#if 0 - if (printer_default->devmode_cont.devmode != NULL) { - result = printer_write_default_dev( snum, printer_default); - if (result != 0) { - close_printer_handle(p, handle); - return result; - } - } -#endif } + + Printer->access_granted = printer_default->access_required; + + /* + * If the client sent a devmode in the OpenPrinter() call, then + * save it here in case we get a job submission on this handle + */ + + if ( (Printer->printer_type != PRINTER_HANDLE_IS_PRINTSERVER) + && q_u->printer_default.devmode_cont.devmode_ptr ) + { + convert_devicemode( Printer->dev.handlename, q_u->printer_default.devmode_cont.devmode, + &Printer->nt_devmode ); + } return WERR_OK; } @@ -1599,8 +1849,11 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER fstring driver; fstring arch; NT_PRINTER_DRIVER_INFO_LEVEL info; + NT_PRINTER_DRIVER_INFO_LEVEL info_win2k; int version; struct current_user user; + WERROR status; + WERROR status_win2k = WERR_ACCESS_DENIED; get_current_user(&user, p); @@ -1608,25 +1861,58 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)-1 ); /* check that we have a valid driver name first */ - if ((version=get_version_id(arch)) == -1) { - /* this is what NT returns */ + + if ((version=get_version_id(arch)) == -1) return WERR_INVALID_ENVIRONMENT; + + ZERO_STRUCT(info); + ZERO_STRUCT(info_win2k); + + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) + { + /* try for Win2k driver if "Windows NT x86" */ + + if ( version == 2 ) { + version = 3; + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) { + status = WERR_UNKNOWN_PRINTER_DRIVER; + goto done; + } + } } - /* if they said "Windows NT x86", then try for version 2 & 3 */ + if (printer_driver_in_use(info.info_3)) { + status = WERR_PRINTER_DRIVER_IN_USE; + goto done; + } if ( version == 2 ) - version = DRIVER_ANY_VERSION; + { + if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3, driver, arch, 3))) + { + /* if we get to here, we now have 2 driver info structures to remove */ + /* remove the Win2k driver first*/ - ZERO_STRUCT(info); + status_win2k = delete_printer_driver(info_win2k.info_3, &user, 3, False ); + free_a_printer_driver( info_win2k, 3 ); + + /* this should not have failed---if it did, report to client */ + if ( !W_ERROR_IS_OK(status_win2k) ) + goto done; + } + } - if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) - return WERR_UNKNOWN_PRINTER_DRIVER; + status = delete_printer_driver(info.info_3, &user, version, False); + + /* if at least one of the deletes succeeded return OK */ - if (printer_driver_in_use(info.info_3)) - return WERR_PRINTER_DRIVER_IN_USE; + if ( W_ERROR_IS_OK(status) || W_ERROR_IS_OK(status_win2k) ) + status = WERR_OK; + +done: + free_a_printer_driver( info, 3 ); - return delete_printer_driver(info.info_3, &user, DRIVER_ANY_VERSION, False); + return status; } /******************************************************************** @@ -1638,10 +1924,13 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV fstring driver; fstring arch; NT_PRINTER_DRIVER_INFO_LEVEL info; + NT_PRINTER_DRIVER_INFO_LEVEL info_win2k; int version; uint32 flags = q_u->delete_flags; BOOL delete_files; struct current_user user; + WERROR status; + WERROR status_win2k = WERR_ACCESS_DENIED; get_current_user(&user, p); @@ -1656,17 +1945,36 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV if ( flags & DPD_DELETE_SPECIFIC_VERSION ) version = q_u->version; - else if ( version == 2 ) - /* if they said "Windows NT x86", then try for version 2 & 3 */ - version = DRIVER_ANY_VERSION; ZERO_STRUCT(info); + ZERO_STRUCT(info_win2k); + + status = get_a_printer_driver(&info, 3, driver, arch, version); - if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) - return WERR_UNKNOWN_PRINTER_DRIVER; + if ( !W_ERROR_IS_OK(status) ) + { + /* + * if the client asked for a specific version, + * or this is something other than Windows NT x86, + * then we've failed + */ + + if ( (flags&DPD_DELETE_SPECIFIC_VERSION) || (version !=2) ) + goto done; + + /* try for Win2k driver if "Windows NT x86" */ + + version = 3; + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) { + status = WERR_UNKNOWN_PRINTER_DRIVER; + goto done; + } + } - if ( printer_driver_in_use(info.info_3) ) - return WERR_PRINTER_DRIVER_IN_USE; + if ( printer_driver_in_use(info.info_3) ) { + status = WERR_PRINTER_DRIVER_IN_USE; + goto done; + } /* * we have a couple of cases to consider. @@ -1682,24 +1990,119 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV delete_files = flags & (DPD_DELETE_ALL_FILES|DPD_DELETE_UNUSED_FILES); - if ( delete_files ) - { - /* fail if any files are in use and DPD_DELETE_ALL_FILES is set */ + /* fail if any files are in use and DPD_DELETE_ALL_FILES is set */ + + if ( delete_files && printer_driver_files_in_use(info.info_3) & (flags&DPD_DELETE_ALL_FILES) ) { + /* no idea of the correct error here */ + status = WERR_ACCESS_DENIED; + goto done; + } + + + /* also check for W32X86/3 if necessary; maybe we already have? */ + + if ( (version == 2) && ((flags&DPD_DELETE_SPECIFIC_VERSION) != DPD_DELETE_SPECIFIC_VERSION) ) { + if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3, driver, arch, 3))) + { + + if ( delete_files && printer_driver_files_in_use(info_win2k.info_3) & (flags&DPD_DELETE_ALL_FILES) ) { + /* no idea of the correct error here */ + free_a_printer_driver( info_win2k, 3 ); + status = WERR_ACCESS_DENIED; + goto done; + } + + /* if we get to here, we now have 2 driver info structures to remove */ + /* remove the Win2k driver first*/ - if ( printer_driver_files_in_use(info.info_3) & (flags&DPD_DELETE_ALL_FILES) ) - /* no idea of the correct error here */ - return WERR_ACCESS_DENIED; + status_win2k = delete_printer_driver(info_win2k.info_3, &user, 3, delete_files); + free_a_printer_driver( info_win2k, 3 ); + + /* this should not have failed---if it did, report to client */ + + if ( !W_ERROR_IS_OK(status_win2k) ) + goto done; + } } - return delete_printer_driver(info.info_3, &user, version, delete_files); + status = delete_printer_driver(info.info_3, &user, version, delete_files); + + if ( W_ERROR_IS_OK(status) || W_ERROR_IS_OK(status_win2k) ) + status = WERR_OK; +done: + free_a_printer_driver( info, 3 ); + + return status; +} + + +/**************************************************************************** + Internal routine for retreiving printerdata + ***************************************************************************/ + +static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printer, + char *key, char *value, uint32 *type, uint8 **data, + uint32 *needed, uint32 in_size ) +{ + REGISTRY_VALUE *val; + int size, data_len; + + if ( !(val = get_printer_data( printer->info_2, key, value)) ) + return WERR_BADFILE; + + *type = regval_type( val ); + + DEBUG(5,("get_printer_dataex: allocating %d\n", in_size)); + + size = regval_size( val ); + + /* copy the min(in_size, len) */ + + if ( in_size ) { + data_len = (size > in_size) ? in_size : size*sizeof(uint8); + if ( (*data = (uint8 *)talloc_memdup(ctx, regval_data_p(val), data_len)) == NULL ) + return WERR_NOMEM; + } + else + *data = NULL; + + *needed = size; + + DEBUG(5,("get_printer_dataex: copy done\n")); + + return WERR_OK; +} + +/**************************************************************************** + Internal routine for removing printerdata + ***************************************************************************/ + +static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, char *key, char *value ) +{ + delete_printer_data( printer->info_2, key, value ); + + return mod_a_printer(*printer, 2); } +/**************************************************************************** + Internal routine for storing printerdata + ***************************************************************************/ + +static WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, char *key, char *value, + uint32 type, uint8 *data, int real_len ) +{ + delete_printer_data( printer->info_2, key, value ); + + add_printer_data( printer->info_2, key, value, type, data, real_len ); + + return mod_a_printer(*printer, 2); +} /******************************************************************** GetPrinterData on a printer server Handle. ********************************************************************/ -static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size) +static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size) { int i; @@ -1708,50 +2111,50 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 if (!strcmp(value, "W3SvcInstalled")) { *type = 0x4; if((*data = (uint8 *)talloc_zero(ctx, 4*sizeof(uint8) )) == NULL) - return False; - *needed = 0x4; - return True; + return WERR_NOMEM; + *needed = 0x4; + return WERR_OK; } if (!strcmp(value, "BeepEnabled")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) - return False; + return WERR_NOMEM; SIVAL(*data, 0, 0x00); *needed = 0x4; - return True; + return WERR_OK; } if (!strcmp(value, "EventLog")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) - return False; + return WERR_NOMEM; /* formally was 0x1b */ SIVAL(*data, 0, 0x0); *needed = 0x4; - return True; + return WERR_OK; } if (!strcmp(value, "NetPopup")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) - return False; + return WERR_NOMEM; SIVAL(*data, 0, 0x00); *needed = 0x4; - return True; + return WERR_OK; } if (!strcmp(value, "MajorVersion")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) - return False; + return WERR_NOMEM; #ifndef EMULATE_WIN2K_HACK /* JERRY */ SIVAL(*data, 0, 2); #else SIVAL(*data, 0, 3); #endif *needed = 0x4; - return True; + return WERR_OK; } if (!strcmp(value, "DefaultSpoolDirectory")) { @@ -1761,7 +2164,7 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type = 0x1; *needed = 2*(strlen(string)+1); if((*data = (uint8 *)talloc(ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) - return False; + return WERR_NOMEM; memset(*data, 0, (*needed > in_size) ? *needed:in_size); /* it's done by hand ready to go on the wire */ @@ -1769,7 +2172,7 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 (*data)[2*i]=string[i]; (*data)[2*i+1]='\0'; } - return True; + return WERR_OK; } if (!strcmp(value, "Architecture")) { @@ -1777,97 +2180,36 @@ static BOOL getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type = 0x1; *needed = 2*(strlen(string)+1); if((*data = (uint8 *)talloc(ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) - return False; + return WERR_NOMEM; memset(*data, 0, (*needed > in_size) ? *needed:in_size); for (i=0; iinfo_2, SPOOL_PRINTERDATA_KEY, value)) ) - { - free_a_printer(&printer, 2); - return False; - } - - *type = regval_type( val ); - - - DEBUG(5,("getprinterdata_printer:allocating %d\n", in_size)); - - if (in_size) - { - if ( (*data = (uint8 *)talloc(ctx, in_size * sizeof(uint8))) == NULL ) - return False; - - memset( *data, 0, in_size *sizeof(uint8) ); - - /* copy the min(in_size, len) */ - - size = regval_size( val ); - memcpy( *data, regval_data_p(val), (size > in_size) ? in_size : size*sizeof(uint8) ); - } - else - *data = NULL; - - *needed = size; - - DEBUG(5,("getprinterdata_printer:copy done\n")); - - - free_a_printer(&printer, 2); - return True; -} - /******************************************************************** * spoolss_getprinterdata ********************************************************************/ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPOOL_R_GETPRINTERDATA *r_u) { - POLICY_HND *handle = &q_u->handle; - UNISTR2 *valuename = &q_u->valuename; - uint32 in_size = q_u->size; - uint32 *type = &r_u->type; - uint32 *out_size = &r_u->size; - uint8 **data = &r_u->data; - uint32 *needed = &r_u->needed; - - fstring value; - BOOL found=False; - Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + POLICY_HND *handle = &q_u->handle; + UNISTR2 *valuename = &q_u->valuename; + uint32 in_size = q_u->size; + uint32 *type = &r_u->type; + uint32 *out_size = &r_u->size; + uint8 **data = &r_u->data; + uint32 *needed = &r_u->needed; + WERROR status; + fstring value; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum = 0; /* * Reminder: when it's a string, the length is in BYTES @@ -1885,45 +2227,58 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO DEBUG(4,("_spoolss_getprinterdata\n")); - if (!Printer) { - if((*data=(uint8 *)talloc_zero(p->mem_ctx, 4*sizeof(uint8))) == NULL) - return WERR_NOMEM; + if ( !Printer ) { DEBUG(2,("_spoolss_getprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); - return WERR_BADFID; + status = WERR_BADFID; + goto done; } unistr2_to_ascii(value, valuename, sizeof(value)-1); - if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) - found = getprinterdata_printer_server(p->mem_ctx, value, type, data, needed, *out_size); + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER ) + status = getprinterdata_printer_server( p->mem_ctx, value, type, data, needed, *out_size ); else - found = getprinterdata_printer(p, p->mem_ctx, handle, value, type, data, needed, *out_size); + { + if ( !get_printer_snum(p,handle, &snum) ) { + status = WERR_BADFID; + goto done; + } - if ( !found ) + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if ( !W_ERROR_IS_OK(status) ) + goto done; + + status = get_printer_dataex( p->mem_ctx, printer, SPOOL_PRINTERDATA_KEY, value, type, data, needed, *out_size ); + } + + if (*needed > *out_size) + status = WERR_MORE_DATA; + +done: + if ( !W_ERROR_IS_OK(status) ) { - DEBUG(5, ("value not found, allocating %d\n", *out_size)); + DEBUG(5, ("error: allocating %d\n", *out_size)); /* reply this param doesn't exist */ - if (*out_size) { - if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) + if ( *out_size ) { + if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) { + if ( printer ) + free_a_printer( &printer, 2 ); return WERR_NOMEM; - } else { + } + } + else { *data = NULL; } - - /* error depends on handle type */ - - if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) - return WERR_INVALID_PARAM; - else - return WERR_BADFILE; } - if (*needed > *out_size) - return WERR_MORE_DATA; - else - return WERR_OK; + /* cleanup & exit */ + + if ( printer ) + free_a_printer( &printer, 2 ); + + return status; } /********************************************************* @@ -1961,6 +2316,7 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, char *remote_ma if (!attempt_netbios_session_request(the_cli, global_myname, remote_machine, &the_cli->dest_ip)) { DEBUG(0,("connect_to_client: machine %s rejected the NetBIOS session request.\n", remote_machine)); + cli_shutdown(the_cli); return False; } @@ -2036,7 +2392,10 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin if(!spoolss_connect_to_client(¬ify_cli, unix_printer)) return False; - message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message); + message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message_list); + /* Tell the connections db we're now interested in printer + * notify messages. */ + register_message_flags( True, FLAG_MSG_PRINTING ); } smb_connections++; @@ -2436,8 +2795,8 @@ static void spoolss_notify_security_desc(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - data->notify_data.data.length=0; - data->notify_data.data.string = NULL; + data->notify_data.sd.size = printer->info_2->secdesc_buf->len; + data->notify_data.sd.desc = dup_sec_desc( mem_ctx, printer->info_2->secdesc_buf->sec ) ; } /******************************************************************* @@ -3443,47 +3802,20 @@ static void free_dev_mode(DEVICEMODE *dev) SAFE_FREE(dev); } + /**************************************************************************** - Create a DEVMODE struct. Returns malloced memory. + Convert an NT_DEVICEMODE to a DEVICEMODE structure. Both pointers + should be valid upon entry ****************************************************************************/ -DEVICEMODE *construct_dev_mode(int snum) +static BOOL convert_nt_devicemode( DEVICEMODE *devmode, NT_DEVICEMODE *ntdevmode ) { - char adevice[32]; - char aform[32]; - NT_PRINTER_INFO_LEVEL *printer = NULL; - NT_DEVICEMODE *ntdevmode = NULL; - DEVICEMODE *devmode = NULL; - - DEBUG(7,("construct_dev_mode\n")); - - DEBUGADD(8,("getting printer characteristics\n")); - - if ((devmode = (DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL) { - DEBUG(2,("construct_dev_mode: malloc fail.\n")); - return NULL; - } - - ZERO_STRUCTP(devmode); - - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) - goto fail; - - if (printer->info_2->devmode) - ntdevmode = dup_nt_devicemode(printer->info_2->devmode); - - if (ntdevmode == NULL) { - DEBUG(5, ("BONG! There was no device mode!\n")); - goto fail; - } - - DEBUGADD(8,("loading DEVICEMODE\n")); - - slprintf(adevice, sizeof(adevice)-1, printer->info_2->printername); - init_unistr(&devmode->devicename, adevice); + if ( !devmode || !ntdevmode ) + return False; + + init_unistr(&devmode->devicename, ntdevmode->devicename); - slprintf(aform, sizeof(aform)-1, ntdevmode->formname); - init_unistr(&devmode->formname, aform); + init_unistr(&devmode->formname, ntdevmode->formname); devmode->specversion = ntdevmode->specversion; devmode->driverversion = ntdevmode->driverversion; @@ -3511,23 +3843,51 @@ DEVICEMODE *construct_dev_mode(int snum) if (ntdevmode->private != NULL) { if ((devmode->private=(uint8 *)memdup(ntdevmode->private, ntdevmode->driverextra)) == NULL) - goto fail; + return False; } + + return True; +} - free_nt_devicemode(&ntdevmode); - free_a_printer(&printer,2); +/**************************************************************************** + Create a DEVMODE struct. Returns malloced memory. +****************************************************************************/ - return devmode; +DEVICEMODE *construct_dev_mode(int snum) +{ + NT_PRINTER_INFO_LEVEL *printer = NULL; + DEVICEMODE *devmode = NULL; + + DEBUG(7,("construct_dev_mode\n")); + + DEBUGADD(8,("getting printer characteristics\n")); - fail: + if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) + return NULL; - if (ntdevmode) - free_nt_devicemode(&ntdevmode); - if (printer) - free_a_printer(&printer,2); - free_dev_mode(devmode); + if ( !printer->info_2->devmode ) { + DEBUG(5, ("BONG! There was no device mode!\n")); + goto done; + } + + if ((devmode = (DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL) { + DEBUG(2,("construct_dev_mode: malloc fail.\n")); + goto done; + } + + ZERO_STRUCTP(devmode); + + DEBUGADD(8,("loading DEVICEMODE\n")); + + if ( !convert_nt_devicemode( devmode, printer->info_2->devmode ) ) { + free_dev_mode( devmode ); + devmode = NULL; + } - return NULL; +done: + free_a_printer(&printer,2); + + return devmode; } /******************************************************************** @@ -4384,7 +4744,7 @@ static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fst * convert an array of ascii string to a UNICODE string ********************************************************************/ -static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *servername) +static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, char *servername) { int i=0; int j=0; @@ -4397,26 +4757,34 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser while (True) { - if (char_array == NULL) + if ( !char_array ) v = ""; - else { + else + { v = char_array[i]; - if (!v) v = ""; /* hack to handle null lists */ + if (!v) + v = ""; /* hack to handle null lists */ } - if ( !strlen(v) ) - break; + /* hack to allow this to be used in places other than when generating + the list of dependent files */ + + if ( servername ) + slprintf( line, sizeof(line)-1, "\\\\%s%s", servername, v ); + else + pstrcpy( line, v ); - slprintf(line, sizeof(line)-1, "\\\\%s%s", servername, v); - DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); - if((tuary=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL) { + if ( (tuary=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL ) { DEBUG(2,("init_unistr_array: Realloc error\n" )); - return; + return 0; } else *uni_array = tuary; + if ( !strlen(v) ) + break; + j += (rpcstr_push((*uni_array+j), line, sizeof(uint16)*strlen(line)+2, STR_TERMINATE) / sizeof(uint16)); i++; } @@ -4426,6 +4794,10 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser } DEBUGADD(6,("last one:done\n")); + + /* return size of array in uint16's */ + + return j+1; } /******************************************************************** @@ -4444,29 +4816,29 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->name, driver.info_3->name ); init_unistr( &info->architecture, driver.info_3->environment ); - if (strlen(driver.info_3->driverpath)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); - init_unistr( &info->driverpath, temp ); - } else - init_unistr( &info->driverpath, "" ); + if (strlen(driver.info_3->driverpath)) { + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + init_unistr( &info->driverpath, temp ); + } else + init_unistr( &info->driverpath, "" ); - if (strlen(driver.info_3->datafile)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); - init_unistr( &info->datafile, temp ); - } else - init_unistr( &info->datafile, "" ); + if (strlen(driver.info_3->datafile)) { + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); + init_unistr( &info->datafile, temp ); + } else + init_unistr( &info->datafile, "" ); - if (strlen(driver.info_3->configfile)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); - init_unistr( &info->configfile, temp ); - } else - init_unistr( &info->configfile, "" ); + if (strlen(driver.info_3->configfile)) { + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); + init_unistr( &info->configfile, temp ); + } else + init_unistr( &info->configfile, "" ); - if (strlen(driver.info_3->helpfile)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile); - init_unistr( &info->helpfile, temp ); - } else - init_unistr( &info->helpfile, "" ); + if (strlen(driver.info_3->helpfile)) { + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile); + init_unistr( &info->helpfile, temp ); + } else + init_unistr( &info->helpfile, "" ); init_unistr( &info->monitorname, driver.info_3->monitorname ); init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype ); @@ -4933,10 +5305,6 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S * in EMF format. * * So I add checks like in NT Server ... - * - * lkclXXXX jean-francois, i love this kind of thing. oh, well, - * there's a bug in NT client-side code, so we'll fix it in the - * server-side code. *nnnnnggggh!* */ if (info_1->p_datatype != 0) { @@ -4954,7 +5322,7 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S unistr2_to_ascii(jobname, &info_1->docname, sizeof(jobname)); - Printer->jobid = print_job_start(&user, snum, jobname); + Printer->jobid = print_job_start(&user, snum, jobname, Printer->nt_devmode); /* An error occured in print_job_start() so return an appropriate NT error code. */ @@ -5004,6 +5372,13 @@ WERROR _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R return WERR_BADFID; (*buffer_written) = print_job_write(snum, Printer->jobid, (char *)buffer, buffer_size); + if (*buffer_written == -1) { + r_u->buffer_written = 0; + if (errno == ENOSPC) + return WERR_NO_SPOOL_SPACE; + else + return WERR_ACCESS_DENIED; + } r_u->buffer_written = q_u->buffer_size2; @@ -5046,11 +5421,13 @@ static WERROR control_printer(POLICY_HND *handle, uint32 command, errcode = WERR_OK; } break; +#if 0 /* JERRY - Never called */ case PRINTER_CONTROL_PURGE: if (print_queue_purge(&user, snum, &errcode)) { errcode = WERR_OK; } break; +#endif default: return WERR_UNKNOWN_LEVEL; } @@ -5060,13 +5437,31 @@ static WERROR control_printer(POLICY_HND *handle, uint32 command, /******************************************************************** * api_spoolss_abortprinter + * From MSDN: "Deletes printer's spool file if printer is configured + * for spooling" ********************************************************************/ WERROR _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R_ABORTPRINTER *r_u) { - POLICY_HND *handle = &q_u->handle; - - return control_printer(handle, PRINTER_CONTROL_PURGE, p); + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + int snum; + struct current_user user; + WERROR errcode = WERR_OK; + + if (!Printer) { + DEBUG(2,("_spoolss_abortprinter: Invalid handle (%s:%u:%u)\n",OUR_HANDLE(handle))); + return WERR_BADFID; + } + + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + + get_current_user( &user, p ); + + print_job_delete( &user, snum, Printer->jobid, &errcode ); + + return errcode; } /******************************************************************** @@ -5315,22 +5710,6 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, goto done; } -#if 0 /* JERRY */ - - /* - * Another one of those historical misunderstandings... - * This is reminisent of a similar call we had in _spoolss_setprinterdata() - * I'm leaving it here as a reminder. --jerry - */ - - if (nt_printer_info_level_equal(printer, old_printer)) { - DEBUG(3, ("update_printer: printer info has not changed\n")); - result = WERR_OK; - goto done; - } - -#endif - /* Check calling user has permission to update printer description */ if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { @@ -5349,49 +5728,22 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, } /* - * Set the DRIVER_INIT info in the tdb; trigger on magic value for the - * DEVMODE.displayfrequency, which is not used for printer drivers. This - * requires Win32 client code (see other notes elsewhere in the code). + * When a *new* driver is bound to a printer, the drivername is used to + * lookup previously saved driver initialization info, which is then + * bound to the printer, simulating what happens in the Windows arch. */ - if (printer->info_2->devmode && - printer->info_2->devmode->displayfrequency == MAGIC_DISPLAY_FREQUENCY) + if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)) { - - DEBUG(10,("update_printer: Save printer driver init data\n")); - printer->info_2->devmode->displayfrequency = 0; - - if (update_driver_init(*printer, 2)!=0) { - DEBUG(10,("update_printer: error updating printer driver init DEVMODE\n")); - result = WERR_ACCESS_DENIED; - goto done; - } - - /* we need to reset all driver init data for all printers - bound to this driver */ - - srv_spoolss_reset_printerdata( printer->info_2->drivername ); - - } - else - { - /* - * When a *new* driver is bound to a printer, the drivername is used to - * lookup previously saved driver initialization info, which is then - * bound to the printer, simulating what happens in the Windows arch. - */ - if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)) + if (!set_driver_init(printer, 2)) { - if (!set_driver_init(printer, 2)) - { - DEBUG(5,("update_printer: Error restoring driver initialization data for driver [%s]!\n", - printer->info_2->drivername)); - } - - DEBUG(10,("update_printer: changing driver [%s]! Sending event!\n", + DEBUG(5,("update_printer: Error restoring driver initialization data for driver [%s]!\n", printer->info_2->drivername)); - - notify_printer_driver(snum, printer->info_2->drivername); } + + DEBUG(10,("update_printer: changing driver [%s]! Sending event!\n", + printer->info_2->drivername)); + + notify_printer_driver(snum, printer->info_2->drivername); } /* Update printer info */ @@ -6594,8 +6946,11 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ */ if (!devmode) + { set_driver_init(printer, 2); - else { + } + else + { /* A valid devmode was included, convert and link it */ DEBUGADD(10, ("spoolss_addprinterex_level_2: devmode included, converting\n")); @@ -6605,8 +6960,6 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ return WERR_NOMEM; } - set_driver_init(printer, 2); - /* write the ASCII on disk */ err = mod_a_printer(*printer, 2); if (!W_ERROR_IS_OK(err)) { @@ -6905,7 +7258,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S uint32 idx = q_u->index; uint32 in_value_len = q_u->valuesize; uint32 in_data_len = q_u->datasize; - uint32 *out_max_value_len= &r_u->valuesize; + uint32 *out_max_value_len = &r_u->valuesize; uint16 **out_value = &r_u->value; uint32 *out_value_len = &r_u->realvaluesize; uint32 *out_type = &r_u->type; @@ -7112,7 +7465,8 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP * when connecting to a printer --jerry */ - if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) + { DEBUG(3, ("_spoolss_setprinterdata: change denied by handle access permissions\n")); status = WERR_ACCESS_DENIED; goto done; @@ -7122,15 +7476,27 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP if (!W_ERROR_IS_OK(status)) return status; - /* save the registry data */ - unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); - delete_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, valuename ); - add_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, valuename, type, data, real_len ); - - /* write the **entire** printer out to disk.... :-( */ - 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 ( (type == REG_BINARY) && strequal( valuename, PHANTOM_DEVMODE_KEY)) + { + /* Set devmode and printer initialization info */ + status = save_driver_init( printer, 2, data, real_len ); + + srv_spoolss_reset_printerdata( printer->info_2->drivername ); + } + else + { + status = set_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, valuename, + type, data, real_len ); + if ( W_ERROR_IS_OK(status) ) + status = mod_a_printer(*printer, 2); + } done: free_a_printer(&printer, 2); @@ -7204,9 +7570,7 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); - status = delete_printer_data( printer->info_2, SPOOL_PRINTERDATA_KEY, valuename ); - if ( NT_STATUS_IS_OK(status) ) - status = mod_a_printer(*printer, 2); + status = delete_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, valuename ); free_a_printer(&printer, 2); @@ -7235,40 +7599,52 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM DEBUG(2,("_spoolss_addform: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } + + + /* forms can be added on printer of on the print server handle */ + + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + { + if (!get_printer_snum(p,handle, &snum)) + return WERR_BADFID; + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + goto done; + } - if (!get_printer_snum(p,handle, &snum)) - return WERR_BADFID; - - if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + if ( !(Printer->access_granted & (PRINTER_ACCESS_ADMINISTER|SERVER_ACCESS_ADMINISTER)) ) { DEBUG(2,("_spoolss_addform: denied by handle permissions.\n")); status = WERR_ACCESS_DENIED; goto done; } - + /* can't add if builtin */ + if (get_a_builtin_ntform(&form->name,&tmpForm)) { - return WERR_ALREADY_EXISTS; + status = WERR_ALREADY_EXISTS; + goto done; } - count=get_ntforms(&list); - if(!add_a_form(&list, form, &count)) - return WERR_NOMEM; + count = get_ntforms(&list); + + if(!add_a_form(&list, form, &count)) { + status = WERR_NOMEM; + goto done; + } + write_ntforms(&list, count); /* - * ChangeID must always be set + * ChangeID must always be set if this is a printer */ - status = get_a_printer(&printer, 2, lp_servicename(snum)); - if (!W_ERROR_IS_OK(status)) - goto done; - - status = mod_a_printer(*printer, 2); - if (!W_ERROR_IS_OK(status)) - goto done; + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + status = mod_a_printer(*printer, 2); done: - free_a_printer(&printer, 2); + if ( printer ) + free_a_printer(&printer, 2); SAFE_FREE(list); return status; @@ -7283,7 +7659,6 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE UNISTR2 *form_name = &q_u->name; nt_forms_struct tmpForm; int count=0; - WERROR ret = WERR_OK; nt_forms_struct *list=NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); int snum; @@ -7297,40 +7672,49 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) - return WERR_BADFID; + /* forms can be deleted on printer of on the print server handle */ + + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + { + if (!get_printer_snum(p,handle, &snum)) + return WERR_BADFID; + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + goto done; + } - if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { - DEBUG(2,("_spoolss_deleteform: denied by handle permissions\n")); - return WERR_ACCESS_DENIED; + if ( !(Printer->access_granted & (PRINTER_ACCESS_ADMINISTER|SERVER_ACCESS_ADMINISTER)) ) { + DEBUG(2,("_spoolss_deleteform: denied by handle permissions.\n")); + status = WERR_ACCESS_DENIED; + goto done; } /* can't delete if builtin */ + if (get_a_builtin_ntform(form_name,&tmpForm)) { - return WERR_INVALID_PARAM; + status = WERR_INVALID_PARAM; + goto done; } count = get_ntforms(&list); - if(!delete_a_form(&list, form_name, &count, &ret)) - return WERR_INVALID_PARAM; + + if ( !delete_a_form(&list, form_name, &count, &status )) + goto done; /* - * ChangeID must always be set + * ChangeID must always be set if this is a printer */ - status = get_a_printer(&printer, 2, lp_servicename(snum)); - if (!W_ERROR_IS_OK(status)) - goto done; - - status = mod_a_printer(*printer, 2); - if (!W_ERROR_IS_OK(status)) - goto done; + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + status = mod_a_printer(*printer, 2); done: - free_a_printer(&printer, 2); + if ( printer ) + free_a_printer(&printer, 2); SAFE_FREE(list); - return ret; + return status; } /**************************************************************************** @@ -7356,40 +7740,48 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) - return WERR_BADFID; + /* forms can be modified on printer of on the print server handle */ + + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + { + if (!get_printer_snum(p,handle, &snum)) + return WERR_BADFID; + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + goto done; + } - if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + if ( !(Printer->access_granted & (PRINTER_ACCESS_ADMINISTER|SERVER_ACCESS_ADMINISTER)) ) { DEBUG(2,("_spoolss_setform: denied by handle permissions\n")); - return WERR_ACCESS_DENIED; + status = WERR_ACCESS_DENIED; + goto done; } /* can't set if builtin */ if (get_a_builtin_ntform(&form->name,&tmpForm)) { - return WERR_INVALID_PARAM; + status = WERR_INVALID_PARAM; + goto done; } - count=get_ntforms(&list); + count = get_ntforms(&list); update_a_form(&list, form, count); write_ntforms(&list, count); /* - * ChangeID must always be set + * ChangeID must always be set if this is a printer */ - status = get_a_printer(&printer, 2, lp_servicename(snum)); - if (!W_ERROR_IS_OK(status)) - goto done; + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + status = mod_a_printer(*printer, 2); - status = mod_a_printer(*printer, 2); - if (!W_ERROR_IS_OK(status)) - goto done; done: - free_a_printer(&printer, 2); + if ( printer ) + free_a_printer(&printer, 2); SAFE_FREE(list); - return WERR_OK; + return status; } /**************************************************************************** @@ -7638,7 +8030,7 @@ static WERROR getjob_level_1(print_queue_struct *queue, int count, int snum, uin return WERR_NOMEM; } - for (i=0; ioffered; uint32 *needed = &r_u->needed; + WERROR wstatus = WERR_OK; int snum; int count; - print_queue_struct *queue=NULL; + print_queue_struct *queue = NULL; print_status_struct prt_status; /* that's an [in out] buffer */ @@ -7764,7 +8172,7 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ DEBUG(5,("spoolss_getjob\n")); - *needed=0; + *needed = 0; if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; @@ -7774,19 +8182,29 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ DEBUGADD(4,("count:[%d], prt_status:[%d], [%s]\n", count, prt_status.status, prt_status.message)); - switch (level) { + switch ( level ) { case 1: - return getjob_level_1(queue, count, snum, jobid, buffer, offered, needed); + wstatus = getjob_level_1(queue, count, snum, jobid, + buffer, offered, needed); + break; case 2: - return getjob_level_2(queue, count, snum, jobid, buffer, offered, needed); + wstatus = getjob_level_2(queue, count, snum, jobid, + buffer, offered, needed); + break; default: - SAFE_FREE(queue); - return WERR_UNKNOWN_LEVEL; + wstatus = WERR_UNKNOWN_LEVEL; + break; } + + SAFE_FREE(queue); + return wstatus; } /******************************************************************** - * spoolss_getprinterdataex + spoolss_getprinterdataex + + From MSDN documentation of GetPrinterDataEx: pass request + to GetPrinterData if key is "PrinterDriverData". ********************************************************************/ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, SPOOL_R_GETPRINTERDATAEX *r_u) @@ -7797,112 +8215,181 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, uint32 *out_size = &r_u->size; uint8 **data = &r_u->data; uint32 *needed = &r_u->needed; - - fstring key, value; + fstring keyname, valuename; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - BOOL found = False; + + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum = 0; + WERROR status = WERR_OK; DEBUG(4,("_spoolss_getprinterdataex\n")); - unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); - unistr2_to_ascii(value, &q_u->valuename, sizeof(value) - 1); + unistr2_to_ascii(keyname, &q_u->keyname, sizeof(keyname) - 1); + unistr2_to_ascii(valuename, &q_u->valuename, sizeof(valuename) - 1); + + DEBUG(10, ("_spoolss_getprinterdataex: key => [%s], value => [%s]\n", + keyname, valuename)); /* in case of problem, return some default values */ - *needed=0; - *type=0; - *out_size=0; + + *needed = 0; + *type = 0; + *out_size = in_size; - if (!Printer) { - if((*data=(uint8 *)talloc_zero(p->mem_ctx, 4*sizeof(uint8))) == NULL) - return WERR_NOMEM; - DEBUG(2,("_spoolss_getprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); - return WERR_BADFID; + DEBUG(2,("_spoolss_getprinterdataex: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); + status = WERR_BADFID; + goto done; } - /* Is the handle to a printer or to the server? */ - if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) - { + if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) { DEBUG(10,("_spoolss_getprinterdatex: Not implemented for server handles yet\n")); - return WERR_INVALID_PARAM; + status = WERR_INVALID_PARAM; + goto done; } - else - { - /* - * From MSDN documentation of GetPrinterDataEx: pass request - * to GetPrinterData if key is "PrinterDriverData". This is - * the only key we really support. Other keys to implement: - * (a) DsDriver - * (b) DsSpooler - * (c) PnPData - * (d) DsUser - */ - - if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) - return WERR_BADFILE; + + if ( !get_printer_snum(p,handle, &snum) ) + return WERR_BADFID; - DEBUG(10, ("_spoolss_getprinterdataex: pass me to getprinterdata\n")); - found = getprinterdata_printer(p, p->mem_ctx, handle, value, - type, data, needed, in_size); - + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if ( !W_ERROR_IS_OK(status) ) + goto done; + + /* check to see if the keyname is valid */ + if ( !strlen(keyname) ) { + status = WERR_INVALID_PARAM; + goto done; } - - if (!found) { - DEBUG(5, ("value not found, allocating %d\n", *out_size)); + + if ( lookup_printerkey( &printer->info_2->data, keyname ) == -1 ) { + DEBUG(4,("_spoolss_getprinterdataex: Invalid keyname [%s]\n", keyname )); + free_a_printer( &printer, 2 ); + status = WERR_BADFILE; + goto done; + } + + /* When given a new keyname, we should just create it */ + + status = get_printer_dataex( p->mem_ctx, printer, keyname, valuename, type, data, needed, in_size ); + + if (*needed > *out_size) + status = WERR_MORE_DATA; + +done: + if ( !W_ERROR_IS_OK(status) ) + { + DEBUG(5, ("error: allocating %d\n", *out_size)); /* reply this param doesn't exist */ - if (*out_size) { - if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) - return WERR_NOMEM; - } else { + + if ( *out_size ) + { + if( (*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL ) { + status = WERR_NOMEM; + goto done; + } + } + else { *data = NULL; - } - - return WERR_INVALID_PARAM; + } } - if (*needed > *out_size) - return WERR_MORE_DATA; - else - return WERR_OK; + if ( printer ) + free_a_printer( &printer, 2 ); + + return status; } /******************************************************************** - * spoolss_setprinterdata + * spoolss_setprinterdataex ********************************************************************/ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, SPOOL_R_SETPRINTERDATAEX *r_u) { - SPOOL_Q_SETPRINTERDATA q_u_local; - SPOOL_R_SETPRINTERDATA r_u_local; - fstring key; + POLICY_HND *handle = &q_u->handle; + uint32 type = q_u->type; + uint8 *data = q_u->data; + uint32 real_len = q_u->real_len; + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum = 0; + WERROR status = WERR_OK; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + fstring valuename; + fstring keyname; + char *oid_string; + DEBUG(4,("_spoolss_setprinterdataex\n")); /* From MSDN documentation of SetPrinterDataEx: pass request to SetPrinterData if key is "PrinterDriverData" */ - unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); + if (!Printer) { + DEBUG(2,("_spoolss_setprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); + return WERR_BADFID; + } - if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) - return WERR_INVALID_PARAM; - - ZERO_STRUCT(q_u_local); - ZERO_STRUCT(r_u_local); - - /* make a copy to call _spoolss_setprinterdata() */ - - memcpy(&q_u_local.handle, &q_u->handle, sizeof(POLICY_HND)); - copy_unistr2(&q_u_local.value, &q_u->value); - q_u_local.type = q_u->type; - q_u_local.max_len = q_u->max_len; - q_u_local.data = q_u->data; - q_u_local.real_len = q_u->real_len; - q_u_local.numeric_data = q_u->numeric_data; + if ( !get_printer_snum(p,handle, &snum) ) + return WERR_BADFID; + + /* + * 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 (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) + { + DEBUG(3, ("_spoolss_setprinterdataex: change denied by handle access permissions\n")); + return WERR_ACCESS_DENIED; + } + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + return status; + + unistr2_to_ascii( valuename, &q_u->value, sizeof(valuename) - 1); + unistr2_to_ascii( keyname, &q_u->key, sizeof(keyname) - 1); + + /* check for OID in valuename */ + + if ( (oid_string = strchr( valuename, ',' )) != NULL ) + { + *oid_string = '\0'; + oid_string++; + } + + /* save the registry data */ + + status = set_printer_dataex( printer, keyname, valuename, type, data, real_len ); + + /* save the OID if one was specified and the previous set call succeeded */ + + if ( W_ERROR_IS_OK(status) && oid_string ) + { + + fstrcat( keyname, "\\" ); + fstrcat( keyname, SPOOL_OID_KEY ); - return _spoolss_setprinterdata(p, &q_u_local, &r_u_local); + /* + * I'm not checking the status here on purpose. Don't know + * if this is right, but I'm returning the status from the + * previous set_printer_dataex() call. I have no idea if + * this is right. --jerry + */ + + set_printer_dataex( printer, keyname, valuename, + REG_SZ, (void*)oid_string, strlen(oid_string)+1 ); + } + + free_a_printer(&printer, 2); + + return status; } @@ -7912,26 +8399,44 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX *q_u, SPOOL_R_DELETEPRINTERDATAEX *r_u) { - SPOOL_Q_DELETEPRINTERDATA q_u_local; - SPOOL_R_DELETEPRINTERDATA r_u_local; - fstring key; - - /* From MSDN documentation of SetPrinterDataEx: pass request to - SetPrinterData if key is "PrinterDriverData" */ - - unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); + POLICY_HND *handle = &q_u->handle; + UNISTR2 *value = &q_u->valuename; + UNISTR2 *key = &q_u->keyname; - if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) - return WERR_INVALID_PARAM; + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum=0; + WERROR status = WERR_OK; + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); + pstring valuename, keyname; - memcpy(&q_u_local.handle, &q_u->handle, sizeof(POLICY_HND)); - copy_unistr2(&q_u_local.valuename, &q_u->valuename); + DEBUG(5,("spoolss_deleteprinterdataex\n")); - return _spoolss_deleteprinterdata( p, &q_u_local, &r_u_local ); -} + if (!Printer) { + DEBUG(2,("_spoolss_deleteprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); + return WERR_BADFID; + } + + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + DEBUG(3, ("_spoolss_deleteprinterdataex: printer properties change denied by handle\n")); + return WERR_ACCESS_DENIED; + } + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + return status; + + unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); + unistr2_to_ascii( keyname, key, sizeof(keyname)-1 ); + status = delete_printer_dataex( printer, keyname, valuename ); + free_a_printer(&printer, 2); + return status; +} /******************************************************************** * spoolss_enumprinterkey @@ -7940,73 +8445,69 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPOOL_R_ENUMPRINTERKEY *r_u) { - fstring key; - uint16 *enumkeys = NULL; - char* ptr = NULL; - int i; - int printerkey_len = strlen(SPOOL_PRINTERDATA_KEY)+1; - + fstring key; + fstring *keynames = NULL; + uint16 *enumkeys = NULL; + int num_keys; + int printerkey_len; + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + NT_PRINTER_DATA *data; + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum = 0; + WERROR status = WERR_BADFILE; + + DEBUG(4,("_spoolss_enumprinterkey\n")); - unistr2_to_ascii( key, &q_u->key, sizeof(key)-1 ); + if (!Printer) { + DEBUG(2,("_spoolss_enumprinterkey: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); + return WERR_BADFID; + } - /* - * we only support enumating all keys (key == "") - * Of course, the only key we support is the "PrinterDriverData" - * key - */ + if ( !get_printer_snum(p,handle, &snum) ) + return WERR_BADFID; - if ( !strlen( key ) ) - { - r_u->needed = printerkey_len*2; + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + return status; - if ( q_u->size < r_u->needed ) - return WERR_MORE_DATA; + /* get the list of subkey names */ - if ( !(enumkeys = talloc( p->mem_ctx, printerkey_len*2 )) ) { - DEBUG(0,("_spoolss_enumprinterkey: talloc() failed for [%d] bytes!\n", - printerkey_len)); - return WERR_NOMEM; - } - - ptr = SPOOL_PRINTERDATA_KEY; - for ( i=0; i<(printerkey_len-1); i++ ) - { - enumkeys[i] = (uint16)(*ptr); - ptr++; - } + unistr2_to_ascii( key, &q_u->key, sizeof(key)-1 ); + data = &printer->info_2->data; - /* tag of '\0's */ - - enumkeys[i] = 0x0; - - if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, printerkey_len, enumkeys)) - return WERR_BADFILE; - - return WERR_OK; + num_keys = get_printer_subkeys( data, key, &keynames ); + + if ( num_keys == -1 ) { + status = WERR_BADFILE; + goto done; } - - /* The "PrinterDriverData" key should have no subkeys */ - if ( strcmp(key, SPOOL_PRINTERDATA_KEY) == 0 ) - { - uint16 dummy_key = 0; - - r_u->needed = 2; - - if (q_u->size < r_u->needed) - return WERR_MORE_DATA; - - if ( !make_spoolss_buffer5(p->mem_ctx, &r_u->keys, 1, &dummy_key ) ) - return WERR_BADFILE; - - return WERR_OK; + + printerkey_len = init_unistr_array( &enumkeys, keynames, NULL ); + + r_u->needed = printerkey_len*2; + + if ( q_u->size < r_u->needed ) { + status = WERR_MORE_DATA; + goto done; } - - /* The return value for an unknown key is documented in MSDN - EnumPrinterKey description */ - - return WERR_BADFILE; + if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, printerkey_len, enumkeys)) { + status = WERR_NOMEM; + goto done; + } + + status = WERR_OK; + + if ( q_u->size < r_u->needed ) + status = WERR_MORE_DATA; + +done: + free_a_printer( &printer, 2 ); + SAFE_FREE( keynames ); + + return status; } /******************************************************************** @@ -8015,25 +8516,49 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, SPOOL_R_DELETEPRINTERKEY *r_u) { - Printer_entry *Printer = find_printer_index_by_hnd(p, &q_u->handle); - fstring key; + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer = find_printer_index_by_hnd(p, &q_u->handle); + fstring key; + NT_PRINTER_INFO_LEVEL *printer = NULL; + int snum=0; + WERROR status; + + DEBUG(5,("spoolss_deleteprinterkey\n")); if (!Printer) { - DEBUG(2,("_spoolss_deleteprinterkey: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(&q_u->handle))); + DEBUG(2,("_spoolss_deleteprinterkey: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } + + /* if keyname == NULL, return error */ + + if ( !q_u->keyname.buffer ) + return WERR_INVALID_PARAM; + + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + DEBUG(3, ("_spoolss_deleteprinterkey: printer properties change denied by handle\n")); + return WERR_ACCESS_DENIED; + } + + status = get_a_printer(&printer, 2, lp_servicename(snum)); + if (!W_ERROR_IS_OK(status)) + return status; + + /* delete the key and all subneys */ unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); + + status = delete_all_printer_data( printer->info_2, key ); - if (strcmp(key, SPOOL_PRINTERDATA_KEY) != 0) - return WERR_INVALID_PARAM; - - /* - * this is what 2k returns when you try to delete the "PrinterDriverData" - * key - */ - - return WERR_ACCESS_DENIED; + if ( W_ERROR_IS_OK(status) ) + status = mod_a_printer(*printer, 2); + + free_a_printer( &printer, 2 ); + + return status; } @@ -8068,7 +8593,6 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ return WERR_BADFID; } - /* first get the printer off of disk */ if (!get_printer_snum(p,handle, &snum)) diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 5c1038949b..69945b50b8 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -338,10 +338,10 @@ BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, u if (!psd) goto out; - if (vuser) - token = vuser->nt_user_token; - else + if (conn->nt_user_token) token = conn->nt_user_token; + else + token = vuser->nt_user_token; ret = se_access_check(psd, token, desired_access, &granted, &status); -- cgit From ad514000db54b887c5c0f8734415e2b10698b365 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 26 Sep 2002 10:25:34 +0000 Subject: Patch from "Stefan (metze) Metzmacher" to do a *much* better job of working with usrmgr. Previously we were blanking out entires, and all sort of mischif. The new patch (which I've now had a chance to test/modify) also takes care not to expand % values (ie we go \\%L\%U -> \\server\user, we don't want to store \\server\user back) and to correctly notice 'not set' compared to 'null string' etc. Andrew Bartlett (This used to be commit ab878b6cc4132594fc33f78aeebf0d8b7266c150) --- source3/rpc_server/srv_samr_nt.c | 4 +- source3/rpc_server/srv_samr_util.c | 420 ++++++++++++++++++++++++++++++------- 2 files changed, 346 insertions(+), 78 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ea631838da..6e9ba2f026 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2802,8 +2802,6 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) acct_ctrl = pdb_get_acct_ctrl(pwd); - copy_id23_to_sam_passwd(pwd, id23); - if (!decode_pw_buffer((char*)id23->pass, plaintext_buf, 256, &len)) { pdb_free_sam(&pwd); return False; @@ -2814,6 +2812,8 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) return False; } + copy_id23_to_sam_passwd(pwd, id23); + /* if it's a trust account, don't update /etc/passwd */ if ( (!IS_SAM_UNIX_USER(pwd)) || ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 7a5b1e5f46..18297056d6 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -1,10 +1,11 @@ /* Unix SMB/CIFS implementation. SAMR Pipe utility functions. - Copyright (C) Jeremy Allison 1996-2001 + Copyright (C) Luke Kenneth Casson Leighton 1996-1998 Copyright (C) Gerald (Jerry) Carter 2000-2001 Copyright (C) Andrew Bartlett 2001-2002 + Copyright (C) Stefan (metze) Metzmacher 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,118 +27,385 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +#define STRING_CHANGED (old_string && !new_string) ||\ + (!old_string && new_string) ||\ + (old_string && new_string && (strcmp(old_string, new_string) != 0)) + /************************************************************* - Copies a SAM_USER_INFO_23 to a SAM_ACCOUNT - **************************************************************/ + Copies a SAM_USER_INFO_21 to a SAM_ACCOUNT +**************************************************************/ -void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) +void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) { + time_t unix_time, stored_time; + const char *old_string, *new_string; if (from == NULL || to == NULL) return; + if (!nt_time_is_zero(&from->logon_time)) { + unix_time=nt_time_to_unix(&from->logon_time); + stored_time = pdb_get_logon_time(to); + DEBUG(10,("INFO_21 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_logon_time(to, unix_time, True); + } + if (!nt_time_is_zero(&from->logoff_time)) { + unix_time=nt_time_to_unix(&from->logoff_time); + stored_time = pdb_get_logoff_time(to); + DEBUG(10,("INFO_21 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_logoff_time(to, unix_time, True); + } + + if (!nt_time_is_zero(&from->kickoff_time)) { + unix_time=nt_time_to_unix(&from->kickoff_time); + stored_time = pdb_get_kickoff_time(to); + DEBUG(10,("INFO_21 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_kickoff_time(to, unix_time , True); + } - pdb_set_logon_time(to,nt_time_to_unix(&from->logon_time), True); - pdb_set_logoff_time(to,nt_time_to_unix(&from->logoff_time), True); - pdb_set_kickoff_time(to, nt_time_to_unix(&from->kickoff_time), True); - pdb_set_pass_can_change_time(to, nt_time_to_unix(&from->pass_can_change_time), True); - pdb_set_pass_must_change_time(to, nt_time_to_unix(&from->pass_must_change_time), True); - - pdb_set_pass_last_set_time(to, nt_time_to_unix(&from->pass_last_set_time)); - - if (from->uni_user_name.buffer) - pdb_set_username(to , pdb_unistr2_convert(&from->uni_user_name )); - if (from->uni_full_name.buffer) - pdb_set_fullname(to , pdb_unistr2_convert(&from->uni_full_name )); - if (from->uni_home_dir.buffer) - pdb_set_homedir(to , pdb_unistr2_convert(&from->uni_home_dir ), True); - if (from->uni_dir_drive.buffer) - pdb_set_dir_drive(to , pdb_unistr2_convert(&from->uni_dir_drive ), True); - if (from->uni_logon_script.buffer) - pdb_set_logon_script(to , pdb_unistr2_convert(&from->uni_logon_script), True); - if (from->uni_profile_path.buffer) - pdb_set_profile_path(to , pdb_unistr2_convert(&from->uni_profile_path), True); - if (from->uni_acct_desc.buffer) - pdb_set_acct_desc(to , pdb_unistr2_convert(&from->uni_acct_desc )); - if (from->uni_workstations.buffer) - pdb_set_workstations(to , pdb_unistr2_convert(&from->uni_workstations)); - if (from->uni_unknown_str.buffer) - pdb_set_unknown_str(to , pdb_unistr2_convert(&from->uni_unknown_str )); - if (from->uni_munged_dial.buffer) - pdb_set_munged_dial(to , pdb_unistr2_convert(&from->uni_munged_dial )); - - if (from->user_rid) - pdb_set_user_sid_from_rid(to, from->user_rid); - if (from->group_rid) - pdb_set_group_sid_from_rid(to, from->group_rid); + if (!nt_time_is_zero(&from->pass_can_change_time)) { + unix_time=nt_time_to_unix(&from->pass_can_change_time); + stored_time = pdb_get_pass_can_change_time(to); + DEBUG(10,("INFO_21 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_can_change_time(to, unix_time, True); + } + if (!nt_time_is_zero(&from->pass_last_set_time)) { + unix_time=nt_time_to_unix(&from->pass_last_set_time); + stored_time = pdb_get_pass_last_set_time(to); + DEBUG(10,("INFO_21 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_last_set_time(to, unix_time); + } + + if (!nt_time_is_zero(&from->pass_must_change_time)) { + unix_time=nt_time_to_unix(&from->pass_must_change_time); + stored_time=pdb_get_pass_must_change_time(to); + DEBUG(10,("INFO_21 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_must_change_time(to, unix_time, True); + } + + /* Backend should check this for sainity */ + if (from->hdr_user_name.buffer) { + old_string = pdb_get_username(to); + new_string = pdb_unistr2_convert(&from->uni_user_name); + DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); + if (STRING_CHANGED) + pdb_set_username(to , new_string); + } + + if (from->hdr_full_name.buffer) { + old_string = pdb_get_fullname(to); + new_string = pdb_unistr2_convert(&from->uni_user_name); + DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_fullname(to , new_string); + } + + if (from->hdr_home_dir.buffer) { + old_string = pdb_get_homedir(to); + new_string = pdb_unistr2_convert(&from->uni_home_dir); + DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_homedir(to , new_string, True); + } + + if (from->hdr_dir_drive.buffer) { + old_string = pdb_get_dir_drive(to); + new_string = pdb_unistr2_convert(&from->uni_dir_drive); + DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_dir_drive(to , new_string, True); + } + if (from->hdr_logon_script.buffer) { + old_string = pdb_get_logon_script(to); + new_string = pdb_unistr2_convert(&from->uni_logon_script); + DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_logon_script(to , new_string, True); + } + + if (from->hdr_profile_path.buffer) { + old_string = pdb_get_profile_path(to); + new_string = pdb_unistr2_convert(&from->uni_profile_path); + DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_profile_path(to , new_string, True); + } + + if (from->hdr_acct_desc.buffer) { + old_string = pdb_get_acct_desc(to); + new_string = pdb_unistr2_convert(&from->uni_acct_desc); + DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_acct_desc(to , new_string); + } + + if (from->hdr_workstations.buffer) { + old_string = pdb_get_workstations(to); + new_string = pdb_unistr2_convert(&from->uni_workstations); + DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_workstations(to , new_string); + } + + if (from->hdr_unknown_str.buffer) { + old_string = pdb_get_unknown_str(to); + new_string = pdb_unistr2_convert(&from->uni_unknown_str); + DEBUG(10,("INFO_21 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_unknown_str(to , new_string); + } + + if (from->hdr_munged_dial.buffer) { + old_string = pdb_get_munged_dial(to); + new_string = pdb_unistr2_convert(&from->uni_munged_dial); + DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_munged_dial(to , new_string); + } + + if (from->user_rid) { + DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); + /* we really allow this ??? metze */ + /* pdb_set_user_sid_from_rid(to, from->user_rid);*/ + } + + if (from->group_rid) { + DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); + pdb_set_group_sid_from_rid(to, from->group_rid); + } + + DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); pdb_set_acct_ctrl(to, from->acb_info); + + DEBUG(10,("INFO_21 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown3(to),from->unknown_3)); pdb_set_unknown_3(to, from->unknown_3); + + DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); pdb_set_logon_divs(to, from->logon_divs); + + DEBUG(15,("INFO_21 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); pdb_set_hours_len(to, from->logon_hrs.len); + DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); pdb_set_hours(to, from->logon_hrs.hours); + DEBUG(10,("INFO_21 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown5(to),from->unknown_5)); pdb_set_unknown_5(to, from->unknown_5); + + DEBUG(10,("INFO_21 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown6(to),from->unknown_6)); pdb_set_unknown_6(to, from->unknown_6); + + DEBUG(10,("INFO_21 PADDING1 %02X %02X %02X %02X %02X %02X\n", + from->padding1[0], + from->padding1[1], + from->padding1[2], + from->padding1[3], + from->padding1[4], + from->padding1[5])); + + DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); + if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) { + pdb_set_pass_must_change_time(to,0, True); + } + + DEBUG(10,("INFO_21 PADDING_2: %02X\n",from->padding2)); + + DEBUG(10,("INFO_21 PADDING_4: %08X\n",from->padding4)); } /************************************************************* - Copies a sam passwd. - **************************************************************/ + Copies a SAM_USER_INFO_23 to a SAM_ACCOUNT +**************************************************************/ -void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) +void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) { + time_t unix_time, stored_time; + const char *old_string, *new_string; + if (from == NULL || to == NULL) return; + if (!nt_time_is_zero(&from->logon_time)) { + unix_time=nt_time_to_unix(&from->logon_time); + stored_time = pdb_get_logon_time(to); + DEBUG(10,("INFO_23 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_logon_time(to, unix_time, True); + } + if (!nt_time_is_zero(&from->logoff_time)) { + unix_time=nt_time_to_unix(&from->logoff_time); + stored_time = pdb_get_logoff_time(to); + DEBUG(10,("INFO_23 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_logoff_time(to, unix_time, True); + } + + if (!nt_time_is_zero(&from->kickoff_time)) { + unix_time=nt_time_to_unix(&from->kickoff_time); + stored_time = pdb_get_kickoff_time(to); + DEBUG(10,("INFO_23 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_kickoff_time(to, unix_time , True); + } - pdb_set_logon_time(to,nt_time_to_unix(&from->logon_time), True); - pdb_set_logoff_time(to,nt_time_to_unix(&from->logoff_time), True); - pdb_set_kickoff_time(to, nt_time_to_unix(&from->kickoff_time), True); - pdb_set_pass_can_change_time(to, nt_time_to_unix(&from->pass_can_change_time), True); - pdb_set_pass_must_change_time(to, nt_time_to_unix(&from->pass_must_change_time), True); - - pdb_set_pass_last_set_time(to, nt_time_to_unix(&from->pass_last_set_time)); - - if (from->uni_user_name.buffer) - pdb_set_username(to , pdb_unistr2_convert(&from->uni_user_name )); - if (from->uni_full_name.buffer) - pdb_set_fullname(to , pdb_unistr2_convert(&from->uni_full_name )); - if (from->uni_home_dir.buffer) - pdb_set_homedir(to , pdb_unistr2_convert(&from->uni_home_dir ), True); - if (from->uni_dir_drive.buffer) - pdb_set_dir_drive(to , pdb_unistr2_convert(&from->uni_dir_drive ), True); - if (from->uni_logon_script.buffer) - pdb_set_logon_script(to , pdb_unistr2_convert(&from->uni_logon_script), True); - if (from->uni_profile_path.buffer) - pdb_set_profile_path(to , pdb_unistr2_convert(&from->uni_profile_path), True); - if (from->uni_acct_desc.buffer) - pdb_set_acct_desc(to , pdb_unistr2_convert(&from->uni_acct_desc )); - if (from->uni_workstations.buffer) - pdb_set_workstations(to , pdb_unistr2_convert(&from->uni_workstations)); - if (from->uni_unknown_str.buffer) - pdb_set_unknown_str(to , pdb_unistr2_convert(&from->uni_unknown_str )); - if (from->uni_munged_dial.buffer) - pdb_set_munged_dial(to , pdb_unistr2_convert(&from->uni_munged_dial )); - - if (from->user_rid) - pdb_set_user_sid_from_rid(to, from->user_rid); - if (from->group_rid) - pdb_set_group_sid_from_rid(to, from->group_rid); + if (!nt_time_is_zero(&from->pass_can_change_time)) { + unix_time=nt_time_to_unix(&from->pass_can_change_time); + stored_time = pdb_get_pass_can_change_time(to); + DEBUG(10,("INFO_23 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_can_change_time(to, unix_time, True); + } + if (!nt_time_is_zero(&from->pass_last_set_time)) { + unix_time=nt_time_to_unix(&from->pass_last_set_time); + stored_time = pdb_get_pass_last_set_time(to); + DEBUG(10,("INFO_23 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_last_set_time(to, unix_time); + } + + if (!nt_time_is_zero(&from->pass_must_change_time)) { + unix_time=nt_time_to_unix(&from->pass_must_change_time); + stored_time=pdb_get_pass_must_change_time(to); + DEBUG(10,("INFO_23 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_must_change_time(to, unix_time, True); + } + + /* Backend should check this for sainity */ + if (from->hdr_user_name.buffer) { + old_string = pdb_get_username(to); + new_string = pdb_unistr2_convert(&from->uni_user_name); + DEBUG(10,("INFO_23 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); + if (STRING_CHANGED) + pdb_set_username(to , new_string); + } + + if (from->hdr_full_name.buffer) { + old_string = pdb_get_fullname(to); + new_string = pdb_unistr2_convert(&from->uni_user_name); + DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_fullname(to , new_string); + } + + if (from->hdr_home_dir.buffer) { + old_string = pdb_get_homedir(to); + new_string = pdb_unistr2_convert(&from->uni_home_dir); + DEBUG(10,("INFO_23 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_homedir(to , new_string, True); + } + + if (from->hdr_dir_drive.buffer) { + old_string = pdb_get_dir_drive(to); + new_string = pdb_unistr2_convert(&from->uni_dir_drive); + DEBUG(10,("INFO_23 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_dir_drive(to , new_string, True); + } - /* FIXME!! Do we need to copy the passwords here as well? - I don't know. Need to figure this out --jerry */ + if (from->hdr_logon_script.buffer) { + old_string = pdb_get_logon_script(to); + new_string = pdb_unistr2_convert(&from->uni_logon_script); + DEBUG(10,("INFO_23 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_logon_script(to , new_string, True); + } - /* Passwords dealt with in caller --abartlet */ + if (from->hdr_profile_path.buffer) { + old_string = pdb_get_profile_path(to); + new_string = pdb_unistr2_convert(&from->uni_profile_path); + DEBUG(10,("INFO_23 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_profile_path(to , new_string, True); + } + + if (from->hdr_acct_desc.buffer) { + old_string = pdb_get_acct_desc(to); + new_string = pdb_unistr2_convert(&from->uni_acct_desc); + DEBUG(10,("INFO_23 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_acct_desc(to , new_string); + } + + if (from->hdr_workstations.buffer) { + old_string = pdb_get_workstations(to); + new_string = pdb_unistr2_convert(&from->uni_workstations); + DEBUG(10,("INFO_23 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_workstations(to , new_string); + } + if (from->hdr_unknown_str.buffer) { + old_string = pdb_get_unknown_str(to); + new_string = pdb_unistr2_convert(&from->uni_unknown_str); + DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_unknown_str(to , new_string); + } + + if (from->hdr_munged_dial.buffer) { + old_string = pdb_get_munged_dial(to); + new_string = pdb_unistr2_convert(&from->uni_munged_dial); + DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_munged_dial(to , new_string); + } + + if (from->user_rid) { + DEBUG(10,("INFO_23 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); + /* we really allow this ??? metze */ + /* pdb_set_user_sid_from_rid(to, from->user_rid);*/ + } + + if (from->group_rid) { + DEBUG(10,("INFO_23 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); + pdb_set_group_sid_from_rid(to, from->group_rid); + } + + DEBUG(10,("INFO_23 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); pdb_set_acct_ctrl(to, from->acb_info); + + DEBUG(10,("INFO_23 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown3(to),from->unknown_3)); pdb_set_unknown_3(to, from->unknown_3); + + DEBUG(15,("INFO_23 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); pdb_set_logon_divs(to, from->logon_divs); + + DEBUG(15,("INFO_23 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); pdb_set_hours_len(to, from->logon_hrs.len); + DEBUG(15,("INFO_23 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); pdb_set_hours(to, from->logon_hrs.hours); + DEBUG(10,("INFO_23 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown5(to),from->unknown_5)); pdb_set_unknown_5(to, from->unknown_5); + + DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown6(to),from->unknown_6)); pdb_set_unknown_6(to, from->unknown_6); + + DEBUG(10,("INFO_23 PADDING1 %02X %02X %02X %02X %02X %02X\n", + from->padding1[0], + from->padding1[1], + from->padding1[2], + from->padding1[3], + from->padding1[4], + from->padding1[5])); + + DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); + if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) { + pdb_set_pass_must_change_time(to,0, True); + } + + DEBUG(10,("INFO_23 PADDING_2: %02X\n",from->padding2)); + + DEBUG(10,("INFO_23 PADDING_4: %08X\n",from->padding4)); } + -- cgit From a5c8985215758d37bcd89f63b97f2ad86393f9c2 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 26 Sep 2002 13:31:49 +0000 Subject: Patch from "Kai Krueger" to get some more of our access control bits right on the SAMR pipe. Andrew Bartlett (This used to be commit e87948c777b59592b130da081ef5d25600455d29) --- source3/rpc_server/srv_samr_nt.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6e9ba2f026..c5a2c54511 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3059,6 +3059,10 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, uint32 *rids=NULL, *new_rids=NULL, *tmp_rids=NULL; struct samr_info *info = NULL; int i,j; + + NTSTATUS ntstatus1; + NTSTATUS ntstatus2; + /* until i see a real useraliases query, we fack one up */ /* I have seen one, JFM 2/12/2001 */ @@ -3084,9 +3088,15 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, USER_ACCESS_GET_GROUPS, "_samr_query_useraliases"))) { - return r_u->status; - } + ntstatus1 = access_check_samr_function(info->acc_granted, DOMAIN_ACCESS_LOOKUP_ALIAS_BY_MEM, "_samr_query_useraliases"); + ntstatus2 = access_check_samr_function(info->acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_query_useraliases"); + + if (!NT_STATUS_IS_OK(ntstatus1) || !NT_STATUS_IS_OK(ntstatus2)) { + if (!(NT_STATUS_EQUAL(ntstatus1,NT_STATUS_ACCESS_DENIED) && NT_STATUS_IS_OK(ntstatus2)) && + !(NT_STATUS_EQUAL(ntstatus1,NT_STATUS_ACCESS_DENIED) && NT_STATUS_IS_OK(ntstatus1))) { + return (NT_STATUS_IS_OK(ntstatus1)) ? ntstatus2 : ntstatus1; + } + } if (!sid_check_is_domain(&info->sid) && !sid_check_is_builtin(&info->sid)) @@ -3157,7 +3167,8 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_GET_MEMBERS, "_samr_query_aliasmem"))) { + if (!NT_STATUS_IS_OK(r_u->status = + access_check_samr_function(acc_granted, ALIAS_ACCESS_GET_MEMBERS, "_samr_query_aliasmem"))) { return r_u->status; } -- cgit From d9729d81a993234db850fa733fd4591e1a5ae56e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 26 Sep 2002 18:37:55 +0000 Subject: syncing up with HEAD again.... (This used to be commit e026b84815ad1a5fa981c24fff197fefa73b4928) --- source3/rpc_server/srv_samr_nt.c | 23 +- source3/rpc_server/srv_samr_util.c | 420 ++++++++++++++++++++++++++++++------- 2 files changed, 361 insertions(+), 82 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ea631838da..c5a2c54511 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2802,8 +2802,6 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) acct_ctrl = pdb_get_acct_ctrl(pwd); - copy_id23_to_sam_passwd(pwd, id23); - if (!decode_pw_buffer((char*)id23->pass, plaintext_buf, 256, &len)) { pdb_free_sam(&pwd); return False; @@ -2814,6 +2812,8 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) return False; } + copy_id23_to_sam_passwd(pwd, id23); + /* if it's a trust account, don't update /etc/passwd */ if ( (!IS_SAM_UNIX_USER(pwd)) || ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || @@ -3059,6 +3059,10 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, uint32 *rids=NULL, *new_rids=NULL, *tmp_rids=NULL; struct samr_info *info = NULL; int i,j; + + NTSTATUS ntstatus1; + NTSTATUS ntstatus2; + /* until i see a real useraliases query, we fack one up */ /* I have seen one, JFM 2/12/2001 */ @@ -3084,9 +3088,15 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, USER_ACCESS_GET_GROUPS, "_samr_query_useraliases"))) { - return r_u->status; - } + ntstatus1 = access_check_samr_function(info->acc_granted, DOMAIN_ACCESS_LOOKUP_ALIAS_BY_MEM, "_samr_query_useraliases"); + ntstatus2 = access_check_samr_function(info->acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_query_useraliases"); + + if (!NT_STATUS_IS_OK(ntstatus1) || !NT_STATUS_IS_OK(ntstatus2)) { + if (!(NT_STATUS_EQUAL(ntstatus1,NT_STATUS_ACCESS_DENIED) && NT_STATUS_IS_OK(ntstatus2)) && + !(NT_STATUS_EQUAL(ntstatus1,NT_STATUS_ACCESS_DENIED) && NT_STATUS_IS_OK(ntstatus1))) { + return (NT_STATUS_IS_OK(ntstatus1)) ? ntstatus2 : ntstatus1; + } + } if (!sid_check_is_domain(&info->sid) && !sid_check_is_builtin(&info->sid)) @@ -3157,7 +3167,8 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_GET_MEMBERS, "_samr_query_aliasmem"))) { + if (!NT_STATUS_IS_OK(r_u->status = + access_check_samr_function(acc_granted, ALIAS_ACCESS_GET_MEMBERS, "_samr_query_aliasmem"))) { return r_u->status; } diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 7a5b1e5f46..18297056d6 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -1,10 +1,11 @@ /* Unix SMB/CIFS implementation. SAMR Pipe utility functions. - Copyright (C) Jeremy Allison 1996-2001 + Copyright (C) Luke Kenneth Casson Leighton 1996-1998 Copyright (C) Gerald (Jerry) Carter 2000-2001 Copyright (C) Andrew Bartlett 2001-2002 + Copyright (C) Stefan (metze) Metzmacher 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,118 +27,385 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +#define STRING_CHANGED (old_string && !new_string) ||\ + (!old_string && new_string) ||\ + (old_string && new_string && (strcmp(old_string, new_string) != 0)) + /************************************************************* - Copies a SAM_USER_INFO_23 to a SAM_ACCOUNT - **************************************************************/ + Copies a SAM_USER_INFO_21 to a SAM_ACCOUNT +**************************************************************/ -void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) +void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) { + time_t unix_time, stored_time; + const char *old_string, *new_string; if (from == NULL || to == NULL) return; + if (!nt_time_is_zero(&from->logon_time)) { + unix_time=nt_time_to_unix(&from->logon_time); + stored_time = pdb_get_logon_time(to); + DEBUG(10,("INFO_21 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_logon_time(to, unix_time, True); + } + if (!nt_time_is_zero(&from->logoff_time)) { + unix_time=nt_time_to_unix(&from->logoff_time); + stored_time = pdb_get_logoff_time(to); + DEBUG(10,("INFO_21 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_logoff_time(to, unix_time, True); + } + + if (!nt_time_is_zero(&from->kickoff_time)) { + unix_time=nt_time_to_unix(&from->kickoff_time); + stored_time = pdb_get_kickoff_time(to); + DEBUG(10,("INFO_21 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_kickoff_time(to, unix_time , True); + } - pdb_set_logon_time(to,nt_time_to_unix(&from->logon_time), True); - pdb_set_logoff_time(to,nt_time_to_unix(&from->logoff_time), True); - pdb_set_kickoff_time(to, nt_time_to_unix(&from->kickoff_time), True); - pdb_set_pass_can_change_time(to, nt_time_to_unix(&from->pass_can_change_time), True); - pdb_set_pass_must_change_time(to, nt_time_to_unix(&from->pass_must_change_time), True); - - pdb_set_pass_last_set_time(to, nt_time_to_unix(&from->pass_last_set_time)); - - if (from->uni_user_name.buffer) - pdb_set_username(to , pdb_unistr2_convert(&from->uni_user_name )); - if (from->uni_full_name.buffer) - pdb_set_fullname(to , pdb_unistr2_convert(&from->uni_full_name )); - if (from->uni_home_dir.buffer) - pdb_set_homedir(to , pdb_unistr2_convert(&from->uni_home_dir ), True); - if (from->uni_dir_drive.buffer) - pdb_set_dir_drive(to , pdb_unistr2_convert(&from->uni_dir_drive ), True); - if (from->uni_logon_script.buffer) - pdb_set_logon_script(to , pdb_unistr2_convert(&from->uni_logon_script), True); - if (from->uni_profile_path.buffer) - pdb_set_profile_path(to , pdb_unistr2_convert(&from->uni_profile_path), True); - if (from->uni_acct_desc.buffer) - pdb_set_acct_desc(to , pdb_unistr2_convert(&from->uni_acct_desc )); - if (from->uni_workstations.buffer) - pdb_set_workstations(to , pdb_unistr2_convert(&from->uni_workstations)); - if (from->uni_unknown_str.buffer) - pdb_set_unknown_str(to , pdb_unistr2_convert(&from->uni_unknown_str )); - if (from->uni_munged_dial.buffer) - pdb_set_munged_dial(to , pdb_unistr2_convert(&from->uni_munged_dial )); - - if (from->user_rid) - pdb_set_user_sid_from_rid(to, from->user_rid); - if (from->group_rid) - pdb_set_group_sid_from_rid(to, from->group_rid); + if (!nt_time_is_zero(&from->pass_can_change_time)) { + unix_time=nt_time_to_unix(&from->pass_can_change_time); + stored_time = pdb_get_pass_can_change_time(to); + DEBUG(10,("INFO_21 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_can_change_time(to, unix_time, True); + } + if (!nt_time_is_zero(&from->pass_last_set_time)) { + unix_time=nt_time_to_unix(&from->pass_last_set_time); + stored_time = pdb_get_pass_last_set_time(to); + DEBUG(10,("INFO_21 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_last_set_time(to, unix_time); + } + + if (!nt_time_is_zero(&from->pass_must_change_time)) { + unix_time=nt_time_to_unix(&from->pass_must_change_time); + stored_time=pdb_get_pass_must_change_time(to); + DEBUG(10,("INFO_21 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_must_change_time(to, unix_time, True); + } + + /* Backend should check this for sainity */ + if (from->hdr_user_name.buffer) { + old_string = pdb_get_username(to); + new_string = pdb_unistr2_convert(&from->uni_user_name); + DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); + if (STRING_CHANGED) + pdb_set_username(to , new_string); + } + + if (from->hdr_full_name.buffer) { + old_string = pdb_get_fullname(to); + new_string = pdb_unistr2_convert(&from->uni_user_name); + DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_fullname(to , new_string); + } + + if (from->hdr_home_dir.buffer) { + old_string = pdb_get_homedir(to); + new_string = pdb_unistr2_convert(&from->uni_home_dir); + DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_homedir(to , new_string, True); + } + + if (from->hdr_dir_drive.buffer) { + old_string = pdb_get_dir_drive(to); + new_string = pdb_unistr2_convert(&from->uni_dir_drive); + DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_dir_drive(to , new_string, True); + } + if (from->hdr_logon_script.buffer) { + old_string = pdb_get_logon_script(to); + new_string = pdb_unistr2_convert(&from->uni_logon_script); + DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_logon_script(to , new_string, True); + } + + if (from->hdr_profile_path.buffer) { + old_string = pdb_get_profile_path(to); + new_string = pdb_unistr2_convert(&from->uni_profile_path); + DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_profile_path(to , new_string, True); + } + + if (from->hdr_acct_desc.buffer) { + old_string = pdb_get_acct_desc(to); + new_string = pdb_unistr2_convert(&from->uni_acct_desc); + DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_acct_desc(to , new_string); + } + + if (from->hdr_workstations.buffer) { + old_string = pdb_get_workstations(to); + new_string = pdb_unistr2_convert(&from->uni_workstations); + DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_workstations(to , new_string); + } + + if (from->hdr_unknown_str.buffer) { + old_string = pdb_get_unknown_str(to); + new_string = pdb_unistr2_convert(&from->uni_unknown_str); + DEBUG(10,("INFO_21 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_unknown_str(to , new_string); + } + + if (from->hdr_munged_dial.buffer) { + old_string = pdb_get_munged_dial(to); + new_string = pdb_unistr2_convert(&from->uni_munged_dial); + DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_munged_dial(to , new_string); + } + + if (from->user_rid) { + DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); + /* we really allow this ??? metze */ + /* pdb_set_user_sid_from_rid(to, from->user_rid);*/ + } + + if (from->group_rid) { + DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); + pdb_set_group_sid_from_rid(to, from->group_rid); + } + + DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); pdb_set_acct_ctrl(to, from->acb_info); + + DEBUG(10,("INFO_21 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown3(to),from->unknown_3)); pdb_set_unknown_3(to, from->unknown_3); + + DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); pdb_set_logon_divs(to, from->logon_divs); + + DEBUG(15,("INFO_21 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); pdb_set_hours_len(to, from->logon_hrs.len); + DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); pdb_set_hours(to, from->logon_hrs.hours); + DEBUG(10,("INFO_21 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown5(to),from->unknown_5)); pdb_set_unknown_5(to, from->unknown_5); + + DEBUG(10,("INFO_21 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown6(to),from->unknown_6)); pdb_set_unknown_6(to, from->unknown_6); + + DEBUG(10,("INFO_21 PADDING1 %02X %02X %02X %02X %02X %02X\n", + from->padding1[0], + from->padding1[1], + from->padding1[2], + from->padding1[3], + from->padding1[4], + from->padding1[5])); + + DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); + if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) { + pdb_set_pass_must_change_time(to,0, True); + } + + DEBUG(10,("INFO_21 PADDING_2: %02X\n",from->padding2)); + + DEBUG(10,("INFO_21 PADDING_4: %08X\n",from->padding4)); } /************************************************************* - Copies a sam passwd. - **************************************************************/ + Copies a SAM_USER_INFO_23 to a SAM_ACCOUNT +**************************************************************/ -void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) +void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) { + time_t unix_time, stored_time; + const char *old_string, *new_string; + if (from == NULL || to == NULL) return; + if (!nt_time_is_zero(&from->logon_time)) { + unix_time=nt_time_to_unix(&from->logon_time); + stored_time = pdb_get_logon_time(to); + DEBUG(10,("INFO_23 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_logon_time(to, unix_time, True); + } + if (!nt_time_is_zero(&from->logoff_time)) { + unix_time=nt_time_to_unix(&from->logoff_time); + stored_time = pdb_get_logoff_time(to); + DEBUG(10,("INFO_23 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_logoff_time(to, unix_time, True); + } + + if (!nt_time_is_zero(&from->kickoff_time)) { + unix_time=nt_time_to_unix(&from->kickoff_time); + stored_time = pdb_get_kickoff_time(to); + DEBUG(10,("INFO_23 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_kickoff_time(to, unix_time , True); + } - pdb_set_logon_time(to,nt_time_to_unix(&from->logon_time), True); - pdb_set_logoff_time(to,nt_time_to_unix(&from->logoff_time), True); - pdb_set_kickoff_time(to, nt_time_to_unix(&from->kickoff_time), True); - pdb_set_pass_can_change_time(to, nt_time_to_unix(&from->pass_can_change_time), True); - pdb_set_pass_must_change_time(to, nt_time_to_unix(&from->pass_must_change_time), True); - - pdb_set_pass_last_set_time(to, nt_time_to_unix(&from->pass_last_set_time)); - - if (from->uni_user_name.buffer) - pdb_set_username(to , pdb_unistr2_convert(&from->uni_user_name )); - if (from->uni_full_name.buffer) - pdb_set_fullname(to , pdb_unistr2_convert(&from->uni_full_name )); - if (from->uni_home_dir.buffer) - pdb_set_homedir(to , pdb_unistr2_convert(&from->uni_home_dir ), True); - if (from->uni_dir_drive.buffer) - pdb_set_dir_drive(to , pdb_unistr2_convert(&from->uni_dir_drive ), True); - if (from->uni_logon_script.buffer) - pdb_set_logon_script(to , pdb_unistr2_convert(&from->uni_logon_script), True); - if (from->uni_profile_path.buffer) - pdb_set_profile_path(to , pdb_unistr2_convert(&from->uni_profile_path), True); - if (from->uni_acct_desc.buffer) - pdb_set_acct_desc(to , pdb_unistr2_convert(&from->uni_acct_desc )); - if (from->uni_workstations.buffer) - pdb_set_workstations(to , pdb_unistr2_convert(&from->uni_workstations)); - if (from->uni_unknown_str.buffer) - pdb_set_unknown_str(to , pdb_unistr2_convert(&from->uni_unknown_str )); - if (from->uni_munged_dial.buffer) - pdb_set_munged_dial(to , pdb_unistr2_convert(&from->uni_munged_dial )); - - if (from->user_rid) - pdb_set_user_sid_from_rid(to, from->user_rid); - if (from->group_rid) - pdb_set_group_sid_from_rid(to, from->group_rid); + if (!nt_time_is_zero(&from->pass_can_change_time)) { + unix_time=nt_time_to_unix(&from->pass_can_change_time); + stored_time = pdb_get_pass_can_change_time(to); + DEBUG(10,("INFO_23 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_can_change_time(to, unix_time, True); + } + if (!nt_time_is_zero(&from->pass_last_set_time)) { + unix_time=nt_time_to_unix(&from->pass_last_set_time); + stored_time = pdb_get_pass_last_set_time(to); + DEBUG(10,("INFO_23 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_last_set_time(to, unix_time); + } + + if (!nt_time_is_zero(&from->pass_must_change_time)) { + unix_time=nt_time_to_unix(&from->pass_must_change_time); + stored_time=pdb_get_pass_must_change_time(to); + DEBUG(10,("INFO_23 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_must_change_time(to, unix_time, True); + } + + /* Backend should check this for sainity */ + if (from->hdr_user_name.buffer) { + old_string = pdb_get_username(to); + new_string = pdb_unistr2_convert(&from->uni_user_name); + DEBUG(10,("INFO_23 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); + if (STRING_CHANGED) + pdb_set_username(to , new_string); + } + + if (from->hdr_full_name.buffer) { + old_string = pdb_get_fullname(to); + new_string = pdb_unistr2_convert(&from->uni_user_name); + DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_fullname(to , new_string); + } + + if (from->hdr_home_dir.buffer) { + old_string = pdb_get_homedir(to); + new_string = pdb_unistr2_convert(&from->uni_home_dir); + DEBUG(10,("INFO_23 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_homedir(to , new_string, True); + } + + if (from->hdr_dir_drive.buffer) { + old_string = pdb_get_dir_drive(to); + new_string = pdb_unistr2_convert(&from->uni_dir_drive); + DEBUG(10,("INFO_23 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_dir_drive(to , new_string, True); + } - /* FIXME!! Do we need to copy the passwords here as well? - I don't know. Need to figure this out --jerry */ + if (from->hdr_logon_script.buffer) { + old_string = pdb_get_logon_script(to); + new_string = pdb_unistr2_convert(&from->uni_logon_script); + DEBUG(10,("INFO_23 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_logon_script(to , new_string, True); + } - /* Passwords dealt with in caller --abartlet */ + if (from->hdr_profile_path.buffer) { + old_string = pdb_get_profile_path(to); + new_string = pdb_unistr2_convert(&from->uni_profile_path); + DEBUG(10,("INFO_23 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_profile_path(to , new_string, True); + } + + if (from->hdr_acct_desc.buffer) { + old_string = pdb_get_acct_desc(to); + new_string = pdb_unistr2_convert(&from->uni_acct_desc); + DEBUG(10,("INFO_23 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_acct_desc(to , new_string); + } + + if (from->hdr_workstations.buffer) { + old_string = pdb_get_workstations(to); + new_string = pdb_unistr2_convert(&from->uni_workstations); + DEBUG(10,("INFO_23 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_workstations(to , new_string); + } + if (from->hdr_unknown_str.buffer) { + old_string = pdb_get_unknown_str(to); + new_string = pdb_unistr2_convert(&from->uni_unknown_str); + DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_unknown_str(to , new_string); + } + + if (from->hdr_munged_dial.buffer) { + old_string = pdb_get_munged_dial(to); + new_string = pdb_unistr2_convert(&from->uni_munged_dial); + DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_munged_dial(to , new_string); + } + + if (from->user_rid) { + DEBUG(10,("INFO_23 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); + /* we really allow this ??? metze */ + /* pdb_set_user_sid_from_rid(to, from->user_rid);*/ + } + + if (from->group_rid) { + DEBUG(10,("INFO_23 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); + pdb_set_group_sid_from_rid(to, from->group_rid); + } + + DEBUG(10,("INFO_23 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); pdb_set_acct_ctrl(to, from->acb_info); + + DEBUG(10,("INFO_23 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown3(to),from->unknown_3)); pdb_set_unknown_3(to, from->unknown_3); + + DEBUG(15,("INFO_23 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); pdb_set_logon_divs(to, from->logon_divs); + + DEBUG(15,("INFO_23 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); pdb_set_hours_len(to, from->logon_hrs.len); + DEBUG(15,("INFO_23 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); pdb_set_hours(to, from->logon_hrs.hours); + DEBUG(10,("INFO_23 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown5(to),from->unknown_5)); pdb_set_unknown_5(to, from->unknown_5); + + DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown6(to),from->unknown_6)); pdb_set_unknown_6(to, from->unknown_6); + + DEBUG(10,("INFO_23 PADDING1 %02X %02X %02X %02X %02X %02X\n", + from->padding1[0], + from->padding1[1], + from->padding1[2], + from->padding1[3], + from->padding1[4], + from->padding1[5])); + + DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); + if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) { + pdb_set_pass_must_change_time(to,0, True); + } + + DEBUG(10,("INFO_23 PADDING_2: %02X\n",from->padding2)); + + DEBUG(10,("INFO_23 PADDING_4: %08X\n",from->padding4)); } + -- cgit From 3c7334c1b5862b8df3533e228978069d2099ac06 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 27 Sep 2002 22:08:25 +0000 Subject: Check for security on delete printer was reversed... Jeremy. (This used to be commit 0d27cc909b4489b54e57481bd8a9494fb077dc3d) --- source3/rpc_server/srv_spoolss_nt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2190215107..dcffa968d5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -313,11 +313,6 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) return WERR_BADFID; } - if (del_a_printer(Printer->dev.handlename) != 0) { - DEBUG(3,("Error deleting printer %s\n", Printer->dev.handlename)); - return WERR_BADFID; - } - /* Check calling user has permission to delete printer. Note that since we set the snum parameter to -1 only administrators can delete the printer. This stops people with the Full Control @@ -328,6 +323,11 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) return WERR_ACCESS_DENIED; } + if (del_a_printer(Printer->dev.handlename) != 0) { + DEBUG(3,("Error deleting printer %s\n", Printer->dev.handlename)); + return WERR_BADFID; + } + if (*lp_deleteprinter_cmd()) { char *cmd = lp_deleteprinter_cmd(); -- cgit From c56213607cd1e9d8a4d98b3aa1e9c36b4d3b275a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 27 Sep 2002 22:51:44 +0000 Subject: It turns out that Windows allows delete printer on a handle opened by an admin user, then used on a pipe handle created by an anonymous user..... but they're working on security.... riiight ! Jeremy. (This used to be commit e96e6a60b82b71714120ce7636fa8402007d4b03) --- source3/rpc_server/srv_spoolss_nt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2190215107..e60a1d2063 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -318,6 +318,19 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) return WERR_BADFID; } + /* + * It turns out that Windows allows delete printer on a handle + * opened by an admin user, then used on a pipe handle created + * by an anonymous user..... but they're working on security.... riiight ! + * JRA. + */ + + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + DEBUG(3, ("delete_printer_handle: denied by handle\n")); + return WERR_ACCESS_DENIED; + } + +#if 0 /* Check calling user has permission to delete printer. Note that since we set the snum parameter to -1 only administrators can delete the printer. This stops people with the Full Control @@ -327,6 +340,7 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) DEBUG(3, ("printer delete denied by security descriptor\n")); return WERR_ACCESS_DENIED; } +#endif if (*lp_deleteprinter_cmd()) { -- cgit From 543edfbeab9540cf819f09715b1bcf0fca9e99b1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 27 Sep 2002 22:51:59 +0000 Subject: It turns out that Windows allows delete printer on a handle opened by an admin user, then used on a pipe handle created by an anonymous user..... but they're working on security.... riiight ! Jeremy. (This used to be commit 322d8b4c83439261cfd2ff79b557bddb1e784660) --- source3/rpc_server/srv_spoolss_nt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index dcffa968d5..f942a685a1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -313,6 +313,19 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) return WERR_BADFID; } + /* + * It turns out that Windows allows delete printer on a handle + * opened by an admin user, then used on a pipe handle created + * by an anonymous user..... but they're working on security.... riiight ! + * JRA. + */ + + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { + DEBUG(3, ("delete_printer_handle: denied by handle\n")); + return WERR_ACCESS_DENIED; + } + +#if 0 /* Check calling user has permission to delete printer. Note that since we set the snum parameter to -1 only administrators can delete the printer. This stops people with the Full Control @@ -322,6 +335,7 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) DEBUG(3, ("printer delete denied by security descriptor\n")); return WERR_ACCESS_DENIED; } +#endif if (del_a_printer(Printer->dev.handlename) != 0) { DEBUG(3,("Error deleting printer %s\n", Printer->dev.handlename)); -- cgit From cdeffe6d909ea84979b0fe286efebc95c2d83209 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 29 Sep 2002 10:39:03 +0000 Subject: We have to hand out info on Builtin here as well. They are stored in group mapping not as local, but as WKN_GRP. Volker (This used to be commit cb05dcab2de117ea4db54af313a05905cd5a0d0a) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c5a2c54511..290baabc3b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1328,7 +1328,7 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM !sid_check_is_in_builtin(&sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - if (!get_local_group_from_sid(sid, &map, MAPPING_WITHOUT_PRIV)) + if (!get_group_map_from_sid(sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; switch (q_u->switch_level) { -- cgit From 4b5c0793de285b6978ca5b6161418d51812ac0ba Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 30 Sep 2002 06:45:58 +0000 Subject: Second part of my fix -- incorrect merge. (This used to be commit 2613d3a48a8d60c3db38406a1abd943dbe0b7d09) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 290baabc3b..020a3c6aaf 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -894,7 +894,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM /* well-known aliases */ if (sid_equal(sid, &global_sid_Builtin) && !lp_hide_local_users()) { - enum_group_mapping(SID_NAME_ALIAS, &map, (int *)&num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); + enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); if (num_entries != 0) { *d_grp=(DOMAIN_GRP *)talloc_zero(ctx, num_entries*sizeof(DOMAIN_GRP)); -- cgit From f2d1f19a66ebaf9b88d23c0faa2412536cc74cda Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 1 Oct 2002 18:26:00 +0000 Subject: syncing up with HEAD. Seems to be a lot of differences creeping in (i ignored the new SAMBA stuff, but the rest of this looks like it should have been merged already). (This used to be commit 3de09e5cf1f667e410ee8b9516a956860ce7290f) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- source3/rpc_server/srv_spoolss_nt.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c5a2c54511..020a3c6aaf 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -894,7 +894,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM /* well-known aliases */ if (sid_equal(sid, &global_sid_Builtin) && !lp_hide_local_users()) { - enum_group_mapping(SID_NAME_ALIAS, &map, (int *)&num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); + enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); if (num_entries != 0) { *d_grp=(DOMAIN_GRP *)talloc_zero(ctx, num_entries*sizeof(DOMAIN_GRP)); @@ -1328,7 +1328,7 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM !sid_check_is_in_builtin(&sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - if (!get_local_group_from_sid(sid, &map, MAPPING_WITHOUT_PRIV)) + if (!get_group_map_from_sid(sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; switch (q_u->switch_level) { diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e60a1d2063..f942a685a1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -313,11 +313,6 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) return WERR_BADFID; } - if (del_a_printer(Printer->dev.handlename) != 0) { - DEBUG(3,("Error deleting printer %s\n", Printer->dev.handlename)); - return WERR_BADFID; - } - /* * It turns out that Windows allows delete printer on a handle * opened by an admin user, then used on a pipe handle created @@ -342,6 +337,11 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) } #endif + if (del_a_printer(Printer->dev.handlename) != 0) { + DEBUG(3,("Error deleting printer %s\n", Printer->dev.handlename)); + return WERR_BADFID; + } + if (*lp_deleteprinter_cmd()) { char *cmd = lp_deleteprinter_cmd(); -- cgit From c4596dcf32902b9c7375d84c8a079d30677054fc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 2 Oct 2002 22:55:28 +0000 Subject: Missing break meant getprintprocessordirectory always returned UNKNOWN_LEVEL. Jeremy. (This used to be commit a9a959b85d110c4a6b9ac8988d35aee9a4d6b9f1) --- source3/rpc_server/srv_spoolss_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f942a685a1..12d6639348 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8776,6 +8776,7 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC case 1: result = getprintprocessordirectory_level_1 (&q_u->name, &q_u->environment, buffer, offered, needed); + break; default: result = WERR_UNKNOWN_LEVEL; } -- cgit From 32027e3b6bb12e81a0f667d550e4bc9be91a29c5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 2 Oct 2002 22:55:40 +0000 Subject: Missing break meant getprintprocessordirectory always returned UNKNOWN_LEVEL. Jeremy. (This used to be commit 1b283b649f68890b0aa450aa1ac90f1e8031a6fd) --- source3/rpc_server/srv_spoolss_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f942a685a1..12d6639348 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8776,6 +8776,7 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC case 1: result = getprintprocessordirectory_level_1 (&q_u->name, &q_u->environment, buffer, offered, needed); + break; default: result = WERR_UNKNOWN_LEVEL; } -- cgit From 83e58265b5595f5268bbcbda1a078a81d6fd5a40 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 4 Oct 2002 03:51:43 +0000 Subject: merge of new client side support the Win2k LSARPC UUID in rpcbind from APP_HEAD (This used to be commit 38c9e4299845fd77cc8629945ce2d259489f7437) --- source3/rpc_server/srv_pipe.c | 41 +++++++++++++++++++++++++++++-------- source3/rpc_server/srv_spoolss_nt.c | 2 +- 2 files changed, 33 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 1947d5514e..5a935be279 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -681,26 +681,49 @@ BOOL check_bind_req(char* pipe_name, RPC_IFACE* abstract, fstrcpy(pname,"\\PIPE\\"); fstrcat(pname,pipe_name); - for(i=0;pipe_names[i].client_pipe; i++) { - if(strequal(pipe_names[i].client_pipe, pname)) + +#ifndef SUPPORT_NEW_LSARPC_UUID + + /* check for the first pipe matching the name */ + + for ( i=0; pipe_names[i].client_pipe; i++ ) { + if ( strequal(pipe_names[i].client_pipe, pname) ) + break; + } +#else + /* we have to check all now since win2k introduced a new UUID on the lsaprpc pipe */ + + for ( i=0; pipe_names[i].client_pipe; i++ ) + { + if ( strequal(pipe_names[i].client_pipe, pname) + && (abstract->version == pipe_names[i].abstr_syntax.version) + && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(RPC_UUID)) == 0) + && (transfer->version == pipe_names[i].trans_syntax.version) + && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(RPC_UUID)) == 0) ) + { break; + } } +#endif if(pipe_names[i].client_pipe == NULL) return False; +#ifndef SUPPORT_NEW_LSARPC_UUID /* check the abstract interface */ - if((abstract->version != pipe_names[i].abstr_syntax.version) || - (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, - sizeof(RPC_UUID)) != 0)) + if ( (abstract->version != pipe_names[i].abstr_syntax.version) + || (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(RPC_UUID)) != 0) ) + { return False; + } /* check the transfer interface */ - if((transfer->version != pipe_names[i].trans_syntax.version) || - (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, - sizeof(RPC_UUID)) != 0)) + if ( (transfer->version != pipe_names[i].trans_syntax.version) + || (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(RPC_UUID)) != 0) ) + { return False; - + } +#endif return True; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 12d6639348..41ef599a3c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2375,7 +2375,7 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, char *remote_ma * Now start the NT Domain stuff :-). */ - if(cli_nt_session_open(the_cli, PIPE_SPOOLSS) == False) { + if(cli_nt_session_open(the_cli, PI_SPOOLSS) == False) { DEBUG(0,("connect_to_client: unable to open the domain client session to machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli))); cli_nt_session_close(the_cli); cli_ulogoff(the_cli); -- cgit From 36ef82a52953384acedbd51f54ded9357fa8ca3e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 4 Oct 2002 04:10:23 +0000 Subject: merge of new client side support the Win2k LSARPC UUID in rpcbind from APP_HEAD (This used to be commit 1cfd2ee433305e91e87804dd55d10e025d30a69e) --- source3/rpc_server/srv_pipe.c | 41 +++++++++++++++++++++++++++++-------- source3/rpc_server/srv_spoolss_nt.c | 2 +- 2 files changed, 33 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 1947d5514e..5a935be279 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -681,26 +681,49 @@ BOOL check_bind_req(char* pipe_name, RPC_IFACE* abstract, fstrcpy(pname,"\\PIPE\\"); fstrcat(pname,pipe_name); - for(i=0;pipe_names[i].client_pipe; i++) { - if(strequal(pipe_names[i].client_pipe, pname)) + +#ifndef SUPPORT_NEW_LSARPC_UUID + + /* check for the first pipe matching the name */ + + for ( i=0; pipe_names[i].client_pipe; i++ ) { + if ( strequal(pipe_names[i].client_pipe, pname) ) + break; + } +#else + /* we have to check all now since win2k introduced a new UUID on the lsaprpc pipe */ + + for ( i=0; pipe_names[i].client_pipe; i++ ) + { + if ( strequal(pipe_names[i].client_pipe, pname) + && (abstract->version == pipe_names[i].abstr_syntax.version) + && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(RPC_UUID)) == 0) + && (transfer->version == pipe_names[i].trans_syntax.version) + && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(RPC_UUID)) == 0) ) + { break; + } } +#endif if(pipe_names[i].client_pipe == NULL) return False; +#ifndef SUPPORT_NEW_LSARPC_UUID /* check the abstract interface */ - if((abstract->version != pipe_names[i].abstr_syntax.version) || - (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, - sizeof(RPC_UUID)) != 0)) + if ( (abstract->version != pipe_names[i].abstr_syntax.version) + || (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(RPC_UUID)) != 0) ) + { return False; + } /* check the transfer interface */ - if((transfer->version != pipe_names[i].trans_syntax.version) || - (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, - sizeof(RPC_UUID)) != 0)) + if ( (transfer->version != pipe_names[i].trans_syntax.version) + || (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(RPC_UUID)) != 0) ) + { return False; - + } +#endif return True; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 12d6639348..41ef599a3c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2375,7 +2375,7 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, char *remote_ma * Now start the NT Domain stuff :-). */ - if(cli_nt_session_open(the_cli, PIPE_SPOOLSS) == False) { + if(cli_nt_session_open(the_cli, PI_SPOOLSS) == False) { DEBUG(0,("connect_to_client: unable to open the domain client session to machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli))); cli_nt_session_close(the_cli); cli_ulogoff(the_cli); -- cgit From 3665777a5bc7ffa92f64ba17daf4cc66c3607198 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 Oct 2002 22:53:18 +0000 Subject: Add a timeout to tdb_lock_bystring(). Ensure we never have more than MAX_PRINT_JOBS in a queue. Jeremy. (This used to be commit 9fe3c0b90d4bff2217e3cb5a34b4683ca314c06e) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 69945b50b8..ecde51df9f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -145,7 +145,7 @@ BOOL share_info_db_init(void) local_pid = sys_getpid(); /* handle a Samba upgrade */ - tdb_lock_bystring(share_tdb, vstring); + tdb_lock_bystring(share_tdb, vstring, 0); /* Cope with byte-reversed older versions of the db. */ vers_id = tdb_fetch_int32(share_tdb, vstring); -- cgit From 9c94d1a2f72b6fcbbd056804837fc8719806491b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 Oct 2002 22:53:30 +0000 Subject: Add a timeout to tdb_lock_bystring(). Ensure we never have more than MAX_PRINT_JOBS in a queue. Jeremy. (This used to be commit bb58a08af459b4abae9d53ab98c15f40638ce52b) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 69945b50b8..ecde51df9f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -145,7 +145,7 @@ BOOL share_info_db_init(void) local_pid = sys_getpid(); /* handle a Samba upgrade */ - tdb_lock_bystring(share_tdb, vstring); + tdb_lock_bystring(share_tdb, vstring, 0); /* Cope with byte-reversed older versions of the db. */ vers_id = tdb_fetch_int32(share_tdb, vstring); -- cgit From 650e0274a1ea98a953b2e6f44e7e8e880d418565 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 6 Oct 2002 23:53:34 +0000 Subject: try to put every security descriptors related definitions in the same file. also try to uniform names to a clean scheme. first part. (This used to be commit a123e05877caf90c28980be2d84b1d0b46e4fd21) --- source3/rpc_server/srv_reg_nt.c | 1 - source3/rpc_server/srv_samr.c | 1 - source3/rpc_server/srv_samr_nt.c | 88 ++++++++++++++++++++-------------------- 3 files changed, 44 insertions(+), 46 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index f96de7e533..7435bdb6f7 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -131,7 +131,6 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY if ( fetch_reg_keys( regkey, &subkeys ) == -1 ) { /* don't really know what to return here */ - result = NT_STATUS_NO_SUCH_FILE; } else { diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index bc3b8970d6..ab3d94cf75 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -155,7 +155,6 @@ static BOOL api_samr_set_sec_obj(pipes_struct *p) return False; } - return True; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 020a3c6aaf..3073ca8f75 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -64,11 +64,11 @@ struct samr_info { TALLOC_CTX *mem_ctx; }; -struct generic_mapping sam_generic_mapping = {SAMR_READ, SAMR_WRITE, SAMR_EXECUTE, SAMR_ALL_ACCESS}; -struct generic_mapping dom_generic_mapping = {DOMAIN_READ, DOMAIN_WRITE, DOMAIN_EXECUTE, DOMAIN_ALL_ACCESS}; -struct generic_mapping usr_generic_mapping = {USER_READ, USER_WRITE, USER_EXECUTE, USER_ALL_ACCESS}; -struct generic_mapping grp_generic_mapping = {GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, GROUP_ALL_ACCESS}; -struct generic_mapping ali_generic_mapping = {ALIAS_READ, ALIAS_WRITE, ALIAS_EXECUTE, ALIAS_ALL_ACCESS}; +struct generic_mapping sam_generic_mapping = {GENERIC_RIGHTS_SAM_READ, GENERIC_RIGHTS_SAM_WRITE, GENERIC_RIGHTS_SAM_EXECUTE, GENERIC_RIGHTS_SAM_ALL_ACCESS}; +struct generic_mapping dom_generic_mapping = {GENERIC_RIGHTS_DOMAIN_READ, GENERIC_RIGHTS_DOMAIN_WRITE, GENERIC_RIGHTS_DOMAIN_EXECUTE, GENERIC_RIGHTS_DOMAIN_ALL_ACCESS}; +struct generic_mapping usr_generic_mapping = {GENERIC_RIGHTS_USER_READ, GENERIC_RIGHTS_USER_WRITE, GENERIC_RIGHTS_USER_EXECUTE, GENERIC_RIGHTS_USER_ALL_ACCESS}; +struct generic_mapping grp_generic_mapping = {GENERIC_RIGHTS_GROUP_READ, GENERIC_RIGHTS_GROUP_WRITE, GENERIC_RIGHTS_GROUP_EXECUTE, GENERIC_RIGHTS_GROUP_ALL_ACCESS}; +struct generic_mapping ali_generic_mapping = {GENERIC_RIGHTS_ALIAS_READ, GENERIC_RIGHTS_ALIAS_WRITE, GENERIC_RIGHTS_ALIAS_EXECUTE, GENERIC_RIGHTS_ALIAS_ALL_ACCESS}; static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size); @@ -375,7 +375,7 @@ NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN if (!find_policy_by_hnd(p, &q_u->pol, (void**)&info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(status = access_check_samr_function(info->acc_granted, SAMR_ACCESS_OPEN_DOMAIN,"_samr_open_domain"))) { + if (!NT_STATUS_IS_OK(status = access_check_samr_function(info->acc_granted, SA_RIGHT_SAM_OPEN_DOMAIN,"_samr_open_domain"))) { return status; } @@ -454,11 +454,11 @@ static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); /*basic access for every one*/ - init_sec_access(&mask, DOMAIN_EXECUTE | DOMAIN_READ); + init_sec_access(&mask, GENERIC_RIGHTS_DOMAIN_EXECUTE | GENERIC_RIGHTS_DOMAIN_READ); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, DOMAIN_ALL_ACCESS); + init_sec_access(&mask, GENERIC_RIGHTS_DOMAIN_ALL_ACCESS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); @@ -493,16 +493,16 @@ static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); /*basic access for every one*/ - init_sec_access(&mask, USER_EXECUTE | USER_READ); + init_sec_access(&mask, GENERIC_RIGHTS_USER_EXECUTE | GENERIC_RIGHTS_USER_READ); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, USER_ALL_ACCESS); + init_sec_access(&mask, GENERIC_RIGHTS_USER_ALL_ACCESS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /*extended access for the user*/ - init_sec_access(&mask,READ_CONTROL_ACCESS | USER_ACCESS_CHANGE_PASSWORD | USER_ACCESS_SET_LOC_COM); + init_sec_access(&mask,READ_CONTROL_ACCESS | SA_RIGHT_USER_CHANGE_PASSWORD | SA_RIGHT_USER_SET_LOC_COM); init_sec_ace(&ace[3], usr_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 4, ace)) == NULL) @@ -536,11 +536,11 @@ static NTSTATUS samr_make_grp_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); /*basic access for every one*/ - init_sec_access(&mask, GROUP_EXECUTE | GROUP_READ); + init_sec_access(&mask, GENERIC_RIGHTS_GROUP_EXECUTE | GENERIC_RIGHTS_GROUP_READ); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, GROUP_ALL_ACCESS); + init_sec_access(&mask, GENERIC_RIGHTS_GROUP_ALL_ACCESS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); @@ -575,11 +575,11 @@ static NTSTATUS samr_make_ali_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); /*basic access for every one*/ - init_sec_access(&mask, ALIAS_EXECUTE | ALIAS_READ); + init_sec_access(&mask, GENERIC_RIGHTS_ALIAS_EXECUTE | GENERIC_RIGHTS_ALIAS_READ); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, ALIAS_ALL_ACCESS); + init_sec_access(&mask, GENERIC_RIGHTS_ALIAS_ALL_ACCESS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); @@ -765,7 +765,7 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, domain_sid = info->sid; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, - DOMAIN_ACCESS_ENUM_ACCOUNTS, + SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_users"))) { return r_u->status; } @@ -1058,7 +1058,7 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_ENUM_ACCOUNTS, "_samr_enum_dom_groups"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_groups"))) { return r_u->status; } @@ -1097,7 +1097,7 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_ENUM_ACCOUNTS, "_samr_enum_dom_aliases"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_aliases"))) { return r_u->status; } @@ -1320,7 +1320,7 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM /* find the policy handle. open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_LOOKUP_INFO, "_samr_query_aliasinfo"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_LOOKUP_INFO, "_samr_query_aliasinfo"))) { return r_u->status; } @@ -1667,7 +1667,7 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN if (!get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_open_user"))) { + if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_user"))) { return nt_status; } @@ -2008,7 +2008,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, USER_ACCESS_GET_GROUPS, "_samr_query_usergroups"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_USER_GET_GROUPS, "_samr_query_usergroups"))) { return r_u->status; } @@ -2194,7 +2194,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_CREATE_USER, "_samr_create_user"))) { + if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_USER, "_samr_create_user"))) { return nt_status; } @@ -2496,7 +2496,7 @@ NTSTATUS _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_ if (!find_policy_by_hnd(p, &q_u->connect_pol, (void**)&info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SAMR_ACCESS_OPEN_DOMAIN, "_samr_lookup_domain"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_SAM_OPEN_DOMAIN, "_samr_lookup_domain"))) { return r_u->status; } @@ -2569,7 +2569,7 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN if (!find_policy_by_hnd(p, &q_u->pol, (void**)&info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SAMR_ACCESS_ENUM_DOMAINS, "_samr_enum_domains"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_SAM_ENUM_DOMAINS, "_samr_enum_domains"))) { return r_u->status; } @@ -2617,7 +2617,7 @@ NTSTATUS _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OP if (!get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_open_alias"))) { + if (!NT_STATUS_IS_OK(status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_alias"))) { return status; } @@ -2928,7 +2928,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - acc_required = USER_ACCESS_SET_LOC_COM | USER_ACCESS_SET_ATTRIBUTES; /* This is probably wrong */ + acc_required = SA_RIGHT_USER_SET_LOC_COM | SA_RIGHT_USER_SET_ATTRIBUTES; /* This is probably wrong */ if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo"))) { return r_u->status; } @@ -3013,7 +3013,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - acc_required = USER_ACCESS_SET_LOC_COM | USER_ACCESS_SET_ATTRIBUTES; /* This is probably wrong */ + acc_required = SA_RIGHT_USER_SET_LOC_COM | SA_RIGHT_USER_SET_ATTRIBUTES; /* This is probably wrong */ if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo2"))) { return r_u->status; } @@ -3088,8 +3088,8 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - ntstatus1 = access_check_samr_function(info->acc_granted, DOMAIN_ACCESS_LOOKUP_ALIAS_BY_MEM, "_samr_query_useraliases"); - ntstatus2 = access_check_samr_function(info->acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_query_useraliases"); + ntstatus1 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_LOOKUP_ALIAS_BY_MEM, "_samr_query_useraliases"); + ntstatus2 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_query_useraliases"); if (!NT_STATUS_IS_OK(ntstatus1) || !NT_STATUS_IS_OK(ntstatus2)) { if (!(NT_STATUS_EQUAL(ntstatus1,NT_STATUS_ACCESS_DENIED) && NT_STATUS_IS_OK(ntstatus2)) && @@ -3168,7 +3168,7 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = - access_check_samr_function(acc_granted, ALIAS_ACCESS_GET_MEMBERS, "_samr_query_aliasmem"))) { + access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_GET_MEMBERS, "_samr_query_aliasmem"))) { return r_u->status; } @@ -3269,7 +3269,7 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_GET_MEMBERS, "_samr_query_groupmem"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_GET_MEMBERS, "_samr_query_groupmem"))) { return r_u->status; } @@ -3361,7 +3361,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_ADD_MEMBER, "_samr_add_aliasmem"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_ADD_MEMBER, "_samr_add_aliasmem"))) { return r_u->status; } @@ -3449,7 +3449,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_REMOVE_MEMBER, "_samr_del_aliasmem"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_REMOVE_MEMBER, "_samr_del_aliasmem"))) { return r_u->status; } @@ -3520,7 +3520,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_ADD_MEMBER, "_samr_add_groupmem"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_ADD_MEMBER, "_samr_add_groupmem"))) { return r_u->status; } @@ -3612,7 +3612,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_REMOVE_MEMBER, "_samr_del_groupmem"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_REMOVE_MEMBER, "_samr_del_groupmem"))) { return r_u->status; } @@ -3692,7 +3692,7 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &user_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DELETE_ACCESS, "_samr_delete_dom_user"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_user"))) { return r_u->status; } @@ -3751,7 +3751,7 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DELETE_ACCESS, "_samr_delete_dom_group"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_group"))) { return r_u->status; } @@ -3813,7 +3813,7 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DELETE_ACCESS, "_samr_delete_dom_alias"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_alias"))) { return r_u->status; } @@ -3876,7 +3876,7 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_CREATE_GROUP, "_samr_create_dom_group"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_GROUP, "_samr_create_dom_group"))) { return r_u->status; } @@ -3941,7 +3941,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_CREATE_ALIAS, "_samr_create_alias"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_ALIAS, "_samr_create_alias"))) { return r_u->status; } @@ -4003,7 +4003,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_LOOKUP_INFO, "_samr_query_groupinfo"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_LOOKUP_INFO, "_samr_query_groupinfo"))) { return r_u->status; } @@ -4055,7 +4055,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_SET_INFO, "_samr_set_groupinfo"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_SET_INFO, "_samr_set_groupinfo"))) { return r_u->status; } @@ -4102,7 +4102,7 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_SET_INFO, "_samr_set_aliasinfo"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_SET_INFO, "_samr_set_aliasinfo"))) { return r_u->status; } @@ -4171,7 +4171,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_open_group"))) { + if (!NT_STATUS_IS_OK(status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_group"))) { return status; } -- cgit From 0672da5c4376ea8f5dcc3e4fc75c9c4efb1c770e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 8 Oct 2002 15:29:13 +0000 Subject: Third part of my fix for usrmgr. Assuming automagic mapping only in parts of srv_samr_nt is not good. This is soo broken. :-) Volker (This used to be commit 74e4a3479f380b320daa0d46c0ba4daa9f98c18f) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 3073ca8f75..6b7318a325 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -931,7 +931,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM for (; (num_entries < max_entries) && (grp != NULL); grp = grp->next) { uint32 trid; - if(!get_group_from_gid(grp->gr_gid, &smap, MAPPING_WITHOUT_PRIV)) + if(!get_group_map_from_gid(grp->gr_gid, &smap, MAPPING_WITHOUT_PRIV)) continue; if (smap.sid_name_use!=SID_NAME_ALIAS) { -- cgit From 876afb5d0f60a7c358b7b3023e59093ce192aa6b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 8 Oct 2002 18:29:57 +0000 Subject: merge from APP_HEAD * s/driverlocation/comment * detect native mode domain and enumerate local groups Also * Added sendfile stats from SAMBA_2_2 (This used to be commit 764b58e2c0b3179cffe157c0ab58761b156b8423) --- source3/rpc_server/srv_spoolss_nt.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 41ef599a3c..2851ed79c6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5603,23 +5603,17 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) char *cmd = lp_addprinter_cmd(); char **qlines; pstring command; - pstring driverlocation; int numlines; int ret; int fd; fstring remote_machine = "%m"; - /* build driver path... only 9X architecture is needed for legacy reasons */ - slprintf(driverlocation, sizeof(driverlocation)-1, "\\\\%s\\print$\\WIN40\\0", - get_called_name()); - /* change \ to \\ for the shell */ - all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring)); standard_sub_basic(current_user_info.smb_name, remote_machine,sizeof(remote_machine)); slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", cmd, printer->info_2->printername, printer->info_2->sharename, printer->info_2->portname, printer->info_2->drivername, - printer->info_2->location, driverlocation, remote_machine); + printer->info_2->location, printer->info_2->comment, remote_machine); DEBUG(10,("Running [%s]\n", command)); ret = smbrun(command, &fd); -- cgit From bfa93735abe52fe07fde1b10ece0c31f5cf73ef8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 8 Oct 2002 18:32:42 +0000 Subject: merge from APP_HEAD of winbindd's domain local group fix (This used to be commit 09c6f6329d6ae9327b7ef06de0ea78d24d805456) --- source3/rpc_server/srv_spoolss_nt.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 41ef599a3c..2851ed79c6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5603,23 +5603,17 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) char *cmd = lp_addprinter_cmd(); char **qlines; pstring command; - pstring driverlocation; int numlines; int ret; int fd; fstring remote_machine = "%m"; - /* build driver path... only 9X architecture is needed for legacy reasons */ - slprintf(driverlocation, sizeof(driverlocation)-1, "\\\\%s\\print$\\WIN40\\0", - get_called_name()); - /* change \ to \\ for the shell */ - all_string_sub(driverlocation,"\\","\\\\",sizeof(pstring)); standard_sub_basic(current_user_info.smb_name, remote_machine,sizeof(remote_machine)); slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", cmd, printer->info_2->printername, printer->info_2->sharename, printer->info_2->portname, printer->info_2->drivername, - printer->info_2->location, driverlocation, remote_machine); + printer->info_2->location, printer->info_2->comment, remote_machine); DEBUG(10,("Running [%s]\n", command)); ret = smbrun(command, &fd); -- cgit From b57d0e060df0a83b0e74439974563c46796064a1 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 9 Oct 2002 16:59:45 +0000 Subject: add_printer_hook() fix from APP_HEAD (This used to be commit b381ed3a9eba24c11796a9ca5cb4d226c131d867) --- source3/rpc_server/srv_spoolss_nt.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2851ed79c6..a1eb99cb32 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -363,10 +363,10 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) /* Send SIGHUP to process group... is there a better way? */ kill(0, SIGHUP); - if ( ( i = lp_servicenumber( Printer->dev.handlename ) ) >= 0 ) { - lp_killservice( i ); - return WERR_OK; - } else + /* go ahead and re-read the services immediately */ + reload_services( False ); + + if ( ( i = lp_servicenumber( Printer->dev.handlename ) ) < 0 ) return WERR_ACCESS_DENIED; } @@ -5638,7 +5638,9 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) /* Send SIGHUP to process group... is there a better way? */ kill(0, SIGHUP); - add_all_printers(); + + /* reload our services immediately */ + reload_services( False ); } file_lines_free(qlines); @@ -5709,6 +5711,13 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, result = WERR_NOMEM; goto done; } + + /* + * make sure we actually reload the services after + * this as smb.conf could have a new section in it + * .... shouldn't .... but could + */ + reload_services(False); } /* Do sanity check on the requested changes for Samba */ @@ -6918,15 +6927,17 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ return WERR_PRINTER_ALREADY_EXISTS; } - if (*lp_addprinter_cmd() ) + if (*lp_addprinter_cmd() ) { if ( !add_printer_hook(printer) ) { free_a_printer(&printer,2); return WERR_ACCESS_DENIED; } + } slprintf(name, sizeof(name)-1, "\\\\%s\\%s", get_called_name(), printer->info_2->sharename); + if ((snum = print_queue_snum(printer->info_2->sharename)) == -1) { free_a_printer(&printer,2); return WERR_ACCESS_DENIED; -- cgit From 01da7d5617d319b1baa9e221051111ad7548feb9 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 9 Oct 2002 17:00:04 +0000 Subject: add_printer_hook() fix from APP_HEAD (This used to be commit 94201672a5c3cffd145e9f04a3ddd0d17a57e73b) --- source3/rpc_server/srv_spoolss_nt.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2851ed79c6..a1eb99cb32 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -363,10 +363,10 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) /* Send SIGHUP to process group... is there a better way? */ kill(0, SIGHUP); - if ( ( i = lp_servicenumber( Printer->dev.handlename ) ) >= 0 ) { - lp_killservice( i ); - return WERR_OK; - } else + /* go ahead and re-read the services immediately */ + reload_services( False ); + + if ( ( i = lp_servicenumber( Printer->dev.handlename ) ) < 0 ) return WERR_ACCESS_DENIED; } @@ -5638,7 +5638,9 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) /* Send SIGHUP to process group... is there a better way? */ kill(0, SIGHUP); - add_all_printers(); + + /* reload our services immediately */ + reload_services( False ); } file_lines_free(qlines); @@ -5709,6 +5711,13 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, result = WERR_NOMEM; goto done; } + + /* + * make sure we actually reload the services after + * this as smb.conf could have a new section in it + * .... shouldn't .... but could + */ + reload_services(False); } /* Do sanity check on the requested changes for Samba */ @@ -6918,15 +6927,17 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ return WERR_PRINTER_ALREADY_EXISTS; } - if (*lp_addprinter_cmd() ) + if (*lp_addprinter_cmd() ) { if ( !add_printer_hook(printer) ) { free_a_printer(&printer,2); return WERR_ACCESS_DENIED; } + } slprintf(name, sizeof(name)-1, "\\\\%s\\%s", get_called_name(), printer->info_2->sharename); + if ((snum = print_queue_snum(printer->info_2->sharename)) == -1) { free_a_printer(&printer,2); return WERR_ACCESS_DENIED; -- cgit From a92bf85234edbf258ca4907aa4b83f9e717ea5ad Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 9 Oct 2002 18:54:20 +0000 Subject: print job properties fix from APP_HEAD. a null devmode is not a failure. (This used to be commit b507dba452ecbd96ec95242f761501d0c5e0d7b5) --- source3/rpc_server/srv_spoolss_nt.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a1eb99cb32..c5d46abe57 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6017,11 +6017,9 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, goto done; } - if (!(devmode = construct_dev_mode(snum))) { - *returned = 0; - result = WERR_NOMEM; - goto done; - } + /* this should not be a failure condition if the devmode is NULL */ + + devmode = construct_dev_mode(snum); for (i=0; i<*returned; i++) fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter, @@ -8122,7 +8120,8 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin /* * if the print job does not have a DEVMODE associated with it, - * just use the one for the printer + * just use the one for the printer. A NULL devicemode is not + * a failure condition */ if ( !(nt_devmode=print_job_devmode( snum, jobid )) ) @@ -8134,11 +8133,6 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin } } - if ( !devmode ) { - ret = WERR_NOMEM; - goto done; - } - fill_job_info_2(info_2, &(queue[i-1]), i, snum, ntprinter, devmode); *needed += spoolss_size_job_info_2(info_2); -- cgit From 9c25d8907088ef35eef396df5a13074f445adacd Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 9 Oct 2002 18:55:35 +0000 Subject: print job properties fix from APP_HEAD. a null devmode is not a failure. (This used to be commit 8f95773e0ab0c5e0854d9e442170e25280279bfb) --- source3/rpc_server/srv_spoolss_nt.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a1eb99cb32..c5d46abe57 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6017,11 +6017,9 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, goto done; } - if (!(devmode = construct_dev_mode(snum))) { - *returned = 0; - result = WERR_NOMEM; - goto done; - } + /* this should not be a failure condition if the devmode is NULL */ + + devmode = construct_dev_mode(snum); for (i=0; i<*returned; i++) fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter, @@ -8122,7 +8120,8 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin /* * if the print job does not have a DEVMODE associated with it, - * just use the one for the printer + * just use the one for the printer. A NULL devicemode is not + * a failure condition */ if ( !(nt_devmode=print_job_devmode( snum, jobid )) ) @@ -8134,11 +8133,6 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin } } - if ( !devmode ) { - ret = WERR_NOMEM; - goto done; - } - fill_job_info_2(info_2, &(queue[i-1]), i, snum, ntprinter, devmode); *needed += spoolss_size_job_info_2(info_2); -- cgit From 4ac9ccfde4d36e3b6065c65c92dd02dddb78b4f2 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 12 Oct 2002 03:38:07 +0000 Subject: Nice *big* patch from metze. The actual design change is relitivly small however: It all goes back to jerry's 'BOOL store', added to many of the elements in a SAM_ACCOUNT. This ensured that smb.conf defaults did not get 'fixed' into ldap. This was a great win for admins, and this patch follows in the same way. This patch extends the concept - we don't store values back into LDAP unless they have been changed. So if we read a value, but don't update it, or we read a value, find it's not there and use a default, we will not update ldap with that value. This reduced clutter in our LDAP DB, and makes it easier to change defaults later on. Metze's particular problem was that when we 'write back' an unchanged value, we would clear any muliple values in that feild. Now he can still have his mulitivalued 'uid' feild, without Samba changing it for *every* other operation. This also applies to many other attributes, and helps to eliminate a nasty race condition. (Time between get and set) This patch is big, and needs more testing, but metze has tested usrmgr, and I've fixed some pdbedit bugs, and tested domain joins, so it isn't compleatly flawed ;-). The same system will be introduced into the SAM code shortly, but this fixes bugs that people were coming across in production uses of Samba 3.0/HEAD, hence it's inclusion here. Andrew Bartlett (This used to be commit 7f237bde212eb188df84a5d8adb598a93fba8155) --- source3/rpc_server/srv_netlog_nt.c | 4 +- source3/rpc_server/srv_samr_nt.c | 17 ++-- source3/rpc_server/srv_samr_util.c | 154 ++++++++++++++++++++++--------------- 3 files changed, 101 insertions(+), 74 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 4478729e4d..69d619a2b0 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -433,12 +433,12 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * cred_hash3( pwd, q_u->pwd, p->dc.sess_key, 0); /* lies! nt and lm passwords are _not_ the same: don't care */ - if (!pdb_set_lanman_passwd (sampass, pwd)) { + if (!pdb_set_lanman_passwd (sampass, pwd, PDB_CHANGED)) { pdb_free_sam(&sampass); return NT_STATUS_NO_MEMORY; } - if (!pdb_set_nt_passwd (sampass, pwd)) { + if (!pdb_set_nt_passwd (sampass, pwd, PDB_CHANGED)) { pdb_free_sam(&sampass); return NT_STATUS_NO_MEMORY; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6b7318a325..686614e9a4 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -205,8 +205,8 @@ static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) /* These now zero out the old password */ - pdb_set_lanman_passwd(sam_pass, NULL); - pdb_set_nt_passwd(sam_pass, NULL); + pdb_set_lanman_passwd(sam_pass, NULL, PDB_DEFAULT); + pdb_set_nt_passwd(sam_pass, NULL, PDB_DEFAULT); } @@ -2288,13 +2288,13 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ return nt_status; } - if (!pdb_set_username(sam_pass, account)) { + if (!pdb_set_username(sam_pass, account, PDB_CHANGED)) { pdb_free_sam(&sam_pass); return NT_STATUS_NO_MEMORY; } } - pdb_set_acct_ctrl(sam_pass, acb_info); + pdb_set_acct_ctrl(sam_pass, acb_info, PDB_CHANGED); if (!pdb_add_sam_account(sam_pass)) { pdb_free_sam(&sam_pass); @@ -2675,8 +2675,9 @@ static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, DOM_SID *sid) pdb_free_sam(&pwd); return False; } - - if (!pdb_set_acct_ctrl(pwd, id10->acb_info)) { + + /* FIX ME: check if the value is really changed --metze */ + if (!pdb_set_acct_ctrl(pwd, id10->acb_info, PDB_CHANGED)) { pdb_free_sam(&pwd); return False; } @@ -2712,11 +2713,11 @@ static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, DOM_SID *sid) return False; } - if (!pdb_set_lanman_passwd (pwd, id12->lm_pwd)) { + if (!pdb_set_lanman_passwd (pwd, id12->lm_pwd, PDB_CHANGED)) { pdb_free_sam(&pwd); return False; } - if (!pdb_set_nt_passwd (pwd, id12->nt_pwd)) { + if (!pdb_set_nt_passwd (pwd, id12->nt_pwd, PDB_CHANGED)) { pdb_free_sam(&pwd); return False; } diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 18297056d6..2a43155c10 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -47,14 +47,14 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) stored_time = pdb_get_logon_time(to); DEBUG(10,("INFO_21 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_logon_time(to, unix_time, True); + pdb_set_logon_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->logoff_time)) { unix_time=nt_time_to_unix(&from->logoff_time); stored_time = pdb_get_logoff_time(to); DEBUG(10,("INFO_21 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_logoff_time(to, unix_time, True); + pdb_set_logoff_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->kickoff_time)) { @@ -62,7 +62,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) stored_time = pdb_get_kickoff_time(to); DEBUG(10,("INFO_21 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_kickoff_time(to, unix_time , True); + pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); } if (!nt_time_is_zero(&from->pass_can_change_time)) { @@ -70,14 +70,14 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) stored_time = pdb_get_pass_can_change_time(to); DEBUG(10,("INFO_21 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_pass_can_change_time(to, unix_time, True); + pdb_set_pass_can_change_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->pass_last_set_time)) { unix_time=nt_time_to_unix(&from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); DEBUG(10,("INFO_21 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_pass_last_set_time(to, unix_time); + pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->pass_must_change_time)) { @@ -85,7 +85,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) stored_time=pdb_get_pass_must_change_time(to); DEBUG(10,("INFO_21 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_pass_must_change_time(to, unix_time, True); + pdb_set_pass_must_change_time(to, unix_time, PDB_CHANGED); } /* Backend should check this for sainity */ @@ -94,7 +94,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_user_name); DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); if (STRING_CHANGED) - pdb_set_username(to , new_string); + pdb_set_username(to , new_string, PDB_CHANGED); } if (from->hdr_full_name.buffer) { @@ -102,7 +102,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_user_name); DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_fullname(to , new_string); + pdb_set_fullname(to , new_string, PDB_CHANGED); } if (from->hdr_home_dir.buffer) { @@ -110,7 +110,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_home_dir); DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_homedir(to , new_string, True); + pdb_set_homedir(to , new_string, PDB_CHANGED); } if (from->hdr_dir_drive.buffer) { @@ -118,7 +118,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_dir_drive); DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_dir_drive(to , new_string, True); + pdb_set_dir_drive(to , new_string, PDB_CHANGED); } if (from->hdr_logon_script.buffer) { @@ -126,7 +126,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_logon_script); DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_logon_script(to , new_string, True); + pdb_set_logon_script(to , new_string, PDB_CHANGED); } if (from->hdr_profile_path.buffer) { @@ -134,7 +134,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_profile_path); DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_profile_path(to , new_string, True); + pdb_set_profile_path(to , new_string, PDB_CHANGED); } if (from->hdr_acct_desc.buffer) { @@ -142,7 +142,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_acct_desc); DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_acct_desc(to , new_string); + pdb_set_acct_desc(to , new_string, PDB_CHANGED); } if (from->hdr_workstations.buffer) { @@ -150,7 +150,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_workstations); DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_workstations(to , new_string); + pdb_set_workstations(to , new_string, PDB_CHANGED); } if (from->hdr_unknown_str.buffer) { @@ -158,7 +158,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_unknown_str); DEBUG(10,("INFO_21 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_unknown_str(to , new_string); + pdb_set_unknown_str(to , new_string, PDB_CHANGED); } if (from->hdr_munged_dial.buffer) { @@ -166,40 +166,53 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_munged_dial); DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_munged_dial(to , new_string); + pdb_set_munged_dial(to , new_string, PDB_CHANGED); } - if (from->user_rid) { + if (from->user_rid != pdb_get_user_rid(to)) { DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); /* we really allow this ??? metze */ - /* pdb_set_user_sid_from_rid(to, from->user_rid);*/ + /* pdb_set_user_sid_from_rid(to, from->user_rid, PDB_CHANGED);*/ } - if (from->group_rid) { + if (from->group_rid != pdb_get_group_rid(to)) { DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); - pdb_set_group_sid_from_rid(to, from->group_rid); + pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); } DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); - pdb_set_acct_ctrl(to, from->acb_info); + if (from->acb_info != pdb_get_acct_ctrl(to)) { + pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); + } - DEBUG(10,("INFO_21 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown3(to),from->unknown_3)); - pdb_set_unknown_3(to, from->unknown_3); - + DEBUG(10,("INFO_21 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown_3(to),from->unknown_3)); + if (from->unknown_3 != pdb_get_unknown_3(to)) { + pdb_set_unknown_3(to, from->unknown_3, PDB_CHANGED); + } DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); - pdb_set_logon_divs(to, from->logon_divs); + if (from->logon_divs != pdb_get_logon_divs(to)) { + pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); + } DEBUG(15,("INFO_21 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); - pdb_set_hours_len(to, from->logon_hrs.len); + if (from->logon_hrs.len != pdb_get_hours_len(to)) { + pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED); + } + DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); - pdb_set_hours(to, from->logon_hrs.hours); +/* Fix me: only update if it changes --metze */ + pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); - DEBUG(10,("INFO_21 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown5(to),from->unknown_5)); - pdb_set_unknown_5(to, from->unknown_5); + DEBUG(10,("INFO_21 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown_5(to),from->unknown_5)); + if (from->unknown_5 != pdb_get_unknown_5(to)) { + pdb_set_unknown_5(to, from->unknown_5, PDB_CHANGED); + } - DEBUG(10,("INFO_21 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown6(to),from->unknown_6)); - pdb_set_unknown_6(to, from->unknown_6); + DEBUG(10,("INFO_21 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); + if (from->unknown_6 != pdb_get_unknown_6(to)) { + pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); + } DEBUG(10,("INFO_21 PADDING1 %02X %02X %02X %02X %02X %02X\n", from->padding1[0], @@ -211,7 +224,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) { - pdb_set_pass_must_change_time(to,0, True); + pdb_set_pass_must_change_time(to,0, PDB_CHANGED); } DEBUG(10,("INFO_21 PADDING_2: %02X\n",from->padding2)); @@ -236,14 +249,14 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) stored_time = pdb_get_logon_time(to); DEBUG(10,("INFO_23 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_logon_time(to, unix_time, True); + pdb_set_logon_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->logoff_time)) { unix_time=nt_time_to_unix(&from->logoff_time); stored_time = pdb_get_logoff_time(to); DEBUG(10,("INFO_23 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_logoff_time(to, unix_time, True); + pdb_set_logoff_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->kickoff_time)) { @@ -251,7 +264,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) stored_time = pdb_get_kickoff_time(to); DEBUG(10,("INFO_23 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_kickoff_time(to, unix_time , True); + pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); } if (!nt_time_is_zero(&from->pass_can_change_time)) { @@ -259,14 +272,14 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) stored_time = pdb_get_pass_can_change_time(to); DEBUG(10,("INFO_23 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_pass_can_change_time(to, unix_time, True); + pdb_set_pass_can_change_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->pass_last_set_time)) { unix_time=nt_time_to_unix(&from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); DEBUG(10,("INFO_23 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_pass_last_set_time(to, unix_time); + pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->pass_must_change_time)) { @@ -274,7 +287,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) stored_time=pdb_get_pass_must_change_time(to); DEBUG(10,("INFO_23 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_pass_must_change_time(to, unix_time, True); + pdb_set_pass_must_change_time(to, unix_time, PDB_CHANGED); } /* Backend should check this for sainity */ @@ -283,7 +296,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_user_name); DEBUG(10,("INFO_23 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); if (STRING_CHANGED) - pdb_set_username(to , new_string); + pdb_set_username(to , new_string, PDB_CHANGED); } if (from->hdr_full_name.buffer) { @@ -291,7 +304,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_user_name); DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_fullname(to , new_string); + pdb_set_fullname(to , new_string, PDB_CHANGED); } if (from->hdr_home_dir.buffer) { @@ -299,7 +312,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_home_dir); DEBUG(10,("INFO_23 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_homedir(to , new_string, True); + pdb_set_homedir(to , new_string, PDB_CHANGED); } if (from->hdr_dir_drive.buffer) { @@ -307,7 +320,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_dir_drive); DEBUG(10,("INFO_23 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_dir_drive(to , new_string, True); + pdb_set_dir_drive(to , new_string, PDB_CHANGED); } if (from->hdr_logon_script.buffer) { @@ -315,7 +328,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_logon_script); DEBUG(10,("INFO_23 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_logon_script(to , new_string, True); + pdb_set_logon_script(to , new_string, PDB_CHANGED); } if (from->hdr_profile_path.buffer) { @@ -323,7 +336,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_profile_path); DEBUG(10,("INFO_23 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_profile_path(to , new_string, True); + pdb_set_profile_path(to , new_string, PDB_CHANGED); } if (from->hdr_acct_desc.buffer) { @@ -331,7 +344,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_acct_desc); DEBUG(10,("INFO_23 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_acct_desc(to , new_string); + pdb_set_acct_desc(to , new_string, PDB_CHANGED); } if (from->hdr_workstations.buffer) { @@ -339,7 +352,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_workstations); DEBUG(10,("INFO_23 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_workstations(to , new_string); + pdb_set_workstations(to , new_string, PDB_CHANGED); } if (from->hdr_unknown_str.buffer) { @@ -347,7 +360,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_unknown_str); DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_unknown_str(to , new_string); + pdb_set_unknown_str(to , new_string, PDB_CHANGED); } if (from->hdr_munged_dial.buffer) { @@ -355,40 +368,53 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_munged_dial); DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_munged_dial(to , new_string); + pdb_set_munged_dial(to , new_string, PDB_CHANGED); } - if (from->user_rid) { + if (from->user_rid != pdb_get_user_rid(to)) { DEBUG(10,("INFO_23 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); /* we really allow this ??? metze */ - /* pdb_set_user_sid_from_rid(to, from->user_rid);*/ + /* pdb_set_user_sid_from_rid(to, from->user_rid, PDB_CHANGED);*/ } - if (from->group_rid) { + if (from->group_rid != pdb_get_group_rid(to)) { DEBUG(10,("INFO_23 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); - pdb_set_group_sid_from_rid(to, from->group_rid); + pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); } DEBUG(10,("INFO_23 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); - pdb_set_acct_ctrl(to, from->acb_info); + if (from->acb_info != pdb_get_acct_ctrl(to)) { + pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); + } - DEBUG(10,("INFO_23 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown3(to),from->unknown_3)); - pdb_set_unknown_3(to, from->unknown_3); - + DEBUG(10,("INFO_23 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown_3(to),from->unknown_3)); + if (from->unknown_3 != pdb_get_unknown_3(to)) { + pdb_set_unknown_3(to, from->unknown_3, PDB_CHANGED); + } DEBUG(15,("INFO_23 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); - pdb_set_logon_divs(to, from->logon_divs); + if (from->logon_divs != pdb_get_logon_divs(to)) { + pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); + } DEBUG(15,("INFO_23 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); - pdb_set_hours_len(to, from->logon_hrs.len); + if (from->logon_hrs.len != pdb_get_hours_len(to)) { + pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED); + } + DEBUG(15,("INFO_23 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); - pdb_set_hours(to, from->logon_hrs.hours); +/* Fix me: only update if it changes --metze */ + pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); - DEBUG(10,("INFO_23 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown5(to),from->unknown_5)); - pdb_set_unknown_5(to, from->unknown_5); + DEBUG(10,("INFO_23 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown_5(to),from->unknown_5)); + if (from->unknown_5 != pdb_get_unknown_5(to)) { + pdb_set_unknown_5(to, from->unknown_5, PDB_CHANGED); + } - DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown6(to),from->unknown_6)); - pdb_set_unknown_6(to, from->unknown_6); + DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); + if (from->unknown_6 != pdb_get_unknown_6(to)) { + pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); + } DEBUG(10,("INFO_23 PADDING1 %02X %02X %02X %02X %02X %02X\n", from->padding1[0], @@ -400,7 +426,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) { - pdb_set_pass_must_change_time(to,0, True); + pdb_set_pass_must_change_time(to,0, PDB_CHANGED); } DEBUG(10,("INFO_23 PADDING_2: %02X\n",from->padding2)); -- cgit From 30acf331a982b6e2655405f8e76aaf1b30ff84fc Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 15 Oct 2002 00:28:04 +0000 Subject: merge from app_head to use GMT in job submission notification (This used to be commit b130c681d2e8e6dcabe8cfd85dd718a294b04233) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c5d46abe57..a4dcfdcec9 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -676,7 +676,7 @@ static void notify_system_time(struct spoolss_notify_msg *msg, return; } - if (!make_systemtime(&systime, localtime((time_t *)msg->notify.data))) { + if (!make_systemtime(&systime, gmtime((time_t *)msg->notify.data))) { DEBUG(5, ("notify_system_time: unable to make systemtime\n")); return; } -- cgit From 4bdfae3df718e1d4945a02f1a317029c54bae883 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 15 Oct 2002 00:35:12 +0000 Subject: merge from APP_HEAD to use GMT in job submission notification (This used to be commit 2ec53858d9ee01ed500f99a67e9a94e33576486d) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c5d46abe57..a4dcfdcec9 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -676,7 +676,7 @@ static void notify_system_time(struct spoolss_notify_msg *msg, return; } - if (!make_systemtime(&systime, localtime((time_t *)msg->notify.data))) { + if (!make_systemtime(&systime, gmtime((time_t *)msg->notify.data))) { DEBUG(5, ("notify_system_time: unable to make systemtime\n")); return; } -- cgit From a0fbdc3d64efb5ea14baa558bb360168edfef3ca Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 16 Oct 2002 18:21:55 +0000 Subject: fix from APP_HEAD to commit a re-init'd printer to disk (This used to be commit 64a159144483457887df2c6d779e6a139dfc6d1f) --- source3/rpc_server/srv_spoolss_nt.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a4dcfdcec9..3e6d5d6594 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1273,6 +1273,12 @@ void reset_all_printerdata(int msg_type, pid_t src, void *buf, size_t len) DEBUG(5,("reset_all_printerdata: Error resetting printer data for printer [%s], driver [%s]!\n", printer->info_2->printername, printer->info_2->drivername)); } + + result = mod_a_printer( *printer, 2 ); + if ( !W_ERROR_IS_OK(result) ) { + DEBUG(3,("reset_all_printerdata: mod_a_printer() failed! (%s)\n", + get_dos_error_msg(result))); + } } free_a_printer( &printer, 2 ); -- cgit From 378fd95ce872912bd2e21c87dd7369f5056203b8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 16 Oct 2002 18:23:15 +0000 Subject: merge from app_head to commit re-init'd printer to disk (This used to be commit 92fd939c3439208660ac3821c458f8cd34a59555) --- source3/rpc_server/srv_spoolss_nt.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a4dcfdcec9..3e6d5d6594 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1273,6 +1273,12 @@ void reset_all_printerdata(int msg_type, pid_t src, void *buf, size_t len) DEBUG(5,("reset_all_printerdata: Error resetting printer data for printer [%s], driver [%s]!\n", printer->info_2->printername, printer->info_2->drivername)); } + + result = mod_a_printer( *printer, 2 ); + if ( !W_ERROR_IS_OK(result) ) { + DEBUG(3,("reset_all_printerdata: mod_a_printer() failed! (%s)\n", + get_dos_error_msg(result))); + } } free_a_printer( &printer, 2 ); -- cgit From 0c35d7863293090925ee862285d844936dc38a94 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Oct 2002 07:50:48 +0000 Subject: This fixes some bugs for NT4 usrmgr.exe Volker (This used to be commit 32d6bcf3acefc77873a7241cc0c7e26241a65301) --- source3/rpc_server/srv_samr_nt.c | 28 +++++++++++++++++++++------- source3/rpc_server/srv_samr_util.c | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 686614e9a4..126db91700 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1180,6 +1180,15 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, /* Get what we need from the password database */ switch (q_u->switch_level) { case 0x1: + /* When playing with usrmgr, this is necessary + if you want immediate refresh after editing + a user. I would like to do this after the + setuserinfo2, but we do not have access to + the domain handle in that call, only to the + user handle. Where else does this hurt? + -- Volker + */ + free_samr_users(info); case 0x2: case 0x4: become_root(); @@ -3181,7 +3190,7 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ if (sid_equal(&alias_sid, &global_sid_Builtin)) { DEBUG(10, ("lookup on Builtin SID (S-1-5-32)\n")); - if(!get_local_group_from_sid(als_sid, &map, MAPPING_WITHOUT_PRIV)) + if(!get_builtin_group_from_sid(als_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; } else { if (sid_equal(&alias_sid, get_global_sam_sid())) { @@ -3513,7 +3522,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD GROUP_MAP map; uid_t uid; NTSTATUS ret; - SAM_ACCOUNT *sam_user; + SAM_ACCOUNT *sam_user=NULL; BOOL check; uint32 acc_granted; @@ -3560,19 +3569,21 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD if ((pwd=getpwuid_alloc(uid)) == NULL) { return NT_STATUS_NO_SUCH_USER; - } else { - passwd_free(&pwd); } - if ((grp=getgrgid(map.gid)) == NULL) + if ((grp=getgrgid(map.gid)) == NULL) { + passwd_free(&pwd); return NT_STATUS_NO_SUCH_GROUP; + } /* we need to copy the name otherwise it's overloaded in user_in_group_list */ fstrcpy(grp_name, grp->gr_name); /* if the user is already in the group */ - if(user_in_group_list(pwd->pw_name, grp_name)) + if(user_in_group_list(pwd->pw_name, grp_name)) { + passwd_free(&pwd); return NT_STATUS_MEMBER_IN_GROUP; + } /* * ok, the group exist, the user exist, the user is not in the group, @@ -3583,9 +3594,12 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD smb_add_user_group(grp_name, pwd->pw_name); /* check if the user has been added then ... */ - if(!user_in_group_list(pwd->pw_name, grp_name)) + if(!user_in_group_list(pwd->pw_name, grp_name)) { + passwd_free(&pwd); return NT_STATUS_MEMBER_NOT_IN_GROUP; /* don't know what to reply else */ + } + passwd_free(&pwd); return NT_STATUS_OK; } diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 2a43155c10..84f28eda08 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -99,7 +99,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_full_name.buffer) { old_string = pdb_get_fullname(to); - new_string = pdb_unistr2_convert(&from->uni_user_name); + new_string = pdb_unistr2_convert(&from->uni_full_name); DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_fullname(to , new_string, PDB_CHANGED); -- cgit From 605ab784015fd5688ec43a5cce1ea5962b27139b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Oct 2002 08:09:28 +0000 Subject: Fix full_name for info23 as well. Thanks, Andrew. Volker (This used to be commit 382c444225fae54ae577baae8948a64a843a2afc) --- source3/rpc_server/srv_samr_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 84f28eda08..97c7b67839 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -301,7 +301,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_full_name.buffer) { old_string = pdb_get_fullname(to); - new_string = pdb_unistr2_convert(&from->uni_user_name); + new_string = pdb_unistr2_convert(&from->uni_full_name); DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_fullname(to , new_string, PDB_CHANGED); -- cgit From 5dbf435408cce525431dbe43bc379797293f5c99 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 Oct 2002 19:28:56 +0000 Subject: This moves the group mapping API into the passdb backend. Currently this calls back to mapping.c, but we have the framework to get the information into LDAP and the passdb.tdb (should we? I think so..). This has received moderate testing with net rpc vampire and usrmgr. I found the add_groupmem segfault in add_aliasmem as well, but that will be another checkin. Volker (This used to be commit f30095852fea19421ac8e25dfe9c5cd4b2206f84) --- source3/rpc_server/srv_lsa_nt.c | 18 +++++++++--------- source3/rpc_server/srv_samr_nt.c | 18 +++++++++--------- source3/rpc_server/srv_util.c | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index e187e1556e..c4fc0a5de7 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -856,7 +856,7 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU return NT_STATUS_ACCESS_DENIED; /* get the list of mapped groups (domain, local, builtin) */ - if(!enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) + if(!pdb_enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) return NT_STATUS_OK; if (q_u->enum_context >= num_entries) @@ -971,7 +971,7 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LS if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITH_PRIV)) + if (!pdb_getgrsid(&map, info->sid, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; DEBUG(10,("_lsa_enum_privsaccount: %d privileges\n", map.priv_set.count)); @@ -1012,7 +1012,7 @@ NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITHOUT_PRIV)) + if (!pdb_getgrsid(&map, info->sid, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_GROUP; /* @@ -1043,12 +1043,12 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITH_PRIV)) + if (!pdb_getgrsid(&map, info->sid, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; map.systemaccount=q_u->access; - if(!add_mapping_entry(&map, TDB_REPLACE)) + if(!pdb_update_group_mapping_entry(&map)) return NT_STATUS_NO_SUCH_GROUP; free_privilege(&map.priv_set); @@ -1075,7 +1075,7 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITH_PRIV)) + if (!pdb_getgrsid(&map, info->sid, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; set=&q_u->set; @@ -1092,7 +1092,7 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u add_privilege(&map.priv_set, *luid_attr); } - if(!add_mapping_entry(&map, TDB_REPLACE)) + if(!pdb_update_group_mapping_entry(&map)) return NT_STATUS_NO_SUCH_GROUP; free_privilege(&map.priv_set); @@ -1119,7 +1119,7 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITH_PRIV)) + if (!pdb_getgrsid(&map, info->sid, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; if (q_u->allrights!=0) { @@ -1149,7 +1149,7 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP remove_privilege(&map.priv_set, *luid_attr); } - if(!add_mapping_entry(&map, TDB_REPLACE)) + if(!pdb_update_group_mapping_entry(&map)) return NT_STATUS_NO_SUCH_GROUP; free_privilege(&map.priv_set); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 126db91700..1db3f60c87 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -302,7 +302,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) return NT_STATUS_OK; } - if (!enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) { + if (!pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) { return NT_STATUS_NO_MEMORY; } @@ -894,7 +894,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM /* well-known aliases */ if (sid_equal(sid, &global_sid_Builtin) && !lp_hide_local_users()) { - enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); + pdb_enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); if (num_entries != 0) { *d_grp=(DOMAIN_GRP *)talloc_zero(ctx, num_entries*sizeof(DOMAIN_GRP)); @@ -931,7 +931,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM for (; (num_entries < max_entries) && (grp != NULL); grp = grp->next) { uint32 trid; - if(!get_group_map_from_gid(grp->gr_gid, &smap, MAPPING_WITHOUT_PRIV)) + if(!pdb_getgrgid(&smap, grp->gr_gid, MAPPING_WITHOUT_PRIV)) continue; if (smap.sid_name_use!=SID_NAME_ALIAS) { @@ -1012,7 +1012,7 @@ static NTSTATUS get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DO *p_num_entries = 0; - enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); + pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); num_entries=group_entries-start_idx; @@ -1337,7 +1337,7 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM !sid_check_is_in_builtin(&sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - if (!get_group_map_from_sid(sid, &map, MAPPING_WITHOUT_PRIV)) + if (!pdb_getgrsid(&map, sid, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; switch (q_u->switch_level) { @@ -3798,7 +3798,7 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S if ( (grp=getgrgid(gid)) != NULL) return NT_STATUS_ACCESS_DENIED; - if(!group_map_remove(group_sid)) + if(!pdb_delete_group_mapping_entry(group_sid)) return NT_STATUS_ACCESS_DENIED; if (!close_policy_hnd(p, &q_u->group_pol)) @@ -3861,7 +3861,7 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S return NT_STATUS_ACCESS_DENIED; /* don't check if we removed it as it could be an un-mapped group */ - group_map_remove(alias_sid); + pdb_delete_group_mapping_entry(alias_sid); if (!close_policy_hnd(p, &q_u->alias_pol)) return NT_STATUS_OBJECT_NAME_INVALID; @@ -4091,7 +4091,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ return NT_STATUS_INVALID_INFO_CLASS; } - if(!add_mapping_entry(&map, TDB_REPLACE)) { + if(!pdb_update_group_mapping_entry(&map)) { free_privilege(&map.priv_set); return NT_STATUS_NO_SUCH_GROUP; } @@ -4135,7 +4135,7 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ return NT_STATUS_INVALID_INFO_CLASS; } - if(!add_mapping_entry(&map, TDB_REPLACE)) { + if(!pdb_update_group_mapping_entry(&map)) { free_privilege(&map.priv_set); return NT_STATUS_NO_SUCH_GROUP; } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 50bf5db4fd..519daff1f6 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -276,7 +276,7 @@ BOOL get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids, SA DEBUG(10,("get_domain_user_groups: searching domain groups [%s] is a member of\n", user_name)); /* first get the list of the domain groups */ - if (!enum_group_mapping(SID_NAME_DOM_GRP, &map, &num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) + if (!pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, &num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) return False; DEBUG(10,("get_domain_user_groups: there are %d mapped groups\n", num_entries)); -- cgit From c7731c988ed289952310f4bec19f6afdb6c1d1fc Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 Oct 2002 20:33:00 +0000 Subject: Same segfault as in add_groupmem. Volker (This used to be commit 1f702dcd2ced6f64a619e3ddbb570f41f7f0986b) --- source3/rpc_server/srv_samr_nt.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1db3f60c87..1bdfefff65 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3414,19 +3414,21 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD if ((pwd=getpwuid_alloc(uid)) == NULL) { return NT_STATUS_NO_SUCH_USER; - } else { - passwd_free(&pwd); } - if ((grp=getgrgid(map.gid)) == NULL) + if ((grp=getgrgid(map.gid)) == NULL) { + passwd_free(&pwd); return NT_STATUS_NO_SUCH_ALIAS; + } /* we need to copy the name otherwise it's overloaded in user_in_group_list */ fstrcpy(grp_name, grp->gr_name); /* if the user is already in the group */ - if(user_in_group_list(pwd->pw_name, grp_name)) + if(user_in_group_list(pwd->pw_name, grp_name)) { + passwd_free(&pwd); return NT_STATUS_MEMBER_IN_ALIAS; + } /* * ok, the group exist, the user exist, the user is not in the group, @@ -3435,9 +3437,12 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD smb_add_user_group(grp_name, pwd->pw_name); /* check if the user has been added then ... */ - if(!user_in_group_list(pwd->pw_name, grp_name)) + if(!user_in_group_list(pwd->pw_name, grp_name)) { + passwd_free(&pwd); return NT_STATUS_MEMBER_NOT_IN_ALIAS; /* don't know what to reply else */ + } + passwd_free(&pwd); return NT_STATUS_OK; } -- cgit From 9b323a3c0deb73cea3c39e5b7323bdf17e199c5c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 22 Oct 2002 22:17:06 +0000 Subject: Fix for systems that allow more than 65536 open files per process. Jeremy. (This used to be commit ff537f10a0c0b6b1d9055eb776d1e8a9864e8363) --- source3/rpc_server/srv_pipe_hnd.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index cc6e4b95f9..1695419687 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -31,10 +31,6 @@ static smb_np_struct *chain_p; static int pipes_open; -#ifndef MAX_OPEN_PIPES -#define MAX_OPEN_PIPES 2048 -#endif - /* * Sometimes I can't decide if I hate Windows printer driver * writers more than I hate the Windows spooler service driver -- cgit From 83219da3028a0341a9c7b2db38738ca30288686b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 22 Oct 2002 22:17:29 +0000 Subject: Fix for systems that allow more than 65536 open files per process. Jeremy. (This used to be commit 947a56ce00e552e8b8d2ed64435eabde6225f044) --- source3/rpc_server/srv_pipe_hnd.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index cc6e4b95f9..1695419687 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -31,10 +31,6 @@ static smb_np_struct *chain_p; static int pipes_open; -#ifndef MAX_OPEN_PIPES -#define MAX_OPEN_PIPES 2048 -#endif - /* * Sometimes I can't decide if I hate Windows printer driver * writers more than I hate the Windows spooler service driver -- cgit From f735551b9edef66b152261cf6eb2f29b7b69d65b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 23 Oct 2002 01:22:32 +0000 Subject: First cut of new ACL mapping code from Andreas Gruenbacher . This is not 100% the same as what SuSE shipped in their Samba, there is a crash bug fix, a race condition fix, and a few logic changes I'd like to discuss with Andreas. Added Andreas to (C) notices for posix_acls.c Jeremy. (This used to be commit 40eafb9dde113af9f7f1808fda22908953f7e8c3) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 020a3c6aaf..f02be9acd3 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -884,7 +884,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM uint32 num_entries = 0; int i; GROUP_MAP smap; - GROUP_MAP *map; + GROUP_MAP *map = NULL; sid_to_string(sid_str, sid); DEBUG(5, ("get_group_alias_entries: enumerating aliases on SID: %s\n", sid_str)); -- cgit From 7689a9c96932a41ccde73b3df0ce358e62a38a15 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 23 Oct 2002 01:22:45 +0000 Subject: First cut of new ACL mapping code from Andreas Gruenbacher . This is not 100% the same as what SuSE shipped in their Samba, there is a crash bug fix, a race condition fix, and a few logic changes I'd like to discuss with Andreas. Added Andreas to (C) notices for posix_acls.c Jeremy. (This used to be commit a81d700ae9c82d4b7ea631ab7862162a2ed3d512) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1bdfefff65..6ef2fcd67d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -884,7 +884,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM uint32 num_entries = 0; int i; GROUP_MAP smap; - GROUP_MAP *map; + GROUP_MAP *map = NULL; sid_to_string(sid_str, sid); DEBUG(5, ("get_group_alias_entries: enumerating aliases on SID: %s\n", sid_str)); -- cgit From 1a96aeebc804603d29a406947c8e69933528bb97 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 23 Oct 2002 01:55:27 +0000 Subject: Debug level 12 is a typo. Jeremy. (This used to be commit c4e4cc9ce169038c4bb8cdcc477d15a9661d1b8e) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f02be9acd3..b3df2b830e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -281,7 +281,7 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOO info->all_machines = all_machines; info->disp_info.user_dbloaded=True; - DEBUG(12,("load_sampwd_entries: done\n")); + DEBUG(10,("load_sampwd_entries: done\n")); return nt_status; } @@ -333,7 +333,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) info->disp_info.group_dbloaded=True; - DEBUG(12,("load_group_domain_entries: done\n")); + DEBUG(10,("load_group_domain_entries: done\n")); return NT_STATUS_OK; } -- cgit From b064077145e61ed4bdf2ccb9b91c94b8c2acb27a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 23 Oct 2002 01:55:40 +0000 Subject: Debug level 12 is a typo. Jeremy. (This used to be commit 4d9b205362997f897be4739efd52ee2cfde4c6cb) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6ef2fcd67d..0718af016f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -281,7 +281,7 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOO info->all_machines = all_machines; info->disp_info.user_dbloaded=True; - DEBUG(12,("load_sampwd_entries: done\n")); + DEBUG(10,("load_sampwd_entries: done\n")); return nt_status; } @@ -333,7 +333,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) info->disp_info.group_dbloaded=True; - DEBUG(12,("load_group_domain_entries: done\n")); + DEBUG(10,("load_group_domain_entries: done\n")); return NT_STATUS_OK; } -- cgit From 158ae87aa9e530c3dc784ebfb3715c2ae254fd31 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 23 Oct 2002 22:23:39 +0000 Subject: Reverted a fix from Volker (sorry). We need to move this fix to the correct place. Jeremy. (This used to be commit e46e38beabe8ae5b1ba1941dcffecbc89165ce2a) --- source3/rpc_server/srv_samr_nt.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 0718af016f..b039d92d9c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1188,7 +1188,10 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, user handle. Where else does this hurt? -- Volker */ +#if 0 + /* We cannot do this here - it kills performace. JRA. */ free_samr_users(info); +#endif case 0x2: case 0x4: become_root(); -- cgit From 35357e85891f24636bb563ae23569ac83517cbae Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 25 Oct 2002 22:16:00 +0000 Subject: merge PURGE_PRINTER fix from APP_HEAD (This used to be commit 4d32e6bdb6500f442ff3cda7d43bdf506a08eacf) --- source3/rpc_server/srv_spoolss_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3e6d5d6594..a5e464f73b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5441,13 +5441,11 @@ static WERROR control_printer(POLICY_HND *handle, uint32 command, errcode = WERR_OK; } break; -#if 0 /* JERRY - Never called */ case PRINTER_CONTROL_PURGE: if (print_queue_purge(&user, snum, &errcode)) { errcode = WERR_OK; } break; -#endif default: return WERR_UNKNOWN_LEVEL; } -- cgit From 71f34ddabd80f3d65d6332e734ce6e20fef31de5 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 25 Oct 2002 22:17:29 +0000 Subject: PURGE_PRINTER fix from APP_HEAD (This used to be commit 8af12875b0608b83187e4156843e37097de4cd13) --- source3/rpc_server/srv_spoolss_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3e6d5d6594..a5e464f73b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5441,13 +5441,11 @@ static WERROR control_printer(POLICY_HND *handle, uint32 command, errcode = WERR_OK; } break; -#if 0 /* JERRY - Never called */ case PRINTER_CONTROL_PURGE: if (print_queue_purge(&user, snum, &errcode)) { errcode = WERR_OK; } break; -#endif default: return WERR_UNKNOWN_LEVEL; } -- cgit From 6d7195d1d79c43f5ccc8dc4a9215c02177d5fa89 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 2 Nov 2002 03:47:48 +0000 Subject: Merge passdb from HEAD -> 3.0 The work here includes: - metze' set/changed patch, which avoids making changes to ldap on unmodified attributes. - volker's group mapping in passdb patch - volker's samsync stuff - volkers SAMR changes. - mezte's connection caching patch - my recent changes (fix magic root check, ldap ssl) Andrew Bartlett (This used to be commit 2044d60bbe0043cdbb9aba931115672bde975d2f) --- source3/rpc_server/srv_lsa_nt.c | 18 ++--- source3/rpc_server/srv_netlog_nt.c | 4 +- source3/rpc_server/srv_samr_nt.c | 69 +++++++++------- source3/rpc_server/srv_samr_util.c | 158 +++++++++++++++++++++---------------- source3/rpc_server/srv_util.c | 2 +- 5 files changed, 144 insertions(+), 107 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index e187e1556e..c4fc0a5de7 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -856,7 +856,7 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU return NT_STATUS_ACCESS_DENIED; /* get the list of mapped groups (domain, local, builtin) */ - if(!enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) + if(!pdb_enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) return NT_STATUS_OK; if (q_u->enum_context >= num_entries) @@ -971,7 +971,7 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LS if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITH_PRIV)) + if (!pdb_getgrsid(&map, info->sid, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; DEBUG(10,("_lsa_enum_privsaccount: %d privileges\n", map.priv_set.count)); @@ -1012,7 +1012,7 @@ NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITHOUT_PRIV)) + if (!pdb_getgrsid(&map, info->sid, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_GROUP; /* @@ -1043,12 +1043,12 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITH_PRIV)) + if (!pdb_getgrsid(&map, info->sid, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; map.systemaccount=q_u->access; - if(!add_mapping_entry(&map, TDB_REPLACE)) + if(!pdb_update_group_mapping_entry(&map)) return NT_STATUS_NO_SUCH_GROUP; free_privilege(&map.priv_set); @@ -1075,7 +1075,7 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITH_PRIV)) + if (!pdb_getgrsid(&map, info->sid, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; set=&q_u->set; @@ -1092,7 +1092,7 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u add_privilege(&map.priv_set, *luid_attr); } - if(!add_mapping_entry(&map, TDB_REPLACE)) + if(!pdb_update_group_mapping_entry(&map)) return NT_STATUS_NO_SUCH_GROUP; free_privilege(&map.priv_set); @@ -1119,7 +1119,7 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!get_group_map_from_sid(info->sid, &map, MAPPING_WITH_PRIV)) + if (!pdb_getgrsid(&map, info->sid, MAPPING_WITH_PRIV)) return NT_STATUS_NO_SUCH_GROUP; if (q_u->allrights!=0) { @@ -1149,7 +1149,7 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP remove_privilege(&map.priv_set, *luid_attr); } - if(!add_mapping_entry(&map, TDB_REPLACE)) + if(!pdb_update_group_mapping_entry(&map)) return NT_STATUS_NO_SUCH_GROUP; free_privilege(&map.priv_set); diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 4478729e4d..69d619a2b0 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -433,12 +433,12 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * cred_hash3( pwd, q_u->pwd, p->dc.sess_key, 0); /* lies! nt and lm passwords are _not_ the same: don't care */ - if (!pdb_set_lanman_passwd (sampass, pwd)) { + if (!pdb_set_lanman_passwd (sampass, pwd, PDB_CHANGED)) { pdb_free_sam(&sampass); return NT_STATUS_NO_MEMORY; } - if (!pdb_set_nt_passwd (sampass, pwd)) { + if (!pdb_set_nt_passwd (sampass, pwd, PDB_CHANGED)) { pdb_free_sam(&sampass); return NT_STATUS_NO_MEMORY; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b3df2b830e..543f9ee379 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -205,8 +205,8 @@ static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) /* These now zero out the old password */ - pdb_set_lanman_passwd(sam_pass, NULL); - pdb_set_nt_passwd(sam_pass, NULL); + pdb_set_lanman_passwd(sam_pass, NULL, PDB_DEFAULT); + pdb_set_nt_passwd(sam_pass, NULL, PDB_DEFAULT); } @@ -302,7 +302,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) return NT_STATUS_OK; } - if (!enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) { + if (!pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) { return NT_STATUS_NO_MEMORY; } @@ -894,7 +894,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM /* well-known aliases */ if (sid_equal(sid, &global_sid_Builtin) && !lp_hide_local_users()) { - enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); + pdb_enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); if (num_entries != 0) { *d_grp=(DOMAIN_GRP *)talloc_zero(ctx, num_entries*sizeof(DOMAIN_GRP)); @@ -931,7 +931,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM for (; (num_entries < max_entries) && (grp != NULL); grp = grp->next) { uint32 trid; - if(!get_group_from_gid(grp->gr_gid, &smap, MAPPING_WITHOUT_PRIV)) + if(!pdb_getgrgid(&smap, grp->gr_gid, MAPPING_WITHOUT_PRIV)) continue; if (smap.sid_name_use!=SID_NAME_ALIAS) { @@ -1012,7 +1012,7 @@ static NTSTATUS get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DO *p_num_entries = 0; - enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); + pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); num_entries=group_entries-start_idx; @@ -1328,7 +1328,7 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM !sid_check_is_in_builtin(&sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - if (!get_group_map_from_sid(sid, &map, MAPPING_WITHOUT_PRIV)) + if (!pdb_getgrsid(&map, sid, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; switch (q_u->switch_level) { @@ -2288,13 +2288,13 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ return nt_status; } - if (!pdb_set_username(sam_pass, account)) { + if (!pdb_set_username(sam_pass, account, PDB_CHANGED)) { pdb_free_sam(&sam_pass); return NT_STATUS_NO_MEMORY; } } - pdb_set_acct_ctrl(sam_pass, acb_info); + pdb_set_acct_ctrl(sam_pass, acb_info, PDB_CHANGED); if (!pdb_add_sam_account(sam_pass)) { pdb_free_sam(&sam_pass); @@ -2675,8 +2675,9 @@ static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, DOM_SID *sid) pdb_free_sam(&pwd); return False; } - - if (!pdb_set_acct_ctrl(pwd, id10->acb_info)) { + + /* FIX ME: check if the value is really changed --metze */ + if (!pdb_set_acct_ctrl(pwd, id10->acb_info, PDB_CHANGED)) { pdb_free_sam(&pwd); return False; } @@ -2712,11 +2713,11 @@ static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, DOM_SID *sid) return False; } - if (!pdb_set_lanman_passwd (pwd, id12->lm_pwd)) { + if (!pdb_set_lanman_passwd (pwd, id12->lm_pwd, PDB_CHANGED)) { pdb_free_sam(&pwd); return False; } - if (!pdb_set_nt_passwd (pwd, id12->nt_pwd)) { + if (!pdb_set_nt_passwd (pwd, id12->nt_pwd, PDB_CHANGED)) { pdb_free_sam(&pwd); return False; } @@ -3180,7 +3181,7 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ if (sid_equal(&alias_sid, &global_sid_Builtin)) { DEBUG(10, ("lookup on Builtin SID (S-1-5-32)\n")); - if(!get_local_group_from_sid(als_sid, &map, MAPPING_WITHOUT_PRIV)) + if(!get_builtin_group_from_sid(als_sid, &map, MAPPING_WITHOUT_PRIV)) return NT_STATUS_NO_SUCH_ALIAS; } else { if (sid_equal(&alias_sid, get_global_sam_sid())) { @@ -3404,19 +3405,21 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD if ((pwd=getpwuid_alloc(uid)) == NULL) { return NT_STATUS_NO_SUCH_USER; - } else { - passwd_free(&pwd); } - if ((grp=getgrgid(map.gid)) == NULL) + if ((grp=getgrgid(map.gid)) == NULL) { + passwd_free(&pwd); return NT_STATUS_NO_SUCH_ALIAS; + } /* we need to copy the name otherwise it's overloaded in user_in_group_list */ fstrcpy(grp_name, grp->gr_name); /* if the user is already in the group */ - if(user_in_group_list(pwd->pw_name, grp_name)) + if(user_in_group_list(pwd->pw_name, grp_name)) { + passwd_free(&pwd); return NT_STATUS_MEMBER_IN_ALIAS; + } /* * ok, the group exist, the user exist, the user is not in the group, @@ -3425,9 +3428,12 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD smb_add_user_group(grp_name, pwd->pw_name); /* check if the user has been added then ... */ - if(!user_in_group_list(pwd->pw_name, grp_name)) + if(!user_in_group_list(pwd->pw_name, grp_name)) { + passwd_free(&pwd); return NT_STATUS_MEMBER_NOT_IN_ALIAS; /* don't know what to reply else */ + } + passwd_free(&pwd); return NT_STATUS_OK; } @@ -3512,7 +3518,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD GROUP_MAP map; uid_t uid; NTSTATUS ret; - SAM_ACCOUNT *sam_user; + SAM_ACCOUNT *sam_user=NULL; BOOL check; uint32 acc_granted; @@ -3559,19 +3565,21 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD if ((pwd=getpwuid_alloc(uid)) == NULL) { return NT_STATUS_NO_SUCH_USER; - } else { - passwd_free(&pwd); } - if ((grp=getgrgid(map.gid)) == NULL) + if ((grp=getgrgid(map.gid)) == NULL) { + passwd_free(&pwd); return NT_STATUS_NO_SUCH_GROUP; + } /* we need to copy the name otherwise it's overloaded in user_in_group_list */ fstrcpy(grp_name, grp->gr_name); /* if the user is already in the group */ - if(user_in_group_list(pwd->pw_name, grp_name)) + if(user_in_group_list(pwd->pw_name, grp_name)) { + passwd_free(&pwd); return NT_STATUS_MEMBER_IN_GROUP; + } /* * ok, the group exist, the user exist, the user is not in the group, @@ -3582,9 +3590,12 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD smb_add_user_group(grp_name, pwd->pw_name); /* check if the user has been added then ... */ - if(!user_in_group_list(pwd->pw_name, grp_name)) + if(!user_in_group_list(pwd->pw_name, grp_name)) { + passwd_free(&pwd); return NT_STATUS_MEMBER_NOT_IN_GROUP; /* don't know what to reply else */ + } + passwd_free(&pwd); return NT_STATUS_OK; } @@ -3783,7 +3794,7 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S if ( (grp=getgrgid(gid)) != NULL) return NT_STATUS_ACCESS_DENIED; - if(!group_map_remove(group_sid)) + if(!pdb_delete_group_mapping_entry(group_sid)) return NT_STATUS_ACCESS_DENIED; if (!close_policy_hnd(p, &q_u->group_pol)) @@ -3846,7 +3857,7 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S return NT_STATUS_ACCESS_DENIED; /* don't check if we removed it as it could be an un-mapped group */ - group_map_remove(alias_sid); + pdb_delete_group_mapping_entry(alias_sid); if (!close_policy_hnd(p, &q_u->alias_pol)) return NT_STATUS_OBJECT_NAME_INVALID; @@ -4076,7 +4087,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ return NT_STATUS_INVALID_INFO_CLASS; } - if(!add_mapping_entry(&map, TDB_REPLACE)) { + if(!pdb_update_group_mapping_entry(&map)) { free_privilege(&map.priv_set); return NT_STATUS_NO_SUCH_GROUP; } @@ -4120,7 +4131,7 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ return NT_STATUS_INVALID_INFO_CLASS; } - if(!add_mapping_entry(&map, TDB_REPLACE)) { + if(!pdb_update_group_mapping_entry(&map)) { free_privilege(&map.priv_set); return NT_STATUS_NO_SUCH_GROUP; } diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 18297056d6..97c7b67839 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -47,14 +47,14 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) stored_time = pdb_get_logon_time(to); DEBUG(10,("INFO_21 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_logon_time(to, unix_time, True); + pdb_set_logon_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->logoff_time)) { unix_time=nt_time_to_unix(&from->logoff_time); stored_time = pdb_get_logoff_time(to); DEBUG(10,("INFO_21 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_logoff_time(to, unix_time, True); + pdb_set_logoff_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->kickoff_time)) { @@ -62,7 +62,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) stored_time = pdb_get_kickoff_time(to); DEBUG(10,("INFO_21 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_kickoff_time(to, unix_time , True); + pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); } if (!nt_time_is_zero(&from->pass_can_change_time)) { @@ -70,14 +70,14 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) stored_time = pdb_get_pass_can_change_time(to); DEBUG(10,("INFO_21 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_pass_can_change_time(to, unix_time, True); + pdb_set_pass_can_change_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->pass_last_set_time)) { unix_time=nt_time_to_unix(&from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); DEBUG(10,("INFO_21 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_pass_last_set_time(to, unix_time); + pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->pass_must_change_time)) { @@ -85,7 +85,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) stored_time=pdb_get_pass_must_change_time(to); DEBUG(10,("INFO_21 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_pass_must_change_time(to, unix_time, True); + pdb_set_pass_must_change_time(to, unix_time, PDB_CHANGED); } /* Backend should check this for sainity */ @@ -94,15 +94,15 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_user_name); DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); if (STRING_CHANGED) - pdb_set_username(to , new_string); + pdb_set_username(to , new_string, PDB_CHANGED); } if (from->hdr_full_name.buffer) { old_string = pdb_get_fullname(to); - new_string = pdb_unistr2_convert(&from->uni_user_name); + new_string = pdb_unistr2_convert(&from->uni_full_name); DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_fullname(to , new_string); + pdb_set_fullname(to , new_string, PDB_CHANGED); } if (from->hdr_home_dir.buffer) { @@ -110,7 +110,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_home_dir); DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_homedir(to , new_string, True); + pdb_set_homedir(to , new_string, PDB_CHANGED); } if (from->hdr_dir_drive.buffer) { @@ -118,7 +118,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_dir_drive); DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_dir_drive(to , new_string, True); + pdb_set_dir_drive(to , new_string, PDB_CHANGED); } if (from->hdr_logon_script.buffer) { @@ -126,7 +126,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_logon_script); DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_logon_script(to , new_string, True); + pdb_set_logon_script(to , new_string, PDB_CHANGED); } if (from->hdr_profile_path.buffer) { @@ -134,7 +134,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_profile_path); DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_profile_path(to , new_string, True); + pdb_set_profile_path(to , new_string, PDB_CHANGED); } if (from->hdr_acct_desc.buffer) { @@ -142,7 +142,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_acct_desc); DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_acct_desc(to , new_string); + pdb_set_acct_desc(to , new_string, PDB_CHANGED); } if (from->hdr_workstations.buffer) { @@ -150,7 +150,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_workstations); DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_workstations(to , new_string); + pdb_set_workstations(to , new_string, PDB_CHANGED); } if (from->hdr_unknown_str.buffer) { @@ -158,7 +158,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_unknown_str); DEBUG(10,("INFO_21 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_unknown_str(to , new_string); + pdb_set_unknown_str(to , new_string, PDB_CHANGED); } if (from->hdr_munged_dial.buffer) { @@ -166,40 +166,53 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) new_string = pdb_unistr2_convert(&from->uni_munged_dial); DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_munged_dial(to , new_string); + pdb_set_munged_dial(to , new_string, PDB_CHANGED); } - if (from->user_rid) { + if (from->user_rid != pdb_get_user_rid(to)) { DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); /* we really allow this ??? metze */ - /* pdb_set_user_sid_from_rid(to, from->user_rid);*/ + /* pdb_set_user_sid_from_rid(to, from->user_rid, PDB_CHANGED);*/ } - if (from->group_rid) { + if (from->group_rid != pdb_get_group_rid(to)) { DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); - pdb_set_group_sid_from_rid(to, from->group_rid); + pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); } DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); - pdb_set_acct_ctrl(to, from->acb_info); + if (from->acb_info != pdb_get_acct_ctrl(to)) { + pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); + } - DEBUG(10,("INFO_21 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown3(to),from->unknown_3)); - pdb_set_unknown_3(to, from->unknown_3); - + DEBUG(10,("INFO_21 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown_3(to),from->unknown_3)); + if (from->unknown_3 != pdb_get_unknown_3(to)) { + pdb_set_unknown_3(to, from->unknown_3, PDB_CHANGED); + } DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); - pdb_set_logon_divs(to, from->logon_divs); + if (from->logon_divs != pdb_get_logon_divs(to)) { + pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); + } DEBUG(15,("INFO_21 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); - pdb_set_hours_len(to, from->logon_hrs.len); + if (from->logon_hrs.len != pdb_get_hours_len(to)) { + pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED); + } + DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); - pdb_set_hours(to, from->logon_hrs.hours); +/* Fix me: only update if it changes --metze */ + pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); - DEBUG(10,("INFO_21 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown5(to),from->unknown_5)); - pdb_set_unknown_5(to, from->unknown_5); + DEBUG(10,("INFO_21 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown_5(to),from->unknown_5)); + if (from->unknown_5 != pdb_get_unknown_5(to)) { + pdb_set_unknown_5(to, from->unknown_5, PDB_CHANGED); + } - DEBUG(10,("INFO_21 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown6(to),from->unknown_6)); - pdb_set_unknown_6(to, from->unknown_6); + DEBUG(10,("INFO_21 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); + if (from->unknown_6 != pdb_get_unknown_6(to)) { + pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); + } DEBUG(10,("INFO_21 PADDING1 %02X %02X %02X %02X %02X %02X\n", from->padding1[0], @@ -211,7 +224,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) { - pdb_set_pass_must_change_time(to,0, True); + pdb_set_pass_must_change_time(to,0, PDB_CHANGED); } DEBUG(10,("INFO_21 PADDING_2: %02X\n",from->padding2)); @@ -236,14 +249,14 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) stored_time = pdb_get_logon_time(to); DEBUG(10,("INFO_23 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_logon_time(to, unix_time, True); + pdb_set_logon_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->logoff_time)) { unix_time=nt_time_to_unix(&from->logoff_time); stored_time = pdb_get_logoff_time(to); DEBUG(10,("INFO_23 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_logoff_time(to, unix_time, True); + pdb_set_logoff_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->kickoff_time)) { @@ -251,7 +264,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) stored_time = pdb_get_kickoff_time(to); DEBUG(10,("INFO_23 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_kickoff_time(to, unix_time , True); + pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); } if (!nt_time_is_zero(&from->pass_can_change_time)) { @@ -259,14 +272,14 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) stored_time = pdb_get_pass_can_change_time(to); DEBUG(10,("INFO_23 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_pass_can_change_time(to, unix_time, True); + pdb_set_pass_can_change_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->pass_last_set_time)) { unix_time=nt_time_to_unix(&from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); DEBUG(10,("INFO_23 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_pass_last_set_time(to, unix_time); + pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); } if (!nt_time_is_zero(&from->pass_must_change_time)) { @@ -274,7 +287,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) stored_time=pdb_get_pass_must_change_time(to); DEBUG(10,("INFO_23 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) - pdb_set_pass_must_change_time(to, unix_time, True); + pdb_set_pass_must_change_time(to, unix_time, PDB_CHANGED); } /* Backend should check this for sainity */ @@ -283,15 +296,15 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_user_name); DEBUG(10,("INFO_23 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); if (STRING_CHANGED) - pdb_set_username(to , new_string); + pdb_set_username(to , new_string, PDB_CHANGED); } if (from->hdr_full_name.buffer) { old_string = pdb_get_fullname(to); - new_string = pdb_unistr2_convert(&from->uni_user_name); + new_string = pdb_unistr2_convert(&from->uni_full_name); DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_fullname(to , new_string); + pdb_set_fullname(to , new_string, PDB_CHANGED); } if (from->hdr_home_dir.buffer) { @@ -299,7 +312,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_home_dir); DEBUG(10,("INFO_23 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_homedir(to , new_string, True); + pdb_set_homedir(to , new_string, PDB_CHANGED); } if (from->hdr_dir_drive.buffer) { @@ -307,7 +320,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_dir_drive); DEBUG(10,("INFO_23 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_dir_drive(to , new_string, True); + pdb_set_dir_drive(to , new_string, PDB_CHANGED); } if (from->hdr_logon_script.buffer) { @@ -315,7 +328,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_logon_script); DEBUG(10,("INFO_23 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_logon_script(to , new_string, True); + pdb_set_logon_script(to , new_string, PDB_CHANGED); } if (from->hdr_profile_path.buffer) { @@ -323,7 +336,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_profile_path); DEBUG(10,("INFO_23 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_profile_path(to , new_string, True); + pdb_set_profile_path(to , new_string, PDB_CHANGED); } if (from->hdr_acct_desc.buffer) { @@ -331,7 +344,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_acct_desc); DEBUG(10,("INFO_23 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) - pdb_set_acct_desc(to , new_string); + pdb_set_acct_desc(to , new_string, PDB_CHANGED); } if (from->hdr_workstations.buffer) { @@ -339,7 +352,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_workstations); DEBUG(10,("INFO_23 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_workstations(to , new_string); + pdb_set_workstations(to , new_string, PDB_CHANGED); } if (from->hdr_unknown_str.buffer) { @@ -347,7 +360,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_unknown_str); DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_unknown_str(to , new_string); + pdb_set_unknown_str(to , new_string, PDB_CHANGED); } if (from->hdr_munged_dial.buffer) { @@ -355,40 +368,53 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) new_string = pdb_unistr2_convert(&from->uni_munged_dial); DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_munged_dial(to , new_string); + pdb_set_munged_dial(to , new_string, PDB_CHANGED); } - if (from->user_rid) { + if (from->user_rid != pdb_get_user_rid(to)) { DEBUG(10,("INFO_23 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); /* we really allow this ??? metze */ - /* pdb_set_user_sid_from_rid(to, from->user_rid);*/ + /* pdb_set_user_sid_from_rid(to, from->user_rid, PDB_CHANGED);*/ } - if (from->group_rid) { + if (from->group_rid != pdb_get_group_rid(to)) { DEBUG(10,("INFO_23 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); - pdb_set_group_sid_from_rid(to, from->group_rid); + pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); } DEBUG(10,("INFO_23 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); - pdb_set_acct_ctrl(to, from->acb_info); + if (from->acb_info != pdb_get_acct_ctrl(to)) { + pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); + } - DEBUG(10,("INFO_23 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown3(to),from->unknown_3)); - pdb_set_unknown_3(to, from->unknown_3); - + DEBUG(10,("INFO_23 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown_3(to),from->unknown_3)); + if (from->unknown_3 != pdb_get_unknown_3(to)) { + pdb_set_unknown_3(to, from->unknown_3, PDB_CHANGED); + } DEBUG(15,("INFO_23 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); - pdb_set_logon_divs(to, from->logon_divs); + if (from->logon_divs != pdb_get_logon_divs(to)) { + pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); + } DEBUG(15,("INFO_23 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); - pdb_set_hours_len(to, from->logon_hrs.len); + if (from->logon_hrs.len != pdb_get_hours_len(to)) { + pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED); + } + DEBUG(15,("INFO_23 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); - pdb_set_hours(to, from->logon_hrs.hours); +/* Fix me: only update if it changes --metze */ + pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); - DEBUG(10,("INFO_23 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown5(to),from->unknown_5)); - pdb_set_unknown_5(to, from->unknown_5); + DEBUG(10,("INFO_23 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown_5(to),from->unknown_5)); + if (from->unknown_5 != pdb_get_unknown_5(to)) { + pdb_set_unknown_5(to, from->unknown_5, PDB_CHANGED); + } - DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown6(to),from->unknown_6)); - pdb_set_unknown_6(to, from->unknown_6); + DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); + if (from->unknown_6 != pdb_get_unknown_6(to)) { + pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); + } DEBUG(10,("INFO_23 PADDING1 %02X %02X %02X %02X %02X %02X\n", from->padding1[0], @@ -400,7 +426,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) { - pdb_set_pass_must_change_time(to,0, True); + pdb_set_pass_must_change_time(to,0, PDB_CHANGED); } DEBUG(10,("INFO_23 PADDING_2: %02X\n",from->padding2)); diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 50bf5db4fd..519daff1f6 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -276,7 +276,7 @@ BOOL get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids, SA DEBUG(10,("get_domain_user_groups: searching domain groups [%s] is a member of\n", user_name)); /* first get the list of the domain groups */ - if (!enum_group_mapping(SID_NAME_DOM_GRP, &map, &num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) + if (!pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, &num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) return False; DEBUG(10,("get_domain_user_groups: there are %d mapped groups\n", num_entries)); -- cgit From d12baf7bf7a81cc579dc717d9592c36ad10fda38 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 2 Nov 2002 12:53:13 +0000 Subject: port sec_desc headers reordering from HEAD. Thanks to Andrew Brtlet for the diff :-) (This used to be commit cf67981e73cf52803eae589a6b86e1274bf72d2c) --- source3/rpc_server/srv_samr_nt.c | 88 ++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 44 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 543f9ee379..7b611922f6 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -64,11 +64,11 @@ struct samr_info { TALLOC_CTX *mem_ctx; }; -struct generic_mapping sam_generic_mapping = {SAMR_READ, SAMR_WRITE, SAMR_EXECUTE, SAMR_ALL_ACCESS}; -struct generic_mapping dom_generic_mapping = {DOMAIN_READ, DOMAIN_WRITE, DOMAIN_EXECUTE, DOMAIN_ALL_ACCESS}; -struct generic_mapping usr_generic_mapping = {USER_READ, USER_WRITE, USER_EXECUTE, USER_ALL_ACCESS}; -struct generic_mapping grp_generic_mapping = {GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, GROUP_ALL_ACCESS}; -struct generic_mapping ali_generic_mapping = {ALIAS_READ, ALIAS_WRITE, ALIAS_EXECUTE, ALIAS_ALL_ACCESS}; +struct generic_mapping sam_generic_mapping = {GENERIC_RIGHTS_SAM_READ, GENERIC_RIGHTS_SAM_WRITE, GENERIC_RIGHTS_SAM_EXECUTE, GENERIC_RIGHTS_SAM_ALL_ACCESS}; +struct generic_mapping dom_generic_mapping = {GENERIC_RIGHTS_DOMAIN_READ, GENERIC_RIGHTS_DOMAIN_WRITE, GENERIC_RIGHTS_DOMAIN_EXECUTE, GENERIC_RIGHTS_DOMAIN_ALL_ACCESS}; +struct generic_mapping usr_generic_mapping = {GENERIC_RIGHTS_USER_READ, GENERIC_RIGHTS_USER_WRITE, GENERIC_RIGHTS_USER_EXECUTE, GENERIC_RIGHTS_USER_ALL_ACCESS}; +struct generic_mapping grp_generic_mapping = {GENERIC_RIGHTS_GROUP_READ, GENERIC_RIGHTS_GROUP_WRITE, GENERIC_RIGHTS_GROUP_EXECUTE, GENERIC_RIGHTS_GROUP_ALL_ACCESS}; +struct generic_mapping ali_generic_mapping = {GENERIC_RIGHTS_ALIAS_READ, GENERIC_RIGHTS_ALIAS_WRITE, GENERIC_RIGHTS_ALIAS_EXECUTE, GENERIC_RIGHTS_ALIAS_ALL_ACCESS}; static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size); @@ -375,7 +375,7 @@ NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN if (!find_policy_by_hnd(p, &q_u->pol, (void**)&info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(status = access_check_samr_function(info->acc_granted, SAMR_ACCESS_OPEN_DOMAIN,"_samr_open_domain"))) { + if (!NT_STATUS_IS_OK(status = access_check_samr_function(info->acc_granted, SA_RIGHT_SAM_OPEN_DOMAIN,"_samr_open_domain"))) { return status; } @@ -454,11 +454,11 @@ static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); /*basic access for every one*/ - init_sec_access(&mask, DOMAIN_EXECUTE | DOMAIN_READ); + init_sec_access(&mask, GENERIC_RIGHTS_DOMAIN_EXECUTE | GENERIC_RIGHTS_DOMAIN_READ); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, DOMAIN_ALL_ACCESS); + init_sec_access(&mask, GENERIC_RIGHTS_DOMAIN_ALL_ACCESS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); @@ -493,16 +493,16 @@ static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); /*basic access for every one*/ - init_sec_access(&mask, USER_EXECUTE | USER_READ); + init_sec_access(&mask, GENERIC_RIGHTS_USER_EXECUTE | GENERIC_RIGHTS_USER_READ); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, USER_ALL_ACCESS); + init_sec_access(&mask, GENERIC_RIGHTS_USER_ALL_ACCESS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /*extended access for the user*/ - init_sec_access(&mask,READ_CONTROL_ACCESS | USER_ACCESS_CHANGE_PASSWORD | USER_ACCESS_SET_LOC_COM); + init_sec_access(&mask,READ_CONTROL_ACCESS | SA_RIGHT_USER_CHANGE_PASSWORD | SA_RIGHT_USER_SET_LOC_COM); init_sec_ace(&ace[3], usr_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 4, ace)) == NULL) @@ -536,11 +536,11 @@ static NTSTATUS samr_make_grp_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); /*basic access for every one*/ - init_sec_access(&mask, GROUP_EXECUTE | GROUP_READ); + init_sec_access(&mask, GENERIC_RIGHTS_GROUP_EXECUTE | GENERIC_RIGHTS_GROUP_READ); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, GROUP_ALL_ACCESS); + init_sec_access(&mask, GENERIC_RIGHTS_GROUP_ALL_ACCESS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); @@ -575,11 +575,11 @@ static NTSTATUS samr_make_ali_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); /*basic access for every one*/ - init_sec_access(&mask, ALIAS_EXECUTE | ALIAS_READ); + init_sec_access(&mask, GENERIC_RIGHTS_ALIAS_EXECUTE | GENERIC_RIGHTS_ALIAS_READ); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, ALIAS_ALL_ACCESS); + init_sec_access(&mask, GENERIC_RIGHTS_ALIAS_ALL_ACCESS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); @@ -765,7 +765,7 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, domain_sid = info->sid; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, - DOMAIN_ACCESS_ENUM_ACCOUNTS, + SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_users"))) { return r_u->status; } @@ -1058,7 +1058,7 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_ENUM_ACCOUNTS, "_samr_enum_dom_groups"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_groups"))) { return r_u->status; } @@ -1097,7 +1097,7 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_ENUM_ACCOUNTS, "_samr_enum_dom_aliases"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_aliases"))) { return r_u->status; } @@ -1320,7 +1320,7 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM /* find the policy handle. open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_LOOKUP_INFO, "_samr_query_aliasinfo"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_LOOKUP_INFO, "_samr_query_aliasinfo"))) { return r_u->status; } @@ -1667,7 +1667,7 @@ NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN if (!get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_open_user"))) { + if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_user"))) { return nt_status; } @@ -2008,7 +2008,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, USER_ACCESS_GET_GROUPS, "_samr_query_usergroups"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_USER_GET_GROUPS, "_samr_query_usergroups"))) { return r_u->status; } @@ -2194,7 +2194,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_CREATE_USER, "_samr_create_user"))) { + if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_USER, "_samr_create_user"))) { return nt_status; } @@ -2496,7 +2496,7 @@ NTSTATUS _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_ if (!find_policy_by_hnd(p, &q_u->connect_pol, (void**)&info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SAMR_ACCESS_OPEN_DOMAIN, "_samr_lookup_domain"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_SAM_OPEN_DOMAIN, "_samr_lookup_domain"))) { return r_u->status; } @@ -2569,7 +2569,7 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN if (!find_policy_by_hnd(p, &q_u->pol, (void**)&info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SAMR_ACCESS_ENUM_DOMAINS, "_samr_enum_domains"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_SAM_ENUM_DOMAINS, "_samr_enum_domains"))) { return r_u->status; } @@ -2617,7 +2617,7 @@ NTSTATUS _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OP if (!get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_open_alias"))) { + if (!NT_STATUS_IS_OK(status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_alias"))) { return status; } @@ -2929,7 +2929,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - acc_required = USER_ACCESS_SET_LOC_COM | USER_ACCESS_SET_ATTRIBUTES; /* This is probably wrong */ + acc_required = SA_RIGHT_USER_SET_LOC_COM | SA_RIGHT_USER_SET_ATTRIBUTES; /* This is probably wrong */ if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo"))) { return r_u->status; } @@ -3014,7 +3014,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - acc_required = USER_ACCESS_SET_LOC_COM | USER_ACCESS_SET_ATTRIBUTES; /* This is probably wrong */ + acc_required = SA_RIGHT_USER_SET_LOC_COM | SA_RIGHT_USER_SET_ATTRIBUTES; /* This is probably wrong */ if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo2"))) { return r_u->status; } @@ -3089,8 +3089,8 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - ntstatus1 = access_check_samr_function(info->acc_granted, DOMAIN_ACCESS_LOOKUP_ALIAS_BY_MEM, "_samr_query_useraliases"); - ntstatus2 = access_check_samr_function(info->acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_query_useraliases"); + ntstatus1 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_LOOKUP_ALIAS_BY_MEM, "_samr_query_useraliases"); + ntstatus2 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_query_useraliases"); if (!NT_STATUS_IS_OK(ntstatus1) || !NT_STATUS_IS_OK(ntstatus2)) { if (!(NT_STATUS_EQUAL(ntstatus1,NT_STATUS_ACCESS_DENIED) && NT_STATUS_IS_OK(ntstatus2)) && @@ -3169,7 +3169,7 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = - access_check_samr_function(acc_granted, ALIAS_ACCESS_GET_MEMBERS, "_samr_query_aliasmem"))) { + access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_GET_MEMBERS, "_samr_query_aliasmem"))) { return r_u->status; } @@ -3270,7 +3270,7 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_GET_MEMBERS, "_samr_query_groupmem"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_GET_MEMBERS, "_samr_query_groupmem"))) { return r_u->status; } @@ -3362,7 +3362,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_ADD_MEMBER, "_samr_add_aliasmem"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_ADD_MEMBER, "_samr_add_aliasmem"))) { return r_u->status; } @@ -3455,7 +3455,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_REMOVE_MEMBER, "_samr_del_aliasmem"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_REMOVE_MEMBER, "_samr_del_aliasmem"))) { return r_u->status; } @@ -3526,7 +3526,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_ADD_MEMBER, "_samr_add_groupmem"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_ADD_MEMBER, "_samr_add_groupmem"))) { return r_u->status; } @@ -3623,7 +3623,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_REMOVE_MEMBER, "_samr_del_groupmem"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_REMOVE_MEMBER, "_samr_del_groupmem"))) { return r_u->status; } @@ -3703,7 +3703,7 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &user_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DELETE_ACCESS, "_samr_delete_dom_user"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_user"))) { return r_u->status; } @@ -3762,7 +3762,7 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DELETE_ACCESS, "_samr_delete_dom_group"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_group"))) { return r_u->status; } @@ -3824,7 +3824,7 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DELETE_ACCESS, "_samr_delete_dom_alias"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_alias"))) { return r_u->status; } @@ -3887,7 +3887,7 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_CREATE_GROUP, "_samr_create_dom_group"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_GROUP, "_samr_create_dom_group"))) { return r_u->status; } @@ -3952,7 +3952,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_CREATE_ALIAS, "_samr_create_alias"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_ALIAS, "_samr_create_alias"))) { return r_u->status; } @@ -4014,7 +4014,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_LOOKUP_INFO, "_samr_query_groupinfo"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_LOOKUP_INFO, "_samr_query_groupinfo"))) { return r_u->status; } @@ -4066,7 +4066,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, GROUP_ACCESS_SET_INFO, "_samr_set_groupinfo"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_SET_INFO, "_samr_set_groupinfo"))) { return r_u->status; } @@ -4113,7 +4113,7 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, ALIAS_ACCESS_SET_INFO, "_samr_set_aliasinfo"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_SET_INFO, "_samr_set_aliasinfo"))) { return r_u->status; } @@ -4182,7 +4182,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(status = access_check_samr_function(acc_granted, DOMAIN_ACCESS_OPEN_ACCOUNT, "_samr_open_group"))) { + if (!NT_STATUS_IS_OK(status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_group"))) { return status; } -- cgit From 93042487882d8b2407541ad21d2e9bc2b59142e5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 7 Nov 2002 02:15:35 +0000 Subject: Merge of scalable printing code fix... Needs testing. Jeremy. (This used to be commit d030df76439c72825d68410211e62090438cef54) --- source3/rpc_server/srv_spoolss_nt.c | 38 ++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a5e464f73b..245df2003f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -178,10 +178,18 @@ static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp) Disconnect from the client ****************************************************************************/ -static void srv_spoolss_replycloseprinter(POLICY_HND *handle) +static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle) { WERROR result; + /* + * Tell the specific printing tdb we no longer want messages for this printer + * by deregistering our PID. + */ + + if (!print_notify_deregister_pid(snum)) + DEBUG(0,("print_notify_register_pid: Failed to register our pid for printer %s\n", lp_const_servicename(snum) )); + /* weird if the test succeds !!! */ if (smb_connections==0) { DEBUG(0,("srv_spoolss_replycloseprinter:Trying to close non-existant notify backchannel !\n")); @@ -219,7 +227,8 @@ static void free_printer_entry(void *ptr) Printer_entry *Printer = (Printer_entry *)ptr; if (Printer->notify.client_connected==True) - srv_spoolss_replycloseprinter(&Printer->notify.client_hnd); + srv_spoolss_replycloseprinter(print_queue_snum(Printer->dev.handlename), + &Printer->notify.client_hnd); Printer->notify.flags=0; Printer->notify.options=0; @@ -2305,7 +2314,7 @@ done: Connect to the client machine. **********************************************************/ -static BOOL spoolss_connect_to_client(struct cli_state *the_cli, char *remote_machine) +static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *remote_machine) { extern pstring global_myname; @@ -2396,7 +2405,7 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, char *remote_ma Connect to the client. ****************************************************************************/ -static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle) +static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle) { WERROR result; @@ -2418,6 +2427,14 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin register_message_flags( True, FLAG_MSG_PRINTING ); } + /* + * Tell the specific printing tdb we want messages for this printer + * by registering our PID. + */ + + if (!print_notify_register_pid(snum)) + DEBUG(0,("print_notify_register_pid: Failed to register our pid for printer %s\n", printer )); + smb_connections++; result = cli_spoolss_reply_open_printer(¬ify_cli, notify_cli.mem_ctx, printer, localprinter, @@ -2448,6 +2465,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE uint32 options = q_u->options; UNISTR2 *localmachine = &q_u->localmachine; uint32 printerlocal = q_u->printerlocal; + int snum; SPOOL_NOTIFY_OPTION *option = q_u->option; /* store the notify value in the printer struct */ @@ -2459,6 +2477,9 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE return WERR_BADFID; } + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + Printer->notify.flags=flags; Printer->notify.options=options; Printer->notify.printerlocal=printerlocal; @@ -2473,7 +2494,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE /* Connect to the client machine and send a ReplyOpenPrinter */ - if(!srv_spoolss_replyopenprinter(Printer->notify.localmachine, + if(!srv_spoolss_replyopenprinter(snum, Printer->notify.localmachine, Printer->notify.printerlocal, 1, &Printer->notify.client_hnd)) return WERR_SERVER_UNAVAILABLE; @@ -5832,7 +5853,7 @@ WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) { POLICY_HND *handle = &q_u->handle; - + int snum; Printer_entry *Printer= find_printer_index_by_hnd(p, handle); if (!Printer) { @@ -5840,8 +5861,11 @@ WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) return WERR_BADFID; } + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + if (Printer->notify.client_connected==True) - srv_spoolss_replycloseprinter(&Printer->notify.client_hnd); + srv_spoolss_replycloseprinter(snum, &Printer->notify.client_hnd); Printer->notify.flags=0; Printer->notify.options=0; -- cgit From 47955b2f6cd10ac690705d322a8862c23f18072c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 7 Nov 2002 02:38:42 +0000 Subject: Merge of scalable printing code fix... Needs testing. Also tidied up some of Richard's code (I don't think he uses the compiler flags -g -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual like I do :-) :-). Jeremy. (This used to be commit 10024ed06e9d91f24fdc78d59eef2f76bf395438) --- source3/rpc_server/srv_spoolss_nt.c | 38 ++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a5e464f73b..245df2003f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -178,10 +178,18 @@ static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp) Disconnect from the client ****************************************************************************/ -static void srv_spoolss_replycloseprinter(POLICY_HND *handle) +static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle) { WERROR result; + /* + * Tell the specific printing tdb we no longer want messages for this printer + * by deregistering our PID. + */ + + if (!print_notify_deregister_pid(snum)) + DEBUG(0,("print_notify_register_pid: Failed to register our pid for printer %s\n", lp_const_servicename(snum) )); + /* weird if the test succeds !!! */ if (smb_connections==0) { DEBUG(0,("srv_spoolss_replycloseprinter:Trying to close non-existant notify backchannel !\n")); @@ -219,7 +227,8 @@ static void free_printer_entry(void *ptr) Printer_entry *Printer = (Printer_entry *)ptr; if (Printer->notify.client_connected==True) - srv_spoolss_replycloseprinter(&Printer->notify.client_hnd); + srv_spoolss_replycloseprinter(print_queue_snum(Printer->dev.handlename), + &Printer->notify.client_hnd); Printer->notify.flags=0; Printer->notify.options=0; @@ -2305,7 +2314,7 @@ done: Connect to the client machine. **********************************************************/ -static BOOL spoolss_connect_to_client(struct cli_state *the_cli, char *remote_machine) +static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *remote_machine) { extern pstring global_myname; @@ -2396,7 +2405,7 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, char *remote_ma Connect to the client. ****************************************************************************/ -static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle) +static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle) { WERROR result; @@ -2418,6 +2427,14 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin register_message_flags( True, FLAG_MSG_PRINTING ); } + /* + * Tell the specific printing tdb we want messages for this printer + * by registering our PID. + */ + + if (!print_notify_register_pid(snum)) + DEBUG(0,("print_notify_register_pid: Failed to register our pid for printer %s\n", printer )); + smb_connections++; result = cli_spoolss_reply_open_printer(¬ify_cli, notify_cli.mem_ctx, printer, localprinter, @@ -2448,6 +2465,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE uint32 options = q_u->options; UNISTR2 *localmachine = &q_u->localmachine; uint32 printerlocal = q_u->printerlocal; + int snum; SPOOL_NOTIFY_OPTION *option = q_u->option; /* store the notify value in the printer struct */ @@ -2459,6 +2477,9 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE return WERR_BADFID; } + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + Printer->notify.flags=flags; Printer->notify.options=options; Printer->notify.printerlocal=printerlocal; @@ -2473,7 +2494,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE /* Connect to the client machine and send a ReplyOpenPrinter */ - if(!srv_spoolss_replyopenprinter(Printer->notify.localmachine, + if(!srv_spoolss_replyopenprinter(snum, Printer->notify.localmachine, Printer->notify.printerlocal, 1, &Printer->notify.client_hnd)) return WERR_SERVER_UNAVAILABLE; @@ -5832,7 +5853,7 @@ WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) { POLICY_HND *handle = &q_u->handle; - + int snum; Printer_entry *Printer= find_printer_index_by_hnd(p, handle); if (!Printer) { @@ -5840,8 +5861,11 @@ WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) return WERR_BADFID; } + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + if (Printer->notify.client_connected==True) - srv_spoolss_replycloseprinter(&Printer->notify.client_hnd); + srv_spoolss_replycloseprinter(snum, &Printer->notify.client_hnd); Printer->notify.flags=0; Printer->notify.options=0; -- cgit From aa208a58e260cfaec6abdc8560491d28b60d7380 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 8 Nov 2002 22:14:31 +0000 Subject: Make it easier to track things down here - add some debugs on failure. (This used to be commit 62ee7b7dc08e7be261211de8f85b8e9be4df7b54) --- source3/rpc_server/srv_samr_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b039d92d9c..66556e3acb 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -303,6 +303,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) } if (!pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) { + DEBUG(1, ("load_group_domain_entries: pdb_enum_group_mapping() failed!\n")); return NT_STATUS_NO_MEMORY; } @@ -311,6 +312,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) grp_array=(DISP_GROUP_INFO *)talloc(mem_ctx, info->disp_info.num_group_account*sizeof(DISP_GROUP_INFO)); if (group_entries!=0 && grp_array==NULL) { + DEBUG(1, ("load_group_domain_entries: talloc() failed for grp_array!\n")); SAFE_FREE(map); return NT_STATUS_NO_MEMORY; } -- cgit From c19598f2a6a3329e973e14e389e0577ebb914f3b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 8 Nov 2002 23:08:59 +0000 Subject: Merge from HEAD: - change auth_sam to use the initialisation flags to determine if the password attributes are set - add const to secrets.c, cliconnect.c - passdb: fix spelling in pdb_ldap, add group mapping back to smbpasswd - SAMR: add debugs to show what fails for group enum. Andrew Bartlett (This used to be commit 4e74d00b3634abf52aa24bfaa6dbe88202aa57a1) --- source3/rpc_server/srv_samr_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7b611922f6..0b5870b16c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -303,6 +303,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) } if (!pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) { + DEBUG(1, ("load_group_domain_entries: pdb_enum_group_mapping() failed!\n")); return NT_STATUS_NO_MEMORY; } @@ -311,6 +312,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) grp_array=(DISP_GROUP_INFO *)talloc(mem_ctx, info->disp_info.num_group_account*sizeof(DISP_GROUP_INFO)); if (group_entries!=0 && grp_array==NULL) { + DEBUG(1, ("load_group_domain_entries: talloc() failed for grp_array!\n")); SAFE_FREE(map); return NT_STATUS_NO_MEMORY; } -- cgit From b3f55b37a09551b6e782e58b3339b9caa4086d6d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 9 Nov 2002 05:41:27 +0000 Subject: re-enable ffpcn on print server handle (This used to be commit e87829b4942237de542d21051092fee069a9c73d) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 245df2003f..5ebefc5ea0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2477,7 +2477,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) + if ( (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && !get_printer_snum(p, handle, &snum) ) return WERR_BADFID; Printer->notify.flags=flags; -- cgit From 2d08c914d782087ab0360aed9387ec1524d273d6 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 9 Nov 2002 05:42:37 +0000 Subject: re-enable ffpcn on print server handle (This used to be commit 47a0c68fa9e98ab761e609d889894db1de9520db) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 245df2003f..5ebefc5ea0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2477,7 +2477,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) + if ( (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && !get_printer_snum(p, handle, &snum) ) return WERR_BADFID; Printer->notify.flags=flags; -- cgit From 4be3750d8e5edb849cf946def10891e0d4dd16d0 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 9 Nov 2002 14:48:27 +0000 Subject: deldriver fix (This used to be commit f20de1f9b0dcac15fbf968e6d5d5af2fdd5fbda1) --- source3/rpc_server/srv_spoolss_nt.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5ebefc5ea0..f8262110ce 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1908,6 +1908,12 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER goto done; } } + /* otherwise it was a failure */ + else { + status = WERR_UNKNOWN_PRINTER_DRIVER; + goto done; + } + } if (printer_driver_in_use(info.info_3)) { -- cgit From cda79e5d36711317f055f3724c354fec000be86a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 9 Nov 2002 14:49:26 +0000 Subject: deldriver fix (This used to be commit 78ff2cc34aedaf82d965a71e0c9dfdeb86a90fdd) --- source3/rpc_server/srv_spoolss_nt.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5ebefc5ea0..f8262110ce 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1908,6 +1908,12 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER goto done; } } + /* otherwise it was a failure */ + else { + status = WERR_UNKNOWN_PRINTER_DRIVER; + goto done; + } + } if (printer_driver_in_use(info.info_3)) { -- cgit From fc2dc328e157d625d6fb4baa5d46cab2bd2a8a4f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 10 Nov 2002 22:24:00 +0000 Subject: First cut of fix for changenotify on a print server handle. Use the connections tdb with an snum of -1 and a special printername. Jeremy. (This used to be commit 06b04380078ad840768a2c5a803f02669f54bc82) --- source3/rpc_server/srv_spoolss_nt.c | 40 +++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f8262110ce..2227d39f44 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -226,9 +226,19 @@ static void free_printer_entry(void *ptr) { Printer_entry *Printer = (Printer_entry *)ptr; - if (Printer->notify.client_connected==True) - srv_spoolss_replycloseprinter(print_queue_snum(Printer->dev.handlename), - &Printer->notify.client_hnd); + if (Printer->notify.client_connected==True) { + int snum = -1; + + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) { + snum = -1; + srv_spoolss_replycloseprinter(snum, &Printer->notify.client_hnd); + } else if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) { + snum = print_queue_snum(Printer->dev.handlename); + if (snum != -1) + srv_spoolss_replycloseprinter(snum, + &Printer->notify.client_hnd); + } + } Printer->notify.flags=0; Printer->notify.options=0; @@ -2471,7 +2481,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE uint32 options = q_u->options; UNISTR2 *localmachine = &q_u->localmachine; uint32 printerlocal = q_u->printerlocal; - int snum; + int snum = -1; SPOOL_NOTIFY_OPTION *option = q_u->option; /* store the notify value in the printer struct */ @@ -2483,9 +2493,6 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE return WERR_BADFID; } - if ( (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && !get_printer_snum(p, handle, &snum) ) - return WERR_BADFID; - Printer->notify.flags=flags; Printer->notify.options=options; Printer->notify.printerlocal=printerlocal; @@ -2500,6 +2507,12 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE /* Connect to the client machine and send a ReplyOpenPrinter */ + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + snum = -1; + else if ( (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && + !get_printer_snum(p, handle, &snum) ) + return WERR_BADFID; + if(!srv_spoolss_replyopenprinter(snum, Printer->notify.localmachine, Printer->notify.printerlocal, 1, &Printer->notify.client_hnd)) @@ -5859,7 +5872,6 @@ WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) { POLICY_HND *handle = &q_u->handle; - int snum; Printer_entry *Printer= find_printer_index_by_hnd(p, handle); if (!Printer) { @@ -5867,11 +5879,17 @@ WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) - return WERR_BADFID; + if (Printer->notify.client_connected==True) { + int snum = -1; + + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + snum = -1; + else if ( (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && + !get_printer_snum(p, handle, &snum) ) + return WERR_BADFID; - if (Printer->notify.client_connected==True) srv_spoolss_replycloseprinter(snum, &Printer->notify.client_hnd); + } Printer->notify.flags=0; Printer->notify.options=0; -- cgit From 7f94064e4ae14b1bfdbb6553420c504a1e571103 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 10 Nov 2002 22:24:10 +0000 Subject: First cut of fix for changenotify on a print server handle. Use the connections tdb with an snum of -1 and a special printername. Jeremy. (This used to be commit 940b04ddfa87acc939911e3fe76496e3c4675632) --- source3/rpc_server/srv_spoolss_nt.c | 40 +++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f8262110ce..2227d39f44 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -226,9 +226,19 @@ static void free_printer_entry(void *ptr) { Printer_entry *Printer = (Printer_entry *)ptr; - if (Printer->notify.client_connected==True) - srv_spoolss_replycloseprinter(print_queue_snum(Printer->dev.handlename), - &Printer->notify.client_hnd); + if (Printer->notify.client_connected==True) { + int snum = -1; + + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) { + snum = -1; + srv_spoolss_replycloseprinter(snum, &Printer->notify.client_hnd); + } else if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) { + snum = print_queue_snum(Printer->dev.handlename); + if (snum != -1) + srv_spoolss_replycloseprinter(snum, + &Printer->notify.client_hnd); + } + } Printer->notify.flags=0; Printer->notify.options=0; @@ -2471,7 +2481,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE uint32 options = q_u->options; UNISTR2 *localmachine = &q_u->localmachine; uint32 printerlocal = q_u->printerlocal; - int snum; + int snum = -1; SPOOL_NOTIFY_OPTION *option = q_u->option; /* store the notify value in the printer struct */ @@ -2483,9 +2493,6 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE return WERR_BADFID; } - if ( (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && !get_printer_snum(p, handle, &snum) ) - return WERR_BADFID; - Printer->notify.flags=flags; Printer->notify.options=options; Printer->notify.printerlocal=printerlocal; @@ -2500,6 +2507,12 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE /* Connect to the client machine and send a ReplyOpenPrinter */ + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + snum = -1; + else if ( (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && + !get_printer_snum(p, handle, &snum) ) + return WERR_BADFID; + if(!srv_spoolss_replyopenprinter(snum, Printer->notify.localmachine, Printer->notify.printerlocal, 1, &Printer->notify.client_hnd)) @@ -5859,7 +5872,6 @@ WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) { POLICY_HND *handle = &q_u->handle; - int snum; Printer_entry *Printer= find_printer_index_by_hnd(p, handle); if (!Printer) { @@ -5867,11 +5879,17 @@ WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) - return WERR_BADFID; + if (Printer->notify.client_connected==True) { + int snum = -1; + + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + snum = -1; + else if ( (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && + !get_printer_snum(p, handle, &snum) ) + return WERR_BADFID; - if (Printer->notify.client_connected==True) srv_spoolss_replycloseprinter(snum, &Printer->notify.client_hnd); + } Printer->notify.flags=0; Printer->notify.options=0; -- cgit From b0f9f11f5fd3aa10be3f7dd3b5d1702222db014f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 11 Nov 2002 22:05:05 +0000 Subject: fix for CR 601. Only call addprinter command when the port, driver, comment, or location field changed (This used to be commit c6d45216f6d3573fb2342f4d3aa3a50415924674) --- source3/rpc_server/srv_spoolss_nt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2227d39f44..871aac8e68 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5780,8 +5780,14 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, } /* Call addprinter hook */ - - if (*lp_addprinter_cmd()) { + /* Check changes to see if this is really needed */ + + if ( *lp_addprinter_cmd() + && (!strequal(printer->info_2->drivername, old_printer->info_2->drivername) + || !strequal(printer->info_2->comment, old_printer->info_2->comment) + || !strequal(printer->info_2->portname, old_printer->info_2->portname) + || !strequal(printer->info_2->location, old_printer->info_2->location)) ) + { if ( !add_printer_hook(printer) ) { result = WERR_ACCESS_DENIED; goto done; -- cgit From 9b62172031ed16221821ad7a975e48c140e4ff26 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 11 Nov 2002 22:05:32 +0000 Subject: fix for CR 601. Only call addprinter command when the port, driver, comment, or location field changed (This used to be commit 62a19247d31b1e5b81767880182b40ba396b261a) --- source3/rpc_server/srv_spoolss_nt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2227d39f44..871aac8e68 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5780,8 +5780,14 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, } /* Call addprinter hook */ - - if (*lp_addprinter_cmd()) { + /* Check changes to see if this is really needed */ + + if ( *lp_addprinter_cmd() + && (!strequal(printer->info_2->drivername, old_printer->info_2->drivername) + || !strequal(printer->info_2->comment, old_printer->info_2->comment) + || !strequal(printer->info_2->portname, old_printer->info_2->portname) + || !strequal(printer->info_2->location, old_printer->info_2->location)) ) + { if ( !add_printer_hook(printer) ) { result = WERR_ACCESS_DENIED; goto done; -- cgit From 250c9801197ea1c949bd94c1c891f81ab118b130 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 12 Nov 2002 23:15:52 +0000 Subject: Removed global_myworkgroup, global_myname, global_myscope. Added liberal dashes of const. This is a rather large check-in, some things may break. It does compile though :-). Jeremy. (This used to be commit 82b8f749a36b42e22186297482aad2abb04fab8a) --- source3/rpc_server/srv_dfs.c | 2 -- source3/rpc_server/srv_dfs_nt.c | 10 ++++----- source3/rpc_server/srv_lsa_nt.c | 41 +++++++++++++++++-------------------- source3/rpc_server/srv_netlog_nt.c | 5 +---- source3/rpc_server/srv_samr_nt.c | 16 +++++++-------- source3/rpc_server/srv_spoolss_nt.c | 4 +--- source3/rpc_server/srv_srvsvc_nt.c | 8 +++----- source3/rpc_server/srv_wkssvc_nt.c | 4 +--- 8 files changed, 36 insertions(+), 54 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 5edc1222a8..676ad8e3f3 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -31,8 +31,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -extern pstring global_myname; - /********************************************************************** api_dfs_exist **********************************************************************/ diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 65e387176d..da92e5c06b 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -29,8 +29,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -extern pstring global_myname; - #define MAX_MSDFS_JUNCTIONS 256 /* This function does not return a WERROR or NTSTATUS code but rather 1 if @@ -197,7 +195,7 @@ static BOOL init_reply_dfs_info_1(struct junction_map* j, DFS_INFO_1* dfs1, int { pstring str; dfs1[i].ptr_entrypath = 1; - slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname, + slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), j[i].service_name, j[i].volume_name); DEBUG(5,("init_reply_dfs_info_1: %d) initing entrypath: %s\n",i,str)); init_unistr2(&dfs1[i].entrypath,str,strlen(str)+1); @@ -212,7 +210,7 @@ static BOOL init_reply_dfs_info_2(struct junction_map* j, DFS_INFO_2* dfs2, int { pstring str; dfs2[i].ptr_entrypath = 1; - slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname, + slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), j[i].service_name, j[i].volume_name); init_unistr2(&dfs2[i].entrypath, str, strlen(str)+1); dfs2[i].ptr_comment = 0; @@ -231,9 +229,9 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I dfs3[i].ptr_entrypath = 1; if (j[i].volume_name[0] == '\0') slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s", - global_myname, j[i].service_name); + global_myname(), j[i].service_name); else - slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname, + 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); diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c4fc0a5de7..fc51d7ef2f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -30,13 +30,11 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -extern fstring global_myworkgroup; -extern pstring global_myname; extern PRIVS privs[]; struct lsa_info { - DOM_SID sid; - uint32 access; + DOM_SID sid; + uint32 access; }; struct generic_mapping lsa_generic_mapping = { @@ -61,7 +59,7 @@ static void free_lsa_info(void *ptr) Init dom_query ***************************************************************************/ -static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) +static void init_dom_query(DOM_QUERY *d_q, const char *dom_name, DOM_SID *dom_sid) { int domlen = (dom_name != NULL) ? strlen(dom_name) : 0; @@ -343,10 +341,11 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s } /*************************************************************************** - init_dns_dom_info. - ***************************************************************************/ -static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, char *nb_name, - char *dns_name, char *forest_name, + Init_dns_dom_info. +***************************************************************************/ + +static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, + const char *dns_name, const char *forest_name, GUID *dom_guid, DOM_SID *dom_sid) { if (nb_name && *nb_name) { @@ -513,7 +512,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF struct lsa_info *handle; LSA_INFO_UNION *info = &r_u->dom; DOM_SID domain_sid; - char *name = NULL; + const char *name; DOM_SID *sid = NULL; r_u->status = NT_STATUS_OK; @@ -548,20 +547,19 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - name = global_myworkgroup; + name = lp_workgroup(); sid = get_global_sam_sid(); break; case ROLE_DOMAIN_MEMBER: - name = global_myworkgroup; + name = lp_workgroup(); /* We need to return the Domain SID here. */ - if (secrets_fetch_domain_sid(global_myworkgroup, - &domain_sid)) + if (secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) sid = &domain_sid; else return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; break; case ROLE_STANDALONE: - name = global_myworkgroup; + name = lp_workgroup(); sid = NULL; break; default: @@ -578,15 +576,15 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - name = global_myworkgroup; + name = lp_workgroup(); sid = get_global_sam_sid(); break; case ROLE_DOMAIN_MEMBER: - name = global_myname; + name = global_myname(); sid = get_global_sam_sid(); break; case ROLE_STANDALONE: - name = global_myname; + name = global_myname(); sid = get_global_sam_sid(); break; default: @@ -1214,7 +1212,7 @@ NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUER NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_INFO2 *r_u) { struct lsa_info *handle; - char *nb_name = NULL; + const char *nb_name; char *dns_name = NULL; char *forest_name = NULL; DOM_SID *sid = NULL; @@ -1236,13 +1234,12 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - nb_name = global_myworkgroup; + nb_name = lp_workgroup(); /* ugly temp hack for these next two */ dns_name = lp_realm(); forest_name = lp_realm(); sid = get_global_sam_sid(); - secrets_fetch_domain_guid(global_myworkgroup, - &guid); + secrets_fetch_domain_guid(lp_workgroup(), &guid); break; default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 69d619a2b0..12841a2e08 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -29,8 +29,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -extern pstring global_myname; - /************************************************************************* init_net_r_req_chal: *************************************************************************/ @@ -687,8 +685,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return NT_STATUS_UNSUCCESSFUL; } - pstrcpy(my_name, global_myname); - strupper(my_name); + pstrcpy(my_name, global_myname()); /* * This is the point at which we get the group diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 66556e3acb..ba5e9b70d3 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -34,8 +34,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -extern fstring global_myworkgroup; -extern pstring global_myname; extern DOM_SID global_sid_Builtin; extern rid_name domain_group_rids[]; @@ -2135,7 +2133,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA free_samr_db(info); /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL), + init_unk_info2(&ctr->info.inf2, lp_workgroup(), global_myname(), (uint32) time(NULL), num_users, num_groups, num_aliases); break; case 0x03: @@ -2145,7 +2143,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA init_unk_info3(&ctr->info.inf3, nt_logout); break; case 0x05: - init_unk_info5(&ctr->info.inf5, global_myname); + init_unk_info5(&ctr->info.inf5, global_myname()); break; case 0x06: init_unk_info6(&ctr->info.inf6); @@ -2576,7 +2574,7 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN struct samr_info *info; uint32 num_entries = 2; fstring dom[2]; - char *name; + const char *name; r_u->status = NT_STATUS_OK; @@ -2590,10 +2588,10 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - name = global_myworkgroup; + name = lp_workgroup(); break; default: - name = global_myname; + name = global_myname(); } fstrcpy(dom[0],name); @@ -4325,7 +4323,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW free_samr_db(info); /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL), + init_unk_info2(&ctr->info.inf2, lp_workgroup(), global_myname(), (uint32) time(NULL), num_users, num_groups, num_aliases); break; case 0x03: @@ -4337,7 +4335,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW init_unk_info3(&ctr->info.inf3, nt_logout); break; case 0x05: - init_unk_info5(&ctr->info.inf5, global_myname); + init_unk_info5(&ctr->info.inf5, global_myname()); break; case 0x06: init_unk_info6(&ctr->info.inf6); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 871aac8e68..ad55ea6a49 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2332,8 +2332,6 @@ done: static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *remote_machine) { - extern pstring global_myname; - ZERO_STRUCTP(the_cli); if(cli_initialise(the_cli) == NULL) { DEBUG(0,("connect_to_client: unable to initialize client connection.\n")); @@ -2358,7 +2356,7 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *rem return False; } - if (!attempt_netbios_session_request(the_cli, global_myname, remote_machine, &the_cli->dest_ip)) { + if (!attempt_netbios_session_request(the_cli, global_myname(), remote_machine, &the_cli->dest_ip)) { DEBUG(0,("connect_to_client: machine %s rejected the NetBIOS session request.\n", remote_machine)); cli_shutdown(the_cli); diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index ecde51df9f..0384bb81a3 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -27,8 +27,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -extern pstring global_myname; - /******************************************************************* Utility function to get the 'type' of a share from an snum. ********************************************************************/ @@ -1211,7 +1209,7 @@ WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R case 102: init_srv_info_102(&ctr->srv.sv102, - 500, global_myname, + 500, global_myname(), string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), lp_major_announce_version(), lp_minor_announce_version(), lp_default_server_announce(), @@ -1225,13 +1223,13 @@ WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R break; case 101: init_srv_info_101(&ctr->srv.sv101, - 500, global_myname, + 500, global_myname(), lp_major_announce_version(), lp_minor_announce_version(), lp_default_server_announce(), string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); break; case 100: - init_srv_info_100(&ctr->srv.sv100, 500, global_myname); + init_srv_info_100(&ctr->srv.sv100, 500, global_myname()); break; default: status = WERR_UNKNOWN_LEVEL; diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 7687e7b00a..bda7b14a42 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -28,8 +28,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -extern pstring global_myname; - /******************************************************************* create_wks_info_100 ********************************************************************/ @@ -41,7 +39,7 @@ static void create_wks_info_100(WKS_INFO_100 *inf) DEBUG(5,("create_wks_info_100: %d\n", __LINE__)); - pstrcpy (my_name, global_myname); + pstrcpy (my_name, global_myname()); strupper(my_name); pstrcpy (domain, lp_workgroup()); -- cgit From 2f194322d419350f35a48dff750066894d68eccf Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 12 Nov 2002 23:20:50 +0000 Subject: Removed global_myworkgroup, global_myname, global_myscope. Added liberal dashes of const. This is a rather large check-in, some things may break. It does compile though :-). Jeremy. (This used to be commit f755711df8f74f9b8e8c1a2b0d07d02a931eeb89) --- source3/rpc_server/srv_dfs.c | 2 -- source3/rpc_server/srv_dfs_nt.c | 10 ++++----- source3/rpc_server/srv_lsa_nt.c | 41 +++++++++++++++++-------------------- source3/rpc_server/srv_netlog_nt.c | 5 +---- source3/rpc_server/srv_samr_nt.c | 16 +++++++-------- source3/rpc_server/srv_spoolss_nt.c | 4 +--- source3/rpc_server/srv_srvsvc_nt.c | 8 +++----- source3/rpc_server/srv_wkssvc_nt.c | 4 +--- 8 files changed, 36 insertions(+), 54 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 5edc1222a8..676ad8e3f3 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -31,8 +31,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -extern pstring global_myname; - /********************************************************************** api_dfs_exist **********************************************************************/ diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 65e387176d..da92e5c06b 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -29,8 +29,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -extern pstring global_myname; - #define MAX_MSDFS_JUNCTIONS 256 /* This function does not return a WERROR or NTSTATUS code but rather 1 if @@ -197,7 +195,7 @@ static BOOL init_reply_dfs_info_1(struct junction_map* j, DFS_INFO_1* dfs1, int { pstring str; dfs1[i].ptr_entrypath = 1; - slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname, + slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), j[i].service_name, j[i].volume_name); DEBUG(5,("init_reply_dfs_info_1: %d) initing entrypath: %s\n",i,str)); init_unistr2(&dfs1[i].entrypath,str,strlen(str)+1); @@ -212,7 +210,7 @@ static BOOL init_reply_dfs_info_2(struct junction_map* j, DFS_INFO_2* dfs2, int { pstring str; dfs2[i].ptr_entrypath = 1; - slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname, + slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), j[i].service_name, j[i].volume_name); init_unistr2(&dfs2[i].entrypath, str, strlen(str)+1); dfs2[i].ptr_comment = 0; @@ -231,9 +229,9 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I dfs3[i].ptr_entrypath = 1; if (j[i].volume_name[0] == '\0') slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s", - global_myname, j[i].service_name); + global_myname(), j[i].service_name); else - slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname, + 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); diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c4fc0a5de7..fc51d7ef2f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -30,13 +30,11 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -extern fstring global_myworkgroup; -extern pstring global_myname; extern PRIVS privs[]; struct lsa_info { - DOM_SID sid; - uint32 access; + DOM_SID sid; + uint32 access; }; struct generic_mapping lsa_generic_mapping = { @@ -61,7 +59,7 @@ static void free_lsa_info(void *ptr) Init dom_query ***************************************************************************/ -static void init_dom_query(DOM_QUERY *d_q, char *dom_name, DOM_SID *dom_sid) +static void init_dom_query(DOM_QUERY *d_q, const char *dom_name, DOM_SID *dom_sid) { int domlen = (dom_name != NULL) ? strlen(dom_name) : 0; @@ -343,10 +341,11 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s } /*************************************************************************** - init_dns_dom_info. - ***************************************************************************/ -static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, char *nb_name, - char *dns_name, char *forest_name, + Init_dns_dom_info. +***************************************************************************/ + +static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, + const char *dns_name, const char *forest_name, GUID *dom_guid, DOM_SID *dom_sid) { if (nb_name && *nb_name) { @@ -513,7 +512,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF struct lsa_info *handle; LSA_INFO_UNION *info = &r_u->dom; DOM_SID domain_sid; - char *name = NULL; + const char *name; DOM_SID *sid = NULL; r_u->status = NT_STATUS_OK; @@ -548,20 +547,19 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - name = global_myworkgroup; + name = lp_workgroup(); sid = get_global_sam_sid(); break; case ROLE_DOMAIN_MEMBER: - name = global_myworkgroup; + name = lp_workgroup(); /* We need to return the Domain SID here. */ - if (secrets_fetch_domain_sid(global_myworkgroup, - &domain_sid)) + if (secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) sid = &domain_sid; else return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; break; case ROLE_STANDALONE: - name = global_myworkgroup; + name = lp_workgroup(); sid = NULL; break; default: @@ -578,15 +576,15 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - name = global_myworkgroup; + name = lp_workgroup(); sid = get_global_sam_sid(); break; case ROLE_DOMAIN_MEMBER: - name = global_myname; + name = global_myname(); sid = get_global_sam_sid(); break; case ROLE_STANDALONE: - name = global_myname; + name = global_myname(); sid = get_global_sam_sid(); break; default: @@ -1214,7 +1212,7 @@ NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUER NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_INFO2 *r_u) { struct lsa_info *handle; - char *nb_name = NULL; + const char *nb_name; char *dns_name = NULL; char *forest_name = NULL; DOM_SID *sid = NULL; @@ -1236,13 +1234,12 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - nb_name = global_myworkgroup; + nb_name = lp_workgroup(); /* ugly temp hack for these next two */ dns_name = lp_realm(); forest_name = lp_realm(); sid = get_global_sam_sid(); - secrets_fetch_domain_guid(global_myworkgroup, - &guid); + secrets_fetch_domain_guid(lp_workgroup(), &guid); break; default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 69d619a2b0..12841a2e08 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -29,8 +29,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -extern pstring global_myname; - /************************************************************************* init_net_r_req_chal: *************************************************************************/ @@ -687,8 +685,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return NT_STATUS_UNSUCCESSFUL; } - pstrcpy(my_name, global_myname); - strupper(my_name); + pstrcpy(my_name, global_myname()); /* * This is the point at which we get the group diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 0b5870b16c..603dcd0017 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -34,8 +34,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -extern fstring global_myworkgroup; -extern pstring global_myname; extern DOM_SID global_sid_Builtin; extern rid_name domain_group_rids[]; @@ -2123,7 +2121,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA free_samr_db(info); /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL), + init_unk_info2(&ctr->info.inf2, lp_workgroup(), global_myname(), (uint32) time(NULL), num_users, num_groups, num_aliases); break; case 0x03: @@ -2133,7 +2131,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA init_unk_info3(&ctr->info.inf3, nt_logout); break; case 0x05: - init_unk_info5(&ctr->info.inf5, global_myname); + init_unk_info5(&ctr->info.inf5, global_myname()); break; case 0x06: init_unk_info6(&ctr->info.inf6); @@ -2564,7 +2562,7 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN struct samr_info *info; uint32 num_entries = 2; fstring dom[2]; - char *name; + const char *name; r_u->status = NT_STATUS_OK; @@ -2578,10 +2576,10 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - name = global_myworkgroup; + name = lp_workgroup(); break; default: - name = global_myname; + name = global_myname(); } fstrcpy(dom[0],name); @@ -4313,7 +4311,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW free_samr_db(info); /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, global_myworkgroup, global_myname, (uint32) time(NULL), + init_unk_info2(&ctr->info.inf2, lp_workgroup(), global_myname(), (uint32) time(NULL), num_users, num_groups, num_aliases); break; case 0x03: @@ -4325,7 +4323,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW init_unk_info3(&ctr->info.inf3, nt_logout); break; case 0x05: - init_unk_info5(&ctr->info.inf5, global_myname); + init_unk_info5(&ctr->info.inf5, global_myname()); break; case 0x06: init_unk_info6(&ctr->info.inf6); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 871aac8e68..ad55ea6a49 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2332,8 +2332,6 @@ done: static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *remote_machine) { - extern pstring global_myname; - ZERO_STRUCTP(the_cli); if(cli_initialise(the_cli) == NULL) { DEBUG(0,("connect_to_client: unable to initialize client connection.\n")); @@ -2358,7 +2356,7 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *rem return False; } - if (!attempt_netbios_session_request(the_cli, global_myname, remote_machine, &the_cli->dest_ip)) { + if (!attempt_netbios_session_request(the_cli, global_myname(), remote_machine, &the_cli->dest_ip)) { DEBUG(0,("connect_to_client: machine %s rejected the NetBIOS session request.\n", remote_machine)); cli_shutdown(the_cli); diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index ecde51df9f..0384bb81a3 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -27,8 +27,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -extern pstring global_myname; - /******************************************************************* Utility function to get the 'type' of a share from an snum. ********************************************************************/ @@ -1211,7 +1209,7 @@ WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R case 102: init_srv_info_102(&ctr->srv.sv102, - 500, global_myname, + 500, global_myname(), string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), lp_major_announce_version(), lp_minor_announce_version(), lp_default_server_announce(), @@ -1225,13 +1223,13 @@ WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R break; case 101: init_srv_info_101(&ctr->srv.sv101, - 500, global_myname, + 500, global_myname(), lp_major_announce_version(), lp_minor_announce_version(), lp_default_server_announce(), string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); break; case 100: - init_srv_info_100(&ctr->srv.sv100, 500, global_myname); + init_srv_info_100(&ctr->srv.sv100, 500, global_myname()); break; default: status = WERR_UNKNOWN_LEVEL; diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 7687e7b00a..bda7b14a42 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -28,8 +28,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -extern pstring global_myname; - /******************************************************************* create_wks_info_100 ********************************************************************/ @@ -41,7 +39,7 @@ static void create_wks_info_100(WKS_INFO_100 *inf) DEBUG(5,("create_wks_info_100: %d\n", __LINE__)); - pstrcpy (my_name, global_myname); + pstrcpy (my_name, global_myname()); strupper(my_name); pstrcpy (domain, lp_workgroup()); -- cgit From 155048633fe3a29fa05eada2fd520c39e45602b6 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 18 Nov 2002 15:45:06 +0000 Subject: formatting fix (This used to be commit 6ce20a61a85f129d42c06844d51f4b2b35b41869) --- source3/rpc_server/srv_spoolss_nt.c | 70 ++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ad55ea6a49..ce877841d3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -962,60 +962,60 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) { SPOOLSS_NOTIFY_MSG *msg = &messages[i]; - /* Are we monitoring this event? */ + /* Are we monitoring this event? */ - if (!is_monitoring_event(p, msg->type, msg->field)) - continue; + if (!is_monitoring_event(p, msg->type, msg->field)) + continue; - DEBUG(10,("process_notify2_message: Sending message type [%x] field [%x] for printer [%s]\n", - msg->type, msg->field, p->dev.handlename)); + DEBUG(10,("process_notify2_message: Sending message type [%x] field [%x] for printer [%s]\n", + msg->type, msg->field, p->dev.handlename)); - /* - * if the is a printer notification handle and not a job notification - * type, then set the id to 0. Other wise just use what was specified - * in the message. - * - * When registering change notification on a print server handle - * we always need to send back the id (snum) matching the printer - * for which the change took place. For change notify registered - * on a printer handle, this does not matter and the id should be 0. - * - * --jerry - */ + /* + * if the is a printer notification handle and not a job notification + * type, then set the id to 0. Other wise just use what was specified + * in the message. + * + * When registering change notification on a print server handle + * we always need to send back the id (snum) matching the printer + * for which the change took place. For change notify registered + * on a printer handle, this does not matter and the id should be 0. + * + * --jerry + */ - if ( ( p->printer_type == PRINTER_HANDLE_IS_PRINTER ) && ( msg->type == PRINTER_NOTIFY_TYPE ) ) - id = 0; - else - id = msg->id; + if ( ( p->printer_type == PRINTER_HANDLE_IS_PRINTER ) && ( msg->type == PRINTER_NOTIFY_TYPE ) ) + id = 0; + else + id = msg->id; - /* Convert unix jobid to smb jobid */ + /* Convert unix jobid to smb jobid */ if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) { - id = sysjob_to_jobid(msg->id); + id = sysjob_to_jobid(msg->id); - if (id == -1) { - DEBUG(3, ("no such unix jobid %d\n", msg->id)); - goto done; + if (id == -1) { + DEBUG(3, ("no such unix jobid %d\n", msg->id)); + goto done; + } } - } construct_info_data( &data[data_len], msg->type, msg->field, id ); - switch(msg->type) { - case PRINTER_NOTIFY_TYPE: + switch(msg->type) { + case PRINTER_NOTIFY_TYPE: if ( !printer_notify_table[msg->field].fn ) - goto done; - printer_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); + goto done; + printer_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); - break; + break; - case JOB_NOTIFY_TYPE: + case JOB_NOTIFY_TYPE: if ( !job_notify_table[msg->field].fn ) - goto done; - job_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); + goto done; + job_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); break; -- cgit From 1abaa7c9d35bf694f0bc98fce89de6ae2c086f93 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 20 Nov 2002 00:39:57 +0000 Subject: more %U fixes for head (This used to be commit ea3787d819df14f8b451780a55d2bf76dc4030ef) --- source3/rpc_server/srv_netlog_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 12841a2e08..dee0866b12 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -566,6 +566,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * nt_workstation, nt_domain)); pstrcpy(current_user_info.smb_name, nt_username); + sub_set_smb_name(nt_username); /* * Convert to a UNIX username. -- cgit From 91b7ac9fb955124263d0e86801db972590dabfb9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 20 Nov 2002 00:53:24 +0000 Subject: merged the %U changes to 3.0 (This used to be commit 58fa6bfee8ba35cc182c18c980e0a4040ddd7d09) --- source3/rpc_server/srv_netlog_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 12841a2e08..dee0866b12 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -566,6 +566,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * nt_workstation, nt_domain)); pstrcpy(current_user_info.smb_name, nt_username); + sub_set_smb_name(nt_username); /* * Convert to a UNIX username. -- cgit From ee90b48633f0300628e71249aa0648b3e92a22ab Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 20 Nov 2002 03:00:32 +0000 Subject: Spelling fix. (This used to be commit 43cd6e5a702bb1004b36a5845e0765851395ebf2) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ba5e9b70d3..e8474118cd 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2249,7 +2249,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ * So we go the easy way, only check after if the account exists. * JFM (2/3/2001), to clear any possible bad understanding (-: * - * We now have seperate script paramaters for adding users/machines so we + * We now have separate script paramaters for adding users/machines so we * now have some sainity-checking to match. */ -- cgit From af365408d5056ea5eeaafd5df23196d9ba19de58 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 25 Nov 2002 06:54:22 +0000 Subject: Instead of walking the entire group database, grabbing all members of each group, testing for membership etc, use the already calculated NT_USER_TOKEN. (which is initgroups() based) So far we only fill out the 'domain' groups - we need to fill out the 'other sids' as well, and we possibly need to filter the list for 'domain groups' only (the old code did that), but Win2k doesn't seem to mind this for now. I also need to find out what the magic '7' is about. Fortunetly JF is in town, so I'll grill him tomorrow :-). Andrew Bartlett (This used to be commit 7e846e7387247f8bc2b07a1a1006014c6978143b) --- source3/rpc_server/srv_netlog_nt.c | 18 ++++++++---------- source3/rpc_server/srv_util.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index dee0866b12..89e46402cf 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -688,16 +688,14 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * pstrcpy(my_name, global_myname()); - /* - * This is the point at which we get the group - * database - we should be getting the gid_t list - * from /etc/group and then turning the uids into - * rids and then into machine sids for this user. - * JRA. - */ - - gids = NULL; - get_domain_user_groups(p->mem_ctx, &num_gids, &gids, server_info->sam_account); + if (!NT_STATUS_IS_OK(status + = nt_token_to_group_list(p->mem_ctx, + &domain_sid, + server_info->ptok, + &num_gids, + &gids))) { + return status; + } init_net_user_info3(p->mem_ctx, usr_info, user_rid, diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 519daff1f6..72a057b91c 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -342,6 +342,7 @@ BOOL get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids, SA DEBUG(0,("get_domain_user_groups: primary gid of user [%s] is not a Domain group !\n", user_name)); DEBUGADD(0,("get_domain_user_groups: You should fix it, NT doesn't like that\n")); + done: *pgids=gids; *numgroups=cur_gid; @@ -350,6 +351,35 @@ BOOL get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids, SA return True; } +/******************************************************************* + gets a domain user's groups from their already-calculated NT_USER_TOKEN + ********************************************************************/ +NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, const DOM_SID *domain_sid, + const NT_USER_TOKEN *nt_token, + int *numgroups, DOM_GID **pgids) +{ + DOM_GID *gids; + int i; + + gids = (DOM_GID *)talloc(mem_ctx, sizeof(*gids) * nt_token->num_sids); + + if (!gids) { + return NT_STATUS_NO_MEMORY; + } + + *numgroups=0; + + for (i=PRIMARY_GROUP_SID_INDEX; i < nt_token->num_sids; i++) { + if (sid_compare_domain(domain_sid, &nt_token->user_sids[i])==0) { + sid_peek_rid(&nt_token->user_sids[i], &(gids[*numgroups].g_rid)); + gids[*numgroups].attr=7; + (*numgroups)++; + } + } + *pgids = gids; + return NT_STATUS_OK; +} + /******************************************************************* Look up a local (domain) rid and return a name and type. ********************************************************************/ -- cgit From f3e3a56ea9085b186af24b0b4e911863fd9ceacc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 29 Nov 2002 02:58:59 +0000 Subject: Merge a bunch of trivial changes from HEAD. The difference remaining should actual functional differences between HEAD and 3.0. - Mostly reformatting - Removal of unecessary #include "smb.h" - Merge of dyn_DRIVERFILE removal - Silly bug fix for python code (This used to be commit d3998307adc50ba50defe610cb656c73799ae3b9) --- source3/rpc_server/srv_reg_nt.c | 1 - source3/rpc_server/srv_samr.c | 1 - 2 files changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index f96de7e533..7435bdb6f7 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -131,7 +131,6 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY if ( fetch_reg_keys( regkey, &subkeys ) == -1 ) { /* don't really know what to return here */ - result = NT_STATUS_NO_SUCH_FILE; } else { diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index bc3b8970d6..ab3d94cf75 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -155,7 +155,6 @@ static BOOL api_samr_set_sec_obj(pipes_struct *p) return False; } - return True; } -- cgit From 1ad8139ef1f9d54b4204f3db67de45e7ac7ee813 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 4 Dec 2002 01:14:34 +0000 Subject: [merge from app_head] XP sends GetPrinterData("ChangeId"). So we now respond accordingly. Possible fix for CR 1147. (This used to be commit 42a2e7d701fd342f2553660eb5094af8723fb50e) --- source3/rpc_server/srv_spoolss_nt.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ce877841d3..126427258f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2292,8 +2292,21 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO status = get_a_printer(&printer, 2, lp_servicename(snum)); if ( !W_ERROR_IS_OK(status) ) goto done; - - status = get_printer_dataex( p->mem_ctx, printer, SPOOL_PRINTERDATA_KEY, value, type, data, needed, *out_size ); + + /* XP sends this and wants to change id value from the PRINTER_INFO_0 */ + + if ( strequal(value, "ChangeId") ) { + *type = REG_DWORD; + *needed = sizeof(uint32); + if ( (*data = (uint8*)talloc(p->mem_ctx, sizeof(uint32))) == NULL) { + status = WERR_NOMEM; + goto done; + } + **data = printer->info_2->changeid; + status = WERR_OK; + } + else + status = get_printer_dataex( p->mem_ctx, printer, SPOOL_PRINTERDATA_KEY, value, type, data, needed, *out_size ); } if (*needed > *out_size) -- cgit From a850e90080cd12fa3c8b92028c8984164494f508 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 4 Dec 2002 01:15:50 +0000 Subject: [merge from app_head] XP sends GetPrinterData("ChangeId"). So we now respond accordingly. Possible fix for CR 1147. (This used to be commit 9424a3b1d1bf11bf38e2bdfd20f1537cf97400ca) --- source3/rpc_server/srv_spoolss_nt.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ad55ea6a49..9e4b31813f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2292,8 +2292,21 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO status = get_a_printer(&printer, 2, lp_servicename(snum)); if ( !W_ERROR_IS_OK(status) ) goto done; - - status = get_printer_dataex( p->mem_ctx, printer, SPOOL_PRINTERDATA_KEY, value, type, data, needed, *out_size ); + + /* XP sends this and wants to change id value from the PRINTER_INFO_0 */ + + if ( strequal(value, "ChangeId") ) { + *type = REG_DWORD; + *needed = sizeof(uint32); + if ( (*data = (uint8*)talloc(p->mem_ctx, sizeof(uint32))) == NULL) { + status = WERR_NOMEM; + goto done; + } + **data = printer->info_2->changeid; + status = WERR_OK; + } + else + status = get_printer_dataex( p->mem_ctx, printer, SPOOL_PRINTERDATA_KEY, value, type, data, needed, *out_size ); } if (*needed > *out_size) -- cgit From 2dd0e949d0a6bf7cf67250516c7fdc91cda24ea3 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Wed, 4 Dec 2002 17:28:51 +0000 Subject: Automatic printer publishing when using APW or choosing 'list in the directory' in printer settings. Currently very little is published, and you cannot unpublish because of a bug in win2k clients. (This used to be commit bbd7c8071a095c4e410f92489050b677a0f0ace1) --- source3/rpc_server/srv_spoolss_nt.c | 137 +++++++++++++++++++++++++++++++----- 1 file changed, 119 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 126427258f..fd22330449 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -30,7 +30,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -/* #define EMULATE_WIN2K_HACK 1 */ #ifndef MAX_OPEN_PRINTER_EXS #define MAX_OPEN_PRINTER_EXS 50 @@ -2153,7 +2152,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint DEBUG(8,("getprinterdata_printer_server:%s\n", value)); - if (!strcmp(value, "W3SvcInstalled")) { + if (!StrCaseCmp(value, "W3SvcInstalled")) { *type = 0x4; if((*data = (uint8 *)talloc_zero(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; @@ -2161,7 +2160,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint return WERR_OK; } - if (!strcmp(value, "BeepEnabled")) { + if (!StrCaseCmp(value, "BeepEnabled")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; @@ -2170,7 +2169,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint return WERR_OK; } - if (!strcmp(value, "EventLog")) { + if (!StrCaseCmp(value, "EventLog")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; @@ -2180,7 +2179,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint return WERR_OK; } - if (!strcmp(value, "NetPopup")) { + if (!StrCaseCmp(value, "NetPopup")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; @@ -2189,20 +2188,20 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint return WERR_OK; } - if (!strcmp(value, "MajorVersion")) { + if (!StrCaseCmp(value, "MajorVersion")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; -#ifndef EMULATE_WIN2K_HACK /* JERRY */ - SIVAL(*data, 0, 2); -#else +#ifdef HAVE_ADS SIVAL(*data, 0, 3); +#else + SIVAL(*data, 0, 2); #endif *needed = 0x4; return WERR_OK; } - if (!strcmp(value, "DefaultSpoolDirectory")) { + if (!StrCaseCmp(value, "DefaultSpoolDirectory")) { fstring string; fstrcpy(string, string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); @@ -2220,7 +2219,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint return WERR_OK; } - if (!strcmp(value, "Architecture")) { + if (!StrCaseCmp(value, "Architecture")) { pstring string="Windows NT x86"; *type = 0x1; *needed = 2*(strlen(string)+1); @@ -2233,8 +2232,35 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint } return WERR_OK; } - - return WERR_INVALID_PARAM; + + if (!StrCaseCmp(value, "DsPresent")) { + *type = 0x4; + if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) + return WERR_NOMEM; + SIVAL(*data, 0, 0x01); + *needed = 0x4; + return WERR_OK; + } + + if (!StrCaseCmp(value, "DNSMachineName")) { + pstring hostname; + + if (!get_myfullname(hostname)) + return WERR_BADFILE; + *type = 0x1; + *needed = 2*(strlen(hostname)+1); + if((*data = (uint8 *)talloc(ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) + return WERR_NOMEM; + memset(*data, 0, (*needed > in_size) ? *needed:in_size); + for (i=0; iglobal_counter = global_counter; printer->total_pages = 0; -#ifndef EMULATE_WIN2K_HACK /* JERRY */ - printer->major_version = 0x0004; /* NT 4 */ - printer->build_version = 0x0565; /* build 1381 */ -#else +#ifdef HAVE_ADS printer->major_version = 0x0005; /* NT 5 */ printer->build_version = 0x0893; /* build 2195 */ +#else + printer->major_version = 0x0004; /* NT 4 */ + printer->build_version = 0x0565; /* build 1381 */ #endif printer->unknown7 = 0x1; printer->unknown8 = 0x0; @@ -4121,6 +4147,18 @@ static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum) return True; } +/******************************************************************** + * construct_printer_info_5 + * fill a printer_info_5 struct + ********************************************************************/ + +static BOOL construct_printer_info_7(PRINTER_INFO_7 *printer) +{ + init_unistr(&printer->guid, ""); + printer->action = 0; + return True; +} + /******************************************************************** Spoolss_enumprinters. ********************************************************************/ @@ -4677,6 +4715,37 @@ static WERROR getprinter_level_5(int snum, NEW_BUFFER *buffer, uint32 offered, u return WERR_OK; } +static WERROR getprinter_level_7(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + PRINTER_INFO_7 *printer=NULL; + + if((printer=(PRINTER_INFO_7*)malloc(sizeof(PRINTER_INFO_7)))==NULL) + return WERR_NOMEM; + + if (!construct_printer_info_7(printer)) + return WERR_NOMEM; + + /* check the required size. */ + *needed += spoolss_size_printer_info_7(printer); + + if (!alloc_buffer_size(buffer, *needed)) { + free_printer_info_7(printer); + return WERR_INSUFFICIENT_BUFFER; + } + + /* fill the buffer with the structures */ + smb_io_printer_info_7("", buffer, printer, 0); + + /* clear memory */ + free_printer_info_7(printer); + + if (*needed > offered) { + return WERR_INSUFFICIENT_BUFFER; + } + + return WERR_OK; +} + /**************************************************************************** ****************************************************************************/ @@ -4712,6 +4781,8 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET return getprinter_level_4(snum, buffer, offered, needed); case 5: return getprinter_level_5(snum, buffer, offered, needed); + case 7: + return getprinter_level_7(snum, buffer, offered, needed); } return WERR_UNKNOWN_LEVEL; } @@ -5850,6 +5921,34 @@ done: return result; } +/**************************************************************************** +****************************************************************************/ +static WERROR publish_or_unpublish_printer(pipes_struct *p, POLICY_HND *handle, + const SPOOL_PRINTER_INFO_LEVEL *info) +{ +#ifdef HAVE_ADS + SPOOL_PRINTER_INFO_LEVEL_7 *info7 = info->info_7; + int snum; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + WERROR result; + + DEBUG(5,("publish_or_unpublish_printer, action = %d\n",info7->action)); + + result = WERR_OK; + + if (!Printer) + return WERR_BADFID; + + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + + nt_printer_publish(snum, info7->action); + + return WERR_OK; +#else + return WERR_UNKNOWN_LEVEL; +#endif +} /**************************************************************************** ****************************************************************************/ @@ -5878,6 +5977,8 @@ WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET case 3: return update_printer_sec(handle, level, info, p, secdesc_ctr); + case 7: + return publish_or_unpublish_printer(p, handle, info); default: return WERR_UNKNOWN_LEVEL; } -- cgit From dae62a3d2ed67998a77ec0ffe4f1540bdcc4fe40 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Wed, 4 Dec 2002 17:40:50 +0000 Subject: Automatic printer publishing when using APW or choosing 'list in the directory' in printer settings. Currently very little is published, and you cannot unpublish because of a bug in win2k clients. (This used to be commit ca6360e8db30fc9be3fe3718c8b49c92dba5ecac) --- source3/rpc_server/srv_spoolss_nt.c | 207 +++++++++++++++++++++++++++--------- 1 file changed, 154 insertions(+), 53 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 9e4b31813f..fd22330449 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -30,7 +30,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -/* #define EMULATE_WIN2K_HACK 1 */ #ifndef MAX_OPEN_PRINTER_EXS #define MAX_OPEN_PRINTER_EXS 50 @@ -962,60 +961,60 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) { SPOOLSS_NOTIFY_MSG *msg = &messages[i]; - /* Are we monitoring this event? */ + /* Are we monitoring this event? */ - if (!is_monitoring_event(p, msg->type, msg->field)) - continue; + if (!is_monitoring_event(p, msg->type, msg->field)) + continue; - DEBUG(10,("process_notify2_message: Sending message type [%x] field [%x] for printer [%s]\n", - msg->type, msg->field, p->dev.handlename)); + DEBUG(10,("process_notify2_message: Sending message type [%x] field [%x] for printer [%s]\n", + msg->type, msg->field, p->dev.handlename)); - /* - * if the is a printer notification handle and not a job notification - * type, then set the id to 0. Other wise just use what was specified - * in the message. - * - * When registering change notification on a print server handle - * we always need to send back the id (snum) matching the printer - * for which the change took place. For change notify registered - * on a printer handle, this does not matter and the id should be 0. - * - * --jerry - */ + /* + * if the is a printer notification handle and not a job notification + * type, then set the id to 0. Other wise just use what was specified + * in the message. + * + * When registering change notification on a print server handle + * we always need to send back the id (snum) matching the printer + * for which the change took place. For change notify registered + * on a printer handle, this does not matter and the id should be 0. + * + * --jerry + */ - if ( ( p->printer_type == PRINTER_HANDLE_IS_PRINTER ) && ( msg->type == PRINTER_NOTIFY_TYPE ) ) - id = 0; - else - id = msg->id; + if ( ( p->printer_type == PRINTER_HANDLE_IS_PRINTER ) && ( msg->type == PRINTER_NOTIFY_TYPE ) ) + id = 0; + else + id = msg->id; - /* Convert unix jobid to smb jobid */ + /* Convert unix jobid to smb jobid */ if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) { - id = sysjob_to_jobid(msg->id); + id = sysjob_to_jobid(msg->id); - if (id == -1) { - DEBUG(3, ("no such unix jobid %d\n", msg->id)); - goto done; + if (id == -1) { + DEBUG(3, ("no such unix jobid %d\n", msg->id)); + goto done; + } } - } construct_info_data( &data[data_len], msg->type, msg->field, id ); - switch(msg->type) { - case PRINTER_NOTIFY_TYPE: + switch(msg->type) { + case PRINTER_NOTIFY_TYPE: if ( !printer_notify_table[msg->field].fn ) - goto done; - printer_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); + goto done; + printer_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); - break; + break; - case JOB_NOTIFY_TYPE: + case JOB_NOTIFY_TYPE: if ( !job_notify_table[msg->field].fn ) - goto done; - job_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); + goto done; + job_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); break; @@ -2153,7 +2152,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint DEBUG(8,("getprinterdata_printer_server:%s\n", value)); - if (!strcmp(value, "W3SvcInstalled")) { + if (!StrCaseCmp(value, "W3SvcInstalled")) { *type = 0x4; if((*data = (uint8 *)talloc_zero(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; @@ -2161,7 +2160,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint return WERR_OK; } - if (!strcmp(value, "BeepEnabled")) { + if (!StrCaseCmp(value, "BeepEnabled")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; @@ -2170,7 +2169,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint return WERR_OK; } - if (!strcmp(value, "EventLog")) { + if (!StrCaseCmp(value, "EventLog")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; @@ -2180,7 +2179,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint return WERR_OK; } - if (!strcmp(value, "NetPopup")) { + if (!StrCaseCmp(value, "NetPopup")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; @@ -2189,20 +2188,20 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint return WERR_OK; } - if (!strcmp(value, "MajorVersion")) { + if (!StrCaseCmp(value, "MajorVersion")) { *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; -#ifndef EMULATE_WIN2K_HACK /* JERRY */ - SIVAL(*data, 0, 2); -#else +#ifdef HAVE_ADS SIVAL(*data, 0, 3); +#else + SIVAL(*data, 0, 2); #endif *needed = 0x4; return WERR_OK; } - if (!strcmp(value, "DefaultSpoolDirectory")) { + if (!StrCaseCmp(value, "DefaultSpoolDirectory")) { fstring string; fstrcpy(string, string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); @@ -2220,7 +2219,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint return WERR_OK; } - if (!strcmp(value, "Architecture")) { + if (!StrCaseCmp(value, "Architecture")) { pstring string="Windows NT x86"; *type = 0x1; *needed = 2*(strlen(string)+1); @@ -2233,8 +2232,35 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint } return WERR_OK; } - - return WERR_INVALID_PARAM; + + if (!StrCaseCmp(value, "DsPresent")) { + *type = 0x4; + if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) + return WERR_NOMEM; + SIVAL(*data, 0, 0x01); + *needed = 0x4; + return WERR_OK; + } + + if (!StrCaseCmp(value, "DNSMachineName")) { + pstring hostname; + + if (!get_myfullname(hostname)) + return WERR_BADFILE; + *type = 0x1; + *needed = 2*(strlen(hostname)+1); + if((*data = (uint8 *)talloc(ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) + return WERR_NOMEM; + memset(*data, 0, (*needed > in_size) ? *needed:in_size); + for (i=0; iglobal_counter = global_counter; printer->total_pages = 0; -#ifndef EMULATE_WIN2K_HACK /* JERRY */ - printer->major_version = 0x0004; /* NT 4 */ - printer->build_version = 0x0565; /* build 1381 */ -#else +#ifdef HAVE_ADS printer->major_version = 0x0005; /* NT 5 */ printer->build_version = 0x0893; /* build 2195 */ +#else + printer->major_version = 0x0004; /* NT 4 */ + printer->build_version = 0x0565; /* build 1381 */ #endif printer->unknown7 = 0x1; printer->unknown8 = 0x0; @@ -4121,6 +4147,18 @@ static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum) return True; } +/******************************************************************** + * construct_printer_info_5 + * fill a printer_info_5 struct + ********************************************************************/ + +static BOOL construct_printer_info_7(PRINTER_INFO_7 *printer) +{ + init_unistr(&printer->guid, ""); + printer->action = 0; + return True; +} + /******************************************************************** Spoolss_enumprinters. ********************************************************************/ @@ -4677,6 +4715,37 @@ static WERROR getprinter_level_5(int snum, NEW_BUFFER *buffer, uint32 offered, u return WERR_OK; } +static WERROR getprinter_level_7(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +{ + PRINTER_INFO_7 *printer=NULL; + + if((printer=(PRINTER_INFO_7*)malloc(sizeof(PRINTER_INFO_7)))==NULL) + return WERR_NOMEM; + + if (!construct_printer_info_7(printer)) + return WERR_NOMEM; + + /* check the required size. */ + *needed += spoolss_size_printer_info_7(printer); + + if (!alloc_buffer_size(buffer, *needed)) { + free_printer_info_7(printer); + return WERR_INSUFFICIENT_BUFFER; + } + + /* fill the buffer with the structures */ + smb_io_printer_info_7("", buffer, printer, 0); + + /* clear memory */ + free_printer_info_7(printer); + + if (*needed > offered) { + return WERR_INSUFFICIENT_BUFFER; + } + + return WERR_OK; +} + /**************************************************************************** ****************************************************************************/ @@ -4712,6 +4781,8 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET return getprinter_level_4(snum, buffer, offered, needed); case 5: return getprinter_level_5(snum, buffer, offered, needed); + case 7: + return getprinter_level_7(snum, buffer, offered, needed); } return WERR_UNKNOWN_LEVEL; } @@ -5850,6 +5921,34 @@ done: return result; } +/**************************************************************************** +****************************************************************************/ +static WERROR publish_or_unpublish_printer(pipes_struct *p, POLICY_HND *handle, + const SPOOL_PRINTER_INFO_LEVEL *info) +{ +#ifdef HAVE_ADS + SPOOL_PRINTER_INFO_LEVEL_7 *info7 = info->info_7; + int snum; + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + WERROR result; + + DEBUG(5,("publish_or_unpublish_printer, action = %d\n",info7->action)); + + result = WERR_OK; + + if (!Printer) + return WERR_BADFID; + + if (!get_printer_snum(p, handle, &snum)) + return WERR_BADFID; + + nt_printer_publish(snum, info7->action); + + return WERR_OK; +#else + return WERR_UNKNOWN_LEVEL; +#endif +} /**************************************************************************** ****************************************************************************/ @@ -5878,6 +5977,8 @@ WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET case 3: return update_printer_sec(handle, level, info, p, secdesc_ctr); + case 7: + return publish_or_unpublish_printer(p, handle, info); default: return WERR_UNKNOWN_LEVEL; } -- cgit From bfd8043a403dfed84bc568685580703a8470738d Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 13 Dec 2002 18:56:48 +0000 Subject: More printer publishing code. - Add published attribute to info2, needed for win clients to work properly - Return proper info on getprinter 7 This means you can now look at the sharing tab of a printer and get correct info about whether it is published or not, and change it. (This used to be commit adda04379ee46f105436262663652f3f576fa3cf) --- source3/rpc_server/srv_spoolss_nt.c | 46 +++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index fd22330449..0e3d69924b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4148,14 +4148,50 @@ static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum) } /******************************************************************** - * construct_printer_info_5 - * fill a printer_info_5 struct + * construct_printer_info_7 + * fill a printer_info_7 struct ********************************************************************/ -static BOOL construct_printer_info_7(PRINTER_INFO_7 *printer) +static BOOL construct_printer_info_7(PRINTER_INFO_7 *printer, int snum) { +#ifdef HAVE_ADS + char *guid_str = NULL; + GUID guid; + ADS_STRUCT *ads; + ADS_STATUS ads_rc; + void *res = NULL; + char *prt_dn; + const char *attrs[] = {"objectGUID", NULL}; + + printer->action = SPOOL_DS_UNPUBLISH; + + ads = ads_init(NULL, NULL, lp_ads_server()); + ads_rc = ads_connect(ads); + ads_rc = ads_find_printer_on_server(ads, &res, lp_servicename(snum), + global_myname()); + if (ADS_ERR_OK(ads_rc) && ads_count_replies(ads, res)) { + prt_dn = ads_get_dn(ads, res); + ads_msgfree(ads, res); + if (prt_dn && + ADS_ERR_OK(ads_search_dn(ads, &res, prt_dn, attrs))) { + ads_rc = ads_search_dn(ads, &res, prt_dn, attrs); + ads_memfree(ads, prt_dn); + ads_pull_guid(ads, res, &guid); + printer->action = SPOOL_DS_PUBLISH; + } + } + + ads_msgfree(ads, res); + + asprintf(&guid_str, "{%s}", uuid_string_static(guid)); + strupper(guid_str); + init_unistr(&printer->guid, guid_str); + +#else + printer->action = SPOOL_DS_UNPUBLISH; init_unistr(&printer->guid, ""); - printer->action = 0; +#endif + return True; } @@ -4722,7 +4758,7 @@ static WERROR getprinter_level_7(int snum, NEW_BUFFER *buffer, uint32 offered, u if((printer=(PRINTER_INFO_7*)malloc(sizeof(PRINTER_INFO_7)))==NULL) return WERR_NOMEM; - if (!construct_printer_info_7(printer)) + if (!construct_printer_info_7(printer, snum)) return WERR_NOMEM; /* check the required size. */ -- cgit From 81a2a307392a12e5ec464e524d2948611e23b943 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 13 Dec 2002 19:01:27 +0000 Subject: More printer publishing code. - Add published attribute to info2, needed for win clients to work properly - Return proper info on getprinter 7 This means you can now look at the sharing tab of a printer and get correct info about whether it is published or not, and change it. (This used to be commit d57bddc9b22e809c79294c7eacbd5d0f115fe990) --- source3/rpc_server/srv_spoolss_nt.c | 46 +++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index fd22330449..0e3d69924b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4148,14 +4148,50 @@ static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum) } /******************************************************************** - * construct_printer_info_5 - * fill a printer_info_5 struct + * construct_printer_info_7 + * fill a printer_info_7 struct ********************************************************************/ -static BOOL construct_printer_info_7(PRINTER_INFO_7 *printer) +static BOOL construct_printer_info_7(PRINTER_INFO_7 *printer, int snum) { +#ifdef HAVE_ADS + char *guid_str = NULL; + GUID guid; + ADS_STRUCT *ads; + ADS_STATUS ads_rc; + void *res = NULL; + char *prt_dn; + const char *attrs[] = {"objectGUID", NULL}; + + printer->action = SPOOL_DS_UNPUBLISH; + + ads = ads_init(NULL, NULL, lp_ads_server()); + ads_rc = ads_connect(ads); + ads_rc = ads_find_printer_on_server(ads, &res, lp_servicename(snum), + global_myname()); + if (ADS_ERR_OK(ads_rc) && ads_count_replies(ads, res)) { + prt_dn = ads_get_dn(ads, res); + ads_msgfree(ads, res); + if (prt_dn && + ADS_ERR_OK(ads_search_dn(ads, &res, prt_dn, attrs))) { + ads_rc = ads_search_dn(ads, &res, prt_dn, attrs); + ads_memfree(ads, prt_dn); + ads_pull_guid(ads, res, &guid); + printer->action = SPOOL_DS_PUBLISH; + } + } + + ads_msgfree(ads, res); + + asprintf(&guid_str, "{%s}", uuid_string_static(guid)); + strupper(guid_str); + init_unistr(&printer->guid, guid_str); + +#else + printer->action = SPOOL_DS_UNPUBLISH; init_unistr(&printer->guid, ""); - printer->action = 0; +#endif + return True; } @@ -4722,7 +4758,7 @@ static WERROR getprinter_level_7(int snum, NEW_BUFFER *buffer, uint32 offered, u if((printer=(PRINTER_INFO_7*)malloc(sizeof(PRINTER_INFO_7)))==NULL) return WERR_NOMEM; - if (!construct_printer_info_7(printer)) + if (!construct_printer_info_7(printer, snum)) return WERR_NOMEM; /* check the required size. */ -- cgit From 5f9348d4fcff534e6efb129fcab5d81ac4f9ba6e Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 13 Dec 2002 21:54:09 +0000 Subject: Store printer guid in the dsspooler registry key so we don't have to query the directory server every time someone asks (This used to be commit f0fc4e30f6284565de404a20450a587cd3fe00a5) --- source3/rpc_server/srv_spoolss_nt.c | 43 ++++++++----------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0e3d69924b..6dd4352cbc 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4154,43 +4154,18 @@ static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum) static BOOL construct_printer_info_7(PRINTER_INFO_7 *printer, int snum) { -#ifdef HAVE_ADS char *guid_str = NULL; GUID guid; - ADS_STRUCT *ads; - ADS_STATUS ads_rc; - void *res = NULL; - char *prt_dn; - const char *attrs[] = {"objectGUID", NULL}; - - printer->action = SPOOL_DS_UNPUBLISH; - - ads = ads_init(NULL, NULL, lp_ads_server()); - ads_rc = ads_connect(ads); - ads_rc = ads_find_printer_on_server(ads, &res, lp_servicename(snum), - global_myname()); - if (ADS_ERR_OK(ads_rc) && ads_count_replies(ads, res)) { - prt_dn = ads_get_dn(ads, res); - ads_msgfree(ads, res); - if (prt_dn && - ADS_ERR_OK(ads_search_dn(ads, &res, prt_dn, attrs))) { - ads_rc = ads_search_dn(ads, &res, prt_dn, attrs); - ads_memfree(ads, prt_dn); - ads_pull_guid(ads, res, &guid); - printer->action = SPOOL_DS_PUBLISH; - } - } - - ads_msgfree(ads, res); - asprintf(&guid_str, "{%s}", uuid_string_static(guid)); - strupper(guid_str); - init_unistr(&printer->guid, guid_str); - -#else - printer->action = SPOOL_DS_UNPUBLISH; - init_unistr(&printer->guid, ""); -#endif + if (is_printer_published(snum, &guid)) { + asprintf(&guid_str, "{%s}", uuid_string_static(guid)); + strupper(guid_str); + init_unistr(&printer->guid, guid_str); + printer->action = SPOOL_DS_PUBLISH; + } else { + init_unistr(&printer->guid, ""); + printer->action = SPOOL_DS_UNPUBLISH; + } return True; } -- cgit From f201af19250895b278568df91aad58cea247e543 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 13 Dec 2002 21:56:34 +0000 Subject: Store printer guid in the dsspooler registry key so we don't have to query the directory server every time someone asks (This used to be commit dd81003bddc17522041e1cd2f0484e1760493e4a) --- source3/rpc_server/srv_spoolss_nt.c | 43 ++++++++----------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0e3d69924b..6dd4352cbc 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4154,43 +4154,18 @@ static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum) static BOOL construct_printer_info_7(PRINTER_INFO_7 *printer, int snum) { -#ifdef HAVE_ADS char *guid_str = NULL; GUID guid; - ADS_STRUCT *ads; - ADS_STATUS ads_rc; - void *res = NULL; - char *prt_dn; - const char *attrs[] = {"objectGUID", NULL}; - - printer->action = SPOOL_DS_UNPUBLISH; - - ads = ads_init(NULL, NULL, lp_ads_server()); - ads_rc = ads_connect(ads); - ads_rc = ads_find_printer_on_server(ads, &res, lp_servicename(snum), - global_myname()); - if (ADS_ERR_OK(ads_rc) && ads_count_replies(ads, res)) { - prt_dn = ads_get_dn(ads, res); - ads_msgfree(ads, res); - if (prt_dn && - ADS_ERR_OK(ads_search_dn(ads, &res, prt_dn, attrs))) { - ads_rc = ads_search_dn(ads, &res, prt_dn, attrs); - ads_memfree(ads, prt_dn); - ads_pull_guid(ads, res, &guid); - printer->action = SPOOL_DS_PUBLISH; - } - } - - ads_msgfree(ads, res); - asprintf(&guid_str, "{%s}", uuid_string_static(guid)); - strupper(guid_str); - init_unistr(&printer->guid, guid_str); - -#else - printer->action = SPOOL_DS_UNPUBLISH; - init_unistr(&printer->guid, ""); -#endif + if (is_printer_published(snum, &guid)) { + asprintf(&guid_str, "{%s}", uuid_string_static(guid)); + strupper(guid_str); + init_unistr(&printer->guid, guid_str); + printer->action = SPOOL_DS_PUBLISH; + } else { + init_unistr(&printer->guid, ""); + printer->action = SPOOL_DS_UNPUBLISH; + } return True; } -- cgit From b1cfbb0f69e9aeefdc037760e5738c3c4bc4fc05 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 17 Dec 2002 21:35:56 +0000 Subject: * fix memory leak when constructing an driver_level_6 structure and no dependent files (working on smbd memory leak). No CR# yet. (This used to be commit f017fa7c478f87165b7b6aa83059fe6fad29ac15) --- source3/rpc_server/srv_spoolss_nt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 6dd4352cbc..b5c5749f3c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4928,8 +4928,10 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, char *s pstrcpy( line, v ); DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); + + /* add one extra unit16 for the second terminating NULL */ - if ( (tuary=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL ) { + if ( (tuary=Realloc(*uni_array, (j+1+strlen(line)+2)*sizeof(uint16))) == NULL ) { DEBUG(2,("init_unistr_array: Realloc error\n" )); return 0; } else @@ -4943,6 +4945,9 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, char *s } if (*uni_array) { + /* special case for ""; we need to add both NULL's here */ + if (!j) + (*uni_array)[j++]=0x0000; (*uni_array)[j]=0x0000; } @@ -5172,6 +5177,7 @@ static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fill_printer_driver_info_6(info, driver, servername); free_a_printer(&printer,2); + free_a_printer_driver(driver, 3); return WERR_OK; } -- cgit From 1c318819cc043b472596186b255d75b12f8abbf8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 17 Dec 2002 21:36:31 +0000 Subject: * fix memory leak when constructing an driver_level_6 structure and no dependent files (working on smbd memory leak). No CR# yet. (This used to be commit 416fd947da4463f5d4dc336dfddf5ce35f50fae9) --- source3/rpc_server/srv_spoolss_nt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 6dd4352cbc..751ff00a04 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4929,7 +4929,9 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, char *s DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); - if ( (tuary=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL ) { + /* add one extra unit16 for the second terminating NULL */ + + if ( (tuary=Realloc(*uni_array, (j+1+strlen(line)+2)*sizeof(uint16))) == NULL ) { DEBUG(2,("init_unistr_array: Realloc error\n" )); return 0; } else @@ -4943,6 +4945,9 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, char *s } if (*uni_array) { + /* special case for ""; we need to add both NULL's here */ + if (!j) + (*uni_array)[j++]=0x0000; (*uni_array)[j]=0x0000; } @@ -5172,6 +5177,7 @@ static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fill_printer_driver_info_6(info, driver, servername); free_a_printer(&printer,2); + free_a_printer_driver(driver, 3); return WERR_OK; } -- cgit From 4ae77aa17ce192eff17f91c2712b97cbbe15671a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 20 Dec 2002 01:29:08 +0000 Subject: Whitespace syncup. (This used to be commit 7a4a2cb8e86ae8ed0bd877f0cfa324e23b96593a) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 751ff00a04..b5c5749f3c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4928,7 +4928,7 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, char *s pstrcpy( line, v ); DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); - + /* add one extra unit16 for the second terminating NULL */ if ( (tuary=Realloc(*uni_array, (j+1+strlen(line)+2)*sizeof(uint16))) == NULL ) { -- cgit From ef8bd7c4f7ae8192ea05db070962ecf0ff3615f3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 20 Dec 2002 20:21:31 +0000 Subject: Forward port the change to talloc_init() to make all talloc contexts named. Ensure we can query them. Jeremy. (This used to be commit 09a218a9f6fb0bd922940467bf8500eb4f1bcf84) --- source3/rpc_server/srv_pipe_hnd.c | 4 ++-- source3/rpc_server/srv_samr_nt.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 2 +- source3/rpc_server/srv_srvsvc_nt.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 1695419687..6cdb6836eb 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -293,7 +293,7 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, ZERO_STRUCTP(p); - if ((p->mem_ctx = talloc_init()) == NULL) { + if ((p->mem_ctx = talloc_init("pipe %s %p", pipe_name, p)) == NULL) { DEBUG(0,("open_rpc_pipe_p: talloc_init failed.\n")); SAFE_FREE(p); return NULL; @@ -544,7 +544,7 @@ void free_pipe_context(pipes_struct *p) DEBUG(3,("free_pipe_context: destroying talloc pool of size %u\n", talloc_pool_size(p->mem_ctx) )); talloc_destroy_pool(p->mem_ctx); } else { - p->mem_ctx = talloc_init(); + p->mem_ctx = talloc_init("pipe %s %p", p->name, p); if (p->mem_ctx == NULL) p->fault_state = True; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 603dcd0017..fd152aa3b3 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -134,7 +134,7 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) fstrcpy(sid_str,"(NULL)"); } - mem_ctx = talloc_init_named("samr_info for domain sid %s", sid_str); + mem_ctx = talloc_init("samr_info for domain sid %s", sid_str); if ((info = (struct samr_info *)talloc(mem_ctx, sizeof(struct samr_info))) == NULL) return NULL; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b5c5749f3c..68a2dcb83d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -776,7 +776,7 @@ static void notify_msg_ctr_init( SPOOLSS_NOTIFY_MSG_CTR *ctr ) if ( !ctr ) return; - ctr->ctx = talloc_init(); + ctr->ctx = talloc_init("notify_msg_ctr_init %p", ctr); return; } diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 0384bb81a3..69f82bb96f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -237,7 +237,7 @@ static BOOL set_share_security(TALLOC_CTX *ctx, const char *share_name, SEC_DESC fstring key; BOOL ret = False; - mem_ctx = talloc_init(); + mem_ctx = talloc_init("set_share_security"); if (mem_ctx == NULL) return False; @@ -327,7 +327,7 @@ BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, u NT_USER_TOKEN *token = NULL; BOOL ret = True; - mem_ctx = talloc_init(); + mem_ctx = talloc_init("share_access_check"); if (mem_ctx == NULL) return False; -- cgit From 7f23546730e49569d41a5edd0c47bb559c4f812d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 20 Dec 2002 20:23:06 +0000 Subject: Forward port the change to talloc_init() to make all talloc contexts named. Ensure we can query them. Jeremy. (This used to be commit 842e08e52a665ae678eea239759bb2de1a0d7b33) --- source3/rpc_server/srv_pipe_hnd.c | 4 ++-- source3/rpc_server/srv_samr_nt.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 2 +- source3/rpc_server/srv_srvsvc_nt.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 1695419687..6cdb6836eb 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -293,7 +293,7 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, ZERO_STRUCTP(p); - if ((p->mem_ctx = talloc_init()) == NULL) { + if ((p->mem_ctx = talloc_init("pipe %s %p", pipe_name, p)) == NULL) { DEBUG(0,("open_rpc_pipe_p: talloc_init failed.\n")); SAFE_FREE(p); return NULL; @@ -544,7 +544,7 @@ void free_pipe_context(pipes_struct *p) DEBUG(3,("free_pipe_context: destroying talloc pool of size %u\n", talloc_pool_size(p->mem_ctx) )); talloc_destroy_pool(p->mem_ctx); } else { - p->mem_ctx = talloc_init(); + p->mem_ctx = talloc_init("pipe %s %p", p->name, p); if (p->mem_ctx == NULL) p->fault_state = True; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e8474118cd..3e3baedb9a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -134,7 +134,7 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) fstrcpy(sid_str,"(NULL)"); } - mem_ctx = talloc_init_named("samr_info for domain sid %s", sid_str); + mem_ctx = talloc_init("samr_info for domain sid %s", sid_str); if ((info = (struct samr_info *)talloc(mem_ctx, sizeof(struct samr_info))) == NULL) return NULL; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b5c5749f3c..68a2dcb83d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -776,7 +776,7 @@ static void notify_msg_ctr_init( SPOOLSS_NOTIFY_MSG_CTR *ctr ) if ( !ctr ) return; - ctr->ctx = talloc_init(); + ctr->ctx = talloc_init("notify_msg_ctr_init %p", ctr); return; } diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 0384bb81a3..69f82bb96f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -237,7 +237,7 @@ static BOOL set_share_security(TALLOC_CTX *ctx, const char *share_name, SEC_DESC fstring key; BOOL ret = False; - mem_ctx = talloc_init(); + mem_ctx = talloc_init("set_share_security"); if (mem_ctx == NULL) return False; @@ -327,7 +327,7 @@ BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, u NT_USER_TOKEN *token = NULL; BOOL ret = True; - mem_ctx = talloc_init(); + mem_ctx = talloc_init("share_access_check"); if (mem_ctx == NULL) return False; -- cgit From 60667264b71d624ec45f567170b85589992567ed Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 30 Dec 2002 04:41:27 +0000 Subject: the shutdown call does not have a 16 bit flags, but 2 byte representing booleans this commit change the structure and code to reflect this some test revelead I'm right. some other revelead currently the abort shutdown does not work against my test machine even if it returns successfully ... need investigation (This used to be commit c5892b656dedd0367adc33d9606311d1dde99a58) --- source3/rpc_server/srv_reg_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 7435bdb6f7..215d468404 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -590,9 +590,9 @@ NTSTATUS _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u /* timeout */ snprintf(timeout, sizeof(timeout), "%d", q_u->timeout); /* reboot */ - snprintf(r, sizeof(r), (q_u->flags & REG_REBOOT_ON_SHUTDOWN)?SHUTDOWN_R_STRING:""); + snprintf(r, sizeof(r), (q_u->reboot) ? SHUTDOWN_R_STRING : ""); /* force */ - snprintf(f, sizeof(f), (q_u->flags & REG_FORCE_SHUTDOWN)?SHUTDOWN_F_STRING:""); + snprintf(f, sizeof(f), (q_u->force) ? SHUTDOWN_F_STRING : ""); pstrcpy(shutdown_script, lp_shutdown_script()); -- cgit From 60f9614400a073626344be6e0dedb8d15611cfff Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 1 Jan 2003 04:19:34 +0000 Subject: Move our password change code along a little - use NTSTATUS, and implmenet minimum password age and min password length for all password changes. Andrew Bartlett (This used to be commit 028f808c032becfa4618924cb301a4af2708fa96) --- source3/rpc_server/srv_samr_nt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 3e3baedb9a..b4cd8ae5b5 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1536,9 +1536,8 @@ NTSTATUS _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_ * is case insensitive. */ - if (!pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, - q_u->nt_newpass.pass, q_u->nt_oldhash.hash)) - r_u->status = NT_STATUS_WRONG_PASSWORD; + r_u->status = pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, + q_u->nt_newpass.pass, q_u->nt_oldhash.hash); init_samr_r_chgpasswd_user(r_u, r_u->status); -- cgit From 6d66fb308ab85bd9691d541764e683e6040cf724 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 2 Jan 2003 09:07:17 +0000 Subject: BIG patch... This patch makes Samba compile cleanly with -Wwrite-strings. - That is, all string literals are marked as 'const'. These strings are always read only, this just marks them as such for passing to other functions. What is most supprising is that I didn't need to change more than a few lines of code (all in 'net', which got a small cleanup of net.h and extern variables). The rest is just adding a lot of 'const'. As far as I can tell, I have not added any new warnings - apart from making all of tdbutil.c's function const (so they warn for adding that const string to struct). Andrew Bartlett (This used to be commit 92a777d0eaa4fb3a1c7835816f93c6bdd456816d) --- source3/rpc_server/srv_lsa.c | 2 +- source3/rpc_server/srv_netlog_nt.c | 6 +++--- source3/rpc_server/srv_pipe.c | 6 +++--- source3/rpc_server/srv_reg_nt.c | 4 ++-- source3/rpc_server/srv_spoolss_nt.c | 30 +++++++++++++++--------------- source3/rpc_server/srv_srvsvc_nt.c | 4 ++-- source3/rpc_server/srv_util.c | 6 +++--- 7 files changed, 29 insertions(+), 29 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index e3495576c9..a2c2290fb7 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -645,7 +645,7 @@ static BOOL api_lsa_query_info2(pipes_struct *p) \PIPE\ntlsa commands ***************************************************************************/ -static struct api_struct api_lsa_cmds[] = +static const struct api_struct api_lsa_cmds[] = { { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 }, { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy }, diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 89e46402cf..c3d48a6527 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -105,7 +105,7 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C uint32 pdc_connection_status = 0x0; uint32 logon_attempts = 0x0; uint32 tc_status = ERROR_NO_LOGON_SERVERS; - char *trusted_domain = "test_domain"; + const char *trusted_domain = "test_domain"; DEBUG(0, ("*** net long ctrl2 %d, %d, %d\n", q_u->function_code, q_u->query_level, q_u->switch_value)); @@ -132,7 +132,7 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C NTSTATUS _net_trust_dom_list(pipes_struct *p, NET_Q_TRUST_DOM_LIST *q_u, NET_R_TRUST_DOM_LIST *r_u) { - char *trusted_domain = "test_domain"; + const char *trusted_domain = "test_domain"; uint32 num_trust_domains = 1; DEBUG(6,("_net_trust_dom_list: %d\n", __LINE__)); @@ -565,7 +565,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain)); - pstrcpy(current_user_info.smb_name, nt_username); + fstrcpy(current_user_info.smb_name, nt_username); sub_set_smb_name(nt_username); /* diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 5a935be279..8aaab43461 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -457,8 +457,8 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); struct api_cmd { - char * pipe_clnt_name; - char * pipe_srv_name; + const char * pipe_clnt_name; + const char * pipe_srv_name; BOOL (*fn) (pipes_struct *); }; @@ -1173,7 +1173,7 @@ BOOL api_pipe_request(pipes_struct *p) Calls the underlying RPC function for a named pipe. ********************************************************************/ -BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, +BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, const struct api_struct *api_rpc_cmds) { int fn_num; diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 215d468404..cbf237251e 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -80,7 +80,7 @@ static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) *******************************************************************/ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY *parent, - char *subkeyname, uint32 access_granted ) + const char *subkeyname, uint32 access_granted ) { REGISTRY_KEY *regkey = NULL; NTSTATUS result = NT_STATUS_OK; @@ -341,7 +341,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) { NTSTATUS status = NT_STATUS_NO_SUCH_FILE; fstring name; - char *value_ascii = ""; + const char *value_ascii = ""; fstring value; int value_length; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 68a2dcb83d..291ed50ddd 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -42,7 +42,7 @@ /* Table to map the driver version */ /* to OS */ -char * drv_ver_to_os[] = { +static const char * drv_ver_to_os[] = { "WIN9X", /* driver version/cversion 0 */ "", /* unused ? */ "WINNT", /* driver version/cversion 2 */ @@ -50,8 +50,8 @@ char * drv_ver_to_os[] = { }; struct table_node { - char *long_archi; - char *short_archi; + const char *long_archi; + const char *short_archi; int version; }; @@ -712,7 +712,7 @@ static void notify_system_time(struct spoolss_notify_msg *msg, } struct notify2_message_table { - char *name; + const char *name; void (*fn)(struct spoolss_notify_msg *msg, SPOOL_NOTIFY_INFO_DATA *data, TALLOC_CTX *mem_ctx); }; @@ -1708,7 +1708,7 @@ static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *u return result; } -BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, +BOOL convert_devicemode(const char *printername, const DEVICEMODE *devmode, NT_DEVICEMODE **pp_nt_devmode) { NT_DEVICEMODE *nt_devmode = *pp_nt_devmode; @@ -2085,7 +2085,7 @@ done: ***************************************************************************/ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printer, - char *key, char *value, uint32 *type, uint8 **data, + const char *key, const char *value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size ) { REGISTRY_VALUE *val; @@ -2121,7 +2121,7 @@ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printe Internal routine for removing printerdata ***************************************************************************/ -static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, char *key, char *value ) +static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value ) { delete_printer_data( printer->info_2, key, value ); @@ -2132,7 +2132,7 @@ static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, char *key, Internal routine for storing printerdata ***************************************************************************/ -static WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, char *key, char *value, +static WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value, uint32 type, uint8 *data, int real_len ) { delete_printer_data( printer->info_2, key, value ); @@ -3094,7 +3094,7 @@ static void spoolss_notify_job_status_string(int snum, * Now we're returning job status codes we just return a "" here. JRA. */ - char *p = ""; + const char *p = ""; pstring temp; uint32 len; @@ -3247,7 +3247,7 @@ struct s_notify_info_data_table { uint16 type; uint16 field; - char *name; + const char *name; uint32 size; void (*fn) (int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -3258,7 +3258,7 @@ struct s_notify_info_data_table whether the notification data is a pointer to a variable sized buffer, a one value uint32 or a two value uint32. */ -struct s_notify_info_data_table notify_info_data_table[] = +static const struct s_notify_info_data_table notify_info_data_table[] = { { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", NOTIFY_STRING, spoolss_notify_server_name }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, "PRINTER_NOTIFY_PRINTER_NAME", NOTIFY_STRING, spoolss_notify_printer_name }, @@ -4897,11 +4897,11 @@ static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fst * convert an array of ascii string to a UNICODE string ********************************************************************/ -static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, char *servername) +static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, const char *servername) { int i=0; int j=0; - char *v; + const char *v; pstring line; uint16 *tuary; @@ -6839,7 +6839,7 @@ WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * /**************************************************************************** ****************************************************************************/ -static void fill_port_1(PORT_INFO_1 *port, char *name) +static void fill_port_1(PORT_INFO_1 *port, const char *name) { init_unistr(&port->port_name, name); } @@ -6847,7 +6847,7 @@ static void fill_port_1(PORT_INFO_1 *port, char *name) /**************************************************************************** ****************************************************************************/ -static void fill_port_2(PORT_INFO_2 *port, char *name) +static void fill_port_2(PORT_INFO_2 *port, const char *name) { init_unistr(&port->port_name, name); init_unistr(&port->monitor_name, "Local Monitor"); diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 69f82bb96f..e0a575f143 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -128,7 +128,7 @@ static TDB_CONTEXT *share_tdb; /* used for share security descriptors */ BOOL share_info_db_init(void) { static pid_t local_pid; - char *vstring = "INFO/version"; + const char *vstring = "INFO/version"; int32 vers_id; if (share_tdb && local_pid == sys_getpid()) @@ -1008,7 +1008,7 @@ static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *sto static void init_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1, uint32 id, uint32 type, uint32 num_opens, uint32 num_users, uint32 open_time, - char *usr_name, char *net_name) + const char *usr_name, const char *net_name) { init_srv_conn_info1(se1 , id, type, num_opens, num_users, open_time, usr_name, net_name); init_srv_conn_info1_str(str1, usr_name, net_name); diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 72a057b91c..4eba9c7d1f 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -485,7 +485,7 @@ NTSTATUS local_lookup_user_name(uint32 rid, char *user_name, uint32 *type) ********************************************************************/ NTSTATUS local_lookup_group_rid(char *group_name, uint32 *rid) { - char *grp_name; + const char *grp_name; int i = -1; /* start do loop at -1 */ do /* find, if it exists, a group rid for the group name*/ @@ -502,9 +502,9 @@ NTSTATUS local_lookup_group_rid(char *group_name, uint32 *rid) /******************************************************************* Look up a local (BUILTIN) alias name and return a rid ********************************************************************/ -NTSTATUS local_lookup_alias_rid(char *alias_name, uint32 *rid) +NTSTATUS local_lookup_alias_rid(const char *alias_name, uint32 *rid) { - char *als_name; + const char *als_name; int i = -1; /* start do loop at -1 */ do /* find, if it exists, a alias rid for the alias name*/ -- cgit From ff18825765440497a4eda97d6aaf7ff327db64bb Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 2 Jan 2003 13:10:25 +0000 Subject: We already have one function to move unistr2 -> multibyte-static, so we don't need a second just for pdb. Also, remove magic 'is lp_guest_account' test - the magic RID should be up to the passdb backend to set. Andrew Bartlett (This used to be commit f71c8338d35a2e8c73c3d8006ea6858cb522c715) --- source3/rpc_server/srv_samr_util.c | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 97c7b67839..d7ead0d15f 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -91,7 +91,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) /* Backend should check this for sainity */ if (from->hdr_user_name.buffer) { old_string = pdb_get_username(to); - new_string = pdb_unistr2_convert(&from->uni_user_name); + new_string = unistr2_static(&from->uni_user_name); DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); if (STRING_CHANGED) pdb_set_username(to , new_string, PDB_CHANGED); @@ -99,7 +99,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_full_name.buffer) { old_string = pdb_get_fullname(to); - new_string = pdb_unistr2_convert(&from->uni_full_name); + new_string = unistr2_static(&from->uni_full_name); DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_fullname(to , new_string, PDB_CHANGED); @@ -107,7 +107,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_home_dir.buffer) { old_string = pdb_get_homedir(to); - new_string = pdb_unistr2_convert(&from->uni_home_dir); + new_string = unistr2_static(&from->uni_home_dir); DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_homedir(to , new_string, PDB_CHANGED); @@ -115,7 +115,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_dir_drive.buffer) { old_string = pdb_get_dir_drive(to); - new_string = pdb_unistr2_convert(&from->uni_dir_drive); + new_string = unistr2_static(&from->uni_dir_drive); DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_dir_drive(to , new_string, PDB_CHANGED); @@ -123,7 +123,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_logon_script.buffer) { old_string = pdb_get_logon_script(to); - new_string = pdb_unistr2_convert(&from->uni_logon_script); + new_string = unistr2_static(&from->uni_logon_script); DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_logon_script(to , new_string, PDB_CHANGED); @@ -131,7 +131,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_profile_path.buffer) { old_string = pdb_get_profile_path(to); - new_string = pdb_unistr2_convert(&from->uni_profile_path); + new_string = unistr2_static(&from->uni_profile_path); DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_profile_path(to , new_string, PDB_CHANGED); @@ -139,7 +139,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_acct_desc.buffer) { old_string = pdb_get_acct_desc(to); - new_string = pdb_unistr2_convert(&from->uni_acct_desc); + new_string = unistr2_static(&from->uni_acct_desc); DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_acct_desc(to , new_string, PDB_CHANGED); @@ -147,7 +147,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_workstations.buffer) { old_string = pdb_get_workstations(to); - new_string = pdb_unistr2_convert(&from->uni_workstations); + new_string = unistr2_static(&from->uni_workstations); DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_workstations(to , new_string, PDB_CHANGED); @@ -155,7 +155,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_unknown_str.buffer) { old_string = pdb_get_unknown_str(to); - new_string = pdb_unistr2_convert(&from->uni_unknown_str); + new_string = unistr2_static(&from->uni_unknown_str); DEBUG(10,("INFO_21 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_unknown_str(to , new_string, PDB_CHANGED); @@ -163,7 +163,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_munged_dial.buffer) { old_string = pdb_get_munged_dial(to); - new_string = pdb_unistr2_convert(&from->uni_munged_dial); + new_string = unistr2_static(&from->uni_munged_dial); DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_munged_dial(to , new_string, PDB_CHANGED); @@ -293,7 +293,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) /* Backend should check this for sainity */ if (from->hdr_user_name.buffer) { old_string = pdb_get_username(to); - new_string = pdb_unistr2_convert(&from->uni_user_name); + new_string = unistr2_static(&from->uni_user_name); DEBUG(10,("INFO_23 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); if (STRING_CHANGED) pdb_set_username(to , new_string, PDB_CHANGED); @@ -301,7 +301,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_full_name.buffer) { old_string = pdb_get_fullname(to); - new_string = pdb_unistr2_convert(&from->uni_full_name); + new_string = unistr2_static(&from->uni_full_name); DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_fullname(to , new_string, PDB_CHANGED); @@ -309,7 +309,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_home_dir.buffer) { old_string = pdb_get_homedir(to); - new_string = pdb_unistr2_convert(&from->uni_home_dir); + new_string = unistr2_static(&from->uni_home_dir); DEBUG(10,("INFO_23 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_homedir(to , new_string, PDB_CHANGED); @@ -317,7 +317,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_dir_drive.buffer) { old_string = pdb_get_dir_drive(to); - new_string = pdb_unistr2_convert(&from->uni_dir_drive); + new_string = unistr2_static(&from->uni_dir_drive); DEBUG(10,("INFO_23 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_dir_drive(to , new_string, PDB_CHANGED); @@ -325,7 +325,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_logon_script.buffer) { old_string = pdb_get_logon_script(to); - new_string = pdb_unistr2_convert(&from->uni_logon_script); + new_string = unistr2_static(&from->uni_logon_script); DEBUG(10,("INFO_23 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_logon_script(to , new_string, PDB_CHANGED); @@ -333,7 +333,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_profile_path.buffer) { old_string = pdb_get_profile_path(to); - new_string = pdb_unistr2_convert(&from->uni_profile_path); + new_string = unistr2_static(&from->uni_profile_path); DEBUG(10,("INFO_23 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_profile_path(to , new_string, PDB_CHANGED); @@ -341,7 +341,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_acct_desc.buffer) { old_string = pdb_get_acct_desc(to); - new_string = pdb_unistr2_convert(&from->uni_acct_desc); + new_string = unistr2_static(&from->uni_acct_desc); DEBUG(10,("INFO_23 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_acct_desc(to , new_string, PDB_CHANGED); @@ -349,7 +349,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_workstations.buffer) { old_string = pdb_get_workstations(to); - new_string = pdb_unistr2_convert(&from->uni_workstations); + new_string = unistr2_static(&from->uni_workstations); DEBUG(10,("INFO_23 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_workstations(to , new_string, PDB_CHANGED); @@ -357,7 +357,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_unknown_str.buffer) { old_string = pdb_get_unknown_str(to); - new_string = pdb_unistr2_convert(&from->uni_unknown_str); + new_string = unistr2_static(&from->uni_unknown_str); DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_unknown_str(to , new_string, PDB_CHANGED); @@ -365,7 +365,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_munged_dial.buffer) { old_string = pdb_get_munged_dial(to); - new_string = pdb_unistr2_convert(&from->uni_munged_dial); + new_string = unistr2_static(&from->uni_munged_dial); DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_munged_dial(to , new_string, PDB_CHANGED); -- cgit From 634c54310c92c48dd4eceec602e230a021bdcfc5 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 3 Jan 2003 08:28:12 +0000 Subject: Merge from HEAD - make Samba compile with -Wwrite-strings without additional warnings. (Adds a lot of const). Andrew Bartlett (This used to be commit 3a7458f9472432ef12c43008414925fd1ce8ea0c) --- source3/rpc_server/srv_lsa.c | 2 +- source3/rpc_server/srv_netlog_nt.c | 4 ++-- source3/rpc_server/srv_pipe.c | 6 +++--- source3/rpc_server/srv_reg_nt.c | 4 ++-- source3/rpc_server/srv_spoolss_nt.c | 30 +++++++++++++++--------------- source3/rpc_server/srv_srvsvc_nt.c | 4 ++-- source3/rpc_server/srv_util.c | 6 +++--- 7 files changed, 28 insertions(+), 28 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index e3495576c9..a2c2290fb7 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -645,7 +645,7 @@ static BOOL api_lsa_query_info2(pipes_struct *p) \PIPE\ntlsa commands ***************************************************************************/ -static struct api_struct api_lsa_cmds[] = +static const struct api_struct api_lsa_cmds[] = { { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 }, { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy }, diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index dee0866b12..3892a8c982 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -105,7 +105,7 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C uint32 pdc_connection_status = 0x0; uint32 logon_attempts = 0x0; uint32 tc_status = ERROR_NO_LOGON_SERVERS; - char *trusted_domain = "test_domain"; + const char *trusted_domain = "test_domain"; DEBUG(0, ("*** net long ctrl2 %d, %d, %d\n", q_u->function_code, q_u->query_level, q_u->switch_value)); @@ -132,7 +132,7 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C NTSTATUS _net_trust_dom_list(pipes_struct *p, NET_Q_TRUST_DOM_LIST *q_u, NET_R_TRUST_DOM_LIST *r_u) { - char *trusted_domain = "test_domain"; + const char *trusted_domain = "test_domain"; uint32 num_trust_domains = 1; DEBUG(6,("_net_trust_dom_list: %d\n", __LINE__)); diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 5a935be279..8aaab43461 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -457,8 +457,8 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); struct api_cmd { - char * pipe_clnt_name; - char * pipe_srv_name; + const char * pipe_clnt_name; + const char * pipe_srv_name; BOOL (*fn) (pipes_struct *); }; @@ -1173,7 +1173,7 @@ BOOL api_pipe_request(pipes_struct *p) Calls the underlying RPC function for a named pipe. ********************************************************************/ -BOOL api_rpcTNP(pipes_struct *p, char *rpc_name, +BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, const struct api_struct *api_rpc_cmds) { int fn_num; diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 7435bdb6f7..c9158a9cf9 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -80,7 +80,7 @@ static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) *******************************************************************/ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY *parent, - char *subkeyname, uint32 access_granted ) + const char *subkeyname, uint32 access_granted ) { REGISTRY_KEY *regkey = NULL; NTSTATUS result = NT_STATUS_OK; @@ -341,7 +341,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) { NTSTATUS status = NT_STATUS_NO_SUCH_FILE; fstring name; - char *value_ascii = ""; + const char *value_ascii = ""; fstring value; int value_length; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 68a2dcb83d..291ed50ddd 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -42,7 +42,7 @@ /* Table to map the driver version */ /* to OS */ -char * drv_ver_to_os[] = { +static const char * drv_ver_to_os[] = { "WIN9X", /* driver version/cversion 0 */ "", /* unused ? */ "WINNT", /* driver version/cversion 2 */ @@ -50,8 +50,8 @@ char * drv_ver_to_os[] = { }; struct table_node { - char *long_archi; - char *short_archi; + const char *long_archi; + const char *short_archi; int version; }; @@ -712,7 +712,7 @@ static void notify_system_time(struct spoolss_notify_msg *msg, } struct notify2_message_table { - char *name; + const char *name; void (*fn)(struct spoolss_notify_msg *msg, SPOOL_NOTIFY_INFO_DATA *data, TALLOC_CTX *mem_ctx); }; @@ -1708,7 +1708,7 @@ static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *u return result; } -BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, +BOOL convert_devicemode(const char *printername, const DEVICEMODE *devmode, NT_DEVICEMODE **pp_nt_devmode) { NT_DEVICEMODE *nt_devmode = *pp_nt_devmode; @@ -2085,7 +2085,7 @@ done: ***************************************************************************/ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printer, - char *key, char *value, uint32 *type, uint8 **data, + const char *key, const char *value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size ) { REGISTRY_VALUE *val; @@ -2121,7 +2121,7 @@ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printe Internal routine for removing printerdata ***************************************************************************/ -static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, char *key, char *value ) +static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value ) { delete_printer_data( printer->info_2, key, value ); @@ -2132,7 +2132,7 @@ static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, char *key, Internal routine for storing printerdata ***************************************************************************/ -static WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, char *key, char *value, +static WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value, uint32 type, uint8 *data, int real_len ) { delete_printer_data( printer->info_2, key, value ); @@ -3094,7 +3094,7 @@ static void spoolss_notify_job_status_string(int snum, * Now we're returning job status codes we just return a "" here. JRA. */ - char *p = ""; + const char *p = ""; pstring temp; uint32 len; @@ -3247,7 +3247,7 @@ struct s_notify_info_data_table { uint16 type; uint16 field; - char *name; + const char *name; uint32 size; void (*fn) (int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -3258,7 +3258,7 @@ struct s_notify_info_data_table whether the notification data is a pointer to a variable sized buffer, a one value uint32 or a two value uint32. */ -struct s_notify_info_data_table notify_info_data_table[] = +static const struct s_notify_info_data_table notify_info_data_table[] = { { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", NOTIFY_STRING, spoolss_notify_server_name }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, "PRINTER_NOTIFY_PRINTER_NAME", NOTIFY_STRING, spoolss_notify_printer_name }, @@ -4897,11 +4897,11 @@ static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fst * convert an array of ascii string to a UNICODE string ********************************************************************/ -static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, char *servername) +static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, const char *servername) { int i=0; int j=0; - char *v; + const char *v; pstring line; uint16 *tuary; @@ -6839,7 +6839,7 @@ WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * /**************************************************************************** ****************************************************************************/ -static void fill_port_1(PORT_INFO_1 *port, char *name) +static void fill_port_1(PORT_INFO_1 *port, const char *name) { init_unistr(&port->port_name, name); } @@ -6847,7 +6847,7 @@ static void fill_port_1(PORT_INFO_1 *port, char *name) /**************************************************************************** ****************************************************************************/ -static void fill_port_2(PORT_INFO_2 *port, char *name) +static void fill_port_2(PORT_INFO_2 *port, const char *name) { init_unistr(&port->port_name, name); init_unistr(&port->monitor_name, "Local Monitor"); diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 69f82bb96f..e0a575f143 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -128,7 +128,7 @@ static TDB_CONTEXT *share_tdb; /* used for share security descriptors */ BOOL share_info_db_init(void) { static pid_t local_pid; - char *vstring = "INFO/version"; + const char *vstring = "INFO/version"; int32 vers_id; if (share_tdb && local_pid == sys_getpid()) @@ -1008,7 +1008,7 @@ static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *sto static void init_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1, uint32 id, uint32 type, uint32 num_opens, uint32 num_users, uint32 open_time, - char *usr_name, char *net_name) + const char *usr_name, const char *net_name) { init_srv_conn_info1(se1 , id, type, num_opens, num_users, open_time, usr_name, net_name); init_srv_conn_info1_str(str1, usr_name, net_name); diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 519daff1f6..1b2ac34a6e 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -455,7 +455,7 @@ NTSTATUS local_lookup_user_name(uint32 rid, char *user_name, uint32 *type) ********************************************************************/ NTSTATUS local_lookup_group_rid(char *group_name, uint32 *rid) { - char *grp_name; + const char *grp_name; int i = -1; /* start do loop at -1 */ do /* find, if it exists, a group rid for the group name*/ @@ -472,9 +472,9 @@ NTSTATUS local_lookup_group_rid(char *group_name, uint32 *rid) /******************************************************************* Look up a local (BUILTIN) alias name and return a rid ********************************************************************/ -NTSTATUS local_lookup_alias_rid(char *alias_name, uint32 *rid) +NTSTATUS local_lookup_alias_rid(const char *alias_name, uint32 *rid) { - char *als_name; + const char *als_name; int i = -1; /* start do loop at -1 */ do /* find, if it exists, a alias rid for the alias name*/ -- cgit From 5714c1e0b0e09050d38e917b9c5d9988b818128d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 4 Jan 2003 06:15:24 +0000 Subject: Fix another pstring/fstring typo (This used to be commit 42e1af2008a86005beb4e93a8b208ca6685c3edd) --- source3/rpc_server/srv_netlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 3892a8c982..c65ea43e1e 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -565,7 +565,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain)); - pstrcpy(current_user_info.smb_name, nt_username); + fstrcpy(current_user_info.smb_name, nt_username); sub_set_smb_name(nt_username); /* -- cgit From e3ed8eaa2fd47a72c7b89d769ee594f238130ff7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 4 Jan 2003 08:45:17 +0000 Subject: Merge from HEAD - move user password changes into the NTSTATUS era, and add suppport for the 'min password age' and 'min passwd len' concepts. (This used to be commit d9417b08d1b649e598b44135bc57008f4e4f7769) --- source3/rpc_server/srv_samr_nt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index fd152aa3b3..c72153eda7 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1524,9 +1524,8 @@ NTSTATUS _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_ * is case insensitive. */ - if (!pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, - q_u->nt_newpass.pass, q_u->nt_oldhash.hash)) - r_u->status = NT_STATUS_WRONG_PASSWORD; + r_u->status = pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, + q_u->nt_newpass.pass, q_u->nt_oldhash.hash); init_samr_r_chgpasswd_user(r_u, r_u->status); -- cgit From 3bc3fabee2d411947dc936372495b5f3a1498031 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 4 Jan 2003 08:54:43 +0000 Subject: Merge from HEAD - extract user's list of SIDs from their NT_TOKEN and return this as thier list of groups, rather than do a seperate lookup. This NT_TOKEN is originally initgroups() (or equiv) based. We currently send all sids in our domain, perhaps this should be further restricted, but this works for now. Andrew Bartlett (This used to be commit f5850928a011211f03e5b9ece37682fd9243e2ba) --- source3/rpc_server/srv_netlog_nt.c | 18 ++++++++---------- source3/rpc_server/srv_util.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index c65ea43e1e..c3d48a6527 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -688,16 +688,14 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * pstrcpy(my_name, global_myname()); - /* - * This is the point at which we get the group - * database - we should be getting the gid_t list - * from /etc/group and then turning the uids into - * rids and then into machine sids for this user. - * JRA. - */ - - gids = NULL; - get_domain_user_groups(p->mem_ctx, &num_gids, &gids, server_info->sam_account); + if (!NT_STATUS_IS_OK(status + = nt_token_to_group_list(p->mem_ctx, + &domain_sid, + server_info->ptok, + &num_gids, + &gids))) { + return status; + } init_net_user_info3(p->mem_ctx, usr_info, user_rid, diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 1b2ac34a6e..f33a576db9 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -350,6 +350,35 @@ BOOL get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids, SA return True; } +/******************************************************************* + gets a domain user's groups from their already-calculated NT_USER_TOKEN + ********************************************************************/ +NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, const DOM_SID *domain_sid, + const NT_USER_TOKEN *nt_token, + int *numgroups, DOM_GID **pgids) +{ + DOM_GID *gids; + int i; + + gids = (DOM_GID *)talloc(mem_ctx, sizeof(*gids) * nt_token->num_sids); + + if (!gids) { + return NT_STATUS_NO_MEMORY; + } + + *numgroups=0; + + for (i=PRIMARY_GROUP_SID_INDEX; i < nt_token->num_sids; i++) { + if (sid_compare_domain(domain_sid, &nt_token->user_sids[i])==0) { + sid_peek_rid(&nt_token->user_sids[i], &(gids[*numgroups].g_rid)); + gids[*numgroups].attr=7; + (*numgroups)++; + } + } + *pgids = gids; + return NT_STATUS_OK; +} + /******************************************************************* Look up a local (domain) rid and return a name and type. ********************************************************************/ -- cgit From 302bffc08f4e0ff48dedd35c0580b143ab52671f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 4 Jan 2003 08:57:51 +0000 Subject: Merge from HEAD - we already have one function for converting a unistr2 to a static 'unix' string, so we don't need a second pdb specific version. Andrew Bartlett (This used to be commit 91ca4771c6b834747b06fff21822a14e929de2c1) --- source3/rpc_server/srv_samr_util.c | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 97c7b67839..d7ead0d15f 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -91,7 +91,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) /* Backend should check this for sainity */ if (from->hdr_user_name.buffer) { old_string = pdb_get_username(to); - new_string = pdb_unistr2_convert(&from->uni_user_name); + new_string = unistr2_static(&from->uni_user_name); DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); if (STRING_CHANGED) pdb_set_username(to , new_string, PDB_CHANGED); @@ -99,7 +99,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_full_name.buffer) { old_string = pdb_get_fullname(to); - new_string = pdb_unistr2_convert(&from->uni_full_name); + new_string = unistr2_static(&from->uni_full_name); DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_fullname(to , new_string, PDB_CHANGED); @@ -107,7 +107,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_home_dir.buffer) { old_string = pdb_get_homedir(to); - new_string = pdb_unistr2_convert(&from->uni_home_dir); + new_string = unistr2_static(&from->uni_home_dir); DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_homedir(to , new_string, PDB_CHANGED); @@ -115,7 +115,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_dir_drive.buffer) { old_string = pdb_get_dir_drive(to); - new_string = pdb_unistr2_convert(&from->uni_dir_drive); + new_string = unistr2_static(&from->uni_dir_drive); DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_dir_drive(to , new_string, PDB_CHANGED); @@ -123,7 +123,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_logon_script.buffer) { old_string = pdb_get_logon_script(to); - new_string = pdb_unistr2_convert(&from->uni_logon_script); + new_string = unistr2_static(&from->uni_logon_script); DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_logon_script(to , new_string, PDB_CHANGED); @@ -131,7 +131,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_profile_path.buffer) { old_string = pdb_get_profile_path(to); - new_string = pdb_unistr2_convert(&from->uni_profile_path); + new_string = unistr2_static(&from->uni_profile_path); DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_profile_path(to , new_string, PDB_CHANGED); @@ -139,7 +139,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_acct_desc.buffer) { old_string = pdb_get_acct_desc(to); - new_string = pdb_unistr2_convert(&from->uni_acct_desc); + new_string = unistr2_static(&from->uni_acct_desc); DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_acct_desc(to , new_string, PDB_CHANGED); @@ -147,7 +147,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_workstations.buffer) { old_string = pdb_get_workstations(to); - new_string = pdb_unistr2_convert(&from->uni_workstations); + new_string = unistr2_static(&from->uni_workstations); DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_workstations(to , new_string, PDB_CHANGED); @@ -155,7 +155,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_unknown_str.buffer) { old_string = pdb_get_unknown_str(to); - new_string = pdb_unistr2_convert(&from->uni_unknown_str); + new_string = unistr2_static(&from->uni_unknown_str); DEBUG(10,("INFO_21 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_unknown_str(to , new_string, PDB_CHANGED); @@ -163,7 +163,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->hdr_munged_dial.buffer) { old_string = pdb_get_munged_dial(to); - new_string = pdb_unistr2_convert(&from->uni_munged_dial); + new_string = unistr2_static(&from->uni_munged_dial); DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_munged_dial(to , new_string, PDB_CHANGED); @@ -293,7 +293,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) /* Backend should check this for sainity */ if (from->hdr_user_name.buffer) { old_string = pdb_get_username(to); - new_string = pdb_unistr2_convert(&from->uni_user_name); + new_string = unistr2_static(&from->uni_user_name); DEBUG(10,("INFO_23 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); if (STRING_CHANGED) pdb_set_username(to , new_string, PDB_CHANGED); @@ -301,7 +301,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_full_name.buffer) { old_string = pdb_get_fullname(to); - new_string = pdb_unistr2_convert(&from->uni_full_name); + new_string = unistr2_static(&from->uni_full_name); DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_fullname(to , new_string, PDB_CHANGED); @@ -309,7 +309,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_home_dir.buffer) { old_string = pdb_get_homedir(to); - new_string = pdb_unistr2_convert(&from->uni_home_dir); + new_string = unistr2_static(&from->uni_home_dir); DEBUG(10,("INFO_23 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_homedir(to , new_string, PDB_CHANGED); @@ -317,7 +317,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_dir_drive.buffer) { old_string = pdb_get_dir_drive(to); - new_string = pdb_unistr2_convert(&from->uni_dir_drive); + new_string = unistr2_static(&from->uni_dir_drive); DEBUG(10,("INFO_23 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_dir_drive(to , new_string, PDB_CHANGED); @@ -325,7 +325,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_logon_script.buffer) { old_string = pdb_get_logon_script(to); - new_string = pdb_unistr2_convert(&from->uni_logon_script); + new_string = unistr2_static(&from->uni_logon_script); DEBUG(10,("INFO_23 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_logon_script(to , new_string, PDB_CHANGED); @@ -333,7 +333,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_profile_path.buffer) { old_string = pdb_get_profile_path(to); - new_string = pdb_unistr2_convert(&from->uni_profile_path); + new_string = unistr2_static(&from->uni_profile_path); DEBUG(10,("INFO_23 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_profile_path(to , new_string, PDB_CHANGED); @@ -341,7 +341,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_acct_desc.buffer) { old_string = pdb_get_acct_desc(to); - new_string = pdb_unistr2_convert(&from->uni_acct_desc); + new_string = unistr2_static(&from->uni_acct_desc); DEBUG(10,("INFO_23 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_acct_desc(to , new_string, PDB_CHANGED); @@ -349,7 +349,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_workstations.buffer) { old_string = pdb_get_workstations(to); - new_string = pdb_unistr2_convert(&from->uni_workstations); + new_string = unistr2_static(&from->uni_workstations); DEBUG(10,("INFO_23 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_workstations(to , new_string, PDB_CHANGED); @@ -357,7 +357,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_unknown_str.buffer) { old_string = pdb_get_unknown_str(to); - new_string = pdb_unistr2_convert(&from->uni_unknown_str); + new_string = unistr2_static(&from->uni_unknown_str); DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_unknown_str(to , new_string, PDB_CHANGED); @@ -365,7 +365,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from->hdr_munged_dial.buffer) { old_string = pdb_get_munged_dial(to); - new_string = pdb_unistr2_convert(&from->uni_munged_dial); + new_string = unistr2_static(&from->uni_munged_dial); DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_munged_dial(to , new_string, PDB_CHANGED); -- cgit From 4eb59f56f17b309f4bd6284c3d3c9550a67060bc Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 4 Jan 2003 14:00:17 +0000 Subject: The last of the merge of idra's shutdown changes from head... Andrew Bartlett (This used to be commit 3b24da8f9971e73b9cb4396e6a18c0694d279aa3) --- source3/rpc_server/srv_reg_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index c9158a9cf9..cbf237251e 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -590,9 +590,9 @@ NTSTATUS _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u /* timeout */ snprintf(timeout, sizeof(timeout), "%d", q_u->timeout); /* reboot */ - snprintf(r, sizeof(r), (q_u->flags & REG_REBOOT_ON_SHUTDOWN)?SHUTDOWN_R_STRING:""); + snprintf(r, sizeof(r), (q_u->reboot) ? SHUTDOWN_R_STRING : ""); /* force */ - snprintf(f, sizeof(f), (q_u->flags & REG_FORCE_SHUTDOWN)?SHUTDOWN_F_STRING:""); + snprintf(f, sizeof(f), (q_u->force) ? SHUTDOWN_F_STRING : ""); pstrcpy(shutdown_script, lp_shutdown_script()); -- cgit From d221b11bc6d62663544d0580321d088152332ec4 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 9 Jan 2003 19:49:14 +0000 Subject: a 0 length printer data value is not a memory allocation error; fix CR601 (This used to be commit 47c1709425e0c8c1e57d95dd4441b1424a5b914c) --- source3/rpc_server/srv_spoolss_nt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 291ed50ddd..279bbb86ff 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2104,8 +2104,16 @@ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printe if ( in_size ) { data_len = (size > in_size) ? in_size : size*sizeof(uint8); - if ( (*data = (uint8 *)talloc_memdup(ctx, regval_data_p(val), data_len)) == NULL ) - return WERR_NOMEM; + + /* special case for 0 length values */ + if ( data_len ) { + if ( (*data = (uint8 *)talloc_memdup(ctx, regval_data_p(val), data_len)) == NULL ) + return WERR_NOMEM; + } + else { + if ( (*data = (uint8 *)talloc_zero(ctx, in_size)) == NULL ) + return WERR_NOMEM; + } } else *data = NULL; -- cgit From 6df2dc56fff6791099652575d022a2892423d65d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 9 Jan 2003 19:51:28 +0000 Subject: a 0 length printer data value is not a memory allocation error; fix CR601 (This used to be commit 3442c270f1bc67890f4e2de3386fcfdec610170d) --- source3/rpc_server/srv_spoolss_nt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 291ed50ddd..279bbb86ff 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2104,8 +2104,16 @@ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printe if ( in_size ) { data_len = (size > in_size) ? in_size : size*sizeof(uint8); - if ( (*data = (uint8 *)talloc_memdup(ctx, regval_data_p(val), data_len)) == NULL ) - return WERR_NOMEM; + + /* special case for 0 length values */ + if ( data_len ) { + if ( (*data = (uint8 *)talloc_memdup(ctx, regval_data_p(val), data_len)) == NULL ) + return WERR_NOMEM; + } + else { + if ( (*data = (uint8 *)talloc_zero(ctx, in_size)) == NULL ) + return WERR_NOMEM; + } } else *data = NULL; -- cgit From 47873e781d219bd523d10ca449ac0efb72daed0e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 11 Jan 2003 02:29:23 +0000 Subject: [merge] make sure to updatre print queue cache during timeout_processing() to send notify events; CR 1491 (This used to be commit 142c5029c701e7a82074e301278846c02843f46f) --- source3/rpc_server/srv_spoolss_nt.c | 53 +++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 279bbb86ff..2fba89030e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -79,8 +79,10 @@ typedef struct _Printer{ uint32 printerlocal; SPOOL_NOTIFY_OPTION *option; POLICY_HND client_hnd; - uint32 client_connected; + BOOL client_connected; uint32 change; + /* are we in a FindNextPrinterChangeNotify() call? */ + BOOL fnpcn; } notify; struct { fstring machine; @@ -90,6 +92,7 @@ typedef struct _Printer{ /* devmode sent in the OpenPrinter() call */ NT_DEVICEMODE *nt_devmode; + } Printer_entry; static Printer_entry *printers_list; @@ -932,7 +935,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) SPOOL_NOTIFY_INFO_DATA *data; uint32 data_len = 0; uint32 id; - int i; + int i, event_index; /* Is there notification on this handle? */ @@ -955,6 +958,8 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) data = talloc( mem_ctx, msg_group->num_msgs*sizeof(SPOOL_NOTIFY_INFO_DATA) ); ZERO_STRUCTP(data); + event_index = 0; + /* build the array of change notifications */ for ( i=0; inum_msgs; i++ ) @@ -1005,17 +1010,13 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) switch(msg->type) { case PRINTER_NOTIFY_TYPE: - if ( !printer_notify_table[msg->field].fn ) - goto done; - printer_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); - + if ( printer_notify_table[msg->field].fn ) + printer_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); break; case JOB_NOTIFY_TYPE: - if ( !job_notify_table[msg->field].fn ) - goto done; - job_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); - + if ( job_notify_table[msg->field].fn ) + job_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); break; default: @@ -1228,6 +1229,32 @@ void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) /* all done */ } +/******************************************************************** + Update the cahce for all printq's with a registered client + connection + ********************************************************************/ + +void update_monitored_printq_cache( void ) +{ + Printer_entry *printer = printers_list; + int snum; + + /* loop through all printers and update the cache where + client_connected == True */ + while ( printer ) + { + if ( (printer->printer_type == PRINTER_HANDLE_IS_PRINTER) + && printer->notify.client_connected ) + { + snum = print_queue_snum_dos(printer->dev.handlename); + print_queue_status( snum, NULL, NULL ); + } + + printer = printer->next; + } + + return; +} /******************************************************************** Send a message to ourself about new driver being installed so we can upgrade the information for each printer bound to this @@ -3727,6 +3754,8 @@ WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN /* We need to keep track of the change value to send back in RRPCN replies otherwise our updates are ignored. */ + Printer->notify.fnpcn = True; + if (Printer->notify.client_connected) { DEBUG(10,("_spoolss_rfnpcnex: Saving change value in request [%x]\n", q_u->change)); Printer->notify.change = q_u->change; @@ -3744,7 +3773,9 @@ WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN break; } - done: + Printer->notify.fnpcn = False; + +done: return result; } -- cgit From 27b05b4df9c4c5b39a817c131f32443912242942 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 11 Jan 2003 02:36:13 +0000 Subject: typo from merge (This used to be commit 1f33b4acb32c5461b9249d3786ea5fc6898e5f18) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2fba89030e..2a451adf93 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1246,7 +1246,7 @@ void update_monitored_printq_cache( void ) if ( (printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && printer->notify.client_connected ) { - snum = print_queue_snum_dos(printer->dev.handlename); + snum = print_queue_snum(printer->dev.handlename); print_queue_status( snum, NULL, NULL ); } -- cgit From 071af8f007efc20c23959d140a87cc09363aae83 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 11 Jan 2003 02:38:36 +0000 Subject: [merge] make sure to update print queue cache during timeout_processing() to send notify events; CR 1491 (This used to be commit f8a915b14d63e4fdb99235053eeb896ef9492068) --- source3/rpc_server/srv_spoolss_nt.c | 49 ++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 279bbb86ff..a289de78de 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -79,8 +79,10 @@ typedef struct _Printer{ uint32 printerlocal; SPOOL_NOTIFY_OPTION *option; POLICY_HND client_hnd; - uint32 client_connected; + BOOL client_connected; uint32 change; + /* are we in a FindNextPrinterChangeNotify() call? */ + BOOL fnpcn; } notify; struct { fstring machine; @@ -90,6 +92,7 @@ typedef struct _Printer{ /* devmode sent in the OpenPrinter() call */ NT_DEVICEMODE *nt_devmode; + } Printer_entry; static Printer_entry *printers_list; @@ -932,7 +935,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) SPOOL_NOTIFY_INFO_DATA *data; uint32 data_len = 0; uint32 id; - int i; + int i, event_index; /* Is there notification on this handle? */ @@ -955,6 +958,8 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) data = talloc( mem_ctx, msg_group->num_msgs*sizeof(SPOOL_NOTIFY_INFO_DATA) ); ZERO_STRUCTP(data); + event_index = 0; + /* build the array of change notifications */ for ( i=0; inum_msgs; i++ ) @@ -1005,17 +1010,13 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) switch(msg->type) { case PRINTER_NOTIFY_TYPE: - if ( !printer_notify_table[msg->field].fn ) - goto done; + if ( printer_notify_table[msg->field].fn ) printer_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); - break; case JOB_NOTIFY_TYPE: - if ( !job_notify_table[msg->field].fn ) - goto done; + if ( job_notify_table[msg->field].fn ) job_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); - break; default: @@ -1228,6 +1229,32 @@ void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) /* all done */ } +/******************************************************************** + Update the cahce for all printq's with a registered client + connection + ********************************************************************/ + +void update_monitored_printq_cache( void ) +{ + Printer_entry *printer = printers_list; + int snum; + + /* loop through all printers and update the cache where + client_connected == True */ + while ( printer ) + { + if ( (printer->printer_type == PRINTER_HANDLE_IS_PRINTER) + && printer->notify.client_connected ) + { + snum = print_queue_snum(printer->dev.handlename); + print_queue_status( snum, NULL, NULL ); + } + + printer = printer->next; + } + + return; +} /******************************************************************** Send a message to ourself about new driver being installed so we can upgrade the information for each printer bound to this @@ -3727,6 +3754,8 @@ WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN /* We need to keep track of the change value to send back in RRPCN replies otherwise our updates are ignored. */ + Printer->notify.fnpcn = True; + if (Printer->notify.client_connected) { DEBUG(10,("_spoolss_rfnpcnex: Saving change value in request [%x]\n", q_u->change)); Printer->notify.change = q_u->change; @@ -3744,7 +3773,9 @@ WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN break; } - done: + Printer->notify.fnpcn = False; + +done: return result; } -- cgit From 183ccefce7ea69b0ff6a40be3e57cfac8ab8e24d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 14 Jan 2003 06:36:40 +0000 Subject: A couple more pstcpy/fstrcpy mixups - doing an fstrcpy into a pstring is harmless, but breaks my automated check. (This used to be commit e5d2b1f6c3c0883054f4e0eab2cac958706a790d) --- source3/rpc_server/srv_srvsvc_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index e0a575f143..6d2320d67d 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1481,7 +1481,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S switch (q_u->info_level) { case 1: - fstrcpy(pathname, lp_pathname(snum)); + pstrcpy(pathname, lp_pathname(snum)); unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); type = q_u->info.share.info2.info_2.type; psd = NULL; @@ -1508,7 +1508,7 @@ WERROR _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 1004: - fstrcpy(pathname, lp_pathname(snum)); + pstrcpy(pathname, lp_pathname(snum)); unistr2_to_ascii(comment, &q_u->info.share.info1004.info_1004_str.uni_remark, sizeof(comment)); type = STYPE_DISKTREE; break; @@ -1518,7 +1518,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return WERR_ACCESS_DENIED; break; case 1501: - fstrcpy(pathname, lp_pathname(snum)); + pstrcpy(pathname, lp_pathname(snum)); fstrcpy(comment, lp_comment(snum)); psd = q_u->info.share.info1501.sdb->sec; map_generic_share_sd_bits(psd); -- cgit From 1fdaca33422243062fd2954813e746213340fa08 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 14 Jan 2003 06:46:14 +0000 Subject: The last of the fstring/pstring mixups, and an extra 'static'. (This used to be commit b328b67fd8fd605636ed58ffd33cf5be3d480672) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2a451adf93..b44910883c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -262,7 +262,7 @@ static void free_printer_entry(void *ptr) Functions to duplicate a SPOOL_NOTIFY_OPTION struct stored in Printer_entry. ****************************************************************************/ -SPOOL_NOTIFY_OPTION *dup_spool_notify_option(SPOOL_NOTIFY_OPTION *sp) +static SPOOL_NOTIFY_OPTION *dup_spool_notify_option(SPOOL_NOTIFY_OPTION *sp) { SPOOL_NOTIFY_OPTION *new_sp = NULL; @@ -5409,7 +5409,7 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ *servermajorversion = 0; *serverminorversion = 0; - pstrcpy(servername, get_called_name()); + fstrcpy(servername, get_called_name()); unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); if (!get_printer_snum(p, handle, &snum)) -- cgit From 27b7e51a3cc619f879655a3230611457ac43b9e7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 14 Jan 2003 08:53:59 +0000 Subject: Merge from HEAD: - fstring/pstring mixups - the detection code that found them (disabled) - a bit of whitespace - a static Andrew Bartlett (This used to be commit 9b70fa868e7d9481f584c83fc4046174e1dedfd9) --- source3/rpc_server/srv_spoolss_nt.c | 8 ++++---- source3/rpc_server/srv_srvsvc_nt.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a289de78de..b44910883c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -262,7 +262,7 @@ static void free_printer_entry(void *ptr) Functions to duplicate a SPOOL_NOTIFY_OPTION struct stored in Printer_entry. ****************************************************************************/ -SPOOL_NOTIFY_OPTION *dup_spool_notify_option(SPOOL_NOTIFY_OPTION *sp) +static SPOOL_NOTIFY_OPTION *dup_spool_notify_option(SPOOL_NOTIFY_OPTION *sp) { SPOOL_NOTIFY_OPTION *new_sp = NULL; @@ -1011,12 +1011,12 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) switch(msg->type) { case PRINTER_NOTIFY_TYPE: if ( printer_notify_table[msg->field].fn ) - printer_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); + printer_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); break; case JOB_NOTIFY_TYPE: if ( job_notify_table[msg->field].fn ) - job_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); + job_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); break; default: @@ -5409,7 +5409,7 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ *servermajorversion = 0; *serverminorversion = 0; - pstrcpy(servername, get_called_name()); + fstrcpy(servername, get_called_name()); unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); if (!get_printer_snum(p, handle, &snum)) diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index e0a575f143..6d2320d67d 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1481,7 +1481,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S switch (q_u->info_level) { case 1: - fstrcpy(pathname, lp_pathname(snum)); + pstrcpy(pathname, lp_pathname(snum)); unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); type = q_u->info.share.info2.info_2.type; psd = NULL; @@ -1508,7 +1508,7 @@ WERROR _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 1004: - fstrcpy(pathname, lp_pathname(snum)); + pstrcpy(pathname, lp_pathname(snum)); unistr2_to_ascii(comment, &q_u->info.share.info1004.info_1004_str.uni_remark, sizeof(comment)); type = STYPE_DISKTREE; break; @@ -1518,7 +1518,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return WERR_ACCESS_DENIED; break; case 1501: - fstrcpy(pathname, lp_pathname(snum)); + pstrcpy(pathname, lp_pathname(snum)); fstrcpy(comment, lp_comment(snum)); psd = q_u->info.share.info1501.sdb->sec; map_generic_share_sd_bits(psd); -- cgit From 4242eda183393b0535ac8ef880b4f441c60137af Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 15 Jan 2003 17:22:48 +0000 Subject: merging some rpcclient and net functionality from HEAD (This used to be commit 7a4c87484237308cb3ad0d671687da7e0f6e733b) --- source3/rpc_server/srv_samr_nt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c72153eda7..2896fd79e4 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1180,6 +1180,18 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, /* Get what we need from the password database */ switch (q_u->switch_level) { case 0x1: + /* When playing with usrmgr, this is necessary + if you want immediate refresh after editing + a user. I would like to do this after the + setuserinfo2, but we do not have access to + the domain handle in that call, only to the + user handle. Where else does this hurt? + -- Volker + */ +#if 0 + /* We cannot do this here - it kills performace. JRA. */ + free_samr_users(info); +#endif case 0x2: case 0x4: become_root(); -- cgit From 5fb59502585c68d03bf016d6a4470f2519f941d7 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 15 Jan 2003 18:31:46 +0000 Subject: small merges from SAMBA_3_0; mostly typos, renames, etc... (This used to be commit 9ac196dad4893b0ceef13281a140be5d85391e6c) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b4cd8ae5b5..2896fd79e4 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2248,7 +2248,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ * So we go the easy way, only check after if the account exists. * JFM (2/3/2001), to clear any possible bad understanding (-: * - * We now have separate script paramaters for adding users/machines so we + * We now have seperate script paramaters for adding users/machines so we * now have some sainity-checking to match. */ -- cgit From 99cdb462083381c88689a4e698ca48b6ed4cf5ac Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 15 Jan 2003 18:57:41 +0000 Subject: *lots of small merges form HEAD *sync up configure.in *don't build torture tools in make all *make sure to remove torture tools as part of make clean (This used to be commit 0fb724b3216eeeb97e61ff12755ca3a31bcad6ef) --- source3/rpc_server/srv_util.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index f33a576db9..4eba9c7d1f 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -342,6 +342,7 @@ BOOL get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids, SA DEBUG(0,("get_domain_user_groups: primary gid of user [%s] is not a Domain group !\n", user_name)); DEBUGADD(0,("get_domain_user_groups: You should fix it, NT doesn't like that\n")); + done: *pgids=gids; *numgroups=cur_gid; -- cgit From ec879eacc263043409b584797d1e8c39258ba125 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 17 Jan 2003 04:58:45 +0000 Subject: This removes the 3rd argument from init_unistr2(). There were 240 calls to init_unistr2() in the code and every one of them got the 3rd argument incorrect, so I thought it best just to remove the argument. The incorrect usage was caused by callers using strlen() to determine the length of the string. The 3rd argument to init_unistr2() was supposed to be the character length, not the byte length of the string, so for non-english this could come out wrong. I also removed the bogus 'always allocate at least 256 bytes' hack. There may be some code that relies on this, but if there is then the code is broken and needs fixing. (This used to be commit b9eff31b1433c81fbff733e194914a40f25e3bda) --- source3/rpc_server/srv_dfs_nt.c | 12 ++++++------ source3/rpc_server/srv_lsa_nt.c | 23 ++++++++++------------- source3/rpc_server/srv_samr_nt.c | 8 ++++---- source3/rpc_server/srv_spoolss_nt.c | 2 +- 4 files changed, 21 insertions(+), 24 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index da92e5c06b..38a26d1988 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -198,7 +198,7 @@ static BOOL init_reply_dfs_info_1(struct junction_map* j, DFS_INFO_1* dfs1, int slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), j[i].service_name, j[i].volume_name); DEBUG(5,("init_reply_dfs_info_1: %d) initing entrypath: %s\n",i,str)); - init_unistr2(&dfs1[i].entrypath,str,strlen(str)+1); + init_unistr2(&dfs1[i].entrypath,str); } return True; } @@ -212,7 +212,7 @@ static BOOL init_reply_dfs_info_2(struct junction_map* j, DFS_INFO_2* dfs2, int dfs2[i].ptr_entrypath = 1; slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), j[i].service_name, j[i].volume_name); - init_unistr2(&dfs2[i].entrypath, str, strlen(str)+1); + init_unistr2(&dfs2[i].entrypath, str); dfs2[i].ptr_comment = 0; dfs2[i].state = 1; /* set up state of dfs junction as OK */ dfs2[i].num_storages = j[i].referral_count; @@ -234,9 +234,9 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I 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); + init_unistr2(&dfs3[i].entrypath, str); dfs3[i].ptr_comment = 1; - init_unistr2(&dfs3[i].comment, "", 1); + init_unistr2(&dfs3[i].comment, ""); dfs3[i].state = 1; dfs3[i].num_storages = dfs3[i].num_storage_infos = j[i].referral_count; dfs3[i].ptr_storages = 1; @@ -267,8 +267,8 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I *p = '\0'; DEBUG(5,("storage %d: %s.%s\n",ii,path,p+1)); stor->state = 2; /* set all storages as ONLINE */ - init_unistr2(&stor->servername, path, strlen(path)+1); - init_unistr2(&stor->sharename, p+1, strlen(p+1)+1); + init_unistr2(&stor->servername, path); + init_unistr2(&stor->sharename, p+1); stor->ptr_servername = stor->ptr_sharename = 1; } } diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index fc51d7ef2f..07a04dabb0 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -77,7 +77,7 @@ static void init_dom_query(DOM_QUERY *d_q, const char *dom_name, DOM_SID *dom_si d_q->buffer_dom_sid = dom_sid != NULL ? 1 : 0; /* domain sid pointer */ /* this string is supposed to be character short */ - init_unistr2(&d_q->uni_domain_name, dom_name, domlen); + init_unistr2(&d_q->uni_domain_name, dom_name); d_q->uni_domain_name.uni_max_len++; if (dom_sid != NULL) @@ -121,7 +121,7 @@ static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) init_uni_hdr(&ref->hdr_ref_dom[num].hdr_dom_name, len); ref->hdr_ref_dom[num].ptr_dom_sid = dom_sid != NULL ? 1 : 0; - init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name, len); + init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name); init_dom_sid2(&ref->ref_dom[num].ref_dom, dom_sid ); return num; @@ -350,24 +350,21 @@ static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, { if (nb_name && *nb_name) { init_uni_hdr(&r_l->hdr_nb_dom_name, strlen(nb_name)); - init_unistr2(&r_l->uni_nb_dom_name, nb_name, - strlen(nb_name)); + init_unistr2(&r_l->uni_nb_dom_name, nb_name); r_l->hdr_nb_dom_name.uni_max_len += 2; r_l->uni_nb_dom_name.uni_max_len += 1; } if (dns_name && *dns_name) { init_uni_hdr(&r_l->hdr_dns_dom_name, strlen(dns_name)); - init_unistr2(&r_l->uni_dns_dom_name, dns_name, - strlen(dns_name)); + init_unistr2(&r_l->uni_dns_dom_name, dns_name); r_l->hdr_dns_dom_name.uni_max_len += 2; r_l->uni_dns_dom_name.uni_max_len += 1; } if (forest_name && *forest_name) { init_uni_hdr(&r_l->hdr_forest_name, strlen(forest_name)); - init_unistr2(&r_l->uni_forest_name, forest_name, - strlen(forest_name)); + init_unistr2(&r_l->uni_forest_name, forest_name); r_l->hdr_forest_name.uni_max_len += 2; r_l->uni_forest_name.uni_max_len += 1; } @@ -770,12 +767,12 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV for (i = 0; i < PRIV_ALL_INDEX; i++, entry++) { if( ihdr_name, 0); - init_unistr2(&entry->name, NULL, 0 ); + init_unistr2(&entry->name, NULL); entry->luid_low = 0; entry->luid_high = 0; } else { init_uni_hdr(&entry->hdr_name, strlen(privs[i+1].priv)); - init_unistr2(&entry->name, privs[i+1].priv, strlen(privs[i+1].priv) ); + init_unistr2(&entry->name, privs[i+1].priv); entry->luid_low = privs[i+1].se_priv; entry->luid_high = 0; } @@ -818,7 +815,7 @@ NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, L if (privs[i].se_priv!=SE_PRIV_ALL) { DEBUG(10,(": %s\n", privs[i].description)); init_uni_hdr(&r_u->hdr_desc, strlen(privs[i].description)); - init_unistr2(&r_u->desc, privs[i].description, strlen(privs[i].description) ); + init_unistr2(&r_u->desc, privs[i].description); r_u->ptr_info=0xdeadbeef; r_u->lang_id=q_u->lang_id; @@ -899,13 +896,13 @@ NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA init_uni_hdr(&r_u->hdr_user_name, ulen); r_u->ptr_user_name = 1; - init_unistr2(&r_u->uni2_user_name, username, ulen); + init_unistr2(&r_u->uni2_user_name, username); r_u->unk1 = 1; init_uni_hdr(&r_u->hdr_dom_name, dlen); r_u->ptr_dom_name = 1; - init_unistr2(&r_u->uni2_dom_name, domname, dlen); + init_unistr2(&r_u->uni2_dom_name, domname); r_u->status = NT_STATUS_OK; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2896fd79e4..74361fd931 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -717,7 +717,7 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UN for (i = 0; i < num_entries; i++) { pwd = disp_user_info[i+start_idx].sam; temp_name = pdb_get_username(pwd); - init_unistr2(&uni_temp_name, temp_name, strlen(temp_name)+1); + init_unistr2(&uni_temp_name, temp_name); user_sid = pdb_get_user_sid(pwd); if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { @@ -866,7 +866,7 @@ static void make_group_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNIST int len = strlen(grp[i].name)+1; init_sam_entry(&sam[i], len, grp[i].rid); - init_unistr2(&uni_name[i], grp[i].name, len); + init_unistr2(&uni_name[i], grp[i].name); } *sam_pp = sam; @@ -1574,7 +1574,7 @@ static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, fstring nam int len = names[i] != NULL ? strlen(names[i]) : 0; DEBUG(10, ("names[%d]:%s\n", i, names[i])); init_uni_hdr(&hdr_name[i], len); - init_unistr2(&uni_name[i], names[i], len); + init_unistr2(&uni_name[i], names[i]); } *pp_uni_name = uni_name; @@ -2555,7 +2555,7 @@ static BOOL make_enum_domains(TALLOC_CTX *ctx, SAM_ENTRY **pp_sam, int len = doms[i] != NULL ? strlen(doms[i]) : 0; init_sam_entry(&sam[i], len, 0); - init_unistr2(&uni_name[i], doms[i], len); + init_unistr2(&uni_name[i], doms[i]); } *pp_sam = sam; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b44910883c..fd85d2f429 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -666,7 +666,7 @@ static void notify_string(struct spoolss_notify_msg *msg, /* The length of the message includes the trailing \0 */ - init_unistr2(&unistr, msg->notify.data, msg->len); + init_unistr2(&unistr, msg->notify.data); data->notify_data.data.length = msg->len * 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, msg->len * 2); -- cgit From 96c795cea7518b50a40caba34e656f056a832589 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 17 Jan 2003 06:15:18 +0000 Subject: reverted this patch till I sort out the craziness with UNIHDR (This used to be commit e3d00fa47d38cd214f5e350e1d6b30d90ed8a52c) --- source3/rpc_server/srv_dfs_nt.c | 12 ++++++------ source3/rpc_server/srv_lsa_nt.c | 23 +++++++++++++---------- source3/rpc_server/srv_samr_nt.c | 8 ++++---- source3/rpc_server/srv_spoolss_nt.c | 2 +- 4 files changed, 24 insertions(+), 21 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 38a26d1988..da92e5c06b 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -198,7 +198,7 @@ static BOOL init_reply_dfs_info_1(struct junction_map* j, DFS_INFO_1* dfs1, int slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), j[i].service_name, j[i].volume_name); DEBUG(5,("init_reply_dfs_info_1: %d) initing entrypath: %s\n",i,str)); - init_unistr2(&dfs1[i].entrypath,str); + init_unistr2(&dfs1[i].entrypath,str,strlen(str)+1); } return True; } @@ -212,7 +212,7 @@ static BOOL init_reply_dfs_info_2(struct junction_map* j, DFS_INFO_2* dfs2, int dfs2[i].ptr_entrypath = 1; slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), j[i].service_name, j[i].volume_name); - init_unistr2(&dfs2[i].entrypath, str); + init_unistr2(&dfs2[i].entrypath, str, strlen(str)+1); dfs2[i].ptr_comment = 0; dfs2[i].state = 1; /* set up state of dfs junction as OK */ dfs2[i].num_storages = j[i].referral_count; @@ -234,9 +234,9 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), j[i].service_name, j[i].volume_name); - init_unistr2(&dfs3[i].entrypath, str); + init_unistr2(&dfs3[i].entrypath, str, strlen(str)+1); dfs3[i].ptr_comment = 1; - init_unistr2(&dfs3[i].comment, ""); + init_unistr2(&dfs3[i].comment, "", 1); dfs3[i].state = 1; dfs3[i].num_storages = dfs3[i].num_storage_infos = j[i].referral_count; dfs3[i].ptr_storages = 1; @@ -267,8 +267,8 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I *p = '\0'; DEBUG(5,("storage %d: %s.%s\n",ii,path,p+1)); stor->state = 2; /* set all storages as ONLINE */ - init_unistr2(&stor->servername, path); - init_unistr2(&stor->sharename, p+1); + init_unistr2(&stor->servername, path, strlen(path)+1); + init_unistr2(&stor->sharename, p+1, strlen(p+1)+1); stor->ptr_servername = stor->ptr_sharename = 1; } } diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 07a04dabb0..fc51d7ef2f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -77,7 +77,7 @@ static void init_dom_query(DOM_QUERY *d_q, const char *dom_name, DOM_SID *dom_si d_q->buffer_dom_sid = dom_sid != NULL ? 1 : 0; /* domain sid pointer */ /* this string is supposed to be character short */ - init_unistr2(&d_q->uni_domain_name, dom_name); + init_unistr2(&d_q->uni_domain_name, dom_name, domlen); d_q->uni_domain_name.uni_max_len++; if (dom_sid != NULL) @@ -121,7 +121,7 @@ static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) init_uni_hdr(&ref->hdr_ref_dom[num].hdr_dom_name, len); ref->hdr_ref_dom[num].ptr_dom_sid = dom_sid != NULL ? 1 : 0; - init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name); + init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name, len); init_dom_sid2(&ref->ref_dom[num].ref_dom, dom_sid ); return num; @@ -350,21 +350,24 @@ static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, { if (nb_name && *nb_name) { init_uni_hdr(&r_l->hdr_nb_dom_name, strlen(nb_name)); - init_unistr2(&r_l->uni_nb_dom_name, nb_name); + init_unistr2(&r_l->uni_nb_dom_name, nb_name, + strlen(nb_name)); r_l->hdr_nb_dom_name.uni_max_len += 2; r_l->uni_nb_dom_name.uni_max_len += 1; } if (dns_name && *dns_name) { init_uni_hdr(&r_l->hdr_dns_dom_name, strlen(dns_name)); - init_unistr2(&r_l->uni_dns_dom_name, dns_name); + init_unistr2(&r_l->uni_dns_dom_name, dns_name, + strlen(dns_name)); r_l->hdr_dns_dom_name.uni_max_len += 2; r_l->uni_dns_dom_name.uni_max_len += 1; } if (forest_name && *forest_name) { init_uni_hdr(&r_l->hdr_forest_name, strlen(forest_name)); - init_unistr2(&r_l->uni_forest_name, forest_name); + init_unistr2(&r_l->uni_forest_name, forest_name, + strlen(forest_name)); r_l->hdr_forest_name.uni_max_len += 2; r_l->uni_forest_name.uni_max_len += 1; } @@ -767,12 +770,12 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV for (i = 0; i < PRIV_ALL_INDEX; i++, entry++) { if( ihdr_name, 0); - init_unistr2(&entry->name, NULL); + init_unistr2(&entry->name, NULL, 0 ); entry->luid_low = 0; entry->luid_high = 0; } else { init_uni_hdr(&entry->hdr_name, strlen(privs[i+1].priv)); - init_unistr2(&entry->name, privs[i+1].priv); + init_unistr2(&entry->name, privs[i+1].priv, strlen(privs[i+1].priv) ); entry->luid_low = privs[i+1].se_priv; entry->luid_high = 0; } @@ -815,7 +818,7 @@ NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, L if (privs[i].se_priv!=SE_PRIV_ALL) { DEBUG(10,(": %s\n", privs[i].description)); init_uni_hdr(&r_u->hdr_desc, strlen(privs[i].description)); - init_unistr2(&r_u->desc, privs[i].description); + init_unistr2(&r_u->desc, privs[i].description, strlen(privs[i].description) ); r_u->ptr_info=0xdeadbeef; r_u->lang_id=q_u->lang_id; @@ -896,13 +899,13 @@ NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA init_uni_hdr(&r_u->hdr_user_name, ulen); r_u->ptr_user_name = 1; - init_unistr2(&r_u->uni2_user_name, username); + init_unistr2(&r_u->uni2_user_name, username, ulen); r_u->unk1 = 1; init_uni_hdr(&r_u->hdr_dom_name, dlen); r_u->ptr_dom_name = 1; - init_unistr2(&r_u->uni2_dom_name, domname); + init_unistr2(&r_u->uni2_dom_name, domname, dlen); r_u->status = NT_STATUS_OK; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 74361fd931..2896fd79e4 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -717,7 +717,7 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UN for (i = 0; i < num_entries; i++) { pwd = disp_user_info[i+start_idx].sam; temp_name = pdb_get_username(pwd); - init_unistr2(&uni_temp_name, temp_name); + init_unistr2(&uni_temp_name, temp_name, strlen(temp_name)+1); user_sid = pdb_get_user_sid(pwd); if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { @@ -866,7 +866,7 @@ static void make_group_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNIST int len = strlen(grp[i].name)+1; init_sam_entry(&sam[i], len, grp[i].rid); - init_unistr2(&uni_name[i], grp[i].name); + init_unistr2(&uni_name[i], grp[i].name, len); } *sam_pp = sam; @@ -1574,7 +1574,7 @@ static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, fstring nam int len = names[i] != NULL ? strlen(names[i]) : 0; DEBUG(10, ("names[%d]:%s\n", i, names[i])); init_uni_hdr(&hdr_name[i], len); - init_unistr2(&uni_name[i], names[i]); + init_unistr2(&uni_name[i], names[i], len); } *pp_uni_name = uni_name; @@ -2555,7 +2555,7 @@ static BOOL make_enum_domains(TALLOC_CTX *ctx, SAM_ENTRY **pp_sam, int len = doms[i] != NULL ? strlen(doms[i]) : 0; init_sam_entry(&sam[i], len, 0); - init_unistr2(&uni_name[i], doms[i]); + init_unistr2(&uni_name[i], doms[i], len); } *pp_sam = sam; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index fd85d2f429..b44910883c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -666,7 +666,7 @@ static void notify_string(struct spoolss_notify_msg *msg, /* The length of the message includes the trailing \0 */ - init_unistr2(&unistr, msg->notify.data); + init_unistr2(&unistr, msg->notify.data, msg->len); data->notify_data.data.length = msg->len * 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, msg->len * 2); -- cgit From 2b79854f068c99b2881a02371b4bc7dd00a4e5aa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 17 Jan 2003 06:34:22 +0000 Subject: Fix reference count bug where smbd's would not terminate with no open resources. Jeremy. (This used to be commit b7e5a2c5474e9edd8fa783462af8986b6bd426a5) --- source3/rpc_server/srv_lsa_hnd.c | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 2d04d72323..814fa60aab 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -137,14 +137,6 @@ BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *) DLIST_ADD(p->pipe_handles->Policy, pol); p->pipe_handles->count++; - /* - * Ensure we don't idle this connection if a handle is open. - * Increment the number of files open on the first handle create. - */ - - if (p->pipe_handles->count == 1) - p->conn->num_files_open++; - *hnd = pol->pol_hnd; DEBUG(4,("Opened policy hnd[%d] ", (int)p->pipe_handles->count)); @@ -212,15 +204,6 @@ BOOL close_policy_hnd(pipes_struct *p, POLICY_HND *hnd) p->pipe_handles->count--; - /* - * Ensure we can idle this connection if this is the last handle. - * Decrement the number of files open on the last handle delete. - */ - - if (p->pipe_handles->count == 0) - p->conn->num_files_open--; - - DLIST_REMOVE(p->pipe_handles->Policy, pol); ZERO_STRUCTP(pol); -- cgit From 074c99a852ce79f4c7791d709b82dc80c32e4d04 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 17 Jan 2003 06:35:33 +0000 Subject: Fix reference count bug where smbd's would not terminate with no open resources. Jeremy. (This used to be commit 0173d6fe164568a73247fa542895443fad6c20c3) --- source3/rpc_server/srv_lsa_hnd.c | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 2d04d72323..814fa60aab 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -137,14 +137,6 @@ BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *) DLIST_ADD(p->pipe_handles->Policy, pol); p->pipe_handles->count++; - /* - * Ensure we don't idle this connection if a handle is open. - * Increment the number of files open on the first handle create. - */ - - if (p->pipe_handles->count == 1) - p->conn->num_files_open++; - *hnd = pol->pol_hnd; DEBUG(4,("Opened policy hnd[%d] ", (int)p->pipe_handles->count)); @@ -212,15 +204,6 @@ BOOL close_policy_hnd(pipes_struct *p, POLICY_HND *hnd) p->pipe_handles->count--; - /* - * Ensure we can idle this connection if this is the last handle. - * Decrement the number of files open on the last handle delete. - */ - - if (p->pipe_handles->count == 0) - p->conn->num_files_open--; - - DLIST_REMOVE(p->pipe_handles->Policy, pol); ZERO_STRUCTP(pol); -- cgit From 9eb368e068076f65083916573cf832988e216b59 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 17 Jan 2003 20:57:26 +0000 Subject: Enable dynamic loading of RPC modules. See docs/textdocs/RPC_PLUGGIN.txt for instructions. (This used to be commit d51e12df78ff8fc721d693fedbd1c633f39edd49) --- source3/rpc_server/srv_dfs.c | 36 +++--- source3/rpc_server/srv_lsa.c | 64 ++++++----- source3/rpc_server/srv_netlog.c | 44 ++++---- source3/rpc_server/srv_pipe.c | 238 ++++++++++++++++++++++++++++++++------- source3/rpc_server/srv_reg.c | 55 ++++----- source3/rpc_server/srv_samr.c | 128 ++++++++++----------- source3/rpc_server/srv_spoolss.c | 29 ++--- source3/rpc_server/srv_srvsvc.c | 59 +++++----- source3/rpc_server/srv_wkssvc.c | 24 ++-- 9 files changed, 422 insertions(+), 255 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 676ad8e3f3..f6e9ca3d56 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -3,8 +3,9 @@ * RPC Pipe client / server routines for Dfs * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Shirish Kalele 2000. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Shirish Kalele 2000, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -157,21 +158,20 @@ static BOOL api_dfs_enum(pipes_struct *p) \pipe\netdfs commands ********************************************************************/ -struct api_struct api_netdfs_cmds[] = +#ifdef RPC_DFS_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_dfs_init(void) +#endif { - {"DFS_EXIST", DFS_EXIST, api_dfs_exist }, - {"DFS_ADD", DFS_ADD, api_dfs_add }, - {"DFS_REMOVE", DFS_REMOVE, api_dfs_remove }, - {"DFS_GET_INFO", DFS_GET_INFO, api_dfs_get_info }, - {"DFS_ENUM", DFS_ENUM, api_dfs_enum }, - {NULL, 0, NULL } -}; - -/******************************************************************* -receives a netdfs pipe and responds. -********************************************************************/ - -BOOL api_netdfs_rpc(pipes_struct *p) -{ - return api_rpcTNP(p, "api_netdfs_rpc", api_netdfs_cmds); + struct api_struct api_netdfs_cmds[] = + { + {"DFS_EXIST", DFS_EXIST, api_dfs_exist }, + {"DFS_ADD", DFS_ADD, api_dfs_add }, + {"DFS_REMOVE", DFS_REMOVE, api_dfs_remove }, + {"DFS_GET_INFO", DFS_GET_INFO, api_dfs_get_info }, + {"DFS_ENUM", DFS_ENUM, api_dfs_enum } + }; + return rpc_pipe_register_commands("netdfs", "netdfs", api_netdfs_cmds, + sizeof(api_netdfs_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index a2c2290fb7..815de390ec 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -5,7 +5,8 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Jim McDonough 2002. + * Copyright (C) Jim McDonough 2002, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -645,35 +646,36 @@ static BOOL api_lsa_query_info2(pipes_struct *p) \PIPE\ntlsa commands ***************************************************************************/ -static const struct api_struct api_lsa_cmds[] = +#ifdef RPC_LSA_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_lsa_init(void) +#endif { - { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 }, - { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy }, - { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info }, - { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom }, - { "LSA_CLOSE" , LSA_CLOSE , api_lsa_close }, - { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret }, - { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids }, - { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names }, - { "LSA_ENUM_PRIVS" , LSA_ENUM_PRIVS , api_lsa_enum_privs }, - { "LSA_PRIV_GET_DISPNAME",LSA_PRIV_GET_DISPNAME,api_lsa_priv_get_dispname}, - { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS , api_lsa_enum_accounts }, - { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser }, - { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT , api_lsa_open_account }, - { "LSA_ENUMPRIVSACCOUNT", LSA_ENUMPRIVSACCOUNT, api_lsa_enum_privsaccount}, - { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT, api_lsa_getsystemaccount }, - { "LSA_SETSYSTEMACCOUNT", LSA_SETSYSTEMACCOUNT, api_lsa_setsystemaccount }, - { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs }, - { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs }, - { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, - { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 }, - { NULL , 0 , NULL } -}; - -/*************************************************************************** - api_ntLsarpcTNP - ***************************************************************************/ -BOOL api_ntlsa_rpc(pipes_struct *p) -{ - return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds); + static const struct api_struct api_lsa_cmds[] = + { + { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 }, + { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy }, + { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info }, + { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom }, + { "LSA_CLOSE" , LSA_CLOSE , api_lsa_close }, + { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret }, + { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids }, + { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names }, + { "LSA_ENUM_PRIVS" , LSA_ENUM_PRIVS , api_lsa_enum_privs }, + { "LSA_PRIV_GET_DISPNAME",LSA_PRIV_GET_DISPNAME,api_lsa_priv_get_dispname}, + { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS , api_lsa_enum_accounts }, + { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser }, + { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT , api_lsa_open_account }, + { "LSA_ENUMPRIVSACCOUNT", LSA_ENUMPRIVSACCOUNT, api_lsa_enum_privsaccount}, + { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT, api_lsa_getsystemaccount }, + { "LSA_SETSYSTEMACCOUNT", LSA_SETSYSTEMACCOUNT, api_lsa_setsystemaccount }, + { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs }, + { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs }, + { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, + { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 } + }; + + return rpc_pipe_register_commands("lsarpc", "lsass", api_lsa_cmds, + sizeof(api_lsa_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index f96a0e2f2d..f377d3952b 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -3,8 +3,9 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jeremy Allison 1998-2001. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Jeremy Allison 1998-2001, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -319,25 +320,26 @@ static BOOL api_net_logon_ctrl(pipes_struct *p) /******************************************************************* array of \PIPE\NETLOGON operations ********************************************************************/ -static struct api_struct api_net_cmds [] = -{ - { "NET_REQCHAL" , NET_REQCHAL , api_net_req_chal }, - { "NET_AUTH" , NET_AUTH , api_net_auth }, - { "NET_AUTH2" , NET_AUTH2 , api_net_auth_2 }, - { "NET_SRVPWSET" , NET_SRVPWSET , api_net_srv_pwset }, - { "NET_SAMLOGON" , NET_SAMLOGON , api_net_sam_logon }, - { "NET_SAMLOGOFF" , NET_SAMLOGOFF , api_net_sam_logoff }, - { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 }, - { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, - { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl }, - { NULL , 0 , NULL } -}; - -/******************************************************************* - receives a netlogon pipe and responds. - ********************************************************************/ -BOOL api_netlog_rpc(pipes_struct *p) +#ifdef RPC_NETLOG_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_net_init(void) +#endif { - return api_rpcTNP(p, "api_netlog_rpc", api_net_cmds); + static struct api_struct api_net_cmds [] = + { + { "NET_REQCHAL" , NET_REQCHAL , api_net_req_chal }, + { "NET_AUTH" , NET_AUTH , api_net_auth }, + { "NET_AUTH2" , NET_AUTH2 , api_net_auth_2 }, + { "NET_SRVPWSET" , NET_SRVPWSET , api_net_srv_pwset }, + { "NET_SAMLOGON" , NET_SAMLOGON , api_net_sam_logon }, + { "NET_SAMLOGOFF" , NET_SAMLOGOFF , api_net_sam_logoff }, + { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 }, + { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, + { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl } + }; + + return rpc_pipe_register_commands("NETLOGON", "lsass", api_net_cmds, + sizeof(api_net_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 8aaab43461..f99bd75974 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -3,8 +3,9 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1998 * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, - * Copyright (C) Paul Ashton 1997-1998. - * Copyright (C) Jeremy Allison 1999. + * Copyright (C) Paul Ashton 1997-1998, + * Copyright (C) Jeremy Allison 1999, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -457,24 +458,53 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); struct api_cmd { - const char * pipe_clnt_name; - const char * pipe_srv_name; - BOOL (*fn) (pipes_struct *); + const char *name; + int (*init)(void); }; static struct api_cmd api_fd_commands[] = { - { "lsarpc", "lsass", api_ntlsa_rpc }, - { "samr", "lsass", api_samr_rpc }, - { "srvsvc", "ntsvcs", api_srvsvc_rpc }, - { "wkssvc", "ntsvcs", api_wkssvc_rpc }, - { "NETLOGON", "lsass", api_netlog_rpc }, - { "winreg", "winreg", api_reg_rpc }, - { "spoolss", "spoolss", api_spoolss_rpc }, - { "netdfs", "netdfs" , api_netdfs_rpc }, - { NULL, NULL, NULL } +#ifndef RPC_LSA_DYNAMIC + { "lsarpc", rpc_lsa_init }, +#endif +#ifndef RPC_SAMR_DYNAMIC + { "samr", rpc_samr_init }, +#endif +#ifndef RPC_SVC_DYNAMIC + { "srvsvc", rpc_srv_init }, +#endif +#ifndef RPC_WKS_DYNAMIC + { "wkssvc", rpc_wks_init }, +#endif +#ifndef RPC_NETLOG_DYNAMIC + { "NETLOGON", rpc_net_init }, +#endif +#ifndef RPC_REG_DYNAMIC + { "winreg", rpc_reg_init }, +#endif +#ifndef RPC_SPOOLSS_DYNAMIC + { "spoolss", rpc_spoolss_init }, +#endif +#ifndef RPC_DFS_DYNAMIC + { "netdfs", rpc_dfs_init }, +#endif + { NULL, NULL } }; +struct rpc_table +{ + struct + { + const char *clnt; + const char *srv; + } pipe; + struct api_struct *cmds; + int n_cmds; +}; + +static struct rpc_table *rpc_lookup; +static int rpc_lookup_size; + /******************************************************************* This is the client reply to our challenge for an authenticated bind request. The challenge we sent is in p->challenge. @@ -681,6 +711,7 @@ BOOL check_bind_req(char* pipe_name, RPC_IFACE* abstract, fstrcpy(pname,"\\PIPE\\"); fstrcat(pname,pipe_name); + DEBUG(3,("check_bind_req for %s\n", pname)); #ifndef SUPPORT_NEW_LSARPC_UUID @@ -727,6 +758,82 @@ BOOL check_bind_req(char* pipe_name, RPC_IFACE* abstract, return True; } +/******************************************************************* + Register commands to an RPC pipe +*******************************************************************/ +int rpc_pipe_register_commands(const char *clnt, const char *srv, const struct api_struct *cmds, int size) +{ + struct rpc_table *rpc_entry; + + + /* We use a temporary variable because this call can fail and + rpc_lookup will still be valid afterwards. It could then succeed if + called again later */ + rpc_entry = realloc(rpc_lookup, + ++rpc_lookup_size*sizeof(struct rpc_table)); + if (NULL == rpc_entry) { + rpc_lookup_size--; + DEBUG(0, ("rpc_pipe_register_commands: memory allocation failed\n")); + return 0; + } else { + rpc_lookup = rpc_entry; + } + + rpc_entry = rpc_lookup + (rpc_lookup_size - 1); + ZERO_STRUCTP(rpc_entry); + rpc_entry->pipe.clnt = strdup(clnt); + rpc_entry->pipe.srv = strdup(srv); + rpc_entry->cmds = realloc(rpc_entry->cmds, + (rpc_entry->n_cmds + size) * + sizeof(struct api_struct)); + memcpy(rpc_entry->cmds + rpc_entry->n_cmds, cmds, + size * sizeof(struct api_struct)); + rpc_entry->n_cmds += size; + + return size; +} + +/******************************************************************* + Register commands to an RPC pipe +*******************************************************************/ +int rpc_load_module(const char *module) +{ +#ifdef HAVE_DLOPEN + void *handle; + int (*module_init)(void); + pstring full_path; + char *error; + + pstrcpy(full_path, lib_path("rpc")); + pstrcat(full_path, "/librpc_"); + pstrcat(full_path, module); + pstrcat(full_path, "."); + pstrcat(full_path, shlib_ext()); + + handle = sys_dlopen(full_path, RTLD_LAZY); + if (!handle) { + DEBUG(0, ("Could not load requested pipe %s as %s\n", + module, full_path)); + DEBUG(0, (" Error: %s\n", dlerror())); + return 0; + } + + DEBUG(3, ("Module '%s' loaded\n", full_path)); + + module_init = sys_dlsym(handle, "rpc_pipe_init"); + if ((error = sys_dlerror()) != NULL) { + DEBUG(0, ("Error trying to resolve symbol 'rpc_pipe_init' in %s: %s\n", + full_path, error)); + return 0; + } + + return module_init(); +#else + DEBUG(0,("Attempting to load a dynamic RPC pipe when dlopen isn't available\n")); + return 0; +#endif +} + /******************************************************************* Respond to a pipe bind request. *******************************************************************/ @@ -754,23 +861,40 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) * that this is a pipe name we support. */ - for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { - if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && - api_fd_commands[i].fn != NULL) { - DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", - api_fd_commands[i].pipe_clnt_name, - api_fd_commands[i].pipe_srv_name)); - fstrcpy(p->pipe_srv_name, api_fd_commands[i].pipe_srv_name); - break; - } + + for (i = 0; i < rpc_lookup_size; i++) { + if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { + DEBUG(0, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", + rpc_lookup[i].pipe.clnt, rpc_lookup[i].pipe.srv)); + fstrcpy(p->pipe_srv_name, rpc_lookup[i].pipe.srv); + break; + } } - if (api_fd_commands[i].fn == NULL) { - DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", - p->name )); - if(!setup_bind_nak(p)) - return False; - return True; + if (i == rpc_lookup_size) { + for (i = 0; api_fd_commands[i].name; i++) { + if (strequal(api_fd_commands[i].name, p->name)) { + api_fd_commands[i].init(); + break; + } + } + + if (!api_fd_commands[i].name && !rpc_load_module(p->name)) { + DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", + p->name )); + if(!setup_bind_nak(p)) + return False; + return True; + } + + for (i = 0; i < rpc_lookup_size; i++) { + if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { + DEBUG(0, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", + rpc_lookup[i].pipe.clnt, rpc_lookup[i].pipe.srv)); + fstrcpy(p->pipe_srv_name, rpc_lookup[i].pipe.srv); + break; + } + } } /* decode the bind request */ @@ -1153,14 +1277,46 @@ BOOL api_pipe_request(pipes_struct *p) } } - for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { - if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && - api_fd_commands[i].fn != NULL) { - DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i].pipe_clnt_name)); - set_current_rpc_talloc(p->mem_ctx); - ret = api_fd_commands[i].fn(p); - set_current_rpc_talloc(NULL); - } + DEBUG(5, ("Requested \\PIPE\\%s\n", p->name)); + + for (i = 0; i < rpc_lookup_size; i++) { + if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { + DEBUG(3,("Doing \\PIPE\\%s\n", + rpc_lookup[i].pipe.clnt)); + set_current_rpc_talloc(p->mem_ctx); + ret = api_rpcTNP(p, rpc_lookup[i].pipe.clnt, + rpc_lookup[i].cmds, + rpc_lookup[i].n_cmds); + set_current_rpc_talloc(NULL); + break; + } + } + + + if (i == rpc_lookup_size) { + for (i = 0; api_fd_commands[i].name; i++) { + if (strequal(api_fd_commands[i].name, p->name)) { + api_fd_commands[i].init(); + break; + } + } + + if (!api_fd_commands[i].name) { + rpc_load_module(p->name); + } + + for (i = 0; i < rpc_lookup_size; i++) { + if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { + DEBUG(3,("Doing \\PIPE\\%s\n", + rpc_lookup[i].pipe.clnt)); + set_current_rpc_talloc(p->mem_ctx); + ret = api_rpcTNP(p, rpc_lookup[i].pipe.clnt, + rpc_lookup[i].cmds, + rpc_lookup[i].n_cmds); + set_current_rpc_talloc(NULL); + break; + } + } } if(p->ntlmssp_auth_validated) @@ -1174,7 +1330,7 @@ BOOL api_pipe_request(pipes_struct *p) ********************************************************************/ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, - const struct api_struct *api_rpc_cmds) + const struct api_struct *api_rpc_cmds, int n_cmds) { int fn_num; fstring name; @@ -1186,14 +1342,14 @@ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, slprintf(name, sizeof(name)-1, "in_%s", rpc_name); prs_dump(name, p->hdr_req.opnum, &p->in_data.data); - for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) { + for (fn_num = 0; fn_num < n_cmds; fn_num++) { if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) { DEBUG(3,("api_rpcTNP: rpc command: %s\n", api_rpc_cmds[fn_num].name)); break; } } - if (api_rpc_cmds[fn_num].name == NULL) { + if (fn_num == n_cmds) { /* * For an unknown RPC just return a fault PDU but * return True to allow RPC's on the pipe to continue @@ -1206,6 +1362,8 @@ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, offset1 = prs_offset(&p->out_data.rdata); + fprintf(stderr, "api_rpc_cmds[%d].fn == %p\n", + fn_num, api_rpc_cmds[fn_num].fn); /* do the actual command */ if(!api_rpc_cmds[fn_num].fn(p)) { DEBUG(0,("api_rpcTNP: %s: %s failed.\n", rpc_name, api_rpc_cmds[fn_num].name)); diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index d0aaf0199b..04960f8e3a 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -3,10 +3,11 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Marc Jacobsen 2000. - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Gerald Carter 2002. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Marc Jacobsen 2000, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Gerald Carter 2002, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -371,29 +372,29 @@ static BOOL api_reg_save_key(pipes_struct *p) /******************************************************************* array of \PIPE\reg operations ********************************************************************/ -static struct api_struct api_reg_cmds[] = -{ - { "REG_CLOSE" , REG_CLOSE , api_reg_close }, - { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, - { "REG_OPEN_HKCR" , REG_OPEN_HKCR , api_reg_open_hkcr }, - { "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm }, - { "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku }, - { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key }, - { "REG_ENUM_VALUE" , REG_ENUM_VALUE , api_reg_enum_value }, - { "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key }, - { "REG_INFO" , REG_INFO , api_reg_info }, - { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, - { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, - { "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a }, - { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key }, - { NULL , 0 , NULL } -}; - -/******************************************************************* - receives a reg pipe and responds. - ********************************************************************/ -BOOL api_reg_rpc(pipes_struct *p) +#ifdef RPC_REG_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_reg_init(void) +#endif { - return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds); + static struct api_struct api_reg_cmds[] = + { + { "REG_CLOSE" , REG_CLOSE , api_reg_close }, + { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, + { "REG_OPEN_HKCR" , REG_OPEN_HKCR , api_reg_open_hkcr }, + { "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm }, + { "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku }, + { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key }, + { "REG_ENUM_VALUE" , REG_ENUM_VALUE , api_reg_enum_value }, + { "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key }, + { "REG_INFO" , REG_INFO , api_reg_info }, + { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, + { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, + { "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a }, + { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key } + }; + return rpc_pipe_register_commands("winreg", "winreg", api_reg_cmds, + sizeof(api_reg_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index ab3d94cf75..3a31ec82e1 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -6,7 +6,7 @@ * Copyright (C) Paul Ashton 1997, * Copyright (C) Marc Jacobsen 1999, * Copyright (C) Jean François Micouleau 1998-2001, - * Copyright (C) Anthony Liguori 2002, + * Copyright (C) Anthony Liguori 2002-2003, * Copyright (C) Jim McDonough 2002. * * Split into interface and implementation modules by, @@ -1443,68 +1443,68 @@ static BOOL api_samr_set_dom_info(pipes_struct *p) array of \PIPE\samr operations ********************************************************************/ -static struct api_struct api_samr_cmds [] = +#ifdef RPC_SAMR_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_samr_init(void) +#endif { - {"SAMR_CLOSE_HND" , SAMR_CLOSE_HND , api_samr_close_hnd }, - {"SAMR_CONNECT" , SAMR_CONNECT , api_samr_connect }, - {"SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon }, - {"SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains }, - {"SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users }, - - {"SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, - {"SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, - {"SAMR_QUERY_USERALIASES" , SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, - {"SAMR_QUERY_ALIASMEM" , SAMR_QUERY_ALIASMEM , api_samr_query_aliasmem }, - {"SAMR_QUERY_GROUPMEM" , SAMR_QUERY_GROUPMEM , api_samr_query_groupmem }, - {"SAMR_ADD_ALIASMEM" , SAMR_ADD_ALIASMEM , api_samr_add_aliasmem }, - {"SAMR_DEL_ALIASMEM" , SAMR_DEL_ALIASMEM , api_samr_del_aliasmem }, - {"SAMR_ADD_GROUPMEM" , SAMR_ADD_GROUPMEM , api_samr_add_groupmem }, - {"SAMR_DEL_GROUPMEM" , SAMR_DEL_GROUPMEM , api_samr_del_groupmem }, - - {"SAMR_DELETE_DOM_USER" , SAMR_DELETE_DOM_USER , api_samr_delete_dom_user }, - {"SAMR_DELETE_DOM_GROUP" , SAMR_DELETE_DOM_GROUP , api_samr_delete_dom_group }, - {"SAMR_DELETE_DOM_ALIAS" , SAMR_DELETE_DOM_ALIAS , api_samr_delete_dom_alias }, - {"SAMR_CREATE_DOM_GROUP" , SAMR_CREATE_DOM_GROUP , api_samr_create_dom_group }, - {"SAMR_CREATE_DOM_ALIAS" , SAMR_CREATE_DOM_ALIAS , api_samr_create_dom_alias }, - {"SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, - {"SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, - {"SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, - {"SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo }, - {"SAMR_SET_USERINFO2" , SAMR_SET_USERINFO2 , api_samr_set_userinfo2 }, - - {"SAMR_QUERY_DOMAIN_INFO" , SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, - {"SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, - {"SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, - {"SAMR_QUERY_DISPINFO3" , SAMR_QUERY_DISPINFO3 , api_samr_query_dispinfo }, - {"SAMR_QUERY_DISPINFO4" , SAMR_QUERY_DISPINFO4 , api_samr_query_dispinfo }, - - {"SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, - {"SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, - {"SAMR_SET_GROUPINFO" , SAMR_SET_GROUPINFO , api_samr_set_groupinfo }, - {"SAMR_SET_ALIASINFO" , SAMR_SET_ALIASINFO , api_samr_set_aliasinfo }, - {"SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user }, - {"SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids }, - {"SAMR_GET_DOM_PWINFO" , SAMR_GET_DOM_PWINFO , api_samr_get_dom_pwinfo }, - {"SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, - {"SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, - {"SAMR_OPEN_GROUP" , SAMR_OPEN_GROUP , api_samr_open_group }, - {"SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, - {"SAMR_UNKNOWN_2D" , SAMR_UNKNOWN_2D , api_samr_unknown_2d }, - {"SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, - - {"SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, - {"SAMR_SET_SEC_OBJECT" , SAMR_SET_SEC_OBJECT , api_samr_set_sec_obj }, - {"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, - {"SAMR_UNKNOWN_2E" , SAMR_UNKNOWN_2E , api_samr_unknown_2e }, - {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, - {"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 }, - {NULL , 0 , NULL } -}; - -/******************************************************************* - receives a samr pipe and responds. - ********************************************************************/ -BOOL api_samr_rpc(pipes_struct *p) -{ - return api_rpcTNP(p, "api_samr_rpc", api_samr_cmds); + static struct api_struct api_samr_cmds [] = + { + {"SAMR_CLOSE_HND" , SAMR_CLOSE_HND , api_samr_close_hnd }, + {"SAMR_CONNECT" , SAMR_CONNECT , api_samr_connect }, + {"SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon }, + {"SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains }, + {"SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users }, + + {"SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, + {"SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, + {"SAMR_QUERY_USERALIASES" , SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, + {"SAMR_QUERY_ALIASMEM" , SAMR_QUERY_ALIASMEM , api_samr_query_aliasmem }, + {"SAMR_QUERY_GROUPMEM" , SAMR_QUERY_GROUPMEM , api_samr_query_groupmem }, + {"SAMR_ADD_ALIASMEM" , SAMR_ADD_ALIASMEM , api_samr_add_aliasmem }, + {"SAMR_DEL_ALIASMEM" , SAMR_DEL_ALIASMEM , api_samr_del_aliasmem }, + {"SAMR_ADD_GROUPMEM" , SAMR_ADD_GROUPMEM , api_samr_add_groupmem }, + {"SAMR_DEL_GROUPMEM" , SAMR_DEL_GROUPMEM , api_samr_del_groupmem }, + + {"SAMR_DELETE_DOM_USER" , SAMR_DELETE_DOM_USER , api_samr_delete_dom_user }, + {"SAMR_DELETE_DOM_GROUP" , SAMR_DELETE_DOM_GROUP , api_samr_delete_dom_group }, + {"SAMR_DELETE_DOM_ALIAS" , SAMR_DELETE_DOM_ALIAS , api_samr_delete_dom_alias }, + {"SAMR_CREATE_DOM_GROUP" , SAMR_CREATE_DOM_GROUP , api_samr_create_dom_group }, + {"SAMR_CREATE_DOM_ALIAS" , SAMR_CREATE_DOM_ALIAS , api_samr_create_dom_alias }, + {"SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, + {"SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, + {"SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, + {"SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo }, + {"SAMR_SET_USERINFO2" , SAMR_SET_USERINFO2 , api_samr_set_userinfo2 }, + + {"SAMR_QUERY_DOMAIN_INFO" , SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, + {"SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, + {"SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, + {"SAMR_QUERY_DISPINFO3" , SAMR_QUERY_DISPINFO3 , api_samr_query_dispinfo }, + {"SAMR_QUERY_DISPINFO4" , SAMR_QUERY_DISPINFO4 , api_samr_query_dispinfo }, + + {"SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, + {"SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, + {"SAMR_SET_GROUPINFO" , SAMR_SET_GROUPINFO , api_samr_set_groupinfo }, + {"SAMR_SET_ALIASINFO" , SAMR_SET_ALIASINFO , api_samr_set_aliasinfo }, + {"SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user }, + {"SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids }, + {"SAMR_GET_DOM_PWINFO" , SAMR_GET_DOM_PWINFO , api_samr_get_dom_pwinfo }, + {"SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, + {"SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, + {"SAMR_OPEN_GROUP" , SAMR_OPEN_GROUP , api_samr_open_group }, + {"SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, + {"SAMR_UNKNOWN_2D" , SAMR_UNKNOWN_2D , api_samr_unknown_2d }, + {"SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, + + {"SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, + {"SAMR_SET_SEC_OBJECT" , SAMR_SET_SEC_OBJECT , api_samr_set_sec_obj }, + {"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, + {"SAMR_UNKNOWN_2E" , SAMR_UNKNOWN_2E , api_samr_unknown_2e }, + {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, + {"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 } + }; + return rpc_pipe_register_commands("samr", "lsass", api_samr_cmds, + sizeof(api_samr_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 5924c5831b..5832ae876b 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -3,9 +3,10 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, - * Copyright (C) Jean François Micouleau 1998-2000. - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Gerald Carter 2001-2002. + * Copyright (C) Jean François Micouleau 1998-2000, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Gerald Carter 2001-2002, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1579,8 +1580,14 @@ static BOOL api_spoolss_replycloseprinter(pipes_struct *p) \pipe\spoolss commands ********************************************************************/ -struct api_struct api_spoolss_cmds[] = +#ifdef RPC_SPOOLSS_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_spoolss_init(void) +#endif { + struct api_struct api_spoolss_cmds[] = + { {"SPOOLSS_OPENPRINTER", SPOOLSS_OPENPRINTER, api_spoolss_open_printer }, {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex }, {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata }, @@ -1634,15 +1641,9 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_DELETEPRINTERDRIVEREX", SPOOLSS_DELETEPRINTERDRIVEREX, api_spoolss_deleteprinterdriverex }, #if 0 {"SPOOLSS_REPLYOPENPRINTER", SPOOLSS_REPLYOPENPRINTER, api_spoolss_replyopenprinter }, - {"SPOOLSS_REPLYCLOSEPRINTER", SPOOLSS_REPLYCLOSEPRINTER, api_spoolss_replycloseprinter }, + {"SPOOLSS_REPLYCLOSEPRINTER", SPOOLSS_REPLYCLOSEPRINTER, api_spoolss_replycloseprinter } #endif - { NULL, 0, NULL } -}; - -/******************************************************************* -receives a spoolss pipe and responds. -********************************************************************/ -BOOL api_spoolss_rpc(pipes_struct *p) -{ - return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds); + }; + return rpc_pipe_register_commands("spoolss", "spoolss", api_spoolss_cmds, + sizeof(api_spoolss_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 4a372de089..983c660965 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -3,8 +3,9 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -525,32 +526,32 @@ static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) \PIPE\srvsvc commands ********************************************************************/ -static const struct api_struct api_srv_cmds[] = +#ifdef RPC_SVC_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_srv_init(void) +#endif { - { "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum }, - { "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum }, - { "SRV_NET_SHARE_ENUM_ALL" , SRV_NET_SHARE_ENUM_ALL , api_srv_net_share_enum_all }, - { "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum }, - { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, - { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del }, - { "SRV_NET_SHARE_DEL_STICKY", SRV_NET_SHARE_DEL_STICKY, api_srv_net_share_del_sticky }, - { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info }, - { "SRV_NET_SHARE_SET_INFO", SRV_NET_SHARE_SET_INFO, api_srv_net_share_set_info }, - { "SRV_NET_FILE_ENUM" , SRV_NET_FILE_ENUM , api_srv_net_file_enum }, - { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, - { "SRV_NET_SRV_SET_INFO" , SRV_NET_SRV_SET_INFO , api_srv_net_srv_set_info }, - { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, - { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, - { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate}, - { "SRV_NET_FILE_QUERY_SECDESC",SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc}, - { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc}, - { NULL , 0 , NULL } -}; - -/******************************************************************* -receives a srvsvc pipe and responds. -********************************************************************/ -BOOL api_srvsvc_rpc(pipes_struct *p) -{ - return api_rpcTNP(p, "api_srvsvc_rpc", api_srv_cmds); + static const struct api_struct api_srv_cmds[] = + { + { "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum }, + { "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum }, + { "SRV_NET_SHARE_ENUM_ALL" , SRV_NET_SHARE_ENUM_ALL , api_srv_net_share_enum_all }, + { "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum }, + { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, + { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del }, + { "SRV_NET_SHARE_DEL_STICKY" , SRV_NET_SHARE_DEL_STICKY , api_srv_net_share_del_sticky }, + { "SRV_NET_SHARE_GET_INFO" , SRV_NET_SHARE_GET_INFO , api_srv_net_share_get_info }, + { "SRV_NET_SHARE_SET_INFO" , SRV_NET_SHARE_SET_INFO , api_srv_net_share_set_info }, + { "SRV_NET_FILE_ENUM" , SRV_NET_FILE_ENUM , api_srv_net_file_enum }, + { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, + { "SRV_NET_SRV_SET_INFO" , SRV_NET_SRV_SET_INFO , api_srv_net_srv_set_info }, + { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, + { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, + { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate }, + { "SRV_NET_FILE_QUERY_SECDESC", SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc }, + { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc } + }; + return rpc_pipe_register_commands("srvsvc", "ntsvcs", api_srv_cmds, + sizeof(api_srv_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index c783becbbe..1fed2cc6db 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -3,7 +3,8 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,16 +59,17 @@ static BOOL api_wks_query_info(pipes_struct *p) /******************************************************************* \PIPE\wkssvc commands ********************************************************************/ -static struct api_struct api_wks_cmds[] = -{ - { "WKS_Q_QUERY_INFO", WKS_QUERY_INFO, api_wks_query_info }, - { NULL , 0 , NULL } -}; -/******************************************************************* - receives a wkssvc pipe and responds. - ********************************************************************/ -BOOL api_wkssvc_rpc(pipes_struct *p) +#ifdef RPC_WKS_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_wks_init(void) +#endif { - return api_rpcTNP(p, "api_wkssvc_rpc", api_wks_cmds); + static struct api_struct api_wks_cmds[] = + { + { "WKS_Q_QUERY_INFO", WKS_QUERY_INFO, api_wks_query_info } + }; + return rpc_pipe_register_commands("wkssvc", "ntsvcs", api_wks_cmds, + sizeof(api_wks_cmds) / sizeof(struct api_struct)); } -- cgit From d7478da11dc5974d95567023a1a01f9bca52250f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 18 Jan 2003 01:40:29 +0000 Subject: removing extra debug statement (This used to be commit 1244ef3dbec1b63eee48d3086661afe26e23e4c0) --- source3/rpc_server/srv_reg_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index cbf237251e..db711dc6af 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -322,8 +322,6 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR rpcstr_pull(name,q_u->uni_name.buffer,sizeof(name),q_u->uni_name.uni_str_len*2,0); - DEBUG(5,("reg_open_entry: Enter\n")); - result = open_registry_key( p, &pol, key, name, 0x0 ); init_reg_r_open_entry( r_u, &pol, result ); -- cgit From 8c6790b6f0b5c205517846e7bad730a72569034a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 18 Jan 2003 01:41:00 +0000 Subject: removing extra debug statement (This used to be commit 657f8c25a585a02b86f4021e38641ee896f098d2) --- source3/rpc_server/srv_reg_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index cbf237251e..db711dc6af 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -322,8 +322,6 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR rpcstr_pull(name,q_u->uni_name.buffer,sizeof(name),q_u->uni_name.uni_str_len*2,0); - DEBUG(5,("reg_open_entry: Enter\n")); - result = open_registry_key( p, &pol, key, name, 0x0 ); init_reg_r_open_entry( r_u, &pol, result ); -- cgit From e2f25587530e8c8345c7d24cd6ed7a26c757cabf Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Sat, 18 Jan 2003 20:41:19 +0000 Subject: Fix some debug levels (were set to 0 with RPC module patch), and change one fprintf(stderr,...) to DEBUG. (This used to be commit 77f8913977343023f8ce123c305dcffc7463357b) --- source3/rpc_server/srv_pipe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index f99bd75974..4c4b3e7af3 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -864,7 +864,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) for (i = 0; i < rpc_lookup_size; i++) { if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { - DEBUG(0, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", + DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", rpc_lookup[i].pipe.clnt, rpc_lookup[i].pipe.srv)); fstrcpy(p->pipe_srv_name, rpc_lookup[i].pipe.srv); break; @@ -889,7 +889,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) for (i = 0; i < rpc_lookup_size; i++) { if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { - DEBUG(0, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", + DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", rpc_lookup[i].pipe.clnt, rpc_lookup[i].pipe.srv)); fstrcpy(p->pipe_srv_name, rpc_lookup[i].pipe.srv); break; @@ -1362,8 +1362,8 @@ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, offset1 = prs_offset(&p->out_data.rdata); - fprintf(stderr, "api_rpc_cmds[%d].fn == %p\n", - fn_num, api_rpc_cmds[fn_num].fn); + DEBUG(6, ("api_rpc_cmds[%d].fn == %p\n", + fn_num, api_rpc_cmds[fn_num].fn)); /* do the actual command */ if(!api_rpc_cmds[fn_num].fn(p)) { DEBUG(0,("api_rpcTNP: %s: %s failed.\n", rpc_name, api_rpc_cmds[fn_num].name)); -- cgit From dd99a6a81619c46ea512076f0ca860748d2fae4a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sun, 19 Jan 2003 05:04:03 +0000 Subject: strip any trailing \'s from reg key names in an open (This used to be commit d13f727c4b442d2327d134a0944c15f4cdc82aa2) --- source3/rpc_server/srv_reg_nt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index db711dc6af..8fc038eab5 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -85,10 +85,18 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY REGISTRY_KEY *regkey = NULL; NTSTATUS result = NT_STATUS_OK; REGSUBKEY_CTR subkeys; + pstring subkeyname2; + int subkey_len; DEBUG(7,("open_registry_key: name = [%s][%s]\n", parent ? parent->name : "NULL", subkeyname)); + /* strip any trailing '\'s */ + pstrcpy( subkeyname2, subkeyname ); + subkey_len = strlen ( subkeyname2 ); + if ( subkey_len && subkeyname2[subkey_len-1] == '\\' ) + subkeyname2[subkey_len-1] = '\0'; + if ((regkey=(REGISTRY_KEY*)malloc(sizeof(REGISTRY_KEY))) == NULL) return NT_STATUS_NO_MEMORY; @@ -101,7 +109,7 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY * not do this stupidity. --jerry */ - if (!subkeyname || !*subkeyname ) { + if ( !subkey_len ) { pstrcpy( regkey->name, parent->name ); } else { @@ -110,7 +118,7 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY pstrcat( regkey->name, parent->name ); pstrcat( regkey->name, "\\" ); } - pstrcat( regkey->name, subkeyname ); + pstrcat( regkey->name, subkeyname2 ); } /* Look up the table of registry I/O operations */ -- cgit From 52b65f70caa1c6ac3f978cd3a349de921fe1eea7 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sun, 19 Jan 2003 05:04:20 +0000 Subject: strip any trailing \'s from reg key names in an open (This used to be commit 03807cd56429e167ca8f3c003a4468461ecb854b) --- source3/rpc_server/srv_reg_nt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index db711dc6af..8fc038eab5 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -85,10 +85,18 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY REGISTRY_KEY *regkey = NULL; NTSTATUS result = NT_STATUS_OK; REGSUBKEY_CTR subkeys; + pstring subkeyname2; + int subkey_len; DEBUG(7,("open_registry_key: name = [%s][%s]\n", parent ? parent->name : "NULL", subkeyname)); + /* strip any trailing '\'s */ + pstrcpy( subkeyname2, subkeyname ); + subkey_len = strlen ( subkeyname2 ); + if ( subkey_len && subkeyname2[subkey_len-1] == '\\' ) + subkeyname2[subkey_len-1] = '\0'; + if ((regkey=(REGISTRY_KEY*)malloc(sizeof(REGISTRY_KEY))) == NULL) return NT_STATUS_NO_MEMORY; @@ -101,7 +109,7 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY * not do this stupidity. --jerry */ - if (!subkeyname || !*subkeyname ) { + if ( !subkey_len ) { pstrcpy( regkey->name, parent->name ); } else { @@ -110,7 +118,7 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY pstrcat( regkey->name, parent->name ); pstrcat( regkey->name, "\\" ); } - pstrcat( regkey->name, subkeyname ); + pstrcat( regkey->name, subkeyname2 ); } /* Look up the table of registry I/O operations */ -- cgit From 2d12fa42941d708f851283833ee35d9c507ea4d8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 21 Jan 2003 03:42:26 +0000 Subject: don't free() auto variables; fixes segfault when looking up RefusePasswordChange registry value (This used to be commit b3fc458e9e4b90deb971dd2495786e74c8b425bd) --- source3/rpc_server/srv_reg_nt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 8fc038eab5..5632544909 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -352,7 +352,6 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) int value_length; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); REGISTRY_VALUE *val = NULL; - REGISTRY_VALUE emptyval; REGVAL_CTR regvals; int i; @@ -374,8 +373,11 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) /* couple of hard coded registry values */ if ( strequal(name, "RefusePasswordChange") ) { - ZERO_STRUCTP( &emptyval ); - val = &emptyval; + if ( (val = (REGISTRY_VALUE*)malloc(sizeof(REGISTRY_VALUE))) == NULL ) { + DEBUG(0,("_reg_info: malloc() failed!\n")); + return NT_STATUS_NO_MEMORY; + } + ZERO_STRUCTP( val ); goto out; } -- cgit From 2bdcf68ab680c9e2103815bf08edb519e9e62088 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 21 Jan 2003 03:42:38 +0000 Subject: don't free() auto variables; fixes segfault when looking up RefusePasswordChange registry value (This used to be commit d89b0bff44fe31244b1835aee0c96c4900d90dc6) --- source3/rpc_server/srv_reg_nt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 8fc038eab5..5632544909 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -352,7 +352,6 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) int value_length; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); REGISTRY_VALUE *val = NULL; - REGISTRY_VALUE emptyval; REGVAL_CTR regvals; int i; @@ -374,8 +373,11 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) /* couple of hard coded registry values */ if ( strequal(name, "RefusePasswordChange") ) { - ZERO_STRUCTP( &emptyval ); - val = &emptyval; + if ( (val = (REGISTRY_VALUE*)malloc(sizeof(REGISTRY_VALUE))) == NULL ) { + DEBUG(0,("_reg_info: malloc() failed!\n")); + return NT_STATUS_NO_MEMORY; + } + ZERO_STRUCTP( val ); goto out; } -- cgit From 28e3e4843194e2559714adc03e05c43f9328aeda Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 2 Feb 2003 05:10:26 +0000 Subject: Send the user's session key in the SAMLOGON reply, so that a member server can use smb signing. Andrew Bartlett (This used to be commit 574e8a8ab7c94ecd9113df42e395e83632980675) --- source3/rpc_server/srv_netlog_nt.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index c3d48a6527..6182da53d9 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -666,7 +666,9 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * pstring my_name; fstring user_sid_string; fstring group_sid_string; - + uchar user_sess_key[16]; + uchar netlogon_sess_key[16]; + sampw = server_info->sam_account; /* set up pointer indicating user/password failed to be found */ @@ -697,6 +699,12 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return status; } + ZERO_STRUCT(netlogon_sess_key); + memcpy(netlogon_sess_key, p->dc.sess_key, 8); + memcpy(user_sess_key, server_info->session_key, sizeof(user_sess_key)); + SamOEMhash(user_sess_key, netlogon_sess_key, 16); + ZERO_STRUCT(netlogon_sess_key); + init_net_user_info3(p->mem_ctx, usr_info, user_rid, group_rid, @@ -719,13 +727,14 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * num_gids, /* uint32 num_groups */ gids , /* DOM_GID *gids */ 0x20 , /* uint32 user_flgs (?) */ - NULL, /* uchar sess_key[16] */ + user_sess_key, my_name , /* char *logon_srv */ pdb_get_domain(sampw), &domain_sid, /* DOM_SID *dom_sid */ /* Should be users domain sid, not servers - for trusted domains */ NULL); /* char *other_sids */ + ZERO_STRUCT(user_sess_key); } free_server_info(&server_info); return status; -- cgit From 3719bfd1a0d15c7c17d86bc049634063434ba8ca Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 2 Feb 2003 05:22:37 +0000 Subject: Merge from HEAD: Send the session key to the client, allowing it to perform SMB signing. Andrew Bartlett (This used to be commit 9bcdb869e53ee8048dd69053b804bdaf55db7b91) --- source3/rpc_server/srv_netlog_nt.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index c3d48a6527..8070cdd984 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -666,6 +666,8 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * pstring my_name; fstring user_sid_string; fstring group_sid_string; + uchar user_sess_key[16]; + uchar netlogon_sess_key[16]; sampw = server_info->sam_account; @@ -697,6 +699,12 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return status; } + ZERO_STRUCT(netlogon_sess_key); + memcpy(netlogon_sess_key, p->dc.sess_key, 8); + memcpy(user_sess_key, server_info->session_key, sizeof(user_sess_key)); + SamOEMhash(user_sess_key, netlogon_sess_key, 16); + ZERO_STRUCT(netlogon_sess_key); + init_net_user_info3(p->mem_ctx, usr_info, user_rid, group_rid, @@ -719,13 +727,14 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * num_gids, /* uint32 num_groups */ gids , /* DOM_GID *gids */ 0x20 , /* uint32 user_flgs (?) */ - NULL, /* uchar sess_key[16] */ + user_sess_key, my_name , /* char *logon_srv */ pdb_get_domain(sampw), &domain_sid, /* DOM_SID *dom_sid */ /* Should be users domain sid, not servers - for trusted domains */ NULL); /* char *other_sids */ + ZERO_STRUCT(user_sess_key); } free_server_info(&server_info); return status; -- cgit From 7d854ebcc67a3c71d3a070dbfc283249787ac4fc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 5 Feb 2003 22:09:06 +0000 Subject: Fixed type. Jeremy. (This used to be commit 76c3ccf6ed258b43d7cf1222524d8e5d2bdc8c82) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b44910883c..e316fc9acb 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1042,7 +1042,7 @@ done: static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, void *buf, size_t len ) { - int offset = 0; + size_t offset = 0; /* Unpack message */ -- cgit From 56060dcf9eef28a8506ddf9828f1501e1bf48801 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 5 Feb 2003 22:09:32 +0000 Subject: Fixed type. Jeremy. (This used to be commit ae635bb6ec05ded8a36d7876be8f3e1b8475e35b) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b44910883c..e316fc9acb 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1042,7 +1042,7 @@ done: static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, void *buf, size_t len ) { - int offset = 0; + size_t offset = 0; /* Unpack message */ -- cgit From b4776d89ea9861def5b9d491b3ec6b881d086505 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Feb 2003 05:42:19 +0000 Subject: added the LSA privileges server backend stubs. Right now they just log what was requested. (This used to be commit 64ac6c2bcb729c4658de48e929cc792681903ecc) --- source3/rpc_server/srv_lsa.c | 99 ++++++++++++++++++++++++++++++++++++++++- source3/rpc_server/srv_lsa_nt.c | 81 +++++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 815de390ec..ace95e7308 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -642,6 +642,100 @@ static BOOL api_lsa_query_info2(pipes_struct *p) } + +/*************************************************************************** + api_lsa_enum_acctrights + ***************************************************************************/ +static BOOL api_lsa_enum_acct_rights(pipes_struct *p) +{ + LSA_Q_ENUM_ACCT_RIGHTS q_u; + LSA_R_ENUM_ACCT_RIGHTS r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_enum_acct_rights("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_enum_acct_rights: failed to unmarshall LSA_Q_ENUM_ACCT_RIGHTS.\n")); + return False; + } + + r_u.status = _lsa_enum_acct_rights(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_enum_acct_rights("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_enum_acct_rights: Failed to marshall LSA_R_ENUM_ACCT_RIGHTS.\n")); + return False; + } + + return True; +} + + +/*************************************************************************** + api_lsa_add_acctrights + ***************************************************************************/ +static BOOL api_lsa_add_acct_rights(pipes_struct *p) +{ + LSA_Q_ADD_ACCT_RIGHTS q_u; + LSA_R_ADD_ACCT_RIGHTS r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_add_acct_rights("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_add_acct_rights: failed to unmarshall LSA_Q_ADD_ACCT_RIGHTS.\n")); + return False; + } + + r_u.status = _lsa_add_acct_rights(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_add_acct_rights("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_add_acct_rights: Failed to marshall LSA_R_ADD_ACCT_RIGHTS.\n")); + return False; + } + + return True; +} + + +/*************************************************************************** + api_lsa_remove_acctrights + ***************************************************************************/ +static BOOL api_lsa_remove_acct_rights(pipes_struct *p) +{ + LSA_Q_REMOVE_ACCT_RIGHTS q_u; + LSA_R_REMOVE_ACCT_RIGHTS r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_remove_acct_rights("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_remove_acct_rights: failed to unmarshall LSA_Q_REMOVE_ACCT_RIGHTS.\n")); + return False; + } + + r_u.status = _lsa_remove_acct_rights(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_remove_acct_rights("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_remove_acct_rights: Failed to marshall LSA_R_REMOVE_ACCT_RIGHTS.\n")); + return False; + } + + return True; +} + + /*************************************************************************** \PIPE\ntlsa commands ***************************************************************************/ @@ -673,7 +767,10 @@ int rpc_lsa_init(void) { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs }, { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs }, { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, - { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 } + { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 }, + { "LSA_ENUMACCTRIGHTS" , LSA_ENUMACCTRIGHTS , api_lsa_enum_acct_rights }, + { "LSA_ADDACCTRIGHTS" , LSA_ADDACCTRIGHTS , api_lsa_add_acct_rights }, + { "LSA_REMOVEACCTRIGHTS", LSA_REMOVEACCTRIGHTS, api_lsa_remove_acct_rights}, }; return rpc_pipe_register_commands("lsarpc", "lsass", api_lsa_cmds, diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index fc51d7ef2f..7a2f5ae443 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1260,3 +1260,84 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I return r_u->status; } + + +/*************************************************************************** + For a given SID, enumerate all the privilege this account has. + ***************************************************************************/ +NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA_R_ENUM_ACCT_RIGHTS *r_u) +{ + struct lsa_info *info=NULL; + char **rights = NULL; + int num_rights = 0; + + r_u->status = NT_STATUS_OK; + + /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; + + init_r_enum_acct_rights(r_u, num_rights, rights); + + return r_u->status; +} + +/*************************************************************************** + add privileges to a acct by SID + ***************************************************************************/ +NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R_ADD_ACCT_RIGHTS *r_u) +{ + struct lsa_info *info=NULL; + int i; + + r_u->status = NT_STATUS_OK; + + /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; + + /* no backend yet - just print them */ + + DEBUG(5,("_lsa_add_acct_rights to %s (%d rights)\n", + sid_string_static(&q_u->sid.sid), q_u->rights.count)); + + for (i=0;irights.count;i++) { + DEBUG(5,("\t%s\n", unistr2_static(&q_u->rights.strings[i].string))); + } + + init_r_add_acct_rights(r_u); + + return r_u->status; +} + + +/*************************************************************************** + remove privileges from a acct by SID + ***************************************************************************/ +NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, LSA_R_REMOVE_ACCT_RIGHTS *r_u) +{ + struct lsa_info *info=NULL; + int i; + + r_u->status = NT_STATUS_OK; + + /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; + + + /* no backend yet - just print them */ + + DEBUG(5,("_lsa_remove_acct_rights from %s all=%d (%d rights)\n", + sid_string_static(&q_u->sid.sid), + q_u->removeall, + q_u->rights.count)); + + for (i=0;irights.count;i++) { + DEBUG(5,("\t%s\n", unistr2_static(&q_u->rights.strings[i].string))); + } + + init_r_remove_acct_rights(r_u); + + return r_u->status; +} -- cgit From 8ddccd47c733abe6118c6f6f8d011bfc508396c1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 11 Feb 2003 21:55:48 +0000 Subject: added server stubs for lsa_enum_acct_with_right (This used to be commit aa2abacaf48924797b6803786c14c9f303185e4a) --- source3/rpc_server/srv_lsa.c | 32 ++++++++++++++++++++++++++++++++ source3/rpc_server/srv_lsa_nt.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index ace95e7308..fad8f5641a 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -674,6 +674,37 @@ static BOOL api_lsa_enum_acct_rights(pipes_struct *p) } +/*************************************************************************** + api_lsa_enum_acct_with_right + ***************************************************************************/ +static BOOL api_lsa_enum_acct_with_right(pipes_struct *p) +{ + LSA_Q_ENUM_ACCT_WITH_RIGHT q_u; + LSA_R_ENUM_ACCT_WITH_RIGHT r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_enum_acct_with_right("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_enum_acct_with_right: failed to unmarshall LSA_Q_ENUM_ACCT_WITH_RIGHT.\n")); + return False; + } + + r_u.status = _lsa_enum_acct_with_right(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_enum_acct_with_right("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_enum_acct_with_right: Failed to marshall LSA_R_ENUM_ACCT_WITH_RIGHT.\n")); + return False; + } + + return True; +} + + /*************************************************************************** api_lsa_add_acctrights ***************************************************************************/ @@ -769,6 +800,7 @@ int rpc_lsa_init(void) { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 }, { "LSA_ENUMACCTRIGHTS" , LSA_ENUMACCTRIGHTS , api_lsa_enum_acct_rights }, + { "LSA_ENUMACCTWITHRIGHT", LSA_ENUMACCTWITHRIGHT, api_lsa_enum_acct_with_right }, { "LSA_ADDACCTRIGHTS" , LSA_ADDACCTRIGHTS , api_lsa_add_acct_rights }, { "LSA_REMOVEACCTRIGHTS", LSA_REMOVEACCTRIGHTS, api_lsa_remove_acct_rights}, }; diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 7a2f5ae443..57e8177bc6 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1282,6 +1282,35 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA return r_u->status; } +/*************************************************************************** +return a list of SIDs for a particular privilege + ***************************************************************************/ +NTSTATUS _lsa_enum_acct_with_right(pipes_struct *p, + LSA_Q_ENUM_ACCT_WITH_RIGHT *q_u, + LSA_R_ENUM_ACCT_WITH_RIGHT *r_u) +{ + struct lsa_info *info=NULL; + char *right; + DOM_SID *sids = NULL; + uint32 count = 0; + + r_u->status = NT_STATUS_OK; + + /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; + + right = unistr2_tdup(p->mem_ctx, &q_u->right); + + DEBUG(5,("lsa_enum_acct_with_right on right %s\n", right)); + + /* no backend db yet .... */ + + init_r_enum_acct_with_right(r_u, count, sids); + + return r_u->status; +} + /*************************************************************************** add privileges to a acct by SID ***************************************************************************/ -- cgit From faf30e69ae0a54a770ef230c0ebae802c0a86be4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Feb 2003 09:14:35 +0000 Subject: initial server side privileges implementation, using a tdb. This needs to be hooked into pdb, and we need some access control on changing privileges. That's next (This used to be commit f4f1f84a6bf1d356ccc83f0ecb135bef4a39619e) --- source3/rpc_server/srv_lsa_nt.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 57e8177bc6..b230381d62 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1270,6 +1270,7 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA struct lsa_info *info=NULL; char **rights = NULL; int num_rights = 0; + int i; r_u->status = NT_STATUS_OK; @@ -1277,8 +1278,15 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; + r_u->status = privilege_enum_account_rights(&q_u->sid.sid, &num_rights, &rights); + init_r_enum_acct_rights(r_u, num_rights, rights); + for (i=0;istatus; } @@ -1304,10 +1312,12 @@ NTSTATUS _lsa_enum_acct_with_right(pipes_struct *p, DEBUG(5,("lsa_enum_acct_with_right on right %s\n", right)); - /* no backend db yet .... */ + r_u->status = privilege_enum_account_with_right(right, &count, &sids); init_r_enum_acct_with_right(r_u, count, sids); + safe_free(sids); + return r_u->status; } @@ -1325,8 +1335,6 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - /* no backend yet - just print them */ - DEBUG(5,("_lsa_add_acct_rights to %s (%d rights)\n", sid_string_static(&q_u->sid.sid), q_u->rights.count)); @@ -1334,6 +1342,17 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R DEBUG(5,("\t%s\n", unistr2_static(&q_u->rights.strings[i].string))); } + + for (i=0;irights.count;i++) { + r_u->status = privilege_add_account_right(unistr2_static(&q_u->rights.strings[i].string), + &q_u->sid.sid); + if (!NT_STATUS_IS_OK(r_u->status)) { + DEBUG(2,("Failed to add right '%s'\n", + unistr2_static(&q_u->rights.strings[i].string))); + break; + } + } + init_r_add_acct_rights(r_u); return r_u->status; @@ -1355,8 +1374,6 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, return NT_STATUS_INVALID_HANDLE; - /* no backend yet - just print them */ - DEBUG(5,("_lsa_remove_acct_rights from %s all=%d (%d rights)\n", sid_string_static(&q_u->sid.sid), q_u->removeall, @@ -1366,6 +1383,16 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, DEBUG(5,("\t%s\n", unistr2_static(&q_u->rights.strings[i].string))); } + for (i=0;irights.count;i++) { + r_u->status = privilege_remove_account_right(unistr2_static(&q_u->rights.strings[i].string), + &q_u->sid.sid); + if (!NT_STATUS_IS_OK(r_u->status)) { + DEBUG(2,("Failed to remove right '%s'\n", + unistr2_static(&q_u->rights.strings[i].string))); + break; + } + } + init_r_remove_acct_rights(r_u); return r_u->status; -- cgit From 0ab1705cbc177f8d31285222ba64618f2c1314ae Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 13 Feb 2003 06:51:51 +0000 Subject: Merge JohnR's patch. Removed extra copy of server name in the printername field (it was mangling the the name to be \\server\\\server\printer ... yes, there were 3 backslashes) reported by get & enum jobs level 2. Jeremy. (This used to be commit 2d63f3a13d2cea794eb413023b83c4a1071eaea0) --- source3/rpc_server/srv_spoolss_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e316fc9acb..6a8333eeea 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6137,9 +6137,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, job_info->jobid=queue->job; - slprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", get_called_name(), ntprinter->info_2->printername); - - init_unistr(&job_info->printername, chaine); + init_unistr(&job_info->printername, ntprinter->info_2->printername); init_unistr(&job_info->machinename, temp_name); init_unistr(&job_info->username, queue->fs_user); -- cgit From f4092b90bf4268a6499188e22000aec8c91b49ad Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 13 Feb 2003 06:52:45 +0000 Subject: Merge JohnR's patch. Removed extra copy of server name in the printername field (it was mangling the the name to be \\server\\\server\printer ... yes, there were 3 backslashes) reported by get & enum jobs level 2. Jeremy. (This used to be commit d079edf7327acba7f00b5868e7e6ce91ddc1eb14) --- source3/rpc_server/srv_spoolss_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e316fc9acb..6a8333eeea 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6137,9 +6137,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, job_info->jobid=queue->job; - slprintf(chaine, sizeof(chaine)-1, "\\\\%s\\%s", get_called_name(), ntprinter->info_2->printername); - - init_unistr(&job_info->printername, chaine); + init_unistr(&job_info->printername, ntprinter->info_2->printername); init_unistr(&job_info->machinename, temp_name); init_unistr(&job_info->username, queue->fs_user); -- cgit From db937d39656c1d1bace72b67724902e18b751330 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 13 Feb 2003 19:42:50 +0000 Subject: Removed unused variable. Jeremy. (This used to be commit c9654c8ec71903c59ff5f66c3fd6ea1baa599133) --- source3/rpc_server/srv_spoolss_nt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 6a8333eeea..594c749c9c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6129,7 +6129,6 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, DEVICEMODE *devmode) { pstring temp_name; - pstring chaine; struct tm *t; t=gmtime(&queue->time); -- cgit From 02da4c79444152a074d79e3b5b8b293a0b61ea1b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 13 Feb 2003 19:49:28 +0000 Subject: Removed unused variable. Jeremy. (This used to be commit a29f1aa85f23fa82795a06ad81b26895b025954b) --- source3/rpc_server/srv_spoolss_nt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 6a8333eeea..594c749c9c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6129,7 +6129,6 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, DEVICEMODE *devmode) { pstring temp_name; - pstring chaine; struct tm *t; t=gmtime(&queue->time); -- cgit From 49d3f7bc81d3ce96513128f3e504ae1228e53d68 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 14 Feb 2003 00:48:28 +0000 Subject: merge from HEAD - enable dynamic RPC modules (This used to be commit d9c485b01017594d113502f9de2248d6c120cfa3) --- source3/rpc_server/srv_dfs.c | 36 +++--- source3/rpc_server/srv_lsa.c | 21 ++-- source3/rpc_server/srv_netlog.c | 44 ++++---- source3/rpc_server/srv_pipe.c | 238 ++++++++++++++++++++++++++++++++------- source3/rpc_server/srv_reg.c | 55 ++++----- source3/rpc_server/srv_samr.c | 128 ++++++++++----------- source3/rpc_server/srv_spoolss.c | 29 ++--- source3/rpc_server/srv_srvsvc.c | 59 +++++----- source3/rpc_server/srv_wkssvc.c | 24 ++-- 9 files changed, 400 insertions(+), 234 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 676ad8e3f3..f6e9ca3d56 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -3,8 +3,9 @@ * RPC Pipe client / server routines for Dfs * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Shirish Kalele 2000. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Shirish Kalele 2000, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -157,21 +158,20 @@ static BOOL api_dfs_enum(pipes_struct *p) \pipe\netdfs commands ********************************************************************/ -struct api_struct api_netdfs_cmds[] = +#ifdef RPC_DFS_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_dfs_init(void) +#endif { - {"DFS_EXIST", DFS_EXIST, api_dfs_exist }, - {"DFS_ADD", DFS_ADD, api_dfs_add }, - {"DFS_REMOVE", DFS_REMOVE, api_dfs_remove }, - {"DFS_GET_INFO", DFS_GET_INFO, api_dfs_get_info }, - {"DFS_ENUM", DFS_ENUM, api_dfs_enum }, - {NULL, 0, NULL } -}; - -/******************************************************************* -receives a netdfs pipe and responds. -********************************************************************/ - -BOOL api_netdfs_rpc(pipes_struct *p) -{ - return api_rpcTNP(p, "api_netdfs_rpc", api_netdfs_cmds); + struct api_struct api_netdfs_cmds[] = + { + {"DFS_EXIST", DFS_EXIST, api_dfs_exist }, + {"DFS_ADD", DFS_ADD, api_dfs_add }, + {"DFS_REMOVE", DFS_REMOVE, api_dfs_remove }, + {"DFS_GET_INFO", DFS_GET_INFO, api_dfs_get_info }, + {"DFS_ENUM", DFS_ENUM, api_dfs_enum } + }; + return rpc_pipe_register_commands("netdfs", "netdfs", api_netdfs_cmds, + sizeof(api_netdfs_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index a2c2290fb7..11388a00b1 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -5,7 +5,8 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Jim McDonough 2002. + * Copyright (C) Jim McDonough 2002, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -644,7 +645,12 @@ static BOOL api_lsa_query_info2(pipes_struct *p) /*************************************************************************** \PIPE\ntlsa commands ***************************************************************************/ - +#ifdef RPC_LSA_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_lsa_init(void) +#endif +{ static const struct api_struct api_lsa_cmds[] = { { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 }, @@ -666,14 +672,9 @@ static const struct api_struct api_lsa_cmds[] = { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs }, { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs }, { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, - { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 }, - { NULL , 0 , NULL } + { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 } }; -/*************************************************************************** - api_ntLsarpcTNP - ***************************************************************************/ -BOOL api_ntlsa_rpc(pipes_struct *p) -{ - return api_rpcTNP(p, "api_ntlsa_rpc", api_lsa_cmds); + return rpc_pipe_register_commands("lsarpc", "lsass", api_lsa_cmds, + sizeof(api_lsa_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index f96a0e2f2d..f377d3952b 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -3,8 +3,9 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jeremy Allison 1998-2001. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Jeremy Allison 1998-2001, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -319,25 +320,26 @@ static BOOL api_net_logon_ctrl(pipes_struct *p) /******************************************************************* array of \PIPE\NETLOGON operations ********************************************************************/ -static struct api_struct api_net_cmds [] = -{ - { "NET_REQCHAL" , NET_REQCHAL , api_net_req_chal }, - { "NET_AUTH" , NET_AUTH , api_net_auth }, - { "NET_AUTH2" , NET_AUTH2 , api_net_auth_2 }, - { "NET_SRVPWSET" , NET_SRVPWSET , api_net_srv_pwset }, - { "NET_SAMLOGON" , NET_SAMLOGON , api_net_sam_logon }, - { "NET_SAMLOGOFF" , NET_SAMLOGOFF , api_net_sam_logoff }, - { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 }, - { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, - { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl }, - { NULL , 0 , NULL } -}; - -/******************************************************************* - receives a netlogon pipe and responds. - ********************************************************************/ -BOOL api_netlog_rpc(pipes_struct *p) +#ifdef RPC_NETLOG_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_net_init(void) +#endif { - return api_rpcTNP(p, "api_netlog_rpc", api_net_cmds); + static struct api_struct api_net_cmds [] = + { + { "NET_REQCHAL" , NET_REQCHAL , api_net_req_chal }, + { "NET_AUTH" , NET_AUTH , api_net_auth }, + { "NET_AUTH2" , NET_AUTH2 , api_net_auth_2 }, + { "NET_SRVPWSET" , NET_SRVPWSET , api_net_srv_pwset }, + { "NET_SAMLOGON" , NET_SAMLOGON , api_net_sam_logon }, + { "NET_SAMLOGOFF" , NET_SAMLOGOFF , api_net_sam_logoff }, + { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 }, + { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, + { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl } + }; + + return rpc_pipe_register_commands("NETLOGON", "lsass", api_net_cmds, + sizeof(api_net_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 8aaab43461..4c4b3e7af3 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -3,8 +3,9 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1998 * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, - * Copyright (C) Paul Ashton 1997-1998. - * Copyright (C) Jeremy Allison 1999. + * Copyright (C) Paul Ashton 1997-1998, + * Copyright (C) Jeremy Allison 1999, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -457,24 +458,53 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); struct api_cmd { - const char * pipe_clnt_name; - const char * pipe_srv_name; - BOOL (*fn) (pipes_struct *); + const char *name; + int (*init)(void); }; static struct api_cmd api_fd_commands[] = { - { "lsarpc", "lsass", api_ntlsa_rpc }, - { "samr", "lsass", api_samr_rpc }, - { "srvsvc", "ntsvcs", api_srvsvc_rpc }, - { "wkssvc", "ntsvcs", api_wkssvc_rpc }, - { "NETLOGON", "lsass", api_netlog_rpc }, - { "winreg", "winreg", api_reg_rpc }, - { "spoolss", "spoolss", api_spoolss_rpc }, - { "netdfs", "netdfs" , api_netdfs_rpc }, - { NULL, NULL, NULL } +#ifndef RPC_LSA_DYNAMIC + { "lsarpc", rpc_lsa_init }, +#endif +#ifndef RPC_SAMR_DYNAMIC + { "samr", rpc_samr_init }, +#endif +#ifndef RPC_SVC_DYNAMIC + { "srvsvc", rpc_srv_init }, +#endif +#ifndef RPC_WKS_DYNAMIC + { "wkssvc", rpc_wks_init }, +#endif +#ifndef RPC_NETLOG_DYNAMIC + { "NETLOGON", rpc_net_init }, +#endif +#ifndef RPC_REG_DYNAMIC + { "winreg", rpc_reg_init }, +#endif +#ifndef RPC_SPOOLSS_DYNAMIC + { "spoolss", rpc_spoolss_init }, +#endif +#ifndef RPC_DFS_DYNAMIC + { "netdfs", rpc_dfs_init }, +#endif + { NULL, NULL } }; +struct rpc_table +{ + struct + { + const char *clnt; + const char *srv; + } pipe; + struct api_struct *cmds; + int n_cmds; +}; + +static struct rpc_table *rpc_lookup; +static int rpc_lookup_size; + /******************************************************************* This is the client reply to our challenge for an authenticated bind request. The challenge we sent is in p->challenge. @@ -681,6 +711,7 @@ BOOL check_bind_req(char* pipe_name, RPC_IFACE* abstract, fstrcpy(pname,"\\PIPE\\"); fstrcat(pname,pipe_name); + DEBUG(3,("check_bind_req for %s\n", pname)); #ifndef SUPPORT_NEW_LSARPC_UUID @@ -727,6 +758,82 @@ BOOL check_bind_req(char* pipe_name, RPC_IFACE* abstract, return True; } +/******************************************************************* + Register commands to an RPC pipe +*******************************************************************/ +int rpc_pipe_register_commands(const char *clnt, const char *srv, const struct api_struct *cmds, int size) +{ + struct rpc_table *rpc_entry; + + + /* We use a temporary variable because this call can fail and + rpc_lookup will still be valid afterwards. It could then succeed if + called again later */ + rpc_entry = realloc(rpc_lookup, + ++rpc_lookup_size*sizeof(struct rpc_table)); + if (NULL == rpc_entry) { + rpc_lookup_size--; + DEBUG(0, ("rpc_pipe_register_commands: memory allocation failed\n")); + return 0; + } else { + rpc_lookup = rpc_entry; + } + + rpc_entry = rpc_lookup + (rpc_lookup_size - 1); + ZERO_STRUCTP(rpc_entry); + rpc_entry->pipe.clnt = strdup(clnt); + rpc_entry->pipe.srv = strdup(srv); + rpc_entry->cmds = realloc(rpc_entry->cmds, + (rpc_entry->n_cmds + size) * + sizeof(struct api_struct)); + memcpy(rpc_entry->cmds + rpc_entry->n_cmds, cmds, + size * sizeof(struct api_struct)); + rpc_entry->n_cmds += size; + + return size; +} + +/******************************************************************* + Register commands to an RPC pipe +*******************************************************************/ +int rpc_load_module(const char *module) +{ +#ifdef HAVE_DLOPEN + void *handle; + int (*module_init)(void); + pstring full_path; + char *error; + + pstrcpy(full_path, lib_path("rpc")); + pstrcat(full_path, "/librpc_"); + pstrcat(full_path, module); + pstrcat(full_path, "."); + pstrcat(full_path, shlib_ext()); + + handle = sys_dlopen(full_path, RTLD_LAZY); + if (!handle) { + DEBUG(0, ("Could not load requested pipe %s as %s\n", + module, full_path)); + DEBUG(0, (" Error: %s\n", dlerror())); + return 0; + } + + DEBUG(3, ("Module '%s' loaded\n", full_path)); + + module_init = sys_dlsym(handle, "rpc_pipe_init"); + if ((error = sys_dlerror()) != NULL) { + DEBUG(0, ("Error trying to resolve symbol 'rpc_pipe_init' in %s: %s\n", + full_path, error)); + return 0; + } + + return module_init(); +#else + DEBUG(0,("Attempting to load a dynamic RPC pipe when dlopen isn't available\n")); + return 0; +#endif +} + /******************************************************************* Respond to a pipe bind request. *******************************************************************/ @@ -754,23 +861,40 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) * that this is a pipe name we support. */ - for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { - if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && - api_fd_commands[i].fn != NULL) { - DEBUG(3,("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", - api_fd_commands[i].pipe_clnt_name, - api_fd_commands[i].pipe_srv_name)); - fstrcpy(p->pipe_srv_name, api_fd_commands[i].pipe_srv_name); - break; - } + + for (i = 0; i < rpc_lookup_size; i++) { + if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { + DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", + rpc_lookup[i].pipe.clnt, rpc_lookup[i].pipe.srv)); + fstrcpy(p->pipe_srv_name, rpc_lookup[i].pipe.srv); + break; + } } - if (api_fd_commands[i].fn == NULL) { - DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", - p->name )); - if(!setup_bind_nak(p)) - return False; - return True; + if (i == rpc_lookup_size) { + for (i = 0; api_fd_commands[i].name; i++) { + if (strequal(api_fd_commands[i].name, p->name)) { + api_fd_commands[i].init(); + break; + } + } + + if (!api_fd_commands[i].name && !rpc_load_module(p->name)) { + DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", + p->name )); + if(!setup_bind_nak(p)) + return False; + return True; + } + + for (i = 0; i < rpc_lookup_size; i++) { + if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { + DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", + rpc_lookup[i].pipe.clnt, rpc_lookup[i].pipe.srv)); + fstrcpy(p->pipe_srv_name, rpc_lookup[i].pipe.srv); + break; + } + } } /* decode the bind request */ @@ -1153,14 +1277,46 @@ BOOL api_pipe_request(pipes_struct *p) } } - for (i = 0; api_fd_commands[i].pipe_clnt_name; i++) { - if (strequal(api_fd_commands[i].pipe_clnt_name, p->name) && - api_fd_commands[i].fn != NULL) { - DEBUG(3,("Doing \\PIPE\\%s\n", api_fd_commands[i].pipe_clnt_name)); - set_current_rpc_talloc(p->mem_ctx); - ret = api_fd_commands[i].fn(p); - set_current_rpc_talloc(NULL); - } + DEBUG(5, ("Requested \\PIPE\\%s\n", p->name)); + + for (i = 0; i < rpc_lookup_size; i++) { + if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { + DEBUG(3,("Doing \\PIPE\\%s\n", + rpc_lookup[i].pipe.clnt)); + set_current_rpc_talloc(p->mem_ctx); + ret = api_rpcTNP(p, rpc_lookup[i].pipe.clnt, + rpc_lookup[i].cmds, + rpc_lookup[i].n_cmds); + set_current_rpc_talloc(NULL); + break; + } + } + + + if (i == rpc_lookup_size) { + for (i = 0; api_fd_commands[i].name; i++) { + if (strequal(api_fd_commands[i].name, p->name)) { + api_fd_commands[i].init(); + break; + } + } + + if (!api_fd_commands[i].name) { + rpc_load_module(p->name); + } + + for (i = 0; i < rpc_lookup_size; i++) { + if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { + DEBUG(3,("Doing \\PIPE\\%s\n", + rpc_lookup[i].pipe.clnt)); + set_current_rpc_talloc(p->mem_ctx); + ret = api_rpcTNP(p, rpc_lookup[i].pipe.clnt, + rpc_lookup[i].cmds, + rpc_lookup[i].n_cmds); + set_current_rpc_talloc(NULL); + break; + } + } } if(p->ntlmssp_auth_validated) @@ -1174,7 +1330,7 @@ BOOL api_pipe_request(pipes_struct *p) ********************************************************************/ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, - const struct api_struct *api_rpc_cmds) + const struct api_struct *api_rpc_cmds, int n_cmds) { int fn_num; fstring name; @@ -1186,14 +1342,14 @@ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, slprintf(name, sizeof(name)-1, "in_%s", rpc_name); prs_dump(name, p->hdr_req.opnum, &p->in_data.data); - for (fn_num = 0; api_rpc_cmds[fn_num].name; fn_num++) { + for (fn_num = 0; fn_num < n_cmds; fn_num++) { if (api_rpc_cmds[fn_num].opnum == p->hdr_req.opnum && api_rpc_cmds[fn_num].fn != NULL) { DEBUG(3,("api_rpcTNP: rpc command: %s\n", api_rpc_cmds[fn_num].name)); break; } } - if (api_rpc_cmds[fn_num].name == NULL) { + if (fn_num == n_cmds) { /* * For an unknown RPC just return a fault PDU but * return True to allow RPC's on the pipe to continue @@ -1206,6 +1362,8 @@ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, offset1 = prs_offset(&p->out_data.rdata); + DEBUG(6, ("api_rpc_cmds[%d].fn == %p\n", + fn_num, api_rpc_cmds[fn_num].fn)); /* do the actual command */ if(!api_rpc_cmds[fn_num].fn(p)) { DEBUG(0,("api_rpcTNP: %s: %s failed.\n", rpc_name, api_rpc_cmds[fn_num].name)); diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index d0aaf0199b..04960f8e3a 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -3,10 +3,11 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Marc Jacobsen 2000. - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Gerald Carter 2002. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Marc Jacobsen 2000, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Gerald Carter 2002, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -371,29 +372,29 @@ static BOOL api_reg_save_key(pipes_struct *p) /******************************************************************* array of \PIPE\reg operations ********************************************************************/ -static struct api_struct api_reg_cmds[] = -{ - { "REG_CLOSE" , REG_CLOSE , api_reg_close }, - { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, - { "REG_OPEN_HKCR" , REG_OPEN_HKCR , api_reg_open_hkcr }, - { "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm }, - { "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku }, - { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key }, - { "REG_ENUM_VALUE" , REG_ENUM_VALUE , api_reg_enum_value }, - { "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key }, - { "REG_INFO" , REG_INFO , api_reg_info }, - { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, - { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, - { "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a }, - { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key }, - { NULL , 0 , NULL } -}; - -/******************************************************************* - receives a reg pipe and responds. - ********************************************************************/ -BOOL api_reg_rpc(pipes_struct *p) +#ifdef RPC_REG_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_reg_init(void) +#endif { - return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds); + static struct api_struct api_reg_cmds[] = + { + { "REG_CLOSE" , REG_CLOSE , api_reg_close }, + { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, + { "REG_OPEN_HKCR" , REG_OPEN_HKCR , api_reg_open_hkcr }, + { "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm }, + { "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku }, + { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key }, + { "REG_ENUM_VALUE" , REG_ENUM_VALUE , api_reg_enum_value }, + { "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key }, + { "REG_INFO" , REG_INFO , api_reg_info }, + { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, + { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, + { "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a }, + { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key } + }; + return rpc_pipe_register_commands("winreg", "winreg", api_reg_cmds, + sizeof(api_reg_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index ab3d94cf75..3a31ec82e1 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -6,7 +6,7 @@ * Copyright (C) Paul Ashton 1997, * Copyright (C) Marc Jacobsen 1999, * Copyright (C) Jean François Micouleau 1998-2001, - * Copyright (C) Anthony Liguori 2002, + * Copyright (C) Anthony Liguori 2002-2003, * Copyright (C) Jim McDonough 2002. * * Split into interface and implementation modules by, @@ -1443,68 +1443,68 @@ static BOOL api_samr_set_dom_info(pipes_struct *p) array of \PIPE\samr operations ********************************************************************/ -static struct api_struct api_samr_cmds [] = +#ifdef RPC_SAMR_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_samr_init(void) +#endif { - {"SAMR_CLOSE_HND" , SAMR_CLOSE_HND , api_samr_close_hnd }, - {"SAMR_CONNECT" , SAMR_CONNECT , api_samr_connect }, - {"SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon }, - {"SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains }, - {"SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users }, - - {"SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, - {"SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, - {"SAMR_QUERY_USERALIASES" , SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, - {"SAMR_QUERY_ALIASMEM" , SAMR_QUERY_ALIASMEM , api_samr_query_aliasmem }, - {"SAMR_QUERY_GROUPMEM" , SAMR_QUERY_GROUPMEM , api_samr_query_groupmem }, - {"SAMR_ADD_ALIASMEM" , SAMR_ADD_ALIASMEM , api_samr_add_aliasmem }, - {"SAMR_DEL_ALIASMEM" , SAMR_DEL_ALIASMEM , api_samr_del_aliasmem }, - {"SAMR_ADD_GROUPMEM" , SAMR_ADD_GROUPMEM , api_samr_add_groupmem }, - {"SAMR_DEL_GROUPMEM" , SAMR_DEL_GROUPMEM , api_samr_del_groupmem }, - - {"SAMR_DELETE_DOM_USER" , SAMR_DELETE_DOM_USER , api_samr_delete_dom_user }, - {"SAMR_DELETE_DOM_GROUP" , SAMR_DELETE_DOM_GROUP , api_samr_delete_dom_group }, - {"SAMR_DELETE_DOM_ALIAS" , SAMR_DELETE_DOM_ALIAS , api_samr_delete_dom_alias }, - {"SAMR_CREATE_DOM_GROUP" , SAMR_CREATE_DOM_GROUP , api_samr_create_dom_group }, - {"SAMR_CREATE_DOM_ALIAS" , SAMR_CREATE_DOM_ALIAS , api_samr_create_dom_alias }, - {"SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, - {"SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, - {"SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, - {"SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo }, - {"SAMR_SET_USERINFO2" , SAMR_SET_USERINFO2 , api_samr_set_userinfo2 }, - - {"SAMR_QUERY_DOMAIN_INFO" , SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, - {"SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, - {"SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, - {"SAMR_QUERY_DISPINFO3" , SAMR_QUERY_DISPINFO3 , api_samr_query_dispinfo }, - {"SAMR_QUERY_DISPINFO4" , SAMR_QUERY_DISPINFO4 , api_samr_query_dispinfo }, - - {"SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, - {"SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, - {"SAMR_SET_GROUPINFO" , SAMR_SET_GROUPINFO , api_samr_set_groupinfo }, - {"SAMR_SET_ALIASINFO" , SAMR_SET_ALIASINFO , api_samr_set_aliasinfo }, - {"SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user }, - {"SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids }, - {"SAMR_GET_DOM_PWINFO" , SAMR_GET_DOM_PWINFO , api_samr_get_dom_pwinfo }, - {"SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, - {"SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, - {"SAMR_OPEN_GROUP" , SAMR_OPEN_GROUP , api_samr_open_group }, - {"SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, - {"SAMR_UNKNOWN_2D" , SAMR_UNKNOWN_2D , api_samr_unknown_2d }, - {"SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, - - {"SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, - {"SAMR_SET_SEC_OBJECT" , SAMR_SET_SEC_OBJECT , api_samr_set_sec_obj }, - {"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, - {"SAMR_UNKNOWN_2E" , SAMR_UNKNOWN_2E , api_samr_unknown_2e }, - {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, - {"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 }, - {NULL , 0 , NULL } -}; - -/******************************************************************* - receives a samr pipe and responds. - ********************************************************************/ -BOOL api_samr_rpc(pipes_struct *p) -{ - return api_rpcTNP(p, "api_samr_rpc", api_samr_cmds); + static struct api_struct api_samr_cmds [] = + { + {"SAMR_CLOSE_HND" , SAMR_CLOSE_HND , api_samr_close_hnd }, + {"SAMR_CONNECT" , SAMR_CONNECT , api_samr_connect }, + {"SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon }, + {"SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains }, + {"SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users }, + + {"SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, + {"SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, + {"SAMR_QUERY_USERALIASES" , SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, + {"SAMR_QUERY_ALIASMEM" , SAMR_QUERY_ALIASMEM , api_samr_query_aliasmem }, + {"SAMR_QUERY_GROUPMEM" , SAMR_QUERY_GROUPMEM , api_samr_query_groupmem }, + {"SAMR_ADD_ALIASMEM" , SAMR_ADD_ALIASMEM , api_samr_add_aliasmem }, + {"SAMR_DEL_ALIASMEM" , SAMR_DEL_ALIASMEM , api_samr_del_aliasmem }, + {"SAMR_ADD_GROUPMEM" , SAMR_ADD_GROUPMEM , api_samr_add_groupmem }, + {"SAMR_DEL_GROUPMEM" , SAMR_DEL_GROUPMEM , api_samr_del_groupmem }, + + {"SAMR_DELETE_DOM_USER" , SAMR_DELETE_DOM_USER , api_samr_delete_dom_user }, + {"SAMR_DELETE_DOM_GROUP" , SAMR_DELETE_DOM_GROUP , api_samr_delete_dom_group }, + {"SAMR_DELETE_DOM_ALIAS" , SAMR_DELETE_DOM_ALIAS , api_samr_delete_dom_alias }, + {"SAMR_CREATE_DOM_GROUP" , SAMR_CREATE_DOM_GROUP , api_samr_create_dom_group }, + {"SAMR_CREATE_DOM_ALIAS" , SAMR_CREATE_DOM_ALIAS , api_samr_create_dom_alias }, + {"SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, + {"SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, + {"SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, + {"SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo }, + {"SAMR_SET_USERINFO2" , SAMR_SET_USERINFO2 , api_samr_set_userinfo2 }, + + {"SAMR_QUERY_DOMAIN_INFO" , SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, + {"SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, + {"SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, + {"SAMR_QUERY_DISPINFO3" , SAMR_QUERY_DISPINFO3 , api_samr_query_dispinfo }, + {"SAMR_QUERY_DISPINFO4" , SAMR_QUERY_DISPINFO4 , api_samr_query_dispinfo }, + + {"SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, + {"SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, + {"SAMR_SET_GROUPINFO" , SAMR_SET_GROUPINFO , api_samr_set_groupinfo }, + {"SAMR_SET_ALIASINFO" , SAMR_SET_ALIASINFO , api_samr_set_aliasinfo }, + {"SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user }, + {"SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids }, + {"SAMR_GET_DOM_PWINFO" , SAMR_GET_DOM_PWINFO , api_samr_get_dom_pwinfo }, + {"SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, + {"SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, + {"SAMR_OPEN_GROUP" , SAMR_OPEN_GROUP , api_samr_open_group }, + {"SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, + {"SAMR_UNKNOWN_2D" , SAMR_UNKNOWN_2D , api_samr_unknown_2d }, + {"SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, + + {"SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, + {"SAMR_SET_SEC_OBJECT" , SAMR_SET_SEC_OBJECT , api_samr_set_sec_obj }, + {"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, + {"SAMR_UNKNOWN_2E" , SAMR_UNKNOWN_2E , api_samr_unknown_2e }, + {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, + {"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 } + }; + return rpc_pipe_register_commands("samr", "lsass", api_samr_cmds, + sizeof(api_samr_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 5924c5831b..5832ae876b 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -3,9 +3,10 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, - * Copyright (C) Jean François Micouleau 1998-2000. - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Gerald Carter 2001-2002. + * Copyright (C) Jean François Micouleau 1998-2000, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Gerald Carter 2001-2002, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1579,8 +1580,14 @@ static BOOL api_spoolss_replycloseprinter(pipes_struct *p) \pipe\spoolss commands ********************************************************************/ -struct api_struct api_spoolss_cmds[] = +#ifdef RPC_SPOOLSS_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_spoolss_init(void) +#endif { + struct api_struct api_spoolss_cmds[] = + { {"SPOOLSS_OPENPRINTER", SPOOLSS_OPENPRINTER, api_spoolss_open_printer }, {"SPOOLSS_OPENPRINTEREX", SPOOLSS_OPENPRINTEREX, api_spoolss_open_printer_ex }, {"SPOOLSS_GETPRINTERDATA", SPOOLSS_GETPRINTERDATA, api_spoolss_getprinterdata }, @@ -1634,15 +1641,9 @@ struct api_struct api_spoolss_cmds[] = {"SPOOLSS_DELETEPRINTERDRIVEREX", SPOOLSS_DELETEPRINTERDRIVEREX, api_spoolss_deleteprinterdriverex }, #if 0 {"SPOOLSS_REPLYOPENPRINTER", SPOOLSS_REPLYOPENPRINTER, api_spoolss_replyopenprinter }, - {"SPOOLSS_REPLYCLOSEPRINTER", SPOOLSS_REPLYCLOSEPRINTER, api_spoolss_replycloseprinter }, + {"SPOOLSS_REPLYCLOSEPRINTER", SPOOLSS_REPLYCLOSEPRINTER, api_spoolss_replycloseprinter } #endif - { NULL, 0, NULL } -}; - -/******************************************************************* -receives a spoolss pipe and responds. -********************************************************************/ -BOOL api_spoolss_rpc(pipes_struct *p) -{ - return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds); + }; + return rpc_pipe_register_commands("spoolss", "spoolss", api_spoolss_cmds, + sizeof(api_spoolss_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 4a372de089..983c660965 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -3,8 +3,9 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -525,32 +526,32 @@ static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) \PIPE\srvsvc commands ********************************************************************/ -static const struct api_struct api_srv_cmds[] = +#ifdef RPC_SVC_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_srv_init(void) +#endif { - { "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum }, - { "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum }, - { "SRV_NET_SHARE_ENUM_ALL" , SRV_NET_SHARE_ENUM_ALL , api_srv_net_share_enum_all }, - { "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum }, - { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, - { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del }, - { "SRV_NET_SHARE_DEL_STICKY", SRV_NET_SHARE_DEL_STICKY, api_srv_net_share_del_sticky }, - { "SRV_NET_SHARE_GET_INFO", SRV_NET_SHARE_GET_INFO, api_srv_net_share_get_info }, - { "SRV_NET_SHARE_SET_INFO", SRV_NET_SHARE_SET_INFO, api_srv_net_share_set_info }, - { "SRV_NET_FILE_ENUM" , SRV_NET_FILE_ENUM , api_srv_net_file_enum }, - { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, - { "SRV_NET_SRV_SET_INFO" , SRV_NET_SRV_SET_INFO , api_srv_net_srv_set_info }, - { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, - { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, - { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate}, - { "SRV_NET_FILE_QUERY_SECDESC",SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc}, - { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc}, - { NULL , 0 , NULL } -}; - -/******************************************************************* -receives a srvsvc pipe and responds. -********************************************************************/ -BOOL api_srvsvc_rpc(pipes_struct *p) -{ - return api_rpcTNP(p, "api_srvsvc_rpc", api_srv_cmds); + static const struct api_struct api_srv_cmds[] = + { + { "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum }, + { "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum }, + { "SRV_NET_SHARE_ENUM_ALL" , SRV_NET_SHARE_ENUM_ALL , api_srv_net_share_enum_all }, + { "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum }, + { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, + { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del }, + { "SRV_NET_SHARE_DEL_STICKY" , SRV_NET_SHARE_DEL_STICKY , api_srv_net_share_del_sticky }, + { "SRV_NET_SHARE_GET_INFO" , SRV_NET_SHARE_GET_INFO , api_srv_net_share_get_info }, + { "SRV_NET_SHARE_SET_INFO" , SRV_NET_SHARE_SET_INFO , api_srv_net_share_set_info }, + { "SRV_NET_FILE_ENUM" , SRV_NET_FILE_ENUM , api_srv_net_file_enum }, + { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, + { "SRV_NET_SRV_SET_INFO" , SRV_NET_SRV_SET_INFO , api_srv_net_srv_set_info }, + { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, + { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, + { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate }, + { "SRV_NET_FILE_QUERY_SECDESC", SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc }, + { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc } + }; + return rpc_pipe_register_commands("srvsvc", "ntsvcs", api_srv_cmds, + sizeof(api_srv_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index c783becbbe..1fed2cc6db 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -3,7 +3,8 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Anthony Liguori 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,16 +59,17 @@ static BOOL api_wks_query_info(pipes_struct *p) /******************************************************************* \PIPE\wkssvc commands ********************************************************************/ -static struct api_struct api_wks_cmds[] = -{ - { "WKS_Q_QUERY_INFO", WKS_QUERY_INFO, api_wks_query_info }, - { NULL , 0 , NULL } -}; -/******************************************************************* - receives a wkssvc pipe and responds. - ********************************************************************/ -BOOL api_wkssvc_rpc(pipes_struct *p) +#ifdef RPC_WKS_DYNAMIC +int rpc_pipe_init(void) +#else +int rpc_wks_init(void) +#endif { - return api_rpcTNP(p, "api_wkssvc_rpc", api_wks_cmds); + static struct api_struct api_wks_cmds[] = + { + { "WKS_Q_QUERY_INFO", WKS_QUERY_INFO, api_wks_query_info } + }; + return rpc_pipe_register_commands("wkssvc", "ntsvcs", api_wks_cmds, + sizeof(api_wks_cmds) / sizeof(struct api_struct)); } -- cgit From 8fc1f1aead6db996a6d96efdc5f81779afc9c8d2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 14 Feb 2003 22:55:46 +0000 Subject: Ensure that only parse_prs.c access internal members of the prs_struct. Needed to move to disk based i/o later. Jeremy. (This used to be commit a823fee5b41a5b6cd4ef05aa1f85f7725bd272a5) --- source3/rpc_server/srv_pipe.c | 26 +++++++++++--------------- source3/rpc_server/srv_pipe_hnd.c | 15 +++++---------- source3/rpc_server/srv_spoolss_nt.c | 5 ++--- 3 files changed, 18 insertions(+), 28 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 4c4b3e7af3..50127005a1 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -84,8 +84,6 @@ BOOL create_next_pdu(pipes_struct *p) uint32 data_space_available; uint32 data_len_left; prs_struct outgoing_pdu; - char *data; - char *data_from; uint32 data_pos; /* @@ -187,26 +185,26 @@ BOOL create_next_pdu(pipes_struct *p) data_pos = prs_offset(&outgoing_pdu); /* Copy the data into the PDU. */ - data_from = prs_data_p(&p->out_data.rdata) + p->out_data.data_sent_length; - if(!prs_append_data(&outgoing_pdu, data_from, data_len)) { + if(!prs_append_some_prs_data(&outgoing_pdu, &p->out_data.rdata, p->out_data.data_sent_length, data_len)) { DEBUG(0,("create_next_pdu: failed to copy %u bytes of data.\n", (unsigned int)data_len)); prs_mem_free(&outgoing_pdu); return False; } - /* - * Set data to point to where we copied the data into. - */ - - data = prs_data_p(&outgoing_pdu) + data_pos; - if (p->hdr.auth_len > 0) { uint32 crc32 = 0; + char *data; DEBUG(5,("create_next_pdu: sign: %s seal: %s data %d auth %d\n", BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, p->hdr.auth_len)); + /* + * Set data to point to where we copied the data into. + */ + + data = prs_data_p(&outgoing_pdu) + data_pos; + if (auth_seal) { crc32 = crc32_calc_buffer(data, data_len); NTLMSSPcalc_p(p, (uchar*)data, data_len); @@ -1389,17 +1387,15 @@ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, /* Check for buffer underflow in rpc parsing */ if ((DEBUGLEVEL >= 10) && - (p->in_data.data.data_offset != p->in_data.data.buffer_size)) { - int data_len = p->in_data.data.buffer_size - - p->in_data.data.data_offset; + (prs_offset(&p->in_data.data) != prs_data_size(&p->in_data.data))) { + size_t data_len = prs_data_size(&p->in_data.data) - prs_offset(&p->in_data.data); char *data; data = malloc(data_len); DEBUG(10, ("api_rpcTNP: rpc input buffer underflow (parse error?)\n")); if (data) { - prs_uint8s(False, "", &p->in_data.data, 0, (unsigned char *)data, - data_len); + prs_uint8s(False, "", &p->in_data.data, 0, (unsigned char *)data, (uint32)data_len); SAFE_FREE(data); } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 6cdb6836eb..8cb81b9c6d 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -618,16 +618,11 @@ authentication failed. Denying the request.\n", p->name)); * Append the data portion into the buffer and return. */ - { - char *data_from = prs_data_p(rpc_in_p) + prs_offset(rpc_in_p); - - if(!prs_append_data(&p->in_data.data, data_from, data_len)) { - DEBUG(0,("process_request_pdu: Unable to append data size %u to parse buffer of size %u.\n", - (unsigned int)data_len, (unsigned int)prs_data_size(&p->in_data.data) )); - set_incoming_fault(p); - return False; - } - + if(!prs_append_some_prs_data(&p->in_data.data, rpc_in_p, prs_offset(rpc_in_p), data_len)) { + DEBUG(0,("process_request_pdu: Unable to append data size %u to parse buffer of size %u.\n", + (unsigned int)data_len, (unsigned int)prs_data_size(&p->in_data.data) )); + set_incoming_fault(p); + return False; } if(p->hdr.flags & RPC_FLG_LAST) { diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 594c749c9c..8304b14a1c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -706,10 +706,9 @@ static void notify_system_time(struct spoolss_notify_msg *msg, return; data->notify_data.data.length = prs_offset(&ps); - data->notify_data.data.string = - talloc(mem_ctx, prs_offset(&ps)); + data->notify_data.data.string = talloc(mem_ctx, prs_offset(&ps)); - memcpy(data->notify_data.data.string, prs_data_p(&ps), prs_offset(&ps)); + prs_copy_all_data_out((char *)data->notify_data.data.string, &ps); prs_mem_free(&ps); } -- cgit From 4cd6e31bd364270580f2907fbc5669bf29d09578 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 14 Feb 2003 23:04:03 +0000 Subject: Ensure that only parse_prs.c access internal members of the prs_struct. Needed to move to disk based i/o later. Jeremy. (This used to be commit 4c3ee228fcdb089eaeead95e79532a9cf6cb0de6) --- source3/rpc_server/srv_pipe.c | 26 +++++++++++--------------- source3/rpc_server/srv_pipe_hnd.c | 15 +++++---------- source3/rpc_server/srv_spoolss_nt.c | 5 ++--- 3 files changed, 18 insertions(+), 28 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 4c4b3e7af3..50127005a1 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -84,8 +84,6 @@ BOOL create_next_pdu(pipes_struct *p) uint32 data_space_available; uint32 data_len_left; prs_struct outgoing_pdu; - char *data; - char *data_from; uint32 data_pos; /* @@ -187,26 +185,26 @@ BOOL create_next_pdu(pipes_struct *p) data_pos = prs_offset(&outgoing_pdu); /* Copy the data into the PDU. */ - data_from = prs_data_p(&p->out_data.rdata) + p->out_data.data_sent_length; - if(!prs_append_data(&outgoing_pdu, data_from, data_len)) { + if(!prs_append_some_prs_data(&outgoing_pdu, &p->out_data.rdata, p->out_data.data_sent_length, data_len)) { DEBUG(0,("create_next_pdu: failed to copy %u bytes of data.\n", (unsigned int)data_len)); prs_mem_free(&outgoing_pdu); return False; } - /* - * Set data to point to where we copied the data into. - */ - - data = prs_data_p(&outgoing_pdu) + data_pos; - if (p->hdr.auth_len > 0) { uint32 crc32 = 0; + char *data; DEBUG(5,("create_next_pdu: sign: %s seal: %s data %d auth %d\n", BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, p->hdr.auth_len)); + /* + * Set data to point to where we copied the data into. + */ + + data = prs_data_p(&outgoing_pdu) + data_pos; + if (auth_seal) { crc32 = crc32_calc_buffer(data, data_len); NTLMSSPcalc_p(p, (uchar*)data, data_len); @@ -1389,17 +1387,15 @@ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, /* Check for buffer underflow in rpc parsing */ if ((DEBUGLEVEL >= 10) && - (p->in_data.data.data_offset != p->in_data.data.buffer_size)) { - int data_len = p->in_data.data.buffer_size - - p->in_data.data.data_offset; + (prs_offset(&p->in_data.data) != prs_data_size(&p->in_data.data))) { + size_t data_len = prs_data_size(&p->in_data.data) - prs_offset(&p->in_data.data); char *data; data = malloc(data_len); DEBUG(10, ("api_rpcTNP: rpc input buffer underflow (parse error?)\n")); if (data) { - prs_uint8s(False, "", &p->in_data.data, 0, (unsigned char *)data, - data_len); + prs_uint8s(False, "", &p->in_data.data, 0, (unsigned char *)data, (uint32)data_len); SAFE_FREE(data); } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 6cdb6836eb..8cb81b9c6d 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -618,16 +618,11 @@ authentication failed. Denying the request.\n", p->name)); * Append the data portion into the buffer and return. */ - { - char *data_from = prs_data_p(rpc_in_p) + prs_offset(rpc_in_p); - - if(!prs_append_data(&p->in_data.data, data_from, data_len)) { - DEBUG(0,("process_request_pdu: Unable to append data size %u to parse buffer of size %u.\n", - (unsigned int)data_len, (unsigned int)prs_data_size(&p->in_data.data) )); - set_incoming_fault(p); - return False; - } - + if(!prs_append_some_prs_data(&p->in_data.data, rpc_in_p, prs_offset(rpc_in_p), data_len)) { + DEBUG(0,("process_request_pdu: Unable to append data size %u to parse buffer of size %u.\n", + (unsigned int)data_len, (unsigned int)prs_data_size(&p->in_data.data) )); + set_incoming_fault(p); + return False; } if(p->hdr.flags & RPC_FLG_LAST) { diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 594c749c9c..8304b14a1c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -706,10 +706,9 @@ static void notify_system_time(struct spoolss_notify_msg *msg, return; data->notify_data.data.length = prs_offset(&ps); - data->notify_data.data.string = - talloc(mem_ctx, prs_offset(&ps)); + data->notify_data.data.string = talloc(mem_ctx, prs_offset(&ps)); - memcpy(data->notify_data.data.string, prs_data_p(&ps), prs_offset(&ps)); + prs_copy_all_data_out((char *)data->notify_data.data.string, &ps); prs_mem_free(&ps); } -- cgit From 940fcdf09575788781e0b92b9080fff527363fd4 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 15 Feb 2003 23:33:30 +0000 Subject: * set PRINTER_ATTRIBUTE_RAW_ONLY; CR 1736 * never save a pointer to an automatic variable (they go away) implement a deep copy for SPOOLSS_NOTIFY_MSG to correct messages being sent that have junk for strings; fix in response to changes for CR 1504 (This used to be commit ffda9e2480414c7ed6156958f516e0d1f3c61350) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8304b14a1c..0bcc3c5a30 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5770,7 +5770,7 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) fstrcpy(info->sharename, lp_servicename(snum)); slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s", get_called_name(), info->sharename); - info->attributes = PRINTER_ATTRIBUTE_SHARED | PRINTER_ATTRIBUTE_NETWORK; + info->attributes = PRINTER_ATTRIBUTE_SAMBA; return True; } -- cgit From a703d55cd7558ef45de435d631bf5315fb616192 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 15 Feb 2003 23:36:18 +0000 Subject: * set PRINTER_ATTRIBUTE_RAW_ONLY; CR 1736 * never save a pointer to an automatic variable (they go away) implement a deep copy for SPOOLSS_NOTIFY_MSG to correct messages being sent that have junk for strings; fix in response to changes for CR 1504 (This used to be commit 043b9dff22e909fc290c34d879cad8b4c980fc13) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8304b14a1c..0bcc3c5a30 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5770,7 +5770,7 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) fstrcpy(info->sharename, lp_servicename(snum)); slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s", get_called_name(), info->sharename); - info->attributes = PRINTER_ATTRIBUTE_SHARED | PRINTER_ATTRIBUTE_NETWORK; + info->attributes = PRINTER_ATTRIBUTE_SAMBA; return True; } -- cgit From cc0202884b1023059769450a4a052431ab362e78 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 17 Feb 2003 12:27:34 +0000 Subject: This patch fixes one of my longest-standing pet hates with Samba :-). When we look see if a user is in a list, and we try to 'expand' an @group, we should lookup the user's own list of groups, rather than looking for all the members of a group. I'm sure this will fix some nasty performance issues, particularly on large domains etc. In particular, this avoids contacting winbind at all, if the group is not a winbind group. (This caused a deadlock on my winbind-on-PDC setup). The groups list always includes the user's primary group, as per the getgrouplist manpage, and my recent changes to our implementation. Andrew Bartlett (This used to be commit 9be21976f7662ebe6eb92fff7cecbdb352eca334) --- source3/rpc_server/srv_samr_nt.c | 20 ++++++++++---------- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2896fd79e4..d766e9c19e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3427,7 +3427,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD fstrcpy(grp_name, grp->gr_name); /* if the user is already in the group */ - if(user_in_group_list(pwd->pw_name, grp_name)) { + if(user_in_unix_group_list(pwd->pw_name, grp_name)) { passwd_free(&pwd); return NT_STATUS_MEMBER_IN_ALIAS; } @@ -3439,7 +3439,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD smb_add_user_group(grp_name, pwd->pw_name); /* check if the user has been added then ... */ - if(!user_in_group_list(pwd->pw_name, grp_name)) { + if(!user_in_unix_group_list(pwd->pw_name, grp_name)) { passwd_free(&pwd); return NT_STATUS_MEMBER_NOT_IN_ALIAS; /* don't know what to reply else */ } @@ -3485,7 +3485,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE if ((grp=getgrgid(map.gid)) == NULL) return NT_STATUS_NO_SUCH_ALIAS; - /* we need to copy the name otherwise it's overloaded in user_in_group_list */ + /* we need to copy the name otherwise it's overloaded in user_in_unix_group_list */ fstrcpy(grp_name, grp->gr_name); /* check if the user exists before trying to remove it from the group */ @@ -3497,7 +3497,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE } /* if the user is not in the group */ - if(!user_in_group_list(pdb_get_username(sam_pass), grp_name)) { + if(!user_in_unix_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_MEMBER_IN_ALIAS; } @@ -3505,7 +3505,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE smb_delete_user_group(grp_name, pdb_get_username(sam_pass)); /* check if the user has been removed then ... */ - if(user_in_group_list(pdb_get_username(sam_pass), grp_name)) { + if(user_in_unix_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_MEMBER_NOT_IN_ALIAS; /* don't know what to reply else */ } @@ -3583,11 +3583,11 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD return NT_STATUS_NO_SUCH_GROUP; } - /* we need to copy the name otherwise it's overloaded in user_in_group_list */ + /* we need to copy the name otherwise it's overloaded in user_in_unix_group_list */ fstrcpy(grp_name, grp->gr_name); /* if the user is already in the group */ - if(user_in_group_list(pwd->pw_name, grp_name)) { + if(user_in_unix_group_list(pwd->pw_name, grp_name)) { passwd_free(&pwd); return NT_STATUS_MEMBER_IN_GROUP; } @@ -3601,7 +3601,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD smb_add_user_group(grp_name, pwd->pw_name); /* check if the user has been added then ... */ - if(!user_in_group_list(pwd->pw_name, grp_name)) { + if(!user_in_unix_group_list(pwd->pw_name, grp_name)) { passwd_free(&pwd); return NT_STATUS_MEMBER_NOT_IN_GROUP; /* don't know what to reply else */ } @@ -3662,7 +3662,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE } /* if the user is not in the group */ - if (!user_in_group_list(pdb_get_username(sam_pass), grp_name)) { + if (!user_in_unix_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_MEMBER_NOT_IN_GROUP; } @@ -3670,7 +3670,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE smb_delete_user_group(grp_name, pdb_get_username(sam_pass)); /* check if the user has been removed then ... */ - if (user_in_group_list(pdb_get_username(sam_pass), grp_name)) { + if (user_in_unix_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_ACCESS_DENIED; /* don't know what to reply else */ } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0bcc3c5a30..3a7ced7725 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1606,7 +1606,7 @@ Can't find printer handle we created for printer %s\n", name )); /* if the user is not root and not a printer admin, then fail */ if ( user.uid != 0 - && !user_in_list(uidtoname(user.uid), lp_printer_admin(snum)) ) + && !user_in_list(uidtoname(user.uid), lp_printer_admin(snum), user.groups, user.ngroups) ) { close_printer_handle(p, handle); return WERR_ACCESS_DENIED; @@ -1653,7 +1653,7 @@ Can't find printer handle we created for printer %s\n", name )); /* check smb.conf parameters and the the sec_desc */ - if (!user_ok(uidtoname(user.uid), snum) || !print_access_check(&user, snum, printer_default->access_required)) { + if (!user_ok(uidtoname(user.uid), snum, user.groups, user.ngroups) || !print_access_check(&user, snum, printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); close_printer_handle(p, handle); return WERR_ACCESS_DENIED; -- cgit From ac30e445ba0291c67a5dec338f5c148298961e61 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 18 Feb 2003 03:42:34 +0000 Subject: set the various DsSpooler keys that are linked to PRINTER_INFO_2 fields; CR 985 (This used to be commit 9efaef4a96a14bd1ffabf12326ff6f6903f663b2) --- source3/rpc_server/srv_spoolss_nt.c | 67 +++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0bcc3c5a30..4306f5185c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4175,13 +4175,17 @@ static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum) if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) return False; - init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/ - init_unistr(&printer->portname, ntprinter->info_2->portname); /* portname */ + init_unistr(&printer->printername, ntprinter->info_2->printername); + init_unistr(&printer->portname, ntprinter->info_2->portname); printer->attributes = ntprinter->info_2->attributes; - printer->device_not_selected_timeout = 0x3a98; - printer->transmission_retry_timeout = 0xafc8; + + /* these two are not used by NT+ according to MSDN */ + + printer->device_not_selected_timeout = 0x0; /* have seen 0x3a98 */ + printer->transmission_retry_timeout = 0x0; /* have seen 0xafc8 */ free_a_printer(&ntprinter, 2); + return True; } @@ -5772,6 +5776,7 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) get_called_name(), info->sharename); info->attributes = PRINTER_ATTRIBUTE_SAMBA; + return True; } @@ -5841,6 +5846,8 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, NT_PRINTER_INFO_LEVEL *printer = NULL, *old_printer = NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); WERROR result; + UNISTR2 buffer; + fstring asc_buffer; DEBUG(8,("update_printer\n")); @@ -5953,20 +5960,60 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, /* Update printer info */ result = mod_a_printer(*printer, 2); - /* flag which changes actually occured. This is a small subset of - all the possible changes */ + /* + * flag which changes actually occured. This is a small subset of + * all the possible changes. We also have to update things in the + * DsSpooler key. + */ + + if (!strequal(printer->info_2->comment, old_printer->info_2->comment)) { + init_unistr2( &buffer, printer->info_2->comment, strlen(printer->info_2->comment)+1 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "description", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); - if (!strequal(printer->info_2->comment, old_printer->info_2->comment)) notify_printer_comment(snum, printer->info_2->comment); + } + + if (!strequal(printer->info_2->sharename, old_printer->info_2->sharename)) { + init_unistr2( &buffer, printer->info_2->sharename, strlen(printer->info_2->sharename)+1 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "printerName", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "shareName", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); - if (!strequal(printer->info_2->sharename, old_printer->info_2->sharename)) notify_printer_sharename(snum, printer->info_2->sharename); + } + + if (!strequal(printer->info_2->portname, old_printer->info_2->portname)) { + init_unistr2( &buffer, printer->info_2->portname, strlen(printer->info_2->portname)+1 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "portName", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); - if (!strequal(printer->info_2->portname, old_printer->info_2->portname)) notify_printer_port(snum, printer->info_2->portname); + } + + if (!strequal(printer->info_2->location, old_printer->info_2->location)) { + init_unistr2( &buffer, printer->info_2->location, strlen(printer->info_2->location)+1 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "location", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); - if (!strequal(printer->info_2->location, old_printer->info_2->location)) notify_printer_location(snum, printer->info_2->location); + } + + /* here we need to update some more DsSpooler keys */ + /* uNCName, serverName, shortServerName */ + + init_unistr2( &buffer, global_myname(), strlen(global_myname())+1 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "serverName", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "shortServerName", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); + + slprintf( asc_buffer, sizeof(asc_buffer)-1, "\\\\%s\\%s", + global_myname(), printer->info_2->sharename ); + init_unistr2( &buffer, asc_buffer, strlen(asc_buffer)+1 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "uNCName", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); done: free_a_printer(&printer, 2); -- cgit From 336ae66c5a7bbb9387e2b4fa74afa7c61fe5206a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 18 Feb 2003 03:43:08 +0000 Subject: set the various DsSpooler keys that are linked to PRINTER_INFO_2 fields; CR 985 (This used to be commit 9a4b7a86fdaab04328b5017c1dd42480753a9a10) --- source3/rpc_server/srv_spoolss_nt.c | 67 +++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3a7ced7725..d94bebf4c1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4175,13 +4175,17 @@ static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum) if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) return False; - init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/ - init_unistr(&printer->portname, ntprinter->info_2->portname); /* portname */ + init_unistr(&printer->printername, ntprinter->info_2->printername); + init_unistr(&printer->portname, ntprinter->info_2->portname); printer->attributes = ntprinter->info_2->attributes; - printer->device_not_selected_timeout = 0x3a98; - printer->transmission_retry_timeout = 0xafc8; + + /* these two are not used by NT+ according to MSDN */ + + printer->device_not_selected_timeout = 0x0; /* have seen 0x3a98 */ + printer->transmission_retry_timeout = 0x0; /* have seen 0xafc8 */ free_a_printer(&ntprinter, 2); + return True; } @@ -5772,6 +5776,7 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) get_called_name(), info->sharename); info->attributes = PRINTER_ATTRIBUTE_SAMBA; + return True; } @@ -5841,6 +5846,8 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, NT_PRINTER_INFO_LEVEL *printer = NULL, *old_printer = NULL; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); WERROR result; + UNISTR2 buffer; + fstring asc_buffer; DEBUG(8,("update_printer\n")); @@ -5953,20 +5960,60 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, /* Update printer info */ result = mod_a_printer(*printer, 2); - /* flag which changes actually occured. This is a small subset of - all the possible changes */ + /* + * flag which changes actually occured. This is a small subset of + * all the possible changes. We also have to update things in the + * DsSpooler key. + */ + + if (!strequal(printer->info_2->comment, old_printer->info_2->comment)) { + init_unistr2( &buffer, printer->info_2->comment, strlen(printer->info_2->comment)+1 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "description", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); - if (!strequal(printer->info_2->comment, old_printer->info_2->comment)) notify_printer_comment(snum, printer->info_2->comment); + } + + if (!strequal(printer->info_2->sharename, old_printer->info_2->sharename)) { + init_unistr2( &buffer, printer->info_2->sharename, strlen(printer->info_2->sharename)+1 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "printerName", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "shareName", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); - if (!strequal(printer->info_2->sharename, old_printer->info_2->sharename)) notify_printer_sharename(snum, printer->info_2->sharename); + } + + if (!strequal(printer->info_2->portname, old_printer->info_2->portname)) { + init_unistr2( &buffer, printer->info_2->portname, strlen(printer->info_2->portname)+1 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "portName", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); - if (!strequal(printer->info_2->portname, old_printer->info_2->portname)) notify_printer_port(snum, printer->info_2->portname); + } + + if (!strequal(printer->info_2->location, old_printer->info_2->location)) { + init_unistr2( &buffer, printer->info_2->location, strlen(printer->info_2->location)+1 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "location", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); - if (!strequal(printer->info_2->location, old_printer->info_2->location)) notify_printer_location(snum, printer->info_2->location); + } + + /* here we need to update some more DsSpooler keys */ + /* uNCName, serverName, shortServerName */ + + init_unistr2( &buffer, global_myname(), strlen(global_myname())+1 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "serverName", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "shortServerName", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); + + slprintf( asc_buffer, sizeof(asc_buffer)-1, "\\\\%s\\%s", + global_myname(), printer->info_2->sharename ); + init_unistr2( &buffer, asc_buffer, strlen(asc_buffer)+1 ); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "uNCName", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); done: free_a_printer(&printer, 2); -- cgit From c536b88b2b71c264a1e31ada51e463fee5cb949b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 18 Feb 2003 18:34:48 +0000 Subject: Use the new modules stuff to load dynrpc modules. Basically this means: - calling the initialization function in the module init_module() instead of rpc_pipe_init() - calling smb_load_module() to do the dlopen(), dlsym() and init_module() calls I'll merge this to 3.0, together with the smb_load_module() function. Discussed with Anthony. (This used to be commit 3757ed8df06ca2b306bef336bdb9c7671f5e6a65) --- source3/rpc_server/srv_dfs.c | 2 +- source3/rpc_server/srv_lsa.c | 2 +- source3/rpc_server/srv_netlog.c | 2 +- source3/rpc_server/srv_pipe.c | 31 ++++++------------------------- source3/rpc_server/srv_reg.c | 2 +- source3/rpc_server/srv_samr.c | 2 +- source3/rpc_server/srv_spoolss.c | 2 +- source3/rpc_server/srv_srvsvc.c | 2 +- source3/rpc_server/srv_wkssvc.c | 2 +- 9 files changed, 14 insertions(+), 33 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index f6e9ca3d56..14c1cb4088 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -159,7 +159,7 @@ static BOOL api_dfs_enum(pipes_struct *p) ********************************************************************/ #ifdef RPC_DFS_DYNAMIC -int rpc_pipe_init(void) +int init_module(void) #else int rpc_dfs_init(void) #endif diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index fad8f5641a..0e4039326b 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -772,7 +772,7 @@ static BOOL api_lsa_remove_acct_rights(pipes_struct *p) ***************************************************************************/ #ifdef RPC_LSA_DYNAMIC -int rpc_pipe_init(void) +int init_module(void) #else int rpc_lsa_init(void) #endif diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index f377d3952b..c9e4fc1b1f 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -322,7 +322,7 @@ static BOOL api_net_logon_ctrl(pipes_struct *p) ********************************************************************/ #ifdef RPC_NETLOG_DYNAMIC -int rpc_pipe_init(void) +int init_module(void) #else int rpc_net_init(void) #endif diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 50127005a1..0b8b7b229a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -794,42 +794,23 @@ int rpc_pipe_register_commands(const char *clnt, const char *srv, const struct a /******************************************************************* Register commands to an RPC pipe *******************************************************************/ -int rpc_load_module(const char *module) +NTSTATUS rpc_load_module(const char *module) { -#ifdef HAVE_DLOPEN - void *handle; - int (*module_init)(void); pstring full_path; - char *error; + NTSTATUS status; pstrcpy(full_path, lib_path("rpc")); pstrcat(full_path, "/librpc_"); pstrcat(full_path, module); pstrcat(full_path, "."); pstrcat(full_path, shlib_ext()); - - handle = sys_dlopen(full_path, RTLD_LAZY); - if (!handle) { + + if (!NT_STATUS_IS_OK(status = smb_load_module(full_path))) { DEBUG(0, ("Could not load requested pipe %s as %s\n", module, full_path)); - DEBUG(0, (" Error: %s\n", dlerror())); - return 0; } - DEBUG(3, ("Module '%s' loaded\n", full_path)); - - module_init = sys_dlsym(handle, "rpc_pipe_init"); - if ((error = sys_dlerror()) != NULL) { - DEBUG(0, ("Error trying to resolve symbol 'rpc_pipe_init' in %s: %s\n", - full_path, error)); - return 0; - } - - return module_init(); -#else - DEBUG(0,("Attempting to load a dynamic RPC pipe when dlopen isn't available\n")); - return 0; -#endif + return status; } /******************************************************************* @@ -877,7 +858,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) } } - if (!api_fd_commands[i].name && !rpc_load_module(p->name)) { + if (!api_fd_commands[i].name && !NT_STATUS_IS_OK(rpc_load_module(p->name))) { DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", p->name )); if(!setup_bind_nak(p)) diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 04960f8e3a..8fc1d42b2f 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -374,7 +374,7 @@ static BOOL api_reg_save_key(pipes_struct *p) ********************************************************************/ #ifdef RPC_REG_DYNAMIC -int rpc_pipe_init(void) +int init_module(void) #else int rpc_reg_init(void) #endif diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 3a31ec82e1..b75195ceef 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1444,7 +1444,7 @@ static BOOL api_samr_set_dom_info(pipes_struct *p) ********************************************************************/ #ifdef RPC_SAMR_DYNAMIC -int rpc_pipe_init(void) +int init_module(void) #else int rpc_samr_init(void) #endif diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 5832ae876b..3023922a5b 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1581,7 +1581,7 @@ static BOOL api_spoolss_replycloseprinter(pipes_struct *p) ********************************************************************/ #ifdef RPC_SPOOLSS_DYNAMIC -int rpc_pipe_init(void) +int init_module(void) #else int rpc_spoolss_init(void) #endif diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 983c660965..7c5e317c87 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -527,7 +527,7 @@ static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) ********************************************************************/ #ifdef RPC_SVC_DYNAMIC -int rpc_pipe_init(void) +int init_module(void) #else int rpc_srv_init(void) #endif diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 1fed2cc6db..e0d662ea80 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -61,7 +61,7 @@ static BOOL api_wks_query_info(pipes_struct *p) ********************************************************************/ #ifdef RPC_WKS_DYNAMIC -int rpc_pipe_init(void) +int init_module(void) #else int rpc_wks_init(void) #endif -- cgit From 8d8a8c9633ea04d269d70b1fa8f4393cc73f7bbd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Feb 2003 22:26:28 +0000 Subject: Make init_module() and thus smb_load_module() return an int. modules/developer.c: init_module() should return an int (This used to be commit 7f59703550378ff2333e3c851bf1a77037510abd) --- source3/rpc_server/srv_pipe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 0b8b7b229a..f6deac68f8 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -794,10 +794,10 @@ int rpc_pipe_register_commands(const char *clnt, const char *srv, const struct a /******************************************************************* Register commands to an RPC pipe *******************************************************************/ -NTSTATUS rpc_load_module(const char *module) +int rpc_load_module(const char *module) { pstring full_path; - NTSTATUS status; + int status; pstrcpy(full_path, lib_path("rpc")); pstrcat(full_path, "/librpc_"); @@ -805,7 +805,7 @@ NTSTATUS rpc_load_module(const char *module) pstrcat(full_path, "."); pstrcat(full_path, shlib_ext()); - if (!NT_STATUS_IS_OK(status = smb_load_module(full_path))) { + if (!(status = smb_load_module(full_path))) { DEBUG(0, ("Could not load requested pipe %s as %s\n", module, full_path)); } @@ -858,7 +858,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) } } - if (!api_fd_commands[i].name && !NT_STATUS_IS_OK(rpc_load_module(p->name))) { + if (!api_fd_commands[i].name && !rpc_load_module(p->name)) { DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", p->name )); if(!setup_bind_nak(p)) -- cgit From 9383d61f6c61ba8600ec73d22bd6f048c55a5261 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 21 Feb 2003 04:47:24 +0000 Subject: Fixed compiler warning. (This used to be commit b3f9cf8c1c293e905a536dfa5bb6a827627b7024) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index b230381d62..1b42c5f141 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1280,7 +1280,7 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA r_u->status = privilege_enum_account_rights(&q_u->sid.sid, &num_rights, &rights); - init_r_enum_acct_rights(r_u, num_rights, rights); + init_r_enum_acct_rights(r_u, num_rights, (const char **)rights); for (i=0;i Date: Fri, 21 Feb 2003 17:04:01 +0000 Subject: couple of merges from APP_HEAD * performance optimization in enumprinterdataex() when keyname is empty * fix a few typos in comments * reload services after addprinter_command() dump registry data in ascii when the key is REG_SZ or REG_MULTI_SZ (This used to be commit 3fc90ea1d9b11186f26484516a4dd8502b6d7323) --- source3/rpc_server/srv_spoolss_nt.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4306f5185c..64dfef2f9e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -615,7 +615,7 @@ static BOOL is_monitoring_event(Printer_entry *p, uint16 notify_type, /* * Flags should always be zero when the change notify - * is registered by the cliebnt's spooler. A user Win32 app + * is registered by the client's spooler. A user Win32 app * might use the flags though instead of the NOTIFY_OPTION_INFO * --jerry */ @@ -5936,6 +5936,13 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, result = WERR_ACCESS_DENIED; goto done; } + + /* + * make sure we actually reload the services after + * this as smb.conf could have a new section in it + * .... shouldn't .... but could + */ + reload_services(False); } /* @@ -8871,11 +8878,24 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ DEBUG(4,("_spoolss_enumprinterdataex\n")); if (!Printer) { - DEBUG(2,("_spoolss_enumprinterdata: Invalid handle (%s:%u:%u1<).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_enumprinterdataex: Invalid handle (%s:%u:%u1<).\n", OUR_HANDLE(handle))); return WERR_BADFID; } - /* first get the printer off of disk */ + /* + * first check for a keyname of NULL or "". Win2k seems to send + * this a lot and we should send back WERR_INVALID_PARAM + * no need to spend time looking up the printer in this case. + * --jerry + */ + + unistr2_to_dos(key, &q_u->key, sizeof(key) - 1); + if ( !strlen(key) ) { + result = WERR_INVALID_PARAM; + goto done; + } + + /* get the printer off of disk */ if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; @@ -8971,7 +8991,8 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ done: - free_a_printer(&printer, 2); + if ( printer ) + free_a_printer(&printer, 2); return result; } -- cgit From ab985b983f45a284b2ee9fdd08801989574edf4b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 21 Feb 2003 17:08:43 +0000 Subject: couple of merges from APP_HEAD * performance optimization in enumprinterdataex() when keyname is empty * fix a few typos in comments * reload services after addprinter_command() dump registry data in ascii when the key is REG_SZ or REG_MULTI_SZ (This used to be commit fde6ef7cc62c58d512dc8053b214f0a3c59a78ab) --- source3/rpc_server/srv_spoolss_nt.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d94bebf4c1..4c87d0f73d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -615,7 +615,7 @@ static BOOL is_monitoring_event(Printer_entry *p, uint16 notify_type, /* * Flags should always be zero when the change notify - * is registered by the cliebnt's spooler. A user Win32 app + * is registered by the client's spooler. A user Win32 app * might use the flags though instead of the NOTIFY_OPTION_INFO * --jerry */ @@ -5936,6 +5936,13 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, result = WERR_ACCESS_DENIED; goto done; } + + /* + * make sure we actually reload the services after + * this as smb.conf could have a new section in it + * .... shouldn't .... but could + */ + reload_services(False); } /* @@ -8871,11 +8878,24 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ DEBUG(4,("_spoolss_enumprinterdataex\n")); if (!Printer) { - DEBUG(2,("_spoolss_enumprinterdata: Invalid handle (%s:%u:%u1<).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_enumprinterdataex: Invalid handle (%s:%u:%u1<).\n", OUR_HANDLE(handle))); return WERR_BADFID; } - /* first get the printer off of disk */ + /* + * first check for a keyname of NULL or "". Win2k seems to send + * this a lot and we should send back WERR_INVALID_PARAM + * no need to spend time looking up the printer in this case. + * --jerry + */ + + unistr2_to_dos(key, &q_u->key, sizeof(key) - 1); + if ( !strlen(key) ) { + result = WERR_INVALID_PARAM; + goto done; + } + + /* get the printer off of disk */ if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; @@ -8971,6 +8991,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ done: + if ( printer ) free_a_printer(&printer, 2); return result; -- cgit From 01490bc0d254380f9bf3ab1f8dc3d98b8c0e723e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 21 Feb 2003 19:02:07 +0000 Subject: s/unistr2_to_dos/unistr2_to_ascii/ to fix compile (This used to be commit de6a2d154e0e863a7628f18cca8fdcaa49d9c0ff) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 64dfef2f9e..3605c1a24d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8889,7 +8889,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ * --jerry */ - unistr2_to_dos(key, &q_u->key, sizeof(key) - 1); + unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); if ( !strlen(key) ) { result = WERR_INVALID_PARAM; goto done; -- cgit From 3d730f89cf3c30d8b17f0d35d2cdf28db53296e2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 21 Feb 2003 20:00:46 +0000 Subject: i patched the wrong branch! s/unistr2_to_dos/unistr2_to_ascii/ (This used to be commit 513fb2ddd85a74de7684a6cb09d57011af69161f) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4c87d0f73d..93566c2bb7 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8889,7 +8889,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ * --jerry */ - unistr2_to_dos(key, &q_u->key, sizeof(key) - 1); + unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); if ( !strlen(key) ) { result = WERR_INVALID_PARAM; goto done; -- cgit From e72ecdc862804339912325fe848401e8ec57cde7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 24 Feb 2003 02:35:54 +0000 Subject: Merge of server-side authentication changes to 3.0: - user_ok() and user_in_group() now take a list of groups, instead of looking for the user in the members of all groups. - The 'server_info' returned from the authentication is now kept around - in future we won't copy the sesion key, username etc, we will just referece them directly. - rhosts upgraded to use the SAM if possible, otherwise fake up based on getpwnam(). - auth_util code to deal with groups upgraded to deal with non-winbind domain members again. Andrew Bartlett (This used to be commit 74b5436c75114170ce7c780c19226103d0df9060) --- source3/rpc_server/srv_netlog_nt.c | 2 +- source3/rpc_server/srv_samr_nt.c | 20 ++++++++++---------- source3/rpc_server/srv_spoolss_nt.c | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 8070cdd984..6182da53d9 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -668,7 +668,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * fstring group_sid_string; uchar user_sess_key[16]; uchar netlogon_sess_key[16]; - + sampw = server_info->sam_account; /* set up pointer indicating user/password failed to be found */ diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2896fd79e4..d766e9c19e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3427,7 +3427,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD fstrcpy(grp_name, grp->gr_name); /* if the user is already in the group */ - if(user_in_group_list(pwd->pw_name, grp_name)) { + if(user_in_unix_group_list(pwd->pw_name, grp_name)) { passwd_free(&pwd); return NT_STATUS_MEMBER_IN_ALIAS; } @@ -3439,7 +3439,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD smb_add_user_group(grp_name, pwd->pw_name); /* check if the user has been added then ... */ - if(!user_in_group_list(pwd->pw_name, grp_name)) { + if(!user_in_unix_group_list(pwd->pw_name, grp_name)) { passwd_free(&pwd); return NT_STATUS_MEMBER_NOT_IN_ALIAS; /* don't know what to reply else */ } @@ -3485,7 +3485,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE if ((grp=getgrgid(map.gid)) == NULL) return NT_STATUS_NO_SUCH_ALIAS; - /* we need to copy the name otherwise it's overloaded in user_in_group_list */ + /* we need to copy the name otherwise it's overloaded in user_in_unix_group_list */ fstrcpy(grp_name, grp->gr_name); /* check if the user exists before trying to remove it from the group */ @@ -3497,7 +3497,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE } /* if the user is not in the group */ - if(!user_in_group_list(pdb_get_username(sam_pass), grp_name)) { + if(!user_in_unix_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_MEMBER_IN_ALIAS; } @@ -3505,7 +3505,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE smb_delete_user_group(grp_name, pdb_get_username(sam_pass)); /* check if the user has been removed then ... */ - if(user_in_group_list(pdb_get_username(sam_pass), grp_name)) { + if(user_in_unix_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_MEMBER_NOT_IN_ALIAS; /* don't know what to reply else */ } @@ -3583,11 +3583,11 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD return NT_STATUS_NO_SUCH_GROUP; } - /* we need to copy the name otherwise it's overloaded in user_in_group_list */ + /* we need to copy the name otherwise it's overloaded in user_in_unix_group_list */ fstrcpy(grp_name, grp->gr_name); /* if the user is already in the group */ - if(user_in_group_list(pwd->pw_name, grp_name)) { + if(user_in_unix_group_list(pwd->pw_name, grp_name)) { passwd_free(&pwd); return NT_STATUS_MEMBER_IN_GROUP; } @@ -3601,7 +3601,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD smb_add_user_group(grp_name, pwd->pw_name); /* check if the user has been added then ... */ - if(!user_in_group_list(pwd->pw_name, grp_name)) { + if(!user_in_unix_group_list(pwd->pw_name, grp_name)) { passwd_free(&pwd); return NT_STATUS_MEMBER_NOT_IN_GROUP; /* don't know what to reply else */ } @@ -3662,7 +3662,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE } /* if the user is not in the group */ - if (!user_in_group_list(pdb_get_username(sam_pass), grp_name)) { + if (!user_in_unix_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_MEMBER_NOT_IN_GROUP; } @@ -3670,7 +3670,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE smb_delete_user_group(grp_name, pdb_get_username(sam_pass)); /* check if the user has been removed then ... */ - if (user_in_group_list(pdb_get_username(sam_pass), grp_name)) { + if (user_in_unix_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_ACCESS_DENIED; /* don't know what to reply else */ } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3605c1a24d..93566c2bb7 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1606,7 +1606,7 @@ Can't find printer handle we created for printer %s\n", name )); /* if the user is not root and not a printer admin, then fail */ if ( user.uid != 0 - && !user_in_list(uidtoname(user.uid), lp_printer_admin(snum)) ) + && !user_in_list(uidtoname(user.uid), lp_printer_admin(snum), user.groups, user.ngroups) ) { close_printer_handle(p, handle); return WERR_ACCESS_DENIED; @@ -1653,7 +1653,7 @@ Can't find printer handle we created for printer %s\n", name )); /* check smb.conf parameters and the the sec_desc */ - if (!user_ok(uidtoname(user.uid), snum) || !print_access_check(&user, snum, printer_default->access_required)) { + if (!user_ok(uidtoname(user.uid), snum, user.groups, user.ngroups) || !print_access_check(&user, snum, printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); close_printer_handle(p, handle); return WERR_ACCESS_DENIED; @@ -8992,7 +8992,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ done: if ( printer ) - free_a_printer(&printer, 2); + free_a_printer(&printer, 2); return result; } -- cgit From 7c7d796b6d292a7c98b099ad1e1adbc4f2363512 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 25 Feb 2003 20:51:23 +0000 Subject: Progress on CR 601 cache the printer_info_2 with the open printer handle. cache is invalidated on a mod_a_printer() call **on that smbd**. Yes, this means that the window for admins to step on each other from different clients just got larger, but since handles a generally short lived this is probably ok. (This used to be commit 33c7b7522504fb15989f32add8e9a087c8d9d0fa) --- source3/rpc_server/srv_spoolss_nt.c | 277 ++++++++++++++++-------------------- 1 file changed, 122 insertions(+), 155 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 93566c2bb7..fa9b8eaeff 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000, * Copyright (C) Jeremy Allison 2001-2002, - * Copyright (C) Gerald Carter 2000-2002, + * Copyright (C) Gerald Carter 2000-2003, * Copyright (C) Tim Potter 2001-2002. * * This program is free software; you can redistribute it and/or modify @@ -37,8 +37,7 @@ #define MAGIC_DISPLAY_FREQUENCY 0xfade2bad #define PHANTOM_DEVMODE_KEY "_p_f_a_n_t_0_m_" -#define PRINTER_HANDLE_IS_PRINTER 0 -#define PRINTER_HANDLE_IS_PRINTSERVER 1 + /* Table to map the driver version */ /* to OS */ @@ -55,46 +54,6 @@ struct table_node { int version; }; - -/* structure to store the printer handles */ -/* and a reference to what it's pointing to */ -/* and the notify info asked about */ -/* that's the central struct */ -typedef struct _Printer{ - struct _Printer *prev, *next; - BOOL document_started; - BOOL page_started; - uint32 jobid; /* jobid in printing backend */ - BOOL printer_type; - union { - fstring handlename; - fstring printerservername; - } dev; - uint32 type; - uint32 access_granted; - struct { - uint32 flags; - uint32 options; - fstring localmachine; - uint32 printerlocal; - SPOOL_NOTIFY_OPTION *option; - POLICY_HND client_hnd; - BOOL client_connected; - uint32 change; - /* are we in a FindNextPrinterChangeNotify() call? */ - BOOL fnpcn; - } notify; - struct { - fstring machine; - fstring user; - } client; - - /* devmode sent in the OpenPrinter() call */ - NT_DEVICEMODE *nt_devmode; - - -} Printer_entry; - static Printer_entry *printers_list; typedef struct _counter_printer_0 { @@ -251,6 +210,9 @@ static void free_printer_entry(void *ptr) Printer->notify.client_connected=False; free_nt_devicemode( &Printer->nt_devmode ); + free_a_printer( &Printer->printer_info, 2 ); + + talloc_destroy( Printer->ctx ); /* Remove from the internal list. */ DLIST_REMOVE(printers_list, Printer); @@ -303,6 +265,29 @@ static Printer_entry *find_printer_index_by_hnd(pipes_struct *p, POLICY_HND *hnd return find_printer; } +/**************************************************************************** + find printer index by handle +****************************************************************************/ + +void invalidate_printer_hnd_cache( char *printername ) +{ + Printer_entry *p; + + DEBUG(10,("invalidate_printer_hnd_cache: printer [%s]\n", printername)); + + for ( p=printers_list; p; p=p->next ) + { + if ( p->printer_type==PRINTER_HANDLE_IS_PRINTER + && StrCaseCmp(p->dev.handlename, printername)==0) + { + DEBUG(10,("invalidating printer_info cache for handl:\n")); + free_a_printer( &p->printer_info, 2 ); + p->printer_info = NULL; + } + } + + return; +} /**************************************************************************** Close printer index by handle. ****************************************************************************/ @@ -534,6 +519,11 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3 ZERO_STRUCTP(new_printer); + if ( !(new_printer->ctx = talloc_init("Printer Entry [0x%x]", (uint32)hnd)) ) { + DEBUG(0,("open_printer_hnd: talloc_init() failed!\n")); + return False; + } + new_printer->notify.option=NULL; /* Add to the internal list. */ @@ -861,8 +851,7 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS /* add a new group? */ - if ( i == ctr->num_groups ) - { + if ( i == ctr->num_groups ) { ctr->num_groups++; if ( !(groups = talloc_realloc( ctr->ctx, ctr->msg_groups, sizeof(SPOOLSS_NOTIFY_MSG_GROUP)*ctr->num_groups)) ) { @@ -929,8 +918,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) /* loop over all printers */ - for (p = printers_list; p; p = p->next) - { + for (p = printers_list; p; p = p->next) { SPOOL_NOTIFY_INFO_DATA *data; uint32 data_len = 0; uint32 id; @@ -961,8 +949,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) /* build the array of change notifications */ - for ( i=0; inum_msgs; i++ ) - { + for ( i=0; inum_msgs; i++ ) { SPOOLSS_NOTIFY_MSG *msg = &messages[i]; /* Are we monitoring this event? */ @@ -995,8 +982,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) /* Convert unix jobid to smb jobid */ - if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) - { + if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) { id = sysjob_to_jobid(msg->id); if (id == -1) { @@ -1204,7 +1190,7 @@ void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) WERROR result; NT_PRINTER_INFO_LEVEL *printer = NULL; - result = get_a_printer(&printer, 2, lp_servicename(snum)); + result = get_a_printer(NULL, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(result)) continue; @@ -1300,7 +1286,7 @@ void reset_all_printerdata(int msg_type, pid_t src, void *buf, size_t len) WERROR result; NT_PRINTER_INFO_LEVEL *printer = NULL; - result = get_a_printer( &printer, 2, lp_servicename(snum) ); + result = get_a_printer( NULL, &printer, 2, lp_const_servicename(snum) ); if ( !W_ERROR_IS_OK(result) ) continue; @@ -2157,9 +2143,7 @@ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printe static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value ) { - delete_printer_data( printer->info_2, key, value ); - - return mod_a_printer(*printer, 2); + return delete_printer_data( printer->info_2, key, value ); } /**************************************************************************** @@ -2171,9 +2155,7 @@ static WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *ke { delete_printer_data( printer->info_2, key, value ); - add_printer_data( printer->info_2, key, value, type, data, real_len ); - - return mod_a_printer(*printer, 2); + return add_printer_data( printer->info_2, key, value, type, data, real_len ); } /******************************************************************** @@ -2349,7 +2331,7 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO goto done; } - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_servicename(snum)); if ( !W_ERROR_IS_OK(status) ) goto done; @@ -3443,7 +3425,7 @@ void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 * ********************************************************************/ -static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int +static BOOL construct_notify_printer_info(Printer_entry *print_hnd, SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id, TALLOC_CTX *mem_ctx) @@ -3462,11 +3444,10 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int (option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"), option_type->count, lp_servicename(snum))); - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &printer, 2, lp_const_servicename(snum)))) return False; - for(field_num=0; field_numcount; field_num++) - { + for(field_num=0; field_numcount; field_num++) { field = option_type->fields[field_num]; DEBUG(4,("construct_notify_printer_info: notify [%d]: type [%x], field [%x]\n", field_num, type, field)); @@ -3474,12 +3455,10 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int if (!search_notify(type, field, &j) ) continue; - if((tid=(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(2,("construct_notify_printer_info: failed to enlarge buffer info->data!\n")); return False; - } - else + } else info->data = tid; current_data = &info->data[info->count]; @@ -3611,7 +3590,7 @@ static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, for (snum=0; snumtype ) { case PRINTER_NOTIFY_TYPE: - if(construct_notify_printer_info(info, snum, + if(construct_notify_printer_info(Printer, info, snum, option_type, id, mem_ctx)) id--; @@ -3682,8 +3661,7 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY count = print_queue_status(snum, &queue, &status); - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, - lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)))) goto done; for (j=0; jflags=flags; @@ -3997,7 +3975,7 @@ DEVICEMODE *construct_dev_mode(int snum) DEBUGADD(8,("getting printer characteristics\n")); - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum)))) return NULL; if ( !printer->info_2->devmode ) { @@ -4030,14 +4008,14 @@ done: * fill a printer_info_2 struct ********************************************************************/ -static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum) +static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *printer, int snum) { int count; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; print_status_struct status; - if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; count = print_queue_length(snum, &status); @@ -4093,12 +4071,12 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum) * fill a printer_info_3 struct ********************************************************************/ -static BOOL construct_printer_info_3(PRINTER_INFO_3 **pp_printer, int snum) +static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 **pp_printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; PRINTER_INFO_3 *printer = NULL; - if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; *pp_printer = NULL; @@ -4148,11 +4126,11 @@ static BOOL construct_printer_info_3(PRINTER_INFO_3 **pp_printer, int snum) * fill a printer_info_4 struct ********************************************************************/ -static BOOL construct_printer_info_4(PRINTER_INFO_4 *printer, int snum) +static BOOL construct_printer_info_4(Printer_entry *print_hnd, PRINTER_INFO_4 *printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; - if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/ @@ -4168,11 +4146,11 @@ static BOOL construct_printer_info_4(PRINTER_INFO_4 *printer, int snum) * fill a printer_info_5 struct ********************************************************************/ -static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum) +static BOOL construct_printer_info_5(Printer_entry *print_hnd, PRINTER_INFO_5 *printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; - if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; init_unistr(&printer->printername, ntprinter->info_2->printername); @@ -4194,12 +4172,12 @@ static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum) * fill a printer_info_7 struct ********************************************************************/ -static BOOL construct_printer_info_7(PRINTER_INFO_7 *printer, int snum) +static BOOL construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *printer, int snum) { char *guid_str = NULL; GUID guid; - if (is_printer_published(snum, &guid)) { + if (is_printer_published(print_hnd, snum, &guid)) { asprintf(&guid_str, "{%s}", uuid_string_static(guid)); strupper(guid_str); init_unistr(&printer->guid, guid_str); @@ -4230,7 +4208,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); - if (construct_printer_info_1(flags, ¤t_prt, snum)) { + if (construct_printer_info_1(NULL, flags, ¤t_prt, snum)) { if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) { DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n")); SAFE_FREE(printers); @@ -4399,7 +4377,7 @@ static WERROR enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint3 if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); - if (construct_printer_info_2(¤t_prt, snum)) { + if (construct_printer_info_2(NULL, ¤t_prt, snum)) { if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2))) == NULL) { DEBUG(2,("enum_all_printers_info_2: failed to enlarge printers buffer!\n")); SAFE_FREE(printers); @@ -4570,14 +4548,14 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_0(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_0 *printer=NULL; if((printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0))) == NULL) return WERR_NOMEM; - construct_printer_info_0(printer, snum); + construct_printer_info_0(print_hnd, printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_0(printer); @@ -4603,14 +4581,14 @@ static WERROR getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_1(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_1 *printer=NULL; if((printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1))) == NULL) return WERR_NOMEM; - construct_printer_info_1(PRINTER_ENUM_ICON8, printer, snum); + construct_printer_info_1(print_hnd, PRINTER_ENUM_ICON8, printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_1(printer); @@ -4636,14 +4614,14 @@ static WERROR getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_2(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_2 *printer=NULL; if((printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)))==NULL) return WERR_NOMEM; - construct_printer_info_2(printer, snum); + construct_printer_info_2(print_hnd, printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_2(printer); @@ -4672,11 +4650,11 @@ static WERROR getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_3(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_3 *printer=NULL; - if (!construct_printer_info_3(&printer, snum)) + if (!construct_printer_info_3(print_hnd, &printer, snum)) return WERR_NOMEM; /* check the required size. */ @@ -4703,14 +4681,14 @@ static WERROR getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_4(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_4(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_4 *printer=NULL; if((printer=(PRINTER_INFO_4*)malloc(sizeof(PRINTER_INFO_4)))==NULL) return WERR_NOMEM; - if (!construct_printer_info_4(printer, snum)) + if (!construct_printer_info_4(print_hnd, printer, snum)) return WERR_NOMEM; /* check the required size. */ @@ -4737,14 +4715,14 @@ static WERROR getprinter_level_4(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_5(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_5(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_5 *printer=NULL; if((printer=(PRINTER_INFO_5*)malloc(sizeof(PRINTER_INFO_5)))==NULL) return WERR_NOMEM; - if (!construct_printer_info_5(printer, snum)) + if (!construct_printer_info_5(print_hnd, printer, snum)) return WERR_NOMEM; /* check the required size. */ @@ -4768,14 +4746,14 @@ static WERROR getprinter_level_5(int snum, NEW_BUFFER *buffer, uint32 offered, u return WERR_OK; } -static WERROR getprinter_level_7(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_7(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_7 *printer=NULL; if((printer=(PRINTER_INFO_7*)malloc(sizeof(PRINTER_INFO_7)))==NULL) return WERR_NOMEM; - if (!construct_printer_info_7(printer, snum)) + if (!construct_printer_info_7(print_hnd, printer, snum)) return WERR_NOMEM; /* check the required size. */ @@ -4809,6 +4787,7 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); int snum; @@ -4823,19 +4802,19 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET switch (level) { case 0: - return getprinter_level_0(snum, buffer, offered, needed); + return getprinter_level_0(Printer, snum, buffer, offered, needed); case 1: - return getprinter_level_1(snum, buffer, offered, needed); + return getprinter_level_1(Printer, snum, buffer, offered, needed); case 2: - return getprinter_level_2(snum, buffer, offered, needed); + return getprinter_level_2(Printer, snum, buffer, offered, needed); case 3: - return getprinter_level_3(snum, buffer, offered, needed); + return getprinter_level_3(Printer, snum, buffer, offered, needed); case 4: - return getprinter_level_4(snum, buffer, offered, needed); + return getprinter_level_4(Printer, snum, buffer, offered, needed); case 5: - return getprinter_level_5(snum, buffer, offered, needed); + return getprinter_level_5(Printer, snum, buffer, offered, needed); case 7: - return getprinter_level_7(snum, buffer, offered, needed); + return getprinter_level_7(Printer, snum, buffer, offered, needed); } return WERR_UNKNOWN_LEVEL; } @@ -4860,7 +4839,7 @@ static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fst ZERO_STRUCT(driver); - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum)))) return WERR_INVALID_PRINTER_NAME; if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) @@ -4920,7 +4899,7 @@ static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fst ZERO_STRUCT(printer); ZERO_STRUCT(driver); - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum)))) return WERR_INVALID_PRINTER_NAME; if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) @@ -5059,7 +5038,7 @@ static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst WERROR status; ZERO_STRUCT(driver); - status=get_a_printer(&printer, 2, lp_servicename(snum) ); + status=get_a_printer(NULL, &printer, 2, lp_const_servicename(snum) ); DEBUG(8,("construct_printer_driver_info_3: status: %s\n", dos_errstr(status))); if (!W_ERROR_IS_OK(status)) return WERR_INVALID_PRINTER_NAME; @@ -5184,7 +5163,7 @@ static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, ZERO_STRUCT(driver); - status=get_a_printer(&printer, 2, lp_servicename(snum) ); + status=get_a_printer(NULL, &printer, 2, lp_const_servicename(snum) ); DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status))); @@ -5853,13 +5832,6 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, result = WERR_OK; - if (level!=2) { - DEBUG(0,("update_printer: Send a mail to samba@samba.org\n")); - DEBUGADD(0,("with the following message: update_printer: level!=2\n")); - result = WERR_UNKNOWN_LEVEL; - goto done; - } - if (!Printer) { result = WERR_BADFID; goto done; @@ -5870,8 +5842,8 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, goto done; } - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum))) || - (!W_ERROR_IS_OK(get_a_printer(&old_printer, 2, lp_servicename(snum))))) { + if (!W_ERROR_IS_OK(get_a_printer(Printer, &printer, 2, lp_const_servicename(snum))) || + (!W_ERROR_IS_OK(get_a_printer(Printer, &old_printer, 2, lp_const_servicename(snum))))) { result = WERR_BADFID; goto done; } @@ -5899,13 +5871,6 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, result = WERR_NOMEM; goto done; } - - /* - * make sure we actually reload the services after - * this as smb.conf could have a new section in it - * .... shouldn't .... but could - */ - reload_services(False); } /* Do sanity check on the requested changes for Samba */ @@ -5964,9 +5929,6 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, notify_printer_driver(snum, printer->info_2->drivername); } - /* Update printer info */ - result = mod_a_printer(*printer, 2); - /* * flag which changes actually occured. This is a small subset of * all the possible changes. We also have to update things in the @@ -6022,6 +5984,9 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "uNCName", REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); + /* Update printer info */ + result = mod_a_printer(*printer, 2); + done: free_a_printer(&printer, 2); free_a_printer(&old_printer, 2); @@ -6051,7 +6016,7 @@ static WERROR publish_or_unpublish_printer(pipes_struct *p, POLICY_HND *handle, if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; - nt_printer_publish(snum, info7->action); + nt_printer_publish(Printer, snum, info7->action); return WERR_OK; #else @@ -6287,7 +6252,7 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, goto done; } - result = get_a_printer(&ntprinter, 2, lp_servicename(snum)); + result = get_a_printer(NULL, &ntprinter, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(result)) { *returned = 0; goto done; @@ -7591,7 +7556,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; - result = get_a_printer(&printer, 2, lp_servicename(snum)); + result = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(result)) return result; @@ -7655,9 +7620,9 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S /* out_value should default to "" or else NT4 has problems unmarshalling the response */ - *out_max_value_len = (in_value_len/sizeof(uint16)); + *out_max_value_len=(in_value_len/sizeof(uint16)); - if ( (*out_value=(uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL ) + if((*out_value=(uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL) { result = WERR_NOMEM; goto done; @@ -7692,7 +7657,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S */ /* name */ - *out_max_value_len = ( in_value_len / sizeof(uint16) ); + *out_max_value_len=(in_value_len/sizeof(uint16)); if ( (*out_value = (uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL ) { result = WERR_NOMEM; @@ -7765,7 +7730,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP goto done; } - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; @@ -7857,7 +7822,7 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ return WERR_ACCESS_DENIED; } - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; @@ -7901,7 +7866,7 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) goto done; } @@ -7972,7 +7937,7 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) goto done; } @@ -8040,7 +8005,7 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) goto done; } @@ -8390,7 +8355,7 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin goto done; } - ret = get_a_printer(&ntprinter, 2, lp_servicename(snum)); + ret = get_a_printer(NULL, &ntprinter, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(ret)) goto done; @@ -8543,7 +8508,7 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, if ( !get_printer_snum(p,handle, &snum) ) return WERR_BADFID; - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_servicename(snum)); if ( !W_ERROR_IS_OK(status) ) goto done; @@ -8638,7 +8603,7 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, return WERR_ACCESS_DENIED; } - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; @@ -8657,11 +8622,10 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, status = set_printer_dataex( printer, keyname, valuename, type, data, real_len ); - /* save the OID if one was specified and the previous set call succeeded */ - - if ( W_ERROR_IS_OK(status) && oid_string ) + if ( W_ERROR_IS_OK(status) ) { - + /* save the OID if one was specified */ + if ( oid_string ) { fstrcat( keyname, "\\" ); fstrcat( keyname, SPOOL_OID_KEY ); @@ -8676,6 +8640,9 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, REG_SZ, (void*)oid_string, strlen(oid_string)+1 ); } + status = mod_a_printer(*printer, 2); + } + free_a_printer(&printer, 2); return status; @@ -8713,7 +8680,7 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX return WERR_ACCESS_DENIED; } - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; @@ -8757,7 +8724,7 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO if ( !get_printer_snum(p,handle, &snum) ) return WERR_BADFID; - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; @@ -8832,7 +8799,7 @@ WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, return WERR_ACCESS_DENIED; } - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; @@ -8901,7 +8868,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ return WERR_BADFID; ZERO_STRUCT(printer); - result = get_a_printer(&printer, 2, lp_servicename(snum)); + result = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(result)) return result; -- cgit From 23b3b29eec61860155404333f6e70ebd24b50940 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 25 Feb 2003 20:53:53 +0000 Subject: Progress on CR 601 cache the printer_info_2 with the open printer handle. cache is invalidated on a mod_a_printer() call **on that smbd**. Yes, this means that the window for admins to step on each other from different clients just got larger, but since handles a generally short lived this is probably ok. (This used to be commit 31272d3b6bb9ec62fd666301c7adfa0c1720a99b) --- source3/rpc_server/srv_spoolss_nt.c | 277 ++++++++++++++++-------------------- 1 file changed, 122 insertions(+), 155 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 93566c2bb7..fa9b8eaeff 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000, * Copyright (C) Jeremy Allison 2001-2002, - * Copyright (C) Gerald Carter 2000-2002, + * Copyright (C) Gerald Carter 2000-2003, * Copyright (C) Tim Potter 2001-2002. * * This program is free software; you can redistribute it and/or modify @@ -37,8 +37,7 @@ #define MAGIC_DISPLAY_FREQUENCY 0xfade2bad #define PHANTOM_DEVMODE_KEY "_p_f_a_n_t_0_m_" -#define PRINTER_HANDLE_IS_PRINTER 0 -#define PRINTER_HANDLE_IS_PRINTSERVER 1 + /* Table to map the driver version */ /* to OS */ @@ -55,46 +54,6 @@ struct table_node { int version; }; - -/* structure to store the printer handles */ -/* and a reference to what it's pointing to */ -/* and the notify info asked about */ -/* that's the central struct */ -typedef struct _Printer{ - struct _Printer *prev, *next; - BOOL document_started; - BOOL page_started; - uint32 jobid; /* jobid in printing backend */ - BOOL printer_type; - union { - fstring handlename; - fstring printerservername; - } dev; - uint32 type; - uint32 access_granted; - struct { - uint32 flags; - uint32 options; - fstring localmachine; - uint32 printerlocal; - SPOOL_NOTIFY_OPTION *option; - POLICY_HND client_hnd; - BOOL client_connected; - uint32 change; - /* are we in a FindNextPrinterChangeNotify() call? */ - BOOL fnpcn; - } notify; - struct { - fstring machine; - fstring user; - } client; - - /* devmode sent in the OpenPrinter() call */ - NT_DEVICEMODE *nt_devmode; - - -} Printer_entry; - static Printer_entry *printers_list; typedef struct _counter_printer_0 { @@ -251,6 +210,9 @@ static void free_printer_entry(void *ptr) Printer->notify.client_connected=False; free_nt_devicemode( &Printer->nt_devmode ); + free_a_printer( &Printer->printer_info, 2 ); + + talloc_destroy( Printer->ctx ); /* Remove from the internal list. */ DLIST_REMOVE(printers_list, Printer); @@ -303,6 +265,29 @@ static Printer_entry *find_printer_index_by_hnd(pipes_struct *p, POLICY_HND *hnd return find_printer; } +/**************************************************************************** + find printer index by handle +****************************************************************************/ + +void invalidate_printer_hnd_cache( char *printername ) +{ + Printer_entry *p; + + DEBUG(10,("invalidate_printer_hnd_cache: printer [%s]\n", printername)); + + for ( p=printers_list; p; p=p->next ) + { + if ( p->printer_type==PRINTER_HANDLE_IS_PRINTER + && StrCaseCmp(p->dev.handlename, printername)==0) + { + DEBUG(10,("invalidating printer_info cache for handl:\n")); + free_a_printer( &p->printer_info, 2 ); + p->printer_info = NULL; + } + } + + return; +} /**************************************************************************** Close printer index by handle. ****************************************************************************/ @@ -534,6 +519,11 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3 ZERO_STRUCTP(new_printer); + if ( !(new_printer->ctx = talloc_init("Printer Entry [0x%x]", (uint32)hnd)) ) { + DEBUG(0,("open_printer_hnd: talloc_init() failed!\n")); + return False; + } + new_printer->notify.option=NULL; /* Add to the internal list. */ @@ -861,8 +851,7 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS /* add a new group? */ - if ( i == ctr->num_groups ) - { + if ( i == ctr->num_groups ) { ctr->num_groups++; if ( !(groups = talloc_realloc( ctr->ctx, ctr->msg_groups, sizeof(SPOOLSS_NOTIFY_MSG_GROUP)*ctr->num_groups)) ) { @@ -929,8 +918,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) /* loop over all printers */ - for (p = printers_list; p; p = p->next) - { + for (p = printers_list; p; p = p->next) { SPOOL_NOTIFY_INFO_DATA *data; uint32 data_len = 0; uint32 id; @@ -961,8 +949,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) /* build the array of change notifications */ - for ( i=0; inum_msgs; i++ ) - { + for ( i=0; inum_msgs; i++ ) { SPOOLSS_NOTIFY_MSG *msg = &messages[i]; /* Are we monitoring this event? */ @@ -995,8 +982,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) /* Convert unix jobid to smb jobid */ - if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) - { + if (msg->flags & SPOOLSS_NOTIFY_MSG_UNIX_JOBID) { id = sysjob_to_jobid(msg->id); if (id == -1) { @@ -1204,7 +1190,7 @@ void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) WERROR result; NT_PRINTER_INFO_LEVEL *printer = NULL; - result = get_a_printer(&printer, 2, lp_servicename(snum)); + result = get_a_printer(NULL, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(result)) continue; @@ -1300,7 +1286,7 @@ void reset_all_printerdata(int msg_type, pid_t src, void *buf, size_t len) WERROR result; NT_PRINTER_INFO_LEVEL *printer = NULL; - result = get_a_printer( &printer, 2, lp_servicename(snum) ); + result = get_a_printer( NULL, &printer, 2, lp_const_servicename(snum) ); if ( !W_ERROR_IS_OK(result) ) continue; @@ -2157,9 +2143,7 @@ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printe static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value ) { - delete_printer_data( printer->info_2, key, value ); - - return mod_a_printer(*printer, 2); + return delete_printer_data( printer->info_2, key, value ); } /**************************************************************************** @@ -2171,9 +2155,7 @@ static WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *ke { delete_printer_data( printer->info_2, key, value ); - add_printer_data( printer->info_2, key, value, type, data, real_len ); - - return mod_a_printer(*printer, 2); + return add_printer_data( printer->info_2, key, value, type, data, real_len ); } /******************************************************************** @@ -2349,7 +2331,7 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO goto done; } - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_servicename(snum)); if ( !W_ERROR_IS_OK(status) ) goto done; @@ -3443,7 +3425,7 @@ void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 * ********************************************************************/ -static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int +static BOOL construct_notify_printer_info(Printer_entry *print_hnd, SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id, TALLOC_CTX *mem_ctx) @@ -3462,11 +3444,10 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int (option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"), option_type->count, lp_servicename(snum))); - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &printer, 2, lp_const_servicename(snum)))) return False; - for(field_num=0; field_numcount; field_num++) - { + for(field_num=0; field_numcount; field_num++) { field = option_type->fields[field_num]; DEBUG(4,("construct_notify_printer_info: notify [%d]: type [%x], field [%x]\n", field_num, type, field)); @@ -3474,12 +3455,10 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int if (!search_notify(type, field, &j) ) continue; - if((tid=(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(2,("construct_notify_printer_info: failed to enlarge buffer info->data!\n")); return False; - } - else + } else info->data = tid; current_data = &info->data[info->count]; @@ -3611,7 +3590,7 @@ static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, for (snum=0; snumtype ) { case PRINTER_NOTIFY_TYPE: - if(construct_notify_printer_info(info, snum, + if(construct_notify_printer_info(Printer, info, snum, option_type, id, mem_ctx)) id--; @@ -3682,8 +3661,7 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY count = print_queue_status(snum, &queue, &status); - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, - lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)))) goto done; for (j=0; jflags=flags; @@ -3997,7 +3975,7 @@ DEVICEMODE *construct_dev_mode(int snum) DEBUGADD(8,("getting printer characteristics\n")); - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum)))) return NULL; if ( !printer->info_2->devmode ) { @@ -4030,14 +4008,14 @@ done: * fill a printer_info_2 struct ********************************************************************/ -static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum) +static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *printer, int snum) { int count; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; print_status_struct status; - if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; count = print_queue_length(snum, &status); @@ -4093,12 +4071,12 @@ static BOOL construct_printer_info_2(PRINTER_INFO_2 *printer, int snum) * fill a printer_info_3 struct ********************************************************************/ -static BOOL construct_printer_info_3(PRINTER_INFO_3 **pp_printer, int snum) +static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 **pp_printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; PRINTER_INFO_3 *printer = NULL; - if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; *pp_printer = NULL; @@ -4148,11 +4126,11 @@ static BOOL construct_printer_info_3(PRINTER_INFO_3 **pp_printer, int snum) * fill a printer_info_4 struct ********************************************************************/ -static BOOL construct_printer_info_4(PRINTER_INFO_4 *printer, int snum) +static BOOL construct_printer_info_4(Printer_entry *print_hnd, PRINTER_INFO_4 *printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; - if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/ @@ -4168,11 +4146,11 @@ static BOOL construct_printer_info_4(PRINTER_INFO_4 *printer, int snum) * fill a printer_info_5 struct ********************************************************************/ -static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum) +static BOOL construct_printer_info_5(Printer_entry *print_hnd, PRINTER_INFO_5 *printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; - if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; init_unistr(&printer->printername, ntprinter->info_2->printername); @@ -4194,12 +4172,12 @@ static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum) * fill a printer_info_7 struct ********************************************************************/ -static BOOL construct_printer_info_7(PRINTER_INFO_7 *printer, int snum) +static BOOL construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *printer, int snum) { char *guid_str = NULL; GUID guid; - if (is_printer_published(snum, &guid)) { + if (is_printer_published(print_hnd, snum, &guid)) { asprintf(&guid_str, "{%s}", uuid_string_static(guid)); strupper(guid_str); init_unistr(&printer->guid, guid_str); @@ -4230,7 +4208,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); - if (construct_printer_info_1(flags, ¤t_prt, snum)) { + if (construct_printer_info_1(NULL, flags, ¤t_prt, snum)) { if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) { DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n")); SAFE_FREE(printers); @@ -4399,7 +4377,7 @@ static WERROR enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint3 if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); - if (construct_printer_info_2(¤t_prt, snum)) { + if (construct_printer_info_2(NULL, ¤t_prt, snum)) { if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2))) == NULL) { DEBUG(2,("enum_all_printers_info_2: failed to enlarge printers buffer!\n")); SAFE_FREE(printers); @@ -4570,14 +4548,14 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_0(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_0 *printer=NULL; if((printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0))) == NULL) return WERR_NOMEM; - construct_printer_info_0(printer, snum); + construct_printer_info_0(print_hnd, printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_0(printer); @@ -4603,14 +4581,14 @@ static WERROR getprinter_level_0(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_1(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_1 *printer=NULL; if((printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1))) == NULL) return WERR_NOMEM; - construct_printer_info_1(PRINTER_ENUM_ICON8, printer, snum); + construct_printer_info_1(print_hnd, PRINTER_ENUM_ICON8, printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_1(printer); @@ -4636,14 +4614,14 @@ static WERROR getprinter_level_1(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_2(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_2 *printer=NULL; if((printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)))==NULL) return WERR_NOMEM; - construct_printer_info_2(printer, snum); + construct_printer_info_2(print_hnd, printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_2(printer); @@ -4672,11 +4650,11 @@ static WERROR getprinter_level_2(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_3(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_3 *printer=NULL; - if (!construct_printer_info_3(&printer, snum)) + if (!construct_printer_info_3(print_hnd, &printer, snum)) return WERR_NOMEM; /* check the required size. */ @@ -4703,14 +4681,14 @@ static WERROR getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_4(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_4(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_4 *printer=NULL; if((printer=(PRINTER_INFO_4*)malloc(sizeof(PRINTER_INFO_4)))==NULL) return WERR_NOMEM; - if (!construct_printer_info_4(printer, snum)) + if (!construct_printer_info_4(print_hnd, printer, snum)) return WERR_NOMEM; /* check the required size. */ @@ -4737,14 +4715,14 @@ static WERROR getprinter_level_4(int snum, NEW_BUFFER *buffer, uint32 offered, u /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_5(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_5(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_5 *printer=NULL; if((printer=(PRINTER_INFO_5*)malloc(sizeof(PRINTER_INFO_5)))==NULL) return WERR_NOMEM; - if (!construct_printer_info_5(printer, snum)) + if (!construct_printer_info_5(print_hnd, printer, snum)) return WERR_NOMEM; /* check the required size. */ @@ -4768,14 +4746,14 @@ static WERROR getprinter_level_5(int snum, NEW_BUFFER *buffer, uint32 offered, u return WERR_OK; } -static WERROR getprinter_level_7(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_7(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_7 *printer=NULL; if((printer=(PRINTER_INFO_7*)malloc(sizeof(PRINTER_INFO_7)))==NULL) return WERR_NOMEM; - if (!construct_printer_info_7(printer, snum)) + if (!construct_printer_info_7(print_hnd, printer, snum)) return WERR_NOMEM; /* check the required size. */ @@ -4809,6 +4787,7 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; + Printer_entry *Printer=find_printer_index_by_hnd(p, handle); int snum; @@ -4823,19 +4802,19 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET switch (level) { case 0: - return getprinter_level_0(snum, buffer, offered, needed); + return getprinter_level_0(Printer, snum, buffer, offered, needed); case 1: - return getprinter_level_1(snum, buffer, offered, needed); + return getprinter_level_1(Printer, snum, buffer, offered, needed); case 2: - return getprinter_level_2(snum, buffer, offered, needed); + return getprinter_level_2(Printer, snum, buffer, offered, needed); case 3: - return getprinter_level_3(snum, buffer, offered, needed); + return getprinter_level_3(Printer, snum, buffer, offered, needed); case 4: - return getprinter_level_4(snum, buffer, offered, needed); + return getprinter_level_4(Printer, snum, buffer, offered, needed); case 5: - return getprinter_level_5(snum, buffer, offered, needed); + return getprinter_level_5(Printer, snum, buffer, offered, needed); case 7: - return getprinter_level_7(snum, buffer, offered, needed); + return getprinter_level_7(Printer, snum, buffer, offered, needed); } return WERR_UNKNOWN_LEVEL; } @@ -4860,7 +4839,7 @@ static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fst ZERO_STRUCT(driver); - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum)))) return WERR_INVALID_PRINTER_NAME; if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) @@ -4920,7 +4899,7 @@ static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fst ZERO_STRUCT(printer); ZERO_STRUCT(driver); - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum)))) return WERR_INVALID_PRINTER_NAME; if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) @@ -5059,7 +5038,7 @@ static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst WERROR status; ZERO_STRUCT(driver); - status=get_a_printer(&printer, 2, lp_servicename(snum) ); + status=get_a_printer(NULL, &printer, 2, lp_const_servicename(snum) ); DEBUG(8,("construct_printer_driver_info_3: status: %s\n", dos_errstr(status))); if (!W_ERROR_IS_OK(status)) return WERR_INVALID_PRINTER_NAME; @@ -5184,7 +5163,7 @@ static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, ZERO_STRUCT(driver); - status=get_a_printer(&printer, 2, lp_servicename(snum) ); + status=get_a_printer(NULL, &printer, 2, lp_const_servicename(snum) ); DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status))); @@ -5853,13 +5832,6 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, result = WERR_OK; - if (level!=2) { - DEBUG(0,("update_printer: Send a mail to samba@samba.org\n")); - DEBUGADD(0,("with the following message: update_printer: level!=2\n")); - result = WERR_UNKNOWN_LEVEL; - goto done; - } - if (!Printer) { result = WERR_BADFID; goto done; @@ -5870,8 +5842,8 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, goto done; } - if (!W_ERROR_IS_OK(get_a_printer(&printer, 2, lp_servicename(snum))) || - (!W_ERROR_IS_OK(get_a_printer(&old_printer, 2, lp_servicename(snum))))) { + if (!W_ERROR_IS_OK(get_a_printer(Printer, &printer, 2, lp_const_servicename(snum))) || + (!W_ERROR_IS_OK(get_a_printer(Printer, &old_printer, 2, lp_const_servicename(snum))))) { result = WERR_BADFID; goto done; } @@ -5899,13 +5871,6 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, result = WERR_NOMEM; goto done; } - - /* - * make sure we actually reload the services after - * this as smb.conf could have a new section in it - * .... shouldn't .... but could - */ - reload_services(False); } /* Do sanity check on the requested changes for Samba */ @@ -5964,9 +5929,6 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, notify_printer_driver(snum, printer->info_2->drivername); } - /* Update printer info */ - result = mod_a_printer(*printer, 2); - /* * flag which changes actually occured. This is a small subset of * all the possible changes. We also have to update things in the @@ -6022,6 +5984,9 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "uNCName", REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); + /* Update printer info */ + result = mod_a_printer(*printer, 2); + done: free_a_printer(&printer, 2); free_a_printer(&old_printer, 2); @@ -6051,7 +6016,7 @@ static WERROR publish_or_unpublish_printer(pipes_struct *p, POLICY_HND *handle, if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; - nt_printer_publish(snum, info7->action); + nt_printer_publish(Printer, snum, info7->action); return WERR_OK; #else @@ -6287,7 +6252,7 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, goto done; } - result = get_a_printer(&ntprinter, 2, lp_servicename(snum)); + result = get_a_printer(NULL, &ntprinter, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(result)) { *returned = 0; goto done; @@ -7591,7 +7556,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; - result = get_a_printer(&printer, 2, lp_servicename(snum)); + result = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(result)) return result; @@ -7655,9 +7620,9 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S /* out_value should default to "" or else NT4 has problems unmarshalling the response */ - *out_max_value_len = (in_value_len/sizeof(uint16)); + *out_max_value_len=(in_value_len/sizeof(uint16)); - if ( (*out_value=(uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL ) + if((*out_value=(uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL) { result = WERR_NOMEM; goto done; @@ -7692,7 +7657,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S */ /* name */ - *out_max_value_len = ( in_value_len / sizeof(uint16) ); + *out_max_value_len=(in_value_len/sizeof(uint16)); if ( (*out_value = (uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL ) { result = WERR_NOMEM; @@ -7765,7 +7730,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP goto done; } - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; @@ -7857,7 +7822,7 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ return WERR_ACCESS_DENIED; } - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; @@ -7901,7 +7866,7 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) goto done; } @@ -7972,7 +7937,7 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) goto done; } @@ -8040,7 +8005,7 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) goto done; } @@ -8390,7 +8355,7 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin goto done; } - ret = get_a_printer(&ntprinter, 2, lp_servicename(snum)); + ret = get_a_printer(NULL, &ntprinter, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(ret)) goto done; @@ -8543,7 +8508,7 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, if ( !get_printer_snum(p,handle, &snum) ) return WERR_BADFID; - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_servicename(snum)); if ( !W_ERROR_IS_OK(status) ) goto done; @@ -8638,7 +8603,7 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, return WERR_ACCESS_DENIED; } - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; @@ -8657,11 +8622,10 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, status = set_printer_dataex( printer, keyname, valuename, type, data, real_len ); - /* save the OID if one was specified and the previous set call succeeded */ - - if ( W_ERROR_IS_OK(status) && oid_string ) + if ( W_ERROR_IS_OK(status) ) { - + /* save the OID if one was specified */ + if ( oid_string ) { fstrcat( keyname, "\\" ); fstrcat( keyname, SPOOL_OID_KEY ); @@ -8676,6 +8640,9 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, REG_SZ, (void*)oid_string, strlen(oid_string)+1 ); } + status = mod_a_printer(*printer, 2); + } + free_a_printer(&printer, 2); return status; @@ -8713,7 +8680,7 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX return WERR_ACCESS_DENIED; } - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; @@ -8757,7 +8724,7 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO if ( !get_printer_snum(p,handle, &snum) ) return WERR_BADFID; - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; @@ -8832,7 +8799,7 @@ WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, return WERR_ACCESS_DENIED; } - status = get_a_printer(&printer, 2, lp_servicename(snum)); + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; @@ -8901,7 +8868,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ return WERR_BADFID; ZERO_STRUCT(printer); - result = get_a_printer(&printer, 2, lp_servicename(snum)); + result = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(result)) return result; -- cgit From 97e7d2ffae74c9c07b38143c8fb028ee91b153bd Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 27 Feb 2003 21:21:02 +0000 Subject: additional fix for CR 601 * distinguish WinXP from Win2k * add a 1/3 of a second delay in OpenPrinter in order to trigger a LAN/WAN optimization in 2k clients. (This used to be commit 96570699d1b715f47c35aa211da6ec18f6fc4109) --- source3/rpc_server/srv_spoolss_nt.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index fa9b8eaeff..4006d0c08e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1675,6 +1675,12 @@ Can't find printer handle we created for printer %s\n", name )); &Printer->nt_devmode ); } + /* HACK ALERT!!! Sleep for 1/3 of a second to try trigger a LAN/WAN + optimization in Windows 2000 clients --jerry */ + + if ( RA_WIN2K == get_remote_arch() ) + usleep( 384000 ); + return WERR_OK; } -- cgit From 0d30cdf66c4e186e20a09e1e8b39d501e662ae50 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 27 Feb 2003 21:22:36 +0000 Subject: additional fix for CR 601 * distinguish WinXP from Win2k * add a 1/3 of a second delay in OpenPrinter in order to trigger a LAN/WAN optimization in 2k clients. (This used to be commit c7712fa054d21b4884a78b7ea6c0fb8b3d637c6b) --- source3/rpc_server/srv_spoolss_nt.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index fa9b8eaeff..4006d0c08e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1675,6 +1675,12 @@ Can't find printer handle we created for printer %s\n", name )); &Printer->nt_devmode ); } + /* HACK ALERT!!! Sleep for 1/3 of a second to try trigger a LAN/WAN + optimization in Windows 2000 clients --jerry */ + + if ( RA_WIN2K == get_remote_arch() ) + usleep( 384000 ); + return WERR_OK; } -- cgit From ba3ccc2928f0178034b48e27383e57a8cf1a4f21 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 1 Mar 2003 02:39:12 +0000 Subject: Added limit to number of jobs enumerated. Set to 0 (means no limit). Yes I will add the docs.... Jeremy. (This used to be commit e1b0001c8df9e9823b42a372ca675188570b252a) --- source3/rpc_server/srv_spoolss_nt.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4006d0c08e..b321832930 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6323,6 +6323,7 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO int snum; print_status_struct prt_status; print_queue_struct *queue=NULL; + int max_rep_jobs; /* that's an [in out] buffer */ spoolss_move_buffer(q_u->buffer, &r_u->buffer); @@ -6336,6 +6337,8 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; + max_rep_jobs = lp_max_reported_jobs(snum); + *returned = print_queue_status(snum, &queue, &prt_status); DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); @@ -6344,6 +6347,9 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO return WERR_OK; } + if (max_rep_jobs && (*returned > max_rep_jobs)) + *returned = max_rep_jobs; + switch (level) { case 1: return enumjobs_level1(queue, snum, buffer, offered, needed, returned); -- cgit From e2366787aea4c1a083eb481dc3e58ec09a33c9e8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 1 Mar 2003 02:39:14 +0000 Subject: Added limit to number of jobs enumerated. Set to 0 (means no limit). Yes I will add the docs.... Jeremy. (This used to be commit 4a739d914bb87a3c8d071dfd0f275a9aab1cf90a) --- source3/rpc_server/srv_spoolss_nt.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4006d0c08e..b321832930 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6323,6 +6323,7 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO int snum; print_status_struct prt_status; print_queue_struct *queue=NULL; + int max_rep_jobs; /* that's an [in out] buffer */ spoolss_move_buffer(q_u->buffer, &r_u->buffer); @@ -6336,6 +6337,8 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; + max_rep_jobs = lp_max_reported_jobs(snum); + *returned = print_queue_status(snum, &queue, &prt_status); DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); @@ -6344,6 +6347,9 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO return WERR_OK; } + if (max_rep_jobs && (*returned > max_rep_jobs)) + *returned = max_rep_jobs; + switch (level) { case 1: return enumjobs_level1(queue, snum, buffer, offered, needed, returned); -- cgit From d95f1e4260e66b0ab37b69105e7cc252e23bee16 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 3 Mar 2003 16:32:03 +0000 Subject: * CR1868: only send a change notify message if we have something that changed that the client is monitoring. * couple of comments abnout how we need to validate driver names on SetPrinter() and AddPrinter() * up the debug level on some overly verbose dev mode parsing messages (This used to be commit e8939165b77c9e2ea8b3cef2e85885b9812c7184) --- source3/rpc_server/srv_spoolss_nt.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b321832930..a966326d3a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -900,7 +900,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) TALLOC_CTX *mem_ctx = notify_ctr_getctx( ctr ); SPOOLSS_NOTIFY_MSG_GROUP *msg_group = notify_ctr_getgroup( ctr, idx ); SPOOLSS_NOTIFY_MSG *messages; - + int sending_msg_count; if ( !msg_group ) { DEBUG(5,("send_notify2_changes() called with no msg group!\n")); @@ -949,6 +949,8 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) /* build the array of change notifications */ + sending_msg_count = 0; + for ( i=0; inum_msgs; i++ ) { SPOOLSS_NOTIFY_MSG *msg = &messages[i]; @@ -957,6 +959,8 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) if (!is_monitoring_event(p, msg->type, msg->field)) continue; + sending_msg_count++; + DEBUG(10,("process_notify2_message: Sending message type [%x] field [%x] for printer [%s]\n", msg->type, msg->field, p->dev.handlename)); @@ -1012,8 +1016,10 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) data_len++; } - cli_spoolss_rrpcn( ¬ify_cli, mem_ctx, &p->notify.client_hnd, - data_len, data, p->notify.change, 0 ); + if ( sending_msg_count ) { + cli_spoolss_rrpcn( ¬ify_cli, mem_ctx, &p->notify.client_hnd, + data_len, data, p->notify.change, 0 ); + } } done: @@ -5886,6 +5892,9 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, goto done; } + /* FIXME!!! If the driver has changed we really should verify that + it is installed before doing much else --jerry */ + /* Check calling user has permission to update printer description */ if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { @@ -7177,6 +7186,9 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ free_a_printer(&printer, 2); return WERR_PRINTER_ALREADY_EXISTS; } + + /* FIXME!!! smbd should check to see if the driver is installed before + trying to add a printer like this --jerry */ if (*lp_addprinter_cmd() ) { if ( !add_printer_hook(printer) ) { -- cgit From 21be9e77761f56abf2b00d4faece2fae2f45e3b6 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 3 Mar 2003 16:34:19 +0000 Subject: * CR1868: only send a change notify message if we have something that changed that the client is monitoring. * couple of comments abnout how we need to validate driver names on SetPrinter() and AddPrinter() * up the debug level on some overly verbose dev mode parsing messages (This used to be commit 7377d671e8a95ac2ab0452f564b18b2a098699cb) --- source3/rpc_server/srv_spoolss_nt.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b321832930..4090800fc9 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -900,7 +900,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) TALLOC_CTX *mem_ctx = notify_ctr_getctx( ctr ); SPOOLSS_NOTIFY_MSG_GROUP *msg_group = notify_ctr_getgroup( ctr, idx ); SPOOLSS_NOTIFY_MSG *messages; - + int sending_msg_count; if ( !msg_group ) { DEBUG(5,("send_notify2_changes() called with no msg group!\n")); @@ -949,6 +949,8 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) /* build the array of change notifications */ + sending_msg_count = 0; + for ( i=0; inum_msgs; i++ ) { SPOOLSS_NOTIFY_MSG *msg = &messages[i]; @@ -957,6 +959,8 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) if (!is_monitoring_event(p, msg->type, msg->field)) continue; + sending_msg_count++; + DEBUG(10,("process_notify2_message: Sending message type [%x] field [%x] for printer [%s]\n", msg->type, msg->field, p->dev.handlename)); @@ -1012,9 +1016,11 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) data_len++; } + if ( sending_msg_count ) { cli_spoolss_rrpcn( ¬ify_cli, mem_ctx, &p->notify.client_hnd, data_len, data, p->notify.change, 0 ); } + } done: DEBUG(8,("send_notify2_changes: Exit...\n")); @@ -5886,6 +5892,9 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, goto done; } + /* FIXME!!! If the driver has changed we really should verify that + it is installed before doing much else --jerry */ + /* Check calling user has permission to update printer description */ if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { @@ -7177,6 +7186,9 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ free_a_printer(&printer, 2); return WERR_PRINTER_ALREADY_EXISTS; } + + /* FIXME!!! smbd should check to see if the driver is installed before + trying to add a printer like this --jerry */ if (*lp_addprinter_cmd() ) { if ( !add_printer_hook(printer) ) { -- cgit From cc7f40f4b7c090e73f7cd54e89e3927c8bff0004 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 3 Mar 2003 17:32:55 +0000 Subject: * always report ourselves as a Windows 2000 print server (even without ADS support) * add "MinorVersion" print server data key and comment on "OSVersion" (This used to be commit e1383368169faa50b9e612c9f71f92f790698b48) --- source3/rpc_server/srv_spoolss_nt.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a966326d3a..5d63f27d23 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2220,14 +2220,37 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; -#ifdef HAVE_ADS SIVAL(*data, 0, 3); -#else + *needed = 0x4; + return WERR_OK; + } + + if (!StrCaseCmp(value, "MinorVersion")) { + *type = 0x4; + if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) + return WERR_NOMEM; + SIVAL(*data, 0, 0); + *needed = 0x4; + return WERR_OK; + } + +#if 0 /* JERRY */ + /* REG_BINARY + * uint32 size = 0x114 + * uint32 major = 5 + * uint32 minor = [0|1] + * uint32 build = [2195|2600] + * extra unicode string = e.g. "Service Pack 3" + */ + if (!StrCaseCmp(value, "OSVersion")) { + *type = 0x4; + if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) + return WERR_NOMEM; SIVAL(*data, 0, 2); -#endif *needed = 0x4; return WERR_OK; } +#endif if (!StrCaseCmp(value, "DefaultSpoolDirectory")) { fstring string; @@ -3843,13 +3866,11 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p printer->global_counter = global_counter; printer->total_pages = 0; -#ifdef HAVE_ADS + + /* in 2.2 we reported ourselves as 0x0004 and 0x0565 */ printer->major_version = 0x0005; /* NT 5 */ printer->build_version = 0x0893; /* build 2195 */ -#else - printer->major_version = 0x0004; /* NT 4 */ - printer->build_version = 0x0565; /* build 1381 */ -#endif + printer->unknown7 = 0x1; printer->unknown8 = 0x0; printer->unknown9 = 0x0; -- cgit From 03a4c1907f93a2efb985ca69180f800be285926d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 3 Mar 2003 17:33:57 +0000 Subject: * always report ourselves as a Windows 2000 print server (even without ADS support) * add "MinorVersion" print server data key and comment on "OSVersion" (This used to be commit 342734e3de71c7dc8e3d24fd66dae58cf647a569) --- source3/rpc_server/srv_spoolss_nt.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4090800fc9..8073e3cf28 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2220,14 +2220,37 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; -#ifdef HAVE_ADS SIVAL(*data, 0, 3); -#else + *needed = 0x4; + return WERR_OK; + } + + if (!StrCaseCmp(value, "MinorVersion")) { + *type = 0x4; + if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) + return WERR_NOMEM; + SIVAL(*data, 0, 0); + *needed = 0x4; + return WERR_OK; + } + +#if 0 /* JERRY */ + /* REG_BINARY + * uint32 size = 0x114 + * uint32 major = 5 + * uint32 minor = [0|1] + * uint32 build = [2195|2600] + * extra unicode string = e.g. "Service Pack 3" + */ + if (!StrCaseCmp(value, "OSVersion")) { + *type = 0x4; + if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) + return WERR_NOMEM; SIVAL(*data, 0, 2); -#endif *needed = 0x4; return WERR_OK; } +#endif if (!StrCaseCmp(value, "DefaultSpoolDirectory")) { fstring string; @@ -3843,13 +3866,11 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p printer->global_counter = global_counter; printer->total_pages = 0; -#ifdef HAVE_ADS + + /* in 2.2 we reported ourselves as 0x0004 and 0x0565 */ printer->major_version = 0x0005; /* NT 5 */ printer->build_version = 0x0893; /* build 2195 */ -#else - printer->major_version = 0x0004; /* NT 4 */ - printer->build_version = 0x0565; /* build 1381 */ -#endif + printer->unknown7 = 0x1; printer->unknown8 = 0x0; printer->unknown9 = 0x0; -- cgit From 52d1dd46d2f26e4f81a6b307e8139ed379af1920 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 3 Mar 2003 19:56:57 +0000 Subject: Fix const warning. Jeremy. (This used to be commit dedc18212a5174b6abac60ede9828f9b726a6c2d) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 50127005a1..588d6644b1 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -800,7 +800,7 @@ int rpc_load_module(const char *module) void *handle; int (*module_init)(void); pstring full_path; - char *error; + const char *error; pstrcpy(full_path, lib_path("rpc")); pstrcat(full_path, "/librpc_"); -- cgit From 04858cd7025bb4c3fdb34a2795568a6b52004c3b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 7 Mar 2003 09:29:56 +0000 Subject: Limit the number of SIDs that may be looked up, in line with existing code for name->sid. (This used to be commit 0ebccc0dbeecc10d423529909a2563fbc3bf9857) --- source3/rpc_server/srv_lsa_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 1b42c5f141..fb6538db39 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -641,6 +641,11 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_ LSA_TRANS_NAME_ENUM *names = NULL; uint32 mapped_count = 0; + if (num_entries > MAX_LOOKUP_SIDS) { + num_entries = MAX_LOOKUP_SIDS; + DEBUG(5,("_lsa_lookup_sids: truncating SID lookup list to %d\n", num_entries)); + } + ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); names = (LSA_TRANS_NAME_ENUM *)talloc_zero(p->mem_ctx, sizeof(LSA_TRANS_NAME_ENUM)); -- cgit From 30d1059b7a29f3f565122c2913531f5cf8a8ce44 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 13 Mar 2003 00:50:04 +0000 Subject: Merge of Andrew Bartlett's SID limit fix from HEAD. Jeremy. (This used to be commit 98ed7e0cbbc693b486bb91855cb3331e51daef6c) --- source3/rpc_server/srv_lsa_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index fc51d7ef2f..10c583b70d 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -641,6 +641,11 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_ LSA_TRANS_NAME_ENUM *names = NULL; uint32 mapped_count = 0; + if (num_entries > MAX_LOOKUP_SIDS) { + num_entries = MAX_LOOKUP_SIDS; + DEBUG(5,("_lsa_lookup_sids: truncating SID lookup list to %d\n", num_entries)); + } + ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); names = (LSA_TRANS_NAME_ENUM *)talloc_zero(p->mem_ctx, sizeof(LSA_TRANS_NAME_ENUM)); -- cgit From 7b18c5d1647b44f46cf973701b3bcc9aefb37e7d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 16 Mar 2003 13:24:36 +0000 Subject: Make sure we mark the assumption of a fstring parameter for 'devicetype' in the function prototype, and change callers to respect this. Andrew Bartlett (This used to be commit 9f3d3c380120f16d76d68f346799282d61eec892) --- source3/rpc_server/srv_srvsvc_nt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 6d2320d67d..815dd75d22 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1840,6 +1840,8 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC struct current_user user; connection_struct *conn = NULL; BOOL became_user = False; + fstring dev; + fstrcpy(dev, "A:"); ZERO_STRUCT(st); @@ -1853,7 +1855,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC get_current_user(&user, p); become_root(); - conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status); + conn = make_connection(qualname, null_pw, dev, user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { @@ -1943,9 +1945,12 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ struct current_user user; connection_struct *conn = NULL; BOOL became_user = False; + fstring dev; + fstrcpy(dev, "A:"); ZERO_STRUCT(st); + r_u->status = WERR_OK; unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); @@ -1956,7 +1961,7 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ get_current_user(&user, p); become_root(); - conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status); + conn = make_connection(qualname, null_pw, dev, user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { -- cgit From 4e8d7b3e8ed045f6a110889c5e31f2c5170b68a7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Mar 2003 23:49:03 +0000 Subject: Ensure dev in make_connection is const. Jeremy. (This used to be commit 1c6ea31b8f48b93606f4c5b6a0472571dc8a471e) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 6d2320d67d..1a7b64858b 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1867,7 +1867,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC r_u->status = WERR_ACCESS_DENIED; goto error_exit; } - became_user = True; + became_user = True; unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename)); unix_convert(filename, conn, NULL, &bad_path, &st); -- cgit From 736c7538412a7e9abd85cc7bc95c48f72bed4d56 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Mar 2003 23:51:18 +0000 Subject: Ensure dev in make_connection is const. Jeremy. (This used to be commit e8155fade61e9dc308a82f442453803160c36806) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 815dd75d22..4d9130fb97 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1869,7 +1869,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC r_u->status = WERR_ACCESS_DENIED; goto error_exit; } - became_user = True; + became_user = True; unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename)); unix_convert(filename, conn, NULL, &bad_path, &st); -- cgit From 47ea3a2bf242a446f658f1573ec5d3ea533333f0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 19 Mar 2003 18:45:19 +0000 Subject: Put in the new modules system. It's now used by passdb and rpc. I will put a doc about it in dev-doc later today. (This used to be commit af7bfee0c6902c07fdb8d3abccf4c8d6bab00b5a) --- source3/rpc_server/srv_dfs.c | 4 --- source3/rpc_server/srv_lsa.c | 4 --- source3/rpc_server/srv_netlog.c | 4 --- source3/rpc_server/srv_pipe.c | 77 ++-------------------------------------- source3/rpc_server/srv_reg.c | 4 --- source3/rpc_server/srv_samr.c | 4 --- source3/rpc_server/srv_spoolss.c | 4 --- source3/rpc_server/srv_srvsvc.c | 4 --- source3/rpc_server/srv_wkssvc.c | 4 --- 9 files changed, 2 insertions(+), 107 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 14c1cb4088..0807efd550 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -158,11 +158,7 @@ static BOOL api_dfs_enum(pipes_struct *p) \pipe\netdfs commands ********************************************************************/ -#ifdef RPC_DFS_DYNAMIC -int init_module(void) -#else int rpc_dfs_init(void) -#endif { struct api_struct api_netdfs_cmds[] = { diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 0e4039326b..bfa706acf2 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -771,11 +771,7 @@ static BOOL api_lsa_remove_acct_rights(pipes_struct *p) \PIPE\ntlsa commands ***************************************************************************/ -#ifdef RPC_LSA_DYNAMIC -int init_module(void) -#else int rpc_lsa_init(void) -#endif { static const struct api_struct api_lsa_cmds[] = { diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index c9e4fc1b1f..7dc0f57f34 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -321,11 +321,7 @@ static BOOL api_net_logon_ctrl(pipes_struct *p) array of \PIPE\NETLOGON operations ********************************************************************/ -#ifdef RPC_NETLOG_DYNAMIC -int init_module(void) -#else int rpc_net_init(void) -#endif { static struct api_struct api_net_cmds [] = { diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index f6deac68f8..d6b774c566 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -454,41 +454,6 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); The switch table for the pipe names and the functions to handle them. *******************************************************************/ -struct api_cmd -{ - const char *name; - int (*init)(void); -}; - -static struct api_cmd api_fd_commands[] = -{ -#ifndef RPC_LSA_DYNAMIC - { "lsarpc", rpc_lsa_init }, -#endif -#ifndef RPC_SAMR_DYNAMIC - { "samr", rpc_samr_init }, -#endif -#ifndef RPC_SVC_DYNAMIC - { "srvsvc", rpc_srv_init }, -#endif -#ifndef RPC_WKS_DYNAMIC - { "wkssvc", rpc_wks_init }, -#endif -#ifndef RPC_NETLOG_DYNAMIC - { "NETLOGON", rpc_net_init }, -#endif -#ifndef RPC_REG_DYNAMIC - { "winreg", rpc_reg_init }, -#endif -#ifndef RPC_SPOOLSS_DYNAMIC - { "spoolss", rpc_spoolss_init }, -#endif -#ifndef RPC_DFS_DYNAMIC - { "netdfs", rpc_dfs_init }, -#endif - { NULL, NULL } -}; - struct rpc_table { struct @@ -791,28 +756,6 @@ int rpc_pipe_register_commands(const char *clnt, const char *srv, const struct a return size; } -/******************************************************************* - Register commands to an RPC pipe -*******************************************************************/ -int rpc_load_module(const char *module) -{ - pstring full_path; - int status; - - pstrcpy(full_path, lib_path("rpc")); - pstrcat(full_path, "/librpc_"); - pstrcat(full_path, module); - pstrcat(full_path, "."); - pstrcat(full_path, shlib_ext()); - - if (!(status = smb_load_module(full_path))) { - DEBUG(0, ("Could not load requested pipe %s as %s\n", - module, full_path)); - } - - return status; -} - /******************************************************************* Respond to a pipe bind request. *******************************************************************/ @@ -851,14 +794,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) } if (i == rpc_lookup_size) { - for (i = 0; api_fd_commands[i].name; i++) { - if (strequal(api_fd_commands[i].name, p->name)) { - api_fd_commands[i].init(); - break; - } - } - - if (!api_fd_commands[i].name && !rpc_load_module(p->name)) { + if (!smb_probe_module("rpc", p->name)) { DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", p->name )); if(!setup_bind_nak(p)) @@ -1273,16 +1209,7 @@ BOOL api_pipe_request(pipes_struct *p) if (i == rpc_lookup_size) { - for (i = 0; api_fd_commands[i].name; i++) { - if (strequal(api_fd_commands[i].name, p->name)) { - api_fd_commands[i].init(); - break; - } - } - - if (!api_fd_commands[i].name) { - rpc_load_module(p->name); - } + smb_probe_module("rpc", p->name); for (i = 0; i < rpc_lookup_size; i++) { if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 8fc1d42b2f..f72d8e4f29 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -373,11 +373,7 @@ static BOOL api_reg_save_key(pipes_struct *p) array of \PIPE\reg operations ********************************************************************/ -#ifdef RPC_REG_DYNAMIC -int init_module(void) -#else int rpc_reg_init(void) -#endif { static struct api_struct api_reg_cmds[] = { diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index b75195ceef..67c092775b 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1443,11 +1443,7 @@ static BOOL api_samr_set_dom_info(pipes_struct *p) array of \PIPE\samr operations ********************************************************************/ -#ifdef RPC_SAMR_DYNAMIC -int init_module(void) -#else int rpc_samr_init(void) -#endif { static struct api_struct api_samr_cmds [] = { diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 3023922a5b..a7dd7a6cef 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1580,11 +1580,7 @@ static BOOL api_spoolss_replycloseprinter(pipes_struct *p) \pipe\spoolss commands ********************************************************************/ -#ifdef RPC_SPOOLSS_DYNAMIC -int init_module(void) -#else int rpc_spoolss_init(void) -#endif { struct api_struct api_spoolss_cmds[] = { diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 7c5e317c87..96820ae74b 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -526,11 +526,7 @@ static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) \PIPE\srvsvc commands ********************************************************************/ -#ifdef RPC_SVC_DYNAMIC -int init_module(void) -#else int rpc_srv_init(void) -#endif { static const struct api_struct api_srv_cmds[] = { diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index e0d662ea80..ddcbadd1d4 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -60,11 +60,7 @@ static BOOL api_wks_query_info(pipes_struct *p) \PIPE\wkssvc commands ********************************************************************/ -#ifdef RPC_WKS_DYNAMIC -int init_module(void) -#else int rpc_wks_init(void) -#endif { static struct api_struct api_wks_cmds[] = { -- cgit From c8eed69be0850e7c68318562c91f73855a09dd92 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 20 Mar 2003 00:51:41 +0000 Subject: lib/messages.c: Check return from chainlock before modifying message queue. Apply the job returned limit across all requests for job queues. Jeremy. (This used to be commit dee1326a1d8a0bf8977df22a0fe014dd5d8dc769) --- source3/rpc_server/srv_spoolss_nt.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8073e3cf28..36ff92e46f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6353,7 +6353,6 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO int snum; print_status_struct prt_status; print_queue_struct *queue=NULL; - int max_rep_jobs; /* that's an [in out] buffer */ spoolss_move_buffer(q_u->buffer, &r_u->buffer); @@ -6367,8 +6366,6 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; - max_rep_jobs = lp_max_reported_jobs(snum); - *returned = print_queue_status(snum, &queue, &prt_status); DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); @@ -6377,9 +6374,6 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO return WERR_OK; } - if (max_rep_jobs && (*returned > max_rep_jobs)) - *returned = max_rep_jobs; - switch (level) { case 1: return enumjobs_level1(queue, snum, buffer, offered, needed, returned); -- cgit From 3be18a1fba5b008e55a4497470165de62aa15054 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 20 Mar 2003 00:52:37 +0000 Subject: lib/messages.c: Check return from chainlock before modifying message queue. Apply the job returned limit across all requests for job queues. Jeremy. (This used to be commit bf795b684e608f82db822e0759e7b69afd451b65) --- source3/rpc_server/srv_spoolss_nt.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5d63f27d23..a7b73b5ac9 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6353,7 +6353,6 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO int snum; print_status_struct prt_status; print_queue_struct *queue=NULL; - int max_rep_jobs; /* that's an [in out] buffer */ spoolss_move_buffer(q_u->buffer, &r_u->buffer); @@ -6367,8 +6366,6 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; - max_rep_jobs = lp_max_reported_jobs(snum); - *returned = print_queue_status(snum, &queue, &prt_status); DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); @@ -6377,9 +6374,6 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO return WERR_OK; } - if (max_rep_jobs && (*returned > max_rep_jobs)) - *returned = max_rep_jobs; - switch (level) { case 1: return enumjobs_level1(queue, snum, buffer, offered, needed, returned); -- cgit From 677838b9997d89dc53c9b5b9a3601c0bc2cbdf80 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 21 Mar 2003 13:28:06 +0000 Subject: Give volker a hand, and let domain joins with existing user accounts work a bit better. This just sets the minimum possible attributes - if we are 'upgrading' an LDAP based user account, the attributes will be there anyway. This matches NT pretty well to. This also fixes some use of unitialised values in the desired_access checking. (found by valgrind). Andrew Bartlett (This used to be commit 929213ff2a5829ba8435ba1be0de317bca1e0da0) --- source3/rpc_server/srv_samr_nt.c | 50 ++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d766e9c19e..7448dc6401 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -81,6 +81,7 @@ NTSTATUS access_check_samr_object(SEC_DESC *psd, NT_USER_TOKEN *nt_user_token, u NTSTATUS status = NT_STATUS_ACCESS_DENIED; if (!se_access_check(psd, nt_user_token, des_access, acc_granted, &status)) { + *acc_granted = des_access; if (geteuid() == sec_initial_uid()) { DEBUG(4,("%s: ACCESS should be DENIED (requested: %#010x)\n", debug, des_access)); @@ -2199,7 +2200,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ uint32 acc_granted; SEC_DESC *psd; size_t sd_size; - uint32 des_access; + uint32 des_access = GENERIC_RIGHTS_USER_ALL_ACCESS; /* Get the domain SID stored in the domain policy */ if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted)) @@ -2284,25 +2285,50 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ DEBUG(3,("_api_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); } + if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&sam_pass))) { + return nt_status; + } + pw = getpwnam_alloc(account); if (pw) { - if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam_pw(&sam_pass, pw))) { - passwd_free(&pw); - return nt_status; + DOM_SID user_sid; + DOM_SID group_sid; + if (!uid_to_sid(&user_sid, pw->pw_uid)) { + passwd_free(&pw); /* done with this now */ + pdb_free_sam(&sam_pass); + DEBUG(1, ("_api_samr_create_user: uid_to_sid failed, cannot add user.\n")); + return NT_STATUS_ACCESS_DENIED; } - passwd_free(&pw); /* done with this now */ - } else { - DEBUG(3,("attempting to create non-unix account %s\n", account)); - - if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&sam_pass))) { - return nt_status; + + if (!pdb_set_user_sid(sam_pass, &user_sid, PDB_CHANGED)) { + passwd_free(&pw); /* done with this now */ + pdb_free_sam(&sam_pass); + return NT_STATUS_NO_MEMORY; } - - if (!pdb_set_username(sam_pass, account, PDB_CHANGED)) { + + if (!gid_to_sid(&group_sid, pw->pw_gid)) { + passwd_free(&pw); /* done with this now */ + pdb_free_sam(&sam_pass); + DEBUG(1, ("_api_samr_create_user: gid_to_sid failed, cannot add user.\n")); + return NT_STATUS_ACCESS_DENIED; + } + + if (!pdb_set_group_sid(sam_pass, &group_sid, PDB_CHANGED)) { + passwd_free(&pw); /* done with this now */ pdb_free_sam(&sam_pass); return NT_STATUS_NO_MEMORY; } + + passwd_free(&pw); /* done with this now */ + } else { + DEBUG(3,("attempting to create non-unix account %s\n", account)); + + } + + if (!pdb_set_username(sam_pass, account, PDB_CHANGED)) { + pdb_free_sam(&sam_pass); + return NT_STATUS_NO_MEMORY; } pdb_set_acct_ctrl(sam_pass, acb_info, PDB_CHANGED); -- cgit From eeae85278106abff538ed672116a81bec29906e3 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 21 Mar 2003 13:35:15 +0000 Subject: (merge from HEAD) Give volker a hand, and let domain joins with existing user accounts work a bit better. This just sets the minimum possible attributes - if we are 'upgrading' an LDAP based user account, the attributes will be there anyway. This matches NT pretty well to. This also fixes some use of unitialised values in the desired_access checking. (found by valgrind). Andrew Bartlett (This used to be commit 536e24ee5b83eaa77be81dd50e3e1a5010b5abf4) --- source3/rpc_server/srv_samr_nt.c | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d766e9c19e..f174114473 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -81,6 +81,7 @@ NTSTATUS access_check_samr_object(SEC_DESC *psd, NT_USER_TOKEN *nt_user_token, u NTSTATUS status = NT_STATUS_ACCESS_DENIED; if (!se_access_check(psd, nt_user_token, des_access, acc_granted, &status)) { + *acc_granted = des_access; if (geteuid() == sec_initial_uid()) { DEBUG(4,("%s: ACCESS should be DENIED (requested: %#010x)\n", debug, des_access)); @@ -2199,7 +2200,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ uint32 acc_granted; SEC_DESC *psd; size_t sd_size; - uint32 des_access; + uint32 des_access = GENERIC_RIGHTS_USER_ALL_ACCESS; /* Get the domain SID stored in the domain policy */ if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted)) @@ -2284,25 +2285,50 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ DEBUG(3,("_api_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); } + if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&sam_pass))) { + return nt_status; + } + pw = getpwnam_alloc(account); if (pw) { - if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam_pw(&sam_pass, pw))) { - passwd_free(&pw); - return nt_status; + DOM_SID user_sid; + DOM_SID group_sid; + if (!uid_to_sid(&user_sid, pw->pw_uid)) { + passwd_free(&pw); /* done with this now */ + pdb_free_sam(&sam_pass); + DEBUG(1, ("_api_samr_create_user: uid_to_sid failed, cannot add user.\n")); + return NT_STATUS_ACCESS_DENIED; } + + if (!pdb_set_user_sid(sam_pass, &user_sid, PDB_CHANGED)) { + passwd_free(&pw); /* done with this now */ + pdb_free_sam(&sam_pass); + return NT_STATUS_NO_MEMORY; + } + + if (!gid_to_sid(&group_sid, pw->pw_gid)) { + passwd_free(&pw); /* done with this now */ + pdb_free_sam(&sam_pass); + DEBUG(1, ("_api_samr_create_user: gid_to_sid failed, cannot add user.\n")); + return NT_STATUS_ACCESS_DENIED; + } + + if (!pdb_set_group_sid(sam_pass, &group_sid, PDB_CHANGED)) { + passwd_free(&pw); /* done with this now */ + pdb_free_sam(&sam_pass); + return NT_STATUS_NO_MEMORY; + } + passwd_free(&pw); /* done with this now */ } else { DEBUG(3,("attempting to create non-unix account %s\n", account)); - if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&sam_pass))) { - return nt_status; } if (!pdb_set_username(sam_pass, account, PDB_CHANGED)) { pdb_free_sam(&sam_pass); return NT_STATUS_NO_MEMORY; - } } pdb_set_acct_ctrl(sam_pass, acb_info, PDB_CHANGED); -- cgit From f2c1d6895fc50526b9be9a703a76d15dd79d3185 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 18:38:59 +0000 Subject: Give error message when module doesn't seem to contain pipe functions (This used to be commit 4dd16790436d18f5ac5868538309128e3f8ad1cc) --- source3/rpc_server/srv_pipe.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index d6b774c566..2ab554f122 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -810,6 +810,11 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) break; } } + + if (i == rpc_lookup_size) { + DEBUG(0, ("module %s doesn't provide functions for pipe %s!\m", p->name, p->name)); + return False; + } } /* decode the bind request */ -- cgit From cdfe4b9b85441678067c37e438ed1c29ee5fa1cf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 19:53:02 +0000 Subject: Fix two typos (This used to be commit 898a246c1650326cbd9b8ca49fb93963e589ea1f) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 2ab554f122..5d8b7d39e9 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -812,7 +812,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) } if (i == rpc_lookup_size) { - DEBUG(0, ("module %s doesn't provide functions for pipe %s!\m", p->name, p->name)); + DEBUG(0, ("module %s doesn't provide functions for pipe %s!\n", p->name, p->name)); return False; } } -- cgit From a97a1d5fed2af91ba4d2c5cf2c82140aef98989d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 31 Mar 2003 00:59:58 +0000 Subject: add a few error checks in EnumPrinterData() (This used to be commit 6cd74dea086aa6e0936719f6e2829494c4688ea6) --- source3/rpc_server/srv_spoolss_nt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a7b73b5ac9..0e81fa38d5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7572,7 +7572,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S Printer_entry *Printer = find_printer_index_by_hnd(p, handle); int snum; WERROR result; - REGISTRY_VALUE *val; + REGISTRY_VALUE *val = NULL; NT_PRINTER_DATA *p_data; int i, key_index, num_values; int name_length; @@ -7610,7 +7610,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S * cf: MSDN EnumPrinterData remark section */ - if ( !in_value_len && !in_data_len ) + if ( !in_value_len && !in_data_len && (key_index != -1) ) { DEBUGADD(6,("Activating NT mega-hack to find sizes\n")); @@ -7650,8 +7650,9 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S * the value len is wrong in NT sp3 * that's the number of bytes not the number of unicode chars */ - - val = regval_ctr_specific_value( &p_data->keys[key_index].values, idx ); + + if ( key_index != -1 ) + val = regval_ctr_specific_value( &p_data->keys[key_index].values, idx ); if ( !val ) { -- cgit From 47f230b761f33210beab7f632e8ed1f111959aba Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 31 Mar 2003 01:00:34 +0000 Subject: add a few error checks in EnumPrinterData() (This used to be commit 453813ec6e2c25a3f6a664212aedcad15cfd6000) --- source3/rpc_server/srv_spoolss_nt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 36ff92e46f..99711cbb13 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7572,7 +7572,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S Printer_entry *Printer = find_printer_index_by_hnd(p, handle); int snum; WERROR result; - REGISTRY_VALUE *val; + REGISTRY_VALUE *val = NULL; NT_PRINTER_DATA *p_data; int i, key_index, num_values; int name_length; @@ -7610,7 +7610,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S * cf: MSDN EnumPrinterData remark section */ - if ( !in_value_len && !in_data_len ) + if ( !in_value_len && !in_data_len && (key_index != -1) ) { DEBUGADD(6,("Activating NT mega-hack to find sizes\n")); @@ -7650,8 +7650,9 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S * the value len is wrong in NT sp3 * that's the number of bytes not the number of unicode chars */ - - val = regval_ctr_specific_value( &p_data->keys[key_index].values, idx ); + + if ( key_index != -1 ) + val = regval_ctr_specific_value( &p_data->keys[key_index].values, idx ); if ( !val ) { -- cgit From b5733dd6ef7c006b0ffc0e6a3c58c30a5d12a585 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 31 Mar 2003 17:39:21 +0000 Subject: fix potential smbd crash when we fail to alloacte a policy handle for a printer open; CR 2102 (reviewed by jreilly) (This used to be commit a179c2cefb15b1b8869a83fe5f14a85d1eb96114) --- source3/rpc_server/srv_spoolss_nt.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 99711cbb13..9c9dd438b3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -519,21 +519,22 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3 ZERO_STRUCTP(new_printer); - if ( !(new_printer->ctx = talloc_init("Printer Entry [0x%x]", (uint32)hnd)) ) { - DEBUG(0,("open_printer_hnd: talloc_init() failed!\n")); + if (!create_policy_hnd(p, hnd, free_printer_entry, new_printer)) { + SAFE_FREE(new_printer); return False; } - new_printer->notify.option=NULL; - /* Add to the internal list. */ DLIST_ADD(printers_list, new_printer); - - if (!create_policy_hnd(p, hnd, free_printer_entry, new_printer)) { - SAFE_FREE(new_printer); + + new_printer->notify.option=NULL; + + if ( !(new_printer->ctx = talloc_init("Printer Entry [0x%x]", (uint32)hnd)) ) { + DEBUG(0,("open_printer_hnd: talloc_init() failed!\n")); + close_printer_handle(p, hnd); return False; } - + if (!set_printer_hnd_printertype(new_printer, name)) { close_printer_handle(p, hnd); return False; -- cgit From 4660928c61dd4d61f24fb447e1c71c828a7710b3 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 31 Mar 2003 17:43:45 +0000 Subject: fix potential smbd crash when we fail to alloacte a policy handle for a printer open; CR 2102 (reviewed by jreilly) (This used to be commit 26478158bc03fdf019589ce68062100a39149b52) --- source3/rpc_server/srv_spoolss_nt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0e81fa38d5..4dd4456b2c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -519,18 +519,19 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3 ZERO_STRUCTP(new_printer); - if ( !(new_printer->ctx = talloc_init("Printer Entry [0x%x]", (uint32)hnd)) ) { - DEBUG(0,("open_printer_hnd: talloc_init() failed!\n")); + if (!create_policy_hnd(p, hnd, free_printer_entry, new_printer)) { + SAFE_FREE(new_printer); return False; } - new_printer->notify.option=NULL; - /* Add to the internal list. */ DLIST_ADD(printers_list, new_printer); - if (!create_policy_hnd(p, hnd, free_printer_entry, new_printer)) { - SAFE_FREE(new_printer); + new_printer->notify.option=NULL; + + if ( !(new_printer->ctx = talloc_init("Printer Entry [0x%x]", (uint32)hnd)) ) { + DEBUG(0,("open_printer_hnd: talloc_init() failed!\n")); + close_printer_handle(p, hnd); return False; } -- cgit From 45c7b76da3f738095910ebfe04d2f173000c59e7 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 1 Apr 2003 14:57:59 +0000 Subject: fix potential handle leak in _spoolss_open_printer_ex(); final fix for CR2102; reviewed by jra (This used to be commit 50c25e54ff05bfb01a93e84afd2ad92e90d5a5c2) --- source3/rpc_server/srv_spoolss_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4dd4456b2c..3c309d6e16 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1623,8 +1623,10 @@ Can't find printer handle we created for printer %s\n", name )); /* NT doesn't let us connect to a printer if the connecting user doesn't have print permission. */ - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum)) { + close_printer_handle(p, handle); return WERR_BADFID; + } se_map_standard(&printer_default->access_required, &printer_std_mapping); -- cgit From c5ff6930821faed19640af87a7e285a061175f63 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 1 Apr 2003 14:58:42 +0000 Subject: fix potential handle leak in _spoolss_open_printer_ex(); final fix for CR2102; reviewed by jra (This used to be commit 3d37e1ece913707f346c3c2459c3c42192a3a1a7) --- source3/rpc_server/srv_spoolss_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 9c9dd438b3..c2729001e4 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1623,8 +1623,10 @@ Can't find printer handle we created for printer %s\n", name )); /* NT doesn't let us connect to a printer if the connecting user doesn't have print permission. */ - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum)) { + close_printer_handle(p, handle); return WERR_BADFID; + } se_map_standard(&printer_default->access_required, &printer_std_mapping); -- cgit From f6f96c2966ee3c96cb8188ce832aa822146de337 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 2 Apr 2003 02:26:01 +0000 Subject: Subtle changes to message handling after ENUMJOBS. Jeremy. (This used to be commit 48f3bf0ea51b9fd09dfb017870e32ca4a8cc4b8c) --- source3/rpc_server/srv_spoolss_nt.c | 103 +++++++++++++++++++++++++++++++++--- 1 file changed, 95 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c2729001e4..71d7530410 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1031,9 +1031,10 @@ done: /*********************************************************************** **********************************************************************/ -static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, void *buf, size_t len ) +static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, void *buf, size_t len ) { + uint32 tv_sec, tv_usec; size_t offset = 0; /* Unpack message */ @@ -1041,8 +1042,9 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, void *buf, size_t len ) offset += tdb_unpack((char *)buf + offset, len - offset, "f", msg->printer); - offset += tdb_unpack((char *)buf + offset, len - offset, "ddddd", - &msg->type, &msg->field, &msg->id, &msg->len, &msg->flags); + offset += tdb_unpack((char *)buf + offset, len - offset, "ddddddd", + &tv_sec, &tv_usec, + &msg->type, &msg->field, &msg->id, &msg->len, &msg->flags); if (msg->len == 0) tdb_unpack((char *)buf + offset, len - offset, "dd", @@ -1054,6 +1056,9 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, void *buf, size_t len ) DEBUG(3, ("notify2_unpack_msg: got NOTIFY2 message, type %d, field 0x%02x, flags 0x%04x\n", msg->type, msg->field, msg->flags)); + tv->tv_sec = tv_sec; + tv->tv_usec = tv_usec; + if (msg->len == 0) DEBUG(3, ("notify2_unpack_msg: value1 = %d, value2 = %d\n", msg->notify.value[0], msg->notify.value[1])); @@ -1063,6 +1068,58 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, void *buf, size_t len ) return True; } +/* ENUMJOB last timestamp list. */ +struct ejts_list { + struct ejts_list *next, *prev; + char *printer_name; + struct timeval tv; +}; + +static struct ejts_list *ejts_head; + +static struct ejts_list *find_enumjobs_timestamp(const char *printer_name) +{ + struct ejts_list *ejtsl; + + for( ejtsl = ejts_head; ejtsl; ejtsl = ejtsl->next) + if (strequal(ejtsl->printer_name, printer_name)) + return ejtsl; + return NULL; +} + +static void set_enumjobs_timestamp(int snum) +{ + const char *printer_name = lp_const_servicename(snum); + struct ejts_list *ejtsl = find_enumjobs_timestamp(printer_name); + + if (!ejtsl) { + ejtsl = (struct ejts_list *)malloc(sizeof(struct ejts_list)); + if (!ejtsl) + return; + ejtsl->printer_name = strdup(printer_name); + if (!ejtsl->printer_name) { + SAFE_FREE(ejtsl); + return; + } + DLIST_ADD(ejts_head, ejtsl); + } + + gettimeofday(&ejtsl->tv, NULL); +} + +static int timeval_diff(struct timeval *tv1, struct timeval *tv2) +{ + if (tv1->tv_sec > tv2->tv_sec) + return 1; + if (tv1->tv_sec < tv2->tv_sec) + return -1; + if (tv1->tv_usec > tv2->tv_usec) + return 1; + if (tv1->tv_usec < tv2->tv_usec) + return -1; + return 0; +} + /******************************************************************** Receive a notify2 message list ********************************************************************/ @@ -1104,8 +1161,9 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz * call. Therefore messages are grouped according to printer handle. */ - for ( i=0; i len) { DEBUG(0,("receive_notify2_message_list: bad message format (len > buf_size) !\n")); return; @@ -1122,9 +1180,32 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz /* unpack messages */ ZERO_STRUCT( notify ); - notify2_unpack_msg( ¬ify, msg_ptr, msg_len ); + notify2_unpack_msg( ¬ify, &msg_tv, msg_ptr, msg_len ); msg_ptr += msg_len; + /* See if it is still relevent. */ + if (notify.type == JOB_NOTIFY_TYPE) { + BOOL status_is_deleting = False; + + if (notify.field == JOB_NOTIFY_STATUS && (notify.notify.value[0] & (JOB_STATUS_DELETING|JOB_STATUS_DELETED))) + status_is_deleting = True; + + if (!status_is_deleting) { + struct ejts_list *ejtsl = find_enumjobs_timestamp(notify.printer); + + if (ejtsl && (timeval_diff(&ejtsl->tv, &msg_tv) > 0)) { + + DEBUG(10, ("receive_notify2_message_list: enumjobs ts = %u, %u, msg ts = %u, %u discarding\n", + (unsigned int)ejtsl->tv.tv_sec, (unsigned int)ejtsl->tv.tv_usec, + (unsigned int)msg_tv.tv_sec, (unsigned int)msg_tv.tv_usec )); + + /* Message no longer relevent. Ignore it. */ + if ( notify.len != 0 ) + SAFE_FREE( notify.notify.data ); + continue; + } + } + } /* add to correct list in container */ notify_msg_ctr_addmsg( &messages, ¬ify ); @@ -6352,6 +6433,7 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; + WERROR wret; int snum; print_status_struct prt_status; @@ -6373,15 +6455,20 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); if (*returned == 0) { + set_enumjobs_timestamp(snum); SAFE_FREE(queue); return WERR_OK; } switch (level) { case 1: - return enumjobs_level1(queue, snum, buffer, offered, needed, returned); + wret = enumjobs_level1(queue, snum, buffer, offered, needed, returned); + set_enumjobs_timestamp(snum); + return wret; case 2: - return enumjobs_level2(queue, snum, buffer, offered, needed, returned); + wret = enumjobs_level2(queue, snum, buffer, offered, needed, returned); + set_enumjobs_timestamp(snum); + return wret; default: SAFE_FREE(queue); *returned=0; -- cgit From a9b39993fa366a6f0ab26deafac61947a9e8e1cc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 2 Apr 2003 02:31:51 +0000 Subject: Subtle changes to message handling after ENUMJOBS. Jeremy. (This used to be commit e5e83544dc0acf812bfa5ea17960b5a6be954ca1) --- source3/rpc_server/srv_spoolss_nt.c | 103 +++++++++++++++++++++++++++++++++--- 1 file changed, 95 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3c309d6e16..1c203733b5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1031,9 +1031,10 @@ done: /*********************************************************************** **********************************************************************/ -static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, void *buf, size_t len ) +static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, void *buf, size_t len ) { + uint32 tv_sec, tv_usec; size_t offset = 0; /* Unpack message */ @@ -1041,8 +1042,9 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, void *buf, size_t len ) offset += tdb_unpack((char *)buf + offset, len - offset, "f", msg->printer); - offset += tdb_unpack((char *)buf + offset, len - offset, "ddddd", - &msg->type, &msg->field, &msg->id, &msg->len, &msg->flags); + offset += tdb_unpack((char *)buf + offset, len - offset, "ddddddd", + &tv_sec, &tv_usec, + &msg->type, &msg->field, &msg->id, &msg->len, &msg->flags); if (msg->len == 0) tdb_unpack((char *)buf + offset, len - offset, "dd", @@ -1054,6 +1056,9 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, void *buf, size_t len ) DEBUG(3, ("notify2_unpack_msg: got NOTIFY2 message, type %d, field 0x%02x, flags 0x%04x\n", msg->type, msg->field, msg->flags)); + tv->tv_sec = tv_sec; + tv->tv_usec = tv_usec; + if (msg->len == 0) DEBUG(3, ("notify2_unpack_msg: value1 = %d, value2 = %d\n", msg->notify.value[0], msg->notify.value[1])); @@ -1063,6 +1068,58 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, void *buf, size_t len ) return True; } +/* ENUMJOB last timestamp list. */ +struct ejts_list { + struct ejts_list *next, *prev; + char *printer_name; + struct timeval tv; +}; + +static struct ejts_list *ejts_head; + +static struct ejts_list *find_enumjobs_timestamp(const char *printer_name) +{ + struct ejts_list *ejtsl; + + for( ejtsl = ejts_head; ejtsl; ejtsl = ejtsl->next) + if (strequal(ejtsl->printer_name, printer_name)) + return ejtsl; + return NULL; +} + +static void set_enumjobs_timestamp(int snum) +{ + const char *printer_name = lp_const_servicename(snum); + struct ejts_list *ejtsl = find_enumjobs_timestamp(printer_name); + + if (!ejtsl) { + ejtsl = (struct ejts_list *)malloc(sizeof(struct ejts_list)); + if (!ejtsl) + return; + ejtsl->printer_name = strdup(printer_name); + if (!ejtsl->printer_name) { + SAFE_FREE(ejtsl); + return; + } + DLIST_ADD(ejts_head, ejtsl); + } + + gettimeofday(&ejtsl->tv, NULL); +} + +static int timeval_diff(struct timeval *tv1, struct timeval *tv2) +{ + if (tv1->tv_sec > tv2->tv_sec) + return 1; + if (tv1->tv_sec < tv2->tv_sec) + return -1; + if (tv1->tv_usec > tv2->tv_usec) + return 1; + if (tv1->tv_usec < tv2->tv_usec) + return -1; + return 0; +} + /******************************************************************** Receive a notify2 message list ********************************************************************/ @@ -1104,8 +1161,9 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz * call. Therefore messages are grouped according to printer handle. */ - for ( i=0; i len) { DEBUG(0,("receive_notify2_message_list: bad message format (len > buf_size) !\n")); return; @@ -1122,9 +1180,32 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz /* unpack messages */ ZERO_STRUCT( notify ); - notify2_unpack_msg( ¬ify, msg_ptr, msg_len ); + notify2_unpack_msg( ¬ify, &msg_tv, msg_ptr, msg_len ); msg_ptr += msg_len; + /* See if it is still relevent. */ + if (notify.type == JOB_NOTIFY_TYPE) { + BOOL status_is_deleting = False; + + if (notify.field == JOB_NOTIFY_STATUS && (notify.notify.value[0] & (JOB_STATUS_DELETING|JOB_STATUS_DELETED))) + status_is_deleting = True; + + if (!status_is_deleting) { + struct ejts_list *ejtsl = find_enumjobs_timestamp(notify.printer); + + if (ejtsl && (timeval_diff(&ejtsl->tv, &msg_tv) > 0)) { + + DEBUG(10, ("receive_notify2_message_list: enumjobs ts = %u, %u, msg ts = %u, %u discarding\n", + (unsigned int)ejtsl->tv.tv_sec, (unsigned int)ejtsl->tv.tv_usec, + (unsigned int)msg_tv.tv_sec, (unsigned int)msg_tv.tv_usec )); + + /* Message no longer relevent. Ignore it. */ + if ( notify.len != 0 ) + SAFE_FREE( notify.notify.data ); + continue; + } + } + } /* add to correct list in container */ notify_msg_ctr_addmsg( &messages, ¬ify ); @@ -6352,6 +6433,7 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; + WERROR wret; int snum; print_status_struct prt_status; @@ -6373,15 +6455,20 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); if (*returned == 0) { + set_enumjobs_timestamp(snum); SAFE_FREE(queue); return WERR_OK; } switch (level) { case 1: - return enumjobs_level1(queue, snum, buffer, offered, needed, returned); + wret = enumjobs_level1(queue, snum, buffer, offered, needed, returned); + set_enumjobs_timestamp(snum); + return wret; case 2: - return enumjobs_level2(queue, snum, buffer, offered, needed, returned); + wret = enumjobs_level2(queue, snum, buffer, offered, needed, returned); + set_enumjobs_timestamp(snum); + return wret; default: SAFE_FREE(queue); *returned=0; -- cgit From a557af96e9f232e2fa012850e0725fde353521bd Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 2 Apr 2003 10:36:02 +0000 Subject: THE Idmap patch :-) includes a --with-idmap=no switch to disable idmap usage if you find problems. cosmetic fixes and param aliases to separate winbind from idamp roles. A temporarily remote idmap winbind compatibility backend. As I have time I will further change code to not call directly winbind (partly done but not tested) and a specilized module will be built in place for the current glue hack. The patch has been tested locally in my limited time, the patch is simple and clear and should not reserve problems, if any just disable it. As usual, comments and fisex are welcome :-) Simo. (This used to be commit 02781320476ed1b7ee5d943fa36f9a66ab67f208) --- source3/rpc_server/srv_samr_nt.c | 2 +- source3/rpc_server/srv_util.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7448dc6401..6e1b6f2160 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -915,7 +915,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM struct sys_grent *grp; struct passwd *pw; gid_t winbind_gid_low, winbind_gid_high; - BOOL winbind_groups_exist = lp_winbind_gid(&winbind_gid_low, &winbind_gid_high); + BOOL winbind_groups_exist = lp_idmap_gid(&winbind_gid_low, &winbind_gid_high); /* local aliases */ /* we return the UNIX groups here. This seems to be the right */ diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 4eba9c7d1f..4656efb6fa 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -112,7 +112,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui *prids=NULL; *numgroups=0; - winbind_groups_exist = lp_winbind_gid(&winbind_gid_low, &winbind_gid_high); + winbind_groups_exist = lp_idmap_gid(&winbind_gid_low, &winbind_gid_high); DEBUG(10,("get_alias_user_groups: looking if SID %s is a member of groups in the SID domain %s\n", -- cgit From 02bb4e1b8ae931d9eefa2fbd4a6f5456aca99b2b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 4 Apr 2003 15:21:04 +0000 Subject: This is a merge of the NETLOGON schannel server code from Samba TNG. Actually, it exists in the main Samba cvs tree in APPLIANCE_TNG as I found out later :-) It adds a new parameter: server schannel = yes/auto/no defaulting to auto. What does this mean to the user: No requireSignOrSeal registry patch for XP anymore. Many thanks for this code to Luke Leighton, Elrond and anybody else I forgot to mention. My next thing will be to see if this applies cleanly to 3_0. Please test and comment! Volker (This used to be commit e1f953241eb020f19fe657f29afdae28dcf5a03b) --- source3/rpc_server/srv_netlog_nt.c | 34 ++- source3/rpc_server/srv_pipe.c | 422 ++++++++++++++++++++++++++++++++++--- source3/rpc_server/srv_pipe_hnd.c | 15 +- 3 files changed, 438 insertions(+), 33 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 6182da53d9..76c1d98dab 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -334,6 +334,13 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) srv_time.time = 0; + if ( (lp_server_schannel() == True) && + ((q_u->clnt_flgs.neg_flags & NETLOGON_NEG_SCHANNEL) == 0) ) { + + /* schannel must be used, but client did not offer it. */ + status = NT_STATUS_ACCESS_DENIED; + } + rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring),q_u->clnt_id.uni_acct_name.uni_str_len*2,0); if (p->dc.challenge_sent && get_md4pw((char *)p->dc.md4pw, mach_acct)) { @@ -366,9 +373,18 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) srv_flgs.neg_flags = 0x000001ff; + if (lp_server_schannel() != False) { + srv_flgs.neg_flags |= NETLOGON_NEG_SCHANNEL; + } + /* set up the LSA AUTH 2 response */ init_net_r_auth_2(r_u, &srv_cred, &srv_flgs, status); + if (NT_STATUS_IS_OK(status)) { + extern struct dcinfo last_dcinfo; + last_dcinfo = p->dc; + } + return r_u->status; } @@ -523,7 +539,23 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; - + + + if ( (lp_server_schannel() == True) && (!p->netsec_auth_validated) ) { + /* 'server schannel = yes' should enforce use of + schannel, the client did offer it in auth2, but + obviously did not use it. */ + return NT_STATUS_ACCESS_DENIED; + } + + if (p->netsec_auth_validated) { + /* The client opens a second RPC NETLOGON pipe without + doing a auth2. The session key for the schannel is + re-used from the auth2 the client did before. */ + extern struct dcinfo last_dcinfo; + p->dc = last_dcinfo; + } + /* checks and updates credentials. creates reply credentials */ if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred))) return NT_STATUS_INVALID_HANDLE; diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 5d8b7d39e9..9425ccbe4d 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -43,6 +43,13 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +/************************************************************* + HACK Alert! + We need to transfer the session key from one rpc bind to the + next. This is the way the netlogon schannel works. +**************************************************************/ +struct dcinfo last_dcinfo; + static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) { unsigned char *hash = p->ntlmssp_hash; @@ -115,6 +122,9 @@ BOOL create_next_pdu(pipes_struct *p) if(p->ntlmssp_auth_validated) data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN); + if(p->netsec_auth_validated) + data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NETSEC_CHK_LEN); + /* * The amount we send is the minimum of the available * space and the amount left to send. @@ -148,6 +158,10 @@ BOOL create_next_pdu(pipes_struct *p) p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len + RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN; p->hdr.auth_len = RPC_AUTH_NTLMSSP_CHK_LEN; + } else if (p->netsec_auth_validated) { + p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len + + RPC_HDR_AUTH_LEN + RPC_AUTH_NETSEC_CHK_LEN; + p->hdr.auth_len = RPC_AUTH_NETSEC_CHK_LEN; } else { p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len; p->hdr.auth_len = 0; @@ -192,7 +206,7 @@ BOOL create_next_pdu(pipes_struct *p) return False; } - if (p->hdr.auth_len > 0) { + if (p->ntlmssp_auth_validated) { uint32 crc32 = 0; char *data; @@ -239,6 +253,47 @@ BOOL create_next_pdu(pipes_struct *p) } } + if (p->netsec_auth_validated) { + char *data; + RPC_HDR_AUTH auth_info; + static const uchar netsec_sig[8] = NETSEC_SIGNATURE; + static const uchar nullbytes[8] = { 0,0,0,0,0,0,0,0 }; + + RPC_AUTH_NETSEC_CHK verf; + prs_struct rverf; + prs_struct rauth; + + uchar sign[8]; + + data = prs_data_p(&outgoing_pdu) + data_pos; + + init_rpc_hdr_auth(&auth_info, NETSEC_AUTH_TYPE, NETSEC_AUTH_LEVEL, + RPC_HDR_AUTH_LEN, 1); + + if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_AUTH.\n")); + prs_mem_free(&outgoing_pdu); + return False; + } + + prs_init(&rverf, 0, p->mem_ctx, MARSHALL); + prs_init(&rauth, 0, p->mem_ctx, MARSHALL); + + memset(sign, 0, sizeof(sign)); + sign[3] = 0x01; + + init_rpc_auth_netsec_chk(&verf, netsec_sig, nullbytes, sign, nullbytes); + + if (!netsec_encode(&p->netsec_auth, &verf, data, data_len)) { + DEBUG(0,("create_next_pdu: failed encode data.\n")); + prs_mem_free(&outgoing_pdu); + return False; + } + + smb_io_rpc_auth_netsec_chk("", &verf, &outgoing_pdu, 0); + p->netsec_auth.seq_num++; + } + /* * Setup the counts for this PDU. */ @@ -775,6 +830,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) enum RPC_PKT_TYPE reply_pkt_type; p->ntlmssp_auth_requested = False; + p->netsec_auth_validated = False; DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); @@ -840,39 +896,62 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) return False; } - /* - * We only support NTLMSSP_AUTH_TYPE requests. - */ + if(auth_info.auth_type == NTLMSSP_AUTH_TYPE) { - if(auth_info.auth_type != NTLMSSP_AUTH_TYPE) { - DEBUG(0,("api_pipe_bind_req: unknown auth type %x requested.\n", - auth_info.auth_type )); - return False; - } + if(!smb_io_rpc_auth_verifier("", &auth_verifier, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to " + "unmarshall RPC_HDR_AUTH struct.\n")); + return False; + } - if(!smb_io_rpc_auth_verifier("", &auth_verifier, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); - return False; - } + if(!strequal(auth_verifier.signature, "NTLMSSP")) { + DEBUG(0,("api_pipe_bind_req: " + "auth_verifier.signature != NTLMSSP\n")); + return False; + } - if(!strequal(auth_verifier.signature, "NTLMSSP")) { - DEBUG(0,("api_pipe_bind_req: auth_verifier.signature != NTLMSSP\n")); - return False; - } + if(auth_verifier.msg_type != NTLMSSP_NEGOTIATE) { + DEBUG(0,("api_pipe_bind_req: " + "auth_verifier.msg_type (%d) != NTLMSSP_NEGOTIATE\n", + auth_verifier.msg_type)); + return False; + } - if(auth_verifier.msg_type != NTLMSSP_NEGOTIATE) { - DEBUG(0,("api_pipe_bind_req: auth_verifier.msg_type (%d) != NTLMSSP_NEGOTIATE\n", - auth_verifier.msg_type)); - return False; - } + if(!smb_io_rpc_auth_ntlmssp_neg("", &ntlmssp_neg, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: " + "Failed to unmarshall RPC_AUTH_NTLMSSP_NEG.\n")); + return False; + } + + p->ntlmssp_chal_flags = SMBD_NTLMSSP_NEG_FLAGS; + p->ntlmssp_auth_requested = True; + + } else if (auth_info.auth_type == NETSEC_AUTH_TYPE) { + + RPC_AUTH_NETSEC_NEG neg; + struct netsec_auth_struct *a = &(p->netsec_auth); + + if (!smb_io_rpc_auth_netsec_neg("", &neg, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: " + "Could not unmarshal SCHANNEL auth neg\n")); + return False; + } - if(!smb_io_rpc_auth_ntlmssp_neg("", &ntlmssp_neg, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_req: Failed to unmarshall RPC_AUTH_NTLMSSP_NEG.\n")); + p->netsec_auth_validated = True; + + memset(a->sess_key, 0, sizeof(a->sess_key)); + memcpy(a->sess_key, last_dcinfo.sess_key, sizeof(last_dcinfo.sess_key)); + + a->seq_num = 0; + + DEBUG(10,("schannel auth: domain [%s] myname [%s]\n", + neg.domain, neg.myname)); + + } else { + DEBUG(0,("api_pipe_bind_req: unknown auth type %x requested.\n", + auth_info.auth_type )); return False; } - - p->ntlmssp_chal_flags = SMBD_NTLMSSP_NEG_FLAGS; - p->ntlmssp_auth_requested = True; } switch(p->hdr.pkt_type) { @@ -1003,6 +1082,33 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) auth_len = prs_offset(&out_auth) - RPC_HDR_AUTH_LEN; } + if (p->netsec_auth_validated) { + RPC_AUTH_VERIFIER auth_verifier; + uint32 flags; + + init_rpc_hdr_auth(&auth_info, NETSEC_AUTH_TYPE, NETSEC_AUTH_LEVEL, RPC_HDR_AUTH_LEN, 1); + if(!smb_io_rpc_hdr_auth("", &auth_info, &out_auth, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_AUTH failed.\n")); + goto err_exit; + } + + /*** NETSEC verifier ***/ + + init_rpc_auth_verifier(&auth_verifier, "\001", 0x0); + if(!smb_io_rpc_netsec_verifier("", &auth_verifier, &out_auth, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_VERIFIER failed.\n")); + goto err_exit; + } + + prs_align(&out_auth); + + flags = 5; + if(!prs_uint32("flags ", &out_auth, 0, &flags)) + goto err_exit; + + auth_len = prs_offset(&out_auth) - RPC_HDR_AUTH_LEN; + } + /* * Create the header, now we know the length. */ @@ -1030,7 +1136,8 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) goto err_exit; } - if(p->ntlmssp_auth_requested && !prs_append_prs_data( &outgoing_rpc, &out_auth)) { + if((p->ntlmssp_auth_requested|p->netsec_auth_validated) && + !prs_append_prs_data( &outgoing_rpc, &out_auth)) { DEBUG(0,("api_pipe_bind_req: append of auth info failed.\n")); goto err_exit; } @@ -1162,6 +1269,265 @@ BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) return True; } +static void netsechash(uchar * key, uchar * data, int data_len) +{ + uchar hash[256]; + uchar index_i = 0; + uchar index_j = 0; + uchar j = 0; + int ind; + + for (ind = 0; ind < 256; ind++) + { + hash[ind] = (uchar) ind; + } + + for (ind = 0; ind < 256; ind++) + { + uchar tc; + + j += (hash[ind] + key[ind % 16]); + + tc = hash[ind]; + hash[ind] = hash[j]; + hash[j] = tc; + } + + for (ind = 0; ind < data_len; ind++) + { + uchar tc; + uchar t; + + index_i++; + index_j += hash[index_i]; + + tc = hash[index_i]; + hash[index_i] = hash[index_j]; + hash[index_j] = tc; + + t = hash[index_i] + hash[index_j]; + data[ind] ^= hash[t]; + } +} + +void dump_data_pw(const char *msg, const uchar * data, size_t len) +{ +#ifdef DEBUG_PASSWORD + DEBUG(11, ("%s", msg)); + if (data != NULL && len > 0) + { + dump_data(11, data, len); + } +#endif +} + +BOOL netsec_encode(struct netsec_auth_struct *a, + RPC_AUTH_NETSEC_CHK * verf, char *data, size_t data_len) +{ + uchar dataN[4]; + uchar digest1[16]; + struct MD5Context ctx3; + uchar sess_kf0[16]; + int i; + + /* store the sequence number */ + SIVAL(dataN, 0, a->seq_num); + + for (i = 0; i < sizeof(sess_kf0); i++) + { + sess_kf0[i] = a->sess_key[i] ^ 0xf0; + } + + dump_data_pw("a->sess_key:\n", a->sess_key, sizeof(a->sess_key)); + dump_data_pw("a->seq_num :\n", dataN, sizeof(dataN)); + + MD5Init(&ctx3); + MD5Update(&ctx3, dataN, 0x4); + MD5Update(&ctx3, verf->sig, 8); + + MD5Update(&ctx3, verf->data8, 8); + + dump_data_pw("verf->data8:\n", verf->data8, sizeof(verf->data8)); + dump_data_pw("sess_kf0:\n", sess_kf0, sizeof(sess_kf0)); + + hmac_md5(sess_kf0, dataN, 0x4, digest1); + dump_data_pw("digest1 (ebp-8):\n", digest1, sizeof(digest1)); + hmac_md5(digest1, verf->data3, 8, digest1); + dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); + netsechash(digest1, verf->data8, 8); + + dump_data_pw("verf->data8:\n", verf->data8, sizeof(verf->data8)); + + dump_data_pw("data :\n", data, data_len); + MD5Update(&ctx3, data, data_len); + + { + char digest_tmp[16]; + char digest2[16]; + MD5Final(digest_tmp, &ctx3); + hmac_md5(a->sess_key, digest_tmp, 16, digest2); + dump_data_pw("digest_tmp:\n", digest_tmp, sizeof(digest_tmp)); + dump_data_pw("digest:\n", digest2, sizeof(digest2)); + memcpy(verf->data1, digest2, sizeof(verf->data1)); + } + + netsechash(digest1, data, data_len); + dump_data_pw("data:\n", data, data_len); + + hmac_md5(a->sess_key, dataN, 0x4, digest1); + dump_data_pw("ctx:\n", digest1, sizeof(digest1)); + + hmac_md5(digest1, verf->data1, 8, digest1); + + dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); + + dump_data_pw("verf->data3:\n", verf->data3, sizeof(verf->data3)); + netsechash(digest1, verf->data3, 8); + dump_data_pw("verf->data3:\n", verf->data3, sizeof(verf->data3)); + + return True; +} + +BOOL netsec_decode(struct netsec_auth_struct *a, + RPC_AUTH_NETSEC_CHK * verf, char *data, size_t data_len) +{ + uchar dataN[4]; + uchar digest1[16]; + struct MD5Context ctx3; + uchar sess_kf0[16]; + int i; + + /* store the sequence number */ + SIVAL(dataN, 0, a->seq_num); + + for (i = 0; i < sizeof(sess_kf0); i++) + { + sess_kf0[i] = a->sess_key[i] ^ 0xf0; + } + + dump_data_pw("a->sess_key:\n", a->sess_key, sizeof(a->sess_key)); + dump_data_pw("a->seq_num :\n", dataN, sizeof(dataN)); + hmac_md5(a->sess_key, dataN, 0x4, digest1); + dump_data_pw("ctx:\n", digest1, sizeof(digest1)); + + hmac_md5(digest1, verf->data1, 8, digest1); + + dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); + dump_data_pw("verf->data3:\n", verf->data3, sizeof(verf->data3)); + netsechash(digest1, verf->data3, 8); + dump_data_pw("verf->data3_dec:\n", verf->data3, sizeof(verf->data3)); + + MD5Init(&ctx3); + MD5Update(&ctx3, dataN, 0x4); + MD5Update(&ctx3, verf->sig, 8); + + dump_data_pw("sess_kf0:\n", sess_kf0, sizeof(sess_kf0)); + + hmac_md5(sess_kf0, dataN, 0x4, digest1); + dump_data_pw("digest1 (ebp-8):\n", digest1, sizeof(digest1)); + hmac_md5(digest1, verf->data3, 8, digest1); + dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); + + dump_data_pw("verf->data8:\n", verf->data8, sizeof(verf->data8)); + netsechash(digest1, verf->data8, 8); + dump_data_pw("verf->data8_dec:\n", verf->data8, sizeof(verf->data8)); + MD5Update(&ctx3, verf->data8, 8); + + dump_data_pw("data :\n", data, data_len); + netsechash(digest1, data, data_len); + dump_data_pw("datadec:\n", data, data_len); + + MD5Update(&ctx3, data, data_len); + { + uchar digest_tmp[16]; + MD5Final(digest_tmp, &ctx3); + hmac_md5(a->sess_key, digest_tmp, 16, digest1); + dump_data_pw("digest_tmp:\n", digest_tmp, sizeof(digest_tmp)); + } + + dump_data_pw("digest:\n", digest1, sizeof(digest1)); + dump_data_pw("verf->data1:\n", verf->data1, sizeof(verf->data1)); + + return memcmp(digest1, verf->data1, sizeof(verf->data1)) == 0; +} + +/**************************************************************************** + Deal with schannel processing on an RPC request. +****************************************************************************/ +BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) +{ + /* + * We always negotiate the following two bits.... + */ + int data_len; + int auth_len; + uint32 old_offset; + RPC_HDR_AUTH auth_info; + RPC_AUTH_NETSEC_CHK netsec_chk; + + + auth_len = p->hdr.auth_len; + + if (auth_len != RPC_AUTH_NETSEC_CHK_LEN) { + DEBUG(0,("Incorrect auth_len %d.\n", auth_len )); + return False; + } + + /* + * The following is that length of the data we must verify or unseal. + * This doesn't include the RPC headers or the auth_len or the RPC_HDR_AUTH_LEN + * preceeding the auth_data. + */ + + data_len = p->hdr.frag_len - RPC_HEADER_LEN - RPC_HDR_REQ_LEN - + RPC_HDR_AUTH_LEN - auth_len; + + DEBUG(5,("data %d auth %d\n", data_len, auth_len)); + + old_offset = prs_offset(rpc_in); + + if(!prs_set_offset(rpc_in, old_offset + data_len)) { + DEBUG(0,("cannot move offset to %u.\n", + (unsigned int)old_offset + data_len )); + return False; + } + + if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, rpc_in, 0)) { + DEBUG(0,("failed to unmarshall RPC_HDR_AUTH.\n")); + return False; + } + + if ((auth_info.auth_type != NETSEC_AUTH_TYPE) || + (auth_info.auth_level != NETSEC_AUTH_LEVEL)) { + DEBUG(0,("Invalid auth info %d or level %d on schannel\n", + auth_info.auth_type, auth_info.auth_level)); + return False; + } + + if(!smb_io_rpc_auth_netsec_chk("", &netsec_chk, rpc_in, 0)) { + DEBUG(0,("failed to unmarshal RPC_AUTH_NETSEC_CHK.\n")); + return False; + } + + if (!netsec_decode(&p->netsec_auth, &netsec_chk, + prs_data_p(rpc_in)+old_offset, data_len)) { + DEBUG(0,("failed to decode PDU\n")); + return False; + } + + /* + * Return the current pointer to the data offset. + */ + + if(!prs_set_offset(rpc_in, old_offset)) { + DEBUG(0,("failed to set offset back to %u\n", + (unsigned int)old_offset )); + return False; + } + + return True; +} + /**************************************************************************** Return a user struct for a pipe user. ****************************************************************************/ diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 8cb81b9c6d..125f603771 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -594,11 +594,18 @@ static BOOL process_request_pdu(pipes_struct *p, prs_struct *rpc_in_p) * Authentication _was_ requested and it already failed. */ - DEBUG(0,("process_request_pdu: RPC request received on pipe %s where \ -authentication failed. Denying the request.\n", p->name)); + DEBUG(0,("process_request_pdu: RPC request received on pipe %s " + "where authentication failed. Denying the request.\n", + p->name)); set_incoming_fault(p); - return False; - } + return False; + } + + if (p->netsec_auth_validated && !api_pipe_netsec_process(p, rpc_in_p)) { + DEBUG(0,("process_request_pdu: failed to do schannel processing.\n")); + set_incoming_fault(p); + return False; + } /* * Check the data length doesn't go over the 15Mb limit. -- cgit From b4d0f208fb936382c7b313bd94c180b5cb708cea Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 6 Apr 2003 07:04:09 +0000 Subject: Merge the TNG netlogon schannel from HEAD. No more XP requiresignorseal anymore! Thanks again to Luke :-) Volker (This used to be commit 6b2b55901d66cab0c0c0c90bd0585c870be6e468) --- source3/rpc_server/srv_netlog_nt.c | 34 ++- source3/rpc_server/srv_pipe.c | 422 ++++++++++++++++++++++++++++++++++--- source3/rpc_server/srv_pipe_hnd.c | 15 +- 3 files changed, 438 insertions(+), 33 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 6182da53d9..76c1d98dab 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -334,6 +334,13 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) srv_time.time = 0; + if ( (lp_server_schannel() == True) && + ((q_u->clnt_flgs.neg_flags & NETLOGON_NEG_SCHANNEL) == 0) ) { + + /* schannel must be used, but client did not offer it. */ + status = NT_STATUS_ACCESS_DENIED; + } + rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring),q_u->clnt_id.uni_acct_name.uni_str_len*2,0); if (p->dc.challenge_sent && get_md4pw((char *)p->dc.md4pw, mach_acct)) { @@ -366,9 +373,18 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) srv_flgs.neg_flags = 0x000001ff; + if (lp_server_schannel() != False) { + srv_flgs.neg_flags |= NETLOGON_NEG_SCHANNEL; + } + /* set up the LSA AUTH 2 response */ init_net_r_auth_2(r_u, &srv_cred, &srv_flgs, status); + if (NT_STATUS_IS_OK(status)) { + extern struct dcinfo last_dcinfo; + last_dcinfo = p->dc; + } + return r_u->status; } @@ -523,7 +539,23 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; - + + + if ( (lp_server_schannel() == True) && (!p->netsec_auth_validated) ) { + /* 'server schannel = yes' should enforce use of + schannel, the client did offer it in auth2, but + obviously did not use it. */ + return NT_STATUS_ACCESS_DENIED; + } + + if (p->netsec_auth_validated) { + /* The client opens a second RPC NETLOGON pipe without + doing a auth2. The session key for the schannel is + re-used from the auth2 the client did before. */ + extern struct dcinfo last_dcinfo; + p->dc = last_dcinfo; + } + /* checks and updates credentials. creates reply credentials */ if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred))) return NT_STATUS_INVALID_HANDLE; diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 588d6644b1..af3f1549a0 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -43,6 +43,13 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +/************************************************************* + HACK Alert! + We need to transfer the session key from one rpc bind to the + next. This is the way the netlogon schannel works. +**************************************************************/ +struct dcinfo last_dcinfo; + static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) { unsigned char *hash = p->ntlmssp_hash; @@ -115,6 +122,9 @@ BOOL create_next_pdu(pipes_struct *p) if(p->ntlmssp_auth_validated) data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN); + if(p->netsec_auth_validated) + data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NETSEC_CHK_LEN); + /* * The amount we send is the minimum of the available * space and the amount left to send. @@ -148,6 +158,10 @@ BOOL create_next_pdu(pipes_struct *p) p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len + RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN; p->hdr.auth_len = RPC_AUTH_NTLMSSP_CHK_LEN; + } else if (p->netsec_auth_validated) { + p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len + + RPC_HDR_AUTH_LEN + RPC_AUTH_NETSEC_CHK_LEN; + p->hdr.auth_len = RPC_AUTH_NETSEC_CHK_LEN; } else { p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len; p->hdr.auth_len = 0; @@ -192,7 +206,7 @@ BOOL create_next_pdu(pipes_struct *p) return False; } - if (p->hdr.auth_len > 0) { + if (p->ntlmssp_auth_validated) { uint32 crc32 = 0; char *data; @@ -239,6 +253,47 @@ BOOL create_next_pdu(pipes_struct *p) } } + if (p->netsec_auth_validated) { + char *data; + RPC_HDR_AUTH auth_info; + static const uchar netsec_sig[8] = NETSEC_SIGNATURE; + static const uchar nullbytes[8] = { 0,0,0,0,0,0,0,0 }; + + RPC_AUTH_NETSEC_CHK verf; + prs_struct rverf; + prs_struct rauth; + + uchar sign[8]; + + data = prs_data_p(&outgoing_pdu) + data_pos; + + init_rpc_hdr_auth(&auth_info, NETSEC_AUTH_TYPE, NETSEC_AUTH_LEVEL, + RPC_HDR_AUTH_LEN, 1); + + if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_AUTH.\n")); + prs_mem_free(&outgoing_pdu); + return False; + } + + prs_init(&rverf, 0, p->mem_ctx, MARSHALL); + prs_init(&rauth, 0, p->mem_ctx, MARSHALL); + + memset(sign, 0, sizeof(sign)); + sign[3] = 0x01; + + init_rpc_auth_netsec_chk(&verf, netsec_sig, nullbytes, sign, nullbytes); + + if (!netsec_encode(&p->netsec_auth, &verf, data, data_len)) { + DEBUG(0,("create_next_pdu: failed encode data.\n")); + prs_mem_free(&outgoing_pdu); + return False; + } + + smb_io_rpc_auth_netsec_chk("", &verf, &outgoing_pdu, 0); + p->netsec_auth.seq_num++; + } + /* * Setup the counts for this PDU. */ @@ -851,6 +906,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) enum RPC_PKT_TYPE reply_pkt_type; p->ntlmssp_auth_requested = False; + p->netsec_auth_validated = False; DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); @@ -918,39 +974,62 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) return False; } - /* - * We only support NTLMSSP_AUTH_TYPE requests. - */ + if(auth_info.auth_type == NTLMSSP_AUTH_TYPE) { - if(auth_info.auth_type != NTLMSSP_AUTH_TYPE) { - DEBUG(0,("api_pipe_bind_req: unknown auth type %x requested.\n", - auth_info.auth_type )); - return False; - } + if(!smb_io_rpc_auth_verifier("", &auth_verifier, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to " + "unmarshall RPC_HDR_AUTH struct.\n")); + return False; + } - if(!smb_io_rpc_auth_verifier("", &auth_verifier, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); - return False; - } + if(!strequal(auth_verifier.signature, "NTLMSSP")) { + DEBUG(0,("api_pipe_bind_req: " + "auth_verifier.signature != NTLMSSP\n")); + return False; + } - if(!strequal(auth_verifier.signature, "NTLMSSP")) { - DEBUG(0,("api_pipe_bind_req: auth_verifier.signature != NTLMSSP\n")); - return False; - } + if(auth_verifier.msg_type != NTLMSSP_NEGOTIATE) { + DEBUG(0,("api_pipe_bind_req: " + "auth_verifier.msg_type (%d) != NTLMSSP_NEGOTIATE\n", + auth_verifier.msg_type)); + return False; + } - if(auth_verifier.msg_type != NTLMSSP_NEGOTIATE) { - DEBUG(0,("api_pipe_bind_req: auth_verifier.msg_type (%d) != NTLMSSP_NEGOTIATE\n", - auth_verifier.msg_type)); - return False; - } + if(!smb_io_rpc_auth_ntlmssp_neg("", &ntlmssp_neg, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: " + "Failed to unmarshall RPC_AUTH_NTLMSSP_NEG.\n")); + return False; + } + + p->ntlmssp_chal_flags = SMBD_NTLMSSP_NEG_FLAGS; + p->ntlmssp_auth_requested = True; + + } else if (auth_info.auth_type == NETSEC_AUTH_TYPE) { + + RPC_AUTH_NETSEC_NEG neg; + struct netsec_auth_struct *a = &(p->netsec_auth); + + if (!smb_io_rpc_auth_netsec_neg("", &neg, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: " + "Could not unmarshal SCHANNEL auth neg\n")); + return False; + } - if(!smb_io_rpc_auth_ntlmssp_neg("", &ntlmssp_neg, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_req: Failed to unmarshall RPC_AUTH_NTLMSSP_NEG.\n")); + p->netsec_auth_validated = True; + + memset(a->sess_key, 0, sizeof(a->sess_key)); + memcpy(a->sess_key, last_dcinfo.sess_key, sizeof(last_dcinfo.sess_key)); + + a->seq_num = 0; + + DEBUG(10,("schannel auth: domain [%s] myname [%s]\n", + neg.domain, neg.myname)); + + } else { + DEBUG(0,("api_pipe_bind_req: unknown auth type %x requested.\n", + auth_info.auth_type )); return False; } - - p->ntlmssp_chal_flags = SMBD_NTLMSSP_NEG_FLAGS; - p->ntlmssp_auth_requested = True; } switch(p->hdr.pkt_type) { @@ -1081,6 +1160,33 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) auth_len = prs_offset(&out_auth) - RPC_HDR_AUTH_LEN; } + if (p->netsec_auth_validated) { + RPC_AUTH_VERIFIER auth_verifier; + uint32 flags; + + init_rpc_hdr_auth(&auth_info, NETSEC_AUTH_TYPE, NETSEC_AUTH_LEVEL, RPC_HDR_AUTH_LEN, 1); + if(!smb_io_rpc_hdr_auth("", &auth_info, &out_auth, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_AUTH failed.\n")); + goto err_exit; + } + + /*** NETSEC verifier ***/ + + init_rpc_auth_verifier(&auth_verifier, "\001", 0x0); + if(!smb_io_rpc_netsec_verifier("", &auth_verifier, &out_auth, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_VERIFIER failed.\n")); + goto err_exit; + } + + prs_align(&out_auth); + + flags = 5; + if(!prs_uint32("flags ", &out_auth, 0, &flags)) + goto err_exit; + + auth_len = prs_offset(&out_auth) - RPC_HDR_AUTH_LEN; + } + /* * Create the header, now we know the length. */ @@ -1108,7 +1214,8 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) goto err_exit; } - if(p->ntlmssp_auth_requested && !prs_append_prs_data( &outgoing_rpc, &out_auth)) { + if((p->ntlmssp_auth_requested|p->netsec_auth_validated) && + !prs_append_prs_data( &outgoing_rpc, &out_auth)) { DEBUG(0,("api_pipe_bind_req: append of auth info failed.\n")); goto err_exit; } @@ -1240,6 +1347,265 @@ BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) return True; } +static void netsechash(uchar * key, uchar * data, int data_len) +{ + uchar hash[256]; + uchar index_i = 0; + uchar index_j = 0; + uchar j = 0; + int ind; + + for (ind = 0; ind < 256; ind++) + { + hash[ind] = (uchar) ind; + } + + for (ind = 0; ind < 256; ind++) + { + uchar tc; + + j += (hash[ind] + key[ind % 16]); + + tc = hash[ind]; + hash[ind] = hash[j]; + hash[j] = tc; + } + + for (ind = 0; ind < data_len; ind++) + { + uchar tc; + uchar t; + + index_i++; + index_j += hash[index_i]; + + tc = hash[index_i]; + hash[index_i] = hash[index_j]; + hash[index_j] = tc; + + t = hash[index_i] + hash[index_j]; + data[ind] ^= hash[t]; + } +} + +void dump_data_pw(const char *msg, const uchar * data, size_t len) +{ +#ifdef DEBUG_PASSWORD + DEBUG(11, ("%s", msg)); + if (data != NULL && len > 0) + { + dump_data(11, data, len); + } +#endif +} + +BOOL netsec_encode(struct netsec_auth_struct *a, + RPC_AUTH_NETSEC_CHK * verf, char *data, size_t data_len) +{ + uchar dataN[4]; + uchar digest1[16]; + struct MD5Context ctx3; + uchar sess_kf0[16]; + int i; + + /* store the sequence number */ + SIVAL(dataN, 0, a->seq_num); + + for (i = 0; i < sizeof(sess_kf0); i++) + { + sess_kf0[i] = a->sess_key[i] ^ 0xf0; + } + + dump_data_pw("a->sess_key:\n", a->sess_key, sizeof(a->sess_key)); + dump_data_pw("a->seq_num :\n", dataN, sizeof(dataN)); + + MD5Init(&ctx3); + MD5Update(&ctx3, dataN, 0x4); + MD5Update(&ctx3, verf->sig, 8); + + MD5Update(&ctx3, verf->data8, 8); + + dump_data_pw("verf->data8:\n", verf->data8, sizeof(verf->data8)); + dump_data_pw("sess_kf0:\n", sess_kf0, sizeof(sess_kf0)); + + hmac_md5(sess_kf0, dataN, 0x4, digest1); + dump_data_pw("digest1 (ebp-8):\n", digest1, sizeof(digest1)); + hmac_md5(digest1, verf->data3, 8, digest1); + dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); + netsechash(digest1, verf->data8, 8); + + dump_data_pw("verf->data8:\n", verf->data8, sizeof(verf->data8)); + + dump_data_pw("data :\n", data, data_len); + MD5Update(&ctx3, data, data_len); + + { + char digest_tmp[16]; + char digest2[16]; + MD5Final(digest_tmp, &ctx3); + hmac_md5(a->sess_key, digest_tmp, 16, digest2); + dump_data_pw("digest_tmp:\n", digest_tmp, sizeof(digest_tmp)); + dump_data_pw("digest:\n", digest2, sizeof(digest2)); + memcpy(verf->data1, digest2, sizeof(verf->data1)); + } + + netsechash(digest1, data, data_len); + dump_data_pw("data:\n", data, data_len); + + hmac_md5(a->sess_key, dataN, 0x4, digest1); + dump_data_pw("ctx:\n", digest1, sizeof(digest1)); + + hmac_md5(digest1, verf->data1, 8, digest1); + + dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); + + dump_data_pw("verf->data3:\n", verf->data3, sizeof(verf->data3)); + netsechash(digest1, verf->data3, 8); + dump_data_pw("verf->data3:\n", verf->data3, sizeof(verf->data3)); + + return True; +} + +BOOL netsec_decode(struct netsec_auth_struct *a, + RPC_AUTH_NETSEC_CHK * verf, char *data, size_t data_len) +{ + uchar dataN[4]; + uchar digest1[16]; + struct MD5Context ctx3; + uchar sess_kf0[16]; + int i; + + /* store the sequence number */ + SIVAL(dataN, 0, a->seq_num); + + for (i = 0; i < sizeof(sess_kf0); i++) + { + sess_kf0[i] = a->sess_key[i] ^ 0xf0; + } + + dump_data_pw("a->sess_key:\n", a->sess_key, sizeof(a->sess_key)); + dump_data_pw("a->seq_num :\n", dataN, sizeof(dataN)); + hmac_md5(a->sess_key, dataN, 0x4, digest1); + dump_data_pw("ctx:\n", digest1, sizeof(digest1)); + + hmac_md5(digest1, verf->data1, 8, digest1); + + dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); + dump_data_pw("verf->data3:\n", verf->data3, sizeof(verf->data3)); + netsechash(digest1, verf->data3, 8); + dump_data_pw("verf->data3_dec:\n", verf->data3, sizeof(verf->data3)); + + MD5Init(&ctx3); + MD5Update(&ctx3, dataN, 0x4); + MD5Update(&ctx3, verf->sig, 8); + + dump_data_pw("sess_kf0:\n", sess_kf0, sizeof(sess_kf0)); + + hmac_md5(sess_kf0, dataN, 0x4, digest1); + dump_data_pw("digest1 (ebp-8):\n", digest1, sizeof(digest1)); + hmac_md5(digest1, verf->data3, 8, digest1); + dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); + + dump_data_pw("verf->data8:\n", verf->data8, sizeof(verf->data8)); + netsechash(digest1, verf->data8, 8); + dump_data_pw("verf->data8_dec:\n", verf->data8, sizeof(verf->data8)); + MD5Update(&ctx3, verf->data8, 8); + + dump_data_pw("data :\n", data, data_len); + netsechash(digest1, data, data_len); + dump_data_pw("datadec:\n", data, data_len); + + MD5Update(&ctx3, data, data_len); + { + uchar digest_tmp[16]; + MD5Final(digest_tmp, &ctx3); + hmac_md5(a->sess_key, digest_tmp, 16, digest1); + dump_data_pw("digest_tmp:\n", digest_tmp, sizeof(digest_tmp)); + } + + dump_data_pw("digest:\n", digest1, sizeof(digest1)); + dump_data_pw("verf->data1:\n", verf->data1, sizeof(verf->data1)); + + return memcmp(digest1, verf->data1, sizeof(verf->data1)) == 0; +} + +/**************************************************************************** + Deal with schannel processing on an RPC request. +****************************************************************************/ +BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) +{ + /* + * We always negotiate the following two bits.... + */ + int data_len; + int auth_len; + uint32 old_offset; + RPC_HDR_AUTH auth_info; + RPC_AUTH_NETSEC_CHK netsec_chk; + + + auth_len = p->hdr.auth_len; + + if (auth_len != RPC_AUTH_NETSEC_CHK_LEN) { + DEBUG(0,("Incorrect auth_len %d.\n", auth_len )); + return False; + } + + /* + * The following is that length of the data we must verify or unseal. + * This doesn't include the RPC headers or the auth_len or the RPC_HDR_AUTH_LEN + * preceeding the auth_data. + */ + + data_len = p->hdr.frag_len - RPC_HEADER_LEN - RPC_HDR_REQ_LEN - + RPC_HDR_AUTH_LEN - auth_len; + + DEBUG(5,("data %d auth %d\n", data_len, auth_len)); + + old_offset = prs_offset(rpc_in); + + if(!prs_set_offset(rpc_in, old_offset + data_len)) { + DEBUG(0,("cannot move offset to %u.\n", + (unsigned int)old_offset + data_len )); + return False; + } + + if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, rpc_in, 0)) { + DEBUG(0,("failed to unmarshall RPC_HDR_AUTH.\n")); + return False; + } + + if ((auth_info.auth_type != NETSEC_AUTH_TYPE) || + (auth_info.auth_level != NETSEC_AUTH_LEVEL)) { + DEBUG(0,("Invalid auth info %d or level %d on schannel\n", + auth_info.auth_type, auth_info.auth_level)); + return False; + } + + if(!smb_io_rpc_auth_netsec_chk("", &netsec_chk, rpc_in, 0)) { + DEBUG(0,("failed to unmarshal RPC_AUTH_NETSEC_CHK.\n")); + return False; + } + + if (!netsec_decode(&p->netsec_auth, &netsec_chk, + prs_data_p(rpc_in)+old_offset, data_len)) { + DEBUG(0,("failed to decode PDU\n")); + return False; + } + + /* + * Return the current pointer to the data offset. + */ + + if(!prs_set_offset(rpc_in, old_offset)) { + DEBUG(0,("failed to set offset back to %u\n", + (unsigned int)old_offset )); + return False; + } + + return True; +} + /**************************************************************************** Return a user struct for a pipe user. ****************************************************************************/ diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 8cb81b9c6d..125f603771 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -594,11 +594,18 @@ static BOOL process_request_pdu(pipes_struct *p, prs_struct *rpc_in_p) * Authentication _was_ requested and it already failed. */ - DEBUG(0,("process_request_pdu: RPC request received on pipe %s where \ -authentication failed. Denying the request.\n", p->name)); + DEBUG(0,("process_request_pdu: RPC request received on pipe %s " + "where authentication failed. Denying the request.\n", + p->name)); set_incoming_fault(p); - return False; - } + return False; + } + + if (p->netsec_auth_validated && !api_pipe_netsec_process(p, rpc_in_p)) { + DEBUG(0,("process_request_pdu: failed to do schannel processing.\n")); + set_incoming_fault(p); + return False; + } /* * Check the data length doesn't go over the 15Mb limit. -- cgit From b4f1061cca33d66a0e473cb6631b1373bca338ac Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 8 Apr 2003 14:06:27 +0000 Subject: fixup extra SAFE_FREE()'s noticed by abartlet (This used to be commit 51d330dcf3bd74367fc18f4229a9cfa0392f0b36) --- source3/rpc_server/srv_spoolss_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1c203733b5..fd837cd9fb 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8414,7 +8414,6 @@ static WERROR getjob_level_1(print_queue_struct *queue, int count, int snum, uin info_1=(JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1)); if (info_1 == NULL) { - SAFE_FREE(queue); return WERR_NOMEM; } @@ -8424,7 +8423,6 @@ static WERROR getjob_level_1(print_queue_struct *queue, int count, int snum, uin } if (found==False) { - SAFE_FREE(queue); SAFE_FREE(info_1); /* NT treats not found as bad param... yet another bad choice */ return WERR_INVALID_PARAM; -- cgit From ff8d6da5a3e799ccad32add6cc2c79014c79a7ba Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 9 Apr 2003 04:38:56 +0000 Subject: forgotten merge left on disk; remove extra SAFE_FREE() (This used to be commit 4d42067cb89220a1b275bc8408c9c1ba2ef7766a) --- source3/rpc_server/srv_spoolss_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 71d7530410..fec9de8990 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8414,7 +8414,6 @@ static WERROR getjob_level_1(print_queue_struct *queue, int count, int snum, uin info_1=(JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1)); if (info_1 == NULL) { - SAFE_FREE(queue); return WERR_NOMEM; } @@ -8424,7 +8423,6 @@ static WERROR getjob_level_1(print_queue_struct *queue, int count, int snum, uin } if (found==False) { - SAFE_FREE(queue); SAFE_FREE(info_1); /* NT treats not found as bad param... yet another bad choice */ return WERR_INVALID_PARAM; -- cgit From c618a8dae43cc45cf8686dd4235435c30b689dcd Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 9 Apr 2003 05:30:48 +0000 Subject: another forgotten merge sitting on my laptop from app_head; only stall open_printer when 2k client opens with admin privs & fix reply for ChangeId printer data reply (This used to be commit 12eb3e993788eb8bc0e9eb62e60a8b55079df5ad) --- source3/rpc_server/srv_spoolss_nt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index fd837cd9fb..3d2b73d571 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1768,8 +1768,11 @@ Can't find printer handle we created for printer %s\n", name )); /* HACK ALERT!!! Sleep for 1/3 of a second to try trigger a LAN/WAN optimization in Windows 2000 clients --jerry */ - if ( RA_WIN2K == get_remote_arch() ) - usleep( 384000 ); + if ( (printer_default->access_required == PRINTER_ACCESS_ADMINISTER) + && (RA_WIN2K == get_remote_arch()) ) + { + usleep( 500000 ); + } return WERR_OK; } @@ -2463,7 +2466,7 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO status = WERR_NOMEM; goto done; } - **data = printer->info_2->changeid; + SIVAL( *data, 0, printer->info_2->changeid ); status = WERR_OK; } else -- cgit From 1c2e2ba39ea03bec900db58a90803df95a91c73f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 9 Apr 2003 06:02:56 +0000 Subject: another forgotten merge sitting on my laptop from app_head; only stall open_printer when 2k client opens with admin privs & fix reply for ChangeId printer data reply (This used to be commit c7c3d42cd5954b040ee7027886ea8d9d0f2da9a5) --- source3/rpc_server/srv_spoolss_nt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index fec9de8990..9f943f036a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1768,8 +1768,11 @@ Can't find printer handle we created for printer %s\n", name )); /* HACK ALERT!!! Sleep for 1/3 of a second to try trigger a LAN/WAN optimization in Windows 2000 clients --jerry */ - if ( RA_WIN2K == get_remote_arch() ) - usleep( 384000 ); + if ( (printer_default->access_required == PRINTER_ACCESS_ADMINISTER) + && (RA_WIN2K == get_remote_arch()) ) + { + usleep( 500000 ); + } return WERR_OK; } @@ -2463,7 +2466,7 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO status = WERR_NOMEM; goto done; } - **data = printer->info_2->changeid; + SIVAL( *data, 0, printer->info_2->changeid ); status = WERR_OK; } else -- cgit From 425797700b24c14c252389c2ff6cf3b569d7ee22 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 9 Apr 2003 09:29:47 +0000 Subject: Put the core schannel functions to parse_prs.c. They are also used by schannel clients. Volker (This used to be commit 41e92409e1c6912db05acc80b6c0d5dccd51859b) --- source3/rpc_server/srv_pipe.c | 189 +----------------------------------------- 1 file changed, 2 insertions(+), 187 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 9425ccbe4d..43fbb4edaa 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -284,13 +284,10 @@ BOOL create_next_pdu(pipes_struct *p) init_rpc_auth_netsec_chk(&verf, netsec_sig, nullbytes, sign, nullbytes); - if (!netsec_encode(&p->netsec_auth, &verf, data, data_len)) { - DEBUG(0,("create_next_pdu: failed encode data.\n")); - prs_mem_free(&outgoing_pdu); - return False; - } + netsec_encode(&p->netsec_auth, &verf, data, data_len); smb_io_rpc_auth_netsec_chk("", &verf, &outgoing_pdu, 0); + p->netsec_auth.seq_num++; } @@ -1269,188 +1266,6 @@ BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) return True; } -static void netsechash(uchar * key, uchar * data, int data_len) -{ - uchar hash[256]; - uchar index_i = 0; - uchar index_j = 0; - uchar j = 0; - int ind; - - for (ind = 0; ind < 256; ind++) - { - hash[ind] = (uchar) ind; - } - - for (ind = 0; ind < 256; ind++) - { - uchar tc; - - j += (hash[ind] + key[ind % 16]); - - tc = hash[ind]; - hash[ind] = hash[j]; - hash[j] = tc; - } - - for (ind = 0; ind < data_len; ind++) - { - uchar tc; - uchar t; - - index_i++; - index_j += hash[index_i]; - - tc = hash[index_i]; - hash[index_i] = hash[index_j]; - hash[index_j] = tc; - - t = hash[index_i] + hash[index_j]; - data[ind] ^= hash[t]; - } -} - -void dump_data_pw(const char *msg, const uchar * data, size_t len) -{ -#ifdef DEBUG_PASSWORD - DEBUG(11, ("%s", msg)); - if (data != NULL && len > 0) - { - dump_data(11, data, len); - } -#endif -} - -BOOL netsec_encode(struct netsec_auth_struct *a, - RPC_AUTH_NETSEC_CHK * verf, char *data, size_t data_len) -{ - uchar dataN[4]; - uchar digest1[16]; - struct MD5Context ctx3; - uchar sess_kf0[16]; - int i; - - /* store the sequence number */ - SIVAL(dataN, 0, a->seq_num); - - for (i = 0; i < sizeof(sess_kf0); i++) - { - sess_kf0[i] = a->sess_key[i] ^ 0xf0; - } - - dump_data_pw("a->sess_key:\n", a->sess_key, sizeof(a->sess_key)); - dump_data_pw("a->seq_num :\n", dataN, sizeof(dataN)); - - MD5Init(&ctx3); - MD5Update(&ctx3, dataN, 0x4); - MD5Update(&ctx3, verf->sig, 8); - - MD5Update(&ctx3, verf->data8, 8); - - dump_data_pw("verf->data8:\n", verf->data8, sizeof(verf->data8)); - dump_data_pw("sess_kf0:\n", sess_kf0, sizeof(sess_kf0)); - - hmac_md5(sess_kf0, dataN, 0x4, digest1); - dump_data_pw("digest1 (ebp-8):\n", digest1, sizeof(digest1)); - hmac_md5(digest1, verf->data3, 8, digest1); - dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); - netsechash(digest1, verf->data8, 8); - - dump_data_pw("verf->data8:\n", verf->data8, sizeof(verf->data8)); - - dump_data_pw("data :\n", data, data_len); - MD5Update(&ctx3, data, data_len); - - { - char digest_tmp[16]; - char digest2[16]; - MD5Final(digest_tmp, &ctx3); - hmac_md5(a->sess_key, digest_tmp, 16, digest2); - dump_data_pw("digest_tmp:\n", digest_tmp, sizeof(digest_tmp)); - dump_data_pw("digest:\n", digest2, sizeof(digest2)); - memcpy(verf->data1, digest2, sizeof(verf->data1)); - } - - netsechash(digest1, data, data_len); - dump_data_pw("data:\n", data, data_len); - - hmac_md5(a->sess_key, dataN, 0x4, digest1); - dump_data_pw("ctx:\n", digest1, sizeof(digest1)); - - hmac_md5(digest1, verf->data1, 8, digest1); - - dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); - - dump_data_pw("verf->data3:\n", verf->data3, sizeof(verf->data3)); - netsechash(digest1, verf->data3, 8); - dump_data_pw("verf->data3:\n", verf->data3, sizeof(verf->data3)); - - return True; -} - -BOOL netsec_decode(struct netsec_auth_struct *a, - RPC_AUTH_NETSEC_CHK * verf, char *data, size_t data_len) -{ - uchar dataN[4]; - uchar digest1[16]; - struct MD5Context ctx3; - uchar sess_kf0[16]; - int i; - - /* store the sequence number */ - SIVAL(dataN, 0, a->seq_num); - - for (i = 0; i < sizeof(sess_kf0); i++) - { - sess_kf0[i] = a->sess_key[i] ^ 0xf0; - } - - dump_data_pw("a->sess_key:\n", a->sess_key, sizeof(a->sess_key)); - dump_data_pw("a->seq_num :\n", dataN, sizeof(dataN)); - hmac_md5(a->sess_key, dataN, 0x4, digest1); - dump_data_pw("ctx:\n", digest1, sizeof(digest1)); - - hmac_md5(digest1, verf->data1, 8, digest1); - - dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); - dump_data_pw("verf->data3:\n", verf->data3, sizeof(verf->data3)); - netsechash(digest1, verf->data3, 8); - dump_data_pw("verf->data3_dec:\n", verf->data3, sizeof(verf->data3)); - - MD5Init(&ctx3); - MD5Update(&ctx3, dataN, 0x4); - MD5Update(&ctx3, verf->sig, 8); - - dump_data_pw("sess_kf0:\n", sess_kf0, sizeof(sess_kf0)); - - hmac_md5(sess_kf0, dataN, 0x4, digest1); - dump_data_pw("digest1 (ebp-8):\n", digest1, sizeof(digest1)); - hmac_md5(digest1, verf->data3, 8, digest1); - dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); - - dump_data_pw("verf->data8:\n", verf->data8, sizeof(verf->data8)); - netsechash(digest1, verf->data8, 8); - dump_data_pw("verf->data8_dec:\n", verf->data8, sizeof(verf->data8)); - MD5Update(&ctx3, verf->data8, 8); - - dump_data_pw("data :\n", data, data_len); - netsechash(digest1, data, data_len); - dump_data_pw("datadec:\n", data, data_len); - - MD5Update(&ctx3, data, data_len); - { - uchar digest_tmp[16]; - MD5Final(digest_tmp, &ctx3); - hmac_md5(a->sess_key, digest_tmp, 16, digest1); - dump_data_pw("digest_tmp:\n", digest_tmp, sizeof(digest_tmp)); - } - - dump_data_pw("digest:\n", digest1, sizeof(digest1)); - dump_data_pw("verf->data1:\n", verf->data1, sizeof(verf->data1)); - - return memcmp(digest1, verf->data1, sizeof(verf->data1)) == 0; -} - /**************************************************************************** Deal with schannel processing on an RPC request. ****************************************************************************/ -- cgit From d3b8ac6f96889c3dc9137a6b24f351e8df9c23cb Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 9 Apr 2003 09:31:29 +0000 Subject: Put the core schannel functions to parse_prs.c. They are also used by schannel clients. Volker (This used to be commit 0f348a35d09ff020837119157ef7f4b9e6f07643) --- source3/rpc_server/srv_pipe.c | 189 +----------------------------------------- 1 file changed, 2 insertions(+), 187 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index af3f1549a0..80275e6070 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -284,13 +284,10 @@ BOOL create_next_pdu(pipes_struct *p) init_rpc_auth_netsec_chk(&verf, netsec_sig, nullbytes, sign, nullbytes); - if (!netsec_encode(&p->netsec_auth, &verf, data, data_len)) { - DEBUG(0,("create_next_pdu: failed encode data.\n")); - prs_mem_free(&outgoing_pdu); - return False; - } + netsec_encode(&p->netsec_auth, &verf, data, data_len); smb_io_rpc_auth_netsec_chk("", &verf, &outgoing_pdu, 0); + p->netsec_auth.seq_num++; } @@ -1347,188 +1344,6 @@ BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) return True; } -static void netsechash(uchar * key, uchar * data, int data_len) -{ - uchar hash[256]; - uchar index_i = 0; - uchar index_j = 0; - uchar j = 0; - int ind; - - for (ind = 0; ind < 256; ind++) - { - hash[ind] = (uchar) ind; - } - - for (ind = 0; ind < 256; ind++) - { - uchar tc; - - j += (hash[ind] + key[ind % 16]); - - tc = hash[ind]; - hash[ind] = hash[j]; - hash[j] = tc; - } - - for (ind = 0; ind < data_len; ind++) - { - uchar tc; - uchar t; - - index_i++; - index_j += hash[index_i]; - - tc = hash[index_i]; - hash[index_i] = hash[index_j]; - hash[index_j] = tc; - - t = hash[index_i] + hash[index_j]; - data[ind] ^= hash[t]; - } -} - -void dump_data_pw(const char *msg, const uchar * data, size_t len) -{ -#ifdef DEBUG_PASSWORD - DEBUG(11, ("%s", msg)); - if (data != NULL && len > 0) - { - dump_data(11, data, len); - } -#endif -} - -BOOL netsec_encode(struct netsec_auth_struct *a, - RPC_AUTH_NETSEC_CHK * verf, char *data, size_t data_len) -{ - uchar dataN[4]; - uchar digest1[16]; - struct MD5Context ctx3; - uchar sess_kf0[16]; - int i; - - /* store the sequence number */ - SIVAL(dataN, 0, a->seq_num); - - for (i = 0; i < sizeof(sess_kf0); i++) - { - sess_kf0[i] = a->sess_key[i] ^ 0xf0; - } - - dump_data_pw("a->sess_key:\n", a->sess_key, sizeof(a->sess_key)); - dump_data_pw("a->seq_num :\n", dataN, sizeof(dataN)); - - MD5Init(&ctx3); - MD5Update(&ctx3, dataN, 0x4); - MD5Update(&ctx3, verf->sig, 8); - - MD5Update(&ctx3, verf->data8, 8); - - dump_data_pw("verf->data8:\n", verf->data8, sizeof(verf->data8)); - dump_data_pw("sess_kf0:\n", sess_kf0, sizeof(sess_kf0)); - - hmac_md5(sess_kf0, dataN, 0x4, digest1); - dump_data_pw("digest1 (ebp-8):\n", digest1, sizeof(digest1)); - hmac_md5(digest1, verf->data3, 8, digest1); - dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); - netsechash(digest1, verf->data8, 8); - - dump_data_pw("verf->data8:\n", verf->data8, sizeof(verf->data8)); - - dump_data_pw("data :\n", data, data_len); - MD5Update(&ctx3, data, data_len); - - { - char digest_tmp[16]; - char digest2[16]; - MD5Final(digest_tmp, &ctx3); - hmac_md5(a->sess_key, digest_tmp, 16, digest2); - dump_data_pw("digest_tmp:\n", digest_tmp, sizeof(digest_tmp)); - dump_data_pw("digest:\n", digest2, sizeof(digest2)); - memcpy(verf->data1, digest2, sizeof(verf->data1)); - } - - netsechash(digest1, data, data_len); - dump_data_pw("data:\n", data, data_len); - - hmac_md5(a->sess_key, dataN, 0x4, digest1); - dump_data_pw("ctx:\n", digest1, sizeof(digest1)); - - hmac_md5(digest1, verf->data1, 8, digest1); - - dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); - - dump_data_pw("verf->data3:\n", verf->data3, sizeof(verf->data3)); - netsechash(digest1, verf->data3, 8); - dump_data_pw("verf->data3:\n", verf->data3, sizeof(verf->data3)); - - return True; -} - -BOOL netsec_decode(struct netsec_auth_struct *a, - RPC_AUTH_NETSEC_CHK * verf, char *data, size_t data_len) -{ - uchar dataN[4]; - uchar digest1[16]; - struct MD5Context ctx3; - uchar sess_kf0[16]; - int i; - - /* store the sequence number */ - SIVAL(dataN, 0, a->seq_num); - - for (i = 0; i < sizeof(sess_kf0); i++) - { - sess_kf0[i] = a->sess_key[i] ^ 0xf0; - } - - dump_data_pw("a->sess_key:\n", a->sess_key, sizeof(a->sess_key)); - dump_data_pw("a->seq_num :\n", dataN, sizeof(dataN)); - hmac_md5(a->sess_key, dataN, 0x4, digest1); - dump_data_pw("ctx:\n", digest1, sizeof(digest1)); - - hmac_md5(digest1, verf->data1, 8, digest1); - - dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); - dump_data_pw("verf->data3:\n", verf->data3, sizeof(verf->data3)); - netsechash(digest1, verf->data3, 8); - dump_data_pw("verf->data3_dec:\n", verf->data3, sizeof(verf->data3)); - - MD5Init(&ctx3); - MD5Update(&ctx3, dataN, 0x4); - MD5Update(&ctx3, verf->sig, 8); - - dump_data_pw("sess_kf0:\n", sess_kf0, sizeof(sess_kf0)); - - hmac_md5(sess_kf0, dataN, 0x4, digest1); - dump_data_pw("digest1 (ebp-8):\n", digest1, sizeof(digest1)); - hmac_md5(digest1, verf->data3, 8, digest1); - dump_data_pw("netsechashkey:\n", digest1, sizeof(digest1)); - - dump_data_pw("verf->data8:\n", verf->data8, sizeof(verf->data8)); - netsechash(digest1, verf->data8, 8); - dump_data_pw("verf->data8_dec:\n", verf->data8, sizeof(verf->data8)); - MD5Update(&ctx3, verf->data8, 8); - - dump_data_pw("data :\n", data, data_len); - netsechash(digest1, data, data_len); - dump_data_pw("datadec:\n", data, data_len); - - MD5Update(&ctx3, data, data_len); - { - uchar digest_tmp[16]; - MD5Final(digest_tmp, &ctx3); - hmac_md5(a->sess_key, digest_tmp, 16, digest1); - dump_data_pw("digest_tmp:\n", digest_tmp, sizeof(digest_tmp)); - } - - dump_data_pw("digest:\n", digest1, sizeof(digest1)); - dump_data_pw("verf->data1:\n", verf->data1, sizeof(verf->data1)); - - return memcmp(digest1, verf->data1, sizeof(verf->data1)) == 0; -} - /**************************************************************************** Deal with schannel processing on an RPC request. ****************************************************************************/ -- cgit From ac65d890703c85fe69e2c577061087b8da2a4a93 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 10 Apr 2003 18:43:00 +0000 Subject: Ensure we're not filtering our essential delete messages. Added jobid debug when unpacking message. Jeremy. (This used to be commit 8bab6e32069e1636a52efa31ca55b49f1b3fa768) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 9f943f036a..c4ae894296 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1053,8 +1053,8 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, voi tdb_unpack((char *)buf + offset, len - offset, "B", &msg->len, &msg->notify.data); - DEBUG(3, ("notify2_unpack_msg: got NOTIFY2 message, type %d, field 0x%02x, flags 0x%04x\n", - msg->type, msg->field, msg->flags)); + DEBUG(3, ("notify2_unpack_msg: got NOTIFY2 message for printer %s, jobid %u type %d, field 0x%02x, flags 0x%04x\n", + msg->printer, (unsigned int)msg->id, msg->type, msg->field, msg->flags)); tv->tv_sec = tv_sec; tv->tv_usec = tv_usec; -- cgit From 7c735eabc9c8277a13fd47bdb18b264e225672d1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 10 Apr 2003 18:43:13 +0000 Subject: Ensure we're not filtering our essential delete messages. Added jobid debug when unpacking message. Jeremy. (This used to be commit 8a6f3313e69c6d47e20838f42ebc9f8a2ce9ddc4) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3d2b73d571..62884fbdf4 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1053,8 +1053,8 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, voi tdb_unpack((char *)buf + offset, len - offset, "B", &msg->len, &msg->notify.data); - DEBUG(3, ("notify2_unpack_msg: got NOTIFY2 message, type %d, field 0x%02x, flags 0x%04x\n", - msg->type, msg->field, msg->flags)); + DEBUG(3, ("notify2_unpack_msg: got NOTIFY2 message for printer %s, jobid %u type %d, field 0x%02x, flags 0x%04x\n", + msg->printer, (unsigned int)msg->id, msg->type, msg->field, msg->flags)); tv->tv_sec = tv_sec; tv->tv_usec = tv_usec; -- cgit From 065561932c660be13f80fefa2a310a51b0c07f9c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 11 Apr 2003 04:09:14 +0000 Subject: A new RPC pipe! The \pipe\echo named pipe is for testing large RPC requests and responses and is only compiled in when --enable-developer is passed to configure. It includes server and client side code for generating and responding to functions on this pipe. The functions are: - AddOne: add one to the uint32 argument and return ig - EchoData: echo back a variable sized char array to the caller - SourceData: request a variable sized char array - SinkData: send a variable sized char array and throw it away There's a win32 implementation of the client and server in the junkcode CVS repository in the rpcecho-win32 subdirectory. (This used to be commit 4ccd34ef836eba05f81dc2da73fd7cfaac201798) --- source3/rpc_server/srv_echo.c | 137 +++++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_echo_nt.c | 78 ++++++++++++++++++++++ 2 files changed, 215 insertions(+) create mode 100644 source3/rpc_server/srv_echo.c create mode 100644 source3/rpc_server/srv_echo_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_echo.c b/source3/rpc_server/srv_echo.c new file mode 100644 index 0000000000..dcd8dd0c53 --- /dev/null +++ b/source3/rpc_server/srv_echo.c @@ -0,0 +1,137 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines for rpcecho + * Copyright (C) Tim Potter 2003. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* This is the interface to the rpcecho pipe. */ + +#include "includes.h" +#include "nterr.h" + +#ifdef DEVELOPER + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +static BOOL api_add_one(pipes_struct *p) +{ + ECHO_Q_ADD_ONE q_u; + ECHO_R_ADD_ONE r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!echo_io_q_add_one("", &q_u, data, 0)) + return False; + + _echo_add_one(p, &q_u, &r_u); + + if(!echo_io_r_add_one("", &r_u, rdata, 0)) + return False; + + return True; +} + +static BOOL api_echo_data(pipes_struct *p) +{ + ECHO_Q_ECHO_DATA q_u; + ECHO_R_ECHO_DATA r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!echo_io_q_echo_data("", &q_u, data, 0)) + return False; + + _echo_data(p, &q_u, &r_u); + + if(!echo_io_r_echo_data("", &r_u, rdata, 0)) + return False; + + return True; +} + +static BOOL api_source_data(pipes_struct *p) +{ + ECHO_Q_SOURCE_DATA q_u; + ECHO_R_SOURCE_DATA r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!echo_io_q_source_data("", &q_u, data, 0)) + return False; + + _source_data(p, &q_u, &r_u); + + if(!echo_io_r_source_data("", &r_u, rdata, 0)) + return False; + + return True; +} + +static BOOL api_sink_data(pipes_struct *p) +{ + ECHO_Q_SINK_DATA q_u; + ECHO_R_SINK_DATA r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!echo_io_q_sink_data("", &q_u, data, 0)) + return False; + + _sink_data(p, &q_u, &r_u); + + if(!echo_io_r_sink_data("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* +\pipe\rpcecho commands +********************************************************************/ + +int rpc_echo_init(void) +{ + struct api_struct api_echo_cmds[] = { + {"ADD_ONE", ECHO_ADD_ONE, api_add_one }, + {"ECHO_DATA", ECHO_DATA, api_echo_data }, + {"SOURCE_DATA", ECHO_SOURCE_DATA, api_source_data }, + {"SINK_DATA", ECHO_SINK_DATA, api_sink_data }, + }; + + return rpc_pipe_register_commands( + "rpcecho", "rpcecho", api_echo_cmds, + sizeof(api_echo_cmds) / sizeof(struct api_struct)); +} + +#endif /* DEVELOPER */ diff --git a/source3/rpc_server/srv_echo_nt.c b/source3/rpc_server/srv_echo_nt.c new file mode 100644 index 0000000000..ddb76b3a21 --- /dev/null +++ b/source3/rpc_server/srv_echo_nt.c @@ -0,0 +1,78 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines for rpcecho + * Copyright (C) Tim Potter 2003. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* This is the interface to the rpcecho pipe. */ + +#include "includes.h" +#include "nterr.h" + +#ifdef DEVELOPER + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +/* Add one to the input and return it */ + +void _echo_add_one(pipes_struct *p, ECHO_Q_ADD_ONE *q_u, ECHO_R_ADD_ONE *r_u) +{ + DEBUG(10, ("_echo_add_one\n")); + + r_u->response = q_u->request + 1; +} + +/* Echo back an array of data */ + +void _echo_data(pipes_struct *p, ECHO_Q_ECHO_DATA *q_u, + ECHO_R_ECHO_DATA *r_u) +{ + DEBUG(10, ("_echo_data\n")); + + r_u->data = talloc(p->mem_ctx, q_u->size); + r_u->size = q_u->size; + memcpy(r_u->data, q_u->data, q_u->size); +} + +/* Sink an array of data */ + +void _sink_data(pipes_struct *p, ECHO_Q_SINK_DATA *q_u, + ECHO_R_SINK_DATA *r_u) +{ + DEBUG(10, ("_sink_data\n")); + + /* My that was some yummy data! */ +} + +/* Source an array of data */ + +void _source_data(pipes_struct *p, ECHO_Q_SOURCE_DATA *q_u, + ECHO_R_SOURCE_DATA *r_u) +{ + uint32 i; + + DEBUG(10, ("_source_data\n")); + + r_u->data = talloc(p->mem_ctx, q_u->size); + r_u->size = q_u->size; + + for (i = 0; i < r_u->size; i++) + r_u->data[i] = i & 0xff; +} + +#endif /* DEVELOPER */ -- cgit From 84b4b3caf1a59d9206e351fef0aa42fcaba1e346 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 11 Apr 2003 20:29:36 +0000 Subject: simple fix to hopefully speed up srv_spoolss_replyopenprinter(). Use the client address from the pipe->conn->client_address instead of trying to resolve the name in the _spoolss_rffpcn() request. Should make us more robust as well when the clients are not registered in DNS or WINS. (This used to be commit 23f0fcf6421b1e8dd6ed6ab14af14ea7eb380c1c) --- source3/rpc_server/srv_spoolss_nt.c | 58 +++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 22 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 62884fbdf4..90090efde8 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2507,34 +2507,43 @@ done: Connect to the client machine. **********************************************************/ -static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *remote_machine) +static BOOL spoolss_connect_to_client(struct cli_state *the_cli, + struct in_addr *client_ip, const char *remote_machine) { ZERO_STRUCTP(the_cli); + if(cli_initialise(the_cli) == NULL) { - DEBUG(0,("connect_to_client: unable to initialize client connection.\n")); + DEBUG(0,("spoolss_connect_to_client: unable to initialize client connection.\n")); return False; } + + if ( is_zero_ip(*client_ip) ) { + if(!resolve_name( remote_machine, &the_cli->dest_ip, 0x20)) { + DEBUG(0,("spoolss_connect_to_client: Can't resolve address for %s\n", remote_machine)); + cli_shutdown(the_cli); + return False; + } - if(!resolve_name( remote_machine, &the_cli->dest_ip, 0x20)) { - DEBUG(0,("connect_to_client: Can't resolve address for %s\n", remote_machine)); - cli_shutdown(the_cli); - return False; + if (ismyip(the_cli->dest_ip)) { + DEBUG(0,("spoolss_connect_to_client: Machine %s is one of our addresses. Cannot add to ourselves.\n", remote_machine)); + cli_shutdown(the_cli); + return False; + } } - - if (ismyip(the_cli->dest_ip)) { - DEBUG(0,("connect_to_client: Machine %s is one of our addresses. Cannot add to ourselves.\n", remote_machine)); - cli_shutdown(the_cli); - return False; + else { + the_cli->dest_ip.s_addr = client_ip->s_addr; + DEBUG(5,("spoolss_connect_to_client: Using address %s (no name resolution necessary)\n", + inet_ntoa(*client_ip) )); } if (!cli_connect(the_cli, remote_machine, &the_cli->dest_ip)) { - DEBUG(0,("connect_to_client: unable to connect to SMB server on machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + DEBUG(0,("spoolss_connect_to_client: unable to connect to SMB server on machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); cli_shutdown(the_cli); return False; } if (!attempt_netbios_session_request(the_cli, global_myname(), remote_machine, &the_cli->dest_ip)) { - DEBUG(0,("connect_to_client: machine %s rejected the NetBIOS session request.\n", + DEBUG(0,("spoolss_connect_to_client: machine %s rejected the NetBIOS session request.\n", remote_machine)); cli_shutdown(the_cli); return False; @@ -2543,13 +2552,13 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *rem the_cli->protocol = PROTOCOL_NT1; if (!cli_negprot(the_cli)) { - DEBUG(0,("connect_to_client: machine %s rejected the negotiate protocol. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + DEBUG(0,("spoolss_connect_to_client: machine %s rejected the negotiate protocol. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); cli_shutdown(the_cli); return False; } if (the_cli->protocol != PROTOCOL_NT1) { - DEBUG(0,("connect_to_client: machine %s didn't negotiate NT protocol.\n", remote_machine)); + DEBUG(0,("spoolss_connect_to_client: machine %s didn't negotiate NT protocol.\n", remote_machine)); cli_shutdown(the_cli); return False; } @@ -2559,19 +2568,19 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *rem */ if (!cli_session_setup(the_cli, "", "", 0, "", 0, "")) { - DEBUG(0,("connect_to_client: machine %s rejected the session setup. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + DEBUG(0,("spoolss_connect_to_client: machine %s rejected the session setup. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); cli_shutdown(the_cli); return False; } if (!(the_cli->sec_mode & 1)) { - DEBUG(0,("connect_to_client: machine %s isn't in user level security mode\n", remote_machine)); + DEBUG(0,("spoolss_connect_to_client: machine %s isn't in user level security mode\n", remote_machine)); cli_shutdown(the_cli); return False; } if (!cli_send_tconX(the_cli, "IPC$", "IPC", "", 1)) { - DEBUG(0,("connect_to_client: machine %s rejected the tconX on the IPC$ share. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + DEBUG(0,("spoolss_connect_to_client: machine %s rejected the tconX on the IPC$ share. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); cli_shutdown(the_cli); return False; } @@ -2582,7 +2591,7 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *rem */ if(cli_nt_session_open(the_cli, PI_SPOOLSS) == False) { - DEBUG(0,("connect_to_client: unable to open the domain client session to machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli))); + DEBUG(0,("spoolss_connect_to_client: unable to open the domain client session to machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli))); cli_nt_session_close(the_cli); cli_ulogoff(the_cli); cli_shutdown(the_cli); @@ -2596,7 +2605,9 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *rem Connect to the client. ****************************************************************************/ -static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle) +static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, + uint32 localprinter, uint32 type, + POLICY_HND *handle, struct in_addr *client_ip) { WERROR result; @@ -2609,7 +2620,7 @@ static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, uint32 l fstrcpy(unix_printer, printer+2); /* the +2 is to strip the leading 2 backslashs */ - if(!spoolss_connect_to_client(¬ify_cli, unix_printer)) + if(!spoolss_connect_to_client(¬ify_cli, client_ip, unix_printer)) return False; message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message_list); @@ -2658,6 +2669,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE uint32 printerlocal = q_u->printerlocal; int snum = -1; SPOOL_NOTIFY_OPTION *option = q_u->option; + struct in_addr client_ip; /* store the notify value in the printer struct */ @@ -2687,10 +2699,12 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE else if ( (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && !get_printer_snum(p, handle, &snum) ) return WERR_BADFID; + + client_ip.s_addr = inet_addr(p->conn->client_address); if(!srv_spoolss_replyopenprinter(snum, Printer->notify.localmachine, Printer->notify.printerlocal, 1, - &Printer->notify.client_hnd)) + &Printer->notify.client_hnd, &client_ip)) return WERR_SERVER_UNAVAILABLE; Printer->notify.client_connected=True; -- cgit From 70231290eac4e3d9c034daaf44fb64947d9f1bee Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 11 Apr 2003 20:32:54 +0000 Subject: simple fix to hopefully speed up srv_spoolss_replyopenprinter(). Use the client address from the pipe->conn->client_address instead of trying to resolve the name in the _spoolss_rffpcn() request. Should make us more robust as well when the clients are not registered in DNS or WINS. (This used to be commit 78b2c1be7d9923716841627044c4e1578a5b9546) --- source3/rpc_server/srv_spoolss_nt.c | 58 +++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 22 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c4ae894296..424d7909d1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2507,34 +2507,43 @@ done: Connect to the client machine. **********************************************************/ -static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *remote_machine) +static BOOL spoolss_connect_to_client(struct cli_state *the_cli, + struct in_addr *client_ip, const char *remote_machine) { ZERO_STRUCTP(the_cli); + if(cli_initialise(the_cli) == NULL) { - DEBUG(0,("connect_to_client: unable to initialize client connection.\n")); + DEBUG(0,("spoolss_connect_to_client: unable to initialize client connection.\n")); return False; } + + if ( is_zero_ip(*client_ip) ) { + if(!resolve_name( remote_machine, &the_cli->dest_ip, 0x20)) { + DEBUG(0,("spoolss_connect_to_client: Can't resolve address for %s\n", remote_machine)); + cli_shutdown(the_cli); + return False; + } - if(!resolve_name( remote_machine, &the_cli->dest_ip, 0x20)) { - DEBUG(0,("connect_to_client: Can't resolve address for %s\n", remote_machine)); - cli_shutdown(the_cli); - return False; + if (ismyip(the_cli->dest_ip)) { + DEBUG(0,("spoolss_connect_to_client: Machine %s is one of our addresses. Cannot add to ourselves.\n", remote_machine)); + cli_shutdown(the_cli); + return False; + } } - - if (ismyip(the_cli->dest_ip)) { - DEBUG(0,("connect_to_client: Machine %s is one of our addresses. Cannot add to ourselves.\n", remote_machine)); - cli_shutdown(the_cli); - return False; + else { + the_cli->dest_ip.s_addr = client_ip->s_addr; + DEBUG(5,("spoolss_connect_to_client: Using address %s (no name resolution necessary)\n", + inet_ntoa(*client_ip) )); } if (!cli_connect(the_cli, remote_machine, &the_cli->dest_ip)) { - DEBUG(0,("connect_to_client: unable to connect to SMB server on machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + DEBUG(0,("spoolss_connect_to_client: unable to connect to SMB server on machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); cli_shutdown(the_cli); return False; } if (!attempt_netbios_session_request(the_cli, global_myname(), remote_machine, &the_cli->dest_ip)) { - DEBUG(0,("connect_to_client: machine %s rejected the NetBIOS session request.\n", + DEBUG(0,("spoolss_connect_to_client: machine %s rejected the NetBIOS session request.\n", remote_machine)); cli_shutdown(the_cli); return False; @@ -2543,13 +2552,13 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *rem the_cli->protocol = PROTOCOL_NT1; if (!cli_negprot(the_cli)) { - DEBUG(0,("connect_to_client: machine %s rejected the negotiate protocol. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + DEBUG(0,("spoolss_connect_to_client: machine %s rejected the negotiate protocol. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); cli_shutdown(the_cli); return False; } if (the_cli->protocol != PROTOCOL_NT1) { - DEBUG(0,("connect_to_client: machine %s didn't negotiate NT protocol.\n", remote_machine)); + DEBUG(0,("spoolss_connect_to_client: machine %s didn't negotiate NT protocol.\n", remote_machine)); cli_shutdown(the_cli); return False; } @@ -2559,19 +2568,19 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *rem */ if (!cli_session_setup(the_cli, "", "", 0, "", 0, "")) { - DEBUG(0,("connect_to_client: machine %s rejected the session setup. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + DEBUG(0,("spoolss_connect_to_client: machine %s rejected the session setup. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); cli_shutdown(the_cli); return False; } if (!(the_cli->sec_mode & 1)) { - DEBUG(0,("connect_to_client: machine %s isn't in user level security mode\n", remote_machine)); + DEBUG(0,("spoolss_connect_to_client: machine %s isn't in user level security mode\n", remote_machine)); cli_shutdown(the_cli); return False; } if (!cli_send_tconX(the_cli, "IPC$", "IPC", "", 1)) { - DEBUG(0,("connect_to_client: machine %s rejected the tconX on the IPC$ share. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); + DEBUG(0,("spoolss_connect_to_client: machine %s rejected the tconX on the IPC$ share. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); cli_shutdown(the_cli); return False; } @@ -2582,7 +2591,7 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *rem */ if(cli_nt_session_open(the_cli, PI_SPOOLSS) == False) { - DEBUG(0,("connect_to_client: unable to open the domain client session to machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli))); + DEBUG(0,("spoolss_connect_to_client: unable to open the domain client session to machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli))); cli_nt_session_close(the_cli); cli_ulogoff(the_cli); cli_shutdown(the_cli); @@ -2596,7 +2605,9 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *rem Connect to the client. ****************************************************************************/ -static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle) +static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, + uint32 localprinter, uint32 type, + POLICY_HND *handle, struct in_addr *client_ip) { WERROR result; @@ -2609,7 +2620,7 @@ static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, uint32 l fstrcpy(unix_printer, printer+2); /* the +2 is to strip the leading 2 backslashs */ - if(!spoolss_connect_to_client(¬ify_cli, unix_printer)) + if(!spoolss_connect_to_client(¬ify_cli, client_ip, unix_printer)) return False; message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message_list); @@ -2658,6 +2669,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE uint32 printerlocal = q_u->printerlocal; int snum = -1; SPOOL_NOTIFY_OPTION *option = q_u->option; + struct in_addr client_ip; /* store the notify value in the printer struct */ @@ -2687,10 +2699,12 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE else if ( (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && !get_printer_snum(p, handle, &snum) ) return WERR_BADFID; + + client_ip.s_addr = inet_addr(p->conn->client_address); if(!srv_spoolss_replyopenprinter(snum, Printer->notify.localmachine, Printer->notify.printerlocal, 1, - &Printer->notify.client_hnd)) + &Printer->notify.client_hnd, &client_ip)) return WERR_SERVER_UNAVAILABLE; Printer->notify.client_connected=True; -- cgit From e1ea87ff03f7029f309a119e6be726a11000ab34 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 11 Apr 2003 23:48:24 +0000 Subject: * We must return 0x2 as the majorversion for nt4 to upload drivers * fix bug found by clobber_region() (This used to be commit b2e29c7bd45f8f33d9ed58fe75bbf5ffc78350f5) --- source3/rpc_server/srv_spoolss_nt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 90090efde8..b0529fea81 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2307,7 +2307,17 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; - SIVAL(*data, 0, 3); + + /* Windows NT 4.0 seems to not allow uploading of drivers + to a server that reports 0x3 as the MajorVersion. + need to investigate more how Win2k gets around this . + -- jerry */ + + if ( RA_WINNT == get_remote_arch() ) + SIVAL(*data, 0, 2); + else + SIVAL(*data, 0, 3); + *needed = 0x4; return WERR_OK; } -- cgit From a056cd8845989475a72ae88681cfb3c9d7b23377 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 11 Apr 2003 23:50:21 +0000 Subject: * We must return 0x2 as the majorversion for nt4 to upload drivers * fix bug found by clobber_region() (This used to be commit ad2765bb5e0c1c4d8f12583e49df5b1bc7ffc389) --- source3/rpc_server/srv_spoolss_nt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 424d7909d1..4432b06fc7 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2307,7 +2307,17 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint *type = 0x4; if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; - SIVAL(*data, 0, 3); + + /* Windows NT 4.0 seems to not allow uploading of drivers + to a server that reports 0x3 as the MajorVersion. + need to investigate more how Win2k gets around this . + -- jerry */ + + if ( RA_WINNT == get_remote_arch() ) + SIVAL(*data, 0, 2); + else + SIVAL(*data, 0, 3); + *needed = 0x4; return WERR_OK; } -- cgit From 3b865c73989e7f13e3a6453f9f9c9a7aca74b129 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 14 Apr 2003 02:08:03 +0000 Subject: Merge of rpcecho pipe for testing large dcerpc requests and responses. Only compiled in when --enable-developer argument passed to configure. (This used to be commit 017da9393bab276543d0d5c50df8c760780f2450) --- source3/rpc_server/srv_pipe.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 80275e6070..1a48435c9d 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -537,6 +537,11 @@ static struct api_cmd api_fd_commands[] = #endif #ifndef RPC_DFS_DYNAMIC { "netdfs", rpc_dfs_init }, +#endif +#ifdef DEVELOPER +#ifndef RPC_ECHO_DYNAMIC + { "rpcecho", rpc_echo_init }, +#endif #endif { NULL, NULL } }; -- cgit From ce31379577d5e713ab7214e46631bd260e653ea6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2003 20:42:26 +0000 Subject: Fix typos (This used to be commit 21166e87bfeeaa5079dfbcac3df9232d73986532) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b0529fea81..dfc045877d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1255,7 +1255,7 @@ static BOOL srv_spoolss_drv_upgrade_printer(char* drivername) /********************************************************************** callback to receive a MSG_PRINTER_DRVUPGRADE message and interate - over all printers, upgrading ones as neessary + over all printers, upgrading ones as necessary **********************************************************************/ void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) @@ -1303,7 +1303,7 @@ void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) } /******************************************************************** - Update the cahce for all printq's with a registered client + Update the cache for all printq's with a registered client connection ********************************************************************/ -- cgit From dfe1dd1455199b561a4fc0600a9e23d5f949197a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 15 Apr 2003 06:56:43 +0000 Subject: Merge of comment typo. Whitespace syncup. (This used to be commit c69237edf2bfdb426447d808fbd1dc6eb5cffabe) --- source3/rpc_server/srv_spoolss_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index dfc045877d..f9788fc7f0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -526,7 +526,7 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3 /* Add to the internal list. */ DLIST_ADD(printers_list, new_printer); - + new_printer->notify.option=NULL; if ( !(new_printer->ctx = talloc_init("Printer Entry [0x%x]", (uint32)hnd)) ) { @@ -534,7 +534,7 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3 close_printer_handle(p, hnd); return False; } - + if (!set_printer_hnd_printertype(new_printer, name)) { close_printer_handle(p, hnd); return False; @@ -2623,7 +2623,7 @@ static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, /* * If it's the first connection, contact the client - * and connect to the IPC$ share anonumously + * and connect to the IPC$ share anonymously */ if (smb_connections==0) { fstring unix_printer; -- cgit From ab8a9c8419a66ff22714fb84530534fde321db26 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 15 Apr 2003 16:55:21 +0000 Subject: use the new modules system for the rpc modules (backport from HEAD) (This used to be commit aca7319e8d45eb604f28b8bd490413b08e2c98f2) --- source3/rpc_server/srv_dfs.c | 4 -- source3/rpc_server/srv_lsa.c | 4 -- source3/rpc_server/srv_netlog.c | 4 -- source3/rpc_server/srv_pipe.c | 106 +++------------------------------------ source3/rpc_server/srv_reg.c | 4 -- source3/rpc_server/srv_samr.c | 4 -- source3/rpc_server/srv_spoolss.c | 4 -- source3/rpc_server/srv_srvsvc.c | 4 -- source3/rpc_server/srv_wkssvc.c | 4 -- 9 files changed, 7 insertions(+), 131 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index f6e9ca3d56..0807efd550 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -158,11 +158,7 @@ static BOOL api_dfs_enum(pipes_struct *p) \pipe\netdfs commands ********************************************************************/ -#ifdef RPC_DFS_DYNAMIC -int rpc_pipe_init(void) -#else int rpc_dfs_init(void) -#endif { struct api_struct api_netdfs_cmds[] = { diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 11388a00b1..8648213fda 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -645,11 +645,7 @@ static BOOL api_lsa_query_info2(pipes_struct *p) /*************************************************************************** \PIPE\ntlsa commands ***************************************************************************/ -#ifdef RPC_LSA_DYNAMIC -int rpc_pipe_init(void) -#else int rpc_lsa_init(void) -#endif { static const struct api_struct api_lsa_cmds[] = { diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index f377d3952b..7dc0f57f34 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -321,11 +321,7 @@ static BOOL api_net_logon_ctrl(pipes_struct *p) array of \PIPE\NETLOGON operations ********************************************************************/ -#ifdef RPC_NETLOG_DYNAMIC -int rpc_pipe_init(void) -#else int rpc_net_init(void) -#endif { static struct api_struct api_net_cmds [] = { diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 1a48435c9d..43fbb4edaa 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -506,46 +506,6 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); The switch table for the pipe names and the functions to handle them. *******************************************************************/ -struct api_cmd -{ - const char *name; - int (*init)(void); -}; - -static struct api_cmd api_fd_commands[] = -{ -#ifndef RPC_LSA_DYNAMIC - { "lsarpc", rpc_lsa_init }, -#endif -#ifndef RPC_SAMR_DYNAMIC - { "samr", rpc_samr_init }, -#endif -#ifndef RPC_SVC_DYNAMIC - { "srvsvc", rpc_srv_init }, -#endif -#ifndef RPC_WKS_DYNAMIC - { "wkssvc", rpc_wks_init }, -#endif -#ifndef RPC_NETLOG_DYNAMIC - { "NETLOGON", rpc_net_init }, -#endif -#ifndef RPC_REG_DYNAMIC - { "winreg", rpc_reg_init }, -#endif -#ifndef RPC_SPOOLSS_DYNAMIC - { "spoolss", rpc_spoolss_init }, -#endif -#ifndef RPC_DFS_DYNAMIC - { "netdfs", rpc_dfs_init }, -#endif -#ifdef DEVELOPER -#ifndef RPC_ECHO_DYNAMIC - { "rpcecho", rpc_echo_init }, -#endif -#endif - { NULL, NULL } -}; - struct rpc_table { struct @@ -848,47 +808,6 @@ int rpc_pipe_register_commands(const char *clnt, const char *srv, const struct a return size; } -/******************************************************************* - Register commands to an RPC pipe -*******************************************************************/ -int rpc_load_module(const char *module) -{ -#ifdef HAVE_DLOPEN - void *handle; - int (*module_init)(void); - pstring full_path; - const char *error; - - pstrcpy(full_path, lib_path("rpc")); - pstrcat(full_path, "/librpc_"); - pstrcat(full_path, module); - pstrcat(full_path, "."); - pstrcat(full_path, shlib_ext()); - - handle = sys_dlopen(full_path, RTLD_LAZY); - if (!handle) { - DEBUG(0, ("Could not load requested pipe %s as %s\n", - module, full_path)); - DEBUG(0, (" Error: %s\n", dlerror())); - return 0; - } - - DEBUG(3, ("Module '%s' loaded\n", full_path)); - - module_init = sys_dlsym(handle, "rpc_pipe_init"); - if ((error = sys_dlerror()) != NULL) { - DEBUG(0, ("Error trying to resolve symbol 'rpc_pipe_init' in %s: %s\n", - full_path, error)); - return 0; - } - - return module_init(); -#else - DEBUG(0,("Attempting to load a dynamic RPC pipe when dlopen isn't available\n")); - return 0; -#endif -} - /******************************************************************* Respond to a pipe bind request. *******************************************************************/ @@ -928,14 +847,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) } if (i == rpc_lookup_size) { - for (i = 0; api_fd_commands[i].name; i++) { - if (strequal(api_fd_commands[i].name, p->name)) { - api_fd_commands[i].init(); - break; - } - } - - if (!api_fd_commands[i].name && !rpc_load_module(p->name)) { + if (!smb_probe_module("rpc", p->name)) { DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", p->name )); if(!setup_bind_nak(p)) @@ -951,6 +863,11 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) break; } } + + if (i == rpc_lookup_size) { + DEBUG(0, ("module %s doesn't provide functions for pipe %s!\n", p->name, p->name)); + return False; + } } /* decode the bind request */ @@ -1478,16 +1395,7 @@ BOOL api_pipe_request(pipes_struct *p) if (i == rpc_lookup_size) { - for (i = 0; api_fd_commands[i].name; i++) { - if (strequal(api_fd_commands[i].name, p->name)) { - api_fd_commands[i].init(); - break; - } - } - - if (!api_fd_commands[i].name) { - rpc_load_module(p->name); - } + smb_probe_module("rpc", p->name); for (i = 0; i < rpc_lookup_size; i++) { if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 04960f8e3a..f72d8e4f29 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -373,11 +373,7 @@ static BOOL api_reg_save_key(pipes_struct *p) array of \PIPE\reg operations ********************************************************************/ -#ifdef RPC_REG_DYNAMIC -int rpc_pipe_init(void) -#else int rpc_reg_init(void) -#endif { static struct api_struct api_reg_cmds[] = { diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 3a31ec82e1..67c092775b 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1443,11 +1443,7 @@ static BOOL api_samr_set_dom_info(pipes_struct *p) array of \PIPE\samr operations ********************************************************************/ -#ifdef RPC_SAMR_DYNAMIC -int rpc_pipe_init(void) -#else int rpc_samr_init(void) -#endif { static struct api_struct api_samr_cmds [] = { diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 5832ae876b..a7dd7a6cef 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1580,11 +1580,7 @@ static BOOL api_spoolss_replycloseprinter(pipes_struct *p) \pipe\spoolss commands ********************************************************************/ -#ifdef RPC_SPOOLSS_DYNAMIC -int rpc_pipe_init(void) -#else int rpc_spoolss_init(void) -#endif { struct api_struct api_spoolss_cmds[] = { diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 983c660965..96820ae74b 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -526,11 +526,7 @@ static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) \PIPE\srvsvc commands ********************************************************************/ -#ifdef RPC_SVC_DYNAMIC -int rpc_pipe_init(void) -#else int rpc_srv_init(void) -#endif { static const struct api_struct api_srv_cmds[] = { diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 1fed2cc6db..ddcbadd1d4 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -60,11 +60,7 @@ static BOOL api_wks_query_info(pipes_struct *p) \PIPE\wkssvc commands ********************************************************************/ -#ifdef RPC_WKS_DYNAMIC -int rpc_pipe_init(void) -#else int rpc_wks_init(void) -#endif { static struct api_struct api_wks_cmds[] = { -- cgit From 09a50497d1360659eb8bd1b9f4be510680267bd2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 16 Apr 2003 15:39:57 +0000 Subject: Fixes to make SCHANNEL work in 3.0 against a W2K DC. Still need to fix multi-PDU encode/decode with SCHANNEL. Also need to test against WNT DC. Jeremy. (This used to be commit ff66d4097088409205b6bad5124a78ef9946010d) --- source3/rpc_server/srv_pipe.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 43fbb4edaa..df99c15777 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -279,8 +279,13 @@ BOOL create_next_pdu(pipes_struct *p) prs_init(&rverf, 0, p->mem_ctx, MARSHALL); prs_init(&rauth, 0, p->mem_ctx, MARSHALL); - memset(sign, 0, sizeof(sign)); - sign[3] = 0x01; + if ((p->netsec_auth.seq_num & 1) == 0) { + DEBUG(0,("SCHANNEL ERROR: seq_num must be odd in server! (seq_num=%d)\n", + p->netsec_auth.seq_num)); + } + + RSIVAL(sign, 0, p->netsec_auth.seq_num); + SIVAL(sign, 4, 0); init_rpc_auth_netsec_chk(&verf, netsec_sig, nullbytes, sign, nullbytes); @@ -1340,6 +1345,9 @@ BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) return False; } + /* The sequence number gets incremented on both send and receive. */ + p->netsec_auth.seq_num++; + return True; } -- cgit From 6f99b229dbf4a9b72fe825ebb2e3751ef3d7b680 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 22 Apr 2003 03:15:32 +0000 Subject: wrap pdb_enum_group_mapping() in [un]become_root() so LDAP queries can get the credentials from secrets.tdb (This used to be commit bb8b63b865b941abecc0d821e710702dd12866fe) --- source3/rpc_server/srv_samr_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f174114473..794fea56df 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -300,11 +300,16 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) DEBUG(10,("load_group_domain_entries: already in memory\n")); return NT_STATUS_OK; } + + + become_root(); if (!pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) { DEBUG(1, ("load_group_domain_entries: pdb_enum_group_mapping() failed!\n")); return NT_STATUS_NO_MEMORY; } + + unbecome_root(); info->disp_info.num_group_account=group_entries; -- cgit From 8de48f3093a0e84bb732b24e7355780368f25a67 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 22 Apr 2003 07:28:41 +0000 Subject: Make our 'get DNS domain name' code try a bit harder - if gethostname() doesn't include a domain portion, do a gethostbyname() lookup on that name. Use this name in our PolicyPrimaryDomainInformation reply (_lsa_query_info2) that Win2k uses when trying to trust us as a trusted domain. (We need to do a better mapping between our Netbios and Win2k domain names, but this will do for now - particularly annoying is the way this possibly needs to map with our kerberos realm). Andrew Bartlett (This used to be commit 3be03271030208a69da29c6e2a7b92cdbaa8c6aa) --- source3/rpc_server/srv_lsa_nt.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 10c583b70d..7771e0ebfa 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -52,7 +52,7 @@ static void free_lsa_info(void *ptr) { struct lsa_info *lsa = (struct lsa_info *)ptr; - SAFE_FREE(lsa); + SAFE_FRE(lsa); } /*************************************************************************** @@ -1222,6 +1222,7 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I char *forest_name = NULL; DOM_SID *sid = NULL; GUID guid; + fstring dnsdomname; ZERO_STRUCT(guid); r_u->status = NT_STATUS_OK; @@ -1241,8 +1242,15 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I case ROLE_DOMAIN_BDC: nb_name = lp_workgroup(); /* ugly temp hack for these next two */ - dns_name = lp_realm(); - forest_name = lp_realm(); + + /* This should be a 'netbios domain -> DNS domain' mapping */ + dnsdomname[0] = '\0'; + get_mydomname(dnsdomname); + strlower(dnsdomname); + + dns_name = dnsdomname; + forest_name = dnsdomname; + sid = get_global_sam_sid(); secrets_fetch_domain_guid(lp_workgroup(), &guid); break; -- cgit From 434f312434faa1cd3c8f15644abbef400ac7b8bc Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 22 Apr 2003 08:50:20 +0000 Subject: Oops... Andrew Bartlett (This used to be commit 898ff89632a394ff32fd38f1c4e94412388fa8bd) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 7771e0ebfa..e7e13d7a84 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -52,7 +52,7 @@ static void free_lsa_info(void *ptr) { struct lsa_info *lsa = (struct lsa_info *)ptr; - SAFE_FRE(lsa); + SAFE_FREE(lsa); } /*************************************************************************** -- cgit From 8301c8c0e4e3085a6e661dd5c04b20fc89db0bc3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 22 Apr 2003 11:25:10 +0000 Subject: Setting the credentials for the netsec netlogon pipe connect upon each samlogon call certainly breaks the credential chain. Do it once during the bind response. Volker (This used to be commit d4262c37f13642e034d3e207bfbb563c17a8a176) --- source3/rpc_server/srv_netlog_nt.c | 8 -------- source3/rpc_server/srv_pipe.c | 5 +++++ 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 76c1d98dab..aa573b8154 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -548,14 +548,6 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return NT_STATUS_ACCESS_DENIED; } - if (p->netsec_auth_validated) { - /* The client opens a second RPC NETLOGON pipe without - doing a auth2. The session key for the schannel is - re-used from the auth2 the client did before. */ - extern struct dcinfo last_dcinfo; - p->dc = last_dcinfo; - } - /* checks and updates credentials. creates reply credentials */ if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred))) return NT_STATUS_INVALID_HANDLE; diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index df99c15777..b09058629a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1088,6 +1088,11 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) RPC_AUTH_VERIFIER auth_verifier; uint32 flags; + /* The client opens a second RPC NETLOGON pipe without + doing a auth2. The credentials for the schannel are + re-used from the auth2 the client did before. */ + p->dc = last_dcinfo; + init_rpc_hdr_auth(&auth_info, NETSEC_AUTH_TYPE, NETSEC_AUTH_LEVEL, RPC_HDR_AUTH_LEN, 1); if(!smb_io_rpc_hdr_auth("", &auth_info, &out_auth, 0)) { DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_AUTH failed.\n")); -- cgit From 846a773bda69ecbf512f8e455e5695dbf868cda7 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 23 Apr 2003 01:04:20 +0000 Subject: Now that Volker fixed the real issues with ldapsam and adding null attributes etc, move the SAMR create_user code back to using the 'pdb_init_sam_pw' method to fill out the attributes. This is basicly the same code, but we really didn't need the duplication. Also, take advantage of the fact that RIDs will always be returned back into the SAM_ACCOUNT on ADD, so we don't need to duplicate the 'get'. This should also help in sites with replicated LDAP - the second fetch might occour before the first is replicated back. Andrew Bartlett (This used to be commit 39714c24fd9da4701d4fe69ddd3d61a25254409f) --- source3/rpc_server/srv_samr_nt.c | 48 +++++++--------------------------------- 1 file changed, 8 insertions(+), 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 794fea56df..7b2cd78dc6 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2205,6 +2205,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ uint32 acc_granted; SEC_DESC *psd; size_t sd_size; + /* check this, when giving away 'add computer to domain' privs */ uint32 des_access = GENERIC_RIGHTS_USER_ALL_ACCESS; /* Get the domain SID stored in the domain policy */ @@ -2290,50 +2291,26 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ DEBUG(3,("_api_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); } - if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&sam_pass))) { - return nt_status; - } - pw = getpwnam_alloc(account); if (pw) { - DOM_SID user_sid; - DOM_SID group_sid; - if (!uid_to_sid(&user_sid, pw->pw_uid)) { - passwd_free(&pw); /* done with this now */ - pdb_free_sam(&sam_pass); - DEBUG(1, ("_api_samr_create_user: uid_to_sid failed, cannot add user.\n")); - return NT_STATUS_ACCESS_DENIED; - } - - if (!pdb_set_user_sid(sam_pass, &user_sid, PDB_CHANGED)) { - passwd_free(&pw); /* done with this now */ - pdb_free_sam(&sam_pass); - return NT_STATUS_NO_MEMORY; - } - - if (!gid_to_sid(&group_sid, pw->pw_gid)) { - passwd_free(&pw); /* done with this now */ - pdb_free_sam(&sam_pass); - DEBUG(1, ("_api_samr_create_user: gid_to_sid failed, cannot add user.\n")); - return NT_STATUS_ACCESS_DENIED; - } - - if (!pdb_set_group_sid(sam_pass, &group_sid, PDB_CHANGED)) { - passwd_free(&pw); /* done with this now */ + nt_status = pdb_init_sam_pw(&sam_pass, pw); + passwd_free(&pw); /* done with this now */ + if (!NT_STATUS_IS_OK(nt_status)) { pdb_free_sam(&sam_pass); - return NT_STATUS_NO_MEMORY; + return nt_status; } - - passwd_free(&pw); /* done with this now */ } else { DEBUG(3,("attempting to create non-unix account %s\n", account)); + if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&sam_pass))) { + return nt_status; } if (!pdb_set_username(sam_pass, account, PDB_CHANGED)) { pdb_free_sam(&sam_pass); return NT_STATUS_NO_MEMORY; + } } pdb_set_acct_ctrl(sam_pass, acb_info, PDB_CHANGED); @@ -2344,15 +2321,6 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ account)); return NT_STATUS_ACCESS_DENIED; } - - pdb_reset_sam(sam_pass); - - if (!pdb_getsampwnam(sam_pass, account)) { - pdb_free_sam(&sam_pass); - DEBUG(0, ("could not find user/computer %s just added to passdb?!?\n", - account)); - return NT_STATUS_ACCESS_DENIED; - } /* Get the user's SID */ sid_copy(&sid, pdb_get_user_sid(sam_pass)); -- cgit From 2a3a9f0bf43c3bf99a71f7296bb5ff6199893fea Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 23 Apr 2003 13:27:35 +0000 Subject: Merge the 'safe' parts of my StrnCpy patch - many of the users really wanted a pstrcpy/fstrcpy or at most a safe_strcpy(). These have the advantage of being compiler-verifiable. Get these out of the way, along with a rewrite of 'get_short_archi' in the spoolss client and server. (This pushes around const string pointers, rather than copied strings). Andrew Bartlett (This used to be commit 32fb801ddc035e8971e9911ed4b6e51892e9d1cc) --- source3/rpc_server/srv_spoolss_nt.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f9788fc7f0..e6129f4ace 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7601,12 +7601,12 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen { pstring path; pstring long_archi; - pstring short_archi; + const char *short_archi; DRIVER_DIRECTORY_1 *info=NULL; unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); - if (get_short_archi(short_archi, long_archi)==False) + if (!(short_archi = get_short_archi(long_archi))) return WERR_INVALID_ENVIRONMENT; if((info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1))) == NULL) @@ -8432,7 +8432,7 @@ WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_ /**************************************************************************** ****************************************************************************/ -static WERROR getjob_level_1(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getjob_level_1(print_queue_struct **queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) { int i=0; BOOL found=False; @@ -8445,7 +8445,7 @@ static WERROR getjob_level_1(print_queue_struct *queue, int count, int snum, uin } for (i=0; i Date: Wed, 23 Apr 2003 14:07:33 +0000 Subject: Patch by Metze to ensure that we always at least initialize our output string for rpc_pull_string. If we had a NULL or zero-length string, we would use uninitialised data in the result string. Andrew Bartlett (This used to be commit df10aee451b431a8a056a949a98393da256185da) --- source3/rpc_server/srv_samr_nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7b2cd78dc6..d6441fd361 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1473,13 +1473,14 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO for (i = 0; i < num_rids; i++) { fstring name; DOM_SID sid; + int ret; r_u->status = NT_STATUS_NONE_MAPPED; rid [i] = 0xffffffff; type[i] = SID_NAME_UNKNOWN; - rpcstr_pull(name, q_u->uni_name[i].buffer, sizeof(name), q_u->uni_name[i].uni_str_len*2, 0); + ret = rpcstr_pull(name, q_u->uni_name[i].buffer, sizeof(name), q_u->uni_name[i].uni_str_len*2, 0); /* * we are only looking for a name @@ -1492,7 +1493,8 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO * a cleaner code is to add the sid of the domain we're looking in * to the local_lookup_name function. */ - if(local_lookup_name(name, &sid, &local_type)) { + + if ((ret > 0) && local_lookup_name(name, &sid, &local_type)) { sid_split_rid(&sid, &local_rid); if (sid_equal(&sid, &pol_sid)) { -- cgit From 43b3ea968b0405efebf7c1cb4d5f541b50b388b0 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 26 Apr 2003 01:15:57 +0000 Subject: back port from HEAD (This used to be commit f7cfdf20b7b3b7743c0c3af4ff62fdde00e45fdc) --- source3/rpc_server/srv_samr_util.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index d7ead0d15f..b81c441811 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -169,13 +169,17 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_munged_dial(to , new_string, PDB_CHANGED); } - if (from->user_rid != pdb_get_user_rid(to)) { + if (from->user_rid == 0) { + DEBUG(10, ("INFO_21: Asked to set User RID to 0 !? Skipping change!\n")); + } else if (from->user_rid != pdb_get_user_rid(to)) { DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); /* we really allow this ??? metze */ /* pdb_set_user_sid_from_rid(to, from->user_rid, PDB_CHANGED);*/ } - if (from->group_rid != pdb_get_group_rid(to)) { + if (from->group_rid == 0) { + DEBUG(10, ("INFO_21: Asked to set Group RID to 0 !? Skipping change!\n")); + } else if (from->group_rid != pdb_get_group_rid(to)) { DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); } @@ -371,13 +375,16 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_munged_dial(to , new_string, PDB_CHANGED); } - if (from->user_rid != pdb_get_user_rid(to)) { + if (from->user_rid == 0) { + DEBUG(10, ("INFO_23: Asked to set User RID to 0 !? Skipping change!\n")); + } else if (from->user_rid != pdb_get_user_rid(to)) { DEBUG(10,("INFO_23 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); /* we really allow this ??? metze */ /* pdb_set_user_sid_from_rid(to, from->user_rid, PDB_CHANGED);*/ } - - if (from->group_rid != pdb_get_group_rid(to)) { + if (from->group_rid == 0) { + DEBUG(10, ("INFO_23: Asked to set Group RID to 0 !? Skipping change!\n")); + } else if (from->group_rid != pdb_get_group_rid(to)) { DEBUG(10,("INFO_23 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); } -- cgit From 17a3acafa89bfc6090b0767d05a00a7505003fcc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 28 Apr 2003 17:48:48 +0000 Subject: Use NTSTATUS as return value for smb_register_*() functions and init_module() function. Patch by metze with some minor modifications. (This used to be commit bc4b51bcb2daa7271c884cb83bf8bdba6d3a9b6d) --- source3/rpc_server/srv_dfs.c | 4 ++-- source3/rpc_server/srv_echo.c | 4 ++-- source3/rpc_server/srv_lsa.c | 4 ++-- source3/rpc_server/srv_netlog.c | 4 ++-- source3/rpc_server/srv_pipe.c | 26 ++++++++++++++++++++++---- source3/rpc_server/srv_reg.c | 4 ++-- source3/rpc_server/srv_samr.c | 4 ++-- source3/rpc_server/srv_spoolss.c | 4 ++-- source3/rpc_server/srv_srvsvc.c | 4 ++-- source3/rpc_server/srv_wkssvc.c | 4 ++-- 10 files changed, 40 insertions(+), 22 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 0807efd550..75a24174ea 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -158,7 +158,7 @@ static BOOL api_dfs_enum(pipes_struct *p) \pipe\netdfs commands ********************************************************************/ -int rpc_dfs_init(void) +NTSTATUS rpc_dfs_init(void) { struct api_struct api_netdfs_cmds[] = { @@ -168,6 +168,6 @@ int rpc_dfs_init(void) {"DFS_GET_INFO", DFS_GET_INFO, api_dfs_get_info }, {"DFS_ENUM", DFS_ENUM, api_dfs_enum } }; - return rpc_pipe_register_commands("netdfs", "netdfs", api_netdfs_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "netdfs", "netdfs", api_netdfs_cmds, sizeof(api_netdfs_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_echo.c b/source3/rpc_server/srv_echo.c index dcd8dd0c53..166b6e939d 100644 --- a/source3/rpc_server/srv_echo.c +++ b/source3/rpc_server/srv_echo.c @@ -120,7 +120,7 @@ static BOOL api_sink_data(pipes_struct *p) \pipe\rpcecho commands ********************************************************************/ -int rpc_echo_init(void) +NTSTATUS rpc_echo_init(void) { struct api_struct api_echo_cmds[] = { {"ADD_ONE", ECHO_ADD_ONE, api_add_one }, @@ -129,7 +129,7 @@ int rpc_echo_init(void) {"SINK_DATA", ECHO_SINK_DATA, api_sink_data }, }; - return rpc_pipe_register_commands( + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "rpcecho", "rpcecho", api_echo_cmds, sizeof(api_echo_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 8648213fda..384e8e9094 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -645,7 +645,7 @@ static BOOL api_lsa_query_info2(pipes_struct *p) /*************************************************************************** \PIPE\ntlsa commands ***************************************************************************/ -int rpc_lsa_init(void) +NTSTATUS rpc_lsa_init(void) { static const struct api_struct api_lsa_cmds[] = { @@ -671,6 +671,6 @@ static const struct api_struct api_lsa_cmds[] = { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 } }; - return rpc_pipe_register_commands("lsarpc", "lsass", api_lsa_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "lsarpc", "lsass", api_lsa_cmds, sizeof(api_lsa_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 7dc0f57f34..0cd4073177 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -321,7 +321,7 @@ static BOOL api_net_logon_ctrl(pipes_struct *p) array of \PIPE\NETLOGON operations ********************************************************************/ -int rpc_net_init(void) +NTSTATUS rpc_net_init(void) { static struct api_struct api_net_cmds [] = { @@ -336,6 +336,6 @@ int rpc_net_init(void) { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl } }; - return rpc_pipe_register_commands("NETLOGON", "lsass", api_net_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "NETLOGON", "lsass", api_net_cmds, sizeof(api_net_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index b09058629a..5b9d39ddc7 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -781,10 +781,28 @@ BOOL check_bind_req(char* pipe_name, RPC_IFACE* abstract, /******************************************************************* Register commands to an RPC pipe *******************************************************************/ -int rpc_pipe_register_commands(const char *clnt, const char *srv, const struct api_struct *cmds, int size) +NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *srv, const struct api_struct *cmds, int size) { struct rpc_table *rpc_entry; + if (!clnt || !srv || !cmds) { + return NT_STATUS_INVALID_PARAMETER; + } + + if (version != SMB_RPC_INTERFACE_VERSION) { + DEBUG(0,("Can't register rpc commands!\n" + "You tried to register a rpc module with SMB_RPC_INTERFACE_VERSION %d" + ", while this version of samba uses version %d!\n", + version,SMB_RPC_INTERFACE_VERSION)); + return NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + /* TODO: + * + * we still need to make sure that don't register the same commands twice!!! + * + * --metze + */ /* We use a temporary variable because this call can fail and rpc_lookup will still be valid afterwards. It could then succeed if @@ -794,7 +812,7 @@ int rpc_pipe_register_commands(const char *clnt, const char *srv, const struct a if (NULL == rpc_entry) { rpc_lookup_size--; DEBUG(0, ("rpc_pipe_register_commands: memory allocation failed\n")); - return 0; + return NT_STATUS_NO_MEMORY; } else { rpc_lookup = rpc_entry; } @@ -810,7 +828,7 @@ int rpc_pipe_register_commands(const char *clnt, const char *srv, const struct a size * sizeof(struct api_struct)); rpc_entry->n_cmds += size; - return size; + return NT_STATUS_OK; } /******************************************************************* @@ -852,7 +870,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) } if (i == rpc_lookup_size) { - if (!smb_probe_module("rpc", p->name)) { + if (NT_STATUS_IS_ERR(smb_probe_module("rpc", p->name))) { DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", p->name )); if(!setup_bind_nak(p)) diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index f72d8e4f29..43bb1ad86a 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -373,7 +373,7 @@ static BOOL api_reg_save_key(pipes_struct *p) array of \PIPE\reg operations ********************************************************************/ -int rpc_reg_init(void) +NTSTATUS rpc_reg_init(void) { static struct api_struct api_reg_cmds[] = { @@ -391,6 +391,6 @@ int rpc_reg_init(void) { "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a }, { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key } }; - return rpc_pipe_register_commands("winreg", "winreg", api_reg_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "winreg", "winreg", api_reg_cmds, sizeof(api_reg_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 67c092775b..9250b023d3 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1443,7 +1443,7 @@ static BOOL api_samr_set_dom_info(pipes_struct *p) array of \PIPE\samr operations ********************************************************************/ -int rpc_samr_init(void) +NTSTATUS rpc_samr_init(void) { static struct api_struct api_samr_cmds [] = { @@ -1501,6 +1501,6 @@ int rpc_samr_init(void) {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, {"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 } }; - return rpc_pipe_register_commands("samr", "lsass", api_samr_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "samr", "lsass", api_samr_cmds, sizeof(api_samr_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index a7dd7a6cef..3e9ed9e39f 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1580,7 +1580,7 @@ static BOOL api_spoolss_replycloseprinter(pipes_struct *p) \pipe\spoolss commands ********************************************************************/ -int rpc_spoolss_init(void) +NTSTATUS rpc_spoolss_init(void) { struct api_struct api_spoolss_cmds[] = { @@ -1640,6 +1640,6 @@ int rpc_spoolss_init(void) {"SPOOLSS_REPLYCLOSEPRINTER", SPOOLSS_REPLYCLOSEPRINTER, api_spoolss_replycloseprinter } #endif }; - return rpc_pipe_register_commands("spoolss", "spoolss", api_spoolss_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "spoolss", "spoolss", api_spoolss_cmds, sizeof(api_spoolss_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 96820ae74b..deba122421 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -526,7 +526,7 @@ static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) \PIPE\srvsvc commands ********************************************************************/ -int rpc_srv_init(void) +NTSTATUS rpc_srv_init(void) { static const struct api_struct api_srv_cmds[] = { @@ -548,6 +548,6 @@ int rpc_srv_init(void) { "SRV_NET_FILE_QUERY_SECDESC", SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc }, { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc } }; - return rpc_pipe_register_commands("srvsvc", "ntsvcs", api_srv_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "srvsvc", "ntsvcs", api_srv_cmds, sizeof(api_srv_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index ddcbadd1d4..8efa29fd0b 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -60,12 +60,12 @@ static BOOL api_wks_query_info(pipes_struct *p) \PIPE\wkssvc commands ********************************************************************/ -int rpc_wks_init(void) +NTSTATUS rpc_wks_init(void) { static struct api_struct api_wks_cmds[] = { { "WKS_Q_QUERY_INFO", WKS_QUERY_INFO, api_wks_query_info } }; - return rpc_pipe_register_commands("wkssvc", "ntsvcs", api_wks_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "wkssvc", "ntsvcs", api_wks_cmds, sizeof(api_wks_cmds) / sizeof(struct api_struct)); } -- cgit From 2aa8a05f336781d7cc7c8cdce9533f96ba9ca8d6 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 29 Apr 2003 05:30:29 +0000 Subject: only call the add_script if the getpwnam_alloc() fails (This used to be commit c0807e21999ec718d722fc0be6b3353c9369db04) --- source3/rpc_server/srv_samr_nt.c | 47 ++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d6441fd361..8ff993d8a6 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2274,26 +2274,35 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ } #endif - /* - * we can't check both the ending $ and the acb_info. - * - * UserManager creates trust accounts (ending in $, - * normal that hidden accounts) with the acb_info equals to ACB_NORMAL. - * JFM, 11/29/2001 - */ - if (account[strlen(account)-1] == '$') - pstrcpy(add_script, lp_addmachine_script()); - else - pstrcpy(add_script, lp_adduser_script()); - - if (*add_script) { - int add_ret; - all_string_sub(add_script, "%u", account, sizeof(account)); - add_ret = smbrun(add_script,NULL); - DEBUG(3,("_api_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); - } - + /* the passdb lookup has failed; check to see if we need to run the + add user/machine script */ + pw = getpwnam_alloc(account); + + if ( !pw ) { + /* + * we can't check both the ending $ and the acb_info. + * + * UserManager creates trust accounts (ending in $, + * normal that hidden accounts) with the acb_info equals to ACB_NORMAL. + * JFM, 11/29/2001 + */ + if (account[strlen(account)-1] == '$') + pstrcpy(add_script, lp_addmachine_script()); + else + pstrcpy(add_script, lp_adduser_script()); + + if (*add_script) { + int add_ret; + all_string_sub(add_script, "%u", account, sizeof(account)); + add_ret = smbrun(add_script,NULL); + DEBUG(3,("_api_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); + } + + /* try again */ + pw = getpwnam_alloc(account); + } + if (pw) { nt_status = pdb_init_sam_pw(&sam_pass, pw); -- cgit From 281d95e2f35f8276d23d075d6e528d16eda9fadc Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 29 Apr 2003 09:43:17 +0000 Subject: Use a common function to create the SAM_ACCOUNT being used to add accounts to the system. This means that we always run Get_Pwnam(), and can never add FOO when foo exists on the system (the idea is to instead add foo into the passdb, using it's full name, RID etc). Andrew Bartlett (This used to be commit bb79b127e02cefae13c822fd0fd165f1f214b740) --- source3/rpc_server/srv_samr_nt.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 8ff993d8a6..62d5f8ab0c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2277,7 +2277,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ /* the passdb lookup has failed; check to see if we need to run the add user/machine script */ - pw = getpwnam_alloc(account); + pw = Get_Pwnam(account); if ( !pw ) { /* @@ -2299,33 +2299,14 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ DEBUG(3,("_api_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); } - /* try again */ - pw = getpwnam_alloc(account); } - - if (pw) { - nt_status = pdb_init_sam_pw(&sam_pass, pw); - passwd_free(&pw); /* done with this now */ - if (!NT_STATUS_IS_OK(nt_status)) { - pdb_free_sam(&sam_pass); - return nt_status; - } - } else { - DEBUG(3,("attempting to create non-unix account %s\n", account)); - - if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&sam_pass))) { - return nt_status; - } + nt_status = pdb_init_sam_new(&sam_pass, account); + if (!NT_STATUS_IS_OK(nt_status)) + return nt_status; - if (!pdb_set_username(sam_pass, account, PDB_CHANGED)) { - pdb_free_sam(&sam_pass); - return NT_STATUS_NO_MEMORY; - } - } - pdb_set_acct_ctrl(sam_pass, acb_info, PDB_CHANGED); - + if (!pdb_add_sam_account(sam_pass)) { pdb_free_sam(&sam_pass); DEBUG(0, ("could not add user/computer %s to passdb. Check permissions?\n", -- cgit From 3eeb40f9b54a4a48a4860a498991fd78274b44cf Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 7 May 2003 08:21:06 +0000 Subject: Set our 'global sam name' in one place. For domain controllers, this is lp_workgroup(), for all other server this is global_myname(). This is the name of the domain for accounts on *this* system, and getting this wrong caused interesting bugs with 'take ownership' on member servers and standalone servers at Snap. (They lookup the username that they got, then convert that to a SID - but becouse the domain out of the smbpasswd entry was wrong, we would fail the lookup). Andrew Bartlett (This used to be commit 5fc78eba20411f3f5a8ccadfcba5c4ab73180dba) --- source3/rpc_server/srv_lsa_nt.c | 23 ++++------------------- source3/rpc_server/srv_samr_nt.c | 9 +-------- 2 files changed, 5 insertions(+), 27 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index e7e13d7a84..2a24d7faa5 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -547,7 +547,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - name = lp_workgroup(); + name = get_global_sam_name(); sid = get_global_sam_sid(); break; case ROLE_DOMAIN_MEMBER: @@ -573,23 +573,8 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF return NT_STATUS_ACCESS_DENIED; /* Request PolicyAccountDomainInformation. */ - switch (lp_server_role()) { - case ROLE_DOMAIN_PDC: - case ROLE_DOMAIN_BDC: - name = lp_workgroup(); - sid = get_global_sam_sid(); - break; - case ROLE_DOMAIN_MEMBER: - name = global_myname(); - sid = get_global_sam_sid(); - break; - case ROLE_STANDALONE: - name = global_myname(); - sid = get_global_sam_sid(); - break; - default: - return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; - } + name = get_global_sam_name(); + sid = get_global_sam_sid(); init_dom_query(&r_u->dom.id5, name, sid); break; case 0x06: @@ -1240,7 +1225,7 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I switch (lp_server_role()) { case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: - nb_name = lp_workgroup(); + nb_name = get_global_sam_name(); /* ugly temp hack for these next two */ /* This should be a 'netbios domain -> DNS domain' mapping */ diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 62d5f8ab0c..970756d47c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2575,14 +2575,7 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN return r_u->status; } - switch (lp_server_role()) { - case ROLE_DOMAIN_PDC: - case ROLE_DOMAIN_BDC: - name = lp_workgroup(); - break; - default: - name = global_myname(); - } + name = get_global_sam_name(); fstrcpy(dom[0],name); strupper(dom[0]); -- cgit From e7c8c15888454043c73967635deb4d3419a489e9 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Sun, 11 May 2003 23:34:18 +0000 Subject: Fix VFS layer: 1. Finally work with cascaded modules with private data storage per module 2. Convert VFS API to macro calls to simplify cascading 3. Add quota support to VFS layer (prepare to NT quota support) Patch by Stefan (metze) Metzemacher, with review of Jelmer and me Tested in past few weeks. Documentation to new VFS API for third-party developers to follow (This used to be commit 91984ef5caa2d13c5d52e1f535bd3bbbae1ec978) --- source3/rpc_server/srv_srvsvc_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 1a7b64858b..6a6391f6ad 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1887,7 +1887,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC } } - sd_size = conn->vfs_ops.get_nt_acl(fsp, fsp->fsp_name, &psd); + sd_size = VFS_GET_NT_ACL(fsp, fsp->fsp_name, &psd); if (sd_size == 0) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", filename)); @@ -1991,7 +1991,7 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ } } - ret = conn->vfs_ops.set_nt_acl(fsp, fsp->fsp_name, q_u->sec_info, q_u->sec_desc); + ret = VFS_SET_NT_ACL(fsp, fsp->fsp_name, q_u->sec_info, q_u->sec_desc); if (ret == False) { DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", filename)); -- cgit From c823b191ab476fc2583d6d6aaa1e2edb09cbb88e Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 12 May 2003 18:12:31 +0000 Subject: And finally IDMAP in 3_0 We really need idmap_ldap to have a good solution with ldapsam, porting it from the prvious code is beeing made, the code is really simple to do so I am confident it is not a problem to commit this code in. Not committing it would have been worst. I really would have been able to finish also the group code, maybe we can put it into a followin release after 3.0.0 even if it may be an upgrade problem. The code has been tested and seem to work right, more testing is needed for corner cases. Currently winbind pdc (working only for users and not for groups) is disabled as I was not able to make a complete group code replacement that works somewhat in a week (I have a complete patch, but there are bugs) Simo. (This used to be commit 0e58085978f984436815114a2ec347cf7899a89d) --- source3/rpc_server/srv_pipe.c | 10 ++-------- source3/rpc_server/srv_samr_nt.c | 30 ++++++++---------------------- source3/rpc_server/srv_util.c | 9 +++++++-- 3 files changed, 17 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 5b9d39ddc7..6a9e591f64 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -472,16 +472,10 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); * Store the UNIX credential data (uid/gid pair) in the pipe structure. */ - if (!IS_SAM_UNIX_USER(server_info->sam_account)) { - DEBUG(0,("Attempted authenticated pipe with invalid user. No uid/gid in SAM_ACCOUNT\n")); - free_server_info(&server_info); - return False; - } - memcpy(p->session_key, server_info->session_key, sizeof(p->session_key)); - p->pipe_user.uid = pdb_get_uid(server_info->sam_account); - p->pipe_user.gid = pdb_get_gid(server_info->sam_account); + p->pipe_user.uid = server_info->uid; + p->pipe_user.gid = server_info->gid; p->pipe_user.ngroups = server_info->n_groups; if (p->pipe_user.ngroups) { diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 970756d47c..8c9e22966a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -6,7 +6,7 @@ * Copyright (C) Paul Ashton 1997, * Copyright (C) Marc Jacobsen 1999, * Copyright (C) Jeremy Allison 2001-2002, - * Copyright (C) Jean François Micouleau 1998-2001, + * Copyright (C) Jean François Micouleau 1998-2001, * Copyright (C) Anthony Liguori 2002, * Copyright (C) Jim McDonough 2002. * @@ -920,7 +920,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM struct sys_grent *grp; struct passwd *pw; gid_t winbind_gid_low, winbind_gid_high; - BOOL winbind_groups_exist = lp_winbind_gid(&winbind_gid_low, &winbind_gid_high); + BOOL winbind_groups_exist = lp_idmap_gid(&winbind_gid_low, &winbind_gid_high); /* local aliases */ /* we return the UNIX groups here. This seems to be the right */ @@ -2811,8 +2811,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) copy_id23_to_sam_passwd(pwd, id23); /* if it's a trust account, don't update /etc/passwd */ - if ( (!IS_SAM_UNIX_USER(pwd)) || - ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || + if ( ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || ( (acct_ctrl & ACB_WSTRUST) == ACB_WSTRUST) || ( (acct_ctrl & ACB_SVRTRUST) == ACB_SVRTRUST) ) { DEBUG(5, ("Changing trust account or non-unix-user password, not updating /etc/passwd\n")); @@ -2873,8 +2872,7 @@ static BOOL set_user_info_pw(char *pass, DOM_SID *sid) } /* if it's a trust account, don't update /etc/passwd */ - if ( (!IS_SAM_UNIX_USER(pwd)) || - ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || + if ( ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || ( (acct_ctrl & ACB_WSTRUST) == ACB_WSTRUST) || ( (acct_ctrl & ACB_SVRTRUST) == ACB_SVRTRUST) ) { DEBUG(5, ("Changing trust account or non-unix-user password, not updating /etc/passwd\n")); @@ -3389,9 +3387,9 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD pdb_free_sam(&sam_user); return NT_STATUS_NO_SUCH_USER; } - - uid = pdb_get_uid(sam_user); - if (uid == -1) { + + /* check a real user exist before we run the script to add a user to a group */ + if (NT_STATUS_IS_ERR(sid_to_uid(pdb_get_user_sid(sam_user), &uid))) { pdb_free_sam(&sam_user); return NT_STATUS_NO_SUCH_USER; } @@ -3401,7 +3399,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD if ((pwd=getpwuid_alloc(uid)) == NULL) { return NT_STATUS_NO_SUCH_USER; } - + if ((grp=getgrgid(map.gid)) == NULL) { passwd_free(&pwd); return NT_STATUS_NO_SUCH_ALIAS; @@ -3550,18 +3548,6 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD return NT_STATUS_NO_SUCH_USER; } - uid = pdb_get_uid(sam_user); - if (uid == -1) { - pdb_free_sam(&sam_user); - return NT_STATUS_NO_SUCH_USER; - } - - pdb_free_sam(&sam_user); - - if ((pwd=getpwuid_alloc(uid)) == NULL) { - return NT_STATUS_NO_SUCH_USER; - } - if ((grp=getgrgid(map.gid)) == NULL) { passwd_free(&pwd); return NT_STATUS_NO_SUCH_GROUP; diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 4eba9c7d1f..f96ccaef67 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -112,7 +112,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui *prids=NULL; *numgroups=0; - winbind_groups_exist = lp_winbind_gid(&winbind_gid_low, &winbind_gid_high); + winbind_groups_exist = lp_idmap_gid(&winbind_gid_low, &winbind_gid_high); DEBUG(10,("get_alias_user_groups: looking if SID %s is a member of groups in the SID domain %s\n", @@ -129,7 +129,12 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui fstrcpy(user_name, pdb_get_username(sam_pass)); grid=pdb_get_group_rid(sam_pass); - gid=pdb_get_gid(sam_pass); + if (NT_STATUS_IS_ERR(sid_to_gid(pdb_get_group_sid(sam_pass), &gid))) { + /* this should never happen */ + DEBUG(2,("get_alias_user_groups: sid_to_gid failed!\n")); + pdb_free_sam(&sam_pass); + return NT_STATUS_UNSUCCESSFUL; + } become_root(); /* on some systems this must run as root */ -- cgit From 6abef0810007c317c3ee866eb3933ce2c696085f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 12 May 2003 21:27:54 +0000 Subject: Fix obvious compiler warnings. Jeremy. (This used to be commit 2a6d0c2481c3c34351e57c30a85004babdbf99b0) --- source3/rpc_server/srv_samr_nt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 8c9e22966a..fa7a10bb1a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3509,7 +3509,6 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD struct group *grp; fstring grp_name; GROUP_MAP map; - uid_t uid; NTSTATUS ret; SAM_ACCOUNT *sam_user=NULL; BOOL check; -- cgit From bc2a3748e9caa8f60f7c2387e7eecd7fb3fae899 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Wed, 14 May 2003 10:59:01 +0000 Subject: Prefix VFS API macros with SMB_ for consistency and to avoid problems with VFS_ macros at system side. We currently have one clash with AIX and its VFS_LOCK. Compiled and tested -- no new functionality or code, just plain rename of macros for yet-unreleased VFS API version. Needs to be done before a24 is out (This used to be commit c2689ed118b490e49497a76ed6a2251262018769) --- source3/rpc_server/srv_srvsvc_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 6a6391f6ad..154376dd33 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1887,7 +1887,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC } } - sd_size = VFS_GET_NT_ACL(fsp, fsp->fsp_name, &psd); + sd_size = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, &psd); if (sd_size == 0) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", filename)); @@ -1991,7 +1991,7 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ } } - ret = VFS_SET_NT_ACL(fsp, fsp->fsp_name, q_u->sec_info, q_u->sec_desc); + ret = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, q_u->sec_info, q_u->sec_desc); if (ret == False) { DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", filename)); -- cgit From a975bc2471dfe83848cd12a9ca757184e0e20612 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 May 2003 17:21:32 +0000 Subject: Ensure sys_adminlog code won't coredump with incorrect client params. Jeremy. (This used to be commit b754089a2660975c593a6651e5e72b7360a0aba1) --- source3/rpc_server/srv_spoolss_nt.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e6129f4ace..95237e979f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -48,6 +48,13 @@ static const char * drv_ver_to_os[] = { "WIN2K", /* driver version/cversion 3 */ }; +static const char *get_drv_ver_to_os(int ver) +{ + if (ver < 0 || ver > 3) + return ""; + return drv_ver_to_os[ver]; +} + struct table_node { const char *long_archi; const char *short_archi; @@ -7464,14 +7471,14 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, /* BEGIN_ADMIN_LOG */ switch(level) { case 3: + fstrcpy(driver_name, driver.info_3->name ? driver.info_3->name : ""); sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", - driver.info_3->name,drv_ver_to_os[driver.info_3->cversion],uidtoname(user.uid)); - fstrcpy(driver_name, driver.info_3->name); + driver_name, get_drv_ver_to_os(driver.info_3->cversion),uidtoname(user.uid)); break; case 6: + fstrcpy(driver_name, driver.info_6->name ? driver.info_6->name : ""); sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", - driver.info_6->name,drv_ver_to_os[driver.info_6->version],uidtoname(user.uid)); - fstrcpy(driver_name, driver.info_6->name); + driver_name, get_drv_ver_to_os(driver.info_6->version),uidtoname(user.uid)); break; } /* END_ADMIN_LOG */ -- cgit From 75c14a4ee8cdf91c249d2ef608147dc55b70f0ff Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 16 May 2003 10:48:58 +0000 Subject: another bugfix from Alex Deiter thanks (This used to be commit 29dc40639fad7652f7f99995be7552f5143ff052) --- source3/rpc_server/srv_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index f96ccaef67..c43eb22375 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -194,7 +194,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui break; } - free(groups); + if(num_groups) free(groups); /* now check for the user's gid (the primary group rid) */ for (i=0; i Date: Fri, 16 May 2003 18:30:22 +0000 Subject: Patch from "Esh, Andrew" to fix core dump bug in add groupmem code. Jeremy. (This used to be commit f41eb9ce9af2075f62abaecd8792d30617d05818) --- source3/rpc_server/srv_samr_nt.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index fa7a10bb1a..ee496126ad 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3505,6 +3505,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD DOM_SID group_sid; DOM_SID user_sid; fstring group_sid_str; + uid_t uid; struct passwd *pwd; struct group *grp; fstring grp_name; @@ -3546,7 +3547,19 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD pdb_free_sam(&sam_user); return NT_STATUS_NO_SUCH_USER; } - + + /* check a real user exist before we run the script to add a user to a group */ + if (NT_STATUS_IS_ERR(sid_to_uid(pdb_get_user_sid(sam_user), &uid))) { + pdb_free_sam(&sam_user); + return NT_STATUS_NO_SUCH_USER; + } + + pdb_free_sam(&sam_user); + + if ((pwd=getpwuid_alloc(uid)) == NULL) { + return NT_STATUS_NO_SUCH_USER; + } + if ((grp=getgrgid(map.gid)) == NULL) { passwd_free(&pwd); return NT_STATUS_NO_SUCH_GROUP; -- cgit From 91077a06184211d6720dd485c3432f833682177d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 22 May 2003 15:27:27 +0000 Subject: fixes bugs 85 & 99 (XP domain logons); don't enable the lsa_query_info2 unless we are trying to be an ADS DC (This used to be commit bf20976e5a993f4cfa05c1e0a9ecab2c7da99263) --- source3/rpc_server/srv_lsa.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 384e8e9094..679cfb73bb 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -668,9 +668,21 @@ static const struct api_struct api_lsa_cmds[] = { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs }, { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs }, { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, + /* be careful of the adding of new RPC's. See commentrs below about + ADS DC capabilities */ { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 } }; +/* + * NOTE: Certain calls can not be enabled if we aren't an ADS DC. Make sure + * these calls are always last and that you decrement by the amount of calls + * to disable. + */ + int funcs = sizeof(api_lsa_cmds) / sizeof(struct api_struct); + + if (!(SEC_ADS == lp_security() && ROLE_DOMAIN_PDC == lp_server_role())) { + funcs -= 1; + } return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "lsarpc", "lsass", api_lsa_cmds, - sizeof(api_lsa_cmds) / sizeof(struct api_struct)); + funcs); } -- cgit From 545e8d499947fec55832352d741e8a904122d564 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 May 2003 23:49:31 +0000 Subject: Change get_nt_acl() to include security_info wanted. Only return this. This gets us closer to W2k+ in what we return for file ACLs. Fix horribly broken make_sec_desc() that screwed up the size when given a SD with no owner or group (how did it get this bad... ?). Jeremy. (This used to be commit 183c9ed4052ab14e269ed1234ca557053f77e77a) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 154376dd33..57ba055aef 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1887,7 +1887,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC } } - sd_size = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, &psd); + sd_size = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION), &psd); if (sd_size == 0) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", filename)); -- cgit From cd22a6ac90f1dfdd30894219afe579fc1869ce45 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 3 Jun 2003 07:18:18 +0000 Subject: Merge DEBUG message on usleep on open. Jeremy. (This used to be commit 063a210448d57e08db6d47a584c591f20645c80a) --- source3/rpc_server/srv_spoolss_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 95237e979f..92b1481ab8 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1778,6 +1778,7 @@ Can't find printer handle we created for printer %s\n", name )); if ( (printer_default->access_required == PRINTER_ACCESS_ADMINISTER) && (RA_WIN2K == get_remote_arch()) ) { + DEBUG(10,("_spoolss_open_printer_ex: Enabling LAN/WAN hack for Win2k clients.\n")); usleep( 500000 ); } -- cgit From 98c9504583c2afe89f6115985d6cacc2905be1f8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 11 Jun 2003 20:42:10 +0000 Subject: Set the user's primary unix group from usrmgr.exe. This part of a fix to bug#45. Volker (This used to be commit 43d306011fe0497dabdf6f43a0d120900fd96e6d) --- source3/rpc_server/srv_samr_nt.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ee496126ad..40f6579e27 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2730,6 +2730,41 @@ static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, DOM_SID *sid) return True; } +/******************************************************************* + The GROUPSID field in the SAM_ACCOUNT changed. Try to tell unix. + ********************************************************************/ +static BOOL set_unix_primary_group(SAM_ACCOUNT *sampass) +{ + struct group *grp; + gid_t gid; + + if (!NT_STATUS_IS_OK(sid_to_gid(pdb_get_group_sid(sampass), + &gid))) { + DEBUG(2,("Could not get gid for primary group of " + "user %s\n", pdb_get_username(sampass))); + return False; + } + + grp = getgrgid(gid); + + if (grp == NULL) { + DEBUG(2,("Could not find primary group %d for " + "user %s\n", gid, pdb_get_username(sampass))); + return False; + } + + if (smb_set_primary_group(grp->gr_name, + pdb_get_username(sampass)) != 0) { + DEBUG(2,("Could not set primary group for user %s to " + "%s\n", + pdb_get_username(sampass), grp->gr_name)); + return False; + } + + return True; +} + + /******************************************************************* set_user_info_21 ********************************************************************/ @@ -2759,6 +2794,9 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, DOM_SID *sid) * id21. I don't know if they need to be set. --jerry */ + if (IS_SAM_CHANGED(pwd, PDB_GROUPSID)) + set_unix_primary_group(pwd); + /* write the change out */ if(!pdb_update_sam_account(pwd)) { pdb_free_sam(&pwd); @@ -2826,6 +2864,9 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) ZERO_STRUCT(plaintext_buf); + if (IS_SAM_CHANGED(pwd, PDB_GROUPSID)) + set_unix_primary_group(pwd); + if(!pdb_update_sam_account(pwd)) { pdb_free_sam(&pwd); return False; -- cgit From 0a9396dcca1e30fa32fbcde3ee2dce86f586ba4b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 13 Jun 2003 04:35:53 +0000 Subject: Rename some uuid functions so as not to conflict with system versions. Fixes bug #154. (This used to be commit 986eae40f7669d15dc75aed340e628aa7efafddc) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 92b1481ab8..217d2cbaea 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4330,7 +4330,7 @@ static BOOL construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *p GUID guid; if (is_printer_published(print_hnd, snum, &guid)) { - asprintf(&guid_str, "{%s}", uuid_string_static(guid)); + asprintf(&guid_str, "{%s}", smb_uuid_string_static(guid)); strupper(guid_str); init_unistr(&printer->guid, guid_str); printer->action = SPOOL_DS_PUBLISH; -- cgit From 75a5c0b307a79536316b651273d3f6983323f5ce Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 18 Jun 2003 15:24:10 +0000 Subject: Ok, this patch removes the privilege stuff we had in, unused, for some time. The code was nice, but put in the wrong place (group mapping) and not supported by most of the code, thus useless. We will put back most of the code when our infrastructure will be changed so that privileges actually really make sense to be set. This is a first patch of a set to enhance all our mapping code cleaness and stability towards a sane next beta for 3.0 code base Simo. (This used to be commit e341e7c49f8c17a9ee30ca3fab3aa0397c1f0c7e) --- source3/rpc_server/srv_lsa_nt.c | 58 ++++++++++++++++++++++++++-------------- source3/rpc_server/srv_samr_nt.c | 56 +++++++++++++++----------------------- source3/rpc_server/srv_util.c | 9 ++++--- 3 files changed, 64 insertions(+), 59 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 2a24d7faa5..93e97a7492 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -403,8 +403,16 @@ NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL /* get the generic lsa policy SD until we store it */ lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size); - if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) - return status; + if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) { + if (geteuid() != 0) { + return status; + } + DEBUG(4,("ACCESS should be DENIED (granted: %#010x; required: %#010x)\n", + acc_granted, des_access)); + DEBUGADD(4,("but overwritten by euid == 0\n")); + acc_granted = des_access; + } + /* associate the domain SID with the (unique) handle. */ if ((info = (struct lsa_info *)malloc(sizeof(struct lsa_info))) == NULL) @@ -441,8 +449,15 @@ NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL * /* get the generic lsa policy SD until we store it */ lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size); - if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) - return status; + if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) { + if (geteuid() != 0) { + return status; + } + DEBUG(4,("ACCESS should be DENIED (granted: %#010x; required: %#010x)\n", + acc_granted, des_access)); + DEBUGADD(4,("but overwritten by euid == 0\n")); + acc_granted = des_access; + } /* associate the domain SID with the (unique) handle. */ if ((info = (struct lsa_info *)malloc(sizeof(struct lsa_info))) == NULL) @@ -844,7 +859,7 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU return NT_STATUS_ACCESS_DENIED; /* get the list of mapped groups (domain, local, builtin) */ - if(!pdb_enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) + if(!pdb_enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED)) return NT_STATUS_OK; if (q_u->enum_context >= num_entries) @@ -949,8 +964,6 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LS { struct lsa_info *info=NULL; GROUP_MAP map; - int i=0; - LUID_ATTR *set=NULL; r_u->status = NT_STATUS_OK; @@ -959,9 +972,10 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LS if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!pdb_getgrsid(&map, info->sid, MAPPING_WITH_PRIV)) + if (!pdb_getgrsid(&map, info->sid)) return NT_STATUS_NO_SUCH_GROUP; +#if 0 /* privileges currently not implemented! */ DEBUG(10,("_lsa_enum_privsaccount: %d privileges\n", map.priv_set.count)); if (map.priv_set.count!=0) { @@ -982,6 +996,9 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LS init_lsa_r_enum_privsaccount(r_u, set, map.priv_set.count, 0); free_privilege(&map.priv_set); +#endif + + init_lsa_r_enum_privsaccount(r_u, set, 0, 0); return r_u->status; } @@ -1000,7 +1017,7 @@ NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!pdb_getgrsid(&map, info->sid, MAPPING_WITHOUT_PRIV)) + if (!pdb_getgrsid(&map, info->sid)) return NT_STATUS_NO_SUCH_GROUP; /* @@ -1012,7 +1029,7 @@ NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA they can be ORed together */ - r_u->access=map.systemaccount; + r_u->access = PR_LOG_ON_LOCALLY | PR_ACCESS_FROM_NETWORK; return r_u->status; } @@ -1031,16 +1048,12 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!pdb_getgrsid(&map, info->sid, MAPPING_WITH_PRIV)) + if (!pdb_getgrsid(&map, info->sid)) return NT_STATUS_NO_SUCH_GROUP; - map.systemaccount=q_u->access; - if(!pdb_update_group_mapping_entry(&map)) return NT_STATUS_NO_SUCH_GROUP; - free_privilege(&map.priv_set); - return r_u->status; } @@ -1050,20 +1063,22 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u) { +#if 0 struct lsa_info *info=NULL; GROUP_MAP map; int i=0; - LUID_ATTR *luid_attr=NULL; PRIVILEGE_SET *set=NULL; +#endif r_u->status = NT_STATUS_OK; +#if 0 /* privileges are not implemented */ /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!pdb_getgrsid(&map, info->sid, MAPPING_WITH_PRIV)) + if (!pdb_getgrsid(&map, info->sid)) return NT_STATUS_NO_SUCH_GROUP; set=&q_u->set; @@ -1085,6 +1100,7 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u free_privilege(&map.priv_set); +#endif return r_u->status; } @@ -1094,20 +1110,22 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEPRIVS *r_u) { +#if 0 struct lsa_info *info=NULL; GROUP_MAP map; int i=0; - LUID_ATTR *luid_attr=NULL; PRIVILEGE_SET *set=NULL; +#endif r_u->status = NT_STATUS_OK; +#if 0 /* privileges are not implemented */ /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!pdb_getgrsid(&map, info->sid, MAPPING_WITH_PRIV)) + if (!pdb_getgrsid(&map, info->sid)) return NT_STATUS_NO_SUCH_GROUP; if (q_u->allrights!=0) { @@ -1141,7 +1159,7 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP return NT_STATUS_NO_SUCH_GROUP; free_privilege(&map.priv_set); - +#endif return r_u->status; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 40f6579e27..6039cac96c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -304,7 +304,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) become_root(); - if (!pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) { + if (!pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED)) { DEBUG(1, ("load_group_domain_entries: pdb_enum_group_mapping() failed!\n")); return NT_STATUS_NO_MEMORY; } @@ -900,7 +900,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM /* well-known aliases */ if (sid_equal(sid, &global_sid_Builtin) && !lp_hide_local_users()) { - pdb_enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); + pdb_enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ONLY_MAPPED); if (num_entries != 0) { *d_grp=(DOMAIN_GRP *)talloc_zero(ctx, num_entries*sizeof(DOMAIN_GRP)); @@ -937,7 +937,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM for (; (num_entries < max_entries) && (grp != NULL); grp = grp->next) { uint32 trid; - if(!pdb_getgrgid(&smap, grp->gr_gid, MAPPING_WITHOUT_PRIV)) + if(!pdb_getgrgid(&smap, grp->gr_gid)) continue; if (smap.sid_name_use!=SID_NAME_ALIAS) { @@ -1018,7 +1018,7 @@ static NTSTATUS get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DO *p_num_entries = 0; - pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV); + pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED); num_entries=group_entries-start_idx; @@ -1346,7 +1346,7 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM !sid_check_is_in_builtin(&sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - if (!pdb_getgrsid(&map, sid, MAPPING_WITHOUT_PRIV)) + if (!pdb_getgrsid(&map, sid)) return NT_STATUS_NO_SUCH_ALIAS; switch (q_u->switch_level) { @@ -3215,12 +3215,12 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ if (sid_equal(&alias_sid, &global_sid_Builtin)) { DEBUG(10, ("lookup on Builtin SID (S-1-5-32)\n")); - if(!get_builtin_group_from_sid(als_sid, &map, MAPPING_WITHOUT_PRIV)) + if(!get_builtin_group_from_sid(als_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; } else { if (sid_equal(&alias_sid, get_global_sam_sid())) { DEBUG(10, ("lookup on Server SID\n")); - if(!get_local_group_from_sid(als_sid, &map, MAPPING_WITHOUT_PRIV)) + if(!get_local_group_from_sid(als_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; } } @@ -3321,7 +3321,7 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ sid_append_rid(&group_sid, group_rid); DEBUG(10, ("lookup on Domain SID\n")); - if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) + if(!get_domain_group_from_sid(group_sid, &map)) return NT_STATUS_NO_SUCH_GROUP; if(!get_uid_list_of_group(map.gid, &uid, &num_uids)) @@ -3405,13 +3405,13 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD if (sid_compare(&alias_sid, get_global_sam_sid())>0) { DEBUG(10, ("adding member on Server SID\n")); - if(!get_local_group_from_sid(alias_sid, &map, MAPPING_WITHOUT_PRIV)) + if(!get_local_group_from_sid(alias_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; } else { if (sid_compare(&alias_sid, &global_sid_Builtin)>0) { DEBUG(10, ("adding member on BUILTIN SID\n")); - if( !get_local_group_from_sid(alias_sid, &map, MAPPING_WITHOUT_PRIV)) + if( !get_local_group_from_sid(alias_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; } else @@ -3502,7 +3502,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE return NT_STATUS_NO_SUCH_ALIAS; } - if( !get_local_group_from_sid(alias_sid, &map, MAPPING_WITHOUT_PRIV)) + if( !get_local_group_from_sid(alias_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; if ((grp=getgrgid(map.gid)) == NULL) @@ -3572,7 +3572,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD DEBUG(10, ("lookup on Domain SID\n")); - if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) + if(!get_domain_group_from_sid(group_sid, &map)) return NT_STATUS_NO_SUCH_GROUP; sid_copy(&user_sid, get_global_sam_sid()); @@ -3667,7 +3667,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE sid_copy(&user_sid, get_global_sam_sid()); sid_append_rid(&user_sid, q_u->rid); - if (!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) + if (!get_domain_group_from_sid(group_sid, &map)) return NT_STATUS_NO_SUCH_GROUP; if ((grp=getgrgid(map.gid)) == NULL) @@ -3812,7 +3812,7 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S DEBUG(10, ("lookup on Domain SID\n")); - if(!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) + if(!get_domain_group_from_sid(group_sid, &map)) return NT_STATUS_NO_SUCH_GROUP; gid=map.gid; @@ -3874,7 +3874,7 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S DEBUG(10, ("lookup on Local SID\n")); - if(!get_local_group_from_sid(alias_sid, &map, MAPPING_WITHOUT_PRIV)) + if(!get_local_group_from_sid(alias_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; gid=map.gid; @@ -3911,12 +3911,9 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S fstring sid_string; struct group *grp; struct samr_info *info; - PRIVILEGE_SET priv_set; uint32 acc_granted; gid_t gid; - init_privilege(&priv_set); - /* Find the policy handle. Open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; @@ -3951,7 +3948,7 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S sid_append_rid(&info_sid, r_u->rid); sid_to_string(sid_string, &info_sid); - if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_DOM_GRP, name, NULL, priv_set, PR_ACCESS_FROM_NETWORK)) + if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_DOM_GRP, name, NULL)) return NT_STATUS_ACCESS_DENIED; if ((info = get_samr_info_by_sid(&info_sid)) == NULL) @@ -3976,12 +3973,9 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S fstring sid_string; struct group *grp; struct samr_info *info; - PRIVILEGE_SET priv_set; uint32 acc_granted; gid_t gid; - init_privilege(&priv_set); - /* Find the policy handle. Open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; @@ -4016,7 +4010,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S sid_to_string(sid_string, &info_sid); /* add the group to the mapping table */ - if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_ALIAS, name, NULL, priv_set, PR_ACCESS_FROM_NETWORK)) + if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_ALIAS, name, NULL)) return NT_STATUS_ACCESS_DENIED; if ((info = get_samr_info_by_sid(&info_sid)) == NULL) @@ -4052,7 +4046,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM return r_u->status; } - if (!get_domain_group_from_sid(group_sid, &map, MAPPING_WITHOUT_PRIV)) + if (!get_domain_group_from_sid(group_sid, &map)) return NT_STATUS_INVALID_HANDLE; ctr=(GROUP_INFO_CTR *)talloc_zero(p->mem_ctx, sizeof(GROUP_INFO_CTR)); @@ -4104,7 +4098,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ return r_u->status; } - if (!get_domain_group_from_sid(group_sid, &map, MAPPING_WITH_PRIV)) + if (!get_domain_group_from_sid(group_sid, &map)) return NT_STATUS_NO_SUCH_GROUP; ctr=q_u->ctr; @@ -4117,17 +4111,13 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ unistr2_to_ascii(map.comment, &(ctr->group.info4.uni_acct_desc), sizeof(map.comment)-1); break; default: - free_privilege(&map.priv_set); return NT_STATUS_INVALID_INFO_CLASS; } if(!pdb_update_group_mapping_entry(&map)) { - free_privilege(&map.priv_set); return NT_STATUS_NO_SUCH_GROUP; } - free_privilege(&map.priv_set); - return NT_STATUS_OK; } @@ -4151,7 +4141,7 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ return r_u->status; } - if (!get_local_group_from_sid(group_sid, &map, MAPPING_WITH_PRIV)) + if (!get_local_group_from_sid(group_sid, &map)) return NT_STATUS_NO_SUCH_GROUP; ctr=&q_u->ctr; @@ -4161,17 +4151,13 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ unistr2_to_ascii(map.comment, &(ctr->alias.info3.uni_acct_desc), sizeof(map.comment)-1); break; default: - free_privilege(&map.priv_set); return NT_STATUS_INVALID_INFO_CLASS; } if(!pdb_update_group_mapping_entry(&map)) { - free_privilege(&map.priv_set); return NT_STATUS_NO_SUCH_GROUP; } - free_privilege(&map.priv_set); - return NT_STATUS_OK; } @@ -4246,7 +4232,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G DEBUG(10, ("_samr_open_group:Opening SID: %s\n", sid_string)); /* check if that group really exists */ - if (!get_domain_group_from_sid(info->sid, &map, MAPPING_WITHOUT_PRIV)) + if (!get_domain_group_from_sid(info->sid, &map)) return NT_STATUS_NO_SUCH_GROUP; /* get a (unique) handle. open a policy on it. */ diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index c43eb22375..a97864dbda 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -148,13 +148,14 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui } for (i=0;i Date: Sun, 22 Jun 2003 10:09:52 +0000 Subject: Found out a good number of NT_STATUS_IS_ERR used the wrong way. As abartlet rememberd me NT_STATUS_IS_ERR != !NT_STATUS_IS_OK This patch will cure the problem. Working on this one I found 16 functions where I think NT_STATUS_IS_ERR() is used correctly, but I'm not 100% sure, coders should check the use of NT_STATUS_IS_ERR() in samba is ok now. Simo. (This used to be commit c501e84d412563eb3f674f76038ec48c2b458687) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- source3/rpc_server/srv_util.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6039cac96c..ebf483da66 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3430,7 +3430,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD } /* check a real user exist before we run the script to add a user to a group */ - if (NT_STATUS_IS_ERR(sid_to_uid(pdb_get_user_sid(sam_user), &uid))) { + if (!NT_STATUS_IS_OK(sid_to_uid(pdb_get_user_sid(sam_user), &uid))) { pdb_free_sam(&sam_user); return NT_STATUS_NO_SUCH_USER; } @@ -3590,7 +3590,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD } /* check a real user exist before we run the script to add a user to a group */ - if (NT_STATUS_IS_ERR(sid_to_uid(pdb_get_user_sid(sam_user), &uid))) { + if (!NT_STATUS_IS_OK(sid_to_uid(pdb_get_user_sid(sam_user), &uid))) { pdb_free_sam(&sam_user); return NT_STATUS_NO_SUCH_USER; } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index a97864dbda..5040b094a8 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -129,7 +129,7 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui fstrcpy(user_name, pdb_get_username(sam_pass)); grid=pdb_get_group_rid(sam_pass); - if (NT_STATUS_IS_ERR(sid_to_gid(pdb_get_group_sid(sam_pass), &gid))) { + if (!NT_STATUS_IS_OK(sid_to_gid(pdb_get_group_sid(sam_pass), &gid))) { /* this should never happen */ DEBUG(2,("get_alias_user_groups: sid_to_gid failed!\n")); pdb_free_sam(&sam_pass); -- cgit From d21358308a2a2c86b4e9d23922c7c940b5d1b012 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 23 Jun 2003 18:29:09 +0000 Subject: wrap group enuemration in brcome/unbecome_root() (bug #110) (This used to be commit 3918fffc7f07202f4c0b940f877184eea7561135) --- source3/rpc_server/srv_util.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 5040b094a8..03e53118a8 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -147,6 +147,8 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui return NT_STATUS_UNSUCCESSFUL; } + become_root(); + for (i=0;i Date: Sun, 29 Jun 2003 03:39:50 +0000 Subject: Here's the code to make winbindd work on a Samba DC to handle domain trusts. Jeremy and I talked about this and it's going in as working code. It keeps winbind clean and solves the trust problem with minimal changes. To summarize, there are 2 basic cases where the deadlock would occur. (1) lookuping up secondary groups for a user, and (2) get[gr|pw]nam() calls that fall through the NSS layer because they don't exist anywhere. o To handle case #1, we bypass winbindd in sys_getgrouplist() unless the username includes the 'winbind separator'. o Case #2 is handled by adding checks in winbindd to return failure if we are a DC and the domain matches our own. This code has been tested using basic share connections, domain logons, and with pam_winbind (both with and without 'winbind use default domain'). The 'trustdomain' auth module should work as well if an admin wants to manually create UNIX users for acounts in the trusted domains. Other misc fixes: * we need to fix check_ntlm_password() to be able to determine if an auth module is authoritative over a user (NT_STATUS_WRONG_PASSWORD, etc...). I worked around my specific situation, but this needs to be fixed. the winbindd auth module was causing delays. * fix named server mutex deadlock between trust domain auth module and winbindd looking up a uid * make sure SAM_ACCOUNT gets stored in the server_info struct for the _net_sam_logon() reply. Configuration details: The recommended method for supporting trusts is to use winbind. The gets us around some of the server mutex issues as well. * set 'files winbind' for passwd: and group: in /etc/nsswitch.conf * create domain trusts like normal * join winbind on the pdc to the Samba domain using 'net rpc join' * add normal parameters to smb.conf for winbind * set 'auth method = guest sam winbind' * start smbd, nmbd, & winbindd Problems that remain: * join a Windows 2k/XP box to a Samba domain. * create a 2-way trust between the Samba domain and an NT domain * logon to the windows client as a user from theh trusted domain * try to browse server in the trusted domain (or other workstations). an NT client seems to work ok, but 2k and XP either prompt for passwords or fail with errors. apparanently this never got tested since no one has ever been able to logon as a trusted user to a Samba domain from a Windows client. (This used to be commit f804b590f9dbf1f0147c06a0a2f12e221ae6fc3b) --- source3/rpc_server/srv_netlog_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index aa573b8154..738ededde1 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -644,7 +644,9 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * p->dc.sess_key)) { status = NT_STATUS_NO_MEMORY; } else { + become_root(); status = auth_context->check_ntlm_password(auth_context, user_info, &server_info); + unbecome_root(); } (auth_context->free)(&auth_context); -- cgit From e359dbcedb53b03df79140c30ecfdfdbcb904595 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 30 Jun 2003 20:45:14 +0000 Subject: * cleanup more DC name resolution issues in check_*domain_security() * is_trusted_domain() is broken without winbind. Still working on this. * get_global_sam_name() should return the workgroup name unless we are a standalone server (verified by volker) * Get_Pwnam() should always fall back to the username (minus domain name) even if it is not our workgroup so that TRUSTEDOMAIN\user can logon if 'user' exists in the local list of accounts (on domain members w/o winbind) Tested using Samba PDC with trusts (running winbindd) and a Samba 3.0 domain member not running winbindd. notes: make_user_info_map() is slightly broken now due to the fact that is_trusted_domain() only works with winbindd. disabled checks temporarily until I can sort this out. (This used to be commit e1d6094d066d4c16ab73075caba40a1ae6c56b1e) --- source3/rpc_server/srv_netlog_nt.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 738ededde1..fa19708773 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -524,6 +524,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * auth_serversupplied_info *server_info = NULL; extern userdom_struct current_user_info; SAM_ACCOUNT *sampw; + struct auth_context *auth_context = NULL; usr_info = (NET_USER_INFO_3 *)talloc(p->mem_ctx, sizeof(NET_USER_INFO_3)); if (!usr_info) @@ -598,10 +599,11 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * DEBUG(5,("Attempting validation level %d for unmapped username %s.\n", q_u->sam_id.ctr->switch_value, nt_username)); + status = NT_STATUS_OK; + switch (ctr->switch_value) { case NET_LOGON_TYPE: { - struct auth_context *auth_context = NULL; if (!NT_STATUS_IS_OK(status = make_auth_context_fixed(&auth_context, ctr->auth.id2.lm_chal))) { return status; } @@ -615,11 +617,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * ctr->auth.id2.nt_chal_resp.buffer, ctr->auth.id2.nt_chal_resp.str_str_len)) { status = NT_STATUS_NO_MEMORY; - } else { - status = auth_context->check_ntlm_password(auth_context, user_info, &server_info); - } - (auth_context->free)(&auth_context); - + } break; } case INTERACTIVE_LOGON_TYPE: @@ -628,8 +626,8 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * convert this to chellange/responce for the auth subsystem to chew on */ { - struct auth_context *auth_context = NULL; const uint8 *chal; + if (!NT_STATUS_IS_OK(status = make_auth_context_subsystem(&auth_context))) { return status; } @@ -643,14 +641,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * ctr->auth.id1.nt_owf.data, p->dc.sess_key)) { status = NT_STATUS_NO_MEMORY; - } else { - become_root(); - status = auth_context->check_ntlm_password(auth_context, user_info, &server_info); - unbecome_root(); } - - (auth_context->free)(&auth_context); - break; } default: @@ -658,6 +649,14 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return NT_STATUS_INVALID_INFO_CLASS; } /* end switch */ + if ( NT_STATUS_IS_OK(status) ) { + become_root(); + status = auth_context->check_ntlm_password(auth_context, + user_info, &server_info); + unbecome_root(); + } + + (auth_context->free)(&auth_context); free_user_info(&user_info); DEBUG(5, ("_net_sam_logon: check_password returned status %s\n", -- cgit From 58fca5074216891bcc9b0c1674b221646af79841 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 1 Jul 2003 21:47:13 +0000 Subject: Adding jcmd's share ACL on XP patch. Thanks Jim ! Jeremy. (This used to be commit 7ed1118ae61a13de2c781a94fc2394090efd1f9b) --- source3/rpc_server/srv_srvsvc_nt.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 57ba055aef..ea66a7d38b 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -432,10 +432,13 @@ static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh100 static void init_srv_share_info_1005(pipes_struct *p, SRV_SHARE_INFO_1005* sh1005, int snum) { - sh1005->dfs_root_flag = 0; + sh1005->share_info_flags = 0; if(lp_host_msdfs() && lp_msdfs_root(snum)) - sh1005->dfs_root_flag = 3; + sh1005->share_info_flags |= + SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT; + sh1005->share_info_flags |= + lp_csc_policy(snum) << SHARE_1005_CSC_POLICY_SHIFT; } /*************************************************************************** Fill in a share info level 1006 structure. @@ -1513,6 +1516,19 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S type = STYPE_DISKTREE; break; case 1005: + /* XP re-sets the csc policy even if it wasn't changed by the + user, so we must compare it to see if it's what is set in + smb.conf, so that we can contine other ops like setting + ACLs on a share */ + if (((q_u->info.share.info1005.share_info_flags & + SHARE_1005_CSC_POLICY_MASK) >> + SHARE_1005_CSC_POLICY_SHIFT) == lp_csc_policy(snum)) + return WERR_OK; + else { + DEBUG(3, ("_srv_net_share_set_info: client is trying to change csc policy from the network; must be done with smb.conf\n")); + return WERR_ACCESS_DENIED; + } + break; case 1006: case 1007: return WERR_ACCESS_DENIED; -- cgit From a31a2c159cd51112abdbe230c7a4df743fe14288 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 3 Jul 2003 03:56:16 +0000 Subject: well this was easy... When winbindd is running on a PDC the SAM_ACCOUNT for a trusted user has a username of DOMAIN\user. Make sure to trim the domain part from the username when filling in the net_sam_logon reply. This fixes the browsing issues i was seen across domain trusts. (This used to be commit 62e36e6ede067ace23f5473d04917c7eeedf07e2) --- source3/rpc_server/srv_netlog_nt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index fa19708773..0dcdf39158 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -732,8 +732,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * init_net_user_info3(p->mem_ctx, usr_info, user_rid, - group_rid, - + group_rid, pdb_get_username(sampw), pdb_get_fullname(sampw), pdb_get_homedir(sampw), -- cgit From 61116049cabc292c2f2d570af4d68ddc537b91f5 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 3 Jul 2003 14:36:42 +0000 Subject: This patch takes the work the jerry did for beta2, and generalises it: - The 'not implmented' checks are now done by all auth modules - the ntdomain/trustdomain/winbind modules are more presise as to what domain names they can and cannot handle - The become_root() calls are now around the winbind pipe opening only, not the entire auth call - The unix username is kept seperate from the NT username, removing the need for 'clean off the domain\' in parse_net.c - All sid->uid translations are now validated with getpwuid() to put a very basic stop to logins with 'half deleted' accounts. Andrew Bartlett (This used to be commit 85f88191b9927cc434645ef4c1eaf5ec0e8af2ec) --- source3/rpc_server/srv_netlog_nt.c | 2 -- source3/rpc_server/srv_pipe.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 0dcdf39158..c4a87d2e26 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -650,10 +650,8 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * } /* end switch */ if ( NT_STATUS_IS_OK(status) ) { - become_root(); status = auth_context->check_ntlm_password(auth_context, user_info, &server_info); - unbecome_root(); } (auth_context->free)(&auth_context); diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 6a9e591f64..f7663204b2 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -464,7 +464,7 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); } fstrcpy(p->user_name, user_name); - fstrcpy(p->pipe_user_name, pdb_get_username(server_info->sam_account)); + fstrcpy(p->pipe_user_name, server_info->unix_name); fstrcpy(p->domain, domain); fstrcpy(p->wks, wks); -- cgit From 6b31240391949fb6afa83853aa3df30b354d508a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 3 Jul 2003 17:18:07 +0000 Subject: Fix for bug #199 (xp driver uploads). Needed to support the "OSVersion" print server data value. (This used to be commit 02bc7be1ac6b75bf6559ea684bbc89ab3e19402e) --- source3/rpc_server/srv_spoolss_nt.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 217d2cbaea..deca2ad8bb 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2339,7 +2339,6 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint return WERR_OK; } -#if 0 /* JERRY */ /* REG_BINARY * uint32 size = 0x114 * uint32 major = 5 @@ -2348,14 +2347,23 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint * extra unicode string = e.g. "Service Pack 3" */ if (!StrCaseCmp(value, "OSVersion")) { - *type = 0x4; - if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) + *type = 0x3; + *needed = 0x114; + + if((*data = (uint8 *)talloc(ctx, (*needed)*sizeof(uint8) )) == NULL) return WERR_NOMEM; - SIVAL(*data, 0, 2); - *needed = 0x4; + ZERO_STRUCTP( *data ); + + SIVAL(*data, 0, *needed); /* size */ + SIVAL(*data, 4, 5); /* Windows 2000 == 5.0 */ + SIVAL(*data, 8, 0); + SIVAL(*data, 12, 2195); /* build */ + + /* leave extra string empty */ + return WERR_OK; } -#endif + if (!StrCaseCmp(value, "DefaultSpoolDirectory")) { fstring string; -- cgit From ce72beb2b558d86fb49063c6b1fa00e07952ce56 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 3 Jul 2003 19:11:31 +0000 Subject: Removed strupper/strlower macros that automatically map to strupper_m/strlower_m. I really want people to think about when they're using multibyte strings. Jeremy. (This used to be commit ff222716a08af65d26ad842ce4c2841cc6540959) --- source3/rpc_server/srv_dfs_nt.c | 2 +- source3/rpc_server/srv_lsa_nt.c | 2 +- source3/rpc_server/srv_samr_nt.c | 4 ++-- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- source3/rpc_server/srv_wkssvc_nt.c | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index da92e5c06b..eba4eaec75 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -135,7 +135,7 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, pstrcpy(altpath, servername); pstrcat(altpath, "\\"); pstrcat(altpath, sharename); - strlower(altpath); + strlower_m(altpath); } DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n", diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 93e97a7492..ca3021a876 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1249,7 +1249,7 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I /* This should be a 'netbios domain -> DNS domain' mapping */ dnsdomname[0] = '\0'; get_mydomname(dnsdomname); - strlower(dnsdomname); + strlower_m(dnsdomname); dns_name = dnsdomname; forest_name = dnsdomname; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ebf483da66..c475260cca 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2225,7 +2225,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ */ rpcstr_pull(account, user_account.buffer, sizeof(account), user_account.uni_str_len*2, 0); - strlower(account); + strlower_m(account); pdb_init_sam(&sam_pass); @@ -2578,7 +2578,7 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN name = get_global_sam_name(); fstrcpy(dom[0],name); - strupper(dom[0]); + strupper_m(dom[0]); fstrcpy(dom[1],"Builtin"); if (!make_enum_domains(p->mem_ctx, &r_u->sam, &r_u->uni_dom_name, num_entries, dom)) diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index deca2ad8bb..2b68e34b2d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4339,7 +4339,7 @@ static BOOL construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *p if (is_printer_published(print_hnd, snum, &guid)) { asprintf(&guid_str, "{%s}", smb_uuid_string_static(guid)); - strupper(guid_str); + strupper_m(guid_str); init_unistr(&printer->guid, guid_str); printer->action = SPOOL_DS_PUBLISH; } else { @@ -4689,7 +4689,7 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ */ unistr2_to_ascii(name, servername, sizeof(name)-1); - strupper(name); + strupper_m(name); switch (level) { case 1: diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index bda7b14a42..25fa029237 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -40,10 +40,10 @@ static void create_wks_info_100(WKS_INFO_100 *inf) DEBUG(5,("create_wks_info_100: %d\n", __LINE__)); pstrcpy (my_name, global_myname()); - strupper(my_name); + strupper_m(my_name); pstrcpy (domain, lp_workgroup()); - strupper(domain); + strupper_m(domain); init_wks_info_100(inf, 0x000001f4, /* platform id info */ -- cgit From e4bfa0a4608d794fd0c6228b58469ddf5473b7b4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 8 Jul 2003 21:58:29 +0000 Subject: Moved SAM_ACCOUNT marshall/unmarshall functions to make them externally available. Removed extra auth_init (thanks metze). Jeremy. (This used to be commit 88135fbc4998c266052647f8b8e437ac01cf50ae) --- source3/rpc_server/srv_samr_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c475260cca..1628a51e53 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -151,10 +151,10 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) return info; } - /******************************************************************* Function to free the per handle data. ********************************************************************/ + static void free_samr_users(struct samr_info *info) { int i; @@ -169,10 +169,10 @@ static void free_samr_users(struct samr_info *info) info->disp_info.num_user_account=0; } - /******************************************************************* Function to free the per handle data. ********************************************************************/ + static void free_samr_db(struct samr_info *info) { /* Groups are talloced */ @@ -183,7 +183,6 @@ static void free_samr_db(struct samr_info *info) info->disp_info.num_group_account=0; } - static void free_samr_info(void *ptr) { struct samr_info *info=(struct samr_info *) ptr; @@ -1128,6 +1127,7 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S /******************************************************************* samr_reply_query_dispinfo ********************************************************************/ + NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_QUERY_DISPINFO *r_u) { -- cgit From 4072006fecf56bebf113fe1d4566156c0d89bacc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 9 Jul 2003 00:23:42 +0000 Subject: Get rid of DISP_USER_INFO/DISP_GROUP_INFO as they serve no useful purpose. Replace with an array of SAM_ACCOUNT/DOMAIN_GRP entries. ZERO struct's in smbd/uid.c stops core dumps when sid_to_XX functions fail. Getting ready to add caching. Jeremy. (This used to be commit 9d0692a54fe2cb087f25796ec2ab5e1d8433e388) --- source3/rpc_server/srv_samr_nt.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1628a51e53..e43cf4f759 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -44,10 +44,10 @@ extern rid_name builtin_alias_rids[]; typedef struct _disp_info { BOOL user_dbloaded; uint32 num_user_account; - DISP_USER_INFO *disp_user_info; + SAM_ACCOUNT *disp_user_info; BOOL group_dbloaded; uint32 num_group_account; - DISP_GROUP_INFO *disp_group_info; + DOMAIN_GRP *disp_group_info; } DISP_INFO; struct samr_info { @@ -161,8 +161,9 @@ static void free_samr_users(struct samr_info *info) if (info->disp_info.user_dbloaded){ for (i=0; idisp_info.num_user_account; i++) { + SAM_ACCOUNT *sam = &info->disp_info.disp_user_info[i]; /* Not really a free, actually a 'clear' */ - pdb_free_sam(&info->disp_info.disp_user_info[i].sam); + pdb_free_sam(&sam); } } info->disp_info.user_dbloaded=False; @@ -211,7 +212,7 @@ static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOOL all_machines) { SAM_ACCOUNT *pwd = NULL; - DISP_USER_INFO *pwd_array = NULL; + SAM_ACCOUNT *pwd_array = NULL; NTSTATUS nt_status = NT_STATUS_OK; TALLOC_CTX *mem_ctx = info->mem_ctx; @@ -254,8 +255,8 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOO if (info->disp_info.num_user_account % MAX_SAM_ENTRIES == 0) { DEBUG(10,("load_sampwd_entries: allocating more memory\n")); - pwd_array=(DISP_USER_INFO *)talloc_realloc(mem_ctx, info->disp_info.disp_user_info, - (info->disp_info.num_user_account+MAX_SAM_ENTRIES)*sizeof(DISP_USER_INFO)); + pwd_array=(SAM_ACCOUNT *)talloc_realloc(mem_ctx, info->disp_info.disp_user_info, + (info->disp_info.num_user_account+MAX_SAM_ENTRIES)*sizeof(SAM_ACCOUNT)); if (pwd_array==NULL) return NT_STATUS_NO_MEMORY; @@ -263,8 +264,8 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOO info->disp_info.disp_user_info=pwd_array; } - /* link the SAM_ACCOUNT to the array */ - info->disp_info.disp_user_info[info->disp_info.num_user_account].sam=pwd; + /* Copy the SAM_ACCOUNT into the array */ + info->disp_info.disp_user_info[info->disp_info.num_user_account]=*pwd; DEBUG(10,("load_sampwd_entries: entry: %d\n", info->disp_info.num_user_account)); @@ -287,7 +288,7 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOO static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) { GROUP_MAP *map=NULL; - DISP_GROUP_INFO *grp_array = NULL; + DOMAIN_GRP *grp_array = NULL; uint32 group_entries = 0; uint32 i; TALLOC_CTX *mem_ctx = info->mem_ctx; @@ -312,8 +313,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) info->disp_info.num_group_account=group_entries; - grp_array=(DISP_GROUP_INFO *)talloc(mem_ctx, info->disp_info.num_group_account*sizeof(DISP_GROUP_INFO)); - + grp_array=(DOMAIN_GRP *)talloc(mem_ctx, info->disp_info.num_group_account*sizeof(DOMAIN_GRP)); if (group_entries!=0 && grp_array==NULL) { DEBUG(1, ("load_group_domain_entries: talloc() failed for grp_array!\n")); SAFE_FREE(map); @@ -323,13 +323,10 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) info->disp_info.disp_group_info=grp_array; for (i=0; iname, map[i].nt_name); - fstrcpy(grp_array[i].grp->comment, map[i].comment); - sid_split_rid(&map[i].sid, &grp_array[i].grp->rid); - grp_array[i].grp->attr=SID_NAME_DOM_GRP; + fstrcpy(grp_array[i].name, map[i].nt_name); + fstrcpy(grp_array[i].comment, map[i].comment); + sid_split_rid(&map[i].sid, &grp_array[i].rid); + grp_array[i].attr=SID_NAME_DOM_GRP; } SAFE_FREE(map); @@ -690,7 +687,7 @@ makes a SAM_ENTRY / UNISTR2* structure from a user list. ********************************************************************/ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNISTR2 **uni_name_pp, - uint32 num_entries, uint32 start_idx, DISP_USER_INFO *disp_user_info, + uint32 num_entries, uint32 start_idx, SAM_ACCOUNT *disp_user_info, DOM_SID *domain_sid) { uint32 i; @@ -720,7 +717,7 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UN } for (i = 0; i < num_entries; i++) { - pwd = disp_user_info[i+start_idx].sam; + pwd = &disp_user_info[i+start_idx]; temp_name = pdb_get_username(pwd); init_unistr2(&uni_temp_name, temp_name, strlen(temp_name)+1); user_sid = pdb_get_user_sid(pwd); -- cgit From 16ff7b26f6b9d288cbd1d39e075b637e24da13a6 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 9 Jul 2003 16:44:47 +0000 Subject: Large set of changes to add UNIX account/group management to winbindd. See README.idmap-and-winbind-changes for details. (This used to be commit 1111bc7b0c7165e1cdf8d90eb49f4c368d2eded6) --- source3/rpc_server/srv_samr_nt.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e43cf4f759..dfa3a8b62e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2259,17 +2259,13 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ */ DEBUG(10,("checking account %s at pos %d for $ termination\n",account, strlen(account)-1)); -#if 0 - if ((acb_info & ACB_WSTRUST) && (account[strlen(account)-1] == '$')) { - pstrcpy(add_script, lp_addmachine_script()); - } else if ((!(acb_info & ACB_WSTRUST)) && (account[strlen(account)-1] != '$')) { - pstrcpy(add_script, lp_adduser_script()); - } else { - DEBUG(0, ("_api_samr_create_user: mismatch between trust flags and $ termination\n")); - pdb_free_sam(&sam_pass); - return NT_STATUS_UNSUCCESSFUL; - } -#endif + + /* + * we used to have code here that made sure the acb_info flags + * matched with the users named (e.g. an account flags as a machine + * trust account ended in '$'). It has been ifdef'd out for a long + * time, so I replaced it with this comment. --jerry + */ /* the passdb lookup has failed; check to see if we need to run the add user/machine script */ @@ -2295,11 +2291,17 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ add_ret = smbrun(add_script,NULL); DEBUG(3,("_api_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); } + else /* no add user script -- ask winbindd to do it */ + { + if ( !winbind_create_user( account ) ) + DEBUG(3,("_api_samr_create_user: winbind_create_user(%s) failed\n", account)); + } } - nt_status = pdb_init_sam_new(&sam_pass, account); - if (!NT_STATUS_IS_OK(nt_status)) + /* implicit call to getpwnam() next */ + + if ( !NT_STATUS_IS_OK(nt_status = pdb_init_sam_new(&sam_pass, account)) ) return nt_status; pdb_set_acct_ctrl(sam_pass, acb_info, PDB_CHANGED); -- cgit From 03d5867d529f126da368ebda70bf2d997aa602e0 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 11 Jul 2003 05:33:40 +0000 Subject: moving more code around. * move rid allocation into IDMAP. See comments in _api_samr_create_user() * add winbind delete user/group functions I'm checking this in to sync up with everyone. But I'm going to split the add a separate winbindd_allocate_rid() function for systems that have an 'add user script' but need idmap to give them a RID. Life would be so much simplier without 'enable rid algorithm'. The current RID allocation is horrible due to this one fact. Tested idmap_tdb but not idmap_ldap yet. Will do that tomorrow. Nothing has changed in the way a samba domain is represented, stored, or search in the directory so things should be ok with previous installations. going to bed now. (This used to be commit 0463045cc7ff177fab44b25faffad5bf7140244d) --- source3/rpc_server/srv_samr_nt.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index dfa3a8b62e..9324fd4765 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2204,6 +2204,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ uint32 acc_granted; SEC_DESC *psd; size_t sd_size; + uint32 new_rid = 0; /* check this, when giving away 'add computer to domain' privs */ uint32 des_access = GENERIC_RIGHTS_USER_ALL_ACCESS; @@ -2272,6 +2273,17 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ pw = Get_Pwnam(account); + /********************************************************************* + * HEADS UP! If we have to create a new user account, we have to get + * a new RID from somewhere. This used to be done by the passdb + * backend. It has been moved into idmap now. Since idmap is now + * wrapped up behind winbind, this means you have to run winbindd if you + * want new accounts to get a new RID when "enable rid algorithm = no". + * Tough. We now have a uniform way of allocating RIDs regardless + * of what ever passdb backend people may use. + * --jerry (2003-07-10) + *********************************************************************/ + if ( !pw ) { /* * we can't check both the ending $ and the acb_info. @@ -2293,15 +2305,17 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ } else /* no add user script -- ask winbindd to do it */ { - if ( !winbind_create_user( account ) ) - DEBUG(3,("_api_samr_create_user: winbind_create_user(%s) failed\n", account)); + if ( !winbind_create_user( account, &new_rid ) ) { + DEBUG(3,("_api_samr_create_user: winbind_create_user(%s) failed\n", + account)); + } } } - /* implicit call to getpwnam() next */ + /* implicit call to getpwnam() next. we have a valid SID coming out of this call */ - if ( !NT_STATUS_IS_OK(nt_status = pdb_init_sam_new(&sam_pass, account)) ) + if ( !NT_STATUS_IS_OK(nt_status = pdb_init_sam_new(&sam_pass, account, new_rid)) ) return nt_status; pdb_set_acct_ctrl(sam_pass, acb_info, PDB_CHANGED); @@ -3711,12 +3725,25 @@ static int smb_delete_user(const char *unix_user) pstring del_script; int ret; + /* try winbindd first since it is impossible to determine where + a user came from via NSS. Try the delete user script if this fails + meaning the user did not exist in winbindd's list of accounts */ + + if ( winbind_delete_user( unix_user ) ) { + DEBUG(3,("winbind_delete_user: removed user (%s)\n", unix_user)); + return 0; + } + + + /* fall back to 'delete user script' */ + pstrcpy(del_script, lp_deluser_script()); if (! *del_script) return -1; all_string_sub(del_script, "%u", unix_user, sizeof(pstring)); ret = smbrun(del_script,NULL); DEBUG(3,("smb_delete_user: Running the command `%s' gave %d\n",del_script,ret)); + return ret; } -- cgit From 456f51bcbe04ccbb37a27b6e115a851cc134adcd Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 14 Jul 2003 08:46:32 +0000 Subject: Jeremy requested that I get my NTLMSSP patch into CVS. He didn't request the schannel code, but I've included that anyway. :-) This patch revives the client-side NTLMSSP support for RPC named pipes in Samba, and cleans up the client and server schannel code. The use of the new code is enabled by the 'sign', 'seal' and 'schannel' commands in rpcclient. The aim was to prove that our separate NTLMSSP client library actually implements NTLMSSP signing and sealing as per Microsoft's NTLMv1 implementation, in the hope that knowing this will assist us in correctly implementing NTLMSSP signing for SMB packets. (Still not yet functional) This patch replaces the NTLMSSP implementation in rpc_client/cli_pipe.c with calls to libsmb/ntlmssp.c. In the process, we have gained the ability to use the more secure NT password, and the ability to sign-only, instead of having to seal the pipe connection. (Previously we were limited to sealing, and could only use the LM-password derived key). Our new client-side NTLMSSP code also needed alteration to cope with our comparatively simple server-side implementation. A future step is to replace it with calls to the same NTLMSSP library. Also included in this patch is the schannel 'sign only' patch I submitted to the team earlier. While not enabled (and not functional, at this stage) the work in this patch makes the code paths *much* easier to follow. I have also included similar hooks in rpccleint to allow the use of schannel on *any* pipe. rpcclient now defaults to not using schannel (or any other extra per-pipe authenticiation) for any connection. The 'schannel' command enables schannel for all pipes until disabled. This code is also much more secure than the previous code, as changes to our cli_pipe routines ensure that the authentication footer cannot be removed by an attacker, and more error states are correctly handled. (The same needs to be done to our server) Andrew Bartlett (This used to be commit 5472ddc9eaf4e79c5b2e1c8ee8c7f190dc285f19) --- source3/rpc_server/srv_pipe.c | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index f7663204b2..9a63ebc7a3 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -227,7 +227,7 @@ BOOL create_next_pdu(pipes_struct *p) if (auth_seal || auth_verify) { RPC_HDR_AUTH auth_info; - init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, NTLMSSP_AUTH_LEVEL, + init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, RPC_PIPE_AUTH_SEAL_LEVEL, (auth_verify ? RPC_HDR_AUTH_LEN : 0), (auth_verify ? 1 : 0)); if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_AUTH.\n")); @@ -263,11 +263,9 @@ BOOL create_next_pdu(pipes_struct *p) prs_struct rverf; prs_struct rauth; - uchar sign[8]; - data = prs_data_p(&outgoing_pdu) + data_pos; - init_rpc_hdr_auth(&auth_info, NETSEC_AUTH_TYPE, NETSEC_AUTH_LEVEL, + init_rpc_hdr_auth(&auth_info, NETSEC_AUTH_TYPE, RPC_PIPE_AUTH_SEAL_LEVEL, RPC_HDR_AUTH_LEN, 1); if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { @@ -284,12 +282,12 @@ BOOL create_next_pdu(pipes_struct *p) p->netsec_auth.seq_num)); } - RSIVAL(sign, 0, p->netsec_auth.seq_num); - SIVAL(sign, 4, 0); - - init_rpc_auth_netsec_chk(&verf, netsec_sig, nullbytes, sign, nullbytes); + init_rpc_auth_netsec_chk(&verf, netsec_sig, nullbytes, nullbytes, nullbytes); - netsec_encode(&p->netsec_auth, &verf, data, data_len); + netsec_encode(&p->netsec_auth, + AUTH_PIPE_NETSEC|AUTH_PIPE_SIGN|AUTH_PIPE_SEAL, + SENDER_IS_ACCEPTOR, + &verf, data, data_len); smb_io_rpc_auth_netsec_chk("", &verf, &outgoing_pdu, 0); @@ -458,6 +456,10 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); p->ntlmssp_hash[256] = 0; p->ntlmssp_hash[257] = 0; } + + dump_data_pw("NTLMSSP hash (v1)\n", p->ntlmssp_hash, + sizeof(p->ntlmssp_hash)); + /* NTLMSSPhash(p->ntlmssp_hash, p24); */ p->ntlmssp_seq_num = 0; @@ -546,7 +548,7 @@ BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *rpc_in_p) return False; } - if (autha_info.auth_type != NTLMSSP_AUTH_TYPE || autha_info.auth_level != NTLMSSP_AUTH_LEVEL) { + if (autha_info.auth_type != NTLMSSP_AUTH_TYPE || autha_info.auth_level != RPC_PIPE_AUTH_SEAL_LEVEL) { DEBUG(0,("api_pipe_bind_auth_resp: incorrect auth type (%d) or level (%d).\n", (int)autha_info.auth_type, (int)autha_info.auth_level )); return False; @@ -1070,7 +1072,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) /*** Authentication info ***/ - init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, NTLMSSP_AUTH_LEVEL, RPC_HDR_AUTH_LEN, 1); + init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, RPC_PIPE_AUTH_SEAL_LEVEL, RPC_HDR_AUTH_LEN, 1); if(!smb_io_rpc_hdr_auth("", &auth_info, &out_auth, 0)) { DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_AUTH failed.\n")); goto err_exit; @@ -1105,7 +1107,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) re-used from the auth2 the client did before. */ p->dc = last_dcinfo; - init_rpc_hdr_auth(&auth_info, NETSEC_AUTH_TYPE, NETSEC_AUTH_LEVEL, RPC_HDR_AUTH_LEN, 1); + init_rpc_hdr_auth(&auth_info, NETSEC_AUTH_TYPE, RPC_PIPE_AUTH_SEAL_LEVEL, RPC_HDR_AUTH_LEN, 1); if(!smb_io_rpc_hdr_auth("", &auth_info, &out_auth, 0)) { DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_AUTH failed.\n")); goto err_exit; @@ -1226,7 +1228,14 @@ BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) * has already been consumed. */ char *data = prs_data_p(rpc_in) + RPC_HDR_REQ_LEN; + dump_data_pw("NTLMSSP hash (v1)\n", p->ntlmssp_hash, + sizeof(p->ntlmssp_hash)); + + dump_data_pw("Incoming RPC PDU (NTLMSSP sealed)\n", + data, data_len); NTLMSSPcalc_p(p, (uchar*)data, data_len); + dump_data_pw("Incoming RPC PDU (NTLMSSP unsealed)\n", + data, data_len); crc32 = crc32_calc_buffer(data, data_len); } @@ -1335,7 +1344,7 @@ BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) } if ((auth_info.auth_type != NETSEC_AUTH_TYPE) || - (auth_info.auth_level != NETSEC_AUTH_LEVEL)) { + (auth_info.auth_level != RPC_PIPE_AUTH_SEAL_LEVEL)) { DEBUG(0,("Invalid auth info %d or level %d on schannel\n", auth_info.auth_type, auth_info.auth_level)); return False; @@ -1346,7 +1355,10 @@ BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) return False; } - if (!netsec_decode(&p->netsec_auth, &netsec_chk, + if (!netsec_decode(&p->netsec_auth, + AUTH_PIPE_NETSEC|AUTH_PIPE_SIGN|AUTH_PIPE_SEAL, + SENDER_IS_INITIATOR, + &netsec_chk, prs_data_p(rpc_in)+old_offset, data_len)) { DEBUG(0,("failed to decode PDU\n")); return False; -- cgit From eb2b68302205e6dc217a4abdef494c45e9fc3cc0 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 14 Jul 2003 19:51:34 +0000 Subject: fix cache coherency bug in print handle print_info_2 cache. Needs to be rewritten to use a reference counter, but this will work for now. also the memory allocation in the printing code needs to be cleaned up to use talloc exclusively. (This used to be commit 3d293027563b36411b7f84ed9d8f47f926271c6f) --- source3/rpc_server/srv_spoolss_nt.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2b68e34b2d..2d316051af 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -273,7 +273,34 @@ static Printer_entry *find_printer_index_by_hnd(pipes_struct *p, POLICY_HND *hnd } /**************************************************************************** - find printer index by handle + look for a printer object cached on an open printer handle +****************************************************************************/ + +WERROR find_printer_in_print_hnd_cache( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL_2 **info2, + const char *printername ) +{ + Printer_entry *p; + + DEBUG(10,("find_printer_in_print_hnd_cache: printer [%s]\n", printername)); + + for ( p=printers_list; p; p=p->next ) + { + if ( p->printer_type==PRINTER_HANDLE_IS_PRINTER + && p->printer_info + && StrCaseCmp(p->dev.handlename, printername) == 0 ) + { + DEBUG(10,("Found printer\n")); + *info2 = dup_printer_2( ctx, p->printer_info->info_2 ); + if ( *info2 ) + return WERR_OK; + } + } + + return WERR_INVALID_PRINTER_NAME; +} + +/**************************************************************************** + destroy any cached printer_info_2 structures on open handles ****************************************************************************/ void invalidate_printer_hnd_cache( char *printername ) -- cgit From 4c53bb6b90fec8e03c812a70a84889fcdf3b1081 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 17 Jul 2003 01:34:05 +0000 Subject: In the presense of RPC fragments, schannel is not strictly request/reply, so the shared sequence number will not be strictly odd/even. Andrew Bartlett (This used to be commit 77c3e69aef545d3f9b7cec9efdc366cbeb0c745e) --- source3/rpc_server/srv_pipe.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 9a63ebc7a3..acc62880d0 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -277,11 +277,6 @@ BOOL create_next_pdu(pipes_struct *p) prs_init(&rverf, 0, p->mem_ctx, MARSHALL); prs_init(&rauth, 0, p->mem_ctx, MARSHALL); - if ((p->netsec_auth.seq_num & 1) == 0) { - DEBUG(0,("SCHANNEL ERROR: seq_num must be odd in server! (seq_num=%d)\n", - p->netsec_auth.seq_num)); - } - init_rpc_auth_netsec_chk(&verf, netsec_sig, nullbytes, nullbytes, nullbytes); netsec_encode(&p->netsec_auth, -- cgit From 06345b81164d575bc1faf537e3c48a5dfe8e2442 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 22 Jul 2003 01:18:24 +0000 Subject: Use %p for a pointer type in a printf-style format string. Also casting a pointer to a uint32 value is incorrect on a 64-bit architecture. (This used to be commit afed2cbbcc07de9e453156972250f5f9d22e8e83) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2d316051af..c7fab32957 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -563,7 +563,7 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3 new_printer->notify.option=NULL; - if ( !(new_printer->ctx = talloc_init("Printer Entry [0x%x]", (uint32)hnd)) ) { + if ( !(new_printer->ctx = talloc_init("Printer Entry [%p]", hnd)) ) { DEBUG(0,("open_printer_hnd: talloc_init() failed!\n")); close_printer_handle(p, hnd); return False; -- cgit From c9bc4b27b71f6baaa9dde1722061f3d59d8554bc Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 22 Jul 2003 06:52:39 +0000 Subject: Another round of uid/gid/pid format string changes I missed the first time. (This used to be commit 6616485dbad74dab7506609c6bfd183fc9c1f93c) --- source3/rpc_server/srv_samr_nt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9324fd4765..99970197c7 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2761,8 +2761,9 @@ static BOOL set_unix_primary_group(SAM_ACCOUNT *sampass) grp = getgrgid(gid); if (grp == NULL) { - DEBUG(2,("Could not find primary group %d for " - "user %s\n", gid, pdb_get_username(sampass))); + DEBUG(2,("Could not find primary group %lu for " + "user %s\n", (unsigned long)gid, + pdb_get_username(sampass))); return False; } -- cgit From c085ace063872bc0152989ae33764341775708ad Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 23 Jul 2003 06:11:38 +0000 Subject: Typo in comment. (This used to be commit 6a9bfcd3b8996a0322f733689fd5e8bf24f224c8) --- source3/rpc_server/srv_netlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index c4a87d2e26..602cd7d2d5 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997. * Copyright (C) Jeremy Allison 1998-2001. - * Copyirht (C) Andrew Bartlett 2001. + * Copyright (C) Andrew Bartlett 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- cgit From 3a5dc7c2ecacecf7dd0cfd71ff1bb298d70b391b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 23 Jul 2003 12:33:59 +0000 Subject: convert snprintf() calls using pstrings & fstrings to pstr_sprintf() and fstr_sprintf() to try to standardize. lots of snprintf() calls were using len-1; some were using len. At least this helps to be consistent. (This used to be commit 9f835b85dd38cbe655eb19021ff763f31886ac00) --- source3/rpc_server/srv_reg_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 5632544909..a4e3638be6 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -596,11 +596,11 @@ NTSTATUS _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u /* security check */ alpha_strcpy (chkmsg, message, NULL, sizeof(message)); /* timeout */ - snprintf(timeout, sizeof(timeout), "%d", q_u->timeout); + fstr_sprintf(timeout, "%d", q_u->timeout); /* reboot */ - snprintf(r, sizeof(r), (q_u->reboot) ? SHUTDOWN_R_STRING : ""); + fstr_sprintf(r, (q_u->reboot) ? SHUTDOWN_R_STRING : ""); /* force */ - snprintf(f, sizeof(f), (q_u->force) ? SHUTDOWN_F_STRING : ""); + fstr_sprintf(f, (q_u->force) ? SHUTDOWN_F_STRING : ""); pstrcpy(shutdown_script, lp_shutdown_script()); -- cgit From 77373f1f8e3b2f61e9bbcd9fadfb83257d390cf2 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 24 Jul 2003 23:46:27 +0000 Subject: More printf fixes - size_t is long on some architectures. (This used to be commit ba4d334b822248d8ab929c9568533431603d967e) --- source3/rpc_server/srv_samr_nt.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 99970197c7..d7238463f6 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2259,7 +2259,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ * now have some sainity-checking to match. */ - DEBUG(10,("checking account %s at pos %d for $ termination\n",account, strlen(account)-1)); + DEBUG(10,("checking account %s at pos %l for $ termination\n",account, strlen(account)-1)); /* * we used to have code here that made sure the acb_info flags diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c7fab32957..a33179d054 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -478,7 +478,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) fstring sname; BOOL found=False; - DEBUG(4,("Setting printer name=%s (len=%d)\n", handlename, strlen(handlename))); + DEBUG(4,("Setting printer name=%s (len=%l)\n", handlename, strlen(handlename))); if (Printer->printer_type==PRINTER_HANDLE_IS_PRINTSERVER) { ZERO_STRUCT(Printer->dev.printerservername); @@ -497,7 +497,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) aprinter=handlename; } - DEBUGADD(5,("searching for [%s] (len=%d)\n", aprinter, strlen(aprinter))); + DEBUGADD(5,("searching for [%s] (len=%l)\n", aprinter, strlen(aprinter))); /* * The original code allowed smbd to store a printer name that @@ -1176,7 +1176,7 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz msg_count = IVAL(buf, 0); msg_ptr = buf + 4; - DEBUG(5, ("receive_notify2_message_list: got %d messages in list\n", msg_count)); + DEBUG(5, ("receive_notify2_message_list: got %l messages in list\n", msg_count)); if (msg_count == 0) { DEBUG(0,("receive_notify2_message_list: bad message format (msg_count == 0) !\n")); @@ -5135,7 +5135,7 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, const c else pstrcpy( line, v ); - DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); + DEBUGADD(6,("%d:%s:%l\n", i, line, strlen(line))); /* add one extra unit16 for the second terminating NULL */ @@ -9092,7 +9092,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ { if ( (enum_values=talloc(p->mem_ctx, num_entries*sizeof(PRINTER_ENUM_VALUES))) == NULL ) { - DEBUG(0,("_spoolss_enumprinterdataex: talloc() failed to allocate memory for [%d] bytes!\n", + DEBUG(0,("_spoolss_enumprinterdataex: talloc() failed to allocate memory for [%l] bytes!\n", num_entries*sizeof(PRINTER_ENUM_VALUES))); result = WERR_NOMEM; goto done; -- cgit From 7d833de662b83f026b54a236588da27dd8899630 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 25 Jul 2003 04:24:40 +0000 Subject: More printf portability fixes. Got caught out by some gcc'isms last time. )-: (This used to be commit 59dae1da66a5eb7e128263bd578f167d8746e9f0) --- source3/rpc_server/srv_samr_nt.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d7238463f6..2f7101fcc2 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2259,7 +2259,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ * now have some sainity-checking to match. */ - DEBUG(10,("checking account %s at pos %l for $ termination\n",account, strlen(account)-1)); + DEBUG(10,("checking account %s at pos %lu for $ termination\n",account, (unsigned long)strlen(account)-1)); /* * we used to have code here that made sure the acb_info flags diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a33179d054..0f984019e9 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -478,7 +478,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) fstring sname; BOOL found=False; - DEBUG(4,("Setting printer name=%s (len=%l)\n", handlename, strlen(handlename))); + DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename, (unsigned long)strlen(handlename))); if (Printer->printer_type==PRINTER_HANDLE_IS_PRINTSERVER) { ZERO_STRUCT(Printer->dev.printerservername); @@ -497,7 +497,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) aprinter=handlename; } - DEBUGADD(5,("searching for [%s] (len=%l)\n", aprinter, strlen(aprinter))); + DEBUGADD(5,("searching for [%s] (len=%lu)\n", aprinter, (unsigned long)strlen(aprinter))); /* * The original code allowed smbd to store a printer name that @@ -1176,7 +1176,7 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz msg_count = IVAL(buf, 0); msg_ptr = buf + 4; - DEBUG(5, ("receive_notify2_message_list: got %l messages in list\n", msg_count)); + DEBUG(5, ("receive_notify2_message_list: got %lu messages in list\n", (unsigned long)msg_count)); if (msg_count == 0) { DEBUG(0,("receive_notify2_message_list: bad message format (msg_count == 0) !\n")); @@ -5135,7 +5135,7 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, const c else pstrcpy( line, v ); - DEBUGADD(6,("%d:%s:%l\n", i, line, strlen(line))); + DEBUGADD(6,("%d:%s:%lu\n", i, line, (unsigned long)strlen(line))); /* add one extra unit16 for the second terminating NULL */ @@ -9092,8 +9092,8 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ { if ( (enum_values=talloc(p->mem_ctx, num_entries*sizeof(PRINTER_ENUM_VALUES))) == NULL ) { - DEBUG(0,("_spoolss_enumprinterdataex: talloc() failed to allocate memory for [%l] bytes!\n", - num_entries*sizeof(PRINTER_ENUM_VALUES))); + DEBUG(0,("_spoolss_enumprinterdataex: talloc() failed to allocate memory for [%lu] bytes!\n", + (unsigned long)num_entries*sizeof(PRINTER_ENUM_VALUES))); result = WERR_NOMEM; goto done; } -- cgit From 6bf70229ae11147496ac7318a3c980c3b985ce8b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 25 Jul 2003 14:35:17 +0000 Subject: fix some error returns and strings; patch from metze (This used to be commit 948b1b138cf1fce18c93645fbdf948e589b19dc5) --- source3/rpc_server/srv_spoolss_nt.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0f984019e9..8237298ebb 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2393,9 +2393,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "DefaultSpoolDirectory")) { - fstring string; - - fstrcpy(string, string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); + const char *string="C:\\PRINTERS"; *type = 0x1; *needed = 2*(strlen(string)+1); if((*data = (uint8 *)talloc(ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) @@ -2411,7 +2409,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint } if (!StrCaseCmp(value, "Architecture")) { - pstring string="Windows NT x86"; + const char *string="Windows NT x86"; *type = 0x1; *needed = 2*(strlen(string)+1); if((*data = (uint8 *)talloc(ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) @@ -7912,6 +7910,11 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP return WERR_BADFID; } + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER ) { + DEBUG(10,("_spoolss_setprinterdata: Not implemented for server handles yet\n")); + return WERR_INVALID_PARAM; + } + if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; @@ -8698,7 +8701,7 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, /* Is the handle to a printer or to the server? */ if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) { - DEBUG(10,("_spoolss_getprinterdatex: Not implemented for server handles yet\n")); + DEBUG(10,("_spoolss_getprinterdataex: Not implemented for server handles yet\n")); status = WERR_INVALID_PARAM; goto done; } @@ -8780,10 +8783,15 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, SetPrinterData if key is "PrinterDriverData" */ if (!Printer) { - DEBUG(2,("_spoolss_setprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_setprinterdataex: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER ) { + DEBUG(10,("_spoolss_setprinterdataex: Not implemented for server handles yet\n")); + return WERR_INVALID_PARAM; + } + if ( !get_printer_snum(p,handle, &snum) ) return WERR_BADFID; -- cgit From ba12e6bb5fcfbf4bdba8f2c38978d38e1f857286 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 31 Jul 2003 01:33:44 +0000 Subject: Wrap calls to change_oem_password() in become_root()/unbecome_root() pairs to allow UNIX password change scripts to work correctly. This is safe as the old password has been checked as correct before invoking this. Jeremy. (This used to be commit 1734d43eb55561d46a6ffb5d806afedfd3746f9f) --- source3/rpc_server/srv_samr_nt.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2f7101fcc2..ea014d7ce0 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1517,17 +1517,17 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO NTSTATUS _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_R_CHGPASSWD_USER *r_u) { - fstring user_name; - fstring wks; + fstring user_name; + fstring wks; - DEBUG(5,("_samr_chgpasswd_user: %d\n", __LINE__)); + DEBUG(5,("_samr_chgpasswd_user: %d\n", __LINE__)); - r_u->status = NT_STATUS_OK; + r_u->status = NT_STATUS_OK; - rpcstr_pull(user_name, q_u->uni_user_name.buffer, sizeof(user_name), q_u->uni_user_name.uni_str_len*2, 0); - rpcstr_pull(wks, q_u->uni_dest_host.buffer, sizeof(wks), q_u->uni_dest_host.uni_str_len*2,0); + rpcstr_pull(user_name, q_u->uni_user_name.buffer, sizeof(user_name), q_u->uni_user_name.uni_str_len*2, 0); + rpcstr_pull(wks, q_u->uni_dest_host.buffer, sizeof(wks), q_u->uni_dest_host.uni_str_len*2,0); - DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); + DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); /* * Pass the user through the NT -> unix user mapping @@ -1541,14 +1541,14 @@ NTSTATUS _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_ * is case insensitive. */ - r_u->status = pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, - q_u->nt_newpass.pass, q_u->nt_oldhash.hash); + r_u->status = pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, + q_u->nt_newpass.pass, q_u->nt_oldhash.hash); - init_samr_r_chgpasswd_user(r_u, r_u->status); + init_samr_r_chgpasswd_user(r_u, r_u->status); - DEBUG(5,("_samr_chgpasswd_user: %d\n", __LINE__)); + DEBUG(5,("_samr_chgpasswd_user: %d\n", __LINE__)); - return r_u->status; + return r_u->status; } /******************************************************************* -- cgit From f210ee9b99b3b6ac0234680f1af83fd783ef9af4 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 1 Aug 2003 14:47:39 +0000 Subject: Fix copyright statements for various pieces of Anthony Liguori's work. (This used to be commit 15d2bc47854df75f8b2644ccbc887d0357d9cd27) --- source3/rpc_server/srv_dfs.c | 2 +- source3/rpc_server/srv_lsa.c | 3 +-- source3/rpc_server/srv_netlog.c | 2 +- source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_reg.c | 2 +- source3/rpc_server/srv_samr.c | 3 +-- source3/rpc_server/srv_samr_nt.c | 1 - source3/rpc_server/srv_spoolss.c | 2 +- source3/rpc_server/srv_srvsvc.c | 2 +- source3/rpc_server/srv_wkssvc.c | 2 +- 10 files changed, 9 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 75a24174ea..093763fec0 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Shirish Kalele 2000, * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Anthony Liguori 2003. + * Copyright (C) Jim McDonough 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 679cfb73bb..47a9646950 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -5,8 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Jim McDonough 2002, - * Copyright (C) Anthony Liguori 2003. + * Copyright (C) Jim McDonough 2002-2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 0cd4073177..f2c3a4d3de 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, * Copyright (C) Jeremy Allison 1998-2001, - * Copyright (C) Anthony Liguori 2003. + * Copyright (C) Jim McDonough 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index acc62880d0..668641e621 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, * Copyright (C) Paul Ashton 1997-1998, * Copyright (C) Jeremy Allison 1999, - * Copyright (C) Anthony Liguori 2003. + * Copyright (C) Jim McDonough 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 43bb1ad86a..e86b89e28e 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -7,7 +7,7 @@ * Copyright (C) Marc Jacobsen 2000, * Copyright (C) Jeremy Allison 2001, * Copyright (C) Gerald Carter 2002, - * Copyright (C) Anthony Liguori 2003. + * Copyright (C) Jim McDonough 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 9250b023d3..0c28b29d3e 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -6,8 +6,7 @@ * Copyright (C) Paul Ashton 1997, * Copyright (C) Marc Jacobsen 1999, * Copyright (C) Jean François Micouleau 1998-2001, - * Copyright (C) Anthony Liguori 2002-2003, - * Copyright (C) Jim McDonough 2002. + * Copyright (C) Jim McDonough 2002-2003. * * Split into interface and implementation modules by, * diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ea014d7ce0..ce586622e5 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -7,7 +7,6 @@ * Copyright (C) Marc Jacobsen 1999, * Copyright (C) Jeremy Allison 2001-2002, * Copyright (C) Jean François Micouleau 1998-2001, - * Copyright (C) Anthony Liguori 2002, * Copyright (C) Jim McDonough 2002. * * This program is free software; you can redistribute it and/or modify diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 3e9ed9e39f..0fc9ca27d7 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -6,7 +6,7 @@ * Copyright (C) Jean François Micouleau 1998-2000, * Copyright (C) Jeremy Allison 2001, * Copyright (C) Gerald Carter 2001-2002, - * Copyright (C) Anthony Liguori 2003. + * Copyright (C) Jim McDonough 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index deba122421..92fcff2c3d 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Anthony Liguori 2003. + * Copyright (C) Jim McDonough 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 8efa29fd0b..a845bc25c7 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -4,7 +4,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, - * Copyright (C) Anthony Liguori 2003. + * Copyright (C) Jim McDonough 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- cgit From 8c64504f7c58b05769ec1014242c15a2eb93ca84 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 1 Aug 2003 15:30:44 +0000 Subject: Update my copyrights according to my agreement with IBM (This used to be commit a2bd8f0bfa12f2a1e33c96bc9dabcc0e2171700d) --- source3/rpc_server/srv_dfs.c | 2 +- source3/rpc_server/srv_lsa.c | 2 +- source3/rpc_server/srv_lsa_nt.c | 2 +- source3/rpc_server/srv_netlog.c | 2 +- source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_reg.c | 2 +- source3/rpc_server/srv_samr.c | 2 +- source3/rpc_server/srv_samr_nt.c | 2 +- source3/rpc_server/srv_spoolss.c | 2 +- source3/rpc_server/srv_srvsvc.c | 2 +- source3/rpc_server/srv_wkssvc.c | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 093763fec0..27bb0732b4 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Shirish Kalele 2000, * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Jim McDonough 2003. + * Copyright (C) Jim McDonough 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 47a9646950..34812b15d9 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Jim McDonough 2002-2003. + * Copyright (C) Jim McDonough 2002-2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index ca3021a876..9eafcb8dc3 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -6,7 +6,7 @@ * Copyright (C) Paul Ashton 1997, * Copyright (C) Jeremy Allison 2001, * Copyright (C) Rafal Szczesniak 2002, - * Copyright (C) Jim McDonough 2002. + * Copyright (C) Jim McDonough 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index f2c3a4d3de..d1be2f3723 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, * Copyright (C) Jeremy Allison 1998-2001, - * Copyright (C) Jim McDonough 2003. + * Copyright (C) Jim McDonough 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 668641e621..594cb3a9ae 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, * Copyright (C) Paul Ashton 1997-1998, * Copyright (C) Jeremy Allison 1999, - * Copyright (C) Jim McDonough 2003. + * Copyright (C) Jim McDonough 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index e86b89e28e..e1a02103f7 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -7,7 +7,7 @@ * Copyright (C) Marc Jacobsen 2000, * Copyright (C) Jeremy Allison 2001, * Copyright (C) Gerald Carter 2002, - * Copyright (C) Jim McDonough 2003. + * Copyright (C) Jim McDonough 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 0c28b29d3e..86ff039683 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -6,7 +6,7 @@ * Copyright (C) Paul Ashton 1997, * Copyright (C) Marc Jacobsen 1999, * Copyright (C) Jean François Micouleau 1998-2001, - * Copyright (C) Jim McDonough 2002-2003. + * Copyright (C) Jim McDonough 2002-2003. * * Split into interface and implementation modules by, * diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ce586622e5..14aad5d6f8 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -7,7 +7,7 @@ * Copyright (C) Marc Jacobsen 1999, * Copyright (C) Jeremy Allison 2001-2002, * Copyright (C) Jean François Micouleau 1998-2001, - * Copyright (C) Jim McDonough 2002. + * Copyright (C) Jim McDonough 2002. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 0fc9ca27d7..fa0ca8478c 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -6,7 +6,7 @@ * Copyright (C) Jean François Micouleau 1998-2000, * Copyright (C) Jeremy Allison 2001, * Copyright (C) Gerald Carter 2001-2002, - * Copyright (C) Jim McDonough 2003. + * Copyright (C) Jim McDonough 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 92fcff2c3d..0da3cf70dd 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Jim McDonough 2003. + * Copyright (C) Jim McDonough 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index a845bc25c7..856f451779 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -4,7 +4,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, - * Copyright (C) Jim McDonough 2003. + * Copyright (C) Jim McDonough 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- cgit From 38b3ee6467230955ec94c820f3740eab89534d8c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 8 Aug 2003 17:08:35 +0000 Subject: RPC fix from Ronan Waide . Tested with rpcecho. Jeremy. (This used to be commit 68590b9e2266cf76b46a68cca0acaa47733811fe) --- source3/rpc_server/srv_spoolss_nt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8237298ebb..edbd1562bc 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7100,7 +7100,6 @@ static void fill_port_2(PORT_INFO_2 *port, const char *name) init_unistr(&port->port_name, name); init_unistr(&port->monitor_name, "Local Monitor"); init_unistr(&port->description, "Local Port"); -#define PORT_TYPE_WRITE 1 port->port_type=PORT_TYPE_WRITE; port->reserved=0x0; } -- cgit From ac8c6e47463545011f5471960c2a2073a9b04979 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 8 Aug 2003 23:09:09 +0000 Subject: Format tidyup. Jeremy. (This used to be commit 049e77d636c5abd0fdd8840c3c4c465708354ed7) --- source3/rpc_server/srv_pipe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 594cb3a9ae..11a5c934de 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -878,10 +878,10 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) } } - if (i == rpc_lookup_size) { - DEBUG(0, ("module %s doesn't provide functions for pipe %s!\n", p->name, p->name)); - return False; - } + if (i == rpc_lookup_size) { + DEBUG(0, ("module %s doesn't provide functions for pipe %s!\n", p->name, p->name)); + return False; + } } /* decode the bind request */ -- cgit From 998ded9155ce22008a4563d678dfb2a4d1385726 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 13 Aug 2003 03:59:41 +0000 Subject: fix bug #286. Fixed by storing the access requested on the anonymous samr connect. Restricted this to enum_domain|open_domain. Added become/unbecome_root() around pdb_enum_group_mapping() enum domain groups samr call. (This used to be commit 36fc199e5f573fea9b7e2c1cf01ad42744a42f08) --- source3/rpc_server/srv_samr_nt.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 14aad5d6f8..5f44acc962 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1013,8 +1013,13 @@ static NTSTATUS get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DO *p_num_entries = 0; + /* access checks for the users were performed higher up. become/unbecome_root() + needed for some passdb backends to enumerate groups */ + + become_root(); pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED); - + unbecome_root(); + num_entries=group_entries-start_idx; /* limit the number of entries */ @@ -2369,6 +2374,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ NTSTATUS _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CONNECT_ANON *r_u) { struct samr_info *info = NULL; + uint32 des_access = q_u->access_mask; /* Access check */ @@ -2386,6 +2392,13 @@ NTSTATUS _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CO if ((info = get_samr_info_by_sid(NULL)) == NULL) return NT_STATUS_NO_MEMORY; + /* don't give away the farm but this is probably ok. The SA_RIGHT_SAM_ENUM_DOMAINS + was observed from a win98 client trying to enumerate users (when configured + user level access control on shares) --jerry */ + + se_map_generic( &des_access, &sam_generic_mapping ); + info->acc_granted = des_access & (SA_RIGHT_SAM_ENUM_DOMAINS|SA_RIGHT_SAM_OPEN_DOMAIN); + info->status = q_u->unknown_0; /* get a (unique) handle. open a policy on it. */ @@ -2510,7 +2523,9 @@ NTSTATUS _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_ if (!find_policy_by_hnd(p, &q_u->connect_pol, (void**)&info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_SAM_OPEN_DOMAIN, "_samr_lookup_domain"))) { + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, + SA_RIGHT_SAM_ENUM_DOMAINS, "_samr_lookup_domain"))) + { return r_u->status; } -- cgit From 11777e6a3085a996ab2c5fa3db34d8834401c24e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 14 Aug 2003 21:14:28 +0000 Subject: Attempt at fixing bug #283. There however is no solution. There is a workaround documented in the bug report. This patch does: * add server support for the LSA_DS UUID on the lsarpc pipe * store a list of context_ids/api_structs in the pipe_struct so that we don't have to lookup the function table for a pipe. We just match the context_id. Note that a dce/rpc alter_context does not destroy the previous context so it is possible to have multiple bindings active on the same pipe. Observed from standalone win2k sp4 client. * added server code for DsROleGetPrimaryDOmainInfo() but disabled it since it causes problems enumerating users and groups from a 2ksp4 domain member in a Samba domain. (This used to be commit 96bc2abfcb0dd0912696fad76e43cb217b33e061) --- source3/rpc_server/srv_dfs.c | 16 ++- source3/rpc_server/srv_echo.c | 20 ++-- source3/rpc_server/srv_lsa.c | 43 +++++--- source3/rpc_server/srv_lsa_ds.c | 91 +++++++++++++++++ source3/rpc_server/srv_lsa_ds_nt.c | 127 ++++++++++++++++++++++++ source3/rpc_server/srv_netlog.c | 13 ++- source3/rpc_server/srv_pipe.c | 195 +++++++++++++++++++++++++------------ source3/rpc_server/srv_pipe_hnd.c | 2 + source3/rpc_server/srv_reg.c | 18 ++-- source3/rpc_server/srv_samr.c | 16 ++- source3/rpc_server/srv_spoolss.c | 11 ++- source3/rpc_server/srv_srvsvc.c | 16 ++- source3/rpc_server/srv_wkssvc.c | 15 ++- 13 files changed, 474 insertions(+), 109 deletions(-) create mode 100644 source3/rpc_server/srv_lsa_ds.c create mode 100644 source3/rpc_server/srv_lsa_ds_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 27bb0732b4..6c35917e61 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -157,17 +157,23 @@ static BOOL api_dfs_enum(pipes_struct *p) /******************************************************************* \pipe\netdfs commands ********************************************************************/ - -NTSTATUS rpc_dfs_init(void) +static struct api_struct api_netdfs_cmds[] = { - struct api_struct api_netdfs_cmds[] = - { {"DFS_EXIST", DFS_EXIST, api_dfs_exist }, {"DFS_ADD", DFS_ADD, api_dfs_add }, {"DFS_REMOVE", DFS_REMOVE, api_dfs_remove }, {"DFS_GET_INFO", DFS_GET_INFO, api_dfs_get_info }, {"DFS_ENUM", DFS_ENUM, api_dfs_enum } - }; +}; + +void netdfs_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_netdfs_cmds; + *n_fns = sizeof(api_netdfs_cmds) / sizeof(struct api_struct); +} + +NTSTATUS rpc_dfs_init(void) +{ return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "netdfs", "netdfs", api_netdfs_cmds, sizeof(api_netdfs_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_echo.c b/source3/rpc_server/srv_echo.c index 166b6e939d..909893ce6d 100644 --- a/source3/rpc_server/srv_echo.c +++ b/source3/rpc_server/srv_echo.c @@ -120,14 +120,22 @@ static BOOL api_sink_data(pipes_struct *p) \pipe\rpcecho commands ********************************************************************/ +struct api_struct api_echo_cmds[] = { + {"ADD_ONE", ECHO_ADD_ONE, api_add_one }, + {"ECHO_DATA", ECHO_DATA, api_echo_data }, + {"SOURCE_DATA", ECHO_SOURCE_DATA, api_source_data }, + {"SINK_DATA", ECHO_SINK_DATA, api_sink_data }, +}; + + +void echo_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_echo_cmds; + *n_fns = sizeof(api_echo_cmds) / sizeof(struct api_struct); +} + NTSTATUS rpc_echo_init(void) { - struct api_struct api_echo_cmds[] = { - {"ADD_ONE", ECHO_ADD_ONE, api_add_one }, - {"ECHO_DATA", ECHO_DATA, api_echo_data }, - {"SOURCE_DATA", ECHO_SOURCE_DATA, api_source_data }, - {"SINK_DATA", ECHO_SINK_DATA, api_sink_data }, - }; return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "rpcecho", "rpcecho", api_echo_cmds, diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 34812b15d9..138fb1d7ef 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -644,9 +644,8 @@ static BOOL api_lsa_query_info2(pipes_struct *p) /*************************************************************************** \PIPE\ntlsa commands ***************************************************************************/ -NTSTATUS rpc_lsa_init(void) -{ -static const struct api_struct api_lsa_cmds[] = + +static struct api_struct api_lsa_cmds[] = { { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 }, { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy }, @@ -671,17 +670,33 @@ static const struct api_struct api_lsa_cmds[] = ADS DC capabilities */ { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 } }; -/* - * NOTE: Certain calls can not be enabled if we aren't an ADS DC. Make sure - * these calls are always last and that you decrement by the amount of calls - * to disable. - */ - int funcs = sizeof(api_lsa_cmds) / sizeof(struct api_struct); - if (!(SEC_ADS == lp_security() && ROLE_DOMAIN_PDC == lp_server_role())) { - funcs -= 1; - } +static int count_fns(void) +{ + int funcs = sizeof(api_lsa_cmds) / sizeof(struct api_struct); + + /* + * NOTE: Certain calls can not be enabled if we aren't an ADS DC. Make sure + * these calls are always last and that you decrement by the amount of calls + * to disable. + */ + if (!(SEC_ADS == lp_security() && ROLE_DOMAIN_PDC == lp_server_role())) { + funcs -= 1; + } + + return funcs; +} +void lsa_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_lsa_cmds; + *n_fns = count_fns(); +} + + +NTSTATUS rpc_lsa_init(void) +{ + int funcs = count_fns(); - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "lsarpc", "lsass", api_lsa_cmds, - funcs); + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "lsarpc", "lsass", api_lsa_cmds, + funcs); } diff --git a/source3/rpc_server/srv_lsa_ds.c b/source3/rpc_server/srv_lsa_ds.c new file mode 100644 index 0000000000..5996935b22 --- /dev/null +++ b/source3/rpc_server/srv_lsa_ds.c @@ -0,0 +1,91 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Gerald Carter 2003 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* This is the interface for the registry functions. */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +/******************************************************************* + api_reg_open_entry + ********************************************************************/ + +static BOOL api_dsrole_get_primary_dominfo(pipes_struct *p) +{ + DS_Q_GETPRIMDOMINFO q_u; + DS_R_GETPRIMDOMINFO r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the request */ + if ( !ds_io_q_getprimdominfo("", data, 0, &q_u) ) + return False; + + /* construct reply. */ + r_u.status = _dsrole_get_primary_dominfo( p, &q_u, &r_u ); + + if ( !ds_io_r_getprimdominfo("", rdata, 0, &r_u) ) + return False; + + return True; +} + +/******************************************************************* + stub functions for unimplemented RPC +*******************************************************************/ + +static BOOL api_dsrole_stub( pipes_struct *p ) +{ + DEBUG(0,("api_dsrole_stub: Hmmm....didn't know this RPC existsed?!??!\n")); + + return False; +} + + +/******************************************************************* + array of \PIPE\lsass (new windows 2000 UUID) operations +********************************************************************/ +static struct api_struct api_lsa_ds_cmds[] = { + { "DS_NOP", DS_NOP, api_dsrole_stub } + +#if 0 /* disabled due to breakage with viewing domain users and groups + on a Samba PDC from win2k clients --jerry CIFS 2003 */ + { "DS_GETPRIMDOMINFO", DS_GETPRIMDOMINFO, api_dsrole_get_primary_dominfo } +#endif + +}; + +void lsa_ds_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_lsa_ds_cmds; + *n_fns = sizeof(api_lsa_ds_cmds) / sizeof(struct api_struct); +} + + +NTSTATUS rpc_lsa_ds_init(void) +{ + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "lsa_ds", "lsa_ds", api_lsa_ds_cmds, + sizeof(api_lsa_ds_cmds) / sizeof(struct api_struct)); +} diff --git a/source3/rpc_server/srv_lsa_ds_nt.c b/source3/rpc_server/srv_lsa_ds_nt.c new file mode 100644 index 0000000000..c277086bdb --- /dev/null +++ b/source3/rpc_server/srv_lsa_ds_nt.c @@ -0,0 +1,127 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997. + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997. + * Copyright (C) Paul Ashton 1997. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Gerald Carter 2002. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Implementation of registry functions. */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +/******************************************************************** + Fill in a DS_DOMINFO_CTR structure + ********************************************************************/ + +static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN_INFO_BASIC **info) +{ + DSROLE_PRIMARY_DOMAIN_INFO_BASIC *basic; + const char *netbios_domain; + fstring dnsdomain; + + DEBUG(10,("fill_dsrole_dominfo_basic: enter\n")); + + if ( !(basic = talloc_zero(ctx, sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC))) ) { + DEBUG(0,("fill_dsrole_dominfo_basic: FATAL error! talloc_xero() failed\n")); + return NT_STATUS_NO_MEMORY; + } + + switch ( lp_server_role() ) { + case ROLE_STANDALONE: + basic->machine_role = DSROLE_STANDALONE_SRV; + break; + case ROLE_DOMAIN_MEMBER: + basic->machine_role = DSROLE_DOMAIN_MEMBER_SRV; + break; + case ROLE_DOMAIN_BDC: + basic->machine_role = DSROLE_BDC; + basic->flags = DSROLE_PRIMARY_DS_RUNNING|DSROLE_PRIMARY_DS_MIXED_MODE; + if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) ) + basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT; + get_mydomname(dnsdomain); + strlower_m(dnsdomain); + break; + case ROLE_DOMAIN_PDC: + basic->machine_role = DSROLE_PDC; + basic->flags = DSROLE_PRIMARY_DS_RUNNING|DSROLE_PRIMARY_DS_MIXED_MODE; + if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) ) + basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT; + get_mydomname(dnsdomain); + strlower_m(dnsdomain); + break; + } + + basic->unknown = 0x6173; /* seen on the wire; maybe padding */ + + /* always set netbios name */ + + basic->netbios_ptr = 1; + netbios_domain = get_global_sam_name(); + init_unistr2( &basic->netbios_domain, netbios_domain, strlen(netbios_domain) ); + + basic->dnsname_ptr = 1; + init_unistr2( &basic->dns_domain, dnsdomain, strlen(dnsdomain) ); + basic->forestname_ptr = 1; + init_unistr2( &basic->forest_domain, dnsdomain, strlen(dnsdomain) ); + + + /* fill in some additional fields if we are a member of an AD domain */ + + if ( lp_security() == SEC_ADS ) { + /* TODO */ + ;; + } + + *info = basic; + + return NT_STATUS_OK; +} + +/******************************************************************** + Implement the DsroleGetPrimaryDomainInfo() call + ********************************************************************/ + +NTSTATUS _dsrole_get_primary_dominfo(pipes_struct *p, DS_Q_GETPRIMDOMINFO *q_u, DS_R_GETPRIMDOMINFO *r_u) +{ + NTSTATUS result; + uint32 level = q_u->level; + + switch ( level ) { + + case DsRolePrimaryDomainInfoBasic: + r_u->level = DsRolePrimaryDomainInfoBasic; + r_u->ptr = 1; + result = fill_dsrole_dominfo_basic( p->mem_ctx, &r_u->info.basic ); + break; + + default: + DEBUG(0,("_dsrole_get_primary_dominfo: Unsupported info level [%d]!\n", + level)); + result = NT_STATUS_INVALID_LEVEL; + } + + return NT_STATUS_OK; +} + + + diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index d1be2f3723..9c10d86379 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -320,10 +320,7 @@ static BOOL api_net_logon_ctrl(pipes_struct *p) /******************************************************************* array of \PIPE\NETLOGON operations ********************************************************************/ - -NTSTATUS rpc_net_init(void) -{ - static struct api_struct api_net_cmds [] = +static struct api_struct api_net_cmds [] = { { "NET_REQCHAL" , NET_REQCHAL , api_net_req_chal }, { "NET_AUTH" , NET_AUTH , api_net_auth }, @@ -336,6 +333,14 @@ NTSTATUS rpc_net_init(void) { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl } }; +void netlog_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_net_cmds; + *n_fns = sizeof(api_net_cmds) / sizeof(struct api_struct); +} + +NTSTATUS rpc_net_init(void) +{ return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "NETLOGON", "lsass", api_net_cmds, sizeof(api_net_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 11a5c934de..1c99943a9d 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -713,26 +713,19 @@ BOOL setup_fault_pdu(pipes_struct *p, NTSTATUS status) Used to reject unknown binds from Win2k. *******************************************************************/ -BOOL check_bind_req(char* pipe_name, RPC_IFACE* abstract, - RPC_IFACE* transfer) +BOOL check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, + RPC_IFACE* transfer, uint32 context_id) { extern struct pipe_id_info pipe_names[]; + char *pipe_name = p->name; int i=0; fstring pname; + fstrcpy(pname,"\\PIPE\\"); fstrcat(pname,pipe_name); DEBUG(3,("check_bind_req for %s\n", pname)); -#ifndef SUPPORT_NEW_LSARPC_UUID - - /* check for the first pipe matching the name */ - - for ( i=0; pipe_names[i].client_pipe; i++ ) { - if ( strequal(pipe_names[i].client_pipe, pname) ) - break; - } -#else /* we have to check all now since win2k introduced a new UUID on the lsaprpc pipe */ for ( i=0; pipe_names[i].client_pipe; i++ ) @@ -743,29 +736,34 @@ BOOL check_bind_req(char* pipe_name, RPC_IFACE* abstract, && (transfer->version == pipe_names[i].trans_syntax.version) && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(RPC_UUID)) == 0) ) { + struct api_struct *fns = NULL; + int n_fns = 0; + PIPE_RPC_FNS *context_fns; + + if ( !(context_fns = malloc(sizeof(PIPE_RPC_FNS))) ) { + DEBUG(0,("check_bind_req: malloc() failed!\n")); + return False; + } + + /* save the RPC function table associated with this bind */ + + get_pipe_fns(i, &fns, &n_fns); + + context_fns->cmds = fns; + context_fns->n_cmds = n_fns; + context_fns->context_id = context_id; + + /* add to the list of open contexts */ + + DLIST_ADD( p->contexts, context_fns ); + break; } } -#endif if(pipe_names[i].client_pipe == NULL) return False; -#ifndef SUPPORT_NEW_LSARPC_UUID - /* check the abstract interface */ - if ( (abstract->version != pipe_names[i].abstr_syntax.version) - || (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(RPC_UUID)) != 0) ) - { - return False; - } - - /* check the transfer interface */ - if ( (transfer->version != pipe_names[i].trans_syntax.version) - || (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(RPC_UUID)) != 0) ) - { - return False; - } -#endif return True; } @@ -861,7 +859,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) } if (i == rpc_lookup_size) { - if (NT_STATUS_IS_ERR(smb_probe_module("rpc", p->name))) { + if (NT_STATUS_IS_ERR(smb_probe_module("rpc", p->name))) { DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", p->name )); if(!setup_bind_nak(p)) @@ -1028,7 +1026,8 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) unknown to NT4) Needed when adding entries to a DACL from NT5 - SK */ - if(check_bind_req(p->name, &hdr_rb.abstract, &hdr_rb.transfer)) { + if(check_bind_req(p, &hdr_rb.abstract, &hdr_rb.transfer, hdr_rb.context_id )) + { init_rpc_hdr_ba(&hdr_ba, MAX_PDU_FRAG_LEN, MAX_PDU_FRAG_LEN, @@ -1391,6 +1390,48 @@ struct current_user *get_current_user(struct current_user *user, pipes_struct *p return user; } +/**************************************************************************** + Find the set of RPC functions associated with this context_id +****************************************************************************/ + +static PIPE_RPC_FNS* find_pipe_fns_by_context( PIPE_RPC_FNS *list, uint32 context_id ) +{ + PIPE_RPC_FNS *fns = NULL; + PIPE_RPC_FNS *tmp = NULL; + + if ( !list ) { + DEBUG(0,("find_pipe_fns_by_context: ERROR! No context list for pipe!\n")); + return NULL; + } + + for (tmp=list; tmp; tmp=tmp->next ) { + if ( tmp->context_id == context_id ) + break; + } + + fns = tmp; + + return fns; +} + +/**************************************************************************** + memory cleanup +****************************************************************************/ + +void free_pipe_rpc_context( PIPE_RPC_FNS *list ) +{ + PIPE_RPC_FNS *tmp = list; + PIPE_RPC_FNS *tmp2; + + while (tmp) { + tmp2 = tmp->next; + SAFE_FREE(tmp); + tmp = tmp2; + } + + return; +} + /**************************************************************************** Find the correct RPC function to call for this request. If the pipe is authenticated then become the correct UNIX user @@ -1399,9 +1440,9 @@ struct current_user *get_current_user(struct current_user *user, pipes_struct *p BOOL api_pipe_request(pipes_struct *p) { - int i = 0; BOOL ret = False; - + PIPE_RPC_FNS *pipe_fns; + if (p->ntlmssp_auth_validated) { if(!become_authenticated_pipe_user(p)) { @@ -1411,36 +1452,19 @@ BOOL api_pipe_request(pipes_struct *p) } DEBUG(5, ("Requested \\PIPE\\%s\n", p->name)); - - for (i = 0; i < rpc_lookup_size; i++) { - if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { - DEBUG(3,("Doing \\PIPE\\%s\n", - rpc_lookup[i].pipe.clnt)); - set_current_rpc_talloc(p->mem_ctx); - ret = api_rpcTNP(p, rpc_lookup[i].pipe.clnt, - rpc_lookup[i].cmds, - rpc_lookup[i].n_cmds); - set_current_rpc_talloc(NULL); - break; - } + + /* get the set of RPC functions for this context */ + + pipe_fns = find_pipe_fns_by_context(p->contexts, p->hdr_req.context_id); + + if ( pipe_fns ) { + set_current_rpc_talloc(p->mem_ctx); + ret = api_rpcTNP(p, p->name, pipe_fns->cmds, pipe_fns->n_cmds); + set_current_rpc_talloc(NULL); } - - - if (i == rpc_lookup_size) { - smb_probe_module("rpc", p->name); - - for (i = 0; i < rpc_lookup_size; i++) { - if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { - DEBUG(3,("Doing \\PIPE\\%s\n", - rpc_lookup[i].pipe.clnt)); - set_current_rpc_talloc(p->mem_ctx); - ret = api_rpcTNP(p, rpc_lookup[i].pipe.clnt, - rpc_lookup[i].cmds, - rpc_lookup[i].n_cmds); - set_current_rpc_talloc(NULL); - break; - } - } + else { + DEBUG(0,("api_pipe_request: No rpc function table associated with context [%d] on pipe [%s]\n", + p->hdr_req.context_id, p->name)); } if(p->ntlmssp_auth_validated) @@ -1529,3 +1553,54 @@ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, return True; } + +/******************************************************************* +*******************************************************************/ + +void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) +{ + struct api_struct *cmds = NULL; + int n_cmds = 0; + + switch ( idx ) { + case PI_LSARPC: + lsa_get_pipe_fns( &cmds, &n_cmds ); + break; + case PI_LSARPC_DS: + lsa_ds_get_pipe_fns( &cmds, &n_cmds ); + break; + case PI_SAMR: + samr_get_pipe_fns( &cmds, &n_cmds ); + break; + case PI_NETLOGON: + netlog_get_pipe_fns( &cmds, &n_cmds ); + break; + case PI_SRVSVC: + srvsvc_get_pipe_fns( &cmds, &n_cmds ); + break; + case PI_WKSSVC: + wkssvc_get_pipe_fns( &cmds, &n_cmds ); + break; + case PI_WINREG: + reg_get_pipe_fns( &cmds, &n_cmds ); + break; + case PI_SPOOLSS: + spoolss_get_pipe_fns( &cmds, &n_cmds ); + break; + case PI_NETDFS: + netdfs_get_pipe_fns( &cmds, &n_cmds ); + break; + case PI_ECHO: + echo_get_pipe_fns( &cmds, &n_cmds ); + break; + default: + DEBUG(0,("get_pipe_fns: Unknown pipe index! [%d]\n", idx)); + } + + *fns = cmds; + *n_fns = n_cmds; + + return; +} + + diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 125f603771..55def97673 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1106,6 +1106,8 @@ static BOOL close_internal_rpc_pipe_hnd(void *np_conn) if (p->mem_ctx) talloc_destroy(p->mem_ctx); + + free_pipe_rpc_context( p->contexts ); /* Free the handles database. */ close_policy_by_pipe(p); diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index e1a02103f7..b780be0aff 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -367,16 +367,12 @@ static BOOL api_reg_save_key(pipes_struct *p) return True; } - - /******************************************************************* array of \PIPE\reg operations ********************************************************************/ -NTSTATUS rpc_reg_init(void) +static struct api_struct api_reg_cmds[] = { - static struct api_struct api_reg_cmds[] = - { { "REG_CLOSE" , REG_CLOSE , api_reg_close }, { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, { "REG_OPEN_HKCR" , REG_OPEN_HKCR , api_reg_open_hkcr }, @@ -390,7 +386,17 @@ NTSTATUS rpc_reg_init(void) { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, { "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a }, { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key } - }; +}; + +void reg_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_reg_cmds; + *n_fns = sizeof(api_reg_cmds) / sizeof(struct api_struct); +} + +NTSTATUS rpc_reg_init(void) +{ + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "winreg", "winreg", api_reg_cmds, sizeof(api_reg_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 86ff039683..d9624bdff0 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1442,10 +1442,8 @@ static BOOL api_samr_set_dom_info(pipes_struct *p) array of \PIPE\samr operations ********************************************************************/ -NTSTATUS rpc_samr_init(void) +static struct api_struct api_samr_cmds [] = { - static struct api_struct api_samr_cmds [] = - { {"SAMR_CLOSE_HND" , SAMR_CLOSE_HND , api_samr_close_hnd }, {"SAMR_CONNECT" , SAMR_CONNECT , api_samr_connect }, {"SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon }, @@ -1499,7 +1497,17 @@ NTSTATUS rpc_samr_init(void) {"SAMR_UNKNOWN_2E" , SAMR_UNKNOWN_2E , api_samr_unknown_2e }, {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, {"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 } - }; +}; + +void samr_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_samr_cmds; + *n_fns = sizeof(api_samr_cmds) / sizeof(struct api_struct); +} + + +NTSTATUS rpc_samr_init(void) +{ return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "samr", "lsass", api_samr_cmds, sizeof(api_samr_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index fa0ca8478c..a903ae9029 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1580,8 +1580,6 @@ static BOOL api_spoolss_replycloseprinter(pipes_struct *p) \pipe\spoolss commands ********************************************************************/ -NTSTATUS rpc_spoolss_init(void) -{ struct api_struct api_spoolss_cmds[] = { {"SPOOLSS_OPENPRINTER", SPOOLSS_OPENPRINTER, api_spoolss_open_printer }, @@ -1640,6 +1638,15 @@ NTSTATUS rpc_spoolss_init(void) {"SPOOLSS_REPLYCLOSEPRINTER", SPOOLSS_REPLYCLOSEPRINTER, api_spoolss_replycloseprinter } #endif }; + +void spoolss_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_spoolss_cmds; + *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct); +} + +NTSTATUS rpc_spoolss_init(void) +{ return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "spoolss", "spoolss", api_spoolss_cmds, sizeof(api_spoolss_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 0da3cf70dd..9d85088e56 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -526,10 +526,8 @@ static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) \PIPE\srvsvc commands ********************************************************************/ -NTSTATUS rpc_srv_init(void) +static struct api_struct api_srv_cmds[] = { - static const struct api_struct api_srv_cmds[] = - { { "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum }, { "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum }, { "SRV_NET_SHARE_ENUM_ALL" , SRV_NET_SHARE_ENUM_ALL , api_srv_net_share_enum_all }, @@ -547,7 +545,17 @@ NTSTATUS rpc_srv_init(void) { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate }, { "SRV_NET_FILE_QUERY_SECDESC", SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc }, { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc } - }; +}; + +void srvsvc_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_srv_cmds; + *n_fns = sizeof(api_srv_cmds) / sizeof(struct api_struct); +} + + +NTSTATUS rpc_srv_init(void) +{ return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "srvsvc", "ntsvcs", api_srv_cmds, sizeof(api_srv_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c index 856f451779..b5c1af34d9 100644 --- a/source3/rpc_server/srv_wkssvc.c +++ b/source3/rpc_server/srv_wkssvc.c @@ -60,12 +60,19 @@ static BOOL api_wks_query_info(pipes_struct *p) \PIPE\wkssvc commands ********************************************************************/ -NTSTATUS rpc_wks_init(void) +static struct api_struct api_wks_cmds[] = { - static struct api_struct api_wks_cmds[] = - { { "WKS_Q_QUERY_INFO", WKS_QUERY_INFO, api_wks_query_info } - }; +}; + +void wkssvc_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_wks_cmds; + *n_fns = sizeof(api_wks_cmds) / sizeof(struct api_struct); +} + +NTSTATUS rpc_wks_init(void) +{ return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "wkssvc", "ntsvcs", api_wks_cmds, sizeof(api_wks_cmds) / sizeof(struct api_struct)); } -- cgit From 8f75104da17dac200395ccc91c32878b0ee5ef9b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 14 Aug 2003 22:14:03 +0000 Subject: fix build (This used to be commit dd9cb6f820c2acf658eb081fb6ffc7e9b6b3c8d6) --- source3/rpc_server/srv_pipe.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 1c99943a9d..ae6337e152 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1590,9 +1590,11 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) case PI_NETDFS: netdfs_get_pipe_fns( &cmds, &n_cmds ); break; +#ifdef DEVELOPER case PI_ECHO: echo_get_pipe_fns( &cmds, &n_cmds ); break; +#endif default: DEBUG(0,("get_pipe_fns: Unknown pipe index! [%d]\n", idx)); } -- cgit From b09eb5aa932a45d82b0b1d2a5d0c447be1a0f28a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 14 Aug 2003 22:17:07 +0000 Subject: jeremy foo (This used to be commit 0b31f592df9aca952f978fd6f28c362a0bf02a53) --- source3/rpc_server/srv_echo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_echo.c b/source3/rpc_server/srv_echo.c index 909893ce6d..c6cfde07c1 100644 --- a/source3/rpc_server/srv_echo.c +++ b/source3/rpc_server/srv_echo.c @@ -136,10 +136,15 @@ void echo_get_pipe_fns( struct api_struct **fns, int *n_fns ) NTSTATUS rpc_echo_init(void) { - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "rpcecho", "rpcecho", api_echo_cmds, sizeof(api_echo_cmds) / sizeof(struct api_struct)); } +#else /* DEVELOPER */ + +NTSTATUS rpc_echo_init(void) +{ + return NT_STATUS_OK; +} #endif /* DEVELOPER */ -- cgit From fc05b0f4c73a44133074cf14afcfd0dee974c7ef Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Fri, 15 Aug 2003 01:33:57 +0000 Subject: return actual results instead of always OK (This used to be commit 71469f3220e54959af13a395918c80273538b6ed) --- source3/rpc_server/srv_lsa_ds_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_ds_nt.c b/source3/rpc_server/srv_lsa_ds_nt.c index c277086bdb..37540a9668 100644 --- a/source3/rpc_server/srv_lsa_ds_nt.c +++ b/source3/rpc_server/srv_lsa_ds_nt.c @@ -103,7 +103,7 @@ static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN NTSTATUS _dsrole_get_primary_dominfo(pipes_struct *p, DS_Q_GETPRIMDOMINFO *q_u, DS_R_GETPRIMDOMINFO *r_u) { - NTSTATUS result; + NTSTATUS result = NT_STATUS_OK; uint32 level = q_u->level; switch ( level ) { @@ -120,7 +120,7 @@ NTSTATUS _dsrole_get_primary_dominfo(pipes_struct *p, DS_Q_GETPRIMDOMINFO *q_u, result = NT_STATUS_INVALID_LEVEL; } - return NT_STATUS_OK; + return result; } -- cgit From 062f89bc2833bf49f873a7fd5c2624babd702db0 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Fri, 15 Aug 2003 01:42:30 +0000 Subject: get rid of some sompiler warnings on IRIX (This used to be commit a6a39c61e8228c8b3b7552ab3c61ec3a6a639143) --- source3/rpc_server/srv_lsa_nt.c | 2 +- source3/rpc_server/srv_pipe.c | 4 ++-- source3/rpc_server/srv_samr_nt.c | 5 ++--- source3/rpc_server/srv_spoolss_nt.c | 17 +++-------------- 4 files changed, 8 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 9eafcb8dc3..330dd727ef 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -502,7 +502,7 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E if (!(info->access & POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - nt_status = secrets_get_trusted_domains(p->mem_ctx, &enum_context, max_num_domains, &num_domains, &trust_doms); + nt_status = secrets_get_trusted_domains(p->mem_ctx, (int *)&enum_context, max_num_domains, (int *)&num_domains, &trust_doms); if (!NT_STATUS_IS_OK(nt_status) && !NT_STATUS_EQUAL(nt_status, STATUS_MORE_ENTRIES) && diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index ae6337e152..d1fb587d74 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1226,10 +1226,10 @@ BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) sizeof(p->ntlmssp_hash)); dump_data_pw("Incoming RPC PDU (NTLMSSP sealed)\n", - data, data_len); + (const unsigned char *)data, data_len); NTLMSSPcalc_p(p, (uchar*)data, data_len); dump_data_pw("Incoming RPC PDU (NTLMSSP unsealed)\n", - data, data_len); + (const unsigned char *)data, data_len); crc32 = crc32_calc_buffer(data, data_len); } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 5f44acc962..a338b5eb4d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -913,7 +913,6 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM } else if (sid_equal(sid, get_global_sam_sid()) && !lp_hide_local_users()) { struct sys_grent *glist; struct sys_grent *grp; - struct passwd *pw; gid_t winbind_gid_low, winbind_gid_high; BOOL winbind_groups_exist = lp_idmap_gid(&winbind_gid_low, &winbind_gid_high); @@ -952,7 +951,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM /* Don't return user private groups... */ - if ((pw = Get_Pwnam(smap.nt_name)) != 0) { + if (Get_Pwnam(smap.nt_name) != 0) { DEBUG(10,("get_group_alias_entries: not returing %s, clashes with user.\n", smap.nt_name )); continue; } @@ -2145,7 +2144,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA num_users, num_groups, num_aliases); break; case 0x03: - account_policy_get(AP_TIME_TO_LOGOUT, (int *)&u_logout); + account_policy_get(AP_TIME_TO_LOGOUT, (unsigned int *)&u_logout); unix_to_nt_time_abs(&nt_logout, u_logout); init_unk_info3(&ctr->info.inf3, nt_logout); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index edbd1562bc..725672da69 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -387,7 +387,6 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) char *cmd = lp_deleteprinter_cmd(); pstring command; int ret; - int i; /* Printer->dev.handlename equals portname equals sharename */ slprintf(command, sizeof(command)-1, "%s \"%s\"", cmd, @@ -406,7 +405,7 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) /* go ahead and re-read the services immediately */ reload_services( False ); - if ( ( i = lp_servicenumber( Printer->dev.handlename ) ) < 0 ) + if ( lp_servicenumber( Printer->dev.handlename ) < 0 ) return WERR_ACCESS_DENIED; } @@ -957,7 +956,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) SPOOL_NOTIFY_INFO_DATA *data; uint32 data_len = 0; uint32 id; - int i, event_index; + int i; /* Is there notification on this handle? */ @@ -980,8 +979,6 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) data = talloc( mem_ctx, msg_group->num_msgs*sizeof(SPOOL_NOTIFY_INFO_DATA) ); ZERO_STRUCTP(data); - event_index = 0; - /* build the array of change notifications */ sending_msg_count = 0; @@ -3753,7 +3750,6 @@ static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, Printer_entry *Printer=find_printer_index_by_hnd(p, hnd); int n_services=lp_numservices(); int i; - uint32 id; SPOOL_NOTIFY_OPTION *option; SPOOL_NOTIFY_OPTION_TYPE *option_type; @@ -3763,7 +3759,6 @@ static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, return WERR_BADFID; option=Printer->notify.option; - id=1; info->version=2; info->data=NULL; info->count=0; @@ -6192,12 +6187,9 @@ static WERROR publish_or_unpublish_printer(pipes_struct *p, POLICY_HND *handle, SPOOL_PRINTER_INFO_LEVEL_7 *info7 = info->info_7; int snum; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - WERROR result; DEBUG(5,("publish_or_unpublish_printer, action = %d\n",info7->action)); - result = WERR_OK; - if (!Printer) return WERR_BADFID; @@ -7722,7 +7714,6 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S NT_PRINTER_INFO_LEVEL *printer = NULL; - uint32 param_index; uint32 biggest_valuesize; uint32 biggest_datasize; uint32 data_len; @@ -7771,7 +7762,6 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S { DEBUGADD(6,("Activating NT mega-hack to find sizes\n")); - param_index = 0; biggest_valuesize = 0; biggest_datasize = 0; @@ -9185,12 +9175,11 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, { pstring path; pstring long_archi; - const char *short_archi; PRINTPROCESSOR_DIRECTORY_1 *info=NULL; unistr2_to_ascii(long_archi, environment, sizeof(long_archi)-1); - if (!(short_archi = get_short_archi(long_archi))) + if (!get_short_archi(long_archi)) return WERR_INVALID_ENVIRONMENT; if((info=(PRINTPROCESSOR_DIRECTORY_1 *)malloc(sizeof(PRINTPROCESSOR_DIRECTORY_1))) == NULL) -- cgit From 4e88fd330e0306188e5a95d8b3d3665e4e3d56bb Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 15 Aug 2003 20:12:40 +0000 Subject: possible fix for bug 288 to repcent using an uninitialized cli_state struct (This used to be commit d09dc91c024d718a8ddb6b7f08c7fe84716beda4) --- source3/rpc_server/srv_spoolss_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 725672da69..646aac347c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2668,6 +2668,8 @@ static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, fstrcpy(unix_printer, printer+2); /* the +2 is to strip the leading 2 backslashs */ + ZERO_STRUCT(notify_cli); + if(!spoolss_connect_to_client(¬ify_cli, client_ip, unix_printer)) return False; -- cgit From 49e66508f271c5d548a045a1297652ed5b03494c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 19 Aug 2003 04:17:21 +0000 Subject: Fix BUG #314: api_netUserGetGRoups() was failing prematurely (also fixed the call to return the real groups and not a mocked up list) Fixed simple compiler warning in srv_lsa_ds.c (This used to be commit 6b0e38e01a44d87b844d973318accc456abef857) --- source3/rpc_server/srv_lsa_ds.c | 2 +- source3/rpc_server/srv_util.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_ds.c b/source3/rpc_server/srv_lsa_ds.c index 5996935b22..21e18f52fc 100644 --- a/source3/rpc_server/srv_lsa_ds.c +++ b/source3/rpc_server/srv_lsa_ds.c @@ -58,7 +58,7 @@ static BOOL api_dsrole_get_primary_dominfo(pipes_struct *p) static BOOL api_dsrole_stub( pipes_struct *p ) { - DEBUG(0,("api_dsrole_stub: Hmmm....didn't know this RPC existsed?!??!\n")); + DEBUG(0,("api_dsrole_stub: Hmmm....didn't know this RPC existed...\n")); return False; } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 03e53118a8..632d381503 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -307,8 +307,17 @@ BOOL get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids, SA */ gids = (DOM_GID *)talloc(ctx, sizeof(DOM_GID) * num_entries); - /* for each group, check if the user is a member of*/ + /* for each group, check if the user is a member of. Only include groups + from this domain */ + for(i=0; i Date: Wed, 20 Aug 2003 16:07:19 +0000 Subject: Fix bug #252. Implement missing SAMR_REMOVE_USER_FOREIGN_DOMAIN call. (This used to be commit dd2cf4897ec3db25c24a2724ffdef4f905625f6a) --- source3/rpc_server/srv_samr.c | 27 ++++++--------- source3/rpc_server/srv_samr_nt.c | 74 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 80 insertions(+), 21 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index d9624bdff0..d9d1a45dce 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -386,7 +386,7 @@ static BOOL api_samr_chgpasswd_user(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - /* unknown 38 command */ + /* change password request */ if (!samr_io_q_chgpasswd_user("", &q_u, data, 0)) { DEBUG(0,("api_samr_chgpasswd_user: Failed to unmarshall SAMR_Q_CHGPASSWD_USER.\n")); return False; @@ -448,7 +448,6 @@ static BOOL api_samr_open_user(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - /* grab the samr unknown 22 */ if(!samr_io_q_open_user("", &q_u, data, 0)) { DEBUG(0,("api_samr_open_user: unable to unmarshall SAMR_Q_OPEN_USER.\n")); return False; @@ -479,7 +478,6 @@ static BOOL api_samr_query_userinfo(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - /* grab the samr unknown 24 */ if(!samr_io_q_query_userinfo("", &q_u, data, 0)){ DEBUG(0,("api_samr_query_userinfo: unable to unmarshall SAMR_Q_QUERY_USERINFO.\n")); return False; @@ -510,7 +508,6 @@ static BOOL api_samr_query_usergroups(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - /* grab the samr unknown 32 */ if(!samr_io_q_query_usergroups("", &q_u, data, 0)) { DEBUG(0,("api_samr_query_usergroups: unable to unmarshall SAMR_Q_QUERY_USERGROUPS.\n")); return False; @@ -541,7 +538,6 @@ static BOOL api_samr_query_dom_info(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - /* grab the samr unknown 8 command */ if(!samr_io_q_query_dom_info("", &q_u, data, 0)) { DEBUG(0,("api_samr_query_dom_info: unable to unmarshall SAMR_Q_QUERY_DOMAIN_INFO.\n")); return False; @@ -1347,13 +1343,13 @@ static BOOL api_samr_open_group(pipes_struct *p) } /******************************************************************* - api_samr_unknown_2d + api_samr_remove_user_foreign_domain ********************************************************************/ -static BOOL api_samr_unknown_2d(pipes_struct *p) +static BOOL api_samr_remove_user_foreign_domain(pipes_struct *p) { - SAMR_Q_UNKNOWN_2D q_u; - SAMR_R_UNKNOWN_2D r_u; + SAMR_Q_REMOVE_USER_FOREIGN_DOMAIN q_u; + SAMR_R_REMOVE_USER_FOREIGN_DOMAIN r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -1361,15 +1357,15 @@ static BOOL api_samr_unknown_2d(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if (!samr_io_q_unknown_2d("", &q_u, data, 0)) { - DEBUG(0,("api_samr_unknown_2d: unable to unmarshall SAMR_Q_UNKNOWN_2D.\n")); + if (!samr_io_q_remove_user_foreign_domain("", &q_u, data, 0)) { + DEBUG(0,("api_samr_remove_user_foreign_domain: unable to unmarshall SAMR_Q_REMOVE_USER_FOREIGN_DOMAIN.\n")); return False; } - r_u.status = _samr_unknown_2d(p, &q_u, &r_u); + r_u.status = _samr_remove_user_foreign_domain(p, &q_u, &r_u); - if (!samr_io_r_unknown_2d("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_unknown_2d: unable to marshall SAMR_R_UNKNOWN_2D.\n")); + if (!samr_io_r_remove_user_foreign_domain("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_remove_user_foreign_domain: unable to marshall SAMR_R_REMOVE_USER_FOREIGN_DOMAIN.\n")); return False; } @@ -1421,7 +1417,6 @@ static BOOL api_samr_set_dom_info(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - /* grab the samr unknown 8 command */ if(!samr_io_q_set_domain_info("", &q_u, data, 0)) { DEBUG(0,("api_samr_set_dom_info: unable to unmarshall SAMR_Q_SET_DOMAIN_INFO.\n")); return False; @@ -1488,7 +1483,7 @@ static struct api_struct api_samr_cmds [] = {"SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, {"SAMR_OPEN_GROUP" , SAMR_OPEN_GROUP , api_samr_open_group }, {"SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, - {"SAMR_UNKNOWN_2D" , SAMR_UNKNOWN_2D , api_samr_unknown_2d }, + {"SAMR_REMOVE_USER_FOREIGN_DOMAIN" , SAMR_REMOVE_USER_FOREIGN_DOMAIN , api_samr_remove_user_foreign_domain }, {"SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, {"SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a338b5eb4d..a14c6cd7e8 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -8,6 +8,7 @@ * Copyright (C) Jeremy Allison 2001-2002, * Copyright (C) Jean François Micouleau 1998-2001, * Copyright (C) Jim McDonough 2002. + * Copyright (C) Gerald (Jerry) Carter 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -3787,7 +3788,8 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM /* check if the user exists before trying to delete */ pdb_init_sam(&sam_pass); if(!pdb_getsampwsid(sam_pass, &user_sid)) { - DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n", pdb_get_username(sam_pass))); + DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n", + sid_string_static(&user_sid))); pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } @@ -4283,13 +4285,75 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G } /********************************************************************* - _samr_unknown_2d + _samr_remove_user_foreign_domain *********************************************************************/ -NTSTATUS _samr_unknown_2d(pipes_struct *p, SAMR_Q_UNKNOWN_2D *q_u, SAMR_R_UNKNOWN_2D *r_u) +NTSTATUS _samr_remove_user_foreign_domain(pipes_struct *p, + SAMR_Q_REMOVE_USER_FOREIGN_DOMAIN *q_u, + SAMR_R_REMOVE_USER_FOREIGN_DOMAIN *r_u) { - DEBUG(0,("_samr_unknown_2d: Not yet implemented.\n")); - return NT_STATUS_NOT_IMPLEMENTED; + DOM_SID user_sid, dom_sid; + SAM_ACCOUNT *sam_pass=NULL; + uint32 acc_granted; + + sid_copy( &user_sid, &q_u->sid.sid ); + + DEBUG(5,("_samr_remove_user_foreign_domain: removing user [%s]\n", + sid_string_static(&user_sid))); + + /* Find the policy handle. Open a policy on it. */ + + if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid, &acc_granted)) + return NT_STATUS_INVALID_HANDLE; + + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, + STD_RIGHT_DELETE_ACCESS, "_samr_remove_user_foreign_domain"))) + { + return r_u->status; + } + + if ( !sid_check_is_in_our_domain(&user_sid) ) { + DEBUG(5,("_samr_remove_user_foreign_domain: user not is our domain!\n")); + return NT_STATUS_NO_SUCH_USER; + } + + /* check if the user exists before trying to delete */ + + pdb_init_sam(&sam_pass); + + if ( !pdb_getsampwsid(sam_pass, &user_sid) ) { + + DEBUG(5,("_samr_remove_user_foreign_domain:User %s doesn't exist.\n", + sid_string_static(&user_sid))); + + pdb_free_sam(&sam_pass); + + return NT_STATUS_NO_SUCH_USER; + } + + /* + * delete the unix side + * + * note: we don't check if the delete really happened + * as the script is not necessary present + * and maybe the sysadmin doesn't want to delete the unix side + */ + + smb_delete_user(pdb_get_username(sam_pass)); + + /* and delete the samba side */ + + if ( !pdb_delete_sam_account(sam_pass) ) { + + DEBUG(5,("_samr_delete_dom_user:Failed to delete entry for user %s.\n", pdb_get_username(sam_pass))); + pdb_free_sam(&sam_pass); + + return NT_STATUS_CANNOT_DELETE; + } + + pdb_free_sam(&sam_pass); + + return NT_STATUS_OK; } /******************************************************************* -- cgit From 983b4e7011174961748eb5d3011ec59b25d0917e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 23 Aug 2003 03:34:24 +0000 Subject: it never amazes me when some new things crawls out of the windows spooler. :-( When installing the Adobe PS driver onto a Samba printer via cupsaddsmb, I noticed a WIN2k client sending DeletePrinterData("DependentFiles") pver and over. I also noticed that we never checked to see if the value was valid. No now we do and return WERR_BADFILE which I think is correct. Next, I noticed that we never wrote the updated printer out to disk after a succesfully DeletePrinterData[Ex](). Finally, I found a driver (Canon BJC 1000 using the Adobe PS drivers and foomatic PPD file) that was destroying the device name string in the devmode. So now get_a_printer_2() always writes out the device name in \\server\share form. I think these changes might fix bug 294. (This used to be commit deb25780874b66e68ac597db24fbc50e7f7458b5) --- source3/rpc_server/srv_spoolss.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index a903ae9029..f846813a40 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -141,7 +141,7 @@ static BOOL api_spoolss_deleteprinterdata(pipes_struct *p) return False; } - r_u.status = _spoolss_deleteprinterdata( p, &q_u, &r_u); + r_u.status = _spoolss_deleteprinterdata( p, &q_u, &r_u ); if (!spoolss_io_r_deleteprinterdata("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_deleteprinterdata: unable to marshall SPOOL_R_DELETEPRINTERDATA.\n")); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 646aac347c..7159527a7d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8023,6 +8023,9 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); status = delete_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, valuename ); + + if ( W_ERROR_IS_OK(status) ) + mod_a_printer( *printer, 2 ); free_a_printer(&printer, 2); @@ -8886,6 +8889,9 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX status = delete_printer_dataex( printer, keyname, valuename ); + if ( W_ERROR_IS_OK(status) ) + mod_a_printer( *printer, 2 ); + free_a_printer(&printer, 2); return status; -- cgit From 2f70d0d9a732556fd7616ec5c8e1fd777310c99e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 27 Aug 2003 20:50:24 +0000 Subject: renaming some functions for consistency (This used to be commit f4ca4aae8ad0496b76c710cf79c791724bdaa4ec) --- source3/rpc_server/srv_samr.c | 6 +++--- source3/rpc_server/srv_samr_nt.c | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index d9d1a45dce..a0f62c20fc 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -453,7 +453,7 @@ static BOOL api_samr_open_user(pipes_struct *p) return False; } - r_u.status = _api_samr_open_user(p, &q_u, &r_u); + r_u.status = _samr_open_user(p, &q_u, &r_u); /* store the response in the SMB stream */ if(!samr_io_r_open_user("", &r_u, rdata, 0)) { @@ -575,7 +575,7 @@ static BOOL api_samr_create_user(pipes_struct *p) return False; } - r_u.status=_api_samr_create_user(p, &q_u, &r_u); + r_u.status=_samr_create_user(p, &q_u, &r_u); /* store the response in the SMB stream */ if(!samr_io_r_create_user("", &r_u, rdata, 0)) { @@ -757,7 +757,7 @@ static BOOL api_samr_open_alias(pipes_struct *p) return False; } - r_u.status=_api_samr_open_alias(p, &q_u, &r_u); + r_u.status=_samr_open_alias(p, &q_u, &r_u); /* store the response in the SMB stream */ if(!samr_io_r_open_alias("", &r_u, rdata, 0)) { diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a14c6cd7e8..7f7b5e8d5e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1664,10 +1664,10 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK } /******************************************************************* - _api_samr_open_user. Safe - gives out no passwd info. + _samr_open_user. Safe - gives out no passwd info. ********************************************************************/ -NTSTATUS _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USER *r_u) +NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USER *r_u) { SAM_ACCOUNT *sampass=NULL; DOM_SID sid; @@ -2186,12 +2186,12 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA } /******************************************************************* - _api_samr_create_user + _samr_create_user Create an account, can be either a normal user or a machine. This funcion will need to be updated for bdc/domain trusts. ********************************************************************/ -NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREATE_USER *r_u) +NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREATE_USER *r_u) { SAM_ACCOUNT *sam_pass=NULL; fstring account; @@ -2305,12 +2305,12 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ int add_ret; all_string_sub(add_script, "%u", account, sizeof(account)); add_ret = smbrun(add_script,NULL); - DEBUG(3,("_api_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); + DEBUG(3,("_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); } else /* no add user script -- ask winbindd to do it */ { if ( !winbind_create_user( account, &new_rid ) ) { - DEBUG(3,("_api_samr_create_user: winbind_create_user(%s) failed\n", + DEBUG(3,("_samr_create_user: winbind_create_user(%s) failed\n", account)); } } @@ -2620,7 +2620,7 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN api_samr_open_alias ********************************************************************/ -NTSTATUS _api_samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_ALIAS *r_u) +NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_ALIAS *r_u) { DOM_SID sid; POLICY_HND domain_pol = q_u->dom_pol; -- cgit From 019349339e814e710b5d7e06c19441c4fe4b39f3 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 28 Aug 2003 20:48:04 +0000 Subject: getting rid of copmpiler warning (This used to be commit d3f5c5c22026b2e1e4f02617a823505ae88eab24) --- source3/rpc_server/srv_lsa_ds.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_ds.c b/source3/rpc_server/srv_lsa_ds.c index 21e18f52fc..1e75175c2c 100644 --- a/source3/rpc_server/srv_lsa_ds.c +++ b/source3/rpc_server/srv_lsa_ds.c @@ -25,6 +25,7 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +#if 0 /* disabled */ /******************************************************************* api_reg_open_entry ********************************************************************/ @@ -51,6 +52,7 @@ static BOOL api_dsrole_get_primary_dominfo(pipes_struct *p) return True; } +#endif /******************************************************************* stub functions for unimplemented RPC -- cgit From 94f59f54921174fc156fade575ca114d331b1bd8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 5 Sep 2003 19:59:55 +0000 Subject: More tuning from cachegrind. Change most trim_string() calls to trim_char(0, as that's what they do. Fix string_replace() to fast-path ascii. Jeremy. (This used to be commit f35e9a8b909d3c74be47083ccc4a4e91a14938db) --- source3/rpc_server/srv_dfs_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index eba4eaec75..3470ad99b4 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -159,7 +159,7 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, { pstring refpath; pstrcpy(refpath,jn.referral_list[i].alternate_path); - trim_string(refpath, "\\", "\\"); + trim_char(refpath, '\\', '\\'); DEBUG(10,("_dfs_remove: refpath: .%s.\n", refpath)); if(strequal(refpath, altpath)) { @@ -257,7 +257,7 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I struct referral* ref = &(j[i].referral_list[ii]); pstrcpy(path, ref->alternate_path); - trim_string(path,"\\",""); + trim_char(path,'\\','\0'); p = strrchr_m(path,'\\'); if(p==NULL) { -- cgit From 0d9410f61d5482e8dfd51dcf89dda44e125336fb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 15 Sep 2003 03:36:04 +0000 Subject: Patch from Gregory Hinton Nietsky , ensure the desired access is read from the incoming RPC request. Jeremy. (This used to be commit fdc5dda44f0190af4e4b0782cb2c5c7de3506d12) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7f7b5e8d5e..261d641ab1 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4236,7 +4236,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G struct samr_info *info; SEC_DESC *psd = NULL; uint32 acc_granted; - uint32 des_access; + uint32 des_access = q_u->access_mask; size_t sd_size; NTSTATUS status; fstring sid_string; -- cgit From 3a48e4b2875a6cb1c143377d7f6fb0be50ea80d2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Sep 2003 23:53:48 +0000 Subject: The "unknown_5" 32 bit field in the user structs is actually 2 16-bit fields, bad_password_count and logon_count. Ensure this is stored/fetched in the various SAMs. As it replaces the unknown_5 field this fits exactly into the tdb SAM without any binary problems. It also is added to the LDAP SAM as two extra attributes. It breaks compatibility with the experimental SAMs xml and mysql. The maintainers of these SAMs must fix them so upgrades like this can be done transparently. I will insist on the "experimental" status until this is solved. Jeremy. (This used to be commit cd7bd8c2daff3293d48f3376a7c5a708a140fd94) --- source3/rpc_server/srv_samr_util.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index b81c441811..db6649073e 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -189,7 +189,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); } - DEBUG(10,("INFO_21 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown_3(to),from->unknown_3)); + DEBUG(10,("INFO_21 UNKNOWN_3: %08X -> %08X\n",pdb_get_unknown_3(to),from->unknown_3)); if (from->unknown_3 != pdb_get_unknown_3(to)) { pdb_set_unknown_3(to, from->unknown_3, PDB_CHANGED); } @@ -208,12 +208,17 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) /* Fix me: only update if it changes --metze */ pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); - DEBUG(10,("INFO_21 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown_5(to),from->unknown_5)); - if (from->unknown_5 != pdb_get_unknown_5(to)) { - pdb_set_unknown_5(to, from->unknown_5, PDB_CHANGED); + DEBUG(10,("INFO_21 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count)); + if (from->bad_password_count != pdb_get_bad_password_count(to)) { + pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED); } - DEBUG(10,("INFO_21 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); + DEBUG(10,("INFO_21 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count)); + if (from->logon_count != pdb_get_logon_count(to)) { + pdb_set_logon_count(to, from->logon_count, PDB_CHANGED); + } + + DEBUG(10,("INFO_21 UNKNOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); if (from->unknown_6 != pdb_get_unknown_6(to)) { pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); } @@ -413,9 +418,14 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) /* Fix me: only update if it changes --metze */ pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); - DEBUG(10,("INFO_23 UNKOWN_5: %08X -> %08X\n",pdb_get_unknown_5(to),from->unknown_5)); - if (from->unknown_5 != pdb_get_unknown_5(to)) { - pdb_set_unknown_5(to, from->unknown_5, PDB_CHANGED); + DEBUG(10,("INFO_23 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count)); + if (from->bad_password_count != pdb_get_bad_password_count(to)) { + pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED); + } + + DEBUG(10,("INFO_23 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count)); + if (from->logon_count != pdb_get_logon_count(to)) { + pdb_set_logon_count(to, from->logon_count, PDB_CHANGED); } DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); -- cgit From 0551426657167c676f1b88443602f9268d21784e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 19 Sep 2003 21:57:43 +0000 Subject: Ensure that dup_sec_desc copies the 'type' field correctly. This caused me to expose a type arguement to make_sec_desc(). We weren't copying the SE_DESC_DACL_AUTO_INHERITED flag which could cause errors on auto inherited checks. Jeremy. (This used to be commit 28b315a7501f42928d73efaa75f74146ba95cf2d) --- source3/rpc_server/srv_lsa_nt.c | 2 +- source3/rpc_server/srv_samr_nt.c | 8 ++++---- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 330dd727ef..686a3069bb 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -334,7 +334,7 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s if((psa = make_sec_acl(mem_ctx, NT4_ACL_REVISION, 3, ace)) == NULL) return NT_STATUS_NO_MEMORY; - if((*sd = make_sec_desc(mem_ctx, SEC_DESC_REVISION, &adm_sid, NULL, NULL, psa, sd_size)) == NULL) + if((*sd = make_sec_desc(mem_ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, &adm_sid, NULL, NULL, psa, sd_size)) == NULL) return NT_STATUS_NO_MEMORY; return NT_STATUS_OK; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 261d641ab1..828e07c1ad 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -467,7 +467,7 @@ static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) return NT_STATUS_NO_MEMORY; - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) return NT_STATUS_NO_MEMORY; return NT_STATUS_OK; @@ -510,7 +510,7 @@ static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 4, ace)) == NULL) return NT_STATUS_NO_MEMORY; - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) return NT_STATUS_NO_MEMORY; return NT_STATUS_OK; @@ -549,7 +549,7 @@ static NTSTATUS samr_make_grp_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) return NT_STATUS_NO_MEMORY; - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) return NT_STATUS_NO_MEMORY; return NT_STATUS_OK; @@ -588,7 +588,7 @@ static NTSTATUS samr_make_ali_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) return NT_STATUS_NO_MEMORY; - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, sd_size)) == NULL) + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) return NT_STATUS_NO_MEMORY; return NT_STATUS_OK; diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index ea66a7d38b..4d1cf9bddc 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -184,7 +184,7 @@ static SEC_DESC *get_share_security_default( TALLOC_CTX *ctx, int snum, size_t * init_sec_ace(&ace, &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, sa, 0); if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 1, &ace)) != NULL) { - psd = make_sec_desc(ctx, SEC_DESC_REVISION, NULL, NULL, NULL, psa, psize); + psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, psize); } if (!psd) { -- cgit From d3b9384308e4b5130c9455b853edc4702d7af303 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 25 Sep 2003 21:26:16 +0000 Subject: Fix for #480. Change the interface for init_unistr2 to not take a length but a flags field. We were assuming that 2*strlen(mb_string) == length of ucs2-le string. This is not the case. Count it after conversion. Jeremy. (This used to be commit f82c273a42f930c7152cfab84394781744815e0e) --- source3/rpc_server/srv_dfs_nt.c | 12 +++---- source3/rpc_server/srv_lsa_ds_nt.c | 6 ++-- source3/rpc_server/srv_lsa_nt.c | 71 +++++++++++++++++-------------------- source3/rpc_server/srv_samr_nt.c | 23 +++++------- source3/rpc_server/srv_spoolss_nt.c | 14 ++++---- 5 files changed, 58 insertions(+), 68 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 3470ad99b4..751cb6e642 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -198,7 +198,7 @@ static BOOL init_reply_dfs_info_1(struct junction_map* j, DFS_INFO_1* dfs1, int slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), j[i].service_name, j[i].volume_name); DEBUG(5,("init_reply_dfs_info_1: %d) initing entrypath: %s\n",i,str)); - init_unistr2(&dfs1[i].entrypath,str,strlen(str)+1); + init_unistr2(&dfs1[i].entrypath,str,UNI_STR_TERMINATE); } return True; } @@ -212,7 +212,7 @@ static BOOL init_reply_dfs_info_2(struct junction_map* j, DFS_INFO_2* dfs2, int dfs2[i].ptr_entrypath = 1; slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), j[i].service_name, j[i].volume_name); - init_unistr2(&dfs2[i].entrypath, str, strlen(str)+1); + init_unistr2(&dfs2[i].entrypath, str, UNI_STR_TERMINATE); dfs2[i].ptr_comment = 0; dfs2[i].state = 1; /* set up state of dfs junction as OK */ dfs2[i].num_storages = j[i].referral_count; @@ -234,9 +234,9 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I 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); + init_unistr2(&dfs3[i].entrypath, str, UNI_STR_TERMINATE); dfs3[i].ptr_comment = 1; - init_unistr2(&dfs3[i].comment, "", 1); + init_unistr2(&dfs3[i].comment, "", UNI_STR_TERMINATE); dfs3[i].state = 1; dfs3[i].num_storages = dfs3[i].num_storage_infos = j[i].referral_count; dfs3[i].ptr_storages = 1; @@ -267,8 +267,8 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I *p = '\0'; DEBUG(5,("storage %d: %s.%s\n",ii,path,p+1)); stor->state = 2; /* set all storages as ONLINE */ - init_unistr2(&stor->servername, path, strlen(path)+1); - init_unistr2(&stor->sharename, p+1, strlen(p+1)+1); + init_unistr2(&stor->servername, path, UNI_STR_TERMINATE); + init_unistr2(&stor->sharename, p+1, UNI_STR_TERMINATE); stor->ptr_servername = stor->ptr_sharename = 1; } } diff --git a/source3/rpc_server/srv_lsa_ds_nt.c b/source3/rpc_server/srv_lsa_ds_nt.c index 37540a9668..97e9dc361d 100644 --- a/source3/rpc_server/srv_lsa_ds_nt.c +++ b/source3/rpc_server/srv_lsa_ds_nt.c @@ -77,12 +77,12 @@ static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN basic->netbios_ptr = 1; netbios_domain = get_global_sam_name(); - init_unistr2( &basic->netbios_domain, netbios_domain, strlen(netbios_domain) ); + init_unistr2( &basic->netbios_domain, netbios_domain, UNI_FLAGS_NONE); basic->dnsname_ptr = 1; - init_unistr2( &basic->dns_domain, dnsdomain, strlen(dnsdomain) ); + init_unistr2( &basic->dns_domain, dnsdomain, UNI_FLAGS_NONE); basic->forestname_ptr = 1; - init_unistr2( &basic->forest_domain, dnsdomain, strlen(dnsdomain) ); + init_unistr2( &basic->forest_domain, dnsdomain, UNI_FLAGS_NONE); /* fill in some additional fields if we are a member of an AD domain */ diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 686a3069bb..0921824cad 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -61,7 +61,12 @@ Init dom_query static void init_dom_query(DOM_QUERY *d_q, const char *dom_name, DOM_SID *dom_sid) { - int domlen = (dom_name != NULL) ? strlen(dom_name) : 0; + d_q->buffer_dom_name = (dom_name != NULL) ? 1 : 0; /* domain buffer pointer */ + d_q->buffer_dom_sid = (dom_sid != NULL) ? 1 : 0; /* domain sid pointer */ + + /* this string is supposed to be non-null terminated. */ + /* But the maxlen in this UNISTR2 must include the terminating null. */ + init_unistr2(&d_q->uni_domain_name, dom_name, UNI_MAXLEN_TERMINATE); /* * I'm not sure why this really odd combination of length @@ -71,14 +76,15 @@ static void init_dom_query(DOM_QUERY *d_q, const char *dom_name, DOM_SID *dom_si * a domain with both odd and even length names... JRA. */ - d_q->uni_dom_str_len = domlen ? ((domlen + 1) * 2) : 0; - d_q->uni_dom_max_len = domlen * 2; - d_q->buffer_dom_name = domlen != 0 ? 1 : 0; /* domain buffer pointer */ - d_q->buffer_dom_sid = dom_sid != NULL ? 1 : 0; /* domain sid pointer */ + /* + * IMPORTANT NOTE !!!! + * The two fields below probably are reversed in meaning, ie. + * the first field is probably the str_len, the second the max + * len. Both are measured in bytes anyway. + */ - /* this string is supposed to be character short */ - init_unistr2(&d_q->uni_domain_name, dom_name, domlen); - d_q->uni_domain_name.uni_max_len++; + d_q->uni_dom_str_len = d_q->uni_domain_name.uni_max_len * 2; + d_q->uni_dom_max_len = d_q->uni_domain_name.uni_str_len * 2; if (dom_sid != NULL) init_dom_sid2(&d_q->dom_sid, dom_sid); @@ -91,7 +97,6 @@ static void init_dom_query(DOM_QUERY *d_q, const char *dom_name, DOM_SID *dom_si static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) { int num = 0; - int len; if (dom_name != NULL) { for (num = 0; num < ref->num_ref_doms_1; num++) { @@ -114,14 +119,11 @@ static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) ref->max_entries = MAX_REF_DOMAINS; ref->num_ref_doms_2 = num+1; - len = (dom_name != NULL) ? strlen(dom_name) : 0; - if(dom_name != NULL && len == 0) - len = 1; - - init_uni_hdr(&ref->hdr_ref_dom[num].hdr_dom_name, len); ref->hdr_ref_dom[num].ptr_dom_sid = dom_sid != NULL ? 1 : 0; - init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name, len); + init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name, UNI_FLAGS_NONE); + init_uni_hdr(&ref->hdr_ref_dom[num].hdr_dom_name, &ref->ref_dom[num].uni_dom_name); + init_dom_sid2(&ref->ref_dom[num].ref_dom, dom_sid ); return num; @@ -349,25 +351,22 @@ static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, GUID *dom_guid, DOM_SID *dom_sid) { if (nb_name && *nb_name) { - init_uni_hdr(&r_l->hdr_nb_dom_name, strlen(nb_name)); - init_unistr2(&r_l->uni_nb_dom_name, nb_name, - strlen(nb_name)); + init_unistr2(&r_l->uni_nb_dom_name, nb_name, UNI_FLAGS_NONE); + init_uni_hdr(&r_l->hdr_nb_dom_name, &r_l->uni_nb_dom_name); r_l->hdr_nb_dom_name.uni_max_len += 2; r_l->uni_nb_dom_name.uni_max_len += 1; } if (dns_name && *dns_name) { - init_uni_hdr(&r_l->hdr_dns_dom_name, strlen(dns_name)); - init_unistr2(&r_l->uni_dns_dom_name, dns_name, - strlen(dns_name)); + init_unistr2(&r_l->uni_dns_dom_name, dns_name, UNI_FLAGS_NONE); + init_uni_hdr(&r_l->hdr_dns_dom_name, &r_l->uni_dns_dom_name); r_l->hdr_dns_dom_name.uni_max_len += 2; r_l->uni_dns_dom_name.uni_max_len += 1; } if (forest_name && *forest_name) { - init_uni_hdr(&r_l->hdr_forest_name, strlen(forest_name)); - init_unistr2(&r_l->uni_forest_name, forest_name, - strlen(forest_name)); + init_unistr2(&r_l->uni_forest_name, forest_name, UNI_FLAGS_NONE); + init_uni_hdr(&r_l->hdr_forest_name, &r_l->uni_forest_name); r_l->hdr_forest_name.uni_max_len += 2; r_l->uni_forest_name.uni_max_len += 1; } @@ -774,13 +773,13 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV for (i = 0; i < PRIV_ALL_INDEX; i++, entry++) { if( ihdr_name, 0); - init_unistr2(&entry->name, NULL, 0 ); + init_unistr2(&entry->name, NULL, UNI_FLAGS_NONE); + init_uni_hdr(&entry->hdr_name, &entry->name); entry->luid_low = 0; entry->luid_high = 0; } else { - init_uni_hdr(&entry->hdr_name, strlen(privs[i+1].priv)); - init_unistr2(&entry->name, privs[i+1].priv, strlen(privs[i+1].priv) ); + init_unistr2(&entry->name, privs[i+1].priv, UNI_FLAGS_NONE); + init_uni_hdr(&entry->hdr_name, &entry->name); entry->luid_low = privs[i+1].se_priv; entry->luid_high = 0; } @@ -822,8 +821,8 @@ NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, L if (privs[i].se_priv!=SE_PRIV_ALL) { DEBUG(10,(": %s\n", privs[i].description)); - init_uni_hdr(&r_u->hdr_desc, strlen(privs[i].description)); - init_unistr2(&r_u->desc, privs[i].description, strlen(privs[i].description) ); + init_unistr2(&r_u->desc, privs[i].description, UNI_FLAGS_NONE); + init_uni_hdr(&r_u->hdr_desc, &r_u->desc); r_u->ptr_info=0xdeadbeef; r_u->lang_id=q_u->lang_id; @@ -890,7 +889,6 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u) { fstring username, domname; - int ulen, dlen; user_struct *vuser = get_valid_user_struct(p->vuid); if (vuser == NULL) @@ -899,18 +897,15 @@ NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA fstrcpy(username, vuser->user.smb_name); fstrcpy(domname, vuser->user.domain); - ulen = strlen(username) + 1; - dlen = strlen(domname) + 1; - - init_uni_hdr(&r_u->hdr_user_name, ulen); r_u->ptr_user_name = 1; - init_unistr2(&r_u->uni2_user_name, username, ulen); + init_unistr2(&r_u->uni2_user_name, username, UNI_STR_TERMINATE); + init_uni_hdr(&r_u->hdr_user_name, &r_u->uni2_user_name); r_u->unk1 = 1; - init_uni_hdr(&r_u->hdr_dom_name, dlen); r_u->ptr_dom_name = 1; - init_unistr2(&r_u->uni2_dom_name, domname, dlen); + init_unistr2(&r_u->uni2_dom_name, domname, UNI_STR_TERMINATE); + init_uni_hdr(&r_u->hdr_dom_name, &r_u->uni2_dom_name); r_u->status = NT_STATUS_OK; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 828e07c1ad..71e5bc7d70 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -719,7 +719,7 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UN for (i = 0; i < num_entries; i++) { pwd = &disp_user_info[i+start_idx]; temp_name = pdb_get_username(pwd); - init_unistr2(&uni_temp_name, temp_name, strlen(temp_name)+1); + init_unistr2(&uni_temp_name, temp_name, UNI_STR_TERMINATE); user_sid = pdb_get_user_sid(pwd); if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { @@ -731,7 +731,7 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UN return NT_STATUS_UNSUCCESSFUL; } - init_sam_entry(&sam[i], uni_temp_name.uni_str_len, user_rid); + init_sam_entry(&sam[i], &uni_temp_name, user_rid); copy_unistr2(&uni_name[i], &uni_temp_name); } @@ -865,10 +865,8 @@ static void make_group_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNIST /* * JRA. I think this should include the null. TNG does not. */ - int len = strlen(grp[i].name)+1; - - init_sam_entry(&sam[i], len, grp[i].rid); - init_unistr2(&uni_name[i], grp[i].name, len); + init_unistr2(&uni_name[i], grp[i].name, UNI_STR_TERMINATE); + init_sam_entry(&sam[i], &uni_name[i], grp[i].rid); } *sam_pp = sam; @@ -1580,10 +1578,9 @@ static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, fstring nam } for (i = 0; i < num_names; i++) { - int len = names[i] != NULL ? strlen(names[i]) : 0; - DEBUG(10, ("names[%d]:%s\n", i, names[i])); - init_uni_hdr(&hdr_name[i], len); - init_unistr2(&uni_name[i], names[i], len); + DEBUG(10, ("names[%d]:%s\n", i, names[i] ? names[i] : "")); + init_unistr2(&uni_name[i], names[i], UNI_FLAGS_NONE); + init_uni_hdr(&hdr_name[i], &uni_name[i]); } *pp_uni_name = uni_name; @@ -2570,10 +2567,8 @@ static BOOL make_enum_domains(TALLOC_CTX *ctx, SAM_ENTRY **pp_sam, return False; for (i = 0; i < num_sam_entries; i++) { - int len = doms[i] != NULL ? strlen(doms[i]) : 0; - - init_sam_entry(&sam[i], len, 0); - init_unistr2(&uni_name[i], doms[i], len); + init_unistr2(&uni_name[i], doms[i], UNI_FLAGS_NONE); + init_sam_entry(&sam[i], &uni_name[i], 0); } *pp_sam = sam; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7159527a7d..493f58f8a8 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -690,7 +690,7 @@ static void notify_string(struct spoolss_notify_msg *msg, /* The length of the message includes the trailing \0 */ - init_unistr2(&unistr, msg->notify.data, msg->len); + init_unistr2(&unistr, msg->notify.data, UNI_STR_TERMINATE); data->notify_data.data.length = msg->len * 2; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, msg->len * 2); @@ -6121,7 +6121,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, */ if (!strequal(printer->info_2->comment, old_printer->info_2->comment)) { - init_unistr2( &buffer, printer->info_2->comment, strlen(printer->info_2->comment)+1 ); + init_unistr2( &buffer, printer->info_2->comment, UNI_STR_TERMINATE); set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "description", REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); @@ -6129,7 +6129,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, } if (!strequal(printer->info_2->sharename, old_printer->info_2->sharename)) { - init_unistr2( &buffer, printer->info_2->sharename, strlen(printer->info_2->sharename)+1 ); + init_unistr2( &buffer, printer->info_2->sharename, UNI_STR_TERMINATE); set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "printerName", REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "shareName", @@ -6139,7 +6139,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, } if (!strequal(printer->info_2->portname, old_printer->info_2->portname)) { - init_unistr2( &buffer, printer->info_2->portname, strlen(printer->info_2->portname)+1 ); + init_unistr2( &buffer, printer->info_2->portname, UNI_STR_TERMINATE); set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "portName", REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); @@ -6147,7 +6147,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, } if (!strequal(printer->info_2->location, old_printer->info_2->location)) { - init_unistr2( &buffer, printer->info_2->location, strlen(printer->info_2->location)+1 ); + init_unistr2( &buffer, printer->info_2->location, UNI_STR_TERMINATE); set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "location", REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); @@ -6157,7 +6157,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, /* here we need to update some more DsSpooler keys */ /* uNCName, serverName, shortServerName */ - init_unistr2( &buffer, global_myname(), strlen(global_myname())+1 ); + init_unistr2( &buffer, global_myname(), UNI_STR_TERMINATE); set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "serverName", REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "shortServerName", @@ -6165,7 +6165,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, slprintf( asc_buffer, sizeof(asc_buffer)-1, "\\\\%s\\%s", global_myname(), printer->info_2->sharename ); - init_unistr2( &buffer, asc_buffer, strlen(asc_buffer)+1 ); + init_unistr2( &buffer, asc_buffer, UNI_STR_TERMINATE); set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "uNCName", REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); -- cgit From cbe69f65f69b0c7b7c2d0d32005da488b50e52ba Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 1 Oct 2003 21:18:32 +0000 Subject: commit sign only patch from Andrew; bug 167; tested using 2k & XP clientspreviously joined to the Samba domain (This used to be commit 3802f5895ee18507c6f467bd11db0b1147a6fdfd) --- source3/rpc_server/srv_pipe.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index d1fb587d74..96261c665f 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -254,18 +254,19 @@ BOOL create_next_pdu(pipes_struct *p) } if (p->netsec_auth_validated) { + int auth_type, auth_level; char *data; RPC_HDR_AUTH auth_info; - static const uchar netsec_sig[8] = NETSEC_SIGNATURE; - static const uchar nullbytes[8] = { 0,0,0,0,0,0,0,0 }; RPC_AUTH_NETSEC_CHK verf; prs_struct rverf; prs_struct rauth; data = prs_data_p(&outgoing_pdu) + data_pos; + /* Check it's the type of reply we were expecting to decode */ - init_rpc_hdr_auth(&auth_info, NETSEC_AUTH_TYPE, RPC_PIPE_AUTH_SEAL_LEVEL, + get_auth_type_level(p->netsec_auth.auth_flags, &auth_type, &auth_level); + init_rpc_hdr_auth(&auth_info, auth_type, auth_level, RPC_HDR_AUTH_LEN, 1); if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { @@ -277,10 +278,8 @@ BOOL create_next_pdu(pipes_struct *p) prs_init(&rverf, 0, p->mem_ctx, MARSHALL); prs_init(&rauth, 0, p->mem_ctx, MARSHALL); - init_rpc_auth_netsec_chk(&verf, netsec_sig, nullbytes, nullbytes, nullbytes); - netsec_encode(&p->netsec_auth, - AUTH_PIPE_NETSEC|AUTH_PIPE_SIGN|AUTH_PIPE_SEAL, + p->netsec_auth.auth_flags, SENDER_IS_ACCEPTOR, &verf, data, data_len); @@ -1337,10 +1336,19 @@ BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) return False; } - if ((auth_info.auth_type != NETSEC_AUTH_TYPE) || - (auth_info.auth_level != RPC_PIPE_AUTH_SEAL_LEVEL)) { - DEBUG(0,("Invalid auth info %d or level %d on schannel\n", - auth_info.auth_type, auth_info.auth_level)); + if (auth_info.auth_type != NETSEC_AUTH_TYPE) { + DEBUG(0,("Invalid auth info %d on schannel\n", + auth_info.auth_type)); + return False; + } + + if (auth_info.auth_level == RPC_PIPE_AUTH_SEAL_LEVEL) { + p->netsec_auth.auth_flags = AUTH_PIPE_NETSEC|AUTH_PIPE_SIGN|AUTH_PIPE_SEAL; + } else if (auth_info.auth_level == RPC_PIPE_AUTH_SIGN_LEVEL) { + p->netsec_auth.auth_flags = AUTH_PIPE_NETSEC|AUTH_PIPE_SIGN; + } else { + DEBUG(0,("Invalid auth level %d on schannel\n", + auth_info.auth_level)); return False; } @@ -1350,7 +1358,7 @@ BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) } if (!netsec_decode(&p->netsec_auth, - AUTH_PIPE_NETSEC|AUTH_PIPE_SIGN|AUTH_PIPE_SEAL, + p->netsec_auth.auth_flags, SENDER_IS_INITIATOR, &netsec_chk, prs_data_p(rpc_in)+old_offset, data_len)) { -- cgit From 3092718ab127bcf83138552a0518cea070451d14 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 2 Oct 2003 17:36:47 +0000 Subject: Portability fix from schmitz@hp.com (Joachim Schmitz) for bug #548. Jeremy. (This used to be commit 6677eba28a1f2de11c36e3edc5b7d2854452bd04) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 493f58f8a8..f2fb02176b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1803,7 +1803,7 @@ Can't find printer handle we created for printer %s\n", name )); && (RA_WIN2K == get_remote_arch()) ) { DEBUG(10,("_spoolss_open_printer_ex: Enabling LAN/WAN hack for Win2k clients.\n")); - usleep( 500000 ); + sys_usleep( 500000 ); } return WERR_OK; -- cgit From b1f610ebb1ba1e6ae0f0e9fbbc703f6a4af68b67 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 6 Oct 2003 01:38:46 +0000 Subject: split some security related functions in their own files. (no need to include all of smbd files to use some basic sec functions) also minor compile fixes couldn't compile to test these due to some kerberos problems wirh 3.0, but on HEAD they're working well, so I suppose it's ok to commit (This used to be commit c78f2d0bd15ecd2ba643bb141cc35a3405787aa1) --- source3/rpc_server/srv_lsa.c | 2 +- source3/rpc_server/srv_lsa_nt.c | 70 ++++++++++++++++++++--------------------- 2 files changed, 36 insertions(+), 36 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 138fb1d7ef..5d6c1551c9 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -443,7 +443,7 @@ static BOOL api_lsa_enum_privsaccount(pipes_struct *p) return False; } - r_u.status = _lsa_enum_privsaccount(p, &q_u, &r_u); + r_u.status = _lsa_enum_privsaccount(p, rdata, &q_u, &r_u); /* store the response in the SMB stream */ if(!lsa_io_r_enum_privsaccount("", &r_u, rdata, 0)) { diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 0921824cad..0a8ad404cb 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -955,7 +955,7 @@ NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENAC For a given SID, enumerate all the privilege this account has. ***************************************************************************/ -NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_R_ENUMPRIVSACCOUNT *r_u) +NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, prs_struct *ps, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_R_ENUMPRIVSACCOUNT *r_u) { struct lsa_info *info=NULL; GROUP_MAP map; @@ -971,29 +971,29 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, LSA_Q_ENUMPRIVSACCOUNT *q_u, LS return NT_STATUS_NO_SUCH_GROUP; #if 0 /* privileges currently not implemented! */ - DEBUG(10,("_lsa_enum_privsaccount: %d privileges\n", map.priv_set.count)); - if (map.priv_set.count!=0) { + DEBUG(10,("_lsa_enum_privsaccount: %d privileges\n", map.priv_set->count)); + if (map.priv_set->count!=0) { - set=(LUID_ATTR *)talloc(p->mem_ctx, map.priv_set.count*sizeof(LUID_ATTR)); + set=(LUID_ATTR *)talloc(map.priv_set->mem_ctx, map.priv_set.count*sizeof(LUID_ATTR)); if (set == NULL) { - free_privilege(&map.priv_set); + destroy_privilege(&map.priv_set); return NT_STATUS_NO_MEMORY; } - for (i=0; iset[i].luid.low; + set[i].luid.high = map.priv_set->set[i].luid.high; + set[i].attr = map.priv_set->set[i].attr; DEBUG(10,("_lsa_enum_privsaccount: priv %d: %d:%d:%d\n", i, set[i].luid.high, set[i].luid.low, set[i].attr)); } } - init_lsa_r_enum_privsaccount(r_u, set, map.priv_set.count, 0); - free_privilege(&map.priv_set); + init_lsa_r_enum_privsaccount(ps->mem_ctx, r_u, set, map.priv_set->count, 0); + destroy_privilege(&map.priv_set); #endif - init_lsa_r_enum_privsaccount(r_u, set, 0, 0); + init_lsa_r_enum_privsaccount(ps->mem_ctx, r_u, set, 0, 0); return r_u->status; } @@ -1059,11 +1059,11 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u) { #if 0 - struct lsa_info *info=NULL; + struct lsa_info *info = NULL; GROUP_MAP map; - int i=0; - LUID_ATTR *luid_attr=NULL; - PRIVILEGE_SET *set=NULL; + int i = 0; + LUID_ATTR *luid_attr = NULL; + PRIVILEGE_SET *set = NULL; #endif r_u->status = NT_STATUS_OK; @@ -1076,24 +1076,24 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u if (!pdb_getgrsid(&map, info->sid)) return NT_STATUS_NO_SUCH_GROUP; - set=&q_u->set; + set = &q_u->set; - for (i=0; icount; i++) { - luid_attr=&set->set[i]; + for (i = 0; i < set->count; i++) { + luid_attr = &set->set[i]; /* check if the privilege is already there */ - if (check_priv_in_privilege(&map.priv_set, *luid_attr)){ - free_privilege(&map.priv_set); + if (check_priv_in_privilege(map.priv_set, *luid_attr)){ + destroy_privilege(&map.priv_set); return NT_STATUS_NO_SUCH_PRIVILEGE; } - add_privilege(&map.priv_set, *luid_attr); + add_privilege(map.priv_set, *luid_attr); } if(!pdb_update_group_mapping_entry(&map)) return NT_STATUS_NO_SUCH_GROUP; - free_privilege(&map.priv_set); + destroy_privilege(&map.priv_set); #endif return r_u->status; @@ -1106,11 +1106,11 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEPRIVS *r_u) { #if 0 - struct lsa_info *info=NULL; + struct lsa_info *info = NULL; GROUP_MAP map; int i=0; - LUID_ATTR *luid_attr=NULL; - PRIVILEGE_SET *set=NULL; + LUID_ATTR *luid_attr = NULL; + PRIVILEGE_SET *set = NULL; #endif r_u->status = NT_STATUS_OK; @@ -1123,37 +1123,37 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP if (!pdb_getgrsid(&map, info->sid)) return NT_STATUS_NO_SUCH_GROUP; - if (q_u->allrights!=0) { + if (q_u->allrights != 0) { /* log it and return, until I see one myself don't do anything */ DEBUG(5,("_lsa_removeprivs: trying to remove all privileges ?\n")); return NT_STATUS_OK; } - if (q_u->ptr==0) { + if (q_u->ptr == 0) { /* log it and return, until I see one myself don't do anything */ DEBUG(5,("_lsa_removeprivs: no privileges to remove ?\n")); return NT_STATUS_OK; } - set=&q_u->set; + set = &q_u->set; - for (i=0; icount; i++) { - luid_attr=&set->set[i]; + for (i = 0; i < set->count; i++) { + luid_attr = &set->set[i]; /* if we don't have the privilege, we're trying to remove, give up */ /* what else can we do ??? JFM. */ - if (!check_priv_in_privilege(&map.priv_set, *luid_attr)){ - free_privilege(&map.priv_set); + if (!check_priv_in_privilege(map.priv_set, *luid_attr)){ + destroy_privilege(&map.priv_set); return NT_STATUS_NO_SUCH_PRIVILEGE; } - remove_privilege(&map.priv_set, *luid_attr); + remove_privilege(map.priv_set, *luid_attr); } if(!pdb_update_group_mapping_entry(&map)) return NT_STATUS_NO_SUCH_GROUP; - free_privilege(&map.priv_set); + destroy_privilege(&map.priv_set); #endif return r_u->status; } -- cgit From f589164ed94d79161d0798296c325b81c5eadbc7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 21 Oct 2003 21:19:00 +0000 Subject: Patch from Stefan Metzmacher to fix signing problems when reverse connecting back to a client for printer notify. Jeremy. (This used to be commit 06aa434c3fdb139e3f3143d19413556945cbcd4f) --- source3/rpc_server/srv_spoolss_nt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f2fb02176b..15578f6148 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2598,7 +2598,8 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, } the_cli->protocol = PROTOCOL_NT1; - + cli_setup_signing_state(the_cli, lp_client_signing()); + if (!cli_negprot(the_cli)) { DEBUG(0,("spoolss_connect_to_client: machine %s rejected the negotiate protocol. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); cli_shutdown(the_cli); -- cgit From 0ce2c6ecb8f6e88a42ab44e07a0b89344c922f0e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 28 Oct 2003 00:51:21 +0000 Subject: Fix for bug #667. DFS filenames can now have arbitrary case. Jeremy. (This used to be commit 74148111e16a863d5a33511e5b15632a736d7e99) --- source3/rpc_server/srv_dfs_nt.c | 58 +++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 751cb6e642..ac3ed9c394 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -70,6 +70,7 @@ WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) pstrcat(altpath, "\\"); pstrcat(altpath, sharename); + /* The following call can change the cwd. */ if(get_referred_path(dfspath, &jn, NULL, NULL)) { exists = True; @@ -79,6 +80,8 @@ WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) else jn.referral_count = 1; + vfs_ChDir(p->conn,p->conn->connectpath); + jn.referral_list = (struct referral*) talloc(p->mem_ctx, jn.referral_count * sizeof(struct referral)); @@ -100,8 +103,11 @@ WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) pstrcpy(jn.referral_list[jn.referral_count-1].alternate_path, altpath); - if(!create_msdfs_link(&jn, exists)) + if(!create_msdfs_link(&jn, exists)) { + vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_CANT_CREATE_JUNCT; + } + vfs_ChDir(p->conn,p->conn->connectpath); return WERR_OK; } @@ -147,8 +153,11 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, /* if no server-share pair given, remove the msdfs link completely */ if(!q_u->ptr_ServerName && !q_u->ptr_ShareName) { - if(!remove_msdfs_link(&jn)) + if(!remove_msdfs_link(&jn)) { + vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; + } + vfs_ChDir(p->conn,p->conn->connectpath); } else { @@ -175,13 +184,19 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, /* Only one referral, remove it */ if(jn.referral_count == 1) { - if(!remove_msdfs_link(&jn)) + if(!remove_msdfs_link(&jn)) { + vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; + } + vfs_ChDir(p->conn,p->conn->connectpath); } else { - if(!create_msdfs_link(&jn, True)) + if(!create_msdfs_link(&jn, True)) { + vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_CANT_CREATE_JUNCT; + } + vfs_ChDir(p->conn,p->conn->connectpath); } } @@ -325,7 +340,8 @@ WERROR _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u) int num_jn = 0; num_jn = enum_msdfs_links(jn); - + vfs_ChDir(p->conn,p->conn->connectpath); + DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", num_jn, level)); r_u->ptr_buffer = level; @@ -351,21 +367,25 @@ WERROR _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u) WERROR _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u, DFS_R_DFS_GET_INFO *r_u) { - UNISTR2* uni_path = &q_u->uni_path; - uint32 level = q_u->level; - pstring path; - struct junction_map jn; - - unistr2_to_ascii(path, uni_path, sizeof(path)-1); - if(!create_junction(path, &jn)) - return WERR_DFS_NO_SUCH_SERVER; + UNISTR2* uni_path = &q_u->uni_path; + uint32 level = q_u->level; + pstring path; + struct junction_map jn; + + unistr2_to_ascii(path, uni_path, sizeof(path)-1); + if(!create_junction(path, &jn)) + return WERR_DFS_NO_SUCH_SERVER; - if(!get_referred_path(path, &jn, NULL, NULL)) - return WERR_DFS_NO_SUCH_VOL; + /* The following call can change the cwd. */ + if(!get_referred_path(path, &jn, NULL, NULL)) { + vfs_ChDir(p->conn,p->conn->connectpath); + return WERR_DFS_NO_SUCH_VOL; + } - r_u->level = level; - r_u->ptr_ctr = 1; - r_u->status = init_reply_dfs_ctr(p->mem_ctx, level, &r_u->ctr, &jn, 1); + vfs_ChDir(p->conn,p->conn->connectpath); + r_u->level = level; + r_u->ptr_ctr = 1; + r_u->status = init_reply_dfs_ctr(p->mem_ctx, level, &r_u->ctr, &jn, 1); - return r_u->status; + return r_u->status; } -- cgit From fbb8f131c2336e921677f41e9fb8bce7406f3336 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 3 Nov 2003 14:34:25 +0000 Subject: Fix more 64-bit printf warnings. (This used to be commit 23443e3aa079710221557e18158d0ddb8ff48a36) --- source3/rpc_server/srv_lsa_hnd.c | 4 ++-- source3/rpc_server/srv_pipe_hnd.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 814fa60aab..2ec62e2c57 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -89,8 +89,8 @@ BOOL init_pipe_handle_list(pipes_struct *p, char *pipe_name) p->pipe_handles = hl; - DEBUG(10,("init_pipe_handles: pipe_handles ref count = %u for pipe %s\n", - p->pipe_handles->pipe_ref_count, pipe_name )); + DEBUG(10,("init_pipe_handles: pipe_handles ref count = %lu for pipe %s\n", + (unsigned long)p->pipe_handles->pipe_ref_count, pipe_name )); return True; } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 55def97673..9297278764 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -541,7 +541,7 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) void free_pipe_context(pipes_struct *p) { if (p->mem_ctx) { - DEBUG(3,("free_pipe_context: destroying talloc pool of size %u\n", talloc_pool_size(p->mem_ctx) )); + DEBUG(3,("free_pipe_context: destroying talloc pool of size %lu\n", talloc_pool_size((unsigned long)p->mem_ctx) )); talloc_destroy_pool(p->mem_ctx); } else { p->mem_ctx = talloc_init("pipe %s %p", p->name, p); -- cgit From cedc6341183fe6f0a64fc694e4475efa6c2c528e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 4 Nov 2003 19:53:37 +0000 Subject: Fix typo in debug statement. (This used to be commit 66e5043553939be2b124bec8581f08b01fdf9c1e) --- source3/rpc_server/srv_pipe_hnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 9297278764..57e45d477f 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -541,7 +541,7 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) void free_pipe_context(pipes_struct *p) { if (p->mem_ctx) { - DEBUG(3,("free_pipe_context: destroying talloc pool of size %lu\n", talloc_pool_size((unsigned long)p->mem_ctx) )); + DEBUG(3,("free_pipe_context: destroying talloc pool of size %lu\n", (unsigned long)talloc_pool_size(p->mem_ctx) )); talloc_destroy_pool(p->mem_ctx); } else { p->mem_ctx = talloc_init("pipe %s %p", p->name, p); -- cgit From ec04a974968bba6e4dc9ed0eb246f054af9602fc Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 7 Nov 2003 08:34:43 +0000 Subject: Remove compleatly wrong comments. (There were correct, 2 years ago...) Andrew Bartlett (This used to be commit 256b85802e5820847fbad4305fcb0f5da2e51975) --- source3/rpc_server/srv_netlog_nt.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 602cd7d2d5..e6d005b157 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -581,8 +581,6 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return NT_STATUS_INVALID_INFO_CLASS; } /* end switch */ - /* check username exists */ - rpcstr_pull(nt_username,uni_samlogon_user->buffer,sizeof(nt_username),uni_samlogon_user->uni_str_len*2,0); rpcstr_pull(nt_domain,uni_samlogon_domain->buffer,sizeof(nt_domain),uni_samlogon_domain->uni_str_len*2,0); rpcstr_pull(nt_workstation,uni_samlogon_workstation->buffer,sizeof(nt_workstation),uni_samlogon_workstation->uni_str_len*2,0); @@ -593,10 +591,6 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * fstrcpy(current_user_info.smb_name, nt_username); sub_set_smb_name(nt_username); - /* - * Convert to a UNIX username. - */ - DEBUG(5,("Attempting validation level %d for unmapped username %s.\n", q_u->sam_id.ctr->switch_value, nt_username)); status = NT_STATUS_OK; -- cgit From 5cfe36d09d1de8c6a82152d4941c1563111f4364 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 7 Nov 2003 18:32:23 +0000 Subject: Handle munged dial string. Patch from Aur?lien Degr?mont with memory leak fixes by me. Jeremy. (This used to be commit e591854eda8568ed1a4ad6b9de64e523c02b4392) --- source3/rpc_server/srv_samr_nt.c | 37 ++++++++++++++++++++++- source3/rpc_server/srv_samr_util.c | 60 +++++++++++++++++++++++++++++++------- 2 files changed, 86 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 71e5bc7d70..446eff9045 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2788,6 +2788,38 @@ static BOOL set_unix_primary_group(SAM_ACCOUNT *sampass) } +/******************************************************************* + set_user_info_20 + ********************************************************************/ + +static BOOL set_user_info_20(SAM_USER_INFO_20 *id20, DOM_SID *sid) +{ + SAM_ACCOUNT *pwd = NULL; + + if (id20 == NULL) { + DEBUG(5, ("set_user_info_20: NULL id20\n")); + return False; + } + + pdb_init_sam(&pwd); + + if (!pdb_getsampwsid(pwd, sid)) { + pdb_free_sam(&pwd); + return False; + } + + copy_id20_to_sam_passwd(pwd, id20); + + /* write the change out */ + if(!pdb_update_sam_account(pwd)) { + pdb_free_sam(&pwd); + return False; + } + + pdb_free_sam(&pwd); + + return True; +} /******************************************************************* set_user_info_21 ********************************************************************/ @@ -3091,6 +3123,10 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ if (!set_user_info_21(ctr->info.id21, &sid)) return NT_STATUS_ACCESS_DENIED; break; + case 20: + if (!set_user_info_20(ctr->info.id20, &sid)) + return NT_STATUS_ACCESS_DENIED; + break; case 16: if (!set_user_info_10(ctr->info.id10, &sid)) return NT_STATUS_ACCESS_DENIED; @@ -4537,4 +4573,3 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R return r_u->status; } - diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index db6649073e..82f93a5b4c 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -31,6 +31,36 @@ (!old_string && new_string) ||\ (old_string && new_string && (strcmp(old_string, new_string) != 0)) +#define STRING_CHANGED_NC(s1,s2) ((s1) && !(s2)) ||\ + (!(s1) && (s2)) ||\ + ((s1) && (s2) && (strcmp((s1), (s2)) != 0)) + +/************************************************************* + Copies a SAM_USER_INFO_20 to a SAM_ACCOUNT +**************************************************************/ + +void copy_id20_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_20 *from) +{ + const char *old_string; + char *new_string; + DATA_BLOB mung; + + if (from == NULL || to == NULL) + return; + + if (from->hdr_munged_dial.buffer) { + old_string = pdb_get_munged_dial(to); + mung.length = from->hdr_munged_dial.uni_str_len; + mung.data = (uint8 *) from->uni_munged_dial.buffer; + new_string = base64_encode_data_blob(mung); + DEBUG(10,("INFO_20 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED_NC(old_string,new_string)) + pdb_set_munged_dial(to , new_string, PDB_CHANGED); + + SAFE_FREE(new_string); + } +} + /************************************************************* Copies a SAM_USER_INFO_21 to a SAM_ACCOUNT **************************************************************/ @@ -39,6 +69,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) { time_t unix_time, stored_time; const char *old_string, *new_string; + DATA_BLOB mung; if (from == NULL || to == NULL) return; @@ -162,11 +193,16 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) } if (from->hdr_munged_dial.buffer) { + char *newstr; old_string = pdb_get_munged_dial(to); - new_string = unistr2_static(&from->uni_munged_dial); - DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_munged_dial(to , new_string, PDB_CHANGED); + mung.length = from->hdr_munged_dial.uni_str_len; + mung.data = (uint8 *) from->uni_munged_dial.buffer; + newstr = base64_encode_data_blob(mung); + DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); + if (STRING_CHANGED_NC(old_string,newstr)) + pdb_set_munged_dial(to , newstr, PDB_CHANGED); + + SAFE_FREE(newstr); } if (from->user_rid == 0) { @@ -250,6 +286,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) { time_t unix_time, stored_time; const char *old_string, *new_string; + DATA_BLOB mung; if (from == NULL || to == NULL) return; @@ -373,11 +410,16 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) } if (from->hdr_munged_dial.buffer) { + char *newstr; old_string = pdb_get_munged_dial(to); - new_string = unistr2_static(&from->uni_munged_dial); - DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_munged_dial(to , new_string, PDB_CHANGED); + mung.length = from->hdr_munged_dial.uni_str_len; + mung.data = (uint8 *) from->uni_munged_dial.buffer; + newstr = base64_encode_data_blob(mung); + DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); + if (STRING_CHANGED_NC(old_string, newstr)) + pdb_set_munged_dial(to , newstr, PDB_CHANGED); + + SAFE_FREE(newstr); } if (from->user_rid == 0) { @@ -450,5 +492,3 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) DEBUG(10,("INFO_23 PADDING_4: %08X\n",from->padding4)); } - - -- cgit From 6ebde91c44402f830b5887f11037b6fa625c16bc Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 7 Nov 2003 23:04:06 +0000 Subject: * only install swat html files once * revert the change that prevent the guest account from being added to a passdb backend since it broke the build farm. * apply patch from Alex Deiter to fix the "smbldap_open: cannot access when not root error" messages when looking up group information (bug 281) (This used to be commit 9b8bf6a950186bd95abe952af4a7d35829b34ff8) --- source3/rpc_server/srv_samr_nt.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 446eff9045..b3e6478c88 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -894,7 +894,9 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM /* well-known aliases */ if (sid_equal(sid, &global_sid_Builtin) && !lp_hide_local_users()) { + become_root(); pdb_enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ONLY_MAPPED); + unbecome_root(); if (num_entries != 0) { *d_grp=(DOMAIN_GRP *)talloc_zero(ctx, num_entries*sizeof(DOMAIN_GRP)); @@ -914,6 +916,7 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM struct sys_grent *grp; gid_t winbind_gid_low, winbind_gid_high; BOOL winbind_groups_exist = lp_idmap_gid(&winbind_gid_low, &winbind_gid_high); + BOOL ret; /* local aliases */ /* we return the UNIX groups here. This seems to be the right */ @@ -930,7 +933,10 @@ static NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM for (; (num_entries < max_entries) && (grp != NULL); grp = grp->next) { uint32 trid; - if(!pdb_getgrgid(&smap, grp->gr_gid)) + become_root(); + ret = pdb_getgrgid(&smap, grp->gr_gid); + unbecome_root(); + if( !ret ) continue; if (smap.sid_name_use!=SID_NAME_ALIAS) { @@ -4111,6 +4117,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM int num_uids=0; GROUP_INFO_CTR *ctr; uint32 acc_granted; + BOOL ret; if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; @@ -4119,7 +4126,10 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM return r_u->status; } - if (!get_domain_group_from_sid(group_sid, &map)) + become_root(); + ret = get_domain_group_from_sid(group_sid, &map); + unbecome_root(); + if (!ret) return NT_STATUS_INVALID_HANDLE; ctr=(GROUP_INFO_CTR *)talloc_zero(p->mem_ctx, sizeof(GROUP_INFO_CTR)); @@ -4271,6 +4281,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G size_t sd_size; NTSTATUS status; fstring sid_string; + BOOL ret; if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; @@ -4305,7 +4316,10 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G DEBUG(10, ("_samr_open_group:Opening SID: %s\n", sid_string)); /* check if that group really exists */ - if (!get_domain_group_from_sid(info->sid, &map)) + become_root(); + ret = get_domain_group_from_sid(info->sid, &map); + unbecome_root(); + if (!ret) return NT_STATUS_NO_SUCH_GROUP; /* get a (unique) handle. open a policy on it. */ -- cgit From 4097f5ec8dbca0be7b4310c4b30961c0b6835f69 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 17 Nov 2003 16:06:10 +0000 Subject: * make sure we only enumerate group mapping entries (not /etc/group) even when doing local aliases * remove "hide local users" parameter; we have this behavior built into 3.0 (This used to be commit a7685a069766ac720f0b26fe01b0e17fc388fca3) --- source3/rpc_server/srv_samr_nt.c | 179 ++++++++++----------------------------- 1 file changed, 44 insertions(+), 135 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b3e6478c88..1cfa8b2853 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -875,140 +875,11 @@ 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 NTSTATUS get_group_alias_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, - uint32 *p_num_entries, uint32 max_entries) -{ - fstring sid_str; - uint32 num_entries = 0; - int i; - GROUP_MAP smap; - GROUP_MAP *map = NULL; - - sid_to_string(sid_str, sid); - DEBUG(5, ("get_group_alias_entries: enumerating aliases on SID: %s\n", sid_str)); - - *p_num_entries = 0; - - /* well-known aliases */ - if (sid_equal(sid, &global_sid_Builtin) && !lp_hide_local_users()) { - - become_root(); - pdb_enum_group_mapping(SID_NAME_WKN_GRP, &map, (int *)&num_entries, ENUM_ONLY_MAPPED); - unbecome_root(); - - if (num_entries != 0) { - *d_grp=(DOMAIN_GRP *)talloc_zero(ctx, num_entries*sizeof(DOMAIN_GRP)); - if (*d_grp==NULL) - return NT_STATUS_NO_MEMORY; - - for(i=0; inext) { - uint32 trid; - - become_root(); - ret = pdb_getgrgid(&smap, grp->gr_gid); - unbecome_root(); - if( !ret ) - continue; - - if (smap.sid_name_use!=SID_NAME_ALIAS) { - continue; - } - - sid_split_rid(&smap.sid, &trid); - - if (!sid_equal(sid, &smap.sid)) - continue; - - /* Don't return winbind groups as they are not local! */ - if (winbind_groups_exist && (grp->gr_gid >= winbind_gid_low)&&(grp->gr_gid <= winbind_gid_high)) { - DEBUG(10,("get_group_alias_entries: not returing %s, not local.\n", smap.nt_name )); - continue; - } - - /* Don't return user private groups... */ - - if (Get_Pwnam(smap.nt_name) != 0) { - DEBUG(10,("get_group_alias_entries: not returing %s, clashes with user.\n", smap.nt_name )); - continue; - } - - for( i = 0; i < num_entries; i++) - if ( (*d_grp)[i].rid == trid ) - break; - - if ( i < num_entries ) { - continue; /* rid was there, dup! */ - } - - /* JRA - added this for large group db enumeration... */ - - if (start_idx > 0) { - /* skip the requested number of entries. - not very efficient, but hey... - */ - start_idx--; - continue; - } - - *d_grp=talloc_realloc(ctx,*d_grp, (num_entries+1)*sizeof(DOMAIN_GRP)); - if (*d_grp==NULL) { - grent_free(glist); - return NT_STATUS_NO_MEMORY; - } - - fstrcpy((*d_grp)[num_entries].name, smap.nt_name); - (*d_grp)[num_entries].rid = trid; - num_entries++; - DEBUG(10,("get_group_alias_entries: added entry %d, rid:%d\n", num_entries, trid)); - } - - grent_free(glist); - } - - *p_num_entries = num_entries; - - DEBUG(10,("get_group_alias_entries: returning %d entries\n", *p_num_entries)); - - if (num_entries >= max_entries) - return STATUS_MORE_ENTRIES; - return NT_STATUS_OK; -} - -/******************************************************************* - Get the group entries - similar to get_sampwd_entries(). - ********************************************************************/ + ******************************************************************/ -static NTSTATUS get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, - uint32 *p_num_entries, uint32 max_entries) +static NTSTATUS get_group_entries( enum SID_NAME_USE type, TALLOC_CTX *ctx, + DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, + uint32 *p_num_entries, uint32 max_entries ) { GROUP_MAP *map=NULL; int i; @@ -1021,7 +892,7 @@ static NTSTATUS get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DO needed for some passdb backends to enumerate groups */ become_root(); - pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED); + pdb_enum_group_mapping(type, &map, (int *)&group_entries, ENUM_ONLY_MAPPED); unbecome_root(); num_entries=group_entries-start_idx; @@ -1042,13 +913,51 @@ static NTSTATUS get_group_domain_entries(TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DO fstrcpy((*d_grp)[i].name, map[i+start_idx].nt_name); fstrcpy((*d_grp)[i].comment, map[i+start_idx].comment); sid_split_rid(&map[i+start_idx].sid, &(*d_grp)[i].rid); - (*d_grp)[i].attr=SID_NAME_DOM_GRP; + (*d_grp)[i].attr=type; } SAFE_FREE(map); *p_num_entries = num_entries; + DEBUG(10,("get_group_entries: returning %d entries\n", *p_num_entries)); + + return NT_STATUS_OK; +} + +/******************************************************************* + Wrapper for enuemrating domain groups + ******************************************************************/ + +static NTSTATUS get_group_domain_entries( TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, + DOM_SID *sid, uint32 start_idx, + uint32 *p_num_entries, uint32 max_entries ) +{ + return get_group_entries( SID_NAME_DOM_GRP, ctx, d_grp, sid, start_idx, + p_num_entries, max_entries ); +} + +/******************************************************************* + Wrapper for enumerating local groups + ******************************************************************/ + +static NTSTATUS get_group_alias_entries( TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, + DOM_SID *sid, uint32 start_idx, + uint32 *p_num_entries, uint32 max_entries) +{ + if ( sid_equal(sid, &global_sid_Builtin) ) { + return get_group_entries( SID_NAME_WKN_GRP, ctx, d_grp, + sid, start_idx, p_num_entries, max_entries ); + } + else if ( sid_equal(sid, get_global_sam_sid()) ) { + return get_group_entries( SID_NAME_ALIAS, ctx, d_grp, + sid, start_idx, p_num_entries, max_entries ); + } + + /* can't do anything with this SID */ + + *p_num_entries = 0; + return NT_STATUS_OK; } -- cgit From 5139e4a1a929e1491702de3f1953a835024f6fe3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 19 Nov 2003 00:18:45 +0000 Subject: Correct fix for checking of '$' name termination. Jeremy. (This used to be commit ec2339645283c9e489659a8892c317bb9f7610f0) --- source3/rpc_server/srv_srvsvc_nt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 4d1cf9bddc..40d3a43bef 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -487,10 +487,9 @@ static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh150 static BOOL is_hidden_share(int snum) { - pstring net_name; + const char *net_name = lp_servicename(snum); - pstrcpy(net_name, lp_servicename(snum)); - return (net_name[strlen(net_name)] == '$') ? True : False; + return (net_name[strlen(net_name) - 1] == '$') ? True : False; } /******************************************************************* -- cgit From fcbfc7ad0669009957c65fa61bb20df75a9701b4 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 22 Nov 2003 13:19:38 +0000 Subject: Changes all over the shop, but all towards: - NTLM2 support in the server - KEY_EXCH support in the server - variable length session keys. In detail: - NTLM2 is an extension of NTLMv1, that is compatible with existing domain controllers (unlike NTLMv2, which requires a DC upgrade). * This is known as 'NTLMv2 session security' * (This is not yet implemented on the RPC pipes however, so there may well still be issues for PDC setups, particuarly around password changes. We do not fully understand the sign/seal implications of NTLM2 on RPC pipes.) This requires modifications to our authentication subsystem, as we must handle the 'challege' input into the challenge-response algorithm being changed. This also needs to be turned off for 'security=server', which does not support this. - KEY_EXCH is another 'security' mechanism, whereby the session key actually used by the server is sent by the client, rather than being the shared-secret directly or indirectly. - As both these methods change the session key, the auth subsystem needed to be changed, to 'override' session keys provided by the backend. - There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation. - The 'names blob' in NTLMSSP is always in unicode - never in ascii. Don't make an ascii version ever. - The other big change is to allow variable length session keys. We have always assumed that session keys are 16 bytes long - and padded to this length if shorter. However, Kerberos session keys are 8 bytes long, when the krb5 login uses DES. * This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. * - Add better DEBUG() messages to ntlm_auth, warning administrators of misconfigurations that prevent access to the privileged pipe. This should help reduce some of the 'it just doesn't work' issues. - Fix data_blob_talloc() to behave the same way data_blob() does when passed a NULL data pointer. (just allocate) REMEMBER to make clean after this commit - I have changed plenty of data structures... (This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc) --- source3/rpc_server/srv_netlog_nt.c | 23 +++++++++++++++++------ source3/rpc_server/srv_pipe.c | 12 +++++++++--- source3/rpc_server/srv_pipe_hnd.c | 2 +- source3/rpc_server/srv_samr_nt.c | 18 +++++++++++++++--- 4 files changed, 42 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index e6d005b157..e8bc6345de 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -683,7 +683,8 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * pstring my_name; fstring user_sid_string; fstring group_sid_string; - uchar user_sess_key[16]; + uchar nt_session_key[16]; + uchar lm_session_key[16]; uchar netlogon_sess_key[16]; sampw = server_info->sam_account; @@ -718,10 +719,18 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * ZERO_STRUCT(netlogon_sess_key); memcpy(netlogon_sess_key, p->dc.sess_key, 8); - memcpy(user_sess_key, server_info->session_key, sizeof(user_sess_key)); - SamOEMhash(user_sess_key, netlogon_sess_key, 16); + if (server_info->nt_session_key.length) { + memcpy(nt_session_key, server_info->nt_session_key.data, + MIN(sizeof(nt_session_key), server_info->nt_session_key.length)); + SamOEMhash(nt_session_key, netlogon_sess_key, 16); + } + if (server_info->lm_session_key.length) { + memcpy(lm_session_key, server_info->lm_session_key.data, + MIN(sizeof(lm_session_key), server_info->lm_session_key.length)); + SamOEMhash(lm_session_key, netlogon_sess_key, 16); + } ZERO_STRUCT(netlogon_sess_key); - + init_net_user_info3(p->mem_ctx, usr_info, user_rid, group_rid, @@ -743,14 +752,16 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * num_gids, /* uint32 num_groups */ gids , /* DOM_GID *gids */ 0x20 , /* uint32 user_flgs (?) */ - user_sess_key, + server_info->nt_session_key.length ? nt_session_key : NULL, + server_info->lm_session_key.length ? lm_session_key : NULL, my_name , /* char *logon_srv */ pdb_get_domain(sampw), &domain_sid, /* DOM_SID *dom_sid */ /* Should be users domain sid, not servers - for trusted domains */ NULL); /* char *other_sids */ - ZERO_STRUCT(user_sess_key); + ZERO_STRUCT(nt_session_key); + ZERO_STRUCT(lm_session_key); } free_server_info(&server_info); return status; diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 96261c665f..fa24efe589 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -420,9 +420,15 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); * Set up the sign/seal data. */ - { + if (server_info->lm_session_key.length != 16) { + DEBUG(1,("api_pipe_ntlmssp_verify: User [%s]\\[%s] from machine %s \ +succeeded authentication on named pipe %s, but session key was of incorrect length [%u].\n", + domain, user_name, wks, p->name, server_info->lm_session_key.length)); + free_server_info(&server_info); + return False; + } else { uchar p24[24]; - NTLMSSPOWFencrypt(server_info->first_8_lm_hash, lm_owf, p24); + NTLMSSPOWFencrypt(server_info->lm_session_key.data, lm_owf, p24); { unsigned char j = 0; int ind; @@ -468,7 +474,7 @@ failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); * Store the UNIX credential data (uid/gid pair) in the pipe structure. */ - memcpy(p->session_key, server_info->session_key, sizeof(p->session_key)); + p->session_key = data_blob(server_info->lm_session_key.data, server_info->lm_session_key.length); p->pipe_user.uid = server_info->uid; p->pipe_user.gid = server_info->gid; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 57e45d477f..a9fd9ec652 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -342,7 +342,7 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, /* Store the session key and NT_TOKEN */ if (vuser) { - memcpy(p->session_key, vuser->session_key, sizeof(p->session_key)); + p->session_key = data_blob(vuser->session_key.data, vuser->session_key.length); p->pipe_user.nt_user_token = dup_nt_token(vuser->nt_user_token); } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1cfa8b2853..1debf90d23 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2953,7 +2953,13 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE break; case 24: - SamOEMhash(ctr->info.id24->pass, p->session_key, 516); + if (p->session_key.length != 16) { + /* we may have no session key at all, + and we don't know how to do the SamOEMhash + for length != 16 */ + return NT_STATUS_NO_USER_SESSION_KEY; + } + SamOEMhash(ctr->info.id24->pass, p->session_key.data, 516); dump_data(100, (char *)ctr->info.id24->pass, 516); @@ -2971,7 +2977,10 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE * info level and W2K SP2 drops down to level 23... JRA. */ - SamOEMhash(ctr->info.id25->pass, p->session_key, 532); + if (p->session_key.length != 16) { + return NT_STATUS_NO_USER_SESSION_KEY; + } + SamOEMhash(ctr->info.id25->pass, p->session_key.data, 532); dump_data(100, (char *)ctr->info.id25->pass, 532); @@ -2982,7 +2991,10 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE return NT_STATUS_INVALID_INFO_CLASS; case 23: - SamOEMhash(ctr->info.id23->pass, p->session_key, 516); + if (p->session_key.length != 16) { + return NT_STATUS_NO_USER_SESSION_KEY; + } + SamOEMhash(ctr->info.id23->pass, p->session_key.data, 516); dump_data(100, (char *)ctr->info.id23->pass, 516); -- cgit From 6b81cc2e0bca79f4aa472cd2b1b90d0c51818612 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 23 Nov 2003 00:04:29 +0000 Subject: Add server-side support for variable-length session keys (as used by DES based krb5 logins). Andrew Bartlett (This used to be commit 240b0d178e1b4a3556207bdf2e342c70155f64ee) --- source3/rpc_server/srv_samr_nt.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1debf90d23..6cd5da4892 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2953,13 +2953,10 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE break; case 24: - if (p->session_key.length != 16) { - /* we may have no session key at all, - and we don't know how to do the SamOEMhash - for length != 16 */ + if (!p->session_key.length) { return NT_STATUS_NO_USER_SESSION_KEY; } - SamOEMhash(ctr->info.id24->pass, p->session_key.data, 516); + SamOEMhashBlob(ctr->info.id24->pass, 516, &p->session_key); dump_data(100, (char *)ctr->info.id24->pass, 516); @@ -2977,10 +2974,10 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE * info level and W2K SP2 drops down to level 23... JRA. */ - if (p->session_key.length != 16) { + if (!p->session_key.length) { return NT_STATUS_NO_USER_SESSION_KEY; } - SamOEMhash(ctr->info.id25->pass, p->session_key.data, 532); + SamOEMhashBlob(ctr->info.id25->pass, 532, &p->session_key); dump_data(100, (char *)ctr->info.id25->pass, 532); @@ -2991,10 +2988,10 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE return NT_STATUS_INVALID_INFO_CLASS; case 23: - if (p->session_key.length != 16) { + if (!p->session_key.length) { return NT_STATUS_NO_USER_SESSION_KEY; } - SamOEMhash(ctr->info.id23->pass, p->session_key.data, 516); + SamOEMhashBlob(ctr->info.id23->pass, 516, &p->session_key); dump_data(100, (char *)ctr->info.id23->pass, 516); -- cgit From c39f5fea4ad7b57ee8ad4d2b115163f76753f853 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 24 Nov 2003 17:31:38 +0000 Subject: more access fixes for group enumeration in LDAP; bug 281 (This used to be commit 68283407e0f366d8315f4be6caed67eb6fe84b85) --- source3/rpc_server/srv_lsa_nt.c | 9 ++++++++- source3/rpc_server/srv_samr_nt.c | 8 +++++--- source3/rpc_server/srv_util.c | 15 +++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 0a8ad404cb..e545d8c267 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -845,6 +845,7 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU int num_entries=0; LSA_SID_ENUM *sids=&r_u->sids; int i=0,j=0; + BOOL ret; if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; @@ -858,8 +859,14 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU return NT_STATUS_ACCESS_DENIED; /* get the list of mapped groups (domain, local, builtin) */ - if(!pdb_enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED)) + become_root(); + ret = pdb_enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED); + unbecome_root(); + if( !ret ) { + DEBUG(3,("_lsa_enum_accounts: enumeration of groups failed!\n")); return NT_STATUS_OK; + } + if (q_u->enum_context >= num_entries) return NT_STATUS_NO_MORE_ENTRIES; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6cd5da4892..d3da830991 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -292,6 +292,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) uint32 group_entries = 0; uint32 i; TALLOC_CTX *mem_ctx = info->mem_ctx; + BOOL ret; DEBUG(10,("load_group_domain_entries\n")); @@ -303,13 +304,14 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) become_root(); - - if (!pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED)) { + ret = pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED); + unbecome_root(); + + if ( !ret ) { DEBUG(1, ("load_group_domain_entries: pdb_enum_group_mapping() failed!\n")); return NT_STATUS_NO_MEMORY; } - unbecome_root(); info->disp_info.num_group_account=group_entries; diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 632d381503..d5b87b7c10 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -281,6 +281,7 @@ BOOL get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids, SA fstring user_name; uint32 grid; uint32 tmp_rid; + BOOL ret; *numgroups= 0; @@ -290,15 +291,21 @@ BOOL get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids, SA DEBUG(10,("get_domain_user_groups: searching domain groups [%s] is a member of\n", user_name)); /* we must wrap this is become/unbecome root for ldap backends */ + become_root(); - /* first get the list of the domain groups */ - if (!pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, &num_entries, ENUM_ONLY_MAPPED)) + ret = pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, &num_entries, ENUM_ONLY_MAPPED); + + unbecome_root(); + + /* end wrapper for group enumeration */ + + + if ( !ret ) return False; + DEBUG(10,("get_domain_user_groups: there are %d mapped groups\n", num_entries)); - unbecome_root(); - /* end wrapper for group enumeration */ /* * alloc memory. In the worse case, we alloc memory for nothing. -- cgit From b4feed1e505d564a0cf355bc6166b622dd044194 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 25 Nov 2003 02:04:03 +0000 Subject: Patch for #263 from jpjanosi@us.ibm.com. Jeremy. (This used to be commit 0f2a50316d8245ea9c441f0ea08e1a0fd9a92583) --- source3/rpc_server/srv_dfs_nt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index ac3ed9c394..f324fd126e 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -369,6 +369,7 @@ WERROR _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u, { UNISTR2* uni_path = &q_u->uni_path; uint32 level = q_u->level; + int consumedcnt = sizeof(pstring); pstring path; struct junction_map jn; @@ -377,7 +378,7 @@ WERROR _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u, return WERR_DFS_NO_SUCH_SERVER; /* The following call can change the cwd. */ - if(!get_referred_path(path, &jn, NULL, NULL)) { + if(!get_referred_path(path, &jn, &consumedcnt, NULL) || consumedcnt < strlen(path)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; } -- cgit From 89ebcb185d493051394a381f0195baa2a53abc01 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 2 Dec 2003 12:48:15 +0000 Subject: Match Win2k and return 'invalid parameter' for creating of a new account with account flags of 0. Andrew Bartlett (This used to be commit 601120f335b69e5b8a003038dfac00f3f234a5c1) --- source3/rpc_server/srv_samr_nt.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d3da830991..de12a7d5c8 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2134,6 +2134,12 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA return nt_status; } + if (!acb_info) { + /* Match Win2k, and return NT_STATUS_INVALID_PARAMETER if + this parameter is zero (ie, no user type specified) */ + return NT_STATUS_INVALID_PARAMETER; + } + /* find the 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 -- cgit From 3d929b1ce67d945979552fe1ea2c70f6d3925326 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 4 Dec 2003 03:35:46 +0000 Subject: * fix RemoveSidForeignDomain() ; bug 252 * don't fall back to unmapped UNIX group for get_local_group_from_sid() * remove an extra become/unbecome_root() pair from group enumeration (This used to be commit da12bbdb0dd9179b1ed457fa009679e2da4a8440) --- source3/rpc_server/srv_samr.c | 20 +++--- source3/rpc_server/srv_samr_nt.c | 127 +++++++++++++++++++++++++-------------- source3/rpc_server/srv_util.c | 2 +- 3 files changed, 92 insertions(+), 57 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index a0f62c20fc..971f5ed40c 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1343,13 +1343,13 @@ static BOOL api_samr_open_group(pipes_struct *p) } /******************************************************************* - api_samr_remove_user_foreign_domain + api_samr_remove_sid_foreign_domain ********************************************************************/ -static BOOL api_samr_remove_user_foreign_domain(pipes_struct *p) +static BOOL api_samr_remove_sid_foreign_domain(pipes_struct *p) { - SAMR_Q_REMOVE_USER_FOREIGN_DOMAIN q_u; - SAMR_R_REMOVE_USER_FOREIGN_DOMAIN r_u; + SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN q_u; + SAMR_R_REMOVE_SID_FOREIGN_DOMAIN r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -1357,15 +1357,15 @@ static BOOL api_samr_remove_user_foreign_domain(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if (!samr_io_q_remove_user_foreign_domain("", &q_u, data, 0)) { - DEBUG(0,("api_samr_remove_user_foreign_domain: unable to unmarshall SAMR_Q_REMOVE_USER_FOREIGN_DOMAIN.\n")); + if (!samr_io_q_remove_sid_foreign_domain("", &q_u, data, 0)) { + DEBUG(0,("api_samr_remove_sid_foreign_domain: unable to unmarshall SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN.\n")); return False; } - r_u.status = _samr_remove_user_foreign_domain(p, &q_u, &r_u); + r_u.status = _samr_remove_sid_foreign_domain(p, &q_u, &r_u); - if (!samr_io_r_remove_user_foreign_domain("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_remove_user_foreign_domain: unable to marshall SAMR_R_REMOVE_USER_FOREIGN_DOMAIN.\n")); + if (!samr_io_r_remove_sid_foreign_domain("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_remove_sid_foreign_domain: unable to marshall SAMR_R_REMOVE_SID_FOREIGN_DOMAIN.\n")); return False; } @@ -1483,7 +1483,7 @@ static struct api_struct api_samr_cmds [] = {"SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, {"SAMR_OPEN_GROUP" , SAMR_OPEN_GROUP , api_samr_open_group }, {"SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, - {"SAMR_REMOVE_USER_FOREIGN_DOMAIN" , SAMR_REMOVE_USER_FOREIGN_DOMAIN , api_samr_remove_user_foreign_domain }, + {"SAMR_REMOVE_SID_FOREIGN_DOMAIN" , SAMR_REMOVE_SID_FOREIGN_DOMAIN , api_samr_remove_sid_foreign_domain }, {"SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, {"SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index de12a7d5c8..7f57a9fc9d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1384,8 +1384,6 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO DEBUG(5,("_samr_lookup_names: looking name on SID %s\n", sid_to_string(sid_str, &pol_sid))); - become_root(); /* local_lookup_name can require root privs */ - for (i = 0; i < num_rids; i++) { fstring name; DOM_SID sid; @@ -1421,8 +1419,6 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO } } - unbecome_root(); - init_samr_r_lookup_names(p->mem_ctx, r_u, num_rids, rid, (uint32 *)type, r_u->status); DEBUG(5,("_samr_lookup_names: %d\n", __LINE__)); @@ -4256,75 +4252,114 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G } /********************************************************************* - _samr_remove_user_foreign_domain + _samr_remove_sid_foreign_domain *********************************************************************/ -NTSTATUS _samr_remove_user_foreign_domain(pipes_struct *p, - SAMR_Q_REMOVE_USER_FOREIGN_DOMAIN *q_u, - SAMR_R_REMOVE_USER_FOREIGN_DOMAIN *r_u) +NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, + SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN *q_u, + SAMR_R_REMOVE_SID_FOREIGN_DOMAIN *r_u) { - DOM_SID user_sid, dom_sid; + DOM_SID delete_sid, alias_sid; SAM_ACCOUNT *sam_pass=NULL; uint32 acc_granted; + GROUP_MAP map; + BOOL is_user = False; + NTSTATUS result; + enum SID_NAME_USE type = SID_NAME_UNKNOWN; - sid_copy( &user_sid, &q_u->sid.sid ); + sid_copy( &delete_sid, &q_u->sid.sid ); - DEBUG(5,("_samr_remove_user_foreign_domain: removing user [%s]\n", - sid_string_static(&user_sid))); + DEBUG(5,("_samr_remove_sid_foreign_domain: removing SID [%s]\n", + sid_string_static(&delete_sid))); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &alias_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + result = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, + "_samr_remove_sid_foreign_domain"); - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, - STD_RIGHT_DELETE_ACCESS, "_samr_remove_user_foreign_domain"))) - { - return r_u->status; - } + if (!NT_STATUS_IS_OK(result)) + return result; + + DEBUG(8, ("_samr_remove_sid_foreign_domain:sid is %s\n", + sid_string_static(&alias_sid))); - if ( !sid_check_is_in_our_domain(&user_sid) ) { - DEBUG(5,("_samr_remove_user_foreign_domain: user not is our domain!\n")); - return NT_STATUS_NO_SUCH_USER; + /* make sure we can handle this */ + + if ( sid_check_is_domain(&alias_sid) ) + type = SID_NAME_DOM_GRP; + else if ( sid_check_is_builtin(&alias_sid) ) + type = SID_NAME_ALIAS; + + if ( type == SID_NAME_UNKNOWN ) { + DEBUG(10, ("_samr_remove_sid_foreign_domain: can't operate on what we don't own!\n")); + return NT_STATUS_OK; } /* check if the user exists before trying to delete */ pdb_init_sam(&sam_pass); - if ( !pdb_getsampwsid(sam_pass, &user_sid) ) { + if ( pdb_getsampwsid(sam_pass, &delete_sid) ) { + is_user = True; + } else { + /* maybe it is a group */ + if( !pdb_getgrsid(&map, delete_sid) ) { + DEBUG(3,("_samr_remove_sid_foreign_domain: %s is not a user or a group!\n", + sid_string_static(&delete_sid))); + result = NT_STATUS_INVALID_SID; + goto done; + } + } - DEBUG(5,("_samr_remove_user_foreign_domain:User %s doesn't exist.\n", - sid_string_static(&user_sid))); - - pdb_free_sam(&sam_pass); + /* we can only delete a user from a group since we don't have + nested groups anyways. So in the latter case, just say OK */ + + if ( is_user ) { + GROUP_MAP *mappings = NULL; + uint32 num_groups, i; + struct group *grp2; - return NT_STATUS_NO_SUCH_USER; - } + if ( pdb_enum_group_mapping(type, &mappings, &num_groups, False) && num_groups>0 ) { + + /* interate over the groups */ + for ( i=0; igr_name) ) + continue; + + smb_delete_user_group(grp2->gr_name, pdb_get_username(sam_pass)); + + if ( user_in_unix_group_list(pdb_get_username(sam_pass), grp2->gr_name) ) { + /* should we fail here ? */ + DEBUG(0,("_samr_remove_sid_foreign_domain: Delete user [%s] from group [%s] failed!\n", + pdb_get_username(sam_pass), grp2->gr_name )); + continue; + } + + DEBUG(10,("_samr_remove_sid_foreign_domain: Removed user [%s] from group [%s]!\n", + pdb_get_username(sam_pass), grp2->gr_name )); + } + + SAFE_FREE(mappings); + } } + result = NT_STATUS_OK; +done: + pdb_free_sam(&sam_pass); - return NT_STATUS_OK; + return result; } /******************************************************************* diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index d5b87b7c10..c2395e6fae 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -382,7 +382,7 @@ BOOL get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids, SA done: *pgids=gids; *numgroups=cur_gid; - safe_free(map); + SAFE_FREE(map); return True; } -- cgit From 16194fbc5a296aae9d7b4cb03512f22dffe48158 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 4 Dec 2003 20:20:59 +0000 Subject: fix process_incoming_data() to return the number of bytes handled this call whether we have a complete pdu or not; fixes bug with multiple pdu request rpc's broken over SMBwriteX calls each (This used to be commit ff06f3ca8e597d093b8a76b5cfabfa6009f4b591) --- source3/rpc_server/srv_pipe_hnd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index a9fd9ec652..514c22d471 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -772,6 +772,7 @@ static ssize_t process_complete_pdu(pipes_struct *p) static ssize_t process_incoming_data(pipes_struct *p, char *data, size_t n) { size_t data_to_copy = MIN(n, MAX_PDU_FRAG_LEN - p->in_data.pdu_received_len); + size_t old_pdu_received_len = p->in_data.pdu_received_len; DEBUG(10,("process_incoming_data: Start: pdu_received_len = %u, pdu_needed_len = %u, incoming data = %u\n", (unsigned int)p->in_data.pdu_received_len, (unsigned int)p->in_data.pdu_needed_len, @@ -831,10 +832,11 @@ incoming data size = %u\n", (unsigned int)p->in_data.pdu_received_len, (unsigned /* * Do we have a complete PDU ? + * (return the nym of bytes handled in the call) */ if(p->in_data.pdu_received_len == p->in_data.pdu_needed_len) - return process_complete_pdu(p); + return process_complete_pdu(p) - old_pdu_received_len; DEBUG(10,("process_incoming_data: not a complete PDU yet. pdu_received_len = %u, pdu_needed_len = %u\n", (unsigned int)p->in_data.pdu_received_len, (unsigned int)p->in_data.pdu_needed_len )); -- cgit From 87fddf6a988dfcdb3f1d3a715df585b6c6efa9d7 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 10 Dec 2003 16:40:17 +0000 Subject: more group lookup access fixes on the neverending bug 281 (This used to be commit 9359a6ea80d1228e87ea825a100a2d289c37162d) --- source3/rpc_server/srv_samr_nt.c | 7 ++++++- source3/rpc_server/srv_util.c | 14 ++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7f57a9fc9d..c84e288a4b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1246,6 +1246,7 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM DOM_SID sid; GROUP_MAP map; uint32 acc_granted; + BOOL ret; r_u->status = NT_STATUS_OK; @@ -1262,7 +1263,11 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM !sid_check_is_in_builtin(&sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - if (!pdb_getgrsid(&map, sid)) + become_root(); + ret = pdb_getgrsid(&map, sid); + unbecome_root(); + + if ( !ret ) return NT_STATUS_NO_SUCH_ALIAS; switch (q_u->switch_level) { diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index c2395e6fae..504e6a83c0 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -147,8 +147,6 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui return NT_STATUS_UNSUCCESSFUL; } - become_root(); - for (i=0;i Date: Wed, 10 Dec 2003 21:13:44 +0000 Subject: Fix UNISTR2 length bug in LsaQueryInfo(3) that cause SID resolution to fail on local files on on domain members; bug 875 (This used to be commit c6594e35573186966a4d57404f1c06b98670db06) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index e545d8c267..2b2cb91924 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -66,7 +66,7 @@ static void init_dom_query(DOM_QUERY *d_q, const char *dom_name, DOM_SID *dom_si /* this string is supposed to be non-null terminated. */ /* But the maxlen in this UNISTR2 must include the terminating null. */ - init_unistr2(&d_q->uni_domain_name, dom_name, UNI_MAXLEN_TERMINATE); + init_unistr2(&d_q->uni_domain_name, dom_name, UNI_BROKEN_NON_NULL); /* * I'm not sure why this really odd combination of length -- cgit From c763e9548c94cdb526d8e486d1450b70b9d3969e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 16 Dec 2003 18:35:23 +0000 Subject: make sure we delete the group mapping before calling the delete group script; patch from Jianliang Lu (This used to be commit 19a8dd523a4ee50ba9066efd60a29cf3ba9ae419) --- source3/rpc_server/srv_samr_nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c84e288a4b..4d4dfed47c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3827,6 +3827,10 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S if ( (grp=getgrgid(gid)) == NULL) return NT_STATUS_NO_SUCH_GROUP; + /* delete mapping first */ + if(!pdb_delete_group_mapping_entry(group_sid)) + return NT_STATUS_ACCESS_DENIED; + /* we can delete the UNIX group */ smb_delete_group(grp->gr_name); @@ -3834,8 +3838,6 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S if ( (grp=getgrgid(gid)) != NULL) return NT_STATUS_ACCESS_DENIED; - if(!pdb_delete_group_mapping_entry(group_sid)) - return NT_STATUS_ACCESS_DENIED; if (!close_policy_hnd(p, &q_u->group_pol)) return NT_STATUS_OBJECT_NAME_INVALID; -- cgit From b4593e92ff75f006982d7f49337a0a94f44d4218 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 2 Jan 2004 05:32:07 +0000 Subject: JHT came up with a nasty (broken) torture case in preparing examples for his book. This prompted me to look at the code that reads the unix group list. This code did a lot of name -> uid -> name -> sid translations, which caused problems. Instead, we now do just name->sid I also cleaned up some interfaces, and client tools. Andrew Bartlett (This used to be commit f9e59f8bc06fae7e5c8cb0980947f78942dc25c0) --- source3/rpc_server/srv_samr_nt.c | 149 +++++++++++++-------------------------- 1 file changed, 50 insertions(+), 99 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 4d4dfed47c..be5f197198 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3176,18 +3176,15 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ int i; GROUP_MAP map; - int num_uids = 0; + int num_sids = 0; DOM_SID2 *sid; - uid_t *uid=NULL; + DOM_SID *sids=NULL; DOM_SID alias_sid; DOM_SID als_sid; uint32 alias_rid; fstring alias_sid_str; - DOM_SID temp_sid; - SAM_ACCOUNT *sam_user = NULL; - BOOL check; uint32 acc_granted; /* find the policy handle. open a policy on it. */ @@ -3207,65 +3204,40 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ if (sid_equal(&alias_sid, &global_sid_Builtin)) { DEBUG(10, ("lookup on Builtin SID (S-1-5-32)\n")); - if(!get_builtin_group_from_sid(als_sid, &map)) + if(!get_builtin_group_from_sid(&als_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; } else { if (sid_equal(&alias_sid, get_global_sam_sid())) { DEBUG(10, ("lookup on Server SID\n")); - if(!get_local_group_from_sid(als_sid, &map)) + if(!get_local_group_from_sid(&als_sid, &map)) { + fstring alias_sid_string; + DEBUG(10, ("Alias %s not found\n", sid_to_string(alias_sid_string, &als_sid))); return NT_STATUS_NO_SUCH_ALIAS; + } } } - if(!get_uid_list_of_group(map.gid, &uid, &num_uids)) + if (!get_sid_list_of_group(map.gid, &sids, &num_sids)) { + fstring alias_sid_string; + DEBUG(10, ("Alias %s found, but member list unavailable\n", sid_to_string(alias_sid_string, &als_sid))); return NT_STATUS_NO_SUCH_ALIAS; + } DEBUG(10, ("sid is %s\n", alias_sid_str)); - sid = (DOM_SID2 *)talloc_zero(p->mem_ctx, sizeof(DOM_SID2) * num_uids); - if (num_uids!=0 && sid == NULL) + sid = (DOM_SID2 *)talloc_zero(p->mem_ctx, sizeof(DOM_SID2) * num_sids); + if (num_sids!=0 && sid == NULL) { + SAFE_FREE(sids); return NT_STATUS_NO_MEMORY; + } - for (i = 0; i < num_uids; i++) { - struct passwd *pass; - uint32 rid; - - sid_copy(&temp_sid, get_global_sam_sid()); - - pass = getpwuid_alloc(uid[i]); - if (!pass) continue; - - if (!NT_STATUS_IS_OK(pdb_init_sam(&sam_user))) { - passwd_free(&pass); - continue; - } - - become_root(); - check = pdb_getsampwnam(sam_user, pass->pw_name); - unbecome_root(); - - if (check != True) { - pdb_free_sam(&sam_user); - passwd_free(&pass); - continue; - } - - rid = pdb_get_user_rid(sam_user); - if (rid == 0) { - pdb_free_sam(&sam_user); - passwd_free(&pass); - continue; - } - - pdb_free_sam(&sam_user); - passwd_free(&pass); - - sid_append_rid(&temp_sid, rid); - - init_dom_sid2(&sid[i], &temp_sid); + for (i = 0; i < num_sids; i++) { + init_dom_sid2(&sid[i], &sids[i]); } DEBUG(10, ("sid is %s\n", alias_sid_str)); - init_samr_r_query_aliasmem(r_u, num_uids, sid, NT_STATUS_OK); + init_samr_r_query_aliasmem(r_u, num_sids, sid, NT_STATUS_OK); + + SAFE_FREE(sids); return NT_STATUS_OK; } @@ -3276,20 +3248,19 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_QUERY_GROUPMEM *r_u) { - int num_uids = 0; + int num_sids = 0; + int final_num_sids = 0; int i; DOM_SID group_sid; uint32 group_rid; fstring group_sid_str; - uid_t *uid=NULL; + DOM_SID *sids=NULL; GROUP_MAP map; uint32 *rid=NULL; uint32 *attr=NULL; - SAM_ACCOUNT *sam_user = NULL; - BOOL check; uint32 acc_granted; /* find the policy handle. open a policy on it. */ @@ -3316,52 +3287,32 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ if(!get_domain_group_from_sid(group_sid, &map)) return NT_STATUS_NO_SUCH_GROUP; - if(!get_uid_list_of_group(map.gid, &uid, &num_uids)) + if(!get_sid_list_of_group(map.gid, &sids, &num_sids)) return NT_STATUS_NO_SUCH_GROUP; - rid=talloc_zero(p->mem_ctx, sizeof(uint32)*num_uids); - attr=talloc_zero(p->mem_ctx, sizeof(uint32)*num_uids); + rid=talloc_zero(p->mem_ctx, sizeof(uint32)*num_sids); + attr=talloc_zero(p->mem_ctx, sizeof(uint32)*num_sids); - if (num_uids!=0 && (rid==NULL || attr==NULL)) + if (num_sids!=0 && (rid==NULL || attr==NULL)) return NT_STATUS_NO_MEMORY; - for (i=0; ipw_name); - unbecome_root(); - - if (check != True) { - pdb_free_sam(&sam_user); - passwd_free(&pass); - continue; - } - - urid = pdb_get_user_rid(sam_user); - if (urid == 0) { - pdb_free_sam(&sam_user); - passwd_free(&pass); - continue; + + if (sid_peek_check_rid(get_global_sam_sid(), &sids[i], &urid)) { + rid[final_num_sids] = urid; + attr[final_num_sids] = SID_NAME_USER; + final_num_sids++; + } else { + fstring user_sid_str, domain_sid_str; + DEBUG(1, ("_samr_query_groupmem: SID %s in group %s is not in our domain %s\n", + sid_to_string(user_sid_str, &sids[i]), + sid_to_string(group_sid_str, &group_sid), + sid_to_string(domain_sid_str, get_global_sam_sid()))); } - - pdb_free_sam(&sam_user); - passwd_free(&pass); - - rid[i] = urid; - attr[i] = SID_NAME_USER; } - init_samr_r_query_groupmem(r_u, num_uids, rid, attr, NT_STATUS_OK); + init_samr_r_query_groupmem(r_u, final_num_sids, rid, attr, NT_STATUS_OK); return NT_STATUS_OK; } @@ -3397,13 +3348,13 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD if (sid_compare(&alias_sid, get_global_sam_sid())>0) { DEBUG(10, ("adding member on Server SID\n")); - if(!get_local_group_from_sid(alias_sid, &map)) + if(!get_local_group_from_sid(&alias_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; } else { if (sid_compare(&alias_sid, &global_sid_Builtin)>0) { DEBUG(10, ("adding member on BUILTIN SID\n")); - if( !get_local_group_from_sid(alias_sid, &map)) + if( !get_local_group_from_sid(&alias_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; } else @@ -3494,7 +3445,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE return NT_STATUS_NO_SUCH_ALIAS; } - if( !get_local_group_from_sid(alias_sid, &map)) + if( !get_local_group_from_sid(&alias_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; if ((grp=getgrgid(map.gid)) == NULL) @@ -3882,7 +3833,7 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S DEBUG(10, ("lookup on Local SID\n")); - if(!get_local_group_from_sid(alias_sid, &map)) + if(!get_local_group_from_sid(&alias_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; gid=map.gid; @@ -4042,8 +3993,8 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM { DOM_SID group_sid; GROUP_MAP map; - uid_t *uid=NULL; - int num_uids=0; + DOM_SID *sids=NULL; + int num_sids=0; GROUP_INFO_CTR *ctr; uint32 acc_granted; BOOL ret; @@ -4068,10 +4019,10 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM switch (q_u->switch_level) { case 1: ctr->switch_value1 = 1; - if(!get_uid_list_of_group(map.gid, &uid, &num_uids)) + if(!get_sid_list_of_group(map.gid, &sids, &num_sids)) return NT_STATUS_NO_SUCH_GROUP; - init_samr_group_info1(&ctr->group.info1, map.nt_name, map.comment, num_uids); - SAFE_FREE(uid); + init_samr_group_info1(&ctr->group.info1, map.nt_name, map.comment, num_sids); + SAFE_FREE(sids); break; case 3: ctr->switch_value1 = 3; @@ -4153,7 +4104,7 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ return r_u->status; } - if (!get_local_group_from_sid(group_sid, &map)) + if (!get_local_group_from_sid(&group_sid, &map)) return NT_STATUS_NO_SUCH_GROUP; ctr=&q_u->ctr; -- cgit From 8c1d0fb955611896f149b3c46521159a5537ab8e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 2 Jan 2004 23:55:44 +0000 Subject: Match Win2k, and return NT_STATUS_INVALID_PARAMETER if this parameter is not an account type Andrew Bartlett (This used to be commit faddf5d8f9821176f4367caaf61844980df9f79c) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index be5f197198..bd26ce6849 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2135,9 +2135,9 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA return nt_status; } - if (!acb_info) { + if (!(acb_info == ACB_NORMAL || acb_info == ACB_DOMTRUST || acb_info == ACB_WSTRUST || acb_info == ACB_SVRTRUST)) { /* Match Win2k, and return NT_STATUS_INVALID_PARAMETER if - this parameter is zero (ie, no user type specified) */ + this parameter is not an account type */ return NT_STATUS_INVALID_PARAMETER; } -- cgit From 500c28974ded4c4789d9f197de5860b20447e606 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 9 Jan 2004 14:54:33 +0000 Subject: fix some warnings from the Sun compiler (This used to be commit ebabf72a78f0165521268b73e0fcabe1ea7834fd) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index bd26ce6849..b9974cba8a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4277,7 +4277,7 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, if ( is_user ) { GROUP_MAP *mappings = NULL; - uint32 num_groups, i; + int num_groups, i; struct group *grp2; if ( pdb_enum_group_mapping(type, &mappings, &num_groups, False) && num_groups>0 ) { -- cgit From b75b755a2ba78ad323d6a87fdbee78b1829f864f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 12 Jan 2004 12:18:11 +0000 Subject: First stab at cracklib support (password quality checking) in Samba 3.0 This adds a configure test, that tries to find out if we have a working cracklib installation, and tries to pick up the debian hints on where the dictionary might be found. Default is per my Fedora Core 1 system - I'm not sure how much it changes. Andrew Bartlett (This used to be commit bc770edb788f0b6f719011cda683f045b76b7ba5) --- source3/rpc_server/srv_samr_nt.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b9974cba8a..7edd34c8dd 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2834,11 +2834,17 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) DEBUG(5, ("Changing trust account or non-unix-user password, not updating /etc/passwd\n")); } else { /* update the UNIX password */ - if (lp_unix_password_sync() ) - if(!chgpasswd(pdb_get_username(pwd), "", plaintext_buf, True)) { + if (lp_unix_password_sync() ) { + struct passwd *passwd = Get_Pwnam(pdb_get_username(pwd)); + if (!passwd) { + DEBUG(1, ("chgpasswd: Username does not exist in system !?!\n")); + } + + if(!chgpasswd(pdb_get_username(pwd), passwd, "", plaintext_buf, True)) { pdb_free_sam(&pwd); return False; } + } } ZERO_STRUCT(plaintext_buf); @@ -2899,7 +2905,12 @@ static BOOL set_user_info_pw(char *pass, DOM_SID *sid) } else { /* update the UNIX password */ if (lp_unix_password_sync()) { - if(!chgpasswd(pdb_get_username(pwd), "", plaintext_buf, True)) { + struct passwd *passwd = Get_Pwnam(pdb_get_username(pwd)); + if (!passwd) { + DEBUG(1, ("chgpasswd: Username does not exist in system !?!\n")); + } + + if(!chgpasswd(pdb_get_username(pwd), passwd, "", plaintext_buf, True)) { pdb_free_sam(&pwd); return False; } -- cgit From 1dce4ebed861a6dfbd19da20601d92bc9be3484a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 14 Jan 2004 17:34:41 +0000 Subject: revert the cracklib changes until post 3.0.2 (This used to be commit 6202e0fa727a4307f51bf42f5ced401a7c7b8214) --- source3/rpc_server/srv_samr_nt.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7edd34c8dd..b9974cba8a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2834,17 +2834,11 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) DEBUG(5, ("Changing trust account or non-unix-user password, not updating /etc/passwd\n")); } else { /* update the UNIX password */ - if (lp_unix_password_sync() ) { - struct passwd *passwd = Get_Pwnam(pdb_get_username(pwd)); - if (!passwd) { - DEBUG(1, ("chgpasswd: Username does not exist in system !?!\n")); - } - - if(!chgpasswd(pdb_get_username(pwd), passwd, "", plaintext_buf, True)) { + if (lp_unix_password_sync() ) + if(!chgpasswd(pdb_get_username(pwd), "", plaintext_buf, True)) { pdb_free_sam(&pwd); return False; } - } } ZERO_STRUCT(plaintext_buf); @@ -2905,12 +2899,7 @@ static BOOL set_user_info_pw(char *pass, DOM_SID *sid) } else { /* update the UNIX password */ if (lp_unix_password_sync()) { - struct passwd *passwd = Get_Pwnam(pdb_get_username(pwd)); - if (!passwd) { - DEBUG(1, ("chgpasswd: Username does not exist in system !?!\n")); - } - - if(!chgpasswd(pdb_get_username(pwd), passwd, "", plaintext_buf, True)) { + if(!chgpasswd(pdb_get_username(pwd), "", plaintext_buf, True)) { pdb_free_sam(&pwd); return False; } -- cgit From 418052559979d350f44f1dd792c720b12f7082ef Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 15 Jan 2004 20:47:30 +0000 Subject: Bug 381: check builtin (not local) group SID. Patch from Jianliang Lu (This used to be commit 2fd2c07df42df42103e81f5eb39bd1778de6ca0a) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b9974cba8a..f189587e85 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3354,7 +3354,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD } else { if (sid_compare(&alias_sid, &global_sid_Builtin)>0) { DEBUG(10, ("adding member on BUILTIN SID\n")); - if( !get_local_group_from_sid(&alias_sid, &map)) + if( !get_builtin_group_from_sid(&alias_sid, &map)) return NT_STATUS_NO_SUCH_ALIAS; } else -- cgit From 784b05c4895fa8d7f5215d4444bc74e91a918114 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 26 Jan 2004 08:45:02 +0000 Subject: This adds client-side support for the unicode/SAMR password change scheme. As well as avoiding DOS charset issues, this scheme returns useful error codes, that we can map back via the pam interface. This patch also cleans up the interfaces used for password buffers, to avoid duplication of code. Andrew Bartlett (This used to be commit 2a2b1f0c872d154fbcce71a250e23dfad085ba1e) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f189587e85..bcb5b239be 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2815,7 +2815,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) acct_ctrl = pdb_get_acct_ctrl(pwd); - if (!decode_pw_buffer((char*)id23->pass, plaintext_buf, 256, &len)) { + if (!decode_pw_buffer((char*)id23->pass, plaintext_buf, 256, &len, STR_UNICODE)) { pdb_free_sam(&pwd); return False; } @@ -2881,7 +2881,7 @@ static BOOL set_user_info_pw(char *pass, DOM_SID *sid) ZERO_STRUCT(plaintext_buf); - if (!decode_pw_buffer(pass, plaintext_buf, 256, &len)) { + if (!decode_pw_buffer(pass, plaintext_buf, 256, &len, STR_UNICODE)) { pdb_free_sam(&pwd); return False; } -- cgit From 2f2e5b01919fe4daf60f97430959ebc98e31ce92 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 30 Jan 2004 18:38:48 +0000 Subject: Fix up name canonicalization (needed for krb5 keytab support later). Remove source_env handler (no longer used in any codepath). Jeremy. (This used to be commit 3a3e33603084048e647af86a9badaaf49433c789) --- source3/rpc_server/srv_lsa_ds_nt.c | 4 ++-- source3/rpc_server/srv_lsa_nt.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_ds_nt.c b/source3/rpc_server/srv_lsa_ds_nt.c index 97e9dc361d..f6e8eed9a9 100644 --- a/source3/rpc_server/srv_lsa_ds_nt.c +++ b/source3/rpc_server/srv_lsa_ds_nt.c @@ -58,7 +58,7 @@ static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN basic->flags = DSROLE_PRIMARY_DS_RUNNING|DSROLE_PRIMARY_DS_MIXED_MODE; if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) ) basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT; - get_mydomname(dnsdomain); + get_mydnsdomname(dnsdomain); strlower_m(dnsdomain); break; case ROLE_DOMAIN_PDC: @@ -66,7 +66,7 @@ static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN basic->flags = DSROLE_PRIMARY_DS_RUNNING|DSROLE_PRIMARY_DS_MIXED_MODE; if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) ) basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT; - get_mydomname(dnsdomain); + get_mydnsdomname(dnsdomain); strlower_m(dnsdomain); break; } diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 2b2cb91924..3300c25254 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1250,7 +1250,7 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I /* This should be a 'netbios domain -> DNS domain' mapping */ dnsdomname[0] = '\0'; - get_mydomname(dnsdomname); + get_mydnsdomname(dnsdomname); strlower_m(dnsdomname); dns_name = dnsdomname; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 15578f6148..61c908e474 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2431,7 +2431,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "DNSMachineName")) { pstring hostname; - if (!get_myfullname(hostname)) + if (!get_mydnsfullname(hostname)) return WERR_BADFILE; *type = 0x1; *needed = 2*(strlen(hostname)+1); -- cgit From 19cc1a9f202551fdaca39d67d926bb77e32d085c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 2 Feb 2004 00:08:35 +0000 Subject: remerge andrew's cracklib patch from HEAD and fix a compile warnings (This used to be commit b60f6ec30d05e4e5bba9934a416ddc8bc089824f) --- source3/rpc_server/srv_samr_nt.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index bcb5b239be..b8de24cf39 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2834,11 +2834,17 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) DEBUG(5, ("Changing trust account or non-unix-user password, not updating /etc/passwd\n")); } else { /* update the UNIX password */ - if (lp_unix_password_sync() ) - if(!chgpasswd(pdb_get_username(pwd), "", plaintext_buf, True)) { + if (lp_unix_password_sync() ) { + struct passwd *passwd = Get_Pwnam(pdb_get_username(pwd)); + if (!passwd) { + DEBUG(1, ("chgpasswd: Username does not exist in system !?!\n")); + } + + if(!chgpasswd(pdb_get_username(pwd), passwd, "", plaintext_buf, True)) { pdb_free_sam(&pwd); return False; } + } } ZERO_STRUCT(plaintext_buf); @@ -2899,7 +2905,12 @@ static BOOL set_user_info_pw(char *pass, DOM_SID *sid) } else { /* update the UNIX password */ if (lp_unix_password_sync()) { - if(!chgpasswd(pdb_get_username(pwd), "", plaintext_buf, True)) { + struct passwd *passwd = Get_Pwnam(pdb_get_username(pwd)); + if (!passwd) { + DEBUG(1, ("chgpasswd: Username does not exist in system !?!\n")); + } + + if(!chgpasswd(pdb_get_username(pwd), passwd, "", plaintext_buf, True)) { pdb_free_sam(&pwd); return False; } -- cgit From 1fa1e931a3ab031675f4e4e08119a531a1b98ab5 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Thu, 12 Feb 2004 16:16:53 +0000 Subject: More sync between passdb on 3.0 and HEAD. Replace unknown_3 with fields_present. Also causes rpc_samr structure field changes. (This used to be commit 1976843345efb6ca4f9cebd964a61acd8ae11d41) --- source3/rpc_server/srv_samr_util.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 82f93a5b4c..409fd8efab 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -225,9 +225,9 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); } - DEBUG(10,("INFO_21 UNKNOWN_3: %08X -> %08X\n",pdb_get_unknown_3(to),from->unknown_3)); - if (from->unknown_3 != pdb_get_unknown_3(to)) { - pdb_set_unknown_3(to, from->unknown_3, PDB_CHANGED); + DEBUG(10,("INFO_21 FIELDS_PRESENT: %08X -> %08X\n",pdb_get_fields_present(to),from->fields_present)); + if (from->fields_present != pdb_get_fields_present(to)) { + pdb_set_fields_present(to, from->fields_present, PDB_CHANGED); } DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); @@ -441,9 +441,9 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); } - DEBUG(10,("INFO_23 UNKOWN_3: %08X -> %08X\n",pdb_get_unknown_3(to),from->unknown_3)); - if (from->unknown_3 != pdb_get_unknown_3(to)) { - pdb_set_unknown_3(to, from->unknown_3, PDB_CHANGED); + DEBUG(10,("INFO_23 FIELDS_PRESENT: %08X -> %08X\n",pdb_get_fields_present(to),from->fields_present)); + if (from->fields_present != pdb_get_fields_present(to)) { + pdb_set_fields_present(to, from->fields_present, PDB_CHANGED); } DEBUG(15,("INFO_23 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); -- cgit From d2742ac2fc42dc36ae089fd043228b7a41e523aa Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 16 Feb 2004 14:24:35 +0000 Subject: Cosmetic fix: Use sid_is_in_our_domain instead of doing it per hand. Volker (This used to be commit 04639e8862c360e89faac8b80c63197d514b7455) --- source3/rpc_server/srv_samr_nt.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b8de24cf39..3c9adf4129 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3263,7 +3263,6 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ int final_num_sids = 0; int i; DOM_SID group_sid; - uint32 group_rid; fstring group_sid_str; DOM_SID *sids=NULL; @@ -3282,17 +3281,14 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ return r_u->status; } - /* todo: change to use sid_compare_front */ - - sid_split_rid(&group_sid, &group_rid); sid_to_string(group_sid_str, &group_sid); DEBUG(10, ("sid is %s\n", group_sid_str)); - /* can we get a query for an SID outside our domain ? */ - if (!sid_equal(&group_sid, get_global_sam_sid())) + if (!sid_check_is_in_our_domain(&group_sid)) { + DEBUG(3, ("sid %s is not in our domain\n", group_sid_str)); return NT_STATUS_NO_SUCH_GROUP; + } - sid_append_rid(&group_sid, group_rid); DEBUG(10, ("lookup on Domain SID\n")); if(!get_domain_group_from_sid(group_sid, &map)) -- cgit From 07892673ff5962ef1bbffbc72bd1588b83e6f777 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 17 Feb 2004 10:11:53 +0000 Subject: In samr_lookup_names Windows does not return WKN_GRP(5) but ALIAS(4) when you search in BUILTIN. Match that. Volker (This used to be commit 2863b21d8a5933c309c51edb09fbda4e669e4890) --- source3/rpc_server/srv_samr_nt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 3c9adf4129..c0d352483f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1418,7 +1418,12 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO if (sid_equal(&sid, &pol_sid)) { rid[i]=local_rid; - type[i]=local_type; + + /* Windows does not return WKN_GRP here, even + * on lookups in builtin */ + type[i] = (local_type == SID_NAME_WKN_GRP) ? + SID_NAME_ALIAS : local_type; + r_u->status = NT_STATUS_OK; } } -- cgit From 34a9928ee1c141f2cdb498d96bb09e7498cf090f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 17 Feb 2004 15:54:57 +0000 Subject: Be able to set alias info for builtin as well. Volker (This used to be commit 7a947ecdf56f2dd02811262372708f8a74bfedad) --- source3/rpc_server/srv_samr_nt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c0d352483f..a087e28f09 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4116,7 +4116,8 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ return r_u->status; } - if (!get_local_group_from_sid(&group_sid, &map)) + if (!get_local_group_from_sid(&group_sid, &map) && + !get_builtin_group_from_sid(&group_sid, &map)) return NT_STATUS_NO_SUCH_GROUP; ctr=&q_u->ctr; -- cgit From 8801465d30f6117e87fef4592bf9aaf103962c2c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 17 Feb 2004 22:46:25 +0000 Subject: Fix based on Volker's code to correctly return code from lsa_lookup_sids on unmapped sids. Jeremy. (This used to be commit 37a52c31682fcf115eefc31381c02a3ec29c1f8d) --- source3/rpc_server/srv_lsa_nt.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 3300c25254..66adc8398a 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -252,9 +252,6 @@ static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME /* Lookup sid from winbindd */ - memset(dom_name, '\0', sizeof(dom_name)); - memset(name, '\0', sizeof(name)); - status = lookup_sid(&find_sid, dom_name, name, &sid_name_use); DEBUG(5, ("init_lsa_trans_names: %s\n", status ? "found" : @@ -262,21 +259,25 @@ static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME if (!status) { sid_name_use = SID_NAME_UNKNOWN; + memset(dom_name, '\0', sizeof(dom_name)); + sid_to_string(name, &find_sid); + dom_idx = -1; + + DEBUG(10,("init_lsa_trans_names: added unknown user '%s' to " + "referenced list.\n", name )); } else { (*mapped_count)++; - } + /* Store domain sid in ref array */ + if (find_sid.num_auths == 5) { + sid_split_rid(&find_sid, &rid); + } + dom_idx = init_dom_ref(ref, dom_name, &find_sid); - /* Store domain sid in ref array */ + DEBUG(10,("init_lsa_trans_names: added user '%s\\%s' to " + "referenced list.\n", dom_name, name )); - if (find_sid.num_auths == 5) { - sid_split_rid(&find_sid, &rid); } - dom_idx = init_dom_ref(ref, dom_name, &find_sid); - - DEBUG(10,("init_lsa_trans_names: added user '%s\\%s' to " - "referenced list.\n", dom_name, name )); - init_lsa_trans_name(&trn->name[total], &trn->uni_name[total], sid_name_use, name, dom_idx); total++; @@ -301,11 +302,6 @@ static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, r_l->dom_ref = ref; r_l->names = names; r_l->mapped_count = mapped_count; - - if (mapped_count == 0) - r_l->status = NT_STATUS_NONE_MAPPED; - else - r_l->status = NT_STATUS_OK; } static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *sd_size) @@ -665,6 +661,12 @@ done: /* set up the LSA Lookup SIDs response */ init_lsa_trans_names(p->mem_ctx, ref, names, num_entries, sid, &mapped_count); + if (mapped_count == 0) + r_u->status = NT_STATUS_NONE_MAPPED; + else if (mapped_count != num_entries) + r_u->status = STATUS_SOME_UNMAPPED; + else + r_u->status = NT_STATUS_OK; init_reply_lookup_sids(r_u, ref, names, mapped_count); return r_u->status; -- cgit From 1bfc09c51ce4f89f7855f38bd724b26cfbc8f8c7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 19 Feb 2004 23:00:01 +0000 Subject: Fixup correct (as per W2K3) returns for lookupsids as well as lookupnames. Inspired by Volkers patch. Jeremy. (This used to be commit a47127e90e7d0928b772ba45bd843eeeacc9ef8a) --- source3/rpc_server/srv_lsa_nt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 66adc8398a..07c024e1ca 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -174,7 +174,7 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, (*mapped_count)++; } else { dom_idx = -1; - rid = 0xffffffff; + rid = 0; name_type = SID_NAME_UNKNOWN; } @@ -202,11 +202,6 @@ static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, r_l->dom_rid = rid2; r_l->mapped_count = mapped_count; - - if (mapped_count == 0) - r_l->status = NT_STATUS_NONE_MAPPED; - else - r_l->status = NT_STATUS_OK; } /*************************************************************************** @@ -711,6 +706,12 @@ done: /* set up the LSA Lookup RIDs response */ init_lsa_rid2s(ref, rids, num_entries, names, &mapped_count, p->endian); + if (mapped_count == 0) + r_u->status = NT_STATUS_NONE_MAPPED; + else if (mapped_count != num_entries) + r_u->status = STATUS_SOME_UNMAPPED; + else + r_u->status = NT_STATUS_OK; init_reply_lookup_names(r_u, ref, num_entries, rids, mapped_count); return r_u->status; -- cgit From 8ccdcb3f1c6b89b01a5ad067e56e7677e1ba63cd Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Wed, 25 Feb 2004 15:02:55 +0000 Subject: reset time and duration are set in minutes, not seconds. Works from usrmgr. (This used to be commit 700049d9efefc7f8952cc60bc46ba8aa790a28ba) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a087e28f09..10069abb76 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4502,8 +4502,8 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R case 0x07: break; case 0x0c: - u_lock_duration=nt_time_to_unix_abs(&q_u->ctr->info.inf12.duration); - u_reset_time=nt_time_to_unix_abs(&q_u->ctr->info.inf12.reset_count); + u_lock_duration=nt_time_to_unix_abs(&q_u->ctr->info.inf12.duration)/60; + u_reset_time=nt_time_to_unix_abs(&q_u->ctr->info.inf12.reset_count)/60; account_policy_set(AP_LOCK_ACCOUNT_DURATION, (int)u_lock_duration); account_policy_set(AP_RESET_COUNT_TIME, (int)u_reset_time); -- cgit From af6f7254a9873a34fb391f1fd78aadadbc796063 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Wed, 25 Feb 2004 20:02:47 +0000 Subject: Do the query part of the previous fix...reset time and duration are set in minutes, not seconds. Works from usrmgr. (This used to be commit 98833a82facb0bc25d9ba6f4d4c1200627e98d6d) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 10069abb76..58dcd48d8d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2081,10 +2081,10 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA break; case 0x0c: account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); - u_lock_duration = account_policy_temp; + u_lock_duration = account_policy_temp * 60; account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp); - u_reset_time = account_policy_temp; + u_reset_time = account_policy_temp * 60; account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); lockout = account_policy_temp; -- cgit From c4877403a04b60619523dfe3fc892564ff41a079 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 29 Feb 2004 16:34:33 +0000 Subject: net_rpc.c: Don't complain if [add|del]mem was successful. srv_samr_nt.c: Correctly report that a user is not member of an alias. Volker (This used to be commit 540f625036871e7facd094fce49d7317f65f4ffd) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 58dcd48d8d..a817627127 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3477,7 +3477,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE /* if the user is not in the group */ if(!user_in_unix_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); - return NT_STATUS_MEMBER_IN_ALIAS; + return NT_STATUS_MEMBER_NOT_IN_ALIAS; } smb_delete_user_group(grp_name, pdb_get_username(sam_pass)); -- cgit From 78b8f3ca0cfbbef0c8f02de20a65d5b89e0f760c Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Tue, 2 Mar 2004 21:02:09 +0000 Subject: Merge fields_present function from HEAD. Now, a field will not be updated on setuserinfo levels which include this field, unless the corresponding bit (defined in passdb.h) is turned on. Without this, newer versions of usrmgr break us pretty bad. (This used to be commit 840340bd96d3c6693b451bc61e155b7b426271e4) --- source3/rpc_server/srv_samr_util.c | 274 +++++++++++++++++++++---------------- 1 file changed, 158 insertions(+), 116 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 409fd8efab..c30cc3e77b 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -73,22 +73,24 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from == NULL || to == NULL) return; - if (!nt_time_is_zero(&from->logon_time)) { + + if (from->fields_present & ACCT_LAST_LOGON) { unix_time=nt_time_to_unix(&from->logon_time); stored_time = pdb_get_logon_time(to); DEBUG(10,("INFO_21 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) pdb_set_logon_time(to, unix_time, PDB_CHANGED); - } - if (!nt_time_is_zero(&from->logoff_time)) { + } + + if (from->fields_present & ACCT_LAST_LOGOFF) { unix_time=nt_time_to_unix(&from->logoff_time); stored_time = pdb_get_logoff_time(to); DEBUG(10,("INFO_21 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) pdb_set_logoff_time(to, unix_time, PDB_CHANGED); } - - if (!nt_time_is_zero(&from->kickoff_time)) { + + if (from->fields_present & ACCT_EXPIRY) { unix_time=nt_time_to_unix(&from->kickoff_time); stored_time = pdb_get_kickoff_time(to); DEBUG(10,("INFO_21 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); @@ -96,14 +98,15 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); } - if (!nt_time_is_zero(&from->pass_can_change_time)) { + if (from->fields_present & ACCT_ALLOW_PWD_CHANGE) { unix_time=nt_time_to_unix(&from->pass_can_change_time); stored_time = pdb_get_pass_can_change_time(to); DEBUG(10,("INFO_21 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) pdb_set_pass_can_change_time(to, unix_time, PDB_CHANGED); } - if (!nt_time_is_zero(&from->pass_last_set_time)) { + + if (from->fields_present & ACCT_LAST_PWD_CHANGE) { unix_time=nt_time_to_unix(&from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); DEBUG(10,("INFO_21 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); @@ -111,7 +114,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); } - if (!nt_time_is_zero(&from->pass_must_change_time)) { + if (from->fields_present & ACCT_FORCE_PWD_CHANGE) { unix_time=nt_time_to_unix(&from->pass_must_change_time); stored_time=pdb_get_pass_must_change_time(to); DEBUG(10,("INFO_21 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); @@ -119,8 +122,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_pass_must_change_time(to, unix_time, PDB_CHANGED); } - /* Backend should check this for sainity */ - if (from->hdr_user_name.buffer) { + if ((from->fields_present & ACCT_USERNAME) && + (from->hdr_user_name.buffer)) { old_string = pdb_get_username(to); new_string = unistr2_static(&from->uni_user_name); DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); @@ -128,7 +131,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_username(to , new_string, PDB_CHANGED); } - if (from->hdr_full_name.buffer) { + if ((from->fields_present & ACCT_FULL_NAME) && + (from->hdr_full_name.buffer)) { old_string = pdb_get_fullname(to); new_string = unistr2_static(&from->uni_full_name); DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); @@ -136,7 +140,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_fullname(to , new_string, PDB_CHANGED); } - if (from->hdr_home_dir.buffer) { + if ((from->fields_present & ACCT_HOME_DIR) && + (from->hdr_home_dir.buffer)) { old_string = pdb_get_homedir(to); new_string = unistr2_static(&from->uni_home_dir); DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); @@ -144,7 +149,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_homedir(to , new_string, PDB_CHANGED); } - if (from->hdr_dir_drive.buffer) { + if ((from->fields_present & ACCT_HOME_DRIVE) && + (from->hdr_dir_drive.buffer)) { old_string = pdb_get_dir_drive(to); new_string = unistr2_static(&from->uni_dir_drive); DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); @@ -152,7 +158,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_dir_drive(to , new_string, PDB_CHANGED); } - if (from->hdr_logon_script.buffer) { + if ((from->fields_present & ACCT_LOGON_SCRIPT) && + (from->hdr_logon_script.buffer)) { old_string = pdb_get_logon_script(to); new_string = unistr2_static(&from->uni_logon_script); DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); @@ -160,7 +167,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_logon_script(to , new_string, PDB_CHANGED); } - if (from->hdr_profile_path.buffer) { + if ((from->fields_present & ACCT_PROFILE) && + (from->hdr_profile_path.buffer)) { old_string = pdb_get_profile_path(to); new_string = unistr2_static(&from->uni_profile_path); DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); @@ -168,7 +176,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_profile_path(to , new_string, PDB_CHANGED); } - if (from->hdr_acct_desc.buffer) { + if ((from->fields_present & ACCT_DESCRIPTION) && + (from->hdr_acct_desc.buffer)) { old_string = pdb_get_acct_desc(to); new_string = unistr2_static(&from->uni_acct_desc); DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); @@ -176,7 +185,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_acct_desc(to , new_string, PDB_CHANGED); } - if (from->hdr_workstations.buffer) { + if ((from->fields_present & ACCT_WORKSTATIONS) && + (from->hdr_workstations.buffer)) { old_string = pdb_get_workstations(to); new_string = unistr2_static(&from->uni_workstations); DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); @@ -184,7 +194,9 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_workstations(to , new_string, PDB_CHANGED); } - if (from->hdr_unknown_str.buffer) { + /* is this right? */ + if ((from->fields_present & ACCT_ADMIN_DESC) && + (from->hdr_unknown_str.buffer)) { old_string = pdb_get_unknown_str(to); new_string = unistr2_static(&from->uni_unknown_str); DEBUG(10,("INFO_21 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); @@ -192,7 +204,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) pdb_set_unknown_str(to , new_string, PDB_CHANGED); } - if (from->hdr_munged_dial.buffer) { + if ((from->fields_present & ACCT_CALLBACK) && + (from->hdr_munged_dial.buffer)) { char *newstr; old_string = pdb_get_munged_dial(to); mung.length = from->hdr_munged_dial.uni_str_len; @@ -205,59 +218,66 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) SAFE_FREE(newstr); } - if (from->user_rid == 0) { - DEBUG(10, ("INFO_21: Asked to set User RID to 0 !? Skipping change!\n")); - } else if (from->user_rid != pdb_get_user_rid(to)) { - DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); - /* we really allow this ??? metze */ - /* pdb_set_user_sid_from_rid(to, from->user_rid, PDB_CHANGED);*/ + if (from->fields_present & ACCT_RID) { + if (from->user_rid == 0) { + DEBUG(10, ("INFO_21: Asked to set User RID to 0 !? Skipping change!\n")); + } else if (from->user_rid != pdb_get_user_rid(to)) { + DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); + } } - if (from->group_rid == 0) { - DEBUG(10, ("INFO_21: Asked to set Group RID to 0 !? Skipping change!\n")); - } else if (from->group_rid != pdb_get_group_rid(to)) { - DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); - pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); + if (from->fields_present & ACCT_PRIMARY_GID) { + if (from->group_rid == 0) { + DEBUG(10, ("INFO_21: Asked to set Group RID to 0 !? Skipping change!\n")); + } else if (from->group_rid != pdb_get_group_rid(to)) { + DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); + pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); + } } - DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); - if (from->acb_info != pdb_get_acct_ctrl(to)) { - pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); + if (from->fields_present & ACCT_FLAGS) { + DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); + if (from->acb_info != pdb_get_acct_ctrl(to)) { + pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); + } } - DEBUG(10,("INFO_21 FIELDS_PRESENT: %08X -> %08X\n",pdb_get_fields_present(to),from->fields_present)); - if (from->fields_present != pdb_get_fields_present(to)) { - pdb_set_fields_present(to, from->fields_present, PDB_CHANGED); - } + if (from->fields_present & ACCT_LOGON_HOURS) { + DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); + if (from->logon_divs != pdb_get_logon_divs(to)) { + pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); + } - DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); - if (from->logon_divs != pdb_get_logon_divs(to)) { - pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); - } + DEBUG(15,("INFO_21 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); + if (from->logon_hrs.len != pdb_get_hours_len(to)) { + pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED); + } - DEBUG(15,("INFO_21 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); - if (from->logon_hrs.len != pdb_get_hours_len(to)) { - pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED); + DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); + /* Fix me: only update if it changes --metze */ + pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); } - DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); -/* Fix me: only update if it changes --metze */ - pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); - - DEBUG(10,("INFO_21 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count)); - if (from->bad_password_count != pdb_get_bad_password_count(to)) { - pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED); + if (from->fields_present & ACCT_BAD_PWD_COUNT) { + DEBUG(10,("INFO_21 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count)); + if (from->bad_password_count != pdb_get_bad_password_count(to)) { + pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED); + } } - DEBUG(10,("INFO_21 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count)); - if (from->logon_count != pdb_get_logon_count(to)) { - pdb_set_logon_count(to, from->logon_count, PDB_CHANGED); + if (from->fields_present & ACCT_NUM_LOGONS) { + DEBUG(10,("INFO_21 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count)); + if (from->logon_count != pdb_get_logon_count(to)) { + pdb_set_logon_count(to, from->logon_count, PDB_CHANGED); + } } - DEBUG(10,("INFO_21 UNKNOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); - if (from->unknown_6 != pdb_get_unknown_6(to)) { - pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); - } + /* if (from->fields_present & ACCT_??) { */ + DEBUG(10,("INFO_21 UNKNOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); + if (from->unknown_6 != pdb_get_unknown_6(to)) { + pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); + } + /* } */ DEBUG(10,("INFO_21 PADDING1 %02X %02X %02X %02X %02X %02X\n", from->padding1[0], @@ -290,14 +310,16 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) if (from == NULL || to == NULL) return; - if (!nt_time_is_zero(&from->logon_time)) { + + if (from->fields_present & ACCT_LAST_LOGON) { unix_time=nt_time_to_unix(&from->logon_time); stored_time = pdb_get_logon_time(to); DEBUG(10,("INFO_23 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) pdb_set_logon_time(to, unix_time, PDB_CHANGED); - } - if (!nt_time_is_zero(&from->logoff_time)) { + } + + if (from->fields_present & ACCT_LAST_LOGOFF) { unix_time=nt_time_to_unix(&from->logoff_time); stored_time = pdb_get_logoff_time(to); DEBUG(10,("INFO_23 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); @@ -305,7 +327,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_logoff_time(to, unix_time, PDB_CHANGED); } - if (!nt_time_is_zero(&from->kickoff_time)) { + if (from->fields_present & ACCT_EXPIRY) { unix_time=nt_time_to_unix(&from->kickoff_time); stored_time = pdb_get_kickoff_time(to); DEBUG(10,("INFO_23 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); @@ -313,14 +335,15 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); } - if (!nt_time_is_zero(&from->pass_can_change_time)) { + if (from->fields_present & ACCT_ALLOW_PWD_CHANGE) { unix_time=nt_time_to_unix(&from->pass_can_change_time); stored_time = pdb_get_pass_can_change_time(to); DEBUG(10,("INFO_23 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) pdb_set_pass_can_change_time(to, unix_time, PDB_CHANGED); } - if (!nt_time_is_zero(&from->pass_last_set_time)) { + + if (from->fields_present & ACCT_LAST_PWD_CHANGE) { unix_time=nt_time_to_unix(&from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); DEBUG(10,("INFO_23 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); @@ -328,7 +351,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); } - if (!nt_time_is_zero(&from->pass_must_change_time)) { + if (from->fields_present & ACCT_FORCE_PWD_CHANGE) { unix_time=nt_time_to_unix(&from->pass_must_change_time); stored_time=pdb_get_pass_must_change_time(to); DEBUG(10,("INFO_23 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); @@ -336,8 +359,9 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_pass_must_change_time(to, unix_time, PDB_CHANGED); } - /* Backend should check this for sainity */ - if (from->hdr_user_name.buffer) { + /* Backend should check this for sanity */ + if ((from->fields_present & ACCT_USERNAME) && + (from->hdr_user_name.buffer)) { old_string = pdb_get_username(to); new_string = unistr2_static(&from->uni_user_name); DEBUG(10,("INFO_23 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); @@ -345,7 +369,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_username(to , new_string, PDB_CHANGED); } - if (from->hdr_full_name.buffer) { + if ((from->fields_present & ACCT_FULL_NAME) && + (from->hdr_full_name.buffer)) { old_string = pdb_get_fullname(to); new_string = unistr2_static(&from->uni_full_name); DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); @@ -353,7 +378,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_fullname(to , new_string, PDB_CHANGED); } - if (from->hdr_home_dir.buffer) { + if ((from->fields_present & ACCT_HOME_DIR) && + (from->hdr_home_dir.buffer)) { old_string = pdb_get_homedir(to); new_string = unistr2_static(&from->uni_home_dir); DEBUG(10,("INFO_23 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); @@ -361,7 +387,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_homedir(to , new_string, PDB_CHANGED); } - if (from->hdr_dir_drive.buffer) { + if ((from->fields_present & ACCT_HOME_DRIVE) && + (from->hdr_dir_drive.buffer)) { old_string = pdb_get_dir_drive(to); new_string = unistr2_static(&from->uni_dir_drive); DEBUG(10,("INFO_23 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); @@ -369,7 +396,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_dir_drive(to , new_string, PDB_CHANGED); } - if (from->hdr_logon_script.buffer) { + if ((from->fields_present & ACCT_LOGON_SCRIPT) && + (from->hdr_logon_script.buffer)) { old_string = pdb_get_logon_script(to); new_string = unistr2_static(&from->uni_logon_script); DEBUG(10,("INFO_23 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); @@ -377,7 +405,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_logon_script(to , new_string, PDB_CHANGED); } - if (from->hdr_profile_path.buffer) { + if ((from->fields_present & ACCT_PROFILE) && + (from->hdr_profile_path.buffer)) { old_string = pdb_get_profile_path(to); new_string = unistr2_static(&from->uni_profile_path); DEBUG(10,("INFO_23 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); @@ -385,7 +414,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_profile_path(to , new_string, PDB_CHANGED); } - if (from->hdr_acct_desc.buffer) { + if ((from->fields_present & ACCT_DESCRIPTION) && + (from->hdr_acct_desc.buffer)) { old_string = pdb_get_acct_desc(to); new_string = unistr2_static(&from->uni_acct_desc); DEBUG(10,("INFO_23 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); @@ -393,7 +423,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_acct_desc(to , new_string, PDB_CHANGED); } - if (from->hdr_workstations.buffer) { + if ((from->fields_present & ACCT_WORKSTATIONS) && + (from->hdr_workstations.buffer)) { old_string = pdb_get_workstations(to); new_string = unistr2_static(&from->uni_workstations); DEBUG(10,("INFO_23 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); @@ -401,7 +432,9 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_workstations(to , new_string, PDB_CHANGED); } - if (from->hdr_unknown_str.buffer) { + /* is this right? */ + if ((from->fields_present & ACCT_ADMIN_DESC) && + (from->hdr_unknown_str.buffer)) { old_string = pdb_get_unknown_str(to); new_string = unistr2_static(&from->uni_unknown_str); DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); @@ -409,7 +442,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) pdb_set_unknown_str(to , new_string, PDB_CHANGED); } - if (from->hdr_munged_dial.buffer) { + if ((from->fields_present & ACCT_CALLBACK) && + (from->hdr_munged_dial.buffer)) { char *newstr; old_string = pdb_get_munged_dial(to); mung.length = from->hdr_munged_dial.uni_str_len; @@ -422,58 +456,66 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) SAFE_FREE(newstr); } - if (from->user_rid == 0) { - DEBUG(10, ("INFO_23: Asked to set User RID to 0 !? Skipping change!\n")); - } else if (from->user_rid != pdb_get_user_rid(to)) { - DEBUG(10,("INFO_23 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); - /* we really allow this ??? metze */ - /* pdb_set_user_sid_from_rid(to, from->user_rid, PDB_CHANGED);*/ - } - if (from->group_rid == 0) { - DEBUG(10, ("INFO_23: Asked to set Group RID to 0 !? Skipping change!\n")); - } else if (from->group_rid != pdb_get_group_rid(to)) { - DEBUG(10,("INFO_23 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); - pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); + if (from->fields_present & ACCT_RID) { + if (from->user_rid == 0) { + DEBUG(10, ("INFO_23: Asked to set User RID to 0 !? Skipping change!\n")); + } else if (from->user_rid != pdb_get_user_rid(to)) { + DEBUG(10,("INFO_23 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); + } + } + + if (from->fields_present & ACCT_PRIMARY_GID) { + if (from->group_rid == 0) { + DEBUG(10, ("INFO_23: Asked to set Group RID to 0 !? Skipping change!\n")); + } else if (from->group_rid != pdb_get_group_rid(to)) { + DEBUG(10,("INFO_23 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); + pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); + } } - DEBUG(10,("INFO_23 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); - if (from->acb_info != pdb_get_acct_ctrl(to)) { - pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); + if (from->fields_present & ACCT_FLAGS) { + DEBUG(10,("INFO_23 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); + if (from->acb_info != pdb_get_acct_ctrl(to)) { + pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); + } } - DEBUG(10,("INFO_23 FIELDS_PRESENT: %08X -> %08X\n",pdb_get_fields_present(to),from->fields_present)); - if (from->fields_present != pdb_get_fields_present(to)) { - pdb_set_fields_present(to, from->fields_present, PDB_CHANGED); - } + if (from->fields_present & ACCT_LOGON_HOURS) { + DEBUG(15,("INFO_23 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); + if (from->logon_divs != pdb_get_logon_divs(to)) { + pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); + } - DEBUG(15,("INFO_23 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); - if (from->logon_divs != pdb_get_logon_divs(to)) { - pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); - } + DEBUG(15,("INFO_23 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); + if (from->logon_hrs.len != pdb_get_hours_len(to)) { + pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED); + } - DEBUG(15,("INFO_23 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); - if (from->logon_hrs.len != pdb_get_hours_len(to)) { - pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED); + DEBUG(15,("INFO_23 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); + /* Fix me: only update if it changes --metze */ + pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); } - DEBUG(15,("INFO_23 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); -/* Fix me: only update if it changes --metze */ - pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); - - DEBUG(10,("INFO_23 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count)); - if (from->bad_password_count != pdb_get_bad_password_count(to)) { - pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED); + if (from->fields_present & ACCT_BAD_PWD_COUNT) { + DEBUG(10,("INFO_23 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count)); + if (from->bad_password_count != pdb_get_bad_password_count(to)) { + pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED); + } } - DEBUG(10,("INFO_23 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count)); - if (from->logon_count != pdb_get_logon_count(to)) { - pdb_set_logon_count(to, from->logon_count, PDB_CHANGED); + if (from->fields_present & ACCT_NUM_LOGONS) { + DEBUG(10,("INFO_23 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count)); + if (from->logon_count != pdb_get_logon_count(to)) { + pdb_set_logon_count(to, from->logon_count, PDB_CHANGED); + } } - DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); - if (from->unknown_6 != pdb_get_unknown_6(to)) { - pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); - } + /* if (from->fields_present & ACCT_??) { */ + DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); + if (from->unknown_6 != pdb_get_unknown_6(to)) { + pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); + } + /* } */ DEBUG(10,("INFO_23 PADDING1 %02X %02X %02X %02X %02X %02X\n", from->padding1[0], -- cgit From 8d12b8768a750c064706053c87016c522964656a Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Wed, 3 Mar 2004 04:23:43 +0000 Subject: quick for for usrmgr. unknown_6 is really max dimension of logon hours array. need to update passdb for this. (This used to be commit fbf909926b7d7b1e92ebeba44469392296c35c1a) --- source3/rpc_server/srv_samr_util.c | 42 +++++++++++--------------------------- 1 file changed, 12 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index c30cc3e77b..dd92e0d90a 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -256,6 +256,12 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); /* Fix me: only update if it changes --metze */ pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); + + /* This is max logon hours */ + DEBUG(10,("INFO_21 UNKNOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); + if (from->unknown_6 != pdb_get_unknown_6(to)) { + pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); + } } if (from->fields_present & ACCT_BAD_PWD_COUNT) { @@ -272,21 +278,6 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) } } - /* if (from->fields_present & ACCT_??) { */ - DEBUG(10,("INFO_21 UNKNOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); - if (from->unknown_6 != pdb_get_unknown_6(to)) { - pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); - } - /* } */ - - DEBUG(10,("INFO_21 PADDING1 %02X %02X %02X %02X %02X %02X\n", - from->padding1[0], - from->padding1[1], - from->padding1[2], - from->padding1[3], - from->padding1[4], - from->padding1[5])); - DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) { pdb_set_pass_must_change_time(to,0, PDB_CHANGED); @@ -494,6 +485,12 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) DEBUG(15,("INFO_23 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); /* Fix me: only update if it changes --metze */ pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); + + /* This is max logon hours */ + DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); + if (from->unknown_6 != pdb_get_unknown_6(to)) { + pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); + } } if (from->fields_present & ACCT_BAD_PWD_COUNT) { @@ -510,21 +507,6 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) } } - /* if (from->fields_present & ACCT_??) { */ - DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); - if (from->unknown_6 != pdb_get_unknown_6(to)) { - pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); - } - /* } */ - - DEBUG(10,("INFO_23 PADDING1 %02X %02X %02X %02X %02X %02X\n", - from->padding1[0], - from->padding1[1], - from->padding1[2], - from->padding1[3], - from->padding1[4], - from->padding1[5])); - DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) { pdb_set_pass_must_change_time(to,0, PDB_CHANGED); -- cgit From b737769a7477351f7f9670e14b06728b9df46389 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Wed, 3 Mar 2004 17:44:00 +0000 Subject: more usrmgr fixes: display lockout timers in minutes, not seconds, for samr 2e (This used to be commit 832674c099a3ff9bb747dba6235e47d40a930abd) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a817627127..35a6f37e17 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4434,10 +4434,10 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW break; case 0x0c: account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); - u_lock_duration = account_policy_temp; + u_lock_duration = account_policy_temp * 60; account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp); - u_reset_time = account_policy_temp; + u_reset_time = account_policy_temp * 60; account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); lockout = account_policy_temp; -- cgit From 51deca6bc9bbf6a07cbf5126cc6b2598484ef29c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 4 Mar 2004 17:57:21 +0000 Subject: There's a specific error message NT_STATUS_ALIAS_EXISTS. (This used to be commit f0d99f318c67852ac5bf9b606faa115ad36a5f80) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 35a6f37e17..70ae4d170e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3964,7 +3964,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S /* check if group already exists */ if ( (grp=getgrnam(name)) != NULL) - return NT_STATUS_GROUP_EXISTS; + return NT_STATUS_ALIAS_EXISTS; /* we can create the UNIX group */ if (smb_create_group(name, &gid) != 0) -- cgit From ccf93c36d8d838b7bb56cc089ed56e8da4db5528 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 10 Mar 2004 01:32:26 +0000 Subject: Formatting reformat before I start to change anything here. Jeremy. (This used to be commit 80fde09fc4a5d7e72611fd587777151adc5c890d) --- source3/rpc_server/srv_dfs_nt.c | 531 +++++++++++++++++++--------------------- 1 file changed, 258 insertions(+), 273 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index f324fd126e..a3b06bb6e1 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -44,324 +44,309 @@ uint32 _dfs_exist(pipes_struct *p, DFS_Q_DFS_EXIST *q_u, DFS_R_DFS_EXIST *r_u) WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) { - struct current_user user; - struct junction_map jn; - struct referral* old_referral_list = NULL; - BOOL exists = False; - - pstring dfspath, servername, sharename; - pstring altpath; - - get_current_user(&user,p); - - if (user.uid != 0) { - DEBUG(10,("_dfs_add: uid != 0. Access denied.\n")); - return WERR_ACCESS_DENIED; - } - - unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1); - unistr2_to_ascii(servername, &q_u->ServerName, sizeof(servername)-1); - unistr2_to_ascii(sharename, &q_u->ShareName, sizeof(sharename)-1); - - DEBUG(5,("init_reply_dfs_add: Request to add %s -> %s\\%s.\n", - dfspath, servername, sharename)); - - pstrcpy(altpath, servername); - pstrcat(altpath, "\\"); - pstrcat(altpath, sharename); - - /* The following call can change the cwd. */ - if(get_referred_path(dfspath, &jn, NULL, NULL)) - { - exists = True; - jn.referral_count += 1; - old_referral_list = jn.referral_list; - } - else - jn.referral_count = 1; - - vfs_ChDir(p->conn,p->conn->connectpath); - - jn.referral_list = (struct referral*) talloc(p->mem_ctx, jn.referral_count - * sizeof(struct referral)); - - if(jn.referral_list == NULL) - { - DEBUG(0,("init_reply_dfs_add: talloc failed for referral list!\n")); - return WERR_DFS_INTERNAL_ERROR; - } - - if(old_referral_list) - { - memcpy(jn.referral_list, old_referral_list, - sizeof(struct referral)*jn.referral_count-1); - SAFE_FREE(old_referral_list); - } + struct current_user user; + struct junction_map jn; + struct referral* old_referral_list = NULL; + BOOL exists = False; + + pstring dfspath, servername, sharename; + pstring altpath; + + get_current_user(&user,p); + + if (user.uid != 0) { + DEBUG(10,("_dfs_add: uid != 0. Access denied.\n")); + return WERR_ACCESS_DENIED; + } + + unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1); + unistr2_to_ascii(servername, &q_u->ServerName, sizeof(servername)-1); + unistr2_to_ascii(sharename, &q_u->ShareName, sizeof(sharename)-1); + + DEBUG(5,("init_reply_dfs_add: Request to add %s -> %s\\%s.\n", + dfspath, servername, sharename)); + + pstrcpy(altpath, servername); + pstrcat(altpath, "\\"); + pstrcat(altpath, sharename); + + /* The following call can change the cwd. */ + if(get_referred_path(dfspath, &jn, NULL, NULL)) { + exists = True; + jn.referral_count += 1; + old_referral_list = jn.referral_list; + } else { + jn.referral_count = 1; + } + + vfs_ChDir(p->conn,p->conn->connectpath); + + jn.referral_list = (struct referral*) talloc(p->mem_ctx, jn.referral_count + * sizeof(struct referral)); + + if(jn.referral_list == NULL) { + DEBUG(0,("init_reply_dfs_add: talloc failed for referral list!\n")); + return WERR_DFS_INTERNAL_ERROR; + } + + if(old_referral_list) { + memcpy(jn.referral_list, old_referral_list, sizeof(struct referral)*jn.referral_count-1); + SAFE_FREE(old_referral_list); + } - jn.referral_list[jn.referral_count-1].proximity = 0; - jn.referral_list[jn.referral_count-1].ttl = REFERRAL_TTL; + jn.referral_list[jn.referral_count-1].proximity = 0; + jn.referral_list[jn.referral_count-1].ttl = REFERRAL_TTL; - pstrcpy(jn.referral_list[jn.referral_count-1].alternate_path, altpath); + pstrcpy(jn.referral_list[jn.referral_count-1].alternate_path, altpath); - if(!create_msdfs_link(&jn, exists)) { - vfs_ChDir(p->conn,p->conn->connectpath); - return WERR_DFS_CANT_CREATE_JUNCT; - } - vfs_ChDir(p->conn,p->conn->connectpath); + if(!create_msdfs_link(&jn, exists)) { + vfs_ChDir(p->conn,p->conn->connectpath); + return WERR_DFS_CANT_CREATE_JUNCT; + } + vfs_ChDir(p->conn,p->conn->connectpath); - return WERR_OK; + return WERR_OK; } WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DFS_R_DFS_REMOVE *r_u) { - struct current_user user; - struct junction_map jn; - BOOL found = False; - - pstring dfspath, servername, sharename; - pstring altpath; - - get_current_user(&user,p); - - if (user.uid != 0) { - DEBUG(10,("_dfs_remove: uid != 0. Access denied.\n")); - return WERR_ACCESS_DENIED; - } - - unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1); - if(q_u->ptr_ServerName) - unistr2_to_ascii(servername, &q_u->ServerName, sizeof(servername)-1); - - if(q_u->ptr_ShareName) - unistr2_to_ascii(sharename, &q_u->ShareName, sizeof(sharename)-1); - - if(q_u->ptr_ServerName && q_u->ptr_ShareName) - { - pstrcpy(altpath, servername); - pstrcat(altpath, "\\"); - pstrcat(altpath, sharename); - strlower_m(altpath); - } - - DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n", - dfspath, servername, sharename)); - - if(!get_referred_path(dfspath, &jn, NULL, NULL)) - return WERR_DFS_NO_SUCH_VOL; - - /* if no server-share pair given, remove the msdfs link completely */ - if(!q_u->ptr_ServerName && !q_u->ptr_ShareName) - { - if(!remove_msdfs_link(&jn)) { - vfs_ChDir(p->conn,p->conn->connectpath); - return WERR_DFS_NO_SUCH_VOL; - } - vfs_ChDir(p->conn,p->conn->connectpath); - } - else - { - 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;iconn,p->conn->connectpath); - return WERR_DFS_NO_SUCH_VOL; - } - vfs_ChDir(p->conn,p->conn->connectpath); + + unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1); + if(q_u->ptr_ServerName) { + unistr2_to_ascii(servername, &q_u->ServerName, sizeof(servername)-1); + } + + if(q_u->ptr_ShareName) { + unistr2_to_ascii(sharename, &q_u->ShareName, sizeof(sharename)-1); + } + + if(q_u->ptr_ServerName && q_u->ptr_ShareName) { + pstrcpy(altpath, servername); + pstrcat(altpath, "\\"); + pstrcat(altpath, sharename); + strlower_m(altpath); + } + + DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n", + dfspath, servername, sharename)); + + if(!get_referred_path(dfspath, &jn, NULL, NULL)) { + return WERR_DFS_NO_SUCH_VOL; } - else - { - if(!create_msdfs_link(&jn, True)) { - vfs_ChDir(p->conn,p->conn->connectpath); - return WERR_DFS_CANT_CREATE_JUNCT; - } - vfs_ChDir(p->conn,p->conn->connectpath); + + /* if no server-share pair given, remove the msdfs link completely */ + if(!q_u->ptr_ServerName && !q_u->ptr_ShareName) { + if(!remove_msdfs_link(&jn)) { + vfs_ChDir(p->conn,p->conn->connectpath); + return WERR_DFS_NO_SUCH_VOL; + } + vfs_ChDir(p->conn,p->conn->connectpath); + } else { + 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;iconn,p->conn->connectpath); + return WERR_DFS_NO_SUCH_VOL; + } + } else { + if(!create_msdfs_link(&jn, True)) { + vfs_ChDir(p->conn,p->conn->connectpath); + return WERR_DFS_CANT_CREATE_JUNCT; + } + } + vfs_ChDir(p->conn,p->conn->connectpath); } - } - return WERR_OK; + return WERR_OK; } static BOOL init_reply_dfs_info_1(struct junction_map* j, DFS_INFO_1* dfs1, int num_j) { - int i=0; - for(i=0;ialternate_path); - trim_char(path,'\\','\0'); - p = strrchr_m(path,'\\'); - if(p==NULL) - { - DEBUG(4,("init_reply_dfs_info_3: invalid path: no \\ found in %s\n",path)); - continue; - } - *p = '\0'; - DEBUG(5,("storage %d: %s.%s\n",ii,path,p+1)); - stor->state = 2; /* set all storages as ONLINE */ - init_unistr2(&stor->servername, path, UNI_STR_TERMINATE); - init_unistr2(&stor->sharename, p+1, UNI_STR_TERMINATE); - stor->ptr_servername = stor->ptr_sharename = 1; + pstrcpy(path, ref->alternate_path); + trim_char(path,'\\','\0'); + p = strrchr_m(path,'\\'); + if(p==NULL) { + DEBUG(4,("init_reply_dfs_info_3: invalid path: no \\ found in %s\n",path)); + continue; + } + *p = '\0'; + DEBUG(5,("storage %d: %s.%s\n",ii,path,p+1)); + stor->state = 2; /* set all storages as ONLINE */ + init_unistr2(&stor->servername, path, UNI_STR_TERMINATE); + init_unistr2(&stor->sharename, p+1, UNI_STR_TERMINATE); + stor->ptr_servername = stor->ptr_sharename = 1; + } } - } - return True; + return True; } static WERROR init_reply_dfs_ctr(TALLOC_CTX *ctx, uint32 level, DFS_INFO_CTR* ctr, struct junction_map* jn, int num_jn) { - /* do the levels */ - switch(level) - { - case 1: - { - DFS_INFO_1* dfs1; - dfs1 = (DFS_INFO_1*) talloc(ctx, num_jn * sizeof(DFS_INFO_1)); - if (!dfs1) - return WERR_NOMEM; - init_reply_dfs_info_1(jn, dfs1, num_jn); - ctr->dfs.info1 = dfs1; - break; - } - case 2: - { - DFS_INFO_2* dfs2; - dfs2 = (DFS_INFO_2*) talloc(ctx, num_jn * sizeof(DFS_INFO_2)); - if (!dfs2) - return WERR_NOMEM; - init_reply_dfs_info_2(jn, dfs2, num_jn); - ctr->dfs.info2 = dfs2; - break; - } - case 3: - { - DFS_INFO_3* dfs3; - dfs3 = (DFS_INFO_3*) talloc(ctx, num_jn * sizeof(DFS_INFO_3)); - if (!dfs3) - return WERR_NOMEM; - init_reply_dfs_info_3(ctx, jn, dfs3, num_jn); - ctr->dfs.info3 = dfs3; - break; - } + /* do the levels */ + switch(level) { + case 1: + { + DFS_INFO_1* dfs1; + dfs1 = (DFS_INFO_1*) talloc(ctx, num_jn * sizeof(DFS_INFO_1)); + if (!dfs1) + return WERR_NOMEM; + init_reply_dfs_info_1(jn, dfs1, num_jn); + ctr->dfs.info1 = dfs1; + break; + } + case 2: + { + DFS_INFO_2* dfs2; + dfs2 = (DFS_INFO_2*) talloc(ctx, num_jn * sizeof(DFS_INFO_2)); + if (!dfs2) + return WERR_NOMEM; + init_reply_dfs_info_2(jn, dfs2, num_jn); + ctr->dfs.info2 = dfs2; + break; + } + case 3: + { + DFS_INFO_3* dfs3; + dfs3 = (DFS_INFO_3*) talloc(ctx, num_jn * sizeof(DFS_INFO_3)); + if (!dfs3) + return WERR_NOMEM; + init_reply_dfs_info_3(ctx, jn, dfs3, num_jn); + ctr->dfs.info3 = dfs3; + break; + } default: return WERR_INVALID_PARAM; - } - return WERR_OK; + } + return WERR_OK; } WERROR _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u) { - uint32 level = q_u->level; - struct junction_map jn[MAX_MSDFS_JUNCTIONS]; - int num_jn = 0; + uint32 level = q_u->level; + struct junction_map jn[MAX_MSDFS_JUNCTIONS]; + int num_jn = 0; - num_jn = enum_msdfs_links(jn); - vfs_ChDir(p->conn,p->conn->connectpath); + num_jn = enum_msdfs_links(jn); + vfs_ChDir(p->conn,p->conn->connectpath); - DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", num_jn, level)); - - r_u->ptr_buffer = level; - r_u->level = r_u->level2 = level; - r_u->ptr_num_entries = r_u->ptr_num_entries2 = 1; - r_u->num_entries = r_u->num_entries2 = num_jn; - r_u->reshnd.ptr_hnd = 1; - r_u->reshnd.handle = num_jn; + DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", num_jn, level)); + + r_u->ptr_buffer = level; + r_u->level = r_u->level2 = level; + r_u->ptr_num_entries = r_u->ptr_num_entries2 = 1; + r_u->num_entries = r_u->num_entries2 = num_jn; + r_u->reshnd.ptr_hnd = 1; + r_u->reshnd.handle = num_jn; - r_u->ctr = (DFS_INFO_CTR*)talloc(p->mem_ctx, sizeof(DFS_INFO_CTR)); - if (!r_u->ctr) - return WERR_NOMEM; - ZERO_STRUCTP(r_u->ctr); - r_u->ctr->switch_value = level; - r_u->ctr->num_entries = num_jn; - r_u->ctr->ptr_dfs_ctr = 1; + r_u->ctr = (DFS_INFO_CTR*)talloc(p->mem_ctx, sizeof(DFS_INFO_CTR)); + if (!r_u->ctr) + return WERR_NOMEM; + ZERO_STRUCTP(r_u->ctr); + r_u->ctr->switch_value = level; + r_u->ctr->num_entries = num_jn; + r_u->ctr->ptr_dfs_ctr = 1; - r_u->status = init_reply_dfs_ctr(p->mem_ctx, level, r_u->ctr, jn, num_jn); + r_u->status = init_reply_dfs_ctr(p->mem_ctx, level, r_u->ctr, jn, num_jn); - return r_u->status; + return r_u->status; } WERROR _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u, -- cgit From dbb38cc6b5829d9ac45e3dea40878039edd26f8d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 16 Mar 2004 17:06:11 +0000 Subject: merging print change notify fix from HP appliance. Also might address some one the issues in BUG 1007 (This used to be commit 17ecea4152fb0883acde675b01f19d3e19ff1d64) --- source3/rpc_server/srv_spoolss_nt.c | 78 ------------------------------------- 1 file changed, 78 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 61c908e474..c971ff3631 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1099,58 +1099,6 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, voi return True; } -/* ENUMJOB last timestamp list. */ -struct ejts_list { - struct ejts_list *next, *prev; - char *printer_name; - struct timeval tv; -}; - -static struct ejts_list *ejts_head; - -static struct ejts_list *find_enumjobs_timestamp(const char *printer_name) -{ - struct ejts_list *ejtsl; - - for( ejtsl = ejts_head; ejtsl; ejtsl = ejtsl->next) - if (strequal(ejtsl->printer_name, printer_name)) - return ejtsl; - return NULL; -} - -static void set_enumjobs_timestamp(int snum) -{ - const char *printer_name = lp_const_servicename(snum); - struct ejts_list *ejtsl = find_enumjobs_timestamp(printer_name); - - if (!ejtsl) { - ejtsl = (struct ejts_list *)malloc(sizeof(struct ejts_list)); - if (!ejtsl) - return; - ejtsl->printer_name = strdup(printer_name); - if (!ejtsl->printer_name) { - SAFE_FREE(ejtsl); - return; - } - DLIST_ADD(ejts_head, ejtsl); - } - - gettimeofday(&ejtsl->tv, NULL); -} - -static int timeval_diff(struct timeval *tv1, struct timeval *tv2) -{ - if (tv1->tv_sec > tv2->tv_sec) - return 1; - if (tv1->tv_sec < tv2->tv_sec) - return -1; - if (tv1->tv_usec > tv2->tv_usec) - return 1; - if (tv1->tv_usec < tv2->tv_usec) - return -1; - return 0; -} - /******************************************************************** Receive a notify2 message list ********************************************************************/ @@ -1214,29 +1162,6 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz notify2_unpack_msg( ¬ify, &msg_tv, msg_ptr, msg_len ); msg_ptr += msg_len; - /* See if it is still relevent. */ - if (notify.type == JOB_NOTIFY_TYPE) { - BOOL status_is_deleting = False; - - if (notify.field == JOB_NOTIFY_STATUS && (notify.notify.value[0] & (JOB_STATUS_DELETING|JOB_STATUS_DELETED))) - status_is_deleting = True; - - if (!status_is_deleting) { - struct ejts_list *ejtsl = find_enumjobs_timestamp(notify.printer); - - if (ejtsl && (timeval_diff(&ejtsl->tv, &msg_tv) > 0)) { - - DEBUG(10, ("receive_notify2_message_list: enumjobs ts = %u, %u, msg ts = %u, %u discarding\n", - (unsigned int)ejtsl->tv.tv_sec, (unsigned int)ejtsl->tv.tv_usec, - (unsigned int)msg_tv.tv_sec, (unsigned int)msg_tv.tv_usec )); - - /* Message no longer relevent. Ignore it. */ - if ( notify.len != 0 ) - SAFE_FREE( notify.notify.data ); - continue; - } - } - } /* add to correct list in container */ notify_msg_ctr_addmsg( &messages, ¬ify ); @@ -6518,7 +6443,6 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); if (*returned == 0) { - set_enumjobs_timestamp(snum); SAFE_FREE(queue); return WERR_OK; } @@ -6526,11 +6450,9 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO switch (level) { case 1: wret = enumjobs_level1(queue, snum, buffer, offered, needed, returned); - set_enumjobs_timestamp(snum); return wret; case 2: wret = enumjobs_level2(queue, snum, buffer, offered, needed, returned); - set_enumjobs_timestamp(snum); return wret; default: SAFE_FREE(queue); -- cgit From 60a237b0b5444b5dc1ba84f31891723e7d7f804d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 18 Mar 2004 07:36:36 +0000 Subject: Fix sambaUserWorkstations for network samlogons against us as DC. Strip the \\ off the workstation. Volker (This used to be commit d01cb00aad76f8be9767fdcfd92c88ea5d8c4f14) --- source3/rpc_server/srv_netlog_nt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index e8bc6345de..bf0e81f5c8 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -598,14 +598,22 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * switch (ctr->switch_value) { case NET_LOGON_TYPE: { + const char *wksname = nt_workstation; + if (!NT_STATUS_IS_OK(status = make_auth_context_fixed(&auth_context, ctr->auth.id2.lm_chal))) { return status; } + /* For a network logon, the workstation name comes in with two + * backslashes in the front. Strip them if they are there. */ + + if (*wksname == '\\') wksname++; + if (*wksname == '\\') wksname++; + /* Standard challenge/response authenticaion */ if (!make_user_info_netlogon_network(&user_info, nt_username, nt_domain, - nt_workstation, + wksname, ctr->auth.id2.lm_chal_resp.buffer, ctr->auth.id2.lm_chal_resp.str_str_len, ctr->auth.id2.nt_chal_resp.buffer, -- cgit From 2197bd26ac1809ca0cee42036c594a97dabe681e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 1 Apr 2004 15:15:13 +0000 Subject: BUG 1023: surround get_group_from_gid() with become_unbecome_root() block (This used to be commit 1aeeb432c75eeb67e9e1323932b37d34da416d37) --- source3/rpc_server/srv_util.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 504e6a83c0..5bb8db4e06 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -149,7 +149,11 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui for (i=0;i Date: Fri, 2 Apr 2004 18:46:19 +0000 Subject: Added per-share parameter "store dos attributes". When set, will store dos attributes in an EA. Based on an original patch from tridge, but modified somewhat to cover all cases. Jeremy. (This used to be commit ed653cd468213e0be901bc654aa3748ce5837947) --- source3/rpc_server/srv_srvsvc_nt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 40d3a43bef..77b9be9966 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1887,13 +1887,13 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename)); unix_convert(filename, conn, NULL, &bad_path, &st); fsp = open_file_shared(conn, filename, &st, SET_OPEN_MODE(DOS_OPEN_RDONLY), - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, 0, &access_mode, &action); + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, 0, &access_mode, &action); if (!fsp) { /* Perhaps it is a directory */ if (errno == EISDIR) fsp = open_directory(conn, filename, &st,FILE_READ_ATTRIBUTES,0, - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), &action); if (!fsp) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); @@ -1991,13 +1991,13 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ unix_convert(filename, conn, NULL, &bad_path, &st); fsp = open_file_shared(conn, filename, &st, SET_OPEN_MODE(DOS_OPEN_RDWR), - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, 0, &access_mode, &action); + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, 0, &access_mode, &action); if (!fsp) { /* Perhaps it is a directory */ if (errno == EISDIR) fsp = open_directory(conn, filename, &st,FILE_READ_ATTRIBUTES,0, - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action); + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), &action); if (!fsp) { DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename)); -- cgit From 931df5850e326ad0639fe317e0ca82e6d820a68e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 5 Apr 2004 12:19:50 +0000 Subject: r39: * importing .cvsignore files * updateing WHATSNEW with vl's change (This used to be commit a7e2730ec4389e0c249886a8bfe1ee14c5abac41) --- source3/rpc_server/.cvsignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 source3/rpc_server/.cvsignore (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/.cvsignore b/source3/rpc_server/.cvsignore deleted file mode 100644 index e69de29bb2..0000000000 -- cgit From d17425ed52b086b7046708a207e849271cedc804 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 6 Apr 2004 08:11:16 +0000 Subject: r69: Global rename of 'nt_session_key' -> 'user_session_key'. The session key could be anything, and may not be based on anything 'NT'. This is also what microsoft calls it. (This used to be commit 724e8d3f33719543146280062435c69a835c491e) --- source3/rpc_server/srv_netlog_nt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index bf0e81f5c8..e3f687be13 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -691,7 +691,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * pstring my_name; fstring user_sid_string; fstring group_sid_string; - uchar nt_session_key[16]; + uchar user_session_key[16]; uchar lm_session_key[16]; uchar netlogon_sess_key[16]; @@ -727,10 +727,10 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * ZERO_STRUCT(netlogon_sess_key); memcpy(netlogon_sess_key, p->dc.sess_key, 8); - if (server_info->nt_session_key.length) { - memcpy(nt_session_key, server_info->nt_session_key.data, - MIN(sizeof(nt_session_key), server_info->nt_session_key.length)); - SamOEMhash(nt_session_key, netlogon_sess_key, 16); + if (server_info->user_session_key.length) { + memcpy(user_session_key, server_info->user_session_key.data, + MIN(sizeof(user_session_key), server_info->user_session_key.length)); + SamOEMhash(user_session_key, netlogon_sess_key, 16); } if (server_info->lm_session_key.length) { memcpy(lm_session_key, server_info->lm_session_key.data, @@ -760,7 +760,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * num_gids, /* uint32 num_groups */ gids , /* DOM_GID *gids */ 0x20 , /* uint32 user_flgs (?) */ - server_info->nt_session_key.length ? nt_session_key : NULL, + server_info->user_session_key.length ? user_session_key : NULL, server_info->lm_session_key.length ? lm_session_key : NULL, my_name , /* char *logon_srv */ pdb_get_domain(sampw), @@ -768,7 +768,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * /* Should be users domain sid, not servers - for trusted domains */ NULL); /* char *other_sids */ - ZERO_STRUCT(nt_session_key); + ZERO_STRUCT(user_session_key); ZERO_STRUCT(lm_session_key); } free_server_info(&server_info); -- cgit From ddc0716fa88bcef0dfe2396ad4b93a5904629d71 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Tue, 6 Apr 2004 22:02:47 +0000 Subject: r91: Fix lsalookupnames. Previously we'd fail if we didn't find the name, but we never checked if it was a domain user and didn't find a local one. (This used to be commit 68022f5ebc55d1f3403dee5198d364cff300baf5) --- source3/rpc_server/srv_lsa_nt.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 07c024e1ca..9801ce47f8 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -165,6 +165,12 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, status = lookup_name(dom_name, user, &sid, &name_type); + if((name_type == SID_NAME_UNKNOWN) && (lp_server_role() == ROLE_DOMAIN_MEMBER) && (strncmp(dom_name, full_name, strlen(dom_name)) != 0)) { + DEBUG(5, ("init_lsa_rid2s: domain name not provided and local account not found, using member domain\n")); + fstrcpy(dom_name, lp_workgroup()); + status = lookup_name(dom_name, user, &sid, &name_type); + } + DEBUG(5, ("init_lsa_rid2s: %s\n", status ? "found" : "not found")); -- cgit From f79e40072a963fd3b9698fa26c4e4dc135ab8c3e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 7 Apr 2004 12:42:03 +0000 Subject: r115: finally checking in tridge's winbindd_schannel patch for connections (This used to be commit 1fae60ab20c5cbe396dc8af1c8c9a98d5683fdf4) --- source3/rpc_server/srv_pipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index fa24efe589..8337c4e3c7 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -227,7 +227,7 @@ BOOL create_next_pdu(pipes_struct *p) if (auth_seal || auth_verify) { RPC_HDR_AUTH auth_info; - init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, RPC_PIPE_AUTH_SEAL_LEVEL, + init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, auth_info.auth_level, (auth_verify ? RPC_HDR_AUTH_LEN : 0), (auth_verify ? 1 : 0)); if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_AUTH.\n")); @@ -1106,7 +1106,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) re-used from the auth2 the client did before. */ p->dc = last_dcinfo; - init_rpc_hdr_auth(&auth_info, NETSEC_AUTH_TYPE, RPC_PIPE_AUTH_SEAL_LEVEL, RPC_HDR_AUTH_LEN, 1); + init_rpc_hdr_auth(&auth_info, NETSEC_AUTH_TYPE, auth_info.auth_level, RPC_HDR_AUTH_LEN, 1); if(!smb_io_rpc_hdr_auth("", &auth_info, &out_auth, 0)) { DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_AUTH failed.\n")); goto err_exit; -- cgit From 7af3777ab32ee220700ed3367d07ca18b2bbdd47 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 7 Apr 2004 12:43:44 +0000 Subject: r116: volker's patch for local group and group nesting (This used to be commit b393469d9581f20e4d4c52633b952ee984cca36f) --- source3/rpc_server/srv_lsa_nt.c | 5 + source3/rpc_server/srv_samr_nt.c | 451 ++++++++++++++++----------------------- 2 files changed, 185 insertions(+), 271 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 9801ce47f8..de4fdceba7 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -171,6 +171,11 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, status = lookup_name(dom_name, user, &sid, &name_type); } + if (name_type == SID_NAME_WKN_GRP) { + /* BUILTIN aliases are still aliases :-) */ + name_type = SID_NAME_ALIAS; + } + DEBUG(5, ("init_lsa_rid2s: %s\n", status ? "found" : "not found")); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 70ae4d170e..2e5fe295ec 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -879,7 +879,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 NTSTATUS get_group_entries( enum SID_NAME_USE type, TALLOC_CTX *ctx, +static NTSTATUS get_group_domain_entries( TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, uint32 *p_num_entries, uint32 max_entries ) { @@ -894,7 +894,8 @@ static NTSTATUS get_group_entries( enum SID_NAME_USE type, TALLOC_CTX *ctx, needed for some passdb backends to enumerate groups */ become_root(); - pdb_enum_group_mapping(type, &map, (int *)&group_entries, ENUM_ONLY_MAPPED); + pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, + ENUM_ONLY_MAPPED); unbecome_root(); num_entries=group_entries-start_idx; @@ -915,51 +916,57 @@ static NTSTATUS get_group_entries( enum SID_NAME_USE type, TALLOC_CTX *ctx, fstrcpy((*d_grp)[i].name, map[i+start_idx].nt_name); fstrcpy((*d_grp)[i].comment, map[i+start_idx].comment); sid_split_rid(&map[i+start_idx].sid, &(*d_grp)[i].rid); - (*d_grp)[i].attr=type; + (*d_grp)[i].attr=SID_NAME_DOM_GRP; } SAFE_FREE(map); *p_num_entries = num_entries; - DEBUG(10,("get_group_entries: returning %d entries\n", *p_num_entries)); + DEBUG(10,("get_group_domain_entries: returning %d entries\n", + *p_num_entries)); return NT_STATUS_OK; } /******************************************************************* - Wrapper for enuemrating domain groups + Wrapper for enumerating local groups ******************************************************************/ -static NTSTATUS get_group_domain_entries( TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, - DOM_SID *sid, uint32 start_idx, - uint32 *p_num_entries, uint32 max_entries ) +static NTSTATUS get_alias_entries( TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, + const DOM_SID *sid, uint32 start_idx, + uint32 *p_num_entries, uint32 max_entries ) { - return get_group_entries( SID_NAME_DOM_GRP, ctx, d_grp, sid, start_idx, - p_num_entries, max_entries ); -} + struct acct_info *info; + int i; + BOOL res; -/******************************************************************* - Wrapper for enumerating local groups - ******************************************************************/ + become_root(); + res = pdb_enum_aliases(sid, start_idx, max_entries, + p_num_entries, &info); + unbecome_root(); -static NTSTATUS get_group_alias_entries( TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, - DOM_SID *sid, uint32 start_idx, - uint32 *p_num_entries, uint32 max_entries) -{ - if ( sid_equal(sid, &global_sid_Builtin) ) { - return get_group_entries( SID_NAME_WKN_GRP, ctx, d_grp, - sid, start_idx, p_num_entries, max_entries ); - } - else if ( sid_equal(sid, get_global_sam_sid()) ) { - return get_group_entries( SID_NAME_ALIAS, ctx, d_grp, - sid, start_idx, p_num_entries, max_entries ); + if (!res) + return NT_STATUS_ACCESS_DENIED; + + if (*p_num_entries == 0) + return NT_STATUS_OK; + + *d_grp = talloc(ctx, sizeof(DOMAIN_GRP) * (*p_num_entries)); + + if (*d_grp == NULL) { + SAFE_FREE(info); + return NT_STATUS_NO_MEMORY; } - /* can't do anything with this SID */ - - *p_num_entries = 0; + for (i=0; i<*p_num_entries; i++) { + fstrcpy((*d_grp)[i].name, info[i].acct_name); + fstrcpy((*d_grp)[i].comment, info[i].acct_desc); + (*d_grp)[i].rid = info[i].rid; + (*d_grp)[i].attr = SID_NAME_ALIAS; + } + SAFE_FREE(info); return NT_STATUS_OK; } @@ -1025,9 +1032,9 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S sid_to_string(sid_str, &sid); DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", sid_str)); - status = get_group_alias_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, - &num_entries, MAX_SAM_ENTRIES); - if (NT_STATUS_IS_ERR(status)) return status; + status = get_alias_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, + &num_entries, MAX_SAM_ENTRIES); + if (!NT_STATUS_IS_OK(status)) return status; make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp); @@ -1244,7 +1251,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_R_QUERY_ALIASINFO *r_u) { DOM_SID sid; - GROUP_MAP map; + struct acct_info info; uint32 acc_granted; BOOL ret; @@ -1259,12 +1266,8 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM return r_u->status; } - if (!sid_check_is_in_our_domain(&sid) && - !sid_check_is_in_builtin(&sid)) - return NT_STATUS_OBJECT_TYPE_MISMATCH; - become_root(); - ret = pdb_getgrsid(&map, sid); + ret = pdb_get_aliasinfo(&sid, &info); unbecome_root(); if ( !ret ) @@ -1274,12 +1277,13 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM case 1: r_u->ptr = 1; r_u->ctr.switch_value1 = 1; - init_samr_alias_info1(&r_u->ctr.alias.info1, map.nt_name, 1, map.comment); + init_samr_alias_info1(&r_u->ctr.alias.info1, + info.acct_name, 1, info.acct_desc); break; case 3: r_u->ptr = 1; r_u->ctr.switch_value1 = 3; - init_samr_alias_info3(&r_u->ctr.alias.info3, map.comment); + init_samr_alias_info3(&r_u->ctr.alias.info3, info.acct_desc); break; default: return NT_STATUS_INVALID_INFO_CLASS; @@ -3191,15 +3195,11 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ { int i; - GROUP_MAP map; int num_sids = 0; DOM_SID2 *sid; DOM_SID *sids=NULL; DOM_SID alias_sid; - DOM_SID als_sid; - uint32 alias_rid; - fstring alias_sid_str; uint32 acc_granted; @@ -3211,35 +3211,12 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_GET_MEMBERS, "_samr_query_aliasmem"))) { return r_u->status; } - - sid_copy(&als_sid, &alias_sid); - sid_to_string(alias_sid_str, &alias_sid); - sid_split_rid(&alias_sid, &alias_rid); - DEBUG(10, ("sid is %s\n", alias_sid_str)); + DEBUG(10, ("sid is %s\n", sid_string_static(&alias_sid))); - if (sid_equal(&alias_sid, &global_sid_Builtin)) { - DEBUG(10, ("lookup on Builtin SID (S-1-5-32)\n")); - if(!get_builtin_group_from_sid(&als_sid, &map)) - return NT_STATUS_NO_SUCH_ALIAS; - } else { - if (sid_equal(&alias_sid, get_global_sam_sid())) { - DEBUG(10, ("lookup on Server SID\n")); - if(!get_local_group_from_sid(&als_sid, &map)) { - fstring alias_sid_string; - DEBUG(10, ("Alias %s not found\n", sid_to_string(alias_sid_string, &als_sid))); - return NT_STATUS_NO_SUCH_ALIAS; - } - } - } - - if (!get_sid_list_of_group(map.gid, &sids, &num_sids)) { - fstring alias_sid_string; - DEBUG(10, ("Alias %s found, but member list unavailable\n", sid_to_string(alias_sid_string, &als_sid))); + if (!pdb_enum_aliasmem(&alias_sid, &sids, &num_sids)) return NT_STATUS_NO_SUCH_ALIAS; - } - DEBUG(10, ("sid is %s\n", alias_sid_str)); sid = (DOM_SID2 *)talloc_zero(p->mem_ctx, sizeof(DOM_SID2) * num_sids); if (num_sids!=0 && sid == NULL) { SAFE_FREE(sids); @@ -3250,7 +3227,6 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ init_dom_sid2(&sid[i], &sids[i]); } - DEBUG(10, ("sid is %s\n", alias_sid_str)); init_samr_r_query_aliasmem(r_u, num_sids, sid, NT_STATUS_OK); SAFE_FREE(sids); @@ -3258,20 +3234,89 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ return NT_STATUS_OK; } +static void add_uid_to_array_unique(uid_t uid, uid_t **uids, int *num) +{ + int i; + + if ((*num) >= groups_max()) + return; + + for (i=0; i<*num; i++) { + if ((*uids)[i] == uid) + return; + } + + *uids = Realloc(*uids, (*num+1) * sizeof(uid_t)); + + if (*uids == NULL) + return; + + (*uids)[*num] = uid; + *num += 1; +} + + +static BOOL get_memberuids(gid_t gid, uid_t **uids, int *num) +{ + struct group *grp; + char **gr; + struct sys_pwent *userlist, *user; + + *uids = NULL; + *num = 0; + + /* We only look at our own sam, so don't care about imported stuff */ + + winbind_off(); + + if ((grp = getgrgid(gid)) == NULL) { + winbind_on(); + return False; + } + + /* Primary group members */ + + userlist = getpwent_list(); + + for (user = userlist; user != NULL; user = user->next) { + if (user->pw_gid != gid) + continue; + add_uid_to_array_unique(user->pw_uid, uids, num); + } + + pwent_free(userlist); + + /* Secondary group members */ + + gr = grp->gr_mem; + while ((*gr != NULL) && ((*gr)[0] != '\0')) { + struct passwd *pw = getpwnam(*gr); + + if (pw == NULL) + continue; + + add_uid_to_array_unique(pw->pw_uid, uids, num); + + gr += 1; + } + + winbind_on(); + + return True; +} + /********************************************************************* _samr_query_groupmem *********************************************************************/ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_QUERY_GROUPMEM *r_u) { - int num_sids = 0; - int final_num_sids = 0; - int i; + int final_num_rids, i; DOM_SID group_sid; fstring group_sid_str; - DOM_SID *sids=NULL; - - GROUP_MAP map; + uid_t *uids; + int num; + gid_t gid; uint32 *rid=NULL; uint32 *attr=NULL; @@ -3296,35 +3341,46 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ DEBUG(10, ("lookup on Domain SID\n")); - if(!get_domain_group_from_sid(group_sid, &map)) + if (!NT_STATUS_IS_OK(sid_to_gid(&group_sid, &gid))) return NT_STATUS_NO_SUCH_GROUP; - if(!get_sid_list_of_group(map.gid, &sids, &num_sids)) + if(!get_memberuids(gid, &uids, &num)) return NT_STATUS_NO_SUCH_GROUP; - rid=talloc_zero(p->mem_ctx, sizeof(uint32)*num_sids); - attr=talloc_zero(p->mem_ctx, sizeof(uint32)*num_sids); + rid=talloc_zero(p->mem_ctx, sizeof(uint32)*num); + attr=talloc_zero(p->mem_ctx, sizeof(uint32)*num); - if (num_sids!=0 && (rid==NULL || attr==NULL)) + if (num!=0 && (rid==NULL || attr==NULL)) return NT_STATUS_NO_MEMORY; - for (i=0; istatus; } - sid_to_string(alias_sid_str, &alias_sid); - DEBUG(10, ("sid is %s\n", alias_sid_str)); - - if (sid_compare(&alias_sid, get_global_sam_sid())>0) { - DEBUG(10, ("adding member on Server SID\n")); - if(!get_local_group_from_sid(&alias_sid, &map)) - return NT_STATUS_NO_SUCH_ALIAS; - - } else { - if (sid_compare(&alias_sid, &global_sid_Builtin)>0) { - DEBUG(10, ("adding member on BUILTIN SID\n")); - if( !get_builtin_group_from_sid(&alias_sid, &map)) - return NT_STATUS_NO_SUCH_ALIAS; - - } else - return NT_STATUS_NO_SUCH_ALIAS; - } + DEBUG(10, ("sid is %s\n", sid_string_static(&alias_sid))); - ret = pdb_init_sam(&sam_user); - if (!NT_STATUS_IS_OK(ret)) - return ret; - - check = pdb_getsampwsid(sam_user, &q_u->sid.sid); - - if (check != True) { - pdb_free_sam(&sam_user); - return NT_STATUS_NO_SUCH_USER; - } - - /* check a real user exist before we run the script to add a user to a group */ - if (!NT_STATUS_IS_OK(sid_to_uid(pdb_get_user_sid(sam_user), &uid))) { - pdb_free_sam(&sam_user); - return NT_STATUS_NO_SUCH_USER; - } - - pdb_free_sam(&sam_user); - - if ((pwd=getpwuid_alloc(uid)) == NULL) { - return NT_STATUS_NO_SUCH_USER; - } - - if ((grp=getgrgid(map.gid)) == NULL) { - passwd_free(&pwd); - return NT_STATUS_NO_SUCH_ALIAS; - } - - /* we need to copy the name otherwise it's overloaded in user_in_group_list */ - fstrcpy(grp_name, grp->gr_name); - - /* if the user is already in the group */ - if(user_in_unix_group_list(pwd->pw_name, grp_name)) { - passwd_free(&pwd); - return NT_STATUS_MEMBER_IN_ALIAS; - } - - /* - * ok, the group exist, the user exist, the user is not in the group, - * we can (finally) add it to the group ! - */ - smb_add_user_group(grp_name, pwd->pw_name); - - /* check if the user has been added then ... */ - if(!user_in_unix_group_list(pwd->pw_name, grp_name)) { - passwd_free(&pwd); - return NT_STATUS_MEMBER_NOT_IN_ALIAS; /* don't know what to reply else */ - } + if (!pdb_add_aliasmem(&alias_sid, &q_u->sid.sid)) + return NT_STATUS_ACCESS_DENIED; - passwd_free(&pwd); return NT_STATUS_OK; } @@ -3433,11 +3417,6 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DEL_ALIASMEM *r_u) { DOM_SID alias_sid; - fstring alias_sid_str; - struct group *grp; - fstring grp_name; - GROUP_MAP map; - SAM_ACCOUNT *sam_pass=NULL; uint32 acc_granted; /* Find the policy handle. Open a policy on it. */ @@ -3448,47 +3427,12 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE return r_u->status; } - sid_to_string(alias_sid_str, &alias_sid); - DEBUG(10, ("_samr_del_aliasmem:sid is %s\n", alias_sid_str)); - - if (!sid_check_is_in_our_domain(&alias_sid) && - !sid_check_is_in_builtin(&alias_sid)) { - DEBUG(10, ("_samr_del_aliasmem:invalid alias group\n")); - return NT_STATUS_NO_SUCH_ALIAS; - } - - if( !get_local_group_from_sid(&alias_sid, &map)) - return NT_STATUS_NO_SUCH_ALIAS; - - if ((grp=getgrgid(map.gid)) == NULL) - return NT_STATUS_NO_SUCH_ALIAS; - - /* we need to copy the name otherwise it's overloaded in user_in_unix_group_list */ - fstrcpy(grp_name, grp->gr_name); - - /* check if the user exists before trying to remove it from the group */ - pdb_init_sam(&sam_pass); - if(!pdb_getsampwsid(sam_pass, &q_u->sid.sid)) { - DEBUG(5,("_samr_del_aliasmem:User %s doesn't exist.\n", pdb_get_username(sam_pass))); - pdb_free_sam(&sam_pass); - return NT_STATUS_NO_SUCH_USER; - } - - /* if the user is not in the group */ - if(!user_in_unix_group_list(pdb_get_username(sam_pass), grp_name)) { - pdb_free_sam(&sam_pass); - return NT_STATUS_MEMBER_NOT_IN_ALIAS; - } - - smb_delete_user_group(grp_name, pdb_get_username(sam_pass)); - - /* check if the user has been removed then ... */ - if(user_in_unix_group_list(pdb_get_username(sam_pass), grp_name)) { - pdb_free_sam(&sam_pass); - return NT_STATUS_MEMBER_NOT_IN_ALIAS; /* don't know what to reply else */ - } + DEBUG(10, ("_samr_del_aliasmem:sid is %s\n", + sid_string_static(&alias_sid))); - pdb_free_sam(&sam_pass); + if (!pdb_del_aliasmem(&alias_sid, &q_u->sid.sid)) + return NT_STATUS_ACCESS_DENIED; + return NT_STATUS_OK; } @@ -3815,12 +3759,6 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, SAMR_R_DELETE_DOM_ALIAS *r_u) { DOM_SID alias_sid; - DOM_SID dom_sid; - uint32 alias_rid; - fstring alias_sid_str; - gid_t gid; - struct group *grp; - GROUP_MAP map; uint32 acc_granted; DEBUG(5, ("_samr_delete_dom_alias: %d\n", __LINE__)); @@ -3832,38 +3770,18 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_alias"))) { return r_u->status; } - - sid_copy(&dom_sid, &alias_sid); - sid_to_string(alias_sid_str, &dom_sid); - sid_split_rid(&dom_sid, &alias_rid); - DEBUG(10, ("sid is %s\n", alias_sid_str)); + DEBUG(10, ("sid is %s\n", sid_string_static(&alias_sid))); - /* we check if it's our SID before deleting */ - if (!sid_equal(&dom_sid, get_global_sam_sid())) + if (!sid_check_is_in_our_domain(&alias_sid)) return NT_STATUS_NO_SUCH_ALIAS; - + DEBUG(10, ("lookup on Local SID\n")); - if(!get_local_group_from_sid(&alias_sid, &map)) - return NT_STATUS_NO_SUCH_ALIAS; - - gid=map.gid; - - /* check if group really exists */ - if ( (grp=getgrgid(gid)) == NULL) - return NT_STATUS_NO_SUCH_ALIAS; - - /* we can delete the UNIX group */ - smb_delete_group(grp->gr_name); - - /* check if the group has been successfully deleted */ - if ( (grp=getgrgid(gid)) != NULL) + /* Have passdb delete the alias */ + if (!pdb_delete_alias(&alias_sid)) return NT_STATUS_ACCESS_DENIED; - /* don't check if we removed it as it could be an un-mapped group */ - pdb_delete_group_mapping_entry(alias_sid); - if (!close_policy_hnd(p, &q_u->alias_pol)) return NT_STATUS_OBJECT_NAME_INVALID; @@ -3941,7 +3859,6 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S DOM_SID dom_sid; DOM_SID info_sid; fstring name; - fstring sid_string; struct group *grp; struct samr_info *info; uint32 acc_granted; @@ -3962,26 +3879,18 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S unistr2_to_ascii(name, &q_u->uni_acct_desc, sizeof(name)-1); - /* check if group already exists */ - if ( (grp=getgrnam(name)) != NULL) - return NT_STATUS_ALIAS_EXISTS; - - /* we can create the UNIX group */ - if (smb_create_group(name, &gid) != 0) - return NT_STATUS_ACCESS_DENIED; - - /* check if the group has been successfully created */ - if ((grp=getgrgid(gid)) == NULL) + /* Have passdb create the alias */ + if (!pdb_create_alias(name, &r_u->rid)) return NT_STATUS_ACCESS_DENIED; - r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); - sid_copy(&info_sid, get_global_sam_sid()); sid_append_rid(&info_sid, r_u->rid); - sid_to_string(sid_string, &info_sid); - /* add the group to the mapping table */ - if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_ALIAS, name, NULL)) + if (!NT_STATUS_IS_OK(sid_to_gid(&info_sid, &gid))) + return NT_STATUS_ACCESS_DENIED; + + /* check if the group has been successfully created */ + if ((grp=getgrgid(gid)) == NULL) return NT_STATUS_ACCESS_DENIED; if ((info = get_samr_info_by_sid(&info_sid)) == NULL) @@ -4006,7 +3915,8 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM DOM_SID group_sid; GROUP_MAP map; DOM_SID *sids=NULL; - int num_sids=0; + uid_t *uids; + int num=0; GROUP_INFO_CTR *ctr; uint32 acc_granted; BOOL ret; @@ -4031,9 +3941,10 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM switch (q_u->switch_level) { case 1: ctr->switch_value1 = 1; - if(!get_sid_list_of_group(map.gid, &sids, &num_sids)) + if(!get_memberuids(map.gid, &uids, &num)) return NT_STATUS_NO_SUCH_GROUP; - init_samr_group_info1(&ctr->group.info1, map.nt_name, map.comment, num_sids); + SAFE_FREE(uids); + init_samr_group_info1(&ctr->group.info1, map.nt_name, map.comment, num); SAFE_FREE(sids); break; case 3: @@ -4105,7 +4016,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_SET_ALIASINFO *r_u) { DOM_SID group_sid; - GROUP_MAP map; + struct acct_info info; ALIAS_INFO_CTR *ctr; uint32 acc_granted; @@ -4116,22 +4027,20 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ return r_u->status; } - if (!get_local_group_from_sid(&group_sid, &map) && - !get_builtin_group_from_sid(&group_sid, &map)) - return NT_STATUS_NO_SUCH_GROUP; - ctr=&q_u->ctr; switch (ctr->switch_value1) { case 3: - unistr2_to_ascii(map.comment, &(ctr->alias.info3.uni_acct_desc), sizeof(map.comment)-1); + unistr2_to_ascii(info.acct_desc, + &(ctr->alias.info3.uni_acct_desc), + sizeof(info.acct_desc)-1); break; default: return NT_STATUS_INVALID_INFO_CLASS; } - if(!pdb_update_group_mapping_entry(&map)) { - return NT_STATUS_NO_SUCH_GROUP; + if(!pdb_set_aliasinfo(&group_sid, &info)) { + return NT_STATUS_ACCESS_DENIED; } return NT_STATUS_OK; -- cgit From 69a91df4ed4fc8a8d2105d098e4572e6c0da5ebb Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 10 Apr 2004 16:09:48 +0000 Subject: r145: pdb_create_alias now returns NTSTATUS. More of this to follow. Volker (This used to be commit 6e18bed17093e0b1792f68817096e64e0e841f26) --- source3/rpc_server/srv_samr_nt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2e5fe295ec..f48a334fff 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3863,6 +3863,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S struct samr_info *info; uint32 acc_granted; gid_t gid; + NTSTATUS result; /* Find the policy handle. Open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid, &acc_granted)) @@ -3880,8 +3881,10 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S unistr2_to_ascii(name, &q_u->uni_acct_desc, sizeof(name)-1); /* Have passdb create the alias */ - if (!pdb_create_alias(name, &r_u->rid)) - return NT_STATUS_ACCESS_DENIED; + result = pdb_create_alias(name, &r_u->rid); + + if (!NT_STATUS_IS_OK(result)) + return result; sid_copy(&info_sid, get_global_sam_sid()); sid_append_rid(&info_sid, r_u->rid); -- cgit From 8ad3d8c9b065f3a2040beff801bdc9dceac868a8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 13 Apr 2004 14:39:48 +0000 Subject: r196: merging struct uuid from trunk (This used to be commit 911a28361b9d8dd50597627f245ebfb57c6294fb) --- source3/rpc_server/srv_lsa_nt.c | 9 ++++---- source3/rpc_server/srv_netlog.c | 41 ++++++++++++++++++++++++++++++++++++- source3/rpc_server/srv_netlog_nt.c | 17 +++++++++++++++ source3/rpc_server/srv_pipe.c | 4 ++-- source3/rpc_server/srv_samr_nt.c | 4 ++-- source3/rpc_server/srv_spoolss_nt.c | 7 ++++--- 6 files changed, 69 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index de4fdceba7..3878734c6d 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -6,7 +6,7 @@ * Copyright (C) Paul Ashton 1997, * Copyright (C) Jeremy Allison 2001, * Copyright (C) Rafal Szczesniak 2002, - * Copyright (C) Jim McDonough 2002. + * Copyright (C) Jim McDonough 2002, * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -350,7 +350,7 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, const char *dns_name, const char *forest_name, - GUID *dom_guid, DOM_SID *dom_sid) + struct uuid *dom_guid, DOM_SID *dom_sid) { if (nb_name && *nb_name) { init_unistr2(&r_l->uni_nb_dom_name, nb_name, UNI_FLAGS_NONE); @@ -375,7 +375,7 @@ static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, /* how do we init the guid ? probably should write an init fn */ if (dom_guid) { - memcpy(&r_l->dom_guid, dom_guid, sizeof(GUID)); + memcpy(&r_l->dom_guid, dom_guid, sizeof(struct uuid)); } if (dom_sid) { @@ -1105,7 +1105,6 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u /* check if the privilege is already there */ if (check_priv_in_privilege(map.priv_set, *luid_attr)){ destroy_privilege(&map.priv_set); - return NT_STATUS_NO_SUCH_PRIVILEGE; } add_privilege(map.priv_set, *luid_attr); @@ -1240,7 +1239,7 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I char *dns_name = NULL; char *forest_name = NULL; DOM_SID *sid = NULL; - GUID guid; + struct uuid guid; fstring dnsdomname; ZERO_STRUCT(guid); diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 9c10d86379..f06a2002e3 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -317,6 +317,42 @@ static BOOL api_net_logon_ctrl(pipes_struct *p) return True; } +/************************************************************************* + api_ds_enum_dom_trusts: + *************************************************************************/ + +#if 0 /* JERRY */ +static BOOL api_ds_enum_dom_trusts(pipes_struct *p) +{ + DS_Q_ENUM_DOM_TRUSTS q_u; + DS_R_ENUM_DOM_TRUSTS r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + DEBUG(6,("api_ds_enum_dom_trusts\n")); + + if ( !ds_io_q_enum_domain_trusts("", data, 0, &q_u) ) { + DEBUG(0,("api_ds_enum_domain_trusts: Failed to unmarshall DS_Q_ENUM_DOM_TRUSTS.\n")); + return False; + } + + r_u.status = _ds_enum_dom_trusts(p, &q_u, &r_u); + + if ( !ds_io_r_enum_domain_trusts("", rdata, 0, &r_u) ) { + DEBUG(0,("api_ds_enum_domain_trusts: Failed to marshall DS_R_ENUM_DOM_TRUSTS.\n")); + return False; + } + + DEBUG(6,("api_ds_enum_dom_trusts\n")); + + return True; +} +#endif /* JERRY */ + /******************************************************************* array of \PIPE\NETLOGON operations ********************************************************************/ @@ -330,7 +366,10 @@ static struct api_struct api_net_cmds [] = { "NET_SAMLOGOFF" , NET_SAMLOGOFF , api_net_sam_logoff }, { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 }, { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, - { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl } + { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl }, +#if 0 /* JERRY */ + { "DS_ENUM_DOM_TRUSTS", DS_ENUM_DOM_TRUSTS, api_ds_enum_dom_trusts } +#endif /* JERRY */ }; void netlog_get_pipe_fns( struct api_struct **fns, int *n_fns ) diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index e3f687be13..be8eda82c9 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -775,4 +775,21 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return status; } +/************************************************************************* + _ds_enum_dom_trusts + *************************************************************************/ +#if 0 /* JERRY -- not correct */ +NTSTATUS _ds_enum_dom_trusts(pipes_struct *p, DS_Q_ENUM_DOM_TRUSTS *q_u, + DS_R_ENUM_DOM_TRUSTS *r_u) +{ + NTSTATUS status = NT_STATUS_OK; + /* TODO: According to MSDN, the can only be executed against a + DC or domain member running Windows 2000 or later. Need + to test against a standalone 2k server and see what it + does. A windows 2000 DC includes its own domain in the + list. --jerry */ + + return status; +} +#endif /* JERRY */ diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 8337c4e3c7..ad7c544b68 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -737,9 +737,9 @@ BOOL check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, { if ( strequal(pipe_names[i].client_pipe, pname) && (abstract->version == pipe_names[i].abstr_syntax.version) - && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(RPC_UUID)) == 0) + && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(struct uuid)) == 0) && (transfer->version == pipe_names[i].trans_syntax.version) - && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(RPC_UUID)) == 0) ) + && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(struct uuid)) == 0) ) { struct api_struct *fns = NULL; int n_fns = 0; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f48a334fff..a8402ab801 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -7,8 +7,8 @@ * Copyright (C) Marc Jacobsen 1999, * Copyright (C) Jeremy Allison 2001-2002, * Copyright (C) Jean François Micouleau 1998-2001, - * Copyright (C) Jim McDonough 2002. - * Copyright (C) Gerald (Jerry) Carter 2003. + * Copyright (C) Jim McDonough 2002, + * Copyright (C) Gerald (Jerry) Carter 2003, * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c971ff3631..3b1bb5ede5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3,7 +3,7 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, - * Copyright (C) Jean François Micouleau 1998-2000, + * Copyright (C) Jean François Micouleau 1998-2000, * Copyright (C) Jeremy Allison 2001-2002, * Copyright (C) Gerald Carter 2000-2003, * Copyright (C) Tim Potter 2001-2002. @@ -4283,10 +4283,11 @@ static BOOL construct_printer_info_5(Printer_entry *print_hnd, PRINTER_INFO_5 *p static BOOL construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *printer, int snum) { char *guid_str = NULL; - GUID guid; + UUID_FLAT guid; if (is_printer_published(print_hnd, snum, &guid)) { - asprintf(&guid_str, "{%s}", smb_uuid_string_static(guid)); + asprintf(&guid_str, "{%s}", + smb_uuid_string_static(smb_uuid_unpack_static(guid))); strupper_m(guid_str); init_unistr(&printer->guid, guid_str); printer->action = SPOOL_DS_PUBLISH; -- cgit From 4c34b09a19282295704b0d36dfd570edaf1a8e11 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 15 Apr 2004 09:07:32 +0000 Subject: r229: Don't list domain groups from BUILTIN. Volker (This used to be commit b4429d97439e511d40901f809e3923945cb52221) --- source3/rpc_server/srv_samr_nt.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a8402ab801..eca0913c1c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -302,6 +302,13 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) return NT_STATUS_OK; } + if (sid_equal(sid, &global_sid_Builtin)) { + /* No domain groups for now in the BUILTIN domain */ + info->disp_info.num_group_account=0; + info->disp_info.disp_group_info=NULL; + info->disp_info.group_dbloaded=True; + return NT_STATUS_OK; + } become_root(); ret = pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED); -- cgit From 35016d020182f8c1e282271b722ed23df6d2660e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 15 Apr 2004 15:59:59 +0000 Subject: r238: Fix memleak (This used to be commit fe7daa3b8a080a9e39ff055177b54f476fce2c32) --- source3/rpc_server/srv_pipe_hnd.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 514c22d471..44fec78c50 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1114,6 +1114,9 @@ static BOOL close_internal_rpc_pipe_hnd(void *np_conn) /* Free the handles database. */ close_policy_by_pipe(p); + if (p->session_key.data != NULL) + data_blob_free(&p->session_key); + delete_nt_token(&p->pipe_user.nt_user_token); SAFE_FREE(p->pipe_user.groups); -- cgit From c1b7b9662de0c03bd33879f23754a49de2a5209a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 4 May 2004 20:09:24 +0000 Subject: r473: Fix for Microsoft hotfix MS04-011 password change breakage. Jeremy. (This used to be commit 038cae8a377b75d70a099f03cb1b8ae9b50e7613) --- source3/rpc_server/srv_pipe.c | 78 ++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 26 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index ad7c544b68..076f800a40 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -87,6 +87,7 @@ BOOL create_next_pdu(pipes_struct *p) RPC_HDR_RESP hdr_resp; BOOL auth_verify = ((p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SIGN) != 0); BOOL auth_seal = ((p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SEAL) != 0); + uint32 ss_padding_len = 0; uint32 data_len; uint32 data_space_available; uint32 data_len_left; @@ -109,21 +110,22 @@ BOOL create_next_pdu(pipes_struct *p) p->hdr.pkt_type = RPC_RESPONSE; /* Set up rpc header flags. */ - if (p->out_data.data_sent_length == 0) + if (p->out_data.data_sent_length == 0) { p->hdr.flags = RPC_FLG_FIRST; - else + } else { p->hdr.flags = 0; + } /* * Work out how much we can fit in a single PDU. */ data_space_available = sizeof(p->out_data.current_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN; - if(p->ntlmssp_auth_validated) + if(p->ntlmssp_auth_validated) { data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN); - - if(p->netsec_auth_validated) + } else if(p->netsec_auth_validated) { data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NETSEC_CHK_LEN); + } /* * The amount we send is the minimum of the available @@ -150,16 +152,31 @@ BOOL create_next_pdu(pipes_struct *p) hdr_resp.alloc_hint = data_len_left; + /* + * Work out if this PDU will be the last. + */ + + if(p->out_data.data_sent_length + data_len >= prs_offset(&p->out_data.rdata)) { + p->hdr.flags |= RPC_FLG_LAST; + if ((auth_seal || auth_verify) && (data_len_left % 8)) { + ss_padding_len = 8 - (data_len_left % 8); + DEBUG(10,("create_next_pdu: adding sign/seal padding of %u\n", + ss_padding_len )); + } + } + /* * Set up the header lengths. */ if (p->ntlmssp_auth_validated) { - p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len + - RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN; + p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + + data_len + ss_padding_len + + RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN; p->hdr.auth_len = RPC_AUTH_NTLMSSP_CHK_LEN; } else if (p->netsec_auth_validated) { - p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len + + p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + + data_len + ss_padding_len + RPC_HDR_AUTH_LEN + RPC_AUTH_NETSEC_CHK_LEN; p->hdr.auth_len = RPC_AUTH_NETSEC_CHK_LEN; } else { @@ -167,13 +184,6 @@ BOOL create_next_pdu(pipes_struct *p) p->hdr.auth_len = 0; } - /* - * Work out if this PDU will be the last. - */ - - if(p->out_data.data_sent_length + data_len >= prs_offset(&p->out_data.rdata)) - p->hdr.flags |= RPC_FLG_LAST; - /* * Init the parse struct to point at the outgoing * data. @@ -206,12 +216,26 @@ BOOL create_next_pdu(pipes_struct *p) return False; } + /* Copy the sign/seal padding data. */ + if (ss_padding_len) { + char pad[8]; + memset(pad, '\0', 8); + if (!prs_copy_data_in(&outgoing_pdu, pad, ss_padding_len)) { + DEBUG(0,("create_next_pdu: failed to add %u bytes of pad data.\n", (unsigned int)ss_padding_len)); + prs_mem_free(&outgoing_pdu); + return False; + } + } + if (p->ntlmssp_auth_validated) { + /* + * NTLMSSP processing. Mutually exclusive with Schannel. + */ uint32 crc32 = 0; char *data; DEBUG(5,("create_next_pdu: sign: %s seal: %s data %d auth %d\n", - BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, p->hdr.auth_len)); + BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len + ss_padding_len, p->hdr.auth_len)); /* * Set data to point to where we copied the data into. @@ -220,15 +244,16 @@ BOOL create_next_pdu(pipes_struct *p) data = prs_data_p(&outgoing_pdu) + data_pos; if (auth_seal) { - crc32 = crc32_calc_buffer(data, data_len); - NTLMSSPcalc_p(p, (uchar*)data, data_len); + crc32 = crc32_calc_buffer(data, data_len + ss_padding_len); + NTLMSSPcalc_p(p, (uchar*)data, data_len + ss_padding_len); } if (auth_seal || auth_verify) { RPC_HDR_AUTH auth_info; - init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, auth_info.auth_level, - (auth_verify ? RPC_HDR_AUTH_LEN : 0), (auth_verify ? 1 : 0)); + init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, + auth_seal ? RPC_PIPE_AUTH_SEAL_LEVEL : RPC_PIPE_AUTH_SIGN_LEVEL, + (auth_verify ? ss_padding_len : 0), (auth_verify ? 1 : 0)); if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_AUTH.\n")); prs_mem_free(&outgoing_pdu); @@ -251,9 +276,10 @@ BOOL create_next_pdu(pipes_struct *p) } NTLMSSPcalc_p(p, (uchar*)auth_data, RPC_AUTH_NTLMSSP_CHK_LEN - 4); } - } - - if (p->netsec_auth_validated) { + } else if (p->netsec_auth_validated) { + /* + * Schannel processing. Mutually exclusive with NTLMSSP. + */ int auth_type, auth_level; char *data; RPC_HDR_AUTH auth_info; @@ -267,7 +293,7 @@ BOOL create_next_pdu(pipes_struct *p) get_auth_type_level(p->netsec_auth.auth_flags, &auth_type, &auth_level); init_rpc_hdr_auth(&auth_info, auth_type, auth_level, - RPC_HDR_AUTH_LEN, 1); + ss_padding_len, 1); if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_AUTH.\n")); @@ -281,7 +307,7 @@ BOOL create_next_pdu(pipes_struct *p) netsec_encode(&p->netsec_auth, p->netsec_auth.auth_flags, SENDER_IS_ACCEPTOR, - &verf, data, data_len); + &verf, data, data_len + ss_padding_len); smb_io_rpc_auth_netsec_chk("", &verf, &outgoing_pdu, 0); @@ -292,7 +318,7 @@ BOOL create_next_pdu(pipes_struct *p) * Setup the counts for this PDU. */ - p->out_data.data_sent_length += data_len; + p->out_data.data_sent_length += (data_len + ss_padding_len); p->out_data.current_pdu_len = p->hdr.frag_len; p->out_data.current_pdu_sent = 0; -- cgit From 741545b4978cf638f4ed8ccd533240d51e6cb24b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 4 May 2004 20:16:59 +0000 Subject: r475: Don't add ss padding length to the sent length as this is compared with the actual data to return. Jeremy. (This used to be commit 7f837db6e47af39b4a33e10e745823b19edb3715) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 076f800a40..3a4e085276 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -318,7 +318,7 @@ BOOL create_next_pdu(pipes_struct *p) * Setup the counts for this PDU. */ - p->out_data.data_sent_length += (data_len + ss_padding_len); + p->out_data.data_sent_length += data_len; p->out_data.current_pdu_len = p->hdr.frag_len; p->out_data.current_pdu_sent = 0; -- cgit From 9259481d8626c542eaa3f87b17e346d8ad85e994 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 7 May 2004 08:42:13 +0000 Subject: r545: Handing a NULL blob to base64_encode_data_blob leads to an invalid write of a 0 in base64_encode_data_blob. I don't know what the base64 encoding of a NULL string is, so fix the problematic caller I found. The real fix should go into base64_encode_data_blob. Volker (This used to be commit 55fd1e490efbe91c391c27101166284034cd32ef) --- source3/rpc_server/srv_samr_util.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index dd92e0d90a..417a712036 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -52,7 +52,8 @@ void copy_id20_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_20 *from) old_string = pdb_get_munged_dial(to); mung.length = from->hdr_munged_dial.uni_str_len; mung.data = (uint8 *) from->uni_munged_dial.buffer; - new_string = base64_encode_data_blob(mung); + new_string = (mung.length == 0) ? + NULL : base64_encode_data_blob(mung); DEBUG(10,("INFO_20 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED_NC(old_string,new_string)) pdb_set_munged_dial(to , new_string, PDB_CHANGED); @@ -210,7 +211,8 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) old_string = pdb_get_munged_dial(to); mung.length = from->hdr_munged_dial.uni_str_len; mung.data = (uint8 *) from->uni_munged_dial.buffer; - newstr = base64_encode_data_blob(mung); + newstr = (mung.length == 0) ? + NULL : base64_encode_data_blob(mung); DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); if (STRING_CHANGED_NC(old_string,newstr)) pdb_set_munged_dial(to , newstr, PDB_CHANGED); @@ -439,7 +441,8 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) old_string = pdb_get_munged_dial(to); mung.length = from->hdr_munged_dial.uni_str_len; mung.data = (uint8 *) from->uni_munged_dial.buffer; - newstr = base64_encode_data_blob(mung); + newstr = (mung.length == 0) ? + NULL : base64_encode_data_blob(mung); DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); if (STRING_CHANGED_NC(old_string, newstr)) pdb_set_munged_dial(to , newstr, PDB_CHANGED); -- cgit From 41db2016adc464691ea2c3497aedca55fcf004ed Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 13 May 2004 20:32:21 +0000 Subject: r704: BUG 1315: fix for schannel client connections to server's that don't support 128 bit encryption (This used to be commit 316ba5ad89ddfa445d44d28141c5901fc64aec90) --- source3/rpc_server/srv_pipe.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 3a4e085276..13d894d2d8 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -124,7 +124,7 @@ BOOL create_next_pdu(pipes_struct *p) if(p->ntlmssp_auth_validated) { data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN); } else if(p->netsec_auth_validated) { - data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NETSEC_CHK_LEN); + data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NETSEC_SIGN_OR_SEAL_CHK_LEN); } /* @@ -177,8 +177,8 @@ BOOL create_next_pdu(pipes_struct *p) } else if (p->netsec_auth_validated) { p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len + ss_padding_len + - RPC_HDR_AUTH_LEN + RPC_AUTH_NETSEC_CHK_LEN; - p->hdr.auth_len = RPC_AUTH_NETSEC_CHK_LEN; + RPC_HDR_AUTH_LEN + RPC_AUTH_NETSEC_SIGN_OR_SEAL_CHK_LEN; + p->hdr.auth_len = RPC_AUTH_NETSEC_SIGN_OR_SEAL_CHK_LEN; } else { p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len; p->hdr.auth_len = 0; @@ -309,7 +309,8 @@ BOOL create_next_pdu(pipes_struct *p) SENDER_IS_ACCEPTOR, &verf, data, data_len + ss_padding_len); - smb_io_rpc_auth_netsec_chk("", &verf, &outgoing_pdu, 0); + smb_io_rpc_auth_netsec_chk("", RPC_AUTH_NETSEC_SIGN_OR_SEAL_CHK_LEN, + &verf, &outgoing_pdu, 0); p->netsec_auth.seq_num++; } @@ -1339,7 +1340,7 @@ BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) auth_len = p->hdr.auth_len; - if (auth_len != RPC_AUTH_NETSEC_CHK_LEN) { + if (auth_len != RPC_AUTH_NETSEC_SIGN_OR_SEAL_CHK_LEN) { DEBUG(0,("Incorrect auth_len %d.\n", auth_len )); return False; } @@ -1384,7 +1385,9 @@ BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) return False; } - if(!smb_io_rpc_auth_netsec_chk("", &netsec_chk, rpc_in, 0)) { + if(!smb_io_rpc_auth_netsec_chk("", RPC_AUTH_NETSEC_SIGN_OR_SEAL_CHK_LEN, + &netsec_chk, rpc_in, 0)) + { DEBUG(0,("failed to unmarshal RPC_AUTH_NETSEC_CHK.\n")); return False; } -- cgit From 8c0db1bbc469932694ed877eebecffa3d1948abd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 19 May 2004 21:49:58 +0000 Subject: r786: Memory leak fixes in (mostly) error code paths from kawasa_r@itg.hitachi.co.jp. A couple of mem leak fixes in mainline code paths though :-). Jeremy. (This used to be commit 4695cc95fe576b6da0d0cb0686f208fc306b2646) --- source3/rpc_server/srv_pipe_hnd.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 44fec78c50..ccf571a0e2 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1118,6 +1118,7 @@ static BOOL close_internal_rpc_pipe_hnd(void *np_conn) data_blob_free(&p->session_key); delete_nt_token(&p->pipe_user.nt_user_token); + data_blob_free(&p->session_key); SAFE_FREE(p->pipe_user.groups); DLIST_REMOVE(InternalPipes, p); -- cgit From 52ddd54083e5875c5ef7bd8e1cdd996289004982 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 20 May 2004 18:28:21 +0000 Subject: r801: Fix from "Jianliang Lu" to return correct group types. Jeremy. (This used to be commit d97b9146a137d43278f3125bafe8a453da82f4ce) --- source3/rpc_server/srv_lsa_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 3878734c6d..1d7fdb0e54 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -171,10 +171,12 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, status = lookup_name(dom_name, user, &sid, &name_type); } +#if 0 /* This is not true. */ if (name_type == SID_NAME_WKN_GRP) { /* BUILTIN aliases are still aliases :-) */ name_type = SID_NAME_ALIAS; } +#endif DEBUG(5, ("init_lsa_rid2s: %s\n", status ? "found" : "not found")); -- cgit From 74a81e6ba61ddc9a473b4c7c15fd7aae553b9b8b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 21 May 2004 00:13:16 +0000 Subject: r805: Fix to stop smbd hanging on missing group member from "Jianliang Lu" . Jeremy. (This used to be commit d5fb5ba9df9fc0f9167e76402c59a971f52e1b1f) --- source3/rpc_server/srv_samr_nt.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index eca0913c1c..ea631d7c85 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3295,16 +3295,12 @@ static BOOL get_memberuids(gid_t gid, uid_t **uids, int *num) /* Secondary group members */ - gr = grp->gr_mem; - while ((*gr != NULL) && ((*gr)[0] != '\0')) { + for (gr = grp->gr_mem; (*gr != NULL) && ((*gr)[0] != '\0'); gr += 1) { struct passwd *pw = getpwnam(*gr); if (pw == NULL) continue; - add_uid_to_array_unique(pw->pw_uid, uids, num); - - gr += 1; } winbind_on(); -- cgit From 331d4fc58c9a7dee70f85d3fe03738bd9b43dc36 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 21 May 2004 18:06:27 +0000 Subject: r810: Fix from "Jerome Borsboom" to ensure error status codes don't get overwritten. Jeremy. (This used to be commit c179451b07c2315a667c2ff683cd30c4d224758e) --- source3/rpc_server/srv_lsa_nt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 1d7fdb0e54..b4e29e6748 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -669,12 +669,12 @@ done: /* set up the LSA Lookup SIDs response */ init_lsa_trans_names(p->mem_ctx, ref, names, num_entries, sid, &mapped_count); - if (mapped_count == 0) - r_u->status = NT_STATUS_NONE_MAPPED; - else if (mapped_count != num_entries) - r_u->status = STATUS_SOME_UNMAPPED; - else - r_u->status = NT_STATUS_OK; + if (NT_STATUS_IS_OK(r_u->status)) { + if (mapped_count == 0) + r_u->status = NT_STATUS_NONE_MAPPED; + else if (mapped_count != num_entries) + r_u->status = STATUS_SOME_UNMAPPED; + } init_reply_lookup_sids(r_u, ref, names, mapped_count); return r_u->status; -- cgit From 7ea0be80de25da22abcf1f1c34f646251f7814c0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 26 May 2004 18:27:16 +0000 Subject: r911: Patch from "Jerome Borsboom" , don't overwrite error code. Jeremy. (This used to be commit 735e49ddc3c4485c7b43208345d0e3e2b8960ad4) --- source3/rpc_server/srv_lsa_nt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index b4e29e6748..ff73fd4a95 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -719,12 +719,12 @@ done: /* set up the LSA Lookup RIDs response */ init_lsa_rid2s(ref, rids, num_entries, names, &mapped_count, p->endian); - if (mapped_count == 0) - r_u->status = NT_STATUS_NONE_MAPPED; - else if (mapped_count != num_entries) - r_u->status = STATUS_SOME_UNMAPPED; - else - r_u->status = NT_STATUS_OK; + if (NT_STATUS_IS_OK(r_u->status)) { + if (mapped_count == 0) + r_u->status = NT_STATUS_NONE_MAPPED; + else if (mapped_count != num_entries) + r_u->status = STATUS_SOME_UNMAPPED; + } init_reply_lookup_names(r_u, ref, num_entries, rids, mapped_count); return r_u->status; -- cgit From 7959cba656133840c37d293ffab6831f3097016f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 27 May 2004 15:38:54 +0000 Subject: r925: add changes frpm trunk (r841 and r842) -- enable background queue update process and allow printers to have different sharenames from printernames (This used to be commit 066b9c4276a968788a03709a00d4f672ac032df7) --- source3/rpc_server/srv_spoolss_nt.c | 107 +++++++++++++++++++++++++++--------- 1 file changed, 81 insertions(+), 26 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3b1bb5ede5..a6d47a46c3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -473,9 +473,11 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) { int snum; int n_services=lp_numservices(); - char *aprinter; + char *aprinter, *printername; fstring sname; BOOL found=False; + NT_PRINTER_INFO_LEVEL *printer; + WERROR result; DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename, (unsigned long)strlen(handlename))); @@ -496,31 +498,56 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) aprinter=handlename; } - DEBUGADD(5,("searching for [%s] (len=%lu)\n", aprinter, (unsigned long)strlen(aprinter))); + DEBUGADD(5, ("searching for [%s] (len=%lu)\n", aprinter, (unsigned long)strlen(aprinter))); - /* - * The original code allowed smbd to store a printer name that - * was different from the share name. This is not possible - * anymore, so I've simplified this loop greatly. Here - * we are just verifying that the printer name is a valid - * printer service defined in smb.conf - * --jerry [Fri Feb 15 11:17:46 CST 2002] - */ + /* have to search on sharename and PRINTER_INFO2->printername */ for (snum=0; snuminfo_2->printername[2], '\\')) ) { + DEBUG(0,("set_printer_hnd_name: info2->printername in wrong format! [%s]\n", + printer->info_2->printername)); + free_a_printer( &printer, 2); + continue; + } + + printername++; + + if ( strequal(printername, aprinter) ) { + found = True; + } + + DEBUGADD(10, ("printername: %s\n", printername)); + + free_a_printer( &printer, 2); + + if ( found ) + break; } @@ -5854,14 +5881,28 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) { + fstring printername; + const char *p; + DEBUG(5,("check_printer_ok: servername=%s printername=%s sharename=%s portname=%s drivername=%s comment=%s location=%s\n", info->servername, info->printername, info->sharename, info->portname, info->drivername, info->comment, info->location)); /* we force some elements to "correct" values */ slprintf(info->servername, sizeof(info->servername)-1, "\\\\%s", get_called_name()); fstrcpy(info->sharename, lp_servicename(snum)); + + /* make sure printername is in \\server\printername format */ + + fstrcpy( printername, info->printername ); + p = printername; + if ( printername[0] == '\\' && printername[1] == '\\' ) { + if ( (p = strchr_m( &printername[2], '\\' )) != NULL ) + p++; + } + slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s", - get_called_name(), info->sharename); + get_called_name(), p ); + info->attributes = PRINTER_ATTRIBUTE_SAMBA; @@ -6057,14 +6098,28 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, if (!strequal(printer->info_2->sharename, old_printer->info_2->sharename)) { init_unistr2( &buffer, printer->info_2->sharename, UNI_STR_TERMINATE); - set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "printerName", - REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "shareName", REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); notify_printer_sharename(snum, printer->info_2->sharename); } + if (!strequal(printer->info_2->printername, old_printer->info_2->printername)) { + char *pname; + + if ( (pname = strchr_m( printer->info_2->printername+2, '\\' )) != NULL ) + pname++; + else + pname = printer->info_2->printername; + + + init_unistr2( &buffer, pname, UNI_STR_TERMINATE); + set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "printerName", + REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); + + notify_printer_printername( snum, pname ); + } + if (!strequal(printer->info_2->portname, old_printer->info_2->portname)) { init_unistr2( &buffer, printer->info_2->portname, UNI_STR_TERMINATE); set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "portName", @@ -8750,19 +8805,19 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, { /* save the OID if one was specified */ if ( oid_string ) { - fstrcat( keyname, "\\" ); - fstrcat( keyname, SPOOL_OID_KEY ); + fstrcat( keyname, "\\" ); + fstrcat( keyname, SPOOL_OID_KEY ); - /* - * I'm not checking the status here on purpose. Don't know - * if this is right, but I'm returning the status from the - * previous set_printer_dataex() call. I have no idea if - * this is right. --jerry - */ + /* + * I'm not checking the status here on purpose. Don't know + * if this is right, but I'm returning the status from the + * previous set_printer_dataex() call. I have no idea if + * this is right. --jerry + */ - set_printer_dataex( printer, keyname, valuename, - REG_SZ, (void*)oid_string, strlen(oid_string)+1 ); - } + set_printer_dataex( printer, keyname, valuename, + REG_SZ, (void*)oid_string, strlen(oid_string)+1 ); + } status = mod_a_printer(*printer, 2); } -- cgit From 9dbf2e2419e2ba0f2293b4a7a5971123f34a09ad Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 3 Jun 2004 18:00:22 +0000 Subject: r991: Allow winbindd to use the domain trust account password for setting up an schannel connection. This solves the problem of a Samba DC running winbind, trusting a native mode AD domain, and needing to enumerate AD users via wbinfo -u. (This used to be commit e9f109d1b38e0b0adec9b7e9a907f90a79d297ea) --- source3/rpc_server/srv_netlog.c | 11 ------ source3/rpc_server/srv_netlog_nt.c | 69 +++++++++++++++++++++++++++++++------- 2 files changed, 56 insertions(+), 24 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index f06a2002e3..705b629732 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -227,8 +227,6 @@ static BOOL api_net_trust_dom_list(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - DEBUG(6,("api_net_trust_dom_list: %d\n", __LINE__)); - /* grab the lsa trusted domain list query... */ if(!net_io_q_trust_dom("", &q_u, data, 0)) { DEBUG(0,("api_net_trust_dom_list: Failed to unmarshall NET_Q_TRUST_DOM_LIST.\n")); @@ -244,8 +242,6 @@ static BOOL api_net_trust_dom_list(pipes_struct *p) return False; } - DEBUG(6,("api_net_trust_dom_list: %d\n", __LINE__)); - return True; } @@ -263,7 +259,6 @@ static BOOL api_net_logon_ctrl2(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__)); /* grab the lsa netlogon ctrl2 query... */ if(!net_io_q_logon_ctrl2("", &q_u, data, 0)) { @@ -278,8 +273,6 @@ static BOOL api_net_logon_ctrl2(pipes_struct *p) return False; } - DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__)); - return True; } @@ -297,8 +290,6 @@ static BOOL api_net_logon_ctrl(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - DEBUG(6,("api_net_logon_ctrl: %d\n", __LINE__)); - /* grab the lsa netlogon ctrl query... */ if(!net_io_q_logon_ctrl("", &q_u, data, 0)) { DEBUG(0,("api_net_logon_ctrl: Failed to unmarshall NET_Q_LOGON_CTRL.\n")); @@ -312,8 +303,6 @@ static BOOL api_net_logon_ctrl(pipes_struct *p) return False; } - DEBUG(6,("api_net_logon_ctrl2: %d\n", __LINE__)); - return True; } diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index be8eda82c9..264b7a74a7 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -47,6 +47,7 @@ static void init_net_r_req_chal(NET_R_REQ_CHAL *r_c, #define ERROR_NO_SUCH_DOMAIN 0x54b #define ERROR_NO_LOGON_SERVERS 0x51f +#define NO_ERROR 0x0 /************************************************************************* net_reply_logon_ctrl: @@ -104,25 +105,67 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C uint32 flags = 0x0; uint32 pdc_connection_status = 0x0; uint32 logon_attempts = 0x0; - uint32 tc_status = ERROR_NO_LOGON_SERVERS; - const char *trusted_domain = "test_domain"; + uint32 tc_status; + fstring servername, domain, dc_name, dc_name2; + struct in_addr dc_ip; - DEBUG(0, ("*** net long ctrl2 %d, %d, %d\n", - q_u->function_code, q_u->query_level, q_u->switch_value)); + /* this should be \\global_myname() */ + unistr2_to_ascii(servername, &q_u->uni_server_name, sizeof(servername)); - DEBUG(6,("_net_logon_ctrl2: %d\n", __LINE__)); - - - /* set up the Logon Control2 response */ - init_net_r_logon_ctrl2(r_u, q_u->query_level, - flags, pdc_connection_status, logon_attempts, - tc_status, trusted_domain); + r_u->status = NT_STATUS_OK; + + tc_status = ERROR_NO_SUCH_DOMAIN; + fstrcpy( dc_name, "" ); + + switch ( q_u->function_code ) { + case NETLOGON_CONTROL_TC_QUERY: + unistr2_to_ascii(domain, &q_u->info.info6.domain, sizeof(domain)); + + if ( !is_trusted_domain( domain ) ) + break; + + if ( !get_dc_name( domain, NULL, dc_name2, &dc_ip ) ) { + tc_status = ERROR_NO_LOGON_SERVERS; + break; + } + + fstr_sprintf( dc_name, "\\\\%s", dc_name2 ); + + tc_status = NO_ERROR; + + break; + + case NETLOGON_CONTROL_REDISCOVER: + unistr2_to_ascii(domain, &q_u->info.info6.domain, sizeof(domain)); + + if ( !is_trusted_domain( domain ) ) + break; + + if ( !get_dc_name( domain, NULL, dc_name2, &dc_ip ) ) { + tc_status = ERROR_NO_LOGON_SERVERS; + break; + } + + fstr_sprintf( dc_name, "\\\\%s", dc_name2 ); + + tc_status = NO_ERROR; + + break; + + default: + /* no idea what this should be */ + DEBUG(0,("_net_logon_ctrl2: unimplemented function level [%d]\n", + q_u->function_code)); + } + + /* prepare the response */ + + init_net_r_logon_ctrl2( r_u, q_u->query_level, flags, + pdc_connection_status, logon_attempts, tc_status, dc_name ); if (lp_server_role() == ROLE_DOMAIN_BDC) send_sync_message(); - DEBUG(6,("_net_logon_ctrl2: %d\n", __LINE__)); - return r_u->status; } -- cgit From 2fc57c9a2ce3a266534dd20e6fed4883e052c557 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 8 Jun 2004 16:14:31 +0000 Subject: r1085: Now it's had some proper user testing, merge in the deferred open fix. I'm still doing more testing, but it fixes a behaviour that we've been wrong on ever since the start of Samba. Jeremy. (This used to be commit 894cc6d16296b934c112786eec896846156aee5d) --- source3/rpc_server/srv_srvsvc_nt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 77b9be9966..087c50451e 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1886,8 +1886,9 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename)); unix_convert(filename, conn, NULL, &bad_path, &st); - fsp = open_file_shared(conn, filename, &st, SET_OPEN_MODE(DOS_OPEN_RDONLY), - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, 0, &access_mode, &action); + fsp = open_file_shared(conn, filename, &st, SET_DENY_MODE(DENY_NONE)|SET_OPEN_MODE(DOS_OPEN_RDONLY), + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, INTERNAL_OPEN_ONLY, + &access_mode, &action); if (!fsp) { /* Perhaps it is a directory */ @@ -1990,8 +1991,9 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename)); unix_convert(filename, conn, NULL, &bad_path, &st); - fsp = open_file_shared(conn, filename, &st, SET_OPEN_MODE(DOS_OPEN_RDWR), - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, 0, &access_mode, &action); + fsp = open_file_shared(conn, filename, &st, SET_DENY_MODE(DENY_NONE)|SET_OPEN_MODE(DOS_OPEN_RDWR), + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, INTERNAL_OPEN_ONLY, + &access_mode, &action); if (!fsp) { /* Perhaps it is a directory */ -- cgit From fddef6fc201ed127eaac737e725d1c2dd8c6926e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 11 Jun 2004 17:54:23 +0000 Subject: r1115: Fix for #1427. Catch bad path errors at the right point. Ensure all our pathname parsing is consistent. Jeremy. (This used to be commit 5e8237e306f0bb0e492f10fb6487938132899384) --- source3/rpc_server/srv_srvsvc_nt.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 087c50451e..54cc0d6161 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1886,6 +1886,18 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename)); unix_convert(filename, conn, NULL, &bad_path, &st); + if (bad_path) { + DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", filename)); + r_u->status = WERR_ACCESS_DENIED; + goto error_exit; + } + + if (!check_name(filename,conn)) { + DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", filename)); + r_u->status = WERR_ACCESS_DENIED; + goto error_exit; + } + fsp = open_file_shared(conn, filename, &st, SET_DENY_MODE(DENY_NONE)|SET_OPEN_MODE(DOS_OPEN_RDONLY), (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, INTERNAL_OPEN_ONLY, &access_mode, &action); @@ -1990,6 +2002,18 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename)); unix_convert(filename, conn, NULL, &bad_path, &st); + if (bad_path) { + DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", filename)); + r_u->status = WERR_ACCESS_DENIED; + goto error_exit; + } + + if (!check_name(filename,conn)) { + DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", filename)); + r_u->status = WERR_ACCESS_DENIED; + goto error_exit; + } + fsp = open_file_shared(conn, filename, &st, SET_DENY_MODE(DENY_NONE)|SET_OPEN_MODE(DOS_OPEN_RDWR), (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, INTERNAL_OPEN_ONLY, -- cgit From bd178fd7a24445b6c5b77961c63926e86b2f1715 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 16 Jun 2004 18:05:47 +0000 Subject: r1171: Patch from "Lu, Jianliang" to reset password counts when account is reset. Jeremy. (This used to be commit 6fb64d8b368d1b24768c5817d5deac1e502e694a) --- source3/rpc_server/srv_samr_util.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 417a712036..8cc44074ab 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -240,6 +240,12 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (from->fields_present & ACCT_FLAGS) { DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); if (from->acb_info != pdb_get_acct_ctrl(to)) { + if (!(from->acb_info & ACB_AUTOLOCK) && (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) { + /* We're unlocking a previously locked user. Reset bad password counts. + Patch from Jianliang Lu. */ + pdb_set_bad_password_count(to, 0, PDB_CHANGED); + pdb_set_bad_password_time(to, 0, PDB_CHANGED); + } pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); } } -- cgit From 087868c49916e96cf860577144bc19b799fd720e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 23 Jun 2004 15:46:01 +0000 Subject: r1230: (merges from HP PSA) fixing a couple of caching bugs in the printing code. (a) make sure to clear jobs_changed list when deleting a job and, (b) invalidate the printer handle cache when we get a notification that something has changed on that printer (This used to be commit e3d4fea7808abc77bfdb1a540ab18afe04af5030) --- source3/rpc_server/srv_spoolss_nt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a6d47a46c3..d8c6b5350c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Jean François Micouleau 1998-2000, * Copyright (C) Jeremy Allison 2001-2002, - * Copyright (C) Gerald Carter 2000-2003, + * Copyright (C) Gerald Carter 2000-2004, * Copyright (C) Tim Potter 2001-2002. * * This program is free software; you can redistribute it and/or modify @@ -312,6 +312,7 @@ void invalidate_printer_hnd_cache( char *printername ) for ( p=printers_list; p; p=p->next ) { if ( p->printer_type==PRINTER_HANDLE_IS_PRINTER + && p->printer_info && StrCaseCmp(p->dev.handlename, printername)==0) { DEBUG(10,("invalidating printer_info cache for handl:\n")); @@ -1188,6 +1189,12 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz ZERO_STRUCT( notify ); notify2_unpack_msg( ¬ify, &msg_tv, msg_ptr, msg_len ); msg_ptr += msg_len; + + /* we don't know if the change was from us or not so kill + any cached printer objects */ + + if ( notify.type == PRINTER_NOTIFY_TYPE ) + invalidate_printer_hnd_cache( notify.printer ); /* add to correct list in container */ -- cgit From cf1c4ae9a63b2cc76d40dd5db721520743a26153 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 24 Jun 2004 19:32:50 +0000 Subject: r1241: Fix incorrect type in printer publishing (struct uuid, not UUID_FLAT). Jeremy. (This used to be commit a535a059754730d0a5c2fe64ef14708da2ca6b5c) --- source3/rpc_server/srv_spoolss_nt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d8c6b5350c..06ba543597 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4317,11 +4317,10 @@ static BOOL construct_printer_info_5(Printer_entry *print_hnd, PRINTER_INFO_5 *p static BOOL construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *printer, int snum) { char *guid_str = NULL; - UUID_FLAT guid; + struct uuid guid; if (is_printer_published(print_hnd, snum, &guid)) { - asprintf(&guid_str, "{%s}", - smb_uuid_string_static(smb_uuid_unpack_static(guid))); + asprintf(&guid_str, "{%s}", smb_uuid_string_static(guid)); strupper_m(guid_str); init_unistr(&printer->guid, guid_str); printer->action = SPOOL_DS_PUBLISH; -- cgit From 5f9af6df053f6608fba9a9c17a4945189de38a58 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 5 Jul 2004 09:46:38 +0000 Subject: r1338: A netlogon schannel failure is a normal event with XP clients. They cache the netlogon session key and try to reconnect using that key. This fails with a restarted smbd, we expect another serverauth2. XP falls back immediately. Make the corresponding messages a debug level 3, not 0 to not flood log.smbd. Volker (This used to be commit 4fda68a62fec6c1e95d5176bc5d06bd49da6f358) --- source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_pipe_hnd.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 13d894d2d8..36929150e5 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1397,7 +1397,7 @@ BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) SENDER_IS_INITIATOR, &netsec_chk, prs_data_p(rpc_in)+old_offset, data_len)) { - DEBUG(0,("failed to decode PDU\n")); + DEBUG(3,("failed to decode PDU\n")); return False; } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index ccf571a0e2..7f7a3025a9 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -602,7 +602,7 @@ static BOOL process_request_pdu(pipes_struct *p, prs_struct *rpc_in_p) } if (p->netsec_auth_validated && !api_pipe_netsec_process(p, rpc_in_p)) { - DEBUG(0,("process_request_pdu: failed to do schannel processing.\n")); + DEBUG(3,("process_request_pdu: failed to do schannel processing.\n")); set_incoming_fault(p); return False; } -- cgit From 776aa21df563495379c9666ca4aa478c46125590 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 5 Jul 2004 15:05:45 +0000 Subject: r1340: _samr_lookupsids with more than 32 (MAX_REF_DOMAINS) SIDs failed. This happened because init_dom_ref did not find the domain in question in the list of already mentioned domains. Could others please double-check this? Thanks, Volker (This used to be commit d7b2e41f00491ecf57db70e4da8cf8a3d2469c2b) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index ff73fd4a95..6c3157d5c9 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -101,7 +101,7 @@ static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) if (dom_name != NULL) { for (num = 0; num < ref->num_ref_doms_1; num++) { fstring domname; - rpcstr_pull(domname, &ref->ref_dom[num].uni_dom_name, sizeof(domname), -1, 0); + rpcstr_pull(domname, ref->ref_dom[num].uni_dom_name.buffer, sizeof(domname), -1, 0); if (strequal(domname, dom_name)) return num; } -- cgit From d4ac326d46faab010eeeb24c893ab13bbbf0337e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 8 Jul 2004 21:01:30 +0000 Subject: r1412: Fix password history list in tdbsam. Fix some memory leaks. Add my (C) to a header file that was at least 50% mine :-). Jeremy. (This used to be commit 8ee6060977ec8e65082f3ad09e1e1ccf5b4672ed) --- source3/rpc_server/srv_pipe_hnd.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 7f7a3025a9..c0e6bf8f5e 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1114,9 +1114,6 @@ static BOOL close_internal_rpc_pipe_hnd(void *np_conn) /* Free the handles database. */ close_policy_by_pipe(p); - if (p->session_key.data != NULL) - data_blob_free(&p->session_key); - delete_nt_token(&p->pipe_user.nt_user_token); data_blob_free(&p->session_key); SAFE_FREE(p->pipe_user.groups); -- cgit From cd87b3b972b39003def69671d8a3c6aaf51afd50 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 9 Jul 2004 00:13:55 +0000 Subject: r1414: Memory leak fixes found by valgrind whilst checking the password history code. Error code paths were not freeing up some memory. Jeremy. (This used to be commit 7c4666e56c2c281e023c6483459cb9e8d4787d36) --- source3/rpc_server/srv_pipe.c | 34 +++++++++++++++++----------------- source3/rpc_server/srv_pipe_hnd.c | 16 ++++++++++++++++ 2 files changed, 33 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 36929150e5..2232f0bc24 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -52,28 +52,28 @@ struct dcinfo last_dcinfo; static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) { - unsigned char *hash = p->ntlmssp_hash; - unsigned char index_i = hash[256]; - unsigned char index_j = hash[257]; - int ind; + unsigned char *hash = p->ntlmssp_hash; + unsigned char index_i = hash[256]; + unsigned char index_j = hash[257]; + int ind; - for( ind = 0; ind < len; ind++) { - unsigned char tc; - unsigned char t; + for( ind = 0; ind < len; ind++) { + unsigned char tc; + unsigned char t; - index_i++; - index_j += hash[index_i]; + index_i++; + index_j += hash[index_i]; - tc = hash[index_i]; - hash[index_i] = hash[index_j]; - hash[index_j] = tc; + tc = hash[index_i]; + hash[index_i] = hash[index_j]; + hash[index_j] = tc; - t = hash[index_i] + hash[index_j]; - data[ind] = data[ind] ^ hash[t]; - } + t = hash[index_i] + hash[index_j]; + data[ind] = data[ind] ^ hash[t]; + } - hash[256] = index_i; - hash[257] = index_j; + hash[256] = index_i; + hash[257] = index_j; } /******************************************************************* diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index c0e6bf8f5e..562b55b8f7 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1091,6 +1091,22 @@ BOOL close_rpc_pipe_hnd(smb_np_struct *p) return True; } +/**************************************************************************** + Close all pipes on a connection. +****************************************************************************/ + +void pipe_close_conn(connection_struct *conn) +{ + smb_np_struct *p, *next; + + for (p=Pipes;p;p=next) { + next = p->next; + if (p->conn == conn) { + close_rpc_pipe_hnd(p); + } + } +} + /**************************************************************************** Close an rpc pipe. ****************************************************************************/ -- cgit From ba3aaa96adc078adb2e99f6cd188edc264df236d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 9 Jul 2004 00:59:06 +0000 Subject: r1415: One more memory leak, found by valgrind.. Jeremy. (This used to be commit 8cfaf575e5161e8307b0a53bd44e84c633e85aed) --- source3/rpc_server/srv_pipe.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 2232f0bc24..c5b0b5694d 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -501,6 +501,9 @@ succeeded authentication on named pipe %s, but session key was of incorrect leng * Store the UNIX credential data (uid/gid pair) in the pipe structure. */ + if (p->session_key.data) { + data_blob_free(&p->session_key); + } p->session_key = data_blob(server_info->lm_session_key.data, server_info->lm_session_key.length); p->pipe_user.uid = server_info->uid; -- cgit From aca738698904fe7c8c19202e3b4a080e7939864d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 13 Jul 2004 19:20:37 +0000 Subject: r1484: BUG 1520: work around bug in xp sp2 rc2 where the client sends a fnpcn() request without previously sending a ffpcn(). Return what win2k sp4 does (This used to be commit 3f73d19807cbcbae8e5cfd96fd5c9b4de8c388a3) --- source3/rpc_server/srv_spoolss_nt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 06ba543597..08553bfe65 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3725,6 +3725,12 @@ static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, info->data=NULL; info->count=0; + /* a bug in xp sp2 rc2 causes it to send a fnpcn request without + sending a ffpcn() request first */ + + if ( !option ) + return WERR_BADFID; + for (i=0; icount; i++) { option_type=&(option->ctr.type[i]); @@ -3787,6 +3793,12 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY info->data=NULL; info->count=0; + /* a bug in xp sp2 rc2 causes it to send a fnpcn request without + sending a ffpcn() request first */ + + if ( !option ) + return WERR_BADFID; + get_printer_snum(p, hnd, &snum); for (i=0; icount; i++) { -- cgit From 9d0783bf211dffe58845b36b0669f05bf8bf25b5 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 14 Jul 2004 04:36:01 +0000 Subject: r1492: Rework our random number generation system. On systems with /dev/urandom, this avoids a change to secrets.tdb for every fork(). For other systems, we now only re-seed after a fork, and on startup. No need to do it per-operation. This removes the 'need_reseed' parameter from generate_random_buffer(). Andrew Bartlett (This used to be commit 36741d3cf53a7bd17d361251f2bb50851cdb035f) --- source3/rpc_server/srv_netlog_nt.c | 2 +- source3/rpc_server/srv_pipe.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 264b7a74a7..b5871a7e56 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -276,7 +276,7 @@ NTSTATUS _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u /* create a server challenge for the client */ /* Set these to random values. */ - generate_random_buffer(p->dc.srv_chal.data, 8, False); + generate_random_buffer(p->dc.srv_chal.data, 8); memcpy(p->dc.srv_cred.challenge.data, p->dc.srv_chal.data, 8); diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index c5b0b5694d..bcf5eb533f 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1097,7 +1097,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) RPC_AUTH_VERIFIER auth_verifier; RPC_AUTH_NTLMSSP_CHAL ntlmssp_chal; - generate_random_buffer(p->challenge, 8, False); + generate_random_buffer(p->challenge, 8); /*** Authentication info ***/ -- cgit From de22eab16dad4372a12c2e95f5fdb5fe9a8d162b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 14 Jul 2004 18:29:12 +0000 Subject: r1501: One more check for option != 0. Jeremy. (This used to be commit a6d0452a2d71201309a5abbe3ebc161ae75b17b8) --- source3/rpc_server/srv_spoolss_nt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 08553bfe65..e3c9ff08d9 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -671,7 +671,11 @@ static BOOL is_monitoring_event(Printer_entry *p, uint16 notify_type, * might use the flags though instead of the NOTIFY_OPTION_INFO * --jerry */ - + + if (!option) { + return False; + } + if (p->notify.flags) return is_monitoring_event_flags( p->notify.flags, notify_type, notify_field); -- cgit From 60727acc3b33cb90309a43c10813fadcb94142eb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 10 Aug 2004 14:27:17 +0000 Subject: r1692: first commit :) * add IA64 to the architecture table of printer-drivers * add new "net"-subcommands: net rpc printer migrate {drivers|printers|forms|security|settings|all} [printer] net rpc share migrate {shares|files|all} [share] this is the first part of the migration suite. this will will (once feature-complete) allow to do 1:1 server-cloning in the best possible way by making heavy use of samba's rpc_client-functions. all migration-steps are implemented as rpc/smb-client-calls; net communicates via rpc/smb with two servers at the same time (a remote, source server and a destination server that currently defaults to the local smbd). this allows e. g. printer-driver migration including driverfiles, recursive mirroring of file-shares including file-acls, etc. almost any migration step can be called with a migrate-subcommand to provide more flexibility during a migration process (at the cost of quite some redundancy :) ). "net rpc printer migrate settings" is still in a bad condition (many open questions that hopefully can be adressed soon). "net rpc share migrate security" as an isolated call to just migrate share-ACLs will be added later. Before playing with it, make sure to use a test-server. Migration is a serious business and this tool-set can perfectly overwrite your existing file/print-shares. * along with the migration functions had to make I the following changes: - implement setprinter level 3 client-side - implement net_add_share level 502 client-side - allow security descriptor to be set in setprinterdata level 2 serverside guenther (This used to be commit 8f1716a29b7e85baf738bc14df7dabf03762f723) --- source3/rpc_server/srv_spoolss_nt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e3c9ff08d9..ccff65688a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1972,6 +1972,7 @@ static int get_version_id (char * arch) {"Windows NT R4000", "W32MIPS", 2 }, {"Windows NT Alpha_AXP", "W32ALPHA", 2 }, {"Windows NT PowerPC", "W32PPC", 2 }, + {"Windows IA64", "IA64", 3 }, {NULL, "", -1 } }; @@ -6220,6 +6221,7 @@ WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET DEVMODE_CTR devmode_ctr = q_u->devmode_ctr; SEC_DESC_BUF *secdesc_ctr = q_u->secdesc_ctr; uint32 command = q_u->command; + WERROR result; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); @@ -6233,7 +6235,12 @@ WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET case 0: return control_printer(handle, command, p); case 2: - return update_printer(p, handle, level, info, devmode_ctr.devmode); + result = update_printer(p, handle, level, info, devmode_ctr.devmode); + if (!W_ERROR_IS_OK(result)) + return result; + if (secdesc_ctr) + result = update_printer_sec(handle, level, info, p, secdesc_ctr); + return result; case 3: return update_printer_sec(handle, level, info, p, secdesc_ctr); -- cgit From 1842fde7d10a6faccae1a24ebc67f8452a5a828e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 18 Aug 2004 13:55:58 +0000 Subject: r1885: tighten the cache consistency with the ntprinters.tdb entry an the in memory cache associated with open printer handles; also make sure that register_messages_flags() doesn't overwrite the originally registers flags (This used to be commit 540daf71d8ad189af5dd6d45aa1ce2b3d67da752) --- source3/rpc_server/srv_spoolss_nt.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ccff65688a..5775b3ab49 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -180,7 +180,7 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle) /* Tell the connections db we're no longer interested in * printer notify messages. */ - register_message_flags( False, FLAG_MSG_PRINTING ); + register_message_flags( False, FLAG_MSG_PRINT_NOTIFY ); } smb_connections--; @@ -1194,12 +1194,6 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz notify2_unpack_msg( ¬ify, &msg_tv, msg_ptr, msg_len ); msg_ptr += msg_len; - /* we don't know if the change was from us or not so kill - any cached printer objects */ - - if ( notify.type == PRINTER_NOTIFY_TYPE ) - invalidate_printer_hnd_cache( notify.printer ); - /* add to correct list in container */ notify_msg_ctr_addmsg( &messages, ¬ify ); @@ -1226,6 +1220,22 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz return; } +/******************************************************************** + callback to MSG_PRINTER_CHANGED. When a printer is changed by + one smbd, all of processes must clear their printer cache immediately. + ********************************************************************/ + +void receive_printer_mod_msg(int msg_type, pid_t src, void *buf, size_t len) +{ + fstring printername; + + fstrcpy( printername, buf ); + + DEBUG(10,("receive_printer_mod_msg: Printer change [%s]\n", printername )); + + invalidate_printer_hnd_cache( printername ); +} + /******************************************************************** Send a message to ourself about new driver being installed so we can upgrade the information for each printer bound to this @@ -2641,7 +2651,7 @@ static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message_list); /* Tell the connections db we're now interested in printer * notify messages. */ - register_message_flags( True, FLAG_MSG_PRINTING ); + register_message_flags( True, FLAG_MSG_PRINT_NOTIFY ); } /* -- cgit From b894c95f8d5c300d3a609cec5a211fc8bd956d1c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 20 Aug 2004 22:50:48 +0000 Subject: r1974: Just use a simple linked list for this. Jeremy. (This used to be commit 77bddd40b0a3cb9d2a95b61c098468d3d98e41b0) --- source3/rpc_server/srv_spoolss_nt.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5775b3ab49..3a5bb8452f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -64,14 +64,14 @@ struct table_node { static Printer_entry *printers_list; typedef struct _counter_printer_0 { - ubi_dlNode Next; - ubi_dlNode Prev; + struct _counter_printer_0 *next; + struct _counter_printer_0 *prev; int snum; uint32 counter; } counter_printer_0; -static ubi_dlList counter_list; +static counter_printer_0 *counter_list; static struct cli_state notify_cli; /* print notify back-channel */ static uint32 smb_connections=0; @@ -3949,9 +3949,7 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p count = print_queue_length(snum, &status); /* check if we already have a counter for this printer */ - session_counter = (counter_printer_0 *)ubi_dlFirst(&counter_list); - - for(; session_counter; session_counter = (counter_printer_0 *)ubi_dlNext(session_counter)) { + for(session_counter = counter_list; session_counter; session_counter = session_counter->next) { if (session_counter->snum == snum) break; } @@ -3965,7 +3963,7 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p ZERO_STRUCTP(session_counter); session_counter->snum=snum; session_counter->counter=0; - ubi_dlAddHead( &counter_list, (ubi_dlNode *)session_counter); + DLIST_ADD(counter_list, session_counter); } /* increment it */ -- cgit From 922d51b522acc06d27cfe37177973513f68c132a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 28 Aug 2004 10:12:23 +0000 Subject: r2093: Fix for Bug 1416. This must have been a cut&paste error from add_gid.... Thanks to Jonas Olsson for the bug report & fix. Volker (This used to be commit de0eaf7be7d0c3aaf4e17b63653ca68b4332c982) --- source3/rpc_server/srv_samr_nt.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ea631d7c85..ce6d9dd37e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3245,9 +3245,6 @@ static void add_uid_to_array_unique(uid_t uid, uid_t **uids, int *num) { int i; - if ((*num) >= groups_max()) - return; - for (i=0; i<*num; i++) { if ((*uids)[i] == uid) return; -- cgit From 278f9467f2079044497e3fd4c5358c280f179e41 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 31 Aug 2004 15:11:41 +0000 Subject: r2133: Several fixes: * BUG 1627: fix for NIS compiles on HPUX 11.00, AIX 4.3 and 5.1 patch from Olaf Flebbe . Will need to watch this one in the build farm. * Fix bug found by rwf@loonybin.net where the PRINT_ATTRIBUTE_PUBLISHED was getting reset by attempts to sanitize the defined attributes (PRINTER_ATTRIBUTE_SAMBA) * Resolve name conflict on DEC OSF-5.1 (inspired by patch from Adharsh Praveen ) * Work around parsing error in the print change notify code (not that the alignment bug is still there but reording the entries in the array works around it). * remove duplicate declaration of getprintprocdir from rpcclient. (This used to be commit 7474c6a446037f3ca2546cb6984d800bfc524029) --- source3/rpc_server/srv_spoolss_nt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3a5bb8452f..d50237905a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1026,7 +1026,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) sending_msg_count++; - DEBUG(10,("process_notify2_message: Sending message type [%x] field [%x] for printer [%s]\n", + DEBUG(10,("process_notify2_message: Sending message type [0x%x] field [0x%2x] for printer [%s]\n", msg->type, msg->field, p->dev.handlename)); /* @@ -5573,6 +5573,12 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ return getprinterdriver2_level3(servername, architecture, clientmajorversion, snum, buffer, offered, needed); case 6: return getprinterdriver2_level6(servername, architecture, clientmajorversion, snum, buffer, offered, needed); +#if 0 /* JERRY */ + case 101: + /* apparently this call is the equivalent of + EnumPrinterDataEx() for the DsDriver key */ + break; +#endif } return WERR_UNKNOWN_LEVEL; @@ -5934,7 +5940,9 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s", get_called_name(), p ); - info->attributes = PRINTER_ATTRIBUTE_SAMBA; + info->attributes |= PRINTER_ATTRIBUTE_SAMBA; + info->attributes &= ~PRINTER_ATTRIBUTE_NOT_SAMBA; + return True; -- cgit From 0fc457be2fbb83edd10a688d220d74ede46cbe50 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 31 Aug 2004 19:56:16 +0000 Subject: r2137: This is a patch I've been running at Hawker for a while. The purpose of this patch is to avoid changing the machine account password, when it has 'already been changed'. This occours in situations where the secure channel between the workstation and the DC breaks down, such as occoured in the MS04-11 security patch. This avoids LDAP replication load issues, due to the client changing the password repeatedly. We also now set the LM password to NULL explicitly, rather than the NT password value, as this is what we get out of a vampire, or when a long password is set (as XP seems to do these days). Andrew Bartlett (This used to be commit 1ad1317a815898b52b1803211ab7b502e331e782) --- source3/rpc_server/srv_netlog_nt.c | 48 +++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index b5871a7e56..3e0762fa43 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -445,6 +445,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * unsigned char pwd[16]; int i; uint32 acct_ctrl; + const uchar *old_pw; /* checks and updates credentials. creates reply credentials */ if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->clnt_id.cred, &srv_cred))) @@ -482,34 +483,43 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * return NT_STATUS_ACCOUNT_DISABLED; } + cred_hash3( pwd, q_u->pwd, p->dc.sess_key, 0); + DEBUG(100,("Server password set : new given value was :\n")); for(i = 0; i < 16; i++) DEBUG(100,("%02X ", q_u->pwd[i])); DEBUG(100,("\n")); - cred_hash3( pwd, q_u->pwd, p->dc.sess_key, 0); + old_pw = pdb_get_nt_passwd(sampass); - /* lies! nt and lm passwords are _not_ the same: don't care */ - if (!pdb_set_lanman_passwd (sampass, pwd, PDB_CHANGED)) { - pdb_free_sam(&sampass); - return NT_STATUS_NO_MEMORY; - } + if (old_pw && memcmp(pwd, old_pw, 16) == 0) { + /* Avoid backend modificiations and other fun if the + client changed the password to the *same thing* */ - if (!pdb_set_nt_passwd (sampass, pwd, PDB_CHANGED)) { - pdb_free_sam(&sampass); - return NT_STATUS_NO_MEMORY; - } + ret = True; + } else { - if (!pdb_set_pass_changed_now (sampass)) { - pdb_free_sam(&sampass); - /* Not quite sure what this one qualifies as, but this will do */ - return NT_STATUS_UNSUCCESSFUL; + /* LM password should be NULL for machines */ + if (!pdb_set_lanman_passwd (sampass, NULL, PDB_CHANGED)) { + pdb_free_sam(&sampass); + return NT_STATUS_NO_MEMORY; + } + + if (!pdb_set_nt_passwd (sampass, pwd, PDB_CHANGED)) { + pdb_free_sam(&sampass); + return NT_STATUS_NO_MEMORY; + } + + if (!pdb_set_pass_changed_now (sampass)) { + pdb_free_sam(&sampass); + /* Not quite sure what this one qualifies as, but this will do */ + return NT_STATUS_UNSUCCESSFUL; + } + + become_root(); + ret = pdb_update_sam_account (sampass); + unbecome_root(); } - - become_root(); - ret = pdb_update_sam_account (sampass); - unbecome_root(); - if (ret) status = NT_STATUS_OK; -- cgit From 410a6c72eafbb7fb1ecc9bf89310842ea8027494 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 14 Sep 2004 00:21:11 +0000 Subject: r2331: check password script code and example from trunk (This used to be commit f836be323a233f3a28cbaa04c532e83ea98ead89) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ce6d9dd37e..74f6030365 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2240,7 +2240,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA if (*add_script) { int add_ret; - all_string_sub(add_script, "%u", account, sizeof(account)); + all_string_sub(add_script, "%u", account, sizeof(add_script)); add_ret = smbrun(add_script,NULL); DEBUG(3,("_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); } @@ -3626,7 +3626,7 @@ static int smb_delete_user(const char *unix_user) pstrcpy(del_script, lp_deluser_script()); if (! *del_script) return -1; - all_string_sub(del_script, "%u", unix_user, sizeof(pstring)); + all_string_sub(del_script, "%u", unix_user, sizeof(del_script)); ret = smbrun(del_script,NULL); DEBUG(3,("smb_delete_user: Running the command `%s' gave %d\n",del_script,ret)); -- cgit From 3ada1c1a992172b92f695343a8648675583f7719 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 16 Sep 2004 22:08:26 +0000 Subject: r2369: Fix from Richard Renard to fix usermgr and trust relationships. Jeremy. (This used to be commit b910e530027c19c4e505314a91ffcb72f20d8f09) --- source3/rpc_server/srv_samr_nt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 74f6030365..34fad9b0ed 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -728,7 +728,17 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UN for (i = 0; i < num_entries; i++) { pwd = &disp_user_info[i+start_idx]; temp_name = pdb_get_username(pwd); - init_unistr2(&uni_temp_name, temp_name, UNI_STR_TERMINATE); + + /* + * usrmgr expects a non-NULL terminated string with + * trust relationships + */ + if (pdb_get_acct_ctrl(pwd) & ACB_DOMTRUST) { + init_unistr2(&uni_temp_name, temp_name, UNI_FLAGS_NONE); + } else { + init_unistr2(&uni_temp_name, temp_name, UNI_STR_TERMINATE); + } + user_sid = pdb_get_user_sid(pwd); if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { -- cgit From 75ea9982fb82b5c20f54910926901057b56acdc5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 22 Sep 2004 00:33:09 +0000 Subject: r2481: Patch from Igor Belyi . Ensure pdb user is deleted first before deleting UNIX user (LDAP backend needs this ordering). Jeremy. (This used to be commit 2815b31e013e517a58027ba74f118209caf4d85f) --- source3/rpc_server/srv_samr_nt.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 34fad9b0ed..37617db5e8 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3675,7 +3675,14 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM return NT_STATUS_NO_SUCH_USER; } - /* delete the unix side */ + /* First delete the samba side */ + if (!pdb_delete_sam_account(sam_pass)) { + DEBUG(5,("_samr_delete_dom_user:Failed to delete entry for user %s.\n", pdb_get_username(sam_pass))); + pdb_free_sam(&sam_pass); + return NT_STATUS_CANNOT_DELETE; + } + + /* Now delete the unix side */ /* * note: we don't check if the delete really happened * as the script is not necessary present @@ -3683,13 +3690,7 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM */ smb_delete_user(pdb_get_username(sam_pass)); - /* and delete the samba side */ - if (!pdb_delete_sam_account(sam_pass)) { - DEBUG(5,("_samr_delete_dom_user:Failed to delete entry for user %s.\n", pdb_get_username(sam_pass))); - pdb_free_sam(&sam_pass); - return NT_STATUS_CANNOT_DELETE; - } - + pdb_free_sam(&sam_pass); if (!close_policy_hnd(p, &q_u->user_pol)) -- cgit From 5a8effaaae3c3037ae0f96a942734298950169c6 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 23 Sep 2004 19:24:02 +0000 Subject: r2569: Patch from Rob Foehl : - fix typo in libads/ldap_printer.c:39, ads_find_printer_on_server() (originally libads-typo.patch) - fix leak in printing/nt_printing.c, is_printer_published() (originally is_printer_published-leak.patch) - fix double print_backend_init() calls, now only called from main() - restructuring in printing/nt_printing.c - replaced (un)publish_it() with ads-specific functions - moved common code to nt_printer_publish() - improved error handling in several places - added check_published_printers() in printing/nt_printing.c, to verify that each published printer is actually in the directory at startup - changed calling semantics of mod_a_printer, dump_a_printer, and update_driver_init to be more consistent with the rest of the api and reduce some copying (This used to be commit 50a5a3dbd02acb0d09133b6e42cc37d091ea901d) --- source3/rpc_server/srv_spoolss_nt.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d50237905a..e7b1fdb1d0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1292,7 +1292,7 @@ void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) /* all we care about currently is the change_id */ - result = mod_a_printer(*printer, 2); + result = mod_a_printer(printer, 2); if (!W_ERROR_IS_OK(result)) { DEBUG(3,("do_drv_upgrade_printer: mod_a_printer() failed with status [%s]\n", dos_errstr(result))); @@ -1396,7 +1396,7 @@ void reset_all_printerdata(int msg_type, pid_t src, void *buf, size_t len) printer->info_2->printername, printer->info_2->drivername)); } - result = mod_a_printer( *printer, 2 ); + result = mod_a_printer( printer, 2 ); if ( !W_ERROR_IS_OK(result) ) { DEBUG(3,("reset_all_printerdata: mod_a_printer() failed! (%s)\n", get_dos_error_msg(result))); @@ -6191,7 +6191,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); /* Update printer info */ - result = mod_a_printer(*printer, 2); + result = mod_a_printer(printer, 2); done: free_a_printer(&printer, 2); @@ -7433,7 +7433,7 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ } /* write the ASCII on disk */ - err = mod_a_printer(*printer, 2); + err = mod_a_printer(printer, 2); if (!W_ERROR_IS_OK(err)) { free_a_printer(&printer,2); return err; @@ -7971,7 +7971,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP status = set_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, valuename, type, data, real_len ); if ( W_ERROR_IS_OK(status) ) - status = mod_a_printer(*printer, 2); + status = mod_a_printer(printer, 2); } done: @@ -8049,7 +8049,7 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ status = delete_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, valuename ); if ( W_ERROR_IS_OK(status) ) - mod_a_printer( *printer, 2 ); + mod_a_printer( printer, 2 ); free_a_printer(&printer, 2); @@ -8119,7 +8119,7 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM */ if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) - status = mod_a_printer(*printer, 2); + status = mod_a_printer(printer, 2); done: if ( printer ) @@ -8186,7 +8186,7 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE */ if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) - status = mod_a_printer(*printer, 2); + status = mod_a_printer(printer, 2); done: if ( printer ) @@ -8252,7 +8252,7 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * */ if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) - status = mod_a_printer(*printer, 2); + status = mod_a_printer(printer, 2); done: @@ -8864,7 +8864,7 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, REG_SZ, (void*)oid_string, strlen(oid_string)+1 ); } - status = mod_a_printer(*printer, 2); + status = mod_a_printer(printer, 2); } free_a_printer(&printer, 2); @@ -8914,7 +8914,7 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX status = delete_printer_dataex( printer, keyname, valuename ); if ( W_ERROR_IS_OK(status) ) - mod_a_printer( *printer, 2 ); + mod_a_printer( printer, 2 ); free_a_printer(&printer, 2); @@ -9037,7 +9037,7 @@ WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, status = delete_all_printer_data( printer->info_2, key ); if ( W_ERROR_IS_OK(status) ) - status = mod_a_printer(*printer, 2); + status = mod_a_printer(printer, 2); free_a_printer( &printer, 2 ); -- cgit From 90cd0c339c800b7a4529a80442c3c487d99d5250 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 1 Oct 2004 03:14:57 +0000 Subject: r2761: Print the decrypted, not encrypted key. Andrew Bartlett (This used to be commit 1833d0ab724d88411ebd79ac26f5642e7c8cfee3) --- source3/rpc_server/srv_netlog_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 3e0762fa43..a3157435f3 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -486,8 +486,8 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * cred_hash3( pwd, q_u->pwd, p->dc.sess_key, 0); DEBUG(100,("Server password set : new given value was :\n")); - for(i = 0; i < 16; i++) - DEBUG(100,("%02X ", q_u->pwd[i])); + for(i = 0; i < sizeof(pwd); i++) + DEBUG(100,("%02X ", pwd[i])); DEBUG(100,("\n")); old_pw = pdb_get_nt_passwd(sampass); -- cgit From 31441aaa137145511a2c09dd540d46876df56701 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 1 Oct 2004 20:34:12 +0000 Subject: r2768: BUG 1519: save the hostname used in the open_printer_ex() for later reuse when filling in the spolss replies (also gets rid of get_called_name() (This used to be commit 57db8ca91f52329c7f8985c04463b6b69015b0c4) --- source3/rpc_server/srv_spoolss_nt.c | 277 +++++++++++++++++++++--------------- 1 file changed, 164 insertions(+), 113 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e7b1fdb1d0..5c8a6235b6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -201,7 +201,7 @@ static void free_printer_entry(void *ptr) snum = -1; srv_spoolss_replycloseprinter(snum, &Printer->notify.client_hnd); } else if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) { - snum = print_queue_snum(Printer->dev.handlename); + snum = print_queue_snum(Printer->sharename); if (snum != -1) srv_spoolss_replycloseprinter(snum, &Printer->notify.client_hnd); @@ -277,17 +277,19 @@ static Printer_entry *find_printer_index_by_hnd(pipes_struct *p, POLICY_HND *hnd ****************************************************************************/ WERROR find_printer_in_print_hnd_cache( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL_2 **info2, - const char *printername ) + const char *servername, const char *printername ) { Printer_entry *p; - DEBUG(10,("find_printer_in_print_hnd_cache: printer [%s]\n", printername)); + DEBUG(10,("find_printer_in_print_hnd_cache: printer [\\\\%s\\%s]\n", + servername, printername)); for ( p=printers_list; p; p=p->next ) { if ( p->printer_type==PRINTER_HANDLE_IS_PRINTER && p->printer_info - && StrCaseCmp(p->dev.handlename, printername) == 0 ) + && strequal( p->sharename, printername ) + && strequal( p->servername, servername ) ) { DEBUG(10,("Found printer\n")); *info2 = dup_printer_2( ctx, p->printer_info->info_2 ); @@ -313,7 +315,7 @@ void invalidate_printer_hnd_cache( char *printername ) { if ( p->printer_type==PRINTER_HANDLE_IS_PRINTER && p->printer_info - && StrCaseCmp(p->dev.handlename, printername)==0) + && StrCaseCmp(p->sharename, printername)==0) { DEBUG(10,("invalidating printer_info cache for handl:\n")); free_a_printer( &p->printer_info, 2 ); @@ -378,8 +380,8 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) } #endif - if (del_a_printer(Printer->dev.handlename) != 0) { - DEBUG(3,("Error deleting printer %s\n", Printer->dev.handlename)); + if (del_a_printer( Printer->sharename ) != 0) { + DEBUG(3,("Error deleting printer %s\n", Printer->sharename)); return WERR_BADFID; } @@ -389,9 +391,7 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) pstring command; int ret; - /* Printer->dev.handlename equals portname equals sharename */ - slprintf(command, sizeof(command)-1, "%s \"%s\"", cmd, - Printer->dev.handlename); + pstr_sprintf(command, "%s \"%s\"", cmd, Printer->sharename); DEBUG(10,("Running [%s]\n", command)); ret = smbrun(command, NULL); @@ -406,7 +406,7 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) /* go ahead and re-read the services immediately */ reload_services( False ); - if ( lp_servicenumber( Printer->dev.handlename ) < 0 ) + if ( lp_servicenumber( Printer->sharename ) < 0 ) return WERR_ACCESS_DENIED; } @@ -427,14 +427,14 @@ static BOOL get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number) } switch (Printer->printer_type) { - case PRINTER_HANDLE_IS_PRINTER: - DEBUG(4,("short name:%s\n", Printer->dev.handlename)); - *number = print_queue_snum(Printer->dev.handlename); - return (*number != -1); - case PRINTER_HANDLE_IS_PRINTSERVER: - return False; - default: - return False; + case PRINTER_HANDLE_IS_PRINTER: + DEBUG(4,("short name:%s\n", Printer->sharename)); + *number = print_queue_snum(Printer->sharename); + return (*number != -1); + case PRINTER_HANDLE_IS_PRINTSERVER: + return False; + default: + return False; } } @@ -475,6 +475,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) int snum; int n_services=lp_numservices(); char *aprinter, *printername; + const char *servername; fstring sname; BOOL found=False; NT_PRINTER_INFO_LEVEL *printer; @@ -482,28 +483,37 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename, (unsigned long)strlen(handlename))); - if (Printer->printer_type==PRINTER_HANDLE_IS_PRINTSERVER) { - ZERO_STRUCT(Printer->dev.printerservername); - strncpy(Printer->dev.printerservername, handlename, strlen(handlename)); - return True; - } - - if (Printer->printer_type!=PRINTER_HANDLE_IS_PRINTER) - return False; - - if (*handlename=='\\') { - aprinter=strchr_m(handlename+2, '\\'); - aprinter++; + aprinter = handlename; + if ( *handlename == '\\' ) { + servername = handlename + 2; + if ( (aprinter = strchr_m( handlename+2, '\\' )) != NULL ) { + *aprinter = '\0'; + aprinter++; + } } else { - aprinter=handlename; + servername = ""; } + + /* save the servername to fill in replies on this handle */ + + if ( !is_myname_or_ipaddr( servername ) ) + return False; + + fstrcpy( Printer->servername, servername ); + + if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER ) + return True; - DEBUGADD(5, ("searching for [%s] (len=%lu)\n", aprinter, (unsigned long)strlen(aprinter))); + if ( Printer->printer_type != PRINTER_HANDLE_IS_PRINTER ) + return False; - /* have to search on sharename and PRINTER_INFO2->printername */ + DEBUGADD(5, ("searching for [%s]\n", aprinter )); - for (snum=0; snum %s\n", aprinter, sname)); - ZERO_STRUCT(Printer->dev.handlename); - fstrcpy(Printer->dev.handlename, sname); + fstrcpy(Printer->sharename, sname); return True; } @@ -696,10 +708,8 @@ static BOOL is_monitoring_event(Printer_entry *p, uint16 notify_type, } } - DEBUG(10, ("%s is not monitoring 0x%02x/0x%02x\n", - (p->printer_type == PRINTER_HANDLE_IS_PRINTER) ? - p->dev.handlename : p->dev.printerservername, - notify_type, notify_field)); + DEBUG(10, ("Open handle for \\\\%s\\%s is not monitoring 0x%02x/0x%02x\n", + p->servername, p->sharename, notify_type, notify_field)); return False; } @@ -995,13 +1005,13 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) if ( !p->notify.client_connected ) continue; - DEBUG(10,("Client connected! [%s]\n", p->dev.handlename)); + DEBUG(10,("Client connected! [\\\\%s\\%s]\n", p->servername, p->sharename)); /* For this printer? Print servers always receive notifications. */ if ( ( p->printer_type == PRINTER_HANDLE_IS_PRINTER ) && - ( !strequal(msg_group->printername, p->dev.handlename) ) ) + ( !strequal(msg_group->printername, p->sharename) ) ) continue; DEBUG(10,("Our printer\n")); @@ -1027,7 +1037,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) DEBUG(10,("process_notify2_message: Sending message type [0x%x] field [0x%2x] for printer [%s]\n", - msg->type, msg->field, p->dev.handlename)); + msg->type, msg->field, p->sharename)); /* * if the is a printer notification handle and not a job notification @@ -1323,7 +1333,7 @@ void update_monitored_printq_cache( void ) if ( (printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && printer->notify.client_connected ) { - snum = print_queue_snum(printer->dev.handlename); + snum = print_queue_snum(printer->sharename); print_queue_status( snum, NULL, NULL ); } @@ -1619,9 +1629,9 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, return WERR_INVALID_PRINTER_NAME; Printer=find_printer_index_by_hnd(p, handle); - if (!Printer) { - DEBUG(0,(" _spoolss_open_printer_ex: logic error. \ -Can't find printer handle we created for printer %s\n", name )); + if ( !Printer ) { + DEBUG(0,(" _spoolss_open_printer_ex: logic error. Can't find printer " + "handle we created for printer %s\n", name )); close_printer_handle(p,handle); return WERR_INVALID_PRINTER_NAME; } @@ -1765,10 +1775,11 @@ Can't find printer handle we created for printer %s\n", name )); if ( (Printer->printer_type != PRINTER_HANDLE_IS_PRINTSERVER) && q_u->printer_default.devmode_cont.devmode_ptr ) { - convert_devicemode( Printer->dev.handlename, q_u->printer_default.devmode_cont.devmode, + convert_devicemode( Printer->sharename, q_u->printer_default.devmode_cont.devmode, &Printer->nt_devmode ); } +#if 0 /* JERRY -- I'm doubtful this is really effective */ /* HACK ALERT!!! Sleep for 1/3 of a second to try trigger a LAN/WAN optimization in Windows 2000 clients --jerry */ @@ -1778,6 +1789,7 @@ Can't find printer handle we created for printer %s\n", name )); DEBUG(10,("_spoolss_open_printer_ex: Enabling LAN/WAN hack for Win2k clients.\n")); sys_usleep( 500000 ); } +#endif return WERR_OK; } @@ -2737,6 +2749,8 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE return WERR_OK; } +#if 0 /* JERRY -- disabled; not used for now */ + /******************************************************************* * fill a notify_info_data with the servername ********************************************************************/ @@ -2750,7 +2764,9 @@ void spoolss_notify_server_name(int snum, pstring temp_name, temp; uint32 len; - slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", get_called_name()); + fstrcpy( temp_name, "\\\\%L" ); + standard_sub_basic( NULL, temp_name, sizeof(temp_name)-1 ); + len = rpcstr_push(temp, temp_name, sizeof(temp)-2, STR_TERMINATE); @@ -2765,6 +2781,9 @@ void spoolss_notify_server_name(int snum, memcpy(data->notify_data.data.string, temp, len); } +#endif + + /******************************************************************* * fill a notify_info_data with the printername (not including the servername). ********************************************************************/ @@ -3437,7 +3456,7 @@ struct s_notify_info_data_table static const struct s_notify_info_data_table notify_info_data_table[] = { -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", NOTIFY_STRING, spoolss_notify_server_name }, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", NOTIFY_STRING, NULL}, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, "PRINTER_NOTIFY_PRINTER_NAME", NOTIFY_STRING, spoolss_notify_printer_name }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SHARE_NAME, "PRINTER_NOTIFY_SHARE_NAME", NOTIFY_STRING, spoolss_notify_share_name }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PORT_NAME, "PRINTER_NOTIFY_PORT_NAME", NOTIFY_STRING, spoolss_notify_port_name }, @@ -3464,7 +3483,7 @@ static const struct s_notify_info_data_table notify_info_data_table[] = { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_BYTES, "PRINTER_NOTIFY_TOTAL_BYTES", NOTIFY_POINTER, NULL }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_BYTES_PRINTED, "PRINTER_NOTIFY_BYTES_PRINTED", NOTIFY_POINTER, NULL }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINTER_NAME, "JOB_NOTIFY_PRINTER_NAME", NOTIFY_STRING, spoolss_notify_printer_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_MACHINE_NAME, "JOB_NOTIFY_MACHINE_NAME", NOTIFY_STRING, spoolss_notify_server_name }, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_MACHINE_NAME, "JOB_NOTIFY_MACHINE_NAME", NOTIFY_STRING, NULL}, { JOB_NOTIFY_TYPE, JOB_NOTIFY_PORT_NAME, "JOB_NOTIFY_PORT_NAME", NOTIFY_STRING, spoolss_notify_port_name }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_USER_NAME, "JOB_NOTIFY_USER_NAME", NOTIFY_STRING, spoolss_notify_username }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_NOTIFY_NAME, "JOB_NOTIFY_NOTIFY_NAME", NOTIFY_STRING, spoolss_notify_username }, @@ -3979,7 +3998,7 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p init_unistr(&printer->printername, chaine); - slprintf(chaine,sizeof(chaine)-1,"\\\\%s", get_called_name()); + slprintf(chaine,sizeof(chaine)-1,"\\\\%s", get_server_name(print_hnd)); init_unistr(&printer->servername, chaine); printer->cjobs = count; @@ -4444,6 +4463,7 @@ static WERROR enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, ui return WERR_INVALID_NAME; } +#if 0 /* JERRY -- disabled for now. Don't think this is used, tested, or correct */ /******************************************************************** enum_all_printers_info_1_remote. *********************************************************************/ @@ -4458,9 +4478,10 @@ static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, /* JFM: currently it's more a place holder than anything else. * In the spooler world there is a notion of server registration. - * the print servers are registring (sp ?) on the PDC (in the same domain) + * the print servers are registered on the PDC (in the same domain) * - * We should have a TDB here. The registration is done thru an undocumented RPC call. + * We should have a TDB here. The registration is done thru an + * undocumented RPC call. */ if((printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1))) == NULL) @@ -4468,8 +4489,8 @@ static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, *returned=1; - slprintf(printername, sizeof(printername)-1,"Windows NT Remote Printers!!\\\\%s", get_called_name()); - slprintf(desc, sizeof(desc)-1,"%s", get_called_name()); + slprintf(printername, sizeof(printername)-1,"Windows NT Remote Printers!!\\\\%s", name); + slprintf(desc, sizeof(desc)-1,"%s", name); slprintf(comment, sizeof(comment)-1, "Logged on Domain"); init_unistr(&printer->description, desc); @@ -4499,6 +4520,8 @@ static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, return WERR_OK; } +#endif + /******************************************************************** enum_all_printers_info_1_network. *********************************************************************/ @@ -4605,8 +4628,10 @@ static WERROR enumprinters_level1( uint32 flags, fstring name, if (flags & PRINTER_ENUM_NAME) return enum_all_printers_info_1_name(name, buffer, offered, needed, returned); +#if 0 /* JERRY - disabled for now */ if (flags & PRINTER_ENUM_REMOTE) return enum_all_printers_info_1_remote(name, buffer, offered, needed, returned); +#endif if (flags & PRINTER_ENUM_NETWORK) return enum_all_printers_info_1_network(name, buffer, offered, needed, returned); @@ -5543,6 +5568,7 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ uint32 *needed = &r_u->needed; uint32 *servermajorversion = &r_u->servermajorversion; uint32 *serverminorversion = &r_u->serverminorversion; + Printer_entry *printer; fstring servername; fstring architecture; @@ -5554,11 +5580,16 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ DEBUG(4,("_spoolss_getprinterdriver2\n")); + if ( !(printer = find_printer_index_by_hnd( p, handle )) ) { + DEBUG(0,("_spoolss_getprinterdriver2: invalid printer handle!\n")); + return WERR_INVALID_PRINTER_NAME; + } + *needed = 0; *servermajorversion = 0; *serverminorversion = 0; - fstrcpy(servername, get_called_name()); + fstrcpy(servername, get_server_name( printer )); unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); if (!get_printer_snum(p, handle, &snum)) @@ -5840,11 +5871,9 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, } /* NT seems to like setting the security descriptor even though - nothing may have actually changed. This causes annoying - dialog boxes when the user doesn't have permission to change - the security descriptor. */ + nothing may have actually changed. */ - nt_printing_getsec(p->mem_ctx, Printer->dev.handlename, &old_secdesc_ctr); + nt_printing_getsec(p->mem_ctx, Printer->sharename, &old_secdesc_ctr); if (DEBUGLEVEL >= 10) { SEC_ACL *the_acl; @@ -5903,7 +5932,7 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, goto done; } - result = nt_printing_setsec(Printer->dev.handlename, new_secdesc_ctr); + result = nt_printing_setsec(Printer->sharename, new_secdesc_ctr); done: @@ -5911,9 +5940,12 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, } /******************************************************************** - Do Samba sanity checks on a printer info struct. - this has changed purpose: it now "canonicalises" printer - info from a client rather than just checking it is correct + Canonicalize printer info from a client + + ATTN: It does not matter what we set the servername to hear + since we do the necessary work in get_a_printer() to set it to + the correct value based on what the client sent in the + _spoolss_open_printer_ex(). ********************************************************************/ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) @@ -5921,11 +5953,13 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) fstring printername; const char *p; - DEBUG(5,("check_printer_ok: servername=%s printername=%s sharename=%s portname=%s drivername=%s comment=%s location=%s\n", - info->servername, info->printername, info->sharename, info->portname, info->drivername, info->comment, info->location)); + DEBUG(5,("check_printer_ok: servername=%s printername=%s sharename=%s " + "portname=%s drivername=%s comment=%s location=%s\n", + info->servername, info->printername, info->sharename, + info->portname, info->drivername, info->comment, info->location)); /* we force some elements to "correct" values */ - slprintf(info->servername, sizeof(info->servername)-1, "\\\\%s", get_called_name()); + slprintf(info->servername, sizeof(info->servername)-1, "\\\\%s", global_myname()); fstrcpy(info->sharename, lp_servicename(snum)); /* make sure printername is in \\server\printername format */ @@ -5938,7 +5972,7 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) } slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s", - get_called_name(), p ); + global_myname(), p ); info->attributes |= PRINTER_ATTRIBUTE_SAMBA; info->attributes &= ~PRINTER_ATTRIBUTE_NOT_SAMBA; @@ -6322,18 +6356,16 @@ WERROR _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u ****************************************************************************/ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, - int position, int snum) + int position, int snum, + NT_PRINTER_INFO_LEVEL *ntprinter) { - pstring temp_name; - struct tm *t; t=gmtime(&queue->time); - slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", get_called_name()); job_info->jobid=queue->job; init_unistr(&job_info->printername, lp_servicename(snum)); - init_unistr(&job_info->machinename, temp_name); + init_unistr(&job_info->machinename, ntprinter->info_2->servername); init_unistr(&job_info->username, queue->fs_user); init_unistr(&job_info->document, queue->fs_file); init_unistr(&job_info->datatype, "RAW"); @@ -6355,17 +6387,15 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *ntprinter, DEVICEMODE *devmode) { - pstring temp_name; struct tm *t; t=gmtime(&queue->time); - slprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", get_called_name()); job_info->jobid=queue->job; init_unistr(&job_info->printername, ntprinter->info_2->printername); - init_unistr(&job_info->machinename, temp_name); + init_unistr(&job_info->machinename, ntprinter->info_2->servername); init_unistr(&job_info->username, queue->fs_user); init_unistr(&job_info->document, queue->fs_file); init_unistr(&job_info->notifyname, queue->fs_user); @@ -6398,6 +6428,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, ****************************************************************************/ static WERROR enumjobs_level1(print_queue_struct *queue, int snum, + NT_PRINTER_INFO_LEVEL *ntprinter, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { @@ -6412,7 +6443,7 @@ static WERROR enumjobs_level1(print_queue_struct *queue, int snum, } for (i=0; i<*returned; i++) - fill_job_info_1(&info[i], &queue[i], i, snum); + fill_job_info_1( &info[i], &queue[i], i, snum, ntprinter ); SAFE_FREE(queue); @@ -6445,10 +6476,10 @@ static WERROR enumjobs_level1(print_queue_struct *queue, int snum, ****************************************************************************/ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, + NT_PRINTER_INFO_LEVEL *ntprinter, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - NT_PRINTER_INFO_LEVEL *ntprinter = NULL; JOB_INFO_2 *info = NULL; int i; WERROR result; @@ -6460,12 +6491,6 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, result = WERR_NOMEM; goto done; } - - result = get_a_printer(NULL, &ntprinter, 2, lp_servicename(snum)); - if (!W_ERROR_IS_OK(result)) { - *returned = 0; - goto done; - } /* this should not be a failure condition if the devmode is NULL */ @@ -6523,7 +6548,7 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; WERROR wret; - + NT_PRINTER_INFO_LEVEL *ntprinter = NULL; int snum; print_status_struct prt_status; print_queue_struct *queue=NULL; @@ -6537,9 +6562,15 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO *needed=0; *returned=0; + /* lookup the printer snum and tdb entry */ + if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; + wret = get_a_printer(NULL, &ntprinter, 2, lp_servicename(snum)); + if ( !W_ERROR_IS_OK(wret) ) + return wret; + *returned = print_queue_status(snum, &queue, &prt_status); DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); @@ -6550,16 +6581,19 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO switch (level) { case 1: - wret = enumjobs_level1(queue, snum, buffer, offered, needed, returned); + wret = enumjobs_level1(queue, snum, ntprinter, buffer, offered, needed, returned); return wret; case 2: - wret = enumjobs_level2(queue, snum, buffer, offered, needed, returned); + wret = enumjobs_level2(queue, snum, ntprinter, buffer, offered, needed, returned); return wret; default: SAFE_FREE(queue); *returned=0; - return WERR_UNKNOWN_LEVEL; + wret = WERR_UNKNOWN_LEVEL; } + + free_a_printer( &ntprinter, 2 ); + return wret; } /**************************************************************************** @@ -6866,7 +6900,6 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, SPOOL_R_ENUMPRINTERDRIVERS *r_u) { - UNISTR2 *environment = &q_u->environment; uint32 level = q_u->level; NEW_BUFFER *buffer = NULL; uint32 offered = q_u->offered; @@ -6882,11 +6915,14 @@ WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS buffer = r_u->buffer; DEBUG(4,("_spoolss_enumprinterdrivers\n")); - fstrcpy(servername, get_called_name()); *needed=0; *returned=0; - unistr2_to_ascii(architecture, environment, sizeof(architecture)-1); + unistr2_to_ascii(architecture, &q_u->environment, sizeof(architecture)-1); + unistr2_to_ascii(servername, &q_u->name, sizeof(servername)-1); + + if ( !is_myname_or_ipaddr( servername ) ) + return WERR_UNKNOWN_PRINTER_DRIVER; switch (level) { case 1: @@ -7387,7 +7423,10 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ } } - slprintf(name, sizeof(name)-1, "\\\\%s\\%s", get_called_name(), + /* use our primary netbios name since get_a_printer() will convert + it to what the client expects on a case by case basis */ + + slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname(), printer->info_2->sharename); @@ -7659,10 +7698,15 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen { pstring path; pstring long_archi; + fstring servername; const char *short_archi; DRIVER_DIRECTORY_1 *info=NULL; + unistr2_to_ascii(servername, name, sizeof(servername)-1); unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); + + if ( !is_myname_or_ipaddr( servername ) ) + return WERR_INVALID_PARAM; if (!(short_archi = get_short_archi(long_archi))) return WERR_INVALID_ENVIRONMENT; @@ -7670,7 +7714,7 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen if((info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1))) == NULL) return WERR_NOMEM; - slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", get_called_name(), short_archi); + slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", servername, short_archi); DEBUG(4,("printer driver directory: [%s]\n", path)); @@ -8496,7 +8540,10 @@ WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_ /**************************************************************************** ****************************************************************************/ -static WERROR getjob_level_1(print_queue_struct **queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getjob_level_1(print_queue_struct **queue, int count, int snum, + NT_PRINTER_INFO_LEVEL *ntprinter, + uint32 jobid, NEW_BUFFER *buffer, uint32 offered, + uint32 *needed) { int i=0; BOOL found=False; @@ -8519,7 +8566,7 @@ static WERROR getjob_level_1(print_queue_struct **queue, int count, int snum, ui return WERR_INVALID_PARAM; } - fill_job_info_1(info_1, &((*queue)[i-1]), i, snum); + fill_job_info_1( info_1, &((*queue)[i-1]), i, snum, ntprinter ); *needed += spoolss_size_job_info_1(info_1); @@ -8541,12 +8588,14 @@ static WERROR getjob_level_1(print_queue_struct **queue, int count, int snum, ui /**************************************************************************** ****************************************************************************/ -static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, + NT_PRINTER_INFO_LEVEL *ntprinter, + uint32 jobid, NEW_BUFFER *buffer, uint32 offered, + uint32 *needed) { int i = 0; BOOL found = False; JOB_INFO_2 *info_2; - NT_PRINTER_INFO_LEVEL *ntprinter = NULL; WERROR ret; DEVICEMODE *devmode = NULL; NT_DEVICEMODE *nt_devmode = NULL; @@ -8574,10 +8623,6 @@ static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, ui goto done; } - ret = get_a_printer(NULL, &ntprinter, 2, lp_const_servicename(snum)); - if (!W_ERROR_IS_OK(ret)) - goto done; - /* * if the print job does not have a DEVMODE associated with it, * just use the one for the printer. A NULL devicemode is not @@ -8633,7 +8678,7 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; WERROR wstatus = WERR_OK; - + NT_PRINTER_INFO_LEVEL *ntprinter = NULL; int snum; int count; print_queue_struct *queue = NULL; @@ -8650,6 +8695,10 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; + wstatus = get_a_printer(NULL, &ntprinter, 2, lp_servicename(snum)); + if ( !W_ERROR_IS_OK(wstatus) ) + return wstatus; + count = print_queue_status(snum, &queue, &prt_status); DEBUGADD(4,("count:[%d], prt_status:[%d], [%s]\n", @@ -8657,11 +8706,11 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ switch ( level ) { case 1: - wstatus = getjob_level_1(&queue, count, snum, jobid, + wstatus = getjob_level_1(&queue, count, snum, ntprinter, jobid, buffer, offered, needed); break; case 2: - wstatus = getjob_level_2(&queue, count, snum, jobid, + wstatus = getjob_level_2(&queue, count, snum, ntprinter, jobid, buffer, offered, needed); break; default: @@ -8670,6 +8719,8 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ } SAFE_FREE(queue); + free_a_printer( &ntprinter, 2 ); + return wstatus; } -- cgit From 2d016a67b87b5fee71fbdd33ea6b6fa78b0c8828 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Oct 2004 22:13:57 +0000 Subject: r2821: Adding "Windows x64" as architecture string and driverdir "x64" for the 64bit AMD platform. (This used to be "Windows AMD64" and "AMD64" in one of the release candidates of SP2 for Windows XP. AMD64 is obviously still supported but not documented.) Guenther (This used to be commit cc5892f0411b8eb5daebe746164a2cf21d3d4c68) --- source3/rpc_server/srv_spoolss_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5c8a6235b6..fb498e73ad 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1995,6 +1995,7 @@ static int get_version_id (char * arch) {"Windows NT Alpha_AXP", "W32ALPHA", 2 }, {"Windows NT PowerPC", "W32PPC", 2 }, {"Windows IA64", "IA64", 3 }, + {"Windows x64", "x64", 3 }, {NULL, "", -1 } }; -- cgit From 3d502114809854a49fab0ff6c14cb6a51a07ab85 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 8 Oct 2004 13:00:47 +0000 Subject: r2865: Add static and remove unused functions that only cload the blame-game in finding out who is causing the massive performance problems with large LDAP directories. Andrew Bartlett (This used to be commit f16ed2616a67c412bc9b78354a5faf673e64cf42) --- source3/rpc_server/srv_util.c | 170 +----------------------------------------- 1 file changed, 3 insertions(+), 167 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 5bb8db4e06..d70054af8c 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -46,7 +46,7 @@ * and groups. */ -rid_name builtin_alias_rids[] = +static const rid_name builtin_alias_rids[] = { { BUILTIN_ALIAS_RID_ADMINS , "Administrators" }, { BUILTIN_ALIAS_RID_USERS , "Users" }, @@ -62,7 +62,7 @@ rid_name builtin_alias_rids[] = }; /* array lookup of well-known Domain RID users. */ -rid_name domain_user_rids[] = +static const rid_name domain_user_rids[] = { { DOMAIN_USER_RID_ADMIN , "Administrator" }, { DOMAIN_USER_RID_GUEST , "Guest" }, @@ -70,7 +70,7 @@ rid_name domain_user_rids[] = }; /* array lookup of well-known Domain RID groups. */ -rid_name domain_group_rids[] = +static const rid_name domain_group_rids[] = { { DOMAIN_GROUP_RID_ADMINS , "Domain Admins" }, { DOMAIN_GROUP_RID_USERS , "Domain Users" }, @@ -414,167 +414,3 @@ NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, const DOM_SID *domain_sid, return NT_STATUS_OK; } -/******************************************************************* - Look up a local (domain) rid and return a name and type. - ********************************************************************/ -NTSTATUS local_lookup_group_name(uint32 rid, char *group_name, uint32 *type) -{ - int i = 0; - (*type) = SID_NAME_DOM_GRP; - - DEBUG(5,("lookup_group_name: rid: %d", rid)); - - while (domain_group_rids[i].rid != rid && domain_group_rids[i].rid != 0) - { - i++; - } - - if (domain_group_rids[i].rid != 0) - { - fstrcpy(group_name, domain_group_rids[i].name); - DEBUG(5,(" = %s\n", group_name)); - return NT_STATUS_OK; - } - - DEBUG(5,(" none mapped\n")); - return NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - Look up a local alias rid and return a name and type. - ********************************************************************/ -NTSTATUS local_lookup_alias_name(uint32 rid, char *alias_name, uint32 *type) -{ - int i = 0; - (*type) = SID_NAME_WKN_GRP; - - DEBUG(5,("lookup_alias_name: rid: %d", rid)); - - while (builtin_alias_rids[i].rid != rid && builtin_alias_rids[i].rid != 0) - { - i++; - } - - if (builtin_alias_rids[i].rid != 0) - { - fstrcpy(alias_name, builtin_alias_rids[i].name); - DEBUG(5,(" = %s\n", alias_name)); - return NT_STATUS_OK; - } - - DEBUG(5,(" none mapped\n")); - return NT_STATUS_NONE_MAPPED; -} - - -#if 0 /*Nobody uses this function just now*/ -/******************************************************************* - Look up a local user rid and return a name and type. - ********************************************************************/ -NTSTATUS local_lookup_user_name(uint32 rid, char *user_name, uint32 *type) -{ - SAM_ACCOUNT *sampwd=NULL; - int i = 0; - BOOL ret; - - (*type) = SID_NAME_USER; - - DEBUG(5,("lookup_user_name: rid: %d", rid)); - - /* look up the well-known domain user rids first */ - while (domain_user_rids[i].rid != rid && domain_user_rids[i].rid != 0) - { - i++; - } - - if (domain_user_rids[i].rid != 0) { - fstrcpy(user_name, domain_user_rids[i].name); - DEBUG(5,(" = %s\n", user_name)); - return NT_STATUS_OK; - } - - pdb_init_sam(&sampwd); - - /* ok, it's a user. find the user account */ - become_root(); - ret = pdb_getsampwrid(sampwd, rid); - unbecome_root(); - - if (ret == True) { - fstrcpy(user_name, pdb_get_username(sampwd) ); - DEBUG(5,(" = %s\n", user_name)); - pdb_free_sam(&sampwd); - return NT_STATUS_OK; - } - - DEBUG(5,(" none mapped\n")); - pdb_free_sam(&sampwd); - return NT_STATUS_NONE_MAPPED; -} - -#endif - -/******************************************************************* - Look up a local (domain) group name and return a rid - ********************************************************************/ -NTSTATUS local_lookup_group_rid(char *group_name, uint32 *rid) -{ - const char *grp_name; - int i = -1; /* start do loop at -1 */ - - do /* find, if it exists, a group rid for the group name*/ - { - i++; - (*rid) = domain_group_rids[i].rid; - grp_name = domain_group_rids[i].name; - - } while (grp_name != NULL && !strequal(grp_name, group_name)); - - return (grp_name != NULL) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - Look up a local (BUILTIN) alias name and return a rid - ********************************************************************/ -NTSTATUS local_lookup_alias_rid(const char *alias_name, uint32 *rid) -{ - const char *als_name; - int i = -1; /* start do loop at -1 */ - - do /* find, if it exists, a alias rid for the alias name*/ - { - i++; - (*rid) = builtin_alias_rids[i].rid; - als_name = builtin_alias_rids[i].name; - - } while (als_name != NULL && !strequal(als_name, alias_name)); - - return (als_name != NULL) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; -} - -/******************************************************************* - Look up a local user name and return a rid - ********************************************************************/ -NTSTATUS local_lookup_user_rid(char *user_name, uint32 *rid) -{ - SAM_ACCOUNT *sampass=NULL; - BOOL ret; - - (*rid) = 0; - - pdb_init_sam(&sampass); - - /* find the user account */ - become_root(); - ret = pdb_getsampwnam(sampass, user_name); - unbecome_root(); - - if (ret == True) { - (*rid) = pdb_get_user_rid(sampass); - pdb_free_sam(&sampass); - return NT_STATUS_OK; - } - - pdb_free_sam(&sampass); - return NT_STATUS_NONE_MAPPED; -} -- cgit From 4792a8de3057dc9a6e6be43f618407ddb036484e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 9 Oct 2004 01:44:05 +0000 Subject: r2868: Well, I'm not quite sure what I'm doing back in Samba 3.0, but anyway... I've been grumbling about under-efficient calls in SAMR, and finally got around to fixing some of them. We now call sys_getgroups() (which in turn calls initgroups(), until glibc 3.4 is released) to figure out a user's group membership. This is far, far more efficient than scanning all the groups looking for a match, and is still the 'posix way', just using an effiecient call. The seperate issue of 'who is in this group' remains, but this one has been biting some people. I need to talk to VL about how best to exersise nasty corner cases, but my initial tests hold strong. (The code is also much simpiler than before, which has to count for something :-) Andrew Bartlett (This used to be commit dc19f161698dab5b71d61fa2bacc7e7b8da5fbba) --- source3/rpc_server/srv_util.c | 153 +++++++++++------------------------------- 1 file changed, 41 insertions(+), 112 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index d70054af8c..ce8e02fae7 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -3,7 +3,8 @@ * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1998 * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, - * Copyright (C) Paul Ashton 1997-1998. + * Copyright (C) Paul Ashton 1997-1998, + * Copyright (C) Andrew Bartlett 2004. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -98,17 +99,6 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui BOOL ret; BOOL winbind_groups_exist; - /* - * this code is far from perfect. - * first it enumerates the full /etc/group and that can be slow. - * second, it works only with users' SIDs - * whereas the day we support nested groups, it will have to - * support both users's SIDs and domain groups' SIDs - * - * having our own ldap backend would be so much faster ! - * we're far from that, but hope one day ;-) JFM. - */ - *prids=NULL; *numgroups=0; @@ -136,11 +126,8 @@ NTSTATUS get_alias_user_groups(TALLOC_CTX *ctx, DOM_SID *sid, int *numgroups, ui return NT_STATUS_UNSUCCESSFUL; } - become_root(); - /* on some systems this must run as root */ - num_groups = getgroups_user(user_name, &groups); - unbecome_root(); - if (num_groups == -1) { + ret = getgroups_user(user_name, &groups, &num_groups); + if (!ret) { /* this should never happen */ DEBUG(2,("get_alias_user_groups: getgroups_user failed\n")); pdb_free_sam(&sam_pass); @@ -272,115 +259,57 @@ done: ********************************************************************/ BOOL get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids, SAM_ACCOUNT *sam_pass) { - GROUP_MAP *map=NULL; - int i, num, num_entries, cur_gid=0; - struct group *grp; - DOM_GID *gids; - fstring user_name; - uint32 grid; - uint32 tmp_rid; - BOOL ret; - - *numgroups= 0; - - fstrcpy(user_name, pdb_get_username(sam_pass)); - grid=pdb_get_group_rid(sam_pass); - DEBUG(10,("get_domain_user_groups: searching domain groups [%s] is a member of\n", user_name)); + const char *username = pdb_get_username(sam_pass); + int n_unix_groups; + int i,j; + gid_t *unix_groups; - /* we must wrap this is become/unbecome root for ldap backends */ + *numgroups = 0; + *pgids = NULL; - become_root(); - /* first get the list of the domain groups */ - ret = pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, &num_entries, ENUM_ONLY_MAPPED); - - unbecome_root(); - - /* end wrapper for group enumeration */ - - - if ( !ret ) + if (!getgroups_user(username, &unix_groups, &n_unix_groups)) { return False; - - DEBUG(10,("get_domain_user_groups: there are %d mapped groups\n", num_entries)); - - - /* - * alloc memory. In the worse case, we alloc memory for nothing. - * but I prefer to alloc for nothing - * than reallocing everytime. - */ - gids = (DOM_GID *)talloc(ctx, sizeof(DOM_GID) * num_entries); + } - /* for each group, check if the user is a member of. Only include groups - from this domain */ + /* now setup the space for storing the SIDS */ - for(i=0; i 0) { - if ( !sid_check_is_in_our_domain(&map[i].sid) ) { - DEBUG(10,("get_domain_user_groups: skipping check of %s since it is not in our domain\n", - map[i].nt_name)); - continue; - } - - if ((grp=getgrgid(map[i].gid)) == NULL) { - /* very weird !!! */ - DEBUG(5,("get_domain_user_groups: gid %d doesn't exist anymore !\n", (int)map[i].gid)); - continue; - } - - for(num=0; grp->gr_mem[num]!=NULL; num++) { - if(strcmp(grp->gr_mem[num], user_name)==0) { - /* we found the user, add the group to the list */ - sid_peek_rid(&map[i].sid, &(gids[cur_gid].g_rid)); - gids[cur_gid].attr=7; - DEBUG(10,("get_domain_user_groups: user found in group %s\n", map[i].nt_name)); - cur_gid++; - break; - } + *pgids = talloc(ctx, sizeof(DOM_GID) * n_unix_groups); + + if (!*pgids) { + DEBUG(0, ("get_user_group: malloc() failed for DOM_GID list!\n")); + SAFE_FREE(unix_groups); + return False; } } - /* we have checked the groups */ - /* we must now check the gid of the user or the primary group rid, that's the same */ - for (i=0; i Date: Mon, 11 Oct 2004 20:01:01 +0000 Subject: r2918: BUG 1907: fix getprinterdriverdir_1(). have to make sure we don't add unnecessary double slashes to the servername (This used to be commit 859599dbcaa9e39a7902cc959955fcea2dad334b) --- source3/rpc_server/srv_spoolss_nt.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index fb498e73ad..a1db4c3854 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7700,13 +7700,22 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen pstring path; pstring long_archi; fstring servername; + char *pservername; const char *short_archi; DRIVER_DIRECTORY_1 *info=NULL; unistr2_to_ascii(servername, name, sizeof(servername)-1); unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); + + /* check for beginning double '\'s and that the server + long enough */ + + pservername = servername; + if ( *pservername == '\\' && strlen(servername)>2 ) { + pservername += 2; + } - if ( !is_myname_or_ipaddr( servername ) ) + if ( !is_myname_or_ipaddr( pservername ) ) return WERR_INVALID_PARAM; if (!(short_archi = get_short_archi(long_archi))) @@ -7715,7 +7724,7 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen if((info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1))) == NULL) return WERR_NOMEM; - slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", servername, short_archi); + slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", pservername, short_archi); DEBUG(4,("printer driver directory: [%s]\n", path)); -- cgit From 7df1ed060be1fe730f78eb4665cdb5f1a3fef0c9 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 13 Oct 2004 19:40:22 +0000 Subject: r2955: fixing a segfault uncovered by the changes for BUG 1519 (This used to be commit 1664395257eb2425246e200ebde4384aa54484a4) --- source3/rpc_server/srv_spoolss_nt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a1db4c3854..c882cea59b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3506,6 +3506,7 @@ static const struct s_notify_info_data_table notify_info_data_table[] = { JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", NOTIFY_ONE_VALUE, spoolss_notify_total_pages }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", NOTIFY_ONE_VALUE, spoolss_notify_pages_printed }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_BYTES, "JOB_NOTIFY_TOTAL_BYTES", NOTIFY_ONE_VALUE, spoolss_notify_job_size }, +{ PRINT_TABLE_END, 0x0, NULL, 0x0, NULL }, }; /******************************************************************* @@ -3571,7 +3572,7 @@ static int search_notify(uint16 type, uint16 field, int *value) { int i; - for (i = 0; i < sizeof(notify_info_data_table); i++) { + for (i = 0; notify_info_data_table[i].type != PRINT_TABLE_END; i++) { if (notify_info_data_table[i].type == type && notify_info_data_table[i].field == field && notify_info_data_table[i].fn != NULL) { -- cgit From c53e6401eb3de7fa4abc85c25f8672b624cf2c66 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 18 Oct 2004 19:57:03 +0000 Subject: r3049: fixing some calls in the printing code to stanard_sub_basic(); fix standard_sub_snum() to use the current user's gid; add some (snum == -1) checks to standard_sub_advanced() (This used to be commit 8c3fd1908d201e9891878ff4c3259ed9690dff97) --- source3/rpc_server/srv_spoolss_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c882cea59b..2bdcfeff4d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2766,7 +2766,7 @@ void spoolss_notify_server_name(int snum, uint32 len; fstrcpy( temp_name, "\\\\%L" ); - standard_sub_basic( NULL, temp_name, sizeof(temp_name)-1 ); + standard_sub_basic( "", temp_name, sizeof(temp_name)-1 ); len = rpcstr_push(temp, temp_name, sizeof(temp)-2, STR_TERMINATE); @@ -6623,7 +6623,7 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u return WERR_BADFID; } - if (!print_job_exists(snum, jobid)) { + if (!print_job_exists(lp_const_servicename(snum), jobid)) { return WERR_INVALID_PRINTER_NAME; } @@ -8640,7 +8640,7 @@ static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, * a failure condition */ - if ( !(nt_devmode=print_job_devmode( snum, jobid )) ) + if ( !(nt_devmode=print_job_devmode( lp_const_servicename(snum), jobid )) ) devmode = construct_dev_mode(snum); else { if ((devmode = (DEVICEMODE *)malloc(sizeof(DEVICEMODE))) != NULL) { -- cgit From 0af8284de1ce411289ec71d5b840a6171b66dc3b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 19 Oct 2004 14:45:48 +0000 Subject: r3065: BUG 1519 (more): apparently the server_name notify request is used to fill in the title bar of the port monitor window and unless we get it right, you cannot open the printer properties from the port monitor window (This used to be commit fc691572c9ba5ae85c63db5202b7777efdbf7260) --- source3/rpc_server/srv_spoolss_nt.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2bdcfeff4d..d096ed4021 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2750,8 +2750,6 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE return WERR_OK; } -#if 0 /* JERRY -- disabled; not used for now */ - /******************************************************************* * fill a notify_info_data with the servername ********************************************************************/ @@ -2762,14 +2760,10 @@ void spoolss_notify_server_name(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - pstring temp_name, temp; + pstring temp; uint32 len; - fstrcpy( temp_name, "\\\\%L" ); - standard_sub_basic( "", temp_name, sizeof(temp_name)-1 ); - - - len = rpcstr_push(temp, temp_name, sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push(temp, printer->info_2->servername, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); @@ -2782,9 +2776,6 @@ void spoolss_notify_server_name(int snum, memcpy(data->notify_data.data.string, temp, len); } -#endif - - /******************************************************************* * fill a notify_info_data with the printername (not including the servername). ********************************************************************/ @@ -3457,7 +3448,7 @@ struct s_notify_info_data_table static const struct s_notify_info_data_table notify_info_data_table[] = { -{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", NOTIFY_STRING, NULL}, +{ PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SERVER_NAME, "PRINTER_NOTIFY_SERVER_NAME", NOTIFY_STRING, spoolss_notify_server_name }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME, "PRINTER_NOTIFY_PRINTER_NAME", NOTIFY_STRING, spoolss_notify_printer_name }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SHARE_NAME, "PRINTER_NOTIFY_SHARE_NAME", NOTIFY_STRING, spoolss_notify_share_name }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PORT_NAME, "PRINTER_NOTIFY_PORT_NAME", NOTIFY_STRING, spoolss_notify_port_name }, @@ -3484,7 +3475,7 @@ static const struct s_notify_info_data_table notify_info_data_table[] = { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_TOTAL_BYTES, "PRINTER_NOTIFY_TOTAL_BYTES", NOTIFY_POINTER, NULL }, { PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_BYTES_PRINTED, "PRINTER_NOTIFY_BYTES_PRINTED", NOTIFY_POINTER, NULL }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_PRINTER_NAME, "JOB_NOTIFY_PRINTER_NAME", NOTIFY_STRING, spoolss_notify_printer_name }, -{ JOB_NOTIFY_TYPE, JOB_NOTIFY_MACHINE_NAME, "JOB_NOTIFY_MACHINE_NAME", NOTIFY_STRING, NULL}, +{ JOB_NOTIFY_TYPE, JOB_NOTIFY_MACHINE_NAME, "JOB_NOTIFY_MACHINE_NAME", NOTIFY_STRING, spoolss_notify_server_name }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_PORT_NAME, "JOB_NOTIFY_PORT_NAME", NOTIFY_STRING, spoolss_notify_port_name }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_USER_NAME, "JOB_NOTIFY_USER_NAME", NOTIFY_STRING, spoolss_notify_username }, { JOB_NOTIFY_TYPE, JOB_NOTIFY_NOTIFY_NAME, "JOB_NOTIFY_NOTIFY_NAME", NOTIFY_STRING, spoolss_notify_username }, -- cgit From f2aca08c653a61dc4d6e99263dda7b649ef648b0 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 19 Oct 2004 16:17:23 +0000 Subject: r3066: BUG 1519: fix segfault caused by double free of a printer (This used to be commit 3760464193c540e82f0ba4e61d1d3b96a9803aca) --- source3/rpc_server/srv_spoolss_nt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d096ed4021..2d230b07bb 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8663,7 +8663,6 @@ static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, free_job_info_2(info_2); /* Also frees devmode */ SAFE_FREE(info_2); - free_a_printer(&ntprinter, 2); return ret; } -- cgit From 4e18fa46d54b65a2145da769cb5e26b63eee1b1d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 19 Oct 2004 22:13:08 +0000 Subject: r3069: add 'force printername' service parameter for people that want to enforce printername == sharename for spoolss printing (This used to be commit d47b8a0b4f348171df35b3b0028ce7d99fab8af3) --- source3/rpc_server/srv_spoolss_nt.c | 44 +++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2d230b07bb..fad5555cea 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -529,12 +529,20 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) } } + /* do another loop to look for printernames */ for (snum=0; !found && snumservername, sizeof(info->servername)-1, "\\\\%s", global_myname()); fstrcpy(info->sharename, lp_servicename(snum)); - /* make sure printername is in \\server\printername format */ + /* check to see if we allow printername != sharename */ + + if ( lp_force_printername(snum) ) { + slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s", + global_myname(), info->sharename ); + } else { + + /* make sure printername is in \\server\printername format */ - fstrcpy( printername, info->printername ); - p = printername; - if ( printername[0] == '\\' && printername[1] == '\\' ) { - if ( (p = strchr_m( &printername[2], '\\' )) != NULL ) - p++; + fstrcpy( printername, info->printername ); + p = printername; + if ( printername[0] == '\\' && printername[1] == '\\' ) { + if ( (p = strchr_m( &printername[2], '\\' )) != NULL ) + p++; + } + + slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s", + global_myname(), p ); } - - slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s", - global_myname(), p ); - + info->attributes |= PRINTER_ATTRIBUTE_SAMBA; info->attributes &= ~PRINTER_ATTRIBUTE_NOT_SAMBA; -- cgit From 154d5f913b4ce60f731227eb1bb3650c45fcde93 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 5 Nov 2004 23:34:00 +0000 Subject: r3566: Completely replace the queryuseraliases call. The previous implementation does not exactly match what you would expect. XP workstations during login actually do this, so we should better become a bit more correct. The LDAP query issued is not really fully optimal, but it is a lot faster and more correct than what was there before. The change in passdb.h makes it possible that queryuseraliases is done with a single ldap query. Volker (This used to be commit 2508d4ed1e16c268fc9f3676b0c6a122e070f93d) --- source3/rpc_server/srv_samr_nt.c | 79 ++++++++---------- source3/rpc_server/srv_util.c | 175 --------------------------------------- 2 files changed, 35 insertions(+), 219 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 37617db5e8..f4348fc83e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3119,31 +3119,19 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, SAMR_R_QUERY_USERALIASES *r_u) { - int num_groups = 0, tmp_num_groups=0; - uint32 *rids=NULL, *new_rids=NULL, *tmp_rids=NULL; + int num_groups = 0; + uint32 *rids=NULL; struct samr_info *info = NULL; - int i,j; + int i; NTSTATUS ntstatus1; NTSTATUS ntstatus2; - /* until i see a real useraliases query, we fack one up */ + DOM_SID *members; + DOM_SID *aliases; + int num_aliases; + BOOL res; - /* I have seen one, JFM 2/12/2001 */ - /* - * Explanation of what this call does: - * for all the SID given in the request: - * return a list of alias (local groups) - * that have those SID as members. - * - * and that's the alias in the domain specified - * in the policy_handle - * - * if the policy handle is on an incorrect sid - * for example a user's sid - * we should reply NT_STATUS_OBJECT_TYPE_MISMATCH - */ - r_u->status = NT_STATUS_OK; DEBUG(5,("_samr_query_useraliases: %d\n", __LINE__)); @@ -3166,40 +3154,43 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, !sid_check_is_builtin(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; + members = talloc(p->mem_ctx, sizeof(DOM_SID) * q_u->num_sids1); - for (i=0; inum_sids1; i++) { + if (members == NULL) + return NT_STATUS_NO_MEMORY; - r_u->status=get_alias_user_groups(p->mem_ctx, &info->sid, &tmp_num_groups, &tmp_rids, &(q_u->sid[i].sid)); + for (i=0; inum_sids1; i++) + sid_copy(&members[i], &q_u->sid[i].sid); - /* - * if there is an error, we just continue as - * it can be an unfound user or group - */ - if (!NT_STATUS_IS_OK(r_u->status)) { - DEBUG(10,("_samr_query_useraliases: an error occured while getting groups\n")); - continue; - } + become_root(); + res = pdb_enum_alias_memberships(members, + q_u->num_sids1, &aliases, + &num_aliases); + unbecome_root(); + + if (!res) + return NT_STATUS_UNSUCCESSFUL; - if (tmp_num_groups==0) { - DEBUG(10,("_samr_query_useraliases: no groups found\n")); + rids = NULL; + num_groups = 0; + + for (i=0; isid, &aliases[i], &rid)) continue; - } - new_rids=(uint32 *)talloc_realloc(p->mem_ctx, rids, (num_groups+tmp_num_groups)*sizeof(uint32)); - if (new_rids==NULL) { - DEBUG(0,("_samr_query_useraliases: could not realloc memory\n")); + rids = talloc_realloc(p->mem_ctx, rids, + sizeof(*rids) * (num_groups+1)); + + if (rids == NULL) return NT_STATUS_NO_MEMORY; - } - rids=new_rids; - for (j=0; j= winbind_gid_low) && (groups[i] <= winbind_gid_high)) { - DEBUG(10,("get_alias_user_groups: not returing %s, not local.\n", map.nt_name)); - continue; - } - - /* Don't return user private groups... */ - if (Get_Pwnam(map.nt_name) != 0) { - DEBUG(10,("get_alias_user_groups: not returing %s, clashes with user.\n", map.nt_name)); - continue; - } - - new_rids=(uint32 *)Realloc(rids, sizeof(uint32)*(cur_rid+1)); - if (new_rids==NULL) { - DEBUG(10,("get_alias_user_groups: could not realloc memory\n")); - pdb_free_sam(&sam_pass); - free(groups); - return NT_STATUS_NO_MEMORY; - } - rids=new_rids; - - sid_peek_rid(&map.sid, &(rids[cur_rid])); - cur_rid++; - break; - } - - if(num_groups) - free(groups); - - /* now check for the user's gid (the primary group rid) */ - for (i=0; i= winbind_gid_low) && (gid <= winbind_gid_high)) { - DEBUG(10,("get_alias_user_groups: not returing %s, not local.\n", map.nt_name )); - goto done; - } - - /* Don't return user private groups... */ - if (Get_Pwnam(map.nt_name) != 0) { - DEBUG(10,("get_alias_user_groups: not returing %s, clashes with user.\n", map.nt_name )); - goto done; - } - - new_rids=(uint32 *)Realloc(rids, sizeof(uint32)*(cur_rid+1)); - if (new_rids==NULL) { - DEBUG(10,("get_alias_user_groups: could not realloc memory\n")); - pdb_free_sam(&sam_pass); - return NT_STATUS_NO_MEMORY; - } - rids=new_rids; - - sid_peek_rid(&map.sid, &(rids[cur_rid])); - cur_rid++; - -done: - *prids=rids; - *numgroups=cur_rid; - pdb_free_sam(&sam_pass); - - return NT_STATUS_OK; -} - - /******************************************************************* gets a domain user's groups ********************************************************************/ -- cgit From f9e87b9ba65f37bafa45eacb1a6c9b8c5483d46b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 12 Nov 2004 15:49:47 +0000 Subject: r3705: Nobody has commented, so I'll take this as an ack... abartlet, I'd like to ask you to take a severe look at this! We have solved the problem to find the global groups a user is in twice: Once in auth_util.c and another time for the corresponding samr call. The attached patch unifies these and sends them through the passdb backend (new function pdb_enum_group_memberships). Thus it gives pdb_ldap.c the chance to further optimize the corresponding call if the samba and posix accounts are unified by issuing a specialized ldap query. The parameter to activate this ldapsam behaviour is ldapsam:trusted = yes Volker (This used to be commit b94838aff1a009f8d8c2c3efd48756a5b8f3f989) --- source3/rpc_server/srv_samr_nt.c | 49 +++++++++++++++++++++++++++++---- source3/rpc_server/srv_util.c | 59 ---------------------------------------- 2 files changed, 44 insertions(+), 64 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f4348fc83e..0c52e859ca 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1943,11 +1943,16 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAMR_R_QUERY_USERGROUPS *r_u) { SAM_ACCOUNT *sam_pass=NULL; + struct passwd *passwd; DOM_SID sid; + DOM_SID *sids; DOM_GID *gids = NULL; int num_groups = 0; + gid_t *unix_gids; + int i, num_gids, num_sids; uint32 acc_granted; BOOL ret; + NTSTATUS result; /* * from the SID in the request: @@ -1986,19 +1991,53 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } - - if(!get_domain_user_groups(p->mem_ctx, &num_groups, &gids, sam_pass)) { + + passwd = getpwnam_alloc(pdb_get_username(sam_pass)); + if (passwd == NULL) { pdb_free_sam(&sam_pass); - return NT_STATUS_NO_SUCH_GROUP; + return NT_STATUS_NO_SUCH_USER; } + + sids = NULL; + num_sids = 0; + + become_root(); + result = pdb_enum_group_memberships(pdb_get_username(sam_pass), + passwd->pw_gid, + &sids, &unix_gids, &num_groups); + unbecome_root(); + + pdb_free_sam(&sam_pass); + passwd_free(&passwd); + + if (!NT_STATUS_IS_OK(result)) + return result; + + SAFE_FREE(unix_gids); + + gids = NULL; + num_gids = 0; + + for (i=0; imem_ctx, gids, + sizeof(*gids) * (num_gids+1)); + gids[num_gids].attr=7; + gids[num_gids].g_rid = rid; + num_gids += 1; + } + SAFE_FREE(sids); /* 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__)); - pdb_free_sam(&sam_pass); - return r_u->status; } diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 215471b444..2689d89972 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -79,65 +79,6 @@ static const rid_name domain_group_rids[] = { 0 , NULL } }; -/******************************************************************* - gets a domain user's groups - ********************************************************************/ -BOOL get_domain_user_groups(TALLOC_CTX *ctx, int *numgroups, DOM_GID **pgids, SAM_ACCOUNT *sam_pass) -{ - - const char *username = pdb_get_username(sam_pass); - int n_unix_groups; - int i,j; - gid_t *unix_groups; - - *numgroups = 0; - *pgids = NULL; - - if (!getgroups_user(username, &unix_groups, &n_unix_groups)) { - return False; - } - - /* now setup the space for storing the SIDS */ - - if (n_unix_groups > 0) { - - *pgids = talloc(ctx, sizeof(DOM_GID) * n_unix_groups); - - if (!*pgids) { - DEBUG(0, ("get_user_group: malloc() failed for DOM_GID list!\n")); - SAFE_FREE(unix_groups); - return False; - } - } - - become_root(); - j = 0; - for (i = 0; i < n_unix_groups; i++) { - GROUP_MAP map; - uint32 rid; - - if (!pdb_getgrgid(&map, unix_groups[i])) { - DEBUG(3, ("get_user_groups: failed to convert gid %ld to a domain group!\n", - (long int)unix_groups[i+1])); - if (i == 0) { - DEBUG(1,("get_domain_user_groups: primary gid of user [%s] is not a Domain group !\n", username)); - DEBUGADD(1,("get_domain_user_groups: You should fix it, NT doesn't like that\n")); - } - } else if ((map.sid_name_use == SID_NAME_DOM_GRP) - && sid_peek_check_rid(get_global_sam_sid(), &map.sid, &rid)) { - (*pgids)[j].attr=7; - (*pgids)[j].g_rid=rid; - j++; - } - } - unbecome_root(); - - *numgroups = j; - - SAFE_FREE(unix_groups); - - return True; -} /******************************************************************* gets a domain user's groups from their already-calculated NT_USER_TOKEN -- cgit From 7c93bdcdf8334d4f2140405a982ea02943c5553c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 19 Nov 2004 13:26:17 +0000 Subject: r3875: Allow to look up at least or own sid in _lsa_lookup_sids. This fixes Bugzilla #1076 and Exchange 5.5 SP4 can then be finally installed on NT4 in a samba-controlled domain. Guenther (This used to be commit bb191c1098dea06bf2cd89276c74e32279fbb3d4) --- source3/rpc_server/srv_lsa_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 6c3157d5c9..498b83a4c9 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -281,8 +281,8 @@ static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME } dom_idx = init_dom_ref(ref, dom_name, &find_sid); - DEBUG(10,("init_lsa_trans_names: added user '%s\\%s' to " - "referenced list.\n", dom_name, name )); + DEBUG(10,("init_lsa_trans_names: added %s '%s\\%s' (%d) to referenced list.\n", + sid_type_lookup(sid_name_use), dom_name, name, sid_name_use )); } -- cgit From b321a8a9ad5d2b8e276c97a4a057c5fbef8b5ff7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 23 Nov 2004 23:13:48 +0000 Subject: r3929: Dead code elimination fix for bug #2075 from jason@ncac.gwu.edu. Jeremy. (This used to be commit 9d367ac636d7d88cd4756531bd8412f8d6d16d14) --- source3/rpc_server/srv_srvsvc_nt.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 54cc0d6161..9837ea2a97 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -356,15 +356,12 @@ out: static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum) { - int len_net_name; pstring remark; - char *net_name = lp_servicename(snum); + const char *net_name = lp_servicename(snum); pstrcpy(remark, lp_comment(snum)); standard_sub_conn(p->conn, remark, sizeof(remark)); - len_net_name = strlen(net_name); - init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), remark, (lp_csc_policy(snum) << 4)); init_srv_share_info501_str(&sh501->info_501_str, net_name, remark); } @@ -375,7 +372,6 @@ static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, int snum) { - int len_net_name; pstring net_name; pstring remark; pstring path; @@ -401,7 +397,6 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, string_replace(path, '/', '\\'); pstrcpy(passwd, ""); - len_net_name = strlen(net_name); sd = get_share_security(ctx, snum, &sd_size); -- cgit From 3bd3be97dc8a581c0502410453091c195e322766 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 6 Dec 2004 19:25:25 +0000 Subject: r4083: consolidate printer searches to use find_service rather than for loops (This used to be commit 12440744ba36445186042c8c254785766cce5385) --- source3/rpc_server/srv_spoolss_nt.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index fad5555cea..aba7e6c22f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -512,24 +512,14 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) /* Search all sharenames first as this is easier than pulling the printer_info_2 off of disk */ - - for (snum=0; !found && snum Date: Tue, 7 Dec 2004 18:25:53 +0000 Subject: r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a) --- source3/rpc_server/srv_dfs_nt.c | 15 ++-- source3/rpc_server/srv_echo_nt.c | 4 +- source3/rpc_server/srv_lsa_ds_nt.c | 2 +- source3/rpc_server/srv_lsa_hnd.c | 4 +- source3/rpc_server/srv_lsa_nt.c | 28 +++--- source3/rpc_server/srv_netlog_nt.c | 2 +- source3/rpc_server/srv_pipe.c | 21 ++--- source3/rpc_server/srv_pipe_hnd.c | 8 +- source3/rpc_server/srv_reg_nt.c | 4 +- source3/rpc_server/srv_samr_nt.c | 81 ++++++++--------- source3/rpc_server/srv_spoolss_nt.c | 174 ++++++++++++++++++------------------ source3/rpc_server/srv_srvsvc_nt.c | 83 +++++++++-------- source3/rpc_server/srv_util.c | 2 +- source3/rpc_server/srv_wkssvc_nt.c | 2 +- 14 files changed, 211 insertions(+), 219 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index a3b06bb6e1..7334eef85b 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -81,9 +81,7 @@ WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) vfs_ChDir(p->conn,p->conn->connectpath); - jn.referral_list = (struct referral*) talloc(p->mem_ctx, jn.referral_count - * sizeof(struct referral)); - + jn.referral_list = TALLOC_ARRAY(p->mem_ctx, struct referral, jn.referral_count); if(jn.referral_list == NULL) { DEBUG(0,("init_reply_dfs_add: talloc failed for referral list!\n")); return WERR_DFS_INTERNAL_ERROR; @@ -245,8 +243,7 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_I dfs3[i].ptr_storages = 1; /* also enumerate the storages */ - dfs3[i].storages = (DFS_STORAGE_INFO*) talloc(ctx, j[i].referral_count * - sizeof(DFS_STORAGE_INFO)); + dfs3[i].storages = TALLOC_ARRAY(ctx, DFS_STORAGE_INFO, j[i].referral_count); if (!dfs3[i].storages) return False; @@ -285,7 +282,7 @@ static WERROR init_reply_dfs_ctr(TALLOC_CTX *ctx, uint32 level, case 1: { DFS_INFO_1* dfs1; - dfs1 = (DFS_INFO_1*) talloc(ctx, num_jn * sizeof(DFS_INFO_1)); + dfs1 = TALLOC_ARRAY(ctx, DFS_INFO_1, num_jn); if (!dfs1) return WERR_NOMEM; init_reply_dfs_info_1(jn, dfs1, num_jn); @@ -295,7 +292,7 @@ static WERROR init_reply_dfs_ctr(TALLOC_CTX *ctx, uint32 level, case 2: { DFS_INFO_2* dfs2; - dfs2 = (DFS_INFO_2*) talloc(ctx, num_jn * sizeof(DFS_INFO_2)); + dfs2 = TALLOC_ARRAY(ctx, DFS_INFO_2, num_jn); if (!dfs2) return WERR_NOMEM; init_reply_dfs_info_2(jn, dfs2, num_jn); @@ -305,7 +302,7 @@ static WERROR init_reply_dfs_ctr(TALLOC_CTX *ctx, uint32 level, case 3: { DFS_INFO_3* dfs3; - dfs3 = (DFS_INFO_3*) talloc(ctx, num_jn * sizeof(DFS_INFO_3)); + dfs3 = TALLOC_ARRAY(ctx, DFS_INFO_3, num_jn); if (!dfs3) return WERR_NOMEM; init_reply_dfs_info_3(ctx, jn, dfs3, num_jn); @@ -336,7 +333,7 @@ WERROR _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u) r_u->reshnd.ptr_hnd = 1; r_u->reshnd.handle = num_jn; - r_u->ctr = (DFS_INFO_CTR*)talloc(p->mem_ctx, sizeof(DFS_INFO_CTR)); + r_u->ctr = TALLOC_P(p->mem_ctx, DFS_INFO_CTR); if (!r_u->ctr) return WERR_NOMEM; ZERO_STRUCTP(r_u->ctr); diff --git a/source3/rpc_server/srv_echo_nt.c b/source3/rpc_server/srv_echo_nt.c index ddb76b3a21..86fcce28c7 100644 --- a/source3/rpc_server/srv_echo_nt.c +++ b/source3/rpc_server/srv_echo_nt.c @@ -44,7 +44,7 @@ void _echo_data(pipes_struct *p, ECHO_Q_ECHO_DATA *q_u, { DEBUG(10, ("_echo_data\n")); - r_u->data = talloc(p->mem_ctx, q_u->size); + r_u->data = TALLOC(p->mem_ctx, q_u->size); r_u->size = q_u->size; memcpy(r_u->data, q_u->data, q_u->size); } @@ -68,7 +68,7 @@ void _source_data(pipes_struct *p, ECHO_Q_SOURCE_DATA *q_u, DEBUG(10, ("_source_data\n")); - r_u->data = talloc(p->mem_ctx, q_u->size); + r_u->data = TALLOC(p->mem_ctx, q_u->size); r_u->size = q_u->size; for (i = 0; i < r_u->size; i++) diff --git a/source3/rpc_server/srv_lsa_ds_nt.c b/source3/rpc_server/srv_lsa_ds_nt.c index f6e8eed9a9..d0b7a299be 100644 --- a/source3/rpc_server/srv_lsa_ds_nt.c +++ b/source3/rpc_server/srv_lsa_ds_nt.c @@ -41,7 +41,7 @@ static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN DEBUG(10,("fill_dsrole_dominfo_basic: enter\n")); - if ( !(basic = talloc_zero(ctx, sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC))) ) { + if ( !(basic = TALLOC_ZERO_P(ctx, DSROLE_PRIMARY_DOMAIN_INFO_BASIC)) ) { DEBUG(0,("fill_dsrole_dominfo_basic: FATAL error! talloc_xero() failed\n")); return NT_STATUS_NO_MEMORY; } diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 2ec62e2c57..0f9f239a02 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -70,7 +70,7 @@ BOOL init_pipe_handle_list(pipes_struct *p, char *pipe_name) * Create list. */ - if ((hl = (struct handle_list *)malloc(sizeof(struct handle_list))) == NULL) + if ((hl = SMB_MALLOC_P(struct handle_list)) == NULL) return False; ZERO_STRUCTP(hl); @@ -112,7 +112,7 @@ BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *) return False; } - pol = (struct policy *)malloc(sizeof(*p)); + pol = SMB_MALLOC_P(struct policy); if (!pol) { DEBUG(0,("create_policy_hnd: ERROR: out of memory!\n")); return False; diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 498b83a4c9..fcd574971f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -232,14 +232,12 @@ static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME /* Allocate memory for list of names */ if (num_entries > 0) { - if (!(trn->name = (LSA_TRANS_NAME *)talloc(ctx, sizeof(LSA_TRANS_NAME) * - num_entries))) { + if (!(trn->name = TALLOC_ARRAY(ctx, LSA_TRANS_NAME, num_entries))) { DEBUG(0, ("init_lsa_trans_names(): out of memory\n")); return; } - if (!(trn->uni_name = (UNISTR2 *)talloc(ctx, sizeof(UNISTR2) * - num_entries))) { + if (!(trn->uni_name = TALLOC_ARRAY(ctx, UNISTR2, num_entries))) { DEBUG(0, ("init_lsa_trans_names(): out of memory\n")); return; } @@ -418,7 +416,7 @@ NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL /* associate the domain SID with the (unique) handle. */ - if ((info = (struct lsa_info *)malloc(sizeof(struct lsa_info))) == NULL) + if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL) return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(info); @@ -463,7 +461,7 @@ NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL * } /* associate the domain SID with the (unique) handle. */ - if ((info = (struct lsa_info *)malloc(sizeof(struct lsa_info))) == NULL) + if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL) return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(info); @@ -550,7 +548,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF info->id2.auditing_enabled = 1; info->id2.count1 = 7; info->id2.count2 = 7; - if ((info->id2.auditsettings = (uint32 *)talloc(p->mem_ctx,7*sizeof(uint32))) == NULL) + if ((info->id2.auditsettings = TALLOC_ARRAY(p->mem_ctx,uint32, 7)) == NULL) return NT_STATUS_NO_MEMORY; for (i = 0; i < 7; i++) info->id2.auditsettings[i] = 3; @@ -649,8 +647,8 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_ DEBUG(5,("_lsa_lookup_sids: truncating SID lookup list to %d\n", num_entries)); } - ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); - names = (LSA_TRANS_NAME_ENUM *)talloc_zero(p->mem_ctx, sizeof(LSA_TRANS_NAME_ENUM)); + ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); + names = TALLOC_ZERO_P(p->mem_ctx, LSA_TRANS_NAME_ENUM); if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) { r_u->status = NT_STATUS_INVALID_HANDLE; @@ -698,8 +696,8 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries)); } - ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF)); - rids = (DOM_RID2 *)talloc_zero(p->mem_ctx, sizeof(DOM_RID2)*num_entries); + ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); + rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries); if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) { r_u->status = NT_STATUS_INVALID_HANDLE; @@ -768,7 +766,7 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV if (enum_context >= PRIV_ALL_INDEX) return NT_STATUS_NO_MORE_ENTRIES; - entries = (LSA_PRIV_ENTRY *)talloc_zero(p->mem_ctx, sizeof(LSA_PRIV_ENTRY) * (PRIV_ALL_INDEX)); + entries = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_PRIV_ENTRY, PRIV_ALL_INDEX); if (entries==NULL) return NT_STATUS_NO_MEMORY; @@ -887,8 +885,8 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU if (q_u->enum_context >= num_entries) return NT_STATUS_NO_MORE_ENTRIES; - sids->ptr_sid = (uint32 *)talloc_zero(p->mem_ctx, (num_entries-q_u->enum_context)*sizeof(uint32)); - sids->sid = (DOM_SID2 *)talloc_zero(p->mem_ctx, (num_entries-q_u->enum_context)*sizeof(DOM_SID2)); + sids->ptr_sid = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_entries-q_u->enum_context); + sids->sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_entries-q_u->enum_context); if (sids->ptr_sid==NULL || sids->sid==NULL) { SAFE_FREE(map); @@ -960,7 +958,7 @@ NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENAC return NT_STATUS_ACCESS_DENIED; /* associate the user/group SID with the (unique) handle. */ - if ((info = (struct lsa_info *)malloc(sizeof(struct lsa_info))) == NULL) + if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL) return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(info); diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index a3157435f3..2bc0cf301e 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -579,7 +579,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * SAM_ACCOUNT *sampw; struct auth_context *auth_context = NULL; - usr_info = (NET_USER_INFO_3 *)talloc(p->mem_ctx, sizeof(NET_USER_INFO_3)); + usr_info = TALLOC_P(p->mem_ctx, NET_USER_INFO_3); if (!usr_info) return NT_STATUS_NO_MEMORY; diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index bcf5eb533f..01e91ce6c5 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -775,7 +775,7 @@ BOOL check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, int n_fns = 0; PIPE_RPC_FNS *context_fns; - if ( !(context_fns = malloc(sizeof(PIPE_RPC_FNS))) ) { + if ( !(context_fns = SMB_MALLOC_P(PIPE_RPC_FNS)) ) { DEBUG(0,("check_bind_req: malloc() failed!\n")); return False; } @@ -831,8 +831,8 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *s /* We use a temporary variable because this call can fail and rpc_lookup will still be valid afterwards. It could then succeed if called again later */ - rpc_entry = realloc(rpc_lookup, - ++rpc_lookup_size*sizeof(struct rpc_table)); + rpc_lookup_size++; + rpc_entry = SMB_REALLOC_ARRAY(rpc_lookup, struct rpc_table, rpc_lookup_size); if (NULL == rpc_entry) { rpc_lookup_size--; DEBUG(0, ("rpc_pipe_register_commands: memory allocation failed\n")); @@ -843,13 +843,10 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *s rpc_entry = rpc_lookup + (rpc_lookup_size - 1); ZERO_STRUCTP(rpc_entry); - rpc_entry->pipe.clnt = strdup(clnt); - rpc_entry->pipe.srv = strdup(srv); - rpc_entry->cmds = realloc(rpc_entry->cmds, - (rpc_entry->n_cmds + size) * - sizeof(struct api_struct)); - memcpy(rpc_entry->cmds + rpc_entry->n_cmds, cmds, - size * sizeof(struct api_struct)); + rpc_entry->pipe.clnt = SMB_STRDUP(clnt); + rpc_entry->pipe.srv = SMB_STRDUP(srv); + rpc_entry->cmds = SMB_REALLOC_ARRAY(rpc_entry->cmds, struct api_struct, rpc_entry->n_cmds + size); + memcpy(rpc_entry->cmds + rpc_entry->n_cmds, cmds, size * sizeof(struct api_struct)); rpc_entry->n_cmds += size; return NT_STATUS_OK; @@ -1585,9 +1582,7 @@ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, if ((DEBUGLEVEL >= 10) && (prs_offset(&p->in_data.data) != prs_data_size(&p->in_data.data))) { size_t data_len = prs_data_size(&p->in_data.data) - prs_offset(&p->in_data.data); - char *data; - - data = malloc(data_len); + char *data = SMB_MALLOC(data_len); DEBUG(10, ("api_rpcTNP: rpc input buffer underflow (parse error?)\n")); if (data) { diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 562b55b8f7..8720a4df68 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -204,8 +204,7 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, for (p = Pipes; p; p = p->next) DEBUG(5,("open_rpc_pipe_p: name %s pnum=%x\n", p->name, p->pnum)); - p = (smb_np_struct *)malloc(sizeof(*p)); - + p = SMB_MALLOC_P(smb_np_struct); if (!p) { DEBUG(0,("ERROR! no memory for pipes_struct!\n")); return NULL; @@ -283,10 +282,9 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, return NULL; } - p = (pipes_struct *)malloc(sizeof(*p)); + p = SMB_MALLOC_P(pipes_struct); - if (!p) - { + if (!p) { DEBUG(0,("ERROR! no memory for pipes_struct!\n")); return NULL; } diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index a4e3638be6..dc9db47c66 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -97,7 +97,7 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY if ( subkey_len && subkeyname2[subkey_len-1] == '\\' ) subkeyname2[subkey_len-1] = '\0'; - if ((regkey=(REGISTRY_KEY*)malloc(sizeof(REGISTRY_KEY))) == NULL) + if ((regkey=SMB_MALLOC_P(REGISTRY_KEY)) == NULL) return NT_STATUS_NO_MEMORY; ZERO_STRUCTP( regkey ); @@ -373,7 +373,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) /* couple of hard coded registry values */ if ( strequal(name, "RefusePasswordChange") ) { - if ( (val = (REGISTRY_VALUE*)malloc(sizeof(REGISTRY_VALUE))) == NULL ) { + if ( (val = SMB_MALLOC_P(REGISTRY_VALUE)) == NULL ) { DEBUG(0,("_reg_info: malloc() failed!\n")); return NT_STATUS_NO_MEMORY; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 0c52e859ca..5f74df420a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -137,7 +137,7 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) mem_ctx = talloc_init("samr_info for domain sid %s", sid_str); - if ((info = (struct samr_info *)talloc(mem_ctx, sizeof(struct samr_info))) == NULL) + if ((info = TALLOC_P(mem_ctx, struct samr_info)) == NULL) return NULL; ZERO_STRUCTP(info); @@ -255,8 +255,8 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOO if (info->disp_info.num_user_account % MAX_SAM_ENTRIES == 0) { DEBUG(10,("load_sampwd_entries: allocating more memory\n")); - pwd_array=(SAM_ACCOUNT *)talloc_realloc(mem_ctx, info->disp_info.disp_user_info, - (info->disp_info.num_user_account+MAX_SAM_ENTRIES)*sizeof(SAM_ACCOUNT)); + pwd_array=TALLOC_REALLOC_ARRAY(mem_ctx, info->disp_info.disp_user_info, SAM_ACCOUNT, + info->disp_info.num_user_account+MAX_SAM_ENTRIES); if (pwd_array==NULL) return NT_STATUS_NO_MEMORY; @@ -322,7 +322,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) info->disp_info.num_group_account=group_entries; - grp_array=(DOMAIN_GRP *)talloc(mem_ctx, info->disp_info.num_group_account*sizeof(DOMAIN_GRP)); + grp_array=TALLOC_ARRAY(mem_ctx, DOMAIN_GRP, info->disp_info.num_group_account); if (group_entries!=0 && grp_array==NULL) { DEBUG(1, ("load_group_domain_entries: talloc() failed for grp_array!\n")); SAFE_FREE(map); @@ -716,9 +716,9 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UN if (num_entries == 0) return NT_STATUS_OK; - sam = (SAM_ENTRY *)talloc_zero(ctx, sizeof(SAM_ENTRY)*num_entries); + sam = TALLOC_ZERO_ARRAY(ctx, SAM_ENTRY, num_entries); - uni_name = (UNISTR2 *)talloc_zero(ctx, sizeof(UNISTR2)*num_entries); + uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_entries); if (sam == NULL || uni_name == NULL) { DEBUG(0, ("make_user_sam_entry_list: talloc_zero failed!\n")); @@ -871,9 +871,8 @@ 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_zero(ctx, sizeof(SAM_ENTRY)*num_sam_entries); - - uni_name = (UNISTR2 *)talloc_zero(ctx, sizeof(UNISTR2)*num_sam_entries); + sam = TALLOC_ZERO_ARRAY(ctx, SAM_ENTRY, num_sam_entries); + uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_sam_entries); if (sam == NULL || uni_name == NULL) { DEBUG(0, ("NULL pointers in SAMR_R_QUERY_DISPINFO\n")); @@ -923,7 +922,7 @@ static NTSTATUS get_group_domain_entries( TALLOC_CTX *ctx, num_entries=max_entries; } - *d_grp=(DOMAIN_GRP *)talloc_zero(ctx, num_entries*sizeof(DOMAIN_GRP)); + *d_grp=TALLOC_ZERO_ARRAY(ctx, DOMAIN_GRP, num_entries); if (num_entries!=0 && *d_grp==NULL){ SAFE_FREE(map); return NT_STATUS_NO_MEMORY; @@ -969,7 +968,7 @@ static NTSTATUS get_alias_entries( TALLOC_CTX *ctx, DOMAIN_GRP **d_grp, if (*p_num_entries == 0) return NT_STATUS_OK; - *d_grp = talloc(ctx, sizeof(DOMAIN_GRP) * (*p_num_entries)); + *d_grp = TALLOC_ARRAY(ctx, DOMAIN_GRP, *p_num_entries); if (*d_grp == NULL) { SAFE_FREE(info); @@ -1187,7 +1186,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, DEBUG(5, ("samr_reply_query_dispinfo: buffer size limits to only %d entries\n", max_entries)); } - if (!(ctr = (SAM_DISPINFO_CTR *)talloc_zero(p->mem_ctx,sizeof(SAM_DISPINFO_CTR)))) + if (!(ctr = TALLOC_ZERO_P(p->mem_ctx,SAM_DISPINFO_CTR))) return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(ctr); @@ -1196,7 +1195,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, switch (q_u->switch_level) { case 0x1: if (max_entries) { - if (!(ctr->sam.info1 = (SAM_DISPINFO_1 *)talloc_zero(p->mem_ctx,max_entries*sizeof(SAM_DISPINFO_1)))) + if (!(ctr->sam.info1 = TALLOC_ZERO_ARRAY(p->mem_ctx,SAM_DISPINFO_1,max_entries))) return NT_STATUS_NO_MEMORY; } disp_ret = init_sam_dispinfo_1(p->mem_ctx, ctr->sam.info1, max_entries, enum_context, @@ -1206,7 +1205,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, break; case 0x2: if (max_entries) { - if (!(ctr->sam.info2 = (SAM_DISPINFO_2 *)talloc_zero(p->mem_ctx,max_entries*sizeof(SAM_DISPINFO_2)))) + if (!(ctr->sam.info2 = TALLOC_ZERO_ARRAY(p->mem_ctx,SAM_DISPINFO_2,max_entries))) return NT_STATUS_NO_MEMORY; } disp_ret = init_sam_dispinfo_2(p->mem_ctx, ctr->sam.info2, max_entries, enum_context, @@ -1216,7 +1215,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, break; case 0x3: if (max_entries) { - if (!(ctr->sam.info3 = (SAM_DISPINFO_3 *)talloc_zero(p->mem_ctx,max_entries*sizeof(SAM_DISPINFO_3)))) + if (!(ctr->sam.info3 = TALLOC_ZERO_ARRAY(p->mem_ctx,SAM_DISPINFO_3,max_entries))) return NT_STATUS_NO_MEMORY; } disp_ret = init_sam_dispinfo_3(p->mem_ctx, ctr->sam.info3, max_entries, enum_context, info->disp_info.disp_group_info); @@ -1225,7 +1224,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, break; case 0x4: if (max_entries) { - if (!(ctr->sam.info4 = (SAM_DISPINFO_4 *)talloc_zero(p->mem_ctx,max_entries*sizeof(SAM_DISPINFO_4)))) + if (!(ctr->sam.info4 = TALLOC_ZERO_ARRAY(p->mem_ctx,SAM_DISPINFO_4,max_entries))) return NT_STATUS_NO_MEMORY; } disp_ret = init_sam_dispinfo_4(p->mem_ctx, ctr->sam.info4, max_entries, enum_context, info->disp_info.disp_user_info); @@ -1234,7 +1233,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, break; case 0x5: if (max_entries) { - if (!(ctr->sam.info5 = (SAM_DISPINFO_5 *)talloc_zero(p->mem_ctx,max_entries*sizeof(SAM_DISPINFO_5)))) + if (!(ctr->sam.info5 = TALLOC_ZERO_ARRAY(p->mem_ctx,SAM_DISPINFO_5,max_entries))) return NT_STATUS_NO_MEMORY; } disp_ret = init_sam_dispinfo_5(p->mem_ctx, ctr->sam.info5, max_entries, enum_context, info->disp_info.disp_group_info); @@ -1512,11 +1511,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_zero(ctx, sizeof(UNIHDR)*num_names); + hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names); if (hdr_name == NULL) return False; - uni_name = (UNISTR2 *)talloc_zero(ctx,sizeof(UNISTR2)*num_names); + uni_name = TALLOC_ZERO_ARRAY(ctx,UNISTR2, num_names); if (uni_name == NULL) return False; } @@ -1562,7 +1561,7 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK } if (num_rids) { - if ((group_attrs = (uint32 *)talloc_zero(p->mem_ctx, num_rids * sizeof(uint32))) == NULL) + if ((group_attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_rids )) == NULL) return NT_STATUS_NO_MEMORY; } @@ -1854,7 +1853,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ DEBUG(5,("_samr_query_userinfo: sid:%s\n", sid_string_static(&info->sid))); - ctr = (SAM_USERINFO_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_USERINFO_CTR)); + ctr = TALLOC_ZERO_P(p->mem_ctx, SAM_USERINFO_CTR); if (!ctr) return NT_STATUS_NO_MEMORY; @@ -1865,7 +1864,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ switch (q_u->switch_value) { case 0x10: - ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(p->mem_ctx, sizeof(SAM_USER_INFO_10)); + ctr->info.id10 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_10); if (ctr->info.id10 == NULL) return NT_STATUS_NO_MEMORY; @@ -1883,11 +1882,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ expire.low = 0xffffffff; expire.high = 0x7fffffff; - ctr->info.id = (SAM_USER_INFO_11 *)talloc_zero(p->mem_ctx, - sizeof - (*ctr-> - info. - id11)); + ctr->info.id = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_11)); ZERO_STRUCTP(ctr->info.id11); init_sam_user_info11(ctr->info.id11, &expire, "BROOKFIELDS$", /* name */ @@ -1900,7 +1895,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ #endif case 0x12: - ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(p->mem_ctx, sizeof(SAM_USER_INFO_12)); + ctr->info.id12 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_12); if (ctr->info.id12 == NULL) return NT_STATUS_NO_MEMORY; @@ -1909,7 +1904,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ break; case 20: - ctr->info.id20 = (SAM_USER_INFO_20 *)talloc_zero(p->mem_ctx,sizeof(SAM_USER_INFO_20)); + ctr->info.id20 = TALLOC_ZERO_P(p->mem_ctx,SAM_USER_INFO_20); if (ctr->info.id20 == NULL) return NT_STATUS_NO_MEMORY; if (!NT_STATUS_IS_OK(r_u->status = get_user_info_20(p->mem_ctx, ctr->info.id20, &info->sid))) @@ -1917,7 +1912,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ break; case 21: - ctr->info.id21 = (SAM_USER_INFO_21 *)talloc_zero(p->mem_ctx,sizeof(SAM_USER_INFO_21)); + ctr->info.id21 = TALLOC_ZERO_P(p->mem_ctx,SAM_USER_INFO_21); if (ctr->info.id21 == NULL) return NT_STATUS_NO_MEMORY; if (!NT_STATUS_IS_OK(r_u->status = get_user_info_21(p->mem_ctx, ctr->info.id21, @@ -2025,8 +2020,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S &(sids[i]), &rid)) continue; - gids = talloc_realloc(p->mem_ctx, gids, - sizeof(*gids) * (num_gids+1)); + gids = TALLOC_REALLOC_ARRAY(p->mem_ctx, gids, DOM_GID, num_gids+1); gids[num_gids].attr=7; gids[num_gids].g_rid = rid; num_gids += 1; @@ -2064,7 +2058,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA uint32 num_users=0, num_groups=0, num_aliases=0; - if ((ctr = (SAM_UNK_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL) + if ((ctr = TALLOC_ZERO_P(p->mem_ctx, SAM_UNK_CTR)) == NULL) return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(ctr); @@ -2549,8 +2543,8 @@ static BOOL make_enum_domains(TALLOC_CTX *ctx, SAM_ENTRY **pp_sam, if (num_sam_entries == 0) return True; - sam = (SAM_ENTRY *)talloc_zero(ctx, sizeof(SAM_ENTRY)*num_sam_entries); - uni_name = (UNISTR2 *)talloc_zero(ctx, sizeof(UNISTR2)*num_sam_entries); + sam = TALLOC_ZERO_ARRAY(ctx, SAM_ENTRY, num_sam_entries); + uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_sam_entries); if (sam == NULL || uni_name == NULL) return False; @@ -3193,7 +3187,7 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, !sid_check_is_builtin(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - members = talloc(p->mem_ctx, sizeof(DOM_SID) * q_u->num_sids1); + members = TALLOC_ARRAY(p->mem_ctx, DOM_SID, q_u->num_sids1); if (members == NULL) return NT_STATUS_NO_MEMORY; @@ -3219,8 +3213,7 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, if (!sid_peek_check_rid(&info->sid, &aliases[i], &rid)) continue; - rids = talloc_realloc(p->mem_ctx, rids, - sizeof(*rids) * (num_groups+1)); + rids = TALLOC_REALLOC_ARRAY(p->mem_ctx, rids, uint32, num_groups+1); if (rids == NULL) return NT_STATUS_NO_MEMORY; @@ -3264,7 +3257,7 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ if (!pdb_enum_aliasmem(&alias_sid, &sids, &num_sids)) return NT_STATUS_NO_SUCH_ALIAS; - sid = (DOM_SID2 *)talloc_zero(p->mem_ctx, sizeof(DOM_SID2) * num_sids); + sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_sids); if (num_sids!=0 && sid == NULL) { SAFE_FREE(sids); return NT_STATUS_NO_MEMORY; @@ -3290,7 +3283,7 @@ static void add_uid_to_array_unique(uid_t uid, uid_t **uids, int *num) return; } - *uids = Realloc(*uids, (*num+1) * sizeof(uid_t)); + *uids = SMB_REALLOC_ARRAY(*uids, uid_t, *num+1); if (*uids == NULL) return; @@ -3387,8 +3380,8 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ if(!get_memberuids(gid, &uids, &num)) return NT_STATUS_NO_SUCH_GROUP; - rid=talloc_zero(p->mem_ctx, sizeof(uint32)*num); - attr=talloc_zero(p->mem_ctx, sizeof(uint32)*num); + rid=TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num); + attr=TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num); if (num!=0 && (rid==NULL || attr==NULL)) return NT_STATUS_NO_MEMORY; @@ -3978,7 +3971,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM if (!ret) return NT_STATUS_INVALID_HANDLE; - ctr=(GROUP_INFO_CTR *)talloc_zero(p->mem_ctx, sizeof(GROUP_INFO_CTR)); + ctr=TALLOC_ZERO_P(p->mem_ctx, GROUP_INFO_CTR); if (ctr==NULL) return NT_STATUS_NO_MEMORY; @@ -4309,7 +4302,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW uint32 account_policy_temp; - if ((ctr = (SAM_UNK_CTR *)talloc_zero(p->mem_ctx, sizeof(SAM_UNK_CTR))) == NULL) + if ((ctr = TALLOC_ZERO_P(p->mem_ctx, SAM_UNK_CTR)) == NULL) return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(ctr); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index aba7e6c22f..78b5fb61fa 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -238,7 +238,7 @@ static SPOOL_NOTIFY_OPTION *dup_spool_notify_option(SPOOL_NOTIFY_OPTION *sp) if (!sp) return NULL; - new_sp = (SPOOL_NOTIFY_OPTION *)malloc(sizeof(SPOOL_NOTIFY_OPTION)); + new_sp = SMB_MALLOC_P(SPOOL_NOTIFY_OPTION); if (!new_sp) return NULL; @@ -585,7 +585,7 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3 DEBUG(10,("open_printer_hnd: name [%s]\n", name)); - if((new_printer=(Printer_entry *)malloc(sizeof(Printer_entry))) == NULL) + if((new_printer=SMB_MALLOC_P(Printer_entry)) == NULL) return False; ZERO_STRUCTP(new_printer); @@ -733,7 +733,7 @@ static void notify_string(struct spoolss_notify_msg *msg, init_unistr2(&unistr, msg->notify.data, UNI_STR_TERMINATE); data->notify_data.data.length = msg->len * 2; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, msg->len * 2); + data->notify_data.data.string = TALLOC_ARRAY(mem_ctx, uint16, msg->len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -770,7 +770,7 @@ static void notify_system_time(struct spoolss_notify_msg *msg, return; data->notify_data.data.length = prs_offset(&ps); - data->notify_data.data.string = talloc(mem_ctx, prs_offset(&ps)); + data->notify_data.data.string = TALLOC(mem_ctx, prs_offset(&ps)); prs_copy_all_data_out((char *)data->notify_data.data.string, &ps); @@ -928,7 +928,7 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS if ( i == ctr->num_groups ) { ctr->num_groups++; - if ( !(groups = talloc_realloc( ctr->ctx, ctr->msg_groups, sizeof(SPOOLSS_NOTIFY_MSG_GROUP)*ctr->num_groups)) ) { + if ( !(groups = TALLOC_REALLOC_ARRAY( ctr->ctx, ctr->msg_groups, SPOOLSS_NOTIFY_MSG_GROUP, ctr->num_groups)) ) { DEBUG(0,("notify_msg_ctr_addmsg: talloc_realloc() failed!\n")); return 0; } @@ -946,7 +946,7 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS msg_grp->num_msgs++; - if ( !(msg_list = talloc_realloc( ctr->ctx, msg_grp->msgs, sizeof(SPOOLSS_NOTIFY_MSG)*msg_grp->num_msgs )) ) { + if ( !(msg_list = TALLOC_REALLOC_ARRAY( ctr->ctx, msg_grp->msgs, SPOOLSS_NOTIFY_MSG, msg_grp->num_msgs )) ) { DEBUG(0,("notify_msg_ctr_addmsg: talloc_realloc() failed for new message [%d]!\n", msg_grp->num_msgs)); return 0; } @@ -958,7 +958,7 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS /* need to allocate own copy of data */ if ( msg->len != 0 ) - msg_grp->msgs[new_slot].notify.data = talloc_memdup( ctr->ctx, msg->notify.data, msg->len ); + msg_grp->msgs[new_slot].notify.data = TALLOC_MEMDUP( ctr->ctx, msg->notify.data, msg->len ); return ctr->num_groups; } @@ -1016,7 +1016,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) /* allocate the max entries possible */ - data = talloc( mem_ctx, msg_group->num_msgs*sizeof(SPOOL_NOTIFY_INFO_DATA) ); + data = TALLOC_ARRAY( mem_ctx, SPOOL_NOTIFY_INFO_DATA, msg_group->num_msgs); ZERO_STRUCTP(data); /* build the array of change notifications */ @@ -1436,7 +1436,7 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode) /* bulk copy first */ - d = talloc_memdup(ctx, devmode, sizeof(DEVICEMODE)); + d = TALLOC_MEMDUP(ctx, devmode, sizeof(DEVICEMODE)); if (!d) return NULL; @@ -1444,7 +1444,7 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode) len = unistrlen(devmode->devicename.buffer); if (len != -1) { - d->devicename.buffer = talloc(ctx, len*2); + d->devicename.buffer = TALLOC_ARRAY(ctx, uint16, len); if (unistrcpy(d->devicename.buffer, devmode->devicename.buffer) != len) return NULL; } @@ -1452,12 +1452,12 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode) len = unistrlen(devmode->formname.buffer); if (len != -1) { - d->devicename.buffer = talloc(ctx, len*2); + d->devicename.buffer = TALLOC_ARRAY(ctx, uint16, len); if (unistrcpy(d->formname.buffer, devmode->formname.buffer) != len) return NULL; } - d->private = talloc_memdup(ctx, devmode->private, devmode->driverextra); + d->private = TALLOC_MEMDUP(ctx, devmode->private, devmode->driverextra); return d; } @@ -1894,7 +1894,7 @@ BOOL convert_devicemode(const char *printername, const DEVICEMODE *devmode, if ((devmode->driverextra != 0) && (devmode->private != NULL)) { SAFE_FREE(nt_devmode->private); nt_devmode->driverextra=devmode->driverextra; - if((nt_devmode->private=(uint8 *)malloc(nt_devmode->driverextra * sizeof(uint8))) == NULL) + if((nt_devmode->private=SMB_MALLOC_ARRAY(uint8, nt_devmode->driverextra)) == NULL) return False; memcpy(nt_devmode->private, devmode->private, nt_devmode->driverextra); } @@ -2235,11 +2235,11 @@ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printe /* special case for 0 length values */ if ( data_len ) { - if ( (*data = (uint8 *)talloc_memdup(ctx, regval_data_p(val), data_len)) == NULL ) + if ( (*data = (uint8 *)TALLOC_MEMDUP(ctx, regval_data_p(val), data_len)) == NULL ) return WERR_NOMEM; } else { - if ( (*data = (uint8 *)talloc_zero(ctx, in_size)) == NULL ) + if ( (*data = (uint8 *)TALLOC_ZERO(ctx, in_size)) == NULL ) return WERR_NOMEM; } } @@ -2286,7 +2286,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "W3SvcInstalled")) { *type = 0x4; - if((*data = (uint8 *)talloc_zero(ctx, 4*sizeof(uint8) )) == NULL) + if((*data = (uint8 *)TALLOC_ZERO(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; *needed = 0x4; return WERR_OK; @@ -2294,7 +2294,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "BeepEnabled")) { *type = 0x4; - if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) + if((*data = (uint8 *)TALLOC(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; SIVAL(*data, 0, 0x00); *needed = 0x4; @@ -2303,7 +2303,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "EventLog")) { *type = 0x4; - if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) + if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL) return WERR_NOMEM; /* formally was 0x1b */ SIVAL(*data, 0, 0x0); @@ -2313,7 +2313,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "NetPopup")) { *type = 0x4; - if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) + if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL) return WERR_NOMEM; SIVAL(*data, 0, 0x00); *needed = 0x4; @@ -2322,7 +2322,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "MajorVersion")) { *type = 0x4; - if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) + if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL) return WERR_NOMEM; /* Windows NT 4.0 seems to not allow uploading of drivers @@ -2341,7 +2341,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "MinorVersion")) { *type = 0x4; - if((*data = (uint8 *)talloc(ctx, 4*sizeof(uint8) )) == NULL) + if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL) return WERR_NOMEM; SIVAL(*data, 0, 0); *needed = 0x4; @@ -2359,7 +2359,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint *type = 0x3; *needed = 0x114; - if((*data = (uint8 *)talloc(ctx, (*needed)*sizeof(uint8) )) == NULL) + if((*data = (uint8 *)TALLOC(ctx, *needed)) == NULL) return WERR_NOMEM; ZERO_STRUCTP( *data ); @@ -2378,7 +2378,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint const char *string="C:\\PRINTERS"; *type = 0x1; *needed = 2*(strlen(string)+1); - if((*data = (uint8 *)talloc(ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) + if((*data = (uint8 *)TALLOC(ctx, (*needed > in_size) ? *needed:in_size )) == NULL) return WERR_NOMEM; memset(*data, 0, (*needed > in_size) ? *needed:in_size); @@ -2394,7 +2394,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint const char *string="Windows NT x86"; *type = 0x1; *needed = 2*(strlen(string)+1); - if((*data = (uint8 *)talloc(ctx, ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) + if((*data = (uint8 *)TALLOC(ctx, (*needed > in_size) ? *needed:in_size )) == NULL) return WERR_NOMEM; memset(*data, 0, (*needed > in_size) ? *needed:in_size); for (i=0; i in_size) ? *needed:in_size) *sizeof(uint8))) == NULL) + if((*data = (uint8 *)TALLOC(ctx, (*needed > in_size) ? *needed:in_size )) == NULL) return WERR_NOMEM; memset(*data, 0, (*needed > in_size) ? *needed:in_size); for (i=0; imem_ctx, sizeof(uint32))) == NULL) { + if ( (*data = (uint8*)TALLOC(p->mem_ctx, sizeof(uint32))) == NULL) { status = WERR_NOMEM; goto done; } @@ -2517,7 +2517,7 @@ done: /* reply this param doesn't exist */ if ( *out_size ) { - if((*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL) { + if((*data=(uint8 *)TALLOC_ZERO_ARRAY(p->mem_ctx, uint8, *out_size)) == NULL) { if ( printer ) free_a_printer( &printer, 2 ); return WERR_NOMEM; @@ -2764,7 +2764,7 @@ void spoolss_notify_server_name(int snum, len = rpcstr_push(temp, printer->info_2->servername, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -2799,7 +2799,7 @@ void spoolss_notify_printer_name(int snum, len = rpcstr_push(temp, p, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -2825,7 +2825,7 @@ void spoolss_notify_share_name(int snum, len = rpcstr_push(temp, lp_servicename(snum), sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -2853,7 +2853,7 @@ void spoolss_notify_port_name(int snum, len = rpcstr_push(temp, printer->info_2->portname, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -2880,7 +2880,7 @@ void spoolss_notify_driver_name(int snum, len = rpcstr_push(temp, printer->info_2->drivername, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -2909,7 +2909,7 @@ void spoolss_notify_comment(int snum, len = rpcstr_push(temp, printer->info_2->comment, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -2936,7 +2936,7 @@ void spoolss_notify_location(int snum, len = rpcstr_push(temp, printer->info_2->location,sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -2975,7 +2975,7 @@ void spoolss_notify_sepfile(int snum, len = rpcstr_push(temp, printer->info_2->sepfile, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -3002,7 +3002,7 @@ void spoolss_notify_print_processor(int snum, len = rpcstr_push(temp, printer->info_2->printprocessor, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -3029,7 +3029,7 @@ void spoolss_notify_parameters(int snum, len = rpcstr_push(temp, printer->info_2->parameters, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -3056,7 +3056,7 @@ void spoolss_notify_datatype(int snum, len = rpcstr_push(temp, printer->info_2->datatype, sizeof(pstring)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -3216,7 +3216,7 @@ static void spoolss_notify_username(int snum, len = rpcstr_push(temp, queue->fs_user, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -3256,7 +3256,7 @@ static void spoolss_notify_job_name(int snum, len = rpcstr_push(temp, queue->fs_file, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -3306,7 +3306,7 @@ static void spoolss_notify_job_status_string(int snum, len = rpcstr_push(temp, p, sizeof(temp) - 2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -3404,7 +3404,7 @@ static void spoolss_notify_submitted_time(int snum, len = sizeof(SYSTEMTIME); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len); + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); if (!data->notify_data.data.string) { data->notify_data.data.length = 0; @@ -3626,7 +3626,7 @@ static BOOL construct_notify_printer_info(Printer_entry *print_hnd, SPOOL_NOTIFY if (!search_notify(type, field, &j) ) continue; - if((tid=(SPOOL_NOTIFY_INFO_DATA *)Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) { + if((tid=SMB_REALLOC_ARRAY(info->data, SPOOL_NOTIFY_INFO_DATA, info->count+1)) == NULL) { DEBUG(2,("construct_notify_printer_info: failed to enlarge buffer info->data!\n")); return False; } else @@ -3682,7 +3682,7 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, if (!search_notify(type, field, &j) ) continue; - if((tid=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) { + if((tid=SMB_REALLOC_ARRAY(info->data, SPOOL_NOTIFY_INFO_DATA, info->count+1)) == NULL) { DEBUG(2,("construct_notify_jobs_info: failed to enlarg buffer info->data!\n")); return False; } @@ -3966,7 +3966,7 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p /* it's the first time, add it to the list */ if (session_counter==NULL) { - if((session_counter=(counter_printer_0 *)malloc(sizeof(counter_printer_0))) == NULL) { + if((session_counter=SMB_MALLOC_P(counter_printer_0)) == NULL) { free_a_printer(&ntprinter, 2); return False; } @@ -4160,7 +4160,7 @@ DEVICEMODE *construct_dev_mode(int snum) goto done; } - if ((devmode = (DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL) { + if ((devmode = SMB_MALLOC_P(DEVICEMODE)) == NULL) { DEBUG(2,("construct_dev_mode: malloc fail.\n")); goto done; } @@ -4257,7 +4257,7 @@ static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 ** return False; *pp_printer = NULL; - if ((printer = (PRINTER_INFO_3 *)malloc(sizeof(PRINTER_INFO_3))) == NULL) { + if ((printer = SMB_MALLOC_P(PRINTER_INFO_3)) == NULL) { DEBUG(2,("construct_printer_info_3: malloc fail.\n")); return False; } @@ -4386,7 +4386,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); if (construct_printer_info_1(NULL, flags, ¤t_prt, snum)) { - if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) { + if((tp=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_1, *returned +1)) == NULL) { DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n")); SAFE_FREE(printers); *returned=0; @@ -4475,7 +4475,7 @@ static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, * undocumented RPC call. */ - if((printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1))) == NULL) + if((printer=SMB_MALLOC_P(PRINTER_INFO_1)) == NULL) return WERR_NOMEM; *returned=1; @@ -4559,7 +4559,7 @@ static WERROR enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint3 DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); if (construct_printer_info_2(NULL, ¤t_prt, snum)) { - if((tp=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2))) == NULL) { + if((tp=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_2, *returned +1)) == NULL) { DEBUG(2,("enum_all_printers_info_2: failed to enlarge printers buffer!\n")); SAFE_FREE(printers); *returned = 0; @@ -4735,7 +4735,7 @@ static WERROR getprinter_level_0(Printer_entry *print_hnd, int snum, NEW_BUFFER { PRINTER_INFO_0 *printer=NULL; - if((printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0))) == NULL) + if((printer=SMB_MALLOC_P(PRINTER_INFO_0)) == NULL) return WERR_NOMEM; construct_printer_info_0(print_hnd, printer, snum); @@ -4768,7 +4768,7 @@ static WERROR getprinter_level_1(Printer_entry *print_hnd, int snum, NEW_BUFFER { PRINTER_INFO_1 *printer=NULL; - if((printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1))) == NULL) + if((printer=SMB_MALLOC_P(PRINTER_INFO_1)) == NULL) return WERR_NOMEM; construct_printer_info_1(print_hnd, PRINTER_ENUM_ICON8, printer, snum); @@ -4801,7 +4801,7 @@ static WERROR getprinter_level_2(Printer_entry *print_hnd, int snum, NEW_BUFFER { PRINTER_INFO_2 *printer=NULL; - if((printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)))==NULL) + if((printer=SMB_MALLOC_P(PRINTER_INFO_2))==NULL) return WERR_NOMEM; construct_printer_info_2(print_hnd, printer, snum); @@ -4868,7 +4868,7 @@ static WERROR getprinter_level_4(Printer_entry *print_hnd, int snum, NEW_BUFFER { PRINTER_INFO_4 *printer=NULL; - if((printer=(PRINTER_INFO_4*)malloc(sizeof(PRINTER_INFO_4)))==NULL) + if((printer=SMB_MALLOC_P(PRINTER_INFO_4))==NULL) return WERR_NOMEM; if (!construct_printer_info_4(print_hnd, printer, snum)) @@ -4902,7 +4902,7 @@ static WERROR getprinter_level_5(Printer_entry *print_hnd, int snum, NEW_BUFFER { PRINTER_INFO_5 *printer=NULL; - if((printer=(PRINTER_INFO_5*)malloc(sizeof(PRINTER_INFO_5)))==NULL) + if((printer=SMB_MALLOC_P(PRINTER_INFO_5))==NULL) return WERR_NOMEM; if (!construct_printer_info_5(print_hnd, printer, snum)) @@ -4933,7 +4933,7 @@ static WERROR getprinter_level_7(Printer_entry *print_hnd, int snum, NEW_BUFFER { PRINTER_INFO_7 *printer=NULL; - if((printer=(PRINTER_INFO_7*)malloc(sizeof(PRINTER_INFO_7)))==NULL) + if((printer=SMB_MALLOC_P(PRINTER_INFO_7))==NULL) return WERR_NOMEM; if (!construct_printer_info_7(print_hnd, printer, snum)) @@ -5135,7 +5135,7 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, const c /* add one extra unit16 for the second terminating NULL */ - if ( (tuary=Realloc(*uni_array, (j+1+strlen(line)+2)*sizeof(uint16))) == NULL ) { + if ( (tuary=SMB_REALLOC_ARRAY(*uni_array, uint16, j+1+strlen(line)+2)) == NULL ) { DEBUG(2,("init_unistr_array: Realloc error\n" )); return 0; } else @@ -5411,7 +5411,7 @@ static WERROR getprinterdriver2_level1(fstring servername, fstring architecture, DRIVER_INFO_1 *info=NULL; WERROR status; - if((info=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1))) == NULL) + if((info=SMB_MALLOC_P(DRIVER_INFO_1)) == NULL) return WERR_NOMEM; status=construct_printer_driver_info_1(info, snum, servername, architecture, version); @@ -5448,7 +5448,7 @@ static WERROR getprinterdriver2_level2(fstring servername, fstring architecture, DRIVER_INFO_2 *info=NULL; WERROR status; - if((info=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2))) == NULL) + if((info=SMB_MALLOC_P(DRIVER_INFO_2)) == NULL) return WERR_NOMEM; status=construct_printer_driver_info_2(info, snum, servername, architecture, version); @@ -6434,7 +6434,7 @@ static WERROR enumjobs_level1(print_queue_struct *queue, int snum, JOB_INFO_1 *info; int i; - info=(JOB_INFO_1 *)malloc(*returned*sizeof(JOB_INFO_1)); + info=SMB_MALLOC_ARRAY(JOB_INFO_1,*returned); if (info==NULL) { SAFE_FREE(queue); *returned=0; @@ -6484,7 +6484,7 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, WERROR result; DEVICEMODE *devmode = NULL; - info=(JOB_INFO_2 *)malloc(*returned*sizeof(JOB_INFO_2)); + info=SMB_MALLOC_ARRAY(JOB_INFO_2,*returned); if (info==NULL) { *returned=0; result = WERR_NOMEM; @@ -6676,7 +6676,7 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture return WERR_NOMEM; if(ndrivers != 0) { - if((tdi1=(DRIVER_INFO_1 *)Realloc(driver_info_1, (*returned+ndrivers) * sizeof(DRIVER_INFO_1))) == NULL) { + if((tdi1=SMB_REALLOC_ARRAY(driver_info_1, DRIVER_INFO_1, *returned+ndrivers )) == NULL) { DEBUG(0,("enumprinterdrivers_level1: failed to enlarge driver info buffer!\n")); SAFE_FREE(driver_info_1); SAFE_FREE(list); @@ -6755,7 +6755,7 @@ static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture return WERR_NOMEM; if(ndrivers != 0) { - if((tdi2=(DRIVER_INFO_2 *)Realloc(driver_info_2, (*returned+ndrivers) * sizeof(DRIVER_INFO_2))) == NULL) { + if((tdi2=SMB_REALLOC_ARRAY(driver_info_2, DRIVER_INFO_2, *returned+ndrivers )) == NULL) { DEBUG(0,("enumprinterdrivers_level2: failed to enlarge driver info buffer!\n")); SAFE_FREE(driver_info_2); SAFE_FREE(list); @@ -6835,7 +6835,7 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture return WERR_NOMEM; if(ndrivers != 0) { - if((tdi3=(DRIVER_INFO_3 *)Realloc(driver_info_3, (*returned+ndrivers) * sizeof(DRIVER_INFO_3))) == NULL) { + if((tdi3=SMB_REALLOC_ARRAY(driver_info_3, DRIVER_INFO_3, *returned+ndrivers )) == NULL) { DEBUG(0,("enumprinterdrivers_level3: failed to enlarge driver info buffer!\n")); SAFE_FREE(driver_info_3); SAFE_FREE(list); @@ -6988,7 +6988,7 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF switch (level) { case 1: - if ((forms_1=(FORM_1 *)malloc(*numofforms * sizeof(FORM_1))) == NULL) { + if ((forms_1=SMB_MALLOC_ARRAY(FORM_1, *numofforms)) == NULL) { *numofforms=0; return WERR_NOMEM; } @@ -7192,7 +7192,7 @@ static WERROR enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need close(fd); if(numlines) { - if((ports=(PORT_INFO_1 *)malloc( numlines * sizeof(PORT_INFO_1) )) == NULL) { + if((ports=SMB_MALLOC_ARRAY( PORT_INFO_1, numlines )) == NULL) { DEBUG(10,("Returning WERR_NOMEM [%s]\n", dos_errstr(WERR_NOMEM))); file_lines_free(qlines); @@ -7212,7 +7212,7 @@ static WERROR enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need } else { *returned = 1; /* Sole Samba port returned. */ - if((ports=(PORT_INFO_1 *)malloc( sizeof(PORT_INFO_1) )) == NULL) + if((ports=SMB_MALLOC_P(PORT_INFO_1)) == NULL) return WERR_NOMEM; DEBUG(10,("enumports_level_1: port name %s\n", SAMBA_PRINTER_PORT_NAME)); @@ -7291,7 +7291,7 @@ static WERROR enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need close(fd); if(numlines) { - if((ports=(PORT_INFO_2 *)malloc( numlines * sizeof(PORT_INFO_2) )) == NULL) { + if((ports=SMB_MALLOC_ARRAY( PORT_INFO_2, numlines)) == NULL) { file_lines_free(qlines); return WERR_NOMEM; } @@ -7310,7 +7310,7 @@ static WERROR enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need *returned = 1; - if((ports=(PORT_INFO_2 *)malloc( sizeof(PORT_INFO_2) )) == NULL) + if((ports=SMB_MALLOC_P(PORT_INFO_2)) == NULL) return WERR_NOMEM; DEBUG(10,("enumports_level_2: port name %s\n", SAMBA_PRINTER_PORT_NAME)); @@ -7390,7 +7390,7 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ int snum; WERROR err = WERR_OK; - if ((printer = (NT_PRINTER_INFO_LEVEL *)malloc(sizeof(NT_PRINTER_INFO_LEVEL))) == NULL) { + if ((printer = SMB_MALLOC_P(NT_PRINTER_INFO_LEVEL)) == NULL) { DEBUG(0,("spoolss_addprinterex_level_2: malloc fail.\n")); return WERR_NOMEM; } @@ -7719,7 +7719,7 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen if (!(short_archi = get_short_archi(long_archi))) return WERR_INVALID_ENVIRONMENT; - if((info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1))) == NULL) + if((info=SMB_MALLOC_P(DRIVER_DIRECTORY_1)) == NULL) return WERR_NOMEM; slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", pservername, short_archi); @@ -7887,7 +7887,7 @@ WERROR _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) + if((*out_value=(uint16 *)TALLOC_ZERO(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL) { result = WERR_NOMEM; goto done; @@ -7902,7 +7902,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S /* only allocate when given a non-zero data_len */ - if ( in_data_len && ((*data_out=(uint8 *)talloc_zero(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) ) + if ( in_data_len && ((*data_out=(uint8 *)TALLOC_ZERO(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) ) { result = WERR_NOMEM; goto done; @@ -7923,7 +7923,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S /* name */ *out_max_value_len=(in_value_len/sizeof(uint16)); - if ( (*out_value = (uint16 *)talloc_zero(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL ) + if ( (*out_value = (uint16 *)TALLOC_ZERO(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL ) { result = WERR_NOMEM; goto done; @@ -7938,7 +7938,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S /* data - counted in bytes */ *out_max_data_len = in_data_len; - if ( (*data_out = (uint8 *)talloc_zero(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) + if ( (*data_out = (uint8 *)TALLOC_ZERO(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) { result = WERR_NOMEM; goto done; @@ -8323,7 +8323,7 @@ static WERROR enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui { PRINTPROCESSOR_1 *info_1=NULL; - if((info_1 = (PRINTPROCESSOR_1 *)malloc(sizeof(PRINTPROCESSOR_1))) == NULL) + if((info_1 = SMB_MALLOC_P(PRINTPROCESSOR_1)) == NULL) return WERR_NOMEM; (*returned) = 0x1; @@ -8390,7 +8390,7 @@ static WERROR enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, { PRINTPROCDATATYPE_1 *info_1=NULL; - if((info_1 = (PRINTPROCDATATYPE_1 *)malloc(sizeof(PRINTPROCDATATYPE_1))) == NULL) + if((info_1 = SMB_MALLOC_P(PRINTPROCDATATYPE_1)) == NULL) return WERR_NOMEM; (*returned) = 0x1; @@ -8450,7 +8450,7 @@ static WERROR enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint { PRINTMONITOR_1 *info_1=NULL; - if((info_1 = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1))) == NULL) + if((info_1 = SMB_MALLOC_P(PRINTMONITOR_1)) == NULL) return WERR_NOMEM; (*returned) = 0x1; @@ -8482,7 +8482,7 @@ static WERROR enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint { PRINTMONITOR_2 *info_2=NULL; - if((info_2 = (PRINTMONITOR_2 *)malloc(sizeof(PRINTMONITOR_2))) == NULL) + if((info_2 = SMB_MALLOC_P(PRINTMONITOR_2)) == NULL) return WERR_NOMEM; (*returned) = 0x1; @@ -8557,7 +8557,7 @@ static WERROR getjob_level_1(print_queue_struct **queue, int count, int snum, BOOL found=False; JOB_INFO_1 *info_1=NULL; - info_1=(JOB_INFO_1 *)malloc(sizeof(JOB_INFO_1)); + info_1=SMB_MALLOC_P(JOB_INFO_1); if (info_1 == NULL) { return WERR_NOMEM; @@ -8608,7 +8608,7 @@ static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, DEVICEMODE *devmode = NULL; NT_DEVICEMODE *nt_devmode = NULL; - info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2)); + info_2=SMB_MALLOC_P(JOB_INFO_2); ZERO_STRUCTP(info_2); @@ -8640,7 +8640,7 @@ static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, if ( !(nt_devmode=print_job_devmode( lp_const_servicename(snum), jobid )) ) devmode = construct_dev_mode(snum); else { - if ((devmode = (DEVICEMODE *)malloc(sizeof(DEVICEMODE))) != NULL) { + if ((devmode = SMB_MALLOC_P(DEVICEMODE)) != NULL) { ZERO_STRUCTP( devmode ); convert_nt_devicemode( devmode, nt_devmode ); } @@ -8818,7 +8818,7 @@ done: if ( *out_size ) { - if( (*data=(uint8 *)talloc_zero(p->mem_ctx, *out_size*sizeof(uint8))) == NULL ) { + if( (*data=(uint8 *)TALLOC_ZERO(p->mem_ctx, *out_size*sizeof(uint8))) == NULL ) { status = WERR_NOMEM; goto done; } @@ -9177,7 +9177,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ num_entries = regval_ctr_numvals( &p_data->keys[key_index].values ); if ( num_entries ) { - if ( (enum_values=talloc(p->mem_ctx, num_entries*sizeof(PRINTER_ENUM_VALUES))) == NULL ) + if ( (enum_values=TALLOC_ARRAY(p->mem_ctx, PRINTER_ENUM_VALUES, num_entries)) == NULL ) { DEBUG(0,("_spoolss_enumprinterdataex: talloc() failed to allocate memory for [%lu] bytes!\n", (unsigned long)num_entries*sizeof(PRINTER_ENUM_VALUES))); @@ -9209,7 +9209,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ data_len = regval_size( val ); if ( data_len ) { - if ( !(enum_values[i].data = talloc_memdup(p->mem_ctx, regval_data_p(val), data_len)) ) + if ( !(enum_values[i].data = TALLOC_MEMDUP(p->mem_ctx, regval_data_p(val), data_len)) ) { DEBUG(0,("talloc_memdup failed to allocate memory [data_len=%d] for data!\n", data_len )); @@ -9272,7 +9272,7 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, if (!get_short_archi(long_archi)) return WERR_INVALID_ENVIRONMENT; - if((info=(PRINTPROCESSOR_DIRECTORY_1 *)malloc(sizeof(PRINTPROCESSOR_DIRECTORY_1))) == NULL) + if((info=SMB_MALLOC_P(PRINTPROCESSOR_DIRECTORY_1)) == NULL) return WERR_NOMEM; pstrcpy(path, "C:\\WINNT\\System32\\spool\\PRTPROCS\\W32X86"); diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 9837ea2a97..af4c94800a 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -522,10 +522,12 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, switch (info_level) { case 0: { - SRV_SHARE_INFO_0 *info0; + SRV_SHARE_INFO_0 *info0 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_0, num_entries); int i = 0; - info0 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_0)); + if (!info0) { + return False; + } for (snum = *resume_hnd; snum < num_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { @@ -540,10 +542,12 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, case 1: { - SRV_SHARE_INFO_1 *info1; + SRV_SHARE_INFO_1 *info1 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1, num_entries); int i = 0; - info1 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1)); + if (!info1) { + return False; + } for (snum = *resume_hnd; snum < num_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { @@ -557,10 +561,12 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, case 2: { - SRV_SHARE_INFO_2 *info2; + SRV_SHARE_INFO_2 *info2 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_2, num_entries); int i = 0; - info2 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_2)); + if (!info2) { + return False; + } for (snum = *resume_hnd; snum < num_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { @@ -574,10 +580,12 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, case 501: { - SRV_SHARE_INFO_501 *info501; + SRV_SHARE_INFO_501 *info501 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_501, num_entries); int i = 0; - info501 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_501)); + if (!info501) { + return False; + } for (snum = *resume_hnd; snum < num_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { @@ -591,10 +599,12 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, case 502: { - SRV_SHARE_INFO_502 *info502; + SRV_SHARE_INFO_502 *info502 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_502, num_entries); int i = 0; - info502 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_502)); + if (!info502) { + return False; + } for (snum = *resume_hnd; snum < num_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { @@ -610,10 +620,12 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, case 1004: { - SRV_SHARE_INFO_1004 *info1004; + SRV_SHARE_INFO_1004 *info1004 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1004, num_entries); int i = 0; - info1004 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1004)); + if (!info1004) { + return False; + } for (snum = *resume_hnd; snum < num_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { @@ -627,10 +639,12 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, case 1005: { - SRV_SHARE_INFO_1005 *info1005; + SRV_SHARE_INFO_1005 *info1005 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1005, num_entries); int i = 0; - info1005 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1005)); + if (!info1005) { + return False; + } for (snum = *resume_hnd; snum < num_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { @@ -644,10 +658,12 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, case 1006: { - SRV_SHARE_INFO_1006 *info1006; + SRV_SHARE_INFO_1006 *info1006 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1006, num_entries); int i = 0; - info1006 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1006)); + if (!info1006) { + return False; + } for (snum = *resume_hnd; snum < num_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { @@ -661,10 +677,12 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, case 1007: { - SRV_SHARE_INFO_1007 *info1007; + SRV_SHARE_INFO_1007 *info1007 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1007, num_entries); int i = 0; - info1007 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1007)); + if (!info1007) { + return False; + } for (snum = *resume_hnd; snum < num_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { @@ -678,10 +696,12 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, case 1501: { - SRV_SHARE_INFO_1501 *info1501; + SRV_SHARE_INFO_1501 *info1501 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1501, num_entries); int i = 0; - info1501 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1501)); + if (!info1501) { + return False; + } for (snum = *resume_hnd; snum < num_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { @@ -1132,8 +1152,7 @@ static WERROR init_srv_file_info_ctr(pipes_struct *p, SRV_FILE_INFO_CTR *ctr, int i; if (*total_entries > 0) { ctr->ptr_entries = 1; - ctr->file.info3 = talloc(ctx, ctr->num_entries * - sizeof(SRV_FILE_INFO_3)); + ctr->file.info3 = TALLOC_ARRAY(ctx, SRV_FILE_INFO_3, ctr->num_entries); } for (i=0 ;inum_entries;i++) { init_srv_file_info3(&ctr->file.info3[i].info_3, i+*resume_hnd, 0x35, 0, "\\PIPE\\samr", "dummy user"); @@ -1184,7 +1203,7 @@ net server get info WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R_NET_SRV_GET_INFO *r_u) { WERROR status = WERR_OK; - SRV_INFO_CTR *ctr = (SRV_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_INFO_CTR)); + SRV_INFO_CTR *ctr = TALLOC_P(p->mem_ctx, SRV_INFO_CTR); if (!ctr) return WERR_NOMEM; @@ -1287,7 +1306,7 @@ WERROR _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_C { DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); - r_u->ctr = (SRV_CONN_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_CONN_INFO_CTR)); + r_u->ctr = TALLOC_P(p->mem_ctx, SRV_CONN_INFO_CTR); if (!r_u->ctr) return WERR_NOMEM; @@ -1312,7 +1331,7 @@ WERROR _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_S { DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__)); - r_u->ctr = (SRV_SESS_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_SESS_INFO_CTR)); + r_u->ctr = TALLOC_P(p->mem_ctx, SRV_SESS_INFO_CTR); if (!r_u->ctr) return WERR_NOMEM; @@ -1795,7 +1814,7 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET struct tm *t; time_t unixdate = time(NULL); - tod = (TIME_OF_DAY_INFO *)talloc(p->mem_ctx, sizeof(TIME_OF_DAY_INFO)); + tod = TALLOC_P(p->mem_ctx, TIME_OF_DAY_INFO); if (!tod) return WERR_NOMEM; @@ -2114,16 +2133,8 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D r_u->disk_enum_ctr.unknown = 0; - { - DISK_INFO *dinfo; - - int dinfo_size = MAX_SERVER_DISK_ENTRIES * sizeof(*dinfo); - - if(!(dinfo = talloc(ctx, dinfo_size))) { - return WERR_NOMEM; - } - - r_u->disk_enum_ctr.disk_info = dinfo; + if(!(r_u->disk_enum_ctr.disk_info = TALLOC_ARRAY(ctx, DISK_INFO, MAX_SERVER_DISK_ENTRIES))) { + return WERR_NOMEM; } r_u->disk_enum_ctr.disk_info_ptr = r_u->disk_enum_ctr.disk_info ? 1 : 0; diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 2689d89972..802e7673a4 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -90,7 +90,7 @@ NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, const DOM_SID *domain_sid, DOM_GID *gids; int i; - gids = (DOM_GID *)talloc(mem_ctx, sizeof(*gids) * nt_token->num_sids); + gids = TALLOC_ARRAY(mem_ctx, DOM_GID, nt_token->num_sids); if (!gids) { return NT_STATUS_NO_MEMORY; diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 25fa029237..6528e63225 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -65,7 +65,7 @@ NTSTATUS _wks_query_info(pipes_struct *p, WKS_Q_QUERY_INFO *q_u, WKS_R_QUERY_INF DEBUG(5,("_wks_query_info: %d\n", __LINE__)); - wks100 = (WKS_INFO_100 *)talloc_zero(p->mem_ctx, sizeof(WKS_INFO_100)); + wks100 = TALLOC_ZERO_P(p->mem_ctx, WKS_INFO_100); if (!wks100) return NT_STATUS_NO_MEMORY; -- cgit From 3c45a093c435a106e08746aa3f3db824192340f1 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 10 Dec 2004 21:08:34 +0000 Subject: r4134: check the setprinter(3) based on the access permissions on the handle and avoid the call to print_access_chaeck() (This used to be commit 426634df9c221fbe4f48b4ff9d1b4b8426a581f7) --- source3/rpc_server/srv_spoolss_nt.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 78b5fb61fa..9aa46d1a5a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5860,6 +5860,17 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, result = WERR_BADFID; goto done; } + + /* Check the user has permissions to change the security + descriptor. By experimentation with two NT machines, the user + requires Full Access to the printer to change security + information. */ + + if ( Printer->access_granted != PRINTER_ACCESS_ADMINISTER ) { + DEBUG(4,("update_printer_sec: updated denied by printer permissions\n")); + result = WERR_ACCESS_DENIED; + goto done; + } /* NT seems to like setting the security descriptor even though nothing may have actually changed. */ @@ -5909,20 +5920,6 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, goto done; } - /* Work out which user is performing the operation */ - - get_current_user(&user, p); - - /* Check the user has permissions to change the security - descriptor. By experimentation with two NT machines, the user - requires Full Access to the printer to change security - information. */ - - if (!print_access_check(&user, snum, PRINTER_ACCESS_ADMINISTER)) { - result = WERR_ACCESS_DENIED; - goto done; - } - result = nt_printing_setsec(Printer->sharename, new_secdesc_ctr); done: -- cgit From 00eede9a6b7e258faa6abe4de0d39a16bbcebd14 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 14 Dec 2004 00:20:55 +0000 Subject: r4184: Removed unused extern. Jeremy. (This used to be commit 72e39041e9fbb7f252292182d56b1927a8133be0) --- source3/rpc_server/srv_spoolss_nt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 9aa46d1a5a..a3424fe73b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5847,7 +5847,6 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, pipes_struct *p, SEC_DESC_BUF *secdesc_ctr) { SEC_DESC_BUF *new_secdesc_ctr = NULL, *old_secdesc_ctr = NULL; - struct current_user user; WERROR result; int snum; -- cgit From 4027c4088b0e5e4d6f87781a44f8703c62f24027 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 15 Dec 2004 13:13:15 +0000 Subject: r4219: Fix samba3 samr "idl"... According to samba4 idl samr_DomInfo2 contains a comment string and not an unknown 12 byte structure... Found after abartlet's smbtorture extended this string to "Tortured by Samba4: Fri Nov 26 15:40:18 2004 CET" ;-)) Volker (This used to be commit b41d94d8186f66136918432cf32e9dcef5a8bd12) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 5f74df420a..b094a5f30b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2115,7 +2115,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA free_samr_db(info); /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, lp_workgroup(), global_myname(), (uint32) time(NULL), + init_unk_info2(&ctr->info.inf2, "", lp_workgroup(), global_myname(), (uint32) time(NULL), num_users, num_groups, num_aliases); break; case 0x03: -- cgit From 390685ca143cb466e7dc13827e951194e35d4a0d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 15 Dec 2004 14:23:15 +0000 Subject: r4222: Always compile before commit... (This used to be commit 0f26ba5226fab5b86031a0df6fba16b8e6af6e7d) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b094a5f30b..771e8c71e3 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4358,7 +4358,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW free_samr_db(info); /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, lp_workgroup(), global_myname(), (uint32) time(NULL), + init_unk_info2(&ctr->info.inf2, "", lp_workgroup(), global_myname(), (uint32) time(NULL), num_users, num_groups, num_aliases); break; case 0x03: -- cgit From 9aba116607c0b85a371c3556a6483bc662c769a3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 22 Dec 2004 16:58:43 +0000 Subject: r4331: Implement SAMR query_dom_info-call info-level 8 server- and client-side, based on samba4-idl. This saves us an enormous amount of totally unnecessary ldap-traffic when several hundreds of winbind-daemons query a Samba3 DC just to get the fake SAM-sequence-number (time(NULL)) by enumerating all users, all groups and all aliases when query-dom-info level 2 is used. Note that we apparently never get the sequence number right (we parse a uint32, although it's a uint64, at least in samba4 idl). For the time being, I would propose to stay with that behaviour. Guenther (This used to be commit f9ab15a986626581000d4b93961184c501f36b93) --- source3/rpc_server/srv_samr_nt.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 771e8c71e3..5d7cd84390 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2133,6 +2133,9 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA case 0x07: init_unk_info7(&ctr->info.inf7); break; + case 0x08: + init_unk_info8(&ctr->info.inf8, (uint32) time(NULL)); + break; case 0x0c: account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); u_lock_duration = account_policy_temp * 60; -- cgit From 8222f958d15256a62712710c9c9a159106746d8b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 22 Dec 2004 23:50:31 +0000 Subject: r4336: Apply some other samba4 SAMR idl that is just too obvious. Don't hard set the value "forcibly disconnect remote users from server when logon hours expire" to "no", instead take the value from our account-policy storage. Guenther (This used to be commit e3bd2a22a5cebc4adf6910d3ec31bc6fada8cd35) --- source3/rpc_server/srv_samr_nt.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 5d7cd84390..8219e689f0 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2113,10 +2113,15 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA } num_groups=info->disp_info.num_group_account; free_samr_db(info); - + + account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); + u_logout = account_policy_temp; + + unix_to_nt_time_abs(&nt_logout, u_logout); + /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ init_unk_info2(&ctr->info.inf2, "", lp_workgroup(), global_myname(), (uint32) time(NULL), - num_users, num_groups, num_aliases); + num_users, num_groups, num_aliases, nt_logout); break; case 0x03: account_policy_get(AP_TIME_TO_LOGOUT, (unsigned int *)&u_logout); @@ -4360,9 +4365,14 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW num_groups=info->disp_info.num_group_account; free_samr_db(info); + account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); + u_logout = account_policy_temp; + + unix_to_nt_time_abs(&nt_logout, u_logout); + /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ init_unk_info2(&ctr->info.inf2, "", lp_workgroup(), global_myname(), (uint32) time(NULL), - num_users, num_groups, num_aliases); + num_users, num_groups, num_aliases, nt_logout); break; case 0x03: account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); -- cgit From e15e7a5f1fc8dfc2e49045f63813d29eb73450e5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 23 Dec 2004 09:36:49 +0000 Subject: r4343: forgot to add info-level 8 to SAMR_UNKNOWN_2E as well. Guenther (This used to be commit 5e6ce9a6e3d62190da5427ed7b5e2f2ac22a0c34) --- source3/rpc_server/srv_samr_nt.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 8219e689f0..820c8e7a3c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4391,6 +4391,9 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW case 0x07: init_unk_info7(&ctr->info.inf7); break; + case 0x08: + init_unk_info8(&ctr->info.inf8, (uint32) time(NULL)); + break; case 0x0c: account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); u_lock_duration = account_policy_temp * 60; -- cgit From b314cf95ce3cf809fd03af2b562e9a6dc156f746 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 24 Dec 2004 00:08:15 +0000 Subject: r4351: Vampire Logon-Hours. Update Logon-Hours only when they have changed. Guenther (This used to be commit 0930ad662770278cbe9fd4e3deaa523957b96697) --- source3/rpc_server/srv_samr_util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 8cc44074ab..c1faede947 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -262,8 +262,12 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) } DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); - /* Fix me: only update if it changes --metze */ - pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); + pstring old, new; + pdb_sethexhours(old, pdb_get_hours(to)); + pdb_sethexhours(new, (const char *)from->logon_hrs.hours); + if (!strequal(old, new)) { + pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); + } /* This is max logon hours */ DEBUG(10,("INFO_21 UNKNOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); -- cgit From d1a61c18fba101e64e6c446491e953c38d721929 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 26 Dec 2004 21:06:43 +0000 Subject: r4370: Don't assume the compiler supports declarations after statements. (This used to be commit 7fa2caec5ec2de4c5e7359621745a65ca9df255c) --- source3/rpc_server/srv_samr_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index c1faede947..dd12a438ca 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -251,6 +251,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_LOGON_HOURS) { + pstring old, new; DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); if (from->logon_divs != pdb_get_logon_divs(to)) { pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); @@ -262,7 +263,6 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) } DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); - pstring old, new; pdb_sethexhours(old, pdb_get_hours(to)); pdb_sethexhours(new, (const char *)from->logon_hrs.hours); if (!strequal(old, new)) { -- cgit From be606e8eeb0a419189bd8f44975c80e182474993 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 6 Jan 2005 23:27:28 +0000 Subject: r4579: small changes to allow the members og the Domain Admins group on the Samba DC to join clients to the domain -- needs more testing and security review but does work with initial testing (This used to be commit 9ade9bf49c7125fb29658f943e9ebb6be9496180) --- source3/rpc_server/srv_samr_nt.c | 198 ++++++++++++++++++++++++++------------- 1 file changed, 134 insertions(+), 64 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 820c8e7a3c..e72cf68c74 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -8,7 +8,7 @@ * Copyright (C) Jeremy Allison 2001-2002, * Copyright (C) Jean François Micouleau 1998-2001, * Copyright (C) Jim McDonough 2002, - * Copyright (C) Gerald (Jerry) Carter 2003, + * Copyright (C) Gerald (Jerry) Carter 2003 - 2004, * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -450,11 +450,10 @@ NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) { extern DOM_SID global_sid_World; - DOM_SID adm_sid; - DOM_SID act_sid; - - SEC_ACE ace[3]; + DOM_SID adm_sid, act_sid, domadmin_sid; + SEC_ACE ace[4]; SEC_ACCESS mask; + size_t i = 0; SEC_ACL *psa = NULL; @@ -466,14 +465,24 @@ static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd /*basic access for every one*/ init_sec_access(&mask, GENERIC_RIGHTS_DOMAIN_EXECUTE | GENERIC_RIGHTS_DOMAIN_READ); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, GENERIC_RIGHTS_DOMAIN_ALL_ACCESS); - init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + init_sec_ace(&ace[i++], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /* add domain admins if we are a DC */ + + if ( IS_DC ) { + sid_copy( &domadmin_sid, get_global_sam_sid() ); + sid_append_rid( &domadmin_sid, DOMAIN_GROUP_RID_ADMINS ); + init_sec_ace(&ace[i++], &domadmin_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + } - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) == NULL) return NT_STATUS_NO_MEMORY; if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) @@ -489,10 +498,10 @@ static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size, DOM_SID *usr_sid) { extern DOM_SID global_sid_World; - DOM_SID adm_sid; - DOM_SID act_sid; + DOM_SID adm_sid, act_sid, domadmin_sid; + size_t i = 0; - SEC_ACE ace[4]; + SEC_ACE ace[5]; SEC_ACCESS mask; SEC_ACL *psa = NULL; @@ -504,17 +513,28 @@ static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); /*basic access for every one*/ + init_sec_access(&mask, GENERIC_RIGHTS_USER_EXECUTE | GENERIC_RIGHTS_USER_READ); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, GENERIC_RIGHTS_USER_ALL_ACCESS); - init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /* add domain admins if we are a DC */ + + if ( IS_DC ) { + sid_copy( &domadmin_sid, get_global_sam_sid() ); + sid_append_rid( &domadmin_sid, DOMAIN_GROUP_RID_ADMINS ); + init_sec_ace(&ace[i++], &domadmin_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + } /*extended access for the user*/ + init_sec_access(&mask,READ_CONTROL_ACCESS | SA_RIGHT_USER_CHANGE_PASSWORD | SA_RIGHT_USER_SET_LOC_COM); - init_sec_ace(&ace[3], usr_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], usr_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 4, ace)) == NULL) return NT_STATUS_NO_MEMORY; @@ -2193,6 +2213,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA uint32 new_rid = 0; /* check this, when giving away 'add computer to domain' privs */ uint32 des_access = GENERIC_RIGHTS_USER_ALL_ACCESS; + BOOL is_domain_admin = False; /* Get the domain SID stored in the domain policy */ if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted)) @@ -2216,6 +2237,13 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA rpcstr_pull(account, user_account.buffer, sizeof(account), user_account.uni_str_len*2, 0); strlower_m(account); + + /* check to see if we are a domain admin */ + + is_domain_admin = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); + + DEBUG(5, ("_samr_create_user: %s is%s a member of the Domain Admins group\n", + p->pipe_user_name, is_domain_admin ? "" : " not")); pdb_init_sam(&sam_pass); @@ -2235,35 +2263,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA * *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 (-: - * - * We now have seperate script paramaters for adding users/machines so we - * now have some sainity-checking to match. - */ - - DEBUG(10,("checking account %s at pos %lu for $ termination\n",account, (unsigned long)strlen(account)-1)); - - /* - * we used to have code here that made sure the acb_info flags - * matched with the users named (e.g. an account flags as a machine - * trust account ended in '$'). It has been ifdef'd out for a long - * time, so I replaced it with this comment. --jerry - */ - - /* the passdb lookup has failed; check to see if we need to run the - add user/machine script */ - - pw = Get_Pwnam(account); + */ /********************************************************************* * HEADS UP! If we have to create a new user account, we have to get @@ -2276,6 +2276,13 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA * --jerry (2003-07-10) *********************************************************************/ + pw = Get_Pwnam(account); + + /* ================ BEGIN DOMAIN ADMIN BLOCK ================ */ + + if ( is_domain_admin ) + become_root(); + if ( !pw ) { /* * we can't check both the ending $ and the acb_info. @@ -2307,12 +2314,22 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA /* implicit call to getpwnam() next. we have a valid SID coming out of this call */ - if ( !NT_STATUS_IS_OK(nt_status = pdb_init_sam_new(&sam_pass, account, new_rid)) ) + if ( !NT_STATUS_IS_OK(nt_status = pdb_init_sam_new(&sam_pass, account, new_rid)) ) { + if ( is_domain_admin ) + unbecome_root(); return nt_status; + } pdb_set_acct_ctrl(sam_pass, acb_info, PDB_CHANGED); - if (!pdb_add_sam_account(sam_pass)) { + ret = pdb_add_sam_account(sam_pass); + + if ( is_domain_admin ) + unbecome_root(); + + /* ================ END DOMAIN ADMIN BLOCK ================ */ + + if ( !ret ) { pdb_free_sam(&sam_pass); DEBUG(0, ("could not add user/computer %s to passdb. Check permissions?\n", account)); @@ -2320,13 +2337,16 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA } /* Get the user's SID */ + sid_copy(&sid, pdb_get_user_sid(sam_pass)); samr_make_usr_obj_sd(p->mem_ctx, &psd, &sd_size, &sid); se_map_generic(&des_access, &usr_generic_mapping); - if (!NT_STATUS_IS_OK(nt_status = - access_check_samr_object(psd, p->pipe_user.nt_user_token, - des_access, &acc_granted, "_samr_create_user"))) { + + nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, + des_access, &acc_granted, "_samr_create_user"); + + if ( !NT_STATUS_IS_OK(nt_status) ) { return nt_status; } @@ -3011,6 +3031,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE SAM_USERINFO_CTR *ctr = q_u->ctr; uint32 acc_granted; uint32 acc_required; + BOOL is_domain_admin; DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); @@ -3020,7 +3041,17 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - acc_required = SA_RIGHT_USER_SET_LOC_COM | SA_RIGHT_USER_SET_ATTRIBUTES; /* This is probably wrong */ + /* the access mask depends on what the caller wants to do */ + + switch (switch_value) { + case 24: + acc_required = SA_RIGHT_USER_SET_PASSWORD | SA_RIGHT_USER_SET_ATTRIBUTES | SA_RIGHT_USER_ACCT_FLAGS_EXPIRY; + break; + default: + acc_required = SA_RIGHT_USER_SET_LOC_COM | SA_RIGHT_USER_SET_ATTRIBUTES; /* This is probably wrong */ + break; + } + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo"))) { return r_u->status; } @@ -3032,23 +3063,36 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE return NT_STATUS_INVALID_INFO_CLASS; } + /* check to see if we are a domain admin */ + + is_domain_admin = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); + + DEBUG(5, ("_samr_create_user: %s is%s a member of the Domain Admins group\n", + p->pipe_user_name, is_domain_admin ? "" : " not")); + + /* ================ BEGIN DOMAIN ADMIN BLOCK ================ */ + + if ( is_domain_admin ) + become_root(); + /* ok! user info levels (lots: see MSDEV help), off we go... */ + switch (switch_value) { case 0x12: if (!set_user_info_12(ctr->info.id12, &sid)) - return NT_STATUS_ACCESS_DENIED; + r_u->status = NT_STATUS_ACCESS_DENIED; break; case 24: if (!p->session_key.length) { - return NT_STATUS_NO_USER_SESSION_KEY; + r_u->status = NT_STATUS_NO_USER_SESSION_KEY; } SamOEMhashBlob(ctr->info.id24->pass, 516, &p->session_key); dump_data(100, (char *)ctr->info.id24->pass, 516); if (!set_user_info_pw((char *)ctr->info.id24->pass, &sid)) - return NT_STATUS_ACCESS_DENIED; + r_u->status = NT_STATUS_ACCESS_DENIED; break; case 25: @@ -3062,34 +3106,41 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE */ if (!p->session_key.length) { - return NT_STATUS_NO_USER_SESSION_KEY; + r_u->status = NT_STATUS_NO_USER_SESSION_KEY; } SamOEMhashBlob(ctr->info.id25->pass, 532, &p->session_key); dump_data(100, (char *)ctr->info.id25->pass, 532); if (!set_user_info_pw(ctr->info.id25->pass, &sid)) - return NT_STATUS_ACCESS_DENIED; + r_u->status = NT_STATUS_ACCESS_DENIED; break; #endif - return NT_STATUS_INVALID_INFO_CLASS; + r_u->status = NT_STATUS_INVALID_INFO_CLASS; + break; case 23: if (!p->session_key.length) { - return NT_STATUS_NO_USER_SESSION_KEY; + r_u->status = NT_STATUS_NO_USER_SESSION_KEY; } SamOEMhashBlob(ctr->info.id23->pass, 516, &p->session_key); dump_data(100, (char *)ctr->info.id23->pass, 516); if (!set_user_info_23(ctr->info.id23, &sid)) - return NT_STATUS_ACCESS_DENIED; + r_u->status = NT_STATUS_ACCESS_DENIED; break; default: - return NT_STATUS_INVALID_INFO_CLASS; + r_u->status = NT_STATUS_INVALID_INFO_CLASS; } + + if ( is_domain_admin ) + unbecome_root(); + + /* ================ END DOMAIN ADMIN BLOCK ================ */ + return r_u->status; } @@ -3105,6 +3156,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ uint16 switch_value = q_u->switch_value; uint32 acc_granted; uint32 acc_required; + BOOL is_domain_admin; DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__)); @@ -3128,7 +3180,20 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ switch_value=ctr->switch_value; + /* check to see if we are a domain admin */ + + is_domain_admin = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); + + DEBUG(5, ("_samr_create_user: %s is%s a member of the Domain Admins group\n", + p->pipe_user_name, is_domain_admin ? "" : " not")); + + /* ================ BEGIN DOMAIN ADMIN BLOCK ================ */ + + if ( is_domain_admin ) + become_root(); + /* ok! user info levels (lots: see MSDEV help), off we go... */ + switch (switch_value) { case 21: if (!set_user_info_21(ctr->info.id21, &sid)) @@ -3136,21 +3201,26 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ break; case 20: if (!set_user_info_20(ctr->info.id20, &sid)) - return NT_STATUS_ACCESS_DENIED; + r_u->status = NT_STATUS_ACCESS_DENIED; break; case 16: if (!set_user_info_10(ctr->info.id10, &sid)) - return NT_STATUS_ACCESS_DENIED; + r_u->status = NT_STATUS_ACCESS_DENIED; break; case 18: /* Used by AS/U JRA. */ if (!set_user_info_12(ctr->info.id12, &sid)) - return NT_STATUS_ACCESS_DENIED; + r_u->status = NT_STATUS_ACCESS_DENIED; break; default: - return NT_STATUS_INVALID_INFO_CLASS; + r_u->status = NT_STATUS_INVALID_INFO_CLASS; } + if ( is_domain_admin ) + unbecome_root(); + + /* ================ END DOMAIN ADMIN BLOCK ================ */ + return r_u->status; } -- cgit From a9928f0d95670b0e770fc9e8b7673bc863c1253b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 10 Jan 2005 15:28:07 +0000 Subject: r4646: Allow Account Lockout with Lockout Duration "forever" (until admin unlocks) to be set and displayed in User Manager. Guenther (This used to be commit 8fd7e26fa12a4102def630efa421fad70f3affb1) --- source3/rpc_server/srv_samr_nt.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e72cf68c74..da1c386fd2 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2163,7 +2163,9 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA break; case 0x0c: account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); - u_lock_duration = account_policy_temp * 60; + u_lock_duration = account_policy_temp; + if (u_lock_duration != -1) + u_lock_duration *= 60; account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp); u_reset_time = account_policy_temp * 60; @@ -4466,7 +4468,9 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW break; case 0x0c: account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); - u_lock_duration = account_policy_temp * 60; + u_lock_duration = account_policy_temp; + if (u_lock_duration != -1) + u_lock_duration *= 60; account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp); u_reset_time = account_policy_temp * 60; @@ -4534,7 +4538,9 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R case 0x07: break; case 0x0c: - u_lock_duration=nt_time_to_unix_abs(&q_u->ctr->info.inf12.duration)/60; + u_lock_duration=nt_time_to_unix_abs(&q_u->ctr->info.inf12.duration); + if (u_lock_duration != -1) + u_lock_duration /= 60; u_reset_time=nt_time_to_unix_abs(&q_u->ctr->info.inf12.reset_count)/60; account_policy_set(AP_LOCK_ACCOUNT_DURATION, (int)u_lock_duration); -- cgit From deaaa6ee9ee0e3f170498baabca4a175453718ed Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Mon, 10 Jan 2005 18:29:52 +0000 Subject: r4651: Add "refuse machine password change" policy field. This update will just return the appropriate reg value. Enforcement to be added soon. Also, fix account policy tdb upgrade so it doesn't just wipe out everything that was in there from a a previous version. (This used to be commit ccae934cf9de4b234bac324b8d878c8ec7862f67) --- source3/rpc_server/srv_reg_nt.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index dc9db47c66..d85a066e34 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -373,11 +373,22 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) /* couple of hard coded registry values */ if ( strequal(name, "RefusePasswordChange") ) { + uint32 dwValue; + if ( (val = SMB_MALLOC_P(REGISTRY_VALUE)) == NULL ) { DEBUG(0,("_reg_info: malloc() failed!\n")); return NT_STATUS_NO_MEMORY; } - ZERO_STRUCTP( val ); + + if (!account_policy_get(AP_REFUSE_MACHINE_PW_CHANGE, &dwValue)) + dwValue = 0; + regval_ctr_addvalue(®vals, "RefusePasswordChange", + REG_DWORD, + (const char*)&dwValue, sizeof(dwValue)); + val = dup_registry_value( + regval_ctr_specific_value( ®vals, 0 ) ); + + status = NT_STATUS_OK; goto out; } -- cgit From bd22606da04bffd3b4966c17ad2c98e6dc8b5e35 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Jan 2005 20:33:41 +0000 Subject: r4656: Convert the winreg pipe to use WERROR returns (as it should). Also fix return of NT_STATUS_NO_MORE_ENTRIES should be ERROR_NO_MORE_ITEMS reported by "Marcin Porwit" . Jeremy. (This used to be commit 511cdec60d431d767fb02f68ca5ddd4ddb59e64a) --- source3/rpc_server/srv_reg_nt.c | 90 ++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index d85a066e34..27cdf1b1b9 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -79,11 +79,11 @@ static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) HK[LM|U]\\\... *******************************************************************/ -static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY *parent, +static WERROR open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY *parent, const char *subkeyname, uint32 access_granted ) { REGISTRY_KEY *regkey = NULL; - NTSTATUS result = NT_STATUS_OK; + WERROR result = WERR_OK; REGSUBKEY_CTR subkeys; pstring subkeyname2; int subkey_len; @@ -98,7 +98,7 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY subkeyname2[subkey_len-1] = '\0'; if ((regkey=SMB_MALLOC_P(REGISTRY_KEY)) == NULL) - return NT_STATUS_NO_MEMORY; + return WERR_NOMEM; ZERO_STRUCTP( regkey ); @@ -126,7 +126,7 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY if ( !(regkey->hook = reghook_cache_find( regkey->name )) ) { DEBUG(0,("open_registry_key: Failed to assigned a REGISTRY_HOOK to [%s]\n", regkey->name )); - return NT_STATUS_OBJECT_PATH_NOT_FOUND; + return WERR_BADFILE; } /* check if the path really exists; failed is indicated by -1 */ @@ -139,7 +139,7 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY if ( fetch_reg_keys( regkey, &subkeys ) == -1 ) { /* don't really know what to return here */ - result = NT_STATUS_NO_SUCH_FILE; + result = WERR_BADFILE; } else { /* @@ -148,7 +148,7 @@ static NTSTATUS open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY */ if ( !create_policy_hnd( p, hnd, free_regkey_info, regkey ) ) - result = NT_STATUS_OBJECT_NAME_NOT_FOUND; + result = WERR_BADFILE; } /* clean up */ @@ -276,22 +276,22 @@ static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum, reg_close ********************************************************************/ -NTSTATUS _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) +WERROR _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) { /* set up the REG unknown_1 response */ ZERO_STRUCT(r_u->pol); /* close the policy handle */ if (!close_registry_key(p, &q_u->pol)) - return NT_STATUS_OBJECT_NAME_INVALID; + return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************* ********************************************************************/ -NTSTATUS _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u) +WERROR _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u) { return open_registry_key( p, &r_u->pol, NULL, KEY_HKLM, 0x0 ); } @@ -299,7 +299,7 @@ NTSTATUS _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM * /******************************************************************* ********************************************************************/ -NTSTATUS _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HKCR *q_u, REG_R_OPEN_HKCR *r_u) +WERROR _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HKCR *q_u, REG_R_OPEN_HKCR *r_u) { return open_registry_key( p, &r_u->pol, NULL, KEY_HKCR, 0x0 ); } @@ -307,7 +307,7 @@ NTSTATUS _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HKCR *q_u, REG_R_OPEN_HKCR * /******************************************************************* ********************************************************************/ -NTSTATUS _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HKU *q_u, REG_R_OPEN_HKU *r_u) +WERROR _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HKU *q_u, REG_R_OPEN_HKU *r_u) { return open_registry_key( p, &r_u->pol, NULL, KEY_HKU, 0x0 ); } @@ -316,17 +316,17 @@ NTSTATUS _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HKU *q_u, REG_R_OPEN_HKU *r_u reg_reply_open_entry ********************************************************************/ -NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY *r_u) +WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY *r_u) { POLICY_HND pol; fstring name; REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->pol); - NTSTATUS result; + WERROR result; DEBUG(5,("reg_open_entry: Enter\n")); if ( !key ) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ rpcstr_pull(name,q_u->uni_name.buffer,sizeof(name),q_u->uni_name.uni_str_len*2,0); @@ -343,9 +343,9 @@ NTSTATUS _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTR reg_reply_info ********************************************************************/ -NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) +WERROR _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) { - NTSTATUS status = NT_STATUS_NO_SUCH_FILE; + WERROR status = WERR_BADFILE; fstring name; const char *value_ascii = ""; fstring value; @@ -358,7 +358,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) DEBUG(5,("_reg_info: Enter\n")); if ( !regkey ) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); @@ -377,7 +377,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) if ( (val = SMB_MALLOC_P(REGISTRY_VALUE)) == NULL ) { DEBUG(0,("_reg_info: malloc() failed!\n")); - return NT_STATUS_NO_MEMORY; + return WERR_NOMEM; } if (!account_policy_get(AP_REFUSE_MACHINE_PW_CHANGE, &dwValue)) @@ -388,7 +388,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); - status = NT_STATUS_OK; + status = WERR_OK; goto out; } @@ -418,7 +418,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); - status = NT_STATUS_OK; + status = WERR_OK; goto out; } @@ -430,7 +430,7 @@ NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) DEBUG(10,("_reg_info: Testing value [%s]\n", val->valuename)); if ( StrCaseCmp( val->valuename, name ) == 0 ) { DEBUG(10,("_reg_info: Found match for value [%s]\n", name)); - status = NT_STATUS_OK; + status = WERR_OK; break; } @@ -454,21 +454,21 @@ out: Implementation of REG_QUERY_KEY ****************************************************************************/ -NTSTATUS _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_u) +WERROR _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_u) { - NTSTATUS status = NT_STATUS_OK; + WERROR status = WERR_OK; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); DEBUG(5,("_reg_query_key: Enter\n")); if ( !regkey ) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ if ( !get_subkey_information( regkey, &r_u->num_subkeys, &r_u->max_subkeylen ) ) - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; if ( !get_value_information( regkey, &r_u->num_values, &r_u->max_valnamelen, &r_u->max_valbufsize ) ) - return NT_STATUS_ACCESS_DENIED; + return WERR_ACCESS_DENIED; r_u->sec_desc = 0x00000078; /* size for key's sec_desc */ @@ -488,15 +488,15 @@ NTSTATUS _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY * Implementation of REG_UNKNOWN_1A ****************************************************************************/ -NTSTATUS _reg_unknown_1a(pipes_struct *p, REG_Q_UNKNOWN_1A *q_u, REG_R_UNKNOWN_1A *r_u) +WERROR _reg_unknown_1a(pipes_struct *p, REG_Q_UNKNOWN_1A *q_u, REG_R_UNKNOWN_1A *r_u) { - NTSTATUS status = NT_STATUS_OK; + WERROR status = WERR_OK; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); DEBUG(5,("_reg_unknown_1a: Enter\n")); if ( !regkey ) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ r_u->unknown = 0x00000005; /* seems to be consistent...no idea what it means */ @@ -510,9 +510,9 @@ NTSTATUS _reg_unknown_1a(pipes_struct *p, REG_Q_UNKNOWN_1A *q_u, REG_R_UNKNOWN_1 Implementation of REG_ENUM_KEY ****************************************************************************/ -NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u) +WERROR _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u) { - NTSTATUS status = NT_STATUS_OK; + WERROR status = WERR_OK; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); char *subkey = NULL; @@ -520,13 +520,13 @@ NTSTATUS _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u DEBUG(5,("_reg_enum_key: Enter\n")); if ( !regkey ) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", regkey->name)); if ( !fetch_reg_keys_specific( regkey, &subkey, q_u->key_index ) ) { - status = NT_STATUS_NO_MORE_ENTRIES; + status = WERR_NO_MORE_ITEMS; goto done; } @@ -547,9 +547,9 @@ done: Implementation of REG_ENUM_VALUE ****************************************************************************/ -NTSTATUS _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE *r_u) +WERROR _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE *r_u) { - NTSTATUS status = NT_STATUS_OK; + WERROR status = WERR_OK; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); REGISTRY_VALUE *val; @@ -557,13 +557,13 @@ NTSTATUS _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALU DEBUG(5,("_reg_enum_value: Enter\n")); if ( !regkey ) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ DEBUG(8,("_reg_enum_key: enumerating values for key [%s]\n", regkey->name)); if ( !fetch_reg_values_specific( regkey, &val, q_u->val_index ) ) { - status = NT_STATUS_NO_MORE_ENTRIES; + status = WERR_NO_MORE_ITEMS; goto done; } @@ -591,9 +591,9 @@ done: #define SHUTDOWN_F_STRING "-f" -NTSTATUS _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) +WERROR _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) { - NTSTATUS status = NT_STATUS_OK; + WERROR status = WERR_OK; pstring shutdown_script; UNISTR2 unimsg = q_u->uni_msg; pstring message; @@ -632,9 +632,9 @@ NTSTATUS _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u reg_abort_shutdwon ********************************************************************/ -NTSTATUS _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABORT_SHUTDOWN *r_u) +WERROR _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABORT_SHUTDOWN *r_u) { - NTSTATUS status = NT_STATUS_OK; + WERROR status = WERR_OK; pstring abort_shutdown_script; pstrcpy(abort_shutdown_script, lp_abort_shutdown_script()); @@ -652,7 +652,7 @@ NTSTATUS _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_A REG_SAVE_KEY (0x14) ********************************************************************/ -NTSTATUS _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) +WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) { REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); @@ -664,12 +664,12 @@ NTSTATUS _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_ */ if ( !regkey ) - return NT_STATUS_INVALID_HANDLE; + return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ DEBUG(8,("_reg_save_key: berifying backup of key [%s]\n", regkey->name)); - return NT_STATUS_OK; + return WERR_OK; } -- cgit From d94d87472ca2f3875caa146424caa178ce20274f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 13 Jan 2005 18:20:37 +0000 Subject: r4724: Add support for Windows privileges in Samba 3.0 (based on Simo's code in trunk). Rewritten with the following changes: * privilege set is based on a 32-bit mask instead of strings (plans are to extend this to a 64 or 128-bit mask before the next 3.0.11preX release). * Remove the privilege code from the passdb API (replication to come later) * Only support the minimum amount of privileges that make sense. * Rewrite the domain join checks to use the SeMachineAccountPrivilege instead of the 'is a member of "Domain Admins"?' check that started all this. Still todo: * Utilize the SePrintOperatorPrivilege in addition to the 'printer admin' parameter * Utilize the SeAddUserPrivilege for adding users and groups * Fix some of the hard coded _lsa_*() calls * Start work on enough of SAM replication to get privileges from one Samba DC to another. * Come up with some management tool for manipultaing privileges instead of user manager since it is buggy when run on a 2k client (haven't tried xp). Works ok on NT4. (This used to be commit 77c10ff9aa6414a31eece6dfec00793f190a9d6c) --- source3/rpc_server/srv_lsa.c | 32 +++++ source3/rpc_server/srv_lsa_nt.c | 299 ++++++++++++++++++--------------------- source3/rpc_server/srv_samr_nt.c | 44 +++--- 3 files changed, 194 insertions(+), 181 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 5d6c1551c9..63e74ec891 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -392,6 +392,37 @@ static BOOL api_lsa_unk_get_connuser(pipes_struct *p) return True; } +/*************************************************************************** + api_lsa_create_user + ***************************************************************************/ + +static BOOL api_lsa_create_account(pipes_struct *p) +{ + LSA_Q_CREATEACCOUNT q_u; + LSA_R_CREATEACCOUNT r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_create_account("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_create_account: failed to unmarshall LSA_Q_CREATEACCOUNT.\n")); + return False; + } + + r_u.status = _lsa_create_account(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_create_account("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_create_account: Failed to marshall LSA_R_CREATEACCOUNT.\n")); + return False; + } + + return True; +} + /*************************************************************************** api_lsa_open_user ***************************************************************************/ @@ -659,6 +690,7 @@ static struct api_struct api_lsa_cmds[] = { "LSA_PRIV_GET_DISPNAME",LSA_PRIV_GET_DISPNAME,api_lsa_priv_get_dispname}, { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS , api_lsa_enum_accounts }, { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser }, + { "LSA_CREATEACCOUNT" , LSA_CREATEACCOUNT , api_lsa_create_account }, { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT , api_lsa_open_account }, { "LSA_ENUMPRIVSACCOUNT", LSA_ENUMPRIVSACCOUNT, api_lsa_enum_privsaccount}, { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT, api_lsa_getsystemaccount }, diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index fcd574971f..89633935a2 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1,4 +1,4 @@ -/* +/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, @@ -7,6 +7,7 @@ * Copyright (C) Jeremy Allison 2001, * Copyright (C) Rafal Szczesniak 2002, * Copyright (C) Jim McDonough 2002, + * Copyright (C) Simo Sorce 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -411,9 +412,12 @@ NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL DEBUG(4,("ACCESS should be DENIED (granted: %#010x; required: %#010x)\n", acc_granted, des_access)); DEBUGADD(4,("but overwritten by euid == 0\n")); - acc_granted = des_access; } + /* This is needed for lsa_open_account and rpcclient .... :-) */ + + if (geteuid() == 0) + acc_granted = POLICY_ALL_ACCESS; /* associate the domain SID with the (unique) handle. */ if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL) @@ -758,49 +762,51 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV { struct lsa_info *handle; uint32 i; + uint32 enum_context = q_u->enum_context; + int num_privs = count_all_privileges(); + LSA_PRIV_ENTRY *entries = NULL; - uint32 enum_context=q_u->enum_context; - LSA_PRIV_ENTRY *entry; - LSA_PRIV_ENTRY *entries=NULL; + /* remember that the enum_context starts at 0 and not 1 */ - if (enum_context >= PRIV_ALL_INDEX) + if ( enum_context >= num_privs ) return NT_STATUS_NO_MORE_ENTRIES; - - entries = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_PRIV_ENTRY, PRIV_ALL_INDEX); - if (entries==NULL) + + DEBUG(10,("_lsa_enum_privs: enum_context:%d total entries:%d\n", + enum_context, num_privs)); + + if ( !(entries = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_PRIV_ENTRY, num_privs + 1))) return NT_STATUS_NO_MEMORY; if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; - /* check if the user have enough rights */ + /* check if the user have enough rights + I don't know if it's the right one. not documented. */ - /* - * I don't know if it's the right one. not documented. - */ if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - entry = entries; - - DEBUG(10,("_lsa_enum_privs: enum_context:%d total entries:%d\n", enum_context, PRIV_ALL_INDEX)); - - for (i = 0; i < PRIV_ALL_INDEX; i++, entry++) { - if( iname, NULL, UNI_FLAGS_NONE); - init_uni_hdr(&entry->hdr_name, &entry->name); - entry->luid_low = 0; - entry->luid_high = 0; + if ( !(entries = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_PRIV_ENTRY, num_privs )) ) + return NT_STATUS_NO_MEMORY; + + + for (i = 0; i < num_privs; i++) { + if( i < enum_context) { + init_unistr2(&entries[i].name, NULL, UNI_FLAGS_NONE); + init_uni_hdr(&entries[i].hdr_name, &entries[i].name); + entries[i].luid_low = 0; + entries[i].luid_high = 0; } else { - init_unistr2(&entry->name, privs[i+1].priv, UNI_FLAGS_NONE); - init_uni_hdr(&entry->hdr_name, &entry->name); - entry->luid_low = privs[i+1].se_priv; - entry->luid_high = 0; + init_unistr2(&entries[i].name, privs[i].name, UNI_FLAGS_NONE); + init_uni_hdr(&entries[i].hdr_name, &entries[i].name); + entries[i].luid_low = privs[i].se_priv; + entries[i].luid_high = 0; } } - enum_context = PRIV_ALL_INDEX; - init_lsa_r_enum_privs(r_u, enum_context, PRIV_ALL_INDEX, entries); + enum_context = num_privs; + + init_lsa_r_enum_privs(r_u, enum_context, num_privs, entries); return NT_STATUS_OK; } @@ -813,7 +819,7 @@ NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, L { struct lsa_info *handle; fstring name_asc; - int i=1; + int i = 0; if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; @@ -828,22 +834,22 @@ NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, L unistr2_to_ascii(name_asc, &q_u->name, sizeof(name_asc)); - DEBUG(10,("_lsa_priv_get_dispname: %s", name_asc)); + DEBUG(10,("_lsa_priv_get_dispname: %s\n", name_asc)); - while (privs[i].se_priv!=SE_PRIV_ALL && strcmp(name_asc, privs[i].priv)) + while (privs[i].se_priv != SE_END && !strequal(name_asc, privs[i].name)) i++; - if (privs[i].se_priv!=SE_PRIV_ALL) { + if (privs[i].se_priv != SE_END) { DEBUG(10,(": %s\n", privs[i].description)); init_unistr2(&r_u->desc, privs[i].description, UNI_FLAGS_NONE); init_uni_hdr(&r_u->hdr_desc, &r_u->desc); - r_u->ptr_info=0xdeadbeef; - r_u->lang_id=q_u->lang_id; + r_u->ptr_info = 0xdeadbeef; + r_u->lang_id = q_u->lang_id; return NT_STATUS_OK; } else { DEBUG(10,("_lsa_priv_get_dispname: doesn't exist\n")); - r_u->ptr_info=0; + r_u->ptr_info = 0; return NT_STATUS_NO_SUCH_PRIVILEGE; } } @@ -855,32 +861,26 @@ _lsa_enum_accounts. NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENUM_ACCOUNTS *r_u) { struct lsa_info *handle; - GROUP_MAP *map=NULL; - int num_entries=0; + DOM_SID *sid_list; + int i, j, num_entries; LSA_SID_ENUM *sids=&r_u->sids; - int i=0,j=0; - BOOL ret; + NTSTATUS ret; if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; - /* check if the user have enough rights */ - - /* - * I don't know if it's the right one. not documented. - */ if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - /* get the list of mapped groups (domain, local, builtin) */ - become_root(); - ret = pdb_enum_group_mapping(SID_NAME_UNKNOWN, &map, &num_entries, ENUM_ONLY_MAPPED); - unbecome_root(); - if( !ret ) { - DEBUG(3,("_lsa_enum_accounts: enumeration of groups failed!\n")); - return NT_STATUS_OK; + sid_list = NULL; + num_entries = 0; + + /* The only way we can currently find out all the SIDs that have been + privileged is to scan all privileges */ + + if (!NT_STATUS_IS_OK(ret = privilege_enumerate_accounts(&sid_list, &num_entries))) { + return ret; } - if (q_u->enum_context >= num_entries) return NT_STATUS_NO_MORE_ENTRIES; @@ -889,19 +889,18 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU sids->sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_entries-q_u->enum_context); if (sids->ptr_sid==NULL || sids->sid==NULL) { - SAFE_FREE(map); + SAFE_FREE(sid_list); return NT_STATUS_NO_MEMORY; } - for (i=q_u->enum_context, j=0; ienum_context, j = 0; i < num_entries; i++, j++) { + init_dom_sid2(&(*sids).sid[j], &sid_list[i]); + (*sids).ptr_sid[j] = 1; } - SAFE_FREE(map); + SAFE_FREE(sid_list); - init_lsa_r_enum_accounts(r_u, j); + init_lsa_r_enum_accounts(r_u, num_entries); return NT_STATUS_OK; } @@ -934,15 +933,51 @@ NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA } /*************************************************************************** - + Lsa Create Account ***************************************************************************/ -NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENACCOUNT *r_u) +NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CREATEACCOUNT *r_u) { struct lsa_info *handle; struct lsa_info *info; - r_u->status = NT_STATUS_OK; + /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) + return NT_STATUS_INVALID_HANDLE; + + /* check if the user have enough rights */ + + /* + * I don't know if it's the right one. not documented. + * but guessed with rpcclient. + */ + if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) + return NT_STATUS_ACCESS_DENIED; + + /* associate the user/group SID with the (unique) handle. */ + if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL) + return NT_STATUS_NO_MEMORY; + + ZERO_STRUCTP(info); + info->sid = q_u->sid.sid; + info->access = q_u->access; + + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + return privilege_create_account( &info->sid ); +} + + +/*************************************************************************** + Lsa Open Account + ***************************************************************************/ + +NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENACCOUNT *r_u) +{ + struct lsa_info *handle; + struct lsa_info *info; /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) @@ -957,6 +992,11 @@ NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENAC if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) return NT_STATUS_ACCESS_DENIED; + /* TODO: Fis the parsing routine before reenabling this check! */ + #if 0 + if (!lookup_sid(&handle->sid, dom_name, name, &type)) + return NT_STATUS_ACCESS_DENIED; + #endif /* associate the user/group SID with the (unique) handle. */ if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL) return NT_STATUS_NO_MEMORY; @@ -969,7 +1009,7 @@ NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENAC if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - return r_u->status; + return NT_STATUS_OK; } /*************************************************************************** @@ -979,44 +1019,24 @@ NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENAC NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, prs_struct *ps, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_R_ENUMPRIVSACCOUNT *r_u) { struct lsa_info *info=NULL; - GROUP_MAP map; - LUID_ATTR *set=NULL; - - r_u->status = NT_STATUS_OK; + PRIVILEGE_SET priv; /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!pdb_getgrsid(&map, info->sid)) - return NT_STATUS_NO_SUCH_GROUP; + privilege_set_init( &priv ); -#if 0 /* privileges currently not implemented! */ - DEBUG(10,("_lsa_enum_privsaccount: %d privileges\n", map.priv_set->count)); - if (map.priv_set->count!=0) { - - set=(LUID_ATTR *)talloc(map.priv_set->mem_ctx, map.priv_set.count*sizeof(LUID_ATTR)); - if (set == NULL) { - destroy_privilege(&map.priv_set); - return NT_STATUS_NO_MEMORY; - } + get_privileges_for_sids( &priv, &info->sid, 1 ); - for (i = 0; i < map.priv_set.count; i++) { - set[i].luid.low = map.priv_set->set[i].luid.low; - set[i].luid.high = map.priv_set->set[i].luid.high; - set[i].attr = map.priv_set->set[i].attr; - DEBUG(10,("_lsa_enum_privsaccount: priv %d: %d:%d:%d\n", i, - set[i].luid.high, set[i].luid.low, set[i].attr)); - } - } + DEBUG(10,("_lsa_enum_privsaccount: %s has %d privileges\n", + sid_string_static(&info->sid), priv.count)); - init_lsa_r_enum_privsaccount(ps->mem_ctx, r_u, set, map.priv_set->count, 0); - destroy_privilege(&map.priv_set); -#endif + init_lsa_r_enum_privsaccount(ps->mem_ctx, r_u, priv.set, priv.count, 0); - init_lsa_r_enum_privsaccount(ps->mem_ctx, r_u, set, 0, 0); + privilege_set_free( &priv ); - return r_u->status; + return NT_STATUS_OK; } /*************************************************************************** @@ -1026,15 +1046,16 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, prs_struct *ps, LSA_Q_ENUMPRIVS NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA_R_GETSYSTEMACCOUNT *r_u) { struct lsa_info *info=NULL; - GROUP_MAP map; - r_u->status = NT_STATUS_OK; + fstring name, dom_name; + enum SID_NAME_USE type; /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!pdb_getgrsid(&map, info->sid)) - return NT_STATUS_NO_SUCH_GROUP; + if (!lookup_sid(&info->sid, dom_name, name, &type)) + return NT_STATUS_ACCESS_DENIED; /* 0x01 -> Log on locally @@ -1047,7 +1068,7 @@ NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA r_u->access = PR_LOG_ON_LOCALLY | PR_ACCESS_FROM_NETWORK; - return r_u->status; + return NT_STATUS_OK; } /*************************************************************************** @@ -1079,44 +1100,31 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u) { -#if 0 struct lsa_info *info = NULL; - GROUP_MAP map; int i = 0; - LUID_ATTR *luid_attr = NULL; + uint32 mask; PRIVILEGE_SET *set = NULL; -#endif - - r_u->status = NT_STATUS_OK; -#if 0 /* privileges are not implemented */ /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!pdb_getgrsid(&map, info->sid)) - return NT_STATUS_NO_SUCH_GROUP; - set = &q_u->set; for (i = 0; i < set->count; i++) { - luid_attr = &set->set[i]; - - /* check if the privilege is already there */ - if (check_priv_in_privilege(map.priv_set, *luid_attr)){ - destroy_privilege(&map.priv_set); + + mask = luid_to_privilege_mask( &(set->set[i].luid) ); + + if ( mask != SE_END ) { + if ( !grant_privilege( &info->sid, mask ) ) { + DEBUG(3,("_lsa_addprivs: grant_privilege( %s, 0x%x) failed!\n", + sid_string_static(&info->sid), mask )); + return NT_STATUS_NO_SUCH_PRIVILEGE; + } } - - add_privilege(map.priv_set, *luid_attr); } - if(!pdb_update_group_mapping_entry(&map)) - return NT_STATUS_NO_SUCH_GROUP; - - destroy_privilege(&map.priv_set); - -#endif - return r_u->status; + return NT_STATUS_OK; } /*************************************************************************** @@ -1125,57 +1133,30 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEPRIVS *r_u) { -#if 0 struct lsa_info *info = NULL; - GROUP_MAP map; - int i=0; - LUID_ATTR *luid_attr = NULL; + int i = 0; + uint32 mask; PRIVILEGE_SET *set = NULL; -#endif - - r_u->status = NT_STATUS_OK; -#if 0 /* privileges are not implemented */ /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - if (!pdb_getgrsid(&map, info->sid)) - return NT_STATUS_NO_SUCH_GROUP; - - if (q_u->allrights != 0) { - /* log it and return, until I see one myself don't do anything */ - DEBUG(5,("_lsa_removeprivs: trying to remove all privileges ?\n")); - return NT_STATUS_OK; - } - - if (q_u->ptr == 0) { - /* log it and return, until I see one myself don't do anything */ - DEBUG(5,("_lsa_removeprivs: no privileges to remove ?\n")); - return NT_STATUS_OK; - } - set = &q_u->set; for (i = 0; i < set->count; i++) { - luid_attr = &set->set[i]; - - /* if we don't have the privilege, we're trying to remove, give up */ - /* what else can we do ??? JFM. */ - if (!check_priv_in_privilege(map.priv_set, *luid_attr)){ - destroy_privilege(&map.priv_set); - return NT_STATUS_NO_SUCH_PRIVILEGE; + mask = luid_to_privilege_mask( &(set->set[i].luid) ); + + if ( mask != SE_END ) { + if ( !revoke_privilege( &info->sid, mask ) ) { + DEBUG(3,("_lsa_removeprivs: revoke_privilege( %s, 0x%x) failed!\n", + sid_string_static(&info->sid), mask )); + return NT_STATUS_NO_SUCH_PRIVILEGE; + } } - - remove_privilege(map.priv_set, *luid_attr); } - if(!pdb_update_group_mapping_entry(&map)) - return NT_STATUS_NO_SUCH_GROUP; - - destroy_privilege(&map.priv_set); -#endif - return r_u->status; + return NT_STATUS_OK; } /*************************************************************************** diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index da1c386fd2..271553f4b2 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2215,7 +2215,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA uint32 new_rid = 0; /* check this, when giving away 'add computer to domain' privs */ uint32 des_access = GENERIC_RIGHTS_USER_ALL_ACCESS; - BOOL is_domain_admin = False; + BOOL can_add_machines = False; /* Get the domain SID stored in the domain policy */ if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted)) @@ -2242,10 +2242,10 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA /* check to see if we are a domain admin */ - is_domain_admin = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); + can_add_machines = user_has_privilege( p->pipe_user.nt_user_token, SE_MACHINE_ACCOUNT ); DEBUG(5, ("_samr_create_user: %s is%s a member of the Domain Admins group\n", - p->pipe_user_name, is_domain_admin ? "" : " not")); + p->pipe_user_name, can_add_machines ? "" : " not")); pdb_init_sam(&sam_pass); @@ -2280,9 +2280,9 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA pw = Get_Pwnam(account); - /* ================ BEGIN DOMAIN ADMIN BLOCK ================ */ + /* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */ - if ( is_domain_admin ) + if ( can_add_machines ) become_root(); if ( !pw ) { @@ -2317,7 +2317,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA /* implicit call to getpwnam() next. we have a valid SID coming out of this call */ if ( !NT_STATUS_IS_OK(nt_status = pdb_init_sam_new(&sam_pass, account, new_rid)) ) { - if ( is_domain_admin ) + if ( can_add_machines ) unbecome_root(); return nt_status; } @@ -2326,10 +2326,10 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA ret = pdb_add_sam_account(sam_pass); - if ( is_domain_admin ) + if ( can_add_machines ) unbecome_root(); - /* ================ END DOMAIN ADMIN BLOCK ================ */ + /* ================ END SeMachineAccountPrivilege BLOCK ================ */ if ( !ret ) { pdb_free_sam(&sam_pass); @@ -3033,7 +3033,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE SAM_USERINFO_CTR *ctr = q_u->ctr; uint32 acc_granted; uint32 acc_required; - BOOL is_domain_admin; + BOOL can_add_machines; DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); @@ -3067,14 +3067,14 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE /* check to see if we are a domain admin */ - is_domain_admin = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); + can_add_machines = user_has_privilege( p->pipe_user.nt_user_token, SE_MACHINE_ACCOUNT ); DEBUG(5, ("_samr_create_user: %s is%s a member of the Domain Admins group\n", - p->pipe_user_name, is_domain_admin ? "" : " not")); + p->pipe_user_name, can_add_machines ? "" : " not")); - /* ================ BEGIN DOMAIN ADMIN BLOCK ================ */ + /* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */ - if ( is_domain_admin ) + if ( can_add_machines ) become_root(); /* ok! user info levels (lots: see MSDEV help), off we go... */ @@ -3138,10 +3138,10 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE } - if ( is_domain_admin ) + if ( can_add_machines ) unbecome_root(); - /* ================ END DOMAIN ADMIN BLOCK ================ */ + /* ================ END SeMachineAccountPrivilege BLOCK ================ */ return r_u->status; } @@ -3158,7 +3158,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ uint16 switch_value = q_u->switch_value; uint32 acc_granted; uint32 acc_required; - BOOL is_domain_admin; + BOOL can_add_machines; DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__)); @@ -3184,14 +3184,14 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ /* check to see if we are a domain admin */ - is_domain_admin = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); + can_add_machines = user_has_privilege( p->pipe_user.nt_user_token, SE_MACHINE_ACCOUNT ); DEBUG(5, ("_samr_create_user: %s is%s a member of the Domain Admins group\n", - p->pipe_user_name, is_domain_admin ? "" : " not")); + p->pipe_user_name, can_add_machines ? "" : " not")); - /* ================ BEGIN DOMAIN ADMIN BLOCK ================ */ + /* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */ - if ( is_domain_admin ) + if ( can_add_machines ) become_root(); /* ok! user info levels (lots: see MSDEV help), off we go... */ @@ -3218,10 +3218,10 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ r_u->status = NT_STATUS_INVALID_INFO_CLASS; } - if ( is_domain_admin ) + if ( can_add_machines ) unbecome_root(); - /* ================ END DOMAIN ADMIN BLOCK ================ */ + /* ================ END SeMachineAccountPrivilege BLOCK ================ */ return r_u->status; } -- cgit From c3ba8b9a53617c75ffbcfa8ef32044cb1691d693 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 14 Jan 2005 19:26:13 +0000 Subject: r4736: small set of merges from rtunk to minimize the diffs (This used to be commit 4b351f2fcc365a7b7f8c22b5139c299aa54c9458) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 271553f4b2..4c3f95fe6b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -75,7 +75,7 @@ static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd level of access for further checks. ********************************************************************/ -NTSTATUS access_check_samr_object(SEC_DESC *psd, NT_USER_TOKEN *nt_user_token, uint32 des_access, +static NTSTATUS access_check_samr_object(SEC_DESC *psd, NT_USER_TOKEN *nt_user_token, uint32 des_access, uint32 *acc_granted, const char *debug) { NTSTATUS status = NT_STATUS_ACCESS_DENIED; @@ -100,7 +100,7 @@ NTSTATUS access_check_samr_object(SEC_DESC *psd, NT_USER_TOKEN *nt_user_token, u Checks if access to a function can be granted ********************************************************************/ -NTSTATUS access_check_samr_function(uint32 acc_granted, uint32 acc_required, const char *debug) +static NTSTATUS access_check_samr_function(uint32 acc_granted, uint32 acc_required, const char *debug) { DEBUG(5,("%s: access check ((granted: %#010x; required: %#010x)\n", debug, acc_granted, acc_required)); -- cgit From 16b2db57a72e300117097f6d6f734e2827a0cc82 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 14 Jan 2005 21:05:54 +0000 Subject: r4739: require membership in Domain Admins to be able to set privileges (This used to be commit e8b4cedc2081eeff53d86c2d894632e57a17926f) --- source3/rpc_server/srv_lsa_nt.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 89633935a2..328f409cf3 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -954,7 +954,14 @@ NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CR if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) return NT_STATUS_ACCESS_DENIED; + /* check to see if the pipe_user is a Domain Admin since + account_pol.tdb was already opened as root, this is all we have */ + + if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + return NT_STATUS_ACCESS_DENIED; + /* associate the user/group SID with the (unique) handle. */ + if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL) return NT_STATUS_NO_MEMORY; @@ -1085,6 +1092,12 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; + /* check to see if the pipe_user is a Domain Admin since + account_pol.tdb was already opened as root, this is all we have */ + + if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + return NT_STATUS_ACCESS_DENIED; + if (!pdb_getgrsid(&map, info->sid)) return NT_STATUS_NO_SUCH_GROUP; @@ -1108,6 +1121,12 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; + + /* check to see if the pipe_user is a Domain Admin since + account_pol.tdb was already opened as root, this is all we have */ + + if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + return NT_STATUS_ACCESS_DENIED; set = &q_u->set; @@ -1142,6 +1161,12 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; + /* check to see if the pipe_user is a Domain Admin since + account_pol.tdb was already opened as root, this is all we have */ + + if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + return NT_STATUS_ACCESS_DENIED; + set = &q_u->set; for (i = 0; i < set->count; i++) { -- cgit From 2c33c41b0c98ee36f5c9b6a368deb1192360fd5b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 14 Jan 2005 21:24:15 +0000 Subject: r4740: allow SE_PRINT_OPERATORS to have printer admin access (This used to be commit 85731706c9d794e8bd3f26ce9b1f881c1ee6a3ba) --- source3/rpc_server/srv_spoolss_nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a3424fe73b..ba3ee4706c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1689,10 +1689,12 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, return WERR_ACCESS_DENIED; } - /* if the user is not root and not a printer admin, then fail */ + /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege, + and not a printer admin, then fail */ if ( user.uid != 0 - && !user_in_list(uidtoname(user.uid), lp_printer_admin(snum), user.groups, user.ngroups) ) + && !user_has_privilege( user.nt_user_token, SE_PRINT_OPERATOR ) + && !user_in_list(uidtoname(user.uid), lp_printer_admin(snum), user.groups, user.ngroups) ) { close_printer_handle(p, handle); return WERR_ACCESS_DENIED; -- cgit From c727866172b5abb1cab0913eb78f3f1d58fcb9aa Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 15 Jan 2005 02:20:30 +0000 Subject: r4742: add server support for lsa_add/remove_account_rights() and fix some parsing bugs related to that code (This used to be commit 7bf1312287cc1ec6b97917ba25fc60d6db09f26c) --- source3/rpc_server/srv_lsa.c | 66 ++++++++++++++++++++++++- source3/rpc_server/srv_lsa_nt.c | 107 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 63e74ec891..e250677534 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -642,7 +642,69 @@ static BOOL api_lsa_query_secobj(pipes_struct *p) } /*************************************************************************** - api_lsa_query_dnsdomainfo + api_lsa_add_acct_rights + ***************************************************************************/ + +static BOOL api_lsa_add_acct_rights(pipes_struct *p) +{ + LSA_Q_ADD_ACCT_RIGHTS q_u; + LSA_R_ADD_ACCT_RIGHTS r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_add_acct_rights("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_add_acct_rights: failed to unmarshall LSA_Q_ADD_ACCT_RIGHTS.\n")); + return False; + } + + r_u.status = _lsa_add_acct_rights(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_add_acct_rights("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_add_acct_rights: Failed to marshall LSA_R_ADD_ACCT_RIGHTS.\n")); + return False; + } + + return True; +} + +/*************************************************************************** + api_lsa_remove_acct_rights + ***************************************************************************/ + +static BOOL api_lsa_remove_acct_rights(pipes_struct *p) +{ + LSA_Q_REMOVE_ACCT_RIGHTS q_u; + LSA_R_REMOVE_ACCT_RIGHTS r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_remove_acct_rights("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_remove_acct_rights: failed to unmarshall LSA_Q_REMOVE_ACCT_RIGHTS.\n")); + return False; + } + + r_u.status = _lsa_remove_acct_rights(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_remove_acct_rights("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_remove_acct_rights: Failed to marshall LSA_R_REMOVE_ACCT_RIGHTS.\n")); + return False; + } + + return True; +} + +/*************************************************************************** + api_lsa_query_info2 ***************************************************************************/ static BOOL api_lsa_query_info2(pipes_struct *p) @@ -697,6 +759,8 @@ static struct api_struct api_lsa_cmds[] = { "LSA_SETSYSTEMACCOUNT", LSA_SETSYSTEMACCOUNT, api_lsa_setsystemaccount }, { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs }, { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs }, + { "LSA_ADDACCTRIGHTS" , LSA_ADDACCTRIGHTS , api_lsa_add_acct_rights }, + { "LSA_REMOVEACCTRIGHTS", LSA_REMOVEACCTRIGHTS, api_lsa_remove_acct_rights }, { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, /* be careful of the adding of new RPC's. See commentrs below about ADS DC capabilities */ diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 328f409cf3..d5bddef739 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1237,6 +1237,8 @@ NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUER return r_u->status; } +/*************************************************************************** + ***************************************************************************/ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_INFO2 *r_u) { @@ -1297,3 +1299,108 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I return r_u->status; } + +/*************************************************************************** + ***************************************************************************/ + +NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R_ADD_ACCT_RIGHTS *r_u) +{ + struct lsa_info *info = NULL; + int i = 0; + DOM_SID sid; + fstring privname; + UNISTR2_ARRAY *uni_privnames = &q_u->rights; + + + /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; + + /* check to see if the pipe_user is a Domain Admin since + account_pol.tdb was already opened as root, this is all we have */ + + if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + return NT_STATUS_ACCESS_DENIED; + + /* according to an NT4 PDC, you can add privileges to SIDs even without + call_lsa_create_account() first. And you can use any arbitrary SID. */ + + sid_copy( &sid, &q_u->sid.sid ); + + /* just a little sanity check */ + + if ( q_u->count != uni_privnames->count ) { + DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n")); + return NT_STATUS_INVALID_HANDLE; + } + + for ( i=0; icount; i++ ) { + unistr2_to_ascii( privname, &uni_privnames->strings[i].string, sizeof(fstring)-1 ); + + /* only try to add non-null strings */ + + if ( *privname && !grant_privilege_by_name( &sid, privname ) ) { + DEBUG(2,("_lsa_add_acct_rights: Failed to add privilege [%s]\n", privname )); + return NT_STATUS_NO_SUCH_PRIVILEGE; + } + } + + return NT_STATUS_OK; +} + +/*************************************************************************** + ***************************************************************************/ + +NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, LSA_R_REMOVE_ACCT_RIGHTS *r_u) +{ + struct lsa_info *info = NULL; + int i = 0; + DOM_SID sid; + fstring privname; + UNISTR2_ARRAY *uni_privnames = &q_u->rights; + + + /* find the connection policy handle. */ + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; + + /* check to see if the pipe_user is a Domain Admin since + account_pol.tdb was already opened as root, this is all we have */ + + if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + return NT_STATUS_ACCESS_DENIED; + + /* according to an NT4 PDC, you can add privileges to SIDs even without + call_lsa_create_account() first. And you can use any arbitrary SID. */ + + sid_copy( &sid, &q_u->sid.sid ); + + if ( q_u->removeall ) { + if ( !revoke_privilege( &sid, SE_ALL_PRIVS ) ) + return NT_STATUS_ACCESS_DENIED; + + return NT_STATUS_OK; + } + + /* just a little sanity check */ + + if ( q_u->count != uni_privnames->count ) { + DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n")); + return NT_STATUS_INVALID_HANDLE; + } + + for ( i=0; icount; i++ ) { + unistr2_to_ascii( privname, &uni_privnames->strings[i].string, sizeof(fstring)-1 ); + + /* only try to add non-null strings */ + + if ( *privname && !revoke_privilege_by_name( &sid, privname ) ) { + DEBUG(2,("_lsa_remove_acct_rights: Failed to add privilege [%s]\n", privname )); + return NT_STATUS_NO_SUCH_PRIVILEGE; + } + } + + return NT_STATUS_OK; +} + + -- cgit From ff909274787a92fcdb0ed36bab097f7d2ae07036 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 15 Jan 2005 03:54:03 +0000 Subject: r4746: add server support for lsa_enum_acct_rights(); last checkin for the night (This used to be commit ccdff4a998405544433aa32938963e4c37962fcc) --- source3/rpc_server/srv_lsa.c | 32 ++++++++++++++++++++++++++++++++ source3/rpc_server/srv_lsa_nt.c | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index e250677534..e3c7832aac 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -703,6 +703,37 @@ static BOOL api_lsa_remove_acct_rights(pipes_struct *p) return True; } +/*************************************************************************** + api_lsa_enum_acct_rights + ***************************************************************************/ + +static BOOL api_lsa_enum_acct_rights(pipes_struct *p) +{ + LSA_Q_ENUM_ACCT_RIGHTS q_u; + LSA_R_ENUM_ACCT_RIGHTS r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_enum_acct_rights("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_enum_acct_rights: failed to unmarshall LSA_Q_ENUM_ACCT_RIGHTS.\n")); + return False; + } + + r_u.status = _lsa_enum_acct_rights(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_enum_acct_rights("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_enum_acct_rights: Failed to marshall LSA_R_ENUM_ACCT_RIGHTS.\n")); + return False; + } + + return True; +} + /*************************************************************************** api_lsa_query_info2 ***************************************************************************/ @@ -761,6 +792,7 @@ static struct api_struct api_lsa_cmds[] = { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs }, { "LSA_ADDACCTRIGHTS" , LSA_ADDACCTRIGHTS , api_lsa_add_acct_rights }, { "LSA_REMOVEACCTRIGHTS", LSA_REMOVEACCTRIGHTS, api_lsa_remove_acct_rights }, + { "LSA_ENUMACCTRIGHTS" , LSA_ENUMACCTRIGHTS , api_lsa_enum_acct_rights }, { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, /* be careful of the adding of new RPC's. See commentrs below about ADS DC capabilities */ diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index d5bddef739..304e1d363c 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1370,9 +1370,6 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) return NT_STATUS_ACCESS_DENIED; - /* according to an NT4 PDC, you can add privileges to SIDs even without - call_lsa_create_account() first. And you can use any arbitrary SID. */ - sid_copy( &sid, &q_u->sid.sid ); if ( q_u->removeall ) { @@ -1395,7 +1392,7 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, /* only try to add non-null strings */ if ( *privname && !revoke_privilege_by_name( &sid, privname ) ) { - DEBUG(2,("_lsa_remove_acct_rights: Failed to add privilege [%s]\n", privname )); + DEBUG(2,("_lsa_remove_acct_rights: Failed to revoke privilege [%s]\n", privname )); return NT_STATUS_NO_SUCH_PRIVILEGE; } } @@ -1404,3 +1401,32 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, } +NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA_R_ENUM_ACCT_RIGHTS *r_u) +{ + struct lsa_info *info = NULL; + DOM_SID sid; + PRIVILEGE_SET privileges; + + + /* find the connection policy handle. */ + + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; + + /* according to an NT4 PDC, you can add privileges to SIDs even without + call_lsa_create_account() first. And you can use any arbitrary SID. */ + + sid_copy( &sid, &q_u->sid.sid ); + + privilege_set_init( &privileges ); + + get_privileges_for_sids( &privileges, &sid, 1 ); + + r_u->status = init_r_enum_acct_rights( r_u, &privileges ); + + privilege_set_free( &privileges ); + + return r_u->status; +} + + -- cgit From 46e5effea948931509283cb84b27007d34b521c8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 17 Jan 2005 15:23:11 +0000 Subject: r4805: Last planned change to the privileges infrastructure: * rewrote the tdb layout of privilege records in account_pol.tdb (allow for 128 bits instead of 32 bit flags) * migrated to using SE_PRIV structure instead of the PRIVILEGE_SET structure. The latter is now used for parsing routines mainly. Still need to incorporate some client support into 'net' so for setting privileges. And make use of the SeAddUserPrivilege right. (This used to be commit 41dc7f7573c6d637e19a01e7ed0e716ac0f1fb15) --- source3/rpc_server/srv_lsa_nt.c | 106 +++++++++++++++++++++--------------- source3/rpc_server/srv_samr_nt.c | 9 ++- source3/rpc_server/srv_spoolss_nt.c | 4 +- 3 files changed, 72 insertions(+), 47 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 304e1d363c..e5154dbb53 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -765,6 +765,7 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV uint32 enum_context = q_u->enum_context; int num_privs = count_all_privileges(); LSA_PRIV_ENTRY *entries = NULL; + LUID_ATTR luid; /* remember that the enum_context starts at 0 and not 1 */ @@ -794,13 +795,17 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV if( i < enum_context) { init_unistr2(&entries[i].name, NULL, UNI_FLAGS_NONE); init_uni_hdr(&entries[i].hdr_name, &entries[i].name); + entries[i].luid_low = 0; entries[i].luid_high = 0; } else { init_unistr2(&entries[i].name, privs[i].name, UNI_FLAGS_NONE); init_uni_hdr(&entries[i].hdr_name, &entries[i].name); - entries[i].luid_low = privs[i].se_priv; - entries[i].luid_high = 0; + + luid = get_privilege_luid( &privs[i].se_priv ); + + entries[i].luid_low = luid.luid.low; + entries[i].luid_high = luid.luid.high; } } @@ -819,7 +824,7 @@ NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, L { struct lsa_info *handle; fstring name_asc; - int i = 0; + const char *description; if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; @@ -834,22 +839,25 @@ NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, L unistr2_to_ascii(name_asc, &q_u->name, sizeof(name_asc)); - DEBUG(10,("_lsa_priv_get_dispname: %s\n", name_asc)); + DEBUG(10,("_lsa_priv_get_dispname: name = %s\n", name_asc)); - while (privs[i].se_priv != SE_END && !strequal(name_asc, privs[i].name)) - i++; + description = get_privilege_dispname( name_asc ); - if (privs[i].se_priv != SE_END) { - DEBUG(10,(": %s\n", privs[i].description)); - init_unistr2(&r_u->desc, privs[i].description, UNI_FLAGS_NONE); + if ( description ) { + DEBUG(10,("_lsa_priv_get_dispname: display name = %s\n", description)); + + init_unistr2(&r_u->desc, description, UNI_FLAGS_NONE); init_uni_hdr(&r_u->hdr_desc, &r_u->desc); r_u->ptr_info = 0xdeadbeef; r_u->lang_id = q_u->lang_id; + return NT_STATUS_OK; } else { DEBUG(10,("_lsa_priv_get_dispname: doesn't exist\n")); + r_u->ptr_info = 0; + return NT_STATUS_NO_SUCH_PRIVILEGE; } } @@ -1026,24 +1034,31 @@ NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENAC NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, prs_struct *ps, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_R_ENUMPRIVSACCOUNT *r_u) { struct lsa_info *info=NULL; - PRIVILEGE_SET priv; + SE_PRIV mask; + PRIVILEGE_SET privileges; /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - privilege_set_init( &priv ); + if ( !get_privileges_for_sids( &mask, &info->sid, 1 ) ) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; - get_privileges_for_sids( &priv, &info->sid, 1 ); + privilege_set_init( &privileges ); - DEBUG(10,("_lsa_enum_privsaccount: %s has %d privileges\n", - sid_string_static(&info->sid), priv.count)); + if ( se_priv_to_privilege_set( &privileges, &mask ) ) { - init_lsa_r_enum_privsaccount(ps->mem_ctx, r_u, priv.set, priv.count, 0); + DEBUG(10,("_lsa_enum_privsaccount: %s has %d privileges\n", + sid_string_static(&info->sid), privileges.count)); - privilege_set_free( &priv ); + r_u->status = init_lsa_r_enum_privsaccount(ps->mem_ctx, r_u, privileges.set, privileges.count, 0); + } + else + r_u->status = NT_STATUS_NO_SUCH_PRIVILEGE; - return NT_STATUS_OK; + privilege_set_free( &privileges ); + + return r_u->status; } /*************************************************************************** @@ -1114,8 +1129,7 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u) { struct lsa_info *info = NULL; - int i = 0; - uint32 mask; + SE_PRIV mask; PRIVILEGE_SET *set = NULL; /* find the connection policy handle. */ @@ -1130,17 +1144,15 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u set = &q_u->set; - for (i = 0; i < set->count; i++) { - - mask = luid_to_privilege_mask( &(set->set[i].luid) ); + if ( !privilege_set_to_se_priv( &mask, set ) ) + return NT_STATUS_NO_SUCH_PRIVILEGE; - if ( mask != SE_END ) { - if ( !grant_privilege( &info->sid, mask ) ) { - DEBUG(3,("_lsa_addprivs: grant_privilege( %s, 0x%x) failed!\n", - sid_string_static(&info->sid), mask )); - return NT_STATUS_NO_SUCH_PRIVILEGE; - } - } + if ( !grant_privilege( &info->sid, &mask ) ) { + DEBUG(3,("_lsa_addprivs: grant_privilege(%s) failed!\n", + sid_string_static(&info->sid) )); + DEBUG(3,("Privilege mask:\n")); + dump_se_priv( DBGC_ALL, 3, &mask ); + return NT_STATUS_NO_SUCH_PRIVILEGE; } return NT_STATUS_OK; @@ -1153,8 +1165,7 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEPRIVS *r_u) { struct lsa_info *info = NULL; - int i = 0; - uint32 mask; + SE_PRIV mask; PRIVILEGE_SET *set = NULL; /* find the connection policy handle. */ @@ -1169,16 +1180,15 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP set = &q_u->set; - for (i = 0; i < set->count; i++) { - mask = luid_to_privilege_mask( &(set->set[i].luid) ); + if ( !privilege_set_to_se_priv( &mask, set ) ) + return NT_STATUS_NO_SUCH_PRIVILEGE; - if ( mask != SE_END ) { - if ( !revoke_privilege( &info->sid, mask ) ) { - DEBUG(3,("_lsa_removeprivs: revoke_privilege( %s, 0x%x) failed!\n", - sid_string_static(&info->sid), mask )); - return NT_STATUS_NO_SUCH_PRIVILEGE; - } - } + if ( !revoke_privilege( &info->sid, &mask ) ) { + DEBUG(3,("_lsa_removeprivs: revoke_privilege(%s) failed!\n", + sid_string_static(&info->sid) )); + DEBUG(3,("Privilege mask:\n")); + dump_se_priv( DBGC_ALL, 3, &mask ); + return NT_STATUS_NO_SUCH_PRIVILEGE; } return NT_STATUS_OK; @@ -1373,7 +1383,7 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, sid_copy( &sid, &q_u->sid.sid ); if ( q_u->removeall ) { - if ( !revoke_privilege( &sid, SE_ALL_PRIVS ) ) + if ( !revoke_all_privileges( &sid ) ) return NT_STATUS_ACCESS_DENIED; return NT_STATUS_OK; @@ -1406,6 +1416,7 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA struct lsa_info *info = NULL; DOM_SID sid; PRIVILEGE_SET privileges; + SE_PRIV mask; /* find the connection policy handle. */ @@ -1418,11 +1429,20 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA sid_copy( &sid, &q_u->sid.sid ); + if ( !get_privileges_for_sids( &mask, &sid, 1 ) ) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + privilege_set_init( &privileges ); - get_privileges_for_sids( &privileges, &sid, 1 ); + if ( se_priv_to_privilege_set( &privileges, &mask ) ) { + + DEBUG(10,("_lsa_enum_acct_rights: %s has %d privileges\n", + sid_string_static(&sid), privileges.count)); - r_u->status = init_r_enum_acct_rights( r_u, &privileges ); + r_u->status = init_r_enum_acct_rights( r_u, &privileges ); + } + else + r_u->status = NT_STATUS_NO_SUCH_PRIVILEGE; privilege_set_free( &privileges ); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 4c3f95fe6b..515eefb1fa 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2216,6 +2216,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA /* check this, when giving away 'add computer to domain' privs */ uint32 des_access = GENERIC_RIGHTS_USER_ALL_ACCESS; BOOL can_add_machines = False; + SE_PRIV se_machineop = SE_MACHINE_ACCOUNT; /* Get the domain SID stored in the domain policy */ if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted)) @@ -2242,7 +2243,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA /* check to see if we are a domain admin */ - can_add_machines = user_has_privilege( p->pipe_user.nt_user_token, SE_MACHINE_ACCOUNT ); + can_add_machines = user_has_privileges( p->pipe_user.nt_user_token, &se_machineop ); DEBUG(5, ("_samr_create_user: %s is%s a member of the Domain Admins group\n", p->pipe_user_name, can_add_machines ? "" : " not")); @@ -3034,6 +3035,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE uint32 acc_granted; uint32 acc_required; BOOL can_add_machines; + SE_PRIV se_machineop = SE_MACHINE_ACCOUNT; DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); @@ -3067,7 +3069,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE /* check to see if we are a domain admin */ - can_add_machines = user_has_privilege( p->pipe_user.nt_user_token, SE_MACHINE_ACCOUNT ); + can_add_machines = user_has_privileges( p->pipe_user.nt_user_token, &se_machineop ); DEBUG(5, ("_samr_create_user: %s is%s a member of the Domain Admins group\n", p->pipe_user_name, can_add_machines ? "" : " not")); @@ -3159,6 +3161,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ uint32 acc_granted; uint32 acc_required; BOOL can_add_machines; + SE_PRIV se_machineop = SE_MACHINE_ACCOUNT; DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__)); @@ -3184,7 +3187,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ /* check to see if we are a domain admin */ - can_add_machines = user_has_privilege( p->pipe_user.nt_user_token, SE_MACHINE_ACCOUNT ); + can_add_machines = user_has_privileges( p->pipe_user.nt_user_token, &se_machineop ); DEBUG(5, ("_samr_create_user: %s is%s a member of the Domain Admins group\n", p->pipe_user_name, can_add_machines ? "" : " not")); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ba3ee4706c..12611c4ee5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1684,6 +1684,8 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, if ( printer_default->access_required & SERVER_ACCESS_ADMINISTER ) { + SE_PRIV se_printop = SE_PRINT_OPERATOR; + if (!lp_ms_add_printer_wizard()) { close_printer_handle(p, handle); return WERR_ACCESS_DENIED; @@ -1693,7 +1695,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, and not a printer admin, then fail */ if ( user.uid != 0 - && !user_has_privilege( user.nt_user_token, SE_PRINT_OPERATOR ) + && !user_has_privileges( user.nt_user_token, &se_printop ) && !user_in_list(uidtoname(user.uid), lp_printer_admin(snum), user.groups, user.ngroups) ) { close_printer_handle(p, handle); -- cgit From b4aaa2ae25c0282287943a43bd0939683dfb2582 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 18 Jan 2005 18:29:28 +0000 Subject: r4822: fix return code when you ask for a non-privileged SID via one of the privileges RPC calls (This used to be commit 3f4f2c80fd157796a7ba56f31f921e8a3ce46bc3) --- source3/rpc_server/srv_lsa_nt.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index e5154dbb53..13053d9877 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -967,6 +967,9 @@ NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CR if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) return NT_STATUS_ACCESS_DENIED; + + if ( is_privileged_sid( &info->sid ) ) + return NT_STATUS_OBJECT_NAME_COLLISION; /* associate the user/group SID with the (unique) handle. */ -- cgit From d50816d59a830ab1ecea271063fe0b2fade9683d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 18 Jan 2005 18:30:32 +0000 Subject: r4824: wrap the shutdown and abort_shutdown calls in check for the SE_REMOTE_SHUTDOWN privilege (This used to be commit d11339b7e3b890b8e01744b6b309efaa7ad328e1) --- source3/rpc_server/srv_reg_nt.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 27cdf1b1b9..c11e0d59a0 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -604,7 +604,7 @@ WERROR _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) /* message */ rpcstr_pull (message, unimsg.buffer, sizeof(message), unimsg.uni_str_len*2,0); - /* security check */ + /* security check */ alpha_strcpy (chkmsg, message, NULL, sizeof(message)); /* timeout */ fstr_sprintf(timeout, "%d", q_u->timeout); @@ -617,12 +617,23 @@ WERROR _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) if(*shutdown_script) { int shutdown_ret; + SE_PRIV se_shutdown = SE_REMOTE_SHUTDOWN; + BOOL can_shutdown; + + can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_shutdown ); + + /********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/ + if ( can_shutdown ) + become_root(); all_string_sub(shutdown_script, "%m", chkmsg, sizeof(shutdown_script)); all_string_sub(shutdown_script, "%t", timeout, sizeof(shutdown_script)); all_string_sub(shutdown_script, "%r", r, sizeof(shutdown_script)); all_string_sub(shutdown_script, "%f", f, sizeof(shutdown_script)); shutdown_ret = smbrun(shutdown_script,NULL); DEBUG(3,("_reg_shutdown: Running the command `%s' gave %d\n",shutdown_script,shutdown_ret)); + if ( can_shutdown ) + unbecome_root(); + /********** END SeRemoteShutdownPrivilege BLOCK **********/ } return status; @@ -641,8 +652,20 @@ WERROR _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABO if(*abort_shutdown_script) { int abort_shutdown_ret; + SE_PRIV se_shutdown = SE_REMOTE_SHUTDOWN; + BOOL can_shutdown; + + can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_shutdown ); + + /********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/ + if ( can_shutdown ) + become_root(); abort_shutdown_ret = smbrun(abort_shutdown_script,NULL); DEBUG(3,("_reg_abort_shutdown: Running the command `%s' gave %d\n",abort_shutdown_script,abort_shutdown_ret)); + if ( can_shutdown ) + unbecome_root(); + /********** END SeRemoteShutdownPrivilege BLOCK **********/ + } return status; -- cgit From 10861a6160fb1ead19e23ff58f3590813600fc7b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 18 Jan 2005 19:51:36 +0000 Subject: r4825: Printing changes ---------------- * bracket the add/delete/set printer scripts with checks for se_print_op * slight change to the add/set printer script semantics. smbd no longer relies on output from the script (on stdout) to re-read smb.conf * remove SIGHUP from set/add/delete printin script code and now just use MSG_SMB_CONF_UPDATED * bracket the add/delete/set share scripts with checks for se_print_op (this includes setting share ACLs) (This used to be commit 8ab8113d2e1bec6a1dbf464882ad724c7c591be4) --- source3/rpc_server/srv_spoolss_nt.c | 74 +++++++++++++++++++------ source3/rpc_server/srv_srvsvc_nt.c | 107 ++++++++++++++++++++++++++---------- 2 files changed, 136 insertions(+), 45 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 12611c4ee5..31e1e4a3bf 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -379,29 +379,50 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) return WERR_ACCESS_DENIED; } #endif - + + /* this does not need a become root since the access check has been + done on the handle already */ + if (del_a_printer( Printer->sharename ) != 0) { DEBUG(3,("Error deleting printer %s\n", Printer->sharename)); return WERR_BADFID; } + /* the delete printer script shoudl be run as root if the user has perms */ + if (*lp_deleteprinter_cmd()) { char *cmd = lp_deleteprinter_cmd(); pstring command; int ret; - + SE_PRIV se_printop = SE_PRINT_OPERATOR; + BOOL is_print_op; + pstr_sprintf(command, "%s \"%s\"", cmd, Printer->sharename); + is_print_op = user_has_privileges( p->pipe_user.nt_user_token, &se_printop ); + DEBUG(10,("Running [%s]\n", command)); + + /********** BEGIN SePrintOperatorPrivlege BLOCK **********/ + + if ( is_print_op ) + become_root(); + ret = smbrun(command, NULL); - if (ret != 0) { - return WERR_BADFID; /* What to return here? */ - } + + if ( is_print_op ) + unbecome_root(); + + /********** BEGIN SePrintOperatorPrivlege BLOCK **********/ + DEBUGADD(10,("returned [%d]\n", ret)); - /* Send SIGHUP to process group... is there a better way? */ - kill(0, SIGHUP); + if (ret != 0) + return WERR_BADFID; /* What to return here? */ + + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); /* go ahead and re-read the services immediately */ reload_services( False ); @@ -5984,7 +6005,7 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) /**************************************************************************** ****************************************************************************/ -static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) +static BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) { extern userdom_struct current_user_info; char *cmd = lp_addprinter_cmd(); @@ -5994,6 +6015,8 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) int ret; int fd; fstring remote_machine = "%m"; + SE_PRIV se_printop = SE_PRINT_OPERATOR; + BOOL is_print_op; standard_sub_basic(current_user_info.smb_name, remote_machine,sizeof(remote_machine)); @@ -6002,8 +6025,22 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) printer->info_2->portname, printer->info_2->drivername, printer->info_2->location, printer->info_2->comment, remote_machine); + is_print_op = user_has_privileges( token, &se_printop ); + DEBUG(10,("Running [%s]\n", command)); + + /********* BEGIN SePrintOperatorPrivilege **********/ + + if ( is_print_op ) + become_root(); + ret = smbrun(command, &fd); + + if ( is_print_op ) + unbecome_root(); + + /********* END SePrintOperatorPrivilege **********/ + DEBUGADD(10,("returned [%d]\n", ret)); if ( ret != 0 ) { @@ -6012,22 +6049,25 @@ static BOOL add_printer_hook(NT_PRINTER_INFO_LEVEL *printer) return False; } + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + + /* reload our services immediately */ + reload_services( False ); + numlines = 0; /* Get lines and convert them back to dos-codepage */ qlines = fd_lines_load(fd, &numlines); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); close(fd); - if(numlines) { + /* Set the portname to what the script says the portname should be. */ + /* but don't require anything to be return from the script exit a good error code */ + + if (numlines) { /* Set the portname to what the script says the portname should be. */ strncpy(printer->info_2->portname, qlines[0], sizeof(printer->info_2->portname)); DEBUGADD(6,("Line[0] = [%s]\n", qlines[0])); - - /* Send SIGHUP to process group... is there a better way? */ - kill(0, SIGHUP); - - /* reload our services immediately */ - reload_services( False ); } file_lines_free(qlines); @@ -6122,7 +6162,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, || !strequal(printer->info_2->portname, old_printer->info_2->portname) || !strequal(printer->info_2->location, old_printer->info_2->location)) ) { - if ( !add_printer_hook(printer) ) { + if ( !add_printer_hook(p->pipe_user.nt_user_token, printer) ) { result = WERR_ACCESS_DENIED; goto done; } @@ -7416,7 +7456,7 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ trying to add a printer like this --jerry */ if (*lp_addprinter_cmd() ) { - if ( !add_printer_hook(printer) ) { + if ( !add_printer_hook(p->pipe_user.nt_user_token, printer) ) { free_a_printer(&printer,2); return WERR_ACCESS_DENIED; } diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index af4c94800a..382941d361 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1470,6 +1470,8 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S int ret; char *ptr; SEC_DESC *psd = NULL; + SE_PRIV se_diskop = SE_DISK_OPERATOR; + BOOL is_disk_op; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); @@ -1492,7 +1494,11 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S get_current_user(&user,p); - if (user.uid != sec_initial_uid()) + is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); + + /* fail out now if you are not root and not a disk op */ + + if ( user.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; switch (q_u->info_level) { @@ -1575,23 +1581,36 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" )); /* Only call modify function if something changed. */ - - if (strcmp(ptr, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) ) { - if (!lp_change_share_cmd() || !*lp_change_share_cmd()) + + if (strcmp(ptr, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) ) + { + if (!lp_change_share_cmd() || !*lp_change_share_cmd()) return WERR_ACCESS_DENIED; slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", lp_change_share_cmd(), dyn_CONFIGFILE, share_name, ptr, comment); 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 )); + + /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ + + if ( is_disk_op ) + become_root(); + + ret = smbrun(command, NULL); + + if ( is_disk_op ) + unbecome_root(); + + /********* END SeDiskOperatorPrivilege BLOCK *********/ + + DEBUG(3,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret )); + + if ( ret != 0 ) return WERR_ACCESS_DENIED; - } /* Tell everyone we updated smb.conf. */ message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); - } else { DEBUG(10,("_srv_net_share_set_info: No change to share name (%s)\n", share_name )); } @@ -1609,7 +1628,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S share_name )); } } - + DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); return WERR_OK; @@ -1631,6 +1650,8 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S int ret; char *ptr; SEC_DESC *psd = NULL; + SE_PRIV se_diskop = SE_DISK_OPERATOR; + BOOL is_disk_op; DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); @@ -1638,16 +1659,16 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S get_current_user(&user,p); - if (user.uid != sec_initial_uid()) { - DEBUG(10,("_srv_net_share_add: uid != sec_initial_uid(). Access denied.\n")); + is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); + + if (user.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; - } if (!lp_add_share_cmd() || !*lp_add_share_cmd()) { DEBUG(10,("_srv_net_share_add: No add share command\n")); return WERR_ACCESS_DENIED; } - + switch (q_u->info_level) { case 0: /* No path. Not enough info in a level 0 to do anything. */ @@ -1713,12 +1734,28 @@ WERROR _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(), dyn_CONFIGFILE, share_name, ptr, comment); - + 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 )); + + /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ + + if ( is_disk_op ) + become_root(); + + ret = smbrun(command, NULL); + + if ( is_disk_op ) + unbecome_root(); + + /********* END SeDiskOperatorPrivilege BLOCK *********/ + + DEBUG(3,("_srv_net_share_add: Running [%s] returned (%d)\n", command, ret )); + + if ( ret != 0 ) return WERR_ACCESS_DENIED; - } + + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); if (psd) { if (!set_share_security(p->mem_ctx, share_name, psd)) @@ -1726,9 +1763,6 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S share_name )); } - /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); - /* * We don't call reload_services() here, the message will * cause this to be done before the next packet is read @@ -1752,6 +1786,8 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S fstring share_name; int ret; int snum; + SE_PRIV se_diskop = SE_DISK_OPERATOR; + BOOL is_disk_op; DEBUG(5,("_srv_net_share_del: %d\n", __LINE__)); @@ -1771,27 +1807,42 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S get_current_user(&user,p); - if (user.uid != sec_initial_uid()) + is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); + + if (user.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) return WERR_ACCESS_DENIED; - + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", lp_delete_share_cmd(), dyn_CONFIGFILE, lp_servicename(snum)); 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 WERR_ACCESS_DENIED; - } - /* Delete the SD in the database. */ - delete_share_security(snum); + /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ + + if ( is_disk_op ) + become_root(); + + ret = smbrun(command, NULL); + + if ( is_disk_op ) + unbecome_root(); + + /********* END SeDiskOperatorPrivilege BLOCK *********/ + + DEBUG(3,("_srv_net_share_del: Running [%s] returned (%d)\n", command, ret )); + + if ( ret != 0 ) + return WERR_ACCESS_DENIED; /* Tell everyone we updated smb.conf. */ message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + /* Delete the SD in the database. */ + delete_share_security(snum); + lp_killservice(snum); return WERR_OK; -- cgit From 1ed62fde09f382342a396a047975fdeeea7113bb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 19 Jan 2005 16:13:26 +0000 Subject: r4847: Hand over a acb_mask to pdb_setsampwent in load_sampwd_entries(). This allows the ldap-backend to search much more effeciently. Machines will be searched in the ldap_machine_suffix and users in the ldap_users_suffix. (Note that we already use the ldap_group_suffix in ldapsam_setsamgrent for quite some time). Using the specific ldap-bases becomes notably important in large domains: On my testmachine "net rpc trustdom list" has to search through 40k accounts just to list 3 interdomain-trust-accounts, similiar effects show up the non-user query_dispinfo-calls, etc. Also renamed all_machines to only_machines in load_sampwd_entries() since that reflects better what is really meant. Guenther (This used to be commit 6394257cc721ca739bda0e320375f04506913533) --- source3/rpc_server/srv_samr_nt.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 515eefb1fa..70c0de7da7 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -56,7 +56,7 @@ struct samr_info { uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ uint32 acc_granted; uint16 acb_mask; - BOOL all_machines; + BOOL only_machines; DISP_INFO disp_info; TALLOC_CTX *mem_ctx; @@ -209,34 +209,40 @@ static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) } -static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOOL all_machines) +static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOOL only_machines) { SAM_ACCOUNT *pwd = NULL; SAM_ACCOUNT *pwd_array = NULL; NTSTATUS nt_status = NT_STATUS_OK; TALLOC_CTX *mem_ctx = info->mem_ctx; + uint16 query_acb_mask = acb_mask; DEBUG(10,("load_sampwd_entries\n")); /* if the snapshoot is already loaded, return */ if ((info->disp_info.user_dbloaded==True) && (info->acb_mask == acb_mask) - && (info->all_machines == all_machines)) { + && (info->only_machines == only_machines)) { DEBUG(10,("load_sampwd_entries: already in memory\n")); return NT_STATUS_OK; } free_samr_users(info); + + if (only_machines) { + query_acb_mask |= ACB_WSTRUST; + query_acb_mask |= ACB_SVRTRUST; + } - if (!pdb_setsampwent(False)) { + if (!pdb_setsampwent(False, query_acb_mask)) { DEBUG(0, ("load_sampwd_entries: Unable to open passdb.\n")); return NT_STATUS_ACCESS_DENIED; } for (; (NT_STATUS_IS_OK(nt_status = pdb_init_sam_talloc(mem_ctx, &pwd))) && pdb_getsampwent(pwd) == True; pwd=NULL) { - - if (all_machines) { + + if (only_machines) { if (!((pdb_get_acct_ctrl(pwd) & ACB_WSTRUST) || (pdb_get_acct_ctrl(pwd) & ACB_SVRTRUST))) { DEBUG(5,("load_sampwd_entries: '%s' is not a machine account - ACB: %x - skipping\n", pdb_get_username(pwd), acb_mask)); @@ -277,7 +283,7 @@ static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOO /* the snapshoot is in memory, we're ready to enumerate fast */ info->acb_mask = acb_mask; - info->all_machines = all_machines; + info->only_machines = only_machines; info->disp_info.user_dbloaded=True; DEBUG(10,("load_sampwd_entries: done\n")); -- cgit From b3757eadf05a4e47a5cd19049ee2c5eecf140c37 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 19 Jan 2005 16:52:19 +0000 Subject: r4849: * finish SeAddUsers support in srv_samr_nt.c * define some const SE_PRIV structure for use when you need a SE_PRIV* to a privilege * fix an annoying compiler warngin in smbfilter.c * translate SIDs to names in 'net rpc rights list accounts' * fix a seg fault in cli_lsa_enum_account_rights caused by me forgetting the precedence of * vs. [] (This used to be commit d25fc84bc2b14da9fcc0f3c8d7baeca83f0ea708) --- source3/rpc_server/srv_samr_nt.c | 358 ++++++++++++++++++++++++++++----------- 1 file changed, 258 insertions(+), 100 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 70c0de7da7..5fd5137cf1 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1,14 +1,14 @@ /* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, * Copyright (C) Marc Jacobsen 1999, - * Copyright (C) Jeremy Allison 2001-2002, - * Copyright (C) Jean François Micouleau 1998-2001, + * Copyright (C) Jeremy Allison 2001-2002, + * Copyright (C) Jean François Micouleau 1998-2001, * Copyright (C) Jim McDonough 2002, - * Copyright (C) Gerald (Jerry) Carter 2003 - 2004, + * Copyright (C) Gerald (Jerry) Carter 2003-2004, * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2221,8 +2221,8 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA uint32 new_rid = 0; /* check this, when giving away 'add computer to domain' privs */ uint32 des_access = GENERIC_RIGHTS_USER_ALL_ACCESS; - BOOL can_add_machines = False; - SE_PRIV se_machineop = SE_MACHINE_ACCOUNT; + BOOL can_add_account; + SE_PRIV se_rights; /* Get the domain SID stored in the domain policy */ if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted)) @@ -2246,14 +2246,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA rpcstr_pull(account, user_account.buffer, sizeof(account), user_account.uni_str_len*2, 0); strlower_m(account); - - /* check to see if we are a domain admin */ - - can_add_machines = user_has_privileges( p->pipe_user.nt_user_token, &se_machineop ); - - DEBUG(5, ("_samr_create_user: %s is%s a member of the Domain Admins group\n", - p->pipe_user_name, can_add_machines ? "" : " not")); - + pdb_init_sam(&sam_pass); become_root(); @@ -2266,13 +2259,6 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA } pdb_free_sam(&sam_pass); - - /* - * 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. - */ /********************************************************************* * HEADS UP! If we have to create a new user account, we have to get @@ -2287,26 +2273,37 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA pw = Get_Pwnam(account); - /* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */ + /* + * we can't check both the ending $ and the acb_info. + * + * UserManager creates trust accounts (ending in $, + * normal that hidden accounts) with the acb_info equals to ACB_NORMAL. + * JFM, 11/29/2001 + */ + + if (account[strlen(account)-1] == '$') { + se_priv_copy( &se_rights, &se_machine_account ); + pstrcpy(add_script, lp_addmachine_script()); + } + else { + se_priv_copy( &se_rights, &se_add_users ); + pstrcpy(add_script, lp_adduser_script()); + } + + can_add_account = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); + + DEBUG(5, ("_samr_create_user: %s can add this account : %s\n", + p->pipe_user_name, can_add_account ? "True":"False" )); + + /********** BEGIN Admin BLOCK **********/ - if ( can_add_machines ) + if ( can_add_account ) become_root(); - + if ( !pw ) { - /* - * we can't check both the ending $ and the acb_info. - * - * UserManager creates trust accounts (ending in $, - * normal that hidden accounts) with the acb_info equals to ACB_NORMAL. - * JFM, 11/29/2001 - */ - if (account[strlen(account)-1] == '$') - pstrcpy(add_script, lp_addmachine_script()); - else - pstrcpy(add_script, lp_adduser_script()); - if (*add_script) { int add_ret; + all_string_sub(add_script, "%u", account, sizeof(add_script)); add_ret = smbrun(add_script,NULL); DEBUG(3,("_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); @@ -2323,28 +2320,32 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA /* implicit call to getpwnam() next. we have a valid SID coming out of this call */ - if ( !NT_STATUS_IS_OK(nt_status = pdb_init_sam_new(&sam_pass, account, new_rid)) ) { - if ( can_add_machines ) - unbecome_root(); - return nt_status; + nt_status = pdb_init_sam_new(&sam_pass, account, new_rid); + + /* this code is order such that we have no unnecessary retuns + out of the admin block of code */ + + if ( NT_STATUS_IS_OK(nt_status) ) { + pdb_set_acct_ctrl(sam_pass, acb_info, PDB_CHANGED); + + if ( !(ret = pdb_add_sam_account(sam_pass)) ) { + pdb_free_sam(&sam_pass); + DEBUG(0, ("could not add user/computer %s to passdb. Check permissions?\n", + account)); + nt_status = NT_STATUS_ACCESS_DENIED; + } } - pdb_set_acct_ctrl(sam_pass, acb_info, PDB_CHANGED); - - ret = pdb_add_sam_account(sam_pass); - - if ( can_add_machines ) + if ( can_add_account ) unbecome_root(); - - /* ================ END SeMachineAccountPrivilege BLOCK ================ */ - if ( !ret ) { - pdb_free_sam(&sam_pass); - DEBUG(0, ("could not add user/computer %s to passdb. Check permissions?\n", - account)); - return NT_STATUS_ACCESS_DENIED; - } - + /********** END Admin BLOCK **********/ + + /* now check for failure */ + + if ( !NT_STATUS_IS_OK(nt_status) ) + return nt_status; + /* Get the user's SID */ sid_copy(&sid, pdb_get_user_sid(sam_pass)); @@ -3515,6 +3516,10 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD { DOM_SID alias_sid; uint32 acc_granted; + SE_PRIV se_rights; + BOOL can_add_accounts; + BOOL ret; + /* Find the policy handle. Open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) @@ -3525,11 +3530,23 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD } DEBUG(10, ("sid is %s\n", sid_string_static(&alias_sid))); + + se_priv_copy( &se_rights, &se_add_users ); + can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); - if (!pdb_add_aliasmem(&alias_sid, &q_u->sid.sid)) - return NT_STATUS_ACCESS_DENIED; - - return NT_STATUS_OK; + /******** BEGIN SeAddUsers BLOCK *********/ + + if ( can_add_accounts ) + become_root(); + + ret = pdb_add_aliasmem(&alias_sid, &q_u->sid.sid); + + if ( can_add_accounts ) + unbecome_root(); + + /******** END SeAddUsers BLOCK *********/ + + return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; } /********************************************************************* @@ -3540,6 +3557,9 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE { DOM_SID alias_sid; uint32 acc_granted; + SE_PRIV se_rights; + BOOL can_add_accounts; + BOOL ret; /* Find the policy handle. Open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) @@ -3552,10 +3572,22 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE DEBUG(10, ("_samr_del_aliasmem:sid is %s\n", sid_string_static(&alias_sid))); - if (!pdb_del_aliasmem(&alias_sid, &q_u->sid.sid)) - return NT_STATUS_ACCESS_DENIED; + se_priv_copy( &se_rights, &se_add_users ); + can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); + + /******** BEGIN SeAddUsers BLOCK *********/ - return NT_STATUS_OK; + if ( can_add_accounts ) + become_root(); + + ret = pdb_del_aliasmem(&alias_sid, &q_u->sid.sid); + + if ( can_add_accounts ) + unbecome_root(); + + /******** END SeAddUsers BLOCK *********/ + + return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; } /********************************************************************* @@ -3576,6 +3608,8 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD SAM_ACCOUNT *sam_user=NULL; BOOL check; uint32 acc_granted; + SE_PRIV se_rights; + BOOL can_add_accounts; /* Find the policy handle. Open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) @@ -3636,6 +3670,14 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD return NT_STATUS_MEMBER_IN_GROUP; } + se_priv_copy( &se_rights, &se_add_users ); + can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); + + /******** BEGIN SeAddUsers BLOCK *********/ + + if ( can_add_accounts ) + become_root(); + /* * ok, the group exist, the user exist, the user is not in the group, * @@ -3644,6 +3686,11 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD smb_add_user_group(grp_name, pwd->pw_name); + if ( can_add_accounts ) + unbecome_root(); + + /******** END SeAddUsers BLOCK *********/ + /* check if the user has been added then ... */ if(!user_in_unix_group_list(pwd->pw_name, grp_name)) { passwd_free(&pwd); @@ -3667,6 +3714,8 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE fstring grp_name; struct group *grp; uint32 acc_granted; + SE_PRIV se_rights; + BOOL can_add_accounts; /* * delete the group member named q_u->rid @@ -3710,9 +3759,23 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE pdb_free_sam(&sam_pass); return NT_STATUS_MEMBER_NOT_IN_GROUP; } + + se_priv_copy( &se_rights, &se_add_users ); + can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); + + /******** BEGIN SeAddUsers BLOCK *********/ + + if ( can_add_accounts ) + become_root(); + smb_delete_user_group(grp_name, pdb_get_username(sam_pass)); + if ( can_add_accounts ) + unbecome_root(); + + /******** END SeAddUsers BLOCK *********/ + /* check if the user has been removed then ... */ if (user_in_unix_group_list(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); @@ -3764,6 +3827,9 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM DOM_SID user_sid; SAM_ACCOUNT *sam_pass=NULL; uint32 acc_granted; + SE_PRIV se_rights; + BOOL can_add_accounts; + BOOL ret; DEBUG(5, ("_samr_delete_dom_user: %d\n", __LINE__)); @@ -3786,22 +3852,40 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM pdb_free_sam(&sam_pass); return NT_STATUS_NO_SUCH_USER; } + + se_priv_copy( &se_rights, &se_add_users ); + can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); - /* First delete the samba side */ - if (!pdb_delete_sam_account(sam_pass)) { + /******** BEGIN SeAddUsers BLOCK *********/ + + if ( can_add_accounts ) + become_root(); + + /* First delete the samba side.... + code is order to prevent unnecessary returns out of the admin + block of code */ + + if ( (ret = pdb_delete_sam_account(sam_pass)) == True ) { + /* + * Now delete the unix side .... + * note: we don't check if the delete really happened + * as the script is not necessary present + * and maybe the sysadmin doesn't want to delete the unix side + */ + smb_delete_user( pdb_get_username(sam_pass) ); + } + + if ( can_add_accounts ) + unbecome_root(); + + /******** END SeAddUsers BLOCK *********/ + + if ( !ret ) { DEBUG(5,("_samr_delete_dom_user:Failed to delete entry for user %s.\n", pdb_get_username(sam_pass))); pdb_free_sam(&sam_pass); return NT_STATUS_CANNOT_DELETE; } - /* Now delete the unix side */ - /* - * note: we don't check if the delete really happened - * as the script is not necessary present - * and maybe the sysadmin doesn't want to delete the unix side - */ - smb_delete_user(pdb_get_username(sam_pass)); - pdb_free_sam(&sam_pass); @@ -3825,6 +3909,9 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S struct group *grp; GROUP_MAP map; uint32 acc_granted; + SE_PRIV se_rights; + BOOL can_add_accounts; + BOOL ret; DEBUG(5, ("samr_delete_dom_group: %d\n", __LINE__)); @@ -3857,17 +3944,33 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S if ( (grp=getgrgid(gid)) == NULL) return NT_STATUS_NO_SUCH_GROUP; + se_priv_copy( &se_rights, &se_add_users ); + can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); + + /******** BEGIN SeAddUsers BLOCK *********/ + + if ( can_add_accounts ) + become_root(); + /* delete mapping first */ - if(!pdb_delete_group_mapping_entry(group_sid)) - return NT_STATUS_ACCESS_DENIED; - - /* we can delete the UNIX group */ - smb_delete_group(grp->gr_name); + + if ( (ret = pdb_delete_group_mapping_entry(group_sid)) == True ) { + smb_delete_group( grp->gr_name ); + } - /* check if the group has been successfully deleted */ - if ( (grp=getgrgid(gid)) != NULL) + if ( can_add_accounts ) + unbecome_root(); + + /******** END SeAddUsers BLOCK *********/ + + if ( !ret ) { + DEBUG(5,("_samr_delete_dom_group: Failed to delete mapping entry for group %s.\n", + group_sid_str)); return NT_STATUS_ACCESS_DENIED; - + } + + /* don't check that the unix group has been deleted. Work like + _samr_delet_dom_user() */ if (!close_policy_hnd(p, &q_u->group_pol)) return NT_STATUS_OBJECT_NAME_INVALID; @@ -3883,6 +3986,9 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S { DOM_SID alias_sid; uint32 acc_granted; + SE_PRIV se_rights; + BOOL can_add_accounts; + BOOL ret; DEBUG(5, ("_samr_delete_dom_alias: %d\n", __LINE__)); @@ -3901,8 +4007,23 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S DEBUG(10, ("lookup on Local SID\n")); + se_priv_copy( &se_rights, &se_add_users ); + can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); + + /******** BEGIN SeAddUsers BLOCK *********/ + + if ( can_add_accounts ) + become_root(); + /* Have passdb delete the alias */ - if (!pdb_delete_alias(&alias_sid)) + ret = pdb_delete_alias(&alias_sid); + + if ( can_add_accounts ) + unbecome_root(); + + /******** END SeAddUsers BLOCK *********/ + + if ( !ret ) return NT_STATUS_ACCESS_DENIED; if (!close_policy_hnd(p, &q_u->alias_pol)) @@ -3925,6 +4046,9 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S struct samr_info *info; uint32 acc_granted; gid_t gid; + SE_PRIV se_rights; + BOOL can_add_accounts; + NTSTATUS result; /* Find the policy handle. Open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid, &acc_granted)) @@ -3937,32 +4061,53 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; - /* TODO: check if allowed to create group and add a become_root/unbecome_root pair.*/ - unistr2_to_ascii(name, &q_u->uni_acct_desc, sizeof(name)-1); /* check if group already exist */ if ((grp=getgrnam(name)) != NULL) return NT_STATUS_GROUP_EXISTS; - /* we can create the UNIX group */ - if (smb_create_group(name, &gid) != 0) - return NT_STATUS_ACCESS_DENIED; - - /* check if the group has been successfully created */ - if ((grp=getgrgid(gid)) == NULL) - return NT_STATUS_ACCESS_DENIED; + se_priv_copy( &se_rights, &se_add_users ); + can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); - r_u->rid=pdb_gid_to_group_rid(grp->gr_gid); - - /* add the group to the mapping table */ - sid_copy(&info_sid, get_global_sam_sid()); - sid_append_rid(&info_sid, r_u->rid); - sid_to_string(sid_string, &info_sid); + /******** BEGIN SeAddUsers BLOCK *********/ + + if ( can_add_accounts ) + become_root(); + + /* check that we successfully create the UNIX group */ + + result = NT_STATUS_ACCESS_DENIED; + if ( (smb_create_group(name, &gid) == 0) && ((grp=getgrgid(gid)) != NULL) ) { + + /* so far, so good */ + + result = NT_STATUS_OK; + + r_u->rid = pdb_gid_to_group_rid( grp->gr_gid ); - if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_DOM_GRP, name, NULL)) - return NT_STATUS_ACCESS_DENIED; + /* add the group to the mapping table */ + + sid_copy( &info_sid, get_global_sam_sid() ); + sid_append_rid( &info_sid, r_u->rid ); + sid_to_string( sid_string, &info_sid ); + + /* reset the error code if we fail to add the mapping entry */ + + if ( !add_initial_entry(grp->gr_gid, sid_string, SID_NAME_DOM_GRP, name, NULL) ) + result = NT_STATUS_ACCESS_DENIED; + } + if ( can_add_accounts ) + unbecome_root(); + + /******** END SeAddUsers BLOCK *********/ + + /* check if we should bail out here */ + + if ( !NT_STATUS_IS_OK(result) ) + return result; + if ((info = get_samr_info_by_sid(&info_sid)) == NULL) return NT_STATUS_NO_MEMORY; @@ -3987,6 +4132,8 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S uint32 acc_granted; gid_t gid; NTSTATUS result; + SE_PRIV se_rights; + BOOL can_add_accounts; /* Find the policy handle. Open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid, &acc_granted)) @@ -3999,13 +4146,24 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; - /* TODO: check if allowed to create group and add a become_root/unbecome_root pair.*/ - unistr2_to_ascii(name, &q_u->uni_acct_desc, sizeof(name)-1); + se_priv_copy( &se_rights, &se_add_users ); + can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); + + /******** BEGIN SeAddUsers BLOCK *********/ + + if ( can_add_accounts ) + become_root(); + /* Have passdb create the alias */ result = pdb_create_alias(name, &r_u->rid); + if ( can_add_accounts ) + unbecome_root(); + + /******** END SeAddUsers BLOCK *********/ + if (!NT_STATUS_IS_OK(result)) return result; -- cgit From 415ea1dfd33904bdf70ea993b0b93e1c852ab0cb Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 19 Jan 2005 18:28:55 +0000 Subject: r4852: merge simo changes to srv_srvsvc_nt.c from trunk that allows the add/change share command to create the directory passed in as an arguement and not require that it pre-exist. Also finish testing of SeDiskOperatorPrivilege via srvmgr.exe (This used to be commit 9af83a7d70324846e6a2660c73589ee68340b4aa) --- source3/rpc_server/srv_srvsvc_nt.c | 43 ++++++++++++-------------------------- 1 file changed, 13 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 382941d361..529b4c198d 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1419,10 +1419,7 @@ WERROR _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, S static char *valid_share_pathname(char *dos_pathname) { - pstring saved_pathname; - pstring unix_pathname; char *ptr; - int ret; /* Convert any '\' paths to '/' */ unix_format(dos_pathname); @@ -1437,21 +1434,7 @@ static char *valid_share_pathname(char *dos_pathname) if (*ptr != '/') return NULL; - /* Can we cd to it ? */ - - /* First save our current directory. */ - if (getcwd(saved_pathname, sizeof(saved_pathname)) == NULL) - return False; - - pstrcpy(unix_pathname, ptr); - - ret = chdir(unix_pathname); - - /* We *MUST* be able to chdir back. Abort if we can't. */ - if (chdir(saved_pathname) == -1) - smb_panic("valid_share_pathname: Unable to restore current directory.\n"); - - return (ret != -1) ? ptr : NULL; + return ptr; } /******************************************************************* @@ -1468,7 +1451,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S int type; int snum; int ret; - char *ptr; + char *path; SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op; @@ -1569,12 +1552,12 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return WERR_ACCESS_DENIED; /* Check if the pathname is valid. */ - if (!(ptr = valid_share_pathname( pathname ))) + if (!(path = valid_share_pathname( pathname ))) return WERR_OBJECT_PATH_INVALID; /* Ensure share name, pathname and comment don't contain '"' characters. */ string_replace(share_name, '"', ' '); - string_replace(ptr, '"', ' '); + string_replace(path, '"', ' '); string_replace(comment, '"', ' '); DEBUG(10,("_srv_net_share_set_info: change share command = %s\n", @@ -1582,13 +1565,13 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S /* Only call modify function if something changed. */ - if (strcmp(ptr, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) ) + if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) ) { if (!lp_change_share_cmd() || !*lp_change_share_cmd()) return WERR_ACCESS_DENIED; slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", - lp_change_share_cmd(), dyn_CONFIGFILE, share_name, ptr, comment); + lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment); DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command )); @@ -1648,7 +1631,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S int type; int snum; int ret; - char *ptr; + char *path; SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op; @@ -1724,16 +1707,16 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S return WERR_ACCESS_DENIED; /* Check if the pathname is valid. */ - if (!(ptr = valid_share_pathname( pathname ))) + if (!(path = valid_share_pathname( pathname ))) return WERR_OBJECT_PATH_INVALID; /* Ensure share name, pathname and comment don't contain '"' characters. */ string_replace(share_name, '"', ' '); - string_replace(ptr, '"', ' '); + string_replace(path, '"', ' '); string_replace(comment, '"', ' '); slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", - lp_add_share_cmd(), dyn_CONFIGFILE, share_name, ptr, comment); + lp_add_share_cmd(), dyn_CONFIGFILE, share_name, path, comment); DEBUG(10,("_srv_net_share_add: Running [%s]\n", command )); @@ -1758,9 +1741,9 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); if (psd) { - if (!set_share_security(p->mem_ctx, share_name, psd)) - DEBUG(0,("_srv_net_share_add: Failed to add security info to share %s.\n", - share_name )); + if (!set_share_security(p->mem_ctx, share_name, psd)) { + DEBUG(0,("_srv_net_share_add: Failed to add security info to share %s.\n", share_name )); + } } /* -- cgit From 372440f207d88e058af76cf7ce4c5901ba7a7547 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 19 Jan 2005 21:10:56 +0000 Subject: r4856: after testing a simple add printer script, i realized that you still have to be root to send the message to all smbds that the config file has been updated (This used to be commit 6409de1a1ef34bb41c3efeebfabdf13be5e08613) --- source3/rpc_server/srv_spoolss_nt.c | 18 +++++++++--------- source3/rpc_server/srv_srvsvc_nt.c | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 31e1e4a3bf..ed7a544d72 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -409,21 +409,21 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) if ( is_print_op ) become_root(); - ret = smbrun(command, NULL); + if ( (ret = smbrun(command, NULL)) == 0 ) { + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + } if ( is_print_op ) unbecome_root(); - /********** BEGIN SePrintOperatorPrivlege BLOCK **********/ + /********** END SePrintOperatorPrivlege BLOCK **********/ DEBUGADD(10,("returned [%d]\n", ret)); if (ret != 0) return WERR_BADFID; /* What to return here? */ - /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); - /* go ahead and re-read the services immediately */ reload_services( False ); @@ -6034,7 +6034,10 @@ static BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printe if ( is_print_op ) become_root(); - ret = smbrun(command, &fd); + if ( (ret = smbrun(command, &fd)) == 0 ) { + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + } if ( is_print_op ) unbecome_root(); @@ -6049,9 +6052,6 @@ static BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printe return False; } - /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); - /* reload our services immediately */ reload_services( False ); diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 529b4c198d..13e1971925 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1580,7 +1580,10 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if ( is_disk_op ) become_root(); - ret = smbrun(command, NULL); + if ( (ret = smbrun(command, NULL)) == 0 ) { + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + } if ( is_disk_op ) unbecome_root(); @@ -1591,9 +1594,6 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if ( ret != 0 ) return WERR_ACCESS_DENIED; - - /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); } else { DEBUG(10,("_srv_net_share_set_info: No change to share name (%s)\n", share_name )); } @@ -1725,7 +1725,10 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S if ( is_disk_op ) become_root(); - ret = smbrun(command, NULL); + if ( (ret = smbrun(command, NULL)) == 0 ) { + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + } if ( is_disk_op ) unbecome_root(); @@ -1737,9 +1740,6 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S if ( ret != 0 ) return WERR_ACCESS_DENIED; - /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); - if (psd) { if (!set_share_security(p->mem_ctx, share_name, psd)) { DEBUG(0,("_srv_net_share_add: Failed to add security info to share %s.\n", share_name )); @@ -1808,7 +1808,10 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S if ( is_disk_op ) become_root(); - ret = smbrun(command, NULL); + if ( (ret = smbrun(command, NULL)) == 0 ) { + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + } if ( is_disk_op ) unbecome_root(); @@ -1820,9 +1823,6 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S if ( ret != 0 ) return WERR_ACCESS_DENIED; - /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); - /* Delete the SD in the database. */ delete_share_security(snum); -- cgit From 6a6c7cbf9968919fea574e84ad3f1318e10969f2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 20 Jan 2005 17:05:10 +0000 Subject: r4871: BUG 603: patch by Daniel Beschorner . Correct access mask check for _samr_lookup_domain() to work with Windows RAS server (This used to be commit 2e7a5608ac6a11f4e9e8bda69abb984fb4f86eb8) --- source3/rpc_server/srv_samr_nt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 5fd5137cf1..462a646329 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2541,8 +2541,11 @@ NTSTATUS _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_ if (!find_policy_by_hnd(p, &q_u->connect_pol, (void**)&info)) return NT_STATUS_INVALID_HANDLE; + /* win9x user manager likes to use SA_RIGHT_SAM_ENUM_DOMAINS here. + Reverted that change so we will work with RAS servers again */ + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, - SA_RIGHT_SAM_ENUM_DOMAINS, "_samr_lookup_domain"))) + SA_RIGHT_SAM_OPEN_DOMAIN, "_samr_lookup_domain"))) { return r_u->status; } -- cgit From b4afdc08d5336e4a337e453443d7af1d8655a31a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 22 Jan 2005 03:37:09 +0000 Subject: r4925: Migrate Account Policies to passdb (esp. replicating ldapsam). Does automated migration from account_policy.tdb v1 and v2 and offers a pdbedit-Migration interface. Jerry, please feel free to revert that if you have other plans. Guenther (This used to be commit 75af83dfcd8ef365b4b1180453060ae5176389f5) --- source3/rpc_server/srv_reg_nt.c | 2 +- source3/rpc_server/srv_samr_nt.c | 59 ++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index c11e0d59a0..3a5c965820 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -380,7 +380,7 @@ WERROR _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) return WERR_NOMEM; } - if (!account_policy_get(AP_REFUSE_MACHINE_PW_CHANGE, &dwValue)) + if (!pdb_get_account_policy(AP_REFUSE_MACHINE_PW_CHANGE, &dwValue)) dwValue = 0; regval_ctr_addvalue(®vals, "RefusePasswordChange", REG_DWORD, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 462a646329..8ee59210eb 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2100,19 +2100,19 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA switch (q_u->switch_value) { case 0x01: - account_policy_get(AP_MIN_PASSWORD_LEN, &account_policy_temp); + pdb_get_account_policy(AP_MIN_PASSWORD_LEN, &account_policy_temp); min_pass_len = account_policy_temp; - account_policy_get(AP_PASSWORD_HISTORY, &account_policy_temp); + pdb_get_account_policy(AP_PASSWORD_HISTORY, &account_policy_temp); pass_hist = account_policy_temp; - account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); + pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); flag = account_policy_temp; - account_policy_get(AP_MAX_PASSWORD_AGE, &account_policy_temp); + pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &account_policy_temp); u_expire = account_policy_temp; - account_policy_get(AP_MIN_PASSWORD_AGE, &account_policy_temp); + pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &account_policy_temp); u_min_age = account_policy_temp; unix_to_nt_time_abs(&nt_expire, u_expire); @@ -2140,7 +2140,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA num_groups=info->disp_info.num_group_account; free_samr_db(info); - account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); + pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); u_logout = account_policy_temp; unix_to_nt_time_abs(&nt_logout, u_logout); @@ -2150,7 +2150,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA num_users, num_groups, num_aliases, nt_logout); break; case 0x03: - account_policy_get(AP_TIME_TO_LOGOUT, (unsigned int *)&u_logout); + pdb_get_account_policy(AP_TIME_TO_LOGOUT, (unsigned int *)&u_logout); unix_to_nt_time_abs(&nt_logout, u_logout); init_unk_info3(&ctr->info.inf3, nt_logout); @@ -2168,15 +2168,15 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA init_unk_info8(&ctr->info.inf8, (uint32) time(NULL)); break; case 0x0c: - account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); + pdb_get_account_policy(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); u_lock_duration = account_policy_temp; if (u_lock_duration != -1) u_lock_duration *= 60; - account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp); + pdb_get_account_policy(AP_RESET_COUNT_TIME, &account_policy_temp); u_reset_time = account_policy_temp * 60; - account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); + pdb_get_account_policy(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); lockout = account_policy_temp; unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); @@ -4567,19 +4567,19 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW switch (q_u->switch_value) { case 0x01: - account_policy_get(AP_MIN_PASSWORD_LEN, &account_policy_temp); + pdb_get_account_policy(AP_MIN_PASSWORD_LEN, &account_policy_temp); min_pass_len = account_policy_temp; - account_policy_get(AP_PASSWORD_HISTORY, &account_policy_temp); + pdb_get_account_policy(AP_PASSWORD_HISTORY, &account_policy_temp); pass_hist = account_policy_temp; - account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); + pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); flag = account_policy_temp; - account_policy_get(AP_MAX_PASSWORD_AGE, &account_policy_temp); + pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &account_policy_temp); u_expire = account_policy_temp; - account_policy_get(AP_MIN_PASSWORD_AGE, &account_policy_temp); + pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &account_policy_temp); u_min_age = account_policy_temp; unix_to_nt_time_abs(&nt_expire, u_expire); @@ -4607,7 +4607,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW num_groups=info->disp_info.num_group_account; free_samr_db(info); - account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); + pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); u_logout = account_policy_temp; unix_to_nt_time_abs(&nt_logout, u_logout); @@ -4617,7 +4617,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW num_users, num_groups, num_aliases, nt_logout); break; case 0x03: - account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); + pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); u_logout = account_policy_temp; unix_to_nt_time_abs(&nt_logout, u_logout); @@ -4637,15 +4637,15 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW init_unk_info8(&ctr->info.inf8, (uint32) time(NULL)); break; case 0x0c: - account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); + pdb_get_account_policy(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); u_lock_duration = account_policy_temp; if (u_lock_duration != -1) u_lock_duration *= 60; - account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp); + pdb_get_account_policy(AP_RESET_COUNT_TIME, &account_policy_temp); u_reset_time = account_policy_temp * 60; - account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); + pdb_get_account_policy(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); lockout = account_policy_temp; unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); @@ -4689,17 +4689,17 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R u_expire=nt_time_to_unix_abs(&q_u->ctr->info.inf1.expire); u_min_age=nt_time_to_unix_abs(&q_u->ctr->info.inf1.min_passwordage); - account_policy_set(AP_MIN_PASSWORD_LEN, (uint32)q_u->ctr->info.inf1.min_length_password); - account_policy_set(AP_PASSWORD_HISTORY, (uint32)q_u->ctr->info.inf1.password_history); - account_policy_set(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)q_u->ctr->info.inf1.flag); - account_policy_set(AP_MAX_PASSWORD_AGE, (int)u_expire); - account_policy_set(AP_MIN_PASSWORD_AGE, (int)u_min_age); + pdb_set_account_policy(AP_MIN_PASSWORD_LEN, (uint32)q_u->ctr->info.inf1.min_length_password); + pdb_set_account_policy(AP_PASSWORD_HISTORY, (uint32)q_u->ctr->info.inf1.password_history); + pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)q_u->ctr->info.inf1.flag); + pdb_set_account_policy(AP_MAX_PASSWORD_AGE, (int)u_expire); + pdb_set_account_policy(AP_MIN_PASSWORD_AGE, (int)u_min_age); break; case 0x02: break; case 0x03: u_logout=nt_time_to_unix_abs(&q_u->ctr->info.inf3.logout); - account_policy_set(AP_TIME_TO_LOGOUT, (int)u_logout); + pdb_set_account_policy(AP_TIME_TO_LOGOUT, (int)u_logout); break; case 0x05: break; @@ -4711,11 +4711,12 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R u_lock_duration=nt_time_to_unix_abs(&q_u->ctr->info.inf12.duration); if (u_lock_duration != -1) u_lock_duration /= 60; + u_reset_time=nt_time_to_unix_abs(&q_u->ctr->info.inf12.reset_count)/60; - account_policy_set(AP_LOCK_ACCOUNT_DURATION, (int)u_lock_duration); - account_policy_set(AP_RESET_COUNT_TIME, (int)u_reset_time); - account_policy_set(AP_BAD_ATTEMPT_LOCKOUT, (uint32)q_u->ctr->info.inf12.bad_attempt_lockout); + pdb_set_account_policy(AP_LOCK_ACCOUNT_DURATION, (int)u_lock_duration); + pdb_set_account_policy(AP_RESET_COUNT_TIME, (int)u_reset_time); + pdb_set_account_policy(AP_BAD_ATTEMPT_LOCKOUT, (uint32)q_u->ctr->info.inf12.bad_attempt_lockout); break; default: return NT_STATUS_INVALID_INFO_CLASS; -- cgit From 6e5accde90d9f078fbb3d1b0f11c45cfe391e4ad Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 22 Jan 2005 11:26:13 +0000 Subject: r4931: Add get_user_info_7 in SAMR. This just gives out the username. (In preparation of adding the ability of renaming users via setuserinfo level 7). Guenther (This used to be commit 6f34ed6c203fa11182640da97581075612d26c0e) --- source3/rpc_server/srv_samr_nt.c | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 8ee59210eb..612e69a813 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1698,6 +1698,40 @@ NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USE return r_u->status; } +/************************************************************************* + get_user_info_7. Safe. Only gives out account_name. + *************************************************************************/ + +static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_SID *user_sid) +{ + SAM_ACCOUNT *smbpass=NULL; + BOOL ret; + NTSTATUS nt_status; + + nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass); + + if (!NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } + + become_root(); + ret = pdb_getsampwsid(smbpass, user_sid); + unbecome_root(); + + if (ret==False) { + DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); + return NT_STATUS_NO_SUCH_USER; + } + + DEBUG(3,("User:[%s]\n", pdb_get_username(smbpass) )); + + ZERO_STRUCTP(id7); + init_sam_user_info7(id7, pdb_get_username(smbpass) ); + + pdb_free_sam(&smbpass); + + return NT_STATUS_OK; +} /************************************************************************* get_user_info_10. Safe. Only gives out acb bits. *************************************************************************/ @@ -1889,6 +1923,14 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ ctr->switch_value = q_u->switch_value; switch (q_u->switch_value) { + case 0x07: + ctr->info.id7 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_7); + if (ctr->info.id7 == NULL) + return NT_STATUS_NO_MEMORY; + + if (!NT_STATUS_IS_OK(r_u->status = get_user_info_7(p->mem_ctx, ctr->info.id7, &info->sid))) + return r_u->status; + break; case 0x10: ctr->info.id10 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_10); if (ctr->info.id10 == NULL) -- cgit From 9b1e5a71180f340a1f6327d53e68bb9b661ec894 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 25 Jan 2005 01:19:02 +0000 Subject: r4972: Fix a warning and some debugging-outputs. Guenther (This used to be commit 1eabfa050b661168b42892c2d841c7891e59cf5f) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 612e69a813..122bde1be5 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3123,7 +3123,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE can_add_machines = user_has_privileges( p->pipe_user.nt_user_token, &se_machineop ); - DEBUG(5, ("_samr_create_user: %s is%s a member of the Domain Admins group\n", + DEBUG(5, ("_samr_set_userinfo: %s is%s a member of the Domain Admins group\n", p->pipe_user_name, can_add_machines ? "" : " not")); /* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */ -- cgit From 46d8ff2320a1c195c3b54c57f5bf172c8473a741 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 26 Jan 2005 20:36:44 +0000 Subject: r5015: (based on abartlet's original patch to restrict password changes) * added SE_PRIV checks to access_check_samr_object() in order to deal with the run-time security descriptor and their interaction with user rights * Reordered original patch in _samr_set_userinfo[2] to still allow root/administrative password changes for users and machines. (This used to be commit f9f9e6039bd9443d54445e41c3783a2be18925fb) --- source3/rpc_server/srv_samr_nt.c | 871 +++++++++++++++++++++------------------ 1 file changed, 471 insertions(+), 400 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 122bde1be5..6815c7147c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -68,31 +68,240 @@ struct generic_mapping usr_generic_mapping = {GENERIC_RIGHTS_USER_READ, GENERIC_ struct generic_mapping grp_generic_mapping = {GENERIC_RIGHTS_GROUP_READ, GENERIC_RIGHTS_GROUP_WRITE, GENERIC_RIGHTS_GROUP_EXECUTE, GENERIC_RIGHTS_GROUP_ALL_ACCESS}; struct generic_mapping ali_generic_mapping = {GENERIC_RIGHTS_ALIAS_READ, GENERIC_RIGHTS_ALIAS_WRITE, GENERIC_RIGHTS_ALIAS_EXECUTE, GENERIC_RIGHTS_ALIAS_ALL_ACCESS}; -static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size); +/******************************************************************* + samr_make_dom_obj_sd + ********************************************************************/ + +static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +{ + extern DOM_SID global_sid_World; + DOM_SID adm_sid, act_sid, domadmin_sid; + SEC_ACE ace[4]; + SEC_ACCESS mask; + size_t i = 0; + + SEC_ACL *psa = NULL; + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + sid_copy(&act_sid, &global_sid_Builtin); + sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + + /*basic access for every one*/ + init_sec_access(&mask, GENERIC_RIGHTS_DOMAIN_EXECUTE | GENERIC_RIGHTS_DOMAIN_READ); + init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /*full access for builtin aliases Administrators and Account Operators*/ + + init_sec_access(&mask, GENERIC_RIGHTS_DOMAIN_ALL_ACCESS); + + init_sec_ace(&ace[i++], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /* add domain admins if we are a DC */ + + if ( IS_DC ) { + sid_copy( &domadmin_sid, get_global_sam_sid() ); + sid_append_rid( &domadmin_sid, DOMAIN_GROUP_RID_ADMINS ); + init_sec_ace(&ace[i++], &domadmin_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + } + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + return NT_STATUS_OK; +} + +/******************************************************************* + samr_make_usr_obj_sd + ********************************************************************/ + +static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size, DOM_SID *usr_sid) +{ + extern DOM_SID global_sid_World; + DOM_SID adm_sid, act_sid, domadmin_sid; + size_t i = 0; + + SEC_ACE ace[5]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + sid_copy(&act_sid, &global_sid_Builtin); + sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + + /*basic access for every one*/ + + init_sec_access(&mask, GENERIC_RIGHTS_USER_EXECUTE | GENERIC_RIGHTS_USER_READ); + init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /*full access for builtin aliases Administrators and Account Operators*/ + + init_sec_access(&mask, GENERIC_RIGHTS_USER_ALL_ACCESS); + init_sec_ace(&ace[i++], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /* add domain admins if we are a DC */ + + if ( IS_DC ) { + sid_copy( &domadmin_sid, get_global_sam_sid() ); + sid_append_rid( &domadmin_sid, DOMAIN_GROUP_RID_ADMINS ); + init_sec_ace(&ace[i++], &domadmin_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + } + + /*extended access for the user*/ + + init_sec_access(&mask,READ_CONTROL_ACCESS | SA_RIGHT_USER_CHANGE_PASSWORD | SA_RIGHT_USER_SET_LOC_COM); + init_sec_ace(&ace[i++], usr_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 4, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + return NT_STATUS_OK; +} + +/******************************************************************* + samr_make_grp_obj_sd + ********************************************************************/ + +static NTSTATUS samr_make_grp_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +{ + extern DOM_SID global_sid_World; + DOM_SID adm_sid; + DOM_SID act_sid; + + SEC_ACE ace[3]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + sid_copy(&act_sid, &global_sid_Builtin); + sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + + /*basic access for every one*/ + init_sec_access(&mask, GENERIC_RIGHTS_GROUP_EXECUTE | GENERIC_RIGHTS_GROUP_READ); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, GENERIC_RIGHTS_GROUP_ALL_ACCESS); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + return NT_STATUS_OK; +} + +/******************************************************************* + samr_make_ali_obj_sd + ********************************************************************/ + +static NTSTATUS samr_make_ali_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +{ + extern DOM_SID global_sid_World; + DOM_SID adm_sid; + DOM_SID act_sid; + + SEC_ACE ace[3]; + SEC_ACCESS mask; + + SEC_ACL *psa = NULL; + + sid_copy(&adm_sid, &global_sid_Builtin); + sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + + sid_copy(&act_sid, &global_sid_Builtin); + sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + + /*basic access for every one*/ + init_sec_access(&mask, GENERIC_RIGHTS_ALIAS_EXECUTE | GENERIC_RIGHTS_ALIAS_READ); + init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, GENERIC_RIGHTS_ALIAS_ALL_ACCESS); + init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) + return NT_STATUS_NO_MEMORY; + + if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) + return NT_STATUS_NO_MEMORY; + + return NT_STATUS_OK; +} /******************************************************************* Checks if access to an object should be granted, and returns that level of access for further checks. ********************************************************************/ -static NTSTATUS access_check_samr_object(SEC_DESC *psd, NT_USER_TOKEN *nt_user_token, uint32 des_access, - uint32 *acc_granted, const char *debug) +static NTSTATUS access_check_samr_object( SEC_DESC *psd, NT_USER_TOKEN *token, + SE_PRIV *rights, uint32 rights_mask, + uint32 des_access, uint32 *acc_granted, + const char *debug ) { NTSTATUS status = NT_STATUS_ACCESS_DENIED; + uint32 saved_mask = 0; - if (!se_access_check(psd, nt_user_token, des_access, acc_granted, &status)) { + /* check privileges; certain SAM access bits should be overridden + by privileges (mostly having to do with creating/modifying/deleting + users and groups) */ + + if ( rights && user_has_any_privilege( token, rights ) ) { + + saved_mask = (des_access & rights_mask); + des_access &= ~saved_mask; + + DEBUG(4,("access_check_samr_object: user rights saved access mask [0x%x]\n", + saved_mask)); + } + + + /* check the security descriptor first */ + + if ( se_access_check(psd, token, des_access, acc_granted, &status) ) + goto done; + + /* give root a free pass */ + + if ( geteuid() == sec_initial_uid() ) { + + DEBUG(4,("%s: ACCESS should be DENIED (requested: %#010x)\n", debug, des_access)); + DEBUGADD(4,("but overritten by euid == sec_initial_uid()\n")); + *acc_granted = des_access; - if (geteuid() == sec_initial_uid()) { - DEBUG(4,("%s: ACCESS should be DENIED (requested: %#010x)\n", - debug, des_access)); - DEBUGADD(4,("but overritten by euid == sec_initial_uid()\n")); - status = NT_STATUS_OK; - } - else { - DEBUG(2,("%s: ACCESS DENIED (requested: %#010x)\n", - debug, des_access)); - } + + status = NT_STATUS_OK; + goto done; } + + + DEBUG(2,("%s: ACCESS DENIED (requested: %#010x)\n", debug, des_access)); + +done: + /* add in any bits saved during the privilege check (only + matters is syayus is ok) */ + + *acc_granted |= saved_mask; + return status; } @@ -102,20 +311,29 @@ static NTSTATUS access_check_samr_object(SEC_DESC *psd, NT_USER_TOKEN *nt_user_t static NTSTATUS access_check_samr_function(uint32 acc_granted, uint32 acc_required, const char *debug) { - DEBUG(5,("%s: access check ((granted: %#010x; required: %#010x)\n", - debug, acc_granted, acc_required)); - if ((acc_granted & acc_required) != acc_required) { - if (geteuid() == sec_initial_uid()) { - DEBUG(4,("%s: ACCESS should be DENIED (granted: %#010x; required: %#010x)\n", - debug, acc_granted, acc_required)); - DEBUGADD(4,("but overwritten by euid == 0\n")); - return NT_STATUS_OK; - } - DEBUG(2,("%s: ACCESS DENIED (granted: %#010x; required: %#010x)\n", + DEBUG(5,("%s: access check ((granted: %#010x; required: %#010x)\n", + debug, acc_granted, acc_required)); + + /* check the security descriptor first */ + + if ( (acc_granted&acc_required) == acc_required ) + return NT_STATUS_OK; + + /* give root a free pass */ + + if (geteuid() == sec_initial_uid()) { + + DEBUG(4,("%s: ACCESS should be DENIED (granted: %#010x; required: %#010x)\n", debug, acc_granted, acc_required)); - return NT_STATUS_ACCESS_DENIED; + DEBUGADD(4,("but overwritten by euid == 0\n")); + + return NT_STATUS_OK; } - return NT_STATUS_OK; + + DEBUG(2,("%s: ACCESS DENIED (granted: %#010x; required: %#010x)\n", + debug, acc_granted, acc_required)); + + return NT_STATUS_ACCESS_DENIED; } @@ -355,281 +573,126 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) return NT_STATUS_OK; } - -/******************************************************************* - _samr_close_hnd - ********************************************************************/ - -NTSTATUS _samr_close_hnd(pipes_struct *p, SAMR_Q_CLOSE_HND *q_u, SAMR_R_CLOSE_HND *r_u) -{ - r_u->status = NT_STATUS_OK; - - /* close the policy handle */ - if (!close_policy_hnd(p, &q_u->pol)) - return NT_STATUS_OBJECT_NAME_INVALID; - - DEBUG(5,("samr_reply_close_hnd: %d\n", __LINE__)); - - return r_u->status; -} - -/******************************************************************* - samr_reply_open_domain - ********************************************************************/ - -NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN_DOMAIN *r_u) -{ - struct samr_info *info; - SEC_DESC *psd = NULL; - uint32 acc_granted; - uint32 des_access = q_u->flags; - size_t sd_size; - NTSTATUS status; - - r_u->status = NT_STATUS_OK; - - /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void**)&info)) - return NT_STATUS_INVALID_HANDLE; - - if (!NT_STATUS_IS_OK(status = access_check_samr_function(info->acc_granted, SA_RIGHT_SAM_OPEN_DOMAIN,"_samr_open_domain"))) { - return status; - } - - /*check if access can be granted as requested by client. */ - samr_make_dom_obj_sd(p->mem_ctx, &psd, &sd_size); - se_map_generic(&des_access,&dom_generic_mapping); - - if (!NT_STATUS_IS_OK(status = - access_check_samr_object(psd, p->pipe_user.nt_user_token, - des_access, &acc_granted, "_samr_open_domain"))) { - return status; - } - - /* associate the domain SID with the (unique) handle. */ - if ((info = get_samr_info_by_sid(&q_u->dom_sid.sid))==NULL) - return NT_STATUS_NO_MEMORY; - info->acc_granted = acc_granted; - - /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->domain_pol, free_samr_info, (void *)info)) - return NT_STATUS_OBJECT_NAME_NOT_FOUND; - - DEBUG(5,("samr_open_domain: %d\n", __LINE__)); - - return r_u->status; -} - -/******************************************************************* - _samr_get_usrdom_pwinfo - ********************************************************************/ - -NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, SAMR_R_GET_USRDOM_PWINFO *r_u) -{ - struct samr_info *info = NULL; - - 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)) - return NT_STATUS_INVALID_HANDLE; - - if (!sid_check_is_in_our_domain(&info->sid)) - return NT_STATUS_OBJECT_TYPE_MISMATCH; - - init_samr_r_get_usrdom_pwinfo(r_u, NT_STATUS_OK); - - DEBUG(5,("_samr_get_usrdom_pwinfo: %d\n", __LINE__)); - - /* - * NT sometimes return NT_STATUS_ACCESS_DENIED - * I don't know yet why. - */ - - return r_u->status; -} - -/******************************************************************* - samr_make_dom_obj_sd - ********************************************************************/ - -static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) -{ - extern DOM_SID global_sid_World; - DOM_SID adm_sid, act_sid, domadmin_sid; - SEC_ACE ace[4]; - SEC_ACCESS mask; - size_t i = 0; - - SEC_ACL *psa = NULL; - - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); - - sid_copy(&act_sid, &global_sid_Builtin); - sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); - - /*basic access for every one*/ - init_sec_access(&mask, GENERIC_RIGHTS_DOMAIN_EXECUTE | GENERIC_RIGHTS_DOMAIN_READ); - init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /*full access for builtin aliases Administrators and Account Operators*/ - - init_sec_access(&mask, GENERIC_RIGHTS_DOMAIN_ALL_ACCESS); - - init_sec_ace(&ace[i++], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[i++], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /* add domain admins if we are a DC */ - - if ( IS_DC ) { - sid_copy( &domadmin_sid, get_global_sam_sid() ); - sid_append_rid( &domadmin_sid, DOMAIN_GROUP_RID_ADMINS ); - init_sec_ace(&ace[i++], &domadmin_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - } - - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) == NULL) - return NT_STATUS_NO_MEMORY; - - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) - return NT_STATUS_NO_MEMORY; - - return NT_STATUS_OK; -} - -/******************************************************************* - samr_make_usr_obj_sd - ********************************************************************/ - -static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size, DOM_SID *usr_sid) -{ - extern DOM_SID global_sid_World; - DOM_SID adm_sid, act_sid, domadmin_sid; - size_t i = 0; - - SEC_ACE ace[5]; - SEC_ACCESS mask; - - SEC_ACL *psa = NULL; - - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); - - sid_copy(&act_sid, &global_sid_Builtin); - sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); - - /*basic access for every one*/ - - init_sec_access(&mask, GENERIC_RIGHTS_USER_EXECUTE | GENERIC_RIGHTS_USER_READ); - init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /*full access for builtin aliases Administrators and Account Operators*/ - - init_sec_access(&mask, GENERIC_RIGHTS_USER_ALL_ACCESS); - init_sec_ace(&ace[i++], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[i++], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /* add domain admins if we are a DC */ - - if ( IS_DC ) { - sid_copy( &domadmin_sid, get_global_sam_sid() ); - sid_append_rid( &domadmin_sid, DOMAIN_GROUP_RID_ADMINS ); - init_sec_ace(&ace[i++], &domadmin_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - } - - /*extended access for the user*/ - - init_sec_access(&mask,READ_CONTROL_ACCESS | SA_RIGHT_USER_CHANGE_PASSWORD | SA_RIGHT_USER_SET_LOC_COM); - init_sec_ace(&ace[i++], usr_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 4, ace)) == NULL) - return NT_STATUS_NO_MEMORY; - - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) - return NT_STATUS_NO_MEMORY; - - return NT_STATUS_OK; -} - + /******************************************************************* - samr_make_grp_obj_sd + _samr_close_hnd ********************************************************************/ -static NTSTATUS samr_make_grp_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +NTSTATUS _samr_close_hnd(pipes_struct *p, SAMR_Q_CLOSE_HND *q_u, SAMR_R_CLOSE_HND *r_u) { - extern DOM_SID global_sid_World; - DOM_SID adm_sid; - DOM_SID act_sid; + r_u->status = NT_STATUS_OK; - SEC_ACE ace[3]; - SEC_ACCESS mask; + /* close the policy handle */ + if (!close_policy_hnd(p, &q_u->pol)) + return NT_STATUS_OBJECT_NAME_INVALID; - SEC_ACL *psa = NULL; + DEBUG(5,("samr_reply_close_hnd: %d\n", __LINE__)); - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + return r_u->status; +} - sid_copy(&act_sid, &global_sid_Builtin); - sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); +/******************************************************************* + samr_reply_open_domain + ********************************************************************/ - /*basic access for every one*/ - init_sec_access(&mask, GENERIC_RIGHTS_GROUP_EXECUTE | GENERIC_RIGHTS_GROUP_READ); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); +NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN_DOMAIN *r_u) +{ + struct samr_info *info; + SEC_DESC *psd = NULL; + uint32 acc_granted; + uint32 des_access = q_u->flags; + size_t sd_size; + NTSTATUS status; + SE_PRIV se_rights; - /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, GENERIC_RIGHTS_GROUP_ALL_ACCESS); - init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + r_u->status = NT_STATUS_OK; - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) - return NT_STATUS_NO_MEMORY; + /* find the connection policy handle. */ + + if ( !find_policy_by_hnd(p, &q_u->pol, (void**)&info) ) + return NT_STATUS_INVALID_HANDLE; - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) + status = access_check_samr_function( info->acc_granted, + SA_RIGHT_SAM_OPEN_DOMAIN, "_samr_open_domain" ); + + if ( !NT_STATUS_IS_OK(status) ) + return status; + + /*check if access can be granted as requested by client. */ + + samr_make_dom_obj_sd( p->mem_ctx, &psd, &sd_size ); + se_map_generic( &des_access, &dom_generic_mapping ); + + se_priv_copy( &se_rights, &se_machine_account ); + se_priv_add( &se_rights, &se_add_users ); + + status = access_check_samr_object( psd, p->pipe_user.nt_user_token, + &se_rights, GENERIC_RIGHTS_DOMAIN_WRITE, des_access, + &acc_granted, "_samr_open_domain" ); + + if ( !NT_STATUS_IS_OK(status) ) + return status; + + /* associate the domain SID with the (unique) handle. */ + if ((info = get_samr_info_by_sid(&q_u->dom_sid.sid))==NULL) return NT_STATUS_NO_MEMORY; + info->acc_granted = acc_granted; - return NT_STATUS_OK; + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &r_u->domain_pol, free_samr_info, (void *)info)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + DEBUG(5,("samr_open_domain: %d\n", __LINE__)); + + return r_u->status; } /******************************************************************* - samr_make_ali_obj_sd + _samr_get_usrdom_pwinfo ********************************************************************/ -static NTSTATUS samr_make_ali_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, SAMR_R_GET_USRDOM_PWINFO *r_u) { - extern DOM_SID global_sid_World; - DOM_SID adm_sid; - DOM_SID act_sid; + struct samr_info *info = NULL; - SEC_ACE ace[3]; - SEC_ACCESS mask; + r_u->status = NT_STATUS_OK; - SEC_ACL *psa = NULL; + /* find the policy handle. open a policy on it. */ + if (!find_policy_by_hnd(p, &q_u->user_pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); + if (!sid_check_is_in_our_domain(&info->sid)) + return NT_STATUS_OBJECT_TYPE_MISMATCH; - sid_copy(&act_sid, &global_sid_Builtin); - sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); + init_samr_r_get_usrdom_pwinfo(r_u, NT_STATUS_OK); - /*basic access for every one*/ - init_sec_access(&mask, GENERIC_RIGHTS_ALIAS_EXECUTE | GENERIC_RIGHTS_ALIAS_READ); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + DEBUG(5,("_samr_get_usrdom_pwinfo: %d\n", __LINE__)); - /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, GENERIC_RIGHTS_ALIAS_ALL_ACCESS); - init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + /* + * NT sometimes return NT_STATUS_ACCESS_DENIED + * I don't know yet why. + */ - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) - return NT_STATUS_NO_MEMORY; + return r_u->status; +} - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) - return NT_STATUS_NO_MEMORY; - return NT_STATUS_OK; +/******************************************************************* + _samr_set_sec_obj + ********************************************************************/ + +NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_SEC_OBJ *r_u) +{ + DEBUG(0,("_samr_set_sec_obj: Not yet implemented!\n")); + return NT_STATUS_NOT_IMPLEMENTED; } -static BOOL get_lsa_policy_samr_sid(pipes_struct *p, POLICY_HND *pol, DOM_SID *sid, uint32 *acc_granted) + +/******************************************************************* +********************************************************************/ + +static BOOL get_lsa_policy_samr_sid( pipes_struct *p, POLICY_HND *pol, + DOM_SID *sid, uint32 *acc_granted) { struct samr_info *info = NULL; @@ -645,17 +708,6 @@ static BOOL get_lsa_policy_samr_sid(pipes_struct *p, POLICY_HND *pol, DOM_SID *s return True; } -/******************************************************************* - _samr_set_sec_obj - ********************************************************************/ - -NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_SEC_OBJ *r_u) -{ - DEBUG(0,("_samr_set_sec_obj: Not yet implemented!\n")); - return NT_STATUS_NOT_IMPLEMENTED; -} - - /******************************************************************* _samr_query_sec_obj ********************************************************************/ @@ -1646,34 +1698,45 @@ NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USE size_t sd_size; BOOL ret; NTSTATUS nt_status; + SE_PRIV se_rights; r_u->status = NT_STATUS_OK; /* find the domain policy handle and get domain SID / access bits in the domain policy. */ - if (!get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted)) + + if ( !get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted) ) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_user"))) { + nt_status = access_check_samr_function( acc_granted, + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_user" ); + + if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; - } nt_status = pdb_init_sam_talloc(p->mem_ctx, &sampass); - if (!NT_STATUS_IS_OK(nt_status)) { + + if (!NT_STATUS_IS_OK(nt_status)) return nt_status; - } /* append the user's RID to it */ + if (!sid_append_rid(&sid, q_u->user_rid)) return NT_STATUS_NO_SUCH_USER; /* check if access can be granted as requested by client. */ + samr_make_usr_obj_sd(p->mem_ctx, &psd, &sd_size, &sid); se_map_generic(&des_access, &usr_generic_mapping); - if (!NT_STATUS_IS_OK(nt_status = - access_check_samr_object(psd, p->pipe_user.nt_user_token, - des_access, &acc_granted, "_samr_open_user"))) { + + se_priv_copy( &se_rights, &se_machine_account ); + se_priv_add( &se_rights, &se_add_users ); + + nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, + &se_rights, GENERIC_RIGHTS_USER_WRITE, des_access, + &acc_granted, "_samr_open_user"); + + if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; - } become_root(); ret=pdb_getsampwsid(sampass, &sid); @@ -2396,7 +2459,8 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA se_map_generic(&des_access, &usr_generic_mapping); nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, - des_access, &acc_granted, "_samr_create_user"); + &se_rights, GENERIC_RIGHTS_USER_WRITE, des_access, + &acc_granted, "_samr_create_user"); if ( !NT_STATUS_IS_OK(nt_status) ) { return nt_status; @@ -2494,11 +2558,12 @@ NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u samr_make_sam_obj_sd(p->mem_ctx, &psd, &sd_size); se_map_generic(&des_access, &sam_generic_mapping); - if (!NT_STATUS_IS_OK(nt_status = - access_check_samr_object(psd, p->pipe_user.nt_user_token, - des_access, &acc_granted, "_samr_connect"))) { + + nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, + NULL, 0, des_access, &acc_granted, "_samr_connect"); + + if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; - } r_u->status = NT_STATUS_OK; @@ -2544,11 +2609,12 @@ NTSTATUS _samr_connect4(pipes_struct *p, SAMR_Q_CONNECT4 *q_u, SAMR_R_CONNECT4 * samr_make_sam_obj_sd(p->mem_ctx, &psd, &sd_size); se_map_generic(&des_access, &sam_generic_mapping); - if (!NT_STATUS_IS_OK(nt_status = - access_check_samr_object(psd, p->pipe_user.nt_user_token, - des_access, &acc_granted, "_samr_connect"))) { + + nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, + NULL, 0, des_access, &acc_granted, "_samr_connect4"); + + if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; - } r_u->status = NT_STATUS_OK; @@ -2693,29 +2759,40 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A uint32 des_access = q_u->access_mask; size_t sd_size; NTSTATUS status; + SE_PRIV se_rights; r_u->status = NT_STATUS_OK; /* find the domain policy and get the SID / access bits stored in the domain policy */ - if (!get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted)) + + if ( !get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted) ) return NT_STATUS_INVALID_HANDLE; + + status = access_check_samr_function(acc_granted, + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_alias"); - if (!NT_STATUS_IS_OK(status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_alias"))) { + if ( !NT_STATUS_IS_OK(status) ) return status; - } /* append the alias' RID to it */ + if (!sid_append_rid(&sid, alias_rid)) return NT_STATUS_NO_SUCH_USER; /*check if access can be granted as requested by client. */ + samr_make_ali_obj_sd(p->mem_ctx, &psd, &sd_size); se_map_generic(&des_access,&ali_generic_mapping); - if (!NT_STATUS_IS_OK(status = - access_check_samr_object(psd, p->pipe_user.nt_user_token, - des_access, &acc_granted, "_samr_open_alias"))) { + + se_priv_add( &se_rights, &se_add_users ); + + + status = access_check_samr_object(psd, p->pipe_user.nt_user_token, + &se_rights, GENERIC_RIGHTS_ALIAS_WRITE, des_access, + &acc_granted, "_samr_open_alias"); + + if ( !NT_STATUS_IS_OK(status) ) return status; - } /* * we should check if the rid really exist !!! @@ -2739,20 +2816,8 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A set_user_info_10 ********************************************************************/ -static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, DOM_SID *sid) +static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, SAM_ACCOUNT *pwd) { - SAM_ACCOUNT *pwd =NULL; - BOOL ret; - - pdb_init_sam(&pwd); - - ret = pdb_getsampwsid(pwd, sid); - - 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); @@ -2779,16 +2844,8 @@ static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, DOM_SID *sid) set_user_info_12 ********************************************************************/ -static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, DOM_SID *sid) +static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, SAM_ACCOUNT *pwd) { - SAM_ACCOUNT *pwd = NULL; - - pdb_init_sam(&pwd); - - if(!pdb_getsampwsid(pwd, sid)) { - pdb_free_sam(&pwd); - return False; - } if (id12 == NULL) { DEBUG(2, ("set_user_info_12: id12 is NULL\n")); @@ -2858,22 +2915,13 @@ static BOOL set_unix_primary_group(SAM_ACCOUNT *sampass) set_user_info_20 ********************************************************************/ -static BOOL set_user_info_20(SAM_USER_INFO_20 *id20, DOM_SID *sid) +static BOOL set_user_info_20(SAM_USER_INFO_20 *id20, SAM_ACCOUNT *pwd) { - SAM_ACCOUNT *pwd = NULL; - if (id20 == NULL) { DEBUG(5, ("set_user_info_20: NULL id20\n")); return False; } - pdb_init_sam(&pwd); - - if (!pdb_getsampwsid(pwd, sid)) { - pdb_free_sam(&pwd); - return False; - } - copy_id20_to_sam_passwd(pwd, id20); /* write the change out */ @@ -2890,22 +2938,14 @@ static BOOL set_user_info_20(SAM_USER_INFO_20 *id20, DOM_SID *sid) set_user_info_21 ********************************************************************/ -static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, DOM_SID *sid) +static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, SAM_ACCOUNT *pwd) { - SAM_ACCOUNT *pwd = NULL; if (id21 == NULL) { DEBUG(5, ("set_user_info_21: NULL id21\n")); return False; } - pdb_init_sam(&pwd); - - if (!pdb_getsampwsid(pwd, sid)) { - pdb_free_sam(&pwd); - return False; - } - copy_id21_to_sam_passwd(pwd, id21); /* @@ -2933,9 +2973,8 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, DOM_SID *sid) set_user_info_23 ********************************************************************/ -static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) +static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, SAM_ACCOUNT *pwd) { - SAM_ACCOUNT *pwd = NULL; pstring plaintext_buf; uint32 len; uint16 acct_ctrl; @@ -2945,13 +2984,6 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) return False; } - pdb_init_sam(&pwd); - - if (!pdb_getsampwsid(pwd, sid)) { - pdb_free_sam(&pwd); - return False; - } - DEBUG(5, ("Attempting administrator password change (level 23) for user %s\n", pdb_get_username(pwd))); @@ -3008,20 +3040,12 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, DOM_SID *sid) set_user_info_pw ********************************************************************/ -static BOOL set_user_info_pw(char *pass, DOM_SID *sid) +static BOOL set_user_info_pw(char *pass, SAM_ACCOUNT *pwd) { - SAM_ACCOUNT *pwd = NULL; uint32 len; pstring plaintext_buf; uint16 acct_ctrl; - pdb_init_sam(&pwd); - - if (!pdb_getsampwsid(pwd, sid)) { - pdb_free_sam(&pwd); - return False; - } - DEBUG(5, ("Attempting administrator password change for user %s\n", pdb_get_username(pwd))); @@ -3080,14 +3104,16 @@ static BOOL set_user_info_pw(char *pass, DOM_SID *sid) NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_USERINFO *r_u) { + SAM_ACCOUNT *pwd = NULL; DOM_SID sid; POLICY_HND *pol = &q_u->pol; uint16 switch_value = q_u->switch_value; SAM_USERINFO_CTR *ctr = q_u->ctr; uint32 acc_granted; uint32 acc_required; - BOOL can_add_machines; - SE_PRIV se_machineop = SE_MACHINE_ACCOUNT; + BOOL ret; + BOOL has_enough_rights; + SE_PRIV se_rights; DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); @@ -3118,24 +3144,42 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE DEBUG(5, ("_samr_set_userinfo: NULL info level\n")); return NT_STATUS_INVALID_INFO_CLASS; } + + pdb_init_sam(&pwd); + + become_root(); + ret = pdb_getsampwsid(pwd, &sid); + unbecome_root(); + + if ( !ret ) { + pdb_free_sam(&pwd); + return NT_STATUS_NO_SUCH_USER; + } + + /* deal with machine password changes differently from userinfo changes */ + + if ( pdb_get_acct_ctrl(pwd) & ACB_WSTRUST ) + se_priv_copy( &se_rights, &se_machine_account ); + else + se_priv_copy( &se_rights, &se_add_users ); - /* check to see if we are a domain admin */ + /* check to see if we have the sufficient rights */ - can_add_machines = user_has_privileges( p->pipe_user.nt_user_token, &se_machineop ); + has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); - DEBUG(5, ("_samr_set_userinfo: %s is%s a member of the Domain Admins group\n", - p->pipe_user_name, can_add_machines ? "" : " not")); + DEBUG(5, ("_samr_set_userinfo: %s does%s possess sufficient rights\n", + p->pipe_user_name, has_enough_rights ? "" : " not")); /* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */ - if ( can_add_machines ) - become_root(); - + if ( has_enough_rights ) + become_root(); + /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { - case 0x12: - if (!set_user_info_12(ctr->info.id12, &sid)) + case 18: + if (!set_user_info_12(ctr->info.id12, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; break; @@ -3147,7 +3191,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE dump_data(100, (char *)ctr->info.id24->pass, 516); - if (!set_user_info_pw((char *)ctr->info.id24->pass, &sid)) + if (!set_user_info_pw((char *)ctr->info.id24->pass, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; break; @@ -3183,7 +3227,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE dump_data(100, (char *)ctr->info.id23->pass, 516); - if (!set_user_info_23(ctr->info.id23, &sid)) + if (!set_user_info_23(ctr->info.id23, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; break; @@ -3192,7 +3236,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE } - if ( can_add_machines ) + if ( has_enough_rights ) unbecome_root(); /* ================ END SeMachineAccountPrivilege BLOCK ================ */ @@ -3206,14 +3250,16 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SET_USERINFO2 *r_u) { + SAM_ACCOUNT *pwd = NULL; DOM_SID sid; SAM_USERINFO_CTR *ctr = q_u->ctr; POLICY_HND *pol = &q_u->pol; uint16 switch_value = q_u->switch_value; uint32 acc_granted; uint32 acc_required; - BOOL can_add_machines; - SE_PRIV se_machineop = SE_MACHINE_ACCOUNT; + BOOL ret; + BOOL has_enough_rights; + SE_PRIV se_rights; DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__)); @@ -3237,43 +3283,61 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ switch_value=ctr->switch_value; - /* check to see if we are a domain admin */ + pdb_init_sam(&pwd); + + become_root(); + ret = pdb_getsampwsid(pwd, &sid); + unbecome_root(); + + if ( !ret ) { + pdb_free_sam(&pwd); + return NT_STATUS_NO_SUCH_USER; + } + + /* deal with machine password changes differently from userinfo changes */ + + if ( pdb_get_acct_ctrl(pwd) & ACB_WSTRUST ) + se_priv_copy( &se_rights, &se_machine_account ); + else + se_priv_copy( &se_rights, &se_add_users ); + + /* check to see if we have the sufficient rights */ - can_add_machines = user_has_privileges( p->pipe_user.nt_user_token, &se_machineop ); + has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); - DEBUG(5, ("_samr_create_user: %s is%s a member of the Domain Admins group\n", - p->pipe_user_name, can_add_machines ? "" : " not")); + DEBUG(5, ("_samr_set_userinfo: %s does%s possess sufficient rights\n", + p->pipe_user_name, has_enough_rights ? "" : " not")); /* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */ - if ( can_add_machines ) - become_root(); - + if ( has_enough_rights ) + become_root(); + /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { case 21: - if (!set_user_info_21(ctr->info.id21, &sid)) + if (!set_user_info_21(ctr->info.id21, pwd)) return NT_STATUS_ACCESS_DENIED; break; case 20: - if (!set_user_info_20(ctr->info.id20, &sid)) + if (!set_user_info_20(ctr->info.id20, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; break; case 16: - if (!set_user_info_10(ctr->info.id10, &sid)) + if (!set_user_info_10(ctr->info.id10, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; break; case 18: /* Used by AS/U JRA. */ - if (!set_user_info_12(ctr->info.id12, &sid)) + if (!set_user_info_12(ctr->info.id12, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; break; default: r_u->status = NT_STATUS_INVALID_INFO_CLASS; } - if ( can_add_machines ) + if ( has_enough_rights ) unbecome_root(); /* ================ END SeMachineAccountPrivilege BLOCK ================ */ @@ -4413,25 +4477,32 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G NTSTATUS status; fstring sid_string; BOOL ret; + SE_PRIV se_rights; if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_group"))) { + status = access_check_samr_function(acc_granted, + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_group"); + + if ( !NT_STATUS_IS_OK(status) ) return status; - } /*check if access can be granted as requested by client. */ samr_make_grp_obj_sd(p->mem_ctx, &psd, &sd_size); se_map_generic(&des_access,&grp_generic_mapping); - if (!NT_STATUS_IS_OK(status = - access_check_samr_object(psd, p->pipe_user.nt_user_token, - des_access, &acc_granted, "_samr_open_group"))) { - return status; - } + se_priv_copy( &se_rights, &se_add_users ); + + status = access_check_samr_object(psd, p->pipe_user.nt_user_token, + &se_rights, GENERIC_RIGHTS_GROUP_WRITE, des_access, + &acc_granted, "_samr_open_group"); + + if ( !NT_STATUS_IS_OK(status) ) + return status; /* this should not be hard-coded like this */ + if (!sid_equal(&sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; -- cgit From 091f4bcda5cee113ade6ae64fa892278eb17dd5b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 27 Jan 2005 02:16:02 +0000 Subject: r5028: * check acb_info mask in _samr_create_user instead of the last character of the user name * fix some access_mask checks in _samr_set_userinfo2 (getting join from XP without being a member of domain admins working) (This used to be commit 04030534ffd35f8ebc997d9403fd87309403dcbf) --- source3/rpc_server/srv_samr_nt.c | 57 +++++++++++++++------------------------- 1 file changed, 21 insertions(+), 36 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6815c7147c..43abfdaafa 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -294,13 +294,15 @@ static NTSTATUS access_check_samr_object( SEC_DESC *psd, NT_USER_TOKEN *token, } - DEBUG(2,("%s: ACCESS DENIED (requested: %#010x)\n", debug, des_access)); - done: /* add in any bits saved during the privilege check (only matters is syayus is ok) */ *acc_granted |= saved_mask; + + DEBUG(4,("%s: access %s (requested: 0x%08x, granted: 0x%08x)\n", + debug, NT_STATUS_IS_OK(status) ? "GRANTED" : "DENIED", + des_access, *acc_granted)); return status; } @@ -2343,12 +2345,6 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA return NT_STATUS_INVALID_PARAMETER; } - /* find the 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... - */ - rpcstr_pull(account, user_account.buffer, sizeof(account), user_account.uni_str_len*2, 0); strlower_m(account); @@ -2377,16 +2373,9 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA *********************************************************************/ pw = Get_Pwnam(account); - - /* - * we can't check both the ending $ and the acb_info. - * - * UserManager creates trust accounts (ending in $, - * normal that hidden accounts) with the acb_info equals to ACB_NORMAL. - * JFM, 11/29/2001 - */ - if (account[strlen(account)-1] == '$') { + /* determine which user right we need to check based on the acb_info */ + if ( acb_info == ACB_WSTRUST ) { se_priv_copy( &se_rights, &se_machine_account ); pstrcpy(add_script, lp_addmachine_script()); } @@ -3122,17 +3111,10 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE /* find the policy handle. open a policy on it. */ if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - - /* the access mask depends on what the caller wants to do */ - switch (switch_value) { - case 24: - acc_required = SA_RIGHT_USER_SET_PASSWORD | SA_RIGHT_USER_SET_ATTRIBUTES | SA_RIGHT_USER_ACCT_FLAGS_EXPIRY; - break; - default: - acc_required = SA_RIGHT_USER_SET_LOC_COM | SA_RIGHT_USER_SET_ATTRIBUTES; /* This is probably wrong */ - break; - } + /* observed when joining an XP client to a Samba domain */ + + acc_required = SA_RIGHT_USER_SET_PASSWORD | SA_RIGHT_USER_SET_ATTRIBUTES | SA_RIGHT_USER_ACCT_FLAGS_EXPIRY; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo"))) { return r_u->status; @@ -3268,8 +3250,11 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ /* find the policy handle. open a policy on it. */ if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; + + /* observed when joining XP client to Samba domain */ + + acc_required = SA_RIGHT_USER_SET_PASSWORD | SA_RIGHT_USER_SET_ATTRIBUTES | SA_RIGHT_USER_ACCT_FLAGS_EXPIRY; - acc_required = SA_RIGHT_USER_SET_LOC_COM | SA_RIGHT_USER_SET_ATTRIBUTES; /* This is probably wrong */ if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo2"))) { return r_u->status; } @@ -3316,14 +3301,6 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { - case 21: - if (!set_user_info_21(ctr->info.id21, pwd)) - return NT_STATUS_ACCESS_DENIED; - break; - case 20: - if (!set_user_info_20(ctr->info.id20, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; - break; case 16: if (!set_user_info_10(ctr->info.id10, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; @@ -3333,6 +3310,14 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ if (!set_user_info_12(ctr->info.id12, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; break; + case 20: + if (!set_user_info_20(ctr->info.id20, pwd)) + r_u->status = NT_STATUS_ACCESS_DENIED; + break; + case 21: + if (!set_user_info_21(ctr->info.id21, pwd)) + return NT_STATUS_ACCESS_DENIED; + break; default: r_u->status = NT_STATUS_INVALID_INFO_CLASS; } -- cgit From 962a5c95528932fde64c8c8b70b0a81c382c2905 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 28 Jan 2005 16:55:09 +0000 Subject: r5056: * correct STANDARD_RIGHTS_WRITE_ACCESS bitmask define * make sure to apply the rights_mask and not just the saved bits from the mask in access_check_samr_object() * allow root to grant/revoke privileges (in addition to Domain Admins) as suggested by Volker. Tested machine joins from XP, 2K, and NT4 with and without pre-existing machine trust accounts. Also tested basic file operations using cmd.exe and explorer.exe after changing the STANDARD_RIGHTS_WRITE_ACCESS bitmask. (This used to be commit c0e7f7ff60a4110809b8f500fdc68a1bf963da36) --- source3/rpc_server/srv_lsa_nt.c | 22 ++++++++++++++++------ source3/rpc_server/srv_samr_nt.c | 8 ++++---- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 13053d9877..da00d2d6c4 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1134,16 +1134,21 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u struct lsa_info *info = NULL; SE_PRIV mask; PRIVILEGE_SET *set = NULL; + struct current_user user; /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - /* check to see if the pipe_user is a Domain Admin since + /* check to see if the pipe_user is root or a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - - if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + + get_current_user( &user, p ); + if ( user.uid != sec_initial_uid() + && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + { return NT_STATUS_ACCESS_DENIED; + } set = &q_u->set; @@ -1170,16 +1175,21 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP struct lsa_info *info = NULL; SE_PRIV mask; PRIVILEGE_SET *set = NULL; + struct current_user user; /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - /* check to see if the pipe_user is a Domain Admin since + /* check to see if the pipe_user is root or a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - - if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + + get_current_user( &user, p ); + if ( user.uid != sec_initial_uid() + && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + { return NT_STATUS_ACCESS_DENIED; + } set = &q_u->set; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 43abfdaafa..4d8e2b51cc 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -270,8 +270,8 @@ static NTSTATUS access_check_samr_object( SEC_DESC *psd, NT_USER_TOKEN *token, saved_mask = (des_access & rights_mask); des_access &= ~saved_mask; - DEBUG(4,("access_check_samr_object: user rights saved access mask [0x%x]\n", - saved_mask)); + DEBUG(4,("access_check_samr_object: user rights access mask [0x%x]\n", + rights_mask)); } @@ -296,9 +296,9 @@ static NTSTATUS access_check_samr_object( SEC_DESC *psd, NT_USER_TOKEN *token, done: /* add in any bits saved during the privilege check (only - matters is syayus is ok) */ + matters is status is ok) */ - *acc_granted |= saved_mask; + *acc_granted |= rights_mask; DEBUG(4,("%s: access %s (requested: 0x%08x, granted: 0x%08x)\n", debug, NT_STATUS_IS_OK(status) ? "GRANTED" : "DENIED", -- cgit From f35a9c5af6226b2292dbb49b9c20bf6b4d5f3bdc Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 31 Jan 2005 22:42:30 +0000 Subject: r5150: consolidate the samr_make.*obj_sd() functions to share code (This used to be commit 5bd03d59263ab619390062c1d023ad1ba54dce6a) --- source3/rpc_server/srv_samr_nt.c | 198 ++++++++------------------------------- 1 file changed, 41 insertions(+), 157 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 4d8e2b51cc..e963fbaa0a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -34,6 +34,11 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +#define SAMR_USR_RIGHTS_WRITE_PW \ + ( READ_CONTROL_ACCESS | \ + SA_RIGHT_USER_CHANGE_PASSWORD | \ + SA_RIGHT_USER_SET_LOC_COM ) + extern DOM_SID global_sid_Builtin; extern rid_name domain_group_rids[]; @@ -69,86 +74,39 @@ struct generic_mapping grp_generic_mapping = {GENERIC_RIGHTS_GROUP_READ, GENERIC struct generic_mapping ali_generic_mapping = {GENERIC_RIGHTS_ALIAS_READ, GENERIC_RIGHTS_ALIAS_WRITE, GENERIC_RIGHTS_ALIAS_EXECUTE, GENERIC_RIGHTS_ALIAS_ALL_ACCESS}; /******************************************************************* - samr_make_dom_obj_sd - ********************************************************************/ +*******************************************************************/ -static NTSTATUS samr_make_dom_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) +static NTSTATUS make_samr_object_sd( TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size, + struct generic_mapping *map, + DOM_SID *sid, uint32 sid_access ) { extern DOM_SID global_sid_World; DOM_SID adm_sid, act_sid, domadmin_sid; - SEC_ACE ace[4]; + SEC_ACE ace[5]; /* at most 5 entries */ SEC_ACCESS mask; size_t i = 0; SEC_ACL *psa = NULL; - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); - - sid_copy(&act_sid, &global_sid_Builtin); - sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); - - /*basic access for every one*/ - init_sec_access(&mask, GENERIC_RIGHTS_DOMAIN_EXECUTE | GENERIC_RIGHTS_DOMAIN_READ); - init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /*full access for builtin aliases Administrators and Account Operators*/ - - init_sec_access(&mask, GENERIC_RIGHTS_DOMAIN_ALL_ACCESS); + /* basic access for Everyone */ - init_sec_ace(&ace[i++], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[i++], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_access(&mask, map->generic_execute | map->generic_read ); + init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - /* add domain admins if we are a DC */ + /* add Full Access 'BUILTIN\Administrators' and 'BUILTIN\Account Operators */ - if ( IS_DC ) { - sid_copy( &domadmin_sid, get_global_sam_sid() ); - sid_append_rid( &domadmin_sid, DOMAIN_GROUP_RID_ADMINS ); - init_sec_ace(&ace[i++], &domadmin_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - } - - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) == NULL) - return NT_STATUS_NO_MEMORY; - - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) - return NT_STATUS_NO_MEMORY; - - return NT_STATUS_OK; -} - -/******************************************************************* - samr_make_usr_obj_sd - ********************************************************************/ - -static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size, DOM_SID *usr_sid) -{ - extern DOM_SID global_sid_World; - DOM_SID adm_sid, act_sid, domadmin_sid; - size_t i = 0; - - SEC_ACE ace[5]; - SEC_ACCESS mask; - - SEC_ACL *psa = NULL; - sid_copy(&adm_sid, &global_sid_Builtin); sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); sid_copy(&act_sid, &global_sid_Builtin); sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); - - /*basic access for every one*/ - init_sec_access(&mask, GENERIC_RIGHTS_USER_EXECUTE | GENERIC_RIGHTS_USER_READ); - init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /*full access for builtin aliases Administrators and Account Operators*/ + init_sec_access(&mask, map->generic_all); - init_sec_access(&mask, GENERIC_RIGHTS_USER_ALL_ACCESS); init_sec_ace(&ace[i++], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); init_sec_ace(&ace[i++], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /* add domain admins if we are a DC */ + + /* Add Full Access for Domain Admins if we are a DC */ if ( IS_DC ) { sid_copy( &domadmin_sid, get_global_sam_sid() ); @@ -156,90 +114,16 @@ static NTSTATUS samr_make_usr_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd init_sec_ace(&ace[i++], &domadmin_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); } - /*extended access for the user*/ + /* if we have a sid, give it some special access */ - init_sec_access(&mask,READ_CONTROL_ACCESS | SA_RIGHT_USER_CHANGE_PASSWORD | SA_RIGHT_USER_SET_LOC_COM); - init_sec_ace(&ace[i++], usr_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 4, ace)) == NULL) - return NT_STATUS_NO_MEMORY; - - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) - return NT_STATUS_NO_MEMORY; - - return NT_STATUS_OK; -} - -/******************************************************************* - samr_make_grp_obj_sd - ********************************************************************/ - -static NTSTATUS samr_make_grp_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) -{ - extern DOM_SID global_sid_World; - DOM_SID adm_sid; - DOM_SID act_sid; - - SEC_ACE ace[3]; - SEC_ACCESS mask; - - SEC_ACL *psa = NULL; - - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); - - sid_copy(&act_sid, &global_sid_Builtin); - sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); - - /*basic access for every one*/ - init_sec_access(&mask, GENERIC_RIGHTS_GROUP_EXECUTE | GENERIC_RIGHTS_GROUP_READ); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, GENERIC_RIGHTS_GROUP_ALL_ACCESS); - init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) - return NT_STATUS_NO_MEMORY; - - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) - return NT_STATUS_NO_MEMORY; - - return NT_STATUS_OK; -} - -/******************************************************************* - samr_make_ali_obj_sd - ********************************************************************/ - -static NTSTATUS samr_make_ali_obj_sd(TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size) -{ - extern DOM_SID global_sid_World; - DOM_SID adm_sid; - DOM_SID act_sid; - - SEC_ACE ace[3]; - SEC_ACCESS mask; - - SEC_ACL *psa = NULL; - - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); - - sid_copy(&act_sid, &global_sid_Builtin); - sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); - - /*basic access for every one*/ - init_sec_access(&mask, GENERIC_RIGHTS_ALIAS_EXECUTE | GENERIC_RIGHTS_ALIAS_READ); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /*full access for builtin aliases Administrators and Account Operators*/ - init_sec_access(&mask, GENERIC_RIGHTS_ALIAS_ALL_ACCESS); - init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[2], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 3, ace)) == NULL) + if ( sid ) { + init_sec_access( &mask, sid_access ); + init_sec_ace(&ace[i++], sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + } + + /* create the security descriptor */ + + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) == NULL) return NT_STATUS_NO_MEMORY; if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) @@ -603,8 +487,8 @@ NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN SEC_DESC *psd = NULL; uint32 acc_granted; uint32 des_access = q_u->flags; - size_t sd_size; NTSTATUS status; + size_t sd_size; SE_PRIV se_rights; r_u->status = NT_STATUS_OK; @@ -622,7 +506,7 @@ NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN /*check if access can be granted as requested by client. */ - samr_make_dom_obj_sd( p->mem_ctx, &psd, &sd_size ); + make_samr_object_sd( p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0 ); se_map_generic( &des_access, &dom_generic_mapping ); se_priv_copy( &se_rights, &se_machine_account ); @@ -719,8 +603,8 @@ NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_ DOM_SID pol_sid; fstring str_sid; SEC_DESC * psd = NULL; - size_t sd_size; uint32 acc_granted; + size_t sd_size; r_u->status = NT_STATUS_OK; @@ -738,19 +622,19 @@ NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_ if (pol_sid.sid_rev_num == 0) { DEBUG(5,("_samr_query_sec_obj: querying security on SAM\n")); - r_u->status = samr_make_sam_obj_sd(p->mem_ctx, &psd, &sd_size); + r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); } else if (sid_equal(&pol_sid,get_global_sam_sid())) /* check if it is our domain SID */ { DEBUG(5,("_samr_query_sec_obj: querying security on Domain with SID: %s\n", sid_to_string(str_sid, &pol_sid))); - r_u->status = samr_make_dom_obj_sd(p->mem_ctx, &psd, &sd_size); + r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0); } else if (sid_equal(&pol_sid,&global_sid_Builtin)) /* check if it is the Builtin Domain */ { /* TODO: Builtin probably needs a different SD with restricted write access*/ DEBUG(5,("_samr_query_sec_obj: querying security on Builtin Domain with SID: %s\n", sid_to_string(str_sid, &pol_sid))); - r_u->status = samr_make_dom_obj_sd(p->mem_ctx, &psd, &sd_size); + r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0); } else if (sid_check_is_in_our_domain(&pol_sid) || sid_check_is_in_builtin(&pol_sid)) @@ -758,7 +642,7 @@ NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_ /* TODO: different SDs have to be generated for aliases groups and users. Currently all three get a default user SD */ DEBUG(10,("_samr_query_sec_obj: querying security on Object with SID: %s\n", sid_to_string(str_sid, &pol_sid))); - r_u->status = samr_make_usr_obj_sd(p->mem_ctx, &psd,&sd_size, &pol_sid); + r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, &pol_sid, SAMR_USR_RIGHTS_WRITE_PW); } else return NT_STATUS_OBJECT_TYPE_MISMATCH; @@ -1727,7 +1611,7 @@ NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USE /* check if access can be granted as requested by client. */ - samr_make_usr_obj_sd(p->mem_ctx, &psd, &sd_size, &sid); + make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, &sid, SAMR_USR_RIGHTS_WRITE_PW); se_map_generic(&des_access, &usr_generic_mapping); se_priv_copy( &se_rights, &se_machine_account ); @@ -2444,7 +2328,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA sid_copy(&sid, pdb_get_user_sid(sam_pass)); - samr_make_usr_obj_sd(p->mem_ctx, &psd, &sd_size, &sid); + make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, &sid, SAMR_USR_RIGHTS_WRITE_PW); se_map_generic(&des_access, &usr_generic_mapping); nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, @@ -2531,8 +2415,8 @@ NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u SEC_DESC *psd = NULL; uint32 acc_granted; uint32 des_access = q_u->access_mask; - size_t sd_size; NTSTATUS nt_status; + size_t sd_size; DEBUG(5,("_samr_connect: %d\n", __LINE__)); @@ -2545,7 +2429,7 @@ NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u return r_u->status; } - samr_make_sam_obj_sd(p->mem_ctx, &psd, &sd_size); + make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); se_map_generic(&des_access, &sam_generic_mapping); nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, @@ -2582,8 +2466,8 @@ NTSTATUS _samr_connect4(pipes_struct *p, SAMR_Q_CONNECT4 *q_u, SAMR_R_CONNECT4 * SEC_DESC *psd = NULL; uint32 acc_granted; uint32 des_access = q_u->access_mask; - size_t sd_size; NTSTATUS nt_status; + size_t sd_size; DEBUG(5,("_samr_connect4: %d\n", __LINE__)); @@ -2596,7 +2480,7 @@ NTSTATUS _samr_connect4(pipes_struct *p, SAMR_Q_CONNECT4 *q_u, SAMR_R_CONNECT4 * return r_u->status; } - samr_make_sam_obj_sd(p->mem_ctx, &psd, &sd_size); + make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); se_map_generic(&des_access, &sam_generic_mapping); nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, @@ -2770,7 +2654,7 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A /*check if access can be granted as requested by client. */ - samr_make_ali_obj_sd(p->mem_ctx, &psd, &sd_size); + make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &ali_generic_mapping, NULL, 0); se_map_generic(&des_access,&ali_generic_mapping); se_priv_add( &se_rights, &se_add_users ); @@ -4474,7 +4358,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G return status; /*check if access can be granted as requested by client. */ - samr_make_grp_obj_sd(p->mem_ctx, &psd, &sd_size); + make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &grp_generic_mapping, NULL, 0); se_map_generic(&des_access,&grp_generic_mapping); se_priv_copy( &se_rights, &se_add_users ); -- cgit From 4523bd1446dc411a29b82bdd13e564979b0d5d18 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 2 Feb 2005 20:11:37 +0000 Subject: r5180: Call the "add machine script" to create all kinds of trust accounts (this restores old behaviour). Fixes #2291. Guenther (This used to be commit 5ca0d1b87cd20f538a13321eb11ef97d00bf5133) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e963fbaa0a..b58111c1b7 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2259,7 +2259,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA pw = Get_Pwnam(account); /* determine which user right we need to check based on the acb_info */ - if ( acb_info == ACB_WSTRUST ) { + if ( acb_info & (ACB_WSTRUST|ACB_SVRTRUST|ACB_DOMTRUST)) { se_priv_copy( &se_rights, &se_machine_account ); pstrcpy(add_script, lp_addmachine_script()); } -- cgit From a84bb6d1ec0316a39c8b730c40c9215d9d7f959a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 3 Feb 2005 15:14:54 +0000 Subject: r5203: additional changes for BUG 2291 to restrict who can join a BDC and add domain trusts (This used to be commit 5ec1faa2ad33772fb48c3863e67d2ce4be726bb2) --- source3/rpc_server/srv_samr_nt.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b58111c1b7..83da810444 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2259,17 +2259,27 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA pw = Get_Pwnam(account); /* determine which user right we need to check based on the acb_info */ - if ( acb_info & (ACB_WSTRUST|ACB_SVRTRUST|ACB_DOMTRUST)) { - se_priv_copy( &se_rights, &se_machine_account ); + + if ( (acb_info & ACB_WSTRUST) == ACB_WSTRUST ) + { pstrcpy(add_script, lp_addmachine_script()); - } - else { - se_priv_copy( &se_rights, &se_add_users ); + se_priv_copy( &se_rights, &se_machine_account ); + can_add_account = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); + } + else if ( (acb_info & ACB_WSTRUST) == ACB_NORMAL ) + { pstrcpy(add_script, lp_adduser_script()); + se_priv_copy( &se_rights, &se_add_users ); + can_add_account = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); + } + else if ( ((acb_info & ACB_SVRTRUST) == ACB_SVRTRUST) || ((acb_info & ACB_DOMTRUST) == ACB_DOMTRUST) ) + { + pstrcpy(add_script, lp_addmachine_script()); + /* only Domain Admins can add a BDC or domain trust */ + se_priv_copy( &se_rights, &se_priv_none ); + can_add_account = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); } - - can_add_account = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); - + DEBUG(5, ("_samr_create_user: %s can add this account : %s\n", p->pipe_user_name, can_add_account ? "True":"False" )); -- cgit From 8f87dcdcdab52efb0ef907ede71c0920a25b0d7b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 3 Feb 2005 16:23:49 +0000 Subject: r5205: more fixups for BUG 2291 (This used to be commit 62e7cc7c3b2fe5187c99e0a1491843579ab997e7) --- source3/rpc_server/srv_samr_nt.c | 57 +++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 27 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 83da810444..1d4569e39f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2260,24 +2260,26 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA /* determine which user right we need to check based on the acb_info */ - if ( (acb_info & ACB_WSTRUST) == ACB_WSTRUST ) + if ( acb_info & ACB_WSTRUST ) { pstrcpy(add_script, lp_addmachine_script()); se_priv_copy( &se_rights, &se_machine_account ); can_add_account = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); } - else if ( (acb_info & ACB_WSTRUST) == ACB_NORMAL ) + else if ( acb_info & ACB_NORMAL ) { pstrcpy(add_script, lp_adduser_script()); se_priv_copy( &se_rights, &se_add_users ); can_add_account = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); } - else if ( ((acb_info & ACB_SVRTRUST) == ACB_SVRTRUST) || ((acb_info & ACB_DOMTRUST) == ACB_DOMTRUST) ) + else if ( acb_info & (ACB_SVRTRUST|ACB_DOMTRUST) ) { pstrcpy(add_script, lp_addmachine_script()); - /* only Domain Admins can add a BDC or domain trust */ - se_priv_copy( &se_rights, &se_priv_none ); - can_add_account = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); + if ( lp_enable_privileges() ) { + /* only Domain Admins can add a BDC or domain trust */ + se_priv_copy( &se_rights, &se_priv_none ); + can_add_account = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); + } } DEBUG(5, ("_samr_create_user: %s can add this account : %s\n", @@ -2996,7 +2998,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE uint32 acc_required; BOOL ret; BOOL has_enough_rights; - SE_PRIV se_rights; + uint32 acb_info; DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); @@ -3033,16 +3035,18 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE } /* deal with machine password changes differently from userinfo changes */ - - if ( pdb_get_acct_ctrl(pwd) & ACB_WSTRUST ) - se_priv_copy( &se_rights, &se_machine_account ); - else - se_priv_copy( &se_rights, &se_add_users ); - /* check to see if we have the sufficient rights */ - has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); - + acb_info = pdb_get_acct_ctrl(pwd); + if ( acb_info & ACB_WSTRUST ) + has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_machine_account); + else if ( acb_info & ACB_NORMAL ) + has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users ); + else if ( acb_info & (ACB_SVRTRUST|ACB_DOMTRUST) ) { + if ( lp_enable_privileges() ) + has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); + } + DEBUG(5, ("_samr_set_userinfo: %s does%s possess sufficient rights\n", p->pipe_user_name, has_enough_rights ? "" : " not")); @@ -3135,7 +3139,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ uint32 acc_required; BOOL ret; BOOL has_enough_rights; - SE_PRIV se_rights; + uint32 acb_info; DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__)); @@ -3173,17 +3177,16 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ return NT_STATUS_NO_SUCH_USER; } - /* deal with machine password changes differently from userinfo changes */ - - if ( pdb_get_acct_ctrl(pwd) & ACB_WSTRUST ) - se_priv_copy( &se_rights, &se_machine_account ); - else - se_priv_copy( &se_rights, &se_add_users ); - - /* check to see if we have the sufficient rights */ - - has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); - + acb_info = pdb_get_acct_ctrl(pwd); + if ( acb_info & ACB_WSTRUST ) + has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_machine_account); + else if ( acb_info & ACB_NORMAL ) + has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users ); + else if ( acb_info & (ACB_SVRTRUST|ACB_DOMTRUST) ) { + if ( lp_enable_privileges() ) + has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); + } + DEBUG(5, ("_samr_set_userinfo: %s does%s possess sufficient rights\n", p->pipe_user_name, has_enough_rights ? "" : " not")); -- cgit From d602fc7bc156dd18637cfbc7b57f793718ff8e56 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 6 Feb 2005 01:12:15 +0000 Subject: r5246: We can't use a pointer to struct lsa_info until is has been initialised. Fix for bugzilla #2315. Can the privileges dude(s) please verify this? (This used to be commit bc4f884104c04f7c9ab7d370586115a9328ce9b1) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index da00d2d6c4..5b92b65edd 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -968,7 +968,7 @@ NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CR if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) return NT_STATUS_ACCESS_DENIED; - if ( is_privileged_sid( &info->sid ) ) + if ( is_privileged_sid( &q_u->sid.sid ) ) return NT_STATUS_OBJECT_NAME_COLLISION; /* associate the user/group SID with the (unique) handle. */ -- cgit From e98f56373bca0efc200bc3a4263477e1790a746b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Feb 2005 14:14:44 +0000 Subject: r5262: Fix server_role in the samr_query_dom_info calls. When we are a BDC we should not say we are a PDC. Guenther (This used to be commit 6cdf3b97de2c28ac92f972621b0ce04c1c80cea5) --- source3/rpc_server/srv_samr_nt.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1d4569e39f..4e7d239b2c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2072,6 +2072,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA NTTIME nt_logout; uint32 account_policy_temp; + uint32 server_role; uint32 num_users=0, num_groups=0, num_aliases=0; @@ -2136,9 +2137,13 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA unix_to_nt_time_abs(&nt_logout, u_logout); + server_role = ROLE_DOMAIN_PDC; + if (lp_server_role() == ROLE_DOMAIN_BDC) + server_role = ROLE_DOMAIN_BDC; + /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, "", lp_workgroup(), global_myname(), (uint32) time(NULL), - num_users, num_groups, num_aliases, nt_logout); + init_unk_info2(&ctr->info.inf2, lp_serverstring(), lp_workgroup(), global_myname(), time(NULL), + num_users, num_groups, num_aliases, nt_logout, server_role); break; case 0x03: pdb_get_account_policy(AP_TIME_TO_LOGOUT, (unsigned int *)&u_logout); @@ -2153,7 +2158,11 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA init_unk_info6(&ctr->info.inf6); break; case 0x07: - init_unk_info7(&ctr->info.inf7); + server_role = ROLE_DOMAIN_PDC; + if (lp_server_role() == ROLE_DOMAIN_BDC) + server_role = ROLE_DOMAIN_BDC; + + init_unk_info7(&ctr->info.inf7, server_role); break; case 0x08: init_unk_info8(&ctr->info.inf8, (uint32) time(NULL)); @@ -4546,6 +4555,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW uint32 num_users=0, num_groups=0, num_aliases=0; uint32 account_policy_temp; + uint32 server_role; if ((ctr = TALLOC_ZERO_P(p->mem_ctx, SAM_UNK_CTR)) == NULL) return NT_STATUS_NO_MEMORY; @@ -4607,9 +4617,13 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW unix_to_nt_time_abs(&nt_logout, u_logout); + server_role = ROLE_DOMAIN_PDC; + if (lp_server_role() == ROLE_DOMAIN_BDC) + server_role = ROLE_DOMAIN_BDC; + /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, "", lp_workgroup(), global_myname(), (uint32) time(NULL), - num_users, num_groups, num_aliases, nt_logout); + init_unk_info2(&ctr->info.inf2, lp_serverstring(), lp_workgroup(), global_myname(), time(NULL), + num_users, num_groups, num_aliases, nt_logout, server_role); break; case 0x03: pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); @@ -4626,7 +4640,10 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW init_unk_info6(&ctr->info.inf6); break; case 0x07: - init_unk_info7(&ctr->info.inf7); + server_role = ROLE_DOMAIN_PDC; + if (lp_server_role() == ROLE_DOMAIN_BDC) + server_role = ROLE_DOMAIN_BDC; + init_unk_info7(&ctr->info.inf7, server_role); break; case 0x08: init_unk_info8(&ctr->info.inf8, (uint32) time(NULL)); -- cgit From 5f54cc9bd3fa76e62926de0670f832f7b0e3739d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Feb 2005 18:20:06 +0000 Subject: r5264: Log with loglevel 0 when account-administration scripts fail. Guenther (This used to be commit 3d391ef149639750db376b05528a27422f8a3321) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 4e7d239b2c..9c8a35045f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2305,7 +2305,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA all_string_sub(add_script, "%u", account, sizeof(add_script)); add_ret = smbrun(add_script,NULL); - DEBUG(3,("_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); + DEBUG(add_ret ? 0 : 3,("_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); } else /* no add user script -- ask winbindd to do it */ { @@ -3813,7 +3813,7 @@ static int smb_delete_user(const char *unix_user) return -1; all_string_sub(del_script, "%u", unix_user, sizeof(del_script)); ret = smbrun(del_script,NULL); - DEBUG(3,("smb_delete_user: Running the command `%s' gave %d\n",del_script,ret)); + DEBUG(ret ? 0 : 3,("smb_delete_user: Running the command `%s' gave %d\n",del_script,ret)); return ret; } -- cgit From 6c84ecb55657ae28eb739a72164f6d7251dc627f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 12 Feb 2005 00:51:31 +0000 Subject: r5349: After talking with Jerry, reverted the addition of account policies to passdb in 3_0 (they are still in trunk). Guenther (This used to be commit fdf9bdbbac1d8d4f3b3e1fc7e49c1e659b9301b1) --- source3/rpc_server/srv_reg_nt.c | 2 +- source3/rpc_server/srv_samr.c | 1 + source3/rpc_server/srv_samr_nt.c | 58 ++++++++++++++++++++-------------------- 3 files changed, 31 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 3a5c965820..c11e0d59a0 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -380,7 +380,7 @@ WERROR _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) return WERR_NOMEM; } - if (!pdb_get_account_policy(AP_REFUSE_MACHINE_PW_CHANGE, &dwValue)) + if (!account_policy_get(AP_REFUSE_MACHINE_PW_CHANGE, &dwValue)) dwValue = 0; regval_ctr_addvalue(®vals, "RefusePasswordChange", REG_DWORD, diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 971f5ed40c..ffb7882e11 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -785,6 +785,7 @@ static BOOL api_samr_set_userinfo(pipes_struct *p) if (!samr_io_q_set_userinfo("", &q_u, data, 0)) { DEBUG(0,("api_samr_set_userinfo: Unable to unmarshall SAMR_Q_SET_USERINFO.\n")); /* Fix for W2K SP2 */ + /* what is that status-code ? - gd */ if (q_u.switch_value == 0x1a) { setup_fault_pdu(p, NT_STATUS(0x1c000006)); return True; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9c8a35045f..291d8713d5 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2092,19 +2092,19 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA switch (q_u->switch_value) { case 0x01: - pdb_get_account_policy(AP_MIN_PASSWORD_LEN, &account_policy_temp); + account_policy_get(AP_MIN_PASSWORD_LEN, &account_policy_temp); min_pass_len = account_policy_temp; - pdb_get_account_policy(AP_PASSWORD_HISTORY, &account_policy_temp); + account_policy_get(AP_PASSWORD_HISTORY, &account_policy_temp); pass_hist = account_policy_temp; - pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); + account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); flag = account_policy_temp; - pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &account_policy_temp); + account_policy_get(AP_MAX_PASSWORD_AGE, &account_policy_temp); u_expire = account_policy_temp; - pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &account_policy_temp); + account_policy_get(AP_MIN_PASSWORD_AGE, &account_policy_temp); u_min_age = account_policy_temp; unix_to_nt_time_abs(&nt_expire, u_expire); @@ -2132,7 +2132,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA num_groups=info->disp_info.num_group_account; free_samr_db(info); - pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); + account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); u_logout = account_policy_temp; unix_to_nt_time_abs(&nt_logout, u_logout); @@ -2146,7 +2146,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA num_users, num_groups, num_aliases, nt_logout, server_role); break; case 0x03: - pdb_get_account_policy(AP_TIME_TO_LOGOUT, (unsigned int *)&u_logout); + account_policy_get(AP_TIME_TO_LOGOUT, (unsigned int *)&u_logout); unix_to_nt_time_abs(&nt_logout, u_logout); init_unk_info3(&ctr->info.inf3, nt_logout); @@ -2168,15 +2168,15 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA init_unk_info8(&ctr->info.inf8, (uint32) time(NULL)); break; case 0x0c: - pdb_get_account_policy(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); + account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); u_lock_duration = account_policy_temp; if (u_lock_duration != -1) u_lock_duration *= 60; - pdb_get_account_policy(AP_RESET_COUNT_TIME, &account_policy_temp); + account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp); u_reset_time = account_policy_temp * 60; - pdb_get_account_policy(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); + account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); lockout = account_policy_temp; unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); @@ -4572,19 +4572,19 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW switch (q_u->switch_value) { case 0x01: - pdb_get_account_policy(AP_MIN_PASSWORD_LEN, &account_policy_temp); + account_policy_get(AP_MIN_PASSWORD_LEN, &account_policy_temp); min_pass_len = account_policy_temp; - pdb_get_account_policy(AP_PASSWORD_HISTORY, &account_policy_temp); + account_policy_get(AP_PASSWORD_HISTORY, &account_policy_temp); pass_hist = account_policy_temp; - pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); + account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); flag = account_policy_temp; - pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &account_policy_temp); + account_policy_get(AP_MAX_PASSWORD_AGE, &account_policy_temp); u_expire = account_policy_temp; - pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &account_policy_temp); + account_policy_get(AP_MIN_PASSWORD_AGE, &account_policy_temp); u_min_age = account_policy_temp; unix_to_nt_time_abs(&nt_expire, u_expire); @@ -4612,7 +4612,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW num_groups=info->disp_info.num_group_account; free_samr_db(info); - pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); + account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); u_logout = account_policy_temp; unix_to_nt_time_abs(&nt_logout, u_logout); @@ -4626,7 +4626,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW num_users, num_groups, num_aliases, nt_logout, server_role); break; case 0x03: - pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); + account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); u_logout = account_policy_temp; unix_to_nt_time_abs(&nt_logout, u_logout); @@ -4649,15 +4649,15 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW init_unk_info8(&ctr->info.inf8, (uint32) time(NULL)); break; case 0x0c: - pdb_get_account_policy(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); + account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); u_lock_duration = account_policy_temp; if (u_lock_duration != -1) u_lock_duration *= 60; - pdb_get_account_policy(AP_RESET_COUNT_TIME, &account_policy_temp); + account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp); u_reset_time = account_policy_temp * 60; - pdb_get_account_policy(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); + account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); lockout = account_policy_temp; unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); @@ -4701,17 +4701,17 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R u_expire=nt_time_to_unix_abs(&q_u->ctr->info.inf1.expire); u_min_age=nt_time_to_unix_abs(&q_u->ctr->info.inf1.min_passwordage); - pdb_set_account_policy(AP_MIN_PASSWORD_LEN, (uint32)q_u->ctr->info.inf1.min_length_password); - pdb_set_account_policy(AP_PASSWORD_HISTORY, (uint32)q_u->ctr->info.inf1.password_history); - pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)q_u->ctr->info.inf1.flag); - pdb_set_account_policy(AP_MAX_PASSWORD_AGE, (int)u_expire); - pdb_set_account_policy(AP_MIN_PASSWORD_AGE, (int)u_min_age); + account_policy_set(AP_MIN_PASSWORD_LEN, (uint32)q_u->ctr->info.inf1.min_length_password); + account_policy_set(AP_PASSWORD_HISTORY, (uint32)q_u->ctr->info.inf1.password_history); + account_policy_set(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)q_u->ctr->info.inf1.flag); + account_policy_set(AP_MAX_PASSWORD_AGE, (int)u_expire); + account_policy_set(AP_MIN_PASSWORD_AGE, (int)u_min_age); break; case 0x02: break; case 0x03: u_logout=nt_time_to_unix_abs(&q_u->ctr->info.inf3.logout); - pdb_set_account_policy(AP_TIME_TO_LOGOUT, (int)u_logout); + account_policy_set(AP_TIME_TO_LOGOUT, (int)u_logout); break; case 0x05: break; @@ -4726,9 +4726,9 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R u_reset_time=nt_time_to_unix_abs(&q_u->ctr->info.inf12.reset_count)/60; - pdb_set_account_policy(AP_LOCK_ACCOUNT_DURATION, (int)u_lock_duration); - pdb_set_account_policy(AP_RESET_COUNT_TIME, (int)u_reset_time); - pdb_set_account_policy(AP_BAD_ATTEMPT_LOCKOUT, (uint32)q_u->ctr->info.inf12.bad_attempt_lockout); + account_policy_set(AP_LOCK_ACCOUNT_DURATION, (int)u_lock_duration); + account_policy_set(AP_RESET_COUNT_TIME, (int)u_reset_time); + account_policy_set(AP_BAD_ATTEMPT_LOCKOUT, (uint32)q_u->ctr->info.inf12.bad_attempt_lockout); break; default: return NT_STATUS_INVALID_INFO_CLASS; -- cgit From 9e52e989ab46bf131185c05651dca1799d73f0a3 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 14 Feb 2005 01:13:14 +0000 Subject: r5383: add missing checks to allow root to manage user rights (This used to be commit ead54b14f6b34f087d3affc2853e16bbbaceb7cc) --- source3/rpc_server/srv_lsa_nt.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 5b92b65edd..b4c8e033ff 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1333,6 +1333,7 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R DOM_SID sid; fstring privname; UNISTR2_ARRAY *uni_privnames = &q_u->rights; + struct current_user user; /* find the connection policy handle. */ @@ -1342,8 +1343,12 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + get_current_user( &user, p ); + if ( user.uid != sec_initial_uid() + && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + { return NT_STATUS_ACCESS_DENIED; + } /* according to an NT4 PDC, you can add privileges to SIDs even without call_lsa_create_account() first. And you can use any arbitrary SID. */ @@ -1381,6 +1386,7 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, DOM_SID sid; fstring privname; UNISTR2_ARRAY *uni_privnames = &q_u->rights; + struct current_user user; /* find the connection policy handle. */ @@ -1390,8 +1396,12 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + get_current_user( &user, p ); + if ( user.uid != sec_initial_uid() + && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + { return NT_STATUS_ACCESS_DENIED; + } sid_copy( &sid, &q_u->sid.sid ); -- cgit From 96edc93c2373b67ae78adbbde7a68a68daa263e0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 16 Feb 2005 19:51:16 +0000 Subject: r5419: Fix some unitialized variable warnings (This used to be commit 9004b7897416d142ab9e3bee60c7bda589f94750) --- source3/rpc_server/srv_samr_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 291d8713d5..ec85981cbe 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2221,7 +2221,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA uint32 new_rid = 0; /* check this, when giving away 'add computer to domain' privs */ uint32 des_access = GENERIC_RIGHTS_USER_ALL_ACCESS; - BOOL can_add_account; + BOOL can_add_account = False; SE_PRIV se_rights; /* Get the domain SID stored in the domain policy */ @@ -3006,7 +3006,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE uint32 acc_granted; uint32 acc_required; BOOL ret; - BOOL has_enough_rights; + BOOL has_enough_rights = False; uint32 acb_info; DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); @@ -3147,7 +3147,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ uint32 acc_granted; uint32 acc_required; BOOL ret; - BOOL has_enough_rights; + BOOL has_enough_rights = False; uint32 acb_info; DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__)); -- cgit From 4e617c62c3998fb0a631b068ebdd159e6b6f286c Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Sat, 19 Feb 2005 10:56:40 +0000 Subject: r5458: Generate a sane response to exceeding lookupsids limit. Truncate list to zero and return NT_STATUS_NONE_MAPPED. This does not crash windows and maintains the benefit of not overallocating memory. The previous response of truncating to the MAX limit was not useful because it crashed lsass.exe on windows (bug opened with MS), and it was also misleading the client to believe that a complete answer was received. (This used to be commit c03a93957404663bbd026668fb95d6c253524fe9) --- source3/rpc_server/srv_lsa_nt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index b4c8e033ff..225e5efd54 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -647,8 +647,9 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_ uint32 mapped_count = 0; if (num_entries > MAX_LOOKUP_SIDS) { - num_entries = MAX_LOOKUP_SIDS; - DEBUG(5,("_lsa_lookup_sids: truncating SID lookup list to %d\n", num_entries)); + num_entries = 0; + DEBUG(5,("_lsa_lookup_sids: limit of %d exceeded, truncating SID lookup list to %d\n", MAX_LOOKUP_SIDS, num_entries)); + r_u->status = NT_STATUS_NONE_MAPPED; } ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); -- cgit From 96aaf64fa6279598b1a7ce67f02316c6cdd2a651 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Sat, 19 Feb 2005 11:09:52 +0000 Subject: r5460: Fix "restrict anonymous = 1". If we have schannel connection, we must be validated with a user, so allow it even if pipe itself had an anonymous connection. (This used to be commit 469a649ad7271159960335419fd3ce2633cf2c8b) --- source3/rpc_server/srv_lsa_hnd.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 0f9f239a02..68072b528a 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -252,6 +252,10 @@ BOOL pipe_access_check(pipes_struct *p) if (lp_restrict_anonymous() > 0) { user_struct *user = get_valid_user_struct(p->vuid); + /* schannel, so we must be ok */ + if (p->netsec_auth_validated) + return True; + if (!user) { DEBUG(3, ("invalid vuid %d\n", p->vuid)); return False; -- cgit From a90a58ff221a4469d6e87df655cb2201d68e237b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Feb 2005 13:47:16 +0000 Subject: r5467: Optimize _samr_query_groupmem with LDAP backend for large domains. Could someone else please look at this patch, verifying that I did not break the ldapsam:trusted = False fallback to the old behaviour? It works fine for me, but you never know. You're certainly free to review the new code as well :-) Thanks, Volker (This used to be commit e1c3ca182b299dc65da1fa39aadb69876b5e16b8) --- source3/rpc_server/srv_samr_nt.c | 52 +++++++++++----------------------------- 1 file changed, 14 insertions(+), 38 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ec85981cbe..7a436e23e9 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3434,18 +3434,17 @@ static BOOL get_memberuids(gid_t gid, uid_t **uids, int *num) NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_QUERY_GROUPMEM *r_u) { - int final_num_rids, i; DOM_SID group_sid; fstring group_sid_str; - uid_t *uids; - int num; - gid_t gid; + int i, num_members; uint32 *rid=NULL; uint32 *attr=NULL; uint32 acc_granted; + NTSTATUS result; + /* find the policy handle. open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; @@ -3464,46 +3463,23 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ DEBUG(10, ("lookup on Domain SID\n")); - if (!NT_STATUS_IS_OK(sid_to_gid(&group_sid, &gid))) - return NT_STATUS_NO_SUCH_GROUP; + become_root(); + result = pdb_enum_group_members(p->mem_ctx, &group_sid, + &rid, &num_members); + unbecome_root(); - if(!get_memberuids(gid, &uids, &num)) - return NT_STATUS_NO_SUCH_GROUP; + if (!NT_STATUS_IS_OK(result)) + return result; - rid=TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num); - attr=TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num); + attr=TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_members); - if (num!=0 && (rid==NULL || attr==NULL)) + if ((num_members!=0) && (rid==NULL)) return NT_STATUS_NO_MEMORY; - final_num_rids = 0; - - for (i=0; i Date: Sun, 20 Feb 2005 14:26:58 +0000 Subject: r5469: Fix error codes of samr_lookup_rids: There's also STATUS_SOME_UNMAPPED. Thanks, Volker (This used to be commit 43dcf0f5cb5dc2dd37ab3cdc2905970d9cc50ba4) --- source3/rpc_server/srv_samr_nt.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7a436e23e9..1881bc6e48 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1510,7 +1510,9 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK int num_rids = q_u->num_rids1; int i; uint32 acc_granted; - + BOOL have_mapped = False; + BOOL have_unmapped = False; + r_u->status = NT_STATUS_OK; DEBUG(5,("_samr_lookup_rids: %d\n", __LINE__)); @@ -1529,7 +1531,11 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK return NT_STATUS_NO_MEMORY; } - r_u->status = NT_STATUS_NONE_MAPPED; + if (!sid_equal(&pol_sid, get_global_sam_sid())) { + /* TODO: Sooner or later we need to look up BUILTIN rids as + * well. -- vl */ + goto done; + } become_root(); /* lookup_sid can require root privs */ @@ -1542,21 +1548,30 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK group_attrs[i] = SID_NAME_UNKNOWN; *group_names[i] = '\0'; - if (sid_equal(&pol_sid, get_global_sam_sid())) { - sid_copy(&sid, &pol_sid); - sid_append_rid(&sid, q_u->rid[i]); + sid_copy(&sid, &pol_sid); + sid_append_rid(&sid, q_u->rid[i]); - if (lookup_sid(&sid, domname, tmpname, &type)) { - r_u->status = NT_STATUS_OK; - group_attrs[i] = (uint32)type; - fstrcpy(group_names[i],tmpname); - DEBUG(5,("_samr_lookup_rids: %s:%d\n", group_names[i], group_attrs[i])); - } + if (lookup_sid(&sid, domname, tmpname, &type)) { + group_attrs[i] = (uint32)type; + fstrcpy(group_names[i],tmpname); + DEBUG(5,("_samr_lookup_rids: %s:%d\n", group_names[i], + group_attrs[i])); + have_mapped = True; + } else { + have_unmapped = True; } } unbecome_root(); + done: + + r_u->status = NT_STATUS_NONE_MAPPED; + + if (have_mapped) + r_u->status = + have_unmapped ? STATUS_SOME_UNMAPPED : NT_STATUS_OK; + if(!make_samr_lookup_rids(p->mem_ctx, num_rids, group_names, &hdr_name, &uni_name)) return NT_STATUS_NO_MEMORY; -- cgit From dc0ec444833be678c5f8cdcf861a46ebe3d2955c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Feb 2005 15:15:33 +0000 Subject: r5471: In cli_samr_lookup_rids, flags is not a flags but an array size. W2k3 rejects everything but 1000 here, so there's no point in exposing that to the caller. Thanks, Volker (This used to be commit 03ec1bd9e54b065c0494bc57a3d78ac0ae28e234) --- source3/rpc_server/srv_samr_nt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1881bc6e48..8a10fa6d2d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1521,9 +1521,10 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; - if (num_rids > MAX_SAM_ENTRIES) { - num_rids = MAX_SAM_ENTRIES; - DEBUG(5,("_samr_lookup_rids: truncating entries to %d\n", num_rids)); + if (num_rids > 1000) { + DEBUG(0, ("Got asked for %d rids (more than 1000) -- according " + "to samba4 idl this is not possible\n", num_rids)); + return NT_STATUS_UNSUCCESSFUL; } if (num_rids) { -- cgit From 180fa12026caef8f22154e0e7c60f9043b5588e2 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Sat, 26 Feb 2005 15:26:55 +0000 Subject: r5580: Fix "net rpc trustdom add". Much closer to what windows does. Also stop referencing unknown_6 from sam, because it's just fixed at 1260, the max len of LOGON_HRS. Need to go in and mark it as "remove me" from passdb. (This used to be commit ffac752875938d510446ebbeba6fc983f65cda1e) --- source3/rpc_server/srv_samr_util.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index dd12a438ca..6797730be9 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -268,12 +268,6 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) if (!strequal(old, new)) { pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); } - - /* This is max logon hours */ - DEBUG(10,("INFO_21 UNKNOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); - if (from->unknown_6 != pdb_get_unknown_6(to)) { - pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); - } } if (from->fields_present & ACCT_BAD_PWD_COUNT) { @@ -296,8 +290,6 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) } DEBUG(10,("INFO_21 PADDING_2: %02X\n",from->padding2)); - - DEBUG(10,("INFO_21 PADDING_4: %08X\n",from->padding4)); } @@ -499,11 +491,6 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) /* Fix me: only update if it changes --metze */ pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); - /* This is max logon hours */ - DEBUG(10,("INFO_23 UNKOWN_6: %08X -> %08X\n",pdb_get_unknown_6(to),from->unknown_6)); - if (from->unknown_6 != pdb_get_unknown_6(to)) { - pdb_set_unknown_6(to, from->unknown_6, PDB_CHANGED); - } } if (from->fields_present & ACCT_BAD_PWD_COUNT) { @@ -526,6 +513,4 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) } DEBUG(10,("INFO_23 PADDING_2: %02X\n",from->padding2)); - - DEBUG(10,("INFO_23 PADDING_4: %08X\n",from->padding4)); } -- cgit From 5ba59da467eef5cbc6506d45b0a6abb1777f2346 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 1 Mar 2005 17:28:25 +0000 Subject: r5605: only display the publish check box on printer if we are a member of an AD domain clean up some hardcoded constands with the REG_XXX constant. (This used to be commit a1d0be740d9ea8c9ea8c04950da826dd84bbc51b) --- source3/rpc_server/srv_spoolss_nt.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ed7a544d72..ffeeb0af9a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2310,7 +2310,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint DEBUG(8,("getprinterdata_printer_server:%s\n", value)); if (!StrCaseCmp(value, "W3SvcInstalled")) { - *type = 0x4; + *type = REG_DWORD; if((*data = (uint8 *)TALLOC_ZERO(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; *needed = 0x4; @@ -2318,7 +2318,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint } if (!StrCaseCmp(value, "BeepEnabled")) { - *type = 0x4; + *type = REG_DWORD; if((*data = (uint8 *)TALLOC(ctx, 4*sizeof(uint8) )) == NULL) return WERR_NOMEM; SIVAL(*data, 0, 0x00); @@ -2327,7 +2327,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint } if (!StrCaseCmp(value, "EventLog")) { - *type = 0x4; + *type = REG_DWORD; if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL) return WERR_NOMEM; /* formally was 0x1b */ @@ -2337,7 +2337,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint } if (!StrCaseCmp(value, "NetPopup")) { - *type = 0x4; + *type = REG_DWORD; if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL) return WERR_NOMEM; SIVAL(*data, 0, 0x00); @@ -2346,7 +2346,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint } if (!StrCaseCmp(value, "MajorVersion")) { - *type = 0x4; + *type = REG_DWORD; if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL) return WERR_NOMEM; @@ -2365,7 +2365,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint } if (!StrCaseCmp(value, "MinorVersion")) { - *type = 0x4; + *type = REG_DWORD; if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL) return WERR_NOMEM; SIVAL(*data, 0, 0); @@ -2381,7 +2381,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint * extra unicode string = e.g. "Service Pack 3" */ if (!StrCaseCmp(value, "OSVersion")) { - *type = 0x3; + *type = REG_BINARY; *needed = 0x114; if((*data = (uint8 *)TALLOC(ctx, *needed)) == NULL) @@ -2401,7 +2401,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "DefaultSpoolDirectory")) { const char *string="C:\\PRINTERS"; - *type = 0x1; + *type = REG_SZ; *needed = 2*(strlen(string)+1); if((*data = (uint8 *)TALLOC(ctx, (*needed > in_size) ? *needed:in_size )) == NULL) return WERR_NOMEM; @@ -2417,7 +2417,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "Architecture")) { const char *string="Windows NT x86"; - *type = 0x1; + *type = REG_SZ; *needed = 2*(strlen(string)+1); if((*data = (uint8 *)TALLOC(ctx, (*needed > in_size) ? *needed:in_size )) == NULL) return WERR_NOMEM; @@ -2430,10 +2430,18 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint } if (!StrCaseCmp(value, "DsPresent")) { - *type = 0x4; + *type = REG_DWORD; if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL) return WERR_NOMEM; - SIVAL(*data, 0, 0x01); + + /* only show the publish check box if we are a + memeber of a AD domain */ + + if ( lp_security() == SEC_ADS ) + SIVAL(*data, 0, 0x01); + else + SIVAL(*data, 0, 0x00); + *needed = 0x4; return WERR_OK; } @@ -2443,7 +2451,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!get_mydnsfullname(hostname)) return WERR_BADFILE; - *type = 0x1; + *type = REG_SZ; *needed = 2*(strlen(hostname)+1); if((*data = (uint8 *)TALLOC(ctx, (*needed > in_size) ? *needed:in_size )) == NULL) return WERR_NOMEM; -- cgit From 140752fd35bd5701b3078abf695f811d933fe893 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 3 Mar 2005 16:52:44 +0000 Subject: r5647: Caches are good for performance, but you get a consistency problem. Fix bug # 2401. Volker (This used to be commit eb4ef94f244d28fe531d0b9f724a66ed3834b687) --- source3/rpc_server/srv_samr_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 8a10fa6d2d..139960f661 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2335,6 +2335,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA /* implicit call to getpwnam() next. we have a valid SID coming out of this call */ + flush_pwnam_cache(); nt_status = pdb_init_sam_new(&sam_pass, account, new_rid); /* this code is order such that we have no unnecessary retuns @@ -3805,6 +3806,7 @@ static int smb_delete_user(const char *unix_user) return -1; all_string_sub(del_script, "%u", unix_user, sizeof(del_script)); ret = smbrun(del_script,NULL); + flush_pwnam_cache(); DEBUG(ret ? 0 : 3,("smb_delete_user: Running the command `%s' gave %d\n",del_script,ret)); return ret; -- cgit From 66df8431ec092c4e629fc07e8e5a242ff3821b2d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 10 Mar 2005 18:50:47 +0000 Subject: r5726: merge LsaLookupPrivValue() code from trunk (This used to be commit 277203b5356af58ce62eb4eec0db2eccadeeffd6) --- source3/rpc_server/srv_lsa.c | 40 ++++++++++++++++++++++++++++++++++++- source3/rpc_server/srv_lsa_nt.c | 44 +++++++++++++++++++++++++++++++++++------ 2 files changed, 77 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index e3c7832aac..dbd5d8c0bf 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -734,6 +734,39 @@ static BOOL api_lsa_enum_acct_rights(pipes_struct *p) return True; } +/*************************************************************************** + api_lsa_lookup_priv_value + ***************************************************************************/ + +static BOOL api_lsa_lookup_priv_value(pipes_struct *p) +{ + LSA_Q_LOOKUP_PRIV_VALUE q_u; + LSA_R_LOOKUP_PRIV_VALUE r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_lookup_priv_value("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_lookup_priv_value: failed to unmarshall LSA_Q_LOOKUP_PRIV_VALUE .\n")); + return False; + } + + r_u.status = _lsa_lookup_priv_value(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_lookup_priv_value("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_lookup_priv_value: Failed to marshall LSA_R_LOOKUP_PRIV_VALUE.\n")); + return False; + } + + return True; +} + +#if 0 /* AD DC work in ongoing in Samba 4 */ + /*************************************************************************** api_lsa_query_info2 ***************************************************************************/ @@ -763,7 +796,7 @@ static BOOL api_lsa_query_info2(pipes_struct *p) return True; } - +#endif /* AD DC work in ongoing in Samba 4 */ /*************************************************************************** \PIPE\ntlsa commands @@ -794,15 +827,19 @@ static struct api_struct api_lsa_cmds[] = { "LSA_REMOVEACCTRIGHTS", LSA_REMOVEACCTRIGHTS, api_lsa_remove_acct_rights }, { "LSA_ENUMACCTRIGHTS" , LSA_ENUMACCTRIGHTS , api_lsa_enum_acct_rights }, { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, + { "LSA_LOOKUPPRIVVALUE" , LSA_LOOKUPPRIVVALUE , api_lsa_lookup_priv_value } +#if 0 /* AD DC work in ongoing in Samba 4 */ /* be careful of the adding of new RPC's. See commentrs below about ADS DC capabilities */ { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 } +#endif /* AD DC work in ongoing in Samba 4 */ }; static int count_fns(void) { int funcs = sizeof(api_lsa_cmds) / sizeof(struct api_struct); +#if 0 /* AD DC work is on going in Samba 4 */ /* * NOTE: Certain calls can not be enabled if we aren't an ADS DC. Make sure * these calls are always last and that you decrement by the amount of calls @@ -811,6 +848,7 @@ static int count_fns(void) if (!(SEC_ADS == lp_security() && ROLE_DOMAIN_PDC == lp_server_role())) { funcs -= 1; } +#endif /* AD DC work in ongoing in Samba 4 */ return funcs; } diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 225e5efd54..7ea35a91fa 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -8,6 +8,7 @@ * Copyright (C) Rafal Szczesniak 2002, * Copyright (C) Jim McDonough 2002, * Copyright (C) Simo Sorce 2003. + * Copyright (C) Gerald (Jerry) Carter 2005. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -345,6 +346,8 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s return NT_STATUS_OK; } +#if 0 /* AD DC work in ongoing in Samba 4 */ + /*************************************************************************** Init_dns_dom_info. ***************************************************************************/ @@ -384,6 +387,8 @@ static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, init_dom_sid2(&r_l->dom_sid, dom_sid); } } +#endif /* AD DC work in ongoing in Samba 4 */ + /*************************************************************************** _lsa_open_policy2. @@ -776,9 +781,6 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV DEBUG(10,("_lsa_enum_privs: enum_context:%d total entries:%d\n", enum_context, num_privs)); - if ( !(entries = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_PRIV_ENTRY, num_privs + 1))) - return NT_STATUS_NO_MEMORY; - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) return NT_STATUS_INVALID_HANDLE; @@ -791,7 +793,6 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV if ( !(entries = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_PRIV_ENTRY, num_privs )) ) return NT_STATUS_NO_MEMORY; - for (i = 0; i < num_privs; i++) { if( i < enum_context) { init_unistr2(&entries[i].name, NULL, UNI_FLAGS_NONE); @@ -1143,7 +1144,7 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u /* check to see if the pipe_user is root or a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - + get_current_user( &user, p ); if ( user.uid != sec_initial_uid() && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) @@ -1184,7 +1185,7 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP /* check to see if the pipe_user is root or a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - + get_current_user( &user, p ); if ( user.uid != sec_initial_uid() && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) @@ -1261,6 +1262,8 @@ NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUER return r_u->status; } +#if 0 /* AD DC work in ongoing in Samba 4 */ + /*************************************************************************** ***************************************************************************/ @@ -1323,6 +1326,7 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I return r_u->status; } +#endif /* AD DC work in ongoing in Samba 4 */ /*************************************************************************** ***************************************************************************/ @@ -1474,3 +1478,31 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA } +NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, LSA_R_LOOKUP_PRIV_VALUE *r_u) +{ + struct lsa_info *info = NULL; + fstring name; + LUID_ATTR priv_luid; + SE_PRIV mask; + + /* find the connection policy handle. */ + + if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + return NT_STATUS_INVALID_HANDLE; + + unistr2_to_ascii(name, &q_u->privname.unistring, sizeof(name)); + + DEBUG(10,("_lsa_priv_get_dispname: name = %s\n", name)); + + if ( !se_priv_from_name( name, &mask ) ) + return NT_STATUS_NO_SUCH_PRIVILEGE; + + priv_luid = get_privilege_luid( &mask ); + + r_u->luid.low = priv_luid.luid.low; + r_u->luid.high = priv_luid.luid.high; + + + return NT_STATUS_OK; +} + -- cgit From 61dfab9f705cb38e552dcec1822974433997543c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 15 Mar 2005 19:43:44 +0000 Subject: r5805: merging spoolss parsing changes from trunk and cleaning up resulting segvs (This used to be commit 25121547caaaed0d60f4db7458570c14e7d21b2a) --- source3/rpc_server/srv_spoolss_nt.c | 908 ++++++++++++++++++++---------------- 1 file changed, 509 insertions(+), 399 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ffeeb0af9a..053290f80f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -644,41 +644,6 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3 return True; } -/**************************************************************************** - Allocate more memory for a BUFFER. -****************************************************************************/ - -static BOOL alloc_buffer_size(NEW_BUFFER *buffer, uint32 buffer_size) -{ - prs_struct *ps; - uint32 extra_space; - uint32 old_offset; - - ps= &buffer->prs; - - /* damn, I'm doing the reverse operation of prs_grow() :) */ - if (buffer_size < prs_data_size(ps)) - extra_space=0; - else - extra_space = buffer_size - prs_data_size(ps); - - /* - * save the offset and move to the end of the buffer - * prs_grow() checks the extra_space against the offset - */ - old_offset=prs_offset(ps); - prs_set_offset(ps, prs_data_size(ps)); - - if (!prs_grow(ps, extra_space)) - return False; - - prs_set_offset(ps, old_offset); - - buffer->string_at_end=prs_data_size(ps); - - return True; -} - /*************************************************************************** check to see if the client motify handle is monitoring the notification given by (notify_type, notify_field). @@ -4121,7 +4086,7 @@ static void free_dev_mode(DEVICEMODE *dev) if (dev == NULL) return; - SAFE_FREE(dev->private); + SAFE_FREE(dev->private); SAFE_FREE(dev); } @@ -4404,13 +4369,14 @@ static BOOL construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *p Spoolss_enumprinters. ********************************************************************/ -static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int snum; int i; int n_services=lp_numservices(); PRINTER_INFO_1 *tp, *printers=NULL; PRINTER_INFO_1 current_prt; + WERROR result = WERR_OK; DEBUG(4,("enum_all_printers_info_1\n")); @@ -4438,29 +4404,36 @@ static WERROR enum_all_printers_info_1(uint32 flags, NEW_BUFFER *buffer, uint32 for (i=0; i<*returned; i++) (*needed) += spoolss_size_printer_info_1(&printers[i]); - if (!alloc_buffer_size(buffer, *needed)) - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; + } /* fill the buffer with the structures */ for (i=0; i<*returned; i++) smb_io_printer_info_1("", buffer, &printers[i], 0); +out: /* clear memory */ + SAFE_FREE(printers); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } - else - return WERR_OK; + if ( !W_ERROR_IS_OK(result) ) + *returned = 0; + + return result; } /******************************************************************** enum_all_printers_info_1_local. *********************************************************************/ -static WERROR enum_all_printers_info_1_local(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enum_all_printers_info_1_local(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { DEBUG(4,("enum_all_printers_info_1_local\n")); @@ -4471,7 +4444,7 @@ static WERROR enum_all_printers_info_1_local(NEW_BUFFER *buffer, uint32 offered, enum_all_printers_info_1_name. *********************************************************************/ -static WERROR enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enum_all_printers_info_1_name(fstring name, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { char *s = name; @@ -4492,13 +4465,14 @@ static WERROR enum_all_printers_info_1_name(fstring name, NEW_BUFFER *buffer, ui enum_all_printers_info_1_remote. *********************************************************************/ -static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enum_all_printers_info_1_remote(fstring name, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTER_INFO_1 *printer; fstring printername; fstring desc; fstring comment; DEBUG(4,("enum_all_printers_info_1_remote\n")); + WERROR result = WERR_OK; /* JFM: currently it's more a place holder than anything else. * In the spooler world there is a notion of server registration. @@ -4525,23 +4499,27 @@ static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, /* check the required size. */ *needed += spoolss_size_printer_info_1(printer); - if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(printer); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the structures */ smb_io_printer_info_1("", buffer, printer, 0); +out: /* clear memory */ SAFE_FREE(printer); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } - else - return WERR_OK; + if ( !W_ERROR_IS_OK(result) ) + *returned = 0; + + return result; } #endif @@ -4550,7 +4528,7 @@ static WERROR enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, enum_all_printers_info_1_network. *********************************************************************/ -static WERROR enum_all_printers_info_1_network(fstring name, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enum_all_printers_info_1_network(fstring name, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { char *s = name; @@ -4579,13 +4557,14 @@ static WERROR enum_all_printers_info_1_network(fstring name, NEW_BUFFER *buffer, * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -static WERROR enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int snum; int i; int n_services=lp_numservices(); PRINTER_INFO_2 *tp, *printers=NULL; PRINTER_INFO_2 current_prt; + WERROR result = WERR_OK; for (snum=0; snum offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the structures */ for (i=0; i<*returned; i++) smb_io_printer_info_2("", buffer, &(printers[i]), 0); +out: /* clear memory */ for (i=0; i<*returned; i++) { free_devmode(printers[i].devmode); } SAFE_FREE(printers); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } - else - return WERR_OK; + if ( !W_ERROR_IS_OK(result) ) + *returned = 0; + + return result; } /******************************************************************** @@ -4641,7 +4621,7 @@ static WERROR enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint3 ********************************************************************/ static WERROR enumprinters_level1( uint32 flags, fstring name, - NEW_BUFFER *buffer, uint32 offered, + RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { /* Not all the flags are equals */ @@ -4668,7 +4648,7 @@ static WERROR enumprinters_level1( uint32 flags, fstring name, ********************************************************************/ static WERROR enumprinters_level2( uint32 flags, fstring servername, - NEW_BUFFER *buffer, uint32 offered, + RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { char *s = servername; @@ -4697,7 +4677,7 @@ static WERROR enumprinters_level2( uint32 flags, fstring servername, ********************************************************************/ static WERROR enumprinters_level5( uint32 flags, fstring servername, - NEW_BUFFER *buffer, uint32 offered, + RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { /* return enum_all_printers_info_5(buffer, offered, needed, returned);*/ @@ -4715,7 +4695,7 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ uint32 flags = q_u->flags; UNISTR2 *servername = &q_u->servername; uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + RPC_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; @@ -4723,8 +4703,11 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ fstring name; /* that's an [in out] buffer */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + + if ( q_u->buffer ) { + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + } DEBUG(4,("_spoolss_enumprinters\n")); @@ -4764,9 +4747,10 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_0(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_0(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_0 *printer=NULL; + WERROR result = WERR_OK; if((printer=SMB_MALLOC_P(PRINTER_INFO_0)) == NULL) return WERR_NOMEM; @@ -4776,30 +4760,34 @@ static WERROR getprinter_level_0(Printer_entry *print_hnd, int snum, NEW_BUFFER /* check the required size. */ *needed += spoolss_size_printer_info_0(printer); - if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(printer); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the structures */ smb_io_printer_info_0("", buffer, printer, 0); +out: /* clear memory */ - SAFE_FREE(printer); - if (*needed > offered) { - return WERR_INSUFFICIENT_BUFFER; - } + SAFE_FREE(printer); - return WERR_OK; + return result; } /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_1(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_1(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_1 *printer=NULL; + WERROR result = WERR_OK; if((printer=SMB_MALLOC_P(PRINTER_INFO_1)) == NULL) return WERR_NOMEM; @@ -4809,30 +4797,33 @@ static WERROR getprinter_level_1(Printer_entry *print_hnd, int snum, NEW_BUFFER /* check the required size. */ *needed += spoolss_size_printer_info_1(printer); - if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(printer); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the structures */ smb_io_printer_info_1("", buffer, printer, 0); +out: /* clear memory */ SAFE_FREE(printer); - if (*needed > offered) { - return WERR_INSUFFICIENT_BUFFER; - } - - return WERR_OK; + return result; } /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_2(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_2(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_2 *printer=NULL; + WERROR result = WERR_OK; if((printer=SMB_MALLOC_P(PRINTER_INFO_2))==NULL) return WERR_NOMEM; @@ -4842,33 +4833,34 @@ static WERROR getprinter_level_2(Printer_entry *print_hnd, int snum, NEW_BUFFER /* check the required size. */ *needed += spoolss_size_printer_info_2(printer); - if (!alloc_buffer_size(buffer, *needed)) { - free_printer_info_2(printer); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; } - /* fill the buffer with the structures */ - if (!smb_io_printer_info_2("", buffer, printer, 0)) { - free_printer_info_2(printer); - return WERR_NOMEM; + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } + + /* fill the buffer with the structures */ + if (!smb_io_printer_info_2("", buffer, printer, 0)) + result = WERR_NOMEM; +out: /* clear memory */ free_printer_info_2(printer); - if (*needed > offered) { - return WERR_INSUFFICIENT_BUFFER; - } - - return WERR_OK; + return result; } /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_3(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_3(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_3 *printer=NULL; + WERROR result = WERR_OK; if (!construct_printer_info_3(print_hnd, &printer, snum)) return WERR_NOMEM; @@ -4876,30 +4868,33 @@ static WERROR getprinter_level_3(Printer_entry *print_hnd, int snum, NEW_BUFFER /* check the required size. */ *needed += spoolss_size_printer_info_3(printer); - if (!alloc_buffer_size(buffer, *needed)) { - free_printer_info_3(printer); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the structures */ smb_io_printer_info_3("", buffer, printer, 0); +out: /* clear memory */ free_printer_info_3(printer); - if (*needed > offered) { - return WERR_INSUFFICIENT_BUFFER; - } - - return WERR_OK; + return result; } /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_4(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_4(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_4 *printer=NULL; + WERROR result = WERR_OK; if((printer=SMB_MALLOC_P(PRINTER_INFO_4))==NULL) return WERR_NOMEM; @@ -4910,30 +4905,33 @@ static WERROR getprinter_level_4(Printer_entry *print_hnd, int snum, NEW_BUFFER /* check the required size. */ *needed += spoolss_size_printer_info_4(printer); - if (!alloc_buffer_size(buffer, *needed)) { - free_printer_info_4(printer); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the structures */ smb_io_printer_info_4("", buffer, printer, 0); +out: /* clear memory */ free_printer_info_4(printer); - if (*needed > offered) { - return WERR_INSUFFICIENT_BUFFER; - } - - return WERR_OK; + return result; } /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_5(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_5(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_5 *printer=NULL; + WERROR result = WERR_OK; if((printer=SMB_MALLOC_P(PRINTER_INFO_5))==NULL) return WERR_NOMEM; @@ -4944,27 +4942,30 @@ static WERROR getprinter_level_5(Printer_entry *print_hnd, int snum, NEW_BUFFER /* check the required size. */ *needed += spoolss_size_printer_info_5(printer); - if (!alloc_buffer_size(buffer, *needed)) { - free_printer_info_5(printer); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the structures */ smb_io_printer_info_5("", buffer, printer, 0); +out: /* clear memory */ free_printer_info_5(printer); - if (*needed > offered) { - return WERR_INSUFFICIENT_BUFFER; - } - - return WERR_OK; + return result; } -static WERROR getprinter_level_7(Printer_entry *print_hnd, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinter_level_7(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_7 *printer=NULL; + WERROR result = WERR_OK; if((printer=SMB_MALLOC_P(PRINTER_INFO_7))==NULL) return WERR_NOMEM; @@ -4975,22 +4976,25 @@ static WERROR getprinter_level_7(Printer_entry *print_hnd, int snum, NEW_BUFFER /* check the required size. */ *needed += spoolss_size_printer_info_7(printer); - if (!alloc_buffer_size(buffer, *needed)) { - free_printer_info_7(printer); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; + } /* fill the buffer with the structures */ smb_io_printer_info_7("", buffer, printer, 0); +out: /* clear memory */ free_printer_info_7(printer); - if (*needed > offered) { - return WERR_INSUFFICIENT_BUFFER; - } - - return WERR_OK; + return result; } /**************************************************************************** @@ -5000,7 +5004,7 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET { POLICY_HND *handle = &q_u->handle; uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + RPC_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); @@ -5008,8 +5012,11 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET int snum; /* that's an [in out] buffer */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + + if ( q_u->buffer ) { + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + } *needed=0; @@ -5433,149 +5440,154 @@ static void free_printer_driver_info_3(DRIVER_INFO_3 *info) static void free_printer_driver_info_6(DRIVER_INFO_6 *info) { SAFE_FREE(info->dependentfiles); - } /**************************************************************************** ****************************************************************************/ -static WERROR getprinterdriver2_level1(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinterdriver2_level1(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_1 *info=NULL; - WERROR status; + WERROR result; if((info=SMB_MALLOC_P(DRIVER_INFO_1)) == NULL) return WERR_NOMEM; - status=construct_printer_driver_info_1(info, snum, servername, architecture, version); - if (!W_ERROR_IS_OK(status)) { - SAFE_FREE(info); - return status; - } + result = construct_printer_driver_info_1(info, snum, servername, architecture, version); + if (!W_ERROR_IS_OK(result)) + goto out; /* check the required size. */ *needed += spoolss_size_printer_driver_info_1(info); - if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(info); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the structures */ smb_io_printer_driver_info_1("", buffer, info, 0); +out: /* clear memory */ SAFE_FREE(info); - if (*needed > offered) - return WERR_INSUFFICIENT_BUFFER; - - return WERR_OK; + return result; } /**************************************************************************** ****************************************************************************/ -static WERROR getprinterdriver2_level2(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinterdriver2_level2(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_2 *info=NULL; - WERROR status; + WERROR result; if((info=SMB_MALLOC_P(DRIVER_INFO_2)) == NULL) return WERR_NOMEM; - status=construct_printer_driver_info_2(info, snum, servername, architecture, version); - if (!W_ERROR_IS_OK(status)) { - SAFE_FREE(info); - return status; - } + result = construct_printer_driver_info_2(info, snum, servername, architecture, version); + if (!W_ERROR_IS_OK(result)) + goto out; /* check the required size. */ *needed += spoolss_size_printer_driver_info_2(info); - if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(info); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the structures */ smb_io_printer_driver_info_2("", buffer, info, 0); +out: /* clear memory */ SAFE_FREE(info); - if (*needed > offered) - return WERR_INSUFFICIENT_BUFFER; - - return WERR_OK; + return result; } /**************************************************************************** ****************************************************************************/ -static WERROR getprinterdriver2_level3(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinterdriver2_level3(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_3 info; - WERROR status; + WERROR result; ZERO_STRUCT(info); - status=construct_printer_driver_info_3(&info, snum, servername, architecture, version); - if (!W_ERROR_IS_OK(status)) { - return status; - } + result = construct_printer_driver_info_3(&info, snum, servername, architecture, version); + if (!W_ERROR_IS_OK(result)) + goto out; /* check the required size. */ *needed += spoolss_size_printer_driver_info_3(&info); - if (!alloc_buffer_size(buffer, *needed)) { - free_printer_driver_info_3(&info); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the structures */ smb_io_printer_driver_info_3("", buffer, &info, 0); +out: free_printer_driver_info_3(&info); - if (*needed > offered) - return WERR_INSUFFICIENT_BUFFER; - - return WERR_OK; + return result; } /**************************************************************************** ****************************************************************************/ -static WERROR getprinterdriver2_level6(fstring servername, fstring architecture, uint32 version, int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinterdriver2_level6(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_6 info; - WERROR status; + WERROR result; ZERO_STRUCT(info); - status=construct_printer_driver_info_6(&info, snum, servername, architecture, version); - if (!W_ERROR_IS_OK(status)) { - return status; - } + result = construct_printer_driver_info_6(&info, snum, servername, architecture, version); + if (!W_ERROR_IS_OK(result)) + goto out; /* check the required size. */ *needed += spoolss_size_printer_driver_info_6(&info); - if (!alloc_buffer_size(buffer, *needed)) { - free_printer_driver_info_6(&info); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the structures */ smb_io_printer_driver_info_6("", buffer, &info, 0); +out: free_printer_driver_info_6(&info); - if (*needed > offered) - return WERR_INSUFFICIENT_BUFFER; - - return WERR_OK; + return result; } /**************************************************************************** @@ -5587,7 +5599,7 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ UNISTR2 *uni_arch = &q_u->architecture; uint32 level = q_u->level; uint32 clientmajorversion = q_u->clientmajorversion; - NEW_BUFFER *buffer = NULL; + RPC_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *servermajorversion = &r_u->servermajorversion; @@ -5599,8 +5611,11 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ int snum; /* that's an [in out] buffer */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + + if ( q_u->buffer ) { + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + } DEBUG(4,("_spoolss_getprinterdriver2\n")); @@ -6389,8 +6404,10 @@ WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) WERROR _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u) { - /* that's an [in out] buffer (despite appearences to the contrary) */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); + /* that's an [in out] buffer */ + + if ( q_u->buffer ) + rpcbuf_move(q_u->buffer, &r_u->buffer); r_u->needed = 0; return WERR_INVALID_PARAM; /* this is what a NT server @@ -6476,11 +6493,12 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, static WERROR enumjobs_level1(print_queue_struct *queue, int snum, NT_PRINTER_INFO_LEVEL *ntprinter, - NEW_BUFFER *buffer, uint32 offered, + RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { JOB_INFO_1 *info; int i; + WERROR result = WERR_OK; info=SMB_MALLOC_ARRAY(JOB_INFO_1,*returned); if (info==NULL) { @@ -6498,24 +6516,28 @@ static WERROR enumjobs_level1(print_queue_struct *queue, int snum, for (i=0; i<*returned; i++) (*needed) += spoolss_size_job_info_1(&info[i]); - if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(info); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the structures */ for (i=0; i<*returned; i++) smb_io_job_info_1("", buffer, &info[i], 0); +out: /* clear memory */ SAFE_FREE(info); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } + if ( !W_ERROR_IS_OK(result) ) + *returned = 0; - return WERR_OK; + return result; } /**************************************************************************** @@ -6524,19 +6546,17 @@ static WERROR enumjobs_level1(print_queue_struct *queue, int snum, static WERROR enumjobs_level2(print_queue_struct *queue, int snum, NT_PRINTER_INFO_LEVEL *ntprinter, - NEW_BUFFER *buffer, uint32 offered, + RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { JOB_INFO_2 *info = NULL; int i; - WERROR result; + WERROR result = WERR_OK; DEVICEMODE *devmode = NULL; - info=SMB_MALLOC_ARRAY(JOB_INFO_2,*returned); - if (info==NULL) { + if ( !(info = SMB_MALLOC_ARRAY(JOB_INFO_2,*returned)) ) { *returned=0; - result = WERR_NOMEM; - goto done; + return WERR_NOMEM; } /* this should not be a failure condition if the devmode is NULL */ @@ -6544,8 +6564,7 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, devmode = construct_dev_mode(snum); for (i=0; i<*returned; i++) - fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter, - devmode); + fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter, devmode); free_a_printer(&ntprinter, 2); SAFE_FREE(queue); @@ -6555,29 +6574,26 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, (*needed) += spoolss_size_job_info_2(&info[i]); if (*needed > offered) { - *returned=0; result = WERR_INSUFFICIENT_BUFFER; - goto done; + goto out; } - if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(info); - result = WERR_INSUFFICIENT_BUFFER; - goto done; + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the structures */ for (i=0; i<*returned; i++) smb_io_job_info_2("", buffer, &info[i], 0); - result = WERR_OK; - - done: - free_a_printer(&ntprinter, 2); +out: free_devmode(devmode); - SAFE_FREE(queue); SAFE_FREE(info); + if ( !W_ERROR_IS_OK(result) ) + *returned = 0; + return result; } @@ -6590,7 +6606,7 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO { POLICY_HND *handle = &q_u->handle; uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + RPC_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; @@ -6601,8 +6617,11 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO print_queue_struct *queue=NULL; /* that's an [in out] buffer */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + + if ( q_u->buffer ) { + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + } DEBUG(4,("_spoolss_enumjobs\n")); @@ -6703,15 +6722,15 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u Enumerates all printer drivers at level 1. ****************************************************************************/ -static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; int ndrivers; uint32 version; fstring *list = NULL; - NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_1 *tdi1, *driver_info_1=NULL; + WERROR result = WERR_OK; *returned=0; @@ -6757,9 +6776,14 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture *needed += spoolss_size_printer_driver_info_1(&driver_info_1[i]); } - if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(driver_info_1); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the driver structures */ @@ -6768,29 +6792,28 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture smb_io_printer_driver_info_1("", buffer, &driver_info_1[i], 0); } +out: SAFE_FREE(driver_info_1); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } + if ( !W_ERROR_IS_OK(result) ) + *returned = 0; - return WERR_OK; + return result; } /**************************************************************************** Enumerates all printer drivers at level 2. ****************************************************************************/ -static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; int ndrivers; uint32 version; fstring *list = NULL; - NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_2 *tdi2, *driver_info_2=NULL; + WERROR result = WERR_OK; *returned=0; @@ -6837,9 +6860,14 @@ static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture *needed += spoolss_size_printer_driver_info_2(&(driver_info_2[i])); } - if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(driver_info_2); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the form structures */ @@ -6848,29 +6876,28 @@ static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture smb_io_printer_driver_info_2("", buffer, &(driver_info_2[i]), 0); } +out: SAFE_FREE(driver_info_2); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } + if ( !W_ERROR_IS_OK(result) ) + *returned = 0; - return WERR_OK; + return result; } /**************************************************************************** Enumerates all printer drivers at level 3. ****************************************************************************/ -static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture, NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; int ndrivers; uint32 version; fstring *list = NULL; - NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_3 *tdi3, *driver_info_3=NULL; + WERROR result = WERR_OK; *returned=0; @@ -6917,28 +6944,32 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture *needed += spoolss_size_printer_driver_info_3(&driver_info_3[i]); } - if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(driver_info_3); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; } - + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; + } + /* fill the buffer with the driver structures */ for (i=0; i<*returned; i++) { DEBUGADD(6,("adding driver [%d] to buffer\n",i)); smb_io_printer_driver_info_3("", buffer, &driver_info_3[i], 0); } +out: for (i=0; i<*returned; i++) SAFE_FREE(driver_info_3[i].dependentfiles); - + SAFE_FREE(driver_info_3); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } + if ( !W_ERROR_IS_OK(result) ) + *returned = 0; - return WERR_OK; + return result; } /**************************************************************************** @@ -6948,22 +6979,25 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, SPOOL_R_ENUMPRINTERDRIVERS *r_u) { uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + RPC_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; - fstring *list = NULL; fstring servername; fstring architecture; /* that's an [in out] buffer */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + + if ( q_u->buffer ) { + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + } DEBUG(4,("_spoolss_enumprinterdrivers\n")); - *needed=0; - *returned=0; + + *needed = 0; + *returned = 0; unistr2_to_ascii(architecture, &q_u->environment, sizeof(architecture)-1); unistr2_to_ascii(servername, &q_u->name, sizeof(servername)-1); @@ -6979,8 +7013,6 @@ WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS case 3: return enumprinterdrivers_level3(servername, architecture, buffer, offered, needed, returned); default: - *returned=0; - SAFE_FREE(list); return WERR_UNKNOWN_LEVEL; } } @@ -7006,7 +7038,7 @@ static void fill_form_1(FORM_1 *form, nt_forms_struct *list) WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u) { uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + RPC_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *numofforms = &r_u->numofforms; @@ -7019,8 +7051,11 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF int i; /* that's an [in out] buffer */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + + if ( q_u->buffer ) { + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + } DEBUG(4,("_spoolss_enumforms\n")); DEBUGADD(5,("Offered buffer size [%d]\n", offered)); @@ -7032,7 +7067,8 @@ WERROR _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 WERR_NO_MORE_ITEMS; + if (*numofforms == 0) + return WERR_NO_MORE_ITEMS; switch (level) { case 1: @@ -7068,10 +7104,17 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF *needed=buffer_size; - if (!alloc_buffer_size(buffer, buffer_size)){ + if (*needed > offered) { SAFE_FREE(forms_1); + *numofforms=0; return WERR_INSUFFICIENT_BUFFER; } + + if (!rpcbuf_alloc_size(buffer, buffer_size)){ + SAFE_FREE(forms_1); + *numofforms=0; + return WERR_NOMEM; + } /* fill the buffer with the form structures */ for (i=0; i offered) { - *numofforms=0; - return WERR_INSUFFICIENT_BUFFER; - } - else - return WERR_OK; + return WERR_OK; default: SAFE_FREE(list); @@ -7107,7 +7145,7 @@ WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * { uint32 level = q_u->level; UNISTR2 *uni_formname = &q_u->formname; - NEW_BUFFER *buffer = NULL; + RPC_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; @@ -7120,8 +7158,11 @@ WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * int numofforms=0, i=0; /* that's an [in out] buffer */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + + if ( q_u->buffer ) { + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + } unistr2_to_ascii(form_name, uni_formname, sizeof(form_name)-1); @@ -7165,13 +7206,11 @@ WERROR _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)){ + if (*needed > offered) return WERR_INSUFFICIENT_BUFFER; - } - if (*needed > offered) { - return WERR_INSUFFICIENT_BUFFER; - } + if (!rpcbuf_alloc_size(buffer, buffer_size)) + return WERR_NOMEM; /* fill the buffer with the form structures */ DEBUGADD(6,("adding form %s [%d] to buffer\n", form_name, i)); @@ -7209,10 +7248,11 @@ static void fill_port_2(PORT_INFO_2 *port, const char *name) enumports level 1. ****************************************************************************/ -static WERROR enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PORT_INFO_1 *ports=NULL; int i=0; + WERROR result = WERR_OK; if (*lp_enumports_cmd()) { char *cmd = lp_enumports_cmd(); @@ -7274,9 +7314,14 @@ static WERROR enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need *needed += spoolss_size_port_info_1(&ports[i]); } - if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(ports); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the ports structures */ @@ -7285,24 +7330,24 @@ static WERROR enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need smb_io_port_1("", buffer, &ports[i], 0); } +out: SAFE_FREE(ports); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } + if ( !W_ERROR_IS_OK(result) ) + *returned = 0; - return WERR_OK; + return result; } /**************************************************************************** enumports level 2. ****************************************************************************/ -static WERROR enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PORT_INFO_2 *ports=NULL; int i=0; + WERROR result = WERR_OK; if (*lp_enumports_cmd()) { char *cmd = lp_enumports_cmd(); @@ -7372,9 +7417,14 @@ static WERROR enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need *needed += spoolss_size_port_info_2(&ports[i]); } - if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(ports); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } /* fill the buffer with the ports structures */ @@ -7383,14 +7433,13 @@ static WERROR enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need smb_io_port_2("", buffer, &ports[i], 0); } +out: SAFE_FREE(ports); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } + if ( !W_ERROR_IS_OK(result) ) + *returned = 0; - return WERR_OK; + return result; } /**************************************************************************** @@ -7400,14 +7449,17 @@ static WERROR enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u) { uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + RPC_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + + if ( q_u->buffer ) { + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + } DEBUG(4,("_spoolss_enumports\n")); @@ -7741,7 +7793,7 @@ static void fill_driverdir_1(DRIVER_DIRECTORY_1 *info, char *name) /**************************************************************************** ****************************************************************************/ -static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environment, NEW_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environment, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { pstring path; pstring long_archi; @@ -7749,6 +7801,7 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen char *pservername; const char *short_archi; DRIVER_DIRECTORY_1 *info=NULL; + WERROR result = WERR_OK; unistr2_to_ascii(servername, name, sizeof(servername)-1); unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); @@ -7778,19 +7831,22 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen *needed += spoolss_size_driverdir_info_1(info); - if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(info); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } smb_io_driverdir_1("", buffer, info, 0); +out: SAFE_FREE(info); - if (*needed > offered) - return WERR_INSUFFICIENT_BUFFER; - - return WERR_OK; + return result; } /**************************************************************************** @@ -7801,13 +7857,16 @@ WERROR _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRI UNISTR2 *name = &q_u->name; UNISTR2 *uni_environment = &q_u->environment; uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + RPC_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; /* that's an [in out] buffer */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + + if ( q_u->buffer ) { + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + } DEBUG(4,("_spoolss_getprinterdriverdirectory\n")); @@ -8367,9 +8426,10 @@ done: enumprintprocessors level 1. ****************************************************************************/ -static WERROR enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprintprocessors_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTPROCESSOR_1 *info_1=NULL; + WERROR result = WERR_OK; if((info_1 = SMB_MALLOC_P(PRINTPROCESSOR_1)) == NULL) return WERR_NOMEM; @@ -8380,19 +8440,25 @@ static WERROR enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui *needed += spoolss_size_printprocessor_info_1(info_1); - if (!alloc_buffer_size(buffer, *needed)) - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; + } smb_io_printprocessor_info_1("", buffer, info_1, 0); +out: SAFE_FREE(info_1); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } + if ( !W_ERROR_IS_OK(result) ) + *returned = 0; - return WERR_OK; + return result; } /**************************************************************************** @@ -8401,14 +8467,17 @@ static WERROR enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, SPOOL_R_ENUMPRINTPROCESSORS *r_u) { uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + RPC_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + + if ( q_u->buffer ) { + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + } DEBUG(5,("spoolss_enumprintprocessors\n")); @@ -8434,9 +8503,10 @@ WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS enumprintprocdatatypes level 1. ****************************************************************************/ -static WERROR enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprintprocdatatypes_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTPROCDATATYPE_1 *info_1=NULL; + WERROR result = WERR_NOMEM; if((info_1 = SMB_MALLOC_P(PRINTPROCDATATYPE_1)) == NULL) return WERR_NOMEM; @@ -8447,19 +8517,25 @@ static WERROR enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, *needed += spoolss_size_printprocdatatype_info_1(info_1); - if (!alloc_buffer_size(buffer, *needed)) - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; + } smb_io_printprocdatatype_info_1("", buffer, info_1, 0); +out: SAFE_FREE(info_1); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } + if ( !W_ERROR_IS_OK(result) ) + *returned = 0; - return WERR_OK; + return result; } /**************************************************************************** @@ -8468,14 +8544,17 @@ static WERROR enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered, WERROR _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u) { uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + RPC_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + + if ( q_u->buffer ) { + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + } DEBUG(5,("_spoolss_enumprintprocdatatypes\n")); @@ -8494,9 +8573,10 @@ WERROR _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDAT enumprintmonitors level 1. ****************************************************************************/ -static WERROR enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprintmonitors_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTMONITOR_1 *info_1=NULL; + WERROR result = WERR_OK; if((info_1 = SMB_MALLOC_P(PRINTMONITOR_1)) == NULL) return WERR_NOMEM; @@ -8507,28 +8587,35 @@ static WERROR enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint *needed += spoolss_size_printmonitor_info_1(info_1); - if (!alloc_buffer_size(buffer, *needed)) - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; + } smb_io_printmonitor_info_1("", buffer, info_1, 0); +out: SAFE_FREE(info_1); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } + if ( !W_ERROR_IS_OK(result) ) + *returned = 0; - return WERR_OK; + return result; } /**************************************************************************** enumprintmonitors level 2. ****************************************************************************/ -static WERROR enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprintmonitors_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTMONITOR_2 *info_2=NULL; + WERROR result = WERR_OK; if((info_2 = SMB_MALLOC_P(PRINTMONITOR_2)) == NULL) return WERR_NOMEM; @@ -8541,19 +8628,25 @@ static WERROR enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint *needed += spoolss_size_printmonitor_info_2(info_2); - if (!alloc_buffer_size(buffer, *needed)) - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; + } smb_io_printmonitor_info_2("", buffer, info_2, 0); +out: SAFE_FREE(info_2); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } - - return WERR_OK; + if ( !W_ERROR_IS_OK(result) ) + *returned = 0; + + return result; } /**************************************************************************** @@ -8562,14 +8655,17 @@ static WERROR enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_u, SPOOL_R_ENUMPRINTMONITORS *r_u) { uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + RPC_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; /* that's an [in out] buffer */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + + if ( q_u->buffer ) { + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + } DEBUG(5,("spoolss_enumprintmonitors\n")); @@ -8598,12 +8694,13 @@ WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_ static WERROR getjob_level_1(print_queue_struct **queue, int count, int snum, NT_PRINTER_INFO_LEVEL *ntprinter, - uint32 jobid, NEW_BUFFER *buffer, uint32 offered, + uint32 jobid, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { int i=0; BOOL found=False; JOB_INFO_1 *info_1=NULL; + WERROR result = WERR_OK; info_1=SMB_MALLOC_P(JOB_INFO_1); @@ -8626,19 +8723,22 @@ static WERROR getjob_level_1(print_queue_struct **queue, int count, int snum, *needed += spoolss_size_job_info_1(info_1); - if (!alloc_buffer_size(buffer, *needed)) { - SAFE_FREE(info_1); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; } smb_io_job_info_1("", buffer, info_1, 0); +out: SAFE_FREE(info_1); - if (*needed > offered) - return WERR_INSUFFICIENT_BUFFER; - - return WERR_OK; + return result; } /**************************************************************************** @@ -8646,7 +8746,7 @@ static WERROR getjob_level_1(print_queue_struct **queue, int count, int snum, static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, NT_PRINTER_INFO_LEVEL *ntprinter, - uint32 jobid, NEW_BUFFER *buffer, uint32 offered, + uint32 jobid, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { int i = 0; @@ -8698,18 +8798,18 @@ static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, *needed += spoolss_size_job_info_2(info_2); - if (!alloc_buffer_size(buffer, *needed)) { + if (*needed > offered) { ret = WERR_INSUFFICIENT_BUFFER; goto done; } - smb_io_job_info_2("", buffer, info_2, 0); - - if (*needed > offered) { + if (!rpcbuf_alloc_size(buffer, *needed)) { ret = WERR_INSUFFICIENT_BUFFER; goto done; } + smb_io_job_info_2("", buffer, info_2, 0); + ret = WERR_OK; done: @@ -8729,7 +8829,7 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ POLICY_HND *handle = &q_u->handle; uint32 jobid = q_u->jobid; uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + RPC_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; WERROR wstatus = WERR_OK; @@ -8740,8 +8840,11 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ print_status_struct prt_status; /* that's an [in out] buffer */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + + if ( q_u->buffer ) { + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + } DEBUG(5,("spoolss_getjob\n")); @@ -9307,13 +9410,14 @@ static void fill_printprocessordirectory_1(PRINTPROCESSOR_DIRECTORY_1 *info, cha static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, UNISTR2 *environment, - NEW_BUFFER *buffer, + RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { pstring path; pstring long_archi; PRINTPROCESSOR_DIRECTORY_1 *info=NULL; + WERROR result = WERR_OK; unistr2_to_ascii(long_archi, environment, sizeof(long_archi)-1); @@ -9329,32 +9433,38 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, *needed += spoolss_size_printprocessordirectory_info_1(info); - if (!alloc_buffer_size(buffer, *needed)) { - safe_free(info); - return WERR_INSUFFICIENT_BUFFER; + if (*needed > offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; } smb_io_printprocessordirectory_1("", buffer, info, 0); - safe_free(info); +out: + SAFE_FREE(info); - if (*needed > offered) - return WERR_INSUFFICIENT_BUFFER; - else - return WERR_OK; + return result; } WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, SPOOL_R_GETPRINTPROCESSORDIRECTORY *r_u) { uint32 level = q_u->level; - NEW_BUFFER *buffer = NULL; + RPC_BUFFER *buffer = NULL; uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; WERROR result; /* that's an [in out] buffer */ - spoolss_move_buffer(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + + if ( q_u->buffer ) { + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + } DEBUG(5,("_spoolss_getprintprocessordirectory\n")); -- cgit From d177f1bc8f0cb5ad91c9146871ba2e93eb2988d2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 15 Mar 2005 20:12:51 +0000 Subject: r5806: * fix a couple more segvs in spoolss * comment out unused variable after jra's change to revert the 56bit des smb signing changes (This used to be commit 13ed08cd2a1097021cc44f4109859ba89db7df81) --- source3/rpc_server/srv_spoolss.c | 3 +++ source3/rpc_server/srv_spoolss_nt.c | 23 +++++++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index f846813a40..b3a67dd6cf 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1244,6 +1244,9 @@ static BOOL api_spoolss_getjob(pipes_struct *p) prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + if(!spoolss_io_q_getjob("", &q_u, data, 0)) { DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n")); return False; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 053290f80f..3c611be9ac 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8752,30 +8752,25 @@ static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, int i = 0; BOOL found = False; JOB_INFO_2 *info_2; - WERROR ret; + WERROR result; DEVICEMODE *devmode = NULL; NT_DEVICEMODE *nt_devmode = NULL; - info_2=SMB_MALLOC_P(JOB_INFO_2); + if ( !(info_2=SMB_MALLOC_P(JOB_INFO_2)) ) + return WERR_NOMEM; ZERO_STRUCTP(info_2); - if (info_2 == NULL) { - ret = WERR_NOMEM; - goto done; - } - for ( i=0; i offered) { - ret = WERR_INSUFFICIENT_BUFFER; + result = WERR_INSUFFICIENT_BUFFER; goto done; } if (!rpcbuf_alloc_size(buffer, *needed)) { - ret = WERR_INSUFFICIENT_BUFFER; + result = WERR_NOMEM; goto done; } smb_io_job_info_2("", buffer, info_2, 0); - ret = WERR_OK; + result = WERR_OK; done: /* Cleanup allocated memory */ @@ -8818,7 +8813,7 @@ static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, free_job_info_2(info_2); /* Also frees devmode */ SAFE_FREE(info_2); - return ret; + return result; } /**************************************************************************** -- cgit From 5d88feaaad77bbb8a172c911624ccb07d6050da4 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 20 Mar 2005 09:23:37 +0000 Subject: r5909: Remove some unecessary casts. Patch from Jason Mader for bugzill #2468. (This used to be commit ede9fd08cf0ce04528f73c74e2345ba46d26f1e2) --- source3/rpc_server/srv_samr_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 6797730be9..61160ccaa0 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -264,7 +264,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); pdb_sethexhours(old, pdb_get_hours(to)); - pdb_sethexhours(new, (const char *)from->logon_hrs.hours); + pdb_sethexhours(new, from->logon_hrs.hours); if (!strequal(old, new)) { pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); } -- cgit From 43f4930ed3210910b2a1f1ff0c04d9c8ed9f238d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 22 Mar 2005 14:20:25 +0000 Subject: r5943: remove unneccessary se_priv_copy() (This used to be commit 2db04a90c4197a3950bbc322948468cb306b3557) --- source3/rpc_server/srv_samr_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 139960f661..9e75dd6f7c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3821,7 +3821,6 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM DOM_SID user_sid; SAM_ACCOUNT *sam_pass=NULL; uint32 acc_granted; - SE_PRIV se_rights; BOOL can_add_accounts; BOOL ret; @@ -3847,8 +3846,7 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM return NT_STATUS_NO_SUCH_USER; } - se_priv_copy( &se_rights, &se_add_users ); - can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); + can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users ); /******** BEGIN SeAddUsers BLOCK *********/ -- cgit From 40295c41dbba119f6b4e32647fb70f51ebf390a0 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 22 Mar 2005 14:48:18 +0000 Subject: r5948: more compile cleanups from Jason Mader (This used to be commit cc6c769c3c26164919dd13777d671abe02c084d9) --- source3/rpc_server/srv_util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 802e7673a4..79d5d06d23 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -42,6 +42,7 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +#if 0 /* these aren't used currently but are here if you need them */ /* * A list of the rids of well known BUILTIN and Domain users * and groups. @@ -78,7 +79,7 @@ static const rid_name domain_group_rids[] = { DOMAIN_GROUP_RID_GUESTS , "Domain Guests" }, { 0 , NULL } }; - +#endif /******************************************************************* gets a domain user's groups from their already-calculated NT_USER_TOKEN -- cgit From 9b38ced168d4db50126c4259b31cb15e2ee2231b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 22 Mar 2005 14:54:12 +0000 Subject: r5950: more compiler warning's from Jason Mader (This used to be commit 27c6e85ad59a86ab45ae3297c7445c4ff15546c8) --- source3/rpc_server/srv_samr_nt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9e75dd6f7c..b96e160156 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1977,7 +1977,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S DOM_GID *gids = NULL; int num_groups = 0; gid_t *unix_gids; - int i, num_gids, num_sids; + int i, num_gids; uint32 acc_granted; BOOL ret; NTSTATUS result; @@ -2027,7 +2027,6 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S } sids = NULL; - num_sids = 0; become_root(); result = pdb_enum_group_memberships(pdb_get_username(sam_pass), @@ -4119,7 +4118,6 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S DOM_SID dom_sid; DOM_SID info_sid; fstring name; - struct group *grp; struct samr_info *info; uint32 acc_granted; gid_t gid; @@ -4166,7 +4164,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S return NT_STATUS_ACCESS_DENIED; /* check if the group has been successfully created */ - if ((grp=getgrgid(gid)) == NULL) + if ( getgrgid(gid) == NULL ) return NT_STATUS_ACCESS_DENIED; if ((info = get_samr_info_by_sid(&info_sid)) == NULL) -- cgit From 93e04e941e15034c8e7aa1faedc74ce536049153 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 22 Mar 2005 18:07:58 +0000 Subject: r5961: final round of compiler warning fixes based on feedback from Jason Mader (This used to be commit 9e77da9320c900b3e437d534e31fa5ff81e9acfd) --- source3/rpc_server/srv_samr_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b96e160156..19989838c7 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2899,7 +2899,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, SAM_ACCOUNT *pwd) acct_ctrl = pdb_get_acct_ctrl(pwd); - if (!decode_pw_buffer((char*)id23->pass, plaintext_buf, 256, &len, STR_UNICODE)) { + if (!decode_pw_buffer(id23->pass, plaintext_buf, 256, &len, STR_UNICODE)) { pdb_free_sam(&pwd); return False; } @@ -2950,7 +2950,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, SAM_ACCOUNT *pwd) set_user_info_pw ********************************************************************/ -static BOOL set_user_info_pw(char *pass, SAM_ACCOUNT *pwd) +static BOOL set_user_info_pw(uint8 *pass, SAM_ACCOUNT *pwd) { uint32 len; pstring plaintext_buf; @@ -3096,7 +3096,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE dump_data(100, (char *)ctr->info.id24->pass, 516); - if (!set_user_info_pw((char *)ctr->info.id24->pass, pwd)) + if (!set_user_info_pw(ctr->info.id24->pass, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; break; -- cgit From cf7d098b2c1032b51b8f5d439b29c8d20d0991ee Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Tue, 22 Mar 2005 20:50:29 +0000 Subject: r5965: Apply Volker's patch for "ldapsam trusted = yes" for samr_lookup_rids. Gives us again up to ~6x improvement on group membership lookups. (This used to be commit e2117bcb09cbd21df3b6621c2794a006418c1d9e) --- source3/rpc_server/srv_samr_nt.c | 62 +++++++++++----------------------------- 1 file changed, 17 insertions(+), 45 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 19989838c7..001da3f3ea 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1464,8 +1464,9 @@ NTSTATUS _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_ makes a SAMR_R_LOOKUP_RIDS structure. ********************************************************************/ -static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, fstring names[], - UNIHDR **pp_hdr_name, UNISTR2 **pp_uni_name) +static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, + const char **names, UNIHDR **pp_hdr_name, + UNISTR2 **pp_uni_name) { uint32 i; UNIHDR *hdr_name=NULL; @@ -1485,7 +1486,7 @@ static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, fstring nam } for (i = 0; i < num_names; i++) { - DEBUG(10, ("names[%d]:%s\n", i, names[i] ? names[i] : "")); + DEBUG(10, ("names[%d]:%s\n", i, *names[i] ? names[i] : "")); init_unistr2(&uni_name[i], names[i], UNI_FLAGS_NONE); init_uni_hdr(&hdr_name[i], &uni_name[i]); } @@ -1502,16 +1503,13 @@ static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, fstring nam NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP_RIDS *r_u) { - fstring group_names[MAX_SAM_ENTRIES]; - uint32 *group_attrs = NULL; + const char **names; + uint32 *attrs = NULL; UNIHDR *hdr_name = NULL; UNISTR2 *uni_name = NULL; DOM_SID pol_sid; int num_rids = q_u->num_rids1; - int i; uint32 acc_granted; - BOOL have_mapped = False; - BOOL have_unmapped = False; r_u->status = NT_STATUS_OK; @@ -1527,11 +1525,12 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK return NT_STATUS_UNSUCCESSFUL; } - if (num_rids) { - if ((group_attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_rids )) == NULL) - return NT_STATUS_NO_MEMORY; - } - + names = TALLOC_ZERO_ARRAY(p->mem_ctx, const char *, num_rids); + attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_rids); + + if ((num_rids != 0) && ((names == NULL) || (attrs == NULL))) + return NT_STATUS_NO_MEMORY; + if (!sid_equal(&pol_sid, get_global_sam_sid())) { /* TODO: Sooner or later we need to look up BUILTIN rids as * well. -- vl */ @@ -1539,44 +1538,17 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK } become_root(); /* lookup_sid can require root privs */ - - for (i = 0; i < num_rids; i++) { - fstring tmpname; - fstring domname; - DOM_SID sid; - enum SID_NAME_USE type; - - group_attrs[i] = SID_NAME_UNKNOWN; - *group_names[i] = '\0'; - - sid_copy(&sid, &pol_sid); - sid_append_rid(&sid, q_u->rid[i]); - - if (lookup_sid(&sid, domname, tmpname, &type)) { - group_attrs[i] = (uint32)type; - fstrcpy(group_names[i],tmpname); - DEBUG(5,("_samr_lookup_rids: %s:%d\n", group_names[i], - group_attrs[i])); - have_mapped = True; - } else { - have_unmapped = True; - } - } - + r_u->status = pdb_lookup_rids(p->mem_ctx, &pol_sid, num_rids, q_u->rid, + &names, &attrs); unbecome_root(); done: - r_u->status = NT_STATUS_NONE_MAPPED; - - if (have_mapped) - r_u->status = - have_unmapped ? STATUS_SOME_UNMAPPED : NT_STATUS_OK; - - if(!make_samr_lookup_rids(p->mem_ctx, num_rids, group_names, &hdr_name, &uni_name)) + if(!make_samr_lookup_rids(p->mem_ctx, num_rids, names, + &hdr_name, &uni_name)) return NT_STATUS_NO_MEMORY; - init_samr_r_lookup_rids(r_u, num_rids, hdr_name, uni_name, group_attrs); + init_samr_r_lookup_rids(r_u, num_rids, hdr_name, uni_name, attrs); DEBUG(5,("_samr_lookup_rids: %d\n", __LINE__)); -- cgit From bece9417d2e232e5b13ea340c79430bb9680eb8a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 23 Mar 2005 20:57:03 +0000 Subject: r6004: Let's make server manager able to kill a user session. This will send a shutdown command to the right process by pid read from the sessions list. (This used to be commit 5d3d025db757f7d48f241142a60a93214f2b47ea) --- source3/rpc_server/srv_srvsvc.c | 29 +++++++++++++++++++++++++ source3/rpc_server/srv_srvsvc_nt.c | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 9d85088e56..0b4eac5cc7 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -165,6 +165,34 @@ static BOOL api_srv_net_sess_enum(pipes_struct *p) return True; } +/******************************************************************* + Delete session. +********************************************************************/ + +static BOOL api_srv_net_sess_del(pipes_struct *p) +{ + SRV_Q_NET_SESS_DEL q_u; + SRV_R_NET_SESS_DEL r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the net server get enum */ + if (!srv_io_q_net_sess_del("", &q_u, data, 0)) + return False; + + /* construct reply. always indicate success */ + r_u.status = _srv_net_sess_del(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if (!srv_io_r_net_sess_del("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* RPC to enumerate shares. ********************************************************************/ @@ -530,6 +558,7 @@ static struct api_struct api_srv_cmds[] = { { "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum }, { "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum }, + { "SRV_NET_SESS_DEL" , SRV_NET_SESS_DEL , api_srv_net_sess_del }, { "SRV_NET_SHARE_ENUM_ALL" , SRV_NET_SHARE_ENUM_ALL , api_srv_net_share_enum_all }, { "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum }, { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 13e1971925..8bcb5c82ac 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1348,6 +1348,49 @@ WERROR _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_S return r_u->status; } +/******************************************************************* +net sess del +********************************************************************/ + +WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SESS_DEL *r_u) +{ + struct sessionid *session_list; + int num_sessions, snum, ret; + fstring username; + fstring machine; + + rpcstr_pull_unistr2_fstring(username, &q_u->uni_user_name); + rpcstr_pull_unistr2_fstring(machine, &q_u->uni_cli_name); + + /* strip leading backslashes if any */ + while (machine[0] == '\\') { + memmove(machine, &machine[1], strlen(machine)); + } + + num_sessions = list_sessions(&session_list); + + DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); + + r_u->status = WERR_ACCESS_DENIED; + + for (snum = 0; snum < num_sessions; snum++) { + + if ((StrCaseCmp(session_list[snum].username, username) == 0 || username[0] == '\0' ) && + StrCaseCmp(session_list[snum].remote_machine, machine) == 0) { + + if ((ret = message_send_pid(session_list[snum].pid, MSG_SHUTDOWN, NULL, 0, False))) { + r_u->status = WERR_OK; + } else { + r_u->status = WERR_ACCESS_DENIED; + } + } + } + + DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); + + return r_u->status; +} + /******************************************************************* Net share enum all. ********************************************************************/ -- cgit From 920745f0df024741f28e8557c52187a8db01c5d1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 23 Mar 2005 21:46:09 +0000 Subject: r6009: Add privillage check for SE_DISK_OP (is this the right privilage?) before allowing users to shut down any sessions. Simo - please check security before allowing state changes. Please review this change. Jeremy. (This used to be commit 51beba71d4d5d3d259e567b65b1694d862814fe9) --- source3/rpc_server/srv_srvsvc_nt.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 8bcb5c82ac..a00409afc8 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1354,10 +1354,13 @@ net sess del WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SESS_DEL *r_u) { + struct current_user user; struct sessionid *session_list; int num_sessions, snum, ret; fstring username; fstring machine; + SE_PRIV se_diskop = SE_DISK_OPERATOR; /* Is disk op appropriate here ? JRA. */ + BOOL is_disk_op = False; rpcstr_pull_unistr2_fstring(username, &q_u->uni_user_name); rpcstr_pull_unistr2_fstring(machine, &q_u->uni_cli_name); @@ -1371,12 +1374,21 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); + get_current_user(&user,p); + + is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); + + /* fail out now if you are not root and not a disk op */ + + if ( user.uid != sec_initial_uid() && !is_disk_op ) + return WERR_ACCESS_DENIED; + r_u->status = WERR_ACCESS_DENIED; for (snum = 0; snum < num_sessions; snum++) { - if ((StrCaseCmp(session_list[snum].username, username) == 0 || username[0] == '\0' ) && - StrCaseCmp(session_list[snum].remote_machine, machine) == 0) { + if ((strequal(session_list[snum].username, username) || username[0] == '\0' ) && + strequal(session_list[snum].remote_machine, machine)) { if ((ret = message_send_pid(session_list[snum].pid, MSG_SHUTDOWN, NULL, 0, False))) { r_u->status = WERR_OK; @@ -1497,7 +1509,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S char *path; SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; - BOOL is_disk_op; + BOOL is_disk_op = False; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); -- cgit From 5d1cb8e79edea9e8581d3c2c9dd297310cd9a98c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 23 Mar 2005 23:26:33 +0000 Subject: r6014: rather large change set.... pulling back all recent rpc changes from trunk into 3.0. I've tested a compile and so don't think I've missed any files. But if so, just mail me and I'll clean backup in a couple of hours. Changes include \winreg, \eventlog, \svcctl, and general parse_misc.c updates. I am planning on bracketing the event code with an #ifdef ENABLE_EVENTLOG until I finish merging Marcin's changes (very soon). (This used to be commit 4e0ac63c36527cd8c52ef720cae17e84f67e7221) --- source3/rpc_server/srv_eventlog.c | 206 ++++++++ source3/rpc_server/srv_eventlog_nt.c | 923 +++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_lsa_ds_nt.c | 7 +- source3/rpc_server/srv_netlog.c | 2 +- source3/rpc_server/srv_pipe.c | 7 + source3/rpc_server/srv_reg.c | 67 ++- source3/rpc_server/srv_reg_nt.c | 141 ++++-- source3/rpc_server/srv_spoolss_nt.c | 19 +- source3/rpc_server/srv_svcctl.c | 294 +++++++++++ source3/rpc_server/srv_svcctl_nt.c | 291 +++++++++++ 10 files changed, 1875 insertions(+), 82 deletions(-) create mode 100644 source3/rpc_server/srv_eventlog.c create mode 100644 source3/rpc_server/srv_eventlog_nt.c create mode 100644 source3/rpc_server/srv_svcctl.c create mode 100644 source3/rpc_server/srv_svcctl_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c new file mode 100644 index 0000000000..07aebcd2fa --- /dev/null +++ b/source3/rpc_server/srv_eventlog.c @@ -0,0 +1,206 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Marcin Krzysztof Porwit 2005. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +static BOOL api_eventlog_open_eventlog(pipes_struct *p) +{ + EVENTLOG_Q_OPEN_EVENTLOG q_u; + EVENTLOG_R_OPEN_EVENTLOG r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!(eventlog_io_q_open_eventlog("", &q_u, data, 0))) { + DEBUG(0, ("eventlog_io_q_open_eventlog: unable to unmarshall EVENTLOG_Q_OPEN_EVENTLOG.\n")); + return False; + } + + r_u.status = _eventlog_open_eventlog(p, &q_u, &r_u); + + if (!(eventlog_io_r_open_eventlog("", &r_u, rdata, 0))) { + DEBUG(0, ("eventlog_io_r_open_eventlog: unable to marshall EVENTLOG_R_OPEN_EVENTLOG.\n")); + return False; + } + + return True; +} + +static BOOL api_eventlog_close_eventlog(pipes_struct *p) +{ + EVENTLOG_Q_CLOSE_EVENTLOG q_u; + EVENTLOG_R_CLOSE_EVENTLOG r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!(eventlog_io_q_close_eventlog("", &q_u, data, 0))) { + DEBUG(0, ("eventlog_io_q_close_eventlog: unable to unmarshall EVENTLOG_Q_CLOSE_EVENTLOG.\n")); + return False; + } + + r_u.status = _eventlog_close_eventlog(p, &q_u, &r_u); + + if (!(eventlog_io_r_close_eventlog("", &r_u, rdata, 0))) { + DEBUG(0, ("eventlog_io_r_close_eventlog: unable to marshall EVENTLOG_R_CLOSE_EVENTLOG.\n")); + return False; + } + + return True; +} + +static BOOL api_eventlog_get_num_records(pipes_struct *p) +{ + EVENTLOG_Q_GET_NUM_RECORDS q_u; + EVENTLOG_R_GET_NUM_RECORDS r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!(eventlog_io_q_get_num_records("", &q_u, data, 0))) { + DEBUG(0, ("eventlog_io_q_get_num_records: unable to unmarshall EVENTLOG_Q_GET_NUM_RECORDS.\n")); + return False; + } + + r_u.status = _eventlog_get_num_records(p, &q_u, &r_u); + + if (!(eventlog_io_r_get_num_records("", &r_u, rdata, 0))) { + DEBUG(0, ("eventlog_io_r_get_num_records: unable to marshall EVENTLOG_R_GET_NUM_RECORDS.\n")); + return False; + } + + return True; +} + +static BOOL api_eventlog_get_oldest_entry(pipes_struct *p) +{ + EVENTLOG_Q_GET_OLDEST_ENTRY q_u; + EVENTLOG_R_GET_OLDEST_ENTRY r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!(eventlog_io_q_get_oldest_entry("", &q_u, data, 0))) { + DEBUG(0, ("eventlog_io_q_get_oldest_entry: unable to unmarshall EVENTLOG_Q_GET_OLDEST_ENTRY.\n")); + return False; + } + + r_u.status = _eventlog_get_oldest_entry(p, &q_u, &r_u); + + if (!(eventlog_io_r_get_oldest_entry("", &r_u, rdata, 0))) { + DEBUG(0, ("eventlog_io_r_get_oldest_entry: unable to marshall EVENTLOG_R_GET_OLDEST_ENTRY.\n")); + return False; + } + + return True; +} + +static BOOL api_eventlog_read_eventlog(pipes_struct *p) +{ + EVENTLOG_Q_READ_EVENTLOG q_u; + EVENTLOG_R_READ_EVENTLOG r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!(eventlog_io_q_read_eventlog("", &q_u, data, 0))) { + DEBUG(0, ("eventlog_io_q_read_eventlog: unable to unmarshall EVENTLOG_Q_READ_EVENTLOG.\n")); + return False; + } + + r_u.status = _eventlog_read_eventlog(p, &q_u, &r_u); + + if (!(eventlog_io_r_read_eventlog("", &q_u, &r_u, rdata, 0))) { + DEBUG(0, ("eventlog_io_r_read_eventlog: unable to marshall EVENTLOG_R_READ_EVENTLOG.\n")); + return False; + } + + return True; +} + +static BOOL api_eventlog_clear_eventlog(pipes_struct *p) +{ + EVENTLOG_Q_CLEAR_EVENTLOG q_u; + EVENTLOG_R_CLEAR_EVENTLOG r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!(eventlog_io_q_clear_eventlog("", &q_u, data, 0))) { + DEBUG(0, ("eventlog_io_q_clear_eventlog: unable to unmarshall EVENTLOG_Q_CLEAR_EVENTLOG.\n")); + return False; + } + + r_u.status = _eventlog_clear_eventlog(p, &q_u, &r_u); + + if (!(eventlog_io_r_clear_eventlog("", &r_u, rdata, 0))) { + DEBUG(0, ("eventlog_io_q_clear_eventlog: unable to marshall EVENTLOG_Q_CLEAR_EVENTLOG.\n")); + return False; + } + + return True; +} + +/* + \pipe\eventlog commands +*/ +struct api_struct api_eventlog_cmds[] = +{ + {"EVENTLOG_OPENEVENTLOG", EVENTLOG_OPENEVENTLOG, api_eventlog_open_eventlog }, + {"EVENTLOG_CLOSEVENTLOG", EVENTLOG_CLOSEEVENTLOG, api_eventlog_close_eventlog }, + {"EVENTLOG_GETNUMRECORDS", EVENTLOG_GETNUMRECORDS, api_eventlog_get_num_records }, + {"EVENTLOG_GETOLDESTENTRY", EVENTLOG_GETOLDESTENTRY, api_eventlog_get_oldest_entry }, + {"EVENTLOG_READEVENTLOG", EVENTLOG_READEVENTLOG, api_eventlog_read_eventlog }, + {"EVENTLOG_CLEAREVENTLOG", EVENTLOG_CLEAREVENTLOG, api_eventlog_clear_eventlog } +}; + +NTSTATUS rpc_eventlog_init(void) +{ + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, + "eventlog", "eventlog", api_eventlog_cmds, + sizeof(api_eventlog_cmds)/sizeof(struct api_struct)); +} + +void eventlog_get_pipe_fns(struct api_struct **fns, int *n_fns) +{ + *fns = api_eventlog_cmds; + *n_fns = sizeof(api_eventlog_cmds) / sizeof(struct api_struct); +} diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c new file mode 100644 index 0000000000..7501434a13 --- /dev/null +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -0,0 +1,923 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Marcin Krzysztof Porwit 2005. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +typedef struct eventlog_info +{ + /* for use by the \PIPE\eventlog policy */ + fstring source_log_file_name; + fstring source_server_name; + fstring handle_string; + uint32 num_records; + uint32 oldest_entry; +} Eventlog_info; + +static void free_eventlog_info(void *ptr) +{ + struct eventlog_info *info = (struct eventlog_info *)ptr; + memset(info->source_log_file_name, '0', sizeof(*(info->source_log_file_name))); + memset(info->source_server_name, '0', sizeof(*(info->source_server_name))); + memset(info->handle_string, '0', sizeof(*(info->handle_string))); + memset(info, 0, sizeof(*(info))); + SAFE_FREE(info); +} + +static Eventlog_info *find_eventlog_info_by_hnd(pipes_struct *p, + POLICY_HND *handle) +{ + Eventlog_info *info = NULL; + + if(!(find_policy_by_hnd(p,handle,(void **)&info))) + { + DEBUG(2,("find_eventlog_info_by_hnd: eventlog not found.\n")); + } + + return info; +} + +void policy_handle_to_string(POLICY_HND *handle, fstring *dest) +{ + memset(dest, 0, sizeof(*dest)); + snprintf((char *)dest, sizeof(*dest), "%08X-%08X-%04X-%04X-%02X%02X%02X%02X%02X", + handle->data1, + handle->data2, + handle->data3, + handle->data4, + handle->data5[0], + handle->data5[1], + handle->data5[2], + handle->data5[3], + handle->data5[4]); +} + +/** + * Callout to open the specified event log + * + * smbrun calling convention -- + * INPUT: + * OUTPUT: the string "SUCCESS" if the command succeeded + * no such string if there was a failure. + */ +static BOOL _eventlog_open_eventlog_hook(Eventlog_info *info) +{ + char *cmd = lp_eventlog_open_cmd(); + char **qlines; + pstring command; + int numlines = 0; + int ret; + int fd = -1; + + if(cmd == NULL || strlen(cmd) == 0) + { + DEBUG(0, ("Must define an \"eventlog open command\" entry in the config.\n")); + return False; + } + + memset(command, 0, sizeof(command)); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", + cmd, + info->source_log_file_name, + info->handle_string); + + DEBUG(10, ("Running [%s]\n", command)); + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); + + if(ret != 0) + { + if(fd != -1) + close(fd); + return False; + } + + qlines = fd_lines_load(fd, &numlines); + DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); + close(fd); + + if(numlines) + { + DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); + if(0 == strncmp(qlines[0], "SUCCESS", strlen("SUCCESS"))) + { + DEBUGADD(10, ("Able to open [%s].\n", info->source_log_file_name)); + file_lines_free(qlines); + return True; + } + } + + file_lines_free(qlines); + return False; +} + +WERROR _eventlog_open_eventlog(pipes_struct *p, + EVENTLOG_Q_OPEN_EVENTLOG *q_u, + EVENTLOG_R_OPEN_EVENTLOG *r_u) +{ + Eventlog_info *info = NULL; + + if(!q_u || !r_u) + return WERR_NOMEM; + + if((info = SMB_MALLOC_P(Eventlog_info)) == NULL) + return WERR_NOMEM; + + ZERO_STRUCTP(info); + + if(q_u->servername_ptr != 0) + { + unistr2_to_ascii(info->source_server_name, &(q_u->servername), sizeof(info->source_server_name)); + } + else + { + /* if servername == NULL, use the local computer */ + fstrcpy(info->source_server_name, global_myname()); + } + DEBUG(10, ("_eventlog_open_eventlog: Using [%s] as the server name.\n", info->source_server_name)); + + if(q_u->sourcename_ptr != 0) + { + unistr2_to_ascii(info->source_log_file_name, &(q_u->sourcename), sizeof(info->source_log_file_name)); + } + else + { + /* if sourcename == NULL, default to "Application" log */ + fstrcpy(info->source_log_file_name, "Application"); + } + DEBUG(10, ("_eventlog_open_eventlog: Using [%s] as the source log file.\n", info->source_log_file_name)); + + if(!create_policy_hnd(p, &(r_u->handle), free_eventlog_info, (void *)info)) + return WERR_NOMEM; + + policy_handle_to_string(&r_u->handle, &info->handle_string); + + if(!(_eventlog_open_eventlog_hook(info))) + return WERR_BADFILE; + + return WERR_OK; +} +/** + * Callout to get the number of records in the specified event log + * + * smbrun calling convention -- + * INPUT: + * OUTPUT: A single line with a single integer containing the number of + * entries in the log. If there are no entries in the log, return 0. + */ +static BOOL _eventlog_get_num_records_hook(Eventlog_info *info) +{ + char *cmd = lp_eventlog_num_records_cmd(); + char **qlines; + pstring command; + int numlines = 0; + int ret; + int fd = -1; + + if(cmd == NULL || strlen(cmd) == 0) + { + DEBUG(0, ("Must define an \"eventlog num records command\" entry in the config.\n")); + return False; + } + + memset(command, 0, sizeof(command)); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", + cmd, + info->source_log_file_name, + info->handle_string); + + DEBUG(10, ("Running [%s]\n", command)); + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); + + if(ret != 0) + { + if(fd != -1) + close(fd); + return False; + } + + qlines = fd_lines_load(fd, &numlines); + DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); + close(fd); + + if(numlines) + { + DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); + sscanf(qlines[0], "%d", &(info->num_records)); + file_lines_free(qlines); + return True; + } + + file_lines_free(qlines); + return False; +} + +WERROR _eventlog_get_num_records(pipes_struct *p, + EVENTLOG_Q_GET_NUM_RECORDS *q_u, + EVENTLOG_R_GET_NUM_RECORDS *r_u) +{ + Eventlog_info *info = NULL; + POLICY_HND *handle = NULL; + + if(!q_u || !r_u) + return WERR_NOMEM; + + handle = &(q_u->handle); + info = find_eventlog_info_by_hnd(p, handle); + + if(!(_eventlog_get_num_records_hook(info))) + return WERR_BADFILE; + + r_u->num_records = info->num_records; + + return WERR_OK; +} +/** + * Callout to find the oldest record in the log + * + * smbrun calling convention -- + * INPUT: + * OUTPUT: If there are entries in the event log, the index of the + * oldest entry. Must be 1 or greater. + * If there are no entries in the log, returns a 0 + */ +static BOOL _eventlog_get_oldest_entry_hook(Eventlog_info *info) +{ + char *cmd = lp_eventlog_oldest_record_cmd(); + char **qlines; + pstring command; + int numlines = 0; + int ret; + int fd = -1; + + if(cmd == NULL || strlen(cmd) == 0) + { + DEBUG(0, ("Must define an \"eventlog oldest record command\" entry in the config.\n")); + return False; + } + + memset(command, 0, sizeof(command)); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", + cmd, + info->source_log_file_name, + info->handle_string); + + DEBUG(10, ("Running [%s]\n", command)); + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); + + if(ret != 0) + { + if(fd != -1) + close(fd); + return False; + } + + qlines = fd_lines_load(fd, &numlines); + DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); + close(fd); + + if(numlines) + { + DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); + sscanf(qlines[0], "%d", &(info->oldest_entry)); + file_lines_free(qlines); + return True; + } + + file_lines_free(qlines); + return False; +} + +WERROR _eventlog_get_oldest_entry(pipes_struct *p, + EVENTLOG_Q_GET_OLDEST_ENTRY *q_u, + EVENTLOG_R_GET_OLDEST_ENTRY *r_u) +{ + Eventlog_info *info = NULL; + POLICY_HND *handle = NULL; + + if(!q_u || !r_u) + return WERR_NOMEM; + + handle = &(q_u->handle); + info = find_eventlog_info_by_hnd(p, handle); + + if(!(_eventlog_get_oldest_entry_hook(info))) + return WERR_BADFILE; + + r_u->oldest_entry = info->oldest_entry; + + return WERR_OK; +} + +/** + * Callout to close the specified event log + * + * smbrun calling convention -- + * INPUT: + * OUTPUT: the string "SUCCESS" if the command succeeded + * no such string if there was a failure. + */ +static BOOL _eventlog_close_eventlog_hook(Eventlog_info *info) +{ + char *cmd = lp_eventlog_close_cmd(); + char **qlines; + pstring command; + int numlines = 0; + int ret; + int fd = -1; + + if(cmd == NULL || strlen(cmd) == 0) + { + DEBUG(0, ("Must define an \"eventlog close command\" entry in the config.\n")); + return False; + } + + memset(command, 0, sizeof(command)); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", + cmd, + info->source_log_file_name, + info->handle_string); + + DEBUG(10, ("Running [%s]\n", command)); + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); + + if(ret != 0) + { + if(fd != -1) + close(fd); + return False; + } + + qlines = fd_lines_load(fd, &numlines); + DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); + close(fd); + + if(numlines) + { + DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); + if(0 == strncmp(qlines[0], "SUCCESS", strlen("SUCCESS"))) + { + DEBUGADD(10, ("Able to close [%s].\n", info->source_log_file_name)); + file_lines_free(qlines); + return True; + } + } + + file_lines_free(qlines); + return False; +} + +WERROR _eventlog_close_eventlog(pipes_struct *p, + EVENTLOG_Q_CLOSE_EVENTLOG *q_u, + EVENTLOG_R_CLOSE_EVENTLOG *r_u) +{ + Eventlog_info *info = NULL; + POLICY_HND *handle; + + if(!q_u || !r_u) + return WERR_NOMEM; + + handle = &(q_u->handle); + + info = find_eventlog_info_by_hnd(p, handle); + if(!(_eventlog_close_eventlog_hook(info))) + return WERR_BADFILE; + + if(!(close_policy_hnd(p, handle))) + { + /* WERR_NOMEM is probably not the correct error, but until I figure out a better + one it will have to do */ + return WERR_NOMEM; + } + + return WERR_OK; +} + +static BOOL _eventlog_read_parse_line(char *line, Eventlog_entry *entry) +{ + char *start = NULL, *stop = NULL; + pstring temp; + int temp_len = 0, i; + + start = line; + + if(start == NULL || strlen(start) == 0) + return False; + if(!(stop = strchr(line, ':'))) + return False; + + DEBUG(6, ("_eventlog_read_parse_line: trying to parse [%s].\n", line)); + + if(0 == strncmp(start, "LEN", stop - start)) + { + /* This will get recomputed later anyway -- probably not necessary */ + entry->record.length = atoi(stop + 1); + } + else if(0 == strncmp(start, "RS1", stop - start)) + { + /* For now all these reserved entries seem to have the same value, + which can be hardcoded to int(1699505740) for now */ + entry->record.reserved1 = atoi(stop + 1); + } + else if(0 == strncmp(start, "RCN", stop - start)) + { + entry->record.record_number = atoi(stop + 1); + } + else if(0 == strncmp(start, "TMG", stop - start)) + { + entry->record.time_generated = atoi(stop + 1); + } + else if(0 == strncmp(start, "TMW", stop - start)) + { + entry->record.time_written = atoi(stop + 1); + } + else if(0 == strncmp(start, "EID", stop - start)) + { + entry->record.event_id = atoi(stop + 1); + } + else if(0 == strncmp(start, "ETP", stop - start)) + { + if(strstr(start, "ERROR")) + { + entry->record.event_type = EVENTLOG_ERROR_TYPE; + } + else if(strstr(start, "WARNING")) + { + entry->record.event_type = EVENTLOG_WARNING_TYPE; + } + else if(strstr(start, "INFO")) + { + entry->record.event_type = EVENTLOG_INFORMATION_TYPE; + } + else if(strstr(start, "AUDIT_SUCCESS")) + { + entry->record.event_type = EVENTLOG_AUDIT_SUCCESS; + } + else if(strstr(start, "AUDIT_FAILURE")) + { + entry->record.event_type = EVENTLOG_AUDIT_FAILURE; + } + else if(strstr(start, "SUCCESS")) + { + entry->record.event_type = EVENTLOG_SUCCESS; + } + else + { + /* some other eventlog type -- currently not defined in MSDN docs, so error out */ + return False; + } + } +/* + else if(0 == strncmp(start, "NST", stop - start)) + { + entry->record.num_strings = atoi(stop + 1); + } +*/ + else if(0 == strncmp(start, "ECT", stop - start)) + { + entry->record.event_category = atoi(stop + 1); + } + else if(0 == strncmp(start, "RS2", stop - start)) + { + entry->record.reserved2 = atoi(stop + 1); + } + else if(0 == strncmp(start, "CRN", stop - start)) + { + entry->record.closing_record_number = atoi(stop + 1); + } + else if(0 == strncmp(start, "USL", stop - start)) + { + entry->record.user_sid_length = atoi(stop + 1); + } + else if(0 == strncmp(start, "SRC", stop - start)) + { + memset(temp, 0, sizeof(temp)); + sscanf(stop+1, "%s", temp); + temp_len = strlen(temp); + rpcstr_push((void *)(entry->data_record.source_name), temp, + sizeof(entry->data_record.source_name), STR_TERMINATE); + entry->data_record.source_name_len = (strlen_w(entry->data_record.source_name)* 2) + 2; + } + else if(0 == strncmp(start, "SRN", stop - start)) + { + memset(temp, 0, sizeof(temp)); + sscanf(stop+1, "%s", temp); + temp_len = strlen(temp); + rpcstr_push((void *)(entry->data_record.computer_name), temp, + sizeof(entry->data_record.computer_name), STR_TERMINATE); + entry->data_record.computer_name_len = (strlen_w(entry->data_record.computer_name)* 2) + 2; + } + else if(0 == strncmp(start, "SID", stop - start)) + { + memset(temp, 0, sizeof(temp)); + sscanf(stop+1, "%s", temp); + temp_len = strlen(temp); + rpcstr_push((void *)(entry->data_record.sid), temp, + sizeof(entry->data_record.sid), STR_TERMINATE); + entry->record.user_sid_length = (strlen_w(entry->data_record.sid) * 2) + 2; + } + else if(0 == strncmp(start, "STR", stop - start)) + { + /* skip past initial ":" */ + stop++; + /* now skip any other leading whitespace */ + while(isspace(stop[0])) + stop++; + temp_len = strlen(stop); + memset(temp, 0, sizeof(temp)); + strncpy(temp, stop, temp_len); + rpcstr_push((void *)(entry->data_record.strings + entry->data_record.strings_len), + temp, + sizeof(entry->data_record.strings) - entry->data_record.strings_len, + STR_TERMINATE); + entry->data_record.strings_len += temp_len + 1; + fprintf(stderr, "Dumping strings:\n"); + for(i = 0; i < entry->data_record.strings_len; i++) + { + fputc((char)entry->data_record.strings[i], stderr); + } + fprintf(stderr, "\nDone\n"); + entry->record.num_strings++; + } + else if(0 == strncmp(start, "DAT", stop - start)) + { + /* Now that we're done processing the STR data, adjust the length to account for + unicode, then proceed with the DAT data. */ + entry->data_record.strings_len *= 2; + /* skip past initial ":" */ + stop++; + /* now skip any other leading whitespace */ + while(isspace(stop[0])) + stop++; + memset(temp, 0, sizeof(temp)); + temp_len = strlen(stop); + strncpy(temp, stop, temp_len); + rpcstr_push((void *)(entry->data_record.user_data), temp, + sizeof(entry->data_record.user_data), STR_TERMINATE); + entry->data_record.user_data_len = (strlen_w((const smb_ucs2_t *)entry->data_record.user_data) * 2) + 2; + } + else + { + /* some other eventlog entry -- not implemented, so dropping on the floor */ + DEBUG(10, ("Unknown entry [%s]. Ignoring.\n", line)); + /* For now return true so that we can keep on parsing this mess. Eventually + we will return False here. */ + return True; + } + return True; +} +/** + * Callout to read entries from the specified event log + * + * smbrun calling convention -- + * INPUT: + * where direction is either "forward" or "backward", the starting record is somewhere + * between the oldest_record and oldest_record+num_records, and the buffer size is the + * maximum size of the buffer that the client can accomodate. + * OUTPUT: A buffer containing a set of entries, one to a line, of the format: + * line type:line data + * These are the allowed line types: + * RS1:(uint32) - reserved. All M$ entries seem to have int(1699505740) for now + * RCN:(uint32) - record number of the record, however it may be calculated by the script + * TMG:(uint32) - time generated, seconds since January 1, 1970, 0000 UTC + * TMW:(uint32) - time written, seconds since January 1, 1970, 0000 UTC + * EID:(uint32) - eventlog source defined event identifier. If there's a stringfile for the event, it is an index into that + * ETP:(uint16) - eventlog type - one of ERROR, WARNING, INFO, AUDIT_SUCCESS, AUDIT_FAILURE + * ECT:(uint16) - event category - depends on the eventlog generator... + * RS2:(uint16) - reserved, make it 0000 + * CRN:(uint32) - reserved, make it 00000000 for now + * USL:(uint32) - user SID length. No sid? Make this 0. Must match SID below + * SRC:[(uint8)] - Name of the source, for example ccPwdSvc, in hex bytes. Can not be multiline. + * SRN:[(uint8)] - Name of the computer on which this is generated, the short hostname usually. + * SID:[(uint8)] - User sid if one exists. Must be present even if there is no SID. + * STR:[(uint8)] - String data. One string per line. Multiple strings can be specified using consecutive "STR" lines, + * up to a total aggregate string length of 1024 characters. + * DAT:[(uint8)] - The user-defined data portion of the event log. Can not be multiple lines. + */ +static BOOL _eventlog_read_eventlog_hook(Eventlog_info *info, Eventlog_entry *entry, const char *direction, int starting_record, int buffer_size, BOOL *eof) +{ + char *cmd = lp_eventlog_read_cmd(); + char **qlines; + pstring command; + int numlines = 0; + int ret; + int fd = -1; + int i; + + if(info == NULL) + return False; + + if(cmd == NULL || strlen(cmd) == 0) + { + DEBUG(0, ("Must define an \"eventlog read command\" entry in the config.\n")); + return False; + } + + slprintf(command, sizeof(command)-1, "%s \"%s\" %s %d %d \"%s\"", + cmd, + info->source_log_file_name, + direction, + starting_record, + buffer_size, + info->handle_string); + + DEBUG(10, ("Running [%s]\n", command)); + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); + + if(ret != 0) + { + if(fd != -1) + close(fd); + return False; + } + + qlines = fd_lines_load(fd, &numlines); + DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); + close(fd); + + if(numlines) + { + for(i = 0; i < numlines; i++) + { + DEBUGADD(10, ("Line[%d] = %s\n", i, qlines[i])); + _eventlog_read_parse_line(qlines[i], entry); + } + file_lines_free(qlines); + return True; + } + else + *eof = True; + + file_lines_free(qlines); + return False; +} + +static BOOL _eventlog_read_prepare_data_buffer(prs_struct *ps, + EVENTLOG_Q_READ_EVENTLOG *q_u, + EVENTLOG_R_READ_EVENTLOG *r_u, + Eventlog_entry *entry) +{ + uint8 *offset; + Eventlog_entry *new = NULL, *insert_point = NULL; + + new = PRS_ALLOC_MEM(ps, Eventlog_entry, 1); + if(new == NULL) + return False; + + entry->data_record.sid_padding = ((4 - ((entry->data_record.source_name_len + + entry->data_record.computer_name_len) % 4)) %4); + entry->data_record.data_padding = (4 - ((entry->data_record.strings_len + + entry->data_record.user_data_len) % 4)) % 4; + entry->record.length = sizeof(Eventlog_record); + entry->record.length += entry->data_record.source_name_len; + entry->record.length += entry->data_record.computer_name_len; + if(entry->record.user_sid_length == 0) + { + /* Should not pad to a DWORD boundary for writing out the sid if there is + no SID, so just propagate the padding to pad the data */ + entry->data_record.data_padding += entry->data_record.sid_padding; + entry->data_record.sid_padding = 0; + } + DEBUG(10, ("sid_padding is [%d].\n", entry->data_record.sid_padding)); + DEBUG(10, ("data_padding is [%d].\n", entry->data_record.data_padding)); + + entry->record.length += entry->data_record.sid_padding; + entry->record.length += entry->record.user_sid_length; + entry->record.length += entry->data_record.strings_len; + entry->record.length += entry->data_record.user_data_len; + entry->record.length += entry->data_record.data_padding; + /* need another copy of length at the end of the data */ + entry->record.length += sizeof(entry->record.length); + DEBUG(10, ("entry->record.length is [%d].\n", entry->record.length)); + entry->data = PRS_ALLOC_MEM(ps, uint8, entry->record.length - sizeof(Eventlog_record) - sizeof(entry->record.length)); + if(entry->data == NULL) + return False; + offset = entry->data; + memcpy(offset, &(entry->data_record.source_name), entry->data_record.source_name_len); + offset += entry->data_record.source_name_len; + memcpy(offset, &(entry->data_record.computer_name), entry->data_record.computer_name_len); + offset += entry->data_record.computer_name_len; + /* SID needs to be DWORD-aligned */ + offset += entry->data_record.sid_padding; + entry->record.user_sid_offset = sizeof(Eventlog_record) + (offset - entry->data); + memcpy(offset, &(entry->data_record.sid), entry->record.user_sid_length); + offset += entry->record.user_sid_length; + /* Now do the strings */ + entry->record.string_offset = sizeof(Eventlog_record) + (offset - entry->data); + memcpy(offset, &(entry->data_record.strings), entry->data_record.strings_len); + offset += entry->data_record.strings_len; + /* Now do the data */ + entry->record.data_length = entry->data_record.user_data_len; + entry->record.data_offset = sizeof(Eventlog_record) + (offset - entry->data); + memcpy(offset, &(entry->data_record.user_data), entry->data_record.user_data_len); + offset += entry->data_record.user_data_len; + /* Now that we've massaged the current entry, copy it into the new entry and add it + to end of the list */ + insert_point=r_u->entry; + + if (NULL == insert_point) + { + r_u->entry = new; + new->next = NULL; + } + else + { + while ((NULL != insert_point->next)) + { + insert_point=insert_point->next; + } + new->next = NULL; + insert_point->next = new; + } + + memcpy(&(new->record), &entry->record, sizeof(Eventlog_record)); + memcpy(&(new->data_record), &entry->data_record, sizeof(Eventlog_data_record)); + new->data = entry->data; + + r_u->num_records++; + r_u->num_bytes_in_resp += entry->record.length; + + return True; +} + +WERROR _eventlog_read_eventlog(pipes_struct *p, + EVENTLOG_Q_READ_EVENTLOG *q_u, + EVENTLOG_R_READ_EVENTLOG *r_u) +{ + Eventlog_info *info = NULL; + POLICY_HND *handle; + Eventlog_entry entry; + BOOL eof = False; + const char *direction = ""; + int starting_record; + prs_struct *ps; + + if(!q_u || !r_u) + return WERR_NOMEM; + + handle = &(q_u->handle); + info = find_eventlog_info_by_hnd(p, handle); + ps = &p->out_data.rdata; + /* Rather than checking the EVENTLOG_SEQUENTIAL_READ/EVENTLOG_SEEK_READ flags, + we'll just go to the offset specified in the request, or the oldest entry + if no offset is specified */ + if(q_u->offset > 0) + starting_record = q_u->offset; + else + starting_record = info->oldest_entry; + if(q_u->flags & EVENTLOG_FORWARDS_READ) + direction = "forward"; + else if(q_u->flags & EVENTLOG_BACKWARDS_READ) + direction = "backward"; + + do + { + ZERO_STRUCT(entry); + if(!(_eventlog_read_eventlog_hook(info, &entry, direction, starting_record, q_u->max_read_size, &eof))) + { + if(eof == False) + return WERR_NOMEM; + } + if(eof == False) + { + /* only if the read hook returned data */ + if(!(_eventlog_read_prepare_data_buffer(ps, q_u, r_u, &entry))) + return WERR_NOMEM; + DEBUG(10, ("_eventlog_read_eventlog: read [%d] bytes out of a max of [%d].\n", + r_u->num_bytes_in_resp, + q_u->max_read_size)); + } + } while((r_u->num_bytes_in_resp <= q_u->max_read_size) && (eof != True)); + + return WERR_OK; +} +/** + * Callout to clear (and optionally backup) a specified event log + * + * smbrun calling convention -- + * INPUT: + * OUTPUT: A single line with the string "SUCCESS" if the command succeeded. + * Otherwise it is assumed to have failed + * + * INPUT: + * OUTPUT: A single line with the string "SUCCESS" if the command succeeded. + * Otherwise it is assumed to have failed + * The given log is copied to that location on the server. See comments for + * eventlog_io_q_clear_eventlog for info about odd file name behavior + */ +static BOOL _eventlog_clear_eventlog_hook(Eventlog_info *info, + pstring backup_file_name) +{ + char *cmd = lp_eventlog_clear_cmd(); + char **qlines; + pstring command; + int numlines = 0; + int ret; + int fd = -1; + + if(cmd == NULL || strlen(cmd) == 0) + { + DEBUG(0, ("Must define an \"eventlog clear command\" entry in the config.\n")); + return False; + } + + memset(command, 0, sizeof(command)); + if(strlen(backup_file_name) > 0) + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\"", + cmd, + info->source_log_file_name, + backup_file_name, + info->handle_string); + else + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", + cmd, + info->source_log_file_name, + info->handle_string); + + DEBUG(10, ("Running [%s]\n", command)); + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); + + if(ret != 0) + { + if(fd != -1) + close(fd); + return False; + } + + qlines = fd_lines_load(fd, &numlines); + DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); + close(fd); + + if(numlines) + { + DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); + if(0 == strncmp(qlines[0], "SUCCESS", strlen("SUCCESS"))) + { + DEBUGADD(10, ("Able to clear [%s].\n", info->source_log_file_name)); + file_lines_free(qlines); + return True; + } + } + + file_lines_free(qlines); + return False; +} + +WERROR _eventlog_clear_eventlog(pipes_struct *p, + EVENTLOG_Q_CLEAR_EVENTLOG *q_u, + EVENTLOG_R_CLEAR_EVENTLOG *r_u) +{ + Eventlog_info *info = NULL; + pstring backup_file_name; + POLICY_HND *handle = NULL; + + if(!q_u || !r_u) + return WERR_NOMEM; + + handle = &(q_u->handle); + info = find_eventlog_info_by_hnd(p, handle); + memset(backup_file_name, 0, sizeof(backup_file_name)); + + if(q_u->backup_file_ptr != 0) + { + unistr2_to_ascii(backup_file_name, &(q_u->backup_file), sizeof(backup_file_name)); + DEBUG(10, ("_eventlog_clear_eventlog: Using [%s] as the backup file name for log [%s].", + backup_file_name, + info->source_log_file_name)); + } + else + { + /* if backup_file == NULL, do not back up the log before clearing it */ + DEBUG(10, ("_eventlog_clear_eventlog: clearing [%s] log without making a backup.", + info->source_log_file_name)); + } + + if(!(_eventlog_clear_eventlog_hook(info, backup_file_name))) + return WERR_BADFILE; + + return WERR_OK; +} diff --git a/source3/rpc_server/srv_lsa_ds_nt.c b/source3/rpc_server/srv_lsa_ds_nt.c index d0b7a299be..b410af8ded 100644 --- a/source3/rpc_server/srv_lsa_ds_nt.c +++ b/source3/rpc_server/srv_lsa_ds_nt.c @@ -46,6 +46,9 @@ static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN return NT_STATUS_NO_MEMORY; } + get_mydnsdomname(dnsdomain); + strlower_m(dnsdomain); + switch ( lp_server_role() ) { case ROLE_STANDALONE: basic->machine_role = DSROLE_STANDALONE_SRV; @@ -58,16 +61,12 @@ static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN basic->flags = DSROLE_PRIMARY_DS_RUNNING|DSROLE_PRIMARY_DS_MIXED_MODE; if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) ) basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT; - get_mydnsdomname(dnsdomain); - strlower_m(dnsdomain); break; case ROLE_DOMAIN_PDC: basic->machine_role = DSROLE_PDC; basic->flags = DSROLE_PRIMARY_DS_RUNNING|DSROLE_PRIMARY_DS_MIXED_MODE; if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) ) basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT; - get_mydnsdomname(dnsdomain); - strlower_m(dnsdomain); break; } diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 705b629732..a45a7eebf6 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -299,7 +299,7 @@ static BOOL api_net_logon_ctrl(pipes_struct *p) r_u.status = _net_logon_ctrl(p, &q_u, &r_u); if(!net_io_r_logon_ctrl("", &r_u, rdata, 0)) { - DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL2.\n")); + DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL.\n")); return False; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 01e91ce6c5..ab21f60902 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -765,6 +765,7 @@ BOOL check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, for ( i=0; pipe_names[i].client_pipe; i++ ) { + DEBUG(10,("checking %s\n", pipe_names[i].client_pipe)); if ( strequal(pipe_names[i].client_pipe, pname) && (abstract->version == pipe_names[i].abstr_syntax.version) && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(struct uuid)) == 0) @@ -1631,6 +1632,12 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) case PI_NETDFS: netdfs_get_pipe_fns( &cmds, &n_cmds ); break; + case PI_SVCCTL: + svcctl_get_pipe_fns( &cmds, &n_cmds ); + break; + case PI_EVENTLOG: + eventlog_get_pipe_fns( &cmds, &n_cmds ); + break; #ifdef DEVELOPER case PI_ECHO: echo_get_pipe_fns( &cmds, &n_cmds ); diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index b780be0aff..b2b3920e9e 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -63,8 +63,8 @@ static BOOL api_reg_close(pipes_struct *p) static BOOL api_reg_open_hklm(pipes_struct *p) { - REG_Q_OPEN_HKLM q_u; - REG_R_OPEN_HKLM r_u; + REG_Q_OPEN_HIVE q_u; + REG_R_OPEN_HIVE r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -72,12 +72,12 @@ static BOOL api_reg_open_hklm(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the reg open */ - if(!reg_io_q_open_hklm("", &q_u, data, 0)) + if(!reg_io_q_open_hive("", &q_u, data, 0)) return False; r_u.status = _reg_open_hklm(p, &q_u, &r_u); - if(!reg_io_r_open_hklm("", &r_u, rdata, 0)) + if(!reg_io_r_open_hive("", &r_u, rdata, 0)) return False; return True; @@ -89,8 +89,8 @@ static BOOL api_reg_open_hklm(pipes_struct *p) static BOOL api_reg_open_hku(pipes_struct *p) { - REG_Q_OPEN_HKU q_u; - REG_R_OPEN_HKU r_u; + REG_Q_OPEN_HIVE q_u; + REG_R_OPEN_HIVE r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -98,12 +98,12 @@ static BOOL api_reg_open_hku(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the reg open */ - if(!reg_io_q_open_hku("", &q_u, data, 0)) + if(!reg_io_q_open_hive("", &q_u, data, 0)) return False; r_u.status = _reg_open_hku(p, &q_u, &r_u); - if(!reg_io_r_open_hku("", &r_u, rdata, 0)) + if(!reg_io_r_open_hive("", &r_u, rdata, 0)) return False; return True; @@ -115,8 +115,8 @@ static BOOL api_reg_open_hku(pipes_struct *p) static BOOL api_reg_open_hkcr(pipes_struct *p) { - REG_Q_OPEN_HKCR q_u; - REG_R_OPEN_HKCR r_u; + REG_Q_OPEN_HIVE q_u; + REG_R_OPEN_HIVE r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -124,12 +124,12 @@ static BOOL api_reg_open_hkcr(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the reg open */ - if(!reg_io_q_open_hkcr("", &q_u, data, 0)) + if(!reg_io_q_open_hive("", &q_u, data, 0)) return False; r_u.status = _reg_open_hkcr(p, &q_u, &r_u); - if(!reg_io_r_open_hkcr("", &r_u, rdata, 0)) + if(!reg_io_r_open_hive("", &r_u, rdata, 0)) return False; return True; @@ -215,6 +215,32 @@ static BOOL api_reg_shutdown(pipes_struct *p) return True; } +/******************************************************************* + api_reg_shutdown_ex + ********************************************************************/ + +static BOOL api_reg_shutdown_ex(pipes_struct *p) +{ + REG_Q_SHUTDOWN_EX q_u; + REG_R_SHUTDOWN_EX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the reg shutdown ex */ + if(!reg_io_q_shutdown_ex("", &q_u, data, 0)) + return False; + + r_u.status = _reg_shutdown_ex(p, &q_u, &r_u); + + if(!reg_io_r_shutdown_ex("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* api_reg_abort_shutdown ********************************************************************/ @@ -268,25 +294,25 @@ static BOOL api_reg_query_key(pipes_struct *p) } /******************************************************************* - api_reg_unknown_1a + api_reg_getversion ********************************************************************/ -static BOOL api_reg_unknown_1a(pipes_struct *p) +static BOOL api_reg_getversion(pipes_struct *p) { - REG_Q_UNKNOWN_1A q_u; - REG_R_UNKNOWN_1A r_u; + REG_Q_GETVERSION q_u; + REG_R_GETVERSION r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!reg_io_q_unknown_1a("", &q_u, data, 0)) + if(!reg_io_q_getversion("", &q_u, data, 0)) return False; - r_u.status = _reg_unknown_1a(p, &q_u, &r_u); + r_u.status = _reg_getversion(p, &q_u, &r_u); - if(!reg_io_r_unknown_1a("", &r_u, rdata, 0)) + if(!reg_io_r_getversion("", &r_u, rdata, 0)) return False; return True; @@ -383,8 +409,9 @@ static struct api_struct api_reg_cmds[] = { "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key }, { "REG_INFO" , REG_INFO , api_reg_info }, { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, + { "REG_SHUTDOWN_EX" , REG_SHUTDOWN_EX , api_reg_shutdown_ex }, { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, - { "REG_UNKNOWN_1A" , REG_UNKNOWN_1A , api_reg_unknown_1a }, + { "REG_GETVERSION" , REG_GETVERSION , api_reg_getversion }, { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key } }; diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index c11e0d59a0..f0d831cc6a 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -5,7 +5,7 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997. * Copyright (C) Paul Ashton 1997. * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Gerald Carter 2002. + * Copyright (C) Gerald Carter 2002-2005. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -291,7 +291,7 @@ WERROR _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) /******************************************************************* ********************************************************************/ -WERROR _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_u) +WERROR _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) { return open_registry_key( p, &r_u->pol, NULL, KEY_HKLM, 0x0 ); } @@ -299,7 +299,7 @@ WERROR _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HKLM *q_u, REG_R_OPEN_HKLM *r_ /******************************************************************* ********************************************************************/ -WERROR _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HKCR *q_u, REG_R_OPEN_HKCR *r_u) +WERROR _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) { return open_registry_key( p, &r_u->pol, NULL, KEY_HKCR, 0x0 ); } @@ -307,7 +307,7 @@ WERROR _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HKCR *q_u, REG_R_OPEN_HKCR *r_ /******************************************************************* ********************************************************************/ -WERROR _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HKU *q_u, REG_R_OPEN_HKU *r_u) +WERROR _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) { return open_registry_key( p, &r_u->pol, NULL, KEY_HKU, 0x0 ); } @@ -328,7 +328,7 @@ WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY if ( !key ) return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ - rpcstr_pull(name,q_u->uni_name.buffer,sizeof(name),q_u->uni_name.uni_str_len*2,0); + rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); result = open_registry_key( p, &pol, key, name, 0x0 ); @@ -362,7 +362,7 @@ WERROR _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); - rpcstr_pull(name, q_u->uni_type.buffer, sizeof(name), q_u->uni_type.uni_str_len*2, 0); + rpcstr_pull(name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0); DEBUG(5,("reg_info: looking up value: [%s]\n", name)); @@ -439,7 +439,7 @@ WERROR _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) out: - new_init_reg_r_info(q_u->ptr_buf, r_u, val, status); + init_reg_r_info(q_u->ptr_buf, r_u, val, status); regval_ctr_destroy( ®vals ); free_registry_value( val ); @@ -485,22 +485,22 @@ WERROR _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_ /***************************************************************************** - Implementation of REG_UNKNOWN_1A + Implementation of REG_GETVERSION ****************************************************************************/ -WERROR _reg_unknown_1a(pipes_struct *p, REG_Q_UNKNOWN_1A *q_u, REG_R_UNKNOWN_1A *r_u) +WERROR _reg_getversion(pipes_struct *p, REG_Q_GETVERSION *q_u, REG_R_GETVERSION *r_u) { WERROR status = WERR_OK; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - DEBUG(5,("_reg_unknown_1a: Enter\n")); + DEBUG(5,("_reg_getversion: Enter\n")); if ( !regkey ) return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ r_u->unknown = 0x00000005; /* seems to be consistent...no idea what it means */ - DEBUG(5,("_reg_unknown_1a: Exit\n")); + DEBUG(5,("_reg_getversion: Exit\n")); return status; } @@ -593,82 +593,131 @@ done: WERROR _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) { - WERROR status = WERR_OK; + REG_Q_SHUTDOWN_EX q_u_ex; + REG_R_SHUTDOWN_EX r_u_ex; + + /* copy fields (including stealing memory) */ + + q_u_ex.server = q_u->server; + q_u_ex.message = q_u->message; + q_u_ex.timeout = q_u->timeout; + q_u_ex.force = q_u->force; + q_u_ex.reboot = q_u->reboot; + q_u_ex.reason = 0x0; /* don't care for now */ + + /* thunk down to _reg_shutdown_ex() (just returns a status) */ + + return _reg_shutdown_ex( p, &q_u_ex, &r_u_ex ); +} + +/******************************************************************* + reg_shutdown_ex + ********************************************************************/ + +#define SHUTDOWN_R_STRING "-r" +#define SHUTDOWN_F_STRING "-f" + + +WERROR _reg_shutdown_ex(pipes_struct *p, REG_Q_SHUTDOWN_EX *q_u, REG_R_SHUTDOWN_EX *r_u) +{ pstring shutdown_script; - UNISTR2 unimsg = q_u->uni_msg; pstring message; pstring chkmsg; fstring timeout; + fstring reason; fstring r; fstring f; + int ret; + BOOL can_shutdown; - /* message */ - rpcstr_pull (message, unimsg.buffer, sizeof(message), unimsg.uni_str_len*2,0); - /* security check */ + + pstrcpy(shutdown_script, lp_shutdown_script()); + + if ( !*shutdown_script ) + return WERR_ACCESS_DENIED; + + /* pull the message string and perform necessary sanity checks on it */ + + pstrcpy( message, "" ); + if ( q_u->message ) { + UNISTR2 *msg_string = q_u->message->string; + + rpcstr_pull( message, msg_string->buffer, sizeof(message), msg_string->uni_str_len*2, 0 ); + } alpha_strcpy (chkmsg, message, NULL, sizeof(message)); - /* timeout */ + fstr_sprintf(timeout, "%d", q_u->timeout); - /* reboot */ fstr_sprintf(r, (q_u->reboot) ? SHUTDOWN_R_STRING : ""); - /* force */ fstr_sprintf(f, (q_u->force) ? SHUTDOWN_F_STRING : ""); + fstr_sprintf( reason, "%d", q_u->reason ); - pstrcpy(shutdown_script, lp_shutdown_script()); - - if(*shutdown_script) { - int shutdown_ret; - SE_PRIV se_shutdown = SE_REMOTE_SHUTDOWN; - BOOL can_shutdown; + all_string_sub( shutdown_script, "%z", chkmsg, sizeof(shutdown_script) ); + all_string_sub( shutdown_script, "%t", timeout, sizeof(shutdown_script) ); + all_string_sub( shutdown_script, "%r", r, sizeof(shutdown_script) ); + all_string_sub( shutdown_script, "%f", f, sizeof(shutdown_script) ); + all_string_sub( shutdown_script, "%x", reason, sizeof(shutdown_script) ); - can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_shutdown ); + can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_remote_shutdown ); /********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/ - if ( can_shutdown ) + + /* IF someone has privs, run the shutdown script as root. OTHERWISE run it as not root + Take the error return from the script and provide it as the Windows return code. */ + + if ( can_shutdown ) { + DEBUG(3,("_reg_shutdown_ex: Privilege Check is OK for shutdown \n")); become_root(); - all_string_sub(shutdown_script, "%m", chkmsg, sizeof(shutdown_script)); - all_string_sub(shutdown_script, "%t", timeout, sizeof(shutdown_script)); - all_string_sub(shutdown_script, "%r", r, sizeof(shutdown_script)); - all_string_sub(shutdown_script, "%f", f, sizeof(shutdown_script)); - shutdown_ret = smbrun(shutdown_script,NULL); - DEBUG(3,("_reg_shutdown: Running the command `%s' gave %d\n",shutdown_script,shutdown_ret)); + } + + ret = smbrun( shutdown_script, NULL ); + + DEBUG(3,("_reg_shutdown_ex: Running the command `%s' gave %d\n", + shutdown_script, ret)); + if ( can_shutdown ) unbecome_root(); + /********** END SeRemoteShutdownPrivilege BLOCK **********/ - } - return status; + return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; } + + + /******************************************************************* reg_abort_shutdwon ********************************************************************/ WERROR _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABORT_SHUTDOWN *r_u) { - WERROR status = WERR_OK; pstring abort_shutdown_script; + int ret; + BOOL can_shutdown; pstrcpy(abort_shutdown_script, lp_abort_shutdown_script()); - if(*abort_shutdown_script) { - int abort_shutdown_ret; - SE_PRIV se_shutdown = SE_REMOTE_SHUTDOWN; - BOOL can_shutdown; + if ( !*abort_shutdown_script ) + return WERR_ACCESS_DENIED; - can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_shutdown ); + can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_remote_shutdown ); /********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/ + if ( can_shutdown ) become_root(); - abort_shutdown_ret = smbrun(abort_shutdown_script,NULL); - DEBUG(3,("_reg_abort_shutdown: Running the command `%s' gave %d\n",abort_shutdown_script,abort_shutdown_ret)); + + ret = smbrun( abort_shutdown_script, NULL ); + + DEBUG(3,("_reg_abort_shutdown: Running the command `%s' gave %d\n", + abort_shutdown_script, ret)); + if ( can_shutdown ) unbecome_root(); - /********** END SeRemoteShutdownPrivilege BLOCK **********/ - } + /********** END SeRemoteShutdownPrivilege BLOCK **********/ - return status; + return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; } /******************************************************************* diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3c611be9ac..2e84a7b909 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1491,10 +1491,10 @@ static void convert_to_openprinterex(TALLOC_CTX *ctx, SPOOL_Q_OPEN_PRINTER_EX *q DEBUG(8,("convert_to_openprinterex\n")); - q_u_ex->printername_ptr = q_u->printername_ptr; - - if (q_u->printername_ptr) - copy_unistr2(&q_u_ex->printername, &q_u->printername); + if ( q_u->printername ) { + q_u_ex->printername = TALLOC_P( ctx, UNISTR2 ); + copy_unistr2(q_u_ex->printername, q_u->printername); + } copy_printer_default(ctx, &q_u_ex->printer_default, &q_u->printer_default); } @@ -1588,7 +1588,6 @@ WERROR _spoolss_open_printer(pipes_struct *p, SPOOL_Q_OPEN_PRINTER *q_u, SPOOL_R WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, SPOOL_R_OPEN_PRINTER_EX *r_u) { - UNISTR2 *printername = NULL; PRINTER_DEFAULT *printer_default = &q_u->printer_default; POLICY_HND *handle = &r_u->handle; @@ -1597,15 +1596,13 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, struct current_user user; Printer_entry *Printer=NULL; - if (q_u->printername_ptr != 0) - printername = &q_u->printername; - - if (printername == NULL) + if ( !q_u->printername ) return WERR_INVALID_PRINTER_NAME; /* some sanity check because you can open a printer or a print server */ /* aka: \\server\printer or \\server */ - unistr2_to_ascii(name, printername, sizeof(name)-1); + + unistr2_to_ascii(name, q_u->printername, sizeof(name)-1); DEBUGADD(3,("checking name: %s\n",name)); @@ -7595,7 +7592,7 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ WERROR _spoolss_addprinterex( pipes_struct *p, SPOOL_Q_ADDPRINTEREX *q_u, SPOOL_R_ADDPRINTEREX *r_u) { - UNISTR2 *uni_srv_name = &q_u->server_name; + UNISTR2 *uni_srv_name = q_u->server_name; uint32 level = q_u->level; SPOOL_PRINTER_INFO_LEVEL *info = &q_u->info; DEVICEMODE *devmode = q_u->devmode_ctr.devmode; diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c new file mode 100644 index 0000000000..85fb9f9ce3 --- /dev/null +++ b/source3/rpc_server/srv_svcctl.c @@ -0,0 +1,294 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Gerald Carter 2005. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_close_service(pipes_struct *p) +{ + SVCCTL_Q_CLOSE_SERVICE q_u; + SVCCTL_R_CLOSE_SERVICE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_close_service("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_close_service(p, &q_u, &r_u); + + if(!svcctl_io_r_close_service("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_open_scmanager(pipes_struct *p) +{ + SVCCTL_Q_OPEN_SCMANAGER q_u; + SVCCTL_R_OPEN_SCMANAGER r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_open_scmanager("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_open_scmanager(p, &q_u, &r_u); + + if(!svcctl_io_r_open_scmanager("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_open_service(pipes_struct *p) +{ + SVCCTL_Q_OPEN_SERVICE q_u; + SVCCTL_R_OPEN_SERVICE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_open_service("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_open_service(p, &q_u, &r_u); + + if(!svcctl_io_r_open_service("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_get_display_name(pipes_struct *p) +{ + SVCCTL_Q_GET_DISPLAY_NAME q_u; + SVCCTL_R_GET_DISPLAY_NAME r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_get_display_name("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_get_display_name(p, &q_u, &r_u); + + if(!svcctl_io_r_get_display_name("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_query_status(pipes_struct *p) +{ + SVCCTL_Q_QUERY_STATUS q_u; + SVCCTL_R_QUERY_STATUS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_query_status("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_query_status(p, &q_u, &r_u); + + if(!svcctl_io_r_query_status("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_enum_services_status(pipes_struct *p) +{ + SVCCTL_Q_ENUM_SERVICES_STATUS q_u; + SVCCTL_R_ENUM_SERVICES_STATUS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_enum_services_status("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_enum_services_status(p, &q_u, &r_u); + + if(!svcctl_io_r_enum_services_status("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_enum_dependent_services(pipes_struct *p) +{ + SVCCTL_Q_ENUM_DEPENDENT_SERVICES q_u; + SVCCTL_R_ENUM_DEPENDENT_SERVICES r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_enum_dependent_services("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_enum_dependent_services(p, &q_u, &r_u); + + if(!svcctl_io_r_enum_dependent_services("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_start_service(pipes_struct *p) +{ + SVCCTL_Q_START_SERVICE q_u; + SVCCTL_R_START_SERVICE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_start_service("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_start_service(p, &q_u, &r_u); + + if(!svcctl_io_r_start_service("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_control_service(pipes_struct *p) +{ + SVCCTL_Q_CONTROL_SERVICE q_u; + SVCCTL_R_CONTROL_SERVICE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_control_service("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_control_service(p, &q_u, &r_u); + + if(!svcctl_io_r_control_service("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_query_service_config(pipes_struct *p) +{ + SVCCTL_Q_QUERY_SERVICE_CONFIG q_u; + SVCCTL_R_QUERY_SERVICE_CONFIG r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_query_service_config("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_query_service_config(p, &q_u, &r_u); + + if(!svcctl_io_r_query_service_config("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + \PIPE\svcctl commands + ********************************************************************/ + +static struct api_struct api_svcctl_cmds[] = +{ + { "SVCCTL_CLOSE_SERVICE" , SVCCTL_CLOSE_SERVICE , api_svcctl_close_service }, + { "SVCCTL_OPEN_SCMANAGER_W" , SVCCTL_OPEN_SCMANAGER_W , api_svcctl_open_scmanager }, + { "SVCCTL_OPEN_SERVICE_W" , SVCCTL_OPEN_SERVICE_W , api_svcctl_open_service }, + { "SVCCTL_GET_DISPLAY_NAME" , SVCCTL_GET_DISPLAY_NAME , api_svcctl_get_display_name }, + { "SVCCTL_QUERY_STATUS" , SVCCTL_QUERY_STATUS , api_svcctl_query_status }, + { "SVCCTL_QUERY_SERVICE_CONFIG_W", SVCCTL_QUERY_SERVICE_CONFIG_W, api_svcctl_query_service_config }, + { "SVCCTL_ENUM_SERVICES_STATUS_W", SVCCTL_ENUM_SERVICES_STATUS_W, api_svcctl_enum_services_status }, + { "SVCCTL_ENUM_DEPENDENT_SERVICES_W", SVCCTL_ENUM_DEPENDENT_SERVICES_W, api_svcctl_enum_dependent_services }, + { "SVCCTL_START_SERVICE_W" , SVCCTL_START_SERVICE_W , api_svcctl_start_service }, + { "SVCCTL_CONTROL_SERVICE" , SVCCTL_CONTROL_SERVICE , api_svcctl_control_service } +}; + +void svcctl_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_svcctl_cmds; + *n_fns = sizeof(api_svcctl_cmds) / sizeof(struct api_struct); +} + +NTSTATUS rpc_svcctl_init(void) +{ + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "svcctl", "ntsvcs", api_svcctl_cmds, + sizeof(api_svcctl_cmds) / sizeof(struct api_struct)); +} diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c new file mode 100644 index 0000000000..19244d2208 --- /dev/null +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -0,0 +1,291 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Gerald (Jerry) Carter 2005 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +/* + * sertup the \PIPE\svcctl db API + */ + +static TDB_CONTEXT *svcctl_tdb; /* used for share security descriptors */ + +#define SCVCTL_DATABASE_VERSION_V1 1 + +/******************************************************************** +********************************************************************/ + +static BOOL init_svcctl_db( void ) +{ + static pid_t local_pid; + const char *vstring = "INFO/version"; + + /* see if we've already opened the tdb */ + + if (svcctl_tdb && local_pid == sys_getpid()) + return True; + + /* so open it */ + if ( !(svcctl_tdb = tdb_open_log(lock_path("svcctl.tdb"), 0, TDB_DEFAULT, + O_RDWR|O_CREAT, 0600))) + { + DEBUG(0,("Failed to open svcctl database %s (%s)\n", + lock_path("svcctl.tdb"), strerror(errno) )); + return False; + } + + local_pid = sys_getpid(); + + /***** BEGIN Check the tdb version ******/ + + tdb_lock_bystring(svcctl_tdb, vstring, 0); + + if ( tdb_fetch_int32(svcctl_tdb, vstring) != SCVCTL_DATABASE_VERSION_V1 ) + tdb_store_int32(svcctl_tdb, vstring, SCVCTL_DATABASE_VERSION_V1); + + tdb_unlock_bystring(svcctl_tdb, vstring); + + /***** END Check the tdb version ******/ + + return True; +} + +/******************************************************************** + TODO + (a) get and set security descriptors on services + (b) read and write QUERY_SERVICE_CONFIG structures + (c) create default secdesc objects for services and SCM + (d) check access control masks with se_access_check() + (e) implement SERVICE * for associating with open handles +********************************************************************/ + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVCCTL_R_OPEN_SCMANAGER *r_u) +{ + /* just fake it for now */ + + if ( !create_policy_hnd( p, &r_u->handle, NULL, NULL ) ) + return WERR_ACCESS_DENIED; + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_R_OPEN_SERVICE *r_u) +{ + fstring service; + + rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); + + /* can only be called on service name (not displayname) */ + + if ( !(strequal( service, "NETLOGON") || strequal(service, "Spooler")) ) + return WERR_NO_SUCH_SERVICE; + + if ( !create_policy_hnd( p, &r_u->handle, NULL, NULL ) ) + return WERR_ACCESS_DENIED; + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_close_service(pipes_struct *p, SVCCTL_Q_CLOSE_SERVICE *q_u, SVCCTL_R_CLOSE_SERVICE *r_u) +{ + if ( !close_policy_hnd( p, &q_u->handle ) ) + return WERR_BADFID; + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, SVCCTL_R_GET_DISPLAY_NAME *r_u) +{ + fstring service; + fstring displayname; + + rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); + + DEBUG(10,("_svcctl_get_display_name: service name [%s]\n", service)); + + if ( !strequal( service, "NETLOGON" ) ) + return WERR_ACCESS_DENIED; + + fstrcpy( displayname, "Net Logon"); + init_svcctl_r_get_display_name( r_u, displayname ); + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_R_QUERY_STATUS *r_u) +{ + + r_u->svc_status.type = 0x0110; + r_u->svc_status.state = 0x0004; + r_u->svc_status.controls_accepted = 0x0005; + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, SVCCTL_R_ENUM_SERVICES_STATUS *r_u) +{ + ENUM_SERVICES_STATUS *services = NULL; + uint32 num_services = 0; + int i = 0; + size_t buffer_size; + WERROR result = WERR_OK; + + /* num_services = str_list_count( lp_enable_svcctl() ); */ + num_services = 2; + + if ( !(services = TALLOC_ARRAY( p->mem_ctx, ENUM_SERVICES_STATUS, num_services )) ) + return WERR_NOMEM; + + DEBUG(8,("_svcctl_enum_services_status: Enumerating %d services\n", num_services)); + + init_unistr( &services[i].servicename, "Spooler" ); + init_unistr( &services[i].displayname, "Spooler" ); + + services[i].status.type = 0x110; + services[i].status.controls_accepted = 0x0; + services[i].status.win32_exit_code = 0x0; + services[i].status.service_exit_code = 0x0; + services[i].status.check_point = 0x0; + services[i].status.wait_hint = 0x0; + if ( !lp_disable_spoolss() ) + services[i].status.state = SVCCTL_RUNNING; + else + services[i].status.state = SVCCTL_STOPPED; + + i++; + + init_unistr( &services[i].servicename, "Netlogon" ); + init_unistr( &services[i].displayname, "Net Logon" ); + + services[i].status.type = 0x20; + services[i].status.controls_accepted = 0x0; + services[i].status.win32_exit_code = 0x0; + services[i].status.service_exit_code = 0x0; + services[i].status.check_point = 0x0; + services[i].status.wait_hint = 0x0; + if ( lp_servicenumber("NETLOGON") != -1 ) + services[i].status.state = SVCCTL_RUNNING; + else + services[i].status.state = SVCCTL_STOPPED; + + buffer_size = 0; + for (i=0; i q_u->buffer_size ) { + num_services = 0; + result = WERR_MORE_DATA; + } + + /* we have to set the outgoing buffer size to the same as the + incoming buffer size (even in the case of failure */ + + rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); + + if ( W_ERROR_IS_OK(result) ) { + for ( i=0; ibuffer, 0 ); + } + + r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size; + r_u->returned = num_services; + + if ( !(r_u->resume = TALLOC_P( p->mem_ctx, uint32 )) ) + return WERR_NOMEM; + + *r_u->resume = 0x0; + + return result; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCTL_R_START_SERVICE *r_u) +{ + return WERR_ACCESS_DENIED; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, SVCCTL_R_CONTROL_SERVICE *r_u) +{ + return WERR_ACCESS_DENIED; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_enum_dependent_services( pipes_struct *p, SVCCTL_Q_ENUM_DEPENDENT_SERVICES *q_u, SVCCTL_R_ENUM_DEPENDENT_SERVICES *r_u ) +{ + + /* we have to set the outgoing buffer size to the same as the + incoming buffer size (even in the case of failure */ + + rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); + + r_u->needed = q_u->buffer_size; + + /* no dependent services...basically a stub function */ + r_u->returned = 0; + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CONFIG *q_u, SVCCTL_R_QUERY_SERVICE_CONFIG *r_u ) +{ + + /* we have to set the outgoing buffer size to the same as the + incoming buffer size (even in the case of failure */ + + r_u->needed = q_u->buffer_size; + + /* no dependent services...basically a stub function */ + + return WERR_ACCESS_DENIED; +} + + -- cgit From 899ade0e62ebbfd6994101c45bb56d20357535af Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 24 Mar 2005 00:01:56 +0000 Subject: r6016: Give access only to root and Domain Users (This used to be commit d3557ed4b7c4d58a50cc6041c06cc4eff5ef659a) --- source3/rpc_server/srv_srvsvc_nt.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index a00409afc8..5dd2e6e47f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1354,13 +1354,13 @@ net sess del WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SESS_DEL *r_u) { - struct current_user user; struct sessionid *session_list; + struct current_user user; int num_sessions, snum, ret; fstring username; fstring machine; - SE_PRIV se_diskop = SE_DISK_OPERATOR; /* Is disk op appropriate here ? JRA. */ - BOOL is_disk_op = False; + /* SE_PRIV se_diskop = SE_DISK_OPERATOR; / * Is disk op appropriate here ? JRA. * / + BOOL is_disk_op = False; / * No. SSS. :) */ rpcstr_pull_unistr2_fstring(username, &q_u->uni_user_name); rpcstr_pull_unistr2_fstring(machine, &q_u->uni_cli_name); @@ -1374,32 +1374,44 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); - get_current_user(&user,p); - - is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); - - /* fail out now if you are not root and not a disk op */ + /* is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); */ - if ( user.uid != sec_initial_uid() && !is_disk_op ) - return WERR_ACCESS_DENIED; - r_u->status = WERR_ACCESS_DENIED; + get_current_user(&user, p); + /* fail out now if you are not root */ + /* or at least domain admins */ + if ((user.uid != sec_initial_uid()) && + ( ! nt_token_check_domain_rid(p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS))) { + + goto done; + } + for (snum = 0; snum < num_sessions; snum++) { if ((strequal(session_list[snum].username, username) || username[0] == '\0' ) && strequal(session_list[snum].remote_machine, machine)) { + if (user.uid != sec_initial_uid()) { + become_root(); + } if ((ret = message_send_pid(session_list[snum].pid, MSG_SHUTDOWN, NULL, 0, False))) { r_u->status = WERR_OK; } else { r_u->status = WERR_ACCESS_DENIED; } + if (user.uid != sec_initial_uid()) { + unbecome_root(); + } } } DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); + +done: + SAFE_FREE(session_list); + return r_u->status; } -- cgit From 91e6894031406d23093b3da05263a0e85219b5f3 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 24 Mar 2005 08:36:00 +0000 Subject: r6034: Check only once (This used to be commit 5a4274371cdbbd278d8aaa922f3e5f51a3cb5aec) --- source3/rpc_server/srv_srvsvc_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 5dd2e6e47f..ed08f185f7 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1359,6 +1359,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES int num_sessions, snum, ret; fstring username; fstring machine; + BOOL not_root = False; /* SE_PRIV se_diskop = SE_DISK_OPERATOR; / * Is disk op appropriate here ? JRA. * / BOOL is_disk_op = False; / * No. SSS. :) */ @@ -1393,6 +1394,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES strequal(session_list[snum].remote_machine, machine)) { if (user.uid != sec_initial_uid()) { + not_root = True; become_root(); } if ((ret = message_send_pid(session_list[snum].pid, MSG_SHUTDOWN, NULL, 0, False))) { @@ -1400,7 +1402,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES } else { r_u->status = WERR_ACCESS_DENIED; } - if (user.uid != sec_initial_uid()) { + if (not_root) { unbecome_root(); } } -- cgit From 987fd2ed97b91804646b8d93fff37d7f2efa6bab Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 24 Mar 2005 14:40:35 +0000 Subject: r6037: little cleanup of unused vars and unnecessary codepaths (This used to be commit 167f7d3caa84e612cf3af0095536734dc7c3ad29) --- source3/rpc_server/srv_srvsvc_nt.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index ed08f185f7..a71f0f1c29 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1360,8 +1360,6 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES fstring username; fstring machine; BOOL not_root = False; - /* SE_PRIV se_diskop = SE_DISK_OPERATOR; / * Is disk op appropriate here ? JRA. * / - BOOL is_disk_op = False; / * No. SSS. :) */ rpcstr_pull_unistr2_fstring(username, &q_u->uni_user_name); rpcstr_pull_unistr2_fstring(machine, &q_u->uni_cli_name); @@ -1375,13 +1373,12 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); - /* is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); */ - r_u->status = WERR_ACCESS_DENIED; get_current_user(&user, p); - /* fail out now if you are not root */ - /* or at least domain admins */ + + /* fail out now if you are not root or not a domain admin */ + if ((user.uid != sec_initial_uid()) && ( ! nt_token_check_domain_rid(p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS))) { @@ -1397,14 +1394,12 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES not_root = True; become_root(); } - if ((ret = message_send_pid(session_list[snum].pid, MSG_SHUTDOWN, NULL, 0, False))) { + + if ((ret = message_send_pid(session_list[snum].pid, MSG_SHUTDOWN, NULL, 0, False))) r_u->status = WERR_OK; - } else { - r_u->status = WERR_ACCESS_DENIED; - } - if (not_root) { + + if (not_root) unbecome_root(); - } } } -- cgit From 0aa89db9471330fd02db395c2eb387ac2dfef54f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 26 Mar 2005 06:52:56 +0000 Subject: r6071: * clean up UNISTR2_ARRAY ( really just an array of UNISTR4 + count ) * add some backwards compatibility to 'net rpc rights list' * verify privilege name in 'net rpc rights privileges ' in order to give back better error messages. (This used to be commit 0e29dc8aa384dfa6d2495beb8a9ffb5371e60a13) --- source3/rpc_server/srv_lsa_nt.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 7ea35a91fa..db1aa57ea9 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1337,7 +1337,7 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R int i = 0; DOM_SID sid; fstring privname; - UNISTR2_ARRAY *uni_privnames = &q_u->rights; + UNISTR4_ARRAY *uni_privnames = q_u->rights; struct current_user user; @@ -1368,11 +1368,16 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R } for ( i=0; icount; i++ ) { - unistr2_to_ascii( privname, &uni_privnames->strings[i].string, sizeof(fstring)-1 ); - + UNISTR4 *uni4_str = &uni_privnames->strings[i]; + /* only try to add non-null strings */ + + if ( !uni4_str->string ) + continue; + + rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE ); - if ( *privname && !grant_privilege_by_name( &sid, privname ) ) { + if ( !grant_privilege_by_name( &sid, privname ) ) { DEBUG(2,("_lsa_add_acct_rights: Failed to add privilege [%s]\n", privname )); return NT_STATUS_NO_SUCH_PRIVILEGE; } @@ -1390,7 +1395,7 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, int i = 0; DOM_SID sid; fstring privname; - UNISTR2_ARRAY *uni_privnames = &q_u->rights; + UNISTR4_ARRAY *uni_privnames = q_u->rights; struct current_user user; @@ -1425,11 +1430,16 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, } for ( i=0; icount; i++ ) { - unistr2_to_ascii( privname, &uni_privnames->strings[i].string, sizeof(fstring)-1 ); - + UNISTR4 *uni4_str = &uni_privnames->strings[i]; + /* only try to add non-null strings */ + + if ( !uni4_str->string ) + continue; + + rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE ); - if ( *privname && !revoke_privilege_by_name( &sid, privname ) ) { + if ( !revoke_privilege_by_name( &sid, privname ) ) { DEBUG(2,("_lsa_remove_acct_rights: Failed to revoke privilege [%s]\n", privname )); return NT_STATUS_NO_SUCH_PRIVILEGE; } @@ -1439,6 +1449,9 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, } +/*************************************************************************** + ***************************************************************************/ + NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA_R_ENUM_ACCT_RIGHTS *r_u) { struct lsa_info *info = NULL; @@ -1478,6 +1491,9 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA } +/*************************************************************************** + ***************************************************************************/ + NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, LSA_R_LOOKUP_PRIV_VALUE *r_u) { struct lsa_info *info = NULL; -- cgit From e84ead0cfdc5e45a577387cc54dceb4c3f32948a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 27 Mar 2005 16:33:04 +0000 Subject: r6080: Port some of the non-critical changes from HEAD to 3_0. The main one is the change in pdb_enum_alias_memberships to match samr.idl a bit closer. Volker (This used to be commit 3a6786516957d9f67af6d53a3167c88aa272972f) --- source3/rpc_server/srv_samr_nt.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 001da3f3ea..7294a46d75 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3230,8 +3230,8 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, SAMR_R_QUERY_USERALIASES *r_u) { - int num_groups = 0; - uint32 *rids=NULL; + int num_alias_rids; + uint32 *alias_rids; struct samr_info *info = NULL; int i; @@ -3239,8 +3239,6 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, NTSTATUS ntstatus2; DOM_SID *members; - DOM_SID *aliases; - int num_aliases; BOOL res; r_u->status = NT_STATUS_OK; @@ -3273,35 +3271,20 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, for (i=0; inum_sids1; i++) sid_copy(&members[i], &q_u->sid[i].sid); + alias_rids = NULL; + num_alias_rids = 0; + become_root(); - res = pdb_enum_alias_memberships(members, - q_u->num_sids1, &aliases, - &num_aliases); + res = pdb_enum_alias_memberships(p->mem_ctx, &info->sid, members, + q_u->num_sids1, + &alias_rids, &num_alias_rids); unbecome_root(); if (!res) return NT_STATUS_UNSUCCESSFUL; - rids = NULL; - num_groups = 0; - - for (i=0; isid, &aliases[i], &rid)) - continue; - - rids = TALLOC_REALLOC_ARRAY(p->mem_ctx, rids, uint32, num_groups+1); - - if (rids == NULL) - return NT_STATUS_NO_MEMORY; - - rids[num_groups] = rid; - num_groups += 1; - } - SAFE_FREE(aliases); - - init_samr_r_query_useraliases(r_u, num_groups, rids, NT_STATUS_OK); + init_samr_r_query_useraliases(r_u, num_alias_rids, alias_rids, + NT_STATUS_OK); return NT_STATUS_OK; } -- cgit From 934d41d23956c663406ff9d68e5a8ba9d81b5096 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 30 Mar 2005 04:40:24 +0000 Subject: r6127: Eliminated all compiler warnings pertaining to mismatched "qualifiers". The whole of samba comiles warning-free with the default compiler flags. Temporarily defined -Wall to locate other potential problems. Found an unused static function (#ifdefed out rather than deleted, in case it's needed for something in progress). There are also a number of uses of undeclared functions, mostly krb5_*. Files with these problems need to have appropriate header files included, but they are not fixed in this update. oplock_linux.c.c has undefined functions capget() and capset(), which need to have "#undef _POSIX_SOURCE" specified before including , but that could potentially have other side effects, so that remains uncorrected as well. The flag -Wall should be added permanently to CFLAGS, and all warnings then generated should be eliminated. (This used to be commit 5b19ede88ed80318e392f8017f4573fbb2ecbe0f) --- source3/rpc_server/srv_svcctl_nt.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 19244d2208..cb04ef1d10 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -34,6 +34,8 @@ static TDB_CONTEXT *svcctl_tdb; /* used for share security descriptors */ /******************************************************************** ********************************************************************/ +#if 0 /* unused static function */ + static BOOL init_svcctl_db( void ) { static pid_t local_pid; @@ -69,6 +71,8 @@ static BOOL init_svcctl_db( void ) return True; } +#endif + /******************************************************************** TODO (a) get and set security descriptors on services -- cgit From 9840db418bad5a39edc4a32a1786f5e2d2c9dff8 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Thu, 31 Mar 2005 05:06:04 +0000 Subject: r6149: Fixes bugs #2498 and 2484. 1. using smbc_getxattr() et al, one may now request all access control entities in the ACL without getting all other NT attributes. 2. added the ability to exclude specified attributes from the result set provided by smbc_getxattr() et al, when requesting all attributes, all NT attributes, or all DOS attributes. 3. eliminated all compiler warnings, including when --enable-developer compiler flags are in use. removed -Wcast-qual flag from list, as that is specifically to force warnings in the case of casting away qualifiers. Note: In the process of eliminating compiler warnings, a few nasties were discovered. In the file libads/sasl.c, PRIVATE kerberos interfaces are being used; and in libsmb/clikrb5.c, both PRIAVE and DEPRECATED kerberos interfaces are being used. Someone who knows kerberos should look at these and determine if there is an alternate method of accomplishing the task. (This used to be commit 994694f7f26da5099f071e1381271a70407f33bb) --- source3/rpc_server/srv_svcctl_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index cb04ef1d10..a76e68a312 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -27,14 +27,14 @@ * sertup the \PIPE\svcctl db API */ -static TDB_CONTEXT *svcctl_tdb; /* used for share security descriptors */ - #define SCVCTL_DATABASE_VERSION_V1 1 /******************************************************************** ********************************************************************/ -#if 0 /* unused static function */ +#if 0 /* unused static function and static variable*/ + +static TDB_CONTEXT *svcctl_tdb; /* used for share security descriptors */ static BOOL init_svcctl_db( void ) { -- cgit From b4c720412978c0a49e11846c7cfe553d055cca1f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 5 Apr 2005 17:49:16 +0000 Subject: r6218: * fix a segv in EnumPrinters():rpc_buffer_alloc when the caller does not provide an RPC_BUFFER in the request * add initial (but wire untested) support for RegRestoreKey() (This used to be commit 22855c7aae940cc4082c231a470f612b8fc6fa0d) --- source3/rpc_server/srv_reg.c | 30 +++++++++++++-- source3/rpc_server/srv_reg_nt.c | 82 ++++++++++++++++++++++++++--------------- 2 files changed, 80 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index b2b3920e9e..a90650c536 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -369,8 +369,31 @@ static BOOL api_reg_enum_value(pipes_struct *p) } /******************************************************************* - api_reg_save_key - ********************************************************************/ + ******************************************************************/ + +static BOOL api_reg_restore_key(pipes_struct *p) +{ + REG_Q_RESTORE_KEY q_u; + REG_R_RESTORE_KEY r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_restore_key("", &q_u, data, 0)) + return False; + + r_u.status = _reg_restore_key(p, &q_u, &r_u); + + if(!reg_io_r_restore_key("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ******************************************************************/ static BOOL api_reg_save_key(pipes_struct *p) { @@ -412,7 +435,8 @@ static struct api_struct api_reg_cmds[] = { "REG_SHUTDOWN_EX" , REG_SHUTDOWN_EX , api_reg_shutdown_ex }, { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, { "REG_GETVERSION" , REG_GETVERSION , api_reg_getversion }, - { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key } + { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key }, + { "REG_RESTORE_KEY" , REG_RESTORE_KEY , api_reg_restore_key } }; void reg_get_pipe_fns( struct api_struct **fns, int *n_fns ) diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index f0d831cc6a..ad7aaa4469 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -561,8 +561,7 @@ WERROR _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE DEBUG(8,("_reg_enum_key: enumerating values for key [%s]\n", regkey->name)); - if ( !fetch_reg_values_specific( regkey, &val, q_u->val_index ) ) - { + if ( !fetch_reg_values_specific( regkey, &val, q_u->val_index ) ) { status = WERR_NO_MORE_ITEMS; goto done; } @@ -587,10 +586,6 @@ done: reg_shutdwon ********************************************************************/ -#define SHUTDOWN_R_STRING "-r" -#define SHUTDOWN_F_STRING "-f" - - WERROR _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) { REG_Q_SHUTDOWN_EX q_u_ex; @@ -630,7 +625,6 @@ WERROR _reg_shutdown_ex(pipes_struct *p, REG_Q_SHUTDOWN_EX *q_u, REG_R_SHUTDOWN_ int ret; BOOL can_shutdown; - pstrcpy(shutdown_script, lp_shutdown_script()); if ( !*shutdown_script ) @@ -659,25 +653,24 @@ WERROR _reg_shutdown_ex(pipes_struct *p, REG_Q_SHUTDOWN_EX *q_u, REG_R_SHUTDOWN_ can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_remote_shutdown ); - /********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/ - /* IF someone has privs, run the shutdown script as root. OTHERWISE run it as not root Take the error return from the script and provide it as the Windows return code. */ - if ( can_shutdown ) { - DEBUG(3,("_reg_shutdown_ex: Privilege Check is OK for shutdown \n")); - become_root(); - } + /********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/ + + if ( can_shutdown ) + become_root(); ret = smbrun( shutdown_script, NULL ); + if ( can_shutdown ) + unbecome_root(); + + /********** END SeRemoteShutdownPrivilege BLOCK **********/ + DEBUG(3,("_reg_shutdown_ex: Running the command `%s' gave %d\n", shutdown_script, ret)); - if ( can_shutdown ) - unbecome_root(); - - /********** END SeRemoteShutdownPrivilege BLOCK **********/ return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; } @@ -702,26 +695,53 @@ WERROR _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABO can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_remote_shutdown ); - /********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/ + /********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/ - if ( can_shutdown ) - become_root(); + if ( can_shutdown ) + become_root(); ret = smbrun( abort_shutdown_script, NULL ); + if ( can_shutdown ) + unbecome_root(); + + /********** END SeRemoteShutdownPrivilege BLOCK **********/ + DEBUG(3,("_reg_abort_shutdown: Running the command `%s' gave %d\n", abort_shutdown_script, ret)); - if ( can_shutdown ) - unbecome_root(); - - /********** END SeRemoteShutdownPrivilege BLOCK **********/ return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; } /******************************************************************* - REG_SAVE_KEY (0x14) + ********************************************************************/ + +WERROR _reg_restore_key(pipes_struct *p, REG_Q_RESTORE_KEY *q_u, REG_R_RESTORE_KEY *r_u) +{ + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + + DEBUG(5,("_reg_restore_key: Enter\n")); + + /* + * basically this is a no op function which just verifies + * that the client gave us a valid registry key handle + */ + + if ( !regkey ) + return WERR_BADFID; + + DEBUG(8,("_reg_restore_key: verifying backup of key [%s]\n", regkey->name)); + +#if 0 + validate_reg_filemame( filename ); + return restore_registry_key( regkey, filename ); +#endif + + return WERR_OK; +} + +/******************************************************************* ********************************************************************/ WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) @@ -731,15 +751,19 @@ WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) DEBUG(5,("_reg_save_key: Enter\n")); /* - * basically this is a no op function which just gverifies + * basically this is a no op function which just verifies * that the client gave us a valid registry key handle */ if ( !regkey ) - return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ + return WERR_BADFID; - DEBUG(8,("_reg_save_key: berifying backup of key [%s]\n", regkey->name)); - + DEBUG(8,("_reg_save_key: verifying backup of key [%s]\n", regkey->name)); + +#if 0 + validate_reg_filemame( filename ); + return backup_registry_key( regkey, filename ); +#endif return WERR_OK; } -- cgit From 978ca8486031e43754a3c23757f361bf3a85f335 Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Wed, 6 Apr 2005 16:28:04 +0000 Subject: r6225: get rid of warnings from my compiler about nested externs (This used to be commit efea76ac71412f8622cd233912309e91b9ea52da) --- source3/rpc_server/srv_lsa_nt.c | 4 ++-- source3/rpc_server/srv_netlog_nt.c | 5 +++-- source3/rpc_server/srv_pipe.c | 5 +++-- source3/rpc_server/srv_samr_nt.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 3 ++- source3/rpc_server/srv_srvsvc_nt.c | 6 +++--- 6 files changed, 14 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index db1aa57ea9..58189fec78 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -33,6 +33,8 @@ #define DBGC_CLASS DBGC_RPC_SRV extern PRIVS privs[]; +extern DOM_SID global_sid_World; +extern DOM_SID global_sid_Builtin; struct lsa_info { DOM_SID sid; @@ -314,8 +316,6 @@ static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *sd_size) { - extern DOM_SID global_sid_World; - extern DOM_SID global_sid_Builtin; DOM_SID local_adm_sid; DOM_SID adm_sid; diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 2bc0cf301e..c8ffa18c5a 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -26,6 +26,9 @@ #include "includes.h" +extern struct dcinfo last_dcinfo; +extern userdom_struct current_user_info; + #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV @@ -424,7 +427,6 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) init_net_r_auth_2(r_u, &srv_cred, &srv_flgs, status); if (NT_STATUS_IS_OK(status)) { - extern struct dcinfo last_dcinfo; last_dcinfo = p->dc; } @@ -575,7 +577,6 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * fstring nt_username, nt_domain, nt_workstation; auth_usersupplied_info *user_info = NULL; auth_serversupplied_info *server_info = NULL; - extern userdom_struct current_user_info; SAM_ACCOUNT *sampw; struct auth_context *auth_context = NULL; diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index ab21f60902..ee6c42bd88 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -40,6 +40,9 @@ #include "includes.h" +extern struct pipe_id_info pipe_names[]; +extern struct current_user current_user; + #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV @@ -751,7 +754,6 @@ BOOL setup_fault_pdu(pipes_struct *p, NTSTATUS status) BOOL check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, RPC_IFACE* transfer, uint32 context_id) { - extern struct pipe_id_info pipe_names[]; char *pipe_name = p->name; int i=0; fstring pname; @@ -1427,7 +1429,6 @@ struct current_user *get_current_user(struct current_user *user, pipes_struct *p if (p->ntlmssp_auth_validated) { memcpy(user, &p->pipe_user, sizeof(struct current_user)); } else { - extern struct current_user current_user; memcpy(user, ¤t_user, sizeof(struct current_user)); } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7294a46d75..24ff6f1f2c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -39,6 +39,7 @@ SA_RIGHT_USER_CHANGE_PASSWORD | \ SA_RIGHT_USER_SET_LOC_COM ) +extern DOM_SID global_sid_World; extern DOM_SID global_sid_Builtin; extern rid_name domain_group_rids[]; @@ -80,7 +81,6 @@ static NTSTATUS make_samr_object_sd( TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd struct generic_mapping *map, DOM_SID *sid, uint32 sid_access ) { - extern DOM_SID global_sid_World; DOM_SID adm_sid, act_sid, domadmin_sid; SEC_ACE ace[5]; /* at most 5 entries */ SEC_ACCESS mask; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2e84a7b909..0f33fd7dec 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -28,6 +28,8 @@ #include "includes.h" +extern userdom_struct current_user_info; + #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV @@ -6027,7 +6029,6 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) static BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) { - extern userdom_struct current_user_info; char *cmd = lp_addprinter_cmd(); char **qlines; pstring command; diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index a71f0f1c29..d806dcdc5a 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -24,6 +24,9 @@ #include "includes.h" +extern DOM_SID global_sid_World; +extern struct generic_mapping file_generic_mapping; + #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV @@ -170,8 +173,6 @@ BOOL share_info_db_init(void) static SEC_DESC *get_share_security_default( TALLOC_CTX *ctx, int snum, size_t *psize) { - extern DOM_SID global_sid_World; - extern struct generic_mapping file_generic_mapping; SEC_ACCESS sa; SEC_ACE ace; SEC_ACL *psa = NULL; @@ -293,7 +294,6 @@ static BOOL delete_share_security(int snum) void map_generic_share_sd_bits(SEC_DESC *psd) { - extern struct generic_mapping file_generic_mapping; int i; SEC_ACL *ps_dacl = NULL; -- cgit From b137b7cc4720ca9d99eab2bb198be1b112c2e24c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 6 Apr 2005 22:27:55 +0000 Subject: r6228: remove BUFHDR2 and clean up LsaEnumTrustedDomains() Tested client and server code. (This used to be commit efb3ac4c69c72c0fa01c558951fa357893562bce) --- source3/rpc_server/srv_lsa_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 58189fec78..f5f22d8cc0 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -523,6 +523,7 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E } /* set up the lsa_enum_trust_dom response */ + init_r_enum_trust_dom(p->mem_ctx, r_u, enum_context, max_num_domains, num_domains, trust_doms); return r_u->status; -- cgit From 466a825ce7a3c9a40a694608523f47e580c78415 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 7 Apr 2005 04:58:38 +0000 Subject: r6232: more cleanups; remove BUFFER3; rename BUFFER4 -> RPC_DATA_BLOB; rename REG_CREATE_VALE -> REG_SET_VALUE (This used to be commit 28d433351cf813c7fb57ebac0e0f4973c85f73e8) --- source3/rpc_server/srv_reg_nt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index ad7aaa4469..f031a3213f 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -720,6 +720,7 @@ WERROR _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABO WERROR _reg_restore_key(pipes_struct *p, REG_Q_RESTORE_KEY *q_u, REG_R_RESTORE_KEY *r_u) { REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + pstring filename; DEBUG(5,("_reg_restore_key: Enter\n")); @@ -731,7 +732,9 @@ WERROR _reg_restore_key(pipes_struct *p, REG_Q_RESTORE_KEY *q_u, REG_R_RESTORE_ if ( !regkey ) return WERR_BADFID; - DEBUG(8,("_reg_restore_key: verifying backup of key [%s]\n", regkey->name)); + rpcstr_pull(filename, q_u->filename.string->buffer, sizeof(filename), q_u->filename.string->uni_str_len*2, STR_TERMINATE); + + DEBUG(8,("_reg_restore_key: verifying restore of key [%s] from \"%s\"\n", regkey->name, filename)); #if 0 validate_reg_filemame( filename ); @@ -747,6 +750,7 @@ WERROR _reg_restore_key(pipes_struct *p, REG_Q_RESTORE_KEY *q_u, REG_R_RESTORE_ WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) { REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + pstring filename; DEBUG(5,("_reg_save_key: Enter\n")); @@ -758,7 +762,9 @@ WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) if ( !regkey ) return WERR_BADFID; - DEBUG(8,("_reg_save_key: verifying backup of key [%s]\n", regkey->name)); + rpcstr_pull(filename, q_u->filename.string->buffer, sizeof(filename), q_u->filename.string->uni_str_len*2, STR_TERMINATE); + + DEBUG(8,("_reg_save_key: verifying backup of key [%s] to \"%s\"\n", regkey->name, filename)); #if 0 validate_reg_filemame( filename ); -- cgit From 83e11ba86c2401ece3c845fd10c22b84e6be7811 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 9 Apr 2005 11:46:40 +0000 Subject: r6263: Get rid of generate_wellknown_sids, they are const static and initializable statically. Volker (This used to be commit 3493d9f383567d286e69c0e60c0708ed400a04d9) --- source3/rpc_server/srv_lsa_nt.c | 2 -- source3/rpc_server/srv_samr_nt.c | 3 --- source3/rpc_server/srv_srvsvc_nt.c | 1 - 3 files changed, 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f5f22d8cc0..5e949f0e63 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -33,8 +33,6 @@ #define DBGC_CLASS DBGC_RPC_SRV extern PRIVS privs[]; -extern DOM_SID global_sid_World; -extern DOM_SID global_sid_Builtin; struct lsa_info { DOM_SID sid; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 24ff6f1f2c..2384ddb9d3 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -39,9 +39,6 @@ SA_RIGHT_USER_CHANGE_PASSWORD | \ SA_RIGHT_USER_SET_LOC_COM ) -extern DOM_SID global_sid_World; -extern DOM_SID global_sid_Builtin; - extern rid_name domain_group_rids[]; extern rid_name domain_alias_rids[]; extern rid_name builtin_alias_rids[]; diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index d806dcdc5a..b5768a09af 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -24,7 +24,6 @@ #include "includes.h" -extern DOM_SID global_sid_World; extern struct generic_mapping file_generic_mapping; #undef DBGC_CLASS -- cgit From 110d86876eef65c838105f7365e50c77c3a02a30 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 10 Apr 2005 17:12:25 +0000 Subject: r6282: Before converting enum_dom_groups, better get the previous version a bit closer to being correct. 'svn blame' shows CVSIN, but somehow I get the feeling this is my code... Volker (This used to be commit 5d34bd617535a26ae121a72add41dc7b8cec4580) --- source3/rpc_server/srv_samr_nt.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2384ddb9d3..84c78eab64 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -864,6 +864,7 @@ static NTSTATUS get_group_domain_entries( TALLOC_CTX *ctx, int i; uint32 group_entries = 0; uint32 num_entries = 0; + NTSTATUS result = NT_STATUS_OK; *p_num_entries = 0; @@ -881,6 +882,7 @@ static NTSTATUS get_group_domain_entries( TALLOC_CTX *ctx, if (num_entries>max_entries) { DEBUG(5,("Limiting to %d entries\n", max_entries)); num_entries=max_entries; + result = STATUS_MORE_ENTRIES; } *d_grp=TALLOC_ZERO_ARRAY(ctx, DOMAIN_GRP, num_entries); @@ -903,7 +905,7 @@ static NTSTATUS get_group_domain_entries( TALLOC_CTX *ctx, DEBUG(10,("get_group_domain_entries: returning %d entries\n", *p_num_entries)); - return NT_STATUS_OK; + return result; } /******************************************************************* @@ -970,13 +972,19 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); /* the domain group array is being allocated in the function below */ - if (!NT_STATUS_IS_OK(r_u->status = get_group_domain_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, &num_entries, MAX_SAM_ENTRIES))) { + r_u->status = get_group_domain_entries(p->mem_ctx, &grp, &sid, + q_u->start_idx, &num_entries, + MAX_SAM_ENTRIES); + + if (!NT_STATUS_IS_OK(r_u->status) && + !NT_STATUS_EQUAL(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); + make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, + num_entries, grp); - init_samr_r_enum_dom_groups(r_u, q_u->start_idx, num_entries); + init_samr_r_enum_dom_groups(r_u, q_u->start_idx+num_entries, + num_entries); DEBUG(5,("samr_enum_dom_groups: %d\n", __LINE__)); -- cgit From d3d6126d94d55a69c45b2f7a63a7fa9b561baf48 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 15 Apr 2005 13:41:49 +0000 Subject: r6351: This is quite a large and intrusive patch, but there are not many pieces that can be taken out of it, so I decided to commit this in one lump. It changes the passdb enumerating functions to use ldap paged results where possible. In particular the samr calls querydispinfo, enumdomusers and friends have undergone significant internal changes. I have tested this extensively with rpcclient and a bit with usrmgr.exe. More tests and the merge to trunk will follow later. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code is based on a first implementation by Günther Deschner, but has evolved quite a bit since then. Volker (This used to be commit f0bb44ac58e190e19eb4e92928979b0446e611c9) --- source3/rpc_server/srv_samr_nt.c | 818 ++++++++++++--------------------------- 1 file changed, 238 insertions(+), 580 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 84c78eab64..fe54476cc9 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -43,14 +43,12 @@ extern rid_name domain_group_rids[]; extern rid_name domain_alias_rids[]; extern rid_name builtin_alias_rids[]; - -typedef struct _disp_info { - BOOL user_dbloaded; - uint32 num_user_account; - SAM_ACCOUNT *disp_user_info; - BOOL group_dbloaded; - uint32 num_group_account; - DOMAIN_GRP *disp_group_info; +typedef struct disp_info { + struct pdb_search *users; + struct pdb_search *machines; + struct pdb_search *groups; + struct pdb_search *aliases; + struct pdb_search *builtins; } DISP_INFO; struct samr_info { @@ -238,10 +236,9 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) mem_ctx = talloc_init("samr_info for domain sid %s", sid_str); - if ((info = TALLOC_P(mem_ctx, struct samr_info)) == NULL) + if ((info = TALLOC_ZERO_P(mem_ctx, struct samr_info)) == NULL) return NULL; - ZERO_STRUCTP(info); DEBUG(10,("get_samr_info_by_sid: created new info for sid %s\n", sid_str)); if (psid) { sid_copy( &info->sid, psid); @@ -256,33 +253,22 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) Function to free the per handle data. ********************************************************************/ -static void free_samr_users(struct samr_info *info) -{ - int i; - - if (info->disp_info.user_dbloaded){ - for (i=0; idisp_info.num_user_account; i++) { - SAM_ACCOUNT *sam = &info->disp_info.disp_user_info[i]; - /* Not really a free, actually a 'clear' */ - pdb_free_sam(&sam); - } - } - info->disp_info.user_dbloaded=False; - info->disp_info.num_user_account=0; -} - /******************************************************************* Function to free the per handle data. ********************************************************************/ static void free_samr_db(struct samr_info *info) { - /* Groups are talloced */ - - free_samr_users(info); - - info->disp_info.group_dbloaded=False; - info->disp_info.num_group_account=0; + pdb_search_destroy(info->disp_info.users); + info->disp_info.users = NULL; + pdb_search_destroy(info->disp_info.machines); + info->disp_info.machines = NULL; + pdb_search_destroy(info->disp_info.groups); + info->disp_info.groups = NULL; + pdb_search_destroy(info->disp_info.aliases); + info->disp_info.aliases = NULL; + pdb_search_destroy(info->disp_info.builtins); + info->disp_info.builtins = NULL; } static void free_samr_info(void *ptr) @@ -309,154 +295,30 @@ static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) pdb_set_nt_passwd(sam_pass, NULL, PDB_DEFAULT); } - -static NTSTATUS load_sampwd_entries(struct samr_info *info, uint16 acb_mask, BOOL only_machines) +static uint32 count_sam_users(struct disp_info *info, uint16 acct_flags) { - SAM_ACCOUNT *pwd = NULL; - SAM_ACCOUNT *pwd_array = NULL; - NTSTATUS nt_status = NT_STATUS_OK; - TALLOC_CTX *mem_ctx = info->mem_ctx; - uint16 query_acb_mask = acb_mask; - - DEBUG(10,("load_sampwd_entries\n")); - - /* if the snapshoot is already loaded, return */ - if ((info->disp_info.user_dbloaded==True) - && (info->acb_mask == acb_mask) - && (info->only_machines == only_machines)) { - DEBUG(10,("load_sampwd_entries: already in memory\n")); - return NT_STATUS_OK; - } - - free_samr_users(info); - - if (only_machines) { - query_acb_mask |= ACB_WSTRUST; - query_acb_mask |= ACB_SVRTRUST; - } - - if (!pdb_setsampwent(False, query_acb_mask)) { - DEBUG(0, ("load_sampwd_entries: Unable to open passdb.\n")); - return NT_STATUS_ACCESS_DENIED; - } - - for (; (NT_STATUS_IS_OK(nt_status = pdb_init_sam_talloc(mem_ctx, &pwd))) - && pdb_getsampwent(pwd) == True; pwd=NULL) { - - if (only_machines) { - if (!((pdb_get_acct_ctrl(pwd) & ACB_WSTRUST) - || (pdb_get_acct_ctrl(pwd) & ACB_SVRTRUST))) { - DEBUG(5,("load_sampwd_entries: '%s' is not a machine account - ACB: %x - skipping\n", pdb_get_username(pwd), acb_mask)); - pdb_free_sam(&pwd); - continue; - } - } else { - if (acb_mask != 0 && !(pdb_get_acct_ctrl(pwd) & acb_mask)) { - pdb_free_sam(&pwd); - DEBUG(5,(" acb_mask %x reject\n", acb_mask)); - continue; - } - } - - /* Realloc some memory for the array of ptr to the SAM_ACCOUNT structs */ - if (info->disp_info.num_user_account % MAX_SAM_ENTRIES == 0) { - - DEBUG(10,("load_sampwd_entries: allocating more memory\n")); - pwd_array=TALLOC_REALLOC_ARRAY(mem_ctx, info->disp_info.disp_user_info, SAM_ACCOUNT, - info->disp_info.num_user_account+MAX_SAM_ENTRIES); - - if (pwd_array==NULL) - return NT_STATUS_NO_MEMORY; - - info->disp_info.disp_user_info=pwd_array; - } - - /* Copy the SAM_ACCOUNT into the array */ - info->disp_info.disp_user_info[info->disp_info.num_user_account]=*pwd; - - DEBUG(10,("load_sampwd_entries: entry: %d\n", info->disp_info.num_user_account)); - - info->disp_info.num_user_account++; - } - - pdb_endsampwent(); - - /* the snapshoot is in memory, we're ready to enumerate fast */ - - info->acb_mask = acb_mask; - info->only_machines = only_machines; - info->disp_info.user_dbloaded=True; - - DEBUG(10,("load_sampwd_entries: done\n")); - - return nt_status; + struct samr_displayentry *entry; + if (info->users == NULL) + info->users = pdb_search_users(acct_flags); + if (info->users == NULL) + return 0; + /* Fetch the last possible entry, thus trigger an enumeration */ + pdb_search_entries(info->users, 0xffffffff, 1, &entry); + return info->users->num_entries; } -static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) +static uint32 count_sam_groups(struct disp_info *info) { - GROUP_MAP *map=NULL; - DOMAIN_GRP *grp_array = NULL; - uint32 group_entries = 0; - uint32 i; - TALLOC_CTX *mem_ctx = info->mem_ctx; - BOOL ret; - - DEBUG(10,("load_group_domain_entries\n")); - - /* if the snapshoot is already loaded, return */ - if (info->disp_info.group_dbloaded==True) { - DEBUG(10,("load_group_domain_entries: already in memory\n")); - return NT_STATUS_OK; - } - - if (sid_equal(sid, &global_sid_Builtin)) { - /* No domain groups for now in the BUILTIN domain */ - info->disp_info.num_group_account=0; - info->disp_info.disp_group_info=NULL; - info->disp_info.group_dbloaded=True; - return NT_STATUS_OK; - } - - become_root(); - ret = pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED); - unbecome_root(); - - if ( !ret ) { - DEBUG(1, ("load_group_domain_entries: pdb_enum_group_mapping() failed!\n")); - return NT_STATUS_NO_MEMORY; - } - - - info->disp_info.num_group_account=group_entries; - - grp_array=TALLOC_ARRAY(mem_ctx, DOMAIN_GRP, info->disp_info.num_group_account); - if (group_entries!=0 && grp_array==NULL) { - DEBUG(1, ("load_group_domain_entries: talloc() failed for grp_array!\n")); - SAFE_FREE(map); - return NT_STATUS_NO_MEMORY; - } - - info->disp_info.disp_group_info=grp_array; - - for (i=0; idisp_info.group_dbloaded=True; - - DEBUG(10,("load_group_domain_entries: done\n")); - - return NT_STATUS_OK; + struct samr_displayentry *entry; + if (info->groups == NULL) + info->groups = pdb_search_groups(); + if (info->groups == NULL) + return 0; + /* Fetch the last possible entry, thus trigger an enumeration */ + pdb_search_entries(info->groups, 0xffffffff, 1, &entry); + return info->groups->num_entries; } - /******************************************************************* _samr_close_hnd ********************************************************************/ @@ -656,20 +518,14 @@ NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_ makes a SAM_ENTRY / UNISTR2* structure from a user list. ********************************************************************/ -static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNISTR2 **uni_name_pp, - uint32 num_entries, uint32 start_idx, SAM_ACCOUNT *disp_user_info, - DOM_SID *domain_sid) +static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, + UNISTR2 **uni_name_pp, + uint32 num_entries, uint32 start_idx, + struct samr_displayentry *entries) { uint32 i; SAM_ENTRY *sam; UNISTR2 *uni_name; - SAM_ACCOUNT *pwd = NULL; - UNISTR2 uni_temp_name; - const char *temp_name; - const DOM_SID *user_sid; - uint32 user_rid; - fstring user_sid_string; - fstring domain_sid_string; *sam_pp = NULL; *uni_name_pp = NULL; @@ -687,31 +543,20 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UN } for (i = 0; i < num_entries; i++) { - pwd = &disp_user_info[i+start_idx]; - temp_name = pdb_get_username(pwd); - + UNISTR2 uni_temp_name; /* * usrmgr expects a non-NULL terminated string with * trust relationships */ - if (pdb_get_acct_ctrl(pwd) & ACB_DOMTRUST) { - init_unistr2(&uni_temp_name, temp_name, UNI_FLAGS_NONE); + if (entries[i].acct_flags & ACB_DOMTRUST) { + init_unistr2(&uni_temp_name, entries[i].account_name, + UNI_FLAGS_NONE); } else { - init_unistr2(&uni_temp_name, temp_name, UNI_STR_TERMINATE); + init_unistr2(&uni_temp_name, entries[i].account_name, + UNI_STR_TERMINATE); } - user_sid = pdb_get_user_sid(pwd); - - if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { - DEBUG(0, ("make_user_sam_entry_list: User %s has SID %s, which conflicts with " - "the domain sid %s. Failing operation.\n", - temp_name, - sid_to_string(user_sid_string, user_sid), - sid_to_string(domain_sid_string, domain_sid))); - return NT_STATUS_UNSUCCESSFUL; - } - - init_sam_entry(&sam[i], &uni_temp_name, user_rid); + init_sam_entry(&sam[i], &uni_temp_name, entries[i].rid); copy_unistr2(&uni_name[i], &uni_temp_name); } @@ -728,15 +573,12 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_R_ENUM_DOM_USERS *r_u) { struct samr_info *info = NULL; - uint32 struct_size=0x20; /* W2K always reply that, client doesn't care */ int num_account; uint32 enum_context=q_u->start_idx; - uint32 max_size=q_u->max_size; - uint32 temp_size; enum remote_arch_types ra_type = get_remote_arch(); int max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K; uint32 max_entries = max_sam_entries; - DOM_SID domain_sid; + struct samr_displayentry *entries = NULL; r_u->status = NT_STATUS_OK; @@ -744,8 +586,6 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - domain_sid = info->sid; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_users"))) { @@ -755,60 +595,36 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); become_root(); - r_u->status=load_sampwd_entries(info, q_u->acb_mask, False); + if (info->disp_info.users == NULL) + info->disp_info.users = pdb_search_users(q_u->acb_mask); + if (info->disp_info.users == NULL) + return NT_STATUS_ACCESS_DENIED; + num_account = pdb_search_entries(info->disp_info.users, + enum_context, max_entries, + &entries); unbecome_root(); - - if (!NT_STATUS_IS_OK(r_u->status)) - return r_u->status; - - num_account = info->disp_info.num_user_account; - if (enum_context > num_account) { - DEBUG(5, ("_samr_enum_dom_users: enumeration handle over total entries\n")); + if (num_account == 0) { + DEBUG(5, ("_samr_enum_dom_users: enumeration handle over " + "total entries\n")); return NT_STATUS_OK; } - /* verify we won't overflow */ - if (max_entries > num_account-enum_context) { - max_entries = num_account-enum_context; - DEBUG(5, ("_samr_enum_dom_users: only %d entries to return\n", max_entries)); - } - - /* calculate the size and limit on the number of entries we will return */ - temp_size=max_entries*struct_size; - - if (temp_size>max_size) { - max_entries=MIN((max_size/struct_size),max_entries);; - DEBUG(5, ("_samr_enum_dom_users: buffer size limits to only %d entries\n", max_entries)); - } - - /* - * Note from JRA. total_entries is not being used here. Currently if there is a - * large user base then it looks like NT will enumerate until get_sampwd_entries - * returns False due to num_entries being zero. This will cause an access denied - * return. I don't think this is right and needs further investigation. Note that - * this is also the same in the TNG code (I don't think that has been tested with - * a very large user list as MAX_SAM_ENTRIES is set to 600). - * - * I also think that one of the 'num_entries' return parameters is probably - * the "max entries" parameter - but in the TNG code they're all currently set to the same - * value (again I think this is wrong). - */ - - r_u->status = make_user_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_acct_name, - max_entries, enum_context, - info->disp_info.disp_user_info, - &domain_sid); + r_u->status = make_user_sam_entry_list(p->mem_ctx, &r_u->sam, + &r_u->uni_acct_name, + num_account, enum_context, + entries); if (!NT_STATUS_IS_OK(r_u->status)) return r_u->status; - if (enum_context+max_entries < num_account) + if (max_entries <= num_account) r_u->status = STATUS_MORE_ENTRIES; DEBUG(5, ("_samr_enum_dom_users: %d\n", __LINE__)); - init_samr_r_enum_dom_users(r_u, q_u->start_idx + max_entries, max_entries); + init_samr_r_enum_dom_users(r_u, q_u->start_idx + num_account, + num_account); DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); @@ -819,8 +635,10 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, makes a SAM_ENTRY / UNISTR2* structure from a group list. ********************************************************************/ -static void make_group_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNISTR2 **uni_name_pp, - uint32 num_sam_entries, DOMAIN_GRP *grp) +static void make_group_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, + UNISTR2 **uni_name_pp, + uint32 num_sam_entries, + struct samr_displayentry *entries) { uint32 i; SAM_ENTRY *sam; @@ -844,188 +662,117 @@ static void make_group_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, UNIST /* * JRA. I think this should include the null. TNG does not. */ - init_unistr2(&uni_name[i], grp[i].name, UNI_STR_TERMINATE); - init_sam_entry(&sam[i], &uni_name[i], grp[i].rid); + init_unistr2(&uni_name[i], entries[i].account_name, + UNI_STR_TERMINATE); + init_sam_entry(&sam[i], &uni_name[i], entries[i].rid); } *sam_pp = sam; *uni_name_pp = uni_name; } -/******************************************************************* - Get the group entries - similar to get_sampwd_entries(). - ******************************************************************/ - -static NTSTATUS get_group_domain_entries( TALLOC_CTX *ctx, - DOMAIN_GRP **d_grp, DOM_SID *sid, uint32 start_idx, - uint32 *p_num_entries, uint32 max_entries ) -{ - GROUP_MAP *map=NULL; - int i; - uint32 group_entries = 0; - uint32 num_entries = 0; - NTSTATUS result = NT_STATUS_OK; - - *p_num_entries = 0; - - /* access checks for the users were performed higher up. become/unbecome_root() - needed for some passdb backends to enumerate groups */ - - become_root(); - pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, - ENUM_ONLY_MAPPED); - unbecome_root(); - - num_entries=group_entries-start_idx; - - /* limit the number of entries */ - if (num_entries>max_entries) { - DEBUG(5,("Limiting to %d entries\n", max_entries)); - num_entries=max_entries; - result = STATUS_MORE_ENTRIES; - } - - *d_grp=TALLOC_ZERO_ARRAY(ctx, DOMAIN_GRP, num_entries); - if (num_entries!=0 && *d_grp==NULL){ - SAFE_FREE(map); - return NT_STATUS_NO_MEMORY; - } - - for (i=0; istatus = NT_STATUS_OK; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) + /* 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; - - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_groups"))) { + + r_u->status = access_check_samr_function(info->acc_granted, + SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, + "_samr_enum_dom_groups"); + if (!NT_STATUS_IS_OK(r_u->status)) return r_u->status; - } DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); /* the domain group array is being allocated in the function below */ - r_u->status = get_group_domain_entries(p->mem_ctx, &grp, &sid, - q_u->start_idx, &num_entries, - MAX_SAM_ENTRIES); - if (!NT_STATUS_IS_OK(r_u->status) && - !NT_STATUS_EQUAL(r_u->status, STATUS_MORE_ENTRIES)) - return r_u->status; + become_root(); + if (info->disp_info.groups == NULL) + info->disp_info.groups = pdb_search_groups(); + unbecome_root(); + if (info->disp_info.groups == NULL) + return NT_STATUS_ACCESS_DENIED; + + become_root(); + num_groups = pdb_search_entries(info->disp_info.groups, q_u->start_idx, + MAX_SAM_ENTRIES, &groups); + unbecome_root(); + make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, - num_entries, grp); + num_groups, groups); - init_samr_r_enum_dom_groups(r_u, q_u->start_idx+num_entries, - num_entries); + init_samr_r_enum_dom_groups(r_u, q_u->start_idx, num_groups); DEBUG(5,("samr_enum_dom_groups: %d\n", __LINE__)); return r_u->status; } - /******************************************************************* samr_reply_enum_dom_aliases ********************************************************************/ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, SAMR_R_ENUM_DOM_ALIASES *r_u) { - DOMAIN_GRP *grp=NULL; - uint32 num_entries = 0; - fstring sid_str; - DOM_SID sid; + struct samr_info *info; + struct samr_displayentry *aliases; + struct pdb_search **search = NULL; + uint32 num_aliases = 0; NTSTATUS status; - uint32 acc_granted; - + r_u->status = NT_STATUS_OK; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) + /* 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; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_aliases"))) { + r_u->status = access_check_samr_function(info->acc_granted, + SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, + "_samr_enum_dom_aliases"); + if (!NT_STATUS_IS_OK(r_u->status)) return r_u->status; - } - - sid_to_string(sid_str, &sid); - DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", sid_str)); - status = get_alias_entries(p->mem_ctx, &grp, &sid, q_u->start_idx, - &num_entries, MAX_SAM_ENTRIES); - if (!NT_STATUS_IS_OK(status)) return status; + DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", + sid_string_static(&info->sid))); + + if (sid_check_is_domain(&info->sid)) + search = &info->disp_info.aliases; + if (sid_check_is_builtin(&info->sid)) + search = &info->disp_info.builtins; + + if (search == NULL) return NT_STATUS_INVALID_HANDLE; + + become_root(); + if (*search == NULL) + *search = pdb_search_aliases(&info->sid); + unbecome_root(); + + if (*search == NULL) return NT_STATUS_ACCESS_DENIED; - make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_entries, grp); + become_root(); + num_aliases = pdb_search_entries(*search, q_u->start_idx, + MAX_SAM_ENTRIES, &aliases); + unbecome_root(); + + make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, + num_aliases, aliases); - /*safe_free(grp);*/ + if (!NT_STATUS_IS_OK(status)) return status; - init_samr_r_enum_dom_aliases(r_u, q_u->start_idx + num_entries, num_entries); + init_samr_r_enum_dom_aliases(r_u, q_u->start_idx + num_aliases, + num_aliases); DEBUG(5,("samr_enum_dom_aliases: %d\n", __LINE__)); @@ -1053,6 +800,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, enum remote_arch_types ra_type = get_remote_arch(); int max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K; DOM_SID domain_sid; + struct samr_displayentry *entries = NULL; DEBUG(5, ("samr_reply_query_dispinfo: %d\n", __LINE__)); r_u->status = NT_STATUS_OK; @@ -1091,68 +839,29 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, * JFM, 12/20/2001 */ - /* Get what we need from the password database */ - switch (q_u->switch_level) { - case 0x1: - /* When playing with usrmgr, this is necessary - if you want immediate refresh after editing - a user. I would like to do this after the - setuserinfo2, but we do not have access to - the domain handle in that call, only to the - user handle. Where else does this hurt? - -- Volker - */ -#if 0 - /* We cannot do this here - it kills performace. JRA. */ - free_samr_users(info); -#endif - case 0x2: - case 0x4: - become_root(); - /* Level 2 is for all machines, otherwise only 'normal' users */ - r_u->status=load_sampwd_entries(info, ACB_NORMAL, q_u->switch_level==2); - unbecome_root(); - if (!NT_STATUS_IS_OK(r_u->status)) { - DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); - return r_u->status; - } - num_account = info->disp_info.num_user_account; - break; - case 0x3: - case 0x5: - r_u->status = load_group_domain_entries(info, &info->sid); - if (!NT_STATUS_IS_OK(r_u->status)) - return r_u->status; - num_account = info->disp_info.num_group_account; - break; - default: - DEBUG(0,("_samr_query_dispinfo: Unknown info level (%u)\n", (unsigned int)q_u->switch_level )); - return NT_STATUS_INVALID_INFO_CLASS; + if ((q_u->switch_level < 1) || (q_u->switch_level > 5)) { + DEBUG(0,("_samr_query_dispinfo: Unknown info level (%u)\n", + (unsigned int)q_u->switch_level )); + return NT_STATUS_INVALID_INFO_CLASS; } /* first limit the number of entries we will return */ if(max_entries > max_sam_entries) { - DEBUG(5, ("samr_reply_query_dispinfo: client requested %d entries, limiting to %d\n", max_entries, max_sam_entries)); + DEBUG(5, ("samr_reply_query_dispinfo: client requested %d " + "entries, limiting to %d\n", max_entries, + max_sam_entries)); max_entries = max_sam_entries; } - if (enum_context > num_account) { - DEBUG(5, ("samr_reply_query_dispinfo: enumeration handle over total entries\n")); - return NT_STATUS_NO_MORE_ENTRIES; - } - - /* verify we won't overflow */ - if (max_entries > num_account-enum_context) { - max_entries = num_account-enum_context; - DEBUG(5, ("samr_reply_query_dispinfo: only %d entries to return\n", max_entries)); - } + /* calculate the size and limit on the number of entries we will + * return */ - /* calculate the size and limit on the number of entries we will return */ temp_size=max_entries*struct_size; if (temp_size>max_size) { max_entries=MIN((max_size/struct_size),max_entries);; - DEBUG(5, ("samr_reply_query_dispinfo: buffer size limits to only %d entries\n", max_entries)); + DEBUG(5, ("samr_reply_query_dispinfo: buffer size limits to " + "only %d entries\n", max_entries)); } if (!(ctr = TALLOC_ZERO_P(p->mem_ctx,SAM_DISPINFO_CTR))) @@ -1160,61 +869,80 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, ZERO_STRUCTP(ctr); + become_root(); + + switch (q_u->switch_level) { + case 0x1: + case 0x4: + if (info->disp_info.users == NULL) + info->disp_info.users = pdb_search_users(ACB_NORMAL); + if (info->disp_info.users == NULL) + return NT_STATUS_ACCESS_DENIED; + num_account = pdb_search_entries(info->disp_info.users, + enum_context, max_entries, + &entries); + break; + case 0x2: + if (info->disp_info.machines == NULL) + info->disp_info.machines = + pdb_search_users(ACB_WSTRUST|ACB_SVRTRUST); + if (info->disp_info.machines == NULL) + return NT_STATUS_ACCESS_DENIED; + num_account = pdb_search_entries(info->disp_info.machines, + enum_context, max_entries, + &entries); + break; + case 0x3: + case 0x5: + if (info->disp_info.groups == NULL) + info->disp_info.groups = pdb_search_groups(); + if (info->disp_info.groups == NULL) + return NT_STATUS_ACCESS_DENIED; + num_account = pdb_search_entries(info->disp_info.groups, + enum_context, max_entries, + &entries); + break; + default: + smb_panic("info class changed"); + break; + } + unbecome_root(); + /* Now create reply structure */ switch (q_u->switch_level) { case 0x1: - if (max_entries) { - if (!(ctr->sam.info1 = TALLOC_ZERO_ARRAY(p->mem_ctx,SAM_DISPINFO_1,max_entries))) - return NT_STATUS_NO_MEMORY; - } - disp_ret = init_sam_dispinfo_1(p->mem_ctx, ctr->sam.info1, max_entries, enum_context, - info->disp_info.disp_user_info, &domain_sid); - if (!NT_STATUS_IS_OK(disp_ret)) - return disp_ret; + disp_ret = init_sam_dispinfo_1(p->mem_ctx, &ctr->sam.info1, + num_account, enum_context, + entries); break; case 0x2: - if (max_entries) { - if (!(ctr->sam.info2 = TALLOC_ZERO_ARRAY(p->mem_ctx,SAM_DISPINFO_2,max_entries))) - return NT_STATUS_NO_MEMORY; - } - disp_ret = init_sam_dispinfo_2(p->mem_ctx, ctr->sam.info2, max_entries, enum_context, - info->disp_info.disp_user_info, &domain_sid); - if (!NT_STATUS_IS_OK(disp_ret)) - return disp_ret; + disp_ret = init_sam_dispinfo_2(p->mem_ctx, &ctr->sam.info2, + num_account, enum_context, + entries); break; case 0x3: - if (max_entries) { - if (!(ctr->sam.info3 = TALLOC_ZERO_ARRAY(p->mem_ctx,SAM_DISPINFO_3,max_entries))) - return NT_STATUS_NO_MEMORY; - } - disp_ret = init_sam_dispinfo_3(p->mem_ctx, ctr->sam.info3, max_entries, enum_context, info->disp_info.disp_group_info); - if (!NT_STATUS_IS_OK(disp_ret)) - return disp_ret; + disp_ret = init_sam_dispinfo_3(p->mem_ctx, &ctr->sam.info3, + num_account, enum_context, + entries); break; case 0x4: - if (max_entries) { - if (!(ctr->sam.info4 = TALLOC_ZERO_ARRAY(p->mem_ctx,SAM_DISPINFO_4,max_entries))) - return NT_STATUS_NO_MEMORY; - } - disp_ret = init_sam_dispinfo_4(p->mem_ctx, ctr->sam.info4, max_entries, enum_context, info->disp_info.disp_user_info); - if (!NT_STATUS_IS_OK(disp_ret)) - return disp_ret; + disp_ret = init_sam_dispinfo_4(p->mem_ctx, &ctr->sam.info4, + num_account, enum_context, + entries); break; case 0x5: - if (max_entries) { - if (!(ctr->sam.info5 = TALLOC_ZERO_ARRAY(p->mem_ctx,SAM_DISPINFO_5,max_entries))) - return NT_STATUS_NO_MEMORY; - } - disp_ret = init_sam_dispinfo_5(p->mem_ctx, ctr->sam.info5, max_entries, enum_context, info->disp_info.disp_group_info); - if (!NT_STATUS_IS_OK(disp_ret)) - return disp_ret; + disp_ret = init_sam_dispinfo_5(p->mem_ctx, &ctr->sam.info5, + num_account, enum_context, + entries); break; - default: - ctr->sam.info = NULL; - return NT_STATUS_INVALID_INFO_CLASS; + smb_panic("info class changed"); + break; } + if (!NT_STATUS_IS_OK(disp_ret)) + return disp_ret; + /* calculate the total size */ total_data_size=num_account*struct_size; @@ -1223,7 +951,9 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, DEBUG(5, ("_samr_query_dispinfo: %d\n", __LINE__)); - init_samr_r_query_dispinfo(r_u, max_entries, total_data_size, temp_size, q_u->switch_level, ctr, r_u->status); + init_samr_r_query_dispinfo(r_u, num_account, total_data_size, + temp_size, q_u->switch_level, ctr, + r_u->status); return r_u->status; @@ -2106,23 +1836,11 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA flag, nt_expire, nt_min_age); break; case 0x02: - become_root(); - r_u->status=load_sampwd_entries(info, ACB_NORMAL, False); + become_root(); + num_users=count_sam_users(&info->disp_info, + ACB_NORMAL); + num_groups=count_sam_groups(&info->disp_info); unbecome_root(); - if (!NT_STATUS_IS_OK(r_u->status)) { - DEBUG(5, ("_samr_query_dispinfo: load_sampwd_entries failed\n")); - return r_u->status; - } - num_users=info->disp_info.num_user_account; - free_samr_db(info); - - r_u->status=load_group_domain_entries(info, get_global_sam_sid()); - if (!NT_STATUS_IS_OK(r_u->status)) { - DEBUG(5, ("_samr_query_dispinfo: load_group_domain_entries failed\n")); - return r_u->status; - } - num_groups=info->disp_info.num_group_account; - free_samr_db(info); account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); u_logout = account_policy_temp; @@ -4380,13 +4098,9 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN *q_u, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN *r_u) { - DOM_SID delete_sid, alias_sid; - SAM_ACCOUNT *sam_pass=NULL; + DOM_SID delete_sid, domain_sid; uint32 acc_granted; - GROUP_MAP map; - BOOL is_user = False; NTSTATUS result; - enum SID_NAME_USE type = SID_NAME_UNKNOWN; sid_copy( &delete_sid, &q_u->sid.sid ); @@ -4395,7 +4109,8 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &alias_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &domain_sid, + &acc_granted)) return NT_STATUS_INVALID_HANDLE; result = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, @@ -4405,80 +4120,33 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, return result; DEBUG(8, ("_samr_remove_sid_foreign_domain:sid is %s\n", - sid_string_static(&alias_sid))); - - /* make sure we can handle this */ - - if ( sid_check_is_domain(&alias_sid) ) - type = SID_NAME_DOM_GRP; - else if ( sid_check_is_builtin(&alias_sid) ) - type = SID_NAME_ALIAS; - - if ( type == SID_NAME_UNKNOWN ) { - DEBUG(10, ("_samr_remove_sid_foreign_domain: can't operate on what we don't own!\n")); - return NT_STATUS_OK; - } + sid_string_static(&domain_sid))); - /* check if the user exists before trying to delete */ - - pdb_init_sam(&sam_pass); - - if ( pdb_getsampwsid(sam_pass, &delete_sid) ) { - is_user = True; - } else { - /* maybe it is a group */ - if( !pdb_getgrsid(&map, delete_sid) ) { - DEBUG(3,("_samr_remove_sid_foreign_domain: %s is not a user or a group!\n", - sid_string_static(&delete_sid))); - result = NT_STATUS_INVALID_SID; - goto done; - } - } - /* we can only delete a user from a group since we don't have nested groups anyways. So in the latter case, just say OK */ - - if ( is_user ) { - GROUP_MAP *mappings = NULL; - int num_groups, i; - struct group *grp2; - - if ( pdb_enum_group_mapping(type, &mappings, &num_groups, False) && num_groups>0 ) { - - /* interate over the groups */ - for ( i=0; igr_name) ) - continue; - - smb_delete_user_group(grp2->gr_name, pdb_get_username(sam_pass)); - - if ( user_in_unix_group_list(pdb_get_username(sam_pass), grp2->gr_name) ) { - /* should we fail here ? */ - DEBUG(0,("_samr_remove_sid_foreign_domain: Delete user [%s] from group [%s] failed!\n", - pdb_get_username(sam_pass), grp2->gr_name )); - continue; - } - - DEBUG(10,("_samr_remove_sid_foreign_domain: Removed user [%s] from group [%s]!\n", - pdb_get_username(sam_pass), grp2->gr_name )); - } - - SAFE_FREE(mappings); - } + /* TODO: The above comment nowadays is bogus. Since we have nested + * groups now, and aliases members are never reported out of the unix + * group membership, the "just say OK" makes this call a no-op. For + * us. This needs fixing however. */ + + /* I've only ever seen this in the wild when deleting a user from + * usrmgr.exe. domain_sid is the builtin domain, and the sid to delete + * is the user about to be deleted. I very much suspect this is the + * only application of this call. To verify this, let people report + * other cases. */ + + if (!sid_check_is_builtin(&domain_sid)) { + DEBUG(1,("_samr_remove_sid_foreign_domain: domain_sid = %s, " + "global_sam_sid() = %s\n", + sid_string_static(&domain_sid), + sid_string_static(get_global_sam_sid()))); + DEBUGADD(1,("please report to samba-technical@samba.org!\n")); + return NT_STATUS_OK; } - - result = NT_STATUS_OK; -done: - pdb_free_sam(&sam_pass); + + result = NT_STATUS_OK; return result; } @@ -4545,21 +4213,11 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW break; case 0x02: become_root(); - r_u->status=load_sampwd_entries(info, ACB_NORMAL, False); + num_users = count_sam_users(&info->disp_info, + ACB_NORMAL); + num_groups = count_sam_groups(&info->disp_info); unbecome_root(); - if (!NT_STATUS_IS_OK(r_u->status)) { - DEBUG(5, ("_samr_unknown_2e: load_sampwd_entries failed\n")); - return r_u->status; - } - num_users=info->disp_info.num_user_account; - free_samr_db(info); - - r_u->status=load_group_domain_entries(info, get_global_sam_sid()); - if (NT_STATUS_IS_ERR(r_u->status)) { - DEBUG(5, ("_samr_unknown_2e: load_group_domain_entries failed\n")); - return r_u->status; - } - num_groups=info->disp_info.num_group_account; + free_samr_db(info); account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); -- cgit From 57eb9f47d058cc3c841aca11404bae2fed5367e4 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 21 Apr 2005 17:13:50 +0000 Subject: r6421: use add machine script when creating a user (ACB_NORMAL) who has a name ending in '$' (usrmgr.exe does this for domain trusts (that's was jfm's original comment I think). avoid an assert() call in libldap. (This used to be commit 0ac57ae94202190ddbe538f7180a0443463b48cf) --- source3/rpc_server/srv_samr_nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index fe54476cc9..89cb49c05c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1985,13 +1985,15 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA se_priv_copy( &se_rights, &se_machine_account ); can_add_account = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); } - else if ( acb_info & ACB_NORMAL ) + /* usrmgr.exe (and net rpc trustdom grant) creates a normal user + account for domain trusts and changes the ACB flags later */ + else if ( acb_info & ACB_NORMAL && (account[strlen(account)-1] != '$') ) { pstrcpy(add_script, lp_adduser_script()); se_priv_copy( &se_rights, &se_add_users ); can_add_account = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); } - else if ( acb_info & (ACB_SVRTRUST|ACB_DOMTRUST) ) + else /* implicit assumption of a BDC or domain trust account here (we already check the flags earlier) */ { pstrcpy(add_script, lp_addmachine_script()); if ( lp_enable_privileges() ) { -- cgit From 0838e604862b1415a85fa8b05350c40b92681183 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 30 Apr 2005 13:21:13 +0000 Subject: r6536: Jeremy, did you actually test this part of revision 801? I just tested that Windows 2003 returns "4 (Local Group)" for rpcclient -c 'lookupnames "System Operators"' Before #ifdef'ing that out again I would like to see a sniff how you get a "5" (WKN_GRP) out of lsa_lookupnames. Volker (This used to be commit f6e27305101ab0c7e04e55b4905e91c19b31f9ef) --- source3/rpc_server/srv_lsa_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 5e949f0e63..4d79589e59 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -173,12 +173,10 @@ static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, status = lookup_name(dom_name, user, &sid, &name_type); } -#if 0 /* This is not true. */ if (name_type == SID_NAME_WKN_GRP) { /* BUILTIN aliases are still aliases :-) */ name_type = SID_NAME_ALIAS; } -#endif DEBUG(5, ("init_lsa_rid2s: %s\n", status ? "found" : "not found")); -- cgit From a7145e26c99c43a39b24bbf16587b2ea1cd1ef9c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sun, 1 May 2005 20:05:16 +0000 Subject: r6566: fix a couple of local group bugs. * ensure that we set full access on the handle returned from _samr_create_dom_alias() so that future set_alias commands succeed * fix bug when looking for internal domains in winbindd (caused winbindd_getgrgid() for local groups to fail). (This used to be commit 4615c96ccb8906af4eb1fbe6d0cbf6bb3bcc3fcf) --- source3/rpc_server/srv_samr_nt.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 89cb49c05c..040d4e7dea 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -730,9 +730,6 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S struct samr_displayentry *aliases; struct pdb_search **search = NULL; uint32 num_aliases = 0; - NTSTATUS status; - - r_u->status = NT_STATUS_OK; /* find the policy handle. open a policy on it. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) @@ -752,14 +749,16 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S if (sid_check_is_builtin(&info->sid)) search = &info->disp_info.builtins; - if (search == NULL) return NT_STATUS_INVALID_HANDLE; + if (search == NULL) + return NT_STATUS_INVALID_HANDLE; become_root(); if (*search == NULL) *search = pdb_search_aliases(&info->sid); unbecome_root(); - if (*search == NULL) return NT_STATUS_ACCESS_DENIED; + if (*search == NULL) + return NT_STATUS_ACCESS_DENIED; become_root(); num_aliases = pdb_search_entries(*search, q_u->start_idx, @@ -769,8 +768,6 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_aliases, aliases); - if (!NT_STATUS_IS_OK(status)) return status; - init_samr_r_enum_dom_aliases(r_u, q_u->start_idx + num_aliases, num_aliases); @@ -3850,6 +3847,10 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S if ((info = get_samr_info_by_sid(&info_sid)) == NULL) return NT_STATUS_NO_MEMORY; + /* they created it; let the user do what he wants with it */ + + info->acc_granted = GENERIC_RIGHTS_ALIAS_ALL_ACCESS; + /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, &r_u->alias_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; -- cgit From 7b9d6ac23e1a7d8136fffd2e3977b09a815da65a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 3 May 2005 07:33:49 +0000 Subject: r6595: This is Volkers new-talloc patch. Just got the go-ahead from Volker to commit. Woo Hoo ! Jeremy. (This used to be commit 316df944a456f150944761dab34add5e8c4ab699) --- source3/rpc_server/srv_pipe_hnd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 8720a4df68..83b78f8d2f 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -536,11 +536,12 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) a complete PDU. ****************************************************************************/ -void free_pipe_context(pipes_struct *p) +static void free_pipe_context(pipes_struct *p) { if (p->mem_ctx) { - DEBUG(3,("free_pipe_context: destroying talloc pool of size %lu\n", (unsigned long)talloc_pool_size(p->mem_ctx) )); - talloc_destroy_pool(p->mem_ctx); + DEBUG(3,("free_pipe_context: destroying talloc pool of size " + "%llu\n", talloc_total_size(p->mem_ctx) )); + talloc_free_children(p->mem_ctx); } else { p->mem_ctx = talloc_init("pipe %s %p", p->name, p); if (p->mem_ctx == NULL) -- cgit From 28824fb1971afd398739723ee7c65427bd086d4b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 3 May 2005 14:01:39 +0000 Subject: r6601: fixing query and set alias info calls (level 1 from the MMC manage computer plugin. (This used to be commit c43c1ec80cb52569ccabcdf95e4004386ecb29d6) --- source3/rpc_server/srv_samr_nt.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 040d4e7dea..54012d57a9 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -985,17 +985,18 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM if ( !ret ) return NT_STATUS_NO_SUCH_ALIAS; - switch (q_u->switch_level) { + if ( !(r_u->ctr = TALLOC_ZERO_P( p->mem_ctx, ALIAS_INFO_CTR )) ) + return NT_STATUS_NO_MEMORY; + + + switch (q_u->level ) { case 1: - r_u->ptr = 1; - r_u->ctr.switch_value1 = 1; - init_samr_alias_info1(&r_u->ctr.alias.info1, - info.acct_name, 1, info.acct_desc); + r_u->ctr->level = 1; + init_samr_alias_info1(&r_u->ctr->alias.info1, info.acct_name, 1, info.acct_desc); break; case 3: - r_u->ptr = 1; - r_u->ctr.switch_value1 = 3; - init_samr_alias_info3(&r_u->ctr.alias.info3, info.acct_desc); + r_u->ctr->level = 3; + init_samr_alias_info3(&r_u->ctr->alias.info3, info.acct_desc); break; default: return NT_STATUS_INVALID_INFO_CLASS; @@ -3984,11 +3985,13 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ ctr=&q_u->ctr; - switch (ctr->switch_value1) { + switch (ctr->level) { case 3: - unistr2_to_ascii(info.acct_desc, - &(ctr->alias.info3.uni_acct_desc), - sizeof(info.acct_desc)-1); + if ( ctr->alias.info3.description.string ) { + unistr2_to_ascii( info.acct_desc, + ctr->alias.info3.description.string, + sizeof(info.acct_desc)-1 ); + } break; default: return NT_STATUS_INVALID_INFO_CLASS; -- cgit From 03377b2a21af510da78a964b125ebceba13f2bb1 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 7 May 2005 14:55:44 +0000 Subject: r6642: BUG 2686: shouold fix the group_setinfo() failures; similar to alias_setinfo() patch from last week (This used to be commit 611cca473ef6c50aeeda79c323f55e8e3402b1b1) --- source3/rpc_server/srv_samr_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 54012d57a9..69298bcd5d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3780,6 +3780,11 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S if ((info = get_samr_info_by_sid(&info_sid)) == NULL) return NT_STATUS_NO_MEMORY; + + /* they created it; let the user do what he wants with it */ + + info->acc_granted = GENERIC_RIGHTS_GROUP_ALL_ACCESS; + /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, &r_u->pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; -- cgit From 4f3c2d4424823df26e56c8ecbfea54d743469304 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 9 May 2005 12:52:57 +0000 Subject: r6679: BUG 2684: abartlett's patch for check the per service hosts allow/deny on printers when connecting via MS-RPC (This used to be commit 80da9ca3869380541728cb38df93d012eb20c307) --- source3/rpc_server/srv_spoolss_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0f33fd7dec..7daf1630fe 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1730,6 +1730,11 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* check smb.conf parameters and the the sec_desc */ + if ( !check_access(smbd_server_fd(), lp_hostsallow(snum), lp_hostsdeny(snum)) ) { + DEBUG(3, ("access DENIED (hosts allow/deny) for printer open\n")); + return WERR_ACCESS_DENIED; + } + if (!user_ok(uidtoname(user.uid), snum, user.groups, user.ngroups) || !print_access_check(&user, snum, printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); close_printer_handle(p, handle); -- cgit From cf4005a78d5b2ce922abb0f15e0d0207d7c74077 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 9 May 2005 13:51:44 +0000 Subject: r6680: event log patches from Marcin (This used to be commit a71e104af84810f488f42cb0843976961e6f6ebe) --- source3/rpc_server/srv_eventlog_nt.c | 184 ++++++++++++++++++++++++----------- 1 file changed, 126 insertions(+), 58 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 7501434a13..ea7512b58d 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -31,6 +31,8 @@ typedef struct eventlog_info fstring handle_string; uint32 num_records; uint32 oldest_entry; + uint32 active_entry; + uint32 flags; } Eventlog_info; static void free_eventlog_info(void *ptr) @@ -415,7 +417,7 @@ WERROR _eventlog_close_eventlog(pipes_struct *p, return WERR_OK; } -static BOOL _eventlog_read_parse_line(char *line, Eventlog_entry *entry) +static BOOL _eventlog_read_parse_line(char *line, Eventlog_entry *entry, BOOL *eor) { char *start = NULL, *stop = NULL; pstring temp; @@ -423,8 +425,13 @@ static BOOL _eventlog_read_parse_line(char *line, Eventlog_entry *entry) start = line; + /* empty line signyfiying record delimeter, or we're at the end of the buffer */ if(start == NULL || strlen(start) == 0) - return False; + { + DEBUG(6, ("_eventlog_read_parse_line: found end-of-record indicator.\n")); + *eor = True; + return True; + } if(!(stop = strchr(line, ':'))) return False; @@ -514,8 +521,11 @@ static BOOL _eventlog_read_parse_line(char *line, Eventlog_entry *entry) else if(0 == strncmp(start, "SRC", stop - start)) { memset(temp, 0, sizeof(temp)); - sscanf(stop+1, "%s", temp); - temp_len = strlen(temp); + stop++; + while(isspace(stop[0])) + stop++; + temp_len = strlen(stop); + strncpy(temp, stop, temp_len); rpcstr_push((void *)(entry->data_record.source_name), temp, sizeof(entry->data_record.source_name), STR_TERMINATE); entry->data_record.source_name_len = (strlen_w(entry->data_record.source_name)* 2) + 2; @@ -523,8 +533,11 @@ static BOOL _eventlog_read_parse_line(char *line, Eventlog_entry *entry) else if(0 == strncmp(start, "SRN", stop - start)) { memset(temp, 0, sizeof(temp)); - sscanf(stop+1, "%s", temp); - temp_len = strlen(temp); + stop++; + while(isspace(stop[0])) + stop++; + temp_len = strlen(stop); + strncpy(temp, stop, temp_len); rpcstr_push((void *)(entry->data_record.computer_name), temp, sizeof(entry->data_record.computer_name), STR_TERMINATE); entry->data_record.computer_name_len = (strlen_w(entry->data_record.computer_name)* 2) + 2; @@ -532,8 +545,11 @@ static BOOL _eventlog_read_parse_line(char *line, Eventlog_entry *entry) else if(0 == strncmp(start, "SID", stop - start)) { memset(temp, 0, sizeof(temp)); - sscanf(stop+1, "%s", temp); - temp_len = strlen(temp); + stop++; + while(isspace(stop[0])) + stop++; + temp_len = strlen(stop); + strncpy(temp, stop, temp_len); rpcstr_push((void *)(entry->data_record.sid), temp, sizeof(entry->data_record.sid), STR_TERMINATE); entry->record.user_sid_length = (strlen_w(entry->data_record.sid) * 2) + 2; @@ -597,6 +613,7 @@ static BOOL _eventlog_read_parse_line(char *line, Eventlog_entry *entry) * between the oldest_record and oldest_record+num_records, and the buffer size is the * maximum size of the buffer that the client can accomodate. * OUTPUT: A buffer containing a set of entries, one to a line, of the format: + * Multiple log entries can be contained in the buffer, delimited by an empty line * line type:line data * These are the allowed line types: * RS1:(uint32) - reserved. All M$ entries seem to have int(1699505740) for now @@ -615,16 +632,21 @@ static BOOL _eventlog_read_parse_line(char *line, Eventlog_entry *entry) * STR:[(uint8)] - String data. One string per line. Multiple strings can be specified using consecutive "STR" lines, * up to a total aggregate string length of 1024 characters. * DAT:[(uint8)] - The user-defined data portion of the event log. Can not be multiple lines. + * - end-of-record indicator */ -static BOOL _eventlog_read_eventlog_hook(Eventlog_info *info, Eventlog_entry *entry, const char *direction, int starting_record, int buffer_size, BOOL *eof) +static BOOL _eventlog_read_eventlog_hook(Eventlog_info *info, + Eventlog_entry *entry, + const char *direction, + int starting_record, + int buffer_size, + BOOL *eof, + char ***buffer, + int *numlines) { char *cmd = lp_eventlog_read_cmd(); - char **qlines; pstring command; - int numlines = 0; int ret; int fd = -1; - int i; if(info == NULL) return False; @@ -643,6 +665,8 @@ static BOOL _eventlog_read_eventlog_hook(Eventlog_info *info, Eventlog_entry *en buffer_size, info->handle_string); + *numlines = 0; + DEBUG(10, ("Running [%s]\n", command)); ret = smbrun(command, &fd); DEBUGADD(10, ("returned [%d]\n", ret)); @@ -654,38 +678,40 @@ static BOOL _eventlog_read_eventlog_hook(Eventlog_info *info, Eventlog_entry *en return False; } - qlines = fd_lines_load(fd, &numlines); - DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); + *buffer = fd_lines_load(fd, numlines); + DEBUGADD(10, ("Lines returned = [%d]\n", *numlines)); close(fd); - if(numlines) + if(*numlines) { + /* for(i = 0; i < numlines; i++) { DEBUGADD(10, ("Line[%d] = %s\n", i, qlines[i])); _eventlog_read_parse_line(qlines[i], entry); } file_lines_free(qlines); + */ + *eof = False; return True; } - else - *eof = True; + *eof = True; - file_lines_free(qlines); +/* file_lines_free(qlines);*/ return False; } -static BOOL _eventlog_read_prepare_data_buffer(prs_struct *ps, - EVENTLOG_Q_READ_EVENTLOG *q_u, - EVENTLOG_R_READ_EVENTLOG *r_u, - Eventlog_entry *entry) +static Eventlog_entry *_eventlog_read_package_entry(prs_struct *ps, + EVENTLOG_Q_READ_EVENTLOG *q_u, + EVENTLOG_R_READ_EVENTLOG *r_u, + Eventlog_entry *entry) { uint8 *offset; - Eventlog_entry *new = NULL, *insert_point = NULL; + Eventlog_entry *new = NULL; new = PRS_ALLOC_MEM(ps, Eventlog_entry, 1); if(new == NULL) - return False; + return NULL; entry->data_record.sid_padding = ((4 - ((entry->data_record.source_name_len + entry->data_record.computer_name_len) % 4)) %4); @@ -714,7 +740,7 @@ static BOOL _eventlog_read_prepare_data_buffer(prs_struct *ps, DEBUG(10, ("entry->record.length is [%d].\n", entry->record.length)); entry->data = PRS_ALLOC_MEM(ps, uint8, entry->record.length - sizeof(Eventlog_record) - sizeof(entry->record.length)); if(entry->data == NULL) - return False; + return NULL; offset = entry->data; memcpy(offset, &(entry->data_record.source_name), entry->data_record.source_name_len); offset += entry->data_record.source_name_len; @@ -734,8 +760,18 @@ static BOOL _eventlog_read_prepare_data_buffer(prs_struct *ps, entry->record.data_offset = sizeof(Eventlog_record) + (offset - entry->data); memcpy(offset, &(entry->data_record.user_data), entry->data_record.user_data_len); offset += entry->data_record.user_data_len; - /* Now that we've massaged the current entry, copy it into the new entry and add it - to end of the list */ + + memcpy(&(new->record), &entry->record, sizeof(Eventlog_record)); + memcpy(&(new->data_record), &entry->data_record, sizeof(Eventlog_data_record)); + new->data = entry->data; + + return new; +} + +static BOOL _eventlog_add_record_to_resp(EVENTLOG_R_READ_EVENTLOG *r_u, Eventlog_entry *new) +{ + Eventlog_entry *insert_point; + insert_point=r_u->entry; if (NULL == insert_point) @@ -752,65 +788,97 @@ static BOOL _eventlog_read_prepare_data_buffer(prs_struct *ps, new->next = NULL; insert_point->next = new; } - - memcpy(&(new->record), &entry->record, sizeof(Eventlog_record)); - memcpy(&(new->data_record), &entry->data_record, sizeof(Eventlog_data_record)); - new->data = entry->data; - r_u->num_records++; - r_u->num_bytes_in_resp += entry->record.length; + r_u->num_bytes_in_resp += new->record.length; return True; } - + WERROR _eventlog_read_eventlog(pipes_struct *p, EVENTLOG_Q_READ_EVENTLOG *q_u, EVENTLOG_R_READ_EVENTLOG *r_u) { Eventlog_info *info = NULL; POLICY_HND *handle; - Eventlog_entry entry; - BOOL eof = False; + Eventlog_entry entry, *new; + BOOL eof = False, eor = False; const char *direction = ""; - int starting_record; + uint32 num_records_read = 0; prs_struct *ps; + int numlines, i; + char **buffer; if(!q_u || !r_u) return WERR_NOMEM; handle = &(q_u->handle); info = find_eventlog_info_by_hnd(p, handle); + info->flags = q_u->flags; ps = &p->out_data.rdata; - /* Rather than checking the EVENTLOG_SEQUENTIAL_READ/EVENTLOG_SEEK_READ flags, - we'll just go to the offset specified in the request, or the oldest entry - if no offset is specified */ - if(q_u->offset > 0) - starting_record = q_u->offset; - else - starting_record = info->oldest_entry; + /* if this is the first time we're reading on this handle */ + if(info->active_entry == 0) + { + /* Rather than checking the EVENTLOG_SEQUENTIAL_READ/EVENTLOG_SEEK_READ flags, + we'll just go to the offset specified in the request, or the oldest entry + if no offset is specified */ + if(q_u->offset > 0) + info->active_entry = q_u->offset; + else + info->active_entry = info->oldest_entry; + + } + if(q_u->flags & EVENTLOG_FORWARDS_READ) direction = "forward"; else if(q_u->flags & EVENTLOG_BACKWARDS_READ) direction = "backward"; - do + if(!(_eventlog_read_eventlog_hook(info, &entry, direction, info->active_entry, q_u->max_read_size, &eof, &buffer, &numlines))) { - ZERO_STRUCT(entry); - if(!(_eventlog_read_eventlog_hook(info, &entry, direction, starting_record, q_u->max_read_size, &eof))) - { - if(eof == False) - return WERR_NOMEM; - } if(eof == False) + return WERR_NOMEM; + } + if(numlines > 0) + { + ZERO_STRUCT(entry); + for(i = 0; i < numlines; i++) { - /* only if the read hook returned data */ - if(!(_eventlog_read_prepare_data_buffer(ps, q_u, r_u, &entry))) - return WERR_NOMEM; - DEBUG(10, ("_eventlog_read_eventlog: read [%d] bytes out of a max of [%d].\n", - r_u->num_bytes_in_resp, - q_u->max_read_size)); + num_records_read = r_u->num_records; + DEBUGADD(10, ("Line[%d] = [%s]\n", i, buffer[i])); + _eventlog_read_parse_line(buffer[i], &entry, &eor); + if(eor == True) + { + /* package new entry */ + if((new = _eventlog_read_package_entry(ps, q_u, r_u, &entry)) == NULL) + { + free(buffer); + return WERR_NOMEM; + } + /* Now see if there is enough room to add */ + if(r_u->num_bytes_in_resp + new->record.length > q_u->max_read_size) + { + r_u->bytes_in_next_record = new->record.length; + /* response would be too big to fit in client-size buffer */ + break; + } + _eventlog_add_record_to_resp(r_u, new); + ZERO_STRUCT(entry); + eor=False; + num_records_read = r_u->num_records - num_records_read; + DEBUG(10, ("_eventlog_read_eventlog: read [%d] records for a total of [%d] records using [%d] bytes out of a max of [%d].\n", + num_records_read, + r_u->num_records, + r_u->num_bytes_in_resp, + q_u->max_read_size)); + /* update the active record */ + if(info->flags & EVENTLOG_FORWARDS_READ) + info->active_entry += num_records_read; + else if(info->flags & EVENTLOG_BACKWARDS_READ) + info->active_entry -= num_records_read; + } } - } while((r_u->num_bytes_in_resp <= q_u->max_read_size) && (eof != True)); + free(buffer); + } return WERR_OK; } -- cgit From 0e5aa494dd57a598ce1ac6e7141273fbe7bcf113 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 13 May 2005 09:18:50 +0000 Subject: r6772: Fix a valgrind error for samr_open_alias uncovered by one of John's test. Jerry, in query_aliasmem, set_aliasinfo and set_groupinfo (and possibly others) need become_root()/unbecome_root() around the pdb calls. I'm not sure I would do the access checks correctly, I would much rather leave that to you. Volker (This used to be commit 88a67e96d1c54fddadbb6a33e4bc5fba884e58e6) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 69298bcd5d..e4588b2e61 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2389,7 +2389,7 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &ali_generic_mapping, NULL, 0); se_map_generic(&des_access,&ali_generic_mapping); - se_priv_add( &se_rights, &se_add_users ); + se_priv_copy( &se_rights, &se_add_users ); status = access_check_samr_object(psd, p->pipe_user.nt_user_token, -- cgit From fe0ce8dd8e18de6110404661f26db7a66ebac5ad Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 18 May 2005 18:02:15 +0000 Subject: r6890: Refactor printing interface to take offset into job. Fixes bug where large print jobs can have out-of-order offsets. Bug found by Arcady Chernyak Jeremy. (This used to be commit 482f7e0e3706098b71aa0b31a134994acb1e9fcf) --- source3/rpc_server/srv_spoolss_nt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7daf1630fe..b7091b2ade 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5798,8 +5798,9 @@ WERROR _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; - (*buffer_written) = print_job_write(snum, Printer->jobid, (char *)buffer, buffer_size); - if (*buffer_written == -1) { + (*buffer_written) = (uint32)print_job_write(snum, Printer->jobid, (const char *)buffer, + (SMB_OFF_T)-1, (size_t)buffer_size); + if (*buffer_written == (uint32)-1) { r_u->buffer_written = 0; if (errno == ENOSPC) return WERR_NO_SPOOL_SPACE; -- cgit From f0c650a38286c07b9f3e83139c15bfbadc70ad5f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 23 May 2005 16:25:31 +0000 Subject: r6942: * merging the registry changes back to the 3.0 tree * removing the testprns tool (This used to be commit 81ffb0dbbbd244623507880c323a3c37e2b8dc4d) --- source3/rpc_server/srv_reg_nt.c | 237 +++++++++++++++++++++++++++++++++--- source3/rpc_server/srv_spoolss_nt.c | 103 ++++++---------- source3/rpc_server/srv_srvsvc_nt.c | 22 +++- 3 files changed, 274 insertions(+), 88 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index f031a3213f..4211e9b9f4 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -25,6 +25,7 @@ /* Implementation of registry functions. */ #include "includes.h" +#include "regfio.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV @@ -38,6 +39,10 @@ ((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) +/* no idea if this is correct, just use the file access bits for now */ + +struct generic_mapping reg_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; + static REGISTRY_KEY *regkeys_list; @@ -534,7 +539,7 @@ WERROR _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u) /* subkey has the string name now */ - init_reg_r_enum_key( r_u, subkey, q_u->unknown_1, q_u->unknown_2 ); + init_reg_r_enum_key( r_u, subkey ); DEBUG(5,("_reg_enum_key: Exit\n")); @@ -625,6 +630,7 @@ WERROR _reg_shutdown_ex(pipes_struct *p, REG_Q_SHUTDOWN_EX *q_u, REG_R_SHUTDOWN_ int ret; BOOL can_shutdown; + pstrcpy(shutdown_script, lp_shutdown_script()); if ( !*shutdown_script ) @@ -635,7 +641,7 @@ WERROR _reg_shutdown_ex(pipes_struct *p, REG_Q_SHUTDOWN_EX *q_u, REG_R_SHUTDOWN_ pstrcpy( message, "" ); if ( q_u->message ) { UNISTR2 *msg_string = q_u->message->string; - + rpcstr_pull( message, msg_string->buffer, sizeof(message), msg_string->uni_str_len*2, 0 ); } alpha_strcpy (chkmsg, message, NULL, sizeof(message)); @@ -650,7 +656,7 @@ WERROR _reg_shutdown_ex(pipes_struct *p, REG_Q_SHUTDOWN_EX *q_u, REG_R_SHUTDOWN_ all_string_sub( shutdown_script, "%r", r, sizeof(shutdown_script) ); all_string_sub( shutdown_script, "%f", f, sizeof(shutdown_script) ); all_string_sub( shutdown_script, "%x", reason, sizeof(shutdown_script) ); - + can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_remote_shutdown ); /* IF someone has privs, run the shutdown script as root. OTHERWISE run it as not root @@ -667,7 +673,7 @@ WERROR _reg_shutdown_ex(pipes_struct *p, REG_Q_SHUTDOWN_EX *q_u, REG_R_SHUTDOWN_ unbecome_root(); /********** END SeRemoteShutdownPrivilege BLOCK **********/ - + DEBUG(3,("_reg_shutdown_ex: Running the command `%s' gave %d\n", shutdown_script, ret)); @@ -714,6 +720,48 @@ WERROR _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABO return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; } +/******************************************************************* + ********************************************************************/ + +static int validate_reg_filename( pstring fname ) +{ + char *p; + int num_services = lp_numservices(); + int snum; + pstring share_path; + pstring unix_fname; + + /* convert to a unix path, stripping the C:\ along the way */ + + if ( !(p = valid_share_pathname( fname ) )) + return -1; + + /* has to exist within a valid file share */ + + for ( snum=0; snumpol ); pstring filename; + int snum; DEBUG(5,("_reg_restore_key: Enter\n")); - /* - * basically this is a no op function which just verifies - * that the client gave us a valid registry key handle - */ - if ( !regkey ) return WERR_BADFID; @@ -736,14 +780,169 @@ WERROR _reg_restore_key(pipes_struct *p, REG_Q_RESTORE_KEY *q_u, REG_R_RESTORE_ DEBUG(8,("_reg_restore_key: verifying restore of key [%s] from \"%s\"\n", regkey->name, filename)); + if ( (snum = validate_reg_filename( filename )) == -1 ) + return WERR_OBJECT_PATH_INVALID; + + DEBUG(2,("_reg_restore_key: Restoring [%s] from %s in share %s\n", regkey->name, filename, lp_servicename(snum) )); + #if 0 - validate_reg_filemame( filename ); return restore_registry_key( regkey, filename ); #endif return WERR_OK; } +/******************************************************************** +********************************************************************/ + +static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, + REGF_NK_REC *parent, SEC_DESC *sec_desc ) +{ + REGF_NK_REC *key; + REGVAL_CTR values; + REGSUBKEY_CTR subkeys; + int i, num_subkeys; + pstring key_tmp; + char *keyname, *parentpath; + pstring subkeypath; + char *subkeyname; + REGISTRY_KEY registry_key; + WERROR result = WERR_OK; + + if ( !regfile ) + return WERR_GENERAL_FAILURE; + + if ( !keypath ) + return WERR_OBJECT_PATH_INVALID; + + /* split up the registry key path */ + + pstrcpy( key_tmp, keypath ); + if ( !reg_split_key( key_tmp, &parentpath, &keyname ) ) + return WERR_OBJECT_PATH_INVALID; + + if ( !keyname ) + keyname = parentpath; + + /* we need a REGISTRY_KEY object here to enumerate subkeys and values */ + + ZERO_STRUCT( registry_key ); + pstrcpy( registry_key.name, keypath ); + if ( !(registry_key.hook = reghook_cache_find( registry_key.name )) ) + return WERR_BADFILE; + + + /* lookup the values and subkeys */ + + ZERO_STRUCT( values ); + ZERO_STRUCT( subkeys ); + + regsubkey_ctr_init( &subkeys ); + regval_ctr_init( &values ); + + fetch_reg_keys( ®istry_key, &subkeys ); + fetch_reg_values( ®istry_key, &values ); + + /* write out this key */ + + if ( !(key = regfio_write_key( regfile, keyname, &values, &subkeys, sec_desc, parent )) ) { + result = WERR_CAN_NOT_COMPLETE; + goto done; + } + + /* write each one of the subkeys out */ + + num_subkeys = regsubkey_ctr_numkeys( &subkeys ); + for ( i=0; imem_ctx, &sd )) ) { + regfio_close( regfile ); + return result; + } + + /* write the registry tree to the file */ + + result = reg_write_tree( regfile, krecord->name, NULL, sd ); + + /* cleanup */ + + regfio_close( regfile ); + + return result; +} + /******************************************************************* ********************************************************************/ @@ -751,25 +950,23 @@ WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) { REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); pstring filename; + int snum; DEBUG(5,("_reg_save_key: Enter\n")); - - /* - * basically this is a no op function which just verifies - * that the client gave us a valid registry key handle - */ - + if ( !regkey ) return WERR_BADFID; rpcstr_pull(filename, q_u->filename.string->buffer, sizeof(filename), q_u->filename.string->uni_str_len*2, STR_TERMINATE); DEBUG(8,("_reg_save_key: verifying backup of key [%s] to \"%s\"\n", regkey->name, filename)); - -#if 0 - validate_reg_filemame( filename ); + + if ( (snum = validate_reg_filename( filename )) == -1 ) + return WERR_OBJECT_PATH_INVALID; + + DEBUG(2,("_reg_save_key: Saving [%s] to %s in share %s\n", regkey->name, filename, lp_servicename(snum) )); + return backup_registry_key( regkey, filename ); -#endif return WERR_OK; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b7091b2ade..2fee1972ab 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2353,9 +2353,8 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint *type = REG_BINARY; *needed = 0x114; - if((*data = (uint8 *)TALLOC(ctx, *needed)) == NULL) + if ( !(*data = TALLOC_ZERO_ARRAY(ctx, uint8, *needed)) ) return WERR_NOMEM; - ZERO_STRUCTP( *data ); SIVAL(*data, 0, *needed); /* size */ SIVAL(*data, 4, 5); /* Windows 2000 == 5.0 */ @@ -7249,16 +7248,11 @@ static void fill_port_2(PORT_INFO_2 *port, const char *name) } /**************************************************************************** - enumports level 1. + wrapper around the enumer ports command ****************************************************************************/ -static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +WERROR enumports_hook( int *count, char ***lines ) { - PORT_INFO_1 *ports=NULL; - int i=0; - WERROR result = WERR_OK; - - if (*lp_enumports_cmd()) { char *cmd = lp_enumports_cmd(); char **qlines; pstring command; @@ -7266,6 +7260,18 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need int ret; int fd; + + /* if no hook then just fill in the default port */ + + if ( !*cmd ) { + qlines = SMB_MALLOC_ARRAY( char*, 2 ); + qlines[0] = SMB_STRDUP( SAMBA_PRINTER_PORT_NAME ); + qlines[1] = NULL; + numlines = 1; + } + else { + /* we have a valid enumport command */ + slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 1); DEBUG(10,("Running [%s]\n", command)); @@ -7274,7 +7280,7 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need if (ret != 0) { if (fd != -1) close(fd); - /* Is this the best error to return here? */ + return WERR_ACCESS_DENIED; } @@ -7282,6 +7288,28 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need qlines = fd_lines_load(fd, &numlines); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); close(fd); + } + + *count = numlines; + *lines = qlines; + + return WERR_OK; +} + +/**************************************************************************** + enumports level 1. +****************************************************************************/ + +static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +{ + PORT_INFO_1 *ports=NULL; + int i=0; + WERROR result = WERR_OK; + char **qlines; + int numlines; + + if ( !W_ERROR_IS_OK(result = enumports_hook( &numlines, &qlines )) ) + return result; if(numlines) { if((ports=SMB_MALLOC_ARRAY( PORT_INFO_1, numlines )) == NULL) { @@ -7301,17 +7329,6 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need *returned = numlines; - } else { - *returned = 1; /* Sole Samba port returned. */ - - if((ports=SMB_MALLOC_P(PORT_INFO_1)) == NULL) - return WERR_NOMEM; - - DEBUG(10,("enumports_level_1: port name %s\n", SAMBA_PRINTER_PORT_NAME)); - - fill_port_1(&ports[0], SAMBA_PRINTER_PORT_NAME); - } - /* check the required size. */ for (i=0; i<*returned; i++) { DEBUGADD(6,("adding port [%d]'s size\n", i)); @@ -7352,40 +7369,12 @@ static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *need PORT_INFO_2 *ports=NULL; int i=0; WERROR result = WERR_OK; - - if (*lp_enumports_cmd()) { - char *cmd = lp_enumports_cmd(); - char *path; char **qlines; - pstring tmp_file; - pstring command; int numlines; - int ret; - int fd; - - if (*lp_pathname(lp_servicenumber(PRINTERS_NAME))) - path = lp_pathname(lp_servicenumber(PRINTERS_NAME)); - else - path = lp_lockdir(); - - slprintf(tmp_file, sizeof(tmp_file)-1, "%s/smbcmd.%u.", path, (unsigned int)sys_getpid()); - slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 2); - unlink(tmp_file); - DEBUG(10,("Running [%s > %s]\n", command,tmp_file)); - ret = smbrun(command, &fd); - DEBUGADD(10,("returned [%d]\n", ret)); - if (ret != 0) { - if (fd != -1) - close(fd); - /* Is this the best error to return here? */ - return WERR_ACCESS_DENIED; - } + if ( !W_ERROR_IS_OK(result = enumports_hook( &numlines, &qlines )) ) + return result; - numlines = 0; - qlines = fd_lines_load(fd, &numlines); - DEBUGADD(10,("Lines returned = [%d]\n", numlines)); - close(fd); if(numlines) { if((ports=SMB_MALLOC_ARRAY( PORT_INFO_2, numlines)) == NULL) { @@ -7403,18 +7392,6 @@ static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *need *returned = numlines; - } else { - - *returned = 1; - - if((ports=SMB_MALLOC_P(PORT_INFO_2)) == NULL) - return WERR_NOMEM; - - DEBUG(10,("enumports_level_2: port name %s\n", SAMBA_PRINTER_PORT_NAME)); - - fill_port_2(&ports[0], SAMBA_PRINTER_PORT_NAME); - } - /* check the required size. */ for (i=0; i<*returned; i++) { DEBUGADD(6,("adding port [%d]'s size\n", i)); diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index b5768a09af..0e699d922b 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1480,7 +1480,7 @@ WERROR _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, S Check a given DOS pathname is valid for a share. ********************************************************************/ -static char *valid_share_pathname(char *dos_pathname) +char *valid_share_pathname(char *dos_pathname) { char *ptr; @@ -1493,7 +1493,7 @@ static char *valid_share_pathname(char *dos_pathname) if (strlen(dos_pathname) > 2 && ptr[1] == ':' && ptr[0] != '/') ptr += 2; - /* Only abolute paths allowed. */ + /* Only absolute paths allowed. */ if (*ptr != '/') return NULL; @@ -1525,8 +1525,12 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S r_u->parm_error = 0; - if (strequal(share_name,"IPC$") || strequal(share_name,"ADMIN$") || strequal(share_name,"global")) + if ( strequal(share_name,"IPC$") + || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) + || strequal(share_name,"global") ) + { return WERR_ACCESS_DENIED; + } snum = find_service(share_name); @@ -1756,8 +1760,12 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S return WERR_UNKNOWN_LEVEL; } - if (strequal(share_name,"IPC$") || strequal(share_name,"ADMIN$") || strequal(share_name,"global")) + if ( strequal(share_name,"IPC$") + || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) + || strequal(share_name,"global") ) + { return WERR_ACCESS_DENIED; + } snum = find_service(share_name); @@ -1839,8 +1847,12 @@ WERROR _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")) + if ( strequal(share_name,"IPC$") + || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) + || strequal(share_name,"global") ) + { return WERR_ACCESS_DENIED; + } snum = find_service(share_name); -- cgit From 450e8d5749504f8392c0cfe8b79218f03b88076a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 31 May 2005 02:23:47 +0000 Subject: r7130: remove 'winbind enable local accounts' code from the 3.0 tree (This used to be commit 318c3db4cb1c85be40b2f812f781bcf5f1da5c19) --- source3/rpc_server/srv_samr_nt.c | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e4588b2e61..73ea575ec5 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2017,14 +2017,6 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA add_ret = smbrun(add_script,NULL); DEBUG(add_ret ? 0 : 3,("_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); } - else /* no add user script -- ask winbindd to do it */ - { - if ( !winbind_create_user( account, &new_rid ) ) { - DEBUG(3,("_samr_create_user: winbind_create_user(%s) failed\n", - account)); - } - } - } /* implicit call to getpwnam() next. we have a valid SID coming out of this call */ @@ -3466,18 +3458,6 @@ static int smb_delete_user(const char *unix_user) pstring del_script; int ret; - /* try winbindd first since it is impossible to determine where - a user came from via NSS. Try the delete user script if this fails - meaning the user did not exist in winbindd's list of accounts */ - - if ( winbind_delete_user( unix_user ) ) { - DEBUG(3,("winbind_delete_user: removed user (%s)\n", unix_user)); - return 0; - } - - - /* fall back to 'delete user script' */ - pstrcpy(del_script, lp_deluser_script()); if (! *del_script) return -1; -- cgit From f24d88cf9da46680d52b42b92bd484e7b09ce99b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 31 May 2005 13:46:45 +0000 Subject: r7139: trying to reduce the number of diffs between trunk and 3.0; changing version to 3.0.20pre1 (This used to be commit 9727d05241574042dd3aa8844ae5c701d22e2da1) --- source3/rpc_server/srv_lsa.c | 159 +++++++++++++++++++++++++++++++++++- source3/rpc_server/srv_lsa_nt.c | 41 +++++++++- source3/rpc_server/srv_netlog_nt.c | 6 -- source3/rpc_server/srv_spoolss_nt.c | 77 ++++++++--------- 4 files changed, 237 insertions(+), 46 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index dbd5d8c0bf..fc84dbe923 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -6,6 +6,7 @@ * Copyright (C) Paul Ashton 1997, * Copyright (C) Jeremy Allison 2001, * Copyright (C) Jim McDonough 2002-2003. + * Copyright (C) Gerald (Jerry) Carter 2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -765,6 +766,156 @@ static BOOL api_lsa_lookup_priv_value(pipes_struct *p) return True; } +/*************************************************************************** + ***************************************************************************/ + +static BOOL api_lsa_open_trust_dom(pipes_struct *p) +{ + LSA_Q_OPEN_TRUSTED_DOMAIN q_u; + LSA_R_OPEN_TRUSTED_DOMAIN r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_open_trusted_domain("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_open_trust_dom: failed to unmarshall LSA_Q_OPEN_TRUSTED_DOMAIN .\n")); + return False; + } + + r_u.status = _lsa_open_trusted_domain(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_open_trusted_domain("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_open_trust_dom: Failed to marshall LSA_R_OPEN_TRUSTED_DOMAIN.\n")); + return False; + } + + return True; +} + +/*************************************************************************** + ***************************************************************************/ + +static BOOL api_lsa_create_trust_dom(pipes_struct *p) +{ + LSA_Q_CREATE_TRUSTED_DOMAIN q_u; + LSA_R_CREATE_TRUSTED_DOMAIN r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_create_trusted_domain("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_create_trust_dom: failed to unmarshall LSA_Q_CREATE_TRUSTED_DOMAIN .\n")); + return False; + } + + r_u.status = _lsa_create_trusted_domain(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_create_trusted_domain("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_create_trust_dom: Failed to marshall LSA_R_CREATE_TRUSTED_DOMAIN.\n")); + return False; + } + + return True; +} + +/*************************************************************************** + ***************************************************************************/ + +static BOOL api_lsa_create_secret(pipes_struct *p) +{ + LSA_Q_CREATE_SECRET q_u; + LSA_R_CREATE_SECRET r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_create_secret("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_create_secret: failed to unmarshall LSA_Q_CREATE_SECRET.\n")); + return False; + } + + r_u.status = _lsa_create_secret(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_create_secret("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_create_secret: Failed to marshall LSA_R_CREATE_SECRET.\n")); + return False; + } + + return True; +} + +/*************************************************************************** + ***************************************************************************/ + +static BOOL api_lsa_set_secret(pipes_struct *p) +{ + LSA_Q_SET_SECRET q_u; + LSA_R_SET_SECRET r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_set_secret("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_set_secret: failed to unmarshall LSA_Q_SET_SECRET.\n")); + return False; + } + + r_u.status = _lsa_set_secret(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_set_secret("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_set_secret: Failed to marshall LSA_R_SET_SECRET.\n")); + return False; + } + + return True; +} + +/*************************************************************************** + ***************************************************************************/ + +static BOOL api_lsa_delete_object(pipes_struct *p) +{ + LSA_Q_DELETE_OBJECT q_u; + LSA_R_DELETE_OBJECT r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!lsa_io_q_delete_object("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_delete_object: failed to unmarshall LSA_Q_DELETE_OBJECT.\n")); + return False; + } + + r_u.status = _lsa_delete_object(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_delete_object("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_delete_object: Failed to marshall LSA_R_DELETE_OBJECT.\n")); + return False; + } + + return True; +} + #if 0 /* AD DC work in ongoing in Samba 4 */ /*************************************************************************** @@ -827,7 +978,13 @@ static struct api_struct api_lsa_cmds[] = { "LSA_REMOVEACCTRIGHTS", LSA_REMOVEACCTRIGHTS, api_lsa_remove_acct_rights }, { "LSA_ENUMACCTRIGHTS" , LSA_ENUMACCTRIGHTS , api_lsa_enum_acct_rights }, { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, - { "LSA_LOOKUPPRIVVALUE" , LSA_LOOKUPPRIVVALUE , api_lsa_lookup_priv_value } + { "LSA_LOOKUPPRIVVALUE" , LSA_LOOKUPPRIVVALUE , api_lsa_lookup_priv_value }, + { "LSA_OPENTRUSTDOM" , LSA_OPENTRUSTDOM , api_lsa_open_trust_dom }, + { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret }, + { "LSA_CREATETRUSTDOM" , LSA_CREATETRUSTDOM , api_lsa_create_trust_dom }, + { "LSA_CREATSECRET" , LSA_CREATESECRET , api_lsa_create_secret }, + { "LSA_SETSECRET" , LSA_SETSECRET , api_lsa_set_secret }, + { "LSA_DELETEOBJECT" , LSA_DELETEOBJECT , api_lsa_delete_object } #if 0 /* AD DC work in ongoing in Samba 4 */ /* be careful of the adding of new RPC's. See commentrs below about ADS DC capabilities */ diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 4d79589e59..b724508e0b 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -749,7 +749,6 @@ NTSTATUS _lsa_close(pipes_struct *p, LSA_Q_CLOSE *q_u, LSA_R_CLOSE *r_u) } /*************************************************************************** - "No more secrets Marty...." :-). ***************************************************************************/ NTSTATUS _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SECRET *r_u) @@ -757,6 +756,46 @@ NTSTATUS _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SE return NT_STATUS_OBJECT_NAME_NOT_FOUND; } +/*************************************************************************** + ***************************************************************************/ + +NTSTATUS _lsa_open_trusted_domain(pipes_struct *p, LSA_Q_OPEN_TRUSTED_DOMAIN *q_u, LSA_R_OPEN_TRUSTED_DOMAIN *r_u) +{ + return NT_STATUS_OBJECT_NAME_NOT_FOUND; +} + +/*************************************************************************** + ***************************************************************************/ + +NTSTATUS _lsa_create_trusted_domain(pipes_struct *p, LSA_Q_CREATE_TRUSTED_DOMAIN *q_u, LSA_R_CREATE_TRUSTED_DOMAIN *r_u) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/*************************************************************************** + ***************************************************************************/ + +NTSTATUS _lsa_create_secret(pipes_struct *p, LSA_Q_CREATE_SECRET *q_u, LSA_R_CREATE_SECRET *r_u) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/*************************************************************************** + ***************************************************************************/ + +NTSTATUS _lsa_set_secret(pipes_struct *p, LSA_Q_SET_SECRET *q_u, LSA_R_SET_SECRET *r_u) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/*************************************************************************** + ***************************************************************************/ + +NTSTATUS _lsa_delete_object(pipes_struct *p, LSA_Q_DELETE_OBJECT *q_u, LSA_R_DELETE_OBJECT *r_u) +{ + return NT_STATUS_ACCESS_DENIED; +} + /*************************************************************************** _lsa_enum_privs. ***************************************************************************/ diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index c8ffa18c5a..eb6bd2ac0a 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -56,12 +56,6 @@ static void init_net_r_req_chal(NET_R_REQ_CHAL *r_c, net_reply_logon_ctrl: *************************************************************************/ -/* Some flag values reverse engineered from NLTEST.EXE */ - -#define LOGON_CTRL_IN_SYNC 0x00 -#define LOGON_CTRL_REPL_NEEDED 0x01 -#define LOGON_CTRL_REPL_IN_PROGRESS 0x02 - NTSTATUS _net_logon_ctrl(pipes_struct *p, NET_Q_LOGON_CTRL *q_u, NET_R_LOGON_CTRL *r_u) { diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2fee1972ab..39c294fa45 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2355,7 +2355,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if ( !(*data = TALLOC_ZERO_ARRAY(ctx, uint8, *needed)) ) return WERR_NOMEM; - + SIVAL(*data, 0, *needed); /* size */ SIVAL(*data, 4, 5); /* Windows 2000 == 5.0 */ SIVAL(*data, 8, 0); @@ -7247,18 +7247,19 @@ static void fill_port_2(PORT_INFO_2 *port, const char *name) port->reserved=0x0; } + /**************************************************************************** wrapper around the enumer ports command ****************************************************************************/ WERROR enumports_hook( int *count, char ***lines ) { - char *cmd = lp_enumports_cmd(); - char **qlines; - pstring command; - int numlines; - int ret; - int fd; + char *cmd = lp_enumports_cmd(); + char **qlines; + pstring command; + int numlines; + int ret; + int fd; /* if no hook then just fill in the default port */ @@ -7310,24 +7311,24 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need if ( !W_ERROR_IS_OK(result = enumports_hook( &numlines, &qlines )) ) return result; - - if(numlines) { - if((ports=SMB_MALLOC_ARRAY( PORT_INFO_1, numlines )) == NULL) { - DEBUG(10,("Returning WERR_NOMEM [%s]\n", - dos_errstr(WERR_NOMEM))); - file_lines_free(qlines); - return WERR_NOMEM; - } - - for (i=0; i Date: Fri, 3 Jun 2005 09:24:48 +0000 Subject: r7217: Only allow schannel connections if a successful Auth2 has been done before. Things tested: Domain join and subsequent interactive and network logon to NT4, W2kSP and XPSP2 workstations and a NT4 domain trusting us. Right now I've got problems with my W2k3 domain trusts. So this needs testing, although I'm really confident that this does not break. Volker (This used to be commit c25b4afda2b657b73a6215d3ff36461a36496ba3) --- source3/rpc_server/srv_netlog_nt.c | 2 ++ source3/rpc_server/srv_pipe.c | 7 +++++++ 2 files changed, 9 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index eb6bd2ac0a..a6fe9ef31a 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -27,6 +27,7 @@ #include "includes.h" extern struct dcinfo last_dcinfo; +extern BOOL server_auth2_negotiated; extern userdom_struct current_user_info; #undef DBGC_CLASS @@ -421,6 +422,7 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) init_net_r_auth_2(r_u, &srv_cred, &srv_flgs, status); if (NT_STATUS_IS_OK(status)) { + server_auth2_negotiated = True; last_dcinfo = p->dc; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index ee6c42bd88..ee4e803d9f 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -52,6 +52,7 @@ extern struct current_user current_user; next. This is the way the netlogon schannel works. **************************************************************/ struct dcinfo last_dcinfo; +BOOL server_auth2_negotiated = False; static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) { @@ -975,6 +976,12 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) RPC_AUTH_NETSEC_NEG neg; struct netsec_auth_struct *a = &(p->netsec_auth); + if (!server_auth2_negotiated) { + DEBUG(0, ("Attempt to bind using schannel " + "without successful serverauth2\n")); + return False; + } + if (!smb_io_rpc_auth_netsec_neg("", &neg, rpc_in_p, 0)) { DEBUG(0,("api_pipe_bind_req: " "Could not unmarshal SCHANNEL auth neg\n")); -- cgit From 04e07e8cc9d6615381e0501cd36cf7d78aeed189 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 8 Jun 2005 03:48:40 +0000 Subject: r7385: Rewrite the RPC bind parsing functions to follow the spec. I haven't yet tested this so I may have screwed this up - however it now follows the DCE spec. valgrinded tests to follow.... Jeremy. (This used to be commit 877e0a61f5821c89149b1403d08675dd7db8039e) --- source3/rpc_server/srv_pipe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index ee4e803d9f..9cf61d6357 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1068,15 +1068,15 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) unknown to NT4) Needed when adding entries to a DACL from NT5 - SK */ - if(check_bind_req(p, &hdr_rb.abstract, &hdr_rb.transfer, hdr_rb.context_id )) - { + if(check_bind_req(p, &hdr_rb.rpc_context[0].abstract, &hdr_rb.rpc_context[0].transfer[0], + hdr_rb.rpc_context[0].context_id )) { init_rpc_hdr_ba(&hdr_ba, MAX_PDU_FRAG_LEN, MAX_PDU_FRAG_LEN, assoc_gid, ack_pipe_name, 0x1, 0x0, 0x0, - &hdr_rb.transfer); + &hdr_rb.rpc_context[0].transfer[0]); } else { RPC_IFACE null_interface; ZERO_STRUCT(null_interface); -- cgit From 129b461673ecd0ad4d16c0c99585dd5c067172df Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 9 Jun 2005 15:20:11 +0000 Subject: r7440: * merge registry server changes from trunk (so far) for more printmig.exe work * merge the sys_select_signal(char c) change from trunk in order to keeo the winbind code in sync (This used to be commit a112c5570a7f8ddddde1af0fa665f40a6067e8cf) --- source3/rpc_server/srv_reg_nt.c | 116 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 112 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 4211e9b9f4..9792592c19 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -762,6 +762,113 @@ static int validate_reg_filename( pstring fname ) return (snum < num_services) ? snum : -1; } +/******************************************************************* + Note: topkeypaty is the *full* path that this *key will be + loaded into (including the name of the key) + ********************************************************************/ + +static WERROR reg_load_tree( REGF_FILE *regfile, const char *topkeypath, + REGF_NK_REC *key ) +{ + REGF_NK_REC *subkey; + REGISTRY_KEY registry_key; + REGVAL_CTR values; + REGSUBKEY_CTR subkeys; + int i; + pstring path; + WERROR result = WERR_OK; + + /* initialize the REGISTRY_KEY structure */ + + if ( !(registry_key.hook = reghook_cache_find(topkeypath)) ) { + DEBUG(0,("reg_load_tree: Failed to assigned a REGISTRY_HOOK to [%s]\n", + topkeypath )); + return WERR_BADFILE; + } + pstrcpy( registry_key.name, topkeypath ); + + /* now start parsing the values and subkeys */ + + ZERO_STRUCT( values ); + ZERO_STRUCT( subkeys ); + + regsubkey_ctr_init( &subkeys ); + regval_ctr_init( &values ); + + /* copy values into the REGVAL_CTR */ + + for ( i=0; inum_values; i++ ) { + regval_ctr_addvalue( &values, key->values[i].valuename, key->values[i].type, + key->values[i].data, (key->values[i].data_size & ~VK_DATA_IN_OFFSET) ); + } + + /* copy subkeys into the REGSUBKEY_CTR */ + + key->subkey_index = 0; + while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { + regsubkey_ctr_addkey( &subkeys, subkey->keyname ); + } + + /* write this key and values out */ + + if ( !store_reg_values( ®istry_key, &values ) + || !store_reg_keys( ®istry_key, &subkeys ) ) + { + DEBUG(0,("reg_load_tree: Failed to load %s!\n", topkeypath)); + result = WERR_REG_IO_FAILURE; + } + + regval_ctr_destroy( &values ); + regsubkey_ctr_destroy( &subkeys ); + + if ( !W_ERROR_IS_OK(result) ) + return result; + + /* now continue to load each subkey registry tree */ + + key->subkey_index = 0; + while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { + pstr_sprintf( path, "%s%s%s", topkeypath, "\\", subkey->keyname ); + result = reg_load_tree( regfile, path, subkey ); + if ( !W_ERROR_IS_OK(result) ) + break; + } + + return result; +} + +/******************************************************************* + ********************************************************************/ + +static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) +{ + REGF_FILE *regfile; + REGF_NK_REC *rootkey; + WERROR result; + + /* open the registry file....fail if the file already exists */ + + if ( !(regfile = regfio_open( fname, (O_RDONLY), 0 )) ) { + DEBUG(0,("backup_registry_key: failed to open \"%s\" (%s)\n", + fname, strerror(errno) )); + return ( ntstatus_to_werror(map_nt_error_from_unix( errno )) ); + } + + /* get the rootkey from the regf file and then load the tree + via recursive calls */ + + if ( !(rootkey = regfio_rootkey( regfile )) ) + return WERR_REG_FILE_INVALID; + + result = reg_load_tree( regfile, krecord->name, rootkey ); + + /* cleanup */ + + regfio_close( regfile ); + + return result; +} + /******************************************************************* ********************************************************************/ @@ -783,13 +890,14 @@ WERROR _reg_restore_key(pipes_struct *p, REG_Q_RESTORE_KEY *q_u, REG_R_RESTORE_ if ( (snum = validate_reg_filename( filename )) == -1 ) return WERR_OBJECT_PATH_INVALID; + /* user must posses SeRestorePrivilege for this this proceed */ + + if ( !user_has_privileges( p->pipe_user.nt_user_token, &se_restore ) ) + return WERR_ACCESS_DENIED; + DEBUG(2,("_reg_restore_key: Restoring [%s] from %s in share %s\n", regkey->name, filename, lp_servicename(snum) )); -#if 0 return restore_registry_key( regkey, filename ); -#endif - - return WERR_OK; } /******************************************************************** -- cgit From c7081a0acde413651468b08193b453e778c59dfa Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 13 Jun 2005 19:53:09 +0000 Subject: r7547: removing unused fields in the REGISTRY_KEY structure associated with open handles (This used to be commit ffc7bd87d8a03d8269ae6d0b9e314f8f20003a06) --- source3/rpc_server/srv_reg_nt.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 9792592c19..9df8e9b5fc 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -43,9 +43,6 @@ struct generic_mapping reg_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; -static REGISTRY_KEY *regkeys_list; - - /****************************************************************** free() function for REGISTRY_KEY *****************************************************************/ @@ -54,8 +51,6 @@ static void free_regkey_info(void *ptr) { REGISTRY_KEY *info = (REGISTRY_KEY*)ptr; - DLIST_REMOVE(regkeys_list, info); - SAFE_FREE(info); } @@ -162,9 +157,6 @@ static WERROR open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY * if ( ! NT_STATUS_IS_OK(result) ) SAFE_FREE( regkey ); - else - DLIST_ADD( regkeys_list, regkey ); - DEBUG(7,("open_registry_key: exit\n")); -- cgit From d559edcce23ada96c4a788c3dbeb66c2890db054 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 14 Jun 2005 03:17:31 +0000 Subject: r7563: svcctl patches from Marcin; have cleaned up formating and am checking the code in to snapshot it before I start changing more things (This used to be commit 560ce111ce8de37d02bce64d2ca60a5f471d5477) --- source3/rpc_server/srv_svcctl.c | 51 +- source3/rpc_server/srv_svcctl_nt.c | 1381 +++++++++++++++++++++++++++++++++--- 2 files changed, 1350 insertions(+), 82 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 85fb9f9ce3..6ba26414d3 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -166,7 +166,29 @@ static BOOL api_svcctl_enum_services_status(pipes_struct *p) return True; } +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_query_service_status_ex(pipes_struct *p) +{ + SVCCTL_Q_QUERY_SERVICE_STATUSEX q_u; + SVCCTL_R_QUERY_SERVICE_STATUSEX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + if(!svcctl_io_q_query_service_status_ex("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_query_service_status_ex(p, &q_u, &r_u); + + if(!svcctl_io_r_query_service_status_ex("", &r_u, rdata, 0)) + return False; + + return True; +} /******************************************************************* ********************************************************************/ @@ -263,6 +285,30 @@ static BOOL api_svcctl_query_service_config(pipes_struct *p) return True; } +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_query_service_config2(pipes_struct *p) +{ + SVCCTL_Q_QUERY_SERVICE_CONFIG2 q_u; + SVCCTL_R_QUERY_SERVICE_CONFIG2 r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_query_service_config2("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_query_service_config2(p, &q_u, &r_u); + + if(!svcctl_io_r_query_service_config2("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* \PIPE\svcctl commands ********************************************************************/ @@ -275,12 +321,15 @@ static struct api_struct api_svcctl_cmds[] = { "SVCCTL_GET_DISPLAY_NAME" , SVCCTL_GET_DISPLAY_NAME , api_svcctl_get_display_name }, { "SVCCTL_QUERY_STATUS" , SVCCTL_QUERY_STATUS , api_svcctl_query_status }, { "SVCCTL_QUERY_SERVICE_CONFIG_W", SVCCTL_QUERY_SERVICE_CONFIG_W, api_svcctl_query_service_config }, + { "SVCCTL_QUERY_SERVICE_CONFIG2_W", SVCCTL_QUERY_SERVICE_CONFIG2_W, api_svcctl_query_service_config2 }, { "SVCCTL_ENUM_SERVICES_STATUS_W", SVCCTL_ENUM_SERVICES_STATUS_W, api_svcctl_enum_services_status }, { "SVCCTL_ENUM_DEPENDENT_SERVICES_W", SVCCTL_ENUM_DEPENDENT_SERVICES_W, api_svcctl_enum_dependent_services }, { "SVCCTL_START_SERVICE_W" , SVCCTL_START_SERVICE_W , api_svcctl_start_service }, - { "SVCCTL_CONTROL_SERVICE" , SVCCTL_CONTROL_SERVICE , api_svcctl_control_service } + { "SVCCTL_CONTROL_SERVICE" , SVCCTL_CONTROL_SERVICE , api_svcctl_control_service }, + { "SVCCTL_QUERY_SERVICE_STATUSEX_W", SVCCTL_QUERY_SERVICE_STATUSEX_W, api_svcctl_query_service_status_ex } }; + void svcctl_get_pipe_fns( struct api_struct **fns, int *n_fns ) { *fns = api_svcctl_cmds; diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index a76e68a312..1feb0f66e4 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -18,81 +18,595 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* TODO - Do the OpenService service name matching case-independently, or at least make it an option. */ + + #include "includes.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +#define SERVICEDB_VERSION_V1 1 /* Will there be more? */ +#define INTERNAL_SERVICES_LIST "NETLOGON Spooler" + +/* */ +/* scripts will execute from the following libdir, if they are in the enable svcctl= */ +/* these should likely be symbolic links. Note that information about them will be extracted from the files themselves */ +/* using the LSB standard keynames for various information */ + +#define SVCCTL_SCRIPT_DIR "/svcctl/" + /* * sertup the \PIPE\svcctl db API */ #define SCVCTL_DATABASE_VERSION_V1 1 +TALLOC_CTX *svcdb=NULL; +static TDB_CONTEXT *service_tdb; /* used for services tdb file */ + +/* there are two types of services -- internal, and external. + Internal services are "built-in" to samba -- there may be + functions that exist to provide the control and enumeration + functions. There certainly is information returned to be + displayed in the typical management console. + + External services are those that can be specified in the smb.conf + file -- and they conform to the LSB specification as to having + particular keywords in the scripts. Note that these "scripts" are + located in the lib directory, and are likely links to LSB-compliant + init.d scripts, such as those that might come with Suse. Note + that the spec is located http://www.linuxbase.org/spec/ */ + + + +/* Expand this to include what can and can't be done + with a particular internal service. Expand as necessary + to add other infromation like what can be controlled, + etc. */ + +typedef struct Internal_service_struct +{ + const char *filename; /* internal name "index" */ + const char *displayname; + const char *description; + const uint32 statustype; + void *status_fn; + void *control_fn; +} Internal_service_description; + + +static const Internal_service_description ISD[] = { + { "NETLOGON", "Net Logon", "Provides logon and authentication service to the network", 0x110, NULL, NULL}, + { "Spooler", "Spooler", "Printing Services", 0x0020, NULL, NULL}, + { NULL, NULL, NULL, 0, NULL, NULL} +}; + /******************************************************************** + TODOs + (a) get and set security descriptors on services + (b) read and write QUERY_SERVICE_CONFIG structures (both kinds, country and western) + (c) create default secdesc objects for services and SCM + (d) check access control masks with se_access_check() ********************************************************************/ -#if 0 /* unused static function and static variable*/ +/* parse a LSB init.d type file for things it provides, dependencies, descriptions, etc. */ + -static TDB_CONTEXT *svcctl_tdb; /* used for share security descriptors */ +/******************************************************************************* + Get the INTERNAL services information for the given service name. +*******************************************************************************/ -static BOOL init_svcctl_db( void ) +static BOOL _svcctl_get_internal_service_data(const Internal_service_description *isd, Service_info *si) { - static pid_t local_pid; - const char *vstring = "INFO/version"; - - /* see if we've already opened the tdb */ + ZERO_STRUCTP( si ); - if (svcctl_tdb && local_pid == sys_getpid()) - return True; + pstrcpy( si->servicename, isd->displayname); + pstrcpy( si->servicetype, "INTERNAL"); + pstrcpy( si->filename, isd->filename); + pstrcpy( si->provides, isd->displayname); + pstrcpy( si->description, isd->description); + pstrcpy( si->shortdescription, isd->description); - /* so open it */ - if ( !(svcctl_tdb = tdb_open_log(lock_path("svcctl.tdb"), 0, TDB_DEFAULT, - O_RDWR|O_CREAT, 0600))) - { - DEBUG(0,("Failed to open svcctl database %s (%s)\n", - lock_path("svcctl.tdb"), strerror(errno) )); + return True; +} + + +/******************************************************************************* + Get the services information by reading and parsing the shell scripts. These + are symbolically linked into the SVCCTL_SCRIPT_DIR directory. + + Get the names of the services/scripts to read from the smb.conf file. +*******************************************************************************/ + +static BOOL _svcctl_get_LSB_data(char *fname,Service_info *si ) +{ + pstring initdfile; + char mybuffer[256]; + const char *tokenptr; + char **qlines; + int fd = -1; + int nlines, *numlines,i,in_section,in_description; + + pstrcpy(si->servicename,""); + pstrcpy(si->servicetype,"EXTERNAL"); + pstrcpy(si->filename,fname); + pstrcpy(si->provides,""); + pstrcpy(si->dependencies,""); + pstrcpy(si->shouldstart,""); + pstrcpy(si->shouldstop,""); + pstrcpy(si->requiredstart,""); + pstrcpy(si->requiredstop,""); + pstrcpy(si->description,""); + pstrcpy(si->shortdescription,""); + + numlines = &nlines; + in_section = 0; + in_description = 0; + + + if( !fname || !*fname ) { + DEBUG(0, ("Must define an \"LSB-style init file\" to read.\n")); return False; } - - local_pid = sys_getpid(); - - /***** BEGIN Check the tdb version ******/ + pstrcpy(initdfile,dyn_LIBDIR); + pstrcat(initdfile,SVCCTL_SCRIPT_DIR); + pstrcat(initdfile,fname); + + /* TODO - should check to see if the file that we're trying to open is + actually a script. If it's NOT, we should do something like warn, + and not continue to try to find info we're looking for */ + + DEBUG(10, ("Opening [%s]\n", initdfile)); + fd = -1; + fd = open(initdfile,O_RDONLY); + *numlines = 0; + + if (fd == -1) { + DEBUG(10, ("Couldn't open [%s]\n", initdfile)); + return False; + } + + qlines = fd_lines_load(fd, numlines); + DEBUGADD(10, ("Lines returned = [%d]\n", *numlines)); + close(fd); + + + if (*numlines) { - tdb_lock_bystring(svcctl_tdb, vstring, 0); + for(i = 0; i < *numlines; i++) { + + DEBUGADD(10, ("Line[%d] = %s\n", i, qlines[i])); + if (!in_section && (0==strwicmp("### BEGIN INIT INFO", qlines[i]))) { + /* we now can look for params */ + DEBUGADD(10, ("Configuration information starts on line = [%d]\n", i)); + in_section = 1; + + } else if (in_section && (0==strwicmp("### END INIT INFO", qlines[i]))) { + DEBUGADD(10, ("Configuration information ends on line = [%d]\n", i)); + DEBUGADD(10, ("Description is [%s]\n", si->description)); + in_description = 0; + in_section = 0; + break; + } else if (in_section) { + tokenptr = qlines[i]; + if (in_description) { + DEBUGADD(10, ("Processing DESCRIPTION [%d]\n", *tokenptr)); + if (tokenptr && (*tokenptr=='#') && (*(tokenptr+1)=='\t')) { + DEBUGADD(10, ("Adding to DESCRIPTION [%d]\n", *tokenptr)); + pstrcat(si->description," "); + pstrcat(si->description,tokenptr+2); + continue; + } + in_description = 0; + DEBUGADD(10, ("Not a description!\n")); + } + if (!next_token(&tokenptr,mybuffer," \t",sizeof(mybuffer))) { + DEBUGADD(10, ("Invalid line [%d]\n", i)); + break; /* bad line? */ + } + if (0 != strncmp(mybuffer,"#",1)) { + DEBUGADD(10, ("Invalid line [%d], is %s\n", i,mybuffer)); + break; + } + if (!next_token(&tokenptr,mybuffer," \t",sizeof(mybuffer))) { + DEBUGADD(10, ("Invalid token on line [%d]\n", i)); + break; /* bad line? */ + } + DEBUGADD(10, ("Keyword is [%s]\n", mybuffer)); + if (0==strwicmp(mybuffer,"Description:")) { + while (tokenptr && *tokenptr && (strchr(" \t",*tokenptr))) { + tokenptr++; + } + pstrcpy(si->description,tokenptr); + DEBUGADD(10, ("FOUND DESCRIPTION! Data is [%s]\n", tokenptr)); + in_description = 1; + } else { + while (tokenptr && *tokenptr && (strchr(" \t",*tokenptr))) { + tokenptr++; + } + DEBUGADD(10, ("Data is [%s]\n", tokenptr)); + in_description = 0; + + /* save certain keywords, don't save others */ + if (0==strwicmp(mybuffer, "Provides:")) { + pstrcpy(si->provides,tokenptr); + pstrcpy(si->servicename,tokenptr); + } + + if (0==strwicmp(mybuffer, "Short-Description:")) { + pstrcpy(si->shortdescription,tokenptr); + } + + if (0==strwicmp(mybuffer, "Required-start:")) { + pstrcpy(si->requiredstart,tokenptr); + pstrcpy(si->dependencies,tokenptr); + } + + if (0==strwicmp(mybuffer, "Should-start:")) { + pstrcpy(si->shouldstart,tokenptr); + } + } + } + } + + file_lines_free(qlines); + return True; + } + + return False; +} + + +BOOL _svcctl_read_service_tdb_to_si(TDB_CONTEXT *stdb,char *service_name, Service_info *si) +{ + + pstring keystring; + TDB_DATA key_data; + + if ((stdb == NULL) || (si == NULL) || (service_name==NULL) || (*service_name == 0)) + return False; + + /* TODO - error handling -- what if the service isn't in the DB? */ + + pstr_sprintf(keystring,"SERVICE/%s/TYPE", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->servicetype,key_data.dptr,key_data.dsize); + si->servicetype[key_data.dsize] = 0; + + /* crude check to see if the service exists... */ + DEBUG(3,("Size of the TYPE field is %d\n",key_data.dsize)); + if (key_data.dsize == 0) + return False; + + pstr_sprintf(keystring,"SERVICE/%s/FILENAME", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->filename,key_data.dptr,key_data.dsize); + si->filename[key_data.dsize] = 0; + + pstr_sprintf(keystring,"SERVICE/%s/PROVIDES", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->provides,key_data.dptr,key_data.dsize); + si->provides[key_data.dsize] = 0; + strncpy(si->servicename,key_data.dptr,key_data.dsize); + si->servicename[key_data.dsize] = 0; + + + pstr_sprintf(keystring,"SERVICE/%s/DEPENDENCIES", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->dependencies,key_data.dptr,key_data.dsize); + si->dependencies[key_data.dsize] = 0; + + pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTART", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->shouldstart,key_data.dptr,key_data.dsize); + si->shouldstart[key_data.dsize] = 0; + + pstr_sprintf(keystring,"SERVICE/%s/SHOULD_STOP", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->shouldstop,key_data.dptr,key_data.dsize); + si->shouldstop[key_data.dsize] = 0; + + pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTART", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->requiredstart,key_data.dptr,key_data.dsize); + si->requiredstart[key_data.dsize] = 0; + + pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTOP", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->requiredstop,key_data.dptr,key_data.dsize); + si->requiredstop[key_data.dsize] = 0; + + pstr_sprintf(keystring,"SERVICE/%s/DESCRIPTION", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->description,key_data.dptr,key_data.dsize); + si->description[key_data.dsize] = 0; + + pstr_sprintf(keystring,"SERVICE/%s/SHORTDESC", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->shortdescription,key_data.dptr,key_data.dsize); + si->shortdescription[key_data.dsize] = 0; + + return True; +} + +/********************************************************************* + given a service nice name, find the underlying service name +*********************************************************************/ + +BOOL _svcctl_service_nicename_to_servicename(TDB_CONTEXT *stdb,pstring service_nicename, pstring servicename,int szsvcname) +{ + pstring keystring; + TDB_DATA key_data; + + if ((stdb == NULL) || (service_nicename==NULL) || (servicename == NULL)) + return False; + + pstr_sprintf(keystring,"SERVICE_NICENAME/%s", servicename); + + DEBUG(5, ("_svcctl_service_nicename_to_servicename: Looking for service name [%s], key [%s]\n", + service_nicename, keystring)); + + key_data = tdb_fetch_bystring(stdb,keystring); + + if (key_data.dsize == 0) { + DEBUG(5, ("_svcctl_service_nicename_to_servicename: [%s] Not found, tried key [%s]\n",service_nicename,keystring)); + return False; + } + + strncpy(servicename,key_data.dptr,szsvcname); + servicename[(key_data.dsize > szsvcname ? szsvcname : key_data.dsize)] = 0; + DEBUG(5, ("_svcctl_service_nicename_to_servicename: Found service name [%s], name is [%s]\n", + service_nicename,servicename)); + + return True; +} + +/********************************************************************* +*********************************************************************/ + +BOOL _svcctl_write_si_to_service_tdb(TDB_CONTEXT *stdb,char *service_name, Service_info *si) +{ + pstring keystring; + + /* Note -- when we write to the tdb, we "index" on the filename + field, not the nice name. when a service is "opened", it is + opened by the nice (SERVICENAME) name, not the file name. + So there needs to be a mapping from nice name back to the file name. */ + + if ((stdb == NULL) || (si == NULL) || (service_name==NULL) || (*service_name == 0)) + return False; + + + /* Store the nicename */ + + pstr_sprintf(keystring,"SERVICE_NICENAME/%s", si->servicename); + tdb_store_bystring(stdb,keystring,string_tdb_data(service_name),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/TYPE", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->servicetype),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/FILENAME", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->filename),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/PROVIDES", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->provides),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/SERVICENAME", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->servicename),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/DEPENDENCIES", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->dependencies),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTART", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->shouldstart),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTOP", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->shouldstop),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTART", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->requiredstart),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTOP", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->requiredstop),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/DESCRIPTION", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->description),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/SHORTDESC", service_name); + tdb_lock_bystring(stdb, keystring, 0); + if (si->shortdescription && *si->shortdescription) + tdb_store_bystring(stdb,keystring,string_tdb_data(si->shortdescription),TDB_REPLACE); + else + tdb_store_bystring(stdb,keystring,string_tdb_data(si->description),TDB_REPLACE); + + return True; +} + +/**************************************************************************** + Create/Open the service control manager tdb. This code a clone of init_group_mapping. +****************************************************************************/ + +BOOL init_svcctl_db(void) +{ + const char *vstring = "INFO/version"; + uint32 vers_id; + char **svc_list; + char **svcname; + pstring keystring; + pstring external_service_list; + pstring internal_service_list; + Service_info si; + const Internal_service_description *isd_ptr; + /* svc_list = str_list_make( "etc/init.d/skeleton etc/init.d/syslog", NULL ); */ + svc_list=(char **)lp_enable_svcctl(); + + if (service_tdb) + return True; + + pstrcpy(external_service_list,""); + + service_tdb = tdb_open_log(lock_path("services.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600); + if (!service_tdb) { + DEBUG(0,("Failed to open service db\n")); + service_tdb = tdb_open_log(lock_path("services.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); + if (!service_tdb) return False; + DEBUG(0,("Created new services db\n")); + } + + if ((-1 == tdb_fetch_uint32(service_tdb, vstring,&vers_id)) || (vers_id != SERVICEDB_VERSION_V1)) { + /* wrong version of DB, or db was just created */ + tdb_traverse(service_tdb, tdb_traverse_delete_fn, NULL); + tdb_store_uint32(service_tdb, vstring, SERVICEDB_VERSION_V1); + } + tdb_unlock_bystring(service_tdb, vstring); + + DEBUG(0,("Initializing services db\n")); - if ( tdb_fetch_int32(svcctl_tdb, vstring) != SCVCTL_DATABASE_VERSION_V1 ) - tdb_store_int32(svcctl_tdb, vstring, SCVCTL_DATABASE_VERSION_V1); + svcname = svc_list; + + /* Get the EXTERNAL services as mentioned by line in smb.conf */ + + while (*svcname) { + DEBUG(10,("Reading information on service %s\n",*svcname)); + if (_svcctl_get_LSB_data(*svcname,&si));{ + /* write the information to the TDB */ + _svcctl_write_si_to_service_tdb(service_tdb,*svcname,&si); + /* definitely not efficient to do it this way. */ + pstrcat(external_service_list,"\""); + pstrcat(external_service_list,*svcname); + pstrcat(external_service_list,"\" "); + } + svcname++; + } + pstrcpy(keystring,"EXTERNAL_SERVICES"); + tdb_lock_bystring(service_tdb, keystring, 0); + DEBUG(8,("Storing external service list [%s]\n",external_service_list)); + tdb_store_bystring(service_tdb,keystring,string_tdb_data(external_service_list),TDB_REPLACE); + tdb_unlock_bystring(service_tdb,keystring); - tdb_unlock_bystring(svcctl_tdb, vstring); + /* Get the INTERNAL services */ - /***** END Check the tdb version ******/ + pstrcpy(internal_service_list,""); + isd_ptr = ISD; + + while (isd_ptr && (isd_ptr->filename)) { + DEBUG(10,("Reading information on service %s\n",isd_ptr->filename)); + if (_svcctl_get_internal_service_data(isd_ptr,&si)){ + /* write the information to the TDB */ + _svcctl_write_si_to_service_tdb(service_tdb,(char *)isd_ptr->filename,&si); + /* definitely not efficient to do it this way. */ + pstrcat(internal_service_list,"\""); + pstrcat(internal_service_list,isd_ptr->filename); + pstrcat(internal_service_list,"\" "); + + } + isd_ptr++; + } + pstrcpy(keystring,"INTERNAL_SERVICES"); + tdb_lock_bystring(service_tdb, keystring, 0); + DEBUG(8,("Storing internal service list [%s]\n",internal_service_list)); + tdb_store_bystring(service_tdb,keystring,string_tdb_data(internal_service_list),TDB_REPLACE); + tdb_unlock_bystring(service_tdb,keystring); return True; } -#endif +/* Service_info related functions */ +static Service_info *find_service_info_by_hnd(pipes_struct *p, POLICY_HND *handle) +{ + Service_info *info = NULL; -/******************************************************************** - TODO - (a) get and set security descriptors on services - (b) read and write QUERY_SERVICE_CONFIG structures - (c) create default secdesc objects for services and SCM - (d) check access control masks with se_access_check() - (e) implement SERVICE * for associating with open handles -********************************************************************/ + if(!(find_policy_by_hnd(p,handle,(void **)&info))) + DEBUG(2,("find_service_info_by_hnd: service not found.\n")); + + return info; +} + +static void free_service_info(void *ptr) +{ + Service_info *info = (Service_info *)ptr; + memset(info,'0',sizeof(Service_info)); + SAFE_FREE(info); +} + +/* SCM_info related functions */ +static void free_SCM_info(void *ptr) +{ + SCM_info *info = (SCM_info *)ptr; + memset(info->target_server_name, '0', sizeof(*(info->target_server_name))); + memset(info->target_db_name, '0', sizeof(*(info->target_db_name))); + memset(info, 0, sizeof(*(info))); + SAFE_FREE(info); +} + +static SCM_info *find_SCManager_info_by_hnd(pipes_struct *p, POLICY_HND *handle) +{ + SCM_info *info = NULL; + + if ( !(find_policy_by_hnd(p,handle,(void **)&info)) ) + DEBUG(2,("svcctl_find_SCManager_info_by_hnd: service not found.\n")); + + return info; +} + +static BOOL _svcctl_open_SCManager_hook(SCM_info *info) +{ + return True; +} + +static BOOL _svcctl_close_SCManager_hook(SCM_info *info) +{ + return True; +} /******************************************************************** ********************************************************************/ WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVCCTL_R_OPEN_SCMANAGER *r_u) { - /* just fake it for now */ - - if ( !create_policy_hnd( p, &r_u->handle, NULL, NULL ) ) - return WERR_ACCESS_DENIED; + /* create the DB of the services that we have */ + /* associate the information from the service opened in the create_policy_hnd string */ + + SCM_info *info = NULL; + fstring fhandle_string; + + if(!q_u || !r_u) + return WERR_NOMEM; + + if((info = SMB_MALLOC_P(SCM_info)) == NULL) + return WERR_NOMEM; + + ZERO_STRUCTP(info); + + info->type = SVC_HANDLE_IS_SCM; + + if(q_u->servername != 0) + unistr2_to_ascii(info->target_server_name, q_u->servername, sizeof(info->target_server_name)); + else { + /* if servername == NULL, use the local computer */ + pstrcpy(info->target_server_name, global_myname()); + } + DEBUG(10, ("_svcctl_open_scmanager: Using [%s] as the server name.\n", info->target_server_name)); + + if(q_u->database != 0) + unistr2_to_ascii(info->target_db_name, q_u->database, sizeof(info->target_db_name)); + else + pstrcpy(info->target_db_name, "ServicesActive"); + + if(!create_policy_hnd(p, &(r_u->handle), free_SCM_info, (void *)info)) + return WERR_NOMEM; + + policy_handle_to_string(&r_u->handle, &fhandle_string); + DEBUG(10, ("_svcctl_open_scmanager: Opening [%s] as the target services db, handle [%s]\n", info->target_db_name,fhandle_string)); + + if(!(_svcctl_open_SCManager_hook(info))) { + /* TODO - should we free the memory that may have been allocated with the policy handle? */ + return WERR_BADFILE; + } return WERR_OK; + } /******************************************************************** @@ -100,29 +614,116 @@ WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVC WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_R_OPEN_SERVICE *r_u) { - fstring service; + pstring service; + pstring service_filename; + fstring fhandle_string; + Service_info *info; + + if(!q_u || !r_u) + return WERR_NOMEM; + + if((info = SMB_MALLOC_P(Service_info)) == NULL) + return WERR_NOMEM; + + ZERO_STRUCTP(info); + + info->type = SVC_HANDLE_IS_SERVICE; rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); - /* can only be called on service name (not displayname) */ + if (service_tdb == NULL) { + DEBUG(1, ("_svcctl_open_service: Cannot open Service [%s], the service database is not open; handle [%s]\n", service,fhandle_string)); + return WERR_ACCESS_DENIED; + } + DEBUG(1, ("_svcctl_open_service: Attempting to open Service [%s], \n", service)); + +#if 0 + if ( !_svcctl_service_nicename_to_servicename(service_tdb, service, service_filename, sizeof(pstring)) ) { + DEBUG(1, ("_svcctl_open_service: Cannot open Service [%s], the service can't be found\n", service)); + return WERR_NO_SUCH_SERVICE; + } +#else + pstrcpy(service_filename,service); +#endif + if (_svcctl_read_service_tdb_to_si(service_tdb,service, info)) + DEBUG(1, ("_svcctl_open_service: Found service [%s], servicename [%s], \n", service, info->servicename)); + else + return WERR_NO_SUCH_SERVICE; + +#if 0 if ( !(strequal( service, "NETLOGON") || strequal(service, "Spooler")) ) return WERR_NO_SUCH_SERVICE; - - if ( !create_policy_hnd( p, &r_u->handle, NULL, NULL ) ) +#endif + if ( !create_policy_hnd( p, &(r_u->handle), free_service_info, (void *)info ) ) return WERR_ACCESS_DENIED; + policy_handle_to_string(&r_u->handle, &fhandle_string); + DEBUG(10, ("_svcctl_open_service: Opening Service [%s], handle [%s]\n", service,fhandle_string)); + return WERR_OK; } /******************************************************************** ********************************************************************/ +/* Note that this can be called to close an individual service, ** OR ** the Service Control Manager */ + WERROR _svcctl_close_service(pipes_struct *p, SVCCTL_Q_CLOSE_SERVICE *q_u, SVCCTL_R_CLOSE_SERVICE *r_u) { - if ( !close_policy_hnd( p, &q_u->handle ) ) - return WERR_BADFID; - + SCM_info *scminfo; + Service_info *svcinfo; + POLICY_HND *handle; + fstring fhandle_string; + POLICY_HND null_policy_handle; + + + handle = &(q_u->handle); + + /* a handle is returned in the close when it's for a service */ + + policy_handle_to_string(handle, &fhandle_string); + DEBUG(10, ("_svcctl_close_service: Closing handle [%s]\n",fhandle_string)); + + ZERO_STRUCT(null_policy_handle); + + policy_handle_to_string(handle, &fhandle_string); + DEBUG(10, ("_svcctl_close_service: Closing handle [%s]\n",fhandle_string)); + + scminfo = find_SCManager_info_by_hnd(p, handle); + + if ((NULL != scminfo) && (scminfo->type == SVC_HANDLE_IS_SCM)) { + DEBUG(3,("_svcctl_close_service: Closing SERVICE DATABASE [%s]\n", scminfo->target_db_name)); + + if(!(_svcctl_close_SCManager_hook(scminfo))) + return WERR_BADFILE; + + if(!(close_policy_hnd(p, handle))) + { + /* WERR_NOMEM is probably not the correct error, but until I figure out a better + one it will have to do */ + DEBUG(3,("_svcctl_close_service: Can't close SCM \n")); + return WERR_NOMEM; + } + memcpy(&(r_u->handle),&null_policy_handle, sizeof(POLICY_HND)); + return WERR_OK; + } + + if ((NULL != scminfo) && (scminfo->type == SVC_HANDLE_IS_SERVICE)) { + svcinfo = (Service_info *)scminfo; + DEBUG(3,("_svcctl_close_service: Handle is a SERVICE not SCM \n")); + DEBUG(3,("_svcctl_close_service: Closing SERVICE [%s]\n", svcinfo->servicename)); + if(!(close_policy_hnd(p, handle))) + { + /* WERR_NOMEM is probably not the correct error, but until I figure out a better + one it will have to do */ + DEBUG(3,("_svcctl_close_service: Can't close SERVICE [%s]\n", svcinfo->servicename)); + return WERR_NOMEM; + } + } + + memcpy(&(r_u->handle),&null_policy_handle, sizeof(POLICY_HND)); + return WERR_OK; } @@ -133,15 +734,34 @@ WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, { fstring service; fstring displayname; + fstring fhandle_string; + + Service_info *service_info; + POLICY_HND *handle; rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); - DEBUG(10,("_svcctl_get_display_name: service name [%s]\n", service)); + handle = &(q_u->handle); + policy_handle_to_string(&q_u->handle, &fhandle_string); + + DEBUG(10, ("_svcctl_get_display_name: Looking for handle [%s]\n",(char *)&fhandle_string)); + service_info = find_service_info_by_hnd(p, handle); + + if (!service_info) { + DEBUG(10, ("_svcctl_get_display_name : Can't find the service for the handle\n")); + return WERR_ACCESS_DENIED; + } + + DEBUG(10, ("_svcctl_get_display_name: Found service [%s], [%s]\n",service_info->servicename,service_info->filename)); + /* no dependent services...basically a stub function */ + +#if 0 if ( !strequal( service, "NETLOGON" ) ) return WERR_ACCESS_DENIED; +#endif + fstrcpy( displayname, service_info->servicename) ; - fstrcpy( displayname, "Net Logon"); init_svcctl_r_get_display_name( r_u, displayname ); return WERR_OK; @@ -153,34 +773,266 @@ WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_R_QUERY_STATUS *r_u) { - r_u->svc_status.type = 0x0110; + r_u->svc_status.type = 0x0020; r_u->svc_status.state = 0x0004; r_u->svc_status.controls_accepted = 0x0005; return WERR_OK; } -/******************************************************************** -********************************************************************/ +/* allocate an array of external services and return them. Null return is okay, make sure &added is also zero! */ -WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, SVCCTL_R_ENUM_SERVICES_STATUS *r_u) +int _svcctl_num_external_services(void) { - ENUM_SERVICES_STATUS *services = NULL; - uint32 num_services = 0; + int num_services; + char **svc_list; + pstring keystring, external_services_string; + TDB_DATA key_data; + + + if (!service_tdb) { + DEBUG(8,("_svcctl_enum_external_services: service database is not open!!!\n")); + num_services = 0; + } else { + pstrcpy(keystring,"EXTERNAL_SERVICES"); + tdb_lock_bystring(service_tdb, keystring, 0); + key_data = tdb_fetch_bystring(service_tdb, keystring); + + if ((key_data.dptr != NULL) && (key_data.dsize != 0)) { + strncpy(external_services_string,key_data.dptr,key_data.dsize); + external_services_string[key_data.dsize] = 0; + DEBUG(8,("_svcctl_enum_external_services: services list is %s, size is %d\n",external_services_string,key_data.dsize)); + } + tdb_unlock_bystring(service_tdb, keystring); + } + svc_list = str_list_make(external_services_string,NULL); + + num_services = str_list_count( (const char **)svc_list); + + return num_services; +} + + + +/* + + Gather information on the "external services". These are services listed in the smb.conf file, and found to exist through + checks in this code. Note that added will be incremented on the basis of the number of services added. svc_ptr should have enough + memory allocated to accommodate all of the services that exist. + + Typically _svcctl_num_external_services is used to "size" the amount of memory allocated, but does little/no work. + + _svcctl_enum_external_services actually examines each of the specified external services, populates the memory structures, and returns. + + ** note that 'added' may end up with less than the number of services found in _num_external_services, such as the case when a service is + called out, but the actual service doesn't exist or the file can't be read for the service information. + + + */ + +WERROR _svcctl_enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services,int *added) +{ + /* *svc_ptr must have pre-allocated memory */ + int num_services = 0; int i = 0; - size_t buffer_size; - WERROR result = WERR_OK; - - /* num_services = str_list_count( lp_enable_svcctl() ); */ - num_services = 2; - - if ( !(services = TALLOC_ARRAY( p->mem_ctx, ENUM_SERVICES_STATUS, num_services )) ) + ENUM_SERVICES_STATUS *services=NULL; + char **svc_list,**svcname; + pstring command, keystring, external_services_string; + int ret; + int fd = -1; + Service_info *si; + TDB_DATA key_data; + + *added = num_services; + + if (!service_tdb) { + DEBUG(8,("_svcctl_enum_external_services: service database is not open!!!\n")); + } else { + pstrcpy(keystring,"EXTERNAL_SERVICES"); + tdb_lock_bystring(service_tdb, keystring, 0); + key_data = tdb_fetch_bystring(service_tdb, keystring); + if ((key_data.dptr != NULL) && (key_data.dsize != 0)) { + strncpy(external_services_string,key_data.dptr,key_data.dsize); + external_services_string[key_data.dsize] = 0; + DEBUG(8,("_svcctl_enum_external_services: services list is %s, size is %d\n",external_services_string,key_data.dsize)); + } + tdb_unlock_bystring(service_tdb, keystring); + } + svc_list = str_list_make(external_services_string,NULL); + + num_services = str_list_count( (const char **)svc_list); + + if (0 == num_services) { + DEBUG(8,("_svcctl_enum_external_services: there are no external services\n")); + *added = num_services; + return WERR_OK; + } + DEBUG(8,("_svcctl_enum_external_services: there are [%d] external services\n",num_services)); + si=TALLOC_ARRAY( tcx, Service_info, 1 ); + if (si == NULL) { + DEBUG(8,("_svcctl_enum_external_services: Failed to alloc si\n")); + return WERR_NOMEM; + } + +#if 0 +/* *svc_ptr has the pointer to the array if there is one already. NULL if not. */ + if ((existing_services>0) && svc_ptr && *svc_ptr) { /* reallocate vs. allocate */ + DEBUG(8,("_svcctl_enum_external_services: REALLOCing %x to %d services\n", *svc_ptr, existing_services+num_services)); + + services=TALLOC_REALLOC_ARRAY(tcx,*svc_ptr,ENUM_SERVICES_STATUS,existing_services+num_services); + DEBUG(8,("_svcctl_enum_external_services: REALLOCed to %x services\n", services)); + + if (!services) return WERR_NOMEM; + *svc_ptr = services; + } else { + if ( !(services = TALLOC_ARRAY( tcx, ENUM_SERVICES_STATUS, num_services )) ) + return WERR_NOMEM; + } +#endif + + if (!svc_ptr || !(*svc_ptr)) + return WERR_NOMEM; + services = *svc_ptr; + if (existing_services > 0) { + i+=existing_services; + } + + svcname = svc_list; + DEBUG(8,("_svcctl_enum_external_services: enumerating %d external services starting at index %d\n", num_services,existing_services)); + + while (*svcname) { + DEBUG(10,("_svcctl_enum_external_services: Reading information on service %s, index %d\n",*svcname,i)); + /* _svcctl_get_LSB_data(*svcname,si); */ + if (!_svcctl_read_service_tdb_to_si(service_tdb,*svcname, si)) { + DEBUG(1,("_svcctl_enum_external_services: CAN'T FIND INFO FOR SERVICE %s in the services DB\n",*svcname)); + } + + if ((si->filename == NULL) || (*si->filename == 0)) { + init_unistr(&services[i].servicename, *svcname ); + } else { + init_unistr( &services[i].servicename, si->filename ); + /* init_unistr( &services[i].servicename, si->servicename ); */ + } + + if ((si->provides == NULL) || (*si->provides == 0)) { + init_unistr(&services[i].displayname, *svcname ); + } else { + init_unistr( &services[i].displayname, si->provides ); + } + + /* TODO - we could keep the following info in the DB, too... */ + + DEBUG(8,("_svcctl_enum_external_services: Service name [%s] displayname [%s]\n", + si->filename, si->provides)); + services[i].status.type = SVCCTL_WIN32_OWN_PROC; + services[i].status.win32_exit_code = 0x0; + services[i].status.service_exit_code = 0x0; + services[i].status.check_point = 0x0; + services[i].status.wait_hint = 0x0; + + /* TODO - do callout here to get the status */ + + memset(command, 0, sizeof(command)); + slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, *svcname, "status"); + + DEBUG(10, ("_svcctl_enum_external_services: status command is [%s]\n", command)); + + /* TODO - wrap in privilege check */ + + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); + close(fd); + if(ret != 0) + DEBUG(10, ("_svcctl_enum_external_services: Command returned [%d]\n", ret)); + services[i].status.state = SVCCTL_STOPPED; + if (ret == 0) { + services[i].status.state = SVCCTL_RUNNING; + services[i].status.controls_accepted = SVCCTL_CONTROL_SHUTDOWN | SVCCTL_CONTROL_STOP; + } else { + services[i].status.state = SVCCTL_STOPPED; + services[i].status.controls_accepted = 0; + } + svcname++; + i++; + } + + DEBUG(10,("_svcctl_enum_external_services: Read services %d\n",num_services)); + *added = num_services; + + return WERR_OK; +} + +int _svcctl_num_internal_services(void) +{ + int num_services; + char **svc_list; + pstring keystring, internal_services_string; + TDB_DATA key_data; + + if (!service_tdb) { + DEBUG(8,("_svcctl_enum_internal_services: service database is not open!!!\n")); + num_services = 0; + } else { + pstrcpy(keystring,"INTERNAL_SERVICES"); + tdb_lock_bystring(service_tdb, keystring, 0); + key_data = tdb_fetch_bystring(service_tdb, keystring); + + if ((key_data.dptr != NULL) && (key_data.dsize != 0)) { + strncpy(internal_services_string,key_data.dptr,key_data.dsize); + internal_services_string[key_data.dsize] = 0; + DEBUG(8,("_svcctl_enum_internal_services: services list is %s, size is %d\n",internal_services_string,key_data.dsize)); + } + tdb_unlock_bystring(service_tdb, keystring); + } + svc_list = str_list_make(internal_services_string,NULL); + + num_services = str_list_count( (const char **)svc_list); + + return num_services; +} + +#if 0 + +int _svcctl_num_internal_services(void) +{ + return 2; +} +#endif + +/* TODO - for internal services, do similar to external services, except we have to call the right status routine... */ + +WERROR _svcctl_enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services, int *added) +{ + int num_services = 2; + int i = 0; + ENUM_SERVICES_STATUS *services=NULL; + + if (!svc_ptr || !(*svc_ptr)) return WERR_NOMEM; - - DEBUG(8,("_svcctl_enum_services_status: Enumerating %d services\n", num_services)); + + services = *svc_ptr; + +#if 0 + /* *svc_ptr has the pointer to the array if there is one already. NULL if not. */ + if ((existing_services>0) && svc_ptr && *svc_ptr) { /* reallocate vs. allocate */ + DEBUG(8,("_svcctl_enum_internal_services: REALLOCing %d services\n", num_services)); + services = TALLOC_REALLOC_ARRAY(tcx,*svc_ptr,ENUM_SERVICES_STATUS,existing_services+num_services); + if (!rsvcs) + return WERR_NOMEM; + *svc_ptr = services; + } else { + if ( !(services = TALLOC_ARRAY( tcx, ENUM_SERVICES_STATUS, num_services )) ) + return WERR_NOMEM; + } +#endif + + if (existing_services > 0) { + i += existing_services; + } + DEBUG(8,("_svcctl_enum_internal_services: Creating %d services, starting index %d\n", num_services,existing_services)); init_unistr( &services[i].servicename, "Spooler" ); - init_unistr( &services[i].displayname, "Spooler" ); + init_unistr( &services[i].displayname, "Print Spooler" ); services[i].status.type = 0x110; services[i].status.controls_accepted = 0x0; @@ -195,7 +1047,7 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT i++; - init_unistr( &services[i].servicename, "Netlogon" ); + init_unistr( &services[i].servicename, "NETLOGON" ); init_unistr( &services[i].displayname, "Net Logon" ); services[i].status.type = 0x20; @@ -208,30 +1060,90 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT services[i].status.state = SVCCTL_RUNNING; else services[i].status.state = SVCCTL_STOPPED; + + *added = num_services; + + return WERR_OK; +} + +WERROR _init_svcdb(void) +{ + if (svcdb) { + talloc_destroy(svcdb); + } + svcdb = talloc_init("services DB"); + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, SVCCTL_R_ENUM_SERVICES_STATUS *r_u) +{ + ENUM_SERVICES_STATUS *services = NULL; + + uint32 num_int_services = 0; + uint32 num_ext_services = 0; + int i = 0; + size_t buffer_size; + WERROR result = WERR_OK; + WERROR ext_result = WERR_OK; + + /* num_services = str_list_count( lp_enable_svcctl() ); */ + + /* here's where we'll read the db of external services */ + /* _svcctl_read_LSB_data(NULL,NULL); */ + /* init_svcctl_db(); */ + num_int_services = 0; + + num_int_services = _svcctl_num_internal_services(); + + num_ext_services = _svcctl_num_external_services(); + + if ( !(services = TALLOC_ARRAY(p->mem_ctx, ENUM_SERVICES_STATUS, num_int_services+num_ext_services )) ) + return WERR_NOMEM; + + result = _svcctl_enum_internal_services(p->mem_ctx, &services, 0, &num_int_services); + + if (W_ERROR_IS_OK(result)) { + DEBUG(8,("_svcctl_enum_services_status: Got %d internal services\n", num_int_services)); + } + + ext_result=_svcctl_enum_external_services(p->mem_ctx, &services, num_int_services, &num_ext_services); + + if (W_ERROR_IS_OK(ext_result)) { + DEBUG(8,("_svcctl_enum_services_status: Got %d external services\n", num_ext_services)); + } + + DEBUG(8,("_svcctl_enum_services_status: total of %d services\n", num_int_services+num_ext_services)); + buffer_size = 0; - for (i=0; i q_u->buffer_size ) { - num_services = 0; + DEBUG(8,("_svcctl_enum_services_status: buffer size passed %d, we need %d\n", + q_u->buffer_size, buffer_size)); + + if (buffer_size > q_u->buffer_size ) { + num_int_services = 0; + num_ext_services = 0; result = WERR_MORE_DATA; } - - /* we have to set the outgoing buffer size to the same as the - incoming buffer size (even in the case of failure */ - rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); - + rpcbuf_init(&r_u->buffer, q_u->buffer_size, p->mem_ctx); + if ( W_ERROR_IS_OK(result) ) { - for ( i=0; ibuffer, 0 ); } - + r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size; - r_u->returned = num_services; + r_u->returned = num_int_services+num_ext_services; if ( !(r_u->resume = TALLOC_P( p->mem_ctx, uint32 )) ) return WERR_NOMEM; @@ -254,7 +1166,75 @@ WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCT WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, SVCCTL_R_CONTROL_SERVICE *r_u) { - return WERR_ACCESS_DENIED; + Service_info *service_info; + POLICY_HND *handle; + pstring command; + fstring fhandle_string; + SERVICE_STATUS *service_status; + int ret,fd; + + /* need to find the service name by the handle that is open */ + handle = &(q_u->handle); + policy_handle_to_string(&q_u->handle, &fhandle_string); + + DEBUG(10, ("_svcctl_control_service: Looking for handle [%s]\n",fhandle_string)); + + service_info = find_service_info_by_hnd(p, handle); + + if (!service_info) { + DEBUG(10, ("_svcctl_control_service : Can't find the service for the handle\n")); + return WERR_BADFID; + } + + /* we return a SERVICE_STATUS structure if there's an error. */ + if ( !(service_status = TALLOC_ARRAY(p->mem_ctx, SERVICE_STATUS, 1 )) ) + return WERR_NOMEM; + + DEBUG(10, ("_svcctl_control_service: Found service [%s], [%s]\n", + service_info->servicename, service_info->filename)); + + /* TODO - call the service config function here... */ + memset(command, 0, sizeof(command)); + if (q_u->control == SVCCTL_CONTROL_STOP) { + slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, + service_info->filename, "stop"); + } + + if (q_u->control == SVCCTL_CONTROL_PAUSE) { + slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, + service_info->filename, "stop"); + } + + if (q_u->control == SVCCTL_CONTROL_CONTINUE) { + slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, + service_info->filename, "restart"); + } + + DEBUG(10, ("_svcctl_control_service: status command is [%s]\n", command)); + + /* TODO - wrap in privilege check */ + + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); + close(fd); + + if(ret != 0) + DEBUG(10, ("_svcctl_enum_external_services: Command returned [%d]\n", ret)); + + /* SET all service_stats bits here...*/ + if (ret == 0) { + service_status->state = SVCCTL_RUNNING; + service_status->controls_accepted = SVCCTL_CONTROL_SHUTDOWN | SVCCTL_CONTROL_STOP; + } else { + service_status->state = SVCCTL_STOPPED; + service_status->controls_accepted = 0; + } + + DEBUG(10, ("_svcctl_query_service_config: Should call the commFound service [%s], [%s]\n",service_info->servicename,service_info->filename)); + + /* no dependent services...basically a stub function */ + + return WERR_OK; } /******************************************************************** @@ -279,17 +1259,256 @@ WERROR _svcctl_enum_dependent_services( pipes_struct *p, SVCCTL_Q_ENUM_DEPENDENT /******************************************************************** ********************************************************************/ -WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CONFIG *q_u, SVCCTL_R_QUERY_SERVICE_CONFIG *r_u ) +WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_STATUSEX *q_u, SVCCTL_R_QUERY_SERVICE_STATUSEX *r_u ) { + SERVICE_STATUS_PROCESS ssp; + fstring fhandle_string; + POLICY_HND *handle; + Service_info *service_info; + pstring command; + int ret,fd; + + /* we have to set the outgoing buffer size to the same as the + incoming buffer size (even in the case of failure */ + + r_u->needed = q_u->buffer_size; + + /* need to find the service name by the handle that is open */ + handle = &(q_u->handle); + policy_handle_to_string(&q_u->handle, &fhandle_string); + + DEBUG(10, ("_svcctl_query_service_status_ex Looking for handle [%s]\n",fhandle_string)); + + /* get rid of the easy errors */ + + if (q_u->info_level != SVC_STATUS_PROCESS_INFO) { + DEBUG(10, ("_svcctl_query_service_status_ex : Invalid information level specified\n")); + return WERR_UNKNOWN_LEVEL; + } + + service_info = find_service_info_by_hnd(p, handle); + + if (!service_info) { + DEBUG(10, ("_svcctl_query_service_status_ex : Can't find the service for the handle\n")); + return WERR_BADFID; + } + if (r_u->needed < (sizeof(SERVICE_STATUS_PROCESS)+sizeof(uint32)+sizeof(uint32))) { + DEBUG(10, ("_svcctl_query_service_status_ex : buffer size of [%d] is too small.\n",r_u->needed)); + return WERR_INSUFFICIENT_BUFFER; + } + + ZERO_STRUCT(ssp); + + if (!strwicmp(service_info->servicetype,"EXTERNAL")) + ssp.type = SVCCTL_WIN32_OWN_PROC; + else + ssp.type = SVCCTL_WIN32_SHARED_PROC; + + /* Get the status of the service.. */ + + DEBUG(10, ("_svcctl_query_service_status_ex: Found service [%s], [%s]\n",service_info->servicename,service_info->filename)); + + memset(command, 0, sizeof(command)); + + slprintf(command, sizeof(command)-1, "%s%s%s %s", + dyn_LIBDIR, SVCCTL_SCRIPT_DIR, service_info->filename, "status"); + + DEBUG(10, ("_svcctl_query_service_status_ex: status command is [%s]\n", command)); + + /* TODO - wrap in privilege check */ + + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); + close(fd); + if(ret != 0) + DEBUG(10, ("_svcctl_query_service_status_ex: Command returned [%d]\n", ret)); + + /* SET all service_stats bits here... */ + if (ret == 0) { + ssp.state = SVCCTL_RUNNING; + ssp.controls_accepted = SVCCTL_CONTROL_SHUTDOWN | SVCCTL_CONTROL_STOP; + } else { + ssp.state = SVCCTL_STOPPED; + ssp.controls_accepted = 0; + } + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CONFIG *q_u, SVCCTL_R_QUERY_SERVICE_CONFIG *r_u ) +{ + /* SERVICE_CONFIG *service_config = NULL; */ + fstring fhandle_string; + POLICY_HND *handle; + Service_info *service_info; + pstring fullpathinfo; + uint32 needed_size; + /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ r_u->needed = q_u->buffer_size; + + /* need to find the service name by the handle that is open */ + handle = &(q_u->handle); + policy_handle_to_string(&q_u->handle, &fhandle_string); + + DEBUG(10, ("_svcctl_query_service_config: Looking for handle [%s]\n",fhandle_string)); + + service_info = find_service_info_by_hnd(p, handle); + +#if 0 + if (q_u->buffer_size < sizeof(Service_info)) { + /* have to report need more... */ + /* TODO worst case -- should actualy calc what we need here. */ + r_u->needed = sizeof(Service_info)+sizeof(pstring)*5; + DEBUG(10, ("_svcctl_query_service_config: NOT ENOUGH BUFFER ALLOCATED FOR RETURN DATA -- provided %d wanted %d\n", + q_u->buffer_size,r_u->needed)); + + return WERR_INSUFFICIENT_BUFFER; + } +#endif + if (!service_info) { + DEBUG(10, ("_svcctl_query_service_config : Can't find the service for the handle\n")); + return WERR_BADFID; + } + +#if 0 + if ( !(service_config = (SERVICE_CONFIG *)TALLOC_ZERO_P(p->mem_ctx, SERVICE_CONFIG)) ) + return WERR_NOMEM; +#endif + + r_u->config.service_type = SVCCTL_WIN32_OWN_PROC; + r_u->config.start_type = SVCCTL_DEMAND_START; + r_u->config.error_control = SVCCTL_SVC_ERROR_IGNORE; + r_u->config.tag_id = 0x00000000; + + /* Init the strings */ + + r_u->config.executablepath = TALLOC_ZERO_P(p->mem_ctx, UNISTR2); + r_u->config.loadordergroup = TALLOC_ZERO_P(p->mem_ctx, UNISTR2); + r_u->config.dependencies = TALLOC_ZERO_P(p->mem_ctx, UNISTR2); + r_u->config.startname = TALLOC_ZERO_P(p->mem_ctx, UNISTR2); + r_u->config.displayname = TALLOC_ZERO_P(p->mem_ctx, UNISTR2); + + DEBUG(10, ("_svcctl_query_service_config: Found service [%s], [%s]\n",service_info->servicename,service_info->filename)); + + pstrcpy(fullpathinfo,dyn_LIBDIR); + pstrcat(fullpathinfo,SVCCTL_SCRIPT_DIR); + pstrcat(fullpathinfo,service_info->filename); + + /* Get and calculate the size of the fields. Note that we're still building the fields in the "too-small buffer case" + even though we throw it away. */ - /* no dependent services...basically a stub function */ + DEBUG(10, ("_svcctl_query_service_config: fullpath info [%s]\n",fullpathinfo)); + init_unistr2(r_u->config.executablepath,fullpathinfo,UNI_STR_TERMINATE); + init_unistr2(r_u->config.loadordergroup,"",UNI_STR_TERMINATE); + init_unistr2(r_u->config.dependencies,service_info->dependencies,UNI_STR_TERMINATE); - return WERR_ACCESS_DENIED; + /* TODO - if someone really cares, perhaps "LocalSystem" should be changed to something else here... */ + + init_unistr2(r_u->config.startname,"LocalSystem",UNI_STR_TERMINATE); + init_unistr2(r_u->config.displayname,service_info->servicename,UNI_STR_TERMINATE); + + needed_size = 0x04 + sizeof(SERVICE_CONFIG)+ 2*( + r_u->config.executablepath->uni_str_len + + r_u->config.loadordergroup->uni_str_len + + r_u->config.dependencies->uni_str_len + + r_u->config.startname->uni_str_len + + r_u->config.displayname->uni_str_len); + + DEBUG(10, ("_svcctl_query_service_config: ****** need to have a buffer of [%d], [%d] for struct \n",needed_size, + sizeof(SERVICE_CONFIG))); + DEBUG(10, ("\tsize of executable path : %d\n",r_u->config.executablepath->uni_str_len)); + DEBUG(10, ("\tsize of loadordergroup : %d\n", r_u->config.loadordergroup->uni_str_len)); + DEBUG(10, ("\tsize of dependencies : %d\n", r_u->config.dependencies->uni_str_len)); + DEBUG(10, ("\tsize of startname : %d\n", r_u->config.startname->uni_str_len)); + DEBUG(10, ("\tsize of displayname : %d\n", r_u->config.displayname->uni_str_len)); + + if (q_u->buffer_size < needed_size) { + /* have to report need more...*/ + r_u->needed = needed_size; + DEBUG(10, ("_svcctl_query_service_config: ****** zeroing strings for return\n")); + memset(&r_u->config,0,sizeof(SERVICE_CONFIG)); + DEBUG(10, ("_svcctl_query_service_config: Not enouh buffer provided for return -- provided %d wanted %d\n", + q_u->buffer_size,needed_size)); + return WERR_INSUFFICIENT_BUFFER; + } + + return WERR_OK; } +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CONFIG2 *q_u, SVCCTL_R_QUERY_SERVICE_CONFIG2 *r_u ) +{ + fstring fhandle_string; + POLICY_HND *handle; + Service_info *service_info; + uint32 level, string_buffer_size; + + /* we have to set the outgoing buffer size to the same as the + incoming buffer size (even in the case of failure */ + r_u->needed = q_u->buffer_size; + r_u->description = NULL; + r_u->returned = q_u->buffer_size; + r_u->offset = 4; + + handle = &(q_u->handle); + policy_handle_to_string(&(q_u->handle), &fhandle_string); + + DEBUG(10, ("_svcctl_query_service_config2: Looking for handle [%s]\n",fhandle_string)); + + service_info = find_service_info_by_hnd(p, handle); + + if (!service_info) { + DEBUG(10, ("_svcctl_query_service_config2 : Can't find the service for the handle\n")); + return WERR_BADFID; + } + + /* + TODO - perhaps move the RPC_DATA_BLOB into the R_QUERY_SERVICE_CONFIG structure, and to the processing in here, vs + in the *r_query_config2 marshalling routine... + */ + + level = q_u->info_level; + DEBUG(10, ("_svcctl_query_service_config2: Found service [%s], [%s]\n",service_info->servicename,service_info->filename)); + DEBUG(10, ("_svcctl_query_service_config2: Looking for level [%x], buffer size is [%x]\n",level,q_u->buffer_size)); + + if (SERVICE_CONFIG_DESCRIPTION == level) { + if (service_info && service_info->shortdescription) { + /* length of the string, plus the terminator... */ + string_buffer_size = strlen(service_info->shortdescription)+1; + DEBUG(10, ("_svcctl_query_service_config: copying the description [%s] length [%d]\n", + service_info->shortdescription,string_buffer_size)); + + if (q_u->buffer_size >= ((string_buffer_size)*2+4)) { + r_u->description = TALLOC_ZERO_P(p->mem_ctx, UNISTR2); + if (!r_u->description) return WERR_NOMEM; + init_unistr2(r_u->description,service_info->shortdescription,UNI_STR_TERMINATE); + } + } + else { + string_buffer_size = 0; + } + DEBUG(10, ("_svcctl_query_service_config2: buffer needed is [%x], return buffer size is [%x]\n", + string_buffer_size,q_u->buffer_size)); + if (((string_buffer_size)*2+4) > q_u->buffer_size) { + r_u->needed = (string_buffer_size+1)*2+4; + DEBUG(10, ("_svcctl_query_service_config2: INSUFFICIENT BUFFER\n")); + return WERR_INSUFFICIENT_BUFFER; + } + DEBUG(10, ("_svcctl_query_service_config2: returning ok, needed is [%x], buffer size is [%x]\n", + r_u->needed,q_u->buffer_size)); + + return WERR_OK; + } + + return WERR_ACCESS_DENIED; +} -- cgit From 2265f5c9d7a829a835d6b58be2abe0604ee0b367 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 14 Jun 2005 15:40:51 +0000 Subject: r7573: you can't make an omlette without break a few eggs....start reworking the svcctl code (This used to be commit 24b369d12f8d5dbfdc317e5f088b8ae2583f4483) --- source3/rpc_server/srv_svcctl_nt.c | 716 ++++++++++++++++--------------------- 1 file changed, 300 insertions(+), 416 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 1feb0f66e4..707fd8bdd5 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -1,7 +1,8 @@ /* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines - * Copyright (C) Gerald (Jerry) Carter 2005 + * Copyright (C) Gerald (Jerry) Carter 2005, + * Copyright (C) Marcin Krzysztof Porwit 2005. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -90,8 +91,99 @@ static const Internal_service_description ISD[] = { (d) check access control masks with se_access_check() ********************************************************************/ -/* parse a LSB init.d type file for things it provides, dependencies, descriptions, etc. */ - +/********************************************************************* + given a service nice name, find the underlying service name +*********************************************************************/ + +BOOL _svcctl_service_nicename_to_servicename(TDB_CONTEXT *stdb,pstring service_nicename, pstring servicename,int szsvcname) +{ + pstring keystring; + TDB_DATA key_data; + + if ((stdb == NULL) || (service_nicename==NULL) || (servicename == NULL)) + return False; + + pstr_sprintf(keystring,"SERVICE_NICENAME/%s", servicename); + + DEBUG(5, ("_svcctl_service_nicename_to_servicename: Looking for service name [%s], key [%s]\n", + service_nicename, keystring)); + + key_data = tdb_fetch_bystring(stdb,keystring); + + if (key_data.dsize == 0) { + DEBUG(5, ("_svcctl_service_nicename_to_servicename: [%s] Not found, tried key [%s]\n",service_nicename,keystring)); + return False; + } + + strncpy(servicename,key_data.dptr,szsvcname); + servicename[(key_data.dsize > szsvcname ? szsvcname : key_data.dsize)] = 0; + DEBUG(5, ("_svcctl_service_nicename_to_servicename: Found service name [%s], name is [%s]\n", + service_nicename,servicename)); + + return True; +} + +/********************************************************************* +*********************************************************************/ + +static BOOL write_si_to_service_tdb(TDB_CONTEXT *stdb,char *service_name, Service_info *si) +{ + pstring keystring; + + /* Note -- when we write to the tdb, we "index" on the filename + field, not the nice name. when a service is "opened", it is + opened by the nice (SERVICENAME) name, not the file name. + So there needs to be a mapping from nice name back to the file name. */ + + if ((stdb == NULL) || (si == NULL) || (service_name==NULL) || (*service_name == 0)) + return False; + + + /* Store the nicename */ + + pstr_sprintf(keystring,"SERVICE_NICENAME/%s", si->servicename); + tdb_store_bystring(stdb,keystring,string_tdb_data(service_name),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/TYPE", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->servicetype),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/FILENAME", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->filename),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/PROVIDES", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->provides),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/SERVICENAME", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->servicename),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/DEPENDENCIES", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->dependencies),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTART", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->shouldstart),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTOP", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->shouldstop),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTART", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->requiredstart),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTOP", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->requiredstop),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/DESCRIPTION", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->description),TDB_REPLACE); + + pstr_sprintf(keystring,"SERVICE/%s/SHORTDESC", service_name); + tdb_lock_bystring(stdb, keystring, 0); + if (si->shortdescription && *si->shortdescription) + tdb_store_bystring(stdb,keystring,string_tdb_data(si->shortdescription),TDB_REPLACE); + else + tdb_store_bystring(stdb,keystring,string_tdb_data(si->description),TDB_REPLACE); + + return True; +} + /******************************************************************************* Get the INTERNAL services information for the given service name. @@ -100,6 +192,7 @@ static const Internal_service_description ISD[] = { static BOOL _svcctl_get_internal_service_data(const Internal_service_description *isd, Service_info *si) { ZERO_STRUCTP( si ); +#if 0 pstrcpy( si->servicename, isd->displayname); pstrcpy( si->servicetype, "INTERNAL"); @@ -107,6 +200,7 @@ static BOOL _svcctl_get_internal_service_data(const Internal_service_description pstrcpy( si->provides, isd->displayname); pstrcpy( si->description, isd->description); pstrcpy( si->shortdescription, isd->description); +#endif return True; } @@ -257,172 +351,6 @@ static BOOL _svcctl_get_LSB_data(char *fname,Service_info *si ) return False; } - -BOOL _svcctl_read_service_tdb_to_si(TDB_CONTEXT *stdb,char *service_name, Service_info *si) -{ - - pstring keystring; - TDB_DATA key_data; - - if ((stdb == NULL) || (si == NULL) || (service_name==NULL) || (*service_name == 0)) - return False; - - /* TODO - error handling -- what if the service isn't in the DB? */ - - pstr_sprintf(keystring,"SERVICE/%s/TYPE", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->servicetype,key_data.dptr,key_data.dsize); - si->servicetype[key_data.dsize] = 0; - - /* crude check to see if the service exists... */ - DEBUG(3,("Size of the TYPE field is %d\n",key_data.dsize)); - if (key_data.dsize == 0) - return False; - - pstr_sprintf(keystring,"SERVICE/%s/FILENAME", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->filename,key_data.dptr,key_data.dsize); - si->filename[key_data.dsize] = 0; - - pstr_sprintf(keystring,"SERVICE/%s/PROVIDES", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->provides,key_data.dptr,key_data.dsize); - si->provides[key_data.dsize] = 0; - strncpy(si->servicename,key_data.dptr,key_data.dsize); - si->servicename[key_data.dsize] = 0; - - - pstr_sprintf(keystring,"SERVICE/%s/DEPENDENCIES", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->dependencies,key_data.dptr,key_data.dsize); - si->dependencies[key_data.dsize] = 0; - - pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTART", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->shouldstart,key_data.dptr,key_data.dsize); - si->shouldstart[key_data.dsize] = 0; - - pstr_sprintf(keystring,"SERVICE/%s/SHOULD_STOP", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->shouldstop,key_data.dptr,key_data.dsize); - si->shouldstop[key_data.dsize] = 0; - - pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTART", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->requiredstart,key_data.dptr,key_data.dsize); - si->requiredstart[key_data.dsize] = 0; - - pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTOP", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->requiredstop,key_data.dptr,key_data.dsize); - si->requiredstop[key_data.dsize] = 0; - - pstr_sprintf(keystring,"SERVICE/%s/DESCRIPTION", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->description,key_data.dptr,key_data.dsize); - si->description[key_data.dsize] = 0; - - pstr_sprintf(keystring,"SERVICE/%s/SHORTDESC", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->shortdescription,key_data.dptr,key_data.dsize); - si->shortdescription[key_data.dsize] = 0; - - return True; -} - -/********************************************************************* - given a service nice name, find the underlying service name -*********************************************************************/ - -BOOL _svcctl_service_nicename_to_servicename(TDB_CONTEXT *stdb,pstring service_nicename, pstring servicename,int szsvcname) -{ - pstring keystring; - TDB_DATA key_data; - - if ((stdb == NULL) || (service_nicename==NULL) || (servicename == NULL)) - return False; - - pstr_sprintf(keystring,"SERVICE_NICENAME/%s", servicename); - - DEBUG(5, ("_svcctl_service_nicename_to_servicename: Looking for service name [%s], key [%s]\n", - service_nicename, keystring)); - - key_data = tdb_fetch_bystring(stdb,keystring); - - if (key_data.dsize == 0) { - DEBUG(5, ("_svcctl_service_nicename_to_servicename: [%s] Not found, tried key [%s]\n",service_nicename,keystring)); - return False; - } - - strncpy(servicename,key_data.dptr,szsvcname); - servicename[(key_data.dsize > szsvcname ? szsvcname : key_data.dsize)] = 0; - DEBUG(5, ("_svcctl_service_nicename_to_servicename: Found service name [%s], name is [%s]\n", - service_nicename,servicename)); - - return True; -} - -/********************************************************************* -*********************************************************************/ - -BOOL _svcctl_write_si_to_service_tdb(TDB_CONTEXT *stdb,char *service_name, Service_info *si) -{ - pstring keystring; - - /* Note -- when we write to the tdb, we "index" on the filename - field, not the nice name. when a service is "opened", it is - opened by the nice (SERVICENAME) name, not the file name. - So there needs to be a mapping from nice name back to the file name. */ - - if ((stdb == NULL) || (si == NULL) || (service_name==NULL) || (*service_name == 0)) - return False; - - - /* Store the nicename */ - - pstr_sprintf(keystring,"SERVICE_NICENAME/%s", si->servicename); - tdb_store_bystring(stdb,keystring,string_tdb_data(service_name),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/TYPE", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->servicetype),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/FILENAME", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->filename),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/PROVIDES", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->provides),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/SERVICENAME", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->servicename),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/DEPENDENCIES", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->dependencies),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTART", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->shouldstart),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTOP", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->shouldstop),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTART", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->requiredstart),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTOP", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->requiredstop),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/DESCRIPTION", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->description),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/SHORTDESC", service_name); - tdb_lock_bystring(stdb, keystring, 0); - if (si->shortdescription && *si->shortdescription) - tdb_store_bystring(stdb,keystring,string_tdb_data(si->shortdescription),TDB_REPLACE); - else - tdb_store_bystring(stdb,keystring,string_tdb_data(si->description),TDB_REPLACE); - - return True; -} - /**************************************************************************** Create/Open the service control manager tdb. This code a clone of init_group_mapping. ****************************************************************************/ @@ -471,7 +399,7 @@ BOOL init_svcctl_db(void) DEBUG(10,("Reading information on service %s\n",*svcname)); if (_svcctl_get_LSB_data(*svcname,&si));{ /* write the information to the TDB */ - _svcctl_write_si_to_service_tdb(service_tdb,*svcname,&si); + write_si_to_service_tdb(service_tdb,*svcname,&si); /* definitely not efficient to do it this way. */ pstrcat(external_service_list,"\""); pstrcat(external_service_list,*svcname); @@ -494,7 +422,7 @@ BOOL init_svcctl_db(void) DEBUG(10,("Reading information on service %s\n",isd_ptr->filename)); if (_svcctl_get_internal_service_data(isd_ptr,&si)){ /* write the information to the TDB */ - _svcctl_write_si_to_service_tdb(service_tdb,(char *)isd_ptr->filename,&si); + write_si_to_service_tdb(service_tdb,(char *)isd_ptr->filename,&si); /* definitely not efficient to do it this way. */ pstrcat(internal_service_list,"\""); pstrcat(internal_service_list,isd_ptr->filename); @@ -512,100 +440,161 @@ BOOL init_svcctl_db(void) return True; } -/* Service_info related functions */ -static Service_info *find_service_info_by_hnd(pipes_struct *p, POLICY_HND *handle) +/******************************************************************** +********************************************************************/ + +static BOOL read_service_tdb_to_si(TDB_CONTEXT *stdb,char *service_name, Service_info *si) { - Service_info *info = NULL; - if(!(find_policy_by_hnd(p,handle,(void **)&info))) - DEBUG(2,("find_service_info_by_hnd: service not found.\n")); + pstring keystring; + TDB_DATA key_data; - return info; -} + if ((stdb == NULL) || (si == NULL) || (service_name==NULL) || (*service_name == 0)) + return False; -static void free_service_info(void *ptr) -{ - Service_info *info = (Service_info *)ptr; - memset(info,'0',sizeof(Service_info)); - SAFE_FREE(info); -} + /* TODO - error handling -- what if the service isn't in the DB? */ + + pstr_sprintf(keystring,"SERVICE/%s/TYPE", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->servicetype,key_data.dptr,key_data.dsize); + si->servicetype[key_data.dsize] = 0; -/* SCM_info related functions */ -static void free_SCM_info(void *ptr) -{ - SCM_info *info = (SCM_info *)ptr; - memset(info->target_server_name, '0', sizeof(*(info->target_server_name))); - memset(info->target_db_name, '0', sizeof(*(info->target_db_name))); - memset(info, 0, sizeof(*(info))); - SAFE_FREE(info); -} + /* crude check to see if the service exists... */ + DEBUG(3,("Size of the TYPE field is %d\n",key_data.dsize)); + if (key_data.dsize == 0) + return False; -static SCM_info *find_SCManager_info_by_hnd(pipes_struct *p, POLICY_HND *handle) -{ - SCM_info *info = NULL; - - if ( !(find_policy_by_hnd(p,handle,(void **)&info)) ) - DEBUG(2,("svcctl_find_SCManager_info_by_hnd: service not found.\n")); + pstr_sprintf(keystring,"SERVICE/%s/FILENAME", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->filename,key_data.dptr,key_data.dsize); + si->filename[key_data.dsize] = 0; - return info; -} + pstr_sprintf(keystring,"SERVICE/%s/PROVIDES", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->provides,key_data.dptr,key_data.dsize); + si->provides[key_data.dsize] = 0; + strncpy(si->servicename,key_data.dptr,key_data.dsize); + si->servicename[key_data.dsize] = 0; -static BOOL _svcctl_open_SCManager_hook(SCM_info *info) -{ - return True; -} + + pstr_sprintf(keystring,"SERVICE/%s/DEPENDENCIES", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->dependencies,key_data.dptr,key_data.dsize); + si->dependencies[key_data.dsize] = 0; + + pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTART", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->shouldstart,key_data.dptr,key_data.dsize); + si->shouldstart[key_data.dsize] = 0; + + pstr_sprintf(keystring,"SERVICE/%s/SHOULD_STOP", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->shouldstop,key_data.dptr,key_data.dsize); + si->shouldstop[key_data.dsize] = 0; + + pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTART", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->requiredstart,key_data.dptr,key_data.dsize); + si->requiredstart[key_data.dsize] = 0; + + pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTOP", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->requiredstop,key_data.dptr,key_data.dsize); + si->requiredstop[key_data.dsize] = 0; + + pstr_sprintf(keystring,"SERVICE/%s/DESCRIPTION", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->description,key_data.dptr,key_data.dsize); + si->description[key_data.dsize] = 0; + + pstr_sprintf(keystring,"SERVICE/%s/SHORTDESC", service_name); + key_data = tdb_fetch_bystring(stdb,keystring); + strncpy(si->shortdescription,key_data.dptr,key_data.dsize); + si->shortdescription[key_data.dsize] = 0; -static BOOL _svcctl_close_SCManager_hook(SCM_info *info) -{ return True; } -/******************************************************************** -********************************************************************/ - -WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVCCTL_R_OPEN_SCMANAGER *r_u) +/****************************************************************** + free() function for REGISTRY_KEY + *****************************************************************/ + +static void free_service_handle_info(void *ptr) { - /* create the DB of the services that we have */ + SERVICE_INFO *info = (SERVICE_INFO*)ptr; - /* associate the information from the service opened in the create_policy_hnd string */ - - SCM_info *info = NULL; - fstring fhandle_string; + SAFE_FREE(info->name); + SAFE_FREE(info); +} - if(!q_u || !r_u) - return WERR_NOMEM; - - if((info = SMB_MALLOC_P(SCM_info)) == NULL) - return WERR_NOMEM; - - ZERO_STRUCTP(info); +/****************************************************************** + Find a registry key handle and return a SERVICE_INFO + *****************************************************************/ - info->type = SVC_HANDLE_IS_SCM; +static SERVICE_INFO *find_service_info_by_hnd(pipes_struct *p, POLICY_HND *hnd) +{ + SERVICE_INFO *service_info = NULL; - if(q_u->servername != 0) - unistr2_to_ascii(info->target_server_name, q_u->servername, sizeof(info->target_server_name)); - else { - /* if servername == NULL, use the local computer */ - pstrcpy(info->target_server_name, global_myname()); + if( !find_policy_by_hnd( p, hnd, (void **)&service_info) ) { + DEBUG(2,("find_service_info_by_hnd: handle not found")); + return NULL; } - DEBUG(10, ("_svcctl_open_scmanager: Using [%s] as the server name.\n", info->target_server_name)); - if(q_u->database != 0) - unistr2_to_ascii(info->target_db_name, q_u->database, sizeof(info->target_db_name)); - else - pstrcpy(info->target_db_name, "ServicesActive"); + return service_info; +} - if(!create_policy_hnd(p, &(r_u->handle), free_SCM_info, (void *)info)) +/****************************************************************** + *****************************************************************/ + +WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, const char *service ) +{ + SERVICE_INFO *info = NULL; + + if ( !(info = SMB_MALLOC_P( SERVICE_INFO )) ) return WERR_NOMEM; + + /* the Service Manager has a NULL name */ + + if ( !service ) { + info->type = SVC_HANDLE_IS_SCM; + } else { + info->type = SVC_HANDLE_IS_SERVICE; + + if ( !(info->name = SMB_STRDUP( service )) ) { + free_service_handle_info( info ); + WERR_NOMEM; + } + +#if 0 + /* lookup the SERVICE_CONTROL_OPS */ - policy_handle_to_string(&r_u->handle, &fhandle_string); - DEBUG(10, ("_svcctl_open_scmanager: Opening [%s] as the target services db, handle [%s]\n", info->target_db_name,fhandle_string)); + for ( i=0; svcctl_ops[i].name; i++ ) { + ;; + } +#endif + } - if(!(_svcctl_open_SCManager_hook(info))) { - /* TODO - should we free the memory that may have been allocated with the policy handle? */ - return WERR_BADFILE; + /* store the SERVICE_INFO and create an open handle */ + + if ( !create_policy_hnd( p, handle, free_service_handle_info, info ) ) { + free_service_handle_info( info ); + return WERR_ACCESS_DENIED; } + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVCCTL_R_OPEN_SCMANAGER *r_u) +{ + /* perform access checks */ + + + /* open the handle and return */ + + return create_open_service_handle( p, &r_u->handle, NULL ); } @@ -615,116 +604,35 @@ WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVC WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_R_OPEN_SERVICE *r_u) { pstring service; - pstring service_filename; - fstring fhandle_string; - Service_info *info; - - if(!q_u || !r_u) - return WERR_NOMEM; - - if((info = SMB_MALLOC_P(Service_info)) == NULL) - return WERR_NOMEM; - - ZERO_STRUCTP(info); - - info->type = SVC_HANDLE_IS_SERVICE; rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); - if (service_tdb == NULL) { - DEBUG(1, ("_svcctl_open_service: Cannot open Service [%s], the service database is not open; handle [%s]\n", service,fhandle_string)); - return WERR_ACCESS_DENIED; + DEBUG(5, ("_svcctl_open_service: Attempting to open Service [%s], \n", service)); + + if ( !service_tdb ) { + DEBUG(1, ("_svcctl_open_service: service database is not open\n!")); + return WERR_ACCESS_DENIED; } - DEBUG(1, ("_svcctl_open_service: Attempting to open Service [%s], \n", service)); + + /* check the access granted on the SCM handle */ + + /* check the access requested on this service */ + -#if 0 - if ( !_svcctl_service_nicename_to_servicename(service_tdb, service, service_filename, sizeof(pstring)) ) { - DEBUG(1, ("_svcctl_open_service: Cannot open Service [%s], the service can't be found\n", service)); +#if 0 /* FIXME!!! */ + if ( ! read_service_tdb_to_si(service_tdb,service, info) ) { return WERR_NO_SUCH_SERVICE; - } -#else - pstrcpy(service_filename,service); #endif - - if (_svcctl_read_service_tdb_to_si(service_tdb,service, info)) - DEBUG(1, ("_svcctl_open_service: Found service [%s], servicename [%s], \n", service, info->servicename)); - else - return WERR_NO_SUCH_SERVICE; -#if 0 - if ( !(strequal( service, "NETLOGON") || strequal(service, "Spooler")) ) - return WERR_NO_SUCH_SERVICE; -#endif - if ( !create_policy_hnd( p, &(r_u->handle), free_service_info, (void *)info ) ) - return WERR_ACCESS_DENIED; - - policy_handle_to_string(&r_u->handle, &fhandle_string); - DEBUG(10, ("_svcctl_open_service: Opening Service [%s], handle [%s]\n", service,fhandle_string)); - - return WERR_OK; + return create_open_service_handle( p, &r_u->handle, service ); } /******************************************************************** ********************************************************************/ -/* Note that this can be called to close an individual service, ** OR ** the Service Control Manager */ - WERROR _svcctl_close_service(pipes_struct *p, SVCCTL_Q_CLOSE_SERVICE *q_u, SVCCTL_R_CLOSE_SERVICE *r_u) { - SCM_info *scminfo; - Service_info *svcinfo; - POLICY_HND *handle; - fstring fhandle_string; - POLICY_HND null_policy_handle; - - - handle = &(q_u->handle); - - /* a handle is returned in the close when it's for a service */ - - policy_handle_to_string(handle, &fhandle_string); - DEBUG(10, ("_svcctl_close_service: Closing handle [%s]\n",fhandle_string)); - - ZERO_STRUCT(null_policy_handle); - - policy_handle_to_string(handle, &fhandle_string); - DEBUG(10, ("_svcctl_close_service: Closing handle [%s]\n",fhandle_string)); - - scminfo = find_SCManager_info_by_hnd(p, handle); - - if ((NULL != scminfo) && (scminfo->type == SVC_HANDLE_IS_SCM)) { - DEBUG(3,("_svcctl_close_service: Closing SERVICE DATABASE [%s]\n", scminfo->target_db_name)); - - if(!(_svcctl_close_SCManager_hook(scminfo))) - return WERR_BADFILE; - - if(!(close_policy_hnd(p, handle))) - { - /* WERR_NOMEM is probably not the correct error, but until I figure out a better - one it will have to do */ - DEBUG(3,("_svcctl_close_service: Can't close SCM \n")); - return WERR_NOMEM; - } - memcpy(&(r_u->handle),&null_policy_handle, sizeof(POLICY_HND)); - return WERR_OK; - } - - if ((NULL != scminfo) && (scminfo->type == SVC_HANDLE_IS_SERVICE)) { - svcinfo = (Service_info *)scminfo; - DEBUG(3,("_svcctl_close_service: Handle is a SERVICE not SCM \n")); - DEBUG(3,("_svcctl_close_service: Closing SERVICE [%s]\n", svcinfo->servicename)); - if(!(close_policy_hnd(p, handle))) - { - /* WERR_NOMEM is probably not the correct error, but until I figure out a better - one it will have to do */ - DEBUG(3,("_svcctl_close_service: Can't close SERVICE [%s]\n", svcinfo->servicename)); - return WERR_NOMEM; - } - } - - memcpy(&(r_u->handle),&null_policy_handle, sizeof(POLICY_HND)); - - return WERR_OK; + return close_policy_hnd( p, &q_u->handle ) ? WERR_OK : WERR_BADFID; } /******************************************************************** @@ -734,17 +642,13 @@ WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, { fstring service; fstring displayname; - fstring fhandle_string; - Service_info *service_info; + SERVICE_INFO *service_info; POLICY_HND *handle; rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); handle = &(q_u->handle); - policy_handle_to_string(&q_u->handle, &fhandle_string); - - DEBUG(10, ("_svcctl_get_display_name: Looking for handle [%s]\n",(char *)&fhandle_string)); service_info = find_service_info_by_hnd(p, handle); @@ -753,14 +657,9 @@ WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, return WERR_ACCESS_DENIED; } - DEBUG(10, ("_svcctl_get_display_name: Found service [%s], [%s]\n",service_info->servicename,service_info->filename)); - /* no dependent services...basically a stub function */ + DEBUG(10,("_svcctl_get_display_name: Found service [%s]\n", service_info->name )); -#if 0 - if ( !strequal( service, "NETLOGON" ) ) - return WERR_ACCESS_DENIED; -#endif - fstrcpy( displayname, service_info->servicename) ; + fstrcpy( displayname, "FIX ME!" ); init_svcctl_r_get_display_name( r_u, displayname ); @@ -772,7 +671,6 @@ WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_R_QUERY_STATUS *r_u) { - r_u->svc_status.type = 0x0020; r_u->svc_status.state = 0x0004; r_u->svc_status.controls_accepted = 0x0005; @@ -791,7 +689,7 @@ int _svcctl_num_external_services(void) if (!service_tdb) { - DEBUG(8,("_svcctl_enum_external_services: service database is not open!!!\n")); + DEBUG(8,("enum_external_services: service database is not open!!!\n")); num_services = 0; } else { pstrcpy(keystring,"EXTERNAL_SERVICES"); @@ -801,7 +699,7 @@ int _svcctl_num_external_services(void) if ((key_data.dptr != NULL) && (key_data.dsize != 0)) { strncpy(external_services_string,key_data.dptr,key_data.dsize); external_services_string[key_data.dsize] = 0; - DEBUG(8,("_svcctl_enum_external_services: services list is %s, size is %d\n",external_services_string,key_data.dsize)); + DEBUG(8,("enum_external_services: services list is %s, size is %d\n",external_services_string,key_data.dsize)); } tdb_unlock_bystring(service_tdb, keystring); } @@ -814,23 +712,26 @@ int _svcctl_num_external_services(void) -/* - - Gather information on the "external services". These are services listed in the smb.conf file, and found to exist through - checks in this code. Note that added will be incremented on the basis of the number of services added. svc_ptr should have enough - memory allocated to accommodate all of the services that exist. - - Typically _svcctl_num_external_services is used to "size" the amount of memory allocated, but does little/no work. - - _svcctl_enum_external_services actually examines each of the specified external services, populates the memory structures, and returns. - - ** note that 'added' may end up with less than the number of services found in _num_external_services, such as the case when a service is - called out, but the actual service doesn't exist or the file can't be read for the service information. - - - */ +/******************************************************************** + Gather information on the "external services". These are services + listed in the smb.conf file, and found to exist through checks in + this code. Note that added will be incremented on the basis of the + number of services added. svc_ptr should have enough memory allocated + to accommodate all of the services that exist. + + Typically _svcctl_num_external_services is used to "size" the amount of + memory allocated, but does little/no work. + + enum_external_services() actually examines each of the specified + external services, populates the memory structures, and returns. + + ** note that 'added' may end up with less than the number of services + found in _num_external_services, such as the case when a service is + called out, but the actual service doesn't exist or the file can't be + read for the service information. +********************************************************************/ -WERROR _svcctl_enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services,int *added) +WERROR enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services,int *added) { /* *svc_ptr must have pre-allocated memory */ int num_services = 0; @@ -846,7 +747,7 @@ WERROR _svcctl_enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc *added = num_services; if (!service_tdb) { - DEBUG(8,("_svcctl_enum_external_services: service database is not open!!!\n")); + DEBUG(8,("enum_external_services: service database is not open!!!\n")); } else { pstrcpy(keystring,"EXTERNAL_SERVICES"); tdb_lock_bystring(service_tdb, keystring, 0); @@ -854,7 +755,7 @@ WERROR _svcctl_enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc if ((key_data.dptr != NULL) && (key_data.dsize != 0)) { strncpy(external_services_string,key_data.dptr,key_data.dsize); external_services_string[key_data.dsize] = 0; - DEBUG(8,("_svcctl_enum_external_services: services list is %s, size is %d\n",external_services_string,key_data.dsize)); + DEBUG(8,("enum_external_services: services list is %s, size is %d\n",external_services_string,key_data.dsize)); } tdb_unlock_bystring(service_tdb, keystring); } @@ -863,24 +764,24 @@ WERROR _svcctl_enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc num_services = str_list_count( (const char **)svc_list); if (0 == num_services) { - DEBUG(8,("_svcctl_enum_external_services: there are no external services\n")); + DEBUG(8,("enum_external_services: there are no external services\n")); *added = num_services; return WERR_OK; } - DEBUG(8,("_svcctl_enum_external_services: there are [%d] external services\n",num_services)); + DEBUG(8,("enum_external_services: there are [%d] external services\n",num_services)); si=TALLOC_ARRAY( tcx, Service_info, 1 ); if (si == NULL) { - DEBUG(8,("_svcctl_enum_external_services: Failed to alloc si\n")); + DEBUG(8,("enum_external_services: Failed to alloc si\n")); return WERR_NOMEM; } #if 0 /* *svc_ptr has the pointer to the array if there is one already. NULL if not. */ if ((existing_services>0) && svc_ptr && *svc_ptr) { /* reallocate vs. allocate */ - DEBUG(8,("_svcctl_enum_external_services: REALLOCing %x to %d services\n", *svc_ptr, existing_services+num_services)); + DEBUG(8,("enum_external_services: REALLOCing %x to %d services\n", *svc_ptr, existing_services+num_services)); services=TALLOC_REALLOC_ARRAY(tcx,*svc_ptr,ENUM_SERVICES_STATUS,existing_services+num_services); - DEBUG(8,("_svcctl_enum_external_services: REALLOCed to %x services\n", services)); + DEBUG(8,("enum_external_services: REALLOCed to %x services\n", services)); if (!services) return WERR_NOMEM; *svc_ptr = services; @@ -898,13 +799,13 @@ WERROR _svcctl_enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc } svcname = svc_list; - DEBUG(8,("_svcctl_enum_external_services: enumerating %d external services starting at index %d\n", num_services,existing_services)); + DEBUG(8,("enum_external_services: enumerating %d external services starting at index %d\n", num_services,existing_services)); while (*svcname) { - DEBUG(10,("_svcctl_enum_external_services: Reading information on service %s, index %d\n",*svcname,i)); + DEBUG(10,("enum_external_services: Reading information on service %s, index %d\n",*svcname,i)); /* _svcctl_get_LSB_data(*svcname,si); */ - if (!_svcctl_read_service_tdb_to_si(service_tdb,*svcname, si)) { - DEBUG(1,("_svcctl_enum_external_services: CAN'T FIND INFO FOR SERVICE %s in the services DB\n",*svcname)); + if (!read_service_tdb_to_si(service_tdb,*svcname, si)) { + DEBUG(1,("enum_external_services: CAN'T FIND INFO FOR SERVICE %s in the services DB\n",*svcname)); } if ((si->filename == NULL) || (*si->filename == 0)) { @@ -922,7 +823,7 @@ WERROR _svcctl_enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc /* TODO - we could keep the following info in the DB, too... */ - DEBUG(8,("_svcctl_enum_external_services: Service name [%s] displayname [%s]\n", + DEBUG(8,("enum_external_services: Service name [%s] displayname [%s]\n", si->filename, si->provides)); services[i].status.type = SVCCTL_WIN32_OWN_PROC; services[i].status.win32_exit_code = 0x0; @@ -935,7 +836,7 @@ WERROR _svcctl_enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc memset(command, 0, sizeof(command)); slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, *svcname, "status"); - DEBUG(10, ("_svcctl_enum_external_services: status command is [%s]\n", command)); + DEBUG(10, ("enum_external_services: status command is [%s]\n", command)); /* TODO - wrap in privilege check */ @@ -943,7 +844,7 @@ WERROR _svcctl_enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc DEBUGADD(10, ("returned [%d]\n", ret)); close(fd); if(ret != 0) - DEBUG(10, ("_svcctl_enum_external_services: Command returned [%d]\n", ret)); + DEBUG(10, ("enum_external_services: Command returned [%d]\n", ret)); services[i].status.state = SVCCTL_STOPPED; if (ret == 0) { services[i].status.state = SVCCTL_RUNNING; @@ -956,7 +857,7 @@ WERROR _svcctl_enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc i++; } - DEBUG(10,("_svcctl_enum_external_services: Read services %d\n",num_services)); + DEBUG(10,("enum_external_services: Read services %d\n",num_services)); *added = num_services; return WERR_OK; @@ -1111,7 +1012,7 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT DEBUG(8,("_svcctl_enum_services_status: Got %d internal services\n", num_int_services)); } - ext_result=_svcctl_enum_external_services(p->mem_ctx, &services, num_int_services, &num_ext_services); + ext_result=enum_external_services(p->mem_ctx, &services, num_int_services, &num_ext_services); if (W_ERROR_IS_OK(ext_result)) { DEBUG(8,("_svcctl_enum_services_status: Got %d external services\n", num_ext_services)); @@ -1166,18 +1067,15 @@ WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCT WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, SVCCTL_R_CONTROL_SERVICE *r_u) { - Service_info *service_info; +#if 0 + SERVICE_INFO *service_info; POLICY_HND *handle; pstring command; - fstring fhandle_string; SERVICE_STATUS *service_status; int ret,fd; /* need to find the service name by the handle that is open */ handle = &(q_u->handle); - policy_handle_to_string(&q_u->handle, &fhandle_string); - - DEBUG(10, ("_svcctl_control_service: Looking for handle [%s]\n",fhandle_string)); service_info = find_service_info_by_hnd(p, handle); @@ -1219,7 +1117,7 @@ WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, S close(fd); if(ret != 0) - DEBUG(10, ("_svcctl_enum_external_services: Command returned [%d]\n", ret)); + DEBUG(10, ("enum_external_services: Command returned [%d]\n", ret)); /* SET all service_stats bits here...*/ if (ret == 0) { @@ -1232,7 +1130,7 @@ WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, S DEBUG(10, ("_svcctl_query_service_config: Should call the commFound service [%s], [%s]\n",service_info->servicename,service_info->filename)); - /* no dependent services...basically a stub function */ +#endif return WERR_OK; } @@ -1262,11 +1160,9 @@ WERROR _svcctl_enum_dependent_services( pipes_struct *p, SVCCTL_Q_ENUM_DEPENDENT WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_STATUSEX *q_u, SVCCTL_R_QUERY_SERVICE_STATUSEX *r_u ) { SERVICE_STATUS_PROCESS ssp; - fstring fhandle_string; POLICY_HND *handle; - Service_info *service_info; + SERVICE_INFO *service_info; pstring command; - int ret,fd; /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ @@ -1275,9 +1171,7 @@ WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_ /* need to find the service name by the handle that is open */ handle = &(q_u->handle); - policy_handle_to_string(&q_u->handle, &fhandle_string); - DEBUG(10, ("_svcctl_query_service_status_ex Looking for handle [%s]\n",fhandle_string)); /* get rid of the easy errors */ @@ -1300,19 +1194,19 @@ WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_ ZERO_STRUCT(ssp); +#if 0 if (!strwicmp(service_info->servicetype,"EXTERNAL")) ssp.type = SVCCTL_WIN32_OWN_PROC; else ssp.type = SVCCTL_WIN32_SHARED_PROC; +#endif /* Get the status of the service.. */ - DEBUG(10, ("_svcctl_query_service_status_ex: Found service [%s], [%s]\n",service_info->servicename,service_info->filename)); - memset(command, 0, sizeof(command)); - slprintf(command, sizeof(command)-1, "%s%s%s %s", - dyn_LIBDIR, SVCCTL_SCRIPT_DIR, service_info->filename, "status"); +#if 0 + slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, service_info->filename, "status"); DEBUG(10, ("_svcctl_query_service_status_ex: status command is [%s]\n", command)); @@ -1332,6 +1226,7 @@ WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_ ssp.state = SVCCTL_STOPPED; ssp.controls_accepted = 0; } +#endif return WERR_OK; } @@ -1341,11 +1236,8 @@ WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_ WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CONFIG *q_u, SVCCTL_R_QUERY_SERVICE_CONFIG *r_u ) { - /* SERVICE_CONFIG *service_config = NULL; */ - fstring fhandle_string; POLICY_HND *handle; - Service_info *service_info; - pstring fullpathinfo; + SERVICE_INFO *service_info; uint32 needed_size; /* we have to set the outgoing buffer size to the same as the @@ -1355,9 +1247,6 @@ WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CON /* need to find the service name by the handle that is open */ handle = &(q_u->handle); - policy_handle_to_string(&q_u->handle, &fhandle_string); - - DEBUG(10, ("_svcctl_query_service_config: Looking for handle [%s]\n",fhandle_string)); service_info = find_service_info_by_hnd(p, handle); @@ -1395,12 +1284,10 @@ WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CON r_u->config.startname = TALLOC_ZERO_P(p->mem_ctx, UNISTR2); r_u->config.displayname = TALLOC_ZERO_P(p->mem_ctx, UNISTR2); - DEBUG(10, ("_svcctl_query_service_config: Found service [%s], [%s]\n",service_info->servicename,service_info->filename)); - +#if 0 pstrcpy(fullpathinfo,dyn_LIBDIR); pstrcat(fullpathinfo,SVCCTL_SCRIPT_DIR); pstrcat(fullpathinfo,service_info->filename); - /* Get and calculate the size of the fields. Note that we're still building the fields in the "too-small buffer case" even though we throw it away. */ @@ -1413,6 +1300,7 @@ WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CON init_unistr2(r_u->config.startname,"LocalSystem",UNI_STR_TERMINATE); init_unistr2(r_u->config.displayname,service_info->servicename,UNI_STR_TERMINATE); +#endif needed_size = 0x04 + sizeof(SERVICE_CONFIG)+ 2*( r_u->config.executablepath->uni_str_len + @@ -1447,10 +1335,9 @@ WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CON WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CONFIG2 *q_u, SVCCTL_R_QUERY_SERVICE_CONFIG2 *r_u ) { - fstring fhandle_string; POLICY_HND *handle; - Service_info *service_info; - uint32 level, string_buffer_size; + SERVICE_INFO *service_info; + uint32 level; /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ @@ -1461,9 +1348,6 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO r_u->offset = 4; handle = &(q_u->handle); - policy_handle_to_string(&(q_u->handle), &fhandle_string); - - DEBUG(10, ("_svcctl_query_service_config2: Looking for handle [%s]\n",fhandle_string)); service_info = find_service_info_by_hnd(p, handle); @@ -1478,9 +1362,8 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO */ level = q_u->info_level; - DEBUG(10, ("_svcctl_query_service_config2: Found service [%s], [%s]\n",service_info->servicename,service_info->filename)); - DEBUG(10, ("_svcctl_query_service_config2: Looking for level [%x], buffer size is [%x]\n",level,q_u->buffer_size)); +#if 0 if (SERVICE_CONFIG_DESCRIPTION == level) { if (service_info && service_info->shortdescription) { /* length of the string, plus the terminator... */ @@ -1509,6 +1392,7 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO return WERR_OK; } +#endif return WERR_ACCESS_DENIED; } -- cgit From 023ac1031b0057ee752cf2d3a8de3d6e0d4b1802 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 14 Jun 2005 18:08:39 +0000 Subject: r7576: implement access checks for open_scm and open_service according to default security descriptor described in MSDN. no one can get in to due to the permissions, but i'll fix that next. (This used to be commit 11902e503ed4f6d6991a9fe7521fe44168274ec8) --- source3/rpc_server/srv_svcctl_nt.c | 126 +++++++++++++++++++++++++++++++++---- 1 file changed, 115 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 707fd8bdd5..53fddcf964 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -440,6 +440,91 @@ BOOL init_svcctl_db(void) return True; } +/******************************************************************** +********************************************************************/ + +static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, + uint32 access_desired, uint32 *access_granted ) +{ + NTSTATUS result; + + /* maybe add privilege checks in here later */ + + se_access_check( sec_desc, token, access_desired, access_granted, &result ); + + return result; +} + +/******************************************************************** +********************************************************************/ + +static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx ) +{ + SEC_ACE ace[2]; + SEC_ACCESS mask; + size_t i = 0; + SEC_DESC *sd; + SEC_ACL *acl; + uint32 sd_size; + + /* basic access for Everyone */ + + init_sec_access(&mask, SC_MANAGER_READ_ACCESS ); + init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /* Full Access 'BUILTIN\Administrators' */ + + init_sec_access(&mask,SC_MANAGER_ALL_ACCESS ); + init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + + /* create the security descriptor */ + + if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) + return NULL; + + if ( !(sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, acl, &sd_size)) ) + return NULL; + + return sd; +} + +/******************************************************************** +********************************************************************/ + +static SEC_DESC* construct_service_sd( TALLOC_CTX *ctx ) +{ + SEC_ACE ace[4]; + SEC_ACCESS mask; + size_t i = 0; + SEC_DESC *sd; + SEC_ACL *acl; + uint32 sd_size; + + /* basic access for Everyone */ + + init_sec_access(&mask, SERVICE_READ_ACCESS ); + init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + init_sec_access(&mask,SERVICE_EXECUTE_ACCESS ); + init_sec_ace(&ace[i++], &global_sid_Builtin_Power_Users, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + init_sec_access(&mask,SERVICE_ALL_ACCESS ); + init_sec_ace(&ace[i++], &global_sid_Builtin_Server_Operators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /* create the security descriptor */ + + if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) + return NULL; + + if ( !(sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, acl, &sd_size)) ) + return NULL; + + return sd; +} + + /******************************************************************** ********************************************************************/ @@ -546,12 +631,15 @@ static SERVICE_INFO *find_service_info_by_hnd(pipes_struct *p, POLICY_HND *hnd) /****************************************************************** *****************************************************************/ -WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, const char *service ) +static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, + const char *service, uint32 access_granted ) { SERVICE_INFO *info = NULL; if ( !(info = SMB_MALLOC_P( SERVICE_INFO )) ) return WERR_NOMEM; + + ZERO_STRUCTP( info ); /* the Service Manager has a NULL name */ @@ -574,6 +662,8 @@ WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, const ch #endif } + info->access_granted = access_granted; + /* store the SERVICE_INFO and create an open handle */ if ( !create_policy_hnd( p, handle, free_service_handle_info, info ) ) { @@ -589,13 +679,20 @@ WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, const ch WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVCCTL_R_OPEN_SCMANAGER *r_u) { - /* perform access checks */ + SEC_DESC *sec_desc; + uint32 access_granted = 0; + NTSTATUS status; - - /* open the handle and return */ + /* perform access checks */ - return create_open_service_handle( p, &r_u->handle, NULL ); - + if ( !(sec_desc = construct_scm_sd( p->mem_ctx )) ) + return WERR_NOMEM; + + status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); + if ( !NT_STATUS_IS_OK(status) ) + return ntstatus_to_werror( status ); + + return create_open_service_handle( p, &r_u->handle, NULL, access_granted ); } /******************************************************************** @@ -603,6 +700,9 @@ WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVC WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_R_OPEN_SERVICE *r_u) { + SEC_DESC *sec_desc; + uint32 access_granted = 0; + NTSTATUS status; pstring service; rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); @@ -614,17 +714,21 @@ WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_ return WERR_ACCESS_DENIED; } - /* check the access granted on the SCM handle */ - - /* check the access requested on this service */ + /* perform access checks */ - + if ( !(sec_desc = construct_service_sd( p->mem_ctx )) ) + return WERR_NOMEM; + + status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); + if ( !NT_STATUS_IS_OK(status) ) + return ntstatus_to_werror( status ); + #if 0 /* FIXME!!! */ if ( ! read_service_tdb_to_si(service_tdb,service, info) ) { return WERR_NO_SUCH_SERVICE; #endif - return create_open_service_handle( p, &r_u->handle, service ); + return create_open_service_handle( p, &r_u->handle, service, access_granted ); } /******************************************************************** -- cgit From 6109b8ad9dd586dad508658c65e33d012cad42b1 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 14 Jun 2005 18:38:15 +0000 Subject: r7578: use global well known DOM_SID objects when possible (This used to be commit 643dc05eb5a8e41cf9cb1768ef42f5dbc0320846) --- source3/rpc_server/srv_samr_nt.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 73ea575ec5..7c6e9f4d92 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -9,6 +9,7 @@ * Copyright (C) Jean François Micouleau 1998-2001, * Copyright (C) Jim McDonough 2002, * Copyright (C) Gerald (Jerry) Carter 2003-2004, + * Copyright (C) Simo Sorce 2003. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -76,7 +77,7 @@ static NTSTATUS make_samr_object_sd( TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd struct generic_mapping *map, DOM_SID *sid, uint32 sid_access ) { - DOM_SID adm_sid, act_sid, domadmin_sid; + DOM_SID domadmin_sid; SEC_ACE ace[5]; /* at most 5 entries */ SEC_ACCESS mask; size_t i = 0; @@ -90,16 +91,10 @@ static NTSTATUS make_samr_object_sd( TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd /* add Full Access 'BUILTIN\Administrators' and 'BUILTIN\Account Operators */ - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); - - sid_copy(&act_sid, &global_sid_Builtin); - sid_append_rid(&act_sid, BUILTIN_ALIAS_RID_ACCOUNT_OPS); - init_sec_access(&mask, map->generic_all); - init_sec_ace(&ace[i++], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[i++], &act_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &global_sid_Builtin_Account_Operators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /* Add Full Access for Domain Admins if we are a DC */ @@ -768,6 +763,8 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_aliases, aliases); + if (!NT_STATUS_IS_OK(status)) return status; + init_samr_r_enum_dom_aliases(r_u, q_u->start_idx + num_aliases, num_aliases); -- cgit From cfe893375473f6d12fd806347827baa615f0cd0a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 14 Jun 2005 19:04:39 +0000 Subject: r7581: fix bad merge (This used to be commit 55d08311032b75724b525d8e0df506de3e988b15) --- source3/rpc_server/srv_samr_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7c6e9f4d92..e510f69cc8 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -763,8 +763,6 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_aliases, aliases); - if (!NT_STATUS_IS_OK(status)) return status; - init_samr_r_enum_dom_aliases(r_u, q_u->start_idx + num_aliases, num_aliases); -- cgit From b6153cb78bdc6dbf26b716793222983fd00545b8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 14 Jun 2005 20:11:59 +0000 Subject: r7583: * more rearranging and renaming of functions * add access checks to _svcctl_XXX() calls based on the access granted on the handle (This used to be commit 82b76d4b34834b7f64389b85befe8bfcae04a404) --- source3/rpc_server/srv_svcctl_nt.c | 1078 +++++++++++++++++++----------------- 1 file changed, 570 insertions(+), 508 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 53fddcf964..3367768f81 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -42,7 +42,6 @@ */ #define SCVCTL_DATABASE_VERSION_V1 1 -TALLOC_CTX *svcdb=NULL; static TDB_CONTEXT *service_tdb; /* used for services tdb file */ /* there are two types of services -- internal, and external. @@ -91,11 +90,12 @@ static const Internal_service_description ISD[] = { (d) check access control masks with se_access_check() ********************************************************************/ +#if 0 /********************************************************************* given a service nice name, find the underlying service name *********************************************************************/ -BOOL _svcctl_service_nicename_to_servicename(TDB_CONTEXT *stdb,pstring service_nicename, pstring servicename,int szsvcname) +static BOOL convert_service_displayname(TDB_CONTEXT *stdb,pstring service_nicename, pstring servicename,int szsvcname) { pstring keystring; TDB_DATA key_data; @@ -105,91 +105,30 @@ BOOL _svcctl_service_nicename_to_servicename(TDB_CONTEXT *stdb,pstring service_ pstr_sprintf(keystring,"SERVICE_NICENAME/%s", servicename); - DEBUG(5, ("_svcctl_service_nicename_to_servicename: Looking for service name [%s], key [%s]\n", + DEBUG(5, ("convert_service_displayname: Looking for service name [%s], key [%s]\n", service_nicename, keystring)); key_data = tdb_fetch_bystring(stdb,keystring); if (key_data.dsize == 0) { - DEBUG(5, ("_svcctl_service_nicename_to_servicename: [%s] Not found, tried key [%s]\n",service_nicename,keystring)); + DEBUG(5, ("convert_service_displayname: [%s] Not found, tried key [%s]\n",service_nicename,keystring)); return False; } strncpy(servicename,key_data.dptr,szsvcname); servicename[(key_data.dsize > szsvcname ? szsvcname : key_data.dsize)] = 0; - DEBUG(5, ("_svcctl_service_nicename_to_servicename: Found service name [%s], name is [%s]\n", + DEBUG(5, ("convert_service_displayname: Found service name [%s], name is [%s]\n", service_nicename,servicename)); return True; } - -/********************************************************************* -*********************************************************************/ - -static BOOL write_si_to_service_tdb(TDB_CONTEXT *stdb,char *service_name, Service_info *si) -{ - pstring keystring; - - /* Note -- when we write to the tdb, we "index" on the filename - field, not the nice name. when a service is "opened", it is - opened by the nice (SERVICENAME) name, not the file name. - So there needs to be a mapping from nice name back to the file name. */ - - if ((stdb == NULL) || (si == NULL) || (service_name==NULL) || (*service_name == 0)) - return False; - - - /* Store the nicename */ - - pstr_sprintf(keystring,"SERVICE_NICENAME/%s", si->servicename); - tdb_store_bystring(stdb,keystring,string_tdb_data(service_name),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/TYPE", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->servicetype),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/FILENAME", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->filename),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/PROVIDES", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->provides),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/SERVICENAME", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->servicename),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/DEPENDENCIES", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->dependencies),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTART", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->shouldstart),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTOP", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->shouldstop),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTART", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->requiredstart),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTOP", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->requiredstop),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/DESCRIPTION", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->description),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/SHORTDESC", service_name); - tdb_lock_bystring(stdb, keystring, 0); - if (si->shortdescription && *si->shortdescription) - tdb_store_bystring(stdb,keystring,string_tdb_data(si->shortdescription),TDB_REPLACE); - else - tdb_store_bystring(stdb,keystring,string_tdb_data(si->description),TDB_REPLACE); - - return True; -} - +#endif /******************************************************************************* Get the INTERNAL services information for the given service name. *******************************************************************************/ -static BOOL _svcctl_get_internal_service_data(const Internal_service_description *isd, Service_info *si) +static BOOL get_internal_service_data(const Internal_service_description *isd, Service_info *si) { ZERO_STRUCTP( si ); #if 0 @@ -213,7 +152,7 @@ static BOOL _svcctl_get_internal_service_data(const Internal_service_description Get the names of the services/scripts to read from the smb.conf file. *******************************************************************************/ -static BOOL _svcctl_get_LSB_data(char *fname,Service_info *si ) +static BOOL get_LSB_data(char *fname,Service_info *si ) { pstring initdfile; char mybuffer[256]; @@ -351,184 +290,10 @@ static BOOL _svcctl_get_LSB_data(char *fname,Service_info *si ) return False; } -/**************************************************************************** - Create/Open the service control manager tdb. This code a clone of init_group_mapping. -****************************************************************************/ - -BOOL init_svcctl_db(void) -{ - const char *vstring = "INFO/version"; - uint32 vers_id; - char **svc_list; - char **svcname; - pstring keystring; - pstring external_service_list; - pstring internal_service_list; - Service_info si; - const Internal_service_description *isd_ptr; - /* svc_list = str_list_make( "etc/init.d/skeleton etc/init.d/syslog", NULL ); */ - svc_list=(char **)lp_enable_svcctl(); - - if (service_tdb) - return True; - - pstrcpy(external_service_list,""); - - service_tdb = tdb_open_log(lock_path("services.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600); - if (!service_tdb) { - DEBUG(0,("Failed to open service db\n")); - service_tdb = tdb_open_log(lock_path("services.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); - if (!service_tdb) return False; - DEBUG(0,("Created new services db\n")); - } - - if ((-1 == tdb_fetch_uint32(service_tdb, vstring,&vers_id)) || (vers_id != SERVICEDB_VERSION_V1)) { - /* wrong version of DB, or db was just created */ - tdb_traverse(service_tdb, tdb_traverse_delete_fn, NULL); - tdb_store_uint32(service_tdb, vstring, SERVICEDB_VERSION_V1); - } - tdb_unlock_bystring(service_tdb, vstring); - - DEBUG(0,("Initializing services db\n")); - - svcname = svc_list; - - /* Get the EXTERNAL services as mentioned by line in smb.conf */ - - while (*svcname) { - DEBUG(10,("Reading information on service %s\n",*svcname)); - if (_svcctl_get_LSB_data(*svcname,&si));{ - /* write the information to the TDB */ - write_si_to_service_tdb(service_tdb,*svcname,&si); - /* definitely not efficient to do it this way. */ - pstrcat(external_service_list,"\""); - pstrcat(external_service_list,*svcname); - pstrcat(external_service_list,"\" "); - } - svcname++; - } - pstrcpy(keystring,"EXTERNAL_SERVICES"); - tdb_lock_bystring(service_tdb, keystring, 0); - DEBUG(8,("Storing external service list [%s]\n",external_service_list)); - tdb_store_bystring(service_tdb,keystring,string_tdb_data(external_service_list),TDB_REPLACE); - tdb_unlock_bystring(service_tdb,keystring); - - /* Get the INTERNAL services */ - - pstrcpy(internal_service_list,""); - isd_ptr = ISD; - - while (isd_ptr && (isd_ptr->filename)) { - DEBUG(10,("Reading information on service %s\n",isd_ptr->filename)); - if (_svcctl_get_internal_service_data(isd_ptr,&si)){ - /* write the information to the TDB */ - write_si_to_service_tdb(service_tdb,(char *)isd_ptr->filename,&si); - /* definitely not efficient to do it this way. */ - pstrcat(internal_service_list,"\""); - pstrcat(internal_service_list,isd_ptr->filename); - pstrcat(internal_service_list,"\" "); - - } - isd_ptr++; - } - pstrcpy(keystring,"INTERNAL_SERVICES"); - tdb_lock_bystring(service_tdb, keystring, 0); - DEBUG(8,("Storing internal service list [%s]\n",internal_service_list)); - tdb_store_bystring(service_tdb,keystring,string_tdb_data(internal_service_list),TDB_REPLACE); - tdb_unlock_bystring(service_tdb,keystring); - - return True; -} - -/******************************************************************** -********************************************************************/ - -static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, - uint32 access_desired, uint32 *access_granted ) -{ - NTSTATUS result; - - /* maybe add privilege checks in here later */ - - se_access_check( sec_desc, token, access_desired, access_granted, &result ); - - return result; -} - -/******************************************************************** -********************************************************************/ - -static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx ) -{ - SEC_ACE ace[2]; - SEC_ACCESS mask; - size_t i = 0; - SEC_DESC *sd; - SEC_ACL *acl; - uint32 sd_size; - - /* basic access for Everyone */ - - init_sec_access(&mask, SC_MANAGER_READ_ACCESS ); - init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /* Full Access 'BUILTIN\Administrators' */ - - init_sec_access(&mask,SC_MANAGER_ALL_ACCESS ); - init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - - /* create the security descriptor */ - - if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) - return NULL; - - if ( !(sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, acl, &sd_size)) ) - return NULL; - - return sd; -} - -/******************************************************************** -********************************************************************/ - -static SEC_DESC* construct_service_sd( TALLOC_CTX *ctx ) -{ - SEC_ACE ace[4]; - SEC_ACCESS mask; - size_t i = 0; - SEC_DESC *sd; - SEC_ACL *acl; - uint32 sd_size; - - /* basic access for Everyone */ - - init_sec_access(&mask, SERVICE_READ_ACCESS ); - init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - init_sec_access(&mask,SERVICE_EXECUTE_ACCESS ); - init_sec_ace(&ace[i++], &global_sid_Builtin_Power_Users, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - init_sec_access(&mask,SERVICE_ALL_ACCESS ); - init_sec_ace(&ace[i++], &global_sid_Builtin_Server_Operators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /* create the security descriptor */ - - if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) - return NULL; - - if ( !(sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, acl, &sd_size)) ) - return NULL; - - return sd; -} - - /******************************************************************** ********************************************************************/ -static BOOL read_service_tdb_to_si(TDB_CONTEXT *stdb,char *service_name, Service_info *si) +static BOOL get_service_info(TDB_CONTEXT *stdb,char *service_name, Service_info *si) { pstring keystring; @@ -600,191 +365,73 @@ static BOOL read_service_tdb_to_si(TDB_CONTEXT *stdb,char *service_name, Service return True; } -/****************************************************************** - free() function for REGISTRY_KEY - *****************************************************************/ - -static void free_service_handle_info(void *ptr) -{ - SERVICE_INFO *info = (SERVICE_INFO*)ptr; - - SAFE_FREE(info->name); - SAFE_FREE(info); -} - -/****************************************************************** - Find a registry key handle and return a SERVICE_INFO - *****************************************************************/ +/********************************************************************* +*********************************************************************/ -static SERVICE_INFO *find_service_info_by_hnd(pipes_struct *p, POLICY_HND *hnd) +static BOOL store_service_info(TDB_CONTEXT *stdb,char *service_name, Service_info *si) { - SERVICE_INFO *service_info = NULL; + pstring keystring; - if( !find_policy_by_hnd( p, hnd, (void **)&service_info) ) { - DEBUG(2,("find_service_info_by_hnd: handle not found")); - return NULL; - } - - return service_info; -} - -/****************************************************************** - *****************************************************************/ - -static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, - const char *service, uint32 access_granted ) -{ - SERVICE_INFO *info = NULL; - - if ( !(info = SMB_MALLOC_P( SERVICE_INFO )) ) - return WERR_NOMEM; - - ZERO_STRUCTP( info ); - - /* the Service Manager has a NULL name */ - - if ( !service ) { - info->type = SVC_HANDLE_IS_SCM; - } else { - info->type = SVC_HANDLE_IS_SERVICE; - - if ( !(info->name = SMB_STRDUP( service )) ) { - free_service_handle_info( info ); - WERR_NOMEM; - } - -#if 0 - /* lookup the SERVICE_CONTROL_OPS */ - - for ( i=0; svcctl_ops[i].name; i++ ) { - ;; - } -#endif - } - - info->access_granted = access_granted; - - /* store the SERVICE_INFO and create an open handle */ - - if ( !create_policy_hnd( p, handle, free_service_handle_info, info ) ) { - free_service_handle_info( info ); - return WERR_ACCESS_DENIED; - } - - return WERR_OK; -} - -/******************************************************************** -********************************************************************/ - -WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVCCTL_R_OPEN_SCMANAGER *r_u) -{ - SEC_DESC *sec_desc; - uint32 access_granted = 0; - NTSTATUS status; - - /* perform access checks */ - - if ( !(sec_desc = construct_scm_sd( p->mem_ctx )) ) - return WERR_NOMEM; - - status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); - if ( !NT_STATUS_IS_OK(status) ) - return ntstatus_to_werror( status ); - - return create_open_service_handle( p, &r_u->handle, NULL, access_granted ); -} + /* Note -- when we write to the tdb, we "index" on the filename + field, not the nice name. when a service is "opened", it is + opened by the nice (SERVICENAME) name, not the file name. + So there needs to be a mapping from nice name back to the file name. */ -/******************************************************************** -********************************************************************/ + if ((stdb == NULL) || (si == NULL) || (service_name==NULL) || (*service_name == 0)) + return False; -WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_R_OPEN_SERVICE *r_u) -{ - SEC_DESC *sec_desc; - uint32 access_granted = 0; - NTSTATUS status; - pstring service; - rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); - - DEBUG(5, ("_svcctl_open_service: Attempting to open Service [%s], \n", service)); - - if ( !service_tdb ) { - DEBUG(1, ("_svcctl_open_service: service database is not open\n!")); - return WERR_ACCESS_DENIED; - } - - /* perform access checks */ - - if ( !(sec_desc = construct_service_sd( p->mem_ctx )) ) - return WERR_NOMEM; - - status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); - if ( !NT_STATUS_IS_OK(status) ) - return ntstatus_to_werror( status ); - -#if 0 /* FIXME!!! */ - if ( ! read_service_tdb_to_si(service_tdb,service, info) ) { - return WERR_NO_SUCH_SERVICE; -#endif - - return create_open_service_handle( p, &r_u->handle, service, access_granted ); -} + /* Store the nicename */ -/******************************************************************** -********************************************************************/ + pstr_sprintf(keystring,"SERVICE_NICENAME/%s", si->servicename); + tdb_store_bystring(stdb,keystring,string_tdb_data(service_name),TDB_REPLACE); -WERROR _svcctl_close_service(pipes_struct *p, SVCCTL_Q_CLOSE_SERVICE *q_u, SVCCTL_R_CLOSE_SERVICE *r_u) -{ - return close_policy_hnd( p, &q_u->handle ) ? WERR_OK : WERR_BADFID; -} + pstr_sprintf(keystring,"SERVICE/%s/TYPE", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->servicetype),TDB_REPLACE); -/******************************************************************** -********************************************************************/ + pstr_sprintf(keystring,"SERVICE/%s/FILENAME", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->filename),TDB_REPLACE); -WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, SVCCTL_R_GET_DISPLAY_NAME *r_u) -{ - fstring service; - fstring displayname; + pstr_sprintf(keystring,"SERVICE/%s/PROVIDES", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->provides),TDB_REPLACE); - SERVICE_INFO *service_info; - POLICY_HND *handle; + pstr_sprintf(keystring,"SERVICE/%s/SERVICENAME", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->servicename),TDB_REPLACE); - rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); + pstr_sprintf(keystring,"SERVICE/%s/DEPENDENCIES", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->dependencies),TDB_REPLACE); - handle = &(q_u->handle); + pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTART", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->shouldstart),TDB_REPLACE); - service_info = find_service_info_by_hnd(p, handle); + pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTOP", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->shouldstop),TDB_REPLACE); - if (!service_info) { - DEBUG(10, ("_svcctl_get_display_name : Can't find the service for the handle\n")); - return WERR_ACCESS_DENIED; - } + pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTART", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->requiredstart),TDB_REPLACE); - DEBUG(10,("_svcctl_get_display_name: Found service [%s]\n", service_info->name )); + pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTOP", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->requiredstop),TDB_REPLACE); - fstrcpy( displayname, "FIX ME!" ); + pstr_sprintf(keystring,"SERVICE/%s/DESCRIPTION", service_name); + tdb_store_bystring(stdb,keystring,string_tdb_data(si->description),TDB_REPLACE); - init_svcctl_r_get_display_name( r_u, displayname ); + pstr_sprintf(keystring,"SERVICE/%s/SHORTDESC", service_name); + tdb_lock_bystring(stdb, keystring, 0); + if (si->shortdescription && *si->shortdescription) + tdb_store_bystring(stdb,keystring,string_tdb_data(si->shortdescription),TDB_REPLACE); + else + tdb_store_bystring(stdb,keystring,string_tdb_data(si->description),TDB_REPLACE); - return WERR_OK; + return True; } /******************************************************************** + allocate an array of external services and return them. Null return + is okay, make sure &added is also zero! ********************************************************************/ -WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_R_QUERY_STATUS *r_u) -{ - r_u->svc_status.type = 0x0020; - r_u->svc_status.state = 0x0004; - r_u->svc_status.controls_accepted = 0x0005; - - return WERR_OK; -} - -/* allocate an array of external services and return them. Null return is okay, make sure &added is also zero! */ - -int _svcctl_num_external_services(void) +static int num_external_services(void) { int num_services; char **svc_list; @@ -823,7 +470,7 @@ int _svcctl_num_external_services(void) number of services added. svc_ptr should have enough memory allocated to accommodate all of the services that exist. - Typically _svcctl_num_external_services is used to "size" the amount of + Typically num_external_services is used to "size" the amount of memory allocated, but does little/no work. enum_external_services() actually examines each of the specified @@ -835,7 +482,7 @@ int _svcctl_num_external_services(void) read for the service information. ********************************************************************/ -WERROR enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services,int *added) +static WERROR enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services,int *added) { /* *svc_ptr must have pre-allocated memory */ int num_services = 0; @@ -895,118 +542,475 @@ WERROR enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ptr, in } #endif - if (!svc_ptr || !(*svc_ptr)) - return WERR_NOMEM; - services = *svc_ptr; - if (existing_services > 0) { - i+=existing_services; + if (!svc_ptr || !(*svc_ptr)) + return WERR_NOMEM; + services = *svc_ptr; + if (existing_services > 0) { + i+=existing_services; + } + + svcname = svc_list; + DEBUG(8,("enum_external_services: enumerating %d external services starting at index %d\n", num_services,existing_services)); + + while (*svcname) { + DEBUG(10,("enum_external_services: Reading information on service %s, index %d\n",*svcname,i)); + /* get_LSB_data(*svcname,si); */ + if (!get_service_info(service_tdb,*svcname, si)) { + DEBUG(1,("enum_external_services: CAN'T FIND INFO FOR SERVICE %s in the services DB\n",*svcname)); + } + + if ((si->filename == NULL) || (*si->filename == 0)) { + init_unistr(&services[i].servicename, *svcname ); + } else { + init_unistr( &services[i].servicename, si->filename ); + /* init_unistr( &services[i].servicename, si->servicename ); */ + } + + if ((si->provides == NULL) || (*si->provides == 0)) { + init_unistr(&services[i].displayname, *svcname ); + } else { + init_unistr( &services[i].displayname, si->provides ); + } + + /* TODO - we could keep the following info in the DB, too... */ + + DEBUG(8,("enum_external_services: Service name [%s] displayname [%s]\n", + si->filename, si->provides)); + services[i].status.type = SVCCTL_WIN32_OWN_PROC; + services[i].status.win32_exit_code = 0x0; + services[i].status.service_exit_code = 0x0; + services[i].status.check_point = 0x0; + services[i].status.wait_hint = 0x0; + + /* TODO - do callout here to get the status */ + + memset(command, 0, sizeof(command)); + slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, *svcname, "status"); + + DEBUG(10, ("enum_external_services: status command is [%s]\n", command)); + + /* TODO - wrap in privilege check */ + + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); + close(fd); + if(ret != 0) + DEBUG(10, ("enum_external_services: Command returned [%d]\n", ret)); + services[i].status.state = SVCCTL_STOPPED; + if (ret == 0) { + services[i].status.state = SVCCTL_RUNNING; + services[i].status.controls_accepted = SVCCTL_CONTROL_SHUTDOWN | SVCCTL_CONTROL_STOP; + } else { + services[i].status.state = SVCCTL_STOPPED; + services[i].status.controls_accepted = 0; + } + svcname++; + i++; + } + + DEBUG(10,("enum_external_services: Read services %d\n",num_services)); + *added = num_services; + + return WERR_OK; +} + +int num_internal_services(void) +{ + int num_services; + char **svc_list; + pstring keystring, internal_services_string; + TDB_DATA key_data; + + if (!service_tdb) { + DEBUG(8,("enum_internal_services: service database is not open!!!\n")); + num_services = 0; + } else { + pstrcpy(keystring,"INTERNAL_SERVICES"); + tdb_lock_bystring(service_tdb, keystring, 0); + key_data = tdb_fetch_bystring(service_tdb, keystring); + + if ((key_data.dptr != NULL) && (key_data.dsize != 0)) { + strncpy(internal_services_string,key_data.dptr,key_data.dsize); + internal_services_string[key_data.dsize] = 0; + DEBUG(8,("enum_internal_services: services list is %s, size is %d\n",internal_services_string,key_data.dsize)); + } + tdb_unlock_bystring(service_tdb, keystring); + } + svc_list = str_list_make(internal_services_string,NULL); + + num_services = str_list_count( (const char **)svc_list); + + return num_services; +} + +/**************************************************************************** + Create/Open the service control manager tdb. This code a clone of init_group_mapping. +****************************************************************************/ + +BOOL init_svcctl_db(void) +{ + const char *vstring = "INFO/version"; + uint32 vers_id; + char **svc_list; + char **svcname; + pstring keystring; + pstring external_service_list; + pstring internal_service_list; + Service_info si; + const Internal_service_description *isd_ptr; + /* svc_list = str_list_make( "etc/init.d/skeleton etc/init.d/syslog", NULL ); */ + svc_list=(char **)lp_enable_svcctl(); + + if (service_tdb) + return True; + + pstrcpy(external_service_list,""); + + service_tdb = tdb_open_log(lock_path("services.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600); + if (!service_tdb) { + DEBUG(0,("Failed to open service db\n")); + service_tdb = tdb_open_log(lock_path("services.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); + if (!service_tdb) return False; + DEBUG(0,("Created new services db\n")); + } + + if ((-1 == tdb_fetch_uint32(service_tdb, vstring,&vers_id)) || (vers_id != SERVICEDB_VERSION_V1)) { + /* wrong version of DB, or db was just created */ + tdb_traverse(service_tdb, tdb_traverse_delete_fn, NULL); + tdb_store_uint32(service_tdb, vstring, SERVICEDB_VERSION_V1); + } + tdb_unlock_bystring(service_tdb, vstring); + + DEBUG(0,("Initializing services db\n")); + + svcname = svc_list; + + /* Get the EXTERNAL services as mentioned by line in smb.conf */ + + while (*svcname) { + DEBUG(10,("Reading information on service %s\n",*svcname)); + if (get_LSB_data(*svcname,&si));{ + /* write the information to the TDB */ + store_service_info(service_tdb,*svcname,&si); + /* definitely not efficient to do it this way. */ + pstrcat(external_service_list,"\""); + pstrcat(external_service_list,*svcname); + pstrcat(external_service_list,"\" "); + } + svcname++; + } + pstrcpy(keystring,"EXTERNAL_SERVICES"); + tdb_lock_bystring(service_tdb, keystring, 0); + DEBUG(8,("Storing external service list [%s]\n",external_service_list)); + tdb_store_bystring(service_tdb,keystring,string_tdb_data(external_service_list),TDB_REPLACE); + tdb_unlock_bystring(service_tdb,keystring); + + /* Get the INTERNAL services */ + + pstrcpy(internal_service_list,""); + isd_ptr = ISD; + + while (isd_ptr && (isd_ptr->filename)) { + DEBUG(10,("Reading information on service %s\n",isd_ptr->filename)); + if (get_internal_service_data(isd_ptr,&si)){ + /* write the information to the TDB */ + store_service_info(service_tdb,(char *)isd_ptr->filename,&si); + /* definitely not efficient to do it this way. */ + pstrcat(internal_service_list,"\""); + pstrcat(internal_service_list,isd_ptr->filename); + pstrcat(internal_service_list,"\" "); + + } + isd_ptr++; + } + pstrcpy(keystring,"INTERNAL_SERVICES"); + tdb_lock_bystring(service_tdb, keystring, 0); + DEBUG(8,("Storing internal service list [%s]\n",internal_service_list)); + tdb_store_bystring(service_tdb,keystring,string_tdb_data(internal_service_list),TDB_REPLACE); + tdb_unlock_bystring(service_tdb,keystring); + + return True; +} + +/******************************************************************** +********************************************************************/ + +static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, + uint32 access_desired, uint32 *access_granted ) +{ + NTSTATUS result; + + /* maybe add privilege checks in here later */ + + se_access_check( sec_desc, token, access_desired, access_granted, &result ); + + return result; +} + +/******************************************************************** +********************************************************************/ + +static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx ) +{ + SEC_ACE ace[2]; + SEC_ACCESS mask; + size_t i = 0; + SEC_DESC *sd; + SEC_ACL *acl; + uint32 sd_size; + + /* basic access for Everyone */ + + init_sec_access(&mask, SC_MANAGER_READ_ACCESS ); + init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /* Full Access 'BUILTIN\Administrators' */ + + init_sec_access(&mask,SC_MANAGER_ALL_ACCESS ); + init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + + /* create the security descriptor */ + + if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) + return NULL; + + if ( !(sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, acl, &sd_size)) ) + return NULL; + + return sd; +} + +/******************************************************************** +********************************************************************/ + +static SEC_DESC* construct_service_sd( TALLOC_CTX *ctx ) +{ + SEC_ACE ace[4]; + SEC_ACCESS mask; + size_t i = 0; + SEC_DESC *sd; + SEC_ACL *acl; + uint32 sd_size; + + /* basic access for Everyone */ + + init_sec_access(&mask, SERVICE_READ_ACCESS ); + init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + init_sec_access(&mask,SERVICE_EXECUTE_ACCESS ); + init_sec_ace(&ace[i++], &global_sid_Builtin_Power_Users, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + init_sec_access(&mask,SERVICE_ALL_ACCESS ); + init_sec_ace(&ace[i++], &global_sid_Builtin_Server_Operators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /* create the security descriptor */ + + if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) + return NULL; + + if ( !(sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, acl, &sd_size)) ) + return NULL; + + return sd; +} + +/****************************************************************** + free() function for REGISTRY_KEY + *****************************************************************/ + +static void free_service_handle_info(void *ptr) +{ + SERVICE_INFO *info = (SERVICE_INFO*)ptr; + + SAFE_FREE(info->name); + SAFE_FREE(info); +} + +/****************************************************************** + Find a registry key handle and return a SERVICE_INFO + *****************************************************************/ + +static SERVICE_INFO *find_service_info_by_hnd(pipes_struct *p, POLICY_HND *hnd) +{ + SERVICE_INFO *service_info = NULL; + + if( !find_policy_by_hnd( p, hnd, (void **)&service_info) ) { + DEBUG(2,("find_service_info_by_hnd: handle not found")); + return NULL; } - svcname = svc_list; - DEBUG(8,("enum_external_services: enumerating %d external services starting at index %d\n", num_services,existing_services)); + return service_info; +} - while (*svcname) { - DEBUG(10,("enum_external_services: Reading information on service %s, index %d\n",*svcname,i)); - /* _svcctl_get_LSB_data(*svcname,si); */ - if (!read_service_tdb_to_si(service_tdb,*svcname, si)) { - DEBUG(1,("enum_external_services: CAN'T FIND INFO FOR SERVICE %s in the services DB\n",*svcname)); - } +/****************************************************************** + *****************************************************************/ + +static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, + const char *service, uint32 access_granted ) +{ + SERVICE_INFO *info = NULL; + + if ( !(info = SMB_MALLOC_P( SERVICE_INFO )) ) + return WERR_NOMEM; - if ((si->filename == NULL) || (*si->filename == 0)) { - init_unistr(&services[i].servicename, *svcname ); - } else { - init_unistr( &services[i].servicename, si->filename ); - /* init_unistr( &services[i].servicename, si->servicename ); */ + ZERO_STRUCTP( info ); + + /* the Service Manager has a NULL name */ + + if ( !service ) { + info->type = SVC_HANDLE_IS_SCM; + } else { + info->type = SVC_HANDLE_IS_SERVICE; + + if ( !(info->name = SMB_STRDUP( service )) ) { + free_service_handle_info( info ); + WERR_NOMEM; } + +#if 0 + /* lookup the SERVICE_CONTROL_OPS */ - if ((si->provides == NULL) || (*si->provides == 0)) { - init_unistr(&services[i].displayname, *svcname ); - } else { - init_unistr( &services[i].displayname, si->provides ); + for ( i=0; svcctl_ops[i].name; i++ ) { + ;; } +#endif + } - /* TODO - we could keep the following info in the DB, too... */ + info->access_granted = access_granted; + + /* store the SERVICE_INFO and create an open handle */ + + if ( !create_policy_hnd( p, handle, free_service_handle_info, info ) ) { + free_service_handle_info( info ); + return WERR_ACCESS_DENIED; + } + + return WERR_OK; +} - DEBUG(8,("enum_external_services: Service name [%s] displayname [%s]\n", - si->filename, si->provides)); - services[i].status.type = SVCCTL_WIN32_OWN_PROC; - services[i].status.win32_exit_code = 0x0; - services[i].status.service_exit_code = 0x0; - services[i].status.check_point = 0x0; - services[i].status.wait_hint = 0x0; +/******************************************************************** +********************************************************************/ - /* TODO - do callout here to get the status */ +WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVCCTL_R_OPEN_SCMANAGER *r_u) +{ + SEC_DESC *sec_desc; + uint32 access_granted = 0; + NTSTATUS status; + + /* perform access checks */ + + if ( !(sec_desc = construct_scm_sd( p->mem_ctx )) ) + return WERR_NOMEM; + + status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); + if ( !NT_STATUS_IS_OK(status) ) + return ntstatus_to_werror( status ); + + return create_open_service_handle( p, &r_u->handle, NULL, access_granted ); +} - memset(command, 0, sizeof(command)); - slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, *svcname, "status"); +/******************************************************************** +********************************************************************/ - DEBUG(10, ("enum_external_services: status command is [%s]\n", command)); +WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_R_OPEN_SERVICE *r_u) +{ + SEC_DESC *sec_desc; + uint32 access_granted = 0; + NTSTATUS status; + pstring service; + SERVICE_INFO *scm_info; - /* TODO - wrap in privilege check */ + rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); + + DEBUG(5, ("_svcctl_open_service: Attempting to open Service [%s], \n", service)); - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - close(fd); - if(ret != 0) - DEBUG(10, ("enum_external_services: Command returned [%d]\n", ret)); - services[i].status.state = SVCCTL_STOPPED; - if (ret == 0) { - services[i].status.state = SVCCTL_RUNNING; - services[i].status.controls_accepted = SVCCTL_CONTROL_SHUTDOWN | SVCCTL_CONTROL_STOP; - } else { - services[i].status.state = SVCCTL_STOPPED; - services[i].status.controls_accepted = 0; - } - svcname++; - i++; - } + + /* based on my tests you can open a service if you have a valid scm handle */ + + if ( !(scm_info = find_service_info_by_hnd( p, &q_u->handle )) ) + return WERR_BADFID; + + /* perform access checks */ + + if ( !(sec_desc = construct_service_sd( p->mem_ctx )) ) + return WERR_NOMEM; + + status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); + if ( !NT_STATUS_IS_OK(status) ) + return ntstatus_to_werror( status ); + +#if 0 /* FIXME!!! */ + if ( ! get_service_info(service_tdb, service, info) ) { + return WERR_NO_SUCH_SERVICE; +#endif + + return create_open_service_handle( p, &r_u->handle, service, access_granted ); +} - DEBUG(10,("enum_external_services: Read services %d\n",num_services)); - *added = num_services; +/******************************************************************** +********************************************************************/ - return WERR_OK; +WERROR _svcctl_close_service(pipes_struct *p, SVCCTL_Q_CLOSE_SERVICE *q_u, SVCCTL_R_CLOSE_SERVICE *r_u) +{ + return close_policy_hnd( p, &q_u->handle ) ? WERR_OK : WERR_BADFID; } -int _svcctl_num_internal_services(void) +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, SVCCTL_R_GET_DISPLAY_NAME *r_u) { - int num_services; - char **svc_list; - pstring keystring, internal_services_string; - TDB_DATA key_data; + fstring service; + fstring displayname; + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + + /* can only use an SCM handle here */ + + if ( !info || (info->type != SVC_HANDLE_IS_SCM) ) + return WERR_BADFID; + + rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); - if (!service_tdb) { - DEBUG(8,("_svcctl_enum_internal_services: service database is not open!!!\n")); - num_services = 0; - } else { - pstrcpy(keystring,"INTERNAL_SERVICES"); - tdb_lock_bystring(service_tdb, keystring, 0); - key_data = tdb_fetch_bystring(service_tdb, keystring); + /* need a tdb lookup here or something */ + + fstrcpy( displayname, "FIX ME!" ); - if ((key_data.dptr != NULL) && (key_data.dsize != 0)) { - strncpy(internal_services_string,key_data.dptr,key_data.dsize); - internal_services_string[key_data.dsize] = 0; - DEBUG(8,("_svcctl_enum_internal_services: services list is %s, size is %d\n",internal_services_string,key_data.dsize)); - } - tdb_unlock_bystring(service_tdb, keystring); - } - svc_list = str_list_make(internal_services_string,NULL); - - num_services = str_list_count( (const char **)svc_list); + init_svcctl_r_get_display_name( r_u, displayname ); - return num_services; + return WERR_OK; } -#if 0 +/******************************************************************** +********************************************************************/ -int _svcctl_num_internal_services(void) +WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_R_QUERY_STATUS *r_u) { - return 2; + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + + /* perform access checks */ + + if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) + return WERR_BADFID; + + if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_STATUS) ) + return WERR_ACCESS_DENIED; + + r_u->svc_status.type = 0x0020; + r_u->svc_status.state = 0x0004; + r_u->svc_status.controls_accepted = 0x0005; + + return WERR_OK; } -#endif -/* TODO - for internal services, do similar to external services, except we have to call the right status routine... */ -WERROR _svcctl_enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services, int *added) +/********************************************************************* + TODO - for internal services, do similar to external services, except + we have to call the right status routine... +**********************************************************************/ + +static WERROR enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services, int *added) { int num_services = 2; int i = 0; @@ -1020,7 +1024,7 @@ WERROR _svcctl_enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc #if 0 /* *svc_ptr has the pointer to the array if there is one already. NULL if not. */ if ((existing_services>0) && svc_ptr && *svc_ptr) { /* reallocate vs. allocate */ - DEBUG(8,("_svcctl_enum_internal_services: REALLOCing %d services\n", num_services)); + DEBUG(8,("enum_internal_services: REALLOCing %d services\n", num_services)); services = TALLOC_REALLOC_ARRAY(tcx,*svc_ptr,ENUM_SERVICES_STATUS,existing_services+num_services); if (!rsvcs) return WERR_NOMEM; @@ -1034,7 +1038,7 @@ WERROR _svcctl_enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc if (existing_services > 0) { i += existing_services; } - DEBUG(8,("_svcctl_enum_internal_services: Creating %d services, starting index %d\n", num_services,existing_services)); + DEBUG(8,("enum_internal_services: Creating %d services, starting index %d\n", num_services,existing_services)); init_unistr( &services[i].servicename, "Spooler" ); init_unistr( &services[i].displayname, "Print Spooler" ); @@ -1071,29 +1075,27 @@ WERROR _svcctl_enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc return WERR_OK; } -WERROR _init_svcdb(void) -{ - if (svcdb) { - talloc_destroy(svcdb); - } - svcdb = talloc_init("services DB"); - - return WERR_OK; -} - /******************************************************************** ********************************************************************/ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, SVCCTL_R_ENUM_SERVICES_STATUS *r_u) { ENUM_SERVICES_STATUS *services = NULL; - uint32 num_int_services = 0; uint32 num_ext_services = 0; int i = 0; size_t buffer_size; WERROR result = WERR_OK; - WERROR ext_result = WERR_OK; + WERROR ext_result = WERR_OK; + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + + /* perform access checks */ + + if ( !info || (info->type != SVC_HANDLE_IS_SCM) ) + return WERR_BADFID; + + if ( !(info->access_granted & SC_RIGHT_MGR_ENUMERATE_SERVICE) ) + return WERR_ACCESS_DENIED; /* num_services = str_list_count( lp_enable_svcctl() ); */ @@ -1103,14 +1105,14 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT num_int_services = 0; - num_int_services = _svcctl_num_internal_services(); + num_int_services = num_internal_services(); - num_ext_services = _svcctl_num_external_services(); + num_ext_services = num_external_services(); if ( !(services = TALLOC_ARRAY(p->mem_ctx, ENUM_SERVICES_STATUS, num_int_services+num_ext_services )) ) return WERR_NOMEM; - result = _svcctl_enum_internal_services(p->mem_ctx, &services, 0, &num_int_services); + result = enum_internal_services(p->mem_ctx, &services, 0, &num_int_services); if (W_ERROR_IS_OK(result)) { DEBUG(8,("_svcctl_enum_services_status: Got %d internal services\n", num_int_services)); @@ -1163,7 +1165,17 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCTL_R_START_SERVICE *r_u) { - return WERR_ACCESS_DENIED; + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + + /* perform access checks */ + + if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) + return WERR_BADFID; + + if ( !(info->access_granted & SC_RIGHT_SVC_START) ) + return WERR_ACCESS_DENIED; + + return WERR_OK; } /******************************************************************** @@ -1171,6 +1183,20 @@ WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCT WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, SVCCTL_R_CONTROL_SERVICE *r_u) { + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + + /* perform access checks */ + /* we only support stop so don't get complicated */ + + if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) + return WERR_BADFID; + + if ( q_u->control != SVCCTL_CONTROL_STOP ) + return WERR_ACCESS_DENIED; + + if ( !(info->access_granted & SC_RIGHT_SVC_STOP) ) + return WERR_ACCESS_DENIED; + #if 0 SERVICE_INFO *service_info; POLICY_HND *handle; @@ -1244,7 +1270,16 @@ WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, S WERROR _svcctl_enum_dependent_services( pipes_struct *p, SVCCTL_Q_ENUM_DEPENDENT_SERVICES *q_u, SVCCTL_R_ENUM_DEPENDENT_SERVICES *r_u ) { + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + + /* perform access checks */ + + if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) + return WERR_BADFID; + if ( !(info->access_granted & SC_RIGHT_SVC_ENUMERATE_DEPENDENTS) ) + return WERR_ACCESS_DENIED; + /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ @@ -1267,6 +1302,15 @@ WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_ POLICY_HND *handle; SERVICE_INFO *service_info; pstring command; + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + + /* perform access checks */ + + if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) + return WERR_BADFID; + + if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_STATUS) ) + return WERR_ACCESS_DENIED; /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ @@ -1343,6 +1387,15 @@ WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CON POLICY_HND *handle; SERVICE_INFO *service_info; uint32 needed_size; + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + + /* perform access checks */ + + if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) + return WERR_BADFID; + + if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_CONFIG) ) + return WERR_ACCESS_DENIED; /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ @@ -1442,6 +1495,15 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO POLICY_HND *handle; SERVICE_INFO *service_info; uint32 level; + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + + /* perform access checks */ + + if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) + return WERR_BADFID; + + if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_CONFIG) ) + return WERR_ACCESS_DENIED; /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ -- cgit From 2851e43e4881485b0af418975eca8f01ab27ca3b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 15 Jun 2005 00:54:43 +0000 Subject: r7595: start trying to split out the svcctl functions into separate files for better maintenance; add SERVICE_CONTROL_OPS for spoolss service (This used to be commit 2b0ea30a1a3aebaabd5d328de50e6ad2ef18d45d) --- source3/rpc_server/srv_svcctl_nt.c | 705 +------------------------------------ 1 file changed, 13 insertions(+), 692 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 3367768f81..e9f60e887c 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -37,700 +37,20 @@ #define SVCCTL_SCRIPT_DIR "/svcctl/" -/* - * sertup the \PIPE\svcctl db API - */ - -#define SCVCTL_DATABASE_VERSION_V1 1 -static TDB_CONTEXT *service_tdb; /* used for services tdb file */ - -/* there are two types of services -- internal, and external. - Internal services are "built-in" to samba -- there may be - functions that exist to provide the control and enumeration - functions. There certainly is information returned to be - displayed in the typical management console. - - External services are those that can be specified in the smb.conf - file -- and they conform to the LSB specification as to having - particular keywords in the scripts. Note that these "scripts" are - located in the lib directory, and are likely links to LSB-compliant - init.d scripts, such as those that might come with Suse. Note - that the spec is located http://www.linuxbase.org/spec/ */ - - -/* Expand this to include what can and can't be done - with a particular internal service. Expand as necessary - to add other infromation like what can be controlled, - etc. */ - -typedef struct Internal_service_struct -{ - const char *filename; /* internal name "index" */ - const char *displayname; - const char *description; - const uint32 statustype; - void *status_fn; - void *control_fn; -} Internal_service_description; - - -static const Internal_service_description ISD[] = { - { "NETLOGON", "Net Logon", "Provides logon and authentication service to the network", 0x110, NULL, NULL}, - { "Spooler", "Spooler", "Printing Services", 0x0020, NULL, NULL}, - { NULL, NULL, NULL, 0, NULL, NULL} +struct service_control_op_table { + const char *name; + SERVICE_CONTROL_OPS *ops; }; +extern SERVICE_CONTROL_OPS spoolss_svc_ops; -/******************************************************************** - TODOs - (a) get and set security descriptors on services - (b) read and write QUERY_SERVICE_CONFIG structures (both kinds, country and western) - (c) create default secdesc objects for services and SCM - (d) check access control masks with se_access_check() -********************************************************************/ - -#if 0 -/********************************************************************* - given a service nice name, find the underlying service name -*********************************************************************/ - -static BOOL convert_service_displayname(TDB_CONTEXT *stdb,pstring service_nicename, pstring servicename,int szsvcname) -{ - pstring keystring; - TDB_DATA key_data; - - if ((stdb == NULL) || (service_nicename==NULL) || (servicename == NULL)) - return False; - - pstr_sprintf(keystring,"SERVICE_NICENAME/%s", servicename); - - DEBUG(5, ("convert_service_displayname: Looking for service name [%s], key [%s]\n", - service_nicename, keystring)); - - key_data = tdb_fetch_bystring(stdb,keystring); - - if (key_data.dsize == 0) { - DEBUG(5, ("convert_service_displayname: [%s] Not found, tried key [%s]\n",service_nicename,keystring)); - return False; - } - - strncpy(servicename,key_data.dptr,szsvcname); - servicename[(key_data.dsize > szsvcname ? szsvcname : key_data.dsize)] = 0; - DEBUG(5, ("convert_service_displayname: Found service name [%s], name is [%s]\n", - service_nicename,servicename)); - - return True; -} -#endif - -/******************************************************************************* - Get the INTERNAL services information for the given service name. -*******************************************************************************/ - -static BOOL get_internal_service_data(const Internal_service_description *isd, Service_info *si) -{ - ZERO_STRUCTP( si ); -#if 0 - - pstrcpy( si->servicename, isd->displayname); - pstrcpy( si->servicetype, "INTERNAL"); - pstrcpy( si->filename, isd->filename); - pstrcpy( si->provides, isd->displayname); - pstrcpy( si->description, isd->description); - pstrcpy( si->shortdescription, isd->description); -#endif - - return True; -} - - -/******************************************************************************* - Get the services information by reading and parsing the shell scripts. These - are symbolically linked into the SVCCTL_SCRIPT_DIR directory. - - Get the names of the services/scripts to read from the smb.conf file. -*******************************************************************************/ - -static BOOL get_LSB_data(char *fname,Service_info *si ) -{ - pstring initdfile; - char mybuffer[256]; - const char *tokenptr; - char **qlines; - int fd = -1; - int nlines, *numlines,i,in_section,in_description; - - pstrcpy(si->servicename,""); - pstrcpy(si->servicetype,"EXTERNAL"); - pstrcpy(si->filename,fname); - pstrcpy(si->provides,""); - pstrcpy(si->dependencies,""); - pstrcpy(si->shouldstart,""); - pstrcpy(si->shouldstop,""); - pstrcpy(si->requiredstart,""); - pstrcpy(si->requiredstop,""); - pstrcpy(si->description,""); - pstrcpy(si->shortdescription,""); - - numlines = &nlines; - in_section = 0; - in_description = 0; - - - if( !fname || !*fname ) { - DEBUG(0, ("Must define an \"LSB-style init file\" to read.\n")); - return False; - } - pstrcpy(initdfile,dyn_LIBDIR); - pstrcat(initdfile,SVCCTL_SCRIPT_DIR); - pstrcat(initdfile,fname); - - /* TODO - should check to see if the file that we're trying to open is - actually a script. If it's NOT, we should do something like warn, - and not continue to try to find info we're looking for */ - - DEBUG(10, ("Opening [%s]\n", initdfile)); - fd = -1; - fd = open(initdfile,O_RDONLY); - *numlines = 0; - - if (fd == -1) { - DEBUG(10, ("Couldn't open [%s]\n", initdfile)); - return False; - } - - qlines = fd_lines_load(fd, numlines); - DEBUGADD(10, ("Lines returned = [%d]\n", *numlines)); - close(fd); - - - if (*numlines) { - - for(i = 0; i < *numlines; i++) { - - DEBUGADD(10, ("Line[%d] = %s\n", i, qlines[i])); - if (!in_section && (0==strwicmp("### BEGIN INIT INFO", qlines[i]))) { - /* we now can look for params */ - DEBUGADD(10, ("Configuration information starts on line = [%d]\n", i)); - in_section = 1; - - } else if (in_section && (0==strwicmp("### END INIT INFO", qlines[i]))) { - DEBUGADD(10, ("Configuration information ends on line = [%d]\n", i)); - DEBUGADD(10, ("Description is [%s]\n", si->description)); - in_description = 0; - in_section = 0; - break; - } else if (in_section) { - tokenptr = qlines[i]; - if (in_description) { - DEBUGADD(10, ("Processing DESCRIPTION [%d]\n", *tokenptr)); - if (tokenptr && (*tokenptr=='#') && (*(tokenptr+1)=='\t')) { - DEBUGADD(10, ("Adding to DESCRIPTION [%d]\n", *tokenptr)); - pstrcat(si->description," "); - pstrcat(si->description,tokenptr+2); - continue; - } - in_description = 0; - DEBUGADD(10, ("Not a description!\n")); - } - if (!next_token(&tokenptr,mybuffer," \t",sizeof(mybuffer))) { - DEBUGADD(10, ("Invalid line [%d]\n", i)); - break; /* bad line? */ - } - if (0 != strncmp(mybuffer,"#",1)) { - DEBUGADD(10, ("Invalid line [%d], is %s\n", i,mybuffer)); - break; - } - if (!next_token(&tokenptr,mybuffer," \t",sizeof(mybuffer))) { - DEBUGADD(10, ("Invalid token on line [%d]\n", i)); - break; /* bad line? */ - } - DEBUGADD(10, ("Keyword is [%s]\n", mybuffer)); - if (0==strwicmp(mybuffer,"Description:")) { - while (tokenptr && *tokenptr && (strchr(" \t",*tokenptr))) { - tokenptr++; - } - pstrcpy(si->description,tokenptr); - DEBUGADD(10, ("FOUND DESCRIPTION! Data is [%s]\n", tokenptr)); - in_description = 1; - } else { - while (tokenptr && *tokenptr && (strchr(" \t",*tokenptr))) { - tokenptr++; - } - DEBUGADD(10, ("Data is [%s]\n", tokenptr)); - in_description = 0; - - /* save certain keywords, don't save others */ - if (0==strwicmp(mybuffer, "Provides:")) { - pstrcpy(si->provides,tokenptr); - pstrcpy(si->servicename,tokenptr); - } - - if (0==strwicmp(mybuffer, "Short-Description:")) { - pstrcpy(si->shortdescription,tokenptr); - } - - if (0==strwicmp(mybuffer, "Required-start:")) { - pstrcpy(si->requiredstart,tokenptr); - pstrcpy(si->dependencies,tokenptr); - } - - if (0==strwicmp(mybuffer, "Should-start:")) { - pstrcpy(si->shouldstart,tokenptr); - } - } - } - } - - file_lines_free(qlines); - return True; - } - - return False; -} - -/******************************************************************** -********************************************************************/ - -static BOOL get_service_info(TDB_CONTEXT *stdb,char *service_name, Service_info *si) -{ - - pstring keystring; - TDB_DATA key_data; - - if ((stdb == NULL) || (si == NULL) || (service_name==NULL) || (*service_name == 0)) - return False; - - /* TODO - error handling -- what if the service isn't in the DB? */ - - pstr_sprintf(keystring,"SERVICE/%s/TYPE", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->servicetype,key_data.dptr,key_data.dsize); - si->servicetype[key_data.dsize] = 0; - - /* crude check to see if the service exists... */ - DEBUG(3,("Size of the TYPE field is %d\n",key_data.dsize)); - if (key_data.dsize == 0) - return False; - - pstr_sprintf(keystring,"SERVICE/%s/FILENAME", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->filename,key_data.dptr,key_data.dsize); - si->filename[key_data.dsize] = 0; - - pstr_sprintf(keystring,"SERVICE/%s/PROVIDES", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->provides,key_data.dptr,key_data.dsize); - si->provides[key_data.dsize] = 0; - strncpy(si->servicename,key_data.dptr,key_data.dsize); - si->servicename[key_data.dsize] = 0; - - - pstr_sprintf(keystring,"SERVICE/%s/DEPENDENCIES", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->dependencies,key_data.dptr,key_data.dsize); - si->dependencies[key_data.dsize] = 0; - - pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTART", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->shouldstart,key_data.dptr,key_data.dsize); - si->shouldstart[key_data.dsize] = 0; - - pstr_sprintf(keystring,"SERVICE/%s/SHOULD_STOP", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->shouldstop,key_data.dptr,key_data.dsize); - si->shouldstop[key_data.dsize] = 0; - - pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTART", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->requiredstart,key_data.dptr,key_data.dsize); - si->requiredstart[key_data.dsize] = 0; - - pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTOP", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->requiredstop,key_data.dptr,key_data.dsize); - si->requiredstop[key_data.dsize] = 0; - - pstr_sprintf(keystring,"SERVICE/%s/DESCRIPTION", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->description,key_data.dptr,key_data.dsize); - si->description[key_data.dsize] = 0; - - pstr_sprintf(keystring,"SERVICE/%s/SHORTDESC", service_name); - key_data = tdb_fetch_bystring(stdb,keystring); - strncpy(si->shortdescription,key_data.dptr,key_data.dsize); - si->shortdescription[key_data.dsize] = 0; - - return True; -} - -/********************************************************************* -*********************************************************************/ - -static BOOL store_service_info(TDB_CONTEXT *stdb,char *service_name, Service_info *si) -{ - pstring keystring; - - /* Note -- when we write to the tdb, we "index" on the filename - field, not the nice name. when a service is "opened", it is - opened by the nice (SERVICENAME) name, not the file name. - So there needs to be a mapping from nice name back to the file name. */ - - if ((stdb == NULL) || (si == NULL) || (service_name==NULL) || (*service_name == 0)) - return False; - - - /* Store the nicename */ - - pstr_sprintf(keystring,"SERVICE_NICENAME/%s", si->servicename); - tdb_store_bystring(stdb,keystring,string_tdb_data(service_name),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/TYPE", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->servicetype),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/FILENAME", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->filename),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/PROVIDES", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->provides),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/SERVICENAME", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->servicename),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/DEPENDENCIES", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->dependencies),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTART", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->shouldstart),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/SHOULDSTOP", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->shouldstop),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTART", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->requiredstart),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/REQUIREDSTOP", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->requiredstop),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/DESCRIPTION", service_name); - tdb_store_bystring(stdb,keystring,string_tdb_data(si->description),TDB_REPLACE); - - pstr_sprintf(keystring,"SERVICE/%s/SHORTDESC", service_name); - tdb_lock_bystring(stdb, keystring, 0); - if (si->shortdescription && *si->shortdescription) - tdb_store_bystring(stdb,keystring,string_tdb_data(si->shortdescription),TDB_REPLACE); - else - tdb_store_bystring(stdb,keystring,string_tdb_data(si->description),TDB_REPLACE); - - return True; -} - -/******************************************************************** - allocate an array of external services and return them. Null return - is okay, make sure &added is also zero! -********************************************************************/ - -static int num_external_services(void) -{ - int num_services; - char **svc_list; - pstring keystring, external_services_string; - TDB_DATA key_data; - - - if (!service_tdb) { - DEBUG(8,("enum_external_services: service database is not open!!!\n")); - num_services = 0; - } else { - pstrcpy(keystring,"EXTERNAL_SERVICES"); - tdb_lock_bystring(service_tdb, keystring, 0); - key_data = tdb_fetch_bystring(service_tdb, keystring); - - if ((key_data.dptr != NULL) && (key_data.dsize != 0)) { - strncpy(external_services_string,key_data.dptr,key_data.dsize); - external_services_string[key_data.dsize] = 0; - DEBUG(8,("enum_external_services: services list is %s, size is %d\n",external_services_string,key_data.dsize)); - } - tdb_unlock_bystring(service_tdb, keystring); - } - svc_list = str_list_make(external_services_string,NULL); - - num_services = str_list_count( (const char **)svc_list); - - return num_services; -} - - - -/******************************************************************** - Gather information on the "external services". These are services - listed in the smb.conf file, and found to exist through checks in - this code. Note that added will be incremented on the basis of the - number of services added. svc_ptr should have enough memory allocated - to accommodate all of the services that exist. - - Typically num_external_services is used to "size" the amount of - memory allocated, but does little/no work. - - enum_external_services() actually examines each of the specified - external services, populates the memory structures, and returns. - - ** note that 'added' may end up with less than the number of services - found in _num_external_services, such as the case when a service is - called out, but the actual service doesn't exist or the file can't be - read for the service information. -********************************************************************/ - -static WERROR enum_external_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services,int *added) -{ - /* *svc_ptr must have pre-allocated memory */ - int num_services = 0; - int i = 0; - ENUM_SERVICES_STATUS *services=NULL; - char **svc_list,**svcname; - pstring command, keystring, external_services_string; - int ret; - int fd = -1; - Service_info *si; - TDB_DATA key_data; - - *added = num_services; - - if (!service_tdb) { - DEBUG(8,("enum_external_services: service database is not open!!!\n")); - } else { - pstrcpy(keystring,"EXTERNAL_SERVICES"); - tdb_lock_bystring(service_tdb, keystring, 0); - key_data = tdb_fetch_bystring(service_tdb, keystring); - if ((key_data.dptr != NULL) && (key_data.dsize != 0)) { - strncpy(external_services_string,key_data.dptr,key_data.dsize); - external_services_string[key_data.dsize] = 0; - DEBUG(8,("enum_external_services: services list is %s, size is %d\n",external_services_string,key_data.dsize)); - } - tdb_unlock_bystring(service_tdb, keystring); - } - svc_list = str_list_make(external_services_string,NULL); - - num_services = str_list_count( (const char **)svc_list); - - if (0 == num_services) { - DEBUG(8,("enum_external_services: there are no external services\n")); - *added = num_services; - return WERR_OK; - } - DEBUG(8,("enum_external_services: there are [%d] external services\n",num_services)); - si=TALLOC_ARRAY( tcx, Service_info, 1 ); - if (si == NULL) { - DEBUG(8,("enum_external_services: Failed to alloc si\n")); - return WERR_NOMEM; - } - -#if 0 -/* *svc_ptr has the pointer to the array if there is one already. NULL if not. */ - if ((existing_services>0) && svc_ptr && *svc_ptr) { /* reallocate vs. allocate */ - DEBUG(8,("enum_external_services: REALLOCing %x to %d services\n", *svc_ptr, existing_services+num_services)); - - services=TALLOC_REALLOC_ARRAY(tcx,*svc_ptr,ENUM_SERVICES_STATUS,existing_services+num_services); - DEBUG(8,("enum_external_services: REALLOCed to %x services\n", services)); - - if (!services) return WERR_NOMEM; - *svc_ptr = services; - } else { - if ( !(services = TALLOC_ARRAY( tcx, ENUM_SERVICES_STATUS, num_services )) ) - return WERR_NOMEM; - } -#endif - - if (!svc_ptr || !(*svc_ptr)) - return WERR_NOMEM; - services = *svc_ptr; - if (existing_services > 0) { - i+=existing_services; - } - - svcname = svc_list; - DEBUG(8,("enum_external_services: enumerating %d external services starting at index %d\n", num_services,existing_services)); - - while (*svcname) { - DEBUG(10,("enum_external_services: Reading information on service %s, index %d\n",*svcname,i)); - /* get_LSB_data(*svcname,si); */ - if (!get_service_info(service_tdb,*svcname, si)) { - DEBUG(1,("enum_external_services: CAN'T FIND INFO FOR SERVICE %s in the services DB\n",*svcname)); - } - - if ((si->filename == NULL) || (*si->filename == 0)) { - init_unistr(&services[i].servicename, *svcname ); - } else { - init_unistr( &services[i].servicename, si->filename ); - /* init_unistr( &services[i].servicename, si->servicename ); */ - } - - if ((si->provides == NULL) || (*si->provides == 0)) { - init_unistr(&services[i].displayname, *svcname ); - } else { - init_unistr( &services[i].displayname, si->provides ); - } - - /* TODO - we could keep the following info in the DB, too... */ - - DEBUG(8,("enum_external_services: Service name [%s] displayname [%s]\n", - si->filename, si->provides)); - services[i].status.type = SVCCTL_WIN32_OWN_PROC; - services[i].status.win32_exit_code = 0x0; - services[i].status.service_exit_code = 0x0; - services[i].status.check_point = 0x0; - services[i].status.wait_hint = 0x0; - - /* TODO - do callout here to get the status */ - - memset(command, 0, sizeof(command)); - slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, *svcname, "status"); - - DEBUG(10, ("enum_external_services: status command is [%s]\n", command)); - - /* TODO - wrap in privilege check */ - - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - close(fd); - if(ret != 0) - DEBUG(10, ("enum_external_services: Command returned [%d]\n", ret)); - services[i].status.state = SVCCTL_STOPPED; - if (ret == 0) { - services[i].status.state = SVCCTL_RUNNING; - services[i].status.controls_accepted = SVCCTL_CONTROL_SHUTDOWN | SVCCTL_CONTROL_STOP; - } else { - services[i].status.state = SVCCTL_STOPPED; - services[i].status.controls_accepted = 0; - } - svcname++; - i++; - } - - DEBUG(10,("enum_external_services: Read services %d\n",num_services)); - *added = num_services; - - return WERR_OK; -} - -int num_internal_services(void) -{ - int num_services; - char **svc_list; - pstring keystring, internal_services_string; - TDB_DATA key_data; - - if (!service_tdb) { - DEBUG(8,("enum_internal_services: service database is not open!!!\n")); - num_services = 0; - } else { - pstrcpy(keystring,"INTERNAL_SERVICES"); - tdb_lock_bystring(service_tdb, keystring, 0); - key_data = tdb_fetch_bystring(service_tdb, keystring); - - if ((key_data.dptr != NULL) && (key_data.dsize != 0)) { - strncpy(internal_services_string,key_data.dptr,key_data.dsize); - internal_services_string[key_data.dsize] = 0; - DEBUG(8,("enum_internal_services: services list is %s, size is %d\n",internal_services_string,key_data.dsize)); - } - tdb_unlock_bystring(service_tdb, keystring); - } - svc_list = str_list_make(internal_services_string,NULL); - - num_services = str_list_count( (const char **)svc_list); - - return num_services; -} - -/**************************************************************************** - Create/Open the service control manager tdb. This code a clone of init_group_mapping. -****************************************************************************/ - -BOOL init_svcctl_db(void) -{ - const char *vstring = "INFO/version"; - uint32 vers_id; - char **svc_list; - char **svcname; - pstring keystring; - pstring external_service_list; - pstring internal_service_list; - Service_info si; - const Internal_service_description *isd_ptr; - /* svc_list = str_list_make( "etc/init.d/skeleton etc/init.d/syslog", NULL ); */ - svc_list=(char **)lp_enable_svcctl(); - - if (service_tdb) - return True; - - pstrcpy(external_service_list,""); - - service_tdb = tdb_open_log(lock_path("services.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600); - if (!service_tdb) { - DEBUG(0,("Failed to open service db\n")); - service_tdb = tdb_open_log(lock_path("services.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); - if (!service_tdb) return False; - DEBUG(0,("Created new services db\n")); - } - - if ((-1 == tdb_fetch_uint32(service_tdb, vstring,&vers_id)) || (vers_id != SERVICEDB_VERSION_V1)) { - /* wrong version of DB, or db was just created */ - tdb_traverse(service_tdb, tdb_traverse_delete_fn, NULL); - tdb_store_uint32(service_tdb, vstring, SERVICEDB_VERSION_V1); - } - tdb_unlock_bystring(service_tdb, vstring); - - DEBUG(0,("Initializing services db\n")); - - svcname = svc_list; - - /* Get the EXTERNAL services as mentioned by line in smb.conf */ - - while (*svcname) { - DEBUG(10,("Reading information on service %s\n",*svcname)); - if (get_LSB_data(*svcname,&si));{ - /* write the information to the TDB */ - store_service_info(service_tdb,*svcname,&si); - /* definitely not efficient to do it this way. */ - pstrcat(external_service_list,"\""); - pstrcat(external_service_list,*svcname); - pstrcat(external_service_list,"\" "); - } - svcname++; - } - pstrcpy(keystring,"EXTERNAL_SERVICES"); - tdb_lock_bystring(service_tdb, keystring, 0); - DEBUG(8,("Storing external service list [%s]\n",external_service_list)); - tdb_store_bystring(service_tdb,keystring,string_tdb_data(external_service_list),TDB_REPLACE); - tdb_unlock_bystring(service_tdb,keystring); - - /* Get the INTERNAL services */ - - pstrcpy(internal_service_list,""); - isd_ptr = ISD; - - while (isd_ptr && (isd_ptr->filename)) { - DEBUG(10,("Reading information on service %s\n",isd_ptr->filename)); - if (get_internal_service_data(isd_ptr,&si)){ - /* write the information to the TDB */ - store_service_info(service_tdb,(char *)isd_ptr->filename,&si); - /* definitely not efficient to do it this way. */ - pstrcat(internal_service_list,"\""); - pstrcat(internal_service_list,isd_ptr->filename); - pstrcat(internal_service_list,"\" "); - - } - isd_ptr++; - } - pstrcpy(keystring,"INTERNAL_SERVICES"); - tdb_lock_bystring(service_tdb, keystring, 0); - DEBUG(8,("Storing internal service list [%s]\n",internal_service_list)); - tdb_store_bystring(service_tdb,keystring,string_tdb_data(internal_service_list),TDB_REPLACE); - tdb_unlock_bystring(service_tdb,keystring); +struct service_control_op_table svcctl_ops[] = { + { "Spooler", &spoolss_svc_ops }, + { "NETLOGON", NULL }, + { NULL, NULL } +}; - return True; -} /******************************************************************** ********************************************************************/ @@ -862,6 +182,8 @@ static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, if ( !service ) { info->type = SVC_HANDLE_IS_SCM; } else { + int i; + info->type = SVC_HANDLE_IS_SERVICE; if ( !(info->name = SMB_STRDUP( service )) ) { @@ -869,13 +191,12 @@ static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, WERR_NOMEM; } -#if 0 /* lookup the SERVICE_CONTROL_OPS */ for ( i=0; svcctl_ops[i].name; i++ ) { - ;; + if ( strequal( svcctl_ops[i].name, service ) ) + info->ops = svcctl_ops[i].ops; } -#endif } info->access_granted = access_granted; -- cgit From 899bc3a07df4ce1f77efc1abce7c3a2e855069e5 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 15 Jun 2005 03:10:36 +0000 Subject: r7603: * fix a bug in the SERVICE_ALL_ACCESS security mask * add calls to start and stop a service (to be filled in by the backend routines in services/svc_*.c (This used to be commit 793d28a946d83beb2576c5c8ce808d32c71c880a) --- source3/rpc_server/srv_svcctl_nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index e9f60e887c..c557036800 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -496,6 +496,8 @@ WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCT if ( !(info->access_granted & SC_RIGHT_SVC_START) ) return WERR_ACCESS_DENIED; + return info->ops->start_service(); + return WERR_OK; } @@ -518,6 +520,8 @@ WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, S if ( !(info->access_granted & SC_RIGHT_SVC_STOP) ) return WERR_ACCESS_DENIED; + return info->ops->stop_service( &r_u->svc_status ); + #if 0 SERVICE_INFO *service_info; POLICY_HND *handle; @@ -582,8 +586,6 @@ WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, S DEBUG(10, ("_svcctl_query_service_config: Should call the commFound service [%s], [%s]\n",service_info->servicename,service_info->filename)); #endif - - return WERR_OK; } /******************************************************************** -- cgit From 3f657f41cc7a71b3d5b769b31be030ebf543a645 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 15 Jun 2005 12:43:36 +0000 Subject: r7606: add WERR_NET_NAME_NOT_FOUND. This is what windows returns when trying to manipulate non-existing shares. Guenther (This used to be commit 2e5cb531ab8a8babbc425b22d17a39c18f602d4f) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 0e699d922b..91f0cefa98 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1536,7 +1536,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S /* Does this share exist ? */ if (snum < 0) - return WERR_INVALID_NAME; + return WERR_NET_NAME_NOT_FOUND; /* No change to printer shares. */ if (lp_print_ok(snum)) -- cgit From 5b678f7a8469e345a6b25fa19ea1a20fce939a21 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 15 Jun 2005 15:18:18 +0000 Subject: r7610: can successfully stop and start the 'spooler' service by setting the state for the 'disable spoolss' parameter in memory for an individual smbd (This used to be commit f19c10d0c3e7701066b765c712df0636e914bf7e) --- source3/rpc_server/srv_svcctl_nt.c | 74 ++++---------------------------------- 1 file changed, 7 insertions(+), 67 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index c557036800..230a222b8d 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -318,6 +318,13 @@ WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_ if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_STATUS) ) return WERR_ACCESS_DENIED; + /* try the service specific status call */ + + if ( info->ops ) + return info->ops->service_status( &r_u->svc_status ); + + /* default action for now */ + r_u->svc_status.type = 0x0020; r_u->svc_status.state = 0x0004; r_u->svc_status.controls_accepted = 0x0005; @@ -497,8 +504,6 @@ WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCT return WERR_ACCESS_DENIED; return info->ops->start_service(); - - return WERR_OK; } /******************************************************************** @@ -521,71 +526,6 @@ WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, S return WERR_ACCESS_DENIED; return info->ops->stop_service( &r_u->svc_status ); - -#if 0 - SERVICE_INFO *service_info; - POLICY_HND *handle; - pstring command; - SERVICE_STATUS *service_status; - int ret,fd; - - /* need to find the service name by the handle that is open */ - handle = &(q_u->handle); - - service_info = find_service_info_by_hnd(p, handle); - - if (!service_info) { - DEBUG(10, ("_svcctl_control_service : Can't find the service for the handle\n")); - return WERR_BADFID; - } - - /* we return a SERVICE_STATUS structure if there's an error. */ - if ( !(service_status = TALLOC_ARRAY(p->mem_ctx, SERVICE_STATUS, 1 )) ) - return WERR_NOMEM; - - DEBUG(10, ("_svcctl_control_service: Found service [%s], [%s]\n", - service_info->servicename, service_info->filename)); - - /* TODO - call the service config function here... */ - memset(command, 0, sizeof(command)); - if (q_u->control == SVCCTL_CONTROL_STOP) { - slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, - service_info->filename, "stop"); - } - - if (q_u->control == SVCCTL_CONTROL_PAUSE) { - slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, - service_info->filename, "stop"); - } - - if (q_u->control == SVCCTL_CONTROL_CONTINUE) { - slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, - service_info->filename, "restart"); - } - - DEBUG(10, ("_svcctl_control_service: status command is [%s]\n", command)); - - /* TODO - wrap in privilege check */ - - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - close(fd); - - if(ret != 0) - DEBUG(10, ("enum_external_services: Command returned [%d]\n", ret)); - - /* SET all service_stats bits here...*/ - if (ret == 0) { - service_status->state = SVCCTL_RUNNING; - service_status->controls_accepted = SVCCTL_CONTROL_SHUTDOWN | SVCCTL_CONTROL_STOP; - } else { - service_status->state = SVCCTL_STOPPED; - service_status->controls_accepted = 0; - } - - DEBUG(10, ("_svcctl_query_service_config: Should call the commFound service [%s], [%s]\n",service_info->servicename,service_info->filename)); - -#endif } /******************************************************************** -- cgit From 9b43bd3b62733992d06b6d8e602364efa816685c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 15 Jun 2005 16:32:12 +0000 Subject: r7613: small changes to _svcctl_open_service() and create_open_service_handle() to prevent invalid service names from being accepted; printmig.exe now migrates drivers successfully (This used to be commit dafb32c01f06c42f44aeb0d16681c5def4903244) --- source3/rpc_server/srv_svcctl_nt.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 230a222b8d..2685377772 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -171,6 +171,7 @@ static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, const char *service, uint32 access_granted ) { SERVICE_INFO *info = NULL; + WERROR result = WERR_OK; if ( !(info = SMB_MALLOC_P( SERVICE_INFO )) ) return WERR_NOMEM; @@ -186,16 +187,23 @@ static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, info->type = SVC_HANDLE_IS_SERVICE; - if ( !(info->name = SMB_STRDUP( service )) ) { - free_service_handle_info( info ); - WERR_NOMEM; - } - /* lookup the SERVICE_CONTROL_OPS */ for ( i=0; svcctl_ops[i].name; i++ ) { - if ( strequal( svcctl_ops[i].name, service ) ) + if ( strequal( svcctl_ops[i].name, service ) ) { info->ops = svcctl_ops[i].ops; + break; + } + } + + if ( !svcctl_ops[i].name ) { + result = WERR_NO_SUCH_SERVICE; + goto done; + } + + if ( !(info->name = SMB_STRDUP( service )) ) { + result = WERR_NOMEM; + goto done; } } @@ -204,11 +212,15 @@ static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, /* store the SERVICE_INFO and create an open handle */ if ( !create_policy_hnd( p, handle, free_service_handle_info, info ) ) { - free_service_handle_info( info ); - return WERR_ACCESS_DENIED; + result = WERR_ACCESS_DENIED; + goto done; } - return WERR_OK; +done: + if ( !W_ERROR_IS_OK(result) ) + free_service_handle_info( info ); + + return result; } /******************************************************************** -- cgit From f2f115c2a203c1a7b685ff3795c9e342499c1cc9 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 15 Jun 2005 17:03:34 +0000 Subject: r7614: convert move_driver_to_download_area() to return WERROR in order to provide better error messages to clients when a AddPrinterDriver[Ex]() call fails (This used to be commit c98e17446afffc4b12f1a31f6e5cce517fc0a95b) --- source3/rpc_server/srv_spoolss_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 39c294fa45..972f6e9730 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7628,9 +7628,7 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, goto done; DEBUG(5,("Moving driver to final destination\n")); - if(!move_driver_to_download_area(driver, level, &user, &err)) { - if (W_ERROR_IS_OK(err)) - err = WERR_ACCESS_DENIED; + if( !W_ERROR_IS_OK(err = move_driver_to_download_area(driver, level, &user, &err)) ) { goto done; } -- cgit From b162a396fecb08cc02addf17aed30fbc5e813f5b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 16 Jun 2005 00:46:43 +0000 Subject: r7624: * removed unmatched tdb_lock_by_string() call (should fix build farm issues) * comment out services.tdb code until I finish rewriting it (This used to be commit 707b7822286a6c7e9d1e4ca3d15b99c976f6e704) --- source3/rpc_server/srv_svcctl_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 2685377772..3d34556340 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -445,9 +445,9 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT num_int_services = 0; - num_int_services = num_internal_services(); + /* num_int_services = num_internal_services(); */ - num_ext_services = num_external_services(); + /* num_ext_services = num_external_services(); */ if ( !(services = TALLOC_ARRAY(p->mem_ctx, ENUM_SERVICES_STATUS, num_int_services+num_ext_services )) ) return WERR_NOMEM; @@ -458,7 +458,7 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT DEBUG(8,("_svcctl_enum_services_status: Got %d internal services\n", num_int_services)); } - ext_result=enum_external_services(p->mem_ctx, &services, num_int_services, &num_ext_services); + /* ext_result=enum_external_services(p->mem_ctx, &services, num_int_services, &num_ext_services); */ if (W_ERROR_IS_OK(ext_result)) { DEBUG(8,("_svcctl_enum_services_status: Got %d external services\n", num_ext_services)); -- cgit From bb2616d0180d21e5962a028617d274c51f5dcc63 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 16 Jun 2005 20:04:16 +0000 Subject: r7645: adding server stubs for RegCreateKey() and RegSetValue() (This used to be commit ce82566badfb907a2f72e2f7d90a7bbbe3811177) --- source3/rpc_server/srv_reg.c | 52 ++++++++++++++++++++++++++++++++++++++++- source3/rpc_server/srv_reg_nt.c | 16 +++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index a90650c536..8c703f3a5a 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -416,6 +416,54 @@ static BOOL api_reg_save_key(pipes_struct *p) return True; } +/******************************************************************* + ******************************************************************/ + +static BOOL api_reg_create_key(pipes_struct *p) +{ + REG_Q_CREATE_KEY q_u; + REG_R_CREATE_KEY r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_create_key("", &q_u, data, 0)) + return False; + + r_u.status = _reg_create_key(p, &q_u, &r_u); + + if(!reg_io_r_create_key("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ******************************************************************/ + +static BOOL api_reg_set_value(pipes_struct *p) +{ + REG_Q_SET_VALUE q_u; + REG_R_SET_VALUE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_set_value("", &q_u, data, 0)) + return False; + + r_u.status = _reg_set_value(p, &q_u, &r_u); + + if(!reg_io_r_set_value("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* array of \PIPE\reg operations ********************************************************************/ @@ -436,7 +484,9 @@ static struct api_struct api_reg_cmds[] = { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, { "REG_GETVERSION" , REG_GETVERSION , api_reg_getversion }, { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key }, - { "REG_RESTORE_KEY" , REG_RESTORE_KEY , api_reg_restore_key } + { "REG_RESTORE_KEY" , REG_RESTORE_KEY , api_reg_restore_key }, + { "REG_CREATE_KEY" , REG_CREATE_KEY , api_reg_create_key }, + { "REG_SET_VALUE" , REG_SET_VALUE , api_reg_set_value } }; void reg_get_pipe_fns( struct api_struct **fns, int *n_fns ) diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 9df8e9b5fc..31a6c019bb 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -1071,4 +1071,20 @@ WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) return WERR_OK; } +/******************************************************************* + ********************************************************************/ + +WERROR _reg_create_key(pipes_struct *p, REG_Q_CREATE_KEY *q_u, REG_R_CREATE_KEY *r_u) +{ + return WERR_ACCESS_DENIED; +} + + +/******************************************************************* + ********************************************************************/ + +WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r_u) +{ + return WERR_ACCESS_DENIED; +} -- cgit From 2fbb43ad82c16ae83da39ff61f665697564c3482 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 16 Jun 2005 20:29:15 +0000 Subject: r7647: add access checks to the top level hive open calls; will need to pass the open request through the backend access check for the subkey open calls (This used to be commit 23acef44e978f3bace762cc98c310b11f0021d31) --- source3/rpc_server/srv_reg_nt.c | 92 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 31a6c019bb..01c60a473f 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -43,6 +43,53 @@ struct generic_mapping reg_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; +/******************************************************************** +********************************************************************/ + +static NTSTATUS registry_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, + uint32 access_desired, uint32 *access_granted ) +{ + NTSTATUS result; + + se_access_check( sec_desc, token, access_desired, access_granted, &result ); + + return result; +} + +/******************************************************************** +********************************************************************/ + +static SEC_DESC* construct_reg_hive_sd( TALLOC_CTX *ctx ) +{ + SEC_ACE ace[2]; + SEC_ACCESS mask; + size_t i = 0; + SEC_DESC *sd; + SEC_ACL *acl; + uint32 sd_size; + + /* basic access for Everyone */ + + init_sec_access(&mask, REG_KEY_READ ); + init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + /* Full Access 'BUILTIN\Administrators' */ + + init_sec_access(&mask, REG_KEY_ALL ); + init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); + + + /* create the security descriptor */ + + if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) + return NULL; + + if ( !(sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, acl, &sd_size)) ) + return NULL; + + return sd; +} + /****************************************************************** free() function for REGISTRY_KEY *****************************************************************/ @@ -290,7 +337,20 @@ WERROR _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) WERROR _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) { - return open_registry_key( p, &r_u->pol, NULL, KEY_HKLM, 0x0 ); + SEC_DESC *sec_desc; + uint32 access_granted = 0; + NTSTATUS status; + + /* perform access checks */ + + if ( !(sec_desc = construct_reg_hive_sd( p->mem_ctx )) ) + return WERR_NOMEM; + + status = registry_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); + if ( !NT_STATUS_IS_OK(status) ) + return ntstatus_to_werror( status ); + + return open_registry_key( p, &r_u->pol, NULL, KEY_HKLM, access_granted ); } /******************************************************************* @@ -298,7 +358,20 @@ WERROR _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_ WERROR _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) { - return open_registry_key( p, &r_u->pol, NULL, KEY_HKCR, 0x0 ); + SEC_DESC *sec_desc; + uint32 access_granted = 0; + NTSTATUS status; + + /* perform access checks */ + + if ( !(sec_desc = construct_reg_hive_sd( p->mem_ctx )) ) + return WERR_NOMEM; + + status = registry_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); + if ( !NT_STATUS_IS_OK(status) ) + return ntstatus_to_werror( status ); + + return open_registry_key( p, &r_u->pol, NULL, KEY_HKCR, access_granted ); } /******************************************************************* @@ -306,7 +379,20 @@ WERROR _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_ WERROR _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) { - return open_registry_key( p, &r_u->pol, NULL, KEY_HKU, 0x0 ); + SEC_DESC *sec_desc; + uint32 access_granted = 0; + NTSTATUS status; + + /* perform access checks */ + + if ( !(sec_desc = construct_reg_hive_sd( p->mem_ctx )) ) + return WERR_NOMEM; + + status = registry_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); + if ( !NT_STATUS_IS_OK(status) ) + return ntstatus_to_werror( status ); + + return open_registry_key( p, &r_u->pol, NULL, KEY_HKU, access_granted ); } /******************************************************************* -- cgit From 17eb05228ee93c9790a0bacbfb0e5e282aa180d2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 16 Jun 2005 20:45:55 +0000 Subject: r7648: adding REGISTRY_HOOK->reg_access_check() for authprization checks on RegOpenKey(); passing it off to the backend code for a given path (This used to be commit 867fd3052bbfdd45856886999619e2ebc6552675) --- source3/rpc_server/srv_reg_nt.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 01c60a473f..ec9a79f534 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -46,7 +46,7 @@ struct generic_mapping reg_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, /******************************************************************** ********************************************************************/ -static NTSTATUS registry_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, +NTSTATUS registry_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, uint32 access_desired, uint32 *access_granted ) { NTSTATUS result; @@ -59,7 +59,7 @@ static NTSTATUS registry_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, /******************************************************************** ********************************************************************/ -static SEC_DESC* construct_reg_hive_sd( TALLOC_CTX *ctx ) +SEC_DESC* construct_registry_sd( TALLOC_CTX *ctx ) { SEC_ACE ace[2]; SEC_ACCESS mask; @@ -322,12 +322,10 @@ static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum, WERROR _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) { - /* set up the REG unknown_1 response */ - ZERO_STRUCT(r_u->pol); - /* close the policy handle */ - if (!close_registry_key(p, &q_u->pol)) - return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ + + if ( !close_registry_key(p, &q_u->pol) ) + return WERR_BADFID; return WERR_OK; } @@ -342,8 +340,9 @@ WERROR _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_ NTSTATUS status; /* perform access checks */ + /* top level keys are done here without passing through the REGISTRY_HOOK api */ - if ( !(sec_desc = construct_reg_hive_sd( p->mem_ctx )) ) + if ( !(sec_desc = construct_registry_sd( p->mem_ctx )) ) return WERR_NOMEM; status = registry_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); @@ -363,8 +362,9 @@ WERROR _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_ NTSTATUS status; /* perform access checks */ + /* top level keys are done here without passing through the REGISTRY_HOOK api */ - if ( !(sec_desc = construct_reg_hive_sd( p->mem_ctx )) ) + if ( !(sec_desc = construct_registry_sd( p->mem_ctx )) ) return WERR_NOMEM; status = registry_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); @@ -384,8 +384,9 @@ WERROR _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u NTSTATUS status; /* perform access checks */ + /* top level keys are done here without passing through the REGISTRY_HOOK api */ - if ( !(sec_desc = construct_reg_hive_sd( p->mem_ctx )) ) + if ( !(sec_desc = construct_registry_sd( p->mem_ctx )) ) return WERR_NOMEM; status = registry_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); @@ -409,8 +410,8 @@ WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY DEBUG(5,("reg_open_entry: Enter\n")); if ( !key ) - return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ - + return WERR_BADFID; + rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); result = open_registry_key( p, &pol, key, name, 0x0 ); @@ -441,7 +442,7 @@ WERROR _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) DEBUG(5,("_reg_info: Enter\n")); if ( !regkey ) - return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ + return WERR_BADFID; DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); @@ -545,7 +546,7 @@ WERROR _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_ DEBUG(5,("_reg_query_key: Enter\n")); if ( !regkey ) - return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ + return WERR_BADFID; if ( !get_subkey_information( regkey, &r_u->num_subkeys, &r_u->max_subkeylen ) ) return WERR_ACCESS_DENIED; @@ -579,9 +580,9 @@ WERROR _reg_getversion(pipes_struct *p, REG_Q_GETVERSION *q_u, REG_R_GETVERSION DEBUG(5,("_reg_getversion: Enter\n")); if ( !regkey ) - return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ + return WERR_BADFID; - r_u->unknown = 0x00000005; /* seems to be consistent...no idea what it means */ + r_u->win_version = 0x00000005; /* Windows 2000 registry API version */ DEBUG(5,("_reg_getversion: Exit\n")); @@ -603,7 +604,7 @@ WERROR _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u) DEBUG(5,("_reg_enum_key: Enter\n")); if ( !regkey ) - return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ + return WERR_BADFID; DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", regkey->name)); @@ -640,7 +641,7 @@ WERROR _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE DEBUG(5,("_reg_enum_value: Enter\n")); if ( !regkey ) - return WERR_BADFID; /* This will be reported as an RPC fault anyway. */ + return WERR_BADFID; DEBUG(8,("_reg_enum_key: enumerating values for key [%s]\n", regkey->name)); -- cgit From b2db8a9bd3aad8e56ab4d95b05d2db7773057e8b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 16 Jun 2005 20:59:39 +0000 Subject: r7649: * fix compile breakage (sorry, should have done a make clean before the last checking). * rename unknown field in REG_GETVERSION * add server stubs for RegDeleteKey() and RegDeleteValue() (This used to be commit 023728c0595eaef60e357d32a25e2c4cee9e21f4) --- source3/rpc_server/srv_reg.c | 52 ++++++++++++++++++++++++++++++++++++++++- source3/rpc_server/srv_reg_nt.c | 17 ++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 8c703f3a5a..c0abc2a9c2 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -464,6 +464,54 @@ static BOOL api_reg_set_value(pipes_struct *p) return True; } +/******************************************************************* + ******************************************************************/ + +static BOOL api_reg_delete_key(pipes_struct *p) +{ + REG_Q_DELETE_KEY q_u; + REG_R_DELETE_KEY r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_delete_key("", &q_u, data, 0)) + return False; + + r_u.status = _reg_delete_key(p, &q_u, &r_u); + + if(!reg_io_r_delete_key("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ******************************************************************/ + +static BOOL api_reg_delete_value(pipes_struct *p) +{ + REG_Q_DELETE_VALUE q_u; + REG_R_DELETE_VALUE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_delete_value("", &q_u, data, 0)) + return False; + + r_u.status = _reg_delete_value(p, &q_u, &r_u); + + if(!reg_io_r_delete_value("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* array of \PIPE\reg operations ********************************************************************/ @@ -486,7 +534,9 @@ static struct api_struct api_reg_cmds[] = { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key }, { "REG_RESTORE_KEY" , REG_RESTORE_KEY , api_reg_restore_key }, { "REG_CREATE_KEY" , REG_CREATE_KEY , api_reg_create_key }, - { "REG_SET_VALUE" , REG_SET_VALUE , api_reg_set_value } + { "REG_SET_VALUE" , REG_SET_VALUE , api_reg_set_value }, + { "REG_DELETE_KEY" , REG_DELETE_KEY , api_reg_delete_key }, + { "REG_DELETE_VALUE" , REG_DELETE_VALUE , api_reg_delete_value } }; void reg_get_pipe_fns( struct api_struct **fns, int *n_fns ) diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index ec9a79f534..2a80594128 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -1175,3 +1175,20 @@ WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r return WERR_ACCESS_DENIED; } +/******************************************************************* + ********************************************************************/ + +WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY *r_u) +{ + return WERR_ACCESS_DENIED; +} + + +/******************************************************************* + ********************************************************************/ + +WERROR _reg_delete_value(pipes_struct *p, REG_Q_DELETE_VALUE *q_u, REG_R_DELETE_VALUE *r_u) +{ + return WERR_ACCESS_DENIED; +} + -- cgit From 2102f6bff9641eeec3b593529be7bf8d9ec784d4 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 17 Jun 2005 01:57:18 +0000 Subject: r7664: add access check hooks to _reg_open_entry which are passed off to the reg_XXX backend. If the backend does not define a regkey_access_check() function, we default to using the standard registry_access_check() (This used to be commit 2f08a904eee772e7d99ae6e3e4c922f74732284f) --- source3/rpc_server/srv_reg_nt.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 2a80594128..95af6c15c9 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -197,6 +197,10 @@ static WERROR open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY * if ( !create_policy_hnd( p, hnd, free_regkey_info, regkey ) ) result = WERR_BADFILE; } + + /* save the access mask */ + + regkey->access_granted = access_granted; /* clean up */ @@ -402,9 +406,10 @@ WERROR _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY *r_u) { - POLICY_HND pol; fstring name; REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->pol); + REGISTRY_KEY *newkey; + uint32 access_granted; WERROR result; DEBUG(5,("reg_open_entry: Enter\n")); @@ -414,13 +419,31 @@ WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); - result = open_registry_key( p, &pol, key, name, 0x0 ); - - init_reg_r_open_entry( r_u, &pol, result ); + /* check granted access first; what is the correct mask here? */ + + if ( !(key->access_granted & SEC_RIGHTS_ENUM_SUBKEYS) ) + return WERR_ACCESS_DENIED; + + /* open the key first to get the appropriate REGISTRY_HOOK + and then check the premissions */ + + if ( !W_ERROR_IS_OK(result = open_registry_key( p, &r_u->handle, key, name, 0 )) ) + return result; - DEBUG(5,("reg_open_entry: Exit\n")); + newkey = find_regkey_index_by_hnd(p, &r_u->handle); - return r_u->status; + /* finally allow the backend to check the access for the requested key */ + + if ( !regkey_access_check( newkey, q_u->access, &access_granted, p->pipe_user.nt_user_token ) ) { + close_registry_key( p, &r_u->handle ); + return WERR_ACCESS_DENIED; + } + + /* if successful, save the granted access mask */ + + newkey->access_granted = access_granted; + + return WERR_OK; } /******************************************************************* -- cgit From 2129d3c711a109b47c3c1596a6a639520d2f72d2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 17 Jun 2005 15:35:31 +0000 Subject: r7691: * add .gdbinit to the svn:ignore files * start adding write support to the Samba registry Flesh out the server implementations of RegCreateKey(), RegSetValue(), RegDeleteKey() and RegDeleteValue() I can create a new key using regedit.exe now but the 'New Key #1' key cannot be deleted yet. (This used to be commit e188fdbef8f0ad202b0ecf3c30be2941ebe6d5b1) --- source3/rpc_server/srv_reg_nt.c | 228 ++++++++++++++++++++++++++++++++++------ 1 file changed, 195 insertions(+), 33 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 95af6c15c9..3491cc2c76 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -179,29 +179,23 @@ static WERROR open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY * /* check if the path really exists; failed is indicated by -1 */ /* if the subkey count failed, bail out */ - ZERO_STRUCTP( &subkeys ); - regsubkey_ctr_init( &subkeys ); if ( fetch_reg_keys( regkey, &subkeys ) == -1 ) { - - /* don't really know what to return here */ result = WERR_BADFILE; + goto done; } - else { - /* - * This would previously return NT_STATUS_TOO_MANY_SECRETS - * that doesn't sound quite right to me --jerry - */ - - if ( !create_policy_hnd( p, hnd, free_regkey_info, regkey ) ) - result = WERR_BADFILE; + + if ( !create_policy_hnd( p, hnd, free_regkey_info, regkey ) ) { + result = WERR_BADFILE; + goto done; } /* save the access mask */ regkey->access_granted = access_granted; +done: /* clean up */ regsubkey_ctr_destroy( &subkeys ); @@ -247,8 +241,6 @@ static BOOL get_subkey_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *m if ( !key ) return False; - ZERO_STRUCTP( &subkeys ); - regsubkey_ctr_init( &subkeys ); if ( fetch_reg_keys( key, &subkeys ) == -1 ) @@ -289,9 +281,6 @@ static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum, if ( !key ) return False; - - ZERO_STRUCTP( &values ); - regval_ctr_init( &values ); if ( fetch_reg_values( key, &values ) == -1 ) @@ -407,27 +396,27 @@ WERROR _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY *r_u) { fstring name; - REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->pol); + REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->pol); REGISTRY_KEY *newkey; uint32 access_granted; WERROR result; DEBUG(5,("reg_open_entry: Enter\n")); - if ( !key ) + if ( !parent ) return WERR_BADFID; rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); /* check granted access first; what is the correct mask here? */ - if ( !(key->access_granted & SEC_RIGHTS_ENUM_SUBKEYS) ) + if ( !(parent->access_granted & (SEC_RIGHTS_ENUM_SUBKEYS|SEC_RIGHTS_CREATE_SUBKEY)) ) return WERR_ACCESS_DENIED; /* open the key first to get the appropriate REGISTRY_HOOK and then check the premissions */ - if ( !W_ERROR_IS_OK(result = open_registry_key( p, &r_u->handle, key, name, 0 )) ) + if ( !W_ERROR_IS_OK(result = open_registry_key( p, &r_u->handle, parent, name, 0 )) ) return result; newkey = find_regkey_index_by_hnd(p, &r_u->handle); @@ -473,8 +462,6 @@ WERROR _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) DEBUG(5,("reg_info: looking up value: [%s]\n", name)); - ZERO_STRUCTP( ®vals ); - regval_ctr_init( ®vals ); /* couple of hard coded registry values */ @@ -891,9 +878,6 @@ static WERROR reg_load_tree( REGF_FILE *regfile, const char *topkeypath, /* now start parsing the values and subkeys */ - ZERO_STRUCT( values ); - ZERO_STRUCT( subkeys ); - regsubkey_ctr_init( &subkeys ); regval_ctr_init( &values ); @@ -1044,9 +1028,6 @@ static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, /* lookup the values and subkeys */ - ZERO_STRUCT( values ); - ZERO_STRUCT( subkeys ); - regsubkey_ctr_init( &subkeys ); regval_ctr_init( &values ); @@ -1186,7 +1167,98 @@ WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) WERROR _reg_create_key(pipes_struct *p, REG_Q_CREATE_KEY *q_u, REG_R_CREATE_KEY *r_u) { - return WERR_ACCESS_DENIED; + REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->handle); + REGISTRY_KEY *newparent; + POLICY_HND newparent_handle; + REGSUBKEY_CTR subkeys; + BOOL write_result; + pstring name; + WERROR result; + + if ( !parent ) + return WERR_BADFID; + + rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); + + /* ok. Here's what we do. */ + + if ( strrchr( name, '\\' ) ) { + pstring newkeyname; + char *ptr; + uint32 access_granted; + + /* (1) check for enumerate rights on the parent handle. CLients can try + create things like 'SOFTWARE\Samba' on the HKLM handle. + (2) open the path to the child parent key if necessary */ + + if ( !(parent->access_granted & SEC_RIGHTS_ENUM_SUBKEYS) ) + return WERR_ACCESS_DENIED; + + pstrcpy( newkeyname, name ); + ptr = strrchr( newkeyname, '\\' ); + *ptr = '\0'; + + result = open_registry_key( p, &newparent_handle, parent, newkeyname, 0 ); + if ( !W_ERROR_IS_OK(result) ) + return result; + + newparent = find_regkey_index_by_hnd(p, &newparent_handle); + SMB_ASSERT( newparent != NULL ); + + if ( !regkey_access_check( newparent, REG_KEY_READ|REG_KEY_WRITE, &access_granted, p->pipe_user.nt_user_token ) ) { + result = WERR_ACCESS_DENIED; + goto done; + } + + newparent->access_granted = access_granted; + + /* copy the new key name (just the lower most keyname) */ + + pstrcpy( name, ptr+1 ); + } + else { + /* use the existing open key information */ + newparent = parent; + memcpy( &newparent_handle, &q_u->handle, sizeof(POLICY_HND) ); + } + + /* (3) check for create subkey rights on the correct parent */ + + if ( !(newparent->access_granted & SEC_RIGHTS_CREATE_SUBKEY) ) { + result = WERR_ACCESS_DENIED; + goto done; + } + + regsubkey_ctr_init( &subkeys ); + + /* (4) lookup the current keys and add the new one */ + + fetch_reg_keys( newparent, &subkeys ); + regsubkey_ctr_addkey( &subkeys, name ); + + /* now write to the registry backend */ + + write_result = store_reg_keys( newparent, &subkeys ); + + regsubkey_ctr_destroy( &subkeys ); + + if ( !write_result ) + return WERR_REG_IO_FAILURE; + + /* (5) open the new key and return the handle. Note that it is probably + not correct to grant full access on this open handle. We should pass + the new open through the regkey_access_check() like we do for + _reg_open_entry() but this is ok for now. */ + + result = open_registry_key( p, &r_u->handle, newparent, name, REG_KEY_ALL ); + +done: + /* close any intermediate key handles */ + + if ( newparent != parent ) + close_registry_key( p, &newparent_handle ); + + return result; } @@ -1195,7 +1267,35 @@ WERROR _reg_create_key(pipes_struct *p, REG_Q_CREATE_KEY *q_u, REG_R_CREATE_KEY WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r_u) { - return WERR_ACCESS_DENIED; + REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); + REGVAL_CTR values; + BOOL write_result; + + if ( !key ) + return WERR_BADFID; + + /* access checks first */ + + if ( !(key->access_granted & SEC_RIGHTS_SET_VALUE) ) + return WERR_ACCESS_DENIED; + + regval_ctr_init( &values ); + + /* lookup the current values and add the new one */ + + fetch_reg_values( key, &values ); + /* FIXME!!!! regval_ctr_addvalue( &values, .... ); */ + + /* now write to the registry backend */ + + write_result = store_reg_values( key, &values ); + + regval_ctr_destroy( &values ); + + if ( !write_result ) + return WERR_REG_IO_FAILURE; + + return WERR_OK; } /******************************************************************* @@ -1203,7 +1303,41 @@ WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY *r_u) { - return WERR_ACCESS_DENIED; + REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->handle); + REGSUBKEY_CTR subkeys; + BOOL write_result; + fstring name; + + if ( !parent ) + return WERR_BADFID; + + rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); + + /* access checks first */ + + if ( !(parent->access_granted & SEC_RIGHTS_CREATE_SUBKEY) ) + return WERR_ACCESS_DENIED; + + regsubkey_ctr_init( &subkeys ); + + /* lookup the current keys and add the new one */ + + fetch_reg_keys( parent, &subkeys ); + + /* FIXME!!! regsubkey_ctr_delkey( &subkeys, name ); */ + + /* now write to the registry backend */ + + write_result = store_reg_keys( parent, &subkeys ); + + regsubkey_ctr_destroy( &subkeys ); + + if ( !write_result ) + return WERR_REG_IO_FAILURE; + + /* rpc_reg.h says there is a POLICY_HDN in the reply...no idea if that is correct */ + + return WERR_OK; } @@ -1212,6 +1346,34 @@ WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY WERROR _reg_delete_value(pipes_struct *p, REG_Q_DELETE_VALUE *q_u, REG_R_DELETE_VALUE *r_u) { - return WERR_ACCESS_DENIED; + REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); + REGVAL_CTR values; + BOOL write_result; + + if ( !key ) + return WERR_BADFID; + + /* access checks first */ + + if ( !(key->access_granted & SEC_RIGHTS_SET_VALUE) ) + return WERR_ACCESS_DENIED; + + regval_ctr_init( &values ); + + /* lookup the current values and add the new one */ + + fetch_reg_values( key, &values ); + /* FIXME!!!! regval_ctr_delval( &values, .... ); */ + + /* now write to the registry backend */ + + write_result = store_reg_values( key, &values ); + + regval_ctr_destroy( &values ); + + if ( !write_result ) + return WERR_REG_IO_FAILURE; + + return WERR_OK; } -- cgit From c25b67b24d3c7ec04a58410aaa05c1aae9688e32 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 17 Jun 2005 18:57:37 +0000 Subject: r7698: * clean upserver frontend for RegDeleteKey() * implement RegDeleteKey() for reg_db backend (This used to be commit 91b81a23b8e2a096747e02fd9392ef590e7f0d61) --- source3/rpc_server/srv_reg_nt.c | 76 ++++++++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 3491cc2c76..a3ab63d06e 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -1304,40 +1304,90 @@ WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY *r_u) { REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->handle); + REGISTRY_KEY *newparent; + POLICY_HND newparent_handle; REGSUBKEY_CTR subkeys; BOOL write_result; - fstring name; + pstring name; + WERROR result; if ( !parent ) return WERR_BADFID; rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); + + /* ok. Here's what we do. */ + + if ( strrchr( name, '\\' ) ) { + pstring newkeyname; + char *ptr; + uint32 access_granted; + + /* (1) check for enumerate rights on the parent handle. CLients can try + create things like 'SOFTWARE\Samba' on the HKLM handle. + (2) open the path to the child parent key if necessary */ - /* access checks first */ - - if ( !(parent->access_granted & SEC_RIGHTS_CREATE_SUBKEY) ) - return WERR_ACCESS_DENIED; + if ( !(parent->access_granted & SEC_RIGHTS_ENUM_SUBKEYS) ) + return WERR_ACCESS_DENIED; + pstrcpy( newkeyname, name ); + ptr = strrchr( newkeyname, '\\' ); + *ptr = '\0'; + + result = open_registry_key( p, &newparent_handle, parent, newkeyname, 0 ); + if ( !W_ERROR_IS_OK(result) ) + return result; + + newparent = find_regkey_index_by_hnd(p, &newparent_handle); + SMB_ASSERT( newparent != NULL ); + + if ( !regkey_access_check( newparent, REG_KEY_READ|REG_KEY_WRITE, &access_granted, p->pipe_user.nt_user_token ) ) { + result = WERR_ACCESS_DENIED; + goto done; + } + + newparent->access_granted = access_granted; + + /* copy the new key name (just the lower most keyname) */ + + pstrcpy( name, ptr+1 ); + } + else { + /* use the existing open key information */ + newparent = parent; + memcpy( &newparent_handle, &q_u->handle, sizeof(POLICY_HND) ); + } + + /* (3) check for create subkey rights on the correct parent */ + + if ( !(newparent->access_granted & STD_RIGHT_DELETE_ACCESS) ) { + result = WERR_ACCESS_DENIED; + goto done; + } + regsubkey_ctr_init( &subkeys ); - /* lookup the current keys and add the new one */ + /* lookup the current keys and delete the new one */ - fetch_reg_keys( parent, &subkeys ); + fetch_reg_keys( newparent, &subkeys ); - /* FIXME!!! regsubkey_ctr_delkey( &subkeys, name ); */ + regsubkey_ctr_delkey( &subkeys, name ); /* now write to the registry backend */ - write_result = store_reg_keys( parent, &subkeys ); + write_result = store_reg_keys( newparent, &subkeys ); regsubkey_ctr_destroy( &subkeys ); - if ( !write_result ) - return WERR_REG_IO_FAILURE; - +done: + /* close any intermediate key handles */ + + if ( newparent != parent ) + close_registry_key( p, &newparent_handle ); + /* rpc_reg.h says there is a POLICY_HDN in the reply...no idea if that is correct */ - return WERR_OK; + return write_result ? WERR_OK : WERR_REG_IO_FAILURE; } -- cgit From 3b1f21b812be54d4ed334e23161e6d9a54f9977f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 18 Jun 2005 04:23:06 +0000 Subject: r7708: Hint from Luke Howard (thanks Luke). Ensure the schannel authenticator is 8 byte aligned, just like the NTLMSSP ones. Trying to fix 64-bit Windows domain logon. Jeremy. (This used to be commit 475d5a277db7709c1b0f851ce8ec4dd8de5e25fc) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 9cf61d6357..30aacdc4c5 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -162,7 +162,7 @@ BOOL create_next_pdu(pipes_struct *p) if(p->out_data.data_sent_length + data_len >= prs_offset(&p->out_data.rdata)) { p->hdr.flags |= RPC_FLG_LAST; - if ((auth_seal || auth_verify) && (data_len_left % 8)) { + if ((auth_seal || auth_verify || p->netsec_auth_validated) && (data_len_left % 8)) { ss_padding_len = 8 - (data_len_left % 8); DEBUG(10,("create_next_pdu: adding sign/seal padding of %u\n", ss_padding_len )); -- cgit From 864ca4f0510da95cadf5ad449b2ec818a78d8c17 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 22 Jun 2005 14:16:10 +0000 Subject: r7836: Fix the bug where users show up as trusting domains. Volker (This used to be commit 61585fa56b4f838f416815598f4a301aa9ee12d7) --- source3/rpc_server/srv_samr_nt.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e510f69cc8..9b98d4cb16 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -45,11 +45,14 @@ extern rid_name domain_alias_rids[]; extern rid_name builtin_alias_rids[]; typedef struct disp_info { - struct pdb_search *users; - struct pdb_search *machines; - struct pdb_search *groups; - struct pdb_search *aliases; - struct pdb_search *builtins; + struct pdb_search *users; /* querydispinfo 1 and 4 */ + struct pdb_search *machines; /* querydispinfo 2 */ + struct pdb_search *groups; /* querydispinfo 3 and 5, enumgroups */ + struct pdb_search *aliases; /* enumaliases */ + struct pdb_search *builtins; /* enumaliases */ + + uint16 enum_acb_mask; + struct pdb_search *enum_users; /* enumusers with a mask */ } DISP_INFO; struct samr_info { @@ -264,6 +267,8 @@ static void free_samr_db(struct samr_info *info) info->disp_info.aliases = NULL; pdb_search_destroy(info->disp_info.builtins); info->disp_info.builtins = NULL; + pdb_search_destroy(info->disp_info.enum_users); + info->disp_info.enum_users = NULL; } static void free_samr_info(void *ptr) @@ -590,11 +595,19 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); become_root(); - if (info->disp_info.users == NULL) - info->disp_info.users = pdb_search_users(q_u->acb_mask); - if (info->disp_info.users == NULL) + if ((info->disp_info.enum_users != NULL) && + (info->disp_info.enum_acb_mask != q_u->acb_mask)) { + pdb_search_destroy(info->disp_info.enum_users); + info->disp_info.enum_users = NULL; + } + + if (info->disp_info.enum_users == NULL) { + info->disp_info.enum_users = pdb_search_users(q_u->acb_mask); + info->disp_info.enum_acb_mask = q_u->acb_mask; + } + if (info->disp_info.enum_users == NULL) return NT_STATUS_ACCESS_DENIED; - num_account = pdb_search_entries(info->disp_info.users, + num_account = pdb_search_entries(info->disp_info.enum_users, enum_context, max_entries, &entries); unbecome_root(); -- cgit From 2fb7ff7d9def29e21dd87f565ccda5437c848cdd Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 24 Jun 2005 14:55:09 +0000 Subject: r7878: mostly just a rename of REG_INFO to REG_QUERY_VALUE for better clarity (This used to be commit d50f0ba07e285728605c8e8aae9d9a251a525e78) --- source3/rpc_server/srv_reg.c | 16 ++++++++-------- source3/rpc_server/srv_reg_nt.c | 11 ++++------- 2 files changed, 12 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index c0abc2a9c2..fec6702758 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -164,13 +164,13 @@ static BOOL api_reg_open_entry(pipes_struct *p) } /******************************************************************* - api_reg_info + api_reg_query_value ********************************************************************/ -static BOOL api_reg_info(pipes_struct *p) +static BOOL api_reg_query_value(pipes_struct *p) { - REG_Q_INFO q_u; - REG_R_INFO r_u; + REG_Q_QUERY_VALUE q_u; + REG_R_QUERY_VALUE r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -178,12 +178,12 @@ static BOOL api_reg_info(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the reg unknown 0x11*/ - if(!reg_io_q_info("", &q_u, data, 0)) + if(!reg_io_q_query_value("", &q_u, data, 0)) return False; - r_u.status = _reg_info(p, &q_u, &r_u); + r_u.status = _reg_query_value(p, &q_u, &r_u); - if(!reg_io_r_info("", &r_u, rdata, 0)) + if(!reg_io_r_query_value("", &r_u, rdata, 0)) return False; return True; @@ -526,7 +526,7 @@ static struct api_struct api_reg_cmds[] = { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key }, { "REG_ENUM_VALUE" , REG_ENUM_VALUE , api_reg_enum_value }, { "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key }, - { "REG_INFO" , REG_INFO , api_reg_info }, + { "REG_QUERY_VALUE" , REG_QUERY_VALUE , api_reg_query_value }, { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, { "REG_SHUTDOWN_EX" , REG_SHUTDOWN_EX , api_reg_shutdown_ex }, { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index a3ab63d06e..455ff3da40 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -439,7 +439,7 @@ WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY reg_reply_info ********************************************************************/ -WERROR _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) +WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VALUE *r_u) { WERROR status = WERR_BADFILE; fstring name; @@ -479,8 +479,7 @@ WERROR _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) regval_ctr_addvalue(®vals, "RefusePasswordChange", REG_DWORD, (const char*)&dwValue, sizeof(dwValue)); - val = dup_registry_value( - regval_ctr_specific_value( ®vals, 0 ) ); + val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); status = WERR_OK; @@ -522,7 +521,7 @@ WERROR _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) for ( i=0; fetch_reg_values_specific(regkey, &val, i); i++ ) { DEBUG(10,("_reg_info: Testing value [%s]\n", val->valuename)); - if ( StrCaseCmp( val->valuename, name ) == 0 ) { + if ( strequal( val->valuename, name ) ) { DEBUG(10,("_reg_info: Found match for value [%s]\n", name)); status = WERR_OK; break; @@ -533,7 +532,7 @@ WERROR _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) out: - init_reg_r_info(q_u->ptr_buf, r_u, val, status); + init_reg_r_query_value(q_u->ptr_buf, r_u, val, status); regval_ctr_destroy( ®vals ); free_registry_value( val ); @@ -1385,8 +1384,6 @@ done: if ( newparent != parent ) close_registry_key( p, &newparent_handle ); - /* rpc_reg.h says there is a POLICY_HDN in the reply...no idea if that is correct */ - return write_result ? WERR_OK : WERR_REG_IO_FAILURE; } -- cgit From 8387af752f81e26f1c141f6053bf6d106f0af5eb Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 24 Jun 2005 15:49:02 +0000 Subject: r7880: fix a typo and memleak on failures cases (patch from marcin) (This used to be commit 6ff0fa0b4385481f2212047d80ca17b55d996def) --- source3/rpc_server/srv_eventlog.c | 2 +- source3/rpc_server/srv_eventlog_nt.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c index 07aebcd2fa..65b10e8fe4 100644 --- a/source3/rpc_server/srv_eventlog.c +++ b/source3/rpc_server/srv_eventlog.c @@ -185,7 +185,7 @@ static BOOL api_eventlog_clear_eventlog(pipes_struct *p) struct api_struct api_eventlog_cmds[] = { {"EVENTLOG_OPENEVENTLOG", EVENTLOG_OPENEVENTLOG, api_eventlog_open_eventlog }, - {"EVENTLOG_CLOSEVENTLOG", EVENTLOG_CLOSEEVENTLOG, api_eventlog_close_eventlog }, + {"EVENTLOG_CLOSEEVENTLOG", EVENTLOG_CLOSEEVENTLOG, api_eventlog_close_eventlog }, {"EVENTLOG_GETNUMRECORDS", EVENTLOG_GETNUMRECORDS, api_eventlog_get_num_records }, {"EVENTLOG_GETOLDESTENTRY", EVENTLOG_GETOLDESTENTRY, api_eventlog_get_oldest_entry }, {"EVENTLOG_READEVENTLOG", EVENTLOG_READEVENTLOG, api_eventlog_read_eventlog }, diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index ea7512b58d..3c6e9a100f 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -169,12 +169,18 @@ WERROR _eventlog_open_eventlog(pipes_struct *p, DEBUG(10, ("_eventlog_open_eventlog: Using [%s] as the source log file.\n", info->source_log_file_name)); if(!create_policy_hnd(p, &(r_u->handle), free_eventlog_info, (void *)info)) + { + free_eventlog_info(info); return WERR_NOMEM; + } policy_handle_to_string(&r_u->handle, &info->handle_string); if(!(_eventlog_open_eventlog_hook(info))) + { + close_policy_hnd(p, &r_u->handle); return WERR_BADFILE; + } return WERR_OK; } -- cgit From 19ca97a70f6b7b41d251eaa76e4d3c980c6eedff Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 24 Jun 2005 20:25:18 +0000 Subject: r7882: Looks like a large patch - but what it actually does is make Samba safe for using our headers and linking with C++ modules. Stops us from using C++ reserved keywords in our code. Jeremy (This used to be commit 9506b8e145982b1160a2f0aee5c9b7a54980940a) --- source3/rpc_server/srv_eventlog_nt.c | 38 ++++++++++++++++++------------------ source3/rpc_server/srv_samr_util.c | 8 ++++---- source3/rpc_server/srv_spoolss_nt.c | 16 +++++++-------- 3 files changed, 31 insertions(+), 31 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 3c6e9a100f..a9b0c9bed8 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -713,10 +713,10 @@ static Eventlog_entry *_eventlog_read_package_entry(prs_struct *ps, Eventlog_entry *entry) { uint8 *offset; - Eventlog_entry *new = NULL; + Eventlog_entry *ee_new = NULL; - new = PRS_ALLOC_MEM(ps, Eventlog_entry, 1); - if(new == NULL) + ee_new = PRS_ALLOC_MEM(ps, Eventlog_entry, 1); + if(ee_new == NULL) return NULL; entry->data_record.sid_padding = ((4 - ((entry->data_record.source_name_len @@ -767,14 +767,14 @@ static Eventlog_entry *_eventlog_read_package_entry(prs_struct *ps, memcpy(offset, &(entry->data_record.user_data), entry->data_record.user_data_len); offset += entry->data_record.user_data_len; - memcpy(&(new->record), &entry->record, sizeof(Eventlog_record)); - memcpy(&(new->data_record), &entry->data_record, sizeof(Eventlog_data_record)); - new->data = entry->data; + memcpy(&(ee_new->record), &entry->record, sizeof(Eventlog_record)); + memcpy(&(ee_new->data_record), &entry->data_record, sizeof(Eventlog_data_record)); + ee_new->data = entry->data; - return new; + return ee_new; } -static BOOL _eventlog_add_record_to_resp(EVENTLOG_R_READ_EVENTLOG *r_u, Eventlog_entry *new) +static BOOL _eventlog_add_record_to_resp(EVENTLOG_R_READ_EVENTLOG *r_u, Eventlog_entry *ee_new) { Eventlog_entry *insert_point; @@ -782,8 +782,8 @@ static BOOL _eventlog_add_record_to_resp(EVENTLOG_R_READ_EVENTLOG *r_u, Eventlog if (NULL == insert_point) { - r_u->entry = new; - new->next = NULL; + r_u->entry = ee_new; + ee_new->next = NULL; } else { @@ -791,11 +791,11 @@ static BOOL _eventlog_add_record_to_resp(EVENTLOG_R_READ_EVENTLOG *r_u, Eventlog { insert_point=insert_point->next; } - new->next = NULL; - insert_point->next = new; + ee_new->next = NULL; + insert_point->next = ee_new; } r_u->num_records++; - r_u->num_bytes_in_resp += new->record.length; + r_u->num_bytes_in_resp += ee_new->record.length; return True; } @@ -806,7 +806,7 @@ WERROR _eventlog_read_eventlog(pipes_struct *p, { Eventlog_info *info = NULL; POLICY_HND *handle; - Eventlog_entry entry, *new; + Eventlog_entry entry, *ee_new; BOOL eof = False, eor = False; const char *direction = ""; uint32 num_records_read = 0; @@ -854,20 +854,20 @@ WERROR _eventlog_read_eventlog(pipes_struct *p, _eventlog_read_parse_line(buffer[i], &entry, &eor); if(eor == True) { - /* package new entry */ - if((new = _eventlog_read_package_entry(ps, q_u, r_u, &entry)) == NULL) + /* package ee_new entry */ + if((ee_new = _eventlog_read_package_entry(ps, q_u, r_u, &entry)) == NULL) { free(buffer); return WERR_NOMEM; } /* Now see if there is enough room to add */ - if(r_u->num_bytes_in_resp + new->record.length > q_u->max_read_size) + if(r_u->num_bytes_in_resp + ee_new->record.length > q_u->max_read_size) { - r_u->bytes_in_next_record = new->record.length; + r_u->bytes_in_next_record = ee_new->record.length; /* response would be too big to fit in client-size buffer */ break; } - _eventlog_add_record_to_resp(r_u, new); + _eventlog_add_record_to_resp(r_u, ee_new); ZERO_STRUCT(entry); eor=False; num_records_read = r_u->num_records - num_records_read; diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 61160ccaa0..66cf1cc46d 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -251,7 +251,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_LOGON_HOURS) { - pstring old, new; + pstring oldstr, newstr; DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); if (from->logon_divs != pdb_get_logon_divs(to)) { pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); @@ -263,9 +263,9 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) } DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); - pdb_sethexhours(old, pdb_get_hours(to)); - pdb_sethexhours(new, from->logon_hrs.hours); - if (!strequal(old, new)) { + pdb_sethexhours(oldstr, pdb_get_hours(to)); + pdb_sethexhours(newstr, from->logon_hrs.hours); + if (!strequal(oldstr, newstr)) { pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); } } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 972f6e9730..e05bfa1eaa 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1445,7 +1445,7 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode) return NULL; } - d->private = TALLOC_MEMDUP(ctx, devmode->private, devmode->driverextra); + d->dev_private = TALLOC_MEMDUP(ctx, devmode->dev_private, devmode->driverextra); return d; } @@ -1885,12 +1885,12 @@ BOOL convert_devicemode(const char *printername, const DEVICEMODE *devmode, * has a new one. JRA. */ - if ((devmode->driverextra != 0) && (devmode->private != NULL)) { - SAFE_FREE(nt_devmode->private); + if ((devmode->driverextra != 0) && (devmode->dev_private != NULL)) { + SAFE_FREE(nt_devmode->nt_dev_private); nt_devmode->driverextra=devmode->driverextra; - if((nt_devmode->private=SMB_MALLOC_ARRAY(uint8, nt_devmode->driverextra)) == NULL) + if((nt_devmode->nt_dev_private=SMB_MALLOC_ARRAY(uint8, nt_devmode->driverextra)) == NULL) return False; - memcpy(nt_devmode->private, devmode->private, nt_devmode->driverextra); + memcpy(nt_devmode->nt_dev_private, devmode->dev_private, nt_devmode->driverextra); } *pp_nt_devmode = nt_devmode; @@ -4089,7 +4089,7 @@ static void free_dev_mode(DEVICEMODE *dev) if (dev == NULL) return; - SAFE_FREE(dev->private); + SAFE_FREE(dev->dev_private); SAFE_FREE(dev); } @@ -4132,8 +4132,8 @@ static BOOL convert_nt_devicemode( DEVICEMODE *devmode, NT_DEVICEMODE *ntdevmode devmode->mediatype = ntdevmode->mediatype; devmode->dithertype = ntdevmode->dithertype; - if (ntdevmode->private != NULL) { - if ((devmode->private=(uint8 *)memdup(ntdevmode->private, ntdevmode->driverextra)) == NULL) + if (ntdevmode->nt_dev_private != NULL) { + if ((devmode->dev_private=(uint8 *)memdup(ntdevmode->nt_dev_private, ntdevmode->driverextra)) == NULL) return False; } -- cgit From b8e787bcac79b01d3f44d497517138b0c013be00 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 24 Jun 2005 22:34:40 +0000 Subject: r7890: * add Reg[SG]etKeySec() server stubs * merge a compile warning fix from trunk to SAMBA_3_0 (This used to be commit 71eb018a05c5012fbd42ba6817aabc0797d38ba1) --- source3/rpc_server/srv_reg.c | 55 ++++++++++++++++++++- source3/rpc_server/srv_reg_nt.c | 107 +++++++++++++++++++++++++++++++++++----- 2 files changed, 149 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index fec6702758..efff8e6722 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -512,6 +512,57 @@ static BOOL api_reg_delete_value(pipes_struct *p) return True; } + +/******************************************************************* + ******************************************************************/ + +static BOOL api_reg_get_key_sec(pipes_struct *p) +{ + REG_Q_GET_KEY_SEC q_u; + REG_R_GET_KEY_SEC r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_get_key_sec("", &q_u, data, 0)) + return False; + + r_u.status = _reg_get_key_sec(p, &q_u, &r_u); + + if(!reg_io_r_get_key_sec("", &r_u, rdata, 0)) + return False; + + return True; +} + + +/******************************************************************* + ******************************************************************/ + +static BOOL api_reg_set_key_sec(pipes_struct *p) +{ + REG_Q_SET_KEY_SEC q_u; + REG_R_SET_KEY_SEC r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!reg_io_q_set_key_sec("", &q_u, data, 0)) + return False; + + r_u.status = _reg_set_key_sec(p, &q_u, &r_u); + + if(!reg_io_r_set_key_sec("", &r_u, rdata, 0)) + return False; + + return True; +} + + /******************************************************************* array of \PIPE\reg operations ********************************************************************/ @@ -536,7 +587,9 @@ static struct api_struct api_reg_cmds[] = { "REG_CREATE_KEY" , REG_CREATE_KEY , api_reg_create_key }, { "REG_SET_VALUE" , REG_SET_VALUE , api_reg_set_value }, { "REG_DELETE_KEY" , REG_DELETE_KEY , api_reg_delete_key }, - { "REG_DELETE_VALUE" , REG_DELETE_VALUE , api_reg_delete_value } + { "REG_DELETE_VALUE" , REG_DELETE_VALUE , api_reg_delete_value }, + { "REG_GET_KEY_SEC" , REG_GET_KEY_SEC , api_reg_get_key_sec }, + { "REG_SET_KEY_SEC" , REG_SET_KEY_SEC , api_reg_set_key_sec } }; void reg_get_pipe_fns( struct api_struct **fns, int *n_fns ) diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 455ff3da40..3b25f11359 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -185,12 +185,12 @@ static WERROR open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY * result = WERR_BADFILE; goto done; } - + if ( !create_policy_hnd( p, hnd, free_regkey_info, regkey ) ) { - result = WERR_BADFILE; + result = WERR_BADFILE; goto done; } - + /* save the access mask */ regkey->access_granted = access_granted; @@ -317,7 +317,7 @@ WERROR _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) { /* close the policy handle */ - if ( !close_registry_key(p, &q_u->pol) ) + if (!close_registry_key(p, &q_u->pol)) return WERR_BADFID; return WERR_OK; @@ -405,14 +405,14 @@ WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY if ( !parent ) return WERR_BADFID; - + rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); /* check granted access first; what is the correct mask here? */ if ( !(parent->access_granted & (SEC_RIGHTS_ENUM_SUBKEYS|SEC_RIGHTS_CREATE_SUBKEY)) ) return WERR_ACCESS_DENIED; - + /* open the key first to get the appropriate REGISTRY_HOOK and then check the premissions */ @@ -503,19 +503,61 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL value_ascii = REG_PT_WINNT; break; } - value_length = push_ucs2(value, value, value_ascii, - sizeof(value), - STR_TERMINATE|STR_NOALIGN); - regval_ctr_addvalue(®vals, REGSTR_PRODUCTTYPE, REG_SZ, - value, value_length); + value_length = push_ucs2(value, value, value_ascii, sizeof(value), + STR_TERMINATE|STR_NOALIGN); + regval_ctr_addvalue(®vals, REGSTR_PRODUCTTYPE, REG_SZ, value, value_length); val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); status = WERR_OK; goto out; } + + /* "HKLM\\System\\CurrentControlSet\\Services\\Tcpip\\Parameters" */ + + if ( strequal( name, "Hostname") ) { + char *hname; + + hname = myhostname(); + value_length = push_ucs2( value, value, hname, sizeof(value), STR_TERMINATE|STR_NOALIGN); + regval_ctr_addvalue( ®vals, "Hostname",REG_SZ, value, value_length ); + + val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); + + status = WERR_OK; + + goto out; + } + if ( strequal( name, "Domain") ) { + fstring mydomainname; + + get_mydnsdomname( mydomainname ); + value_length = push_ucs2( value, value, mydomainname, sizeof(value), STR_TERMINATE|STR_NOALIGN); + regval_ctr_addvalue( ®vals, "Domain", REG_SZ, value, value_length ); + + val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); + + status = WERR_OK; + + goto out; + } + + /* "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" */ + + if ( strequal( name, "SystemRoot") ) { + value_length = push_ucs2( value, value, "c:\\windows", sizeof(value), STR_TERMINATE|STR_NOALIGN); + regval_ctr_addvalue( ®vals, "SystemRoot", REG_SZ, value, value_length ); + + val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); + + status = WERR_OK; + + goto out; + } + + /* else fall back to actually looking up the value */ for ( i=0; fetch_reg_values_specific(regkey, &val, i); i++ ) @@ -1377,6 +1419,8 @@ WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY write_result = store_reg_keys( newparent, &subkeys ); regsubkey_ctr_destroy( &subkeys ); + + result = write_result ? WERR_OK : WERR_REG_IO_FAILURE; done: /* close any intermediate key handles */ @@ -1384,7 +1428,7 @@ done: if ( newparent != parent ) close_registry_key( p, &newparent_handle ); - return write_result ? WERR_OK : WERR_REG_IO_FAILURE; + return result; } @@ -1424,3 +1468,42 @@ WERROR _reg_delete_value(pipes_struct *p, REG_Q_DELETE_VALUE *q_u, REG_R_DELETE return WERR_OK; } +/******************************************************************* + ********************************************************************/ + +WERROR _reg_get_key_sec(pipes_struct *p, REG_Q_GET_KEY_SEC *q_u, REG_R_GET_KEY_SEC *r_u) +{ + REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); + + if ( !key ) + return WERR_BADFID; + + /* access checks first */ + + if ( !(key->access_granted & STD_RIGHT_READ_CONTROL_ACCESS) ) + return WERR_ACCESS_DENIED; + + + + return WERR_ACCESS_DENIED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _reg_set_key_sec(pipes_struct *p, REG_Q_SET_KEY_SEC *q_u, REG_R_SET_KEY_SEC *r_u) +{ + REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); + + if ( !key ) + return WERR_BADFID; + + /* access checks first */ + + if ( !(key->access_granted & STD_RIGHT_WRITE_DAC_ACCESS) ) + return WERR_ACCESS_DENIED; + + return WERR_ACCESS_DENIED; +} + + -- cgit From bd509a81cb6c295988a1626adfe394c9778c005e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 25 Jun 2005 17:31:40 +0000 Subject: r7908: * change REGISTRY_HOOK api to use const (fix compiler warning in init_registry_data() * Add means of storing registry values in registry.tdb * add builtin_registry_values[] array for REG_DWORD and REG_SZ values needed during startup * Finish up RegDeleteValue() and RegSetValue() * Finish up regdb_store_reg_values() and regdb_fetch_reg_values() I can now create and retrieve values using regedit.exe on Win2k. bin/net -S rain -U% rpc registry enumerate 'hklm\software\samba' Valuename = Version Type = REG_SZ Data = 3.0.20 Next is to do the virtual writes in reg_printing.c and I'll be done with Print Migrator (yeah! finally) (This used to be commit 3d837e58db9ded64d6b85f047012c7d487be4627) --- source3/rpc_server/srv_reg_nt.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 3b25f11359..0e4c49aa48 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -464,6 +464,7 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL regval_ctr_init( ®vals ); + /* FIXME!!! Move these to a dynmanic lookup in the reg_fetch_values() */ /* couple of hard coded registry values */ if ( strequal(name, "RefusePasswordChange") ) { @@ -544,20 +545,6 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL goto out; } - /* "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" */ - - if ( strequal( name, "SystemRoot") ) { - value_length = push_ucs2( value, value, "c:\\windows", sizeof(value), STR_TERMINATE|STR_NOALIGN); - regval_ctr_addvalue( ®vals, "SystemRoot", REG_SZ, value, value_length ); - - val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); - - status = WERR_OK; - - goto out; - } - - /* else fall back to actually looking up the value */ for ( i=0; fetch_reg_values_specific(regkey, &val, i); i++ ) @@ -1311,6 +1298,7 @@ WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); REGVAL_CTR values; BOOL write_result; + fstring valuename; if ( !key ) return WERR_BADFID; @@ -1320,12 +1308,16 @@ WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r if ( !(key->access_granted & SEC_RIGHTS_SET_VALUE) ) return WERR_ACCESS_DENIED; + rpcstr_pull( valuename, q_u->name.string->buffer, sizeof(valuename), q_u->name.string->uni_str_len*2, 0 ); + + regval_ctr_init( &values ); /* lookup the current values and add the new one */ fetch_reg_values( key, &values ); - /* FIXME!!!! regval_ctr_addvalue( &values, .... ); */ + + regval_ctr_addvalue( &values, valuename, q_u->type, q_u->value.buffer, q_u->value.buf_len ); /* now write to the registry backend */ @@ -1440,7 +1432,8 @@ WERROR _reg_delete_value(pipes_struct *p, REG_Q_DELETE_VALUE *q_u, REG_R_DELETE REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); REGVAL_CTR values; BOOL write_result; - + fstring valuename; + if ( !key ) return WERR_BADFID; @@ -1448,13 +1441,16 @@ WERROR _reg_delete_value(pipes_struct *p, REG_Q_DELETE_VALUE *q_u, REG_R_DELETE if ( !(key->access_granted & SEC_RIGHTS_SET_VALUE) ) return WERR_ACCESS_DENIED; - + + rpcstr_pull( valuename, q_u->name.string->buffer, sizeof(valuename), q_u->name.string->uni_str_len*2, 0 ); + regval_ctr_init( &values ); /* lookup the current values and add the new one */ fetch_reg_values( key, &values ); - /* FIXME!!!! regval_ctr_delval( &values, .... ); */ + + regval_ctr_delvalue( &values, valuename ); /* now write to the registry backend */ -- cgit From ab0033d40a369a7fc16496cb9773f3436cb268ae Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 27 Jun 2005 03:40:03 +0000 Subject: r7938: * move the hardcoded registry value names from _reg_query_value() to a thin layer in fetch_reg_values(). Not entirely efficient seeing as the the dynamic value paths are stored in an unsorted array but it is one strequal() per path. If this was really big it should be worked into the reghook_cache(). (This used to be commit 63b81ad3cb484090a181fbd13e04922a5c17e7d9) --- source3/rpc_server/srv_reg_nt.c | 92 +---------------------------------------- 1 file changed, 1 insertion(+), 91 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 0e4c49aa48..4603bb077b 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -443,9 +443,6 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL { WERROR status = WERR_BADFILE; fstring name; - const char *value_ascii = ""; - fstring value; - int value_length; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); REGISTRY_VALUE *val = NULL; REGVAL_CTR regvals; @@ -463,89 +460,6 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL DEBUG(5,("reg_info: looking up value: [%s]\n", name)); regval_ctr_init( ®vals ); - - /* FIXME!!! Move these to a dynmanic lookup in the reg_fetch_values() */ - /* couple of hard coded registry values */ - - if ( strequal(name, "RefusePasswordChange") ) { - uint32 dwValue; - - if ( (val = SMB_MALLOC_P(REGISTRY_VALUE)) == NULL ) { - DEBUG(0,("_reg_info: malloc() failed!\n")); - return WERR_NOMEM; - } - - if (!account_policy_get(AP_REFUSE_MACHINE_PW_CHANGE, &dwValue)) - dwValue = 0; - regval_ctr_addvalue(®vals, "RefusePasswordChange", - REG_DWORD, - (const char*)&dwValue, sizeof(dwValue)); - val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); - - status = WERR_OK; - - goto out; - } - - if ( strequal(name, REGSTR_PRODUCTTYPE) ) { - /* This makes the server look like a member server to clients */ - /* which tells clients that we have our own local user and */ - /* group databases and helps with ACL support. */ - - switch (lp_server_role()) { - case ROLE_DOMAIN_PDC: - case ROLE_DOMAIN_BDC: - value_ascii = REG_PT_LANMANNT; - break; - case ROLE_STANDALONE: - value_ascii = REG_PT_SERVERNT; - break; - case ROLE_DOMAIN_MEMBER: - value_ascii = REG_PT_WINNT; - break; - } - - value_length = push_ucs2(value, value, value_ascii, sizeof(value), - STR_TERMINATE|STR_NOALIGN); - regval_ctr_addvalue(®vals, REGSTR_PRODUCTTYPE, REG_SZ, value, value_length); - val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); - - status = WERR_OK; - - goto out; - } - - /* "HKLM\\System\\CurrentControlSet\\Services\\Tcpip\\Parameters" */ - - if ( strequal( name, "Hostname") ) { - char *hname; - - hname = myhostname(); - value_length = push_ucs2( value, value, hname, sizeof(value), STR_TERMINATE|STR_NOALIGN); - regval_ctr_addvalue( ®vals, "Hostname",REG_SZ, value, value_length ); - - val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); - - status = WERR_OK; - - goto out; - } - - if ( strequal( name, "Domain") ) { - fstring mydomainname; - - get_mydnsdomname( mydomainname ); - value_length = push_ucs2( value, value, mydomainname, sizeof(value), STR_TERMINATE|STR_NOALIGN); - regval_ctr_addvalue( ®vals, "Domain", REG_SZ, value, value_length ); - - val = dup_registry_value( regval_ctr_specific_value( ®vals, 0 ) ); - - status = WERR_OK; - - goto out; - } - - /* else fall back to actually looking up the value */ for ( i=0; fetch_reg_values_specific(regkey, &val, i); i++ ) { @@ -559,8 +473,6 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL free_registry_value( val ); } - -out: init_reg_r_query_value(q_u->ptr_buf, r_u, val, status); regval_ctr_destroy( ®vals ); @@ -880,7 +792,7 @@ static int validate_reg_filename( pstring fname ) } /******************************************************************* - Note: topkeypaty is the *full* path that this *key will be + Note: topkeypat is the *full* path that this *key will be loaded into (including the name of the key) ********************************************************************/ @@ -1479,8 +1391,6 @@ WERROR _reg_get_key_sec(pipes_struct *p, REG_Q_GET_KEY_SEC *q_u, REG_R_GET_KEY_ if ( !(key->access_granted & STD_RIGHT_READ_CONTROL_ACCESS) ) return WERR_ACCESS_DENIED; - - return WERR_ACCESS_DENIED; } -- cgit From bf547ff1ad4120f898e89fd75ec94f577a0fc84d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 28 Jun 2005 19:25:48 +0000 Subject: r7981: MS-DFS tidyup patches from James Peach . Looking forward to the day he can commit these himself :-). Jeremy. (This used to be commit 12ff2978295a84fe6177af129c495a0021befacc) --- source3/rpc_server/srv_dfs.c | 4 +--- source3/rpc_server/srv_dfs_nt.c | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 6c35917e61..42be7c5a35 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -27,10 +27,8 @@ #include "includes.h" #include "nterr.h" -#define MAX_MSDFS_JUNCTIONS 256 - #undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV +#define DBGC_CLASS DBGC_MSDFS /********************************************************************** api_dfs_exist diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 7334eef85b..938b01540f 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -27,9 +27,7 @@ #include "nterr.h" #undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -#define MAX_MSDFS_JUNCTIONS 256 +#define DBGC_CLASS DBGC_MSDFS /* This function does not return a WERROR or NTSTATUS code but rather 1 if dfs exists, or 0 otherwise. */ @@ -321,7 +319,7 @@ WERROR _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u) struct junction_map jn[MAX_MSDFS_JUNCTIONS]; int num_jn = 0; - num_jn = enum_msdfs_links(jn); + num_jn = enum_msdfs_links(jn, ARRAY_SIZE(jn)); vfs_ChDir(p->conn,p->conn->connectpath); DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", num_jn, level)); -- cgit From e4a11ba5853ff323e3fcb989dfdbf7e7c11717ec Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 28 Jun 2005 22:39:18 +0000 Subject: r7987: map generic bits to specific bits in open requests (This used to be commit 7764e8a6775ead942d8ceac89cbcb947136bf7fa) --- source3/rpc_server/srv_reg_nt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 4603bb077b..158888967b 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -41,7 +41,7 @@ /* no idea if this is correct, just use the file access bits for now */ -struct generic_mapping reg_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; +static struct generic_mapping reg_generic_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; /******************************************************************** ********************************************************************/ @@ -51,6 +51,7 @@ NTSTATUS registry_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, { NTSTATUS result; + se_map_generic( &access_desired, ®_generic_map ); se_access_check( sec_desc, token, access_desired, access_granted, &result ); return result; @@ -1020,12 +1021,12 @@ static WERROR make_default_reg_sd( TALLOC_CTX *ctx, SEC_DESC **psd ) /* basic access for Everyone */ - init_sec_access(&mask, reg_map.generic_execute | reg_map.generic_read ); + init_sec_access(&mask, reg_generic_map.generic_execute | reg_generic_map.generic_read ); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /* add Full Access 'BUILTIN\Administrators' */ - init_sec_access(&mask, reg_map.generic_all); + init_sec_access(&mask, reg_generic_map.generic_all); sid_copy(&adm_sid, &global_sid_Builtin); sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); -- cgit From 270b90e25f2ec5fcb1283588a9e605b7228e0e41 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 29 Jun 2005 16:35:32 +0000 Subject: r7995: * privileges are local except when they're *not* printmig.exe assumes that the LUID of the SeBackupPrivlege on the target server matches the LUID of the privilege on the local client. Even though an LUID is never guaranteed to be the same across reboots. How *awful*! My cat could write better code! (more on my cat later....) * Set the privelege LUID in the global PRIVS[] array * Rename RegCreateKey() to RegCreateKeyEx() to better match MSDN * Rename the unknown field in RegCreateKeyEx() to disposition (guess according to MSDN) * Add the capability to define REG_TDB_ONLY for using the reg_db.c functions and stress the RegXXX() rpc functions. (This used to be commit 0d6352da4800aabc04dfd7c65a6afe6af7cd2d4b) --- source3/rpc_server/srv_lsa_nt.c | 2 +- source3/rpc_server/srv_reg.c | 14 +++++++------- source3/rpc_server/srv_reg_nt.c | 26 ++++++++++++++------------ source3/rpc_server/srv_spoolss_nt.c | 7 ++++--- 4 files changed, 26 insertions(+), 23 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index b724508e0b..15d420538e 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1544,7 +1544,7 @@ NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, L unistr2_to_ascii(name, &q_u->privname.unistring, sizeof(name)); - DEBUG(10,("_lsa_priv_get_dispname: name = %s\n", name)); + DEBUG(10,("_lsa_lookup_priv_value: name = %s\n", name)); if ( !se_priv_from_name( name, &mask ) ) return NT_STATUS_NO_SUCH_PRIVILEGE; diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index efff8e6722..871b1a9f12 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -419,22 +419,22 @@ static BOOL api_reg_save_key(pipes_struct *p) /******************************************************************* ******************************************************************/ -static BOOL api_reg_create_key(pipes_struct *p) +static BOOL api_reg_create_key_ex(pipes_struct *p) { - REG_Q_CREATE_KEY q_u; - REG_R_CREATE_KEY r_u; + REG_Q_CREATE_KEY_EX q_u; + REG_R_CREATE_KEY_EX r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!reg_io_q_create_key("", &q_u, data, 0)) + if(!reg_io_q_create_key_ex("", &q_u, data, 0)) return False; - r_u.status = _reg_create_key(p, &q_u, &r_u); + r_u.status = _reg_create_key_ex(p, &q_u, &r_u); - if(!reg_io_r_create_key("", &r_u, rdata, 0)) + if(!reg_io_r_create_key_ex("", &r_u, rdata, 0)) return False; return True; @@ -584,7 +584,7 @@ static struct api_struct api_reg_cmds[] = { "REG_GETVERSION" , REG_GETVERSION , api_reg_getversion }, { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key }, { "REG_RESTORE_KEY" , REG_RESTORE_KEY , api_reg_restore_key }, - { "REG_CREATE_KEY" , REG_CREATE_KEY , api_reg_create_key }, + { "REG_CREATE_KEY_EX" , REG_CREATE_KEY_EX , api_reg_create_key_ex }, { "REG_SET_VALUE" , REG_SET_VALUE , api_reg_set_value }, { "REG_DELETE_KEY" , REG_DELETE_KEY , api_reg_delete_key }, { "REG_DELETE_VALUE" , REG_DELETE_VALUE , api_reg_delete_value }, diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 158888967b..7170c0a301 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -30,17 +30,10 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -#define REGSTR_PRODUCTTYPE "ProductType" -#define REG_PT_WINNT "WinNT" -#define REG_PT_LANMANNT "LanmanNT" -#define REG_PT_SERVERNT "ServerNT" - #define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ ((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) -/* no idea if this is correct, just use the file access bits for now */ - static struct generic_mapping reg_generic_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; /******************************************************************** @@ -266,9 +259,7 @@ static BOOL get_subkey_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *m } /******************************************************************** - retrieve information about the values. We don't store values - here. The registry tdb is intended to be a frontend to oether - Samba tdb's (such as ntdrivers.tdb). + retrieve information about the values. *******************************************************************/ static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum, @@ -294,7 +285,7 @@ static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum, for ( i=0; ivaluename)+1 ); + lenmax = MAX(lenmax, val->valuename ? strlen(val->valuename)+1 : 0 ); sizemax = MAX(sizemax, val->size ); val = regval_ctr_specific_value( &values, i ); @@ -1106,7 +1097,7 @@ WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) /******************************************************************* ********************************************************************/ -WERROR _reg_create_key(pipes_struct *p, REG_Q_CREATE_KEY *q_u, REG_R_CREATE_KEY *r_u) +WERROR _reg_create_key_ex(pipes_struct *p, REG_Q_CREATE_KEY_EX *q_u, REG_R_CREATE_KEY_EX *r_u) { REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->handle); REGISTRY_KEY *newparent; @@ -1223,6 +1214,12 @@ WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r rpcstr_pull( valuename, q_u->name.string->buffer, sizeof(valuename), q_u->name.string->uni_str_len*2, 0 ); + /* verify the name */ + + if ( !*valuename ) + return WERR_INVALID_PARAM; + + DEBUG(8,("_reg_set_value: Setting value for [%s:%s]\n", key->name, valuename)); regval_ctr_init( &values ); @@ -1357,6 +1354,11 @@ WERROR _reg_delete_value(pipes_struct *p, REG_Q_DELETE_VALUE *q_u, REG_R_DELETE rpcstr_pull( valuename, q_u->name.string->buffer, sizeof(valuename), q_u->name.string->uni_str_len*2, 0 ); + if ( !*valuename ) + return WERR_INVALID_PARAM; + + DEBUG(8,("_reg_delete_value: Setting value for [%s:%s]\n", key->name, valuename)); + regval_ctr_init( &values ); /* lookup the current values and add the new one */ diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e05bfa1eaa..12e8e2bd41 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2211,7 +2211,8 @@ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printe uint32 *needed, uint32 in_size ) { REGISTRY_VALUE *val; - int size, data_len; + uint32 size; + int data_len; if ( !(val = get_printer_data( printer->info_2, key, value)) ) return WERR_BADFILE; @@ -8030,7 +8031,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S result = WERR_NOMEM; goto done; } - data_len = (size_t)regval_size(val); + data_len = regval_size(val); memcpy( *data_out, regval_data_p(val), data_len ); *out_data_len = data_len; } @@ -9250,7 +9251,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ int i; REGISTRY_VALUE *val; char *value_name; - int data_len; + uint32 data_len; DEBUG(4,("_spoolss_enumprinterdataex\n")); -- cgit From d966feb9bcb744881ce8ee687ecb2a01be808dbf Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 30 Jun 2005 15:19:54 +0000 Subject: r8019: Better give a hint that we are failing share-manipulation due to missing scripts. Guenther (This used to be commit 1f17b4f45e966cba83f6ad48e5017cbaa5b58bdf) --- source3/rpc_server/srv_srvsvc_nt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 91f0cefa98..f8124031ce 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1634,8 +1634,10 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) ) { - if (!lp_change_share_cmd() || !*lp_change_share_cmd()) + if (!lp_change_share_cmd() || !*lp_change_share_cmd()) { + DEBUG(10,("_srv_net_share_set_info: No change share command\n")); return WERR_ACCESS_DENIED; + } slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment); @@ -1870,8 +1872,10 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S if (user.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; - if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) + if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) { + DEBUG(10,("_srv_net_share_del: No delete share command\n")); return WERR_ACCESS_DENIED; + } slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", lp_delete_share_cmd(), dyn_CONFIGFILE, lp_servicename(snum)); -- cgit From c5a51f02732b75bc7ee1ca7252a4817b075a67b7 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 30 Jun 2005 20:16:16 +0000 Subject: r8027: driver information is now back via winreg (This used to be commit f0a1c6b9cec28d5b4aa8a1a2f9b34d1f13113a6c) --- source3/rpc_server/srv_reg_nt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 7170c0a301..db199634c5 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -490,11 +490,15 @@ WERROR _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_ if ( !regkey ) return WERR_BADFID; - if ( !get_subkey_information( regkey, &r_u->num_subkeys, &r_u->max_subkeylen ) ) + if ( !get_subkey_information( regkey, &r_u->num_subkeys, &r_u->max_subkeylen ) ) { + DEBUG(0,("_reg_query_key: get_subkey_information() failed!\n")); return WERR_ACCESS_DENIED; + } - if ( !get_value_information( regkey, &r_u->num_values, &r_u->max_valnamelen, &r_u->max_valbufsize ) ) + if ( !get_value_information( regkey, &r_u->num_values, &r_u->max_valnamelen, &r_u->max_valbufsize ) ) { + DEBUG(0,("_reg_query_key: get_value_information() failed!\n")); return WERR_ACCESS_DENIED; + } r_u->sec_desc = 0x00000078; /* size for key's sec_desc */ -- cgit From c296f858ef61acd6c749db768670453f436f78f2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 2 Jul 2005 01:23:21 +0000 Subject: r8066: * had to modify the printer data storage slightly in ntprinters.tdb when packing values. It is a compatible change though and will not require a tdb version upgrade * Can successfully create new printer subkeys via winreg that are immediately available via spoolss calls. Still cannot delete keys yet though. That comes next. (This used to be commit 00bce2b3bb78a44842a258b1737076281297d247) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 12e8e2bd41..19ef3700e6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -583,7 +583,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) DEBUGADD(10, ("printername: %s\n", printername)); - free_a_printer( &printer, 2); + free_a_printer( &printer, 2); } if ( !found ) { -- cgit From af8a691db11a5072865f8b03fd1cbd3aab5cb6d7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 8 Jul 2005 04:51:27 +0000 Subject: r8219: Merge the new open code from HEAD to 3.0. Haven't yet run the torture tests on this as it's very late NY time (just wanted to get this work into the tree). I'll test this over the weekend.... Jerry - in looking at the difference between the two trees there seem to be some printing/ntprinting.c and registry changes we might want to examine to try keep in sync. Jeremy. (This used to be commit c7fe18761e2c753afbffd3a78abff46472a9b8eb) --- source3/rpc_server/srv_srvsvc_nt.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index f8124031ce..c3fd53a384 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1976,8 +1976,6 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC files_struct *fsp = NULL; SMB_STRUCT_STAT st; BOOL bad_path; - int access_mode; - int action; NTSTATUS nt_status; struct current_user user; connection_struct *conn = NULL; @@ -2025,15 +2023,16 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC goto error_exit; } - fsp = open_file_shared(conn, filename, &st, SET_DENY_MODE(DENY_NONE)|SET_OPEN_MODE(DOS_OPEN_RDONLY), - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, INTERNAL_OPEN_ONLY, - &access_mode, &action); - + fsp = open_file_stat(conn, filename, &st); if (!fsp) { /* Perhaps it is a directory */ if (errno == EISDIR) - fsp = open_directory(conn, filename, &st,FILE_READ_ATTRIBUTES,0, - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), &action); + fsp = open_directory(conn, filename, &st, + READ_CONTROL_ACCESS, + FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_OPEN, + 0, + NULL); if (!fsp) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); @@ -2092,8 +2091,6 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ files_struct *fsp = NULL; SMB_STRUCT_STAT st; BOOL bad_path; - int access_mode; - int action; NTSTATUS nt_status; struct current_user user; connection_struct *conn = NULL; @@ -2142,15 +2139,17 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ } - fsp = open_file_shared(conn, filename, &st, SET_DENY_MODE(DENY_NONE)|SET_OPEN_MODE(DOS_OPEN_RDWR), - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, INTERNAL_OPEN_ONLY, - &access_mode, &action); + fsp = open_file_stat(conn, filename, &st); if (!fsp) { /* Perhaps it is a directory */ if (errno == EISDIR) - fsp = open_directory(conn, filename, &st,FILE_READ_ATTRIBUTES,0, - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), &action); + fsp = open_directory(conn, filename, &st, + FILE_READ_ATTRIBUTES, + FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_OPEN, + 0, + NULL); if (!fsp) { DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename)); @@ -2178,11 +2177,13 @@ error_exit: close_file(fsp, True); } - if (became_user) + if (became_user) { unbecome_user(); + } - if (conn) + if (conn) { close_cnum(conn, user.vuid); + } return r_u->status; } -- cgit From 18609ce1af72802accd1e5e85689db69e8b0c914 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 11 Jul 2005 16:55:10 +0000 Subject: r8322: * get RegSetValue() working for printer subkey values (not immediate values below the key yet. (This used to be commit a872ea5f0e29f7b585574a56b52a5eb44cb92278) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 19ef3700e6..0329471d49 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2261,7 +2261,7 @@ static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char Internal routine for storing printerdata ***************************************************************************/ -static WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value, +WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value, uint32 type, uint8 *data, int real_len ) { delete_printer_data( printer->info_2, key, value ); -- cgit From e574081ad93ec5f5eb121436a889f64294fa290d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 11 Jul 2005 18:27:22 +0000 Subject: r8324: * initial cut at creating printers via the registry API Need to add delete_key support (This used to be commit 9a27f7181adca10f60c47d342a51dec34321e12b) --- source3/rpc_server/srv_spoolss_nt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0329471d49..b5dd459462 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6033,7 +6033,7 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) /**************************************************************************** ****************************************************************************/ -static BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) +BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) { char *cmd = lp_addprinter_cmd(); char **qlines; @@ -6043,7 +6043,7 @@ static BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printe int fd; fstring remote_machine = "%m"; SE_PRIV se_printop = SE_PRINT_OPERATOR; - BOOL is_print_op; + BOOL is_print_op = False; standard_sub_basic(current_user_info.smb_name, remote_machine,sizeof(remote_machine)); @@ -6052,7 +6052,8 @@ static BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printe printer->info_2->portname, printer->info_2->drivername, printer->info_2->location, printer->info_2->comment, remote_machine); - is_print_op = user_has_privileges( token, &se_printop ); + if ( token ) + is_print_op = user_has_privileges( token, &se_printop ); DEBUG(10,("Running [%s]\n", command)); -- cgit From f2ff8bed26cc8b0f2fffbc41a605a8f95163a382 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 11 Jul 2005 18:59:54 +0000 Subject: r8326: factor out the delete printer code to a delete_printer_hook() for reuse (This used to be commit 0689851a90fbd91ff30f6e2afc05d141f6ce082d) --- source3/rpc_server/srv_spoolss_nt.c | 109 ++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 56 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b5dd459462..5fbb6d91b0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -345,6 +345,58 @@ static BOOL close_printer_handle(pipes_struct *p, POLICY_HND *hnd) return True; } +/**************************************************************************** + Delete a printer given a handle. +****************************************************************************/ +WERROR delete_printer_hook( NT_USER_TOKEN *token, const char *sharename ) +{ + char *cmd = lp_deleteprinter_cmd(); + pstring command; + int ret; + SE_PRIV se_printop = SE_PRINT_OPERATOR; + BOOL is_print_op = False; + + /* can't fail if we don't try */ + + if ( !*cmd ) + return WERR_OK; + + pstr_sprintf(command, "%s \"%s\"", cmd, sharename); + + if ( token ) + is_print_op = user_has_privileges( token, &se_printop ); + + DEBUG(10,("Running [%s]\n", command)); + + /********** BEGIN SePrintOperatorPrivlege BLOCK **********/ + + if ( is_print_op ) + become_root(); + + if ( (ret = smbrun(command, NULL)) == 0 ) { + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + } + + if ( is_print_op ) + unbecome_root(); + + /********** END SePrintOperatorPrivlege BLOCK **********/ + + DEBUGADD(10,("returned [%d]\n", ret)); + + if (ret != 0) + return WERR_BADFID; /* What to return here? */ + + /* go ahead and re-read the services immediately */ + reload_services( False ); + + if ( lp_servicenumber( sharename ) < 0 ) + return WERR_ACCESS_DENIED; + + return WERR_OK; +} + /**************************************************************************** Delete a printer given a handle. ****************************************************************************/ @@ -369,18 +421,6 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) DEBUG(3, ("delete_printer_handle: denied by handle\n")); return WERR_ACCESS_DENIED; } - -#if 0 - /* Check calling user has permission to delete printer. Note that - since we set the snum parameter to -1 only administrators can - delete the printer. This stops people with the Full Control - permission from deleting the printer. */ - - if (!print_access_check(NULL, -1, PRINTER_ACCESS_ADMINISTER)) { - DEBUG(3, ("printer delete denied by security descriptor\n")); - return WERR_ACCESS_DENIED; - } -#endif /* this does not need a become root since the access check has been done on the handle already */ @@ -390,50 +430,7 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) return WERR_BADFID; } - /* the delete printer script shoudl be run as root if the user has perms */ - - if (*lp_deleteprinter_cmd()) { - - char *cmd = lp_deleteprinter_cmd(); - pstring command; - int ret; - SE_PRIV se_printop = SE_PRINT_OPERATOR; - BOOL is_print_op; - - pstr_sprintf(command, "%s \"%s\"", cmd, Printer->sharename); - - is_print_op = user_has_privileges( p->pipe_user.nt_user_token, &se_printop ); - - DEBUG(10,("Running [%s]\n", command)); - - /********** BEGIN SePrintOperatorPrivlege BLOCK **********/ - - if ( is_print_op ) - become_root(); - - if ( (ret = smbrun(command, NULL)) == 0 ) { - /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); - } - - if ( is_print_op ) - unbecome_root(); - - /********** END SePrintOperatorPrivlege BLOCK **********/ - - DEBUGADD(10,("returned [%d]\n", ret)); - - if (ret != 0) - return WERR_BADFID; /* What to return here? */ - - /* go ahead and re-read the services immediately */ - reload_services( False ); - - if ( lp_servicenumber( Printer->sharename ) < 0 ) - return WERR_ACCESS_DENIED; - } - - return WERR_OK; + return delete_printer_hook( p->pipe_user.nt_user_token, Printer->sharename ); } /**************************************************************************** -- cgit From e7c48884a5c7e1f88ce2decf7d12db338ff8995e Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Wed, 13 Jul 2005 20:04:26 +0000 Subject: r8432: Fix #2077 - login to trusted domain doesn't allow home drive map and login scripts to be executed. We were filling in our name as the server which processed the login, even when it was done by a trusted DC. Thanks to John Janosik for the fix. (This used to be commit 0446319a3b8096df385978449ffaa231bc5cfd0c) --- source3/rpc_server/srv_netlog_nt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index a6fe9ef31a..7880a724b5 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -764,8 +764,13 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return NT_STATUS_UNSUCCESSFUL; } - pstrcpy(my_name, global_myname()); - + + if(server_info->login_server) { + pstrcpy(my_name, server_info->login_server); + } else { + pstrcpy(my_name, global_myname()); + } + if (!NT_STATUS_IS_OK(status = nt_token_to_group_list(p->mem_ctx, &domain_sid, -- cgit From 6fe54515435e351ba958886cb9a7175c436ef88d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 15 Jul 2005 14:26:11 +0000 Subject: r8501: * disable printer handle object cache (was mostly used for NT4 clients enumerating printer data on slow CPUs) * fix pinter and secdesc record upgrade to normalize the key (rev'd printer tdb version) * fixed problem that was normalizing the printername name field in general, this should fix the issues upgrading print servers from 3.0.14a to 3.0.20 (This used to be commit d07179de2f2a6eb1d13d0e25ac10de1a21475559) --- source3/rpc_server/srv_spoolss_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5fbb6d91b0..66804028e1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -274,6 +274,7 @@ static Printer_entry *find_printer_index_by_hnd(pipes_struct *p, POLICY_HND *hnd return find_printer; } +#ifdef ENABLE_PRINT_HND_OBJECT_CACHE /**************************************************************************** look for a printer object cached on an open printer handle ****************************************************************************/ @@ -327,6 +328,8 @@ void invalidate_printer_hnd_cache( char *printername ) return; } +#endif + /**************************************************************************** Close printer index by handle. ****************************************************************************/ @@ -1213,6 +1216,7 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz return; } +#ifdef ENABLE_PRINT_HND_OBJECT_CACHE /******************************************************************** callback to MSG_PRINTER_CHANGED. When a printer is changed by one smbd, all of processes must clear their printer cache immediately. @@ -1228,6 +1232,7 @@ void receive_printer_mod_msg(int msg_type, pid_t src, void *buf, size_t len) invalidate_printer_hnd_cache( printername ); } +#endif /******************************************************************** Send a message to ourself about new driver being installed -- cgit From 263a51cd62815b568d0d2053ee29cdd77428ba31 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 19 Jul 2005 00:59:25 +0000 Subject: r8564: Sometimes we're too dumb to live... Fix samr calls where we were using USER_INFO_XX structs and functions where XX was sometimes in hex and sometimes in decimal. Now it's all in decimal (should be no functionality change). Jeremy. (This used to be commit 84651aca04cbcbf50ab2e78333cc9d9e49dd92f5) --- source3/rpc_server/srv_samr_nt.c | 70 ++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9b98d4cb16..2e73db2807 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1411,10 +1411,10 @@ static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_S return NT_STATUS_OK; } /************************************************************************* - get_user_info_10. Safe. Only gives out acb bits. + get_user_info_16. Safe. Only gives out acb bits. *************************************************************************/ -static NTSTATUS get_user_info_10(TALLOC_CTX *mem_ctx, SAM_USER_INFO_10 *id10, DOM_SID *user_sid) +static NTSTATUS get_user_info_16(TALLOC_CTX *mem_ctx, SAM_USER_INFO_16 *id16, DOM_SID *user_sid) { SAM_ACCOUNT *smbpass=NULL; BOOL ret; @@ -1437,8 +1437,8 @@ static NTSTATUS get_user_info_10(TALLOC_CTX *mem_ctx, SAM_USER_INFO_10 *id10, DO DEBUG(3,("User:[%s]\n", pdb_get_username(smbpass) )); - ZERO_STRUCTP(id10); - init_sam_user_info10(id10, pdb_get_acct_ctrl(smbpass) ); + ZERO_STRUCTP(id16); + init_sam_user_info16(id16, pdb_get_acct_ctrl(smbpass) ); pdb_free_sam(&smbpass); @@ -1446,12 +1446,12 @@ static NTSTATUS get_user_info_10(TALLOC_CTX *mem_ctx, SAM_USER_INFO_10 *id10, DO } /************************************************************************* - get_user_info_12. OK - this is the killer as it gives out password info. + get_user_info_18. OK - this is the killer as it gives out password info. Ensure that this is only allowed on an encrypted connection with a root user. JRA. *************************************************************************/ -static NTSTATUS get_user_info_12(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_INFO_12 * id12, DOM_SID *user_sid) +static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_INFO_18 * id18, DOM_SID *user_sid) { SAM_ACCOUNT *smbpass=NULL; BOOL ret; @@ -1488,8 +1488,8 @@ static NTSTATUS get_user_info_12(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_ return NT_STATUS_ACCOUNT_DISABLED; } - ZERO_STRUCTP(id12); - init_sam_user_info12(id12, pdb_get_lanman_passwd(smbpass), pdb_get_nt_passwd(smbpass)); + ZERO_STRUCTP(id18); + init_sam_user_info18(id18, pdb_get_lanman_passwd(smbpass), pdb_get_nt_passwd(smbpass)); pdb_free_sam(&smbpass); @@ -1601,7 +1601,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ ctr->switch_value = q_u->switch_value; switch (q_u->switch_value) { - case 0x07: + case 7: ctr->info.id7 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_7); if (ctr->info.id7 == NULL) return NT_STATUS_NO_MEMORY; @@ -1609,18 +1609,18 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ if (!NT_STATUS_IS_OK(r_u->status = get_user_info_7(p->mem_ctx, ctr->info.id7, &info->sid))) return r_u->status; break; - case 0x10: - ctr->info.id10 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_10); - if (ctr->info.id10 == NULL) + case 16: + ctr->info.id16 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_16); + if (ctr->info.id16 == NULL) return NT_STATUS_NO_MEMORY; - if (!NT_STATUS_IS_OK(r_u->status = get_user_info_10(p->mem_ctx, ctr->info.id10, &info->sid))) + if (!NT_STATUS_IS_OK(r_u->status = get_user_info_16(p->mem_ctx, ctr->info.id16, &info->sid))) return r_u->status; break; #if 0 /* whoops - got this wrong. i think. or don't understand what's happening. */ - case 0x11: + case 17: { NTTIME expire; info = (void *)&id11; @@ -1628,9 +1628,9 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ expire.low = 0xffffffff; expire.high = 0x7fffffff; - ctr->info.id = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_11)); - ZERO_STRUCTP(ctr->info.id11); - init_sam_user_info11(ctr->info.id11, &expire, + ctr->info.id = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_17)); + ZERO_STRUCTP(ctr->info.id17); + init_sam_user_info17(ctr->info.id17, &expire, "BROOKFIELDS$", /* name */ 0x03ef, /* user rid */ 0x201, /* group rid */ @@ -1640,12 +1640,12 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ } #endif - case 0x12: - ctr->info.id12 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_12); - if (ctr->info.id12 == NULL) + case 18: + ctr->info.id18 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_18); + if (ctr->info.id18 == NULL) return NT_STATUS_NO_MEMORY; - if (!NT_STATUS_IS_OK(r_u->status = get_user_info_12(p, p->mem_ctx, ctr->info.id12, &info->sid))) + if (!NT_STATUS_IS_OK(r_u->status = get_user_info_18(p, p->mem_ctx, ctr->info.id18, &info->sid))) return r_u->status; break; @@ -2418,19 +2418,19 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A } /******************************************************************* - set_user_info_10 + set_user_info_16 ********************************************************************/ -static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, SAM_ACCOUNT *pwd) +static BOOL set_user_info_16(const SAM_USER_INFO_16 *id16, SAM_ACCOUNT *pwd) { - if (id10 == NULL) { - DEBUG(5, ("set_user_info_10: NULL id10\n")); + if (id16 == NULL) { + DEBUG(5, ("set_user_info_16: NULL id16\n")); pdb_free_sam(&pwd); return False; } /* FIX ME: check if the value is really changed --metze */ - if (!pdb_set_acct_ctrl(pwd, id10->acb_info, PDB_CHANGED)) { + if (!pdb_set_acct_ctrl(pwd, id16->acb_info, PDB_CHANGED)) { pdb_free_sam(&pwd); return False; } @@ -2446,23 +2446,23 @@ static BOOL set_user_info_10(const SAM_USER_INFO_10 *id10, SAM_ACCOUNT *pwd) } /******************************************************************* - set_user_info_12 + set_user_info_18 ********************************************************************/ -static BOOL set_user_info_12(SAM_USER_INFO_12 *id12, SAM_ACCOUNT *pwd) +static BOOL set_user_info_18(SAM_USER_INFO_18 *id18, SAM_ACCOUNT *pwd) { - if (id12 == NULL) { - DEBUG(2, ("set_user_info_12: id12 is NULL\n")); + if (id18 == NULL) { + DEBUG(2, ("set_user_info_18: id18 is NULL\n")); pdb_free_sam(&pwd); return False; } - if (!pdb_set_lanman_passwd (pwd, id12->lm_pwd, PDB_CHANGED)) { + if (!pdb_set_lanman_passwd (pwd, id18->lm_pwd, PDB_CHANGED)) { pdb_free_sam(&pwd); return False; } - if (!pdb_set_nt_passwd (pwd, id12->nt_pwd, PDB_CHANGED)) { + if (!pdb_set_nt_passwd (pwd, id18->nt_pwd, PDB_CHANGED)) { pdb_free_sam(&pwd); return False; } @@ -2779,7 +2779,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE switch (switch_value) { case 18: - if (!set_user_info_12(ctr->info.id12, pwd)) + if (!set_user_info_18(ctr->info.id18, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; break; @@ -2919,12 +2919,12 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ switch (switch_value) { case 16: - if (!set_user_info_10(ctr->info.id10, pwd)) + if (!set_user_info_16(ctr->info.id16, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; break; case 18: /* Used by AS/U JRA. */ - if (!set_user_info_12(ctr->info.id12, pwd)) + if (!set_user_info_18(ctr->info.id18, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; break; case 20: -- cgit From 99478cd59bc89c82248652ca8a7a326f0e8cad39 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 19 Jul 2005 03:54:01 +0000 Subject: r8573: Fix set but not used warning in srvsvc server-side code. Another bugzilla (#2891) from Jason Mader. (This used to be commit ae6b4df7fed2516c5236755f75300ec0d95c35b3) --- source3/rpc_server/srv_srvsvc_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index c3fd53a384..b607d32e54 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1355,7 +1355,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES { struct sessionid *session_list; struct current_user user; - int num_sessions, snum, ret; + int num_sessions, snum; fstring username; fstring machine; BOOL not_root = False; @@ -1394,7 +1394,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES become_root(); } - if ((ret = message_send_pid(session_list[snum].pid, MSG_SHUTDOWN, NULL, 0, False))) + if (message_send_pid(session_list[snum].pid, MSG_SHUTDOWN, NULL, 0, False)) r_u->status = WERR_OK; if (not_root) -- cgit From ae64b2f2aad54833fb29911c50406f784bd2d8b6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 19 Jul 2005 21:41:41 +0000 Subject: r8617: Be very explicit if addprinterex is called that the "addprinter command" must be defined in smb.conf. Jeremy. (This used to be commit 86f8368c997f0eece20724a0a7158832c66da9f7) --- source3/rpc_server/srv_spoolss_nt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 66804028e1..7498a449c3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7492,7 +7492,7 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ /* check to see if the printer already exists */ if ((snum = print_queue_snum(printer->info_2->sharename)) != -1) { - DEBUG(5, ("_spoolss_addprinterex: Attempted to add a printer named [%s] when one already existed!\n", + DEBUG(5, ("spoolss_addprinterex_level_2: Attempted to add a printer named [%s] when one already existed!\n", printer->info_2->sharename)); free_a_printer(&printer, 2); return WERR_PRINTER_ALREADY_EXISTS; @@ -7505,7 +7505,12 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ if ( !add_printer_hook(p->pipe_user.nt_user_token, printer) ) { free_a_printer(&printer,2); return WERR_ACCESS_DENIED; - } + } + } else { + DEBUG(0,("spoolss_addprinterex_level_2: add printer for printer %s called and no" + "smb.conf parameter \"addprinter command\" is defined. This" + "parameter must exist for this call to succeed\n", + printer->info_2->sharename )); } /* use our primary netbios name since get_a_printer() will convert -- cgit From 8b2b177a8e07e3a0cb00fbd7fdbafc8aeba5b204 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 27 Jul 2005 20:25:04 +0000 Subject: r8805: Merge a duplicate struct. Get ready to support SPNEGO rpc binds. Jeremy. (This used to be commit fd6e342746edfda2f25df1ae0067d359b756e0cd) --- source3/rpc_server/srv_pipe.c | 125 ++++++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 60 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 30aacdc4c5..70563d3029 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -582,9 +582,9 @@ BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *rpc_in_p) return False; } - if (autha_info.auth_type != NTLMSSP_AUTH_TYPE || autha_info.auth_level != RPC_PIPE_AUTH_SEAL_LEVEL) { + if (autha_info.auth.auth_type != NTLMSSP_AUTH_TYPE || autha_info.auth.auth_level != RPC_PIPE_AUTH_SEAL_LEVEL) { DEBUG(0,("api_pipe_bind_auth_resp: incorrect auth type (%d) or level (%d).\n", - (int)autha_info.auth_type, (int)autha_info.auth_level )); + (int)autha_info.auth.auth_type, (int)autha_info.auth.auth_level )); return False; } @@ -941,67 +941,72 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) return False; } - if(auth_info.auth_type == NTLMSSP_AUTH_TYPE) { - - if(!smb_io_rpc_auth_verifier("", &auth_verifier, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_req: unable to " - "unmarshall RPC_HDR_AUTH struct.\n")); - return False; - } - - if(!strequal(auth_verifier.signature, "NTLMSSP")) { - DEBUG(0,("api_pipe_bind_req: " - "auth_verifier.signature != NTLMSSP\n")); - return False; - } - - if(auth_verifier.msg_type != NTLMSSP_NEGOTIATE) { - DEBUG(0,("api_pipe_bind_req: " - "auth_verifier.msg_type (%d) != NTLMSSP_NEGOTIATE\n", - auth_verifier.msg_type)); - return False; - } - - if(!smb_io_rpc_auth_ntlmssp_neg("", &ntlmssp_neg, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_req: " - "Failed to unmarshall RPC_AUTH_NTLMSSP_NEG.\n")); - return False; - } - - p->ntlmssp_chal_flags = SMBD_NTLMSSP_NEG_FLAGS; - p->ntlmssp_auth_requested = True; - - } else if (auth_info.auth_type == NETSEC_AUTH_TYPE) { - - RPC_AUTH_NETSEC_NEG neg; - struct netsec_auth_struct *a = &(p->netsec_auth); - - if (!server_auth2_negotiated) { - DEBUG(0, ("Attempt to bind using schannel " - "without successful serverauth2\n")); - return False; + switch(auth_info.auth_type) { + case NTLMSSP_AUTH_TYPE: + + if(!smb_io_rpc_auth_verifier("", &auth_verifier, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to " + "unmarshall RPC_HDR_AUTH struct.\n")); + return False; + } + + if(!strequal(auth_verifier.signature, "NTLMSSP")) { + DEBUG(0,("api_pipe_bind_req: " + "auth_verifier.signature != NTLMSSP\n")); + return False; + } + + if(auth_verifier.msg_type != NTLMSSP_NEGOTIATE) { + DEBUG(0,("api_pipe_bind_req: " + "auth_verifier.msg_type (%d) != NTLMSSP_NEGOTIATE\n", + auth_verifier.msg_type)); + return False; + } + + if(!smb_io_rpc_auth_ntlmssp_neg("", &ntlmssp_neg, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: " + "Failed to unmarshall RPC_AUTH_NTLMSSP_NEG.\n")); + return False; + } + + p->ntlmssp_chal_flags = SMBD_NTLMSSP_NEG_FLAGS; + p->ntlmssp_auth_requested = True; + break; + + case NETSEC_AUTH_TYPE: + { + RPC_AUTH_NETSEC_NEG neg; + struct netsec_auth_struct *a = &(p->netsec_auth); + + if (!server_auth2_negotiated) { + DEBUG(0, ("Attempt to bind using schannel " + "without successful serverauth2\n")); + return False; + } + + if (!smb_io_rpc_auth_netsec_neg("", &neg, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: " + "Could not unmarshal SCHANNEL auth neg\n")); + return False; + } + + p->netsec_auth_validated = True; + + memset(a->sess_key, 0, sizeof(a->sess_key)); + memcpy(a->sess_key, last_dcinfo.sess_key, sizeof(last_dcinfo.sess_key)); + + a->seq_num = 0; + + DEBUG(10,("schannel auth: domain [%s] myname [%s]\n", + neg.domain, neg.myname)); + break; } - if (!smb_io_rpc_auth_netsec_neg("", &neg, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_req: " - "Could not unmarshal SCHANNEL auth neg\n")); + case SPNEGO_AUTH_TYPE: + default: + DEBUG(0,("api_pipe_bind_req: unknown auth type %x requested.\n", + auth_info.auth_type )); return False; - } - - p->netsec_auth_validated = True; - - memset(a->sess_key, 0, sizeof(a->sess_key)); - memcpy(a->sess_key, last_dcinfo.sess_key, sizeof(last_dcinfo.sess_key)); - - a->seq_num = 0; - - DEBUG(10,("schannel auth: domain [%s] myname [%s]\n", - neg.domain, neg.myname)); - - } else { - DEBUG(0,("api_pipe_bind_req: unknown auth type %x requested.\n", - auth_info.auth_type )); - return False; } } -- cgit From 473cfa4c35170ec51a9ae92986ff2891e5068d4b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 1 Aug 2005 19:58:16 +0000 Subject: r8894: Fix a warning. Bugzilla #2939. (This used to be commit 7648f6cef038dde7fdfbe157784f2fd5437218b0) --- source3/rpc_server/srv_svcctl_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 3d34556340..580d000d12 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -350,7 +350,7 @@ WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_ we have to call the right status routine... **********************************************************************/ -static WERROR enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services, int *added) +static WERROR enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services, uint32 *added) { int num_services = 2; int i = 0; @@ -443,8 +443,6 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT /* _svcctl_read_LSB_data(NULL,NULL); */ /* init_svcctl_db(); */ - num_int_services = 0; - /* num_int_services = num_internal_services(); */ /* num_ext_services = num_external_services(); */ -- cgit From 57939971b42b8f0a993e08e92480223b4f412907 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 2 Aug 2005 07:26:29 +0000 Subject: r8916: should fix the valgrind invalid read of size 1 onthe GetPrinterData("OSVersion") abartlet saw when browsing from Vista client. (This used to be commit b527b86ae80ebc0b6e7318ed31d44be985aa9af0) --- source3/rpc_server/srv_spoolss_nt.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7498a449c3..bec67daa3e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2283,7 +2283,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "W3SvcInstalled")) { *type = REG_DWORD; - if((*data = (uint8 *)TALLOC_ZERO(ctx, 4*sizeof(uint8) )) == NULL) + if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) ) return WERR_NOMEM; *needed = 0x4; return WERR_OK; @@ -2291,7 +2291,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "BeepEnabled")) { *type = REG_DWORD; - if((*data = (uint8 *)TALLOC(ctx, 4*sizeof(uint8) )) == NULL) + if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) ) return WERR_NOMEM; SIVAL(*data, 0, 0x00); *needed = 0x4; @@ -2300,7 +2300,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "EventLog")) { *type = REG_DWORD; - if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL) + if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) ) return WERR_NOMEM; /* formally was 0x1b */ SIVAL(*data, 0, 0x0); @@ -2310,7 +2310,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "NetPopup")) { *type = REG_DWORD; - if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL) + if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) ) return WERR_NOMEM; SIVAL(*data, 0, 0x00); *needed = 0x4; @@ -2319,7 +2319,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "MajorVersion")) { *type = REG_DWORD; - if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL) + if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) ) return WERR_NOMEM; /* Windows NT 4.0 seems to not allow uploading of drivers @@ -2338,7 +2338,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "MinorVersion")) { *type = REG_DWORD; - if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL) + if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) ) return WERR_NOMEM; SIVAL(*data, 0, 0); *needed = 0x4; @@ -2356,7 +2356,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint *type = REG_BINARY; *needed = 0x114; - if ( !(*data = TALLOC_ZERO_ARRAY(ctx, uint8, *needed)) ) + if ( !(*data = TALLOC_ZERO_ARRAY(ctx, uint8, (*needed > in_size) ? *needed:in_size )) ) return WERR_NOMEM; SIVAL(*data, 0, *needed); /* size */ @@ -2402,7 +2402,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "DsPresent")) { *type = REG_DWORD; - if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL) + if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) ) return WERR_NOMEM; /* only show the publish check box if we are a -- cgit From 235644680f1fe0defdffcaeb3364150fbb344d86 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 2 Aug 2005 20:19:42 +0000 Subject: r8941: Fix unused variable warning. Bugzilla #2940. (This used to be commit 6d0aafa5990b1e56d046489e07cbfe85d258c53f) --- source3/rpc_server/srv_svcctl_nt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 580d000d12..15d947cf0f 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -253,7 +253,6 @@ WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_ uint32 access_granted = 0; NTSTATUS status; pstring service; - SERVICE_INFO *scm_info; rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); @@ -262,7 +261,7 @@ WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_ /* based on my tests you can open a service if you have a valid scm handle */ - if ( !(scm_info = find_service_info_by_hnd( p, &q_u->handle )) ) + if ( !find_service_info_by_hnd( p, &q_u->handle ) ) return WERR_BADFID; /* perform access checks */ -- cgit From 191b5977d0c7bf65d418e5e97de0e8b8d9d5237c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 2 Aug 2005 20:33:50 +0000 Subject: r8943: Fix segfault in enum_service_status (This used to be commit 04a551f0a4d321f5e1a7af33468160e2c7839af8) --- source3/rpc_server/srv_svcctl_nt.c | 76 +++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 43 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 15d947cf0f..6cdc71bf03 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -349,7 +349,7 @@ WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_ we have to call the right status routine... **********************************************************************/ -static WERROR enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services, uint32 *added) +static WERROR enum_internal_services(TALLOC_CTX *ctx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services, uint32 *added) { int num_services = 2; int i = 0; @@ -360,24 +360,23 @@ static WERROR enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ services = *svc_ptr; -#if 0 - /* *svc_ptr has the pointer to the array if there is one already. NULL if not. */ - if ((existing_services>0) && svc_ptr && *svc_ptr) { /* reallocate vs. allocate */ - DEBUG(8,("enum_internal_services: REALLOCing %d services\n", num_services)); - services = TALLOC_REALLOC_ARRAY(tcx,*svc_ptr,ENUM_SERVICES_STATUS,existing_services+num_services); - if (!rsvcs) + if ( (existing_services > 0) && svc_ptr && *svc_ptr ) { + ENUM_SERVICES_STATUS *tmp_services = NULL; + uint32 total_svc = existing_services + num_services; + + if ( !(tmp_services = TALLOC_REALLOC_ARRAY( ctx, services, ENUM_SERVICES_STATUS, total_svc )) ) return WERR_NOMEM; - *svc_ptr = services; - } else { - if ( !(services = TALLOC_ARRAY( tcx, ENUM_SERVICES_STATUS, num_services )) ) + + services = tmp_services; + i += existing_services; + } + else { + if ( !(services = TALLOC_ARRAY( ctx, ENUM_SERVICES_STATUS, num_services )) ) return WERR_NOMEM; } -#endif - if (existing_services > 0) { - i += existing_services; - } - DEBUG(8,("enum_internal_services: Creating %d services, starting index %d\n", num_services,existing_services)); + DEBUG(8,("enum_internal_services: Creating %d services, starting index %d\n", + num_services, existing_services)); init_unistr( &services[i].servicename, "Spooler" ); init_unistr( &services[i].displayname, "Print Spooler" ); @@ -409,7 +408,8 @@ static WERROR enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ else services[i].status.state = SVCCTL_STOPPED; - *added = num_services; + *added = num_services; + *svc_ptr = services; return WERR_OK; } @@ -420,12 +420,10 @@ static WERROR enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, SVCCTL_R_ENUM_SERVICES_STATUS *r_u) { ENUM_SERVICES_STATUS *services = NULL; - uint32 num_int_services = 0; - uint32 num_ext_services = 0; + uint32 num_int_services, num_ext_services, total_services; int i = 0; - size_t buffer_size; + size_t buffer_size = 0; WERROR result = WERR_OK; - WERROR ext_result = WERR_OK; SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); /* perform access checks */ @@ -436,46 +434,38 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT if ( !(info->access_granted & SC_RIGHT_MGR_ENUMERATE_SERVICE) ) return WERR_ACCESS_DENIED; + num_int_services = 0; + num_ext_services = 0; + /* num_services = str_list_count( lp_enable_svcctl() ); */ /* here's where we'll read the db of external services */ /* _svcctl_read_LSB_data(NULL,NULL); */ /* init_svcctl_db(); */ - /* num_int_services = num_internal_services(); */ - - /* num_ext_services = num_external_services(); */ - if ( !(services = TALLOC_ARRAY(p->mem_ctx, ENUM_SERVICES_STATUS, num_int_services+num_ext_services )) ) - return WERR_NOMEM; - - result = enum_internal_services(p->mem_ctx, &services, 0, &num_int_services); + return WERR_NOMEM; - if (W_ERROR_IS_OK(result)) { + if ( W_ERROR_IS_OK(enum_internal_services(p->mem_ctx, &services, 0, &num_int_services)) ) DEBUG(8,("_svcctl_enum_services_status: Got %d internal services\n", num_int_services)); - } - /* ext_result=enum_external_services(p->mem_ctx, &services, num_int_services, &num_ext_services); */ - - if (W_ERROR_IS_OK(ext_result)) { +#if 0 + if ( W_ERROR_IS_OK(enum_external_services(p->mem_ctx, &services, num_int_services, &num_ext_services)) ) DEBUG(8,("_svcctl_enum_services_status: Got %d external services\n", num_ext_services)); - } +#endif + + total_services = num_int_services + num_ext_services; - DEBUG(8,("_svcctl_enum_services_status: total of %d services\n", num_int_services+num_ext_services)); + DEBUG(8,("_svcctl_enum_services_status: total of %d services\n", total_services )); - buffer_size = 0; - for (i=0;ibuffer_size, buffer_size)); if (buffer_size > q_u->buffer_size ) { - num_int_services = 0; - num_ext_services = 0; + total_services = 0; result = WERR_MORE_DATA; } @@ -487,7 +477,7 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT } r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size; - r_u->returned = num_int_services+num_ext_services; + r_u->returned = total_services; if ( !(r_u->resume = TALLOC_P( p->mem_ctx, uint32 )) ) return WERR_NOMEM; -- cgit From a4cdedcc085e0b9a94e6757a9b427af503ad6593 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 2 Aug 2005 20:59:20 +0000 Subject: r8950: Fix one more mem leak found by Gunther. Jeremy. (This used to be commit 547c6ee0a965b425719cdb834dd5d68a3a3e7117) --- source3/rpc_server/srv_dfs_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 938b01540f..b005192010 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -319,7 +319,7 @@ WERROR _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u) struct junction_map jn[MAX_MSDFS_JUNCTIONS]; int num_jn = 0; - num_jn = enum_msdfs_links(jn, ARRAY_SIZE(jn)); + num_jn = enum_msdfs_links(p->mem_ctx, jn, ARRAY_SIZE(jn)); vfs_ChDir(p->conn,p->conn->connectpath); DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", num_jn, level)); -- cgit From abb81cfe2688dec69fe154d3abff8eff388c779c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 2 Aug 2005 23:24:32 +0000 Subject: r8959: Make msdfs code talloc based. Fix leaks. Jeremy. (This used to be commit 076023df8ea7c0f03baf8102e55d347e05542c7b) --- source3/rpc_server/srv_dfs_nt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index b005192010..f61348ee05 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -69,7 +69,7 @@ WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) pstrcat(altpath, sharename); /* The following call can change the cwd. */ - if(get_referred_path(dfspath, &jn, NULL, NULL)) { + if(get_referred_path(p->mem_ctx, dfspath, &jn, NULL, NULL)) { exists = True; jn.referral_count += 1; old_referral_list = jn.referral_list; @@ -87,7 +87,6 @@ WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) if(old_referral_list) { memcpy(jn.referral_list, old_referral_list, sizeof(struct referral)*jn.referral_count-1); - SAFE_FREE(old_referral_list); } jn.referral_list[jn.referral_count-1].proximity = 0; @@ -140,7 +139,7 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n", dfspath, servername, sharename)); - if(!get_referred_path(dfspath, &jn, NULL, NULL)) { + if(!get_referred_path(p->mem_ctx, dfspath, &jn, NULL, NULL)) { return WERR_DFS_NO_SUCH_VOL; } @@ -358,7 +357,7 @@ WERROR _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u, return WERR_DFS_NO_SUCH_SERVER; /* The following call can change the cwd. */ - if(!get_referred_path(path, &jn, &consumedcnt, NULL) || consumedcnt < strlen(path)) { + if(!get_referred_path(p->mem_ctx, path, &jn, &consumedcnt, NULL) || consumedcnt < strlen(path)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; } -- cgit From 3ada346cbea6a3710cdb6d0ce81a9d95edca156e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 3 Aug 2005 01:08:42 +0000 Subject: r8971: Fix querydispinfo (still need to look at enumdomusers) to allow to list more then 511 users. After the rewrite, the old NT_STATUS-semantics didn't fit any longer. Guenther (This used to be commit 690da51d835fd780b16d8ce6521957146c90da78) --- source3/rpc_server/srv_samr_nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2e73db2807..431c672dd4 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -808,7 +808,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, struct samr_displayentry *entries = NULL; DEBUG(5, ("samr_reply_query_dispinfo: %d\n", __LINE__)); - r_u->status = NT_STATUS_OK; + r_u->status = NT_STATUS_UNSUCCESSFUL; /* find the policy handle. open a policy on it. */ if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) @@ -951,8 +951,10 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, /* calculate the total size */ total_data_size=num_account*struct_size; - if (enum_context+max_entries < num_account) + if (num_account) r_u->status = STATUS_MORE_ENTRIES; + else + r_u->status = NT_STATUS_OK; DEBUG(5, ("_samr_query_dispinfo: %d\n", __LINE__)); -- cgit From fdc2ab72f7a524b43c7fe03e17cf4817fc3730a2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 3 Aug 2005 22:07:57 +0000 Subject: r9021: Fix smbd-crash bug in openprinter (found by samba4 smbtorture RPC-SPOOLSS). Guenther (This used to be commit 06bfe789d54a12dfa3c46e9777f96ff7e162a9db) --- source3/rpc_server/srv_spoolss_nt.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index bec67daa3e..692dacf159 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1488,19 +1488,23 @@ static void copy_printer_default(TALLOC_CTX *ctx, PRINTER_DEFAULT *new_def, PRIN * SPOOL_Q_OPEN_PRINTER_EX structure ********************************************************************/ -static void convert_to_openprinterex(TALLOC_CTX *ctx, SPOOL_Q_OPEN_PRINTER_EX *q_u_ex, SPOOL_Q_OPEN_PRINTER *q_u) +static WERROR convert_to_openprinterex(TALLOC_CTX *ctx, SPOOL_Q_OPEN_PRINTER_EX *q_u_ex, SPOOL_Q_OPEN_PRINTER *q_u) { if (!q_u_ex || !q_u) - return; + return WERR_OK; DEBUG(8,("convert_to_openprinterex\n")); if ( q_u->printername ) { - q_u_ex->printername = TALLOC_P( ctx, UNISTR2 ); + q_u_ex->printername = TALLOC_ZERO_P( ctx, UNISTR2 ); + if (q_u_ex->printername == NULL) + return WERR_NOMEM; copy_unistr2(q_u_ex->printername, q_u->printername); } copy_printer_default(ctx, &q_u_ex->printer_default, &q_u->printer_default); + + return WERR_OK; } /******************************************************************** @@ -1522,7 +1526,9 @@ WERROR _spoolss_open_printer(pipes_struct *p, SPOOL_Q_OPEN_PRINTER *q_u, SPOOL_R /* convert the OpenPrinter() call to OpenPrinterEx() */ - convert_to_openprinterex(p->mem_ctx, &q_u_ex, q_u); + r_u_ex.status = convert_to_openprinterex(p->mem_ctx, &q_u_ex, q_u); + if (!W_ERROR_IS_OK(r_u_ex.status)) + return r_u_ex.status; r_u_ex.status = _spoolss_open_printer_ex(p, &q_u_ex, &r_u_ex); -- cgit From 777422836ccfd3f2cafa19537534b970bc96fc2b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 5 Aug 2005 00:25:52 +0000 Subject: r9080: If we don't understand the auth, bind nak not pdu fault. Should fix usermgr on W2K3 SP1. Jeremy. (This used to be commit 592ec9fbffc704761c6b29cfc795cf3af7d5fe38) --- source3/rpc_server/srv_pipe.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 70563d3029..63e8d2f5cd 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -666,7 +666,7 @@ static BOOL setup_bind_nak(pipes_struct *p) if(!prs_uint16("reject code", &outgoing_rpc, 0, &zero)) { prs_mem_free(&outgoing_rpc); - return False; + return False; } p->out_data.data_sent_length = 0; @@ -896,11 +896,9 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) if (i == rpc_lookup_size) { if (NT_STATUS_IS_ERR(smb_probe_module("rpc", p->name))) { - DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", - p->name )); - if(!setup_bind_nak(p)) - return False; - return True; + DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", + p->name )); + return setup_bind_nak(p); } for (i = 0; i < rpc_lookup_size; i++) { @@ -921,7 +919,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) /* decode the bind request */ if(!smb_io_rpc_hdr_rb("", &hdr_rb, rpc_in_p, 0)) { DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_RB struct.\n")); - return False; + return setup_bind_nak(p); } /* @@ -938,7 +936,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) if(!smb_io_rpc_hdr_auth("", &auth_info, rpc_in_p, 0)) { DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); - return False; + return setup_bind_nak(p); } switch(auth_info.auth_type) { @@ -947,26 +945,26 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) if(!smb_io_rpc_auth_verifier("", &auth_verifier, rpc_in_p, 0)) { DEBUG(0,("api_pipe_bind_req: unable to " "unmarshall RPC_HDR_AUTH struct.\n")); - return False; + return setup_bind_nak(p); } if(!strequal(auth_verifier.signature, "NTLMSSP")) { DEBUG(0,("api_pipe_bind_req: " "auth_verifier.signature != NTLMSSP\n")); - return False; + return setup_bind_nak(p); } if(auth_verifier.msg_type != NTLMSSP_NEGOTIATE) { DEBUG(0,("api_pipe_bind_req: " "auth_verifier.msg_type (%d) != NTLMSSP_NEGOTIATE\n", auth_verifier.msg_type)); - return False; + return setup_bind_nak(p); } if(!smb_io_rpc_auth_ntlmssp_neg("", &ntlmssp_neg, rpc_in_p, 0)) { DEBUG(0,("api_pipe_bind_req: " "Failed to unmarshall RPC_AUTH_NTLMSSP_NEG.\n")); - return False; + return setup_bind_nak(p); } p->ntlmssp_chal_flags = SMBD_NTLMSSP_NEG_FLAGS; @@ -981,13 +979,13 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) if (!server_auth2_negotiated) { DEBUG(0, ("Attempt to bind using schannel " "without successful serverauth2\n")); - return False; + return setup_bind_nak(p); } if (!smb_io_rpc_auth_netsec_neg("", &neg, rpc_in_p, 0)) { DEBUG(0,("api_pipe_bind_req: " "Could not unmarshal SCHANNEL auth neg\n")); - return False; + return setup_bind_nak(p); } p->netsec_auth_validated = True; @@ -1006,7 +1004,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) default: DEBUG(0,("api_pipe_bind_req: unknown auth type %x requested.\n", auth_info.auth_type )); - return False; + return setup_bind_nak(p); } } -- cgit From 6014bb000e77e2522cb35110af881b9b0ccc9ed5 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 5 Aug 2005 04:48:02 +0000 Subject: r9098: fix another usrmgr.exe crash when viewing user properties at debuglevel 10 (This used to be commit f5756c2611df5a026d78f8acb229d7c25f1fd383) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 431c672dd4..1eb4b1236d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1229,7 +1229,7 @@ static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, } for (i = 0; i < num_names; i++) { - DEBUG(10, ("names[%d]:%s\n", i, *names[i] ? names[i] : "")); + DEBUG(10, ("names[%d]:%s\n", i, names[i] && *names[i] ? names[i] : "")); init_unistr2(&uni_name[i], names[i], UNI_FLAGS_NONE); init_uni_hdr(&hdr_name[i], &uni_name[i]); } -- cgit From 7fff6638fca113694ef1570ce1331cc8c2e056f8 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 5 Aug 2005 12:33:00 +0000 Subject: r9112: Fix #2953 - credentials chain on DC gets out of sync with client when NT_STATUS_NO_USER returned. We were moving to the next step in the chain when the client wasn't. Only update when the user logs on. (This used to be commit b01a3a4111f544eef5bd678237d07a82d1ce9c22) --- source3/rpc_server/srv_netlog_nt.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 7880a724b5..0af8b14fe2 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -449,6 +449,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->clnt_id.cred, &srv_cred))) return NT_STATUS_INVALID_HANDLE; + reseed_client_creds(&p->dc.clnt_cred, &q_u->clnt_id.cred); memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); @@ -545,6 +546,8 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF &q_u->sam_id.client.cred, &srv_cred))) return NT_STATUS_INVALID_HANDLE; + /* what happens if we get a logoff for an unknown user? */ + reseed_client_creds(&p->dc.clnt_cred, &q_u->sam_id.client.cred); memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); /* XXXX maybe we want to say 'no', reject the client's credentials */ @@ -603,11 +606,6 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred))) return NT_STATUS_INVALID_HANDLE; - memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); - - r_u->buffer_creds = 1; /* yes, we have valid server credentials */ - memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds)); - /* find the username */ switch (q_u->sam_id.logon_level) { @@ -719,6 +717,15 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return status; } + /* moved from right after deal_with_creds above, since we weren't + supposed to update unless logon was successful */ + + reseed_client_creds(&p->dc.clnt_cred, &q_u->sam_id.client.cred); + memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); + + r_u->buffer_creds = 1; /* yes, we have valid server credentials */ + memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds)); + if (server_info->guest) { /* We don't like guest domain logons... */ DEBUG(5,("_net_sam_logon: Attempted domain logon as GUEST denied.\n")); -- cgit From e93b4cedc339154e63dbde3a09503c7930339e26 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 5 Aug 2005 14:32:42 +0000 Subject: r9114: removing gratuitous debug messages (This used to be commit c3e14230387d8644152cf7e1f612a7ca7ec6f583) --- source3/rpc_server/srv_reg_nt.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index db199634c5..feb89be542 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -393,8 +393,6 @@ WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY uint32 access_granted; WERROR result; - DEBUG(5,("reg_open_entry: Enter\n")); - if ( !parent ) return WERR_BADFID; @@ -440,8 +438,6 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL REGVAL_CTR regvals; int i; - DEBUG(5,("_reg_info: Enter\n")); - if ( !regkey ) return WERR_BADFID; @@ -470,8 +466,6 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL regval_ctr_destroy( ®vals ); free_registry_value( val ); - DEBUG(5,("_reg_info: Exit\n")); - return status; } @@ -485,8 +479,6 @@ WERROR _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_ WERROR status = WERR_OK; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - DEBUG(5,("_reg_query_key: Enter\n")); - if ( !regkey ) return WERR_BADFID; @@ -508,8 +500,6 @@ WERROR _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_ ZERO_STRUCT(r_u->mod_time); - DEBUG(5,("_reg_query_key: Exit\n")); - return status; } @@ -523,15 +513,11 @@ WERROR _reg_getversion(pipes_struct *p, REG_Q_GETVERSION *q_u, REG_R_GETVERSION WERROR status = WERR_OK; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - DEBUG(5,("_reg_getversion: Enter\n")); - if ( !regkey ) return WERR_BADFID; r_u->win_version = 0x00000005; /* Windows 2000 registry API version */ - DEBUG(5,("_reg_getversion: Exit\n")); - return status; } @@ -547,8 +533,6 @@ WERROR _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u) char *subkey = NULL; - DEBUG(5,("_reg_enum_key: Enter\n")); - if ( !regkey ) return WERR_BADFID; @@ -566,8 +550,6 @@ WERROR _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u) init_reg_r_enum_key( r_u, subkey ); - DEBUG(5,("_reg_enum_key: Exit\n")); - done: SAFE_FREE( subkey ); return status; @@ -584,12 +566,10 @@ WERROR _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE REGISTRY_VALUE *val; - DEBUG(5,("_reg_enum_value: Enter\n")); - if ( !regkey ) return WERR_BADFID; - DEBUG(8,("_reg_enum_key: enumerating values for key [%s]\n", regkey->name)); + DEBUG(8,("_reg_enum_value: enumerating values for key [%s]\n", regkey->name)); if ( !fetch_reg_values_specific( regkey, &val, q_u->val_index ) ) { status = WERR_NO_MORE_ITEMS; @@ -602,9 +582,6 @@ WERROR _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE init_reg_r_enum_val( r_u, val ); - - DEBUG(5,("_reg_enum_value: Exit\n")); - done: free_registry_value( val ); @@ -900,8 +877,6 @@ WERROR _reg_restore_key(pipes_struct *p, REG_Q_RESTORE_KEY *q_u, REG_R_RESTORE_ pstring filename; int snum; - DEBUG(5,("_reg_restore_key: Enter\n")); - if ( !regkey ) return WERR_BADFID; @@ -1079,8 +1054,6 @@ WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) pstring filename; int snum; - DEBUG(5,("_reg_save_key: Enter\n")); - if ( !regkey ) return WERR_BADFID; -- cgit From 617a99ec52d5e4684bbd851f0d7949c8607241e0 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sun, 7 Aug 2005 20:10:21 +0000 Subject: r9194: do not enumerate privileges when they are not enabled (This used to be commit ff6e3464a2df7fd8a79da8f059a080934d9b3749) --- source3/rpc_server/srv_lsa_nt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 15d420538e..b9db5c6b59 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -805,12 +805,17 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV struct lsa_info *handle; uint32 i; uint32 enum_context = q_u->enum_context; - int num_privs = count_all_privileges(); + int num_privs = 0; LSA_PRIV_ENTRY *entries = NULL; LUID_ATTR luid; /* remember that the enum_context starts at 0 and not 1 */ + if ( lp_enable_privileges() ) + num_privs = count_all_privileges(); + else + DEBUG(0,("_lsa_enum_privs: client trying to enumerate privileges by not enabled in smb.conf!\n")); + if ( enum_context >= num_privs ) return NT_STATUS_NO_MORE_ENTRIES; -- cgit From fd6dde216168fba678346c2520051ddc63e70ae5 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sun, 7 Aug 2005 20:28:53 +0000 Subject: r9195: setting log level to 2 instead of 0 (This used to be commit 3a633a509e8e8e5239d456960f3014172f1e4b3d) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index b9db5c6b59..021f1dc8e0 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -814,7 +814,7 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV if ( lp_enable_privileges() ) num_privs = count_all_privileges(); else - DEBUG(0,("_lsa_enum_privs: client trying to enumerate privileges by not enabled in smb.conf!\n")); + DEBUG(2,("_lsa_enum_privs: client trying to enumerate privileges by not enabled in smb.conf!\n")); if ( enum_context >= num_privs ) return NT_STATUS_NO_MORE_ENTRIES; -- cgit From 3662fb6d3ae14750520c6567a6d488f1b7a377d6 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 10 Aug 2005 16:02:32 +0000 Subject: r9229: merge from trunk: allow admins to uncheck the "User must change Password at next Logon" checkbox in Usermanager. Guenther (This used to be commit b1e4b72c1c36869c4dfc5ed284be24edc99f6774) --- source3/rpc_server/srv_samr_util.c | 39 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 66cf1cc46d..24869d5d2b 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -286,7 +286,25 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) { - pdb_set_pass_must_change_time(to,0, PDB_CHANGED); + pdb_set_pass_must_change_time(to,0, PDB_CHANGED); + } else { + uint32 expire; + time_t new_time; + if (pdb_get_pass_must_change_time(to) == 0) { + if (!account_policy_get(AP_MAX_PASSWORD_AGE, &expire) + || expire == (uint32)-1) { + new_time = get_time_t_max(); + } else { + time_t old_time = pdb_get_pass_last_set_time(to); + new_time = old_time + expire; + if ((new_time) < time(0)) { + new_time = time(0) + expire; + } + } + if (!pdb_set_pass_must_change_time (to, new_time, PDB_CHANGED)) { + DEBUG (0, ("pdb_set_pass_must_change_time failed!\n")); + } + } } DEBUG(10,("INFO_21 PADDING_2: %02X\n",from->padding2)); @@ -490,7 +508,6 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) DEBUG(15,("INFO_23 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); /* Fix me: only update if it changes --metze */ pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); - } if (from->fields_present & ACCT_BAD_PWD_COUNT) { @@ -510,6 +527,24 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) { pdb_set_pass_must_change_time(to,0, PDB_CHANGED); + } else { + uint32 expire; + time_t new_time; + if (pdb_get_pass_must_change_time(to) == 0) { + if (!account_policy_get(AP_MAX_PASSWORD_AGE, &expire) + || expire == (uint32)-1) { + new_time = get_time_t_max(); + } else { + time_t old_time = pdb_get_pass_last_set_time(to); + new_time = old_time + expire; + if ((new_time) < time(0)) { + new_time = time(0) + expire; + } + } + if (!pdb_set_pass_must_change_time (to, new_time, PDB_CHANGED)) { + DEBUG (0, ("pdb_set_pass_must_change_time failed!\n")); + } + } } DEBUG(10,("INFO_23 PADDING_2: %02X\n",from->padding2)); -- cgit From d6403e7280530ed66aa9f5d97ca225afb7130484 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Thu, 11 Aug 2005 19:45:53 +0000 Subject: r9242: Fix my fix for #2953. I'd moved too much code until after we verify the user, causing netlogon to return an invalid response for failed interactive logons. (This used to be commit 4deb918b682fb51d8712cfdafc6210275dd10fc4) --- source3/rpc_server/srv_netlog_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 0af8b14fe2..388d649c3c 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -606,6 +606,9 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred))) return NT_STATUS_INVALID_HANDLE; + r_u->buffer_creds = 1; /* yes, we have valid server credentials */ + memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds)); + /* find the username */ switch (q_u->sam_id.logon_level) { @@ -723,9 +726,6 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * reseed_client_creds(&p->dc.clnt_cred, &q_u->sam_id.client.cred); memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); - r_u->buffer_creds = 1; /* yes, we have valid server credentials */ - memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds)); - if (server_info->guest) { /* We don't like guest domain logons... */ DEBUG(5,("_net_sam_logon: Attempted domain logon as GUEST denied.\n")); -- cgit From dcf2200411f8a98eaee03b6fa235e1e9aa41b3f3 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 12 Aug 2005 15:28:19 +0000 Subject: r9261: Fix #2976: windows member servers wouldn't alloc connections from users defined locally because if we didn't find them as a DC we were marking the response as authoritative. Now if it's not a domain we know, we mark the response non-authoritative. Fix from jpjanosi@us.ibm.com (This used to be commit d522277b86ff728f6f2b9feb2f8e3fa38c43d162) --- source3/rpc_server/srv_netlog_nt.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 388d649c3c..78ff669d07 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -716,6 +716,15 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * /* Check account and password */ if (!NT_STATUS_IS_OK(status)) { + /* If we don't know what this domain is, we need to + indicate that we are not authoritative. This + allows the client to decide if it needs to try + a local user. Fix by jpjanosi@us.ibm.com, #2976 */ + if ( NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER) + && !strequal(nt_domain, get_global_sam_name()) + && !is_trusted_domain(nt_domain) ) + r_u->auth_resp = 0; /* We are not authoritative */ + free_server_info(&server_info); return status; } -- cgit From d04c1efd0ff130acbf17a0167a878cf27d9bdec5 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 12 Aug 2005 16:00:54 +0000 Subject: r9264: fix valgrind invalid write error in enumprinterdata() (This used to be commit bfebbc86fc0f90e580888da25006d8e5e50b6304) --- source3/rpc_server/srv_spoolss_nt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 692dacf159..5391ac5f41 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8040,13 +8040,14 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S /* data - counted in bytes */ *out_max_data_len = in_data_len; - if ( (*data_out = (uint8 *)TALLOC_ZERO(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) + if ( in_data_len && (*data_out = (uint8 *)TALLOC_ZERO(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) { result = WERR_NOMEM; goto done; } data_len = regval_size(val); - memcpy( *data_out, regval_data_p(val), data_len ); + if ( *data_out ) + memcpy( *data_out, regval_data_p(val), data_len ); *out_data_len = data_len; } -- cgit From 36115e7ebcb344000149cf3ec9a458529bbb64d2 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 12 Aug 2005 21:35:21 +0000 Subject: r9275: Remove some dead code. Bugzilla #2982. (This used to be commit e1fc7d89c26b671e77c7cb14e03690091b671b1d) --- source3/rpc_server/srv_samr_nt.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1eb4b1236d..1f79ce5c14 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -804,7 +804,6 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, uint32 num_account = 0; enum remote_arch_types ra_type = get_remote_arch(); int max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K; - DOM_SID domain_sid; struct samr_displayentry *entries = NULL; DEBUG(5, ("samr_reply_query_dispinfo: %d\n", __LINE__)); @@ -814,8 +813,6 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) return NT_STATUS_INVALID_HANDLE; - domain_sid = info->sid; - /* * calculate how many entries we will return. * based on -- cgit From 021892a6ceecd8a1311a6d582688ae3ec4bfdd22 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 12 Aug 2005 21:39:01 +0000 Subject: r9276: Fix another unused variable warning. Bugzilla #2981. (This used to be commit abe2ab72e6b1d53dbe04d02882e4fee9cb34dec7) --- source3/rpc_server/srv_svcctl_nt.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 6cdc71bf03..2e44dc3692 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -756,7 +756,6 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO { POLICY_HND *handle; SERVICE_INFO *service_info; - uint32 level; SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); /* perform access checks */ @@ -789,10 +788,8 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO in the *r_query_config2 marshalling routine... */ - level = q_u->info_level; - #if 0 - if (SERVICE_CONFIG_DESCRIPTION == level) { + if (SERVICE_CONFIG_DESCRIPTION == q_u->info_level) { if (service_info && service_info->shortdescription) { /* length of the string, plus the terminator... */ string_buffer_size = strlen(service_info->shortdescription)+1; -- cgit From e76107dd9b3f53009466f0067aed843905819e4e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 24 Aug 2005 19:21:00 +0000 Subject: r9594: return the mapped name in enum_dom_groups() (This used to be commit a769aaec88257ae006c61f0fcfd98efd4b639268) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1f79ce5c14..05aa6fe484 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -670,7 +670,7 @@ static void make_group_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, /* * JRA. I think this should include the null. TNG does not. */ - init_unistr2(&uni_name[i], entries[i].account_name, + init_unistr2(&uni_name[i], entries[i].fullname, UNI_STR_TERMINATE); init_sam_entry(&sam[i], &uni_name[i], entries[i].rid); } -- cgit From be0f3f159f6c210cc3f9c6054dc7e1d079f2c611 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 26 Aug 2005 18:57:32 +0000 Subject: r9660: real fix for group enumeration bug in 3.0.20; only affected the ldapsam code (This used to be commit 62f9fb5e3a9bce539c9fedc5fdec1b8741a922c7) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 05aa6fe484..1f79ce5c14 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -670,7 +670,7 @@ static void make_group_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, /* * JRA. I think this should include the null. TNG does not. */ - init_unistr2(&uni_name[i], entries[i].fullname, + init_unistr2(&uni_name[i], entries[i].account_name, UNI_STR_TERMINATE); init_sam_entry(&sam[i], &uni_name[i], entries[i].rid); } -- cgit From 44707ad2e00a91f459e80efbe8f362b5853b0a62 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 29 Aug 2005 14:55:40 +0000 Subject: r9739: conver the reg_objects (REGSUBKEY_CTR & REGVAL_CTR) to use the new talloc() features: Note that the REGSUB_CTR and REGVAL_CTR objects *must* be talloc()'d since the methods use the object pointer as the talloc context for internal private data. There is no longer a regXXX_ctr_intit() and regXXX_ctr_destroy() pair of functions. Simply TALLOC_ZERO_P() and TALLOC_FREE() the object. Also had to convert the printer_info_2->NT_PRINTER_DATA field to be talloc()'d as well. This is just a stop on the road to cleaning up the printer memory management. (This used to be commit ef721333ab9639cb5346067497e99fbd0d4425dd) --- source3/rpc_server/srv_reg_nt.c | 165 +++++++++++++++++++---------------- source3/rpc_server/srv_spoolss_nt.c | 167 ++++++++---------------------------- 2 files changed, 130 insertions(+), 202 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index feb89be542..8b861f8431 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -125,7 +125,7 @@ static WERROR open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY * { REGISTRY_KEY *regkey = NULL; WERROR result = WERR_OK; - REGSUBKEY_CTR subkeys; + REGSUBKEY_CTR *subkeys = NULL; pstring subkeyname2; int subkey_len; @@ -167,21 +167,25 @@ static WERROR open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY * if ( !(regkey->hook = reghook_cache_find( regkey->name )) ) { DEBUG(0,("open_registry_key: Failed to assigned a REGISTRY_HOOK to [%s]\n", regkey->name )); - return WERR_BADFILE; + result = WERR_BADFILE; + goto done; } /* check if the path really exists; failed is indicated by -1 */ /* if the subkey count failed, bail out */ - regsubkey_ctr_init( &subkeys ); - - if ( fetch_reg_keys( regkey, &subkeys ) == -1 ) { + if ( !(subkeys = TALLOC_ZERO_P( p->mem_ctx, REGSUBKEY_CTR )) ) { + result = WERR_NOMEM; + goto done; + } + + if ( fetch_reg_keys( regkey, subkeys ) == -1 ) { result = WERR_BADFILE; goto done; } if ( !create_policy_hnd( p, hnd, free_regkey_info, regkey ) ) { - result = WERR_BADFILE; + result = WERR_BADFILE; goto done; } @@ -192,7 +196,7 @@ static WERROR open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY * done: /* clean up */ - regsubkey_ctr_destroy( &subkeys ); + TALLOC_FREE( subkeys ); if ( ! NT_STATUS_IS_OK(result) ) SAFE_FREE( regkey ); @@ -229,31 +233,32 @@ static BOOL get_subkey_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *m { int num_subkeys, i; uint32 max_len; - REGSUBKEY_CTR subkeys; + REGSUBKEY_CTR *subkeys; uint32 len; if ( !key ) return False; - regsubkey_ctr_init( &subkeys ); - - if ( fetch_reg_keys( key, &subkeys ) == -1 ) + if ( !(subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR )) ) + return False; + + if ( fetch_reg_keys( key, subkeys ) == -1 ) return False; /* find the longest string */ max_len = 0; - num_subkeys = regsubkey_ctr_numkeys( &subkeys ); + num_subkeys = regsubkey_ctr_numkeys( subkeys ); for ( i=0; ivaluename ? strlen(val->valuename)+1 : 0 ); sizemax = MAX(sizemax, val->size ); - val = regval_ctr_specific_value( &values, i ); + val = regval_ctr_specific_value( values, i ); } *maxnum = num_values; *maxlen = lenmax; *maxsize = sizemax; - regval_ctr_destroy( &values ); + TALLOC_FREE( values ); return True; } @@ -400,7 +406,7 @@ WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY /* check granted access first; what is the correct mask here? */ - if ( !(parent->access_granted & (SEC_RIGHTS_ENUM_SUBKEYS|SEC_RIGHTS_CREATE_SUBKEY)) ) + if ( !(parent->access_granted & (SEC_RIGHTS_ENUM_SUBKEYS|SEC_RIGHTS_CREATE_SUBKEY|SEC_RIGHTS_QUERY_VALUE|SEC_RIGHTS_SET_VALUE)) ) return WERR_ACCESS_DENIED; /* open the key first to get the appropriate REGISTRY_HOOK @@ -435,7 +441,7 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL fstring name; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); REGISTRY_VALUE *val = NULL; - REGVAL_CTR regvals; + REGVAL_CTR *regvals; int i; if ( !regkey ) @@ -447,7 +453,8 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL DEBUG(5,("reg_info: looking up value: [%s]\n", name)); - regval_ctr_init( ®vals ); + if ( !(regvals = TALLOC_P( p->mem_ctx, REGVAL_CTR )) ) + return WERR_NOMEM; for ( i=0; fetch_reg_values_specific(regkey, &val, i); i++ ) { @@ -463,7 +470,7 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL init_reg_r_query_value(q_u->ptr_buf, r_u, val, status); - regval_ctr_destroy( ®vals ); + TALLOC_FREE( regvals ); free_registry_value( val ); return status; @@ -774,8 +781,8 @@ static WERROR reg_load_tree( REGF_FILE *regfile, const char *topkeypath, { REGF_NK_REC *subkey; REGISTRY_KEY registry_key; - REGVAL_CTR values; - REGSUBKEY_CTR subkeys; + REGVAL_CTR *values; + REGSUBKEY_CTR *subkeys; int i; pstring path; WERROR result = WERR_OK; @@ -791,13 +798,16 @@ static WERROR reg_load_tree( REGF_FILE *regfile, const char *topkeypath, /* now start parsing the values and subkeys */ - regsubkey_ctr_init( &subkeys ); - regval_ctr_init( &values ); + if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) + return WERR_NOMEM; + if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) + return WERR_NOMEM; + /* copy values into the REGVAL_CTR */ for ( i=0; inum_values; i++ ) { - regval_ctr_addvalue( &values, key->values[i].valuename, key->values[i].type, + regval_ctr_addvalue( values, key->values[i].valuename, key->values[i].type, key->values[i].data, (key->values[i].data_size & ~VK_DATA_IN_OFFSET) ); } @@ -805,20 +815,19 @@ static WERROR reg_load_tree( REGF_FILE *regfile, const char *topkeypath, key->subkey_index = 0; while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { - regsubkey_ctr_addkey( &subkeys, subkey->keyname ); + regsubkey_ctr_addkey( subkeys, subkey->keyname ); } /* write this key and values out */ - if ( !store_reg_values( ®istry_key, &values ) - || !store_reg_keys( ®istry_key, &subkeys ) ) + if ( !store_reg_values( ®istry_key, values ) + || !store_reg_keys( ®istry_key, subkeys ) ) { DEBUG(0,("reg_load_tree: Failed to load %s!\n", topkeypath)); result = WERR_REG_IO_FAILURE; } - regval_ctr_destroy( &values ); - regsubkey_ctr_destroy( &subkeys ); + TALLOC_FREE( subkeys ); if ( !W_ERROR_IS_OK(result) ) return result; @@ -904,8 +913,8 @@ static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, REGF_NK_REC *parent, SEC_DESC *sec_desc ) { REGF_NK_REC *key; - REGVAL_CTR values; - REGSUBKEY_CTR subkeys; + REGVAL_CTR *values; + REGSUBKEY_CTR *subkeys; int i, num_subkeys; pstring key_tmp; char *keyname, *parentpath; @@ -939,24 +948,27 @@ static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, /* lookup the values and subkeys */ - regsubkey_ctr_init( &subkeys ); - regval_ctr_init( &values ); - - fetch_reg_keys( ®istry_key, &subkeys ); - fetch_reg_values( ®istry_key, &values ); + if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) + return WERR_NOMEM; + + if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) + return WERR_NOMEM; + + fetch_reg_keys( ®istry_key, subkeys ); + fetch_reg_values( ®istry_key, values ); /* write out this key */ - if ( !(key = regfio_write_key( regfile, keyname, &values, &subkeys, sec_desc, parent )) ) { + if ( !(key = regfio_write_key( regfile, keyname, values, subkeys, sec_desc, parent )) ) { result = WERR_CAN_NOT_COMPLETE; goto done; } /* write each one of the subkeys out */ - num_subkeys = regsubkey_ctr_numkeys( &subkeys ); + num_subkeys = regsubkey_ctr_numkeys( subkeys ); for ( i=0; ihandle); REGISTRY_KEY *newparent; POLICY_HND newparent_handle; - REGSUBKEY_CTR subkeys; + REGSUBKEY_CTR *subkeys; BOOL write_result; pstring name; WERROR result; @@ -1138,19 +1149,22 @@ WERROR _reg_create_key_ex(pipes_struct *p, REG_Q_CREATE_KEY_EX *q_u, REG_R_CREAT goto done; } - regsubkey_ctr_init( &subkeys ); - + if ( !(subkeys = TALLOC_ZERO_P( p->mem_ctx, REGSUBKEY_CTR )) ) { + result = WERR_NOMEM; + goto done; + } + /* (4) lookup the current keys and add the new one */ - fetch_reg_keys( newparent, &subkeys ); - regsubkey_ctr_addkey( &subkeys, name ); + fetch_reg_keys( newparent, subkeys ); + regsubkey_ctr_addkey( subkeys, name ); /* now write to the registry backend */ - write_result = store_reg_keys( newparent, &subkeys ); - - regsubkey_ctr_destroy( &subkeys ); + write_result = store_reg_keys( newparent, subkeys ); + TALLOC_FREE( subkeys ); + if ( !write_result ) return WERR_REG_IO_FAILURE; @@ -1177,7 +1191,7 @@ done: WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r_u) { REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); - REGVAL_CTR values; + REGVAL_CTR *values; BOOL write_result; fstring valuename; @@ -1198,19 +1212,20 @@ WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r DEBUG(8,("_reg_set_value: Setting value for [%s:%s]\n", key->name, valuename)); - regval_ctr_init( &values ); + if ( !(values = TALLOC_ZERO_P( p->mem_ctx, REGVAL_CTR )) ) + return WERR_NOMEM; /* lookup the current values and add the new one */ - fetch_reg_values( key, &values ); + fetch_reg_values( key, values ); - regval_ctr_addvalue( &values, valuename, q_u->type, q_u->value.buffer, q_u->value.buf_len ); + regval_ctr_addvalue( values, valuename, q_u->type, q_u->value.buffer, q_u->value.buf_len ); /* now write to the registry backend */ - write_result = store_reg_values( key, &values ); + write_result = store_reg_values( key, values ); - regval_ctr_destroy( &values ); + TALLOC_FREE( values ); if ( !write_result ) return WERR_REG_IO_FAILURE; @@ -1226,7 +1241,7 @@ WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->handle); REGISTRY_KEY *newparent; POLICY_HND newparent_handle; - REGSUBKEY_CTR subkeys; + REGSUBKEY_CTR *subkeys; BOOL write_result; pstring name; WERROR result; @@ -1285,19 +1300,22 @@ WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY goto done; } - regsubkey_ctr_init( &subkeys ); + if ( !(subkeys = TALLOC_ZERO_P( p->mem_ctx, REGSUBKEY_CTR )) ) { + result = WERR_NOMEM; + goto done; + } /* lookup the current keys and delete the new one */ - fetch_reg_keys( newparent, &subkeys ); + fetch_reg_keys( newparent, subkeys ); - regsubkey_ctr_delkey( &subkeys, name ); + regsubkey_ctr_delkey( subkeys, name ); /* now write to the registry backend */ - write_result = store_reg_keys( newparent, &subkeys ); + write_result = store_reg_keys( newparent, subkeys ); - regsubkey_ctr_destroy( &subkeys ); + TALLOC_FREE( subkeys ); result = write_result ? WERR_OK : WERR_REG_IO_FAILURE; @@ -1317,7 +1335,7 @@ done: WERROR _reg_delete_value(pipes_struct *p, REG_Q_DELETE_VALUE *q_u, REG_R_DELETE_VALUE *r_u) { REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); - REGVAL_CTR values; + REGVAL_CTR *values; BOOL write_result; fstring valuename; @@ -1336,19 +1354,20 @@ WERROR _reg_delete_value(pipes_struct *p, REG_Q_DELETE_VALUE *q_u, REG_R_DELETE DEBUG(8,("_reg_delete_value: Setting value for [%s:%s]\n", key->name, valuename)); - regval_ctr_init( &values ); + if ( !(values = TALLOC_ZERO_P( p->mem_ctx, REGVAL_CTR )) ) + return WERR_NOMEM; /* lookup the current values and add the new one */ - fetch_reg_values( key, &values ); + fetch_reg_values( key, values ); - regval_ctr_delvalue( &values, valuename ); + regval_ctr_delvalue( values, valuename ); /* now write to the registry backend */ - write_result = store_reg_values( key, &values ); + write_result = store_reg_values( key, values ); - regval_ctr_destroy( &values ); + TALLOC_FREE( values ); if ( !write_result ) return WERR_REG_IO_FAILURE; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5391ac5f41..ee35b5853f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -274,62 +274,6 @@ static Printer_entry *find_printer_index_by_hnd(pipes_struct *p, POLICY_HND *hnd return find_printer; } -#ifdef ENABLE_PRINT_HND_OBJECT_CACHE -/**************************************************************************** - look for a printer object cached on an open printer handle -****************************************************************************/ - -WERROR find_printer_in_print_hnd_cache( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL_2 **info2, - const char *servername, const char *printername ) -{ - Printer_entry *p; - - DEBUG(10,("find_printer_in_print_hnd_cache: printer [\\\\%s\\%s]\n", - servername, printername)); - - for ( p=printers_list; p; p=p->next ) - { - if ( p->printer_type==PRINTER_HANDLE_IS_PRINTER - && p->printer_info - && strequal( p->sharename, printername ) - && strequal( p->servername, servername ) ) - { - DEBUG(10,("Found printer\n")); - *info2 = dup_printer_2( ctx, p->printer_info->info_2 ); - if ( *info2 ) - return WERR_OK; - } - } - - return WERR_INVALID_PRINTER_NAME; -} - -/**************************************************************************** - destroy any cached printer_info_2 structures on open handles -****************************************************************************/ - -void invalidate_printer_hnd_cache( char *printername ) -{ - Printer_entry *p; - - DEBUG(10,("invalidate_printer_hnd_cache: printer [%s]\n", printername)); - - for ( p=printers_list; p; p=p->next ) - { - if ( p->printer_type==PRINTER_HANDLE_IS_PRINTER - && p->printer_info - && StrCaseCmp(p->sharename, printername)==0) - { - DEBUG(10,("invalidating printer_info cache for handl:\n")); - free_a_printer( &p->printer_info, 2 ); - p->printer_info = NULL; - } - } - - return; -} -#endif - /**************************************************************************** Close printer index by handle. ****************************************************************************/ @@ -1216,24 +1160,6 @@ static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, siz return; } -#ifdef ENABLE_PRINT_HND_OBJECT_CACHE -/******************************************************************** - callback to MSG_PRINTER_CHANGED. When a printer is changed by - one smbd, all of processes must clear their printer cache immediately. - ********************************************************************/ - -void receive_printer_mod_msg(int msg_type, pid_t src, void *buf, size_t len) -{ - fstring printername; - - fstrcpy( printername, buf ); - - DEBUG(10,("receive_printer_mod_msg: Printer change [%s]\n", printername )); - - invalidate_printer_hnd_cache( printername ); -} -#endif - /******************************************************************** Send a message to ourself about new driver being installed so we can upgrade the information for each printer bound to this @@ -1804,7 +1730,10 @@ static BOOL convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni, switch (level) { case 2: - ret = uni_2_asc_printer_info_2(uni->info_2, &printer->info_2); + /* printer->info_2 is already a valid printer */ + ret = uni_2_asc_printer_info_2(uni->info_2, printer->info_2); + printer->info_2->setuptime = time(NULL); + break; default: break; @@ -2272,8 +2201,8 @@ static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value, uint32 type, uint8 *data, int real_len ) { - delete_printer_data( printer->info_2, key, value ); - + /* the registry objects enforce uniqueness based on value name */ + return add_printer_data( printer->info_2, key, value, type, data, real_len ); } @@ -4234,22 +4163,19 @@ static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *p printer->cjobs = count; /* jobs */ printer->averageppm = ntprinter->info_2->averageppm; /* average pages per minute */ - if((printer->devmode = construct_dev_mode(snum)) == NULL) { + if ( !(printer->devmode = construct_dev_mode(snum)) ) DEBUG(8, ("Returning NULL Devicemode!\n")); - } - if (ntprinter->info_2->secdesc_buf && ntprinter->info_2->secdesc_buf->len != 0) { - /* steal the printer info sec_desc structure. [badly done]. */ - printer->secdesc = ntprinter->info_2->secdesc_buf->sec; - ntprinter->info_2->secdesc_buf->sec = NULL; /* Stolen memory. */ - ntprinter->info_2->secdesc_buf->len = 0; /* Stolen memory. */ - ntprinter->info_2->secdesc_buf->max_len = 0; /* Stolen memory. */ - } - else { - printer->secdesc = NULL; + printer->secdesc = NULL; + + if ( ntprinter->info_2->secdesc_buf + && ntprinter->info_2->secdesc_buf->len != 0 ) + { + printer->secdesc = dup_sec_desc( get_talloc_ctx(), ntprinter->info_2->secdesc_buf->sec ); } free_a_printer(&ntprinter, 2); + return True; } @@ -4274,32 +4200,12 @@ static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 ** ZERO_STRUCTP(printer); - printer->flags = 4; /* These are the components of the SD we are returning. */ - if (ntprinter->info_2->secdesc_buf && ntprinter->info_2->secdesc_buf->len != 0) { - /* steal the printer info sec_desc structure. [badly done]. */ - printer->secdesc = ntprinter->info_2->secdesc_buf->sec; - -#if 0 - /* - * Set the flags for the components we are returning. - */ + /* These are the components of the SD we are returning. */ - if (printer->secdesc->owner_sid) - printer->flags |= OWNER_SECURITY_INFORMATION; + printer->flags = 0x4; - if (printer->secdesc->grp_sid) - printer->flags |= GROUP_SECURITY_INFORMATION; - - if (printer->secdesc->dacl) - printer->flags |= DACL_SECURITY_INFORMATION; - - if (printer->secdesc->sacl) - printer->flags |= SACL_SECURITY_INFORMATION; -#endif - - ntprinter->info_2->secdesc_buf->sec = NULL; /* Stolen the malloced memory. */ - ntprinter->info_2->secdesc_buf->len = 0; /* Stolen the malloced memory. */ - ntprinter->info_2->secdesc_buf->max_len = 0; /* Stolen the malloced memory. */ + if (ntprinter->info_2->secdesc_buf && ntprinter->info_2->secdesc_buf->len != 0) { + printer->secdesc = dup_sec_desc( get_talloc_ctx(), ntprinter->info_2->secdesc_buf->sec ); } free_a_printer(&ntprinter, 2); @@ -4582,16 +4488,20 @@ static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint3 if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); - if (construct_printer_info_2(NULL, ¤t_prt, snum)) { - if((tp=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_2, *returned +1)) == NULL) { + if (construct_printer_info_2(NULL, ¤t_prt, snum)) + { + if ( !(tp=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_2, *returned +1)) ) { DEBUG(2,("enum_all_printers_info_2: failed to enlarge printers buffer!\n")); SAFE_FREE(printers); *returned = 0; return WERR_NOMEM; } - else printers = tp; + DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *returned)); + + printers = tp; memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_2)); + (*returned)++; } } @@ -4617,9 +4527,10 @@ static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint3 out: /* clear memory */ - for (i=0; i<*returned; i++) { + + for (i=0; i<*returned; i++) free_devmode(printers[i].devmode); - } + SAFE_FREE(printers); if ( !W_ERROR_IS_OK(result) ) @@ -7905,8 +7816,6 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S int i, key_index, num_values; int name_length; - ZERO_STRUCT( printer ); - *out_type = 0; *out_max_data_len = 0; @@ -7927,7 +7836,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S if (!W_ERROR_IS_OK(result)) return result; - p_data = &printer->info_2->data; + p_data = printer->info_2->data; key_index = lookup_printerkey( p_data, SPOOL_PRINTERDATA_KEY ); result = WERR_OK; @@ -7945,11 +7854,11 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S biggest_valuesize = 0; biggest_datasize = 0; - num_values = regval_ctr_numvals( &p_data->keys[key_index].values ); - + num_values = regval_ctr_numvals( p_data->keys[key_index].values ); + for ( i=0; ikeys[key_index].values, i ); + val = regval_ctr_specific_value( p_data->keys[key_index].values, i ); name_length = strlen(val->valuename); if ( strlen(val->valuename) > biggest_valuesize ) @@ -7979,7 +7888,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S */ if ( key_index != -1 ) - val = regval_ctr_specific_value( &p_data->keys[key_index].values, idx ); + val = regval_ctr_specific_value( p_data->keys[key_index].values, idx ); if ( !val ) { @@ -8937,7 +8846,7 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, goto done; } - if ( lookup_printerkey( &printer->info_2->data, keyname ) == -1 ) { + if ( lookup_printerkey( printer->info_2->data, keyname ) == -1 ) { DEBUG(4,("_spoolss_getprinterdataex: Invalid keyname [%s]\n", keyname )); free_a_printer( &printer, 2 ); status = WERR_BADFILE; @@ -9158,7 +9067,7 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO /* get the list of subkey names */ unistr2_to_ascii( key, &q_u->key, sizeof(key)-1 ); - data = &printer->info_2->data; + data = printer->info_2->data; num_keys = get_printer_subkeys( data, key, &keynames ); @@ -9301,7 +9210,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ /* now look for a match on the key name */ - p_data = &printer->info_2->data; + p_data = printer->info_2->data; unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); if ( (key_index = lookup_printerkey( p_data, key)) == -1 ) @@ -9316,7 +9225,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ /* allocate the memory for the array of pointers -- if necessary */ - num_entries = regval_ctr_numvals( &p_data->keys[key_index].values ); + num_entries = regval_ctr_numvals( p_data->keys[key_index].values ); if ( num_entries ) { if ( (enum_values=TALLOC_ARRAY(p->mem_ctx, PRINTER_ENUM_VALUES, num_entries)) == NULL ) @@ -9339,7 +9248,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ { /* lookup the registry value */ - val = regval_ctr_specific_value( &p_data->keys[key_index].values, i ); + val = regval_ctr_specific_value( p_data->keys[key_index].values, i ); DEBUG(10,("retrieved value number [%d] [%s]\n", i, regval_name(val) )); /* copy the data */ -- cgit From c53e760ea52871b476617c6caad64ca88154ff10 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 29 Aug 2005 17:48:01 +0000 Subject: r9752: figured out why talloc_steal() is a bad idea for SEC_DESC* Add a comment so someone else doesn't get bitten by this as well. (This used to be commit 050364ef34b1e69260bd9df9e2140c45263e92f5) --- source3/rpc_server/srv_spoolss_nt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ee35b5853f..33eeec91de 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4171,7 +4171,11 @@ static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *p if ( ntprinter->info_2->secdesc_buf && ntprinter->info_2->secdesc_buf->len != 0 ) { - printer->secdesc = dup_sec_desc( get_talloc_ctx(), ntprinter->info_2->secdesc_buf->sec ); + /* don't use talloc_steal() here unless you do a deep steal of all + the SEC_DESC members */ + + printer->secdesc = dup_sec_desc( get_talloc_ctx(), + ntprinter->info_2->secdesc_buf->sec ); } free_a_printer(&ntprinter, 2); @@ -4205,7 +4209,11 @@ static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 ** printer->flags = 0x4; if (ntprinter->info_2->secdesc_buf && ntprinter->info_2->secdesc_buf->len != 0) { - printer->secdesc = dup_sec_desc( get_talloc_ctx(), ntprinter->info_2->secdesc_buf->sec ); + /* don't use talloc_steal() here unless you do a deep steal of all + the SEC_DESC members */ + + printer->secdesc = dup_sec_desc( get_talloc_ctx(), + ntprinter->info_2->secdesc_buf->sec ); } free_a_printer(&ntprinter, 2); -- cgit From 8c072021efba737539b46e993df0c21a6438a82a Mon Sep 17 00:00:00 2001 From: James Peach Date: Tue, 30 Aug 2005 06:41:32 +0000 Subject: r9780: Clean up a bunch of compiler warnings. (This used to be commit 623d2e69319ffead31a780a4d6156dae45f386d7) --- source3/rpc_server/srv_reg_nt.c | 2 -- source3/rpc_server/srv_srvsvc_nt.c | 3 --- 2 files changed, 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 8b861f8431..7a5216ada5 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -1078,8 +1078,6 @@ WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) DEBUG(2,("_reg_save_key: Saving [%s] to %s in share %s\n", regkey->name, filename, lp_servicename(snum) )); return backup_registry_key( regkey, filename ); - - return WERR_OK; } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index b607d32e54..e9dd015421 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1597,11 +1597,9 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S DEBUG(3, ("_srv_net_share_set_info: client is trying to change csc policy from the network; must be done with smb.conf\n")); return WERR_ACCESS_DENIED; } - break; case 1006: case 1007: return WERR_ACCESS_DENIED; - break; case 1501: pstrcpy(pathname, lp_pathname(snum)); fstrcpy(comment, lp_comment(snum)); @@ -1753,7 +1751,6 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S case 1006: case 1007: return WERR_ACCESS_DENIED; - break; case 1501: /* DFS only level. */ return WERR_ACCESS_DENIED; -- cgit From a206a5efdd4b75e78153a0b23a3d6e5a144ed42a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 30 Aug 2005 11:33:12 +0000 Subject: r9788: more compiler warnings from Jason Mader (This used to be commit 9c51aa5bd2862d73663c4148eff3080341010405) --- source3/rpc_server/srv_reg_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 7a5216ada5..07ebe4e20c 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -808,7 +808,7 @@ static WERROR reg_load_tree( REGF_FILE *regfile, const char *topkeypath, for ( i=0; inum_values; i++ ) { regval_ctr_addvalue( values, key->values[i].valuename, key->values[i].type, - key->values[i].data, (key->values[i].data_size & ~VK_DATA_IN_OFFSET) ); + (char*)key->values[i].data, (key->values[i].data_size & ~VK_DATA_IN_OFFSET) ); } /* copy subkeys into the REGSUBKEY_CTR */ @@ -1217,7 +1217,7 @@ WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r fetch_reg_values( key, values ); - regval_ctr_addvalue( values, valuename, q_u->type, q_u->value.buffer, q_u->value.buf_len ); + regval_ctr_addvalue( values, valuename, q_u->type, (char*)q_u->value.buffer, q_u->value.buf_len ); /* now write to the registry backend */ -- cgit From 513e81458f89b6c32262d7e9645be4750f299393 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 2 Sep 2005 09:10:42 +0000 Subject: r9945: fix typos. Guenther (This used to be commit 12029e902277053a4066eae1b3ae311fae5e6422) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 33eeec91de..cda3f26137 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1594,7 +1594,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, if (printer_default->access_required & ~(SERVER_ACCESS_ADMINISTER | SERVER_ACCESS_ENUMERATE)) { - DEBUG(3, ("access DENIED for non-printserver bits")); + DEBUG(3, ("access DENIED for non-printserver bits\n")); close_printer_handle(p, handle); return WERR_ACCESS_DENIED; } -- cgit From d4f2df5d5cfe50de71eadbb14cf920c6af29bc39 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 2 Sep 2005 13:42:56 +0000 Subject: r9956: Ensure accounts with the SeAddUsersPrivilege can modify domain and local group attributes (posted to samba ml and confirmed fix) (This used to be commit 005d4cb3c636383ccf70c4891cd7cc4bd3b48ad2) --- source3/rpc_server/srv_samr_nt.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1f79ce5c14..656241a73f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3924,6 +3924,8 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ GROUP_MAP map; GROUP_INFO_CTR *ctr; uint32 acc_granted; + BOOL ret; + BOOL can_mod_accounts; if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; @@ -3948,11 +3950,21 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ return NT_STATUS_INVALID_INFO_CLASS; } - if(!pdb_update_group_mapping_entry(&map)) { - return NT_STATUS_NO_SUCH_GROUP; - } + can_mod_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users ); - return NT_STATUS_OK; + /******** BEGIN SeAddUsers BLOCK *********/ + + if ( can_mod_accounts ) + become_root(); + + ret = pdb_update_group_mapping_entry(&map); + + if ( can_mod_accounts ) + unbecome_root(); + + /******** End SeAddUsers BLOCK *********/ + + return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; } /********************************************************************* @@ -3967,6 +3979,8 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ struct acct_info info; ALIAS_INFO_CTR *ctr; uint32 acc_granted; + BOOL ret; + BOOL can_mod_accounts; if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; @@ -3989,11 +4003,21 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ return NT_STATUS_INVALID_INFO_CLASS; } - if(!pdb_set_aliasinfo(&group_sid, &info)) { - return NT_STATUS_ACCESS_DENIED; - } + can_mod_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users ); - return NT_STATUS_OK; + /******** BEGIN SeAddUsers BLOCK *********/ + + if ( can_mod_accounts ) + become_root(); + + ret = pdb_set_aliasinfo( &group_sid, &info ); + + if ( can_mod_accounts ) + unbecome_root(); + + /******** End SeAddUsers BLOCK *********/ + + return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; } /********************************************************************* -- cgit From a9b96c6b3d2fa111c2210b57fa816fcbc1946fc5 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 14 Sep 2005 12:49:24 +0000 Subject: r10221: add "free pass for root" in svcctl and default winreg access checks (This used to be commit 24901187962e24bfa5ba7722aba0aeb9397ac7b6) --- source3/rpc_server/srv_reg_nt.c | 8 ++++++++ source3/rpc_server/srv_svcctl_nt.c | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 07ebe4e20c..7a48b8dd22 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -46,6 +46,14 @@ NTSTATUS registry_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, se_map_generic( &access_desired, ®_generic_map ); se_access_check( sec_desc, token, access_desired, access_granted, &result ); + + if ( !NT_STATUS_IS_OK(result) ) { + if ( geteuid() == sec_initial_uid() ) { + DEBUG(5,("registry_access_check: access check bypassed for 'root'\n")); + *access_granted = access_desired; + return NT_STATUS_OK; + } + } return result; } diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 2e44dc3692..16c3259840 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -59,10 +59,18 @@ static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, uint32 access_desired, uint32 *access_granted ) { NTSTATUS result; - + /* maybe add privilege checks in here later */ se_access_check( sec_desc, token, access_desired, access_granted, &result ); + + if ( !NT_STATUS_IS_OK(result) ) { + if ( geteuid() == sec_initial_uid() ) { + DEBUG(5,("svcctl_access_check: access check bypassed for 'root'\n")); + *access_granted = access_desired; + return NT_STATUS_OK; + } + } return result; } -- cgit From fbcaef3bf662b4a46ce7e131ae6bd04c3b735433 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 16 Sep 2005 14:47:21 +0000 Subject: r10264: reverse order of 'root free pass' checks in service and registry access_checks() (This used to be commit 35b338a4fc95c14629579336dcf3bd240fda92d3) --- source3/rpc_server/srv_reg_nt.c | 15 +++++++-------- source3/rpc_server/srv_svcctl_nt.c | 14 +++++--------- 2 files changed, 12 insertions(+), 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 7a48b8dd22..9ffc77fce8 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -45,16 +45,15 @@ NTSTATUS registry_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, NTSTATUS result; se_map_generic( &access_desired, ®_generic_map ); - se_access_check( sec_desc, token, access_desired, access_granted, &result ); - if ( !NT_STATUS_IS_OK(result) ) { - if ( geteuid() == sec_initial_uid() ) { - DEBUG(5,("registry_access_check: access check bypassed for 'root'\n")); - *access_granted = access_desired; - return NT_STATUS_OK; - } + if ( geteuid() == sec_initial_uid() ) { + DEBUG(5,("registry_access_check: access check bypassed for 'root'\n")); + *access_granted = access_desired; + return NT_STATUS_OK; } - + + se_access_check( sec_desc, token, access_desired, access_granted, &result ); + return result; } diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 16c3259840..538b97a2b1 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -60,18 +60,14 @@ static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, { NTSTATUS result; - /* maybe add privilege checks in here later */ + if ( geteuid() == sec_initial_uid() ) { + DEBUG(5,("svcctl_access_check: access check bypassed for 'root'\n")); + *access_granted = access_desired; + return NT_STATUS_OK; + } se_access_check( sec_desc, token, access_desired, access_granted, &result ); - if ( !NT_STATUS_IS_OK(result) ) { - if ( geteuid() == sec_initial_uid() ) { - DEBUG(5,("svcctl_access_check: access check bypassed for 'root'\n")); - *access_granted = access_desired; - return NT_STATUS_OK; - } - } - return result; } -- cgit From c2e5ce15017270cfc62ea4fed23976115305b0d5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 16 Sep 2005 16:20:48 +0000 Subject: r10269: Server-side fix for creds change - revert jcmd's change. Jeremy. (This used to be commit e1c9813d63a441037bc71622a29acda099d72f71) --- source3/rpc_server/srv_netlog_nt.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 78ff669d07..15827a8b55 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -449,7 +449,6 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->clnt_id.cred, &srv_cred))) return NT_STATUS_INVALID_HANDLE; - reseed_client_creds(&p->dc.clnt_cred, &q_u->clnt_id.cred); memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); @@ -547,7 +546,6 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF return NT_STATUS_INVALID_HANDLE; /* what happens if we get a logoff for an unknown user? */ - reseed_client_creds(&p->dc.clnt_cred, &q_u->sam_id.client.cred); memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); /* XXXX maybe we want to say 'no', reject the client's credentials */ @@ -606,6 +604,8 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred))) return NT_STATUS_INVALID_HANDLE; + memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); + r_u->buffer_creds = 1; /* yes, we have valid server credentials */ memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds)); @@ -729,12 +729,6 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return status; } - /* moved from right after deal_with_creds above, since we weren't - supposed to update unless logon was successful */ - - reseed_client_creds(&p->dc.clnt_cred, &q_u->sam_id.client.cred); - memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); - if (server_info->guest) { /* We don't like guest domain logons... */ DEBUG(5,("_net_sam_logon: Attempted domain logon as GUEST denied.\n")); -- cgit From 1896d77fe59de96e3ccc33c35fc93317d907b697 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 28 Sep 2005 16:54:42 +0000 Subject: r10585: variation of fix in trunk for root-free-pass in registry access checks (This used to be commit b41f997a2a67f7dc60b300866b38f72846c600fb) --- source3/rpc_server/srv_reg_nt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 9ffc77fce8..a405948864 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -44,14 +44,13 @@ NTSTATUS registry_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, { NTSTATUS result; - se_map_generic( &access_desired, ®_generic_map ); - if ( geteuid() == sec_initial_uid() ) { DEBUG(5,("registry_access_check: access check bypassed for 'root'\n")); - *access_granted = access_desired; + *access_granted = REG_KEY_ALL; return NT_STATUS_OK; } + se_map_generic( &access_desired, ®_generic_map ); se_access_check( sec_desc, token, access_desired, access_granted, &result ); return result; -- cgit From 54abd2aa66069e6baf7769c496f46d9dba18db39 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Sep 2005 17:13:37 +0000 Subject: r10656: BIG merge from trunk. Features not copied over * \PIPE\unixinfo * winbindd's {group,alias}membership new functions * winbindd's lookupsids() functionality * swat (trunk changes to be reverted as per discussion with Deryck) (This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3) --- source3/rpc_server/srv_eventlog.c | 6 - source3/rpc_server/srv_eventlog_nt.c | 1585 +++++++++++++-------------- source3/rpc_server/srv_lsa_hnd.c | 6 +- source3/rpc_server/srv_lsa_nt.c | 7 +- source3/rpc_server/srv_netlog_nt.c | 269 ++--- source3/rpc_server/srv_ntsvcs.c | 220 ++++ source3/rpc_server/srv_ntsvcs_nt.c | 174 +++ source3/rpc_server/srv_pipe.c | 2001 ++++++++++++++++++++++------------ source3/rpc_server/srv_pipe_hnd.c | 217 ++-- source3/rpc_server/srv_reg.c | 57 +- source3/rpc_server/srv_reg_nt.c | 436 +++----- source3/rpc_server/srv_samr_nt.c | 153 +-- source3/rpc_server/srv_samr_util.c | 4 +- source3/rpc_server/srv_spoolss_nt.c | 55 +- source3/rpc_server/srv_srvsvc_nt.c | 5 +- source3/rpc_server/srv_svcctl.c | 76 +- source3/rpc_server/srv_svcctl_nt.c | 694 ++++++------ 17 files changed, 3472 insertions(+), 2493 deletions(-) create mode 100644 source3/rpc_server/srv_ntsvcs.c create mode 100644 source3/rpc_server/srv_ntsvcs_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c index 65b10e8fe4..ae15d43f4b 100644 --- a/source3/rpc_server/srv_eventlog.c +++ b/source3/rpc_server/srv_eventlog.c @@ -27,7 +27,6 @@ static BOOL api_eventlog_open_eventlog(pipes_struct *p) { EVENTLOG_Q_OPEN_EVENTLOG q_u; EVENTLOG_R_OPEN_EVENTLOG r_u; - prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -53,7 +52,6 @@ static BOOL api_eventlog_close_eventlog(pipes_struct *p) { EVENTLOG_Q_CLOSE_EVENTLOG q_u; EVENTLOG_R_CLOSE_EVENTLOG r_u; - prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -79,7 +77,6 @@ static BOOL api_eventlog_get_num_records(pipes_struct *p) { EVENTLOG_Q_GET_NUM_RECORDS q_u; EVENTLOG_R_GET_NUM_RECORDS r_u; - prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -105,7 +102,6 @@ static BOOL api_eventlog_get_oldest_entry(pipes_struct *p) { EVENTLOG_Q_GET_OLDEST_ENTRY q_u; EVENTLOG_R_GET_OLDEST_ENTRY r_u; - prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -131,7 +127,6 @@ static BOOL api_eventlog_read_eventlog(pipes_struct *p) { EVENTLOG_Q_READ_EVENTLOG q_u; EVENTLOG_R_READ_EVENTLOG r_u; - prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -157,7 +152,6 @@ static BOOL api_eventlog_clear_eventlog(pipes_struct *p) { EVENTLOG_Q_CLEAR_EVENTLOG q_u; EVENTLOG_R_CLEAR_EVENTLOG r_u; - prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index a9b0c9bed8..414c99d28e 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -1,7 +1,8 @@ /* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines - * Copyright (C) Marcin Krzysztof Porwit 2005. + * Copyright (C) Marcin Krzysztof Porwit 2005, + * Copyright (C) Gerald (Jerry) Carter 2005. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,56 +24,152 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -typedef struct eventlog_info +typedef struct { + char *logname; + char *servername; + uint32 num_records; + uint32 oldest_entry; + uint32 flags; +} EventlogInfo; + + +/******************************************************************** + Inform the external eventlog machinery of default values (on startup + probably) +********************************************************************/ + +void eventlog_refresh_external_parameters( NT_USER_TOKEN *token ) { - /* for use by the \PIPE\eventlog policy */ - fstring source_log_file_name; - fstring source_server_name; - fstring handle_string; - uint32 num_records; - uint32 oldest_entry; - uint32 active_entry; - uint32 flags; -} Eventlog_info; + const char **elogs = lp_eventlog_list(); + int i; + + if ( !elogs ) + return ; + + if ( !*lp_eventlog_control_cmd() ) + return; + + for ( i=0; elogs[i]; i++ ) { + + DEBUG(10,("eventlog_refresh_external_parameters: Refreshing =>[%s]\n", + elogs[i])); + + if ( !control_eventlog_hook( token, elogs[i] ) ) { + DEBUG(0,("eventlog_refresh_external_parameters: failed to refresh [%s]\n", + elogs[i])); + } + } + + return; +} + +/******************************************************************** +********************************************************************/ static void free_eventlog_info(void *ptr) { - struct eventlog_info *info = (struct eventlog_info *)ptr; - memset(info->source_log_file_name, '0', sizeof(*(info->source_log_file_name))); - memset(info->source_server_name, '0', sizeof(*(info->source_server_name))); - memset(info->handle_string, '0', sizeof(*(info->handle_string))); - memset(info, 0, sizeof(*(info))); - SAFE_FREE(info); + TALLOC_FREE( ptr ); } -static Eventlog_info *find_eventlog_info_by_hnd(pipes_struct *p, - POLICY_HND *handle) +/******************************************************************** +********************************************************************/ + +static EventlogInfo *find_eventlog_info_by_hnd(pipes_struct *p, POLICY_HND *handle) { - Eventlog_info *info = NULL; + EventlogInfo *info; - if(!(find_policy_by_hnd(p,handle,(void **)&info))) - { - DEBUG(2,("find_eventlog_info_by_hnd: eventlog not found.\n")); - } + if ( !find_policy_by_hnd(p,handle,(void **)&info) ) { + DEBUG(2,("find_eventlog_info_by_hnd: eventlog not found.\n")); + return NULL; + } - return info; + return info; } -void policy_handle_to_string(POLICY_HND *handle, fstring *dest) +/******************************************************************** + Callout to control the specified event log - passing out only + the MaxSize and Retention values, along with eventlog name + uses smbrun... + INPUT: + OUTPUT: nothing +********************************************************************/ + +BOOL control_eventlog_hook(NT_USER_TOKEN *token, const char *elogname ) { - memset(dest, 0, sizeof(*dest)); - snprintf((char *)dest, sizeof(*dest), "%08X-%08X-%04X-%04X-%02X%02X%02X%02X%02X", - handle->data1, - handle->data2, - handle->data3, - handle->data4, - handle->data5[0], - handle->data5[1], - handle->data5[2], - handle->data5[3], - handle->data5[4]); + char *cmd = lp_eventlog_control_cmd(); + pstring command; + int ret; + int fd = -1; + uint32 uiMaxSize, uiRetention; + pstring path; + REGISTRY_KEY *keyinfo; + REGISTRY_VALUE *val; + REGVAL_CTR *values; + WERROR wresult; + + if ( !cmd || !*cmd ) { + DEBUG(0, ("control_eventlog_hook: No \"eventlog control command\" defined in smb.conf!\n")); + return False; + } + + /* set resonable defaults. 512Kb on size and 1 week on time */ + + uiMaxSize = 0x80000; + uiRetention = 604800; + + /* the general idea is to internally open the registry + key and retreive the values. That way we can continue + to use the same fetch/store api that we use in + srv_reg_nt.c */ + + pstr_sprintf( path, "%s/%s", KEY_EVENTLOG, elogname ); + wresult = regkey_open_internal( &keyinfo, path, token, REG_KEY_READ ); + + if ( !W_ERROR_IS_OK( wresult ) ) { + DEBUG(4,("control_eventlog_hook: Failed to open key [%s] (%s)\n", + path, dos_errstr(wresult) )); + return False; + } + + if ( !(values = TALLOC_ZERO_P( keyinfo, REGVAL_CTR )) ) { + TALLOC_FREE( keyinfo ); + DEBUG(0,("control_eventlog_hook: talloc() failed!\n")); + + return False; + } + fetch_reg_values( keyinfo, values ); + + if ( (val = regval_ctr_getvalue( values, "Retention" )) != NULL ) + uiRetention = IVAL( regval_data_p(val), 0 ); + + if ( (val = regval_ctr_getvalue( values, "MaxSize" )) != NULL ) + uiMaxSize = IVAL( regval_data_p(val), 0 ); + + TALLOC_FREE( keyinfo ); + + /* now run the command */ + + pstr_sprintf(command, "%s \"%s\" %u %u", cmd, elogname, uiRetention, uiMaxSize ); + + DEBUG(10, ("control_eventlog_hook: Running [%s]\n", command)); + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); + + if ( ret != 0 ) { + DEBUG(10,("control_eventlog_hook: Command returned [%d]\n", ret)); + if (fd != -1 ) + close(fd); + return False; + } + + close(fd); + return True; } + +/******************************************************************** +********************************************************************/ + /** * Callout to open the specified event log * @@ -81,109 +178,53 @@ void policy_handle_to_string(POLICY_HND *handle, fstring *dest) * OUTPUT: the string "SUCCESS" if the command succeeded * no such string if there was a failure. */ -static BOOL _eventlog_open_eventlog_hook(Eventlog_info *info) +static BOOL open_eventlog_hook( EventlogInfo *info ) { - char *cmd = lp_eventlog_open_cmd(); - char **qlines; - pstring command; - int numlines = 0; - int ret; - int fd = -1; - - if(cmd == NULL || strlen(cmd) == 0) - { - DEBUG(0, ("Must define an \"eventlog open command\" entry in the config.\n")); - return False; - } - - memset(command, 0, sizeof(command)); - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", - cmd, - info->source_log_file_name, - info->handle_string); - - DEBUG(10, ("Running [%s]\n", command)); - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - - if(ret != 0) - { - if(fd != -1) - close(fd); - return False; - } + char *cmd = lp_eventlog_open_cmd(); + char **qlines; + pstring command; + int numlines = 0; + int ret; + int fd = -1; + + if ( !cmd || !*cmd ) { + DEBUG(0, ("Must define an \"eventlog open command\" entry in the config.\n")); + return False; + } + + pstr_sprintf(command, "%s \"%s\"", cmd, info->logname ); - qlines = fd_lines_load(fd, &numlines); - DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); - close(fd); + DEBUG(10, ("Running [%s]\n", command)); + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); - if(numlines) - { - DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); - if(0 == strncmp(qlines[0], "SUCCESS", strlen("SUCCESS"))) - { - DEBUGADD(10, ("Able to open [%s].\n", info->source_log_file_name)); - file_lines_free(qlines); - return True; + if(ret != 0) { + if(fd != -1) { + close(fd); + } + return False; } - } - file_lines_free(qlines); - return False; -} + qlines = fd_lines_load(fd, &numlines); + DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); + close(fd); -WERROR _eventlog_open_eventlog(pipes_struct *p, - EVENTLOG_Q_OPEN_EVENTLOG *q_u, - EVENTLOG_R_OPEN_EVENTLOG *r_u) -{ - Eventlog_info *info = NULL; - - if(!q_u || !r_u) - return WERR_NOMEM; - - if((info = SMB_MALLOC_P(Eventlog_info)) == NULL) - return WERR_NOMEM; - - ZERO_STRUCTP(info); - - if(q_u->servername_ptr != 0) - { - unistr2_to_ascii(info->source_server_name, &(q_u->servername), sizeof(info->source_server_name)); - } - else - { - /* if servername == NULL, use the local computer */ - fstrcpy(info->source_server_name, global_myname()); - } - DEBUG(10, ("_eventlog_open_eventlog: Using [%s] as the server name.\n", info->source_server_name)); - - if(q_u->sourcename_ptr != 0) - { - unistr2_to_ascii(info->source_log_file_name, &(q_u->sourcename), sizeof(info->source_log_file_name)); - } - else - { - /* if sourcename == NULL, default to "Application" log */ - fstrcpy(info->source_log_file_name, "Application"); - } - DEBUG(10, ("_eventlog_open_eventlog: Using [%s] as the source log file.\n", info->source_log_file_name)); - - if(!create_policy_hnd(p, &(r_u->handle), free_eventlog_info, (void *)info)) - { - free_eventlog_info(info); - return WERR_NOMEM; - } - - policy_handle_to_string(&r_u->handle, &info->handle_string); - - if(!(_eventlog_open_eventlog_hook(info))) - { - close_policy_hnd(p, &r_u->handle); - return WERR_BADFILE; - } - - return WERR_OK; + if(numlines) { + DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); + if(0 == strncmp(qlines[0], "SUCCESS", strlen("SUCCESS"))) { + DEBUGADD(10, ("Able to open [%s].\n", info->logname)); + file_lines_free(qlines); + return True; + } + } + + file_lines_free(qlines); + + return False; } + +/******************************************************************** +********************************************************************/ /** * Callout to get the number of records in the specified event log * @@ -192,74 +233,52 @@ WERROR _eventlog_open_eventlog(pipes_struct *p, * OUTPUT: A single line with a single integer containing the number of * entries in the log. If there are no entries in the log, return 0. */ -static BOOL _eventlog_get_num_records_hook(Eventlog_info *info) -{ - char *cmd = lp_eventlog_num_records_cmd(); - char **qlines; - pstring command; - int numlines = 0; - int ret; - int fd = -1; - - if(cmd == NULL || strlen(cmd) == 0) - { - DEBUG(0, ("Must define an \"eventlog num records command\" entry in the config.\n")); - return False; - } - - memset(command, 0, sizeof(command)); - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", - cmd, - info->source_log_file_name, - info->handle_string); - - DEBUG(10, ("Running [%s]\n", command)); - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - - if(ret != 0) - { - if(fd != -1) - close(fd); - return False; - } - qlines = fd_lines_load(fd, &numlines); - DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); - close(fd); +static BOOL get_num_records_hook(EventlogInfo *info) +{ + char *cmd = lp_eventlog_num_records_cmd(); + char **qlines; + pstring command; + int numlines = 0; + int ret; + int fd = -1; + + if ( !cmd || !*cmd ) { + DEBUG(0, ("Must define an \"eventlog num records command\" entry in the config.\n")); + return False; + } - if(numlines) - { - DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); - sscanf(qlines[0], "%d", &(info->num_records)); - file_lines_free(qlines); - return True; - } + pstr_sprintf( command, "%s \"%s\"", cmd, info->logname ); - file_lines_free(qlines); - return False; -} + DEBUG(10, ("Running [%s]\n", command)); + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); -WERROR _eventlog_get_num_records(pipes_struct *p, - EVENTLOG_Q_GET_NUM_RECORDS *q_u, - EVENTLOG_R_GET_NUM_RECORDS *r_u) -{ - Eventlog_info *info = NULL; - POLICY_HND *handle = NULL; + if(ret != 0) { + if(fd != -1) { + close(fd); + } + return False; + } - if(!q_u || !r_u) - return WERR_NOMEM; + qlines = fd_lines_load(fd, &numlines); + DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); + close(fd); - handle = &(q_u->handle); - info = find_eventlog_info_by_hnd(p, handle); + if(numlines) { + DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); + sscanf(qlines[0], "%d", &(info->num_records)); + file_lines_free(qlines); + return True; + } - if(!(_eventlog_get_num_records_hook(info))) - return WERR_BADFILE; + file_lines_free(qlines); + return False; +} - r_u->num_records = info->num_records; +/******************************************************************** +********************************************************************/ - return WERR_OK; -} /** * Callout to find the oldest record in the log * @@ -269,75 +288,51 @@ WERROR _eventlog_get_num_records(pipes_struct *p, * oldest entry. Must be 1 or greater. * If there are no entries in the log, returns a 0 */ -static BOOL _eventlog_get_oldest_entry_hook(Eventlog_info *info) -{ - char *cmd = lp_eventlog_oldest_record_cmd(); - char **qlines; - pstring command; - int numlines = 0; - int ret; - int fd = -1; - - if(cmd == NULL || strlen(cmd) == 0) - { - DEBUG(0, ("Must define an \"eventlog oldest record command\" entry in the config.\n")); - return False; - } - - memset(command, 0, sizeof(command)); - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", - cmd, - info->source_log_file_name, - info->handle_string); - - DEBUG(10, ("Running [%s]\n", command)); - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - - if(ret != 0) - { - if(fd != -1) - close(fd); - return False; - } - qlines = fd_lines_load(fd, &numlines); - DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); - close(fd); - - if(numlines) - { - DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); - sscanf(qlines[0], "%d", &(info->oldest_entry)); - file_lines_free(qlines); - return True; - } - - file_lines_free(qlines); - return False; -} - -WERROR _eventlog_get_oldest_entry(pipes_struct *p, - EVENTLOG_Q_GET_OLDEST_ENTRY *q_u, - EVENTLOG_R_GET_OLDEST_ENTRY *r_u) +static BOOL get_oldest_entry_hook(EventlogInfo *info) { - Eventlog_info *info = NULL; - POLICY_HND *handle = NULL; + char *cmd = lp_eventlog_oldest_record_cmd(); + char **qlines; + pstring command; + int numlines = 0; + int ret; + int fd = -1; + + if ( !cmd || !*cmd ) { + DEBUG(0, ("Must define an \"eventlog oldest record command\" entry in the config.\n")); + return False; + } + + pstr_sprintf( command, "%s \"%s\"", cmd, info->logname ); - if(!q_u || !r_u) - return WERR_NOMEM; + DEBUG(10, ("Running [%s]\n", command)); + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); - handle = &(q_u->handle); - info = find_eventlog_info_by_hnd(p, handle); + if(ret != 0) { + if(fd != -1) { + close(fd); + } + return False; + } - if(!(_eventlog_get_oldest_entry_hook(info))) - return WERR_BADFILE; + qlines = fd_lines_load(fd, &numlines); + DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); + close(fd); - r_u->oldest_entry = info->oldest_entry; + if(numlines) { + DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); + sscanf(qlines[0], "%d", &(info->oldest_entry)); + file_lines_free(qlines); + return True; + } - return WERR_OK; + file_lines_free(qlines); + return False; } +/******************************************************************** +********************************************************************/ /** * Callout to close the specified event log * @@ -346,270 +341,206 @@ WERROR _eventlog_get_oldest_entry(pipes_struct *p, * OUTPUT: the string "SUCCESS" if the command succeeded * no such string if there was a failure. */ -static BOOL _eventlog_close_eventlog_hook(Eventlog_info *info) + +static BOOL close_eventlog_hook(EventlogInfo *info) { - char *cmd = lp_eventlog_close_cmd(); - char **qlines; - pstring command; - int numlines = 0; - int ret; - int fd = -1; - - if(cmd == NULL || strlen(cmd) == 0) - { - DEBUG(0, ("Must define an \"eventlog close command\" entry in the config.\n")); - return False; - } - - memset(command, 0, sizeof(command)); - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", - cmd, - info->source_log_file_name, - info->handle_string); - - DEBUG(10, ("Running [%s]\n", command)); - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - - if(ret != 0) - { - if(fd != -1) - close(fd); - return False; - } + char *cmd = lp_eventlog_close_cmd(); + char **qlines; + pstring command; + int numlines = 0; + int ret; + int fd = -1; + + if ( !cmd || !*cmd ) { + DEBUG(0, ("Must define an \"eventlog close command\" entry in the config.\n")); + return False; + } - qlines = fd_lines_load(fd, &numlines); - DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); - close(fd); + pstr_sprintf( command, "%s \"%s\"", cmd, info->logname ); - if(numlines) - { - DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); - if(0 == strncmp(qlines[0], "SUCCESS", strlen("SUCCESS"))) - { - DEBUGADD(10, ("Able to close [%s].\n", info->source_log_file_name)); - file_lines_free(qlines); - return True; - } - } + DEBUG(10, ("Running [%s]\n", command)); + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); - file_lines_free(qlines); - return False; -} + if(ret != 0) { + if(fd != -1) { + close(fd); + } + return False; + } -WERROR _eventlog_close_eventlog(pipes_struct *p, - EVENTLOG_Q_CLOSE_EVENTLOG *q_u, - EVENTLOG_R_CLOSE_EVENTLOG *r_u) -{ - Eventlog_info *info = NULL; - POLICY_HND *handle; + qlines = fd_lines_load(fd, &numlines); + DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); + close(fd); - if(!q_u || !r_u) - return WERR_NOMEM; + if(numlines) { + DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); + if(0 == strncmp(qlines[0], "SUCCESS", 7)) { + DEBUGADD(10, ("Able to close [%s].\n", info->logname)); + file_lines_free(qlines); + return True; + } + } - handle = &(q_u->handle); - - info = find_eventlog_info_by_hnd(p, handle); - if(!(_eventlog_close_eventlog_hook(info))) - return WERR_BADFILE; - - if(!(close_policy_hnd(p, handle))) - { - /* WERR_NOMEM is probably not the correct error, but until I figure out a better - one it will have to do */ - return WERR_NOMEM; - } - - return WERR_OK; + file_lines_free(qlines); + return False; } -static BOOL _eventlog_read_parse_line(char *line, Eventlog_entry *entry, BOOL *eor) +/******************************************************************** +********************************************************************/ + +static BOOL parse_logentry(char *line, Eventlog_entry *entry, BOOL *eor) { - char *start = NULL, *stop = NULL; - pstring temp; - int temp_len = 0, i; + char *start = NULL, *stop = NULL; + pstring temp; + int temp_len = 0, i; - start = line; + start = line; - /* empty line signyfiying record delimeter, or we're at the end of the buffer */ - if(start == NULL || strlen(start) == 0) - { - DEBUG(6, ("_eventlog_read_parse_line: found end-of-record indicator.\n")); - *eor = True; - return True; - } - if(!(stop = strchr(line, ':'))) - return False; + /* empty line signyfiying record delimeter, or we're at the end of the buffer */ + if(start == NULL || strlen(start) == 0) { + DEBUG(6, ("parse_logentry: found end-of-record indicator.\n")); + *eor = True; + return True; + } + if(!(stop = strchr(line, ':'))) { + return False; + } - DEBUG(6, ("_eventlog_read_parse_line: trying to parse [%s].\n", line)); - - if(0 == strncmp(start, "LEN", stop - start)) - { - /* This will get recomputed later anyway -- probably not necessary */ - entry->record.length = atoi(stop + 1); - } - else if(0 == strncmp(start, "RS1", stop - start)) - { - /* For now all these reserved entries seem to have the same value, - which can be hardcoded to int(1699505740) for now */ - entry->record.reserved1 = atoi(stop + 1); - } - else if(0 == strncmp(start, "RCN", stop - start)) - { - entry->record.record_number = atoi(stop + 1); - } - else if(0 == strncmp(start, "TMG", stop - start)) - { - entry->record.time_generated = atoi(stop + 1); - } - else if(0 == strncmp(start, "TMW", stop - start)) - { - entry->record.time_written = atoi(stop + 1); - } - else if(0 == strncmp(start, "EID", stop - start)) - { - entry->record.event_id = atoi(stop + 1); - } - else if(0 == strncmp(start, "ETP", stop - start)) - { - if(strstr(start, "ERROR")) - { - entry->record.event_type = EVENTLOG_ERROR_TYPE; - } - else if(strstr(start, "WARNING")) - { - entry->record.event_type = EVENTLOG_WARNING_TYPE; - } - else if(strstr(start, "INFO")) - { - entry->record.event_type = EVENTLOG_INFORMATION_TYPE; - } - else if(strstr(start, "AUDIT_SUCCESS")) - { - entry->record.event_type = EVENTLOG_AUDIT_SUCCESS; - } - else if(strstr(start, "AUDIT_FAILURE")) - { - entry->record.event_type = EVENTLOG_AUDIT_FAILURE; - } - else if(strstr(start, "SUCCESS")) - { - entry->record.event_type = EVENTLOG_SUCCESS; - } - else - { - /* some other eventlog type -- currently not defined in MSDN docs, so error out */ - return False; - } - } + DEBUG(6, ("parse_logentry: trying to parse [%s].\n", line)); + + if(0 == strncmp(start, "LEN", stop - start)) { + /* This will get recomputed later anyway -- probably not necessary */ + entry->record.length = atoi(stop + 1); + } else if(0 == strncmp(start, "RS1", stop - start)) { + /* For now all these reserved entries seem to have the same value, + which can be hardcoded to int(1699505740) for now */ + entry->record.reserved1 = atoi(stop + 1); + } else if(0 == strncmp(start, "RCN", stop - start)) { + entry->record.record_number = atoi(stop + 1); + } else if(0 == strncmp(start, "TMG", stop - start)) { + entry->record.time_generated = atoi(stop + 1); + } else if(0 == strncmp(start, "TMW", stop - start)) { + entry->record.time_written = atoi(stop + 1); + } else if(0 == strncmp(start, "EID", stop - start)) { + entry->record.event_id = atoi(stop + 1); + } else if(0 == strncmp(start, "ETP", stop - start)) { + if(strstr(start, "ERROR")) { + entry->record.event_type = EVENTLOG_ERROR_TYPE; + } else if(strstr(start, "WARNING")) { + entry->record.event_type = EVENTLOG_WARNING_TYPE; + } else if(strstr(start, "INFO")) { + entry->record.event_type = EVENTLOG_INFORMATION_TYPE; + } else if(strstr(start, "AUDIT_SUCCESS")) { + entry->record.event_type = EVENTLOG_AUDIT_SUCCESS; + } else if(strstr(start, "AUDIT_FAILURE")) { + entry->record.event_type = EVENTLOG_AUDIT_FAILURE; + } else if(strstr(start, "SUCCESS")) { + entry->record.event_type = EVENTLOG_SUCCESS; + } else { + /* some other eventlog type -- currently not defined in MSDN docs, so error out */ + return False; + } + } /* - else if(0 == strncmp(start, "NST", stop - start)) - { - entry->record.num_strings = atoi(stop + 1); - } + else if(0 == strncmp(start, "NST", stop - start)) + { + entry->record.num_strings = atoi(stop + 1); + } */ - else if(0 == strncmp(start, "ECT", stop - start)) - { - entry->record.event_category = atoi(stop + 1); - } - else if(0 == strncmp(start, "RS2", stop - start)) - { - entry->record.reserved2 = atoi(stop + 1); - } - else if(0 == strncmp(start, "CRN", stop - start)) - { - entry->record.closing_record_number = atoi(stop + 1); - } - else if(0 == strncmp(start, "USL", stop - start)) - { - entry->record.user_sid_length = atoi(stop + 1); - } - else if(0 == strncmp(start, "SRC", stop - start)) - { - memset(temp, 0, sizeof(temp)); - stop++; - while(isspace(stop[0])) - stop++; - temp_len = strlen(stop); - strncpy(temp, stop, temp_len); - rpcstr_push((void *)(entry->data_record.source_name), temp, - sizeof(entry->data_record.source_name), STR_TERMINATE); - entry->data_record.source_name_len = (strlen_w(entry->data_record.source_name)* 2) + 2; - } - else if(0 == strncmp(start, "SRN", stop - start)) - { - memset(temp, 0, sizeof(temp)); - stop++; - while(isspace(stop[0])) - stop++; - temp_len = strlen(stop); - strncpy(temp, stop, temp_len); - rpcstr_push((void *)(entry->data_record.computer_name), temp, - sizeof(entry->data_record.computer_name), STR_TERMINATE); - entry->data_record.computer_name_len = (strlen_w(entry->data_record.computer_name)* 2) + 2; - } - else if(0 == strncmp(start, "SID", stop - start)) - { - memset(temp, 0, sizeof(temp)); - stop++; - while(isspace(stop[0])) - stop++; - temp_len = strlen(stop); - strncpy(temp, stop, temp_len); - rpcstr_push((void *)(entry->data_record.sid), temp, - sizeof(entry->data_record.sid), STR_TERMINATE); - entry->record.user_sid_length = (strlen_w(entry->data_record.sid) * 2) + 2; - } - else if(0 == strncmp(start, "STR", stop - start)) - { - /* skip past initial ":" */ - stop++; - /* now skip any other leading whitespace */ - while(isspace(stop[0])) - stop++; - temp_len = strlen(stop); - memset(temp, 0, sizeof(temp)); - strncpy(temp, stop, temp_len); - rpcstr_push((void *)(entry->data_record.strings + entry->data_record.strings_len), - temp, - sizeof(entry->data_record.strings) - entry->data_record.strings_len, - STR_TERMINATE); - entry->data_record.strings_len += temp_len + 1; - fprintf(stderr, "Dumping strings:\n"); - for(i = 0; i < entry->data_record.strings_len; i++) - { - fputc((char)entry->data_record.strings[i], stderr); - } - fprintf(stderr, "\nDone\n"); - entry->record.num_strings++; - } - else if(0 == strncmp(start, "DAT", stop - start)) - { - /* Now that we're done processing the STR data, adjust the length to account for - unicode, then proceed with the DAT data. */ - entry->data_record.strings_len *= 2; - /* skip past initial ":" */ - stop++; - /* now skip any other leading whitespace */ - while(isspace(stop[0])) - stop++; - memset(temp, 0, sizeof(temp)); - temp_len = strlen(stop); - strncpy(temp, stop, temp_len); - rpcstr_push((void *)(entry->data_record.user_data), temp, - sizeof(entry->data_record.user_data), STR_TERMINATE); - entry->data_record.user_data_len = (strlen_w((const smb_ucs2_t *)entry->data_record.user_data) * 2) + 2; - } - else - { - /* some other eventlog entry -- not implemented, so dropping on the floor */ - DEBUG(10, ("Unknown entry [%s]. Ignoring.\n", line)); - /* For now return true so that we can keep on parsing this mess. Eventually - we will return False here. */ + else if(0 == strncmp(start, "ECT", stop - start)) { + entry->record.event_category = atoi(stop + 1); + } else if(0 == strncmp(start, "RS2", stop - start)) { + entry->record.reserved2 = atoi(stop + 1); + } else if(0 == strncmp(start, "CRN", stop - start)) { + entry->record.closing_record_number = atoi(stop + 1); + } else if(0 == strncmp(start, "USL", stop - start)) { + entry->record.user_sid_length = atoi(stop + 1); + } else if(0 == strncmp(start, "SRC", stop - start)) { + memset(temp, 0, sizeof(temp)); + stop++; + while(isspace(stop[0])) { + stop++; + } + temp_len = strlen(stop); + strncpy(temp, stop, temp_len); + rpcstr_push((void *)(entry->data_record.source_name), temp, + sizeof(entry->data_record.source_name), STR_TERMINATE); + entry->data_record.source_name_len = (strlen_w(entry->data_record.source_name)* 2) + 2; + } else if(0 == strncmp(start, "SRN", stop - start)) { + memset(temp, 0, sizeof(temp)); + stop++; + while(isspace(stop[0])) { + stop++; + } + temp_len = strlen(stop); + strncpy(temp, stop, temp_len); + rpcstr_push((void *)(entry->data_record.computer_name), temp, + sizeof(entry->data_record.computer_name), STR_TERMINATE); + entry->data_record.computer_name_len = (strlen_w(entry->data_record.computer_name)* 2) + 2; + } else if(0 == strncmp(start, "SID", stop - start)) { + memset(temp, 0, sizeof(temp)); + stop++; + while(isspace(stop[0])) { + stop++; + } + temp_len = strlen(stop); + strncpy(temp, stop, temp_len); + rpcstr_push((void *)(entry->data_record.sid), temp, + sizeof(entry->data_record.sid), STR_TERMINATE); + entry->record.user_sid_length = (strlen_w(entry->data_record.sid) * 2) + 2; + } else if(0 == strncmp(start, "STR", stop - start)) { + /* skip past initial ":" */ + stop++; + /* now skip any other leading whitespace */ + while(isspace(stop[0])) { + stop++; + } + temp_len = strlen(stop); + memset(temp, 0, sizeof(temp)); + strncpy(temp, stop, temp_len); + rpcstr_push((void *)(entry->data_record.strings + entry->data_record.strings_len), + temp, + sizeof(entry->data_record.strings) - entry->data_record.strings_len, + STR_TERMINATE); + entry->data_record.strings_len += temp_len + 1; + fprintf(stderr, "Dumping strings:\n"); + for(i = 0; i < entry->data_record.strings_len; i++) { + fputc((char)entry->data_record.strings[i], stderr); + } + fprintf(stderr, "\nDone\n"); + entry->record.num_strings++; + } else if(0 == strncmp(start, "DAT", stop - start)) { + /* Now that we're done processing the STR data, adjust the length to account for + unicode, then proceed with the DAT data. */ + entry->data_record.strings_len *= 2; + /* skip past initial ":" */ + stop++; + /* now skip any other leading whitespace */ + while(isspace(stop[0])) { + stop++; + } + entry->data_record.user_data_len = strlen(stop); + memset(entry->data_record.user_data, 0, sizeof(entry->data_record.user_data)); + if(entry->data_record.user_data_len > 0) { + /* copy no more than the first 1024 bytes */ + if(entry->data_record.user_data_len > sizeof(entry->data_record.user_data)) + entry->data_record.user_data_len = sizeof(entry->data_record.user_data); + memcpy(entry->data_record.user_data, stop, entry->data_record.user_data_len); + } + } else { + /* some other eventlog entry -- not implemented, so dropping on the floor */ + DEBUG(10, ("Unknown entry [%s]. Ignoring.\n", line)); + /* For now return true so that we can keep on parsing this mess. Eventually + we will return False here. */ + return True; + } return True; - } - return True; } + +/******************************************************************** +********************************************************************/ + /** * Callout to read entries from the specified event log * @@ -640,254 +571,162 @@ static BOOL _eventlog_read_parse_line(char *line, Eventlog_entry *entry, BOOL *e * DAT:[(uint8)] - The user-defined data portion of the event log. Can not be multiple lines. * - end-of-record indicator */ -static BOOL _eventlog_read_eventlog_hook(Eventlog_info *info, - Eventlog_entry *entry, - const char *direction, - int starting_record, - int buffer_size, - BOOL *eof, - char ***buffer, - int *numlines) + +static BOOL read_eventlog_hook(EventlogInfo *info, Eventlog_entry *entry, + const char *direction, int starting_record, + int buffer_size, BOOL *eof, + char ***buffer, int *numlines) { - char *cmd = lp_eventlog_read_cmd(); - pstring command; - int ret; - int fd = -1; + char *cmd = lp_eventlog_read_cmd(); + pstring command; + int ret; + int fd = -1; - if(info == NULL) - return False; + if ( !info ) + return False; - if(cmd == NULL || strlen(cmd) == 0) - { - DEBUG(0, ("Must define an \"eventlog read command\" entry in the config.\n")); - return False; - } - - slprintf(command, sizeof(command)-1, "%s \"%s\" %s %d %d \"%s\"", - cmd, - info->source_log_file_name, - direction, - starting_record, - buffer_size, - info->handle_string); - - *numlines = 0; - - DEBUG(10, ("Running [%s]\n", command)); - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - - if(ret != 0) - { - if(fd != -1) - close(fd); - return False; - } + if ( !cmd || !*cmd ) { + DEBUG(0, ("Must define an \"eventlog read command\" entry in the config.\n")); + return False; + } - *buffer = fd_lines_load(fd, numlines); - DEBUGADD(10, ("Lines returned = [%d]\n", *numlines)); - close(fd); + pstr_sprintf( command, "%s \"%s\" %s %d %d", + cmd, info->logname, direction, starting_record, buffer_size ); + + *numlines = 0; + + DEBUG(10, ("Running [%s]\n", command)); + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); + + if(ret != 0) { + if(fd != -1) { + close(fd); + } + return False; + } + + *buffer = fd_lines_load(fd, numlines); + DEBUGADD(10, ("Lines returned = [%d]\n", *numlines)); + close(fd); - if(*numlines) - { - /* - for(i = 0; i < numlines; i++) - { - DEBUGADD(10, ("Line[%d] = %s\n", i, qlines[i])); - _eventlog_read_parse_line(qlines[i], entry); + if(*numlines) { + /* + for(i = 0; i < numlines; i++) + { + DEBUGADD(10, ("Line[%d] = %s\n", i, qlines[i])); + parse_logentry(qlines[i], entry); + } + file_lines_free(qlines); + */ + *eof = False; + return True; } - file_lines_free(qlines); - */ - *eof = False; - return True; - } - *eof = True; + *eof = True; /* file_lines_free(qlines);*/ - return False; + return False; } - -static Eventlog_entry *_eventlog_read_package_entry(prs_struct *ps, + +/******************************************************************** +********************************************************************/ + +static Eventlog_entry *read_package_entry(prs_struct *ps, EVENTLOG_Q_READ_EVENTLOG *q_u, EVENTLOG_R_READ_EVENTLOG *r_u, Eventlog_entry *entry) { - uint8 *offset; - Eventlog_entry *ee_new = NULL; - - ee_new = PRS_ALLOC_MEM(ps, Eventlog_entry, 1); - if(ee_new == NULL) - return NULL; - - entry->data_record.sid_padding = ((4 - ((entry->data_record.source_name_len - + entry->data_record.computer_name_len) % 4)) %4); - entry->data_record.data_padding = (4 - ((entry->data_record.strings_len - + entry->data_record.user_data_len) % 4)) % 4; - entry->record.length = sizeof(Eventlog_record); - entry->record.length += entry->data_record.source_name_len; - entry->record.length += entry->data_record.computer_name_len; - if(entry->record.user_sid_length == 0) - { - /* Should not pad to a DWORD boundary for writing out the sid if there is - no SID, so just propagate the padding to pad the data */ - entry->data_record.data_padding += entry->data_record.sid_padding; - entry->data_record.sid_padding = 0; - } - DEBUG(10, ("sid_padding is [%d].\n", entry->data_record.sid_padding)); - DEBUG(10, ("data_padding is [%d].\n", entry->data_record.data_padding)); - - entry->record.length += entry->data_record.sid_padding; - entry->record.length += entry->record.user_sid_length; - entry->record.length += entry->data_record.strings_len; - entry->record.length += entry->data_record.user_data_len; - entry->record.length += entry->data_record.data_padding; - /* need another copy of length at the end of the data */ - entry->record.length += sizeof(entry->record.length); - DEBUG(10, ("entry->record.length is [%d].\n", entry->record.length)); - entry->data = PRS_ALLOC_MEM(ps, uint8, entry->record.length - sizeof(Eventlog_record) - sizeof(entry->record.length)); - if(entry->data == NULL) - return NULL; - offset = entry->data; - memcpy(offset, &(entry->data_record.source_name), entry->data_record.source_name_len); - offset += entry->data_record.source_name_len; - memcpy(offset, &(entry->data_record.computer_name), entry->data_record.computer_name_len); - offset += entry->data_record.computer_name_len; - /* SID needs to be DWORD-aligned */ - offset += entry->data_record.sid_padding; - entry->record.user_sid_offset = sizeof(Eventlog_record) + (offset - entry->data); - memcpy(offset, &(entry->data_record.sid), entry->record.user_sid_length); - offset += entry->record.user_sid_length; - /* Now do the strings */ - entry->record.string_offset = sizeof(Eventlog_record) + (offset - entry->data); - memcpy(offset, &(entry->data_record.strings), entry->data_record.strings_len); - offset += entry->data_record.strings_len; - /* Now do the data */ - entry->record.data_length = entry->data_record.user_data_len; - entry->record.data_offset = sizeof(Eventlog_record) + (offset - entry->data); - memcpy(offset, &(entry->data_record.user_data), entry->data_record.user_data_len); - offset += entry->data_record.user_data_len; - - memcpy(&(ee_new->record), &entry->record, sizeof(Eventlog_record)); - memcpy(&(ee_new->data_record), &entry->data_record, sizeof(Eventlog_data_record)); - ee_new->data = entry->data; - - return ee_new; -} + uint8 *offset; + Eventlog_entry *ee_new = NULL; -static BOOL _eventlog_add_record_to_resp(EVENTLOG_R_READ_EVENTLOG *r_u, Eventlog_entry *ee_new) -{ - Eventlog_entry *insert_point; - - insert_point=r_u->entry; - - if (NULL == insert_point) - { - r_u->entry = ee_new; - ee_new->next = NULL; - } - else - { - while ((NULL != insert_point->next)) - { - insert_point=insert_point->next; - } - ee_new->next = NULL; - insert_point->next = ee_new; - } - r_u->num_records++; - r_u->num_bytes_in_resp += ee_new->record.length; - - return True; + ee_new = PRS_ALLOC_MEM(ps, Eventlog_entry, 1); + if(ee_new == NULL) { + return NULL; + } + + entry->data_record.sid_padding = ((4 - ((entry->data_record.source_name_len + + entry->data_record.computer_name_len) % 4)) %4); + entry->data_record.data_padding = (4 - ((entry->data_record.strings_len + + entry->data_record.user_data_len) % 4)) % 4; + entry->record.length = sizeof(Eventlog_record); + entry->record.length += entry->data_record.source_name_len; + entry->record.length += entry->data_record.computer_name_len; + if(entry->record.user_sid_length == 0) { + /* Should not pad to a DWORD boundary for writing out the sid if there is + no SID, so just propagate the padding to pad the data */ + entry->data_record.data_padding += entry->data_record.sid_padding; + entry->data_record.sid_padding = 0; + } + DEBUG(10, ("sid_padding is [%d].\n", entry->data_record.sid_padding)); + DEBUG(10, ("data_padding is [%d].\n", entry->data_record.data_padding)); + + entry->record.length += entry->data_record.sid_padding; + entry->record.length += entry->record.user_sid_length; + entry->record.length += entry->data_record.strings_len; + entry->record.length += entry->data_record.user_data_len; + entry->record.length += entry->data_record.data_padding; + /* need another copy of length at the end of the data */ + entry->record.length += sizeof(entry->record.length); + DEBUG(10, ("entry->record.length is [%d].\n", entry->record.length)); + entry->data = PRS_ALLOC_MEM(ps, uint8, entry->record.length - sizeof(Eventlog_record) - sizeof(entry->record.length)); + if(entry->data == NULL) { + return NULL; + } + offset = entry->data; + memcpy(offset, &(entry->data_record.source_name), entry->data_record.source_name_len); + offset += entry->data_record.source_name_len; + memcpy(offset, &(entry->data_record.computer_name), entry->data_record.computer_name_len); + offset += entry->data_record.computer_name_len; + /* SID needs to be DWORD-aligned */ + offset += entry->data_record.sid_padding; + entry->record.user_sid_offset = sizeof(Eventlog_record) + (offset - entry->data); + memcpy(offset, &(entry->data_record.sid), entry->record.user_sid_length); + offset += entry->record.user_sid_length; + /* Now do the strings */ + entry->record.string_offset = sizeof(Eventlog_record) + (offset - entry->data); + memcpy(offset, &(entry->data_record.strings), entry->data_record.strings_len); + offset += entry->data_record.strings_len; + /* Now do the data */ + entry->record.data_length = entry->data_record.user_data_len; + entry->record.data_offset = sizeof(Eventlog_record) + (offset - entry->data); + memcpy(offset, &(entry->data_record.user_data), entry->data_record.user_data_len); + offset += entry->data_record.user_data_len; + + memcpy(&(ee_new->record), &entry->record, sizeof(Eventlog_record)); + memcpy(&(ee_new->data_record), &entry->data_record, sizeof(Eventlog_data_record)); + ee_new->data = entry->data; + + return ee_new; } - -WERROR _eventlog_read_eventlog(pipes_struct *p, - EVENTLOG_Q_READ_EVENTLOG *q_u, - EVENTLOG_R_READ_EVENTLOG *r_u) + +/******************************************************************** +********************************************************************/ + +static BOOL add_record_to_resp(EVENTLOG_R_READ_EVENTLOG *r_u, Eventlog_entry *ee_new) { - Eventlog_info *info = NULL; - POLICY_HND *handle; - Eventlog_entry entry, *ee_new; - BOOL eof = False, eor = False; - const char *direction = ""; - uint32 num_records_read = 0; - prs_struct *ps; - int numlines, i; - char **buffer; - - if(!q_u || !r_u) - return WERR_NOMEM; - - handle = &(q_u->handle); - info = find_eventlog_info_by_hnd(p, handle); - info->flags = q_u->flags; - ps = &p->out_data.rdata; - /* if this is the first time we're reading on this handle */ - if(info->active_entry == 0) - { - /* Rather than checking the EVENTLOG_SEQUENTIAL_READ/EVENTLOG_SEEK_READ flags, - we'll just go to the offset specified in the request, or the oldest entry - if no offset is specified */ - if(q_u->offset > 0) - info->active_entry = q_u->offset; - else - info->active_entry = info->oldest_entry; - - } - - if(q_u->flags & EVENTLOG_FORWARDS_READ) - direction = "forward"; - else if(q_u->flags & EVENTLOG_BACKWARDS_READ) - direction = "backward"; - - if(!(_eventlog_read_eventlog_hook(info, &entry, direction, info->active_entry, q_u->max_read_size, &eof, &buffer, &numlines))) - { - if(eof == False) - return WERR_NOMEM; - } - if(numlines > 0) - { - ZERO_STRUCT(entry); - for(i = 0; i < numlines; i++) - { - num_records_read = r_u->num_records; - DEBUGADD(10, ("Line[%d] = [%s]\n", i, buffer[i])); - _eventlog_read_parse_line(buffer[i], &entry, &eor); - if(eor == True) - { - /* package ee_new entry */ - if((ee_new = _eventlog_read_package_entry(ps, q_u, r_u, &entry)) == NULL) - { - free(buffer); - return WERR_NOMEM; - } - /* Now see if there is enough room to add */ - if(r_u->num_bytes_in_resp + ee_new->record.length > q_u->max_read_size) - { - r_u->bytes_in_next_record = ee_new->record.length; - /* response would be too big to fit in client-size buffer */ - break; + Eventlog_entry *insert_point; + + insert_point=r_u->entry; + + if (NULL == insert_point) { + r_u->entry = ee_new; + ee_new->next = NULL; + } else { + while ((NULL != insert_point->next)) { + insert_point=insert_point->next; } - _eventlog_add_record_to_resp(r_u, ee_new); - ZERO_STRUCT(entry); - eor=False; - num_records_read = r_u->num_records - num_records_read; - DEBUG(10, ("_eventlog_read_eventlog: read [%d] records for a total of [%d] records using [%d] bytes out of a max of [%d].\n", - num_records_read, - r_u->num_records, - r_u->num_bytes_in_resp, - q_u->max_read_size)); - /* update the active record */ - if(info->flags & EVENTLOG_FORWARDS_READ) - info->active_entry += num_records_read; - else if(info->flags & EVENTLOG_BACKWARDS_READ) - info->active_entry -= num_records_read; - } - } - free(buffer); - } - - return WERR_OK; + ee_new->next = NULL; + insert_point->next = ee_new; + } + r_u->num_records++; + r_u->num_bytes_in_resp += ee_new->record.length; + + return True; } + +/******************************************************************** +********************************************************************/ + /** * Callout to clear (and optionally backup) a specified event log * @@ -902,96 +741,224 @@ WERROR _eventlog_read_eventlog(pipes_struct *p, * The given log is copied to that location on the server. See comments for * eventlog_io_q_clear_eventlog for info about odd file name behavior */ -static BOOL _eventlog_clear_eventlog_hook(Eventlog_info *info, - pstring backup_file_name) + +static BOOL clear_eventlog_hook(EventlogInfo *info, pstring backup_file_name) { - char *cmd = lp_eventlog_clear_cmd(); - char **qlines; - pstring command; - int numlines = 0; - int ret; - int fd = -1; - - if(cmd == NULL || strlen(cmd) == 0) - { - DEBUG(0, ("Must define an \"eventlog clear command\" entry in the config.\n")); - return False; - } - - memset(command, 0, sizeof(command)); - if(strlen(backup_file_name) > 0) - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\"", - cmd, - info->source_log_file_name, - backup_file_name, - info->handle_string); - else - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", - cmd, - info->source_log_file_name, - info->handle_string); - - DEBUG(10, ("Running [%s]\n", command)); - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - - if(ret != 0) - { - if(fd != -1) - close(fd); - return False; - } + char *cmd = lp_eventlog_clear_cmd(); + char **qlines; + pstring command; + int numlines = 0; + int ret; + int fd = -1; + + if ( !cmd || !*cmd ) { + DEBUG(0, ("Must define an \"eventlog clear command\" entry in the config.\n")); + return False; + } + + if ( strlen(backup_file_name) ) + pstr_sprintf( command, "%s \"%s\" \"%s\"", cmd, info->logname, backup_file_name ); + else + pstr_sprintf( command, "%s \"%s\"", cmd, info->logname ); + + DEBUG(10, ("Running [%s]\n", command)); + ret = smbrun(command, &fd); + DEBUGADD(10, ("returned [%d]\n", ret)); - qlines = fd_lines_load(fd, &numlines); - DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); - close(fd); + if(ret != 0) { + if(fd != -1) { + close(fd); + } + return False; + } - if(numlines) - { - DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); - if(0 == strncmp(qlines[0], "SUCCESS", strlen("SUCCESS"))) - { - DEBUGADD(10, ("Able to clear [%s].\n", info->source_log_file_name)); - file_lines_free(qlines); - return True; + qlines = fd_lines_load(fd, &numlines); + DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); + close(fd); + + if(numlines) { + DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); + if(0 == strncmp(qlines[0], "SUCCESS", strlen("SUCCESS"))) { + DEBUGADD(10, ("Able to clear [%s].\n", info->logname)); + file_lines_free(qlines); + return True; + } } - } - file_lines_free(qlines); - return False; + file_lines_free(qlines); + return False; +} + +/******************************************************************* +*******************************************************************/ + +WERROR _eventlog_open_eventlog(pipes_struct *p, EVENTLOG_Q_OPEN_EVENTLOG *q_u, EVENTLOG_R_OPEN_EVENTLOG *r_u) +{ + EventlogInfo *info = NULL; + fstring str; + + if ( !(info = TALLOC_ZERO_P(NULL, EventlogInfo)) ) + return WERR_NOMEM; + + fstrcpy( str, global_myname() ); + if ( q_u->servername.string ) { + rpcstr_pull( str, q_u->servername.string->buffer, + sizeof(str), q_u->servername.string->uni_str_len*2, 0 ); + } + info->servername = talloc_strdup( info, str ); + + fstrcpy( str, "Application" ); + if ( q_u->logname.string ) { + rpcstr_pull( str, q_u->logname.string->buffer, + sizeof(str), q_u->logname.string->uni_str_len*2, 0 ); + } + info->logname = talloc_strdup( info, str ); + + DEBUG(10, ("_eventlog_open_eventlog: Using [%s] as the server name.\n", info->servername)); + DEBUG(10, ("_eventlog_open_eventlog: Using [%s] as the source log file.\n", info->logname)); + + if ( !create_policy_hnd(p, &r_u->handle, free_eventlog_info, (void *)info) ) { + free_eventlog_info(info); + return WERR_NOMEM; + } + + if ( !(open_eventlog_hook(info)) ) { + close_policy_hnd(p, &r_u->handle); + return WERR_BADFILE; + } + + return WERR_OK; } -WERROR _eventlog_clear_eventlog(pipes_struct *p, - EVENTLOG_Q_CLEAR_EVENTLOG *q_u, - EVENTLOG_R_CLEAR_EVENTLOG *r_u) +/******************************************************************** +********************************************************************/ + +WERROR _eventlog_clear_eventlog(pipes_struct *p, EVENTLOG_Q_CLEAR_EVENTLOG *q_u, EVENTLOG_R_CLEAR_EVENTLOG *r_u) { - Eventlog_info *info = NULL; - pstring backup_file_name; - POLICY_HND *handle = NULL; + EventlogInfo *info = find_eventlog_info_by_hnd(p, &q_u->handle); + pstring backup_file_name; - if(!q_u || !r_u) - return WERR_NOMEM; + pstrcpy( backup_file_name, "" ); - handle = &(q_u->handle); - info = find_eventlog_info_by_hnd(p, handle); - memset(backup_file_name, 0, sizeof(backup_file_name)); + if ( q_u->backupfile.string ) + unistr2_to_ascii(backup_file_name, q_u->backupfile.string, sizeof(backup_file_name)); - if(q_u->backup_file_ptr != 0) - { - unistr2_to_ascii(backup_file_name, &(q_u->backup_file), sizeof(backup_file_name)); DEBUG(10, ("_eventlog_clear_eventlog: Using [%s] as the backup file name for log [%s].", - backup_file_name, - info->source_log_file_name)); - } - else - { - /* if backup_file == NULL, do not back up the log before clearing it */ - DEBUG(10, ("_eventlog_clear_eventlog: clearing [%s] log without making a backup.", - info->source_log_file_name)); - } - - if(!(_eventlog_clear_eventlog_hook(info, backup_file_name))) - return WERR_BADFILE; - - return WERR_OK; + backup_file_name, info->logname)); + + if ( !(clear_eventlog_hook(info, backup_file_name)) ) + return WERR_BADFILE; + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _eventlog_close_eventlog(pipes_struct *p, EVENTLOG_Q_CLOSE_EVENTLOG *q_u, EVENTLOG_R_CLOSE_EVENTLOG *r_u) +{ + EventlogInfo *info = find_eventlog_info_by_hnd(p,&q_u->handle); + + if ( !(close_eventlog_hook(info)) ) + return WERR_BADFILE; + + if ( !(close_policy_hnd(p, &q_u->handle)) ) { + return WERR_BADFID; + } + + return WERR_OK; } + +/******************************************************************** +********************************************************************/ + +WERROR _eventlog_read_eventlog(pipes_struct *p, EVENTLOG_Q_READ_EVENTLOG *q_u, EVENTLOG_R_READ_EVENTLOG *r_u) +{ + EventlogInfo *info = find_eventlog_info_by_hnd(p, &q_u->handle); + Eventlog_entry entry, *ee_new; + BOOL eof = False, eor = False; + const char *direction = ""; + uint32 num_records_read = 0; + prs_struct *ps; + int numlines, i; + char **buffer; + + info->flags = q_u->flags; + ps = &p->out_data.rdata; + + if ( info->flags & EVENTLOG_FORWARDS_READ ) + direction = "forward"; + else if ( info->flags & EVENTLOG_BACKWARDS_READ ) + direction = "backward"; + + if ( !(read_eventlog_hook(info, &entry, direction, q_u->offset, q_u->max_read_size, &eof, &buffer, &numlines)) ) { + if(eof == False) { + return WERR_NOMEM; + } + } + + if(numlines > 0) { + ZERO_STRUCT(entry); + for(i = 0; i < numlines; i++) { + num_records_read = r_u->num_records; + DEBUGADD(10, ("Line[%d] = [%s]\n", i, buffer[i])); + parse_logentry(buffer[i], &entry, &eor); + if(eor == True) { + /* package ee_new entry */ + if((ee_new = read_package_entry(ps, q_u, r_u, &entry)) == NULL) { + SAFE_FREE(buffer); + return WERR_NOMEM; + } + /* Now see if there is enough room to add */ + if(r_u->num_bytes_in_resp + ee_new->record.length > q_u->max_read_size) { + r_u->bytes_in_next_record = ee_new->record.length; + /* response would be too big to fit in client-size buffer */ + break; + } + add_record_to_resp(r_u, ee_new); + ZERO_STRUCT(entry); + eor=False; + num_records_read = r_u->num_records - num_records_read; + DEBUG(10, ("_eventlog_read_eventlog: read [%d] records for a total of [%d] records using [%d] bytes out of a max of [%d].\n", + num_records_read, + r_u->num_records, + r_u->num_bytes_in_resp, + q_u->max_read_size)); + } + } + SAFE_FREE(buffer); + } + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _eventlog_get_oldest_entry(pipes_struct *p, EVENTLOG_Q_GET_OLDEST_ENTRY *q_u, EVENTLOG_R_GET_OLDEST_ENTRY *r_u) +{ + EventlogInfo *info = find_eventlog_info_by_hnd(p, &q_u->handle); + + if ( !(get_oldest_entry_hook(info)) ) + return WERR_BADFILE; + + r_u->oldest_entry = info->oldest_entry; + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _eventlog_get_num_records(pipes_struct *p, EVENTLOG_Q_GET_NUM_RECORDS *q_u, EVENTLOG_R_GET_NUM_RECORDS *r_u) +{ + EventlogInfo *info = find_eventlog_info_by_hnd(p, &q_u->handle); + + if ( !(get_num_records_hook(info)) ) + return WERR_BADFILE; + + r_u->num_records = info->num_records; + + return WERR_OK; +} + diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 68072b528a..7da87d5b93 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -253,16 +253,18 @@ BOOL pipe_access_check(pipes_struct *p) user_struct *user = get_valid_user_struct(p->vuid); /* schannel, so we must be ok */ - if (p->netsec_auth_validated) + if (p->pipe_bound && (p->auth.auth_type == PIPE_AUTH_TYPE_SCHANNEL)) { return True; + } if (!user) { DEBUG(3, ("invalid vuid %d\n", p->vuid)); return False; } - if (user->guest) + if (user->guest) { return False; + } } return True; diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 021f1dc8e0..15d420538e 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -805,17 +805,12 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV struct lsa_info *handle; uint32 i; uint32 enum_context = q_u->enum_context; - int num_privs = 0; + int num_privs = count_all_privileges(); LSA_PRIV_ENTRY *entries = NULL; LUID_ATTR luid; /* remember that the enum_context starts at 0 and not 1 */ - if ( lp_enable_privileges() ) - num_privs = count_all_privileges(); - else - DEBUG(2,("_lsa_enum_privs: client trying to enumerate privileges by not enabled in smb.conf!\n")); - if ( enum_context >= num_privs ) return NT_STATUS_NO_MORE_ENTRIES; diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 15827a8b55..5aefe3ca3c 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -74,6 +74,7 @@ NTSTATUS _net_logon_ctrl(pipes_struct *p, NET_Q_LOGON_CTRL *q_u, /**************************************************************************** Send a message to smbd to do a sam synchronisation **************************************************************************/ + static void send_sync_message(void) { TDB_CONTEXT *tdb; @@ -268,26 +269,33 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) NTSTATUS _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u) { - NTSTATUS status = NT_STATUS_OK; - - rpcstr_pull(p->dc.remote_machine,q_u->uni_logon_clnt.buffer,sizeof(fstring),q_u->uni_logon_clnt.uni_str_len*2,0); - - /* create a server challenge for the client */ - /* Set these to random values. */ - generate_random_buffer(p->dc.srv_chal.data, 8); - - memcpy(p->dc.srv_cred.challenge.data, p->dc.srv_chal.data, 8); + if (!p->dc) { + p->dc = TALLOC_ZERO_P(p->pipe_state_mem_ctx, struct dcinfo); + if (!p->dc) { + return NT_STATUS_NO_MEMORY; + } + } else { + DEBUG(10,("_net_req_chal: new challenge requested. Clearing old state.\n")); + ZERO_STRUCTP(p->dc); + } - memcpy(p->dc.clnt_chal.data , q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); - memcpy(p->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + rpcstr_pull(p->dc->remote_machine, + q_u->uni_logon_clnt.buffer, + sizeof(fstring),q_u->uni_logon_clnt.uni_str_len*2,0); - memset((char *)p->dc.sess_key, '\0', sizeof(p->dc.sess_key)); + /* Save the client challenge to the server. */ + memcpy(p->dc->clnt_chal.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); - p->dc.challenge_sent = True; + /* Create a server challenge for the client */ + /* Set this to a random value. */ + generate_random_buffer(p->dc->srv_chal.data, 8); + /* set up the LSA REQUEST CHALLENGE response */ - init_net_r_req_chal(r_u, &p->dc.srv_chal, status); + init_net_r_req_chal(r_u, &p->dc->srv_chal, NT_STATUS_OK); - return status; + p->dc->challenge_sent = True; + + return NT_STATUS_OK; } /************************************************************************* @@ -301,50 +309,54 @@ static void init_net_r_auth(NET_R_AUTH *r_a, DOM_CHAL *resp_cred, NTSTATUS statu } /************************************************************************* - _net_auth + _net_auth. Create the initial credentials. *************************************************************************/ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) { - NTSTATUS status = NT_STATUS_OK; - DOM_CHAL srv_cred; - UTIME srv_time; fstring mach_acct; + fstring remote_machine; + DOM_CHAL srv_chal_out; - srv_time.time = 0; - - rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring),q_u->clnt_id.uni_acct_name.uni_str_len*2,0); + if (!p->dc || !p->dc->challenge_sent) { + return NT_STATUS_ACCESS_DENIED; + } - if (p->dc.challenge_sent && get_md4pw((char *)p->dc.md4pw, mach_acct)) { + rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring), + q_u->clnt_id.uni_acct_name.uni_str_len*2,0); + rpcstr_pull(remote_machine, q_u->clnt_id.uni_comp_name.buffer,sizeof(fstring), + q_u->clnt_id.uni_comp_name.uni_str_len*2,0); - /* from client / server challenges and md4 password, generate sess key */ - cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal, - p->dc.md4pw, p->dc.sess_key); - - /* check that the client credentials are valid */ - if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) { - - /* create server challenge for inclusion in the reply */ - cred_create(p->dc.sess_key, &p->dc.srv_cred.challenge, srv_time, &srv_cred); - - /* copy the received client credentials for use next time */ - memcpy(p->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); - memcpy(p->dc.srv_cred .challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); - - /* Save the machine account name. */ - fstrcpy(p->dc.mach_acct, mach_acct); - - p->dc.authenticated = True; + if (!get_md4pw((char *)p->dc->mach_pw, mach_acct)) { + DEBUG(0,("_net_auth: creds_server_check failed. Failed to " + "get pasword for machine account %s " + "from client %s\n", + mach_acct, remote_machine )); + return NT_STATUS_ACCESS_DENIED; + } - } else { - status = NT_STATUS_ACCESS_DENIED; - } - } else { - status = NT_STATUS_ACCESS_DENIED; + /* From the client / server challenges and md4 password, generate sess key */ + creds_server_init(p->dc, + &p->dc->clnt_chal, /* Stored client chal. */ + &p->dc->srv_chal, /* Stored server chal. */ + p->dc->mach_pw, + &srv_chal_out); + + /* Check client credentials are valid. */ + if (!creds_server_check(p->dc, &q_u->clnt_chal)) { + DEBUG(0,("_net_auth: creds_server_check failed. Rejecting auth " + "request from client %s machine account %s\n", + remote_machine, mach_acct )); + return NT_STATUS_ACCESS_DENIED; } - + + fstrcpy(p->dc->mach_acct, mach_acct); + fstrcpy(p->dc->remote_machine, remote_machine); + p->dc->authenticated = True; + /* set up the LSA AUTH response */ - init_net_r_auth(r_u, &srv_cred, status); + /* Return the server credentials. */ + init_net_r_auth(r_u, &srv_chal_out, NT_STATUS_OK); return r_u->status; } @@ -367,51 +379,54 @@ static void init_net_r_auth_2(NET_R_AUTH_2 *r_a, NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) { - NTSTATUS status = NT_STATUS_OK; - DOM_CHAL srv_cred; - UTIME srv_time; NEG_FLAGS srv_flgs; fstring mach_acct; + fstring remote_machine; + DOM_CHAL srv_chal_out; - srv_time.time = 0; + rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring), + q_u->clnt_id.uni_acct_name.uni_str_len*2,0); + rpcstr_pull(remote_machine, q_u->clnt_id.uni_comp_name.buffer,sizeof(fstring), + q_u->clnt_id.uni_comp_name.uni_str_len*2,0); + + if (!p->dc || !p->dc->challenge_sent) { + DEBUG(0,("_net_auth2: no challenge sent to client %s\n", + remote_machine )); + return NT_STATUS_ACCESS_DENIED; + } if ( (lp_server_schannel() == True) && ((q_u->clnt_flgs.neg_flags & NETLOGON_NEG_SCHANNEL) == 0) ) { /* schannel must be used, but client did not offer it. */ - status = NT_STATUS_ACCESS_DENIED; + DEBUG(0,("_net_auth2: schannel required but client failed " + "to offer it. Client was %s\n", + mach_acct )); + return NT_STATUS_ACCESS_DENIED; } - rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring),q_u->clnt_id.uni_acct_name.uni_str_len*2,0); - - if (p->dc.challenge_sent && get_md4pw((char *)p->dc.md4pw, mach_acct)) { - - /* from client / server challenges and md4 password, generate sess key */ - cred_session_key(&p->dc.clnt_chal, &p->dc.srv_chal, - p->dc.md4pw, p->dc.sess_key); - - /* check that the client credentials are valid */ - if (cred_assert(&q_u->clnt_chal, p->dc.sess_key, &p->dc.clnt_cred.challenge, srv_time)) { - - /* create server challenge for inclusion in the reply */ - cred_create(p->dc.sess_key, &p->dc.srv_cred.challenge, srv_time, &srv_cred); - - /* copy the received client credentials for use next time */ - memcpy(p->dc.clnt_cred.challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); - memcpy(p->dc.srv_cred .challenge.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); - - /* Save the machine account name. */ - fstrcpy(p->dc.mach_acct, mach_acct); - - p->dc.authenticated = True; + if (!get_md4pw((char *)p->dc->mach_pw, mach_acct)) { + DEBUG(0,("_net_auth2: failed to get machine password for " + "account %s\n", + mach_acct )); + return NT_STATUS_ACCESS_DENIED; + } - } else { - status = NT_STATUS_ACCESS_DENIED; - } - } else { - status = NT_STATUS_ACCESS_DENIED; + /* From the client / server challenges and md4 password, generate sess key */ + creds_server_init(p->dc, + &p->dc->clnt_chal, /* Stored client chal. */ + &p->dc->srv_chal, /* Stored server chal. */ + p->dc->mach_pw, + &srv_chal_out); + + /* Check client credentials are valid. */ + if (!creds_server_check(p->dc, &q_u->clnt_chal)) { + DEBUG(0,("_net_auth2: creds_server_check failed. Rejecting auth " + "request from client %s machine account %s\n", + remote_machine, mach_acct )); + return NT_STATUS_ACCESS_DENIED; } - + srv_flgs.neg_flags = 0x000001ff; if (lp_server_schannel() != False) { @@ -419,12 +434,11 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) } /* set up the LSA AUTH 2 response */ - init_net_r_auth_2(r_u, &srv_cred, &srv_flgs, status); + init_net_r_auth_2(r_u, &srv_chal_out, &srv_flgs, NT_STATUS_OK); - if (NT_STATUS_IS_OK(status)) { - server_auth2_negotiated = True; - last_dcinfo = p->dc; - } + server_auth2_negotiated = True; + p->dc->authenticated = True; + last_dcinfo = *p->dc; return r_u->status; } @@ -436,32 +450,39 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_u) { NTSTATUS status = NT_STATUS_ACCESS_DENIED; - DOM_CRED srv_cred; - pstring workstation; + fstring workstation; SAM_ACCOUNT *sampass=NULL; BOOL ret = False; unsigned char pwd[16]; int i; uint32 acct_ctrl; + DOM_CRED cred_out; const uchar *old_pw; - /* checks and updates credentials. creates reply credentials */ - if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->clnt_id.cred, &srv_cred))) + if (!p->dc || !p->dc->authenticated) { return NT_STATUS_INVALID_HANDLE; + } - memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); + /* Step the creds chain forward. */ + if (!creds_server_step(p->dc, &q_u->clnt_id.cred, &cred_out)) { + DEBUG(0,("_net_srv_pwset: creds_server_step failed. Rejecting auth " + "request from client %s machine account %s\n", + p->dc->remote_machine, p->dc->mach_acct )); + return NT_STATUS_ACCESS_DENIED; + } DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); rpcstr_pull(workstation,q_u->clnt_id.login.uni_comp_name.buffer, sizeof(workstation),q_u->clnt_id.login.uni_comp_name.uni_str_len*2,0); - DEBUG(3,("Server Password Set by Wksta:[%s] on account [%s]\n", workstation, p->dc.mach_acct)); + DEBUG(3,("_net_srv_pwset: Server Password Set by Wksta:[%s] on account [%s]\n", + workstation, p->dc->mach_acct)); pdb_init_sam(&sampass); become_root(); - ret=pdb_getsampwnam(sampass, p->dc.mach_acct); + ret=pdb_getsampwnam(sampass, p->dc->mach_acct); unbecome_root(); /* Ensure the account exists and is a machine account. */ @@ -481,7 +502,8 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * return NT_STATUS_ACCOUNT_DISABLED; } - cred_hash3( pwd, q_u->pwd, p->dc.sess_key, 0); + /* Woah - what does this to to the credential chain ? JRA */ + cred_hash3( pwd, q_u->pwd, p->dc->sess_key, 0); DEBUG(100,("Server password set : new given value was :\n")); for(i = 0; i < sizeof(pwd); i++) @@ -498,17 +520,17 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * } else { /* LM password should be NULL for machines */ - if (!pdb_set_lanman_passwd (sampass, NULL, PDB_CHANGED)) { + if (!pdb_set_lanman_passwd(sampass, NULL, PDB_CHANGED)) { pdb_free_sam(&sampass); return NT_STATUS_NO_MEMORY; } - if (!pdb_set_nt_passwd (sampass, pwd, PDB_CHANGED)) { + if (!pdb_set_nt_passwd(sampass, pwd, PDB_CHANGED)) { pdb_free_sam(&sampass); return NT_STATUS_NO_MEMORY; } - if (!pdb_set_pass_changed_now (sampass)) { + if (!pdb_set_pass_changed_now(sampass)) { pdb_free_sam(&sampass); /* Not quite sure what this one qualifies as, but this will do */ return NT_STATUS_UNSUCCESSFUL; @@ -518,42 +540,41 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * ret = pdb_update_sam_account (sampass); unbecome_root(); } - if (ret) + if (ret) { status = NT_STATUS_OK; + } /* set up the LSA Server Password Set response */ - init_net_r_srv_pwset(r_u, &srv_cred, status); + init_net_r_srv_pwset(r_u, &cred_out, status); pdb_free_sam(&sampass); return r_u->status; } - /************************************************************************* _net_sam_logoff: *************************************************************************/ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF *r_u) { - DOM_CRED srv_cred; - if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; - /* checks and updates credentials. creates reply credentials */ - if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, - &q_u->sam_id.client.cred, &srv_cred))) + if (!p->dc || !p->dc->authenticated) { return NT_STATUS_INVALID_HANDLE; + } - /* what happens if we get a logoff for an unknown user? */ - memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); - - /* XXXX maybe we want to say 'no', reject the client's credentials */ 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_OK; + /* checks and updates credentials. creates reply credentials */ + if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { + DEBUG(0,("_net_sam_logoff: creds_server_step failed. Rejecting auth " + "request from client %s machine account %s\n", + p->dc->remote_machine, p->dc->mach_acct )); + return NT_STATUS_ACCESS_DENIED; + } + r_u->status = NT_STATUS_OK; return r_u->status; } @@ -567,7 +588,6 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * NTSTATUS status = NT_STATUS_OK; NET_USER_INFO_3 *usr_info = NULL; NET_ID_INFO_CTR *ctr = q_u->sam_id.ctr; - DOM_CRED srv_cred; UNISTR2 *uni_samlogon_user = NULL; UNISTR2 *uni_samlogon_domain = NULL; UNISTR2 *uni_samlogon_workstation = NULL; @@ -588,26 +608,31 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * r_u->switch_value = 0; /* indicates no info */ r_u->auth_resp = 1; /* authoritative response */ r_u->switch_value = 3; /* indicates type of validation user info */ + r_u->buffer_creds = 1; /* Ensure we always return server creds. */ if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; + if (!p->dc || !p->dc->authenticated) { + return NT_STATUS_INVALID_HANDLE; + } - if ( (lp_server_schannel() == True) && (!p->netsec_auth_validated) ) { + if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { /* 'server schannel = yes' should enforce use of schannel, the client did offer it in auth2, but obviously did not use it. */ + DEBUG(0,("_net_sam_logoff: client %s not using schannel for netlogon\n", + p->dc->remote_machine )); return NT_STATUS_ACCESS_DENIED; } /* checks and updates credentials. creates reply credentials */ - if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred))) - return NT_STATUS_INVALID_HANDLE; - - memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred)); - - r_u->buffer_creds = 1; /* yes, we have valid server credentials */ - memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds)); + if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { + DEBUG(0,("_net_sam_logoff: creds_server_step failed. Rejecting auth " + "request from client %s machine account %s\n", + p->dc->remote_machine, p->dc->mach_acct )); + return NT_STATUS_ACCESS_DENIED; + } /* find the username */ @@ -692,7 +717,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * nt_workstation, chal, ctr->auth.id1.lm_owf.data, ctr->auth.id1.nt_owf.data, - p->dc.sess_key)) { + p->dc->sess_key)) { status = NT_STATUS_NO_MEMORY; } break; @@ -791,7 +816,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * } ZERO_STRUCT(netlogon_sess_key); - memcpy(netlogon_sess_key, p->dc.sess_key, 8); + memcpy(netlogon_sess_key, p->dc->sess_key, 8); if (server_info->user_session_key.length) { memcpy(user_session_key, server_info->user_session_key.data, MIN(sizeof(user_session_key), server_info->user_session_key.length)); diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c new file mode 100644 index 0000000000..48910dbee2 --- /dev/null +++ b/source3/rpc_server/srv_ntsvcs.c @@ -0,0 +1,220 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Gerald Carter 2005. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +/******************************************************************* + ********************************************************************/ + +static BOOL api_ntsvcs_get_version(pipes_struct *p) +{ + NTSVCS_Q_GET_VERSION q_u; + NTSVCS_R_GET_VERSION r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!ntsvcs_io_q_get_version("", &q_u, data, 0)) + return False; + + r_u.status = _ntsvcs_get_version(p, &q_u, &r_u); + + if(!ntsvcs_io_r_get_version("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_ntsvcs_get_device_list_size(pipes_struct *p) +{ + NTSVCS_Q_GET_DEVICE_LIST_SIZE q_u; + NTSVCS_R_GET_DEVICE_LIST_SIZE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!ntsvcs_io_q_get_device_list_size("", &q_u, data, 0)) + return False; + + r_u.status = _ntsvcs_get_device_list_size(p, &q_u, &r_u); + + if(!ntsvcs_io_r_get_device_list_size("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_ntsvcs_get_device_list(pipes_struct *p) +{ + NTSVCS_Q_GET_DEVICE_LIST q_u; + NTSVCS_R_GET_DEVICE_LIST r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!ntsvcs_io_q_get_device_list("", &q_u, data, 0)) + return False; + + r_u.status = _ntsvcs_get_device_list(p, &q_u, &r_u); + + if(!ntsvcs_io_r_get_device_list("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_ntsvcs_validate_device_instance(pipes_struct *p) +{ + NTSVCS_Q_VALIDATE_DEVICE_INSTANCE q_u; + NTSVCS_R_VALIDATE_DEVICE_INSTANCE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!ntsvcs_io_q_validate_device_instance("", &q_u, data, 0)) + return False; + + r_u.status = _ntsvcs_validate_device_instance(p, &q_u, &r_u); + + if(!ntsvcs_io_r_validate_device_instance("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_ntsvcs_get_device_reg_property(pipes_struct *p) +{ + NTSVCS_Q_GET_DEVICE_REG_PROPERTY q_u; + NTSVCS_R_GET_DEVICE_REG_PROPERTY r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!ntsvcs_io_q_get_device_reg_property("", &q_u, data, 0)) + return False; + + r_u.status = _ntsvcs_get_device_reg_property(p, &q_u, &r_u); + + if(!ntsvcs_io_r_get_device_reg_property("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_ntsvcs_get_hw_profile_info(pipes_struct *p) +{ + NTSVCS_Q_GET_HW_PROFILE_INFO q_u; + NTSVCS_R_GET_HW_PROFILE_INFO r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!ntsvcs_io_q_get_hw_profile_info("", &q_u, data, 0)) + return False; + + r_u.status = _ntsvcs_get_hw_profile_info(p, &q_u, &r_u); + + if(!ntsvcs_io_r_get_hw_profile_info("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_ntsvcs_hw_profile_flags(pipes_struct *p) +{ + NTSVCS_Q_HW_PROFILE_FLAGS q_u; + NTSVCS_R_HW_PROFILE_FLAGS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!ntsvcs_io_q_hw_profile_flags("", &q_u, data, 0)) + return False; + + r_u.status = _ntsvcs_hw_profile_flags(p, &q_u, &r_u); + + if(!ntsvcs_io_r_hw_profile_flags("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + \PIPE\svcctl commands + ********************************************************************/ + +static struct api_struct api_ntsvcs_cmds[] = +{ + { "NTSVCS_GET_VERSION" , NTSVCS_GET_VERSION , api_ntsvcs_get_version }, + { "NTSVCS_GET_DEVICE_LIST_SIZE" , NTSVCS_GET_DEVICE_LIST_SIZE , api_ntsvcs_get_device_list_size }, + { "NTSVCS_GET_DEVICE_LIST" , NTSVCS_GET_DEVICE_LIST , api_ntsvcs_get_device_list }, + { "NTSVCS_VALIDATE_DEVICE_INSTANCE" , NTSVCS_VALIDATE_DEVICE_INSTANCE , api_ntsvcs_validate_device_instance }, + { "NTSVCS_GET_DEVICE_REG_PROPERTY" , NTSVCS_GET_DEVICE_REG_PROPERTY , api_ntsvcs_get_device_reg_property }, + { "NTSVCS_GET_HW_PROFILE_INFO" , NTSVCS_GET_HW_PROFILE_INFO , api_ntsvcs_get_hw_profile_info }, + { "NTSVCS_HW_PROFILE_FLAGS" , NTSVCS_HW_PROFILE_FLAGS , api_ntsvcs_hw_profile_flags } +}; + + +void ntsvcs_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_ntsvcs_cmds; + *n_fns = sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct); +} + +NTSTATUS rpc_ntsvcs_init(void) +{ + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "ntsvcs", "ntsvcs", api_ntsvcs_cmds, + sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct)); +} diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c new file mode 100644 index 0000000000..0bb9154aaf --- /dev/null +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -0,0 +1,174 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * + * Copyright (C) Gerald (Jerry) Carter 2005. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +/******************************************************************** +********************************************************************/ + +static char* get_device_path( const char *device ) +{ + static pstring path; + + pstr_sprintf( path, "ROOT\\Legacy_%s\\0000", device ); + + return path; +} + +/******************************************************************** +********************************************************************/ + +WERROR _ntsvcs_get_version( pipes_struct *p, NTSVCS_Q_GET_VERSION *q_u, NTSVCS_R_GET_VERSION *r_u ) +{ + r_u->version = 0x00000400; /* no idea what this means */ + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _ntsvcs_get_device_list_size( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST_SIZE *q_u, NTSVCS_R_GET_DEVICE_LIST_SIZE *r_u ) +{ + fstring device; + const char *devicepath; + + if ( !q_u->devicename ) + return WERR_ACCESS_DENIED; + + rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0); + devicepath = get_device_path( device ); + + r_u->size = strlen(devicepath) + 2; + + return WERR_OK; +} + + +/******************************************************************** +********************************************************************/ + +WERROR _ntsvcs_get_device_list( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST *q_u, NTSVCS_R_GET_DEVICE_LIST *r_u ) +{ + fstring device; + const char *devicepath; + + if ( !q_u->devicename ) + return WERR_ACCESS_DENIED; + + rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0); + devicepath = get_device_path( device ); + + /* From the packet traces I've see, I think this really should be an array + of UNISTR2's. But I've never seen more than one string in spite of the + fact that the string in double NULL terminated. -- jerry */ + + init_unistr2( &r_u->devicepath, devicepath, UNI_STR_TERMINATE ); + r_u->needed = r_u->devicepath.uni_str_len; + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _ntsvcs_get_device_reg_property( pipes_struct *p, NTSVCS_Q_GET_DEVICE_REG_PROPERTY *q_u, NTSVCS_R_GET_DEVICE_REG_PROPERTY *r_u ) +{ + fstring devicepath; + char *ptr; + REGVAL_CTR *values; + REGISTRY_VALUE *val; + + rpcstr_pull(devicepath, q_u->devicepath.buffer, sizeof(devicepath), q_u->devicepath.uni_str_len*2, 0); + + switch( q_u->property ) { + case DEV_REGPROP_DESC: + /* just parse the service name from the device path and then + lookup the display name */ + if ( !(ptr = strrchr_m( devicepath, '\\' )) ) + return WERR_GENERAL_FAILURE; + *ptr = '\0'; + + if ( !(ptr = strrchr_m( devicepath, '_' )) ) + return WERR_GENERAL_FAILURE; + ptr++; + + if ( !(values = svcctl_fetch_regvalues( ptr, p->pipe_user.nt_user_token )) ) + return WERR_GENERAL_FAILURE; + + if ( !(val = regval_ctr_getvalue( values, "DisplayName" )) ) { + TALLOC_FREE( values ); + return WERR_GENERAL_FAILURE; + } + + r_u->unknown1 = 0x1; /* always 1...tested using a remove device manager connection */ + r_u->size = reg_init_regval_buffer( &r_u->value, val ); + r_u->needed = r_u->size; + + TALLOC_FREE(values); + + break; + + default: + r_u->unknown1 = 0x00437c98; + return WERR_CM_NO_SUCH_VALUE; + } + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _ntsvcs_validate_device_instance( pipes_struct *p, NTSVCS_Q_VALIDATE_DEVICE_INSTANCE *q_u, NTSVCS_R_VALIDATE_DEVICE_INSTANCE *r_u ) +{ + /* whatever dude */ + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _ntsvcs_get_hw_profile_info( pipes_struct *p, NTSVCS_Q_GET_HW_PROFILE_INFO *q_u, NTSVCS_R_GET_HW_PROFILE_INFO *r_u ) +{ + /* steal the incoming buffer */ + + r_u->buffer_size = q_u->buffer_size; + r_u->buffer = q_u->buffer; + + /* Take the 5th Ammentment */ + + return WERR_CM_NO_MORE_HW_PROFILES; +} + +/******************************************************************** +********************************************************************/ + +WERROR _ntsvcs_hw_profile_flags( pipes_struct *p, NTSVCS_Q_HW_PROFILE_FLAGS *q_u, NTSVCS_R_HW_PROFILE_FLAGS *r_u ) +{ + /* just nod your head */ + + return WERR_OK; +} + diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 63e8d2f5cd..ba6d9704e8 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1,11 +1,7 @@ /* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1998 - * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, - * Copyright (C) Paul Ashton 1997-1998, - * Copyright (C) Jeremy Allison 1999, - * Copyright (C) Jim McDonough 2003. + * Almost completely rewritten by (C) Jeremy Allison 2005. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,12 +26,6 @@ * and DCE/RPC, while minimising the amount of mallocs, unnecessary * data copies, and network traffic. * - * in this version, which takes a "let's learn what's going on and - * get something running" approach, there is additional network - * traffic generated, but the code should be easier to understand... - * - * ... if you read the docs. or stare at packets for weeks on end. - * */ #include "includes.h" @@ -51,52 +41,38 @@ extern struct current_user current_user; We need to transfer the session key from one rpc bind to the next. This is the way the netlogon schannel works. **************************************************************/ + struct dcinfo last_dcinfo; BOOL server_auth2_negotiated = False; -static void NTLMSSPcalc_p( pipes_struct *p, unsigned char *data, int len) +static void free_pipe_ntlmssp_auth_data(struct pipe_auth_data *auth) { - unsigned char *hash = p->ntlmssp_hash; - unsigned char index_i = hash[256]; - unsigned char index_j = hash[257]; - int ind; - - for( ind = 0; ind < len; ind++) { - unsigned char tc; - unsigned char t; + AUTH_NTLMSSP_STATE *a = auth->a_u.auth_ntlmssp_state; - index_i++; - index_j += hash[index_i]; - - tc = hash[index_i]; - hash[index_i] = hash[index_j]; - hash[index_j] = tc; - - t = hash[index_i] + hash[index_j]; - data[ind] = data[ind] ^ hash[t]; + if (a) { + auth_ntlmssp_end(&a); } - - hash[256] = index_i; - hash[257] = index_j; + auth->a_u.auth_ntlmssp_state = NULL; } /******************************************************************* Generate the next PDU to be returned from the data in p->rdata. - We cheat here as this function doesn't handle the special auth - footers of the authenticated bind response reply. + Handle NTLMSSP. ********************************************************************/ -BOOL create_next_pdu(pipes_struct *p) +static BOOL create_next_pdu_ntlmssp(pipes_struct *p) { RPC_HDR_RESP hdr_resp; - BOOL auth_verify = ((p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SIGN) != 0); - BOOL auth_seal = ((p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SEAL) != 0); uint32 ss_padding_len = 0; - uint32 data_len; uint32 data_space_available; uint32 data_len_left; + uint32 data_len; prs_struct outgoing_pdu; - uint32 data_pos; + NTSTATUS status; + DATA_BLOB auth_blob; + RPC_HDR_AUTH auth_info; + uint8 auth_type, auth_level; + AUTH_NTLMSSP_STATE *a = p->auth.a_u.auth_ntlmssp_state; /* * If we're in the fault state, keep returning fault PDU's until @@ -124,18 +100,6 @@ BOOL create_next_pdu(pipes_struct *p) * Work out how much we can fit in a single PDU. */ - data_space_available = sizeof(p->out_data.current_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN; - if(p->ntlmssp_auth_validated) { - data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN); - } else if(p->netsec_auth_validated) { - data_space_available -= (RPC_HDR_AUTH_LEN + RPC_AUTH_NETSEC_SIGN_OR_SEAL_CHK_LEN); - } - - /* - * The amount we send is the minimum of the available - * space and the amount left to send. - */ - data_len_left = prs_offset(&p->out_data.rdata) - p->out_data.data_sent_length; /* @@ -143,10 +107,18 @@ BOOL create_next_pdu(pipes_struct *p) */ if(!data_len_left) { - DEBUG(0,("create_next_pdu: no data left to send !\n")); + DEBUG(0,("create_next_pdu_ntlmssp: no data left to send !\n")); return False; } + data_space_available = sizeof(p->out_data.current_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN - + RPC_HDR_AUTH_LEN - NTLMSSP_SIG_SIZE; + + /* + * The amount we send is the minimum of the available + * space and the amount left to send. + */ + data_len = MIN(data_len_left, data_space_available); /* @@ -162,9 +134,9 @@ BOOL create_next_pdu(pipes_struct *p) if(p->out_data.data_sent_length + data_len >= prs_offset(&p->out_data.rdata)) { p->hdr.flags |= RPC_FLG_LAST; - if ((auth_seal || auth_verify || p->netsec_auth_validated) && (data_len_left % 8)) { + if (data_len_left % 8) { ss_padding_len = 8 - (data_len_left % 8); - DEBUG(10,("create_next_pdu: adding sign/seal padding of %u\n", + DEBUG(10,("create_next_pdu_ntlmssp: adding sign/seal padding of %u\n", ss_padding_len )); } } @@ -173,20 +145,11 @@ BOOL create_next_pdu(pipes_struct *p) * Set up the header lengths. */ - if (p->ntlmssp_auth_validated) { - p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + + p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len + ss_padding_len + - RPC_HDR_AUTH_LEN + RPC_AUTH_NTLMSSP_CHK_LEN; - p->hdr.auth_len = RPC_AUTH_NTLMSSP_CHK_LEN; - } else if (p->netsec_auth_validated) { - p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + - data_len + ss_padding_len + - RPC_HDR_AUTH_LEN + RPC_AUTH_NETSEC_SIGN_OR_SEAL_CHK_LEN; - p->hdr.auth_len = RPC_AUTH_NETSEC_SIGN_OR_SEAL_CHK_LEN; - } else { - p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len; - p->hdr.auth_len = 0; - } + RPC_HDR_AUTH_LEN + NTLMSSP_SIG_SIZE; + p->hdr.auth_len = NTLMSSP_SIG_SIZE; + /* * Init the parse struct to point at the outgoing @@ -198,127 +161,105 @@ BOOL create_next_pdu(pipes_struct *p) /* Store the header in the data stream. */ if(!smb_io_rpc_hdr("hdr", &p->hdr, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR.\n")); + DEBUG(0,("create_next_pdu_ntlmssp: failed to marshall RPC_HDR.\n")); prs_mem_free(&outgoing_pdu); return False; } if(!smb_io_rpc_hdr_resp("resp", &hdr_resp, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_RESP.\n")); + DEBUG(0,("create_next_pdu_ntlmssp: failed to marshall RPC_HDR_RESP.\n")); prs_mem_free(&outgoing_pdu); return False; } - /* Store the current offset. */ - data_pos = prs_offset(&outgoing_pdu); - /* Copy the data into the PDU. */ if(!prs_append_some_prs_data(&outgoing_pdu, &p->out_data.rdata, p->out_data.data_sent_length, data_len)) { - DEBUG(0,("create_next_pdu: failed to copy %u bytes of data.\n", (unsigned int)data_len)); + DEBUG(0,("create_next_pdu_ntlmssp: failed to copy %u bytes of data.\n", (unsigned int)data_len)); prs_mem_free(&outgoing_pdu); return False; } /* Copy the sign/seal padding data. */ if (ss_padding_len) { - char pad[8]; + unsigned char pad[8]; + memset(pad, '\0', 8); if (!prs_copy_data_in(&outgoing_pdu, pad, ss_padding_len)) { - DEBUG(0,("create_next_pdu: failed to add %u bytes of pad data.\n", (unsigned int)ss_padding_len)); + DEBUG(0,("create_next_pdu_ntlmssp: failed to add %u bytes of pad data.\n", + (unsigned int)ss_padding_len)); prs_mem_free(&outgoing_pdu); return False; } } - if (p->ntlmssp_auth_validated) { - /* - * NTLMSSP processing. Mutually exclusive with Schannel. - */ - uint32 crc32 = 0; - char *data; - - DEBUG(5,("create_next_pdu: sign: %s seal: %s data %d auth %d\n", - BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len + ss_padding_len, p->hdr.auth_len)); - - /* - * Set data to point to where we copied the data into. - */ - data = prs_data_p(&outgoing_pdu) + data_pos; + /* Now write out the auth header and null blob. */ + if (p->auth.auth_type == PIPE_AUTH_TYPE_NTLMSSP) { + auth_type = RPC_NTLMSSP_AUTH_TYPE; + } else { + auth_type = RPC_SPNEGO_AUTH_TYPE; + } + if (p->auth.auth_level == PIPE_AUTH_LEVEL_PRIVACY) { + auth_level = RPC_AUTH_LEVEL_PRIVACY; + } else { + auth_level = RPC_AUTH_LEVEL_INTEGRITY; + } - if (auth_seal) { - crc32 = crc32_calc_buffer(data, data_len + ss_padding_len); - NTLMSSPcalc_p(p, (uchar*)data, data_len + ss_padding_len); - } + init_rpc_hdr_auth(&auth_info, auth_type, auth_level, ss_padding_len, 1 /* context id. */); + if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu_ntlmssp: failed to marshall RPC_HDR_AUTH.\n")); + prs_mem_free(&outgoing_pdu); + return False; + } - if (auth_seal || auth_verify) { - RPC_HDR_AUTH auth_info; + /* Generate the sign blob. */ - init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, - auth_seal ? RPC_PIPE_AUTH_SEAL_LEVEL : RPC_PIPE_AUTH_SIGN_LEVEL, - (auth_verify ? ss_padding_len : 0), (auth_verify ? 1 : 0)); - if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_AUTH.\n")); + switch (p->auth.auth_level) { + case PIPE_AUTH_LEVEL_PRIVACY: + /* Data portion is encrypted. */ + status = ntlmssp_seal_packet(a->ntlmssp_state, + prs_data_p(&outgoing_pdu) + RPC_HEADER_LEN + RPC_HDR_RESP_LEN, + data_len + ss_padding_len, + prs_data_p(&outgoing_pdu), + (size_t)prs_offset(&outgoing_pdu), + &auth_blob); + if (!NT_STATUS_IS_OK(status)) { + data_blob_free(&auth_blob); prs_mem_free(&outgoing_pdu); return False; } - } - - if (auth_verify) { - RPC_AUTH_NTLMSSP_CHK ntlmssp_chk; - char *auth_data = prs_data_p(&outgoing_pdu); - - p->ntlmssp_seq_num++; - init_rpc_auth_ntlmssp_chk(&ntlmssp_chk, NTLMSSP_SIGN_VERSION, - crc32, p->ntlmssp_seq_num++); - auth_data = prs_data_p(&outgoing_pdu) + prs_offset(&outgoing_pdu) + 4; - if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &ntlmssp_chk, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_AUTH_NTLMSSP_CHK.\n")); + break; + case PIPE_AUTH_LEVEL_INTEGRITY: + /* Data is signed. */ + status = ntlmssp_sign_packet(a->ntlmssp_state, + prs_data_p(&outgoing_pdu) + RPC_HEADER_LEN + RPC_HDR_RESP_LEN, + data_len + ss_padding_len, + prs_data_p(&outgoing_pdu), + (size_t)prs_offset(&outgoing_pdu), + &auth_blob); + if (!NT_STATUS_IS_OK(status)) { + data_blob_free(&auth_blob); prs_mem_free(&outgoing_pdu); return False; } - NTLMSSPcalc_p(p, (uchar*)auth_data, RPC_AUTH_NTLMSSP_CHK_LEN - 4); - } - } else if (p->netsec_auth_validated) { - /* - * Schannel processing. Mutually exclusive with NTLMSSP. - */ - int auth_type, auth_level; - char *data; - RPC_HDR_AUTH auth_info; - - RPC_AUTH_NETSEC_CHK verf; - prs_struct rverf; - prs_struct rauth; - - data = prs_data_p(&outgoing_pdu) + data_pos; - /* Check it's the type of reply we were expecting to decode */ - - get_auth_type_level(p->netsec_auth.auth_flags, &auth_type, &auth_level); - init_rpc_hdr_auth(&auth_info, auth_type, auth_level, - ss_padding_len, 1); - - if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { - DEBUG(0,("create_next_pdu: failed to marshall RPC_HDR_AUTH.\n")); + break; + default: prs_mem_free(&outgoing_pdu); return False; - } - - prs_init(&rverf, 0, p->mem_ctx, MARSHALL); - prs_init(&rauth, 0, p->mem_ctx, MARSHALL); - - netsec_encode(&p->netsec_auth, - p->netsec_auth.auth_flags, - SENDER_IS_ACCEPTOR, - &verf, data, data_len + ss_padding_len); - - smb_io_rpc_auth_netsec_chk("", RPC_AUTH_NETSEC_SIGN_OR_SEAL_CHK_LEN, - &verf, &outgoing_pdu, 0); + } - p->netsec_auth.seq_num++; + /* Append the auth blob. */ + if (!prs_copy_data_in(&outgoing_pdu, auth_blob.data, NTLMSSP_SIG_SIZE)) { + DEBUG(0,("create_next_pdu_ntlmssp: failed to add %u bytes auth blob.\n", + (unsigned int)NTLMSSP_SIG_SIZE)); + data_blob_free(&auth_blob); + prs_mem_free(&outgoing_pdu); + return False; } + data_blob_free(&auth_blob); + /* * Setup the counts for this PDU. */ @@ -332,292 +273,501 @@ BOOL create_next_pdu(pipes_struct *p) } /******************************************************************* - Process an NTLMSSP authentication response. - If this function succeeds, the user has been authenticated - and their domain, name and calling workstation stored in - the pipe struct. - The initial challenge is stored in p->challenge. - *******************************************************************/ + Generate the next PDU to be returned from the data in p->rdata. + Return an schannel authenticated fragment. + ********************************************************************/ -static BOOL api_pipe_ntlmssp_verify(pipes_struct *p, RPC_AUTH_NTLMSSP_RESP *ntlmssp_resp) +static BOOL create_next_pdu_schannel(pipes_struct *p) { - uchar lm_owf[24]; - uchar nt_owf[128]; - int nt_pw_len; - int lm_pw_len; - fstring user_name; - fstring domain; - fstring wks; + RPC_HDR_RESP hdr_resp; + uint32 ss_padding_len = 0; + uint32 data_len; + uint32 data_space_available; + uint32 data_len_left; + prs_struct outgoing_pdu; + uint32 data_pos; - NTSTATUS nt_status; + /* + * If we're in the fault state, keep returning fault PDU's until + * the pipe gets closed. JRA. + */ - struct auth_context *auth_context = NULL; - auth_usersupplied_info *user_info = NULL; - auth_serversupplied_info *server_info = NULL; + if(p->fault_state) { + setup_fault_pdu(p, NT_STATUS(0x1c010002)); + return True; + } - DEBUG(5,("api_pipe_ntlmssp_verify: checking user details\n")); + memset((char *)&hdr_resp, '\0', sizeof(hdr_resp)); - memset(p->user_name, '\0', sizeof(p->user_name)); - memset(p->pipe_user_name, '\0', sizeof(p->pipe_user_name)); - memset(p->domain, '\0', sizeof(p->domain)); - memset(p->wks, '\0', sizeof(p->wks)); + /* Change the incoming request header to a response. */ + p->hdr.pkt_type = RPC_RESPONSE; - /* Set up for non-authenticated user. */ - delete_nt_token(&p->pipe_user.nt_user_token); - p->pipe_user.ngroups = 0; - SAFE_FREE( p->pipe_user.groups); + /* Set up rpc header flags. */ + if (p->out_data.data_sent_length == 0) { + p->hdr.flags = RPC_FLG_FIRST; + } else { + p->hdr.flags = 0; + } - /* - * Setup an empty password for a guest user. + /* + * Work out how much we can fit in a single PDU. */ + data_len_left = prs_offset(&p->out_data.rdata) - p->out_data.data_sent_length; + /* - * We always negotiate UNICODE. + * Ensure there really is data left to send. */ - if (p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_UNICODE) { - rpcstr_pull(user_name, ntlmssp_resp->user, sizeof(fstring), ntlmssp_resp->hdr_usr.str_str_len*2, 0 ); - rpcstr_pull(domain, ntlmssp_resp->domain, sizeof(fstring), ntlmssp_resp->hdr_domain.str_str_len*2, 0); - rpcstr_pull(wks, ntlmssp_resp->wks, sizeof(fstring), ntlmssp_resp->hdr_wks.str_str_len*2, 0); - } else { - pull_ascii_fstring(user_name, ntlmssp_resp->user); - pull_ascii_fstring(domain, ntlmssp_resp->domain); - pull_ascii_fstring(wks, ntlmssp_resp->wks); + if(!data_len_left) { + DEBUG(0,("create_next_pdu_schannel: no data left to send !\n")); + return False; } - DEBUG(5,("user: %s domain: %s wks: %s\n", user_name, domain, wks)); + data_space_available = sizeof(p->out_data.current_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN - + RPC_HDR_AUTH_LEN - RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN; - nt_pw_len = MIN(sizeof(nt_owf), ntlmssp_resp->hdr_nt_resp.str_str_len); - lm_pw_len = MIN(sizeof(lm_owf), ntlmssp_resp->hdr_lm_resp.str_str_len); - - memcpy(lm_owf, ntlmssp_resp->lm_resp, sizeof(lm_owf)); - memcpy(nt_owf, ntlmssp_resp->nt_resp, nt_pw_len); + /* + * The amount we send is the minimum of the available + * space and the amount left to send. + */ -#ifdef DEBUG_PASSWORD - DEBUG(100,("lm, nt owfs, chal\n")); - dump_data(100, (char *)lm_owf, sizeof(lm_owf)); - dump_data(100, (char *)nt_owf, nt_pw_len); - dump_data(100, (char *)p->challenge, 8); -#endif + data_len = MIN(data_len_left, data_space_available); /* - * Allow guest access. Patch from Shirish Kalele . + * Set up the alloc hint. This should be the data left to + * send. */ - if (*user_name) { - - /* - * Do the length checking only if user is not NULL. - */ + hdr_resp.alloc_hint = data_len_left; - if (ntlmssp_resp->hdr_lm_resp.str_str_len == 0) - return False; - if (ntlmssp_resp->hdr_nt_resp.str_str_len == 0) - return False; - if (ntlmssp_resp->hdr_usr.str_str_len == 0) - return False; - if (ntlmssp_resp->hdr_domain.str_str_len == 0) - return False; - if (ntlmssp_resp->hdr_wks.str_str_len == 0) - return False; + /* + * Work out if this PDU will be the last. + */ + if(p->out_data.data_sent_length + data_len >= prs_offset(&p->out_data.rdata)) { + p->hdr.flags |= RPC_FLG_LAST; + if (data_len_left % 8) { + ss_padding_len = 8 - (data_len_left % 8); + DEBUG(10,("create_next_pdu_schannel: adding sign/seal padding of %u\n", + ss_padding_len )); + } } - - make_auth_context_fixed(&auth_context, (uchar*)p->challenge); - if (!make_user_info_netlogon_network(&user_info, - user_name, domain, wks, - lm_owf, lm_pw_len, - nt_owf, nt_pw_len)) { - DEBUG(0,("make_user_info_netlogon_network failed! Failing authenticaion.\n")); - return False; - } - - nt_status = auth_context->check_ntlm_password(auth_context, user_info, &server_info); - - (auth_context->free)(&auth_context); - free_user_info(&user_info); - - p->ntlmssp_auth_validated = NT_STATUS_IS_OK(nt_status); - - if (!p->ntlmssp_auth_validated) { - DEBUG(1,("api_pipe_ntlmssp_verify: User [%s]\\[%s] from machine %s \ -failed authentication on named pipe %s.\n", domain, user_name, wks, p->name )); - free_server_info(&server_info); - return False; - } + p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len + ss_padding_len + + RPC_HDR_AUTH_LEN + RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN; + p->hdr.auth_len = RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN; /* - * Set up the sign/seal data. + * Init the parse struct to point at the outgoing + * data. */ - if (server_info->lm_session_key.length != 16) { - DEBUG(1,("api_pipe_ntlmssp_verify: User [%s]\\[%s] from machine %s \ -succeeded authentication on named pipe %s, but session key was of incorrect length [%u].\n", - domain, user_name, wks, p->name, server_info->lm_session_key.length)); - free_server_info(&server_info); - return False; - } else { - uchar p24[24]; - NTLMSSPOWFencrypt(server_info->lm_session_key.data, lm_owf, p24); - { - unsigned char j = 0; - int ind; - - unsigned char k2[8]; + prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL); + prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); - memcpy(k2, p24, 5); - k2[5] = 0xe5; - k2[6] = 0x38; - k2[7] = 0xb0; + /* Store the header in the data stream. */ + if(!smb_io_rpc_hdr("hdr", &p->hdr, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu_schannel: failed to marshall RPC_HDR.\n")); + prs_mem_free(&outgoing_pdu); + return False; + } - for (ind = 0; ind < 256; ind++) - p->ntlmssp_hash[ind] = (unsigned char)ind; + if(!smb_io_rpc_hdr_resp("resp", &hdr_resp, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu_schannel: failed to marshall RPC_HDR_RESP.\n")); + prs_mem_free(&outgoing_pdu); + return False; + } - for( ind = 0; ind < 256; ind++) { - unsigned char tc; + /* Store the current offset. */ + data_pos = prs_offset(&outgoing_pdu); - j += (p->ntlmssp_hash[ind] + k2[ind%8]); + /* Copy the data into the PDU. */ - tc = p->ntlmssp_hash[ind]; - p->ntlmssp_hash[ind] = p->ntlmssp_hash[j]; - p->ntlmssp_hash[j] = tc; - } + if(!prs_append_some_prs_data(&outgoing_pdu, &p->out_data.rdata, p->out_data.data_sent_length, data_len)) { + DEBUG(0,("create_next_pdu_schannel: failed to copy %u bytes of data.\n", (unsigned int)data_len)); + prs_mem_free(&outgoing_pdu); + return False; + } - p->ntlmssp_hash[256] = 0; - p->ntlmssp_hash[257] = 0; + /* Copy the sign/seal padding data. */ + if (ss_padding_len) { + char pad[8]; + memset(pad, '\0', 8); + if (!prs_copy_data_in(&outgoing_pdu, pad, ss_padding_len)) { + DEBUG(0,("create_next_pdu_schannel: failed to add %u bytes of pad data.\n", (unsigned int)ss_padding_len)); + prs_mem_free(&outgoing_pdu); + return False; } + } - dump_data_pw("NTLMSSP hash (v1)\n", p->ntlmssp_hash, - sizeof(p->ntlmssp_hash)); - -/* NTLMSSPhash(p->ntlmssp_hash, p24); */ - p->ntlmssp_seq_num = 0; + { + /* + * Schannel processing. + */ + char *data; + RPC_HDR_AUTH auth_info; + RPC_AUTH_SCHANNEL_CHK verf; - } + data = prs_data_p(&outgoing_pdu) + data_pos; + /* Check it's the type of reply we were expecting to decode */ - fstrcpy(p->user_name, user_name); - fstrcpy(p->pipe_user_name, server_info->unix_name); - fstrcpy(p->domain, domain); - fstrcpy(p->wks, wks); + init_rpc_hdr_auth(&auth_info, + RPC_SCHANNEL_AUTH_TYPE, + p->auth.auth_level == PIPE_AUTH_LEVEL_PRIVACY ? + RPC_AUTH_LEVEL_PRIVACY : RPC_AUTH_LEVEL_INTEGRITY, + ss_padding_len, 1); - /* - * Store the UNIX credential data (uid/gid pair) in the pipe structure. - */ + if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu_schannel: failed to marshall RPC_HDR_AUTH.\n")); + prs_mem_free(&outgoing_pdu); + return False; + } - if (p->session_key.data) { - data_blob_free(&p->session_key); - } - p->session_key = data_blob(server_info->lm_session_key.data, server_info->lm_session_key.length); + schannel_encode(p->auth.a_u.schannel_auth, + p->auth.auth_level, + SENDER_IS_ACCEPTOR, + &verf, data, data_len + ss_padding_len); - p->pipe_user.uid = server_info->uid; - p->pipe_user.gid = server_info->gid; - - p->pipe_user.ngroups = server_info->n_groups; - if (p->pipe_user.ngroups) { - if (!(p->pipe_user.groups = memdup(server_info->groups, sizeof(gid_t) * p->pipe_user.ngroups))) { - DEBUG(0,("failed to memdup group list to p->pipe_user.groups\n")); - free_server_info(&server_info); + if (!smb_io_rpc_auth_schannel_chk("", RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN, + &verf, &outgoing_pdu, 0)) { + prs_mem_free(&outgoing_pdu); return False; } - } - if (server_info->ptok) - p->pipe_user.nt_user_token = dup_nt_token(server_info->ptok); - else { - DEBUG(1,("Error: Authmodule failed to provide nt_user_token\n")); - p->pipe_user.nt_user_token = NULL; - free_server_info(&server_info); - return False; + p->auth.a_u.schannel_auth->seq_num++; } - p->ntlmssp_auth_validated = True; + /* + * Setup the counts for this PDU. + */ + + p->out_data.data_sent_length += data_len; + p->out_data.current_pdu_len = p->hdr.frag_len; + p->out_data.current_pdu_sent = 0; - free_server_info(&server_info); + prs_mem_free(&outgoing_pdu); return True; } /******************************************************************* - The switch table for the pipe names and the functions to handle them. - *******************************************************************/ + Generate the next PDU to be returned from the data in p->rdata. + No authentication done. +********************************************************************/ -struct rpc_table +static BOOL create_next_pdu_noauth(pipes_struct *p) { - struct - { - const char *clnt; - const char *srv; - } pipe; - struct api_struct *cmds; - int n_cmds; -}; + RPC_HDR_RESP hdr_resp; + uint32 data_len; + uint32 data_space_available; + uint32 data_len_left; + prs_struct outgoing_pdu; -static struct rpc_table *rpc_lookup; -static int rpc_lookup_size; + /* + * If we're in the fault state, keep returning fault PDU's until + * the pipe gets closed. JRA. + */ -/******************************************************************* - This is the client reply to our challenge for an authenticated - bind request. The challenge we sent is in p->challenge. -*******************************************************************/ + if(p->fault_state) { + setup_fault_pdu(p, NT_STATUS(0x1c010002)); + return True; + } -BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *rpc_in_p) -{ - RPC_HDR_AUTHA autha_info; - RPC_AUTH_VERIFIER auth_verifier; - RPC_AUTH_NTLMSSP_RESP ntlmssp_resp; + memset((char *)&hdr_resp, '\0', sizeof(hdr_resp)); - DEBUG(5,("api_pipe_bind_auth_resp: decode request. %d\n", __LINE__)); + /* Change the incoming request header to a response. */ + p->hdr.pkt_type = RPC_RESPONSE; - if (p->hdr.auth_len == 0) { - DEBUG(0,("api_pipe_bind_auth_resp: No auth field sent !\n")); - return False; + /* Set up rpc header flags. */ + if (p->out_data.data_sent_length == 0) { + p->hdr.flags = RPC_FLG_FIRST; + } else { + p->hdr.flags = 0; } /* - * Decode the authentication verifier response. + * Work out how much we can fit in a single PDU. + */ + + data_len_left = prs_offset(&p->out_data.rdata) - p->out_data.data_sent_length; + + /* + * Ensure there really is data left to send. + */ + + if(!data_len_left) { + DEBUG(0,("create_next_pdu_noath: no data left to send !\n")); + return False; + } + + data_space_available = sizeof(p->out_data.current_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN; + + /* + * The amount we send is the minimum of the available + * space and the amount left to send. + */ + + data_len = MIN(data_len_left, data_space_available); + + /* + * Set up the alloc hint. This should be the data left to + * send. + */ + + hdr_resp.alloc_hint = data_len_left; + + /* + * Work out if this PDU will be the last. */ - if(!smb_io_rpc_hdr_autha("", &autha_info, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_auth_resp: unmarshall of RPC_HDR_AUTHA failed.\n")); + if(p->out_data.data_sent_length + data_len >= prs_offset(&p->out_data.rdata)) { + p->hdr.flags |= RPC_FLG_LAST; + } + + /* + * Set up the header lengths. + */ + + p->hdr.frag_len = RPC_HEADER_LEN + RPC_HDR_RESP_LEN + data_len; + p->hdr.auth_len = 0; + + /* + * Init the parse struct to point at the outgoing + * data. + */ + + prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL); + prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); + + /* Store the header in the data stream. */ + if(!smb_io_rpc_hdr("hdr", &p->hdr, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu_noath: failed to marshall RPC_HDR.\n")); + prs_mem_free(&outgoing_pdu); return False; } - if (autha_info.auth.auth_type != NTLMSSP_AUTH_TYPE || autha_info.auth.auth_level != RPC_PIPE_AUTH_SEAL_LEVEL) { - DEBUG(0,("api_pipe_bind_auth_resp: incorrect auth type (%d) or level (%d).\n", - (int)autha_info.auth.auth_type, (int)autha_info.auth.auth_level )); + if(!smb_io_rpc_hdr_resp("resp", &hdr_resp, &outgoing_pdu, 0)) { + DEBUG(0,("create_next_pdu_noath: failed to marshall RPC_HDR_RESP.\n")); + prs_mem_free(&outgoing_pdu); return False; } - if(!smb_io_rpc_auth_verifier("", &auth_verifier, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_auth_resp: unmarshall of RPC_AUTH_VERIFIER failed.\n")); + /* Copy the data into the PDU. */ + + if(!prs_append_some_prs_data(&outgoing_pdu, &p->out_data.rdata, p->out_data.data_sent_length, data_len)) { + DEBUG(0,("create_next_pdu_noauth: failed to copy %u bytes of data.\n", (unsigned int)data_len)); + prs_mem_free(&outgoing_pdu); return False; } /* - * Ensure this is a NTLMSSP_AUTH packet type. + * Setup the counts for this PDU. */ - if (!rpc_auth_verifier_chk(&auth_verifier, "NTLMSSP", NTLMSSP_AUTH)) { - DEBUG(0,("api_pipe_bind_auth_resp: rpc_auth_verifier_chk failed.\n")); + p->out_data.data_sent_length += data_len; + p->out_data.current_pdu_len = p->hdr.frag_len; + p->out_data.current_pdu_sent = 0; + + prs_mem_free(&outgoing_pdu); + return True; +} + +/******************************************************************* + Generate the next PDU to be returned from the data in p->rdata. +********************************************************************/ + +BOOL create_next_pdu(pipes_struct *p) +{ + switch(p->auth.auth_level) { + case PIPE_AUTH_LEVEL_NONE: + case PIPE_AUTH_LEVEL_CONNECT: + /* This is incorrect for auth level connect. Fixme. JRA */ + return create_next_pdu_noauth(p); + + default: + switch(p->auth.auth_type) { + case PIPE_AUTH_TYPE_NTLMSSP: + case PIPE_AUTH_TYPE_SPNEGO_NTLMSSP: + return create_next_pdu_ntlmssp(p); + case PIPE_AUTH_TYPE_SCHANNEL: + return create_next_pdu_schannel(p); + default: + break; + } + } + + DEBUG(0,("create_next_pdu: invalid internal auth level %u / type %u", + (unsigned int)p->auth.auth_level, + (unsigned int)p->auth.auth_type)); + return False; +} + +/******************************************************************* + Process an NTLMSSP authentication response. + If this function succeeds, the user has been authenticated + and their domain, name and calling workstation stored in + the pipe struct. +*******************************************************************/ + +static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) +{ + DATA_BLOB reply; + NTSTATUS status; + AUTH_NTLMSSP_STATE *a = p->auth.a_u.auth_ntlmssp_state; + + DEBUG(5,("pipe_ntlmssp_verify_final: checking user details\n")); + + ZERO_STRUCT(reply); + + memset(p->user_name, '\0', sizeof(p->user_name)); + memset(p->pipe_user_name, '\0', sizeof(p->pipe_user_name)); + memset(p->domain, '\0', sizeof(p->domain)); + memset(p->wks, '\0', sizeof(p->wks)); + + /* Set up for non-authenticated user. */ + delete_nt_token(&p->pipe_user.nt_user_token); + p->pipe_user.ngroups = 0; + SAFE_FREE( p->pipe_user.groups); + + status = auth_ntlmssp_update(a, *p_resp_blob, &reply); + + /* Don't generate a reply. */ + data_blob_free(&reply); + + if (!NT_STATUS_IS_OK(status)) { return False; } - if(!smb_io_rpc_auth_ntlmssp_resp("", &ntlmssp_resp, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_auth_resp: Failed to unmarshall RPC_AUTH_NTLMSSP_RESP.\n")); + fstrcpy(p->user_name, a->ntlmssp_state->user); + fstrcpy(p->pipe_user_name, a->server_info->unix_name); + fstrcpy(p->domain, a->ntlmssp_state->domain); + fstrcpy(p->wks, a->ntlmssp_state->workstation); + + DEBUG(5,("pipe_ntlmssp_verify_final: OK: user: %s domain: %s workstation: %s\n", + p->user_name, p->domain, p->wks)); + + /* + * Store the UNIX credential data (uid/gid pair) in the pipe structure. + */ + + p->pipe_user.uid = a->server_info->uid; + p->pipe_user.gid = a->server_info->gid; + + /* + * Copy the session key from the ntlmssp state. + */ + + data_blob_free(&p->session_key); + p->session_key = data_blob(a->ntlmssp_state->session_key.data, a->ntlmssp_state->session_key.length); + if (!p->session_key.data) { return False; } + p->pipe_user.ngroups = a->server_info->n_groups; + if (p->pipe_user.ngroups) { + if (!(p->pipe_user.groups = memdup(a->server_info->groups, sizeof(gid_t) * p->pipe_user.ngroups))) { + DEBUG(0,("failed to memdup group list to p->pipe_user.groups\n")); + return False; + } + } + + if (a->server_info->ptok) { + p->pipe_user.nt_user_token = dup_nt_token(a->server_info->ptok); + } else { + DEBUG(1,("Error: Authmodule failed to provide nt_user_token\n")); + p->pipe_user.nt_user_token = NULL; + return False; + } + + return True; +} + +/******************************************************************* + The switch table for the pipe names and the functions to handle them. +*******************************************************************/ + +struct rpc_table { + struct { + const char *clnt; + const char *srv; + } pipe; + struct api_struct *cmds; + int n_cmds; +}; + +static struct rpc_table *rpc_lookup; +static int rpc_lookup_size; + +/******************************************************************* + This is the "stage3" NTLMSSP response after a bind request and reply. +*******************************************************************/ + +BOOL api_pipe_bind_auth3(pipes_struct *p, prs_struct *rpc_in_p) +{ + RPC_HDR_AUTH auth_info; + uint32 pad; + DATA_BLOB blob; + + ZERO_STRUCT(blob); + + DEBUG(5,("api_pipe_bind_auth3: decode request. %d\n", __LINE__)); + + if (p->hdr.auth_len == 0) { + DEBUG(0,("api_pipe_bind_auth3: No auth field sent !\n")); + goto err; + } + + /* 4 bytes padding. */ + if (!prs_uint32("pad", rpc_in_p, 0, &pad)) { + DEBUG(0,("api_pipe_bind_auth3: unmarshall of 4 byte pad failed.\n")); + goto err; + } + + /* + * Decode the authentication verifier response. + */ + + if(!smb_io_rpc_hdr_auth("", &auth_info, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_auth3: unmarshall of RPC_HDR_AUTH failed.\n")); + goto err; + } + + if (auth_info.auth_type != RPC_NTLMSSP_AUTH_TYPE) { + DEBUG(0,("api_pipe_bind_auth3: incorrect auth type (%u).\n", + (unsigned int)auth_info.auth_type )); + return False; + } + + blob = data_blob(NULL,p->hdr.auth_len); + + if (!prs_copy_data_out(blob.data, rpc_in_p, p->hdr.auth_len)) { + DEBUG(0,("api_pipe_bind_auth3: Failed to pull %u bytes - the response blob.\n", + (unsigned int)p->hdr.auth_len )); + goto err; + } + /* * The following call actually checks the challenge/response data. * for correctness against the given DOMAIN\user name. */ - if (!api_pipe_ntlmssp_verify(p, &ntlmssp_resp)) - return False; + if (!pipe_ntlmssp_verify_final(p, &blob)) { + goto err; + } + + data_blob_free(&blob); + + p->pipe_bound = True; - p->pipe_bound = True -; return True; + + err: + + data_blob_free(&blob); + free_pipe_ntlmssp_auth_data(&p->auth); + p->auth.a_u.auth_ntlmssp_state = NULL; + + return False; } /******************************************************************* @@ -642,13 +792,12 @@ static BOOL setup_bind_nak(pipes_struct *p) prs_init( &outgoing_rpc, 0, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); - /* * Initialize a bind_nak header. */ init_rpc_hdr(&nak_hdr, RPC_BINDNACK, RPC_FLG_FIRST | RPC_FLG_LAST, - p->hdr.call_id, RPC_HEADER_LEN + sizeof(uint16), 0); + p->hdr.call_id, RPC_HEADER_LEN + sizeof(uint16), 0); /* * Marshall the header into the outgoing PDU. @@ -673,6 +822,11 @@ static BOOL setup_bind_nak(pipes_struct *p) p->out_data.current_pdu_len = prs_offset(&outgoing_rpc); p->out_data.current_pdu_sent = 0; + if (p->auth.auth_data_free_func) { + (*p->auth.auth_data_free_func)(&p->auth); + } + p->auth.auth_level = PIPE_AUTH_LEVEL_NONE; + p->auth.auth_type = PIPE_AUTH_TYPE_NONE; p->pipe_bound = False; return True; @@ -766,15 +920,13 @@ BOOL check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, /* we have to check all now since win2k introduced a new UUID on the lsaprpc pipe */ - for ( i=0; pipe_names[i].client_pipe; i++ ) - { + for ( i=0; pipe_names[i].client_pipe; i++ ) { DEBUG(10,("checking %s\n", pipe_names[i].client_pipe)); if ( strequal(pipe_names[i].client_pipe, pname) && (abstract->version == pipe_names[i].abstr_syntax.version) && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(struct uuid)) == 0) && (transfer->version == pipe_names[i].trans_syntax.version) - && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(struct uuid)) == 0) ) - { + && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(struct uuid)) == 0) ) { struct api_struct *fns = NULL; int n_fns = 0; PIPE_RPC_FNS *context_fns; @@ -800,8 +952,9 @@ BOOL check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, } } - if(pipe_names[i].client_pipe == NULL) + if(pipe_names[i].client_pipe == NULL) { return False; + } return True; } @@ -809,6 +962,7 @@ BOOL check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, /******************************************************************* Register commands to an RPC pipe *******************************************************************/ + NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *srv, const struct api_struct *cmds, int size) { struct rpc_table *rpc_entry; @@ -856,6 +1010,365 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *s return NT_STATUS_OK; } +/******************************************************************* + Handle a SPNEGO krb5 bind auth. +*******************************************************************/ + +static BOOL pipe_spnego_auth_bind_kerberos(pipes_struct *p, prs_struct *rpc_in_p, RPC_HDR_AUTH *pauth_info, + DATA_BLOB *psecblob, prs_struct *pout_auth) +{ + return False; +} + +/******************************************************************* + Handle the first part of a SPNEGO bind auth. +*******************************************************************/ + +static BOOL pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_p, + RPC_HDR_AUTH *pauth_info, prs_struct *pout_auth) +{ + DATA_BLOB blob; + DATA_BLOB secblob; + DATA_BLOB response; + DATA_BLOB chal; + char *OIDs[ASN1_MAX_OIDS]; + int i; + NTSTATUS status; + BOOL got_kerberos_mechanism = False; + AUTH_NTLMSSP_STATE *a = NULL; + RPC_HDR_AUTH auth_info; + + ZERO_STRUCT(secblob); + ZERO_STRUCT(chal); + ZERO_STRUCT(response); + + /* Grab the SPNEGO blob. */ + blob = data_blob(NULL,p->hdr.auth_len); + + if (!prs_copy_data_out(blob.data, rpc_in_p, p->hdr.auth_len)) { + DEBUG(0,("pipe_spnego_auth_bind_negotiate: Failed to pull %u bytes - the SPNEGO auth header.\n", + (unsigned int)p->hdr.auth_len )); + goto err; + } + + if (blob.data[0] != ASN1_APPLICATION(0)) { + goto err; + } + + /* parse out the OIDs and the first sec blob */ + if (!parse_negTokenTarg(blob, OIDs, &secblob)) { + DEBUG(0,("pipe_spnego_auth_bind_negotiate: Failed to parse the security blob.\n")); + goto err; + } + + if (strcmp(OID_KERBEROS5, OIDs[0]) == 0 || strcmp(OID_KERBEROS5_OLD, OIDs[0]) == 0) { + got_kerberos_mechanism = True; + } + + for (i=0;OIDs[i];i++) { + DEBUG(3,("pipe_spnego_auth_bind_negotiate: Got OID %s\n", OIDs[i])); + SAFE_FREE(OIDs[i]); + } + DEBUG(3,("pipe_spnego_auth_bind_negotiate: Got secblob of size %lu\n", (unsigned long)secblob.length)); + + if ( got_kerberos_mechanism && ((lp_security()==SEC_ADS) || lp_use_kerberos_keytab()) ) { + BOOL ret = pipe_spnego_auth_bind_kerberos(p, rpc_in_p, pauth_info, &secblob, pout_auth); + data_blob_free(&secblob); + data_blob_free(&blob); + return ret; + } + + if (p->auth.auth_type == PIPE_AUTH_TYPE_SPNEGO_NTLMSSP && p->auth.a_u.auth_ntlmssp_state) { + /* Free any previous auth type. */ + free_pipe_ntlmssp_auth_data(&p->auth); + } + + /* Initialize the NTLM engine. */ + status = auth_ntlmssp_start(&a); + if (!NT_STATUS_IS_OK(status)) { + goto err; + } + + /* + * Pass the first security blob of data to it. + * This can return an error or NT_STATUS_MORE_PROCESSING_REQUIRED + * which means we need another packet to complete the bind. + */ + + status = auth_ntlmssp_update(a, secblob, &chal); + + if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + DEBUG(3,("pipe_spnego_auth_bind_negotiate: auth_ntlmssp_update failed.\n")); + goto err; + } + + /* Generate the response blob we need for step 2 of the bind. */ + response = spnego_gen_auth_response(&chal, status, OID_NTLMSSP); + + /* Copy the blob into the pout_auth parse struct */ + init_rpc_hdr_auth(&auth_info, RPC_SPNEGO_AUTH_TYPE, pauth_info->auth_level, RPC_HDR_AUTH_LEN, 1); + if(!smb_io_rpc_hdr_auth("", &auth_info, pout_auth, 0)) { + DEBUG(0,("pipe_spnego_auth_bind_negotiate: marshalling of RPC_HDR_AUTH failed.\n")); + goto err; + } + + if (!prs_copy_data_in(pout_auth, response.data, response.length)) { + DEBUG(0,("pipe_spnego_auth_bind_negotiate: marshalling of data blob failed.\n")); + goto err; + } + + p->auth.a_u.auth_ntlmssp_state = a; + p->auth.auth_data_free_func = &free_pipe_ntlmssp_auth_data; + p->auth.auth_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP; + + data_blob_free(&blob); + data_blob_free(&secblob); + data_blob_free(&chal); + data_blob_free(&response); + + /* We can't set pipe_bound True yet - we need an RPC_ALTER_CONTEXT response packet... */ + return True; + + err: + + data_blob_free(&blob); + data_blob_free(&secblob); + data_blob_free(&chal); + data_blob_free(&response); + + p->auth.a_u.auth_ntlmssp_state = NULL; + + return False; +} + +/******************************************************************* + Handle the second part of a SPNEGO bind auth. +*******************************************************************/ + +static BOOL pipe_spnego_auth_bind_continue(pipes_struct *p, prs_struct *rpc_in_p, + RPC_HDR_AUTH *pauth_info, prs_struct *pout_auth) +{ + DATA_BLOB spnego_blob, auth_blob, auth_reply; + AUTH_NTLMSSP_STATE *a = p->auth.a_u.auth_ntlmssp_state; + + ZERO_STRUCT(spnego_blob); + ZERO_STRUCT(auth_blob); + ZERO_STRUCT(auth_reply); + + if (p->auth.auth_type != PIPE_AUTH_TYPE_SPNEGO_NTLMSSP || !a) { + DEBUG(0,("pipe_spnego_auth_bind_continue: not in NTLMSSP auth state.\n")); + goto err; + } + + /* Grab the SPNEGO blob. */ + spnego_blob = data_blob(NULL,p->hdr.auth_len); + + if (!prs_copy_data_out(spnego_blob.data, rpc_in_p, p->hdr.auth_len)) { + DEBUG(0,("pipe_spnego_auth_bind_continue: Failed to pull %u bytes - the SPNEGO auth header.\n", + (unsigned int)p->hdr.auth_len )); + goto err; + } + + if (spnego_blob.data[0] != ASN1_CONTEXT(1)) { + DEBUG(0,("pipe_spnego_auth_bind_continue: invalid SPNEGO blob type.\n")); + goto err; + } + + if (!spnego_parse_auth(spnego_blob, &auth_blob)) { + DEBUG(0,("pipe_spnego_auth_bind_continue: invalid SPNEGO blob.\n")); + goto err; + } + + /* + * The following call actually checks the challenge/response data. + * for correctness against the given DOMAIN\user name. + */ + + if (!pipe_ntlmssp_verify_final(p, &auth_blob)) { + goto err; + } + + data_blob_free(&spnego_blob); + data_blob_free(&auth_blob); + data_blob_free(&auth_reply); + + p->pipe_bound = True; + + return True; + + err: + + data_blob_free(&spnego_blob); + data_blob_free(&auth_blob); + data_blob_free(&auth_reply); + + free_pipe_ntlmssp_auth_data(&p->auth); + p->auth.a_u.auth_ntlmssp_state = NULL; + + return False; +} + +/******************************************************************* + Handle an schannel bind auth. +*******************************************************************/ + +static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, + RPC_HDR_AUTH *pauth_info, prs_struct *pout_auth) +{ + RPC_HDR_AUTH auth_info; + RPC_AUTH_SCHANNEL_NEG neg; + RPC_AUTH_VERIFIER auth_verifier; + uint32 flags; + + if (!server_auth2_negotiated) { + DEBUG(0, ("pipe_schannel_auth_bind: Attempt to bind using schannel without successful serverauth2\n")); + return False; + } + + if (!smb_io_rpc_auth_schannel_neg("", &neg, rpc_in_p, 0)) { + DEBUG(0,("pipe_schannel_auth_bind: Could not unmarshal SCHANNEL auth neg\n")); + return False; + } + + p->auth.a_u.schannel_auth = TALLOC_P(p->pipe_state_mem_ctx, struct schannel_auth_struct); + if (!p->auth.a_u.schannel_auth) { + return False; + } + + memset(p->auth.a_u.schannel_auth->sess_key, 0, sizeof(p->auth.a_u.schannel_auth->sess_key)); + memcpy(p->auth.a_u.schannel_auth->sess_key, last_dcinfo.sess_key, sizeof(last_dcinfo.sess_key)); + + p->auth.a_u.schannel_auth->seq_num = 0; + + /* + * JRA. Should we also copy the schannel session key into the pipe session key p->session_key + * here ? We do that for NTLMSPP, but the session key is already set up from the vuser + * struct of the person who opened the pipe. I need to test this further. JRA. + */ + + /* The client opens a second RPC NETLOGON pipe without + doing a auth2. The credentials for the schannel are + re-used from the auth2 the client did before. */ + p->dc = TALLOC_ZERO_P(p->pipe_state_mem_ctx, struct dcinfo); + if (!p->dc) { + return False; + } + *p->dc = last_dcinfo; + + init_rpc_hdr_auth(&auth_info, RPC_SCHANNEL_AUTH_TYPE, pauth_info->auth_level, RPC_HDR_AUTH_LEN, 1); + if(!smb_io_rpc_hdr_auth("", &auth_info, pout_auth, 0)) { + DEBUG(0,("pipe_schannel_auth_bind: marshalling of RPC_HDR_AUTH failed.\n")); + return False; + } + + /*** SCHANNEL verifier ***/ + + init_rpc_auth_verifier(&auth_verifier, "\001", 0x0); + if(!smb_io_rpc_schannel_verifier("", &auth_verifier, pout_auth, 0)) { + DEBUG(0,("pipe_schannel_auth_bind: marshalling of RPC_AUTH_VERIFIER failed.\n")); + return False; + } + + prs_align(pout_auth); + + flags = 5; + if(!prs_uint32("flags ", pout_auth, 0, &flags)) { + return False; + } + + DEBUG(10,("pipe_schannel_auth_bind: schannel auth: domain [%s] myname [%s]\n", + neg.domain, neg.myname)); + + /* We're finished with this bind - no more packets. */ + p->auth.auth_data_free_func = NULL; + p->auth.auth_type = PIPE_AUTH_TYPE_SCHANNEL; + + p->pipe_bound = True; + + return True; +} + +/******************************************************************* + Handle an NTLMSSP bind auth. +*******************************************************************/ + +static BOOL pipe_ntlmssp_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, + RPC_HDR_AUTH *pauth_info, prs_struct *pout_auth) +{ + RPC_HDR_AUTH auth_info; + DATA_BLOB blob; + DATA_BLOB response; + NTSTATUS status; + AUTH_NTLMSSP_STATE *a = NULL; + + ZERO_STRUCT(blob); + ZERO_STRUCT(response); + + /* Grab the NTLMSSP blob. */ + blob = data_blob(NULL,p->hdr.auth_len); + + if (!prs_copy_data_out(blob.data, rpc_in_p, p->hdr.auth_len)) { + DEBUG(0,("pipe_ntlmssp_auth_bind: Failed to pull %u bytes - the NTLM auth header.\n", + (unsigned int)p->hdr.auth_len )); + goto err; + } + + if (strncmp(blob.data, "NTLMSSP", 7) != 0) { + DEBUG(0,("pipe_ntlmssp_auth_bind: Failed to read NTLMSSP in blob\n")); + goto err; + } + + /* We have an NTLMSSP blob. */ + status = auth_ntlmssp_start(&a); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("pipe_ntlmssp_auth_bind: auth_ntlmssp_start failed: %s\n", + nt_errstr(status) )); + goto err; + } + + status = auth_ntlmssp_update(a, blob, &response); + if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + DEBUG(0,("pipe_ntlmssp_auth_bind: auth_ntlmssp_update failed: %s\n", + nt_errstr(status) )); + goto err; + } + + data_blob_free(&blob); + + /* Copy the blob into the pout_auth parse struct */ + init_rpc_hdr_auth(&auth_info, RPC_NTLMSSP_AUTH_TYPE, pauth_info->auth_level, RPC_HDR_AUTH_LEN, 1); + if(!smb_io_rpc_hdr_auth("", &auth_info, pout_auth, 0)) { + DEBUG(0,("pipe_ntlmssp_auth_bind: marshalling of RPC_HDR_AUTH failed.\n")); + goto err; + } + + if (!prs_copy_data_in(pout_auth, response.data, response.length)) { + DEBUG(0,("pipe_ntlmssp_auth_bind: marshalling of data blob failed.\n")); + goto err; + } + + p->auth.a_u.auth_ntlmssp_state = a; + p->auth.auth_data_free_func = &free_pipe_ntlmssp_auth_data; + p->auth.auth_type = PIPE_AUTH_TYPE_NTLMSSP; + + data_blob_free(&blob); + data_blob_free(&response); + + DEBUG(10,("pipe_ntlmssp_auth_bind: NTLMSSP auth started\n")); + + /* We can't set pipe_bound True yet - we need an RPC_AUTH3 response packet... */ + return True; + + err: + + data_blob_free(&blob); + data_blob_free(&response); + + free_pipe_ntlmssp_auth_data(&p->auth); + p->auth.a_u.auth_ntlmssp_state = NULL; + return False; +} + /******************************************************************* Respond to a pipe bind request. *******************************************************************/ @@ -872,162 +1385,280 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) prs_struct outgoing_rpc; int i = 0; int auth_len = 0; - enum RPC_PKT_TYPE reply_pkt_type; + unsigned int auth_type = RPC_ANONYMOUS_AUTH_TYPE; + + /* No rebinds on a bound pipe - use alter context. */ + if (p->pipe_bound) { + DEBUG(2,("api_pipe_bind_req: rejecting bind request on bound pipe %s.\n", p->pipe_srv_name)); + return setup_bind_nak(p); + } - p->ntlmssp_auth_requested = False; - p->netsec_auth_validated = False; + prs_init( &outgoing_rpc, 0, p->mem_ctx, MARSHALL); + + /* + * Marshall directly into the outgoing PDU space. We + * must do this as we need to set to the bind response + * header and are never sending more than one PDU here. + */ + + prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); + + /* + * Setup the memory to marshall the ba header, and the + * auth footers. + */ + + if(!prs_init(&out_hdr_ba, 1024, p->mem_ctx, MARSHALL)) { + DEBUG(0,("api_pipe_bind_req: malloc out_hdr_ba failed.\n")); + prs_mem_free(&outgoing_rpc); + return False; + } + + if(!prs_init(&out_auth, 1024, p->mem_ctx, MARSHALL)) { + DEBUG(0,("api_pipe_bind_req: malloc out_auth failed.\n")); + prs_mem_free(&outgoing_rpc); + prs_mem_free(&out_hdr_ba); + return False; + } DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); /* - * Try and find the correct pipe name to ensure - * that this is a pipe name we support. + * Try and find the correct pipe name to ensure + * that this is a pipe name we support. + */ + + + for (i = 0; i < rpc_lookup_size; i++) { + if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { + DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", + rpc_lookup[i].pipe.clnt, rpc_lookup[i].pipe.srv)); + fstrcpy(p->pipe_srv_name, rpc_lookup[i].pipe.srv); + break; + } + } + + if (i == rpc_lookup_size) { + if (NT_STATUS_IS_ERR(smb_probe_module("rpc", p->name))) { + DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", + p->name )); + prs_mem_free(&outgoing_rpc); + prs_mem_free(&out_hdr_ba); + prs_mem_free(&out_auth); + + return setup_bind_nak(p); + } + + for (i = 0; i < rpc_lookup_size; i++) { + if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { + DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", + rpc_lookup[i].pipe.clnt, rpc_lookup[i].pipe.srv)); + fstrcpy(p->pipe_srv_name, rpc_lookup[i].pipe.srv); + break; + } + } + + if (i == rpc_lookup_size) { + DEBUG(0, ("module %s doesn't provide functions for pipe %s!\n", p->name, p->name)); + goto err_exit; + } + } + + /* decode the bind request */ + if(!smb_io_rpc_hdr_rb("", &hdr_rb, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_RB struct.\n")); + goto err_exit; + } + + /* name has to be \PIPE\xxxxx */ + fstrcpy(ack_pipe_name, "\\PIPE\\"); + fstrcat(ack_pipe_name, p->pipe_srv_name); + + DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); + + /* + * Check if this is an authenticated bind request. + */ + + if (p->hdr.auth_len) { + /* + * Decode the authentication verifier. + */ + + if(!smb_io_rpc_hdr_auth("", &auth_info, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); + goto err_exit; + } + + auth_type = auth_info.auth_type; + + /* Work out if we have to sign or seal etc. */ + switch (auth_info.auth_level) { + case RPC_AUTH_LEVEL_INTEGRITY: + p->auth.auth_level = PIPE_AUTH_LEVEL_INTEGRITY; + break; + case RPC_AUTH_LEVEL_PRIVACY: + p->auth.auth_level = PIPE_AUTH_LEVEL_PRIVACY; + break; + default: + DEBUG(0,("api_pipe_bind_req: unexpected auth level (%u).\n", + (unsigned int)auth_info.auth_level )); + goto err_exit; + } + } else { + ZERO_STRUCT(auth_info); + } + + assoc_gid = hdr_rb.bba.assoc_gid ? hdr_rb.bba.assoc_gid : 0x53f0; + + switch(auth_type) { + case RPC_NTLMSSP_AUTH_TYPE: + if (!pipe_ntlmssp_auth_bind(p, rpc_in_p, &auth_info, &out_auth)) { + goto err_exit; + } + assoc_gid = 0x7a77; + break; + + case RPC_SCHANNEL_AUTH_TYPE: + if (!pipe_schannel_auth_bind(p, rpc_in_p, &auth_info, &out_auth)) { + goto err_exit; + } + break; + + case RPC_SPNEGO_AUTH_TYPE: + if (!pipe_spnego_auth_bind_negotiate(p, rpc_in_p, &auth_info, &out_auth)) { + goto err_exit; + } + break; + + case RPC_ANONYMOUS_AUTH_TYPE: + /* Unauthenticated bind request. */ + /* We're finished - no more packets. */ + p->auth.auth_type = PIPE_AUTH_TYPE_NONE; + /* We must set the pipe auth_level here also. */ + p->auth.auth_level = PIPE_AUTH_LEVEL_NONE; + p->pipe_bound = True; + break; + + default: + DEBUG(0,("api_pipe_bind_req: unknown auth type %x requested.\n", auth_type )); + goto err_exit; + } + + /* + * Create the bind response struct. + */ + + /* If the requested abstract synt uuid doesn't match our client pipe, + reject the bind_ack & set the transfer interface synt to all 0's, + ver 0 (observed when NT5 attempts to bind to abstract interfaces + unknown to NT4) + Needed when adding entries to a DACL from NT5 - SK */ + + if(check_bind_req(p, &hdr_rb.rpc_context[0].abstract, &hdr_rb.rpc_context[0].transfer[0], + hdr_rb.rpc_context[0].context_id )) { + init_rpc_hdr_ba(&hdr_ba, + RPC_MAX_PDU_FRAG_LEN, + RPC_MAX_PDU_FRAG_LEN, + assoc_gid, + ack_pipe_name, + 0x1, 0x0, 0x0, + &hdr_rb.rpc_context[0].transfer[0]); + } else { + RPC_IFACE null_interface; + ZERO_STRUCT(null_interface); + /* Rejection reason: abstract syntax not supported */ + init_rpc_hdr_ba(&hdr_ba, RPC_MAX_PDU_FRAG_LEN, + RPC_MAX_PDU_FRAG_LEN, assoc_gid, + ack_pipe_name, 0x1, 0x2, 0x1, + &null_interface); + p->pipe_bound = False; + } + + /* + * and marshall it. */ - - for (i = 0; i < rpc_lookup_size; i++) { - if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { - DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", - rpc_lookup[i].pipe.clnt, rpc_lookup[i].pipe.srv)); - fstrcpy(p->pipe_srv_name, rpc_lookup[i].pipe.srv); - break; - } + if(!smb_io_rpc_hdr_ba("", &hdr_ba, &out_hdr_ba, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_BA failed.\n")); + goto err_exit; } - if (i == rpc_lookup_size) { - if (NT_STATUS_IS_ERR(smb_probe_module("rpc", p->name))) { - DEBUG(3,("api_pipe_bind_req: Unknown pipe name %s in bind request.\n", - p->name )); - return setup_bind_nak(p); - } - - for (i = 0; i < rpc_lookup_size; i++) { - if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { - DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", - rpc_lookup[i].pipe.clnt, rpc_lookup[i].pipe.srv)); - fstrcpy(p->pipe_srv_name, rpc_lookup[i].pipe.srv); - break; - } - } + /* + * Create the header, now we know the length. + */ - if (i == rpc_lookup_size) { - DEBUG(0, ("module %s doesn't provide functions for pipe %s!\n", p->name, p->name)); - return False; - } + if (prs_offset(&out_auth)) { + auth_len = prs_offset(&out_auth) - RPC_HDR_AUTH_LEN; } - /* decode the bind request */ - if(!smb_io_rpc_hdr_rb("", &hdr_rb, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_RB struct.\n")); - return setup_bind_nak(p); - } + init_rpc_hdr(&p->hdr, RPC_BINDACK, RPC_FLG_FIRST | RPC_FLG_LAST, + p->hdr.call_id, + RPC_HEADER_LEN + prs_offset(&out_hdr_ba) + prs_offset(&out_auth), + auth_len); /* - * Check if this is an authenticated request. + * Marshall the header into the outgoing PDU. */ - if (p->hdr.auth_len != 0) { - RPC_AUTH_VERIFIER auth_verifier; - RPC_AUTH_NTLMSSP_NEG ntlmssp_neg; - - /* - * Decode the authentication verifier. - */ - - if(!smb_io_rpc_hdr_auth("", &auth_info, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_AUTH struct.\n")); - return setup_bind_nak(p); - } - - switch(auth_info.auth_type) { - case NTLMSSP_AUTH_TYPE: - - if(!smb_io_rpc_auth_verifier("", &auth_verifier, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_req: unable to " - "unmarshall RPC_HDR_AUTH struct.\n")); - return setup_bind_nak(p); - } - - if(!strequal(auth_verifier.signature, "NTLMSSP")) { - DEBUG(0,("api_pipe_bind_req: " - "auth_verifier.signature != NTLMSSP\n")); - return setup_bind_nak(p); - } - - if(auth_verifier.msg_type != NTLMSSP_NEGOTIATE) { - DEBUG(0,("api_pipe_bind_req: " - "auth_verifier.msg_type (%d) != NTLMSSP_NEGOTIATE\n", - auth_verifier.msg_type)); - return setup_bind_nak(p); - } + if(!smb_io_rpc_hdr("", &p->hdr, &outgoing_rpc, 0)) { + DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR failed.\n")); + goto err_exit; + } - if(!smb_io_rpc_auth_ntlmssp_neg("", &ntlmssp_neg, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_req: " - "Failed to unmarshall RPC_AUTH_NTLMSSP_NEG.\n")); - return setup_bind_nak(p); - } + /* + * Now add the RPC_HDR_BA and any auth needed. + */ - p->ntlmssp_chal_flags = SMBD_NTLMSSP_NEG_FLAGS; - p->ntlmssp_auth_requested = True; - break; + if(!prs_append_prs_data( &outgoing_rpc, &out_hdr_ba)) { + DEBUG(0,("api_pipe_bind_req: append of RPC_HDR_BA failed.\n")); + goto err_exit; + } - case NETSEC_AUTH_TYPE: - { - RPC_AUTH_NETSEC_NEG neg; - struct netsec_auth_struct *a = &(p->netsec_auth); + if (auth_len && !prs_append_prs_data( &outgoing_rpc, &out_auth)) { + DEBUG(0,("api_pipe_bind_req: append of auth info failed.\n")); + goto err_exit; + } - if (!server_auth2_negotiated) { - DEBUG(0, ("Attempt to bind using schannel " - "without successful serverauth2\n")); - return setup_bind_nak(p); - } + /* + * Setup the lengths for the initial reply. + */ - if (!smb_io_rpc_auth_netsec_neg("", &neg, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_req: " - "Could not unmarshal SCHANNEL auth neg\n")); - return setup_bind_nak(p); - } + p->out_data.data_sent_length = 0; + p->out_data.current_pdu_len = prs_offset(&outgoing_rpc); + p->out_data.current_pdu_sent = 0; - p->netsec_auth_validated = True; + prs_mem_free(&out_hdr_ba); + prs_mem_free(&out_auth); - memset(a->sess_key, 0, sizeof(a->sess_key)); - memcpy(a->sess_key, last_dcinfo.sess_key, sizeof(last_dcinfo.sess_key)); + return True; - a->seq_num = 0; + err_exit: - DEBUG(10,("schannel auth: domain [%s] myname [%s]\n", - neg.domain, neg.myname)); - break; - } + prs_mem_free(&outgoing_rpc); + prs_mem_free(&out_hdr_ba); + prs_mem_free(&out_auth); + return setup_bind_nak(p); +} - case SPNEGO_AUTH_TYPE: - default: - DEBUG(0,("api_pipe_bind_req: unknown auth type %x requested.\n", - auth_info.auth_type )); - return setup_bind_nak(p); - } - } +/**************************************************************************** + Deal with an alter context call. Can be third part of 3 leg auth request for + SPNEGO calls. +****************************************************************************/ - switch(p->hdr.pkt_type) { - case RPC_BIND: - /* name has to be \PIPE\xxxxx */ - fstrcpy(ack_pipe_name, "\\PIPE\\"); - fstrcat(ack_pipe_name, p->pipe_srv_name); - reply_pkt_type = RPC_BINDACK; - break; - case RPC_ALTCONT: - /* secondary address CAN be NULL - * as the specs say it's ignored. - * It MUST NULL to have the spoolss working. - */ - fstrcpy(ack_pipe_name,""); - reply_pkt_type = RPC_ALTCONTRESP; - break; - default: - return False; - } +BOOL api_pipe_alter_context(pipes_struct *p, prs_struct *rpc_in_p) +{ + RPC_HDR_BA hdr_ba; + RPC_HDR_RB hdr_rb; + RPC_HDR_AUTH auth_info; + uint16 assoc_gid; + fstring ack_pipe_name; + prs_struct out_hdr_ba; + prs_struct out_auth; + prs_struct outgoing_rpc; + int auth_len = 0; - DEBUG(5,("api_pipe_bind_req: make response. %d\n", __LINE__)); + prs_init( &outgoing_rpc, 0, p->mem_ctx, MARSHALL); /* * Marshall directly into the outgoing PDU space. We @@ -1035,7 +1666,6 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) * header and are never sending more than one PDU here. */ - prs_init( &outgoing_rpc, 0, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* @@ -1044,22 +1674,68 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) */ if(!prs_init(&out_hdr_ba, 1024, p->mem_ctx, MARSHALL)) { - DEBUG(0,("api_pipe_bind_req: malloc out_hdr_ba failed.\n")); + DEBUG(0,("api_pipe_alter_context: malloc out_hdr_ba failed.\n")); prs_mem_free(&outgoing_rpc); return False; } if(!prs_init(&out_auth, 1024, p->mem_ctx, MARSHALL)) { - DEBUG(0,("pi_pipe_bind_req: malloc out_auth failed.\n")); + DEBUG(0,("api_pipe_alter_context: malloc out_auth failed.\n")); prs_mem_free(&outgoing_rpc); prs_mem_free(&out_hdr_ba); return False; } - if (p->ntlmssp_auth_requested) - assoc_gid = 0x7a77; - else - assoc_gid = hdr_rb.bba.assoc_gid ? hdr_rb.bba.assoc_gid : 0x53f0; + DEBUG(5,("api_pipe_alter_context: decode request. %d\n", __LINE__)); + + /* decode the alter context request */ + if(!smb_io_rpc_hdr_rb("", &hdr_rb, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_alter_context: unable to unmarshall RPC_HDR_RB struct.\n")); + goto err_exit; + } + + /* secondary address CAN be NULL + * as the specs say it's ignored. + * It MUST be NULL to have the spoolss working. + */ + fstrcpy(ack_pipe_name,""); + + DEBUG(5,("api_pipe_alter_context: make response. %d\n", __LINE__)); + + /* + * Check if this is an authenticated alter context request. + */ + + if (p->hdr.auth_len != 0) { + /* + * Decode the authentication verifier. + */ + + if(!smb_io_rpc_hdr_auth("", &auth_info, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_alter_context: unable to unmarshall RPC_HDR_AUTH struct.\n")); + goto err_exit; + } + + /* + * Currently only the SPNEGO auth type uses the alter ctx + * response in place of the NTLMSSP auth3 type. + */ + + if (auth_info.auth_type == RPC_SPNEGO_AUTH_TYPE) { + /* We can only finish if the pipe is unbound. */ + if (!p->pipe_bound) { + if (!pipe_spnego_auth_bind_continue(p, rpc_in_p, &auth_info, &out_auth)) { + goto err_exit; + } + } else { + goto err_exit; + } + } + } else { + ZERO_STRUCT(auth_info); + } + + assoc_gid = hdr_rb.bba.assoc_gid ? hdr_rb.bba.assoc_gid : 0x53f0; /* * Create the bind response struct. @@ -1074,8 +1750,8 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) if(check_bind_req(p, &hdr_rb.rpc_context[0].abstract, &hdr_rb.rpc_context[0].transfer[0], hdr_rb.rpc_context[0].context_id )) { init_rpc_hdr_ba(&hdr_ba, - MAX_PDU_FRAG_LEN, - MAX_PDU_FRAG_LEN, + RPC_MAX_PDU_FRAG_LEN, + RPC_MAX_PDU_FRAG_LEN, assoc_gid, ack_pipe_name, 0x1, 0x0, 0x0, @@ -1084,10 +1760,11 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) RPC_IFACE null_interface; ZERO_STRUCT(null_interface); /* Rejection reason: abstract syntax not supported */ - init_rpc_hdr_ba(&hdr_ba, MAX_PDU_FRAG_LEN, - MAX_PDU_FRAG_LEN, assoc_gid, + init_rpc_hdr_ba(&hdr_ba, RPC_MAX_PDU_FRAG_LEN, + RPC_MAX_PDU_FRAG_LEN, assoc_gid, ack_pipe_name, 0x1, 0x2, 0x1, &null_interface); + p->pipe_bound = False; } /* @@ -1095,85 +1772,19 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) */ if(!smb_io_rpc_hdr_ba("", &hdr_ba, &out_hdr_ba, 0)) { - DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_BA failed.\n")); + DEBUG(0,("api_pipe_alter_context: marshalling of RPC_HDR_BA failed.\n")); goto err_exit; } /* - * Now the authentication. + * Create the header, now we know the length. */ - if (p->ntlmssp_auth_requested) { - RPC_AUTH_VERIFIER auth_verifier; - RPC_AUTH_NTLMSSP_CHAL ntlmssp_chal; - - generate_random_buffer(p->challenge, 8); - - /*** Authentication info ***/ - - init_rpc_hdr_auth(&auth_info, NTLMSSP_AUTH_TYPE, RPC_PIPE_AUTH_SEAL_LEVEL, RPC_HDR_AUTH_LEN, 1); - if(!smb_io_rpc_hdr_auth("", &auth_info, &out_auth, 0)) { - DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_AUTH failed.\n")); - goto err_exit; - } - - /*** NTLMSSP verifier ***/ - - init_rpc_auth_verifier(&auth_verifier, "NTLMSSP", NTLMSSP_CHALLENGE); - if(!smb_io_rpc_auth_verifier("", &auth_verifier, &out_auth, 0)) { - DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_VERIFIER failed.\n")); - goto err_exit; - } - - /* NTLMSSP challenge ***/ - - init_rpc_auth_ntlmssp_chal(&ntlmssp_chal, p->ntlmssp_chal_flags, p->challenge); - if(!smb_io_rpc_auth_ntlmssp_chal("", &ntlmssp_chal, &out_auth, 0)) { - DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_NTLMSSP_CHAL failed.\n")); - goto err_exit; - } - - /* Auth len in the rpc header doesn't include auth_header. */ - auth_len = prs_offset(&out_auth) - RPC_HDR_AUTH_LEN; - } - - if (p->netsec_auth_validated) { - RPC_AUTH_VERIFIER auth_verifier; - uint32 flags; - - /* The client opens a second RPC NETLOGON pipe without - doing a auth2. The credentials for the schannel are - re-used from the auth2 the client did before. */ - p->dc = last_dcinfo; - - init_rpc_hdr_auth(&auth_info, NETSEC_AUTH_TYPE, auth_info.auth_level, RPC_HDR_AUTH_LEN, 1); - if(!smb_io_rpc_hdr_auth("", &auth_info, &out_auth, 0)) { - DEBUG(0,("api_pipe_bind_req: marshalling of RPC_HDR_AUTH failed.\n")); - goto err_exit; - } - - /*** NETSEC verifier ***/ - - init_rpc_auth_verifier(&auth_verifier, "\001", 0x0); - if(!smb_io_rpc_netsec_verifier("", &auth_verifier, &out_auth, 0)) { - DEBUG(0,("api_pipe_bind_req: marshalling of RPC_AUTH_VERIFIER failed.\n")); - goto err_exit; - } - - prs_align(&out_auth); - - flags = 5; - if(!prs_uint32("flags ", &out_auth, 0, &flags)) - goto err_exit; - + if (prs_offset(&out_auth)) { auth_len = prs_offset(&out_auth) - RPC_HDR_AUTH_LEN; } - /* - * Create the header, now we know the length. - */ - - init_rpc_hdr(&p->hdr, reply_pkt_type, RPC_FLG_FIRST | RPC_FLG_LAST, + init_rpc_hdr(&p->hdr, RPC_ALTCONTRESP, RPC_FLG_FIRST | RPC_FLG_LAST, p->hdr.call_id, RPC_HEADER_LEN + prs_offset(&out_hdr_ba) + prs_offset(&out_auth), auth_len); @@ -1183,7 +1794,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) */ if(!smb_io_rpc_hdr("", &p->hdr, &outgoing_rpc, 0)) { - DEBUG(0,("pi_pipe_bind_req: marshalling of RPC_HDR failed.\n")); + DEBUG(0,("api_pipe_alter_context: marshalling of RPC_HDR failed.\n")); goto err_exit; } @@ -1192,19 +1803,15 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) */ if(!prs_append_prs_data( &outgoing_rpc, &out_hdr_ba)) { - DEBUG(0,("api_pipe_bind_req: append of RPC_HDR_BA failed.\n")); + DEBUG(0,("api_pipe_alter_context: append of RPC_HDR_BA failed.\n")); goto err_exit; } - if((p->ntlmssp_auth_requested|p->netsec_auth_validated) && - !prs_append_prs_data( &outgoing_rpc, &out_auth)) { - DEBUG(0,("api_pipe_bind_req: append of auth info failed.\n")); + if (auth_len && !prs_append_prs_data( &outgoing_rpc, &out_auth)) { + DEBUG(0,("api_pipe_alter_context: append of auth info failed.\n")); goto err_exit; } - if(!p->ntlmssp_auth_requested) - p->pipe_bound = True; - /* * Setup the lengths for the initial reply. */ @@ -1223,138 +1830,141 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) prs_mem_free(&outgoing_rpc); prs_mem_free(&out_hdr_ba); prs_mem_free(&out_auth); - return False; + return setup_bind_nak(p); } /**************************************************************************** - Deal with sign & seal processing on an RPC request. + Deal with NTLMSSP sign & seal processing on an RPC request. ****************************************************************************/ -BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in) +BOOL api_pipe_ntlmssp_auth_process(pipes_struct *p, prs_struct *rpc_in, + uint32 *p_ss_padding_len, NTSTATUS *pstatus) { - /* - * We always negotiate the following two bits.... - */ - BOOL auth_verify = ((p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SIGN) != 0); - BOOL auth_seal = ((p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SEAL) != 0); - int data_len; - int auth_len; - uint32 old_offset; - uint32 crc32 = 0; + RPC_HDR_AUTH auth_info; + uint32 auth_len = p->hdr.auth_len; + uint32 save_offset = prs_offset(rpc_in); + AUTH_NTLMSSP_STATE *a = p->auth.a_u.auth_ntlmssp_state; + unsigned char *data = NULL; + size_t data_len; + unsigned char *full_packet_data = NULL; + size_t full_packet_data_len; + DATA_BLOB auth_blob; + + *pstatus = NT_STATUS_OK; - auth_len = p->hdr.auth_len; + if (p->auth.auth_level == PIPE_AUTH_LEVEL_NONE || p->auth.auth_level == PIPE_AUTH_LEVEL_CONNECT) { + return True; + } + + if (!a) { + *pstatus = NT_STATUS_INVALID_PARAMETER; + return False; + } - if ((auth_len != RPC_AUTH_NTLMSSP_CHK_LEN) && auth_verify) { - DEBUG(0,("api_pipe_auth_process: Incorrect auth_len %d.\n", auth_len )); + /* Ensure there's enough data for an authenticated request. */ + if ((auth_len > RPC_MAX_SIGN_SIZE) || + (RPC_HEADER_LEN + RPC_HDR_REQ_LEN + RPC_HDR_AUTH_LEN + auth_len > p->hdr.frag_len)) { + DEBUG(0,("api_pipe_ntlmssp_auth_process: auth_len %u is too large.\n", + (unsigned int)auth_len )); + *pstatus = NT_STATUS_INVALID_PARAMETER; return False; } /* - * The following is that length of the data we must verify or unseal. - * This doesn't include the RPC headers or the auth_len or the RPC_HDR_AUTH_LEN - * preceeding the auth_data. + * We need the full packet data + length (minus auth stuff) as well as the packet data + length + * after the RPC header. + * We need to pass in the full packet (minus auth len) to the NTLMSSP sign and check seal + * functions as NTLMv2 checks the rpc headers also. */ - data_len = p->hdr.frag_len - RPC_HEADER_LEN - RPC_HDR_REQ_LEN - - (auth_verify ? RPC_HDR_AUTH_LEN : 0) - auth_len; - - DEBUG(5,("api_pipe_auth_process: sign: %s seal: %s data %d auth %d\n", - BOOLSTR(auth_verify), BOOLSTR(auth_seal), data_len, auth_len)); + data = (unsigned char *)(prs_data_p(rpc_in) + RPC_HDR_REQ_LEN); + data_len = (size_t)(p->hdr.frag_len - RPC_HEADER_LEN - RPC_HDR_REQ_LEN - RPC_HDR_AUTH_LEN - auth_len); - if (auth_seal) { - /* - * The data in rpc_in doesn't contain the RPC_HEADER as this - * has already been consumed. - */ - char *data = prs_data_p(rpc_in) + RPC_HDR_REQ_LEN; - dump_data_pw("NTLMSSP hash (v1)\n", p->ntlmssp_hash, - sizeof(p->ntlmssp_hash)); + full_packet_data = p->in_data.current_in_pdu; + full_packet_data_len = p->hdr.frag_len - auth_len; - dump_data_pw("Incoming RPC PDU (NTLMSSP sealed)\n", - (const unsigned char *)data, data_len); - NTLMSSPcalc_p(p, (uchar*)data, data_len); - dump_data_pw("Incoming RPC PDU (NTLMSSP unsealed)\n", - (const unsigned char *)data, data_len); - crc32 = crc32_calc_buffer(data, data_len); + /* Pull the auth header and the following data into a blob. */ + if(!prs_set_offset(rpc_in, RPC_HDR_REQ_LEN + data_len)) { + DEBUG(0,("api_pipe_ntlmssp_auth_process: cannot move offset to %u.\n", + (unsigned int)RPC_HDR_REQ_LEN + (unsigned int)data_len )); + *pstatus = NT_STATUS_INVALID_PARAMETER; + return False; } - old_offset = prs_offset(rpc_in); - - if (auth_seal || auth_verify) { - RPC_HDR_AUTH auth_info; - - if(!prs_set_offset(rpc_in, old_offset + data_len)) { - DEBUG(0,("api_pipe_auth_process: cannot move offset to %u.\n", - (unsigned int)old_offset + data_len )); - return False; - } - - if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, rpc_in, 0)) { - DEBUG(0,("api_pipe_auth_process: failed to unmarshall RPC_HDR_AUTH.\n")); - return False; - } + if(!smb_io_rpc_hdr_auth("hdr_auth", &auth_info, rpc_in, 0)) { + DEBUG(0,("api_pipe_ntlmssp_auth_process: failed to unmarshall RPC_HDR_AUTH.\n")); + *pstatus = NT_STATUS_INVALID_PARAMETER; + return False; } - if (auth_verify) { - RPC_AUTH_NTLMSSP_CHK ntlmssp_chk; - char *req_data = prs_data_p(rpc_in) + prs_offset(rpc_in) + 4; - - DEBUG(5,("api_pipe_auth_process: auth %d\n", prs_offset(rpc_in) + 4)); - - /* - * Ensure we have RPC_AUTH_NTLMSSP_CHK_LEN - 4 more bytes in the - * incoming buffer. - */ - if(prs_mem_get(rpc_in, RPC_AUTH_NTLMSSP_CHK_LEN - 4) == NULL) { - DEBUG(0,("api_pipe_auth_process: missing %d bytes in buffer.\n", - RPC_AUTH_NTLMSSP_CHK_LEN - 4 )); - return False; - } - - NTLMSSPcalc_p(p, (uchar*)req_data, RPC_AUTH_NTLMSSP_CHK_LEN - 4); - if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &ntlmssp_chk, rpc_in, 0)) { - DEBUG(0,("api_pipe_auth_process: failed to unmarshall RPC_AUTH_NTLMSSP_CHK.\n")); - return False; - } - - if (!rpc_auth_ntlmssp_chk(&ntlmssp_chk, crc32, p->ntlmssp_seq_num)) { - DEBUG(0,("api_pipe_auth_process: NTLMSSP check failed.\n")); + auth_blob.data = prs_data_p(rpc_in) + prs_offset(rpc_in); + auth_blob.length = auth_len; + + switch (p->auth.auth_level) { + case PIPE_AUTH_LEVEL_PRIVACY: + /* Data is encrypted. */ + *pstatus = ntlmssp_unseal_packet(a->ntlmssp_state, + data, data_len, + full_packet_data, + full_packet_data_len, + &auth_blob); + if (!NT_STATUS_IS_OK(*pstatus)) { + return False; + } + break; + case PIPE_AUTH_LEVEL_INTEGRITY: + /* Data is signed. */ + *pstatus = ntlmssp_check_packet(a->ntlmssp_state, + data, data_len, + full_packet_data, + full_packet_data_len, + &auth_blob); + if (!NT_STATUS_IS_OK(*pstatus)) { + return False; + } + break; + default: + *pstatus = NT_STATUS_INVALID_PARAMETER; return False; - } } /* * Return the current pointer to the data offset. */ - if(!prs_set_offset(rpc_in, old_offset)) { + if(!prs_set_offset(rpc_in, save_offset)) { DEBUG(0,("api_pipe_auth_process: failed to set offset back to %u\n", - (unsigned int)old_offset )); + (unsigned int)save_offset )); + *pstatus = NT_STATUS_INVALID_PARAMETER; return False; } + /* + * Remember the padding length. We must remove it from the real data + * stream once the sign/seal is done. + */ + + *p_ss_padding_len = auth_info.auth_pad_len; + return True; } /**************************************************************************** Deal with schannel processing on an RPC request. ****************************************************************************/ -BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) + +BOOL api_pipe_schannel_process(pipes_struct *p, prs_struct *rpc_in, uint32 *p_ss_padding_len) { - /* - * We always negotiate the following two bits.... - */ - int data_len; - int auth_len; - uint32 old_offset; + uint32 data_len; + uint32 auth_len; + uint32 save_offset = prs_offset(rpc_in); RPC_HDR_AUTH auth_info; - RPC_AUTH_NETSEC_CHK netsec_chk; - + RPC_AUTH_SCHANNEL_CHK schannel_chk; auth_len = p->hdr.auth_len; - if (auth_len != RPC_AUTH_NETSEC_SIGN_OR_SEAL_CHK_LEN) { - DEBUG(0,("Incorrect auth_len %d.\n", auth_len )); + if (auth_len != RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN) { + DEBUG(0,("Incorrect auth_len %u.\n", (unsigned int)auth_len )); return False; } @@ -1364,16 +1974,21 @@ BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) * preceeding the auth_data. */ + if (p->hdr.frag_len < RPC_HEADER_LEN + RPC_HDR_REQ_LEN + RPC_HDR_AUTH_LEN + auth_len) { + DEBUG(0,("Incorrect frag %u, auth %u.\n", + (unsigned int)p->hdr.frag_len, + (unsigned int)auth_len )); + return False; + } + data_len = p->hdr.frag_len - RPC_HEADER_LEN - RPC_HDR_REQ_LEN - RPC_HDR_AUTH_LEN - auth_len; DEBUG(5,("data %d auth %d\n", data_len, auth_len)); - old_offset = prs_offset(rpc_in); - - if(!prs_set_offset(rpc_in, old_offset + data_len)) { + if(!prs_set_offset(rpc_in, RPC_HDR_REQ_LEN + data_len)) { DEBUG(0,("cannot move offset to %u.\n", - (unsigned int)old_offset + data_len )); + (unsigned int)RPC_HDR_REQ_LEN + data_len )); return False; } @@ -1382,34 +1997,22 @@ BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) return False; } - if (auth_info.auth_type != NETSEC_AUTH_TYPE) { + if (auth_info.auth_type != RPC_SCHANNEL_AUTH_TYPE) { DEBUG(0,("Invalid auth info %d on schannel\n", auth_info.auth_type)); return False; } - if (auth_info.auth_level == RPC_PIPE_AUTH_SEAL_LEVEL) { - p->netsec_auth.auth_flags = AUTH_PIPE_NETSEC|AUTH_PIPE_SIGN|AUTH_PIPE_SEAL; - } else if (auth_info.auth_level == RPC_PIPE_AUTH_SIGN_LEVEL) { - p->netsec_auth.auth_flags = AUTH_PIPE_NETSEC|AUTH_PIPE_SIGN; - } else { - DEBUG(0,("Invalid auth level %d on schannel\n", - auth_info.auth_level)); - return False; - } - - if(!smb_io_rpc_auth_netsec_chk("", RPC_AUTH_NETSEC_SIGN_OR_SEAL_CHK_LEN, - &netsec_chk, rpc_in, 0)) - { - DEBUG(0,("failed to unmarshal RPC_AUTH_NETSEC_CHK.\n")); + if(!smb_io_rpc_auth_schannel_chk("", RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN, &schannel_chk, rpc_in, 0)) { + DEBUG(0,("failed to unmarshal RPC_AUTH_SCHANNEL_CHK.\n")); return False; } - if (!netsec_decode(&p->netsec_auth, - p->netsec_auth.auth_flags, + if (!schannel_decode(p->auth.a_u.schannel_auth, + p->auth.auth_level, SENDER_IS_INITIATOR, - &netsec_chk, - prs_data_p(rpc_in)+old_offset, data_len)) { + &schannel_chk, + prs_data_p(rpc_in)+RPC_HDR_REQ_LEN, data_len)) { DEBUG(3,("failed to decode PDU\n")); return False; } @@ -1418,14 +2021,21 @@ BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) * Return the current pointer to the data offset. */ - if(!prs_set_offset(rpc_in, old_offset)) { + if(!prs_set_offset(rpc_in, save_offset)) { DEBUG(0,("failed to set offset back to %u\n", - (unsigned int)old_offset )); + (unsigned int)save_offset )); return False; } /* The sequence number gets incremented on both send and receive. */ - p->netsec_auth.seq_num++; + p->auth.a_u.schannel_auth->seq_num++; + + /* + * Remember the padding length. We must remove it from the real data + * stream once the sign/seal is done. + */ + + *p_ss_padding_len = auth_info.auth_pad_len; return True; } @@ -1436,7 +2046,9 @@ BOOL api_pipe_netsec_process(pipes_struct *p, prs_struct *rpc_in) struct current_user *get_current_user(struct current_user *user, pipes_struct *p) { - if (p->ntlmssp_auth_validated) { + if (p->pipe_bound && + (p->auth.auth_type == PIPE_AUTH_TYPE_NTLMSSP || + (p->auth.auth_type == PIPE_AUTH_TYPE_SPNEGO_NTLMSSP))) { memcpy(user, &p->pipe_user, sizeof(struct current_user)); } else { memcpy(user, ¤t_user, sizeof(struct current_user)); @@ -1470,7 +2082,7 @@ static PIPE_RPC_FNS* find_pipe_fns_by_context( PIPE_RPC_FNS *list, uint32 contex } /**************************************************************************** - memory cleanup + Memory cleanup. ****************************************************************************/ void free_pipe_rpc_context( PIPE_RPC_FNS *list ) @@ -1496,14 +2108,17 @@ void free_pipe_rpc_context( PIPE_RPC_FNS *list ) BOOL api_pipe_request(pipes_struct *p) { BOOL ret = False; + BOOL changed_user = False; PIPE_RPC_FNS *pipe_fns; - if (p->ntlmssp_auth_validated) { - + if (p->pipe_bound && + ((p->auth.auth_type == PIPE_AUTH_TYPE_NTLMSSP) || + (p->auth.auth_type == PIPE_AUTH_TYPE_SPNEGO_NTLMSSP))) { if(!become_authenticated_pipe_user(p)) { prs_mem_free(&p->out_data.rdata); return False; } + changed_user = True; } DEBUG(5, ("Requested \\PIPE\\%s\n", p->name)); @@ -1522,8 +2137,9 @@ BOOL api_pipe_request(pipes_struct *p) p->hdr_req.context_id, p->name)); } - if(p->ntlmssp_auth_validated) + if (changed_user) { unbecome_authenticated_pipe_user(); + } return ret; } @@ -1649,6 +2265,9 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) case PI_EVENTLOG: eventlog_get_pipe_fns( &cmds, &n_cmds ); break; + case PI_NTSVCS: + ntsvcs_get_pipe_fns( &cmds, &n_cmds ); + break; #ifdef DEVELOPER case PI_ECHO: echo_get_pipe_fns( &cmds, &n_cmds ); @@ -1663,5 +2282,3 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) return; } - - diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 83b78f8d2f..205223190b 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -2,8 +2,8 @@ * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1998, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, - * Copyright (C) Jeremy Allison 1999. + * Largely re-written : 2005 + * Copyright (C) Jeremy Allison 1998 - 2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -106,10 +106,11 @@ static int pipe_handle_offset; void set_pipe_handle_offset(int max_open_files) { - if(max_open_files < 0x7000) - pipe_handle_offset = 0x7000; - else - pipe_handle_offset = max_open_files + 10; /* For safety. :-) */ + if(max_open_files < 0x7000) { + pipe_handle_offset = 0x7000; + } else { + pipe_handle_offset = max_open_files + 10; /* For safety. :-) */ + } } /**************************************************************************** @@ -128,8 +129,9 @@ void reset_chain_p(void) void init_rpc_pipe_hnd(void) { bmap = bitmap_allocate(MAX_OPEN_PIPES); - if (!bmap) + if (!bmap) { exit_server("out of memory in init_rpc_pipe_hnd"); + } } /**************************************************************************** @@ -154,7 +156,7 @@ static BOOL pipe_init_outgoing_data(pipes_struct *p) * Initialize the outgoing RPC data buffer. * we will use this as the raw data area for replying to rpc requests. */ - if(!prs_init(&o_data->rdata, MAX_PDU_FRAG_LEN, p->mem_ctx, MARSHALL)) { + if(!prs_init(&o_data->rdata, RPC_MAX_PDU_FRAG_LEN, p->mem_ctx, MARSHALL)) { DEBUG(0,("pipe_init_outgoing_data: malloc fail.\n")); return False; } @@ -177,8 +179,9 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, DEBUG(4,("Open pipe requested %s (pipes_open=%d)\n", pipe_name, pipes_open)); - if (strstr(pipe_name, "spoolss")) + if (strstr(pipe_name, "spoolss")) { is_spoolss_pipe = True; + } if (is_spoolss_pipe && current_spoolss_pipes_open >= MAX_OPEN_SPOOLSS_PIPES) { DEBUG(10,("open_rpc_pipe_p: spooler bug workaround. Denying open on pipe %s\n", @@ -189,8 +192,10 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, /* not repeating pipe numbers makes it easier to track things in log files and prevents client bugs where pipe numbers are reused over connection restarts */ - if (next_pipe == 0) + + if (next_pipe == 0) { next_pipe = (sys_getpid() ^ time(NULL)) % MAX_OPEN_PIPES; + } i = bitmap_find(bmap, next_pipe); @@ -201,8 +206,9 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, next_pipe = (i+1) % MAX_OPEN_PIPES; - for (p = Pipes; p; p = p->next) + for (p = Pipes; p; p = p->next) { DEBUG(5,("open_rpc_pipe_p: name %s pnum=%x\n", p->name, p->pnum)); + } p = SMB_MALLOC_P(smb_np_struct); if (!p) { @@ -259,8 +265,9 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, chain_p = p; /* Iterate over p_it as a temp variable, to display all open pipes */ - for (p_it = Pipes; p_it; p_it = p_it->next) + for (p_it = Pipes; p_it; p_it = p_it->next) { DEBUG(5,("open pipes: name %s pnum=%x\n", p_it->name, p_it->pnum)); + } return chain_p; } @@ -297,9 +304,17 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, return NULL; } + if ((p->pipe_state_mem_ctx = talloc_init("pipe_state %s %p", pipe_name, p)) == NULL) { + DEBUG(0,("open_rpc_pipe_p: talloc_init failed.\n")); + talloc_destroy(p->mem_ctx); + SAFE_FREE(p); + return NULL; + } + if (!init_pipe_handle_list(p, pipe_name)) { DEBUG(0,("open_rpc_pipe_p: init_pipe_handles failed.\n")); talloc_destroy(p->mem_ctx); + talloc_destroy(p->pipe_state_mem_ctx); SAFE_FREE(p); return NULL; } @@ -311,8 +326,10 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, * change the type to UNMARSALLING before processing the stream. */ - if(!prs_init(&p->in_data.data, MAX_PDU_FRAG_LEN, p->mem_ctx, MARSHALL)) { + if(!prs_init(&p->in_data.data, RPC_MAX_PDU_FRAG_LEN, p->mem_ctx, MARSHALL)) { DEBUG(0,("open_rpc_pipe_p: malloc fail for in_data struct.\n")); + talloc_destroy(p->mem_ctx); + talloc_destroy(p->pipe_state_mem_ctx); return NULL; } @@ -325,12 +342,6 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, p->vuid = vuid; - p->ntlmssp_chal_flags = 0; - p->ntlmssp_auth_validated = False; - p->ntlmssp_auth_requested = False; - - p->pipe_bound = False; - p->fault_state = False; p->endian = RPC_LITTLE_ENDIAN; ZERO_STRUCT(p->pipe_user); @@ -344,21 +355,6 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, p->pipe_user.nt_user_token = dup_nt_token(vuser->nt_user_token); } - /* - * Initialize the incoming RPC struct. - */ - - p->in_data.pdu_needed_len = 0; - p->in_data.pdu_received_len = 0; - - /* - * Initialize the outgoing RPC struct. - */ - - p->out_data.current_pdu_len = 0; - p->out_data.current_pdu_sent = 0; - p->out_data.data_sent_length = 0; - /* * Initialize the outgoing RPC data buffer with no memory. */ @@ -504,7 +500,7 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) * Ensure that the pdu length is sane. */ - if((p->hdr.frag_len < RPC_HEADER_LEN) || (p->hdr.frag_len > MAX_PDU_FRAG_LEN)) { + if((p->hdr.frag_len < RPC_HEADER_LEN) || (p->hdr.frag_len > RPC_MAX_PDU_FRAG_LEN)) { DEBUG(0,("unmarshall_rpc_header: assert on frag length failed.\n")); set_incoming_fault(p); prs_mem_free(&rpc_in); @@ -514,18 +510,8 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) DEBUG(10,("unmarshall_rpc_header: type = %u, flags = %u\n", (unsigned int)p->hdr.pkt_type, (unsigned int)p->hdr.flags )); - /* - * Adjust for the header we just ate. - */ - p->in_data.pdu_received_len = 0; p->in_data.pdu_needed_len = (uint32)p->hdr.frag_len - RPC_HEADER_LEN; - /* - * Null the data we just ate. - */ - - memset((char *)&p->in_data.current_in_pdu[0], '\0', RPC_HEADER_LEN); - prs_mem_free(&rpc_in); return 0; /* No extra data processed. */ @@ -540,12 +526,13 @@ static void free_pipe_context(pipes_struct *p) { if (p->mem_ctx) { DEBUG(3,("free_pipe_context: destroying talloc pool of size " - "%llu\n", talloc_total_size(p->mem_ctx) )); + "%lu\n", (unsigned long)talloc_total_size(p->mem_ctx) )); talloc_free_children(p->mem_ctx); } else { p->mem_ctx = talloc_init("pipe %s %p", p->name, p); - if (p->mem_ctx == NULL) + if (p->mem_ctx == NULL) { p->fault_state = True; + } } } @@ -556,9 +543,9 @@ static void free_pipe_context(pipes_struct *p) static BOOL process_request_pdu(pipes_struct *p, prs_struct *rpc_in_p) { - BOOL auth_verify = ((p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SIGN) != 0); + uint32 ss_padding_len = 0; size_t data_len = p->hdr.frag_len - RPC_HEADER_LEN - RPC_HDR_REQ_LEN - - (auth_verify ? RPC_HDR_AUTH_LEN : 0) - p->hdr.auth_len; + (p->hdr.auth_len ? RPC_HDR_AUTH_LEN : 0) - p->hdr.auth_len; if(!p->pipe_bound) { DEBUG(0,("process_request_pdu: rpc request with no bind.\n")); @@ -581,29 +568,40 @@ static BOOL process_request_pdu(pipes_struct *p, prs_struct *rpc_in_p) return False; } - if(p->ntlmssp_auth_validated && !api_pipe_auth_process(p, rpc_in_p)) { - DEBUG(0,("process_request_pdu: failed to do auth processing.\n")); - set_incoming_fault(p); - return False; - } + switch(p->auth.auth_type) { + case PIPE_AUTH_TYPE_NONE: + break; - if (p->ntlmssp_auth_requested && !p->ntlmssp_auth_validated) { + case PIPE_AUTH_TYPE_SPNEGO_NTLMSSP: + case PIPE_AUTH_TYPE_NTLMSSP: + { + NTSTATUS status; + if(!api_pipe_ntlmssp_auth_process(p, rpc_in_p, &ss_padding_len, &status)) { + DEBUG(0,("process_request_pdu: failed to do auth processing.\n")); + DEBUG(0,("process_request_pdu: error was %s.\n", nt_errstr(status) )); + set_incoming_fault(p); + return False; + } + break; + } - /* - * Authentication _was_ requested and it already failed. - */ + case PIPE_AUTH_TYPE_SCHANNEL: + if (!api_pipe_schannel_process(p, rpc_in_p, &ss_padding_len)) { + DEBUG(3,("process_request_pdu: failed to do schannel processing.\n")); + set_incoming_fault(p); + return False; + } + break; - DEBUG(0,("process_request_pdu: RPC request received on pipe %s " - "where authentication failed. Denying the request.\n", - p->name)); - set_incoming_fault(p); - return False; + default: + DEBUG(0,("process_request_pdu: unknown auth type %u set.\n", (unsigned int)p->auth.auth_type )); + set_incoming_fault(p); + return False; } - if (p->netsec_auth_validated && !api_pipe_netsec_process(p, rpc_in_p)) { - DEBUG(3,("process_request_pdu: failed to do schannel processing.\n")); - set_incoming_fault(p); - return False; + /* Now we've done the sign/seal we can remove any padding data. */ + if (data_len > ss_padding_len) { + data_len -= ss_padding_len; } /* @@ -643,8 +641,7 @@ static BOOL process_request_pdu(pipes_struct *p, prs_struct *rpc_in_p) * size as the current offset. */ - if(!prs_set_buffer_size(&p->in_data.data, prs_offset(&p->in_data.data))) - { + if(!prs_set_buffer_size(&p->in_data.data, prs_offset(&p->in_data.data))) { DEBUG(0,("process_request_pdu: Call to prs_set_buffer_size failed!\n")); set_incoming_fault(p); return False; @@ -664,8 +661,9 @@ static BOOL process_request_pdu(pipes_struct *p, prs_struct *rpc_in_p) free_pipe_context(p); - if(pipe_init_outgoing_data(p)) + if(pipe_init_outgoing_data(p)) { ret = api_pipe_request(p); + } free_pipe_context(p); @@ -690,11 +688,11 @@ static BOOL process_request_pdu(pipes_struct *p, prs_struct *rpc_in_p) already been parsed and stored in p->hdr. ****************************************************************************/ -static ssize_t process_complete_pdu(pipes_struct *p) +static void process_complete_pdu(pipes_struct *p) { prs_struct rpc_in; - size_t data_len = p->in_data.pdu_received_len; - char *data_p = (char *)&p->in_data.current_in_pdu[0]; + size_t data_len = p->in_data.pdu_received_len - RPC_HEADER_LEN; + char *data_p = (char *)&p->in_data.current_in_pdu[RPC_HEADER_LEN]; BOOL reply = False; if(p->fault_state) { @@ -702,7 +700,7 @@ static ssize_t process_complete_pdu(pipes_struct *p) p->name )); set_incoming_fault(p); setup_fault_pdu(p, NT_STATUS(0x1c010002)); - return (ssize_t)data_len; + return; } prs_init( &rpc_in, 0, p->mem_ctx, UNMARSHALL); @@ -722,19 +720,28 @@ static ssize_t process_complete_pdu(pipes_struct *p) switch (p->hdr.pkt_type) { case RPC_BIND: - case RPC_ALTCONT: /* * We assume that a pipe bind is only in one pdu. */ - if(pipe_init_outgoing_data(p)) + if(pipe_init_outgoing_data(p)) { reply = api_pipe_bind_req(p, &rpc_in); + } + break; + case RPC_ALTCONT: + /* + * We assume that a pipe bind is only in one pdu. + */ + if(pipe_init_outgoing_data(p)) { + reply = api_pipe_alter_context(p, &rpc_in); + } break; - case RPC_BINDRESP: + case RPC_AUTH3: /* - * We assume that a pipe bind_resp is only in one pdu. + * The third packet in an NTLMSSP auth exchange. */ - if(pipe_init_outgoing_data(p)) - reply = api_pipe_bind_auth_resp(p, &rpc_in); + if(pipe_init_outgoing_data(p)) { + reply = api_pipe_bind_auth3(p, &rpc_in); + } break; case RPC_REQUEST: reply = process_request_pdu(p, &rpc_in); @@ -761,7 +768,6 @@ static ssize_t process_complete_pdu(pipes_struct *p) } prs_mem_free(&rpc_in); - return (ssize_t)data_len; } /**************************************************************************** @@ -770,8 +776,7 @@ static ssize_t process_complete_pdu(pipes_struct *p) static ssize_t process_incoming_data(pipes_struct *p, char *data, size_t n) { - size_t data_to_copy = MIN(n, MAX_PDU_FRAG_LEN - p->in_data.pdu_received_len); - size_t old_pdu_received_len = p->in_data.pdu_received_len; + size_t data_to_copy = MIN(n, RPC_MAX_PDU_FRAG_LEN - p->in_data.pdu_received_len); DEBUG(10,("process_incoming_data: Start: pdu_received_len = %u, pdu_needed_len = %u, incoming data = %u\n", (unsigned int)p->in_data.pdu_received_len, (unsigned int)p->in_data.pdu_needed_len, @@ -812,8 +817,9 @@ incoming data size = %u\n", (unsigned int)p->in_data.pdu_received_len, (unsigned * data we need, then loop again. */ - if(p->in_data.pdu_needed_len == 0) + if(p->in_data.pdu_needed_len == 0) { return unmarshall_rpc_header(p); + } /* * Ok - at this point we have a valid RPC_HEADER in p->hdr. @@ -824,24 +830,27 @@ incoming data size = %u\n", (unsigned int)p->in_data.pdu_received_len, (unsigned /* * Copy as much of the data as we need into the current_in_pdu buffer. + * pdu_needed_len becomes zero when we have a complete pdu. */ memcpy( (char *)&p->in_data.current_in_pdu[p->in_data.pdu_received_len], data, data_to_copy); p->in_data.pdu_received_len += data_to_copy; + p->in_data.pdu_needed_len -= data_to_copy; /* * Do we have a complete PDU ? - * (return the nym of bytes handled in the call) + * (return the number of bytes handled in the call) */ - if(p->in_data.pdu_received_len == p->in_data.pdu_needed_len) - return process_complete_pdu(p) - old_pdu_received_len; + if(p->in_data.pdu_needed_len == 0) { + process_complete_pdu(p); + return data_to_copy; + } DEBUG(10,("process_incoming_data: not a complete PDU yet. pdu_received_len = %u, pdu_needed_len = %u\n", (unsigned int)p->in_data.pdu_received_len, (unsigned int)p->in_data.pdu_needed_len )); return (ssize_t)data_to_copy; - } /**************************************************************************** @@ -878,8 +887,9 @@ static ssize_t write_to_internal_pipe(void *np_conn, char *data, size_t n) DEBUG(10,("write_to_pipe: data_used = %d\n", (int)data_used )); - if(data_used < 0) + if(data_used < 0) { return -1; + } data_left -= data_used; data += data_used; @@ -948,9 +958,9 @@ static ssize_t read_from_internal_pipe(void *np_conn, char *data, size_t n, * authentications failing. Just ignore it so things work. */ - if(n > MAX_PDU_FRAG_LEN) { + if(n > RPC_MAX_PDU_FRAG_LEN) { 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 )); +pipe %s. We can only service %d sized reads.\n", (unsigned int)n, p->name, RPC_MAX_PDU_FRAG_LEN )); } /* @@ -1019,8 +1029,9 @@ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, BOOL wait_rpc_pipe_hnd_state(smb_np_struct *p, uint16 priority) { - if (p == NULL) + if (p == NULL) { return False; + } if (p->open) { DEBUG(3,("wait_rpc_pipe_hnd_state: Setting pipe wait state priority=%x on pipe (name=%s)\n", @@ -1043,8 +1054,9 @@ BOOL wait_rpc_pipe_hnd_state(smb_np_struct *p, uint16 priority) BOOL set_rpc_pipe_hnd_state(smb_np_struct *p, uint16 device_state) { - if (p == NULL) + if (p == NULL) { return False; + } if (p->open) { DEBUG(3,("set_rpc_pipe_hnd_state: Setting pipe device state=%x on pipe (name=%s)\n", @@ -1121,9 +1133,18 @@ static BOOL close_internal_rpc_pipe_hnd(void *np_conn) prs_mem_free(&p->out_data.rdata); prs_mem_free(&p->in_data.data); - if (p->mem_ctx) + if (p->auth.auth_data_free_func) { + (*p->auth.auth_data_free_func)(&p->auth); + } + + if (p->mem_ctx) { talloc_destroy(p->mem_ctx); - + } + + if (p->pipe_state_mem_ctx) { + talloc_destroy(p->pipe_state_mem_ctx); + } + free_pipe_rpc_context( p->contexts ); /* Free the handles database. */ @@ -1152,8 +1173,9 @@ smb_np_struct *get_rpc_pipe_p(char *buf, int where) { int pnum = SVAL(buf,where); - if (chain_p) + if (chain_p) { return chain_p; + } return get_rpc_pipe(pnum); } @@ -1168,9 +1190,10 @@ smb_np_struct *get_rpc_pipe(int pnum) DEBUG(4,("search for pipe pnum=%x\n", pnum)); - for (p=Pipes;p;p=p->next) + for (p=Pipes;p;p=p->next) { DEBUG(5,("pipe name %s pnum=%x (pipes_open=%d)\n", p->name, p->pnum, pipes_open)); + } for (p=Pipes;p;p=p->next) { if (p->pnum == pnum) { diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 871b1a9f12..1772524038 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -383,7 +383,7 @@ static BOOL api_reg_restore_key(pipes_struct *p) if(!reg_io_q_restore_key("", &q_u, data, 0)) return False; - + r_u.status = _reg_restore_key(p, &q_u, &r_u); if(!reg_io_r_restore_key("", &r_u, rdata, 0)) @@ -393,7 +393,7 @@ static BOOL api_reg_restore_key(pipes_struct *p) } /******************************************************************* - ******************************************************************/ + ********************************************************************/ static BOOL api_reg_save_key(pipes_struct *p) { @@ -416,6 +416,57 @@ static BOOL api_reg_save_key(pipes_struct *p) return True; } +/******************************************************************* + api_reg_open_hkpd + ********************************************************************/ + +static BOOL api_reg_open_hkpd(pipes_struct *p) +{ + REG_Q_OPEN_HIVE q_u; + REG_R_OPEN_HIVE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the reg open */ + if(!reg_io_q_open_hive("", &q_u, data, 0)) + return False; + + r_u.status = _reg_open_hkpd(p, &q_u, &r_u); + + if(!reg_io_r_open_hive("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + api_reg_open_hkpd + ********************************************************************/ +static BOOL api_reg_open_hkpt(pipes_struct *p) +{ + REG_Q_OPEN_HIVE q_u; + REG_R_OPEN_HIVE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the reg open */ + if(!reg_io_q_open_hive("", &q_u, data, 0)) + return False; + + r_u.status = _reg_open_hkpt(p, &q_u, &r_u); + + if(!reg_io_r_open_hive("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* ******************************************************************/ @@ -573,6 +624,8 @@ static struct api_struct api_reg_cmds[] = { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, { "REG_OPEN_HKCR" , REG_OPEN_HKCR , api_reg_open_hkcr }, { "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm }, + { "REG_OPEN_HKPD" , REG_OPEN_HKPD , api_reg_open_hkpd }, + { "REG_OPEN_HKPT" , REG_OPEN_HKPT , api_reg_open_hkpt }, { "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku }, { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key }, { "REG_ENUM_VALUE" , REG_ENUM_VALUE , api_reg_enum_value }, diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index a405948864..4db5ed0ed6 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -33,62 +33,9 @@ #define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ ((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) +static struct generic_mapping reg_generic_map = + { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; -static struct generic_mapping reg_generic_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; - -/******************************************************************** -********************************************************************/ - -NTSTATUS registry_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, - uint32 access_desired, uint32 *access_granted ) -{ - NTSTATUS result; - - if ( geteuid() == sec_initial_uid() ) { - DEBUG(5,("registry_access_check: access check bypassed for 'root'\n")); - *access_granted = REG_KEY_ALL; - return NT_STATUS_OK; - } - - se_map_generic( &access_desired, ®_generic_map ); - se_access_check( sec_desc, token, access_desired, access_granted, &result ); - - return result; -} - -/******************************************************************** -********************************************************************/ - -SEC_DESC* construct_registry_sd( TALLOC_CTX *ctx ) -{ - SEC_ACE ace[2]; - SEC_ACCESS mask; - size_t i = 0; - SEC_DESC *sd; - SEC_ACL *acl; - uint32 sd_size; - - /* basic access for Everyone */ - - init_sec_access(&mask, REG_KEY_READ ); - init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /* Full Access 'BUILTIN\Administrators' */ - - init_sec_access(&mask, REG_KEY_ALL ); - init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - - /* create the security descriptor */ - - if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) - return NULL; - - if ( !(sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, acl, &sd_size)) ) - return NULL; - - return sd; -} /****************************************************************** free() function for REGISTRY_KEY @@ -96,9 +43,7 @@ SEC_DESC* construct_registry_sd( TALLOC_CTX *ctx ) static void free_regkey_info(void *ptr) { - REGISTRY_KEY *info = (REGISTRY_KEY*)ptr; - - SAFE_FREE(info); + TALLOC_FREE( ptr ); } /****************************************************************** @@ -126,89 +71,38 @@ static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) HK[LM|U]\\\... *******************************************************************/ -static WERROR open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY *parent, - const char *subkeyname, uint32 access_granted ) +static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, + REGISTRY_KEY **keyinfo, REGISTRY_KEY *parent, + const char *subkeyname, uint32 access_desired ) { - REGISTRY_KEY *regkey = NULL; + pstring keypath; + int path_len; WERROR result = WERR_OK; - REGSUBKEY_CTR *subkeys = NULL; - pstring subkeyname2; - int subkey_len; - - DEBUG(7,("open_registry_key: name = [%s][%s]\n", - parent ? parent->name : "NULL", subkeyname)); - - /* strip any trailing '\'s */ - pstrcpy( subkeyname2, subkeyname ); - subkey_len = strlen ( subkeyname2 ); - if ( subkey_len && subkeyname2[subkey_len-1] == '\\' ) - subkeyname2[subkey_len-1] = '\0'; - if ((regkey=SMB_MALLOC_P(REGISTRY_KEY)) == NULL) - return WERR_NOMEM; - - ZERO_STRUCTP( regkey ); - - /* - * very crazy, but regedit.exe on Win2k will attempt to call - * REG_OPEN_ENTRY with a keyname of "". We should return a new - * (second) handle here on the key->name. regedt32.exe does - * not do this stupidity. --jerry - */ - - if ( !subkey_len ) { - pstrcpy( regkey->name, parent->name ); - } - else { - pstrcpy( regkey->name, "" ); - if ( parent ) { - pstrcat( regkey->name, parent->name ); - pstrcat( regkey->name, "\\" ); - } - pstrcat( regkey->name, subkeyname2 ); - } + /* create a full registry path and strip any trailing '\' + characters */ + + pstr_sprintf( keypath, "%s%s%s", + parent ? parent->name : "", + parent ? "\\" : "", + subkeyname ); - /* Look up the table of registry I/O operations */ - - if ( !(regkey->hook = reghook_cache_find( regkey->name )) ) { - DEBUG(0,("open_registry_key: Failed to assigned a REGISTRY_HOOK to [%s]\n", - regkey->name )); - result = WERR_BADFILE; - goto done; - } + path_len = strlen( keypath ); + if ( path_len && keypath[path_len-1] == '\\' ) + keypath[path_len-1] = '\0'; - /* check if the path really exists; failed is indicated by -1 */ - /* if the subkey count failed, bail out */ - - if ( !(subkeys = TALLOC_ZERO_P( p->mem_ctx, REGSUBKEY_CTR )) ) { - result = WERR_NOMEM; - goto done; - } - - if ( fetch_reg_keys( regkey, subkeys ) == -1 ) { - result = WERR_BADFILE; - goto done; - } + /* now do the internal open */ - if ( !create_policy_hnd( p, hnd, free_regkey_info, regkey ) ) { + result = regkey_open_internal( keyinfo, keypath, p->pipe_user.nt_user_token, access_desired ); + if ( !W_ERROR_IS_OK(result) ) + return result; + + if ( !create_policy_hnd( p, hnd, free_regkey_info, *keyinfo ) ) { result = WERR_BADFILE; - goto done; + TALLOC_FREE( *keyinfo ); } - /* save the access mask */ - - regkey->access_granted = access_granted; - -done: - /* clean up */ - - TALLOC_FREE( subkeys ); - - if ( ! NT_STATUS_IS_OK(result) ) - SAFE_FREE( regkey ); - DEBUG(7,("open_registry_key: exit\n")); - return result; } @@ -332,43 +226,39 @@ WERROR _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) WERROR _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) { - SEC_DESC *sec_desc; - uint32 access_granted = 0; - NTSTATUS status; + REGISTRY_KEY *keyinfo; - /* perform access checks */ - /* top level keys are done here without passing through the REGISTRY_HOOK api */ + return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKLM, q_u->access ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _reg_open_hkpd(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) +{ + REGISTRY_KEY *keyinfo; - if ( !(sec_desc = construct_registry_sd( p->mem_ctx )) ) - return WERR_NOMEM; - - status = registry_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); - if ( !NT_STATUS_IS_OK(status) ) - return ntstatus_to_werror( status ); - - return open_registry_key( p, &r_u->pol, NULL, KEY_HKLM, access_granted ); + return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKPD, q_u->access ); } /******************************************************************* ********************************************************************/ -WERROR _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) +WERROR _reg_open_hkpt(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) { - SEC_DESC *sec_desc; - uint32 access_granted = 0; - NTSTATUS status; + REGISTRY_KEY *keyinfo; - /* perform access checks */ - /* top level keys are done here without passing through the REGISTRY_HOOK api */ + return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKPT, q_u->access ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) +{ + REGISTRY_KEY *keyinfo; - if ( !(sec_desc = construct_registry_sd( p->mem_ctx )) ) - return WERR_NOMEM; - - status = registry_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); - if ( !NT_STATUS_IS_OK(status) ) - return ntstatus_to_werror( status ); - - return open_registry_key( p, &r_u->pol, NULL, KEY_HKCR, access_granted ); + return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKCR, q_u->access ); } /******************************************************************* @@ -376,21 +266,9 @@ WERROR _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_ WERROR _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) { - SEC_DESC *sec_desc; - uint32 access_granted = 0; - NTSTATUS status; - - /* perform access checks */ - /* top level keys are done here without passing through the REGISTRY_HOOK api */ + REGISTRY_KEY *keyinfo; - if ( !(sec_desc = construct_registry_sd( p->mem_ctx )) ) - return WERR_NOMEM; - - status = registry_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); - if ( !NT_STATUS_IS_OK(status) ) - return ntstatus_to_werror( status ); - - return open_registry_key( p, &r_u->pol, NULL, KEY_HKU, access_granted ); + return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKU, q_u->access ); } /******************************************************************* @@ -401,9 +279,8 @@ WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY { fstring name; REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->pol); - REGISTRY_KEY *newkey; - uint32 access_granted; - WERROR result; + REGISTRY_KEY *newkey = NULL; + uint32 check_rights; if ( !parent ) return WERR_BADFID; @@ -412,29 +289,22 @@ WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY /* check granted access first; what is the correct mask here? */ - if ( !(parent->access_granted & (SEC_RIGHTS_ENUM_SUBKEYS|SEC_RIGHTS_CREATE_SUBKEY|SEC_RIGHTS_QUERY_VALUE|SEC_RIGHTS_SET_VALUE)) ) + check_rights = ( SEC_RIGHTS_ENUM_SUBKEYS| + SEC_RIGHTS_CREATE_SUBKEY| + SEC_RIGHTS_QUERY_VALUE| + SEC_RIGHTS_SET_VALUE); + + if ( !(parent->access_granted & check_rights) ) return WERR_ACCESS_DENIED; - /* open the key first to get the appropriate REGISTRY_HOOK - and then check the premissions */ - - if ( !W_ERROR_IS_OK(result = open_registry_key( p, &r_u->handle, parent, name, 0 )) ) - return result; - - newkey = find_regkey_index_by_hnd(p, &r_u->handle); - - /* finally allow the backend to check the access for the requested key */ - - if ( !regkey_access_check( newkey, q_u->access, &access_granted, p->pipe_user.nt_user_token ) ) { - close_registry_key( p, &r_u->handle ); - return WERR_ACCESS_DENIED; - } - - /* if successful, save the granted access mask */ - - newkey->access_granted = access_granted; - - return WERR_OK; + /* + * very crazy, but regedit.exe on Win2k will attempt to call + * REG_OPEN_ENTRY with a keyname of "". We should return a new + * (second) handle here on the key->name. regedt32.exe does + * not do this stupidity. --jerry + */ + + return open_registry_key( p, &r_u->handle, &newkey, parent, name, q_u->access ); } /******************************************************************* @@ -454,16 +324,93 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL return WERR_BADFID; DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); + DEBUG(7,("_reg_info: policy key type = [%08x]\n", regkey->type)); rpcstr_pull(name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0); - DEBUG(5,("reg_info: looking up value: [%s]\n", name)); + DEBUG(5,("_reg_info: looking up value: [%s]\n", name)); if ( !(regvals = TALLOC_P( p->mem_ctx, REGVAL_CTR )) ) return WERR_NOMEM; - for ( i=0; fetch_reg_values_specific(regkey, &val, i); i++ ) + /* Handle QueryValue calls on HKEY_PERFORMANCE_DATA */ + if(regkey->type == REG_KEY_HKPD) + { + if(strequal(name, "Global")) + { + uint32 outbuf_len; + prs_struct prs_hkpd; + prs_init(&prs_hkpd, q_u->bufsize, p->mem_ctx, MARSHALL); + status = reg_perfcount_get_hkpd(&prs_hkpd, q_u->bufsize, &outbuf_len, NULL); + regval_ctr_addvalue(regvals, "HKPD", REG_BINARY, + prs_hkpd.data_p, outbuf_len); + val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); + prs_mem_free(&prs_hkpd); + } + else if(strequal(name, "Counter 009")) + { + uint32 base_index; + uint32 buffer_size; + char *buffer; + + buffer = NULL; + base_index = reg_perfcount_get_base_index(); + buffer_size = reg_perfcount_get_counter_names(base_index, &buffer); + regval_ctr_addvalue(regvals, "Counter 009", + REG_MULTI_SZ, buffer, buffer_size); + + val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); + + if(buffer_size > 0) + { + SAFE_FREE(buffer); + status = WERR_OK; + } + } + else if(strequal(name, "Explain 009")) + { + uint32 base_index; + uint32 buffer_size; + char *buffer; + + buffer = NULL; + base_index = reg_perfcount_get_base_index(); + buffer_size = reg_perfcount_get_counter_help(base_index, &buffer); + regval_ctr_addvalue(regvals, "Explain 009", + REG_MULTI_SZ, buffer, buffer_size); + + val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); + + if(buffer_size > 0) + { + SAFE_FREE(buffer); + status = WERR_OK; + } + } + else if(isdigit(name[0])) + { + /* we probably have a request for a specific object here */ + uint32 outbuf_len; + prs_struct prs_hkpd; + prs_init(&prs_hkpd, q_u->bufsize, p->mem_ctx, MARSHALL); + status = reg_perfcount_get_hkpd(&prs_hkpd, q_u->bufsize, &outbuf_len, name); + regval_ctr_addvalue(regvals, "HKPD", REG_BINARY, + prs_hkpd.data_p, outbuf_len); + + val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); + prs_mem_free(&prs_hkpd); + } + else + { + DEBUG(3,("Unsupported key name [%s] for HKPD.\n", name)); + return WERR_BADFILE; + } + } + /* HKPT calls can be handled out of reg_dynamic.c with the hkpt_params handler */ + else { + for ( i=0; fetch_reg_values_specific(regkey, &val, i); i++ ) + { DEBUG(10,("_reg_info: Testing value [%s]\n", val->valuename)); if ( strequal( val->valuename, name ) ) { DEBUG(10,("_reg_info: Found match for value [%s]\n", name)); @@ -472,6 +419,7 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL } free_registry_value( val ); + } } init_reg_r_query_value(q_u->ptr_buf, r_u, val, status); @@ -482,7 +430,6 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL return status; } - /***************************************************************************** Implementation of REG_QUERY_KEY ****************************************************************************/ @@ -998,7 +945,7 @@ static WERROR make_default_reg_sd( TALLOC_CTX *ctx, SEC_DESC **psd ) SEC_ACE ace[2]; /* at most 2 entries */ SEC_ACCESS mask; SEC_ACL *psa = NULL; - uint32 sd_size; + size_t sd_size; /* set the owner to BUILTIN\Administrator */ @@ -1092,7 +1039,7 @@ WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) WERROR _reg_create_key_ex(pipes_struct *p, REG_Q_CREATE_KEY_EX *q_u, REG_R_CREATE_KEY_EX *r_u) { REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->handle); - REGISTRY_KEY *newparent; + REGISTRY_KEY *newparentinfo, *keyinfo; POLICY_HND newparent_handle; REGSUBKEY_CTR *subkeys; BOOL write_result; @@ -1109,7 +1056,6 @@ WERROR _reg_create_key_ex(pipes_struct *p, REG_Q_CREATE_KEY_EX *q_u, REG_R_CREAT if ( strrchr( name, '\\' ) ) { pstring newkeyname; char *ptr; - uint32 access_granted; /* (1) check for enumerate rights on the parent handle. CLients can try create things like 'SOFTWARE\Samba' on the HKLM handle. @@ -1122,19 +1068,11 @@ WERROR _reg_create_key_ex(pipes_struct *p, REG_Q_CREATE_KEY_EX *q_u, REG_R_CREAT ptr = strrchr( newkeyname, '\\' ); *ptr = '\0'; - result = open_registry_key( p, &newparent_handle, parent, newkeyname, 0 ); + result = open_registry_key( p, &newparent_handle, &newparentinfo, + parent, newkeyname, (REG_KEY_READ|REG_KEY_WRITE) ); + if ( !W_ERROR_IS_OK(result) ) return result; - - newparent = find_regkey_index_by_hnd(p, &newparent_handle); - SMB_ASSERT( newparent != NULL ); - - if ( !regkey_access_check( newparent, REG_KEY_READ|REG_KEY_WRITE, &access_granted, p->pipe_user.nt_user_token ) ) { - result = WERR_ACCESS_DENIED; - goto done; - } - - newparent->access_granted = access_granted; /* copy the new key name (just the lower most keyname) */ @@ -1142,13 +1080,13 @@ WERROR _reg_create_key_ex(pipes_struct *p, REG_Q_CREATE_KEY_EX *q_u, REG_R_CREAT } else { /* use the existing open key information */ - newparent = parent; + newparentinfo = parent; memcpy( &newparent_handle, &q_u->handle, sizeof(POLICY_HND) ); } /* (3) check for create subkey rights on the correct parent */ - if ( !(newparent->access_granted & SEC_RIGHTS_CREATE_SUBKEY) ) { + if ( !(newparentinfo->access_granted & SEC_RIGHTS_CREATE_SUBKEY) ) { result = WERR_ACCESS_DENIED; goto done; } @@ -1160,12 +1098,12 @@ WERROR _reg_create_key_ex(pipes_struct *p, REG_Q_CREATE_KEY_EX *q_u, REG_R_CREAT /* (4) lookup the current keys and add the new one */ - fetch_reg_keys( newparent, subkeys ); + fetch_reg_keys( newparentinfo, subkeys ); regsubkey_ctr_addkey( subkeys, name ); /* now write to the registry backend */ - write_result = store_reg_keys( newparent, subkeys ); + write_result = store_reg_keys( newparentinfo, subkeys ); TALLOC_FREE( subkeys ); @@ -1173,16 +1111,15 @@ WERROR _reg_create_key_ex(pipes_struct *p, REG_Q_CREATE_KEY_EX *q_u, REG_R_CREAT return WERR_REG_IO_FAILURE; /* (5) open the new key and return the handle. Note that it is probably - not correct to grant full access on this open handle. We should pass - the new open through the regkey_access_check() like we do for - _reg_open_entry() but this is ok for now. */ + not correct to grant full access on this open handle. */ - result = open_registry_key( p, &r_u->handle, newparent, name, REG_KEY_ALL ); + result = open_registry_key( p, &r_u->handle, &keyinfo, newparentinfo, name, REG_KEY_READ ); + keyinfo->access_granted = REG_KEY_ALL; done: /* close any intermediate key handles */ - if ( newparent != parent ) + if ( newparentinfo != parent ) close_registry_key( p, &newparent_handle ); return result; @@ -1243,7 +1180,7 @@ WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY *r_u) { REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->handle); - REGISTRY_KEY *newparent; + REGISTRY_KEY *newparentinfo; POLICY_HND newparent_handle; REGSUBKEY_CTR *subkeys; BOOL write_result; @@ -1252,6 +1189,15 @@ WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY if ( !parent ) return WERR_BADFID; + + /* MSDN says parent the handle must have been opened with DELETE access */ + + /* (1) check for delete rights on the parent */ + + if ( !(parent->access_granted & STD_RIGHT_DELETE_ACCESS) ) { + result = WERR_ACCESS_DENIED; + goto done; + } rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); @@ -1260,50 +1206,24 @@ WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY if ( strrchr( name, '\\' ) ) { pstring newkeyname; char *ptr; - uint32 access_granted; - /* (1) check for enumerate rights on the parent handle. CLients can try - create things like 'SOFTWARE\Samba' on the HKLM handle. - (2) open the path to the child parent key if necessary */ + /* (2) open the path to the child parent key if necessary */ + /* split the registry path and save the subkeyname */ - if ( !(parent->access_granted & SEC_RIGHTS_ENUM_SUBKEYS) ) - return WERR_ACCESS_DENIED; - pstrcpy( newkeyname, name ); ptr = strrchr( newkeyname, '\\' ); *ptr = '\0'; + pstrcpy( name, ptr+1 ); - result = open_registry_key( p, &newparent_handle, parent, newkeyname, 0 ); + result = open_registry_key( p, &newparent_handle, &newparentinfo, parent, newkeyname, (REG_KEY_READ|REG_KEY_WRITE) ); if ( !W_ERROR_IS_OK(result) ) return result; - - newparent = find_regkey_index_by_hnd(p, &newparent_handle); - SMB_ASSERT( newparent != NULL ); - - if ( !regkey_access_check( newparent, REG_KEY_READ|REG_KEY_WRITE, &access_granted, p->pipe_user.nt_user_token ) ) { - result = WERR_ACCESS_DENIED; - goto done; - } - - newparent->access_granted = access_granted; - - /* copy the new key name (just the lower most keyname) */ - - pstrcpy( name, ptr+1 ); } else { /* use the existing open key information */ - newparent = parent; - memcpy( &newparent_handle, &q_u->handle, sizeof(POLICY_HND) ); + newparentinfo = parent; } - /* (3) check for create subkey rights on the correct parent */ - - if ( !(newparent->access_granted & STD_RIGHT_DELETE_ACCESS) ) { - result = WERR_ACCESS_DENIED; - goto done; - } - if ( !(subkeys = TALLOC_ZERO_P( p->mem_ctx, REGSUBKEY_CTR )) ) { result = WERR_NOMEM; goto done; @@ -1311,13 +1231,13 @@ WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY /* lookup the current keys and delete the new one */ - fetch_reg_keys( newparent, subkeys ); + fetch_reg_keys( newparentinfo, subkeys ); regsubkey_ctr_delkey( subkeys, name ); /* now write to the registry backend */ - write_result = store_reg_keys( newparent, subkeys ); + write_result = store_reg_keys( newparentinfo, subkeys ); TALLOC_FREE( subkeys ); @@ -1326,7 +1246,7 @@ WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY done: /* close any intermediate key handles */ - if ( newparent != parent ) + if ( newparentinfo != parent ) close_registry_key( p, &newparent_handle ); return result; @@ -1414,5 +1334,3 @@ WERROR _reg_set_key_sec(pipes_struct *p, REG_Q_SET_KEY_SEC *q_u, REG_R_SET_KEY_ return WERR_ACCESS_DENIED; } - - diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 656241a73f..b69f03a3a2 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -6,7 +6,7 @@ * Copyright (C) Paul Ashton 1997, * Copyright (C) Marc Jacobsen 1999, * Copyright (C) Jeremy Allison 2001-2002, - * Copyright (C) Jean François Micouleau 1998-2001, + * Copyright (C) Jean François Micouleau 1998-2001, * Copyright (C) Jim McDonough 2002, * Copyright (C) Gerald (Jerry) Carter 2003-2004, * Copyright (C) Simo Sorce 2003. @@ -88,17 +88,17 @@ static NTSTATUS make_samr_object_sd( TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd SEC_ACL *psa = NULL; /* basic access for Everyone */ - + init_sec_access(&mask, map->generic_execute | map->generic_read ); init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - + /* add Full Access 'BUILTIN\Administrators' and 'BUILTIN\Account Operators */ - + init_sec_access(&mask, map->generic_all); init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); init_sec_ace(&ace[i++], &global_sid_Builtin_Account_Operators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - + /* Add Full Access for Domain Admins if we are a DC */ if ( IS_DC ) { @@ -108,14 +108,14 @@ static NTSTATUS make_samr_object_sd( TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd } /* if we have a sid, give it some special access */ - + if ( sid ) { init_sec_access( &mask, sid_access ); init_sec_ace(&ace[i++], sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - } - +} + /* create the security descriptor */ - + if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) == NULL) return NT_STATUS_NO_MEMORY; @@ -347,7 +347,7 @@ NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN uint32 acc_granted; uint32 des_access = q_u->flags; NTSTATUS status; - size_t sd_size; + size_t sd_size; SE_PRIV se_rights; r_u->status = NT_STATUS_OK; @@ -421,7 +421,6 @@ NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, return r_u->status; } - /******************************************************************* _samr_set_sec_obj ********************************************************************/ @@ -1456,11 +1455,13 @@ static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_ BOOL ret; NTSTATUS nt_status; - if (!p->ntlmssp_auth_validated) + if (p->auth.auth_type != PIPE_AUTH_TYPE_NTLMSSP || p->auth.auth_type != PIPE_AUTH_TYPE_SPNEGO_NTLMSSP) { return NT_STATUS_ACCESS_DENIED; + } - if (!(p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SIGN) || !(p->ntlmssp_chal_flags & NTLMSSP_NEGOTIATE_SEAL)) + if (p->auth.auth_level != PIPE_AUTH_LEVEL_PRIVACY) { return NT_STATUS_ACCESS_DENIED; + } /* * Do *NOT* do become_root()/unbecome_root() here ! JRA. @@ -1794,11 +1795,12 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA time_t u_lock_duration, u_reset_time; NTTIME nt_lock_duration, nt_reset_time; uint32 lockout; - time_t u_logout; NTTIME nt_logout; uint32 account_policy_temp; + + time_t seq_num; uint32 server_role; uint32 num_users=0, num_groups=0, num_aliases=0; @@ -1819,19 +1821,19 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA switch (q_u->switch_value) { case 0x01: - account_policy_get(AP_MIN_PASSWORD_LEN, &account_policy_temp); + pdb_get_account_policy(AP_MIN_PASSWORD_LEN, &account_policy_temp); min_pass_len = account_policy_temp; - account_policy_get(AP_PASSWORD_HISTORY, &account_policy_temp); + pdb_get_account_policy(AP_PASSWORD_HISTORY, &account_policy_temp); pass_hist = account_policy_temp; - account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); + pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); flag = account_policy_temp; - account_policy_get(AP_MAX_PASSWORD_AGE, &account_policy_temp); + pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &account_policy_temp); u_expire = account_policy_temp; - account_policy_get(AP_MIN_PASSWORD_AGE, &account_policy_temp); + pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &account_policy_temp); u_min_age = account_policy_temp; unix_to_nt_time_abs(&nt_expire, u_expire); @@ -1847,21 +1849,23 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA num_groups=count_sam_groups(&info->disp_info); unbecome_root(); - account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); + pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); u_logout = account_policy_temp; unix_to_nt_time_abs(&nt_logout, u_logout); + if (!pdb_get_seq_num(&seq_num)) + seq_num = time(NULL); + server_role = ROLE_DOMAIN_PDC; if (lp_server_role() == ROLE_DOMAIN_BDC) server_role = ROLE_DOMAIN_BDC; - /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, lp_serverstring(), lp_workgroup(), global_myname(), time(NULL), + init_unk_info2(&ctr->info.inf2, lp_serverstring(), lp_workgroup(), global_myname(), seq_num, num_users, num_groups, num_aliases, nt_logout, server_role); break; case 0x03: - account_policy_get(AP_TIME_TO_LOGOUT, (unsigned int *)&u_logout); + pdb_get_account_policy(AP_TIME_TO_LOGOUT, (unsigned int *)&u_logout); unix_to_nt_time_abs(&nt_logout, u_logout); init_unk_info3(&ctr->info.inf3, nt_logout); @@ -1880,18 +1884,21 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA init_unk_info7(&ctr->info.inf7, server_role); break; case 0x08: - init_unk_info8(&ctr->info.inf8, (uint32) time(NULL)); + if (!pdb_get_seq_num(&seq_num)) + seq_num = time(NULL); + + init_unk_info8(&ctr->info.inf8, (uint32) seq_num); break; case 0x0c: - account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); + pdb_get_account_policy(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); u_lock_duration = account_policy_temp; if (u_lock_duration != -1) u_lock_duration *= 60; - account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp); + pdb_get_account_policy(AP_RESET_COUNT_TIME, &account_policy_temp); u_reset_time = account_policy_temp * 60; - account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); + pdb_get_account_policy(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); lockout = account_policy_temp; unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); @@ -1955,7 +1962,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA rpcstr_pull(account, user_account.buffer, sizeof(account), user_account.uni_str_len*2, 0); strlower_m(account); - + pdb_init_sam(&sam_pass); become_root(); @@ -1968,7 +1975,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA } pdb_free_sam(&sam_pass); - + /********************************************************************* * HEADS UP! If we have to create a new user account, we have to get * a new RID from somewhere. This used to be done by the passdb @@ -1979,7 +1986,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA * of what ever passdb backend people may use. * --jerry (2003-07-10) *********************************************************************/ - + pw = Get_Pwnam(account); /* determine which user right we need to check based on the acb_info */ @@ -2005,27 +2012,27 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA /* only Domain Admins can add a BDC or domain trust */ se_priv_copy( &se_rights, &se_priv_none ); can_add_account = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); - } } - + } + DEBUG(5, ("_samr_create_user: %s can add this account : %s\n", p->pipe_user_name, can_add_account ? "True":"False" )); /********** BEGIN Admin BLOCK **********/ - + if ( can_add_account ) become_root(); - + if ( !pw ) { if (*add_script) { - int add_ret; - - all_string_sub(add_script, "%u", account, sizeof(add_script)); - add_ret = smbrun(add_script,NULL); - DEBUG(add_ret ? 0 : 3,("_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); - } + int add_ret; + + all_string_sub(add_script, "%u", account, sizeof(add_script)); + add_ret = smbrun(add_script,NULL); + DEBUG(add_ret ? 0 : 3,("_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); + } } - + /* implicit call to getpwnam() next. we have a valid SID coming out of this call */ flush_pwnam_cache(); @@ -2147,7 +2154,7 @@ NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u uint32 acc_granted; uint32 des_access = q_u->access_mask; NTSTATUS nt_status; - size_t sd_size; + size_t sd_size; DEBUG(5,("_samr_connect: %d\n", __LINE__)); @@ -2198,7 +2205,7 @@ NTSTATUS _samr_connect4(pipes_struct *p, SAMR_Q_CONNECT4 *q_u, SAMR_R_CONNECT4 * uint32 acc_granted; uint32 des_access = q_u->access_mask; NTSTATUS nt_status; - size_t sd_size; + size_t sd_size; DEBUG(5,("_samr_connect4: %d\n", __LINE__)); @@ -2734,7 +2741,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo"))) { return r_u->status; } - + DEBUG(5, ("_samr_set_userinfo: sid:%s, level:%d\n", sid_string_static(&sid), switch_value)); if (ctr == NULL) { @@ -2765,7 +2772,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE if ( lp_enable_privileges() ) has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); } - + DEBUG(5, ("_samr_set_userinfo: %s does%s possess sufficient rights\n", p->pipe_user_name, has_enough_rights ? "" : " not")); @@ -2905,7 +2912,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ if ( lp_enable_privileges() ) has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); } - + DEBUG(5, ("_samr_set_userinfo: %s does%s possess sufficient rights\n", p->pipe_user_name, has_enough_rights ? "" : " not")); @@ -3597,7 +3604,7 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S gid=map.gid; /* check if group really exists */ - if ( (grp=getgrgid(gid)) == NULL) + if ( (grp=getgrgid(gid)) == NULL) return NT_STATUS_NO_SUCH_GROUP; se_priv_copy( &se_rights, &se_add_users ); @@ -4195,6 +4202,8 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW uint32 num_users=0, num_groups=0, num_aliases=0; uint32 account_policy_temp; + + time_t seq_num; uint32 server_role; if ((ctr = TALLOC_ZERO_P(p->mem_ctx, SAM_UNK_CTR)) == NULL) @@ -4212,19 +4221,19 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW switch (q_u->switch_value) { case 0x01: - account_policy_get(AP_MIN_PASSWORD_LEN, &account_policy_temp); + pdb_get_account_policy(AP_MIN_PASSWORD_LEN, &account_policy_temp); min_pass_len = account_policy_temp; - account_policy_get(AP_PASSWORD_HISTORY, &account_policy_temp); + pdb_get_account_policy(AP_PASSWORD_HISTORY, &account_policy_temp); pass_hist = account_policy_temp; - account_policy_get(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); + pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); flag = account_policy_temp; - account_policy_get(AP_MAX_PASSWORD_AGE, &account_policy_temp); + pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &account_policy_temp); u_expire = account_policy_temp; - account_policy_get(AP_MIN_PASSWORD_AGE, &account_policy_temp); + pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &account_policy_temp); u_min_age = account_policy_temp; unix_to_nt_time_abs(&nt_expire, u_expire); @@ -4242,21 +4251,23 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW free_samr_db(info); - account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); + pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); u_logout = account_policy_temp; unix_to_nt_time_abs(&nt_logout, u_logout); + if (!pdb_get_seq_num(&seq_num)) + seq_num = time(NULL); + server_role = ROLE_DOMAIN_PDC; if (lp_server_role() == ROLE_DOMAIN_BDC) server_role = ROLE_DOMAIN_BDC; - /* The time call below is to get a sequence number for the sam. FIXME !!! JRA. */ - init_unk_info2(&ctr->info.inf2, lp_serverstring(), lp_workgroup(), global_myname(), time(NULL), + init_unk_info2(&ctr->info.inf2, lp_serverstring(), lp_workgroup(), global_myname(), seq_num, num_users, num_groups, num_aliases, nt_logout, server_role); break; case 0x03: - account_policy_get(AP_TIME_TO_LOGOUT, &account_policy_temp); + pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); u_logout = account_policy_temp; unix_to_nt_time_abs(&nt_logout, u_logout); @@ -4273,21 +4284,25 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW server_role = ROLE_DOMAIN_PDC; if (lp_server_role() == ROLE_DOMAIN_BDC) server_role = ROLE_DOMAIN_BDC; + init_unk_info7(&ctr->info.inf7, server_role); break; case 0x08: - init_unk_info8(&ctr->info.inf8, (uint32) time(NULL)); + if (!pdb_get_seq_num(&seq_num)) + seq_num = time(NULL); + + init_unk_info8(&ctr->info.inf8, (uint32) seq_num); break; case 0x0c: - account_policy_get(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); + pdb_get_account_policy(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); u_lock_duration = account_policy_temp; if (u_lock_duration != -1) u_lock_duration *= 60; - account_policy_get(AP_RESET_COUNT_TIME, &account_policy_temp); + pdb_get_account_policy(AP_RESET_COUNT_TIME, &account_policy_temp); u_reset_time = account_policy_temp * 60; - account_policy_get(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); + pdb_get_account_policy(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); lockout = account_policy_temp; unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); @@ -4331,17 +4346,17 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R u_expire=nt_time_to_unix_abs(&q_u->ctr->info.inf1.expire); u_min_age=nt_time_to_unix_abs(&q_u->ctr->info.inf1.min_passwordage); - account_policy_set(AP_MIN_PASSWORD_LEN, (uint32)q_u->ctr->info.inf1.min_length_password); - account_policy_set(AP_PASSWORD_HISTORY, (uint32)q_u->ctr->info.inf1.password_history); - account_policy_set(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)q_u->ctr->info.inf1.flag); - account_policy_set(AP_MAX_PASSWORD_AGE, (int)u_expire); - account_policy_set(AP_MIN_PASSWORD_AGE, (int)u_min_age); + pdb_set_account_policy(AP_MIN_PASSWORD_LEN, (uint32)q_u->ctr->info.inf1.min_length_password); + pdb_set_account_policy(AP_PASSWORD_HISTORY, (uint32)q_u->ctr->info.inf1.password_history); + pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)q_u->ctr->info.inf1.flag); + pdb_set_account_policy(AP_MAX_PASSWORD_AGE, (int)u_expire); + pdb_set_account_policy(AP_MIN_PASSWORD_AGE, (int)u_min_age); break; case 0x02: break; case 0x03: u_logout=nt_time_to_unix_abs(&q_u->ctr->info.inf3.logout); - account_policy_set(AP_TIME_TO_LOGOUT, (int)u_logout); + pdb_set_account_policy(AP_TIME_TO_LOGOUT, (int)u_logout); break; case 0x05: break; @@ -4356,9 +4371,9 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R u_reset_time=nt_time_to_unix_abs(&q_u->ctr->info.inf12.reset_count)/60; - account_policy_set(AP_LOCK_ACCOUNT_DURATION, (int)u_lock_duration); - account_policy_set(AP_RESET_COUNT_TIME, (int)u_reset_time); - account_policy_set(AP_BAD_ATTEMPT_LOCKOUT, (uint32)q_u->ctr->info.inf12.bad_attempt_lockout); + pdb_set_account_policy(AP_LOCK_ACCOUNT_DURATION, (int)u_lock_duration); + pdb_set_account_policy(AP_RESET_COUNT_TIME, (int)u_reset_time); + pdb_set_account_policy(AP_BAD_ATTEMPT_LOCKOUT, (uint32)q_u->ctr->info.inf12.bad_attempt_lockout); break; default: return NT_STATUS_INVALID_INFO_CLASS; diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 24869d5d2b..1d9a8ecd1d 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -291,7 +291,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) uint32 expire; time_t new_time; if (pdb_get_pass_must_change_time(to) == 0) { - if (!account_policy_get(AP_MAX_PASSWORD_AGE, &expire) + if (!pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &expire) || expire == (uint32)-1) { new_time = get_time_t_max(); } else { @@ -531,7 +531,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) uint32 expire; time_t new_time; if (pdb_get_pass_must_change_time(to) == 0) { - if (!account_policy_get(AP_MAX_PASSWORD_AGE, &expire) + if (!pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &expire) || expire == (uint32)-1) { new_time = get_time_t_max(); } else { diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cda3f26137..5233d6c252 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -75,7 +75,7 @@ typedef struct _counter_printer_0 { static counter_printer_0 *counter_list; -static struct cli_state notify_cli; /* print notify back-channel */ +static struct rpc_pipe_client *notify_cli_pipe; /* print notify back-channel pipe handle*/ static uint32 smb_connections=0; @@ -166,7 +166,7 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle) return; } - result = cli_spoolss_reply_close_printer(¬ify_cli, notify_cli.mem_ctx, handle); + result = rpccli_spoolss_reply_close_printer(notify_cli_pipe, notify_cli_pipe->cli->mem_ctx, handle); if (!W_ERROR_IS_OK(result)) DEBUG(0,("srv_spoolss_replycloseprinter: reply_close_printer failed [%s].\n", @@ -174,9 +174,8 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle) /* if it's the last connection, deconnect the IPC$ share */ if (smb_connections==1) { - cli_nt_session_close(¬ify_cli); - cli_ulogoff(¬ify_cli); - cli_shutdown(¬ify_cli); + cli_shutdown(notify_cli_pipe->cli); + notify_cli_pipe = NULL; /* The above call shuts downn the pipe also. */ message_deregister(MSG_PRINTER_NOTIFY2); /* Tell the connections db we're no longer interested in @@ -688,7 +687,7 @@ static void notify_system_time(struct spoolss_notify_msg *msg, return; } - if (!prs_init(&ps, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL)) { + if (!prs_init(&ps, RPC_MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL)) { DEBUG(5, ("notify_system_time: prs_init() failed\n")); return; } @@ -1021,7 +1020,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) } if ( sending_msg_count ) { - cli_spoolss_rrpcn( ¬ify_cli, mem_ctx, &p->notify.client_hnd, + rpccli_spoolss_rrpcn( notify_cli_pipe, mem_ctx, &p->notify.client_hnd, data_len, data, p->notify.change, 0 ); } } @@ -1075,7 +1074,8 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, voi Receive a notify2 message list ********************************************************************/ -static void receive_notify2_message_list(int msg_type, pid_t src, void *msg, size_t len) +static void receive_notify2_message_list(int msg_type, struct process_id src, + void *msg, size_t len) { size_t msg_count, i; char *buf = (char *)msg; @@ -1176,7 +1176,8 @@ static BOOL srv_spoolss_drv_upgrade_printer(char* drivername) DEBUG(10,("srv_spoolss_drv_upgrade_printer: Sending message about driver upgrade [%s]\n", drivername)); - message_send_pid(sys_getpid(), MSG_PRINTER_DRVUPGRADE, drivername, len+1, False); + message_send_pid(pid_to_procid(sys_getpid()), + MSG_PRINTER_DRVUPGRADE, drivername, len+1, False); return True; } @@ -1186,7 +1187,7 @@ static BOOL srv_spoolss_drv_upgrade_printer(char* drivername) over all printers, upgrading ones as necessary **********************************************************************/ -void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len) +void do_drv_upgrade_printer(int msg_type, struct process_id src, void *buf, size_t len) { fstring drivername; int snum; @@ -1272,7 +1273,8 @@ static BOOL srv_spoolss_reset_printerdata(char* drivername) DEBUG(10,("srv_spoolss_reset_printerdata: Sending message about resetting printerdata [%s]\n", drivername)); - message_send_pid(sys_getpid(), MSG_PRINTERDATA_INIT_RESET, drivername, len+1, False); + message_send_pid(pid_to_procid(sys_getpid()), + MSG_PRINTERDATA_INIT_RESET, drivername, len+1, False); return True; } @@ -1282,7 +1284,8 @@ static BOOL srv_spoolss_reset_printerdata(char* drivername) over all printers, resetting printer data as neessary **********************************************************************/ -void reset_all_printerdata(int msg_type, pid_t src, void *buf, size_t len) +void reset_all_printerdata(int msg_type, struct process_id src, + void *buf, size_t len) { fstring drivername; int snum; @@ -2001,7 +2004,10 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER /* this should not have failed---if it did, report to client */ if ( !W_ERROR_IS_OK(status_win2k) ) + { + status = status_win2k; goto done; + } } } @@ -2479,9 +2485,10 @@ done: Connect to the client machine. **********************************************************/ -static BOOL spoolss_connect_to_client(struct cli_state *the_cli, +static BOOL spoolss_connect_to_client(struct cli_state *the_cli, struct rpc_pipe_client **pp_pipe, struct in_addr *client_ip, const char *remote_machine) { + NTSTATUS ret; ZERO_STRUCTP(the_cli); if(cli_initialise(the_cli) == NULL) { @@ -2563,10 +2570,10 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, * Now start the NT Domain stuff :-). */ - if(cli_nt_session_open(the_cli, PI_SPOOLSS) == False) { - DEBUG(0,("spoolss_connect_to_client: unable to open the domain client session to machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli))); - cli_nt_session_close(the_cli); - cli_ulogoff(the_cli); + *pp_pipe = cli_rpc_pipe_open_noauth(the_cli, PI_SPOOLSS, &ret); + if(!*pp_pipe) { + DEBUG(0,("spoolss_connect_to_client: unable to open the spoolss pipe on machine %s. Error was : %s.\n", + remote_machine, nt_errstr(ret))); cli_shutdown(the_cli); return False; } @@ -2589,13 +2596,14 @@ static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, * and connect to the IPC$ share anonymously */ if (smb_connections==0) { + struct cli_state notify_cli; /* print notify back-channel */ fstring unix_printer; fstrcpy(unix_printer, printer+2); /* the +2 is to strip the leading 2 backslashs */ ZERO_STRUCT(notify_cli); - if(!spoolss_connect_to_client(¬ify_cli, client_ip, unix_printer)) + if(!spoolss_connect_to_client(¬ify_cli, ¬ify_cli_pipe, client_ip, unix_printer)) return False; message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message_list); @@ -2614,7 +2622,7 @@ static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, smb_connections++; - result = cli_spoolss_reply_open_printer(¬ify_cli, notify_cli.mem_ctx, printer, localprinter, + result = rpccli_spoolss_reply_open_printer(notify_cli_pipe, notify_cli_pipe->cli->mem_ctx, printer, localprinter, type, handle); if (!W_ERROR_IS_OK(result)) @@ -6117,17 +6125,12 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, || !strequal(printer->info_2->portname, old_printer->info_2->portname) || !strequal(printer->info_2->location, old_printer->info_2->location)) ) { + /* add_printer_hook() will call reload_services() */ + if ( !add_printer_hook(p->pipe_user.nt_user_token, printer) ) { result = WERR_ACCESS_DENIED; goto done; } - - /* - * make sure we actually reload the services after - * this as smb.conf could have a new section in it - * .... shouldn't .... but could - */ - reload_services(False); } /* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index e9dd015421..9643b2a724 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -113,7 +113,8 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int sn What to do when smb.conf is updated. ********************************************************************/ -static void smb_conf_updated(int msg_type, pid_t src, void *buf, size_t len) +static void smb_conf_updated(int msg_type, struct process_id src, + void *buf, size_t len) { DEBUG(10,("smb_conf_updated: Got message saying smb.conf was updated. Reloading.\n")); reload_services(False); @@ -1394,7 +1395,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES become_root(); } - if (message_send_pid(session_list[snum].pid, MSG_SHUTDOWN, NULL, 0, False)) + if (message_send_pid(pid_to_procid(session_list[snum].pid), MSG_SHUTDOWN, NULL, 0, False)) r_u->status = WERR_OK; if (not_root) diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 6ba26414d3..31d8bbe9b3 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -309,24 +309,76 @@ static BOOL api_svcctl_query_service_config2(pipes_struct *p) return True; } +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_lock_service_db(pipes_struct *p) +{ + SVCCTL_Q_LOCK_SERVICE_DB q_u; + SVCCTL_R_LOCK_SERVICE_DB r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_lock_service_db("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_lock_service_db(p, &q_u, &r_u); + + if(!svcctl_io_r_lock_service_db("", &r_u, rdata, 0)) + return False; + + return True; +} + + +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_unlock_service_db(pipes_struct *p) +{ + SVCCTL_Q_UNLOCK_SERVICE_DB q_u; + SVCCTL_R_UNLOCK_SERVICE_DB r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_unlock_service_db("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_unlock_service_db(p, &q_u, &r_u); + + if(!svcctl_io_r_unlock_service_db("", &r_u, rdata, 0)) + return False; + + return True; +} + + /******************************************************************* \PIPE\svcctl commands ********************************************************************/ static struct api_struct api_svcctl_cmds[] = { - { "SVCCTL_CLOSE_SERVICE" , SVCCTL_CLOSE_SERVICE , api_svcctl_close_service }, - { "SVCCTL_OPEN_SCMANAGER_W" , SVCCTL_OPEN_SCMANAGER_W , api_svcctl_open_scmanager }, - { "SVCCTL_OPEN_SERVICE_W" , SVCCTL_OPEN_SERVICE_W , api_svcctl_open_service }, - { "SVCCTL_GET_DISPLAY_NAME" , SVCCTL_GET_DISPLAY_NAME , api_svcctl_get_display_name }, - { "SVCCTL_QUERY_STATUS" , SVCCTL_QUERY_STATUS , api_svcctl_query_status }, - { "SVCCTL_QUERY_SERVICE_CONFIG_W", SVCCTL_QUERY_SERVICE_CONFIG_W, api_svcctl_query_service_config }, - { "SVCCTL_QUERY_SERVICE_CONFIG2_W", SVCCTL_QUERY_SERVICE_CONFIG2_W, api_svcctl_query_service_config2 }, - { "SVCCTL_ENUM_SERVICES_STATUS_W", SVCCTL_ENUM_SERVICES_STATUS_W, api_svcctl_enum_services_status }, - { "SVCCTL_ENUM_DEPENDENT_SERVICES_W", SVCCTL_ENUM_DEPENDENT_SERVICES_W, api_svcctl_enum_dependent_services }, - { "SVCCTL_START_SERVICE_W" , SVCCTL_START_SERVICE_W , api_svcctl_start_service }, - { "SVCCTL_CONTROL_SERVICE" , SVCCTL_CONTROL_SERVICE , api_svcctl_control_service }, - { "SVCCTL_QUERY_SERVICE_STATUSEX_W", SVCCTL_QUERY_SERVICE_STATUSEX_W, api_svcctl_query_service_status_ex } + { "SVCCTL_CLOSE_SERVICE" , SVCCTL_CLOSE_SERVICE , api_svcctl_close_service }, + { "SVCCTL_OPEN_SCMANAGER_W" , SVCCTL_OPEN_SCMANAGER_W , api_svcctl_open_scmanager }, + { "SVCCTL_OPEN_SERVICE_W" , SVCCTL_OPEN_SERVICE_W , api_svcctl_open_service }, + { "SVCCTL_GET_DISPLAY_NAME" , SVCCTL_GET_DISPLAY_NAME , api_svcctl_get_display_name }, + { "SVCCTL_QUERY_STATUS" , SVCCTL_QUERY_STATUS , api_svcctl_query_status }, + { "SVCCTL_QUERY_SERVICE_CONFIG_W" , SVCCTL_QUERY_SERVICE_CONFIG_W , api_svcctl_query_service_config }, + { "SVCCTL_QUERY_SERVICE_CONFIG2_W" , SVCCTL_QUERY_SERVICE_CONFIG2_W , api_svcctl_query_service_config2 }, + { "SVCCTL_ENUM_SERVICES_STATUS_W" , SVCCTL_ENUM_SERVICES_STATUS_W , api_svcctl_enum_services_status }, + { "SVCCTL_ENUM_DEPENDENT_SERVICES_W" , SVCCTL_ENUM_DEPENDENT_SERVICES_W , api_svcctl_enum_dependent_services }, + { "SVCCTL_START_SERVICE_W" , SVCCTL_START_SERVICE_W , api_svcctl_start_service }, + { "SVCCTL_CONTROL_SERVICE" , SVCCTL_CONTROL_SERVICE , api_svcctl_control_service }, + { "SVCCTL_QUERY_SERVICE_STATUSEX_W" , SVCCTL_QUERY_SERVICE_STATUSEX_W , api_svcctl_query_service_status_ex }, + { "SVCCTL_LOCK_SERVICE_DB" , SVCCTL_LOCK_SERVICE_DB , api_svcctl_lock_service_db }, + { "SVCCTL_UNLOCK_SERVICE_DB" , SVCCTL_UNLOCK_SERVICE_DB , api_svcctl_unlock_service_db } }; diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 538b97a2b1..e8df2acb22 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -1,8 +1,11 @@ /* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines - * Copyright (C) Gerald (Jerry) Carter 2005, + * * Copyright (C) Marcin Krzysztof Porwit 2005. + * + * Largely Rewritten (Again) by: + * Copyright (C) Gerald (Jerry) Carter 2005. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,51 +22,97 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* TODO - Do the OpenService service name matching case-independently, or at least make it an option. */ - - #include "includes.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -#define SERVICEDB_VERSION_V1 1 /* Will there be more? */ -#define INTERNAL_SERVICES_LIST "NETLOGON Spooler" - -/* */ -/* scripts will execute from the following libdir, if they are in the enable svcctl= */ -/* these should likely be symbolic links. Note that information about them will be extracted from the files themselves */ -/* using the LSB standard keynames for various information */ - -#define SVCCTL_SCRIPT_DIR "/svcctl/" - - -struct service_control_op_table { +struct service_control_op { const char *name; SERVICE_CONTROL_OPS *ops; }; extern SERVICE_CONTROL_OPS spoolss_svc_ops; +extern SERVICE_CONTROL_OPS rcinit_svc_ops; +extern SERVICE_CONTROL_OPS netlogon_svc_ops; +extern SERVICE_CONTROL_OPS winreg_svc_ops; -struct service_control_op_table svcctl_ops[] = { - { "Spooler", &spoolss_svc_ops }, - { "NETLOGON", NULL }, - { NULL, NULL } -}; +struct service_control_op *svcctl_ops; + +static struct generic_mapping scm_generic_map = + { SC_MANAGER_READ_ACCESS, SC_MANAGER_WRITE_ACCESS, SC_MANAGER_EXECUTE_ACCESS, SC_MANAGER_ALL_ACCESS }; +static struct generic_mapping svc_generic_map = + { SERVICE_READ_ACCESS, SERVICE_WRITE_ACCESS, SERVICE_EXECUTE_ACCESS, SERVICE_ALL_ACCESS }; /******************************************************************** ********************************************************************/ +BOOL init_service_op_table( void ) +{ + const char **service_list = lp_svcctl_list(); + int num_services = 3 + str_list_count( service_list ); + int i; + + if ( !(svcctl_ops = TALLOC_ARRAY( NULL, struct service_control_op, num_services+1)) ) { + DEBUG(0,("init_service_op_table: talloc() failed!\n")); + return False; + } + + /* services listed in smb.conf get the rc.init interface */ + + for ( i=0; service_list[i]; i++ ) { + svcctl_ops[i].name = talloc_strdup( svcctl_ops, service_list[i] ); + svcctl_ops[i].ops = &rcinit_svc_ops; + } + + /* add builtin services */ + + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "Spooler" ); + svcctl_ops[i].ops = &spoolss_svc_ops; + i++; + + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "NETLOGON" ); + svcctl_ops[i].ops = &netlogon_svc_ops; + i++; + + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "RemoteRegistry" ); + svcctl_ops[i].ops = &winreg_svc_ops; + i++; + + /* NULL terminate the array */ + + svcctl_ops[i].name = NULL; + svcctl_ops[i].ops = NULL; + + return True; +} + +/******************************************************************** +********************************************************************/ + +static struct service_control_op* find_service_by_name( const char *name ) +{ + int i; + + for ( i=0; svcctl_ops[i].name; i++ ) { + if ( strequal( name, svcctl_ops[i].name ) ) + return &svcctl_ops[i]; + } + + return NULL; +} +/******************************************************************** +********************************************************************/ + static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, uint32 access_desired, uint32 *access_granted ) { NTSTATUS result; if ( geteuid() == sec_initial_uid() ) { - DEBUG(5,("svcctl_access_check: access check bypassed for 'root'\n")); - *access_granted = access_desired; - return NT_STATUS_OK; + DEBUG(5,("svcctl_access_check: using root's token\n")); + token = get_root_nt_token(); } se_access_check( sec_desc, token, access_desired, access_granted, &result ); @@ -81,7 +130,7 @@ static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx ) size_t i = 0; SEC_DESC *sd; SEC_ACL *acl; - uint32 sd_size; + size_t sd_size; /* basic access for Everyone */ @@ -105,51 +154,13 @@ static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx ) return sd; } -/******************************************************************** -********************************************************************/ - -static SEC_DESC* construct_service_sd( TALLOC_CTX *ctx ) -{ - SEC_ACE ace[4]; - SEC_ACCESS mask; - size_t i = 0; - SEC_DESC *sd; - SEC_ACL *acl; - uint32 sd_size; - - /* basic access for Everyone */ - - init_sec_access(&mask, SERVICE_READ_ACCESS ); - init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - init_sec_access(&mask,SERVICE_EXECUTE_ACCESS ); - init_sec_ace(&ace[i++], &global_sid_Builtin_Power_Users, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - init_sec_access(&mask,SERVICE_ALL_ACCESS ); - init_sec_ace(&ace[i++], &global_sid_Builtin_Server_Operators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /* create the security descriptor */ - - if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) - return NULL; - - if ( !(sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, acl, &sd_size)) ) - return NULL; - - return sd; -} - /****************************************************************** free() function for REGISTRY_KEY *****************************************************************/ static void free_service_handle_info(void *ptr) { - SERVICE_INFO *info = (SERVICE_INFO*)ptr; - - SAFE_FREE(info->name); - SAFE_FREE(info); + TALLOC_FREE( ptr ); } /****************************************************************** @@ -171,44 +182,50 @@ static SERVICE_INFO *find_service_info_by_hnd(pipes_struct *p, POLICY_HND *hnd) /****************************************************************** *****************************************************************/ -static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, +static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, uint32 type, const char *service, uint32 access_granted ) { SERVICE_INFO *info = NULL; WERROR result = WERR_OK; + struct service_control_op *s_op; - if ( !(info = SMB_MALLOC_P( SERVICE_INFO )) ) + if ( !(info = TALLOC_ZERO_P( NULL, SERVICE_INFO )) ) return WERR_NOMEM; - ZERO_STRUCTP( info ); - /* the Service Manager has a NULL name */ - if ( !service ) { + info->type = SVC_HANDLE_IS_SCM; + + switch ( type ) { + case SVC_HANDLE_IS_SCM: info->type = SVC_HANDLE_IS_SCM; - } else { - int i; + break; + case SVC_HANDLE_IS_DBLOCK: + info->type = SVC_HANDLE_IS_DBLOCK; + break; + + case SVC_HANDLE_IS_SERVICE: info->type = SVC_HANDLE_IS_SERVICE; /* lookup the SERVICE_CONTROL_OPS */ - for ( i=0; svcctl_ops[i].name; i++ ) { - if ( strequal( svcctl_ops[i].name, service ) ) { - info->ops = svcctl_ops[i].ops; - break; - } - } - - if ( !svcctl_ops[i].name ) { + if ( !(s_op = find_service_by_name( service )) ) { result = WERR_NO_SUCH_SERVICE; goto done; } + + info->ops = s_op->ops; - if ( !(info->name = SMB_STRDUP( service )) ) { + if ( !(info->name = talloc_strdup( info, s_op->name )) ) { result = WERR_NOMEM; goto done; } + break; + + default: + result = WERR_NO_SUCH_SERVICE; + goto done; } info->access_granted = access_granted; @@ -241,11 +258,12 @@ WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVC if ( !(sec_desc = construct_scm_sd( p->mem_ctx )) ) return WERR_NOMEM; + se_map_generic( &q_u->access, &scm_generic_map ); status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); if ( !NT_STATUS_IS_OK(status) ) return ntstatus_to_werror( status ); - return create_open_service_handle( p, &r_u->handle, NULL, access_granted ); + return create_open_service_handle( p, &r_u->handle, SVC_HANDLE_IS_SCM, NULL, access_granted ); } /******************************************************************** @@ -268,21 +286,18 @@ WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_ if ( !find_service_info_by_hnd( p, &q_u->handle ) ) return WERR_BADFID; - /* perform access checks */ + /* perform access checks. Use the root token in order to ensure that we + retreive the security descriptor */ - if ( !(sec_desc = construct_service_sd( p->mem_ctx )) ) + if ( !(sec_desc = svcctl_get_secdesc( p->mem_ctx, service, get_root_nt_token() )) ) return WERR_NOMEM; + se_map_generic( &q_u->access, &svc_generic_map ); status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); if ( !NT_STATUS_IS_OK(status) ) return ntstatus_to_werror( status ); - -#if 0 /* FIXME!!! */ - if ( ! get_service_info(service_tdb, service, info) ) { - return WERR_NO_SUCH_SERVICE; -#endif - return create_open_service_handle( p, &r_u->handle, service, access_granted ); + return create_open_service_handle( p, &r_u->handle, SVC_HANDLE_IS_SERVICE, service, access_granted ); } /******************************************************************** @@ -299,7 +314,7 @@ WERROR _svcctl_close_service(pipes_struct *p, SVCCTL_Q_CLOSE_SERVICE *q_u, SVCCT WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, SVCCTL_R_GET_DISPLAY_NAME *r_u) { fstring service; - fstring displayname; + const char *display_name; SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); /* can only use an SCM handle here */ @@ -308,12 +323,9 @@ WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, return WERR_BADFID; rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); - - /* need a tdb lookup here or something */ - fstrcpy( displayname, "FIX ME!" ); - - init_svcctl_r_get_display_name( r_u, displayname ); + display_name = svcctl_lookup_dispname( service, p->pipe_user.nt_user_token ); + init_svcctl_r_get_display_name( r_u, display_name ); return WERR_OK; } @@ -335,87 +347,40 @@ WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_ /* try the service specific status call */ - if ( info->ops ) - return info->ops->service_status( &r_u->svc_status ); - - /* default action for now */ - - r_u->svc_status.type = 0x0020; - r_u->svc_status.state = 0x0004; - r_u->svc_status.controls_accepted = 0x0005; - - return WERR_OK; + return info->ops->service_status( info->name, &r_u->svc_status ); } +/******************************************************************** +********************************************************************/ -/********************************************************************* - TODO - for internal services, do similar to external services, except - we have to call the right status routine... -**********************************************************************/ - -static WERROR enum_internal_services(TALLOC_CTX *ctx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services, uint32 *added) +static int enumerate_status( TALLOC_CTX *ctx, ENUM_SERVICES_STATUS **status, NT_USER_TOKEN *token ) { - int num_services = 2; - int i = 0; - ENUM_SERVICES_STATUS *services=NULL; - - if (!svc_ptr || !(*svc_ptr)) - return WERR_NOMEM; - - services = *svc_ptr; - - if ( (existing_services > 0) && svc_ptr && *svc_ptr ) { - ENUM_SERVICES_STATUS *tmp_services = NULL; - uint32 total_svc = existing_services + num_services; - - if ( !(tmp_services = TALLOC_REALLOC_ARRAY( ctx, services, ENUM_SERVICES_STATUS, total_svc )) ) - return WERR_NOMEM; - - services = tmp_services; - i += existing_services; - } - else { - if ( !(services = TALLOC_ARRAY( ctx, ENUM_SERVICES_STATUS, num_services )) ) - return WERR_NOMEM; + int num_services = 0; + int i; + ENUM_SERVICES_STATUS *st; + const char *display_name; + + /* just count */ + while ( svcctl_ops[num_services].name ) + num_services++; + + if ( !(st = TALLOC_ARRAY( ctx, ENUM_SERVICES_STATUS, num_services )) ) { + DEBUG(0,("enumerate_status: talloc() failed!\n")); + return -1; } - - DEBUG(8,("enum_internal_services: Creating %d services, starting index %d\n", - num_services, existing_services)); - - init_unistr( &services[i].servicename, "Spooler" ); - init_unistr( &services[i].displayname, "Print Spooler" ); - - services[i].status.type = 0x110; - services[i].status.controls_accepted = 0x0; - services[i].status.win32_exit_code = 0x0; - services[i].status.service_exit_code = 0x0; - services[i].status.check_point = 0x0; - services[i].status.wait_hint = 0x0; - if ( !lp_disable_spoolss() ) - services[i].status.state = SVCCTL_RUNNING; - else - services[i].status.state = SVCCTL_STOPPED; - - i++; - init_unistr( &services[i].servicename, "NETLOGON" ); - init_unistr( &services[i].displayname, "Net Logon" ); + for ( i=0; iservice_status( svcctl_ops[i].name, &st[i].status ); + } - services[i].status.type = 0x20; - services[i].status.controls_accepted = 0x0; - services[i].status.win32_exit_code = 0x0; - services[i].status.service_exit_code = 0x0; - services[i].status.check_point = 0x0; - services[i].status.wait_hint = 0x0; - if ( lp_servicenumber("NETLOGON") != -1 ) - services[i].status.state = SVCCTL_RUNNING; - else - services[i].status.state = SVCCTL_STOPPED; - - *added = num_services; - *svc_ptr = services; + *status = st; - return WERR_OK; + return num_services; } /******************************************************************** @@ -424,11 +389,12 @@ static WERROR enum_internal_services(TALLOC_CTX *ctx,ENUM_SERVICES_STATUS **svc_ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, SVCCTL_R_ENUM_SERVICES_STATUS *r_u) { ENUM_SERVICES_STATUS *services = NULL; - uint32 num_int_services, num_ext_services, total_services; + uint32 num_services; int i = 0; size_t buffer_size = 0; WERROR result = WERR_OK; SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + NT_USER_TOKEN *token = p->pipe_user.nt_user_token; /* perform access checks */ @@ -438,50 +404,29 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT if ( !(info->access_granted & SC_RIGHT_MGR_ENUMERATE_SERVICE) ) return WERR_ACCESS_DENIED; - num_int_services = 0; - num_ext_services = 0; - - /* num_services = str_list_count( lp_enable_svcctl() ); */ - - /* here's where we'll read the db of external services */ - /* _svcctl_read_LSB_data(NULL,NULL); */ - /* init_svcctl_db(); */ - - if ( !(services = TALLOC_ARRAY(p->mem_ctx, ENUM_SERVICES_STATUS, num_int_services+num_ext_services )) ) + if ( (num_services = enumerate_status( p->mem_ctx, &services, token )) == -1 ) return WERR_NOMEM; - if ( W_ERROR_IS_OK(enum_internal_services(p->mem_ctx, &services, 0, &num_int_services)) ) - DEBUG(8,("_svcctl_enum_services_status: Got %d internal services\n", num_int_services)); - -#if 0 - if ( W_ERROR_IS_OK(enum_external_services(p->mem_ctx, &services, num_int_services, &num_ext_services)) ) - DEBUG(8,("_svcctl_enum_services_status: Got %d external services\n", num_ext_services)); -#endif - - total_services = num_int_services + num_ext_services; - - DEBUG(8,("_svcctl_enum_services_status: total of %d services\n", total_services )); - - for ( i=0; i q_u->buffer_size ) { - total_services = 0; + num_services = 0; result = WERR_MORE_DATA; } rpcbuf_init(&r_u->buffer, q_u->buffer_size, p->mem_ctx); if ( W_ERROR_IS_OK(result) ) { - for ( i=0; ibuffer, 0 ); } r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size; - r_u->returned = total_services; + r_u->returned = num_services; if ( !(r_u->resume = TALLOC_P( p->mem_ctx, uint32 )) ) return WERR_NOMEM; @@ -506,7 +451,7 @@ WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCT if ( !(info->access_granted & SC_RIGHT_SVC_START) ) return WERR_ACCESS_DENIED; - return info->ops->start_service(); + return info->ops->start_service( info->name ); } /******************************************************************** @@ -517,18 +462,27 @@ WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, S SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); /* perform access checks */ - /* we only support stop so don't get complicated */ - + if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) return WERR_BADFID; - if ( q_u->control != SVCCTL_CONTROL_STOP ) - return WERR_ACCESS_DENIED; - - if ( !(info->access_granted & SC_RIGHT_SVC_STOP) ) - return WERR_ACCESS_DENIED; + switch ( q_u->control ) { + case SVCCTL_CONTROL_STOP: + if ( !(info->access_granted & SC_RIGHT_SVC_STOP) ) + return WERR_ACCESS_DENIED; + + return info->ops->stop_service( info->name, &r_u->svc_status ); - return info->ops->stop_service( &r_u->svc_status ); + case SVCCTL_CONTROL_INTERROGATE: + if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_STATUS) ) + return WERR_ACCESS_DENIED; + + return info->ops->service_status( info->name, &r_u->svc_status ); + } + + /* default control action */ + + return WERR_ACCESS_DENIED; } /******************************************************************** @@ -564,11 +518,8 @@ WERROR _svcctl_enum_dependent_services( pipes_struct *p, SVCCTL_Q_ENUM_DEPENDENT WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_STATUSEX *q_u, SVCCTL_R_QUERY_SERVICE_STATUSEX *r_u ) { - SERVICE_STATUS_PROCESS ssp; - POLICY_HND *handle; - SERVICE_INFO *service_info; - pstring command; SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + uint32 buffer_size; /* perform access checks */ @@ -579,68 +530,80 @@ WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_ return WERR_ACCESS_DENIED; /* we have to set the outgoing buffer size to the same as the - incoming buffer size (even in the case of failure */ - - r_u->needed = q_u->buffer_size; - - /* need to find the service name by the handle that is open */ - handle = &(q_u->handle); + incoming buffer size (even in the case of failure) */ + rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); + r_u->needed = q_u->buffer_size; + + switch ( q_u->level ) { + case SVC_STATUS_PROCESS_INFO: + { + SERVICE_STATUS_PROCESS svc_stat_proc; - /* get rid of the easy errors */ + /* Get the status of the service.. */ + info->ops->service_status( info->name, &svc_stat_proc.status ); + svc_stat_proc.process_id = sys_getpid(); + svc_stat_proc.service_flags = 0x0; - if (q_u->info_level != SVC_STATUS_PROCESS_INFO) { - DEBUG(10, ("_svcctl_query_service_status_ex : Invalid information level specified\n")); - return WERR_UNKNOWN_LEVEL; + svcctl_io_service_status_process( "", &svc_stat_proc, &r_u->buffer, 0 ); + buffer_size = sizeof(SERVICE_STATUS_PROCESS); + break; + } + + default: + return WERR_UNKNOWN_LEVEL; } - service_info = find_service_info_by_hnd(p, handle); - - if (!service_info) { - DEBUG(10, ("_svcctl_query_service_status_ex : Can't find the service for the handle\n")); - return WERR_BADFID; - } - if (r_u->needed < (sizeof(SERVICE_STATUS_PROCESS)+sizeof(uint32)+sizeof(uint32))) { - DEBUG(10, ("_svcctl_query_service_status_ex : buffer size of [%d] is too small.\n",r_u->needed)); - return WERR_INSUFFICIENT_BUFFER; - } - - ZERO_STRUCT(ssp); - -#if 0 - if (!strwicmp(service_info->servicetype,"EXTERNAL")) - ssp.type = SVCCTL_WIN32_OWN_PROC; - else - ssp.type = SVCCTL_WIN32_SHARED_PROC; -#endif + buffer_size += buffer_size % 4; + r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size; - /* Get the status of the service.. */ + if (buffer_size > q_u->buffer_size ) + return WERR_MORE_DATA; + + return WERR_OK; +} - memset(command, 0, sizeof(command)); +/******************************************************************** +********************************************************************/ -#if 0 - slprintf(command, sizeof(command)-1, "%s%s%s %s", dyn_LIBDIR, SVCCTL_SCRIPT_DIR, service_info->filename, "status"); +static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG *config, NT_USER_TOKEN *token ) +{ + REGVAL_CTR *values; + REGISTRY_VALUE *val; - DEBUG(10, ("_svcctl_query_service_status_ex: status command is [%s]\n", command)); + /* retrieve the registry values for this service */ + + if ( !(values = svcctl_fetch_regvalues( name, token )) ) + return WERR_REG_CORRUPT; + + /* now fill in the individual values */ + + config->displayname = TALLOC_ZERO_P( ctx, UNISTR2 ); + if ( (val = regval_ctr_getvalue( values, "DisplayName" )) != NULL ) + init_unistr2( config->displayname, regval_sz( val ), UNI_STR_TERMINATE ); + else + init_unistr2( config->displayname, name, UNI_STR_TERMINATE ); - /* TODO - wrap in privilege check */ + if ( (val = regval_ctr_getvalue( values, "ObjectName" )) != NULL ) { + config->startname = TALLOC_ZERO_P( ctx, UNISTR2 ); + init_unistr2( config->startname, regval_sz( val ), UNI_STR_TERMINATE ); + } + + if ( (val = regval_ctr_getvalue( values, "ImagePath" )) != NULL ) { + config->executablepath = TALLOC_ZERO_P( ctx, UNISTR2 ); + init_unistr2( config->executablepath, regval_sz( val ), UNI_STR_TERMINATE ); + } - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - close(fd); - if(ret != 0) - DEBUG(10, ("_svcctl_query_service_status_ex: Command returned [%d]\n", ret)); + /* a few hard coded values */ + /* loadordergroup and dependencies are empty */ + + config->tag_id = 0x00000000; /* unassigned loadorder group */ + config->service_type = SVCCTL_WIN32_OWN_PROC; + config->start_type = SVCCTL_DEMAND_START; + config->error_control = SVCCTL_SVC_ERROR_NORMAL; - /* SET all service_stats bits here... */ - if (ret == 0) { - ssp.state = SVCCTL_RUNNING; - ssp.controls_accepted = SVCCTL_CONTROL_SHUTDOWN | SVCCTL_CONTROL_STOP; - } else { - ssp.state = SVCCTL_STOPPED; - ssp.controls_accepted = 0; - } -#endif + TALLOC_FREE( values ); return WERR_OK; } @@ -650,10 +613,9 @@ WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_ WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CONFIG *q_u, SVCCTL_R_QUERY_SERVICE_CONFIG *r_u ) { - POLICY_HND *handle; - SERVICE_INFO *service_info; - uint32 needed_size; SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + uint32 buffer_size; + WERROR wresult; /* perform access checks */ @@ -667,89 +629,19 @@ WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CON incoming buffer size (even in the case of failure */ r_u->needed = q_u->buffer_size; + + wresult = fill_svc_config( p->mem_ctx, info->name, &r_u->config, p->pipe_user.nt_user_token ); + if ( !W_ERROR_IS_OK(wresult) ) + return wresult; + + buffer_size = svcctl_sizeof_service_config( &r_u->config ); + r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size; - /* need to find the service name by the handle that is open */ - handle = &(q_u->handle); - - service_info = find_service_info_by_hnd(p, handle); - -#if 0 - if (q_u->buffer_size < sizeof(Service_info)) { - /* have to report need more... */ - /* TODO worst case -- should actualy calc what we need here. */ - r_u->needed = sizeof(Service_info)+sizeof(pstring)*5; - DEBUG(10, ("_svcctl_query_service_config: NOT ENOUGH BUFFER ALLOCATED FOR RETURN DATA -- provided %d wanted %d\n", - q_u->buffer_size,r_u->needed)); - - return WERR_INSUFFICIENT_BUFFER; - } -#endif - if (!service_info) { - DEBUG(10, ("_svcctl_query_service_config : Can't find the service for the handle\n")); - return WERR_BADFID; - } - -#if 0 - if ( !(service_config = (SERVICE_CONFIG *)TALLOC_ZERO_P(p->mem_ctx, SERVICE_CONFIG)) ) - return WERR_NOMEM; -#endif - - r_u->config.service_type = SVCCTL_WIN32_OWN_PROC; - r_u->config.start_type = SVCCTL_DEMAND_START; - r_u->config.error_control = SVCCTL_SVC_ERROR_IGNORE; - r_u->config.tag_id = 0x00000000; - - /* Init the strings */ - - r_u->config.executablepath = TALLOC_ZERO_P(p->mem_ctx, UNISTR2); - r_u->config.loadordergroup = TALLOC_ZERO_P(p->mem_ctx, UNISTR2); - r_u->config.dependencies = TALLOC_ZERO_P(p->mem_ctx, UNISTR2); - r_u->config.startname = TALLOC_ZERO_P(p->mem_ctx, UNISTR2); - r_u->config.displayname = TALLOC_ZERO_P(p->mem_ctx, UNISTR2); - -#if 0 - pstrcpy(fullpathinfo,dyn_LIBDIR); - pstrcat(fullpathinfo,SVCCTL_SCRIPT_DIR); - pstrcat(fullpathinfo,service_info->filename); - /* Get and calculate the size of the fields. Note that we're still building the fields in the "too-small buffer case" - even though we throw it away. */ - - DEBUG(10, ("_svcctl_query_service_config: fullpath info [%s]\n",fullpathinfo)); - init_unistr2(r_u->config.executablepath,fullpathinfo,UNI_STR_TERMINATE); - init_unistr2(r_u->config.loadordergroup,"",UNI_STR_TERMINATE); - init_unistr2(r_u->config.dependencies,service_info->dependencies,UNI_STR_TERMINATE); - - /* TODO - if someone really cares, perhaps "LocalSystem" should be changed to something else here... */ - - init_unistr2(r_u->config.startname,"LocalSystem",UNI_STR_TERMINATE); - init_unistr2(r_u->config.displayname,service_info->servicename,UNI_STR_TERMINATE); -#endif - - needed_size = 0x04 + sizeof(SERVICE_CONFIG)+ 2*( - r_u->config.executablepath->uni_str_len + - r_u->config.loadordergroup->uni_str_len + - r_u->config.dependencies->uni_str_len + - r_u->config.startname->uni_str_len + - r_u->config.displayname->uni_str_len); - - DEBUG(10, ("_svcctl_query_service_config: ****** need to have a buffer of [%d], [%d] for struct \n",needed_size, - sizeof(SERVICE_CONFIG))); - DEBUG(10, ("\tsize of executable path : %d\n",r_u->config.executablepath->uni_str_len)); - DEBUG(10, ("\tsize of loadordergroup : %d\n", r_u->config.loadordergroup->uni_str_len)); - DEBUG(10, ("\tsize of dependencies : %d\n", r_u->config.dependencies->uni_str_len)); - DEBUG(10, ("\tsize of startname : %d\n", r_u->config.startname->uni_str_len)); - DEBUG(10, ("\tsize of displayname : %d\n", r_u->config.displayname->uni_str_len)); - - if (q_u->buffer_size < needed_size) { - /* have to report need more...*/ - r_u->needed = needed_size; - DEBUG(10, ("_svcctl_query_service_config: ****** zeroing strings for return\n")); - memset(&r_u->config,0,sizeof(SERVICE_CONFIG)); - DEBUG(10, ("_svcctl_query_service_config: Not enouh buffer provided for return -- provided %d wanted %d\n", - q_u->buffer_size,needed_size)); - return WERR_INSUFFICIENT_BUFFER; + if (buffer_size > q_u->buffer_size ) { + ZERO_STRUCTP( &r_u->config ); + return WERR_INSUFFICIENT_BUFFER; } - + return WERR_OK; } @@ -758,9 +650,8 @@ WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CON WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CONFIG2 *q_u, SVCCTL_R_QUERY_SERVICE_CONFIG2 *r_u ) { - POLICY_HND *handle; - SERVICE_INFO *service_info; SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + uint32 buffer_size; /* perform access checks */ @@ -773,55 +664,84 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ - r_u->needed = q_u->buffer_size; - r_u->description = NULL; - r_u->returned = q_u->buffer_size; - r_u->offset = 4; + rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); + r_u->needed = q_u->buffer_size; - handle = &(q_u->handle); + switch ( q_u->level ) { + case SERVICE_CONFIG_DESCRIPTION: + { + SERVICE_DESCRIPTION desc_buf; + const char *description; + + description = svcctl_lookup_description( info->name, p->pipe_user.nt_user_token ); + + ZERO_STRUCTP( &desc_buf ); - service_info = find_service_info_by_hnd(p, handle); + init_service_description_buffer( &desc_buf, description ); + svcctl_io_service_description( "", &desc_buf, &r_u->buffer, 0 ); + buffer_size = svcctl_sizeof_service_description( &desc_buf ); - if (!service_info) { - DEBUG(10, ("_svcctl_query_service_config2 : Can't find the service for the handle\n")); - return WERR_BADFID; - } - - /* - TODO - perhaps move the RPC_DATA_BLOB into the R_QUERY_SERVICE_CONFIG structure, and to the processing in here, vs - in the *r_query_config2 marshalling routine... - */ - -#if 0 - if (SERVICE_CONFIG_DESCRIPTION == q_u->info_level) { - if (service_info && service_info->shortdescription) { - /* length of the string, plus the terminator... */ - string_buffer_size = strlen(service_info->shortdescription)+1; - DEBUG(10, ("_svcctl_query_service_config: copying the description [%s] length [%d]\n", - service_info->shortdescription,string_buffer_size)); - - if (q_u->buffer_size >= ((string_buffer_size)*2+4)) { - r_u->description = TALLOC_ZERO_P(p->mem_ctx, UNISTR2); - if (!r_u->description) return WERR_NOMEM; - init_unistr2(r_u->description,service_info->shortdescription,UNI_STR_TERMINATE); - } + break; } - else { - string_buffer_size = 0; - } - DEBUG(10, ("_svcctl_query_service_config2: buffer needed is [%x], return buffer size is [%x]\n", - string_buffer_size,q_u->buffer_size)); - if (((string_buffer_size)*2+4) > q_u->buffer_size) { - r_u->needed = (string_buffer_size+1)*2+4; - DEBUG(10, ("_svcctl_query_service_config2: INSUFFICIENT BUFFER\n")); - return WERR_INSUFFICIENT_BUFFER; + break; + case SERVICE_CONFIG_FAILURE_ACTIONS: + { + SERVICE_FAILURE_ACTIONS actions; + + /* nothing to say...just service the request */ + + ZERO_STRUCTP( &actions ); + svcctl_io_service_fa( "", &actions, &r_u->buffer, 0 ); + buffer_size = svcctl_sizeof_service_fa( &actions ); + + break; } - DEBUG(10, ("_svcctl_query_service_config2: returning ok, needed is [%x], buffer size is [%x]\n", - r_u->needed,q_u->buffer_size)); + break; + + default: + return WERR_UNKNOWN_LEVEL; + } + + buffer_size += buffer_size % 4; + r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size; - return WERR_OK; - } -#endif + if (buffer_size > q_u->buffer_size ) + return WERR_INSUFFICIENT_BUFFER; - return WERR_ACCESS_DENIED; + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_lock_service_db( pipes_struct *p, SVCCTL_Q_LOCK_SERVICE_DB *q_u, SVCCTL_R_LOCK_SERVICE_DB *r_u ) +{ + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + + /* perform access checks */ + + if ( !info || (info->type != SVC_HANDLE_IS_SCM) ) + return WERR_BADFID; + + if ( !(info->access_granted & SC_RIGHT_MGR_LOCK) ) + return WERR_ACCESS_DENIED; + + /* Just open a handle. Doesn't actually lock anything */ + + return create_open_service_handle( p, &r_u->h_lock, SVC_HANDLE_IS_DBLOCK, NULL, 0 ); +; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_unlock_service_db( pipes_struct *p, SVCCTL_Q_UNLOCK_SERVICE_DB *q_u, SVCCTL_R_UNLOCK_SERVICE_DB *r_u ) +{ + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->h_lock ); + + + if ( !info || (info->type != SVC_HANDLE_IS_DBLOCK) ) + return WERR_BADFID; + + return close_policy_hnd( p, &q_u->h_lock) ? WERR_OK : WERR_BADFID; } -- cgit From ac34076306c6fd5cafcba73df7f1f556277a4a0a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 5 Oct 2005 01:47:52 +0000 Subject: r10722: Remove unused BOOL in struct dcinfo. Ensure that the mach_acct and remote machine entries are set correctly in struct dcinfo - we'll need this as a key for a persistent schannel state later. Jeremy. (This used to be commit 47269b5c7161d740c2e86227de3acd9e08c53817) --- source3/rpc_server/srv_netlog_nt.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 5aefe3ca3c..a89e3d572a 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -436,10 +436,14 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) /* set up the LSA AUTH 2 response */ init_net_r_auth_2(r_u, &srv_chal_out, &srv_flgs, NT_STATUS_OK); + fstrcpy(p->dc->mach_acct, mach_acct); + fstrcpy(p->dc->remote_machine, remote_machine); + server_auth2_negotiated = True; p->dc->authenticated = True; last_dcinfo = *p->dc; + //secrets_store_schannel_session_info(p->dc); return r_u->status; } -- cgit From 2237bc6a4275a6c02196552b14b1632709917328 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 5 Oct 2005 01:50:47 +0000 Subject: r10724: Got a little ahead of myself... Jeremy. (This used to be commit 86ffef8162393be3da81fda13772f0f1d40b0d08) --- source3/rpc_server/srv_netlog_nt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index a89e3d572a..1ad058b519 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -443,7 +443,6 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) p->dc->authenticated = True; last_dcinfo = *p->dc; - //secrets_store_schannel_session_info(p->dc); return r_u->status; } -- cgit From 0bf72b6e330a76bee502cb36c1cb80c46d47d33c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 6 Oct 2005 17:48:03 +0000 Subject: r10781: merging eventlog and svcctl code from trunk (This used to be commit f10aa9fb84bfac4f1a22b74d63999668700ffaac) --- source3/rpc_server/srv_eventlog_lib.c | 620 +++++++++++++++++ source3/rpc_server/srv_eventlog_nt.c | 1225 ++++++++++++++++----------------- source3/rpc_server/srv_ntsvcs_nt.c | 6 +- source3/rpc_server/srv_reg_nt.c | 6 +- source3/rpc_server/srv_svcctl_nt.c | 19 +- 5 files changed, 1229 insertions(+), 647 deletions(-) create mode 100644 source3/rpc_server/srv_eventlog_lib.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c new file mode 100644 index 0000000000..a8c1ad51d2 --- /dev/null +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -0,0 +1,620 @@ + +/* + * Unix SMB/CIFS implementation. + * Eventlog utility routines + * Copyright (C) Marcin Krzysztof Porwit 2005, + * Copyright (C) Gerald (Jerry) Carter 2005. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "includes.h" + + +/**************************************************************** +Init an Eventlog TDB, and return it. If null, something bad happened. +****************************************************************/ +TDB_CONTEXT *init_eventlog_tdb( char *tdbfilename ) +{ + TDB_CONTEXT *the_tdb; + + unlink( tdbfilename ); + + the_tdb = + tdb_open_log( tdbfilename, 0, TDB_DEFAULT, O_RDWR | O_CREAT, + 0664 ); + if ( the_tdb == NULL ) { + DEBUG( 1, ( "Can't open tdb for [%s]\n", tdbfilename ) ); + return NULL; + } + tdb_store_int32( the_tdb, VN_oldest_entry, 1 ); + tdb_store_int32( the_tdb, VN_next_record, 1 ); + + /* initialize with defaults, copy real values in here from registry */ + + tdb_store_int32( the_tdb, VN_maxsize, 0x80000 ); + tdb_store_int32( the_tdb, VN_retention, 0x93A80 ); + + tdb_store_int32( the_tdb, VN_version, EVENTLOG_DATABASE_VERSION_V1 ); + return the_tdb; +} + +/* make the tdb file name for an event log, given destination buffer and size */ +char *mk_tdbfilename( char *dest_buffer, char *eventlog_name, int size_dest ) +{ + if ( !dest_buffer ) + return NULL; + pstring ondisk_name; + + pstrcpy( ondisk_name, "EV" ); + pstrcat( ondisk_name, eventlog_name ); + pstrcat( ondisk_name, ".tdb" ); + + memset( dest_buffer, 0, size_dest ); + + /* BAD things could happen if the dest_buffer is not large enough... */ + if ( strlen( ondisk_name ) > size_dest ) { + DEBUG( 3, ( "Buffer not big enough for filename\n" ) ); + return NULL; + } + + strncpy( dest_buffer, ondisk_name, size_dest ); + + return dest_buffer; +} + + +/* count the number of bytes in the TDB */ + +/* Arg! Static Globals! */ + +static int eventlog_tdbcount; +static int eventlog_tdbsize; + +/* this function is used to count up the number of bytes in a particular TDB */ +int eventlog_tdb_size_fn( TDB_CONTEXT * tdb, TDB_DATA key, TDB_DATA data, + void *state ) +{ + eventlog_tdbsize += data.dsize; + eventlog_tdbcount++; + return 0; +} + +/* returns the size of the eventlog, and if MaxSize is a non-null ptr, puts + the MaxSize there. This is purely a way not to have yet another function that solely + reads the maxsize of the eventlog. Yeah, that's it. */ + +int eventlog_tdb_size( TDB_CONTEXT * tdb, int *MaxSize, int *Retention ) +{ + if ( !tdb ) + return 0; + eventlog_tdbcount = 0; + eventlog_tdbsize = 0; + + tdb_traverse( tdb, eventlog_tdb_size_fn, NULL ); + + if ( MaxSize != NULL ) { + *MaxSize = tdb_fetch_int32( tdb, VN_maxsize ); + } + + if ( Retention != NULL ) { + *Retention = tdb_fetch_int32( tdb, VN_retention ); + } + + DEBUG( 1, + ( "eventlog size: [%d] for [%d] records\n", eventlog_tdbsize, + eventlog_tdbcount ) ); + return eventlog_tdbsize; +} + + +/* + Discard early event logs until we have enough for 'needed' bytes... + NO checking done beforehand to see that we actually need to do this, and + it's going to pluck records one-by-one. So, it's best to determine that this + needs to be done before doing it. + + Setting whack_by_date to True indicates that eventlogs falling outside of the + retention range need to go... + +*/ + +/* return True if we made enough room to accommodate needed bytes */ + +BOOL make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, + BOOL whack_by_date ) +{ + int start_record, i, new_start; + int end_record; + int nbytes, reclen, len, Retention, MaxSize; + + int tresv1, trecnum, timegen, timewr; + + TDB_DATA key, ret; + TALLOC_CTX *mem_ctx = NULL; + + time_t current_time, exp_time; + + /* discard some eventlogs */ + + /* read eventlogs from oldest_entry -- there can't be any discontinuity in recnos, + although records not necessarily guaranteed to have successive times */ + /* */ + mem_ctx = talloc_init( "make_way_for_eventlogs" ); /* Homage to BPG */ + + if ( mem_ctx == NULL ) + return False; /* can't allocate memory indicates bigger problems */ + /* lock */ + tdb_lock_bystring( the_tdb, VN_next_record, 1 ); + /* read */ + end_record = tdb_fetch_int32( the_tdb, VN_next_record ); + start_record = tdb_fetch_int32( the_tdb, VN_oldest_entry ); + Retention = tdb_fetch_int32( the_tdb, VN_retention ); + MaxSize = tdb_fetch_int32( the_tdb, VN_maxsize ); + + time( ¤t_time ); + + /* calculate ... */ + exp_time = current_time - Retention; /* discard older than exp_time */ + + /* todo - check for sanity in next_record */ + nbytes = 0; + + DEBUG( 3, + ( "MaxSize [%d] Retention [%d] Current Time [%d] exp_time [%d]\n", + MaxSize, Retention, (uint32)current_time, (uint32)exp_time ) ); + DEBUG( 3, + ( "Start Record [%d] End Record [%d]\n", start_record, + end_record ) ); + + for ( i = start_record; i < end_record; i++ ) { + /* read a record, add the amt to nbytes */ + key.dsize = sizeof( int32 ); + key.dptr = ( char * ) ( int32 * ) & i; + ret = tdb_fetch( the_tdb, key ); + if ( ret.dsize == 0 ) { + DEBUG( 8, + ( "Can't find a record for the key, record [%d]\n", + i ) ); + tdb_unlock_bystring( the_tdb, VN_next_record ); + return False; + } + nbytes += ret.dsize; /* note this includes overhead */ + + len = tdb_unpack( ret.dptr, ret.dsize, "ddddd", &reclen, + &tresv1, &trecnum, &timegen, &timewr ); + DEBUG( 8, + ( "read record %d, record size is [%d], total so far [%d]\n", + i, reclen, nbytes ) ); + + SAFE_FREE( ret.dptr ); + + /* note that other servers may just stop writing records when the size limit + is reached, and there are no records older than 'retention'. This doesn't + like a very useful thing to do, so instead we whack (as in sleeps with the + fishes) just enough records to fit the what we need. This behavior could + be changed to 'match', if the need arises. */ + + if ( !whack_by_date && ( nbytes >= needed ) ) + break; /* done */ + if ( whack_by_date && ( timegen >= exp_time ) ) + break; /* done */ + } + + DEBUG( 3, + ( "nbytes [%d] needed [%d] start_record is [%d], should be set to [%d]\n", + nbytes, needed, start_record, i ) ); + /* todo - remove eventlog entries here and set starting record to start_record... */ + new_start = i; + if ( start_record != new_start ) { + for ( i = start_record; i < new_start; i++ ) { + key.dsize = sizeof( int32 ); + key.dptr = ( char * ) ( int32 * ) & i; + tdb_delete( the_tdb, key ); + } + + tdb_store_int32( the_tdb, VN_oldest_entry, new_start ); + } + tdb_unlock_bystring( the_tdb, VN_next_record ); + return True; +} + +/* + some hygiene for an eventlog - see how big it is, and then + calculate how many bytes we need to remove +*/ + +BOOL prune_eventlog( TDB_CONTEXT * tdb ) +{ + int MaxSize, Retention, CalcdSize; + + if ( !tdb ) { + DEBUG( 4, ( "No eventlog tdb handle\n" ) ); + return False; + } + + CalcdSize = eventlog_tdb_size( tdb, &MaxSize, &Retention ); + DEBUG( 3, + ( "Calculated size [%d] MaxSize [%d]\n", CalcdSize, + MaxSize ) ); + + if ( CalcdSize > MaxSize ) { + return make_way_for_eventlogs( tdb, CalcdSize - MaxSize, + False ); + } + + return make_way_for_eventlogs( tdb, 0, True ); +} + +BOOL can_write_to_eventlog( TDB_CONTEXT * tdb, int32 needed ) +{ + int calcd_size; + int MaxSize, Retention; + + /* see if we can write to the eventlog -- do a policy enforcement */ + if ( !tdb ) + return False; /* tdb is null, so we can't write to it */ + + + if ( needed < 0 ) + return False; + MaxSize = 0; + Retention = 0; + + calcd_size = eventlog_tdb_size( tdb, &MaxSize, &Retention ); + + if ( calcd_size <= MaxSize ) + return True; /* you betcha */ + if ( calcd_size + needed < MaxSize ) + return True; + + if ( Retention == 0xffffffff ) { + return False; /* see msdn - we can't write no room, discard */ + } + /* + note don't have to test, but always good to show intent, in case changes needed + later + */ + + if ( Retention == 0x00000000 ) { + /* discard record(s) */ + /* todo - decide when to remove a bunch vs. just what we need... */ + return make_way_for_eventlogs( tdb, calcd_size - MaxSize, + True ); + } + + return make_way_for_eventlogs( tdb, calcd_size - MaxSize, False ); +} + +TDB_CONTEXT *open_eventlog_tdb( char *tdbfilename ) +{ + TDB_CONTEXT *the_tdb; + + the_tdb = + tdb_open_log( tdbfilename, 0, TDB_DEFAULT, O_RDWR | O_CREAT, + 0664 ); + if ( the_tdb == NULL ) { + return init_eventlog_tdb( tdbfilename ); + } + if ( EVENTLOG_DATABASE_VERSION_V1 != + tdb_fetch_int32( the_tdb, VN_version ) ) { + tdb_close( the_tdb ); + return init_eventlog_tdb( tdbfilename ); + } + return the_tdb; +} + +/* write an eventlog entry. Note that we have to lock, read next eventlog, increment, write, write the record, unlock */ + +/* coming into this, ee has the eventlog record, and the auxilliary date (computer name, etc.) + filled into the other structure. Before packing into a record, this routine will calc the + appropriate padding, etc., and then blast out the record in a form that can be read back in */ +int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ) +{ + int32 next_record; + uint8 *packed_ee; + TALLOC_CTX *mem_ctx = NULL; + TDB_DATA kbuf, ebuf; + uint32 n_packed; + + if ( !ee ) + return 0; + + mem_ctx = talloc_init( "write_eventlog_tdb" ); + + if ( mem_ctx == NULL ) + return 0; + + if ( !ee ) + return 0; + /* discard any entries that have bogus time, which usually indicates a bogus entry as well. */ + if ( ee->record.time_generated == 0 ) + return 0; + +#define MARGIN 512 + + /* todo - check for sanity in next_record */ + + fixup_eventlog_entry( ee ); + + if ( !can_write_to_eventlog( the_tdb, ee->record.length ) ) { + DEBUG( 3, ( "Can't write to Eventlog, no room \n" ) ); + talloc_destroy( mem_ctx ); + return 0; + } + + /* alloc mem for the packed version */ + packed_ee = TALLOC( mem_ctx, ee->record.length + MARGIN ); + if ( !packed_ee ) { + talloc_destroy( mem_ctx ); + return 0; + } + + /* need to read the record number and insert it into the entry here */ + + /* lock */ + tdb_lock_bystring( the_tdb, VN_next_record, 1 ); + /* read */ + next_record = tdb_fetch_int32( the_tdb, VN_next_record ); + + n_packed = + tdb_pack( packed_ee, ee->record.length + MARGIN, + "ddddddwwwwddddddBBdBBBd", ee->record.length, + ee->record.reserved1, next_record, + ee->record.time_generated, ee->record.time_written, + ee->record.event_id, ee->record.event_type, + ee->record.num_strings, ee->record.event_category, + ee->record.reserved2, + ee->record.closing_record_number, + ee->record.string_offset, + ee->record.user_sid_length, + ee->record.user_sid_offset, ee->record.data_length, + ee->record.data_offset, + ee->data_record.source_name_len, + ee->data_record.source_name, + ee->data_record.computer_name_len, + ee->data_record.computer_name, + ee->data_record.sid_padding, + ee->record.user_sid_length, ee->data_record.sid, + ee->data_record.strings_len, + ee->data_record.strings, + ee->data_record.user_data_len, + ee->data_record.user_data, + ee->data_record.data_padding ); + + /*DEBUG(3,("write_eventlog_tdb: packed into %d\n",n_packed)); */ + + /* increment the record count */ + + kbuf.dsize = sizeof( int32 ); + kbuf.dptr = ( uint8 * ) & next_record; + + ebuf.dsize = n_packed; + ebuf.dptr = packed_ee; + + if ( tdb_store( the_tdb, kbuf, ebuf, 0 ) ) { + /* DEBUG(1,("write_eventlog_tdb: Can't write record %d to eventlog\n",next_record)); */ + tdb_unlock_bystring( the_tdb, VN_next_record ); + talloc_destroy( mem_ctx ); + return 0; + } + next_record++; + tdb_store_int32( the_tdb, VN_next_record, next_record ); + tdb_unlock_bystring( the_tdb, VN_next_record ); + talloc_destroy( mem_ctx ); + return ( next_record - 1 ); +} + +/* calculate the correct fields etc for an eventlog entry */ + +void fixup_eventlog_entry( Eventlog_entry * ee ) +{ + /* fix up the eventlog entry structure as necessary */ + + ee->data_record.sid_padding = + ( ( 4 - + ( ( ee->data_record.source_name_len + + ee->data_record.computer_name_len ) % 4 ) ) % 4 ); + ee->data_record.data_padding = + ( 4 - + ( ( ee->data_record.strings_len + + ee->data_record.user_data_len ) % 4 ) ) % 4; + ee->record.length = sizeof( Eventlog_record ); + ee->record.length += ee->data_record.source_name_len; + ee->record.length += ee->data_record.computer_name_len; + if ( ee->record.user_sid_length == 0 ) { + /* Should not pad to a DWORD boundary for writing out the sid if there is + no SID, so just propagate the padding to pad the data */ + ee->data_record.data_padding += ee->data_record.sid_padding; + ee->data_record.sid_padding = 0; + } + /* DEBUG(10, ("sid_padding is [%d].\n", ee->data_record.sid_padding)); */ + /* DEBUG(10, ("data_padding is [%d].\n", ee->data_record.data_padding)); */ + + ee->record.length += ee->data_record.sid_padding; + ee->record.length += ee->record.user_sid_length; + ee->record.length += ee->data_record.strings_len; + ee->record.length += ee->data_record.user_data_len; + ee->record.length += ee->data_record.data_padding; + /* need another copy of length at the end of the data */ + ee->record.length += sizeof( ee->record.length ); +} + +/******************************************************************** +Note that it's a pretty good idea to initialize the Eventlog_entry structure to zero's before +calling parse_logentry on an batch of lines that may resolve to a record. +ALSO, it's a good idea to remove any linefeeds (that's EOL to you and me) on the lines going in. + +********************************************************************/ + +BOOL parse_logentry( char *line, Eventlog_entry * entry, BOOL * eor ) +{ + char *start = NULL, *stop = NULL; + pstring temp; + int temp_len = 0; + + start = line; + + /* empty line signyfiying record delimeter, or we're at the end of the buffer */ + if ( start == NULL || strlen( start ) == 0 ) { + DEBUG( 6, + ( "parse_logentry: found end-of-record indicator.\n" ) ); + *eor = True; + return True; + } + if ( !( stop = strchr( line, ':' ) ) ) { + return False; + } + + DEBUG( 6, ( "parse_logentry: trying to parse [%s].\n", line ) ); + + if ( 0 == strncmp( start, "LEN", stop - start ) ) { + /* This will get recomputed later anyway -- probably not necessary */ + entry->record.length = atoi( stop + 1 ); + } else if ( 0 == strncmp( start, "RS1", stop - start ) ) { + /* For now all these reserved entries seem to have the same value, + which can be hardcoded to int(1699505740) for now */ + entry->record.reserved1 = atoi( stop + 1 ); + } else if ( 0 == strncmp( start, "RCN", stop - start ) ) { + entry->record.record_number = atoi( stop + 1 ); + } else if ( 0 == strncmp( start, "TMG", stop - start ) ) { + entry->record.time_generated = atoi( stop + 1 ); + } else if ( 0 == strncmp( start, "TMW", stop - start ) ) { + entry->record.time_written = atoi( stop + 1 ); + } else if ( 0 == strncmp( start, "EID", stop - start ) ) { + entry->record.event_id = atoi( stop + 1 ); + } else if ( 0 == strncmp( start, "ETP", stop - start ) ) { + if ( strstr( start, "ERROR" ) ) { + entry->record.event_type = EVENTLOG_ERROR_TYPE; + } else if ( strstr( start, "WARNING" ) ) { + entry->record.event_type = EVENTLOG_WARNING_TYPE; + } else if ( strstr( start, "INFO" ) ) { + entry->record.event_type = EVENTLOG_INFORMATION_TYPE; + } else if ( strstr( start, "AUDIT_SUCCESS" ) ) { + entry->record.event_type = EVENTLOG_AUDIT_SUCCESS; + } else if ( strstr( start, "AUDIT_FAILURE" ) ) { + entry->record.event_type = EVENTLOG_AUDIT_FAILURE; + } else if ( strstr( start, "SUCCESS" ) ) { + entry->record.event_type = EVENTLOG_SUCCESS; + } else { + /* some other eventlog type -- currently not defined in MSDN docs, so error out */ + return False; + } + } + +/* + else if(0 == strncmp(start, "NST", stop - start)) + { + entry->record.num_strings = atoi(stop + 1); + } +*/ + else if ( 0 == strncmp( start, "ECT", stop - start ) ) { + entry->record.event_category = atoi( stop + 1 ); + } else if ( 0 == strncmp( start, "RS2", stop - start ) ) { + entry->record.reserved2 = atoi( stop + 1 ); + } else if ( 0 == strncmp( start, "CRN", stop - start ) ) { + entry->record.closing_record_number = atoi( stop + 1 ); + } else if ( 0 == strncmp( start, "USL", stop - start ) ) { + entry->record.user_sid_length = atoi( stop + 1 ); + } else if ( 0 == strncmp( start, "SRC", stop - start ) ) { + memset( temp, 0, sizeof( temp ) ); + stop++; + while ( isspace( stop[0] ) ) { + stop++; + } + temp_len = strlen( stop ); + strncpy( temp, stop, temp_len ); + rpcstr_push( ( void * ) ( entry->data_record.source_name ), + temp, sizeof( entry->data_record.source_name ), + STR_TERMINATE ); + entry->data_record.source_name_len = + ( strlen_w( entry->data_record.source_name ) * 2 ) + + 2; + } else if ( 0 == strncmp( start, "SRN", stop - start ) ) { + memset( temp, 0, sizeof( temp ) ); + stop++; + while ( isspace( stop[0] ) ) { + stop++; + } + temp_len = strlen( stop ); + strncpy( temp, stop, temp_len ); + rpcstr_push( ( void * ) ( entry->data_record.computer_name ), + temp, sizeof( entry->data_record.computer_name ), + STR_TERMINATE ); + entry->data_record.computer_name_len = + ( strlen_w( entry->data_record.computer_name ) * 2 ) + + 2; + } else if ( 0 == strncmp( start, "SID", stop - start ) ) { + memset( temp, 0, sizeof( temp ) ); + stop++; + while ( isspace( stop[0] ) ) { + stop++; + } + temp_len = strlen( stop ); + strncpy( temp, stop, temp_len ); + rpcstr_push( ( void * ) ( entry->data_record.sid ), temp, + sizeof( entry->data_record.sid ), + STR_TERMINATE ); + entry->record.user_sid_length = + ( strlen_w( entry->data_record.sid ) * 2 ) + 2; + } else if ( 0 == strncmp( start, "STR", stop - start ) ) { + /* skip past initial ":" */ + stop++; + /* now skip any other leading whitespace */ + while ( isspace( stop[0] ) ) { + stop++; + } + temp_len = strlen( stop ); + memset( temp, 0, sizeof( temp ) ); + strncpy( temp, stop, temp_len ); + rpcstr_push( ( void * ) ( entry->data_record.strings + + entry->data_record.strings_len ), + temp, + sizeof( entry->data_record.strings ) - + entry->data_record.strings_len, STR_TERMINATE ); + entry->data_record.strings_len += temp_len + 1; + entry->record.num_strings++; + } else if ( 0 == strncmp( start, "DAT", stop - start ) ) { + /* Now that we're done processing the STR data, adjust the length to account for + unicode, then proceed with the DAT data. */ + entry->data_record.strings_len *= 2; + /* skip past initial ":" */ + stop++; + /* now skip any other leading whitespace */ + while ( isspace( stop[0] ) ) { + stop++; + } + entry->data_record.user_data_len = strlen( stop ); + memset( entry->data_record.user_data, 0, + sizeof( entry->data_record.user_data ) ); + if ( entry->data_record.user_data_len > 0 ) { + /* copy no more than the first 1024 bytes */ + if ( entry->data_record.user_data_len > + sizeof( entry->data_record.user_data ) ) + entry->data_record.user_data_len = + sizeof( entry->data_record. + user_data ); + memcpy( entry->data_record.user_data, stop, + entry->data_record.user_data_len ); + } + } else { + /* some other eventlog entry -- not implemented, so dropping on the floor */ + DEBUG( 10, ( "Unknown entry [%s]. Ignoring.\n", line ) ); + /* For now return true so that we can keep on parsing this mess. Eventually + we will return False here. */ + return True; + } + return True; +} diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 414c99d28e..6067c94fe8 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -2,6 +2,7 @@ * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Marcin Krzysztof Porwit 2005, + * Copyright (C) Brian Moran 2005, * Copyright (C) Gerald (Jerry) Carter 2005. * * This program is free software; you can redistribute it and/or modify @@ -18,12 +19,23 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include "includes.h" -#undef DBGC_CLASS +#undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV + +typedef struct { + pstring logname; /* rather than alloc on the fly what we need... (memory is cheap now) */ + pstring tdbfname; + TDB_CONTEXT *log_tdb; /* the pointer to the TDB_CONTEXT */ +} EventlogTDBInfo; + +static int nlogs; +static EventlogTDBInfo *ttdb = NULL; +static TALLOC_CTX *mem_ctx = NULL; + typedef struct { char *logname; char *servername; @@ -32,54 +44,295 @@ typedef struct { uint32 flags; } EventlogInfo; - + + +#if 0 /* UNUSED */ /******************************************************************** - Inform the external eventlog machinery of default values (on startup - probably) -********************************************************************/ + ********************************************************************/ + +void test_eventlog_tdb( TDB_CONTEXT * the_tdb ) +{ + Eventlog_entry ee; + + int i = 0; + + memset( &ee, 0, sizeof( Eventlog_entry ) ); + + if ( !the_tdb ) + return; + + for ( i = 0; i < 100; i++ ) { + ee.record.length = sizeof( ee.record ); + memset( &ee.data_record, 0, sizeof( ee.data_record ) ); + ee.record.reserved1 = 0xBEEFDEAD; + ee.record.record_number = 1000 - i; /* should get substituted */ + ee.record.time_generated = 0; + ee.record.time_written = 0; + ee.record.event_id = 500; + ee.record.event_type = 300; + ee.record.num_strings = 0; + ee.record.event_category = 0; + ee.record.reserved2 = ( i << 8 ) | i; + ee.record.closing_record_number = -1; + ee.record.string_offset = 0; + ee.record.user_sid_length = 0; + ee.record.user_sid_offset = 0; + ee.record.data_length = 0; + ee.record.data_offset = 0; + + rpcstr_push( ( void * ) ( ee.data_record.source_name ), + "SystemLog", + sizeof( ee.data_record.source_name ), + STR_TERMINATE ); + ee.data_record.source_name_len = + ( strlen_w( ee.data_record.source_name ) * 2 ) + 2; + + rpcstr_push( ( void * ) ( ee.data_record.computer_name ), + "DMLINUX", + sizeof( ee.data_record.computer_name ), + STR_TERMINATE ); + + ee.data_record.computer_name_len = + ( strlen_w( ee.data_record.computer_name ) * 2 ) + 2; + + write_eventlog_tdb( the_tdb, &ee ); + } +} +#endif /* UNUSED */ + +/******************************************************************** + ********************************************************************/ -void eventlog_refresh_external_parameters( NT_USER_TOKEN *token ) +static void refresh_eventlog_tdb_table( void ) { - const char **elogs = lp_eventlog_list(); - int i; + const char **elogs = lp_eventlog_list( ); + int i, j; if ( !elogs ) - return ; + return; - if ( !*lp_eventlog_control_cmd() ) + if ( !mem_ctx ) { + mem_ctx = talloc_init( "refresh_eventlog_tdb_table" ); + } + + if ( !mem_ctx ) { + DEBUG( 1, ( "Can't allocate memory\n" ) ); return; + } + + /* count them */ + for ( i = 0; elogs[i]; i++ ) { + } + /* number of logs in i */ + DEBUG( 10, ( "Number of eventlogs %d\n", i ) ); + /* check to see if we need to adjust our tables */ + + if ( ( ttdb != NULL ) ) { + if ( i != nlogs ) { + /* refresh the table, by closing and reconstructing */ + DEBUG( 10, ( "Closing existing table \n" ) ); + for ( j = 0; j < nlogs; j++ ) { + tdb_close( ttdb[j].log_tdb ); + } + TALLOC_FREE( ttdb ); + ttdb = NULL; + } else { /* i == nlogs */ + + for ( j = 0; j < nlogs; j++ ) { + if ( StrCaseCmp( ttdb[j].logname, elogs[i] ) ) { + /* something changed, have to discard */ + DEBUG( 10, + ( "Closing existing table \n" ) ); + for ( j = 0; j < nlogs; j++ ) { + tdb_close( ttdb[j].log_tdb ); + } + TALLOC_FREE( ttdb ); + ttdb = NULL; + break; + } + } + } + } - for ( i=0; elogs[i]; i++ ) { - - DEBUG(10,("eventlog_refresh_external_parameters: Refreshing =>[%s]\n", - elogs[i])); - - if ( !control_eventlog_hook( token, elogs[i] ) ) { - DEBUG(0,("eventlog_refresh_external_parameters: failed to refresh [%s]\n", - elogs[i])); + /* note that this might happen because of above */ + if ( ( i > 0 ) && ( ttdb == NULL ) ) { + /* alloc the room */ + DEBUG( 10, ( "Creating the table\n" ) ); + ttdb = TALLOC( mem_ctx, sizeof( EventlogTDBInfo ) * i ); + if ( !ttdb ) { + DEBUG( 10, + ( "Can't allocate table for tdb handles \n" ) ); + return; } - } - - return; + for ( j = 0; j < i; j++ ) { + pstrcpy( ttdb[j].tdbfname, + lock_path( mk_tdbfilename + ( ttdb[j].tdbfname, + ( char * ) elogs[j], + sizeof( pstring ) ) ) ); + pstrcpy( ttdb[j].logname, elogs[j] ); + DEBUG( 10, ( "Opening tdb for %s\n", elogs[j] ) ); + ttdb[j].log_tdb = + open_eventlog_tdb( ttdb[j].tdbfname ); + } + } + nlogs = i; } /******************************************************************** -********************************************************************/ + ********************************************************************/ -static void free_eventlog_info(void *ptr) +TDB_CONTEXT *tdb_of( char *eventlog_name ) +{ + int i; + + if ( !eventlog_name ) + return NULL; + + if ( !ttdb ) { + DEBUG( 10, ( "Refreshing list of eventlogs\n" ) ); + refresh_eventlog_tdb_table( ); + + if ( !ttdb ) { + DEBUG( 10, + ( "eventlog tdb table is NULL after a refresh!\n" ) ); + return NULL; + } + } + + DEBUG( 10, ( "Number of eventlogs %d\n", nlogs ) ); + + for ( i = 0; i < nlogs; i++ ) { + if ( strequal( eventlog_name, ttdb[i].logname ) ) + return ttdb[i].log_tdb; + } + + return NULL; +} + + +/******************************************************************** + For the given tdb, get the next eventlog record into the passed + Eventlog_entry. returns NULL if it can't get the record for some reason. + ********************************************************************/ + +Eventlog_entry *get_eventlog_record( prs_struct * ps, TDB_CONTEXT * tdb, + int recno, Eventlog_entry * ee ) +{ + TDB_DATA ret, key; + + int srecno; + int reclen; + int len; + uint8 *rbuff; + + pstring *wpsource, *wpcomputer, *wpsid, *wpstrs, *puserdata; + + key.dsize = sizeof( int32 ); + rbuff = NULL; + + srecno = recno; + key.dptr = ( char * ) &srecno; + + ret = tdb_fetch( tdb, key ); + + if ( ret.dsize == 0 ) { + DEBUG( 8, + ( "Can't find a record for the key, record %d\n", + recno ) ); + return NULL; + } + + len = tdb_unpack( ret.dptr, ret.dsize, "d", &reclen ); + + DEBUG( 10, ( "Unpacking record %d, size is %d\n", srecno, len ) ); + + if ( !len ) + return NULL; + + /* ee = PRS_ALLOC_MEM(ps, Eventlog_entry, 1); */ + + if ( !ee ) + return NULL; + + len = tdb_unpack( ret.dptr, ret.dsize, "ddddddwwwwddddddBBdBBBd", + &ee->record.length, &ee->record.reserved1, + &ee->record.record_number, + &ee->record.time_generated, + &ee->record.time_written, &ee->record.event_id, + &ee->record.event_type, &ee->record.num_strings, + &ee->record.event_category, &ee->record.reserved2, + &ee->record.closing_record_number, + &ee->record.string_offset, + &ee->record.user_sid_length, + &ee->record.user_sid_offset, + &ee->record.data_length, &ee->record.data_offset, + &ee->data_record.source_name_len, &wpsource, + &ee->data_record.computer_name_len, &wpcomputer, + &ee->data_record.sid_padding, + &ee->record.user_sid_length, &wpsid, + &ee->data_record.strings_len, &wpstrs, + &ee->data_record.user_data_len, &puserdata, + &ee->data_record.data_padding ); + DEBUG( 10, + ( "Read record %d, len in tdb was %d\n", + ee->record.record_number, len ) ); + + /* have to do the following because the tdb_unpack allocs a buff, stuffs a pointer to the buff + into it's 2nd argment for 'B' */ + + if ( wpcomputer ) + memcpy( ee->data_record.computer_name, wpcomputer, + ee->data_record.computer_name_len ); + if ( wpsource ) + memcpy( ee->data_record.source_name, wpsource, + ee->data_record.source_name_len ); + + if ( wpsid ) + memcpy( ee->data_record.sid, wpsid, + ee->record.user_sid_length ); + if ( wpstrs ) + memcpy( ee->data_record.strings, wpstrs, + ee->data_record.strings_len ); + + /* note that userdata is a pstring */ + if ( puserdata ) + memcpy( ee->data_record.user_data, puserdata, + ee->data_record.user_data_len ); + + SAFE_FREE( wpcomputer ); + SAFE_FREE( wpsource ); + SAFE_FREE( wpsid ); + SAFE_FREE( wpstrs ); + SAFE_FREE( puserdata ); + + DEBUG( 10, ( "get_eventlog_record: read back %d\n", len ) ); + DEBUG( 10, + ( "get_eventlog_record: computer_name %d is ", + ee->data_record.computer_name_len ) ); + SAFE_FREE( ret.dptr ); + return ee; +} + +/******************************************************************** + ********************************************************************/ + +static void free_eventlog_info( void *ptr ) { TALLOC_FREE( ptr ); } /******************************************************************** -********************************************************************/ + ********************************************************************/ -static EventlogInfo *find_eventlog_info_by_hnd(pipes_struct *p, POLICY_HND *handle) +static EventlogInfo *find_eventlog_info_by_hnd( pipes_struct * p, + POLICY_HND * handle ) { EventlogInfo *info; - - if ( !find_policy_by_hnd(p,handle,(void **)&info) ) { - DEBUG(2,("find_eventlog_info_by_hnd: eventlog not found.\n")); + + if ( !find_policy_by_hnd( p, handle, ( void ** ) &info ) ) { + DEBUG( 2, + ( "find_eventlog_info_by_hnd: eventlog not found.\n" ) ); return NULL; } @@ -87,144 +340,85 @@ static EventlogInfo *find_eventlog_info_by_hnd(pipes_struct *p, POLICY_HND *hand } /******************************************************************** - Callout to control the specified event log - passing out only - the MaxSize and Retention values, along with eventlog name - uses smbrun... - INPUT: - OUTPUT: nothing -********************************************************************/ + note that this can only be called AFTER the table is constructed, + since it uses the table to find the tdb handle + ********************************************************************/ -BOOL control_eventlog_hook(NT_USER_TOKEN *token, const char *elogname ) +static BOOL sync_eventlog_params( const char *elogname ) { - char *cmd = lp_eventlog_control_cmd(); - pstring command; - int ret; - int fd = -1; - uint32 uiMaxSize, uiRetention; pstring path; + uint32 uiMaxSize; + uint32 uiRetention; REGISTRY_KEY *keyinfo; REGISTRY_VALUE *val; REGVAL_CTR *values; WERROR wresult; + TDB_CONTEXT *the_tdb; + + the_tdb = tdb_of( ( char * ) elogname ); + + DEBUG( 4, ( "sync_eventlog_params with %s\n", elogname ) ); - if ( !cmd || !*cmd ) { - DEBUG(0, ("control_eventlog_hook: No \"eventlog control command\" defined in smb.conf!\n")); + if ( !the_tdb ) { + DEBUG( 4, ( "Can't open tdb for %s\n", elogname ) ); return False; } - /* set resonable defaults. 512Kb on size and 1 week on time */ - + uiMaxSize = 0x80000; uiRetention = 604800; - + /* the general idea is to internally open the registry key and retreive the values. That way we can continue to use the same fetch/store api that we use in srv_reg_nt.c */ pstr_sprintf( path, "%s/%s", KEY_EVENTLOG, elogname ); - wresult = regkey_open_internal( &keyinfo, path, token, REG_KEY_READ ); - + + wresult = + regkey_open_internal( &keyinfo, path, get_root_nt_token( ), + REG_KEY_READ ); + if ( !W_ERROR_IS_OK( wresult ) ) { - DEBUG(4,("control_eventlog_hook: Failed to open key [%s] (%s)\n", - path, dos_errstr(wresult) )); + DEBUG( 4, + ( "sync_eventlog_params: Failed to open key [%s] (%s)\n", + path, dos_errstr( wresult ) ) ); return False; } - - if ( !(values = TALLOC_ZERO_P( keyinfo, REGVAL_CTR )) ) { + + if ( !( values = TALLOC_ZERO_P( keyinfo, REGVAL_CTR ) ) ) { TALLOC_FREE( keyinfo ); - DEBUG(0,("control_eventlog_hook: talloc() failed!\n")); - + DEBUG( 0, ( "control_eventlog_hook: talloc() failed!\n" ) ); + return False; } fetch_reg_values( keyinfo, values ); - - if ( (val = regval_ctr_getvalue( values, "Retention" )) != NULL ) - uiRetention = IVAL( regval_data_p(val), 0 ); - if ( (val = regval_ctr_getvalue( values, "MaxSize" )) != NULL ) - uiMaxSize = IVAL( regval_data_p(val), 0 ); - - TALLOC_FREE( keyinfo ); - - /* now run the command */ + if ( ( val = regval_ctr_getvalue( values, "Retention" ) ) != NULL ) + uiRetention = IVAL( regval_data_p( val ), 0 ); - pstr_sprintf(command, "%s \"%s\" %u %u", cmd, elogname, uiRetention, uiMaxSize ); + if ( ( val = regval_ctr_getvalue( values, "MaxSize" ) ) != NULL ) + uiMaxSize = IVAL( regval_data_p( val ), 0 ); - DEBUG(10, ("control_eventlog_hook: Running [%s]\n", command)); - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); + TALLOC_FREE( keyinfo ); - if ( ret != 0 ) { - DEBUG(10,("control_eventlog_hook: Command returned [%d]\n", ret)); - if (fd != -1 ) - close(fd); - return False; - } + tdb_store_int32( the_tdb, VN_maxsize, uiMaxSize ); + tdb_store_int32( the_tdb, VN_retention, uiRetention ); - close(fd); return True; } - /******************************************************************** -********************************************************************/ + ********************************************************************/ -/** - * Callout to open the specified event log - * - * smbrun calling convention -- - * INPUT: - * OUTPUT: the string "SUCCESS" if the command succeeded - * no such string if there was a failure. - */ -static BOOL open_eventlog_hook( EventlogInfo *info ) +static BOOL open_eventlog_hook( EventlogInfo * info ) { - char *cmd = lp_eventlog_open_cmd(); - char **qlines; - pstring command; - int numlines = 0; - int ret; - int fd = -1; - - if ( !cmd || !*cmd ) { - DEBUG(0, ("Must define an \"eventlog open command\" entry in the config.\n")); - return False; - } - - pstr_sprintf(command, "%s \"%s\"", cmd, info->logname ); - - DEBUG(10, ("Running [%s]\n", command)); - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - - if(ret != 0) { - if(fd != -1) { - close(fd); - } - return False; - } - - qlines = fd_lines_load(fd, &numlines); - DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); - close(fd); - - if(numlines) { - DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); - if(0 == strncmp(qlines[0], "SUCCESS", strlen("SUCCESS"))) { - DEBUGADD(10, ("Able to open [%s].\n", info->logname)); - file_lines_free(qlines); - return True; - } - } - - file_lines_free(qlines); - - return False; + return True; } /******************************************************************** ********************************************************************/ + /** * Callout to get the number of records in the specified event log * @@ -234,50 +428,49 @@ static BOOL open_eventlog_hook( EventlogInfo *info ) * entries in the log. If there are no entries in the log, return 0. */ -static BOOL get_num_records_hook(EventlogInfo *info) + +static BOOL get_num_records_hook( EventlogInfo * info ) { - char *cmd = lp_eventlog_num_records_cmd(); - char **qlines; - pstring command; - int numlines = 0; - int ret; - int fd = -1; - - if ( !cmd || !*cmd ) { - DEBUG(0, ("Must define an \"eventlog num records command\" entry in the config.\n")); - return False; - } - pstr_sprintf( command, "%s \"%s\"", cmd, info->logname ); + TDB_CONTEXT *the_tdb = NULL; + int next_record; + int oldest_record; - DEBUG(10, ("Running [%s]\n", command)); - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - if(ret != 0) { - if(fd != -1) { - close(fd); - } + the_tdb = tdb_of( info->logname ); + + if ( !the_tdb ) { + DEBUG( 10, ( "Can't find tdb for %s\n", info->logname ) ); + info->num_records = 0; return False; } - qlines = fd_lines_load(fd, &numlines); - DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); - close(fd); + /* lock */ + tdb_lock_bystring( the_tdb, VN_next_record, 1 ); + + + /* read */ + next_record = tdb_fetch_int32( the_tdb, VN_next_record ); + oldest_record = tdb_fetch_int32( the_tdb, VN_oldest_entry ); + + + + DEBUG( 8, + ( "Oldest Record %d Next Record %d\n", oldest_record, + next_record ) ); + + info->num_records = ( next_record - oldest_record ); + info->oldest_entry = oldest_record; + tdb_unlock_bystring( the_tdb, VN_next_record ); + + + return True; - if(numlines) { - DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); - sscanf(qlines[0], "%d", &(info->num_records)); - file_lines_free(qlines); - return True; - } - file_lines_free(qlines); - return False; } /******************************************************************** -********************************************************************/ + ********************************************************************/ /** * Callout to find the oldest record in the log @@ -289,50 +482,17 @@ static BOOL get_num_records_hook(EventlogInfo *info) * If there are no entries in the log, returns a 0 */ -static BOOL get_oldest_entry_hook(EventlogInfo *info) +static BOOL get_oldest_entry_hook( EventlogInfo * info ) { - char *cmd = lp_eventlog_oldest_record_cmd(); - char **qlines; - pstring command; - int numlines = 0; - int ret; - int fd = -1; - - if ( !cmd || !*cmd ) { - DEBUG(0, ("Must define an \"eventlog oldest record command\" entry in the config.\n")); - return False; - } - - pstr_sprintf( command, "%s \"%s\"", cmd, info->logname ); - - DEBUG(10, ("Running [%s]\n", command)); - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - if(ret != 0) { - if(fd != -1) { - close(fd); - } - return False; - } - - qlines = fd_lines_load(fd, &numlines); - DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); - close(fd); - - if(numlines) { - DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); - sscanf(qlines[0], "%d", &(info->oldest_entry)); - file_lines_free(qlines); - return True; - } - - file_lines_free(qlines); - return False; + /* it's the same thing */ + return get_num_records_hook( info ); } + /******************************************************************** -********************************************************************/ + ********************************************************************/ + /** * Callout to close the specified event log * @@ -342,323 +502,51 @@ static BOOL get_oldest_entry_hook(EventlogInfo *info) * no such string if there was a failure. */ -static BOOL close_eventlog_hook(EventlogInfo *info) -{ - char *cmd = lp_eventlog_close_cmd(); - char **qlines; - pstring command; - int numlines = 0; - int ret; - int fd = -1; - - if ( !cmd || !*cmd ) { - DEBUG(0, ("Must define an \"eventlog close command\" entry in the config.\n")); - return False; - } - - pstr_sprintf( command, "%s \"%s\"", cmd, info->logname ); - - DEBUG(10, ("Running [%s]\n", command)); - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - - if(ret != 0) { - if(fd != -1) { - close(fd); - } - return False; - } - - qlines = fd_lines_load(fd, &numlines); - DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); - close(fd); - - if(numlines) { - DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); - if(0 == strncmp(qlines[0], "SUCCESS", 7)) { - DEBUGADD(10, ("Able to close [%s].\n", info->logname)); - file_lines_free(qlines); - return True; - } - } - - file_lines_free(qlines); - return False; -} - -/******************************************************************** -********************************************************************/ - -static BOOL parse_logentry(char *line, Eventlog_entry *entry, BOOL *eor) +static BOOL close_eventlog_hook( EventlogInfo * info ) { - char *start = NULL, *stop = NULL; - pstring temp; - int temp_len = 0, i; - - start = line; - /* empty line signyfiying record delimeter, or we're at the end of the buffer */ - if(start == NULL || strlen(start) == 0) { - DEBUG(6, ("parse_logentry: found end-of-record indicator.\n")); - *eor = True; - return True; - } - if(!(stop = strchr(line, ':'))) { - return False; - } - - DEBUG(6, ("parse_logentry: trying to parse [%s].\n", line)); - - if(0 == strncmp(start, "LEN", stop - start)) { - /* This will get recomputed later anyway -- probably not necessary */ - entry->record.length = atoi(stop + 1); - } else if(0 == strncmp(start, "RS1", stop - start)) { - /* For now all these reserved entries seem to have the same value, - which can be hardcoded to int(1699505740) for now */ - entry->record.reserved1 = atoi(stop + 1); - } else if(0 == strncmp(start, "RCN", stop - start)) { - entry->record.record_number = atoi(stop + 1); - } else if(0 == strncmp(start, "TMG", stop - start)) { - entry->record.time_generated = atoi(stop + 1); - } else if(0 == strncmp(start, "TMW", stop - start)) { - entry->record.time_written = atoi(stop + 1); - } else if(0 == strncmp(start, "EID", stop - start)) { - entry->record.event_id = atoi(stop + 1); - } else if(0 == strncmp(start, "ETP", stop - start)) { - if(strstr(start, "ERROR")) { - entry->record.event_type = EVENTLOG_ERROR_TYPE; - } else if(strstr(start, "WARNING")) { - entry->record.event_type = EVENTLOG_WARNING_TYPE; - } else if(strstr(start, "INFO")) { - entry->record.event_type = EVENTLOG_INFORMATION_TYPE; - } else if(strstr(start, "AUDIT_SUCCESS")) { - entry->record.event_type = EVENTLOG_AUDIT_SUCCESS; - } else if(strstr(start, "AUDIT_FAILURE")) { - entry->record.event_type = EVENTLOG_AUDIT_FAILURE; - } else if(strstr(start, "SUCCESS")) { - entry->record.event_type = EVENTLOG_SUCCESS; - } else { - /* some other eventlog type -- currently not defined in MSDN docs, so error out */ - return False; - } - } -/* - else if(0 == strncmp(start, "NST", stop - start)) - { - entry->record.num_strings = atoi(stop + 1); - } -*/ - else if(0 == strncmp(start, "ECT", stop - start)) { - entry->record.event_category = atoi(stop + 1); - } else if(0 == strncmp(start, "RS2", stop - start)) { - entry->record.reserved2 = atoi(stop + 1); - } else if(0 == strncmp(start, "CRN", stop - start)) { - entry->record.closing_record_number = atoi(stop + 1); - } else if(0 == strncmp(start, "USL", stop - start)) { - entry->record.user_sid_length = atoi(stop + 1); - } else if(0 == strncmp(start, "SRC", stop - start)) { - memset(temp, 0, sizeof(temp)); - stop++; - while(isspace(stop[0])) { - stop++; - } - temp_len = strlen(stop); - strncpy(temp, stop, temp_len); - rpcstr_push((void *)(entry->data_record.source_name), temp, - sizeof(entry->data_record.source_name), STR_TERMINATE); - entry->data_record.source_name_len = (strlen_w(entry->data_record.source_name)* 2) + 2; - } else if(0 == strncmp(start, "SRN", stop - start)) { - memset(temp, 0, sizeof(temp)); - stop++; - while(isspace(stop[0])) { - stop++; - } - temp_len = strlen(stop); - strncpy(temp, stop, temp_len); - rpcstr_push((void *)(entry->data_record.computer_name), temp, - sizeof(entry->data_record.computer_name), STR_TERMINATE); - entry->data_record.computer_name_len = (strlen_w(entry->data_record.computer_name)* 2) + 2; - } else if(0 == strncmp(start, "SID", stop - start)) { - memset(temp, 0, sizeof(temp)); - stop++; - while(isspace(stop[0])) { - stop++; - } - temp_len = strlen(stop); - strncpy(temp, stop, temp_len); - rpcstr_push((void *)(entry->data_record.sid), temp, - sizeof(entry->data_record.sid), STR_TERMINATE); - entry->record.user_sid_length = (strlen_w(entry->data_record.sid) * 2) + 2; - } else if(0 == strncmp(start, "STR", stop - start)) { - /* skip past initial ":" */ - stop++; - /* now skip any other leading whitespace */ - while(isspace(stop[0])) { - stop++; - } - temp_len = strlen(stop); - memset(temp, 0, sizeof(temp)); - strncpy(temp, stop, temp_len); - rpcstr_push((void *)(entry->data_record.strings + entry->data_record.strings_len), - temp, - sizeof(entry->data_record.strings) - entry->data_record.strings_len, - STR_TERMINATE); - entry->data_record.strings_len += temp_len + 1; - fprintf(stderr, "Dumping strings:\n"); - for(i = 0; i < entry->data_record.strings_len; i++) { - fputc((char)entry->data_record.strings[i], stderr); - } - fprintf(stderr, "\nDone\n"); - entry->record.num_strings++; - } else if(0 == strncmp(start, "DAT", stop - start)) { - /* Now that we're done processing the STR data, adjust the length to account for - unicode, then proceed with the DAT data. */ - entry->data_record.strings_len *= 2; - /* skip past initial ":" */ - stop++; - /* now skip any other leading whitespace */ - while(isspace(stop[0])) { - stop++; - } - entry->data_record.user_data_len = strlen(stop); - memset(entry->data_record.user_data, 0, sizeof(entry->data_record.user_data)); - if(entry->data_record.user_data_len > 0) { - /* copy no more than the first 1024 bytes */ - if(entry->data_record.user_data_len > sizeof(entry->data_record.user_data)) - entry->data_record.user_data_len = sizeof(entry->data_record.user_data); - memcpy(entry->data_record.user_data, stop, entry->data_record.user_data_len); - } - } else { - /* some other eventlog entry -- not implemented, so dropping on the floor */ - DEBUG(10, ("Unknown entry [%s]. Ignoring.\n", line)); - /* For now return true so that we can keep on parsing this mess. Eventually - we will return False here. */ - return True; - } return True; } /******************************************************************** -********************************************************************/ - -/** - * Callout to read entries from the specified event log - * - * smbrun calling convention -- - * INPUT: - * where direction is either "forward" or "backward", the starting record is somewhere - * between the oldest_record and oldest_record+num_records, and the buffer size is the - * maximum size of the buffer that the client can accomodate. - * OUTPUT: A buffer containing a set of entries, one to a line, of the format: - * Multiple log entries can be contained in the buffer, delimited by an empty line - * line type:line data - * These are the allowed line types: - * RS1:(uint32) - reserved. All M$ entries seem to have int(1699505740) for now - * RCN:(uint32) - record number of the record, however it may be calculated by the script - * TMG:(uint32) - time generated, seconds since January 1, 1970, 0000 UTC - * TMW:(uint32) - time written, seconds since January 1, 1970, 0000 UTC - * EID:(uint32) - eventlog source defined event identifier. If there's a stringfile for the event, it is an index into that - * ETP:(uint16) - eventlog type - one of ERROR, WARNING, INFO, AUDIT_SUCCESS, AUDIT_FAILURE - * ECT:(uint16) - event category - depends on the eventlog generator... - * RS2:(uint16) - reserved, make it 0000 - * CRN:(uint32) - reserved, make it 00000000 for now - * USL:(uint32) - user SID length. No sid? Make this 0. Must match SID below - * SRC:[(uint8)] - Name of the source, for example ccPwdSvc, in hex bytes. Can not be multiline. - * SRN:[(uint8)] - Name of the computer on which this is generated, the short hostname usually. - * SID:[(uint8)] - User sid if one exists. Must be present even if there is no SID. - * STR:[(uint8)] - String data. One string per line. Multiple strings can be specified using consecutive "STR" lines, - * up to a total aggregate string length of 1024 characters. - * DAT:[(uint8)] - The user-defined data portion of the event log. Can not be multiple lines. - * - end-of-record indicator - */ - -static BOOL read_eventlog_hook(EventlogInfo *info, Eventlog_entry *entry, - const char *direction, int starting_record, - int buffer_size, BOOL *eof, - char ***buffer, int *numlines) -{ - char *cmd = lp_eventlog_read_cmd(); - pstring command; - int ret; - int fd = -1; - - if ( !info ) - return False; - - if ( !cmd || !*cmd ) { - DEBUG(0, ("Must define an \"eventlog read command\" entry in the config.\n")); - return False; - } - - pstr_sprintf( command, "%s \"%s\" %s %d %d", - cmd, info->logname, direction, starting_record, buffer_size ); - - *numlines = 0; - - DEBUG(10, ("Running [%s]\n", command)); - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - - if(ret != 0) { - if(fd != -1) { - close(fd); - } - return False; - } - - *buffer = fd_lines_load(fd, numlines); - DEBUGADD(10, ("Lines returned = [%d]\n", *numlines)); - close(fd); - - if(*numlines) { - /* - for(i = 0; i < numlines; i++) - { - DEBUGADD(10, ("Line[%d] = %s\n", i, qlines[i])); - parse_logentry(qlines[i], entry); - } - file_lines_free(qlines); - */ - *eof = False; - return True; - } - *eof = True; - -/* file_lines_free(qlines);*/ - return False; -} - -/******************************************************************** -********************************************************************/ + ********************************************************************/ -static Eventlog_entry *read_package_entry(prs_struct *ps, - EVENTLOG_Q_READ_EVENTLOG *q_u, - EVENTLOG_R_READ_EVENTLOG *r_u, - Eventlog_entry *entry) +static Eventlog_entry *read_package_entry( prs_struct * ps, + EVENTLOG_Q_READ_EVENTLOG * q_u, + EVENTLOG_R_READ_EVENTLOG * r_u, + Eventlog_entry * entry ) { uint8 *offset; Eventlog_entry *ee_new = NULL; - ee_new = PRS_ALLOC_MEM(ps, Eventlog_entry, 1); - if(ee_new == NULL) { + ee_new = PRS_ALLOC_MEM( ps, Eventlog_entry, 1 ); + if ( ee_new == NULL ) { return NULL; } - entry->data_record.sid_padding = ((4 - ((entry->data_record.source_name_len - + entry->data_record.computer_name_len) % 4)) %4); - entry->data_record.data_padding = (4 - ((entry->data_record.strings_len - + entry->data_record.user_data_len) % 4)) % 4; - entry->record.length = sizeof(Eventlog_record); + entry->data_record.sid_padding = + ( ( 4 - + ( ( entry->data_record.source_name_len + + entry->data_record.computer_name_len ) % 4 ) ) % 4 ); + entry->data_record.data_padding = + ( 4 - + ( ( entry->data_record.strings_len + + entry->data_record.user_data_len ) % 4 ) ) % 4; + entry->record.length = sizeof( Eventlog_record ); entry->record.length += entry->data_record.source_name_len; entry->record.length += entry->data_record.computer_name_len; - if(entry->record.user_sid_length == 0) { + if ( entry->record.user_sid_length == 0 ) { /* Should not pad to a DWORD boundary for writing out the sid if there is no SID, so just propagate the padding to pad the data */ - entry->data_record.data_padding += entry->data_record.sid_padding; + entry->data_record.data_padding += + entry->data_record.sid_padding; entry->data_record.sid_padding = 0; } - DEBUG(10, ("sid_padding is [%d].\n", entry->data_record.sid_padding)); - DEBUG(10, ("data_padding is [%d].\n", entry->data_record.data_padding)); + DEBUG( 10, + ( "sid_padding is [%d].\n", entry->data_record.sid_padding ) ); + DEBUG( 10, + ( "data_padding is [%d].\n", + entry->data_record.data_padding ) ); entry->record.length += entry->data_record.sid_padding; entry->record.length += entry->record.user_sid_length; @@ -666,66 +554,82 @@ static Eventlog_entry *read_package_entry(prs_struct *ps, entry->record.length += entry->data_record.user_data_len; entry->record.length += entry->data_record.data_padding; /* need another copy of length at the end of the data */ - entry->record.length += sizeof(entry->record.length); - DEBUG(10, ("entry->record.length is [%d].\n", entry->record.length)); - entry->data = PRS_ALLOC_MEM(ps, uint8, entry->record.length - sizeof(Eventlog_record) - sizeof(entry->record.length)); - if(entry->data == NULL) { + entry->record.length += sizeof( entry->record.length ); + DEBUG( 10, + ( "entry->record.length is [%d].\n", entry->record.length ) ); + entry->data = + PRS_ALLOC_MEM( ps, uint8, + entry->record.length - + sizeof( Eventlog_record ) - + sizeof( entry->record.length ) ); + if ( entry->data == NULL ) { return NULL; } offset = entry->data; - memcpy(offset, &(entry->data_record.source_name), entry->data_record.source_name_len); + memcpy( offset, &( entry->data_record.source_name ), + entry->data_record.source_name_len ); offset += entry->data_record.source_name_len; - memcpy(offset, &(entry->data_record.computer_name), entry->data_record.computer_name_len); + memcpy( offset, &( entry->data_record.computer_name ), + entry->data_record.computer_name_len ); offset += entry->data_record.computer_name_len; /* SID needs to be DWORD-aligned */ offset += entry->data_record.sid_padding; - entry->record.user_sid_offset = sizeof(Eventlog_record) + (offset - entry->data); - memcpy(offset, &(entry->data_record.sid), entry->record.user_sid_length); + entry->record.user_sid_offset = + sizeof( Eventlog_record ) + ( offset - entry->data ); + memcpy( offset, &( entry->data_record.sid ), + entry->record.user_sid_length ); offset += entry->record.user_sid_length; /* Now do the strings */ - entry->record.string_offset = sizeof(Eventlog_record) + (offset - entry->data); - memcpy(offset, &(entry->data_record.strings), entry->data_record.strings_len); + entry->record.string_offset = + sizeof( Eventlog_record ) + ( offset - entry->data ); + memcpy( offset, &( entry->data_record.strings ), + entry->data_record.strings_len ); offset += entry->data_record.strings_len; /* Now do the data */ entry->record.data_length = entry->data_record.user_data_len; - entry->record.data_offset = sizeof(Eventlog_record) + (offset - entry->data); - memcpy(offset, &(entry->data_record.user_data), entry->data_record.user_data_len); + entry->record.data_offset = + sizeof( Eventlog_record ) + ( offset - entry->data ); + memcpy( offset, &( entry->data_record.user_data ), + entry->data_record.user_data_len ); offset += entry->data_record.user_data_len; - memcpy(&(ee_new->record), &entry->record, sizeof(Eventlog_record)); - memcpy(&(ee_new->data_record), &entry->data_record, sizeof(Eventlog_data_record)); + memcpy( &( ee_new->record ), &entry->record, + sizeof( Eventlog_record ) ); + memcpy( &( ee_new->data_record ), &entry->data_record, + sizeof( Eventlog_data_record ) ); ee_new->data = entry->data; return ee_new; } /******************************************************************** -********************************************************************/ + ********************************************************************/ -static BOOL add_record_to_resp(EVENTLOG_R_READ_EVENTLOG *r_u, Eventlog_entry *ee_new) +static BOOL add_record_to_resp( EVENTLOG_R_READ_EVENTLOG * r_u, + Eventlog_entry * ee_new ) { Eventlog_entry *insert_point; - insert_point=r_u->entry; + insert_point = r_u->entry; - if (NULL == insert_point) { + if ( NULL == insert_point ) { r_u->entry = ee_new; ee_new->next = NULL; } else { - while ((NULL != insert_point->next)) { - insert_point=insert_point->next; + while ( ( NULL != insert_point->next ) ) { + insert_point = insert_point->next; } ee_new->next = NULL; insert_point->next = ee_new; } - r_u->num_records++; + r_u->num_records++; r_u->num_bytes_in_resp += ee_new->record.length; return True; } /******************************************************************** -********************************************************************/ + ********************************************************************/ /** * Callout to clear (and optionally backup) a specified event log @@ -741,128 +645,153 @@ static BOOL add_record_to_resp(EVENTLOG_R_READ_EVENTLOG *r_u, Eventlog_entry *ee * The given log is copied to that location on the server. See comments for * eventlog_io_q_clear_eventlog for info about odd file name behavior */ - -static BOOL clear_eventlog_hook(EventlogInfo *info, pstring backup_file_name) +static BOOL clear_eventlog_hook( EventlogInfo * info, + pstring backup_file_name ) { - char *cmd = lp_eventlog_clear_cmd(); - char **qlines; - pstring command; - int numlines = 0; - int ret; - int fd = -1; - - if ( !cmd || !*cmd ) { - DEBUG(0, ("Must define an \"eventlog clear command\" entry in the config.\n")); - return False; - } - if ( strlen(backup_file_name) ) - pstr_sprintf( command, "%s \"%s\" \"%s\"", cmd, info->logname, backup_file_name ); - else - pstr_sprintf( command, "%s \"%s\"", cmd, info->logname ); + int i; - DEBUG(10, ("Running [%s]\n", command)); - ret = smbrun(command, &fd); - DEBUGADD(10, ("returned [%d]\n", ret)); - if(ret != 0) { - if(fd != -1) { - close(fd); - } + if ( !info ) return False; - } - - qlines = fd_lines_load(fd, &numlines); - DEBUGADD(10, ("Lines returned = [%d]\n", numlines)); - close(fd); - - if(numlines) { - DEBUGADD(10, ("Line[0] = [%s]\n", qlines[0])); - if(0 == strncmp(qlines[0], "SUCCESS", strlen("SUCCESS"))) { - DEBUGADD(10, ("Able to clear [%s].\n", info->logname)); - file_lines_free(qlines); + DEBUG( 3, ( "There are %d event logs\n", nlogs ) ); + for ( i = 0; i < nlogs; i++ ) { + DEBUG( 3, + ( "Comparing Eventlog %s, %s\n", info->logname, + ttdb[i].logname ) ); + if ( !StrCaseCmp( info->logname, ttdb[i].logname ) ) { + /* close the current one, reinit */ + tdb_close( ttdb[i].log_tdb ); + DEBUG( 3, + ( "Closing Eventlog %s, file-on-disk %s\n", + info->logname, ttdb[i].tdbfname ) ); + ttdb[i].log_tdb = + init_eventlog_tdb( ttdb[i].tdbfname ); return True; } } - file_lines_free(qlines); - return False; + return False; /* not found */ + /* TODO- do something with the backup file name */ + } /******************************************************************* -*******************************************************************/ + *******************************************************************/ + +static int eventlog_size( char *eventlog_name ) +{ + TDB_CONTEXT *tdb; + + if ( !eventlog_name ) + return 0; + tdb = tdb_of( eventlog_name ); + if ( !tdb ) + return 0; + return eventlog_tdb_size( tdb, NULL, NULL ); +} + +/******************************************************************** + ********************************************************************/ -WERROR _eventlog_open_eventlog(pipes_struct *p, EVENTLOG_Q_OPEN_EVENTLOG *q_u, EVENTLOG_R_OPEN_EVENTLOG *r_u) +WERROR _eventlog_open_eventlog( pipes_struct * p, + EVENTLOG_Q_OPEN_EVENTLOG * q_u, + EVENTLOG_R_OPEN_EVENTLOG * r_u ) { EventlogInfo *info = NULL; fstring str; - - if ( !(info = TALLOC_ZERO_P(NULL, EventlogInfo)) ) + + if ( !( info = TALLOC_ZERO_P( NULL, EventlogInfo ) ) ) return WERR_NOMEM; - fstrcpy( str, global_myname() ); + fstrcpy( str, global_myname( ) ); if ( q_u->servername.string ) { - rpcstr_pull( str, q_u->servername.string->buffer, - sizeof(str), q_u->servername.string->uni_str_len*2, 0 ); - } + rpcstr_pull( str, q_u->servername.string->buffer, + sizeof( str ), + q_u->servername.string->uni_str_len * 2, 0 ); + } + info->servername = talloc_strdup( info, str ); fstrcpy( str, "Application" ); if ( q_u->logname.string ) { - rpcstr_pull( str, q_u->logname.string->buffer, - sizeof(str), q_u->logname.string->uni_str_len*2, 0 ); - } + rpcstr_pull( str, q_u->logname.string->buffer, + sizeof( str ), + q_u->logname.string->uni_str_len * 2, 0 ); + } + info->logname = talloc_strdup( info, str ); - DEBUG(10, ("_eventlog_open_eventlog: Using [%s] as the server name.\n", info->servername)); - DEBUG(10, ("_eventlog_open_eventlog: Using [%s] as the source log file.\n", info->logname)); + DEBUG( 1, + ( "Size of %s is %d\n", info->logname, + eventlog_size( info->logname ) ) ); - if ( !create_policy_hnd(p, &r_u->handle, free_eventlog_info, (void *)info) ) { - free_eventlog_info(info); + + + DEBUG( 10, + ( "_eventlog_open_eventlog: Using [%s] as the server name.\n", + info->servername ) ); + DEBUG( 10, + ( "_eventlog_open_eventlog: Using [%s] as the source log file.\n", + info->logname ) ); + + + if ( !create_policy_hnd + ( p, &r_u->handle, free_eventlog_info, ( void * ) info ) ) { + free_eventlog_info( info ); return WERR_NOMEM; } - - if ( !(open_eventlog_hook(info)) ) { - close_policy_hnd(p, &r_u->handle); + + if ( !open_eventlog_hook( info ) ) { + close_policy_hnd( p, &r_u->handle ); return WERR_BADFILE; } - + + sync_eventlog_params( info->logname ); + prune_eventlog( tdb_of( info->logname ) ); + return WERR_OK; } /******************************************************************** -********************************************************************/ + ********************************************************************/ -WERROR _eventlog_clear_eventlog(pipes_struct *p, EVENTLOG_Q_CLEAR_EVENTLOG *q_u, EVENTLOG_R_CLEAR_EVENTLOG *r_u) +WERROR _eventlog_clear_eventlog( pipes_struct * p, + EVENTLOG_Q_CLEAR_EVENTLOG * q_u, + EVENTLOG_R_CLEAR_EVENTLOG * r_u ) { - EventlogInfo *info = find_eventlog_info_by_hnd(p, &q_u->handle); + EventlogInfo *info = find_eventlog_info_by_hnd( p, &q_u->handle ); pstring backup_file_name; pstrcpy( backup_file_name, "" ); - if ( q_u->backupfile.string ) - unistr2_to_ascii(backup_file_name, q_u->backupfile.string, sizeof(backup_file_name)); + if ( q_u->backupfile.string ) + unistr2_to_ascii( backup_file_name, q_u->backupfile.string, + sizeof( backup_file_name ) ); - DEBUG(10, ("_eventlog_clear_eventlog: Using [%s] as the backup file name for log [%s].", - backup_file_name, info->logname)); + DEBUG( 10, + ( "_eventlog_clear_eventlog: Using [%s] as the backup file name for log [%s].", + backup_file_name, info->logname ) ); - if ( !(clear_eventlog_hook(info, backup_file_name)) ) + if ( !( clear_eventlog_hook( info, backup_file_name ) ) ) return WERR_BADFILE; return WERR_OK; } /******************************************************************** -********************************************************************/ + ********************************************************************/ -WERROR _eventlog_close_eventlog(pipes_struct *p, EVENTLOG_Q_CLOSE_EVENTLOG *q_u, EVENTLOG_R_CLOSE_EVENTLOG *r_u) +WERROR _eventlog_close_eventlog( pipes_struct * p, + EVENTLOG_Q_CLOSE_EVENTLOG * q_u, + EVENTLOG_R_CLOSE_EVENTLOG * r_u ) { - EventlogInfo *info = find_eventlog_info_by_hnd(p,&q_u->handle); + EventlogInfo *info = find_eventlog_info_by_hnd( p, &q_u->handle ); - if ( !(close_eventlog_hook(info)) ) + if ( !( close_eventlog_hook( info ) ) ) return WERR_BADFILE; - if ( !(close_policy_hnd(p, &q_u->handle)) ) { + if ( !( close_policy_hnd( p, &q_u->handle ) ) ) { return WERR_BADFID; } @@ -870,76 +799,93 @@ WERROR _eventlog_close_eventlog(pipes_struct *p, EVENTLOG_Q_CLOSE_EVENTLOG *q_u, } /******************************************************************** -********************************************************************/ - -WERROR _eventlog_read_eventlog(pipes_struct *p, EVENTLOG_Q_READ_EVENTLOG *q_u, EVENTLOG_R_READ_EVENTLOG *r_u) + ********************************************************************/ + +WERROR _eventlog_read_eventlog( pipes_struct * p, + EVENTLOG_Q_READ_EVENTLOG * q_u, + EVENTLOG_R_READ_EVENTLOG * r_u ) { - EventlogInfo *info = find_eventlog_info_by_hnd(p, &q_u->handle); + EventlogInfo *info = find_eventlog_info_by_hnd( p, &q_u->handle ); Eventlog_entry entry, *ee_new; - BOOL eof = False, eor = False; - const char *direction = ""; + uint32 num_records_read = 0; prs_struct *ps; - int numlines, i; - char **buffer; + int bytes_left, record_number; + TDB_CONTEXT *the_tdb; + info->flags = q_u->flags; ps = &p->out_data.rdata; - if ( info->flags & EVENTLOG_FORWARDS_READ ) - direction = "forward"; - else if ( info->flags & EVENTLOG_BACKWARDS_READ ) - direction = "backward"; - if ( !(read_eventlog_hook(info, &entry, direction, q_u->offset, q_u->max_read_size, &eof, &buffer, &numlines)) ) { - if(eof == False) { - return WERR_NOMEM; - } + bytes_left = q_u->max_read_size; + the_tdb = tdb_of( info->logname ); + if ( !the_tdb ) { + /* todo handle the error */ + } + /* DEBUG(8,("Bytes left is %d\n",bytes_left)); */ + + + record_number = q_u->offset; + + while ( bytes_left > 0 ) { + if ( get_eventlog_record + ( ps, the_tdb, record_number, &entry ) ) { + DEBUG( 8, + ( "Retrieved record %d\n", record_number ) ); + /* Now see if there is enough room to add */ + if ( ( ee_new = + read_package_entry( ps, q_u, r_u, + &entry ) ) == NULL ) { + return WERR_NOMEM; - if(numlines > 0) { - ZERO_STRUCT(entry); - for(i = 0; i < numlines; i++) { - num_records_read = r_u->num_records; - DEBUGADD(10, ("Line[%d] = [%s]\n", i, buffer[i])); - parse_logentry(buffer[i], &entry, &eor); - if(eor == True) { - /* package ee_new entry */ - if((ee_new = read_package_entry(ps, q_u, r_u, &entry)) == NULL) { - SAFE_FREE(buffer); - return WERR_NOMEM; - } - /* Now see if there is enough room to add */ - if(r_u->num_bytes_in_resp + ee_new->record.length > q_u->max_read_size) { - r_u->bytes_in_next_record = ee_new->record.length; - /* response would be too big to fit in client-size buffer */ - break; - } - add_record_to_resp(r_u, ee_new); - ZERO_STRUCT(entry); - eor=False; - num_records_read = r_u->num_records - num_records_read; - DEBUG(10, ("_eventlog_read_eventlog: read [%d] records for a total of [%d] records using [%d] bytes out of a max of [%d].\n", - num_records_read, - r_u->num_records, - r_u->num_bytes_in_resp, - q_u->max_read_size)); } + + if ( r_u->num_bytes_in_resp + ee_new->record.length > + q_u->max_read_size ) { + r_u->bytes_in_next_record = + ee_new->record.length; + /* response would be too big to fit in client-size buffer */ + bytes_left = 0; + break; + } + add_record_to_resp( r_u, ee_new ); + bytes_left -= ee_new->record.length; + ZERO_STRUCT( entry ); + num_records_read = + r_u->num_records - num_records_read; + DEBUG( 10, + ( "_eventlog_read_eventlog: read [%d] records for a total of [%d] records using [%d] bytes out of a max of [%d].\n", + num_records_read, r_u->num_records, + r_u->num_bytes_in_resp, + q_u->max_read_size ) ); + } else { + DEBUG( 8, ( "get_eventlog_record returned NULL\n" ) ); + return WERR_NOMEM; /* wrong error - but return one anyway */ } - SAFE_FREE(buffer); - } + + if ( info->flags & EVENTLOG_FORWARDS_READ ) { + record_number++; + } else { + record_number--; + } + + } return WERR_OK; } /******************************************************************** -********************************************************************/ + ********************************************************************/ -WERROR _eventlog_get_oldest_entry(pipes_struct *p, EVENTLOG_Q_GET_OLDEST_ENTRY *q_u, EVENTLOG_R_GET_OLDEST_ENTRY *r_u) +WERROR _eventlog_get_oldest_entry( pipes_struct * p, + EVENTLOG_Q_GET_OLDEST_ENTRY * q_u, + EVENTLOG_R_GET_OLDEST_ENTRY * r_u ) { - EventlogInfo *info = find_eventlog_info_by_hnd(p, &q_u->handle); + EventlogInfo *info = find_eventlog_info_by_hnd( p, &q_u->handle ); - if ( !(get_oldest_entry_hook(info)) ) + if ( !( get_oldest_entry_hook( info ) ) ) return WERR_BADFILE; r_u->oldest_entry = info->oldest_entry; @@ -948,17 +894,18 @@ WERROR _eventlog_get_oldest_entry(pipes_struct *p, EVENTLOG_Q_GET_OLDEST_ENTRY * } /******************************************************************** -********************************************************************/ + ********************************************************************/ -WERROR _eventlog_get_num_records(pipes_struct *p, EVENTLOG_Q_GET_NUM_RECORDS *q_u, EVENTLOG_R_GET_NUM_RECORDS *r_u) +WERROR _eventlog_get_num_records( pipes_struct * p, + EVENTLOG_Q_GET_NUM_RECORDS * q_u, + EVENTLOG_R_GET_NUM_RECORDS * r_u ) { - EventlogInfo *info = find_eventlog_info_by_hnd(p, &q_u->handle); + EventlogInfo *info = find_eventlog_info_by_hnd( p, &q_u->handle ); - if ( !(get_num_records_hook(info)) ) + if ( !( get_num_records_hook( info ) ) ) return WERR_BADFILE; r_u->num_records = info->num_records; return WERR_OK; } - diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index 0bb9154aaf..79259174fd 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -80,11 +80,9 @@ WERROR _ntsvcs_get_device_list( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST *q_u, rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0); devicepath = get_device_path( device ); - /* From the packet traces I've see, I think this really should be an array - of UNISTR2's. But I've never seen more than one string in spite of the - fact that the string in double NULL terminated. -- jerry */ + /* This has to be DOUBLE NULL terminated */ - init_unistr2( &r_u->devicepath, devicepath, UNI_STR_TERMINATE ); + init_unistr2( &r_u->devicepath, devicepath, UNI_STR_DBLTERMINATE ); r_u->needed = r_u->devicepath.uni_str_len; return WERR_OK; diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 4db5ed0ed6..0ba3e04b99 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -293,9 +293,11 @@ WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY SEC_RIGHTS_CREATE_SUBKEY| SEC_RIGHTS_QUERY_VALUE| SEC_RIGHTS_SET_VALUE); - - if ( !(parent->access_granted & check_rights) ) + + if ( !(parent->access_granted & check_rights) ) { + DEBUG(8,("Rights check failed, parent had %04x, check_rights %04x\n",parent->access_granted, check_rights)); return WERR_ACCESS_DENIED; + } /* * very crazy, but regedit.exe on Win2k will attempt to call diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index e8df2acb22..19648f5e78 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -32,10 +32,21 @@ struct service_control_op { SERVICE_CONTROL_OPS *ops; }; -extern SERVICE_CONTROL_OPS spoolss_svc_ops; +#define SVCCTL_NUM_INTERNAL_SERVICES 4 + +/* handle external services */ extern SERVICE_CONTROL_OPS rcinit_svc_ops; + +/* builtin services (see service_db.c and services/svc_*.c */ +extern SERVICE_CONTROL_OPS spoolss_svc_ops; extern SERVICE_CONTROL_OPS netlogon_svc_ops; extern SERVICE_CONTROL_OPS winreg_svc_ops; +extern SERVICE_CONTROL_OPS wins_svc_ops; + +/* make sure this number patches the number of builtin + SERVICE_CONTROL_OPS structure listed above */ + +#define SVCCTL_NUM_INTERNAL_SERVICES 4 struct service_control_op *svcctl_ops; @@ -51,7 +62,7 @@ static struct generic_mapping svc_generic_map = BOOL init_service_op_table( void ) { const char **service_list = lp_svcctl_list(); - int num_services = 3 + str_list_count( service_list ); + int num_services = SVCCTL_NUM_INTERNAL_SERVICES + str_list_count( service_list ); int i; if ( !(svcctl_ops = TALLOC_ARRAY( NULL, struct service_control_op, num_services+1)) ) { @@ -80,6 +91,10 @@ BOOL init_service_op_table( void ) svcctl_ops[i].ops = &winreg_svc_ops; i++; + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "WINS" ); + svcctl_ops[i].ops = &wins_svc_ops; + i++; + /* NULL terminate the array */ svcctl_ops[i].name = NULL; -- cgit From e127501d4589a5a9c92e2f400fc67bda5a8e6855 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 7 Oct 2005 01:46:19 +0000 Subject: r10792: Fix the "schannel not stored across client disconnects" problem. Based on the Samba4 solution - stores data in $samba/private/schannel_store.tdb. This tdb is not left open but open and closed on demand. Jeremy. (This used to be commit a6d8a4b1ff31c5552075455dbd98cb58795958a9) --- source3/rpc_server/srv_netlog_nt.c | 10 ++++++---- source3/rpc_server/srv_pipe.c | 29 ++++++++++++++--------------- 2 files changed, 20 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 1ad058b519..2dd8b821d8 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -26,8 +26,6 @@ #include "includes.h" -extern struct dcinfo last_dcinfo; -extern BOOL server_auth2_negotiated; extern userdom_struct current_user_info; #undef DBGC_CLASS @@ -438,10 +436,14 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) fstrcpy(p->dc->mach_acct, mach_acct); fstrcpy(p->dc->remote_machine, remote_machine); + fstrcpy(p->dc->domain, lp_workgroup() ); - server_auth2_negotiated = True; p->dc->authenticated = True; - last_dcinfo = *p->dc; + + /* Store off the state so we can continue after client disconnect. */ + become_root(); + secrets_store_schannel_session_info(p->mem_ctx, p->dc); + unbecome_root(); return r_u->status; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index ba6d9704e8..1ca5210842 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -36,15 +36,6 @@ extern struct current_user current_user; #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -/************************************************************* - HACK Alert! - We need to transfer the session key from one rpc bind to the - next. This is the way the netlogon schannel works. -**************************************************************/ - -struct dcinfo last_dcinfo; -BOOL server_auth2_negotiated = False; - static void free_pipe_ntlmssp_auth_data(struct pipe_auth_data *auth) { AUTH_NTLMSSP_STATE *a = auth->a_u.auth_ntlmssp_state; @@ -1218,15 +1209,23 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, RPC_HDR_AUTH auth_info; RPC_AUTH_SCHANNEL_NEG neg; RPC_AUTH_VERIFIER auth_verifier; + BOOL ret; + struct dcinfo stored_dcinfo; uint32 flags; - if (!server_auth2_negotiated) { - DEBUG(0, ("pipe_schannel_auth_bind: Attempt to bind using schannel without successful serverauth2\n")); + if (!smb_io_rpc_auth_schannel_neg("", &neg, rpc_in_p, 0)) { + DEBUG(0,("pipe_schannel_auth_bind: Could not unmarshal SCHANNEL auth neg\n")); return False; } - if (!smb_io_rpc_auth_schannel_neg("", &neg, rpc_in_p, 0)) { - DEBUG(0,("pipe_schannel_auth_bind: Could not unmarshal SCHANNEL auth neg\n")); + ZERO_STRUCT(stored_dcinfo); + + become_root(); + ret = secrets_restore_schannel_session_info(p->mem_ctx, neg.myname, &stored_dcinfo); + unbecome_root(); + + if (!ret) { + DEBUG(0, ("pipe_schannel_auth_bind: Attempt to bind using schannel without successful serverauth2\n")); return False; } @@ -1236,7 +1235,7 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, } memset(p->auth.a_u.schannel_auth->sess_key, 0, sizeof(p->auth.a_u.schannel_auth->sess_key)); - memcpy(p->auth.a_u.schannel_auth->sess_key, last_dcinfo.sess_key, sizeof(last_dcinfo.sess_key)); + memcpy(p->auth.a_u.schannel_auth->sess_key, stored_dcinfo.sess_key, sizeof(stored_dcinfo.sess_key)); p->auth.a_u.schannel_auth->seq_num = 0; @@ -1253,7 +1252,7 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, if (!p->dc) { return False; } - *p->dc = last_dcinfo; + *p->dc = stored_dcinfo; init_rpc_hdr_auth(&auth_info, RPC_SCHANNEL_AUTH_TYPE, pauth_info->auth_level, RPC_HDR_AUTH_LEN, 1); if(!smb_io_rpc_hdr_auth("", &auth_info, pout_auth, 0)) { -- cgit From c226b7d4beaa9239b8790889aa0a8d3c23eac73c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 7 Oct 2005 01:52:48 +0000 Subject: r10795: Fix code before decl error. Jeremy. (This used to be commit 30bd894ee63e5be266b6069533138ccb3c0fbccb) --- source3/rpc_server/srv_eventlog_lib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index a8c1ad51d2..8c7ce4a648 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -54,9 +54,10 @@ TDB_CONTEXT *init_eventlog_tdb( char *tdbfilename ) /* make the tdb file name for an event log, given destination buffer and size */ char *mk_tdbfilename( char *dest_buffer, char *eventlog_name, int size_dest ) { + pstring ondisk_name; + if ( !dest_buffer ) return NULL; - pstring ondisk_name; pstrcpy( ondisk_name, "EV" ); pstrcat( ondisk_name, eventlog_name ); -- cgit From 01a1e5cdb0339a7cb3a85280b118985562bb2d7f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 7 Oct 2005 12:14:25 +0000 Subject: r10819: merging a couple of fixes from trunk * only keep the registry,tdb file open when we have an open key handle * tpot's setup.py fix * removing files that no longer exist in trunk and copying some that were missing in 3.0 (This used to be commit 6c6bf6ca5fd430a7a20bf20ed08050328660e570) --- source3/rpc_server/srv_eventlog_lib.c | 3 +-- source3/rpc_server/srv_eventlog_nt.c | 2 +- source3/rpc_server/srv_reg_nt.c | 5 ++--- 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 8c7ce4a648..3b7a32dac2 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -304,8 +304,7 @@ TDB_CONTEXT *open_eventlog_tdb( char *tdbfilename ) TDB_CONTEXT *the_tdb; the_tdb = - tdb_open_log( tdbfilename, 0, TDB_DEFAULT, O_RDWR | O_CREAT, - 0664 ); + tdb_open_log( tdbfilename, 0, TDB_DEFAULT, O_RDONLY,0664 ); if ( the_tdb == NULL ) { return init_eventlog_tdb( tdbfilename ); } diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 6067c94fe8..d3b350f233 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -400,7 +400,7 @@ static BOOL sync_eventlog_params( const char *elogname ) if ( ( val = regval_ctr_getvalue( values, "MaxSize" ) ) != NULL ) uiMaxSize = IVAL( regval_data_p( val ), 0 ); - TALLOC_FREE( keyinfo ); + regkey_close_internal( keyinfo ); tdb_store_int32( the_tdb, VN_maxsize, uiMaxSize ); tdb_store_int32( the_tdb, VN_retention, uiRetention ); diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 0ba3e04b99..47c8746b12 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -43,7 +43,7 @@ static struct generic_mapping reg_generic_map = static void free_regkey_info(void *ptr) { - TALLOC_FREE( ptr ); + regkey_close_internal( (REGISTRY_KEY*)ptr ); } /****************************************************************** @@ -99,10 +99,9 @@ static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, if ( !create_policy_hnd( p, hnd, free_regkey_info, *keyinfo ) ) { result = WERR_BADFILE; - TALLOC_FREE( *keyinfo ); + regkey_close_internal( *keyinfo ); } - return result; } -- cgit From 254938c636b6062630d54a598b2975d7a984f70d Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Tue, 11 Oct 2005 20:14:04 +0000 Subject: r10911: part of #2861: add rename support for usrmgr.exe when using tdbsam This gets it working before replacing tdb with the samba4 version. (This used to be commit 8210b0503a050e12ee1b4335fa6e50d10ad06577) --- source3/rpc_server/srv_samr_nt.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b69f03a3a2..26a691e9b4 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2423,6 +2423,32 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A return r_u->status; } +/******************************************************************* + set_user_info_7 + ********************************************************************/ +static NTSTATUS set_user_info_7(const SAM_USER_INFO_7 *id7, SAM_ACCOUNT *pwd) +{ + fstring new_name; + NTSTATUS rc; + + if (id7 == NULL) { + DEBUG(5, ("set_user_info_7: NULL id7\n")); + pdb_free_sam(&pwd); + return NT_STATUS_ACCESS_DENIED; + } + + if(!rpcstr_pull(new_name, id7->uni_name.buffer, sizeof(new_name), id7->uni_name.uni_str_len*2, 0)) { + DEBUG(5, ("set_user_info_7: failed to get new username\n")); + pdb_free_sam(&pwd); + return NT_STATUS_ACCESS_DENIED; + } + + rc = pdb_rename_sam_account(pwd, new_name); + + pdb_free_sam(&pwd); + return rc; +} + /******************************************************************* set_user_info_16 ********************************************************************/ @@ -2924,6 +2950,9 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { + case 7: + r_u->status = set_user_info_7(ctr->info.id7, pwd); + break; case 16: if (!set_user_info_16(ctr->info.id16, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; -- cgit From b9ae4455fd0be70c6c7b08807425066e0dd91242 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 14 Oct 2005 14:51:48 +0000 Subject: r11054: patch from Brian Moran; fix error code return in _srv_net_name_validate() (This used to be commit b4e78520ccb8c896a52e3f3e7a52e19e3b2c33bf) --- source3/rpc_server/srv_srvsvc_nt.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 9643b2a724..1022cb960d 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2275,31 +2275,18 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV_R_NET_NAME_VALIDATE *r_u) { - int snum; fstring share_name; - r_u->status=WERR_OK; - - switch(q_u->type) { - + switch ( q_u->type ) { case 0x9: - - /*check if share name is ok*/ - /*also check if we already have a share with this name*/ + /* check if share name is ok. + TODO: check for invalid characters in name? */ unistr2_to_ascii(share_name, &q_u->uni_name, sizeof(share_name)); - snum = find_service(share_name); - - /* Share already exists. */ - if (snum >= 0) - r_u->status = WERR_ALREADY_EXISTS; break; - default: - /*unsupported type*/ - r_u->status = WERR_UNKNOWN_LEVEL; - break; + return WERR_UNKNOWN_LEVEL; } - return r_u->status; + return WERR_OK; } -- cgit From bb68761a500fc5d426c75e53700fa793e016135f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 14 Oct 2005 16:07:00 +0000 Subject: r11060: merging new eventlog code from trunk (This used to be commit 1bcf7e82ede63a851a244162a3b939373787b693) --- source3/rpc_server/srv_eventlog_lib.c | 348 ++++++++++++------- source3/rpc_server/srv_eventlog_nt.c | 628 +++++++++++++--------------------- 2 files changed, 469 insertions(+), 507 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 3b7a32dac2..495ad8e58c 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -1,8 +1,8 @@ - /* * Unix SMB/CIFS implementation. * Eventlog utility routines * Copyright (C) Marcin Krzysztof Porwit 2005, + * Copyright (C) Brian Moran 2005. * Copyright (C) Gerald (Jerry) Carter 2005. * * This program is free software; you can redistribute it and/or modify @@ -22,117 +22,132 @@ #include "includes.h" +/* maintain a list of open eventlog tdbs with reference counts */ -/**************************************************************** -Init an Eventlog TDB, and return it. If null, something bad happened. -****************************************************************/ -TDB_CONTEXT *init_eventlog_tdb( char *tdbfilename ) -{ - TDB_CONTEXT *the_tdb; - - unlink( tdbfilename ); +struct elog_open_tdb { + struct elog_open_tdb *prev, *next; + char *name; + TDB_CONTEXT *tdb; + int ref_count; +}; - the_tdb = - tdb_open_log( tdbfilename, 0, TDB_DEFAULT, O_RDWR | O_CREAT, - 0664 ); - if ( the_tdb == NULL ) { - DEBUG( 1, ( "Can't open tdb for [%s]\n", tdbfilename ) ); - return NULL; - } - tdb_store_int32( the_tdb, VN_oldest_entry, 1 ); - tdb_store_int32( the_tdb, VN_next_record, 1 ); +static struct elog_open_tdb *open_elog_list; - /* initialize with defaults, copy real values in here from registry */ - - tdb_store_int32( the_tdb, VN_maxsize, 0x80000 ); - tdb_store_int32( the_tdb, VN_retention, 0x93A80 ); - - tdb_store_int32( the_tdb, VN_version, EVENTLOG_DATABASE_VERSION_V1 ); - return the_tdb; -} +/******************************************************************** + Init an Eventlog TDB, and return it. If null, something bad + happened. +********************************************************************/ -/* make the tdb file name for an event log, given destination buffer and size */ -char *mk_tdbfilename( char *dest_buffer, char *eventlog_name, int size_dest ) +TDB_CONTEXT *elog_init_tdb( char *tdbfilename ) { - pstring ondisk_name; - - if ( !dest_buffer ) - return NULL; + TDB_CONTEXT *tdb; - pstrcpy( ondisk_name, "EV" ); - pstrcat( ondisk_name, eventlog_name ); - pstrcat( ondisk_name, ".tdb" ); + DEBUG(10,("elog_init_tdb: Initializing eventlog tdb (%s)\n", + tdbfilename)); - memset( dest_buffer, 0, size_dest ); + tdb = tdb_open_log( tdbfilename, 0, TDB_DEFAULT, + O_RDWR|O_CREAT|O_TRUNC, 0600 ); - /* BAD things could happen if the dest_buffer is not large enough... */ - if ( strlen( ondisk_name ) > size_dest ) { - DEBUG( 3, ( "Buffer not big enough for filename\n" ) ); + if ( !tdb ) { + DEBUG( 0, ( "Can't open tdb for [%s]\n", tdbfilename ) ); return NULL; } - strncpy( dest_buffer, ondisk_name, size_dest ); + /* initialize with defaults, copy real values in here from registry */ + + tdb_store_int32( tdb, EVT_OLDEST_ENTRY, 1 ); + tdb_store_int32( tdb, EVT_NEXT_RECORD, 1 ); + tdb_store_int32( tdb, EVT_MAXSIZE, 0x80000 ); + tdb_store_int32( tdb, EVT_RETENTION, 0x93A80 ); + + tdb_store_int32( tdb, EVT_VERSION, EVENTLOG_DATABASE_VERSION_V1 ); - return dest_buffer; + return tdb; } +/******************************************************************** + make the tdb file name for an event log, given destination buffer + and size. Caller must free memory. +********************************************************************/ -/* count the number of bytes in the TDB */ +char *elog_tdbname( const char *name ) +{ + fstring path; + char *tdb_fullpath; + char *eventlogdir = lock_path( "eventlog" ); + + pstr_sprintf( path, "%s/%s.tdb", eventlogdir, name ); + strlower_m( path ); + tdb_fullpath = SMB_STRDUP( path ); + + return tdb_fullpath; +} -/* Arg! Static Globals! */ -static int eventlog_tdbcount; -static int eventlog_tdbsize; +/******************************************************************** + this function is used to count up the number of bytes in a + particular TDB +********************************************************************/ + +struct trav_size_struct { + int size; + int rec_count; +}; -/* this function is used to count up the number of bytes in a particular TDB */ -int eventlog_tdb_size_fn( TDB_CONTEXT * tdb, TDB_DATA key, TDB_DATA data, +static int eventlog_tdb_size_fn( TDB_CONTEXT * tdb, TDB_DATA key, TDB_DATA data, void *state ) { - eventlog_tdbsize += data.dsize; - eventlog_tdbcount++; + struct trav_size_struct *tsize = state; + + tsize->size += data.dsize; + tsize->rec_count++; + return 0; } -/* returns the size of the eventlog, and if MaxSize is a non-null ptr, puts - the MaxSize there. This is purely a way not to have yet another function that solely - reads the maxsize of the eventlog. Yeah, that's it. */ +/******************************************************************** + returns the size of the eventlog, and if MaxSize is a non-null + ptr, puts the MaxSize there. This is purely a way not to have yet + another function that solely reads the maxsize of the eventlog. + Yeah, that's it. +********************************************************************/ -int eventlog_tdb_size( TDB_CONTEXT * tdb, int *MaxSize, int *Retention ) +int elog_tdb_size( TDB_CONTEXT * tdb, int *MaxSize, int *Retention ) { + struct trav_size_struct tsize; + if ( !tdb ) return 0; - eventlog_tdbcount = 0; - eventlog_tdbsize = 0; + + ZERO_STRUCT( tsize ); - tdb_traverse( tdb, eventlog_tdb_size_fn, NULL ); + tdb_traverse( tdb, eventlog_tdb_size_fn, &tsize ); if ( MaxSize != NULL ) { - *MaxSize = tdb_fetch_int32( tdb, VN_maxsize ); + *MaxSize = tdb_fetch_int32( tdb, EVT_MAXSIZE ); } if ( Retention != NULL ) { - *Retention = tdb_fetch_int32( tdb, VN_retention ); + *Retention = tdb_fetch_int32( tdb, EVT_RETENTION ); } DEBUG( 1, - ( "eventlog size: [%d] for [%d] records\n", eventlog_tdbsize, - eventlog_tdbcount ) ); - return eventlog_tdbsize; + ( "eventlog size: [%d] for [%d] records\n", tsize.size, + tsize.rec_count ) ); + return tsize.size; } - -/* - Discard early event logs until we have enough for 'needed' bytes... - NO checking done beforehand to see that we actually need to do this, and - it's going to pluck records one-by-one. So, it's best to determine that this - needs to be done before doing it. - - Setting whack_by_date to True indicates that eventlogs falling outside of the - retention range need to go... - -*/ - -/* return True if we made enough room to accommodate needed bytes */ +/******************************************************************** + Discard early event logs until we have enough for 'needed' bytes... + NO checking done beforehand to see that we actually need to do + this, and it's going to pluck records one-by-one. So, it's best + to determine that this needs to be done before doing it. + + Setting whack_by_date to True indicates that eventlogs falling + outside of the retention range need to go... + + return True if we made enough room to accommodate needed bytes +********************************************************************/ BOOL make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, BOOL whack_by_date ) @@ -140,12 +155,9 @@ BOOL make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, int start_record, i, new_start; int end_record; int nbytes, reclen, len, Retention, MaxSize; - int tresv1, trecnum, timegen, timewr; - TDB_DATA key, ret; TALLOC_CTX *mem_ctx = NULL; - time_t current_time, exp_time; /* discard some eventlogs */ @@ -158,12 +170,12 @@ BOOL make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, if ( mem_ctx == NULL ) return False; /* can't allocate memory indicates bigger problems */ /* lock */ - tdb_lock_bystring( the_tdb, VN_next_record, 1 ); + tdb_lock_bystring( the_tdb, EVT_NEXT_RECORD, 1 ); /* read */ - end_record = tdb_fetch_int32( the_tdb, VN_next_record ); - start_record = tdb_fetch_int32( the_tdb, VN_oldest_entry ); - Retention = tdb_fetch_int32( the_tdb, VN_retention ); - MaxSize = tdb_fetch_int32( the_tdb, VN_maxsize ); + end_record = tdb_fetch_int32( the_tdb, EVT_NEXT_RECORD ); + start_record = tdb_fetch_int32( the_tdb, EVT_OLDEST_ENTRY ); + Retention = tdb_fetch_int32( the_tdb, EVT_RETENTION ); + MaxSize = tdb_fetch_int32( the_tdb, EVT_MAXSIZE ); time( ¤t_time ); @@ -189,7 +201,7 @@ BOOL make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, DEBUG( 8, ( "Can't find a record for the key, record [%d]\n", i ) ); - tdb_unlock_bystring( the_tdb, VN_next_record ); + tdb_unlock_bystring( the_tdb, EVT_NEXT_RECORD ); return False; } nbytes += ret.dsize; /* note this includes overhead */ @@ -226,16 +238,16 @@ BOOL make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, tdb_delete( the_tdb, key ); } - tdb_store_int32( the_tdb, VN_oldest_entry, new_start ); + tdb_store_int32( the_tdb, EVT_OLDEST_ENTRY, new_start ); } - tdb_unlock_bystring( the_tdb, VN_next_record ); + tdb_unlock_bystring( the_tdb, EVT_NEXT_RECORD ); return True; } -/* +/******************************************************************** some hygiene for an eventlog - see how big it is, and then calculate how many bytes we need to remove -*/ +********************************************************************/ BOOL prune_eventlog( TDB_CONTEXT * tdb ) { @@ -246,7 +258,7 @@ BOOL prune_eventlog( TDB_CONTEXT * tdb ) return False; } - CalcdSize = eventlog_tdb_size( tdb, &MaxSize, &Retention ); + CalcdSize = elog_tdb_size( tdb, &MaxSize, &Retention ); DEBUG( 3, ( "Calculated size [%d] MaxSize [%d]\n", CalcdSize, MaxSize ) ); @@ -259,6 +271,9 @@ BOOL prune_eventlog( TDB_CONTEXT * tdb ) return make_way_for_eventlogs( tdb, 0, True ); } +/******************************************************************** +********************************************************************/ + BOOL can_write_to_eventlog( TDB_CONTEXT * tdb, int32 needed ) { int calcd_size; @@ -274,7 +289,7 @@ BOOL can_write_to_eventlog( TDB_CONTEXT * tdb, int32 needed ) MaxSize = 0; Retention = 0; - calcd_size = eventlog_tdb_size( tdb, &MaxSize, &Retention ); + calcd_size = elog_tdb_size( tdb, &MaxSize, &Retention ); if ( calcd_size <= MaxSize ) return True; /* you betcha */ @@ -299,28 +314,128 @@ BOOL can_write_to_eventlog( TDB_CONTEXT * tdb, int32 needed ) return make_way_for_eventlogs( tdb, calcd_size - MaxSize, False ); } -TDB_CONTEXT *open_eventlog_tdb( char *tdbfilename ) +/******************************************************************* +*******************************************************************/ + +TDB_CONTEXT *elog_open_tdb( char *logname ) { - TDB_CONTEXT *the_tdb; + TDB_CONTEXT *tdb; + uint32 vers_id; + struct elog_open_tdb *ptr; + char *tdbfilename; + pstring tdbpath; + struct elog_open_tdb *tdb_node; + char *eventlogdir; + + /* first see if we have an open context */ + + for ( ptr=open_elog_list; ptr; ptr=ptr->next ) { + if ( strequal( ptr->name, logname ) ) { + ptr->ref_count++; + return ptr->tdb; + } + } + + /* make sure that the eventlog dir exists */ + + eventlogdir = lock_path( "eventlog" ); + if ( !directory_exist( eventlogdir, NULL ) ) + mkdir( eventlogdir, 0755 ); + + /* get the path on disk */ + + tdbfilename = elog_tdbname( logname ); + pstrcpy( tdbpath, tdbfilename ); + SAFE_FREE( tdbfilename ); + + DEBUG(7,("elog_open_tdb: Opening %s...\n", tdbpath )); + + tdb = tdb_open_log( tdbpath, 0, TDB_DEFAULT, O_RDWR , 0 ); + if ( tdb ) { + vers_id = tdb_fetch_int32( tdb, EVT_VERSION ); + + if ( vers_id != EVENTLOG_DATABASE_VERSION_V1 ) { + DEBUG(1,("elog_open_tdb: Invalid version [%d] on file [%s].\n", + vers_id, tdbpath)); + tdb_close( tdb ); + tdb = elog_init_tdb( tdbpath ); + } + } + else { + tdb = elog_init_tdb( tdbpath ); + } + + /* if we got a valid context, then add it to the list */ + + if ( tdb ) { + if ( !(tdb_node = TALLOC_ZERO_P( NULL, struct elog_open_tdb )) ) { + DEBUG(0,("elog_open_tdb: talloc() failure!\n")); + tdb_close( tdb ); + return NULL; + } + + tdb_node->name = talloc_strdup( tdb_node, logname ); + tdb_node->tdb = tdb; + tdb_node->ref_count = 1; + + DLIST_ADD( open_elog_list, tdb_node ); + } + + return tdb; +} + +/******************************************************************* + Wrapper to handle reference counts to the tdb +*******************************************************************/ - the_tdb = - tdb_open_log( tdbfilename, 0, TDB_DEFAULT, O_RDONLY,0664 ); - if ( the_tdb == NULL ) { - return init_eventlog_tdb( tdbfilename ); +int elog_close_tdb( TDB_CONTEXT *tdb ) +{ + struct elog_open_tdb *ptr; + + if ( !tdb ) + return 0; + + /* See if we can just decrement the ref_count. + Just compare pointer values (not names ) */ + + for ( ptr=open_elog_list; ptr; ptr=ptr->next ) { + if ( tdb == ptr->tdb ) { + ptr->ref_count--; + break; + } } - if ( EVENTLOG_DATABASE_VERSION_V1 != - tdb_fetch_int32( the_tdb, VN_version ) ) { - tdb_close( the_tdb ); - return init_eventlog_tdb( tdbfilename ); + + /* if we have a NULL pointer; it means we are trying to + close a tdb not in the list of open eventlogs */ + + SMB_ASSERT( ptr != NULL ); + if ( !ptr ) + return tdb_close( tdb ); + + SMB_ASSERT( ptr->ref_count >= 0 ); + + if ( ptr->ref_count == 0 ) { + DLIST_REMOVE( open_elog_list, ptr ); + TALLOC_FREE( ptr ); + return tdb_close( tdb ); } - return the_tdb; + + return 0; } -/* write an eventlog entry. Note that we have to lock, read next eventlog, increment, write, write the record, unlock */ -/* coming into this, ee has the eventlog record, and the auxilliary date (computer name, etc.) - filled into the other structure. Before packing into a record, this routine will calc the - appropriate padding, etc., and then blast out the record in a form that can be read back in */ +/******************************************************************* + write an eventlog entry. Note that we have to lock, read next + eventlog, increment, write, write the record, unlock + + coming into this, ee has the eventlog record, and the auxilliary date + (computer name, etc.) filled into the other structure. Before packing + into a record, this routine will calc the appropriate padding, etc., + and then blast out the record in a form that can be read back in +*******************************************************************/ + +#define MARGIN 512 + int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ) { int32 next_record; @@ -343,8 +458,6 @@ int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ) if ( ee->record.time_generated == 0 ) return 0; -#define MARGIN 512 - /* todo - check for sanity in next_record */ fixup_eventlog_entry( ee ); @@ -365,9 +478,9 @@ int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ) /* need to read the record number and insert it into the entry here */ /* lock */ - tdb_lock_bystring( the_tdb, VN_next_record, 1 ); + tdb_lock_bystring( the_tdb, EVT_NEXT_RECORD, 1 ); /* read */ - next_record = tdb_fetch_int32( the_tdb, VN_next_record ); + next_record = tdb_fetch_int32( the_tdb, EVT_NEXT_RECORD ); n_packed = tdb_pack( packed_ee, ee->record.length + MARGIN, @@ -406,18 +519,20 @@ int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ) if ( tdb_store( the_tdb, kbuf, ebuf, 0 ) ) { /* DEBUG(1,("write_eventlog_tdb: Can't write record %d to eventlog\n",next_record)); */ - tdb_unlock_bystring( the_tdb, VN_next_record ); + tdb_unlock_bystring( the_tdb, EVT_NEXT_RECORD ); talloc_destroy( mem_ctx ); return 0; } next_record++; - tdb_store_int32( the_tdb, VN_next_record, next_record ); - tdb_unlock_bystring( the_tdb, VN_next_record ); + tdb_store_int32( the_tdb, EVT_NEXT_RECORD, next_record ); + tdb_unlock_bystring( the_tdb, EVT_NEXT_RECORD ); talloc_destroy( mem_ctx ); return ( next_record - 1 ); } -/* calculate the correct fields etc for an eventlog entry */ +/******************************************************************* + calculate the correct fields etc for an eventlog entry +*******************************************************************/ void fixup_eventlog_entry( Eventlog_entry * ee ) { @@ -453,10 +568,11 @@ void fixup_eventlog_entry( Eventlog_entry * ee ) } /******************************************************************** -Note that it's a pretty good idea to initialize the Eventlog_entry structure to zero's before -calling parse_logentry on an batch of lines that may resolve to a record. -ALSO, it's a good idea to remove any linefeeds (that's EOL to you and me) on the lines going in. - + Note that it's a pretty good idea to initialize the Eventlog_entry + structure to zero's before calling parse_logentry on an batch of + lines that may resolve to a record. ALSO, it's a good idea to + remove any linefeeds (that's EOL to you and me) on the lines + going in. ********************************************************************/ BOOL parse_logentry( char *line, Eventlog_entry * entry, BOOL * eor ) diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index d3b350f233..577ec48482 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -25,192 +25,201 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV - -typedef struct { - pstring logname; /* rather than alloc on the fly what we need... (memory is cheap now) */ - pstring tdbfname; - TDB_CONTEXT *log_tdb; /* the pointer to the TDB_CONTEXT */ -} EventlogTDBInfo; - -static int nlogs; -static EventlogTDBInfo *ttdb = NULL; -static TALLOC_CTX *mem_ctx = NULL; - typedef struct { char *logname; - char *servername; + TDB_CONTEXT *tdb; uint32 num_records; uint32 oldest_entry; uint32 flags; -} EventlogInfo; + uint32 access_granted; +} EVENTLOG_INFO; +/******************************************************************** + ********************************************************************/ +static void free_eventlog_info( void *ptr ) +{ + EVENTLOG_INFO *elog = (EVENTLOG_INFO *)ptr; + + if ( elog->tdb ) + elog_close_tdb( elog->tdb ); + + TALLOC_FREE( elog ); +} -#if 0 /* UNUSED */ /******************************************************************** ********************************************************************/ - -void test_eventlog_tdb( TDB_CONTEXT * the_tdb ) + +static EVENTLOG_INFO *find_eventlog_info_by_hnd( pipes_struct * p, + POLICY_HND * handle ) { - Eventlog_entry ee; - - int i = 0; - - memset( &ee, 0, sizeof( Eventlog_entry ) ); - - if ( !the_tdb ) - return; - - for ( i = 0; i < 100; i++ ) { - ee.record.length = sizeof( ee.record ); - memset( &ee.data_record, 0, sizeof( ee.data_record ) ); - ee.record.reserved1 = 0xBEEFDEAD; - ee.record.record_number = 1000 - i; /* should get substituted */ - ee.record.time_generated = 0; - ee.record.time_written = 0; - ee.record.event_id = 500; - ee.record.event_type = 300; - ee.record.num_strings = 0; - ee.record.event_category = 0; - ee.record.reserved2 = ( i << 8 ) | i; - ee.record.closing_record_number = -1; - ee.record.string_offset = 0; - ee.record.user_sid_length = 0; - ee.record.user_sid_offset = 0; - ee.record.data_length = 0; - ee.record.data_offset = 0; - - rpcstr_push( ( void * ) ( ee.data_record.source_name ), - "SystemLog", - sizeof( ee.data_record.source_name ), - STR_TERMINATE ); - ee.data_record.source_name_len = - ( strlen_w( ee.data_record.source_name ) * 2 ) + 2; - - rpcstr_push( ( void * ) ( ee.data_record.computer_name ), - "DMLINUX", - sizeof( ee.data_record.computer_name ), - STR_TERMINATE ); - - ee.data_record.computer_name_len = - ( strlen_w( ee.data_record.computer_name ) * 2 ) + 2; - - write_eventlog_tdb( the_tdb, &ee ); + EVENTLOG_INFO *info; + + if ( !find_policy_by_hnd( p, handle, ( void ** ) &info ) ) { + DEBUG( 2, + ( "find_eventlog_info_by_hnd: eventlog not found.\n" ) ); + return NULL; } + + return info; } -#endif /* UNUSED */ /******************************************************************** - ********************************************************************/ +********************************************************************/ -static void refresh_eventlog_tdb_table( void ) +static BOOL elog_check_access( EVENTLOG_INFO *info, NT_USER_TOKEN *token ) { - const char **elogs = lp_eventlog_list( ); - int i, j; + char *tdbname = elog_tdbname( info->logname ); + SEC_DESC *sec_desc; + BOOL ret; + NTSTATUS ntstatus; + + if ( !tdbname ) + return False; + + /* get the security descriptor for the file */ + + sec_desc = get_nt_acl_no_snum( info, tdbname ); + SAFE_FREE( tdbname ); + + if ( !sec_desc ) { + DEBUG(5,("elog_check_access: Unable to get NT ACL for %s\n", + tdbname)); + return False; + } + + /* run the check, try for the max allowed */ + + ret = se_access_check( sec_desc, token, MAXIMUM_ALLOWED_ACCESS, + &info->access_granted, &ntstatus ); + + if ( sec_desc ) + TALLOC_FREE( sec_desc ); + + if ( !ret ) { + DEBUG(8,("elog_check_access: se_access_check() return %s\n", + nt_errstr( ntstatus))); + return False; + } + + /* we have to have READ permission for a successful open */ + + return ( info->access_granted & SA_RIGHT_FILE_READ_DATA ); +} - if ( !elogs ) - return; +/******************************************************************** + ********************************************************************/ - if ( !mem_ctx ) { - mem_ctx = talloc_init( "refresh_eventlog_tdb_table" ); +static BOOL elog_validate_logname( const char *name ) +{ + int i; + const char **elogs = lp_eventlog_list(); + + for ( i=0; elogs[i]; i++ ) { + if ( strequal( name, elogs[i] ) ) + return True; } + + return False; +} - if ( !mem_ctx ) { - DEBUG( 1, ( "Can't allocate memory\n" ) ); - return; - } +/******************************************************************** + ********************************************************************/ - /* count them */ - for ( i = 0; elogs[i]; i++ ) { - } - /* number of logs in i */ - DEBUG( 10, ( "Number of eventlogs %d\n", i ) ); - /* check to see if we need to adjust our tables */ - - if ( ( ttdb != NULL ) ) { - if ( i != nlogs ) { - /* refresh the table, by closing and reconstructing */ - DEBUG( 10, ( "Closing existing table \n" ) ); - for ( j = 0; j < nlogs; j++ ) { - tdb_close( ttdb[j].log_tdb ); - } - TALLOC_FREE( ttdb ); - ttdb = NULL; - } else { /* i == nlogs */ - - for ( j = 0; j < nlogs; j++ ) { - if ( StrCaseCmp( ttdb[j].logname, elogs[i] ) ) { - /* something changed, have to discard */ - DEBUG( 10, - ( "Closing existing table \n" ) ); - for ( j = 0; j < nlogs; j++ ) { - tdb_close( ttdb[j].log_tdb ); - } - TALLOC_FREE( ttdb ); - ttdb = NULL; - break; - } +static WERROR elog_open( pipes_struct * p, const char *logname, POLICY_HND *hnd ) +{ + EVENTLOG_INFO *elog; + + /* first thing is to validate the eventlog name */ + + if ( !elog_validate_logname( logname ) ) + return WERR_OBJECT_PATH_INVALID; + + if ( !(elog = TALLOC_ZERO_P( NULL, EVENTLOG_INFO )) ) + return WERR_NOMEM; + + elog->logname = talloc_strdup( elog, logname ); + + /* Open the tdb first (so that we can create any new tdbs if necessary). + We have to do this as root and then use an internal access check + on the file permissions since you can only have a tdb open once + in a single process */ + + become_root(); + elog->tdb = elog_open_tdb( elog->logname ); + unbecome_root(); + + if ( !elog->tdb ) { + /* according to MSDN, if the logfile cannot be found, we should + default to the "Application" log */ + + if ( !strequal( logname, ELOG_APPL ) ) { + + TALLOC_FREE( elog->logname ); + + elog->logname = talloc_strdup( elog, ELOG_APPL ); + + /* do the access check */ + if ( !elog_check_access( elog, p->pipe_user.nt_user_token ) ) { + TALLOC_FREE( elog ); + return WERR_ACCESS_DENIED; } + + become_root(); + elog->tdb = elog_open_tdb( elog->logname ); + unbecome_root(); + } + + if ( !elog->tdb ) { + TALLOC_FREE( elog ); + return WERR_ACCESS_DENIED; /* ??? */ } } + + /* now do the access check. Close the tdb if we fail here */ - /* note that this might happen because of above */ - if ( ( i > 0 ) && ( ttdb == NULL ) ) { - /* alloc the room */ - DEBUG( 10, ( "Creating the table\n" ) ); - ttdb = TALLOC( mem_ctx, sizeof( EventlogTDBInfo ) * i ); - if ( !ttdb ) { - DEBUG( 10, - ( "Can't allocate table for tdb handles \n" ) ); - return; - } - for ( j = 0; j < i; j++ ) { - pstrcpy( ttdb[j].tdbfname, - lock_path( mk_tdbfilename - ( ttdb[j].tdbfname, - ( char * ) elogs[j], - sizeof( pstring ) ) ) ); - pstrcpy( ttdb[j].logname, elogs[j] ); - DEBUG( 10, ( "Opening tdb for %s\n", elogs[j] ) ); - ttdb[j].log_tdb = - open_eventlog_tdb( ttdb[j].tdbfname ); - } + if ( !elog_check_access( elog, p->pipe_user.nt_user_token ) ) { + elog_close_tdb( elog->tdb ); + TALLOC_FREE( elog ); + return WERR_ACCESS_DENIED; + } + + /* create the policy handle */ + + if ( !create_policy_hnd + ( p, hnd, free_eventlog_info, ( void * ) elog ) ) { + free_eventlog_info( elog ); + return WERR_NOMEM; } - nlogs = i; + + return WERR_OK; } /******************************************************************** ********************************************************************/ -TDB_CONTEXT *tdb_of( char *eventlog_name ) +static WERROR elog_close( pipes_struct *p, POLICY_HND *hnd ) { - int i; - - if ( !eventlog_name ) - return NULL; + if ( !( close_policy_hnd( p, hnd ) ) ) { + return WERR_BADFID; + } - if ( !ttdb ) { - DEBUG( 10, ( "Refreshing list of eventlogs\n" ) ); - refresh_eventlog_tdb_table( ); - - if ( !ttdb ) { - DEBUG( 10, - ( "eventlog tdb table is NULL after a refresh!\n" ) ); - return NULL; - } - } + return WERR_OK; +} - DEBUG( 10, ( "Number of eventlogs %d\n", nlogs ) ); +/******************************************************************* + *******************************************************************/ - for ( i = 0; i < nlogs; i++ ) { - if ( strequal( eventlog_name, ttdb[i].logname ) ) - return ttdb[i].log_tdb; +static int elog_size( EVENTLOG_INFO *info ) +{ + if ( !info || !info->tdb ) { + DEBUG(0,("elog_size: Invalid info* structure!\n")); + return 0; } - return NULL; + return elog_tdb_size( info->tdb, NULL, NULL ); } - /******************************************************************** For the given tdb, get the next eventlog record into the passed Eventlog_entry. returns NULL if it can't get the record for some reason. @@ -314,37 +323,12 @@ Eventlog_entry *get_eventlog_record( prs_struct * ps, TDB_CONTEXT * tdb, return ee; } -/******************************************************************** - ********************************************************************/ - -static void free_eventlog_info( void *ptr ) -{ - TALLOC_FREE( ptr ); -} - -/******************************************************************** - ********************************************************************/ - -static EventlogInfo *find_eventlog_info_by_hnd( pipes_struct * p, - POLICY_HND * handle ) -{ - EventlogInfo *info; - - if ( !find_policy_by_hnd( p, handle, ( void ** ) &info ) ) { - DEBUG( 2, - ( "find_eventlog_info_by_hnd: eventlog not found.\n" ) ); - return NULL; - } - - return info; -} - /******************************************************************** note that this can only be called AFTER the table is constructed, since it uses the table to find the tdb handle ********************************************************************/ -static BOOL sync_eventlog_params( const char *elogname ) +static BOOL sync_eventlog_params( EVENTLOG_INFO *info ) { pstring path; uint32 uiMaxSize; @@ -353,14 +337,12 @@ static BOOL sync_eventlog_params( const char *elogname ) REGISTRY_VALUE *val; REGVAL_CTR *values; WERROR wresult; - TDB_CONTEXT *the_tdb; - - the_tdb = tdb_of( ( char * ) elogname ); + char *elogname = info->logname; DEBUG( 4, ( "sync_eventlog_params with %s\n", elogname ) ); - if ( !the_tdb ) { - DEBUG( 4, ( "Can't open tdb for %s\n", elogname ) ); + if ( !info->tdb ) { + DEBUG( 4, ( "No open tdb! (%s)\n", info->logname ) ); return False; } /* set resonable defaults. 512Kb on size and 1 week on time */ @@ -402,112 +384,52 @@ static BOOL sync_eventlog_params( const char *elogname ) regkey_close_internal( keyinfo ); - tdb_store_int32( the_tdb, VN_maxsize, uiMaxSize ); - tdb_store_int32( the_tdb, VN_retention, uiRetention ); - - return True; -} - -/******************************************************************** - ********************************************************************/ + tdb_store_int32( info->tdb, EVT_MAXSIZE, uiMaxSize ); + tdb_store_int32( info->tdb, EVT_RETENTION, uiRetention ); -static BOOL open_eventlog_hook( EventlogInfo * info ) -{ return True; } /******************************************************************** ********************************************************************/ -/** - * Callout to get the number of records in the specified event log - * - * smbrun calling convention -- - * INPUT: - * OUTPUT: A single line with a single integer containing the number of - * entries in the log. If there are no entries in the log, return 0. - */ - - -static BOOL get_num_records_hook( EventlogInfo * info ) +static BOOL get_num_records_hook( EVENTLOG_INFO * info ) { - - TDB_CONTEXT *the_tdb = NULL; int next_record; int oldest_record; - - the_tdb = tdb_of( info->logname ); - - if ( !the_tdb ) { - DEBUG( 10, ( "Can't find tdb for %s\n", info->logname ) ); - info->num_records = 0; + if ( !info->tdb ) { + DEBUG( 10, ( "No open tdb for %s\n", info->logname ) ); return False; } - /* lock */ - tdb_lock_bystring( the_tdb, VN_next_record, 1 ); - - - /* read */ - next_record = tdb_fetch_int32( the_tdb, VN_next_record ); - oldest_record = tdb_fetch_int32( the_tdb, VN_oldest_entry ); - + /* lock the tdb since we have to get 2 records */ + tdb_lock_bystring( info->tdb, EVT_NEXT_RECORD, 1 ); + next_record = tdb_fetch_int32( info->tdb, EVT_NEXT_RECORD); + oldest_record = tdb_fetch_int32( info->tdb, EVT_OLDEST_ENTRY); + tdb_unlock_bystring( info->tdb, EVT_NEXT_RECORD); DEBUG( 8, - ( "Oldest Record %d Next Record %d\n", oldest_record, + ( "Oldest Record %d; Next Record %d\n", oldest_record, next_record ) ); info->num_records = ( next_record - oldest_record ); info->oldest_entry = oldest_record; - tdb_unlock_bystring( the_tdb, VN_next_record ); - return True; - - } /******************************************************************** ********************************************************************/ -/** - * Callout to find the oldest record in the log - * - * smbrun calling convention -- - * INPUT: - * OUTPUT: If there are entries in the event log, the index of the - * oldest entry. Must be 1 or greater. - * If there are no entries in the log, returns a 0 - */ - -static BOOL get_oldest_entry_hook( EventlogInfo * info ) +static BOOL get_oldest_entry_hook( EVENTLOG_INFO * info ) { /* it's the same thing */ return get_num_records_hook( info ); } - -/******************************************************************** - ********************************************************************/ - -/** - * Callout to close the specified event log - * - * smbrun calling convention -- - * INPUT: - * OUTPUT: the string "SUCCESS" if the command succeeded - * no such string if there was a failure. - */ - -static BOOL close_eventlog_hook( EventlogInfo * info ) -{ - - return True; -} - /******************************************************************** ********************************************************************/ @@ -628,69 +550,6 @@ static BOOL add_record_to_resp( EVENTLOG_R_READ_EVENTLOG * r_u, return True; } -/******************************************************************** - ********************************************************************/ - -/** - * Callout to clear (and optionally backup) a specified event log - * - * smbrun calling convention -- - * INPUT: - * OUTPUT: A single line with the string "SUCCESS" if the command succeeded. - * Otherwise it is assumed to have failed - * - * INPUT: - * OUTPUT: A single line with the string "SUCCESS" if the command succeeded. - * Otherwise it is assumed to have failed - * The given log is copied to that location on the server. See comments for - * eventlog_io_q_clear_eventlog for info about odd file name behavior - */ -static BOOL clear_eventlog_hook( EventlogInfo * info, - pstring backup_file_name ) -{ - - int i; - - - if ( !info ) - return False; - DEBUG( 3, ( "There are %d event logs\n", nlogs ) ); - for ( i = 0; i < nlogs; i++ ) { - DEBUG( 3, - ( "Comparing Eventlog %s, %s\n", info->logname, - ttdb[i].logname ) ); - if ( !StrCaseCmp( info->logname, ttdb[i].logname ) ) { - /* close the current one, reinit */ - tdb_close( ttdb[i].log_tdb ); - DEBUG( 3, - ( "Closing Eventlog %s, file-on-disk %s\n", - info->logname, ttdb[i].tdbfname ) ); - ttdb[i].log_tdb = - init_eventlog_tdb( ttdb[i].tdbfname ); - return True; - } - } - - return False; /* not found */ - /* TODO- do something with the backup file name */ - -} - -/******************************************************************* - *******************************************************************/ - -static int eventlog_size( char *eventlog_name ) -{ - TDB_CONTEXT *tdb; - - if ( !eventlog_name ) - return 0; - tdb = tdb_of( eventlog_name ); - if ( !tdb ) - return 0; - return eventlog_tdb_size( tdb, NULL, NULL ); -} - /******************************************************************** ********************************************************************/ @@ -698,83 +557,81 @@ WERROR _eventlog_open_eventlog( pipes_struct * p, EVENTLOG_Q_OPEN_EVENTLOG * q_u, EVENTLOG_R_OPEN_EVENTLOG * r_u ) { - EventlogInfo *info = NULL; - fstring str; - - if ( !( info = TALLOC_ZERO_P( NULL, EventlogInfo ) ) ) - return WERR_NOMEM; + fstring servername, logname; + EVENTLOG_INFO *info; + WERROR wresult; - fstrcpy( str, global_myname( ) ); + fstrcpy( servername, "" ); if ( q_u->servername.string ) { - rpcstr_pull( str, q_u->servername.string->buffer, - sizeof( str ), + rpcstr_pull( servername, q_u->servername.string->buffer, + sizeof( servername ), q_u->servername.string->uni_str_len * 2, 0 ); } - info->servername = talloc_strdup( info, str ); - - fstrcpy( str, "Application" ); + fstrcpy( logname, "" ); if ( q_u->logname.string ) { - rpcstr_pull( str, q_u->logname.string->buffer, - sizeof( str ), + rpcstr_pull( logname, q_u->logname.string->buffer, + sizeof( logname ), q_u->logname.string->uni_str_len * 2, 0 ); } - - info->logname = talloc_strdup( info, str ); - - DEBUG( 1, - ( "Size of %s is %d\n", info->logname, - eventlog_size( info->logname ) ) ); - - - - DEBUG( 10, - ( "_eventlog_open_eventlog: Using [%s] as the server name.\n", - info->servername ) ); - DEBUG( 10, - ( "_eventlog_open_eventlog: Using [%s] as the source log file.\n", - info->logname ) ); - - - if ( !create_policy_hnd - ( p, &r_u->handle, free_eventlog_info, ( void * ) info ) ) { - free_eventlog_info( info ); - return WERR_NOMEM; + + DEBUG( 10,("_eventlog_open_eventlog: Server [%s], Log [%s]\n", + servername, logname )); + + /* according to MSDN, if the logfile cannot be found, we should + default to the "Application" log */ + + if ( !W_ERROR_IS_OK( wresult = elog_open( p, logname, &r_u->handle )) ) + return wresult; + + if ( !(info = find_eventlog_info_by_hnd( p, &r_u->handle )) ) { + DEBUG(0,("_eventlog_open_eventlog: eventlog (%s) opened but unable to find handle!\n", + logname )); + elog_close( p, &r_u->handle ); + return WERR_BADFID; } - if ( !open_eventlog_hook( info ) ) { - close_policy_hnd( p, &r_u->handle ); - return WERR_BADFILE; - } + DEBUG(10,("_eventlog_open_eventlog: Size [%d]\n", elog_size( info ))); - sync_eventlog_params( info->logname ); - prune_eventlog( tdb_of( info->logname ) ); + sync_eventlog_params( info ); + prune_eventlog( info->tdb ); return WERR_OK; } /******************************************************************** + This call still needs some work ********************************************************************/ WERROR _eventlog_clear_eventlog( pipes_struct * p, EVENTLOG_Q_CLEAR_EVENTLOG * q_u, EVENTLOG_R_CLEAR_EVENTLOG * r_u ) { - EventlogInfo *info = find_eventlog_info_by_hnd( p, &q_u->handle ); + EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); pstring backup_file_name; - pstrcpy( backup_file_name, "" ); + if ( !info ) + return WERR_BADFID; - if ( q_u->backupfile.string ) - unistr2_to_ascii( backup_file_name, q_u->backupfile.string, - sizeof( backup_file_name ) ); + pstrcpy( backup_file_name, "" ); + if ( q_u->backupfile.string ) { + rpcstr_pull( backup_file_name, q_u->backupfile.string->buffer, + sizeof( backup_file_name ), + q_u->backupfile.string->uni_str_len * 2, 0 ); + } - DEBUG( 10, + DEBUG( 8, ( "_eventlog_clear_eventlog: Using [%s] as the backup file name for log [%s].", backup_file_name, info->logname ) ); - if ( !( clear_eventlog_hook( info, backup_file_name ) ) ) - return WERR_BADFILE; +#if 0 + /* close the current one, reinit */ + + tdb_close( info->tdb ); + + if ( !(info->tdb = elog_init_tdb( ttdb[i].tdbfname )) ) + return WERR_ACCESS_DENIED; +#endif return WERR_OK; } @@ -786,16 +643,7 @@ WERROR _eventlog_close_eventlog( pipes_struct * p, EVENTLOG_Q_CLOSE_EVENTLOG * q_u, EVENTLOG_R_CLOSE_EVENTLOG * r_u ) { - EventlogInfo *info = find_eventlog_info_by_hnd( p, &q_u->handle ); - - if ( !( close_eventlog_hook( info ) ) ) - return WERR_BADFILE; - - if ( !( close_policy_hnd( p, &q_u->handle ) ) ) { - return WERR_BADFID; - } - - return WERR_OK; + return elog_close( p, &q_u->handle ); } /******************************************************************** @@ -805,56 +653,55 @@ WERROR _eventlog_read_eventlog( pipes_struct * p, EVENTLOG_Q_READ_EVENTLOG * q_u, EVENTLOG_R_READ_EVENTLOG * r_u ) { - EventlogInfo *info = find_eventlog_info_by_hnd( p, &q_u->handle ); + EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); Eventlog_entry entry, *ee_new; uint32 num_records_read = 0; prs_struct *ps; int bytes_left, record_number; - TDB_CONTEXT *the_tdb; - + TDB_CONTEXT *tdb; info->flags = q_u->flags; ps = &p->out_data.rdata; - bytes_left = q_u->max_read_size; - the_tdb = tdb_of( info->logname ); - if ( !the_tdb ) { - /* todo handle the error */ - + tdb = info->tdb; + if ( !tdb ) { + return WERR_EVENTLOG_FILE_CORRUPT; } - /* DEBUG(8,("Bytes left is %d\n",bytes_left)); */ + /* DEBUG(8,("Bytes left is %d\n",bytes_left)); */ record_number = q_u->offset; while ( bytes_left > 0 ) { if ( get_eventlog_record - ( ps, the_tdb, record_number, &entry ) ) { + ( ps, tdb, record_number, &entry ) ) { DEBUG( 8, ( "Retrieved record %d\n", record_number ) ); + /* Now see if there is enough room to add */ - if ( ( ee_new = - read_package_entry( ps, q_u, r_u, - &entry ) ) == NULL ) { + ee_new = read_package_entry( ps, q_u, r_u,&entry ); + if ( !ee_new ) return WERR_NOMEM; - } - if ( r_u->num_bytes_in_resp + ee_new->record.length > q_u->max_read_size ) { r_u->bytes_in_next_record = ee_new->record.length; + /* response would be too big to fit in client-size buffer */ + bytes_left = 0; break; } + add_record_to_resp( r_u, ee_new ); bytes_left -= ee_new->record.length; ZERO_STRUCT( entry ); num_records_read = r_u->num_records - num_records_read; + DEBUG( 10, ( "_eventlog_read_eventlog: read [%d] records for a total of [%d] records using [%d] bytes out of a max of [%d].\n", num_records_read, r_u->num_records, @@ -866,13 +713,12 @@ WERROR _eventlog_read_eventlog( pipes_struct * p, } - if ( info->flags & EVENTLOG_FORWARDS_READ ) { + if ( info->flags & EVENTLOG_FORWARDS_READ ) record_number++; - } else { + else record_number--; - } - } + return WERR_OK; } @@ -883,7 +729,7 @@ WERROR _eventlog_get_oldest_entry( pipes_struct * p, EVENTLOG_Q_GET_OLDEST_ENTRY * q_u, EVENTLOG_R_GET_OLDEST_ENTRY * r_u ) { - EventlogInfo *info = find_eventlog_info_by_hnd( p, &q_u->handle ); + EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); if ( !( get_oldest_entry_hook( info ) ) ) return WERR_BADFILE; @@ -900,7 +746,7 @@ WERROR _eventlog_get_num_records( pipes_struct * p, EVENTLOG_Q_GET_NUM_RECORDS * q_u, EVENTLOG_R_GET_NUM_RECORDS * r_u ) { - EventlogInfo *info = find_eventlog_info_by_hnd( p, &q_u->handle ); + EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); if ( !( get_num_records_hook( info ) ) ) return WERR_BADFILE; -- cgit From 1b9122943558fa903991ba1353e04faacdac85fe Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 14 Oct 2005 21:09:56 +0000 Subject: r11069: make sure to zero memory when allocating a a REGVAL_CTR struct (This used to be commit bfdcbb7572352b3a3b7941249438a927eb91e18d) --- source3/rpc_server/srv_reg_nt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 47c8746b12..4cd824c9ef 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -331,7 +331,7 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL DEBUG(5,("_reg_info: looking up value: [%s]\n", name)); - if ( !(regvals = TALLOC_P( p->mem_ctx, REGVAL_CTR )) ) + if ( !(regvals = TALLOC_ZERO_P( p->mem_ctx, REGVAL_CTR )) ) return WERR_NOMEM; /* Handle QueryValue calls on HKEY_PERFORMANCE_DATA */ @@ -536,6 +536,10 @@ WERROR _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE status = WERR_NO_MORE_ITEMS; goto done; } + + if ( val->type == REG_MULTI_SZ ) { + + } DEBUG(10,("_reg_enum_value: retrieved value named [%s]\n", val->valuename)); -- cgit From 5b52e4a0eb8cd4a68eb35114576ccc0ae85c2a1a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 14 Oct 2005 21:43:13 +0000 Subject: r11072: add routines for converting REG_MULTI_SZ to and from char** (This used to be commit e858eed813b5a9a8d57262142c5bbde2951b5590) --- source3/rpc_server/srv_reg_nt.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 4cd824c9ef..35a060c38e 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -537,9 +537,21 @@ WERROR _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE goto done; } +#if 0 /* JERRY TEST CODE */ if ( val->type == REG_MULTI_SZ ) { - + char **str; + int num_strings = regval_convert_multi_sz( (uint16*)regval_data_p(val), regval_size(val), &str ); + uint16 *buffer; + size_t buf_size; + + + if ( num_strings ) + buf_size = regval_build_multi_sz( str, &buffer ); + + TALLOC_FREE( str ); + TALLOC_FREE( buffer ); } +#endif DEBUG(10,("_reg_enum_value: retrieved value named [%s]\n", val->valuename)); -- cgit From 6f72169c7cee4d8334c15e3add711cd1716e618a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 18 Oct 2005 02:37:13 +0000 Subject: r11135: should fix seg fault in addprinter code reported by Marcin. Allocate memory in convert_printer_info() if necessary (This used to be commit 7ada5da8e94a08a9a3e488172fa04ce688882299) --- source3/rpc_server/srv_spoolss_nt.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5233d6c252..a8fc1bc229 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1729,20 +1729,29 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, static BOOL convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni, NT_PRINTER_INFO_LEVEL *printer, uint32 level) { - BOOL ret = True; + BOOL ret; switch (level) { case 2: - /* printer->info_2 is already a valid printer */ + /* allocate memory if needed. Messy because + convert_printer_info is used to update an existing + printer or build a new one */ + + if ( !printer->info_2 ) { + printer->info_2 = TALLOC_ZERO_P( printer, NT_PRINTER_INFO_LEVEL_2 ); + if ( !printer->info_2 ) { + DEBUG(0,("convert_printer_info: talloc() failed!\n")); + return False; + } + } + ret = uni_2_asc_printer_info_2(uni->info_2, printer->info_2); printer->info_2->setuptime = time(NULL); - break; - default: - break; + return ret; } - return ret; + return False; } static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *uni, -- cgit From 8d7c88667190fe286971ac4fffb64ee5bd9eeeb0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Oct 2005 03:24:00 +0000 Subject: r11137: Compile with only 2 warnings (I'm still working on that code) on a gcc4 x86_64 box. Jeremy. (This used to be commit d720867a788c735e56d53d63265255830ec21208) --- source3/rpc_server/srv_eventlog_lib.c | 6 +++--- source3/rpc_server/srv_netlog_nt.c | 4 ++-- source3/rpc_server/srv_pipe.c | 28 ++++++++++++++-------------- source3/rpc_server/srv_samr_nt.c | 15 +++++++-------- 4 files changed, 26 insertions(+), 27 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 495ad8e58c..b21c2a2529 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -483,7 +483,7 @@ int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ) next_record = tdb_fetch_int32( the_tdb, EVT_NEXT_RECORD ); n_packed = - tdb_pack( packed_ee, ee->record.length + MARGIN, + tdb_pack( (char *)packed_ee, ee->record.length + MARGIN, "ddddddwwwwddddddBBdBBBd", ee->record.length, ee->record.reserved1, next_record, ee->record.time_generated, ee->record.time_written, @@ -512,10 +512,10 @@ int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ) /* increment the record count */ kbuf.dsize = sizeof( int32 ); - kbuf.dptr = ( uint8 * ) & next_record; + kbuf.dptr = (char * ) & next_record; ebuf.dsize = n_packed; - ebuf.dptr = packed_ee; + ebuf.dptr = (char *)packed_ee; if ( tdb_store( the_tdb, kbuf, ebuf, 0 ) ) { /* DEBUG(1,("write_eventlog_tdb: Can't write record %d to eventlog\n",next_record)); */ diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 2dd8b821d8..f75ad6bba0 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -337,7 +337,7 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) creds_server_init(p->dc, &p->dc->clnt_chal, /* Stored client chal. */ &p->dc->srv_chal, /* Stored server chal. */ - p->dc->mach_pw, + (const char *)p->dc->mach_pw, &srv_chal_out); /* Check client credentials are valid. */ @@ -414,7 +414,7 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) creds_server_init(p->dc, &p->dc->clnt_chal, /* Stored client chal. */ &p->dc->srv_chal, /* Stored server chal. */ - p->dc->mach_pw, + (const char *)p->dc->mach_pw, &srv_chal_out); /* Check client credentials are valid. */ diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 1ca5210842..b615080d34 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -173,7 +173,7 @@ static BOOL create_next_pdu_ntlmssp(pipes_struct *p) /* Copy the sign/seal padding data. */ if (ss_padding_len) { - unsigned char pad[8]; + char pad[8]; memset(pad, '\0', 8); if (!prs_copy_data_in(&outgoing_pdu, pad, ss_padding_len)) { @@ -210,9 +210,9 @@ static BOOL create_next_pdu_ntlmssp(pipes_struct *p) case PIPE_AUTH_LEVEL_PRIVACY: /* Data portion is encrypted. */ status = ntlmssp_seal_packet(a->ntlmssp_state, - prs_data_p(&outgoing_pdu) + RPC_HEADER_LEN + RPC_HDR_RESP_LEN, + (unsigned char *)prs_data_p(&outgoing_pdu) + RPC_HEADER_LEN + RPC_HDR_RESP_LEN, data_len + ss_padding_len, - prs_data_p(&outgoing_pdu), + (unsigned char *)prs_data_p(&outgoing_pdu), (size_t)prs_offset(&outgoing_pdu), &auth_blob); if (!NT_STATUS_IS_OK(status)) { @@ -224,9 +224,9 @@ static BOOL create_next_pdu_ntlmssp(pipes_struct *p) case PIPE_AUTH_LEVEL_INTEGRITY: /* Data is signed. */ status = ntlmssp_sign_packet(a->ntlmssp_state, - prs_data_p(&outgoing_pdu) + RPC_HEADER_LEN + RPC_HDR_RESP_LEN, + (unsigned char *)prs_data_p(&outgoing_pdu) + RPC_HEADER_LEN + RPC_HDR_RESP_LEN, data_len + ss_padding_len, - prs_data_p(&outgoing_pdu), + (unsigned char *)prs_data_p(&outgoing_pdu), (size_t)prs_offset(&outgoing_pdu), &auth_blob); if (!NT_STATUS_IS_OK(status)) { @@ -241,7 +241,7 @@ static BOOL create_next_pdu_ntlmssp(pipes_struct *p) } /* Append the auth blob. */ - if (!prs_copy_data_in(&outgoing_pdu, auth_blob.data, NTLMSSP_SIG_SIZE)) { + if (!prs_copy_data_in(&outgoing_pdu, (char *)auth_blob.data, NTLMSSP_SIG_SIZE)) { DEBUG(0,("create_next_pdu_ntlmssp: failed to add %u bytes auth blob.\n", (unsigned int)NTLMSSP_SIG_SIZE)); data_blob_free(&auth_blob); @@ -731,7 +731,7 @@ BOOL api_pipe_bind_auth3(pipes_struct *p, prs_struct *rpc_in_p) blob = data_blob(NULL,p->hdr.auth_len); - if (!prs_copy_data_out(blob.data, rpc_in_p, p->hdr.auth_len)) { + if (!prs_copy_data_out((char *)blob.data, rpc_in_p, p->hdr.auth_len)) { DEBUG(0,("api_pipe_bind_auth3: Failed to pull %u bytes - the response blob.\n", (unsigned int)p->hdr.auth_len )); goto err; @@ -1036,7 +1036,7 @@ static BOOL pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_ /* Grab the SPNEGO blob. */ blob = data_blob(NULL,p->hdr.auth_len); - if (!prs_copy_data_out(blob.data, rpc_in_p, p->hdr.auth_len)) { + if (!prs_copy_data_out((char *)blob.data, rpc_in_p, p->hdr.auth_len)) { DEBUG(0,("pipe_spnego_auth_bind_negotiate: Failed to pull %u bytes - the SPNEGO auth header.\n", (unsigned int)p->hdr.auth_len )); goto err; @@ -1103,7 +1103,7 @@ static BOOL pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_ goto err; } - if (!prs_copy_data_in(pout_auth, response.data, response.length)) { + if (!prs_copy_data_in(pout_auth, (char *)response.data, response.length)) { DEBUG(0,("pipe_spnego_auth_bind_negotiate: marshalling of data blob failed.\n")); goto err; } @@ -1154,7 +1154,7 @@ static BOOL pipe_spnego_auth_bind_continue(pipes_struct *p, prs_struct *rpc_in_p /* Grab the SPNEGO blob. */ spnego_blob = data_blob(NULL,p->hdr.auth_len); - if (!prs_copy_data_out(spnego_blob.data, rpc_in_p, p->hdr.auth_len)) { + if (!prs_copy_data_out((char *)spnego_blob.data, rpc_in_p, p->hdr.auth_len)) { DEBUG(0,("pipe_spnego_auth_bind_continue: Failed to pull %u bytes - the SPNEGO auth header.\n", (unsigned int)p->hdr.auth_len )); goto err; @@ -1306,13 +1306,13 @@ static BOOL pipe_ntlmssp_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, /* Grab the NTLMSSP blob. */ blob = data_blob(NULL,p->hdr.auth_len); - if (!prs_copy_data_out(blob.data, rpc_in_p, p->hdr.auth_len)) { + if (!prs_copy_data_out((char *)blob.data, rpc_in_p, p->hdr.auth_len)) { DEBUG(0,("pipe_ntlmssp_auth_bind: Failed to pull %u bytes - the NTLM auth header.\n", (unsigned int)p->hdr.auth_len )); goto err; } - if (strncmp(blob.data, "NTLMSSP", 7) != 0) { + if (strncmp((char *)blob.data, "NTLMSSP", 7) != 0) { DEBUG(0,("pipe_ntlmssp_auth_bind: Failed to read NTLMSSP in blob\n")); goto err; } @@ -1341,7 +1341,7 @@ static BOOL pipe_ntlmssp_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, goto err; } - if (!prs_copy_data_in(pout_auth, response.data, response.length)) { + if (!prs_copy_data_in(pout_auth, (char *)response.data, response.length)) { DEBUG(0,("pipe_ntlmssp_auth_bind: marshalling of data blob failed.\n")); goto err; } @@ -1896,7 +1896,7 @@ BOOL api_pipe_ntlmssp_auth_process(pipes_struct *p, prs_struct *rpc_in, return False; } - auth_blob.data = prs_data_p(rpc_in) + prs_offset(rpc_in); + auth_blob.data = (unsigned char *)prs_data_p(rpc_in) + prs_offset(rpc_in); auth_blob.length = auth_len; switch (p->auth.auth_level) { diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 26a691e9b4..45a77197ee 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1688,9 +1688,9 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S DOM_SID sid; DOM_SID *sids; DOM_GID *gids = NULL; - int num_groups = 0; + size_t num_groups = 0; gid_t *unix_gids; - int i, num_gids; + size_t i, num_gids; uint32 acc_granted; BOOL ret; NTSTATUS result; @@ -2988,10 +2988,10 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, SAMR_R_QUERY_USERALIASES *r_u) { - int num_alias_rids; + size_t num_alias_rids; uint32 *alias_rids; struct samr_info *info = NULL; - int i; + size_t i; NTSTATUS ntstatus1; NTSTATUS ntstatus2; @@ -3052,9 +3052,8 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_QUERY_ALIASMEM *r_u) { - int i; - - int num_sids = 0; + size_t i; + size_t num_sids = 0; DOM_SID2 *sid; DOM_SID *sids=NULL; @@ -3165,7 +3164,7 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ { DOM_SID group_sid; fstring group_sid_str; - int i, num_members; + size_t i, num_members; uint32 *rid=NULL; uint32 *attr=NULL; -- cgit From 39be2680e008931ff8372a978ac2d8d705c5e03a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 19 Oct 2005 02:50:45 +0000 Subject: r11170: root free pass on eventlog open access check (This used to be commit 4e3ff41e1ee2e3c323814fd8c6aa44ecab412257) --- source3/rpc_server/srv_eventlog_nt.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 577ec48482..5901f68f52 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -88,6 +88,13 @@ static BOOL elog_check_access( EVENTLOG_INFO *info, NT_USER_TOKEN *token ) return False; } + /* root free pass */ + + if ( geteuid() == sec_initial_uid() ) { + DEBUG(5,("elog_check_access: using root's token\n")); + token = get_root_nt_token(); + } + /* run the check, try for the max allowed */ ret = se_access_check( sec_desc, token, MAXIMUM_ALLOWED_ACCESS, -- cgit From 6fc9098dcc1a1ef232b96f5d4c562bf340db8988 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 20 Oct 2005 20:26:11 +0000 Subject: r11235: fix segfault in addprinter due to mixing talloc() and malloc()'d memory (This used to be commit f6f78877b485be5efd5cf1f3147b2e9fee647e52) --- source3/rpc_server/srv_spoolss_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a8fc1bc229..026e7681e0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7413,13 +7413,11 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ int snum; WERROR err = WERR_OK; - if ((printer = SMB_MALLOC_P(NT_PRINTER_INFO_LEVEL)) == NULL) { + if ( !(printer = TALLOC_ZERO_P(NULL, NT_PRINTER_INFO_LEVEL)) ) { DEBUG(0,("spoolss_addprinterex_level_2: malloc fail.\n")); return WERR_NOMEM; } - ZERO_STRUCTP(printer); - /* convert from UNICODE to ASCII - this allocates the info_2 struct inside *printer.*/ if (!convert_printer_info(info, printer, 2)) { free_a_printer(&printer, 2); -- cgit From 1113cad9c0c81e9ecec3a0f4317c950943cfc62a Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Thu, 20 Oct 2005 20:40:47 +0000 Subject: r11236: Implement user rename for smbpasswd and ldap backends. Some cleanup on tdb as well to make naming consistent. (This used to be commit ee91eb9a39cc5e3edd9e97eb040e7557930e4e62) --- source3/rpc_server/srv_samr_nt.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 45a77197ee..598f9db1da 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2429,7 +2429,9 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A static NTSTATUS set_user_info_7(const SAM_USER_INFO_7 *id7, SAM_ACCOUNT *pwd) { fstring new_name; + SAM_ACCOUNT *check_acct = NULL; NTSTATUS rc; + BOOL check_rc; if (id7 == NULL) { DEBUG(5, ("set_user_info_7: NULL id7\n")); @@ -2443,6 +2445,24 @@ static NTSTATUS set_user_info_7(const SAM_USER_INFO_7 *id7, SAM_ACCOUNT *pwd) return NT_STATUS_ACCESS_DENIED; } + /* check to see if the new username already exists. Note: we can't + reliably lock all backends, so there is potentially the + possibility that a user can be created in between this check and + the rename. The rename should fail, but may not get the + exact same failure status code. I think this is small enough + of a window for this type of operation and the results are + simply that the rename fails with a slightly different status + code (like UNSUCCESSFUL instead of ALREADY_EXISTS). */ + + pdb_init_sam(&check_acct); + check_rc = pdb_getsampwnam(check_acct, new_name); + pdb_free_sam(&check_acct); + + if (check_rc == True) { + /* this account exists: say so */ + return NT_STATUS_USER_EXISTS; + } + rc = pdb_rename_sam_account(pwd, new_name); pdb_free_sam(&pwd); -- cgit From cd310c19cefddc799ec5f8b374bc9c5ea9dec5f1 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 21 Oct 2005 02:14:23 +0000 Subject: r11240: * fix invalid read reported by valgrind in the spoolss backchannel connection by rewriting spoolss_connect_to_client(). Ensure that we save the cli_state* in the rpc_pipe_client struct. * fix typo in debug message in cli_start_connection" (This used to be commit 18400f96628ffdd332c2fb2aa52b5e9aee5cb3ce) --- source3/rpc_server/srv_spoolss_nt.c | 102 ++++++++++++------------------------ 1 file changed, 34 insertions(+), 68 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 026e7681e0..e5b3ca3947 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -174,8 +174,10 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle) /* if it's the last connection, deconnect the IPC$ share */ if (smb_connections==1) { - cli_shutdown(notify_cli_pipe->cli); + + cli_shutdown( notify_cli_pipe->cli ); notify_cli_pipe = NULL; /* The above call shuts downn the pipe also. */ + message_deregister(MSG_PRINTER_NOTIFY2); /* Tell the connections db we're no longer interested in @@ -2494,99 +2496,66 @@ done: Connect to the client machine. **********************************************************/ -static BOOL spoolss_connect_to_client(struct cli_state *the_cli, struct rpc_pipe_client **pp_pipe, +static BOOL spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, struct in_addr *client_ip, const char *remote_machine) { NTSTATUS ret; - ZERO_STRUCTP(the_cli); - - if(cli_initialise(the_cli) == NULL) { - DEBUG(0,("spoolss_connect_to_client: unable to initialize client connection.\n")); - return False; - } - + struct cli_state *the_cli; + struct in_addr rm_addr; + if ( is_zero_ip(*client_ip) ) { - if(!resolve_name( remote_machine, &the_cli->dest_ip, 0x20)) { - DEBUG(0,("spoolss_connect_to_client: Can't resolve address for %s\n", remote_machine)); - cli_shutdown(the_cli); - return False; + if ( !resolve_name( remote_machine, &rm_addr, 0x20) ) { + DEBUG(2,("spoolss_connect_to_client: Can't resolve address for %s\n", remote_machine)); + return False; } - if (ismyip(the_cli->dest_ip)) { + if ( ismyip( rm_addr )) { DEBUG(0,("spoolss_connect_to_client: Machine %s is one of our addresses. Cannot add to ourselves.\n", remote_machine)); - cli_shutdown(the_cli); return False; } - } - else { - the_cli->dest_ip.s_addr = client_ip->s_addr; + } else { + rm_addr.s_addr = client_ip->s_addr; DEBUG(5,("spoolss_connect_to_client: Using address %s (no name resolution necessary)\n", inet_ntoa(*client_ip) )); } - if (!cli_connect(the_cli, remote_machine, &the_cli->dest_ip)) { - DEBUG(0,("spoolss_connect_to_client: unable to connect to SMB server on machine %s. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); - cli_shutdown(the_cli); - return False; - } - - if (!attempt_netbios_session_request(the_cli, global_myname(), remote_machine, &the_cli->dest_ip)) { - DEBUG(0,("spoolss_connect_to_client: machine %s rejected the NetBIOS session request.\n", - remote_machine)); - cli_shutdown(the_cli); - return False; - } + /* setup the connection */ - the_cli->protocol = PROTOCOL_NT1; - cli_setup_signing_state(the_cli, lp_client_signing()); - - if (!cli_negprot(the_cli)) { - DEBUG(0,("spoolss_connect_to_client: machine %s rejected the negotiate protocol. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); - cli_shutdown(the_cli); - return False; - } + ret = cli_full_connection( &the_cli, global_myname(), remote_machine, + &rm_addr, 0, "IPC$", "IPC", + "", /* username */ + "", /* domain */ + "", /* password */ + 0, lp_client_signing(), NULL ); - if (the_cli->protocol != PROTOCOL_NT1) { - DEBUG(0,("spoolss_connect_to_client: machine %s didn't negotiate NT protocol.\n", remote_machine)); - cli_shutdown(the_cli); - return False; - } - - /* - * Do an anonymous session setup. - */ - - if (!cli_session_setup(the_cli, "", "", 0, "", 0, "")) { - DEBUG(0,("spoolss_connect_to_client: machine %s rejected the session setup. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); - cli_shutdown(the_cli); + if ( !NT_STATUS_IS_OK( ret ) ) { + DEBUG(2,("spoolss_connect_to_client: connection to [%s] failed!\n", + remote_machine )); return False; - } - - if (!(the_cli->sec_mode & 1)) { - DEBUG(0,("spoolss_connect_to_client: machine %s isn't in user level security mode\n", remote_machine)); + } + + if ( the_cli->protocol != PROTOCOL_NT1 ) { + DEBUG(0,("spoolss_connect_to_client: machine %s didn't negotiate NT protocol.\n", remote_machine)); cli_shutdown(the_cli); return False; } - if (!cli_send_tconX(the_cli, "IPC$", "IPC", "", 1)) { - DEBUG(0,("spoolss_connect_to_client: machine %s rejected the tconX on the IPC$ share. Error was : %s.\n", remote_machine, cli_errstr(the_cli) )); - cli_shutdown(the_cli); - return False; - } - /* * Ok - we have an anonymous connection to the IPC$ share. * Now start the NT Domain stuff :-). */ - *pp_pipe = cli_rpc_pipe_open_noauth(the_cli, PI_SPOOLSS, &ret); - if(!*pp_pipe) { - DEBUG(0,("spoolss_connect_to_client: unable to open the spoolss pipe on machine %s. Error was : %s.\n", + if ( !(*pp_pipe = cli_rpc_pipe_open_noauth(the_cli, PI_SPOOLSS, &ret)) ) { + DEBUG(2,("spoolss_connect_to_client: unable to open the spoolss pipe on machine %s. Error was : %s.\n", remote_machine, nt_errstr(ret))); cli_shutdown(the_cli); return False; } + /* make sure to save the cli_state pointer. Keep its own talloc_ctx */ + + (*pp_pipe)->cli = the_cli; + return True; } @@ -2605,14 +2574,11 @@ static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, * and connect to the IPC$ share anonymously */ if (smb_connections==0) { - struct cli_state notify_cli; /* print notify back-channel */ fstring unix_printer; fstrcpy(unix_printer, printer+2); /* the +2 is to strip the leading 2 backslashs */ - ZERO_STRUCT(notify_cli); - - if(!spoolss_connect_to_client(¬ify_cli, ¬ify_cli_pipe, client_ip, unix_printer)) + if ( !spoolss_connect_to_client( ¬ify_cli_pipe, client_ip, unix_printer )) return False; message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message_list); -- cgit From 90b1ca259706e7ae31c0ce7384a9e448a771f1b7 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 25 Oct 2005 12:49:24 +0000 Subject: r11292: Missed merge from Samba 2.2 many years ago.... Don't count open pipes in the num_files_open on a connection. conn_idle_all() handles this by looking for open rpc handles If there are no open handles, we can close the IPC$ share. (This used to be commit 747fba4dbf06c42495c430cd78c1cded3445f821) --- source3/rpc_server/srv_pipe_hnd.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 205223190b..6077faed16 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -337,9 +337,6 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, p->conn = conn; - /* Ensure the connection isn't idled whilst this pipe is open. */ - p->conn->num_files_open++; - p->vuid = vuid; p->endian = RPC_LITTLE_ENDIAN; @@ -1156,8 +1153,6 @@ static BOOL close_internal_rpc_pipe_hnd(void *np_conn) DLIST_REMOVE(InternalPipes, p); - p->conn->num_files_open--; - ZERO_STRUCTP(p); SAFE_FREE(p); -- cgit From e1ffd2d612184fb1343cbe7e1d5d1aacebe0e8fa Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 27 Oct 2005 13:30:23 +0000 Subject: r11332: eventlog API uses NTSTATUS, not WERROR for return codes (This used to be commit f5f40633bc3f641a0fef4934375d0d829899b0d7) --- source3/rpc_server/srv_eventlog_nt.c | 67 ++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 34 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 5901f68f52..6413221031 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -133,17 +133,17 @@ static BOOL elog_validate_logname( const char *name ) /******************************************************************** ********************************************************************/ -static WERROR elog_open( pipes_struct * p, const char *logname, POLICY_HND *hnd ) +static NTSTATUS elog_open( pipes_struct * p, const char *logname, POLICY_HND *hnd ) { EVENTLOG_INFO *elog; /* first thing is to validate the eventlog name */ if ( !elog_validate_logname( logname ) ) - return WERR_OBJECT_PATH_INVALID; + return NT_STATUS_OBJECT_PATH_INVALID; if ( !(elog = TALLOC_ZERO_P( NULL, EVENTLOG_INFO )) ) - return WERR_NOMEM; + return NT_STATUS_NO_MEMORY; elog->logname = talloc_strdup( elog, logname ); @@ -169,7 +169,7 @@ static WERROR elog_open( pipes_struct * p, const char *logname, POLICY_HND *hnd /* do the access check */ if ( !elog_check_access( elog, p->pipe_user.nt_user_token ) ) { TALLOC_FREE( elog ); - return WERR_ACCESS_DENIED; + return NT_STATUS_ACCESS_DENIED; } become_root(); @@ -179,7 +179,7 @@ static WERROR elog_open( pipes_struct * p, const char *logname, POLICY_HND *hnd if ( !elog->tdb ) { TALLOC_FREE( elog ); - return WERR_ACCESS_DENIED; /* ??? */ + return NT_STATUS_ACCESS_DENIED; /* ??? */ } } @@ -188,7 +188,7 @@ static WERROR elog_open( pipes_struct * p, const char *logname, POLICY_HND *hnd if ( !elog_check_access( elog, p->pipe_user.nt_user_token ) ) { elog_close_tdb( elog->tdb ); TALLOC_FREE( elog ); - return WERR_ACCESS_DENIED; + return NT_STATUS_ACCESS_DENIED; } /* create the policy handle */ @@ -196,22 +196,22 @@ static WERROR elog_open( pipes_struct * p, const char *logname, POLICY_HND *hnd if ( !create_policy_hnd ( p, hnd, free_eventlog_info, ( void * ) elog ) ) { free_eventlog_info( elog ); - return WERR_NOMEM; + return NT_STATUS_NO_MEMORY; } - return WERR_OK; + return NT_STATUS_OK; } /******************************************************************** ********************************************************************/ -static WERROR elog_close( pipes_struct *p, POLICY_HND *hnd ) +static NTSTATUS elog_close( pipes_struct *p, POLICY_HND *hnd ) { if ( !( close_policy_hnd( p, hnd ) ) ) { - return WERR_BADFID; + return NT_STATUS_INVALID_HANDLE; } - return WERR_OK; + return NT_STATUS_OK; } /******************************************************************* @@ -432,7 +432,6 @@ static BOOL get_num_records_hook( EVENTLOG_INFO * info ) static BOOL get_oldest_entry_hook( EVENTLOG_INFO * info ) { - /* it's the same thing */ return get_num_records_hook( info ); } @@ -560,13 +559,13 @@ static BOOL add_record_to_resp( EVENTLOG_R_READ_EVENTLOG * r_u, /******************************************************************** ********************************************************************/ -WERROR _eventlog_open_eventlog( pipes_struct * p, +NTSTATUS _eventlog_open_eventlog( pipes_struct * p, EVENTLOG_Q_OPEN_EVENTLOG * q_u, EVENTLOG_R_OPEN_EVENTLOG * r_u ) { fstring servername, logname; EVENTLOG_INFO *info; - WERROR wresult; + NTSTATUS result; fstrcpy( servername, "" ); if ( q_u->servername.string ) { @@ -588,14 +587,14 @@ WERROR _eventlog_open_eventlog( pipes_struct * p, /* according to MSDN, if the logfile cannot be found, we should default to the "Application" log */ - if ( !W_ERROR_IS_OK( wresult = elog_open( p, logname, &r_u->handle )) ) - return wresult; + if ( !NT_STATUS_IS_OK( result = elog_open( p, logname, &r_u->handle )) ) + return result; if ( !(info = find_eventlog_info_by_hnd( p, &r_u->handle )) ) { DEBUG(0,("_eventlog_open_eventlog: eventlog (%s) opened but unable to find handle!\n", logname )); elog_close( p, &r_u->handle ); - return WERR_BADFID; + return NT_STATUS_INVALID_HANDLE; } DEBUG(10,("_eventlog_open_eventlog: Size [%d]\n", elog_size( info ))); @@ -603,14 +602,14 @@ WERROR _eventlog_open_eventlog( pipes_struct * p, sync_eventlog_params( info ); prune_eventlog( info->tdb ); - return WERR_OK; + return NT_STATUS_OK; } /******************************************************************** This call still needs some work ********************************************************************/ -WERROR _eventlog_clear_eventlog( pipes_struct * p, +NTSTATUS _eventlog_clear_eventlog( pipes_struct * p, EVENTLOG_Q_CLEAR_EVENTLOG * q_u, EVENTLOG_R_CLEAR_EVENTLOG * r_u ) { @@ -618,7 +617,7 @@ WERROR _eventlog_clear_eventlog( pipes_struct * p, pstring backup_file_name; if ( !info ) - return WERR_BADFID; + return NT_STATUS_INVALID_HANDLE; pstrcpy( backup_file_name, "" ); if ( q_u->backupfile.string ) { @@ -637,16 +636,16 @@ WERROR _eventlog_clear_eventlog( pipes_struct * p, tdb_close( info->tdb ); if ( !(info->tdb = elog_init_tdb( ttdb[i].tdbfname )) ) - return WERR_ACCESS_DENIED; + return NT_STATUS_ACCESS_DENIED; #endif - return WERR_OK; + return NT_STATUS_OK; } /******************************************************************** ********************************************************************/ -WERROR _eventlog_close_eventlog( pipes_struct * p, +NTSTATUS _eventlog_close_eventlog( pipes_struct * p, EVENTLOG_Q_CLOSE_EVENTLOG * q_u, EVENTLOG_R_CLOSE_EVENTLOG * r_u ) { @@ -656,7 +655,7 @@ WERROR _eventlog_close_eventlog( pipes_struct * p, /******************************************************************** ********************************************************************/ -WERROR _eventlog_read_eventlog( pipes_struct * p, +NTSTATUS _eventlog_read_eventlog( pipes_struct * p, EVENTLOG_Q_READ_EVENTLOG * q_u, EVENTLOG_R_READ_EVENTLOG * r_u ) { @@ -674,7 +673,7 @@ WERROR _eventlog_read_eventlog( pipes_struct * p, bytes_left = q_u->max_read_size; tdb = info->tdb; if ( !tdb ) { - return WERR_EVENTLOG_FILE_CORRUPT; + return NT_STATUS_ACCESS_DENIED; } /* DEBUG(8,("Bytes left is %d\n",bytes_left)); */ @@ -690,7 +689,7 @@ WERROR _eventlog_read_eventlog( pipes_struct * p, /* Now see if there is enough room to add */ ee_new = read_package_entry( ps, q_u, r_u,&entry ); if ( !ee_new ) - return WERR_NOMEM; + return NT_STATUS_NO_MEMORY; if ( r_u->num_bytes_in_resp + ee_new->record.length > q_u->max_read_size ) { @@ -716,7 +715,7 @@ WERROR _eventlog_read_eventlog( pipes_struct * p, q_u->max_read_size ) ); } else { DEBUG( 8, ( "get_eventlog_record returned NULL\n" ) ); - return WERR_NOMEM; /* wrong error - but return one anyway */ + return NT_STATUS_NO_MEMORY; /* wrong error - but return one anyway */ } @@ -726,39 +725,39 @@ WERROR _eventlog_read_eventlog( pipes_struct * p, record_number--; } - return WERR_OK; + return NT_STATUS_OK; } /******************************************************************** ********************************************************************/ -WERROR _eventlog_get_oldest_entry( pipes_struct * p, +NTSTATUS _eventlog_get_oldest_entry( pipes_struct * p, EVENTLOG_Q_GET_OLDEST_ENTRY * q_u, EVENTLOG_R_GET_OLDEST_ENTRY * r_u ) { EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); if ( !( get_oldest_entry_hook( info ) ) ) - return WERR_BADFILE; + return NT_STATUS_ACCESS_DENIED; r_u->oldest_entry = info->oldest_entry; - return WERR_OK; + return NT_STATUS_OK; } /******************************************************************** ********************************************************************/ -WERROR _eventlog_get_num_records( pipes_struct * p, +NTSTATUS _eventlog_get_num_records( pipes_struct * p, EVENTLOG_Q_GET_NUM_RECORDS * q_u, EVENTLOG_R_GET_NUM_RECORDS * r_u ) { EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); if ( !( get_num_records_hook( info ) ) ) - return WERR_BADFILE; + return NT_STATUS_ACCESS_DENIED; r_u->num_records = info->num_records; - return WERR_OK; + return NT_STATUS_OK; } -- cgit From a656626d0f63d74dbfe6d42201c751df56c6f5a0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 31 Oct 2005 23:47:57 +0000 Subject: r11433: Fix for bug #3223 - ensure we're root before doing any potential lib/smbldap.c calls. Jeremy. (This used to be commit 915cfb48f08b3748e22e68ed028eaca6d558cbad) --- source3/rpc_server/srv_samr_nt.c | 58 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 598f9db1da..d1d751d8ae 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1805,8 +1805,9 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA uint32 num_users=0, num_groups=0, num_aliases=0; - if ((ctr = TALLOC_ZERO_P(p->mem_ctx, SAM_UNK_CTR)) == NULL) + if ((ctr = TALLOC_ZERO_P(p->mem_ctx, SAM_UNK_CTR)) == NULL) { return NT_STATUS_NO_MEMORY; + } ZERO_STRUCTP(ctr); @@ -1815,12 +1816,17 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) { return NT_STATUS_INVALID_HANDLE; + } switch (q_u->switch_value) { case 0x01: + become_root(); + + /* AS ROOT !!! */ + pdb_get_account_policy(AP_MIN_PASSWORD_LEN, &account_policy_temp); min_pass_len = account_policy_temp; @@ -1835,7 +1841,11 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &account_policy_temp); u_min_age = account_policy_temp; + + /* !AS ROOT */ + unbecome_root(); + unix_to_nt_time_abs(&nt_expire, u_expire); unix_to_nt_time_abs(&nt_min_age, u_min_age); @@ -1843,11 +1853,14 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA flag, nt_expire, nt_min_age); break; case 0x02: + become_root(); + + /* AS ROOT !!! */ + num_users=count_sam_users(&info->disp_info, ACB_NORMAL); num_groups=count_sam_groups(&info->disp_info); - unbecome_root(); pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); u_logout = account_policy_temp; @@ -1857,6 +1870,10 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA if (!pdb_get_seq_num(&seq_num)) seq_num = time(NULL); + /* !AS ROOT */ + + unbecome_root(); + server_role = ROLE_DOMAIN_PDC; if (lp_server_role() == ROLE_DOMAIN_BDC) server_role = ROLE_DOMAIN_BDC; @@ -1865,7 +1882,17 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA num_users, num_groups, num_aliases, nt_logout, server_role); break; case 0x03: + + become_root(); + + /* AS ROOT !!! */ + pdb_get_account_policy(AP_TIME_TO_LOGOUT, (unsigned int *)&u_logout); + + /* !AS ROOT */ + + unbecome_root(); + unix_to_nt_time_abs(&nt_logout, u_logout); init_unk_info3(&ctr->info.inf3, nt_logout); @@ -1884,16 +1911,32 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA init_unk_info7(&ctr->info.inf7, server_role); break; case 0x08: - if (!pdb_get_seq_num(&seq_num)) + + become_root(); + + /* AS ROOT !!! */ + + if (!pdb_get_seq_num(&seq_num)) { seq_num = time(NULL); + } + + /* !AS ROOT */ + + unbecome_root(); init_unk_info8(&ctr->info.inf8, (uint32) seq_num); break; case 0x0c: + + become_root(); + + /* AS ROOT !!! */ + pdb_get_account_policy(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); u_lock_duration = account_policy_temp; - if (u_lock_duration != -1) + if (u_lock_duration != -1) { u_lock_duration *= 60; + } pdb_get_account_policy(AP_RESET_COUNT_TIME, &account_policy_temp); u_reset_time = account_policy_temp * 60; @@ -1901,6 +1944,10 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA pdb_get_account_policy(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); lockout = account_policy_temp; + /* !AS ROOT */ + + unbecome_root(); + unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); unix_to_nt_time_abs(&nt_reset_time, u_reset_time); @@ -1910,6 +1957,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA return NT_STATUS_INVALID_INFO_CLASS; } + 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__)); -- cgit From c9effb004cb4bb9baa87fb429f22c834226708bb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 2 Nov 2005 00:19:26 +0000 Subject: r11451: Fix -O1 "might be using uninitialized" errors. Jeremy. (This used to be commit cab76c3c33883aad444eefb6562ab1b27d9ca88a) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d1d751d8ae..71272a9a98 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -799,7 +799,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAM_DISPINFO_CTR *ctr; uint32 temp_size=0, total_data_size=0; - NTSTATUS disp_ret; + NTSTATUS disp_ret = NT_STATUS_UNSUCCESSFUL; uint32 num_account = 0; enum remote_arch_types ra_type = get_remote_arch(); int max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K; -- cgit From 6d5757395a0e54245543794d0d6d6d6a32cd857a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 5 Nov 2005 04:21:55 +0000 Subject: r11511: A classic "friday night check-in" :-). This moves much of the Samba4 timezone handling code back into Samba3. Gets rid of "kludge-gmt" and removes the effectiveness of the parameter "time offset" (I can add this back in very easily if needed) - it's no longer being looked at. I'm hoping this will fix the problems people have been having with DST transitions. I'll start comprehensive testing tomorrow, but for now all modifications are done. Splits time get/set functions into srv_XXX and cli_XXX as they need to look at different timezone offsets. Get rid of much of the "efficiency" cruft that was added to Samba back in the day when the C library timezone handling functions were slow. Jeremy. (This used to be commit 414303bc0272f207046b471a0364fa296b67c1f8) --- source3/rpc_server/srv_srvsvc_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 1022cb960d..a7162c929d 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1,5 +1,5 @@ -/* - * Unix SMB/CIFS implementation. + /* + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Jeremy Allison 2001. @@ -1947,7 +1947,7 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET t->tm_min, t->tm_sec, 0, - TimeDiff(unixdate)/60, + get_time_zone(unixdate)/60, 10000, t->tm_mday, t->tm_mon + 1, -- cgit From fcceedd67c29bae6941949a16ebef37e95dab601 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 8 Nov 2005 06:19:34 +0000 Subject: r11573: Adding Andrew Bartlett's patch to make machine account logons work if the client gives the MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT or MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT flags. This changes the auth module interface to 2 (from 1). The effect of this is that clients can access resources as a machine account if they set these flags. This is the same as Windows (think of a VPN where the vpn client authenticates itself to a VPN server using machine account credentials - the vpn server checks that the machine password was valid by performing a machine account check with the PDC in the same was as it would a user account check. I may add in a restriction (parameter) to allow this behaviour to be turned off (as it was previously). That may be on by default. Andrew Bartlett please review this change carefully. Jeremy. (This used to be commit d1caef866326346fb191f8129d13d98379f18cd8) --- source3/rpc_server/srv_netlog_nt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index f75ad6bba0..91566d325c 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -695,6 +695,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * if (!make_user_info_netlogon_network(&user_info, nt_username, nt_domain, wksname, + ctr->auth.id2.param_ctrl, ctr->auth.id2.lm_chal_resp.buffer, ctr->auth.id2.lm_chal_resp.str_str_len, ctr->auth.id2.nt_chal_resp.buffer, @@ -719,7 +720,9 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * if (!make_user_info_netlogon_interactive(&user_info, nt_username, nt_domain, - nt_workstation, chal, + nt_workstation, + ctr->auth.id1.param_ctrl, + chal, ctr->auth.id1.lm_owf.data, ctr->auth.id1.nt_owf.data, p->dc->sess_key)) { -- cgit From c672a17ff09a7cbe4982c221090ba82377e1a044 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 9 Nov 2005 19:37:13 +0000 Subject: r11617: fix typo (This used to be commit 37d2bf02f37f6d1b5bac9523f085c00625722761) --- source3/rpc_server/srv_netlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 91566d325c..7903adff6d 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -633,7 +633,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * /* checks and updates credentials. creates reply credentials */ if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { - DEBUG(0,("_net_sam_logoff: creds_server_step failed. Rejecting auth " + DEBUG(0,("_net_sam_logon: creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", p->dc->remote_machine, p->dc->mach_acct )); return NT_STATUS_ACCESS_DENIED; -- cgit From 70cac98b6e1871cf93b379a4834de1778853de86 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 17 Nov 2005 17:41:02 +0000 Subject: r11760: fix sequential reads in the eventlog; event viewer is behaving better now as well but needs more testing (This used to be commit ba2f94aeae1f8e69d53fc360785adf222a8c9c6e) --- source3/rpc_server/srv_eventlog_nt.c | 186 ++++++++++++++++++++--------------- 1 file changed, 105 insertions(+), 81 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 6413221031..0f0b73029a 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -28,6 +28,7 @@ typedef struct { char *logname; TDB_CONTEXT *tdb; + uint32 current_record; uint32 num_records; uint32 oldest_entry; uint32 flags; @@ -130,6 +131,45 @@ static BOOL elog_validate_logname( const char *name ) return False; } +/******************************************************************** +********************************************************************/ + +static BOOL get_num_records_hook( EVENTLOG_INFO * info ) +{ + int next_record; + int oldest_record; + + if ( !info->tdb ) { + DEBUG( 10, ( "No open tdb for %s\n", info->logname ) ); + return False; + } + + /* lock the tdb since we have to get 2 records */ + + tdb_lock_bystring( info->tdb, EVT_NEXT_RECORD, 1 ); + next_record = tdb_fetch_int32( info->tdb, EVT_NEXT_RECORD); + oldest_record = tdb_fetch_int32( info->tdb, EVT_OLDEST_ENTRY); + tdb_unlock_bystring( info->tdb, EVT_NEXT_RECORD); + + DEBUG( 8, + ( "Oldest Record %d; Next Record %d\n", oldest_record, + next_record ) ); + + info->num_records = ( next_record - oldest_record ); + info->oldest_entry = oldest_record; + + return True; +} + +/******************************************************************** + ********************************************************************/ + +static BOOL get_oldest_entry_hook( EVENTLOG_INFO * info ) +{ + /* it's the same thing */ + return get_num_records_hook( info ); +} + /******************************************************************** ********************************************************************/ @@ -199,6 +239,15 @@ static NTSTATUS elog_open( pipes_struct * p, const char *logname, POLICY_HND *hn return NT_STATUS_NO_MEMORY; } + /* set the initial current_record pointer */ + + if ( !get_oldest_entry_hook( elog ) ) { + DEBUG(3,("elog_open: Successfully opened eventlog but can't " + "get any information on internal records!\n")); + } + + elog->current_record = elog->oldest_entry; + return NT_STATUS_OK; } @@ -397,45 +446,6 @@ static BOOL sync_eventlog_params( EVENTLOG_INFO *info ) return True; } -/******************************************************************** -********************************************************************/ - -static BOOL get_num_records_hook( EVENTLOG_INFO * info ) -{ - int next_record; - int oldest_record; - - if ( !info->tdb ) { - DEBUG( 10, ( "No open tdb for %s\n", info->logname ) ); - return False; - } - - /* lock the tdb since we have to get 2 records */ - - tdb_lock_bystring( info->tdb, EVT_NEXT_RECORD, 1 ); - next_record = tdb_fetch_int32( info->tdb, EVT_NEXT_RECORD); - oldest_record = tdb_fetch_int32( info->tdb, EVT_OLDEST_ENTRY); - tdb_unlock_bystring( info->tdb, EVT_NEXT_RECORD); - - DEBUG( 8, - ( "Oldest Record %d; Next Record %d\n", oldest_record, - next_record ) ); - - info->num_records = ( next_record - oldest_record ); - info->oldest_entry = oldest_record; - - return True; -} - -/******************************************************************** - ********************************************************************/ - -static BOOL get_oldest_entry_hook( EVENTLOG_INFO * info ) -{ - /* it's the same thing */ - return get_num_records_hook( info ); -} - /******************************************************************** ********************************************************************/ @@ -661,71 +671,85 @@ NTSTATUS _eventlog_read_eventlog( pipes_struct * p, { EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); Eventlog_entry entry, *ee_new; - uint32 num_records_read = 0; prs_struct *ps; int bytes_left, record_number; - TDB_CONTEXT *tdb; - info->flags = q_u->flags; ps = &p->out_data.rdata; + uint32 elog_read_type, elog_read_dir; bytes_left = q_u->max_read_size; - tdb = info->tdb; - if ( !tdb ) { + + if ( !info->tdb ) return NT_STATUS_ACCESS_DENIED; + + /* check for valid flags. Can't use the sequential and seek flags together */ + + elog_read_type = q_u->flags & (EVENTLOG_SEQUENTIAL_READ|EVENTLOG_SEEK_READ); + elog_read_dir = q_u->flags & (EVENTLOG_FORWARDS_READ|EVENTLOG_BACKWARDS_READ); + + if ( elog_read_type == (EVENTLOG_SEQUENTIAL_READ|EVENTLOG_SEEK_READ) + || elog_read_dir == (EVENTLOG_FORWARDS_READ|EVENTLOG_BACKWARDS_READ) ) + { + DEBUG(3,("_eventlog_read_eventlog: Invalid flags [0x%x] for ReadEventLog\n", q_u->flags)); + return NT_STATUS_INVALID_PARAMETER; } - /* DEBUG(8,("Bytes left is %d\n",bytes_left)); */ + /* a sequential read should ignore the offset */ - record_number = q_u->offset; + if ( elog_read_type & EVENTLOG_SEQUENTIAL_READ ) + record_number = info->current_record; + else + record_number = q_u->offset; while ( bytes_left > 0 ) { - if ( get_eventlog_record - ( ps, tdb, record_number, &entry ) ) { - DEBUG( 8, - ( "Retrieved record %d\n", record_number ) ); + + /* assume that when the record fetch fails, that we are done */ + + if ( !get_eventlog_record ( ps, info->tdb, record_number, &entry ) ) + break; + + DEBUG( 8, ( "Retrieved record %d\n", record_number ) ); - /* Now see if there is enough room to add */ - ee_new = read_package_entry( ps, q_u, r_u,&entry ); - if ( !ee_new ) - return NT_STATUS_NO_MEMORY; - - if ( r_u->num_bytes_in_resp + ee_new->record.length > - q_u->max_read_size ) { - r_u->bytes_in_next_record = - ee_new->record.length; - - /* response would be too big to fit in client-size buffer */ + /* Now see if there is enough room to add */ + + if ( !(ee_new = read_package_entry( ps, q_u, r_u,&entry )) ) + return NT_STATUS_NO_MEMORY; + + if ( r_u->num_bytes_in_resp + ee_new->record.length > q_u->max_read_size ) { + r_u->bytes_in_next_record = ee_new->record.length; + + /* response would be too big to fit in client-size buffer */ - bytes_left = 0; - break; - } + bytes_left = 0; + break; + } - add_record_to_resp( r_u, ee_new ); - bytes_left -= ee_new->record.length; - ZERO_STRUCT( entry ); - num_records_read = - r_u->num_records - num_records_read; + add_record_to_resp( r_u, ee_new ); + bytes_left -= ee_new->record.length; + ZERO_STRUCT( entry ); + num_records_read = r_u->num_records - num_records_read; - DEBUG( 10, - ( "_eventlog_read_eventlog: read [%d] records for a total of [%d] records using [%d] bytes out of a max of [%d].\n", - num_records_read, r_u->num_records, - r_u->num_bytes_in_resp, - q_u->max_read_size ) ); - } else { - DEBUG( 8, ( "get_eventlog_record returned NULL\n" ) ); - return NT_STATUS_NO_MEMORY; /* wrong error - but return one anyway */ - } - + DEBUG( 10, ( "_eventlog_read_eventlog: read [%d] records for a total " + "of [%d] records using [%d] bytes out of a max of [%d].\n", + num_records_read, r_u->num_records, + r_u->num_bytes_in_resp, + q_u->max_read_size ) ); if ( info->flags & EVENTLOG_FORWARDS_READ ) record_number++; else record_number--; + + /* update the eventlog record pointer */ + + info->current_record = record_number; } - - return NT_STATUS_OK; + + /* crazy by WinXP uses NT_STATUS_BUFFER_TOO_SMALL to + say when there are no more records */ + + return (num_records_read ? NT_STATUS_OK : NT_STATUS_BUFFER_TOO_SMALL); } /******************************************************************** -- cgit From 5251618c7fff7635a4b64072f88eaf5e4e25761e Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 17 Nov 2005 20:08:59 +0000 Subject: r11761: * fix clearing of event logs by truncating the tdb. This feature got broken in some of the other updates. Now each open handle stores an pointer to an open tdb data structure (not the tdb pointer itself). Clearing can be done with a simple elog_close_tdb( elog, True ) to force a close and then calling elog_open_tdb( logname, True ) to force an tdb truncate. Permissions on existing tdbs are maintained which is important. * We don't currently handle backup. Haven't looked at the format of a backuped up eventlog to know what the deal is. (This used to be commit 2df34c9403446d12f1ceeac38cbda5d3ba805b02) --- source3/rpc_server/srv_eventlog_lib.c | 107 +++++++++++++++++++--------------- source3/rpc_server/srv_eventlog_nt.c | 64 +++++++++++--------- 2 files changed, 94 insertions(+), 77 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index b21c2a2529..ec5edf2f34 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -24,14 +24,7 @@ /* maintain a list of open eventlog tdbs with reference counts */ -struct elog_open_tdb { - struct elog_open_tdb *prev, *next; - char *name; - TDB_CONTEXT *tdb; - int ref_count; -}; - -static struct elog_open_tdb *open_elog_list; +static ELOG_TDB *open_elog_list; /******************************************************************** Init an Eventlog TDB, and return it. If null, something bad @@ -317,14 +310,14 @@ BOOL can_write_to_eventlog( TDB_CONTEXT * tdb, int32 needed ) /******************************************************************* *******************************************************************/ -TDB_CONTEXT *elog_open_tdb( char *logname ) +ELOG_TDB *elog_open_tdb( char *logname, BOOL force_clear ) { - TDB_CONTEXT *tdb; + TDB_CONTEXT *tdb = NULL; uint32 vers_id; - struct elog_open_tdb *ptr; + ELOG_TDB *ptr; char *tdbfilename; pstring tdbpath; - struct elog_open_tdb *tdb_node; + ELOG_TDB *tdb_node = NULL; char *eventlogdir; /* first see if we have an open context */ @@ -332,7 +325,19 @@ TDB_CONTEXT *elog_open_tdb( char *logname ) for ( ptr=open_elog_list; ptr; ptr=ptr->next ) { if ( strequal( ptr->name, logname ) ) { ptr->ref_count++; - return ptr->tdb; + + /* trick to alow clearing of the eventlog tdb. + The force_clear flag should imply that someone + has done a force close. So make sure the tdb + is NULL. If this is a normal open, then just + return the existing reference */ + + if ( force_clear ) { + SMB_ASSERT( ptr->tdb == NULL ); + break; + } + else + return ptr; } } @@ -348,27 +353,41 @@ TDB_CONTEXT *elog_open_tdb( char *logname ) pstrcpy( tdbpath, tdbfilename ); SAFE_FREE( tdbfilename ); - DEBUG(7,("elog_open_tdb: Opening %s...\n", tdbpath )); + DEBUG(7,("elog_open_tdb: Opening %s...(force_clear == %s)\n", + tdbpath, force_clear?"True":"False" )); + + /* the tdb wasn't already open or this is a forced clear open */ - tdb = tdb_open_log( tdbpath, 0, TDB_DEFAULT, O_RDWR , 0 ); - if ( tdb ) { - vers_id = tdb_fetch_int32( tdb, EVT_VERSION ); + if ( !force_clear ) { - if ( vers_id != EVENTLOG_DATABASE_VERSION_V1 ) { - DEBUG(1,("elog_open_tdb: Invalid version [%d] on file [%s].\n", - vers_id, tdbpath)); - tdb_close( tdb ); - tdb = elog_init_tdb( tdbpath ); + tdb = tdb_open_log( tdbpath, 0, TDB_DEFAULT, O_RDWR , 0 ); + if ( tdb ) { + vers_id = tdb_fetch_int32( tdb, EVT_VERSION ); + + if ( vers_id != EVENTLOG_DATABASE_VERSION_V1 ) { + DEBUG(1,("elog_open_tdb: Invalid version [%d] on file [%s].\n", + vers_id, tdbpath)); + tdb_close( tdb ); + tdb = elog_init_tdb( tdbpath ); + } } } - else { + + if ( !tdb ) tdb = elog_init_tdb( tdbpath ); - } /* if we got a valid context, then add it to the list */ if ( tdb ) { - if ( !(tdb_node = TALLOC_ZERO_P( NULL, struct elog_open_tdb )) ) { + /* on a forced clear, just reset the tdb context if we already + have an open entry in the list */ + + if ( ptr ) { + ptr->tdb = tdb; + return ptr; + } + + if ( !(tdb_node = TALLOC_ZERO_P( NULL, ELOG_TDB)) ) { DEBUG(0,("elog_open_tdb: talloc() failure!\n")); tdb_close( tdb ); return NULL; @@ -381,42 +400,34 @@ TDB_CONTEXT *elog_open_tdb( char *logname ) DLIST_ADD( open_elog_list, tdb_node ); } - return tdb; + return tdb_node; } /******************************************************************* Wrapper to handle reference counts to the tdb *******************************************************************/ -int elog_close_tdb( TDB_CONTEXT *tdb ) +int elog_close_tdb( ELOG_TDB *etdb, BOOL force_close ) { - struct elog_open_tdb *ptr; + TDB_CONTEXT *tdb; - if ( !tdb ) + if ( !etdb ) return 0; - /* See if we can just decrement the ref_count. - Just compare pointer values (not names ) */ - - for ( ptr=open_elog_list; ptr; ptr=ptr->next ) { - if ( tdb == ptr->tdb ) { - ptr->ref_count--; - break; - } - } + etdb->ref_count--; - /* if we have a NULL pointer; it means we are trying to - close a tdb not in the list of open eventlogs */ - - SMB_ASSERT( ptr != NULL ); - if ( !ptr ) + SMB_ASSERT( etdb->ref_count >= 0 ); + + if ( etdb->ref_count == 0 ) { + tdb = etdb->tdb; + DLIST_REMOVE( open_elog_list, etdb ); + TALLOC_FREE( etdb ); return tdb_close( tdb ); + } - SMB_ASSERT( ptr->ref_count >= 0 ); - - if ( ptr->ref_count == 0 ) { - DLIST_REMOVE( open_elog_list, ptr ); - TALLOC_FREE( ptr ); + if ( force_close ) { + tdb = etdb->tdb; + etdb->tdb = NULL; return tdb_close( tdb ); } diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 0f0b73029a..05feb51f95 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -27,7 +27,7 @@ typedef struct { char *logname; - TDB_CONTEXT *tdb; + ELOG_TDB *etdb; uint32 current_record; uint32 num_records; uint32 oldest_entry; @@ -42,8 +42,8 @@ static void free_eventlog_info( void *ptr ) { EVENTLOG_INFO *elog = (EVENTLOG_INFO *)ptr; - if ( elog->tdb ) - elog_close_tdb( elog->tdb ); + if ( elog->etdb ) + elog_close_tdb( elog->etdb, False ); TALLOC_FREE( elog ); } @@ -139,17 +139,17 @@ static BOOL get_num_records_hook( EVENTLOG_INFO * info ) int next_record; int oldest_record; - if ( !info->tdb ) { + if ( !info->etdb ) { DEBUG( 10, ( "No open tdb for %s\n", info->logname ) ); return False; } /* lock the tdb since we have to get 2 records */ - tdb_lock_bystring( info->tdb, EVT_NEXT_RECORD, 1 ); - next_record = tdb_fetch_int32( info->tdb, EVT_NEXT_RECORD); - oldest_record = tdb_fetch_int32( info->tdb, EVT_OLDEST_ENTRY); - tdb_unlock_bystring( info->tdb, EVT_NEXT_RECORD); + tdb_lock_bystring( ELOG_TDB_CTX(info->etdb), EVT_NEXT_RECORD, 1 ); + next_record = tdb_fetch_int32( ELOG_TDB_CTX(info->etdb), EVT_NEXT_RECORD); + oldest_record = tdb_fetch_int32( ELOG_TDB_CTX(info->etdb), EVT_OLDEST_ENTRY); + tdb_unlock_bystring( ELOG_TDB_CTX(info->etdb), EVT_NEXT_RECORD); DEBUG( 8, ( "Oldest Record %d; Next Record %d\n", oldest_record, @@ -193,10 +193,10 @@ static NTSTATUS elog_open( pipes_struct * p, const char *logname, POLICY_HND *hn in a single process */ become_root(); - elog->tdb = elog_open_tdb( elog->logname ); + elog->etdb = elog_open_tdb( elog->logname, False ); unbecome_root(); - if ( !elog->tdb ) { + if ( !elog->etdb ) { /* according to MSDN, if the logfile cannot be found, we should default to the "Application" log */ @@ -213,11 +213,11 @@ static NTSTATUS elog_open( pipes_struct * p, const char *logname, POLICY_HND *hn } become_root(); - elog->tdb = elog_open_tdb( elog->logname ); + elog->etdb = elog_open_tdb( elog->logname, False ); unbecome_root(); } - if ( !elog->tdb ) { + if ( !elog->etdb ) { TALLOC_FREE( elog ); return NT_STATUS_ACCESS_DENIED; /* ??? */ } @@ -226,7 +226,7 @@ static NTSTATUS elog_open( pipes_struct * p, const char *logname, POLICY_HND *hn /* now do the access check. Close the tdb if we fail here */ if ( !elog_check_access( elog, p->pipe_user.nt_user_token ) ) { - elog_close_tdb( elog->tdb ); + elog_close_tdb( elog->etdb, False ); TALLOC_FREE( elog ); return NT_STATUS_ACCESS_DENIED; } @@ -268,12 +268,12 @@ static NTSTATUS elog_close( pipes_struct *p, POLICY_HND *hnd ) static int elog_size( EVENTLOG_INFO *info ) { - if ( !info || !info->tdb ) { + if ( !info || !info->etdb ) { DEBUG(0,("elog_size: Invalid info* structure!\n")); return 0; } - return elog_tdb_size( info->tdb, NULL, NULL ); + return elog_tdb_size( ELOG_TDB_CTX(info->etdb), NULL, NULL ); } /******************************************************************** @@ -397,7 +397,7 @@ static BOOL sync_eventlog_params( EVENTLOG_INFO *info ) DEBUG( 4, ( "sync_eventlog_params with %s\n", elogname ) ); - if ( !info->tdb ) { + if ( !info->etdb ) { DEBUG( 4, ( "No open tdb! (%s)\n", info->logname ) ); return False; } @@ -440,8 +440,8 @@ static BOOL sync_eventlog_params( EVENTLOG_INFO *info ) regkey_close_internal( keyinfo ); - tdb_store_int32( info->tdb, EVT_MAXSIZE, uiMaxSize ); - tdb_store_int32( info->tdb, EVT_RETENTION, uiRetention ); + tdb_store_int32( ELOG_TDB_CTX(info->etdb), EVT_MAXSIZE, uiMaxSize ); + tdb_store_int32( ELOG_TDB_CTX(info->etdb), EVT_RETENTION, uiRetention ); return True; } @@ -610,7 +610,7 @@ NTSTATUS _eventlog_open_eventlog( pipes_struct * p, DEBUG(10,("_eventlog_open_eventlog: Size [%d]\n", elog_size( info ))); sync_eventlog_params( info ); - prune_eventlog( info->tdb ); + prune_eventlog( ELOG_TDB_CTX(info->etdb) ); return NT_STATUS_OK; } @@ -634,20 +634,26 @@ NTSTATUS _eventlog_clear_eventlog( pipes_struct * p, rpcstr_pull( backup_file_name, q_u->backupfile.string->buffer, sizeof( backup_file_name ), q_u->backupfile.string->uni_str_len * 2, 0 ); + + DEBUG(8,( "_eventlog_clear_eventlog: Using [%s] as the backup " + "file name for log [%s].", + backup_file_name, info->logname ) ); } - DEBUG( 8, - ( "_eventlog_clear_eventlog: Using [%s] as the backup file name for log [%s].", - backup_file_name, info->logname ) ); + /* check for WRITE access to the file */ + + if ( !(info->access_granted&SA_RIGHT_FILE_WRITE_DATA) ) + return NT_STATUS_ACCESS_DENIED; -#if 0 - /* close the current one, reinit */ + /* Force a close and reopen */ - tdb_close( info->tdb ); + elog_close_tdb( info->etdb, True ); + become_root(); + info->etdb = elog_open_tdb( info->logname, True ); + unbecome_root(); - if ( !(info->tdb = elog_init_tdb( ttdb[i].tdbfname )) ) + if ( !info->etdb ) return NT_STATUS_ACCESS_DENIED; -#endif return NT_STATUS_OK; } @@ -680,7 +686,7 @@ NTSTATUS _eventlog_read_eventlog( pipes_struct * p, bytes_left = q_u->max_read_size; - if ( !info->tdb ) + if ( !info->etdb ) return NT_STATUS_ACCESS_DENIED; /* check for valid flags. Can't use the sequential and seek flags together */ @@ -706,7 +712,7 @@ NTSTATUS _eventlog_read_eventlog( pipes_struct * p, /* assume that when the record fetch fails, that we are done */ - if ( !get_eventlog_record ( ps, info->tdb, record_number, &entry ) ) + if ( !get_eventlog_record ( ps, ELOG_TDB_CTX(info->etdb), record_number, &entry ) ) break; DEBUG( 8, ( "Retrieved record %d\n", record_number ) ); -- cgit From 1ce288386575fb1c9d464ff463094c2294cb5564 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 17 Nov 2005 21:03:22 +0000 Subject: r11762: fix my build breakage (This used to be commit 9ee851630ec3443f27a61de6eaf222c74d2d064a) --- source3/rpc_server/srv_eventlog_nt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 05feb51f95..658928b927 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -680,9 +680,10 @@ NTSTATUS _eventlog_read_eventlog( pipes_struct * p, uint32 num_records_read = 0; prs_struct *ps; int bytes_left, record_number; + uint32 elog_read_type, elog_read_dir; + info->flags = q_u->flags; ps = &p->out_data.rdata; - uint32 elog_read_type, elog_read_dir; bytes_left = q_u->max_read_size; -- cgit From d09beee040b62d9b783869bc9af7f17301e3f5e0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 17 Nov 2005 22:40:10 +0000 Subject: r11769: Looking at a performance problem enumerating accounts, wondered if changing to support samr_connect5 might help so quickly coded it up. No it doesn't :-(. Don't merge this for 3.0.21 please. Jeremy. (This used to be commit bff1df678a8948d382f4555e83a1df23146a4b12) --- source3/rpc_server/srv_samr.c | 34 ++++++++++++++++++++++++- source3/rpc_server/srv_samr_nt.c | 54 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index ffb7882e11..520bf47a31 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -679,6 +679,37 @@ static BOOL api_samr_connect4(pipes_struct *p) return True; } +/******************************************************************* + api_samr_connect5 + ********************************************************************/ + +static BOOL api_samr_connect5(pipes_struct *p) +{ + SAMR_Q_CONNECT5 q_u; + SAMR_R_CONNECT5 r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the samr open policy */ + if(!samr_io_q_connect5("", &q_u, data, 0)) { + DEBUG(0,("api_samr_connect5: unable to unmarshall SAMR_Q_CONNECT5.\n")); + return False; + } + + r_u.status = _samr_connect5(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!samr_io_r_connect5("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_connect5: unable to marshall SAMR_R_CONNECT5.\n")); + return False; + } + + return True; +} + /********************************************************************** api_samr_lookup_domain **********************************************************************/ @@ -1492,7 +1523,8 @@ static struct api_struct api_samr_cmds [] = {"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, {"SAMR_UNKNOWN_2E" , SAMR_UNKNOWN_2E , api_samr_unknown_2e }, {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, - {"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 } + {"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 }, + {"SAMR_CONNECT5" , SAMR_CONNECT5 , api_samr_connect5 } }; void samr_get_pipe_fns( struct api_struct **fns, int *n_fns ) diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 71272a9a98..bfc96ea0f6 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2293,6 +2293,60 @@ NTSTATUS _samr_connect4(pipes_struct *p, SAMR_Q_CONNECT4 *q_u, SAMR_R_CONNECT4 * return r_u->status; } +/******************************************************************* + samr_connect5 + ********************************************************************/ + +NTSTATUS _samr_connect5(pipes_struct *p, SAMR_Q_CONNECT5 *q_u, SAMR_R_CONNECT5 *r_u) +{ + struct samr_info *info = NULL; + SEC_DESC *psd = NULL; + uint32 acc_granted; + uint32 des_access = q_u->access_mask; + NTSTATUS nt_status; + POLICY_HND pol; + size_t sd_size; + + + DEBUG(5,("_samr_connect5: %d\n", __LINE__)); + + ZERO_STRUCTP(r_u); + + /* Access check */ + + if (!pipe_access_check(p)) { + DEBUG(3, ("access denied to samr_connect5\n")); + r_u->status = NT_STATUS_ACCESS_DENIED; + return r_u->status; + } + + make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); + se_map_generic(&des_access, &sam_generic_mapping); + + nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, + NULL, 0, des_access, &acc_granted, "_samr_connect5"); + + if ( !NT_STATUS_IS_OK(nt_status) ) + return nt_status; + + /* associate the user's SID and access granted with the new handle. */ + if ((info = get_samr_info_by_sid(NULL)) == NULL) + return NT_STATUS_NO_MEMORY; + + info->acc_granted = acc_granted; + info->status = q_u->access_mask; + + /* get a (unique) handle. open a policy on it. */ + if (!create_policy_hnd(p, &pol, free_samr_info, (void *)info)) + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + + DEBUG(5,("_samr_connect: %d\n", __LINE__)); + + init_samr_r_connect5(r_u, &pol, NT_STATUS_OK); + + return r_u->status; +} + /********************************************************************** api_samr_lookup_domain **********************************************************************/ -- cgit From 9be0ce442285a0f63e6c226f6cf07d05a3f20021 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 18 Nov 2005 23:15:47 +0000 Subject: r11793: Fix the SAMR cache so it works across completely insane client behaviour (ie.: open pipe/open SAMR handle/enumerate 0 - 1024 close SAMR handle, close pipe. open pipe/open SAMR handle/enumerate 1024 - 2048... close SAMR handle, close pipe. And on ad-nausium. Amazing.... probably object-oriented client side programming in action yet again. This change should *massively* improve performance when enumerating users from an LDAP database. Jeremy. (This used to be commit 8ce705d9cc1b6a79d710a10ff38f72a0f1006dda) --- source3/rpc_server/srv_samr.c | 20 +- source3/rpc_server/srv_samr_nt.c | 522 +++++++++++++++++++++++++++++---------- 2 files changed, 407 insertions(+), 135 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 520bf47a31..e8fd86ba46 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1405,13 +1405,13 @@ static BOOL api_samr_remove_sid_foreign_domain(pipes_struct *p) } /******************************************************************* - api_samr_query_dom_info + api_samr_query_dom_info2 ********************************************************************/ -static BOOL api_samr_unknown_2e(pipes_struct *p) +static BOOL api_samr_query_domain_info2(pipes_struct *p) { - SAMR_Q_UNKNOWN_2E q_u; - SAMR_R_UNKNOWN_2E r_u; + SAMR_Q_QUERY_DOMAIN_INFO2 q_u; + SAMR_R_QUERY_DOMAIN_INFO2 r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -1419,16 +1419,16 @@ static BOOL api_samr_unknown_2e(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the samr unknown 8 command */ - if(!samr_io_q_unknown_2e("", &q_u, data, 0)) { - DEBUG(0,("api_samr_unknown_2e: unable to unmarshall SAMR_Q_UNKNOWN_2E.\n")); + if(!samr_io_q_query_domain_info2("", &q_u, data, 0)) { + DEBUG(0,("api_samr_query_domain_info2: unable to unmarshall SAMR_Q_QUERY_DOMAIN_INFO2.\n")); return False; } - r_u.status = _samr_unknown_2e(p, &q_u, &r_u); + r_u.status = _samr_query_domain_info2(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_samr_unknown_2e("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_unknown_2e: unable to marshall SAMR_R_UNKNOWN_2E.\n")); + if(!samr_io_r_samr_query_domain_info2("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_query_domain_info2: unable to marshall SAMR_R_QUERY_DOMAIN_INFO2.\n")); return False; } @@ -1521,7 +1521,7 @@ static struct api_struct api_samr_cmds [] = {"SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, {"SAMR_SET_SEC_OBJECT" , SAMR_SET_SEC_OBJECT , api_samr_set_sec_obj }, {"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, - {"SAMR_UNKNOWN_2E" , SAMR_UNKNOWN_2E , api_samr_unknown_2e }, + {"SAMR_QUERY_DOMAIN_INFO2", SAMR_QUERY_DOMAIN_INFO2, api_samr_query_domain_info2}, {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, {"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 }, {"SAMR_CONNECT5" , SAMR_CONNECT5 , api_samr_connect5 } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index bfc96ea0f6..563c3f864f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -40,11 +40,16 @@ SA_RIGHT_USER_CHANGE_PASSWORD | \ SA_RIGHT_USER_SET_LOC_COM ) +#define DISP_INFO_CACHE_TIMEOUT 30 + extern rid_name domain_group_rids[]; extern rid_name domain_alias_rids[]; extern rid_name builtin_alias_rids[]; typedef struct disp_info { + struct disp_info *next, *prev; + TALLOC_CTX *mem_ctx; + DOM_SID sid; /* identify which domain this is. */ struct pdb_search *users; /* querydispinfo 1 and 4 */ struct pdb_search *machines; /* querydispinfo 2 */ struct pdb_search *groups; /* querydispinfo 3 and 5, enumgroups */ @@ -53,8 +58,15 @@ typedef struct disp_info { uint16 enum_acb_mask; struct pdb_search *enum_users; /* enumusers with a mask */ + + smb_event_id_t di_cache_timeout_event; /* cache idle timeout handler. */ } DISP_INFO; +/* We keep a static list of these by SID as modern clients close down + all resources between each request in a complete enumeration. */ + +static DISP_INFO *disp_info_list; + struct samr_info { /* for use by the \PIPE\samr policy */ DOM_SID sid; @@ -62,8 +74,7 @@ struct samr_info { uint32 acc_granted; uint16 acb_mask; BOOL only_machines; - DISP_INFO disp_info; - + DISP_INFO *disp_info; TALLOC_CTX *mem_ctx; }; @@ -215,6 +226,39 @@ static NTSTATUS access_check_samr_function(uint32 acc_granted, uint32 acc_requir return NT_STATUS_ACCESS_DENIED; } +/******************************************************************* + Fetch or create a dispinfo struct. +********************************************************************/ + +static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid, const char *sid_str) +{ + TALLOC_CTX *mem_ctx; + DISP_INFO *dpi; + + for (dpi = disp_info_list; dpi; dpi = dpi->next) { + if (sid_equal(psid, &dpi->sid)) { + return dpi; + } + } + + /* This struct is never free'd - I'm using talloc so we + can get a list out of smbd using smbcontrol. There will + be one of these per SID we're authorative for. JRA. */ + + mem_ctx = talloc_init("DISP_INFO for domain sid %s", sid_str); + + if ((dpi = TALLOC_ZERO_P(mem_ctx, DISP_INFO)) == NULL) + return NULL; + + dpi->mem_ctx = mem_ctx; + if (psid) { + sid_copy( &dpi->sid, psid); + } + + DLIST_ADD(disp_info_list, dpi); + + return dpi; +} /******************************************************************* Create a samr_info struct. @@ -244,41 +288,143 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) DEBUG(10,("get_samr_info_by_sid: created new info for NULL sid.\n")); } info->mem_ctx = mem_ctx; + + info->disp_info = get_samr_dispinfo_by_sid(psid, sid_str); + + if (!info->disp_info) { + talloc_destroy(mem_ctx); + return NULL; + } + return info; } /******************************************************************* - Function to free the per handle data. + Function to free the per SID data. ********************************************************************/ +static void free_samr_cache(DISP_INFO *disp_info) +{ + DEBUG(10,("free_samr_cache: deleting cache\n")); + + if (disp_info->users) { + DEBUG(10,("free_samr_cache: deleting users cache\n")); + pdb_search_destroy(disp_info->users); + disp_info->users = NULL; + } + if (disp_info->machines) { + DEBUG(10,("free_samr_cache: deleting machines cache\n")); + pdb_search_destroy(disp_info->machines); + disp_info->machines = NULL; + } + if (disp_info->groups) { + DEBUG(10,("free_samr_cache: deleting groups cache\n")); + pdb_search_destroy(disp_info->groups); + disp_info->groups = NULL; + } + if (disp_info->aliases) { + DEBUG(10,("free_samr_cache: deleting aliases cache\n")); + pdb_search_destroy(disp_info->aliases); + disp_info->aliases = NULL; + } + if (disp_info->builtins) { + DEBUG(10,("free_samr_cache: deleting builtins cache\n")); + pdb_search_destroy(disp_info->builtins); + disp_info->builtins = NULL; + } + if (disp_info->enum_users) { + DEBUG(10,("free_samr_cache: deleting enum_users cache\n")); + pdb_search_destroy(disp_info->enum_users); + disp_info->enum_users = NULL; + } + disp_info->enum_acb_mask = 0; +} + /******************************************************************* Function to free the per handle data. ********************************************************************/ -static void free_samr_db(struct samr_info *info) -{ - pdb_search_destroy(info->disp_info.users); - info->disp_info.users = NULL; - pdb_search_destroy(info->disp_info.machines); - info->disp_info.machines = NULL; - pdb_search_destroy(info->disp_info.groups); - info->disp_info.groups = NULL; - pdb_search_destroy(info->disp_info.aliases); - info->disp_info.aliases = NULL; - pdb_search_destroy(info->disp_info.builtins); - info->disp_info.builtins = NULL; - pdb_search_destroy(info->disp_info.enum_users); - info->disp_info.enum_users = NULL; -} - static void free_samr_info(void *ptr) { struct samr_info *info=(struct samr_info *) ptr; - free_samr_db(info); + /* Only free the dispinfo cache if no one bothered to set up + a timeout. */ + + if (info->disp_info && info->disp_info->di_cache_timeout_event == (smb_event_id_t)0) { + free_samr_cache(info->disp_info); + } + talloc_destroy(info->mem_ctx); } +/******************************************************************* + Idle event handler. Throw away the disp info cache. + ********************************************************************/ + +static void disp_info_cache_idle_timeout_handler(void **private_data, + time_t *ev_interval, + time_t ev_now) +{ + DISP_INFO *disp_info = (DISP_INFO *)(*private_data); + + free_samr_cache(disp_info); + + /* Remove the event. */ + smb_unregister_idle_event(disp_info->di_cache_timeout_event); + disp_info->di_cache_timeout_event = (smb_event_id_t)0; + + DEBUG(10,("disp_info_cache_idle_timeout_handler: caching timed out at %u\n", + (unsigned int)ev_now)); +} + +/******************************************************************* + Setup cache removal idle event handler. + ********************************************************************/ + +static void set_disp_info_cache_timeout(DISP_INFO *disp_info, time_t secs_fromnow) +{ + /* Remove any pending timeout and update. */ + + if (disp_info->di_cache_timeout_event) { + smb_unregister_idle_event(disp_info->di_cache_timeout_event); + disp_info->di_cache_timeout_event = (smb_event_id_t)0; + } + + DEBUG(10,("set_disp_info_cache_timeout: caching enumeration for %u seconds\n", + (unsigned int)secs_fromnow )); + + disp_info->di_cache_timeout_event = + smb_register_idle_event(disp_info_cache_idle_timeout_handler, + disp_info, + secs_fromnow); +} + +/******************************************************************* + Remove the cache removal idle event handler. + ********************************************************************/ + +static void clear_disp_info_cache_timeout(DISP_INFO *disp_info) +{ + if (disp_info->di_cache_timeout_event) { + smb_unregister_idle_event(disp_info->di_cache_timeout_event); + disp_info->di_cache_timeout_event = (smb_event_id_t)0; + DEBUG(10,("clear_disp_info_cache_timeout: clearing idle event.\n")); + } +} + +/******************************************************************* + Force flush any cache. We do this on any samr_set_xxx call. + ********************************************************************/ + +static void force_flush_samr_cache(DISP_INFO *disp_info) +{ + if (disp_info) { + clear_disp_info_cache_timeout(disp_info); + free_samr_cache(disp_info); + } +} + /******************************************************************* Ensure password info is never given out. Paranioa... JRA. ********************************************************************/ @@ -298,24 +444,36 @@ static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) static uint32 count_sam_users(struct disp_info *info, uint16 acct_flags) { struct samr_displayentry *entry; - if (info->users == NULL) + if (info->users == NULL) { info->users = pdb_search_users(acct_flags); - if (info->users == NULL) - return 0; + if (info->users == NULL) { + return 0; + } + } /* Fetch the last possible entry, thus trigger an enumeration */ pdb_search_entries(info->users, 0xffffffff, 1, &entry); + + /* Ensure we cache this enumeration. */ + set_disp_info_cache_timeout(info, DISP_INFO_CACHE_TIMEOUT); + return info->users->num_entries; } static uint32 count_sam_groups(struct disp_info *info) { struct samr_displayentry *entry; - if (info->groups == NULL) + if (info->groups == NULL) { info->groups = pdb_search_groups(); - if (info->groups == NULL) - return 0; + if (info->groups == NULL) { + return 0; + } + } /* Fetch the last possible entry, thus trigger an enumeration */ pdb_search_entries(info->groups, 0xffffffff, 1, &entry); + + /* Ensure we cache this enumeration. */ + set_disp_info_cache_timeout(info, DISP_INFO_CACHE_TIMEOUT); + return info->groups->num_entries; } @@ -431,12 +589,12 @@ NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_ return NT_STATUS_NOT_IMPLEMENTED; } - /******************************************************************* ********************************************************************/ static BOOL get_lsa_policy_samr_sid( pipes_struct *p, POLICY_HND *pol, - DOM_SID *sid, uint32 *acc_granted) + DOM_SID *sid, uint32 *acc_granted, + DISP_INFO **ppdisp_info) { struct samr_info *info = NULL; @@ -449,6 +607,10 @@ static BOOL get_lsa_policy_samr_sid( pipes_struct *p, POLICY_HND *pol, *sid = info->sid; *acc_granted = info->acc_granted; + if (ppdisp_info) { + *ppdisp_info = info->disp_info; + } + return True; } @@ -467,42 +629,35 @@ NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_ r_u->status = NT_STATUS_OK; /* Get the SID. */ - if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &pol_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &pol_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - - DEBUG(10,("_samr_query_sec_obj: querying security on SID: %s\n", sid_to_string(str_sid, &pol_sid))); /* Check what typ of SID is beeing queried (e.g Domain SID, User SID, Group SID) */ /* To query the security of the SAM it self an invalid SID with S-0-0 is passed to this function */ - if (pol_sid.sid_rev_num == 0) - { + if (pol_sid.sid_rev_num == 0) { DEBUG(5,("_samr_query_sec_obj: querying security on SAM\n")); r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); - } - else if (sid_equal(&pol_sid,get_global_sam_sid())) /* check if it is our domain SID */ - - { + } else if (sid_equal(&pol_sid,get_global_sam_sid())) { + /* check if it is our domain SID */ DEBUG(5,("_samr_query_sec_obj: querying security on Domain with SID: %s\n", sid_to_string(str_sid, &pol_sid))); r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0); - } - else if (sid_equal(&pol_sid,&global_sid_Builtin)) /* check if it is the Builtin Domain */ - { + } else if (sid_equal(&pol_sid,&global_sid_Builtin)) { + /* check if it is the Builtin Domain */ /* TODO: Builtin probably needs a different SD with restricted write access*/ DEBUG(5,("_samr_query_sec_obj: querying security on Builtin Domain with SID: %s\n", sid_to_string(str_sid, &pol_sid))); r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0); - } - else if (sid_check_is_in_our_domain(&pol_sid) || - sid_check_is_in_builtin(&pol_sid)) - { + } else if (sid_check_is_in_our_domain(&pol_sid) || + sid_check_is_in_builtin(&pol_sid)) { /* TODO: different SDs have to be generated for aliases groups and users. Currently all three get a default user SD */ DEBUG(10,("_samr_query_sec_obj: querying security on Object with SID: %s\n", sid_to_string(str_sid, &pol_sid))); r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, &pol_sid, SAMR_USR_RIGHTS_WRITE_PW); + } else { + return NT_STATUS_OBJECT_TYPE_MISMATCH; } - else return NT_STATUS_OBJECT_TYPE_MISMATCH; if ((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL) return NT_STATUS_NO_MEMORY; @@ -594,21 +749,32 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); become_root(); - if ((info->disp_info.enum_users != NULL) && - (info->disp_info.enum_acb_mask != q_u->acb_mask)) { - pdb_search_destroy(info->disp_info.enum_users); - info->disp_info.enum_users = NULL; + + /* AS ROOT !!!! */ + + if ((info->disp_info->enum_users != NULL) && + (info->disp_info->enum_acb_mask != q_u->acb_mask)) { + pdb_search_destroy(info->disp_info->enum_users); + info->disp_info->enum_users = NULL; } - if (info->disp_info.enum_users == NULL) { - info->disp_info.enum_users = pdb_search_users(q_u->acb_mask); - info->disp_info.enum_acb_mask = q_u->acb_mask; + if (info->disp_info->enum_users == NULL) { + info->disp_info->enum_users = pdb_search_users(q_u->acb_mask); + info->disp_info->enum_acb_mask = q_u->acb_mask; } - if (info->disp_info.enum_users == NULL) + + if (info->disp_info->enum_users == NULL) { + /* END AS ROOT !!!! */ + unbecome_root(); return NT_STATUS_ACCESS_DENIED; - num_account = pdb_search_entries(info->disp_info.enum_users, + } + + num_account = pdb_search_entries(info->disp_info->enum_users, enum_context, max_entries, &entries); + + /* END AS ROOT !!!! */ + unbecome_root(); if (num_account == 0) { @@ -625,8 +791,13 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, if (!NT_STATUS_IS_OK(r_u->status)) return r_u->status; - if (max_entries <= num_account) + if (max_entries <= num_account) { + /* Ensure we cache this enumeration. */ + set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); r_u->status = STATUS_MORE_ENTRIES; + } else { + clear_disp_info_cache_timeout(info->disp_info); + } DEBUG(5, ("_samr_enum_dom_users: %d\n", __LINE__)); @@ -705,18 +876,23 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM /* the domain group array is being allocated in the function below */ become_root(); - if (info->disp_info.groups == NULL) - info->disp_info.groups = pdb_search_groups(); - unbecome_root(); - if (info->disp_info.groups == NULL) - return NT_STATUS_ACCESS_DENIED; + if (info->disp_info->groups == NULL) { + info->disp_info->groups = pdb_search_groups(); - become_root(); - num_groups = pdb_search_entries(info->disp_info.groups, q_u->start_idx, + if (info->disp_info->groups == NULL) { + unbecome_root(); + return NT_STATUS_ACCESS_DENIED; + } + } + + num_groups = pdb_search_entries(info->disp_info->groups, q_u->start_idx, MAX_SAM_ENTRIES, &groups); unbecome_root(); + /* Ensure we cache this enumeration. */ + set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); + make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_groups, groups); @@ -752,26 +928,30 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S sid_string_static(&info->sid))); if (sid_check_is_domain(&info->sid)) - search = &info->disp_info.aliases; + search = &info->disp_info->aliases; if (sid_check_is_builtin(&info->sid)) - search = &info->disp_info.builtins; + search = &info->disp_info->builtins; if (search == NULL) return NT_STATUS_INVALID_HANDLE; become_root(); - if (*search == NULL) - *search = pdb_search_aliases(&info->sid); - unbecome_root(); - if (*search == NULL) - return NT_STATUS_ACCESS_DENIED; + if (*search == NULL) { + *search = pdb_search_aliases(&info->sid); + if (*search == NULL) { + unbecome_root(); + return NT_STATUS_ACCESS_DENIED; + } + } - become_root(); num_aliases = pdb_search_entries(*search, q_u->start_idx, MAX_SAM_ENTRIES, &aliases); unbecome_root(); + /* Ensure we cache this enumeration. */ + set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); + make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, num_aliases, aliases); @@ -872,38 +1052,68 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, become_root(); + /* THe following done as ROOT. Don't return without unbecome_root(). */ + switch (q_u->switch_level) { case 0x1: case 0x4: - if (info->disp_info.users == NULL) - info->disp_info.users = pdb_search_users(ACB_NORMAL); - if (info->disp_info.users == NULL) - return NT_STATUS_ACCESS_DENIED; - num_account = pdb_search_entries(info->disp_info.users, + if (info->disp_info->users == NULL) { + info->disp_info->users = pdb_search_users(ACB_NORMAL); + if (info->disp_info->users == NULL) { + unbecome_root(); + return NT_STATUS_ACCESS_DENIED; + } + DEBUG(10,("samr_reply_query_dispinfo: starting user enumeration at index %u\n", + (unsigned int)enum_context )); + } else { + DEBUG(10,("samr_reply_query_dispinfo: using cached user enumeration at index %u\n", + (unsigned int)enum_context )); + } + + num_account = pdb_search_entries(info->disp_info->users, enum_context, max_entries, &entries); break; case 0x2: - if (info->disp_info.machines == NULL) - info->disp_info.machines = + if (info->disp_info->machines == NULL) { + info->disp_info->machines = pdb_search_users(ACB_WSTRUST|ACB_SVRTRUST); - if (info->disp_info.machines == NULL) - return NT_STATUS_ACCESS_DENIED; - num_account = pdb_search_entries(info->disp_info.machines, + if (info->disp_info->machines == NULL) { + unbecome_root(); + return NT_STATUS_ACCESS_DENIED; + } + DEBUG(10,("samr_reply_query_dispinfo: starting machine enumeration at index %u\n", + (unsigned int)enum_context )); + } else { + DEBUG(10,("samr_reply_query_dispinfo: using cached machine enumeration at index %u\n", + (unsigned int)enum_context )); + } + + num_account = pdb_search_entries(info->disp_info->machines, enum_context, max_entries, &entries); break; case 0x3: case 0x5: - if (info->disp_info.groups == NULL) - info->disp_info.groups = pdb_search_groups(); - if (info->disp_info.groups == NULL) - return NT_STATUS_ACCESS_DENIED; - num_account = pdb_search_entries(info->disp_info.groups, + if (info->disp_info->groups == NULL) { + info->disp_info->groups = pdb_search_groups(); + if (info->disp_info->groups == NULL) { + unbecome_root(); + return NT_STATUS_ACCESS_DENIED; + } + DEBUG(10,("samr_reply_query_dispinfo: starting group enumeration at index %u\n", + (unsigned int)enum_context )); + } else { + DEBUG(10,("samr_reply_query_dispinfo: using cached group enumeration at index %u\n", + (unsigned int)enum_context )); + } + + num_account = pdb_search_entries(info->disp_info->groups, enum_context, max_entries, &entries); break; default: + unbecome_root(); smb_panic("info class changed"); break; } @@ -947,10 +1157,14 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, /* calculate the total size */ total_data_size=num_account*struct_size; - if (num_account) + if (num_account) { + /* Ensure we cache this enumeration. */ + set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); r_u->status = STATUS_MORE_ENTRIES; - else + } else { + clear_disp_info_cache_timeout(info->disp_info); r_u->status = NT_STATUS_OK; + } DEBUG(5, ("_samr_query_dispinfo: %d\n", __LINE__)); @@ -978,7 +1192,7 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM DEBUG(5,("_samr_query_aliasinfo: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_LOOKUP_INFO, "_samr_query_aliasinfo"))) { return r_u->status; @@ -1096,7 +1310,7 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO ZERO_ARRAY(rid); ZERO_ARRAY(type); - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid, &acc_granted)) { + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid, &acc_granted, NULL)) { init_samr_r_lookup_names(p->mem_ctx, r_u, 0, NULL, NULL, NT_STATUS_OBJECT_TYPE_MISMATCH); return r_u->status; } @@ -1255,7 +1469,7 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK DEBUG(5,("_samr_lookup_rids: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; if (num_rids > 1000) { @@ -1317,7 +1531,7 @@ NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USE /* find the domain policy handle and get domain SID / access bits in the domain policy. */ - if ( !get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted) ) + if ( !get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted, NULL) ) return NT_STATUS_INVALID_HANDLE; nt_status = access_check_samr_function( acc_granted, @@ -1712,7 +1926,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_USER_GET_GROUPS, "_samr_query_usergroups"))) { @@ -1858,9 +2072,9 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA /* AS ROOT !!! */ - num_users=count_sam_users(&info->disp_info, + num_users=count_sam_users(info->disp_info, ACB_NORMAL); - num_groups=count_sam_groups(&info->disp_info); + num_groups=count_sam_groups(info->disp_info); pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); u_logout = account_policy_temp; @@ -1993,9 +2207,10 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA uint32 des_access = GENERIC_RIGHTS_USER_ALL_ACCESS; BOOL can_add_account = False; SE_PRIV se_rights; + DISP_INFO *disp_info = NULL; /* Get the domain SID stored in the domain policy */ - if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_USER, "_samr_create_user"))) { @@ -2141,6 +2356,9 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA return NT_STATUS_OBJECT_NAME_NOT_FOUND; } + /* After a "set" ensure we have no cached display info. */ + force_flush_samr_cache(info->disp_info); + r_u->user_rid=pdb_get_user_rid(sam_pass); r_u->access_granted = acc_granted; @@ -2478,7 +2696,7 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A /* find the domain policy and get the SID / access bits stored in the domain policy */ - if ( !get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted) ) + if ( !get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted, NULL) ) return NT_STATUS_INVALID_HANDLE; status = access_check_samr_function(acc_granted, @@ -2873,13 +3091,14 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE BOOL ret; BOOL has_enough_rights = False; uint32 acb_info; + DISP_INFO *disp_info = NULL; DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); r_u->status = NT_STATUS_OK; /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; /* observed when joining an XP client to a Samba domain */ @@ -2995,6 +3214,10 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE /* ================ END SeMachineAccountPrivilege BLOCK ================ */ + if (NT_STATUS_IS_OK(r_u->status)) { + force_flush_samr_cache(disp_info); + } + return r_u->status; } @@ -3014,13 +3237,14 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ BOOL ret; BOOL has_enough_rights = False; uint32 acb_info; + DISP_INFO *disp_info = NULL; DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__)); r_u->status = NT_STATUS_OK; /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; /* observed when joining XP client to Samba domain */ @@ -3101,6 +3325,10 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ /* ================ END SeMachineAccountPrivilege BLOCK ================ */ + if (NT_STATUS_IS_OK(r_u->status)) { + force_flush_samr_cache(disp_info); + } + return r_u->status; } @@ -3184,7 +3412,7 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ uint32 acc_granted; /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = @@ -3296,7 +3524,7 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ NTSTATUS result; /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_GET_MEMBERS, "_samr_query_groupmem"))) { @@ -3345,10 +3573,10 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD SE_PRIV se_rights; BOOL can_add_accounts; BOOL ret; - + DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_ADD_MEMBER, "_samr_add_aliasmem"))) { @@ -3372,6 +3600,10 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD /******** END SeAddUsers BLOCK *********/ + if (ret) { + force_flush_samr_cache(disp_info); + } + return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; } @@ -3386,9 +3618,10 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE SE_PRIV se_rights; BOOL can_add_accounts; BOOL ret; + DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_REMOVE_MEMBER, "_samr_del_aliasmem"))) { @@ -3413,6 +3646,10 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE /******** END SeAddUsers BLOCK *********/ + if (ret) { + force_flush_samr_cache(disp_info); + } + return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; } @@ -3436,9 +3673,10 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD uint32 acc_granted; SE_PRIV se_rights; BOOL can_add_accounts; + DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_ADD_MEMBER, "_samr_add_groupmem"))) { @@ -3524,6 +3762,9 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD } passwd_free(&pwd); + + force_flush_samr_cache(disp_info); + return NT_STATUS_OK; } @@ -3542,6 +3783,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE uint32 acc_granted; SE_PRIV se_rights; BOOL can_add_accounts; + DISP_INFO *disp_info = NULL; /* * delete the group member named q_u->rid @@ -3550,7 +3792,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE */ /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_REMOVE_MEMBER, "_samr_del_groupmem"))) { @@ -3609,6 +3851,9 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE } pdb_free_sam(&sam_pass); + + force_flush_samr_cache(disp_info); + return NT_STATUS_OK; } @@ -3644,11 +3889,12 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM uint32 acc_granted; BOOL can_add_accounts; BOOL ret; + DISP_INFO *disp_info = NULL; DEBUG(5, ("_samr_delete_dom_user: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &user_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &user_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_user"))) { @@ -3705,6 +3951,8 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM if (!close_policy_hnd(p, &q_u->user_pol)) return NT_STATUS_OBJECT_NAME_INVALID; + force_flush_samr_cache(disp_info); + return NT_STATUS_OK; } @@ -3725,11 +3973,12 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S SE_PRIV se_rights; BOOL can_add_accounts; BOOL ret; + DISP_INFO *disp_info = NULL; DEBUG(5, ("samr_delete_dom_group: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_group"))) { @@ -3788,6 +4037,8 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S if (!close_policy_hnd(p, &q_u->group_pol)) return NT_STATUS_OBJECT_NAME_INVALID; + force_flush_samr_cache(disp_info); + return NT_STATUS_OK; } @@ -3802,11 +4053,12 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S SE_PRIV se_rights; BOOL can_add_accounts; BOOL ret; + DISP_INFO *disp_info = NULL; DEBUG(5, ("_samr_delete_dom_alias: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_alias"))) { @@ -3842,6 +4094,8 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S if (!close_policy_hnd(p, &q_u->alias_pol)) return NT_STATUS_OBJECT_NAME_INVALID; + force_flush_samr_cache(disp_info); + return NT_STATUS_OK; } @@ -3862,9 +4116,10 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S SE_PRIV se_rights; BOOL can_add_accounts; NTSTATUS result; + DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_GROUP, "_samr_create_dom_group"))) { @@ -3933,6 +4188,8 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S if (!create_policy_hnd(p, &r_u->pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; + force_flush_samr_cache(disp_info); + return NT_STATUS_OK; } @@ -3951,9 +4208,10 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S NTSTATUS result; SE_PRIV se_rights; BOOL can_add_accounts; + DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_ALIAS, "_samr_create_alias"))) { @@ -4005,6 +4263,8 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S if (!create_policy_hnd(p, &r_u->alias_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; + force_flush_samr_cache(disp_info); + return NT_STATUS_OK; } @@ -4026,7 +4286,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM uint32 acc_granted; BOOL ret; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_LOOKUP_INFO, "_samr_query_groupinfo"))) { @@ -4083,8 +4343,9 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ uint32 acc_granted; BOOL ret; BOOL can_mod_accounts; + DISP_INFO *disp_info = NULL; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_SET_INFO, "_samr_set_groupinfo"))) { @@ -4121,6 +4382,10 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ /******** End SeAddUsers BLOCK *********/ + if (ret) { + force_flush_samr_cache(disp_info); + } + return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; } @@ -4138,8 +4403,9 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ uint32 acc_granted; BOOL ret; BOOL can_mod_accounts; + DISP_INFO *disp_info = NULL; - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_SET_INFO, "_samr_set_aliasinfo"))) { @@ -4174,6 +4440,10 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ /******** End SeAddUsers BLOCK *********/ + if (ret) { + force_flush_samr_cache(disp_info); + } + return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; } @@ -4217,7 +4487,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G BOOL ret; SE_PRIV se_rights; - if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid, &acc_granted)) + if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; status = access_check_samr_function(acc_granted, @@ -4280,7 +4550,8 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, DOM_SID delete_sid, domain_sid; uint32 acc_granted; NTSTATUS result; - + DISP_INFO *disp_info = NULL; + sid_copy( &delete_sid, &q_u->sid.sid ); DEBUG(5,("_samr_remove_sid_foreign_domain: removing SID [%s]\n", @@ -4289,7 +4560,7 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, /* Find the policy handle. Open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &domain_sid, - &acc_granted)) + &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; result = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, @@ -4324,6 +4595,7 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, return NT_STATUS_OK; } + force_flush_samr_cache(disp_info); result = NT_STATUS_OK; @@ -4331,10 +4603,12 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, } /******************************************************************* - _samr_unknown_2e + _samr_query_domain_info2 ********************************************************************/ -NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOWN_2E *r_u) +NTSTATUS _samr_query_domain_info2(pipes_struct *p, + SAMR_Q_QUERY_DOMAIN_INFO2 *q_u, + SAMR_R_QUERY_DOMAIN_INFO2 *r_u) { struct samr_info *info = NULL; SAM_UNK_CTR *ctr; @@ -4363,7 +4637,7 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW r_u->status = NT_STATUS_OK; - DEBUG(5,("_samr_unknown_2e: %d\n", __LINE__)); + DEBUG(5,("_samr_query_domain_info2: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) @@ -4394,13 +4668,11 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW break; case 0x02: become_root(); - num_users = count_sam_users(&info->disp_info, + num_users = count_sam_users(info->disp_info, ACB_NORMAL); - num_groups = count_sam_groups(&info->disp_info); + num_groups = count_sam_groups(info->disp_info); unbecome_root(); - free_samr_db(info); - pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); u_logout = account_policy_temp; @@ -4464,9 +4736,9 @@ NTSTATUS _samr_unknown_2e(pipes_struct *p, SAMR_Q_UNKNOWN_2E *q_u, SAMR_R_UNKNOW return NT_STATUS_INVALID_INFO_CLASS; } - init_samr_r_samr_unknown_2e(r_u, q_u->switch_value, ctr, NT_STATUS_OK); + init_samr_r_samr_query_domain_info2(r_u, q_u->switch_value, ctr, NT_STATUS_OK); - DEBUG(5,("_samr_unknown_2e: %d\n", __LINE__)); + DEBUG(5,("_samr_query_domain_info2: %d\n", __LINE__)); return r_u->status; } -- cgit From 2770e98aec8bcf462f1619a6506385cb4cfbc256 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 22 Nov 2005 14:29:14 +0000 Subject: r11856: Replace unknown1 with group_attr. Can anyone remember why we initialize groups only with 0x03 instead of 0x07 ? Guenther (This used to be commit 3282c7c458d390547fbaca44821eff376e8f9aaa) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 563c3f864f..34779348a4 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1980,7 +1980,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S continue; gids = TALLOC_REALLOC_ARRAY(p->mem_ctx, gids, DOM_GID, num_gids+1); - gids[num_gids].attr=7; + gids[num_gids].attr= (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT|SE_GROUP_ENABLED); gids[num_gids].g_rid = rid; num_gids += 1; } -- cgit From 4826f9d41322649111be7495ede60a8939ad2995 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 22 Nov 2005 14:41:40 +0000 Subject: r11859: Another place where the SE_GROUP constants read better then "7". Guenther (This used to be commit 4c4b2096459ffa6ca0130f1259499933e3182d47) --- source3/rpc_server/srv_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 79d5d06d23..3666d47478 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -102,7 +102,7 @@ NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, const DOM_SID *domain_sid, for (i=PRIMARY_GROUP_SID_INDEX; i < nt_token->num_sids; i++) { if (sid_compare_domain(domain_sid, &nt_token->user_sids[i])==0) { sid_peek_rid(&nt_token->user_sids[i], &(gids[*numgroups].g_rid)); - gids[*numgroups].attr=7; + gids[*numgroups].attr= (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT|SE_GROUP_ENABLED); (*numgroups)++; } } -- cgit From f2ecd4fed0ed11b73fa330588501a0ac37583174 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 22 Nov 2005 15:52:22 +0000 Subject: r11860: BUG 3156: don't use find_service() when explicitly looking for a printer as the username map might get in the way (This used to be commit 46bf28c81c27dfdc412318a83bf565211a58a47d) --- source3/rpc_server/srv_spoolss_nt.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e5b3ca3947..f0ba863b4d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -479,29 +479,30 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) DEBUGADD(5, ("searching for [%s]\n", aprinter )); /* Search all sharenames first as this is easier than pulling - the printer_info_2 off of disk */ + the printer_info_2 off of disk. Don't use find_service() since + that calls out to map_username() */ - snum = find_service(aprinter); - - if ( lp_snum_ok(snum) && lp_print_ok(snum) ) { - found = True; - fstrcpy( sname, aprinter ); - } - /* do another loop to look for printernames */ for (snum=0; !found && snum Date: Tue, 22 Nov 2005 20:26:23 +0000 Subject: r11865: The only way to stop multiple LDAP searches is to agressively cache results. We now cache them for 10 seconds, down from 30 seconds (however each re-use will refresh the idle timeout). Any set calls will flush the cache. Jeremy. (This used to be commit c9a0720f552719eb77a2c72fc2e942de52fbf1d6) --- source3/rpc_server/srv_samr_nt.c | 66 ++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 34779348a4..00c8a9956c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -40,7 +40,7 @@ SA_RIGHT_USER_CHANGE_PASSWORD | \ SA_RIGHT_USER_SET_LOC_COM ) -#define DISP_INFO_CACHE_TIMEOUT 30 +#define DISP_INFO_CACHE_TIMEOUT 10 extern rid_name domain_group_rids[]; extern rid_name domain_alias_rids[]; @@ -303,9 +303,9 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) Function to free the per SID data. ********************************************************************/ -static void free_samr_cache(DISP_INFO *disp_info) +static void free_samr_cache(DISP_INFO *disp_info, const char *sid_str) { - DEBUG(10,("free_samr_cache: deleting cache\n")); + DEBUG(10,("free_samr_cache: deleting cache for SID %s\n", sid_str)); if (disp_info->users) { DEBUG(10,("free_samr_cache: deleting users cache\n")); @@ -352,7 +352,9 @@ static void free_samr_info(void *ptr) a timeout. */ if (info->disp_info && info->disp_info->di_cache_timeout_event == (smb_event_id_t)0) { - free_samr_cache(info->disp_info); + fstring sid_str; + sid_to_string(sid_str, &info->disp_info->sid); + free_samr_cache(info->disp_info, sid_str); } talloc_destroy(info->mem_ctx); @@ -366,16 +368,19 @@ static void disp_info_cache_idle_timeout_handler(void **private_data, time_t *ev_interval, time_t ev_now) { + fstring sid_str; DISP_INFO *disp_info = (DISP_INFO *)(*private_data); - free_samr_cache(disp_info); + sid_to_string(sid_str, &disp_info->sid); + + free_samr_cache(disp_info, sid_str); /* Remove the event. */ smb_unregister_idle_event(disp_info->di_cache_timeout_event); disp_info->di_cache_timeout_event = (smb_event_id_t)0; - DEBUG(10,("disp_info_cache_idle_timeout_handler: caching timed out at %u\n", - (unsigned int)ev_now)); + DEBUG(10,("disp_info_cache_idle_timeout_handler: caching timed out for SID %s at %u\n", + sid_str, (unsigned int)ev_now)); } /******************************************************************* @@ -384,6 +389,10 @@ static void disp_info_cache_idle_timeout_handler(void **private_data, static void set_disp_info_cache_timeout(DISP_INFO *disp_info, time_t secs_fromnow) { + fstring sid_str; + + sid_to_string(sid_str, &disp_info->sid); + /* Remove any pending timeout and update. */ if (disp_info->di_cache_timeout_event) { @@ -391,8 +400,8 @@ static void set_disp_info_cache_timeout(DISP_INFO *disp_info, time_t secs_fromno disp_info->di_cache_timeout_event = (smb_event_id_t)0; } - DEBUG(10,("set_disp_info_cache_timeout: caching enumeration for %u seconds\n", - (unsigned int)secs_fromnow )); + DEBUG(10,("set_disp_info_cache_timeout: caching enumeration for SID %s for %u seconds\n", + sid_str, (unsigned int)secs_fromnow )); disp_info->di_cache_timeout_event = smb_register_idle_event(disp_info_cache_idle_timeout_handler, @@ -400,28 +409,24 @@ static void set_disp_info_cache_timeout(DISP_INFO *disp_info, time_t secs_fromno secs_fromnow); } -/******************************************************************* - Remove the cache removal idle event handler. - ********************************************************************/ - -static void clear_disp_info_cache_timeout(DISP_INFO *disp_info) -{ - if (disp_info->di_cache_timeout_event) { - smb_unregister_idle_event(disp_info->di_cache_timeout_event); - disp_info->di_cache_timeout_event = (smb_event_id_t)0; - DEBUG(10,("clear_disp_info_cache_timeout: clearing idle event.\n")); - } -} - /******************************************************************* Force flush any cache. We do this on any samr_set_xxx call. + We must also remove the timeout handler. ********************************************************************/ static void force_flush_samr_cache(DISP_INFO *disp_info) { if (disp_info) { - clear_disp_info_cache_timeout(disp_info); - free_samr_cache(disp_info); + fstring sid_str; + + sid_to_string(sid_str, &disp_info->sid); + if (disp_info->di_cache_timeout_event) { + smb_unregister_idle_event(disp_info->di_cache_timeout_event); + disp_info->di_cache_timeout_event = (smb_event_id_t)0; + DEBUG(10,("force_flush_samr_cache: clearing idle event for SID %s\n", + sid_str)); + } + free_samr_cache(disp_info, sid_str); } } @@ -792,13 +797,14 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, return r_u->status; if (max_entries <= num_account) { - /* Ensure we cache this enumeration. */ - set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); r_u->status = STATUS_MORE_ENTRIES; } else { - clear_disp_info_cache_timeout(info->disp_info); + r_u->status = NT_STATUS_OK; } + /* Ensure we cache this enumeration. */ + set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); + DEBUG(5, ("_samr_enum_dom_users: %d\n", __LINE__)); init_samr_r_enum_dom_users(r_u, q_u->start_idx + num_account, @@ -1158,14 +1164,14 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, total_data_size=num_account*struct_size; if (num_account) { - /* Ensure we cache this enumeration. */ - set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); r_u->status = STATUS_MORE_ENTRIES; } else { - clear_disp_info_cache_timeout(info->disp_info); r_u->status = NT_STATUS_OK; } + /* Ensure we cache this enumeration. */ + set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); + DEBUG(5, ("_samr_query_dispinfo: %d\n", __LINE__)); init_samr_r_query_dispinfo(r_u, num_account, total_data_size, -- cgit From ed6936598ef73f1fc46801fd5dc7765d65032fa1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 25 Nov 2005 10:19:24 +0000 Subject: r11898: Add a missing become_root(). Volker (This used to be commit efb7576d4e970e3cbb4621ebd754d329eec58b5a) --- source3/rpc_server/srv_samr_nt.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 00c8a9956c..b0472d287a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -307,6 +307,11 @@ static void free_samr_cache(DISP_INFO *disp_info, const char *sid_str) { DEBUG(10,("free_samr_cache: deleting cache for SID %s\n", sid_str)); + /* We need to become root here because the paged search might have to + * tell the LDAP server we're not interested in the rest anymore. */ + + become_root(); + if (disp_info->users) { DEBUG(10,("free_samr_cache: deleting users cache\n")); pdb_search_destroy(disp_info->users); @@ -338,6 +343,8 @@ static void free_samr_cache(DISP_INFO *disp_info, const char *sid_str) disp_info->enum_users = NULL; } disp_info->enum_acb_mask = 0; + + unbecome_root(); } /******************************************************************* -- cgit From 3088a85c62e1475747496199d18137ee89f914a5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 26 Nov 2005 17:54:24 +0000 Subject: r11915: Remove unused extern declarations (This used to be commit 3c35fb642a187b785816bb8cbb3573df9612a9f8) --- source3/rpc_server/srv_samr_nt.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b0472d287a..2bb8078f78 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -42,10 +42,6 @@ #define DISP_INFO_CACHE_TIMEOUT 10 -extern rid_name domain_group_rids[]; -extern rid_name domain_alias_rids[]; -extern rid_name builtin_alias_rids[]; - typedef struct disp_info { struct disp_info *next, *prev; TALLOC_CTX *mem_ctx; -- cgit From 4ce649984982fc5b9c83c7685182951352bca12d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 26 Nov 2005 19:17:57 +0000 Subject: r11917: Move nt_token_to_group_list to srv_netlog_nt.c. srv_util.c is empty now. Volker (This used to be commit ae4ffc1cfb745a756d047c35f947f80acf4b0e55) --- source3/rpc_server/srv_netlog_nt.c | 29 +++++++++++++++++++++++++++++ source3/rpc_server/srv_util.c | 29 ----------------------------- 2 files changed, 29 insertions(+), 29 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 7903adff6d..d0d47be9f2 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -584,6 +584,35 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF } +/******************************************************************* + gets a domain user's groups from their already-calculated NT_USER_TOKEN + ********************************************************************/ +static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, const DOM_SID *domain_sid, + const NT_USER_TOKEN *nt_token, + int *numgroups, DOM_GID **pgids) +{ + DOM_GID *gids; + int i; + + gids = TALLOC_ARRAY(mem_ctx, DOM_GID, nt_token->num_sids); + + if (!gids) { + return NT_STATUS_NO_MEMORY; + } + + *numgroups=0; + + for (i=PRIMARY_GROUP_SID_INDEX; i < nt_token->num_sids; i++) { + if (sid_compare_domain(domain_sid, &nt_token->user_sids[i])==0) { + sid_peek_rid(&nt_token->user_sids[i], &(gids[*numgroups].g_rid)); + gids[*numgroups].attr= (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT|SE_GROUP_ENABLED); + (*numgroups)++; + } + } + *pgids = gids; + return NT_STATUS_OK; +} + /************************************************************************* _net_sam_logon *************************************************************************/ diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 3666d47478..924e08cc23 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -81,32 +81,3 @@ static const rid_name domain_group_rids[] = }; #endif -/******************************************************************* - gets a domain user's groups from their already-calculated NT_USER_TOKEN - ********************************************************************/ -NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, const DOM_SID *domain_sid, - const NT_USER_TOKEN *nt_token, - int *numgroups, DOM_GID **pgids) -{ - DOM_GID *gids; - int i; - - gids = TALLOC_ARRAY(mem_ctx, DOM_GID, nt_token->num_sids); - - if (!gids) { - return NT_STATUS_NO_MEMORY; - } - - *numgroups=0; - - for (i=PRIMARY_GROUP_SID_INDEX; i < nt_token->num_sids; i++) { - if (sid_compare_domain(domain_sid, &nt_token->user_sids[i])==0) { - sid_peek_rid(&nt_token->user_sids[i], &(gids[*numgroups].g_rid)); - gids[*numgroups].attr= (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT|SE_GROUP_ENABLED); - (*numgroups)++; - } - } - *pgids = gids; - return NT_STATUS_OK; -} - -- cgit From 5976053f05c20fd2d010ec7949202e365fb701ee Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 26 Nov 2005 19:22:17 +0000 Subject: r11918: Remove two unused variables (This used to be commit 5524d662954165eef3fdd15986fe0b4de09180d7) --- source3/rpc_server/srv_samr_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2bb8078f78..9a09b5f544 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -68,8 +68,6 @@ struct samr_info { DOM_SID sid; uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ uint32 acc_granted; - uint16 acb_mask; - BOOL only_machines; DISP_INFO *disp_info; TALLOC_CTX *mem_ctx; }; -- cgit From add1493a86d62c298f4a9e0686e8e81deab70c57 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 26 Nov 2005 20:28:12 +0000 Subject: r11919: The generic mappings in srv_samr_nt.c are only used there -- make them static. One long overdue simplification: Change local_lookup_sid to local_lookup_rid its responsible for "our" domain only, in fact it checked for it. Volker (This used to be commit 35ba5e083cddfa5ddba5ad84233262fadfbe87b2) --- source3/rpc_server/srv_samr_nt.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9a09b5f544..ec2bc3fe4a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -72,11 +72,31 @@ struct samr_info { TALLOC_CTX *mem_ctx; }; -struct generic_mapping sam_generic_mapping = {GENERIC_RIGHTS_SAM_READ, GENERIC_RIGHTS_SAM_WRITE, GENERIC_RIGHTS_SAM_EXECUTE, GENERIC_RIGHTS_SAM_ALL_ACCESS}; -struct generic_mapping dom_generic_mapping = {GENERIC_RIGHTS_DOMAIN_READ, GENERIC_RIGHTS_DOMAIN_WRITE, GENERIC_RIGHTS_DOMAIN_EXECUTE, GENERIC_RIGHTS_DOMAIN_ALL_ACCESS}; -struct generic_mapping usr_generic_mapping = {GENERIC_RIGHTS_USER_READ, GENERIC_RIGHTS_USER_WRITE, GENERIC_RIGHTS_USER_EXECUTE, GENERIC_RIGHTS_USER_ALL_ACCESS}; -struct generic_mapping grp_generic_mapping = {GENERIC_RIGHTS_GROUP_READ, GENERIC_RIGHTS_GROUP_WRITE, GENERIC_RIGHTS_GROUP_EXECUTE, GENERIC_RIGHTS_GROUP_ALL_ACCESS}; -struct generic_mapping ali_generic_mapping = {GENERIC_RIGHTS_ALIAS_READ, GENERIC_RIGHTS_ALIAS_WRITE, GENERIC_RIGHTS_ALIAS_EXECUTE, GENERIC_RIGHTS_ALIAS_ALL_ACCESS}; +static struct generic_mapping sam_generic_mapping = { + GENERIC_RIGHTS_SAM_READ, + GENERIC_RIGHTS_SAM_WRITE, + GENERIC_RIGHTS_SAM_EXECUTE, + GENERIC_RIGHTS_SAM_ALL_ACCESS}; +static struct generic_mapping dom_generic_mapping = { + GENERIC_RIGHTS_DOMAIN_READ, + GENERIC_RIGHTS_DOMAIN_WRITE, + GENERIC_RIGHTS_DOMAIN_EXECUTE, + GENERIC_RIGHTS_DOMAIN_ALL_ACCESS}; +static struct generic_mapping usr_generic_mapping = { + GENERIC_RIGHTS_USER_READ, + GENERIC_RIGHTS_USER_WRITE, + GENERIC_RIGHTS_USER_EXECUTE, + GENERIC_RIGHTS_USER_ALL_ACCESS}; +static struct generic_mapping grp_generic_mapping = { + GENERIC_RIGHTS_GROUP_READ, + GENERIC_RIGHTS_GROUP_WRITE, + GENERIC_RIGHTS_GROUP_EXECUTE, + GENERIC_RIGHTS_GROUP_ALL_ACCESS}; +static struct generic_mapping ali_generic_mapping = { + GENERIC_RIGHTS_ALIAS_READ, + GENERIC_RIGHTS_ALIAS_WRITE, + GENERIC_RIGHTS_ALIAS_EXECUTE, + GENERIC_RIGHTS_ALIAS_ALL_ACCESS}; /******************************************************************* *******************************************************************/ -- cgit From fcf14ebee21378064187dd4389c01d8eaea3ca2a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 26 Nov 2005 21:35:43 +0000 Subject: r11921: samr_open_domain can only open "our" domain and BUILTIN. Volker (This used to be commit 049920ce4f78723bc884c46b2ee4ef22f25c482c) --- source3/rpc_server/srv_samr_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ec2bc3fe4a..ac774355a7 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -562,6 +562,11 @@ NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN if ( !NT_STATUS_IS_OK(status) ) return status; + if (!sid_check_is_domain(&q_u->dom_sid.sid) && + !sid_check_is_builtin(&q_u->dom_sid.sid)) { + return NT_STATUS_NO_SUCH_DOMAIN; + } + /* associate the domain SID with the (unique) handle. */ if ((info = get_samr_info_by_sid(&q_u->dom_sid.sid))==NULL) return NT_STATUS_NO_MEMORY; -- cgit From 046a8873b9001662eff7bbdf549d2a511216c092 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 26 Nov 2005 22:04:28 +0000 Subject: r11922: Looks bigger than it is: There's no point in allocating arrays in samr_lookup_rids twice. It was done in the srv_samr_nt.c code as well as in the pdb module. Remove the latter, this might happen more often. Volker (This used to be commit 57f0cf8cdd6928f4759036e5dd53d41736aa910d) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ac774355a7..65bb0ef1ab 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1523,8 +1523,8 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK } become_root(); /* lookup_sid can require root privs */ - r_u->status = pdb_lookup_rids(p->mem_ctx, &pol_sid, num_rids, q_u->rid, - &names, &attrs); + r_u->status = pdb_lookup_rids(&pol_sid, num_rids, q_u->rid, + names, attrs); unbecome_root(); done: -- cgit From 10bc204efb9a56d1f1f53326d4354e39851e635a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 26 Nov 2005 22:28:41 +0000 Subject: r11923: Add samr_lookup_rids for the builtin domain. Doing it this way feels a bit wrong, but so far we don't have proper multi-domain support in passdb yet... Volker (This used to be commit c917cfc320f0250d23fda3525a7632bc01643707) --- source3/rpc_server/srv_samr_nt.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 65bb0ef1ab..b4d699188a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1516,19 +1516,11 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK if ((num_rids != 0) && ((names == NULL) || (attrs == NULL))) return NT_STATUS_NO_MEMORY; - if (!sid_equal(&pol_sid, get_global_sam_sid())) { - /* TODO: Sooner or later we need to look up BUILTIN rids as - * well. -- vl */ - goto done; - } - become_root(); /* lookup_sid can require root privs */ r_u->status = pdb_lookup_rids(&pol_sid, num_rids, q_u->rid, names, attrs); unbecome_root(); - done: - if(!make_samr_lookup_rids(p->mem_ctx, num_rids, names, &hdr_name, &uni_name)) return NT_STATUS_NO_MEMORY; -- cgit From 48c2f9fc72afaf5d7817bfb12f0acef9ab26faf0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 27 Nov 2005 01:17:24 +0000 Subject: r11924: Added Volkers's (C) to srv_samr_nt.c, removed separate "builtin" search enumeration, fixed count of groups and users to return zero if we're getting domain info on the builtin domain (need to fix the enumgroup and enumuser calls also). Added count_sam_aliases to return the correct alias count. Need to push the SID arg down into the group mapping interface so we only return the correct aliases. Upped passdb version numer for Volkers changes. SAM-MYSQL guys - you will need to fix your backend now. More tests needed. Jeremy. (This used to be commit b53d5cd565b05b0595979efba6176d0cafc8cb03) --- source3/rpc_server/srv_samr_nt.c | 76 +++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 25 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b4d699188a..f10597055e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -5,11 +5,12 @@ * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, * Copyright (C) Marc Jacobsen 1999, - * Copyright (C) Jeremy Allison 2001-2002, + * Copyright (C) Jeremy Allison 2001-2005, * Copyright (C) Jean François Micouleau 1998-2001, * Copyright (C) Jim McDonough 2002, * Copyright (C) Gerald (Jerry) Carter 2003-2004, * Copyright (C) Simo Sorce 2003. + * Copyright (C) Volker Lendecke 2005. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,15 +47,16 @@ typedef struct disp_info { struct disp_info *next, *prev; TALLOC_CTX *mem_ctx; DOM_SID sid; /* identify which domain this is. */ + BOOL builtin_domain; /* Quick flag to check if this is the builtin domain. */ struct pdb_search *users; /* querydispinfo 1 and 4 */ struct pdb_search *machines; /* querydispinfo 2 */ struct pdb_search *groups; /* querydispinfo 3 and 5, enumgroups */ struct pdb_search *aliases; /* enumaliases */ - struct pdb_search *builtins; /* enumaliases */ uint16 enum_acb_mask; struct pdb_search *enum_users; /* enumusers with a mask */ + smb_event_id_t di_cache_timeout_event; /* cache idle timeout handler. */ } DISP_INFO; @@ -66,6 +68,7 @@ static DISP_INFO *disp_info_list; struct samr_info { /* for use by the \PIPE\samr policy */ DOM_SID sid; + BOOL builtin_domain; /* Quick flag to check if this is the builtin domain. */ uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ uint32 acc_granted; DISP_INFO *disp_info; @@ -265,8 +268,12 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid, const char *sid_str) return NULL; dpi->mem_ctx = mem_ctx; + if (psid) { sid_copy( &dpi->sid, psid); + dpi->builtin_domain = sid_check_is_builtin(psid); + } else { + dpi->builtin_domain = False; } DLIST_ADD(disp_info_list, dpi); @@ -298,8 +305,10 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) DEBUG(10,("get_samr_info_by_sid: created new info for sid %s\n", sid_str)); if (psid) { sid_copy( &info->sid, psid); + info->builtin_domain = sid_check_is_builtin(psid); } else { DEBUG(10,("get_samr_info_by_sid: created new info for NULL sid.\n")); + info->builtin_domain = False; } info->mem_ctx = mem_ctx; @@ -346,11 +355,6 @@ static void free_samr_cache(DISP_INFO *disp_info, const char *sid_str) pdb_search_destroy(disp_info->aliases); disp_info->aliases = NULL; } - if (disp_info->builtins) { - DEBUG(10,("free_samr_cache: deleting builtins cache\n")); - pdb_search_destroy(disp_info->builtins); - disp_info->builtins = NULL; - } if (disp_info->enum_users) { DEBUG(10,("free_samr_cache: deleting enum_users cache\n")); pdb_search_destroy(disp_info->enum_users); @@ -470,6 +474,12 @@ static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) static uint32 count_sam_users(struct disp_info *info, uint16 acct_flags) { struct samr_displayentry *entry; + + if (info->builtin_domain) { + /* No users in builtin. */ + return 0; + } + if (info->users == NULL) { info->users = pdb_search_users(acct_flags); if (info->users == NULL) { @@ -488,6 +498,12 @@ static uint32 count_sam_users(struct disp_info *info, uint16 acct_flags) static uint32 count_sam_groups(struct disp_info *info) { struct samr_displayentry *entry; + + if (info->builtin_domain) { + /* No groups in builtin. */ + return 0; + } + if (info->groups == NULL) { info->groups = pdb_search_groups(); if (info->groups == NULL) { @@ -503,6 +519,25 @@ static uint32 count_sam_groups(struct disp_info *info) return info->groups->num_entries; } +static uint32 count_sam_aliases(struct disp_info *info) +{ + struct samr_displayentry *entry; + + if (info->aliases == NULL) { + info->aliases = pdb_search_aliases(&info->sid); + if (info->aliases == NULL) { + return 0; + } + } + /* Fetch the last possible entry, thus trigger an enumeration */ + pdb_search_entries(info->aliases, 0xffffffff, 1, &entry); + + /* Ensure we cache this enumeration. */ + set_disp_info_cache_timeout(info, DISP_INFO_CACHE_TIMEOUT); + + return info->aliases->num_entries; +} + /******************************************************************* _samr_close_hnd ********************************************************************/ @@ -943,7 +978,6 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S { struct samr_info *info; struct samr_displayentry *aliases; - struct pdb_search **search = NULL; uint32 num_aliases = 0; /* find the policy handle. open a policy on it. */ @@ -959,25 +993,17 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", sid_string_static(&info->sid))); - if (sid_check_is_domain(&info->sid)) - search = &info->disp_info->aliases; - if (sid_check_is_builtin(&info->sid)) - search = &info->disp_info->builtins; - - if (search == NULL) - return NT_STATUS_INVALID_HANDLE; - become_root(); - if (*search == NULL) { - *search = pdb_search_aliases(&info->sid); - if (*search == NULL) { + if (info->disp_info->aliases == NULL) { + info->disp_info->aliases = pdb_search_aliases(&info->sid); + if (info->disp_info->aliases == NULL) { unbecome_root(); return NT_STATUS_ACCESS_DENIED; } } - num_aliases = pdb_search_entries(*search, q_u->start_idx, + num_aliases = pdb_search_entries(info->disp_info->aliases, q_u->start_idx, MAX_SAM_ENTRIES, &aliases); unbecome_root(); @@ -2096,9 +2122,9 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA /* AS ROOT !!! */ - num_users=count_sam_users(info->disp_info, - ACB_NORMAL); - num_groups=count_sam_groups(info->disp_info); + num_users = count_sam_users(info->disp_info, ACB_NORMAL); + num_groups = count_sam_groups(info->disp_info); + num_aliases = count_sam_aliases(info->disp_info); pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); u_logout = account_policy_temp; @@ -4692,9 +4718,9 @@ NTSTATUS _samr_query_domain_info2(pipes_struct *p, break; case 0x02: become_root(); - num_users = count_sam_users(info->disp_info, - ACB_NORMAL); + num_users = count_sam_users(info->disp_info, ACB_NORMAL); num_groups = count_sam_groups(info->disp_info); + num_aliases = count_sam_aliases(info->disp_info); unbecome_root(); pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); -- cgit From d9f26f78f6325651b79f21e11fb1781c9cfafd78 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 27 Nov 2005 01:26:52 +0000 Subject: r11927: No users or groups to return in BUILTIN domain. Jeremy. (This used to be commit 908e671c75f78b87fe0ee9129f0aca004565c407) --- source3/rpc_server/srv_samr_nt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f10597055e..6ad5ec7706 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -814,6 +814,13 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); + if (info->builtin_domain) { + /* No users in builtin. */ + init_samr_r_enum_dom_users(r_u, q_u->start_idx, 0); + DEBUG(5,("_samr_enum_dom_users: No users in BUILTIN\n")); + return r_u->status; + } + become_root(); /* AS ROOT !!!! */ @@ -940,6 +947,13 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); + if (info->builtin_domain) { + /* No groups in builtin. */ + init_samr_r_enum_dom_groups(r_u, q_u->start_idx, 0); + DEBUG(5,("_samr_enum_dom_users: No groups in BUILTIN\n")); + return r_u->status; + } + /* the domain group array is being allocated in the function below */ become_root(); -- cgit From add7cff52095b53646cf6907a557b4d1f17cb050 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 27 Nov 2005 21:51:46 +0000 Subject: r11936: Fix bug in returning remote time found by Thomas Bork . get_time_zone() was overwriting static buffer returned by gmtime(). Lars - this is a mandatory fix for the next patch... Jeremy. (This used to be commit 68d03a7a74738ce62e7531127aa4533147217e6d) --- source3/rpc_server/srv_srvsvc_nt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index a7162c929d..0e7ded39f5 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1924,6 +1924,9 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET TIME_OF_DAY_INFO *tod; struct tm *t; time_t unixdate = time(NULL); + /* We do this call first as if we do it *after* the gmtime call + it overwrites the pointed-to values. JRA */ + uint32 zone = get_time_zone(unixdate)/60; tod = TALLOC_P(p->mem_ctx, TIME_OF_DAY_INFO); if (!tod) @@ -1947,7 +1950,7 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET t->tm_min, t->tm_sec, 0, - get_time_zone(unixdate)/60, + zone, 10000, t->tm_mday, t->tm_mon + 1, -- cgit From 05fafb83968a31907d996d37b91bdd9b72998701 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 29 Nov 2005 02:10:52 +0000 Subject: r11950: If we got a connection oriented cancel pdu we would spin processing it. Fix that, and also add in comments for all possible CL and CO PDU types. Make sure we process them correctly. Jeremy. (This used to be commit 672113a627aa9060795871bc2ea3a02e696d7d7d) --- source3/rpc_server/srv_pipe.c | 49 +++++++++++++++++++++++ source3/rpc_server/srv_pipe_hnd.c | 81 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 127 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index b615080d34..8084e7673a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -892,6 +892,55 @@ BOOL setup_fault_pdu(pipes_struct *p, NTSTATUS status) return True; } +#if 0 +/******************************************************************* + Marshall a cancel_ack pdu. + We should probably check the auth-verifier here. +*******************************************************************/ + +BOOL setup_cancel_ack_reply(pipes_struct *p, prs_struct *rpc_in_p) +{ + prs_struct outgoing_pdu; + RPC_HDR ack_reply_hdr; + + /* Free any memory in the current return data buffer. */ + prs_mem_free(&p->out_data.rdata); + + /* + * Marshall directly into the outgoing PDU space. We + * must do this as we need to set to the bind response + * header and are never sending more than one PDU here. + */ + + prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL); + prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); + + /* + * Initialize a cancel_ack header. + */ + + init_rpc_hdr(&ack_reply_hdr, RPC_CANCEL_ACK, RPC_FLG_FIRST | RPC_FLG_LAST, + p->hdr.call_id, RPC_HEADER_LEN, 0); + + /* + * Marshall the header into the outgoing PDU. + */ + + if(!smb_io_rpc_hdr("", &ack_reply_hdr, &outgoing_pdu, 0)) { + DEBUG(0,("setup_cancel_ack_reply: marshalling of RPC_HDR failed.\n")); + prs_mem_free(&outgoing_pdu); + return False; + } + + p->out_data.data_sent_length = 0; + p->out_data.current_pdu_len = prs_offset(&outgoing_pdu); + p->out_data.current_pdu_sent = 0; + + prs_mem_free(&outgoing_pdu); + return True; +} +#endif + /******************************************************************* Ensure a bind request has the correct abstract & transfer interface. Used to reject unknown binds from Win2k. diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 6077faed16..5fb84115cc 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -716,6 +716,32 @@ static void process_complete_pdu(pipes_struct *p) (unsigned int)p->hdr.pkt_type )); switch (p->hdr.pkt_type) { + case RPC_REQUEST: + reply = process_request_pdu(p, &rpc_in); + break; + + case RPC_PING: /* CL request - ignore... */ + DEBUG(0,("process_complete_pdu: Error. Connectionless packet type %u received on pipe %s.\n", + (unsigned int)p->hdr.pkt_type, p->name)); + break; + + case RPC_RESPONSE: /* No responses here. */ + DEBUG(0,("process_complete_pdu: Error. RPC_RESPONSE received from client on pipe %s.\n", + p->name )); + break; + + case RPC_FAULT: + case RPC_WORKING: /* CL request - reply to a ping when a call in process. */ + case RPC_NOCALL: /* CL - server reply to a ping call. */ + case RPC_REJECT: + case RPC_ACK: + case RPC_CL_CANCEL: + case RPC_FACK: + case RPC_CANCEL_ACK: + DEBUG(0,("process_complete_pdu: Error. Connectionless packet type %u received on pipe %s.\n", + (unsigned int)p->hdr.pkt_type, p->name)); + break; + case RPC_BIND: /* * We assume that a pipe bind is only in one pdu. @@ -724,6 +750,14 @@ static void process_complete_pdu(pipes_struct *p) reply = api_pipe_bind_req(p, &rpc_in); } break; + + case RPC_BINDACK: + case RPC_BINDNACK: + DEBUG(0,("process_complete_pdu: Error. RPC_BINDACK/RPC_BINDNACK packet type %u received on pipe %s.\n", + (unsigned int)p->hdr.pkt_type, p->name)); + break; + + case RPC_ALTCONT: /* * We assume that a pipe bind is only in one pdu. @@ -732,6 +766,12 @@ static void process_complete_pdu(pipes_struct *p) reply = api_pipe_alter_context(p, &rpc_in); } break; + + case RPC_ALTCONTRESP: + DEBUG(0,("process_complete_pdu: Error. RPC_ALTCONTRESP on pipe %s: Should only be server -> client.\n", + p->name)); + break; + case RPC_AUTH3: /* * The third packet in an NTLMSSP auth exchange. @@ -740,9 +780,38 @@ static void process_complete_pdu(pipes_struct *p) reply = api_pipe_bind_auth3(p, &rpc_in); } break; - case RPC_REQUEST: - reply = process_request_pdu(p, &rpc_in); + + case RPC_SHUTDOWN: + DEBUG(0,("process_complete_pdu: Error. RPC_SHUTDOWN on pipe %s: Should only be server -> client.\n", + p->name)); + break; + + case RPC_CO_CANCEL: + /* For now just free all client data and continue processing. */ + DEBUG(3,("process_complete_pdu: RPC_ORPHANED. Abandoning rpc call.\n")); + /* As we never do asynchronous RPC serving, we can never cancel a + call (as far as I know). If we ever did we'd have to send a cancel_ack + reply. For now, just free all client data and continue processing. */ + reply = True; break; +#if 0 + /* Enable this if we're doing async rpc. */ + /* We must check the call-id matches the outstanding callid. */ + if(pipe_init_outgoing_data(p)) { + /* Send a cancel_ack PDU reply. */ + /* We should probably check the auth-verifier here. */ + reply = setup_cancel_ack_reply(p, &rpc_in); + } + break; +#endif + + case RPC_ORPHANED: + /* We should probably check the auth-verifier here. + For now just free all client data and continue processing. */ + DEBUG(3,("process_complete_pdu: RPC_ORPHANED. Abandoning rpc call.\n")); + reply = True; + break; + default: DEBUG(0,("process_complete_pdu: Unknown rpc type = %u received.\n", (unsigned int)p->hdr.pkt_type )); break; @@ -815,7 +884,13 @@ incoming data size = %u\n", (unsigned int)p->in_data.pdu_received_len, (unsigned */ if(p->in_data.pdu_needed_len == 0) { - return unmarshall_rpc_header(p); + ssize_t rret = unmarshall_rpc_header(p); + if (rret == -1 || p->in_data.pdu_needed_len > 0) { + return rret; + } + /* If rret == 0 and pdu_needed_len == 0 here we have a PDU that consists + of an RPC_HEADER only. This is a RPC_SHUTDOWN, RPC_CO_CANCEL or RPC_ORPHANED + pdu type. Deal with this in process_complete_pdu(). */ } /* -- cgit From 6ffd82ea7794747619e4d5eab20100f019eef2da Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 29 Nov 2005 23:40:01 +0000 Subject: r11964: rename flag to password_properties in SAM_UNK_INFO_1 because that's what it is. (SAM_UNK_INFO_1 should get a better name as well). Guenther (This used to be commit d94aaeb625c39b6205fe61c274aed57b1399bafc) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6ad5ec7706..52b78d5e8d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4834,7 +4834,7 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R pdb_set_account_policy(AP_MIN_PASSWORD_LEN, (uint32)q_u->ctr->info.inf1.min_length_password); pdb_set_account_policy(AP_PASSWORD_HISTORY, (uint32)q_u->ctr->info.inf1.password_history); - pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)q_u->ctr->info.inf1.flag); + pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)q_u->ctr->info.inf1.password_properties); pdb_set_account_policy(AP_MAX_PASSWORD_AGE, (int)u_expire); pdb_set_account_policy(AP_MIN_PASSWORD_AGE, (int)u_min_age); break; -- cgit From d1f91f7c723733113b4e9792042101c80dfc064c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Dec 2005 06:46:46 +0000 Subject: r12043: It's amazing the warnings you find when compiling on a 64-bit box with gcc4 and -O6... Fix a bunch of C99 dereferencing type-punned pointer will break strict-aliasing rules errors. Also added prs_int32 (not uint32...) as it's needed in one place. Find places where prs_uint32 was being used to marshall/unmarshall a time_t (a big no no on 64-bits). More warning fixes to come. Thanks to Volker for nudging me to compile like this. Jeremy. (This used to be commit c65b752604f8f58abc4e7ae8514dc2c7f086271c) --- source3/rpc_server/srv_eventlog_nt.c | 2 +- source3/rpc_server/srv_lsa_nt.c | 40 ++++++++++++++++++------------------ source3/rpc_server/srv_reg_nt.c | 2 +- source3/rpc_server/srv_samr_nt.c | 32 ++++++++++++++++------------- source3/rpc_server/srv_spoolss_nt.c | 2 +- source3/rpc_server/srv_svcctl_nt.c | 2 +- 6 files changed, 42 insertions(+), 38 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 658928b927..a8b9c66717 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -56,7 +56,7 @@ static EVENTLOG_INFO *find_eventlog_info_by_hnd( pipes_struct * p, { EVENTLOG_INFO *info; - if ( !find_policy_by_hnd( p, handle, ( void ** ) &info ) ) { + if ( !find_policy_by_hnd( p, handle, (void **)(void *)&info ) ) { DEBUG( 2, ( "find_eventlog_info_by_hnd: eventlog not found.\n" ) ); return NULL; diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 15d420538e..b56ae10914 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -501,7 +501,7 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E uint32 num_domains; NTSTATUS nt_status; - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ @@ -539,7 +539,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF r_u->status = NT_STATUS_OK; - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; switch (q_u->info_class) { @@ -657,7 +657,7 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_ ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); names = TALLOC_ZERO_P(p->mem_ctx, LSA_TRANS_NAME_ENUM); - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) { + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { r_u->status = NT_STATUS_INVALID_HANDLE; goto done; } @@ -706,7 +706,7 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries); - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) { + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { r_u->status = NT_STATUS_INVALID_HANDLE; goto done; } @@ -817,7 +817,7 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV DEBUG(10,("_lsa_enum_privs: enum_context:%d total entries:%d\n", enum_context, num_privs)); - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights @@ -864,7 +864,7 @@ NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, L fstring name_asc; const char *description; - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ @@ -912,7 +912,7 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU LSA_SID_ENUM *sids=&r_u->sids; NTSTATUS ret; - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) @@ -988,7 +988,7 @@ NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CR struct lsa_info *info; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ @@ -1036,7 +1036,7 @@ NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENAC struct lsa_info *info; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ @@ -1079,7 +1079,7 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, prs_struct *ps, LSA_Q_ENUMPRIVS PRIVILEGE_SET privileges; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; if ( !get_privileges_for_sids( &mask, &info->sid, 1 ) ) @@ -1114,7 +1114,7 @@ NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; if (!lookup_sid(&info->sid, dom_name, name, &type)) @@ -1145,7 +1145,7 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA r_u->status = NT_STATUS_OK; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is a Domain Admin since @@ -1175,7 +1175,7 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u struct current_user user; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is root or a Domain Admin since @@ -1216,7 +1216,7 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP struct current_user user; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is root or a Domain Admin since @@ -1259,7 +1259,7 @@ NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUER r_u->status = NT_STATUS_OK; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ @@ -1316,7 +1316,7 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I ZERO_STRUCT(guid); r_u->status = NT_STATUS_OK; - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; switch (q_u->info_class) { @@ -1378,7 +1378,7 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is a Domain Admin since @@ -1436,7 +1436,7 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is a Domain Admin since @@ -1498,7 +1498,7 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* according to an NT4 PDC, you can add privileges to SIDs even without @@ -1539,7 +1539,7 @@ NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, L /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; unistr2_to_ascii(name, &q_u->privname.unistring, sizeof(name)); diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 35a060c38e..33711d0fac 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -54,7 +54,7 @@ static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) { REGISTRY_KEY *regkey = NULL; - if(!find_policy_by_hnd(p,hnd,(void **)®key)) { + if(!find_policy_by_hnd(p,hnd,(void **)(void *)®key)) { DEBUG(2,("find_regkey_index_by_hnd: Registry Key not found: ")); return NULL; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 52b78d5e8d..635d870762 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -573,7 +573,7 @@ NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN /* find the connection policy handle. */ - if ( !find_policy_by_hnd(p, &q_u->pol, (void**)&info) ) + if ( !find_policy_by_hnd(p, &q_u->pol, (void**)(void *)&info) ) return NT_STATUS_INVALID_HANDLE; status = access_check_samr_function( info->acc_granted, @@ -627,7 +627,7 @@ NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, 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)) + if (!find_policy_by_hnd(p, &q_u->user_pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; if (!sid_check_is_in_our_domain(&info->sid)) @@ -665,7 +665,7 @@ static BOOL get_lsa_policy_samr_sid( pipes_struct *p, POLICY_HND *pol, struct samr_info *info = NULL; /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, pol, (void **)&info)) + if (!find_policy_by_hnd(p, pol, (void **)(void *)&info)) return False; if (!info) @@ -803,7 +803,7 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, r_u->status = NT_STATUS_OK; /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, @@ -936,7 +936,7 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM r_u->status = NT_STATUS_OK; /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; r_u->status = access_check_samr_function(info->acc_granted, @@ -995,7 +995,7 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S uint32 num_aliases = 0; /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; r_u->status = access_check_samr_function(info->acc_granted, @@ -1061,7 +1061,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, r_u->status = NT_STATUS_UNSUCCESSFUL; /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* @@ -1857,7 +1857,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ r_u->status=NT_STATUS_OK; /* search for the handle */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; domain_sid = info->sid; @@ -2094,7 +2094,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) { + if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)(void *)&info)) { return NT_STATUS_INVALID_HANDLE; } @@ -2165,7 +2165,11 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA /* AS ROOT !!! */ - pdb_get_account_policy(AP_TIME_TO_LOGOUT, (unsigned int *)&u_logout); + { + uint32 ul; + pdb_get_account_policy(AP_TIME_TO_LOGOUT, &ul); + u_logout = (time_t)ul; + } /* !AS ROOT */ @@ -2641,7 +2645,7 @@ NTSTATUS _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_ r_u->status = NT_STATUS_OK; - if (!find_policy_by_hnd(p, &q_u->connect_pol, (void**)&info)) + if (!find_policy_by_hnd(p, &q_u->connect_pol, (void**)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* win9x user manager likes to use SA_RIGHT_SAM_ENUM_DOMAINS here. @@ -2717,7 +2721,7 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN r_u->status = NT_STATUS_OK; - if (!find_policy_by_hnd(p, &q_u->pol, (void**)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void**)(void *)&info)) return NT_STATUS_INVALID_HANDLE; if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_SAM_ENUM_DOMAINS, "_samr_enum_domains"))) { @@ -3418,7 +3422,7 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, DEBUG(5,("_samr_query_useraliases: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; ntstatus1 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_LOOKUP_ALIAS_BY_MEM, "_samr_query_useraliases"); @@ -4704,7 +4708,7 @@ NTSTATUS _samr_query_domain_info2(pipes_struct *p, DEBUG(5,("_samr_query_domain_info2: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info)) + if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; switch (q_u->switch_value) { diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f0ba863b4d..334158bbbd 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -267,7 +267,7 @@ static Printer_entry *find_printer_index_by_hnd(pipes_struct *p, POLICY_HND *hnd { Printer_entry *find_printer = NULL; - if(!find_policy_by_hnd(p,hnd,(void **)&find_printer)) { + if(!find_policy_by_hnd(p,hnd,(void **)(void *)&find_printer)) { DEBUG(2,("find_printer_index_by_hnd: Printer handle not found: ")); return NULL; } diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 19648f5e78..bbf313f7fa 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -186,7 +186,7 @@ static SERVICE_INFO *find_service_info_by_hnd(pipes_struct *p, POLICY_HND *hnd) { SERVICE_INFO *service_info = NULL; - if( !find_policy_by_hnd( p, hnd, (void **)&service_info) ) { + if( !find_policy_by_hnd( p, hnd, (void **)(void *)&service_info) ) { DEBUG(2,("find_service_info_by_hnd: handle not found")); return NULL; } -- cgit From 05ac2de0df78d22ad5afb42ea5c72ba17bef8395 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 3 Dec 2005 18:34:13 +0000 Subject: r12051: Merge across the lookup_name and lookup_sid work. Lets see how the build farm reacts :-) Volker (This used to be commit 9f99d04a54588cd9d1a1ab163ebb304437f932f7) --- source3/rpc_server/srv_lsa_nt.c | 123 ++++++++++++++++++--------------- source3/rpc_server/srv_samr_nt.c | 144 +++++++++++++++++++++++---------------- 2 files changed, 153 insertions(+), 114 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index b56ae10914..78e9cd6211 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -135,67 +135,75 @@ static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) init_lsa_rid2s ***************************************************************************/ -static void init_lsa_rid2s(DOM_R_REF *ref, DOM_RID2 *rid2, - int num_entries, UNISTR2 *name, - uint32 *mapped_count, BOOL endian) +static int init_lsa_rid2s(TALLOC_CTX *mem_ctx, + DOM_R_REF *ref, DOM_RID2 *rid2, + int num_entries, UNISTR2 *name, + int flags) { - int i; - int total = 0; - *mapped_count = 0; + int mapped_count, i; SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS); + mapped_count = 0; + become_root(); /* lookup_name can require root privs */ for (i = 0; i < num_entries; i++) { BOOL status = False; DOM_SID sid; - uint32 rid = 0xffffffff; - int dom_idx = -1; - pstring full_name; - fstring dom_name, user; - enum SID_NAME_USE name_type = SID_NAME_UNKNOWN; + uint32 rid; + int dom_idx; + char *full_name, *domain; + enum SID_NAME_USE type = SID_NAME_UNKNOWN; /* Split name into domain and user component */ - unistr2_to_ascii(full_name, &name[i], sizeof(full_name)); - split_domain_name(full_name, dom_name, user); - - /* Lookup name */ + if (rpcstr_pull_unistr2_talloc(mem_ctx, &full_name, + &name[i]) < 0) { + DEBUG(0, ("pull_ucs2_talloc failed\n")); + return 0; + } DEBUG(5, ("init_lsa_rid2s: looking up name %s\n", full_name)); - status = lookup_name(dom_name, user, &sid, &name_type); - - if((name_type == SID_NAME_UNKNOWN) && (lp_server_role() == ROLE_DOMAIN_MEMBER) && (strncmp(dom_name, full_name, strlen(dom_name)) != 0)) { - DEBUG(5, ("init_lsa_rid2s: domain name not provided and local account not found, using member domain\n")); - fstrcpy(dom_name, lp_workgroup()); - status = lookup_name(dom_name, user, &sid, &name_type); - } + /* We can ignore the result of lookup_name, it will not touch + "type" if it's not successful */ - if (name_type == SID_NAME_WKN_GRP) { - /* BUILTIN aliases are still aliases :-) */ - name_type = SID_NAME_ALIAS; - } + lookup_name(mem_ctx, full_name, flags, &domain, NULL, + &sid, &type); DEBUG(5, ("init_lsa_rid2s: %s\n", status ? "found" : "not found")); - if (status && name_type != SID_NAME_UNKNOWN) { + switch (type) { + case SID_NAME_USER: + case SID_NAME_DOM_GRP: + case SID_NAME_DOMAIN: + case SID_NAME_ALIAS: + case SID_NAME_WKN_GRP: + /* Leave these unchanged */ + break; + default: + /* Don't hand out anything but the list above */ + type = SID_NAME_UNKNOWN; + break; + } + + rid = 0; + dom_idx = -1; + + if (type != SID_NAME_UNKNOWN) { sid_split_rid(&sid, &rid); - dom_idx = init_dom_ref(ref, dom_name, &sid); - (*mapped_count)++; - } else { - dom_idx = -1; - rid = 0; - name_type = SID_NAME_UNKNOWN; + dom_idx = init_dom_ref(ref, domain, &sid); + mapped_count++; } - init_dom_rid2(&rid2[total], rid, name_type, dom_idx); - total++; + init_dom_rid2(&rid2[i], rid, type, dom_idx); } unbecome_root(); + + return mapped_count; } /*************************************************************************** @@ -250,42 +258,44 @@ static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME DOM_SID find_sid = sid[i].sid; uint32 rid = 0xffffffff; int dom_idx = -1; - fstring name, dom_name; - enum SID_NAME_USE sid_name_use = (enum SID_NAME_USE)0; + char *name, *domain; + enum SID_NAME_USE type = SID_NAME_UNKNOWN; - sid_to_string(name, &find_sid); - DEBUG(5, ("init_lsa_trans_names: looking up sid %s\n", name)); + DEBUG(5, ("init_lsa_trans_names: looking up sid %s\n", + sid_string_static(&find_sid))); /* Lookup sid from winbindd */ - status = lookup_sid(&find_sid, dom_name, name, &sid_name_use); + status = lookup_sid(ctx, &find_sid, &domain, &name, &type); DEBUG(5, ("init_lsa_trans_names: %s\n", status ? "found" : "not found")); if (!status) { - sid_name_use = SID_NAME_UNKNOWN; - memset(dom_name, '\0', sizeof(dom_name)); - sid_to_string(name, &find_sid); + type = SID_NAME_UNKNOWN; + domain = talloc_strdup(ctx, ""); + name = talloc_strdup(ctx, + sid_string_static(&find_sid)); dom_idx = -1; - DEBUG(10,("init_lsa_trans_names: added unknown user '%s' to " - "referenced list.\n", name )); + DEBUG(10,("init_lsa_trans_names: added unknown user " + "'%s' to referenced list.\n", name )); } else { (*mapped_count)++; /* Store domain sid in ref array */ if (find_sid.num_auths == 5) { sid_split_rid(&find_sid, &rid); } - dom_idx = init_dom_ref(ref, dom_name, &find_sid); + dom_idx = init_dom_ref(ref, domain, &find_sid); - DEBUG(10,("init_lsa_trans_names: added %s '%s\\%s' (%d) to referenced list.\n", - sid_type_lookup(sid_name_use), dom_name, name, sid_name_use )); + DEBUG(10,("init_lsa_trans_names: added %s '%s\\%s' " + "(%d) to referenced list.\n", + sid_type_lookup(type), domain, name, type)); } init_lsa_trans_name(&trn->name[total], &trn->uni_name[total], - sid_name_use, name, dom_idx); + type, name, dom_idx); total++; } @@ -697,12 +707,18 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP DOM_R_REF *ref; DOM_RID2 *rids; uint32 mapped_count = 0; + int flags = 0; if (num_entries > MAX_LOOKUP_SIDS) { num_entries = MAX_LOOKUP_SIDS; DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries)); } + /* Probably the lookup_level is some sort of bitmask. */ + if (q_u->lookup_level == 1) { + flags = LOOKUP_NAME_ALL; + } + ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries); @@ -720,10 +736,11 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP if (!ref || !rids) return NT_STATUS_NO_MEMORY; + /* set up the LSA Lookup RIDs response */ + mapped_count = init_lsa_rid2s(p->mem_ctx, ref, rids, num_entries, + names, flags); done: - /* set up the LSA Lookup RIDs response */ - init_lsa_rid2s(ref, rids, num_entries, names, &mapped_count, p->endian); if (NT_STATUS_IS_OK(r_u->status)) { if (mapped_count == 0) r_u->status = NT_STATUS_NONE_MAPPED; @@ -1109,15 +1126,13 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, prs_struct *ps, LSA_Q_ENUMPRIVS NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA_R_GETSYSTEMACCOUNT *r_u) { struct lsa_info *info=NULL; - fstring name, dom_name; - enum SID_NAME_USE type; /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - if (!lookup_sid(&info->sid, dom_name, name, &type)) + if (!lookup_sid(p->mem_ctx, &info->sid, NULL, NULL, NULL)) return NT_STATUS_ACCESS_DENIED; /* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 635d870762..13f3a3284b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1366,9 +1366,7 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOKUP_NAMES *r_u) { uint32 rid[MAX_SAM_ENTRIES]; - uint32 local_rid; enum SID_NAME_USE type[MAX_SAM_ENTRIES]; - enum SID_NAME_USE local_type; int i; int num_rids = q_u->num_names2; DOM_SID pol_sid; @@ -1400,42 +1398,30 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO for (i = 0; i < num_rids; i++) { fstring name; - DOM_SID sid; int ret; r_u->status = NT_STATUS_NONE_MAPPED; + type[i] = SID_NAME_UNKNOWN; rid [i] = 0xffffffff; - type[i] = SID_NAME_UNKNOWN; ret = rpcstr_pull(name, q_u->uni_name[i].buffer, sizeof(name), q_u->uni_name[i].uni_str_len*2, 0); - /* - * we are only looking for a name - * the SID we get back can be outside - * the scope of the pol_sid - * - * in clear: it prevents to reply to domain\group: yes - * when only builtin\group exists. - * - * a cleaner code is to add the sid of the domain we're looking in - * to the local_lookup_name function. - */ - - if ((ret > 0) && local_lookup_name(name, &sid, &local_type)) { - sid_split_rid(&sid, &local_rid); - - if (sid_equal(&sid, &pol_sid)) { - rid[i]=local_rid; - - /* Windows does not return WKN_GRP here, even - * on lookups in builtin */ - type[i] = (local_type == SID_NAME_WKN_GRP) ? - SID_NAME_ALIAS : local_type; - - r_u->status = NT_STATUS_OK; + if (ret <= 0) { + continue; + } + + if (sid_check_is_builtin(&pol_sid)) { + if (lookup_builtin_name(name, &rid[i])) { + type[i] = SID_NAME_ALIAS; } - } + } else { + lookup_global_sam_name(name, &rid[i], &type[i]); + } + + if (type[i] != SID_NAME_UNKNOWN) { + r_u->status = NT_STATUS_OK; + } } init_samr_r_lookup_names(p->mem_ctx, r_u, num_rids, rid, (uint32 *)type, r_u->status); @@ -2247,6 +2233,41 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA return r_u->status; } +/* W2k3 seems to use the same check for all 3 objects that can be created via + * SAMR, if you try to create for example "Dialup" as an alias it says + * "NT_STATUS_USER_EXISTS". This is racy, but we can't really lock the user + * database. */ + +static NTSTATUS can_create(TALLOC_CTX *mem_ctx, const char *new_name) +{ + enum SID_NAME_USE type; + BOOL result; + + become_root(); + /* Lookup in our local databases (only LOOKUP_NAME_ISOLATED set) + * whether the name already exists */ + result = lookup_name(mem_ctx, new_name, LOOKUP_NAME_ISOLATED, + NULL, NULL, NULL, &type); + unbecome_root(); + + if (!result) { + return NT_STATUS_OK; + } + + DEBUG(5, ("trying to create %s, exists as %s\n", + new_name, sid_type_lookup(type))); + + if (type == SID_NAME_DOM_GRP) { + return NT_STATUS_GROUP_EXISTS; + } + if (type == SID_NAME_ALIAS) { + return NT_STATUS_ALIAS_EXISTS; + } + + /* Yes, the default is NT_STATUS_USER_EXISTS */ + return NT_STATUS_USER_EXISTS; +} + /******************************************************************* _samr_create_user Create an account, can be either a normal user or a machine. @@ -2294,19 +2315,11 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA rpcstr_pull(account, user_account.buffer, sizeof(account), user_account.uni_str_len*2, 0); strlower_m(account); - pdb_init_sam(&sam_pass); - - become_root(); - ret = pdb_getsampwnam(sam_pass, account); - unbecome_root(); - if (ret == True) { - /* this account exists: say so */ - pdb_free_sam(&sam_pass); - return NT_STATUS_USER_EXISTS; + nt_status = can_create(p->mem_ctx, account); + if (!NT_STATUS_IS_OK(nt_status)) { + return nt_status; } - pdb_free_sam(&sam_pass); - /********************************************************************* * HEADS UP! If we have to create a new user account, we have to get * a new RID from somewhere. This used to be done by the passdb @@ -2776,7 +2789,7 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A /* append the alias' RID to it */ if (!sid_append_rid(&sid, alias_rid)) - return NT_STATUS_NO_SUCH_USER; + return NT_STATUS_NO_SUCH_ALIAS; /*check if access can be granted as requested by client. */ @@ -2793,12 +2806,21 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A if ( !NT_STATUS_IS_OK(status) ) return status; - /* - * we should check if the rid really exist !!! - * JFM. - */ + { + /* Check we actually have the requested alias */ + enum SID_NAME_USE type; + BOOL result; - /* associate the user's SID with the new handle. */ + become_root(); + result = lookup_sid(NULL, &sid, NULL, NULL, &type); + unbecome_root(); + + if (!result || (type != SID_NAME_ALIAS)) { + return NT_STATUS_NO_SUCH_ALIAS; + } + } + + /* associate the alias SID with the new handle. */ if ((info = get_samr_info_by_sid(&sid)) == NULL) return NT_STATUS_NO_MEMORY; @@ -2814,12 +2836,11 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A /******************************************************************* set_user_info_7 ********************************************************************/ -static NTSTATUS set_user_info_7(const SAM_USER_INFO_7 *id7, SAM_ACCOUNT *pwd) +static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx, + const SAM_USER_INFO_7 *id7, SAM_ACCOUNT *pwd) { fstring new_name; - SAM_ACCOUNT *check_acct = NULL; NTSTATUS rc; - BOOL check_rc; if (id7 == NULL) { DEBUG(5, ("set_user_info_7: NULL id7\n")); @@ -2842,13 +2863,9 @@ static NTSTATUS set_user_info_7(const SAM_USER_INFO_7 *id7, SAM_ACCOUNT *pwd) simply that the rename fails with a slightly different status code (like UNSUCCESSFUL instead of ALREADY_EXISTS). */ - pdb_init_sam(&check_acct); - check_rc = pdb_getsampwnam(check_acct, new_name); - pdb_free_sam(&check_acct); - - if (check_rc == True) { - /* this account exists: say so */ - return NT_STATUS_USER_EXISTS; + rc = can_create(mem_ctx, new_name); + if (!NT_STATUS_IS_OK(rc)) { + return rc; } rc = pdb_rename_sam_account(pwd, new_name); @@ -3365,7 +3382,8 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ switch (switch_value) { case 7: - r_u->status = set_user_info_7(ctr->info.id7, pwd); + r_u->status = set_user_info_7(p->mem_ctx, + ctr->info.id7, pwd); break; case 16: if (!set_user_info_16(ctr->info.id16, pwd)) @@ -4199,9 +4217,10 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S unistr2_to_ascii(name, &q_u->uni_acct_desc, sizeof(name)-1); - /* check if group already exist */ - if ((grp=getgrnam(name)) != NULL) - return NT_STATUS_GROUP_EXISTS; + r_u->status = can_create(p->mem_ctx, name); + if (!NT_STATUS_IS_OK(r_u->status)) { + return r_u->status; + } se_priv_copy( &se_rights, &se_add_users ); can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); @@ -4289,6 +4308,11 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; + r_u->status = can_create(p->mem_ctx, name); + if (!NT_STATUS_IS_OK(r_u->status)) { + return r_u->status; + } + unistr2_to_ascii(name, &q_u->uni_acct_desc, sizeof(name)-1); se_priv_copy( &se_rights, &se_add_users ); -- cgit From 6a92f418ea36eb12b247e11656b3e8bbe367f394 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 8 Dec 2005 19:34:22 +0000 Subject: r12133: Fix an uninitialized variable in new code in rpc_server/srv_samr_nt.c. Fix winbind_lookup_name for the local domain, ie for aliases on a member server. Volker (This used to be commit 4ba50c823e8d61f87ab5627f15e826e73e45ffcc) --- source3/rpc_server/srv_samr_nt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 13f3a3284b..880e1db388 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2243,6 +2243,8 @@ static NTSTATUS can_create(TALLOC_CTX *mem_ctx, const char *new_name) enum SID_NAME_USE type; BOOL result; + DEBUG(10, ("Checking whether [%s] can be created\n", new_name)); + become_root(); /* Lookup in our local databases (only LOOKUP_NAME_ISOLATED set) * whether the name already exists */ @@ -2251,6 +2253,7 @@ static NTSTATUS can_create(TALLOC_CTX *mem_ctx, const char *new_name) unbecome_root(); if (!result) { + DEBUG(10, ("%s does not exist, can create it\n", new_name)); return NT_STATUS_OK; } @@ -4308,16 +4311,16 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; - r_u->status = can_create(p->mem_ctx, name); - if (!NT_STATUS_IS_OK(r_u->status)) { - return r_u->status; - } - unistr2_to_ascii(name, &q_u->uni_acct_desc, sizeof(name)-1); se_priv_copy( &se_rights, &se_add_users ); can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); + result = can_create(p->mem_ctx, name); + if (!NT_STATUS_IS_OK(result)) { + return result; + } + /******** BEGIN SeAddUsers BLOCK *********/ if ( can_add_accounts ) -- cgit From 661c5c741a5285a5ddf8c1fc74ba50335f1c1931 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 10 Dec 2005 11:22:01 +0000 Subject: r12163: Change lookup_sid and lookup_name to return const char * instead of char *, use a temporary talloc_ctx for clarity. Volker (This used to be commit b15815c804bf3e558ed6357b5e9a6e3e0fac777f) --- source3/rpc_server/srv_lsa_nt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 78e9cd6211..6cd673550e 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -96,7 +96,7 @@ static void init_dom_query(DOM_QUERY *d_q, const char *dom_name, DOM_SID *dom_si init_dom_ref - adds a domain if it's not already in, returns the index. ***************************************************************************/ -static int init_dom_ref(DOM_R_REF *ref, char *dom_name, DOM_SID *dom_sid) +static int init_dom_ref(DOM_R_REF *ref, const char *dom_name, DOM_SID *dom_sid) { int num = 0; @@ -153,7 +153,8 @@ static int init_lsa_rid2s(TALLOC_CTX *mem_ctx, DOM_SID sid; uint32 rid; int dom_idx; - char *full_name, *domain; + char *full_name; + const char *domain; enum SID_NAME_USE type = SID_NAME_UNKNOWN; /* Split name into domain and user component */ @@ -258,7 +259,7 @@ static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME DOM_SID find_sid = sid[i].sid; uint32 rid = 0xffffffff; int dom_idx = -1; - char *name, *domain; + const char *name, *domain; enum SID_NAME_USE type = SID_NAME_UNKNOWN; DEBUG(5, ("init_lsa_trans_names: looking up sid %s\n", -- cgit From a48955306705ac7f045e3726d7097900550bebe3 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sun, 11 Dec 2005 04:21:34 +0000 Subject: r12173: doing some service control work * Add a few new error codes for disabled services * dump some more details about service status in 'net rpc service' * disable the WINS and NetLogon services if not configured in smb.conf Still trying to figure out how to disable the start button on the NetLogon and WINS services. (This used to be commit c0f54eeebc84ec9fab63c5b105511762bcc136be) --- source3/rpc_server/srv_svcctl_nt.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index bbf313f7fa..97c38753c3 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -615,9 +615,20 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG config->tag_id = 0x00000000; /* unassigned loadorder group */ config->service_type = SVCCTL_WIN32_OWN_PROC; - config->start_type = SVCCTL_DEMAND_START; config->error_control = SVCCTL_SVC_ERROR_NORMAL; + /* set the start type. NetLogon and WINS are disabled to prevent + the client from showing the "Start" button (if of course the services + are not running */ + + if ( strequal( name, "NETLOGON" ) && ( lp_servicenumber(name) == -1 ) ) + config->start_type = SVCCTL_DISABLED; + else if ( strequal( name, "WINS" ) && ( !lp_wins_support() )) + config->start_type = SVCCTL_DISABLED; + else + config->start_type = SVCCTL_DEMAND_START; + + TALLOC_FREE( values ); return WERR_OK; -- cgit From 2c0114d2116488de195ca99a0f1d46d79a7bdbd6 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sun, 11 Dec 2005 05:06:35 +0000 Subject: r12177: last of outstanding patches in my queue to deal with MMC. Validate the share name and fail when trying to creating a share with bad characters. (This used to be commit 174fe494f9cbec3386ed687007e137fa7064373d) --- source3/rpc_server/srv_srvsvc_nt.c | 46 +++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 0e7ded39f5..1d574d82fb 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -29,6 +29,26 @@ extern struct generic_mapping file_generic_mapping; #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +#define INVALID_SHARENAME_CHARS "<>*?|" + +/******************************************************************** + Check a string for any occurrences of a specified list of invalid + characters. +********************************************************************/ + +static BOOL validate_net_name( const char *name, const char *invalid_chars, int max_len ) +{ + int i; + + for ( i=0; istatus; } +/******************************************************************** +********************************************************************/ + WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV_R_NET_NAME_VALIDATE *r_u) { - fstring share_name; + fstring sharename; switch ( q_u->type ) { case 0x9: - /* check if share name is ok. - TODO: check for invalid characters in name? */ - - unistr2_to_ascii(share_name, &q_u->uni_name, sizeof(share_name)); + /* Run the name through alpha_strcpy() to remove any unsafe + shell characters. Compare the copied string with the original + and fail if the strings don't match */ + + unistr2_to_ascii(sharename, &q_u->uni_name, sizeof(sharename)); + if ( !validate_net_name( sharename, INVALID_SHARENAME_CHARS, sizeof(sharename) ) ) { + DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", sharename)); + return WERR_INVALID_NAME; + } break; + default: return WERR_UNKNOWN_LEVEL; } -- cgit From 728e527d2c73b1db69f03bcf6015af6843315408 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 14 Dec 2005 01:09:46 +0000 Subject: r12224: adding more characters to the invalid share name string (This used to be commit e461143639889da78cd4de47df40ac59a5a758a4) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 1d574d82fb..090aa4c9ff 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -29,7 +29,7 @@ extern struct generic_mapping file_generic_mapping; #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -#define INVALID_SHARENAME_CHARS "<>*?|" +#define INVALID_SHARENAME_CHARS "<>*?|/\\+=;:\"," /******************************************************************** Check a string for any occurrences of a specified list of invalid -- cgit From 6f91e3a8629de97468357339f68d789ab01814ce Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 15 Dec 2005 18:39:28 +0000 Subject: r12262: * patch from Brian Moran to fix segv in eventlogadm when not eventlogs are listed in smb.conf * initialize the local group description in set_alias_info() (This used to be commit 58f8b42069a69c0b61da2609e5706a6c0d512e09) --- source3/rpc_server/srv_samr_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 880e1db388..c90b4d3660 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4516,6 +4516,8 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ ctr->alias.info3.description.string, sizeof(info.acct_desc)-1 ); } + else + fstrcpy( info.acct_desc, "" ); break; default: return NT_STATUS_INVALID_INFO_CLASS; -- cgit From e7a1a0ead2013464dc8204e5b997ddc3ae46e973 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 13 Jan 2006 20:24:50 +0000 Subject: r12914: adding query/set ops for security descriptors on services. (This used to be commit cefd2d7cb6140b068d66e2383e9acfa4c3c4b4c7) --- source3/rpc_server/srv_svcctl.c | 52 ++++++++++++++++++++- source3/rpc_server/srv_svcctl_nt.c | 92 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 31d8bbe9b3..74ae3aaa16 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -358,6 +358,54 @@ static BOOL api_svcctl_unlock_service_db(pipes_struct *p) return True; } +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_query_security_sec(pipes_struct *p) +{ + SVCCTL_Q_QUERY_SERVICE_SEC q_u; + SVCCTL_R_QUERY_SERVICE_SEC r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_query_service_sec("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_query_service_sec(p, &q_u, &r_u); + + if(!svcctl_io_r_query_service_sec("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_set_security_sec(pipes_struct *p) +{ + SVCCTL_Q_SET_SERVICE_SEC q_u; + SVCCTL_R_SET_SERVICE_SEC r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!svcctl_io_q_set_service_sec("", &q_u, data, 0)) + return False; + + r_u.status = _svcctl_set_service_sec(p, &q_u, &r_u); + + if(!svcctl_io_r_set_service_sec("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* \PIPE\svcctl commands @@ -378,7 +426,9 @@ static struct api_struct api_svcctl_cmds[] = { "SVCCTL_CONTROL_SERVICE" , SVCCTL_CONTROL_SERVICE , api_svcctl_control_service }, { "SVCCTL_QUERY_SERVICE_STATUSEX_W" , SVCCTL_QUERY_SERVICE_STATUSEX_W , api_svcctl_query_service_status_ex }, { "SVCCTL_LOCK_SERVICE_DB" , SVCCTL_LOCK_SERVICE_DB , api_svcctl_lock_service_db }, - { "SVCCTL_UNLOCK_SERVICE_DB" , SVCCTL_UNLOCK_SERVICE_DB , api_svcctl_unlock_service_db } + { "SVCCTL_UNLOCK_SERVICE_DB" , SVCCTL_UNLOCK_SERVICE_DB , api_svcctl_unlock_service_db }, + { "SVCCTL_QUERY_SERVICE_SEC" , SVCCTL_QUERY_SERVICE_SEC , api_svcctl_query_security_sec }, + { "SVCCTL_SET_SERVICE_SEC" , SVCCTL_SET_SERVICE_SEC , api_svcctl_set_security_sec } }; diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 97c38753c3..4db8f7ed3f 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -771,3 +771,95 @@ WERROR _svcctl_unlock_service_db( pipes_struct *p, SVCCTL_Q_UNLOCK_SERVICE_DB *q return close_policy_hnd( p, &q_u->h_lock) ? WERR_OK : WERR_BADFID; } + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_query_service_sec( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_SEC *q_u, SVCCTL_R_QUERY_SERVICE_SEC *r_u ) +{ + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SEC_DESC *sec_desc; + + + /* only support the SCM and individual services */ + + if ( !info || !(info->type & (SVC_HANDLE_IS_SERVICE|SVC_HANDLE_IS_SCM)) ) + return WERR_BADFID; + + /* check access reights (according to MSDN) */ + + if ( !(info->access_granted & STD_RIGHT_READ_CONTROL_ACCESS) ) + return WERR_ACCESS_DENIED; + + /* TODO: handle something besides DACL_SECURITY_INFORMATION */ + + if ( (q_u->security_flags & DACL_SECURITY_INFORMATION) != DACL_SECURITY_INFORMATION ) + return WERR_INVALID_PARAM; + + /* lookup the security descriptor and marshall it up for a reply */ + + if ( !(sec_desc = svcctl_get_secdesc( p->mem_ctx, info->name, get_root_nt_token() )) ) + return WERR_NOMEM; + + r_u->needed = sec_desc_size( sec_desc ); + + if ( r_u->needed > q_u->buffer_size ) { + ZERO_STRUCTP( &r_u->buffer ); + return WERR_INSUFFICIENT_BUFFER; + } + + rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); + + if ( !sec_io_desc("", &sec_desc, &r_u->buffer.prs, 0 ) ) + return WERR_NOMEM; + + return WERR_OK; +} + +/******************************************************************** +********************************************************************/ + +WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, SVCCTL_R_SET_SERVICE_SEC *r_u ) +{ + SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SEC_DESC *sec_desc = NULL; + uint32 required_access; + + if ( !info || !(info->type & (SVC_HANDLE_IS_SERVICE|SVC_HANDLE_IS_SCM)) ) + return WERR_BADFID; + + /* check the access on the open handle */ + + switch ( q_u->security_flags ) { + case DACL_SECURITY_INFORMATION: + required_access = STD_RIGHT_WRITE_DAC_ACCESS; + break; + + case OWNER_SECURITY_INFORMATION: + case GROUP_SECURITY_INFORMATION: + required_access = STD_RIGHT_WRITE_OWNER_ACCESS; + break; + + case SACL_SECURITY_INFORMATION: + return WERR_INVALID_PARAM; + default: + return WERR_INVALID_PARAM; + } + + if ( !(info->access_granted & required_access) ) + return WERR_ACCESS_DENIED; + + /* read the security descfriptor */ + + if ( !sec_io_desc("", &sec_desc, &q_u->buffer.prs, 0 ) ) + return WERR_NOMEM; + + /* store the new SD */ + + if ( !svcctl_set_secdesc( p->mem_ctx, info->name, sec_desc, p->pipe_user.nt_user_token ) ) + return WERR_ACCESS_DENIED; + + return WERR_OK; +} + + -- cgit From bb59be3e0d2687fd2a59e831f7efdb34e5ee5d3d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 13 Jan 2006 20:26:59 +0000 Subject: r12915: protect against changing the SCM security descriptor (This used to be commit 5842da99681c15437c11e9925dec24c8c0e3708a) --- source3/rpc_server/srv_svcctl_nt.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 4db8f7ed3f..049bdf6075 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -828,6 +828,11 @@ WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, if ( !info || !(info->type & (SVC_HANDLE_IS_SERVICE|SVC_HANDLE_IS_SCM)) ) return WERR_BADFID; + /* can't set the security de4scriptor on the ServiceControlManager */ + + if ( info->type == SVC_HANDLE_IS_SCM ) + return WERR_ACCESS_DENIED; + /* check the access on the open handle */ switch ( q_u->security_flags ) { -- cgit From 005c88054f526d9a14d748b665cd6b4853e60a35 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 13 Jan 2006 21:22:25 +0000 Subject: r12916: use rpcstr_pull() instead of unistr_to_ascii() when validating share names (This used to be commit c08bc30698eac2f3f5dd8257b4fd7c3e23e6de39) --- source3/rpc_server/srv_srvsvc_nt.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 090aa4c9ff..230f062662 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1,5 +1,5 @@ - /* - * Unix SMB/CIFS implementation. +/* + * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Jeremy Allison 2001. @@ -2312,11 +2312,7 @@ WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV switch ( q_u->type ) { case 0x9: - /* Run the name through alpha_strcpy() to remove any unsafe - shell characters. Compare the copied string with the original - and fail if the strings don't match */ - - unistr2_to_ascii(sharename, &q_u->uni_name, sizeof(sharename)); + rpcstr_pull(sharename, q_u->uni_name.buffer, sizeof(sharename), q_u->uni_name.uni_str_len*2, 0); if ( !validate_net_name( sharename, INVALID_SHARENAME_CHARS, sizeof(sharename) ) ) { DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", sharename)); return WERR_INVALID_NAME; -- cgit From a02415bf363e3c1b6863b135bdae3b2e2708db3b Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Sat, 14 Jan 2006 12:37:25 +0000 Subject: r12935: After discussion with Volker fix bug #3397 using a variant of the patch by Alex Deiter (tiamat@komi.mts.ru). Introduces level 9 of getuserinfo and allows to successfully install MS SMS2003 on a member of a Samba domain. Also added support for this level in rpcclient. The code for infolevel 9 is modelled upon Samba-TNG by Alex Deiter. Jerry, we need this in 3.0.21b. (This used to be commit 93461646ce2ad6e2f8b11d40ce98722d56a83b43) --- source3/rpc_server/srv_samr_nt.c | 53 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c90b4d3660..8f8c035c9c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1672,6 +1672,41 @@ static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_S return NT_STATUS_OK; } + +/************************************************************************* + get_user_info_9. Only gives out primary group SID. + *************************************************************************/ +static NTSTATUS get_user_info_9(TALLOC_CTX *mem_ctx, SAM_USER_INFO_9 * id9, DOM_SID *user_sid) +{ + SAM_ACCOUNT *smbpass=NULL; + BOOL ret; + NTSTATUS nt_status; + + nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass); + + if (!NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } + + become_root(); + ret = pdb_getsampwsid(smbpass, user_sid); + unbecome_root(); + + if (ret==False) { + DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); + return NT_STATUS_NO_SUCH_USER; + } + + DEBUG(3,("User:[%s]\n", pdb_get_username(smbpass) )); + + ZERO_STRUCTP(id9); + init_sam_user_info9(id9, pdb_get_group_rid(smbpass) ); + + pdb_free_sam(&smbpass); + + return NT_STATUS_OK; +} + /************************************************************************* get_user_info_16. Safe. Only gives out acb bits. *************************************************************************/ @@ -1864,6 +1899,8 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ /* ok! user info levels (lots: see MSDEV help), off we go... */ ctr->switch_value = q_u->switch_value; + DEBUG(5,("_samr_query_userinfo: user info level: %d\n", q_u->switch_value)); + switch (q_u->switch_value) { case 7: ctr->info.id7 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_7); @@ -1873,6 +1910,14 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ if (!NT_STATUS_IS_OK(r_u->status = get_user_info_7(p->mem_ctx, ctr->info.id7, &info->sid))) return r_u->status; break; + case 9: + ctr->info.id9 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_9); + if (ctr->info.id9 == NULL) + return NT_STATUS_NO_MEMORY; + + if (!NT_STATUS_IS_OK(r_u->status = get_user_info_9(p->mem_ctx, ctr->info.id9, &info->sid))) + return r_u->status; + break; case 16: ctr->info.id16 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_16); if (ctr->info.id16 == NULL) @@ -2677,8 +2722,12 @@ NTSTATUS _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_ ZERO_STRUCT(sid); - if (!secrets_fetch_domain_sid(domain_name, &sid)) { - r_u->status = NT_STATUS_NO_SUCH_DOMAIN; + if (strequal(domain_name, builtin_domain_name())) { + sid_copy(&sid, &global_sid_Builtin); + } else { + if (!secrets_fetch_domain_sid(domain_name, &sid)) { + r_u->status = NT_STATUS_NO_SUCH_DOMAIN; + } } DEBUG(2,("Returning domain sid for domain %s -> %s\n", domain_name, sid_string_static(&sid))); -- cgit From e95e6044b06fa225b016f20ab53ee4082a8f5ae0 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 23 Jan 2006 14:02:17 +0000 Subject: r13081: correct fix for the segv in nmbd caused by a double free on namerec. (This used to be commit c908dbc4b260bac72cbc6d25f4728359a6ec8259) --- source3/rpc_server/srv_srvsvc_nt.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 230f062662..b0e8111f62 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2,8 +2,8 @@ * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Nigel Williams 2001. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Nigel Williams 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1539,6 +1539,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op = False; + int max_connections = 0; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); @@ -1583,6 +1584,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(pathname)); type = q_u->info.share.info2.info_2.type; + max_connections = (q_u->info.share.info2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.max_uses; psd = NULL; break; #if 0 @@ -1658,8 +1660,8 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return WERR_ACCESS_DENIED; } - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", - lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", + lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment, max_connections ); DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command )); @@ -1951,16 +1953,17 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET TIME_OF_DAY_INFO *tod; struct tm *t; time_t unixdate = time(NULL); + /* We do this call first as if we do it *after* the gmtime call it overwrites the pointed-to values. JRA */ + uint32 zone = get_time_zone(unixdate)/60; - tod = TALLOC_P(p->mem_ctx, TIME_OF_DAY_INFO); - if (!tod) + DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); + + if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, TIME_OF_DAY_INFO)) ) return WERR_NOMEM; - ZERO_STRUCTP(tod); - r_u->tod = tod; r_u->ptr_srv_tod = 0x1; r_u->status = WERR_OK; -- cgit From 0773e797610f01729b434335614bf267618b8aac Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 23 Jan 2006 14:04:40 +0000 Subject: r13082: revert an accidentally commited patch (still in progress) (This used to be commit e43775fb3156bf29e4e412f01ad2d731aa866323) --- source3/rpc_server/srv_srvsvc_nt.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index b0e8111f62..230f062662 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2,8 +2,8 @@ * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Nigel Williams 2001. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Nigel Williams 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1539,7 +1539,6 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op = False; - int max_connections = 0; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); @@ -1584,7 +1583,6 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(pathname)); type = q_u->info.share.info2.info_2.type; - max_connections = (q_u->info.share.info2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.max_uses; psd = NULL; break; #if 0 @@ -1660,8 +1658,8 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return WERR_ACCESS_DENIED; } - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", - lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment, max_connections ); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", + lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment); DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command )); @@ -1953,17 +1951,16 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET TIME_OF_DAY_INFO *tod; struct tm *t; time_t unixdate = time(NULL); - /* We do this call first as if we do it *after* the gmtime call it overwrites the pointed-to values. JRA */ - uint32 zone = get_time_zone(unixdate)/60; - DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); - - if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, TIME_OF_DAY_INFO)) ) + tod = TALLOC_P(p->mem_ctx, TIME_OF_DAY_INFO); + if (!tod) return WERR_NOMEM; + ZERO_STRUCTP(tod); + r_u->tod = tod; r_u->ptr_srv_tod = 0x1; r_u->status = WERR_OK; -- cgit From 9ededd3151a259a37b17a0082e82ee6864c57045 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 23 Jan 2006 14:34:26 +0000 Subject: r13085: hook the max connections spin box in the share properties MMC plugin dialog to the 'max connections' smb.conf parameter. Also added the max uses int from the SHARE_INFO_2 structure to the 'modify share command' (This used to be commit af68748baae6d2e5ef850c16622d5424fd303ee7) --- source3/rpc_server/srv_srvsvc_nt.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 230f062662..b3af4b7168 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2,8 +2,8 @@ * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Nigel Williams 2001. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Nigel Williams 2001. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -109,6 +109,8 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int sn pstring remark; pstring path; pstring passwd; + int max_connections = lp_max_connections(snum); + uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff; char *net_name = lp_servicename(snum); pstrcpy(remark, lp_comment(snum)); @@ -125,7 +127,7 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int sn pstrcpy(passwd, ""); - init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd); + init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum), remark, 0, max_uses, 1, path, passwd); init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); } @@ -1539,6 +1541,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op = False; + int max_connections = 0; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); @@ -1583,6 +1586,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(pathname)); type = q_u->info.share.info2.info_2.type; + max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; psd = NULL; break; #if 0 @@ -1651,15 +1655,16 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S /* Only call modify function if something changed. */ - if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) ) + if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) + || (lp_max_connections(snum) != max_connections) ) { if (!lp_change_share_cmd() || !*lp_change_share_cmd()) { DEBUG(10,("_srv_net_share_set_info: No change share command\n")); return WERR_ACCESS_DENIED; } - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", - lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", + lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment, max_connections ); DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command )); @@ -1951,16 +1956,17 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET TIME_OF_DAY_INFO *tod; struct tm *t; time_t unixdate = time(NULL); + /* We do this call first as if we do it *after* the gmtime call it overwrites the pointed-to values. JRA */ + uint32 zone = get_time_zone(unixdate)/60; - tod = TALLOC_P(p->mem_ctx, TIME_OF_DAY_INFO); - if (!tod) + DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); + + if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, TIME_OF_DAY_INFO)) ) return WERR_NOMEM; - ZERO_STRUCTP(tod); - r_u->tod = tod; r_u->ptr_srv_tod = 0x1; r_u->status = WERR_OK; -- cgit From e5d1583c5977964366e450f4e9379399c5720217 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 23 Jan 2006 14:47:55 +0000 Subject: r13086: hooking max connections into 'add share' as well (although the WinXP UI doesn't give you a way to set the value on add (This used to be commit e6afdf1df568921c82ce85fdce9456674c3a9a75) --- source3/rpc_server/srv_srvsvc_nt.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index b3af4b7168..65e0504e67 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1711,7 +1711,8 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S } /******************************************************************* - Net share add. Call 'add_share_command "sharename" "pathname" "comment" "read only = xxx"' + Net share add. Call 'add_share_command "sharename" "pathname" + "comment" "max connections = " ********************************************************************/ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) @@ -1728,6 +1729,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op; + int max_connections = 0; DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); @@ -1756,6 +1758,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S 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)); unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name)); + max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; type = q_u->info.share.info2.info_2.type; break; case 501: @@ -1792,9 +1795,8 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S return WERR_INVALID_NAME; } - if ( strequal(share_name,"IPC$") - || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) - || strequal(share_name,"global") ) + if ( strequal(share_name,"IPC$") || strequal(share_name,"global") + || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) ) { return WERR_ACCESS_DENIED; } @@ -1818,8 +1820,13 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S string_replace(path, '"', ' '); string_replace(comment, '"', ' '); - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"", - lp_add_share_cmd(), dyn_CONFIGFILE, share_name, path, comment); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", + lp_add_share_cmd(), + dyn_CONFIGFILE, + share_name, + path, + comment, + max_connections); DEBUG(10,("_srv_net_share_add: Running [%s]\n", command )); -- cgit From 77965f6cf6997a6af7fe3cb225b3fb5ced9acd4a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 25 Jan 2006 21:29:36 +0000 Subject: r13138: old fix I forgot to commit need to access info when using the ldap backend (This used to be commit 80c0625667f28253e9b6f1ac1a5c88aa8261f9b0) --- source3/rpc_server/srv_samr_nt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 8f8c035c9c..2f9d494a26 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4495,8 +4495,11 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_SET_INFO, "_samr_set_groupinfo"))) { return r_u->status; } - - if (!get_domain_group_from_sid(group_sid, &map)) + + become_root(); + ret = get_domain_group_from_sid(group_sid, &map); + unbecome_root(); + if (!ret) return NT_STATUS_NO_SUCH_GROUP; ctr=q_u->ctr; -- cgit From 60bcd1bd77557c86a7b384add8ff9b6b48a6e32d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 25 Jan 2006 23:00:07 +0000 Subject: r13147: Raise creds_server_step fail log messages to debug level 2. These can happen in normal operation (I think - not 100% sure) and don't want to alarm admins. Jerry please add this to 3.0.21b. Jeremy. (This used to be commit 47178b1b5ad06905f345a0f6b6267701d8aefddb) --- source3/rpc_server/srv_netlog_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index d0d47be9f2..643921f596 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -470,7 +470,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * /* Step the creds chain forward. */ if (!creds_server_step(p->dc, &q_u->clnt_id.cred, &cred_out)) { - DEBUG(0,("_net_srv_pwset: creds_server_step failed. Rejecting auth " + DEBUG(2,("_net_srv_pwset: creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", p->dc->remote_machine, p->dc->mach_acct )); return NT_STATUS_ACCESS_DENIED; @@ -573,7 +573,7 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF /* checks and updates credentials. creates reply credentials */ if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { - DEBUG(0,("_net_sam_logoff: creds_server_step failed. Rejecting auth " + DEBUG(2,("_net_sam_logoff: creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", p->dc->remote_machine, p->dc->mach_acct )); return NT_STATUS_ACCESS_DENIED; @@ -662,7 +662,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * /* checks and updates credentials. creates reply credentials */ if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { - DEBUG(0,("_net_sam_logon: creds_server_step failed. Rejecting auth " + DEBUG(2,("_net_sam_logon: creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", p->dc->remote_machine, p->dc->mach_acct )); return NT_STATUS_ACCESS_DENIED; -- cgit From f1022af07bbc72412d8fca7945a2c276fba88a7e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 27 Jan 2006 02:35:08 +0000 Subject: r13176: Fix show-stopper bug for 3.0.21b where 4 leg NTLMSSP SPNEGO auth was not generating the correct auth header on the 4th packet. This may fix a lot of Windows client complaints and is essential for release. Jeremy. (This used to be commit 48dd8c732b890e3fd3d8e80ace765487601cfb26) --- source3/rpc_server/srv_pipe.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 8084e7673a..ecf79d0c1f 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1188,12 +1188,17 @@ static BOOL pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_ static BOOL pipe_spnego_auth_bind_continue(pipes_struct *p, prs_struct *rpc_in_p, RPC_HDR_AUTH *pauth_info, prs_struct *pout_auth) { - DATA_BLOB spnego_blob, auth_blob, auth_reply; + RPC_HDR_AUTH auth_info; + DATA_BLOB spnego_blob; + DATA_BLOB auth_blob; + DATA_BLOB auth_reply; + DATA_BLOB response; AUTH_NTLMSSP_STATE *a = p->auth.a_u.auth_ntlmssp_state; ZERO_STRUCT(spnego_blob); ZERO_STRUCT(auth_blob); ZERO_STRUCT(auth_reply); + ZERO_STRUCT(response); if (p->auth.auth_type != PIPE_AUTH_TYPE_SPNEGO_NTLMSSP || !a) { DEBUG(0,("pipe_spnego_auth_bind_continue: not in NTLMSSP auth state.\n")); @@ -1230,7 +1235,24 @@ static BOOL pipe_spnego_auth_bind_continue(pipes_struct *p, prs_struct *rpc_in_p data_blob_free(&spnego_blob); data_blob_free(&auth_blob); + + /* Generate the spnego "accept completed" blob - no incoming data. */ + response = spnego_gen_auth_response(&auth_reply, NT_STATUS_OK, OID_NTLMSSP); + + /* Copy the blob into the pout_auth parse struct */ + init_rpc_hdr_auth(&auth_info, RPC_SPNEGO_AUTH_TYPE, pauth_info->auth_level, RPC_HDR_AUTH_LEN, 1); + if(!smb_io_rpc_hdr_auth("", &auth_info, pout_auth, 0)) { + DEBUG(0,("pipe_spnego_auth_bind_continue: marshalling of RPC_HDR_AUTH failed.\n")); + goto err; + } + + if (!prs_copy_data_in(pout_auth, (char *)response.data, response.length)) { + DEBUG(0,("pipe_spnego_auth_bind_continue: marshalling of data blob failed.\n")); + goto err; + } + data_blob_free(&auth_reply); + data_blob_free(&response); p->pipe_bound = True; @@ -1241,6 +1263,7 @@ static BOOL pipe_spnego_auth_bind_continue(pipes_struct *p, prs_struct *rpc_in_p data_blob_free(&spnego_blob); data_blob_free(&auth_blob); data_blob_free(&auth_reply); + data_blob_free(&response); free_pipe_ntlmssp_auth_data(&p->auth); p->auth.a_u.auth_ntlmssp_state = NULL; -- cgit From d14af63e6ab600eb3ac705f2f425c860e927553a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 2 Feb 2006 20:44:50 +0000 Subject: r13293: Rather a big patch I'm afraid, but this should fix bug #3347 by saving the UNIX token used to set a delete on close flag, and using it when doing the delete. libsmbsharemodes.so still needs updating to cope with this change. Samba4 torture tests to follow. Jeremy. (This used to be commit 23f16cbc2e8cde97c486831e26bcafd4ab4a9654) --- source3/rpc_server/srv_dfs_nt.c | 4 ++-- source3/rpc_server/srv_lsa_nt.c | 9 ++++----- source3/rpc_server/srv_pipe.c | 15 ++++++++------- source3/rpc_server/srv_pipe_hnd.c | 6 +++--- source3/rpc_server/srv_spoolss_nt.c | 12 ++++++------ source3/rpc_server/srv_srvsvc_nt.c | 18 +++++++++--------- 6 files changed, 32 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index f61348ee05..63e4d4e9b7 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -52,7 +52,7 @@ WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) get_current_user(&user,p); - if (user.uid != 0) { + if (user.ut.uid != 0) { DEBUG(10,("_dfs_add: uid != 0. Access denied.\n")); return WERR_ACCESS_DENIED; } @@ -115,7 +115,7 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, get_current_user(&user,p); - if (user.uid != 0) { + if (user.ut.uid != 0) { DEBUG(10,("_dfs_remove: uid != 0. Access denied.\n")); return WERR_ACCESS_DENIED; } diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 6cd673550e..f48f3e863a 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1198,7 +1198,7 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u account_pol.tdb was already opened as root, this is all we have */ get_current_user( &user, p ); - if ( user.uid != sec_initial_uid() + if ( user.ut.uid != sec_initial_uid() && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { return NT_STATUS_ACCESS_DENIED; @@ -1239,7 +1239,7 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP account_pol.tdb was already opened as root, this is all we have */ get_current_user( &user, p ); - if ( user.uid != sec_initial_uid() + if ( user.ut.uid != sec_initial_uid() && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { return NT_STATUS_ACCESS_DENIED; @@ -1401,7 +1401,7 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R account_pol.tdb was already opened as root, this is all we have */ get_current_user( &user, p ); - if ( user.uid != sec_initial_uid() + if ( user.ut.uid != sec_initial_uid() && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { return NT_STATUS_ACCESS_DENIED; @@ -1459,7 +1459,7 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, account_pol.tdb was already opened as root, this is all we have */ get_current_user( &user, p ); - if ( user.uid != sec_initial_uid() + if ( user.ut.uid != sec_initial_uid() && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { return NT_STATUS_ACCESS_DENIED; @@ -1573,4 +1573,3 @@ NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, L return NT_STATUS_OK; } - diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index ecf79d0c1f..381adbe635 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -617,8 +617,8 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) /* Set up for non-authenticated user. */ delete_nt_token(&p->pipe_user.nt_user_token); - p->pipe_user.ngroups = 0; - SAFE_FREE( p->pipe_user.groups); + p->pipe_user.ut.ngroups = 0; + SAFE_FREE( p->pipe_user.ut.groups); status = auth_ntlmssp_update(a, *p_resp_blob, &reply); @@ -641,8 +641,8 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) * Store the UNIX credential data (uid/gid pair) in the pipe structure. */ - p->pipe_user.uid = a->server_info->uid; - p->pipe_user.gid = a->server_info->gid; + p->pipe_user.ut.uid = a->server_info->uid; + p->pipe_user.ut.gid = a->server_info->gid; /* * Copy the session key from the ntlmssp state. @@ -654,9 +654,10 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) return False; } - p->pipe_user.ngroups = a->server_info->n_groups; - if (p->pipe_user.ngroups) { - if (!(p->pipe_user.groups = memdup(a->server_info->groups, sizeof(gid_t) * p->pipe_user.ngroups))) { + p->pipe_user.ut.ngroups = a->server_info->n_groups; + if (p->pipe_user.ut.ngroups) { + if (!(p->pipe_user.ut.groups = memdup(a->server_info->groups, + sizeof(gid_t) * p->pipe_user.ut.ngroups))) { DEBUG(0,("failed to memdup group list to p->pipe_user.groups\n")); return False; } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 5fb84115cc..37d3ef64c0 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -343,8 +343,8 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, ZERO_STRUCT(p->pipe_user); - p->pipe_user.uid = (uid_t)-1; - p->pipe_user.gid = (gid_t)-1; + p->pipe_user.ut.uid = (uid_t)-1; + p->pipe_user.ut.gid = (gid_t)-1; /* Store the session key and NT_TOKEN */ if (vuser) { @@ -1224,7 +1224,7 @@ static BOOL close_internal_rpc_pipe_hnd(void *np_conn) delete_nt_token(&p->pipe_user.nt_user_token); data_blob_free(&p->session_key); - SAFE_FREE(p->pipe_user.groups); + SAFE_FREE(p->pipe_user.ut.groups); DLIST_REMOVE(InternalPipes, p); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 334158bbbd..a22d6db266 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1620,9 +1620,9 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege, and not a printer admin, then fail */ - if ( user.uid != 0 + if ( user.ut.uid != 0 && !user_has_privileges( user.nt_user_token, &se_printop ) - && !user_in_list(uidtoname(user.uid), lp_printer_admin(snum), user.groups, user.ngroups) ) + && !user_in_list(uidtoname(user.ut.uid), lp_printer_admin(snum), user.ut.groups, user.ut.ngroups) ) { close_printer_handle(p, handle); return WERR_ACCESS_DENIED; @@ -1676,7 +1676,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, return WERR_ACCESS_DENIED; } - if (!user_ok(uidtoname(user.uid), snum, user.groups, user.ngroups) || !print_access_check(&user, snum, printer_default->access_required)) { + if (!user_ok(uidtoname(user.ut.uid), snum, user.ut.groups, user.ut.ngroups) || !print_access_check(&user, snum, printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); close_printer_handle(p, handle); return WERR_ACCESS_DENIED; @@ -1869,7 +1869,7 @@ static WERROR _spoolss_enddocprinter_internal(pipes_struct *p, POLICY_HND *handl return WERR_BADFID; Printer->document_started=False; - print_job_end(snum, Printer->jobid,True); + print_job_end(snum, Printer->jobid,NORMAL_CLOSE); /* error codes unhandled so far ... */ return WERR_OK; @@ -7554,12 +7554,12 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, case 3: fstrcpy(driver_name, driver.info_3->name ? driver.info_3->name : ""); sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", - driver_name, get_drv_ver_to_os(driver.info_3->cversion),uidtoname(user.uid)); + driver_name, get_drv_ver_to_os(driver.info_3->cversion),uidtoname(user.ut.uid)); break; case 6: fstrcpy(driver_name, driver.info_6->name ? driver.info_6->name : ""); sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", - driver_name, get_drv_ver_to_os(driver.info_6->version),uidtoname(user.uid)); + driver_name, get_drv_ver_to_os(driver.info_6->version),uidtoname(user.ut.uid)); break; } /* END_ADMIN_LOG */ diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 65e0504e67..8150a8bf69 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1401,7 +1401,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES /* fail out now if you are not root or not a domain admin */ - if ((user.uid != sec_initial_uid()) && + if ((user.ut.uid != sec_initial_uid()) && ( ! nt_token_check_domain_rid(p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS))) { goto done; @@ -1412,7 +1412,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES if ((strequal(session_list[snum].username, username) || username[0] == '\0' ) && strequal(session_list[snum].remote_machine, machine)) { - if (user.uid != sec_initial_uid()) { + if (user.ut.uid != sec_initial_uid()) { not_root = True; become_root(); } @@ -1572,7 +1572,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S /* fail out now if you are not root and not a disk op */ - if ( user.uid != sec_initial_uid() && !is_disk_op ) + if ( user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; switch (q_u->info_level) { @@ -1739,7 +1739,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); - if (user.uid != sec_initial_uid() && !is_disk_op ) + if (user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; if (!lp_add_share_cmd() || !*lp_add_share_cmd()) { @@ -1906,7 +1906,7 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); - if (user.uid != sec_initial_uid() && !is_disk_op ) + if (user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) { @@ -2098,7 +2098,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC psd->dacl->revision = (uint16) NT4_ACL_REVISION; - close_file(fsp, True); + close_file(fsp, NORMAL_CLOSE); unbecome_user(); close_cnum(conn, user.vuid); return r_u->status; @@ -2106,7 +2106,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC error_exit: if(fsp) { - close_file(fsp, True); + close_file(fsp, NORMAL_CLOSE); } if (became_user) @@ -2207,7 +2207,7 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ goto error_exit; } - close_file(fsp, True); + close_file(fsp, NORMAL_CLOSE); unbecome_user(); close_cnum(conn, user.vuid); return r_u->status; @@ -2215,7 +2215,7 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ error_exit: if(fsp) { - close_file(fsp, True); + close_file(fsp, NORMAL_CLOSE); } if (became_user) { -- cgit From 0af1500fc0bafe61019f1b2ab1d9e1d369221240 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 3 Feb 2006 22:19:41 +0000 Subject: r13316: Let the carnage begin.... Sync with trunk as off r13315 (This used to be commit 17e63ac4ed8325c0d44fe62b2442449f3298559f) --- source3/rpc_server/srv_dfs.c | 587 +++++++++++++++++++++++++++++++----- source3/rpc_server/srv_dfs_nt.c | 406 ++++++++++++++++--------- source3/rpc_server/srv_lsa_nt.c | 256 ++++++++-------- source3/rpc_server/srv_netlog_nt.c | 96 +++--- source3/rpc_server/srv_pipe.c | 5 +- source3/rpc_server/srv_pipe_hnd.c | 5 +- source3/rpc_server/srv_samr_nt.c | 279 +++++++++-------- source3/rpc_server/srv_spoolss_nt.c | 20 +- source3/rpc_server/srv_srvsvc_nt.c | 208 +------------ 9 files changed, 1129 insertions(+), 733 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c index 42be7c5a35..44a9c06a3c 100644 --- a/source3/rpc_server/srv_dfs.c +++ b/source3/rpc_server/srv_dfs.c @@ -1,177 +1,602 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines for Dfs - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Shirish Kalele 2000, - * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Jim McDonough 2003. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +/* + * Unix SMB/CIFS implementation. + * server auto-generated by pidl. DO NOT MODIFY! */ -/* This is the interface to the dfs pipe. */ - #include "includes.h" #include "nterr.h" #undef DBGC_CLASS -#define DBGC_CLASS DBGC_MSDFS +#define DBGC_CLASS DBGC_RPC -/********************************************************************** - api_dfs_exist - **********************************************************************/ +/****************************************************************** + api_dfs_GetManagerVersion + *****************************************************************/ -static BOOL api_dfs_exist(pipes_struct *p) +static BOOL api_dfs_GetManagerVersion(pipes_struct *p) { - DFS_Q_DFS_EXIST q_u; - DFS_R_DFS_EXIST r_u; + NETDFS_Q_DFS_GETMANAGERVERSION q_u; + NETDFS_R_DFS_GETMANAGERVERSION r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_GetManagerVersion("", &q_u, data, 0)) + return False; + + _dfs_GetManagerVersion(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_GetManagerVersion("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_Add + *****************************************************************/ - if(!dfs_io_q_dfs_exist("", &q_u, data, 0)) +static BOOL api_dfs_Add(pipes_struct *p) +{ + NETDFS_Q_DFS_ADD q_u; + NETDFS_R_DFS_ADD r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_Add("", &q_u, data, 0)) return False; - r_u.status = _dfs_exist(p, &q_u, &r_u); + r_u.status = _dfs_Add(p, &q_u, &r_u); - if (!dfs_io_r_dfs_exist("", &r_u, rdata, 0)) + if (!netdfs_io_r_dfs_Add("", &r_u, rdata, 0)) return False; + + return True; +} +/****************************************************************** + api_dfs_Remove + *****************************************************************/ +static BOOL api_dfs_Remove(pipes_struct *p) +{ + NETDFS_Q_DFS_REMOVE q_u; + NETDFS_R_DFS_REMOVE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_Remove("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_Remove(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_Remove("", &r_u, rdata, 0)) + return False; + return True; } +/****************************************************************** + api_dfs_SetInfo + *****************************************************************/ -/***************************************************************** - api_dfs_add +static BOOL api_dfs_SetInfo(pipes_struct *p) +{ + NETDFS_Q_DFS_SETINFO q_u; + NETDFS_R_DFS_SETINFO r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_SetInfo("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_SetInfo(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_SetInfo("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_GetInfo *****************************************************************/ -static BOOL api_dfs_add(pipes_struct *p) +static BOOL api_dfs_GetInfo(pipes_struct *p) { - DFS_Q_DFS_ADD q_u; - DFS_R_DFS_ADD r_u; + NETDFS_Q_DFS_GETINFO q_u; + NETDFS_R_DFS_GETINFO r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_GetInfo("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_GetInfo(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_GetInfo("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_Enum + *****************************************************************/ +static BOOL api_dfs_Enum(pipes_struct *p) +{ + NETDFS_Q_DFS_ENUM q_u; + NETDFS_R_DFS_ENUM r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!dfs_io_q_dfs_add("", &q_u, data, 0)) + if (!netdfs_io_q_dfs_Enum("", &q_u, data, 0)) return False; - r_u.status = _dfs_add(p, &q_u, &r_u); + r_u.status = _dfs_Enum(p, &q_u, &r_u); - if (!dfs_io_r_dfs_add("", &r_u, rdata, 0)) + if (!netdfs_io_r_dfs_Enum("", &r_u, rdata, 0)) return False; return True; } +/****************************************************************** + api_dfs_Rename + *****************************************************************/ -/***************************************************************** - api_dfs_remove +static BOOL api_dfs_Rename(pipes_struct *p) +{ + NETDFS_Q_DFS_RENAME q_u; + NETDFS_R_DFS_RENAME r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_Rename("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_Rename(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_Rename("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_Move *****************************************************************/ -static BOOL api_dfs_remove(pipes_struct *p) +static BOOL api_dfs_Move(pipes_struct *p) { - DFS_Q_DFS_REMOVE q_u; - DFS_R_DFS_REMOVE r_u; + NETDFS_Q_DFS_MOVE q_u; + NETDFS_R_DFS_MOVE r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!dfs_io_q_dfs_remove("", &q_u, data, 0)) + if (!netdfs_io_q_dfs_Move("", &q_u, data, 0)) return False; - r_u.status = _dfs_remove(p, &q_u, &r_u); + r_u.status = _dfs_Move(p, &q_u, &r_u); - if (!dfs_io_r_dfs_remove("", &r_u, rdata, 0)) + if (!netdfs_io_r_dfs_Move("", &r_u, rdata, 0)) return False; return True; } +/****************************************************************** + api_dfs_ManagerGetConfigInfo + *****************************************************************/ -/******************************************************************* - api_dfs_get_info - *******************************************************************/ +static BOOL api_dfs_ManagerGetConfigInfo(pipes_struct *p) +{ + NETDFS_Q_DFS_MANAGERGETCONFIGINFO q_u; + NETDFS_R_DFS_MANAGERGETCONFIGINFO r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_ManagerGetConfigInfo("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_ManagerGetConfigInfo(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_ManagerGetConfigInfo("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_ManagerSendSiteInfo + *****************************************************************/ -static BOOL api_dfs_get_info(pipes_struct *p) +static BOOL api_dfs_ManagerSendSiteInfo(pipes_struct *p) { - DFS_Q_DFS_GET_INFO q_u; - DFS_R_DFS_GET_INFO r_u; + NETDFS_Q_DFS_MANAGERSENDSITEINFO q_u; + NETDFS_R_DFS_MANAGERSENDSITEINFO r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_ManagerSendSiteInfo("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_ManagerSendSiteInfo(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_ManagerSendSiteInfo("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_AddFtRoot + *****************************************************************/ +static BOOL api_dfs_AddFtRoot(pipes_struct *p) +{ + NETDFS_Q_DFS_ADDFTROOT q_u; + NETDFS_R_DFS_ADDFTROOT r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!dfs_io_q_dfs_get_info("", &q_u, data, 0)) + if (!netdfs_io_q_dfs_AddFtRoot("", &q_u, data, 0)) return False; - r_u.status = _dfs_get_info(p, &q_u, &r_u); + r_u.status = _dfs_AddFtRoot(p, &q_u, &r_u); - if(!dfs_io_r_dfs_get_info("", &r_u, rdata, 0)) + if (!netdfs_io_r_dfs_AddFtRoot("", &r_u, rdata, 0)) return False; + + return True; +} +/****************************************************************** + api_dfs_RemoveFtRoot + *****************************************************************/ +static BOOL api_dfs_RemoveFtRoot(pipes_struct *p) +{ + NETDFS_Q_DFS_REMOVEFTROOT q_u; + NETDFS_R_DFS_REMOVEFTROOT r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_RemoveFtRoot("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_RemoveFtRoot(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_RemoveFtRoot("", &r_u, rdata, 0)) + return False; + return True; } +/****************************************************************** + api_dfs_AddStdRoot + *****************************************************************/ -/******************************************************************* - api_dfs_enum - *******************************************************************/ +static BOOL api_dfs_AddStdRoot(pipes_struct *p) +{ + NETDFS_Q_DFS_ADDSTDROOT q_u; + NETDFS_R_DFS_ADDSTDROOT r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_AddStdRoot("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_AddStdRoot(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_AddStdRoot("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_RemoveStdRoot + *****************************************************************/ -static BOOL api_dfs_enum(pipes_struct *p) +static BOOL api_dfs_RemoveStdRoot(pipes_struct *p) { - DFS_Q_DFS_ENUM q_u; - DFS_R_DFS_ENUM r_u; + NETDFS_Q_DFS_REMOVESTDROOT q_u; + NETDFS_R_DFS_REMOVESTDROOT r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_RemoveStdRoot("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_RemoveStdRoot(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_RemoveStdRoot("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_ManagerInitialize + *****************************************************************/ +static BOOL api_dfs_ManagerInitialize(pipes_struct *p) +{ + NETDFS_Q_DFS_MANAGERINITIALIZE q_u; + NETDFS_R_DFS_MANAGERINITIALIZE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_ManagerInitialize("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_ManagerInitialize(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_ManagerInitialize("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_AddStdRootForced + *****************************************************************/ - if(!dfs_io_q_dfs_enum("", &q_u, data, 0)) +static BOOL api_dfs_AddStdRootForced(pipes_struct *p) +{ + NETDFS_Q_DFS_ADDSTDROOTFORCED q_u; + NETDFS_R_DFS_ADDSTDROOTFORCED r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_AddStdRootForced("", &q_u, data, 0)) return False; - r_u.status = _dfs_enum(p, &q_u, &r_u); + r_u.status = _dfs_AddStdRootForced(p, &q_u, &r_u); - if(!dfs_io_r_dfs_enum("", &r_u, rdata, 0)) + if (!netdfs_io_r_dfs_AddStdRootForced("", &r_u, rdata, 0)) return False; + + return True; +} +/****************************************************************** + api_dfs_GetDcAddress + *****************************************************************/ +static BOOL api_dfs_GetDcAddress(pipes_struct *p) +{ + NETDFS_Q_DFS_GETDCADDRESS q_u; + NETDFS_R_DFS_GETDCADDRESS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_GetDcAddress("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_GetDcAddress(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_GetDcAddress("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_SetDcAddress + *****************************************************************/ + +static BOOL api_dfs_SetDcAddress(pipes_struct *p) +{ + NETDFS_Q_DFS_SETDCADDRESS q_u; + NETDFS_R_DFS_SETDCADDRESS r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_SetDcAddress("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_SetDcAddress(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_SetDcAddress("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_FlushFtTable + *****************************************************************/ + +static BOOL api_dfs_FlushFtTable(pipes_struct *p) +{ + NETDFS_Q_DFS_FLUSHFTTABLE q_u; + NETDFS_R_DFS_FLUSHFTTABLE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_FlushFtTable("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_FlushFtTable(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_FlushFtTable("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_Add2 + *****************************************************************/ + +static BOOL api_dfs_Add2(pipes_struct *p) +{ + NETDFS_Q_DFS_ADD2 q_u; + NETDFS_R_DFS_ADD2 r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_Add2("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_Add2(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_Add2("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_Remove2 + *****************************************************************/ + +static BOOL api_dfs_Remove2(pipes_struct *p) +{ + NETDFS_Q_DFS_REMOVE2 q_u; + NETDFS_R_DFS_REMOVE2 r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_Remove2("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_Remove2(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_Remove2("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_EnumEx + *****************************************************************/ + +static BOOL api_dfs_EnumEx(pipes_struct *p) +{ + NETDFS_Q_DFS_ENUMEX q_u; + NETDFS_R_DFS_ENUMEX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_EnumEx("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_EnumEx(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_EnumEx("", &r_u, rdata, 0)) + return False; + + return True; +} +/****************************************************************** + api_dfs_SetInfo2 + *****************************************************************/ + +static BOOL api_dfs_SetInfo2(pipes_struct *p) +{ + NETDFS_Q_DFS_SETINFO2 q_u; + NETDFS_R_DFS_SETINFO2 r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!netdfs_io_q_dfs_SetInfo2("", &q_u, data, 0)) + return False; + + r_u.status = _dfs_SetInfo2(p, &q_u, &r_u); + + if (!netdfs_io_r_dfs_SetInfo2("", &r_u, rdata, 0)) + return False; + return True; } -/******************************************************************* -\pipe\netdfs commands -********************************************************************/ -static struct api_struct api_netdfs_cmds[] = +/* Tables */ +static struct api_struct api_netdfs_cmds[] = { - {"DFS_EXIST", DFS_EXIST, api_dfs_exist }, - {"DFS_ADD", DFS_ADD, api_dfs_add }, - {"DFS_REMOVE", DFS_REMOVE, api_dfs_remove }, - {"DFS_GET_INFO", DFS_GET_INFO, api_dfs_get_info }, - {"DFS_ENUM", DFS_ENUM, api_dfs_enum } + {"DFS_GETMANAGERVERSION", DFS_GETMANAGERVERSION, api_dfs_GetManagerVersion}, + {"DFS_ADD", DFS_ADD, api_dfs_Add}, + {"DFS_REMOVE", DFS_REMOVE, api_dfs_Remove}, + {"DFS_SETINFO", DFS_SETINFO, api_dfs_SetInfo}, + {"DFS_GETINFO", DFS_GETINFO, api_dfs_GetInfo}, + {"DFS_ENUM", DFS_ENUM, api_dfs_Enum}, + {"DFS_RENAME", DFS_RENAME, api_dfs_Rename}, + {"DFS_MOVE", DFS_MOVE, api_dfs_Move}, + {"DFS_MANAGERGETCONFIGINFO", DFS_MANAGERGETCONFIGINFO, api_dfs_ManagerGetConfigInfo}, + {"DFS_MANAGERSENDSITEINFO", DFS_MANAGERSENDSITEINFO, api_dfs_ManagerSendSiteInfo}, + {"DFS_ADDFTROOT", DFS_ADDFTROOT, api_dfs_AddFtRoot}, + {"DFS_REMOVEFTROOT", DFS_REMOVEFTROOT, api_dfs_RemoveFtRoot}, + {"DFS_ADDSTDROOT", DFS_ADDSTDROOT, api_dfs_AddStdRoot}, + {"DFS_REMOVESTDROOT", DFS_REMOVESTDROOT, api_dfs_RemoveStdRoot}, + {"DFS_MANAGERINITIALIZE", DFS_MANAGERINITIALIZE, api_dfs_ManagerInitialize}, + {"DFS_ADDSTDROOTFORCED", DFS_ADDSTDROOTFORCED, api_dfs_AddStdRootForced}, + {"DFS_GETDCADDRESS", DFS_GETDCADDRESS, api_dfs_GetDcAddress}, + {"DFS_SETDCADDRESS", DFS_SETDCADDRESS, api_dfs_SetDcAddress}, + {"DFS_FLUSHFTTABLE", DFS_FLUSHFTTABLE, api_dfs_FlushFtTable}, + {"DFS_ADD2", DFS_ADD2, api_dfs_Add2}, + {"DFS_REMOVE2", DFS_REMOVE2, api_dfs_Remove2}, + {"DFS_ENUMEX", DFS_ENUMEX, api_dfs_EnumEx}, + {"DFS_SETINFO2", DFS_SETINFO2, api_dfs_SetInfo2}, }; -void netdfs_get_pipe_fns( struct api_struct **fns, int *n_fns ) +void netdfs_get_pipe_fns(struct api_struct **fns, int *n_fns) { *fns = api_netdfs_cmds; *n_fns = sizeof(api_netdfs_cmds) / sizeof(struct api_struct); } -NTSTATUS rpc_dfs_init(void) +NTSTATUS rpc_netdfs_init(void) { - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "netdfs", "netdfs", api_netdfs_cmds, - sizeof(api_netdfs_cmds) / sizeof(struct api_struct)); + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "netdfs", "netdfs", api_netdfs_cmds, sizeof(api_netdfs_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 63e4d4e9b7..f04d8c37c3 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -1,10 +1,9 @@ /* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines for Dfs - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Shirish Kalele 2000. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Shirish Kalele 2000. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Jelmer Vernooij 2005. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +23,6 @@ /* This is the implementation of the dfs pipe. */ #include "includes.h" -#include "nterr.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_MSDFS @@ -32,7 +30,7 @@ /* This function does not return a WERROR or NTSTATUS code but rather 1 if dfs exists, or 0 otherwise. */ -uint32 _dfs_exist(pipes_struct *p, DFS_Q_DFS_EXIST *q_u, DFS_R_DFS_EXIST *r_u) +uint32 _dfs_GetManagerVersion(pipes_struct *p, NETDFS_Q_DFS_GETMANAGERVERSION *q_u, NETDFS_R_DFS_GETMANAGERVERSION *r_u) { if(lp_host_msdfs()) return 1; @@ -40,7 +38,7 @@ uint32 _dfs_exist(pipes_struct *p, DFS_Q_DFS_EXIST *q_u, DFS_R_DFS_EXIST *r_u) return 0; } -WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) +WERROR _dfs_Add(pipes_struct *p, NETDFS_Q_DFS_ADD* q_u, NETDFS_R_DFS_ADD *r_u) { struct current_user user; struct junction_map jn; @@ -57,9 +55,9 @@ WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) return WERR_ACCESS_DENIED; } - unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1); - unistr2_to_ascii(servername, &q_u->ServerName, sizeof(servername)-1); - unistr2_to_ascii(sharename, &q_u->ShareName, sizeof(sharename)-1); + unistr2_to_ascii(dfspath, &q_u->path, sizeof(dfspath)-1); + unistr2_to_ascii(servername, &q_u->server, sizeof(servername)-1); + unistr2_to_ascii(sharename, &q_u->share, sizeof(sharename)-1); DEBUG(5,("init_reply_dfs_add: Request to add %s -> %s\\%s.\n", dfspath, servername, sharename)); @@ -103,8 +101,8 @@ WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u) return WERR_OK; } -WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, - DFS_R_DFS_REMOVE *r_u) +WERROR _dfs_Remove(pipes_struct *p, NETDFS_Q_DFS_REMOVE *q_u, + NETDFS_R_DFS_REMOVE *r_u) { struct current_user user; struct junction_map jn; @@ -120,16 +118,16 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, return WERR_ACCESS_DENIED; } - unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1); - if(q_u->ptr_ServerName) { - unistr2_to_ascii(servername, &q_u->ServerName, sizeof(servername)-1); + unistr2_to_ascii(dfspath, &q_u->path, sizeof(dfspath)-1); + if(q_u->ptr0_server) { + unistr2_to_ascii(servername, &q_u->server, sizeof(servername)-1); } - if(q_u->ptr_ShareName) { - unistr2_to_ascii(sharename, &q_u->ShareName, sizeof(sharename)-1); + if(q_u->ptr0_share) { + unistr2_to_ascii(sharename, &q_u->share, sizeof(sharename)-1); } - if(q_u->ptr_ServerName && q_u->ptr_ShareName) { + if(q_u->ptr0_server && q_u->ptr0_share) { pstrcpy(altpath, servername); pstrcat(altpath, "\\"); pstrcat(altpath, sharename); @@ -144,7 +142,7 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, } /* if no server-share pair given, remove the msdfs link completely */ - if(!q_u->ptr_ServerName && !q_u->ptr_ShareName) { + if(!q_u->ptr0_server && !q_u->ptr0_share) { if(!remove_msdfs_link(&jn)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; @@ -189,167 +187,164 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u, return WERR_OK; } -static BOOL init_reply_dfs_info_1(struct junction_map* j, DFS_INFO_1* dfs1, int num_j) +static BOOL init_reply_dfs_info_1(struct junction_map* j, NETDFS_DFS_INFO1* dfs1) { - int i=0; - for(i=0;iptr0_path = 1; + slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), + j->service_name, j->volume_name); + DEBUG(5,("init_reply_dfs_info_1: initing entrypath: %s\n",str)); + init_unistr2(&dfs1->path,str,UNI_STR_TERMINATE); return True; } -static BOOL init_reply_dfs_info_2(struct junction_map* j, DFS_INFO_2* dfs2, int num_j) +static BOOL init_reply_dfs_info_2(struct junction_map* j, NETDFS_DFS_INFO2* dfs2) { - int i=0; - for(i=0;iptr0_path = 1; + slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), + j->service_name, j->volume_name); + init_unistr2(&dfs2->path, str, UNI_STR_TERMINATE); + dfs2->ptr0_comment = 0; + dfs2->state = 1; /* set up state of dfs junction as OK */ + dfs2->num_stores = j->referral_count; return True; } -static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_INFO_3* dfs3, int num_j) +static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, NETDFS_DFS_INFO3* dfs3) { - int i=0,ii=0; - for(i=0;ialternate_path); - trim_char(path,'\\','\0'); - p = strrchr_m(path,'\\'); - if(p==NULL) { - DEBUG(4,("init_reply_dfs_info_3: invalid path: no \\ found in %s\n",path)); - continue; - } - *p = '\0'; - DEBUG(5,("storage %d: %s.%s\n",ii,path,p+1)); - stor->state = 2; /* set all storages as ONLINE */ - init_unistr2(&stor->servername, path, UNI_STR_TERMINATE); - init_unistr2(&stor->sharename, p+1, UNI_STR_TERMINATE); - stor->ptr_servername = stor->ptr_sharename = 1; + int ii; + pstring str; + dfs3->ptr0_path = 1; + if (j->volume_name[0] == '\0') + slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s", + global_myname(), j->service_name); + else + slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), + j->service_name, j->volume_name); + + init_unistr2(&dfs3->path, str, UNI_STR_TERMINATE); + dfs3->ptr0_comment = 1; + init_unistr2(&dfs3->comment, "", UNI_STR_TERMINATE); + dfs3->state = 1; + dfs3->num_stores = dfs3->size_stores = j->referral_count; + dfs3->ptr0_stores = 1; + + /* also enumerate the stores */ + dfs3->stores = TALLOC_ARRAY(ctx, NETDFS_DFS_STORAGEINFO, j->referral_count); + if (!dfs3->stores) + return False; + + memset(dfs3->stores, '\0', j->referral_count * sizeof(NETDFS_DFS_STORAGEINFO)); + + for(ii=0;iireferral_count;ii++) { + char* p; + pstring path; + NETDFS_DFS_STORAGEINFO* stor = &(dfs3->stores[ii]); + struct referral* ref = &(j->referral_list[ii]); + + pstrcpy(path, ref->alternate_path); + trim_char(path,'\\','\0'); + p = strrchr_m(path,'\\'); + if(p==NULL) { + DEBUG(4,("init_reply_dfs_info_3: invalid path: no \\ found in %s\n",path)); + continue; } + *p = '\0'; + DEBUG(5,("storage %d: %s.%s\n",ii,path,p+1)); + stor->state = 2; /* set all stores as ONLINE */ + init_unistr2(&stor->server, path, UNI_STR_TERMINATE); + init_unistr2(&stor->share, p+1, UNI_STR_TERMINATE); + stor->ptr0_server = stor->ptr0_share = 1; } return True; } -static WERROR init_reply_dfs_ctr(TALLOC_CTX *ctx, uint32 level, - DFS_INFO_CTR* ctr, struct junction_map* jn, - int num_jn) +WERROR _dfs_Enum(pipes_struct *p, NETDFS_Q_DFS_ENUM *q_u, NETDFS_R_DFS_ENUM *r_u) { - /* do the levels */ - switch(level) { + uint32 level = q_u->level; + struct junction_map jn[MAX_MSDFS_JUNCTIONS]; + int num_jn = 0; + int i; + + num_jn = enum_msdfs_links(p->mem_ctx, jn, ARRAY_SIZE(jn)); + vfs_ChDir(p->conn,p->conn->connectpath); + + DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", num_jn, level)); + + r_u->ptr0_info = q_u->ptr0_info; + r_u->ptr0_total = q_u->ptr0_total; + r_u->total = num_jn; + + r_u->info = q_u->info; + + /* Create the return array */ + switch (level) { case 1: - { - DFS_INFO_1* dfs1; - dfs1 = TALLOC_ARRAY(ctx, DFS_INFO_1, num_jn); - if (!dfs1) + if ((r_u->info.e.u.info1.s = TALLOC_ARRAY(p->mem_ctx, NETDFS_DFS_INFO1, num_jn)) == NULL) { return WERR_NOMEM; - init_reply_dfs_info_1(jn, dfs1, num_jn); - ctr->dfs.info1 = dfs1; - break; } + r_u->info.e.u.info1.count = num_jn; + r_u->info.e.u.info1.ptr0_s = 1; + r_u->info.e.u.info1.size_s = num_jn; + break; case 2: - { - DFS_INFO_2* dfs2; - dfs2 = TALLOC_ARRAY(ctx, DFS_INFO_2, num_jn); - if (!dfs2) + if ((r_u->info.e.u.info2.s = TALLOC_ARRAY(p->mem_ctx, NETDFS_DFS_INFO2, num_jn)) == NULL) { return WERR_NOMEM; - init_reply_dfs_info_2(jn, dfs2, num_jn); - ctr->dfs.info2 = dfs2; - break; } + r_u->info.e.u.info2.count = num_jn; + r_u->info.e.u.info2.ptr0_s = 1; + r_u->info.e.u.info2.size_s = num_jn; + break; case 3: - { - DFS_INFO_3* dfs3; - dfs3 = TALLOC_ARRAY(ctx, DFS_INFO_3, num_jn); - if (!dfs3) + if ((r_u->info.e.u.info3.s = TALLOC_ARRAY(p->mem_ctx, NETDFS_DFS_INFO3, num_jn)) == NULL) { return WERR_NOMEM; - init_reply_dfs_info_3(ctx, jn, dfs3, num_jn); - ctr->dfs.info3 = dfs3; + } + r_u->info.e.u.info3.count = num_jn; + r_u->info.e.u.info3.ptr0_s = 1; + r_u->info.e.u.info3.size_s = num_jn; break; + case 4: + if ((r_u->info.e.u.info4.s = TALLOC_ARRAY(p->mem_ctx, NETDFS_DFS_INFO4, num_jn)) == NULL) { + return WERR_NOMEM; } + r_u->info.e.u.info4.count = num_jn; + r_u->info.e.u.info4.ptr0_s = 1; + r_u->info.e.u.info4.size_s = num_jn; + break; default: return WERR_INVALID_PARAM; } - return WERR_OK; -} - -WERROR _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u) -{ - uint32 level = q_u->level; - struct junction_map jn[MAX_MSDFS_JUNCTIONS]; - int num_jn = 0; - - num_jn = enum_msdfs_links(p->mem_ctx, jn, ARRAY_SIZE(jn)); - vfs_ChDir(p->conn,p->conn->connectpath); - - DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", num_jn, level)); - r_u->ptr_buffer = level; - r_u->level = r_u->level2 = level; - r_u->ptr_num_entries = r_u->ptr_num_entries2 = 1; - r_u->num_entries = r_u->num_entries2 = num_jn; - r_u->reshnd.ptr_hnd = 1; - r_u->reshnd.handle = num_jn; - - r_u->ctr = TALLOC_P(p->mem_ctx, DFS_INFO_CTR); - if (!r_u->ctr) - return WERR_NOMEM; - ZERO_STRUCTP(r_u->ctr); - r_u->ctr->switch_value = level; - r_u->ctr->num_entries = num_jn; - r_u->ctr->ptr_dfs_ctr = 1; + for (i = 0; i < num_jn; i++) { + switch (level) { + case 1: + init_reply_dfs_info_1(&jn[i], &r_u->info.e.u.info1.s[i]); + break; + case 2: + init_reply_dfs_info_2(&jn[i], &r_u->info.e.u.info2.s[i]); + break; + case 3: + init_reply_dfs_info_3(p->mem_ctx, &jn[i], &r_u->info.e.u.info3.s[i]); + break; + default: + return WERR_INVALID_PARAM; + } + } - r_u->status = init_reply_dfs_ctr(p->mem_ctx, level, r_u->ctr, jn, num_jn); + r_u->status = WERR_OK; return r_u->status; } -WERROR _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u, - DFS_R_DFS_GET_INFO *r_u) +WERROR _dfs_GetInfo(pipes_struct *p, NETDFS_Q_DFS_GETINFO *q_u, + NETDFS_R_DFS_GETINFO *r_u) { - UNISTR2* uni_path = &q_u->uni_path; + UNISTR2* uni_path = &q_u->path; uint32 level = q_u->level; int consumedcnt = sizeof(pstring); pstring path; + BOOL ret; struct junction_map jn; unistr2_to_ascii(path, uni_path, sizeof(path)-1); @@ -363,9 +358,130 @@ WERROR _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u, } vfs_ChDir(p->conn,p->conn->connectpath); - r_u->level = level; - r_u->ptr_ctr = 1; - r_u->status = init_reply_dfs_ctr(p->mem_ctx, level, &r_u->ctr, &jn, 1); + r_u->info.switch_value = level; + r_u->info.ptr0 = 1; + r_u->status = WERR_OK; + + switch (level) { + case 1: ret = init_reply_dfs_info_1(&jn, &r_u->info.u.info1); break; + case 2: ret = init_reply_dfs_info_2(&jn, &r_u->info.u.info2); break; + case 3: ret = init_reply_dfs_info_3(p->mem_ctx, &jn, &r_u->info.u.info3); break; + default: + ret = False; + break; + } + + if (!ret) + r_u->status = WERR_INVALID_PARAM; return r_u->status; } + +WERROR _dfs_SetInfo(pipes_struct *p, NETDFS_Q_DFS_SETINFO *q_u, NETDFS_R_DFS_SETINFO *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_Rename(pipes_struct *p, NETDFS_Q_DFS_RENAME *q_u, NETDFS_R_DFS_RENAME *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_Move(pipes_struct *p, NETDFS_Q_DFS_MOVE *q_u, NETDFS_R_DFS_MOVE *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_ManagerGetConfigInfo(pipes_struct *p, NETDFS_Q_DFS_MANAGERGETCONFIGINFO *q_u, NETDFS_R_DFS_MANAGERGETCONFIGINFO *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_ManagerSendSiteInfo(pipes_struct *p, NETDFS_Q_DFS_MANAGERSENDSITEINFO *q_u, NETDFS_R_DFS_MANAGERSENDSITEINFO *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_AddFtRoot(pipes_struct *p, NETDFS_Q_DFS_ADDFTROOT *q_u, NETDFS_R_DFS_ADDFTROOT *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_RemoveFtRoot(pipes_struct *p, NETDFS_Q_DFS_REMOVEFTROOT *q_u, NETDFS_R_DFS_REMOVEFTROOT *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_AddStdRoot(pipes_struct *p, NETDFS_Q_DFS_ADDSTDROOT *q_u, NETDFS_R_DFS_ADDSTDROOT *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_RemoveStdRoot(pipes_struct *p, NETDFS_Q_DFS_REMOVESTDROOT *q_u, NETDFS_R_DFS_REMOVESTDROOT *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_ManagerInitialize(pipes_struct *p, NETDFS_Q_DFS_MANAGERINITIALIZE *q_u, NETDFS_R_DFS_MANAGERINITIALIZE *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_AddStdRootForced(pipes_struct *p, NETDFS_Q_DFS_ADDSTDROOTFORCED *q_u, NETDFS_R_DFS_ADDSTDROOTFORCED *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_GetDcAddress(pipes_struct *p, NETDFS_Q_DFS_GETDCADDRESS *q_u, NETDFS_R_DFS_GETDCADDRESS *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_SetDcAddress(pipes_struct *p, NETDFS_Q_DFS_SETDCADDRESS *q_u, NETDFS_R_DFS_SETDCADDRESS *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_FlushFtTable(pipes_struct *p, NETDFS_Q_DFS_FLUSHFTTABLE *q_u, NETDFS_R_DFS_FLUSHFTTABLE *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_Add2(pipes_struct *p, NETDFS_Q_DFS_ADD2 *q_u, NETDFS_R_DFS_ADD2 *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_Remove2(pipes_struct *p, NETDFS_Q_DFS_REMOVE2 *q_u, NETDFS_R_DFS_REMOVE2 *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_EnumEx(pipes_struct *p, NETDFS_Q_DFS_ENUMEX *q_u, NETDFS_R_DFS_ENUMEX *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + +WERROR _dfs_SetInfo2(pipes_struct *p, NETDFS_Q_DFS_SETINFO2 *q_u, NETDFS_R_DFS_SETINFO2 *r_u) +{ + /* FIXME: Implement your code here */ + return WERR_NOT_SUPPORTED; +} + diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f48f3e863a..c93107cec4 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -9,6 +9,7 @@ * Copyright (C) Jim McDonough 2002, * Copyright (C) Simo Sorce 2003. * Copyright (C) Gerald (Jerry) Carter 2005. + * Copyright (C) Volker Lendecke 2005. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -102,9 +103,7 @@ static int init_dom_ref(DOM_R_REF *ref, const char *dom_name, DOM_SID *dom_sid) if (dom_name != NULL) { for (num = 0; num < ref->num_ref_doms_1; num++) { - fstring domname; - rpcstr_pull(domname, ref->ref_dom[num].uni_dom_name.buffer, sizeof(domname), -1, 0); - if (strequal(domname, dom_name)) + if (sid_equal(dom_sid, &ref->ref_dom[num].ref_dom.sid)) return num; } } else { @@ -159,8 +158,8 @@ static int init_lsa_rid2s(TALLOC_CTX *mem_ctx, /* Split name into domain and user component */ - if (rpcstr_pull_unistr2_talloc(mem_ctx, &full_name, - &name[i]) < 0) { + full_name = rpcstr_pull_unistr2_talloc(mem_ctx, &name[i]); + if (full_name == NULL) { DEBUG(0, ("pull_ucs2_talloc failed\n")); return 0; } @@ -226,87 +225,6 @@ static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, r_l->mapped_count = mapped_count; } -/*************************************************************************** - Init lsa_trans_names. - ***************************************************************************/ - -static void init_lsa_trans_names(TALLOC_CTX *ctx, DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *trn, - int num_entries, DOM_SID2 *sid, - uint32 *mapped_count) -{ - int i; - int total = 0; - *mapped_count = 0; - - /* Allocate memory for list of names */ - - if (num_entries > 0) { - if (!(trn->name = TALLOC_ARRAY(ctx, LSA_TRANS_NAME, num_entries))) { - DEBUG(0, ("init_lsa_trans_names(): out of memory\n")); - return; - } - - if (!(trn->uni_name = TALLOC_ARRAY(ctx, UNISTR2, num_entries))) { - DEBUG(0, ("init_lsa_trans_names(): out of memory\n")); - return; - } - } - - become_root(); /* Need root to get to passdb to for local sids */ - - for (i = 0; i < num_entries; i++) { - BOOL status = False; - DOM_SID find_sid = sid[i].sid; - uint32 rid = 0xffffffff; - int dom_idx = -1; - const char *name, *domain; - enum SID_NAME_USE type = SID_NAME_UNKNOWN; - - DEBUG(5, ("init_lsa_trans_names: looking up sid %s\n", - sid_string_static(&find_sid))); - - /* Lookup sid from winbindd */ - - status = lookup_sid(ctx, &find_sid, &domain, &name, &type); - - DEBUG(5, ("init_lsa_trans_names: %s\n", status ? "found" : - "not found")); - - if (!status) { - type = SID_NAME_UNKNOWN; - domain = talloc_strdup(ctx, ""); - name = talloc_strdup(ctx, - sid_string_static(&find_sid)); - dom_idx = -1; - - DEBUG(10,("init_lsa_trans_names: added unknown user " - "'%s' to referenced list.\n", name )); - } else { - (*mapped_count)++; - /* Store domain sid in ref array */ - if (find_sid.num_auths == 5) { - sid_split_rid(&find_sid, &rid); - } - dom_idx = init_dom_ref(ref, domain, &find_sid); - - DEBUG(10,("init_lsa_trans_names: added %s '%s\\%s' " - "(%d) to referenced list.\n", - sid_type_lookup(type), domain, name, type)); - - } - - init_lsa_trans_name(&trn->name[total], &trn->uni_name[total], - type, name, dom_idx); - total++; - } - - unbecome_root(); - - trn->num_entries = total; - trn->ptr_trans_names = 1; - trn->num_entries2 = total; -} - /*************************************************************************** Init_reply_lookup_sids. ***************************************************************************/ @@ -315,7 +233,7 @@ static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *names, uint32 mapped_count) { - r_l->ptr_dom_ref = 1; + r_l->ptr_dom_ref = ref ? 1 : 0; r_l->dom_ref = ref; r_l->names = names; r_l->mapped_count = mapped_count; @@ -496,10 +414,12 @@ NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL * ufff, done :) mimir ***************************************************************************/ -NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_ENUM_TRUST_DOM *r_u) +NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, + LSA_R_ENUM_TRUST_DOM *r_u) { struct lsa_info *info; - uint32 enum_context = q_u->enum_context; + uint32 next_idx; + struct trustdom_info **domains; /* * preferred length is set to 5 as a "our" preferred length @@ -507,10 +427,11 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E * update (20.08.2002): it's not preferred length, but preferred size! * it needs further investigation how to optimally choose this value */ - uint32 max_num_domains = q_u->preferred_len < 5 ? q_u->preferred_len : 10; - TRUSTDOM **trust_doms; + uint32 max_num_domains = + q_u->preferred_len < 5 ? q_u->preferred_len : 10; uint32 num_domains; NTSTATUS nt_status; + uint32 num_thistime; if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; @@ -519,19 +440,34 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, LSA_R_E if (!(info->access & POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - nt_status = secrets_get_trusted_domains(p->mem_ctx, (int *)&enum_context, max_num_domains, (int *)&num_domains, &trust_doms); + nt_status = secrets_trusted_domains(p->mem_ctx, &num_domains, + &domains); - if (!NT_STATUS_IS_OK(nt_status) && - !NT_STATUS_EQUAL(nt_status, STATUS_MORE_ENTRIES) && - !NT_STATUS_EQUAL(nt_status, NT_STATUS_NO_MORE_ENTRIES)) { + if (!NT_STATUS_IS_OK(nt_status)) { return nt_status; - } else { - r_u->status = nt_status; } + if (q_u->enum_context < num_domains) { + num_thistime = MIN(num_domains, max_num_domains); + + r_u->status = STATUS_MORE_ENTRIES; + + if (q_u->enum_context + num_thistime > num_domains) { + num_thistime = num_domains - q_u->enum_context; + r_u->status = NT_STATUS_OK; + } + + next_idx = q_u->enum_context + num_thistime; + } else { + num_thistime = 0; + next_idx = 0xffffffff; + r_u->status = NT_STATUS_NO_MORE_ENTRIES; + } + /* set up the lsa_enum_trust_dom response */ - init_r_enum_trust_dom(p->mem_ctx, r_u, enum_context, max_num_domains, num_domains, trust_doms); + init_r_enum_trust_dom(p->mem_ctx, r_u, next_idx, + num_thistime, domains+q_u->enum_context); return r_u->status; } @@ -650,24 +586,29 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF _lsa_lookup_sids ***************************************************************************/ -NTSTATUS _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_SIDS *r_u) +NTSTATUS _lsa_lookup_sids(pipes_struct *p, + LSA_Q_LOOKUP_SIDS *q_u, + LSA_R_LOOKUP_SIDS *r_u) { struct lsa_info *handle; - DOM_SID2 *sid = q_u->sids.sid; - int num_entries = q_u->sids.num_entries; - DOM_R_REF *ref = NULL; - LSA_TRANS_NAME_ENUM *names = NULL; + + int i, num_sids; + const DOM_SID **sids; uint32 mapped_count = 0; - if (num_entries > MAX_LOOKUP_SIDS) { - num_entries = 0; - DEBUG(5,("_lsa_lookup_sids: limit of %d exceeded, truncating SID lookup list to %d\n", MAX_LOOKUP_SIDS, num_entries)); - r_u->status = NT_STATUS_NONE_MAPPED; - } + struct lsa_dom_info *dom_infos; + struct lsa_name_info *name_infos; + + DOM_R_REF *ref = NULL; + LSA_TRANS_NAME_ENUM *names = NULL; - ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); names = TALLOC_ZERO_P(p->mem_ctx, LSA_TRANS_NAME_ENUM); + if ((q_u->level < 1) || (q_u->level > 6)) { + r_u->status = NT_STATUS_INVALID_PARAMETER; + goto done; + } + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { r_u->status = NT_STATUS_INVALID_HANDLE; goto done; @@ -678,19 +619,91 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, LSA_Q_LOOKUP_SIDS *q_u, LSA_R_LOOKUP_ r_u->status = NT_STATUS_ACCESS_DENIED; goto done; } - if (!ref || !names) - return NT_STATUS_NO_MEMORY; -done: + num_sids = q_u->sids.num_entries; + if (num_sids > MAX_LOOKUP_SIDS) { + DEBUG(5,("_lsa_lookup_sids: limit of %d exceeded, truncating " + "SID lookup list to %d\n", + MAX_LOOKUP_SIDS, num_sids)); + r_u->status = NT_STATUS_NONE_MAPPED; + goto done; + } - /* set up the LSA Lookup SIDs response */ - init_lsa_trans_names(p->mem_ctx, ref, names, num_entries, sid, &mapped_count); - if (NT_STATUS_IS_OK(r_u->status)) { - if (mapped_count == 0) - r_u->status = NT_STATUS_NONE_MAPPED; - else if (mapped_count != num_entries) - r_u->status = STATUS_SOME_UNMAPPED; + ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); + + sids = TALLOC_ARRAY(p->mem_ctx, const DOM_SID *, num_sids); + if ((ref == NULL) || (names == NULL) || (sids == NULL)) { + r_u->status = NT_STATUS_NO_MEMORY; + goto done; + } + + for (i=0; isids.sid[i].sid; + } + + r_u->status = lookup_sids(p->mem_ctx, num_sids, sids, q_u->level, + &dom_infos, &name_infos); + + if (!NT_STATUS_IS_OK(r_u->status)) { + goto done; + } + + if (num_sids > 0) { + names->name = TALLOC_ARRAY(names, LSA_TRANS_NAME, num_sids); + names->uni_name = TALLOC_ARRAY(names, UNISTR2, num_sids); + if ((names->name == NULL) || (names->uni_name == NULL)) { + r_u->status = NT_STATUS_NO_MEMORY; + goto done; + } } + + for (i=0; istatus = NT_STATUS_INTERNAL_ERROR; + goto done; + } + } + + for (i=0; itype == SID_NAME_UNKNOWN) { + name->dom_idx = -1; + name->name = talloc_asprintf(p->mem_ctx, "%8.8x", + name->rid); + if (name->name == NULL) { + r_u->status = NT_STATUS_NO_MEMORY; + goto done; + } + } else { + mapped_count += 1; + } + init_lsa_trans_name(&names->name[i], &names->uni_name[i], + name->type, name->name, name->dom_idx); + } + + names->num_entries = num_sids; + names->ptr_trans_names = 1; + names->num_entries2 = num_sids; + + r_u->status = NT_STATUS_NONE_MAPPED; + if (mapped_count > 0) { + r_u->status = (mapped_count < num_sids) ? + STATUS_SOME_UNMAPPED : NT_STATUS_OK; + } + + DEBUG(10, ("num_sids %d, mapped_count %d, status %s\n", + num_sids, mapped_count, nt_errstr(r_u->status))); + + done: init_reply_lookup_sids(r_u, ref, names, mapped_count); return r_u->status; @@ -1173,10 +1186,7 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA if (!pdb_getgrsid(&map, info->sid)) return NT_STATUS_NO_SUCH_GROUP; - if(!pdb_update_group_mapping_entry(&map)) - return NT_STATUS_NO_SUCH_GROUP; - - return r_u->status; + return pdb_update_group_mapping_entry(&map); } /*************************************************************************** diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 643921f596..fd78f954cc 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -542,12 +542,9 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * } become_root(); - ret = pdb_update_sam_account (sampass); + r_u->status = pdb_update_sam_account (sampass); unbecome_root(); } - if (ret) { - status = NT_STATUS_OK; - } /* set up the LSA Server Password Set response */ init_net_r_srv_pwset(r_u, &cred_out, status); @@ -587,29 +584,29 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF /******************************************************************* gets a domain user's groups from their already-calculated NT_USER_TOKEN ********************************************************************/ -static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, const DOM_SID *domain_sid, - const NT_USER_TOKEN *nt_token, +static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, + const DOM_SID *domain_sid, + size_t num_sids, + const DOM_SID *sids, int *numgroups, DOM_GID **pgids) { - DOM_GID *gids; int i; - gids = TALLOC_ARRAY(mem_ctx, DOM_GID, nt_token->num_sids); - - if (!gids) { - return NT_STATUS_NO_MEMORY; - } - *numgroups=0; + *pgids = NULL; - for (i=PRIMARY_GROUP_SID_INDEX; i < nt_token->num_sids; i++) { - if (sid_compare_domain(domain_sid, &nt_token->user_sids[i])==0) { - sid_peek_rid(&nt_token->user_sids[i], &(gids[*numgroups].g_rid)); - gids[*numgroups].attr= (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT|SE_GROUP_ENABLED); - (*numgroups)++; + for (i=0; idc->remote_machine )); return NT_STATUS_ACCESS_DENIED; } @@ -734,10 +731,10 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * break; } case INTERACTIVE_LOGON_TYPE: - /* 'Interactive' autheticaion, supplies the password in its - MD4 form, encrypted with the session key. We will - convert this to chellange/responce for the auth - subsystem to chew on */ + /* 'Interactive' authentication, supplies the password in its + MD4 form, encrypted with the session key. We will convert + this to challenge/response for the auth subsystem to chew + on */ { const uint8 *chal; @@ -787,14 +784,15 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * && !is_trusted_domain(nt_domain) ) r_u->auth_resp = 0; /* We are not authoritative */ - free_server_info(&server_info); + talloc_free(server_info); return status; } if (server_info->guest) { /* We don't like guest domain logons... */ - DEBUG(5,("_net_sam_logon: Attempted domain logon as GUEST denied.\n")); - free_server_info(&server_info); + DEBUG(5,("_net_sam_logon: Attempted domain logon as GUEST " + "denied.\n")); + talloc_free(server_info); return NT_STATUS_LOGON_FAILURE; } @@ -819,7 +817,8 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * sampw = server_info->sam_account; - /* set up pointer indicating user/password failed to be found */ + /* set up pointer indicating user/password failed to be + * found */ usr_info->ptr_user_info = 0; user_sid = pdb_get_user_sid(sampw); @@ -829,8 +828,12 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * sid_split_rid(&domain_sid, &user_rid); if (!sid_peek_check_rid(&domain_sid, group_sid, &group_rid)) { - DEBUG(1, ("_net_sam_logon: user %s\\%s has user sid %s\n but group sid %s.\nThe conflicting domain portions are not supported for NETLOGON calls\n", - pdb_get_domain(sampw), pdb_get_username(sampw), + DEBUG(1, ("_net_sam_logon: user %s\\%s has user sid " + "%s\n but group sid %s.\n" + "The conflicting domain portions are not " + "supported for NETLOGON calls\n", + pdb_get_domain(sampw), + pdb_get_username(sampw), sid_to_string(user_sid_string, user_sid), sid_to_string(group_sid_string, group_sid))); return NT_STATUS_UNSUCCESSFUL; @@ -842,26 +845,30 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * } else { pstrcpy(my_name, global_myname()); } - - if (!NT_STATUS_IS_OK(status - = nt_token_to_group_list(p->mem_ctx, - &domain_sid, - server_info->ptok, - &num_gids, - &gids))) { + + status = nt_token_to_group_list(p->mem_ctx, &domain_sid, + server_info->num_sids, + server_info->sids, + &num_gids, &gids); + + if (!NT_STATUS_IS_OK(status)) { return status; } ZERO_STRUCT(netlogon_sess_key); memcpy(netlogon_sess_key, p->dc->sess_key, 8); if (server_info->user_session_key.length) { - memcpy(user_session_key, server_info->user_session_key.data, - MIN(sizeof(user_session_key), server_info->user_session_key.length)); + memcpy(user_session_key, + server_info->user_session_key.data, + MIN(sizeof(user_session_key), + server_info->user_session_key.length)); SamOEMhash(user_session_key, netlogon_sess_key, 16); } if (server_info->lm_session_key.length) { - memcpy(lm_session_key, server_info->lm_session_key.data, - MIN(sizeof(lm_session_key), server_info->lm_session_key.length)); + memcpy(lm_session_key, + server_info->lm_session_key.data, + MIN(sizeof(lm_session_key), + server_info->lm_session_key.length)); SamOEMhash(lm_session_key, netlogon_sess_key, 16); } ZERO_STRUCT(netlogon_sess_key); @@ -891,14 +898,11 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * server_info->lm_session_key.length ? lm_session_key : NULL, my_name , /* char *logon_srv */ pdb_get_domain(sampw), - &domain_sid, /* DOM_SID *dom_sid */ - /* Should be users domain sid, not servers - for trusted domains */ - - NULL); /* char *other_sids */ + &domain_sid); /* DOM_SID *dom_sid */ ZERO_STRUCT(user_session_key); ZERO_STRUCT(lm_session_key); } - free_server_info(&server_info); + talloc_free(server_info); return status; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 381adbe635..68b3a2d434 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -616,7 +616,7 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) memset(p->wks, '\0', sizeof(p->wks)); /* Set up for non-authenticated user. */ - delete_nt_token(&p->pipe_user.nt_user_token); + talloc_free(p->pipe_user.nt_user_token); p->pipe_user.ut.ngroups = 0; SAFE_FREE( p->pipe_user.ut.groups); @@ -664,7 +664,8 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) } if (a->server_info->ptok) { - p->pipe_user.nt_user_token = dup_nt_token(a->server_info->ptok); + p->pipe_user.nt_user_token = + dup_nt_token(NULL, a->server_info->ptok); } else { DEBUG(1,("Error: Authmodule failed to provide nt_user_token\n")); p->pipe_user.nt_user_token = NULL; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 37d3ef64c0..86a04e7ccb 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -349,7 +349,8 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, /* Store the session key and NT_TOKEN */ if (vuser) { p->session_key = data_blob(vuser->session_key.data, vuser->session_key.length); - p->pipe_user.nt_user_token = dup_nt_token(vuser->nt_user_token); + p->pipe_user.nt_user_token = dup_nt_token( + NULL, vuser->nt_user_token); } /* @@ -1222,7 +1223,7 @@ static BOOL close_internal_rpc_pipe_hnd(void *np_conn) /* Free the handles database. */ close_policy_by_pipe(p); - delete_nt_token(&p->pipe_user.nt_user_token); + talloc_free(p->pipe_user.nt_user_token); data_blob_free(&p->session_key); SAFE_FREE(p->pipe_user.ut.groups); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2f9d494a26..81344cdc1e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -140,7 +140,7 @@ static NTSTATUS make_samr_object_sd( TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd if ( sid ) { init_sec_access( &mask, sid_access ); init_sec_ace(&ace[i++], sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); -} + } /* create the security descriptor */ @@ -1416,7 +1416,7 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO type[i] = SID_NAME_ALIAS; } } else { - lookup_global_sam_name(name, &rid[i], &type[i]); + lookup_global_sam_name(name, 0, &rid[i], &type[i]); } if (type[i] != SID_NAME_UNKNOWN) { @@ -1927,28 +1927,6 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ return r_u->status; break; -#if 0 -/* whoops - got this wrong. i think. or don't understand what's happening. */ - case 17: - { - NTTIME expire; - info = (void *)&id11; - - expire.low = 0xffffffff; - expire.high = 0x7fffffff; - - ctr->info.id = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_17)); - ZERO_STRUCTP(ctr->info.id17); - init_sam_user_info17(ctr->info.id17, &expire, - "BROOKFIELDS$", /* name */ - 0x03ef, /* user rid */ - 0x201, /* group rid */ - 0x0080); /* acb info */ - - break; - } -#endif - case 18: ctr->info.id18 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_18); if (ctr->info.id18 == NULL) @@ -1993,10 +1971,11 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAMR_R_QUERY_USERGROUPS *r_u) { SAM_ACCOUNT *sam_pass=NULL; - struct passwd *passwd; DOM_SID sid; DOM_SID *sids; + DOM_GID dom_gid; DOM_GID *gids = NULL; + uint32 primary_group_rid; size_t num_groups = 0; gid_t *unix_gids; size_t i, num_gids; @@ -2031,58 +2010,72 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S if (!sid_check_is_in_our_domain(&sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - pdb_init_sam(&sam_pass); + pdb_init_sam_talloc(p->mem_ctx, &sam_pass); become_root(); ret = pdb_getsampwsid(sam_pass, &sid); unbecome_root(); - if (ret == False) { - pdb_free_sam(&sam_pass); - return NT_STATUS_NO_SUCH_USER; - } - - passwd = getpwnam_alloc(pdb_get_username(sam_pass)); - if (passwd == NULL) { - pdb_free_sam(&sam_pass); + if (!ret) { + DEBUG(10, ("pdb_getsampwsid failed for %s\n", + sid_string_static(&sid))); return NT_STATUS_NO_SUCH_USER; } sids = NULL; become_root(); - result = pdb_enum_group_memberships(pdb_get_username(sam_pass), - passwd->pw_gid, + result = pdb_enum_group_memberships(p->mem_ctx, sam_pass, &sids, &unix_gids, &num_groups); unbecome_root(); - pdb_free_sam(&sam_pass); - passwd_free(&passwd); - - if (!NT_STATUS_IS_OK(result)) + if (!NT_STATUS_IS_OK(result)) { + DEBUG(10, ("pdb_enum_group_memberships failed for %s\n", + sid_string_static(&sid))); return result; - - SAFE_FREE(unix_gids); + } gids = NULL; num_gids = 0; + dom_gid.attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT| + SE_GROUP_ENABLED); + + if (!sid_peek_check_rid(get_global_sam_sid(), + pdb_get_group_sid(sam_pass), + &primary_group_rid)) { + DEBUG(5, ("Group sid %s for user %s not in our domain\n", + sid_string_static(pdb_get_group_sid(sam_pass)), + pdb_get_username(sam_pass))); + pdb_free_sam(&sam_pass); + return NT_STATUS_INTERNAL_DB_CORRUPTION; + } + + dom_gid.g_rid = primary_group_rid; + + ADD_TO_ARRAY(p->mem_ctx, DOM_GID, dom_gid, &gids, &num_gids); + for (i=0; imem_ctx, gids, DOM_GID, num_gids+1); - gids[num_gids].attr= (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT|SE_GROUP_ENABLED); - gids[num_gids].g_rid = rid; - num_gids += 1; + if (dom_gid.g_rid == primary_group_rid) { + /* We added the primary group directly from the + * sam_account. The other SIDs are unique from + * enum_group_memberships */ + continue; + } + + ADD_TO_ARRAY(p->mem_ctx, DOM_GID, dom_gid, &gids, &num_gids); } - SAFE_FREE(sids); /* construct the response. lkclXXXX: gids are not copied! */ - init_samr_r_query_usergroups(r_u, num_groups, gids, r_u->status); + init_samr_r_query_usergroups(r_u, num_gids, gids, r_u->status); DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__)); @@ -2322,7 +2315,8 @@ static NTSTATUS can_create(TALLOC_CTX *mem_ctx, const char *new_name) This funcion will need to be updated for bdc/domain trusts. ********************************************************************/ -NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREATE_USER *r_u) +NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, + SAMR_R_CREATE_USER *r_u) { SAM_ACCOUNT *sam_pass=NULL; fstring account; @@ -2339,7 +2333,6 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA uint32 acc_granted; SEC_DESC *psd; size_t sd_size; - uint32 new_rid = 0; /* check this, when giving away 'add computer to domain' privs */ uint32 des_access = GENERIC_RIGHTS_USER_ALL_ACCESS; BOOL can_add_account = False; @@ -2347,20 +2340,26 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA DISP_INFO *disp_info = NULL; /* Get the domain SID stored in the domain policy */ - if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted, + &disp_info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(nt_status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_USER, "_samr_create_user"))) { + nt_status = access_check_samr_function(acc_granted, + SA_RIGHT_DOMAIN_CREATE_USER, + "_samr_create_user"); + if (!NT_STATUS_IS_OK(nt_status)) { return nt_status; } - if (!(acb_info == ACB_NORMAL || acb_info == ACB_DOMTRUST || acb_info == ACB_WSTRUST || acb_info == ACB_SVRTRUST)) { + if (!(acb_info == ACB_NORMAL || acb_info == ACB_DOMTRUST || + acb_info == ACB_WSTRUST || acb_info == ACB_SVRTRUST)) { /* Match Win2k, and return NT_STATUS_INVALID_PARAMETER if this parameter is not an account type */ return NT_STATUS_INVALID_PARAMETER; } - rpcstr_pull(account, user_account.buffer, sizeof(account), user_account.uni_str_len*2, 0); + rpcstr_pull(account, user_account.buffer, sizeof(account), + user_account.uni_str_len*2, 0); strlower_m(account); nt_status = can_create(p->mem_ctx, account); @@ -2369,14 +2368,14 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA } /********************************************************************* - * HEADS UP! If we have to create a new user account, we have to get - * a new RID from somewhere. This used to be done by the passdb - * backend. It has been moved into idmap now. Since idmap is now - * wrapped up behind winbind, this means you have to run winbindd if you - * want new accounts to get a new RID when "enable rid algorithm = no". - * Tough. We now have a uniform way of allocating RIDs regardless - * of what ever passdb backend people may use. - * --jerry (2003-07-10) + * HEADS UP! If we have to create a new user account, we have to get + * a new RID from somewhere. This used to be done by the passdb + * backend. It has been moved into idmap now. Since idmap is now + * wrapped up behind winbind, this means you have to run winbindd if + * you want new accounts to get a new RID when "enable rid algorithm = + * no". Tough. We now have a uniform way of allocating RIDs + * regardless of what ever passdb backend people may use. --jerry + * (2003-07-10) *********************************************************************/ pw = Get_Pwnam(account); @@ -2387,24 +2386,30 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA { pstrcpy(add_script, lp_addmachine_script()); se_priv_copy( &se_rights, &se_machine_account ); - can_add_account = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); + can_add_account = user_has_privileges( + p->pipe_user.nt_user_token, &se_rights ); } /* usrmgr.exe (and net rpc trustdom grant) creates a normal user account for domain trusts and changes the ACB flags later */ - else if ( acb_info & ACB_NORMAL && (account[strlen(account)-1] != '$') ) + else if ( acb_info & ACB_NORMAL && + (account[strlen(account)-1] != '$') ) { pstrcpy(add_script, lp_adduser_script()); se_priv_copy( &se_rights, &se_add_users ); - can_add_account = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); + can_add_account = user_has_privileges( + p->pipe_user.nt_user_token, &se_rights ); } - else /* implicit assumption of a BDC or domain trust account here (we already check the flags earlier) */ + else /* implicit assumption of a BDC or domain trust account here + * (we already check the flags earlier) */ { pstrcpy(add_script, lp_addmachine_script()); if ( lp_enable_privileges() ) { /* only Domain Admins can add a BDC or domain trust */ se_priv_copy( &se_rights, &se_priv_none ); - can_add_account = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); - } + can_add_account = nt_token_check_domain_rid( + p->pipe_user.nt_user_token, + DOMAIN_GROUP_RID_ADMINS ); + } } DEBUG(5, ("_samr_create_user: %s can add this account : %s\n", @@ -2419,16 +2424,20 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA if (*add_script) { int add_ret; - all_string_sub(add_script, "%u", account, sizeof(add_script)); + all_string_sub(add_script, "%u", account, + sizeof(add_script)); add_ret = smbrun(add_script,NULL); - DEBUG(add_ret ? 0 : 3,("_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); + DEBUG(add_ret ? 0 : 3,("_samr_create_user: Running " + "the command `%s' gave %d\n", + add_script, add_ret)); } } - /* implicit call to getpwnam() next. we have a valid SID coming out of this call */ + /* implicit call to getpwnam() next. we have a valid SID coming out + * of this call */ flush_pwnam_cache(); - nt_status = pdb_init_sam_new(&sam_pass, account, new_rid); + nt_status = pdb_init_sam_new(&sam_pass, account); /* this code is order such that we have no unnecessary retuns out of the admin block of code */ @@ -2438,7 +2447,8 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA if ( !(ret = pdb_add_sam_account(sam_pass)) ) { pdb_free_sam(&sam_pass); - DEBUG(0, ("could not add user/computer %s to passdb. Check permissions?\n", + DEBUG(0, ("could not add user/computer %s to passdb. " + "Check permissions?\n", account)); nt_status = NT_STATUS_ACCESS_DENIED; } @@ -2458,7 +2468,8 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREA sid_copy(&sid, pdb_get_user_sid(sam_pass)); - make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, &sid, SAMR_USR_RIGHTS_WRITE_PW); + make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, + &sid, SAMR_USR_RIGHTS_WRITE_PW); se_map_generic(&des_access, &usr_generic_mapping); nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, @@ -2944,7 +2955,7 @@ static BOOL set_user_info_16(const SAM_USER_INFO_16 *id16, SAM_ACCOUNT *pwd) return False; } - if(!pdb_update_sam_account(pwd)) { + if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) { pdb_free_sam(&pwd); return False; } @@ -2980,7 +2991,7 @@ static BOOL set_user_info_18(SAM_USER_INFO_18 *id18, SAM_ACCOUNT *pwd) return False; } - if(!pdb_update_sam_account(pwd)) { + if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) { pdb_free_sam(&pwd); return False; } @@ -2997,8 +3008,7 @@ static BOOL set_unix_primary_group(SAM_ACCOUNT *sampass) struct group *grp; gid_t gid; - if (!NT_STATUS_IS_OK(sid_to_gid(pdb_get_group_sid(sampass), - &gid))) { + if (!sid_to_gid(pdb_get_group_sid(sampass), &gid)) { DEBUG(2,("Could not get gid for primary group of " "user %s\n", pdb_get_username(sampass))); return False; @@ -3039,7 +3049,7 @@ static BOOL set_user_info_20(SAM_USER_INFO_20 *id20, SAM_ACCOUNT *pwd) copy_id20_to_sam_passwd(pwd, id20); /* write the change out */ - if(!pdb_update_sam_account(pwd)) { + if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) { pdb_free_sam(&pwd); return False; } @@ -3073,7 +3083,7 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, SAM_ACCOUNT *pwd) set_unix_primary_group(pwd); /* write the change out */ - if(!pdb_update_sam_account(pwd)) { + if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) { pdb_free_sam(&pwd); return False; } @@ -3140,7 +3150,7 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, SAM_ACCOUNT *pwd) if (IS_SAM_CHANGED(pwd, PDB_GROUPSID)) set_unix_primary_group(pwd); - if(!pdb_update_sam_account(pwd)) { + if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) { pdb_free_sam(&pwd); return False; } @@ -3202,7 +3212,7 @@ static BOOL set_user_info_pw(uint8 *pass, SAM_ACCOUNT *pwd) DEBUG(5,("set_user_info_pw: pdb_update_pwd()\n")); /* update the SAMBA password */ - if(!pdb_update_sam_account(pwd)) { + if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) { pdb_free_sam(&pwd); return False; } @@ -3485,7 +3495,6 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, NTSTATUS ntstatus2; DOM_SID *members; - BOOL res; r_u->status = NT_STATUS_OK; @@ -3521,13 +3530,14 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, num_alias_rids = 0; become_root(); - res = pdb_enum_alias_memberships(p->mem_ctx, &info->sid, members, - q_u->num_sids1, - &alias_rids, &num_alias_rids); + ntstatus1 = pdb_enum_alias_memberships(p->mem_ctx, &info->sid, members, + q_u->num_sids1, + &alias_rids, &num_alias_rids); unbecome_root(); - if (!res) - return NT_STATUS_UNSUCCESSFUL; + if (!NT_STATUS_IS_OK(ntstatus1)) { + return ntstatus1; + } init_samr_r_query_useraliases(r_u, num_alias_rids, alias_rids, NT_STATUS_OK); @@ -3540,6 +3550,7 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_QUERY_ALIASMEM *r_u) { + NTSTATUS status; size_t i; size_t num_sids = 0; DOM_SID2 *sid; @@ -3560,8 +3571,11 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ DEBUG(10, ("sid is %s\n", sid_string_static(&alias_sid))); - if (!pdb_enum_aliasmem(&alias_sid, &sids, &num_sids)) - return NT_STATUS_NO_SUCH_ALIAS; + status = pdb_enum_aliasmem(&alias_sid, &sids, &num_sids); + + if (!NT_STATUS_IS_OK(status)) { + return status; + } sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_sids); if (num_sids!=0 && sid == NULL) { @@ -3710,7 +3724,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD uint32 acc_granted; SE_PRIV se_rights; BOOL can_add_accounts; - BOOL ret; + NTSTATUS ret; DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ @@ -3738,11 +3752,11 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD /******** END SeAddUsers BLOCK *********/ - if (ret) { + if (NT_STATUS_IS_OK(ret)) { force_flush_samr_cache(disp_info); } - return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; + return ret; } /********************************************************************* @@ -3755,7 +3769,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE uint32 acc_granted; SE_PRIV se_rights; BOOL can_add_accounts; - BOOL ret; + NTSTATUS ret; DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ @@ -3784,11 +3798,11 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE /******** END SeAddUsers BLOCK *********/ - if (ret) { + if (NT_STATUS_IS_OK(ret)) { force_flush_samr_cache(disp_info); } - return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; + return ret; } /********************************************************************* @@ -3847,19 +3861,18 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD } /* check a real user exist before we run the script to add a user to a group */ - if (!NT_STATUS_IS_OK(sid_to_uid(pdb_get_user_sid(sam_user), &uid))) { + if (!sid_to_uid(pdb_get_user_sid(sam_user), &uid)) { pdb_free_sam(&sam_user); return NT_STATUS_NO_SUCH_USER; } pdb_free_sam(&sam_user); - if ((pwd=getpwuid_alloc(uid)) == NULL) { + if ((pwd=getpwuid_alloc(p->mem_ctx, uid)) == NULL) { return NT_STATUS_NO_SUCH_USER; } if ((grp=getgrgid(map.gid)) == NULL) { - passwd_free(&pwd); return NT_STATUS_NO_SUCH_GROUP; } @@ -3867,8 +3880,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD fstrcpy(grp_name, grp->gr_name); /* if the user is already in the group */ - if(user_in_unix_group_list(pwd->pw_name, grp_name)) { - passwd_free(&pwd); + if(user_in_unix_group(pwd->pw_name, grp_name)) { return NT_STATUS_MEMBER_IN_GROUP; } @@ -3894,13 +3906,10 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD /******** END SeAddUsers BLOCK *********/ /* check if the user has been added then ... */ - if(!user_in_unix_group_list(pwd->pw_name, grp_name)) { - passwd_free(&pwd); + if(!user_in_unix_group(pwd->pw_name, grp_name)) { return NT_STATUS_MEMBER_NOT_IN_GROUP; /* don't know what to reply else */ } - passwd_free(&pwd); - force_flush_samr_cache(disp_info); return NT_STATUS_OK; @@ -3961,7 +3970,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE } /* if the user is not in the group */ - if (!user_in_unix_group_list(pdb_get_username(sam_pass), grp_name)) { + if (!user_in_unix_group(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_MEMBER_NOT_IN_GROUP; } @@ -3983,7 +3992,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE /******** END SeAddUsers BLOCK *********/ /* check if the user has been removed then ... */ - if (user_in_unix_group_list(pdb_get_username(sam_pass), grp_name)) { + if (user_in_unix_group(pdb_get_username(sam_pass), grp_name)) { pdb_free_sam(&sam_pass); return NT_STATUS_ACCESS_DENIED; /* don't know what to reply else */ } @@ -4290,19 +4299,28 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S /* so far, so good */ result = NT_STATUS_OK; - - r_u->rid = pdb_gid_to_group_rid( grp->gr_gid ); - /* add the group to the mapping table */ + if (pdb_rid_algorithm()) { + r_u->rid = pdb_gid_to_group_rid( grp->gr_gid ); + } else { + if (!pdb_new_rid(&r_u->rid)) { + result = NT_STATUS_ACCESS_DENIED; + } + } + + if (NT_STATUS_IS_OK(result)) { + + /* add the group to the mapping table */ - sid_copy( &info_sid, get_global_sam_sid() ); - sid_append_rid( &info_sid, r_u->rid ); - sid_to_string( sid_string, &info_sid ); + sid_copy( &info_sid, get_global_sam_sid() ); + sid_append_rid( &info_sid, r_u->rid ); + sid_to_string( sid_string, &info_sid ); - /* reset the error code if we fail to add the mapping entry */ + /* reset the error code if we fail to add the mapping entry */ - if ( !add_initial_entry(grp->gr_gid, sid_string, SID_NAME_DOM_GRP, name, NULL) ) - result = NT_STATUS_ACCESS_DENIED; + if ( !add_initial_entry(grp->gr_gid, sid_string, SID_NAME_DOM_GRP, name, NULL) ) + result = NT_STATUS_ACCESS_DENIED; + } } if ( can_add_accounts ) @@ -4383,18 +4401,26 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S /******** END SeAddUsers BLOCK *********/ - if (!NT_STATUS_IS_OK(result)) + if (!NT_STATUS_IS_OK(result)) { + DEBUG(10, ("pdb_create_alias failed: %s\n", + nt_errstr(result))); return result; + } sid_copy(&info_sid, get_global_sam_sid()); sid_append_rid(&info_sid, r_u->rid); - if (!NT_STATUS_IS_OK(sid_to_gid(&info_sid, &gid))) + if (!sid_to_gid(&info_sid, &gid)) { + DEBUG(10, ("Could not find alias just created\n")); return NT_STATUS_ACCESS_DENIED; + } /* check if the group has been successfully created */ - if ( getgrgid(gid) == NULL ) + if ( getgrgid(gid) == NULL ) { + DEBUG(10, ("getgrgid(%d) of just created alias failed\n", + gid)); return NT_STATUS_ACCESS_DENIED; + } if ((info = get_samr_info_by_sid(&info_sid)) == NULL) return NT_STATUS_NO_MEMORY; @@ -4485,7 +4511,8 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ GROUP_MAP map; GROUP_INFO_CTR *ctr; uint32 acc_granted; - BOOL ret; + NTSTATUS ret; + BOOL result; BOOL can_mod_accounts; DISP_INFO *disp_info = NULL; @@ -4497,9 +4524,9 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ } become_root(); - ret = get_domain_group_from_sid(group_sid, &map); + result = get_domain_group_from_sid(group_sid, &map); unbecome_root(); - if (!ret) + if (!result) return NT_STATUS_NO_SUCH_GROUP; ctr=q_u->ctr; @@ -4529,11 +4556,11 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ /******** End SeAddUsers BLOCK *********/ - if (ret) { + if (NT_STATUS_IS_OK(ret)) { force_flush_samr_cache(disp_info); } - return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; + return ret; } /********************************************************************* diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a22d6db266..e6d45f76ec 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1620,10 +1620,13 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege, and not a printer admin, then fail */ - if ( user.ut.uid != 0 - && !user_has_privileges( user.nt_user_token, &se_printop ) - && !user_in_list(uidtoname(user.ut.uid), lp_printer_admin(snum), user.ut.groups, user.ut.ngroups) ) - { + if ((user.ut.uid != 0) && + !user_has_privileges(user.nt_user_token, + &se_printop ) && + !token_contains_name_in_list( + uidtoname(user.ut.uid), NULL, + user.nt_user_token, + lp_printer_admin(snum))) { close_printer_handle(p, handle); return WERR_ACCESS_DENIED; } @@ -1676,7 +1679,10 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, return WERR_ACCESS_DENIED; } - if (!user_ok(uidtoname(user.ut.uid), snum, user.ut.groups, user.ut.ngroups) || !print_access_check(&user, snum, printer_default->access_required)) { + if (!user_ok_token(uidtoname(user.ut.uid), user.nt_user_token, + snum) || + !print_access_check(&user, snum, + printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); close_printer_handle(p, handle); return WERR_ACCESS_DENIED; @@ -5997,7 +6003,7 @@ BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) numlines = 0; /* Get lines and convert them back to dos-codepage */ - qlines = fd_lines_load(fd, &numlines); + qlines = fd_lines_load(fd, &numlines, 0); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); close(fd); @@ -7195,7 +7201,7 @@ WERROR enumports_hook( int *count, char ***lines ) } numlines = 0; - qlines = fd_lines_load(fd, &numlines); + qlines = fd_lines_load(fd, &numlines, 0); DEBUGADD(10,("Lines returned = [%d]\n", numlines)); close(fd); } diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 8150a8bf69..f279c98c31 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -29,26 +29,6 @@ extern struct generic_mapping file_generic_mapping; #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -#define INVALID_SHARENAME_CHARS "<>*?|/\\+=;:\"," - -/******************************************************************** - Check a string for any occurrences of a specified list of invalid - characters. -********************************************************************/ - -static BOOL validate_net_name( const char *name, const char *invalid_chars, int max_len ) -{ - int i; - - for ( i=0; iinfo_2_str, net_name, remark, path, passwd); } -/******************************************************************* - What to do when smb.conf is updated. - ********************************************************************/ - -static void smb_conf_updated(int msg_type, struct process_id src, - void *buf, size_t len) -{ - DEBUG(10,("smb_conf_updated: Got message saying smb.conf was updated. Reloading.\n")); - reload_services(False); -} - -/******************************************************************* - Create the share security tdb. - ********************************************************************/ - -static TDB_CONTEXT *share_tdb; /* used for share security descriptors */ -#define SHARE_DATABASE_VERSION_V1 1 -#define SHARE_DATABASE_VERSION_V2 2 /* version id in little endian. */ - -BOOL share_info_db_init(void) -{ - static pid_t local_pid; - const char *vstring = "INFO/version"; - int32 vers_id; - - if (share_tdb && local_pid == sys_getpid()) - return True; - 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) )); - return False; - } - - local_pid = sys_getpid(); - - /* handle a Samba upgrade */ - tdb_lock_bystring(share_tdb, vstring, 0); - - /* Cope with byte-reversed older versions of the db. */ - vers_id = tdb_fetch_int32(share_tdb, vstring); - if ((vers_id == SHARE_DATABASE_VERSION_V1) || (IREV(vers_id) == SHARE_DATABASE_VERSION_V1)) { - /* Written on a bigendian machine with old fetch_int code. Save as le. */ - tdb_store_int32(share_tdb, vstring, SHARE_DATABASE_VERSION_V2); - vers_id = SHARE_DATABASE_VERSION_V2; - } - - if (vers_id != SHARE_DATABASE_VERSION_V2) { - tdb_traverse(share_tdb, tdb_traverse_delete_fn, NULL); - tdb_store_int32(share_tdb, vstring, SHARE_DATABASE_VERSION_V2); - } - tdb_unlock_bystring(share_tdb, vstring); - - message_register(MSG_SMB_CONF_UPDATED, smb_conf_updated); - - return True; -} - -/******************************************************************* - Fake up a Everyone, full access as a default. - ********************************************************************/ - -static SEC_DESC *get_share_security_default( TALLOC_CTX *ctx, int snum, size_t *psize) -{ - SEC_ACCESS sa; - SEC_ACE ace; - SEC_ACL *psa = NULL; - SEC_DESC *psd = NULL; - uint32 def_access = GENERIC_ALL_ACCESS; - - se_map_generic(&def_access, &file_generic_mapping); - - init_sec_access(&sa, GENERIC_ALL_ACCESS | def_access ); - init_sec_ace(&ace, &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, sa, 0); - - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 1, &ace)) != NULL) { - psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, psize); - } - - if (!psd) { - DEBUG(0,("get_share_security: Failed to make SEC_DESC.\n")); - return NULL; - } - - return psd; -} - -/******************************************************************* - Pull a security descriptor from the share tdb. - ********************************************************************/ - -static SEC_DESC *get_share_security( TALLOC_CTX *ctx, int snum, size_t *psize) -{ - prs_struct ps; - fstring key; - SEC_DESC *psd = NULL; - - *psize = 0; - - /* Fetch security descriptor from tdb */ - - slprintf(key, sizeof(key)-1, "SECDESC/%s", lp_servicename(snum)); - - if (tdb_prs_fetch(share_tdb, key, &ps, ctx)!=0 || - !sec_io_desc("get_share_security", &psd, &ps, 1)) { - - DEBUG(4,("get_share_security: using default secdesc for %s\n", lp_servicename(snum) )); - - return get_share_security_default(ctx, snum, psize); - } - - if (psd) - *psize = sec_desc_size(psd); - - prs_mem_free(&ps); - return psd; -} - -/******************************************************************* - Store a security descriptor in the share db. - ********************************************************************/ - -static BOOL set_share_security(TALLOC_CTX *ctx, const char *share_name, SEC_DESC *psd) -{ - prs_struct ps; - TALLOC_CTX *mem_ctx = NULL; - fstring key; - BOOL ret = False; - - mem_ctx = talloc_init("set_share_security"); - if (mem_ctx == NULL) - return False; - - prs_init(&ps, (uint32)sec_desc_size(psd), mem_ctx, MARSHALL); - - if (!sec_io_desc("share_security", &psd, &ps, 1)) - goto out; - - slprintf(key, sizeof(key)-1, "SECDESC/%s", share_name); - - if (tdb_prs_store(share_tdb, key, &ps)==0) { - ret = True; - DEBUG(5,("set_share_security: stored secdesc for %s\n", share_name )); - } else { - DEBUG(1,("set_share_security: Failed to store secdesc for %s\n", share_name )); - } - - /* Free malloc'ed memory */ - -out: - - prs_mem_free(&ps); - if (mem_ctx) - talloc_destroy(mem_ctx); - return ret; -} - -/******************************************************************* - Delete a security descriptor. -********************************************************************/ - -static BOOL delete_share_security(int snum) -{ - TDB_DATA kbuf; - fstring key; - - slprintf(key, sizeof(key)-1, "SECDESC/%s", lp_servicename(snum)); - kbuf.dptr = key; - kbuf.dsize = strlen(key)+1; - - if (tdb_delete(share_tdb, kbuf) != 0) { - DEBUG(0,("delete_share_security: Failed to delete entry for share %s\n", - lp_servicename(snum) )); - return False; - } - - return True; -} - /******************************************************************* Map any generic bits to file specific bits. ********************************************************************/ -void map_generic_share_sd_bits(SEC_DESC *psd) +static void map_generic_share_sd_bits(SEC_DESC *psd) { int i; SEC_ACL *ps_dacl = NULL; @@ -517,7 +318,7 @@ 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 num_services = 0; int snum; TALLOC_CTX *ctx = p->mem_ctx; @@ -528,6 +329,11 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, ctr->info_level = ctr->switch_value = info_level; *resume_hnd = 0; + /* Ensure all the usershares are loaded. */ + become_root(); + num_services = load_usershare_shares(); + unbecome_root(); + /* Count the number of entries. */ for (snum = 0; snum < num_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) -- cgit From ef3f2c9675194efa17cfd4b4b5393a6e0a335bdf Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 8 Feb 2006 15:09:09 +0000 Subject: r13393: Do not initialize the lp_svcctl_list() value since it is handled internally in services_db.c now. This prevents internal services from being listed twice (one internal and one external) when no 'svcctl list' parameter is explcitly set in smb.conf (This used to be commit 6c4ede6cee7e1d25a6357e959972e8d390c27fe3) --- source3/rpc_server/srv_svcctl_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 049bdf6075..a0b8b66f50 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -72,7 +72,7 @@ BOOL init_service_op_table( void ) /* services listed in smb.conf get the rc.init interface */ - for ( i=0; service_list[i]; i++ ) { + for ( i=0; service_list && service_list[i]; i++ ) { svcctl_ops[i].name = talloc_strdup( svcctl_ops, service_list[i] ); svcctl_ops[i].ops = &rcinit_svc_ops; } -- cgit From 86358fc10bb02bd3069736bedb120f52fa3f6494 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 8 Feb 2006 22:16:03 +0000 Subject: r13396: Add in userinfo26, re-enable userinfo25 - took the knowledge from Samba4 on how to decode the 532 byte password buffers. Getting closer to passing samba4 RPC-SCHANNEL test. Jeremy. (This used to be commit 205db6968a26c43dec64c14d8053d8e66807086f) --- source3/rpc_server/srv_samr_nt.c | 50 +++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 81344cdc1e..52f922b924 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3316,27 +3316,27 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE break; case 25: -#if 0 - /* - * Currently we don't really know how to unmarshall - * the level 25 struct, and the password encryption - * is different. This is a placeholder for when we - * do understand it. In the meantime just return INVALID - * info level and W2K SP2 drops down to level 23... JRA. - */ - if (!p->session_key.length) { r_u->status = NT_STATUS_NO_USER_SESSION_KEY; } - SamOEMhashBlob(ctr->info.id25->pass, 532, &p->session_key); + encode_or_decode_arc4_passwd_buffer(ctr->info.id25->pass, &p->session_key); dump_data(100, (char *)ctr->info.id25->pass, 532); - if (!set_user_info_pw(ctr->info.id25->pass, &sid)) + if (!set_user_info_pw(ctr->info.id25->pass, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; break; -#endif - r_u->status = NT_STATUS_INVALID_INFO_CLASS; + + case 26: + if (!p->session_key.length) { + r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + } + encode_or_decode_arc4_passwd_buffer(ctr->info.id26->pass, &p->session_key); + + dump_data(100, (char *)ctr->info.id26->pass, 516); + + if (!set_user_info_pw(ctr->info.id26->pass, pwd)) + r_u->status = NT_STATUS_ACCESS_DENIED; break; case 23: @@ -3432,7 +3432,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); } - DEBUG(5, ("_samr_set_userinfo: %s does%s possess sufficient rights\n", + DEBUG(5, ("_samr_set_userinfo2: %s does%s possess sufficient rights\n", p->pipe_user_name, has_enough_rights ? "" : " not")); /* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */ @@ -3464,6 +3464,28 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ if (!set_user_info_21(ctr->info.id21, pwd)) return NT_STATUS_ACCESS_DENIED; break; + case 23: + if (!p->session_key.length) { + r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + } + SamOEMhashBlob(ctr->info.id23->pass, 516, &p->session_key); + + dump_data(100, (char *)ctr->info.id23->pass, 516); + + if (!set_user_info_23(ctr->info.id23, pwd)) + r_u->status = NT_STATUS_ACCESS_DENIED; + break; + case 26: + if (!p->session_key.length) { + r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + } + encode_or_decode_arc4_passwd_buffer(ctr->info.id26->pass, &p->session_key); + + dump_data(100, (char *)ctr->info.id26->pass, 516); + + if (!set_user_info_pw(ctr->info.id26->pass, pwd)) + r_u->status = NT_STATUS_ACCESS_DENIED; + break; default: r_u->status = NT_STATUS_INVALID_INFO_CLASS; } -- cgit From cf7c47aac990f67e1829a7e4b9d3550b7e93739b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 9 Feb 2006 00:23:40 +0000 Subject: r13399: Get closer to passing RPC-SCHANNEL test. Jeremy. (This used to be commit 8ae70122b79fbe682c227ec2c4e5a72bf58d76de) --- source3/rpc_server/srv_netlog.c | 8 ++++---- source3/rpc_server/srv_netlog_nt.c | 14 +++++++++----- source3/rpc_server/srv_samr_nt.c | 5 +++++ 3 files changed, 18 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index a45a7eebf6..567028eec4 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -197,10 +197,10 @@ static BOOL api_net_sam_logon(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!net_io_q_sam_logon("", &q_u, data, 0)) { - DEBUG(0, ("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n")); - return False; - } + if(!net_io_q_sam_logon("", &q_u, data, 0)) { + DEBUG(0, ("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n")); + return False; + } r_u.status = _net_sam_logon(p, &q_u, &r_u); diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index fd78f954cc..d6ec31a985 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -473,7 +473,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * DEBUG(2,("_net_srv_pwset: creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", p->dc->remote_machine, p->dc->mach_acct )); - return NT_STATUS_ACCESS_DENIED; + return NT_STATUS_INVALID_PARAMETER; } DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); @@ -573,7 +573,7 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF DEBUG(2,("_net_sam_logoff: creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", p->dc->remote_machine, p->dc->mach_acct )); - return NT_STATUS_ACCESS_DENIED; + return NT_STATUS_INVALID_PARAMETER; } r_u->status = NT_STATUS_OK; @@ -636,9 +636,13 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * /* store the user information, if there is any. */ r_u->user = usr_info; - r_u->switch_value = 0; /* indicates no info */ r_u->auth_resp = 1; /* authoritative response */ - r_u->switch_value = 3; /* indicates type of validation user info */ + if (q_u->validation_level != 2 && q_u->validation_level != 3) { + DEBUG(0,("_net_sam_logon: bad validation_level value %d.\n", (int)q_u->validation_level )); + return NT_STATUS_ACCESS_DENIED; + } + /* We handle the return of USER_INFO_2 instead of 3 in the parse return. Sucks, I know... */ + r_u->switch_value = q_u->validation_level; /* indicates type of validation user info */ r_u->buffer_creds = 1; /* Ensure we always return server creds. */ if (!get_valid_user_struct(p->vuid)) @@ -662,7 +666,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * DEBUG(2,("_net_sam_logon: creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", p->dc->remote_machine, p->dc->mach_acct )); - return NT_STATUS_ACCESS_DENIED; + return NT_STATUS_INVALID_PARAMETER; } /* find the username */ diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 52f922b924..bf0e2ba070 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2537,6 +2537,11 @@ NTSTATUS _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CO was observed from a win98 client trying to enumerate users (when configured user level access control on shares) --jerry */ + if (des_access == MAXIMUM_ALLOWED_ACCESS) { + /* Map to max possible knowing we're filtered below. */ + des_access = GENERIC_ALL_ACCESS; + } + se_map_generic( &des_access, &sam_generic_mapping ); info->acc_granted = des_access & (SA_RIGHT_SAM_ENUM_DOMAINS|SA_RIGHT_SAM_OPEN_DOMAIN); -- cgit From ad8b47a2ba4e81420bc2272e8438a727cc2223ee Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 9 Feb 2006 07:03:23 +0000 Subject: r13407: Change the credentials code to be more like the Samba4 structure, makes fixes much easier to port. Fix the size of dc->sess_key to be 16 bytes, not 8 bytes - only store 8 bytes in the inter-smbd store in secrets.tdb though. Should fix some uses of the dc->sess_key where we where assuming we could read 16 bytes. Jeremy. (This used to be commit 5b3c2e63c73fee8949108abe19ac7a448a033a7f) --- source3/rpc_server/srv_netlog_nt.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index d6ec31a985..784f733617 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -817,7 +817,6 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * fstring group_sid_string; uchar user_session_key[16]; uchar lm_session_key[16]; - uchar netlogon_sess_key[16]; sampw = server_info->sam_account; @@ -859,23 +858,20 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return status; } - ZERO_STRUCT(netlogon_sess_key); - memcpy(netlogon_sess_key, p->dc->sess_key, 8); if (server_info->user_session_key.length) { memcpy(user_session_key, server_info->user_session_key.data, MIN(sizeof(user_session_key), server_info->user_session_key.length)); - SamOEMhash(user_session_key, netlogon_sess_key, 16); + SamOEMhash(user_session_key, p->dc->sess_key, 16); } if (server_info->lm_session_key.length) { memcpy(lm_session_key, server_info->lm_session_key.data, MIN(sizeof(lm_session_key), server_info->lm_session_key.length)); - SamOEMhash(lm_session_key, netlogon_sess_key, 16); + SamOEMhash(lm_session_key, p->dc->sess_key, 16); } - ZERO_STRUCT(netlogon_sess_key); init_net_user_info3(p->mem_ctx, usr_info, user_rid, -- cgit From 4d2b4c92d25c9c06be1ba84da5e2c9bfa4209a30 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 10 Feb 2006 18:05:55 +0000 Subject: r13434: Add stub for NET_SAM_LOGON_EX. Jeremy. (This used to be commit 58544eb3c848e1dddd774270fbaae7d704a37b53) --- source3/rpc_server/srv_netlog.c | 34 +++++++++++++++++++++++++++++++++- source3/rpc_server/srv_netlog_nt.c | 10 ++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 567028eec4..78ffb2e9f1 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -210,7 +210,7 @@ static BOOL api_net_sam_logon(pipes_struct *p) return False; } - return True; + return True; } /************************************************************************* @@ -306,6 +306,37 @@ static BOOL api_net_logon_ctrl(pipes_struct *p) return True; } +/************************************************************************* + api_net_sam_logon_ex: + *************************************************************************/ + +static BOOL api_net_sam_logon_ex(pipes_struct *p) +{ + NET_Q_SAM_LOGON_EX q_u; + NET_R_SAM_LOGON_EX r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if(!net_io_q_sam_logon_ex("", &q_u, data, 0)) { + DEBUG(0, ("api_net_sam_logon_ex: Failed to unmarshall NET_Q_SAM_LOGON_EX.\n")); + return False; + } + + r_u.status = _net_sam_logon_ex(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!net_io_r_sam_logon_ex("", &r_u, rdata, 0)) { + DEBUG(0,("api_net_sam_logon_ex: Failed to marshall NET_R_SAM_LOGON_EX.\n")); + return False; + } + + return True; +} + + /************************************************************************* api_ds_enum_dom_trusts: *************************************************************************/ @@ -356,6 +387,7 @@ static struct api_struct api_net_cmds [] = { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 }, { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl }, + { "NET_SAMLOGON_EX" , NET_SAMLOGON_EX , api_net_sam_logon_ex }, #if 0 /* JERRY */ { "DS_ENUM_DOM_TRUSTS", DS_ENUM_DOM_TRUSTS, api_ds_enum_dom_trusts } #endif /* JERRY */ diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 784f733617..0bd9d9bc7d 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -906,6 +906,16 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return status; } +/************************************************************************* + _net_sam_logon_ex + *************************************************************************/ + +NTSTATUS _net_sam_logon_ex(pipes_struct *p, NET_Q_SAM_LOGON_EX *q_u, NET_R_SAM_LOGON_EX *r_u) +{ + setup_fault_pdu(p, NT_STATUS(0x1c010002)); + return NT_STATUS(0x1c010002); +} + /************************************************************************* _ds_enum_dom_trusts *************************************************************************/ -- cgit From e19ae285813e2e00d97f6b1c01a135935aa43fdc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 10 Feb 2006 18:51:18 +0000 Subject: r13436: Add in NET_SAM_LOGON_EX. Still needs testing. Jeremy (This used to be commit f58d0ebf749ad6dab562e74e9fd2c16606183d6c) --- source3/rpc_server/srv_netlog_nt.c | 66 +++++++++++++++++++++++++++++++------- 1 file changed, 54 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 0bd9d9bc7d..39f2f4a09c 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -614,7 +614,10 @@ static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, _net_sam_logon *************************************************************************/ -NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_u) +static NTSTATUS _net_sam_logon_internal(pipes_struct *p, + NET_Q_SAM_LOGON *q_u, + NET_R_SAM_LOGON *r_u, + BOOL process_creds) { NTSTATUS status = NT_STATUS_OK; NET_USER_INFO_3 *usr_info = NULL; @@ -648,8 +651,10 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; - if (!p->dc || !p->dc->authenticated) { - return NT_STATUS_INVALID_HANDLE; + if (process_creds) { + if (!p->dc || !p->dc->authenticated) { + return NT_STATUS_INVALID_HANDLE; + } } if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { @@ -661,12 +666,14 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * return NT_STATUS_ACCESS_DENIED; } - /* checks and updates credentials. creates reply credentials */ - if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { - DEBUG(2,("_net_sam_logon: creds_server_step failed. Rejecting auth " - "request from client %s machine account %s\n", - p->dc->remote_machine, p->dc->mach_acct )); - return NT_STATUS_INVALID_PARAMETER; + if (process_creds) { + /* checks and updates credentials. creates reply credentials */ + if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { + DEBUG(2,("_net_sam_logon: creds_server_step failed. Rejecting auth " + "request from client %s machine account %s\n", + p->dc->remote_machine, p->dc->mach_acct )); + return NT_STATUS_INVALID_PARAMETER; + } } /* find the username */ @@ -907,13 +914,48 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * } /************************************************************************* - _net_sam_logon_ex + _net_sam_logon + *************************************************************************/ + +NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_u) +{ + return _net_sam_logon_internal(p, q_u, r_u, True); +} + +/************************************************************************* + _net_sam_logon_ex - no credential chaining. Map into net sam logon. *************************************************************************/ NTSTATUS _net_sam_logon_ex(pipes_struct *p, NET_Q_SAM_LOGON_EX *q_u, NET_R_SAM_LOGON_EX *r_u) { - setup_fault_pdu(p, NT_STATUS(0x1c010002)); - return NT_STATUS(0x1c010002); + NET_Q_SAM_LOGON q; + NET_R_SAM_LOGON r; + + ZERO_STRUCT(q); + ZERO_STRUCT(r); + + /* Only allow this if the pipe is protected. */ + /* FIXME ! */ + + /* Map a NET_Q_SAM_LOGON_EX to NET_Q_SAM_LOGON. */ + q.validation_level = q_u->validation_level; + + /* Map a DOM_SAM_INFO_EX into a DOM_SAM_INFO with no creds. */ + q.sam_id.logon_level = q_u->sam_id.logon_level; + q.sam_id.ctr = q_u->sam_id.ctr; + + r_u->status = _net_sam_logon_internal(p, &q, &r, False); + + if (!NT_STATUS_IS_OK(r_u->status)) { + return r_u->status; + } + + /* Map the NET_R_SAM_LOGON to NET_R_SAM_LOGON_EX. */ + r_u->switch_value = r.switch_value; + r_u->user = r.user; + r_u->auth_resp = r.auth_resp; + r_u->flags = 0; /* FIXME ! */ + return r_u->status; } /************************************************************************* -- cgit From e493d329122e16a70f9f858aaa9ba51d20eba3c7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 10 Feb 2006 19:16:50 +0000 Subject: r13439: Fix NET_SAM_LOGON_EX. Jeremy. (This used to be commit 9437ffc84f4d924ab67f3e16ef507d2aeeeb5f34) --- source3/rpc_server/srv_netlog_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 39f2f4a09c..9c7f17c14f 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -941,6 +941,7 @@ NTSTATUS _net_sam_logon_ex(pipes_struct *p, NET_Q_SAM_LOGON_EX *q_u, NET_R_SAM_L q.validation_level = q_u->validation_level; /* Map a DOM_SAM_INFO_EX into a DOM_SAM_INFO with no creds. */ + q.sam_id.client.login = q_u->sam_id.client; q.sam_id.logon_level = q_u->sam_id.logon_level; q.sam_id.ctr = q_u->sam_id.ctr; -- cgit From e83c7d0141c0726a74c7be48914e94bac7167ab1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 10 Feb 2006 23:09:00 +0000 Subject: r13442: Implement samr_chgpasswd_user3 server-side. Guenther (This used to be commit f60eddc0a4dfe623e5f115533a62c03810fd5f38) --- source3/rpc_server/srv_samr.c | 32 ++++++++++++ source3/rpc_server/srv_samr_nt.c | 105 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 130 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index e8fd86ba46..015ed6c5ea 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -679,6 +679,37 @@ static BOOL api_samr_connect4(pipes_struct *p) return True; } +/******************************************************************* + api_samr_chgpasswd_user3 + ********************************************************************/ + +static BOOL api_samr_chgpasswd_user3(pipes_struct *p) +{ + SAMR_Q_CHGPASSWD_USER3 q_u; + SAMR_R_CHGPASSWD_USER3 r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* change password request */ + if (!samr_io_q_chgpasswd_user3("", &q_u, data, 0)) { + DEBUG(0,("api_samr_chgpasswd_user3: Failed to unmarshall SAMR_Q_CHGPASSWD_USER3.\n")); + return False; + } + + r_u.status = _samr_chgpasswd_user3(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!samr_io_r_chgpasswd_user3("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_chgpasswd_user3: Failed to marshall SAMR_R_CHGPASSWD_USER3.\n" )); + return False; + } + + return True; +} + /******************************************************************* api_samr_connect5 ********************************************************************/ @@ -1524,6 +1555,7 @@ static struct api_struct api_samr_cmds [] = {"SAMR_QUERY_DOMAIN_INFO2", SAMR_QUERY_DOMAIN_INFO2, api_samr_query_domain_info2}, {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, {"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 }, + {"SAMR_CHGPASSWD_USER3" , SAMR_CHGPASSWD_USER3 , api_samr_chgpasswd_user3 }, {"SAMR_CONNECT5" , SAMR_CONNECT5 , api_samr_connect5 } }; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index bf0e2ba070..75a72fa028 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1462,7 +1462,7 @@ NTSTATUS _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_ */ r_u->status = pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, - q_u->nt_newpass.pass, q_u->nt_oldhash.hash); + q_u->nt_newpass.pass, q_u->nt_oldhash.hash, NULL); init_samr_r_chgpasswd_user(r_u, r_u->status); @@ -1471,6 +1471,97 @@ NTSTATUS _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_ return r_u->status; } +/******************************************************************* + _samr_chgpasswd_user3 + ********************************************************************/ + +NTSTATUS _samr_chgpasswd_user3(pipes_struct *p, SAMR_Q_CHGPASSWD_USER3 *q_u, SAMR_R_CHGPASSWD_USER3 *r_u) +{ + fstring user_name; + fstring wks; + uint32 reject_reason; + SAM_UNK_INFO_1 *info = NULL; + SAMR_CHANGE_REJECT *reject = NULL; + + DEBUG(5,("_samr_chgpasswd_user3: %d\n", __LINE__)); + + rpcstr_pull(user_name, q_u->uni_user_name.buffer, sizeof(user_name), q_u->uni_user_name.uni_str_len*2, 0); + rpcstr_pull(wks, q_u->uni_dest_host.buffer, sizeof(wks), q_u->uni_dest_host.uni_str_len*2,0); + + DEBUG(5,("_samr_chgpasswd_user3: user: %s wks: %s\n", user_name, wks)); + + /* + * Pass the user through the NT -> unix user mapping + * function. + */ + + (void)map_username(user_name); + + /* + * UNIX username case mangling not required, pass_oem_change + * is case insensitive. + */ + + r_u->status = pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, + q_u->nt_newpass.pass, q_u->nt_oldhash.hash, &reject_reason); + + if (NT_STATUS_EQUAL(r_u->status, NT_STATUS_PASSWORD_RESTRICTION)) { + + uint32 min_pass_len,pass_hist,password_properties; + time_t u_expire, u_min_age; + NTTIME nt_expire, nt_min_age; + uint32 account_policy_temp; + + if ((info = TALLOC_ZERO_P(p->mem_ctx, SAM_UNK_INFO_1)) == NULL) { + return NT_STATUS_NO_MEMORY; + } + + if ((reject = TALLOC_ZERO_P(p->mem_ctx, SAMR_CHANGE_REJECT)) == NULL) { + return NT_STATUS_NO_MEMORY; + } + + ZERO_STRUCTP(info); + ZERO_STRUCTP(reject); + + become_root(); + + /* AS ROOT !!! */ + + pdb_get_account_policy(AP_MIN_PASSWORD_LEN, &account_policy_temp); + min_pass_len = account_policy_temp; + + pdb_get_account_policy(AP_PASSWORD_HISTORY, &account_policy_temp); + pass_hist = account_policy_temp; + + pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); + password_properties = account_policy_temp; + + pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &account_policy_temp); + u_expire = account_policy_temp; + + pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &account_policy_temp); + u_min_age = account_policy_temp; + + /* !AS ROOT */ + + unbecome_root(); + + unix_to_nt_time_abs(&nt_expire, u_expire); + unix_to_nt_time_abs(&nt_min_age, u_min_age); + + init_unk_info1(info, (uint16)min_pass_len, (uint16)pass_hist, + password_properties, nt_expire, nt_min_age); + + reject->reject_reason = reject_reason; + } + + init_samr_r_chgpasswd_user3(r_u, r_u->status, reject, info); + + DEBUG(5,("_samr_chgpasswd_user3: %d\n", __LINE__)); + + return r_u->status; +} + /******************************************************************* makes a SAMR_R_LOOKUP_RIDS structure. ********************************************************************/ @@ -2090,7 +2181,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA { struct samr_info *info = NULL; SAM_UNK_CTR *ctr; - uint32 min_pass_len,pass_hist,flag; + uint32 min_pass_len,pass_hist,password_properties; time_t u_expire, u_min_age; NTTIME nt_expire, nt_min_age; @@ -2136,7 +2227,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA pass_hist = account_policy_temp; pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); - flag = account_policy_temp; + password_properties = account_policy_temp; pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &account_policy_temp); u_expire = account_policy_temp; @@ -2152,7 +2243,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA unix_to_nt_time_abs(&nt_min_age, u_min_age); init_unk_info1(&ctr->info.inf1, (uint16)min_pass_len, (uint16)pass_hist, - flag, nt_expire, nt_min_age); + password_properties, nt_expire, nt_min_age); break; case 0x02: @@ -4815,7 +4906,7 @@ NTSTATUS _samr_query_domain_info2(pipes_struct *p, { struct samr_info *info = NULL; SAM_UNK_CTR *ctr; - uint32 min_pass_len,pass_hist,flag; + uint32 min_pass_len,pass_hist,password_properties; time_t u_expire, u_min_age; NTTIME nt_expire, nt_min_age; @@ -4855,7 +4946,7 @@ NTSTATUS _samr_query_domain_info2(pipes_struct *p, pass_hist = account_policy_temp; pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); - flag = account_policy_temp; + password_properties = account_policy_temp; pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &account_policy_temp); u_expire = account_policy_temp; @@ -4867,7 +4958,7 @@ NTSTATUS _samr_query_domain_info2(pipes_struct *p, unix_to_nt_time_abs(&nt_min_age, u_min_age); init_unk_info1(&ctr->info.inf1, (uint16)min_pass_len, (uint16)pass_hist, - flag, nt_expire, nt_min_age); + password_properties, nt_expire, nt_min_age); break; case 0x02: become_root(); -- cgit From 72b30eba6463cd4479b4f2c5076209bf77e4fc57 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 10 Feb 2006 23:41:41 +0000 Subject: r13444: Add REJECT_REASON_OTHER for samr_chgpasswd_user3 Guenther (This used to be commit 58baf718be90d750f51cf51a25714fcdcd5679b7) --- source3/rpc_server/srv_samr_nt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 75a72fa028..b3be0cccc1 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1505,7 +1505,8 @@ NTSTATUS _samr_chgpasswd_user3(pipes_struct *p, SAMR_Q_CHGPASSWD_USER3 *q_u, SAM r_u->status = pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, q_u->nt_newpass.pass, q_u->nt_oldhash.hash, &reject_reason); - if (NT_STATUS_EQUAL(r_u->status, NT_STATUS_PASSWORD_RESTRICTION)) { + if (NT_STATUS_EQUAL(r_u->status, NT_STATUS_PASSWORD_RESTRICTION) || + NT_STATUS_EQUAL(r_u->status, NT_STATUS_ACCOUNT_RESTRICTION)) { uint32 min_pass_len,pass_hist,password_properties; time_t u_expire, u_min_age; -- cgit From 06cf1e18e562cf350e657c69e38a40b7f2bbf697 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 10 Feb 2006 23:52:53 +0000 Subject: r13447: Added LSA_LOOKUPSIDS2 and LSA_LOOKUPSIDS3. Jeremy. (This used to be commit a164cfab420a2439dad8fd85f8b4d652087fa6b9) --- source3/rpc_server/srv_lsa.c | 64 +++++++- source3/rpc_server/srv_lsa_nt.c | 298 +++++++++++++++++++++++++++++-------- source3/rpc_server/srv_netlog_nt.c | 6 +- 3 files changed, 301 insertions(+), 67 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index fc84dbe923..0818ba3eac 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -916,6 +916,66 @@ static BOOL api_lsa_delete_object(pipes_struct *p) return True; } +/*************************************************************************** + api_lsa_lookup_sids2 + ***************************************************************************/ + +static BOOL api_lsa_lookup_sids2(pipes_struct *p) +{ + LSA_Q_LOOKUP_SIDS2 q_u; + LSA_R_LOOKUP_SIDS2 r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the info class and policy handle */ + if(!lsa_io_q_lookup_sids2("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_lookup_sids2: failed to unmarshall LSA_Q_LOOKUP_SIDS2.\n")); + return False; + } + + r_u.status = _lsa_lookup_sids2(p, &q_u, &r_u); + + if(!lsa_io_r_lookup_sids2("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_lookup_sids2: Failed to marshall LSA_R_LOOKUP_SIDS2.\n")); + return False; + } + + return True; +} + +/*************************************************************************** + api_lsa_lookup_sids3 + ***************************************************************************/ + +static BOOL api_lsa_lookup_sids3(pipes_struct *p) +{ + LSA_Q_LOOKUP_SIDS3 q_u; + LSA_R_LOOKUP_SIDS3 r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the info class and policy handle */ + if(!lsa_io_q_lookup_sids3("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_lookup_sids3: failed to unmarshall LSA_Q_LOOKUP_SIDS3.\n")); + return False; + } + + r_u.status = _lsa_lookup_sids3(p, &q_u, &r_u); + + if(!lsa_io_r_lookup_sids3("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_lookup_sids3: Failed to marshall LSA_R_LOOKUP_SIDS3.\n")); + return False; + } + + return True; +} + #if 0 /* AD DC work in ongoing in Samba 4 */ /*************************************************************************** @@ -984,7 +1044,9 @@ static struct api_struct api_lsa_cmds[] = { "LSA_CREATETRUSTDOM" , LSA_CREATETRUSTDOM , api_lsa_create_trust_dom }, { "LSA_CREATSECRET" , LSA_CREATESECRET , api_lsa_create_secret }, { "LSA_SETSECRET" , LSA_SETSECRET , api_lsa_set_secret }, - { "LSA_DELETEOBJECT" , LSA_DELETEOBJECT , api_lsa_delete_object } + { "LSA_DELETEOBJECT" , LSA_DELETEOBJECT , api_lsa_delete_object }, + { "LSA_LOOKUPSIDS2" , LSA_LOOKUPSIDS2 , api_lsa_lookup_sids2 }, + { "LSA_LOOKUPSIDS3" , LSA_LOOKUPSIDS3 , api_lsa_lookup_sids3 } #if 0 /* AD DC work in ongoing in Samba 4 */ /* be careful of the adding of new RPC's. See commentrs below about ADS DC capabilities */ diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c93107cec4..d13ddf387a 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -229,9 +229,10 @@ static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, Init_reply_lookup_sids. ***************************************************************************/ -static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, - DOM_R_REF *ref, LSA_TRANS_NAME_ENUM *names, - uint32 mapped_count) +static void init_reply_lookup_sids2(LSA_R_LOOKUP_SIDS2 *r_l, + DOM_R_REF *ref, + LSA_TRANS_NAME_ENUM2 *names, + uint32 mapped_count) { r_l->ptr_dom_ref = ref ? 1 : 0; r_l->dom_ref = ref; @@ -239,6 +240,64 @@ static void init_reply_lookup_sids(LSA_R_LOOKUP_SIDS *r_l, r_l->mapped_count = mapped_count; } +/*************************************************************************** + Init_reply_lookup_sids. + ***************************************************************************/ + +static void init_reply_lookup_sids3(LSA_R_LOOKUP_SIDS3 *r_l, + DOM_R_REF *ref, + LSA_TRANS_NAME_ENUM2 *names, + uint32 mapped_count) +{ + r_l->ptr_dom_ref = ref ? 1 : 0; + r_l->dom_ref = ref; + r_l->names = names; + r_l->mapped_count = mapped_count; +} + +/*************************************************************************** + Init_reply_lookup_sids. + ***************************************************************************/ + +static NTSTATUS init_reply_lookup_sids(TALLOC_CTX *mem_ctx, + LSA_R_LOOKUP_SIDS *r_l, + DOM_R_REF *ref, + LSA_TRANS_NAME_ENUM2 *names, + uint32 mapped_count) +{ + LSA_TRANS_NAME_ENUM *oldnames = TALLOC_ZERO_P(mem_ctx, LSA_TRANS_NAME_ENUM); + + if (!oldnames) { + return NT_STATUS_NO_MEMORY; + } + + oldnames->num_entries = names->num_entries; + oldnames->ptr_trans_names = names->ptr_trans_names; + oldnames->num_entries2 = names->num_entries2; + oldnames->uni_name = names->uni_name; + + if (names->num_entries) { + int i; + + oldnames->name = TALLOC_ARRAY(oldnames, LSA_TRANS_NAME, names->num_entries); + + if (!oldnames->name) { + return NT_STATUS_NO_MEMORY; + } + for (i = 0; i < names->num_entries; i++) { + oldnames->name[i].sid_name_use = names->name[i].sid_name_use; + oldnames->name[i].hdr_name = names->name[i].hdr_name; + oldnames->name[i].domain_idx = names->name[i].domain_idx; + } + } + + r_l->ptr_dom_ref = ref ? 1 : 0; + r_l->dom_ref = ref; + r_l->names = oldnames; + r_l->mapped_count = mapped_count; + return NT_STATUS_OK; +} + static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *sd_size) { DOM_SID local_adm_sid; @@ -583,77 +642,54 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF } /*************************************************************************** - _lsa_lookup_sids + _lsa_lookup_sids_internal ***************************************************************************/ -NTSTATUS _lsa_lookup_sids(pipes_struct *p, - LSA_Q_LOOKUP_SIDS *q_u, - LSA_R_LOOKUP_SIDS *r_u) +static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, + uint16 level, /* input */ + int num_sids, /* input */ + const DOM_SID2 *sid, /* input */ + DOM_R_REF **pp_ref, /* output */ + LSA_TRANS_NAME_ENUM2 **pp_names, /* output */ + uint32 *pp_mapped_count) { - struct lsa_info *handle; - - int i, num_sids; - const DOM_SID **sids; - uint32 mapped_count = 0; - - struct lsa_dom_info *dom_infos; - struct lsa_name_info *name_infos; - + NTSTATUS status; + int i; + const DOM_SID **sids = NULL; + LSA_TRANS_NAME_ENUM2 *names = NULL; DOM_R_REF *ref = NULL; - LSA_TRANS_NAME_ENUM *names = NULL; - - names = TALLOC_ZERO_P(p->mem_ctx, LSA_TRANS_NAME_ENUM); - - if ((q_u->level < 1) || (q_u->level > 6)) { - r_u->status = NT_STATUS_INVALID_PARAMETER; - goto done; - } - - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { - r_u->status = NT_STATUS_INVALID_HANDLE; - goto done; - } - - /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { - r_u->status = NT_STATUS_ACCESS_DENIED; - goto done; - } - - num_sids = q_u->sids.num_entries; - if (num_sids > MAX_LOOKUP_SIDS) { - DEBUG(5,("_lsa_lookup_sids: limit of %d exceeded, truncating " - "SID lookup list to %d\n", - MAX_LOOKUP_SIDS, num_sids)); - r_u->status = NT_STATUS_NONE_MAPPED; - goto done; - } + uint32 mapped_count = 0; + struct lsa_dom_info *dom_infos = NULL; + struct lsa_name_info *name_infos = NULL; + *pp_mapped_count = 0; + *pp_ref = NULL; + *pp_names = NULL; + + names = TALLOC_ZERO_P(p->mem_ctx, LSA_TRANS_NAME_ENUM2); + sids = TALLOC_ARRAY(p->mem_ctx, const DOM_SID *, num_sids); ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - sids = TALLOC_ARRAY(p->mem_ctx, const DOM_SID *, num_sids); - if ((ref == NULL) || (names == NULL) || (sids == NULL)) { - r_u->status = NT_STATUS_NO_MEMORY; - goto done; + if (sids == NULL || names == NULL || ref == NULL) { + return NT_STATUS_NO_MEMORY; } for (i=0; isids.sid[i].sid; + sids[i] = &sid[i].sid; } - r_u->status = lookup_sids(p->mem_ctx, num_sids, sids, q_u->level, + status = lookup_sids(p->mem_ctx, num_sids, sids, level, &dom_infos, &name_infos); - if (!NT_STATUS_IS_OK(r_u->status)) { - goto done; + if (!NT_STATUS_IS_OK(status)) { + return status; } if (num_sids > 0) { - names->name = TALLOC_ARRAY(names, LSA_TRANS_NAME, num_sids); + names->name = TALLOC_ARRAY(names, LSA_TRANS_NAME2, num_sids); names->uni_name = TALLOC_ARRAY(names, UNISTR2, num_sids); if ((names->name == NULL) || (names->uni_name == NULL)) { - r_u->status = NT_STATUS_NO_MEMORY; - goto done; + return NT_STATUS_NO_MEMORY; } } @@ -667,8 +703,7 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, &dom_infos[i].sid) != i) { DEBUG(0, ("Domain %s mentioned twice??\n", dom_infos[i].name)); - r_u->status = NT_STATUS_INTERNAL_ERROR; - goto done; + return NT_STATUS_INTERNAL_ERROR; } } @@ -680,13 +715,12 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, name->name = talloc_asprintf(p->mem_ctx, "%8.8x", name->rid); if (name->name == NULL) { - r_u->status = NT_STATUS_NO_MEMORY; - goto done; + return NT_STATUS_NO_MEMORY; } } else { mapped_count += 1; } - init_lsa_trans_name(&names->name[i], &names->uni_name[i], + init_lsa_trans_name2(&names->name[i], &names->uni_name[i], name->type, name->name, name->dom_idx); } @@ -694,18 +728,152 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, names->ptr_trans_names = 1; names->num_entries2 = num_sids; - r_u->status = NT_STATUS_NONE_MAPPED; + status = NT_STATUS_NONE_MAPPED; if (mapped_count > 0) { - r_u->status = (mapped_count < num_sids) ? + status = (mapped_count < num_sids) ? STATUS_SOME_UNMAPPED : NT_STATUS_OK; } DEBUG(10, ("num_sids %d, mapped_count %d, status %s\n", - num_sids, mapped_count, nt_errstr(r_u->status))); + num_sids, mapped_count, nt_errstr(status))); + + *pp_mapped_count = mapped_count; + *pp_ref = ref; + *pp_names = names; + + return status; +} + +/*************************************************************************** + _lsa_lookup_sids + ***************************************************************************/ + +NTSTATUS _lsa_lookup_sids(pipes_struct *p, + LSA_Q_LOOKUP_SIDS *q_u, + LSA_R_LOOKUP_SIDS *r_u) +{ + struct lsa_info *handle; + int num_sids = q_u->sids.num_entries; + uint32 mapped_count = 0; + DOM_R_REF *ref = NULL; + LSA_TRANS_NAME_ENUM2 *names = NULL; + NTSTATUS status; + + if ((q_u->level < 1) || (q_u->level > 6)) { + return NT_STATUS_INVALID_PARAMETER; + } + + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { + return NT_STATUS_INVALID_HANDLE; + } + + /* check if the user has enough rights */ + if (!(handle->access & POLICY_LOOKUP_NAMES)) { + return NT_STATUS_ACCESS_DENIED; + } + + if (num_sids > MAX_LOOKUP_SIDS) { + DEBUG(5,("_lsa_lookup_sids: limit of %d exceeded, requested %d\n", + MAX_LOOKUP_SIDS, num_sids)); + return NT_STATUS_NONE_MAPPED; + } + + r_u->status = _lsa_lookup_sids_internal(p, + q_u->level, + num_sids, + q_u->sids.sid, + &ref, + &names, + &mapped_count); + + /* Convert from LSA_TRANS_NAME_ENUM2 to LSA_TRANS_NAME_ENUM */ + + status = init_reply_lookup_sids(p->mem_ctx, r_u, ref, names, mapped_count); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + return r_u->status; +} + +/*************************************************************************** + _lsa_lookup_sids2 + ***************************************************************************/ + +NTSTATUS _lsa_lookup_sids2(pipes_struct *p, + LSA_Q_LOOKUP_SIDS2 *q_u, + LSA_R_LOOKUP_SIDS2 *r_u) +{ + struct lsa_info *handle; + int num_sids = q_u->sids.num_entries; + uint32 mapped_count = 0; + DOM_R_REF *ref = NULL; + LSA_TRANS_NAME_ENUM2 *names = NULL; + + if ((q_u->level < 1) || (q_u->level > 6)) { + return NT_STATUS_INVALID_PARAMETER; + } + + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { + return NT_STATUS_INVALID_HANDLE; + } + + /* check if the user have enough rights */ + if (!(handle->access & POLICY_LOOKUP_NAMES)) { + return NT_STATUS_ACCESS_DENIED; + } + + if (num_sids > MAX_LOOKUP_SIDS) { + DEBUG(5,("_lsa_lookup_sids2: limit of %d exceeded, requested %d\n", + MAX_LOOKUP_SIDS, num_sids)); + return NT_STATUS_NONE_MAPPED; + } + + r_u->status = _lsa_lookup_sids_internal(p, + q_u->level, + num_sids, + q_u->sids.sid, + &ref, + &names, + &mapped_count); + + init_reply_lookup_sids2(r_u, ref, names, mapped_count); + return r_u->status; +} + +/*************************************************************************** + _lsa_lookup_sida3 + ***************************************************************************/ + +NTSTATUS _lsa_lookup_sids3(pipes_struct *p, + LSA_Q_LOOKUP_SIDS3 *q_u, + LSA_R_LOOKUP_SIDS3 *r_u) +{ + int num_sids = q_u->sids.num_entries; + uint32 mapped_count = 0; + DOM_R_REF *ref = NULL; + LSA_TRANS_NAME_ENUM2 *names = NULL; + + if ((q_u->level < 1) || (q_u->level > 6)) { + return NT_STATUS_INVALID_PARAMETER; + } + + /* No policy handle on this call. Restrict to crypto connections. */ + + if (num_sids > MAX_LOOKUP_SIDS) { + DEBUG(5,("_lsa_lookup_sids3: limit of %d exceeded, requested %d\n", + MAX_LOOKUP_SIDS, num_sids)); + return NT_STATUS_NONE_MAPPED; + } - done: - init_reply_lookup_sids(r_u, ref, names, mapped_count); + r_u->status = _lsa_lookup_sids_internal(p, + q_u->level, + num_sids, + q_u->sids.sid, + &ref, + &names, + &mapped_count); + init_reply_lookup_sids3(r_u, ref, names, mapped_count); return r_u->status; } diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 9c7f17c14f..c21a72965d 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -935,7 +935,11 @@ NTSTATUS _net_sam_logon_ex(pipes_struct *p, NET_Q_SAM_LOGON_EX *q_u, NET_R_SAM_L ZERO_STRUCT(r); /* Only allow this if the pipe is protected. */ - /* FIXME ! */ + if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) { + DEBUG(0,("_net_sam_logon_ex: client %s not using schannel for netlogon\n", + p->dc->remote_machine )); + return NT_STATUS_INVALID_PARAMETER; + } /* Map a NET_Q_SAM_LOGON_EX to NET_Q_SAM_LOGON. */ q.validation_level = q_u->validation_level; -- cgit From acc4a837aad67e7ade0289d67d05e5d57241dce3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 11 Feb 2006 00:04:39 +0000 Subject: r13449: Ensure we don't crash if no dc struct on pipe. Jeremy. (This used to be commit a9e1d0f3b4fd7a0732a5023d0b4dcc2c4b1b03f8) --- source3/rpc_server/srv_lsa_nt.c | 5 +++++ source3/rpc_server/srv_netlog_nt.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index d13ddf387a..f7a462d2b2 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -858,6 +858,11 @@ NTSTATUS _lsa_lookup_sids3(pipes_struct *p, } /* No policy handle on this call. Restrict to crypto connections. */ + if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) { + DEBUG(0,("_lsa_lookup_sids3: client %s not using schannel for netlogon\n", + get_remote_machine_name() )); + return NT_STATUS_INVALID_PARAMETER; + } if (num_sids > MAX_LOOKUP_SIDS) { DEBUG(5,("_lsa_lookup_sids3: limit of %d exceeded, requested %d\n", diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index c21a72965d..2b98314722 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -937,7 +937,7 @@ NTSTATUS _net_sam_logon_ex(pipes_struct *p, NET_Q_SAM_LOGON_EX *q_u, NET_R_SAM_L /* Only allow this if the pipe is protected. */ if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) { DEBUG(0,("_net_sam_logon_ex: client %s not using schannel for netlogon\n", - p->dc->remote_machine )); + get_remote_machine_name() )); return NT_STATUS_INVALID_PARAMETER; } -- cgit From e22d38bddef441eaaa5b0b0c5dbc92225e20f912 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 11 Feb 2006 02:46:41 +0000 Subject: r13455: Prepare to add lookupnames2. Jeremy. (This used to be commit 2274709587bd1f27bea2eacf633182f20cd07b1e) --- source3/rpc_server/srv_lsa_nt.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f7a462d2b2..78461008a8 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -131,11 +131,11 @@ static int init_dom_ref(DOM_R_REF *ref, const char *dom_name, DOM_SID *dom_sid) } /*************************************************************************** - init_lsa_rid2s + init_lsa_rids ***************************************************************************/ -static int init_lsa_rid2s(TALLOC_CTX *mem_ctx, - DOM_R_REF *ref, DOM_RID2 *rid2, +static int init_lsa_rids(TALLOC_CTX *mem_ctx, + DOM_R_REF *ref, DOM_RID *prid, int num_entries, UNISTR2 *name, int flags) { @@ -148,7 +148,6 @@ static int init_lsa_rid2s(TALLOC_CTX *mem_ctx, become_root(); /* lookup_name can require root privs */ for (i = 0; i < num_entries; i++) { - BOOL status = False; DOM_SID sid; uint32 rid; int dom_idx; @@ -164,7 +163,7 @@ static int init_lsa_rid2s(TALLOC_CTX *mem_ctx, return 0; } - DEBUG(5, ("init_lsa_rid2s: looking up name %s\n", full_name)); + DEBUG(5, ("init_lsa_rids: looking up name %s\n", full_name)); /* We can ignore the result of lookup_name, it will not touch "type" if it's not successful */ @@ -172,8 +171,6 @@ static int init_lsa_rid2s(TALLOC_CTX *mem_ctx, lookup_name(mem_ctx, full_name, flags, &domain, NULL, &sid, &type); - DEBUG(5, ("init_lsa_rid2s: %s\n", status ? "found" : - "not found")); switch (type) { case SID_NAME_USER: @@ -181,10 +178,12 @@ static int init_lsa_rid2s(TALLOC_CTX *mem_ctx, case SID_NAME_DOMAIN: case SID_NAME_ALIAS: case SID_NAME_WKN_GRP: + DEBUG(5, ("init_lsa_rids: %s found\n", full_name)); /* Leave these unchanged */ break; default: /* Don't hand out anything but the list above */ + DEBUG(5, ("init_lsa_rids: %s not found\n", full_name)); type = SID_NAME_UNKNOWN; break; } @@ -198,7 +197,7 @@ static int init_lsa_rid2s(TALLOC_CTX *mem_ctx, mapped_count++; } - init_dom_rid2(&rid2[i], rid, type, dom_idx); + init_dom_rid(&prid[i], rid, type, dom_idx); } unbecome_root(); @@ -212,7 +211,7 @@ static int init_lsa_rid2s(TALLOC_CTX *mem_ctx, static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, DOM_R_REF *ref, uint32 num_entries, - DOM_RID2 *rid2, uint32 mapped_count) + DOM_RID *rid, uint32 mapped_count) { r_l->ptr_dom_ref = 1; r_l->dom_ref = ref; @@ -220,7 +219,7 @@ static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, r_l->num_entries = num_entries; r_l->ptr_entries = 1; r_l->num_entries2 = num_entries; - r_l->dom_rid = rid2; + r_l->dom_rid = rid; r_l->mapped_count = mapped_count; } @@ -892,7 +891,7 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP UNISTR2 *names = q_u->uni_name; int num_entries = q_u->num_entries; DOM_R_REF *ref; - DOM_RID2 *rids; + DOM_RID *rids; uint32 mapped_count = 0; int flags = 0; @@ -907,7 +906,7 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP } ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries); + rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries); if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { r_u->status = NT_STATUS_INVALID_HANDLE; @@ -924,7 +923,7 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP return NT_STATUS_NO_MEMORY; /* set up the LSA Lookup RIDs response */ - mapped_count = init_lsa_rid2s(p->mem_ctx, ref, rids, num_entries, + mapped_count = init_lsa_rids(p->mem_ctx, ref, rids, num_entries, names, flags); done: -- cgit From 785c78b79517c8b4c776abebcd4edc90141df3a2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 11 Feb 2006 04:25:06 +0000 Subject: r13456: Add lsa_lookup_names2. Jeremy. (This used to be commit b57406c89feaf550f6c2d29ef0ed73a935908add) --- source3/rpc_server/srv_lsa.c | 32 +++++++++++++++ source3/rpc_server/srv_lsa_nt.c | 89 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 0818ba3eac..e20b4e18b4 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -976,6 +976,37 @@ static BOOL api_lsa_lookup_sids3(pipes_struct *p) return True; } +/*************************************************************************** + api_lsa_lookup_names2 + ***************************************************************************/ + +static BOOL api_lsa_lookup_names2(pipes_struct *p) +{ + LSA_Q_LOOKUP_NAMES2 q_u; + LSA_R_LOOKUP_NAMES2 r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the info class and policy handle */ + if(!lsa_io_q_lookup_names2("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_lookup_names2: failed to unmarshall LSA_Q_LOOKUP_NAMES2.\n")); + return False; + } + + r_u.status = _lsa_lookup_names2(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_lookup_names2("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_lookup_names2: Failed to marshall LSA_R_LOOKUP_NAMES2.\n")); + return False; + } + + return True; +} + #if 0 /* AD DC work in ongoing in Samba 4 */ /*************************************************************************** @@ -1046,6 +1077,7 @@ static struct api_struct api_lsa_cmds[] = { "LSA_SETSECRET" , LSA_SETSECRET , api_lsa_set_secret }, { "LSA_DELETEOBJECT" , LSA_DELETEOBJECT , api_lsa_delete_object }, { "LSA_LOOKUPSIDS2" , LSA_LOOKUPSIDS2 , api_lsa_lookup_sids2 }, + { "LSA_LOOKUPNAMES2" , LSA_LOOKUPNAMES2 , api_lsa_lookup_names2 }, { "LSA_LOOKUPSIDS3" , LSA_LOOKUPSIDS3 , api_lsa_lookup_sids3 } #if 0 /* AD DC work in ongoing in Samba 4 */ /* be careful of the adding of new RPC's. See commentrs below about diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 78461008a8..200cdb8d9e 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -224,6 +224,25 @@ static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, r_l->mapped_count = mapped_count; } +/*************************************************************************** + init_reply_lookup_names2 + ***************************************************************************/ + +static void init_reply_lookup_names2(LSA_R_LOOKUP_NAMES2 *r_l, + DOM_R_REF *ref, uint32 num_entries, + DOM_RID2 *rid, uint32 mapped_count) +{ + r_l->ptr_dom_ref = 1; + r_l->dom_ref = ref; + + r_l->num_entries = num_entries; + r_l->ptr_entries = 1; + r_l->num_entries2 = num_entries; + r_l->dom_rid = rid; + + r_l->mapped_count = mapped_count; +} + /*************************************************************************** Init_reply_lookup_sids. ***************************************************************************/ @@ -938,6 +957,76 @@ done: return r_u->status; } +/*************************************************************************** +lsa_reply_lookup_names2 + ***************************************************************************/ + +NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOOKUP_NAMES2 *r_u) +{ + struct lsa_info *handle; + UNISTR2 *names = q_u->uni_name; + int num_entries = q_u->num_entries; + DOM_R_REF *ref; + DOM_RID *rids; + DOM_RID2 *rids2; + int i; + uint32 mapped_count = 0; + int flags = 0; + + if (num_entries > MAX_LOOKUP_SIDS) { + num_entries = MAX_LOOKUP_SIDS; + DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries)); + } + + /* Probably the lookup_level is some sort of bitmask. */ + if (q_u->lookup_level == 1) { + flags = LOOKUP_NAME_ALL; + } + + ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); + rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries); + rids2 = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries); + + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { + r_u->status = NT_STATUS_INVALID_HANDLE; + goto done; + } + + /* check if the user have enough rights */ + if (!(handle->access & POLICY_LOOKUP_NAMES)) { + r_u->status = NT_STATUS_ACCESS_DENIED; + goto done; + } + + if (!ref || !rids || !rids2) + return NT_STATUS_NO_MEMORY; + + /* set up the LSA Lookup RIDs response */ + mapped_count = init_lsa_rids(p->mem_ctx, ref, rids, num_entries, + names, flags); +done: + + if (NT_STATUS_IS_OK(r_u->status)) { + if (mapped_count == 0) + r_u->status = NT_STATUS_NONE_MAPPED; + else if (mapped_count != num_entries) + r_u->status = STATUS_SOME_UNMAPPED; + } + + /* Convert the rids array to rids2. */ + for (i = 0; i < num_entries; i++) { + rids2[i].type = rids[i].type; + rids2[i].rid = rids[i].rid; + rids2[i].rid_idx = rids[i].rid_idx; + rids2[i].unknown = 0; + } + + init_reply_lookup_names2(r_u, ref, num_entries, rids2, mapped_count); + + return r_u->status; +} + + /*************************************************************************** _lsa_close. Also weird - needs to check if lsa handle is correct. JRA. ***************************************************************************/ -- cgit From 85160e654e5a1fc4fcb0d6cecc5187cc3b62f6d7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 11 Feb 2006 05:36:27 +0000 Subject: r13458: Add parsing functions - but stub internals for lookupnames3 and 4. Jeremy. (This used to be commit f1a362580ae37730dc8393a79f832aed5d0ea4be) --- source3/rpc_server/srv_lsa.c | 66 ++++++++++++++++++++++++++++++++++++++++- source3/rpc_server/srv_lsa_nt.c | 17 +++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index e20b4e18b4..286266f30d 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -1007,6 +1007,68 @@ static BOOL api_lsa_lookup_names2(pipes_struct *p) return True; } +/*************************************************************************** + api_lsa_lookup_names3 + ***************************************************************************/ + +static BOOL api_lsa_lookup_names3(pipes_struct *p) +{ + LSA_Q_LOOKUP_NAMES3 q_u; + LSA_R_LOOKUP_NAMES3 r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the info class and policy handle */ + if(!lsa_io_q_lookup_names3("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_lookup_names3: failed to unmarshall LSA_Q_LOOKUP_NAMES3.\n")); + return False; + } + + r_u.status = _lsa_lookup_names3(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_lookup_names3("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_lookup_names3: Failed to marshall LSA_R_LOOKUP_NAMES3.\n")); + return False; + } + + return True; +} + +/*************************************************************************** + api_lsa_lookup_names4 + ***************************************************************************/ + +static BOOL api_lsa_lookup_names4(pipes_struct *p) +{ + LSA_Q_LOOKUP_NAMES4 q_u; + LSA_R_LOOKUP_NAMES4 r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the info class and policy handle */ + if(!lsa_io_q_lookup_names4("", &q_u, data, 0)) { + DEBUG(0,("api_lsa_lookup_names4: failed to unmarshall LSA_Q_LOOKUP_NAMES4.\n")); + return False; + } + + r_u.status = _lsa_lookup_names4(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!lsa_io_r_lookup_names4("", &r_u, rdata, 0)) { + DEBUG(0,("api_lsa_lookup_names4: Failed to marshall LSA_R_LOOKUP_NAMES4.\n")); + return False; + } + + return True; +} + #if 0 /* AD DC work in ongoing in Samba 4 */ /*************************************************************************** @@ -1078,7 +1140,9 @@ static struct api_struct api_lsa_cmds[] = { "LSA_DELETEOBJECT" , LSA_DELETEOBJECT , api_lsa_delete_object }, { "LSA_LOOKUPSIDS2" , LSA_LOOKUPSIDS2 , api_lsa_lookup_sids2 }, { "LSA_LOOKUPNAMES2" , LSA_LOOKUPNAMES2 , api_lsa_lookup_names2 }, - { "LSA_LOOKUPSIDS3" , LSA_LOOKUPSIDS3 , api_lsa_lookup_sids3 } + { "LSA_LOOKUPNAMES3" , LSA_LOOKUPNAMES3 , api_lsa_lookup_names3 }, + { "LSA_LOOKUPSIDS3" , LSA_LOOKUPSIDS3 , api_lsa_lookup_sids3 }, + { "LSA_LOOKUPNAMES4" , LSA_LOOKUPNAMES4 , api_lsa_lookup_names4 } #if 0 /* AD DC work in ongoing in Samba 4 */ /* be careful of the adding of new RPC's. See commentrs below about ADS DC capabilities */ diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 200cdb8d9e..038ec06715 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1026,6 +1026,23 @@ done: return r_u->status; } +/*************************************************************************** +lsa_reply_lookup_names3 - stub for now. + ***************************************************************************/ + +NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOOKUP_NAMES3 *r_u) +{ + return NT_STATUS_ACCESS_DENIED; +} + +/*************************************************************************** +lsa_reply_lookup_names4 - stub for now. + ***************************************************************************/ + +NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOOKUP_NAMES4 *r_u) +{ + return NT_STATUS_ACCESS_DENIED; +} /*************************************************************************** _lsa_close. Also weird - needs to check if lsa handle is correct. JRA. -- cgit From 301d51e13a1aa4e633e2da161b0dd260a8a499cd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 13 Feb 2006 17:08:25 +0000 Subject: r13494: Merge the stuff I've done in head the last days. Volker (This used to be commit bb40e544de68f01a6e774753f508e69373b39899) --- source3/rpc_server/srv_samr_nt.c | 527 ++++++++------------------------------- 1 file changed, 103 insertions(+), 424 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b3be0cccc1..133178bd0d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2410,18 +2410,13 @@ static NTSTATUS can_create(TALLOC_CTX *mem_ctx, const char *new_name) NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_CREATE_USER *r_u) { - SAM_ACCOUNT *sam_pass=NULL; - fstring account; + char *account; 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; NTSTATUS nt_status; - struct passwd *pw; uint32 acc_granted; SEC_DESC *psd; size_t sd_size; @@ -2450,33 +2445,20 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, return NT_STATUS_INVALID_PARAMETER; } - rpcstr_pull(account, user_account.buffer, sizeof(account), - user_account.uni_str_len*2, 0); - strlower_m(account); + account = rpcstr_pull_unistr2_talloc(p->mem_ctx, &q_u->uni_name); + if (account == NULL) { + return NT_STATUS_NO_MEMORY; + } nt_status = can_create(p->mem_ctx, account); if (!NT_STATUS_IS_OK(nt_status)) { return nt_status; } - /********************************************************************* - * HEADS UP! If we have to create a new user account, we have to get - * a new RID from somewhere. This used to be done by the passdb - * backend. It has been moved into idmap now. Since idmap is now - * wrapped up behind winbind, this means you have to run winbindd if - * you want new accounts to get a new RID when "enable rid algorithm = - * no". Tough. We now have a uniform way of allocating RIDs - * regardless of what ever passdb backend people may use. --jerry - * (2003-07-10) - *********************************************************************/ - - pw = Get_Pwnam(account); - /* determine which user right we need to check based on the acb_info */ if ( acb_info & ACB_WSTRUST ) { - pstrcpy(add_script, lp_addmachine_script()); se_priv_copy( &se_rights, &se_machine_account ); can_add_account = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); @@ -2486,7 +2468,6 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, else if ( acb_info & ACB_NORMAL && (account[strlen(account)-1] != '$') ) { - pstrcpy(add_script, lp_adduser_script()); se_priv_copy( &se_rights, &se_add_users ); can_add_account = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); @@ -2494,7 +2475,6 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, else /* implicit assumption of a BDC or domain trust account here * (we already check the flags earlier) */ { - pstrcpy(add_script, lp_addmachine_script()); if ( lp_enable_privileges() ) { /* only Domain Admins can add a BDC or domain trust */ se_priv_copy( &se_rights, &se_priv_none ); @@ -2512,40 +2492,9 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, if ( can_add_account ) become_root(); - if ( !pw ) { - if (*add_script) { - int add_ret; - - all_string_sub(add_script, "%u", account, - sizeof(add_script)); - add_ret = smbrun(add_script,NULL); - DEBUG(add_ret ? 0 : 3,("_samr_create_user: Running " - "the command `%s' gave %d\n", - add_script, add_ret)); - } - } - - /* implicit call to getpwnam() next. we have a valid SID coming out - * of this call */ + nt_status = pdb_create_user(p->mem_ctx, account, acb_info, + &r_u->user_rid); - flush_pwnam_cache(); - nt_status = pdb_init_sam_new(&sam_pass, account); - - /* this code is order such that we have no unnecessary retuns - out of the admin block of code */ - - if ( NT_STATUS_IS_OK(nt_status) ) { - pdb_set_acct_ctrl(sam_pass, acb_info, PDB_CHANGED); - - if ( !(ret = pdb_add_sam_account(sam_pass)) ) { - pdb_free_sam(&sam_pass); - DEBUG(0, ("could not add user/computer %s to passdb. " - "Check permissions?\n", - account)); - nt_status = NT_STATUS_ACCESS_DENIED; - } - } - if ( can_add_account ) unbecome_root(); @@ -2557,8 +2506,8 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, return nt_status; /* Get the user's SID */ - - sid_copy(&sid, pdb_get_user_sid(sam_pass)); + + sid_compose(&sid, get_global_sam_sid(), r_u->user_rid); make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, &sid, SAMR_USR_RIGHTS_WRITE_PW); @@ -2574,7 +2523,6 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, /* associate the user's SID with the new handle. */ if ((info = get_samr_info_by_sid(&sid)) == NULL) { - pdb_free_sam(&sam_pass); return NT_STATUS_NO_MEMORY; } @@ -2584,19 +2532,14 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, /* 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; } /* After a "set" ensure we have no cached display info. */ force_flush_samr_cache(info->disp_info); - r_u->user_rid=pdb_get_user_rid(sam_pass); - r_u->access_granted = acc_granted; - pdb_free_sam(&sam_pass); - return NT_STATUS_OK; } @@ -3097,41 +3040,6 @@ static BOOL set_user_info_18(SAM_USER_INFO_18 *id18, SAM_ACCOUNT *pwd) return True; } -/******************************************************************* - The GROUPSID field in the SAM_ACCOUNT changed. Try to tell unix. - ********************************************************************/ -static BOOL set_unix_primary_group(SAM_ACCOUNT *sampass) -{ - struct group *grp; - gid_t gid; - - if (!sid_to_gid(pdb_get_group_sid(sampass), &gid)) { - DEBUG(2,("Could not get gid for primary group of " - "user %s\n", pdb_get_username(sampass))); - return False; - } - - grp = getgrgid(gid); - - if (grp == NULL) { - DEBUG(2,("Could not find primary group %lu for " - "user %s\n", (unsigned long)gid, - pdb_get_username(sampass))); - return False; - } - - if (smb_set_primary_group(grp->gr_name, - pdb_get_username(sampass)) != 0) { - DEBUG(2,("Could not set primary group for user %s to " - "%s\n", - pdb_get_username(sampass), grp->gr_name)); - return False; - } - - return True; -} - - /******************************************************************* set_user_info_20 ********************************************************************/ @@ -3159,12 +3067,14 @@ static BOOL set_user_info_20(SAM_USER_INFO_20 *id20, SAM_ACCOUNT *pwd) set_user_info_21 ********************************************************************/ -static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, SAM_ACCOUNT *pwd) +static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, + SAM_ACCOUNT *pwd) { - + NTSTATUS status; + if (id21 == NULL) { DEBUG(5, ("set_user_info_21: NULL id21\n")); - return False; + return NT_STATUS_INVALID_PARAMETER; } copy_id21_to_sam_passwd(pwd, id21); @@ -3176,33 +3086,38 @@ static BOOL set_user_info_21(SAM_USER_INFO_21 *id21, SAM_ACCOUNT *pwd) * id21. I don't know if they need to be set. --jerry */ - if (IS_SAM_CHANGED(pwd, PDB_GROUPSID)) - set_unix_primary_group(pwd); + if (IS_SAM_CHANGED(pwd, PDB_GROUPSID) && + !NT_STATUS_IS_OK(status = pdb_set_unix_primary_group(mem_ctx, + pwd))) { + return status; + } /* write the change out */ - if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) { + if(!NT_STATUS_IS_OK(status = pdb_update_sam_account(pwd))) { pdb_free_sam(&pwd); - return False; + return status; } pdb_free_sam(&pwd); - return True; + return NT_STATUS_OK; } /******************************************************************* set_user_info_23 ********************************************************************/ -static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, SAM_ACCOUNT *pwd) +static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, + SAM_ACCOUNT *pwd) { pstring plaintext_buf; uint32 len; uint16 acct_ctrl; + NTSTATUS status; if (id23 == NULL) { DEBUG(5, ("set_user_info_23: NULL id23\n")); - return False; + return NT_STATUS_INVALID_PARAMETER; } DEBUG(5, ("Attempting administrator password change (level 23) for user %s\n", @@ -3212,12 +3127,12 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, SAM_ACCOUNT *pwd) if (!decode_pw_buffer(id23->pass, plaintext_buf, 256, &len, STR_UNICODE)) { pdb_free_sam(&pwd); - return False; + return NT_STATUS_INVALID_PARAMETER; } if (!pdb_set_plaintext_passwd (pwd, plaintext_buf)) { pdb_free_sam(&pwd); - return False; + return NT_STATUS_ACCESS_DENIED; } copy_id23_to_sam_passwd(pwd, id23); @@ -3237,24 +3152,28 @@ static BOOL set_user_info_23(SAM_USER_INFO_23 *id23, SAM_ACCOUNT *pwd) if(!chgpasswd(pdb_get_username(pwd), passwd, "", plaintext_buf, True)) { pdb_free_sam(&pwd); - return False; + return NT_STATUS_ACCESS_DENIED; } } } ZERO_STRUCT(plaintext_buf); - if (IS_SAM_CHANGED(pwd, PDB_GROUPSID)) - set_unix_primary_group(pwd); + if (IS_SAM_CHANGED(pwd, PDB_GROUPSID) && + (!NT_STATUS_IS_OK(status = pdb_set_unix_primary_group(mem_ctx, + pwd)))) { + pdb_free_sam(&pwd); + return status; + } - if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) { + if(!NT_STATUS_IS_OK(status = pdb_update_sam_account(pwd))) { pdb_free_sam(&pwd); - return False; + return status; } pdb_free_sam(&pwd); - return True; + return NT_STATUS_OK; } /******************************************************************* @@ -3444,8 +3363,8 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE dump_data(100, (char *)ctr->info.id23->pass, 516); - if (!set_user_info_23(ctr->info.id23, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + r_u->status = set_user_info_23(p->mem_ctx, + ctr->info.id23, pwd); break; default: @@ -3558,8 +3477,8 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ r_u->status = NT_STATUS_ACCESS_DENIED; break; case 21: - if (!set_user_info_21(ctr->info.id21, pwd)) - return NT_STATUS_ACCESS_DENIED; + r_u->status = set_user_info_21(p->mem_ctx, + ctr->info.id21, pwd); break; case 23: if (!p->session_key.length) { @@ -3569,8 +3488,8 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ dump_data(100, (char *)ctr->info.id23->pass, 516); - if (!set_user_info_23(ctr->info.id23, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + r_u->status = set_user_info_23(p->mem_ctx, + ctr->info.id23, pwd); break; case 26: if (!p->session_key.length) { @@ -3713,70 +3632,6 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ return NT_STATUS_OK; } -static void add_uid_to_array_unique(uid_t uid, uid_t **uids, int *num) -{ - int i; - - for (i=0; i<*num; i++) { - if ((*uids)[i] == uid) - return; - } - - *uids = SMB_REALLOC_ARRAY(*uids, uid_t, *num+1); - - if (*uids == NULL) - return; - - (*uids)[*num] = uid; - *num += 1; -} - - -static BOOL get_memberuids(gid_t gid, uid_t **uids, int *num) -{ - struct group *grp; - char **gr; - struct sys_pwent *userlist, *user; - - *uids = NULL; - *num = 0; - - /* We only look at our own sam, so don't care about imported stuff */ - - winbind_off(); - - if ((grp = getgrgid(gid)) == NULL) { - winbind_on(); - return False; - } - - /* Primary group members */ - - userlist = getpwent_list(); - - for (user = userlist; user != NULL; user = user->next) { - if (user->pw_gid != gid) - continue; - add_uid_to_array_unique(user->pw_uid, uids, num); - } - - pwent_free(userlist); - - /* Secondary group members */ - - for (gr = grp->gr_mem; (*gr != NULL) && ((*gr)[0] != '\0'); gr += 1) { - struct passwd *pw = getpwnam(*gr); - - if (pw == NULL) - continue; - add_uid_to_array_unique(pw->pw_uid, uids, num); - } - - winbind_on(); - - return True; -} - /********************************************************************* _samr_query_groupmem *********************************************************************/ @@ -3931,16 +3786,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_ADD_GROUPMEM *r_u) { DOM_SID group_sid; - DOM_SID user_sid; - fstring group_sid_str; - uid_t uid; - struct passwd *pwd; - struct group *grp; - fstring grp_name; - GROUP_MAP map; - NTSTATUS ret; - SAM_ACCOUNT *sam_user=NULL; - BOOL check; + uint32 group_rid; uint32 acc_granted; SE_PRIV se_rights; BOOL can_add_accounts; @@ -3954,53 +3800,11 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD return r_u->status; } - sid_to_string(group_sid_str, &group_sid); - DEBUG(10, ("sid is %s\n", group_sid_str)); - - if (sid_compare(&group_sid, get_global_sam_sid())<=0) - return NT_STATUS_NO_SUCH_GROUP; - - DEBUG(10, ("lookup on Domain SID\n")); - - if(!get_domain_group_from_sid(group_sid, &map)) - return NT_STATUS_NO_SUCH_GROUP; - - sid_copy(&user_sid, get_global_sam_sid()); - sid_append_rid(&user_sid, q_u->rid); - - ret = pdb_init_sam(&sam_user); - if (!NT_STATUS_IS_OK(ret)) - return ret; - - check = pdb_getsampwsid(sam_user, &user_sid); - - if (check != True) { - pdb_free_sam(&sam_user); - return NT_STATUS_NO_SUCH_USER; - } + DEBUG(10, ("sid is %s\n", sid_string_static(&group_sid))); - /* check a real user exist before we run the script to add a user to a group */ - if (!sid_to_uid(pdb_get_user_sid(sam_user), &uid)) { - pdb_free_sam(&sam_user); - return NT_STATUS_NO_SUCH_USER; - } - - pdb_free_sam(&sam_user); - - if ((pwd=getpwuid_alloc(p->mem_ctx, uid)) == NULL) { - return NT_STATUS_NO_SUCH_USER; - } - - if ((grp=getgrgid(map.gid)) == NULL) { - return NT_STATUS_NO_SUCH_GROUP; - } - - /* we need to copy the name otherwise it's overloaded in user_in_unix_group_list */ - fstrcpy(grp_name, grp->gr_name); - - /* if the user is already in the group */ - if(user_in_unix_group(pwd->pw_name, grp_name)) { - return NT_STATUS_MEMBER_IN_GROUP; + if (!sid_peek_check_rid(get_global_sam_sid(), &group_sid, + &group_rid)) { + return NT_STATUS_INVALID_HANDLE; } se_priv_copy( &se_rights, &se_add_users ); @@ -4010,28 +3814,17 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD if ( can_add_accounts ) become_root(); - - /* - * ok, the group exist, the user exist, the user is not in the group, - * - * we can (finally) add it to the group ! - */ - - smb_add_user_group(grp_name, pwd->pw_name); + r_u->status = pdb_add_groupmem(p->mem_ctx, group_rid, q_u->rid); + if ( can_add_accounts ) unbecome_root(); /******** END SeAddUsers BLOCK *********/ - /* check if the user has been added then ... */ - if(!user_in_unix_group(pwd->pw_name, grp_name)) { - return NT_STATUS_MEMBER_NOT_IN_GROUP; /* don't know what to reply else */ - } - force_flush_samr_cache(disp_info); - return NT_STATUS_OK; + return r_u->status; } /********************************************************************* @@ -4041,11 +3834,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DEL_GROUPMEM *r_u) { DOM_SID group_sid; - DOM_SID user_sid; - SAM_ACCOUNT *sam_pass=NULL; - GROUP_MAP map; - fstring grp_name; - struct group *grp; + uint32 group_rid; uint32 acc_granted; SE_PRIV se_rights; BOOL can_add_accounts; @@ -4064,36 +3853,11 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_REMOVE_MEMBER, "_samr_del_groupmem"))) { return r_u->status; } - - if (!sid_check_is_in_our_domain(&group_sid)) - return NT_STATUS_NO_SUCH_GROUP; - - sid_copy(&user_sid, get_global_sam_sid()); - sid_append_rid(&user_sid, q_u->rid); - - if (!get_domain_group_from_sid(group_sid, &map)) - return NT_STATUS_NO_SUCH_GROUP; - - if ((grp=getgrgid(map.gid)) == NULL) - return NT_STATUS_NO_SUCH_GROUP; - - /* we need to copy the name otherwise it's overloaded in user_in_group_list */ - fstrcpy(grp_name, grp->gr_name); - - /* check if the user exists before trying to remove it from the group */ - pdb_init_sam(&sam_pass); - if (!pdb_getsampwsid(sam_pass, &user_sid)) { - DEBUG(5,("User %s doesn't exist.\n", pdb_get_username(sam_pass))); - pdb_free_sam(&sam_pass); - return NT_STATUS_NO_SUCH_USER; - } - /* if the user is not in the group */ - if (!user_in_unix_group(pdb_get_username(sam_pass), grp_name)) { - pdb_free_sam(&sam_pass); - return NT_STATUS_MEMBER_NOT_IN_GROUP; + if (!sid_peek_check_rid(get_global_sam_sid(), &group_sid, + &group_rid)) { + return NT_STATUS_INVALID_HANDLE; } - se_priv_copy( &se_rights, &se_add_users ); can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); @@ -4103,45 +3867,16 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE if ( can_add_accounts ) become_root(); - smb_delete_user_group(grp_name, pdb_get_username(sam_pass)); + r_u->status = pdb_del_groupmem(p->mem_ctx, group_rid, q_u->rid); if ( can_add_accounts ) unbecome_root(); /******** END SeAddUsers BLOCK *********/ - /* check if the user has been removed then ... */ - if (user_in_unix_group(pdb_get_username(sam_pass), grp_name)) { - pdb_free_sam(&sam_pass); - return NT_STATUS_ACCESS_DENIED; /* don't know what to reply else */ - } - - pdb_free_sam(&sam_pass); - force_flush_samr_cache(disp_info); - return NT_STATUS_OK; - -} - -/**************************************************************************** - Delete a UNIX user on demand. -****************************************************************************/ - -static int smb_delete_user(const char *unix_user) -{ - pstring del_script; - int ret; - - pstrcpy(del_script, lp_deluser_script()); - if (! *del_script) - return -1; - all_string_sub(del_script, "%u", unix_user, sizeof(del_script)); - ret = smbrun(del_script,NULL); - flush_pwnam_cache(); - DEBUG(ret ? 0 : 3,("smb_delete_user: Running the command `%s' gave %d\n",del_script,ret)); - - return ret; + return r_u->status; } /********************************************************************* @@ -4154,7 +3889,6 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM SAM_ACCOUNT *sam_pass=NULL; uint32 acc_granted; BOOL can_add_accounts; - BOOL ret; DISP_INFO *disp_info = NULL; DEBUG(5, ("_samr_delete_dom_user: %d\n", __LINE__)); @@ -4186,29 +3920,19 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM if ( can_add_accounts ) become_root(); - /* First delete the samba side.... - code is order to prevent unnecessary returns out of the admin - block of code */ - - if ( (ret = pdb_delete_sam_account(sam_pass)) == True ) { - /* - * Now delete the unix side .... - * note: we don't check if the delete really happened - * as the script is not necessary present - * and maybe the sysadmin doesn't want to delete the unix side - */ - smb_delete_user( pdb_get_username(sam_pass) ); - } - + r_u->status = pdb_delete_user(p->mem_ctx, sam_pass); + if ( can_add_accounts ) unbecome_root(); /******** END SeAddUsers BLOCK *********/ - if ( !ret ) { - DEBUG(5,("_samr_delete_dom_user:Failed to delete entry for user %s.\n", pdb_get_username(sam_pass))); + if ( !NT_STATUS_IS_OK(r_u->status) ) { + DEBUG(5,("_samr_delete_dom_user: Failed to delete entry for " + "user %s: %s.\n", pdb_get_username(sam_pass), + nt_errstr(r_u->status))); pdb_free_sam(&sam_pass); - return NT_STATUS_CANNOT_DELETE; + return r_u->status; } @@ -4229,16 +3953,10 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, SAMR_R_DELETE_DOM_GROUP *r_u) { DOM_SID group_sid; - DOM_SID dom_sid; uint32 group_rid; - fstring group_sid_str; - gid_t gid; - struct group *grp; - GROUP_MAP map; uint32 acc_granted; SE_PRIV se_rights; BOOL can_add_accounts; - BOOL ret; DISP_INFO *disp_info = NULL; DEBUG(5, ("samr_delete_dom_group: %d\n", __LINE__)); @@ -4250,27 +3968,13 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_group"))) { return r_u->status; } - - sid_copy(&dom_sid, &group_sid); - sid_to_string(group_sid_str, &dom_sid); - sid_split_rid(&dom_sid, &group_rid); - DEBUG(10, ("sid is %s\n", group_sid_str)); + DEBUG(10, ("sid is %s\n", sid_string_static(&group_sid))); - /* we check if it's our SID before deleting */ - if (!sid_equal(&dom_sid, get_global_sam_sid())) - return NT_STATUS_NO_SUCH_GROUP; - - DEBUG(10, ("lookup on Domain SID\n")); - - if(!get_domain_group_from_sid(group_sid, &map)) - return NT_STATUS_NO_SUCH_GROUP; - - gid=map.gid; - - /* check if group really exists */ - if ( (grp=getgrgid(gid)) == NULL) + if (!sid_peek_check_rid(get_global_sam_sid(), &group_sid, + &group_rid)) { return NT_STATUS_NO_SUCH_GROUP; + } se_priv_copy( &se_rights, &se_add_users ); can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); @@ -4280,26 +3984,21 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S if ( can_add_accounts ) become_root(); - /* delete mapping first */ - - if ( (ret = pdb_delete_group_mapping_entry(group_sid)) == True ) { - smb_delete_group( grp->gr_name ); - } + r_u->status = pdb_delete_dom_group(p->mem_ctx, group_rid); if ( can_add_accounts ) unbecome_root(); /******** END SeAddUsers BLOCK *********/ - if ( !ret ) { - DEBUG(5,("_samr_delete_dom_group: Failed to delete mapping entry for group %s.\n", - group_sid_str)); - return NT_STATUS_ACCESS_DENIED; + if ( !NT_STATUS_IS_OK(r_u->status) ) { + DEBUG(5,("_samr_delete_dom_group: Failed to delete mapping " + "entry for group %s: %s\n", + sid_string_static(&group_sid), + nt_errstr(r_u->status))); + return r_u->status; } - /* don't check that the unix group has been deleted. Work like - _samr_delet_dom_user() */ - if (!close_policy_hnd(p, &q_u->group_pol)) return NT_STATUS_OBJECT_NAME_INVALID; @@ -4373,15 +4072,11 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S { DOM_SID dom_sid; DOM_SID info_sid; - fstring name; - fstring sid_string; - struct group *grp; + const char *name; struct samr_info *info; uint32 acc_granted; - gid_t gid; SE_PRIV se_rights; BOOL can_add_accounts; - NTSTATUS result; DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ @@ -4395,7 +4090,10 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; - unistr2_to_ascii(name, &q_u->uni_acct_desc, sizeof(name)-1); + name = rpcstr_pull_unistr2_talloc(p->mem_ctx, &q_u->uni_acct_desc); + if (name == NULL) { + return NT_STATUS_NO_MEMORY; + } r_u->status = can_create(p->mem_ctx, name); if (!NT_STATUS_IS_OK(r_u->status)) { @@ -4412,35 +4110,7 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S /* check that we successfully create the UNIX group */ - result = NT_STATUS_ACCESS_DENIED; - if ( (smb_create_group(name, &gid) == 0) && ((grp=getgrgid(gid)) != NULL) ) { - - /* so far, so good */ - - result = NT_STATUS_OK; - - if (pdb_rid_algorithm()) { - r_u->rid = pdb_gid_to_group_rid( grp->gr_gid ); - } else { - if (!pdb_new_rid(&r_u->rid)) { - result = NT_STATUS_ACCESS_DENIED; - } - } - - if (NT_STATUS_IS_OK(result)) { - - /* add the group to the mapping table */ - - sid_copy( &info_sid, get_global_sam_sid() ); - sid_append_rid( &info_sid, r_u->rid ); - sid_to_string( sid_string, &info_sid ); - - /* reset the error code if we fail to add the mapping entry */ - - if ( !add_initial_entry(grp->gr_gid, sid_string, SID_NAME_DOM_GRP, name, NULL) ) - result = NT_STATUS_ACCESS_DENIED; - } - } + r_u->status = pdb_create_dom_group(p->mem_ctx, name, &r_u->rid); if ( can_add_accounts ) unbecome_root(); @@ -4449,13 +4119,14 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S /* check if we should bail out here */ - if ( !NT_STATUS_IS_OK(result) ) - return result; + if ( !NT_STATUS_IS_OK(r_u->status) ) + return r_u->status; + + sid_compose(&info_sid, get_global_sam_sid(), r_u->rid); if ((info = get_samr_info_by_sid(&info_sid)) == NULL) return NT_STATUS_NO_MEMORY; - /* they created it; let the user do what he wants with it */ info->acc_granted = GENERIC_RIGHTS_GROUP_ALL_ACCESS; @@ -4568,9 +4239,6 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM { DOM_SID group_sid; GROUP_MAP map; - DOM_SID *sids=NULL; - uid_t *uids; - int num=0; GROUP_INFO_CTR *ctr; uint32 acc_granted; BOOL ret; @@ -4593,14 +4261,25 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM return NT_STATUS_NO_MEMORY; switch (q_u->switch_level) { - case 1: + case 1: { + uint32 *members; + size_t num_members; + ctr->switch_value1 = 1; - if(!get_memberuids(map.gid, &uids, &num)) - return NT_STATUS_NO_SUCH_GROUP; - SAFE_FREE(uids); - init_samr_group_info1(&ctr->group.info1, map.nt_name, map.comment, num); - SAFE_FREE(sids); + + become_root(); + r_u->status = pdb_enum_group_members( + p->mem_ctx, &group_sid, &members, &num_members); + unbecome_root(); + + if (!NT_STATUS_IS_OK(r_u->status)) { + return r_u->status; + } + + init_samr_group_info1(&ctr->group.info1, map.nt_name, + map.comment, num_members); break; + } case 3: ctr->switch_value1 = 3; init_samr_group_info3(&ctr->group.info3); -- cgit From 87d23f263fdc370afcb2a1a45889514a57e2cedd Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 15 Feb 2006 18:24:16 +0000 Subject: r13511: Fix bug in the samr dispinfo enumeration code. Make sure to associate the DOMAIN dispinfo cache with a User/Group SAMR handle (not the SID of the user or group). Ensure that enumeration after deleting a user works. (This used to be commit 7967f89caa17ea93cb7e9d8695f1904ccb9a2864) --- source3/rpc_server/srv_samr_nt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 133178bd0d..bc73c9ef87 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -252,6 +252,17 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid, const char *sid_str) TALLOC_CTX *mem_ctx; DISP_INFO *dpi; + /* There are two cases to consider here: + 1) The SID is a domain SID and we look for an equality match, or + 2) This is an account SID and so we return the DISP_INFO* for our + domain */ + + if ( psid && sid_check_is_in_our_domain( psid ) ) { + DEBUG(10,("get_samr_dispinfo_by_sid: Replacing %s with our domain SID\n", + sid_str)); + psid = get_global_sam_sid(); + } + for (dpi = disp_info_list; dpi; dpi = dpi->next) { if (sid_equal(psid, &dpi->sid)) { return dpi; -- cgit From 3e4cf56fa3f9d465d27dadaa6790bbcdea5d3cd9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 15 Feb 2006 23:15:55 +0000 Subject: r13519: Fix the credentials chaining across netlogon pipe disconnects. I mean it this time :-). Jeremy. (This used to be commit 80f4868944d349015d2b64c2414b06466a8194aa) --- source3/rpc_server/srv_netlog_nt.c | 169 +++++++++++++++++++++++++++---------- source3/rpc_server/srv_pipe.c | 23 ++--- 2 files changed, 134 insertions(+), 58 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 2b98314722..97e19e6cb7 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -281,6 +281,10 @@ NTSTATUS _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u q_u->uni_logon_clnt.buffer, sizeof(fstring),q_u->uni_logon_clnt.uni_str_len*2,0); + /* Remember the workstation name. This is what we'll use to look + up the secrets.tdb record later. */ + fstrcpy(p->wks, p->dc->remote_machine); + /* Save the client challenge to the server. */ memcpy(p->dc->clnt_chal.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); @@ -464,10 +468,31 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * DOM_CRED cred_out; const uchar *old_pw; + DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); + + /* We need the workstation name for the creds lookup. */ + rpcstr_pull(workstation,q_u->clnt_id.login.uni_comp_name.buffer, + sizeof(workstation),q_u->clnt_id.login.uni_comp_name.uni_str_len*2,0); + + if (!p->dc) { + /* Restore the saved state of the netlogon creds. */ + become_root(); + ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, + workstation, + &p->dc); + unbecome_root(); + if (!ret) { + return NT_STATUS_INVALID_HANDLE; + } + } + if (!p->dc || !p->dc->authenticated) { return NT_STATUS_INVALID_HANDLE; } + DEBUG(3,("_net_srv_pwset: Server Password Set by Wksta:[%s] on account [%s]\n", + workstation, p->dc->mach_acct)); + /* Step the creds chain forward. */ if (!creds_server_step(p->dc, &q_u->clnt_id.cred, &cred_out)) { DEBUG(2,("_net_srv_pwset: creds_server_step failed. Rejecting auth " @@ -476,17 +501,10 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * return NT_STATUS_INVALID_PARAMETER; } - DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); - - rpcstr_pull(workstation,q_u->clnt_id.login.uni_comp_name.buffer, - sizeof(workstation),q_u->clnt_id.login.uni_comp_name.uni_str_len*2,0); - - DEBUG(3,("_net_srv_pwset: Server Password Set by Wksta:[%s] on account [%s]\n", - workstation, p->dc->mach_acct)); - - pdb_init_sam(&sampass); - + /* We must store the creds state after an update. */ become_root(); + secrets_store_schannel_session_info(p->pipe_state_mem_ctx, p->dc); + pdb_init_sam(&sampass); ret=pdb_getsampwnam(sampass, p->dc->mach_acct); unbecome_root(); @@ -559,9 +577,28 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF *r_u) { + fstring workstation; + if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; + if (!p->dc) { + /* Restore the saved state of the netlogon creds. */ + BOOL ret; + + *workstation = '\0'; + rpcstr_pull_unistr2_fstring(workstation, &q_u->sam_id.client.login.uni_comp_name); + + become_root(); + secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, + workstation, + &p->dc); + unbecome_root(); + if (!ret) { + return NT_STATUS_INVALID_HANDLE; + } + } + if (!p->dc || !p->dc->authenticated) { return NT_STATUS_INVALID_HANDLE; } @@ -576,6 +613,11 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF return NT_STATUS_INVALID_PARAMETER; } + /* We must store the creds state after an update. */ + become_root(); + secrets_store_schannel_session_info(p->pipe_state_mem_ctx, p->dc); + unbecome_root(); + r_u->status = NT_STATUS_OK; return r_u->status; } @@ -651,32 +693,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; - if (process_creds) { - if (!p->dc || !p->dc->authenticated) { - return NT_STATUS_INVALID_HANDLE; - } - } - - if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { - /* 'server schannel = yes' should enforce use of - schannel, the client did offer it in auth2, but - obviously did not use it. */ - DEBUG(0,("_net_sam_logon: client %s not using schannel for netlogon\n", - p->dc->remote_machine )); - return NT_STATUS_ACCESS_DENIED; - } - - if (process_creds) { - /* checks and updates credentials. creates reply credentials */ - if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { - DEBUG(2,("_net_sam_logon: creds_server_step failed. Rejecting auth " - "request from client %s machine account %s\n", - p->dc->remote_machine, p->dc->mach_acct )); - return NT_STATUS_INVALID_PARAMETER; - } - } - - /* find the username */ + /* We need the workstation name for the creds lookup. */ switch (q_u->sam_id.logon_level) { case INTERACTIVE_LOGON_TYPE: @@ -703,9 +720,52 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, rpcstr_pull(nt_domain,uni_samlogon_domain->buffer,sizeof(nt_domain),uni_samlogon_domain->uni_str_len*2,0); rpcstr_pull(nt_workstation,uni_samlogon_workstation->buffer,sizeof(nt_workstation),uni_samlogon_workstation->uni_str_len*2,0); - DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, - nt_workstation, nt_domain)); - + DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain)); + + if (process_creds) { + if (!p->dc) { + /* Restore the saved state of the netlogon creds. */ + BOOL ret; + + become_root(); + secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, + nt_workstation, + &p->dc); + unbecome_root(); + if (!ret) { + return NT_STATUS_INVALID_HANDLE; + } + } + + if (!p->dc || !p->dc->authenticated) { + return NT_STATUS_INVALID_HANDLE; + } + } + + if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { + /* 'server schannel = yes' should enforce use of + schannel, the client did offer it in auth2, but + obviously did not use it. */ + DEBUG(0,("_net_sam_logon: client %s not using schannel for netlogon\n", + p->dc->remote_machine )); + return NT_STATUS_ACCESS_DENIED; + } + + if (process_creds) { + /* checks and updates credentials. creates reply credentials */ + if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { + DEBUG(2,("_net_sam_logon: creds_server_step failed. Rejecting auth " + "request from client %s machine account %s\n", + p->dc->remote_machine, p->dc->mach_acct )); + return NT_STATUS_INVALID_PARAMETER; + } + + /* We must store the creds state after an update. */ + become_root(); + secrets_store_schannel_session_info(p->pipe_state_mem_ctx, p->dc); + unbecome_root(); + } + fstrcpy(current_user_info.smb_name, nt_username); sub_set_smb_name(nt_username); @@ -822,8 +882,9 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, pstring my_name; fstring user_sid_string; fstring group_sid_string; - uchar user_session_key[16]; - uchar lm_session_key[16]; + unsigned char user_session_key[16]; + unsigned char lm_session_key[16]; + unsigned char pipe_session_key[16]; sampw = server_info->sam_account; @@ -870,14 +931,36 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, server_info->user_session_key.data, MIN(sizeof(user_session_key), server_info->user_session_key.length)); - SamOEMhash(user_session_key, p->dc->sess_key, 16); + if (process_creds) { + /* Get the pipe session key from the creds. */ + memcpy(pipe_session_key, p->dc->sess_key, 16); + } else { + /* Get the pipe session key from the schannel. */ + if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL || p->auth.a_u.schannel_auth == NULL) { + return NT_STATUS_INVALID_HANDLE; + } + memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16); + } + SamOEMhash(user_session_key, pipe_session_key, 16); + memset(pipe_session_key, '\0', 16); } if (server_info->lm_session_key.length) { memcpy(lm_session_key, server_info->lm_session_key.data, MIN(sizeof(lm_session_key), server_info->lm_session_key.length)); - SamOEMhash(lm_session_key, p->dc->sess_key, 16); + if (process_creds) { + /* Get the pipe session key from the creds. */ + memcpy(pipe_session_key, p->dc->sess_key, 16); + } else { + /* Get the pipe session key from the schannel. */ + if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL || p->auth.a_u.schannel_auth == NULL) { + return NT_STATUS_INVALID_HANDLE; + } + memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16); + } + SamOEMhash(lm_session_key, pipe_session_key, 16); + memset(pipe_session_key, '\0', 16); } init_net_user_info3(p->mem_ctx, usr_info, diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 68b3a2d434..716654103a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1284,7 +1284,7 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, RPC_AUTH_SCHANNEL_NEG neg; RPC_AUTH_VERIFIER auth_verifier; BOOL ret; - struct dcinfo stored_dcinfo; + struct dcinfo *pdcinfo; uint32 flags; if (!smb_io_rpc_auth_schannel_neg("", &neg, rpc_in_p, 0)) { @@ -1292,10 +1292,8 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, return False; } - ZERO_STRUCT(stored_dcinfo); - become_root(); - ret = secrets_restore_schannel_session_info(p->mem_ctx, neg.myname, &stored_dcinfo); + ret = secrets_restore_schannel_session_info(p->mem_ctx, neg.myname, &pdcinfo); unbecome_root(); if (!ret) { @@ -1305,29 +1303,24 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, p->auth.a_u.schannel_auth = TALLOC_P(p->pipe_state_mem_ctx, struct schannel_auth_struct); if (!p->auth.a_u.schannel_auth) { + talloc_free(pdcinfo); return False; } memset(p->auth.a_u.schannel_auth->sess_key, 0, sizeof(p->auth.a_u.schannel_auth->sess_key)); - memcpy(p->auth.a_u.schannel_auth->sess_key, stored_dcinfo.sess_key, sizeof(stored_dcinfo.sess_key)); + memcpy(p->auth.a_u.schannel_auth->sess_key, pdcinfo->sess_key, + sizeof(pdcinfo->sess_key)); + + talloc_free(pdcinfo); p->auth.a_u.schannel_auth->seq_num = 0; /* * JRA. Should we also copy the schannel session key into the pipe session key p->session_key - * here ? We do that for NTLMSPP, but the session key is already set up from the vuser + * here ? We do that for NTLMSSP, but the session key is already set up from the vuser * struct of the person who opened the pipe. I need to test this further. JRA. */ - /* The client opens a second RPC NETLOGON pipe without - doing a auth2. The credentials for the schannel are - re-used from the auth2 the client did before. */ - p->dc = TALLOC_ZERO_P(p->pipe_state_mem_ctx, struct dcinfo); - if (!p->dc) { - return False; - } - *p->dc = stored_dcinfo; - init_rpc_hdr_auth(&auth_info, RPC_SCHANNEL_AUTH_TYPE, pauth_info->auth_level, RPC_HDR_AUTH_LEN, 1); if(!smb_io_rpc_hdr_auth("", &auth_info, pout_auth, 0)) { DEBUG(0,("pipe_schannel_auth_bind: marshalling of RPC_HDR_AUTH failed.\n")); -- cgit From 8d5ef34aa35406c32b00a75bcb3aed0c1c0979b3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 16 Feb 2006 01:06:21 +0000 Subject: r13521: Implement LOOKUPNAME3 and 4. Jeremy. (This used to be commit 6ec0e9124a1a7b19c9853b8e26075cbbb8751f10) --- source3/rpc_server/srv_lsa_nt.c | 285 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 257 insertions(+), 28 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 038ec06715..a9886363d2 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -4,7 +4,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, - * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Jeremy Allison 2001, 2006. * Copyright (C) Rafal Szczesniak 2002, * Copyright (C) Jim McDonough 2002, * Copyright (C) Simo Sorce 2003. @@ -131,21 +131,23 @@ static int init_dom_ref(DOM_R_REF *ref, const char *dom_name, DOM_SID *dom_sid) } /*************************************************************************** - init_lsa_rids + lookup_lsa_rids. Must be called as root for lookup_name to work. ***************************************************************************/ -static int init_lsa_rids(TALLOC_CTX *mem_ctx, - DOM_R_REF *ref, DOM_RID *prid, - int num_entries, UNISTR2 *name, - int flags) +static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx, + DOM_R_REF *ref, + DOM_RID *prid, + int num_entries, + const UNISTR2 *name, + int flags, + int *pmapped_count) { int mapped_count, i; SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS); mapped_count = 0; - - become_root(); /* lookup_name can require root privs */ + *pmapped_count = 0; for (i = 0; i < num_entries; i++) { DOM_SID sid; @@ -160,10 +162,10 @@ static int init_lsa_rids(TALLOC_CTX *mem_ctx, full_name = rpcstr_pull_unistr2_talloc(mem_ctx, &name[i]); if (full_name == NULL) { DEBUG(0, ("pull_ucs2_talloc failed\n")); - return 0; + return NT_STATUS_NO_MEMORY; } - DEBUG(5, ("init_lsa_rids: looking up name %s\n", full_name)); + DEBUG(5, ("lookup_lsa_rids: looking up name %s\n", full_name)); /* We can ignore the result of lookup_name, it will not touch "type" if it's not successful */ @@ -171,7 +173,6 @@ static int init_lsa_rids(TALLOC_CTX *mem_ctx, lookup_name(mem_ctx, full_name, flags, &domain, NULL, &sid, &type); - switch (type) { case SID_NAME_USER: case SID_NAME_DOM_GRP: @@ -200,9 +201,92 @@ static int init_lsa_rids(TALLOC_CTX *mem_ctx, init_dom_rid(&prid[i], rid, type, dom_idx); } - unbecome_root(); + *pmapped_count = mapped_count; + return NT_STATUS_OK; +} + +/*************************************************************************** + lookup_lsa_sids. Must be called as root for lookup_name to work. + ***************************************************************************/ + +static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, + DOM_R_REF *ref, + LSA_TRANSLATED_SID3 *trans_sids, + int num_entries, + const UNISTR2 *name, + int flags, + int *pmapped_count) +{ + int mapped_count, i; + + SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS); + + mapped_count = 0; + *pmapped_count = 0; + + for (i = 0; i < num_entries; i++) { + DOM_SID sid; + uint32 rid; + int dom_idx; + char *full_name; + const char *domain; + enum SID_NAME_USE type = SID_NAME_UNKNOWN; - return mapped_count; + /* Split name into domain and user component */ + + full_name = rpcstr_pull_unistr2_talloc(mem_ctx, &name[i]); + if (full_name == NULL) { + DEBUG(0, ("pull_ucs2_talloc failed\n")); + return NT_STATUS_NO_MEMORY; + } + + DEBUG(5, ("init_lsa_sids: looking up name %s\n", full_name)); + + /* We can ignore the result of lookup_name, it will not touch + "type" if it's not successful */ + + lookup_name(mem_ctx, full_name, flags, &domain, NULL, + &sid, &type); + + switch (type) { + case SID_NAME_USER: + case SID_NAME_DOM_GRP: + case SID_NAME_DOMAIN: + case SID_NAME_ALIAS: + case SID_NAME_WKN_GRP: + DEBUG(5, ("init_lsa_sids: %s found\n", full_name)); + /* Leave these unchanged */ + break; + default: + /* Don't hand out anything but the list above */ + DEBUG(5, ("init_lsa_sids: %s not found\n", full_name)); + type = SID_NAME_UNKNOWN; + break; + } + + rid = 0; + dom_idx = -1; + + if (type != SID_NAME_UNKNOWN) { + DOM_SID domain_sid; + sid_copy(&domain_sid, &sid); + sid_split_rid(&domain_sid, &rid); + dom_idx = init_dom_ref(ref, domain, &domain_sid); + mapped_count++; + } + + /* Initialize the LSA_TRANSLATED_SID3 return. */ + trans_sids[i].sid_type = type; + trans_sids[i].sid2 = TALLOC_P(mem_ctx, DOM_SID2); + if (trans_sids[i].sid2 == NULL) { + return NT_STATUS_NO_MEMORY; + } + init_dom_sid2(trans_sids[i].sid2, &sid); + trans_sids[i].sid_idx = dom_idx; + } + + *pmapped_count = mapped_count; + return NT_STATUS_OK; } /*************************************************************************** @@ -243,6 +327,44 @@ static void init_reply_lookup_names2(LSA_R_LOOKUP_NAMES2 *r_l, r_l->mapped_count = mapped_count; } +/*************************************************************************** + init_reply_lookup_names3 + ***************************************************************************/ + +static void init_reply_lookup_names3(LSA_R_LOOKUP_NAMES3 *r_l, + DOM_R_REF *ref, uint32 num_entries, + LSA_TRANSLATED_SID3 *trans_sids, uint32 mapped_count) +{ + r_l->ptr_dom_ref = 1; + r_l->dom_ref = ref; + + r_l->num_entries = num_entries; + r_l->ptr_entries = 1; + r_l->num_entries2 = num_entries; + r_l->trans_sids = trans_sids; + + r_l->mapped_count = mapped_count; +} + +/*************************************************************************** + init_reply_lookup_names4 + ***************************************************************************/ + +static void init_reply_lookup_names4(LSA_R_LOOKUP_NAMES4 *r_l, + DOM_R_REF *ref, uint32 num_entries, + LSA_TRANSLATED_SID3 *trans_sids, uint32 mapped_count) +{ + r_l->ptr_dom_ref = 1; + r_l->dom_ref = ref; + + r_l->num_entries = num_entries; + r_l->ptr_entries = 1; + r_l->num_entries2 = num_entries; + r_l->trans_sids = trans_sids; + + r_l->mapped_count = mapped_count; +} + /*************************************************************************** Init_reply_lookup_sids. ***************************************************************************/ @@ -942,8 +1064,11 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP return NT_STATUS_NO_MEMORY; /* set up the LSA Lookup RIDs response */ - mapped_count = init_lsa_rids(p->mem_ctx, ref, rids, num_entries, - names, flags); + become_root(); /* lookup_name can require root privs */ + r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries, + names, flags, &mapped_count); + unbecome_root(); + done: if (NT_STATUS_IS_OK(r_u->status)) { @@ -952,8 +1077,8 @@ done: else if (mapped_count != num_entries) r_u->status = STATUS_SOME_UNMAPPED; } - init_reply_lookup_names(r_u, ref, num_entries, rids, mapped_count); + init_reply_lookup_names(r_u, ref, num_entries, rids, mapped_count); return r_u->status; } @@ -975,7 +1100,7 @@ NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOO if (num_entries > MAX_LOOKUP_SIDS) { num_entries = MAX_LOOKUP_SIDS; - DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries)); + DEBUG(5,("_lsa_lookup_names2: truncating name lookup list to %d\n", num_entries)); } /* Probably the lookup_level is some sort of bitmask. */ @@ -998,19 +1123,24 @@ NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOO goto done; } - if (!ref || !rids || !rids2) + if (!ref || !rids || !rids2) { return NT_STATUS_NO_MEMORY; + } /* set up the LSA Lookup RIDs response */ - mapped_count = init_lsa_rids(p->mem_ctx, ref, rids, num_entries, - names, flags); + become_root(); /* lookup_name can require root privs */ + r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries, + names, flags, &mapped_count); + unbecome_root(); + done: if (NT_STATUS_IS_OK(r_u->status)) { - if (mapped_count == 0) + if (mapped_count == 0) { r_u->status = NT_STATUS_NONE_MAPPED; - else if (mapped_count != num_entries) + } else if (mapped_count != num_entries) { r_u->status = STATUS_SOME_UNMAPPED; + } } /* Convert the rids array to rids2. */ @@ -1022,26 +1152,124 @@ done: } init_reply_lookup_names2(r_u, ref, num_entries, rids2, mapped_count); - return r_u->status; } /*************************************************************************** -lsa_reply_lookup_names3 - stub for now. +lsa_reply_lookup_names3. ***************************************************************************/ NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOOKUP_NAMES3 *r_u) { - return NT_STATUS_ACCESS_DENIED; + struct lsa_info *handle; + UNISTR2 *names = q_u->uni_name; + int num_entries = q_u->num_entries; + DOM_R_REF *ref = NULL; + LSA_TRANSLATED_SID3 *trans_sids = NULL; + uint32 mapped_count = 0; + int flags = 0; + + if (num_entries > MAX_LOOKUP_SIDS) { + num_entries = MAX_LOOKUP_SIDS; + DEBUG(5,("_lsa_lookup_names3: truncating name lookup list to %d\n", num_entries)); + } + + /* Probably the lookup_level is some sort of bitmask. */ + if (q_u->lookup_level == 1) { + flags = LOOKUP_NAME_ALL; + } + + ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); + trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries); + + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { + r_u->status = NT_STATUS_INVALID_HANDLE; + goto done; + } + + /* check if the user have enough rights */ + if (!(handle->access & POLICY_LOOKUP_NAMES)) { + r_u->status = NT_STATUS_ACCESS_DENIED; + goto done; + } + + if (!ref || !trans_sids) { + return NT_STATUS_NO_MEMORY; + } + + /* set up the LSA Lookup SIDs response */ + become_root(); /* lookup_name can require root privs */ + r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries, + names, flags, &mapped_count); + unbecome_root(); + +done: + + if (NT_STATUS_IS_OK(r_u->status)) { + if (mapped_count == 0) { + r_u->status = NT_STATUS_NONE_MAPPED; + } else if (mapped_count != num_entries) { + r_u->status = STATUS_SOME_UNMAPPED; + } + } + + init_reply_lookup_names3(r_u, ref, num_entries, trans_sids, mapped_count); + return r_u->status; } /*************************************************************************** -lsa_reply_lookup_names4 - stub for now. +lsa_reply_lookup_names4. ***************************************************************************/ NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOOKUP_NAMES4 *r_u) { - return NT_STATUS_ACCESS_DENIED; + UNISTR2 *names = q_u->uni_name; + int num_entries = q_u->num_entries; + DOM_R_REF *ref = NULL; + LSA_TRANSLATED_SID3 *trans_sids = NULL; + uint32 mapped_count = 0; + int flags = 0; + + if (num_entries > MAX_LOOKUP_SIDS) { + num_entries = MAX_LOOKUP_SIDS; + DEBUG(5,("_lsa_lookup_names4: truncating name lookup list to %d\n", num_entries)); + } + + /* Probably the lookup_level is some sort of bitmask. */ + if (q_u->lookup_level == 1) { + flags = LOOKUP_NAME_ALL; + } + + /* No policy handle on this call. Restrict to crypto connections. */ + if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) { + DEBUG(0,("_lsa_lookup_names4: client %s not using schannel for netlogon\n", + get_remote_machine_name() )); + return NT_STATUS_INVALID_PARAMETER; + } + + ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); + trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries); + + if (!ref || !trans_sids) { + return NT_STATUS_NO_MEMORY; + } + + /* set up the LSA Lookup SIDs response */ + become_root(); /* lookup_name can require root privs */ + r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries, + names, flags, &mapped_count); + unbecome_root(); + + if (NT_STATUS_IS_OK(r_u->status)) { + if (mapped_count == 0) { + r_u->status = NT_STATUS_NONE_MAPPED; + } else if (mapped_count != num_entries) { + r_u->status = STATUS_SOME_UNMAPPED; + } + } + + init_reply_lookup_names4(r_u, ref, num_entries, trans_sids, mapped_count); + return r_u->status; } /*************************************************************************** @@ -1050,8 +1278,9 @@ NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOO NTSTATUS _lsa_close(pipes_struct *p, LSA_Q_CLOSE *q_u, LSA_R_CLOSE *r_u) { - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) + if (!find_policy_by_hnd(p, &q_u->pol, NULL)) { return NT_STATUS_INVALID_HANDLE; + } close_policy_hnd(p, &q_u->pol); return NT_STATUS_OK; -- cgit From 39a572e0106696e24540d9829812917635c1fd06 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 17 Feb 2006 04:22:32 +0000 Subject: r13539: Add 128 bit creds processing client and server. Thanks to Andrew Bartlett's Samba4 code. Jeremy. (This used to be commit a2fb436fc5dd536cfe860be93f55f9cb58139a0e) --- source3/rpc_server/srv_netlog_nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 97e19e6cb7..52f2c2e34c 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -338,7 +338,8 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) } /* From the client / server challenges and md4 password, generate sess key */ - creds_server_init(p->dc, + creds_server_init(0, /* No neg flags. */ + p->dc, &p->dc->clnt_chal, /* Stored client chal. */ &p->dc->srv_chal, /* Stored server chal. */ (const char *)p->dc->mach_pw, @@ -415,7 +416,8 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) } /* From the client / server challenges and md4 password, generate sess key */ - creds_server_init(p->dc, + creds_server_init(q_u->clnt_flgs.neg_flags, + p->dc, &p->dc->clnt_chal, /* Stored client chal. */ &p->dc->srv_chal, /* Stored server chal. */ (const char *)p->dc->mach_pw, -- cgit From a2f2a1d9f8f02bf4a4ffb38cc35a92cda770e4f4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 17 Feb 2006 17:20:53 +0000 Subject: r13544: -O1 janitor work :-) (This used to be commit a95d7d722273863efa820674672393fe6e5a33b7) --- source3/rpc_server/srv_netlog_nt.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 52f2c2e34c..109f936ec6 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -592,9 +592,8 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF rpcstr_pull_unistr2_fstring(workstation, &q_u->sam_id.client.login.uni_comp_name); become_root(); - secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, - workstation, - &p->dc); + ret = secrets_restore_schannel_session_info( + p->pipe_state_mem_ctx, workstation, &p->dc); unbecome_root(); if (!ret) { return NT_STATUS_INVALID_HANDLE; @@ -730,9 +729,9 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, BOOL ret; become_root(); - secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, - nt_workstation, - &p->dc); + ret = secrets_restore_schannel_session_info( + p->pipe_state_mem_ctx, nt_workstation, + &p->dc); unbecome_root(); if (!ret) { return NT_STATUS_INVALID_HANDLE; -- cgit From b2ae6e08daee619936f2858eafb31b3a8d8ecfcb Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 17 Feb 2006 21:07:26 +0000 Subject: r13547: add earlier checks to deny deleting a printer driver. The previous code relied upon file permissions alone. Now we check that the user is a printer administrator and that the share has not been marked read only for that user. (This used to be commit 117d9fd9e16a7afbc6772506a4f8c33ff99d33f7) --- source3/rpc_server/srv_spoolss_nt.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e6d45f76ec..c767daf88c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1973,9 +1973,21 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER struct current_user user; WERROR status; WERROR status_win2k = WERR_ACCESS_DENIED; + SE_PRIV se_printop = SE_PRINT_OPERATOR; get_current_user(&user, p); + /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege, + and not a printer admin, then fail */ + + if ( (user.ut.uid != 0) + && !user_has_privileges(user.nt_user_token, &se_printop ) + && !token_contains_name_in_list( uidtoname(user.ut.uid), + NULL, user.nt_user_token, lp_printer_admin(-1)) ) + { + return WERR_ACCESS_DENIED; + } + unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)-1 ); unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)-1 ); @@ -2059,9 +2071,21 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV struct current_user user; WERROR status; WERROR status_win2k = WERR_ACCESS_DENIED; + SE_PRIV se_printop = SE_PRINT_OPERATOR; get_current_user(&user, p); + /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege, + and not a printer admin, then fail */ + + if ( (user.ut.uid != 0) + && !user_has_privileges(user.nt_user_token, &se_printop ) + && !token_contains_name_in_list( uidtoname(user.ut.uid), + NULL, user.nt_user_token, lp_printer_admin(-1)) ) + { + return WERR_ACCESS_DENIED; + } + unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)-1 ); unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)-1 ); -- cgit From 952a631d5de34bd7bf938b0c1349126a0243a3d0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 17 Feb 2006 21:32:31 +0000 Subject: r13548: Always use the get_remote_macinhe_name() as the key for the creds store. This should fix the problems Jerry reported (but I have still to run tests :-). Jeremy. (This used to be commit 43f095a38d66caa774d80fe32e1b96ec25dd1f07) --- source3/rpc_server/srv_netlog_nt.c | 96 +++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 49 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 109f936ec6..af1f0ebdcf 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -281,10 +281,6 @@ NTSTATUS _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u q_u->uni_logon_clnt.buffer, sizeof(fstring),q_u->uni_logon_clnt.uni_str_len*2,0); - /* Remember the workstation name. This is what we'll use to look - up the secrets.tdb record later. */ - fstrcpy(p->wks, p->dc->remote_machine); - /* Save the client challenge to the server. */ memcpy(p->dc->clnt_chal.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); @@ -448,7 +444,9 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) /* Store off the state so we can continue after client disconnect. */ become_root(); - secrets_store_schannel_session_info(p->mem_ctx, p->dc); + secrets_store_schannel_session_info(p->mem_ctx, + get_remote_machine_name(), + p->dc); unbecome_root(); return r_u->status; @@ -480,7 +478,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * /* Restore the saved state of the netlogon creds. */ become_root(); ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, - workstation, + get_remote_machine_name(), &p->dc); unbecome_root(); if (!ret) { @@ -505,7 +503,9 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * /* We must store the creds state after an update. */ become_root(); - secrets_store_schannel_session_info(p->pipe_state_mem_ctx, p->dc); + secrets_store_schannel_session_info(p->pipe_state_mem_ctx, + get_remote_machine_name(), + p->dc); pdb_init_sam(&sampass); ret=pdb_getsampwnam(sampass, p->dc->mach_acct); unbecome_root(); @@ -579,8 +579,6 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF *r_u) { - fstring workstation; - if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; @@ -588,12 +586,10 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF /* Restore the saved state of the netlogon creds. */ BOOL ret; - *workstation = '\0'; - rpcstr_pull_unistr2_fstring(workstation, &q_u->sam_id.client.login.uni_comp_name); - become_root(); - ret = secrets_restore_schannel_session_info( - p->pipe_state_mem_ctx, workstation, &p->dc); + ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, + get_remote_machine_name(), + &p->dc); unbecome_root(); if (!ret) { return NT_STATUS_INVALID_HANDLE; @@ -616,7 +612,9 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF /* We must store the creds state after an update. */ become_root(); - secrets_store_schannel_session_info(p->pipe_state_mem_ctx, p->dc); + secrets_store_schannel_session_info(p->pipe_state_mem_ctx, + get_remote_machine_name(), + p->dc); unbecome_root(); r_u->status = NT_STATUS_OK; @@ -694,44 +692,15 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; - /* We need the workstation name for the creds lookup. */ - - switch (q_u->sam_id.logon_level) { - case INTERACTIVE_LOGON_TYPE: - uni_samlogon_user = &ctr->auth.id1.uni_user_name; - uni_samlogon_domain = &ctr->auth.id1.uni_domain_name; - - uni_samlogon_workstation = &ctr->auth.id1.uni_wksta_name; - - DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); - break; - case NET_LOGON_TYPE: - uni_samlogon_user = &ctr->auth.id2.uni_user_name; - uni_samlogon_domain = &ctr->auth.id2.uni_domain_name; - uni_samlogon_workstation = &ctr->auth.id2.uni_wksta_name; - - DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); - break; - default: - DEBUG(2,("SAM Logon: unsupported switch value\n")); - return NT_STATUS_INVALID_INFO_CLASS; - } /* end switch */ - - rpcstr_pull(nt_username,uni_samlogon_user->buffer,sizeof(nt_username),uni_samlogon_user->uni_str_len*2,0); - rpcstr_pull(nt_domain,uni_samlogon_domain->buffer,sizeof(nt_domain),uni_samlogon_domain->uni_str_len*2,0); - rpcstr_pull(nt_workstation,uni_samlogon_workstation->buffer,sizeof(nt_workstation),uni_samlogon_workstation->uni_str_len*2,0); - - DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain)); - if (process_creds) { if (!p->dc) { /* Restore the saved state of the netlogon creds. */ BOOL ret; become_root(); - ret = secrets_restore_schannel_session_info( - p->pipe_state_mem_ctx, nt_workstation, - &p->dc); + ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, + get_remote_machine_name(), + &p->dc); unbecome_root(); if (!ret) { return NT_STATUS_INVALID_HANDLE; @@ -748,7 +717,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, schannel, the client did offer it in auth2, but obviously did not use it. */ DEBUG(0,("_net_sam_logon: client %s not using schannel for netlogon\n", - p->dc->remote_machine )); + get_remote_machine_name() )); return NT_STATUS_ACCESS_DENIED; } @@ -763,10 +732,39 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, /* We must store the creds state after an update. */ become_root(); - secrets_store_schannel_session_info(p->pipe_state_mem_ctx, p->dc); + secrets_store_schannel_session_info(p->pipe_state_mem_ctx, + get_remote_machine_name(), + p->dc); unbecome_root(); } + + switch (q_u->sam_id.logon_level) { + case INTERACTIVE_LOGON_TYPE: + uni_samlogon_user = &ctr->auth.id1.uni_user_name; + uni_samlogon_domain = &ctr->auth.id1.uni_domain_name; + + uni_samlogon_workstation = &ctr->auth.id1.uni_wksta_name; + + DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); + break; + case NET_LOGON_TYPE: + uni_samlogon_user = &ctr->auth.id2.uni_user_name; + uni_samlogon_domain = &ctr->auth.id2.uni_domain_name; + uni_samlogon_workstation = &ctr->auth.id2.uni_wksta_name; + + DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); + break; + default: + DEBUG(2,("SAM Logon: unsupported switch value\n")); + return NT_STATUS_INVALID_INFO_CLASS; + } /* end switch */ + + rpcstr_pull(nt_username,uni_samlogon_user->buffer,sizeof(nt_username),uni_samlogon_user->uni_str_len*2,0); + rpcstr_pull(nt_domain,uni_samlogon_domain->buffer,sizeof(nt_domain),uni_samlogon_domain->uni_str_len*2,0); + rpcstr_pull(nt_workstation,uni_samlogon_workstation->buffer,sizeof(nt_workstation),uni_samlogon_workstation->uni_str_len*2,0); + + DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain)); fstrcpy(current_user_info.smb_name, nt_username); sub_set_smb_name(nt_username); -- cgit From 3403fc2d4966e7b2e29ec45ecdc53332302427e4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 17 Feb 2006 23:57:28 +0000 Subject: r13552: Make sure we're using the same name to load the stored creds under all circumstances. This may be wrong, but at least we're now consistent. Jeremy. (This used to be commit 09f0b3e1a366ba3eef4ab9a8e302daabd4f36936) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 716654103a..23419d5c55 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1293,7 +1293,7 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, } become_root(); - ret = secrets_restore_schannel_session_info(p->mem_ctx, neg.myname, &pdcinfo); + ret = secrets_restore_schannel_session_info(p->mem_ctx, get_remote_machine_name(), &pdcinfo); unbecome_root(); if (!ret) { -- cgit From 9132acff082381b32961eb2b3244b8fedd4df218 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 18 Feb 2006 00:27:31 +0000 Subject: r13553: Fix all our warnings at -O6 on an x86_64 box. Jeremy. (This used to be commit ea82958349a57ef4b7ce9638eec5f1388b0fba2a) --- source3/rpc_server/srv_lsa_nt.c | 20 ++++++++++---------- source3/rpc_server/srv_netlog_nt.c | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index a9886363d2..bdfb742f7a 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -137,12 +137,12 @@ static int init_dom_ref(DOM_R_REF *ref, const char *dom_name, DOM_SID *dom_sid) static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx, DOM_R_REF *ref, DOM_RID *prid, - int num_entries, + uint32 num_entries, const UNISTR2 *name, int flags, - int *pmapped_count) + uint32 *pmapped_count) { - int mapped_count, i; + uint32 mapped_count, i; SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS); @@ -212,12 +212,12 @@ static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx, static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, DOM_R_REF *ref, LSA_TRANSLATED_SID3 *trans_sids, - int num_entries, + uint32 num_entries, const UNISTR2 *name, int flags, - int *pmapped_count) + uint32 *pmapped_count) { - int mapped_count, i; + uint32 mapped_count, i; SMB_ASSERT(num_entries <= MAX_LOOKUP_SIDS); @@ -1030,7 +1030,7 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP { struct lsa_info *handle; UNISTR2 *names = q_u->uni_name; - int num_entries = q_u->num_entries; + uint32 num_entries = q_u->num_entries; DOM_R_REF *ref; DOM_RID *rids; uint32 mapped_count = 0; @@ -1090,7 +1090,7 @@ NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOO { struct lsa_info *handle; UNISTR2 *names = q_u->uni_name; - int num_entries = q_u->num_entries; + uint32 num_entries = q_u->num_entries; DOM_R_REF *ref; DOM_RID *rids; DOM_RID2 *rids2; @@ -1163,7 +1163,7 @@ NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOO { struct lsa_info *handle; UNISTR2 *names = q_u->uni_name; - int num_entries = q_u->num_entries; + uint32 num_entries = q_u->num_entries; DOM_R_REF *ref = NULL; LSA_TRANSLATED_SID3 *trans_sids = NULL; uint32 mapped_count = 0; @@ -1224,7 +1224,7 @@ lsa_reply_lookup_names4. NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOOKUP_NAMES4 *r_u) { UNISTR2 *names = q_u->uni_name; - int num_entries = q_u->num_entries; + uint32 num_entries = q_u->num_entries; DOM_R_REF *ref = NULL; LSA_TRANSLATED_SID3 *trans_sids = NULL; uint32 mapped_count = 0; diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index af1f0ebdcf..1813fd6c1e 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -338,7 +338,7 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) p->dc, &p->dc->clnt_chal, /* Stored client chal. */ &p->dc->srv_chal, /* Stored server chal. */ - (const char *)p->dc->mach_pw, + p->dc->mach_pw, &srv_chal_out); /* Check client credentials are valid. */ @@ -416,7 +416,7 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) p->dc, &p->dc->clnt_chal, /* Stored client chal. */ &p->dc->srv_chal, /* Stored server chal. */ - (const char *)p->dc->mach_pw, + p->dc->mach_pw, &srv_chal_out); /* Check client credentials are valid. */ -- cgit From 5539d3d5a8d270a86c749d4ec5a5ceefa228b339 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 18 Feb 2006 00:39:31 +0000 Subject: r13556: Ensure that any potential creds operation are protected by schannel if "server schannel = true" was set. Jeremy. (This used to be commit fd84d9703ed01feb010df4ebb7e9ceb0d063780b) --- source3/rpc_server/srv_netlog_nt.c | 45 ++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 1813fd6c1e..2b0d870812 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -474,6 +474,15 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * rpcstr_pull(workstation,q_u->clnt_id.login.uni_comp_name.buffer, sizeof(workstation),q_u->clnt_id.login.uni_comp_name.uni_str_len*2,0); + if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { + /* 'server schannel = yes' should enforce use of + schannel, the client did offer it in auth2, but + obviously did not use it. */ + DEBUG(0,("_net_srv_pwset: client %s not using schannel for netlogon\n", + get_remote_machine_name() )); + return NT_STATUS_ACCESS_DENIED; + } + if (!p->dc) { /* Restore the saved state of the netlogon creds. */ become_root(); @@ -579,6 +588,16 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF *r_u) { + if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { + /* 'server schannel = yes' should enforce use of + schannel, the client did offer it in auth2, but + obviously did not use it. */ + DEBUG(0,("_net_sam_logoff: client %s not using schannel for netlogon\n", + get_remote_machine_name() )); + return NT_STATUS_ACCESS_DENIED; + } + + if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; @@ -671,10 +690,20 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, auth_serversupplied_info *server_info = NULL; SAM_ACCOUNT *sampw; struct auth_context *auth_context = NULL; - + + if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { + /* 'server schannel = yes' should enforce use of + schannel, the client did offer it in auth2, but + obviously did not use it. */ + DEBUG(0,("_net_sam_logon_internal: client %s not using schannel for netlogon\n", + get_remote_machine_name() )); + return NT_STATUS_ACCESS_DENIED; + } + usr_info = TALLOC_P(p->mem_ctx, NET_USER_INFO_3); - if (!usr_info) + if (!usr_info) { return NT_STATUS_NO_MEMORY; + } ZERO_STRUCTP(usr_info); @@ -710,18 +739,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (!p->dc || !p->dc->authenticated) { return NT_STATUS_INVALID_HANDLE; } - } - - if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { - /* 'server schannel = yes' should enforce use of - schannel, the client did offer it in auth2, but - obviously did not use it. */ - DEBUG(0,("_net_sam_logon: client %s not using schannel for netlogon\n", - get_remote_machine_name() )); - return NT_STATUS_ACCESS_DENIED; - } - if (process_creds) { /* checks and updates credentials. creates reply credentials */ if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { DEBUG(2,("_net_sam_logon: creds_server_step failed. Rejecting auth " @@ -738,7 +756,6 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, unbecome_root(); } - switch (q_u->sam_id.logon_level) { case INTERACTIVE_LOGON_TYPE: uni_samlogon_user = &ctr->auth.id1.uni_user_name; -- cgit From 0bc643620b38e647d62140d545c042e459df9a6c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 18 Feb 2006 01:21:18 +0000 Subject: r13557: (Hopefully) get the creds store/restore key right from the correct part of the netlogon and schannel packets. Jeremy. (This used to be commit 4877f336b257e6f59833a6e0679959a2ec879974) --- source3/rpc_server/srv_netlog_nt.c | 53 +++++++++++++++++++++++++------------- source3/rpc_server/srv_pipe.c | 8 +++++- 2 files changed, 42 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 2b0d870812..e762a8b9e2 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -385,6 +385,8 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring), q_u->clnt_id.uni_acct_name.uni_str_len*2,0); + + /* We use this as the key to store the creds. */ rpcstr_pull(remote_machine, q_u->clnt_id.uni_comp_name.buffer,sizeof(fstring), q_u->clnt_id.uni_comp_name.uni_str_len*2,0); @@ -445,7 +447,7 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) /* Store off the state so we can continue after client disconnect. */ become_root(); secrets_store_schannel_session_info(p->mem_ctx, - get_remote_machine_name(), + remote_machine, p->dc); unbecome_root(); @@ -459,7 +461,7 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_u) { NTSTATUS status = NT_STATUS_ACCESS_DENIED; - fstring workstation; + fstring remote_machine; SAM_ACCOUNT *sampass=NULL; BOOL ret = False; unsigned char pwd[16]; @@ -470,16 +472,16 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); - /* We need the workstation name for the creds lookup. */ - rpcstr_pull(workstation,q_u->clnt_id.login.uni_comp_name.buffer, - sizeof(workstation),q_u->clnt_id.login.uni_comp_name.uni_str_len*2,0); + /* We need the remote machine name for the creds lookup. */ + rpcstr_pull(remote_machine,q_u->clnt_id.login.uni_comp_name.buffer, + sizeof(remote_machine),q_u->clnt_id.login.uni_comp_name.uni_str_len*2,0); if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { /* 'server schannel = yes' should enforce use of schannel, the client did offer it in auth2, but obviously did not use it. */ DEBUG(0,("_net_srv_pwset: client %s not using schannel for netlogon\n", - get_remote_machine_name() )); + remote_machine )); return NT_STATUS_ACCESS_DENIED; } @@ -487,7 +489,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * /* Restore the saved state of the netlogon creds. */ become_root(); ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, - get_remote_machine_name(), + remote_machine, &p->dc); unbecome_root(); if (!ret) { @@ -499,21 +501,21 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * return NT_STATUS_INVALID_HANDLE; } - DEBUG(3,("_net_srv_pwset: Server Password Set by Wksta:[%s] on account [%s]\n", - workstation, p->dc->mach_acct)); + DEBUG(3,("_net_srv_pwset: Server Password Set by remote machine:[%s] on account [%s]\n", + remote_machine, p->dc->mach_acct)); /* Step the creds chain forward. */ if (!creds_server_step(p->dc, &q_u->clnt_id.cred, &cred_out)) { DEBUG(2,("_net_srv_pwset: creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", - p->dc->remote_machine, p->dc->mach_acct )); + remote_machine, p->dc->mach_acct )); return NT_STATUS_INVALID_PARAMETER; } /* We must store the creds state after an update. */ become_root(); secrets_store_schannel_session_info(p->pipe_state_mem_ctx, - get_remote_machine_name(), + remote_machine, p->dc); pdb_init_sam(&sampass); ret=pdb_getsampwnam(sampass, p->dc->mach_acct); @@ -588,6 +590,8 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF *r_u) { + fstring remote_machine; + if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { /* 'server schannel = yes' should enforce use of schannel, the client did offer it in auth2, but @@ -601,13 +605,17 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; + /* Get the remote machine name for the creds store. */ + rpcstr_pull(remote_machine,q_u->sam_id.client.login.uni_comp_name.buffer, + sizeof(remote_machine),q_u->sam_id.client.login.uni_comp_name.uni_str_len*2,0); + if (!p->dc) { /* Restore the saved state of the netlogon creds. */ BOOL ret; become_root(); ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, - get_remote_machine_name(), + remote_machine, &p->dc); unbecome_root(); if (!ret) { @@ -625,14 +633,14 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { DEBUG(2,("_net_sam_logoff: creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", - p->dc->remote_machine, p->dc->mach_acct )); + remote_machine, p->dc->mach_acct )); return NT_STATUS_INVALID_PARAMETER; } /* We must store the creds state after an update. */ become_root(); secrets_store_schannel_session_info(p->pipe_state_mem_ctx, - get_remote_machine_name(), + remote_machine, p->dc); unbecome_root(); @@ -640,10 +648,10 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF return r_u->status; } - /******************************************************************* gets a domain user's groups from their already-calculated NT_USER_TOKEN ********************************************************************/ + static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, const DOM_SID *domain_sid, size_t num_sids, @@ -722,13 +730,22 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, return NT_STATUS_NO_SUCH_USER; if (process_creds) { + fstring remote_machine; + + /* Get the remote machine name for the creds store. */ + /* Note this is the remote machine this request is coming from (member server), + not neccessarily the workstation name the user is logging onto. + */ + rpcstr_pull(remote_machine,q_u->sam_id.client.login.uni_comp_name.buffer, + sizeof(remote_machine),q_u->sam_id.client.login.uni_comp_name.uni_str_len*2,0); + if (!p->dc) { /* Restore the saved state of the netlogon creds. */ BOOL ret; become_root(); ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, - get_remote_machine_name(), + remote_machine, &p->dc); unbecome_root(); if (!ret) { @@ -744,14 +761,14 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { DEBUG(2,("_net_sam_logon: creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", - p->dc->remote_machine, p->dc->mach_acct )); + remote_machine, p->dc->mach_acct )); return NT_STATUS_INVALID_PARAMETER; } /* We must store the creds state after an update. */ become_root(); secrets_store_schannel_session_info(p->pipe_state_mem_ctx, - get_remote_machine_name(), + remote_machine, p->dc); unbecome_root(); } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 23419d5c55..3ed33ca691 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1292,8 +1292,14 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, return False; } + /* + * The neg.myname key here must match the remote computer name + * given in the DOM_CLNT_SRV.uni_comp_name used on all netlogon pipe + * operations that use credentials. + */ + become_root(); - ret = secrets_restore_schannel_session_info(p->mem_ctx, get_remote_machine_name(), &pdcinfo); + ret = secrets_restore_schannel_session_info(p->mem_ctx, neg.myname, &pdcinfo); unbecome_root(); if (!ret) { -- cgit From fb5362c069b5b6548478b2217a0519c56d856705 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 20 Feb 2006 17:59:58 +0000 Subject: r13571: Replace all calls to talloc_free() with thye TALLOC_FREE() macro which sets the freed pointer to NULL. (This used to be commit b65be8874a2efe5a4b167448960a4fcf6bd995e2) --- source3/rpc_server/srv_netlog_nt.c | 6 +++--- source3/rpc_server/srv_pipe.c | 6 +++--- source3/rpc_server/srv_pipe_hnd.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index e762a8b9e2..737729a4ce 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -888,7 +888,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, && !is_trusted_domain(nt_domain) ) r_u->auth_resp = 0; /* We are not authoritative */ - talloc_free(server_info); + TALLOC_FREE(server_info); return status; } @@ -896,7 +896,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, /* We don't like guest domain logons... */ DEBUG(5,("_net_sam_logon: Attempted domain logon as GUEST " "denied.\n")); - talloc_free(server_info); + TALLOC_FREE(server_info); return NT_STATUS_LOGON_FAILURE; } @@ -1025,7 +1025,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, ZERO_STRUCT(user_session_key); ZERO_STRUCT(lm_session_key); } - talloc_free(server_info); + TALLOC_FREE(server_info); return status; } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 3ed33ca691..67fb89ef79 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -616,7 +616,7 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) memset(p->wks, '\0', sizeof(p->wks)); /* Set up for non-authenticated user. */ - talloc_free(p->pipe_user.nt_user_token); + TALLOC_FREE(p->pipe_user.nt_user_token); p->pipe_user.ut.ngroups = 0; SAFE_FREE( p->pipe_user.ut.groups); @@ -1309,7 +1309,7 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, p->auth.a_u.schannel_auth = TALLOC_P(p->pipe_state_mem_ctx, struct schannel_auth_struct); if (!p->auth.a_u.schannel_auth) { - talloc_free(pdcinfo); + TALLOC_FREE(pdcinfo); return False; } @@ -1317,7 +1317,7 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, memcpy(p->auth.a_u.schannel_auth->sess_key, pdcinfo->sess_key, sizeof(pdcinfo->sess_key)); - talloc_free(pdcinfo); + TALLOC_FREE(pdcinfo); p->auth.a_u.schannel_auth->seq_num = 0; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 86a04e7ccb..f7467f2cf0 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1223,7 +1223,7 @@ static BOOL close_internal_rpc_pipe_hnd(void *np_conn) /* Free the handles database. */ close_policy_by_pipe(p); - talloc_free(p->pipe_user.nt_user_token); + TALLOC_FREE(p->pipe_user.nt_user_token); data_blob_free(&p->session_key); SAFE_FREE(p->pipe_user.ut.groups); -- cgit From 2203bed32c84c63737f402accf73452efb76b483 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 20 Feb 2006 20:09:36 +0000 Subject: r13576: This is the beginnings of moving the SAM_ACCOUNT data structure to make full use of the new talloc() interface. Discussed with Volker and Jeremy. * remove the internal mem_ctx and simply use the talloc() structure as the context. * replace the internal free_fn() with a talloc_destructor() function * remove the unnecessary private nested structure * rename SAM_ACCOUNT to 'struct samu' to indicate the current an upcoming changes. Groups will most likely be replaced with a 'struct samg' in the future. Note that there are now passbd API changes. And for the most part, the wrapper functions remain the same. While this code has been tested on tdb and ldap based Samba PDC's as well as Samba member servers, there are probably still some bugs. The code also needs more testing under valgrind to ensure it's not leaking memory. But it's a start...... (This used to be commit 19b7593972480540283c5bf02c02e5ecd8d2c3f0) --- source3/rpc_server/srv_netlog_nt.c | 24 +++---- source3/rpc_server/srv_samr_nt.c | 124 ++++++++++++++++++------------------- source3/rpc_server/srv_samr_util.c | 12 ++-- 3 files changed, 80 insertions(+), 80 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 737729a4ce..ea0685f41b 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -206,7 +206,7 @@ static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, static BOOL get_md4pw(char *md4pw, char *mach_acct) { - SAM_ACCOUNT *sampass = NULL; + struct samu *sampass = NULL; const uint8 *pass; BOOL ret; uint32 acct_ctrl; @@ -239,7 +239,7 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) if (ret==False) { DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); return False; } @@ -251,12 +251,12 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) ((pass=pdb_get_nt_passwd(sampass)) != NULL)) { memcpy(md4pw, pass, 16); dump_data(5, md4pw, 16); - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); return True; } DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); return False; } @@ -462,7 +462,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * { NTSTATUS status = NT_STATUS_ACCESS_DENIED; fstring remote_machine; - SAM_ACCOUNT *sampass=NULL; + struct samu *sampass=NULL; BOOL ret = False; unsigned char pwd[16]; int i; @@ -529,12 +529,12 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * && (acct_ctrl & ACB_WSTRUST || acct_ctrl & ACB_SVRTRUST || acct_ctrl & ACB_DOMTRUST))) { - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); return NT_STATUS_NO_SUCH_USER; } if (pdb_get_acct_ctrl(sampass) & ACB_DISABLED) { - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); return NT_STATUS_ACCOUNT_DISABLED; } @@ -557,17 +557,17 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * /* LM password should be NULL for machines */ if (!pdb_set_lanman_passwd(sampass, NULL, PDB_CHANGED)) { - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); return NT_STATUS_NO_MEMORY; } if (!pdb_set_nt_passwd(sampass, pwd, PDB_CHANGED)) { - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); return NT_STATUS_NO_MEMORY; } if (!pdb_set_pass_changed_now(sampass)) { - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); /* Not quite sure what this one qualifies as, but this will do */ return NT_STATUS_UNSUCCESSFUL; } @@ -580,7 +580,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * /* set up the LSA Server Password Set response */ init_net_r_srv_pwset(r_u, &cred_out, status); - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); return r_u->status; } @@ -696,7 +696,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, fstring nt_username, nt_domain, nt_workstation; auth_usersupplied_info *user_info = NULL; auth_serversupplied_info *server_info = NULL; - SAM_ACCOUNT *sampw; + struct samu *sampw; struct auth_context *auth_context = NULL; if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index bc73c9ef87..f9a28f1272 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -470,7 +470,7 @@ static void force_flush_samr_cache(DISP_INFO *disp_info) Ensure password info is never given out. Paranioa... JRA. ********************************************************************/ -static void samr_clear_sam_passwd(SAM_ACCOUNT *sam_pass) +static void samr_clear_sam_passwd(struct samu *sam_pass) { if (!sam_pass) @@ -1667,7 +1667,7 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USER *r_u) { - SAM_ACCOUNT *sampass=NULL; + struct samu *sampass=NULL; DOM_SID sid; POLICY_HND domain_pol = q_u->domain_pol; POLICY_HND *user_pol = &r_u->user_pol; @@ -1727,7 +1727,7 @@ NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USE return NT_STATUS_NO_SUCH_USER; } - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); /* associate the user's SID and access bits with the new handle. */ if ((info = get_samr_info_by_sid(&sid)) == NULL) @@ -1747,7 +1747,7 @@ NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USE static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_SID *user_sid) { - SAM_ACCOUNT *smbpass=NULL; + struct samu *smbpass=NULL; BOOL ret; NTSTATUS nt_status; @@ -1771,7 +1771,7 @@ static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_S ZERO_STRUCTP(id7); init_sam_user_info7(id7, pdb_get_username(smbpass) ); - pdb_free_sam(&smbpass); + TALLOC_FREE(smbpass); return NT_STATUS_OK; } @@ -1781,7 +1781,7 @@ static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_S *************************************************************************/ static NTSTATUS get_user_info_9(TALLOC_CTX *mem_ctx, SAM_USER_INFO_9 * id9, DOM_SID *user_sid) { - SAM_ACCOUNT *smbpass=NULL; + struct samu *smbpass=NULL; BOOL ret; NTSTATUS nt_status; @@ -1805,7 +1805,7 @@ static NTSTATUS get_user_info_9(TALLOC_CTX *mem_ctx, SAM_USER_INFO_9 * id9, DOM_ ZERO_STRUCTP(id9); init_sam_user_info9(id9, pdb_get_group_rid(smbpass) ); - pdb_free_sam(&smbpass); + TALLOC_FREE(smbpass); return NT_STATUS_OK; } @@ -1816,7 +1816,7 @@ static NTSTATUS get_user_info_9(TALLOC_CTX *mem_ctx, SAM_USER_INFO_9 * id9, DOM_ static NTSTATUS get_user_info_16(TALLOC_CTX *mem_ctx, SAM_USER_INFO_16 *id16, DOM_SID *user_sid) { - SAM_ACCOUNT *smbpass=NULL; + struct samu *smbpass=NULL; BOOL ret; NTSTATUS nt_status; @@ -1840,7 +1840,7 @@ static NTSTATUS get_user_info_16(TALLOC_CTX *mem_ctx, SAM_USER_INFO_16 *id16, DO ZERO_STRUCTP(id16); init_sam_user_info16(id16, pdb_get_acct_ctrl(smbpass) ); - pdb_free_sam(&smbpass); + TALLOC_FREE(smbpass); return NT_STATUS_OK; } @@ -1853,7 +1853,7 @@ static NTSTATUS get_user_info_16(TALLOC_CTX *mem_ctx, SAM_USER_INFO_16 *id16, DO static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_INFO_18 * id18, DOM_SID *user_sid) { - SAM_ACCOUNT *smbpass=NULL; + struct samu *smbpass=NULL; BOOL ret; NTSTATUS nt_status; @@ -1879,21 +1879,21 @@ static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_ if (ret == False) { DEBUG(4, ("User %s not found\n", sid_string_static(user_sid))); - pdb_free_sam(&smbpass); + TALLOC_FREE(smbpass); return (geteuid() == (uid_t)0) ? NT_STATUS_NO_SUCH_USER : NT_STATUS_ACCESS_DENIED; } DEBUG(3,("User:[%s] 0x%x\n", pdb_get_username(smbpass), pdb_get_acct_ctrl(smbpass) )); if ( pdb_get_acct_ctrl(smbpass) & ACB_DISABLED) { - pdb_free_sam(&smbpass); + TALLOC_FREE(smbpass); return NT_STATUS_ACCOUNT_DISABLED; } ZERO_STRUCTP(id18); init_sam_user_info18(id18, pdb_get_lanman_passwd(smbpass), pdb_get_nt_passwd(smbpass)); - pdb_free_sam(&smbpass); + TALLOC_FREE(smbpass); return NT_STATUS_OK; } @@ -1904,7 +1904,7 @@ static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, SAM_USER_INFO_20 *id20, DOM_SID *user_sid) { - SAM_ACCOUNT *sampass=NULL; + struct samu *sampass=NULL; BOOL ret; pdb_init_sam_talloc(mem_ctx, &sampass); @@ -1925,7 +1925,7 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, SAM_USER_INFO_20 *id20, DO ZERO_STRUCTP(id20); init_sam_user_info20A(id20, sampass); - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); return NT_STATUS_OK; } @@ -1937,7 +1937,7 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, SAM_USER_INFO_20 *id20, DO static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, DOM_SID *user_sid, DOM_SID *domain_sid) { - SAM_ACCOUNT *sampass=NULL; + struct samu *sampass=NULL; BOOL ret; NTSTATUS nt_status; @@ -1962,7 +1962,7 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, ZERO_STRUCTP(id21); nt_status = init_sam_user_info21A(id21, sampass, domain_sid); - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); return NT_STATUS_OK; } @@ -2073,7 +2073,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAMR_R_QUERY_USERGROUPS *r_u) { - SAM_ACCOUNT *sam_pass=NULL; + struct samu *sam_pass=NULL; DOM_SID sid; DOM_SID *sids; DOM_GID dom_gid; @@ -2150,7 +2150,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S DEBUG(5, ("Group sid %s for user %s not in our domain\n", sid_string_static(pdb_get_group_sid(sam_pass)), pdb_get_username(sam_pass))); - pdb_free_sam(&sam_pass); + TALLOC_FREE(sam_pass); return NT_STATUS_INTERNAL_DB_CORRUPTION; } @@ -2951,20 +2951,20 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A set_user_info_7 ********************************************************************/ static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx, - const SAM_USER_INFO_7 *id7, SAM_ACCOUNT *pwd) + const SAM_USER_INFO_7 *id7, struct samu *pwd) { fstring new_name; NTSTATUS rc; if (id7 == NULL) { DEBUG(5, ("set_user_info_7: NULL id7\n")); - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return NT_STATUS_ACCESS_DENIED; } if(!rpcstr_pull(new_name, id7->uni_name.buffer, sizeof(new_name), id7->uni_name.uni_str_len*2, 0)) { DEBUG(5, ("set_user_info_7: failed to get new username\n")); - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return NT_STATUS_ACCESS_DENIED; } @@ -2984,7 +2984,7 @@ static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx, rc = pdb_rename_sam_account(pwd, new_name); - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return rc; } @@ -2992,26 +2992,26 @@ static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx, set_user_info_16 ********************************************************************/ -static BOOL set_user_info_16(const SAM_USER_INFO_16 *id16, SAM_ACCOUNT *pwd) +static BOOL set_user_info_16(const SAM_USER_INFO_16 *id16, struct samu *pwd) { if (id16 == NULL) { DEBUG(5, ("set_user_info_16: NULL id16\n")); - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return False; } /* FIX ME: check if the value is really changed --metze */ if (!pdb_set_acct_ctrl(pwd, id16->acb_info, PDB_CHANGED)) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return False; } if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return False; } - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return True; } @@ -3020,34 +3020,34 @@ static BOOL set_user_info_16(const SAM_USER_INFO_16 *id16, SAM_ACCOUNT *pwd) set_user_info_18 ********************************************************************/ -static BOOL set_user_info_18(SAM_USER_INFO_18 *id18, SAM_ACCOUNT *pwd) +static BOOL set_user_info_18(SAM_USER_INFO_18 *id18, struct samu *pwd) { if (id18 == NULL) { DEBUG(2, ("set_user_info_18: id18 is NULL\n")); - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return False; } if (!pdb_set_lanman_passwd (pwd, id18->lm_pwd, PDB_CHANGED)) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return False; } if (!pdb_set_nt_passwd (pwd, id18->nt_pwd, PDB_CHANGED)) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return False; } if (!pdb_set_pass_changed_now (pwd)) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return False; } if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return False; } - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return True; } @@ -3055,7 +3055,7 @@ static BOOL set_user_info_18(SAM_USER_INFO_18 *id18, SAM_ACCOUNT *pwd) set_user_info_20 ********************************************************************/ -static BOOL set_user_info_20(SAM_USER_INFO_20 *id20, SAM_ACCOUNT *pwd) +static BOOL set_user_info_20(SAM_USER_INFO_20 *id20, struct samu *pwd) { if (id20 == NULL) { DEBUG(5, ("set_user_info_20: NULL id20\n")); @@ -3066,11 +3066,11 @@ static BOOL set_user_info_20(SAM_USER_INFO_20 *id20, SAM_ACCOUNT *pwd) /* write the change out */ if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return False; } - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return True; } @@ -3079,7 +3079,7 @@ static BOOL set_user_info_20(SAM_USER_INFO_20 *id20, SAM_ACCOUNT *pwd) ********************************************************************/ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, - SAM_ACCOUNT *pwd) + struct samu *pwd) { NTSTATUS status; @@ -3105,11 +3105,11 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, /* write the change out */ if(!NT_STATUS_IS_OK(status = pdb_update_sam_account(pwd))) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return status; } - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return NT_STATUS_OK; } @@ -3119,7 +3119,7 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, ********************************************************************/ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, - SAM_ACCOUNT *pwd) + struct samu *pwd) { pstring plaintext_buf; uint32 len; @@ -3137,12 +3137,12 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, acct_ctrl = pdb_get_acct_ctrl(pwd); if (!decode_pw_buffer(id23->pass, plaintext_buf, 256, &len, STR_UNICODE)) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return NT_STATUS_INVALID_PARAMETER; } if (!pdb_set_plaintext_passwd (pwd, plaintext_buf)) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return NT_STATUS_ACCESS_DENIED; } @@ -3162,7 +3162,7 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, } if(!chgpasswd(pdb_get_username(pwd), passwd, "", plaintext_buf, True)) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return NT_STATUS_ACCESS_DENIED; } } @@ -3173,16 +3173,16 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, if (IS_SAM_CHANGED(pwd, PDB_GROUPSID) && (!NT_STATUS_IS_OK(status = pdb_set_unix_primary_group(mem_ctx, pwd)))) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return status; } if(!NT_STATUS_IS_OK(status = pdb_update_sam_account(pwd))) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return status; } - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return NT_STATUS_OK; } @@ -3191,7 +3191,7 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, set_user_info_pw ********************************************************************/ -static BOOL set_user_info_pw(uint8 *pass, SAM_ACCOUNT *pwd) +static BOOL set_user_info_pw(uint8 *pass, struct samu *pwd) { uint32 len; pstring plaintext_buf; @@ -3205,12 +3205,12 @@ static BOOL set_user_info_pw(uint8 *pass, SAM_ACCOUNT *pwd) ZERO_STRUCT(plaintext_buf); if (!decode_pw_buffer(pass, plaintext_buf, 256, &len, STR_UNICODE)) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return False; } if (!pdb_set_plaintext_passwd (pwd, plaintext_buf)) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return False; } @@ -3228,7 +3228,7 @@ static BOOL set_user_info_pw(uint8 *pass, SAM_ACCOUNT *pwd) } if(!chgpasswd(pdb_get_username(pwd), passwd, "", plaintext_buf, True)) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return False; } } @@ -3240,11 +3240,11 @@ static BOOL set_user_info_pw(uint8 *pass, SAM_ACCOUNT *pwd) /* update the SAMBA password */ if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return False; } - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return True; } @@ -3255,7 +3255,7 @@ static BOOL set_user_info_pw(uint8 *pass, SAM_ACCOUNT *pwd) NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_USERINFO *r_u) { - SAM_ACCOUNT *pwd = NULL; + struct samu *pwd = NULL; DOM_SID sid; POLICY_HND *pol = &q_u->pol; uint16 switch_value = q_u->switch_value; @@ -3297,7 +3297,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE unbecome_root(); if ( !ret ) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return NT_STATUS_NO_SUCH_USER; } @@ -3401,7 +3401,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SET_USERINFO2 *r_u) { - SAM_ACCOUNT *pwd = NULL; + struct samu *pwd = NULL; DOM_SID sid; SAM_USERINFO_CTR *ctr = q_u->ctr; POLICY_HND *pol = &q_u->pol; @@ -3445,7 +3445,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ unbecome_root(); if ( !ret ) { - pdb_free_sam(&pwd); + TALLOC_FREE(pwd); return NT_STATUS_NO_SUCH_USER; } @@ -3897,7 +3897,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAMR_R_DELETE_DOM_USER *r_u ) { DOM_SID user_sid; - SAM_ACCOUNT *sam_pass=NULL; + struct samu *sam_pass=NULL; uint32 acc_granted; BOOL can_add_accounts; DISP_INFO *disp_info = NULL; @@ -3920,7 +3920,7 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM if(!pdb_getsampwsid(sam_pass, &user_sid)) { DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n", sid_string_static(&user_sid))); - pdb_free_sam(&sam_pass); + TALLOC_FREE(sam_pass); return NT_STATUS_NO_SUCH_USER; } @@ -3942,12 +3942,12 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM DEBUG(5,("_samr_delete_dom_user: Failed to delete entry for " "user %s: %s.\n", pdb_get_username(sam_pass), nt_errstr(r_u->status))); - pdb_free_sam(&sam_pass); + TALLOC_FREE(sam_pass); return r_u->status; } - pdb_free_sam(&sam_pass); + TALLOC_FREE(sam_pass); if (!close_policy_hnd(p, &q_u->user_pol)) return NT_STATUS_OBJECT_NAME_INVALID; diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 1d9a8ecd1d..03a726dd92 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -36,10 +36,10 @@ ((s1) && (s2) && (strcmp((s1), (s2)) != 0)) /************************************************************* - Copies a SAM_USER_INFO_20 to a SAM_ACCOUNT + Copies a SAM_USER_INFO_20 to a struct samu **************************************************************/ -void copy_id20_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_20 *from) +void copy_id20_to_sam_passwd(struct samu *to, SAM_USER_INFO_20 *from) { const char *old_string; char *new_string; @@ -63,10 +63,10 @@ void copy_id20_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_20 *from) } /************************************************************* - Copies a SAM_USER_INFO_21 to a SAM_ACCOUNT + Copies a SAM_USER_INFO_21 to a struct samu **************************************************************/ -void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) +void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) { time_t unix_time, stored_time; const char *old_string, *new_string; @@ -312,10 +312,10 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from) /************************************************************* - Copies a SAM_USER_INFO_23 to a SAM_ACCOUNT + Copies a SAM_USER_INFO_23 to a struct samu **************************************************************/ -void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from) +void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) { time_t unix_time, stored_time; const char *old_string, *new_string; -- cgit From cd559192633d78a9f06e239c6a448955f6ea0842 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 21 Feb 2006 14:34:11 +0000 Subject: r13590: * replace all pdb_init_sam[_talloc]() calls with samu_new() * replace all pdb_{init,fill}_sam_pw() calls with samu_set_unix() (This used to be commit 6f1afa4acc93a07d0ee9940822d7715acaae634f) --- source3/rpc_server/srv_netlog_nt.c | 11 ++++-- source3/rpc_server/srv_samr_nt.c | 69 ++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 39 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index ea0685f41b..a71d97ada7 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -229,8 +229,9 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) } #endif /* 0 */ - if(!NT_STATUS_IS_OK(pdb_init_sam(&sampass))) + if ( !(sampass = samu_new( NULL )) ) { return False; + } /* JRA. This is ok as it is only used for generating the challenge. */ become_root(); @@ -517,10 +518,14 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * secrets_store_schannel_session_info(p->pipe_state_mem_ctx, remote_machine, p->dc); - pdb_init_sam(&sampass); - ret=pdb_getsampwnam(sampass, p->dc->mach_acct); + if ( (sampass = samu_new( NULL )) != NULL ) { + ret = pdb_getsampwnam(sampass, p->dc->mach_acct); + } unbecome_root(); + if ( !sampass ) + return NT_STATUS_NO_MEMORY; + /* Ensure the account exists and is a machine account. */ acct_ctrl = pdb_get_acct_ctrl(sampass); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f9a28f1272..5c2950b491 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1693,10 +1693,9 @@ NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USE if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; - nt_status = pdb_init_sam_talloc(p->mem_ctx, &sampass); - - if (!NT_STATUS_IS_OK(nt_status)) - return nt_status; + if ( !(sampass = samu_new( p->mem_ctx )) ) { + return NT_STATUS_NO_MEMORY; + } /* append the user's RID to it */ @@ -1749,19 +1748,16 @@ static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_S { struct samu *smbpass=NULL; BOOL ret; - NTSTATUS nt_status; - nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass); - - if (!NT_STATUS_IS_OK(nt_status)) { - return nt_status; + if ( !(smbpass = samu_new( mem_ctx )) ) { + return NT_STATUS_NO_MEMORY; } - + become_root(); ret = pdb_getsampwsid(smbpass, user_sid); unbecome_root(); - if (ret==False) { + if ( !ret ) { DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); return NT_STATUS_NO_SUCH_USER; } @@ -1783,12 +1779,9 @@ static NTSTATUS get_user_info_9(TALLOC_CTX *mem_ctx, SAM_USER_INFO_9 * id9, DOM_ { struct samu *smbpass=NULL; BOOL ret; - NTSTATUS nt_status; - - nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass); - if (!NT_STATUS_IS_OK(nt_status)) { - return nt_status; + if ( !(smbpass = samu_new( mem_ctx )) ) { + return NT_STATUS_NO_MEMORY; } become_root(); @@ -1818,12 +1811,9 @@ static NTSTATUS get_user_info_16(TALLOC_CTX *mem_ctx, SAM_USER_INFO_16 *id16, DO { struct samu *smbpass=NULL; BOOL ret; - NTSTATUS nt_status; - nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass); - - if (!NT_STATUS_IS_OK(nt_status)) { - return nt_status; + if ( !(smbpass = samu_new( mem_ctx )) ) { + return NT_STATUS_NO_MEMORY; } become_root(); @@ -1855,7 +1845,6 @@ static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_ { struct samu *smbpass=NULL; BOOL ret; - NTSTATUS nt_status; if (p->auth.auth_type != PIPE_AUTH_TYPE_NTLMSSP || p->auth.auth_type != PIPE_AUTH_TYPE_SPNEGO_NTLMSSP) { return NT_STATUS_ACCESS_DENIED; @@ -1869,10 +1858,8 @@ static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_ * Do *NOT* do become_root()/unbecome_root() here ! JRA. */ - nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass); - - if (!NT_STATUS_IS_OK(nt_status)) { - return nt_status; + if ( !(smbpass = samu_new( mem_ctx )) ) { + return NT_STATUS_NO_MEMORY; } ret = pdb_getsampwsid(smbpass, user_sid); @@ -1907,7 +1894,9 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, SAM_USER_INFO_20 *id20, DO struct samu *sampass=NULL; BOOL ret; - pdb_init_sam_talloc(mem_ctx, &sampass); + if ( !(sampass = samu_new( mem_ctx )) ) { + return NT_STATUS_NO_MEMORY; + } become_root(); ret = pdb_getsampwsid(sampass, user_sid); @@ -1941,9 +1930,8 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, BOOL ret; NTSTATUS nt_status; - nt_status = pdb_init_sam_talloc(mem_ctx, &sampass); - if (!NT_STATUS_IS_OK(nt_status)) { - return nt_status; + if ( !(sampass = samu_new( mem_ctx )) ) { + return NT_STATUS_NO_MEMORY; } become_root(); @@ -2113,8 +2101,10 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S if (!sid_check_is_in_our_domain(&sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - pdb_init_sam_talloc(p->mem_ctx, &sam_pass); - + if ( !(sam_pass = samu_new( p->mem_ctx )) ) { + return NT_STATUS_NO_MEMORY; + } + become_root(); ret = pdb_getsampwsid(sam_pass, &sid); unbecome_root(); @@ -3290,7 +3280,9 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE return NT_STATUS_INVALID_INFO_CLASS; } - pdb_init_sam(&pwd); + if ( !(pwd = samu_new( NULL )) ) { + return NT_STATUS_NO_MEMORY; + } become_root(); ret = pdb_getsampwsid(pwd, &sid); @@ -3438,8 +3430,10 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ switch_value=ctr->switch_value; - pdb_init_sam(&pwd); - + if ( !(pwd = samu_new( NULL )) ) { + return NT_STATUS_NO_MEMORY; + } + become_root(); ret = pdb_getsampwsid(pwd, &sid); unbecome_root(); @@ -3916,7 +3910,10 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM return NT_STATUS_CANNOT_DELETE; /* check if the user exists before trying to delete */ - pdb_init_sam(&sam_pass); + if ( !(sam_pass = samu_new( NULL )) ) { + return NT_STATUS_NO_MEMORY; + } + if(!pdb_getsampwsid(sam_pass, &user_sid)) { DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n", sid_string_static(&user_sid))); -- cgit From cab298856ab1179cdaec2ef89121f7c66c6b6d76 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 22 Feb 2006 10:28:02 +0000 Subject: r13622: Allow to rename machine accounts in a Samba Domain. This still uses the "rename user script" to do the rename of the posix machine account (this might be changed later). Fixes #2331. Guenther (This used to be commit b2eac2e6eb6ddd1bcb4ed5172e7cd64144c18d16) --- source3/rpc_server/srv_samr_nt.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 5c2950b491..33de292d22 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3071,13 +3071,47 @@ static BOOL set_user_info_20(SAM_USER_INFO_20 *id20, struct samu *pwd) static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, struct samu *pwd) { + fstring new_name; NTSTATUS status; - + if (id21 == NULL) { DEBUG(5, ("set_user_info_21: NULL id21\n")); return NT_STATUS_INVALID_PARAMETER; } - + + /* we need to separately check for an account rename first */ + if (rpcstr_pull(new_name, id21->uni_user_name.buffer, + sizeof(new_name), id21->uni_user_name.uni_str_len*2, 0) && + (!strequal(new_name, pdb_get_username(pwd)))) { + + /* check to see if the new username already exists. Note: we can't + reliably lock all backends, so there is potentially the + possibility that a user can be created in between this check and + the rename. The rename should fail, but may not get the + exact same failure status code. I think this is small enough + of a window for this type of operation and the results are + simply that the rename fails with a slightly different status + code (like UNSUCCESSFUL instead of ALREADY_EXISTS). */ + + status = can_create(mem_ctx, new_name); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + status = pdb_rename_sam_account(pwd, new_name); + + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("set_user_info_21: failed to rename account: %s\n", + nt_errstr(status))); + TALLOC_FREE(pwd); + return status; + } + + /* set the new username so that later + functions can work on the new account */ + pdb_set_username(pwd, new_name, PDB_SET); + } + copy_id21_to_sam_passwd(pwd, id21); /* -- cgit From d95e13e68f3c7ac517a45877b351849ef4a99b93 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 24 Feb 2006 21:36:40 +0000 Subject: r13679: Commiting the rm_primary_group.patch posted on samba-technical * ignore the primary group SID attribute from struct samu* * generate the primary group SID strictlky from the Unix primary group when dealing with passdb users * Fix memory leak in original patch caused by failing to free a talloc * * add wrapper around samu_set_unix() to prevent exposing the create BOOL to callers. Wrappers are samu_set_unix() and samu-allic_rid_unix() (This used to be commit bcf269e2ec6630b78d909010fabd3b69dd6dda84) --- source3/rpc_server/srv_samr_nt.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 33de292d22..47e1a31535 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3121,17 +3121,16 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, * id21. I don't know if they need to be set. --jerry */ - if (IS_SAM_CHANGED(pwd, PDB_GROUPSID) && - !NT_STATUS_IS_OK(status = pdb_set_unix_primary_group(mem_ctx, - pwd))) { - return status; + if ( IS_SAM_CHANGED(pwd, PDB_GROUPSID) ) { + status = pdb_set_unix_primary_group(mem_ctx, pwd); + if ( !NT_STATUS_IS_OK(status) ) { + return status; + } } - - /* write the change out */ - if(!NT_STATUS_IS_OK(status = pdb_update_sam_account(pwd))) { - TALLOC_FREE(pwd); - return status; - } + + /* Don't worry about writing out the user account since the + primary group SID is generated solely from the user's Unix + primary group. */ TALLOC_FREE(pwd); -- cgit From e54786b53543b4667288c64abb55478fddd95061 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 27 Feb 2006 10:32:45 +0000 Subject: r13711: * Correctly handle acb_info/acct_flags as uint32 not as uint16. * Fix a couple of related parsing issues. * in the info3 reply in a samlogon, return the ACB-flags (instead of returning zero) Guenther (This used to be commit 5b89e8bc24f0fdc8b52d5c9e849aba723df34ea7) --- source3/rpc_server/srv_netlog_nt.c | 4 ++-- source3/rpc_server/srv_samr_nt.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index a71d97ada7..8dbd4ff33f 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -1016,12 +1016,12 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, pdb_get_pass_last_set_time(sampw), pdb_get_pass_can_change_time(sampw), pdb_get_pass_must_change_time(sampw), - 0, /* logon_count */ 0, /* bad_pw_count */ num_gids, /* uint32 num_groups */ gids , /* DOM_GID *gids */ - 0x20 , /* uint32 user_flgs (?) */ + LOGON_EXTRA_SIDS, /* uint32 user_flgs (?) */ + pdb_get_acct_ctrl(sampw), server_info->user_session_key.length ? user_session_key : NULL, server_info->lm_session_key.length ? lm_session_key : NULL, my_name , /* char *logon_srv */ diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 47e1a31535..fa5b080634 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -482,7 +482,7 @@ static void samr_clear_sam_passwd(struct samu *sam_pass) pdb_set_nt_passwd(sam_pass, NULL, PDB_DEFAULT); } -static uint32 count_sam_users(struct disp_info *info, uint16 acct_flags) +static uint32 count_sam_users(struct disp_info *info, uint32 acct_flags) { struct samr_displayentry *entry; @@ -3218,7 +3218,7 @@ static BOOL set_user_info_pw(uint8 *pass, struct samu *pwd) { uint32 len; pstring plaintext_buf; - uint16 acct_ctrl; + uint32 acct_ctrl; DEBUG(5, ("Attempting administrator password change for user %s\n", pdb_get_username(pwd))); -- cgit From aec8de1703cd034a253b06b26e849c01d8ce131f Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 27 Feb 2006 14:45:27 +0000 Subject: r13715: Put back the code that actually modify the account, removed, I presume by mistake, by Jerry in the recent patch the removes the primary group SID stuff. set_user_info_21 is called to update many other things like the description of a user for example (that's what failed on me). Jerry, please review this one. (This used to be commit 239a37d201168d095f600042b1ffcd047f18ba8a) --- source3/rpc_server/srv_samr_nt.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index fa5b080634..de6c28a38d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3132,6 +3132,12 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, primary group SID is generated solely from the user's Unix primary group. */ + /* write the change out */ + if(!NT_STATUS_IS_OK(status = pdb_update_sam_account(pwd))) { + TALLOC_FREE(pwd); + return status; + } + TALLOC_FREE(pwd); return NT_STATUS_OK; -- cgit From a2327fc68848a1352fed5273969d4c674b1dbd73 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 1 Mar 2006 03:10:21 +0000 Subject: r13766: Patch from Arek Glabek : * Fix parsing error in eventlogadm caused by log entries with no DAT: line. (This used to be commit f0a8f438793a806e8cf73e1e695b09e540a4239e) --- source3/rpc_server/srv_eventlog_lib.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index ec5edf2f34..b3d94901ba 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -707,16 +707,13 @@ BOOL parse_logentry( char *line, Eventlog_entry * entry, BOOL * eor ) memset( temp, 0, sizeof( temp ) ); strncpy( temp, stop, temp_len ); rpcstr_push( ( void * ) ( entry->data_record.strings + - entry->data_record.strings_len ), + ( entry->data_record.strings_len / 2 ) ), temp, sizeof( entry->data_record.strings ) - - entry->data_record.strings_len, STR_TERMINATE ); - entry->data_record.strings_len += temp_len + 1; + ( entry->data_record.strings_len / 2 ), STR_TERMINATE ); + entry->data_record.strings_len += ( temp_len * 2 ) + 2; entry->record.num_strings++; } else if ( 0 == strncmp( start, "DAT", stop - start ) ) { - /* Now that we're done processing the STR data, adjust the length to account for - unicode, then proceed with the DAT data. */ - entry->data_record.strings_len *= 2; /* skip past initial ":" */ stop++; /* now skip any other leading whitespace */ -- cgit From 1b456f2894fc663a9b6edbc51fe1b107ede196d8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 1 Mar 2006 21:56:59 +0000 Subject: r13778: When deleting machine accounts it's the SeMachineAccountPrivilege that counts. Jeremy. (This used to be commit aa85ba4f3799ffbe5c6f84f768f03a4c68d879dc) --- source3/rpc_server/srv_samr_nt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index de6c28a38d..e4dc92c08d 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3933,6 +3933,7 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM struct samu *sam_pass=NULL; uint32 acc_granted; BOOL can_add_accounts; + uint32 acb_info; DISP_INFO *disp_info = NULL; DEBUG(5, ("_samr_delete_dom_user: %d\n", __LINE__)); @@ -3960,7 +3961,14 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM return NT_STATUS_NO_SUCH_USER; } - can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users ); + acb_info = pdb_get_acct_ctrl(sam_pass); + + /* For machine accounts it's the SeMachineAccountPrivilege that counts. */ + if ( acb_info & ACB_WSTRUST ) { + can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_machine_account ); + } else { + can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users ); + } /******** BEGIN SeAddUsers BLOCK *********/ -- cgit From e33b728c7b2076917e2149191222b259e5c1d942 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 3 Mar 2006 16:44:30 +0000 Subject: r13815: "Into the blind world let us now descend," Began the poet, his face as pale as death. "I will go first, and you will follow me." --- Adding XcvDataPort() to the spoolss code for remotely add ports. The design is to allow an intuitive means of creating a new CUPS print queue from the Windows 2000/XP APW without hacks like specifying the deviceURI in the location field of the printer properties dialog. Also set 'default devmode = yes' as the new default since it causes no harm and only is executed when you have a NULL devmode anyways. (This used to be commit 123e478ce5b5f63a61d00197332b847e83722468) --- source3/rpc_server/srv_spoolss.c | 55 +++---------- source3/rpc_server/srv_spoolss_nt.c | 149 ++++++++++++++---------------------- 2 files changed, 68 insertions(+), 136 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index b3a67dd6cf..0a43e8ae8a 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1519,66 +1519,34 @@ static BOOL api_spoolss_deleteprinterdriverex(pipes_struct *p) return True; } -#if 0 - -/**************************************************************************** -****************************************************************************/ - -static BOOL api_spoolss_replyopenprinter(pipes_struct *p) -{ - SPOOL_Q_REPLYOPENPRINTER q_u; - SPOOL_R_REPLYOPENPRINTER r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!spoolss_io_q_replyopenprinter("", &q_u, data, 0)) { - DEBUG(0,("spoolss_io_q_replyopenprinter: unable to unmarshall SPOOL_Q_REPLYOPENPRINTER.\n")); - return False; - } - - r_u.status = _spoolss_replyopenprinter(p, &q_u, &r_u); - - if(!spoolss_io_r_replyopenprinter("", &r_u, rdata, 0)) { - DEBUG(0,("spoolss_io_r_replyopenprinter: unable to marshall SPOOL_R_REPLYOPENPRINTER.\n")); - return False; - } - - return True; -} - /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_replycloseprinter(pipes_struct *p) +static BOOL api_spoolss_xcvdataport(pipes_struct *p) { - SPOOL_Q_REPLYCLOSEPRINTER q_u; - SPOOL_R_REPLYCLOSEPRINTER r_u; + SPOOL_Q_XCVDATAPORT q_u; + SPOOL_R_XCVDATAPORT r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!spoolss_io_q_replycloseprinter("", &q_u, data, 0)) { - DEBUG(0,("spoolss_io_q_replycloseprinter: unable to unmarshall SPOOL_Q_REPLYCLOSEPRINTER.\n")); + if(!spoolss_io_q_xcvdataport("", &q_u, data, 0)) { + DEBUG(0,("spoolss_io_q_replyopenprinter: unable to unmarshall SPOOL_Q_XCVDATAPORT.\n")); return False; } - r_u.status = _spoolss_replycloseprinter(p, &q_u, &r_u); + r_u.status = _spoolss_xcvdataport(p, &q_u, &r_u); - if(!spoolss_io_r_replycloseprinter("", &r_u, rdata, 0)) { - DEBUG(0,("spoolss_io_r_replycloseprinter: unable to marshall SPOOL_R_REPLYCLOSEPRINTER.\n")); + if(!spoolss_io_r_xcvdataport("", &r_u, rdata, 0)) { + DEBUG(0,("spoolss_io_r_replyopenprinter: unable to marshall SPOOL_R_XCVDATAPORT.\n")); return False; } return True; } -#endif - /******************************************************************* \pipe\spoolss commands ********************************************************************/ @@ -1636,11 +1604,8 @@ static BOOL api_spoolss_replycloseprinter(pipes_struct *p) {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory}, {"SPOOLSS_ADDPRINTERDRIVEREX", SPOOLSS_ADDPRINTERDRIVEREX, api_spoolss_addprinterdriverex }, {"SPOOLSS_DELETEPRINTERDRIVEREX", SPOOLSS_DELETEPRINTERDRIVEREX, api_spoolss_deleteprinterdriverex }, -#if 0 - {"SPOOLSS_REPLYOPENPRINTER", SPOOLSS_REPLYOPENPRINTER, api_spoolss_replyopenprinter }, - {"SPOOLSS_REPLYCLOSEPRINTER", SPOOLSS_REPLYCLOSEPRINTER, api_spoolss_replycloseprinter } -#endif - }; + {"SPOOLSS_XCVDATAPORT", SPOOLSS_XCVDATAPORT, api_spoolss_xcvdataport }, +}; void spoolss_get_pipe_fns( struct api_struct **fns, int *n_fns ) { diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c767daf88c..cfa0cc7cba 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -435,7 +435,10 @@ static BOOL set_printer_hnd_printertype(Printer_entry *Printer, char *handlename } /**************************************************************************** - Set printer handle name. + Set printer handle name.. Accept names like \\server, \\server\printer, + \\server\SHARE, & "\\server\,XcvMonitor Standard TCP/IP Port" See + the MSDN docs regarding OpenPrinter() for details on the XcvData() and + XcvDataPort() interface. ****************************************************************************/ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) @@ -477,6 +480,14 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) return False; DEBUGADD(5, ("searching for [%s]\n", aprinter )); + + /* check for the TCPMON interface */ + + if ( strequal( aprinter, SPL_XCV_MONITOR_TCPMON ) ) { + Printer->printer_type = PRINTER_HANDLE_IS_TCPMON; + fstrcpy(sname, SPL_XCV_MONITOR_TCPMON); + found = True; + } /* Search all sharenames first as this is easier than pulling the printer_info_2 off of disk. Don't use find_service() since @@ -1473,60 +1484,6 @@ WERROR _spoolss_open_printer(pipes_struct *p, SPOOL_Q_OPEN_PRINTER *q_u, SPOOL_R } /******************************************************************** - * spoolss_open_printer - * - * If the openprinterex rpc call contains a devmode, - * it's a per-user one. This per-user devmode is derivated - * from the global devmode. Openprinterex() contains a per-user - * devmode for when you do EMF printing and spooling. - * In the EMF case, the NT workstation is only doing half the job - * of rendering the page. The other half is done by running the printer - * driver on the server. - * The EMF file doesn't contain the page description (paper size, orientation, ...). - * The EMF file only contains what is to be printed on the page. - * So in order for the server to know how to print, the NT client sends - * a devicemode attached to the openprinterex call. - * But this devicemode is short lived, it's only valid for the current print job. - * - * If Samba would have supported EMF spooling, this devicemode would - * have been attached to the handle, to sent it to the driver to correctly - * rasterize the EMF file. - * - * As Samba only supports RAW spooling, we only receive a ready-to-print file, - * we just act as a pass-thru between windows and the printer. - * - * In order to know that Samba supports only RAW spooling, NT has to call - * getprinter() at level 2 (attribute field) or NT has to call startdoc() - * and until NT sends a RAW job, we refuse it. - * - * But to call getprinter() or startdoc(), you first need a valid handle, - * and to get an handle you have to call openprintex(). Hence why you have - * a devicemode in the openprinterex() call. - * - * - * Differences between NT4 and NT 2000. - * NT4: - * --- - * On NT4, you only have a global devicemode. This global devicemode can be changed - * by the administrator (or by a user with enough privs). Everytime a user - * wants to print, the devicemode is resetted to the default. In Word, everytime - * you print, the printer's characteristics are always reset to the global devicemode. - * - * NT 2000: - * ------- - * In W2K, there is the notion of per-user devicemode. The first time you use - * a printer, a per-user devicemode is build from the global devicemode. - * If you change your per-user devicemode, it is saved in the registry, under the - * H_KEY_CURRENT_KEY sub_tree. So that everytime you print, you have your default - * printer preferences available. - * - * To change the per-user devicemode: it's the "Printing Preferences ..." button - * on the General Tab of the printer properties windows. - * - * To change the global devicemode: it's the "Printing Defaults..." button - * on the Advanced Tab of the printer properties window. - * - * JFM. ********************************************************************/ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, SPOOL_R_OPEN_PRINTER_EX *r_u) @@ -1581,10 +1538,15 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, * Second case: the user is opening a printer: * NT doesn't let us connect to a printer if the connecting user * doesn't have print permission. + * + * Third case: user is opening the TCP/IP port monitor + * access checks same as opening a handle to the print server. */ - if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + switch (Printer->printer_type ) { + case PRINTER_HANDLE_IS_PRINTSERVER: + case PRINTER_HANDLE_IS_TCPMON: /* Printserver handles use global struct... */ snum = -1; @@ -1642,10 +1604,9 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, ? "SERVER_ACCESS_ADMINISTER" : "SERVER_ACCESS_ENUMERATE" )); /* We fall through to return WERR_OK */ - - } - else - { + break; + + case PRINTER_HANDLE_IS_PRINTER: /* NT doesn't let us connect to a printer if the connecting user doesn't have print permission. */ @@ -1702,6 +1663,11 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, DEBUG(4,("Setting printer access = %s\n", (printer_default->access_required == PRINTER_ACCESS_ADMINISTER) ? "PRINTER_ACCESS_ADMINISTER" : "PRINTER_ACCESS_USE" )); + break; + + default: + /* sanity check to prevent programmer error */ + return WERR_BADFID; } Printer->access_granted = printer_default->access_required; @@ -8496,18 +8462,22 @@ WERROR _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDAT static WERROR enumprintmonitors_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - PRINTMONITOR_1 *info_1=NULL; + PRINTMONITOR_1 *info_1; WERROR result = WERR_OK; + int i; - if((info_1 = SMB_MALLOC_P(PRINTMONITOR_1)) == NULL) + if((info_1 = SMB_MALLOC_ARRAY(PRINTMONITOR_1, 2)) == NULL) return WERR_NOMEM; - (*returned) = 0x1; + *returned = 2; - init_unistr(&info_1->name, "Local Port"); - - *needed += spoolss_size_printmonitor_info_1(info_1); + init_unistr(&(info_1[0].name), "Local Port"); + init_unistr(&(info_1[1].name), "Standard TCP/IP Port"); + for ( i=0; i<*returned; i++ ) { + *needed += spoolss_size_printmonitor_info_1(&info_1[i]); + } + if (*needed > offered) { result = WERR_INSUFFICIENT_BUFFER; goto out; @@ -8518,7 +8488,9 @@ static WERROR enumprintmonitors_level_1(RPC_BUFFER *buffer, uint32 offered, uint goto out; } - smb_io_printmonitor_info_1("", buffer, info_1, 0); + for ( i=0; i<*returned; i++ ) { + smb_io_printmonitor_info_1("", buffer, &info_1[i], 0); + } out: SAFE_FREE(info_1); @@ -8535,20 +8507,27 @@ out: static WERROR enumprintmonitors_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - PRINTMONITOR_2 *info_2=NULL; + PRINTMONITOR_2 *info_2; WERROR result = WERR_OK; + int i; - if((info_2 = SMB_MALLOC_P(PRINTMONITOR_2)) == NULL) + if((info_2 = SMB_MALLOC_ARRAY(PRINTMONITOR_2, 2)) == NULL) return WERR_NOMEM; - (*returned) = 0x1; + *returned = 2; - init_unistr(&info_2->name, "Local Port"); - init_unistr(&info_2->environment, "Windows NT X86"); - init_unistr(&info_2->dll_name, "localmon.dll"); - - *needed += spoolss_size_printmonitor_info_2(info_2); + init_unistr(&(info_2[0].name), "Local Port"); + init_unistr(&(info_2[0].environment), "Windows NT X86"); + init_unistr(&(info_2[0].dll_name), "localmon.dll"); + + init_unistr(&(info_2[1].name), "Standard TCP/IP Port"); + init_unistr(&(info_2[1].environment), "Windows NT X86"); + init_unistr(&(info_2[1].dll_name), "tcpmon.dll"); + for ( i=0; i<*returned; i++ ) { + *needed += spoolss_size_printmonitor_info_2(&info_2[i]); + } + if (*needed > offered) { result = WERR_INSUFFICIENT_BUFFER; goto out; @@ -8559,7 +8538,9 @@ static WERROR enumprintmonitors_level_2(RPC_BUFFER *buffer, uint32 offered, uint goto out; } - smb_io_printmonitor_info_2("", buffer, info_2, 0); + for ( i=0; i<*returned; i++ ) { + smb_io_printmonitor_info_2("", buffer, &info_2[i], 0); + } out: SAFE_FREE(info_2); @@ -9398,23 +9379,9 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC return result; } -#if 0 - -WERROR _spoolss_replyopenprinter(pipes_struct *p, SPOOL_Q_REPLYOPENPRINTER *q_u, - SPOOL_R_REPLYOPENPRINTER *r_u) +WERROR _spoolss_xcvdataport(pipes_struct *p, SPOOL_Q_XCVDATAPORT *q_u, SPOOL_R_XCVDATAPORT *r_u) { - DEBUG(5,("_spoolss_replyopenprinter\n")); - - DEBUG(10, ("replyopenprinter for localprinter %d\n", q_u->printer)); - return WERR_OK; } -WERROR _spoolss_replycloseprinter(pipes_struct *p, SPOOL_Q_REPLYCLOSEPRINTER *q_u, - SPOOL_R_REPLYCLOSEPRINTER *r_u) -{ - DEBUG(5,("_spoolss_replycloseprinter\n")); - return WERR_OK; -} -#endif -- cgit From 354c24d5257bad429c300b5cb7052d034d48d7a9 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 3 Mar 2006 19:28:51 +0000 Subject: r13820: * Start fleshing out the XcvDataPort() server implementation * Add support for the "Local Port" monitor as well through this API (This used to be commit ba9cdd88a0abf90a9c04959e554d7e4f10d17ff7) --- source3/rpc_server/srv_spoolss_nt.c | 135 ++++++++++++++++++++++++++---------- 1 file changed, 99 insertions(+), 36 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cfa0cc7cba..2f2f599f43 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -200,10 +200,10 @@ static void free_printer_entry(void *ptr) if (Printer->notify.client_connected==True) { int snum = -1; - if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) { + if ( Printer->printer_type == SPLHND_SERVER) { snum = -1; srv_spoolss_replycloseprinter(snum, &Printer->notify.client_hnd); - } else if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) { + } else if (Printer->printer_type == SPLHND_PRINTER) { snum = print_queue_snum(Printer->sharename); if (snum != -1) srv_spoolss_replycloseprinter(snum, @@ -395,11 +395,11 @@ static BOOL get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number) } switch (Printer->printer_type) { - case PRINTER_HANDLE_IS_PRINTER: + case SPLHND_PRINTER: DEBUG(4,("short name:%s\n", Printer->sharename)); *number = print_queue_snum(Printer->sharename); return (*number != -1); - case PRINTER_HANDLE_IS_PRINTSERVER: + case SPLHND_SERVER: return False; default: return False; @@ -423,12 +423,12 @@ static BOOL set_printer_hnd_printertype(Printer_entry *Printer, char *handlename /* it's a print server */ if (*handlename=='\\' && *(handlename+1)=='\\' && !strchr_m(handlename+2, '\\')) { DEBUGADD(4,("Printer is a print server\n")); - Printer->printer_type = PRINTER_HANDLE_IS_PRINTSERVER; + Printer->printer_type = SPLHND_SERVER; } - /* it's a printer */ + /* it's a printer (set_printer_hnd_name() will handle port monitors */ else { DEBUGADD(4,("Printer is a printer\n")); - Printer->printer_type = PRINTER_HANDLE_IS_PRINTER; + Printer->printer_type = SPLHND_PRINTER; } return True; @@ -473,21 +473,26 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) fstrcpy( Printer->servername, servername ); - if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER ) + if ( Printer->printer_type == SPLHND_SERVER ) return True; - if ( Printer->printer_type != PRINTER_HANDLE_IS_PRINTER ) + if ( Printer->printer_type != SPLHND_PRINTER ) return False; DEBUGADD(5, ("searching for [%s]\n", aprinter )); - /* check for the TCPMON interface */ + /* check for the Port Monitor Interface */ if ( strequal( aprinter, SPL_XCV_MONITOR_TCPMON ) ) { - Printer->printer_type = PRINTER_HANDLE_IS_TCPMON; + Printer->printer_type = SPLHND_PORTMON_TCP; fstrcpy(sname, SPL_XCV_MONITOR_TCPMON); found = True; } + else if ( strequal( aprinter, SPL_XCV_MONITOR_LOCALMON ) ) { + Printer->printer_type = SPLHND_PORTMON_LOCAL; + fstrcpy(sname, SPL_XCV_MONITOR_LOCALMON); + found = True; + } /* Search all sharenames first as this is easier than pulling the printer_info_2 off of disk. Don't use find_service() since @@ -954,7 +959,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) /* For this printer? Print servers always receive notifications. */ - if ( ( p->printer_type == PRINTER_HANDLE_IS_PRINTER ) && + if ( ( p->printer_type == SPLHND_PRINTER ) && ( !strequal(msg_group->printername, p->sharename) ) ) continue; @@ -996,7 +1001,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) * --jerry */ - if ( ( p->printer_type == PRINTER_HANDLE_IS_PRINTER ) && ( msg->type == PRINTER_NOTIFY_TYPE ) ) + if ( ( p->printer_type == SPLHND_PRINTER ) && ( msg->type == PRINTER_NOTIFY_TYPE ) ) id = 0; else id = msg->id; @@ -1260,7 +1265,7 @@ void update_monitored_printq_cache( void ) client_connected == True */ while ( printer ) { - if ( (printer->printer_type == PRINTER_HANDLE_IS_PRINTER) + if ( (printer->printer_type == SPLHND_PRINTER) && printer->notify.client_connected ) { snum = print_queue_snum(printer->sharename); @@ -1539,14 +1544,15 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, * NT doesn't let us connect to a printer if the connecting user * doesn't have print permission. * - * Third case: user is opening the TCP/IP port monitor + * Third case: user is opening a Port Monitor * access checks same as opening a handle to the print server. */ switch (Printer->printer_type ) { - case PRINTER_HANDLE_IS_PRINTSERVER: - case PRINTER_HANDLE_IS_TCPMON: + case SPLHND_SERVER: + case SPLHND_PORTMON_TCP: + case SPLHND_PORTMON_LOCAL: /* Printserver handles use global struct... */ snum = -1; @@ -1606,7 +1612,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* We fall through to return WERR_OK */ break; - case PRINTER_HANDLE_IS_PRINTER: + case SPLHND_PRINTER: /* NT doesn't let us connect to a printer if the connecting user doesn't have print permission. */ @@ -1677,7 +1683,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, * save it here in case we get a job submission on this handle */ - if ( (Printer->printer_type != PRINTER_HANDLE_IS_PRINTSERVER) + if ( (Printer->printer_type != SPLHND_SERVER) && q_u->printer_default.devmode_cont.devmode_ptr ) { convert_devicemode( Printer->sharename, q_u->printer_default.devmode_cont.devmode, @@ -2431,7 +2437,7 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO unistr2_to_ascii(value, valuename, sizeof(value)-1); - if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER ) + if ( Printer->printer_type == SPLHND_SERVER ) status = getprinterdata_printer_server( p->mem_ctx, value, type, data, needed, *out_size ); else { @@ -2650,9 +2656,9 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE /* Connect to the client machine and send a ReplyOpenPrinter */ - if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + if ( Printer->printer_type == SPLHND_SERVER) snum = -1; - else if ( (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && + else if ( (Printer->printer_type == SPLHND_PRINTER) && !get_printer_snum(p, handle, &snum) ) return WERR_BADFID; @@ -3842,11 +3848,11 @@ WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN /* just ignore the SPOOL_NOTIFY_OPTION */ switch (Printer->printer_type) { - case PRINTER_HANDLE_IS_PRINTSERVER: + case SPLHND_SERVER: result = printserver_notify_info(p, handle, info, p->mem_ctx); break; - case PRINTER_HANDLE_IS_PRINTER: + case SPLHND_PRINTER: result = printer_notify_info(p, handle, info, p->mem_ctx); break; } @@ -6287,9 +6293,9 @@ WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) if (Printer->notify.client_connected==True) { int snum = -1; - if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) + if ( Printer->printer_type == SPLHND_SERVER) snum = -1; - else if ( (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && + else if ( (Printer->printer_type == SPLHND_PRINTER) && !get_printer_snum(p, handle, &snum) ) return WERR_BADFID; @@ -7971,7 +7977,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP return WERR_BADFID; } - if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER ) { + if ( Printer->printer_type == SPLHND_SERVER ) { DEBUG(10,("_spoolss_setprinterdata: Not implemented for server handles yet\n")); return WERR_INVALID_PARAM; } @@ -8128,7 +8134,7 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM /* forms can be added on printer of on the print server handle */ - if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + if ( Printer->printer_type == SPLHND_PRINTER ) { if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; @@ -8164,7 +8170,7 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM * ChangeID must always be set if this is a printer */ - if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + if ( Printer->printer_type == SPLHND_PRINTER ) status = mod_a_printer(printer, 2); done: @@ -8199,7 +8205,7 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE /* forms can be deleted on printer of on the print server handle */ - if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + if ( Printer->printer_type == SPLHND_PRINTER ) { if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; @@ -8231,7 +8237,7 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE * ChangeID must always be set if this is a printer */ - if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + if ( Printer->printer_type == SPLHND_PRINTER ) status = mod_a_printer(printer, 2); done: @@ -8267,7 +8273,7 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * /* forms can be modified on printer of on the print server handle */ - if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + if ( Printer->printer_type == SPLHND_PRINTER ) { if (!get_printer_snum(p,handle, &snum)) return WERR_BADFID; @@ -8297,7 +8303,7 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * * ChangeID must always be set if this is a printer */ - if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTER ) + if ( Printer->printer_type == SPLHND_PRINTER ) status = mod_a_printer(printer, 2); @@ -8824,7 +8830,7 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, /* Is the handle to a printer or to the server? */ - if (Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER) { + if (Printer->printer_type == SPLHND_SERVER) { DEBUG(10,("_spoolss_getprinterdataex: Not implemented for server handles yet\n")); status = WERR_INVALID_PARAM; goto done; @@ -8911,7 +8917,7 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, return WERR_BADFID; } - if ( Printer->printer_type == PRINTER_HANDLE_IS_PRINTSERVER ) { + if ( Printer->printer_type == SPLHND_SERVER ) { DEBUG(10,("_spoolss_setprinterdataex: Not implemented for server handles yet\n")); return WERR_INVALID_PARAM; } @@ -9379,9 +9385,66 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC return result; } -WERROR _spoolss_xcvdataport(pipes_struct *p, SPOOL_Q_XCVDATAPORT *q_u, SPOOL_R_XCVDATAPORT *r_u) +/******************************************************************* +*******************************************************************/ + +static WERROR process_xcvtcp_command( const char *command, RPC_BUFFER *inbuf, RPC_BUFFER *outbuf ) +{ + DEBUG(10,("process_xcvtcp_command: Received command \"%s\"\n", command)); + + return WERR_OK; +} + +/******************************************************************* +*******************************************************************/ + +static WERROR process_xcvlocal_command( const char *command, RPC_BUFFER *inbuf, RPC_BUFFER *outbuf ) { + DEBUG(10,("process_xcvlocal_command: Received command \"%s\"\n", command)); + return WERR_OK; } +/******************************************************************* +*******************************************************************/ + +WERROR _spoolss_xcvdataport(pipes_struct *p, SPOOL_Q_XCVDATAPORT *q_u, SPOOL_R_XCVDATAPORT *r_u) +{ + Printer_entry *Printer = find_printer_index_by_hnd(p, &q_u->handle); + fstring command; + + if (!Printer) { + DEBUG(2,("_spoolss_xcvdataport: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(&q_u->handle))); + return WERR_BADFID; + } + + /* Has to be a handle to the TCP/IP port monitor */ + + if ( Printer->printer_type != SPLHND_PORTMON_TCP ) { + DEBUG(2,("_spoolss_xcvdataport: Call only valid for the TCP/IP Port Monitor\n")); + return WERR_BADFID; + } + + /* requires administrative access to the server */ + + if ( !(Printer->access_granted & SERVER_ACCESS_ADMINISTER) ) { + DEBUG(2,("_spoolss_xcvdataport: denied by handle permissions.\n")); + return WERR_ACCESS_DENIED; + } + + /* Get the command name. There's numerous commands supported by the + TCPMON interface. */ + + rpcstr_pull(command, q_u->dataname.buffer, sizeof(command), q_u->dataname.uni_str_len*2, 0); + + switch ( Printer->printer_type ) { + case SPLHND_PORTMON_TCP: + return process_xcvtcp_command( command, &q_u->indata, &r_u->outdata ); + case SPLHND_PORTMON_LOCAL: + return process_xcvlocal_command( command, &q_u->indata, &r_u->outdata ); + } + + return WERR_INVALID_PRINT_MONITOR; +} + -- cgit From 2a7847ea378ca71e7901c1bed6fdcf87ff8f1d70 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 3 Mar 2006 19:39:59 +0000 Subject: r13821: replacing some strings with macros (This used to be commit a34ab5c827630a5517e4c706877a172e6063f227) --- source3/rpc_server/srv_spoolss_nt.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2f2f599f43..98abd9d15e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7147,13 +7147,15 @@ static void fill_port_1(PORT_INFO_1 *port, const char *name) } /**************************************************************************** + TODO: This probably needs distinguish between TCP/IP and Local ports + somehow. ****************************************************************************/ static void fill_port_2(PORT_INFO_2 *port, const char *name) { init_unistr(&port->port_name, name); init_unistr(&port->monitor_name, "Local Monitor"); - init_unistr(&port->description, "Local Port"); + init_unistr(&port->description, SPL_LOCAL_PORT ); port->port_type=PORT_TYPE_WRITE; port->reserved=0x0; } @@ -8477,8 +8479,8 @@ static WERROR enumprintmonitors_level_1(RPC_BUFFER *buffer, uint32 offered, uint *returned = 2; - init_unistr(&(info_1[0].name), "Local Port"); - init_unistr(&(info_1[1].name), "Standard TCP/IP Port"); + init_unistr(&(info_1[0].name), SPL_LOCAL_PORT ); + init_unistr(&(info_1[1].name), SPL_TCPIP_PORT ); for ( i=0; i<*returned; i++ ) { *needed += spoolss_size_printmonitor_info_1(&info_1[i]); @@ -8522,13 +8524,13 @@ static WERROR enumprintmonitors_level_2(RPC_BUFFER *buffer, uint32 offered, uint *returned = 2; - init_unistr(&(info_2[0].name), "Local Port"); - init_unistr(&(info_2[0].environment), "Windows NT X86"); - init_unistr(&(info_2[0].dll_name), "localmon.dll"); + init_unistr( &(info_2[0].name), SPL_LOCAL_PORT ); + init_unistr( &(info_2[0].environment), "Windows NT X86" ); + init_unistr( &(info_2[0].dll_name), "localmon.dll" ); - init_unistr(&(info_2[1].name), "Standard TCP/IP Port"); - init_unistr(&(info_2[1].environment), "Windows NT X86"); - init_unistr(&(info_2[1].dll_name), "tcpmon.dll"); + init_unistr( &(info_2[1].name), SPL_TCPIP_PORT ); + init_unistr( &(info_2[1].environment), "Windows NT X86" ); + init_unistr( &(info_2[1].dll_name), "tcpmon.dll" ); for ( i=0; i<*returned; i++ ) { *needed += spoolss_size_printmonitor_info_2(&info_2[i]); -- cgit From 889ff32b5eb6ac60bc6f490ceb85dceee77c18d9 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 3 Mar 2006 20:49:31 +0000 Subject: r13824: * add api table for Xcv TCPMON and LOCALMON calls starting with the "MonitorUI" call * Fix some parsing errors This gets us to the Add Port Wizard dialog. (This used to be commit a444aa7f0088fb71ff89df8c280209188b33ec3d) --- source3/rpc_server/srv_spoolss_nt.c | 101 +++++++++++++++++++++++++++++++++--- 1 file changed, 93 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 98abd9d15e..126c2cc140 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -86,6 +86,15 @@ extern STANDARD_MAPPING printer_std_mapping, printserver_std_mapping; #define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ ((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) + +/* API table for Xcv Monitor functions */ + +struct xcv_api_table { + const char *name; + WERROR(*fn) (RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed); +}; + + /* translate between internal status numbers and NT status numbers */ static int nt_printj_status(int v) { @@ -9387,24 +9396,95 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC return result; } +/******************************************************************* + Streams the monitor UI DLL name in UNICODE +*******************************************************************/ + +static WERROR xcvtcp_monitorui( RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed ) +{ + const char *dllname = "tcpmonui.dll"; + + *needed = (strlen(dllname)+1) * 2; + + if ( rpcbuf_get_size(out) < *needed ) { + return WERR_INSUFFICIENT_BUFFER; + } + + if ( !make_monitorui_buf( out, dllname ) ) { + return WERR_NOMEM; + } + + return WERR_OK; +} + /******************************************************************* *******************************************************************/ -static WERROR process_xcvtcp_command( const char *command, RPC_BUFFER *inbuf, RPC_BUFFER *outbuf ) +struct xcv_api_table xcvtcp_cmds[] = { + { "MonitorUI", xcvtcp_monitorui }, + { NULL, NULL } +}; + +static WERROR process_xcvtcp_command( const char *command, RPC_BUFFER *inbuf, + RPC_BUFFER *outbuf, uint32 *needed ) { + int i; + DEBUG(10,("process_xcvtcp_command: Received command \"%s\"\n", command)); + for ( i=0; xcvtcp_cmds[i].name; i++ ) { + if ( strcmp( command, xcvtcp_cmds[i].name ) == 0 ) + return xcvtcp_cmds[i].fn( inbuf, outbuf, needed ); + } + + return WERR_BADFUNC; +} + +/******************************************************************* +*******************************************************************/ + +static WERROR xcvlocal_monitorui( RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed ) +{ + const char *dllname = "localui.dll"; + + *needed = (strlen(dllname)+1) * 2; + + if ( rpcbuf_get_size(out) < *needed ) { + return WERR_INSUFFICIENT_BUFFER; + } + + if ( !make_monitorui_buf( out, dllname )) { + return WERR_NOMEM; + } + return WERR_OK; } /******************************************************************* *******************************************************************/ -static WERROR process_xcvlocal_command( const char *command, RPC_BUFFER *inbuf, RPC_BUFFER *outbuf ) +struct xcv_api_table xcvlocal_cmds[] = { + { "MonitorUI", xcvlocal_monitorui }, + { NULL, NULL } +}; + + +/******************************************************************* +*******************************************************************/ + +static WERROR process_xcvlocal_command( const char *command, RPC_BUFFER *inbuf, + RPC_BUFFER *outbuf, uint32 *needed ) { + int i; + DEBUG(10,("process_xcvlocal_command: Received command \"%s\"\n", command)); - return WERR_OK; + + for ( i=0; xcvlocal_cmds[i].name; i++ ) { + if ( strcmp( command, xcvlocal_cmds[i].name ) == 0 ) + return xcvlocal_cmds[i].fn( inbuf, outbuf , needed ); + } + return WERR_BADFUNC; } /******************************************************************* @@ -9422,8 +9502,8 @@ WERROR _spoolss_xcvdataport(pipes_struct *p, SPOOL_Q_XCVDATAPORT *q_u, SPOOL_R_X /* Has to be a handle to the TCP/IP port monitor */ - if ( Printer->printer_type != SPLHND_PORTMON_TCP ) { - DEBUG(2,("_spoolss_xcvdataport: Call only valid for the TCP/IP Port Monitor\n")); + if ( !(Printer->printer_type & (SPLHND_PORTMON_LOCAL|SPLHND_PORTMON_TCP)) ) { + DEBUG(2,("_spoolss_xcvdataport: Call only valid for Port Monitors\n")); return WERR_BADFID; } @@ -9437,13 +9517,18 @@ WERROR _spoolss_xcvdataport(pipes_struct *p, SPOOL_Q_XCVDATAPORT *q_u, SPOOL_R_X /* Get the command name. There's numerous commands supported by the TCPMON interface. */ - rpcstr_pull(command, q_u->dataname.buffer, sizeof(command), q_u->dataname.uni_str_len*2, 0); + rpcstr_pull(command, q_u->dataname.buffer, sizeof(command), + q_u->dataname.uni_str_len*2, 0); + + /* Allocate the outgoing buffer */ + + rpcbuf_init( &r_u->outdata, q_u->offered, p->mem_ctx ); switch ( Printer->printer_type ) { case SPLHND_PORTMON_TCP: - return process_xcvtcp_command( command, &q_u->indata, &r_u->outdata ); + return process_xcvtcp_command( command, &q_u->indata, &r_u->outdata, &r_u->needed ); case SPLHND_PORTMON_LOCAL: - return process_xcvlocal_command( command, &q_u->indata, &r_u->outdata ); + return process_xcvlocal_command( command, &q_u->indata, &r_u->outdata, &r_u->needed ); } return WERR_INVALID_PRINT_MONITOR; -- cgit From 5df58c38f3c29d87c5918d1611c17e016c6f7545 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 4 Mar 2006 00:05:40 +0000 Subject: r13829: From the "It's not pretty but it works" category * Finish prototype of the "add port command" implementation Format is "addportcommand portname deviceURI" * DeviceURI is either - socket://hostname:port/ - lpr://hostname/queue depending on what the client sent in the request (This used to be commit 6d74de7a676b71e83a3c3714743e6380c04e4425) --- source3/rpc_server/srv_spoolss_nt.c | 112 ++++++++++++++++++++++++++++++++---- 1 file changed, 101 insertions(+), 11 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 126c2cc140..a9d4e14aae 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -91,7 +91,7 @@ extern STANDARD_MAPPING printer_std_mapping, printserver_std_mapping; struct xcv_api_table { const char *name; - WERROR(*fn) (RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed); + WERROR(*fn) (NT_USER_TOKEN *token, RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed); }; @@ -5956,6 +5956,52 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) /**************************************************************************** ****************************************************************************/ +WERROR add_port_hook(NT_USER_TOKEN *token, const char *portname, const char *uri ) +{ + char *cmd = lp_addport_cmd(); + pstring command; + int ret; + int fd; + SE_PRIV se_printop = SE_PRINT_OPERATOR; + BOOL is_print_op = False; + + if ( !*cmd ) { + return WERR_ACCESS_DENIED; + } + + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", cmd, portname, uri ); + + if ( token ) + is_print_op = user_has_privileges( token, &se_printop ); + + DEBUG(10,("Running [%s]\n", command)); + + /********* BEGIN SePrintOperatorPrivilege **********/ + + if ( is_print_op ) + become_root(); + + ret = smbrun(command, &fd); + + if ( is_print_op ) + unbecome_root(); + + /********* END SePrintOperatorPrivilege **********/ + + DEBUGADD(10,("returned [%d]\n", ret)); + + if ( ret != 0 ) { + if (fd != -1) + close(fd); + return WERR_ACCESS_DENIED; + } + + return WERR_OK; +} + +/**************************************************************************** +****************************************************************************/ + BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) { char *cmd = lp_addprinter_cmd(); @@ -6025,6 +6071,7 @@ BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) return True; } + /******************************************************************** * Called by spoolss_api_setprinter * when updating a printer description. @@ -9400,7 +9447,8 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC Streams the monitor UI DLL name in UNICODE *******************************************************************/ -static WERROR xcvtcp_monitorui( RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed ) +static WERROR xcvtcp_monitorui( NT_USER_TOKEN *token, RPC_BUFFER *in, + RPC_BUFFER *out, uint32 *needed ) { const char *dllname = "tcpmonui.dll"; @@ -9417,16 +9465,54 @@ static WERROR xcvtcp_monitorui( RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed return WERR_OK; } +/******************************************************************* + Create a new TCP/IP port +*******************************************************************/ + +static WERROR xcvtcp_addport( NT_USER_TOKEN *token, RPC_BUFFER *in, + RPC_BUFFER *out, uint32 *needed ) +{ + NT_PORT_DATA_1 port1; + pstring device_uri; + + ZERO_STRUCT( port1 ); + + /* convert to our internal port data structure */ + + if ( !convert_port_data_1( &port1, in ) ) { + return WERR_NOMEM; + } + + /* create the device URI and call the add_port_hook() */ + + switch ( port1.protocol ) { + case PORT_PROTOCOL_DIRECT: + pstr_sprintf( device_uri, "socket://%s:%d/", port1.hostaddr, port1.port ); + break; + + case PORT_PROTOCOL_LPR: + pstr_sprintf( device_uri, "lpr://%s/%s", port1.hostaddr, port1.queue ); + break; + + default: + return WERR_UNKNOWN_PORT; + } + + return add_port_hook( token, port1.name, device_uri ); +} + /******************************************************************* *******************************************************************/ struct xcv_api_table xcvtcp_cmds[] = { { "MonitorUI", xcvtcp_monitorui }, + { "AddPort", xcvtcp_addport}, { NULL, NULL } }; -static WERROR process_xcvtcp_command( const char *command, RPC_BUFFER *inbuf, - RPC_BUFFER *outbuf, uint32 *needed ) +static WERROR process_xcvtcp_command( NT_USER_TOKEN *token, const char *command, + RPC_BUFFER *inbuf, RPC_BUFFER *outbuf, + uint32 *needed ) { int i; @@ -9434,7 +9520,7 @@ static WERROR process_xcvtcp_command( const char *command, RPC_BUFFER *inbuf, for ( i=0; xcvtcp_cmds[i].name; i++ ) { if ( strcmp( command, xcvtcp_cmds[i].name ) == 0 ) - return xcvtcp_cmds[i].fn( inbuf, outbuf, needed ); + return xcvtcp_cmds[i].fn( token, inbuf, outbuf, needed ); } return WERR_BADFUNC; @@ -9443,7 +9529,8 @@ static WERROR process_xcvtcp_command( const char *command, RPC_BUFFER *inbuf, /******************************************************************* *******************************************************************/ -static WERROR xcvlocal_monitorui( RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed ) +static WERROR xcvlocal_monitorui( NT_USER_TOKEN *token, RPC_BUFFER *in, + RPC_BUFFER *out, uint32 *needed ) { const char *dllname = "localui.dll"; @@ -9472,8 +9559,9 @@ struct xcv_api_table xcvlocal_cmds[] = { /******************************************************************* *******************************************************************/ -static WERROR process_xcvlocal_command( const char *command, RPC_BUFFER *inbuf, - RPC_BUFFER *outbuf, uint32 *needed ) +static WERROR process_xcvlocal_command( NT_USER_TOKEN *token, const char *command, + RPC_BUFFER *inbuf, RPC_BUFFER *outbuf, + uint32 *needed ) { int i; @@ -9482,7 +9570,7 @@ static WERROR process_xcvlocal_command( const char *command, RPC_BUFFER *inbuf, for ( i=0; xcvlocal_cmds[i].name; i++ ) { if ( strcmp( command, xcvlocal_cmds[i].name ) == 0 ) - return xcvlocal_cmds[i].fn( inbuf, outbuf , needed ); + return xcvlocal_cmds[i].fn( token, inbuf, outbuf , needed ); } return WERR_BADFUNC; } @@ -9526,9 +9614,11 @@ WERROR _spoolss_xcvdataport(pipes_struct *p, SPOOL_Q_XCVDATAPORT *q_u, SPOOL_R_X switch ( Printer->printer_type ) { case SPLHND_PORTMON_TCP: - return process_xcvtcp_command( command, &q_u->indata, &r_u->outdata, &r_u->needed ); + return process_xcvtcp_command( p->pipe_user.nt_user_token, command, + &q_u->indata, &r_u->outdata, &r_u->needed ); case SPLHND_PORTMON_LOCAL: - return process_xcvlocal_command( command, &q_u->indata, &r_u->outdata, &r_u->needed ); + return process_xcvlocal_command( p->pipe_user.nt_user_token, command, + &q_u->indata, &r_u->outdata, &r_u->needed ); } return WERR_INVALID_PRINT_MONITOR; -- cgit From 129fd6c5c641cf4c2db31eb093baebd08df63107 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 6 Mar 2006 18:40:00 +0000 Subject: r13878: move PORT_DATA_1 to use static sized UNICODE strings as per MSDN (This used to be commit c803e1b2afdfc5bd983f046c976c01adebcfa1ad) --- source3/rpc_server/srv_spoolss_nt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a9d4e14aae..938658c479 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -9528,6 +9528,7 @@ static WERROR process_xcvtcp_command( NT_USER_TOKEN *token, const char *command, /******************************************************************* *******************************************************************/ +#if 0 /* don't support management using the "Local Port" monitor */ static WERROR xcvlocal_monitorui( NT_USER_TOKEN *token, RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed ) @@ -9554,6 +9555,12 @@ struct xcv_api_table xcvlocal_cmds[] = { { "MonitorUI", xcvlocal_monitorui }, { NULL, NULL } }; +#else +struct xcv_api_table xcvlocal_cmds[] = { + { NULL, NULL } +}; +#endif + /******************************************************************* @@ -9566,7 +9573,6 @@ static WERROR process_xcvlocal_command( NT_USER_TOKEN *token, const char *comman int i; DEBUG(10,("process_xcvlocal_command: Received command \"%s\"\n", command)); - for ( i=0; xcvlocal_cmds[i].name; i++ ) { if ( strcmp( command, xcvlocal_cmds[i].name ) == 0 ) -- cgit From 894358a8f3e338b339b6c37233edef794b312087 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Mar 2006 06:31:04 +0000 Subject: r13915: Fixed a very interesting class of realloc() bugs found by Coverity. realloc can return NULL in one of two cases - (1) the realloc failed, (2) realloc succeeded but the new size requested was zero, in which case this is identical to a free() call. The error paths dealing with these two cases should be different, but mostly weren't. Secondly the standard idiom for dealing with realloc when you know the new size is non-zero is the following : tmp = realloc(p, size); if (!tmp) { SAFE_FREE(p); return error; } else { p = tmp; } However, there were *many* *many* places in Samba where we were using the old (broken) idiom of : p = realloc(p, size) if (!p) { return error; } which will leak the memory pointed to by p on realloc fail. This commit (hopefully) fixes all these cases by moving to a standard idiom of : p = SMB_REALLOC(p, size) if (!p) { return error; } Where if the realloc returns null due to the realloc failing or size == 0 we *guarentee* that the storage pointed to by p has been freed. This allows me to remove a lot of code that was dealing with the standard (more verbose) method that required a tmp pointer. This is almost always what you want. When a realloc fails you never usually want the old memory, you want to free it and get into your error processing asap. For the 11 remaining cases where we really do need to keep the old pointer I have invented the new macro SMB_REALLOC_KEEP_OLD_ON_ERROR, which can be used as follows : tmp = SMB_REALLOC_KEEP_OLD_ON_ERROR(p, size); if (!tmp) { SAFE_FREE(p); return error; } else { p = tmp; } SMB_REALLOC_KEEP_OLD_ON_ERROR guarentees never to free the pointer p, even on size == 0 or realloc fail. All this is done by a hidden extra argument to Realloc(), BOOL free_old_on_error which is set appropriately by the SMB_REALLOC and SMB_REALLOC_KEEP_OLD_ON_ERROR macros (and their array counterparts). It remains to be seen what this will do to our Coverity bug count :-). Jeremy. (This used to be commit 1d710d06a214f3f1740e80e0bffd6aab44aac2b0) --- source3/rpc_server/srv_pipe.c | 5 +++- source3/rpc_server/srv_spoolss_nt.c | 55 ++++++++++++++----------------------- 2 files changed, 24 insertions(+), 36 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 67fb89ef79..eb7fd25daa 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1032,7 +1032,7 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *s rpc_lookup will still be valid afterwards. It could then succeed if called again later */ rpc_lookup_size++; - rpc_entry = SMB_REALLOC_ARRAY(rpc_lookup, struct rpc_table, rpc_lookup_size); + rpc_entry = SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(rpc_lookup, struct rpc_table, rpc_lookup_size); if (NULL == rpc_entry) { rpc_lookup_size--; DEBUG(0, ("rpc_pipe_register_commands: memory allocation failed\n")); @@ -1046,6 +1046,9 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *s rpc_entry->pipe.clnt = SMB_STRDUP(clnt); rpc_entry->pipe.srv = SMB_STRDUP(srv); rpc_entry->cmds = SMB_REALLOC_ARRAY(rpc_entry->cmds, struct api_struct, rpc_entry->n_cmds + size); + if (!rpc_entry->cmds) { + return NT_STATUS_NO_MEMORY; + } memcpy(rpc_entry->cmds + rpc_entry->n_cmds, cmds, size * sizeof(struct api_struct)); rpc_entry->n_cmds += size; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 938658c479..cc51df98c1 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3540,7 +3540,7 @@ static BOOL construct_notify_printer_info(Printer_entry *print_hnd, SPOOL_NOTIFY uint16 type; uint16 field; - SPOOL_NOTIFY_INFO_DATA *current_data, *tid; + SPOOL_NOTIFY_INFO_DATA *current_data; NT_PRINTER_INFO_LEVEL *printer = NULL; print_queue_struct *queue=NULL; @@ -3561,11 +3561,10 @@ static BOOL construct_notify_printer_info(Printer_entry *print_hnd, SPOOL_NOTIFY if (!search_notify(type, field, &j) ) continue; - if((tid=SMB_REALLOC_ARRAY(info->data, SPOOL_NOTIFY_INFO_DATA, info->count+1)) == NULL) { + if((info->data=SMB_REALLOC_ARRAY(info->data, SPOOL_NOTIFY_INFO_DATA, info->count+1)) == NULL) { DEBUG(2,("construct_notify_printer_info: failed to enlarge buffer info->data!\n")); return False; - } else - info->data = tid; + } current_data = &info->data[info->count]; @@ -3601,7 +3600,7 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, uint16 type; uint16 field; - SPOOL_NOTIFY_INFO_DATA *current_data, *tid; + SPOOL_NOTIFY_INFO_DATA *current_data; DEBUG(4,("construct_notify_jobs_info\n")); @@ -3617,11 +3616,10 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, if (!search_notify(type, field, &j) ) continue; - if((tid=SMB_REALLOC_ARRAY(info->data, SPOOL_NOTIFY_INFO_DATA, info->count+1)) == NULL) { + if((info->data=SMB_REALLOC_ARRAY(info->data, SPOOL_NOTIFY_INFO_DATA, info->count+1)) == NULL) { DEBUG(2,("construct_notify_jobs_info: failed to enlarg buffer info->data!\n")); return False; } - else info->data = tid; current_data=&(info->data[info->count]); @@ -4296,7 +4294,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32 int snum; int i; int n_services=lp_numservices(); - PRINTER_INFO_1 *tp, *printers=NULL; + PRINTER_INFO_1 *printers=NULL; PRINTER_INFO_1 current_prt; WERROR result = WERR_OK; @@ -4307,13 +4305,11 @@ static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32 DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); if (construct_printer_info_1(NULL, flags, ¤t_prt, snum)) { - if((tp=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_1, *returned +1)) == NULL) { + if((printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_1, *returned +1)) == NULL) { DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n")); - SAFE_FREE(printers); *returned=0; return WERR_NOMEM; } - else printers = tp; DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned)); memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_1)); @@ -4484,7 +4480,7 @@ static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint3 int snum; int i; int n_services=lp_numservices(); - PRINTER_INFO_2 *tp, *printers=NULL; + PRINTER_INFO_2 *printers=NULL; PRINTER_INFO_2 current_prt; WERROR result = WERR_OK; @@ -4492,18 +4488,15 @@ static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint3 if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) { DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum)); - if (construct_printer_info_2(NULL, ¤t_prt, snum)) - { - if ( !(tp=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_2, *returned +1)) ) { + if (construct_printer_info_2(NULL, ¤t_prt, snum)) { + if ( !(printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_2, *returned +1)) ) { DEBUG(2,("enum_all_printers_info_2: failed to enlarge printers buffer!\n")); - SAFE_FREE(printers); *returned = 0; return WERR_NOMEM; } - DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *returned)); + DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *returned + 1)); - printers = tp; memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_2)); (*returned)++; @@ -5074,7 +5067,6 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, const c int j=0; const char *v; pstring line; - uint16 *tuary; DEBUG(6,("init_unistr_array\n")); *uni_array=NULL; @@ -5102,12 +5094,11 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, const c /* add one extra unit16 for the second terminating NULL */ - if ( (tuary=SMB_REALLOC_ARRAY(*uni_array, uint16, j+1+strlen(line)+2)) == NULL ) { + if ( (*uni_array=SMB_REALLOC_ARRAY(*uni_array, uint16, j+1+strlen(line)+2)) == NULL ) { DEBUG(2,("init_unistr_array: Realloc error\n" )); return 0; - } else - *uni_array = tuary; - + } + if ( !strlen(v) ) break; @@ -6699,7 +6690,7 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture uint32 version; fstring *list = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; - DRIVER_INFO_1 *tdi1, *driver_info_1=NULL; + DRIVER_INFO_1 *driver_info_1=NULL; WERROR result = WERR_OK; *returned=0; @@ -6713,13 +6704,11 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture return WERR_NOMEM; if(ndrivers != 0) { - if((tdi1=SMB_REALLOC_ARRAY(driver_info_1, DRIVER_INFO_1, *returned+ndrivers )) == NULL) { + if((driver_info_1=SMB_REALLOC_ARRAY(driver_info_1, DRIVER_INFO_1, *returned+ndrivers )) == NULL) { DEBUG(0,("enumprinterdrivers_level1: failed to enlarge driver info buffer!\n")); - SAFE_FREE(driver_info_1); SAFE_FREE(list); return WERR_NOMEM; } - else driver_info_1 = tdi1; } for (i=0; i Date: Tue, 7 Mar 2006 21:13:19 +0000 Subject: r13994: Belt and braces - ensure RPC_BUFFER is valid. Jeremy. (This used to be commit d993797191865878ebfd2ff9028d341017605cd6) --- source3/rpc_server/srv_spoolss_nt.c | 119 +++++++++++++++++++++++------------- 1 file changed, 75 insertions(+), 44 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cc51df98c1..6a1be53738 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4624,11 +4624,13 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ /* that's an [in out] buffer */ - if ( q_u->buffer ) { - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + if (!q_u->buffer) { + return WERR_INVALID_PARAM; } + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_spoolss_enumprinters\n")); *needed=0; @@ -4933,11 +4935,13 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET /* that's an [in out] buffer */ - if ( q_u->buffer ) { - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + if (!q_u->buffer) { + return WERR_INVALID_PARAM; } + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + *needed=0; if (!get_printer_snum(p, handle, &snum)) @@ -5530,11 +5534,13 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ /* that's an [in out] buffer */ - if ( q_u->buffer ) { - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + if (!q_u->buffer) { + return WERR_INVALID_PARAM; } + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_spoolss_getprinterdriver2\n")); if ( !(printer = find_printer_index_by_hnd( p, handle )) ) { @@ -6367,8 +6373,11 @@ WERROR _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u { /* that's an [in out] buffer */ - if ( q_u->buffer ) - rpcbuf_move(q_u->buffer, &r_u->buffer); + if (!q_u->buffer) { + return WERR_INVALID_PARAM; + } + + rpcbuf_move(q_u->buffer, &r_u->buffer); r_u->needed = 0; return WERR_INVALID_PARAM; /* this is what a NT server @@ -6579,11 +6588,13 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO /* that's an [in out] buffer */ - if ( q_u->buffer ) { - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + if (!q_u->buffer) { + return WERR_INVALID_PARAM; } + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_spoolss_enumjobs\n")); *needed=0; @@ -6944,11 +6955,13 @@ WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS /* that's an [in out] buffer */ - if ( q_u->buffer ) { - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + if (!q_u->buffer) { + return WERR_INVALID_PARAM; } + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_spoolss_enumprinterdrivers\n")); *needed = 0; @@ -7007,11 +7020,13 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF /* that's an [in out] buffer */ - if ( q_u->buffer ) { - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + if (!q_u->buffer) { + return WERR_INVALID_PARAM; } + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_spoolss_enumforms\n")); DEBUGADD(5,("Offered buffer size [%d]\n", offered)); DEBUGADD(5,("Info level [%d]\n", level)); @@ -7114,11 +7129,13 @@ WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * /* that's an [in out] buffer */ - if ( q_u->buffer ) { - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + if (!q_u->buffer) { + return WERR_INVALID_PARAM; } + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + unistr2_to_ascii(form_name, uni_formname, sizeof(form_name)-1); DEBUG(4,("_spoolss_getform\n")); @@ -7392,11 +7409,13 @@ WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUM /* that's an [in out] buffer */ - if ( q_u->buffer ) { - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + if (!q_u->buffer) { + return WERR_INVALID_PARAM; } + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_spoolss_enumports\n")); *returned=0; @@ -7800,11 +7819,13 @@ WERROR _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRI /* that's an [in out] buffer */ - if ( q_u->buffer ) { - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + if (!q_u->buffer ) { + return WERR_INVALID_PARAM; } + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_spoolss_getprinterdriverdirectory\n")); *needed=0; @@ -8410,11 +8431,13 @@ WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS /* that's an [in out] buffer */ - if ( q_u->buffer ) { - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + if (!q_u->buffer) { + return WERR_INVALID_PARAM; } + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(5,("spoolss_enumprintprocessors\n")); /* @@ -8487,11 +8510,13 @@ WERROR _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDAT /* that's an [in out] buffer */ - if ( q_u->buffer ) { - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + if (!q_u->buffer) { + return WERR_INVALID_PARAM; } + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(5,("_spoolss_enumprintprocdatatypes\n")); *returned=0; @@ -8613,11 +8638,13 @@ WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_ /* that's an [in out] buffer */ - if ( q_u->buffer ) { - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + if (!q_u->buffer) { + return WERR_INVALID_PARAM; } + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(5,("spoolss_enumprintmonitors\n")); /* @@ -8787,11 +8814,13 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ /* that's an [in out] buffer */ - if ( q_u->buffer ) { - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + if (!q_u->buffer) { + return WERR_INVALID_PARAM; } + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(5,("spoolss_getjob\n")); *needed = 0; @@ -9407,11 +9436,13 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC /* that's an [in out] buffer */ - if ( q_u->buffer ) { - rpcbuf_move(q_u->buffer, &r_u->buffer); - buffer = r_u->buffer; + if (!q_u->buffer) { + return WERR_INVALID_PARAM; } + rpcbuf_move(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(5,("_spoolss_getprintprocessordirectory\n")); *needed=0; -- cgit From 77709e58add9d716d70941908258bcd2f83e17fa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 8 Mar 2006 07:30:37 +0000 Subject: r14031: Coverity bug CID #110. Free all resources correctly on pipe initialization failure. Jeremy. (This used to be commit daa919a94b3d81401654004bc0f32c45451203c1) --- source3/rpc_server/srv_pipe_hnd.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index f7467f2cf0..0d07db2be3 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -330,6 +330,8 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, DEBUG(0,("open_rpc_pipe_p: malloc fail for in_data struct.\n")); talloc_destroy(p->mem_ctx); talloc_destroy(p->pipe_state_mem_ctx); + close_policy_by_pipe(p); + SAFE_FREE(p); return NULL; } -- cgit From 5a1c225c18ee778490c2d6f789afc3fad3a34703 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 10 Mar 2006 23:52:37 +0000 Subject: r14178: Clarify code for Coverity #49. Ensure we know we can't have an uninitialized *returned val. Jeremy. (This used to be commit e83515afd2cb63b0dfa4f7fe00b6b7163bf35f2f) --- source3/rpc_server/srv_spoolss_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 6a1be53738..af413b8b70 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4484,6 +4484,8 @@ static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint3 PRINTER_INFO_2 current_prt; WERROR result = WERR_OK; + *returned = 0; + for (snum=0; snum Date: Sat, 11 Mar 2006 02:09:18 +0000 Subject: r14182: Ensure we know that dom_sid cannot be null. Jeremy. (This used to be commit e3a28bf4c8064f7053b7d1a25a2f087ac2095fcd) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index bdfb742f7a..80c86a3079 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -120,7 +120,7 @@ static int init_dom_ref(DOM_R_REF *ref, const char *dom_name, DOM_SID *dom_sid) ref->max_entries = MAX_REF_DOMAINS; ref->num_ref_doms_2 = num+1; - ref->hdr_ref_dom[num].ptr_dom_sid = dom_sid != NULL ? 1 : 0; + ref->hdr_ref_dom[num].ptr_dom_sid = 1; /* dom sid cannot be NULL. */ init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name, UNI_FLAGS_NONE); init_uni_hdr(&ref->hdr_ref_dom[num].hdr_dom_name, &ref->ref_dom[num].uni_dom_name); -- cgit From c9f256cb6ca0a51551004580e2422bb23bddbe20 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 12 Mar 2006 00:03:00 +0000 Subject: r14226: Fix Coverity bug # 109 (This used to be commit e9a63e3b35822eefbc5e17b6f9a4aab5e8c03074) --- source3/rpc_server/srv_reg_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 33711d0fac..5ac6738b99 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -835,8 +835,10 @@ static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) /* get the rootkey from the regf file and then load the tree via recursive calls */ - if ( !(rootkey = regfio_rootkey( regfile )) ) + if ( !(rootkey = regfio_rootkey( regfile )) ) { + regfio_close( regfile ); return WERR_REG_FILE_INVALID; + } result = reg_load_tree( regfile, krecord->name, rootkey ); -- cgit From 71bf1be099e2afd989275da1d9fc9f668169a348 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 12 Mar 2006 10:47:02 +0000 Subject: r14233: Fix Coverity bug # 206 (This used to be commit 0dc3030bce7bc7a58c509c70fe503a70db80b62d) --- source3/rpc_server/srv_spoolss_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index af413b8b70..2424c46691 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4823,8 +4823,10 @@ static WERROR getprinter_level_4(Printer_entry *print_hnd, int snum, RPC_BUFFER if((printer=SMB_MALLOC_P(PRINTER_INFO_4))==NULL) return WERR_NOMEM; - if (!construct_printer_info_4(print_hnd, printer, snum)) + if (!construct_printer_info_4(print_hnd, printer, snum)) { + SAFE_FREE(printer); return WERR_NOMEM; + } /* check the required size. */ *needed += spoolss_size_printer_info_4(printer); -- cgit From 05b4d0b38e53de20b7aad2bbb3c6a6788d23313f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 12 Mar 2006 19:16:45 +0000 Subject: r14250: Fix coverity bug #107. Resource leak on error path. Jeremy. (This used to be commit ca96c7be778d01594a540917acd3c5c218d6459c) --- source3/rpc_server/srv_spoolss_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2424c46691..951757d4c8 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4862,8 +4862,10 @@ static WERROR getprinter_level_5(Printer_entry *print_hnd, int snum, RPC_BUFFER if((printer=SMB_MALLOC_P(PRINTER_INFO_5))==NULL) return WERR_NOMEM; - if (!construct_printer_info_5(print_hnd, printer, snum)) + if (!construct_printer_info_5(print_hnd, printer, snum)) { + free_printer_info_5(printer); return WERR_NOMEM; + } /* check the required size. */ *needed += spoolss_size_printer_info_5(printer); -- cgit From 65eb331afcabe76ef6a5a688fb2709dad4369295 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Mar 2006 00:23:17 +0000 Subject: r14264: Fix coverity #207. Resource leak on error path. Jeremy. (This used to be commit 0429b6e8c34a99d4b2a9a4849075ef2a5acadf9e) --- source3/rpc_server/srv_spoolss_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 951757d4c8..d31b68d24e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6900,6 +6900,7 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture architecture, version); if (!W_ERROR_IS_OK(status)) { SAFE_FREE(list); + SAFE_FREE(driver_info_3); return status; } fill_printer_driver_info_3(&driver_info_3[*returned+i], driver, servername); -- cgit From 88dda37184d4282da1f9facf953003f0d1e82406 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Mar 2006 00:25:04 +0000 Subject: r14266: Fix coverity #205. Resource leak on error path. Jeremy. (This used to be commit 23d69758bbff9687ab508e12931a5a49691d7e0d) --- source3/rpc_server/srv_spoolss_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d31b68d24e..57ca89379e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6818,6 +6818,7 @@ static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture architecture, version); if (!W_ERROR_IS_OK(status)) { SAFE_FREE(list); + SAFE_FREE(driver_info_2); return status; } fill_printer_driver_info_2(&driver_info_2[*returned+i], driver, servername); -- cgit From bb0d6f04598ea8eb489137f2a23d98ad9f9a0eee Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Mar 2006 00:26:38 +0000 Subject: r14268: Fix coverity error #204. Resource leak on error path. Jeremy. (This used to be commit 5f74e56b865e0bdde0e574cd5f97cf29b06ad155) --- source3/rpc_server/srv_spoolss_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 57ca89379e..e86b36a5fe 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6736,6 +6736,7 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture architecture, version); if (!W_ERROR_IS_OK(status)) { SAFE_FREE(list); + SAFE_FREE(driver_info_1); return status; } fill_printer_driver_info_1(&driver_info_1[*returned+i], driver, servername, architecture ); -- cgit From e4600491cf847668172c37857e972364b87b0c7a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Mar 2006 03:56:24 +0000 Subject: r14284: Fix coverity bug #103. Make code clearer - probably not a real issue but this code is easier to read. Jeremy. (This used to be commit 6621acc68f9a65540330d5c0d07db2488a3e8678) --- source3/rpc_server/srv_spoolss_nt.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e86b36a5fe..475862bc4c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7241,6 +7241,8 @@ WERROR enumports_hook( int *count, char ***lines ) int ret; int fd; + *count = 0; + *lines = NULL; /* if no hook then just fill in the default port */ @@ -7259,9 +7261,9 @@ WERROR enumports_hook( int *count, char ***lines ) ret = smbrun(command, &fd); DEBUG(10,("Returned [%d]\n", ret)); if (ret != 0) { - if (fd != -1) + if (fd != -1) { close(fd); - + } return WERR_ACCESS_DENIED; } @@ -7289,8 +7291,11 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need char **qlines; int numlines; - if ( !W_ERROR_IS_OK(result = enumports_hook( &numlines, &qlines )) ) + result = enumports_hook( &numlines, &qlines ); + if (!W_ERROR_IS_OK(result)) { + file_lines_free(qlines); return result; + } if(numlines) { if((ports=SMB_MALLOC_ARRAY( PORT_INFO_1, numlines )) == NULL) { @@ -7304,9 +7309,8 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need DEBUG(6,("Filling port number [%d] with port [%s]\n", i, qlines[i])); fill_port_1(&ports[i], qlines[i]); } - - file_lines_free(qlines); } + file_lines_free(qlines); *returned = numlines; -- cgit From acc651a31be5f099aa5a13ba854b0a130be5d30d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Mar 2006 03:59:53 +0000 Subject: r14286: Similar clarifiction fix for coverity #102. Jeremy. (This used to be commit f458596b0edd958321c5d4061f034846348a3fe6) --- source3/rpc_server/srv_spoolss_nt.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 475862bc4c..573603b659 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7288,8 +7288,8 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need PORT_INFO_1 *ports=NULL; int i=0; WERROR result = WERR_OK; - char **qlines; - int numlines; + char **qlines = NULL; + int numlines = 0; result = enumports_hook( &numlines, &qlines ); if (!W_ERROR_IS_OK(result)) { @@ -7354,12 +7354,14 @@ static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *need PORT_INFO_2 *ports=NULL; int i=0; WERROR result = WERR_OK; - char **qlines; - int numlines; + char **qlines = NULL; + int numlines = 0; - if ( !W_ERROR_IS_OK(result = enumports_hook( &numlines, &qlines )) ) + result = enumports_hook( &numlines, &qlines ); + if ( !W_ERROR_IS_OK(result)) { + file_lines_free(qlines); return result; - + } if(numlines) { if((ports=SMB_MALLOC_ARRAY( PORT_INFO_2, numlines)) == NULL) { @@ -7371,10 +7373,10 @@ static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *need DEBUG(6,("Filling port number [%d] with port [%s]\n", i, qlines[i])); fill_port_2(&(ports[i]), qlines[i]); } - - file_lines_free(qlines); } + file_lines_free(qlines); + *returned = numlines; /* check the required size. */ -- cgit From 19879eba8378f58db403c27202b9cc0af60db559 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Mar 2006 04:05:47 +0000 Subject: r14289: Fix coverity #101, resource leak on error code path. Jeremy. (This used to be commit d9e1d6fed099e7651807aa839a743fc7756ee326) --- source3/rpc_server/srv_spoolss_nt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 573603b659..dd706b68ed 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7046,12 +7046,17 @@ WERROR _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) + if (*numofforms == 0) { + SAFE_FREE(builtinlist); + SAFE_FREE(list); return WERR_NO_MORE_ITEMS; + } switch (level) { case 1: if ((forms_1=SMB_MALLOC_ARRAY(FORM_1, *numofforms)) == NULL) { + SAFE_FREE(builtinlist); + SAFE_FREE(list); *numofforms=0; return WERR_NOMEM; } @@ -7114,7 +7119,6 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF SAFE_FREE(builtinlist); return WERR_UNKNOWN_LEVEL; } - } /**************************************************************************** -- cgit From 860015db1fe89944e37163234505d26b7cfe5386 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Mar 2006 06:48:41 +0000 Subject: r14299: Fix coverity #225. In a loop we were forgetting to free resources on error exit path. Jeremy. (This used to be commit 1c0b4ed0acdb7fccb148d714796752fefc6dd78c) --- source3/rpc_server/srv_spoolss_nt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index dd706b68ed..57509fcd87 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6871,8 +6871,8 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture int ndrivers; uint32 version; fstring *list = NULL; - NT_PRINTER_DRIVER_INFO_LEVEL driver; DRIVER_INFO_3 *driver_info_3=NULL; + NT_PRINTER_DRIVER_INFO_LEVEL driver; WERROR result = WERR_OK; *returned=0; @@ -6882,8 +6882,10 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture ndrivers=get_ntdrivers(&list, architecture, version); DEBUGADD(4,("we have:[%d] drivers in environment [%s] and version [%d]\n", ndrivers, architecture, version)); - if(ndrivers == -1) + if(ndrivers == -1) { + SAFE_FREE(driver_info_3); return WERR_NOMEM; + } if(ndrivers != 0) { if((driver_info_3=SMB_REALLOC_ARRAY(driver_info_3, DRIVER_INFO_3, *returned+ndrivers )) == NULL) { @@ -6936,8 +6938,9 @@ static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture } out: - for (i=0; i<*returned; i++) + for (i=0; i<*returned; i++) { SAFE_FREE(driver_info_3[i].dependentfiles); + } SAFE_FREE(driver_info_3); -- cgit From ad838bf65e3e67a0a19cd3be4c969a01928f9636 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Mar 2006 06:50:33 +0000 Subject: r14301: Fix coverity #224. In a loop we were forgetting to free resources on error exit path. Jeremy. (This used to be commit f1a5e5aefeeb78512c41cc8fc075b240696a3eb7) --- source3/rpc_server/srv_spoolss_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 57509fcd87..31a278f7f3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6799,8 +6799,10 @@ static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture ndrivers=get_ntdrivers(&list, architecture, version); DEBUGADD(4,("we have:[%d] drivers in environment [%s] and version [%d]\n", ndrivers, architecture, version)); - if(ndrivers == -1) + if(ndrivers == -1) { + SAFE_FREE(driver_info_2); return WERR_NOMEM; + } if(ndrivers != 0) { if((driver_info_2=SMB_REALLOC_ARRAY(driver_info_2, DRIVER_INFO_2, *returned+ndrivers )) == NULL) { -- cgit From d72bb5627ccc14f2396f3e464686b6dfebee6ec5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Mar 2006 06:52:03 +0000 Subject: r14303: Fix coverity #223. In a loop we were forgetting to free resources on error exit path. Jeremy. (This used to be commit f71aa3ab8fdfd08c1bec57b6506ead7c4af7299d) --- source3/rpc_server/srv_spoolss_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 31a278f7f3..70432c34ca 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6717,8 +6717,10 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture ndrivers=get_ntdrivers(&list, architecture, version); DEBUGADD(4,("we have:[%d] drivers in environment [%s] and version [%d]\n", ndrivers, architecture, version)); - if(ndrivers == -1) + if(ndrivers == -1) { + SAFE_FREE(driver_info_1); return WERR_NOMEM; + } if(ndrivers != 0) { if((driver_info_1=SMB_REALLOC_ARRAY(driver_info_1, DRIVER_INFO_1, *returned+ndrivers )) == NULL) { -- cgit From bd1e853c19ddc0c731beb19d919e63e4df1fb0e0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 13 Mar 2006 18:59:31 +0000 Subject: r14338: Fix coverity #55 by explicit cast. Jeremy. (This used to be commit 1fece52da4d667fa182aa9a87aaee3917860448b) --- source3/rpc_server/srv_svcctl_nt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index a0b8b66f50..638b66bb9e 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -416,11 +416,14 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT if ( !info || (info->type != SVC_HANDLE_IS_SCM) ) return WERR_BADFID; - if ( !(info->access_granted & SC_RIGHT_MGR_ENUMERATE_SERVICE) ) + if ( !(info->access_granted & SC_RIGHT_MGR_ENUMERATE_SERVICE) ) { return WERR_ACCESS_DENIED; + } - if ( (num_services = enumerate_status( p->mem_ctx, &services, token )) == -1 ) + num_services = enumerate_status( p->mem_ctx, &services, token ); + if (num_services == (uint32)-1 ) { return WERR_NOMEM; + } for ( i=0; i Date: Mon, 13 Mar 2006 23:07:14 +0000 Subject: r14353: Fix coverity bugs #61 and #62. Remember to divide by the size of the data table. Clean up the struct a little. Jeremy. (This used to be commit 338538410d484a9358b60b05a86180275344ffa4) --- source3/rpc_server/srv_spoolss_nt.c | 45 +++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 70432c34ca..9fd51c9e27 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3441,25 +3441,22 @@ static uint32 size_of_notify_info_data(uint16 type, uint16 field) { int i=0; - for (i = 0; i < sizeof(notify_info_data_table); i++) - { + for (i = 0; i < (sizeof(notify_info_data_table)/sizeof(struct s_notify_info_data_table)); i++) { if ( (notify_info_data_table[i].type == type) - && (notify_info_data_table[i].field == field) ) - { - switch(notify_info_data_table[i].size) - { - case NOTIFY_ONE_VALUE: - case NOTIFY_TWO_VALUE: - return 1; - case NOTIFY_STRING: - return 2; - - /* The only pointer notify data I have seen on - the wire is the submitted time and this has - the notify size set to 4. -tpot */ - - case NOTIFY_POINTER: - return 4; + && (notify_info_data_table[i].field == field) ) { + switch(notify_info_data_table[i].size) { + case NOTIFY_ONE_VALUE: + case NOTIFY_TWO_VALUE: + return 1; + case NOTIFY_STRING: + return 2; + + /* The only pointer notify data I have seen on + the wire is the submitted time and this has + the notify size set to 4. -tpot */ + + case NOTIFY_POINTER: + return 4; case NOTIFY_SECDESC: return 5; @@ -3476,23 +3473,23 @@ static uint32 size_of_notify_info_data(uint16 type, uint16 field) Return the type of notify_info_data. ********************************************************************/ -static int type_of_notify_info_data(uint16 type, uint16 field) +static uint32 type_of_notify_info_data(uint16 type, uint16 field) { - int i=0; + uint32 i=0; - for (i = 0; i < sizeof(notify_info_data_table); i++) { + for (i = 0; i < (sizeof(notify_info_data_table)/sizeof(struct s_notify_info_data_table)); i++) { if (notify_info_data_table[i].type == type && notify_info_data_table[i].field == field) return notify_info_data_table[i].size; } - return False; + return 0; } /**************************************************************************** ****************************************************************************/ -static int search_notify(uint16 type, uint16 field, int *value) +static BOOL search_notify(uint16 type, uint16 field, int *value) { int i; @@ -3521,10 +3518,8 @@ void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 info_data->enc_type = type_of_notify_info_data(type, field); info_data->id = id; - } - /******************************************************************* * * fill a notify_info struct with info asked -- cgit From e6676a9a6928deb03c2a43a66c1245dd05d03e71 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 14 Mar 2006 17:21:30 +0000 Subject: r14387: Try and fix the coverity issues (#53, #54) with negative sink by ensuring all uses of rpcstr_push are consistent with a size_t dest size arg. Jeremy. (This used to be commit f65d7afe1977d9d85046732842f9643716c15088) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 9fd51c9e27..38d2827956 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8013,7 +8013,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S goto done; } - *out_value_len = (uint32)rpcstr_push((char *)*out_value, regval_name(val), in_value_len, 0); + *out_value_len = (uint32)rpcstr_push((char *)*out_value, regval_name(val), (size_t)in_value_len, 0); /* type */ -- cgit From be2bc3147c562acf6472bd6f3b4eadb3d9115ba3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 14 Mar 2006 20:32:27 +0000 Subject: r14395: Fix coverity bug #55. Ensure no unsigned/signed comparisons. Jeremy. (This used to be commit cd3ad3f1a6f622b4bad5cb21b132de4cc476e03f) --- source3/rpc_server/srv_svcctl_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 638b66bb9e..6062dcee5c 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -404,7 +404,7 @@ static int enumerate_status( TALLOC_CTX *ctx, ENUM_SERVICES_STATUS **status, NT_ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, SVCCTL_R_ENUM_SERVICES_STATUS *r_u) { ENUM_SERVICES_STATUS *services = NULL; - uint32 num_services; + int num_services; int i = 0; size_t buffer_size = 0; WERROR result = WERR_OK; @@ -421,7 +421,7 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT } num_services = enumerate_status( p->mem_ctx, &services, token ); - if (num_services == (uint32)-1 ) { + if (num_services == -1 ) { return WERR_NOMEM; } @@ -444,7 +444,7 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT } r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size; - r_u->returned = num_services; + r_u->returned = (uint32)num_services; if ( !(r_u->resume = TALLOC_P( p->mem_ctx, uint32 )) ) return WERR_NOMEM; -- cgit From 0ce53f8ba5110381ad6f910abe581a69019135b8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 15 Mar 2006 00:10:38 +0000 Subject: r14403: * modifies create_local_nt_token() to create a BUILTIN\Administrators group IFF sid_to_gid(S-1-5-32-544) fails and 'winbind nested groups = yes' * Add a SID domain to the group mapping enumeration passdb call to fix the checks for local and builtin groups. The SID can be NULL if you want the old semantics for internal maintenance. I only updated the tdb group mapping code. * remove any group mapping from the tdb that have a gid of -1 for better consistency with pdb_ldap.c. The fixes the problem with calling add_group_map() in the tdb code for unmapped groups which might have had a record present. * Ensure that we distinguish between groups in the BUILTIN and local machine domains via getgrnam() Other wise BUILTIN\Administrators & SERVER\Administrators would resolve to the same gid. * Doesn't strip the global_sam_name() from groups in the local machine's domain (this is required to work with 'winbind default domain' code) Still todo. * Fix fallback Administrators membership for root and domain Admins if nested groups = no or winbindd is not running * issues with "su - user -c 'groups'" command * There are a few outstanding issues with BUILTIN\Users that Windows apparently tends to assume. I worked around this presently with a manual group mapping but I do not think this is a good solution. So I'll probably add some similar as I did for Administrators. (This used to be commit 612979476aef62e8e8eef632fa6be7d30282bb83) --- source3/rpc_server/srv_lsa_nt.c | 2 +- source3/rpc_server/srv_samr_nt.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 80c86a3079..7fe42efefb 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1071,7 +1071,7 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP done: - if (NT_STATUS_IS_OK(r_u->status)) { + if (NT_STATUS_IS_OK(r_u->status) && (num_entries != 0) ) { if (mapped_count == 0) r_u->status = NT_STATUS_NONE_MAPPED; else if (mapped_count != num_entries) diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e4dc92c08d..6a4c9f7133 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1650,6 +1650,10 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK names, attrs); unbecome_root(); + if ( NT_STATUS_EQUAL(r_u->status, NT_STATUS_NONE_MAPPED) && (num_rids == 0) ) { + r_u->status = NT_STATUS_OK; + } + if(!make_samr_lookup_rids(p->mem_ctx, num_rids, names, &hdr_name, &uni_name)) return NT_STATUS_NO_MEMORY; @@ -2914,6 +2918,7 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A /* Check we actually have the requested alias */ enum SID_NAME_USE type; BOOL result; + gid_t gid; become_root(); result = lookup_sid(NULL, &sid, NULL, NULL, &type); @@ -2922,6 +2927,13 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A if (!result || (type != SID_NAME_ALIAS)) { return NT_STATUS_NO_SUCH_ALIAS; } + + /* make sure there is a mapping */ + + if ( !sid_to_gid( &sid, &gid ) ) { + return NT_STATUS_NO_SUCH_ALIAS; + } + } /* associate the alias SID with the new handle. */ -- cgit From 24961b173b53075100cf433bbc1c90485f376434 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 15 Mar 2006 12:23:09 +0000 Subject: r14443: rework get_md4pw() to ease debugging. The only functional change is that we now check wheter the sec_channel_type matches the trust account type. Guenther (This used to be commit c35eb449375d53ffa0815897e7723c203be1f732) --- source3/rpc_server/srv_netlog_nt.c | 93 ++++++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 24 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 8dbd4ff33f..f3200cbdd7 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -204,7 +204,7 @@ static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, gets a machine password entry. checks access rights of the host. ******************************************************************/ -static BOOL get_md4pw(char *md4pw, char *mach_acct) +static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) { struct samu *sampass = NULL; const uint8 *pass; @@ -230,35 +230,74 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct) #endif /* 0 */ if ( !(sampass = samu_new( NULL )) ) { - return False; + return NT_STATUS_NO_MEMORY; } /* JRA. This is ok as it is only used for generating the challenge. */ become_root(); - ret=pdb_getsampwnam(sampass, mach_acct); + ret = pdb_getsampwnam(sampass, mach_acct); unbecome_root(); - if (ret==False) { + if (ret == False) { DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); TALLOC_FREE(sampass); - return False; + return NT_STATUS_ACCESS_DENIED; } acct_ctrl = pdb_get_acct_ctrl(sampass); - if (!(acct_ctrl & ACB_DISABLED) && - ((acct_ctrl & ACB_DOMTRUST) || - (acct_ctrl & ACB_WSTRUST) || - (acct_ctrl & ACB_SVRTRUST)) && - ((pass=pdb_get_nt_passwd(sampass)) != NULL)) { - memcpy(md4pw, pass, 16); - dump_data(5, md4pw, 16); - TALLOC_FREE(sampass); - return True; + if (acct_ctrl & ACB_DISABLED) { + DEBUG(0,("get_md4pw: Workstation %s: account is disabled\n", mach_acct)); + TALLOC_FREE(sampass); + return NT_STATUS_ACCOUNT_DISABLED; } - - DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); + + if (!(acct_ctrl & ACB_SVRTRUST) || + !(acct_ctrl & ACB_WSTRUST) || + !(acct_ctrl & ACB_DOMTRUST)) { + DEBUG(0,("get_md4pw: Workstation %s: account is not a trust account\n", mach_acct)); + TALLOC_FREE(sampass); + return NT_STATUS_NO_TRUST_SAM_ACCOUNT; + } + + switch (sec_chan_type) { + case SEC_CHAN_BDC: + if (!(acct_ctrl & ACB_SVRTRUST)) { + DEBUG(0,("get_md4pw: Workstation %s: BDC secure channel requested " + "but not a server trust account\n", mach_acct)); + TALLOC_FREE(sampass); + return NT_STATUS_NO_TRUST_SAM_ACCOUNT; + } + case SEC_CHAN_WKSTA: + if (!(acct_ctrl & ACB_WSTRUST)) { + DEBUG(0,("get_md4pw: Workstation %s: WORKSTATION secure channel requested " + "but not a workstation trust account\n", mach_acct)); + TALLOC_FREE(sampass); + return NT_STATUS_NO_TRUST_SAM_ACCOUNT; + } + case SEC_CHAN_DOMAIN: + if (!(acct_ctrl & ACB_DOMTRUST)) { + DEBUG(0,("get_md4pw: Workstation %s: DOMAIN secure channel requested " + "but not a interdomain trust account\n", mach_acct)); + TALLOC_FREE(sampass); + return NT_STATUS_NO_TRUST_SAM_ACCOUNT; + } + default: + break; + } + + if ((pass = pdb_get_nt_passwd(sampass)) == NULL) { + DEBUG(0,("get_md4pw: Workstation %s: account does not have a password\n", mach_acct)); + TALLOC_FREE(sampass); + return NT_STATUS_LOGON_FAILURE; + } + + memcpy(md4pw, pass, 16); + dump_data(5, md4pw, 16); + TALLOC_FREE(sampass); - return False; + + return NT_STATUS_OK; + } @@ -313,6 +352,7 @@ static void init_net_r_auth(NET_R_AUTH *r_a, DOM_CHAL *resp_cred, NTSTATUS statu NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) { + NTSTATUS status; fstring mach_acct; fstring remote_machine; DOM_CHAL srv_chal_out; @@ -326,11 +366,13 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) rpcstr_pull(remote_machine, q_u->clnt_id.uni_comp_name.buffer,sizeof(fstring), q_u->clnt_id.uni_comp_name.uni_str_len*2,0); - if (!get_md4pw((char *)p->dc->mach_pw, mach_acct)) { + status = get_md4pw((char *)p->dc->mach_pw, mach_acct, q_u->clnt_id.sec_chan); + if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("_net_auth: creds_server_check failed. Failed to " - "get pasword for machine account %s " - "from client %s\n", - mach_acct, remote_machine )); + "get password for machine account %s " + "from client %s: %s\n", + mach_acct, remote_machine, nt_errstr(status) )); + /* always return NT_STATUS_ACCESS_DENIED */ return NT_STATUS_ACCESS_DENIED; } @@ -379,6 +421,7 @@ static void init_net_r_auth_2(NET_R_AUTH_2 *r_a, NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) { + NTSTATUS status; NEG_FLAGS srv_flgs; fstring mach_acct; fstring remote_machine; @@ -407,10 +450,12 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) return NT_STATUS_ACCESS_DENIED; } - if (!get_md4pw((char *)p->dc->mach_pw, mach_acct)) { + status = get_md4pw((char *)p->dc->mach_pw, mach_acct, q_u->clnt_id.sec_chan); + if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("_net_auth2: failed to get machine password for " - "account %s\n", - mach_acct )); + "account %s: %s\n", + mach_acct, nt_errstr(status) )); + /* always return NT_STATUS_ACCESS_DENIED */ return NT_STATUS_ACCESS_DENIED; } -- cgit From 0f0ad2992eedeb9e75ddd2c122b5a5b291ba4efe Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 15 Mar 2006 14:58:39 +0000 Subject: r14448: * protect against NULL cli_state* pointers in cli_rpc_pipe_open() * Fix inverted logic check for machine accounts in get_md4pw() (This used to be commit a36529535dcb5a262e7627b80fb62a31240dc8ad) --- source3/rpc_server/srv_netlog_nt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index f3200cbdd7..cafef5ab7f 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -251,9 +251,10 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) return NT_STATUS_ACCOUNT_DISABLED; } - if (!(acct_ctrl & ACB_SVRTRUST) || - !(acct_ctrl & ACB_WSTRUST) || - !(acct_ctrl & ACB_DOMTRUST)) { + if (!(acct_ctrl & ACB_SVRTRUST) && + !(acct_ctrl & ACB_WSTRUST) && + !(acct_ctrl & ACB_DOMTRUST)) + { DEBUG(0,("get_md4pw: Workstation %s: account is not a trust account\n", mach_acct)); TALLOC_FREE(sampass); return NT_STATUS_NO_TRUST_SAM_ACCOUNT; -- cgit From 36f622acea8ffa59233bc1b96c6a38f1c29623a8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 15 Mar 2006 15:38:15 +0000 Subject: r14450: Fix more get_md4pw() breakage caused by missing "breaks" in the switch statement which matched the schannel type against the account type. (This used to be commit 57c705ea63381ed9ab09145b4f57a736931fa6ca) --- source3/rpc_server/srv_netlog_nt.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index cafef5ab7f..1a7ab4ef53 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -268,6 +268,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) TALLOC_FREE(sampass); return NT_STATUS_NO_TRUST_SAM_ACCOUNT; } + break; case SEC_CHAN_WKSTA: if (!(acct_ctrl & ACB_WSTRUST)) { DEBUG(0,("get_md4pw: Workstation %s: WORKSTATION secure channel requested " @@ -275,6 +276,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) TALLOC_FREE(sampass); return NT_STATUS_NO_TRUST_SAM_ACCOUNT; } + break; case SEC_CHAN_DOMAIN: if (!(acct_ctrl & ACB_DOMTRUST)) { DEBUG(0,("get_md4pw: Workstation %s: DOMAIN secure channel requested " @@ -282,6 +284,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) TALLOC_FREE(sampass); return NT_STATUS_NO_TRUST_SAM_ACCOUNT; } + break; default: break; } -- cgit From f4a5c016e31f8254800b6aec971f9397f0ee8ed1 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 16 Mar 2006 16:46:23 +0000 Subject: r14482: Fixes for spoolss code (after coverity fixes) when the client sends a NULL RPC_BUFFER* (This used to be commit 69f816e9f885bdeb6e8c67222b6fdca76d9d1025) --- source3/rpc_server/srv_spoolss_nt.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 38d2827956..350e9d3562 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4621,7 +4621,7 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ /* that's an [in out] buffer */ - if (!q_u->buffer) { + if (!q_u->buffer && (offered!=0)) { return WERR_INVALID_PARAM; } @@ -4936,7 +4936,7 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET /* that's an [in out] buffer */ - if (!q_u->buffer) { + if (!q_u->buffer && (offered!=0)) { return WERR_INVALID_PARAM; } @@ -5535,7 +5535,7 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ /* that's an [in out] buffer */ - if (!q_u->buffer) { + if (!q_u->buffer && (offered!=0)) { return WERR_INVALID_PARAM; } @@ -6374,7 +6374,7 @@ WERROR _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u { /* that's an [in out] buffer */ - if (!q_u->buffer) { + if (!q_u->buffer && (q_u->offered!=0)) { return WERR_INVALID_PARAM; } @@ -6589,7 +6589,7 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO /* that's an [in out] buffer */ - if (!q_u->buffer) { + if (!q_u->buffer && (offered!=0)) { return WERR_INVALID_PARAM; } @@ -6966,7 +6966,7 @@ WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS /* that's an [in out] buffer */ - if (!q_u->buffer) { + if (!q_u->buffer && (offered!=0)) { return WERR_INVALID_PARAM; } @@ -7031,7 +7031,7 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF /* that's an [in out] buffer */ - if (!q_u->buffer) { + if (!q_u->buffer && (offered!=0) ) { return WERR_INVALID_PARAM; } @@ -7144,7 +7144,7 @@ WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * /* that's an [in out] buffer */ - if (!q_u->buffer) { + if (!q_u->buffer && (offered!=0)) { return WERR_INVALID_PARAM; } @@ -7430,7 +7430,7 @@ WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUM /* that's an [in out] buffer */ - if (!q_u->buffer) { + if (!q_u->buffer && (offered!=0)) { return WERR_INVALID_PARAM; } @@ -7840,7 +7840,7 @@ WERROR _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRI /* that's an [in out] buffer */ - if (!q_u->buffer ) { + if (!q_u->buffer && (offered!=0)) { return WERR_INVALID_PARAM; } @@ -8452,7 +8452,7 @@ WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS /* that's an [in out] buffer */ - if (!q_u->buffer) { + if (!q_u->buffer && (offered!=0)) { return WERR_INVALID_PARAM; } @@ -8531,7 +8531,7 @@ WERROR _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDAT /* that's an [in out] buffer */ - if (!q_u->buffer) { + if (!q_u->buffer && (offered!=0)) { return WERR_INVALID_PARAM; } @@ -8659,7 +8659,7 @@ WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_ /* that's an [in out] buffer */ - if (!q_u->buffer) { + if (!q_u->buffer && (offered!=0)) { return WERR_INVALID_PARAM; } @@ -8835,7 +8835,7 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ /* that's an [in out] buffer */ - if (!q_u->buffer) { + if (!q_u->buffer && (offered!=0)) { return WERR_INVALID_PARAM; } @@ -9457,7 +9457,7 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC /* that's an [in out] buffer */ - if (!q_u->buffer) { + if (!q_u->buffer && (offered!=0)) { return WERR_INVALID_PARAM; } -- cgit From 1d5ab8fd05123dd46e64a6249db2928c89aec2f2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 21 Mar 2006 00:04:05 +0000 Subject: r14597: Merge DCERPC_FAULT constants from Samba 4. Guenther (This used to be commit 3f195f8248c88ec8bf8ceb195575ce6bb49d7fc4) --- source3/rpc_server/srv_pipe.c | 10 +++++----- source3/rpc_server/srv_pipe_hnd.c | 4 ++-- source3/rpc_server/srv_samr.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index eb7fd25daa..9b6fcb2f15 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -71,7 +71,7 @@ static BOOL create_next_pdu_ntlmssp(pipes_struct *p) */ if(p->fault_state) { - setup_fault_pdu(p, NT_STATUS(0x1c010002)); + setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR)); return True; } @@ -284,7 +284,7 @@ static BOOL create_next_pdu_schannel(pipes_struct *p) */ if(p->fault_state) { - setup_fault_pdu(p, NT_STATUS(0x1c010002)); + setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR)); return True; } @@ -460,7 +460,7 @@ static BOOL create_next_pdu_noauth(pipes_struct *p) */ if(p->fault_state) { - setup_fault_pdu(p, NT_STATUS(0x1c010002)); + setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR)); return True; } @@ -2250,7 +2250,7 @@ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, * and not put the pipe into fault state. JRA. */ DEBUG(4, ("unknown\n")); - setup_fault_pdu(p, NT_STATUS(0x1c010002)); + setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR)); return True; } @@ -2268,7 +2268,7 @@ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, if (p->bad_handle_fault_state) { DEBUG(4,("api_rpcTNP: bad handle fault return.\n")); p->bad_handle_fault_state = False; - setup_fault_pdu(p, NT_STATUS(0x1C00001A)); + setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_CONTEXT_MISMATCH)); return True; } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 0d07db2be3..9cc8b72546 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -699,7 +699,7 @@ static void process_complete_pdu(pipes_struct *p) DEBUG(10,("process_complete_pdu: pipe %s in fault state.\n", p->name )); set_incoming_fault(p); - setup_fault_pdu(p, NT_STATUS(0x1c010002)); + setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR)); return; } @@ -826,7 +826,7 @@ static void process_complete_pdu(pipes_struct *p) if (!reply) { DEBUG(3,("process_complete_pdu: DCE/RPC fault sent on pipe %s\n", p->pipe_srv_name)); set_incoming_fault(p); - setup_fault_pdu(p, NT_STATUS(0x1c010002)); + setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR)); prs_mem_free(&rpc_in); } else { /* diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 015ed6c5ea..8e4955a81c 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -849,7 +849,7 @@ static BOOL api_samr_set_userinfo(pipes_struct *p) /* Fix for W2K SP2 */ /* what is that status-code ? - gd */ if (q_u.switch_value == 0x1a) { - setup_fault_pdu(p, NT_STATUS(0x1c000006)); + setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG)); return True; } return False; -- cgit From 1839b4be14e905428257eb999def184d73dcf08f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 22 Mar 2006 08:04:13 +0000 Subject: r14634: Many bug fixes thanks to train rides and overnight stays in airports * Finally fix parsing idmap uid/gid ranges not to break with spaces surrounding the '-' * Allow local groups to renamed by adding info level 2 to _samr_set_aliasinfo() * Fix parsing bug in _samr_del_dom_alias() reply * Prevent root from being deleted via Samba * Prevent builting groups from being renamed or deleted * Fix bug in pdb_tdb that broke renaming user accounts * Make sure winbindd is running when trying to create the Administrators and Users BUILTIN groups automatically from smbd (and not just check the winbind nexted groups parameter value). * Have the top level rid allocator verify that the RID it is about to grant is not already assigned in our own SAM (retries up to 250 times). This fixes passdb with existing SIDs assigned to users from the RID algorithm but not monotonically allocating the RIDs from passdb. (This used to be commit db1162241f79c2af8afb7d8c26e8ed1c4a4b476f) --- source3/rpc_server/srv_samr_nt.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6a4c9f7133..dc17977041 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3464,9 +3464,14 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - /* observed when joining XP client to Samba domain */ +#if 0 /* this really should be applied on a per info level basis --jerry */ + + /* observed when joining XP client to Samba domain */ acc_required = SA_RIGHT_USER_SET_PASSWORD | SA_RIGHT_USER_SET_ATTRIBUTES | SA_RIGHT_USER_ACCT_FLAGS_EXPIRY; +#else + acc_required = SA_RIGHT_USER_SET_ATTRIBUTES; +#endif if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo2"))) { return r_u->status; @@ -4093,12 +4098,22 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; + /* copy the handle to the outgoing reply */ + + memcpy( &r_u->pol, &q_u->alias_pol, sizeof(r_u->pol) ); + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_alias"))) { return r_u->status; } DEBUG(10, ("sid is %s\n", sid_string_static(&alias_sid))); + /* Don't let Windows delete builtin groups */ + + if ( sid_check_is_in_builtin( &alias_sid ) ) { + return NT_STATUS_SPECIAL_ACCOUNT; + } + if (!sid_check_is_in_our_domain(&alias_sid)) return NT_STATUS_NO_SUCH_ALIAS; @@ -4453,7 +4468,30 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ ctr=&q_u->ctr; + /* get the current group information */ + + if ( !pdb_get_aliasinfo( &group_sid, &info ) ) { + return NT_STATUS_NO_SUCH_ALIAS; + } + switch (ctr->level) { + case 2: + /* We currently do not support renaming groups in the + the BUILTIN domain. Refer to util_builtin.c to understand + why. The eventually needs to be fixed to be like Windows + where you can rename builtin groups, just not delete them */ + + if ( sid_check_is_in_builtin( &group_sid ) ) { + return NT_STATUS_SPECIAL_ACCOUNT; + } + + if ( ctr->alias.info2.name.string ) { + unistr2_to_ascii( info.acct_name, ctr->alias.info2.name.string, + sizeof(info.acct_name)-1 ); + } + else + fstrcpy( info.acct_name, "" ); + break; case 3: if ( ctr->alias.info3.description.string ) { unistr2_to_ascii( info.acct_desc, -- cgit From 20204ab040247d431060b9a53ca6437024d76d6c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 22 Mar 2006 15:00:42 +0000 Subject: r14646: Adding samr querygroup infolevels 2 & 5. Guenther (This used to be commit 6c4fe819c69f281915ad0f4c3bde4dfb194aa33a) --- source3/rpc_server/srv_samr_nt.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index dc17977041..c4b3d3512c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4362,6 +4362,10 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM map.comment, num_members); break; } + case 2: + ctr->switch_value1 = 2; + init_samr_group_info2(&ctr->group.info2, map.nt_name); + break; case 3: ctr->switch_value1 = 3; init_samr_group_info3(&ctr->group.info3); @@ -4370,6 +4374,28 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM ctr->switch_value1 = 4; init_samr_group_info4(&ctr->group.info4, map.comment); break; + case 5: { + /* + uint32 *members; + size_t num_members; + */ + + ctr->switch_value1 = 5; + + /* + become_root(); + r_u->status = pdb_enum_group_members( + p->mem_ctx, &group_sid, &members, &num_members); + unbecome_root(); + + if (!NT_STATUS_IS_OK(r_u->status)) { + return r_u->status; + } + */ + init_samr_group_info5(&ctr->group.info5, map.nt_name, + map.comment, 0 /* num_members */); /* in w2k3 this is always 0 */ + break; + } default: return NT_STATUS_INVALID_INFO_CLASS; } -- cgit From 00fb5e431d9e418597cadcc7914818f8cf1cc102 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 29 Mar 2006 23:35:16 +0000 Subject: r14786: Fix coverity #275. null deref. Jeremy. (This used to be commit 363d31c9ec2d2a4429ab4d26b3d7c78b76f60626) --- source3/rpc_server/srv_spoolss_nt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 350e9d3562..44a0aeba90 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -723,14 +723,21 @@ static void notify_system_time(struct spoolss_notify_msg *msg, if (!make_systemtime(&systime, gmtime((time_t *)msg->notify.data))) { DEBUG(5, ("notify_system_time: unable to make systemtime\n")); + prs_mem_free(&ps); return; } - if (!spoolss_io_system_time("", &ps, 0, &systime)) + if (!spoolss_io_system_time("", &ps, 0, &systime)) { + prs_mem_free(&ps); return; + } data->notify_data.data.length = prs_offset(&ps); data->notify_data.data.string = TALLOC(mem_ctx, prs_offset(&ps)); + if (!data->notify_data.data.string) { + prs_mem_free(&ps); + return; + } prs_copy_all_data_out((char *)data->notify_data.data.string, &ps); -- cgit From 2178bcaa39ec20e055537611619f694a0ebd7248 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 29 Mar 2006 23:42:03 +0000 Subject: r14788: Fix coverity bug #276. null deref. Jeremy. (This used to be commit 0217f7d7bf4c8b5b7de2433485fb6f78b62ac817) --- source3/rpc_server/srv_spoolss_nt.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 44a0aeba90..aede762ed4 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -984,6 +984,10 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) /* allocate the max entries possible */ data = TALLOC_ARRAY( mem_ctx, SPOOL_NOTIFY_INFO_DATA, msg_group->num_msgs); + if (!data) { + return; + } + ZERO_STRUCTP(data); /* build the array of change notifications */ @@ -1400,6 +1404,9 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode) len = unistrlen(devmode->devicename.buffer); if (len != -1) { d->devicename.buffer = TALLOC_ARRAY(ctx, uint16, len); + if (!d->devicename.buffer) { + return NULL; + } if (unistrcpy(d->devicename.buffer, devmode->devicename.buffer) != len) return NULL; } @@ -1408,12 +1415,17 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode) len = unistrlen(devmode->formname.buffer); if (len != -1) { d->devicename.buffer = TALLOC_ARRAY(ctx, uint16, len); + if (!d->devicename.buffer) { + return NULL; + } if (unistrcpy(d->formname.buffer, devmode->formname.buffer) != len) return NULL; } d->dev_private = TALLOC_MEMDUP(ctx, devmode->dev_private, devmode->driverextra); - + if (!d->dev_private) { + return NULL; + } return d; } @@ -5894,6 +5906,10 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, } new_secdesc_ctr = sec_desc_merge(p->mem_ctx, secdesc_ctr, old_secdesc_ctr); + if (!new_secdesc_ctr) { + result = WERR_NOMEM; + goto done; + } if (sec_desc_equal(new_secdesc_ctr->sec, old_secdesc_ctr->sec)) { result = WERR_OK; -- cgit From 655b04e4f8585a952afe226e602995ebbc7d1600 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 11 Apr 2006 15:47:24 +0000 Subject: r15041: Adding rpc client calls to manipulate auditing policies on remote CIFS servers. Also add a new "net rpc audit" tool. The lsa query infolevels were taken from samb4 IDL, the lsa policy flags and categories are partly documented on msdn. I need to cleanup the double lsa_query_info_policy{2}{_new} calls next. Guenther (This used to be commit 0fed66926f4b72444abfc8ffb8c46cca8d0600aa) --- source3/rpc_server/srv_lsa_nt.c | 53 ++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 7fe42efefb..1f74f24296 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -62,7 +62,7 @@ static void free_lsa_info(void *ptr) Init dom_query ***************************************************************************/ -static void init_dom_query(DOM_QUERY *d_q, const char *dom_name, DOM_SID *dom_sid) +static void init_dom_query_3(DOM_QUERY_3 *d_q, const char *dom_name, DOM_SID *dom_sid) { d_q->buffer_dom_name = (dom_name != NULL) ? 1 : 0; /* domain buffer pointer */ d_q->buffer_dom_sid = (dom_sid != NULL) ? 1 : 0; /* domain sid pointer */ @@ -93,6 +93,15 @@ static void init_dom_query(DOM_QUERY *d_q, const char *dom_name, DOM_SID *dom_si init_dom_sid2(&d_q->dom_sid, dom_sid); } +/*************************************************************************** +Init dom_query + ***************************************************************************/ + +static void init_dom_query_5(DOM_QUERY_5 *d_q, const char *dom_name, DOM_SID *dom_sid) +{ + return init_dom_query_3(d_q, dom_name, dom_sid); +} + /*************************************************************************** init_dom_ref - adds a domain if it's not already in, returns the index. ***************************************************************************/ @@ -678,7 +687,7 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO *r_u) { struct lsa_info *handle; - LSA_INFO_UNION *info = &r_u->dom; + LSA_INFO_CTR *ctr = &r_u->ctr; DOM_SID domain_sid; const char *name; DOM_SID *sid = NULL; @@ -691,19 +700,31 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF switch (q_u->info_class) { case 0x02: { - unsigned int i; + + uint32 policy_def = LSA_AUDIT_POLICY_ALL; + /* check if the user have enough rights */ - if (!(handle->access & POLICY_VIEW_AUDIT_INFORMATION)) + if (!(handle->access & POLICY_VIEW_AUDIT_INFORMATION)) { + DEBUG(10,("_lsa_query_info: insufficient access rights\n")); return NT_STATUS_ACCESS_DENIED; + } /* fake info: We audit everything. ;) */ - info->id2.auditing_enabled = 1; - info->id2.count1 = 7; - info->id2.count2 = 7; - if ((info->id2.auditsettings = TALLOC_ARRAY(p->mem_ctx,uint32, 7)) == NULL) + ctr->info.id2.ptr = 1; + ctr->info.id2.auditing_enabled = True; + ctr->info.id2.count1 = ctr->info.id2.count2 = LSA_AUDIT_NUM_CATEGORIES; + + if ((ctr->info.id2.auditsettings = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, LSA_AUDIT_NUM_CATEGORIES)) == NULL) return NT_STATUS_NO_MEMORY; - for (i = 0; i < 7; i++) - info->id2.auditsettings[i] = 3; + + ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_ACCOUNT_MANAGEMENT] = policy_def; + ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_FILE_AND_OBJECT_ACCESS] = policy_def; + ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_LOGON] = policy_def; + ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_PROCCESS_TRACKING] = policy_def; + ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_SECURITY_POLICY_CHANGES] = policy_def; + ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_SYSTEM] = policy_def; + ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_USE_OF_USER_RIGHTS] = policy_def; + break; } case 0x03: @@ -733,7 +754,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; } - init_dom_query(&r_u->dom.id3, name, sid); + init_dom_query_3(&r_u->ctr.info.id3, name, sid); break; case 0x05: /* check if the user have enough rights */ @@ -743,7 +764,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF /* Request PolicyAccountDomainInformation. */ name = get_global_sam_name(); sid = get_global_sam_sid(); - init_dom_query(&r_u->dom.id5, name, sid); + init_dom_query_5(&r_u->ctr.info.id5, name, sid); break; case 0x06: /* check if the user have enough rights */ @@ -756,14 +777,14 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF * only a BDC is a backup controller * of the domain, it controls. */ - info->id6.server_role = 2; + ctr->info.id6.server_role = 2; break; default: /* * any other role is a primary * of the domain, it controls. */ - info->id6.server_role = 3; + ctr->info.id6.server_role = 3; break; } break; @@ -774,8 +795,8 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF } if (NT_STATUS_IS_OK(r_u->status)) { - r_u->undoc_buffer = 0x22000000; /* bizarre */ - r_u->info_class = q_u->info_class; + r_u->dom_ptr = 0x22000000; /* bizarre */ + ctr->info_class = q_u->info_class; } return r_u->status; -- cgit From 3f2b06d614c7bb9cd2699f0e380a8b3e9e08137f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 11 Apr 2006 17:00:08 +0000 Subject: r15044: Fix the build. (void returning non-void). Guenther (This used to be commit 3ff278b852b4085461127bc7ccb2c5dba81fb3c8) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 1f74f24296..d5222bbcb9 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -99,7 +99,7 @@ Init dom_query static void init_dom_query_5(DOM_QUERY_5 *d_q, const char *dom_name, DOM_SID *dom_sid) { - return init_dom_query_3(d_q, dom_name, dom_sid); + init_dom_query_3(d_q, dom_name, dom_sid); } /*************************************************************************** -- cgit From e17302200c138eec7df504a7f4b2bde46073a810 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 17 Apr 2006 11:49:06 +0000 Subject: r15101: Little step towards getting Samba4 tdb into 3: tdb_lock_bystring does not have the timeout argument in Samba4. Add a new routine tdb_lock_bystring_with_timeout. Volker (This used to be commit b9c6e3f55602fa505859a4b2cd137b74105d685f) --- source3/rpc_server/srv_eventlog_lib.c | 4 ++-- source3/rpc_server/srv_eventlog_nt.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index b3d94901ba..acae1c94e9 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -163,7 +163,7 @@ BOOL make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, if ( mem_ctx == NULL ) return False; /* can't allocate memory indicates bigger problems */ /* lock */ - tdb_lock_bystring( the_tdb, EVT_NEXT_RECORD, 1 ); + tdb_lock_bystring_with_timeout( the_tdb, EVT_NEXT_RECORD, 1 ); /* read */ end_record = tdb_fetch_int32( the_tdb, EVT_NEXT_RECORD ); start_record = tdb_fetch_int32( the_tdb, EVT_OLDEST_ENTRY ); @@ -489,7 +489,7 @@ int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ) /* need to read the record number and insert it into the entry here */ /* lock */ - tdb_lock_bystring( the_tdb, EVT_NEXT_RECORD, 1 ); + tdb_lock_bystring_with_timeout( the_tdb, EVT_NEXT_RECORD, 1 ); /* read */ next_record = tdb_fetch_int32( the_tdb, EVT_NEXT_RECORD ); diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index a8b9c66717..284ee37348 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -146,7 +146,7 @@ static BOOL get_num_records_hook( EVENTLOG_INFO * info ) /* lock the tdb since we have to get 2 records */ - tdb_lock_bystring( ELOG_TDB_CTX(info->etdb), EVT_NEXT_RECORD, 1 ); + tdb_lock_bystring_with_timeout( ELOG_TDB_CTX(info->etdb), EVT_NEXT_RECORD, 1 ); next_record = tdb_fetch_int32( ELOG_TDB_CTX(info->etdb), EVT_NEXT_RECORD); oldest_record = tdb_fetch_int32( ELOG_TDB_CTX(info->etdb), EVT_OLDEST_ENTRY); tdb_unlock_bystring( ELOG_TDB_CTX(info->etdb), EVT_NEXT_RECORD); -- cgit From 0498f3b8890ec62eeb9275a6bf685a6c3d81fce5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 18 Apr 2006 18:00:57 +0000 Subject: r15129: Separate out mechanism and policy for NTLMSSP auth/sign/seal. With this change (and setting lanman auth = no in smb.conf) we have *identical* NTLMSSP flags to W2K3 in SPNEGO auth. Jeremy (This used to be commit 93ca3eee55297eb7fdd38fca38103ce129987e2a) --- source3/rpc_server/srv_pipe.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 9b6fcb2f15..72298520e3 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -606,7 +606,7 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) NTSTATUS status; AUTH_NTLMSSP_STATE *a = p->auth.a_u.auth_ntlmssp_state; - DEBUG(5,("pipe_ntlmssp_verify_final: checking user details\n")); + DEBUG(5,("pipe_ntlmssp_verify_final: pipe %s checking user details\n", p->name)); ZERO_STRUCT(reply); @@ -629,6 +629,27 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) return False; } + /* Finally - if the pipe negotiated integrity (sign) or privacy (seal) + ensure the underlying NTLMSSP flags are also set. If not we should + refuse the bind. */ + + if (p->auth.auth_level == PIPE_AUTH_LEVEL_INTEGRITY) { + if (!(a->ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SIGN)) { + DEBUG(0,("pipe_ntlmssp_verify_final: pipe %s : packet integrity requested " + "but client declined signing.\n", + p->name )); + return False; + } + } + if (p->auth.auth_level == PIPE_AUTH_LEVEL_PRIVACY) { + if (!(a->ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SEAL)) { + DEBUG(0,("pipe_ntlmssp_verify_final: pipe %s : packet privacy requested " + "but client declined sealing.\n", + p->name )); + return False; + } + } + fstrcpy(p->user_name, a->ntlmssp_state->user); fstrcpy(p->pipe_user_name, a->server_info->unix_name); fstrcpy(p->domain, a->ntlmssp_state->domain); -- cgit From d4a51cc5009ac2794070e8f9b159d17be7af8a47 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 28 Apr 2006 15:35:42 +0000 Subject: r15309: normalize printing keys when deleting (This used to be commit 037f9f831e001a12261419e37c725558dd717af9) --- source3/rpc_server/srv_spoolss_nt.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index aede762ed4..70470a45e7 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7657,21 +7657,6 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, goto done; } - /* BEGIN_ADMIN_LOG */ - switch(level) { - case 3: - fstrcpy(driver_name, driver.info_3->name ? driver.info_3->name : ""); - sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", - driver_name, get_drv_ver_to_os(driver.info_3->cversion),uidtoname(user.ut.uid)); - break; - case 6: - fstrcpy(driver_name, driver.info_6->name ? driver.info_6->name : ""); - sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.", - driver_name, get_drv_ver_to_os(driver.info_6->version),uidtoname(user.ut.uid)); - break; - } - /* END_ADMIN_LOG */ - /* * I think this is where he DrvUpgradePrinter() hook would be * be called in a driver's interface DLL on a Windows NT 4.0/2k -- cgit From 1f3fe6a50451c6e0b223fa70ddceb7543f060d89 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 29 Apr 2006 23:36:57 +0000 Subject: r15334: Fix warning. This table and function not used anymore. Jerry please check. Jeremy. (This used to be commit 9f676603aaf84829d52dc8d0e0872a058a4d3d4e) --- source3/rpc_server/srv_spoolss_nt.c | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 70470a45e7..2e224896c4 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -40,23 +40,6 @@ extern userdom_struct current_user_info; #define MAGIC_DISPLAY_FREQUENCY 0xfade2bad #define PHANTOM_DEVMODE_KEY "_p_f_a_n_t_0_m_" - -/* Table to map the driver version */ -/* to OS */ -static const char * drv_ver_to_os[] = { - "WIN9X", /* driver version/cversion 0 */ - "", /* unused ? */ - "WINNT", /* driver version/cversion 2 */ - "WIN2K", /* driver version/cversion 3 */ -}; - -static const char *get_drv_ver_to_os(int ver) -{ - if (ver < 0 || ver > 3) - return ""; - return drv_ver_to_os[ver]; -} - struct table_node { const char *long_archi; const char *short_archi; -- cgit From 2bdbd3fa6dd351f393f4972578e382da73ebcc18 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 1 May 2006 18:54:53 +0000 Subject: r15380: default eventlog tdbs to mode 0660 to allow easier access by BUILTIN\Administrators (This used to be commit a02933c9589e34488f289cbc40f77f6864a58367) --- source3/rpc_server/srv_eventlog_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index acae1c94e9..e04aefa7e1 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -39,7 +39,7 @@ TDB_CONTEXT *elog_init_tdb( char *tdbfilename ) tdbfilename)); tdb = tdb_open_log( tdbfilename, 0, TDB_DEFAULT, - O_RDWR|O_CREAT|O_TRUNC, 0600 ); + O_RDWR|O_CREAT|O_TRUNC, 0660 ); if ( !tdb ) { DEBUG( 0, ( "Can't open tdb for [%s]\n", tdbfilename ) ); -- cgit From 52e778e6f85c5affbcc40e5ce629792e6f16b553 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 4 May 2006 17:28:05 +0000 Subject: r15438: Fix samrQueryDomainInfo level 5 where we returned our netbios name eversince instead of the domain name when we are a DC. Yes, there are applications relying on this call to be correct. Guenther (This used to be commit 26dd22c9af8caf3db236984e4683ba210376ca59) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c4b3d3512c..d672ab4a5b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2301,7 +2301,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA init_unk_info3(&ctr->info.inf3, nt_logout); break; case 0x05: - init_unk_info5(&ctr->info.inf5, global_myname()); + init_unk_info5(&ctr->info.inf5, get_global_sam_name()); break; case 0x06: init_unk_info6(&ctr->info.inf6); @@ -4802,7 +4802,7 @@ NTSTATUS _samr_query_domain_info2(pipes_struct *p, init_unk_info3(&ctr->info.inf3, nt_logout); break; case 0x05: - init_unk_info5(&ctr->info.inf5, global_myname()); + init_unk_info5(&ctr->info.inf5, get_global_sam_name()); break; case 0x06: init_unk_info6(&ctr->info.inf6); -- cgit From 0fe21ac5609940be815148a2f73e1e456b7c3cce Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 4 May 2006 19:01:11 +0000 Subject: r15442: Add some more client rpc for the querydominfo calls (from samba4 idl). Also return the hostname for the level 6 call (to be consistent with the server name in level 2). Guenther (This used to be commit 41b72e77ae70c96de4659af6b4b6bd842dd67981) --- source3/rpc_server/srv_samr_nt.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d672ab4a5b..035f838048 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2304,7 +2304,10 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA init_unk_info5(&ctr->info.inf5, get_global_sam_name()); break; case 0x06: - init_unk_info6(&ctr->info.inf6); + /* NT returns its own name when a PDC. win2k and later + * only the name of the PDC if itself is a BDC (samba4 + * idl) */ + init_unk_info6(&ctr->info.inf6, global_myname()); break; case 0x07: server_role = ROLE_DOMAIN_PDC; @@ -4712,8 +4715,8 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, ********************************************************************/ NTSTATUS _samr_query_domain_info2(pipes_struct *p, - SAMR_Q_QUERY_DOMAIN_INFO2 *q_u, - SAMR_R_QUERY_DOMAIN_INFO2 *r_u) + SAMR_Q_QUERY_DOMAIN_INFO2 *q_u, + SAMR_R_QUERY_DOMAIN_INFO2 *r_u) { struct samr_info *info = NULL; SAM_UNK_CTR *ctr; @@ -4805,7 +4808,10 @@ NTSTATUS _samr_query_domain_info2(pipes_struct *p, init_unk_info5(&ctr->info.inf5, get_global_sam_name()); break; case 0x06: - init_unk_info6(&ctr->info.inf6); + /* NT returns its own name when a PDC. win2k and later + * only the name of the PDC if itself is a BDC (samba4 + * idl) */ + init_unk_info6(&ctr->info.inf6, global_myname()); break; case 0x07: server_role = ROLE_DOMAIN_PDC; @@ -4849,7 +4855,7 @@ NTSTATUS _samr_query_domain_info2(pipes_struct *p, } /******************************************************************* - _samr_ + _samr_set_dom_info ********************************************************************/ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R_SET_DOMAIN_INFO *r_u) -- cgit From c5e28047622aba53c8d009df77ce4d230d4d6637 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 5 May 2006 08:04:28 +0000 Subject: r15452: Again purely cosmetic reformat of the samr query domain info calls. Guenther (This used to be commit 6ed7d7fa70e3f750f921192c0f75594d608875b7) --- source3/rpc_server/srv_samr.c | 19 +++++++++---------- source3/rpc_server/srv_samr_nt.c | 14 ++++++++------ 2 files changed, 17 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 8e4955a81c..6ce4f88261 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -525,10 +525,10 @@ static BOOL api_samr_query_usergroups(pipes_struct *p) } /******************************************************************* - api_samr_query_dom_info + api_samr_query_domain_info ********************************************************************/ -static BOOL api_samr_query_dom_info(pipes_struct *p) +static BOOL api_samr_query_domain_info(pipes_struct *p) { SAMR_Q_QUERY_DOMAIN_INFO q_u; SAMR_R_QUERY_DOMAIN_INFO r_u; @@ -538,16 +538,16 @@ static BOOL api_samr_query_dom_info(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - if(!samr_io_q_query_dom_info("", &q_u, data, 0)) { - DEBUG(0,("api_samr_query_dom_info: unable to unmarshall SAMR_Q_QUERY_DOMAIN_INFO.\n")); + if(!samr_io_q_query_domain_info("", &q_u, data, 0)) { + DEBUG(0,("api_samr_query_domain_info: unable to unmarshall SAMR_Q_QUERY_DOMAIN_INFO.\n")); return False; } - r_u.status = _samr_query_dom_info(p, &q_u, &r_u); + r_u.status = _samr_query_domain_info(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_query_dom_info("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_query_dom_info: unable to marshall SAMR_R_QUERY_DOMAIN_INFO.\n")); + if(!samr_io_r_query_domain_info("", &r_u, rdata, 0)) { + DEBUG(0,("api_samr_query_domain_info: unable to marshall SAMR_R_QUERY_DOMAIN_INFO.\n")); return False; } @@ -1449,7 +1449,6 @@ static BOOL api_samr_query_domain_info2(pipes_struct *p) ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); - /* grab the samr unknown 8 command */ if(!samr_io_q_query_domain_info2("", &q_u, data, 0)) { DEBUG(0,("api_samr_query_domain_info2: unable to unmarshall SAMR_Q_QUERY_DOMAIN_INFO2.\n")); return False; @@ -1458,7 +1457,7 @@ static BOOL api_samr_query_domain_info2(pipes_struct *p) r_u.status = _samr_query_domain_info2(p, &q_u, &r_u); /* store the response in the SMB stream */ - if(!samr_io_r_samr_query_domain_info2("", &r_u, rdata, 0)) { + if(!samr_io_r_query_domain_info2("", &r_u, rdata, 0)) { DEBUG(0,("api_samr_query_domain_info2: unable to marshall SAMR_R_QUERY_DOMAIN_INFO2.\n")); return False; } @@ -1529,7 +1528,7 @@ static struct api_struct api_samr_cmds [] = {"SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo }, {"SAMR_SET_USERINFO2" , SAMR_SET_USERINFO2 , api_samr_set_userinfo2 }, - {"SAMR_QUERY_DOMAIN_INFO" , SAMR_QUERY_DOMAIN_INFO, api_samr_query_dom_info }, + {"SAMR_QUERY_DOMAIN_INFO" , SAMR_QUERY_DOMAIN_INFO, api_samr_query_domain_info}, {"SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, {"SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, {"SAMR_QUERY_DISPINFO3" , SAMR_QUERY_DISPINFO3 , api_samr_query_dispinfo }, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 035f838048..d2a8447786 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2180,10 +2180,12 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S } /******************************************************************* - _samr_query_dom_info + _samr_query_domain_info ********************************************************************/ -NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR_R_QUERY_DOMAIN_INFO *r_u) +NTSTATUS _samr_query_domain_info(pipes_struct *p, + SAMR_Q_QUERY_DOMAIN_INFO *q_u, + SAMR_R_QUERY_DOMAIN_INFO *r_u) { struct samr_info *info = NULL; SAM_UNK_CTR *ctr; @@ -2212,7 +2214,7 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA r_u->status = NT_STATUS_OK; - DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); + DEBUG(5,("_samr_query_domain_info: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)(void *)&info)) { @@ -2364,9 +2366,9 @@ NTSTATUS _samr_query_dom_info(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO *q_u, SA } - init_samr_r_query_dom_info(r_u, q_u->switch_value, ctr, NT_STATUS_OK); + init_samr_r_query_domain_info(r_u, q_u->switch_value, ctr, NT_STATUS_OK); - DEBUG(5,("_samr_query_dom_info: %d\n", __LINE__)); + DEBUG(5,("_samr_query_domain_info: %d\n", __LINE__)); return r_u->status; } @@ -4847,7 +4849,7 @@ NTSTATUS _samr_query_domain_info2(pipes_struct *p, return NT_STATUS_INVALID_INFO_CLASS; } - init_samr_r_samr_query_domain_info2(r_u, q_u->switch_value, ctr, NT_STATUS_OK); + init_samr_r_query_domain_info2(r_u, q_u->switch_value, ctr, NT_STATUS_OK); DEBUG(5,("_samr_query_domain_info2: %d\n", __LINE__)); -- cgit From 212b832e4a3a368d14f061aeffcc034650e247da Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 5 May 2006 08:22:50 +0000 Subject: r15454: As testing, documentation and samba4 idl indicate that there is no known difference between samr_query_domain_info and samr_query_domain_info2, wrap the info2 call around the info call. There have been various "could not access LDAP when not root" bugs lurking around in samr_query_domain_info2 anyway. Guenther (This used to be commit 3e181b46bea87797d654d57a6c8231cba6ff5a7b) --- source3/rpc_server/srv_samr_nt.c | 136 +++------------------------------------ 1 file changed, 10 insertions(+), 126 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d2a8447786..4507c1c88b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4720,138 +4720,22 @@ NTSTATUS _samr_query_domain_info2(pipes_struct *p, SAMR_Q_QUERY_DOMAIN_INFO2 *q_u, SAMR_R_QUERY_DOMAIN_INFO2 *r_u) { - struct samr_info *info = NULL; - SAM_UNK_CTR *ctr; - uint32 min_pass_len,pass_hist,password_properties; - time_t u_expire, u_min_age; - NTTIME nt_expire, nt_min_age; - - time_t u_lock_duration, u_reset_time; - NTTIME nt_lock_duration, nt_reset_time; - uint32 lockout; - - time_t u_logout; - NTTIME nt_logout; + SAMR_Q_QUERY_DOMAIN_INFO q; + SAMR_R_QUERY_DOMAIN_INFO r; - uint32 num_users=0, num_groups=0, num_aliases=0; - - uint32 account_policy_temp; - - time_t seq_num; - uint32 server_role; - - if ((ctr = TALLOC_ZERO_P(p->mem_ctx, SAM_UNK_CTR)) == NULL) - return NT_STATUS_NO_MEMORY; - - ZERO_STRUCTP(ctr); - - r_u->status = NT_STATUS_OK; + ZERO_STRUCT(q); + ZERO_STRUCT(r); DEBUG(5,("_samr_query_domain_info2: %d\n", __LINE__)); - /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)(void *)&info)) - return NT_STATUS_INVALID_HANDLE; - - switch (q_u->switch_value) { - case 0x01: - pdb_get_account_policy(AP_MIN_PASSWORD_LEN, &account_policy_temp); - min_pass_len = account_policy_temp; - - pdb_get_account_policy(AP_PASSWORD_HISTORY, &account_policy_temp); - pass_hist = account_policy_temp; - - pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp); - password_properties = account_policy_temp; - - pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &account_policy_temp); - u_expire = account_policy_temp; - - pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &account_policy_temp); - u_min_age = account_policy_temp; + q.domain_pol = q_u->domain_pol; + q.switch_value = q_u->switch_value; - unix_to_nt_time_abs(&nt_expire, u_expire); - unix_to_nt_time_abs(&nt_min_age, u_min_age); + r_u->status = _samr_query_domain_info(p, &q, &r); - init_unk_info1(&ctr->info.inf1, (uint16)min_pass_len, (uint16)pass_hist, - password_properties, nt_expire, nt_min_age); - break; - case 0x02: - become_root(); - num_users = count_sam_users(info->disp_info, ACB_NORMAL); - num_groups = count_sam_groups(info->disp_info); - num_aliases = count_sam_aliases(info->disp_info); - unbecome_root(); - - pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); - u_logout = account_policy_temp; - - unix_to_nt_time_abs(&nt_logout, u_logout); - - if (!pdb_get_seq_num(&seq_num)) - seq_num = time(NULL); - - server_role = ROLE_DOMAIN_PDC; - if (lp_server_role() == ROLE_DOMAIN_BDC) - server_role = ROLE_DOMAIN_BDC; - - init_unk_info2(&ctr->info.inf2, lp_serverstring(), lp_workgroup(), global_myname(), seq_num, - num_users, num_groups, num_aliases, nt_logout, server_role); - break; - case 0x03: - pdb_get_account_policy(AP_TIME_TO_LOGOUT, &account_policy_temp); - u_logout = account_policy_temp; - - unix_to_nt_time_abs(&nt_logout, u_logout); - - init_unk_info3(&ctr->info.inf3, nt_logout); - break; - case 0x05: - init_unk_info5(&ctr->info.inf5, get_global_sam_name()); - break; - case 0x06: - /* NT returns its own name when a PDC. win2k and later - * only the name of the PDC if itself is a BDC (samba4 - * idl) */ - init_unk_info6(&ctr->info.inf6, global_myname()); - break; - case 0x07: - server_role = ROLE_DOMAIN_PDC; - if (lp_server_role() == ROLE_DOMAIN_BDC) - server_role = ROLE_DOMAIN_BDC; - - init_unk_info7(&ctr->info.inf7, server_role); - break; - case 0x08: - if (!pdb_get_seq_num(&seq_num)) - seq_num = time(NULL); - - init_unk_info8(&ctr->info.inf8, (uint32) seq_num); - break; - case 0x0c: - pdb_get_account_policy(AP_LOCK_ACCOUNT_DURATION, &account_policy_temp); - u_lock_duration = account_policy_temp; - if (u_lock_duration != -1) - u_lock_duration *= 60; - - pdb_get_account_policy(AP_RESET_COUNT_TIME, &account_policy_temp); - u_reset_time = account_policy_temp * 60; - - pdb_get_account_policy(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_temp); - lockout = account_policy_temp; - - unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); - unix_to_nt_time_abs(&nt_reset_time, u_reset_time); - - init_unk_info12(&ctr->info.inf12, nt_lock_duration, nt_reset_time, (uint16)lockout); - break; - default: - return NT_STATUS_INVALID_INFO_CLASS; - } - - init_samr_r_query_domain_info2(r_u, q_u->switch_value, ctr, NT_STATUS_OK); - - DEBUG(5,("_samr_query_domain_info2: %d\n", __LINE__)); + r_u->ptr_0 = r.ptr_0; + r_u->switch_value = r.switch_value; + r_u->ctr = r.ctr; return r_u->status; } -- cgit From 4137c63d0236d429c33b718674b365c6efcba695 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 5 May 2006 08:26:34 +0000 Subject: r15455: Add rpccli_samr_query_dom_info2() and return the comment string in samr_query_domain_info(2) for consistency reasons. Guenther (This used to be commit 870495e2c8628deee0498e68cc1d93abfbc56da4) --- source3/rpc_server/srv_samr_nt.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 4507c1c88b..c9e6b552c8 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2302,6 +2302,9 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, init_unk_info3(&ctr->info.inf3, nt_logout); break; + case 0x04: + init_unk_info4(&ctr->info.inf4, lp_serverstring()); + break; case 0x05: init_unk_info5(&ctr->info.inf5, get_global_sam_name()); break; -- cgit From 77aa11f4dc78450640802cd944a2ee541f12080f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 13 May 2006 17:21:07 +0000 Subject: r15570: Fix Coverity bug # 286. I really wonder why gcc -O1 did not catch this one. Volker (This used to be commit c6bf2c8922e612278349fe53ca11f6be6c819009) --- source3/rpc_server/srv_reg_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 5ac6738b99..8fd0e55c54 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -1199,7 +1199,7 @@ WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY *r_u) { REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->handle); - REGISTRY_KEY *newparentinfo; + REGISTRY_KEY *newparentinfo = NULL; POLICY_HND newparent_handle; REGSUBKEY_CTR *subkeys; BOOL write_result; -- cgit From 1a850a4f37654282039e4b8712a874365ca16681 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 31 May 2006 01:31:01 +0000 Subject: r15975: Only call the printer publishing calls if 'security = ads' (prevent a segv) (This used to be commit a2ef525d9e3b4f050cb4e02fad67808d3e916373) --- source3/rpc_server/srv_spoolss_nt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2e224896c4..0281e3da0c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6279,7 +6279,13 @@ static WERROR publish_or_unpublish_printer(pipes_struct *p, POLICY_HND *handle, #ifdef HAVE_ADS SPOOL_PRINTER_INFO_LEVEL_7 *info7 = info->info_7; int snum; - Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + Printer_entry *Printer; + + if ( lp_security() != SEC_ADS ) { + return WERR_UNKNOWN_LEVEL; + } + + Printer = find_printer_index_by_hnd(p, handle); DEBUG(5,("publish_or_unpublish_printer, action = %d\n",info7->action)); -- cgit From 656d8c30db52ecfeecff83909dbb9bafb37d123c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 6 Jun 2006 00:34:26 +0000 Subject: r16054: Janitor for Volker ? Volker - some reason you didn't fix this in 3.0 ? Jeremy. We had no way to return NT_STATUS_OK from the netlogon serverpwset, although we successfully set the machine password... One thing the samba3 join test found. Volker (This used to be commit e5b7acc9b5cb6e8cf3d03c9d392fad06e0d282d9) --- source3/rpc_server/srv_netlog_nt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 1a7ab4ef53..d512115e83 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -510,7 +510,6 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_u) { - NTSTATUS status = NT_STATUS_ACCESS_DENIED; fstring remote_machine; struct samu *sampass=NULL; BOOL ret = False; @@ -632,7 +631,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * } /* set up the LSA Server Password Set response */ - init_net_r_srv_pwset(r_u, &cred_out, status); + init_net_r_srv_pwset(r_u, &cred_out, r_u->status); TALLOC_FREE(sampass); return r_u->status; -- cgit From c594a5519d459730252a9692200a849b84b4e96a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 6 Jun 2006 14:18:12 +0000 Subject: r16060: This is one of the more dirty patches I've put in lately. Parse enough of SetUserInfo level 25 to survive the join method XP uses if the user did not exist before. For good taste this contains way too much cut&paste, but for a real fix there is just not enough time. Up to 3.0.22 we completely ignored that a full level 21 is being sent together with level 25, but we got away with that because on creation we did not set the "disabled" flag on the workstation account. Now we correctly follow W2k3 in this regard, and we end up with a disabled workstation after join. Man, I hate rpc_parse/. The correct fix would be to import PIDL generated samr parsing, but this is would probably be a bit too much for .23... Thanks to Tom Bork for finding this one. Volker (This used to be commit 5a37aba10551456042266443cc0a92f28f8c3d0d) --- source3/rpc_server/srv_samr_nt.c | 52 ++++++++++ source3/rpc_server/srv_samr_util.c | 189 +++++++++++++++++++++++++++++++++++++ 2 files changed, 241 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c9e6b552c8..7a06e562ef 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3298,6 +3298,52 @@ static BOOL set_user_info_pw(uint8 *pass, struct samu *pwd) return True; } +/******************************************************************* + set_user_info_25 + ********************************************************************/ + +static NTSTATUS set_user_info_25(TALLOC_CTX *mem_ctx, SAM_USER_INFO_25 *id25, + struct samu *pwd) +{ + NTSTATUS status; + + if (id25 == NULL) { + DEBUG(5, ("set_user_info_25: NULL id25\n")); + return NT_STATUS_INVALID_PARAMETER; + } + + copy_id25_to_sam_passwd(pwd, id25); + + /* + * 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 + */ + + if ( IS_SAM_CHANGED(pwd, PDB_GROUPSID) ) { + status = pdb_set_unix_primary_group(mem_ctx, pwd); + if ( !NT_STATUS_IS_OK(status) ) { + return status; + } + } + + /* Don't worry about writing out the user account since the + primary group SID is generated solely from the user's Unix + primary group. */ + + /* write the change out */ + if(!NT_STATUS_IS_OK(status = pdb_update_sam_account(pwd))) { + TALLOC_FREE(pwd); + return status; + } + + /* WARNING: No TALLOC_FREE(pwd), we are about to set the password + * hereafter! */ + + return NT_STATUS_OK; +} + /******************************************************************* samr_reply_set_userinfo ********************************************************************/ @@ -3401,6 +3447,11 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE dump_data(100, (char *)ctr->info.id25->pass, 532); + r_u->status = set_user_info_25(p->mem_ctx, + ctr->info.id25, pwd); + if (!NT_STATUS_IS_OK(r_u->status)) { + goto done; + } if (!set_user_info_pw(ctr->info.id25->pass, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; break; @@ -3433,6 +3484,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE r_u->status = NT_STATUS_INVALID_INFO_CLASS; } + done: if ( has_enough_rights ) unbecome_root(); diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 03a726dd92..2b65eb210f 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -549,3 +549,192 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) DEBUG(10,("INFO_23 PADDING_2: %02X\n",from->padding2)); } + +/************************************************************* + Copies a SAM_USER_INFO_25 to a struct samu +**************************************************************/ + +void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) +{ + time_t unix_time, stored_time; + const char *old_string, *new_string; + DATA_BLOB mung; + + if (from == NULL || to == NULL) + return; + + if (from->fields_present & ACCT_LAST_LOGON) { + unix_time=nt_time_to_unix(&from->logon_time); + stored_time = pdb_get_logon_time(to); + DEBUG(10,("INFO_25 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_logon_time(to, unix_time, PDB_CHANGED); + } + + if (from->fields_present & ACCT_LAST_LOGOFF) { + unix_time=nt_time_to_unix(&from->logoff_time); + stored_time = pdb_get_logoff_time(to); + DEBUG(10,("INFO_25 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_logoff_time(to, unix_time, PDB_CHANGED); + } + + if (from->fields_present & ACCT_EXPIRY) { + unix_time=nt_time_to_unix(&from->kickoff_time); + stored_time = pdb_get_kickoff_time(to); + DEBUG(10,("INFO_25 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); + } + + if (from->fields_present & ACCT_ALLOW_PWD_CHANGE) { + unix_time=nt_time_to_unix(&from->pass_can_change_time); + stored_time = pdb_get_pass_can_change_time(to); + DEBUG(10,("INFO_25 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_can_change_time(to, unix_time, PDB_CHANGED); + } + + if (from->fields_present & ACCT_LAST_PWD_CHANGE) { + unix_time=nt_time_to_unix(&from->pass_last_set_time); + stored_time = pdb_get_pass_last_set_time(to); + DEBUG(10,("INFO_25 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); + } + + if (from->fields_present & ACCT_FORCE_PWD_CHANGE) { + unix_time=nt_time_to_unix(&from->pass_must_change_time); + stored_time=pdb_get_pass_must_change_time(to); + DEBUG(10,("INFO_25 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + if (stored_time != unix_time) + pdb_set_pass_must_change_time(to, unix_time, PDB_CHANGED); + } + + if ((from->fields_present & ACCT_USERNAME) && + (from->hdr_user_name.buffer)) { + old_string = pdb_get_username(to); + new_string = unistr2_static(&from->uni_user_name); + DEBUG(10,("INFO_25 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); + if (STRING_CHANGED) + pdb_set_username(to , new_string, PDB_CHANGED); + } + + if ((from->fields_present & ACCT_FULL_NAME) && + (from->hdr_full_name.buffer)) { + old_string = pdb_get_fullname(to); + new_string = unistr2_static(&from->uni_full_name); + DEBUG(10,("INFO_25 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_fullname(to , new_string, PDB_CHANGED); + } + + if ((from->fields_present & ACCT_HOME_DIR) && + (from->hdr_home_dir.buffer)) { + old_string = pdb_get_homedir(to); + new_string = unistr2_static(&from->uni_home_dir); + DEBUG(10,("INFO_25 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_homedir(to , new_string, PDB_CHANGED); + } + + if ((from->fields_present & ACCT_HOME_DRIVE) && + (from->hdr_dir_drive.buffer)) { + old_string = pdb_get_dir_drive(to); + new_string = unistr2_static(&from->uni_dir_drive); + DEBUG(10,("INFO_25 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_dir_drive(to , new_string, PDB_CHANGED); + } + + if ((from->fields_present & ACCT_LOGON_SCRIPT) && + (from->hdr_logon_script.buffer)) { + old_string = pdb_get_logon_script(to); + new_string = unistr2_static(&from->uni_logon_script); + DEBUG(10,("INFO_25 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_logon_script(to , new_string, PDB_CHANGED); + } + + if ((from->fields_present & ACCT_PROFILE) && + (from->hdr_profile_path.buffer)) { + old_string = pdb_get_profile_path(to); + new_string = unistr2_static(&from->uni_profile_path); + DEBUG(10,("INFO_25 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_profile_path(to , new_string, PDB_CHANGED); + } + + if ((from->fields_present & ACCT_DESCRIPTION) && + (from->hdr_acct_desc.buffer)) { + old_string = pdb_get_acct_desc(to); + new_string = unistr2_static(&from->uni_acct_desc); + DEBUG(10,("INFO_25 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); + if (STRING_CHANGED) + pdb_set_acct_desc(to , new_string, PDB_CHANGED); + } + + if ((from->fields_present & ACCT_WORKSTATIONS) && + (from->hdr_workstations.buffer)) { + old_string = pdb_get_workstations(to); + new_string = unistr2_static(&from->uni_workstations); + DEBUG(10,("INFO_25 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_workstations(to , new_string, PDB_CHANGED); + } + + /* is this right? */ + if ((from->fields_present & ACCT_ADMIN_DESC) && + (from->hdr_unknown_str.buffer)) { + old_string = pdb_get_unknown_str(to); + new_string = unistr2_static(&from->uni_unknown_str); + DEBUG(10,("INFO_25 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); + if (STRING_CHANGED) + pdb_set_unknown_str(to , new_string, PDB_CHANGED); + } + + if ((from->fields_present & ACCT_CALLBACK) && + (from->hdr_munged_dial.buffer)) { + char *newstr; + old_string = pdb_get_munged_dial(to); + mung.length = from->hdr_munged_dial.uni_str_len; + mung.data = (uint8 *) from->uni_munged_dial.buffer; + newstr = (mung.length == 0) ? + NULL : base64_encode_data_blob(mung); + DEBUG(10,("INFO_25 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); + if (STRING_CHANGED_NC(old_string,newstr)) + pdb_set_munged_dial(to , newstr, PDB_CHANGED); + + SAFE_FREE(newstr); + } + + if (from->fields_present & ACCT_RID) { + if (from->user_rid == 0) { + DEBUG(10, ("INFO_25: Asked to set User RID to 0 !? Skipping change!\n")); + } else if (from->user_rid != pdb_get_user_rid(to)) { + DEBUG(10,("INFO_25 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); + } + } + + if (from->fields_present & ACCT_PRIMARY_GID) { + if (from->group_rid == 0) { + DEBUG(10, ("INFO_25: Asked to set Group RID to 0 !? Skipping change!\n")); + } else if (from->group_rid != pdb_get_group_rid(to)) { + DEBUG(10,("INFO_25 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); + pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); + } + } + + if (from->fields_present & ACCT_FLAGS) { + DEBUG(10,("INFO_25 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); + if (from->acb_info != pdb_get_acct_ctrl(to)) { + if (!(from->acb_info & ACB_AUTOLOCK) && (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) { + /* We're unlocking a previously locked user. Reset bad password counts. + Patch from Jianliang Lu. */ + pdb_set_bad_password_count(to, 0, PDB_CHANGED); + pdb_set_bad_password_time(to, 0, PDB_CHANGED); + } + pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); + } + } +} -- cgit From efdc5b72fd5c154172a94eb2e1ffa22cbbd7aacf Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 6 Jun 2006 20:34:26 +0000 Subject: r16065: Re-add a strlower_m(account) in samr_create_user that was dropped for no reason but to increase fidelity with W2k3. Tom Bork has raised valid concerns that Unix scripts might rely on the account names being lower-case, so keep that. We might later decide to only lower-case the unix name passed to 'add [user|group] script' but keep the passdb entry upper-case. But there are enough user-visible changes in 3_0 already so that we should push this off to a later date. Tom, waiting for more bug reports from you ;-)) Thanks for insisting! Volker (This used to be commit bc78cca290559c5ca7623b9f6d9933e32668b9c4) --- source3/rpc_server/srv_samr_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7a06e562ef..5e82ecd0ca 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2463,6 +2463,8 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, return NT_STATUS_NO_MEMORY; } + strlower_m(account); + nt_status = can_create(p->mem_ctx, account); if (!NT_STATUS_IS_OK(nt_status)) { return nt_status; -- cgit From f9147c4e408d316d194c4e367dfccbf433cb8ec9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Jun 2006 01:54:09 +0000 Subject: r16241: Fix Klocwork #106 and others like it. Make 2 important changes. pdb_get_methods() returning NULL is a *fatal* error. Don't try and cope with it just call smb_panic. This removes a *lot* of pointless "if (!pdb)" handling code. Secondly, ensure that if samu_init() fails we *always* back out of a function. That way we are never in a situation where the pdb_XXX() functions need to start with a "if (sampass)" test - this was just bad design, not defensive programming. Jeremy. (This used to be commit a0d368197d6ae6777b7c2c3c6e970ab8ae7ca2ae) --- source3/rpc_server/srv_netlog_nt.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index d512115e83..10cd5c82ba 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -238,7 +238,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) ret = pdb_getsampwnam(sampass, mach_acct); unbecome_root(); - if (ret == False) { + if (!ret) { DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); TALLOC_FREE(sampass); return NT_STATUS_ACCESS_DENIED; @@ -562,26 +562,30 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * } /* We must store the creds state after an update. */ + sampass = samu_new( NULL ); + if (!sampass) { + return NT_STATUS_NO_MEMORY; + } + become_root(); secrets_store_schannel_session_info(p->pipe_state_mem_ctx, remote_machine, p->dc); - if ( (sampass = samu_new( NULL )) != NULL ) { - ret = pdb_getsampwnam(sampass, p->dc->mach_acct); - } + ret = pdb_getsampwnam(sampass, p->dc->mach_acct); unbecome_root(); - if ( !sampass ) - return NT_STATUS_NO_MEMORY; + if (!ret) { + TALLOC_FREE(sampass); + return NT_STATUS_ACCESS_DENIED; + } /* Ensure the account exists and is a machine account. */ acct_ctrl = pdb_get_acct_ctrl(sampass); - if (!(ret - && (acct_ctrl & ACB_WSTRUST || + if (!(acct_ctrl & ACB_WSTRUST || acct_ctrl & ACB_SVRTRUST || - acct_ctrl & ACB_DOMTRUST))) { + acct_ctrl & ACB_DOMTRUST)) { TALLOC_FREE(sampass); return NT_STATUS_NO_SUCH_USER; } @@ -626,7 +630,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * } become_root(); - r_u->status = pdb_update_sam_account (sampass); + r_u->status = pdb_update_sam_account(sampass); unbecome_root(); } -- cgit From eb41bfb91ba754458bfb9bd68bf38992995c0d01 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 16 Jun 2006 21:10:19 +0000 Subject: r16301: Fix a memleak (This used to be commit 21aaede518503e6722ba5ccfdb2c77007d12ddee) --- source3/rpc_server/srv_srvsvc_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index f279c98c31..a936ef5870 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -746,6 +746,8 @@ static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto (*stot) = 0; } + + SAFE_FREE(session_list); } /******************************************************************* -- cgit From 3c34f6085af1e168a1fe7602ae01ba643a7781bd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 20 Jun 2006 09:16:53 +0000 Subject: r16409: Fix Klocwork ID's. 1177 In reg_perfcount.c: 1200 1202 1203 1204 In regfio.c: 1243 1245 1246 1247 1251 Jerry, the reg_perfcount and regfio.c ones, can you take a look please? This is really your code, and I'm not sure I did the right thing to return an error. smbcacls.c: 1377 srv_eventlog_nt.c: 1415 1416 1417 srv_lsa_nt.c: 1420 1421 srv_netlog_nt.c: 1429 srv_samr_nt: 1458 1459 1460 Volker Volker (This used to be commit d6547d12b1c9f9454876665a5bdb010f46b9f5ff) --- source3/rpc_server/srv_eventlog_nt.c | 12 ++++++++++++ source3/rpc_server/srv_lsa_nt.c | 5 +++++ source3/rpc_server/srv_netlog_nt.c | 5 +++++ source3/rpc_server/srv_samr_nt.c | 23 ++++++++++++++++++----- 4 files changed, 40 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 284ee37348..c1c0b6a0e2 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -682,6 +682,10 @@ NTSTATUS _eventlog_read_eventlog( pipes_struct * p, int bytes_left, record_number; uint32 elog_read_type, elog_read_dir; + if (info == NULL) { + return NT_STATUS_INVALID_HANDLE; + } + info->flags = q_u->flags; ps = &p->out_data.rdata; @@ -768,6 +772,10 @@ NTSTATUS _eventlog_get_oldest_entry( pipes_struct * p, { EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); + if (info == NULL) { + return NT_STATUS_INVALID_HANDLE; + } + if ( !( get_oldest_entry_hook( info ) ) ) return NT_STATUS_ACCESS_DENIED; @@ -785,6 +793,10 @@ NTSTATUS _eventlog_get_num_records( pipes_struct * p, { EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); + if (info == NULL) { + return NT_STATUS_INVALID_HANDLE; + } + if ( !( get_num_records_hook( info ) ) ) return NT_STATUS_ACCESS_DENIED; diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index d5222bbcb9..ae9795952c 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1133,6 +1133,11 @@ NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOO rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries); rids2 = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries); + if ((ref == NULL) || (rids == NULL) || (rids2 == NULL)) { + r_u->status = NT_STATUS_NO_MEMORY; + goto done; + } + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { r_u->status = NT_STATUS_INVALID_HANDLE; goto done; diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 10cd5c82ba..6603d2f1d4 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -985,6 +985,11 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, user_sid = pdb_get_user_sid(sampw); group_sid = pdb_get_group_sid(sampw); + if ((user_sid == NULL) || (group_sid == NULL)) { + DEBUG(1, ("_net_sam_logon: User without group or user SID\n")); + return NT_STATUS_UNSUCCESSFUL; + } + sid_copy(&domain_sid, user_sid); sid_split_rid(&domain_sid, &user_rid); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 5e82ecd0ca..bfae47ef25 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3207,8 +3207,14 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, } else { /* update the UNIX password */ if (lp_unix_password_sync() ) { - struct passwd *passwd = Get_Pwnam(pdb_get_username(pwd)); - if (!passwd) { + struct passwd *passwd; + if (pdb_get_username(pwd) == NULL) { + DEBUG(1, ("chgpasswd: User without name???\n")); + TALLOC_FREE(pwd); + return NT_STATUS_ACCESS_DENIED; + } + + if ((passwd = Get_Pwnam(pdb_get_username(pwd))) == NULL) { DEBUG(1, ("chgpasswd: Username does not exist in system !?!\n")); } @@ -3273,8 +3279,15 @@ static BOOL set_user_info_pw(uint8 *pass, struct samu *pwd) } else { /* update the UNIX password */ if (lp_unix_password_sync()) { - struct passwd *passwd = Get_Pwnam(pdb_get_username(pwd)); - if (!passwd) { + struct passwd *passwd; + + if (pdb_get_username(pwd) == NULL) { + DEBUG(1, ("chgpasswd: User without name???\n")); + TALLOC_FREE(pwd); + return False; + } + + if ((passwd = Get_Pwnam(pdb_get_username(pwd))) == NULL) { DEBUG(1, ("chgpasswd: Username does not exist in system !?!\n")); } @@ -3800,7 +3813,7 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ attr=TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_members); - if ((num_members!=0) && (rid==NULL)) + if ((num_members!=0) && (attr==NULL)) return NT_STATUS_NO_MEMORY; for (i=0; i Date: Wed, 21 Jun 2006 00:17:14 +0000 Subject: r16433: Fix Coverity #300 (triggered by a Klockwork bugfix I think). If a alloc fails just return NT_STATUS_NO_MEMORY, don't go to "done" label and deref pointers. Jeremy. (This used to be commit 490c7c84674860ecd9daa24341edb427b9fe0aa5) --- source3/rpc_server/srv_lsa_nt.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index ae9795952c..efa7156eea 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1135,7 +1135,7 @@ NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOO if ((ref == NULL) || (rids == NULL) || (rids2 == NULL)) { r_u->status = NT_STATUS_NO_MEMORY; - goto done; + return NT_STATUS_NO_MEMORY; } if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { @@ -1149,10 +1149,6 @@ NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOO goto done; } - if (!ref || !rids || !rids2) { - return NT_STATUS_NO_MEMORY; - } - /* set up the LSA Lookup RIDs response */ become_root(); /* lookup_name can require root privs */ r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries, -- cgit From 429cd6db0b32ee0e91a12548d83e82a7f7b6571c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Jun 2006 00:42:24 +0000 Subject: r16542: Fix #3863, reported by jason@ncac.gwu.edu Jeremy. (This used to be commit cde8323fdc4d4ddaa30e8c59bec89dc130fe26a6) --- source3/rpc_server/srv_eventlog_lib.c | 6 ++++++ source3/rpc_server/srv_eventlog_nt.c | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index e04aefa7e1..66be1dc34f 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -201,6 +201,12 @@ BOOL make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, len = tdb_unpack( ret.dptr, ret.dsize, "ddddd", &reclen, &tresv1, &trecnum, &timegen, &timewr ); + if (len == -1) { + DEBUG( 10,("make_way_for_eventlogs: tdb_unpack failed.\n")); + tdb_unlock_bystring( the_tdb, EVT_NEXT_RECORD ); + return False; + } + DEBUG( 8, ( "read record %d, record size is [%d], total so far [%d]\n", i, reclen, nbytes ) ); diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index c1c0b6a0e2..79839a0a52 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -289,12 +289,10 @@ Eventlog_entry *get_eventlog_record( prs_struct * ps, TDB_CONTEXT * tdb, int srecno; int reclen; int len; - uint8 *rbuff; pstring *wpsource, *wpcomputer, *wpsid, *wpstrs, *puserdata; key.dsize = sizeof( int32 ); - rbuff = NULL; srecno = recno; key.dptr = ( char * ) &srecno; -- cgit From 24814867c3470ef63c3cae28ad7c6644029b65d2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Jun 2006 00:49:14 +0000 Subject: r16544: Fix bug #3864 reported by jason@ncac.gwu.edu. Jeremy. (This used to be commit 16e42b446bea171c3ad848aefaa92c7404aade42) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index bfae47ef25..da2bb8c3b5 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1956,7 +1956,7 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, TALLOC_FREE(sampass); - return NT_STATUS_OK; + return nt_status; } /******************************************************************* -- cgit From d1014c1cdfce116741ddd6eccd65b69530ce0b84 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Jun 2006 00:50:14 +0000 Subject: r16582: Fix Klocwork #1997 and all generic class of problems where we don't correctly check the return from memdup. Jeremy. (This used to be commit ce14daf51c7ee2f9c68c77f7f4674e6f0e35c9ca) --- source3/rpc_server/srv_pipe.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 72298520e3..1c91735756 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -679,7 +679,8 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) if (p->pipe_user.ut.ngroups) { if (!(p->pipe_user.ut.groups = memdup(a->server_info->groups, sizeof(gid_t) * p->pipe_user.ut.ngroups))) { - DEBUG(0,("failed to memdup group list to p->pipe_user.groups\n")); + DEBUG(0,("pipe_ntlmssp_verify_final: failed to memdup group list to p->pipe_user.groups\n")); + data_blob_free(&p->session_key); return False; } } @@ -687,9 +688,17 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) if (a->server_info->ptok) { p->pipe_user.nt_user_token = dup_nt_token(NULL, a->server_info->ptok); + if (!p->pipe_user.nt_user_token) { + DEBUG(1,("pipe_ntlmssp_verify_final: dup_nt_token failed.\n")); + data_blob_free(&p->session_key); + SAFE_FREE(p->pipe_user.ut.groups); + return False; + } + } else { - DEBUG(1,("Error: Authmodule failed to provide nt_user_token\n")); - p->pipe_user.nt_user_token = NULL; + DEBUG(1,("pipe_ntlmssp_verify_final: Error: Authmodule failed to provide nt_user_token\n")); + data_blob_free(&p->session_key); + SAFE_FREE(p->pipe_user.ut.groups); return False; } -- cgit From 45bc56c27b16e7d50f3f6e6ba8d6eb2e4a5abb52 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Jun 2006 21:33:52 +0000 Subject: r16646: Fix bug #3888 reported by Jason Mader . Jeremy. (This used to be commit 433d7a1bc91ff479934a256ff84e6866e16d1f85) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index da2bb8c3b5..2786a740ff 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1618,7 +1618,7 @@ static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP_RIDS *r_u) { const char **names; - uint32 *attrs = NULL; + enum SID_NAME_USE *attrs = NULL; UNIHDR *hdr_name = NULL; UNISTR2 *uni_name = NULL; DOM_SID pol_sid; -- cgit From b85c276e95208f16d089402e7c43c8ff3fe39b3f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Jun 2006 17:03:19 +0000 Subject: r16678: Fix bug #3898 reported by jason@ncac.gwu.edu. Jeremy. (This used to be commit 5c5ea3152f8dbdfd7717b65e035191ffed3ec548) --- source3/rpc_server/srv_samr_nt.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2786a740ff..e045de5639 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1619,12 +1619,14 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK { const char **names; enum SID_NAME_USE *attrs = NULL; + uint32 *wire_attrs = NULL; UNIHDR *hdr_name = NULL; UNISTR2 *uni_name = NULL; DOM_SID pol_sid; int num_rids = q_u->num_rids1; uint32 acc_granted; - + int i; + r_u->status = NT_STATUS_OK; DEBUG(5,("_samr_lookup_rids: %d\n", __LINE__)); @@ -1640,9 +1642,10 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK } names = TALLOC_ZERO_ARRAY(p->mem_ctx, const char *, num_rids); - attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_rids); + attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, enum SID_NAME_USE, num_rids); + wire_attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_rids); - if ((num_rids != 0) && ((names == NULL) || (attrs == NULL))) + if ((num_rids != 0) && ((names == NULL) || (attrs == NULL) || wire_attrs)) return NT_STATUS_NO_MEMORY; become_root(); /* lookup_sid can require root privs */ @@ -1658,7 +1661,12 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK &hdr_name, &uni_name)) return NT_STATUS_NO_MEMORY; - init_samr_r_lookup_rids(r_u, num_rids, hdr_name, uni_name, attrs); + /* Convert from enum SID_NAME_USE to uint32 for wire format. */ + for (i = 0; i < num_rids; i++) { + wire_attrs[i] = (uint32)attrs[i]; + } + + init_samr_r_lookup_rids(r_u, num_rids, hdr_name, uni_name, wire_attrs); DEBUG(5,("_samr_lookup_rids: %d\n", __LINE__)); -- cgit From 26c0b81d757d711646239fc55ed326fa3b0180cc Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 3 Jul 2006 16:12:16 +0000 Subject: r16785: BUG 3908: Fix rpc bin authentication failure which broke user password changes Jeremy, please review. (This used to be commit 154e4a281503f0cbc2e654640f1dfa4b4d35a3cd) --- source3/rpc_server/srv_pipe.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 1c91735756..812a720d90 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -620,7 +620,10 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) p->pipe_user.ut.ngroups = 0; SAFE_FREE( p->pipe_user.ut.groups); + /* this has to be done as root in order to verify the password */ + become_root(); status = auth_ntlmssp_update(a, *p_resp_blob, &reply); + unbecome_root(); /* Don't generate a reply. */ data_blob_free(&reply); -- cgit From d1a9ac533be5d1c5b81371bd3181c4fd89e13d7d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Jul 2006 15:29:21 +0000 Subject: r16799: Fix remote smbd crash bug by removing half-implemented info level 4 dfs_Enum. Guenther (This used to be commit 4e5ea585c3482c38f2624e45f1268d3864a99faa) --- source3/rpc_server/srv_dfs_nt.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index f04d8c37c3..8239584522 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -304,14 +304,6 @@ WERROR _dfs_Enum(pipes_struct *p, NETDFS_Q_DFS_ENUM *q_u, NETDFS_R_DFS_ENUM *r_u r_u->info.e.u.info3.ptr0_s = 1; r_u->info.e.u.info3.size_s = num_jn; break; - case 4: - if ((r_u->info.e.u.info4.s = TALLOC_ARRAY(p->mem_ctx, NETDFS_DFS_INFO4, num_jn)) == NULL) { - return WERR_NOMEM; - } - r_u->info.e.u.info4.count = num_jn; - r_u->info.e.u.info4.ptr0_s = 1; - r_u->info.e.u.info4.size_s = num_jn; - break; default: return WERR_INVALID_PARAM; } -- cgit From fbdcf2663b56007a438ac4f0d8d82436b1bfe688 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Jul 2006 18:01:26 +0000 Subject: r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8) --- source3/rpc_server/srv_dfs_nt.c | 10 +- source3/rpc_server/srv_lsa_nt.c | 31 +-- source3/rpc_server/srv_pipe.c | 105 +++---- source3/rpc_server/srv_pipe_hnd.c | 9 +- source3/rpc_server/srv_samr_nt.c | 17 +- source3/rpc_server/srv_samr_util.c | 35 ++- source3/rpc_server/srv_spoolss_nt.c | 98 +++---- source3/rpc_server/srv_srvsvc.c | 33 ++- source3/rpc_server/srv_srvsvc_nt.c | 520 +++++++++++++++++++++++------------ source3/rpc_server/srv_svcctl_nt.c | 2 +- source3/rpc_server/srv_unixinfo.c | 163 +++++++++++ source3/rpc_server/srv_unixinfo_nt.c | 166 +++++++++++ 12 files changed, 856 insertions(+), 333 deletions(-) create mode 100644 source3/rpc_server/srv_unixinfo.c create mode 100644 source3/rpc_server/srv_unixinfo_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 8239584522..c7f8e05d91 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -40,7 +40,6 @@ uint32 _dfs_GetManagerVersion(pipes_struct *p, NETDFS_Q_DFS_GETMANAGERVERSION *q WERROR _dfs_Add(pipes_struct *p, NETDFS_Q_DFS_ADD* q_u, NETDFS_R_DFS_ADD *r_u) { - struct current_user user; struct junction_map jn; struct referral* old_referral_list = NULL; BOOL exists = False; @@ -48,9 +47,7 @@ WERROR _dfs_Add(pipes_struct *p, NETDFS_Q_DFS_ADD* q_u, NETDFS_R_DFS_ADD *r_u) pstring dfspath, servername, sharename; pstring altpath; - get_current_user(&user,p); - - if (user.ut.uid != 0) { + if (p->pipe_user.ut.uid != 0) { DEBUG(10,("_dfs_add: uid != 0. Access denied.\n")); return WERR_ACCESS_DENIED; } @@ -104,16 +101,13 @@ WERROR _dfs_Add(pipes_struct *p, NETDFS_Q_DFS_ADD* q_u, NETDFS_R_DFS_ADD *r_u) WERROR _dfs_Remove(pipes_struct *p, NETDFS_Q_DFS_REMOVE *q_u, NETDFS_R_DFS_REMOVE *r_u) { - struct current_user user; struct junction_map jn; BOOL found = False; pstring dfspath, servername, sharename; pstring altpath; - get_current_user(&user,p); - - if (user.ut.uid != 0) { + if (p->pipe_user.ut.uid != 0) { DEBUG(10,("_dfs_remove: uid != 0. Access denied.\n")); return WERR_ACCESS_DENIED; } diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index efa7156eea..2cc5ef6110 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1557,17 +1557,23 @@ NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CR * I don't know if it's the right one. not documented. * but guessed with rpcclient. */ - if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) + if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) { + DEBUG(10, ("_lsa_create_account: No POLICY_GET_PRIVATE_INFORMATION access right!\n")); return NT_STATUS_ACCESS_DENIED; + } /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { + DEBUG(10, ("_lsa_create_account: The use is not a Domain Admin, deny access!\n")); return NT_STATUS_ACCESS_DENIED; + } - if ( is_privileged_sid( &q_u->sid.sid ) ) + if ( is_privileged_sid( &q_u->sid.sid ) ) { + DEBUG(10, ("_lsa_create_account: Policy account already exists!\n")); return NT_STATUS_OBJECT_NAME_COLLISION; + } /* associate the user/group SID with the (unique) handle. */ @@ -1582,6 +1588,7 @@ NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CR if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; + DEBUG(10, ("_lsa_create_account: call privileges code to create an account\n")); return privilege_create_account( &info->sid ); } @@ -1676,7 +1683,7 @@ NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA return NT_STATUS_INVALID_HANDLE; if (!lookup_sid(p->mem_ctx, &info->sid, NULL, NULL, NULL)) - return NT_STATUS_ACCESS_DENIED; + return NT_STATUS_OK; /* 0x01 -> Log on locally @@ -1727,7 +1734,6 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u struct lsa_info *info = NULL; SE_PRIV mask; PRIVILEGE_SET *set = NULL; - struct current_user user; /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) @@ -1736,8 +1742,7 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u /* check to see if the pipe_user is root or a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - get_current_user( &user, p ); - if ( user.ut.uid != sec_initial_uid() + if ( p->pipe_user.ut.uid != sec_initial_uid() && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { return NT_STATUS_ACCESS_DENIED; @@ -1768,7 +1773,6 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP struct lsa_info *info = NULL; SE_PRIV mask; PRIVILEGE_SET *set = NULL; - struct current_user user; /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) @@ -1777,8 +1781,7 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP /* check to see if the pipe_user is root or a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - get_current_user( &user, p ); - if ( user.ut.uid != sec_initial_uid() + if ( p->pipe_user.ut.uid != sec_initial_uid() && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { return NT_STATUS_ACCESS_DENIED; @@ -1929,7 +1932,6 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R DOM_SID sid; fstring privname; UNISTR4_ARRAY *uni_privnames = q_u->rights; - struct current_user user; /* find the connection policy handle. */ @@ -1939,8 +1941,7 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - get_current_user( &user, p ); - if ( user.ut.uid != sec_initial_uid() + if ( p->pipe_user.ut.uid != sec_initial_uid() && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { return NT_STATUS_ACCESS_DENIED; @@ -1987,7 +1988,6 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, DOM_SID sid; fstring privname; UNISTR4_ARRAY *uni_privnames = q_u->rights; - struct current_user user; /* find the connection policy handle. */ @@ -1997,8 +1997,7 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - get_current_user( &user, p ); - if ( user.ut.uid != sec_initial_uid() + if ( p->pipe_user.ut.uid != sec_initial_uid() && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { return NT_STATUS_ACCESS_DENIED; diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 812a720d90..e2c5e865ed 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -46,6 +46,11 @@ static void free_pipe_ntlmssp_auth_data(struct pipe_auth_data *auth) auth->a_u.auth_ntlmssp_state = NULL; } +static DATA_BLOB generic_session_key(void) +{ + return data_blob("SystemLibraryDTC", 16); +} + /******************************************************************* Generate the next PDU to be returned from the data in p->rdata. Handle NTLMSSP. @@ -610,16 +615,6 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) ZERO_STRUCT(reply); - memset(p->user_name, '\0', sizeof(p->user_name)); - memset(p->pipe_user_name, '\0', sizeof(p->pipe_user_name)); - memset(p->domain, '\0', sizeof(p->domain)); - memset(p->wks, '\0', sizeof(p->wks)); - - /* Set up for non-authenticated user. */ - TALLOC_FREE(p->pipe_user.nt_user_token); - p->pipe_user.ut.ngroups = 0; - SAFE_FREE( p->pipe_user.ut.groups); - /* this has to be done as root in order to verify the password */ become_root(); status = auth_ntlmssp_update(a, *p_resp_blob, &reply); @@ -632,6 +627,12 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) return False; } + if (a->server_info->ptok == NULL) { + DEBUG(1,("Error: Authmodule failed to provide nt_user_token\n")); + p->pipe_user.nt_user_token = NULL; + return False; + } + /* Finally - if the pipe negotiated integrity (sign) or privacy (seal) ensure the underlying NTLMSSP flags are also set. If not we should refuse the bind. */ @@ -653,13 +654,9 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) } } - fstrcpy(p->user_name, a->ntlmssp_state->user); - fstrcpy(p->pipe_user_name, a->server_info->unix_name); - fstrcpy(p->domain, a->ntlmssp_state->domain); - fstrcpy(p->wks, a->ntlmssp_state->workstation); - DEBUG(5,("pipe_ntlmssp_verify_final: OK: user: %s domain: %s workstation: %s\n", - p->user_name, p->domain, p->wks)); + a->ntlmssp_state->user, a->ntlmssp_state->domain, + a->ntlmssp_state->workstation)); /* * Store the UNIX credential data (uid/gid pair) in the pipe structure. @@ -669,11 +666,13 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) p->pipe_user.ut.gid = a->server_info->gid; /* - * Copy the session key from the ntlmssp state. + * We're an authenticated bind over smb, so the session key needs to + * be set to "SystemLibraryDTC". Weird, but this is what Windows + * does. See the RPC-SAMBA3SESSIONKEY. */ data_blob_free(&p->session_key); - p->session_key = data_blob(a->ntlmssp_state->session_key.data, a->ntlmssp_state->session_key.length); + p->session_key = generic_session_key(); if (!p->session_key.data) { return False; } @@ -688,23 +687,21 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) } } - if (a->server_info->ptok) { - p->pipe_user.nt_user_token = - dup_nt_token(NULL, a->server_info->ptok); - if (!p->pipe_user.nt_user_token) { - DEBUG(1,("pipe_ntlmssp_verify_final: dup_nt_token failed.\n")); - data_blob_free(&p->session_key); - SAFE_FREE(p->pipe_user.ut.groups); - return False; - } - - } else { + if (!a->server_info->ptok) { DEBUG(1,("pipe_ntlmssp_verify_final: Error: Authmodule failed to provide nt_user_token\n")); data_blob_free(&p->session_key); SAFE_FREE(p->pipe_user.ut.groups); return False; } + p->pipe_user.nt_user_token = dup_nt_token(NULL, a->server_info->ptok); + if (!p->pipe_user.nt_user_token) { + DEBUG(1,("pipe_ntlmssp_verify_final: dup_nt_token failed.\n")); + data_blob_free(&p->session_key); + SAFE_FREE(p->pipe_user.ut.groups); + return False; + } + return True; } @@ -1361,8 +1358,21 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, * JRA. Should we also copy the schannel session key into the pipe session key p->session_key * here ? We do that for NTLMSSP, but the session key is already set up from the vuser * struct of the person who opened the pipe. I need to test this further. JRA. + * + * VL. As we are mapping this to guest set the generic key + * "SystemLibraryDTC" key here. It's a bit difficult to test against + * W2k3, as it does not allow schannel binds against SAMR and LSA + * anymore. */ + data_blob_free(&p->session_key); + p->session_key = generic_session_key(); + if (p->session_key.data == NULL) { + DEBUG(0, ("pipe_schannel_auth_bind: Could not alloc session" + " key\n")); + return False; + } + init_rpc_hdr_auth(&auth_info, RPC_SCHANNEL_AUTH_TYPE, pauth_info->auth_level, RPC_HDR_AUTH_LEN, 1); if(!smb_io_rpc_hdr_auth("", &auth_info, pout_auth, 0)) { DEBUG(0,("pipe_schannel_auth_bind: marshalling of RPC_HDR_AUTH failed.\n")); @@ -1391,6 +1401,12 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, p->auth.auth_data_free_func = NULL; p->auth.auth_type = PIPE_AUTH_TYPE_SCHANNEL; + if (!set_current_user_guest(&p->pipe_user)) { + DEBUG(1, ("pipe_schannel_auth_bind: Could not set guest " + "token\n")); + return False; + } + p->pipe_bound = True; return True; @@ -1641,11 +1657,18 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) case RPC_ANONYMOUS_AUTH_TYPE: /* Unauthenticated bind request. */ + /* Get the authenticated pipe user from current_user */ + if (!copy_current_user(&p->pipe_user, ¤t_user)) { + DEBUG(10, ("Could not copy current user\n")); + goto err_exit; + } /* We're finished - no more packets. */ p->auth.auth_type = PIPE_AUTH_TYPE_NONE; /* We must set the pipe auth_level here also. */ p->auth.auth_level = PIPE_AUTH_LEVEL_NONE; p->pipe_bound = True; + /* The session key was initialized from the SMB + * session in make_internal_rpc_pipe_p */ break; default: @@ -2148,23 +2171,6 @@ BOOL api_pipe_schannel_process(pipes_struct *p, prs_struct *rpc_in, uint32 *p_ss return True; } -/**************************************************************************** - Return a user struct for a pipe user. -****************************************************************************/ - -struct current_user *get_current_user(struct current_user *user, pipes_struct *p) -{ - if (p->pipe_bound && - (p->auth.auth_type == PIPE_AUTH_TYPE_NTLMSSP || - (p->auth.auth_type == PIPE_AUTH_TYPE_SPNEGO_NTLMSSP))) { - memcpy(user, &p->pipe_user, sizeof(struct current_user)); - } else { - memcpy(user, ¤t_user, sizeof(struct current_user)); - } - - return user; -} - /**************************************************************************** Find the set of RPC functions associated with this context_id ****************************************************************************/ @@ -2219,9 +2225,7 @@ BOOL api_pipe_request(pipes_struct *p) BOOL changed_user = False; PIPE_RPC_FNS *pipe_fns; - if (p->pipe_bound && - ((p->auth.auth_type == PIPE_AUTH_TYPE_NTLMSSP) || - (p->auth.auth_type == PIPE_AUTH_TYPE_SPNEGO_NTLMSSP))) { + if (p->pipe_bound) { if(!become_authenticated_pipe_user(p)) { prs_mem_free(&p->out_data.rdata); return False; @@ -2373,6 +2377,9 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) case PI_EVENTLOG: eventlog_get_pipe_fns( &cmds, &n_cmds ); break; + case PI_UNIXINFO: + unixinfo_get_pipe_fns( &cmds, &n_cmds ); + break; case PI_NTSVCS: ntsvcs_get_pipe_fns( &cmds, &n_cmds ); break; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 9cc8b72546..8aa5bb3e6d 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -351,8 +351,6 @@ static void *make_internal_rpc_pipe_p(char *pipe_name, /* Store the session key and NT_TOKEN */ if (vuser) { p->session_key = data_blob(vuser->session_key.data, vuser->session_key.length); - p->pipe_user.nt_user_token = dup_nt_token( - NULL, vuser->nt_user_token); } /* @@ -1169,6 +1167,13 @@ BOOL close_rpc_pipe_hnd(smb_np_struct *p) p->name, p->pnum, pipes_open)); DLIST_REMOVE(Pipes, p); + + /* TODO: Remove from pipe open db */ + + if ( !delete_pipe_opendb( p ) ) { + DEBUG(3,("close_rpc_pipe_hnd: failed to delete %s " + "pipe from open db.\n", p->name)); + } ZERO_STRUCTP(p); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e045de5639..2e0b355db5 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1435,7 +1435,7 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO } } - init_samr_r_lookup_names(p->mem_ctx, r_u, num_rids, rid, (uint32 *)type, r_u->status); + init_samr_r_lookup_names(p->mem_ctx, r_u, num_rids, rid, type, r_u->status); DEBUG(5,("_samr_lookup_names: %d\n", __LINE__)); @@ -2508,7 +2508,8 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, } DEBUG(5, ("_samr_create_user: %s can add this account : %s\n", - p->pipe_user_name, can_add_account ? "True":"False" )); + uidtoname(p->pipe_user.ut.uid), + can_add_account ? "True":"False" )); /********** BEGIN Admin BLOCK **********/ @@ -3110,9 +3111,11 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, } /* we need to separately check for an account rename first */ + if (rpcstr_pull(new_name, id21->uni_user_name.buffer, - sizeof(new_name), id21->uni_user_name.uni_str_len*2, 0) && - (!strequal(new_name, pdb_get_username(pwd)))) { + sizeof(new_name), id21->uni_user_name.uni_str_len*2, 0) + && (!strequal(new_name, pdb_get_username(pwd)))) + { /* check to see if the new username already exists. Note: we can't reliably lock all backends, so there is potentially the @@ -3435,7 +3438,8 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE } DEBUG(5, ("_samr_set_userinfo: %s does%s possess sufficient rights\n", - p->pipe_user_name, has_enough_rights ? "" : " not")); + uidtoname(p->pipe_user.ut.uid), + has_enough_rights ? "" : " not")); /* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */ @@ -3593,7 +3597,8 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ } DEBUG(5, ("_samr_set_userinfo2: %s does%s possess sufficient rights\n", - p->pipe_user_name, has_enough_rights ? "" : " not")); + uidtoname(p->pipe_user.ut.uid), + has_enough_rights ? "" : " not")); /* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */ diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 2b65eb210f..c4bec79c9c 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -195,14 +195,13 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) pdb_set_workstations(to , new_string, PDB_CHANGED); } - /* is this right? */ - if ((from->fields_present & ACCT_ADMIN_DESC) && - (from->hdr_unknown_str.buffer)) { - old_string = pdb_get_unknown_str(to); - new_string = unistr2_static(&from->uni_unknown_str); - DEBUG(10,("INFO_21 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); + if ((from->fields_present & ACCT_COMMENT) && + (from->hdr_comment.buffer)) { + old_string = pdb_get_comment(to); + new_string = unistr2_static(&from->uni_comment); + DEBUG(10,("INFO_21 UNI_COMMENT: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_unknown_str(to , new_string, PDB_CHANGED); + pdb_set_comment(to, new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_CALLBACK) && @@ -445,14 +444,13 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) pdb_set_workstations(to , new_string, PDB_CHANGED); } - /* is this right? */ - if ((from->fields_present & ACCT_ADMIN_DESC) && - (from->hdr_unknown_str.buffer)) { - old_string = pdb_get_unknown_str(to); - new_string = unistr2_static(&from->uni_unknown_str); + if ((from->fields_present & ACCT_COMMENT) && + (from->hdr_comment.buffer)) { + old_string = pdb_get_comment(to); + new_string = unistr2_static(&from->uni_comment); DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_unknown_str(to , new_string, PDB_CHANGED); + pdb_set_comment(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_CALLBACK) && @@ -683,14 +681,13 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) pdb_set_workstations(to , new_string, PDB_CHANGED); } - /* is this right? */ - if ((from->fields_present & ACCT_ADMIN_DESC) && - (from->hdr_unknown_str.buffer)) { - old_string = pdb_get_unknown_str(to); - new_string = unistr2_static(&from->uni_unknown_str); + if ((from->fields_present & ACCT_COMMENT) && + (from->hdr_comment.buffer)) { + old_string = pdb_get_comment(to); + new_string = unistr2_static(&from->uni_comment); DEBUG(10,("INFO_25 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) - pdb_set_unknown_str(to , new_string, PDB_CHANGED); + pdb_set_comment(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_CALLBACK) && diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0281e3da0c..3dbad208cc 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -331,7 +331,7 @@ WERROR delete_printer_hook( NT_USER_TOKEN *token, const char *sharename ) /* go ahead and re-read the services immediately */ reload_services( False ); - if ( lp_servicenumber( sharename ) < 0 ) + if ( !share_defined( sharename ) ) return WERR_ACCESS_DENIED; return WERR_OK; @@ -1509,7 +1509,6 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, fstring name; int snum; - struct current_user user; Printer_entry *Printer=NULL; if ( !q_u->printername ) @@ -1533,8 +1532,6 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, return WERR_INVALID_PRINTER_NAME; } - get_current_user(&user, p); - /* * First case: the user is opening the print server: * @@ -1599,12 +1596,12 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege, and not a printer admin, then fail */ - if ((user.ut.uid != 0) && - !user_has_privileges(user.nt_user_token, + if ((p->pipe_user.ut.uid != 0) && + !user_has_privileges(p->pipe_user.nt_user_token, &se_printop ) && !token_contains_name_in_list( - uidtoname(user.ut.uid), NULL, - user.nt_user_token, + uidtoname(p->pipe_user.ut.uid), NULL, + p->pipe_user.nt_user_token, lp_printer_admin(snum))) { close_printer_handle(p, handle); return WERR_ACCESS_DENIED; @@ -1657,9 +1654,9 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, return WERR_ACCESS_DENIED; } - if (!user_ok_token(uidtoname(user.ut.uid), user.nt_user_token, - snum) || - !print_access_check(&user, snum, + if (!user_ok_token(uidtoname(p->pipe_user.ut.uid), + p->pipe_user.nt_user_token, snum) || + !print_access_check(&p->pipe_user, snum, printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); close_printer_handle(p, handle); @@ -1953,20 +1950,17 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER NT_PRINTER_DRIVER_INFO_LEVEL info; NT_PRINTER_DRIVER_INFO_LEVEL info_win2k; int version; - struct current_user user; WERROR status; WERROR status_win2k = WERR_ACCESS_DENIED; SE_PRIV se_printop = SE_PRINT_OPERATOR; - get_current_user(&user, p); - /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege, and not a printer admin, then fail */ - if ( (user.ut.uid != 0) - && !user_has_privileges(user.nt_user_token, &se_printop ) - && !token_contains_name_in_list( uidtoname(user.ut.uid), - NULL, user.nt_user_token, lp_printer_admin(-1)) ) + if ( (p->pipe_user.ut.uid != 0) + && !user_has_privileges(p->pipe_user.nt_user_token, &se_printop ) + && !token_contains_name_in_list( uidtoname(p->pipe_user.ut.uid), + NULL, p->pipe_user.nt_user_token, lp_printer_admin(-1)) ) { return WERR_ACCESS_DENIED; } @@ -2013,7 +2007,7 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER /* if we get to here, we now have 2 driver info structures to remove */ /* remove the Win2k driver first*/ - status_win2k = delete_printer_driver(info_win2k.info_3, &user, 3, False ); + status_win2k = delete_printer_driver(info_win2k.info_3, &p->pipe_user, 3, False ); free_a_printer_driver( info_win2k, 3 ); /* this should not have failed---if it did, report to client */ @@ -2025,7 +2019,7 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER } } - status = delete_printer_driver(info.info_3, &user, version, False); + status = delete_printer_driver(info.info_3, &p->pipe_user, version, False); /* if at least one of the deletes succeeded return OK */ @@ -2051,20 +2045,17 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV int version; uint32 flags = q_u->delete_flags; BOOL delete_files; - struct current_user user; WERROR status; WERROR status_win2k = WERR_ACCESS_DENIED; SE_PRIV se_printop = SE_PRINT_OPERATOR; - get_current_user(&user, p); - /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege, and not a printer admin, then fail */ - if ( (user.ut.uid != 0) - && !user_has_privileges(user.nt_user_token, &se_printop ) - && !token_contains_name_in_list( uidtoname(user.ut.uid), - NULL, user.nt_user_token, lp_printer_admin(-1)) ) + if ( (p->pipe_user.ut.uid != 0) + && !user_has_privileges(p->pipe_user.nt_user_token, &se_printop ) + && !token_contains_name_in_list( uidtoname(p->pipe_user.ut.uid), + NULL, p->pipe_user.nt_user_token, lp_printer_admin(-1)) ) { return WERR_ACCESS_DENIED; } @@ -2150,7 +2141,7 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV /* if we get to here, we now have 2 driver info structures to remove */ /* remove the Win2k driver first*/ - status_win2k = delete_printer_driver(info_win2k.info_3, &user, 3, delete_files); + status_win2k = delete_printer_driver(info_win2k.info_3, &p->pipe_user, 3, delete_files); free_a_printer_driver( info_win2k, 3 ); /* this should not have failed---if it did, report to client */ @@ -2160,7 +2151,7 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV } } - status = delete_printer_driver(info.info_3, &user, version, delete_files); + status = delete_printer_driver(info.info_3, &p->pipe_user, version, delete_files); if ( W_ERROR_IS_OK(status) || W_ERROR_IS_OK(status_win2k) ) status = WERR_OK; @@ -4073,7 +4064,7 @@ static BOOL convert_nt_devicemode( DEVICEMODE *devmode, NT_DEVICEMODE *ntdevmode Create a DEVMODE struct. Returns malloced memory. ****************************************************************************/ -DEVICEMODE *construct_dev_mode(int snum) +DEVICEMODE *construct_dev_mode(const char *servicename) { NT_PRINTER_INFO_LEVEL *printer = NULL; DEVICEMODE *devmode = NULL; @@ -4082,7 +4073,7 @@ DEVICEMODE *construct_dev_mode(int snum) DEBUGADD(8,("getting printer characteristics\n")); - if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, servicename))) return NULL; if ( !printer->info_2->devmode ) { @@ -4154,7 +4145,7 @@ static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *p printer->cjobs = count; /* jobs */ printer->averageppm = ntprinter->info_2->averageppm; /* average pages per minute */ - if ( !(printer->devmode = construct_dev_mode(snum)) ) + if ( !(printer->devmode = construct_dev_mode(lp_const_servicename(snum))) ) DEBUG(8, ("Returning NULL Devicemode!\n")); printer->secdesc = NULL; @@ -5640,15 +5631,12 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S pstring jobname; fstring datatype; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - struct current_user user; if (!Printer) { DEBUG(2,("_spoolss_startdocprinter: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle))); return WERR_BADFID; } - get_current_user(&user, p); - /* * a nice thing with NT is it doesn't listen to what you tell it. * when asked to send _only_ RAW datas, it tries to send datas @@ -5672,7 +5660,7 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S unistr2_to_ascii(jobname, &info_1->docname, sizeof(jobname)); - Printer->jobid = print_job_start(&user, snum, jobname, Printer->nt_devmode); + Printer->jobid = print_job_start(&p->pipe_user, snum, jobname, Printer->nt_devmode); /* An error occured in print_job_start() so return an appropriate NT error code. */ @@ -5745,13 +5733,10 @@ WERROR _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R static WERROR control_printer(POLICY_HND *handle, uint32 command, pipes_struct *p) { - struct current_user user; int snum; WERROR errcode = WERR_BADFUNC; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - get_current_user(&user, p); - if (!Printer) { DEBUG(2,("control_printer: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle))); return WERR_BADFID; @@ -5762,18 +5747,18 @@ static WERROR control_printer(POLICY_HND *handle, uint32 command, switch (command) { case PRINTER_CONTROL_PAUSE: - if (print_queue_pause(&user, snum, &errcode)) { + if (print_queue_pause(&p->pipe_user, snum, &errcode)) { errcode = WERR_OK; } break; case PRINTER_CONTROL_RESUME: case PRINTER_CONTROL_UNPAUSE: - if (print_queue_resume(&user, snum, &errcode)) { + if (print_queue_resume(&p->pipe_user, snum, &errcode)) { errcode = WERR_OK; } break; case PRINTER_CONTROL_PURGE: - if (print_queue_purge(&user, snum, &errcode)) { + if (print_queue_purge(&p->pipe_user, snum, &errcode)) { errcode = WERR_OK; } break; @@ -5795,7 +5780,6 @@ WERROR _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R POLICY_HND *handle = &q_u->handle; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); int snum; - struct current_user user; WERROR errcode = WERR_OK; if (!Printer) { @@ -5806,9 +5790,7 @@ WERROR _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; - get_current_user( &user, p ); - - print_job_delete( &user, snum, Printer->jobid, &errcode ); + print_job_delete( &p->pipe_user, snum, Printer->jobid, &errcode ); return errcode; } @@ -6018,7 +6000,9 @@ BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) SE_PRIV se_printop = SE_PRINT_OPERATOR; BOOL is_print_op = False; - standard_sub_basic(current_user_info.smb_name, remote_machine,sizeof(remote_machine)); + standard_sub_basic(current_user_info.smb_name, + current_user_info.domain, + remote_machine,sizeof(remote_machine)); slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", cmd, printer->info_2->printername, printer->info_2->sharename, @@ -6544,7 +6528,7 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, /* this should not be a failure condition if the devmode is NULL */ - devmode = construct_dev_mode(snum); + devmode = construct_dev_mode(lp_const_servicename(snum)); for (i=0; i<*returned; i++) fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter, devmode); @@ -6664,7 +6648,6 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u uint32 jobid = q_u->jobid; uint32 command = q_u->command; - struct current_user user; int snum; WERROR errcode = WERR_BADFUNC; @@ -6676,23 +6659,21 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u return WERR_INVALID_PRINTER_NAME; } - get_current_user(&user, p); - switch (command) { case JOB_CONTROL_CANCEL: case JOB_CONTROL_DELETE: - if (print_job_delete(&user, snum, jobid, &errcode)) { + if (print_job_delete(&p->pipe_user, snum, jobid, &errcode)) { errcode = WERR_OK; } break; case JOB_CONTROL_PAUSE: - if (print_job_pause(&user, snum, jobid, &errcode)) { + if (print_job_pause(&p->pipe_user, snum, jobid, &errcode)) { errcode = WERR_OK; } break; case JOB_CONTROL_RESTART: case JOB_CONTROL_RESUME: - if (print_job_resume(&user, snum, jobid, &errcode)) { + if (print_job_resume(&p->pipe_user, snum, jobid, &errcode)) { errcode = WERR_OK; } break; @@ -7618,26 +7599,23 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, SPOOL_PRINTER_DRIVER_INFO_LEVEL *info = &q_u->info; WERROR err = WERR_OK; NT_PRINTER_DRIVER_INFO_LEVEL driver; - struct current_user user; fstring driver_name; uint32 version; ZERO_STRUCT(driver); - get_current_user(&user, p); - if (!convert_printer_driver_info(info, &driver, level)) { err = WERR_NOMEM; goto done; } DEBUG(5,("Cleaning driver's information\n")); - err = clean_up_driver_struct(driver, level, &user); + err = clean_up_driver_struct(driver, level, &p->pipe_user); if (!W_ERROR_IS_OK(err)) goto done; DEBUG(5,("Moving driver to final destination\n")); - if( !W_ERROR_IS_OK(err = move_driver_to_download_area(driver, level, &user, &err)) ) { + if( !W_ERROR_IS_OK(err = move_driver_to_download_area(driver, level, &p->pipe_user, &err)) ) { goto done; } @@ -8777,7 +8755,7 @@ static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, */ if ( !(nt_devmode=print_job_devmode( lp_const_servicename(snum), jobid )) ) - devmode = construct_dev_mode(snum); + devmode = construct_dev_mode(lp_const_servicename(snum)); else { if ((devmode = SMB_MALLOC_P(DEVICEMODE)) != NULL) { ZERO_STRUCTP( devmode ); diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 0b4eac5cc7..e4f85d0bdb 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -6,6 +6,7 @@ * Copyright (C) Paul Ashton 1997, * Copyright (C) Jeremy Allison 2001, * Copyright (C) Jim McDonough 2003. + * Copyright (C) Gera;d (Jerry) Carter 2006. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -550,6 +551,35 @@ static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) return True; } +/******************************************************************* +*******************************************************************/ + +static BOOL api_srv_net_file_close(pipes_struct *p) +{ + SRV_Q_NET_FILE_CLOSE q_u; + SRV_R_NET_FILE_CLOSE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net file set info from Win9x */ + if(!srv_io_q_net_file_close("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_file_close: Failed to unmarshall SRV_Q_NET_FILE_SET_SECDESC.\n")); + return False; + } + + r_u.status = _srv_net_file_close(p, &q_u, &r_u); + + if(!srv_io_r_net_file_close("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_file_close: Failed to marshall SRV_R_NET_FILE_SET_SECDESC.\n")); + return False; + } + + return True; +} + /******************************************************************* \PIPE\srvsvc commands ********************************************************************/ @@ -573,7 +603,8 @@ static struct api_struct api_srv_cmds[] = { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate }, { "SRV_NET_FILE_QUERY_SECDESC", SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc }, - { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc } + { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc }, + { "SRV_NET_FILE_CLOSE" , SRV_NET_FILE_CLOSE , api_srv_net_file_close } }; void srvsvc_get_pipe_fns( struct api_struct **fns, int *n_fns ) diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index a936ef5870..12a86ce9f3 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -4,6 +4,7 @@ * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Jeremy Allison 2001. * Copyright (C) Nigel Williams 2001. + * Copyright (C) Gerald (Jerry) Carter 2006. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,10 +26,179 @@ #include "includes.h" extern struct generic_mapping file_generic_mapping; +extern userdom_struct current_user_info; #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +/* Use for enumerating connections, pipes, & files */ + +struct file_enum_count { + TALLOC_CTX *ctx; + int count; + FILE_INFO_3 *info; +}; + +struct sess_file_count { + pid_t pid; + uid_t uid; + int count; +}; + +/**************************************************************************** + Count the entries belonging to a service in the connection db. +****************************************************************************/ + +static int pipe_enum_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *p) +{ + struct pipe_open_rec prec; + struct file_enum_count *fenum = (struct file_enum_count *)p; + + if (dbuf.dsize != sizeof(struct pipe_open_rec)) + return 0; + + memcpy(&prec, dbuf.dptr, sizeof(struct pipe_open_rec)); + + if ( process_exists(prec.pid) ) { + FILE_INFO_3 *f; + int i = fenum->count; + pstring fullpath; + + snprintf( fullpath, sizeof(fullpath), "\\PIPE\\%s", prec.name ); + + f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 ); + if ( !f ) { + DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); + return 1; + } + fenum->info = f; + + + init_srv_file_info3( &fenum->info[i], + (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum), + (FILE_READ_DATA|FILE_WRITE_DATA), + 0, + uidtoname( prec.uid ), + fullpath ); + + fenum->count++; + } + + return 0; +} + +/******************************************************************* +********************************************************************/ + +static WERROR net_enum_pipes( TALLOC_CTX *ctx, FILE_INFO_3 **info, + uint32 *count, uint32 resume ) +{ + struct file_enum_count fenum; + TDB_CONTEXT *conn_tdb = conn_tdb_ctx(); + + if ( !conn_tdb ) { + DEBUG(0,("net_enum_pipes: Failed to retrieve the connections tdb handle!\n")); + return WERR_ACCESS_DENIED; + } + + fenum.ctx = ctx; + fenum.count = *count; + fenum.info = *info; + + if (tdb_traverse(conn_tdb, pipe_enum_fn, &fenum) == -1) { + DEBUG(0,("net_enum_pipes: traverse of connections.tdb failed with error %s.\n", + tdb_errorstr(conn_tdb) )); + return WERR_NOMEM; + } + + *info = fenum.info; + *count = fenum.count; + + return WERR_OK;} + +/******************************************************************* +********************************************************************/ + +/* global needed to make use of the share_mode_forall() callback */ +static struct file_enum_count f_enum_cnt; + +static void enum_file_fn( const struct share_mode_entry *e, + const char *sharepath, const char *fname ) +{ + struct file_enum_count *fenum = &f_enum_cnt; + + /* If the pid was not found delete the entry from connections.tdb */ + + if ( process_exists(e->pid) ) { + FILE_INFO_3 *f; + int i = fenum->count; + files_struct fsp; + struct byte_range_lock *brl; + int num_locks = 0; + pstring fullpath; + uint32 permissions; + + f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 ); + if ( !f ) { + DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); + return; + } + fenum->info = f; + + /* need to count the number of locks on a file */ + + ZERO_STRUCT( fsp ); + fsp.dev = e->dev; + fsp.inode = e->inode; + + if ( (brl = brl_get_locks(NULL,&fsp)) != NULL ) { + num_locks = brl->num_locks; + TALLOC_FREE( brl ); + } + + if ( strcmp( fname, "." ) == 0 ) { + pstr_sprintf( fullpath, "C:%s", sharepath ); + } else { + pstr_sprintf( fullpath, "C:%s/%s", sharepath, fname ); + } + string_replace( fullpath, '/', '\\' ); + + /* mask out create (what ever that is) */ + permissions = e->share_access & (FILE_READ_DATA|FILE_WRITE_DATA); + + /* now fill in the FILE_INFO_3 struct */ + init_srv_file_info3( &fenum->info[i], + e->share_file_id, + permissions, + num_locks, + uidtoname(e->uid), + fullpath ); + + fenum->count++; + } + + return; + +} + +/******************************************************************* +********************************************************************/ + +static WERROR net_enum_files( TALLOC_CTX *ctx, FILE_INFO_3 **info, + uint32 *count, uint32 resume ) +{ + f_enum_cnt.ctx = ctx; + f_enum_cnt.count = *count; + f_enum_cnt.info = *info; + + share_mode_forall( enum_file_fn ); + + *info = f_enum_cnt.info; + *count = f_enum_cnt.count; + + return WERR_OK; +} + /******************************************************************* Utility function to get the 'type' of a share from an snum. ********************************************************************/ @@ -70,11 +240,16 @@ static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int sn static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum) { + connection_struct *conn = p->conn; pstring remark; char *net_name = lp_servicename(snum); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark,sizeof(remark)); + standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + remark, sizeof(remark)); init_srv_share_info1(&sh1->info_1, net_name, get_share_type(snum), remark); init_srv_share_info1_str(&sh1->info_1_str, net_name, remark); @@ -86,15 +261,21 @@ static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int sn static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int snum) { + connection_struct *conn = p->conn; pstring remark; pstring path; pstring passwd; int max_connections = lp_max_connections(snum); uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff; - + int count = 0; char *net_name = lp_servicename(snum); + pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark,sizeof(remark)); + standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + remark, sizeof(remark)); pstrcpy(path, "C:"); pstrcat(path, lp_pathname(snum)); @@ -107,7 +288,10 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int sn pstrcpy(passwd, ""); - init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum), remark, 0, max_uses, 1, path, passwd); + count = count_current_connections( net_name, False ); + init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum), + remark, 0, max_uses, count, path, passwd); + init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); } @@ -179,11 +363,16 @@ out: static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum) { + connection_struct *conn = p->conn; pstring remark; const char *net_name = lp_servicename(snum); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark, sizeof(remark)); + standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + remark, sizeof(remark)); init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), remark, (lp_csc_policy(snum) << 4)); init_srv_share_info501_str(&sh501->info_501_str, net_name, remark); @@ -195,6 +384,7 @@ static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, int snum) { + connection_struct *conn = p->conn; pstring net_name; pstring remark; pstring path; @@ -208,7 +398,11 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, pstrcpy(net_name, lp_servicename(snum)); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark,sizeof(remark)); + standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + remark, sizeof(remark)); pstrcpy(path, "C:"); pstrcat(path, lp_pathname(snum)); @@ -233,10 +427,15 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh1004, int snum) { + connection_struct *conn = p->conn; pstring remark; pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark, sizeof(remark)); + standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + remark, sizeof(remark)); ZERO_STRUCTP(sh1004); @@ -632,16 +831,6 @@ static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_I r_n->status = status; } -/******************************************************************* - fill in a sess info level 1 structure. - ********************************************************************/ - -static void init_srv_sess_0_info(SESS_INFO_0 *se0, SESS_INFO_0_STR *str0, char *name) -{ - init_srv_sess_info0(se0, name); - init_srv_sess_info0_str(str0, name); -} - /******************************************************************* fill in a sess info level 0 structure. ********************************************************************/ @@ -662,11 +851,7 @@ static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *sto if (snum) { for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { - init_srv_sess_0_info(&ss0->info_0[num_entries], - &ss0->info_0_str[num_entries], session_list[(*snum)].remote_machine); - - /* move on to creating next session */ - /* move on to creating next sess */ + init_srv_sess_info0( &ss0->info_0[num_entries], session_list[(*snum)].remote_machine); num_entries++; } @@ -687,17 +872,35 @@ static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *sto } /******************************************************************* - fill in a sess info level 1 structure. - ********************************************************************/ +********************************************************************/ -static void init_srv_sess_1_info(SESS_INFO_1 *se1, SESS_INFO_1_STR *str1, - char *name, char *user, - uint32 num_opens, - uint32 open_time, uint32 idle_time, - uint32 usr_flgs) +/* global needed to make use of the share_mode_forall() callback */ +static struct sess_file_count s_file_cnt; + +static void sess_file_fn( const struct share_mode_entry *e, + const char *sharepath, const char *fname ) { - init_srv_sess_info1(se1 , name, user, num_opens, open_time, idle_time, usr_flgs); - init_srv_sess_info1_str(str1, name, user); + struct sess_file_count *sess = &s_file_cnt; + + if ( (procid_to_pid(&e->pid) == sess->pid) && (sess->uid == e->uid) ) { + sess->count++; + } + + return; +} + +/******************************************************************* +********************************************************************/ + +static int net_count_files( uid_t uid, pid_t pid ) +{ + s_file_cnt.count = 0; + s_file_cnt.uid = uid; + s_file_cnt.pid = pid; + + share_mode_forall( sess_file_fn ); + + return s_file_cnt.count; } /******************************************************************* @@ -708,43 +911,58 @@ static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto { struct sessionid *session_list; uint32 num_entries = 0; - (*stot) = list_sessions(&session_list); + time_t now = time(NULL); + if ( !snum ) { + ss1->num_entries_read = 0; + ss1->ptr_sess_info = 0; + ss1->num_entries_read2 = 0; + + (*stot) = 0; + + return; + } + if (ss1 == NULL) { (*snum) = 0; - SAFE_FREE(session_list); return; } - DEBUG(5,("init_srv_sess_1_ss1\n")); - - if (snum) { - for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { - init_srv_sess_1_info(&ss1->info_1[num_entries], - &ss1->info_1_str[num_entries], - session_list[*snum].remote_machine, - session_list[*snum].username, - 1, 10, 5, 0); - - /* move on to creating next session */ - /* move on to creating next sess */ - num_entries++; - } + (*stot) = list_sessions(&session_list); + - ss1->num_entries_read = num_entries; - ss1->ptr_sess_info = num_entries > 0 ? 1 : 0; - ss1->num_entries_read2 = num_entries; - - if ((*snum) >= (*stot)) { - (*snum) = 0; + for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { + uint32 num_files; + uint32 connect_time; + struct passwd *pw = sys_getpwnam(session_list[*snum].username); + BOOL guest; + + if ( !pw ) { + DEBUG(10,("init_srv_sess_info_1: failed to find owner: %s\n", + session_list[*snum].username)); + continue; } - - } else { - ss1->num_entries_read = 0; - ss1->ptr_sess_info = 0; - ss1->num_entries_read2 = 0; - - (*stot) = 0; + + connect_time = (uint32)(now - session_list[*snum].connect_start); + num_files = net_count_files(pw->pw_uid, session_list[*snum].pid); + guest = strequal( session_list[*snum].username, lp_guestaccount() ); + + init_srv_sess_info1( &ss1->info_1[num_entries], + session_list[*snum].remote_machine, + session_list[*snum].username, + num_files, + connect_time, + 0, + guest); + num_entries++; + } + + ss1->num_entries_read = num_entries; + ss1->ptr_sess_info = num_entries > 0 ? 1 : 0; + ss1->num_entries_read2 = num_entries; + + if ((*snum) >= (*stot)) { + (*snum) = 0; } SAFE_FREE(session_list); @@ -964,66 +1182,53 @@ static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, makes a SRV_R_NET_FILE_ENUM structure. ********************************************************************/ -static WERROR init_srv_file_info_ctr(pipes_struct *p, SRV_FILE_INFO_CTR *ctr, - int switch_value, uint32 *resume_hnd, - uint32 *total_entries) +static WERROR net_file_enum_3( SRV_R_NET_FILE_ENUM *r, uint32 resume_hnd ) { - WERROR status = WERR_OK; - TALLOC_CTX *ctx = p->mem_ctx; - DEBUG(5,("init_srv_file_info_ctr: %d\n", __LINE__)); - *total_entries = 1; /* dummy entries only, for */ + TALLOC_CTX *ctx = get_talloc_ctx(); + SRV_FILE_INFO_CTR *ctr = &r->ctr; - ctr->switch_value = switch_value; - ctr->num_entries = *total_entries - *resume_hnd; + /* TODO -- Windows enumerates + (b) active pipes + (c) open directories and files */ + + r->status = net_enum_files( ctx, &ctr->file.info3, &ctr->num_entries, resume_hnd ); + if ( !W_ERROR_IS_OK(r->status)) + goto done; + + r->status = net_enum_pipes( ctx, &ctr->file.info3, &ctr->num_entries, resume_hnd ); + if ( !W_ERROR_IS_OK(r->status)) + goto done; + + r->level = ctr->level = 3; + r->total_entries = ctr->num_entries; + /* ctr->num_entries = r->total_entries - resume_hnd; */ ctr->num_entries2 = ctr->num_entries; + ctr->ptr_file_info = 1; - switch (switch_value) { - case 3: { - int i; - if (*total_entries > 0) { - ctr->ptr_entries = 1; - ctr->file.info3 = TALLOC_ARRAY(ctx, SRV_FILE_INFO_3, ctr->num_entries); - } - for (i=0 ;inum_entries;i++) { - init_srv_file_info3(&ctr->file.info3[i].info_3, i+*resume_hnd, 0x35, 0, "\\PIPE\\samr", "dummy user"); - init_srv_file_info3_str(&ctr->file.info3[i].info_3_str, "\\PIPE\\samr", "dummy user"); - - } - ctr->ptr_file_info = 1; - *resume_hnd = 0; - break; - } - default: - DEBUG(5,("init_srv_file_info_ctr: unsupported switch value %d\n", switch_value)); - (*resume_hnd = 0); - (*total_entries) = 0; - ctr->ptr_entries = 0; - status = WERR_UNKNOWN_LEVEL; - break; - } + r->status = WERR_OK; - return status; +done: + if ( ctr->num_entries > 0 ) + ctr->ptr_entries = 1; + + init_enum_hnd(&r->enum_hnd, 0); + + return r->status; } /******************************************************************* - makes a SRV_R_NET_FILE_ENUM structure. -********************************************************************/ +*******************************************************************/ -static void init_srv_r_net_file_enum(pipes_struct *p, SRV_R_NET_FILE_ENUM *r_n, - uint32 resume_hnd, int file_level, int switch_value) +WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) { - DEBUG(5,("init_srv_r_net_file_enum: %d\n", __LINE__)); - - r_n->file_level = file_level; - if (file_level == 0) - r_n->status = WERR_UNKNOWN_LEVEL; - else - r_n->status = init_srv_file_info_ctr(p, &r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries)); - - if (!W_ERROR_IS_OK(r_n->status)) - resume_hnd = 0; - - init_enum_hnd(&r_n->enum_hnd, resume_hnd); + switch ( q_u->level ) { + case 3: + return net_file_enum_3( r_u, get_enum_hnd(&q_u->enum_hnd) ); + default: + return WERR_UNKNOWN_LEVEL; + } + + return WERR_OK; } /******************************************************************* @@ -1109,25 +1314,6 @@ WERROR _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R return r_u->status; } -/******************************************************************* -net file enum -********************************************************************/ - -WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) -{ - DEBUG(5,("srv_net_file_enum: %d\n", __LINE__)); - - /* set up the */ - init_srv_r_net_file_enum(p, r_u, - get_enum_hnd(&q_u->enum_hnd), - q_u->file_level, - q_u->ctr.switch_value); - - DEBUG(5,("srv_net_file_enum: %d\n", __LINE__)); - - return r_u->status; -} - /******************************************************************* net conn enum ********************************************************************/ @@ -1185,7 +1371,6 @@ net sess del WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SESS_DEL *r_u) { struct sessionid *session_list; - struct current_user user; int num_sessions, snum; fstring username; fstring machine; @@ -1205,11 +1390,9 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES r_u->status = WERR_ACCESS_DENIED; - get_current_user(&user, p); - /* fail out now if you are not root or not a domain admin */ - if ((user.ut.uid != sec_initial_uid()) && + if ((p->pipe_user.ut.uid != sec_initial_uid()) && ( ! nt_token_check_domain_rid(p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS))) { goto done; @@ -1220,7 +1403,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES if ((strequal(session_list[snum].username, username) || username[0] == '\0' ) && strequal(session_list[snum].remote_machine, machine)) { - if (user.ut.uid != sec_initial_uid()) { + if (p->pipe_user.ut.uid != sec_initial_uid()) { not_root = True; become_root(); } @@ -1337,7 +1520,6 @@ char *valid_share_pathname(char *dos_pathname) WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) { - struct current_user user; pstring command; fstring share_name; fstring comment; @@ -1374,13 +1556,11 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if (lp_print_ok(snum)) return WERR_ACCESS_DENIED; - get_current_user(&user,p); - is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); /* fail out now if you are not root and not a disk op */ - if ( user.ut.uid != sec_initial_uid() && !is_disk_op ) + if ( p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; switch (q_u->info_level) { @@ -1525,7 +1705,6 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) { - struct current_user user; pstring command; fstring share_name; fstring comment; @@ -1543,11 +1722,9 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S r_u->parm_error = 0; - get_current_user(&user,p); - is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); - if (user.ut.uid != sec_initial_uid() && !is_disk_op ) + if (p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; if (!lp_add_share_cmd() || !*lp_add_share_cmd()) { @@ -1682,7 +1859,6 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) { - struct current_user user; pstring command; fstring share_name; int ret; @@ -1710,11 +1886,9 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S if (lp_print_ok(snum)) return WERR_ACCESS_DENIED; - get_current_user(&user,p); - is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); - if (user.ut.uid != sec_initial_uid() && !is_disk_op ) + if (p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) { @@ -1826,7 +2000,6 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC SMB_STRUCT_STAT st; BOOL bad_path; NTSTATUS nt_status; - struct current_user user; connection_struct *conn = NULL; BOOL became_user = False; @@ -1839,10 +2012,8 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC /* Null password is ok - we are already an authenticated user... */ null_pw = data_blob(NULL, 0); - get_current_user(&user, p); - become_root(); - conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status); + conn = make_connection(qualname, null_pw, "A:", p->pipe_user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { @@ -1872,18 +2043,18 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC goto error_exit; } - fsp = open_file_stat(conn, filename, &st); - if (!fsp) { + nt_status = open_file_stat(conn, filename, &st, &fsp); + if (!NT_STATUS_IS_OK(nt_status)) { /* Perhaps it is a directory */ - if (errno == EISDIR) - fsp = open_directory(conn, filename, &st, + if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) + nt_status = open_directory(conn, filename, &st, READ_CONTROL_ACCESS, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0, - NULL); + NULL, &fsp); - if (!fsp) { + if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); r_u->status = WERR_ACCESS_DENIED; goto error_exit; @@ -1908,7 +2079,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC close_file(fsp, NORMAL_CLOSE); unbecome_user(); - close_cnum(conn, user.vuid); + close_cnum(conn, p->pipe_user.vuid); return r_u->status; error_exit: @@ -1921,7 +2092,7 @@ error_exit: unbecome_user(); if (conn) - close_cnum(conn, user.vuid); + close_cnum(conn, p->pipe_user.vuid); return r_u->status; } @@ -1941,7 +2112,6 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ SMB_STRUCT_STAT st; BOOL bad_path; NTSTATUS nt_status; - struct current_user user; connection_struct *conn = NULL; BOOL became_user = False; @@ -1954,10 +2124,8 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ /* Null password is ok - we are already an authenticated user... */ null_pw = data_blob(NULL, 0); - get_current_user(&user, p); - become_root(); - conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status); + conn = make_connection(qualname, null_pw, "A:", p->pipe_user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { @@ -1988,19 +2156,19 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ } - fsp = open_file_stat(conn, filename, &st); + nt_status = open_file_stat(conn, filename, &st, &fsp); - if (!fsp) { + if (!NT_STATUS_IS_OK(nt_status)) { /* Perhaps it is a directory */ - if (errno == EISDIR) - fsp = open_directory(conn, filename, &st, + if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) + nt_status = open_directory(conn, filename, &st, FILE_READ_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0, - NULL); + NULL, &fsp); - if (!fsp) { + if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename)); r_u->status = WERR_ACCESS_DENIED; goto error_exit; @@ -2017,7 +2185,7 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ close_file(fsp, NORMAL_CLOSE); unbecome_user(); - close_cnum(conn, user.vuid); + close_cnum(conn, p->pipe_user.vuid); return r_u->status; error_exit: @@ -2031,7 +2199,7 @@ error_exit: } if (conn) { - close_cnum(conn, user.vuid); + close_cnum(conn, p->pipe_user.vuid); } return r_u->status; @@ -2133,7 +2301,7 @@ WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV switch ( q_u->type ) { case 0x9: - rpcstr_pull(sharename, q_u->uni_name.buffer, sizeof(sharename), q_u->uni_name.uni_str_len*2, 0); + rpcstr_pull(sharename, q_u->sharename.buffer, sizeof(sharename), q_u->sharename.uni_str_len*2, 0); if ( !validate_net_name( sharename, INVALID_SHARENAME_CHARS, sizeof(sharename) ) ) { DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", sharename)); return WERR_INVALID_NAME; @@ -2146,3 +2314,13 @@ WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV return WERR_OK; } + + +/******************************************************************** +********************************************************************/ + +WERROR _srv_net_file_close(pipes_struct *p, SRV_Q_NET_FILE_CLOSE *q_u, SRV_R_NET_FILE_CLOSE *r_u) +{ + return WERR_ACCESS_DENIED; +} + diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 6062dcee5c..dd790691d3 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -624,7 +624,7 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG the client from showing the "Start" button (if of course the services are not running */ - if ( strequal( name, "NETLOGON" ) && ( lp_servicenumber(name) == -1 ) ) + if ( strequal( name, "NETLOGON" ) && ( !share_defined(name) ) ) config->start_type = SVCCTL_DISABLED; else if ( strequal( name, "WINS" ) && ( !lp_wins_support() )) config->start_type = SVCCTL_DISABLED; diff --git a/source3/rpc_server/srv_unixinfo.c b/source3/rpc_server/srv_unixinfo.c new file mode 100644 index 0000000000..f21416dfab --- /dev/null +++ b/source3/rpc_server/srv_unixinfo.c @@ -0,0 +1,163 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines for unixinfo-pipe + * Copyright (C) Volker Lendecke 2005 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* This is the interface to the rpcunixinfo pipe. */ + +#include "includes.h" +#include "nterr.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +static BOOL api_sid_to_uid(pipes_struct *p) +{ + UNIXINFO_Q_SID_TO_UID q_u; + UNIXINFO_R_SID_TO_UID r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!unixinfo_io_q_unixinfo_sid_to_uid("", &q_u, data, 0)) + return False; + + r_u.status = _unixinfo_sid_to_uid(p, &q_u, &r_u); + + if (!unixinfo_io_r_unixinfo_sid_to_uid("", &r_u, rdata, 0)) + return False; + + return True; +} + +static BOOL api_uid_to_sid(pipes_struct *p) +{ + UNIXINFO_Q_UID_TO_SID q_u; + UNIXINFO_R_UID_TO_SID r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!unixinfo_io_q_unixinfo_uid_to_sid("", &q_u, data, 0)) + return False; + + r_u.status = _unixinfo_uid_to_sid(p, &q_u, &r_u); + + if (!unixinfo_io_r_unixinfo_uid_to_sid("", &r_u, rdata, 0)) + return False; + + return True; +} + +static BOOL api_sid_to_gid(pipes_struct *p) +{ + UNIXINFO_Q_SID_TO_GID q_u; + UNIXINFO_R_SID_TO_GID r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!unixinfo_io_q_unixinfo_sid_to_gid("", &q_u, data, 0)) + return False; + + r_u.status = _unixinfo_sid_to_gid(p, &q_u, &r_u); + + if (!unixinfo_io_r_unixinfo_sid_to_gid("", &r_u, rdata, 0)) + return False; + + return True; +} + +static BOOL api_gid_to_sid(pipes_struct *p) +{ + UNIXINFO_Q_GID_TO_SID q_u; + UNIXINFO_R_GID_TO_SID r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!unixinfo_io_q_unixinfo_gid_to_sid("", &q_u, data, 0)) + return False; + + r_u.status = _unixinfo_gid_to_sid(p, &q_u, &r_u); + + if (!unixinfo_io_r_unixinfo_gid_to_sid("", &r_u, rdata, 0)) + return False; + + return True; +} + +static BOOL api_getpwuid(pipes_struct *p) +{ + UNIXINFO_Q_GETPWUID q_u; + UNIXINFO_R_GETPWUID r_u; + + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + if (!unixinfo_io_q_unixinfo_getpwuid("", &q_u, data, 0)) + return False; + + r_u.status = _unixinfo_getpwuid(p, &q_u, &r_u); + + if (!unixinfo_io_r_unixinfo_getpwuid("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* +\pipe\unixinfo commands +********************************************************************/ + +struct api_struct api_unixinfo_cmds[] = { + {"SID_TO_UID", UNIXINFO_SID_TO_UID, api_sid_to_uid }, + {"UID_TO_SID", UNIXINFO_UID_TO_SID, api_uid_to_sid }, + {"SID_TO_GID", UNIXINFO_SID_TO_GID, api_sid_to_gid }, + {"GID_TO_SID", UNIXINFO_GID_TO_SID, api_gid_to_sid }, + {"GETPWUID", UNIXINFO_GETPWUID, api_getpwuid }, +}; + + +void unixinfo_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_unixinfo_cmds; + *n_fns = sizeof(api_unixinfo_cmds) / sizeof(struct api_struct); +} + +NTSTATUS rpc_unixinfo_init(void) +{ + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, + "unixinfo", "unixinfo", api_unixinfo_cmds, + sizeof(api_unixinfo_cmds) / sizeof(struct api_struct)); +} diff --git a/source3/rpc_server/srv_unixinfo_nt.c b/source3/rpc_server/srv_unixinfo_nt.c new file mode 100644 index 0000000000..79756f20a7 --- /dev/null +++ b/source3/rpc_server/srv_unixinfo_nt.c @@ -0,0 +1,166 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines for unixinfo-pipe + * Copyright (C) Volker Lendecke 2005 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* This is the interface to the rpcunixinfo pipe. */ + +#include "includes.h" +#include "nterr.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +/* Map a sid to a uid */ + +NTSTATUS _unixinfo_sid_to_uid(pipes_struct *p, + UNIXINFO_Q_SID_TO_UID *q_u, + UNIXINFO_R_SID_TO_UID *r_u) +{ + uid_t uid; + + r_u->uid.low = 0; + r_u->uid.high = 0; + + r_u->status = sid_to_uid(&q_u->sid, &uid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; + if (NT_STATUS_IS_OK(r_u->status)) + r_u->uid.low = uid; + + return r_u->status; +} + +/* Map a uid to a sid */ + +NTSTATUS _unixinfo_uid_to_sid(pipes_struct *p, + UNIXINFO_Q_UID_TO_SID *q_u, + UNIXINFO_R_UID_TO_SID *r_u) +{ + DOM_SID sid; + + r_u->status = NT_STATUS_NO_SUCH_USER; + + if (q_u->uid.high == 0) { + uid_to_sid(&sid, q_u->uid.low); + r_u->status = NT_STATUS_OK; + } + + init_r_unixinfo_uid_to_sid(r_u, + NT_STATUS_IS_OK(r_u->status) ? &sid : NULL); + + return r_u->status; +} + +/* Map a sid to a gid */ + +NTSTATUS _unixinfo_sid_to_gid(pipes_struct *p, + UNIXINFO_Q_SID_TO_GID *q_u, + UNIXINFO_R_SID_TO_GID *r_u) +{ + gid_t gid; + + r_u->gid.low = 0; + r_u->gid.high = 0; + + r_u->status = sid_to_gid(&q_u->sid, &gid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; + if (NT_STATUS_IS_OK(r_u->status)) + r_u->gid.low = gid; + + return r_u->status; +} + +/* Map a gid to a sid */ + +NTSTATUS _unixinfo_gid_to_sid(pipes_struct *p, + UNIXINFO_Q_GID_TO_SID *q_u, + UNIXINFO_R_GID_TO_SID *r_u) +{ + DOM_SID sid; + + r_u->status = NT_STATUS_NO_SUCH_USER; + + if (q_u->gid.high == 0) { + gid_to_sid(&sid, q_u->gid.low); + r_u->status = NT_STATUS_OK; + } + + init_r_unixinfo_gid_to_sid(r_u, + NT_STATUS_IS_OK(r_u->status) ? &sid : NULL); + + return r_u->status; +} + +/* Get unix struct passwd information */ + +NTSTATUS _unixinfo_getpwuid(pipes_struct *p, + UNIXINFO_Q_GETPWUID *q_u, + UNIXINFO_R_GETPWUID *r_u) +{ + int i; + + if (r_u->count > 1023) { + return NT_STATUS_INVALID_PARAMETER; + } + + r_u->info = TALLOC_ARRAY(p->mem_ctx, struct unixinfo_getpwuid, + q_u->count); + + if ((r_u->count > 0) && (r_u->info == NULL)) { + return NT_STATUS_NO_MEMORY; + } + + r_u->status = NT_STATUS_OK; + r_u->count = q_u->count; + + for (i=0; icount; i++) { + struct passwd *pw; + char *homedir, *shell; + ssize_t len1, len2; + + r_u->info[i].status = NT_STATUS_NO_SUCH_USER; + r_u->info[i].homedir = ""; + r_u->info[i].shell = ""; + + if (q_u->uid[i].high != 0) { + DEBUG(10, ("64-bit uids not yet supported...\n")); + continue; + } + + pw = getpwuid(q_u->uid[i].low); + + if (pw == NULL) { + DEBUG(10, ("Did not find uid %d\n", q_u->uid[i].low)); + continue; + } + + len1 = push_utf8_talloc(p->mem_ctx, &homedir, pw->pw_dir); + len2 = push_utf8_talloc(p->mem_ctx, &shell, pw->pw_shell); + + if ((len1 < 0) || (len2 < 0) || (homedir == NULL) || + (shell == NULL)) { + DEBUG(3, ("push_utf8_talloc failed\n")); + r_u->info[i].status = NT_STATUS_NO_MEMORY; + continue; + } + + r_u->info[i].status = NT_STATUS_OK; + r_u->info[i].homedir = homedir; + r_u->info[i].shell = shell; + } + + return r_u->status; +} -- cgit From 7c1f79143b4f28e6eff0cf914defd0a008372055 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 11 Jul 2006 20:02:22 +0000 Subject: r16953: Don't allow groups to be renamed to an existing user or other group (This used to be commit 7d619f127ee70fdd486ffaab4546a53d76a2288c) --- source3/rpc_server/srv_samr_nt.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2e0b355db5..66f196ae3a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4590,6 +4590,10 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ switch (ctr->level) { case 2: + { + fstring group_name; + enum SID_NAME_USE type; + /* We currently do not support renaming groups in the the BUILTIN domain. Refer to util_builtin.c to understand why. The eventually needs to be fixed to be like Windows @@ -4599,13 +4603,26 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ return NT_STATUS_SPECIAL_ACCOUNT; } - if ( ctr->alias.info2.name.string ) { - unistr2_to_ascii( info.acct_name, ctr->alias.info2.name.string, - sizeof(info.acct_name)-1 ); + /* There has to be a valid name */ + if ( !ctr->alias.info2.name.string ) + return NT_STATUS_INVALID_PARAMETER; + + unistr2_to_ascii( info.acct_name, ctr->alias.info2.name.string, + sizeof(info.acct_name)-1 ); + + /* make sure the name doesn't already exist as a user + or local group */ + + fstr_sprintf( group_name, "%s\\%s", global_myname(), info.acct_name ); + if ( lookup_name( p->mem_ctx, group_name, 0, NULL, NULL, NULL, &type) ) { + if ( type == SID_NAME_USER ) { + return NT_STATUS_USER_EXISTS; + } + + return NT_STATUS_ALIAS_EXISTS; } - else - fstrcpy( info.acct_name, "" ); break; + } case 3: if ( ctr->alias.info3.description.string ) { unistr2_to_ascii( info.acct_desc, -- cgit From 751ad5753402749c1e1638ba4d07aed0d76c52bc Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 11 Jul 2006 20:31:13 +0000 Subject: r16954: Volker reminded me we already have code to do this check. Reuse can_create() to prevent renameing a group to an existing user or group. (This used to be commit ce7091fda1eb3c7ea0900f455cec48c3b95a17f6) --- source3/rpc_server/srv_samr_nt.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 66f196ae3a..9c453b04a4 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4592,7 +4592,7 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ case 2: { fstring group_name; - enum SID_NAME_USE type; + NTSTATUS status; /* We currently do not support renaming groups in the the BUILTIN domain. Refer to util_builtin.c to understand @@ -4614,13 +4614,9 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ or local group */ fstr_sprintf( group_name, "%s\\%s", global_myname(), info.acct_name ); - if ( lookup_name( p->mem_ctx, group_name, 0, NULL, NULL, NULL, &type) ) { - if ( type == SID_NAME_USER ) { - return NT_STATUS_USER_EXISTS; - } - - return NT_STATUS_ALIAS_EXISTS; - } + status = can_create( p->mem_ctx, group_name ); + if ( !NT_STATUS_IS_OK( status ) ) + return status; break; } case 3: -- cgit From 1f2419d9f8be0efcf2e43ecf97ea59d501e62fe8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 14 Jul 2006 17:46:06 +0000 Subject: r17032: I thought I had already merged this from trunk: > r16959 | vlendec | 2006-07-11 23:10:44 +0200 (Di, 11 Jul 2006) | 1 line > > get_share_security does not need snum, activate RPC-SAMBA3-SRVSVC Volker (This used to be commit c89471e15766fcdbfa4f40701e12c19f95c2d8ef) --- source3/rpc_server/srv_srvsvc_nt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 12a86ce9f3..a313bbb881 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -338,7 +338,7 @@ BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, u if (mem_ctx == NULL) return False; - psd = get_share_security(mem_ctx, snum, &sd_size); + psd = get_share_security(mem_ctx, lp_servicename(snum), &sd_size); if (!psd) goto out; @@ -415,7 +415,7 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, pstrcpy(passwd, ""); - sd = get_share_security(ctx, snum, &sd_size); + sd = get_share_security(ctx, lp_servicename(snum), &sd_size); init_srv_share_info502(&sh502->info_502, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size); init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, path, passwd, sd, sd_size); @@ -493,7 +493,7 @@ static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh150 ZERO_STRUCTP(sh1501); - sd = get_share_security(ctx, snum, &sd_size); + sd = get_share_security(ctx, lp_servicename(snum), &sd_size); sh1501->sdb = make_sec_desc_buf(p->mem_ctx, sd_size, sd); } @@ -1684,7 +1684,8 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S SEC_DESC *old_sd; size_t sd_size; - old_sd = get_share_security(p->mem_ctx, snum, &sd_size); + old_sd = get_share_security(p->mem_ctx, lp_servicename(snum), + &sd_size); if (old_sd && !sec_desc_equal(old_sd, psd)) { if (!set_share_security(p->mem_ctx, share_name, psd)) -- cgit From 5b474afa74697321a24e952c63e60bcb1e84dced Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 14 Jul 2006 17:53:45 +0000 Subject: r17033: Restructure init_srv_share_info_ctr so that there's only one loop, not a dozen or so. Next step will be to eliminate the explicit snum reference. Volker (This used to be commit 6e98f8d6c6cc126b0d27ac574c128be96e50abf3) --- source3/rpc_server/srv_srvsvc_nt.c | 304 +++++++++++++++---------------------- 1 file changed, 119 insertions(+), 185 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index a313bbb881..9e1556b618 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -513,8 +513,10 @@ static BOOL is_hidden_share(int snum) Fill in a share info structure. ********************************************************************/ -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) +static WERROR 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 = 0; @@ -523,7 +525,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, DEBUG(5,("init_srv_share_info_ctr\n")); - ZERO_STRUCTPN(ctr); + ZERO_STRUCT(ctr->share); ctr->info_level = ctr->switch_value = info_level; *resume_hnd = 0; @@ -533,218 +535,153 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, num_services = load_usershare_shares(); unbecome_root(); - /* Count the number of entries. */ - for (snum = 0; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) - num_entries++; - } - - *total_entries = num_entries; - ctr->num_entries2 = ctr->num_entries = num_entries; - ctr->ptr_share_info = ctr->ptr_entries = 1; - - if (!num_entries) - return True; - - switch (info_level) { - case 0: - { - SRV_SHARE_INFO_0 *info0 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_0, num_entries); - int i = 0; + num_entries = 0; - if (!info0) { - return False; - } + ZERO_STRUCT(ctr->share); - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_0(p, &info0[i++], snum); - } + for (snum = *resume_hnd; snum < num_services; snum++) { + if (!lp_snum_ok(snum) || !lp_browseable(snum)) { + continue; } - - ctr->share.info0 = info0; - break; - - } - - case 1: - { - SRV_SHARE_INFO_1 *info1 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1, num_entries); - int i = 0; - - if (!info1) { - return False; + if (!all_shares && is_hidden_share(snum)) { + continue; } - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_1(p, &info1[i++], snum); + switch (info_level) { + case 0: + { + SRV_SHARE_INFO_0 i; + init_srv_share_info_0(p, &i, snum); + ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_0, i, + &ctr->share.info0, &num_entries); + if (ctr->share.info0 == NULL) { + return WERR_NOMEM; } + break; } - ctr->share.info1 = info1; - break; - } - - case 2: - { - SRV_SHARE_INFO_2 *info2 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_2, num_entries); - int i = 0; - - if (!info2) { - return False; - } - - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_2(p, &info2[i++], snum); + case 1: + { + SRV_SHARE_INFO_1 i; + init_srv_share_info_1(p, &i, snum); + ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1, i, + &ctr->share.info1, &num_entries); + if (ctr->share.info1 == NULL) { + return WERR_NOMEM; } + break; } - ctr->share.info2 = info2; - break; - } - - case 501: - { - SRV_SHARE_INFO_501 *info501 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_501, num_entries); - int i = 0; - - if (!info501) { - return False; - } - - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_501(p, &info501[i++], snum); + case 2: + { + SRV_SHARE_INFO_2 i; + init_srv_share_info_2(p, &i, snum); + ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_2, i, + &ctr->share.info2, &num_entries); + if (ctr->share.info2 == NULL) { + return WERR_NOMEM; } + break; } - - ctr->share.info501 = info501; - break; - } - - case 502: - { - SRV_SHARE_INFO_502 *info502 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_502, num_entries); - int i = 0; - if (!info502) { - return False; + case 501: + { + SRV_SHARE_INFO_501 i; + init_srv_share_info_501(p, &i, snum); + ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_501, i, + &ctr->share.info501, &num_entries); + if (ctr->share.info501 == NULL) { + return WERR_NOMEM; + } + break; } - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_502(p, &info502[i++], snum); + case 502: + { + SRV_SHARE_INFO_502 i; + init_srv_share_info_502(p, &i, snum); + ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_502, i, + &ctr->share.info502, &num_entries); + if (ctr->share.info502 == NULL) { + return WERR_NOMEM; } + break; } - ctr->share.info502 = info502; - break; - } - - /* here for completeness but not currently used with enum (1004 - 1501)*/ + /* here for completeness but not currently used with enum + * (1004 - 1501)*/ - case 1004: - { - SRV_SHARE_INFO_1004 *info1004 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1004, num_entries); - int i = 0; - - if (!info1004) { - return False; - } - - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_1004(p, &info1004[i++], snum); + case 1004: + { + SRV_SHARE_INFO_1004 i; + init_srv_share_info_1004(p, &i, snum); + ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1004, i, + &ctr->share.info1004, &num_entries); + if (ctr->share.info1004 == NULL) { + return WERR_NOMEM; } + break; } - ctr->share.info1004 = info1004; - break; - } - - case 1005: - { - SRV_SHARE_INFO_1005 *info1005 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1005, num_entries); - int i = 0; - - if (!info1005) { - return False; - } - - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_1005(p, &info1005[i++], snum); + case 1005: + { + SRV_SHARE_INFO_1005 i; + init_srv_share_info_1005(p, &i, snum); + ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1005, i, + &ctr->share.info1005, &num_entries); + if (ctr->share.info1005 == NULL) { + return WERR_NOMEM; } + break; } - ctr->share.info1005 = info1005; - break; - } - - case 1006: - { - SRV_SHARE_INFO_1006 *info1006 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1006, num_entries); - int i = 0; - - if (!info1006) { - return False; - } - - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_1006(p, &info1006[i++], snum); + case 1006: + { + SRV_SHARE_INFO_1006 i; + init_srv_share_info_1006(p, &i, snum); + ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1006, i, + &ctr->share.info1006, &num_entries); + if (ctr->share.info1006 == NULL) { + return WERR_NOMEM; } + break; } - ctr->share.info1006 = info1006; - break; - } - - case 1007: - { - SRV_SHARE_INFO_1007 *info1007 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1007, num_entries); - int i = 0; - - if (!info1007) { - return False; - } - - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_1007(p, &info1007[i++], snum); + case 1007: + { + SRV_SHARE_INFO_1007 i; + init_srv_share_info_1007(p, &i, snum); + ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1007, i, + &ctr->share.info1007, &num_entries); + if (ctr->share.info1007 == NULL) { + return WERR_NOMEM; } + break; } - ctr->share.info1007 = info1007; - break; - } - - case 1501: - { - SRV_SHARE_INFO_1501 *info1501 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1501, num_entries); - int i = 0; - - if (!info1501) { - return False; - } - - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_1501(p, &info1501[i++], snum); + case 1501: + { + SRV_SHARE_INFO_1501 i; + init_srv_share_info_1501(p, &i, snum); + ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1501, i, + &ctr->share.info1501, &num_entries); + if (ctr->share.info1501 == NULL) { + return WERR_NOMEM; } + break; + } + default: + DEBUG(5,("init_srv_share_info_ctr: unsupported switch " + "value %d\n", info_level)); + return WERR_UNKNOWN_LEVEL; } - - ctr->share.info1501 = info1501; - break; - } - default: - DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level)); - return False; } - return True; + *total_entries = num_entries; + ctr->num_entries2 = ctr->num_entries = num_entries; + ctr->ptr_share_info = ctr->ptr_entries = 1; + + return WERR_OK; } /******************************************************************* @@ -756,12 +693,9 @@ static void init_srv_r_net_share_enum(pipes_struct *p, SRV_R_NET_SHARE_ENUM *r_n { DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__)); - if (init_srv_share_info_ctr(p, &r_n->ctr, info_level, - &resume_hnd, &r_n->total_entries, all)) { - r_n->status = WERR_OK; - } else { - r_n->status = WERR_UNKNOWN_LEVEL; - } + r_n->status = init_srv_share_info_ctr(p, &r_n->ctr, info_level, + &resume_hnd, + &r_n->total_entries, all); init_enum_hnd(&r_n->enum_hnd, resume_hnd); } -- cgit From 2203228c791761bcab07961da725488636bee8df Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 14 Jul 2006 22:06:38 +0000 Subject: r17039: Eliminate snum from enumshares and getshareinfo. Get rid of some pstrings. Volker (This used to be commit c5e393d5eda4e13a844171d9ff319d1f1bac3d84) --- source3/rpc_server/srv_srvsvc_nt.c | 279 ++++++++++++++++++++----------------- 1 file changed, 155 insertions(+), 124 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 9e1556b618..50df99901b 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -200,19 +200,19 @@ static WERROR net_enum_files( TALLOC_CTX *ctx, FILE_INFO_3 **info, } /******************************************************************* - Utility function to get the 'type' of a share from an snum. + Utility function to get the 'type' of a share from a share definition. ********************************************************************/ -static uint32 get_share_type(int snum) +static uint32 get_share_type(const struct share_params *params) { - char *net_name = lp_servicename(snum); + char *net_name = lp_servicename(params->service); int len_net_name = strlen(net_name); /* work out the share type */ uint32 type = STYPE_DISKTREE; - if (lp_print_ok(snum)) + if (lp_print_ok(params->service)) type = STYPE_PRINTQ; - if (strequal(lp_fstype(snum), "IPC")) + if (strequal(lp_fstype(params->service), "IPC")) type = STYPE_IPC; if (net_name[len_net_name] == '$') type |= STYPE_HIDDEN; @@ -224,12 +224,10 @@ static uint32 get_share_type(int snum) Fill in a share info level 0 structure. ********************************************************************/ -static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int snum) +static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, + const struct share_params *params) { - pstring net_name; - - pstrcpy(net_name, lp_servicename(snum)); - + char *net_name = lp_servicename(params->service); init_srv_share_info0(&sh0->info_0, net_name); init_srv_share_info0_str(&sh0->info_0_str, net_name); } @@ -238,20 +236,21 @@ static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int sn Fill in a share info level 1 structure. ********************************************************************/ -static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum) +static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, + const struct share_params *params) { connection_struct *conn = p->conn; - pstring remark; + char *net_name = lp_servicename(params->service); + char *remark; - char *net_name = lp_servicename(snum); - pstrcpy(remark, lp_comment(snum)); - standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, - conn->connectpath, conn->gid, - get_current_username(), - current_user_info.domain, - remark, sizeof(remark)); + remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), + conn->user, conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + lp_comment(params->service)); - init_srv_share_info1(&sh1->info_1, net_name, get_share_type(snum), remark); + init_srv_share_info1(&sh1->info_1, net_name, get_share_type(params), + remark); init_srv_share_info1_str(&sh1->info_1_str, net_name, remark); } @@ -259,40 +258,37 @@ static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int sn Fill in a share info level 2 structure. ********************************************************************/ -static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int snum) +static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, + const struct share_params *params) { connection_struct *conn = p->conn; - pstring remark; - pstring path; - pstring passwd; - int max_connections = lp_max_connections(snum); + char *remark; + char *path; + int max_connections = lp_max_connections(params->service); uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff; int count = 0; - char *net_name = lp_servicename(snum); + char *net_name = lp_servicename(params->service); - pstrcpy(remark, lp_comment(snum)); - standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, - conn->connectpath, conn->gid, - get_current_username(), - current_user_info.domain, - remark, sizeof(remark)); - pstrcpy(path, "C:"); - pstrcat(path, lp_pathname(snum)); + remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), + conn->user, conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + lp_comment(params->service)); + path = talloc_asprintf(p->mem_ctx, "C:%s", + lp_pathname(params->service)); /* - * Change / to \\ so that win2k will see it as a valid path. This was added to - * enable use of browsing in win2k add share dialog. + * Change / to \\ so that win2k will see it as a valid path. This was + * added to enable use of browsing in win2k add share dialog. */ string_replace(path, '/', '\\'); - pstrcpy(passwd, ""); - count = count_current_connections( net_name, False ); - init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum), - remark, 0, max_uses, count, path, passwd); + init_srv_share_info2(&sh2->info_2, net_name, get_share_type(params), + remark, 0, max_uses, count, path, ""); - init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); + init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, ""); } /******************************************************************* @@ -361,20 +357,22 @@ out: Fill in a share info level 501 structure. ********************************************************************/ -static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum) +static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, + const struct share_params *params) { connection_struct *conn = p->conn; - pstring remark; - - const char *net_name = lp_servicename(snum); - pstrcpy(remark, lp_comment(snum)); - standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, - conn->connectpath, conn->gid, - get_current_username(), - current_user_info.domain, - remark, sizeof(remark)); - - init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), remark, (lp_csc_policy(snum) << 4)); + char *remark; + const char *net_name = lp_servicename(params->service); + + remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), + conn->user, conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + lp_comment(params->service)); + + init_srv_share_info501(&sh501->info_501, net_name, + get_share_type(params), remark, + (lp_csc_policy(params->service) << 4)); init_srv_share_info501_str(&sh501->info_501_str, net_name, remark); } @@ -382,13 +380,13 @@ static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, Fill in a share info level 502 structure. ********************************************************************/ -static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, int snum) +static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, + const struct share_params *params) { connection_struct *conn = p->conn; - pstring net_name; - pstring remark; - pstring path; - pstring passwd; + char *net_name; + char *remark; + char *path; SEC_DESC *sd; size_t sd_size; TALLOC_CTX *ctx = p->mem_ctx; @@ -396,46 +394,50 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, ZERO_STRUCTP(sh502); - pstrcpy(net_name, lp_servicename(snum)); - pstrcpy(remark, lp_comment(snum)); - standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, - conn->connectpath, conn->gid, - get_current_username(), - current_user_info.domain, - remark, sizeof(remark)); - pstrcpy(path, "C:"); - pstrcat(path, lp_pathname(snum)); + net_name = lp_servicename(params->service); + + remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), + conn->user, conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + lp_comment(params->service)); + + path = talloc_asprintf(p->mem_ctx, "C:%s", + lp_pathname(params->service)); /* - * Change / to \\ so that win2k will see it as a valid path. This was added to - * enable use of browsing in win2k add share dialog. + * Change / to \\ so that win2k will see it as a valid path. This was + * added to enable use of browsing in win2k add share dialog. */ string_replace(path, '/', '\\'); - pstrcpy(passwd, ""); - - sd = get_share_security(ctx, lp_servicename(snum), &sd_size); + sd = get_share_security(ctx, lp_servicename(params->service), + &sd_size); - init_srv_share_info502(&sh502->info_502, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size); - init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, path, passwd, sd, sd_size); + init_srv_share_info502(&sh502->info_502, net_name, + get_share_type(params), remark, 0, 0xffffffff, + 1, path, "", sd, sd_size); + init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, + path, "", sd, sd_size); } /*************************************************************************** Fill in a share info level 1004 structure. ***************************************************************************/ -static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh1004, int snum) +static void init_srv_share_info_1004(pipes_struct *p, + SRV_SHARE_INFO_1004* sh1004, + const struct share_params *params) { connection_struct *conn = p->conn; - pstring remark; + char *remark; - pstrcpy(remark, lp_comment(snum)); - standard_sub_advanced(lp_servicename(SNUM(conn)), conn->user, - conn->connectpath, conn->gid, - get_current_username(), - current_user_info.domain, - remark, sizeof(remark)); + remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), + conn->user, conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + lp_comment(params->service)); ZERO_STRUCTP(sh1004); @@ -447,21 +449,25 @@ static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh100 Fill in a share info level 1005 structure. ***************************************************************************/ -static void init_srv_share_info_1005(pipes_struct *p, SRV_SHARE_INFO_1005* sh1005, int snum) +static void init_srv_share_info_1005(pipes_struct *p, + SRV_SHARE_INFO_1005* sh1005, + const struct share_params *params) { sh1005->share_info_flags = 0; - if(lp_host_msdfs() && lp_msdfs_root(snum)) + if(lp_host_msdfs() && lp_msdfs_root(params->service)) sh1005->share_info_flags |= SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT; sh1005->share_info_flags |= - lp_csc_policy(snum) << SHARE_1005_CSC_POLICY_SHIFT; + lp_csc_policy(params->service) << SHARE_1005_CSC_POLICY_SHIFT; } /*************************************************************************** Fill in a share info level 1006 structure. ***************************************************************************/ -static void init_srv_share_info_1006(pipes_struct *p, SRV_SHARE_INFO_1006* sh1006, int snum) +static void init_srv_share_info_1006(pipes_struct *p, + SRV_SHARE_INFO_1006* sh1006, + const struct share_params *params) { sh1006->max_uses = -1; } @@ -470,22 +476,28 @@ static void init_srv_share_info_1006(pipes_struct *p, SRV_SHARE_INFO_1006* sh100 Fill in a share info level 1007 structure. ***************************************************************************/ -static void init_srv_share_info_1007(pipes_struct *p, SRV_SHARE_INFO_1007* sh1007, int snum) +static void init_srv_share_info_1007(pipes_struct *p, + SRV_SHARE_INFO_1007* sh1007, + const struct share_params *params) { pstring alternate_directory_name = ""; uint32 flags = 0; ZERO_STRUCTP(sh1007); - init_srv_share_info1007(&sh1007->info_1007, flags, alternate_directory_name); - init_srv_share_info1007_str(&sh1007->info_1007_str, alternate_directory_name); + init_srv_share_info1007(&sh1007->info_1007, flags, + alternate_directory_name); + init_srv_share_info1007_str(&sh1007->info_1007_str, + alternate_directory_name); } /******************************************************************* Fill in a share info level 1501 structure. ********************************************************************/ -static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh1501, int snum) +static void init_srv_share_info_1501(pipes_struct *p, + SRV_SHARE_INFO_1501 *sh1501, + const struct share_params *params) { SEC_DESC *sd; size_t sd_size; @@ -493,7 +505,8 @@ static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh150 ZERO_STRUCTP(sh1501); - sd = get_share_security(ctx, lp_servicename(snum), &sd_size); + sd = get_share_security(ctx, lp_servicename(params->service), + &sd_size); sh1501->sdb = make_sec_desc_buf(p->mem_ctx, sd_size, sd); } @@ -502,11 +515,11 @@ static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh150 True if it ends in '$'. ********************************************************************/ -static BOOL is_hidden_share(int snum) +static BOOL is_hidden_share(const struct share_params *params) { - const char *net_name = lp_servicename(snum); + const char *net_name = lp_servicename(params->service); - return (net_name[strlen(net_name) - 1] == '$') ? True : False; + return (net_name[strlen(net_name) - 1] == '$'); } /******************************************************************* @@ -519,9 +532,9 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, uint32 *total_entries, BOOL all_shares) { int num_entries = 0; - int num_services = 0; - int snum; TALLOC_CTX *ctx = p->mem_ctx; + struct share_iterator *shares; + struct share_params *share; DEBUG(5,("init_srv_share_info_ctr\n")); @@ -532,18 +545,23 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, /* Ensure all the usershares are loaded. */ become_root(); - num_services = load_usershare_shares(); + load_usershare_shares(); unbecome_root(); num_entries = 0; ZERO_STRUCT(ctr->share); - for (snum = *resume_hnd; snum < num_services; snum++) { - if (!lp_snum_ok(snum) || !lp_browseable(snum)) { + if (!(shares = share_list_all(ctx))) { + DEBUG(5, ("Could not list shares\n")); + return WERR_ACCESS_DENIED; + } + + while ((share = next_share(shares)) != NULL) { + if (!lp_browseable(share->service)) { continue; } - if (!all_shares && is_hidden_share(snum)) { + if (!all_shares && is_hidden_share(share)) { continue; } @@ -551,7 +569,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, case 0: { SRV_SHARE_INFO_0 i; - init_srv_share_info_0(p, &i, snum); + init_srv_share_info_0(p, &i, share); ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_0, i, &ctr->share.info0, &num_entries); if (ctr->share.info0 == NULL) { @@ -563,7 +581,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, case 1: { SRV_SHARE_INFO_1 i; - init_srv_share_info_1(p, &i, snum); + init_srv_share_info_1(p, &i, share); ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1, i, &ctr->share.info1, &num_entries); if (ctr->share.info1 == NULL) { @@ -575,7 +593,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, case 2: { SRV_SHARE_INFO_2 i; - init_srv_share_info_2(p, &i, snum); + init_srv_share_info_2(p, &i, share); ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_2, i, &ctr->share.info2, &num_entries); if (ctr->share.info2 == NULL) { @@ -587,7 +605,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, case 501: { SRV_SHARE_INFO_501 i; - init_srv_share_info_501(p, &i, snum); + init_srv_share_info_501(p, &i, share); ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_501, i, &ctr->share.info501, &num_entries); if (ctr->share.info501 == NULL) { @@ -599,7 +617,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, case 502: { SRV_SHARE_INFO_502 i; - init_srv_share_info_502(p, &i, snum); + init_srv_share_info_502(p, &i, share); ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_502, i, &ctr->share.info502, &num_entries); if (ctr->share.info502 == NULL) { @@ -614,7 +632,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, case 1004: { SRV_SHARE_INFO_1004 i; - init_srv_share_info_1004(p, &i, snum); + init_srv_share_info_1004(p, &i, share); ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1004, i, &ctr->share.info1004, &num_entries); if (ctr->share.info1004 == NULL) { @@ -626,7 +644,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, case 1005: { SRV_SHARE_INFO_1005 i; - init_srv_share_info_1005(p, &i, snum); + init_srv_share_info_1005(p, &i, share); ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1005, i, &ctr->share.info1005, &num_entries); if (ctr->share.info1005 == NULL) { @@ -638,7 +656,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, case 1006: { SRV_SHARE_INFO_1006 i; - init_srv_share_info_1006(p, &i, snum); + init_srv_share_info_1006(p, &i, share); ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1006, i, &ctr->share.info1006, &num_entries); if (ctr->share.info1006 == NULL) { @@ -650,7 +668,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, case 1007: { SRV_SHARE_INFO_1007 i; - init_srv_share_info_1007(p, &i, snum); + init_srv_share_info_1007(p, &i, share); ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1007, i, &ctr->share.info1007, &num_entries); if (ctr->share.info1007 == NULL) { @@ -662,7 +680,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, case 1501: { SRV_SHARE_INFO_1501 i; - init_srv_share_info_1501(p, &i, snum); + init_srv_share_info_1501(p, &i, share); ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1501, i, &ctr->share.info1501, &num_entries); if (ctr->share.info1501 == NULL) { @@ -675,6 +693,8 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, "value %d\n", info_level)); return WERR_UNKNOWN_LEVEL; } + + TALLOC_FREE(share); } *total_entries = num_entries; @@ -708,52 +728,63 @@ static void init_srv_r_net_share_get_info(pipes_struct *p, SRV_R_NET_SHARE_GET_I char *share_name, uint32 info_level) { WERROR status = WERR_OK; - int snum; + const struct share_params *params; DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__)); r_n->info.switch_value = info_level; - snum = find_service(share_name); + params = get_share_params(p->mem_ctx, share_name); - if (snum >= 0) { + if (params != NULL) { switch (info_level) { case 0: - init_srv_share_info_0(p, &r_n->info.share.info0, snum); + init_srv_share_info_0(p, &r_n->info.share.info0, + params); break; case 1: - init_srv_share_info_1(p, &r_n->info.share.info1, snum); + init_srv_share_info_1(p, &r_n->info.share.info1, + params); break; case 2: - init_srv_share_info_2(p, &r_n->info.share.info2, snum); + init_srv_share_info_2(p, &r_n->info.share.info2, + params); break; case 501: - init_srv_share_info_501(p, &r_n->info.share.info501, snum); + init_srv_share_info_501(p, &r_n->info.share.info501, + params); break; case 502: - init_srv_share_info_502(p, &r_n->info.share.info502, snum); + init_srv_share_info_502(p, &r_n->info.share.info502, + params); break; /* here for completeness */ case 1004: - init_srv_share_info_1004(p, &r_n->info.share.info1004, snum); + init_srv_share_info_1004(p, &r_n->info.share.info1004, + params); break; case 1005: - init_srv_share_info_1005(p, &r_n->info.share.info1005, snum); + init_srv_share_info_1005(p, &r_n->info.share.info1005, + params); break; /* here for completeness 1006 - 1501 */ case 1006: - init_srv_share_info_1006(p, &r_n->info.share.info1006, snum); + init_srv_share_info_1006(p, &r_n->info.share.info1006, + params); break; case 1007: - init_srv_share_info_1007(p, &r_n->info.share.info1007, snum); + init_srv_share_info_1007(p, &r_n->info.share.info1007, + params); break; case 1501: - init_srv_share_info_1501(p, &r_n->info.share.info1501, snum); + init_srv_share_info_1501(p, &r_n->info.share.info1501, + params); break; default: - DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level)); + DEBUG(5,("init_srv_net_share_get_info: unsupported " + "switch value %d\n", info_level)); status = WERR_UNKNOWN_LEVEL; break; } -- cgit From f512695ea4659a9e384ed0c6d7bfe2a705012e78 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Jul 2006 17:55:01 +0000 Subject: r17064: lsa_GetUserName needs to return the name for S-1-5-7 on an anonymous login. Found that because I want to play around with setsharesecurity, for this I need the "whoami" call figuring out the SID of the currently connected user. Not activating this test yet until the build farm has picked up the new samba4 revision. Volker (This used to be commit 5cfe482841b77208b68376f9e2b8a4a62271f7c9) --- source3/rpc_server/srv_lsa_nt.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 2cc5ef6110..b4b8876db0 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1514,14 +1514,26 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u) { - fstring username, domname; + const char *username, *domname; user_struct *vuser = get_valid_user_struct(p->vuid); if (vuser == NULL) return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; - - fstrcpy(username, vuser->user.smb_name); - fstrcpy(domname, vuser->user.domain); + + if (vuser->guest) { + /* + * I'm 99% sure this is not the right place to do this, + * global_sid_Anonymous should probably be put into the token + * instead of the guest id -- vl + */ + if (!lookup_sid(p->mem_ctx, &global_sid_Anonymous, + &domname, &username, NULL)) { + return NT_STATUS_NO_MEMORY; + } + } else { + username = vuser->user.smb_name; + domname = vuser->user.domain; + } r_u->ptr_user_name = 1; init_unistr2(&r_u->uni2_user_name, username, UNI_STR_TERMINATE); -- cgit From 283b74fce595642fb2e2a2fad87c2de9c3bc5403 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 17 Jul 2006 19:50:59 +0000 Subject: r17096: Simplify share_access_check a bit: It takes the sharename instead of the snum, and the decision which token to use (conn or vuser) does not really belong here, it is better done in the two places where this is called. Volker (This used to be commit 0a138888adf7a0f04a38cd911e797e1a379e908b) --- source3/rpc_server/srv_srvsvc_nt.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 50df99901b..19099b931e 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -320,36 +320,30 @@ static void map_generic_share_sd_bits(SEC_DESC *psd) Can this user access with share with the required permissions ? ********************************************************************/ -BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, uint32 desired_access) +BOOL share_access_check(const NT_USER_TOKEN *token, const char *sharename, + uint32 desired_access) { uint32 granted; NTSTATUS status; TALLOC_CTX *mem_ctx = NULL; SEC_DESC *psd = NULL; size_t sd_size; - NT_USER_TOKEN *token = NULL; BOOL ret = True; - mem_ctx = talloc_init("share_access_check"); - if (mem_ctx == NULL) + if (!(mem_ctx = talloc_init("share_access_check"))) { return False; + } - psd = get_share_security(mem_ctx, lp_servicename(snum), &sd_size); - - if (!psd) - goto out; + psd = get_share_security(mem_ctx, sharename, &sd_size); - if (conn->nt_user_token) - token = conn->nt_user_token; - else - token = vuser->nt_user_token; + if (!psd) { + TALLOC_FREE(mem_ctx); + return True; + } ret = se_access_check(psd, token, desired_access, &granted, &status); -out: - talloc_destroy(mem_ctx); - return ret; } -- cgit From 4c713703d046f756989e7eb901e884829825593c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 17 Jul 2006 19:53:15 +0000 Subject: r17097: Move share_access_check from rpc_server/srv_srvsvc_nt.c to lib/sharesec.c (This used to be commit 220dd4333032aea238066e3fbec9fca51ed16ddf) --- source3/rpc_server/srv_srvsvc_nt.c | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 19099b931e..be4c51c0d2 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -316,37 +316,6 @@ static void map_generic_share_sd_bits(SEC_DESC *psd) } } -/******************************************************************* - Can this user access with share with the required permissions ? -********************************************************************/ - -BOOL share_access_check(const NT_USER_TOKEN *token, const char *sharename, - uint32 desired_access) -{ - uint32 granted; - NTSTATUS status; - TALLOC_CTX *mem_ctx = NULL; - SEC_DESC *psd = NULL; - size_t sd_size; - BOOL ret = True; - - if (!(mem_ctx = talloc_init("share_access_check"))) { - return False; - } - - psd = get_share_security(mem_ctx, sharename, &sd_size); - - if (!psd) { - TALLOC_FREE(mem_ctx); - return True; - } - - ret = se_access_check(psd, token, desired_access, &granted, &status); - - talloc_destroy(mem_ctx); - return ret; -} - /******************************************************************* Fill in a share info level 501 structure. ********************************************************************/ -- cgit From 9f6fb43eeefb18578040a0f3b5af941460ec5ca9 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 19 Jul 2006 20:59:04 +0000 Subject: r17150: MMC User & group plugins fixes: * Make sure to lower case all usernames before calling the create, delete, or rename hooks. * Preserve case for usernames in passdb * Flush the getpwnam cache after renaming a user * Add become/unbecome root block in _samr_delete_dom_user() when trying to verify the account's existence. (This used to be commit bbe11b7a950e7d85001f042bbd1ea3bf33ecda7b) --- source3/rpc_server/srv_samr_nt.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9c453b04a4..3a70c93a1c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2471,8 +2471,6 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, return NT_STATUS_NO_MEMORY; } - strlower_m(account); - nt_status = can_create(p->mem_ctx, account); if (!NT_STATUS_IS_OK(nt_status)) { return nt_status; @@ -3214,7 +3212,7 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, if ( ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || ( (acct_ctrl & ACB_WSTRUST) == ACB_WSTRUST) || ( (acct_ctrl & ACB_SVRTRUST) == ACB_SVRTRUST) ) { - DEBUG(5, ("Changing trust account or non-unix-user password, not updating /etc/passwd\n")); + DEBUG(5, ("Changing trust account. Not updating /etc/passwd\n")); } else { /* update the UNIX password */ if (lp_unix_password_sync() ) { @@ -3396,10 +3394,25 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - /* observed when joining an XP client to a Samba domain */ + /* This is tricky. A WinXP domain join sets + (SA_RIGHT_USER_SET_PASSWORD|SA_RIGHT_USER_SET_ATTRIBUTES|SA_RIGHT_USER_ACCT_FLAGS_EXPIRY) + The MMC lusrmgr plugin includes these perms and more in the SamrOpenUser(). But the + standard Win32 API calls just ask for SA_RIGHT_USER_SET_PASSWORD in the SamrOpenUser(). + This should be enough for levels 18, 24, 25,& 26. Info level 23 can set more so + we'll use the set from the WinXP join as the basis. */ + + switch (switch_value) { + case 18: + case 24: + case 25: + case 26: + acc_required = SA_RIGHT_USER_SET_PASSWORD; + break; + default: + acc_required = SA_RIGHT_USER_SET_PASSWORD | SA_RIGHT_USER_SET_ATTRIBUTES | SA_RIGHT_USER_ACCT_FLAGS_EXPIRY; + break; + } - acc_required = SA_RIGHT_USER_SET_PASSWORD | SA_RIGHT_USER_SET_ATTRIBUTES | SA_RIGHT_USER_ACCT_FLAGS_EXPIRY; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo"))) { return r_u->status; } @@ -4040,6 +4053,7 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM BOOL can_add_accounts; uint32 acb_info; DISP_INFO *disp_info = NULL; + BOOL ret; DEBUG(5, ("_samr_delete_dom_user: %d\n", __LINE__)); @@ -4059,7 +4073,11 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM return NT_STATUS_NO_MEMORY; } - if(!pdb_getsampwsid(sam_pass, &user_sid)) { + become_root(); + ret = pdb_getsampwsid(sam_pass, &user_sid); + unbecome_root(); + + if( !ret ) { DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n", sid_string_static(&user_sid))); TALLOC_FREE(sam_pass); -- cgit From e0c68d0a1d591e4285746a8af70040448752a735 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 21 Jul 2006 14:13:30 +0000 Subject: r17177: Get rid of a global variable by adding a private data pointer to share_mode_forall(). Volker (This used to be commit f97f6cedffdc4d10afcac90a163b93a801acf514) --- source3/rpc_server/srv_srvsvc_nt.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index be4c51c0d2..e4e5bde215 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -123,7 +123,8 @@ static WERROR net_enum_pipes( TALLOC_CTX *ctx, FILE_INFO_3 **info, static struct file_enum_count f_enum_cnt; static void enum_file_fn( const struct share_mode_entry *e, - const char *sharepath, const char *fname ) + const char *sharepath, const char *fname, + void *dummy ) { struct file_enum_count *fenum = &f_enum_cnt; @@ -191,7 +192,7 @@ static WERROR net_enum_files( TALLOC_CTX *ctx, FILE_INFO_3 **info, f_enum_cnt.count = *count; f_enum_cnt.info = *info; - share_mode_forall( enum_file_fn ); + share_mode_forall( enum_file_fn, NULL ); *info = f_enum_cnt.info; *count = f_enum_cnt.count; @@ -802,13 +803,11 @@ static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *sto /******************************************************************* ********************************************************************/ -/* global needed to make use of the share_mode_forall() callback */ -static struct sess_file_count s_file_cnt; - static void sess_file_fn( const struct share_mode_entry *e, - const char *sharepath, const char *fname ) + const char *sharepath, const char *fname, + void *private_data ) { - struct sess_file_count *sess = &s_file_cnt; + struct sess_file_count *sess = (struct sess_file_count *)private_data; if ( (procid_to_pid(&e->pid) == sess->pid) && (sess->uid == e->uid) ) { sess->count++; @@ -822,11 +821,13 @@ static void sess_file_fn( const struct share_mode_entry *e, static int net_count_files( uid_t uid, pid_t pid ) { + struct sess_file_count s_file_cnt; + s_file_cnt.count = 0; s_file_cnt.uid = uid; s_file_cnt.pid = pid; - share_mode_forall( sess_file_fn ); + share_mode_forall( sess_file_fn, (void *)&s_file_cnt ); return s_file_cnt.count; } -- cgit From efc7ac209da61d2bd389ccd3b8c8d6d6a6b53989 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 22 Jul 2006 00:53:19 +0000 Subject: r17183: LsaLookupSids() shoudl return the string form of a SID when it cannot be mapped and not the hex of the RID. Who wrote that? (This used to be commit 4e51cf34cf4cbe77957d754952369df3a180f974) --- source3/rpc_server/srv_lsa_nt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index b4b8876db0..0d8ec75150 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -873,8 +873,9 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, if (name->type == SID_NAME_UNKNOWN) { name->dom_idx = -1; - name->name = talloc_asprintf(p->mem_ctx, "%8.8x", - name->rid); + /* unknown sids should return the string representation of the SID */ + name->name = talloc_asprintf(p->mem_ctx, "%s", + sid_string_static(sids[i])); if (name->name == NULL) { return NT_STATUS_NO_MEMORY; } -- cgit From 19cc80b40f06a1c4d64b174b544c1631024c0034 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 22 Jul 2006 19:15:22 +0000 Subject: r17188: Dump lsa_lookupsids3. I could not make it work at all against W2k3, the rpc-lsa test even considers NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED not to be an error. Before someone re-activates this, show me a working sniff please :-) Volker (This used to be commit b185fb9fa61d89b612870c2fdd9e112c9e7ae57c) --- source3/rpc_server/srv_lsa_nt.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 0d8ec75150..f458f68b74 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1004,43 +1004,29 @@ NTSTATUS _lsa_lookup_sids2(pipes_struct *p, /*************************************************************************** _lsa_lookup_sida3 + + Before someone actually re-activates this, please present a sniff showing + this call against some Windows server. I (vl) could not make it work against + w2k3 at all. ***************************************************************************/ NTSTATUS _lsa_lookup_sids3(pipes_struct *p, LSA_Q_LOOKUP_SIDS3 *q_u, LSA_R_LOOKUP_SIDS3 *r_u) { - int num_sids = q_u->sids.num_entries; uint32 mapped_count = 0; - DOM_R_REF *ref = NULL; - LSA_TRANS_NAME_ENUM2 *names = NULL; + DOM_R_REF ref; + LSA_TRANS_NAME_ENUM2 names; if ((q_u->level < 1) || (q_u->level > 6)) { return NT_STATUS_INVALID_PARAMETER; } - /* No policy handle on this call. Restrict to crypto connections. */ - if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) { - DEBUG(0,("_lsa_lookup_sids3: client %s not using schannel for netlogon\n", - get_remote_machine_name() )); - return NT_STATUS_INVALID_PARAMETER; - } - - if (num_sids > MAX_LOOKUP_SIDS) { - DEBUG(5,("_lsa_lookup_sids3: limit of %d exceeded, requested %d\n", - MAX_LOOKUP_SIDS, num_sids)); - return NT_STATUS_NONE_MAPPED; - } - - r_u->status = _lsa_lookup_sids_internal(p, - q_u->level, - num_sids, - q_u->sids.sid, - &ref, - &names, - &mapped_count); + r_u->status = NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED; - init_reply_lookup_sids3(r_u, ref, names, mapped_count); + ZERO_STRUCT(ref); + ZERO_STRUCT(names); + init_reply_lookup_sids3(r_u, &ref, &names, mapped_count); return r_u->status; } -- cgit From e85be720a39c10724d5b6e50f794f5cf36648c2a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 22 Jul 2006 19:44:17 +0000 Subject: r17192: Make this actually survive valgrind. We NEED pidl here... Maybe bzr is not such a bad idea, then you would probably see less spam on samba-cvs, sorry for that... :-) Volker (This used to be commit 41456b498a181c70707ca1ea80288bd7bdcadcdf) --- source3/rpc_server/srv_lsa_nt.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f458f68b74..e609eac950 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1015,8 +1015,8 @@ NTSTATUS _lsa_lookup_sids3(pipes_struct *p, LSA_R_LOOKUP_SIDS3 *r_u) { uint32 mapped_count = 0; - DOM_R_REF ref; - LSA_TRANS_NAME_ENUM2 names; + DOM_R_REF *ref; + LSA_TRANS_NAME_ENUM2 *names; if ((q_u->level < 1) || (q_u->level > 6)) { return NT_STATUS_INVALID_PARAMETER; @@ -1024,9 +1024,16 @@ NTSTATUS _lsa_lookup_sids3(pipes_struct *p, r_u->status = NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED; - ZERO_STRUCT(ref); - ZERO_STRUCT(names); - init_reply_lookup_sids3(r_u, &ref, &names, mapped_count); + ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); + names = TALLOC_ZERO_P(p->mem_ctx, LSA_TRANS_NAME_ENUM2); + + if ((ref == NULL) || (names == NULL)) { + /* We would segfault later on in lsa_io_r_lookup_sids3 anyway, + * so do a planned exit here. We NEEEED pidl! */ + smb_panic("talloc failed"); + } + + init_reply_lookup_sids3(r_u, ref, names, mapped_count); return r_u->status; } -- cgit From dc833fa69413dd2747c2730bf051b1c54c064698 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 22 Jul 2006 20:46:02 +0000 Subject: r17194: To run rpc-samba3-lsa in the build farm, we can't rely on geteuid()==0. Adapt it to other "Am I root?" checks. Jerry, Jeremy, please check this! Thanks, Volker (This used to be commit f777b2d294f7258e676976d7807adbb644c85a2f) --- source3/rpc_server/srv_lsa_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index e609eac950..04747406d4 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -544,7 +544,7 @@ NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL lsa_get_generic_sd(p->mem_ctx, &psd, &sd_size); if(!se_access_check(psd, p->pipe_user.nt_user_token, des_access, &acc_granted, &status)) { - if (geteuid() != 0) { + if (p->pipe_user.ut.uid != sec_initial_uid()) { return status; } DEBUG(4,("ACCESS should be DENIED (granted: %#010x; required: %#010x)\n", @@ -554,7 +554,7 @@ NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL /* This is needed for lsa_open_account and rpcclient .... :-) */ - if (geteuid() == 0) + if (p->pipe_user.ut.uid == sec_initial_uid()) acc_granted = POLICY_ALL_ACCESS; /* associate the domain SID with the (unique) handle. */ -- cgit From aac411b7dddefeafc0762dade882a769fc99069e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 23 Jul 2006 08:18:31 +0000 Subject: r17199: Add comment to the RID/SID miracle (This used to be commit 4c4ae01c671bd35687af686a34824a96828e6b25) --- source3/rpc_server/srv_lsa_nt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 04747406d4..41df870414 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -873,7 +873,12 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, if (name->type == SID_NAME_UNKNOWN) { name->dom_idx = -1; - /* unknown sids should return the string representation of the SID */ + /* Unknown sids should return the string + * representation of the SID. Windows 2003 behaves + * rather erratic here, in many cases it returns the + * RID as 8 bytes hex, in others it returns the full + * SID. We (Jerry/VL) could not figure out which the + * hard cases are, so leave it with the SID. */ name->name = talloc_asprintf(p->mem_ctx, "%s", sid_string_static(sids[i])); if (name->name == NULL) { -- cgit From 8cc35cc8da75f1e831f0b84fc667ec0c9bff6b4b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 24 Jul 2006 12:05:20 +0000 Subject: r17217: Fix a couple of "smbldap_open(): Cannot open when not root" bugs when viewing or modifying local group membership. (This used to be commit 41e30a9666e1fb736cd2ba8a5ad9285fcde50d47) --- source3/rpc_server/srv_samr_nt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 3a70c93a1c..bb5e7dbce4 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3771,7 +3771,9 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ DEBUG(10, ("sid is %s\n", sid_string_static(&alias_sid))); + become_root(); status = pdb_enum_aliasmem(&alias_sid, &sids, &num_sids); + unbecome_root(); if (!NT_STATUS_IS_OK(status)) { return status; @@ -4602,7 +4604,11 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ /* get the current group information */ - if ( !pdb_get_aliasinfo( &group_sid, &info ) ) { + become_root(); + ret = pdb_get_aliasinfo( &group_sid, &info ); + unbecome_root(); + + if ( !ret ) { return NT_STATUS_NO_SUCH_ALIAS; } -- cgit From 9d4fa2b27b746d6a5716bfa049b2a1ee191ba6d5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 25 Jul 2006 21:23:34 +0000 Subject: r17244: There were several error paths where NT_PRINTER_INFO_LEVEL wasn't being freed - also one enum jobs case where the NT_PRINTER_INFO_LEVEL and queue weren't being freed. Strange that Coverity or Klokwork didn't pick these up. Hopefully will fix #3962. Jeremy. (This used to be commit bb264123872bfec42ad85ec0c8afa3a8c7d1811e) --- source3/rpc_server/srv_spoolss_nt.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3dbad208cc..db098e74be 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -441,7 +441,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) const char *servername; fstring sname; BOOL found=False; - NT_PRINTER_INFO_LEVEL *printer; + NT_PRINTER_INFO_LEVEL *printer = NULL; WERROR result; DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename, (unsigned long)strlen(handlename))); @@ -532,6 +532,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) printername++; if ( strequal(printername, aprinter) ) { + free_a_printer( &printer, 2); found = True; break; } @@ -541,6 +542,8 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) free_a_printer( &printer, 2); } + free_a_printer( &printer, 2); + if ( !found ) { DEBUGADD(4,("Printer not found\n")); return False; @@ -3551,6 +3554,7 @@ static BOOL construct_notify_printer_info(Printer_entry *print_hnd, SPOOL_NOTIFY if((info->data=SMB_REALLOC_ARRAY(info->data, SPOOL_NOTIFY_INFO_DATA, info->count+1)) == NULL) { DEBUG(2,("construct_notify_printer_info: failed to enlarge buffer info->data!\n")); + free_a_printer(&printer, 2); return False; } @@ -4181,6 +4185,7 @@ static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 ** *pp_printer = NULL; if ((printer = SMB_MALLOC_P(PRINTER_INFO_3)) == NULL) { DEBUG(2,("construct_printer_info_3: malloc fail.\n")); + free_a_printer(&ntprinter, 2); return False; } @@ -4983,8 +4988,10 @@ static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fst if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum)))) return WERR_INVALID_PRINTER_NAME; - if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) + if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) { + free_a_printer(&printer, 2); return WERR_UNKNOWN_PRINTER_DRIVER; + } fill_printer_driver_info_1(info, driver, servername, architecture); @@ -5043,8 +5050,10 @@ static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fst if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum)))) return WERR_INVALID_PRINTER_NAME; - if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) + if (!W_ERROR_IS_OK(get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version))) { + free_a_printer(&printer, 2); return WERR_UNKNOWN_PRINTER_DRIVER; + } fill_printer_driver_info_2(info, driver, servername); @@ -6611,22 +6620,24 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO if (*returned == 0) { SAFE_FREE(queue); + free_a_printer(&ntprinter, 2); return WERR_OK; } switch (level) { case 1: wret = enumjobs_level1(queue, snum, ntprinter, buffer, offered, needed, returned); - return wret; + break; case 2: wret = enumjobs_level2(queue, snum, ntprinter, buffer, offered, needed, returned); - return wret; + break; default: - SAFE_FREE(queue); *returned=0; wret = WERR_UNKNOWN_LEVEL; + break; } + SAFE_FREE(queue); free_a_printer( &ntprinter, 2 ); return wret; } -- cgit From 29a4d666bad176483a5a346d24dc1b044bf67b2b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 25 Jul 2006 21:33:13 +0000 Subject: r17245: Second part of fix for #3962. Don't do a double free in the infolevel2 case. Free both queue and NT_PRINTER_INFO_LEVEL in the same place. Jeremy. (This used to be commit 6ac3a4ce78f42949013ae7bd675ff292fb0383ca) --- source3/rpc_server/srv_spoolss_nt.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index db098e74be..cd0a4f2bb3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6395,9 +6395,9 @@ WERROR _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u /**************************************************************************** ****************************************************************************/ -static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, +static void fill_job_info_1(JOB_INFO_1 *job_info, const print_queue_struct *queue, int position, int snum, - NT_PRINTER_INFO_LEVEL *ntprinter) + const NT_PRINTER_INFO_LEVEL *ntprinter) { struct tm *t; @@ -6422,9 +6422,9 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, /**************************************************************************** ****************************************************************************/ -static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, +static BOOL fill_job_info_2(JOB_INFO_2 *job_info, const print_queue_struct *queue, int position, int snum, - NT_PRINTER_INFO_LEVEL *ntprinter, + const NT_PRINTER_INFO_LEVEL *ntprinter, DEVICEMODE *devmode) { struct tm *t; @@ -6467,8 +6467,8 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, Enumjobs at level 1. ****************************************************************************/ -static WERROR enumjobs_level1(print_queue_struct *queue, int snum, - NT_PRINTER_INFO_LEVEL *ntprinter, +static WERROR enumjobs_level1(const print_queue_struct *queue, int snum, + const NT_PRINTER_INFO_LEVEL *ntprinter, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { @@ -6478,7 +6478,6 @@ static WERROR enumjobs_level1(print_queue_struct *queue, int snum, info=SMB_MALLOC_ARRAY(JOB_INFO_1,*returned); if (info==NULL) { - SAFE_FREE(queue); *returned=0; return WERR_NOMEM; } @@ -6486,8 +6485,6 @@ static WERROR enumjobs_level1(print_queue_struct *queue, int snum, for (i=0; i<*returned; i++) fill_job_info_1( &info[i], &queue[i], i, snum, ntprinter ); - SAFE_FREE(queue); - /* check the required size. */ for (i=0; i<*returned; i++) (*needed) += spoolss_size_job_info_1(&info[i]); @@ -6520,8 +6517,8 @@ out: Enumjobs at level 2. ****************************************************************************/ -static WERROR enumjobs_level2(print_queue_struct *queue, int snum, - NT_PRINTER_INFO_LEVEL *ntprinter, +static WERROR enumjobs_level2(const print_queue_struct *queue, int snum, + const NT_PRINTER_INFO_LEVEL *ntprinter, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { @@ -6542,9 +6539,6 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, for (i=0; i<*returned; i++) fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter, devmode); - free_a_printer(&ntprinter, 2); - SAFE_FREE(queue); - /* check the required size. */ for (i=0; i<*returned; i++) (*needed) += spoolss_size_job_info_2(&info[i]); -- cgit From a093a76dc14303fd1c42fb2c0b87faf3748815e4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 28 Jul 2006 22:42:39 +0000 Subject: r17293: After the results from the cluster tests in Germany, fix the messaging code to call the efficient calls : save_re_uid() set_effective_uid(0); messaging_op restore_re_uid(); instead of using heavyweight become_root()/unbecome_root() pairs around all messaging code. Fixup the messaging code to ensure sec_init() is called (only once) so that non-root processes still work when sending messages. This is a lighter weight solution to become_root()/unbecome_root() (which swaps all the supplemental groups) and should be more efficient. I will migrate all server code over to using this (a similar technique should be used in the passdb backend where needed). Jeremy. (This used to be commit 4ace291278d9a44f5c577bdd3b282c1231e543df) --- source3/rpc_server/srv_srvsvc_nt.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index e4e5bde215..de3148aae8 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1303,7 +1303,6 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES int num_sessions, snum; fstring username; fstring machine; - BOOL not_root = False; rpcstr_pull_unistr2_fstring(username, &q_u->uni_user_name); rpcstr_pull_unistr2_fstring(machine, &q_u->uni_cli_name); @@ -1332,16 +1331,8 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES if ((strequal(session_list[snum].username, username) || username[0] == '\0' ) && strequal(session_list[snum].remote_machine, machine)) { - if (p->pipe_user.ut.uid != sec_initial_uid()) { - not_root = True; - become_root(); - } - if (message_send_pid(pid_to_procid(session_list[snum].pid), MSG_SHUTDOWN, NULL, 0, False)) r_u->status = WERR_OK; - - if (not_root) - unbecome_root(); } } -- cgit From e23781b3b304d1e69ad80af5ae9c0ed8d02cf996 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 30 Jul 2006 16:36:56 +0000 Subject: r17316: More C++ warnings -- 456 left (This used to be commit 1e4ee728df7eeafc1b4d533240acb032f73b4f5c) --- source3/rpc_server/srv_eventlog_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 66be1dc34f..c853f932ae 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -90,7 +90,7 @@ struct trav_size_struct { static int eventlog_tdb_size_fn( TDB_CONTEXT * tdb, TDB_DATA key, TDB_DATA data, void *state ) { - struct trav_size_struct *tsize = state; + struct trav_size_struct *tsize = (struct trav_size_struct *)state; tsize->size += data.dsize; tsize->rec_count++; @@ -486,7 +486,7 @@ int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ) } /* alloc mem for the packed version */ - packed_ee = TALLOC( mem_ctx, ee->record.length + MARGIN ); + packed_ee = (uint8 *)TALLOC( mem_ctx, ee->record.length + MARGIN ); if ( !packed_ee ) { talloc_destroy( mem_ctx ); return 0; -- cgit From 49001a5b1b07e9a24e5f7efa0dfd880772bdb435 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 31 Jul 2006 20:58:02 +0000 Subject: r17346: Add optimisation vl needs for the cluster code where we don't get the chainlock when getting the byte range lock record read-only. Jeremy. (This used to be commit fcd798ca0c1b76adb2bcda4a99c40c7aacb0addb) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index de3148aae8..609c819a7d 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -152,7 +152,7 @@ static void enum_file_fn( const struct share_mode_entry *e, fsp.dev = e->dev; fsp.inode = e->inode; - if ( (brl = brl_get_locks(NULL,&fsp)) != NULL ) { + if ( (brl = brl_get_locks_readonly(NULL,&fsp)) != NULL ) { num_locks = brl->num_locks; TALLOC_FREE( brl ); } -- cgit From 430fa0eba08cbf180d83740a895a0018af1c7f21 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 31 Jul 2006 21:40:25 +0000 Subject: r17348: Some C++ warnings (This used to be commit ae6b9b34e59167e3958bfdb9997fa25340b9a0a3) --- source3/rpc_server/srv_echo_nt.c | 4 ++-- source3/rpc_server/srv_pipe.c | 7 ++++--- source3/rpc_server/srv_spoolss_nt.c | 20 ++++++++++++-------- 3 files changed, 18 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_echo_nt.c b/source3/rpc_server/srv_echo_nt.c index 86fcce28c7..c861c74cc6 100644 --- a/source3/rpc_server/srv_echo_nt.c +++ b/source3/rpc_server/srv_echo_nt.c @@ -44,7 +44,7 @@ void _echo_data(pipes_struct *p, ECHO_Q_ECHO_DATA *q_u, { DEBUG(10, ("_echo_data\n")); - r_u->data = TALLOC(p->mem_ctx, q_u->size); + r_u->data = (char *)TALLOC(p->mem_ctx, q_u->size); r_u->size = q_u->size; memcpy(r_u->data, q_u->data, q_u->size); } @@ -68,7 +68,7 @@ void _source_data(pipes_struct *p, ECHO_Q_SOURCE_DATA *q_u, DEBUG(10, ("_source_data\n")); - r_u->data = TALLOC(p->mem_ctx, q_u->size); + r_u->data = (char *)TALLOC(p->mem_ctx, q_u->size); r_u->size = q_u->size; for (i = 0; i < r_u->size; i++) diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index e2c5e865ed..74583f075b 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -679,8 +679,9 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) p->pipe_user.ut.ngroups = a->server_info->n_groups; if (p->pipe_user.ut.ngroups) { - if (!(p->pipe_user.ut.groups = memdup(a->server_info->groups, - sizeof(gid_t) * p->pipe_user.ut.ngroups))) { + if (!(p->pipe_user.ut.groups = (gid_t *) + memdup(a->server_info->groups, + sizeof(gid_t) * p->pipe_user.ut.ngroups))) { DEBUG(0,("pipe_ntlmssp_verify_final: failed to memdup group list to p->pipe_user.groups\n")); data_blob_free(&p->session_key); return False; @@ -2322,7 +2323,7 @@ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, if ((DEBUGLEVEL >= 10) && (prs_offset(&p->in_data.data) != prs_data_size(&p->in_data.data))) { size_t data_len = prs_data_size(&p->in_data.data) - prs_offset(&p->in_data.data); - char *data = SMB_MALLOC(data_len); + char *data = (char *)SMB_MALLOC(data_len); DEBUG(10, ("api_rpcTNP: rpc input buffer underflow (parse error?)\n")); if (data) { diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cd0a4f2bb3..fc25614963 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -719,7 +719,8 @@ static void notify_system_time(struct spoolss_notify_msg *msg, } data->notify_data.data.length = prs_offset(&ps); - data->notify_data.data.string = TALLOC(mem_ctx, prs_offset(&ps)); + data->notify_data.data.string = (uint16 *) + TALLOC(mem_ctx, prs_offset(&ps)); if (!data->notify_data.data.string) { prs_mem_free(&ps); return; @@ -911,7 +912,8 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS /* need to allocate own copy of data */ if ( msg->len != 0 ) - msg_grp->msgs[new_slot].notify.data = TALLOC_MEMDUP( ctr->ctx, msg->notify.data, msg->len ); + msg_grp->msgs[new_slot].notify.data = (char *) + TALLOC_MEMDUP( ctr->ctx, msg->notify.data, msg->len ); return ctr->num_groups; } @@ -1220,7 +1222,7 @@ void do_drv_upgrade_printer(int msg_type, struct process_id src, void *buf, size int n_services = lp_numservices(); len = MIN(len,sizeof(drivername)-1); - strncpy(drivername, buf, len); + strncpy(drivername, (const char *)buf, len); DEBUG(10,("do_drv_upgrade_printer: Got message for new driver [%s]\n", drivername )); @@ -1318,7 +1320,7 @@ void reset_all_printerdata(int msg_type, struct process_id src, int n_services = lp_numservices(); len = MIN( len, sizeof(drivername)-1 ); - strncpy( drivername, buf, len ); + strncpy( drivername, (const char *)buf, len ); DEBUG(10,("reset_all_printerdata: Got message for new driver [%s]\n", drivername )); @@ -1381,7 +1383,7 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode) /* bulk copy first */ - d = TALLOC_MEMDUP(ctx, devmode, sizeof(DEVICEMODE)); + d = (DEVICEMODE *)TALLOC_MEMDUP(ctx, devmode, sizeof(DEVICEMODE)); if (!d) return NULL; @@ -1408,7 +1410,8 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode) return NULL; } - d->dev_private = TALLOC_MEMDUP(ctx, devmode->dev_private, devmode->driverextra); + d->dev_private = (uint8 *)TALLOC_MEMDUP(ctx, devmode->dev_private, + devmode->driverextra); if (!d->dev_private) { return NULL; } @@ -9046,7 +9049,8 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, */ set_printer_dataex( printer, keyname, valuename, - REG_SZ, (void*)oid_string, strlen(oid_string)+1 ); + REG_SZ, (uint8 *)oid_string, + strlen(oid_string)+1 ); } status = mod_a_printer(printer, 2); @@ -9336,7 +9340,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ data_len = regval_size( val ); if ( data_len ) { - if ( !(enum_values[i].data = TALLOC_MEMDUP(p->mem_ctx, regval_data_p(val), data_len)) ) + if ( !(enum_values[i].data = (uint8 *)TALLOC_MEMDUP(p->mem_ctx, regval_data_p(val), data_len)) ) { DEBUG(0,("talloc_memdup failed to allocate memory [data_len=%d] for data!\n", data_len )); -- cgit From 8eebd925b26c4592eba1773a94379f891ead6144 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 1 Aug 2006 14:46:08 +0000 Subject: r17364: Another NT4 join bug: The idealx tools set the primary group sid, and if we do an update_sam_account later on, we want to also set it using the delete/add method. As the idealx tools use the replace method, they don't care about what has been in there before. Jerry, this is a likely 3.0.23b candidate. Not merging, it's your call :-) Volker (This used to be commit f002a3633892fc040f0a6d076723c660bb82a41a) --- source3/rpc_server/srv_samr_nt.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index bb5e7dbce4..ec3630ec26 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3338,13 +3338,20 @@ static NTSTATUS set_user_info_25(TALLOC_CTX *mem_ctx, SAM_USER_INFO_25 *id25, copy_id25_to_sam_passwd(pwd, id25); + /* write the change out */ + if(!NT_STATUS_IS_OK(status = pdb_update_sam_account(pwd))) { + TALLOC_FREE(pwd); + return status; + } + /* - * 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 + * We need to "pdb_update_sam_account" before the unix primary group + * is set, because the idealx scripts would also change the + * sambaPrimaryGroupSid using the ldap replace method. pdb_ldap uses + * the delete explicit / add explicit, which would then fail to find + * the previous primaryGroupSid value. */ - + if ( IS_SAM_CHANGED(pwd, PDB_GROUPSID) ) { status = pdb_set_unix_primary_group(mem_ctx, pwd); if ( !NT_STATUS_IS_OK(status) ) { @@ -3352,16 +3359,6 @@ static NTSTATUS set_user_info_25(TALLOC_CTX *mem_ctx, SAM_USER_INFO_25 *id25, } } - /* Don't worry about writing out the user account since the - primary group SID is generated solely from the user's Unix - primary group. */ - - /* write the change out */ - if(!NT_STATUS_IS_OK(status = pdb_update_sam_account(pwd))) { - TALLOC_FREE(pwd); - return status; - } - /* WARNING: No TALLOC_FREE(pwd), we are about to set the password * hereafter! */ -- cgit From 22c9a3151e1aba83b6a72612440a230fd70f1e5a Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 3 Aug 2006 15:19:01 +0000 Subject: r17386: fix inverted logic pointed out by Volker. When deleting a printer return access denied if the printer still exists after the delete_printer_hook() is called (This used to be commit c05e2bdc0c068eb832035daea7962ab1a9e787b2) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index fc25614963..6548bf3c6d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -331,7 +331,7 @@ WERROR delete_printer_hook( NT_USER_TOKEN *token, const char *sharename ) /* go ahead and re-read the services immediately */ reload_services( False ); - if ( !share_defined( sharename ) ) + if ( share_defined( sharename ) ) return WERR_ACCESS_DENIED; return WERR_OK; -- cgit From 6cab0fbb8b8bc1aadbc4c76d9759983eeb18b9fb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 7 Aug 2006 15:41:43 +0000 Subject: r17439: Fix logic error in checking TALLOC return. Spotted by Volker. Jeremy. (This used to be commit 06aea05c52ee770a2dd6465e9e2fcd0ccd8c811d) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ec3630ec26..31e434cbfb 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1645,7 +1645,7 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, enum SID_NAME_USE, num_rids); wire_attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_rids); - if ((num_rids != 0) && ((names == NULL) || (attrs == NULL) || wire_attrs)) + if ((num_rids != 0) && ((names == NULL) || (attrs == NULL) || (wire_attrs==NULL))) return NT_STATUS_NO_MEMORY; become_root(); /* lookup_sid can require root privs */ -- cgit From ff7c0a7c357ab8a0ff9de6d18988933e0b398780 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 8 Aug 2006 08:26:40 +0000 Subject: r17451: Change pdb_getgrsid not to take a DOM_SID but a const DOM_SID * as an argument. Volker (This used to be commit 873a5a1211d185fd50e7167d88cbc869f70dfd3f) --- source3/rpc_server/srv_lsa_nt.c | 2 +- source3/rpc_server/srv_samr_nt.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 41df870414..33cbba933f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1730,7 +1730,7 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) return NT_STATUS_ACCESS_DENIED; - if (!pdb_getgrsid(&map, info->sid)) + if (!pdb_getgrsid(&map, &info->sid)) return NT_STATUS_NO_SUCH_GROUP; return pdb_update_group_mapping_entry(&map); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 31e434cbfb..0835da4908 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4438,7 +4438,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM } become_root(); - ret = get_domain_group_from_sid(group_sid, &map); + ret = get_domain_group_from_sid(&group_sid, &map); unbecome_root(); if (!ret) return NT_STATUS_INVALID_HANDLE; @@ -4535,7 +4535,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ } become_root(); - result = get_domain_group_from_sid(group_sid, &map); + result = get_domain_group_from_sid(&group_sid, &map); unbecome_root(); if (!result) return NT_STATUS_NO_SUCH_GROUP; @@ -4754,7 +4754,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G /* check if that group really exists */ become_root(); - ret = get_domain_group_from_sid(info->sid, &map); + ret = get_domain_group_from_sid(&info->sid, &map); unbecome_root(); if (!ret) return NT_STATUS_NO_SUCH_GROUP; -- cgit From 11673dc07a137e911de3920f0ee6717b365f2ab4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 8 Aug 2006 11:00:16 +0000 Subject: r17453: Fix msdfs RPC management (this broke with the autogenerated dfs rpcs). * Remove "unknown" from dfs_Enum (samba4 dfs IDL updates to follow). * When encountering an unsupported infolevel the rpc server must reply with a dfs_info_0 structure and WERR_OK (observed from w2k3 when talking to nt4). Guenther (This used to be commit f9bef1f08f7d2a4c95c28329ac73e8646f033998) --- source3/rpc_server/srv_dfs_nt.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index c7f8e05d91..abdd9e8f23 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -200,6 +200,7 @@ static BOOL init_reply_dfs_info_2(struct junction_map* j, NETDFS_DFS_INFO2* dfs2 j->service_name, j->volume_name); init_unistr2(&dfs2->path, str, UNI_STR_TERMINATE); dfs2->ptr0_comment = 0; + init_unistr2(&dfs2->comment, j->comment, UNI_STR_TERMINATE); dfs2->state = 1; /* set up state of dfs junction as OK */ dfs2->num_stores = j->referral_count; return True; @@ -219,7 +220,7 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, NETDF init_unistr2(&dfs3->path, str, UNI_STR_TERMINATE); dfs3->ptr0_comment = 1; - init_unistr2(&dfs3->comment, "", UNI_STR_TERMINATE); + init_unistr2(&dfs3->comment, j->comment, UNI_STR_TERMINATE); dfs3->state = 1; dfs3->num_stores = dfs3->size_stores = j->referral_count; dfs3->ptr0_stores = 1; @@ -254,6 +255,14 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, NETDF return True; } +static BOOL init_reply_dfs_info_100(struct junction_map* j, NETDFS_DFS_INFO100* dfs100) +{ + dfs100->ptr0_comment = 1; + init_unistr2(&dfs100->comment, j->comment, UNI_STR_TERMINATE); + return True; +} + + WERROR _dfs_Enum(pipes_struct *p, NETDFS_Q_DFS_ENUM *q_u, NETDFS_R_DFS_ENUM *r_u) { uint32 level = q_u->level; @@ -264,7 +273,7 @@ WERROR _dfs_Enum(pipes_struct *p, NETDFS_Q_DFS_ENUM *q_u, NETDFS_R_DFS_ENUM *r_u num_jn = enum_msdfs_links(p->mem_ctx, jn, ARRAY_SIZE(jn)); vfs_ChDir(p->conn,p->conn->connectpath); - DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", num_jn, level)); + DEBUG(5,("_dfs_Enum: %d junctions found in Dfs, doing level %d\n", num_jn, level)); r_u->ptr0_info = q_u->ptr0_info; r_u->ptr0_total = q_u->ptr0_total; @@ -330,7 +339,7 @@ WERROR _dfs_GetInfo(pipes_struct *p, NETDFS_Q_DFS_GETINFO *q_u, uint32 level = q_u->level; int consumedcnt = sizeof(pstring); pstring path; - BOOL ret; + BOOL ret = False; struct junction_map jn; unistr2_to_ascii(path, uni_path, sizeof(path)-1); @@ -352,8 +361,12 @@ WERROR _dfs_GetInfo(pipes_struct *p, NETDFS_Q_DFS_GETINFO *q_u, case 1: ret = init_reply_dfs_info_1(&jn, &r_u->info.u.info1); break; case 2: ret = init_reply_dfs_info_2(&jn, &r_u->info.u.info2); break; case 3: ret = init_reply_dfs_info_3(p->mem_ctx, &jn, &r_u->info.u.info3); break; + case 100: ret = init_reply_dfs_info_100(&jn, &r_u->info.u.info100); break; default: - ret = False; + r_u->info.ptr0 = 1; + r_u->info.switch_value = 0; + r_u->status = WERR_OK; + ret = True; break; } -- cgit From e1e62d89999629d41cc2b66b12eb37ce190d5db0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 8 Aug 2006 19:29:34 +0000 Subject: r17463: A bit of cleanup work: Remove some unused code: pdb_find_alias is not used anymore, and nobody I think has ever used the pdb_nop operations for group mapping. smbpasswd and tdb use the default ones and ldap has its own. Make the functions pdb_getgr* return NTSTATUS instead of BOOL. Nobody right now really makes use of it, but it feels wrong to throw away information so early. Volker (This used to be commit f9856f6490fe44fdba97ea86062237d8c74d4bdc) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 33cbba933f..adccc76275 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1730,7 +1730,7 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) return NT_STATUS_ACCESS_DENIED; - if (!pdb_getgrsid(&map, &info->sid)) + if (!NT_STATUS_IS_OK(pdb_getgrsid(&map, &info->sid))) return NT_STATUS_NO_SUCH_GROUP; return pdb_update_group_mapping_entry(&map); -- cgit From 76362d0d33892df39c0a370f1f64c8581daaf166 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 9 Aug 2006 15:25:26 +0000 Subject: r17468: To minimize the diff later on, pre-commit some changes independently: Change internal mapping.c functions to return NTSTATUS instead of BOOL. Volker (This used to be commit 4ebfc30a28a6f48613098176c5acdfdafbd2941a) --- source3/rpc_server/srv_samr_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 0835da4908..a70a49652e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4438,7 +4438,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM } become_root(); - ret = get_domain_group_from_sid(&group_sid, &map); + ret = NT_STATUS_IS_OK(get_domain_group_from_sid(&group_sid, &map)); unbecome_root(); if (!ret) return NT_STATUS_INVALID_HANDLE; @@ -4535,7 +4535,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ } become_root(); - result = get_domain_group_from_sid(&group_sid, &map); + result = NT_STATUS_IS_OK(get_domain_group_from_sid(&group_sid, &map)); unbecome_root(); if (!result) return NT_STATUS_NO_SUCH_GROUP; @@ -4754,7 +4754,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G /* check if that group really exists */ become_root(); - ret = get_domain_group_from_sid(&info->sid, &map); + ret = NT_STATUS_IS_OK(get_domain_group_from_sid(&info->sid, &map)); unbecome_root(); if (!ret) return NT_STATUS_NO_SUCH_GROUP; -- cgit From 03e3cd1d5a005ad5fd2bc97f9863abf675efd09f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 15 Aug 2006 14:07:15 +0000 Subject: r17554: Cleanup (This used to be commit 761cbd52f0cff6b864c506ec03c94039b6101ef9) --- source3/rpc_server/srv_lsa_nt.c | 2 +- source3/rpc_server/srv_samr_nt.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index adccc76275..41df870414 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1730,7 +1730,7 @@ NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) return NT_STATUS_ACCESS_DENIED; - if (!NT_STATUS_IS_OK(pdb_getgrsid(&map, &info->sid))) + if (!pdb_getgrsid(&map, info->sid)) return NT_STATUS_NO_SUCH_GROUP; return pdb_update_group_mapping_entry(&map); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a70a49652e..31e434cbfb 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4438,7 +4438,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM } become_root(); - ret = NT_STATUS_IS_OK(get_domain_group_from_sid(&group_sid, &map)); + ret = get_domain_group_from_sid(group_sid, &map); unbecome_root(); if (!ret) return NT_STATUS_INVALID_HANDLE; @@ -4535,7 +4535,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ } become_root(); - result = NT_STATUS_IS_OK(get_domain_group_from_sid(&group_sid, &map)); + result = get_domain_group_from_sid(group_sid, &map); unbecome_root(); if (!result) return NT_STATUS_NO_SUCH_GROUP; @@ -4754,7 +4754,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G /* check if that group really exists */ become_root(); - ret = NT_STATUS_IS_OK(get_domain_group_from_sid(&info->sid, &map)); + ret = get_domain_group_from_sid(info->sid, &map); unbecome_root(); if (!ret) return NT_STATUS_NO_SUCH_GROUP; -- cgit From 6717e0d467bea50cb7712e6b5278ddb403fdf828 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 24 Aug 2006 12:49:18 +0000 Subject: r17797: Just say "ok" when trying to rename a local group to its same name. (This used to be commit e6e54125003373f83e6900668ceb9981e8620776) --- source3/rpc_server/srv_samr_nt.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 31e434cbfb..67fa7f283c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4612,7 +4612,7 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ switch (ctr->level) { case 2: { - fstring group_name; + fstring group_name, acct_name; NTSTATUS status; /* We currently do not support renaming groups in the @@ -4624,12 +4624,19 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ return NT_STATUS_SPECIAL_ACCOUNT; } - /* There has to be a valid name */ + /* There has to be a valid name (and it has to be different) */ + if ( !ctr->alias.info2.name.string ) return NT_STATUS_INVALID_PARAMETER; - unistr2_to_ascii( info.acct_name, ctr->alias.info2.name.string, - sizeof(info.acct_name)-1 ); + unistr2_to_ascii( acct_name, ctr->alias.info2.name.string, + sizeof(acct_name)-1 ); + + /* If the name is the same just reply "ok". Yes this + doesn't allow you to change the case of a group name. */ + + if ( strequal( acct_name, info.acct_name ) ) + return NT_STATUS_OK; /* make sure the name doesn't already exist as a user or local group */ -- cgit From b65eb11a2ec568c9caa0510918cefaad3fa22703 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 28 Aug 2006 04:52:36 +0000 Subject: r17872: Fix possible null deref found by the Stanford checker. Jeremy. (This used to be commit ac06fc42cb9b1e2304d44653614aeaa7c537f34b) --- source3/rpc_server/srv_srvsvc_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 609c819a7d..3e79b420a9 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -771,7 +771,9 @@ static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *sto (*stot) = list_sessions(&session_list); if (ss0 == NULL) { - (*snum) = 0; + if (snum) { + (*snum) = 0; + } SAFE_FREE(session_list); return; } -- cgit From 995205fc60f87e1a02aa1c6f309db55ae18e908a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 6 Sep 2006 18:32:20 +0000 Subject: r18188: merge 3.0-libndr branch (This used to be commit 1115745caed3093c25d6be01ffee21819fb0a675) --- source3/rpc_server/srv_samr_util.c | 36 ++++++++++++++++++------------------ source3/rpc_server/srv_spoolss_nt.c | 3 +-- source3/rpc_server/srv_unixinfo_nt.c | 27 ++++++++++----------------- 3 files changed, 29 insertions(+), 37 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index c4bec79c9c..4fbd9d07d2 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -76,7 +76,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) return; if (from->fields_present & ACCT_LAST_LOGON) { - unix_time=nt_time_to_unix(&from->logon_time); + unix_time=nt_time_to_unix(from->logon_time); stored_time = pdb_get_logon_time(to); DEBUG(10,("INFO_21 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -84,7 +84,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_LAST_LOGOFF) { - unix_time=nt_time_to_unix(&from->logoff_time); + unix_time=nt_time_to_unix(from->logoff_time); stored_time = pdb_get_logoff_time(to); DEBUG(10,("INFO_21 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -92,7 +92,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_EXPIRY) { - unix_time=nt_time_to_unix(&from->kickoff_time); + unix_time=nt_time_to_unix(from->kickoff_time); stored_time = pdb_get_kickoff_time(to); DEBUG(10,("INFO_21 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -100,7 +100,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_ALLOW_PWD_CHANGE) { - unix_time=nt_time_to_unix(&from->pass_can_change_time); + unix_time=nt_time_to_unix(from->pass_can_change_time); stored_time = pdb_get_pass_can_change_time(to); DEBUG(10,("INFO_21 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -108,7 +108,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_LAST_PWD_CHANGE) { - unix_time=nt_time_to_unix(&from->pass_last_set_time); + unix_time=nt_time_to_unix(from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); DEBUG(10,("INFO_21 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -116,7 +116,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_FORCE_PWD_CHANGE) { - unix_time=nt_time_to_unix(&from->pass_must_change_time); + unix_time=nt_time_to_unix(from->pass_must_change_time); stored_time=pdb_get_pass_must_change_time(to); DEBUG(10,("INFO_21 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -324,7 +324,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) return; if (from->fields_present & ACCT_LAST_LOGON) { - unix_time=nt_time_to_unix(&from->logon_time); + unix_time=nt_time_to_unix(from->logon_time); stored_time = pdb_get_logon_time(to); DEBUG(10,("INFO_23 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -332,7 +332,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) } if (from->fields_present & ACCT_LAST_LOGOFF) { - unix_time=nt_time_to_unix(&from->logoff_time); + unix_time=nt_time_to_unix(from->logoff_time); stored_time = pdb_get_logoff_time(to); DEBUG(10,("INFO_23 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -340,7 +340,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) } if (from->fields_present & ACCT_EXPIRY) { - unix_time=nt_time_to_unix(&from->kickoff_time); + unix_time=nt_time_to_unix(from->kickoff_time); stored_time = pdb_get_kickoff_time(to); DEBUG(10,("INFO_23 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -348,7 +348,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) } if (from->fields_present & ACCT_ALLOW_PWD_CHANGE) { - unix_time=nt_time_to_unix(&from->pass_can_change_time); + unix_time=nt_time_to_unix(from->pass_can_change_time); stored_time = pdb_get_pass_can_change_time(to); DEBUG(10,("INFO_23 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -356,7 +356,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) } if (from->fields_present & ACCT_LAST_PWD_CHANGE) { - unix_time=nt_time_to_unix(&from->pass_last_set_time); + unix_time=nt_time_to_unix(from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); DEBUG(10,("INFO_23 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -364,7 +364,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) } if (from->fields_present & ACCT_FORCE_PWD_CHANGE) { - unix_time=nt_time_to_unix(&from->pass_must_change_time); + unix_time=nt_time_to_unix(from->pass_must_change_time); stored_time=pdb_get_pass_must_change_time(to); DEBUG(10,("INFO_23 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -562,7 +562,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) return; if (from->fields_present & ACCT_LAST_LOGON) { - unix_time=nt_time_to_unix(&from->logon_time); + unix_time=nt_time_to_unix(from->logon_time); stored_time = pdb_get_logon_time(to); DEBUG(10,("INFO_25 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -570,7 +570,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) } if (from->fields_present & ACCT_LAST_LOGOFF) { - unix_time=nt_time_to_unix(&from->logoff_time); + unix_time=nt_time_to_unix(from->logoff_time); stored_time = pdb_get_logoff_time(to); DEBUG(10,("INFO_25 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -578,7 +578,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) } if (from->fields_present & ACCT_EXPIRY) { - unix_time=nt_time_to_unix(&from->kickoff_time); + unix_time=nt_time_to_unix(from->kickoff_time); stored_time = pdb_get_kickoff_time(to); DEBUG(10,("INFO_25 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -586,7 +586,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) } if (from->fields_present & ACCT_ALLOW_PWD_CHANGE) { - unix_time=nt_time_to_unix(&from->pass_can_change_time); + unix_time=nt_time_to_unix(from->pass_can_change_time); stored_time = pdb_get_pass_can_change_time(to); DEBUG(10,("INFO_25 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -594,7 +594,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) } if (from->fields_present & ACCT_LAST_PWD_CHANGE) { - unix_time=nt_time_to_unix(&from->pass_last_set_time); + unix_time=nt_time_to_unix(from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); DEBUG(10,("INFO_25 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -602,7 +602,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) } if (from->fields_present & ACCT_FORCE_PWD_CHANGE) { - unix_time=nt_time_to_unix(&from->pass_must_change_time); + unix_time=nt_time_to_unix(from->pass_must_change_time); stored_time=pdb_get_pass_must_change_time(to); DEBUG(10,("INFO_25 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 6548bf3c6d..e60a431846 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5287,8 +5287,7 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN info->previousdrivernames=NULL; init_unistr_array(&info->previousdrivernames, &nullstr, servername); - info->driver_date.low=0; - info->driver_date.high=0; + info->driver_date=0; info->padding=0; info->driver_version_low=0; diff --git a/source3/rpc_server/srv_unixinfo_nt.c b/source3/rpc_server/srv_unixinfo_nt.c index 79756f20a7..2d479b42f6 100644 --- a/source3/rpc_server/srv_unixinfo_nt.c +++ b/source3/rpc_server/srv_unixinfo_nt.c @@ -34,12 +34,11 @@ NTSTATUS _unixinfo_sid_to_uid(pipes_struct *p, { uid_t uid; - r_u->uid.low = 0; - r_u->uid.high = 0; + r_u->uid = 0; r_u->status = sid_to_uid(&q_u->sid, &uid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; if (NT_STATUS_IS_OK(r_u->status)) - r_u->uid.low = uid; + r_u->uid = uid; return r_u->status; } @@ -54,8 +53,8 @@ NTSTATUS _unixinfo_uid_to_sid(pipes_struct *p, r_u->status = NT_STATUS_NO_SUCH_USER; - if (q_u->uid.high == 0) { - uid_to_sid(&sid, q_u->uid.low); + if (q_u->uid == 0) { + uid_to_sid(&sid, q_u->uid); r_u->status = NT_STATUS_OK; } @@ -73,12 +72,11 @@ NTSTATUS _unixinfo_sid_to_gid(pipes_struct *p, { gid_t gid; - r_u->gid.low = 0; - r_u->gid.high = 0; + r_u->gid = 0; r_u->status = sid_to_gid(&q_u->sid, &gid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; if (NT_STATUS_IS_OK(r_u->status)) - r_u->gid.low = gid; + r_u->gid = gid; return r_u->status; } @@ -93,8 +91,8 @@ NTSTATUS _unixinfo_gid_to_sid(pipes_struct *p, r_u->status = NT_STATUS_NO_SUCH_USER; - if (q_u->gid.high == 0) { - gid_to_sid(&sid, q_u->gid.low); + if (q_u->gid == 0) { + gid_to_sid(&sid, q_u->gid); r_u->status = NT_STATUS_OK; } @@ -135,15 +133,10 @@ NTSTATUS _unixinfo_getpwuid(pipes_struct *p, r_u->info[i].homedir = ""; r_u->info[i].shell = ""; - if (q_u->uid[i].high != 0) { - DEBUG(10, ("64-bit uids not yet supported...\n")); - continue; - } - - pw = getpwuid(q_u->uid[i].low); + pw = getpwuid(q_u->uid[i]); if (pw == NULL) { - DEBUG(10, ("Did not find uid %d\n", q_u->uid[i].low)); + DEBUG(10, ("Did not find uid %lld\n", q_u->uid[i])); continue; } -- cgit From 2b27c93a9a8471693d7dcb5fdbe8afe65b22ff66 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 8 Sep 2006 14:28:06 +0000 Subject: r18271: Big change: * autogenerate lsa ndr code * rename 'enum SID_NAME_USE' to 'enum lsa_SidType' * merge a log more security descriptor functions from gen_ndr/ndr_security.c in SAMBA_4_0 The most embarassing thing is the "#define strlen_m strlen" We need a real implementation in SAMBA_3_0 which I'll work on after this code is in. (This used to be commit 3da9f80c28b1e75ef6d46d38fbb81ade6b9fa951) --- source3/rpc_server/srv_lsa_nt.c | 4 ++-- source3/rpc_server/srv_samr_nt.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 41df870414..f60d352942 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -164,7 +164,7 @@ static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx, int dom_idx; char *full_name; const char *domain; - enum SID_NAME_USE type = SID_NAME_UNKNOWN; + enum lsa_SidType type = SID_NAME_UNKNOWN; /* Split name into domain and user component */ @@ -239,7 +239,7 @@ static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, int dom_idx; char *full_name; const char *domain; - enum SID_NAME_USE type = SID_NAME_UNKNOWN; + enum lsa_SidType type = SID_NAME_UNKNOWN; /* Split name into domain and user component */ diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 67fa7f283c..a0b6d4763a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1377,7 +1377,7 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOKUP_NAMES *r_u) { uint32 rid[MAX_SAM_ENTRIES]; - enum SID_NAME_USE type[MAX_SAM_ENTRIES]; + enum lsa_SidType type[MAX_SAM_ENTRIES]; int i; int num_rids = q_u->num_names2; DOM_SID pol_sid; @@ -1618,7 +1618,7 @@ static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP_RIDS *r_u) { const char **names; - enum SID_NAME_USE *attrs = NULL; + enum lsa_SidType *attrs = NULL; uint32 *wire_attrs = NULL; UNIHDR *hdr_name = NULL; UNISTR2 *uni_name = NULL; @@ -1642,7 +1642,7 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK } names = TALLOC_ZERO_ARRAY(p->mem_ctx, const char *, num_rids); - attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, enum SID_NAME_USE, num_rids); + attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, enum lsa_SidType, num_rids); wire_attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_rids); if ((num_rids != 0) && ((names == NULL) || (attrs == NULL) || (wire_attrs==NULL))) @@ -1661,7 +1661,7 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK &hdr_name, &uni_name)) return NT_STATUS_NO_MEMORY; - /* Convert from enum SID_NAME_USE to uint32 for wire format. */ + /* Convert from enum lsa_SidType to uint32 for wire format. */ for (i = 0; i < num_rids; i++) { wire_attrs[i] = (uint32)attrs[i]; } @@ -2391,7 +2391,7 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, static NTSTATUS can_create(TALLOC_CTX *mem_ctx, const char *new_name) { - enum SID_NAME_USE type; + enum lsa_SidType type; BOOL result; DEBUG(10, ("Checking whether [%s] can be created\n", new_name)); @@ -2933,7 +2933,7 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A { /* Check we actually have the requested alias */ - enum SID_NAME_USE type; + enum lsa_SidType type; BOOL result; gid_t gid; -- cgit From 703881988bfa825fcaec0739904d9648c5ade29e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 11 Sep 2006 16:40:18 +0000 Subject: r18390: give a better error code metze (This used to be commit b2709f4fe529e89fcabfa3fc2ff27e09a192b3b6) --- source3/rpc_server/srv_unixinfo_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_unixinfo_nt.c b/source3/rpc_server/srv_unixinfo_nt.c index 2d479b42f6..5afbb7bed0 100644 --- a/source3/rpc_server/srv_unixinfo_nt.c +++ b/source3/rpc_server/srv_unixinfo_nt.c @@ -89,7 +89,7 @@ NTSTATUS _unixinfo_gid_to_sid(pipes_struct *p, { DOM_SID sid; - r_u->status = NT_STATUS_NO_SUCH_USER; + r_u->status = NT_STATUS_NO_SUCH_GROUP; if (q_u->gid == 0) { gid_to_sid(&sid, q_u->gid); -- cgit From 5e1146ab5845169aba57dcd216f88589276e5df8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Mon, 11 Sep 2006 22:02:34 +0000 Subject: r18404: * swap from POLICY_HND to the struct policy_handle from ndr/misc.h * move OUR_HANDLE macro to include/rpc_misc.h (This used to be commit 2b37079af2f569df7a58878150a61980c6fe06ee) --- source3/rpc_server/srv_lsa_hnd.c | 18 ++++++++++++------ source3/rpc_server/srv_reg_nt.c | 3 --- source3/rpc_server/srv_spoolss_nt.c | 4 ---- 3 files changed, 12 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 7da87d5b93..88c59ee895 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -103,6 +103,7 @@ BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *) { static uint32 pol_hnd_low = 0; static uint32 pol_hnd_high = 0; + time_t t = time(NULL); struct policy *pol; @@ -127,12 +128,17 @@ BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *) if (pol_hnd_low == 0) (pol_hnd_high)++; - SIVAL(&pol->pol_hnd.data1, 0 , 0); /* first bit must be null */ - SIVAL(&pol->pol_hnd.data2, 0 , pol_hnd_low ); /* second bit is incrementing */ - SSVAL(&pol->pol_hnd.data3, 0 , pol_hnd_high); /* second bit is incrementing */ - SSVAL(&pol->pol_hnd.data4, 0 , (pol_hnd_high>>16)); /* second bit is incrementing */ - SIVAL(pol->pol_hnd.data5, 0, time(NULL)); /* something random */ - SIVAL(pol->pol_hnd.data5, 4, sys_getpid()); /* something more random */ + SIVAL(&pol->pol_hnd.handle_type, 0 , 0); /* first bit must be null */ + SIVAL(&pol->pol_hnd.uuid.time_low, 0 , pol_hnd_low ); /* second bit is incrementing */ + SSVAL(&pol->pol_hnd.uuid.time_mid, 0 , pol_hnd_high); /* second bit is incrementing */ + SSVAL(&pol->pol_hnd.uuid.time_hi_and_version, 0 , (pol_hnd_high>>16)); /* second bit is incrementing */ + + /* split the current time into two 16 bit values */ + + SSVAL(pol->pol_hnd.uuid.clock_seq, 0, (t>>16)); /* something random */ + SSVAL(pol->pol_hnd.uuid.node, 0, t); /* something random */ + + SIVAL(pol->pol_hnd.uuid.node, 2, sys_getpid()); /* something more random */ DLIST_ADD(p->pipe_handles->Policy, pol); p->pipe_handles->count++; diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 8fd0e55c54..3728252c99 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -30,9 +30,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -#define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ -((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) - static struct generic_mapping reg_generic_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e60a431846..5f8e705ea3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -66,10 +66,6 @@ static uint32 smb_connections=0; extern STANDARD_MAPPING printer_std_mapping, printserver_std_mapping; -#define OUR_HANDLE(hnd) (((hnd)==NULL)?"NULL":(IVAL((hnd)->data5,4)==(uint32)sys_getpid()?"OURS":"OTHER")), \ -((unsigned int)IVAL((hnd)->data5,4)),((unsigned int)sys_getpid()) - - /* API table for Xcv Monitor functions */ struct xcv_api_table { -- cgit From 62c78742c48c90d3a0256305a9e8c1c92b94c648 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 12 Sep 2006 02:26:32 +0000 Subject: r18413: Based on the new torture test I added in samba4 it turns out the flags determines what kind of share is this. I suppose 0x80000000 means something like (legacy) as it will fail for any share name longer then 13 chars (same size accepted for old RAP calls that come from pre NT OSs. Jerry, let me know if you want me to commit this to 3_0_23 Simo. (This used to be commit f09f8b2d820b10679f3e9cf80749da0a35f5ce6a) --- source3/rpc_server/srv_srvsvc_nt.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 3e79b420a9..c65401f1c4 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2221,11 +2221,28 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV_R_NET_NAME_VALIDATE *r_u) { fstring sharename; + int len; + + if ((q_u->flags != 0x0) && (q_u->flags != 0x80000000)) { + return WERR_INVALID_PARAM; + } switch ( q_u->type ) { case 0x9: rpcstr_pull(sharename, q_u->sharename.buffer, sizeof(sharename), q_u->sharename.uni_str_len*2, 0); - if ( !validate_net_name( sharename, INVALID_SHARENAME_CHARS, sizeof(sharename) ) ) { + + len = strlen_m(sharename); + + if ((q_u->flags == 0x0) && (len > 81)) { + DEBUG(5,("_srv_net_name_validate: share name too long (%s > 81 chars)\n", sharename)); + return WERR_INVALID_NAME; + } + if ((q_u->flags == 0x80000000) && (len > 13)) { + DEBUG(5,("_srv_net_name_validate: share name too long (%s > 13 chars)\n", sharename)); + return WERR_INVALID_NAME; + } + + if ( ! validate_net_name( sharename, INVALID_SHARENAME_CHARS, sizeof(sharename) ) ) { DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", sharename)); return WERR_INVALID_NAME; } -- cgit From bad8c0d6f15990b8de6e9ff6dc79628c67eba187 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 12 Sep 2006 18:02:33 +0000 Subject: r18429: fix a regression renaming local group introduced by trying to handle renames to the same name (This used to be commit 4faa5004fb7e5814bf8a97cfe8d0b443f0acdb8d) --- source3/rpc_server/srv_samr_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a0b6d4763a..822a6a2ab7 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4638,6 +4638,8 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ if ( strequal( acct_name, info.acct_name ) ) return NT_STATUS_OK; + fstrcpy( info.acct_name, acct_name ); + /* make sure the name doesn't already exist as a user or local group */ -- cgit From 48e2a2bfb75cdc914345b498012e82331546f0c0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 13 Sep 2006 16:28:25 +0000 Subject: r18481: Use pidl-generated server side code for dfs. (This used to be commit 3f337c104d42321595161d0283b39357df252a8e) --- source3/rpc_server/srv_dfs.c | 602 ---------------------------------------- source3/rpc_server/srv_dfs_nt.c | 207 +++++--------- 2 files changed, 77 insertions(+), 732 deletions(-) delete mode 100644 source3/rpc_server/srv_dfs.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs.c b/source3/rpc_server/srv_dfs.c deleted file mode 100644 index 44a9c06a3c..0000000000 --- a/source3/rpc_server/srv_dfs.c +++ /dev/null @@ -1,602 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * server auto-generated by pidl. DO NOT MODIFY! - */ - -#include "includes.h" -#include "nterr.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC - -/****************************************************************** - api_dfs_GetManagerVersion - *****************************************************************/ - -static BOOL api_dfs_GetManagerVersion(pipes_struct *p) -{ - NETDFS_Q_DFS_GETMANAGERVERSION q_u; - NETDFS_R_DFS_GETMANAGERVERSION r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_GetManagerVersion("", &q_u, data, 0)) - return False; - - _dfs_GetManagerVersion(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_GetManagerVersion("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_Add - *****************************************************************/ - -static BOOL api_dfs_Add(pipes_struct *p) -{ - NETDFS_Q_DFS_ADD q_u; - NETDFS_R_DFS_ADD r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_Add("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_Add(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_Add("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_Remove - *****************************************************************/ - -static BOOL api_dfs_Remove(pipes_struct *p) -{ - NETDFS_Q_DFS_REMOVE q_u; - NETDFS_R_DFS_REMOVE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_Remove("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_Remove(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_Remove("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_SetInfo - *****************************************************************/ - -static BOOL api_dfs_SetInfo(pipes_struct *p) -{ - NETDFS_Q_DFS_SETINFO q_u; - NETDFS_R_DFS_SETINFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_SetInfo("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_SetInfo(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_SetInfo("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_GetInfo - *****************************************************************/ - -static BOOL api_dfs_GetInfo(pipes_struct *p) -{ - NETDFS_Q_DFS_GETINFO q_u; - NETDFS_R_DFS_GETINFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_GetInfo("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_GetInfo(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_GetInfo("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_Enum - *****************************************************************/ - -static BOOL api_dfs_Enum(pipes_struct *p) -{ - NETDFS_Q_DFS_ENUM q_u; - NETDFS_R_DFS_ENUM r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_Enum("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_Enum(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_Enum("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_Rename - *****************************************************************/ - -static BOOL api_dfs_Rename(pipes_struct *p) -{ - NETDFS_Q_DFS_RENAME q_u; - NETDFS_R_DFS_RENAME r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_Rename("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_Rename(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_Rename("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_Move - *****************************************************************/ - -static BOOL api_dfs_Move(pipes_struct *p) -{ - NETDFS_Q_DFS_MOVE q_u; - NETDFS_R_DFS_MOVE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_Move("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_Move(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_Move("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_ManagerGetConfigInfo - *****************************************************************/ - -static BOOL api_dfs_ManagerGetConfigInfo(pipes_struct *p) -{ - NETDFS_Q_DFS_MANAGERGETCONFIGINFO q_u; - NETDFS_R_DFS_MANAGERGETCONFIGINFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_ManagerGetConfigInfo("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_ManagerGetConfigInfo(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_ManagerGetConfigInfo("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_ManagerSendSiteInfo - *****************************************************************/ - -static BOOL api_dfs_ManagerSendSiteInfo(pipes_struct *p) -{ - NETDFS_Q_DFS_MANAGERSENDSITEINFO q_u; - NETDFS_R_DFS_MANAGERSENDSITEINFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_ManagerSendSiteInfo("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_ManagerSendSiteInfo(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_ManagerSendSiteInfo("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_AddFtRoot - *****************************************************************/ - -static BOOL api_dfs_AddFtRoot(pipes_struct *p) -{ - NETDFS_Q_DFS_ADDFTROOT q_u; - NETDFS_R_DFS_ADDFTROOT r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_AddFtRoot("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_AddFtRoot(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_AddFtRoot("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_RemoveFtRoot - *****************************************************************/ - -static BOOL api_dfs_RemoveFtRoot(pipes_struct *p) -{ - NETDFS_Q_DFS_REMOVEFTROOT q_u; - NETDFS_R_DFS_REMOVEFTROOT r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_RemoveFtRoot("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_RemoveFtRoot(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_RemoveFtRoot("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_AddStdRoot - *****************************************************************/ - -static BOOL api_dfs_AddStdRoot(pipes_struct *p) -{ - NETDFS_Q_DFS_ADDSTDROOT q_u; - NETDFS_R_DFS_ADDSTDROOT r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_AddStdRoot("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_AddStdRoot(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_AddStdRoot("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_RemoveStdRoot - *****************************************************************/ - -static BOOL api_dfs_RemoveStdRoot(pipes_struct *p) -{ - NETDFS_Q_DFS_REMOVESTDROOT q_u; - NETDFS_R_DFS_REMOVESTDROOT r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_RemoveStdRoot("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_RemoveStdRoot(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_RemoveStdRoot("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_ManagerInitialize - *****************************************************************/ - -static BOOL api_dfs_ManagerInitialize(pipes_struct *p) -{ - NETDFS_Q_DFS_MANAGERINITIALIZE q_u; - NETDFS_R_DFS_MANAGERINITIALIZE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_ManagerInitialize("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_ManagerInitialize(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_ManagerInitialize("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_AddStdRootForced - *****************************************************************/ - -static BOOL api_dfs_AddStdRootForced(pipes_struct *p) -{ - NETDFS_Q_DFS_ADDSTDROOTFORCED q_u; - NETDFS_R_DFS_ADDSTDROOTFORCED r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_AddStdRootForced("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_AddStdRootForced(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_AddStdRootForced("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_GetDcAddress - *****************************************************************/ - -static BOOL api_dfs_GetDcAddress(pipes_struct *p) -{ - NETDFS_Q_DFS_GETDCADDRESS q_u; - NETDFS_R_DFS_GETDCADDRESS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_GetDcAddress("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_GetDcAddress(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_GetDcAddress("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_SetDcAddress - *****************************************************************/ - -static BOOL api_dfs_SetDcAddress(pipes_struct *p) -{ - NETDFS_Q_DFS_SETDCADDRESS q_u; - NETDFS_R_DFS_SETDCADDRESS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_SetDcAddress("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_SetDcAddress(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_SetDcAddress("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_FlushFtTable - *****************************************************************/ - -static BOOL api_dfs_FlushFtTable(pipes_struct *p) -{ - NETDFS_Q_DFS_FLUSHFTTABLE q_u; - NETDFS_R_DFS_FLUSHFTTABLE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_FlushFtTable("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_FlushFtTable(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_FlushFtTable("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_Add2 - *****************************************************************/ - -static BOOL api_dfs_Add2(pipes_struct *p) -{ - NETDFS_Q_DFS_ADD2 q_u; - NETDFS_R_DFS_ADD2 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_Add2("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_Add2(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_Add2("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_Remove2 - *****************************************************************/ - -static BOOL api_dfs_Remove2(pipes_struct *p) -{ - NETDFS_Q_DFS_REMOVE2 q_u; - NETDFS_R_DFS_REMOVE2 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_Remove2("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_Remove2(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_Remove2("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_EnumEx - *****************************************************************/ - -static BOOL api_dfs_EnumEx(pipes_struct *p) -{ - NETDFS_Q_DFS_ENUMEX q_u; - NETDFS_R_DFS_ENUMEX r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_EnumEx("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_EnumEx(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_EnumEx("", &r_u, rdata, 0)) - return False; - - return True; -} -/****************************************************************** - api_dfs_SetInfo2 - *****************************************************************/ - -static BOOL api_dfs_SetInfo2(pipes_struct *p) -{ - NETDFS_Q_DFS_SETINFO2 q_u; - NETDFS_R_DFS_SETINFO2 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!netdfs_io_q_dfs_SetInfo2("", &q_u, data, 0)) - return False; - - r_u.status = _dfs_SetInfo2(p, &q_u, &r_u); - - if (!netdfs_io_r_dfs_SetInfo2("", &r_u, rdata, 0)) - return False; - - return True; -} - -/* Tables */ -static struct api_struct api_netdfs_cmds[] = -{ - {"DFS_GETMANAGERVERSION", DFS_GETMANAGERVERSION, api_dfs_GetManagerVersion}, - {"DFS_ADD", DFS_ADD, api_dfs_Add}, - {"DFS_REMOVE", DFS_REMOVE, api_dfs_Remove}, - {"DFS_SETINFO", DFS_SETINFO, api_dfs_SetInfo}, - {"DFS_GETINFO", DFS_GETINFO, api_dfs_GetInfo}, - {"DFS_ENUM", DFS_ENUM, api_dfs_Enum}, - {"DFS_RENAME", DFS_RENAME, api_dfs_Rename}, - {"DFS_MOVE", DFS_MOVE, api_dfs_Move}, - {"DFS_MANAGERGETCONFIGINFO", DFS_MANAGERGETCONFIGINFO, api_dfs_ManagerGetConfigInfo}, - {"DFS_MANAGERSENDSITEINFO", DFS_MANAGERSENDSITEINFO, api_dfs_ManagerSendSiteInfo}, - {"DFS_ADDFTROOT", DFS_ADDFTROOT, api_dfs_AddFtRoot}, - {"DFS_REMOVEFTROOT", DFS_REMOVEFTROOT, api_dfs_RemoveFtRoot}, - {"DFS_ADDSTDROOT", DFS_ADDSTDROOT, api_dfs_AddStdRoot}, - {"DFS_REMOVESTDROOT", DFS_REMOVESTDROOT, api_dfs_RemoveStdRoot}, - {"DFS_MANAGERINITIALIZE", DFS_MANAGERINITIALIZE, api_dfs_ManagerInitialize}, - {"DFS_ADDSTDROOTFORCED", DFS_ADDSTDROOTFORCED, api_dfs_AddStdRootForced}, - {"DFS_GETDCADDRESS", DFS_GETDCADDRESS, api_dfs_GetDcAddress}, - {"DFS_SETDCADDRESS", DFS_SETDCADDRESS, api_dfs_SetDcAddress}, - {"DFS_FLUSHFTTABLE", DFS_FLUSHFTTABLE, api_dfs_FlushFtTable}, - {"DFS_ADD2", DFS_ADD2, api_dfs_Add2}, - {"DFS_REMOVE2", DFS_REMOVE2, api_dfs_Remove2}, - {"DFS_ENUMEX", DFS_ENUMEX, api_dfs_EnumEx}, - {"DFS_SETINFO2", DFS_SETINFO2, api_dfs_SetInfo2}, -}; - -void netdfs_get_pipe_fns(struct api_struct **fns, int *n_fns) -{ - *fns = api_netdfs_cmds; - *n_fns = sizeof(api_netdfs_cmds) / sizeof(struct api_struct); -} - -NTSTATUS rpc_netdfs_init(void) -{ - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "netdfs", "netdfs", api_netdfs_cmds, sizeof(api_netdfs_cmds) / sizeof(struct api_struct)); -} diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index abdd9e8f23..4a5aad58b9 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -3,7 +3,7 @@ * RPC Pipe client / server routines for Dfs * Copyright (C) Shirish Kalele 2000. * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Jelmer Vernooij 2005. + * Copyright (C) Jelmer Vernooij 2005-2006. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,21 +30,20 @@ /* This function does not return a WERROR or NTSTATUS code but rather 1 if dfs exists, or 0 otherwise. */ -uint32 _dfs_GetManagerVersion(pipes_struct *p, NETDFS_Q_DFS_GETMANAGERVERSION *q_u, NETDFS_R_DFS_GETMANAGERVERSION *r_u) +void _dfs_GetManagerVersion(pipes_struct *p, uint32 *exists) { if(lp_host_msdfs()) - return 1; + *exists = 1; else - return 0; + *exists = 0; } -WERROR _dfs_Add(pipes_struct *p, NETDFS_Q_DFS_ADD* q_u, NETDFS_R_DFS_ADD *r_u) +WERROR _dfs_Add(pipes_struct *p, const char *path, const char *server, const char *share, const char *comment, uint32_t flags) { struct junction_map jn; struct referral* old_referral_list = NULL; BOOL exists = False; - pstring dfspath, servername, sharename; pstring altpath; if (p->pipe_user.ut.uid != 0) { @@ -52,19 +51,15 @@ WERROR _dfs_Add(pipes_struct *p, NETDFS_Q_DFS_ADD* q_u, NETDFS_R_DFS_ADD *r_u) return WERR_ACCESS_DENIED; } - unistr2_to_ascii(dfspath, &q_u->path, sizeof(dfspath)-1); - unistr2_to_ascii(servername, &q_u->server, sizeof(servername)-1); - unistr2_to_ascii(sharename, &q_u->share, sizeof(sharename)-1); - DEBUG(5,("init_reply_dfs_add: Request to add %s -> %s\\%s.\n", - dfspath, servername, sharename)); + path, server, share)); - pstrcpy(altpath, servername); + pstrcpy(altpath, server); pstrcat(altpath, "\\"); - pstrcat(altpath, sharename); + pstrcat(altpath, share); /* The following call can change the cwd. */ - if(get_referred_path(p->mem_ctx, dfspath, &jn, NULL, NULL)) { + if(get_referred_path(p->mem_ctx, path, &jn, NULL, NULL)) { exists = True; jn.referral_count += 1; old_referral_list = jn.referral_list; @@ -98,13 +93,11 @@ WERROR _dfs_Add(pipes_struct *p, NETDFS_Q_DFS_ADD* q_u, NETDFS_R_DFS_ADD *r_u) return WERR_OK; } -WERROR _dfs_Remove(pipes_struct *p, NETDFS_Q_DFS_REMOVE *q_u, - NETDFS_R_DFS_REMOVE *r_u) +WERROR _dfs_Remove(pipes_struct *p, const char *path, const char *server, const char *share) { struct junction_map jn; BOOL found = False; - pstring dfspath, servername, sharename; pstring altpath; if (p->pipe_user.ut.uid != 0) { @@ -112,31 +105,22 @@ WERROR _dfs_Remove(pipes_struct *p, NETDFS_Q_DFS_REMOVE *q_u, return WERR_ACCESS_DENIED; } - unistr2_to_ascii(dfspath, &q_u->path, sizeof(dfspath)-1); - if(q_u->ptr0_server) { - unistr2_to_ascii(servername, &q_u->server, sizeof(servername)-1); - } - - if(q_u->ptr0_share) { - unistr2_to_ascii(sharename, &q_u->share, sizeof(sharename)-1); - } - - if(q_u->ptr0_server && q_u->ptr0_share) { - pstrcpy(altpath, servername); + if(server && share) { + pstrcpy(altpath, server); pstrcat(altpath, "\\"); - pstrcat(altpath, sharename); + pstrcat(altpath, share); strlower_m(altpath); } DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n", - dfspath, servername, sharename)); + path, server, share)); - if(!get_referred_path(p->mem_ctx, dfspath, &jn, NULL, NULL)) { + if(!get_referred_path(p->mem_ctx, path, &jn, NULL, NULL)) { return WERR_DFS_NO_SUCH_VOL; } /* if no server-share pair given, remove the msdfs link completely */ - if(!q_u->ptr0_server && !q_u->ptr0_share) { + if(!server && !share) { if(!remove_msdfs_link(&jn)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; @@ -181,61 +165,50 @@ WERROR _dfs_Remove(pipes_struct *p, NETDFS_Q_DFS_REMOVE *q_u, return WERR_OK; } -static BOOL init_reply_dfs_info_1(struct junction_map* j, NETDFS_DFS_INFO1* dfs1) +static BOOL init_reply_dfs_info_1(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info1* dfs1) { - pstring str; - dfs1->ptr0_path = 1; - slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), - j->service_name, j->volume_name); - DEBUG(5,("init_reply_dfs_info_1: initing entrypath: %s\n",str)); - init_unistr2(&dfs1->path,str,UNI_STR_TERMINATE); + dfs1->path = talloc_asprintf(mem_ctx, + "\\\\%s\\%s\\%s", global_myname(), + j->service_name, j->volume_name); + DEBUG(5,("init_reply_dfs_info_1: initing entrypath: %s\n",dfs1->path)); return True; } -static BOOL init_reply_dfs_info_2(struct junction_map* j, NETDFS_DFS_INFO2* dfs2) +static BOOL init_reply_dfs_info_2(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info2* dfs2) { - pstring str; - dfs2->ptr0_path = 1; - slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), - j->service_name, j->volume_name); - init_unistr2(&dfs2->path, str, UNI_STR_TERMINATE); - dfs2->ptr0_comment = 0; - init_unistr2(&dfs2->comment, j->comment, UNI_STR_TERMINATE); + dfs2->path = talloc_asprintf(mem_ctx, + "\\\\%s\\%s\\%s", global_myname(), j->service_name, j->volume_name); + dfs2->comment = talloc_strdup(mem_ctx, j->comment); dfs2->state = 1; /* set up state of dfs junction as OK */ dfs2->num_stores = j->referral_count; return True; } -static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, NETDFS_DFS_INFO3* dfs3) +static BOOL init_reply_dfs_info_3(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info3* dfs3) { int ii; - pstring str; - dfs3->ptr0_path = 1; if (j->volume_name[0] == '\0') - slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s", + dfs3->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s", global_myname(), j->service_name); else - slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), + dfs3->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s\\%s", global_myname(), j->service_name, j->volume_name); - init_unistr2(&dfs3->path, str, UNI_STR_TERMINATE); - dfs3->ptr0_comment = 1; - init_unistr2(&dfs3->comment, j->comment, UNI_STR_TERMINATE); + dfs3->comment = talloc_strdup(mem_ctx, j->comment); dfs3->state = 1; - dfs3->num_stores = dfs3->size_stores = j->referral_count; - dfs3->ptr0_stores = 1; + dfs3->num_stores = j->referral_count; /* also enumerate the stores */ - dfs3->stores = TALLOC_ARRAY(ctx, NETDFS_DFS_STORAGEINFO, j->referral_count); + dfs3->stores = TALLOC_ARRAY(mem_ctx, struct dfs_StorageInfo, j->referral_count); if (!dfs3->stores) return False; - memset(dfs3->stores, '\0', j->referral_count * sizeof(NETDFS_DFS_STORAGEINFO)); + memset(dfs3->stores, '\0', j->referral_count * sizeof(struct dfs_StorageInfo)); for(ii=0;iireferral_count;ii++) { char* p; pstring path; - NETDFS_DFS_STORAGEINFO* stor = &(dfs3->stores[ii]); + struct dfs_StorageInfo* stor = &(dfs3->stores[ii]); struct referral* ref = &(j->referral_list[ii]); pstrcpy(path, ref->alternate_path); @@ -248,24 +221,21 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, NETDF *p = '\0'; DEBUG(5,("storage %d: %s.%s\n",ii,path,p+1)); stor->state = 2; /* set all stores as ONLINE */ - init_unistr2(&stor->server, path, UNI_STR_TERMINATE); - init_unistr2(&stor->share, p+1, UNI_STR_TERMINATE); - stor->ptr0_server = stor->ptr0_share = 1; + stor->server = talloc_strdup(mem_ctx, path); + stor->share = talloc_strdup(mem_ctx, p+1); } return True; } -static BOOL init_reply_dfs_info_100(struct junction_map* j, NETDFS_DFS_INFO100* dfs100) +static BOOL init_reply_dfs_info_100(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info100* dfs100) { - dfs100->ptr0_comment = 1; - init_unistr2(&dfs100->comment, j->comment, UNI_STR_TERMINATE); + dfs100->comment = talloc_strdup(mem_ctx, j->comment); return True; } -WERROR _dfs_Enum(pipes_struct *p, NETDFS_Q_DFS_ENUM *q_u, NETDFS_R_DFS_ENUM *r_u) +WERROR _dfs_Enum(pipes_struct *p, uint32_t level, uint32_t bufsize, struct dfs_EnumStruct *info, uint32_t *unknown, uint32_t *total) { - uint32 level = q_u->level; struct junction_map jn[MAX_MSDFS_JUNCTIONS]; int num_jn = 0; int i; @@ -275,37 +245,27 @@ WERROR _dfs_Enum(pipes_struct *p, NETDFS_Q_DFS_ENUM *q_u, NETDFS_R_DFS_ENUM *r_u DEBUG(5,("_dfs_Enum: %d junctions found in Dfs, doing level %d\n", num_jn, level)); - r_u->ptr0_info = q_u->ptr0_info; - r_u->ptr0_total = q_u->ptr0_total; - r_u->total = num_jn; - - r_u->info = q_u->info; + *total = num_jn; /* Create the return array */ switch (level) { case 1: - if ((r_u->info.e.u.info1.s = TALLOC_ARRAY(p->mem_ctx, NETDFS_DFS_INFO1, num_jn)) == NULL) { + if ((info->e.info1->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info1, num_jn)) == NULL) { return WERR_NOMEM; } - r_u->info.e.u.info1.count = num_jn; - r_u->info.e.u.info1.ptr0_s = 1; - r_u->info.e.u.info1.size_s = num_jn; + info->e.info1->count = num_jn; break; case 2: - if ((r_u->info.e.u.info2.s = TALLOC_ARRAY(p->mem_ctx, NETDFS_DFS_INFO2, num_jn)) == NULL) { + if ((info->e.info2->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info2, num_jn)) == NULL) { return WERR_NOMEM; } - r_u->info.e.u.info2.count = num_jn; - r_u->info.e.u.info2.ptr0_s = 1; - r_u->info.e.u.info2.size_s = num_jn; + info->e.info2->count = num_jn; break; case 3: - if ((r_u->info.e.u.info3.s = TALLOC_ARRAY(p->mem_ctx, NETDFS_DFS_INFO3, num_jn)) == NULL) { + if ((info->e.info3->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info3, num_jn)) == NULL) { return WERR_NOMEM; } - r_u->info.e.u.info3.count = num_jn; - r_u->info.e.u.info3.ptr0_s = 1; - r_u->info.e.u.info3.size_s = num_jn; + info->e.info3->count = num_jn; break; default: return WERR_INVALID_PARAM; @@ -314,35 +274,28 @@ WERROR _dfs_Enum(pipes_struct *p, NETDFS_Q_DFS_ENUM *q_u, NETDFS_R_DFS_ENUM *r_u for (i = 0; i < num_jn; i++) { switch (level) { case 1: - init_reply_dfs_info_1(&jn[i], &r_u->info.e.u.info1.s[i]); + init_reply_dfs_info_1(p->mem_ctx, &jn[i], &info->e.info1->s[i]); break; case 2: - init_reply_dfs_info_2(&jn[i], &r_u->info.e.u.info2.s[i]); + init_reply_dfs_info_2(p->mem_ctx, &jn[i], &info->e.info2->s[i]); break; case 3: - init_reply_dfs_info_3(p->mem_ctx, &jn[i], &r_u->info.e.u.info3.s[i]); + init_reply_dfs_info_3(p->mem_ctx, &jn[i], &info->e.info3->s[i]); break; default: return WERR_INVALID_PARAM; } } - r_u->status = WERR_OK; - - return r_u->status; + return WERR_OK; } -WERROR _dfs_GetInfo(pipes_struct *p, NETDFS_Q_DFS_GETINFO *q_u, - NETDFS_R_DFS_GETINFO *r_u) +WERROR _dfs_GetInfo(pipes_struct *p, const char *path, const char *server, const char *share, uint32_t level, union dfs_Info *info) { - UNISTR2* uni_path = &q_u->path; - uint32 level = q_u->level; int consumedcnt = sizeof(pstring); - pstring path; - BOOL ret = False; struct junction_map jn; + BOOL ret; - unistr2_to_ascii(path, uni_path, sizeof(path)-1); if(!create_junction(path, &jn)) return WERR_DFS_NO_SUCH_SERVER; @@ -353,132 +306,126 @@ WERROR _dfs_GetInfo(pipes_struct *p, NETDFS_Q_DFS_GETINFO *q_u, } vfs_ChDir(p->conn,p->conn->connectpath); - r_u->info.switch_value = level; - r_u->info.ptr0 = 1; - r_u->status = WERR_OK; switch (level) { - case 1: ret = init_reply_dfs_info_1(&jn, &r_u->info.u.info1); break; - case 2: ret = init_reply_dfs_info_2(&jn, &r_u->info.u.info2); break; - case 3: ret = init_reply_dfs_info_3(p->mem_ctx, &jn, &r_u->info.u.info3); break; - case 100: ret = init_reply_dfs_info_100(&jn, &r_u->info.u.info100); break; + case 1: ret = init_reply_dfs_info_1(p->mem_ctx, &jn, info->info1); break; + case 2: ret = init_reply_dfs_info_2(p->mem_ctx, &jn, info->info2); break; + case 3: ret = init_reply_dfs_info_3(p->mem_ctx, &jn, info->info3); break; + case 100: ret = init_reply_dfs_info_100(p->mem_ctx, &jn, info->info100); break; default: - r_u->info.ptr0 = 1; - r_u->info.switch_value = 0; - r_u->status = WERR_OK; - ret = True; - break; + info->info1 = NULL; + return WERR_INVALID_PARAM; } if (!ret) - r_u->status = WERR_INVALID_PARAM; + return WERR_INVALID_PARAM; - return r_u->status; + return WERR_OK; } -WERROR _dfs_SetInfo(pipes_struct *p, NETDFS_Q_DFS_SETINFO *q_u, NETDFS_R_DFS_SETINFO *r_u) +WERROR _dfs_SetInfo(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_Rename(pipes_struct *p, NETDFS_Q_DFS_RENAME *q_u, NETDFS_R_DFS_RENAME *r_u) +WERROR _dfs_Rename(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_Move(pipes_struct *p, NETDFS_Q_DFS_MOVE *q_u, NETDFS_R_DFS_MOVE *r_u) +WERROR _dfs_Move(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_ManagerGetConfigInfo(pipes_struct *p, NETDFS_Q_DFS_MANAGERGETCONFIGINFO *q_u, NETDFS_R_DFS_MANAGERGETCONFIGINFO *r_u) +WERROR _dfs_ManagerGetConfigInfo(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_ManagerSendSiteInfo(pipes_struct *p, NETDFS_Q_DFS_MANAGERSENDSITEINFO *q_u, NETDFS_R_DFS_MANAGERSENDSITEINFO *r_u) +WERROR _dfs_ManagerSendSiteInfo(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_AddFtRoot(pipes_struct *p, NETDFS_Q_DFS_ADDFTROOT *q_u, NETDFS_R_DFS_ADDFTROOT *r_u) +WERROR _dfs_AddFtRoot(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_RemoveFtRoot(pipes_struct *p, NETDFS_Q_DFS_REMOVEFTROOT *q_u, NETDFS_R_DFS_REMOVEFTROOT *r_u) +WERROR _dfs_RemoveFtRoot(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_AddStdRoot(pipes_struct *p, NETDFS_Q_DFS_ADDSTDROOT *q_u, NETDFS_R_DFS_ADDSTDROOT *r_u) +WERROR _dfs_AddStdRoot(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_RemoveStdRoot(pipes_struct *p, NETDFS_Q_DFS_REMOVESTDROOT *q_u, NETDFS_R_DFS_REMOVESTDROOT *r_u) +WERROR _dfs_RemoveStdRoot(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_ManagerInitialize(pipes_struct *p, NETDFS_Q_DFS_MANAGERINITIALIZE *q_u, NETDFS_R_DFS_MANAGERINITIALIZE *r_u) +WERROR _dfs_ManagerInitialize(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_AddStdRootForced(pipes_struct *p, NETDFS_Q_DFS_ADDSTDROOTFORCED *q_u, NETDFS_R_DFS_ADDSTDROOTFORCED *r_u) +WERROR _dfs_AddStdRootForced(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_GetDcAddress(pipes_struct *p, NETDFS_Q_DFS_GETDCADDRESS *q_u, NETDFS_R_DFS_GETDCADDRESS *r_u) +WERROR _dfs_GetDcAddress(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_SetDcAddress(pipes_struct *p, NETDFS_Q_DFS_SETDCADDRESS *q_u, NETDFS_R_DFS_SETDCADDRESS *r_u) +WERROR _dfs_SetDcAddress(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_FlushFtTable(pipes_struct *p, NETDFS_Q_DFS_FLUSHFTTABLE *q_u, NETDFS_R_DFS_FLUSHFTTABLE *r_u) +WERROR _dfs_FlushFtTable(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_Add2(pipes_struct *p, NETDFS_Q_DFS_ADD2 *q_u, NETDFS_R_DFS_ADD2 *r_u) +WERROR _dfs_Add2(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_Remove2(pipes_struct *p, NETDFS_Q_DFS_REMOVE2 *q_u, NETDFS_R_DFS_REMOVE2 *r_u) +WERROR _dfs_Remove2(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_EnumEx(pipes_struct *p, NETDFS_Q_DFS_ENUMEX *q_u, NETDFS_R_DFS_ENUMEX *r_u) +WERROR _dfs_EnumEx(pipes_struct *p, const char *name, uint32_t level, uint32_t bufsize, struct dfs_EnumStruct *info, uint32_t *total) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; } -WERROR _dfs_SetInfo2(pipes_struct *p, NETDFS_Q_DFS_SETINFO2 *q_u, NETDFS_R_DFS_SETINFO2 *r_u) +WERROR _dfs_SetInfo2(pipes_struct *p) { /* FIXME: Implement your code here */ return WERR_NOT_SUPPORTED; -- cgit From e6b7c350c1f88c7b92e012be03cb3af207ff4187 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 13 Sep 2006 17:39:21 +0000 Subject: r18487: Add NULL checks (This used to be commit 3df11307f8ca05e4f7182522d835911f0768e9eb) --- source3/rpc_server/srv_dfs_nt.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 4a5aad58b9..f3b6d8af88 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -170,6 +170,9 @@ static BOOL init_reply_dfs_info_1(TALLOC_CTX *mem_ctx, struct junction_map* j, s dfs1->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s\\%s", global_myname(), j->service_name, j->volume_name); + if (dfs1->path == NULL) + return False; + DEBUG(5,("init_reply_dfs_info_1: initing entrypath: %s\n",dfs1->path)); return True; } @@ -178,6 +181,8 @@ static BOOL init_reply_dfs_info_2(TALLOC_CTX *mem_ctx, struct junction_map* j, s { dfs2->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s\\%s", global_myname(), j->service_name, j->volume_name); + if (dfs2->path == NULL) + return False; dfs2->comment = talloc_strdup(mem_ctx, j->comment); dfs2->state = 1; /* set up state of dfs junction as OK */ dfs2->num_stores = j->referral_count; @@ -194,6 +199,9 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *mem_ctx, struct junction_map* j, s dfs3->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s\\%s", global_myname(), j->service_name, j->volume_name); + if (dfs3->path == NULL) + return False; + dfs3->comment = talloc_strdup(mem_ctx, j->comment); dfs3->state = 1; dfs3->num_stores = j->referral_count; -- cgit From 71453ab90dbda7f335a3c7119eb8d404e85a0131 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 14 Sep 2006 14:51:16 +0000 Subject: r18526: Use generated server for unixinfo RPC interface. (This used to be commit a5c0606d7667506fdc64776e32d4b3508195a199) --- source3/rpc_server/srv_unixinfo.c | 163 ----------------------------------- source3/rpc_server/srv_unixinfo_nt.c | 116 ++++++++++--------------- 2 files changed, 44 insertions(+), 235 deletions(-) delete mode 100644 source3/rpc_server/srv_unixinfo.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_unixinfo.c b/source3/rpc_server/srv_unixinfo.c deleted file mode 100644 index f21416dfab..0000000000 --- a/source3/rpc_server/srv_unixinfo.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines for unixinfo-pipe - * Copyright (C) Volker Lendecke 2005 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* This is the interface to the rpcunixinfo pipe. */ - -#include "includes.h" -#include "nterr.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -static BOOL api_sid_to_uid(pipes_struct *p) -{ - UNIXINFO_Q_SID_TO_UID q_u; - UNIXINFO_R_SID_TO_UID r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!unixinfo_io_q_unixinfo_sid_to_uid("", &q_u, data, 0)) - return False; - - r_u.status = _unixinfo_sid_to_uid(p, &q_u, &r_u); - - if (!unixinfo_io_r_unixinfo_sid_to_uid("", &r_u, rdata, 0)) - return False; - - return True; -} - -static BOOL api_uid_to_sid(pipes_struct *p) -{ - UNIXINFO_Q_UID_TO_SID q_u; - UNIXINFO_R_UID_TO_SID r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!unixinfo_io_q_unixinfo_uid_to_sid("", &q_u, data, 0)) - return False; - - r_u.status = _unixinfo_uid_to_sid(p, &q_u, &r_u); - - if (!unixinfo_io_r_unixinfo_uid_to_sid("", &r_u, rdata, 0)) - return False; - - return True; -} - -static BOOL api_sid_to_gid(pipes_struct *p) -{ - UNIXINFO_Q_SID_TO_GID q_u; - UNIXINFO_R_SID_TO_GID r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!unixinfo_io_q_unixinfo_sid_to_gid("", &q_u, data, 0)) - return False; - - r_u.status = _unixinfo_sid_to_gid(p, &q_u, &r_u); - - if (!unixinfo_io_r_unixinfo_sid_to_gid("", &r_u, rdata, 0)) - return False; - - return True; -} - -static BOOL api_gid_to_sid(pipes_struct *p) -{ - UNIXINFO_Q_GID_TO_SID q_u; - UNIXINFO_R_GID_TO_SID r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!unixinfo_io_q_unixinfo_gid_to_sid("", &q_u, data, 0)) - return False; - - r_u.status = _unixinfo_gid_to_sid(p, &q_u, &r_u); - - if (!unixinfo_io_r_unixinfo_gid_to_sid("", &r_u, rdata, 0)) - return False; - - return True; -} - -static BOOL api_getpwuid(pipes_struct *p) -{ - UNIXINFO_Q_GETPWUID q_u; - UNIXINFO_R_GETPWUID r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!unixinfo_io_q_unixinfo_getpwuid("", &q_u, data, 0)) - return False; - - r_u.status = _unixinfo_getpwuid(p, &q_u, &r_u); - - if (!unixinfo_io_r_unixinfo_getpwuid("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* -\pipe\unixinfo commands -********************************************************************/ - -struct api_struct api_unixinfo_cmds[] = { - {"SID_TO_UID", UNIXINFO_SID_TO_UID, api_sid_to_uid }, - {"UID_TO_SID", UNIXINFO_UID_TO_SID, api_uid_to_sid }, - {"SID_TO_GID", UNIXINFO_SID_TO_GID, api_sid_to_gid }, - {"GID_TO_SID", UNIXINFO_GID_TO_SID, api_gid_to_sid }, - {"GETPWUID", UNIXINFO_GETPWUID, api_getpwuid }, -}; - - -void unixinfo_get_pipe_fns( struct api_struct **fns, int *n_fns ) -{ - *fns = api_unixinfo_cmds; - *n_fns = sizeof(api_unixinfo_cmds) / sizeof(struct api_struct); -} - -NTSTATUS rpc_unixinfo_init(void) -{ - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, - "unixinfo", "unixinfo", api_unixinfo_cmds, - sizeof(api_unixinfo_cmds) / sizeof(struct api_struct)); -} diff --git a/source3/rpc_server/srv_unixinfo_nt.c b/source3/rpc_server/srv_unixinfo_nt.c index 5afbb7bed0..321c6a6a5e 100644 --- a/source3/rpc_server/srv_unixinfo_nt.c +++ b/source3/rpc_server/srv_unixinfo_nt.c @@ -23,120 +23,92 @@ #include "includes.h" #include "nterr.h" + + #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV /* Map a sid to a uid */ -NTSTATUS _unixinfo_sid_to_uid(pipes_struct *p, - UNIXINFO_Q_SID_TO_UID *q_u, - UNIXINFO_R_SID_TO_UID *r_u) +NTSTATUS _unixinfo_SidToUid(pipes_struct *p, struct dom_sid sid, uint64_t *uid) { - uid_t uid; + uid_t real_uid; + NTSTATUS status; + *uid = 0; - r_u->uid = 0; + status = sid_to_uid(&sid, &real_uid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; + if (NT_STATUS_IS_OK(status)) + *uid = real_uid; - r_u->status = sid_to_uid(&q_u->sid, &uid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; - if (NT_STATUS_IS_OK(r_u->status)) - r_u->uid = uid; - - return r_u->status; + return status; } /* Map a uid to a sid */ -NTSTATUS _unixinfo_uid_to_sid(pipes_struct *p, - UNIXINFO_Q_UID_TO_SID *q_u, - UNIXINFO_R_UID_TO_SID *r_u) +NTSTATUS _unixinfo_UidToSid(pipes_struct *p, uint64_t uid, struct dom_sid *sid) { - DOM_SID sid; + NTSTATUS status = NT_STATUS_NO_SUCH_USER; - r_u->status = NT_STATUS_NO_SUCH_USER; + uid_to_sid(sid, (uid_t)uid); + status = NT_STATUS_OK; - if (q_u->uid == 0) { - uid_to_sid(&sid, q_u->uid); - r_u->status = NT_STATUS_OK; - } - - init_r_unixinfo_uid_to_sid(r_u, - NT_STATUS_IS_OK(r_u->status) ? &sid : NULL); - - return r_u->status; + return status; } /* Map a sid to a gid */ -NTSTATUS _unixinfo_sid_to_gid(pipes_struct *p, - UNIXINFO_Q_SID_TO_GID *q_u, - UNIXINFO_R_SID_TO_GID *r_u) +NTSTATUS _unixinfo_SidToGid(pipes_struct *p, struct dom_sid sid, uint64_t *gid) { - gid_t gid; + gid_t real_gid; + NTSTATUS status; - r_u->gid = 0; + *gid = 0; - r_u->status = sid_to_gid(&q_u->sid, &gid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; - if (NT_STATUS_IS_OK(r_u->status)) - r_u->gid = gid; + status = sid_to_gid(&sid, &real_gid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; + if (NT_STATUS_IS_OK(status)) + *gid = real_gid; - return r_u->status; + return status; } /* Map a gid to a sid */ -NTSTATUS _unixinfo_gid_to_sid(pipes_struct *p, - UNIXINFO_Q_GID_TO_SID *q_u, - UNIXINFO_R_GID_TO_SID *r_u) +NTSTATUS _unixinfo_GidToSid(pipes_struct *p, uint64_t gid, struct dom_sid *sid) { - DOM_SID sid; + NTSTATUS status = NT_STATUS_NO_SUCH_GROUP; - r_u->status = NT_STATUS_NO_SUCH_GROUP; + gid_to_sid(sid, (gid_t)gid); + status = NT_STATUS_OK; - if (q_u->gid == 0) { - gid_to_sid(&sid, q_u->gid); - r_u->status = NT_STATUS_OK; - } - - init_r_unixinfo_gid_to_sid(r_u, - NT_STATUS_IS_OK(r_u->status) ? &sid : NULL); - - return r_u->status; + return status; } /* Get unix struct passwd information */ -NTSTATUS _unixinfo_getpwuid(pipes_struct *p, - UNIXINFO_Q_GETPWUID *q_u, - UNIXINFO_R_GETPWUID *r_u) +NTSTATUS _unixinfo_GetPWUid(pipes_struct *p, uint32_t *count, uint64_t *uids, + struct unixinfo_GetPWUidInfo *infos) { int i; + NTSTATUS status; - if (r_u->count > 1023) { + if (*count > 1023) return NT_STATUS_INVALID_PARAMETER; - } - - r_u->info = TALLOC_ARRAY(p->mem_ctx, struct unixinfo_getpwuid, - q_u->count); - - if ((r_u->count > 0) && (r_u->info == NULL)) { - return NT_STATUS_NO_MEMORY; - } - r_u->status = NT_STATUS_OK; - r_u->count = q_u->count; + status = NT_STATUS_OK; - for (i=0; icount; i++) { + for (i=0; i<*count; i++) { struct passwd *pw; char *homedir, *shell; ssize_t len1, len2; - r_u->info[i].status = NT_STATUS_NO_SUCH_USER; - r_u->info[i].homedir = ""; - r_u->info[i].shell = ""; + infos[i].status = NT_STATUS_NO_SUCH_USER; + infos[i].homedir = ""; + infos[i].shell = ""; - pw = getpwuid(q_u->uid[i]); + pw = getpwuid(uids[i]); if (pw == NULL) { - DEBUG(10, ("Did not find uid %lld\n", q_u->uid[i])); + DEBUG(10, ("Did not find uid %lld\n", uids[i])); continue; } @@ -146,14 +118,14 @@ NTSTATUS _unixinfo_getpwuid(pipes_struct *p, if ((len1 < 0) || (len2 < 0) || (homedir == NULL) || (shell == NULL)) { DEBUG(3, ("push_utf8_talloc failed\n")); - r_u->info[i].status = NT_STATUS_NO_MEMORY; + infos[i].status = NT_STATUS_NO_MEMORY; continue; } - r_u->info[i].status = NT_STATUS_OK; - r_u->info[i].homedir = homedir; - r_u->info[i].shell = shell; + infos[i].status = NT_STATUS_OK; + infos[i].homedir = homedir; + infos[i].shell = shell; } - return r_u->status; + return status; } -- cgit From e5db7fee0f5cb3bd7434cdefebabc7a8376aa0d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 15 Sep 2006 22:49:27 +0000 Subject: r18572: Use the autogenerated client and server for the echo interface and implement some of the missing functions. RPC-ECHO now passes against Samba3. (This used to be commit 9e9a05366176454cc1779acc6c2b6070743f5939) --- source3/rpc_server/srv_echo.c | 150 --------------------------------------- source3/rpc_server/srv_echo_nt.c | 86 ++++++++++++++++++---- source3/rpc_server/srv_pipe.c | 4 +- 3 files changed, 73 insertions(+), 167 deletions(-) delete mode 100644 source3/rpc_server/srv_echo.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_echo.c b/source3/rpc_server/srv_echo.c deleted file mode 100644 index c6cfde07c1..0000000000 --- a/source3/rpc_server/srv_echo.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines for rpcecho - * Copyright (C) Tim Potter 2003. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* This is the interface to the rpcecho pipe. */ - -#include "includes.h" -#include "nterr.h" - -#ifdef DEVELOPER - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -static BOOL api_add_one(pipes_struct *p) -{ - ECHO_Q_ADD_ONE q_u; - ECHO_R_ADD_ONE r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!echo_io_q_add_one("", &q_u, data, 0)) - return False; - - _echo_add_one(p, &q_u, &r_u); - - if(!echo_io_r_add_one("", &r_u, rdata, 0)) - return False; - - return True; -} - -static BOOL api_echo_data(pipes_struct *p) -{ - ECHO_Q_ECHO_DATA q_u; - ECHO_R_ECHO_DATA r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!echo_io_q_echo_data("", &q_u, data, 0)) - return False; - - _echo_data(p, &q_u, &r_u); - - if(!echo_io_r_echo_data("", &r_u, rdata, 0)) - return False; - - return True; -} - -static BOOL api_source_data(pipes_struct *p) -{ - ECHO_Q_SOURCE_DATA q_u; - ECHO_R_SOURCE_DATA r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!echo_io_q_source_data("", &q_u, data, 0)) - return False; - - _source_data(p, &q_u, &r_u); - - if(!echo_io_r_source_data("", &r_u, rdata, 0)) - return False; - - return True; -} - -static BOOL api_sink_data(pipes_struct *p) -{ - ECHO_Q_SINK_DATA q_u; - ECHO_R_SINK_DATA r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!echo_io_q_sink_data("", &q_u, data, 0)) - return False; - - _sink_data(p, &q_u, &r_u); - - if(!echo_io_r_sink_data("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* -\pipe\rpcecho commands -********************************************************************/ - -struct api_struct api_echo_cmds[] = { - {"ADD_ONE", ECHO_ADD_ONE, api_add_one }, - {"ECHO_DATA", ECHO_DATA, api_echo_data }, - {"SOURCE_DATA", ECHO_SOURCE_DATA, api_source_data }, - {"SINK_DATA", ECHO_SINK_DATA, api_sink_data }, -}; - - -void echo_get_pipe_fns( struct api_struct **fns, int *n_fns ) -{ - *fns = api_echo_cmds; - *n_fns = sizeof(api_echo_cmds) / sizeof(struct api_struct); -} - -NTSTATUS rpc_echo_init(void) -{ - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, - "rpcecho", "rpcecho", api_echo_cmds, - sizeof(api_echo_cmds) / sizeof(struct api_struct)); -} - -#else /* DEVELOPER */ - -NTSTATUS rpc_echo_init(void) -{ - return NT_STATUS_OK; -} -#endif /* DEVELOPER */ diff --git a/source3/rpc_server/srv_echo_nt.c b/source3/rpc_server/srv_echo_nt.c index c861c74cc6..221f4bc8b2 100644 --- a/source3/rpc_server/srv_echo_nt.c +++ b/source3/rpc_server/srv_echo_nt.c @@ -30,29 +30,25 @@ /* Add one to the input and return it */ -void _echo_add_one(pipes_struct *p, ECHO_Q_ADD_ONE *q_u, ECHO_R_ADD_ONE *r_u) +void _echo_AddOne(pipes_struct *p, uint32_t in_data, uint32_t *out_data) { DEBUG(10, ("_echo_add_one\n")); - r_u->response = q_u->request + 1; + *out_data = in_data + 1; } /* Echo back an array of data */ -void _echo_data(pipes_struct *p, ECHO_Q_ECHO_DATA *q_u, - ECHO_R_ECHO_DATA *r_u) +void _echo_EchoData(pipes_struct *p, uint32_t len, uint8_t *in_data, uint8_t *out_data) { DEBUG(10, ("_echo_data\n")); - r_u->data = (char *)TALLOC(p->mem_ctx, q_u->size); - r_u->size = q_u->size; - memcpy(r_u->data, q_u->data, q_u->size); + memcpy(out_data, in_data, len); } /* Sink an array of data */ -void _sink_data(pipes_struct *p, ECHO_Q_SINK_DATA *q_u, - ECHO_R_SINK_DATA *r_u) +void _echo_SinkData(pipes_struct *p, uint32_t len, uint8_t *data) { DEBUG(10, ("_sink_data\n")); @@ -61,18 +57,78 @@ void _sink_data(pipes_struct *p, ECHO_Q_SINK_DATA *q_u, /* Source an array of data */ -void _source_data(pipes_struct *p, ECHO_Q_SOURCE_DATA *q_u, - ECHO_R_SOURCE_DATA *r_u) +void _echo_SourceData(pipes_struct *p, uint32_t len, uint8_t *data) { uint32 i; DEBUG(10, ("_source_data\n")); - r_u->data = (char *)TALLOC(p->mem_ctx, q_u->size); - r_u->size = q_u->size; + for (i = 0; i < len; i++) + data[i] = i & 0xff; +} - for (i = 0; i < r_u->size; i++) - r_u->data[i] = i & 0xff; +void _echo_TestCall(pipes_struct *p, const char *s1, const char **s2) +{ + *s2 = talloc_strdup(p->mem_ctx, s1); +} + +NTSTATUS _echo_TestCall2(pipes_struct *p, uint16_t level, union echo_Info *info) +{ + switch (level) { + case 1: + info->info1.v = 10; + break; + case 2: + info->info2.v = 20; + break; + case 3: + info->info3.v = 30; + break; + case 4: + info->info4.v = 40; + break; + case 5: + info->info5.v1 = 50; + info->info5.v2 = 60; + break; + case 6: + info->info6.v1 = 70; + info->info6.info1.v= 80; + break; + case 7: + info->info7.v1 = 80; + info->info7.info4.v = 90; + break; + default: + return NT_STATUS_INVALID_LEVEL; + } + + return NT_STATUS_OK; +} + +uint32 _echo_TestSleep(pipes_struct *p, uint32_t seconds) +{ + sleep(seconds); + return seconds; +} + +void _echo_TestEnum(pipes_struct *p, enum echo_Enum1 *foo1, struct echo_Enum2 *foo2, union echo_Enum3 *foo3) +{ +} + +void _echo_TestSurrounding(pipes_struct *p, struct echo_Surrounding *data) +{ + data->x *= 2; + data->surrounding = talloc_zero_array(p->mem_ctx, uint16_t, data->x); +} + +uint16 _echo_TestDoublePointer(pipes_struct *p, uint16_t ***data) +{ + if (!*data) + return 0; + if (!**data) + return 0; + return ***data; } #endif /* DEVELOPER */ diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 74583f075b..4c798e4300 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2385,8 +2385,8 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) ntsvcs_get_pipe_fns( &cmds, &n_cmds ); break; #ifdef DEVELOPER - case PI_ECHO: - echo_get_pipe_fns( &cmds, &n_cmds ); + case PI_RPCECHO: + rpcecho_get_pipe_fns( &cmds, &n_cmds ); break; #endif default: -- cgit From 1e02ed76ebf9841e4b7a70e209cfdb192c28a8b3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Sep 2006 19:27:15 +0000 Subject: r18621: Fix samr server build. Guenther (This used to be commit 23d6656427d0f7184f5365f6cb9356b15186b30e) --- source3/rpc_server/srv_samr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 6ce4f88261..ff6136a643 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1531,8 +1531,8 @@ static struct api_struct api_samr_cmds [] = {"SAMR_QUERY_DOMAIN_INFO" , SAMR_QUERY_DOMAIN_INFO, api_samr_query_domain_info}, {"SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, {"SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, + {"SAMR_QUERY_DISPINFO2" , SAMR_QUERY_DISPINFO2 , api_samr_query_dispinfo }, {"SAMR_QUERY_DISPINFO3" , SAMR_QUERY_DISPINFO3 , api_samr_query_dispinfo }, - {"SAMR_QUERY_DISPINFO4" , SAMR_QUERY_DISPINFO4 , api_samr_query_dispinfo }, {"SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, {"SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, -- cgit From 4e7d11449ad419f4fa791e26e059a9f73d6d4042 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 19 Sep 2006 00:12:11 +0000 Subject: r18654: Rename "struct uuid" => "struct GUID" for consistency. (This used to be commit 5de76767e857e9d159ea46e2ded612ccd6d6bf19) --- source3/rpc_server/srv_pipe.c | 4 ++-- source3/rpc_server/srv_spoolss_nt.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 4c798e4300..5abf1c293a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -997,9 +997,9 @@ BOOL check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, DEBUG(10,("checking %s\n", pipe_names[i].client_pipe)); if ( strequal(pipe_names[i].client_pipe, pname) && (abstract->version == pipe_names[i].abstr_syntax.version) - && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(struct uuid)) == 0) + && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(struct GUID)) == 0) && (transfer->version == pipe_names[i].trans_syntax.version) - && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(struct uuid)) == 0) ) { + && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(struct GUID)) == 0) ) { struct api_struct *fns = NULL; int n_fns = 0; PIPE_RPC_FNS *context_fns; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5f8e705ea3..16dec45318 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4262,7 +4262,7 @@ static BOOL construct_printer_info_5(Printer_entry *print_hnd, PRINTER_INFO_5 *p static BOOL construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *printer, int snum) { char *guid_str = NULL; - struct uuid guid; + struct GUID guid; if (is_printer_published(print_hnd, snum, &guid)) { asprintf(&guid_str, "{%s}", smb_uuid_string_static(guid)); -- cgit From d1e28fa76d14d0628f58cca8a6f6ca878851652f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Sep 2006 17:29:31 +0000 Subject: r18680: Fix last struct uuids (in uncommented code). Guenther (This used to be commit 41c79ee5accb13f73d1f65b303d723ca2ff49933) --- source3/rpc_server/srv_lsa_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f60d352942..9e1e9a397a 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -487,7 +487,7 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, const char *dns_name, const char *forest_name, - struct uuid *dom_guid, DOM_SID *dom_sid) + struct GUID *dom_guid, DOM_SID *dom_sid) { if (nb_name && *nb_name) { init_unistr2(&r_l->uni_nb_dom_name, nb_name, UNI_FLAGS_NONE); @@ -512,7 +512,7 @@ static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, /* how do we init the guid ? probably should write an init fn */ if (dom_guid) { - memcpy(&r_l->dom_guid, dom_guid, sizeof(struct uuid)); + memcpy(&r_l->dom_guid, dom_guid, sizeof(struct GUID)); } if (dom_sid) { @@ -1879,7 +1879,7 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I char *dns_name = NULL; char *forest_name = NULL; DOM_SID *sid = NULL; - struct uuid guid; + struct GUID guid; fstring dnsdomname; ZERO_STRUCT(guid); -- cgit From e04dda6a2ab35eb2e4dc18a8a0507517175a655e Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Wed, 20 Sep 2006 17:25:46 +0000 Subject: r18722: Fix up password change times. The can change and must change times are calculated based on the last change time, policies, and acb flags. Next step will be to not bother storing them. Right now I'm just trying to get them reported correctly. (This used to be commit fd5761c9e52cbf8f1f7e45e71693598b27ecbf57) --- source3/rpc_server/srv_samr_util.c | 60 +++++++++++++------------------------- 1 file changed, 20 insertions(+), 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 4fbd9d07d2..08a2fb92bb 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -283,26 +283,16 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } } - DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); - if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) { - pdb_set_pass_must_change_time(to,0, PDB_CHANGED); - } else { - uint32 expire; - time_t new_time; - if (pdb_get_pass_must_change_time(to) == 0) { - if (!pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &expire) - || expire == (uint32)-1) { - new_time = get_time_t_max(); - } else { - time_t old_time = pdb_get_pass_last_set_time(to); - new_time = old_time + expire; - if ((new_time) < time(0)) { - new_time = time(0) + expire; - } - } - if (!pdb_set_pass_must_change_time (to, new_time, PDB_CHANGED)) { - DEBUG (0, ("pdb_set_pass_must_change_time failed!\n")); - } + /* If the must change flag is set, the last set time goes to zero. + the must change and can change fields also do, but they are + calculated from policy, not set from the wire */ + + if (from->fields_present & ACCT_EXPIRED_FLAG) { + DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); + if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) { + pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); + } else { + pdb_set_pass_last_set_time(to, time(0), PDB_CHANGED); } } @@ -522,26 +512,16 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) } } - DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); - if (from->passmustchange==PASS_MUST_CHANGE_AT_NEXT_LOGON) { - pdb_set_pass_must_change_time(to,0, PDB_CHANGED); - } else { - uint32 expire; - time_t new_time; - if (pdb_get_pass_must_change_time(to) == 0) { - if (!pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &expire) - || expire == (uint32)-1) { - new_time = get_time_t_max(); - } else { - time_t old_time = pdb_get_pass_last_set_time(to); - new_time = old_time + expire; - if ((new_time) < time(0)) { - new_time = time(0) + expire; - } - } - if (!pdb_set_pass_must_change_time (to, new_time, PDB_CHANGED)) { - DEBUG (0, ("pdb_set_pass_must_change_time failed!\n")); - } + /* If the must change flag is set, the last set time goes to zero. + the must change and can change fields also do, but they are + calculated from policy, not set from the wire */ + + if (from->fields_present & ACCT_EXPIRED_FLAG) { + DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); + if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) { + pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); + } else { + pdb_set_pass_last_set_time(to, time(0), PDB_CHANGED); } } -- cgit From 77a7066d79dd0cb26a63d70295b318b70e12ea17 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Wed, 20 Sep 2006 17:37:20 +0000 Subject: r18724: Fixup time(0) -> time(NULL) (This used to be commit 6b17af0769ab0d04ec01cc83ed6e7fad822b00b1) --- source3/rpc_server/srv_samr_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 08a2fb92bb..94121e2717 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -292,7 +292,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) { pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); } else { - pdb_set_pass_last_set_time(to, time(0), PDB_CHANGED); + pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED); } } @@ -521,7 +521,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) { pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); } else { - pdb_set_pass_last_set_time(to, time(0), PDB_CHANGED); + pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED); } } -- cgit From 9dda6cdf4c3034620b90bb418bfaebeabb5aeca2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 20 Sep 2006 17:56:50 +0000 Subject: r18725: Replace out one wkssvc call (wkssrv_GetInfo()) with autogenerated code. Removed first rpc_parse/*.c file. w00t! (This used to be commit bb9b7a058d72569bee5683856661ac063c281c9f) --- source3/rpc_server/srv_wkssvc.c | 78 --------- source3/rpc_server/srv_wkssvc_nt.c | 316 ++++++++++++++++++++++++++++++++++--- 2 files changed, 294 insertions(+), 100 deletions(-) delete mode 100644 source3/rpc_server/srv_wkssvc.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c deleted file mode 100644 index b5c1af34d9..0000000000 --- a/source3/rpc_server/srv_wkssvc.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997, - * Copyright (C) Jim McDonough 2003. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* This is the interface to the wks pipe. */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -/******************************************************************* - api_wks_query_info - ********************************************************************/ - -static BOOL api_wks_query_info(pipes_struct *p) -{ - WKS_Q_QUERY_INFO q_u; - WKS_R_QUERY_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net share enum */ - if(!wks_io_q_query_info("", &q_u, data, 0)) - return False; - - r_u.status = _wks_query_info(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!wks_io_r_query_info("", &r_u, rdata, 0)) - return False; - - return True; -} - - -/******************************************************************* - \PIPE\wkssvc commands - ********************************************************************/ - -static struct api_struct api_wks_cmds[] = -{ - { "WKS_Q_QUERY_INFO", WKS_QUERY_INFO, api_wks_query_info } -}; - -void wkssvc_get_pipe_fns( struct api_struct **fns, int *n_fns ) -{ - *fns = api_wks_cmds; - *n_fns = sizeof(api_wks_cmds) / sizeof(struct api_struct); -} - -NTSTATUS rpc_wks_init(void) -{ - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "wkssvc", "ntsvcs", api_wks_cmds, - sizeof(api_wks_cmds) / sizeof(struct api_struct)); -} diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 6528e63225..fe48251639 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -29,51 +29,323 @@ #define DBGC_CLASS DBGC_RPC_SRV /******************************************************************* - create_wks_info_100 + Fill in the valiues for the struct wkssvc_NetWkstaInfo100. ********************************************************************/ -static void create_wks_info_100(WKS_INFO_100 *inf) +static void create_wks_info_100(struct wkssvc_NetWkstaInfo100 *info100) { pstring my_name; pstring domain; - DEBUG(5,("create_wks_info_100: %d\n", __LINE__)); - pstrcpy (my_name, global_myname()); strupper_m(my_name); pstrcpy (domain, lp_workgroup()); strupper_m(domain); + + info100->platform_id = 0x000001f4; /* unknown */ + info100->version_major = lp_major_announce_version(); + info100->version_minor = lp_minor_announce_version(); + + info100->server_name = talloc_strdup( info100, my_name ); + info100->domain_name = talloc_strdup( info100, domain ); - init_wks_info_100(inf, - 0x000001f4, /* platform id info */ - lp_major_announce_version(), - lp_minor_announce_version(), - my_name, domain); + return; } -/******************************************************************* - wks_reply_query_info - +/******************************************************************** only supports info level 100 at the moment. + ********************************************************************/ + +WERROR _wkssvc_NetWkstaGetInfo( pipes_struct *p, const char *server_name, uint32_t level, + union wkssvc_NetWkstaInfo *info ) +{ + struct wkssvc_NetWkstaInfo100 *wks100 = NULL; + + /* We only support info level 100 currently */ + + if ( level != 100 ) { + return NT_STATUS_INVALID_LEVEL; + } + + if ( (wks100 = TALLOC_ZERO_P(p->mem_ctx, struct wkssvc_NetWkstaInfo100)) == NULL ) { + return NT_STATUS_NO_MEMORY; + } + create_wks_info_100( wks100 ); + + info->info100 = wks100; + + return NT_STATUS_OK; +} + +/******************************************************************** ********************************************************************/ -NTSTATUS _wks_query_info(pipes_struct *p, WKS_Q_QUERY_INFO *q_u, WKS_R_QUERY_INFO *r_u) +WERROR _wkssvc_NetWkstaSetInfo( pipes_struct *p ) { - WKS_INFO_100 *wks100 = NULL; + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} - DEBUG(5,("_wks_query_info: %d\n", __LINE__)); +/******************************************************************** + ********************************************************************/ - wks100 = TALLOC_ZERO_P(p->mem_ctx, WKS_INFO_100); +WERROR _wkssvc_NetWkstaEnumUsers( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} - if (!wks100) - return NT_STATUS_NO_MEMORY; +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRWKSTAUSERGETINFO( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRWKSTAUSERSETINFO( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _wkssvc_NetWkstaTransportEnum( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRWKSTATRANSPORTADD( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRWKSTATRANSPORTDEL( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRUSEADD( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRUSEGETINFO( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRUSEDEL( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRUSEENUM( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRMESSAGEBUFFERSEND( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRWORKSTATIONSTATISTICSGET( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRLOGONDOMAINNAMEADD( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRLOGONDOMAINNAMEDEL( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRJOINDOMAIN( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRUNJOINDOMAIN( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRRENAMEMACHINEINDOMAIN( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRVALIDATENAME( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRGETJOININFORMATION( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRGETJOINABLEOUS( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _wkssvc_NetrJoinDomain2( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _wkssvc_NetrUnjoinDomain2( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _wkssvc_NetrRenameMachineInDomain2( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRVALIDATENAME2( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRGETJOINABLEOUS2( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} - create_wks_info_100(wks100); - init_wks_r_query_info(r_u, q_u->switch_value, wks100, NT_STATUS_OK); +/******************************************************************** + ********************************************************************/ + +WERROR _wkssvc_NetrAddAlternateComputerName( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} - DEBUG(5,("_wks_query_info: %d\n", __LINE__)); +/******************************************************************** + ********************************************************************/ - return r_u->status; +WERROR _wkssvc_NetrRemoveAlternateComputerName( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; } + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRSETPRIMARYCOMPUTERNAME( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRENUMERATECOMPUTERNAMES( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + -- cgit From 8126f9137508b4b46a039bccbf65434a3a2bcbcf Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 20 Sep 2006 18:06:02 +0000 Subject: r18728: revert previous commit until I fix the wkssvc_nt.c changes (This used to be commit 57d8519185008602fab5cf5d1d1951415aacb7f0) --- source3/rpc_server/srv_wkssvc_nt.c | 316 +++---------------------------------- 1 file changed, 22 insertions(+), 294 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index fe48251639..6528e63225 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -29,323 +29,51 @@ #define DBGC_CLASS DBGC_RPC_SRV /******************************************************************* - Fill in the valiues for the struct wkssvc_NetWkstaInfo100. + create_wks_info_100 ********************************************************************/ -static void create_wks_info_100(struct wkssvc_NetWkstaInfo100 *info100) +static void create_wks_info_100(WKS_INFO_100 *inf) { pstring my_name; pstring domain; + DEBUG(5,("create_wks_info_100: %d\n", __LINE__)); + pstrcpy (my_name, global_myname()); strupper_m(my_name); pstrcpy (domain, lp_workgroup()); strupper_m(domain); - - info100->platform_id = 0x000001f4; /* unknown */ - info100->version_major = lp_major_announce_version(); - info100->version_minor = lp_minor_announce_version(); - - info100->server_name = talloc_strdup( info100, my_name ); - info100->domain_name = talloc_strdup( info100, domain ); - return; + init_wks_info_100(inf, + 0x000001f4, /* platform id info */ + lp_major_announce_version(), + lp_minor_announce_version(), + my_name, domain); } -/******************************************************************** +/******************************************************************* + wks_reply_query_info + only supports info level 100 at the moment. - ********************************************************************/ - -WERROR _wkssvc_NetWkstaGetInfo( pipes_struct *p, const char *server_name, uint32_t level, - union wkssvc_NetWkstaInfo *info ) -{ - struct wkssvc_NetWkstaInfo100 *wks100 = NULL; - - /* We only support info level 100 currently */ - - if ( level != 100 ) { - return NT_STATUS_INVALID_LEVEL; - } - - if ( (wks100 = TALLOC_ZERO_P(p->mem_ctx, struct wkssvc_NetWkstaInfo100)) == NULL ) { - return NT_STATUS_NO_MEMORY; - } - - create_wks_info_100( wks100 ); - - info->info100 = wks100; - - return NT_STATUS_OK; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _wkssvc_NetWkstaSetInfo( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _wkssvc_NetWkstaEnumUsers( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRWKSTAUSERGETINFO( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRWKSTAUSERSETINFO( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _wkssvc_NetWkstaTransportEnum( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRWKSTATRANSPORTADD( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRWKSTATRANSPORTDEL( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRUSEADD( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRUSEGETINFO( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRUSEDEL( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRUSEENUM( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRMESSAGEBUFFERSEND( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRWORKSTATIONSTATISTICSGET( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} -/******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRLOGONDOMAINNAMEADD( pipes_struct *p ) +NTSTATUS _wks_query_info(pipes_struct *p, WKS_Q_QUERY_INFO *q_u, WKS_R_QUERY_INFO *r_u) { - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRLOGONDOMAINNAMEDEL( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRJOINDOMAIN( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRUNJOINDOMAIN( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRRENAMEMACHINEINDOMAIN( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRVALIDATENAME( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRGETJOININFORMATION( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRGETJOINABLEOUS( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ + WKS_INFO_100 *wks100 = NULL; -WERROR _wkssvc_NetrJoinDomain2( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _wkssvc_NetrUnjoinDomain2( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _wkssvc_NetrRenameMachineInDomain2( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRVALIDATENAME2( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ + DEBUG(5,("_wks_query_info: %d\n", __LINE__)); -WERROR _WKSSVC_NETRGETJOINABLEOUS2( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} - -/******************************************************************** - ********************************************************************/ - -WERROR _wkssvc_NetrAddAlternateComputerName( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} + wks100 = TALLOC_ZERO_P(p->mem_ctx, WKS_INFO_100); -/******************************************************************** - ********************************************************************/ - -WERROR _wkssvc_NetrRemoveAlternateComputerName( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} + if (!wks100) + return NT_STATUS_NO_MEMORY; -/******************************************************************** - ********************************************************************/ + create_wks_info_100(wks100); + init_wks_r_query_info(r_u, q_u->switch_value, wks100, NT_STATUS_OK); -WERROR _WKSSVC_NETRSETPRIMARYCOMPUTERNAME( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; -} + DEBUG(5,("_wks_query_info: %d\n", __LINE__)); -/******************************************************************** - ********************************************************************/ - -WERROR _WKSSVC_NETRENUMERATECOMPUTERNAMES( pipes_struct *p ) -{ - /* FIXME: Add implementation code here */ - return WERR_NOT_SUPPORTED; + return r_u->status; } - -- cgit From 01c684a3e97013d665b165cdec3a0bf688c05a6f Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 20 Sep 2006 18:10:56 +0000 Subject: r18730: readd missing files (one more) (This used to be commit 8e0b801c8be3f040a2a928e0b966279741a5d303) --- source3/rpc_server/srv_wkssvc.c | 78 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 source3/rpc_server/srv_wkssvc.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c new file mode 100644 index 0000000000..b5c1af34d9 --- /dev/null +++ b/source3/rpc_server/srv_wkssvc.c @@ -0,0 +1,78 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Jim McDonough 2003. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* This is the interface to the wks pipe. */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +/******************************************************************* + api_wks_query_info + ********************************************************************/ + +static BOOL api_wks_query_info(pipes_struct *p) +{ + WKS_Q_QUERY_INFO q_u; + WKS_R_QUERY_INFO r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the net share enum */ + if(!wks_io_q_query_info("", &q_u, data, 0)) + return False; + + r_u.status = _wks_query_info(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!wks_io_r_query_info("", &r_u, rdata, 0)) + return False; + + return True; +} + + +/******************************************************************* + \PIPE\wkssvc commands + ********************************************************************/ + +static struct api_struct api_wks_cmds[] = +{ + { "WKS_Q_QUERY_INFO", WKS_QUERY_INFO, api_wks_query_info } +}; + +void wkssvc_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_wks_cmds; + *n_fns = sizeof(api_wks_cmds) / sizeof(struct api_struct); +} + +NTSTATUS rpc_wks_init(void) +{ + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "wkssvc", "ntsvcs", api_wks_cmds, + sizeof(api_wks_cmds) / sizeof(struct api_struct)); +} -- cgit From b7d069097bdc8d1d9a0694225dd1583cb60c7b3c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 20 Sep 2006 19:26:21 +0000 Subject: r18739: * Get the wkssvc patch right this time. * Remove the old wkssvc server, client, & parsing code. * Update srv_wkssvc_nt.c with stubs for the remaining stubs (This used to be commit 0cb79ee13fd78b515a48b2c72d91596ed21e41a8) --- source3/rpc_server/srv_wkssvc.c | 78 --------- source3/rpc_server/srv_wkssvc_nt.c | 323 ++++++++++++++++++++++++++++++++++--- 2 files changed, 301 insertions(+), 100 deletions(-) delete mode 100644 source3/rpc_server/srv_wkssvc.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc.c b/source3/rpc_server/srv_wkssvc.c deleted file mode 100644 index b5c1af34d9..0000000000 --- a/source3/rpc_server/srv_wkssvc.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997, - * Copyright (C) Jim McDonough 2003. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* This is the interface to the wks pipe. */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -/******************************************************************* - api_wks_query_info - ********************************************************************/ - -static BOOL api_wks_query_info(pipes_struct *p) -{ - WKS_Q_QUERY_INFO q_u; - WKS_R_QUERY_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net share enum */ - if(!wks_io_q_query_info("", &q_u, data, 0)) - return False; - - r_u.status = _wks_query_info(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!wks_io_r_query_info("", &r_u, rdata, 0)) - return False; - - return True; -} - - -/******************************************************************* - \PIPE\wkssvc commands - ********************************************************************/ - -static struct api_struct api_wks_cmds[] = -{ - { "WKS_Q_QUERY_INFO", WKS_QUERY_INFO, api_wks_query_info } -}; - -void wkssvc_get_pipe_fns( struct api_struct **fns, int *n_fns ) -{ - *fns = api_wks_cmds; - *n_fns = sizeof(api_wks_cmds) / sizeof(struct api_struct); -} - -NTSTATUS rpc_wks_init(void) -{ - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "wkssvc", "ntsvcs", api_wks_cmds, - sizeof(api_wks_cmds) / sizeof(struct api_struct)); -} diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 6528e63225..ead1b7b918 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -29,51 +29,330 @@ #define DBGC_CLASS DBGC_RPC_SRV /******************************************************************* - create_wks_info_100 + Fill in the valiues for the struct wkssvc_NetWkstaInfo100. ********************************************************************/ -static void create_wks_info_100(WKS_INFO_100 *inf) +static void create_wks_info_100(struct wkssvc_NetWkstaInfo100 *info100) { pstring my_name; pstring domain; - DEBUG(5,("create_wks_info_100: %d\n", __LINE__)); - pstrcpy (my_name, global_myname()); strupper_m(my_name); pstrcpy (domain, lp_workgroup()); strupper_m(domain); + + info100->platform_id = 0x000001f4; /* unknown */ + info100->version_major = lp_major_announce_version(); + info100->version_minor = lp_minor_announce_version(); + + info100->server_name = talloc_strdup( info100, my_name ); + info100->domain_name = talloc_strdup( info100, domain ); - init_wks_info_100(inf, - 0x000001f4, /* platform id info */ - lp_major_announce_version(), - lp_minor_announce_version(), - my_name, domain); + return; } -/******************************************************************* - wks_reply_query_info - +/******************************************************************** only supports info level 100 at the moment. + ********************************************************************/ + +WERROR _wkssvc_NetWkstaGetInfo( pipes_struct *p, const char *server_name, uint32_t level, + union wkssvc_NetWkstaInfo *info ) +{ + struct wkssvc_NetWkstaInfo100 *wks100 = NULL; + + /* We only support info level 100 currently */ + + if ( level != 100 ) { + return NT_STATUS_INVALID_LEVEL; + } + + if ( (wks100 = TALLOC_ZERO_P(p->mem_ctx, struct wkssvc_NetWkstaInfo100)) == NULL ) { + return NT_STATUS_NO_MEMORY; + } + create_wks_info_100( wks100 ); + + info->info100 = wks100; + + return NT_STATUS_OK; +} + +/******************************************************************** ********************************************************************/ -NTSTATUS _wks_query_info(pipes_struct *p, WKS_Q_QUERY_INFO *q_u, WKS_R_QUERY_INFO *r_u) +WERROR _wkssvc_NetWkstaSetInfo( pipes_struct *p, const char *server_name, + uint32_t level, union wkssvc_NetWkstaInfo *info, + uint32_t *parm_error ) { - WKS_INFO_100 *wks100 = NULL; + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} - DEBUG(5,("_wks_query_info: %d\n", __LINE__)); +/******************************************************************** + ********************************************************************/ - wks100 = TALLOC_ZERO_P(p->mem_ctx, WKS_INFO_100); +WERROR _wkssvc_NetWkstaEnumUsers( pipes_struct *p, const char *server_name, + uint32_t level, + union WKS_USER_ENUM_UNION *users, + uint32_t prefmaxlen, uint32_t *entriesread, + uint32_t *totalentries, + uint32_t *resumehandle ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} - if (!wks100) - return NT_STATUS_NO_MEMORY; +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRWKSTAUSERGETINFO( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRWKSTAUSERSETINFO( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _wkssvc_NetWkstaTransportEnum( pipes_struct *p, const char *server_name, uint32_t *level, union wkssvc_NetWkstaTransportCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRWKSTATRANSPORTADD( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRWKSTATRANSPORTDEL( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRUSEADD( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRUSEGETINFO( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRUSEDEL( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRUSEENUM( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRMESSAGEBUFFERSEND( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRWORKSTATIONSTATISTICSGET( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRLOGONDOMAINNAMEADD( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRLOGONDOMAINNAMEDEL( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRJOINDOMAIN( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRUNJOINDOMAIN( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRRENAMEMACHINEINDOMAIN( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRVALIDATENAME( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRGETJOININFORMATION( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRGETJOINABLEOUS( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, const char *server_name, const char *domain_name, const char *account_name, const char *admin_account, struct wkssvc_PasswordBuffer *encrypted_password, uint32_t join_flags) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, const char *server_name, const char *account, struct wkssvc_PasswordBuffer *encrypted_password, uint32_t unjoin_flags) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _wkssvc_NetrRenameMachineInDomain2(pipes_struct *p, const char *server_name, const char *NewMachineName, const char *Account, struct wkssvc_PasswordBuffer *EncryptedPassword, uint32_t RenameOptions) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRVALIDATENAME2( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRGETJOINABLEOUS2( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} - create_wks_info_100(wks100); - init_wks_r_query_info(r_u, q_u->switch_value, wks100, NT_STATUS_OK); +/******************************************************************** + ********************************************************************/ + +WERROR _wkssvc_NetrAddAlternateComputerName(pipes_struct *p, const char *server_name, const char *NewAlternateMachineName, const char *Account, struct wkssvc_PasswordBuffer *EncryptedPassword, uint32_t Reserved) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} - DEBUG(5,("_wks_query_info: %d\n", __LINE__)); +/******************************************************************** + ********************************************************************/ - return r_u->status; +WERROR _wkssvc_NetrRemoveAlternateComputerName(pipes_struct *p, const char *server_name, const char *AlternateMachineNameToRemove, const char *Account, struct wkssvc_PasswordBuffer *EncryptedPassword, uint32_t Reserved) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; } + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRSETPRIMARYCOMPUTERNAME( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************** + ********************************************************************/ + +WERROR _WKSSVC_NETRENUMERATECOMPUTERNAMES( pipes_struct *p ) +{ + /* FIXME: Add implementation code here */ + return WERR_NOT_SUPPORTED; +} + -- cgit From 12a5226534c0efabf42dbac5301d5a8373fe1aa0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 20 Sep 2006 20:45:23 +0000 Subject: r18742: this function returns WERROR gix the build on RedHat 7.0 metze (This used to be commit d6f5a0cc7a7833f36288ec6201da6b4422b22c97) --- source3/rpc_server/srv_wkssvc_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index ead1b7b918..f46bbf98b2 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -65,18 +65,18 @@ WERROR _wkssvc_NetWkstaGetInfo( pipes_struct *p, const char *server_name, uint32 /* We only support info level 100 currently */ if ( level != 100 ) { - return NT_STATUS_INVALID_LEVEL; + return WERR_UNKNOWN_LEVEL; } if ( (wks100 = TALLOC_ZERO_P(p->mem_ctx, struct wkssvc_NetWkstaInfo100)) == NULL ) { - return NT_STATUS_NO_MEMORY; + return WERR_NOMEM; } create_wks_info_100( wks100 ); info->info100 = wks100; - return NT_STATUS_OK; + return WERR_OK; } /******************************************************************** -- cgit From 4db7642caa99c1b054322a8971c4b673556487ce Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 20 Sep 2006 22:23:12 +0000 Subject: r18745: Use the Samba4 data structures for security descriptors and security descriptor buffers. Make security access masks simply a uint32 rather than a structure with a uint32 in it. (This used to be commit b41c52b9db5fc4a553b20a7a5a051a4afced9366) --- source3/rpc_server/srv_spoolss_nt.c | 26 +++++++++++++------------- source3/rpc_server/srv_srvsvc_nt.c | 10 +++++----- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 16dec45318..1a396a2391 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -3008,8 +3008,8 @@ static void spoolss_notify_security_desc(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - data->notify_data.sd.size = printer->info_2->secdesc_buf->len; - data->notify_data.sd.desc = dup_sec_desc( mem_ctx, printer->info_2->secdesc_buf->sec ) ; + data->notify_data.sd.size = printer->info_2->secdesc_buf->sd_size; + data->notify_data.sd.desc = dup_sec_desc( mem_ctx, printer->info_2->secdesc_buf->sd ) ; } /******************************************************************* @@ -4154,13 +4154,13 @@ static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *p printer->secdesc = NULL; if ( ntprinter->info_2->secdesc_buf - && ntprinter->info_2->secdesc_buf->len != 0 ) + && ntprinter->info_2->secdesc_buf->sd_size != 0 ) { /* don't use talloc_steal() here unless you do a deep steal of all the SEC_DESC members */ printer->secdesc = dup_sec_desc( get_talloc_ctx(), - ntprinter->info_2->secdesc_buf->sec ); + ntprinter->info_2->secdesc_buf->sd ); } free_a_printer(&ntprinter, 2); @@ -4194,12 +4194,12 @@ static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 ** printer->flags = 0x4; - if (ntprinter->info_2->secdesc_buf && ntprinter->info_2->secdesc_buf->len != 0) { + if (ntprinter->info_2->secdesc_buf && ntprinter->info_2->secdesc_buf->sd_size != 0) { /* don't use talloc_steal() here unless you do a deep steal of all the SEC_DESC members */ printer->secdesc = dup_sec_desc( get_talloc_ctx(), - ntprinter->info_2->secdesc_buf->sec ); + ntprinter->info_2->secdesc_buf->sd ); } free_a_printer(&ntprinter, 2); @@ -5845,20 +5845,20 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, SEC_ACL *the_acl; int i; - the_acl = old_secdesc_ctr->sec->dacl; + the_acl = old_secdesc_ctr->sd->dacl; DEBUG(10, ("old_secdesc_ctr for %s has %d aces:\n", PRINTERNAME(snum), the_acl->num_aces)); for (i = 0; i < the_acl->num_aces; i++) { fstring sid_str; - sid_to_string(sid_str, &the_acl->ace[i].trustee); + sid_to_string(sid_str, &the_acl->aces[i].trustee); DEBUG(10, ("%s 0x%08x\n", sid_str, - the_acl->ace[i].info.mask)); + the_acl->aces[i].access_mask)); } - the_acl = secdesc_ctr->sec->dacl; + the_acl = secdesc_ctr->sd->dacl; if (the_acl) { DEBUG(10, ("secdesc_ctr for %s has %d aces:\n", @@ -5867,10 +5867,10 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, for (i = 0; i < the_acl->num_aces; i++) { fstring sid_str; - sid_to_string(sid_str, &the_acl->ace[i].trustee); + sid_to_string(sid_str, &the_acl->aces[i].trustee); DEBUG(10, ("%s 0x%08x\n", sid_str, - the_acl->ace[i].info.mask)); + the_acl->aces[i].access_mask)); } } else { DEBUG(10, ("dacl for secdesc_ctr is NULL\n")); @@ -5883,7 +5883,7 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, goto done; } - if (sec_desc_equal(new_secdesc_ctr->sec, old_secdesc_ctr->sec)) { + if (sec_desc_equal(new_secdesc_ctr->sd, old_secdesc_ctr->sd)) { result = WERR_OK; goto done; } diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index c65401f1c4..21032a4ed9 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -309,11 +309,11 @@ static void map_generic_share_sd_bits(SEC_DESC *psd) return; for (i = 0; i < ps_dacl->num_aces; i++) { - SEC_ACE *psa = &ps_dacl->ace[i]; - uint32 orig_mask = psa->info.mask; + SEC_ACE *psa = &ps_dacl->aces[i]; + uint32 orig_mask = psa->access_mask; - se_map_generic(&psa->info.mask, &file_generic_mapping); - psa->info.mask |= orig_mask; + se_map_generic(&psa->access_mask, &file_generic_mapping); + psa->access_mask |= orig_mask; } } @@ -1538,7 +1538,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S case 1501: pstrcpy(pathname, lp_pathname(snum)); fstrcpy(comment, lp_comment(snum)); - psd = q_u->info.share.info1501.sdb->sec; + psd = q_u->info.share.info1501.sdb->sd; map_generic_share_sd_bits(psd); type = STYPE_DISKTREE; break; -- cgit From f002bb2a46d76a2216737ef9e3aa366a4ab33437 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Wed, 20 Sep 2006 23:43:56 +0000 Subject: r18754: Get rid of some more invalid time sets (This used to be commit 3840d3785f1d61885aa7c83675a3e19673eb4b2a) --- source3/rpc_server/srv_samr_util.c | 48 -------------------------------------- 1 file changed, 48 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 94121e2717..242d44c6e8 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -99,14 +99,6 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); } - if (from->fields_present & ACCT_ALLOW_PWD_CHANGE) { - unix_time=nt_time_to_unix(from->pass_can_change_time); - stored_time = pdb_get_pass_can_change_time(to); - DEBUG(10,("INFO_21 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) - pdb_set_pass_can_change_time(to, unix_time, PDB_CHANGED); - } - if (from->fields_present & ACCT_LAST_PWD_CHANGE) { unix_time=nt_time_to_unix(from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); @@ -115,14 +107,6 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); } - if (from->fields_present & ACCT_FORCE_PWD_CHANGE) { - unix_time=nt_time_to_unix(from->pass_must_change_time); - stored_time=pdb_get_pass_must_change_time(to); - DEBUG(10,("INFO_21 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) - pdb_set_pass_must_change_time(to, unix_time, PDB_CHANGED); - } - if ((from->fields_present & ACCT_USERNAME) && (from->hdr_user_name.buffer)) { old_string = pdb_get_username(to); @@ -337,14 +321,6 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); } - if (from->fields_present & ACCT_ALLOW_PWD_CHANGE) { - unix_time=nt_time_to_unix(from->pass_can_change_time); - stored_time = pdb_get_pass_can_change_time(to); - DEBUG(10,("INFO_23 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) - pdb_set_pass_can_change_time(to, unix_time, PDB_CHANGED); - } - if (from->fields_present & ACCT_LAST_PWD_CHANGE) { unix_time=nt_time_to_unix(from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); @@ -353,14 +329,6 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); } - if (from->fields_present & ACCT_FORCE_PWD_CHANGE) { - unix_time=nt_time_to_unix(from->pass_must_change_time); - stored_time=pdb_get_pass_must_change_time(to); - DEBUG(10,("INFO_23 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) - pdb_set_pass_must_change_time(to, unix_time, PDB_CHANGED); - } - /* Backend should check this for sanity */ if ((from->fields_present & ACCT_USERNAME) && (from->hdr_user_name.buffer)) { @@ -565,14 +533,6 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); } - if (from->fields_present & ACCT_ALLOW_PWD_CHANGE) { - unix_time=nt_time_to_unix(from->pass_can_change_time); - stored_time = pdb_get_pass_can_change_time(to); - DEBUG(10,("INFO_25 PASS_CAN_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) - pdb_set_pass_can_change_time(to, unix_time, PDB_CHANGED); - } - if (from->fields_present & ACCT_LAST_PWD_CHANGE) { unix_time=nt_time_to_unix(from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); @@ -581,14 +541,6 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); } - if (from->fields_present & ACCT_FORCE_PWD_CHANGE) { - unix_time=nt_time_to_unix(from->pass_must_change_time); - stored_time=pdb_get_pass_must_change_time(to); - DEBUG(10,("INFO_25 PASS_MUST_CH: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) - pdb_set_pass_must_change_time(to, unix_time, PDB_CHANGED); - } - if ((from->fields_present & ACCT_USERNAME) && (from->hdr_user_name.buffer)) { old_string = pdb_get_username(to); -- cgit From 045567f2be01a210b5e53236e3332254f11ee9c8 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 20 Sep 2006 23:49:13 +0000 Subject: r18756: cleanup copyrights after moving to new wkssvc implementation code (This used to be commit 18b24e0fe94449b4a3e662f75b233d9c5f622d06) --- source3/rpc_server/srv_wkssvc_nt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index f46bbf98b2..79e9337e88 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -1,10 +1,9 @@ /* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jeremy Allison 2001. + * + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Gerald (Jerry) Carter 2006. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- cgit From eab57a0a0fe90be464f5061691f57ca1da150885 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 21 Sep 2006 17:51:06 +0000 Subject: r18789: Replace the winreg server code with the libndr parsing code. Many things work (OpenHKLM, etc...) but some still don't. This shouldn't block anyone so I'm checking it in. Will probably move to a bzr tree after this for longer dev cycles between checkins. (This used to be commit cf1404a0d7538288b9370ba80df328f81b713ce0) --- source3/rpc_server/srv_initshutdown_nt.c | 63 ++ source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_reg.c | 659 ------------- source3/rpc_server/srv_reg_nt.c | 1352 -------------------------- source3/rpc_server/srv_winreg_nt.c | 1518 ++++++++++++++++++++++++++++++ 5 files changed, 1582 insertions(+), 2012 deletions(-) create mode 100644 source3/rpc_server/srv_initshutdown_nt.c delete mode 100644 source3/rpc_server/srv_reg.c delete mode 100644 source3/rpc_server/srv_reg_nt.c create mode 100644 source3/rpc_server/srv_winreg_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_initshutdown_nt.c b/source3/rpc_server/srv_initshutdown_nt.c new file mode 100644 index 0000000000..a73077fe03 --- /dev/null +++ b/source3/rpc_server/srv_initshutdown_nt.c @@ -0,0 +1,63 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997. + * Copyright (C) Gerald Carter 2006. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Implementation of registry functions. */ + +#include "includes.h" +#include "regfio.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + + +/******************************************************************* + ********************************************************************/ +WERROR _initshutdown_Init(pipes_struct *p, uint16_t *hostname, struct initshutdown_String *message, uint32_t timeout, uint8_t force_apps, uint8_t reboot) +{ + uint32_t reason = 0; + + /* thunk down to _winreg_InitiateSystemShutdownEx() + (just returns a status) */ + + return _winreg_InitiateSystemShutdownEx( p, hostname, message, timeout, + force_apps, reboot, reason ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _initshutdown_InitEx(pipes_struct *p, uint16_t *hostname, struct initshutdown_String *message, uint32_t timeout, uint8_t force_apps, uint8_t reboot, uint32_t reason) +{ + return _winreg_InitiateSystemShutdownEx( p, hostname, message, timeout, + force_apps, reboot, reason ); +} + + + + +/******************************************************************* + reg_abort_shutdwon + ********************************************************************/ + +WERROR _initshutdown_Abort(pipes_struct *p, uint16_t *server) +{ + return _winreg_AbortSystemShutdown( p, server ); +} diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 5abf1c293a..b60ee37f40 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2364,7 +2364,7 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) wkssvc_get_pipe_fns( &cmds, &n_cmds ); break; case PI_WINREG: - reg_get_pipe_fns( &cmds, &n_cmds ); + winreg_get_pipe_fns( &cmds, &n_cmds ); break; case PI_SPOOLSS: spoolss_get_pipe_fns( &cmds, &n_cmds ); diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c deleted file mode 100644 index 1772524038..0000000000 --- a/source3/rpc_server/srv_reg.c +++ /dev/null @@ -1,659 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997, - * Copyright (C) Marc Jacobsen 2000, - * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Gerald Carter 2002, - * Copyright (C) Jim McDonough 2003. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* This is the interface for the registry functions. */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -/******************************************************************* - api_reg_close - ********************************************************************/ - -static BOOL api_reg_close(pipes_struct *p) -{ - REG_Q_CLOSE q_u; - REG_R_CLOSE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg unknown 1 */ - if(!reg_io_q_close("", &q_u, data, 0)) - return False; - - r_u.status = _reg_close(p, &q_u, &r_u); - - if(!reg_io_r_close("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_open_khlm - ********************************************************************/ - -static BOOL api_reg_open_hklm(pipes_struct *p) -{ - REG_Q_OPEN_HIVE q_u; - REG_R_OPEN_HIVE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg open */ - if(!reg_io_q_open_hive("", &q_u, data, 0)) - return False; - - r_u.status = _reg_open_hklm(p, &q_u, &r_u); - - if(!reg_io_r_open_hive("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_open_khu - ********************************************************************/ - -static BOOL api_reg_open_hku(pipes_struct *p) -{ - REG_Q_OPEN_HIVE q_u; - REG_R_OPEN_HIVE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg open */ - if(!reg_io_q_open_hive("", &q_u, data, 0)) - return False; - - r_u.status = _reg_open_hku(p, &q_u, &r_u); - - if(!reg_io_r_open_hive("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_open_khcr - ********************************************************************/ - -static BOOL api_reg_open_hkcr(pipes_struct *p) -{ - REG_Q_OPEN_HIVE q_u; - REG_R_OPEN_HIVE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg open */ - if(!reg_io_q_open_hive("", &q_u, data, 0)) - return False; - - r_u.status = _reg_open_hkcr(p, &q_u, &r_u); - - if(!reg_io_r_open_hive("", &r_u, rdata, 0)) - return False; - - return True; -} - - -/******************************************************************* - api_reg_open_entry - ********************************************************************/ - -static BOOL api_reg_open_entry(pipes_struct *p) -{ - REG_Q_OPEN_ENTRY q_u; - REG_R_OPEN_ENTRY r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg open entry */ - if(!reg_io_q_open_entry("", &q_u, data, 0)) - return False; - - /* construct reply. */ - r_u.status = _reg_open_entry(p, &q_u, &r_u); - - if(!reg_io_r_open_entry("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_query_value - ********************************************************************/ - -static BOOL api_reg_query_value(pipes_struct *p) -{ - REG_Q_QUERY_VALUE q_u; - REG_R_QUERY_VALUE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg unknown 0x11*/ - if(!reg_io_q_query_value("", &q_u, data, 0)) - return False; - - r_u.status = _reg_query_value(p, &q_u, &r_u); - - if(!reg_io_r_query_value("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_shutdown - ********************************************************************/ - -static BOOL api_reg_shutdown(pipes_struct *p) -{ - REG_Q_SHUTDOWN q_u; - REG_R_SHUTDOWN r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg shutdown */ - if(!reg_io_q_shutdown("", &q_u, data, 0)) - return False; - - r_u.status = _reg_shutdown(p, &q_u, &r_u); - - if(!reg_io_r_shutdown("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_shutdown_ex - ********************************************************************/ - -static BOOL api_reg_shutdown_ex(pipes_struct *p) -{ - REG_Q_SHUTDOWN_EX q_u; - REG_R_SHUTDOWN_EX r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg shutdown ex */ - if(!reg_io_q_shutdown_ex("", &q_u, data, 0)) - return False; - - r_u.status = _reg_shutdown_ex(p, &q_u, &r_u); - - if(!reg_io_r_shutdown_ex("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_abort_shutdown - ********************************************************************/ - -static BOOL api_reg_abort_shutdown(pipes_struct *p) -{ - REG_Q_ABORT_SHUTDOWN q_u; - REG_R_ABORT_SHUTDOWN r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg shutdown */ - if(!reg_io_q_abort_shutdown("", &q_u, data, 0)) - return False; - - r_u.status = _reg_abort_shutdown(p, &q_u, &r_u); - - if(!reg_io_r_abort_shutdown("", &r_u, rdata, 0)) - return False; - - return True; -} - - -/******************************************************************* - api_reg_query_key - ********************************************************************/ - -static BOOL api_reg_query_key(pipes_struct *p) -{ - REG_Q_QUERY_KEY q_u; - REG_R_QUERY_KEY r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_query_key("", &q_u, data, 0)) - return False; - - r_u.status = _reg_query_key(p, &q_u, &r_u); - - if(!reg_io_r_query_key("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_getversion - ********************************************************************/ - -static BOOL api_reg_getversion(pipes_struct *p) -{ - REG_Q_GETVERSION q_u; - REG_R_GETVERSION r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_getversion("", &q_u, data, 0)) - return False; - - r_u.status = _reg_getversion(p, &q_u, &r_u); - - if(!reg_io_r_getversion("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_enum_key - ********************************************************************/ - -static BOOL api_reg_enum_key(pipes_struct *p) -{ - REG_Q_ENUM_KEY q_u; - REG_R_ENUM_KEY r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_enum_key("", &q_u, data, 0)) - return False; - - r_u.status = _reg_enum_key(p, &q_u, &r_u); - - if(!reg_io_r_enum_key("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_enum_value - ********************************************************************/ - -static BOOL api_reg_enum_value(pipes_struct *p) -{ - REG_Q_ENUM_VALUE q_u; - REG_R_ENUM_VALUE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_enum_val("", &q_u, data, 0)) - return False; - - r_u.status = _reg_enum_value(p, &q_u, &r_u); - - if(!reg_io_r_enum_val("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - ******************************************************************/ - -static BOOL api_reg_restore_key(pipes_struct *p) -{ - REG_Q_RESTORE_KEY q_u; - REG_R_RESTORE_KEY r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_restore_key("", &q_u, data, 0)) - return False; - - r_u.status = _reg_restore_key(p, &q_u, &r_u); - - if(!reg_io_r_restore_key("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - ********************************************************************/ - -static BOOL api_reg_save_key(pipes_struct *p) -{ - REG_Q_SAVE_KEY q_u; - REG_R_SAVE_KEY r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_save_key("", &q_u, data, 0)) - return False; - - r_u.status = _reg_save_key(p, &q_u, &r_u); - - if(!reg_io_r_save_key("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_open_hkpd - ********************************************************************/ - -static BOOL api_reg_open_hkpd(pipes_struct *p) -{ - REG_Q_OPEN_HIVE q_u; - REG_R_OPEN_HIVE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg open */ - if(!reg_io_q_open_hive("", &q_u, data, 0)) - return False; - - r_u.status = _reg_open_hkpd(p, &q_u, &r_u); - - if(!reg_io_r_open_hive("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_reg_open_hkpd - ********************************************************************/ -static BOOL api_reg_open_hkpt(pipes_struct *p) -{ - REG_Q_OPEN_HIVE q_u; - REG_R_OPEN_HIVE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the reg open */ - if(!reg_io_q_open_hive("", &q_u, data, 0)) - return False; - - r_u.status = _reg_open_hkpt(p, &q_u, &r_u); - - if(!reg_io_r_open_hive("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - ******************************************************************/ - -static BOOL api_reg_create_key_ex(pipes_struct *p) -{ - REG_Q_CREATE_KEY_EX q_u; - REG_R_CREATE_KEY_EX r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_create_key_ex("", &q_u, data, 0)) - return False; - - r_u.status = _reg_create_key_ex(p, &q_u, &r_u); - - if(!reg_io_r_create_key_ex("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - ******************************************************************/ - -static BOOL api_reg_set_value(pipes_struct *p) -{ - REG_Q_SET_VALUE q_u; - REG_R_SET_VALUE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_set_value("", &q_u, data, 0)) - return False; - - r_u.status = _reg_set_value(p, &q_u, &r_u); - - if(!reg_io_r_set_value("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - ******************************************************************/ - -static BOOL api_reg_delete_key(pipes_struct *p) -{ - REG_Q_DELETE_KEY q_u; - REG_R_DELETE_KEY r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_delete_key("", &q_u, data, 0)) - return False; - - r_u.status = _reg_delete_key(p, &q_u, &r_u); - - if(!reg_io_r_delete_key("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - ******************************************************************/ - -static BOOL api_reg_delete_value(pipes_struct *p) -{ - REG_Q_DELETE_VALUE q_u; - REG_R_DELETE_VALUE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_delete_value("", &q_u, data, 0)) - return False; - - r_u.status = _reg_delete_value(p, &q_u, &r_u); - - if(!reg_io_r_delete_value("", &r_u, rdata, 0)) - return False; - - return True; -} - - -/******************************************************************* - ******************************************************************/ - -static BOOL api_reg_get_key_sec(pipes_struct *p) -{ - REG_Q_GET_KEY_SEC q_u; - REG_R_GET_KEY_SEC r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_get_key_sec("", &q_u, data, 0)) - return False; - - r_u.status = _reg_get_key_sec(p, &q_u, &r_u); - - if(!reg_io_r_get_key_sec("", &r_u, rdata, 0)) - return False; - - return True; -} - - -/******************************************************************* - ******************************************************************/ - -static BOOL api_reg_set_key_sec(pipes_struct *p) -{ - REG_Q_SET_KEY_SEC q_u; - REG_R_SET_KEY_SEC r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!reg_io_q_set_key_sec("", &q_u, data, 0)) - return False; - - r_u.status = _reg_set_key_sec(p, &q_u, &r_u); - - if(!reg_io_r_set_key_sec("", &r_u, rdata, 0)) - return False; - - return True; -} - - -/******************************************************************* - array of \PIPE\reg operations - ********************************************************************/ - -static struct api_struct api_reg_cmds[] = -{ - { "REG_CLOSE" , REG_CLOSE , api_reg_close }, - { "REG_OPEN_ENTRY" , REG_OPEN_ENTRY , api_reg_open_entry }, - { "REG_OPEN_HKCR" , REG_OPEN_HKCR , api_reg_open_hkcr }, - { "REG_OPEN_HKLM" , REG_OPEN_HKLM , api_reg_open_hklm }, - { "REG_OPEN_HKPD" , REG_OPEN_HKPD , api_reg_open_hkpd }, - { "REG_OPEN_HKPT" , REG_OPEN_HKPT , api_reg_open_hkpt }, - { "REG_OPEN_HKU" , REG_OPEN_HKU , api_reg_open_hku }, - { "REG_ENUM_KEY" , REG_ENUM_KEY , api_reg_enum_key }, - { "REG_ENUM_VALUE" , REG_ENUM_VALUE , api_reg_enum_value }, - { "REG_QUERY_KEY" , REG_QUERY_KEY , api_reg_query_key }, - { "REG_QUERY_VALUE" , REG_QUERY_VALUE , api_reg_query_value }, - { "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown }, - { "REG_SHUTDOWN_EX" , REG_SHUTDOWN_EX , api_reg_shutdown_ex }, - { "REG_ABORT_SHUTDOWN" , REG_ABORT_SHUTDOWN , api_reg_abort_shutdown }, - { "REG_GETVERSION" , REG_GETVERSION , api_reg_getversion }, - { "REG_SAVE_KEY" , REG_SAVE_KEY , api_reg_save_key }, - { "REG_RESTORE_KEY" , REG_RESTORE_KEY , api_reg_restore_key }, - { "REG_CREATE_KEY_EX" , REG_CREATE_KEY_EX , api_reg_create_key_ex }, - { "REG_SET_VALUE" , REG_SET_VALUE , api_reg_set_value }, - { "REG_DELETE_KEY" , REG_DELETE_KEY , api_reg_delete_key }, - { "REG_DELETE_VALUE" , REG_DELETE_VALUE , api_reg_delete_value }, - { "REG_GET_KEY_SEC" , REG_GET_KEY_SEC , api_reg_get_key_sec }, - { "REG_SET_KEY_SEC" , REG_SET_KEY_SEC , api_reg_set_key_sec } -}; - -void reg_get_pipe_fns( struct api_struct **fns, int *n_fns ) -{ - *fns = api_reg_cmds; - *n_fns = sizeof(api_reg_cmds) / sizeof(struct api_struct); -} - -NTSTATUS rpc_reg_init(void) -{ - - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "winreg", "winreg", api_reg_cmds, - sizeof(api_reg_cmds) / sizeof(struct api_struct)); -} diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c deleted file mode 100644 index 3728252c99..0000000000 --- a/source3/rpc_server/srv_reg_nt.c +++ /dev/null @@ -1,1352 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997. - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997. - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Gerald Carter 2002-2005. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* Implementation of registry functions. */ - -#include "includes.h" -#include "regfio.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -static struct generic_mapping reg_generic_map = - { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; - - -/****************************************************************** - free() function for REGISTRY_KEY - *****************************************************************/ - -static void free_regkey_info(void *ptr) -{ - regkey_close_internal( (REGISTRY_KEY*)ptr ); -} - -/****************************************************************** - Find a registry key handle and return a REGISTRY_KEY - *****************************************************************/ - -static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) -{ - REGISTRY_KEY *regkey = NULL; - - if(!find_policy_by_hnd(p,hnd,(void **)(void *)®key)) { - DEBUG(2,("find_regkey_index_by_hnd: Registry Key not found: ")); - return NULL; - } - - return regkey; -} - - -/******************************************************************* - Function for open a new registry handle and creating a handle - Note that P should be valid & hnd should already have space - - When we open a key, we store the full path to the key as - HK[LM|U]\\\... - *******************************************************************/ - -static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, - REGISTRY_KEY **keyinfo, REGISTRY_KEY *parent, - const char *subkeyname, uint32 access_desired ) -{ - pstring keypath; - int path_len; - WERROR result = WERR_OK; - - /* create a full registry path and strip any trailing '\' - characters */ - - pstr_sprintf( keypath, "%s%s%s", - parent ? parent->name : "", - parent ? "\\" : "", - subkeyname ); - - path_len = strlen( keypath ); - if ( path_len && keypath[path_len-1] == '\\' ) - keypath[path_len-1] = '\0'; - - /* now do the internal open */ - - result = regkey_open_internal( keyinfo, keypath, p->pipe_user.nt_user_token, access_desired ); - if ( !W_ERROR_IS_OK(result) ) - return result; - - if ( !create_policy_hnd( p, hnd, free_regkey_info, *keyinfo ) ) { - result = WERR_BADFILE; - regkey_close_internal( *keyinfo ); - } - - return result; -} - -/******************************************************************* - Function for open a new registry handle and creating a handle - Note that P should be valid & hnd should already have space - *******************************************************************/ - -static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd) -{ - REGISTRY_KEY *regkey = find_regkey_index_by_hnd(p, hnd); - - if ( !regkey ) { - DEBUG(2,("close_registry_key: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(hnd))); - return False; - } - - close_policy_hnd(p, hnd); - - return True; -} - -/******************************************************************** - retrieve information about the subkeys - *******************************************************************/ - -static BOOL get_subkey_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *maxlen ) -{ - int num_subkeys, i; - uint32 max_len; - REGSUBKEY_CTR *subkeys; - uint32 len; - - if ( !key ) - return False; - - if ( !(subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR )) ) - return False; - - if ( fetch_reg_keys( key, subkeys ) == -1 ) - return False; - - /* find the longest string */ - - max_len = 0; - num_subkeys = regsubkey_ctr_numkeys( subkeys ); - - for ( i=0; ivaluename ? strlen(val->valuename)+1 : 0 ); - sizemax = MAX(sizemax, val->size ); - - val = regval_ctr_specific_value( values, i ); - } - - *maxnum = num_values; - *maxlen = lenmax; - *maxsize = sizemax; - - TALLOC_FREE( values ); - - return True; -} - - -/******************************************************************** - reg_close - ********************************************************************/ - -WERROR _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u) -{ - /* close the policy handle */ - - if (!close_registry_key(p, &q_u->pol)) - return WERR_BADFID; - - return WERR_OK; -} - -/******************************************************************* - ********************************************************************/ - -WERROR _reg_open_hklm(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) -{ - REGISTRY_KEY *keyinfo; - - return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKLM, q_u->access ); -} - -/******************************************************************* - ********************************************************************/ - -WERROR _reg_open_hkpd(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) -{ - REGISTRY_KEY *keyinfo; - - return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKPD, q_u->access ); -} - -/******************************************************************* - ********************************************************************/ - -WERROR _reg_open_hkpt(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) -{ - REGISTRY_KEY *keyinfo; - - return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKPT, q_u->access ); -} - -/******************************************************************* - ********************************************************************/ - -WERROR _reg_open_hkcr(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) -{ - REGISTRY_KEY *keyinfo; - - return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKCR, q_u->access ); -} - -/******************************************************************* - ********************************************************************/ - -WERROR _reg_open_hku(pipes_struct *p, REG_Q_OPEN_HIVE *q_u, REG_R_OPEN_HIVE *r_u) -{ - REGISTRY_KEY *keyinfo; - - return open_registry_key( p, &r_u->pol, &keyinfo, NULL, KEY_HKU, q_u->access ); -} - -/******************************************************************* - reg_reply_open_entry - ********************************************************************/ - -WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY *r_u) -{ - fstring name; - REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->pol); - REGISTRY_KEY *newkey = NULL; - uint32 check_rights; - - if ( !parent ) - return WERR_BADFID; - - rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); - - /* check granted access first; what is the correct mask here? */ - - check_rights = ( SEC_RIGHTS_ENUM_SUBKEYS| - SEC_RIGHTS_CREATE_SUBKEY| - SEC_RIGHTS_QUERY_VALUE| - SEC_RIGHTS_SET_VALUE); - - if ( !(parent->access_granted & check_rights) ) { - DEBUG(8,("Rights check failed, parent had %04x, check_rights %04x\n",parent->access_granted, check_rights)); - return WERR_ACCESS_DENIED; - } - - /* - * very crazy, but regedit.exe on Win2k will attempt to call - * REG_OPEN_ENTRY with a keyname of "". We should return a new - * (second) handle here on the key->name. regedt32.exe does - * not do this stupidity. --jerry - */ - - return open_registry_key( p, &r_u->handle, &newkey, parent, name, q_u->access ); -} - -/******************************************************************* - reg_reply_info - ********************************************************************/ - -WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VALUE *r_u) -{ - WERROR status = WERR_BADFILE; - fstring name; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - REGISTRY_VALUE *val = NULL; - REGVAL_CTR *regvals; - int i; - - if ( !regkey ) - return WERR_BADFID; - - DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); - DEBUG(7,("_reg_info: policy key type = [%08x]\n", regkey->type)); - - rpcstr_pull(name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0); - - DEBUG(5,("_reg_info: looking up value: [%s]\n", name)); - - if ( !(regvals = TALLOC_ZERO_P( p->mem_ctx, REGVAL_CTR )) ) - return WERR_NOMEM; - - /* Handle QueryValue calls on HKEY_PERFORMANCE_DATA */ - if(regkey->type == REG_KEY_HKPD) - { - if(strequal(name, "Global")) - { - uint32 outbuf_len; - prs_struct prs_hkpd; - prs_init(&prs_hkpd, q_u->bufsize, p->mem_ctx, MARSHALL); - status = reg_perfcount_get_hkpd(&prs_hkpd, q_u->bufsize, &outbuf_len, NULL); - regval_ctr_addvalue(regvals, "HKPD", REG_BINARY, - prs_hkpd.data_p, outbuf_len); - val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); - prs_mem_free(&prs_hkpd); - } - else if(strequal(name, "Counter 009")) - { - uint32 base_index; - uint32 buffer_size; - char *buffer; - - buffer = NULL; - base_index = reg_perfcount_get_base_index(); - buffer_size = reg_perfcount_get_counter_names(base_index, &buffer); - regval_ctr_addvalue(regvals, "Counter 009", - REG_MULTI_SZ, buffer, buffer_size); - - val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); - - if(buffer_size > 0) - { - SAFE_FREE(buffer); - status = WERR_OK; - } - } - else if(strequal(name, "Explain 009")) - { - uint32 base_index; - uint32 buffer_size; - char *buffer; - - buffer = NULL; - base_index = reg_perfcount_get_base_index(); - buffer_size = reg_perfcount_get_counter_help(base_index, &buffer); - regval_ctr_addvalue(regvals, "Explain 009", - REG_MULTI_SZ, buffer, buffer_size); - - val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); - - if(buffer_size > 0) - { - SAFE_FREE(buffer); - status = WERR_OK; - } - } - else if(isdigit(name[0])) - { - /* we probably have a request for a specific object here */ - uint32 outbuf_len; - prs_struct prs_hkpd; - prs_init(&prs_hkpd, q_u->bufsize, p->mem_ctx, MARSHALL); - status = reg_perfcount_get_hkpd(&prs_hkpd, q_u->bufsize, &outbuf_len, name); - regval_ctr_addvalue(regvals, "HKPD", REG_BINARY, - prs_hkpd.data_p, outbuf_len); - - val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); - prs_mem_free(&prs_hkpd); - } - else - { - DEBUG(3,("Unsupported key name [%s] for HKPD.\n", name)); - return WERR_BADFILE; - } - } - /* HKPT calls can be handled out of reg_dynamic.c with the hkpt_params handler */ - else - { - for ( i=0; fetch_reg_values_specific(regkey, &val, i); i++ ) - { - DEBUG(10,("_reg_info: Testing value [%s]\n", val->valuename)); - if ( strequal( val->valuename, name ) ) { - DEBUG(10,("_reg_info: Found match for value [%s]\n", name)); - status = WERR_OK; - break; - } - - free_registry_value( val ); - } - } - - init_reg_r_query_value(q_u->ptr_buf, r_u, val, status); - - TALLOC_FREE( regvals ); - free_registry_value( val ); - - return status; -} - -/***************************************************************************** - Implementation of REG_QUERY_KEY - ****************************************************************************/ - -WERROR _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_u) -{ - WERROR status = WERR_OK; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - - if ( !regkey ) - return WERR_BADFID; - - if ( !get_subkey_information( regkey, &r_u->num_subkeys, &r_u->max_subkeylen ) ) { - DEBUG(0,("_reg_query_key: get_subkey_information() failed!\n")); - return WERR_ACCESS_DENIED; - } - - if ( !get_value_information( regkey, &r_u->num_values, &r_u->max_valnamelen, &r_u->max_valbufsize ) ) { - DEBUG(0,("_reg_query_key: get_value_information() failed!\n")); - return WERR_ACCESS_DENIED; - } - - - r_u->sec_desc = 0x00000078; /* size for key's sec_desc */ - - /* Win9x set this to 0x0 since it does not keep timestamps. - Doing the same here for simplicity --jerry */ - - ZERO_STRUCT(r_u->mod_time); - - return status; -} - - -/***************************************************************************** - Implementation of REG_GETVERSION - ****************************************************************************/ - -WERROR _reg_getversion(pipes_struct *p, REG_Q_GETVERSION *q_u, REG_R_GETVERSION *r_u) -{ - WERROR status = WERR_OK; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - - if ( !regkey ) - return WERR_BADFID; - - r_u->win_version = 0x00000005; /* Windows 2000 registry API version */ - - return status; -} - - -/***************************************************************************** - Implementation of REG_ENUM_KEY - ****************************************************************************/ - -WERROR _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u) -{ - WERROR status = WERR_OK; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - char *subkey = NULL; - - - if ( !regkey ) - return WERR_BADFID; - - DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", regkey->name)); - - if ( !fetch_reg_keys_specific( regkey, &subkey, q_u->key_index ) ) - { - status = WERR_NO_MORE_ITEMS; - goto done; - } - - DEBUG(10,("_reg_enum_key: retrieved subkey named [%s]\n", subkey)); - - /* subkey has the string name now */ - - init_reg_r_enum_key( r_u, subkey ); - -done: - SAFE_FREE( subkey ); - return status; -} - -/***************************************************************************** - Implementation of REG_ENUM_VALUE - ****************************************************************************/ - -WERROR _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE *r_u) -{ - WERROR status = WERR_OK; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - REGISTRY_VALUE *val; - - - if ( !regkey ) - return WERR_BADFID; - - DEBUG(8,("_reg_enum_value: enumerating values for key [%s]\n", regkey->name)); - - if ( !fetch_reg_values_specific( regkey, &val, q_u->val_index ) ) { - status = WERR_NO_MORE_ITEMS; - goto done; - } - -#if 0 /* JERRY TEST CODE */ - if ( val->type == REG_MULTI_SZ ) { - char **str; - int num_strings = regval_convert_multi_sz( (uint16*)regval_data_p(val), regval_size(val), &str ); - uint16 *buffer; - size_t buf_size; - - - if ( num_strings ) - buf_size = regval_build_multi_sz( str, &buffer ); - - TALLOC_FREE( str ); - TALLOC_FREE( buffer ); - } -#endif - - DEBUG(10,("_reg_enum_value: retrieved value named [%s]\n", val->valuename)); - - /* subkey has the string name now */ - - init_reg_r_enum_val( r_u, val ); - -done: - free_registry_value( val ); - - return status; -} - - -/******************************************************************* - reg_shutdwon - ********************************************************************/ - -WERROR _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) -{ - REG_Q_SHUTDOWN_EX q_u_ex; - REG_R_SHUTDOWN_EX r_u_ex; - - /* copy fields (including stealing memory) */ - - q_u_ex.server = q_u->server; - q_u_ex.message = q_u->message; - q_u_ex.timeout = q_u->timeout; - q_u_ex.force = q_u->force; - q_u_ex.reboot = q_u->reboot; - q_u_ex.reason = 0x0; /* don't care for now */ - - /* thunk down to _reg_shutdown_ex() (just returns a status) */ - - return _reg_shutdown_ex( p, &q_u_ex, &r_u_ex ); -} - -/******************************************************************* - reg_shutdown_ex - ********************************************************************/ - -#define SHUTDOWN_R_STRING "-r" -#define SHUTDOWN_F_STRING "-f" - - -WERROR _reg_shutdown_ex(pipes_struct *p, REG_Q_SHUTDOWN_EX *q_u, REG_R_SHUTDOWN_EX *r_u) -{ - pstring shutdown_script; - pstring message; - pstring chkmsg; - fstring timeout; - fstring reason; - fstring r; - fstring f; - int ret; - BOOL can_shutdown; - - - pstrcpy(shutdown_script, lp_shutdown_script()); - - if ( !*shutdown_script ) - return WERR_ACCESS_DENIED; - - /* pull the message string and perform necessary sanity checks on it */ - - pstrcpy( message, "" ); - if ( q_u->message ) { - UNISTR2 *msg_string = q_u->message->string; - - rpcstr_pull( message, msg_string->buffer, sizeof(message), msg_string->uni_str_len*2, 0 ); - } - alpha_strcpy (chkmsg, message, NULL, sizeof(message)); - - fstr_sprintf(timeout, "%d", q_u->timeout); - fstr_sprintf(r, (q_u->reboot) ? SHUTDOWN_R_STRING : ""); - fstr_sprintf(f, (q_u->force) ? SHUTDOWN_F_STRING : ""); - fstr_sprintf( reason, "%d", q_u->reason ); - - all_string_sub( shutdown_script, "%z", chkmsg, sizeof(shutdown_script) ); - all_string_sub( shutdown_script, "%t", timeout, sizeof(shutdown_script) ); - all_string_sub( shutdown_script, "%r", r, sizeof(shutdown_script) ); - all_string_sub( shutdown_script, "%f", f, sizeof(shutdown_script) ); - all_string_sub( shutdown_script, "%x", reason, sizeof(shutdown_script) ); - - can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_remote_shutdown ); - - /* IF someone has privs, run the shutdown script as root. OTHERWISE run it as not root - Take the error return from the script and provide it as the Windows return code. */ - - /********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/ - - if ( can_shutdown ) - become_root(); - - ret = smbrun( shutdown_script, NULL ); - - if ( can_shutdown ) - unbecome_root(); - - /********** END SeRemoteShutdownPrivilege BLOCK **********/ - - DEBUG(3,("_reg_shutdown_ex: Running the command `%s' gave %d\n", - shutdown_script, ret)); - - - return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; -} - - - - -/******************************************************************* - reg_abort_shutdwon - ********************************************************************/ - -WERROR _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABORT_SHUTDOWN *r_u) -{ - pstring abort_shutdown_script; - int ret; - BOOL can_shutdown; - - pstrcpy(abort_shutdown_script, lp_abort_shutdown_script()); - - if ( !*abort_shutdown_script ) - return WERR_ACCESS_DENIED; - - can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_remote_shutdown ); - - /********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/ - - if ( can_shutdown ) - become_root(); - - ret = smbrun( abort_shutdown_script, NULL ); - - if ( can_shutdown ) - unbecome_root(); - - /********** END SeRemoteShutdownPrivilege BLOCK **********/ - - DEBUG(3,("_reg_abort_shutdown: Running the command `%s' gave %d\n", - abort_shutdown_script, ret)); - - - return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; -} - -/******************************************************************* - ********************************************************************/ - -static int validate_reg_filename( pstring fname ) -{ - char *p; - int num_services = lp_numservices(); - int snum; - pstring share_path; - pstring unix_fname; - - /* convert to a unix path, stripping the C:\ along the way */ - - if ( !(p = valid_share_pathname( fname ) )) - return -1; - - /* has to exist within a valid file share */ - - for ( snum=0; snummem_ctx, REGSUBKEY_CTR )) ) - return WERR_NOMEM; - - if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) - return WERR_NOMEM; - - /* copy values into the REGVAL_CTR */ - - for ( i=0; inum_values; i++ ) { - regval_ctr_addvalue( values, key->values[i].valuename, key->values[i].type, - (char*)key->values[i].data, (key->values[i].data_size & ~VK_DATA_IN_OFFSET) ); - } - - /* copy subkeys into the REGSUBKEY_CTR */ - - key->subkey_index = 0; - while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { - regsubkey_ctr_addkey( subkeys, subkey->keyname ); - } - - /* write this key and values out */ - - if ( !store_reg_values( ®istry_key, values ) - || !store_reg_keys( ®istry_key, subkeys ) ) - { - DEBUG(0,("reg_load_tree: Failed to load %s!\n", topkeypath)); - result = WERR_REG_IO_FAILURE; - } - - TALLOC_FREE( subkeys ); - - if ( !W_ERROR_IS_OK(result) ) - return result; - - /* now continue to load each subkey registry tree */ - - key->subkey_index = 0; - while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { - pstr_sprintf( path, "%s%s%s", topkeypath, "\\", subkey->keyname ); - result = reg_load_tree( regfile, path, subkey ); - if ( !W_ERROR_IS_OK(result) ) - break; - } - - return result; -} - -/******************************************************************* - ********************************************************************/ - -static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) -{ - REGF_FILE *regfile; - REGF_NK_REC *rootkey; - WERROR result; - - /* open the registry file....fail if the file already exists */ - - if ( !(regfile = regfio_open( fname, (O_RDONLY), 0 )) ) { - DEBUG(0,("backup_registry_key: failed to open \"%s\" (%s)\n", - fname, strerror(errno) )); - return ( ntstatus_to_werror(map_nt_error_from_unix( errno )) ); - } - - /* get the rootkey from the regf file and then load the tree - via recursive calls */ - - if ( !(rootkey = regfio_rootkey( regfile )) ) { - regfio_close( regfile ); - return WERR_REG_FILE_INVALID; - } - - result = reg_load_tree( regfile, krecord->name, rootkey ); - - /* cleanup */ - - regfio_close( regfile ); - - return result; -} - -/******************************************************************* - ********************************************************************/ - -WERROR _reg_restore_key(pipes_struct *p, REG_Q_RESTORE_KEY *q_u, REG_R_RESTORE_KEY *r_u) -{ - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - pstring filename; - int snum; - - if ( !regkey ) - return WERR_BADFID; - - rpcstr_pull(filename, q_u->filename.string->buffer, sizeof(filename), q_u->filename.string->uni_str_len*2, STR_TERMINATE); - - DEBUG(8,("_reg_restore_key: verifying restore of key [%s] from \"%s\"\n", regkey->name, filename)); - - if ( (snum = validate_reg_filename( filename )) == -1 ) - return WERR_OBJECT_PATH_INVALID; - - /* user must posses SeRestorePrivilege for this this proceed */ - - if ( !user_has_privileges( p->pipe_user.nt_user_token, &se_restore ) ) - return WERR_ACCESS_DENIED; - - DEBUG(2,("_reg_restore_key: Restoring [%s] from %s in share %s\n", regkey->name, filename, lp_servicename(snum) )); - - return restore_registry_key( regkey, filename ); -} - -/******************************************************************** -********************************************************************/ - -static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, - REGF_NK_REC *parent, SEC_DESC *sec_desc ) -{ - REGF_NK_REC *key; - REGVAL_CTR *values; - REGSUBKEY_CTR *subkeys; - int i, num_subkeys; - pstring key_tmp; - char *keyname, *parentpath; - pstring subkeypath; - char *subkeyname; - REGISTRY_KEY registry_key; - WERROR result = WERR_OK; - - if ( !regfile ) - return WERR_GENERAL_FAILURE; - - if ( !keypath ) - return WERR_OBJECT_PATH_INVALID; - - /* split up the registry key path */ - - pstrcpy( key_tmp, keypath ); - if ( !reg_split_key( key_tmp, &parentpath, &keyname ) ) - return WERR_OBJECT_PATH_INVALID; - - if ( !keyname ) - keyname = parentpath; - - /* we need a REGISTRY_KEY object here to enumerate subkeys and values */ - - ZERO_STRUCT( registry_key ); - pstrcpy( registry_key.name, keypath ); - if ( !(registry_key.hook = reghook_cache_find( registry_key.name )) ) - return WERR_BADFILE; - - - /* lookup the values and subkeys */ - - if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) - return WERR_NOMEM; - - if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) - return WERR_NOMEM; - - fetch_reg_keys( ®istry_key, subkeys ); - fetch_reg_values( ®istry_key, values ); - - /* write out this key */ - - if ( !(key = regfio_write_key( regfile, keyname, values, subkeys, sec_desc, parent )) ) { - result = WERR_CAN_NOT_COMPLETE; - goto done; - } - - /* write each one of the subkeys out */ - - num_subkeys = regsubkey_ctr_numkeys( subkeys ); - for ( i=0; imem_ctx, &sd )) ) { - regfio_close( regfile ); - return result; - } - - /* write the registry tree to the file */ - - result = reg_write_tree( regfile, krecord->name, NULL, sd ); - - /* cleanup */ - - regfio_close( regfile ); - - return result; -} - -/******************************************************************* - ********************************************************************/ - -WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u) -{ - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - pstring filename; - int snum; - - if ( !regkey ) - return WERR_BADFID; - - rpcstr_pull(filename, q_u->filename.string->buffer, sizeof(filename), q_u->filename.string->uni_str_len*2, STR_TERMINATE); - - DEBUG(8,("_reg_save_key: verifying backup of key [%s] to \"%s\"\n", regkey->name, filename)); - - if ( (snum = validate_reg_filename( filename )) == -1 ) - return WERR_OBJECT_PATH_INVALID; - - DEBUG(2,("_reg_save_key: Saving [%s] to %s in share %s\n", regkey->name, filename, lp_servicename(snum) )); - - return backup_registry_key( regkey, filename ); -} - -/******************************************************************* - ********************************************************************/ - -WERROR _reg_create_key_ex(pipes_struct *p, REG_Q_CREATE_KEY_EX *q_u, REG_R_CREATE_KEY_EX *r_u) -{ - REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->handle); - REGISTRY_KEY *newparentinfo, *keyinfo; - POLICY_HND newparent_handle; - REGSUBKEY_CTR *subkeys; - BOOL write_result; - pstring name; - WERROR result; - - if ( !parent ) - return WERR_BADFID; - - rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); - - /* ok. Here's what we do. */ - - if ( strrchr( name, '\\' ) ) { - pstring newkeyname; - char *ptr; - - /* (1) check for enumerate rights on the parent handle. CLients can try - create things like 'SOFTWARE\Samba' on the HKLM handle. - (2) open the path to the child parent key if necessary */ - - if ( !(parent->access_granted & SEC_RIGHTS_ENUM_SUBKEYS) ) - return WERR_ACCESS_DENIED; - - pstrcpy( newkeyname, name ); - ptr = strrchr( newkeyname, '\\' ); - *ptr = '\0'; - - result = open_registry_key( p, &newparent_handle, &newparentinfo, - parent, newkeyname, (REG_KEY_READ|REG_KEY_WRITE) ); - - if ( !W_ERROR_IS_OK(result) ) - return result; - - /* copy the new key name (just the lower most keyname) */ - - pstrcpy( name, ptr+1 ); - } - else { - /* use the existing open key information */ - newparentinfo = parent; - memcpy( &newparent_handle, &q_u->handle, sizeof(POLICY_HND) ); - } - - /* (3) check for create subkey rights on the correct parent */ - - if ( !(newparentinfo->access_granted & SEC_RIGHTS_CREATE_SUBKEY) ) { - result = WERR_ACCESS_DENIED; - goto done; - } - - if ( !(subkeys = TALLOC_ZERO_P( p->mem_ctx, REGSUBKEY_CTR )) ) { - result = WERR_NOMEM; - goto done; - } - - /* (4) lookup the current keys and add the new one */ - - fetch_reg_keys( newparentinfo, subkeys ); - regsubkey_ctr_addkey( subkeys, name ); - - /* now write to the registry backend */ - - write_result = store_reg_keys( newparentinfo, subkeys ); - - TALLOC_FREE( subkeys ); - - if ( !write_result ) - return WERR_REG_IO_FAILURE; - - /* (5) open the new key and return the handle. Note that it is probably - not correct to grant full access on this open handle. */ - - result = open_registry_key( p, &r_u->handle, &keyinfo, newparentinfo, name, REG_KEY_READ ); - keyinfo->access_granted = REG_KEY_ALL; - -done: - /* close any intermediate key handles */ - - if ( newparentinfo != parent ) - close_registry_key( p, &newparent_handle ); - - return result; -} - - -/******************************************************************* - ********************************************************************/ - -WERROR _reg_set_value(pipes_struct *p, REG_Q_SET_VALUE *q_u, REG_R_SET_VALUE *r_u) -{ - REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); - REGVAL_CTR *values; - BOOL write_result; - fstring valuename; - - if ( !key ) - return WERR_BADFID; - - /* access checks first */ - - if ( !(key->access_granted & SEC_RIGHTS_SET_VALUE) ) - return WERR_ACCESS_DENIED; - - rpcstr_pull( valuename, q_u->name.string->buffer, sizeof(valuename), q_u->name.string->uni_str_len*2, 0 ); - - /* verify the name */ - - if ( !*valuename ) - return WERR_INVALID_PARAM; - - DEBUG(8,("_reg_set_value: Setting value for [%s:%s]\n", key->name, valuename)); - - if ( !(values = TALLOC_ZERO_P( p->mem_ctx, REGVAL_CTR )) ) - return WERR_NOMEM; - - /* lookup the current values and add the new one */ - - fetch_reg_values( key, values ); - - regval_ctr_addvalue( values, valuename, q_u->type, (char*)q_u->value.buffer, q_u->value.buf_len ); - - /* now write to the registry backend */ - - write_result = store_reg_values( key, values ); - - TALLOC_FREE( values ); - - if ( !write_result ) - return WERR_REG_IO_FAILURE; - - return WERR_OK; -} - -/******************************************************************* - ********************************************************************/ - -WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY *r_u) -{ - REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, &q_u->handle); - REGISTRY_KEY *newparentinfo = NULL; - POLICY_HND newparent_handle; - REGSUBKEY_CTR *subkeys; - BOOL write_result; - pstring name; - WERROR result; - - if ( !parent ) - return WERR_BADFID; - - /* MSDN says parent the handle must have been opened with DELETE access */ - - /* (1) check for delete rights on the parent */ - - if ( !(parent->access_granted & STD_RIGHT_DELETE_ACCESS) ) { - result = WERR_ACCESS_DENIED; - goto done; - } - - rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 ); - - /* ok. Here's what we do. */ - - if ( strrchr( name, '\\' ) ) { - pstring newkeyname; - char *ptr; - - /* (2) open the path to the child parent key if necessary */ - /* split the registry path and save the subkeyname */ - - pstrcpy( newkeyname, name ); - ptr = strrchr( newkeyname, '\\' ); - *ptr = '\0'; - pstrcpy( name, ptr+1 ); - - result = open_registry_key( p, &newparent_handle, &newparentinfo, parent, newkeyname, (REG_KEY_READ|REG_KEY_WRITE) ); - if ( !W_ERROR_IS_OK(result) ) - return result; - } - else { - /* use the existing open key information */ - newparentinfo = parent; - } - - if ( !(subkeys = TALLOC_ZERO_P( p->mem_ctx, REGSUBKEY_CTR )) ) { - result = WERR_NOMEM; - goto done; - } - - /* lookup the current keys and delete the new one */ - - fetch_reg_keys( newparentinfo, subkeys ); - - regsubkey_ctr_delkey( subkeys, name ); - - /* now write to the registry backend */ - - write_result = store_reg_keys( newparentinfo, subkeys ); - - TALLOC_FREE( subkeys ); - - result = write_result ? WERR_OK : WERR_REG_IO_FAILURE; - -done: - /* close any intermediate key handles */ - - if ( newparentinfo != parent ) - close_registry_key( p, &newparent_handle ); - - return result; -} - - -/******************************************************************* - ********************************************************************/ - -WERROR _reg_delete_value(pipes_struct *p, REG_Q_DELETE_VALUE *q_u, REG_R_DELETE_VALUE *r_u) -{ - REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); - REGVAL_CTR *values; - BOOL write_result; - fstring valuename; - - if ( !key ) - return WERR_BADFID; - - /* access checks first */ - - if ( !(key->access_granted & SEC_RIGHTS_SET_VALUE) ) - return WERR_ACCESS_DENIED; - - rpcstr_pull( valuename, q_u->name.string->buffer, sizeof(valuename), q_u->name.string->uni_str_len*2, 0 ); - - if ( !*valuename ) - return WERR_INVALID_PARAM; - - DEBUG(8,("_reg_delete_value: Setting value for [%s:%s]\n", key->name, valuename)); - - if ( !(values = TALLOC_ZERO_P( p->mem_ctx, REGVAL_CTR )) ) - return WERR_NOMEM; - - /* lookup the current values and add the new one */ - - fetch_reg_values( key, values ); - - regval_ctr_delvalue( values, valuename ); - - /* now write to the registry backend */ - - write_result = store_reg_values( key, values ); - - TALLOC_FREE( values ); - - if ( !write_result ) - return WERR_REG_IO_FAILURE; - - return WERR_OK; -} - -/******************************************************************* - ********************************************************************/ - -WERROR _reg_get_key_sec(pipes_struct *p, REG_Q_GET_KEY_SEC *q_u, REG_R_GET_KEY_SEC *r_u) -{ - REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); - - if ( !key ) - return WERR_BADFID; - - /* access checks first */ - - if ( !(key->access_granted & STD_RIGHT_READ_CONTROL_ACCESS) ) - return WERR_ACCESS_DENIED; - - return WERR_ACCESS_DENIED; -} - -/******************************************************************* - ********************************************************************/ - -WERROR _reg_set_key_sec(pipes_struct *p, REG_Q_SET_KEY_SEC *q_u, REG_R_SET_KEY_SEC *r_u) -{ - REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle); - - if ( !key ) - return WERR_BADFID; - - /* access checks first */ - - if ( !(key->access_granted & STD_RIGHT_WRITE_DAC_ACCESS) ) - return WERR_ACCESS_DENIED; - - return WERR_ACCESS_DENIED; -} diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c new file mode 100644 index 0000000000..aea848fd17 --- /dev/null +++ b/source3/rpc_server/srv_winreg_nt.c @@ -0,0 +1,1518 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Gerald Carter 2002-2005. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* Implementation of registry functions. */ + +#include "includes.h" +#include "regfio.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +#if 0 /* temporaily disabled */ +static struct generic_mapping reg_generic_map = + { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; +#endif + +/****************************************************************** + free() function for REGISTRY_KEY + *****************************************************************/ + +static void free_regkey_info(void *ptr) +{ + regkey_close_internal( (REGISTRY_KEY*)ptr ); +} + +/****************************************************************** + Find a registry key handle and return a REGISTRY_KEY + *****************************************************************/ + +static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) +{ + REGISTRY_KEY *regkey = NULL; + + if(!find_policy_by_hnd(p,hnd,(void **)(void *)®key)) { + DEBUG(2,("find_regkey_index_by_hnd: Registry Key not found: ")); + return NULL; + } + + return regkey; +} + + +/******************************************************************* + Function for open a new registry handle and creating a handle + Note that P should be valid & hnd should already have space + + When we open a key, we store the full path to the key as + HK[LM|U]\\\... + *******************************************************************/ + +static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, + REGISTRY_KEY **keyinfo, REGISTRY_KEY *parent, + const char *subkeyname, uint32 access_desired ) +{ + pstring keypath; + int path_len; + WERROR result = WERR_OK; + + /* create a full registry path and strip any trailing '\' + characters */ + + pstr_sprintf( keypath, "%s%s%s", + parent ? parent->name : "", + parent ? "\\" : "", + subkeyname ); + + path_len = strlen( keypath ); + if ( path_len && keypath[path_len-1] == '\\' ) + keypath[path_len-1] = '\0'; + + /* now do the internal open */ + + result = regkey_open_internal( keyinfo, keypath, p->pipe_user.nt_user_token, access_desired ); + if ( !W_ERROR_IS_OK(result) ) + return result; + + if ( !create_policy_hnd( p, hnd, free_regkey_info, *keyinfo ) ) { + result = WERR_BADFILE; + regkey_close_internal( *keyinfo ); + } + + return result; +} + +/******************************************************************* + Function for open a new registry handle and creating a handle + Note that P should be valid & hnd should already have space + *******************************************************************/ + +static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd) +{ + REGISTRY_KEY *regkey = find_regkey_index_by_hnd(p, hnd); + + if ( !regkey ) { + DEBUG(2,("close_registry_key: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(hnd))); + return False; + } + + close_policy_hnd(p, hnd); + + return True; +} + +/******************************************************************** + retrieve information about the subkeys + *******************************************************************/ + +static BOOL get_subkey_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *maxlen ) +{ + int num_subkeys, i; + uint32 max_len; + REGSUBKEY_CTR *subkeys; + uint32 len; + + if ( !key ) + return False; + + if ( !(subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR )) ) + return False; + + if ( fetch_reg_keys( key, subkeys ) == -1 ) + return False; + + /* find the longest string */ + + max_len = 0; + num_subkeys = regsubkey_ctr_numkeys( subkeys ); + + for ( i=0; ivaluename ? strlen(val->valuename)+1 : 0 ); + sizemax = MAX(sizemax, val->size ); + + val = regval_ctr_specific_value( values, i ); + } + + *maxnum = num_values; + *maxlen = lenmax; + *maxsize = sizemax; + + TALLOC_FREE( values ); + + return True; +} + + +/******************************************************************** + reg_close + ********************************************************************/ + +WERROR _winreg_CloseKey(pipes_struct *p, struct policy_handle *handle) +{ + /* close the policy handle */ + + if (!close_registry_key(p, handle)) + return WERR_BADFID; + + return WERR_OK; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_OpenHKLM(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +{ + REGISTRY_KEY *keyinfo; + + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKLM, access_mask ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_OpenHKPD(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +{ + REGISTRY_KEY *keyinfo; + + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKPD, access_mask ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_OpenHKPT(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +{ + REGISTRY_KEY *keyinfo; + + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKPT, access_mask ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_OpenHKCR(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +{ + REGISTRY_KEY *keyinfo; + + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKCR, access_mask ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_OpenHKU(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +{ + REGISTRY_KEY *keyinfo; + + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKU, access_mask ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_OpenHKCU(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +{ + REGISTRY_KEY *keyinfo; + + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKCU, access_mask ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_OpenHKCC(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +{ + REGISTRY_KEY *keyinfo; + + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKCC, access_mask ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_OpenHKDD(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +{ + REGISTRY_KEY *keyinfo; + + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKDD, access_mask ); +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_OpenHKPN(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +{ + REGISTRY_KEY *keyinfo; + + return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKPN, access_mask ); +} + +/******************************************************************* + reg_reply_open_entry + ********************************************************************/ + +WERROR _winreg_OpenKey(pipes_struct *p, struct policy_handle *parent_handle, struct winreg_String keyname, uint32_t unknown, uint32_t access_mask, struct policy_handle *handle) +{ + char *name; + REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, parent_handle ); + REGISTRY_KEY *newkey = NULL; + uint32 check_rights; + + if ( !parent ) + return WERR_BADFID; + + if ( (name = talloc_strdup( p->mem_ctx, keyname.name )) == NULL ) { + return WERR_INVALID_PARAM; + } + + /* check granted access first; what is the correct mask here? */ + + check_rights = ( SEC_RIGHTS_ENUM_SUBKEYS| + SEC_RIGHTS_CREATE_SUBKEY| + SEC_RIGHTS_QUERY_VALUE| + SEC_RIGHTS_SET_VALUE); + + if ( !(parent->access_granted & check_rights) ) { + DEBUG(8,("Rights check failed, parent had %04x, check_rights %04x\n",parent->access_granted, check_rights)); + return WERR_ACCESS_DENIED; + } + + /* + * very crazy, but regedit.exe on Win2k will attempt to call + * REG_OPEN_ENTRY with a keyname of "". We should return a new + * (second) handle here on the key->name. regedt32.exe does + * not do this stupidity. --jerry + */ + + return open_registry_key( p, handle, &newkey, parent, name, access_mask ); +} + +/******************************************************************* + reg_reply_info + ********************************************************************/ + +WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t **data, uint32_t *size, uint32_t *length) +{ + WERROR status = WERR_BADFILE; + char *name; + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + REGISTRY_VALUE *val = NULL; + REGVAL_CTR *regvals; + int i; + + if ( !regkey ) + return WERR_BADFID; + + *size = *length = *type = 0; + value_name.name = NULL; + + DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); + DEBUG(7,("_reg_info: policy key type = [%08x]\n", regkey->type)); + + if ( (name = talloc_strdup( p->mem_ctx, value_name.name )) == NULL ) { + return WERR_NOMEM; + } + + DEBUG(5,("_reg_info: looking up value: [%s]\n", name)); + + if ( !(regvals = TALLOC_ZERO_P( p->mem_ctx, REGVAL_CTR )) ) + return WERR_NOMEM; + + /* Handle QueryValue calls on HKEY_PERFORMANCE_DATA */ + if(regkey->type == REG_KEY_HKPD) + { + if(strequal(name, "Global")) + { + uint32 outbuf_len; + prs_struct prs_hkpd; + prs_init(&prs_hkpd, *size, p->mem_ctx, MARSHALL); + status = reg_perfcount_get_hkpd(&prs_hkpd, *size, &outbuf_len, NULL); + regval_ctr_addvalue(regvals, "HKPD", REG_BINARY, + prs_hkpd.data_p, outbuf_len); + val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); + prs_mem_free(&prs_hkpd); + } + else if(strequal(name, "Counter 009")) + { + uint32 base_index; + uint32 buffer_size; + char *buffer; + + buffer = NULL; + base_index = reg_perfcount_get_base_index(); + buffer_size = reg_perfcount_get_counter_names(base_index, &buffer); + regval_ctr_addvalue(regvals, "Counter 009", + REG_MULTI_SZ, buffer, buffer_size); + + val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); + + if(buffer_size > 0) + { + SAFE_FREE(buffer); + status = WERR_OK; + } + } + else if(strequal(name, "Explain 009")) + { + uint32 base_index; + uint32 buffer_size; + char *buffer; + + buffer = NULL; + base_index = reg_perfcount_get_base_index(); + buffer_size = reg_perfcount_get_counter_help(base_index, &buffer); + regval_ctr_addvalue(regvals, "Explain 009", + REG_MULTI_SZ, buffer, buffer_size); + + val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); + + if(buffer_size > 0) + { + SAFE_FREE(buffer); + status = WERR_OK; + } + } + else if(isdigit(name[0])) + { + /* we probably have a request for a specific object here */ + uint32 outbuf_len; + prs_struct prs_hkpd; + prs_init(&prs_hkpd, *size, p->mem_ctx, MARSHALL); + status = reg_perfcount_get_hkpd(&prs_hkpd, *size, &outbuf_len, name); + regval_ctr_addvalue(regvals, "HKPD", REG_BINARY, + prs_hkpd.data_p, outbuf_len); + + val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); + prs_mem_free(&prs_hkpd); + } + else + { + DEBUG(3,("Unsupported key name [%s] for HKPD.\n", name)); + return WERR_BADFILE; + } + } + /* HKPT calls can be handled out of reg_dynamic.c with the hkpt_params handler */ + else + { + for ( i=0; fetch_reg_values_specific(regkey, &val, i); i++ ) + { + DEBUG(10,("_reg_info: Testing value [%s]\n", val->valuename)); + if ( strequal( val->valuename, name ) ) { + DEBUG(10,("_reg_info: Found match for value [%s]\n", name)); + status = WERR_OK; + break; + } + + free_registry_value( val ); + } + } + + if ( val ) { + *size = regval_size( val ); + *length = regval_size( val ); + + if ( (*data = talloc_memdup( p->mem_ctx, regval_data_p(val), *size )) == NULL ) { + status = WERR_NOMEM; + } + + *type = val->type; + } + + TALLOC_FREE( regvals ); + free_registry_value( val ); + + return status; +} + +/***************************************************************************** + Implementation of REG_QUERY_KEY + ****************************************************************************/ + +WERROR _winreg_QueryInfoKey(pipes_struct *p, struct policy_handle *handle, + struct winreg_String class_in, + struct winreg_String *class_out, uint32_t *num_subkeys, + uint32_t *max_subkeylen, uint32_t *max_subkeysize, + uint32_t *num_values, uint32_t *max_valnamelen, + uint32_t *max_valbufsize, uint32_t *secdescsize, + NTTIME *last_changed_time) +{ + WERROR status = WERR_OK; + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + + if ( !regkey ) + return WERR_BADFID; + + if ( !get_subkey_information( regkey, num_subkeys, max_subkeylen) ) { + DEBUG(0,("_reg_query_key: get_subkey_information() failed!\n")); + return WERR_ACCESS_DENIED; + } + + if ( !get_value_information( regkey, num_values, max_valnamelen, max_valbufsize) ) { + DEBUG(0,("_reg_query_key: get_value_information() failed!\n")); + return WERR_ACCESS_DENIED; + } + + *secdescsize = 0x00000078; /* size for key's sec_desc */ + + /* Win9x set this to 0x0 since it does not keep timestamps. + Doing the same here for simplicity --jerry */ + + *last_changed_time = 0; + + return status; +} + + +/***************************************************************************** + Implementation of REG_GETVERSION + ****************************************************************************/ + +WERROR _winreg_GetVersion(pipes_struct *p, struct policy_handle *handle, uint32_t *version) +{ + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + + if ( !regkey ) + return WERR_BADFID; + + *version = 0x00000005; /* Windows 2000 registry API version */ + + return WERR_OK; +} + + +/***************************************************************************** + Implementation of REG_ENUM_KEY + ****************************************************************************/ + +WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_StringBuf *name, struct winreg_StringBuf *keyclass, NTTIME *last_changed_time) +{ + WERROR status = WERR_OK; + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + char *subkey = NULL; + + + if ( !regkey ) + return WERR_BADFID; + + if ( !name || !keyclass || !last_changed_time ) + return WERR_INVALID_PARAM; + + DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", regkey->name)); + + if ( !fetch_reg_keys_specific( regkey, &subkey, enum_index ) ) { + status = WERR_NO_MORE_ITEMS; + goto done; + } + + DEBUG(10,("_reg_enum_key: retrieved subkey named [%s]\n", subkey)); + + *last_changed_time = 0; + keyclass->name = NULL; + if ( (name->name = talloc_strdup( p->mem_ctx, subkey )) == NULL ) { + status = WERR_NOMEM; + } + +done: + SAFE_FREE( subkey ); + return status; +} + +/***************************************************************************** + Implementation of REG_ENUM_VALUE + ****************************************************************************/ + +WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_StringBuf *name, enum winreg_Type *type, uint8_t *value, uint32_t *size, uint32_t *length) +{ + WERROR status = WERR_OK; + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + REGISTRY_VALUE *val; + + if ( !regkey ) + return WERR_BADFID; + + if ( !name || !type || !value || !size || !length ) + return WERR_INVALID_PARAM; + + DEBUG(8,("_reg_enum_value: enumerating values for key [%s]\n", regkey->name)); + + if ( !fetch_reg_values_specific( regkey, &val, enum_index ) ) { + status = WERR_NO_MORE_ITEMS; + goto done; + } + + DEBUG(10,("_reg_enum_value: retrieved value named [%s]\n", val->valuename)); + + /* subkey has the string name now */ + + if ( (name->name = talloc_strdup( p->mem_ctx, val->valuename )) == NULL ) { + status = WERR_NOMEM; + } + + *size = regval_size( val ); + *length = regval_size( val ); + + if ( (value = talloc_memdup( p->mem_ctx, regval_data_p(val), *size )) == NULL ) { + status = WERR_NOMEM; + } + + *type = val->type; + +done: + free_registry_value( val ); + + return status; +} + + +/******************************************************************* + reg_shutdwon + ********************************************************************/ + +WERROR _winreg_InitiateSystemShutdown(pipes_struct *p, uint16_t *hostname, struct initshutdown_String *message, uint32_t timeout, uint8_t force_apps, uint8_t reboot) +{ + uint32_t reason = 0; + + /* thunk down to _winreg_InitiateSystemShutdownEx() + (just returns a status) */ + + return _winreg_InitiateSystemShutdownEx( p, hostname, message, timeout, + force_apps, reboot, reason ); +} + +/******************************************************************* + reg_shutdown_ex + ********************************************************************/ + +#define SHUTDOWN_R_STRING "-r" +#define SHUTDOWN_F_STRING "-f" + + +WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, uint16_t *hostname, struct initshutdown_String *message, uint32_t timeout, uint8_t force_apps, uint8_t reboot, uint32_t reason) +{ + pstring shutdown_script; + char *msg = NULL; + pstring chkmsg; + fstring str_timeout; + fstring str_reason; + fstring r; + fstring f; + int ret; + BOOL can_shutdown; + + + pstrcpy(shutdown_script, lp_shutdown_script()); + + if ( !*shutdown_script ) + return WERR_ACCESS_DENIED; + + /* pull the message string and perform necessary sanity checks on it */ + + if ( message && message->name && message->name->name ) { + if ( (msg = talloc_strdup(p->mem_ctx, message->name->name )) == NULL ) { + return WERR_NOMEM; + } + } + alpha_strcpy (chkmsg, msg?msg:"", NULL, strlen(msg)); + + fstr_sprintf(str_timeout, "%d", timeout); + fstr_sprintf(r, reboot ? SHUTDOWN_R_STRING : ""); + fstr_sprintf(f, force_apps ? SHUTDOWN_F_STRING : ""); + fstr_sprintf(str_reason, "%d", reason ); + + all_string_sub( shutdown_script, "%z", chkmsg, sizeof(shutdown_script) ); + all_string_sub( shutdown_script, "%t", str_timeout, sizeof(shutdown_script) ); + all_string_sub( shutdown_script, "%r", r, sizeof(shutdown_script) ); + all_string_sub( shutdown_script, "%f", f, sizeof(shutdown_script) ); + all_string_sub( shutdown_script, "%x", str_reason, sizeof(shutdown_script) ); + + can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_remote_shutdown ); + + /* IF someone has privs, run the shutdown script as root. OTHERWISE run it as not root + Take the error return from the script and provide it as the Windows return code. */ + + /********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/ + + if ( can_shutdown ) + become_root(); + + ret = smbrun( shutdown_script, NULL ); + + if ( can_shutdown ) + unbecome_root(); + + /********** END SeRemoteShutdownPrivilege BLOCK **********/ + + DEBUG(3,("_reg_shutdown_ex: Running the command `%s' gave %d\n", + shutdown_script, ret)); + + + return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; +} + + + + +/******************************************************************* + reg_abort_shutdwon + ********************************************************************/ + +WERROR _winreg_AbortSystemShutdown(pipes_struct *p, uint16_t *server) +{ + pstring abort_shutdown_script; + int ret; + BOOL can_shutdown; + + pstrcpy(abort_shutdown_script, lp_abort_shutdown_script()); + + if ( !*abort_shutdown_script ) + return WERR_ACCESS_DENIED; + + can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_remote_shutdown ); + + /********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/ + + if ( can_shutdown ) + become_root(); + + ret = smbrun( abort_shutdown_script, NULL ); + + if ( can_shutdown ) + unbecome_root(); + + /********** END SeRemoteShutdownPrivilege BLOCK **********/ + + DEBUG(3,("_reg_abort_shutdown: Running the command `%s' gave %d\n", + abort_shutdown_script, ret)); + + + return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; +} + +#if 0 /* This code works but is disabled for now until I + fix the WinReg IDL file -- jerry */ + +/******************************************************************* + ********************************************************************/ + +static int validate_reg_filename( pstring fname ) +{ + char *p; + int num_services = lp_numservices(); + int snum; + pstring share_path; + pstring unix_fname; + + /* convert to a unix path, stripping the C:\ along the way */ + + if ( !(p = valid_share_pathname( fname ) )) + return -1; + + /* has to exist within a valid file share */ + + for ( snum=0; snummem_ctx, REGSUBKEY_CTR )) ) + return WERR_NOMEM; + + if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) + return WERR_NOMEM; + + /* copy values into the REGVAL_CTR */ + + for ( i=0; inum_values; i++ ) { + regval_ctr_addvalue( values, key->values[i].valuename, key->values[i].type, + (char*)key->values[i].data, (key->values[i].data_size & ~VK_DATA_IN_OFFSET) ); + } + + /* copy subkeys into the REGSUBKEY_CTR */ + + key->subkey_index = 0; + while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { + regsubkey_ctr_addkey( subkeys, subkey->keyname ); + } + + /* write this key and values out */ + + if ( !store_reg_values( ®istry_key, values ) + || !store_reg_keys( ®istry_key, subkeys ) ) + { + DEBUG(0,("reg_load_tree: Failed to load %s!\n", topkeypath)); + result = WERR_REG_IO_FAILURE; + } + + TALLOC_FREE( subkeys ); + + if ( !W_ERROR_IS_OK(result) ) + return result; + + /* now continue to load each subkey registry tree */ + + key->subkey_index = 0; + while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { + pstr_sprintf( path, "%s%s%s", topkeypath, "\\", subkey->keyname ); + result = reg_load_tree( regfile, path, subkey ); + if ( !W_ERROR_IS_OK(result) ) + break; + } + + return result; +} + +/******************************************************************* + ********************************************************************/ + +static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) +{ + REGF_FILE *regfile; + REGF_NK_REC *rootkey; + WERROR result; + + /* open the registry file....fail if the file already exists */ + + if ( !(regfile = regfio_open( fname, (O_RDONLY), 0 )) ) { + DEBUG(0,("restore_registry_key: failed to open \"%s\" (%s)\n", + fname, strerror(errno) )); + return ( ntstatus_to_werror(map_nt_error_from_unix( errno )) ); + } + + /* get the rootkey from the regf file and then load the tree + via recursive calls */ + + if ( !(rootkey = regfio_rootkey( regfile )) ) { + regfio_close( regfile ); + return WERR_REG_FILE_INVALID; + } + + result = reg_load_tree( regfile, krecord->name, rootkey ); + + /* cleanup */ + + regfio_close( regfile ); + + return result; +} + +#endif + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_RestoreKey(pipes_struct *p) +{ +#if 0 /* temporarily disabled */ + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + pstring filename; + int snum; + + if ( !regkey ) + return WERR_BADFID; + + rpcstr_pull(filename, q_u->filename.string->buffer, sizeof(filename), q_u->filename.string->uni_str_len*2, STR_TERMINATE); + + DEBUG(8,("_reg_restore_key: verifying restore of key [%s] from \"%s\"\n", regkey->name, filename)); + + if ( (snum = validate_reg_filename( filename )) == -1 ) + return WERR_OBJECT_PATH_INVALID; + + /* user must posses SeRestorePrivilege for this this proceed */ + + if ( !user_has_privileges( p->pipe_user.nt_user_token, &se_restore ) ) + return WERR_ACCESS_DENIED; + + DEBUG(2,("_reg_restore_key: Restoring [%s] from %s in share %s\n", regkey->name, filename, lp_servicename(snum) )); + + return restore_registry_key( regkey, filename ); +#endif + + return WERR_NOT_SUPPORTED; +} + +#if 0 /* this code works but has been disable until I fix + the winreg IDL -- jerry */ + +/******************************************************************** +********************************************************************/ + +static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, + REGF_NK_REC *parent, SEC_DESC *sec_desc ) +{ + REGF_NK_REC *key; + REGVAL_CTR *values; + REGSUBKEY_CTR *subkeys; + int i, num_subkeys; + pstring key_tmp; + char *keyname, *parentpath; + pstring subkeypath; + char *subkeyname; + REGISTRY_KEY registry_key; + WERROR result = WERR_OK; + + if ( !regfile ) + return WERR_GENERAL_FAILURE; + + if ( !keypath ) + return WERR_OBJECT_PATH_INVALID; + + /* split up the registry key path */ + + pstrcpy( key_tmp, keypath ); + if ( !reg_split_key( key_tmp, &parentpath, &keyname ) ) + return WERR_OBJECT_PATH_INVALID; + + if ( !keyname ) + keyname = parentpath; + + /* we need a REGISTRY_KEY object here to enumerate subkeys and values */ + + ZERO_STRUCT( registry_key ); + pstrcpy( registry_key.name, keypath ); + if ( !(registry_key.hook = reghook_cache_find( registry_key.name )) ) + return WERR_BADFILE; + + + /* lookup the values and subkeys */ + + if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) + return WERR_NOMEM; + + if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) + return WERR_NOMEM; + + fetch_reg_keys( ®istry_key, subkeys ); + fetch_reg_values( ®istry_key, values ); + + /* write out this key */ + + if ( !(key = regfio_write_key( regfile, keyname, values, subkeys, sec_desc, parent )) ) { + result = WERR_CAN_NOT_COMPLETE; + goto done; + } + + /* write each one of the subkeys out */ + + num_subkeys = regsubkey_ctr_numkeys( subkeys ); + for ( i=0; imem_ctx, &sd )) ) { + regfio_close( regfile ); + return result; + } + + /* write the registry tree to the file */ + + result = reg_write_tree( regfile, krecord->name, NULL, sd ); + + /* cleanup */ + + regfio_close( regfile ); + + return result; +} +#endif + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_SaveKey(pipes_struct *p) +{ +#if 0 + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); + pstring filename; + int snum; + + if ( !regkey ) + return WERR_BADFID; + + rpcstr_pull(filename, q_u->filename.string->buffer, sizeof(filename), q_u->filename.string->uni_str_len*2, STR_TERMINATE); + + DEBUG(8,("_reg_save_key: verifying backup of key [%s] to \"%s\"\n", regkey->name, filename)); + + if ( (snum = validate_reg_filename( filename )) == -1 ) + return WERR_OBJECT_PATH_INVALID; + + DEBUG(2,("_reg_save_key: Saving [%s] to %s in share %s\n", regkey->name, filename, lp_servicename(snum) )); + + return backup_registry_key( regkey, filename ); +#endif + + /* disabled for now until I fix the IDL --jerry */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_SaveKeyEx(pipes_struct *p) +{ + /* disabled for now until I fix the IDL --jerry */ + return WERR_NOT_SUPPORTED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, struct winreg_String keyname, + struct winreg_String keyclass, uint32_t options, uint32_t access_mask, + struct winreg_SecBuf *secdesc, struct policy_handle *new_handle, + enum winreg_CreateAction *action_taken ) +{ + REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, handle); + REGISTRY_KEY *newparentinfo, *keyinfo; + POLICY_HND newparent_handle; + REGSUBKEY_CTR *subkeys; + BOOL write_result; + char *name; + WERROR result; + + if ( !parent ) + return WERR_BADFID; + + if ( (name = talloc_strdup( p->mem_ctx, keyname.name )) == NULL ) { + return WERR_NOMEM; + } + + /* ok. Here's what we do. */ + + if ( strrchr( name, '\\' ) ) { + pstring newkeyname; + char *ptr; + + /* (1) check for enumerate rights on the parent handle. CLients can try + create things like 'SOFTWARE\Samba' on the HKLM handle. + (2) open the path to the child parent key if necessary */ + + if ( !(parent->access_granted & SEC_RIGHTS_ENUM_SUBKEYS) ) + return WERR_ACCESS_DENIED; + + pstrcpy( newkeyname, name ); + ptr = strrchr( newkeyname, '\\' ); + *ptr = '\0'; + + result = open_registry_key( p, &newparent_handle, &newparentinfo, + parent, newkeyname, (REG_KEY_READ|REG_KEY_WRITE) ); + + if ( !W_ERROR_IS_OK(result) ) + return result; + + /* copy the new key name (just the lower most keyname) */ + + pstrcpy( name, ptr+1 ); + } + else { + /* use the existing open key information */ + newparentinfo = parent; + memcpy( &newparent_handle, handle, sizeof(POLICY_HND) ); + } + + /* (3) check for create subkey rights on the correct parent */ + + if ( !(newparentinfo->access_granted & SEC_RIGHTS_CREATE_SUBKEY) ) { + result = WERR_ACCESS_DENIED; + goto done; + } + + if ( !(subkeys = TALLOC_ZERO_P( p->mem_ctx, REGSUBKEY_CTR )) ) { + result = WERR_NOMEM; + goto done; + } + + /* (4) lookup the current keys and add the new one */ + + fetch_reg_keys( newparentinfo, subkeys ); + regsubkey_ctr_addkey( subkeys, name ); + + /* now write to the registry backend */ + + write_result = store_reg_keys( newparentinfo, subkeys ); + + TALLOC_FREE( subkeys ); + + if ( !write_result ) + return WERR_REG_IO_FAILURE; + + /* (5) open the new key and return the handle. Note that it is probably + not correct to grant full access on this open handle. */ + + result = open_registry_key( p, new_handle, &keyinfo, newparentinfo, name, REG_KEY_READ ); + keyinfo->access_granted = REG_KEY_ALL; + + /* FIXME: report the truth here */ + + *action_taken = REG_CREATED_NEW_KEY; + +done: + /* close any intermediate key handles */ + + if ( newparentinfo != parent ) + close_registry_key( p, &newparent_handle ); + + return result; +} + + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_SetValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String name, enum winreg_Type type, uint8_t *data, uint32_t size) +{ + REGISTRY_KEY *key = find_regkey_index_by_hnd(p, handle); + REGVAL_CTR *values; + BOOL write_result; + char *valuename; + + if ( !key ) + return WERR_BADFID; + + /* access checks first */ + + if ( !(key->access_granted & SEC_RIGHTS_SET_VALUE) ) + return WERR_ACCESS_DENIED; + + /* verify the name */ + + if ( (valuename = talloc_strdup(p->mem_ctx, name.name)) == NULL ) { + return WERR_INVALID_PARAM; + } + + DEBUG(8,("_reg_set_value: Setting value for [%s:%s]\n", key->name, valuename)); + + if ( !(values = TALLOC_ZERO_P( p->mem_ctx, REGVAL_CTR )) ) + return WERR_NOMEM; + + /* lookup the current values and add the new one */ + + fetch_reg_values( key, values ); + + regval_ctr_addvalue( values, valuename, type, (const char *)data, size ); + + /* now write to the registry backend */ + + write_result = store_reg_values( key, values ); + + TALLOC_FREE( values ); + + if ( !write_result ) + return WERR_REG_IO_FAILURE; + + return WERR_OK; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_DeleteKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String key) +{ + REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, handle); + REGISTRY_KEY *newparentinfo = NULL; + POLICY_HND newparent_handle; + REGSUBKEY_CTR *subkeys; + BOOL write_result; + char *name; + WERROR result; + + if ( !parent ) + return WERR_BADFID; + + /* MSDN says parent the handle must have been opened with DELETE access */ + + /* (1) check for delete rights on the parent */ + + if ( !(parent->access_granted & STD_RIGHT_DELETE_ACCESS) ) { + result = WERR_ACCESS_DENIED; + goto done; + } + + if ( (name = talloc_strdup( p->mem_ctx, key.name )) == NULL ) { + result = WERR_INVALID_PARAM; + goto done; + } + + /* ok. Here's what we do. */ + + if ( strrchr( name, '\\' ) ) { + pstring newkeyname; + char *ptr; + + /* (2) open the path to the child parent key if necessary */ + /* split the registry path and save the subkeyname */ + + pstrcpy( newkeyname, name ); + ptr = strrchr( newkeyname, '\\' ); + *ptr = '\0'; + pstrcpy( name, ptr+1 ); + + result = open_registry_key( p, &newparent_handle, &newparentinfo, parent, newkeyname, (REG_KEY_READ|REG_KEY_WRITE) ); + if ( !W_ERROR_IS_OK(result) ) + return result; + } + else { + /* use the existing open key information */ + newparentinfo = parent; + } + + if ( !(subkeys = TALLOC_ZERO_P( p->mem_ctx, REGSUBKEY_CTR )) ) { + result = WERR_NOMEM; + goto done; + } + + /* lookup the current keys and delete the new one */ + + fetch_reg_keys( newparentinfo, subkeys ); + + regsubkey_ctr_delkey( subkeys, name ); + + /* now write to the registry backend */ + + write_result = store_reg_keys( newparentinfo, subkeys ); + + TALLOC_FREE( subkeys ); + + result = write_result ? WERR_OK : WERR_REG_IO_FAILURE; + +done: + /* close any intermediate key handles */ + + if ( newparentinfo != parent ) + close_registry_key( p, &newparent_handle ); + + return result; +} + + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_DeleteValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value) +{ + REGISTRY_KEY *key = find_regkey_index_by_hnd(p, handle); + REGVAL_CTR *values; + BOOL write_result; + char *valuename; + + if ( !key ) + return WERR_BADFID; + + /* access checks first */ + + if ( !(key->access_granted & SEC_RIGHTS_SET_VALUE) ) + return WERR_ACCESS_DENIED; + + if ( (valuename = talloc_strdup( p->mem_ctx, value.name )) == NULL ) { + return WERR_INVALID_PARAM; + } + + DEBUG(8,("_reg_delete_value: Setting value for [%s:%s]\n", key->name, valuename)); + + if ( !(values = TALLOC_ZERO_P( p->mem_ctx, REGVAL_CTR )) ) + return WERR_NOMEM; + + /* lookup the current values and add the new one */ + + fetch_reg_values( key, values ); + + regval_ctr_delvalue( values, valuename ); + + /* now write to the registry backend */ + + write_result = store_reg_values( key, values ); + + TALLOC_FREE( values ); + + if ( !write_result ) + return WERR_REG_IO_FAILURE; + + return WERR_OK; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_GetKeySecurity(pipes_struct *p, struct policy_handle *handle, uint32_t sec_info, struct KeySecurityData *sd) +{ + REGISTRY_KEY *key = find_regkey_index_by_hnd(p, handle); + + if ( !key ) + return WERR_BADFID; + + /* access checks first */ + + if ( !(key->access_granted & STD_RIGHT_READ_CONTROL_ACCESS) ) + return WERR_ACCESS_DENIED; + + return WERR_ACCESS_DENIED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_SetKeySecurity(pipes_struct *p, struct policy_handle *handle, uint32_t access_mask, struct KeySecurityData *sd) +{ + REGISTRY_KEY *key = find_regkey_index_by_hnd(p, handle); + + if ( !key ) + return WERR_BADFID; + + /* access checks first */ + + if ( !(key->access_granted & STD_RIGHT_WRITE_DAC_ACCESS) ) + return WERR_ACCESS_DENIED; + + return WERR_ACCESS_DENIED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_FlushKey(pipes_struct *p, struct policy_handle *handle) +{ + /* I'm just replying OK because there's not a lot + here I see to do i --jerry */ + + return WERR_OK; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_UnLoadKey(pipes_struct *p) +{ + /* fill in your code here if you think this call should + do anything */ + + return WERR_NOT_SUPPORTED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_ReplaceKey(pipes_struct *p) +{ + /* fill in your code here if you think this call should + do anything */ + + return WERR_NOT_SUPPORTED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_LoadKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String *keyname, struct winreg_String *filename) +{ + /* fill in your code here if you think this call should + do anything */ + + return WERR_NOT_SUPPORTED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_NotifyChangeKeyValue(pipes_struct *p, struct policy_handle *handle, uint8_t watch_subtree, uint32_t notify_filter, uint32_t unknown, struct winreg_String string1, struct winreg_String string2, uint32_t unknown2) +{ + /* fill in your code here if you think this call should + do anything */ + + return WERR_NOT_SUPPORTED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_QueryMultipleValues(pipes_struct *p, struct policy_handle *key_handle, struct QueryMultipleValue *values, uint32_t num_values, uint8_t *buffer, uint32_t *buffer_size) +{ + /* fill in your code here if you think this call should + do anything */ + + return WERR_NOT_SUPPORTED; +} + +/******************************************************************* + ********************************************************************/ + +WERROR _winreg_QueryMultipleValues2(pipes_struct *p) +{ + /* fill in your code here if you think this call should + do anything */ + + return WERR_NOT_SUPPORTED; +} + -- cgit From 8e0217da6f19a75250c27c5abaa000ee4d328267 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 21 Sep 2006 18:09:20 +0000 Subject: r18790: Correct the IDL (still a bug in pidl) for QueryValue() (This used to be commit 44851d7afa3112278faea41b470cc5d3cad97cb5) --- source3/rpc_server/srv_winreg_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index aea848fd17..4e3b3e1fb2 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -350,7 +350,7 @@ WERROR _winreg_OpenKey(pipes_struct *p, struct policy_handle *parent_handle, str reg_reply_info ********************************************************************/ -WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t **data, uint32_t *size, uint32_t *length) +WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t *data, uint32_t *size, uint32_t *length) { WERROR status = WERR_BADFILE; char *name; @@ -470,9 +470,11 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct *size = regval_size( val ); *length = regval_size( val ); +#if 0 if ( (*data = talloc_memdup( p->mem_ctx, regval_data_p(val), *size )) == NULL ) { status = WERR_NOMEM; } +#endif *type = val->type; } -- cgit From c8ef27a3c3db3f04d592652fd6103c5b5cf83d03 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 21 Sep 2006 18:22:51 +0000 Subject: r18792: small fix for server QueryValue code (This used to be commit b11558c2320d8da8fee0fb8398729f9005021384) --- source3/rpc_server/srv_winreg_nt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 4e3b3e1fb2..6f276d0c86 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -363,8 +363,7 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct return WERR_BADFID; *size = *length = *type = 0; - value_name.name = NULL; - + DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); DEBUG(7,("_reg_info: policy key type = [%08x]\n", regkey->type)); -- cgit From 1303cd82451aca43d63166bbd2779ea4a388a72d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 21 Sep 2006 18:54:25 +0000 Subject: r18794: Make ENumKey() work again in the registry server (This used to be commit 7ead5ac79203a15dc1d9d7982446eafbb1f9eefd) --- source3/rpc_server/srv_winreg_nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 6f276d0c86..91435fc87e 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -554,7 +554,7 @@ WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t e if ( !regkey ) return WERR_BADFID; - if ( !name || !keyclass || !last_changed_time ) + if ( !name || !keyclass ) return WERR_INVALID_PARAM; DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", regkey->name)); @@ -566,7 +566,9 @@ WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t e DEBUG(10,("_reg_enum_key: retrieved subkey named [%s]\n", subkey)); - *last_changed_time = 0; + if ( last_changed_time ) { + *last_changed_time = 0; + } keyclass->name = NULL; if ( (name->name = talloc_strdup( p->mem_ctx, subkey )) == NULL ) { status = WERR_NOMEM; -- cgit From 7ba2554d88a187ca1f4f40014363fdf9de2223a0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 21 Sep 2006 23:57:32 +0000 Subject: r18802: Use the pidl-generated code for the srvsvc interface, both client and server code. This has had some basic testing. I'll do more during the next couple of days and hopefully also make RPC-SRVSVC from Samba4 pass against it. (This used to be commit ef10672399c4b82700dc431b4d93431ffdd42d98) --- source3/rpc_server/srv_echo_nt.c | 1 + source3/rpc_server/srv_srvsvc.c | 621 ----------------- source3/rpc_server/srv_srvsvc_nt.c | 1295 ++++++++++++++++++------------------ 3 files changed, 666 insertions(+), 1251 deletions(-) delete mode 100644 source3/rpc_server/srv_srvsvc.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_echo_nt.c b/source3/rpc_server/srv_echo_nt.c index 221f4bc8b2..b6c5442e03 100644 --- a/source3/rpc_server/srv_echo_nt.c +++ b/source3/rpc_server/srv_echo_nt.c @@ -2,6 +2,7 @@ * Unix SMB/CIFS implementation. * RPC Pipe client / server routines for rpcecho * Copyright (C) Tim Potter 2003. + * Copyright (C) Jelmer Vernooij 2006. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c deleted file mode 100644 index e4f85d0bdb..0000000000 --- a/source3/rpc_server/srv_srvsvc.c +++ /dev/null @@ -1,621 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997, - * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Jim McDonough 2003. - * Copyright (C) Gera;d (Jerry) Carter 2006. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* This is the interface to the srvsvc pipe. */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -/******************************************************************* - api_srv_net_srv_get_info -********************************************************************/ - -static BOOL api_srv_net_srv_get_info(pipes_struct *p) -{ - SRV_Q_NET_SRV_GET_INFO q_u; - SRV_R_NET_SRV_GET_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server get info */ - if (!srv_io_q_net_srv_get_info("", &q_u, data, 0)) - return False; - - r_u.status = _srv_net_srv_get_info(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if (!srv_io_r_net_srv_get_info("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_srv_net_srv_get_info -********************************************************************/ - -static BOOL api_srv_net_srv_set_info(pipes_struct *p) -{ - SRV_Q_NET_SRV_SET_INFO q_u; - SRV_R_NET_SRV_SET_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server set info */ - if (!srv_io_q_net_srv_set_info("", &q_u, data, 0)) - return False; - - r_u.status = _srv_net_srv_set_info(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if (!srv_io_r_net_srv_set_info("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_srv_net_file_enum -********************************************************************/ - -static BOOL api_srv_net_file_enum(pipes_struct *p) -{ - SRV_Q_NET_FILE_ENUM q_u; - SRV_R_NET_FILE_ENUM r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net file enum */ - if (!srv_io_q_net_file_enum("", &q_u, data, 0)) - return False; - - r_u.status = _srv_net_file_enum(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!srv_io_r_net_file_enum("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - api_srv_net_conn_enum -********************************************************************/ - -static BOOL api_srv_net_conn_enum(pipes_struct *p) -{ - SRV_Q_NET_CONN_ENUM q_u; - SRV_R_NET_CONN_ENUM r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server get enum */ - if (!srv_io_q_net_conn_enum("", &q_u, data, 0)) - return False; - - r_u.status = _srv_net_conn_enum(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if (!srv_io_r_net_conn_enum("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - Enumerate sessions. -********************************************************************/ - -static BOOL api_srv_net_sess_enum(pipes_struct *p) -{ - SRV_Q_NET_SESS_ENUM q_u; - SRV_R_NET_SESS_ENUM r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server get enum */ - if (!srv_io_q_net_sess_enum("", &q_u, data, 0)) - return False; - - /* construct reply. always indicate success */ - r_u.status = _srv_net_sess_enum(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if (!srv_io_r_net_sess_enum("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - Delete session. -********************************************************************/ - -static BOOL api_srv_net_sess_del(pipes_struct *p) -{ - SRV_Q_NET_SESS_DEL q_u; - SRV_R_NET_SESS_DEL r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server get enum */ - if (!srv_io_q_net_sess_del("", &q_u, data, 0)) - return False; - - /* construct reply. always indicate success */ - r_u.status = _srv_net_sess_del(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if (!srv_io_r_net_sess_del("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - RPC to enumerate shares. -********************************************************************/ - -static BOOL api_srv_net_share_enum_all(pipes_struct *p) -{ - SRV_Q_NET_SHARE_ENUM q_u; - SRV_R_NET_SHARE_ENUM r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server get enum. */ - if(!srv_io_q_net_share_enum("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_enum_all: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n")); - return False; - } - - r_u.status = _srv_net_share_enum_all(p, &q_u, &r_u); - - if (!srv_io_r_net_share_enum("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_enum_all: Failed to marshall SRV_R_NET_SHARE_ENUM.\n")); - return False; - } - - return True; -} - -/******************************************************************* - RPC to enumerate shares. -********************************************************************/ - -static BOOL api_srv_net_share_enum(pipes_struct *p) -{ - SRV_Q_NET_SHARE_ENUM q_u; - SRV_R_NET_SHARE_ENUM r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server get enum. */ - if(!srv_io_q_net_share_enum("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_enum: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n")); - return False; - } - - r_u.status = _srv_net_share_enum(p, &q_u, &r_u); - - if (!srv_io_r_net_share_enum("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_enum: Failed to marshall SRV_R_NET_SHARE_ENUM.\n")); - return False; - } - - return True; -} - -/******************************************************************* - RPC to return share information. -********************************************************************/ - -static BOOL api_srv_net_share_get_info(pipes_struct *p) -{ - SRV_Q_NET_SHARE_GET_INFO q_u; - SRV_R_NET_SHARE_GET_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server get info. */ - if(!srv_io_q_net_share_get_info("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_get_info: Failed to unmarshall SRV_Q_NET_SHARE_GET_INFO.\n")); - return False; - } - - r_u.status = _srv_net_share_get_info(p, &q_u, &r_u); - - if(!srv_io_r_net_share_get_info("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_get_info: Failed to marshall SRV_R_NET_SHARE_GET_INFO.\n")); - return False; - } - - return True; -} - -/******************************************************************* - RPC to set share information. -********************************************************************/ - -static BOOL api_srv_net_share_set_info(pipes_struct *p) -{ - SRV_Q_NET_SHARE_SET_INFO q_u; - SRV_R_NET_SHARE_SET_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server set info. */ - if(!srv_io_q_net_share_set_info("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_set_info: Failed to unmarshall SRV_Q_NET_SHARE_SET_INFO.\n")); - return False; - } - - r_u.status = _srv_net_share_set_info(p, &q_u, &r_u); - - if(!srv_io_r_net_share_set_info("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_set_info: Failed to marshall SRV_R_NET_SHARE_SET_INFO.\n")); - return False; - } - - return True; -} - -/******************************************************************* - RPC to add share information. -********************************************************************/ - -static BOOL api_srv_net_share_add(pipes_struct *p) -{ - SRV_Q_NET_SHARE_ADD q_u; - SRV_R_NET_SHARE_ADD r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server add info. */ - if(!srv_io_q_net_share_add("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_add: Failed to unmarshall SRV_Q_NET_SHARE_ADD.\n")); - return False; - } - - r_u.status = _srv_net_share_add(p, &q_u, &r_u); - - if(!srv_io_r_net_share_add("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_add: Failed to marshall SRV_R_NET_SHARE_ADD.\n")); - return False; - } - - return True; -} - -/******************************************************************* - RPC to delete share information. -********************************************************************/ - -static BOOL api_srv_net_share_del(pipes_struct *p) -{ - SRV_Q_NET_SHARE_DEL q_u; - SRV_R_NET_SHARE_DEL r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server del info. */ - if(!srv_io_q_net_share_del("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_del: Failed to unmarshall SRV_Q_NET_SHARE_DEL.\n")); - return False; - } - - r_u.status = _srv_net_share_del(p, &q_u, &r_u); - - if(!srv_io_r_net_share_del("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_del: Failed to marshall SRV_R_NET_SHARE_DEL.\n")); - return False; - } - - return True; -} - -/******************************************************************* - RPC to delete share information. -********************************************************************/ - -static BOOL api_srv_net_share_del_sticky(pipes_struct *p) -{ - SRV_Q_NET_SHARE_DEL q_u; - SRV_R_NET_SHARE_DEL r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server del info. */ - if(!srv_io_q_net_share_del("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_del_sticky: Failed to unmarshall SRV_Q_NET_SHARE_DEL.\n")); - return False; - } - - r_u.status = _srv_net_share_del_sticky(p, &q_u, &r_u); - - if(!srv_io_r_net_share_del("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_del_sticky: Failed to marshall SRV_R_NET_SHARE_DEL.\n")); - return False; - } - - return True; -} - -/******************************************************************* - api_srv_net_remote_tod -********************************************************************/ - -static BOOL api_srv_net_remote_tod(pipes_struct *p) -{ - SRV_Q_NET_REMOTE_TOD q_u; - SRV_R_NET_REMOTE_TOD r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server get enum */ - if(!srv_io_q_net_remote_tod("", &q_u, data, 0)) - return False; - - r_u.status = _srv_net_remote_tod(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!srv_io_r_net_remote_tod("", &r_u, rdata, 0)) - return False; - - return True; -} - -/******************************************************************* - RPC to enumerate disks available on a server e.g. C:, D: ... -*******************************************************************/ - -static BOOL api_srv_net_disk_enum(pipes_struct *p) -{ - SRV_Q_NET_DISK_ENUM q_u; - SRV_R_NET_DISK_ENUM r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server disk enum. */ - if(!srv_io_q_net_disk_enum("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_disk_enum: Failed to unmarshall SRV_Q_NET_DISK_ENUM.\n")); - return False; - } - - r_u.status = _srv_net_disk_enum(p, &q_u, &r_u); - - if(!srv_io_r_net_disk_enum("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_disk_enum: Failed to marshall SRV_R_NET_DISK_ENUM.\n")); - return False; - } - - return True; -} - -/******************************************************************* - NetValidateName (opnum 0x21) -*******************************************************************/ - -static BOOL api_srv_net_name_validate(pipes_struct *p) -{ - SRV_Q_NET_NAME_VALIDATE q_u; - SRV_R_NET_NAME_VALIDATE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server disk enum. */ - if(!srv_io_q_net_name_validate("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_name_validate: Failed to unmarshall SRV_Q_NET_NAME_VALIDATE.\n")); - return False; - } - - r_u.status = _srv_net_name_validate(p, &q_u, &r_u); - - if(!srv_io_r_net_name_validate("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_name_validate: Failed to marshall SRV_R_NET_NAME_VALIDATE.\n")); - return False; - } - - return True; -} - -/******************************************************************* - NetFileQuerySecdesc (opnum 0x27) -*******************************************************************/ - -static BOOL api_srv_net_file_query_secdesc(pipes_struct *p) -{ - SRV_Q_NET_FILE_QUERY_SECDESC q_u; - SRV_R_NET_FILE_QUERY_SECDESC r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net file get info from Win9x */ - if(!srv_io_q_net_file_query_secdesc("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_file_query_secdesc: Failed to unmarshall SRV_Q_NET_FILE_QUERY_SECDESC.\n")); - return False; - } - - r_u.status = _srv_net_file_query_secdesc(p, &q_u, &r_u); - - if(!srv_io_r_net_file_query_secdesc("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_file_query_secdesc: Failed to marshall SRV_R_NET_FILE_QUERY_SECDESC.\n")); - return False; - } - - return True; -} - -/******************************************************************* - NetFileSetSecdesc (opnum 0x28) -*******************************************************************/ - -static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) -{ - SRV_Q_NET_FILE_SET_SECDESC q_u; - SRV_R_NET_FILE_SET_SECDESC r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net file set info from Win9x */ - if(!srv_io_q_net_file_set_secdesc("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_file_set_secdesc: Failed to unmarshall SRV_Q_NET_FILE_SET_SECDESC.\n")); - return False; - } - - r_u.status = _srv_net_file_set_secdesc(p, &q_u, &r_u); - - if(!srv_io_r_net_file_set_secdesc("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_file_set_secdesc: Failed to marshall SRV_R_NET_FILE_SET_SECDESC.\n")); - return False; - } - - return True; -} - -/******************************************************************* -*******************************************************************/ - -static BOOL api_srv_net_file_close(pipes_struct *p) -{ - SRV_Q_NET_FILE_CLOSE q_u; - SRV_R_NET_FILE_CLOSE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net file set info from Win9x */ - if(!srv_io_q_net_file_close("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_file_close: Failed to unmarshall SRV_Q_NET_FILE_SET_SECDESC.\n")); - return False; - } - - r_u.status = _srv_net_file_close(p, &q_u, &r_u); - - if(!srv_io_r_net_file_close("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_file_close: Failed to marshall SRV_R_NET_FILE_SET_SECDESC.\n")); - return False; - } - - return True; -} - -/******************************************************************* -\PIPE\srvsvc commands -********************************************************************/ - -static struct api_struct api_srv_cmds[] = -{ - { "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum }, - { "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum }, - { "SRV_NET_SESS_DEL" , SRV_NET_SESS_DEL , api_srv_net_sess_del }, - { "SRV_NET_SHARE_ENUM_ALL" , SRV_NET_SHARE_ENUM_ALL , api_srv_net_share_enum_all }, - { "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum }, - { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, - { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del }, - { "SRV_NET_SHARE_DEL_STICKY" , SRV_NET_SHARE_DEL_STICKY , api_srv_net_share_del_sticky }, - { "SRV_NET_SHARE_GET_INFO" , SRV_NET_SHARE_GET_INFO , api_srv_net_share_get_info }, - { "SRV_NET_SHARE_SET_INFO" , SRV_NET_SHARE_SET_INFO , api_srv_net_share_set_info }, - { "SRV_NET_FILE_ENUM" , SRV_NET_FILE_ENUM , api_srv_net_file_enum }, - { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, - { "SRV_NET_SRV_SET_INFO" , SRV_NET_SRV_SET_INFO , api_srv_net_srv_set_info }, - { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, - { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, - { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate }, - { "SRV_NET_FILE_QUERY_SECDESC", SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc }, - { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc }, - { "SRV_NET_FILE_CLOSE" , SRV_NET_FILE_CLOSE , api_srv_net_file_close } -}; - -void srvsvc_get_pipe_fns( struct api_struct **fns, int *n_fns ) -{ - *fns = api_srv_cmds; - *n_fns = sizeof(api_srv_cmds) / sizeof(struct api_struct); -} - - -NTSTATUS rpc_srv_init(void) -{ - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "srvsvc", "ntsvcs", api_srv_cmds, - sizeof(api_srv_cmds) / sizeof(struct api_struct)); -} diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 21032a4ed9..ecb907e72d 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -5,6 +5,7 @@ * Copyright (C) Jeremy Allison 2001. * Copyright (C) Nigel Williams 2001. * Copyright (C) Gerald (Jerry) Carter 2006. + * Copyright (C) Jelmer Vernooij 2006. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +26,8 @@ #include "includes.h" +#define MAX_SERVER_DISK_ENTRIES 15 + extern struct generic_mapping file_generic_mapping; extern userdom_struct current_user_info; @@ -35,8 +38,8 @@ extern userdom_struct current_user_info; struct file_enum_count { TALLOC_CTX *ctx; - int count; - FILE_INFO_3 *info; + uint32 count; + struct srvsvc_NetFileInfo3 *info; }; struct sess_file_count { @@ -60,26 +63,25 @@ static int pipe_enum_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, voi memcpy(&prec, dbuf.dptr, sizeof(struct pipe_open_rec)); if ( process_exists(prec.pid) ) { - FILE_INFO_3 *f; + struct srvsvc_NetFileInfo3 *f; int i = fenum->count; pstring fullpath; snprintf( fullpath, sizeof(fullpath), "\\PIPE\\%s", prec.name ); - f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 ); + f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, struct srvsvc_NetFileInfo3, i+1 ); if ( !f ) { DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); return 1; } + fenum->info = f; - - init_srv_file_info3( &fenum->info[i], - (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum), - (FILE_READ_DATA|FILE_WRITE_DATA), - 0, - uidtoname( prec.uid ), - fullpath ); + fenum->info[i].fid = (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum); + fenum->info[i].permissions = (FILE_READ_DATA|FILE_WRITE_DATA); + fenum->info[i].num_locks = 0; + fenum->info[i].user = uidtoname( prec.uid ); + fenum->info[i].path = fullpath; fenum->count++; } @@ -90,8 +92,8 @@ static int pipe_enum_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, voi /******************************************************************* ********************************************************************/ -static WERROR net_enum_pipes( TALLOC_CTX *ctx, FILE_INFO_3 **info, - uint32 *count, uint32 resume ) +static WERROR net_enum_pipes( TALLOC_CTX *ctx, struct srvsvc_NetFileInfo3 **info, + uint32 *count, uint32 *resume ) { struct file_enum_count fenum; TDB_CONTEXT *conn_tdb = conn_tdb_ctx(); @@ -102,8 +104,8 @@ static WERROR net_enum_pipes( TALLOC_CTX *ctx, FILE_INFO_3 **info, } fenum.ctx = ctx; - fenum.count = *count; fenum.info = *info; + fenum.count = *count; if (tdb_traverse(conn_tdb, pipe_enum_fn, &fenum) == -1) { DEBUG(0,("net_enum_pipes: traverse of connections.tdb failed with error %s.\n", @@ -131,7 +133,7 @@ static void enum_file_fn( const struct share_mode_entry *e, /* If the pid was not found delete the entry from connections.tdb */ if ( process_exists(e->pid) ) { - FILE_INFO_3 *f; + struct srvsvc_NetFileInfo3 *f; int i = fenum->count; files_struct fsp; struct byte_range_lock *brl; @@ -139,7 +141,7 @@ static void enum_file_fn( const struct share_mode_entry *e, pstring fullpath; uint32 permissions; - f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 ); + f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, struct srvsvc_NetFileInfo3, i+1 ); if ( !f ) { DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); return; @@ -167,13 +169,11 @@ static void enum_file_fn( const struct share_mode_entry *e, /* mask out create (what ever that is) */ permissions = e->share_access & (FILE_READ_DATA|FILE_WRITE_DATA); - /* now fill in the FILE_INFO_3 struct */ - init_srv_file_info3( &fenum->info[i], - e->share_file_id, - permissions, - num_locks, - uidtoname(e->uid), - fullpath ); + fenum->info[i].fid = e->share_file_id; + fenum->info[i].permissions = permissions; + fenum->info[i].num_locks = num_locks; + fenum->info[i].user = uidtoname(e->uid); + fenum->info[i].path = fullpath; fenum->count++; } @@ -185,8 +185,8 @@ static void enum_file_fn( const struct share_mode_entry *e, /******************************************************************* ********************************************************************/ -static WERROR net_enum_files( TALLOC_CTX *ctx, FILE_INFO_3 **info, - uint32 *count, uint32 resume ) +static WERROR net_enum_files( TALLOC_CTX *ctx, struct srvsvc_NetFileInfo3 **info, + uint32 *count, uint32 *resume ) { f_enum_cnt.ctx = ctx; f_enum_cnt.count = *count; @@ -225,41 +225,36 @@ static uint32 get_share_type(const struct share_params *params) Fill in a share info level 0 structure. ********************************************************************/ -static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, +static void init_srv_share_info_0(pipes_struct *p, struct srvsvc_NetShareInfo0 *sh0, const struct share_params *params) { - char *net_name = lp_servicename(params->service); - init_srv_share_info0(&sh0->info_0, net_name); - init_srv_share_info0_str(&sh0->info_0_str, net_name); + sh0->name = lp_servicename(params->service); } /******************************************************************* Fill in a share info level 1 structure. ********************************************************************/ -static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, +static void init_srv_share_info_1(pipes_struct *p, struct srvsvc_NetShareInfo1 *sh1, const struct share_params *params) { connection_struct *conn = p->conn; - char *net_name = lp_servicename(params->service); - char *remark; - remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), + sh1->comment = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), conn->user, conn->connectpath, conn->gid, get_current_username(), current_user_info.domain, lp_comment(params->service)); - init_srv_share_info1(&sh1->info_1, net_name, get_share_type(params), - remark); - init_srv_share_info1_str(&sh1->info_1_str, net_name, remark); + sh1->name = lp_servicename(params->service); + sh1->type = get_share_type(params); } /******************************************************************* Fill in a share info level 2 structure. ********************************************************************/ -static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, +static void init_srv_share_info_2(pipes_struct *p, struct srvsvc_NetShareInfo2 *sh2, const struct share_params *params) { connection_struct *conn = p->conn; @@ -286,10 +281,14 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, string_replace(path, '/', '\\'); count = count_current_connections( net_name, False ); - init_srv_share_info2(&sh2->info_2, net_name, get_share_type(params), - remark, 0, max_uses, count, path, ""); - - init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, ""); + sh2->name = net_name; + sh2->type = get_share_type(params); + sh2->comment = remark; + sh2->permissions = 0; + sh2->max_users = max_uses; + sh2->current_users = count; + sh2->path = path; + sh2->password = ""; } /******************************************************************* @@ -321,7 +320,7 @@ static void map_generic_share_sd_bits(SEC_DESC *psd) Fill in a share info level 501 structure. ********************************************************************/ -static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, +static void init_srv_share_info_501(pipes_struct *p, struct srvsvc_NetShareInfo501 *sh501, const struct share_params *params) { connection_struct *conn = p->conn; @@ -334,20 +333,24 @@ static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, current_user_info.domain, lp_comment(params->service)); - init_srv_share_info501(&sh501->info_501, net_name, - get_share_type(params), remark, - (lp_csc_policy(params->service) << 4)); - init_srv_share_info501_str(&sh501->info_501_str, net_name, remark); + + sh501->name = net_name; + sh501->type = get_share_type(params); + sh501->comment = remark; + sh501->csc_policy = (lp_csc_policy(params->service) << 4); } /******************************************************************* Fill in a share info level 502 structure. ********************************************************************/ -static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, +static void init_srv_share_info_502(pipes_struct *p, struct srvsvc_NetShareInfo502 *sh502, const struct share_params *params) { + int max_connections = lp_max_connections(params->service); + uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff; connection_struct *conn = p->conn; + int count; char *net_name; char *remark; char *path; @@ -359,7 +362,8 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, ZERO_STRUCTP(sh502); net_name = lp_servicename(params->service); - + count = count_current_connections( net_name, False ); + remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), conn->user, conn->connectpath, conn->gid, get_current_username(), @@ -379,11 +383,16 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, sd = get_share_security(ctx, lp_servicename(params->service), &sd_size); - init_srv_share_info502(&sh502->info_502, net_name, - get_share_type(params), remark, 0, 0xffffffff, - 1, path, "", sd, sd_size); - init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, - path, "", sd, sd_size); + sh502->name = net_name; + sh502->type = get_share_type(params); + sh502->comment = remark; + sh502->path = path; + sh502->password = ""; + sh502->sd = sd; + sh502->permissions = 0; + sh502->max_users = max_uses; + sh502->current_users = count; + sh502->unknown = 1; } /*************************************************************************** @@ -391,7 +400,7 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, ***************************************************************************/ static void init_srv_share_info_1004(pipes_struct *p, - SRV_SHARE_INFO_1004* sh1004, + struct srvsvc_NetShareInfo1004* sh1004, const struct share_params *params) { connection_struct *conn = p->conn; @@ -404,9 +413,8 @@ static void init_srv_share_info_1004(pipes_struct *p, lp_comment(params->service)); ZERO_STRUCTP(sh1004); - - init_srv_share_info1004(&sh1004->info_1004, remark); - init_srv_share_info1004_str(&sh1004->info_1004_str, remark); + + sh1004->comment = remark; } /*************************************************************************** @@ -414,15 +422,15 @@ static void init_srv_share_info_1004(pipes_struct *p, ***************************************************************************/ static void init_srv_share_info_1005(pipes_struct *p, - SRV_SHARE_INFO_1005* sh1005, + struct srvsvc_NetShareInfo1005* sh1005, const struct share_params *params) { - sh1005->share_info_flags = 0; + sh1005->dfs_flags = 0; if(lp_host_msdfs() && lp_msdfs_root(params->service)) - sh1005->share_info_flags |= + sh1005->dfs_flags |= SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT; - sh1005->share_info_flags |= + sh1005->dfs_flags |= lp_csc_policy(params->service) << SHARE_1005_CSC_POLICY_SHIFT; } /*************************************************************************** @@ -430,10 +438,10 @@ static void init_srv_share_info_1005(pipes_struct *p, ***************************************************************************/ static void init_srv_share_info_1006(pipes_struct *p, - SRV_SHARE_INFO_1006* sh1006, + struct srvsvc_NetShareInfo1006* sh1006, const struct share_params *params) { - sh1006->max_uses = -1; + sh1006->max_users = -1; } /*************************************************************************** @@ -441,18 +449,15 @@ static void init_srv_share_info_1006(pipes_struct *p, ***************************************************************************/ static void init_srv_share_info_1007(pipes_struct *p, - SRV_SHARE_INFO_1007* sh1007, + struct srvsvc_NetShareInfo1007* sh1007, const struct share_params *params) { - pstring alternate_directory_name = ""; uint32 flags = 0; ZERO_STRUCTP(sh1007); - init_srv_share_info1007(&sh1007->info_1007, flags, - alternate_directory_name); - init_srv_share_info1007_str(&sh1007->info_1007_str, - alternate_directory_name); + sh1007->flags = flags; + sh1007->alternate_directory_name = ""; } /******************************************************************* @@ -460,7 +465,7 @@ static void init_srv_share_info_1007(pipes_struct *p, ********************************************************************/ static void init_srv_share_info_1501(pipes_struct *p, - SRV_SHARE_INFO_1501 *sh1501, + struct sec_desc_buf *sh1501, const struct share_params *params) { SEC_DESC *sd; @@ -472,7 +477,7 @@ static void init_srv_share_info_1501(pipes_struct *p, sd = get_share_security(ctx, lp_servicename(params->service), &sd_size); - sh1501->sdb = make_sec_desc_buf(p->mem_ctx, sd_size, sd); + sh1501->sd = sd; } /******************************************************************* @@ -491,20 +496,18 @@ static BOOL is_hidden_share(const struct share_params *params) ********************************************************************/ static WERROR init_srv_share_info_ctr(pipes_struct *p, - SRV_SHARE_INFO_CTR *ctr, + union srvsvc_NetShareCtr *ctr, uint32 info_level, uint32 *resume_hnd, uint32 *total_entries, BOOL all_shares) { - int num_entries = 0; TALLOC_CTX *ctx = p->mem_ctx; struct share_iterator *shares; struct share_params *share; DEBUG(5,("init_srv_share_info_ctr\n")); - ZERO_STRUCT(ctr->share); + ZERO_STRUCTP(ctr); - ctr->info_level = ctr->switch_value = info_level; *resume_hnd = 0; /* Ensure all the usershares are loaded. */ @@ -512,15 +515,50 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, load_usershare_shares(); unbecome_root(); - num_entries = 0; - - ZERO_STRUCT(ctr->share); + *total_entries = 0; if (!(shares = share_list_all(ctx))) { DEBUG(5, ("Could not list shares\n")); return WERR_ACCESS_DENIED; } + switch (info_level) { + case 0: + ctr->ctr0 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr0); + break; + case 1: + ctr->ctr1 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1); + break; + case 2: + ctr->ctr2 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr2); + break; + case 501: + ctr->ctr501 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr501); + break; + case 502: + ctr->ctr502 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr502); + break; + case 1004: + ctr->ctr1004 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1004); + break; + case 1005: + ctr->ctr1005 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1005); + break; + case 1006: + ctr->ctr1006 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1006); + break; + case 1007: + ctr->ctr1007 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1007); + break; + case 1501: + ctr->ctr1501 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1501); + break; + default: + DEBUG(5,("init_srv_share_info_ctr: unsupported switch " + "value %d\n", info_level)); + return WERR_UNKNOWN_LEVEL; + } + while ((share = next_share(shares)) != NULL) { if (!lp_browseable(share->service)) { continue; @@ -532,61 +570,66 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, switch (info_level) { case 0: { - SRV_SHARE_INFO_0 i; + struct srvsvc_NetShareInfo0 i; init_srv_share_info_0(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_0, i, - &ctr->share.info0, &num_entries); - if (ctr->share.info0 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo0, i, + &ctr->ctr0->array, &ctr->ctr0->count); + if (ctr->ctr0->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr0->count; break; } case 1: { - SRV_SHARE_INFO_1 i; + struct srvsvc_NetShareInfo1 i; init_srv_share_info_1(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1, i, - &ctr->share.info1, &num_entries); - if (ctr->share.info1 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1, i, + &ctr->ctr1->array, &ctr->ctr1->count); + if (ctr->ctr1->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr1->count; break; } case 2: { - SRV_SHARE_INFO_2 i; + struct srvsvc_NetShareInfo2 i; init_srv_share_info_2(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_2, i, - &ctr->share.info2, &num_entries); - if (ctr->share.info2 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo2, i, + &ctr->ctr2->array, &ctr->ctr2->count); + if (ctr->ctr2->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr2->count; break; } case 501: { - SRV_SHARE_INFO_501 i; + struct srvsvc_NetShareInfo501 i; init_srv_share_info_501(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_501, i, - &ctr->share.info501, &num_entries); - if (ctr->share.info501 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo501, i, + &ctr->ctr501->array, &ctr->ctr501->count); + if (ctr->ctr501->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr501->count; break; } case 502: { - SRV_SHARE_INFO_502 i; + struct srvsvc_NetShareInfo502 i; init_srv_share_info_502(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_502, i, - &ctr->share.info502, &num_entries); - if (ctr->share.info502 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo502, i, + &ctr->ctr502->array, &ctr->ctr502->count); + if (ctr->ctr502->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr502->count; break; } @@ -595,176 +638,81 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, case 1004: { - SRV_SHARE_INFO_1004 i; + struct srvsvc_NetShareInfo1004 i; init_srv_share_info_1004(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1004, i, - &ctr->share.info1004, &num_entries); - if (ctr->share.info1004 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1004, i, + &ctr->ctr1004->array, &ctr->ctr1004->count); + if (ctr->ctr1004->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr1004->count; break; } case 1005: { - SRV_SHARE_INFO_1005 i; + struct srvsvc_NetShareInfo1005 i; init_srv_share_info_1005(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1005, i, - &ctr->share.info1005, &num_entries); - if (ctr->share.info1005 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1005, i, + &ctr->ctr1005->array, &ctr->ctr1005->count); + if (ctr->ctr1005->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr1005->count; break; } case 1006: { - SRV_SHARE_INFO_1006 i; + struct srvsvc_NetShareInfo1006 i; init_srv_share_info_1006(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1006, i, - &ctr->share.info1006, &num_entries); - if (ctr->share.info1006 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1006, i, + &ctr->ctr1006->array, &ctr->ctr1006->count); + if (ctr->ctr1006->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr1006->count; break; } case 1007: { - SRV_SHARE_INFO_1007 i; + struct srvsvc_NetShareInfo1007 i; init_srv_share_info_1007(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1007, i, - &ctr->share.info1007, &num_entries); - if (ctr->share.info1007 == NULL) { + ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1007, i, + &ctr->ctr1007->array, &ctr->ctr1007->count); + if (ctr->ctr1007->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr1007->count; break; } case 1501: { - SRV_SHARE_INFO_1501 i; + struct sec_desc_buf i; init_srv_share_info_1501(p, &i, share); - ADD_TO_ARRAY(ctx, SRV_SHARE_INFO_1501, i, - &ctr->share.info1501, &num_entries); - if (ctr->share.info1501 == NULL) { + ADD_TO_ARRAY(ctx, struct sec_desc_buf, i, + &ctr->ctr1501->array, &ctr->ctr1501->count); + if (ctr->ctr1501->array == NULL) { return WERR_NOMEM; } + *total_entries = ctr->ctr1501->count; break; } - default: - DEBUG(5,("init_srv_share_info_ctr: unsupported switch " - "value %d\n", info_level)); - return WERR_UNKNOWN_LEVEL; } TALLOC_FREE(share); } - *total_entries = num_entries; - ctr->num_entries2 = ctr->num_entries = num_entries; - ctr->ptr_share_info = ctr->ptr_entries = 1; - return WERR_OK; } -/******************************************************************* - Inits a SRV_R_NET_SHARE_ENUM structure. -********************************************************************/ - -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__)); - - r_n->status = init_srv_share_info_ctr(p, &r_n->ctr, info_level, - &resume_hnd, - &r_n->total_entries, all); - - init_enum_hnd(&r_n->enum_hnd, resume_hnd); -} - -/******************************************************************* - Inits a SRV_R_NET_SHARE_GET_INFO structure. -********************************************************************/ - -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) -{ - WERROR status = WERR_OK; - const struct share_params *params; - - DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__)); - - r_n->info.switch_value = info_level; - - params = get_share_params(p->mem_ctx, share_name); - - if (params != NULL) { - switch (info_level) { - case 0: - init_srv_share_info_0(p, &r_n->info.share.info0, - params); - break; - case 1: - init_srv_share_info_1(p, &r_n->info.share.info1, - params); - break; - case 2: - init_srv_share_info_2(p, &r_n->info.share.info2, - params); - break; - case 501: - init_srv_share_info_501(p, &r_n->info.share.info501, - params); - break; - case 502: - init_srv_share_info_502(p, &r_n->info.share.info502, - params); - break; - - /* here for completeness */ - case 1004: - init_srv_share_info_1004(p, &r_n->info.share.info1004, - params); - break; - case 1005: - init_srv_share_info_1005(p, &r_n->info.share.info1005, - params); - break; - - /* here for completeness 1006 - 1501 */ - case 1006: - init_srv_share_info_1006(p, &r_n->info.share.info1006, - params); - break; - case 1007: - init_srv_share_info_1007(p, &r_n->info.share.info1007, - params); - break; - case 1501: - init_srv_share_info_1501(p, &r_n->info.share.info1501, - params); - break; - default: - DEBUG(5,("init_srv_net_share_get_info: unsupported " - "switch value %d\n", info_level)); - status = WERR_UNKNOWN_LEVEL; - break; - } - } else { - status = WERR_INVALID_NAME; - } - - r_n->info.ptr_share_ctr = W_ERROR_IS_OK(status) ? 1 : 0; - r_n->status = status; -} - /******************************************************************* fill in a sess info level 0 structure. ********************************************************************/ -static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot) +static void init_srv_sess_info_0(pipes_struct *p, struct srvsvc_NetSessCtr0 *ss0, uint32 *snum, uint32 *stot) { struct sessionid *session_list; uint32 num_entries = 0; @@ -780,24 +728,23 @@ static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *sto DEBUG(5,("init_srv_sess_0_ss0\n")); + ss0->array = talloc_array(p->mem_ctx, struct srvsvc_NetSessInfo0, *stot); + if (snum) { - for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { - init_srv_sess_info0( &ss0->info_0[num_entries], session_list[(*snum)].remote_machine); + for (; (*snum) < (*stot); (*snum)++) { + ss0->array[num_entries].client = session_list[(*snum)].remote_machine; num_entries++; } - ss0->num_entries_read = num_entries; - ss0->ptr_sess_info = num_entries > 0 ? 1 : 0; - ss0->num_entries_read2 = num_entries; + ss0->count = num_entries; if ((*snum) >= (*stot)) { (*snum) = 0; } } else { - ss0->num_entries_read = 0; - ss0->ptr_sess_info = 0; - ss0->num_entries_read2 = 0; + ss0->array = NULL; + ss0->count = 0; } SAFE_FREE(session_list); } @@ -838,16 +785,15 @@ static int net_count_files( uid_t uid, pid_t pid ) fill in a sess info level 1 structure. ********************************************************************/ -static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot) +static void init_srv_sess_info_1(pipes_struct *p, struct srvsvc_NetSessCtr1 *ss1, uint32 *snum, uint32 *stot) { struct sessionid *session_list; uint32 num_entries = 0; time_t now = time(NULL); if ( !snum ) { - ss1->num_entries_read = 0; - ss1->ptr_sess_info = 0; - ss1->num_entries_read2 = 0; + ss1->count = 0; + ss1->array = NULL; (*stot) = 0; @@ -860,9 +806,10 @@ static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto } (*stot) = list_sessions(&session_list); - - for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { + ss1->array = talloc_array(p->mem_ctx, struct srvsvc_NetSessInfo1, *stot); + + for (; (*snum) < (*stot); (*snum)++) { uint32 num_files; uint32 connect_time; struct passwd *pw = sys_getpwnam(session_list[*snum].username); @@ -878,19 +825,17 @@ static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto num_files = net_count_files(pw->pw_uid, session_list[*snum].pid); guest = strequal( session_list[*snum].username, lp_guestaccount() ); - init_srv_sess_info1( &ss1->info_1[num_entries], - session_list[*snum].remote_machine, - session_list[*snum].username, - num_files, - connect_time, - 0, - guest); + ss1->array[num_entries].client = session_list[*snum].remote_machine; + ss1->array[num_entries].user = session_list[*snum].username; + ss1->array[num_entries].num_open = num_files; + ss1->array[num_entries].time = connect_time; + ss1->array[num_entries].idle_time = 0; + ss1->array[num_entries].user_flags = guest; + num_entries++; } - ss1->num_entries_read = num_entries; - ss1->ptr_sess_info = num_entries > 0 ? 1 : 0; - ss1->num_entries_read2 = num_entries; + ss1->count = num_entries; if ((*snum) >= (*stot)) { (*snum) = 0; @@ -903,28 +848,26 @@ static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *sto makes a SRV_R_NET_SESS_ENUM structure. ********************************************************************/ -static WERROR init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, +static WERROR init_srv_sess_info_ctr(pipes_struct *p, union srvsvc_NetSessCtr *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { WERROR status = WERR_OK; DEBUG(5,("init_srv_sess_info_ctr: %d\n", __LINE__)); - ctr->switch_value = switch_value; - switch (switch_value) { case 0: - init_srv_sess_info_0(&(ctr->sess.info0), resume_hnd, total_entries); - ctr->ptr_sess_ctr = 1; + ctr->ctr0 = talloc(p->mem_ctx, struct srvsvc_NetSessCtr0); + init_srv_sess_info_0(p, ctr->ctr0, resume_hnd, total_entries); break; case 1: - init_srv_sess_info_1(&(ctr->sess.info1), resume_hnd, total_entries); - ctr->ptr_sess_ctr = 1; + ctr->ctr1 = talloc(p->mem_ctx, struct srvsvc_NetSessCtr1); + init_srv_sess_info_1(p, ctr->ctr1, resume_hnd, total_entries); break; default: DEBUG(5,("init_srv_sess_info_ctr: unsupported switch value %d\n", switch_value)); (*resume_hnd) = 0; (*total_entries) = 0; - ctr->ptr_sess_ctr = 0; + ctr->ctr0 = NULL; status = WERR_UNKNOWN_LEVEL; break; } @@ -932,33 +875,11 @@ static WERROR init_srv_sess_info_ctr(SRV_SESS_INFO_CTR *ctr, return status; } -/******************************************************************* - makes a SRV_R_NET_SESS_ENUM structure. -********************************************************************/ - -static void init_srv_r_net_sess_enum(SRV_R_NET_SESS_ENUM *r_n, - uint32 resume_hnd, int sess_level, int switch_value) -{ - DEBUG(5,("init_srv_r_net_sess_enum: %d\n", __LINE__)); - - r_n->sess_level = sess_level; - - if (sess_level == -1) - r_n->status = WERR_UNKNOWN_LEVEL; - else - r_n->status = init_srv_sess_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); - - if (!W_ERROR_IS_OK(r_n->status)) - resume_hnd = 0; - - init_enum_hnd(&r_n->enum_hnd, resume_hnd); -} - /******************************************************************* fill in a conn info level 0 structure. ********************************************************************/ -static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *stot) +static void init_srv_conn_info_0(pipes_struct *p, struct srvsvc_NetConnCtr0 *ss0, uint32 *snum, uint32 *stot) { uint32 num_entries = 0; (*stot) = 1; @@ -971,27 +892,25 @@ static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *sto DEBUG(5,("init_srv_conn_0_ss0\n")); if (snum) { - for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) { + ss0->array = talloc_array(p->mem_ctx, struct srvsvc_NetConnInfo0, *stot); + for (; (*snum) < (*stot); (*snum)++) { - init_srv_conn_info0(&ss0->info_0[num_entries], (*stot)); + ss0->array[num_entries].conn_id = (*stot); /* move on to creating next connection */ /* move on to creating next conn */ num_entries++; } - ss0->num_entries_read = num_entries; - ss0->ptr_conn_info = num_entries > 0 ? 1 : 0; - ss0->num_entries_read2 = num_entries; + ss0->count = num_entries; if ((*snum) >= (*stot)) { (*snum) = 0; } } else { - ss0->num_entries_read = 0; - ss0->ptr_conn_info = 0; - ss0->num_entries_read2 = 0; + ss0->array = NULL; + ss0->count = 0; (*stot) = 0; } @@ -1001,20 +920,7 @@ static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *sto fill in a conn info level 1 structure. ********************************************************************/ -static void init_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1, - uint32 id, uint32 type, - uint32 num_opens, uint32 num_users, uint32 open_time, - const char *usr_name, const char *net_name) -{ - init_srv_conn_info1(se1 , id, type, num_opens, num_users, open_time, usr_name, net_name); - init_srv_conn_info1_str(str1, usr_name, net_name); -} - -/******************************************************************* - fill in a conn info level 1 structure. - ********************************************************************/ - -static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *stot) +static void init_srv_conn_info_1(pipes_struct *p, struct srvsvc_NetConnCtr1 *ss1, uint32 *snum, uint32 *stot) { uint32 num_entries = 0; (*stot) = 1; @@ -1027,29 +933,30 @@ static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto DEBUG(5,("init_srv_conn_1_ss1\n")); if (snum) { - for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) { - init_srv_conn_1_info(&ss1->info_1[num_entries], - &ss1->info_1_str[num_entries], - (*stot), 0x3, 1, 1, 3,"dummy_user", "IPC$"); + ss1->array = talloc_array(p->mem_ctx, struct srvsvc_NetConnInfo1, *stot); + for (; (*snum) < (*stot); (*snum)++) { + ss1->array[num_entries].conn_id = (*stot); + ss1->array[num_entries].conn_type = 0x3; + ss1->array[num_entries].num_open = 1; + ss1->array[num_entries].num_users = 1; + ss1->array[num_entries].conn_time = 3; + ss1->array[num_entries].user = "dummy_user"; + ss1->array[num_entries].share = "IPC$"; /* move on to creating next connection */ /* move on to creating next conn */ num_entries++; } - ss1->num_entries_read = num_entries; - ss1->ptr_conn_info = num_entries > 0 ? 1 : 0; - ss1->num_entries_read2 = num_entries; - + ss1->count = num_entries; if ((*snum) >= (*stot)) { (*snum) = 0; } } else { - ss1->num_entries_read = 0; - ss1->ptr_conn_info = 0; - ss1->num_entries_read2 = 0; + ss1->count = 0; + ss1->array = NULL; (*stot) = 0; } @@ -1059,28 +966,24 @@ static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto makes a SRV_R_NET_CONN_ENUM structure. ********************************************************************/ -static WERROR init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, +static WERROR init_srv_conn_info_ctr(pipes_struct *p, union srvsvc_NetConnCtr *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { WERROR status = WERR_OK; DEBUG(5,("init_srv_conn_info_ctr: %d\n", __LINE__)); - ctr->switch_value = switch_value; - switch (switch_value) { case 0: - init_srv_conn_info_0(&ctr->conn.info0, resume_hnd, total_entries); - ctr->ptr_conn_ctr = 1; + init_srv_conn_info_0(p, ctr->ctr0, resume_hnd, total_entries); break; case 1: - init_srv_conn_info_1(&ctr->conn.info1, resume_hnd, total_entries); - ctr->ptr_conn_ctr = 1; + init_srv_conn_info_1(p, ctr->ctr1, resume_hnd, total_entries); break; default: DEBUG(5,("init_srv_conn_info_ctr: unsupported switch value %d\n", switch_value)); - (*resume_hnd = 0); + ctr->ctr0 = NULL; + (*resume_hnd) = 0; (*total_entries) = 0; - ctr->ptr_conn_ctr = 0; status = WERR_UNKNOWN_LEVEL; break; } @@ -1088,73 +991,42 @@ static WERROR init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, return status; } -/******************************************************************* - makes a SRV_R_NET_CONN_ENUM structure. -********************************************************************/ - -static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, - uint32 resume_hnd, int conn_level, int switch_value) -{ - DEBUG(5,("init_srv_r_net_conn_enum: %d\n", __LINE__)); - - r_n->conn_level = conn_level; - if (conn_level == -1) - r_n->status = WERR_UNKNOWN_LEVEL; - else - r_n->status = init_srv_conn_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); - - if (!W_ERROR_IS_OK(r_n->status)) - resume_hnd = 0; - - init_enum_hnd(&r_n->enum_hnd, resume_hnd); -} - /******************************************************************* makes a SRV_R_NET_FILE_ENUM structure. ********************************************************************/ -static WERROR net_file_enum_3( SRV_R_NET_FILE_ENUM *r, uint32 resume_hnd ) +static WERROR net_file_enum_3(pipes_struct *p, union srvsvc_NetFileCtr *ctr, uint32 *resume_hnd, uint32 *num_entries ) { TALLOC_CTX *ctx = get_talloc_ctx(); - SRV_FILE_INFO_CTR *ctr = &r->ctr; + WERROR status; /* TODO -- Windows enumerates (b) active pipes (c) open directories and files */ - r->status = net_enum_files( ctx, &ctr->file.info3, &ctr->num_entries, resume_hnd ); - if ( !W_ERROR_IS_OK(r->status)) - goto done; - - r->status = net_enum_pipes( ctx, &ctr->file.info3, &ctr->num_entries, resume_hnd ); - if ( !W_ERROR_IS_OK(r->status)) - goto done; + ctr->ctr3 = talloc_zero(p->mem_ctx, struct srvsvc_NetFileCtr3); - r->level = ctr->level = 3; - r->total_entries = ctr->num_entries; - /* ctr->num_entries = r->total_entries - resume_hnd; */ - ctr->num_entries2 = ctr->num_entries; - ctr->ptr_file_info = 1; - - r->status = WERR_OK; - -done: - if ( ctr->num_entries > 0 ) - ctr->ptr_entries = 1; - - init_enum_hnd(&r->enum_hnd, 0); + status = net_enum_files( ctx, &ctr->ctr3->array, num_entries, resume_hnd ); + if ( !W_ERROR_IS_OK(status)) + return status; + + status = net_enum_pipes( ctx, &ctr->ctr3->array, num_entries, resume_hnd ); + if ( !W_ERROR_IS_OK(status)) + return status; - return r->status; + ctr->ctr3->count = *num_entries; + + return WERR_OK; } /******************************************************************* *******************************************************************/ -WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) +WERROR _srvsvc_NetFileEnum(pipes_struct *p, const char *server_unc, const char *path, const char *user, uint32_t *level, union srvsvc_NetFileCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) { - switch ( q_u->level ) { + switch ( *level ) { case 3: - return net_file_enum_3( r_u, get_enum_hnd(&q_u->enum_hnd) ); + return net_file_enum_3(p, ctr, resume_handle, totalentries ); default: return WERR_UNKNOWN_LEVEL; } @@ -1166,15 +1038,11 @@ WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_F net server get info ********************************************************************/ -WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R_NET_SRV_GET_INFO *r_u) +WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetSrvInfo *info) { WERROR status = WERR_OK; - SRV_INFO_CTR *ctr = TALLOC_P(p->mem_ctx, SRV_INFO_CTR); - if (!ctr) - return WERR_NOMEM; - - ZERO_STRUCTP(ctr); + ZERO_STRUCTP(info); DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); @@ -1183,131 +1051,106 @@ WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R return WERR_ACCESS_DENIED; } - switch (q_u->switch_value) { + switch (level) { /* Technically level 102 should only be available to Administrators but there isn't anything super-secret here, as most of it is made up. */ case 102: - init_srv_info_102(&ctr->srv.sv102, - 500, global_myname(), - string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), - lp_major_announce_version(), lp_minor_announce_version(), - lp_default_server_announce(), - 0xffffffff, /* users */ - 0xf, /* disc */ - 0, /* hidden */ - 240, /* announce */ - 3000, /* announce delta */ - 100000, /* licenses */ - "c:\\"); /* user path */ + info->info102 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo102); + + info->info102->platform_id = 500; + info->info102->version_major = lp_major_announce_version(); + info->info102->version_minor = lp_minor_announce_version(); + info->info102->server_name = global_myname(); + info->info102->server_type = lp_default_server_announce(); + info->info102->userpath = "C:\\"; + info->info102->licenses = 10000; + info->info102->anndelta = 3000; + info->info102->disc = 0xf; + info->info102->users = 0xffffffff; + info->info102->hidden = 0; + info->info102->announce = 240; + info->info102->comment = lp_serverstring(); break; case 101: - init_srv_info_101(&ctr->srv.sv101, - 500, global_myname(), - lp_major_announce_version(), lp_minor_announce_version(), - lp_default_server_announce(), - string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); + info->info101 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo101); + info->info101->platform_id = 500; + info->info101->server_name = global_myname(); + info->info101->version_major = lp_major_announce_version(); + info->info101->version_minor = lp_minor_announce_version(); + info->info101->server_type = lp_default_server_announce(); + info->info101->comment = lp_serverstring(); break; case 100: - init_srv_info_100(&ctr->srv.sv100, 500, global_myname()); + info->info100 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo100); + info->info100->platform_id = 500; + info->info100->server_name = global_myname(); break; default: - status = WERR_UNKNOWN_LEVEL; + return WERR_UNKNOWN_LEVEL; break; } - /* set up the net server get info structure */ - init_srv_r_net_srv_get_info(r_u, q_u->switch_value, ctr, status); - DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); - return r_u->status; + return status; } /******************************************************************* net server set info ********************************************************************/ -WERROR _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R_NET_SRV_SET_INFO *r_u) +WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetSrvInfo info, uint32_t *parm_error) { - WERROR status = WERR_OK; - - DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__)); - /* Set up the net server set info structure. */ - - init_srv_r_net_srv_set_info(r_u, 0x0, status); - - DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__)); - - return r_u->status; + *parm_error = 0; + return WERR_OK; } /******************************************************************* net conn enum ********************************************************************/ -WERROR _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_CONN_ENUM *r_u) +WERROR _srvsvc_NetConnEnum(pipes_struct *p, const char *server_unc, const char *path, uint32_t *level, union srvsvc_NetConnCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) { DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); - r_u->ctr = TALLOC_P(p->mem_ctx, SRV_CONN_INFO_CTR); - if (!r_u->ctr) - return WERR_NOMEM; - - ZERO_STRUCTP(r_u->ctr); + ZERO_STRUCTP(ctr); /* set up the */ - init_srv_r_net_conn_enum(r_u, - get_enum_hnd(&q_u->enum_hnd), - q_u->conn_level, - q_u->ctr->switch_value); - - DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); - - return r_u->status; + return init_srv_conn_info_ctr(p, ctr, *level, resume_handle, totalentries); } /******************************************************************* net sess enum ********************************************************************/ -WERROR _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_SESS_ENUM *r_u) +WERROR _srvsvc_NetSessEnum(pipes_struct *p, const char *server_unc, const char *client, const char *user, uint32_t *level, union srvsvc_NetSessCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) { DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__)); - r_u->ctr = TALLOC_P(p->mem_ctx, SRV_SESS_INFO_CTR); - if (!r_u->ctr) - return WERR_NOMEM; - - ZERO_STRUCTP(r_u->ctr); + ZERO_STRUCTP(ctr); /* set up the */ - init_srv_r_net_sess_enum(r_u, - get_enum_hnd(&q_u->enum_hnd), - q_u->sess_level, - q_u->ctr->switch_value); - - DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__)); - - return r_u->status; + return init_srv_sess_info_ctr(p, ctr, + *level, + resume_handle, + totalentries); } /******************************************************************* net sess del ********************************************************************/ -WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SESS_DEL *r_u) +WERROR _srvsvc_NetSessDel(pipes_struct *p, const char *server_unc, const char *client, const char *user) { struct sessionid *session_list; int num_sessions, snum; - fstring username; - fstring machine; + WERROR status; - rpcstr_pull_unistr2_fstring(username, &q_u->uni_user_name); - rpcstr_pull_unistr2_fstring(machine, &q_u->uni_cli_name); + char *machine = talloc_strdup(p->mem_ctx, server_unc); /* strip leading backslashes if any */ while (machine[0] == '\\') { @@ -1318,7 +1161,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); - r_u->status = WERR_ACCESS_DENIED; + status = WERR_ACCESS_DENIED; /* fail out now if you are not root or not a domain admin */ @@ -1330,11 +1173,11 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES for (snum = 0; snum < num_sessions; snum++) { - if ((strequal(session_list[snum].username, username) || username[0] == '\0' ) && + if ((strequal(session_list[snum].username, user) || user[0] == '\0' ) && strequal(session_list[snum].remote_machine, machine)) { if (message_send_pid(pid_to_procid(session_list[snum].pid), MSG_SHUTDOWN, NULL, 0, False)) - r_u->status = WERR_OK; + status = WERR_OK; } } @@ -1344,14 +1187,14 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES done: SAFE_FREE(session_list); - return r_u->status; + return status; } /******************************************************************* Net share enum all. ********************************************************************/ -WERROR _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) +WERROR _srvsvc_NetShareEnumAll(pipes_struct *p, const char *server_unc, uint32_t *level, union srvsvc_NetShareCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) { DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); @@ -1361,20 +1204,15 @@ WERROR _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R } /* Create the list of shares for the response. */ - init_srv_r_net_share_enum(p, r_u, - q_u->ctr.info_level, - get_enum_hnd(&q_u->enum_hnd), True); - - DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); - - return r_u->status; + return init_srv_share_info_ctr(p, ctr, *level, + resume_handle, totalentries, True); } /******************************************************************* Net share enum. ********************************************************************/ -WERROR _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) +WERROR _srvsvc_NetShareEnum(pipes_struct *p, const char *server_unc, uint32_t *level, union srvsvc_NetShareCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) { DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); @@ -1384,32 +1222,87 @@ WERROR _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET } /* Create the list of shares for the response. */ - init_srv_r_net_share_enum(p, r_u, - q_u->ctr.info_level, - get_enum_hnd(&q_u->enum_hnd), False); - - DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); - - return r_u->status; + return init_srv_share_info_ctr(p, ctr, *level, + resume_handle, totalentries, False); } /******************************************************************* Net share get info. ********************************************************************/ -WERROR _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, SRV_R_NET_SHARE_GET_INFO *r_u) +WERROR _srvsvc_NetShareGetInfo(pipes_struct *p, const char *server_unc, const char *share_name, uint32_t level, union srvsvc_NetShareInfo *info) { - fstring share_name; + const struct share_params *params; - DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); + params = get_share_params(p->mem_ctx, share_name); - /* 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, r_u, share_name, q_u->info_level); + if (params != NULL) { + switch (level) { + case 0: + info->info0 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo0); + init_srv_share_info_0(p, info->info0, + params); + break; + case 1: + info->info1 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1); + init_srv_share_info_1(p, info->info1, + params); + break; + case 2: + info->info2 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo2); + init_srv_share_info_2(p, info->info2, + params); + break; + case 501: + info->info501 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo501); + init_srv_share_info_501(p, info->info501, + params); + break; + case 502: + info->info502 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo502); + init_srv_share_info_502(p, info->info502, + params); + break; + + /* here for completeness */ + case 1004: + info->info1004 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1004); + init_srv_share_info_1004(p, info->info1004, + params); + break; + case 1005: + info->info1005 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1005); + init_srv_share_info_1005(p, info->info1005, + params); + break; - DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); + /* here for completeness 1006 - 1501 */ + case 1006: + info->info1006 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1006); + init_srv_share_info_1006(p, info->info1006, + params); + break; + case 1007: + info->info1007 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1007); + init_srv_share_info_1007(p, info->info1007, + params); + break; + case 1501: + info->info1501 = talloc(p->mem_ctx, struct sec_desc_buf); + init_srv_share_info_1501(p, info->info1501, + params); + break; + default: + DEBUG(5,("init_srv_net_share_get_info: unsupported " + "switch value %d\n", level)); + return WERR_UNKNOWN_LEVEL; + break; + } + } else { + return WERR_INVALID_NAME; + } - return r_u->status; + return WERR_OK; } /******************************************************************* @@ -1440,11 +1333,10 @@ char *valid_share_pathname(char *dos_pathname) Net share set info. Modify share details. ********************************************************************/ -WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) +WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, const char *share_name, uint32_t level, union srvsvc_NetShareInfo info, uint32_t *parm_error) { pstring command; - fstring share_name; - fstring comment; + pstring comment; pstring pathname; int type; int snum; @@ -1454,12 +1346,11 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op = False; int max_connections = 0; + fstring tmp_share_name; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); - unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); - - r_u->parm_error = 0; + *parm_error = 0; if ( strequal(share_name,"IPC$") || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) @@ -1468,7 +1359,8 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return WERR_ACCESS_DENIED; } - snum = find_service(share_name); + fstrcpy(tmp_share_name, share_name); + snum = find_service(tmp_share_name); /* Does this share exist ? */ if (snum < 0) @@ -1485,18 +1377,18 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if ( p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; - switch (q_u->info_level) { + switch (level) { case 1: pstrcpy(pathname, lp_pathname(snum)); - unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); - type = q_u->info.share.info2.info_2.type; + pstrcpy(comment, info.info1->comment); + type = info.info1->type; psd = NULL; break; case 2: - unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); - unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(pathname)); - type = q_u->info.share.info2.info_2.type; - max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; + pstrcpy(comment, info.info2->comment); + pstrcpy(pathname, info.info2->path); + type = info.info2->type; + max_connections = (info.info2->max_users == 0xffffffff) ? 0 : info.info2->max_users; psd = NULL; break; #if 0 @@ -1508,15 +1400,15 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S break; #endif case 502: - unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(comment)); - unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(pathname)); - type = q_u->info.share.info502.info_502.type; - psd = q_u->info.share.info502.info_502_str.sd; + pstrcpy(comment, info.info502->comment); + pstrcpy(pathname, info.info502->path); + type = info.info502->type; + psd = info.info502->sd; map_generic_share_sd_bits(psd); break; case 1004: pstrcpy(pathname, lp_pathname(snum)); - unistr2_to_ascii(comment, &q_u->info.share.info1004.info_1004_str.uni_remark, sizeof(comment)); + pstrcpy(comment, info.info1004->comment); type = STYPE_DISKTREE; break; case 1005: @@ -1524,7 +1416,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S user, so we must compare it to see if it's what is set in smb.conf, so that we can contine other ops like setting ACLs on a share */ - if (((q_u->info.share.info1005.share_info_flags & + if (((info.info1005->dfs_flags & SHARE_1005_CSC_POLICY_MASK) >> SHARE_1005_CSC_POLICY_SHIFT) == lp_csc_policy(snum)) return WERR_OK; @@ -1537,13 +1429,13 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return WERR_ACCESS_DENIED; case 1501: pstrcpy(pathname, lp_pathname(snum)); - fstrcpy(comment, lp_comment(snum)); - psd = q_u->info.share.info1501.sdb->sd; + pstrcpy(comment, lp_comment(snum)); + psd = info.info1501->sd; map_generic_share_sd_bits(psd); type = STYPE_DISKTREE; break; default: - DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", q_u->info_level)); + DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", level)); return WERR_UNKNOWN_LEVEL; } @@ -1556,7 +1448,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return WERR_OBJECT_PATH_INVALID; /* Ensure share name, pathname and comment don't contain '"' characters. */ - string_replace(share_name, '"', ' '); + string_replace(tmp_share_name, '"', ' '); string_replace(path, '"', ' '); string_replace(comment, '"', ' '); @@ -1626,16 +1518,16 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S "comment" "max connections = " ********************************************************************/ -WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) +WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetShareInfo info, uint32_t *parm_error) { pstring command; - fstring share_name; - fstring comment; + pstring share_name; + pstring comment; pstring pathname; + char *path; int type; int snum; int ret; - char *path; SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op; @@ -1643,7 +1535,7 @@ WERROR _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__)); - r_u->parm_error = 0; + *parm_error = 0; is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); @@ -1655,7 +1547,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S return WERR_ACCESS_DENIED; } - switch (q_u->info_level) { + switch (level) { case 0: /* No path. Not enough info in a level 0 to do anything. */ return WERR_ACCESS_DENIED; @@ -1663,21 +1555,21 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S /* Not enough info in a level 1 to do anything. */ return WERR_ACCESS_DENIED; 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)); - unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name)); - max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; - type = q_u->info.share.info2.info_2.type; + pstrcpy(share_name, info.info2->name); + pstrcpy(comment, info.info2->comment); + pstrcpy(pathname, info.info2->path); + max_connections = (info.info2->max_users == 0xffffffff) ? 0 : info.info2->max_users; + type = info.info2->type; break; case 501: /* No path. Not enough info in a level 501 to do anything. */ return WERR_ACCESS_DENIED; case 502: - unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name)); - unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name)); - unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name)); - type = q_u->info.share.info502.info_502.type; - psd = q_u->info.share.info502.info_502_str.sd; + pstrcpy(share_name, info.info502->name); + pstrcpy(comment, info.info502->comment); + pstrcpy(pathname, info.info502->path); + type = info.info502->type; + psd = info.info502->sd; map_generic_share_sd_bits(psd); break; @@ -1692,7 +1584,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S /* DFS only level. */ return WERR_ACCESS_DENIED; default: - DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", q_u->info_level)); + DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", level)); return WERR_UNKNOWN_LEVEL; } @@ -1780,19 +1672,17 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S a parameter. ********************************************************************/ -WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) +WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, const char *share_name, uint32_t reserved) { pstring command; - fstring share_name; int ret; int snum; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op; + fstring tmp_share_name; DEBUG(5,("_srv_net_share_del: %d\n", __LINE__)); - unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); - if ( strequal(share_name,"IPC$") || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) || strequal(share_name,"global") ) @@ -1800,7 +1690,8 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S return WERR_ACCESS_DENIED; } - snum = find_service(share_name); + fstrcpy(tmp_share_name, share_name); + snum = find_service(tmp_share_name); if (snum < 0) return WERR_NO_SUCH_SHARE; @@ -1852,22 +1743,22 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S return WERR_OK; } -WERROR _srv_net_share_del_sticky(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) +WERROR _srvsvc_NetShareDelSticky(pipes_struct *p, const char *server_unc, const char *share_name, uint32_t reserved) { DEBUG(5,("_srv_net_share_del_stick: %d\n", __LINE__)); - return _srv_net_share_del(p, q_u, r_u); + return _srvsvc_NetShareDel(p, server_unc, share_name, reserved); } /******************************************************************* time of day ********************************************************************/ -WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET_REMOTE_TOD *r_u) +WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, const char *server_unc, struct srvsvc_NetRemoteTODInfo *tod) { - TIME_OF_DAY_INFO *tod; struct tm *t; time_t unixdate = time(NULL); + WERROR status = WERR_OK; /* We do this call first as if we do it *after* the gmtime call it overwrites the pointed-to values. JRA */ @@ -1876,101 +1767,87 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); - if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, TIME_OF_DAY_INFO)) ) - return WERR_NOMEM; - - r_u->tod = tod; - r_u->ptr_srv_tod = 0x1; - r_u->status = WERR_OK; - - DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); - t = gmtime(&unixdate); /* set up the */ - init_time_of_day_info(tod, - unixdate, - 0, - t->tm_hour, - t->tm_min, - t->tm_sec, - 0, - zone, - 10000, - t->tm_mday, - t->tm_mon + 1, - 1900+t->tm_year, - t->tm_wday); + tod->elapsed = unixdate; + tod->msecs = 0; + tod->hours = t->tm_hour; + tod->mins = t->tm_min; + tod->secs = t->tm_sec; + tod->hunds = 0; + tod->timezone = zone; + tod->tinterval = 10000; + tod->day = t->tm_mday; + tod->month = t->tm_mon + 1; + tod->year = 1900+t->tm_year; + tod->weekday = t->tm_wday; DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); - return r_u->status; + return status; } /*********************************************************************************** Win9x NT tools get security descriptor. ***********************************************************************************/ -WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC *q_u, - SRV_R_NET_FILE_QUERY_SECDESC *r_u) +WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, const char *server_unc, const char *share, const char *file, uint32_t securityinformation, struct sec_desc_buf *sd_buf) { SEC_DESC *psd = NULL; size_t sd_size; DATA_BLOB null_pw; - pstring filename; - pstring qualname; files_struct *fsp = NULL; SMB_STRUCT_STAT st; BOOL bad_path; NTSTATUS nt_status; connection_struct *conn = NULL; BOOL became_user = False; + WERROR status = WERR_OK; + pstring tmp_file; ZERO_STRUCT(st); - r_u->status = WERR_OK; - - unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); /* Null password is ok - we are already an authenticated user... */ null_pw = data_blob(NULL, 0); become_root(); - conn = make_connection(qualname, null_pw, "A:", p->pipe_user.vuid, &nt_status); + conn = make_connection(share, null_pw, "A:", p->pipe_user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", qualname)); - r_u->status = ntstatus_to_werror(nt_status); + DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", share)); + status = ntstatus_to_werror(nt_status); goto error_exit; } if (!become_user(conn, conn->vuid)) { DEBUG(0,("_srv_net_file_query_secdesc: Can't become connected user!\n")); - r_u->status = WERR_ACCESS_DENIED; + status = WERR_ACCESS_DENIED; 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); + pstrcpy(tmp_file, file); + unix_convert(tmp_file, conn, NULL, &bad_path, &st); if (bad_path) { - DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } - if (!check_name(filename,conn)) { - DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + if (!check_name(file,conn)) { + DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = open_file_stat(conn, filename, &st, &fsp); + nt_status = open_file_stat(conn, file, &st, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { /* Perhaps it is a directory */ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) - nt_status = open_directory(conn, filename, &st, + nt_status = open_directory(conn, file, &st, READ_CONTROL_ACCESS, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, @@ -1978,8 +1855,8 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC NULL, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } } @@ -1987,23 +1864,20 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC sd_size = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION), &psd); if (sd_size == 0) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } - r_u->ptr_response = 1; - r_u->size_response = sd_size; - r_u->ptr_secdesc = 1; - r_u->size_secdesc = sd_size; - r_u->sec_desc = psd; + sd_buf->sd_size= sd_size; + sd_buf->sd = psd; psd->dacl->revision = (uint16) NT4_ACL_REVISION; close_file(fsp, NORMAL_CLOSE); unbecome_user(); close_cnum(conn, p->pipe_user.vuid); - return r_u->status; + return status; error_exit: @@ -2017,19 +1891,16 @@ error_exit: if (conn) close_cnum(conn, p->pipe_user.vuid); - return r_u->status; + return status; } /*********************************************************************************** Win9x NT tools set security descriptor. ***********************************************************************************/ -WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_u, - SRV_R_NET_FILE_SET_SECDESC *r_u) +WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, const char *server_unc, const char *share, const char *file, uint32_t securityinformation, struct sec_desc_buf sd_buf) { BOOL ret; - pstring filename; - pstring qualname; DATA_BLOB null_pw; files_struct *fsp = NULL; SMB_STRUCT_STAT st; @@ -2037,54 +1908,52 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ NTSTATUS nt_status; connection_struct *conn = NULL; BOOL became_user = False; + WERROR status = WERR_OK; + pstring tmp_file; ZERO_STRUCT(st); - r_u->status = WERR_OK; - - unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); - /* Null password is ok - we are already an authenticated user... */ null_pw = data_blob(NULL, 0); become_root(); - conn = make_connection(qualname, null_pw, "A:", p->pipe_user.vuid, &nt_status); + conn = make_connection(share, null_pw, "A:", p->pipe_user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", qualname)); - r_u->status = ntstatus_to_werror(nt_status); + DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", share)); + status = ntstatus_to_werror(nt_status); 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 = WERR_ACCESS_DENIED; + status = WERR_ACCESS_DENIED; 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); + pstrcpy(tmp_file, file); + unix_convert(tmp_file, conn, NULL, &bad_path, &st); if (bad_path) { - DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } - if (!check_name(filename,conn)) { - DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + if (!check_name(file,conn)) { + DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = open_file_stat(conn, filename, &st, &fsp); + nt_status = open_file_stat(conn, file, &st, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { /* Perhaps it is a directory */ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) - nt_status = open_directory(conn, filename, &st, + nt_status = open_directory(conn, file, &st, FILE_READ_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, @@ -2092,24 +1961,24 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ NULL, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } } - ret = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, q_u->sec_info, q_u->sec_desc); + ret = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, securityinformation, sd_buf.sd); if (ret == False) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", file)); + status = WERR_ACCESS_DENIED; goto error_exit; } close_file(fsp, NORMAL_CLOSE); unbecome_user(); close_cnum(conn, p->pipe_user.vuid); - return r_u->status; + return status; error_exit: @@ -2125,7 +1994,7 @@ error_exit: close_cnum(conn, p->pipe_user.vuid); } - return r_u->status; + return status; } /*********************************************************************************** @@ -2174,76 +2043,68 @@ static const char *next_server_disk_enum(uint32 *resume) return disk; } -WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_DISK_ENUM *r_u) +WERROR _srvsvc_NetDiskEnum(pipes_struct *p, const char *server_unc, uint32_t level, struct srvsvc_NetDiskInfo *info, uint32_t maxlen, uint32_t *totalentries, uint32_t *resume_handle) { uint32 i; const char *disk_name; - TALLOC_CTX *ctx = p->mem_ctx; - uint32 resume=get_enum_hnd(&q_u->enum_hnd); - r_u->status=WERR_OK; - - r_u->total_entries = init_server_disk_enum(&resume); + WERROR status = WERR_OK; - r_u->disk_enum_ctr.unknown = 0; + *totalentries = init_server_disk_enum(resume_handle); + info->count = 0; - if(!(r_u->disk_enum_ctr.disk_info = TALLOC_ARRAY(ctx, DISK_INFO, MAX_SERVER_DISK_ENTRIES))) { + if(!(info->disks = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetDiskInfo0, MAX_SERVER_DISK_ENTRIES))) { return WERR_NOMEM; } - r_u->disk_enum_ctr.disk_info_ptr = r_u->disk_enum_ctr.disk_info ? 1 : 0; - - /*allow one DISK_INFO for null terminator*/ + /*allow one struct srvsvc_NetDiskInfo0 for null terminator*/ - for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(&resume)); i++) { + for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(resume_handle)); i++) { - r_u->disk_enum_ctr.entries_read++; + info->count++; + (*totalentries)++; /*copy disk name into a unicode string*/ - init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name); + info->disks[i].disk = disk_name; } /* add a terminating null string. Is this there if there is more data to come? */ - r_u->disk_enum_ctr.entries_read++; + info->count++; + (*totalentries)++; - init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, ""); + info->disks[i].disk = ""; - init_enum_hnd(&r_u->enum_hnd, resume); - - return r_u->status; + return status; } /******************************************************************** ********************************************************************/ -WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV_R_NET_NAME_VALIDATE *r_u) +WERROR _srvsvc_NetNameValidate(pipes_struct *p, const char *server_unc, const char *name, uint32_t name_type, uint32_t flags) { - fstring sharename; int len; - if ((q_u->flags != 0x0) && (q_u->flags != 0x80000000)) { + if ((flags != 0x0) && (flags != 0x80000000)) { return WERR_INVALID_PARAM; } - switch ( q_u->type ) { + switch ( name_type ) { case 0x9: - rpcstr_pull(sharename, q_u->sharename.buffer, sizeof(sharename), q_u->sharename.uni_str_len*2, 0); - - len = strlen_m(sharename); + len = strlen_m(name); - if ((q_u->flags == 0x0) && (len > 81)) { - DEBUG(5,("_srv_net_name_validate: share name too long (%s > 81 chars)\n", sharename)); + if ((flags == 0x0) && (len > 81)) { + DEBUG(5,("_srv_net_name_validate: share name too long (%s > 81 chars)\n", name)); return WERR_INVALID_NAME; } - if ((q_u->flags == 0x80000000) && (len > 13)) { - DEBUG(5,("_srv_net_name_validate: share name too long (%s > 13 chars)\n", sharename)); + if ((flags == 0x80000000) && (len > 13)) { + DEBUG(5,("_srv_net_name_validate: share name too long (%s > 13 chars)\n", name)); return WERR_INVALID_NAME; } - if ( ! validate_net_name( sharename, INVALID_SHARENAME_CHARS, sizeof(sharename) ) ) { - DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", sharename)); + if ( ! validate_net_name( name, INVALID_SHARENAME_CHARS, sizeof(name) ) ) { + DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", name)); return WERR_INVALID_NAME; } break; @@ -2259,8 +2120,182 @@ WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV /******************************************************************** ********************************************************************/ -WERROR _srv_net_file_close(pipes_struct *p, SRV_Q_NET_FILE_CLOSE *q_u, SRV_R_NET_FILE_CLOSE *r_u) +WERROR _srvsvc_NetFileClose(pipes_struct *p, const char *server_unc, uint32_t fid) { return WERR_ACCESS_DENIED; } +WERROR _srvsvc_NetCharDevEnum(pipes_struct *p, const char *server_unc, uint32_t *level, union srvsvc_NetCharDevCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetCharDevGetInfo(pipes_struct *p, const char *server_unc, const char *device_name, uint32_t level, union srvsvc_NetCharDevInfo *info) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetCharDevControl(pipes_struct *p, const char *server_unc, const char *device_name, uint32_t opcode) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetCharDevQEnum(pipes_struct *p, const char *server_unc, const char *user, uint32_t *level, union srvsvc_NetCharDevQCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetCharDevQGetInfo(pipes_struct *p, const char *server_unc, const char *queue_name, const char *user, uint32_t level, union srvsvc_NetCharDevQInfo *info) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetCharDevQSetInfo(pipes_struct *p, const char *server_unc, const char *queue_name, uint32_t level, union srvsvc_NetCharDevQInfo info, uint32_t *parm_error) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetCharDevQPurge(pipes_struct *p, const char *server_unc, const char *queue_name) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetCharDevQPurgeSelf(pipes_struct *p, const char *server_unc, const char *queue_name, const char *computer_name) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetFileGetInfo(pipes_struct *p, const char *server_unc, uint32_t fid, uint32_t level, union srvsvc_NetFileInfo *info) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetShareCheck(pipes_struct *p, const char *server_unc, const char *device_name, enum srvsvc_ShareType *type) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetServerStatisticsGet(pipes_struct *p, const char *server_unc, const char *service, uint32_t level, uint32_t options, struct srvsvc_Statistics *stats) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetTransportAdd(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetTransportInfo info) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetTransportEnum(pipes_struct *p, const char *server_unc, uint32_t *level, union srvsvc_NetTransportCtr *transports, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetTransportDel(pipes_struct *p, const char *server_unc, uint32_t unknown, struct srvsvc_NetTransportInfo0 transport) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetSetServiceBits(pipes_struct *p, const char *server_unc, const char *transport, uint32_t servicebits, uint32_t updateimmediately) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetPathType(pipes_struct *p, const char *server_unc, const char *path, uint32_t pathflags, uint32_t *pathtype) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetPathCanonicalize(pipes_struct *p, const char *server_unc, const char *path, uint8_t *can_path, uint32_t maxbuf, const char *prefix, uint32_t *pathtype, uint32_t pathflags) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetPathCompare(pipes_struct *p, const char *server_unc, const char *path1, const char *path2, uint32_t pathtype, uint32_t pathflags) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRPRNAMECANONICALIZE(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetPRNameCompare(pipes_struct *p, const char *server_unc, const char *name1, const char *name2, uint32_t name_type, uint32_t flags) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetShareDelStart(pipes_struct *p, const char *server_unc, const char *share, uint32_t reserved, struct policy_handle *hnd) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetShareDelCommit(pipes_struct *p, struct policy_handle *hnd) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetServerTransportAddEx(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetTransportInfo info) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetServerSetServiceBitsEx(pipes_struct *p, const char *server_unc, const char *emulated_server_unc, const char *transport, uint32_t servicebitsofinterest, uint32_t servicebits, uint32_t updateimmediately) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSGETVERSION(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSCREATELOCALPARTITION(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSDELETELOCALPARTITION(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSSETLOCALVOLUMESTATE(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSSETSERVERINFO(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSCREATEEXITPOINT(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSDELETEEXITPOINT(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRSERVERTRANSPORTDELEX(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSMANAGERREPORTSITEINFO(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSMODIFYPREFIX(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NETRDFSFIXLOCALVOLUME(pipes_struct *p) +{ + return WERR_NOT_SUPPORTED; +} -- cgit From 7239a85f0a8da51c10ca500408e328b3a84a08b1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Sep 2006 03:41:11 +0000 Subject: r18804: resume_hnd isn't a ref pointer and can be NULL metze (This used to be commit 8736262342611d432d529812bc1f647b8d6cf625) --- source3/rpc_server/srv_srvsvc_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index ecb907e72d..d8eb7a662e 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -508,7 +508,9 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, ZERO_STRUCTP(ctr); - *resume_hnd = 0; + if (resume_hnd) { + *resume_hnd = 0; + } /* Ensure all the usershares are loaded. */ become_root(); -- cgit From 387bfebfcf74e4b56b21a772b0e38b6cdb9dcf25 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 22 Sep 2006 15:09:08 +0000 Subject: r18823: Fix some errors in the srsvc handling code and start running the RPC-SRVSVC test against samba3. (This used to be commit f0508ecb44f13e9e9e521e2534889e98a31d2372) --- source3/rpc_server/srv_srvsvc_nt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index d8eb7a662e..737868f375 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -803,7 +803,8 @@ static void init_srv_sess_info_1(pipes_struct *p, struct srvsvc_NetSessCtr1 *ss1 } if (ss1 == NULL) { - (*snum) = 0; + if (snum != NULL) + (*snum) = 0; return; } @@ -867,7 +868,8 @@ static WERROR init_srv_sess_info_ctr(pipes_struct *p, union srvsvc_NetSessCtr *c break; default: DEBUG(5,("init_srv_sess_info_ctr: unsupported switch value %d\n", switch_value)); - (*resume_hnd) = 0; + if (resume_hnd != NULL) + (*resume_hnd) = 0; (*total_entries) = 0; ctr->ctr0 = NULL; status = WERR_UNKNOWN_LEVEL; @@ -887,7 +889,8 @@ static void init_srv_conn_info_0(pipes_struct *p, struct srvsvc_NetConnCtr0 *ss0 (*stot) = 1; if (ss0 == NULL) { - (*snum) = 0; + if (snum != NULL) + (*snum) = 0; return; } @@ -928,7 +931,8 @@ static void init_srv_conn_info_1(pipes_struct *p, struct srvsvc_NetConnCtr1 *ss1 (*stot) = 1; if (ss1 == NULL) { - (*snum) = 0; + if (snum != NULL) + (*snum) = 0; return; } -- cgit From 10a8d62e961eb779391d3d104e7b73ae1ce7ab00 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 25 Sep 2006 04:52:30 +0000 Subject: r18888: Fix a 64-bit warning (This used to be commit 94b53f2f2abf7be003aebdb586b154dfda56d120) --- source3/rpc_server/srv_unixinfo_nt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_unixinfo_nt.c b/source3/rpc_server/srv_unixinfo_nt.c index 321c6a6a5e..5dd5215ed0 100644 --- a/source3/rpc_server/srv_unixinfo_nt.c +++ b/source3/rpc_server/srv_unixinfo_nt.c @@ -108,7 +108,8 @@ NTSTATUS _unixinfo_GetPWUid(pipes_struct *p, uint32_t *count, uint64_t *uids, pw = getpwuid(uids[i]); if (pw == NULL) { - DEBUG(10, ("Did not find uid %lld\n", uids[i])); + DEBUG(10, ("Did not find uid %lld\n", + (long long int)uids[i])); continue; } -- cgit From fec98506440bbff0c340cc6e35767f0e81398519 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 25 Sep 2006 16:26:25 +0000 Subject: r18898: Fix for bug #4100 from Udo Eberhardt . Ensure we initialize values for smb_io_notify_info_data_strings to fix crash. Jeremy. (This used to be commit ceefb8dd3ca67449d5afbf556e9879abb37830ac) --- source3/rpc_server/srv_spoolss_nt.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1a396a2391..cd69fdf107 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2887,6 +2887,9 @@ static void spoolss_notify_devmode(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { + /* for a dummy implementation we have to zero the fields */ + data->notify_data.data.length = 0; + data->notify_data.data.string = NULL; } /******************************************************************* -- cgit From 5935ea9da149b10f6969d892a238564894f478f4 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 26 Sep 2006 19:37:37 +0000 Subject: r18929: * Clarify QueryValue IDL and regenerate code * Fix server _winreg_Query_Value() implementation so that usrmgr.exe starts now (This used to be commit 435d7bfc37f430c462fcb53bf3a82fcddc809771) --- source3/rpc_server/srv_winreg_nt.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 91435fc87e..b874c5e5d1 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -350,7 +350,7 @@ WERROR _winreg_OpenKey(pipes_struct *p, struct policy_handle *parent_handle, str reg_reply_info ********************************************************************/ -WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t *data, uint32_t *size, uint32_t *length) +WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t *data, uint32_t *data_size, uint32_t *value_length) { WERROR status = WERR_BADFILE; char *name; @@ -362,7 +362,7 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct if ( !regkey ) return WERR_BADFID; - *size = *length = *type = 0; + *value_length = *type = 0; DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); DEBUG(7,("_reg_info: policy key type = [%08x]\n", regkey->type)); @@ -383,8 +383,8 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct { uint32 outbuf_len; prs_struct prs_hkpd; - prs_init(&prs_hkpd, *size, p->mem_ctx, MARSHALL); - status = reg_perfcount_get_hkpd(&prs_hkpd, *size, &outbuf_len, NULL); + prs_init(&prs_hkpd, *data_size, p->mem_ctx, MARSHALL); + status = reg_perfcount_get_hkpd(&prs_hkpd, *data_size, &outbuf_len, NULL); regval_ctr_addvalue(regvals, "HKPD", REG_BINARY, prs_hkpd.data_p, outbuf_len); val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); @@ -435,8 +435,8 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct /* we probably have a request for a specific object here */ uint32 outbuf_len; prs_struct prs_hkpd; - prs_init(&prs_hkpd, *size, p->mem_ctx, MARSHALL); - status = reg_perfcount_get_hkpd(&prs_hkpd, *size, &outbuf_len, name); + prs_init(&prs_hkpd, *data_size, p->mem_ctx, MARSHALL); + status = reg_perfcount_get_hkpd(&prs_hkpd, *data_size, &outbuf_len, name); regval_ctr_addvalue(regvals, "HKPD", REG_BINARY, prs_hkpd.data_p, outbuf_len); @@ -465,17 +465,20 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct } } + /* if we have a value then copy it to the output */ + if ( val ) { - *size = regval_size( val ); - *length = regval_size( val ); + *value_length = regval_size( val ); + *type = val->type; -#if 0 - if ( (*data = talloc_memdup( p->mem_ctx, regval_data_p(val), *size )) == NULL ) { - status = WERR_NOMEM; + if ( *data_size == 0 ) { + status = WERR_OK; + } else if ( *value_length > *data_size ) { + status = WERR_MORE_DATA; + } else { + memcpy( data, regval_data_p(val), *value_length ); + status = WERR_OK; } -#endif - - *type = val->type; } TALLOC_FREE( regvals ); -- cgit From 49c73b5734a42b9d018dd7cfa006a1820ba08dee Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 26 Sep 2006 21:01:57 +0000 Subject: r18931: * Fix the IDL for QueryInfoKey. teh Classname in an in,out ref pointer * Clarify variable names in EnumValue IDL * Fix server code for _winreg_EnumValue() and _winreg_QueryInfoKe() (This used to be commit f520a9d0fba4cc3cfbda40dd68cb63c4c3c4ed30) --- source3/rpc_server/srv_winreg_nt.c | 50 ++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 23 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index b874c5e5d1..7adc29ec0a 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -492,12 +492,12 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct ****************************************************************************/ WERROR _winreg_QueryInfoKey(pipes_struct *p, struct policy_handle *handle, - struct winreg_String class_in, - struct winreg_String *class_out, uint32_t *num_subkeys, - uint32_t *max_subkeylen, uint32_t *max_subkeysize, + struct winreg_String *classname, + uint32_t *num_subkeys, uint32_t *max_subkeylen, + uint32_t *max_subkeysize, uint32_t *num_values, uint32_t *max_valnamelen, - uint32_t *max_valbufsize, uint32_t *secdescsize, - NTTIME *last_changed_time) + uint32_t *max_valbufsize, + uint32_t *secdescsize, NTTIME *last_changed_time) { WERROR status = WERR_OK; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); @@ -506,22 +506,23 @@ WERROR _winreg_QueryInfoKey(pipes_struct *p, struct policy_handle *handle, return WERR_BADFID; if ( !get_subkey_information( regkey, num_subkeys, max_subkeylen) ) { - DEBUG(0,("_reg_query_key: get_subkey_information() failed!\n")); + DEBUG(0,("_winreg_QueryInfoKey: get_subkey_information() failed!\n")); return WERR_ACCESS_DENIED; } if ( !get_value_information( regkey, num_values, max_valnamelen, max_valbufsize) ) { - DEBUG(0,("_reg_query_key: get_value_information() failed!\n")); + DEBUG(0,("_winreg_QueryInfoKey: get_value_information() failed!\n")); return WERR_ACCESS_DENIED; } - *secdescsize = 0x00000078; /* size for key's sec_desc */ - - /* Win9x set this to 0x0 since it does not keep timestamps. - Doing the same here for simplicity --jerry */ - + *secdescsize = 0; /* used to be hard coded for 0x00000078 */ *last_changed_time = 0; + *max_subkeysize = 0; /* maybe this is the classname length ? */ + /* don't bother with class names for now */ + + classname->name = NULL; + return status; } @@ -586,7 +587,7 @@ done: Implementation of REG_ENUM_VALUE ****************************************************************************/ -WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_StringBuf *name, enum winreg_Type *type, uint8_t *value, uint32_t *size, uint32_t *length) +WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_StringBuf *name, enum winreg_Type *type, uint8_t *data, uint32_t *data_size, uint32_t *value_length) { WERROR status = WERR_OK; REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); @@ -595,17 +596,17 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, uint32_t if ( !regkey ) return WERR_BADFID; - if ( !name || !type || !value || !size || !length ) + if ( !name ) return WERR_INVALID_PARAM; - - DEBUG(8,("_reg_enum_value: enumerating values for key [%s]\n", regkey->name)); + + DEBUG(8,("_winreg_EnumValue: enumerating values for key [%s]\n", regkey->name)); if ( !fetch_reg_values_specific( regkey, &val, enum_index ) ) { status = WERR_NO_MORE_ITEMS; goto done; } - DEBUG(10,("_reg_enum_value: retrieved value named [%s]\n", val->valuename)); + DEBUG(10,("_winreg_EnumValue: retrieved value named [%s]\n", val->valuename)); /* subkey has the string name now */ @@ -613,15 +614,18 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, uint32_t status = WERR_NOMEM; } - *size = regval_size( val ); - *length = regval_size( val ); + *value_length = regval_size( val ); + *type = val->type; - if ( (value = talloc_memdup( p->mem_ctx, regval_data_p(val), *size )) == NULL ) { - status = WERR_NOMEM; + if ( *data_size == 0 ) { + status = WERR_OK; + } else if ( *value_length > *data_size ) { + status = WERR_MORE_DATA; + } else { + memcpy( data, regval_data_p(val), *value_length ); + status = WERR_OK; } - *type = val->type; - done: free_registry_value( val ); -- cgit From 855d12e56759c39dc80624fcd1096ee4f1f55d81 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 26 Sep 2006 22:03:52 +0000 Subject: r18932: In RegEnumvalue() and RegQueryValue(), the output buffer size must match the real value of the data. (This used to be commit e11108024a049f6a62d6c170296ee9877200a0c0) --- source3/rpc_server/srv_winreg_nt.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 7adc29ec0a..a90e9e2c77 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -479,6 +479,8 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct memcpy( data, regval_data_p(val), *value_length ); status = WERR_OK; } + + *data_size = *value_length; } TALLOC_FREE( regvals ); @@ -626,6 +628,8 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, uint32_t status = WERR_OK; } + *data_size = *value_length; + done: free_registry_value( val ); -- cgit From c67b5558741ca1e425ed5f51589db3c9ecbf782d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 26 Sep 2006 22:39:40 +0000 Subject: r18934: fix a segv in CreateKey() (This used to be commit 92f22f67ede2ae8c23ee86021a5709d2e27d1dec) --- source3/rpc_server/srv_winreg_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index a90e9e2c77..cb2c795679 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -1231,7 +1231,9 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, struct /* FIXME: report the truth here */ - *action_taken = REG_CREATED_NEW_KEY; + if ( action_taken ) { + *action_taken = REG_CREATED_NEW_KEY; + } done: /* close any intermediate key handles */ -- cgit From d89a951517744c523d26af5e0e71d70fcc9f643b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 27 Sep 2006 03:43:42 +0000 Subject: r18940: Fix a few memory corruption bugs to make CreateKey() and DeleteKey() work (This used to be commit e7e3e35c1def29430dc69d3311d5779575659ec5) --- source3/rpc_server/srv_winreg_nt.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index cb2c795679..03320b38f6 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -1189,7 +1189,9 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, struct /* copy the new key name (just the lower most keyname) */ - pstrcpy( name, ptr+1 ); + if ( (name = talloc_strdup( p->mem_ctx, ptr+1 )) == NULL ) { + return WERR_NOMEM; + } } else { /* use the existing open key information */ @@ -1334,11 +1336,15 @@ WERROR _winreg_DeleteKey(pipes_struct *p, struct policy_handle *handle, struct w pstrcpy( newkeyname, name ); ptr = strrchr( newkeyname, '\\' ); *ptr = '\0'; - pstrcpy( name, ptr+1 ); + if ( (name = talloc_strdup( p->mem_ctx, ptr+1 )) == NULL ) { + result = WERR_NOMEM; + goto done; + } result = open_registry_key( p, &newparent_handle, &newparentinfo, parent, newkeyname, (REG_KEY_READ|REG_KEY_WRITE) ); - if ( !W_ERROR_IS_OK(result) ) - return result; + if ( !W_ERROR_IS_OK(result) ) { + goto done; + } } else { /* use the existing open key information */ -- cgit From 2279881bd47e7869b3e488f85d3317dbaddbf0dd Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 27 Sep 2006 13:24:57 +0000 Subject: r18954: Fix segv in QueryValue and Enumvalue. regedit.exe now is happy again when creating keys and values (This used to be commit 6e9e9f8facbdd694041709e1fc6a8f824ac8c119) --- source3/rpc_server/srv_winreg_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 03320b38f6..c5e4230706 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -471,7 +471,7 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct *value_length = regval_size( val ); *type = val->type; - if ( *data_size == 0 ) { + if ( *data_size == 0 || !data ) { status = WERR_OK; } else if ( *value_length > *data_size ) { status = WERR_MORE_DATA; @@ -619,7 +619,7 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, uint32_t *value_length = regval_size( val ); *type = val->type; - if ( *data_size == 0 ) { + if ( *data_size == 0 || !data ) { status = WERR_OK; } else if ( *value_length > *data_size ) { status = WERR_MORE_DATA; -- cgit From b3ec4697ef153aec4ac2fc95ee4781b757a7a9ac Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 27 Sep 2006 16:05:25 +0000 Subject: r18962: * Add IDL for SaveKey() and RestoreKey() and regenerated * Tested RegSaveKey() using win32 app. Apparently this code has been brokne for a really long time. (This used to be commit 5381dcbde34206462562bdfc7639f488820a5a64) --- source3/rpc_server/srv_winreg_nt.c | 76 +++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 42 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index c5e4230706..92ea0b3d85 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -1,9 +1,8 @@ /* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997. - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Gerald Carter 2002-2005. + * + * Copyright (C) Gerald Carter 2002-2006. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,10 +27,8 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -#if 0 /* temporaily disabled */ static struct generic_mapping reg_generic_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; -#endif /****************************************************************** free() function for REGISTRY_KEY @@ -761,9 +758,6 @@ WERROR _winreg_AbortSystemShutdown(pipes_struct *p, uint16_t *server) return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; } -#if 0 /* This code works but is disabled for now until I - fix the WinReg IDL file -- jerry */ - /******************************************************************* ********************************************************************/ @@ -914,26 +908,26 @@ static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) return result; } -#endif - /******************************************************************* ********************************************************************/ -WERROR _winreg_RestoreKey(pipes_struct *p) +WERROR _winreg_RestoreKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String *filename, uint32_t flags) { -#if 0 /* temporarily disabled */ - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - pstring filename; + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + pstring fname; int snum; if ( !regkey ) return WERR_BADFID; - rpcstr_pull(filename, q_u->filename.string->buffer, sizeof(filename), q_u->filename.string->uni_str_len*2, STR_TERMINATE); + if ( !filename || !filename->name ) + return WERR_INVALID_PARAM; + + pstrcpy( fname, filename->name ); - DEBUG(8,("_reg_restore_key: verifying restore of key [%s] from \"%s\"\n", regkey->name, filename)); + DEBUG(8,("_winreg_RestoreKey: verifying restore of key [%s] from \"%s\"\n", regkey->name, fname)); - if ( (snum = validate_reg_filename( filename )) == -1 ) + if ( (snum = validate_reg_filename( fname )) == -1 ) return WERR_OBJECT_PATH_INVALID; /* user must posses SeRestorePrivilege for this this proceed */ @@ -941,17 +935,13 @@ WERROR _winreg_RestoreKey(pipes_struct *p) if ( !user_has_privileges( p->pipe_user.nt_user_token, &se_restore ) ) return WERR_ACCESS_DENIED; - DEBUG(2,("_reg_restore_key: Restoring [%s] from %s in share %s\n", regkey->name, filename, lp_servicename(snum) )); + DEBUG(2,("_winreg_RestoreKey: Restoring [%s] from %s in share %s\n", regkey->name, fname, lp_servicename(snum) )); - return restore_registry_key( regkey, filename ); -#endif + return restore_registry_key( regkey, fname ); return WERR_NOT_SUPPORTED; } -#if 0 /* this code works but has been disable until I fix - the winreg IDL -- jerry */ - /******************************************************************** ********************************************************************/ @@ -987,14 +977,16 @@ static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, /* we need a REGISTRY_KEY object here to enumerate subkeys and values */ ZERO_STRUCT( registry_key ); - pstrcpy( registry_key.name, keypath ); - if ( !(registry_key.hook = reghook_cache_find( registry_key.name )) ) + + if ( (registry_key.name = talloc_strdup(regfile->mem_ctx, keypath)) == NULL ) + return WERR_NOMEM; + + if ( (registry_key.hook = reghook_cache_find( registry_key.name )) == NULL ) return WERR_BADFILE; - /* lookup the values and subkeys */ - if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) + if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) return WERR_NOMEM; if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) @@ -1025,6 +1017,7 @@ static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, done: TALLOC_FREE( subkeys ); + TALLOC_FREE( registry_key.name ); return result; } @@ -1101,35 +1094,32 @@ static WERROR backup_registry_key ( REGISTRY_KEY *krecord, const char *fname ) return result; } -#endif /******************************************************************* ********************************************************************/ -WERROR _winreg_SaveKey(pipes_struct *p) +WERROR _winreg_SaveKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String *filename, struct KeySecurityAttribute *sec_attrib) { -#if 0 - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol ); - pstring filename; + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + pstring fname; int snum; if ( !regkey ) return WERR_BADFID; - rpcstr_pull(filename, q_u->filename.string->buffer, sizeof(filename), q_u->filename.string->uni_str_len*2, STR_TERMINATE); + if ( !filename || !filename->name ) + return WERR_INVALID_PARAM; - DEBUG(8,("_reg_save_key: verifying backup of key [%s] to \"%s\"\n", regkey->name, filename)); + pstrcpy( fname, filename->name ); + + DEBUG(8,("_winreg_SaveKey: verifying backup of key [%s] to \"%s\"\n", regkey->name, fname)); - if ( (snum = validate_reg_filename( filename )) == -1 ) + if ( (snum = validate_reg_filename( fname )) == -1 ) return WERR_OBJECT_PATH_INVALID; - DEBUG(2,("_reg_save_key: Saving [%s] to %s in share %s\n", regkey->name, filename, lp_servicename(snum) )); + DEBUG(2,("_winreg_SaveKey: Saving [%s] to %s in share %s\n", regkey->name, fname, lp_servicename(snum) )); - return backup_registry_key( regkey, filename ); -#endif - - /* disabled for now until I fix the IDL --jerry */ - return WERR_NOT_SUPPORTED; + return backup_registry_key( regkey, fname ); } /******************************************************************* @@ -1137,7 +1127,9 @@ WERROR _winreg_SaveKey(pipes_struct *p) WERROR _winreg_SaveKeyEx(pipes_struct *p) { - /* disabled for now until I fix the IDL --jerry */ + /* fill in your code here if you think this call should + do anything */ + return WERR_NOT_SUPPORTED; } -- cgit From 7ced2e983d29d769a9ad1055f244ecd1e3d08918 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 2 Oct 2006 08:38:54 +0000 Subject: r19028: Implement getprinterinfo level 6 (only the status) and get rid of snum in the getprinter calls. Survives the RPC-SAMBA3-SPOOLSS test which I will activate when the Samba4 build farm has picked it up. Volker (This used to be commit d7248b6cfa4d6e639d92afdd092136d900d90e19) --- source3/rpc_server/srv_spoolss_nt.c | 294 ++++++++++++++++++++++++++---------- 1 file changed, 214 insertions(+), 80 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cd69fdf107..8d9ba7cb90 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -373,7 +373,8 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) Return the snum of a printer corresponding to an handle. ****************************************************************************/ -static BOOL get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number) +static BOOL get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number, + struct share_params **params) { Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); @@ -386,6 +387,13 @@ static BOOL get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number) case SPLHND_PRINTER: DEBUG(4,("short name:%s\n", Printer->sharename)); *number = print_queue_snum(Printer->sharename); + if ((*number != -1) && (params != NULL)) { + *params = get_share_params(tmp_talloc_ctx(), + Printer->sharename); + if (*params == NULL) { + return False; + } + } return (*number != -1); case SPLHND_SERVER: return False; @@ -1626,7 +1634,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* NT doesn't let us connect to a printer if the connecting user doesn't have print permission. */ - if (!get_printer_snum(p, handle, &snum)) { + if (!get_printer_snum(p, handle, &snum, NULL)) { close_printer_handle(p, handle); return WERR_BADFID; } @@ -1853,7 +1861,7 @@ static WERROR _spoolss_enddocprinter_internal(pipes_struct *p, POLICY_HND *handl return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; Printer->document_started=False; @@ -2445,7 +2453,7 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO status = getprinterdata_printer_server( p->mem_ctx, value, type, data, needed, *out_size ); else { - if ( !get_printer_snum(p,handle, &snum) ) { + if ( !get_printer_snum(p,handle, &snum, NULL) ) { status = WERR_BADFID; goto done; } @@ -2663,7 +2671,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE if ( Printer->printer_type == SPLHND_SERVER) snum = -1; else if ( (Printer->printer_type == SPLHND_PRINTER) && - !get_printer_snum(p, handle, &snum) ) + !get_printer_snum(p, handle, &snum, NULL) ) return WERR_BADFID; client_ip.s_addr = inet_addr(p->conn->client_address); @@ -3751,7 +3759,7 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY if ( !option ) return WERR_BADFID; - get_printer_snum(p, hnd, &snum); + get_printer_snum(p, hnd, &snum, NULL); for (i=0; icount; i++) { option_type=&option->ctr.type[i]; @@ -3869,7 +3877,9 @@ done: * fill a printer_info_0 struct ********************************************************************/ -static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *printer, int snum) +static BOOL construct_printer_info_0(Printer_entry *print_hnd, + PRINTER_INFO_0 *printer, + const struct share_params *params) { pstring chaine; int count; @@ -3880,14 +3890,15 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p time_t setuptime; print_status_struct status; - if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, + lp_const_servicename(params->service)))) return False; - count = print_queue_length(snum, &status); + count = print_queue_length(params->service, &status); /* check if we already have a counter for this printer */ for(session_counter = counter_list; session_counter; session_counter = session_counter->next) { - if (session_counter->snum == snum) + if (session_counter->snum == params->service) break; } @@ -3898,7 +3909,7 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p return False; } ZERO_STRUCTP(session_counter); - session_counter->snum=snum; + session_counter->snum=params->service; session_counter->counter=0; DLIST_ADD(counter_list, session_counter); } @@ -3974,21 +3985,25 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p * construct_printer_info_1 * fill a printer_info_1 struct ********************************************************************/ -static BOOL construct_printer_info_1(Printer_entry *print_hnd, uint32 flags, PRINTER_INFO_1 *printer, int snum) +static BOOL construct_printer_info_1(Printer_entry *print_hnd, uint32 flags, + PRINTER_INFO_1 *printer, + const struct share_params *params) { pstring chaine; pstring chaine2; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; - if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, + lp_const_servicename(params->service)))) return False; printer->flags=flags; if (*ntprinter->info_2->comment == '\0') { - init_unistr(&printer->comment, lp_comment(snum)); + init_unistr(&printer->comment, lp_comment(params->service)); slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s", ntprinter->info_2->printername, - ntprinter->info_2->drivername, lp_comment(snum)); + ntprinter->info_2->drivername, + lp_comment(params->service)); } else { init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ @@ -4112,26 +4127,29 @@ done: * fill a printer_info_2 struct ********************************************************************/ -static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *printer, int snum) +static BOOL construct_printer_info_2(Printer_entry *print_hnd, + PRINTER_INFO_2 *printer, + const struct share_params *params) { int count; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; print_status_struct status; - if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, + lp_const_servicename(params->service)))) return False; - count = print_queue_length(snum, &status); + count = print_queue_length(params->service, &status); init_unistr(&printer->servername, ntprinter->info_2->servername); /* servername*/ init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/ - init_unistr(&printer->sharename, lp_servicename(snum)); /* sharename */ + init_unistr(&printer->sharename, lp_servicename(params->service)); /* sharename */ init_unistr(&printer->portname, ntprinter->info_2->portname); /* port */ init_unistr(&printer->drivername, ntprinter->info_2->drivername); /* drivername */ if (*ntprinter->info_2->comment == '\0') - init_unistr(&printer->comment, lp_comment(snum)); /* comment */ + init_unistr(&printer->comment, lp_comment(params->service)); /* comment */ else init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ @@ -4151,7 +4169,8 @@ static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *p printer->cjobs = count; /* jobs */ printer->averageppm = ntprinter->info_2->averageppm; /* average pages per minute */ - if ( !(printer->devmode = construct_dev_mode(lp_const_servicename(snum))) ) + if ( !(printer->devmode = construct_dev_mode( + lp_const_servicename(params->service))) ) DEBUG(8, ("Returning NULL Devicemode!\n")); printer->secdesc = NULL; @@ -4176,12 +4195,15 @@ static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *p * fill a printer_info_3 struct ********************************************************************/ -static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 **pp_printer, int snum) +static BOOL construct_printer_info_3(Printer_entry *print_hnd, + PRINTER_INFO_3 **pp_printer, + const struct share_params *params) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; PRINTER_INFO_3 *printer = NULL; - if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, + lp_const_servicename(params->service)))) return False; *pp_printer = NULL; @@ -4216,11 +4238,14 @@ static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 ** * fill a printer_info_4 struct ********************************************************************/ -static BOOL construct_printer_info_4(Printer_entry *print_hnd, PRINTER_INFO_4 *printer, int snum) +static BOOL construct_printer_info_4(Printer_entry *print_hnd, + PRINTER_INFO_4 *printer, + const struct share_params *params) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; - if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, + lp_const_servicename(params->service)))) return False; init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/ @@ -4236,11 +4261,14 @@ static BOOL construct_printer_info_4(Printer_entry *print_hnd, PRINTER_INFO_4 *p * fill a printer_info_5 struct ********************************************************************/ -static BOOL construct_printer_info_5(Printer_entry *print_hnd, PRINTER_INFO_5 *printer, int snum) +static BOOL construct_printer_info_5(Printer_entry *print_hnd, + PRINTER_INFO_5 *printer, + const struct share_params *params) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; - if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, + lp_const_servicename(params->service)))) return False; init_unistr(&printer->printername, ntprinter->info_2->printername); @@ -4257,17 +4285,45 @@ static BOOL construct_printer_info_5(Printer_entry *print_hnd, PRINTER_INFO_5 *p return True; } +/******************************************************************** + * construct_printer_info_6 + * fill a printer_info_6 struct + ********************************************************************/ + +static BOOL construct_printer_info_6(Printer_entry *print_hnd, + PRINTER_INFO_6 *printer, + const struct share_params *params) +{ + NT_PRINTER_INFO_LEVEL *ntprinter = NULL; + int count; + print_status_struct status; + + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, + lp_const_servicename(params->service)))) + return False; + + count = print_queue_length(params->service, &status); + + printer->status = nt_printq_status(status.status); + + free_a_printer(&ntprinter, 2); + + return True; +} + /******************************************************************** * construct_printer_info_7 * fill a printer_info_7 struct ********************************************************************/ -static BOOL construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *printer, int snum) +static BOOL construct_printer_info_7(Printer_entry *print_hnd, + PRINTER_INFO_7 *printer, + const struct share_params *params) { char *guid_str = NULL; struct GUID guid; - if (is_printer_published(print_hnd, snum, &guid)) { + if (is_printer_published(print_hnd, params->service, &guid)) { asprintf(&guid_str, "{%s}", smb_uuid_string_static(guid)); strupper_m(guid_str); init_unistr(&printer->guid, guid_str); @@ -4297,9 +4353,12 @@ static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32 for (snum=0; snum offered) { + result = WERR_INSUFFICIENT_BUFFER; + goto out; + } + + if (!rpcbuf_alloc_size(buffer, *needed)) { + result = WERR_NOMEM; + goto out; + } + + /* fill the buffer with the structures */ + smb_io_printer_info_6("", buffer, printer, 0); + +out: + /* clear memory */ + free_printer_info_6(printer); + + return result; +} + +static WERROR getprinter_level_7(Printer_entry *print_hnd, + const struct share_params *params, + RPC_BUFFER *buffer, uint32 offered, + uint32 *needed) { PRINTER_INFO_7 *printer=NULL; WERROR result = WERR_OK; @@ -4893,7 +5016,7 @@ static WERROR getprinter_level_7(Printer_entry *print_hnd, int snum, RPC_BUFFER if((printer=SMB_MALLOC_P(PRINTER_INFO_7))==NULL) return WERR_NOMEM; - if (!construct_printer_info_7(print_hnd, printer, snum)) + if (!construct_printer_info_7(print_hnd, printer, params)) return WERR_NOMEM; /* check the required size. */ @@ -4931,6 +5054,7 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); + struct share_params *params; int snum; @@ -4945,24 +5069,34 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET *needed=0; - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum, ¶ms)) return WERR_BADFID; switch (level) { case 0: - return getprinter_level_0(Printer, snum, buffer, offered, needed); + return getprinter_level_0(Printer, params, buffer, offered, + needed); case 1: - return getprinter_level_1(Printer, snum, buffer, offered, needed); + return getprinter_level_1(Printer, params, buffer, offered, + needed); case 2: - return getprinter_level_2(Printer, snum, buffer, offered, needed); + return getprinter_level_2(Printer, params, buffer, offered, + needed); case 3: - return getprinter_level_3(Printer, snum, buffer, offered, needed); + return getprinter_level_3(Printer, params, buffer, offered, + needed); case 4: - return getprinter_level_4(Printer, snum, buffer, offered, needed); + return getprinter_level_4(Printer, params, buffer, offered, + needed); case 5: - return getprinter_level_5(Printer, snum, buffer, offered, needed); + return getprinter_level_5(Printer, params, buffer, offered, + needed); + case 6: + return getprinter_level_6(Printer, params, buffer, offered, + needed); case 7: - return getprinter_level_7(Printer, snum, buffer, offered, needed); + return getprinter_level_7(Printer, params, buffer, offered, + needed); } return WERR_UNKNOWN_LEVEL; } @@ -5559,7 +5693,7 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ fstrcpy(servername, get_server_name( printer )); unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; switch (level) { @@ -5615,7 +5749,7 @@ WERROR _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPO return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; Printer->page_started=False; @@ -5664,7 +5798,7 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S } /* get the share number of the printer */ - if (!get_printer_snum(p, handle, &snum)) { + if (!get_printer_snum(p, handle, &snum, NULL)) { return WERR_BADFID; } @@ -5716,7 +5850,7 @@ WERROR _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; (*buffer_written) = (uint32)print_job_write(snum, Printer->jobid, (const char *)buffer, @@ -5752,7 +5886,7 @@ static WERROR control_printer(POLICY_HND *handle, uint32 command, return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; switch (command) { @@ -5797,7 +5931,7 @@ WERROR _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; print_job_delete( &p->pipe_user, snum, Printer->jobid, &errcode ); @@ -5820,7 +5954,7 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - if (!Printer || !get_printer_snum(p, handle, &snum)) { + if (!Printer || !get_printer_snum(p, handle, &snum, NULL)) { DEBUG(2,("update_printer_sec: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle))); @@ -6095,7 +6229,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, goto done; } - if (!get_printer_snum(p, handle, &snum)) { + if (!get_printer_snum(p, handle, &snum, NULL)) { result = WERR_BADFID; goto done; } @@ -6286,7 +6420,7 @@ static WERROR publish_or_unpublish_printer(pipes_struct *p, POLICY_HND *handle, if (!Printer) return WERR_BADFID; - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; nt_printer_publish(Printer, snum, info7->action); @@ -6356,7 +6490,7 @@ WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) if ( Printer->printer_type == SPLHND_SERVER) snum = -1; else if ( (Printer->printer_type == SPLHND_PRINTER) && - !get_printer_snum(p, handle, &snum) ) + !get_printer_snum(p, handle, &snum, NULL) ) return WERR_BADFID; srv_spoolss_replycloseprinter(snum, &Printer->notify.client_hnd); @@ -6603,7 +6737,7 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO /* lookup the printer snum and tdb entry */ - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; wret = get_a_printer(NULL, &ntprinter, 2, lp_servicename(snum)); @@ -6657,7 +6791,7 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u int snum; WERROR errcode = WERR_BADFUNC; - if (!get_printer_snum(p, handle, &snum)) { + if (!get_printer_snum(p, handle, &snum, NULL)) { return WERR_BADFID; } @@ -7883,7 +8017,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S return WERR_BADFID; } - if (!get_printer_snum(p,handle, &snum)) + if (!get_printer_snum(p,handle, &snum, NULL)) return WERR_BADFID; result = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); @@ -8048,7 +8182,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP return WERR_INVALID_PARAM; } - if (!get_printer_snum(p,handle, &snum)) + if (!get_printer_snum(p,handle, &snum, NULL)) return WERR_BADFID; /* @@ -8120,7 +8254,7 @@ WERROR _spoolss_resetprinter(pipes_struct *p, SPOOL_Q_RESETPRINTER *q_u, SPOOL_R return WERR_BADFID; } - if (!get_printer_snum(p,handle, &snum)) + if (!get_printer_snum(p,handle, &snum, NULL)) return WERR_BADFID; @@ -8150,7 +8284,7 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { @@ -8202,7 +8336,7 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM if ( Printer->printer_type == SPLHND_PRINTER ) { - if (!get_printer_snum(p,handle, &snum)) + if (!get_printer_snum(p,handle, &snum, NULL)) return WERR_BADFID; status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); @@ -8273,7 +8407,7 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE if ( Printer->printer_type == SPLHND_PRINTER ) { - if (!get_printer_snum(p,handle, &snum)) + if (!get_printer_snum(p,handle, &snum, NULL)) return WERR_BADFID; status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); @@ -8341,7 +8475,7 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * if ( Printer->printer_type == SPLHND_PRINTER ) { - if (!get_printer_snum(p,handle, &snum)) + if (!get_printer_snum(p,handle, &snum, NULL)) return WERR_BADFID; status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); @@ -8827,7 +8961,7 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ *needed = 0; - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; wstatus = get_a_printer(NULL, &ntprinter, 2, lp_servicename(snum)); @@ -8910,7 +9044,7 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, goto done; } - if ( !get_printer_snum(p,handle, &snum) ) + if ( !get_printer_snum(p,handle, &snum, NULL) ) return WERR_BADFID; status = get_a_printer(Printer, &printer, 2, lp_servicename(snum)); @@ -8996,7 +9130,7 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, return WERR_INVALID_PARAM; } - if ( !get_printer_snum(p,handle, &snum) ) + if ( !get_printer_snum(p,handle, &snum, NULL) ) return WERR_BADFID; /* @@ -9083,7 +9217,7 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { @@ -9135,7 +9269,7 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO return WERR_BADFID; } - if ( !get_printer_snum(p,handle, &snum) ) + if ( !get_printer_snum(p,handle, &snum, NULL) ) return WERR_BADFID; status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); @@ -9205,7 +9339,7 @@ WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, if ( !q_u->keyname.buffer ) return WERR_INVALID_PARAM; - if (!get_printer_snum(p, handle, &snum)) + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { @@ -9278,7 +9412,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ /* get the printer off of disk */ - if (!get_printer_snum(p,handle, &snum)) + if (!get_printer_snum(p,handle, &snum, NULL)) return WERR_BADFID; ZERO_STRUCT(printer); -- cgit From dc1f0804dd8177d3c3a0b2db993855d5679e9565 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Tue, 3 Oct 2006 17:14:18 +0000 Subject: r19058: Implement "user cannot change password", and complete "user must change password at next logon" code. The "password last set time" of zero now means "user must change password", because that's how windows seems to use it. The "can change" and "must change" times are now calculated based on the "last set" time and policies. We use the "can change" field now to indicate that a user cannot change a password by putting MAX_TIME_T in it (so long as "last set" time isn't zero). Based on this, we set the password-can-change bit in the faked secdesc. (This used to be commit 21abbeaee9b7f7cff1d34d048463c30cda44a2e3) --- source3/rpc_server/srv_netlog_nt.c | 2 +- source3/rpc_server/srv_samr_nt.c | 118 +++++++++++++++++++++++++++++++++---- 2 files changed, 107 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 6603d2f1d4..b8c776964e 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -623,7 +623,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * return NT_STATUS_NO_MEMORY; } - if (!pdb_set_pass_changed_now(sampass)) { + if (!pdb_set_pass_last_set_time(sampass, time(NULL), PDB_CHANGED)) { TALLOC_FREE(sampass); /* Not quite sure what this one qualifies as, but this will do */ return NT_STATUS_UNSUCCESSFUL; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 822a6a2ab7..5c0f50699e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -40,6 +40,8 @@ ( READ_CONTROL_ACCESS | \ SA_RIGHT_USER_CHANGE_PASSWORD | \ SA_RIGHT_USER_SET_LOC_COM ) +#define SAMR_USR_RIGHTS_CANT_WRITE_PW \ + ( READ_CONTROL_ACCESS | SA_RIGHT_USER_SET_LOC_COM ) #define DISP_INFO_CACHE_TIMEOUT 10 @@ -90,6 +92,11 @@ static struct generic_mapping usr_generic_mapping = { GENERIC_RIGHTS_USER_WRITE, GENERIC_RIGHTS_USER_EXECUTE, GENERIC_RIGHTS_USER_ALL_ACCESS}; +static struct generic_mapping usr_nopwchange_generic_mapping = { + GENERIC_RIGHTS_USER_READ, + GENERIC_RIGHTS_USER_WRITE, + GENERIC_RIGHTS_USER_EXECUTE & ~SA_RIGHT_USER_CHANGE_PASSWORD, + GENERIC_RIGHTS_USER_ALL_ACCESS}; static struct generic_mapping grp_generic_mapping = { GENERIC_RIGHTS_GROUP_READ, GENERIC_RIGHTS_GROUP_WRITE, @@ -656,16 +663,6 @@ NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, return r_u->status; } -/******************************************************************* - _samr_set_sec_obj - ********************************************************************/ - -NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_SEC_OBJ *r_u) -{ - DEBUG(0,("_samr_set_sec_obj: Not yet implemented!\n")); - return NT_STATUS_NOT_IMPLEMENTED; -} - /******************************************************************* ********************************************************************/ @@ -691,6 +688,97 @@ static BOOL get_lsa_policy_samr_sid( pipes_struct *p, POLICY_HND *pol, return True; } +/******************************************************************* + _samr_set_sec_obj + ********************************************************************/ + +NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_SEC_OBJ *r_u) +{ + DOM_SID pol_sid; + uint32 acc_granted, i; + SEC_ACL *dacl; + BOOL ret; + struct samu *sampass=NULL; + NTSTATUS status; + + r_u->status = NT_STATUS_OK; + + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid, &acc_granted, NULL)) + return NT_STATUS_INVALID_HANDLE; + + if (!(sampass = samu_new( p->mem_ctx))) { + DEBUG(0,("No memory!\n")); + return NT_STATUS_NO_MEMORY; + } + + /* get the user record */ + become_root(); + ret = pdb_getsampwsid(sampass, &pol_sid); + unbecome_root(); + + if (!ret) { + DEBUG(4, ("User %s not found\n", sid_string_static(&pol_sid))); + TALLOC_FREE(sampass); + return NT_STATUS_INVALID_HANDLE; + } + + dacl = q_u->buf->sd->dacl; + for (i=0; i < dacl->num_aces; i++) { + if (sid_equal(&pol_sid, &dacl->aces[i].trustee)) { + ret = pdb_set_pass_can_change(sampass, + (dacl->aces[i].access_mask & + SA_RIGHT_USER_CHANGE_PASSWORD) ? + True: False); + break; + } + } + + if (!ret) { + TALLOC_FREE(sampass); + return NT_STATUS_ACCESS_DENIED; + } + + status = pdb_update_sam_account(sampass); + + TALLOC_FREE(sampass); + + return status; +} + +/******************************************************************* + build correct perms based on policies and password times for _samr_query_sec_obj +*******************************************************************/ +static BOOL check_change_pw_access(TALLOC_CTX *mem_ctx, DOM_SID *user_sid) +{ + struct samu *sampass=NULL; + BOOL ret; + + if ( !(sampass = samu_new( mem_ctx )) ) { + DEBUG(0,("No memory!\n")); + return False; + } + + become_root(); + ret = pdb_getsampwsid(sampass, user_sid); + unbecome_root(); + + if (ret == False) { + DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); + TALLOC_FREE(sampass); + return False; + } + + DEBUG(3,("User:[%s]\n", pdb_get_username(sampass) )); + + if (pdb_get_pass_can_change(sampass)) { + TALLOC_FREE(sampass); + return True; + } + TALLOC_FREE(sampass); + return False; +} + + /******************************************************************* _samr_query_sec_obj ********************************************************************/ @@ -731,7 +819,13 @@ NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_ /* TODO: different SDs have to be generated for aliases groups and users. Currently all three get a default user SD */ DEBUG(10,("_samr_query_sec_obj: querying security on Object with SID: %s\n", sid_to_string(str_sid, &pol_sid))); - r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, &pol_sid, SAMR_USR_RIGHTS_WRITE_PW); + if (check_change_pw_access(p->mem_ctx, &pol_sid)) { + r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, + &pol_sid, SAMR_USR_RIGHTS_WRITE_PW); + } else { + r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_nopwchange_generic_mapping, + &pol_sid, SAMR_USR_RIGHTS_CANT_WRITE_PW); + } } else { return NT_STATUS_OBJECT_TYPE_MISMATCH; } @@ -3056,7 +3150,7 @@ static BOOL set_user_info_18(SAM_USER_INFO_18 *id18, struct samu *pwd) TALLOC_FREE(pwd); return False; } - if (!pdb_set_pass_changed_now (pwd)) { + if (!pdb_set_pass_last_set_time (pwd, time(NULL), PDB_CHANGED)) { TALLOC_FREE(pwd); return False; } -- cgit From e918cf3abfa14d85cc21bb66d00b9e7cbb0d0626 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 6 Oct 2006 19:07:23 +0000 Subject: r19154: Trivial logic simplification: Get rid of two indentation levels. Survives the consistency checks just checked into Samba4. Volker (This used to be commit c48bb4b37b32fac9d01d243290532641d3701ec7) --- source3/rpc_server/srv_spoolss_nt.c | 83 +++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8d9ba7cb90..32cd5766af 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4346,30 +4346,41 @@ static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32 int i; int n_services=lp_numservices(); PRINTER_INFO_1 *printers=NULL; - PRINTER_INFO_1 current_prt; WERROR result = WERR_OK; DEBUG(4,("enum_all_printers_info_1\n")); for (snum=0; snum Date: Fri, 6 Oct 2006 19:32:52 +0000 Subject: r19156: Make enumprinters use the share iterators. Volker (This used to be commit 9b1759617ce7841a78d9f792254a9e4fa814858f) --- source3/rpc_server/srv_spoolss_nt.c | 54 ++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 32cd5766af..b6af6b0b80 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4342,29 +4342,27 @@ static BOOL construct_printer_info_7(Printer_entry *print_hnd, static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - int snum; int i; - int n_services=lp_numservices(); + struct share_iterator *shares; + struct share_params *printer; PRINTER_INFO_1 *printers=NULL; WERROR result = WERR_OK; DEBUG(4,("enum_all_printers_info_1\n")); - for (snum=0; snumservice))); if (!construct_printer_info_1(NULL, flags, ¤t_prt, - ¶ms)) { + printer)) { continue; } @@ -4373,6 +4371,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32 DEBUG(2,("enum_all_printers_info_1: failed to enlarge " "printers buffer!\n")); *returned=0; + TALLOC_FREE(shares); return WERR_NOMEM; } DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", @@ -4381,6 +4380,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32 memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_1)); (*returned)++; + TALLOC_FREE(printer); } /* check the required size. */ @@ -4405,6 +4405,7 @@ out: /* clear memory */ SAFE_FREE(printers); + TALLOC_FREE(shares); if ( !W_ERROR_IS_OK(result) ) *returned = 0; @@ -4542,27 +4543,27 @@ static WERROR enum_all_printers_info_1_network(fstring name, RPC_BUFFER *buffer, static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - int snum; int i; - int n_services=lp_numservices(); + struct share_iterator *shares; + struct share_params *printer; PRINTER_INFO_2 *printers=NULL; WERROR result = WERR_OK; *returned = 0; - for (snum=0; snumservice))); if (!construct_printer_info_2(NULL, ¤t_prt, - ¶ms)) { + printer)) { continue; } if ( !(printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_2, @@ -4570,6 +4571,7 @@ static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint3 DEBUG(2,("enum_all_printers_info_2: failed to enlarge " "printers buffer!\n")); *returned = 0; + TALLOC_FREE(shares); return WERR_NOMEM; } @@ -4579,6 +4581,7 @@ static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint3 memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_2)); (*returned)++; + TALLOC_FREE(printer); } /* check the required size. */ @@ -4606,6 +4609,7 @@ out: free_devmode(printers[i].devmode); SAFE_FREE(printers); + TALLOC_FREE(shares); if ( !W_ERROR_IS_OK(result) ) *returned = 0; -- cgit From b71a0be998c0171a01c632f3e14e9764c2dda6c2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 10 Oct 2006 07:53:41 +0000 Subject: r19220: Check if a backend has set rng_fault_state and send a dce-level fault pdu. Volker (This used to be commit 21c08e7ef460ae7eaf1f441e8aadcfe0502fa1ad) --- source3/rpc_server/srv_pipe.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index b60ee37f40..50ef195015 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2310,6 +2310,13 @@ BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, return True; } + if (p->rng_fault_state) { + DEBUG(4, ("api_rpcTNP: rng fault return\n")); + p->rng_fault_state = False; + setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR)); + return True; + } + slprintf(name, sizeof(name)-1, "out_%s", rpc_name); offset2 = prs_offset(&p->out_data.rdata); prs_set_offset(&p->out_data.rdata, offset1); -- cgit From 4980baf2e1f1de2715b1c0243ea7e79668d87501 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 10 Oct 2006 08:39:11 +0000 Subject: r19224: Add setting the rng_fault_state to the already converted pipes. Convert the low-hanging fruit of the LSA server. This provides a sample how the server calls can be converted one by one, see the "proxy_lsa_call" function. Volker (This used to be commit 99e54a213ad3561ea6e8dc44c483847c18c5681e) --- source3/rpc_server/srv_dfs_nt.c | 18 ++ source3/rpc_server/srv_lsa.c | 159 ++---------- source3/rpc_server/srv_lsa_nt.c | 491 ++++++++++++++++++++++++++++++++++++- source3/rpc_server/srv_srvsvc_nt.c | 35 +++ source3/rpc_server/srv_winreg_nt.c | 9 +- source3/rpc_server/srv_wkssvc_nt.c | 30 +++ 6 files changed, 596 insertions(+), 146 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index f3b6d8af88..4857a839e1 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -334,108 +334,126 @@ WERROR _dfs_GetInfo(pipes_struct *p, const char *path, const char *server, const WERROR _dfs_SetInfo(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_Rename(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_Move(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_ManagerGetConfigInfo(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_ManagerSendSiteInfo(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_AddFtRoot(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_RemoveFtRoot(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_AddStdRoot(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_RemoveStdRoot(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_ManagerInitialize(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_AddStdRootForced(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_GetDcAddress(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_SetDcAddress(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_FlushFtTable(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_Add2(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_Remove2(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_EnumEx(pipes_struct *p, const char *name, uint32_t level, uint32_t bufsize, struct dfs_EnumStruct *info, uint32_t *total) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _dfs_SetInfo2(pipes_struct *p) { /* FIXME: Implement your code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 286266f30d..0269e75e4e 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -30,6 +30,23 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +static BOOL proxy_lsa_call(pipes_struct *p, uint8 opnum) +{ + struct api_struct *fns; + int n_fns; + + lsarpc_get_pipe_fns(&fns, &n_fns); + + if (opnum >= n_fns) + return False; + + if (fns[opnum].opnum != opnum) { + smb_panic("LSA function table not sorted\n"); + } + + return fns[opnum].fn(p); +} + /*************************************************************************** api_lsa_open_policy2 ***************************************************************************/ @@ -218,28 +235,7 @@ static BOOL api_lsa_lookup_names(pipes_struct *p) static BOOL api_lsa_close(pipes_struct *p) { - LSA_Q_CLOSE q_u; - LSA_R_CLOSE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!lsa_io_q_close("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_close: lsa_io_q_close failed.\n")); - return False; - } - - r_u.status = _lsa_close(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if (!lsa_io_r_close("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_close: lsa_io_r_close failed.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, DCERPC_LSA_CLOSE); } /*************************************************************************** @@ -248,28 +244,7 @@ static BOOL api_lsa_close(pipes_struct *p) static BOOL api_lsa_open_secret(pipes_struct *p) { - LSA_Q_OPEN_SECRET q_u; - LSA_R_OPEN_SECRET r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_open_secret("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_open_secret: failed to unmarshall LSA_Q_OPEN_SECRET.\n")); - return False; - } - - r_u.status = _lsa_open_secret(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_open_secret("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_open_secret: Failed to marshall LSA_R_OPEN_SECRET.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, DCERPC_LSA_OPENSECRET); } /*************************************************************************** @@ -771,29 +746,7 @@ static BOOL api_lsa_lookup_priv_value(pipes_struct *p) static BOOL api_lsa_open_trust_dom(pipes_struct *p) { - LSA_Q_OPEN_TRUSTED_DOMAIN q_u; - LSA_R_OPEN_TRUSTED_DOMAIN r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_open_trusted_domain("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_open_trust_dom: failed to unmarshall LSA_Q_OPEN_TRUSTED_DOMAIN .\n")); - return False; - } - - r_u.status = _lsa_open_trusted_domain(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_open_trusted_domain("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_open_trust_dom: Failed to marshall LSA_R_OPEN_TRUSTED_DOMAIN.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, DCERPC_LSA_OPENTRUSTEDDOMAIN); } /*************************************************************************** @@ -801,29 +754,7 @@ static BOOL api_lsa_open_trust_dom(pipes_struct *p) static BOOL api_lsa_create_trust_dom(pipes_struct *p) { - LSA_Q_CREATE_TRUSTED_DOMAIN q_u; - LSA_R_CREATE_TRUSTED_DOMAIN r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_create_trusted_domain("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_create_trust_dom: failed to unmarshall LSA_Q_CREATE_TRUSTED_DOMAIN .\n")); - return False; - } - - r_u.status = _lsa_create_trusted_domain(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_create_trusted_domain("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_create_trust_dom: Failed to marshall LSA_R_CREATE_TRUSTED_DOMAIN.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, DCERPC_LSA_CREATETRUSTEDDOMAIN); } /*************************************************************************** @@ -831,29 +762,7 @@ static BOOL api_lsa_create_trust_dom(pipes_struct *p) static BOOL api_lsa_create_secret(pipes_struct *p) { - LSA_Q_CREATE_SECRET q_u; - LSA_R_CREATE_SECRET r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_create_secret("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_create_secret: failed to unmarshall LSA_Q_CREATE_SECRET.\n")); - return False; - } - - r_u.status = _lsa_create_secret(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_create_secret("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_create_secret: Failed to marshall LSA_R_CREATE_SECRET.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, DCERPC_LSA_CREATESECRET); } /*************************************************************************** @@ -861,29 +770,7 @@ static BOOL api_lsa_create_secret(pipes_struct *p) static BOOL api_lsa_set_secret(pipes_struct *p) { - LSA_Q_SET_SECRET q_u; - LSA_R_SET_SECRET r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_set_secret("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_set_secret: failed to unmarshall LSA_Q_SET_SECRET.\n")); - return False; - } - - r_u.status = _lsa_set_secret(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_set_secret("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_set_secret: Failed to marshall LSA_R_SET_SECRET.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, DCERPC_LSA_SETSECRET); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 9e1e9a397a..1a92ec6740 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1297,20 +1297,22 @@ NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOO _lsa_close. Also weird - needs to check if lsa handle is correct. JRA. ***************************************************************************/ -NTSTATUS _lsa_close(pipes_struct *p, LSA_Q_CLOSE *q_u, LSA_R_CLOSE *r_u) +NTSTATUS _lsa_Close(pipes_struct *p, struct policy_handle *handle) { - if (!find_policy_by_hnd(p, &q_u->pol, NULL)) { + if (!find_policy_by_hnd(p, handle, NULL)) { return NT_STATUS_INVALID_HANDLE; } - close_policy_hnd(p, &q_u->pol); + close_policy_hnd(p, handle); return NT_STATUS_OK; } /*************************************************************************** ***************************************************************************/ -NTSTATUS _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SECRET *r_u) +NTSTATUS _lsa_OpenSecret(pipes_struct *p, struct policy_handle *handle, + struct lsa_String name, uint32_t access_mask, + struct policy_handle *sec_handle) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -1318,7 +1320,9 @@ NTSTATUS _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SE /*************************************************************************** ***************************************************************************/ -NTSTATUS _lsa_open_trusted_domain(pipes_struct *p, LSA_Q_OPEN_TRUSTED_DOMAIN *q_u, LSA_R_OPEN_TRUSTED_DOMAIN *r_u) +NTSTATUS _lsa_OpenTrustedDomain(pipes_struct *p, struct policy_handle *handle, + struct dom_sid2 *sid, uint32_t access_mask, + struct policy_handle *trustdom_handle) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -1326,7 +1330,11 @@ NTSTATUS _lsa_open_trusted_domain(pipes_struct *p, LSA_Q_OPEN_TRUSTED_DOMAIN *q_ /*************************************************************************** ***************************************************************************/ -NTSTATUS _lsa_create_trusted_domain(pipes_struct *p, LSA_Q_CREATE_TRUSTED_DOMAIN *q_u, LSA_R_CREATE_TRUSTED_DOMAIN *r_u) +NTSTATUS _lsa_CreateTrustedDomain(pipes_struct *p, + struct policy_handle *handle, + struct lsa_DomainInfo *info, + uint32_t access_mask, + struct policy_handle *trustdom_handle) { return NT_STATUS_ACCESS_DENIED; } @@ -1334,7 +1342,9 @@ NTSTATUS _lsa_create_trusted_domain(pipes_struct *p, LSA_Q_CREATE_TRUSTED_DOMAIN /*************************************************************************** ***************************************************************************/ -NTSTATUS _lsa_create_secret(pipes_struct *p, LSA_Q_CREATE_SECRET *q_u, LSA_R_CREATE_SECRET *r_u) +NTSTATUS _lsa_CreateSecret(pipes_struct *p, struct policy_handle *handle, + struct lsa_String name, uint32_t access_mask, + struct policy_handle *sec_handle) { return NT_STATUS_ACCESS_DENIED; } @@ -1342,7 +1352,9 @@ NTSTATUS _lsa_create_secret(pipes_struct *p, LSA_Q_CREATE_SECRET *q_u, LSA_R_CRE /*************************************************************************** ***************************************************************************/ -NTSTATUS _lsa_set_secret(pipes_struct *p, LSA_Q_SET_SECRET *q_u, LSA_R_SET_SECRET *r_u) +NTSTATUS _lsa_SetSecret(pipes_struct *p, struct policy_handle *sec_handle, + struct lsa_DATA_BUF *new_val, + struct lsa_DATA_BUF *old_val) { return NT_STATUS_ACCESS_DENIED; } @@ -2122,3 +2134,466 @@ NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, L return NT_STATUS_OK; } + + +/* + * From here on the server routines are just dummy ones to make smbd link with + * librpc/gen_ndr/srv_lsa.c. These routines are actually never called, we are + * pulling the server stubs across one by one. + */ + +NTSTATUS _lsa_Delete(pipes_struct *p, struct policy_handle *handle) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_EnumPrivs(pipes_struct *p, struct policy_handle *handle, uint32_t *resume_handle, uint32_t max_count, struct lsa_PrivArray *_privs) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_QuerySecurity(pipes_struct *p, struct policy_handle *handle, uint32_t sec_info, struct sec_desc_buf *sdbuf) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_SetSecObj(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_ChangePassword(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_OpenPolicy(pipes_struct *p, uint16_t *system_name, struct lsa_ObjectAttribute *attr, uint32_t access_mask, struct policy_handle *handle) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, struct policy_handle *handle, uint16_t level, union lsa_PolicyInformation *info) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_SetInfoPolicy(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_ClearAuditLog(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_CreateAccount(pipes_struct *p, struct policy_handle *handle, struct dom_sid2 *sid, uint32_t access_mask, struct policy_handle *acct_handle) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_EnumAccounts(pipes_struct *p, struct policy_handle *handle, uint32_t *resume_handle, uint32_t num_entries, struct lsa_SidArray *sids) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_EnumTrustDom(pipes_struct *p, struct policy_handle *handle, uint32_t *resume_handle, uint32_t max_size, struct lsa_DomainList *domains) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LookupNames(pipes_struct *p, struct policy_handle *handle, uint32_t num_names, struct lsa_String *names, struct lsa_RefDomainList *domains, struct lsa_TransSidArray *sids, uint16_t level, uint32_t *count) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LookupSids(pipes_struct *p, struct policy_handle *handle, struct lsa_SidArray *sids, struct lsa_RefDomainList *domains, struct lsa_TransNameArray *names, uint16_t level, uint32_t *count) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_OpenAccount(pipes_struct *p, struct policy_handle *handle, struct dom_sid2 *sid, uint32_t access_mask, struct policy_handle *acct_handle) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_EnumPrivsAccount(pipes_struct *p, struct policy_handle *handle, struct lsa_PrivilegeSet *_privs) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_AddPrivilegesToAccount(pipes_struct *p, struct policy_handle *handle, struct lsa_PrivilegeSet *_privs) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_RemovePrivilegesFromAccount(pipes_struct *p, struct policy_handle *handle, uint8_t remove_all, struct lsa_PrivilegeSet *_privs) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_GetQuotasForAccount(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_SetQuotasForAccount(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_QueryTrustedDomainInfo(pipes_struct *p, struct policy_handle *trustdom_handle, enum lsa_TrustDomInfoEnum level, union lsa_TrustedDomainInfo *info) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_SetInformationTrustedDomain(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_QuerySecret(pipes_struct *p, struct policy_handle *sec_handle, struct lsa_DATA_BUF_PTR *new_val, NTTIME *new_mtime, struct lsa_DATA_BUF_PTR *old_val, NTTIME *old_mtime) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LookupPrivValue(pipes_struct *p, struct policy_handle *handle, struct lsa_String *name, struct lsa_LUID *luid) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LookupPrivName(pipes_struct *p, struct policy_handle *handle, struct lsa_LUID *luid, struct lsa_StringLarge *name) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p, struct policy_handle *handle, struct lsa_String *name, struct lsa_StringLarge *disp_name, uint16_t *language_id, uint16_t unknown) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_DeleteObject(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_EnumAccountsWithUserRight(pipes_struct *p, struct policy_handle *handle, struct lsa_String *name, struct lsa_SidArray *sids) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_EnumAccountRights(pipes_struct *p, struct policy_handle *handle, struct dom_sid2 *sid, struct lsa_RightSet *rights) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_AddAccountRights(pipes_struct *p, struct policy_handle *handle, struct dom_sid2 *sid, struct lsa_RightSet *rights) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p, struct policy_handle *handle, struct dom_sid2 *sid, uint32_t unknown, struct lsa_RightSet *rights) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_QueryTrustedDomainInfoBySid(pipes_struct *p, struct policy_handle *handle, struct dom_sid2 *dom_sid, enum lsa_TrustDomInfoEnum level, union lsa_TrustedDomainInfo *info) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_SetTrustedDomainInfo(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_DeleteTrustedDomain(pipes_struct *p, struct policy_handle *handle, struct dom_sid2 *dom_sid) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_StorePrivateData(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_RetrievePrivateData(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_OpenPolicy2(pipes_struct *p, const char *system_name, struct lsa_ObjectAttribute *attr, uint32_t access_mask, struct policy_handle *handle) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_GetUserName(pipes_struct *p, const char *system_name, struct lsa_String *account_name, struct lsa_StringPointer *authority_name) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_QueryInfoPolicy2(pipes_struct *p, struct policy_handle *handle, uint16_t level, union lsa_PolicyInformation *info) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_SetInfoPolicy2(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_QueryTrustedDomainInfoByName(pipes_struct *p, struct policy_handle *handle, struct lsa_String trusted_domain, enum lsa_TrustDomInfoEnum level, union lsa_TrustedDomainInfo *info) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_SetTrustedDomainInfoByName(pipes_struct *p, struct policy_handle *handle, struct lsa_String trusted_domain, enum lsa_TrustDomInfoEnum level, union lsa_TrustedDomainInfo *info) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_EnumTrustedDomainsEx(pipes_struct *p, struct policy_handle *handle, uint32_t *resume_handle, struct lsa_DomainListEx *domains, uint32_t max_size) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_CreateTrustedDomainEx(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_CloseTrustedDomainEx(pipes_struct *p, struct policy_handle *handle) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_QueryDomainInformationPolicy(pipes_struct *p, struct policy_handle *handle, uint16_t level, union lsa_DomainInformationPolicy *info) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_SetDomainInformationPolicy(pipes_struct *p, struct policy_handle *handle, uint16_t level, union lsa_DomainInformationPolicy *info) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_OpenTrustedDomainByName(pipes_struct *p, struct policy_handle *handle, struct lsa_String name, uint32_t access_mask, struct policy_handle *trustdom_handle) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_TestCall(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LookupSids2(pipes_struct *p, struct policy_handle *handle, struct lsa_SidArray *sids, struct lsa_RefDomainList *domains, struct lsa_TransNameArray2 *names, uint16_t level, uint32_t *count, uint32_t unknown1, uint32_t unknown2) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LookupNames2(pipes_struct *p, struct policy_handle *handle, uint32_t num_names, struct lsa_String *names, struct lsa_RefDomainList *domains, struct lsa_TransSidArray2 *sids, uint16_t level, uint32_t *count, uint32_t unknown1, uint32_t unknown2) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_CreateTrustedDomainEx2(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_CREDRWRITE(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_CREDRREAD(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_CREDRENUMERATE(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_CREDRWRITEDOMAINCREDENTIALS(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_CREDRREADDOMAINCREDENTIALS(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_CREDRDELETE(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_CREDRGETTARGETINFO(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_CREDRPROFILELOADED(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LookupNames3(pipes_struct *p, struct policy_handle *handle, uint32_t num_names, struct lsa_String *names, struct lsa_RefDomainList *domains, struct lsa_TransSidArray3 *sids, uint16_t level, uint32_t *count, uint32_t unknown1, uint32_t unknown2) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_CREDRGETSESSIONTYPES(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LSARREGISTERAUDITEVENT(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LSARGENAUDITEVENT(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LSARUNREGISTERAUDITEVENT(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LSARQUERYFORESTTRUSTINFORMATION(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LSARSETFORESTTRUSTINFORMATION(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_CREDRRENAME(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LookupSids3(pipes_struct *p, struct lsa_SidArray *sids, struct lsa_RefDomainList *domains, struct lsa_TransNameArray2 *names, uint16_t level, uint32_t *count, uint32_t unknown1, uint32_t unknown2) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LookupNames4(pipes_struct *p, uint32_t num_names, struct lsa_String *names, struct lsa_RefDomainList *domains, struct lsa_TransSidArray3 *sids, uint16_t level, uint32_t *count, uint32_t unknown1, uint32_t unknown2) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LSAROPENPOLICYSCE(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LSARADTREGISTERSECURITYEVENTSOURCE(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _lsa_LSARADTREPORTSECURITYEVENT(pipes_struct *p) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 737868f375..ec39c2a482 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2133,175 +2133,210 @@ WERROR _srvsvc_NetFileClose(pipes_struct *p, const char *server_unc, uint32_t fi WERROR _srvsvc_NetCharDevEnum(pipes_struct *p, const char *server_unc, uint32_t *level, union srvsvc_NetCharDevCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetCharDevGetInfo(pipes_struct *p, const char *server_unc, const char *device_name, uint32_t level, union srvsvc_NetCharDevInfo *info) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetCharDevControl(pipes_struct *p, const char *server_unc, const char *device_name, uint32_t opcode) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetCharDevQEnum(pipes_struct *p, const char *server_unc, const char *user, uint32_t *level, union srvsvc_NetCharDevQCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetCharDevQGetInfo(pipes_struct *p, const char *server_unc, const char *queue_name, const char *user, uint32_t level, union srvsvc_NetCharDevQInfo *info) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetCharDevQSetInfo(pipes_struct *p, const char *server_unc, const char *queue_name, uint32_t level, union srvsvc_NetCharDevQInfo info, uint32_t *parm_error) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetCharDevQPurge(pipes_struct *p, const char *server_unc, const char *queue_name) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetCharDevQPurgeSelf(pipes_struct *p, const char *server_unc, const char *queue_name, const char *computer_name) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetFileGetInfo(pipes_struct *p, const char *server_unc, uint32_t fid, uint32_t level, union srvsvc_NetFileInfo *info) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetShareCheck(pipes_struct *p, const char *server_unc, const char *device_name, enum srvsvc_ShareType *type) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetServerStatisticsGet(pipes_struct *p, const char *server_unc, const char *service, uint32_t level, uint32_t options, struct srvsvc_Statistics *stats) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetTransportAdd(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetTransportInfo info) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetTransportEnum(pipes_struct *p, const char *server_unc, uint32_t *level, union srvsvc_NetTransportCtr *transports, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetTransportDel(pipes_struct *p, const char *server_unc, uint32_t unknown, struct srvsvc_NetTransportInfo0 transport) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetSetServiceBits(pipes_struct *p, const char *server_unc, const char *transport, uint32_t servicebits, uint32_t updateimmediately) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetPathType(pipes_struct *p, const char *server_unc, const char *path, uint32_t pathflags, uint32_t *pathtype) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetPathCanonicalize(pipes_struct *p, const char *server_unc, const char *path, uint8_t *can_path, uint32_t maxbuf, const char *prefix, uint32_t *pathtype, uint32_t pathflags) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetPathCompare(pipes_struct *p, const char *server_unc, const char *path1, const char *path2, uint32_t pathtype, uint32_t pathflags) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NETRPRNAMECANONICALIZE(pipes_struct *p) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetPRNameCompare(pipes_struct *p, const char *server_unc, const char *name1, const char *name2, uint32_t name_type, uint32_t flags) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetShareDelStart(pipes_struct *p, const char *server_unc, const char *share, uint32_t reserved, struct policy_handle *hnd) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetShareDelCommit(pipes_struct *p, struct policy_handle *hnd) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetServerTransportAddEx(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetTransportInfo info) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NetServerSetServiceBitsEx(pipes_struct *p, const char *server_unc, const char *emulated_server_unc, const char *transport, uint32_t servicebitsofinterest, uint32_t servicebits, uint32_t updateimmediately) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NETRDFSGETVERSION(pipes_struct *p) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NETRDFSCREATELOCALPARTITION(pipes_struct *p) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NETRDFSDELETELOCALPARTITION(pipes_struct *p) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NETRDFSSETLOCALVOLUMESTATE(pipes_struct *p) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NETRDFSSETSERVERINFO(pipes_struct *p) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NETRDFSCREATEEXITPOINT(pipes_struct *p) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NETRDFSDELETEEXITPOINT(pipes_struct *p) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NETRSERVERTRANSPORTDELEX(pipes_struct *p) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NETRDFSMANAGERREPORTSITEINFO(pipes_struct *p) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NETRDFSMODIFYPREFIX(pipes_struct *p) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } WERROR _srvsvc_NETRDFSFIXLOCALVOLUME(pipes_struct *p) { + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 92ea0b3d85..090338a301 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -938,8 +938,6 @@ WERROR _winreg_RestoreKey(pipes_struct *p, struct policy_handle *handle, struct DEBUG(2,("_winreg_RestoreKey: Restoring [%s] from %s in share %s\n", regkey->name, fname, lp_servicename(snum) )); return restore_registry_key( regkey, fname ); - - return WERR_NOT_SUPPORTED; } /******************************************************************** @@ -1130,6 +1128,7 @@ WERROR _winreg_SaveKeyEx(pipes_struct *p) /* fill in your code here if you think this call should do anything */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -1472,6 +1471,7 @@ WERROR _winreg_UnLoadKey(pipes_struct *p) /* fill in your code here if you think this call should do anything */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -1483,6 +1483,7 @@ WERROR _winreg_ReplaceKey(pipes_struct *p) /* fill in your code here if you think this call should do anything */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -1494,6 +1495,7 @@ WERROR _winreg_LoadKey(pipes_struct *p, struct policy_handle *handle, struct win /* fill in your code here if you think this call should do anything */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -1505,6 +1507,7 @@ WERROR _winreg_NotifyChangeKeyValue(pipes_struct *p, struct policy_handle *handl /* fill in your code here if you think this call should do anything */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -1516,6 +1519,7 @@ WERROR _winreg_QueryMultipleValues(pipes_struct *p, struct policy_handle *key_ha /* fill in your code here if you think this call should do anything */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -1527,6 +1531,7 @@ WERROR _winreg_QueryMultipleValues2(pipes_struct *p) /* fill in your code here if you think this call should do anything */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 79e9337e88..3ed1cbe682 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -86,6 +86,7 @@ WERROR _wkssvc_NetWkstaSetInfo( pipes_struct *p, const char *server_name, uint32_t *parm_error ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -100,6 +101,7 @@ WERROR _wkssvc_NetWkstaEnumUsers( pipes_struct *p, const char *server_name, uint32_t *resumehandle ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -109,6 +111,7 @@ WERROR _wkssvc_NetWkstaEnumUsers( pipes_struct *p, const char *server_name, WERROR _WKSSVC_NETRWKSTAUSERGETINFO( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -118,6 +121,7 @@ WERROR _WKSSVC_NETRWKSTAUSERGETINFO( pipes_struct *p ) WERROR _WKSSVC_NETRWKSTAUSERSETINFO( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -127,6 +131,7 @@ WERROR _WKSSVC_NETRWKSTAUSERSETINFO( pipes_struct *p ) WERROR _wkssvc_NetWkstaTransportEnum( pipes_struct *p, const char *server_name, uint32_t *level, union wkssvc_NetWkstaTransportCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -136,6 +141,7 @@ WERROR _wkssvc_NetWkstaTransportEnum( pipes_struct *p, const char *server_name, WERROR _WKSSVC_NETRWKSTATRANSPORTADD( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -145,6 +151,7 @@ WERROR _WKSSVC_NETRWKSTATRANSPORTADD( pipes_struct *p ) WERROR _WKSSVC_NETRWKSTATRANSPORTDEL( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -154,6 +161,7 @@ WERROR _WKSSVC_NETRWKSTATRANSPORTDEL( pipes_struct *p ) WERROR _WKSSVC_NETRUSEADD( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -163,6 +171,7 @@ WERROR _WKSSVC_NETRUSEADD( pipes_struct *p ) WERROR _WKSSVC_NETRUSEGETINFO( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -172,6 +181,7 @@ WERROR _WKSSVC_NETRUSEGETINFO( pipes_struct *p ) WERROR _WKSSVC_NETRUSEDEL( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -181,6 +191,7 @@ WERROR _WKSSVC_NETRUSEDEL( pipes_struct *p ) WERROR _WKSSVC_NETRUSEENUM( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -190,6 +201,7 @@ WERROR _WKSSVC_NETRUSEENUM( pipes_struct *p ) WERROR _WKSSVC_NETRMESSAGEBUFFERSEND( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -199,6 +211,7 @@ WERROR _WKSSVC_NETRMESSAGEBUFFERSEND( pipes_struct *p ) WERROR _WKSSVC_NETRWORKSTATIONSTATISTICSGET( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -208,6 +221,7 @@ WERROR _WKSSVC_NETRWORKSTATIONSTATISTICSGET( pipes_struct *p ) WERROR _WKSSVC_NETRLOGONDOMAINNAMEADD( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -217,6 +231,7 @@ WERROR _WKSSVC_NETRLOGONDOMAINNAMEADD( pipes_struct *p ) WERROR _WKSSVC_NETRLOGONDOMAINNAMEDEL( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -226,6 +241,7 @@ WERROR _WKSSVC_NETRLOGONDOMAINNAMEDEL( pipes_struct *p ) WERROR _WKSSVC_NETRJOINDOMAIN( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -235,6 +251,7 @@ WERROR _WKSSVC_NETRJOINDOMAIN( pipes_struct *p ) WERROR _WKSSVC_NETRUNJOINDOMAIN( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -244,6 +261,7 @@ WERROR _WKSSVC_NETRUNJOINDOMAIN( pipes_struct *p ) WERROR _WKSSVC_NETRRENAMEMACHINEINDOMAIN( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -253,6 +271,7 @@ WERROR _WKSSVC_NETRRENAMEMACHINEINDOMAIN( pipes_struct *p ) WERROR _WKSSVC_NETRVALIDATENAME( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -262,6 +281,7 @@ WERROR _WKSSVC_NETRVALIDATENAME( pipes_struct *p ) WERROR _WKSSVC_NETRGETJOININFORMATION( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -271,6 +291,7 @@ WERROR _WKSSVC_NETRGETJOININFORMATION( pipes_struct *p ) WERROR _WKSSVC_NETRGETJOINABLEOUS( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -280,6 +301,7 @@ WERROR _WKSSVC_NETRGETJOINABLEOUS( pipes_struct *p ) WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, const char *server_name, const char *domain_name, const char *account_name, const char *admin_account, struct wkssvc_PasswordBuffer *encrypted_password, uint32_t join_flags) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -289,6 +311,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, const char *server_name, const c WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, const char *server_name, const char *account, struct wkssvc_PasswordBuffer *encrypted_password, uint32_t unjoin_flags) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -298,6 +321,7 @@ WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, const char *server_name, const WERROR _wkssvc_NetrRenameMachineInDomain2(pipes_struct *p, const char *server_name, const char *NewMachineName, const char *Account, struct wkssvc_PasswordBuffer *EncryptedPassword, uint32_t RenameOptions) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -307,6 +331,7 @@ WERROR _wkssvc_NetrRenameMachineInDomain2(pipes_struct *p, const char *server_na WERROR _WKSSVC_NETRVALIDATENAME2( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -316,6 +341,7 @@ WERROR _WKSSVC_NETRVALIDATENAME2( pipes_struct *p ) WERROR _WKSSVC_NETRGETJOINABLEOUS2( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -325,6 +351,7 @@ WERROR _WKSSVC_NETRGETJOINABLEOUS2( pipes_struct *p ) WERROR _wkssvc_NetrAddAlternateComputerName(pipes_struct *p, const char *server_name, const char *NewAlternateMachineName, const char *Account, struct wkssvc_PasswordBuffer *EncryptedPassword, uint32_t Reserved) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -334,6 +361,7 @@ WERROR _wkssvc_NetrAddAlternateComputerName(pipes_struct *p, const char *server_ WERROR _wkssvc_NetrRemoveAlternateComputerName(pipes_struct *p, const char *server_name, const char *AlternateMachineNameToRemove, const char *Account, struct wkssvc_PasswordBuffer *EncryptedPassword, uint32_t Reserved) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -343,6 +371,7 @@ WERROR _wkssvc_NetrRemoveAlternateComputerName(pipes_struct *p, const char *serv WERROR _WKSSVC_NETRSETPRIMARYCOMPUTERNAME( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } @@ -352,6 +381,7 @@ WERROR _WKSSVC_NETRSETPRIMARYCOMPUTERNAME( pipes_struct *p ) WERROR _WKSSVC_NETRENUMERATECOMPUTERNAMES( pipes_struct *p ) { /* FIXME: Add implementation code here */ + p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -- cgit From 7b9ef5e8409cdfba121a0520fd5e3b10467c20b4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 15 Oct 2006 16:06:10 +0000 Subject: r19292: Avoid some potential segfaults: In winreg_EnumValue all pointers are unique pointers and can thus be independently NULL. Thanks, Volker (This used to be commit d48ac0726a931a7200c47a87f771b74826ab9c96) --- source3/rpc_server/srv_winreg_nt.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 090338a301..a892a9bb8d 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -613,19 +613,31 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, uint32_t status = WERR_NOMEM; } - *value_length = regval_size( val ); - *type = val->type; + if (type != NULL) { + *type = val->type; + } - if ( *data_size == 0 || !data ) { - status = WERR_OK; - } else if ( *value_length > *data_size ) { - status = WERR_MORE_DATA; - } else { - memcpy( data, regval_data_p(val), *value_length ); + if (data != NULL) { + if ((data_size == NULL) || (value_length == NULL)) { + status = WERR_INVALID_PARAM; + goto done; + } + + if (regval_size(val) > *data_size) { + status = WERR_MORE_DATA; + goto done; + } + + memcpy( data, regval_data_p(val), regval_size(val) ); status = WERR_OK; } - *data_size = *value_length; + if (value_length != NULL) { + *value_length = regval_size( val ); + } + if (data_size != NULL) { + *data_size = regval_size( val ); + } done: free_registry_value( val ); -- cgit From 2a10d7686553a2c2377165b7f80269d2dcae8847 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 21 Oct 2006 17:00:47 +0000 Subject: r19448: Convert delete_share_security to struct share_params plus some cleanups (This used to be commit c73d0815a3a1f58b951caa62fac601a8f4630894) --- source3/rpc_server/srv_srvsvc_nt.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index ec39c2a482..0e7f749a4e 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1680,12 +1680,11 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, uint32_t lev WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, const char *share_name, uint32_t reserved) { - pstring command; + char *command; int ret; - int snum; + struct share_params *params; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op; - fstring tmp_share_name; DEBUG(5,("_srv_net_share_del: %d\n", __LINE__)); @@ -1696,14 +1695,12 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, const char * return WERR_ACCESS_DENIED; } - fstrcpy(tmp_share_name, share_name); - snum = find_service(tmp_share_name); - - if (snum < 0) + if (!(params = get_share_params(p->mem_ctx, share_name))) { return WERR_NO_SUCH_SHARE; + } /* No change to printer shares. */ - if (lp_print_ok(snum)) + if (lp_print_ok(params->service)) return WERR_ACCESS_DENIED; is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); @@ -1715,9 +1712,12 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, const char * DEBUG(10,("_srv_net_share_del: No delete share command\n")); return WERR_ACCESS_DENIED; } - - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", - lp_delete_share_cmd(), dyn_CONFIGFILE, lp_servicename(snum)); + + if (asprintf(&command, "%s \"%s\" \"%s\"", + lp_delete_share_cmd(), dyn_CONFIGFILE, + lp_servicename(params->service)) == -1) { + return WERR_NOMEM; + } DEBUG(10,("_srv_net_share_del: Running [%s]\n", command )); @@ -1733,6 +1733,8 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, const char * if ( is_disk_op ) unbecome_root(); + + SAFE_FREE(command); /********* END SeDiskOperatorPrivilege BLOCK *********/ @@ -1742,9 +1744,9 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, const char * return WERR_ACCESS_DENIED; /* Delete the SD in the database. */ - delete_share_security(snum); + delete_share_security(params); - lp_killservice(snum); + lp_killservice(params->service); return WERR_OK; } -- cgit From 24f7144930b9235fa2a83e4833853906016ea114 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 23 Oct 2006 20:11:12 +0000 Subject: r19468: Fix some potential NULL dereferences (This used to be commit c8ed4129767d53ba6b7a084ca43b3e22e847ffec) --- source3/rpc_server/srv_srvsvc_nt.c | 62 +++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 0e7f749a4e..c4a6c1103e 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -503,6 +503,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, TALLOC_CTX *ctx = p->mem_ctx; struct share_iterator *shares; struct share_params *share; + WERROR result = WERR_NOMEM; DEBUG(5,("init_srv_share_info_ctr\n")); @@ -526,39 +527,69 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, switch (info_level) { case 0: - ctr->ctr0 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr0); + if (!(ctr->ctr0 = talloc_zero( + p->mem_ctx, struct srvsvc_NetShareCtr0))) { + goto done; + } break; case 1: - ctr->ctr1 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1); + if (!(ctr->ctr1 = talloc_zero( + p->mem_ctx, struct srvsvc_NetShareCtr1))) { + goto done; + } break; case 2: - ctr->ctr2 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr2); + if (!(ctr->ctr2 = talloc_zero( + p->mem_ctx, struct srvsvc_NetShareCtr2))) { + goto done; + } break; case 501: - ctr->ctr501 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr501); + if (!(ctr->ctr501 = talloc_zero( + p->mem_ctx, struct srvsvc_NetShareCtr501))) { + goto done; + } break; case 502: - ctr->ctr502 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr502); + if (!(ctr->ctr502 = talloc_zero( + p->mem_ctx, struct srvsvc_NetShareCtr502))) { + goto done; + } break; case 1004: - ctr->ctr1004 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1004); + if (!(ctr->ctr1004 = talloc_zero( + p->mem_ctx, struct srvsvc_NetShareCtr1004))) { + goto done; + } break; case 1005: - ctr->ctr1005 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1005); + if (!(ctr->ctr1005 = talloc_zero( + p->mem_ctx, struct srvsvc_NetShareCtr1005))) { + goto done; + } break; case 1006: - ctr->ctr1006 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1006); + if (!(ctr->ctr1006 = talloc_zero( + p->mem_ctx, struct srvsvc_NetShareCtr1006))) { + goto done; + } break; case 1007: - ctr->ctr1007 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1007); + if (!(ctr->ctr1007 = talloc_zero( + p->mem_ctx, struct srvsvc_NetShareCtr1007))) { + goto done; + } break; case 1501: - ctr->ctr1501 = talloc_zero(p->mem_ctx, struct srvsvc_NetShareCtr1501); + if (!(ctr->ctr1501 = talloc_zero( + p->mem_ctx, struct srvsvc_NetShareCtr1501))) { + goto done; + } break; default: - DEBUG(5,("init_srv_share_info_ctr: unsupported switch " - "value %d\n", info_level)); - return WERR_UNKNOWN_LEVEL; + DEBUG(5,("init_srv_share_info_ctr: unsupported switch " + "value %d\n", info_level)); + return WERR_UNKNOWN_LEVEL; } while ((share = next_share(shares)) != NULL) { @@ -707,7 +738,10 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, TALLOC_FREE(share); } - return WERR_OK; + result = WERR_OK; + done: + TALLOC_FREE(shares); + return result; } /******************************************************************* -- cgit From bef92ebb257adda6634c559e0240ad4991840212 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 11 Nov 2006 18:07:51 +0000 Subject: r19669: set_share_security does not need a mem_ctx passed (This used to be commit 53eaa603eb84047263c27d57b8c0f5ce8e157189) --- source3/rpc_server/srv_srvsvc_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index c4a6c1103e..35938d087e 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1542,7 +1542,7 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, const ch &sd_size); if (old_sd && !sec_desc_equal(old_sd, psd)) { - if (!set_share_security(p->mem_ctx, share_name, psd)) + if (!set_share_security(share_name, psd)) DEBUG(0,("_srv_net_share_set_info: Failed to change security info in share %s.\n", share_name )); } @@ -1691,7 +1691,7 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, uint32_t lev return WERR_ACCESS_DENIED; if (psd) { - if (!set_share_security(p->mem_ctx, share_name, psd)) { + if (!set_share_security(share_name, psd)) { DEBUG(0,("_srv_net_share_add: Failed to add security info to share %s.\n", share_name )); } } -- cgit From 64bab725f028ac68fe34cdb9b2efb2238b67db57 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 13 Nov 2006 10:50:55 +0000 Subject: r19689: Fix a NULL dereference found by coverity (the call to strlen). Jerry, please check this. The way I understood alpha_strcpy the last arg needs to be the size of the target, not of the source. Thanks, Volker (This used to be commit 287d68daab89c78748b90849c9782473784b6a84) --- source3/rpc_server/srv_winreg_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index a892a9bb8d..1a130f19b6 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -689,12 +689,14 @@ WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, uint16_t *hostname, str /* pull the message string and perform necessary sanity checks on it */ + chkmsg[0] = '\0'; + if ( message && message->name && message->name->name ) { if ( (msg = talloc_strdup(p->mem_ctx, message->name->name )) == NULL ) { return WERR_NOMEM; } + alpha_strcpy (chkmsg, msg, NULL, sizeof(chkmsg)); } - alpha_strcpy (chkmsg, msg?msg:"", NULL, strlen(msg)); fstr_sprintf(str_timeout, "%d", timeout); fstr_sprintf(r, reboot ? SHUTDOWN_R_STRING : ""); -- cgit From 9bb1f909fdc7e4c4d52382d3a920e156e39c3768 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 18 Nov 2006 17:06:43 +0000 Subject: r19775: Fix typo (This used to be commit 370e29ebb9da92c9072bdd4eec84980b5753089a) --- source3/rpc_server/srv_eventlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 79839a0a52..ec07981de9 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -405,7 +405,7 @@ static BOOL sync_eventlog_params( EVENTLOG_INFO *info ) uiRetention = 604800; /* the general idea is to internally open the registry - key and retreive the values. That way we can continue + key and retrieve the values. That way we can continue to use the same fetch/store api that we use in srv_reg_nt.c */ -- cgit From 09ec562a09e4195e58b051a74a90d113aa0e0ac7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 18 Nov 2006 17:07:15 +0000 Subject: r19776: Hmmm. I should have done one instead of three commits. Sorry :-) (This used to be commit e2a35ceffe35b25aafde987c50e63b89a3e3ec16) --- source3/rpc_server/srv_svcctl_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index dd790691d3..0b985f83dc 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -302,7 +302,7 @@ WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_ return WERR_BADFID; /* perform access checks. Use the root token in order to ensure that we - retreive the security descriptor */ + retrieve the security descriptor */ if ( !(sec_desc = svcctl_get_secdesc( p->mem_ctx, service, get_root_nt_token() )) ) return WERR_NOMEM; -- cgit From e82cd437cc3c93e25f56d3326d6ba527a33ebfbf Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 19 Nov 2006 10:50:33 +0000 Subject: r19778: Make regkey_open_internal take a talloc ctx (This used to be commit cb7f4211b8441642dce9594522dc9588475a7719) --- source3/rpc_server/srv_eventlog_nt.c | 5 ++--- source3/rpc_server/srv_winreg_nt.c | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index ec07981de9..ba366ed983 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -411,9 +411,8 @@ static BOOL sync_eventlog_params( EVENTLOG_INFO *info ) pstr_sprintf( path, "%s/%s", KEY_EVENTLOG, elogname ); - wresult = - regkey_open_internal( &keyinfo, path, get_root_nt_token( ), - REG_KEY_READ ); + wresult = regkey_open_internal( + NULL, &keyinfo, path, get_root_nt_token(), REG_KEY_READ ); if ( !W_ERROR_IS_OK( wresult ) ) { DEBUG( 4, diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 1a130f19b6..ebf825b684 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -86,7 +86,9 @@ static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, /* now do the internal open */ - result = regkey_open_internal( keyinfo, keypath, p->pipe_user.nt_user_token, access_desired ); + result = regkey_open_internal( NULL, keyinfo, keypath, + p->pipe_user.nt_user_token, + access_desired ); if ( !W_ERROR_IS_OK(result) ) return result; -- cgit From bfad4421449d7f49287b1ebe81bf572c271f8fca Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 19 Nov 2006 11:11:01 +0000 Subject: r19780: Ok, regkey_open_internal needs a regkey_close_internal. Giving a talloc ctx is misleading here. This needs fixing properly :-) Volker (This used to be commit f808182346aa16bb2f3a9383e28d318099a5e14e) --- source3/rpc_server/srv_eventlog_nt.c | 5 +++-- source3/rpc_server/srv_winreg_nt.c | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index ba366ed983..ec07981de9 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -411,8 +411,9 @@ static BOOL sync_eventlog_params( EVENTLOG_INFO *info ) pstr_sprintf( path, "%s/%s", KEY_EVENTLOG, elogname ); - wresult = regkey_open_internal( - NULL, &keyinfo, path, get_root_nt_token(), REG_KEY_READ ); + wresult = + regkey_open_internal( &keyinfo, path, get_root_nt_token( ), + REG_KEY_READ ); if ( !W_ERROR_IS_OK( wresult ) ) { DEBUG( 4, diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index ebf825b684..1a130f19b6 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -86,9 +86,7 @@ static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, /* now do the internal open */ - result = regkey_open_internal( NULL, keyinfo, keypath, - p->pipe_user.nt_user_token, - access_desired ); + result = regkey_open_internal( keyinfo, keypath, p->pipe_user.nt_user_token, access_desired ); if ( !W_ERROR_IS_OK(result) ) return result; -- cgit From ded7c032a311afdda225bde70a9cb0581cd7ee48 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 20 Nov 2006 13:39:01 +0000 Subject: r19803: Fix problem reported by Chetan S: QueryInfoKey needs to report the max name length in *bytes* for UTF-16, not the string length. This got lost during the conversion. This took a while to figure out :-) Thanks to Chetan! Volker (This used to be commit 8df6544fa855d2d07b1b69c8d448a1362e41733c) --- source3/rpc_server/srv_winreg_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 1a130f19b6..f733b14c63 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -190,7 +190,7 @@ static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum, } *maxnum = num_values; - *maxlen = lenmax; + *maxlen = lenmax*2; *maxsize = sizemax; TALLOC_FREE( values ); -- cgit From ead21a53ae51e9cff726e4901c49fe5109734ad6 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 21 Nov 2006 13:28:27 +0000 Subject: r19819: Windows returns an empty string instead of NULL here (This used to be commit c1083216c83f4236edb78484c6333ff1d1646c40) --- source3/rpc_server/srv_winreg_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index f733b14c63..c45be08454 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -572,7 +572,7 @@ WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t e if ( last_changed_time ) { *last_changed_time = 0; } - keyclass->name = NULL; + keyclass->name = ""; if ( (name->name = talloc_strdup( p->mem_ctx, subkey )) == NULL ) { status = WERR_NOMEM; } -- cgit From c8951115792a8be64b294de68f47679c3c3ed28f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 21 Nov 2006 19:47:48 +0000 Subject: r19824: Fix the max value calculation in QueryInfoKey (This used to be commit cd14b7f05234f540601cd2c5841a52dd047c965d) --- source3/rpc_server/srv_winreg_nt.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index c45be08454..23b594ac78 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -163,7 +163,6 @@ static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *maxlen, uint32 *maxsize ) { REGVAL_CTR *values; - REGISTRY_VALUE *val; uint32 sizemax, lenmax; int i, num_values; @@ -178,15 +177,17 @@ static BOOL get_value_information( REGISTRY_KEY *key, uint32 *maxnum, lenmax = sizemax = 0; num_values = regval_ctr_numvals( values ); - - val = regval_ctr_specific_value( values, 0 ); - - for ( i=0; ivaluename ? strlen(val->valuename)+1 : 0 ); + + for ( i=0; ivaluename ? + strlen(val->valuename)+1 : 0 ); sizemax = MAX(sizemax, val->size ); - - val = regval_ctr_specific_value( values, i ); } *maxnum = num_values; -- cgit From 6b0819e96cb4bb1692485a6c7e841330687c63f8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 23 Nov 2006 16:19:06 +0000 Subject: r19860: Streamline _winreg_QueryValue a bit. We've been pushing around memory considerably here. This temporarily removes a cache for the tdb based registry, I'll re-add that in srv_winreg_nt.c in the next step. This fixes creating/renaming values from the windows regedit.exe, as "New Value #1" was not entering the cache after being created. Volker (This used to be commit c8c81f0e86256f769765c142e4f1e4c45cb74296) --- source3/rpc_server/srv_winreg_nt.c | 191 +++++++++++++++++-------------------- 1 file changed, 86 insertions(+), 105 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 23b594ac78..b81b4be32d 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -348,14 +348,20 @@ WERROR _winreg_OpenKey(pipes_struct *p, struct policy_handle *parent_handle, str reg_reply_info ********************************************************************/ -WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value_name, enum winreg_Type *type, uint8_t *data, uint32_t *data_size, uint32_t *value_length) +WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, + struct winreg_String value_name, + enum winreg_Type *type, uint8_t *data, + uint32_t *data_size, uint32_t *value_length) { - WERROR status = WERR_BADFILE; - char *name; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); - REGISTRY_VALUE *val = NULL; - REGVAL_CTR *regvals; - int i; + WERROR status = WERR_BADFILE; + REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + prs_struct prs_hkpd; + + uint8_t *outbuf; + uint32_t outbuf_size; + + BOOL free_buf = False; + BOOL free_prs = False; if ( !regkey ) return WERR_BADFID; @@ -365,124 +371,99 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, struct DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); DEBUG(7,("_reg_info: policy key type = [%08x]\n", regkey->type)); - if ( (name = talloc_strdup( p->mem_ctx, value_name.name )) == NULL ) { - return WERR_NOMEM; - } - - DEBUG(5,("_reg_info: looking up value: [%s]\n", name)); - - if ( !(regvals = TALLOC_ZERO_P( p->mem_ctx, REGVAL_CTR )) ) - return WERR_NOMEM; - /* Handle QueryValue calls on HKEY_PERFORMANCE_DATA */ if(regkey->type == REG_KEY_HKPD) { - if(strequal(name, "Global")) - { - uint32 outbuf_len; - prs_struct prs_hkpd; + if(strequal(value_name.name, "Global")) { prs_init(&prs_hkpd, *data_size, p->mem_ctx, MARSHALL); - status = reg_perfcount_get_hkpd(&prs_hkpd, *data_size, &outbuf_len, NULL); - regval_ctr_addvalue(regvals, "HKPD", REG_BINARY, - prs_hkpd.data_p, outbuf_len); - val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); - prs_mem_free(&prs_hkpd); + status = reg_perfcount_get_hkpd( + &prs_hkpd, *data_size, &outbuf_size, NULL); + outbuf = (uint8_t *)prs_hkpd.data_p; + free_prs = True; } - else if(strequal(name, "Counter 009")) - { - uint32 base_index; - uint32 buffer_size; - char *buffer; - - buffer = NULL; - base_index = reg_perfcount_get_base_index(); - buffer_size = reg_perfcount_get_counter_names(base_index, &buffer); - regval_ctr_addvalue(regvals, "Counter 009", - REG_MULTI_SZ, buffer, buffer_size); - - val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); - - if(buffer_size > 0) - { - SAFE_FREE(buffer); - status = WERR_OK; - } + else if(strequal(value_name.name, "Counter 009")) { + outbuf_size = reg_perfcount_get_counter_names( + reg_perfcount_get_base_index(), + (char **)&outbuf); + free_buf = True; } - else if(strequal(name, "Explain 009")) - { - uint32 base_index; - uint32 buffer_size; - char *buffer; - - buffer = NULL; - base_index = reg_perfcount_get_base_index(); - buffer_size = reg_perfcount_get_counter_help(base_index, &buffer); - regval_ctr_addvalue(regvals, "Explain 009", - REG_MULTI_SZ, buffer, buffer_size); - - val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); - - if(buffer_size > 0) - { - SAFE_FREE(buffer); - status = WERR_OK; - } + else if(strequal(value_name.name, "Explain 009")) { + outbuf_size = reg_perfcount_get_counter_help( + reg_perfcount_get_base_index(), + (char **)&outbuf); + free_buf = True; } - else if(isdigit(name[0])) - { - /* we probably have a request for a specific object here */ - uint32 outbuf_len; - prs_struct prs_hkpd; + else if(isdigit(value_name.name[0])) { + /* we probably have a request for a specific object + * here */ prs_init(&prs_hkpd, *data_size, p->mem_ctx, MARSHALL); - status = reg_perfcount_get_hkpd(&prs_hkpd, *data_size, &outbuf_len, name); - regval_ctr_addvalue(regvals, "HKPD", REG_BINARY, - prs_hkpd.data_p, outbuf_len); - - val = dup_registry_value(regval_ctr_specific_value(regvals, 0)); - prs_mem_free(&prs_hkpd); + status = reg_perfcount_get_hkpd( + &prs_hkpd, *data_size, &outbuf_size, + value_name.name); + outbuf = (uint8_t *)prs_hkpd.data_p; + free_prs = True; } - else - { - DEBUG(3,("Unsupported key name [%s] for HKPD.\n", name)); + else { + DEBUG(3,("Unsupported key name [%s] for HKPD.\n", + value_name.name)); return WERR_BADFILE; } + + *type = REG_BINARY; } - /* HKPT calls can be handled out of reg_dynamic.c with the hkpt_params handler */ - else - { - for ( i=0; fetch_reg_values_specific(regkey, &val, i); i++ ) - { - DEBUG(10,("_reg_info: Testing value [%s]\n", val->valuename)); - if ( strequal( val->valuename, name ) ) { - DEBUG(10,("_reg_info: Found match for value [%s]\n", name)); - status = WERR_OK; - break; + else { + /* HKPT calls can be handled out of reg_dynamic.c with the + * hkpt_params handler */ + + REGVAL_CTR *regvals; + uint32 i; + + if (!(regvals = TALLOC_ZERO_P(p->mem_ctx, REGVAL_CTR))) { + return WERR_NOMEM; } - - free_registry_value( val ); - } - } - /* if we have a value then copy it to the output */ + /* + * Don't use fetch_reg_values_specific here, there is too much + * memory copying around. I'll re-add the cache later. VL + */ - if ( val ) { - *value_length = regval_size( val ); - *type = val->type; + if (fetch_reg_values(regkey, regvals) == -1) { + TALLOC_FREE(regvals); + return WERR_BADFILE; + } - if ( *data_size == 0 || !data ) { - status = WERR_OK; - } else if ( *value_length > *data_size ) { - status = WERR_MORE_DATA; - } else { - memcpy( data, regval_data_p(val), *value_length ); - status = WERR_OK; + for (i=0; inum_values; i++) { + if (strequal(regvals->values[i]->valuename, + value_name.name)) { + break; + } } - *data_size = *value_length; + if (i == regvals->num_values) { + TALLOC_FREE(regvals); + return WERR_BADFILE; + } + + outbuf = regvals->values[i]->data_p; + outbuf_size = regvals->values[i]->size; + *type = regvals->values[i]->type; } - TALLOC_FREE( regvals ); - free_registry_value( val ); + *value_length = outbuf_size; + + if ( *data_size == 0 || !data ) { + status = WERR_OK; + } else if ( *value_length > *data_size ) { + status = WERR_MORE_DATA; + } else { + memcpy( data, outbuf, *value_length ); + status = WERR_OK; + } + + *data_size = *value_length; + + if (free_prs) prs_mem_free(&prs_hkpd); + if (free_buf) SAFE_FREE(outbuf); return status; } -- cgit From 3f62a1a3eb17b190aa12540304c72028adb66fba Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 23 Nov 2006 19:21:11 +0000 Subject: r19867: Introduce struct regkey_info in srv_winreg_nt.c to be able to re-add the QueryValue and later the QueryKey cache independent of the backend. Volker (This used to be commit 0ed3a21fccd9c05f1db40f8e20376a76583a81b6) --- source3/rpc_server/srv_winreg_nt.c | 221 ++++++++++++++++++++++--------------- 1 file changed, 130 insertions(+), 91 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index b81b4be32d..5342a9512c 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -30,22 +30,29 @@ static struct generic_mapping reg_generic_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; +struct regkey_info { + REGISTRY_KEY *key; +}; + /****************************************************************** - free() function for REGISTRY_KEY + free() function for struct regkey_info *****************************************************************/ static void free_regkey_info(void *ptr) { - regkey_close_internal( (REGISTRY_KEY*)ptr ); + struct regkey_info *info = (struct regkey_info *)ptr; + regkey_close_internal( info->key ); + TALLOC_FREE(info); } /****************************************************************** Find a registry key handle and return a REGISTRY_KEY *****************************************************************/ -static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) +static struct regkey_info *find_regkey_info_by_hnd(pipes_struct *p, + POLICY_HND *hnd) { - REGISTRY_KEY *regkey = NULL; + struct regkey_info *regkey = NULL; if(!find_policy_by_hnd(p,hnd,(void **)(void *)®key)) { DEBUG(2,("find_regkey_index_by_hnd: Registry Key not found: ")); @@ -55,6 +62,17 @@ static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) return regkey; } +static REGISTRY_KEY *find_regkey_by_hnd(pipes_struct *p, POLICY_HND *hnd) +{ + struct regkey_info *regkey = find_regkey_info_by_hnd(p, hnd); + + if (regkey == NULL) { + return NULL; + } + + return regkey->key; +} + /******************************************************************* Function for open a new registry handle and creating a handle @@ -65,37 +83,58 @@ static REGISTRY_KEY *find_regkey_index_by_hnd(pipes_struct *p, POLICY_HND *hnd) *******************************************************************/ static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, - REGISTRY_KEY **keyinfo, REGISTRY_KEY *parent, - const char *subkeyname, uint32 access_desired ) + struct regkey_info **pinfo, + REGISTRY_KEY *parent, + const char *subkeyname, + uint32 access_desired ) { - pstring keypath; + char *keypath; int path_len; WERROR result = WERR_OK; + struct regkey_info *info; /* create a full registry path and strip any trailing '\' characters */ - - pstr_sprintf( keypath, "%s%s%s", - parent ? parent->name : "", - parent ? "\\" : "", - subkeyname ); - + + if (asprintf(&keypath, "%s%s%s", + parent ? parent->name : "", + parent ? "\\" : "", + subkeyname) == -1) { + return WERR_NOMEM; + } + path_len = strlen( keypath ); if ( path_len && keypath[path_len-1] == '\\' ) keypath[path_len-1] = '\0'; + + if (!(info = TALLOC_ZERO_P(NULL, struct regkey_info))) { + SAFE_FREE(keypath); + return WERR_NOMEM; + } /* now do the internal open */ - result = regkey_open_internal( keyinfo, keypath, p->pipe_user.nt_user_token, access_desired ); - if ( !W_ERROR_IS_OK(result) ) + result = regkey_open_internal( &info->key, keypath, + p->pipe_user.nt_user_token, + access_desired ); + SAFE_FREE(keypath); + + if ( !W_ERROR_IS_OK(result) ) { + TALLOC_FREE(info); return result; + } - if ( !create_policy_hnd( p, hnd, free_regkey_info, *keyinfo ) ) { - result = WERR_BADFILE; - regkey_close_internal( *keyinfo ); + if ( !create_policy_hnd( p, hnd, free_regkey_info, info ) ) { + regkey_close_internal( info->key ); + TALLOC_FREE(info); + return WERR_BADFILE; + } + + if (pinfo) { + *pinfo = info; } - return result; + return WERR_OK;; } /******************************************************************* @@ -105,7 +144,7 @@ static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd) { - REGISTRY_KEY *regkey = find_regkey_index_by_hnd(p, hnd); + REGISTRY_KEY *regkey = find_regkey_by_hnd(p, hnd); if ( !regkey ) { DEBUG(2,("close_registry_key: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(hnd))); @@ -219,89 +258,79 @@ WERROR _winreg_CloseKey(pipes_struct *p, struct policy_handle *handle) WERROR _winreg_OpenHKLM(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { - REGISTRY_KEY *keyinfo; - - return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKLM, access_mask ); + return open_registry_key(p, handle, NULL, NULL, KEY_HKLM, access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKPD(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKPD(pipes_struct *p, uint16_t *system_name, + uint32_t access_mask, struct policy_handle *handle) { - REGISTRY_KEY *keyinfo; - - return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKPD, access_mask ); + return open_registry_key(p, handle, NULL, NULL, KEY_HKPD, access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKPT(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKPT(pipes_struct *p, uint16_t *system_name, + uint32_t access_mask, struct policy_handle *handle) { - REGISTRY_KEY *keyinfo; - - return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKPT, access_mask ); + return open_registry_key(p, handle, NULL, NULL, KEY_HKPT, access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKCR(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKCR(pipes_struct *p, uint16_t *system_name, + uint32_t access_mask, struct policy_handle *handle) { - REGISTRY_KEY *keyinfo; - - return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKCR, access_mask ); + return open_registry_key(p, handle, NULL, NULL, KEY_HKCR, access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKU(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKU(pipes_struct *p, uint16_t *system_name, + uint32_t access_mask, struct policy_handle *handle) { - REGISTRY_KEY *keyinfo; - - return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKU, access_mask ); + return open_registry_key(p, handle, NULL, NULL, KEY_HKU, access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKCU(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKCU(pipes_struct *p, uint16_t *system_name, + uint32_t access_mask, struct policy_handle *handle) { - REGISTRY_KEY *keyinfo; - - return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKCU, access_mask ); + return open_registry_key(p, handle, NULL, NULL, KEY_HKCU, access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKCC(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKCC(pipes_struct *p, uint16_t *system_name, + uint32_t access_mask, struct policy_handle *handle) { - REGISTRY_KEY *keyinfo; - - return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKCC, access_mask ); + return open_registry_key(p, handle, NULL, NULL, KEY_HKCC, access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKDD(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKDD(pipes_struct *p, uint16_t *system_name, + uint32_t access_mask, struct policy_handle *handle) { - REGISTRY_KEY *keyinfo; - - return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKDD, access_mask ); + return open_registry_key(p, handle, NULL, NULL, KEY_HKDD, access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKPN(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKPN(pipes_struct *p, uint16_t *system_name, + uint32_t access_mask, struct policy_handle *handle) { - REGISTRY_KEY *keyinfo; - - return open_registry_key( p, handle, &keyinfo, NULL, KEY_HKPN, access_mask ); + return open_registry_key(p, handle, NULL, NULL, KEY_HKPN, access_mask); } /******************************************************************* @@ -311,8 +340,7 @@ WERROR _winreg_OpenHKPN(pipes_struct *p, uint16_t *system_name, uint32_t access_ WERROR _winreg_OpenKey(pipes_struct *p, struct policy_handle *parent_handle, struct winreg_String keyname, uint32_t unknown, uint32_t access_mask, struct policy_handle *handle) { char *name; - REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, parent_handle ); - REGISTRY_KEY *newkey = NULL; + REGISTRY_KEY *parent = find_regkey_by_hnd(p, parent_handle ); uint32 check_rights; if ( !parent ) @@ -341,7 +369,7 @@ WERROR _winreg_OpenKey(pipes_struct *p, struct policy_handle *parent_handle, str * not do this stupidity. --jerry */ - return open_registry_key( p, handle, &newkey, parent, name, access_mask ); + return open_registry_key( p, handle, NULL, parent, name, access_mask ); } /******************************************************************* @@ -354,7 +382,7 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, uint32_t *data_size, uint32_t *value_length) { WERROR status = WERR_BADFILE; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + REGISTRY_KEY *regkey = find_regkey_by_hnd( p, handle ); prs_struct prs_hkpd; uint8_t *outbuf; @@ -481,7 +509,7 @@ WERROR _winreg_QueryInfoKey(pipes_struct *p, struct policy_handle *handle, uint32_t *secdescsize, NTTIME *last_changed_time) { WERROR status = WERR_OK; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + REGISTRY_KEY *regkey = find_regkey_by_hnd( p, handle ); if ( !regkey ) return WERR_BADFID; @@ -514,7 +542,7 @@ WERROR _winreg_QueryInfoKey(pipes_struct *p, struct policy_handle *handle, WERROR _winreg_GetVersion(pipes_struct *p, struct policy_handle *handle, uint32_t *version) { - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + REGISTRY_KEY *regkey = find_regkey_by_hnd( p, handle ); if ( !regkey ) return WERR_BADFID; @@ -532,7 +560,7 @@ WERROR _winreg_GetVersion(pipes_struct *p, struct policy_handle *handle, uint32_ WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_StringBuf *name, struct winreg_StringBuf *keyclass, NTTIME *last_changed_time) { WERROR status = WERR_OK; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + REGISTRY_KEY *regkey = find_regkey_by_hnd( p, handle ); char *subkey = NULL; @@ -571,7 +599,7 @@ done: WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_StringBuf *name, enum winreg_Type *type, uint8_t *data, uint32_t *data_size, uint32_t *value_length) { WERROR status = WERR_OK; - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + REGISTRY_KEY *regkey = find_regkey_by_hnd( p, handle ); REGISTRY_VALUE *val; if ( !regkey ) @@ -909,7 +937,7 @@ static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) WERROR _winreg_RestoreKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String *filename, uint32_t flags) { - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + REGISTRY_KEY *regkey = find_regkey_by_hnd( p, handle ); pstring fname; int snum; @@ -1094,7 +1122,7 @@ static WERROR backup_registry_key ( REGISTRY_KEY *krecord, const char *fname ) WERROR _winreg_SaveKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String *filename, struct KeySecurityAttribute *sec_attrib) { - REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, handle ); + REGISTRY_KEY *regkey = find_regkey_by_hnd( p, handle ); pstring fname; int snum; @@ -1131,13 +1159,16 @@ WERROR _winreg_SaveKeyEx(pipes_struct *p) /******************************************************************* ********************************************************************/ -WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, struct winreg_String keyname, - struct winreg_String keyclass, uint32_t options, uint32_t access_mask, - struct winreg_SecBuf *secdesc, struct policy_handle *new_handle, +WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, + struct winreg_String keyname, + struct winreg_String keyclass, + uint32_t options, uint32_t access_mask, + struct winreg_SecBuf *secdesc, + struct policy_handle *new_handle, enum winreg_CreateAction *action_taken ) { - REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, handle); - REGISTRY_KEY *newparentinfo, *keyinfo; + struct regkey_info *parent = find_regkey_info_by_hnd(p, handle); + struct regkey_info *newparentinfo, *keyinfo; POLICY_HND newparent_handle; REGSUBKEY_CTR *subkeys; BOOL write_result; @@ -1157,19 +1188,22 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, struct pstring newkeyname; char *ptr; - /* (1) check for enumerate rights on the parent handle. CLients can try - create things like 'SOFTWARE\Samba' on the HKLM handle. - (2) open the path to the child parent key if necessary */ + /* (1) check for enumerate rights on the parent handle. + Clients can try create things like 'SOFTWARE\Samba' on + the HKLM handle. (2) open the path to the child parent + key if necessary */ - if ( !(parent->access_granted & SEC_RIGHTS_ENUM_SUBKEYS) ) + if ( !(parent->key->access_granted & SEC_RIGHTS_ENUM_SUBKEYS) ) return WERR_ACCESS_DENIED; pstrcpy( newkeyname, name ); ptr = strrchr( newkeyname, '\\' ); *ptr = '\0'; - result = open_registry_key( p, &newparent_handle, &newparentinfo, - parent, newkeyname, (REG_KEY_READ|REG_KEY_WRITE) ); + result = open_registry_key( p, &newparent_handle, + &newparentinfo, + parent->key, newkeyname, + (REG_KEY_READ|REG_KEY_WRITE) ); if ( !W_ERROR_IS_OK(result) ) return result; @@ -1188,7 +1222,8 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, struct /* (3) check for create subkey rights on the correct parent */ - if ( !(newparentinfo->access_granted & SEC_RIGHTS_CREATE_SUBKEY) ) { + if ( !(newparentinfo->key->access_granted + & SEC_RIGHTS_CREATE_SUBKEY) ) { result = WERR_ACCESS_DENIED; goto done; } @@ -1200,12 +1235,12 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, struct /* (4) lookup the current keys and add the new one */ - fetch_reg_keys( newparentinfo, subkeys ); + fetch_reg_keys( newparentinfo->key, subkeys ); regsubkey_ctr_addkey( subkeys, name ); /* now write to the registry backend */ - write_result = store_reg_keys( newparentinfo, subkeys ); + write_result = store_reg_keys( newparentinfo->key, subkeys ); TALLOC_FREE( subkeys ); @@ -1215,8 +1250,9 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, struct /* (5) open the new key and return the handle. Note that it is probably not correct to grant full access on this open handle. */ - result = open_registry_key( p, new_handle, &keyinfo, newparentinfo, name, REG_KEY_READ ); - keyinfo->access_granted = REG_KEY_ALL; + result = open_registry_key( p, new_handle, &keyinfo, + newparentinfo->key, name, REG_KEY_READ ); + keyinfo->key->access_granted = REG_KEY_ALL; /* FIXME: report the truth here */ @@ -1239,7 +1275,7 @@ done: WERROR _winreg_SetValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String name, enum winreg_Type type, uint8_t *data, uint32_t size) { - REGISTRY_KEY *key = find_regkey_index_by_hnd(p, handle); + REGISTRY_KEY *key = find_regkey_by_hnd(p, handle); REGVAL_CTR *values; BOOL write_result; char *valuename; @@ -1286,8 +1322,8 @@ WERROR _winreg_SetValue(pipes_struct *p, struct policy_handle *handle, struct wi WERROR _winreg_DeleteKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String key) { - REGISTRY_KEY *parent = find_regkey_index_by_hnd(p, handle); - REGISTRY_KEY *newparentinfo = NULL; + struct regkey_info *parent = find_regkey_info_by_hnd(p, handle); + struct regkey_info *newparentinfo = NULL; POLICY_HND newparent_handle; REGSUBKEY_CTR *subkeys; BOOL write_result; @@ -1301,7 +1337,7 @@ WERROR _winreg_DeleteKey(pipes_struct *p, struct policy_handle *handle, struct w /* (1) check for delete rights on the parent */ - if ( !(parent->access_granted & STD_RIGHT_DELETE_ACCESS) ) { + if ( !(parent->key->access_granted & STD_RIGHT_DELETE_ACCESS) ) { result = WERR_ACCESS_DENIED; goto done; } @@ -1328,7 +1364,10 @@ WERROR _winreg_DeleteKey(pipes_struct *p, struct policy_handle *handle, struct w goto done; } - result = open_registry_key( p, &newparent_handle, &newparentinfo, parent, newkeyname, (REG_KEY_READ|REG_KEY_WRITE) ); + result = open_registry_key( p, &newparent_handle, + &newparentinfo, parent->key, + newkeyname, + (REG_KEY_READ|REG_KEY_WRITE) ); if ( !W_ERROR_IS_OK(result) ) { goto done; } @@ -1345,13 +1384,13 @@ WERROR _winreg_DeleteKey(pipes_struct *p, struct policy_handle *handle, struct w /* lookup the current keys and delete the new one */ - fetch_reg_keys( newparentinfo, subkeys ); + fetch_reg_keys( newparentinfo->key, subkeys ); regsubkey_ctr_delkey( subkeys, name ); /* now write to the registry backend */ - write_result = store_reg_keys( newparentinfo, subkeys ); + write_result = store_reg_keys( newparentinfo->key, subkeys ); TALLOC_FREE( subkeys ); @@ -1372,7 +1411,7 @@ done: WERROR _winreg_DeleteValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value) { - REGISTRY_KEY *key = find_regkey_index_by_hnd(p, handle); + REGISTRY_KEY *key = find_regkey_by_hnd(p, handle); REGVAL_CTR *values; BOOL write_result; char *valuename; @@ -1417,7 +1456,7 @@ WERROR _winreg_DeleteValue(pipes_struct *p, struct policy_handle *handle, struct WERROR _winreg_GetKeySecurity(pipes_struct *p, struct policy_handle *handle, uint32_t sec_info, struct KeySecurityData *sd) { - REGISTRY_KEY *key = find_regkey_index_by_hnd(p, handle); + REGISTRY_KEY *key = find_regkey_by_hnd(p, handle); if ( !key ) return WERR_BADFID; @@ -1435,7 +1474,7 @@ WERROR _winreg_GetKeySecurity(pipes_struct *p, struct policy_handle *handle, uin WERROR _winreg_SetKeySecurity(pipes_struct *p, struct policy_handle *handle, uint32_t access_mask, struct KeySecurityData *sd) { - REGISTRY_KEY *key = find_regkey_index_by_hnd(p, handle); + REGISTRY_KEY *key = find_regkey_by_hnd(p, handle); if ( !key ) return WERR_BADFID; -- cgit From 015534e254797eb114f1a3bc747b666d8bd65a2e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 23 Nov 2006 22:58:50 +0000 Subject: r19872: Move the value cache to srv_winreg_nt.c. Fix some minor issues found while playing with regedit.exe. Volker (This used to be commit 81bd816fa2afe89261aff2f395e8d056b73e515c) --- source3/rpc_server/srv_winreg_nt.c | 169 ++++++++++++++++++++++--------------- 1 file changed, 100 insertions(+), 69 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 5342a9512c..ffce49cd9c 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -32,6 +32,7 @@ static struct generic_mapping reg_generic_map = struct regkey_info { REGISTRY_KEY *key; + REGVAL_CTR *value_cache; }; /****************************************************************** @@ -73,6 +74,23 @@ static REGISTRY_KEY *find_regkey_by_hnd(pipes_struct *p, POLICY_HND *hnd) return regkey->key; } +static WERROR fill_value_cache(struct regkey_info *info) +{ + if (info->value_cache != NULL) { + return WERR_OK; + } + + if (!(info->value_cache = TALLOC_ZERO_P(info, REGVAL_CTR))) { + return WERR_NOMEM; + } + + if (fetch_reg_values(info->key, info->value_cache) == -1) { + TALLOC_FREE(info->value_cache); + return WERR_BADFILE; + } + + return WERR_OK; +} /******************************************************************* Function for open a new registry handle and creating a handle @@ -382,7 +400,8 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, uint32_t *data_size, uint32_t *value_length) { WERROR status = WERR_BADFILE; - REGISTRY_KEY *regkey = find_regkey_by_hnd( p, handle ); + struct regkey_info *info = find_regkey_info_by_hnd( p, handle ); + REGISTRY_KEY *regkey; prs_struct prs_hkpd; uint8_t *outbuf; @@ -391,9 +410,11 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, BOOL free_buf = False; BOOL free_prs = False; - if ( !regkey ) + if ( !info ) return WERR_BADFID; + regkey = info->key; + *value_length = *type = 0; DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); @@ -440,41 +461,36 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, *type = REG_BINARY; } else { - /* HKPT calls can be handled out of reg_dynamic.c with the - * hkpt_params handler */ - - REGVAL_CTR *regvals; + REGISTRY_VALUE *val = NULL; uint32 i; - if (!(regvals = TALLOC_ZERO_P(p->mem_ctx, REGVAL_CTR))) { - return WERR_NOMEM; - } - - /* - * Don't use fetch_reg_values_specific here, there is too much - * memory copying around. I'll re-add the cache later. VL - */ + status = fill_value_cache(info); - if (fetch_reg_values(regkey, regvals) == -1) { - TALLOC_FREE(regvals); - return WERR_BADFILE; + if (!(W_ERROR_IS_OK(status))) { + return status; } - - for (i=0; inum_values; i++) { - if (strequal(regvals->values[i]->valuename, + + for (i=0; ivalue_cache->num_values; i++) { + if (strequal(info->value_cache->values[i]->valuename, value_name.name)) { + val = info->value_cache->values[i]; break; } } - if (i == regvals->num_values) { - TALLOC_FREE(regvals); + if (val == NULL) { + if (data_size) { + *data_size = 0; + } + if (value_length) { + *value_length = 0; + } return WERR_BADFILE; } - outbuf = regvals->values[i]->data_p; - outbuf_size = regvals->values[i]->size; - *type = regvals->values[i]->type; + outbuf = val->data_p; + outbuf_size = val->size; + *type = val->type; } *value_length = outbuf_size; @@ -596,31 +612,40 @@ done: Implementation of REG_ENUM_VALUE ****************************************************************************/ -WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_StringBuf *name, enum winreg_Type *type, uint8_t *data, uint32_t *data_size, uint32_t *value_length) +WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, + uint32_t enum_index, struct winreg_StringBuf *name, + enum winreg_Type *type, uint8_t *data, + uint32_t *data_size, uint32_t *value_length) { WERROR status = WERR_OK; - REGISTRY_KEY *regkey = find_regkey_by_hnd( p, handle ); - REGISTRY_VALUE *val; + struct regkey_info *info = find_regkey_info_by_hnd( p, handle ); + REGISTRY_KEY *regkey; + REGISTRY_VALUE *val = NULL; - if ( !regkey ) - return WERR_BADFID; + if ( !info ) + return WERR_BADFID; if ( !name ) return WERR_INVALID_PARAM; + + regkey = info->key; - DEBUG(8,("_winreg_EnumValue: enumerating values for key [%s]\n", regkey->name)); + DEBUG(8,("_winreg_EnumValue: enumerating values for key [%s]\n", + regkey->name)); - if ( !fetch_reg_values_specific( regkey, &val, enum_index ) ) { - status = WERR_NO_MORE_ITEMS; - goto done; + status = fill_value_cache(info); + if (!W_ERROR_IS_OK(status)) { + return status; } - DEBUG(10,("_winreg_EnumValue: retrieved value named [%s]\n", val->valuename)); - - /* subkey has the string name now */ - - if ( (name->name = talloc_strdup( p->mem_ctx, val->valuename )) == NULL ) { - status = WERR_NOMEM; + if (enum_index >= info->value_cache->num_values) { + return WERR_BADFILE; + } + + val = info->value_cache->values[enum_index]; + + if (!(name->name = talloc_strdup(p->mem_ctx, val->valuename))) { + return WERR_NOMEM; } if (type != NULL) { @@ -629,33 +654,26 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, uint32_t if (data != NULL) { if ((data_size == NULL) || (value_length == NULL)) { - status = WERR_INVALID_PARAM; - goto done; + return WERR_INVALID_PARAM; } - if (regval_size(val) > *data_size) { - status = WERR_MORE_DATA; - goto done; + if (val->size > *data_size) { + return WERR_MORE_DATA; } - memcpy( data, regval_data_p(val), regval_size(val) ); - status = WERR_OK; + memcpy( data, val->data_p, val->size ); } if (value_length != NULL) { - *value_length = regval_size( val ); + *value_length = val->size; } if (data_size != NULL) { - *data_size = regval_size( val ); + *data_size = val->size; } -done: - free_registry_value( val ); - - return status; + return WERR_OK; } - /******************************************************************* reg_shutdwon ********************************************************************/ @@ -1275,26 +1293,31 @@ done: WERROR _winreg_SetValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String name, enum winreg_Type type, uint8_t *data, uint32_t size) { - REGISTRY_KEY *key = find_regkey_by_hnd(p, handle); + struct regkey_info *info = find_regkey_info_by_hnd(p, handle); + REGISTRY_KEY *key; REGVAL_CTR *values; BOOL write_result; - char *valuename; - if ( !key ) + if ( !info ) return WERR_BADFID; + + key = info->key; + + if (!name.name || (strlen(name.name) == 0)) { + /* + * This is the "Standard Value" for a key, we don't support + * that (yet...) + */ + return WERR_ACCESS_DENIED; + } /* access checks first */ if ( !(key->access_granted & SEC_RIGHTS_SET_VALUE) ) return WERR_ACCESS_DENIED; - /* verify the name */ - - if ( (valuename = talloc_strdup(p->mem_ctx, name.name)) == NULL ) { - return WERR_INVALID_PARAM; - } - - DEBUG(8,("_reg_set_value: Setting value for [%s:%s]\n", key->name, valuename)); + DEBUG(8,("_reg_set_value: Setting value for [%s:%s]\n", key->name, + name.name)); if ( !(values = TALLOC_ZERO_P( p->mem_ctx, REGVAL_CTR )) ) return WERR_NOMEM; @@ -1303,7 +1326,8 @@ WERROR _winreg_SetValue(pipes_struct *p, struct policy_handle *handle, struct wi fetch_reg_values( key, values ); - regval_ctr_addvalue( values, valuename, type, (const char *)data, size ); + regval_ctr_addvalue( values, name.name, type, + (const char *)data, size ); /* now write to the registry backend */ @@ -1313,7 +1337,9 @@ WERROR _winreg_SetValue(pipes_struct *p, struct policy_handle *handle, struct wi if ( !write_result ) return WERR_REG_IO_FAILURE; - + + TALLOC_FREE(info->value_cache); + return WERR_OK; } @@ -1411,13 +1437,16 @@ done: WERROR _winreg_DeleteValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value) { - REGISTRY_KEY *key = find_regkey_by_hnd(p, handle); + struct regkey_info *info = find_regkey_info_by_hnd(p, handle); + REGISTRY_KEY *key; REGVAL_CTR *values; BOOL write_result; char *valuename; - if ( !key ) + if ( !info ) return WERR_BADFID; + + key = info->key; /* access checks first */ @@ -1447,7 +1476,9 @@ WERROR _winreg_DeleteValue(pipes_struct *p, struct policy_handle *handle, struct if ( !write_result ) return WERR_REG_IO_FAILURE; - + + TALLOC_FREE(info->value_cache); + return WERR_OK; } -- cgit From b189e6d76edc5e2080f9b7f29aae07cde7aa6308 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 27 Nov 2006 07:41:59 +0000 Subject: r19912: Move the subkey cache to srv_winreg_nt.c (This used to be commit 01a53590a6325413551016effe302585a3a1e656) --- source3/rpc_server/srv_winreg_nt.c | 41 ++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index ffce49cd9c..ce3e2e4b7d 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -33,6 +33,7 @@ static struct generic_mapping reg_generic_map = struct regkey_info { REGISTRY_KEY *key; REGVAL_CTR *value_cache; + REGSUBKEY_CTR *subkey_cache; }; /****************************************************************** @@ -576,35 +577,47 @@ WERROR _winreg_GetVersion(pipes_struct *p, struct policy_handle *handle, uint32_ WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_StringBuf *name, struct winreg_StringBuf *keyclass, NTTIME *last_changed_time) { WERROR status = WERR_OK; - REGISTRY_KEY *regkey = find_regkey_by_hnd( p, handle ); - char *subkey = NULL; - + struct regkey_info *info = find_regkey_info_by_hnd( p, handle ); + REGISTRY_KEY *regkey; - if ( !regkey ) + if ( !info ) return WERR_BADFID; + regkey = info->key; + if ( !name || !keyclass ) return WERR_INVALID_PARAM; DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", regkey->name)); - if ( !fetch_reg_keys_specific( regkey, &subkey, enum_index ) ) { - status = WERR_NO_MORE_ITEMS; - goto done; + if (!info->subkey_cache) { + if (!(info->subkey_cache = TALLOC_ZERO_P( + info, REGSUBKEY_CTR))) { + return WERR_NOMEM; } - DEBUG(10,("_reg_enum_key: retrieved subkey named [%s]\n", subkey)); + if (fetch_reg_keys(regkey, info->subkey_cache) == -1) { + TALLOC_FREE(info->subkey_cache); + return WERR_NO_MORE_ITEMS; + } + } + + if (enum_index >= info->subkey_cache->num_subkeys) { + return WERR_NO_MORE_ITEMS; + } + + DEBUG(10,("_reg_enum_key: retrieved subkey named [%s]\n", + info->subkey_cache->subkeys[enum_index])); + if (!(name->name = talloc_strdup( + p->mem_ctx, info->subkey_cache->subkeys[enum_index]))) { + status = WERR_NOMEM; + } if ( last_changed_time ) { *last_changed_time = 0; } keyclass->name = ""; - if ( (name->name = talloc_strdup( p->mem_ctx, subkey )) == NULL ) { - status = WERR_NOMEM; - } -done: - SAFE_FREE( subkey ); return status; } @@ -1261,6 +1274,7 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, write_result = store_reg_keys( newparentinfo->key, subkeys ); TALLOC_FREE( subkeys ); + TALLOC_FREE( newparentinfo->subkey_cache ); if ( !write_result ) return WERR_REG_IO_FAILURE; @@ -1419,6 +1433,7 @@ WERROR _winreg_DeleteKey(pipes_struct *p, struct policy_handle *handle, struct w write_result = store_reg_keys( newparentinfo->key, subkeys ); TALLOC_FREE( subkeys ); + TALLOC_FREE( newparentinfo->subkey_cache ); result = write_result ? WERR_OK : WERR_REG_IO_FAILURE; -- cgit From f57cd1f63c900a7b17955cc7e11cd1f6b6b12474 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 27 Nov 2006 07:52:46 +0000 Subject: r19914: The "default" value with the name "" need different 0-length treatment as the other StringBufs, otherwise clicking on a key with this value being set leads to regedit.exe on w2k3 chew all memory. (This used to be commit b148cde7f39859102288a87b6f0bd2b250947a85) --- source3/rpc_server/srv_winreg_nt.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index ce3e2e4b7d..cac06888e4 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -626,7 +626,7 @@ WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t e ****************************************************************************/ WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, - uint32_t enum_index, struct winreg_StringBuf *name, + uint32_t enum_index, struct winreg_ValNameBuf *name, enum winreg_Type *type, uint8_t *data, uint32_t *data_size, uint32_t *value_length) { @@ -1317,14 +1317,6 @@ WERROR _winreg_SetValue(pipes_struct *p, struct policy_handle *handle, struct wi key = info->key; - if (!name.name || (strlen(name.name) == 0)) { - /* - * This is the "Standard Value" for a key, we don't support - * that (yet...) - */ - return WERR_ACCESS_DENIED; - } - /* access checks first */ if ( !(key->access_granted & SEC_RIGHTS_SET_VALUE) ) -- cgit From 2d6e409dc237035fd6c53bc45e6d822ad7776731 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 27 Nov 2006 08:05:42 +0000 Subject: r19915: Fix two type-punned warnings (This used to be commit f1266475daa3687e0b0dc5333a6fbd12a9640c3a) --- source3/rpc_server/srv_winreg_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index cac06888e4..623aab8523 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -434,13 +434,13 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, else if(strequal(value_name.name, "Counter 009")) { outbuf_size = reg_perfcount_get_counter_names( reg_perfcount_get_base_index(), - (char **)&outbuf); + (char **)(void *)&outbuf); free_buf = True; } else if(strequal(value_name.name, "Explain 009")) { outbuf_size = reg_perfcount_get_counter_help( reg_perfcount_get_base_index(), - (char **)&outbuf); + (char **)(void *)&outbuf); free_buf = True; } else if(isdigit(value_name.name[0])) { -- cgit From 4a361ffd7f0b62f05e552c6da926881cd1f756a0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 27 Nov 2006 14:05:28 +0000 Subject: r19918: Convert winreg_CreateKey to use a ref ** instead of a unique *. W2k3 can still create keys on Samba and vice versa. Jelmer, please check. Thanks, Volker (This used to be commit 1b460d6cdfe0cadd915a5299e6ca9bb359bf0075) --- source3/rpc_server/srv_winreg_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 623aab8523..2b7bd41a62 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -1196,7 +1196,7 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, uint32_t options, uint32_t access_mask, struct winreg_SecBuf *secdesc, struct policy_handle *new_handle, - enum winreg_CreateAction *action_taken ) + enum winreg_CreateAction **action_taken ) { struct regkey_info *parent = find_regkey_info_by_hnd(p, handle); struct regkey_info *newparentinfo, *keyinfo; @@ -1288,8 +1288,8 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, /* FIXME: report the truth here */ - if ( action_taken ) { - *action_taken = REG_CREATED_NEW_KEY; + if ( *action_taken ) { + **action_taken = REG_CREATED_NEW_KEY; } done: -- cgit From 8e8821b1dae2c32ecc9a7900fd0f30ec0a32ba4e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 27 Nov 2006 14:29:55 +0000 Subject: r19919: Convert winreg_EnumKey to use ref ** instead of a unique *. Volker (This used to be commit b714b51884af0d79de8568410676d4889f23ffb6) --- source3/rpc_server/srv_winreg_nt.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 2b7bd41a62..4138d1f1fc 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -574,7 +574,10 @@ WERROR _winreg_GetVersion(pipes_struct *p, struct policy_handle *handle, uint32_ Implementation of REG_ENUM_KEY ****************************************************************************/ -WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_StringBuf *name, struct winreg_StringBuf *keyclass, NTTIME *last_changed_time) +WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, + uint32_t enum_index, struct winreg_StringBuf *name, + struct winreg_StringBuf **keyclass, + NTTIME **last_changed_time) { WERROR status = WERR_OK; struct regkey_info *info = find_regkey_info_by_hnd( p, handle ); @@ -613,10 +616,12 @@ WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t e p->mem_ctx, info->subkey_cache->subkeys[enum_index]))) { status = WERR_NOMEM; } - if ( last_changed_time ) { - *last_changed_time = 0; + if ( *last_changed_time ) { + **last_changed_time = 0; + } + if ( *keyclass ) { + (*keyclass)->name = ""; } - keyclass->name = ""; return status; } -- cgit From 7ef185fae7fc43b566dedb267023cf8d346baee2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 28 Nov 2006 12:18:00 +0000 Subject: r19929: Fix indentation (This used to be commit 2369ad08529d31bb77b9cb5378d0114669cdf8a8) --- source3/rpc_server/srv_winreg_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 4138d1f1fc..79a2d82ae1 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -597,7 +597,7 @@ WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, if (!(info->subkey_cache = TALLOC_ZERO_P( info, REGSUBKEY_CTR))) { return WERR_NOMEM; - } + } if (fetch_reg_keys(regkey, info->subkey_cache) == -1) { TALLOC_FREE(info->subkey_cache); -- cgit From f1d492d11f4da7bbff883fefc3d8fcb71f08f67b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 28 Nov 2006 13:09:32 +0000 Subject: r19930: Revert the winreg idl changes. At least enumkey does not work anymore today. With more than 5 different trees I can't swear that I did test this properly yesterday. Sorry for the noise. Volker (This used to be commit 978a6196bf0a2280c7f74b4a6d9fa7941c3aa049) --- source3/rpc_server/srv_winreg_nt.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 79a2d82ae1..52de236bce 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -574,10 +574,7 @@ WERROR _winreg_GetVersion(pipes_struct *p, struct policy_handle *handle, uint32_ Implementation of REG_ENUM_KEY ****************************************************************************/ -WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, - uint32_t enum_index, struct winreg_StringBuf *name, - struct winreg_StringBuf **keyclass, - NTTIME **last_changed_time) +WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_StringBuf *name, struct winreg_StringBuf *keyclass, NTTIME *last_changed_time) { WERROR status = WERR_OK; struct regkey_info *info = find_regkey_info_by_hnd( p, handle ); @@ -616,12 +613,10 @@ WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, p->mem_ctx, info->subkey_cache->subkeys[enum_index]))) { status = WERR_NOMEM; } - if ( *last_changed_time ) { - **last_changed_time = 0; - } - if ( *keyclass ) { - (*keyclass)->name = ""; + if ( last_changed_time ) { + *last_changed_time = 0; } + keyclass->name = ""; return status; } @@ -1201,7 +1196,7 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, uint32_t options, uint32_t access_mask, struct winreg_SecBuf *secdesc, struct policy_handle *new_handle, - enum winreg_CreateAction **action_taken ) + enum winreg_CreateAction *action_taken ) { struct regkey_info *parent = find_regkey_info_by_hnd(p, handle); struct regkey_info *newparentinfo, *keyinfo; @@ -1293,8 +1288,8 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, /* FIXME: report the truth here */ - if ( *action_taken ) { - **action_taken = REG_CREATED_NEW_KEY; + if ( action_taken ) { + *action_taken = REG_CREATED_NEW_KEY; } done: -- cgit From 1c91cca86eacc74c2785c54bc75c5ff18d7a773d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 29 Nov 2006 10:51:00 +0000 Subject: r19947: Change regkey_open_internal to take the parent key and a talloc_ctx as arguments. This also replaces regkey_close_internal by TALLOC_FREE. Volker (This used to be commit a177bbb2d5611f03cec25b7577c2e6a542f94a69) --- source3/rpc_server/srv_eventlog_nt.c | 7 +++---- source3/rpc_server/srv_winreg_nt.c | 19 +------------------ 2 files changed, 4 insertions(+), 22 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index ec07981de9..73dfd42184 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -411,9 +411,8 @@ static BOOL sync_eventlog_params( EVENTLOG_INFO *info ) pstr_sprintf( path, "%s/%s", KEY_EVENTLOG, elogname ); - wresult = - regkey_open_internal( &keyinfo, path, get_root_nt_token( ), - REG_KEY_READ ); + wresult = regkey_open_internal( NULL, NULL, &keyinfo, path, + get_root_nt_token( ), REG_KEY_READ ); if ( !W_ERROR_IS_OK( wresult ) ) { DEBUG( 4, @@ -436,7 +435,7 @@ static BOOL sync_eventlog_params( EVENTLOG_INFO *info ) if ( ( val = regval_ctr_getvalue( values, "MaxSize" ) ) != NULL ) uiMaxSize = IVAL( regval_data_p( val ), 0 ); - regkey_close_internal( keyinfo ); + TALLOC_FREE( keyinfo ); tdb_store_int32( ELOG_TDB_CTX(info->etdb), EVT_MAXSIZE, uiMaxSize ); tdb_store_int32( ELOG_TDB_CTX(info->etdb), EVT_RETENTION, uiRetention ); diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 52de236bce..16c271427e 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -43,7 +43,6 @@ struct regkey_info { static void free_regkey_info(void *ptr) { struct regkey_info *info = (struct regkey_info *)ptr; - regkey_close_internal( info->key ); TALLOC_FREE(info); } @@ -107,36 +106,21 @@ static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, const char *subkeyname, uint32 access_desired ) { - char *keypath; - int path_len; WERROR result = WERR_OK; struct regkey_info *info; /* create a full registry path and strip any trailing '\' characters */ - if (asprintf(&keypath, "%s%s%s", - parent ? parent->name : "", - parent ? "\\" : "", - subkeyname) == -1) { - return WERR_NOMEM; - } - - path_len = strlen( keypath ); - if ( path_len && keypath[path_len-1] == '\\' ) - keypath[path_len-1] = '\0'; - if (!(info = TALLOC_ZERO_P(NULL, struct regkey_info))) { - SAFE_FREE(keypath); return WERR_NOMEM; } /* now do the internal open */ - result = regkey_open_internal( &info->key, keypath, + result = regkey_open_internal( info, parent, &info->key, subkeyname, p->pipe_user.nt_user_token, access_desired ); - SAFE_FREE(keypath); if ( !W_ERROR_IS_OK(result) ) { TALLOC_FREE(info); @@ -144,7 +128,6 @@ static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, } if ( !create_policy_hnd( p, hnd, free_regkey_info, info ) ) { - regkey_close_internal( info->key ); TALLOC_FREE(info); return WERR_BADFILE; } -- cgit From 575845ccbeb2acc5dcb5133b80fd19b1d80169f2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 30 Nov 2006 07:38:40 +0000 Subject: r19963: Add 'registry shares = yes' and registry key security descriptors. (This used to be commit 6cab254c49e07b11c170511ec613f0f33914c3e6) --- source3/rpc_server/srv_srvsvc_nt.c | 1 + source3/rpc_server/srv_winreg_nt.c | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 35938d087e..ac9a1132e1 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -516,6 +516,7 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, /* Ensure all the usershares are loaded. */ become_root(); load_usershare_shares(); + load_registry_shares(); unbecome_root(); *total_entries = 0; diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 16c271427e..847bc967c5 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -1478,6 +1478,10 @@ WERROR _winreg_DeleteValue(pipes_struct *p, struct policy_handle *handle, struct WERROR _winreg_GetKeySecurity(pipes_struct *p, struct policy_handle *handle, uint32_t sec_info, struct KeySecurityData *sd) { REGISTRY_KEY *key = find_regkey_by_hnd(p, handle); + WERROR err; + struct security_descriptor *secdesc; + uint8 *data; + size_t len; if ( !key ) return WERR_BADFID; @@ -1486,8 +1490,28 @@ WERROR _winreg_GetKeySecurity(pipes_struct *p, struct policy_handle *handle, uin if ( !(key->access_granted & STD_RIGHT_READ_CONTROL_ACCESS) ) return WERR_ACCESS_DENIED; + + err = regkey_get_secdesc(p->mem_ctx, key, &secdesc); + if (!W_ERROR_IS_OK(err)) { + return err; + } + + err = ntstatus_to_werror(marshall_sec_desc(p->mem_ctx, secdesc, + &data, &len)); + if (!W_ERROR_IS_OK(err)) { + return err; + } + + if (len > sd->size) { + sd->size = len; + return WERR_INSUFFICIENT_BUFFER; + } + + sd->size = len; + sd->len = len; + sd->data = data; - return WERR_ACCESS_DENIED; + return WERR_OK; } /******************************************************************* @@ -1496,6 +1520,8 @@ WERROR _winreg_GetKeySecurity(pipes_struct *p, struct policy_handle *handle, uin WERROR _winreg_SetKeySecurity(pipes_struct *p, struct policy_handle *handle, uint32_t access_mask, struct KeySecurityData *sd) { REGISTRY_KEY *key = find_regkey_by_hnd(p, handle); + struct security_descriptor *secdesc; + WERROR err; if ( !key ) return WERR_BADFID; @@ -1504,8 +1530,14 @@ WERROR _winreg_SetKeySecurity(pipes_struct *p, struct policy_handle *handle, uin if ( !(key->access_granted & STD_RIGHT_WRITE_DAC_ACCESS) ) return WERR_ACCESS_DENIED; - - return WERR_ACCESS_DENIED; + + err = ntstatus_to_werror(unmarshall_sec_desc(p->mem_ctx, sd->data, + sd->len, &secdesc)); + if (!W_ERROR_IS_OK(err)) { + return err; + } + + return regkey_set_secdesc(key, secdesc); } /******************************************************************* -- cgit From ecf90c495eb850cd6f376fb4e090640b69f0c029 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 1 Dec 2006 20:01:09 +0000 Subject: r19991: Sorry for this 2000-liner... The main thing here is a rewrite of srv_winreg_nt.c. The core functionality has moved to registry/reg_api.c which is then usable by the rest of Samba as well. On that way it fixes creating keys with more than one element in the path. This did not work before. Two things that sneaked in (sorry :-) is the change of some routines from NTSTATUS to WERROR the removed "parent" argument to regkey_open_internal. Volker (This used to be commit fea52801de8c7b85c578d200c599475680c5339f) --- source3/rpc_server/srv_eventlog_nt.c | 2 +- source3/rpc_server/srv_winreg_nt.c | 703 ++++++++--------------------------- 2 files changed, 155 insertions(+), 550 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 73dfd42184..6911bdcd3b 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -411,7 +411,7 @@ static BOOL sync_eventlog_params( EVENTLOG_INFO *info ) pstr_sprintf( path, "%s/%s", KEY_EVENTLOG, elogname ); - wresult = regkey_open_internal( NULL, NULL, &keyinfo, path, + wresult = regkey_open_internal( NULL, &keyinfo, path, get_root_nt_token( ), REG_KEY_READ ); if ( !W_ERROR_IS_OK( wresult ) ) { diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 847bc967c5..4b394428c3 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -30,30 +30,24 @@ static struct generic_mapping reg_generic_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; -struct regkey_info { - REGISTRY_KEY *key; - REGVAL_CTR *value_cache; - REGSUBKEY_CTR *subkey_cache; -}; - /****************************************************************** free() function for struct regkey_info *****************************************************************/ -static void free_regkey_info(void *ptr) +static void free_regkey(void *ptr) { - struct regkey_info *info = (struct regkey_info *)ptr; - TALLOC_FREE(info); + struct registry_key *key = (struct registry_key *)ptr; + TALLOC_FREE(key); } /****************************************************************** Find a registry key handle and return a REGISTRY_KEY *****************************************************************/ -static struct regkey_info *find_regkey_info_by_hnd(pipes_struct *p, - POLICY_HND *hnd) +static struct registry_key *find_regkey_by_hnd(pipes_struct *p, + POLICY_HND *hnd) { - struct regkey_info *regkey = NULL; + struct registry_key *regkey = NULL; if(!find_policy_by_hnd(p,hnd,(void **)(void *)®key)) { DEBUG(2,("find_regkey_index_by_hnd: Registry Key not found: ")); @@ -63,35 +57,6 @@ static struct regkey_info *find_regkey_info_by_hnd(pipes_struct *p, return regkey; } -static REGISTRY_KEY *find_regkey_by_hnd(pipes_struct *p, POLICY_HND *hnd) -{ - struct regkey_info *regkey = find_regkey_info_by_hnd(p, hnd); - - if (regkey == NULL) { - return NULL; - } - - return regkey->key; -} - -static WERROR fill_value_cache(struct regkey_info *info) -{ - if (info->value_cache != NULL) { - return WERR_OK; - } - - if (!(info->value_cache = TALLOC_ZERO_P(info, REGVAL_CTR))) { - return WERR_NOMEM; - } - - if (fetch_reg_values(info->key, info->value_cache) == -1) { - TALLOC_FREE(info->value_cache); - return WERR_BADFILE; - } - - return WERR_OK; -} - /******************************************************************* Function for open a new registry handle and creating a handle Note that P should be valid & hnd should already have space @@ -101,40 +66,31 @@ static WERROR fill_value_cache(struct regkey_info *info) *******************************************************************/ static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, - struct regkey_info **pinfo, - REGISTRY_KEY *parent, + struct registry_key *parent, const char *subkeyname, uint32 access_desired ) { - WERROR result = WERR_OK; - struct regkey_info *info; + WERROR result = WERR_OK; + struct registry_key *key; - /* create a full registry path and strip any trailing '\' - characters */ + /* now do the internal open */ - if (!(info = TALLOC_ZERO_P(NULL, struct regkey_info))) { - return WERR_NOMEM; + if (parent == NULL) { + result = reg_openhive(NULL, subkeyname, access_desired, + p->pipe_user.nt_user_token, &key); + } + else { + result = reg_openkey(NULL, parent, subkeyname, access_desired, + &key); } - - /* now do the internal open */ - - result = regkey_open_internal( info, parent, &info->key, subkeyname, - p->pipe_user.nt_user_token, - access_desired ); if ( !W_ERROR_IS_OK(result) ) { - TALLOC_FREE(info); return result; } - if ( !create_policy_hnd( p, hnd, free_regkey_info, info ) ) { - TALLOC_FREE(info); + if ( !create_policy_hnd( p, hnd, free_regkey, key ) ) { return WERR_BADFILE; } - - if (pinfo) { - *pinfo = info; - } return WERR_OK;; } @@ -146,10 +102,11 @@ static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd) { - REGISTRY_KEY *regkey = find_regkey_by_hnd(p, hnd); + struct registry_key *regkey = find_regkey_by_hnd(p, hnd); if ( !regkey ) { - DEBUG(2,("close_registry_key: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(hnd))); + DEBUG(2,("close_registry_key: Invalid handle (%s:%u:%u)\n", + OUR_HANDLE(hnd))); return False; } @@ -158,89 +115,6 @@ static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd) return True; } -/******************************************************************** - retrieve information about the subkeys - *******************************************************************/ - -static BOOL get_subkey_information( REGISTRY_KEY *key, uint32 *maxnum, uint32 *maxlen ) -{ - int num_subkeys, i; - uint32 max_len; - REGSUBKEY_CTR *subkeys; - uint32 len; - - if ( !key ) - return False; - - if ( !(subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR )) ) - return False; - - if ( fetch_reg_keys( key, subkeys ) == -1 ) - return False; - - /* find the longest string */ - - max_len = 0; - num_subkeys = regsubkey_ctr_numkeys( subkeys ); - - for ( i=0; ivaluename ? - strlen(val->valuename)+1 : 0 ); - sizemax = MAX(sizemax, val->size ); - } - - *maxnum = num_values; - *maxlen = lenmax*2; - *maxsize = sizemax; - - TALLOC_FREE( values ); - - return True; -} - - /******************************************************************** reg_close ********************************************************************/ @@ -260,7 +134,7 @@ WERROR _winreg_CloseKey(pipes_struct *p, struct policy_handle *handle) WERROR _winreg_OpenHKLM(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { - return open_registry_key(p, handle, NULL, NULL, KEY_HKLM, access_mask); + return open_registry_key(p, handle, NULL, KEY_HKLM, access_mask); } /******************************************************************* @@ -269,7 +143,7 @@ WERROR _winreg_OpenHKLM(pipes_struct *p, uint16_t *system_name, uint32_t access_ WERROR _winreg_OpenHKPD(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { - return open_registry_key(p, handle, NULL, NULL, KEY_HKPD, access_mask); + return open_registry_key(p, handle, NULL, KEY_HKPD, access_mask); } /******************************************************************* @@ -278,7 +152,7 @@ WERROR _winreg_OpenHKPD(pipes_struct *p, uint16_t *system_name, WERROR _winreg_OpenHKPT(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { - return open_registry_key(p, handle, NULL, NULL, KEY_HKPT, access_mask); + return open_registry_key(p, handle, NULL, KEY_HKPT, access_mask); } /******************************************************************* @@ -287,7 +161,7 @@ WERROR _winreg_OpenHKPT(pipes_struct *p, uint16_t *system_name, WERROR _winreg_OpenHKCR(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { - return open_registry_key(p, handle, NULL, NULL, KEY_HKCR, access_mask); + return open_registry_key(p, handle, NULL, KEY_HKCR, access_mask); } /******************************************************************* @@ -296,7 +170,7 @@ WERROR _winreg_OpenHKCR(pipes_struct *p, uint16_t *system_name, WERROR _winreg_OpenHKU(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { - return open_registry_key(p, handle, NULL, NULL, KEY_HKU, access_mask); + return open_registry_key(p, handle, NULL, KEY_HKU, access_mask); } /******************************************************************* @@ -305,7 +179,7 @@ WERROR _winreg_OpenHKU(pipes_struct *p, uint16_t *system_name, WERROR _winreg_OpenHKCU(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { - return open_registry_key(p, handle, NULL, NULL, KEY_HKCU, access_mask); + return open_registry_key(p, handle, NULL, KEY_HKCU, access_mask); } /******************************************************************* @@ -314,7 +188,7 @@ WERROR _winreg_OpenHKCU(pipes_struct *p, uint16_t *system_name, WERROR _winreg_OpenHKCC(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { - return open_registry_key(p, handle, NULL, NULL, KEY_HKCC, access_mask); + return open_registry_key(p, handle, NULL, KEY_HKCC, access_mask); } /******************************************************************* @@ -323,7 +197,7 @@ WERROR _winreg_OpenHKCC(pipes_struct *p, uint16_t *system_name, WERROR _winreg_OpenHKDD(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { - return open_registry_key(p, handle, NULL, NULL, KEY_HKDD, access_mask); + return open_registry_key(p, handle, NULL, KEY_HKDD, access_mask); } /******************************************************************* @@ -332,46 +206,23 @@ WERROR _winreg_OpenHKDD(pipes_struct *p, uint16_t *system_name, WERROR _winreg_OpenHKPN(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) { - return open_registry_key(p, handle, NULL, NULL, KEY_HKPN, access_mask); + return open_registry_key(p, handle, NULL, KEY_HKPN, access_mask); } /******************************************************************* reg_reply_open_entry ********************************************************************/ -WERROR _winreg_OpenKey(pipes_struct *p, struct policy_handle *parent_handle, struct winreg_String keyname, uint32_t unknown, uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenKey(pipes_struct *p, struct policy_handle *parent_handle, + struct winreg_String keyname, uint32_t unknown, + uint32_t access_mask, struct policy_handle *handle) { - char *name; - REGISTRY_KEY *parent = find_regkey_by_hnd(p, parent_handle ); - uint32 check_rights; + struct registry_key *parent = find_regkey_by_hnd(p, parent_handle ); if ( !parent ) return WERR_BADFID; - if ( (name = talloc_strdup( p->mem_ctx, keyname.name )) == NULL ) { - return WERR_INVALID_PARAM; - } - - /* check granted access first; what is the correct mask here? */ - - check_rights = ( SEC_RIGHTS_ENUM_SUBKEYS| - SEC_RIGHTS_CREATE_SUBKEY| - SEC_RIGHTS_QUERY_VALUE| - SEC_RIGHTS_SET_VALUE); - - if ( !(parent->access_granted & check_rights) ) { - DEBUG(8,("Rights check failed, parent had %04x, check_rights %04x\n",parent->access_granted, check_rights)); - return WERR_ACCESS_DENIED; - } - - /* - * very crazy, but regedit.exe on Win2k will attempt to call - * REG_OPEN_ENTRY with a keyname of "". We should return a new - * (second) handle here on the key->name. regedt32.exe does - * not do this stupidity. --jerry - */ - - return open_registry_key( p, handle, NULL, parent, name, access_mask ); + return open_registry_key(p, handle, parent, keyname.name, access_mask); } /******************************************************************* @@ -384,28 +235,26 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, uint32_t *data_size, uint32_t *value_length) { WERROR status = WERR_BADFILE; - struct regkey_info *info = find_regkey_info_by_hnd( p, handle ); - REGISTRY_KEY *regkey; + struct registry_key *regkey = find_regkey_by_hnd( p, handle ); prs_struct prs_hkpd; uint8_t *outbuf; uint32_t outbuf_size; + DATA_BLOB val_blob; BOOL free_buf = False; BOOL free_prs = False; - if ( !info ) + if ( !regkey ) return WERR_BADFID; - regkey = info->key; - *value_length = *type = 0; - DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->name)); - DEBUG(7,("_reg_info: policy key type = [%08x]\n", regkey->type)); + DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->key->name)); + DEBUG(7,("_reg_info: policy key type = [%08x]\n", regkey->key->type)); /* Handle QueryValue calls on HKEY_PERFORMANCE_DATA */ - if(regkey->type == REG_KEY_HKPD) + if(regkey->key->type == REG_KEY_HKPD) { if(strequal(value_name.name, "Global")) { prs_init(&prs_hkpd, *data_size, p->mem_ctx, MARSHALL); @@ -445,35 +294,27 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, *type = REG_BINARY; } else { - REGISTRY_VALUE *val = NULL; - uint32 i; - - status = fill_value_cache(info); + struct registry_value *val; - if (!(W_ERROR_IS_OK(status))) { - return status; - } - - for (i=0; ivalue_cache->num_values; i++) { - if (strequal(info->value_cache->values[i]->valuename, - value_name.name)) { - val = info->value_cache->values[i]; - break; - } - } - - if (val == NULL) { + status = reg_queryvalue(p->mem_ctx, regkey, value_name.name, + &val); + if (!W_ERROR_IS_OK(status)) { if (data_size) { *data_size = 0; } if (value_length) { *value_length = 0; } - return WERR_BADFILE; + return status; } - outbuf = val->data_p; - outbuf_size = val->size; + status = registry_push_value(p->mem_ctx, val, &val_blob); + if (!W_ERROR_IS_OK(status)) { + return status; + } + + outbuf = val_blob.data; + outbuf_size = val_blob.length; *type = val->type; } @@ -509,30 +350,32 @@ WERROR _winreg_QueryInfoKey(pipes_struct *p, struct policy_handle *handle, uint32_t *secdescsize, NTTIME *last_changed_time) { WERROR status = WERR_OK; - REGISTRY_KEY *regkey = find_regkey_by_hnd( p, handle ); + struct registry_key *regkey = find_regkey_by_hnd( p, handle ); if ( !regkey ) - return WERR_BADFID; - - if ( !get_subkey_information( regkey, num_subkeys, max_subkeylen) ) { - DEBUG(0,("_winreg_QueryInfoKey: get_subkey_information() failed!\n")); - return WERR_ACCESS_DENIED; - } - - if ( !get_value_information( regkey, num_values, max_valnamelen, max_valbufsize) ) { - DEBUG(0,("_winreg_QueryInfoKey: get_value_information() failed!\n")); - return WERR_ACCESS_DENIED; + return WERR_BADFID; + + classname->name = NULL; + + status = reg_queryinfokey(regkey, num_subkeys, max_subkeylen, + max_subkeysize, num_values, max_valnamelen, + max_valbufsize, secdescsize, + last_changed_time); + if (!W_ERROR_IS_OK(status)) { + return status; } - *secdescsize = 0; /* used to be hard coded for 0x00000078 */ - *last_changed_time = 0; - *max_subkeysize = 0; /* maybe this is the classname length ? */ + /* + * These calculations account for the registry buffers being + * UTF-16. They are inexact at best, but so far they worked. + */ + + *max_subkeylen *= 2; - /* don't bother with class names for now */ - - classname->name = NULL; + *max_valnamelen += 1; + *max_valnamelen *= 2; - return status; + return WERR_OK; } @@ -542,7 +385,7 @@ WERROR _winreg_QueryInfoKey(pipes_struct *p, struct policy_handle *handle, WERROR _winreg_GetVersion(pipes_struct *p, struct policy_handle *handle, uint32_t *version) { - REGISTRY_KEY *regkey = find_regkey_by_hnd( p, handle ); + struct registry_key *regkey = find_regkey_by_hnd( p, handle ); if ( !regkey ) return WERR_BADFID; @@ -559,49 +402,24 @@ WERROR _winreg_GetVersion(pipes_struct *p, struct policy_handle *handle, uint32_ WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_StringBuf *name, struct winreg_StringBuf *keyclass, NTTIME *last_changed_time) { - WERROR status = WERR_OK; - struct regkey_info *info = find_regkey_info_by_hnd( p, handle ); - REGISTRY_KEY *regkey; + WERROR err; + struct registry_key *key = find_regkey_by_hnd( p, handle ); - if ( !info ) + if ( !key ) return WERR_BADFID; - regkey = info->key; - if ( !name || !keyclass ) return WERR_INVALID_PARAM; - DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", regkey->name)); - - if (!info->subkey_cache) { - if (!(info->subkey_cache = TALLOC_ZERO_P( - info, REGSUBKEY_CTR))) { - return WERR_NOMEM; - } - - if (fetch_reg_keys(regkey, info->subkey_cache) == -1) { - TALLOC_FREE(info->subkey_cache); - return WERR_NO_MORE_ITEMS; - } - } - - if (enum_index >= info->subkey_cache->num_subkeys) { - return WERR_NO_MORE_ITEMS; - } + DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", key->key->name)); - DEBUG(10,("_reg_enum_key: retrieved subkey named [%s]\n", - info->subkey_cache->subkeys[enum_index])); - - if (!(name->name = talloc_strdup( - p->mem_ctx, info->subkey_cache->subkeys[enum_index]))) { - status = WERR_NOMEM; - } - if ( last_changed_time ) { - *last_changed_time = 0; + err = reg_enumkey(p->mem_ctx, key, enum_index, (char **)&name->name, + last_changed_time); + if (!W_ERROR_IS_OK(err)) { + return err; } keyclass->name = ""; - - return status; + return WERR_OK; } /***************************************************************************** @@ -613,35 +431,33 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, enum winreg_Type *type, uint8_t *data, uint32_t *data_size, uint32_t *value_length) { - WERROR status = WERR_OK; - struct regkey_info *info = find_regkey_info_by_hnd( p, handle ); - REGISTRY_KEY *regkey; - REGISTRY_VALUE *val = NULL; + WERROR err; + struct registry_key *key = find_regkey_by_hnd( p, handle ); + const char *valname; + struct registry_value *val; + DATA_BLOB value_blob; - if ( !info ) + if ( !key ) return WERR_BADFID; if ( !name ) return WERR_INVALID_PARAM; - regkey = info->key; - DEBUG(8,("_winreg_EnumValue: enumerating values for key [%s]\n", - regkey->name)); + key->key->name)); - status = fill_value_cache(info); - if (!W_ERROR_IS_OK(status)) { - return status; + err = reg_enumvalue(p->mem_ctx, key, enum_index, &valname, &val); + if (!W_ERROR_IS_OK(err)) { + return err; } - if (enum_index >= info->value_cache->num_values) { - return WERR_BADFILE; + err = registry_push_value(p->mem_ctx, val, &value_blob); + if (!W_ERROR_IS_OK(err)) { + return err; } - val = info->value_cache->values[enum_index]; - - if (!(name->name = talloc_strdup(p->mem_ctx, val->valuename))) { - return WERR_NOMEM; + if (name != NULL) { + name->name = valname; } if (type != NULL) { @@ -653,18 +469,18 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, return WERR_INVALID_PARAM; } - if (val->size > *data_size) { + if (value_blob.length > *data_size) { return WERR_MORE_DATA; } - memcpy( data, val->data_p, val->size ); + memcpy( data, value_blob.data, value_blob.length ); } if (value_length != NULL) { - *value_length = val->size; + *value_length = value_blob.length; } if (data_size != NULL) { - *data_size = val->size; + *data_size = value_blob.length; } return WERR_OK; @@ -951,7 +767,7 @@ static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) WERROR _winreg_RestoreKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String *filename, uint32_t flags) { - REGISTRY_KEY *regkey = find_regkey_by_hnd( p, handle ); + struct registry_key *regkey = find_regkey_by_hnd( p, handle ); pstring fname; int snum; @@ -963,7 +779,8 @@ WERROR _winreg_RestoreKey(pipes_struct *p, struct policy_handle *handle, struct pstrcpy( fname, filename->name ); - DEBUG(8,("_winreg_RestoreKey: verifying restore of key [%s] from \"%s\"\n", regkey->name, fname)); + DEBUG(8,("_winreg_RestoreKey: verifying restore of key [%s] from " + "\"%s\"\n", regkey->key->name, fname)); if ( (snum = validate_reg_filename( fname )) == -1 ) return WERR_OBJECT_PATH_INVALID; @@ -973,9 +790,10 @@ WERROR _winreg_RestoreKey(pipes_struct *p, struct policy_handle *handle, struct if ( !user_has_privileges( p->pipe_user.nt_user_token, &se_restore ) ) return WERR_ACCESS_DENIED; - DEBUG(2,("_winreg_RestoreKey: Restoring [%s] from %s in share %s\n", regkey->name, fname, lp_servicename(snum) )); + DEBUG(2,("_winreg_RestoreKey: Restoring [%s] from %s in share %s\n", + regkey->key->name, fname, lp_servicename(snum) )); - return restore_registry_key( regkey, fname ); + return restore_registry_key( regkey->key, fname ); } /******************************************************************** @@ -1136,7 +954,7 @@ static WERROR backup_registry_key ( REGISTRY_KEY *krecord, const char *fname ) WERROR _winreg_SaveKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String *filename, struct KeySecurityAttribute *sec_attrib) { - REGISTRY_KEY *regkey = find_regkey_by_hnd( p, handle ); + struct registry_key *regkey = find_regkey_by_hnd( p, handle ); pstring fname; int snum; @@ -1148,14 +966,16 @@ WERROR _winreg_SaveKey(pipes_struct *p, struct policy_handle *handle, struct win pstrcpy( fname, filename->name ); - DEBUG(8,("_winreg_SaveKey: verifying backup of key [%s] to \"%s\"\n", regkey->name, fname)); + DEBUG(8,("_winreg_SaveKey: verifying backup of key [%s] to \"%s\"\n", + regkey->key->name, fname)); if ( (snum = validate_reg_filename( fname )) == -1 ) return WERR_OBJECT_PATH_INVALID; - DEBUG(2,("_winreg_SaveKey: Saving [%s] to %s in share %s\n", regkey->name, fname, lp_servicename(snum) )); + DEBUG(2,("_winreg_SaveKey: Saving [%s] to %s in share %s\n", + regkey->key->name, fname, lp_servicename(snum) )); - return backup_registry_key( regkey, fname ); + return backup_registry_key( regkey->key, fname ); } /******************************************************************* @@ -1181,303 +1001,88 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, struct policy_handle *new_handle, enum winreg_CreateAction *action_taken ) { - struct regkey_info *parent = find_regkey_info_by_hnd(p, handle); - struct regkey_info *newparentinfo, *keyinfo; - POLICY_HND newparent_handle; - REGSUBKEY_CTR *subkeys; - BOOL write_result; - char *name; + struct registry_key *parent = find_regkey_by_hnd(p, handle); + struct registry_key *new_key; WERROR result; if ( !parent ) return WERR_BADFID; - if ( (name = talloc_strdup( p->mem_ctx, keyname.name )) == NULL ) { - return WERR_NOMEM; - } - - /* ok. Here's what we do. */ - - if ( strrchr( name, '\\' ) ) { - pstring newkeyname; - char *ptr; - - /* (1) check for enumerate rights on the parent handle. - Clients can try create things like 'SOFTWARE\Samba' on - the HKLM handle. (2) open the path to the child parent - key if necessary */ - - if ( !(parent->key->access_granted & SEC_RIGHTS_ENUM_SUBKEYS) ) - return WERR_ACCESS_DENIED; - - pstrcpy( newkeyname, name ); - ptr = strrchr( newkeyname, '\\' ); - *ptr = '\0'; - - result = open_registry_key( p, &newparent_handle, - &newparentinfo, - parent->key, newkeyname, - (REG_KEY_READ|REG_KEY_WRITE) ); - - if ( !W_ERROR_IS_OK(result) ) - return result; - - /* copy the new key name (just the lower most keyname) */ - - if ( (name = talloc_strdup( p->mem_ctx, ptr+1 )) == NULL ) { - return WERR_NOMEM; - } - } - else { - /* use the existing open key information */ - newparentinfo = parent; - memcpy( &newparent_handle, handle, sizeof(POLICY_HND) ); - } - - /* (3) check for create subkey rights on the correct parent */ - - if ( !(newparentinfo->key->access_granted - & SEC_RIGHTS_CREATE_SUBKEY) ) { - result = WERR_ACCESS_DENIED; - goto done; - } - - if ( !(subkeys = TALLOC_ZERO_P( p->mem_ctx, REGSUBKEY_CTR )) ) { - result = WERR_NOMEM; - goto done; + result = reg_createkey(NULL, parent, keyname.name, access_mask, + &new_key, action_taken); + if (!W_ERROR_IS_OK(result)) { + return result; } - /* (4) lookup the current keys and add the new one */ - - fetch_reg_keys( newparentinfo->key, subkeys ); - regsubkey_ctr_addkey( subkeys, name ); - - /* now write to the registry backend */ - - write_result = store_reg_keys( newparentinfo->key, subkeys ); - - TALLOC_FREE( subkeys ); - TALLOC_FREE( newparentinfo->subkey_cache ); - - if ( !write_result ) - return WERR_REG_IO_FAILURE; - - /* (5) open the new key and return the handle. Note that it is probably - not correct to grant full access on this open handle. */ - - result = open_registry_key( p, new_handle, &keyinfo, - newparentinfo->key, name, REG_KEY_READ ); - keyinfo->key->access_granted = REG_KEY_ALL; - - /* FIXME: report the truth here */ - - if ( action_taken ) { - *action_taken = REG_CREATED_NEW_KEY; + if (!create_policy_hnd(p, new_handle, free_regkey, new_key)) { + TALLOC_FREE(new_key); + return WERR_BADFILE; } -done: - /* close any intermediate key handles */ - - if ( newparentinfo != parent ) - close_registry_key( p, &newparent_handle ); - - return result; + return WERR_OK; } - /******************************************************************* ********************************************************************/ -WERROR _winreg_SetValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String name, enum winreg_Type type, uint8_t *data, uint32_t size) +WERROR _winreg_SetValue(pipes_struct *p, struct policy_handle *handle, + struct winreg_String name, enum winreg_Type type, + uint8_t *data, uint32_t size) { - struct regkey_info *info = find_regkey_info_by_hnd(p, handle); - REGISTRY_KEY *key; - REGVAL_CTR *values; - BOOL write_result; + struct registry_key *key = find_regkey_by_hnd(p, handle); + struct registry_value *val; + WERROR status; - if ( !info ) + if ( !key ) return WERR_BADFID; - key = info->key; - - /* access checks first */ - - if ( !(key->access_granted & SEC_RIGHTS_SET_VALUE) ) - return WERR_ACCESS_DENIED; - - DEBUG(8,("_reg_set_value: Setting value for [%s:%s]\n", key->name, + DEBUG(8,("_reg_set_value: Setting value for [%s:%s]\n", key->key->name, name.name)); - - if ( !(values = TALLOC_ZERO_P( p->mem_ctx, REGVAL_CTR )) ) - return WERR_NOMEM; - - /* lookup the current values and add the new one */ - - fetch_reg_values( key, values ); - - regval_ctr_addvalue( values, name.name, type, - (const char *)data, size ); - - /* now write to the registry backend */ - - write_result = store_reg_values( key, values ); - - TALLOC_FREE( values ); - - if ( !write_result ) - return WERR_REG_IO_FAILURE; - TALLOC_FREE(info->value_cache); + status = registry_pull_value(p->mem_ctx, &val, type, data, size, size); + if (!W_ERROR_IS_OK(status)) { + return status; + } - return WERR_OK; + return reg_setvalue(key, name.name, val); } /******************************************************************* ********************************************************************/ -WERROR _winreg_DeleteKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String key) +WERROR _winreg_DeleteKey(pipes_struct *p, struct policy_handle *handle, + struct winreg_String key) { - struct regkey_info *parent = find_regkey_info_by_hnd(p, handle); - struct regkey_info *newparentinfo = NULL; - POLICY_HND newparent_handle; - REGSUBKEY_CTR *subkeys; - BOOL write_result; - char *name; - WERROR result; + struct registry_key *parent = find_regkey_by_hnd(p, handle); if ( !parent ) return WERR_BADFID; - /* MSDN says parent the handle must have been opened with DELETE access */ - - /* (1) check for delete rights on the parent */ - - if ( !(parent->key->access_granted & STD_RIGHT_DELETE_ACCESS) ) { - result = WERR_ACCESS_DENIED; - goto done; - } - - if ( (name = talloc_strdup( p->mem_ctx, key.name )) == NULL ) { - result = WERR_INVALID_PARAM; - goto done; - } - - /* ok. Here's what we do. */ - - if ( strrchr( name, '\\' ) ) { - pstring newkeyname; - char *ptr; - - /* (2) open the path to the child parent key if necessary */ - /* split the registry path and save the subkeyname */ - - pstrcpy( newkeyname, name ); - ptr = strrchr( newkeyname, '\\' ); - *ptr = '\0'; - if ( (name = talloc_strdup( p->mem_ctx, ptr+1 )) == NULL ) { - result = WERR_NOMEM; - goto done; - } - - result = open_registry_key( p, &newparent_handle, - &newparentinfo, parent->key, - newkeyname, - (REG_KEY_READ|REG_KEY_WRITE) ); - if ( !W_ERROR_IS_OK(result) ) { - goto done; - } - } - else { - /* use the existing open key information */ - newparentinfo = parent; - } - - if ( !(subkeys = TALLOC_ZERO_P( p->mem_ctx, REGSUBKEY_CTR )) ) { - result = WERR_NOMEM; - goto done; - } - - /* lookup the current keys and delete the new one */ - - fetch_reg_keys( newparentinfo->key, subkeys ); - - regsubkey_ctr_delkey( subkeys, name ); - - /* now write to the registry backend */ - - write_result = store_reg_keys( newparentinfo->key, subkeys ); - - TALLOC_FREE( subkeys ); - TALLOC_FREE( newparentinfo->subkey_cache ); - - result = write_result ? WERR_OK : WERR_REG_IO_FAILURE; - -done: - /* close any intermediate key handles */ - - if ( newparentinfo != parent ) - close_registry_key( p, &newparent_handle ); - - return result; + return reg_deletekey(parent, key.name); } /******************************************************************* ********************************************************************/ -WERROR _winreg_DeleteValue(pipes_struct *p, struct policy_handle *handle, struct winreg_String value) +WERROR _winreg_DeleteValue(pipes_struct *p, struct policy_handle *handle, + struct winreg_String value) { - struct regkey_info *info = find_regkey_info_by_hnd(p, handle); - REGISTRY_KEY *key; - REGVAL_CTR *values; - BOOL write_result; - char *valuename; + struct registry_key *key = find_regkey_by_hnd(p, handle); - if ( !info ) + if ( !key ) return WERR_BADFID; - key = info->key; - - /* access checks first */ - - if ( !(key->access_granted & SEC_RIGHTS_SET_VALUE) ) - return WERR_ACCESS_DENIED; - - if ( (valuename = talloc_strdup( p->mem_ctx, value.name )) == NULL ) { - return WERR_INVALID_PARAM; - } - - DEBUG(8,("_reg_delete_value: Setting value for [%s:%s]\n", key->name, valuename)); - - if ( !(values = TALLOC_ZERO_P( p->mem_ctx, REGVAL_CTR )) ) - return WERR_NOMEM; - - /* lookup the current values and add the new one */ - - fetch_reg_values( key, values ); - - regval_ctr_delvalue( values, valuename ); - - /* now write to the registry backend */ - - write_result = store_reg_values( key, values ); - - TALLOC_FREE( values ); - - if ( !write_result ) - return WERR_REG_IO_FAILURE; - - TALLOC_FREE(info->value_cache); - - return WERR_OK; + return reg_deletevalue(key, value.name); } /******************************************************************* ********************************************************************/ -WERROR _winreg_GetKeySecurity(pipes_struct *p, struct policy_handle *handle, uint32_t sec_info, struct KeySecurityData *sd) +WERROR _winreg_GetKeySecurity(pipes_struct *p, struct policy_handle *handle, + uint32_t sec_info, struct KeySecurityData *sd) { - REGISTRY_KEY *key = find_regkey_by_hnd(p, handle); + struct registry_key *key = find_regkey_by_hnd(p, handle); WERROR err; struct security_descriptor *secdesc; uint8 *data; @@ -1488,10 +1093,10 @@ WERROR _winreg_GetKeySecurity(pipes_struct *p, struct policy_handle *handle, uin /* access checks first */ - if ( !(key->access_granted & STD_RIGHT_READ_CONTROL_ACCESS) ) + if ( !(key->key->access_granted & STD_RIGHT_READ_CONTROL_ACCESS) ) return WERR_ACCESS_DENIED; - err = regkey_get_secdesc(p->mem_ctx, key, &secdesc); + err = regkey_get_secdesc(p->mem_ctx, key->key, &secdesc); if (!W_ERROR_IS_OK(err)) { return err; } @@ -1519,7 +1124,7 @@ WERROR _winreg_GetKeySecurity(pipes_struct *p, struct policy_handle *handle, uin WERROR _winreg_SetKeySecurity(pipes_struct *p, struct policy_handle *handle, uint32_t access_mask, struct KeySecurityData *sd) { - REGISTRY_KEY *key = find_regkey_by_hnd(p, handle); + struct registry_key *key = find_regkey_by_hnd(p, handle); struct security_descriptor *secdesc; WERROR err; @@ -1528,7 +1133,7 @@ WERROR _winreg_SetKeySecurity(pipes_struct *p, struct policy_handle *handle, uin /* access checks first */ - if ( !(key->access_granted & STD_RIGHT_WRITE_DAC_ACCESS) ) + if ( !(key->key->access_granted & STD_RIGHT_WRITE_DAC_ACCESS) ) return WERR_ACCESS_DENIED; err = ntstatus_to_werror(unmarshall_sec_desc(p->mem_ctx, sd->data, @@ -1537,7 +1142,7 @@ WERROR _winreg_SetKeySecurity(pipes_struct *p, struct policy_handle *handle, uin return err; } - return regkey_set_secdesc(key, secdesc); + return regkey_set_secdesc(key->key, secdesc); } /******************************************************************* -- cgit From 760056ec8d40dca264e5317ac2326f42032a879e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 2 Dec 2006 11:18:19 +0000 Subject: r20007: Fix a const warning just introduced (This used to be commit 3da37287cadfe251491bcefea4ca9d407048868b) --- source3/rpc_server/srv_winreg_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 4b394428c3..98c1107db5 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -433,7 +433,7 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, { WERROR err; struct registry_key *key = find_regkey_by_hnd( p, handle ); - const char *valname; + char *valname; struct registry_value *val; DATA_BLOB value_blob; -- cgit From 3f1978c059a126330f66de046f98f25b7f1346f5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 2 Dec 2006 23:01:34 +0000 Subject: r20012: Reformatting (This used to be commit b32c65cb6243f939247bcfb0f14e4e49dc5ee13e) --- source3/rpc_server/srv_srvsvc_nt.c | 66 +++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 26 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index ac9a1132e1..2dae3c598f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1559,7 +1559,9 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, const ch "comment" "max connections = " ********************************************************************/ -WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetShareInfo info, uint32_t *parm_error) +WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, + uint32_t level, union srvsvc_NetShareInfo info, + uint32_t *parm_error) { pstring command; pstring share_name; @@ -1578,7 +1580,8 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, uint32_t lev *parm_error = 0; - is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); + is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, + &se_diskop ); if (p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; @@ -1599,7 +1602,8 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, uint32_t lev pstrcpy(share_name, info.info2->name); pstrcpy(comment, info.info2->comment); pstrcpy(pathname, info.info2->path); - max_connections = (info.info2->max_users == 0xffffffff) ? 0 : info.info2->max_users; + max_connections = (info.info2->max_users == 0xffffffff) ? + 0 : info.info2->max_users; type = info.info2->type; break; case 501: @@ -1614,7 +1618,8 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, uint32_t lev map_generic_share_sd_bits(psd); break; - /* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */ + /* none of the following contain share names. NetShareAdd + * does not have a separate parameter for the share name */ case 1004: case 1005: @@ -1625,19 +1630,22 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, uint32_t lev /* DFS only level. */ return WERR_ACCESS_DENIED; default: - DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", level)); + DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", + level)); return WERR_UNKNOWN_LEVEL; } /* check for invalid share names */ - if ( !validate_net_name( share_name, INVALID_SHARENAME_CHARS, sizeof(share_name) ) ) { - DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", share_name)); + if ( !validate_net_name( share_name, INVALID_SHARENAME_CHARS, + sizeof(share_name) ) ) { + DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", + share_name)); return WERR_INVALID_NAME; } if ( strequal(share_name,"IPC$") || strequal(share_name,"global") - || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) ) + || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) ) { return WERR_ACCESS_DENIED; } @@ -1656,18 +1664,16 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, uint32_t lev if (!(path = valid_share_pathname( pathname ))) return WERR_OBJECT_PATH_INVALID; - /* Ensure share name, pathname and comment don't contain '"' characters. */ + /* Ensure share name, pathname and comment don't contain '"' + * characters. */ + string_replace(share_name, '"', ' '); string_replace(path, '"', ' '); string_replace(comment, '"', ' '); - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", - lp_add_share_cmd(), - dyn_CONFIGFILE, - share_name, - path, - comment, - max_connections); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" " + "%d", lp_add_share_cmd(), dyn_CONFIGFILE, share_name, + path, comment, max_connections); DEBUG(10,("_srv_net_share_add: Running [%s]\n", command )); @@ -1678,7 +1684,8 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, uint32_t lev if ( (ret = smbrun(command, NULL)) == 0 ) { /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, + False, NULL); } if ( is_disk_op ) @@ -1686,14 +1693,16 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, uint32_t lev /********* END SeDiskOperatorPrivilege BLOCK *********/ - DEBUG(3,("_srv_net_share_add: Running [%s] returned (%d)\n", command, ret )); + DEBUG(3,("_srv_net_share_add: Running [%s] returned (%d)\n", command, + ret )); if ( ret != 0 ) return WERR_ACCESS_DENIED; if (psd) { if (!set_share_security(share_name, psd)) { - DEBUG(0,("_srv_net_share_add: Failed to add security info to share %s.\n", share_name )); + DEBUG(0,("_srv_net_share_add: Failed to add security " + "info to share %s.\n", share_name )); } } @@ -1713,7 +1722,8 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, uint32_t lev a parameter. ********************************************************************/ -WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, const char *share_name, uint32_t reserved) +WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, + const char *share_name, uint32_t reserved) { char *command; int ret; @@ -1724,8 +1734,8 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, const char * DEBUG(5,("_srv_net_share_del: %d\n", __LINE__)); if ( strequal(share_name,"IPC$") - || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) - || strequal(share_name,"global") ) + || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) + || strequal(share_name,"global") ) { return WERR_ACCESS_DENIED; } @@ -1738,7 +1748,8 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, const char * if (lp_print_ok(params->service)) return WERR_ACCESS_DENIED; - is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); + is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, + &se_diskop ); if (p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; @@ -1763,7 +1774,8 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, const char * if ( (ret = smbrun(command, NULL)) == 0 ) { /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, + False, NULL); } if ( is_disk_op ) @@ -1773,7 +1785,8 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, const char * /********* END SeDiskOperatorPrivilege BLOCK *********/ - DEBUG(3,("_srv_net_share_del: Running [%s] returned (%d)\n", command, ret )); + DEBUG(3,("_srv_net_share_del: Running [%s] returned (%d)\n", command, + ret )); if ( ret != 0 ) return WERR_ACCESS_DENIED; @@ -1786,7 +1799,8 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, const char * return WERR_OK; } -WERROR _srvsvc_NetShareDelSticky(pipes_struct *p, const char *server_unc, const char *share_name, uint32_t reserved) +WERROR _srvsvc_NetShareDelSticky(pipes_struct *p, const char *server_unc, + const char *share_name, uint32_t reserved) { DEBUG(5,("_srv_net_share_del_stick: %d\n", __LINE__)); -- cgit From c6597384ba1c3db03cc21a771737123f70391fb9 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 3 Dec 2006 10:09:37 +0000 Subject: r20013: Fix segfaults: parm_error is a unique in/out ptr (This used to be commit 0104371dd648204c9e8102cdc399539857be4a63) --- source3/rpc_server/srv_srvsvc_nt.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 2dae3c598f..5b24b3d2b8 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1146,7 +1146,9 @@ net server set info WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetSrvInfo info, uint32_t *parm_error) { /* Set up the net server set info structure. */ - *parm_error = 0; + if (parm_error) { + *parm_error = 0; + } return WERR_OK; } @@ -1391,7 +1393,9 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, const ch DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); - *parm_error = 0; + if (parm_error) { + *parm_error = 0; + } if ( strequal(share_name,"IPC$") || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) @@ -1578,7 +1582,9 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); - *parm_error = 0; + if (parm_error) { + *parm_error = 0; + } is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); -- cgit From fe34827ffdaf4f0bbf5da739661675b0595388c7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 3 Dec 2006 16:18:31 +0000 Subject: r20015: We have to zero out handle on key_close, otherwise the NT4 regedit will re-use the handle (This used to be commit 0afd696f88ed04f562ef64201ac2e58cef372a90) --- source3/rpc_server/srv_winreg_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 98c1107db5..1738aafc4e 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -126,6 +126,8 @@ WERROR _winreg_CloseKey(pipes_struct *p, struct policy_handle *handle) if (!close_registry_key(p, handle)) return WERR_BADFID; + ZERO_STRUCTP(handle); + return WERR_OK; } -- cgit From b67609792783416e0b89fb31f441bf17828aa5d8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 3 Dec 2006 16:19:29 +0000 Subject: r20017: Make srvsvc_NetShareAdd & friends take care of registry shares (This used to be commit fc29a283cc9c2458375aa4fe2ecef82e6a3847df) --- source3/rpc_server/srv_srvsvc_nt.c | 424 ++++++++++++++++++++++++++----------- 1 file changed, 299 insertions(+), 125 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 5b24b3d2b8..abfa794518 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1372,18 +1372,273 @@ char *valid_share_pathname(char *dos_pathname) return ptr; } +static void setval_helper(struct registry_key *key, const char *name, + const char *value, WERROR *err) +{ + struct registry_value val; + + if (!W_ERROR_IS_OK(*err)) { + return; + } + + ZERO_STRUCT(val); + val.type = REG_SZ; + val.v.sz.str = CONST_DISCARD(char *, value); + val.v.sz.len = strlen(value)+1; + + *err = reg_setvalue(key, name, &val); +} + +static WERROR add_share(const char *share_name, const char *path, + const char *comment, uint32 max_connections, + const struct nt_user_token *token, + BOOL is_disk_op) +{ + if (lp_add_share_cmd() && *lp_add_share_cmd()) { + char *command; + int ret; + + if (asprintf(&command, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", + lp_add_share_cmd(), dyn_CONFIGFILE, share_name, + path, comment, max_connections) == -1) { + return WERR_NOMEM; + } + + DEBUG(10,("add_share: Running [%s]\n", command )); + + /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ + + if ( is_disk_op ) + become_root(); + + if ( (ret = smbrun(command, NULL)) == 0 ) { + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, + NULL, 0, False, NULL); + } + + if ( is_disk_op ) + unbecome_root(); + + /********* END SeDiskOperatorPrivilege BLOCK *********/ + + DEBUG(3,("_srv_net_share_add: Running [%s] returned (%d)\n", + command, ret )); + + /* + * No fallback to registry shares, the user did define a add + * share command, so fail here. + */ + + SAFE_FREE(command); + return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; + } + + if (lp_registry_shares()) { + char *keyname; + struct registry_key *key; + enum winreg_CreateAction action; + WERROR err; + TALLOC_CTX *mem_ctx; + + if (!(keyname = talloc_asprintf(NULL, "%s\\%s", KEY_SMBCONF, + share_name))) { + return WERR_NOMEM; + } + + mem_ctx = (TALLOC_CTX *)keyname; + + err = reg_create_path(mem_ctx, keyname, REG_KEY_WRITE, + is_disk_op ? get_root_nt_token():token, + &action, &key); + + if (action != REG_CREATED_NEW_KEY) { + err = WERR_ALREADY_EXISTS; + } + + if (!W_ERROR_IS_OK(err)) { + TALLOC_FREE(mem_ctx); + return err; + } + + setval_helper(key, "path", path, &err); + if ((comment != NULL) && (comment[0] != '\0')) { + setval_helper(key, "comment", comment, &err); + } + if (max_connections != 0) { + char tmp[16]; + snprintf(tmp, sizeof(tmp), "%d", max_connections); + setval_helper(key, "max connections", tmp, &err); + } + + if (!W_ERROR_IS_OK(err)) { + /* + * Hmmmm. We'd need transactions on the registry to + * get this right.... + */ + reg_delete_path(is_disk_op ? get_root_nt_token():token, + keyname); + } + TALLOC_FREE(mem_ctx); + return err; + } + + return WERR_ACCESS_DENIED; +} + +static WERROR delete_share(const char *sharename, + const struct nt_user_token *token, + BOOL is_disk_op) +{ + if (lp_delete_share_cmd() && *lp_delete_share_cmd()) { + char *command; + int ret; + + if (asprintf(&command, "%s \"%s\" \"%s\"", + lp_delete_share_cmd(), dyn_CONFIGFILE, + sharename)) { + return WERR_NOMEM; + } + + DEBUG(10,("delete_share: Running [%s]\n", command )); + + /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ + + if ( is_disk_op ) + become_root(); + + if ( (ret = smbrun(command, NULL)) == 0 ) { + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, + NULL, 0, False, NULL); + } + + if ( is_disk_op ) + unbecome_root(); + + /********* END SeDiskOperatorPrivilege BLOCK *********/ + + SAFE_FREE(command); + + DEBUG(3,("_srv_net_share_del: Running [%s] returned (%d)\n", + command, ret )); + return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; + } + + if (lp_registry_shares()) { + char *keyname; + WERROR err; + + if (asprintf(&keyname, "%s\\%s", KEY_SMBCONF, + sharename) == -1) { + return WERR_NOMEM; + } + + err = reg_delete_path(is_disk_op ? get_root_nt_token():token, + keyname); + SAFE_FREE(keyname); + return err; + } + + return WERR_ACCESS_DENIED; +} + +static WERROR change_share(const char *share_name, const char *path, + const char *comment, uint32 max_connections, + const struct nt_user_token *token, + BOOL is_disk_op) +{ + if (lp_change_share_cmd() && *lp_change_share_cmd()) { + char *command; + int ret; + + if (asprintf(&command, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", + lp_change_share_cmd(), dyn_CONFIGFILE, share_name, + path, comment, max_connections) == -1) { + return WERR_NOMEM; + } + + DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command)); + + /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ + + if ( is_disk_op ) + become_root(); + + if ( (ret = smbrun(command, NULL)) == 0 ) { + /* Tell everyone we updated smb.conf. */ + message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, + NULL, 0, False, NULL); + } + + if ( is_disk_op ) + unbecome_root(); + + /********* END SeDiskOperatorPrivilege BLOCK *********/ + + DEBUG(3,("_srv_net_share_set_info: Running [%s] returned " + "(%d)\n", command, ret )); + + SAFE_FREE(command); + + return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; + } + + if (lp_registry_shares()) { + char *keyname; + struct registry_key *key; + WERROR err; + TALLOC_CTX *mem_ctx; + + if (!(keyname = talloc_asprintf(NULL, "%s\\%s", KEY_SMBCONF, + share_name))) { + return WERR_NOMEM; + } + + mem_ctx = (TALLOC_CTX *)keyname; + + err = reg_open_path(mem_ctx, keyname, REG_KEY_WRITE, + is_disk_op ? get_root_nt_token():token, + &key); + if (!W_ERROR_IS_OK(err)) { + TALLOC_FREE(mem_ctx); + return err; + } + + setval_helper(key, "path", path, &err); + + reg_deletevalue(key, "comment"); + if ((comment != NULL) && (comment[0] != '\0')) { + setval_helper(key, "comment", comment, &err); + } + + reg_deletevalue(key, "max connections"); + if (max_connections != 0) { + char tmp[16]; + snprintf(tmp, sizeof(tmp), "%d", max_connections); + setval_helper(key, "max connections", tmp, &err); + } + + TALLOC_FREE(mem_ctx); + return err; + } + + return WERR_ACCESS_DENIED; +} + /******************************************************************* Net share set info. Modify share details. ********************************************************************/ -WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, const char *share_name, uint32_t level, union srvsvc_NetShareInfo info, uint32_t *parm_error) +WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, + const char *share_name, uint32_t level, + union srvsvc_NetShareInfo info, + uint32_t *parm_error) { - pstring command; pstring comment; pstring pathname; int type; int snum; - int ret; char *path; SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; @@ -1415,7 +1670,8 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, const ch if (lp_print_ok(snum)) return WERR_ACCESS_DENIED; - is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); + is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, + &se_diskop ); /* fail out now if you are not root and not a disk op */ @@ -1433,17 +1689,10 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, const ch pstrcpy(comment, info.info2->comment); pstrcpy(pathname, info.info2->path); type = info.info2->type; - max_connections = (info.info2->max_users == 0xffffffff) ? 0 : info.info2->max_users; - psd = NULL; - break; -#if 0 - /* not supported on set but here for completeness */ - case 501: - unistr2_to_ascii(comment, &q_u->info.share.info501.info_501_str.uni_remark, sizeof(comment)); - type = q_u->info.share.info501.info_501.type; + max_connections = (info.info2->max_users == 0xffffffff) ? + 0 : info.info2->max_users; psd = NULL; break; -#endif case 502: pstrcpy(comment, info.info502->comment); pstrcpy(pathname, info.info502->path); @@ -1466,7 +1715,9 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, const ch SHARE_1005_CSC_POLICY_SHIFT) == lp_csc_policy(snum)) return WERR_OK; else { - DEBUG(3, ("_srv_net_share_set_info: client is trying to change csc policy from the network; must be done with smb.conf\n")); + DEBUG(3, ("_srv_net_share_set_info: client is trying " + "to change csc policy from the network; " + "must be done with smb.conf\n")); return WERR_ACCESS_DENIED; } case 1006: @@ -1480,7 +1731,8 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, const ch type = STYPE_DISKTREE; break; default: - DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", level)); + DEBUG(5,("_srv_net_share_set_info: unsupported switch value " + "%d\n", level)); return WERR_UNKNOWN_LEVEL; } @@ -1492,50 +1744,29 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, const ch if (!(path = valid_share_pathname( pathname ))) return WERR_OBJECT_PATH_INVALID; - /* Ensure share name, pathname and comment don't contain '"' characters. */ + /* Ensure share name, pathname and comment don't contain '"' + * characters. */ string_replace(tmp_share_name, '"', ' '); string_replace(path, '"', ' '); string_replace(comment, '"', ' '); DEBUG(10,("_srv_net_share_set_info: change share command = %s\n", - lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" )); + lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" )); /* Only call modify function if something changed. */ - if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) - || (lp_max_connections(snum) != max_connections) ) - { - if (!lp_change_share_cmd() || !*lp_change_share_cmd()) { - DEBUG(10,("_srv_net_share_set_info: No change share command\n")); - return WERR_ACCESS_DENIED; - } + if (strcmp(path, lp_pathname(snum)) + || strcmp(comment, lp_comment(snum)) + || (lp_max_connections(snum) != max_connections) ) { + WERROR err; - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", - lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment, max_connections ); + err = change_share(tmp_share_name, path, comment, + max_connections, p->pipe_user.nt_user_token, + is_disk_op); - DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command )); - - /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ - - if ( is_disk_op ) - become_root(); - - if ( (ret = smbrun(command, NULL)) == 0 ) { - /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + if (!W_ERROR_IS_OK(err)) { + return err; } - - if ( is_disk_op ) - unbecome_root(); - - /********* END SeDiskOperatorPrivilege BLOCK *********/ - - DEBUG(3,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret )); - - if ( ret != 0 ) - return WERR_ACCESS_DENIED; - } else { - DEBUG(10,("_srv_net_share_set_info: No change to share name (%s)\n", share_name )); } /* Replace SD if changed. */ @@ -1547,9 +1778,11 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, const ch &sd_size); if (old_sd && !sec_desc_equal(old_sd, psd)) { - if (!set_share_security(share_name, psd)) - DEBUG(0,("_srv_net_share_set_info: Failed to change security info in share %s.\n", - share_name )); + if (!set_share_security(share_name, psd)) { + DEBUG(0,("_srv_net_share_set_info: Failed to " + "change security info in share %s.\n", + share_name )); + } } } @@ -1558,6 +1791,7 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, const ch return WERR_OK; } + /******************************************************************* Net share add. Call 'add_share_command "sharename" "pathname" "comment" "max connections = " @@ -1567,18 +1801,16 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetShareInfo info, uint32_t *parm_error) { - pstring command; pstring share_name; pstring comment; pstring pathname; char *path; int type; - int snum; - int ret; SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op; - int max_connections = 0; + uint32 max_connections = 0; + WERROR err; DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); @@ -1592,11 +1824,6 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, if (p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; - if (!lp_add_share_cmd() || !*lp_add_share_cmd()) { - DEBUG(10,("_srv_net_share_add: No add share command\n")); - return WERR_ACCESS_DENIED; - } - switch (level) { case 0: /* No path. Not enough info in a level 0 to do anything. */ @@ -1656,11 +1883,10 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, return WERR_ACCESS_DENIED; } - snum = find_service(share_name); - - /* Share already exists. */ - if (snum >= 0) + if (get_share_params(p->mem_ctx, share_name) != NULL) { + /* Share already exists. */ return WERR_ALREADY_EXISTS; + } /* We can only add disk shares. */ if (type != STYPE_DISKTREE) @@ -1677,34 +1903,13 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, string_replace(path, '"', ' '); string_replace(comment, '"', ' '); - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" " - "%d", lp_add_share_cmd(), dyn_CONFIGFILE, share_name, - path, comment, max_connections); - - DEBUG(10,("_srv_net_share_add: Running [%s]\n", command )); - - /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ - - if ( is_disk_op ) - become_root(); + err = add_share(share_name, path, comment, max_connections, + p->pipe_user.nt_user_token, is_disk_op); - if ( (ret = smbrun(command, NULL)) == 0 ) { - /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, - False, NULL); + if (!W_ERROR_IS_OK(err)) { + return err; } - if ( is_disk_op ) - unbecome_root(); - - /********* END SeDiskOperatorPrivilege BLOCK *********/ - - DEBUG(3,("_srv_net_share_add: Running [%s] returned (%d)\n", command, - ret )); - - if ( ret != 0 ) - return WERR_ACCESS_DENIED; - if (psd) { if (!set_share_security(share_name, psd)) { DEBUG(0,("_srv_net_share_add: Failed to add security " @@ -1731,11 +1936,10 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, const char *share_name, uint32_t reserved) { - char *command; - int ret; struct share_params *params; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op; + WERROR err; DEBUG(5,("_srv_net_share_del: %d\n", __LINE__)); @@ -1760,43 +1964,13 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, if (p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; - if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) { - DEBUG(10,("_srv_net_share_del: No delete share command\n")); - return WERR_ACCESS_DENIED; - } - - if (asprintf(&command, "%s \"%s\" \"%s\"", - lp_delete_share_cmd(), dyn_CONFIGFILE, - lp_servicename(params->service)) == -1) { - return WERR_NOMEM; - } - - DEBUG(10,("_srv_net_share_del: Running [%s]\n", command )); + err = delete_share(lp_servicename(params->service), + p->pipe_user.nt_user_token, is_disk_op); - /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ - - if ( is_disk_op ) - become_root(); - - if ( (ret = smbrun(command, NULL)) == 0 ) { - /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, - False, NULL); + if (!W_ERROR_IS_OK(err)) { + return err; } - if ( is_disk_op ) - unbecome_root(); - - SAFE_FREE(command); - - /********* END SeDiskOperatorPrivilege BLOCK *********/ - - DEBUG(3,("_srv_net_share_del: Running [%s] returned (%d)\n", command, - ret )); - - if ( ret != 0 ) - return WERR_ACCESS_DENIED; - /* Delete the SD in the database. */ delete_share_security(params); -- cgit From 61bd0c8e450b3638c38bc60eb31fc6a4488f3121 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 3 Dec 2006 17:16:45 +0000 Subject: r20019: Replace one set of tricky code by calls to another set of tricky code: Initializing the reg_db now uses reg_createkey and reg_setvalue. Volker (This used to be commit cab5ccbbe484795f13531726d68b978073262e33) --- source3/rpc_server/srv_srvsvc_nt.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index abfa794518..1b86fa349f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1375,18 +1375,10 @@ char *valid_share_pathname(char *dos_pathname) static void setval_helper(struct registry_key *key, const char *name, const char *value, WERROR *err) { - struct registry_value val; - if (!W_ERROR_IS_OK(*err)) { return; } - - ZERO_STRUCT(val); - val.type = REG_SZ; - val.v.sz.str = CONST_DISCARD(char *, value); - val.v.sz.len = strlen(value)+1; - - *err = reg_setvalue(key, name, &val); + *err = reg_set_sz(key, name, value); } static WERROR add_share(const char *share_name, const char *path, -- cgit From 2494868ffba14d425531df98651d777a13d3be28 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 3 Dec 2006 17:34:11 +0000 Subject: r20020: Arglll... eventlogadm links against reg_db but not the rest of the registry stuff. Revert the last change. This needs better fixing. Volker (This used to be commit ad1e00430bf5c4130023d30e9c8266ecdc640d2b) --- source3/rpc_server/srv_srvsvc_nt.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 1b86fa349f..abfa794518 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1375,10 +1375,18 @@ char *valid_share_pathname(char *dos_pathname) static void setval_helper(struct registry_key *key, const char *name, const char *value, WERROR *err) { + struct registry_value val; + if (!W_ERROR_IS_OK(*err)) { return; } - *err = reg_set_sz(key, name, value); + + ZERO_STRUCT(val); + val.type = REG_SZ; + val.v.sz.str = CONST_DISCARD(char *, value); + val.v.sz.len = strlen(value)+1; + + *err = reg_setvalue(key, name, &val); } static WERROR add_share(const char *share_name, const char *path, -- cgit From e59e787b4868acffad49b6264e319d585643d5ab Mon Sep 17 00:00:00 2001 From: Herb Lewis Date: Wed, 20 Dec 2006 01:10:04 +0000 Subject: r20269: merge -r20264:20267 from SAMBA_3_0_24 more no previous prototype warnings (This used to be commit 41be182f78762372ae13759ede5d2bd40a71d7f5) --- source3/rpc_server/srv_eventlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 6911bdcd3b..519be60199 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -281,7 +281,7 @@ static int elog_size( EVENTLOG_INFO *info ) Eventlog_entry. returns NULL if it can't get the record for some reason. ********************************************************************/ -Eventlog_entry *get_eventlog_record( prs_struct * ps, TDB_CONTEXT * tdb, +static Eventlog_entry *get_eventlog_record( prs_struct * ps, TDB_CONTEXT * tdb, int recno, Eventlog_entry * ee ) { TDB_DATA ret, key; -- cgit From 18bf0b29b4b9b466136f08c1b6777ad8517779ed Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 5 Jan 2007 14:52:10 +0000 Subject: r20546: Fix some IBM checker errors (This used to be commit 8f67efd582655e03fea746eee499f3cab6cbdb4d) --- source3/rpc_server/srv_samr_util.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 242d44c6e8..8acc1785ef 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -52,6 +52,7 @@ void copy_id20_to_sam_passwd(struct samu *to, SAM_USER_INFO_20 *from) old_string = pdb_get_munged_dial(to); mung.length = from->hdr_munged_dial.uni_str_len; mung.data = (uint8 *) from->uni_munged_dial.buffer; + mung.free = NULL; new_string = (mung.length == 0) ? NULL : base64_encode_data_blob(mung); DEBUG(10,("INFO_20 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); @@ -194,6 +195,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) old_string = pdb_get_munged_dial(to); mung.length = from->hdr_munged_dial.uni_str_len; mung.data = (uint8 *) from->uni_munged_dial.buffer; + mung.free = NULL; newstr = (mung.length == 0) ? NULL : base64_encode_data_blob(mung); DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); @@ -417,6 +419,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) old_string = pdb_get_munged_dial(to); mung.length = from->hdr_munged_dial.uni_str_len; mung.data = (uint8 *) from->uni_munged_dial.buffer; + mung.free = NULL; newstr = (mung.length == 0) ? NULL : base64_encode_data_blob(mung); DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); @@ -628,6 +631,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) old_string = pdb_get_munged_dial(to); mung.length = from->hdr_munged_dial.uni_str_len; mung.data = (uint8 *) from->uni_munged_dial.buffer; + mung.free = NULL; newstr = (mung.length == 0) ? NULL : base64_encode_data_blob(mung); DEBUG(10,("INFO_25 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); -- cgit From db0ad252a0622dfac17d44ca646168df4c1c22e5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 12 Jan 2007 23:47:16 +0000 Subject: r20718: Sync up the filename path parsing changes from SAMBA_3_0_24. The only difference between the two trees now w.r.t file serving are the changes to smbd/open.c in this branch I need to review. Jeremy. (This used to be commit f4474edf6a0c71001dbd01429ef70bafad6abd74) --- source3/rpc_server/srv_srvsvc_nt.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index abfa794518..646a414cda 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2036,7 +2036,6 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, const char *server_unc, const DATA_BLOB null_pw; files_struct *fsp = NULL; SMB_STRUCT_STAT st; - BOOL bad_path; NTSTATUS nt_status; connection_struct *conn = NULL; BOOL became_user = False; @@ -2067,8 +2066,8 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, const char *server_unc, const became_user = True; pstrcpy(tmp_file, file); - unix_convert(tmp_file, conn, NULL, &bad_path, &st); - if (bad_path) { + nt_status = unix_convert(conn, tmp_file, False, NULL, &st); + if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", file)); status = WERR_ACCESS_DENIED; goto error_exit; @@ -2141,7 +2140,6 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, const char *server_unc, const DATA_BLOB null_pw; files_struct *fsp = NULL; SMB_STRUCT_STAT st; - BOOL bad_path; NTSTATUS nt_status; connection_struct *conn = NULL; BOOL became_user = False; @@ -2171,8 +2169,8 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, const char *server_unc, const became_user = True; pstrcpy(tmp_file, file); - unix_convert(tmp_file, conn, NULL, &bad_path, &st); - if (bad_path) { + nt_status = unix_convert(conn, tmp_file, False, NULL, &st); + if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", file)); status = WERR_ACCESS_DENIED; goto error_exit; -- cgit From b906886e9e9739877fef4c381c46a9a9d61859ba Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 16 Jan 2007 08:17:26 +0000 Subject: r20824: Send access to the trusted domain passwords through the pdb backend, so that in the next step we can store them in LDAP to be replicated across DCs. Thanks to Michael Adam Volker (This used to be commit 3c879745cfc39be6128b63a88ecdbfa3d9ce6c2d) --- source3/rpc_server/srv_lsa_nt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 1a92ec6740..44ec292750 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -648,8 +648,7 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, if (!(info->access & POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - nt_status = secrets_trusted_domains(p->mem_ctx, &num_domains, - &domains); + nt_status = pdb_enum_trusteddoms(p->mem_ctx, &num_domains, &domains); if (!NT_STATUS_IS_OK(nt_status)) { return nt_status; -- cgit From 62e11c4f1748d98f479110c8c0e656a8f65dca4d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 16 Jan 2007 15:42:03 +0000 Subject: r20832: Remove extra pointers previously added to unique [out] pointers. Instead, add [ref] pointers where necessary (top-level [ref] pointers, by spec, don't appear on the wire). This brings us closer to the DCE/RPC standard again. (This used to be commit 580f2a7197b1bc9db14a643fdd112b40ef37aaef) --- source3/rpc_server/srv_winreg_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 1738aafc4e..4006b375b5 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -430,7 +430,7 @@ WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t e WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_ValNameBuf *name, - enum winreg_Type *type, uint8_t *data, + enum winreg_Type *type, uint8_t **data, uint32_t *data_size, uint32_t *value_length) { WERROR err; -- cgit From 83eb0d1d6d90d182e8eee8496695113c89f8dba1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 17 Jan 2007 02:09:37 +0000 Subject: r20844: Somewhat radical change - this may break the build (I will watch carefully - so I'm doing it in one transaction so I can roll back). Change check_name(), reduce_name() and dptr_create() to return NTSTATUS. This helps a lot in error path processing and especially in reduce_name() allows us to ditch the flaky and error-prone saving of errno and return errors directly. Jeremy. (This used to be commit 6133a694aa429d638320e39ffe1c49d172583ccf) --- source3/rpc_server/srv_srvsvc_nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 646a414cda..a9adaf3200 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2073,7 +2073,8 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, const char *server_unc, const goto error_exit; } - if (!check_name(file,conn)) { + nt_status = check_name(conn, file); + if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", file)); status = WERR_ACCESS_DENIED; goto error_exit; @@ -2176,7 +2177,8 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, const char *server_unc, const goto error_exit; } - if (!check_name(file,conn)) { + nt_status = check_name(conn, file); + if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", file)); status = WERR_ACCESS_DENIED; goto error_exit; -- cgit From d6b3fce078869de35334c0805ff141dc8bcf5f65 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 18 Jan 2007 10:18:59 +0000 Subject: r20875: Pass DCE/RPC server call arguments as a struct rather than as separate arguments. This makes it a bit more similar to the Samba4 code. (This used to be commit 0596badb410a58e7a715e2b17bc0bef0489a2448) --- source3/rpc_server/srv_dfs_nt.c | 112 ++++---- source3/rpc_server/srv_echo_nt.c | 66 ++--- source3/rpc_server/srv_initshutdown_nt.c | 33 ++- source3/rpc_server/srv_lsa_nt.c | 180 ++++++------ source3/rpc_server/srv_srvsvc_nt.c | 460 +++++++++++++++---------------- source3/rpc_server/srv_unixinfo_nt.c | 49 ++-- source3/rpc_server/srv_winreg_nt.c | 324 ++++++++++------------ source3/rpc_server/srv_wkssvc_nt.c | 74 +++-- 8 files changed, 629 insertions(+), 669 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 4857a839e1..98818826df 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -30,15 +30,15 @@ /* This function does not return a WERROR or NTSTATUS code but rather 1 if dfs exists, or 0 otherwise. */ -void _dfs_GetManagerVersion(pipes_struct *p, uint32 *exists) +void _dfs_GetManagerVersion(pipes_struct *p, struct dfs_GetManagerVersion *r) { if(lp_host_msdfs()) - *exists = 1; + *r->out.exist_flag = 1; else - *exists = 0; + *r->out.exist_flag = 0; } -WERROR _dfs_Add(pipes_struct *p, const char *path, const char *server, const char *share, const char *comment, uint32_t flags) +WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) { struct junction_map jn; struct referral* old_referral_list = NULL; @@ -52,14 +52,14 @@ WERROR _dfs_Add(pipes_struct *p, const char *path, const char *server, const cha } DEBUG(5,("init_reply_dfs_add: Request to add %s -> %s\\%s.\n", - path, server, share)); + r->in.path, r->in.server, r->in.share)); - pstrcpy(altpath, server); + pstrcpy(altpath, r->in.server); pstrcat(altpath, "\\"); - pstrcat(altpath, share); + pstrcat(altpath, r->in.share); /* The following call can change the cwd. */ - if(get_referred_path(p->mem_ctx, path, &jn, NULL, NULL)) { + if(get_referred_path(p->mem_ctx, r->in.path, &jn, NULL, NULL)) { exists = True; jn.referral_count += 1; old_referral_list = jn.referral_list; @@ -93,7 +93,7 @@ WERROR _dfs_Add(pipes_struct *p, const char *path, const char *server, const cha return WERR_OK; } -WERROR _dfs_Remove(pipes_struct *p, const char *path, const char *server, const char *share) +WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) { struct junction_map jn; BOOL found = False; @@ -105,22 +105,22 @@ WERROR _dfs_Remove(pipes_struct *p, const char *path, const char *server, const return WERR_ACCESS_DENIED; } - if(server && share) { - pstrcpy(altpath, server); + if (r->in.server && r->in.share) { + pstrcpy(altpath, r->in.server); pstrcat(altpath, "\\"); - pstrcat(altpath, share); + pstrcat(altpath, r->in.share); strlower_m(altpath); } DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n", - path, server, share)); + r->in.path, r->in.server, r->in.share)); - if(!get_referred_path(p->mem_ctx, path, &jn, NULL, NULL)) { + if(!get_referred_path(p->mem_ctx, r->in.path, &jn, NULL, NULL)) { return WERR_DFS_NO_SUCH_VOL; } /* if no server-share pair given, remove the msdfs link completely */ - if(!server && !share) { + if(!r->in.server && !r->in.share) { if(!remove_msdfs_link(&jn)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; @@ -242,7 +242,7 @@ static BOOL init_reply_dfs_info_100(TALLOC_CTX *mem_ctx, struct junction_map* j, } -WERROR _dfs_Enum(pipes_struct *p, uint32_t level, uint32_t bufsize, struct dfs_EnumStruct *info, uint32_t *unknown, uint32_t *total) +WERROR _dfs_Enum(pipes_struct *p, struct dfs_Enum *r) { struct junction_map jn[MAX_MSDFS_JUNCTIONS]; int num_jn = 0; @@ -251,44 +251,44 @@ WERROR _dfs_Enum(pipes_struct *p, uint32_t level, uint32_t bufsize, struct dfs_E num_jn = enum_msdfs_links(p->mem_ctx, jn, ARRAY_SIZE(jn)); vfs_ChDir(p->conn,p->conn->connectpath); - DEBUG(5,("_dfs_Enum: %d junctions found in Dfs, doing level %d\n", num_jn, level)); + DEBUG(5,("_dfs_Enum: %d junctions found in Dfs, doing level %d\n", num_jn, r->in.level)); - *total = num_jn; + *r->out.total = num_jn; /* Create the return array */ - switch (level) { + switch (r->in.level) { case 1: - if ((info->e.info1->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info1, num_jn)) == NULL) { + if ((r->out.info->e.info1->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info1, num_jn)) == NULL) { return WERR_NOMEM; } - info->e.info1->count = num_jn; + r->out.info->e.info1->count = num_jn; break; case 2: - if ((info->e.info2->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info2, num_jn)) == NULL) { + if ((r->out.info->e.info2->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info2, num_jn)) == NULL) { return WERR_NOMEM; } - info->e.info2->count = num_jn; + r->out.info->e.info2->count = num_jn; break; case 3: - if ((info->e.info3->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info3, num_jn)) == NULL) { + if ((r->out.info->e.info3->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info3, num_jn)) == NULL) { return WERR_NOMEM; } - info->e.info3->count = num_jn; + r->out.info->e.info3->count = num_jn; break; default: return WERR_INVALID_PARAM; } for (i = 0; i < num_jn; i++) { - switch (level) { + switch (r->in.level) { case 1: - init_reply_dfs_info_1(p->mem_ctx, &jn[i], &info->e.info1->s[i]); + init_reply_dfs_info_1(p->mem_ctx, &jn[i], &r->out.info->e.info1->s[i]); break; case 2: - init_reply_dfs_info_2(p->mem_ctx, &jn[i], &info->e.info2->s[i]); + init_reply_dfs_info_2(p->mem_ctx, &jn[i], &r->out.info->e.info2->s[i]); break; case 3: - init_reply_dfs_info_3(p->mem_ctx, &jn[i], &info->e.info3->s[i]); + init_reply_dfs_info_3(p->mem_ctx, &jn[i], &r->out.info->e.info3->s[i]); break; default: return WERR_INVALID_PARAM; @@ -298,30 +298,30 @@ WERROR _dfs_Enum(pipes_struct *p, uint32_t level, uint32_t bufsize, struct dfs_E return WERR_OK; } -WERROR _dfs_GetInfo(pipes_struct *p, const char *path, const char *server, const char *share, uint32_t level, union dfs_Info *info) +WERROR _dfs_GetInfo(pipes_struct *p, struct dfs_GetInfo *r) { int consumedcnt = sizeof(pstring); struct junction_map jn; BOOL ret; - if(!create_junction(path, &jn)) + if(!create_junction(r->in.path, &jn)) return WERR_DFS_NO_SUCH_SERVER; /* The following call can change the cwd. */ - if(!get_referred_path(p->mem_ctx, path, &jn, &consumedcnt, NULL) || consumedcnt < strlen(path)) { + if(!get_referred_path(p->mem_ctx, r->in.path, &jn, &consumedcnt, NULL) || consumedcnt < strlen(r->in.path)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; } vfs_ChDir(p->conn,p->conn->connectpath); - switch (level) { - case 1: ret = init_reply_dfs_info_1(p->mem_ctx, &jn, info->info1); break; - case 2: ret = init_reply_dfs_info_2(p->mem_ctx, &jn, info->info2); break; - case 3: ret = init_reply_dfs_info_3(p->mem_ctx, &jn, info->info3); break; - case 100: ret = init_reply_dfs_info_100(p->mem_ctx, &jn, info->info100); break; + switch (r->in.level) { + case 1: ret = init_reply_dfs_info_1(p->mem_ctx, &jn, r->out.info->info1); break; + case 2: ret = init_reply_dfs_info_2(p->mem_ctx, &jn, r->out.info->info2); break; + case 3: ret = init_reply_dfs_info_3(p->mem_ctx, &jn, r->out.info->info3); break; + case 100: ret = init_reply_dfs_info_100(p->mem_ctx, &jn, r->out.info->info100); break; default: - info->info1 = NULL; + r->out.info->info1 = NULL; return WERR_INVALID_PARAM; } @@ -331,126 +331,126 @@ WERROR _dfs_GetInfo(pipes_struct *p, const char *path, const char *server, const return WERR_OK; } -WERROR _dfs_SetInfo(pipes_struct *p) +WERROR _dfs_SetInfo(pipes_struct *p, struct dfs_SetInfo *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_Rename(pipes_struct *p) +WERROR _dfs_Rename(pipes_struct *p, struct dfs_Rename *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_Move(pipes_struct *p) +WERROR _dfs_Move(pipes_struct *p, struct dfs_Move *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_ManagerGetConfigInfo(pipes_struct *p) +WERROR _dfs_ManagerGetConfigInfo(pipes_struct *p, struct dfs_ManagerGetConfigInfo *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_ManagerSendSiteInfo(pipes_struct *p) +WERROR _dfs_ManagerSendSiteInfo(pipes_struct *p, struct dfs_ManagerSendSiteInfo *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_AddFtRoot(pipes_struct *p) +WERROR _dfs_AddFtRoot(pipes_struct *p, struct dfs_AddFtRoot *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_RemoveFtRoot(pipes_struct *p) +WERROR _dfs_RemoveFtRoot(pipes_struct *p, struct dfs_RemoveFtRoot *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_AddStdRoot(pipes_struct *p) +WERROR _dfs_AddStdRoot(pipes_struct *p, struct dfs_AddStdRoot *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_RemoveStdRoot(pipes_struct *p) +WERROR _dfs_RemoveStdRoot(pipes_struct *p, struct dfs_RemoveStdRoot *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_ManagerInitialize(pipes_struct *p) +WERROR _dfs_ManagerInitialize(pipes_struct *p, struct dfs_ManagerInitialize *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_AddStdRootForced(pipes_struct *p) +WERROR _dfs_AddStdRootForced(pipes_struct *p, struct dfs_AddStdRootForced *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_GetDcAddress(pipes_struct *p) +WERROR _dfs_GetDcAddress(pipes_struct *p, struct dfs_GetDcAddress *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_SetDcAddress(pipes_struct *p) +WERROR _dfs_SetDcAddress(pipes_struct *p, struct dfs_SetDcAddress *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_FlushFtTable(pipes_struct *p) +WERROR _dfs_FlushFtTable(pipes_struct *p, struct dfs_FlushFtTable *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_Add2(pipes_struct *p) +WERROR _dfs_Add2(pipes_struct *p, struct dfs_Add2 *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_Remove2(pipes_struct *p) +WERROR _dfs_Remove2(pipes_struct *p, struct dfs_Remove2 *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_EnumEx(pipes_struct *p, const char *name, uint32_t level, uint32_t bufsize, struct dfs_EnumStruct *info, uint32_t *total) +WERROR _dfs_EnumEx(pipes_struct *p, struct dfs_EnumEx *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _dfs_SetInfo2(pipes_struct *p) +WERROR _dfs_SetInfo2(pipes_struct *p, struct dfs_SetInfo2 *r) { /* FIXME: Implement your code here */ p->rng_fault_state = True; diff --git a/source3/rpc_server/srv_echo_nt.c b/source3/rpc_server/srv_echo_nt.c index b6c5442e03..eb095f6bfe 100644 --- a/source3/rpc_server/srv_echo_nt.c +++ b/source3/rpc_server/srv_echo_nt.c @@ -31,25 +31,25 @@ /* Add one to the input and return it */ -void _echo_AddOne(pipes_struct *p, uint32_t in_data, uint32_t *out_data) +void _echo_AddOne(pipes_struct *p, struct echo_AddOne *r) { DEBUG(10, ("_echo_add_one\n")); - *out_data = in_data + 1; + *r->out.out_data = r->in.in_data + 1; } /* Echo back an array of data */ -void _echo_EchoData(pipes_struct *p, uint32_t len, uint8_t *in_data, uint8_t *out_data) +void _echo_EchoData(pipes_struct *p, struct echo_EchoData *r) { DEBUG(10, ("_echo_data\n")); - memcpy(out_data, in_data, len); + memcpy(r->out.out_data, r->in.in_data, r->in.len); } /* Sink an array of data */ -void _echo_SinkData(pipes_struct *p, uint32_t len, uint8_t *data) +void _echo_SinkData(pipes_struct *p, struct echo_SinkData *r) { DEBUG(10, ("_sink_data\n")); @@ -58,47 +58,47 @@ void _echo_SinkData(pipes_struct *p, uint32_t len, uint8_t *data) /* Source an array of data */ -void _echo_SourceData(pipes_struct *p, uint32_t len, uint8_t *data) +void _echo_SourceData(pipes_struct *p, struct echo_SourceData *r) { uint32 i; DEBUG(10, ("_source_data\n")); - for (i = 0; i < len; i++) - data[i] = i & 0xff; + for (i = 0; i < r->in.len; i++) + r->out.data[i] = i & 0xff; } -void _echo_TestCall(pipes_struct *p, const char *s1, const char **s2) +void _echo_TestCall(pipes_struct *p, struct echo_TestCall *r) { - *s2 = talloc_strdup(p->mem_ctx, s1); + *r->out.s2 = talloc_strdup(p->mem_ctx, r->in.s1); } -NTSTATUS _echo_TestCall2(pipes_struct *p, uint16_t level, union echo_Info *info) +NTSTATUS _echo_TestCall2(pipes_struct *p, struct echo_TestCall2 *r) { - switch (level) { + switch (r->in.level) { case 1: - info->info1.v = 10; + r->out.info->info1.v = 10; break; case 2: - info->info2.v = 20; + r->out.info->info2.v = 20; break; case 3: - info->info3.v = 30; + r->out.info->info3.v = 30; break; case 4: - info->info4.v = 40; + r->out.info->info4.v = 40; break; case 5: - info->info5.v1 = 50; - info->info5.v2 = 60; + r->out.info->info5.v1 = 50; + r->out.info->info5.v2 = 60; break; case 6: - info->info6.v1 = 70; - info->info6.info1.v= 80; + r->out.info->info6.v1 = 70; + r->out.info->info6.info1.v= 80; break; case 7: - info->info7.v1 = 80; - info->info7.info4.v = 90; + r->out.info->info7.v1 = 80; + r->out.info->info7.info4.v = 90; break; default: return NT_STATUS_INVALID_LEVEL; @@ -107,29 +107,29 @@ NTSTATUS _echo_TestCall2(pipes_struct *p, uint16_t level, union echo_Info *info) return NT_STATUS_OK; } -uint32 _echo_TestSleep(pipes_struct *p, uint32_t seconds) +uint32 _echo_TestSleep(pipes_struct *p, struct echo_TestSleep *r) { - sleep(seconds); - return seconds; + sleep(r->in.seconds); + return r->in.seconds; } -void _echo_TestEnum(pipes_struct *p, enum echo_Enum1 *foo1, struct echo_Enum2 *foo2, union echo_Enum3 *foo3) +void _echo_TestEnum(pipes_struct *p, struct echo_TestEnum *r) { } -void _echo_TestSurrounding(pipes_struct *p, struct echo_Surrounding *data) +void _echo_TestSurrounding(pipes_struct *p, struct echo_TestSurrounding *r) { - data->x *= 2; - data->surrounding = talloc_zero_array(p->mem_ctx, uint16_t, data->x); + r->out.data->x *= 2; + r->out.data->surrounding = talloc_zero_array(p->mem_ctx, uint16_t, r->in.data->x); } -uint16 _echo_TestDoublePointer(pipes_struct *p, uint16_t ***data) +uint16 _echo_TestDoublePointer(pipes_struct *p, struct echo_TestDoublePointer *r) { - if (!*data) + if (!*r->in.data) return 0; - if (!**data) + if (!**r->in.data) return 0; - return ***data; + return ***r->in.data; } #endif /* DEVELOPER */ diff --git a/source3/rpc_server/srv_initshutdown_nt.c b/source3/rpc_server/srv_initshutdown_nt.c index a73077fe03..cd84f72058 100644 --- a/source3/rpc_server/srv_initshutdown_nt.c +++ b/source3/rpc_server/srv_initshutdown_nt.c @@ -30,24 +30,37 @@ /******************************************************************* ********************************************************************/ -WERROR _initshutdown_Init(pipes_struct *p, uint16_t *hostname, struct initshutdown_String *message, uint32_t timeout, uint8_t force_apps, uint8_t reboot) +WERROR _initshutdown_Init(pipes_struct *p, struct initshutdown_Init *r) { - uint32_t reason = 0; + struct winreg_InitiateSystemShutdownEx s; + + s.in.hostname = r->in.hostname; + s.in.message = r->in.message; + s.in.timeout = r->in.timeout; + s.in.force_apps = r->in.force_apps; + s.in.reboot = r->in.reboot; + s.in.reason = 0; /* thunk down to _winreg_InitiateSystemShutdownEx() (just returns a status) */ - return _winreg_InitiateSystemShutdownEx( p, hostname, message, timeout, - force_apps, reboot, reason ); + return _winreg_InitiateSystemShutdownEx( p, &s ); } /******************************************************************* ********************************************************************/ -WERROR _initshutdown_InitEx(pipes_struct *p, uint16_t *hostname, struct initshutdown_String *message, uint32_t timeout, uint8_t force_apps, uint8_t reboot, uint32_t reason) +WERROR _initshutdown_InitEx(pipes_struct *p, struct initshutdown_InitEx *r) { - return _winreg_InitiateSystemShutdownEx( p, hostname, message, timeout, - force_apps, reboot, reason ); + struct winreg_InitiateSystemShutdownEx s; + s.in.hostname = r->in.hostname; + s.in.message = r->in.message; + s.in.timeout = r->in.timeout; + s.in.force_apps = r->in.force_apps; + s.in.reboot = r->in.reboot; + s.in.reason = r->in.reason; + + return _winreg_InitiateSystemShutdownEx( p, &s); } @@ -57,7 +70,9 @@ WERROR _initshutdown_InitEx(pipes_struct *p, uint16_t *hostname, struct initshut reg_abort_shutdwon ********************************************************************/ -WERROR _initshutdown_Abort(pipes_struct *p, uint16_t *server) +WERROR _initshutdown_Abort(pipes_struct *p, struct initshutdown_Abort *r) { - return _winreg_AbortSystemShutdown( p, server ); + struct winreg_AbortSystemShutdown s; + s.in.server = r->in.server; + return _winreg_AbortSystemShutdown( p, &s ); } diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 44ec292750..76ec38af6f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1296,22 +1296,20 @@ NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOO _lsa_close. Also weird - needs to check if lsa handle is correct. JRA. ***************************************************************************/ -NTSTATUS _lsa_Close(pipes_struct *p, struct policy_handle *handle) +NTSTATUS _lsa_Close(pipes_struct *p, struct lsa_Close *r) { - if (!find_policy_by_hnd(p, handle, NULL)) { + if (!find_policy_by_hnd(p, r->in.handle, NULL)) { return NT_STATUS_INVALID_HANDLE; } - close_policy_hnd(p, handle); + close_policy_hnd(p, r->in.handle); return NT_STATUS_OK; } /*************************************************************************** ***************************************************************************/ -NTSTATUS _lsa_OpenSecret(pipes_struct *p, struct policy_handle *handle, - struct lsa_String name, uint32_t access_mask, - struct policy_handle *sec_handle) +NTSTATUS _lsa_OpenSecret(pipes_struct *p, struct lsa_OpenSecret *r) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -1319,9 +1317,7 @@ NTSTATUS _lsa_OpenSecret(pipes_struct *p, struct policy_handle *handle, /*************************************************************************** ***************************************************************************/ -NTSTATUS _lsa_OpenTrustedDomain(pipes_struct *p, struct policy_handle *handle, - struct dom_sid2 *sid, uint32_t access_mask, - struct policy_handle *trustdom_handle) +NTSTATUS _lsa_OpenTrustedDomain(pipes_struct *p, struct lsa_OpenTrustedDomain *r) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } @@ -1329,11 +1325,7 @@ NTSTATUS _lsa_OpenTrustedDomain(pipes_struct *p, struct policy_handle *handle, /*************************************************************************** ***************************************************************************/ -NTSTATUS _lsa_CreateTrustedDomain(pipes_struct *p, - struct policy_handle *handle, - struct lsa_DomainInfo *info, - uint32_t access_mask, - struct policy_handle *trustdom_handle) +NTSTATUS _lsa_CreateTrustedDomain(pipes_struct *p, struct lsa_CreateTrustedDomain *r) { return NT_STATUS_ACCESS_DENIED; } @@ -1341,9 +1333,7 @@ NTSTATUS _lsa_CreateTrustedDomain(pipes_struct *p, /*************************************************************************** ***************************************************************************/ -NTSTATUS _lsa_CreateSecret(pipes_struct *p, struct policy_handle *handle, - struct lsa_String name, uint32_t access_mask, - struct policy_handle *sec_handle) +NTSTATUS _lsa_CreateSecret(pipes_struct *p, struct lsa_CreateSecret *r) { return NT_STATUS_ACCESS_DENIED; } @@ -1351,9 +1341,7 @@ NTSTATUS _lsa_CreateSecret(pipes_struct *p, struct policy_handle *handle, /*************************************************************************** ***************************************************************************/ -NTSTATUS _lsa_SetSecret(pipes_struct *p, struct policy_handle *sec_handle, - struct lsa_DATA_BUF *new_val, - struct lsa_DATA_BUF *old_val) +NTSTATUS _lsa_SetSecret(pipes_struct *p, struct lsa_SetSecret *r) { return NT_STATUS_ACCESS_DENIED; } @@ -2141,457 +2129,457 @@ NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, L * pulling the server stubs across one by one. */ -NTSTATUS _lsa_Delete(pipes_struct *p, struct policy_handle *handle) +NTSTATUS _lsa_Delete(pipes_struct *p, struct lsa_Delete *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumPrivs(pipes_struct *p, struct policy_handle *handle, uint32_t *resume_handle, uint32_t max_count, struct lsa_PrivArray *_privs) +NTSTATUS _lsa_EnumPrivs(pipes_struct *p, struct lsa_EnumPrivs *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_QuerySecurity(pipes_struct *p, struct policy_handle *handle, uint32_t sec_info, struct sec_desc_buf *sdbuf) +NTSTATUS _lsa_QuerySecurity(pipes_struct *p, struct lsa_QuerySecurity *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_SetSecObj(pipes_struct *p) +NTSTATUS _lsa_SetSecObj(pipes_struct *p, struct lsa_SetSecObj *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_ChangePassword(pipes_struct *p) +NTSTATUS _lsa_ChangePassword(pipes_struct *p, struct lsa_ChangePassword *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_OpenPolicy(pipes_struct *p, uint16_t *system_name, struct lsa_ObjectAttribute *attr, uint32_t access_mask, struct policy_handle *handle) +NTSTATUS _lsa_OpenPolicy(pipes_struct *p, struct lsa_OpenPolicy *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, struct policy_handle *handle, uint16_t level, union lsa_PolicyInformation *info) +NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, struct lsa_QueryInfoPolicy *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_SetInfoPolicy(pipes_struct *p) +NTSTATUS _lsa_SetInfoPolicy(pipes_struct *p, struct lsa_SetInfoPolicy *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_ClearAuditLog(pipes_struct *p) +NTSTATUS _lsa_ClearAuditLog(pipes_struct *p, struct lsa_ClearAuditLog *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CreateAccount(pipes_struct *p, struct policy_handle *handle, struct dom_sid2 *sid, uint32_t access_mask, struct policy_handle *acct_handle) +NTSTATUS _lsa_CreateAccount(pipes_struct *p, struct lsa_CreateAccount *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumAccounts(pipes_struct *p, struct policy_handle *handle, uint32_t *resume_handle, uint32_t num_entries, struct lsa_SidArray *sids) +NTSTATUS _lsa_EnumAccounts(pipes_struct *p, struct lsa_EnumAccounts *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumTrustDom(pipes_struct *p, struct policy_handle *handle, uint32_t *resume_handle, uint32_t max_size, struct lsa_DomainList *domains) +NTSTATUS _lsa_EnumTrustDom(pipes_struct *p, struct lsa_EnumTrustDom *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupNames(pipes_struct *p, struct policy_handle *handle, uint32_t num_names, struct lsa_String *names, struct lsa_RefDomainList *domains, struct lsa_TransSidArray *sids, uint16_t level, uint32_t *count) +NTSTATUS _lsa_LookupNames(pipes_struct *p, struct lsa_LookupNames *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupSids(pipes_struct *p, struct policy_handle *handle, struct lsa_SidArray *sids, struct lsa_RefDomainList *domains, struct lsa_TransNameArray *names, uint16_t level, uint32_t *count) +NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_OpenAccount(pipes_struct *p, struct policy_handle *handle, struct dom_sid2 *sid, uint32_t access_mask, struct policy_handle *acct_handle) +NTSTATUS _lsa_OpenAccount(pipes_struct *p, struct lsa_OpenAccount *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumPrivsAccount(pipes_struct *p, struct policy_handle *handle, struct lsa_PrivilegeSet *_privs) +NTSTATUS _lsa_EnumPrivsAccount(pipes_struct *p, struct lsa_EnumPrivsAccount *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_AddPrivilegesToAccount(pipes_struct *p, struct policy_handle *handle, struct lsa_PrivilegeSet *_privs) +NTSTATUS _lsa_AddPrivilegesToAccount(pipes_struct *p, struct lsa_AddPrivilegesToAccount *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_RemovePrivilegesFromAccount(pipes_struct *p, struct policy_handle *handle, uint8_t remove_all, struct lsa_PrivilegeSet *_privs) +NTSTATUS _lsa_RemovePrivilegesFromAccount(pipes_struct *p, struct lsa_RemovePrivilegesFromAccount *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_GetQuotasForAccount(pipes_struct *p) +NTSTATUS _lsa_GetQuotasForAccount(pipes_struct *p, struct lsa_GetQuotasForAccount *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_SetQuotasForAccount(pipes_struct *p) +NTSTATUS _lsa_SetQuotasForAccount(pipes_struct *p, struct lsa_SetQuotasForAccount *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p) +NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p, struct lsa_GetSystemAccessAccount *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p) +NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p, struct lsa_SetSystemAccessAccount *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_QueryTrustedDomainInfo(pipes_struct *p, struct policy_handle *trustdom_handle, enum lsa_TrustDomInfoEnum level, union lsa_TrustedDomainInfo *info) +NTSTATUS _lsa_QueryTrustedDomainInfo(pipes_struct *p, struct lsa_QueryTrustedDomainInfo *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_SetInformationTrustedDomain(pipes_struct *p) +NTSTATUS _lsa_SetInformationTrustedDomain(pipes_struct *p, struct lsa_SetInformationTrustedDomain *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_QuerySecret(pipes_struct *p, struct policy_handle *sec_handle, struct lsa_DATA_BUF_PTR *new_val, NTTIME *new_mtime, struct lsa_DATA_BUF_PTR *old_val, NTTIME *old_mtime) +NTSTATUS _lsa_QuerySecret(pipes_struct *p, struct lsa_QuerySecret *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupPrivValue(pipes_struct *p, struct policy_handle *handle, struct lsa_String *name, struct lsa_LUID *luid) +NTSTATUS _lsa_LookupPrivValue(pipes_struct *p, struct lsa_LookupPrivValue *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupPrivName(pipes_struct *p, struct policy_handle *handle, struct lsa_LUID *luid, struct lsa_StringLarge *name) +NTSTATUS _lsa_LookupPrivName(pipes_struct *p, struct lsa_LookupPrivName *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p, struct policy_handle *handle, struct lsa_String *name, struct lsa_StringLarge *disp_name, uint16_t *language_id, uint16_t unknown) +NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p, struct lsa_LookupPrivDisplayName *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_DeleteObject(pipes_struct *p) +NTSTATUS _lsa_DeleteObject(pipes_struct *p, struct lsa_DeleteObject *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumAccountsWithUserRight(pipes_struct *p, struct policy_handle *handle, struct lsa_String *name, struct lsa_SidArray *sids) +NTSTATUS _lsa_EnumAccountsWithUserRight(pipes_struct *p, struct lsa_EnumAccountsWithUserRight *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumAccountRights(pipes_struct *p, struct policy_handle *handle, struct dom_sid2 *sid, struct lsa_RightSet *rights) +NTSTATUS _lsa_EnumAccountRights(pipes_struct *p, struct lsa_EnumAccountRights *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_AddAccountRights(pipes_struct *p, struct policy_handle *handle, struct dom_sid2 *sid, struct lsa_RightSet *rights) +NTSTATUS _lsa_AddAccountRights(pipes_struct *p, struct lsa_AddAccountRights *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p, struct policy_handle *handle, struct dom_sid2 *sid, uint32_t unknown, struct lsa_RightSet *rights) +NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p, struct lsa_RemoveAccountRights *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_QueryTrustedDomainInfoBySid(pipes_struct *p, struct policy_handle *handle, struct dom_sid2 *dom_sid, enum lsa_TrustDomInfoEnum level, union lsa_TrustedDomainInfo *info) +NTSTATUS _lsa_QueryTrustedDomainInfoBySid(pipes_struct *p, struct lsa_QueryTrustedDomainInfoBySid *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_SetTrustedDomainInfo(pipes_struct *p) +NTSTATUS _lsa_SetTrustedDomainInfo(pipes_struct *p, struct lsa_SetTrustedDomainInfo *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_DeleteTrustedDomain(pipes_struct *p, struct policy_handle *handle, struct dom_sid2 *dom_sid) +NTSTATUS _lsa_DeleteTrustedDomain(pipes_struct *p, struct lsa_DeleteTrustedDomain *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_StorePrivateData(pipes_struct *p) +NTSTATUS _lsa_StorePrivateData(pipes_struct *p, struct lsa_StorePrivateData *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_RetrievePrivateData(pipes_struct *p) +NTSTATUS _lsa_RetrievePrivateData(pipes_struct *p, struct lsa_RetrievePrivateData *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_OpenPolicy2(pipes_struct *p, const char *system_name, struct lsa_ObjectAttribute *attr, uint32_t access_mask, struct policy_handle *handle) +NTSTATUS _lsa_OpenPolicy2(pipes_struct *p, struct lsa_OpenPolicy2 *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_GetUserName(pipes_struct *p, const char *system_name, struct lsa_String *account_name, struct lsa_StringPointer *authority_name) +NTSTATUS _lsa_GetUserName(pipes_struct *p, struct lsa_GetUserName *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_QueryInfoPolicy2(pipes_struct *p, struct policy_handle *handle, uint16_t level, union lsa_PolicyInformation *info) +NTSTATUS _lsa_QueryInfoPolicy2(pipes_struct *p, struct lsa_QueryInfoPolicy2 *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_SetInfoPolicy2(pipes_struct *p) +NTSTATUS _lsa_SetInfoPolicy2(pipes_struct *p, struct lsa_SetInfoPolicy2 *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_QueryTrustedDomainInfoByName(pipes_struct *p, struct policy_handle *handle, struct lsa_String trusted_domain, enum lsa_TrustDomInfoEnum level, union lsa_TrustedDomainInfo *info) +NTSTATUS _lsa_QueryTrustedDomainInfoByName(pipes_struct *p, struct lsa_QueryTrustedDomainInfoByName *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_SetTrustedDomainInfoByName(pipes_struct *p, struct policy_handle *handle, struct lsa_String trusted_domain, enum lsa_TrustDomInfoEnum level, union lsa_TrustedDomainInfo *info) +NTSTATUS _lsa_SetTrustedDomainInfoByName(pipes_struct *p, struct lsa_SetTrustedDomainInfoByName *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumTrustedDomainsEx(pipes_struct *p, struct policy_handle *handle, uint32_t *resume_handle, struct lsa_DomainListEx *domains, uint32_t max_size) +NTSTATUS _lsa_EnumTrustedDomainsEx(pipes_struct *p, struct lsa_EnumTrustedDomainsEx *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CreateTrustedDomainEx(pipes_struct *p) +NTSTATUS _lsa_CreateTrustedDomainEx(pipes_struct *p, struct lsa_CreateTrustedDomainEx *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CloseTrustedDomainEx(pipes_struct *p, struct policy_handle *handle) +NTSTATUS _lsa_CloseTrustedDomainEx(pipes_struct *p, struct lsa_CloseTrustedDomainEx *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_QueryDomainInformationPolicy(pipes_struct *p, struct policy_handle *handle, uint16_t level, union lsa_DomainInformationPolicy *info) +NTSTATUS _lsa_QueryDomainInformationPolicy(pipes_struct *p, struct lsa_QueryDomainInformationPolicy *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_SetDomainInformationPolicy(pipes_struct *p, struct policy_handle *handle, uint16_t level, union lsa_DomainInformationPolicy *info) +NTSTATUS _lsa_SetDomainInformationPolicy(pipes_struct *p, struct lsa_SetDomainInformationPolicy *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_OpenTrustedDomainByName(pipes_struct *p, struct policy_handle *handle, struct lsa_String name, uint32_t access_mask, struct policy_handle *trustdom_handle) +NTSTATUS _lsa_OpenTrustedDomainByName(pipes_struct *p, struct lsa_OpenTrustedDomainByName *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_TestCall(pipes_struct *p) +NTSTATUS _lsa_TestCall(pipes_struct *p, struct lsa_TestCall *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupSids2(pipes_struct *p, struct policy_handle *handle, struct lsa_SidArray *sids, struct lsa_RefDomainList *domains, struct lsa_TransNameArray2 *names, uint16_t level, uint32_t *count, uint32_t unknown1, uint32_t unknown2) +NTSTATUS _lsa_LookupSids2(pipes_struct *p, struct lsa_LookupSids2 *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupNames2(pipes_struct *p, struct policy_handle *handle, uint32_t num_names, struct lsa_String *names, struct lsa_RefDomainList *domains, struct lsa_TransSidArray2 *sids, uint16_t level, uint32_t *count, uint32_t unknown1, uint32_t unknown2) +NTSTATUS _lsa_LookupNames2(pipes_struct *p, struct lsa_LookupNames2 *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CreateTrustedDomainEx2(pipes_struct *p) +NTSTATUS _lsa_CreateTrustedDomainEx2(pipes_struct *p, struct lsa_CreateTrustedDomainEx2 *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CREDRWRITE(pipes_struct *p) +NTSTATUS _lsa_CREDRWRITE(pipes_struct *p, struct lsa_CREDRWRITE *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CREDRREAD(pipes_struct *p) +NTSTATUS _lsa_CREDRREAD(pipes_struct *p, struct lsa_CREDRREAD *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CREDRENUMERATE(pipes_struct *p) +NTSTATUS _lsa_CREDRENUMERATE(pipes_struct *p, struct lsa_CREDRENUMERATE *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CREDRWRITEDOMAINCREDENTIALS(pipes_struct *p) +NTSTATUS _lsa_CREDRWRITEDOMAINCREDENTIALS(pipes_struct *p, struct lsa_CREDRWRITEDOMAINCREDENTIALS *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CREDRREADDOMAINCREDENTIALS(pipes_struct *p) +NTSTATUS _lsa_CREDRREADDOMAINCREDENTIALS(pipes_struct *p, struct lsa_CREDRREADDOMAINCREDENTIALS *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CREDRDELETE(pipes_struct *p) +NTSTATUS _lsa_CREDRDELETE(pipes_struct *p, struct lsa_CREDRDELETE *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CREDRGETTARGETINFO(pipes_struct *p) +NTSTATUS _lsa_CREDRGETTARGETINFO(pipes_struct *p, struct lsa_CREDRGETTARGETINFO *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CREDRPROFILELOADED(pipes_struct *p) +NTSTATUS _lsa_CREDRPROFILELOADED(pipes_struct *p, struct lsa_CREDRPROFILELOADED *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupNames3(pipes_struct *p, struct policy_handle *handle, uint32_t num_names, struct lsa_String *names, struct lsa_RefDomainList *domains, struct lsa_TransSidArray3 *sids, uint16_t level, uint32_t *count, uint32_t unknown1, uint32_t unknown2) +NTSTATUS _lsa_LookupNames3(pipes_struct *p, struct lsa_LookupNames3 *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CREDRGETSESSIONTYPES(pipes_struct *p) +NTSTATUS _lsa_CREDRGETSESSIONTYPES(pipes_struct *p, struct lsa_CREDRGETSESSIONTYPES *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LSARREGISTERAUDITEVENT(pipes_struct *p) +NTSTATUS _lsa_LSARREGISTERAUDITEVENT(pipes_struct *p, struct lsa_LSARREGISTERAUDITEVENT *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LSARGENAUDITEVENT(pipes_struct *p) +NTSTATUS _lsa_LSARGENAUDITEVENT(pipes_struct *p, struct lsa_LSARGENAUDITEVENT *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LSARUNREGISTERAUDITEVENT(pipes_struct *p) +NTSTATUS _lsa_LSARUNREGISTERAUDITEVENT(pipes_struct *p, struct lsa_LSARUNREGISTERAUDITEVENT *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LSARQUERYFORESTTRUSTINFORMATION(pipes_struct *p) +NTSTATUS _lsa_LSARQUERYFORESTTRUSTINFORMATION(pipes_struct *p, struct lsa_LSARQUERYFORESTTRUSTINFORMATION *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LSARSETFORESTTRUSTINFORMATION(pipes_struct *p) +NTSTATUS _lsa_LSARSETFORESTTRUSTINFORMATION(pipes_struct *p, struct lsa_LSARSETFORESTTRUSTINFORMATION *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CREDRRENAME(pipes_struct *p) +NTSTATUS _lsa_CREDRRENAME(pipes_struct *p, struct lsa_CREDRRENAME *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupSids3(pipes_struct *p, struct lsa_SidArray *sids, struct lsa_RefDomainList *domains, struct lsa_TransNameArray2 *names, uint16_t level, uint32_t *count, uint32_t unknown1, uint32_t unknown2) +NTSTATUS _lsa_LookupSids3(pipes_struct *p, struct lsa_LookupSids3 *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupNames4(pipes_struct *p, uint32_t num_names, struct lsa_String *names, struct lsa_RefDomainList *domains, struct lsa_TransSidArray3 *sids, uint16_t level, uint32_t *count, uint32_t unknown1, uint32_t unknown2) +NTSTATUS _lsa_LookupNames4(pipes_struct *p, struct lsa_LookupNames4 *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LSAROPENPOLICYSCE(pipes_struct *p) +NTSTATUS _lsa_LSAROPENPOLICYSCE(pipes_struct *p, struct lsa_LSAROPENPOLICYSCE *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LSARADTREGISTERSECURITYEVENTSOURCE(pipes_struct *p) +NTSTATUS _lsa_LSARADTREGISTERSECURITYEVENTSOURCE(pipes_struct *p, struct lsa_LSARADTREGISTERSECURITYEVENTSOURCE *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(pipes_struct *p) +NTSTATUS _lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE(pipes_struct *p, struct lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LSARADTREPORTSECURITYEVENT(pipes_struct *p) +NTSTATUS _lsa_LSARADTREPORTSECURITYEVENT(pipes_struct *p, struct lsa_LSARADTREPORTSECURITYEVENT *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index a9adaf3200..06c84b60e9 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1063,11 +1063,11 @@ static WERROR net_file_enum_3(pipes_struct *p, union srvsvc_NetFileCtr *ctr, uin /******************************************************************* *******************************************************************/ -WERROR _srvsvc_NetFileEnum(pipes_struct *p, const char *server_unc, const char *path, const char *user, uint32_t *level, union srvsvc_NetFileCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +WERROR _srvsvc_NetFileEnum(pipes_struct *p, struct srvsvc_NetFileEnum *r) { - switch ( *level ) { + switch ( *r->in.level ) { case 3: - return net_file_enum_3(p, ctr, resume_handle, totalentries ); + return net_file_enum_3(p, r->in.ctr, r->in.resume_handle, r->out.totalentries ); default: return WERR_UNKNOWN_LEVEL; } @@ -1079,11 +1079,11 @@ WERROR _srvsvc_NetFileEnum(pipes_struct *p, const char *server_unc, const char * net server get info ********************************************************************/ -WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetSrvInfo *info) +WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, struct srvsvc_NetSrvGetInfo *r) { WERROR status = WERR_OK; - ZERO_STRUCTP(info); + ZERO_STRUCTP(r->out.info); DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); @@ -1092,42 +1092,42 @@ WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, const char *server_unc, uint32_t l return WERR_ACCESS_DENIED; } - switch (level) { + switch (r->in.level) { /* Technically level 102 should only be available to Administrators but there isn't anything super-secret here, as most of it is made up. */ case 102: - info->info102 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo102); - - info->info102->platform_id = 500; - info->info102->version_major = lp_major_announce_version(); - info->info102->version_minor = lp_minor_announce_version(); - info->info102->server_name = global_myname(); - info->info102->server_type = lp_default_server_announce(); - info->info102->userpath = "C:\\"; - info->info102->licenses = 10000; - info->info102->anndelta = 3000; - info->info102->disc = 0xf; - info->info102->users = 0xffffffff; - info->info102->hidden = 0; - info->info102->announce = 240; - info->info102->comment = lp_serverstring(); + r->out.info->info102 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo102); + + r->out.info->info102->platform_id = 500; + r->out.info->info102->version_major = lp_major_announce_version(); + r->out.info->info102->version_minor = lp_minor_announce_version(); + r->out.info->info102->server_name = global_myname(); + r->out.info->info102->server_type = lp_default_server_announce(); + r->out.info->info102->userpath = "C:\\"; + r->out.info->info102->licenses = 10000; + r->out.info->info102->anndelta = 3000; + r->out.info->info102->disc = 0xf; + r->out.info->info102->users = 0xffffffff; + r->out.info->info102->hidden = 0; + r->out.info->info102->announce = 240; + r->out.info->info102->comment = lp_serverstring(); break; case 101: - info->info101 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo101); - info->info101->platform_id = 500; - info->info101->server_name = global_myname(); - info->info101->version_major = lp_major_announce_version(); - info->info101->version_minor = lp_minor_announce_version(); - info->info101->server_type = lp_default_server_announce(); - info->info101->comment = lp_serverstring(); + r->out.info->info101 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo101); + r->out.info->info101->platform_id = 500; + r->out.info->info101->server_name = global_myname(); + r->out.info->info101->version_major = lp_major_announce_version(); + r->out.info->info101->version_minor = lp_minor_announce_version(); + r->out.info->info101->server_type = lp_default_server_announce(); + r->out.info->info101->comment = lp_serverstring(); break; case 100: - info->info100 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo100); - info->info100->platform_id = 500; - info->info100->server_name = global_myname(); + r->out.info->info100 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo100); + r->out.info->info100->platform_id = 500; + r->out.info->info100->server_name = global_myname(); break; default: return WERR_UNKNOWN_LEVEL; @@ -1143,11 +1143,11 @@ WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, const char *server_unc, uint32_t l net server set info ********************************************************************/ -WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetSrvInfo info, uint32_t *parm_error) +WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, struct srvsvc_NetSrvSetInfo *r) { /* Set up the net server set info structure. */ - if (parm_error) { - *parm_error = 0; + if (r->out.parm_error) { + *r->out.parm_error = 0; } return WERR_OK; } @@ -1156,44 +1156,44 @@ WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, const char *server_unc, uint32_t l net conn enum ********************************************************************/ -WERROR _srvsvc_NetConnEnum(pipes_struct *p, const char *server_unc, const char *path, uint32_t *level, union srvsvc_NetConnCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +WERROR _srvsvc_NetConnEnum(pipes_struct *p, struct srvsvc_NetConnEnum *r) { DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); - ZERO_STRUCTP(ctr); + ZERO_STRUCTP(r->out.ctr); /* set up the */ - return init_srv_conn_info_ctr(p, ctr, *level, resume_handle, totalentries); + return init_srv_conn_info_ctr(p, r->out.ctr, *r->in.level, r->in.resume_handle, r->out.totalentries); } /******************************************************************* net sess enum ********************************************************************/ -WERROR _srvsvc_NetSessEnum(pipes_struct *p, const char *server_unc, const char *client, const char *user, uint32_t *level, union srvsvc_NetSessCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +WERROR _srvsvc_NetSessEnum(pipes_struct *p, struct srvsvc_NetSessEnum *r) { DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__)); - ZERO_STRUCTP(ctr); + ZERO_STRUCTP(r->out.ctr); /* set up the */ - return init_srv_sess_info_ctr(p, ctr, - *level, - resume_handle, - totalentries); + return init_srv_sess_info_ctr(p, r->out.ctr, + *r->in.level, + r->in.resume_handle, + r->out.totalentries); } /******************************************************************* net sess del ********************************************************************/ -WERROR _srvsvc_NetSessDel(pipes_struct *p, const char *server_unc, const char *client, const char *user) +WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r) { struct sessionid *session_list; int num_sessions, snum; WERROR status; - char *machine = talloc_strdup(p->mem_ctx, server_unc); + char *machine = talloc_strdup(p->mem_ctx, r->in.server_unc); /* strip leading backslashes if any */ while (machine[0] == '\\') { @@ -1216,8 +1216,8 @@ WERROR _srvsvc_NetSessDel(pipes_struct *p, const char *server_unc, const char *c for (snum = 0; snum < num_sessions; snum++) { - if ((strequal(session_list[snum].username, user) || user[0] == '\0' ) && - strequal(session_list[snum].remote_machine, machine)) { + if ((strequal(session_list[snum].username, r->in.user) || r->in.user[0] == '\0' ) && + strequal(session_list[snum].remote_machine, machine)) { if (message_send_pid(pid_to_procid(session_list[snum].pid), MSG_SHUTDOWN, NULL, 0, False)) status = WERR_OK; @@ -1237,7 +1237,7 @@ done: Net share enum all. ********************************************************************/ -WERROR _srvsvc_NetShareEnumAll(pipes_struct *p, const char *server_unc, uint32_t *level, union srvsvc_NetShareCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +WERROR _srvsvc_NetShareEnumAll(pipes_struct *p, struct srvsvc_NetShareEnumAll *r) { DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); @@ -1247,15 +1247,15 @@ WERROR _srvsvc_NetShareEnumAll(pipes_struct *p, const char *server_unc, uint32_t } /* Create the list of shares for the response. */ - return init_srv_share_info_ctr(p, ctr, *level, - resume_handle, totalentries, True); + return init_srv_share_info_ctr(p, r->out.ctr, *r->in.level, + r->in.resume_handle, r->out.totalentries, True); } /******************************************************************* Net share enum. ********************************************************************/ -WERROR _srvsvc_NetShareEnum(pipes_struct *p, const char *server_unc, uint32_t *level, union srvsvc_NetShareCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +WERROR _srvsvc_NetShareEnum(pipes_struct *p, struct srvsvc_NetShareEnum *r) { DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); @@ -1265,79 +1265,72 @@ WERROR _srvsvc_NetShareEnum(pipes_struct *p, const char *server_unc, uint32_t *l } /* Create the list of shares for the response. */ - return init_srv_share_info_ctr(p, ctr, *level, - resume_handle, totalentries, False); + return init_srv_share_info_ctr(p, r->out.ctr, *r->in.level, + r->in.resume_handle, r->out.totalentries, False); } /******************************************************************* Net share get info. ********************************************************************/ -WERROR _srvsvc_NetShareGetInfo(pipes_struct *p, const char *server_unc, const char *share_name, uint32_t level, union srvsvc_NetShareInfo *info) +WERROR _srvsvc_NetShareGetInfo(pipes_struct *p, struct srvsvc_NetShareGetInfo *r) { const struct share_params *params; - params = get_share_params(p->mem_ctx, share_name); + params = get_share_params(p->mem_ctx, r->in.share_name); if (params != NULL) { - switch (level) { + switch (r->in.level) { case 0: - info->info0 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo0); - init_srv_share_info_0(p, info->info0, - params); + r->out.info->info0 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo0); + init_srv_share_info_0(p, r->out.info->info0, params); break; case 1: - info->info1 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1); - init_srv_share_info_1(p, info->info1, - params); + r->out.info->info1 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1); + init_srv_share_info_1(p, r->out.info->info1, params); break; case 2: - info->info2 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo2); - init_srv_share_info_2(p, info->info2, - params); + r->out.info->info2 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo2); + init_srv_share_info_2(p, r->out.info->info2, params); break; case 501: - info->info501 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo501); - init_srv_share_info_501(p, info->info501, - params); + r->out.info->info501 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo501); + init_srv_share_info_501(p, r->out.info->info501, params); break; case 502: - info->info502 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo502); - init_srv_share_info_502(p, info->info502, - params); + r->out.info->info502 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo502); + init_srv_share_info_502(p, r->out.info->info502, params); break; /* here for completeness */ case 1004: - info->info1004 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1004); - init_srv_share_info_1004(p, info->info1004, - params); + r->out.info->info1004 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1004); + init_srv_share_info_1004(p, r->out.info->info1004, params); break; case 1005: - info->info1005 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1005); - init_srv_share_info_1005(p, info->info1005, - params); + r->out.info->info1005 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1005); + init_srv_share_info_1005(p, r->out.info->info1005, params); break; /* here for completeness 1006 - 1501 */ case 1006: - info->info1006 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1006); - init_srv_share_info_1006(p, info->info1006, + r->out.info->info1006 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1006); + init_srv_share_info_1006(p, r->out.info->info1006, params); break; case 1007: - info->info1007 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1007); - init_srv_share_info_1007(p, info->info1007, + r->out.info->info1007 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1007); + init_srv_share_info_1007(p, r->out.info->info1007, params); break; case 1501: - info->info1501 = talloc(p->mem_ctx, struct sec_desc_buf); - init_srv_share_info_1501(p, info->info1501, + r->out.info->info1501 = talloc(p->mem_ctx, struct sec_desc_buf); + init_srv_share_info_1501(p, r->out.info->info1501, params); break; default: DEBUG(5,("init_srv_net_share_get_info: unsupported " - "switch value %d\n", level)); + "switch value %d\n", r->in.level)); return WERR_UNKNOWN_LEVEL; break; } @@ -1630,10 +1623,7 @@ static WERROR change_share(const char *share_name, const char *path, Net share set info. Modify share details. ********************************************************************/ -WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, - const char *share_name, uint32_t level, - union srvsvc_NetShareInfo info, - uint32_t *parm_error) +WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r) { pstring comment; pstring pathname; @@ -1648,18 +1638,18 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); - if (parm_error) { - *parm_error = 0; + if (r->out.parm_error) { + *r->out.parm_error = 0; } - if ( strequal(share_name,"IPC$") - || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) - || strequal(share_name,"global") ) + if ( strequal(r->in.share_name,"IPC$") + || ( lp_enable_asu_support() && strequal(r->in.share_name,"ADMIN$") ) + || strequal(r->in.share_name,"global") ) { return WERR_ACCESS_DENIED; } - fstrcpy(tmp_share_name, share_name); + fstrcpy(tmp_share_name, r->in.share_name); snum = find_service(tmp_share_name); /* Does this share exist ? */ @@ -1678,31 +1668,31 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, if ( p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; - switch (level) { + switch (r->in.level) { case 1: pstrcpy(pathname, lp_pathname(snum)); - pstrcpy(comment, info.info1->comment); - type = info.info1->type; + pstrcpy(comment, r->in.info.info1->comment); + type = r->in.info.info1->type; psd = NULL; break; case 2: - pstrcpy(comment, info.info2->comment); - pstrcpy(pathname, info.info2->path); - type = info.info2->type; - max_connections = (info.info2->max_users == 0xffffffff) ? - 0 : info.info2->max_users; + pstrcpy(comment, r->in.info.info2->comment); + pstrcpy(pathname, r->in.info.info2->path); + type = r->in.info.info2->type; + max_connections = (r->in.info.info2->max_users == 0xffffffff) ? + 0 : r->in.info.info2->max_users; psd = NULL; break; case 502: - pstrcpy(comment, info.info502->comment); - pstrcpy(pathname, info.info502->path); - type = info.info502->type; - psd = info.info502->sd; + pstrcpy(comment, r->in.info.info502->comment); + pstrcpy(pathname, r->in.info.info502->path); + type = r->in.info.info502->type; + psd = r->in.info.info502->sd; map_generic_share_sd_bits(psd); break; case 1004: pstrcpy(pathname, lp_pathname(snum)); - pstrcpy(comment, info.info1004->comment); + pstrcpy(comment, r->in.info.info1004->comment); type = STYPE_DISKTREE; break; case 1005: @@ -1710,7 +1700,7 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, user, so we must compare it to see if it's what is set in smb.conf, so that we can contine other ops like setting ACLs on a share */ - if (((info.info1005->dfs_flags & + if (((r->in.info.info1005->dfs_flags & SHARE_1005_CSC_POLICY_MASK) >> SHARE_1005_CSC_POLICY_SHIFT) == lp_csc_policy(snum)) return WERR_OK; @@ -1726,13 +1716,13 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, case 1501: pstrcpy(pathname, lp_pathname(snum)); pstrcpy(comment, lp_comment(snum)); - psd = info.info1501->sd; + psd = r->in.info.info1501->sd; map_generic_share_sd_bits(psd); type = STYPE_DISKTREE; break; default: DEBUG(5,("_srv_net_share_set_info: unsupported switch value " - "%d\n", level)); + "%d\n", r->in.level)); return WERR_UNKNOWN_LEVEL; } @@ -1778,10 +1768,10 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, &sd_size); if (old_sd && !sec_desc_equal(old_sd, psd)) { - if (!set_share_security(share_name, psd)) { + if (!set_share_security(r->in.share_name, psd)) { DEBUG(0,("_srv_net_share_set_info: Failed to " "change security info in share %s.\n", - share_name )); + r->in.share_name )); } } } @@ -1797,9 +1787,7 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, const char *server_unc, "comment" "max connections = " ********************************************************************/ -WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, - uint32_t level, union srvsvc_NetShareInfo info, - uint32_t *parm_error) +WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r) { pstring share_name; pstring comment; @@ -1814,8 +1802,8 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); - if (parm_error) { - *parm_error = 0; + if (r->out.parm_error) { + *r->out.parm_error = 0; } is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, @@ -1824,7 +1812,7 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, if (p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; - switch (level) { + switch (r->in.level) { case 0: /* No path. Not enough info in a level 0 to do anything. */ return WERR_ACCESS_DENIED; @@ -1832,22 +1820,22 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, /* Not enough info in a level 1 to do anything. */ return WERR_ACCESS_DENIED; case 2: - pstrcpy(share_name, info.info2->name); - pstrcpy(comment, info.info2->comment); - pstrcpy(pathname, info.info2->path); - max_connections = (info.info2->max_users == 0xffffffff) ? - 0 : info.info2->max_users; - type = info.info2->type; + pstrcpy(share_name, r->in.info.info2->name); + pstrcpy(comment, r->in.info.info2->comment); + pstrcpy(pathname, r->in.info.info2->path); + max_connections = (r->in.info.info2->max_users == 0xffffffff) ? + 0 : r->in.info.info2->max_users; + type = r->in.info.info2->type; break; case 501: /* No path. Not enough info in a level 501 to do anything. */ return WERR_ACCESS_DENIED; case 502: - pstrcpy(share_name, info.info502->name); - pstrcpy(comment, info.info502->comment); - pstrcpy(pathname, info.info502->path); - type = info.info502->type; - psd = info.info502->sd; + pstrcpy(share_name, r->in.info.info502->name); + pstrcpy(comment, r->in.info.info502->comment); + pstrcpy(pathname, r->in.info.info502->path); + type = r->in.info.info502->type; + psd = r->in.info.info502->sd; map_generic_share_sd_bits(psd); break; @@ -1864,7 +1852,7 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, return WERR_ACCESS_DENIED; default: DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", - level)); + r->in.level)); return WERR_UNKNOWN_LEVEL; } @@ -1933,8 +1921,7 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, const char *server_unc, a parameter. ********************************************************************/ -WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, - const char *share_name, uint32_t reserved) +WERROR _srvsvc_NetShareDel(pipes_struct *p, struct srvsvc_NetShareDel *r) { struct share_params *params; SE_PRIV se_diskop = SE_DISK_OPERATOR; @@ -1943,14 +1930,14 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, DEBUG(5,("_srv_net_share_del: %d\n", __LINE__)); - if ( strequal(share_name,"IPC$") - || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) - || strequal(share_name,"global") ) + if ( strequal(r->in.share_name, "IPC$") + || ( lp_enable_asu_support() && strequal(r->in.share_name,"ADMIN$") ) + || strequal(r->in.share_name, "global") ) { return WERR_ACCESS_DENIED; } - if (!(params = get_share_params(p->mem_ctx, share_name))) { + if (!(params = get_share_params(p->mem_ctx, r->in.share_name))) { return WERR_NO_SUCH_SHARE; } @@ -1979,19 +1966,24 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, const char *server_unc, return WERR_OK; } -WERROR _srvsvc_NetShareDelSticky(pipes_struct *p, const char *server_unc, - const char *share_name, uint32_t reserved) +WERROR _srvsvc_NetShareDelSticky(pipes_struct *p, struct srvsvc_NetShareDelSticky *r) { + struct srvsvc_NetShareDel s; + DEBUG(5,("_srv_net_share_del_stick: %d\n", __LINE__)); - return _srvsvc_NetShareDel(p, server_unc, share_name, reserved); + s.in.server_unc = r->in.server_unc; + s.in.share_name = r->in.share_name; + s.in.reserved = r->in.reserved; + + return _srvsvc_NetShareDel(p, &s); } /******************************************************************* time of day ********************************************************************/ -WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, const char *server_unc, struct srvsvc_NetRemoteTODInfo *tod) +WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, struct srvsvc_NetRemoteTOD *r) { struct tm *t; time_t unixdate = time(NULL); @@ -2007,18 +1999,18 @@ WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, const char *server_unc, struct srvs t = gmtime(&unixdate); /* set up the */ - tod->elapsed = unixdate; - tod->msecs = 0; - tod->hours = t->tm_hour; - tod->mins = t->tm_min; - tod->secs = t->tm_sec; - tod->hunds = 0; - tod->timezone = zone; - tod->tinterval = 10000; - tod->day = t->tm_mday; - tod->month = t->tm_mon + 1; - tod->year = 1900+t->tm_year; - tod->weekday = t->tm_wday; + r->out.info->elapsed = unixdate; + r->out.info->msecs = 0; + r->out.info->hours = t->tm_hour; + r->out.info->mins = t->tm_min; + r->out.info->secs = t->tm_sec; + r->out.info->hunds = 0; + r->out.info->timezone = zone; + r->out.info->tinterval = 10000; + r->out.info->day = t->tm_mday; + r->out.info->month = t->tm_mon + 1; + r->out.info->year = 1900+t->tm_year; + r->out.info->weekday = t->tm_wday; DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); @@ -2029,7 +2021,7 @@ WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, const char *server_unc, struct srvs Win9x NT tools get security descriptor. ***********************************************************************************/ -WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, const char *server_unc, const char *share, const char *file, uint32_t securityinformation, struct sec_desc_buf *sd_buf) +WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecurity *r) { SEC_DESC *psd = NULL; size_t sd_size; @@ -2049,11 +2041,11 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, const char *server_unc, const null_pw = data_blob(NULL, 0); become_root(); - conn = make_connection(share, null_pw, "A:", p->pipe_user.vuid, &nt_status); + conn = make_connection(r->in.share, null_pw, "A:", p->pipe_user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", share)); + DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", r->in.share)); status = ntstatus_to_werror(nt_status); goto error_exit; } @@ -2065,26 +2057,26 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, const char *server_unc, const } became_user = True; - pstrcpy(tmp_file, file); + pstrcpy(tmp_file, r->in.file); nt_status = unix_convert(conn, tmp_file, False, NULL, &st); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", file)); + DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", r->in.file)); status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = check_name(conn, file); + nt_status = check_name(conn, r->in.file); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", file)); + DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", r->in.file)); status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = open_file_stat(conn, file, &st, &fsp); + nt_status = open_file_stat(conn, r->in.file, &st, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { /* Perhaps it is a directory */ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) - nt_status = open_directory(conn, file, &st, + nt_status = open_directory(conn, r->in.file, &st, READ_CONTROL_ACCESS, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, @@ -2092,7 +2084,7 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, const char *server_unc, const NULL, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", file)); + DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", r->in.file)); status = WERR_ACCESS_DENIED; goto error_exit; } @@ -2101,13 +2093,13 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, const char *server_unc, const sd_size = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION), &psd); if (sd_size == 0) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", file)); + DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", r->in.file)); status = WERR_ACCESS_DENIED; goto error_exit; } - sd_buf->sd_size= sd_size; - sd_buf->sd = psd; + r->out.sd_buf->sd_size= sd_size; + r->out.sd_buf->sd = psd; psd->dacl->revision = (uint16) NT4_ACL_REVISION; @@ -2135,7 +2127,7 @@ error_exit: Win9x NT tools set security descriptor. ***********************************************************************************/ -WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, const char *server_unc, const char *share, const char *file, uint32_t securityinformation, struct sec_desc_buf sd_buf) +WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecurity *r) { BOOL ret; DATA_BLOB null_pw; @@ -2153,11 +2145,11 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, const char *server_unc, const null_pw = data_blob(NULL, 0); become_root(); - conn = make_connection(share, null_pw, "A:", p->pipe_user.vuid, &nt_status); + conn = make_connection(r->in.share, null_pw, "A:", p->pipe_user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", share)); + DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", r->in.share)); status = ntstatus_to_werror(nt_status); goto error_exit; } @@ -2169,28 +2161,28 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, const char *server_unc, const } became_user = True; - pstrcpy(tmp_file, file); + pstrcpy(tmp_file, r->in.file); nt_status = unix_convert(conn, tmp_file, False, NULL, &st); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", file)); + DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", r->in.file)); status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = check_name(conn, file); + nt_status = check_name(conn, r->in.file); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", file)); + DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", r->in.file)); status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = open_file_stat(conn, file, &st, &fsp); + nt_status = open_file_stat(conn, r->in.file, &st, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { /* Perhaps it is a directory */ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) - nt_status = open_directory(conn, file, &st, + nt_status = open_directory(conn, r->in.file, &st, FILE_READ_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, @@ -2198,16 +2190,16 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, const char *server_unc, const NULL, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", file)); + DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", r->in.file)); status = WERR_ACCESS_DENIED; goto error_exit; } } - ret = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, securityinformation, sd_buf.sd); + ret = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, r->in.securityinformation, r->in.sd_buf.sd); if (ret == False) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", file)); + DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", r->in.file)); status = WERR_ACCESS_DENIED; goto error_exit; } @@ -2280,38 +2272,38 @@ static const char *next_server_disk_enum(uint32 *resume) return disk; } -WERROR _srvsvc_NetDiskEnum(pipes_struct *p, const char *server_unc, uint32_t level, struct srvsvc_NetDiskInfo *info, uint32_t maxlen, uint32_t *totalentries, uint32_t *resume_handle) +WERROR _srvsvc_NetDiskEnum(pipes_struct *p, struct srvsvc_NetDiskEnum *r) { uint32 i; const char *disk_name; WERROR status = WERR_OK; - *totalentries = init_server_disk_enum(resume_handle); - info->count = 0; + *r->out.totalentries = init_server_disk_enum(r->in.resume_handle); + r->out.info->count = 0; - if(!(info->disks = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetDiskInfo0, MAX_SERVER_DISK_ENTRIES))) { + if(!(r->out.info->disks = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetDiskInfo0, MAX_SERVER_DISK_ENTRIES))) { return WERR_NOMEM; } /*allow one struct srvsvc_NetDiskInfo0 for null terminator*/ - for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(resume_handle)); i++) { + for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(r->in.resume_handle)); i++) { - info->count++; - (*totalentries)++; + r->out.info->count++; + (*r->out.totalentries)++; /*copy disk name into a unicode string*/ - info->disks[i].disk = disk_name; + r->out.info->disks[i].disk = disk_name; } /* add a terminating null string. Is this there if there is more data to come? */ - info->count++; - (*totalentries)++; + r->out.info->count++; + (*r->out.totalentries)++; - info->disks[i].disk = ""; + r->out.info->disks[i].disk = ""; return status; } @@ -2319,29 +2311,29 @@ WERROR _srvsvc_NetDiskEnum(pipes_struct *p, const char *server_unc, uint32_t lev /******************************************************************** ********************************************************************/ -WERROR _srvsvc_NetNameValidate(pipes_struct *p, const char *server_unc, const char *name, uint32_t name_type, uint32_t flags) +WERROR _srvsvc_NetNameValidate(pipes_struct *p, struct srvsvc_NetNameValidate *r) { int len; - if ((flags != 0x0) && (flags != 0x80000000)) { + if ((r->in.flags != 0x0) && (r->in.flags != 0x80000000)) { return WERR_INVALID_PARAM; } - switch ( name_type ) { + switch ( r->in.name_type ) { case 0x9: - len = strlen_m(name); + len = strlen_m(r->in.name); - if ((flags == 0x0) && (len > 81)) { - DEBUG(5,("_srv_net_name_validate: share name too long (%s > 81 chars)\n", name)); + if ((r->in.flags == 0x0) && (len > 81)) { + DEBUG(5,("_srv_net_name_validate: share name too long (%s > 81 chars)\n", r->in.name)); return WERR_INVALID_NAME; } - if ((flags == 0x80000000) && (len > 13)) { - DEBUG(5,("_srv_net_name_validate: share name too long (%s > 13 chars)\n", name)); + if ((r->in.flags == 0x80000000) && (len > 13)) { + DEBUG(5,("_srv_net_name_validate: share name too long (%s > 13 chars)\n", r->in.name)); return WERR_INVALID_NAME; } - if ( ! validate_net_name( name, INVALID_SHARENAME_CHARS, sizeof(name) ) ) { - DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", name)); + if ( ! validate_net_name( r->in.name, INVALID_SHARENAME_CHARS, sizeof(r->in.name) ) ) { + DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", r->in.name)); return WERR_INVALID_NAME; } break; @@ -2357,216 +2349,216 @@ WERROR _srvsvc_NetNameValidate(pipes_struct *p, const char *server_unc, const ch /******************************************************************** ********************************************************************/ -WERROR _srvsvc_NetFileClose(pipes_struct *p, const char *server_unc, uint32_t fid) +WERROR _srvsvc_NetFileClose(pipes_struct *p, struct srvsvc_NetFileClose *r) { return WERR_ACCESS_DENIED; } -WERROR _srvsvc_NetCharDevEnum(pipes_struct *p, const char *server_unc, uint32_t *level, union srvsvc_NetCharDevCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +WERROR _srvsvc_NetCharDevEnum(pipes_struct *p, struct srvsvc_NetCharDevEnum *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetCharDevGetInfo(pipes_struct *p, const char *server_unc, const char *device_name, uint32_t level, union srvsvc_NetCharDevInfo *info) +WERROR _srvsvc_NetCharDevGetInfo(pipes_struct *p, struct srvsvc_NetCharDevGetInfo *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetCharDevControl(pipes_struct *p, const char *server_unc, const char *device_name, uint32_t opcode) +WERROR _srvsvc_NetCharDevControl(pipes_struct *p, struct srvsvc_NetCharDevControl *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetCharDevQEnum(pipes_struct *p, const char *server_unc, const char *user, uint32_t *level, union srvsvc_NetCharDevQCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +WERROR _srvsvc_NetCharDevQEnum(pipes_struct *p, struct srvsvc_NetCharDevQEnum *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetCharDevQGetInfo(pipes_struct *p, const char *server_unc, const char *queue_name, const char *user, uint32_t level, union srvsvc_NetCharDevQInfo *info) +WERROR _srvsvc_NetCharDevQGetInfo(pipes_struct *p, struct srvsvc_NetCharDevQGetInfo *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetCharDevQSetInfo(pipes_struct *p, const char *server_unc, const char *queue_name, uint32_t level, union srvsvc_NetCharDevQInfo info, uint32_t *parm_error) +WERROR _srvsvc_NetCharDevQSetInfo(pipes_struct *p, struct srvsvc_NetCharDevQSetInfo *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetCharDevQPurge(pipes_struct *p, const char *server_unc, const char *queue_name) +WERROR _srvsvc_NetCharDevQPurge(pipes_struct *p, struct srvsvc_NetCharDevQPurge *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetCharDevQPurgeSelf(pipes_struct *p, const char *server_unc, const char *queue_name, const char *computer_name) +WERROR _srvsvc_NetCharDevQPurgeSelf(pipes_struct *p, struct srvsvc_NetCharDevQPurgeSelf *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetFileGetInfo(pipes_struct *p, const char *server_unc, uint32_t fid, uint32_t level, union srvsvc_NetFileInfo *info) +WERROR _srvsvc_NetFileGetInfo(pipes_struct *p, struct srvsvc_NetFileGetInfo *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetShareCheck(pipes_struct *p, const char *server_unc, const char *device_name, enum srvsvc_ShareType *type) +WERROR _srvsvc_NetShareCheck(pipes_struct *p, struct srvsvc_NetShareCheck *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetServerStatisticsGet(pipes_struct *p, const char *server_unc, const char *service, uint32_t level, uint32_t options, struct srvsvc_Statistics *stats) +WERROR _srvsvc_NetServerStatisticsGet(pipes_struct *p, struct srvsvc_NetServerStatisticsGet *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetTransportAdd(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetTransportInfo info) +WERROR _srvsvc_NetTransportAdd(pipes_struct *p, struct srvsvc_NetTransportAdd *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetTransportEnum(pipes_struct *p, const char *server_unc, uint32_t *level, union srvsvc_NetTransportCtr *transports, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +WERROR _srvsvc_NetTransportEnum(pipes_struct *p, struct srvsvc_NetTransportEnum *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetTransportDel(pipes_struct *p, const char *server_unc, uint32_t unknown, struct srvsvc_NetTransportInfo0 transport) +WERROR _srvsvc_NetTransportDel(pipes_struct *p, struct srvsvc_NetTransportDel *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetSetServiceBits(pipes_struct *p, const char *server_unc, const char *transport, uint32_t servicebits, uint32_t updateimmediately) +WERROR _srvsvc_NetSetServiceBits(pipes_struct *p, struct srvsvc_NetSetServiceBits *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetPathType(pipes_struct *p, const char *server_unc, const char *path, uint32_t pathflags, uint32_t *pathtype) +WERROR _srvsvc_NetPathType(pipes_struct *p, struct srvsvc_NetPathType *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetPathCanonicalize(pipes_struct *p, const char *server_unc, const char *path, uint8_t *can_path, uint32_t maxbuf, const char *prefix, uint32_t *pathtype, uint32_t pathflags) +WERROR _srvsvc_NetPathCanonicalize(pipes_struct *p, struct srvsvc_NetPathCanonicalize *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetPathCompare(pipes_struct *p, const char *server_unc, const char *path1, const char *path2, uint32_t pathtype, uint32_t pathflags) +WERROR _srvsvc_NetPathCompare(pipes_struct *p, struct srvsvc_NetPathCompare *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRPRNAMECANONICALIZE(pipes_struct *p) +WERROR _srvsvc_NETRPRNAMECANONICALIZE(pipes_struct *p, struct srvsvc_NETRPRNAMECANONICALIZE *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetPRNameCompare(pipes_struct *p, const char *server_unc, const char *name1, const char *name2, uint32_t name_type, uint32_t flags) +WERROR _srvsvc_NetPRNameCompare(pipes_struct *p, struct srvsvc_NetPRNameCompare *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetShareDelStart(pipes_struct *p, const char *server_unc, const char *share, uint32_t reserved, struct policy_handle *hnd) +WERROR _srvsvc_NetShareDelStart(pipes_struct *p, struct srvsvc_NetShareDelStart *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetShareDelCommit(pipes_struct *p, struct policy_handle *hnd) +WERROR _srvsvc_NetShareDelCommit(pipes_struct *p, struct srvsvc_NetShareDelCommit *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetServerTransportAddEx(pipes_struct *p, const char *server_unc, uint32_t level, union srvsvc_NetTransportInfo info) +WERROR _srvsvc_NetServerTransportAddEx(pipes_struct *p, struct srvsvc_NetServerTransportAddEx *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetServerSetServiceBitsEx(pipes_struct *p, const char *server_unc, const char *emulated_server_unc, const char *transport, uint32_t servicebitsofinterest, uint32_t servicebits, uint32_t updateimmediately) +WERROR _srvsvc_NetServerSetServiceBitsEx(pipes_struct *p, struct srvsvc_NetServerSetServiceBitsEx *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRDFSGETVERSION(pipes_struct *p) +WERROR _srvsvc_NETRDFSGETVERSION(pipes_struct *p, struct srvsvc_NETRDFSGETVERSION *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRDFSCREATELOCALPARTITION(pipes_struct *p) +WERROR _srvsvc_NETRDFSCREATELOCALPARTITION(pipes_struct *p, struct srvsvc_NETRDFSCREATELOCALPARTITION *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRDFSDELETELOCALPARTITION(pipes_struct *p) +WERROR _srvsvc_NETRDFSDELETELOCALPARTITION(pipes_struct *p, struct srvsvc_NETRDFSDELETELOCALPARTITION *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRDFSSETLOCALVOLUMESTATE(pipes_struct *p) +WERROR _srvsvc_NETRDFSSETLOCALVOLUMESTATE(pipes_struct *p, struct srvsvc_NETRDFSSETLOCALVOLUMESTATE *R) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRDFSSETSERVERINFO(pipes_struct *p) +WERROR _srvsvc_NETRDFSSETSERVERINFO(pipes_struct *p, struct srvsvc_NETRDFSSETSERVERINFO *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRDFSCREATEEXITPOINT(pipes_struct *p) +WERROR _srvsvc_NETRDFSCREATEEXITPOINT(pipes_struct *p, struct srvsvc_NETRDFSCREATEEXITPOINT *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRDFSDELETEEXITPOINT(pipes_struct *p) +WERROR _srvsvc_NETRDFSDELETEEXITPOINT(pipes_struct *p, struct srvsvc_NETRDFSDELETEEXITPOINT *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRSERVERTRANSPORTDELEX(pipes_struct *p) +WERROR _srvsvc_NETRSERVERTRANSPORTDELEX(pipes_struct *p, struct srvsvc_NETRSERVERTRANSPORTDELEX *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRDFSMANAGERREPORTSITEINFO(pipes_struct *p) +WERROR _srvsvc_NETRDFSMANAGERREPORTSITEINFO(pipes_struct *p, struct srvsvc_NETRDFSMANAGERREPORTSITEINFO *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRDFSMODIFYPREFIX(pipes_struct *p) +WERROR _srvsvc_NETRDFSMODIFYPREFIX(pipes_struct *p, struct srvsvc_NETRDFSMODIFYPREFIX *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRDFSFIXLOCALVOLUME(pipes_struct *p) +WERROR _srvsvc_NETRDFSFIXLOCALVOLUME(pipes_struct *p, struct srvsvc_NETRDFSFIXLOCALVOLUME *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; diff --git a/source3/rpc_server/srv_unixinfo_nt.c b/source3/rpc_server/srv_unixinfo_nt.c index 5dd5215ed0..565d96e1fc 100644 --- a/source3/rpc_server/srv_unixinfo_nt.c +++ b/source3/rpc_server/srv_unixinfo_nt.c @@ -30,26 +30,26 @@ /* Map a sid to a uid */ -NTSTATUS _unixinfo_SidToUid(pipes_struct *p, struct dom_sid sid, uint64_t *uid) +NTSTATUS _unixinfo_SidToUid(pipes_struct *p, struct unixinfo_SidToUid *r) { uid_t real_uid; NTSTATUS status; - *uid = 0; + *r->out.uid = 0; - status = sid_to_uid(&sid, &real_uid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; + status = sid_to_uid(&r->in.sid, &real_uid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; if (NT_STATUS_IS_OK(status)) - *uid = real_uid; + *r->out.uid = real_uid; return status; } /* Map a uid to a sid */ -NTSTATUS _unixinfo_UidToSid(pipes_struct *p, uint64_t uid, struct dom_sid *sid) +NTSTATUS _unixinfo_UidToSid(pipes_struct *p, struct unixinfo_UidToSid *r) { NTSTATUS status = NT_STATUS_NO_SUCH_USER; - uid_to_sid(sid, (uid_t)uid); + uid_to_sid(r->out.sid, (uid_t)r->in.uid); status = NT_STATUS_OK; return status; @@ -57,27 +57,27 @@ NTSTATUS _unixinfo_UidToSid(pipes_struct *p, uint64_t uid, struct dom_sid *sid) /* Map a sid to a gid */ -NTSTATUS _unixinfo_SidToGid(pipes_struct *p, struct dom_sid sid, uint64_t *gid) +NTSTATUS _unixinfo_SidToGid(pipes_struct *p, struct unixinfo_SidToGid *r) { gid_t real_gid; NTSTATUS status; - *gid = 0; + *r->out.gid = 0; - status = sid_to_gid(&sid, &real_gid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; + status = sid_to_gid(&r->in.sid, &real_gid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; if (NT_STATUS_IS_OK(status)) - *gid = real_gid; + *r->out.gid = real_gid; return status; } /* Map a gid to a sid */ -NTSTATUS _unixinfo_GidToSid(pipes_struct *p, uint64_t gid, struct dom_sid *sid) +NTSTATUS _unixinfo_GidToSid(pipes_struct *p, struct unixinfo_GidToSid *r) { NTSTATUS status = NT_STATUS_NO_SUCH_GROUP; - gid_to_sid(sid, (gid_t)gid); + gid_to_sid(r->out.sid, (gid_t)r->in.gid); status = NT_STATUS_OK; return status; @@ -85,31 +85,30 @@ NTSTATUS _unixinfo_GidToSid(pipes_struct *p, uint64_t gid, struct dom_sid *sid) /* Get unix struct passwd information */ -NTSTATUS _unixinfo_GetPWUid(pipes_struct *p, uint32_t *count, uint64_t *uids, - struct unixinfo_GetPWUidInfo *infos) +NTSTATUS _unixinfo_GetPWUid(pipes_struct *p, struct unixinfo_GetPWUid *r) { int i; NTSTATUS status; - if (*count > 1023) + if (*r->in.count > 1023) return NT_STATUS_INVALID_PARAMETER; status = NT_STATUS_OK; - for (i=0; i<*count; i++) { + for (i=0; i<*r->in.count; i++) { struct passwd *pw; char *homedir, *shell; ssize_t len1, len2; - infos[i].status = NT_STATUS_NO_SUCH_USER; - infos[i].homedir = ""; - infos[i].shell = ""; + r->out.infos[i].status = NT_STATUS_NO_SUCH_USER; + r->out.infos[i].homedir = ""; + r->out.infos[i].shell = ""; - pw = getpwuid(uids[i]); + pw = getpwuid(r->in.uids[i]); if (pw == NULL) { DEBUG(10, ("Did not find uid %lld\n", - (long long int)uids[i])); + (long long int)r->in.uids[i])); continue; } @@ -119,13 +118,13 @@ NTSTATUS _unixinfo_GetPWUid(pipes_struct *p, uint32_t *count, uint64_t *uids, if ((len1 < 0) || (len2 < 0) || (homedir == NULL) || (shell == NULL)) { DEBUG(3, ("push_utf8_talloc failed\n")); - infos[i].status = NT_STATUS_NO_MEMORY; + r->out.infos[i].status = NT_STATUS_NO_MEMORY; continue; } - infos[i].status = NT_STATUS_OK; - infos[i].homedir = homedir; - infos[i].shell = shell; + r->out.infos[i].status = NT_STATUS_OK; + r->out.infos[i].homedir = homedir; + r->out.infos[i].shell = shell; } return status; diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 4006b375b5..404210a416 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -119,14 +119,14 @@ static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd) reg_close ********************************************************************/ -WERROR _winreg_CloseKey(pipes_struct *p, struct policy_handle *handle) +WERROR _winreg_CloseKey(pipes_struct *p, struct winreg_CloseKey *r) { /* close the policy handle */ - if (!close_registry_key(p, handle)) + if (!close_registry_key(p, r->in.handle)) return WERR_BADFID; - ZERO_STRUCTP(handle); + ZERO_STRUCTP(r->out.handle); return WERR_OK; } @@ -134,110 +134,97 @@ WERROR _winreg_CloseKey(pipes_struct *p, struct policy_handle *handle) /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKLM(pipes_struct *p, uint16_t *system_name, uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKLM(pipes_struct *p, struct winreg_OpenHKLM *r) { - return open_registry_key(p, handle, NULL, KEY_HKLM, access_mask); + return open_registry_key(p, r->out.handle, NULL, KEY_HKLM, r->in.access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKPD(pipes_struct *p, uint16_t *system_name, - uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKPD(pipes_struct *p, struct winreg_OpenHKPD *r) { - return open_registry_key(p, handle, NULL, KEY_HKPD, access_mask); + return open_registry_key(p, r->out.handle, NULL, KEY_HKPD, r->in.access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKPT(pipes_struct *p, uint16_t *system_name, - uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKPT(pipes_struct *p, struct winreg_OpenHKPT *r) { - return open_registry_key(p, handle, NULL, KEY_HKPT, access_mask); + return open_registry_key(p, r->out.handle, NULL, KEY_HKPT, r->in.access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKCR(pipes_struct *p, uint16_t *system_name, - uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKCR(pipes_struct *p, struct winreg_OpenHKCR *r) { - return open_registry_key(p, handle, NULL, KEY_HKCR, access_mask); + return open_registry_key(p, r->out.handle, NULL, KEY_HKCR, r->in.access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKU(pipes_struct *p, uint16_t *system_name, - uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKU(pipes_struct *p, struct winreg_OpenHKU *r) { - return open_registry_key(p, handle, NULL, KEY_HKU, access_mask); + return open_registry_key(p, r->out.handle, NULL, KEY_HKU, r->in.access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKCU(pipes_struct *p, uint16_t *system_name, - uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKCU(pipes_struct *p, struct winreg_OpenHKCU *r) { - return open_registry_key(p, handle, NULL, KEY_HKCU, access_mask); + return open_registry_key(p, r->out.handle, NULL, KEY_HKCU, r->in.access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKCC(pipes_struct *p, uint16_t *system_name, - uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKCC(pipes_struct *p, struct winreg_OpenHKCC *r) { - return open_registry_key(p, handle, NULL, KEY_HKCC, access_mask); + return open_registry_key(p, r->out.handle, NULL, KEY_HKCC, r->in.access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKDD(pipes_struct *p, uint16_t *system_name, - uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKDD(pipes_struct *p, struct winreg_OpenHKDD *r) { - return open_registry_key(p, handle, NULL, KEY_HKDD, access_mask); + return open_registry_key(p, r->out.handle, NULL, KEY_HKDD, r->in.access_mask); } /******************************************************************* ********************************************************************/ -WERROR _winreg_OpenHKPN(pipes_struct *p, uint16_t *system_name, - uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenHKPN(pipes_struct *p, struct winreg_OpenHKPN *r) { - return open_registry_key(p, handle, NULL, KEY_HKPN, access_mask); + return open_registry_key(p, r->out.handle, NULL, KEY_HKPN, r->in.access_mask); } /******************************************************************* reg_reply_open_entry ********************************************************************/ -WERROR _winreg_OpenKey(pipes_struct *p, struct policy_handle *parent_handle, - struct winreg_String keyname, uint32_t unknown, - uint32_t access_mask, struct policy_handle *handle) +WERROR _winreg_OpenKey(pipes_struct *p, struct winreg_OpenKey *r) { - struct registry_key *parent = find_regkey_by_hnd(p, parent_handle ); + struct registry_key *parent = find_regkey_by_hnd(p, r->in.parent_handle ); if ( !parent ) return WERR_BADFID; - return open_registry_key(p, handle, parent, keyname.name, access_mask); + return open_registry_key(p, r->out.handle, parent, r->in.keyname.name, r->in.access_mask); } /******************************************************************* reg_reply_info ********************************************************************/ -WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, - struct winreg_String value_name, - enum winreg_Type *type, uint8_t *data, - uint32_t *data_size, uint32_t *value_length) +WERROR _winreg_QueryValue(pipes_struct *p, struct winreg_QueryValue *r) { WERROR status = WERR_BADFILE; - struct registry_key *regkey = find_regkey_by_hnd( p, handle ); + struct registry_key *regkey = find_regkey_by_hnd( p, r->in.handle ); prs_struct prs_hkpd; uint8_t *outbuf; @@ -250,7 +237,7 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, if ( !regkey ) return WERR_BADFID; - *value_length = *type = 0; + *r->out.value_length = *r->out.type = 0; DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->key->name)); DEBUG(7,("_reg_info: policy key type = [%08x]\n", regkey->key->type)); @@ -258,54 +245,54 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, /* Handle QueryValue calls on HKEY_PERFORMANCE_DATA */ if(regkey->key->type == REG_KEY_HKPD) { - if(strequal(value_name.name, "Global")) { - prs_init(&prs_hkpd, *data_size, p->mem_ctx, MARSHALL); + if(strequal(r->in.value_name.name, "Global")) { + prs_init(&prs_hkpd, *r->in.data_size, p->mem_ctx, MARSHALL); status = reg_perfcount_get_hkpd( - &prs_hkpd, *data_size, &outbuf_size, NULL); + &prs_hkpd, *r->in.data_size, &outbuf_size, NULL); outbuf = (uint8_t *)prs_hkpd.data_p; free_prs = True; } - else if(strequal(value_name.name, "Counter 009")) { + else if(strequal(r->in.value_name.name, "Counter 009")) { outbuf_size = reg_perfcount_get_counter_names( reg_perfcount_get_base_index(), (char **)(void *)&outbuf); free_buf = True; } - else if(strequal(value_name.name, "Explain 009")) { + else if(strequal(r->in.value_name.name, "Explain 009")) { outbuf_size = reg_perfcount_get_counter_help( reg_perfcount_get_base_index(), (char **)(void *)&outbuf); free_buf = True; } - else if(isdigit(value_name.name[0])) { + else if(isdigit(r->in.value_name.name[0])) { /* we probably have a request for a specific object * here */ - prs_init(&prs_hkpd, *data_size, p->mem_ctx, MARSHALL); + prs_init(&prs_hkpd, *r->in.data_size, p->mem_ctx, MARSHALL); status = reg_perfcount_get_hkpd( - &prs_hkpd, *data_size, &outbuf_size, - value_name.name); + &prs_hkpd, *r->in.data_size, &outbuf_size, + r->in.value_name.name); outbuf = (uint8_t *)prs_hkpd.data_p; free_prs = True; } else { DEBUG(3,("Unsupported key name [%s] for HKPD.\n", - value_name.name)); + r->in.value_name.name)); return WERR_BADFILE; } - *type = REG_BINARY; + *r->out.type = REG_BINARY; } else { struct registry_value *val; - status = reg_queryvalue(p->mem_ctx, regkey, value_name.name, + status = reg_queryvalue(p->mem_ctx, regkey, r->in.value_name.name, &val); if (!W_ERROR_IS_OK(status)) { - if (data_size) { - *data_size = 0; + if (r->out.data_size) { + *r->out.data_size = 0; } - if (value_length) { - *value_length = 0; + if (r->out.value_length) { + *r->out.value_length = 0; } return status; } @@ -317,21 +304,21 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, outbuf = val_blob.data; outbuf_size = val_blob.length; - *type = val->type; + *r->out.type = val->type; } - *value_length = outbuf_size; + *r->out.value_length = outbuf_size; - if ( *data_size == 0 || !data ) { + if ( *r->in.data_size == 0 || !r->out.data ) { status = WERR_OK; - } else if ( *value_length > *data_size ) { + } else if ( *r->out.value_length > *r->in.data_size ) { status = WERR_MORE_DATA; } else { - memcpy( data, outbuf, *value_length ); + memcpy( r->out.data, outbuf, *r->out.value_length ); status = WERR_OK; } - *data_size = *value_length; + *r->out.data_size = *r->out.value_length; if (free_prs) prs_mem_free(&prs_hkpd); if (free_buf) SAFE_FREE(outbuf); @@ -343,26 +330,20 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct policy_handle *handle, Implementation of REG_QUERY_KEY ****************************************************************************/ -WERROR _winreg_QueryInfoKey(pipes_struct *p, struct policy_handle *handle, - struct winreg_String *classname, - uint32_t *num_subkeys, uint32_t *max_subkeylen, - uint32_t *max_subkeysize, - uint32_t *num_values, uint32_t *max_valnamelen, - uint32_t *max_valbufsize, - uint32_t *secdescsize, NTTIME *last_changed_time) +WERROR _winreg_QueryInfoKey(pipes_struct *p, struct winreg_QueryInfoKey *r) { WERROR status = WERR_OK; - struct registry_key *regkey = find_regkey_by_hnd( p, handle ); + struct registry_key *regkey = find_regkey_by_hnd( p, r->in.handle ); if ( !regkey ) return WERR_BADFID; - classname->name = NULL; + r->out.classname->name = NULL; - status = reg_queryinfokey(regkey, num_subkeys, max_subkeylen, - max_subkeysize, num_values, max_valnamelen, - max_valbufsize, secdescsize, - last_changed_time); + status = reg_queryinfokey(regkey, r->out.num_subkeys, r->out.max_subkeylen, + r->out.max_classlen, r->out.num_values, r->out.max_valnamelen, + r->out.max_valbufsize, r->out.secdescsize, + r->out.last_changed_time); if (!W_ERROR_IS_OK(status)) { return status; } @@ -372,10 +353,10 @@ WERROR _winreg_QueryInfoKey(pipes_struct *p, struct policy_handle *handle, * UTF-16. They are inexact at best, but so far they worked. */ - *max_subkeylen *= 2; + *r->out.max_subkeylen *= 2; - *max_valnamelen += 1; - *max_valnamelen *= 2; + *r->out.max_valnamelen += 1; + *r->out.max_valnamelen *= 2; return WERR_OK; } @@ -385,14 +366,14 @@ WERROR _winreg_QueryInfoKey(pipes_struct *p, struct policy_handle *handle, Implementation of REG_GETVERSION ****************************************************************************/ -WERROR _winreg_GetVersion(pipes_struct *p, struct policy_handle *handle, uint32_t *version) +WERROR _winreg_GetVersion(pipes_struct *p, struct winreg_GetVersion *r) { - struct registry_key *regkey = find_regkey_by_hnd( p, handle ); + struct registry_key *regkey = find_regkey_by_hnd( p, r->in.handle ); if ( !regkey ) return WERR_BADFID; - *version = 0x00000005; /* Windows 2000 registry API version */ + *r->out.version = 0x00000005; /* Windows 2000 registry API version */ return WERR_OK; } @@ -402,25 +383,25 @@ WERROR _winreg_GetVersion(pipes_struct *p, struct policy_handle *handle, uint32_ Implementation of REG_ENUM_KEY ****************************************************************************/ -WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t enum_index, struct winreg_StringBuf *name, struct winreg_StringBuf *keyclass, NTTIME *last_changed_time) +WERROR _winreg_EnumKey(pipes_struct *p, struct winreg_EnumKey *r) { WERROR err; - struct registry_key *key = find_regkey_by_hnd( p, handle ); + struct registry_key *key = find_regkey_by_hnd( p, r->in.handle ); if ( !key ) return WERR_BADFID; - if ( !name || !keyclass ) + if ( !r->in.name || !r->in.keyclass ) return WERR_INVALID_PARAM; DEBUG(8,("_reg_enum_key: enumerating key [%s]\n", key->key->name)); - err = reg_enumkey(p->mem_ctx, key, enum_index, (char **)&name->name, - last_changed_time); + err = reg_enumkey(p->mem_ctx, key, r->in.enum_index, (char **)&r->out.name->name, + r->out.last_changed_time); if (!W_ERROR_IS_OK(err)) { return err; } - keyclass->name = ""; + r->out.keyclass->name = ""; return WERR_OK; } @@ -428,13 +409,10 @@ WERROR _winreg_EnumKey(pipes_struct *p, struct policy_handle *handle, uint32_t e Implementation of REG_ENUM_VALUE ****************************************************************************/ -WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, - uint32_t enum_index, struct winreg_ValNameBuf *name, - enum winreg_Type *type, uint8_t **data, - uint32_t *data_size, uint32_t *value_length) +WERROR _winreg_EnumValue(pipes_struct *p, struct winreg_EnumValue *r) { WERROR err; - struct registry_key *key = find_regkey_by_hnd( p, handle ); + struct registry_key *key = find_regkey_by_hnd( p, r->in.handle ); char *valname; struct registry_value *val; DATA_BLOB value_blob; @@ -442,13 +420,13 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, if ( !key ) return WERR_BADFID; - if ( !name ) + if ( !r->in.name ) return WERR_INVALID_PARAM; DEBUG(8,("_winreg_EnumValue: enumerating values for key [%s]\n", key->key->name)); - err = reg_enumvalue(p->mem_ctx, key, enum_index, &valname, &val); + err = reg_enumvalue(p->mem_ctx, key, r->in.enum_index, &valname, &val); if (!W_ERROR_IS_OK(err)) { return err; } @@ -458,31 +436,31 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, return err; } - if (name != NULL) { - name->name = valname; + if (r->out.name != NULL) { + r->out.name->name = valname; } - if (type != NULL) { - *type = val->type; + if (r->out.type != NULL) { + *r->out.type = val->type; } - if (data != NULL) { - if ((data_size == NULL) || (value_length == NULL)) { + if (r->out.data != NULL) { + if ((r->out.data_size == NULL) || (r->out.value_length == NULL)) { return WERR_INVALID_PARAM; } - if (value_blob.length > *data_size) { + if (value_blob.length > *r->out.data_size) { return WERR_MORE_DATA; } - memcpy( data, value_blob.data, value_blob.length ); + memcpy( r->out.data, value_blob.data, value_blob.length ); } - if (value_length != NULL) { - *value_length = value_blob.length; + if (r->out.value_length != NULL) { + *r->out.value_length = value_blob.length; } - if (data_size != NULL) { - *data_size = value_blob.length; + if (r->out.data_size != NULL) { + *r->out.data_size = value_blob.length; } return WERR_OK; @@ -492,15 +470,21 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct policy_handle *handle, reg_shutdwon ********************************************************************/ -WERROR _winreg_InitiateSystemShutdown(pipes_struct *p, uint16_t *hostname, struct initshutdown_String *message, uint32_t timeout, uint8_t force_apps, uint8_t reboot) +WERROR _winreg_InitiateSystemShutdown(pipes_struct *p, struct winreg_InitiateSystemShutdown *r) { - uint32_t reason = 0; + struct winreg_InitiateSystemShutdownEx s; + + s.in.hostname = r->in.hostname; + s.in.message = r->in.message; + s.in.timeout = r->in.timeout; + s.in.force_apps = r->in.force_apps; + s.in.reboot = r->in.reboot; + s.in.reason = 0; /* thunk down to _winreg_InitiateSystemShutdownEx() (just returns a status) */ - return _winreg_InitiateSystemShutdownEx( p, hostname, message, timeout, - force_apps, reboot, reason ); + return _winreg_InitiateSystemShutdownEx( p, &s ); } /******************************************************************* @@ -511,14 +495,14 @@ WERROR _winreg_InitiateSystemShutdown(pipes_struct *p, uint16_t *hostname, struc #define SHUTDOWN_F_STRING "-f" -WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, uint16_t *hostname, struct initshutdown_String *message, uint32_t timeout, uint8_t force_apps, uint8_t reboot, uint32_t reason) +WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, struct winreg_InitiateSystemShutdownEx *r) { pstring shutdown_script; char *msg = NULL; pstring chkmsg; fstring str_timeout; fstring str_reason; - fstring r; + fstring reboot; fstring f; int ret; BOOL can_shutdown; @@ -533,21 +517,21 @@ WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, uint16_t *hostname, str chkmsg[0] = '\0'; - if ( message && message->name && message->name->name ) { - if ( (msg = talloc_strdup(p->mem_ctx, message->name->name )) == NULL ) { + if ( r->in.message && r->in.message->name && r->in.message->name->name ) { + if ( (msg = talloc_strdup(p->mem_ctx, r->in.message->name->name )) == NULL ) { return WERR_NOMEM; } alpha_strcpy (chkmsg, msg, NULL, sizeof(chkmsg)); } - fstr_sprintf(str_timeout, "%d", timeout); - fstr_sprintf(r, reboot ? SHUTDOWN_R_STRING : ""); - fstr_sprintf(f, force_apps ? SHUTDOWN_F_STRING : ""); - fstr_sprintf(str_reason, "%d", reason ); + fstr_sprintf(str_timeout, "%d", r->in.timeout); + fstr_sprintf(reboot, r->in.reboot ? SHUTDOWN_R_STRING : ""); + fstr_sprintf(f, r->in.force_apps ? SHUTDOWN_F_STRING : ""); + fstr_sprintf(str_reason, "%d", r->in.reason ); all_string_sub( shutdown_script, "%z", chkmsg, sizeof(shutdown_script) ); all_string_sub( shutdown_script, "%t", str_timeout, sizeof(shutdown_script) ); - all_string_sub( shutdown_script, "%r", r, sizeof(shutdown_script) ); + all_string_sub( shutdown_script, "%r", reboot, sizeof(shutdown_script) ); all_string_sub( shutdown_script, "%f", f, sizeof(shutdown_script) ); all_string_sub( shutdown_script, "%x", str_reason, sizeof(shutdown_script) ); @@ -582,7 +566,7 @@ WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, uint16_t *hostname, str reg_abort_shutdwon ********************************************************************/ -WERROR _winreg_AbortSystemShutdown(pipes_struct *p, uint16_t *server) +WERROR _winreg_AbortSystemShutdown(pipes_struct *p, struct winreg_AbortSystemShutdown *r) { pstring abort_shutdown_script; int ret; @@ -767,19 +751,19 @@ static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) /******************************************************************* ********************************************************************/ -WERROR _winreg_RestoreKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String *filename, uint32_t flags) +WERROR _winreg_RestoreKey(pipes_struct *p, struct winreg_RestoreKey *r) { - struct registry_key *regkey = find_regkey_by_hnd( p, handle ); + struct registry_key *regkey = find_regkey_by_hnd( p, r->in.handle ); pstring fname; int snum; if ( !regkey ) return WERR_BADFID; - if ( !filename || !filename->name ) + if ( !r->in.filename || !r->in.filename->name ) return WERR_INVALID_PARAM; - pstrcpy( fname, filename->name ); + pstrcpy( fname, r->in.filename->name ); DEBUG(8,("_winreg_RestoreKey: verifying restore of key [%s] from " "\"%s\"\n", regkey->key->name, fname)); @@ -954,19 +938,19 @@ static WERROR backup_registry_key ( REGISTRY_KEY *krecord, const char *fname ) /******************************************************************* ********************************************************************/ -WERROR _winreg_SaveKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String *filename, struct KeySecurityAttribute *sec_attrib) +WERROR _winreg_SaveKey(pipes_struct *p, struct winreg_SaveKey *r) { - struct registry_key *regkey = find_regkey_by_hnd( p, handle ); + struct registry_key *regkey = find_regkey_by_hnd( p, r->in.handle ); pstring fname; int snum; if ( !regkey ) return WERR_BADFID; - if ( !filename || !filename->name ) + if ( !r->in.filename || !r->in.filename->name ) return WERR_INVALID_PARAM; - pstrcpy( fname, filename->name ); + pstrcpy( fname, r->in.filename->name ); DEBUG(8,("_winreg_SaveKey: verifying backup of key [%s] to \"%s\"\n", regkey->key->name, fname)); @@ -983,7 +967,7 @@ WERROR _winreg_SaveKey(pipes_struct *p, struct policy_handle *handle, struct win /******************************************************************* ********************************************************************/ -WERROR _winreg_SaveKeyEx(pipes_struct *p) +WERROR _winreg_SaveKeyEx(pipes_struct *p, struct winreg_SaveKeyEx *r) { /* fill in your code here if you think this call should do anything */ @@ -995,28 +979,22 @@ WERROR _winreg_SaveKeyEx(pipes_struct *p) /******************************************************************* ********************************************************************/ -WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, - struct winreg_String keyname, - struct winreg_String keyclass, - uint32_t options, uint32_t access_mask, - struct winreg_SecBuf *secdesc, - struct policy_handle *new_handle, - enum winreg_CreateAction *action_taken ) +WERROR _winreg_CreateKey( pipes_struct *p, struct winreg_CreateKey *r) { - struct registry_key *parent = find_regkey_by_hnd(p, handle); + struct registry_key *parent = find_regkey_by_hnd(p, r->in.handle); struct registry_key *new_key; WERROR result; if ( !parent ) return WERR_BADFID; - result = reg_createkey(NULL, parent, keyname.name, access_mask, - &new_key, action_taken); + result = reg_createkey(NULL, parent, r->in.name.name, r->in.access_mask, + &new_key, r->out.action_taken); if (!W_ERROR_IS_OK(result)) { return result; } - if (!create_policy_hnd(p, new_handle, free_regkey, new_key)) { + if (!create_policy_hnd(p, r->out.new_handle, free_regkey, new_key)) { TALLOC_FREE(new_key); return WERR_BADFILE; } @@ -1027,64 +1005,60 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct policy_handle *handle, /******************************************************************* ********************************************************************/ -WERROR _winreg_SetValue(pipes_struct *p, struct policy_handle *handle, - struct winreg_String name, enum winreg_Type type, - uint8_t *data, uint32_t size) +WERROR _winreg_SetValue(pipes_struct *p, struct winreg_SetValue *r) { - struct registry_key *key = find_regkey_by_hnd(p, handle); + struct registry_key *key = find_regkey_by_hnd(p, r->in.handle); struct registry_value *val; WERROR status; if ( !key ) return WERR_BADFID; - DEBUG(8,("_reg_set_value: Setting value for [%s:%s]\n", key->key->name, - name.name)); + DEBUG(8,("_reg_set_value: Setting value for [%s:%s]\n", + key->key->name, r->in.name.name)); - status = registry_pull_value(p->mem_ctx, &val, type, data, size, size); + status = registry_pull_value(p->mem_ctx, &val, r->in.type, r->in.data, + r->in.size, r->in.size); if (!W_ERROR_IS_OK(status)) { return status; } - return reg_setvalue(key, name.name, val); + return reg_setvalue(key, r->in.name.name, val); } /******************************************************************* ********************************************************************/ -WERROR _winreg_DeleteKey(pipes_struct *p, struct policy_handle *handle, - struct winreg_String key) +WERROR _winreg_DeleteKey(pipes_struct *p, struct winreg_DeleteKey *r) { - struct registry_key *parent = find_regkey_by_hnd(p, handle); + struct registry_key *parent = find_regkey_by_hnd(p, r->in.handle); if ( !parent ) return WERR_BADFID; - return reg_deletekey(parent, key.name); + return reg_deletekey(parent, r->in.key.name); } /******************************************************************* ********************************************************************/ -WERROR _winreg_DeleteValue(pipes_struct *p, struct policy_handle *handle, - struct winreg_String value) +WERROR _winreg_DeleteValue(pipes_struct *p, struct winreg_DeleteValue *r) { - struct registry_key *key = find_regkey_by_hnd(p, handle); + struct registry_key *key = find_regkey_by_hnd(p, r->in.handle); if ( !key ) return WERR_BADFID; - return reg_deletevalue(key, value.name); + return reg_deletevalue(key, r->in.value.name); } /******************************************************************* ********************************************************************/ -WERROR _winreg_GetKeySecurity(pipes_struct *p, struct policy_handle *handle, - uint32_t sec_info, struct KeySecurityData *sd) +WERROR _winreg_GetKeySecurity(pipes_struct *p, struct winreg_GetKeySecurity *r) { - struct registry_key *key = find_regkey_by_hnd(p, handle); + struct registry_key *key = find_regkey_by_hnd(p, r->in.handle); WERROR err; struct security_descriptor *secdesc; uint8 *data; @@ -1109,14 +1083,14 @@ WERROR _winreg_GetKeySecurity(pipes_struct *p, struct policy_handle *handle, return err; } - if (len > sd->size) { - sd->size = len; + if (len > r->out.sd->size) { + r->out.sd->size = len; return WERR_INSUFFICIENT_BUFFER; } - sd->size = len; - sd->len = len; - sd->data = data; + r->out.sd->size = len; + r->out.sd->len = len; + r->out.sd->data = data; return WERR_OK; } @@ -1124,9 +1098,9 @@ WERROR _winreg_GetKeySecurity(pipes_struct *p, struct policy_handle *handle, /******************************************************************* ********************************************************************/ -WERROR _winreg_SetKeySecurity(pipes_struct *p, struct policy_handle *handle, uint32_t access_mask, struct KeySecurityData *sd) +WERROR _winreg_SetKeySecurity(pipes_struct *p, struct winreg_SetKeySecurity *r) { - struct registry_key *key = find_regkey_by_hnd(p, handle); + struct registry_key *key = find_regkey_by_hnd(p, r->in.handle); struct security_descriptor *secdesc; WERROR err; @@ -1138,8 +1112,8 @@ WERROR _winreg_SetKeySecurity(pipes_struct *p, struct policy_handle *handle, uin if ( !(key->key->access_granted & STD_RIGHT_WRITE_DAC_ACCESS) ) return WERR_ACCESS_DENIED; - err = ntstatus_to_werror(unmarshall_sec_desc(p->mem_ctx, sd->data, - sd->len, &secdesc)); + err = ntstatus_to_werror(unmarshall_sec_desc(p->mem_ctx, r->in.sd->data, + r->in.sd->len, &secdesc)); if (!W_ERROR_IS_OK(err)) { return err; } @@ -1150,7 +1124,7 @@ WERROR _winreg_SetKeySecurity(pipes_struct *p, struct policy_handle *handle, uin /******************************************************************* ********************************************************************/ -WERROR _winreg_FlushKey(pipes_struct *p, struct policy_handle *handle) +WERROR _winreg_FlushKey(pipes_struct *p, struct winreg_FlushKey *r) { /* I'm just replying OK because there's not a lot here I see to do i --jerry */ @@ -1161,7 +1135,7 @@ WERROR _winreg_FlushKey(pipes_struct *p, struct policy_handle *handle) /******************************************************************* ********************************************************************/ -WERROR _winreg_UnLoadKey(pipes_struct *p) +WERROR _winreg_UnLoadKey(pipes_struct *p, struct winreg_UnLoadKey *r) { /* fill in your code here if you think this call should do anything */ @@ -1173,7 +1147,7 @@ WERROR _winreg_UnLoadKey(pipes_struct *p) /******************************************************************* ********************************************************************/ -WERROR _winreg_ReplaceKey(pipes_struct *p) +WERROR _winreg_ReplaceKey(pipes_struct *p, struct winreg_ReplaceKey *r) { /* fill in your code here if you think this call should do anything */ @@ -1185,7 +1159,7 @@ WERROR _winreg_ReplaceKey(pipes_struct *p) /******************************************************************* ********************************************************************/ -WERROR _winreg_LoadKey(pipes_struct *p, struct policy_handle *handle, struct winreg_String *keyname, struct winreg_String *filename) +WERROR _winreg_LoadKey(pipes_struct *p, struct winreg_LoadKey *r) { /* fill in your code here if you think this call should do anything */ @@ -1197,7 +1171,7 @@ WERROR _winreg_LoadKey(pipes_struct *p, struct policy_handle *handle, struct win /******************************************************************* ********************************************************************/ -WERROR _winreg_NotifyChangeKeyValue(pipes_struct *p, struct policy_handle *handle, uint8_t watch_subtree, uint32_t notify_filter, uint32_t unknown, struct winreg_String string1, struct winreg_String string2, uint32_t unknown2) +WERROR _winreg_NotifyChangeKeyValue(pipes_struct *p, struct winreg_NotifyChangeKeyValue *r) { /* fill in your code here if you think this call should do anything */ @@ -1209,7 +1183,7 @@ WERROR _winreg_NotifyChangeKeyValue(pipes_struct *p, struct policy_handle *handl /******************************************************************* ********************************************************************/ -WERROR _winreg_QueryMultipleValues(pipes_struct *p, struct policy_handle *key_handle, struct QueryMultipleValue *values, uint32_t num_values, uint8_t *buffer, uint32_t *buffer_size) +WERROR _winreg_QueryMultipleValues(pipes_struct *p, struct winreg_QueryMultipleValues *r) { /* fill in your code here if you think this call should do anything */ @@ -1221,7 +1195,7 @@ WERROR _winreg_QueryMultipleValues(pipes_struct *p, struct policy_handle *key_ha /******************************************************************* ********************************************************************/ -WERROR _winreg_QueryMultipleValues2(pipes_struct *p) +WERROR _winreg_QueryMultipleValues2(pipes_struct *p, struct winreg_QueryMultipleValues2 *r) { /* fill in your code here if you think this call should do anything */ diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 3ed1cbe682..1a827b265b 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -56,14 +56,13 @@ static void create_wks_info_100(struct wkssvc_NetWkstaInfo100 *info100) only supports info level 100 at the moment. ********************************************************************/ -WERROR _wkssvc_NetWkstaGetInfo( pipes_struct *p, const char *server_name, uint32_t level, - union wkssvc_NetWkstaInfo *info ) +WERROR _wkssvc_NetWkstaGetInfo( pipes_struct *p, struct wkssvc_NetWkstaGetInfo *r) { struct wkssvc_NetWkstaInfo100 *wks100 = NULL; /* We only support info level 100 currently */ - if ( level != 100 ) { + if ( r->in.level != 100 ) { return WERR_UNKNOWN_LEVEL; } @@ -73,7 +72,7 @@ WERROR _wkssvc_NetWkstaGetInfo( pipes_struct *p, const char *server_name, uint32 create_wks_info_100( wks100 ); - info->info100 = wks100; + r->out.info->info100 = wks100; return WERR_OK; } @@ -81,9 +80,7 @@ WERROR _wkssvc_NetWkstaGetInfo( pipes_struct *p, const char *server_name, uint32 /******************************************************************** ********************************************************************/ -WERROR _wkssvc_NetWkstaSetInfo( pipes_struct *p, const char *server_name, - uint32_t level, union wkssvc_NetWkstaInfo *info, - uint32_t *parm_error ) +WERROR _wkssvc_NetWkstaSetInfo( pipes_struct *p, struct wkssvc_NetWkstaSetInfo *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -93,12 +90,7 @@ WERROR _wkssvc_NetWkstaSetInfo( pipes_struct *p, const char *server_name, /******************************************************************** ********************************************************************/ -WERROR _wkssvc_NetWkstaEnumUsers( pipes_struct *p, const char *server_name, - uint32_t level, - union WKS_USER_ENUM_UNION *users, - uint32_t prefmaxlen, uint32_t *entriesread, - uint32_t *totalentries, - uint32_t *resumehandle ) +WERROR _wkssvc_NetWkstaEnumUsers( pipes_struct *p, struct wkssvc_NetWkstaEnumUsers *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -108,7 +100,7 @@ WERROR _wkssvc_NetWkstaEnumUsers( pipes_struct *p, const char *server_name, /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRWKSTAUSERGETINFO( pipes_struct *p ) +WERROR _WKSSVC_NETRWKSTAUSERGETINFO( pipes_struct *p, struct WKSSVC_NETRWKSTAUSERGETINFO *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -118,7 +110,7 @@ WERROR _WKSSVC_NETRWKSTAUSERGETINFO( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRWKSTAUSERSETINFO( pipes_struct *p ) +WERROR _WKSSVC_NETRWKSTAUSERSETINFO( pipes_struct *p, struct WKSSVC_NETRWKSTAUSERSETINFO *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -128,7 +120,7 @@ WERROR _WKSSVC_NETRWKSTAUSERSETINFO( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _wkssvc_NetWkstaTransportEnum( pipes_struct *p, const char *server_name, uint32_t *level, union wkssvc_NetWkstaTransportCtr *ctr, uint32_t max_buffer, uint32_t *totalentries, uint32_t *resume_handle) +WERROR _wkssvc_NetWkstaTransportEnum( pipes_struct *p, struct wkssvc_NetWkstaTransportEnum *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -138,7 +130,7 @@ WERROR _wkssvc_NetWkstaTransportEnum( pipes_struct *p, const char *server_name, /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRWKSTATRANSPORTADD( pipes_struct *p ) +WERROR _WKSSVC_NETRWKSTATRANSPORTADD( pipes_struct *p, struct WKSSVC_NETRWKSTATRANSPORTADD *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -148,7 +140,7 @@ WERROR _WKSSVC_NETRWKSTATRANSPORTADD( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRWKSTATRANSPORTDEL( pipes_struct *p ) +WERROR _WKSSVC_NETRWKSTATRANSPORTDEL( pipes_struct *p, struct WKSSVC_NETRWKSTATRANSPORTDEL *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -158,7 +150,7 @@ WERROR _WKSSVC_NETRWKSTATRANSPORTDEL( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRUSEADD( pipes_struct *p ) +WERROR _WKSSVC_NETRUSEADD( pipes_struct *p, struct WKSSVC_NETRUSEADD *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -168,7 +160,7 @@ WERROR _WKSSVC_NETRUSEADD( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRUSEGETINFO( pipes_struct *p ) +WERROR _WKSSVC_NETRUSEGETINFO( pipes_struct *p, struct WKSSVC_NETRUSEGETINFO *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -178,7 +170,7 @@ WERROR _WKSSVC_NETRUSEGETINFO( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRUSEDEL( pipes_struct *p ) +WERROR _WKSSVC_NETRUSEDEL( pipes_struct *p, struct WKSSVC_NETRUSEDEL *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -188,7 +180,7 @@ WERROR _WKSSVC_NETRUSEDEL( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRUSEENUM( pipes_struct *p ) +WERROR _WKSSVC_NETRUSEENUM( pipes_struct *p, struct WKSSVC_NETRUSEENUM *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -198,7 +190,7 @@ WERROR _WKSSVC_NETRUSEENUM( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRMESSAGEBUFFERSEND( pipes_struct *p ) +WERROR _WKSSVC_NETRMESSAGEBUFFERSEND( pipes_struct *p, struct WKSSVC_NETRMESSAGEBUFFERSEND *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -208,7 +200,7 @@ WERROR _WKSSVC_NETRMESSAGEBUFFERSEND( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRWORKSTATIONSTATISTICSGET( pipes_struct *p ) +WERROR _WKSSVC_NETRWORKSTATIONSTATISTICSGET( pipes_struct *p, struct WKSSVC_NETRWORKSTATIONSTATISTICSGET *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -218,7 +210,7 @@ WERROR _WKSSVC_NETRWORKSTATIONSTATISTICSGET( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRLOGONDOMAINNAMEADD( pipes_struct *p ) +WERROR _WKSSVC_NETRLOGONDOMAINNAMEADD( pipes_struct *p, struct WKSSVC_NETRLOGONDOMAINNAMEADD *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -228,7 +220,7 @@ WERROR _WKSSVC_NETRLOGONDOMAINNAMEADD( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRLOGONDOMAINNAMEDEL( pipes_struct *p ) +WERROR _WKSSVC_NETRLOGONDOMAINNAMEDEL( pipes_struct *p, struct WKSSVC_NETRLOGONDOMAINNAMEDEL *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -238,7 +230,7 @@ WERROR _WKSSVC_NETRLOGONDOMAINNAMEDEL( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRJOINDOMAIN( pipes_struct *p ) +WERROR _WKSSVC_NETRJOINDOMAIN( pipes_struct *p, struct WKSSVC_NETRJOINDOMAIN *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -248,7 +240,7 @@ WERROR _WKSSVC_NETRJOINDOMAIN( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRUNJOINDOMAIN( pipes_struct *p ) +WERROR _WKSSVC_NETRUNJOINDOMAIN( pipes_struct *p, struct WKSSVC_NETRUNJOINDOMAIN *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -258,7 +250,7 @@ WERROR _WKSSVC_NETRUNJOINDOMAIN( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRRENAMEMACHINEINDOMAIN( pipes_struct *p ) +WERROR _WKSSVC_NETRRENAMEMACHINEINDOMAIN( pipes_struct *p, struct WKSSVC_NETRRENAMEMACHINEINDOMAIN *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -268,7 +260,7 @@ WERROR _WKSSVC_NETRRENAMEMACHINEINDOMAIN( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRVALIDATENAME( pipes_struct *p ) +WERROR _WKSSVC_NETRVALIDATENAME( pipes_struct *p, struct WKSSVC_NETRVALIDATENAME *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -278,7 +270,7 @@ WERROR _WKSSVC_NETRVALIDATENAME( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRGETJOININFORMATION( pipes_struct *p ) +WERROR _WKSSVC_NETRGETJOININFORMATION( pipes_struct *p, struct WKSSVC_NETRGETJOININFORMATION *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -288,7 +280,7 @@ WERROR _WKSSVC_NETRGETJOININFORMATION( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRGETJOINABLEOUS( pipes_struct *p ) +WERROR _WKSSVC_NETRGETJOINABLEOUS( pipes_struct *p, struct WKSSVC_NETRGETJOINABLEOUS *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -298,7 +290,7 @@ WERROR _WKSSVC_NETRGETJOINABLEOUS( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, const char *server_name, const char *domain_name, const char *account_name, const char *admin_account, struct wkssvc_PasswordBuffer *encrypted_password, uint32_t join_flags) +WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -308,7 +300,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, const char *server_name, const c /******************************************************************** ********************************************************************/ -WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, const char *server_name, const char *account, struct wkssvc_PasswordBuffer *encrypted_password, uint32_t unjoin_flags) +WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, struct wkssvc_NetrUnjoinDomain2 *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -318,7 +310,7 @@ WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, const char *server_name, const /******************************************************************** ********************************************************************/ -WERROR _wkssvc_NetrRenameMachineInDomain2(pipes_struct *p, const char *server_name, const char *NewMachineName, const char *Account, struct wkssvc_PasswordBuffer *EncryptedPassword, uint32_t RenameOptions) +WERROR _wkssvc_NetrRenameMachineInDomain2(pipes_struct *p, struct wkssvc_NetrRenameMachineInDomain2 *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -328,7 +320,7 @@ WERROR _wkssvc_NetrRenameMachineInDomain2(pipes_struct *p, const char *server_na /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRVALIDATENAME2( pipes_struct *p ) +WERROR _WKSSVC_NETRVALIDATENAME2( pipes_struct *p, struct WKSSVC_NETRVALIDATENAME2 *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -338,7 +330,7 @@ WERROR _WKSSVC_NETRVALIDATENAME2( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRGETJOINABLEOUS2( pipes_struct *p ) +WERROR _WKSSVC_NETRGETJOINABLEOUS2( pipes_struct *p, struct WKSSVC_NETRGETJOINABLEOUS2 *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -348,7 +340,7 @@ WERROR _WKSSVC_NETRGETJOINABLEOUS2( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _wkssvc_NetrAddAlternateComputerName(pipes_struct *p, const char *server_name, const char *NewAlternateMachineName, const char *Account, struct wkssvc_PasswordBuffer *EncryptedPassword, uint32_t Reserved) +WERROR _wkssvc_NetrAddAlternateComputerName(pipes_struct *p, struct wkssvc_NetrAddAlternateComputerName *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -358,7 +350,7 @@ WERROR _wkssvc_NetrAddAlternateComputerName(pipes_struct *p, const char *server_ /******************************************************************** ********************************************************************/ -WERROR _wkssvc_NetrRemoveAlternateComputerName(pipes_struct *p, const char *server_name, const char *AlternateMachineNameToRemove, const char *Account, struct wkssvc_PasswordBuffer *EncryptedPassword, uint32_t Reserved) +WERROR _wkssvc_NetrRemoveAlternateComputerName(pipes_struct *p, struct wkssvc_NetrRemoveAlternateComputerName *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -368,7 +360,7 @@ WERROR _wkssvc_NetrRemoveAlternateComputerName(pipes_struct *p, const char *serv /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRSETPRIMARYCOMPUTERNAME( pipes_struct *p ) +WERROR _WKSSVC_NETRSETPRIMARYCOMPUTERNAME( pipes_struct *p, struct WKSSVC_NETRSETPRIMARYCOMPUTERNAME *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -378,7 +370,7 @@ WERROR _WKSSVC_NETRSETPRIMARYCOMPUTERNAME( pipes_struct *p ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRENUMERATECOMPUTERNAMES( pipes_struct *p ) +WERROR _WKSSVC_NETRENUMERATECOMPUTERNAMES( pipes_struct *p, struct WKSSVC_NETRENUMERATECOMPUTERNAMES *r ) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; -- cgit From 71730ae5eb658c8c674273d9162e1c989e3bccda Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 18 Jan 2007 11:31:38 +0000 Subject: r20876: Fix bug 4346 -- Thanks to YAMASAKI Hiroyuki (This used to be commit a7a66eb4eb2e518007b791457694c39dfff90705) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 06c84b60e9..3dea0a8493 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -215,7 +215,7 @@ static uint32 get_share_type(const struct share_params *params) type = STYPE_PRINTQ; if (strequal(lp_fstype(params->service), "IPC")) type = STYPE_IPC; - if (net_name[len_net_name] == '$') + if (net_name[len_net_name-1] == '$') type |= STYPE_HIDDEN; return type; -- cgit From 6beb5192801f63b7cb73bf0448aef550f9b1ccd8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 29 Jan 2007 22:51:44 +0000 Subject: r21047: Hand marshalling hack from Martin Zielinski to allow Vista to upload printer drivers (it wants level 8 which we don't support yet). Downgrade in the same way that Windows servers do. Jeremy. (This used to be commit 01c659692c3e054904f1af815cf243b8a1dde109) --- source3/rpc_server/srv_spoolss.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 0a43e8ae8a..dcc357f804 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1477,6 +1477,15 @@ static BOOL api_spoolss_addprinterdriverex(pipes_struct *p) ZERO_STRUCT(r_u); if(!spoolss_io_q_addprinterdriverex("", &q_u, data, 0)) { + if (q_u.level != 3 && q_u.level != 6) { + /* Clever hack from Martin Zielinski + * to allow downgrade from level 8 (Vista). + */ + DEBUG(3,("api_spoolss_addprinterdriverex: unknown SPOOL_Q_ADDPRINTERDRIVEREX level %u.\n", + (unsigned int)q_u.level )); + setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG)); + return True; + } DEBUG(0,("spoolss_io_q_addprinterdriverex: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVEREX.\n")); return False; } -- cgit From caf8c6a76be051559ffcfe97084edca43e0a3cee Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 30 Jan 2007 22:22:06 +0000 Subject: r21064: The core of this patch is void message_register(int msg_type, void (*fn)(int msg_type, struct process_id pid, - void *buf, size_t len)) + void *buf, size_t len, + void *private_data), + void *private_data) { struct dispatch_fns *dfn; So this adds a (so far unused) private pointer that is passed from message_register to the message handler. A prerequisite to implement a tiny samba4-API compatible wrapper around our messaging system. That itself is necessary for the Samba4 notify system. Yes, I know, I could import the whole Samba4 messaging system, but I want to do it step by step and I think getting notify in is more important in this step. Volker (This used to be commit c8ae60ed65dcce9660ee39c75488f2838cf9a28b) --- source3/rpc_server/srv_spoolss_nt.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b6af6b0b80..a655b7054b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1107,7 +1107,8 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, voi ********************************************************************/ static void receive_notify2_message_list(int msg_type, struct process_id src, - void *msg, size_t len) + void *msg, size_t len, + void *private_data) { size_t msg_count, i; char *buf = (char *)msg; @@ -1219,7 +1220,8 @@ static BOOL srv_spoolss_drv_upgrade_printer(char* drivername) over all printers, upgrading ones as necessary **********************************************************************/ -void do_drv_upgrade_printer(int msg_type, struct process_id src, void *buf, size_t len) +void do_drv_upgrade_printer(int msg_type, struct process_id src, + void *buf, size_t len, void *private_data) { fstring drivername; int snum; @@ -1317,7 +1319,7 @@ static BOOL srv_spoolss_reset_printerdata(char* drivername) **********************************************************************/ void reset_all_printerdata(int msg_type, struct process_id src, - void *buf, size_t len) + void *buf, size_t len, void *private_data) { fstring drivername; int snum; @@ -2597,7 +2599,8 @@ static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, if ( !spoolss_connect_to_client( ¬ify_cli_pipe, client_ip, unix_printer )) return False; - message_register(MSG_PRINTER_NOTIFY2, receive_notify2_message_list); + message_register(MSG_PRINTER_NOTIFY2, + receive_notify2_message_list, NULL); /* Tell the connections db we're now interested in printer * notify messages. */ register_message_flags( True, FLAG_MSG_PRINT_NOTIFY ); -- cgit From 0150bd394ba73c7fb379294f7a78d710abdcbabf Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 31 Jan 2007 20:28:32 +0000 Subject: r21099: Protect ourselves from null pointer deref. This isn't the correct fix for the Vista bug, but it needed as protection against invalid RPC. Thanks to Martin Zielinski for pointing this out. Jeremy. (This used to be commit fbab8e4ba93325f68353ee345a257a5445d78e67) --- source3/rpc_server/srv_spoolss_nt.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a655b7054b..3270801fc2 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5988,6 +5988,12 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, goto done; } + if (!secdesc_ctr) { + DEBUG(10,("update_printer_sec: secdesc_ctr is NULL !\n")); + result = WERR_INVALID_PARAM; + goto done; + } + /* Check the user has permissions to change the security descriptor. By experimentation with two NT machines, the user requires Full Access to the printer to change security -- cgit From 5eb536601aadf3015a677bb83d02f8ae2b9cc725 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 31 Jan 2007 21:33:45 +0000 Subject: r21100: Add the RPC hack fix to adddriver as well as adddriverex. Thanks to Martin Zielinski . Jeremy. (This used to be commit d18a3f8b72f0f4cf0aa5b599f36ce3f4125adac3) --- source3/rpc_server/srv_spoolss.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index dcc357f804..c9ff9697e0 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -910,6 +910,15 @@ static BOOL api_spoolss_addprinterdriver(pipes_struct *p) ZERO_STRUCT(r_u); if(!spoolss_io_q_addprinterdriver("", &q_u, data, 0)) { + if (q_u.level != 3 && q_u.level != 6) { + /* Clever hack from Martin Zielinski + * to allow downgrade from level 8 (Vista). + */ + DEBUG(3,("api_spoolss_addprinterdriver: unknown SPOOL_Q_ADDPRINTERDRIVER level %u.\n", + (unsigned int)q_u.level )); + setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG)); + return True; + } DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n")); return False; } -- cgit From 69d8c5ae5f1319e3c9430aa7d6d09ca2a62ba10a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 1 Feb 2007 19:29:07 +0000 Subject: r21115: notify_internal.c needs to remove the table entry if a process has crashed. So it needs the specific error message. Make messages.c return NTSTATUS and specificially NT_STATUS_INVALID_HANDLE if sending to a non-existent process. Volker (This used to be commit 3f620d181da0c356c8ffbdb5b380ccab3645a972) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 3dea0a8493..c0953f2723 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1219,7 +1219,7 @@ WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r) if ((strequal(session_list[snum].username, r->in.user) || r->in.user[0] == '\0' ) && strequal(session_list[snum].remote_machine, machine)) { - if (message_send_pid(pid_to_procid(session_list[snum].pid), MSG_SHUTDOWN, NULL, 0, False)) + if (NT_STATUS_IS_OK(message_send_pid(pid_to_procid(session_list[snum].pid), MSG_SHUTDOWN, NULL, 0, False))) status = WERR_OK; } } -- cgit From d4135a3bdbe70bf87632396b79af5b17c7da5dd5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Feb 2007 00:50:47 +0000 Subject: r21129: Fix from Martin Zielinski - ensure the hand marshalled container size is a multiple of 4 bytes for RPC alignment. Jeremy. (This used to be commit 0e9ad2b29f1c05dc3f5d5e9659fe0557fa077d2e) --- source3/rpc_server/srv_spoolss_nt.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3270801fc2..d0a754f281 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -9532,6 +9532,16 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ /* copy data into the reply */ r_u->ctr.size = r_u->needed; + + /* Fix from Martin Zielinski - ensure + * the hand marshalled container size is a multiple + * of 4 bytes for RPC alignment. + */ + + if (needed % 4) { + r_u->ctr.size += 4-(needed % 4); + } + r_u->ctr.size_of_array = r_u->returned; r_u->ctr.values = enum_values; -- cgit From 3ad849db21c7ba7171f3980629de031d5c8adc95 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 5 Feb 2007 19:32:31 +0000 Subject: r21164: Fix from Martin Zielinski for EnumprinterdataEX on Vista. Jeremy. (This used to be commit b16707a8615e1d00839d31e7a3061fb111336691) --- source3/rpc_server/srv_spoolss_nt.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d0a754f281..48b34755a6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -9521,6 +9521,15 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ /* housekeeping information in the reply */ + /* Fix from Martin Zielinski - ensure + * the hand marshalled container size is a multiple + * of 4 bytes for RPC alignment. + */ + + if (needed % 4) { + needed += 4-(needed % 4); + } + r_u->needed = needed; r_u->returned = num_entries; @@ -9533,15 +9542,6 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ r_u->ctr.size = r_u->needed; - /* Fix from Martin Zielinski - ensure - * the hand marshalled container size is a multiple - * of 4 bytes for RPC alignment. - */ - - if (needed % 4) { - r_u->ctr.size += 4-(needed % 4); - } - r_u->ctr.size_of_array = r_u->returned; r_u->ctr.values = enum_values; -- cgit From 7a5fa7f12ec439ef5a4af29aa86498f799b6b9a5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 6 Feb 2007 21:05:34 +0000 Subject: r21191: Add in the POSIX open/mkdir/unlink calls. Move more error code returns to NTSTATUS. Client test code to follow... See if this passes the build-farm before I add it into 3.0.25. Jeremy. (This used to be commit 83dbbdff345fa9e427c9579183f4380004bf3dd7) --- source3/rpc_server/srv_srvsvc_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index c0953f2723..005c57e50a 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2081,6 +2081,7 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecur FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0, + FILE_ATTRIBUTE_DIRECTORY, NULL, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { @@ -2187,6 +2188,7 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecur FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0, + FILE_ATTRIBUTE_DIRECTORY, NULL, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { -- cgit From c96fc96de955ce5330af113abcee20645c8b5b78 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 9 Feb 2007 23:14:23 +0000 Subject: r21265: Fix some valgrind errors -- not in 3_0 (This used to be commit b419a3407532efcd50f54c77927b3b3bb566845f) --- source3/rpc_server/srv_srvsvc_nt.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 005c57e50a..615f5e1b07 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -80,8 +80,16 @@ static int pipe_enum_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, voi fenum->info[i].fid = (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum); fenum->info[i].permissions = (FILE_READ_DATA|FILE_WRITE_DATA); fenum->info[i].num_locks = 0; - fenum->info[i].user = uidtoname( prec.uid ); - fenum->info[i].path = fullpath; + if (!(fenum->info[i].user = talloc_strdup( + fenum->ctx, uidtoname(prec.uid)))) { + /* There's not much we can do here. */ + fenum->info[i].user = ""; + } + if (!(fenum->info[i].path = talloc_strdup( + fenum->ctx, fullpath))) { + /* There's not much we can do here. */ + fenum->info[i].path = ""; + } fenum->count++; } @@ -172,8 +180,16 @@ static void enum_file_fn( const struct share_mode_entry *e, fenum->info[i].fid = e->share_file_id; fenum->info[i].permissions = permissions; fenum->info[i].num_locks = num_locks; - fenum->info[i].user = uidtoname(e->uid); - fenum->info[i].path = fullpath; + if (!(fenum->info[i].user = talloc_strdup( + fenum->ctx, uidtoname(e->uid)))) { + /* There's not much we can do here. */ + fenum->info[i].user = ""; + } + if (!(fenum->info[i].path = talloc_strdup( + fenum->ctx, fullpath))) { + /* There's not much we can do here. */ + fenum->info[i].path = ""; + } fenum->count++; } @@ -863,8 +879,14 @@ static void init_srv_sess_info_1(pipes_struct *p, struct srvsvc_NetSessCtr1 *ss1 num_files = net_count_files(pw->pw_uid, session_list[*snum].pid); guest = strequal( session_list[*snum].username, lp_guestaccount() ); - ss1->array[num_entries].client = session_list[*snum].remote_machine; - ss1->array[num_entries].user = session_list[*snum].username; + if (!(ss1->array[num_entries].client = talloc_strdup( + ss1->array, session_list[*snum].remote_machine))) { + ss1->array[num_entries].client = ""; + } + if (!(ss1->array[num_entries].user = talloc_strdup( + ss1->array, session_list[*snum].username))) { + ss1->array[num_entries].user = ""; + } ss1->array[num_entries].num_open = num_files; ss1->array[num_entries].time = connect_time; ss1->array[num_entries].idle_time = 0; -- cgit From 4003edf0df14b69fca0d1af923badbd682c0008c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 16 Feb 2007 14:50:57 +0000 Subject: r21385: Regenerate IDL after pidl changes, sync winreg.idl from samba4. (This used to be commit b84370513fbf790e599c33f177fb271a2a992b72) --- source3/rpc_server/srv_winreg_nt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 404210a416..6db31eeb80 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -445,22 +445,22 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct winreg_EnumValue *r) } if (r->out.data != NULL) { - if ((r->out.data_size == NULL) || (r->out.value_length == NULL)) { + if ((r->out.size == NULL) || (r->out.length == NULL)) { return WERR_INVALID_PARAM; } - if (value_blob.length > *r->out.data_size) { + if (value_blob.length > *r->out.size) { return WERR_MORE_DATA; } memcpy( r->out.data, value_blob.data, value_blob.length ); } - if (r->out.value_length != NULL) { - *r->out.value_length = value_blob.length; + if (r->out.length != NULL) { + *r->out.length = value_blob.length; } - if (r->out.data_size != NULL) { - *r->out.data_size = value_blob.length; + if (r->out.size != NULL) { + *r->out.size = value_blob.length; } return WERR_OK; -- cgit From 1052cadbae7bf71a0575b06e8ac7ff52c7fb95ee Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 20 Feb 2007 13:43:41 +0000 Subject: r21462: Fix EnumValue (?) (This used to be commit e73a418b5b0100936efb4c1133da3cfe3fcb61cd) --- source3/rpc_server/srv_winreg_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 6db31eeb80..9e712173ab 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -444,7 +444,7 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct winreg_EnumValue *r) *r->out.type = val->type; } - if (r->out.data != NULL) { + if (r->out.value != NULL) { if ((r->out.size == NULL) || (r->out.length == NULL)) { return WERR_INVALID_PARAM; } @@ -453,7 +453,7 @@ WERROR _winreg_EnumValue(pipes_struct *p, struct winreg_EnumValue *r) return WERR_MORE_DATA; } - memcpy( r->out.data, value_blob.data, value_blob.length ); + memcpy( r->out.value, value_blob.data, value_blob.length ); } if (r->out.length != NULL) { -- cgit From 2b52e35770270959d5029fa84932d436652c7193 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 22 Feb 2007 20:52:27 +0000 Subject: r21507: Fix some "cannot access LDAP when no root" bugs. The two culprits were * pdb_get_account_policy() * pdb_get_group_sid() (This used to be commit 6a69caf6907fad01b13aa4358ce5c62506f98495) --- source3/rpc_server/srv_samr_nt.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 5c0f50699e..d35d97f2a0 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2179,6 +2179,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S uint32 acc_granted; BOOL ret; NTSTATUS result; + BOOL success = False; /* * from the SID in the request: @@ -2223,9 +2224,15 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S sids = NULL; + /* make both calls inside the root block */ become_root(); result = pdb_enum_group_memberships(p->mem_ctx, sam_pass, &sids, &unix_gids, &num_groups); + if ( NT_STATUS_IS_OK(result) ) { + success = sid_peek_check_rid(get_global_sam_sid(), + pdb_get_group_sid(sam_pass), + &primary_group_rid); + } unbecome_root(); if (!NT_STATUS_IS_OK(result)) { @@ -2234,15 +2241,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S return result; } - gids = NULL; - num_gids = 0; - - dom_gid.attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT| - SE_GROUP_ENABLED); - - if (!sid_peek_check_rid(get_global_sam_sid(), - pdb_get_group_sid(sam_pass), - &primary_group_rid)) { + if ( !success ) { DEBUG(5, ("Group sid %s for user %s not in our domain\n", sid_string_static(pdb_get_group_sid(sam_pass)), pdb_get_username(sam_pass))); @@ -2250,8 +2249,12 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S return NT_STATUS_INTERNAL_DB_CORRUPTION; } - dom_gid.g_rid = primary_group_rid; + gids = NULL; + num_gids = 0; + dom_gid.attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT| + SE_GROUP_ENABLED); + dom_gid.g_rid = primary_group_rid; ADD_TO_ARRAY(p->mem_ctx, DOM_GID, dom_gid, &gids, &num_gids); for (i=0; i Date: Mon, 26 Feb 2007 22:44:24 +0000 Subject: r21549: Only create DISP_INFO structs for domain handles, the others don't need them. It just does not make sense to do a querydispinfo on an alias handle... This fixes a memleak: Every samr_connect*() call leaked a DISP_INFO for the (NULL) sid. More cleanup pending: Essentially, we only need the DISP_INFO cache for the get_global_sam_sid() domain. BUILTIN is fixed and small enough, and there are no other domains around where enumerations could happen. This also removes the explicit builtin_domain flags. I don't think this is worth it. If this makes a significant difference, then we have a *VERY* tuned RPC layer... Jeremy, please check this. If it's ok, we might want to merge it across. Volker (This used to be commit 0aceda68a825788895759e79de55b080ad3f971d) --- source3/rpc_server/srv_samr_nt.c | 82 +++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 35 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d35d97f2a0..f59ab61509 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -49,7 +49,6 @@ typedef struct disp_info { struct disp_info *next, *prev; TALLOC_CTX *mem_ctx; DOM_SID sid; /* identify which domain this is. */ - BOOL builtin_domain; /* Quick flag to check if this is the builtin domain. */ struct pdb_search *users; /* querydispinfo 1 and 4 */ struct pdb_search *machines; /* querydispinfo 2 */ struct pdb_search *groups; /* querydispinfo 3 and 5, enumgroups */ @@ -70,7 +69,6 @@ static DISP_INFO *disp_info_list; struct samr_info { /* for use by the \PIPE\samr policy */ DOM_SID sid; - BOOL builtin_domain; /* Quick flag to check if this is the builtin domain. */ uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ uint32 acc_granted; DISP_INFO *disp_info; @@ -254,22 +252,11 @@ static NTSTATUS access_check_samr_function(uint32 acc_granted, uint32 acc_requir Fetch or create a dispinfo struct. ********************************************************************/ -static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid, const char *sid_str) +static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid) { TALLOC_CTX *mem_ctx; DISP_INFO *dpi; - /* There are two cases to consider here: - 1) The SID is a domain SID and we look for an equality match, or - 2) This is an account SID and so we return the DISP_INFO* for our - domain */ - - if ( psid && sid_check_is_in_our_domain( psid ) ) { - DEBUG(10,("get_samr_dispinfo_by_sid: Replacing %s with our domain SID\n", - sid_str)); - psid = get_global_sam_sid(); - } - for (dpi = disp_info_list; dpi; dpi = dpi->next) { if (sid_equal(psid, &dpi->sid)) { return dpi; @@ -280,19 +267,18 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid, const char *sid_str) can get a list out of smbd using smbcontrol. There will be one of these per SID we're authorative for. JRA. */ - mem_ctx = talloc_init("DISP_INFO for domain sid %s", sid_str); + mem_ctx = talloc_init("DISP_INFO for domain sid %s", + sid_string_static(psid)); - if ((dpi = TALLOC_ZERO_P(mem_ctx, DISP_INFO)) == NULL) + if ((dpi = TALLOC_ZERO_P(mem_ctx, DISP_INFO)) == NULL) { + DEBUG(0, ("talloc failed\n")); + TALLOC_FREE(mem_ctx); return NULL; + } dpi->mem_ctx = mem_ctx; - if (psid) { - sid_copy( &dpi->sid, psid); - dpi->builtin_domain = sid_check_is_builtin(psid); - } else { - dpi->builtin_domain = False; - } + sid_copy( &dpi->sid, psid); DLIST_ADD(disp_info_list, dpi); @@ -323,20 +309,11 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) DEBUG(10,("get_samr_info_by_sid: created new info for sid %s\n", sid_str)); if (psid) { sid_copy( &info->sid, psid); - info->builtin_domain = sid_check_is_builtin(psid); } else { DEBUG(10,("get_samr_info_by_sid: created new info for NULL sid.\n")); - info->builtin_domain = False; } info->mem_ctx = mem_ctx; - info->disp_info = get_samr_dispinfo_by_sid(psid, sid_str); - - if (!info->disp_info) { - talloc_destroy(mem_ctx); - return NULL; - } - return info; } @@ -493,7 +470,7 @@ static uint32 count_sam_users(struct disp_info *info, uint32 acct_flags) { struct samr_displayentry *entry; - if (info->builtin_domain) { + if (sid_check_is_builtin(&info->sid)) { /* No users in builtin. */ return 0; } @@ -517,7 +494,7 @@ static uint32 count_sam_groups(struct disp_info *info) { struct samr_displayentry *entry; - if (info->builtin_domain) { + if (sid_check_is_builtin(&info->sid)) { /* No groups in builtin. */ return 0; } @@ -625,6 +602,11 @@ NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN return NT_STATUS_NO_MEMORY; info->acc_granted = acc_granted; + if (!(info->disp_info = get_samr_dispinfo_by_sid(&q_u->dom_sid.sid))) { + TALLOC_FREE(info->mem_ctx); + return NT_STATUS_NO_MEMORY; + } + /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, &r_u->domain_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -679,6 +661,11 @@ static BOOL get_lsa_policy_samr_sid( pipes_struct *p, POLICY_HND *pol, if (!info) return False; + if (!info->disp_info) { + /* Not a domain */ + return False; + } + *sid = info->sid; *acc_granted = info->acc_granted; if (ppdisp_info) { @@ -911,6 +898,11 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; + if (!info->disp_info) { + /* not a domain */ + return NT_STATUS_INVALID_HANDLE; + } + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_users"))) { @@ -919,7 +911,7 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); - if (info->builtin_domain) { + if (sid_check_is_builtin(&info->sid)) { /* No users in builtin. */ init_samr_r_enum_dom_users(r_u, q_u->start_idx, 0); DEBUG(5,("_samr_enum_dom_users: No users in BUILTIN\n")); @@ -1044,6 +1036,11 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; + if (!info->disp_info) { + /* not a domain */ + return NT_STATUS_INVALID_HANDLE; + } + r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_groups"); @@ -1052,7 +1049,7 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); - if (info->builtin_domain) { + if (sid_check_is_builtin(&info->sid)) { /* No groups in builtin. */ init_samr_r_enum_dom_groups(r_u, q_u->start_idx, 0); DEBUG(5,("_samr_enum_dom_users: No groups in BUILTIN\n")); @@ -1103,6 +1100,11 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; + if (!info->disp_info) { + /* not a domain */ + return NT_STATUS_INVALID_HANDLE; + } + r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_aliases"); @@ -1169,6 +1171,11 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; + if (!info->disp_info) { + /* not a domain */ + return NT_STATUS_INVALID_HANDLE; + } + /* * calculate how many entries we will return. * based on @@ -2325,6 +2332,11 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)(void *)&info)) { return NT_STATUS_INVALID_HANDLE; } + + if (!info->disp_info) { + /* not a domain */ + return NT_STATUS_INVALID_HANDLE; + } switch (q_u->switch_value) { case 0x01: -- cgit From ab6a1df7a6f75637a0f25e02e16847d2441dee6d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 26 Feb 2007 22:48:42 +0000 Subject: r21550: make disp_info_list static to get_samr_dispinfo_by_sid(), add a comment :-) (This used to be commit fad2ee8aa3e99c31a0632a80b4a64dedb6e01495) --- source3/rpc_server/srv_samr_nt.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f59ab61509..b7a45267a3 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -64,8 +64,6 @@ typedef struct disp_info { /* We keep a static list of these by SID as modern clients close down all resources between each request in a complete enumeration. */ -static DISP_INFO *disp_info_list; - struct samr_info { /* for use by the \PIPE\samr policy */ DOM_SID sid; @@ -254,6 +252,24 @@ static NTSTATUS access_check_samr_function(uint32 acc_granted, uint32 acc_requir static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid) { + /* + * We do a static cache for DISP_INFO's here. Explanation can be found + * in Jeremy's checkin message to r11793: + * + * Fix the SAMR cache so it works across completely insane + * client behaviour (ie.: + * open pipe/open SAMR handle/enumerate 0 - 1024 + * close SAMR handle, close pipe. + * open pipe/open SAMR handle/enumerate 1024 - 2048... + * close SAMR handle, close pipe. + * And on ad-nausium. Amazing.... probably object-oriented + * client side programming in action yet again. + * This change should *massively* improve performance when + * enumerating users from an LDAP database. + * Jeremy. + */ + + static DISP_INFO *disp_info_list; TALLOC_CTX *mem_ctx; DISP_INFO *dpi; -- cgit From f4a008424f227c1da388e4aa4ac303fc86c460ce Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 26 Feb 2007 23:06:17 +0000 Subject: r21551: Ok, this is more subtle. More tomorrow :-) (This used to be commit f63189907efe857ef51ff91470ddb8d21b9a41fa) --- source3/rpc_server/srv_samr_nt.c | 102 ++++++++++++++------------------------- 1 file changed, 37 insertions(+), 65 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b7a45267a3..d35d97f2a0 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -49,6 +49,7 @@ typedef struct disp_info { struct disp_info *next, *prev; TALLOC_CTX *mem_ctx; DOM_SID sid; /* identify which domain this is. */ + BOOL builtin_domain; /* Quick flag to check if this is the builtin domain. */ struct pdb_search *users; /* querydispinfo 1 and 4 */ struct pdb_search *machines; /* querydispinfo 2 */ struct pdb_search *groups; /* querydispinfo 3 and 5, enumgroups */ @@ -64,9 +65,12 @@ typedef struct disp_info { /* We keep a static list of these by SID as modern clients close down all resources between each request in a complete enumeration. */ +static DISP_INFO *disp_info_list; + struct samr_info { /* for use by the \PIPE\samr policy */ DOM_SID sid; + BOOL builtin_domain; /* Quick flag to check if this is the builtin domain. */ uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ uint32 acc_granted; DISP_INFO *disp_info; @@ -250,29 +254,22 @@ static NTSTATUS access_check_samr_function(uint32 acc_granted, uint32 acc_requir Fetch or create a dispinfo struct. ********************************************************************/ -static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid) +static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid, const char *sid_str) { - /* - * We do a static cache for DISP_INFO's here. Explanation can be found - * in Jeremy's checkin message to r11793: - * - * Fix the SAMR cache so it works across completely insane - * client behaviour (ie.: - * open pipe/open SAMR handle/enumerate 0 - 1024 - * close SAMR handle, close pipe. - * open pipe/open SAMR handle/enumerate 1024 - 2048... - * close SAMR handle, close pipe. - * And on ad-nausium. Amazing.... probably object-oriented - * client side programming in action yet again. - * This change should *massively* improve performance when - * enumerating users from an LDAP database. - * Jeremy. - */ - - static DISP_INFO *disp_info_list; TALLOC_CTX *mem_ctx; DISP_INFO *dpi; + /* There are two cases to consider here: + 1) The SID is a domain SID and we look for an equality match, or + 2) This is an account SID and so we return the DISP_INFO* for our + domain */ + + if ( psid && sid_check_is_in_our_domain( psid ) ) { + DEBUG(10,("get_samr_dispinfo_by_sid: Replacing %s with our domain SID\n", + sid_str)); + psid = get_global_sam_sid(); + } + for (dpi = disp_info_list; dpi; dpi = dpi->next) { if (sid_equal(psid, &dpi->sid)) { return dpi; @@ -283,18 +280,19 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid) can get a list out of smbd using smbcontrol. There will be one of these per SID we're authorative for. JRA. */ - mem_ctx = talloc_init("DISP_INFO for domain sid %s", - sid_string_static(psid)); + mem_ctx = talloc_init("DISP_INFO for domain sid %s", sid_str); - if ((dpi = TALLOC_ZERO_P(mem_ctx, DISP_INFO)) == NULL) { - DEBUG(0, ("talloc failed\n")); - TALLOC_FREE(mem_ctx); + if ((dpi = TALLOC_ZERO_P(mem_ctx, DISP_INFO)) == NULL) return NULL; - } dpi->mem_ctx = mem_ctx; - sid_copy( &dpi->sid, psid); + if (psid) { + sid_copy( &dpi->sid, psid); + dpi->builtin_domain = sid_check_is_builtin(psid); + } else { + dpi->builtin_domain = False; + } DLIST_ADD(disp_info_list, dpi); @@ -325,11 +323,20 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) DEBUG(10,("get_samr_info_by_sid: created new info for sid %s\n", sid_str)); if (psid) { sid_copy( &info->sid, psid); + info->builtin_domain = sid_check_is_builtin(psid); } else { DEBUG(10,("get_samr_info_by_sid: created new info for NULL sid.\n")); + info->builtin_domain = False; } info->mem_ctx = mem_ctx; + info->disp_info = get_samr_dispinfo_by_sid(psid, sid_str); + + if (!info->disp_info) { + talloc_destroy(mem_ctx); + return NULL; + } + return info; } @@ -486,7 +493,7 @@ static uint32 count_sam_users(struct disp_info *info, uint32 acct_flags) { struct samr_displayentry *entry; - if (sid_check_is_builtin(&info->sid)) { + if (info->builtin_domain) { /* No users in builtin. */ return 0; } @@ -510,7 +517,7 @@ static uint32 count_sam_groups(struct disp_info *info) { struct samr_displayentry *entry; - if (sid_check_is_builtin(&info->sid)) { + if (info->builtin_domain) { /* No groups in builtin. */ return 0; } @@ -618,11 +625,6 @@ NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN return NT_STATUS_NO_MEMORY; info->acc_granted = acc_granted; - if (!(info->disp_info = get_samr_dispinfo_by_sid(&q_u->dom_sid.sid))) { - TALLOC_FREE(info->mem_ctx); - return NT_STATUS_NO_MEMORY; - } - /* get a (unique) handle. open a policy on it. */ if (!create_policy_hnd(p, &r_u->domain_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -677,11 +679,6 @@ static BOOL get_lsa_policy_samr_sid( pipes_struct *p, POLICY_HND *pol, if (!info) return False; - if (!info->disp_info) { - /* Not a domain */ - return False; - } - *sid = info->sid; *acc_granted = info->acc_granted; if (ppdisp_info) { @@ -914,11 +911,6 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - if (!info->disp_info) { - /* not a domain */ - return NT_STATUS_INVALID_HANDLE; - } - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_users"))) { @@ -927,7 +919,7 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); - if (sid_check_is_builtin(&info->sid)) { + if (info->builtin_domain) { /* No users in builtin. */ init_samr_r_enum_dom_users(r_u, q_u->start_idx, 0); DEBUG(5,("_samr_enum_dom_users: No users in BUILTIN\n")); @@ -1052,11 +1044,6 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - if (!info->disp_info) { - /* not a domain */ - return NT_STATUS_INVALID_HANDLE; - } - r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_groups"); @@ -1065,7 +1052,7 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); - if (sid_check_is_builtin(&info->sid)) { + if (info->builtin_domain) { /* No groups in builtin. */ init_samr_r_enum_dom_groups(r_u, q_u->start_idx, 0); DEBUG(5,("_samr_enum_dom_users: No groups in BUILTIN\n")); @@ -1116,11 +1103,6 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - if (!info->disp_info) { - /* not a domain */ - return NT_STATUS_INVALID_HANDLE; - } - r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_aliases"); @@ -1187,11 +1169,6 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - if (!info->disp_info) { - /* not a domain */ - return NT_STATUS_INVALID_HANDLE; - } - /* * calculate how many entries we will return. * based on @@ -2348,11 +2325,6 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)(void *)&info)) { return NT_STATUS_INVALID_HANDLE; } - - if (!info->disp_info) { - /* not a domain */ - return NT_STATUS_INVALID_HANDLE; - } switch (q_u->switch_value) { case 0x01: -- cgit From 2838d7499cbd5b7ebade52321985244aee9a9f70 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 27 Feb 2007 17:21:21 +0000 Subject: r21563: Fix a memleak: We only need dispinfo structs for "our" and for the builtin domain. Without this patch we leaked a DISPINFO for the (NULL) domain per samr_connect*() call. Volker (This used to be commit 4423880ff47a94074c625a4f4f81c3b516faa644) --- source3/rpc_server/srv_samr_nt.c | 81 ++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d35d97f2a0..7cf75bcd40 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -46,8 +46,6 @@ #define DISP_INFO_CACHE_TIMEOUT 10 typedef struct disp_info { - struct disp_info *next, *prev; - TALLOC_CTX *mem_ctx; DOM_SID sid; /* identify which domain this is. */ BOOL builtin_domain; /* Quick flag to check if this is the builtin domain. */ struct pdb_search *users; /* querydispinfo 1 and 4 */ @@ -65,8 +63,6 @@ typedef struct disp_info { /* We keep a static list of these by SID as modern clients close down all resources between each request in a complete enumeration. */ -static DISP_INFO *disp_info_list; - struct samr_info { /* for use by the \PIPE\samr policy */ DOM_SID sid; @@ -254,49 +250,59 @@ static NTSTATUS access_check_samr_function(uint32 acc_granted, uint32 acc_requir Fetch or create a dispinfo struct. ********************************************************************/ -static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid, const char *sid_str) +static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid) { - TALLOC_CTX *mem_ctx; - DISP_INFO *dpi; + /* + * We do a static cache for DISP_INFO's here. Explanation can be found + * in Jeremy's checkin message to r11793: + * + * Fix the SAMR cache so it works across completely insane + * client behaviour (ie.: + * open pipe/open SAMR handle/enumerate 0 - 1024 + * close SAMR handle, close pipe. + * open pipe/open SAMR handle/enumerate 1024 - 2048... + * close SAMR handle, close pipe. + * And on ad-nausium. Amazing.... probably object-oriented + * client side programming in action yet again. + * This change should *massively* improve performance when + * enumerating users from an LDAP database. + * Jeremy. + * + * "Our" and the builtin domain are the only ones where we ever + * enumerate stuff, so just cache 2 entries. + */ + + static struct disp_info builtin_dispinfo; + static struct disp_info domain_dispinfo; /* There are two cases to consider here: 1) The SID is a domain SID and we look for an equality match, or 2) This is an account SID and so we return the DISP_INFO* for our domain */ - if ( psid && sid_check_is_in_our_domain( psid ) ) { - DEBUG(10,("get_samr_dispinfo_by_sid: Replacing %s with our domain SID\n", - sid_str)); - psid = get_global_sam_sid(); - } - - for (dpi = disp_info_list; dpi; dpi = dpi->next) { - if (sid_equal(psid, &dpi->sid)) { - return dpi; - } - } - - /* This struct is never free'd - I'm using talloc so we - can get a list out of smbd using smbcontrol. There will - be one of these per SID we're authorative for. JRA. */ - - mem_ctx = talloc_init("DISP_INFO for domain sid %s", sid_str); - - if ((dpi = TALLOC_ZERO_P(mem_ctx, DISP_INFO)) == NULL) + if (psid == NULL) { return NULL; + } - dpi->mem_ctx = mem_ctx; + if (sid_check_is_builtin(psid) || sid_check_is_in_builtin(psid)) { + /* + * Necessary only once, but it does not really hurt. + */ + sid_copy(&builtin_dispinfo.sid, &global_sid_Builtin); - if (psid) { - sid_copy( &dpi->sid, psid); - dpi->builtin_domain = sid_check_is_builtin(psid); - } else { - dpi->builtin_domain = False; + return &builtin_dispinfo; } + + if (sid_check_is_domain(psid) || sid_check_is_in_our_domain(psid)) { + /* + * Necessary only once, but it does not really hurt. + */ + sid_copy(&domain_dispinfo.sid, get_global_sam_sid()); - DLIST_ADD(disp_info_list, dpi); + return &domain_dispinfo; + } - return dpi; + return NULL; } /******************************************************************* @@ -330,12 +336,7 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) } info->mem_ctx = mem_ctx; - info->disp_info = get_samr_dispinfo_by_sid(psid, sid_str); - - if (!info->disp_info) { - talloc_destroy(mem_ctx); - return NULL; - } + info->disp_info = get_samr_dispinfo_by_sid(psid); return info; } -- cgit From 8c5846acf241307ebd82b41fd454f0f50825a37a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Feb 2007 22:04:23 +0000 Subject: r21569: Fix bug reported by Martin Zielinski where return value was incorrectly initialized. Jeremy. (This used to be commit 8d45f1f3b524031a34cfba21b677be8a09fc192c) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 48b34755a6..958e9d81fe 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -8633,7 +8633,7 @@ WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS static WERROR enumprintprocdatatypes_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { PRINTPROCDATATYPE_1 *info_1=NULL; - WERROR result = WERR_NOMEM; + WERROR result = WERR_OK; if((info_1 = SMB_MALLOC_P(PRINTPROCDATATYPE_1)) == NULL) return WERR_NOMEM; -- cgit From 742a853875045e5f38b5c82b963dabc928141304 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 1 Mar 2007 18:48:52 +0000 Subject: r21635: Don't free talloc()'d memory. I wish people would check the callers when changing how memory is allocated. (This used to be commit 78bf4042dd22bf063846c58729d5b64be3fce8a8) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 7cf75bcd40..56f2344247 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3886,7 +3886,7 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ init_samr_r_query_aliasmem(r_u, num_sids, sid, NT_STATUS_OK); - SAFE_FREE(sids); + TALLOC_FREE(sids); return NT_STATUS_OK; } -- cgit From 0d91334fe799f6b50a8265f9dc097411c3a29e18 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 11 Mar 2007 16:49:16 +0000 Subject: r21784: Replace smb_register_idle_event() with event_add_timed(). This fixes winbind who did not run the idle events to drop ldap connections. Volker (This used to be commit af3308ce5a21220ff4c510de356dbaa6cf9ff997) --- source3/rpc_server/srv_samr_nt.c | 79 ++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 47 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 56f2344247..ca7185f527 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -56,8 +56,8 @@ typedef struct disp_info { uint16 enum_acb_mask; struct pdb_search *enum_users; /* enumusers with a mask */ - - smb_event_id_t di_cache_timeout_event; /* cache idle timeout handler. */ + struct timed_event *cache_timeout_event; /* cache idle timeout + * handler. */ } DISP_INFO; /* We keep a static list of these by SID as modern clients close down @@ -345,9 +345,10 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) Function to free the per SID data. ********************************************************************/ -static void free_samr_cache(DISP_INFO *disp_info, const char *sid_str) +static void free_samr_cache(DISP_INFO *disp_info) { - DEBUG(10,("free_samr_cache: deleting cache for SID %s\n", sid_str)); + DEBUG(10, ("free_samr_cache: deleting cache for SID %s\n", + sid_string_static(&disp_info->sid))); /* We need to become root here because the paged search might have to * tell the LDAP server we're not interested in the rest anymore. */ @@ -395,10 +396,8 @@ static void free_samr_info(void *ptr) /* Only free the dispinfo cache if no one bothered to set up a timeout. */ - if (info->disp_info && info->disp_info->di_cache_timeout_event == (smb_event_id_t)0) { - fstring sid_str; - sid_to_string(sid_str, &info->disp_info->sid); - free_samr_cache(info->disp_info, sid_str); + if (info->disp_info && info->disp_info->cache_timeout_event == NULL) { + free_samr_cache(info->disp_info); } talloc_destroy(info->mem_ctx); @@ -408,23 +407,18 @@ static void free_samr_info(void *ptr) Idle event handler. Throw away the disp info cache. ********************************************************************/ -static void disp_info_cache_idle_timeout_handler(void **private_data, - time_t *ev_interval, - time_t ev_now) +static void disp_info_cache_idle_timeout_handler(struct event_context *ev_ctx, + struct timed_event *te, + const struct timeval *now, + void *private_data) { - fstring sid_str; - DISP_INFO *disp_info = (DISP_INFO *)(*private_data); - - sid_to_string(sid_str, &disp_info->sid); + DISP_INFO *disp_info = (DISP_INFO *)private_data; - free_samr_cache(disp_info, sid_str); + TALLOC_FREE(disp_info->cache_timeout_event); - /* Remove the event. */ - smb_unregister_idle_event(disp_info->di_cache_timeout_event); - disp_info->di_cache_timeout_event = (smb_event_id_t)0; - - DEBUG(10,("disp_info_cache_idle_timeout_handler: caching timed out for SID %s at %u\n", - sid_str, (unsigned int)ev_now)); + DEBUG(10, ("disp_info_cache_idle_timeout_handler: caching timed " + "out\n")); + free_samr_cache(disp_info); } /******************************************************************* @@ -433,24 +427,20 @@ static void disp_info_cache_idle_timeout_handler(void **private_data, static void set_disp_info_cache_timeout(DISP_INFO *disp_info, time_t secs_fromnow) { - fstring sid_str; - - sid_to_string(sid_str, &disp_info->sid); - /* Remove any pending timeout and update. */ - if (disp_info->di_cache_timeout_event) { - smb_unregister_idle_event(disp_info->di_cache_timeout_event); - disp_info->di_cache_timeout_event = (smb_event_id_t)0; - } + TALLOC_FREE(disp_info->cache_timeout_event); - DEBUG(10,("set_disp_info_cache_timeout: caching enumeration for SID %s for %u seconds\n", - sid_str, (unsigned int)secs_fromnow )); + DEBUG(10,("set_disp_info_cache_timeout: caching enumeration for " + "SID %s for %u seconds\n", + sid_string_static(&disp_info->sid), + (unsigned int)secs_fromnow )); - disp_info->di_cache_timeout_event = - smb_register_idle_event(disp_info_cache_idle_timeout_handler, - disp_info, - secs_fromnow); + disp_info->cache_timeout_event = event_add_timed( + smbd_event_context(), NULL, + timeval_current_ofs(secs_fromnow, 0), + "disp_info_cache_idle_timeout_handler", + disp_info_cache_idle_timeout_handler, (void *)disp_info); } /******************************************************************* @@ -460,18 +450,13 @@ static void set_disp_info_cache_timeout(DISP_INFO *disp_info, time_t secs_fromno static void force_flush_samr_cache(DISP_INFO *disp_info) { - if (disp_info) { - fstring sid_str; - - sid_to_string(sid_str, &disp_info->sid); - if (disp_info->di_cache_timeout_event) { - smb_unregister_idle_event(disp_info->di_cache_timeout_event); - disp_info->di_cache_timeout_event = (smb_event_id_t)0; - DEBUG(10,("force_flush_samr_cache: clearing idle event for SID %s\n", - sid_str)); - } - free_samr_cache(disp_info, sid_str); + if ((disp_info == NULL) || (disp_info->cache_timeout_event == NULL)) { + return; } + + DEBUG(10,("force_flush_samr_cache: clearing idle event\n")); + TALLOC_FREE(disp_info->cache_timeout_event); + free_samr_cache(disp_info); } /******************************************************************* -- cgit From 24cdd7c73389c9eed981313973df2c3595222781 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 12 Mar 2007 17:55:24 +0000 Subject: r21800: Check-in the DFS rewrite. I am still testing this but it works from smbclient and Windows, and I am promising to support and fix both client and server code moving forward. Still need to test the RPC admin support but I haven't changed that code. Jeremy. (This used to be commit 7a7862c01d07796ef206b255c676ad7dc2cc42fc) --- source3/rpc_server/srv_dfs_nt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 98818826df..c7adffd62f 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -42,6 +42,8 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) { struct junction_map jn; struct referral* old_referral_list = NULL; + BOOL self_ref = False; + int consumedcnt = 0; BOOL exists = False; pstring altpath; @@ -59,7 +61,7 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) pstrcat(altpath, r->in.share); /* The following call can change the cwd. */ - if(get_referred_path(p->mem_ctx, r->in.path, &jn, NULL, NULL)) { + if(get_referred_path(p->mem_ctx, r->in.path, &jn, &consumedcnt, &self_ref)) { exists = True; jn.referral_count += 1; old_referral_list = jn.referral_list; @@ -96,6 +98,8 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) { struct junction_map jn; + BOOL self_ref = False; + int consumedcnt = 0; BOOL found = False; pstring altpath; @@ -115,7 +119,7 @@ WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n", r->in.path, r->in.server, r->in.share)); - if(!get_referred_path(p->mem_ctx, r->in.path, &jn, NULL, NULL)) { + if(!get_referred_path(p->mem_ctx, r->in.path, &jn, &consumedcnt, &self_ref)) { return WERR_DFS_NO_SUCH_VOL; } @@ -302,13 +306,14 @@ WERROR _dfs_GetInfo(pipes_struct *p, struct dfs_GetInfo *r) { int consumedcnt = sizeof(pstring); struct junction_map jn; + BOOL self_ref = False; BOOL ret; if(!create_junction(r->in.path, &jn)) return WERR_DFS_NO_SUCH_SERVER; /* The following call can change the cwd. */ - if(!get_referred_path(p->mem_ctx, r->in.path, &jn, &consumedcnt, NULL) || consumedcnt < strlen(r->in.path)) { + if(!get_referred_path(p->mem_ctx, r->in.path, &jn, &consumedcnt, &self_ref) || consumedcnt < strlen(r->in.path)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; } @@ -456,4 +461,3 @@ WERROR _dfs_SetInfo2(pipes_struct *p, struct dfs_SetInfo2 *r) p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } - -- cgit From 56ba44766854ed7cda265bdaf85913f2a1008282 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 28 Mar 2007 13:34:59 +0000 Subject: r22001: change prototype of dump_data(), so that it takes unsigned char * now, which matches what samba4 has. also fix all the callers to prevent compiler warnings metze (This used to be commit fa322f0cc9c26a9537ba3f0a7d4e4a25941317e7) --- source3/rpc_server/srv_lsa_hnd.c | 6 +++--- source3/rpc_server/srv_netlog_nt.c | 2 +- source3/rpc_server/srv_pipe_hnd.c | 2 +- source3/rpc_server/srv_samr_nt.c | 12 ++++++------ source3/rpc_server/srv_spoolss_nt.c | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 88c59ee895..a95415c9ce 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -146,7 +146,7 @@ BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *) *hnd = pol->pol_hnd; DEBUG(4,("Opened policy hnd[%d] ", (int)p->pipe_handles->count)); - dump_data(4, (char *)hnd, sizeof(*hnd)); + dump_data(4, (uint8 *)hnd, sizeof(*hnd)); return True; } @@ -166,7 +166,7 @@ static struct policy *find_policy_by_hnd_internal(pipes_struct *p, POLICY_HND *h for (i = 0, pol=p->pipe_handles->Policy;pol;pol=pol->next, i++) { if (memcmp(&pol->pol_hnd, hnd, sizeof(*hnd)) == 0) { DEBUG(4,("Found policy hnd[%d] ", (int)i)); - dump_data(4, (char *)hnd, sizeof(*hnd)); + dump_data(4, (uint8 *)hnd, sizeof(*hnd)); if (data_p) *data_p = pol->data_ptr; return pol; @@ -174,7 +174,7 @@ static struct policy *find_policy_by_hnd_internal(pipes_struct *p, POLICY_HND *h } DEBUG(4,("Policy not found: ")); - dump_data(4, (char *)hnd, sizeof(*hnd)); + dump_data(4, (uint8 *)hnd, sizeof(*hnd)); p->bad_handle_fault_state = True; diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index b8c776964e..0c12cb3b7c 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -296,7 +296,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) } memcpy(md4pw, pass, 16); - dump_data(5, md4pw, 16); + dump_data(5, (uint8 *)md4pw, 16); TALLOC_FREE(sampass); diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 8aa5bb3e6d..d65696668e 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -937,7 +937,7 @@ ssize_t write_to_pipe(smb_np_struct *p, char *data, size_t n) DEBUG(6,(" name: %s open: %s len: %d\n", p->name, BOOLSTR(p->open), (int)n)); - dump_data(50, data, n); + dump_data(50, (uint8 *)data, n); return p->namedpipe_write(p->np_state, data, n); } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ca7185f527..c743e68530 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3553,7 +3553,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE } SamOEMhashBlob(ctr->info.id24->pass, 516, &p->session_key); - dump_data(100, (char *)ctr->info.id24->pass, 516); + dump_data(100, ctr->info.id24->pass, 516); if (!set_user_info_pw(ctr->info.id24->pass, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; @@ -3565,7 +3565,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE } encode_or_decode_arc4_passwd_buffer(ctr->info.id25->pass, &p->session_key); - dump_data(100, (char *)ctr->info.id25->pass, 532); + dump_data(100, ctr->info.id25->pass, 532); r_u->status = set_user_info_25(p->mem_ctx, ctr->info.id25, pwd); @@ -3582,7 +3582,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE } encode_or_decode_arc4_passwd_buffer(ctr->info.id26->pass, &p->session_key); - dump_data(100, (char *)ctr->info.id26->pass, 516); + dump_data(100, ctr->info.id26->pass, 516); if (!set_user_info_pw(ctr->info.id26->pass, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; @@ -3594,7 +3594,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE } SamOEMhashBlob(ctr->info.id23->pass, 516, &p->session_key); - dump_data(100, (char *)ctr->info.id23->pass, 516); + dump_data(100, ctr->info.id23->pass, 516); r_u->status = set_user_info_23(p->mem_ctx, ctr->info.id23, pwd); @@ -3728,7 +3728,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ } SamOEMhashBlob(ctr->info.id23->pass, 516, &p->session_key); - dump_data(100, (char *)ctr->info.id23->pass, 516); + dump_data(100, ctr->info.id23->pass, 516); r_u->status = set_user_info_23(p->mem_ctx, ctr->info.id23, pwd); @@ -3739,7 +3739,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ } encode_or_decode_arc4_passwd_buffer(ctr->info.id26->pass, &p->session_key); - dump_data(100, (char *)ctr->info.id26->pass, 516); + dump_data(100, ctr->info.id26->pass, 516); if (!set_user_info_pw(ctr->info.id26->pass, pwd)) r_u->status = NT_STATUS_ACCESS_DENIED; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 958e9d81fe..e06d613c74 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1097,7 +1097,7 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, voi DEBUG(3, ("notify2_unpack_msg: value1 = %d, value2 = %d\n", msg->notify.value[0], msg->notify.value[1])); else - dump_data(3, msg->notify.data, msg->len); + dump_data(3, (uint8 *)msg->notify.data, msg->len); return True; } -- cgit From bc2b6436d0f5f3e9ffdfaeb7f1b32996a83d5478 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 29 Mar 2007 09:35:51 +0000 Subject: r22009: change TDB_DATA from char * to unsigned char * and fix all compiler warnings in the users metze (This used to be commit 3a28443079c141a6ce8182c65b56ca210e34f37f) --- source3/rpc_server/srv_eventlog_lib.c | 10 +++++----- source3/rpc_server/srv_eventlog_nt.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index c853f932ae..c780cf910c 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -188,7 +188,7 @@ BOOL make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, for ( i = start_record; i < end_record; i++ ) { /* read a record, add the amt to nbytes */ key.dsize = sizeof( int32 ); - key.dptr = ( char * ) ( int32 * ) & i; + key.dptr = ( uint8 * ) ( int32 * ) & i; ret = tdb_fetch( the_tdb, key ); if ( ret.dsize == 0 ) { DEBUG( 8, @@ -233,7 +233,7 @@ BOOL make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, if ( start_record != new_start ) { for ( i = start_record; i < new_start; i++ ) { key.dsize = sizeof( int32 ); - key.dptr = ( char * ) ( int32 * ) & i; + key.dptr = ( uint8 * ) ( int32 * ) & i; tdb_delete( the_tdb, key ); } @@ -500,7 +500,7 @@ int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ) next_record = tdb_fetch_int32( the_tdb, EVT_NEXT_RECORD ); n_packed = - tdb_pack( (char *)packed_ee, ee->record.length + MARGIN, + tdb_pack( (uint8 *)packed_ee, ee->record.length + MARGIN, "ddddddwwwwddddddBBdBBBd", ee->record.length, ee->record.reserved1, next_record, ee->record.time_generated, ee->record.time_written, @@ -529,10 +529,10 @@ int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ) /* increment the record count */ kbuf.dsize = sizeof( int32 ); - kbuf.dptr = (char * ) & next_record; + kbuf.dptr = (uint8 * ) & next_record; ebuf.dsize = n_packed; - ebuf.dptr = (char *)packed_ee; + ebuf.dptr = (uint8 *)packed_ee; if ( tdb_store( the_tdb, kbuf, ebuf, 0 ) ) { /* DEBUG(1,("write_eventlog_tdb: Can't write record %d to eventlog\n",next_record)); */ diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 519be60199..753772642a 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -295,7 +295,7 @@ static Eventlog_entry *get_eventlog_record( prs_struct * ps, TDB_CONTEXT * tdb, key.dsize = sizeof( int32 ); srecno = recno; - key.dptr = ( char * ) &srecno; + key.dptr = ( uint8 * ) &srecno; ret = tdb_fetch( tdb, key ); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e06d613c74..b33fc6b5b0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1073,18 +1073,18 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, voi /* Unpack message */ - offset += tdb_unpack((char *)buf + offset, len - offset, "f", + offset += tdb_unpack((uint8 *)buf + offset, len - offset, "f", msg->printer); - offset += tdb_unpack((char *)buf + offset, len - offset, "ddddddd", + offset += tdb_unpack((uint8 *)buf + offset, len - offset, "ddddddd", &tv_sec, &tv_usec, &msg->type, &msg->field, &msg->id, &msg->len, &msg->flags); if (msg->len == 0) - tdb_unpack((char *)buf + offset, len - offset, "dd", + tdb_unpack((uint8 *)buf + offset, len - offset, "dd", &msg->notify.value[0], &msg->notify.value[1]); else - tdb_unpack((char *)buf + offset, len - offset, "B", + tdb_unpack((uint8 *)buf + offset, len - offset, "B", &msg->len, &msg->notify.data); DEBUG(3, ("notify2_unpack_msg: got NOTIFY2 message for printer %s, jobid %u type %d, field 0x%02x, flags 0x%04x\n", -- cgit From 0389cad7c492eda5aee590d0396748c7da9b44ff Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 3 Apr 2007 12:28:40 +0000 Subject: r22055: Port the endpoint mapper (and functions it requires) to Samba 3. (This used to be commit ad981261877e6a2dce0c4f4e71fd9127aa31538a) --- source3/rpc_server/srv_epmapper_nt.c | 71 ++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_pipe.c | 5 ++- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 source3/rpc_server/srv_epmapper_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_epmapper_nt.c b/source3/rpc_server/srv_epmapper_nt.c new file mode 100644 index 0000000000..77a06124db --- /dev/null +++ b/source3/rpc_server/srv_epmapper_nt.c @@ -0,0 +1,71 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines for the endpoint mapper + * Copyright (C) Jelmer Vernooij 2007. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* This is the implementation of the dfs pipe. */ + +#include "includes.h" + +uint32 _epm_MapAuth(pipes_struct *p, struct epm_MapAuth *r) +{ + /* FIXME */ + return 0; +} + +uint32 _epm_MgmtDelete(pipes_struct *p, struct epm_MgmtDelete *r) +{ + /* FIXME */ + return 0; +} + +uint32 _epm_InqObject(pipes_struct *p, struct epm_InqObject *r) +{ + /* FIXME */ + return 0; +} + +uint32 _epm_LookupHandleFree(pipes_struct *p, struct epm_LookupHandleFree *r) +{ + /* FIXME */ + return 0; +} + +uint32 _epm_Map(pipes_struct *p, struct epm_Map *r) +{ + /* FIXME */ + return 0; +} + +uint32 _epm_Lookup(pipes_struct *p, struct epm_Lookup *r) +{ + /* FIXME */ + return 0; +} + +uint32 _epm_Delete(pipes_struct *p, struct epm_Delete *r) +{ + /* FIXME */ + return 0; +} + +uint32 _epm_Insert(pipes_struct *p, struct epm_Insert *r) +{ + /* FIXME */ + return 0; +} diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 50ef195015..83c059d36c 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2382,7 +2382,7 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) case PI_SVCCTL: svcctl_get_pipe_fns( &cmds, &n_cmds ); break; - case PI_EVENTLOG: + case PI_EVENTLOG: eventlog_get_pipe_fns( &cmds, &n_cmds ); break; case PI_UNIXINFO: @@ -2396,6 +2396,9 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) rpcecho_get_pipe_fns( &cmds, &n_cmds ); break; #endif + case PI_EPMAPPER: + epmapper_get_pipe_fns( &cmds, &n_cmds ); + break; default: DEBUG(0,("get_pipe_fns: Unknown pipe index! [%d]\n", idx)); } -- cgit From 7f8d89bc5488cea1b85161dec98dc1a2dddd7b45 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 3 Apr 2007 19:47:19 +0000 Subject: r22062: Fix the parsing of info level 3. Flags is not a flags field, but an offset. Fixed 64-bit display of ACLs on printers. Jeremy. (This used to be commit 0c8949ff5d742dbe59f2af0f57a289f238e3592c) --- source3/rpc_server/srv_spoolss_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b33fc6b5b0..3e1c1a2408 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4220,8 +4220,6 @@ static BOOL construct_printer_info_3(Printer_entry *print_hnd, /* These are the components of the SD we are returning. */ - printer->flags = 0x4; - if (ntprinter->info_2->secdesc_buf && ntprinter->info_2->secdesc_buf->sd_size != 0) { /* don't use talloc_steal() here unless you do a deep steal of all the SEC_DESC members */ -- cgit From cab91684e51356215a4c764e1673e4fd8420b8e8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 3 Apr 2007 22:59:55 +0000 Subject: r22064: Fix the DFS code to work better with Vista clients. Allow "host msdfs = true" to be set in the [global] section and allow Vista to see shares with "msdfs root = yes" and "msdfs root = no" off the same server. Down to an error message really :-). Jeremy. (This used to be commit 1a0f69bb21fd03a18514dfc93c84568708144e28) --- source3/rpc_server/srv_dfs_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index c7adffd62f..56c1ce00ab 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -61,7 +61,7 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) pstrcat(altpath, r->in.share); /* The following call can change the cwd. */ - if(get_referred_path(p->mem_ctx, r->in.path, &jn, &consumedcnt, &self_ref)) { + if(NT_STATUS_IS_OK(get_referred_path(p->mem_ctx, r->in.path, &jn, &consumedcnt, &self_ref))) { exists = True; jn.referral_count += 1; old_referral_list = jn.referral_list; @@ -119,7 +119,7 @@ WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n", r->in.path, r->in.server, r->in.share)); - if(!get_referred_path(p->mem_ctx, r->in.path, &jn, &consumedcnt, &self_ref)) { + if(!NT_STATUS_IS_OK(get_referred_path(p->mem_ctx, r->in.path, &jn, &consumedcnt, &self_ref))) { return WERR_DFS_NO_SUCH_VOL; } @@ -313,7 +313,7 @@ WERROR _dfs_GetInfo(pipes_struct *p, struct dfs_GetInfo *r) return WERR_DFS_NO_SUCH_SERVER; /* The following call can change the cwd. */ - if(!get_referred_path(p->mem_ctx, r->in.path, &jn, &consumedcnt, &self_ref) || consumedcnt < strlen(r->in.path)) { + if(!NT_STATUS_IS_OK(get_referred_path(p->mem_ctx, r->in.path, &jn, &consumedcnt, &self_ref)) || consumedcnt < strlen(r->in.path)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; } -- cgit From a1e72969d571d6b12f4cfa8c6dc16d7d982daa51 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 6 Apr 2007 18:52:30 +0000 Subject: r22104: BUG 4439: Fix the object picket on x64 WIndopws XP/2003. Enable the DsRoleGetPrimaryDomainInfo() server code. Tested by Win2000/XP/2003/Vista (x86) and WinXP (x64) (This used to be commit eab9ca7e7d8d7dc3e705720f8bc5dff5c8ec5f5f) --- source3/rpc_server/srv_lsa_ds.c | 13 +++------- source3/rpc_server/srv_lsa_ds_nt.c | 49 +++++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_ds.c b/source3/rpc_server/srv_lsa_ds.c index 1e75175c2c..db741a1b64 100644 --- a/source3/rpc_server/srv_lsa_ds.c +++ b/source3/rpc_server/srv_lsa_ds.c @@ -25,9 +25,7 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -#if 0 /* disabled */ /******************************************************************* - api_reg_open_entry ********************************************************************/ static BOOL api_dsrole_get_primary_dominfo(pipes_struct *p) @@ -41,18 +39,17 @@ static BOOL api_dsrole_get_primary_dominfo(pipes_struct *p) ZERO_STRUCT(r_u); /* grab the request */ - if ( !ds_io_q_getprimdominfo("", data, 0, &q_u) ) + if ( !ds_io_q_getprimdominfo("", &q_u, data, 0) ) return False; /* construct reply. */ r_u.status = _dsrole_get_primary_dominfo( p, &q_u, &r_u ); - if ( !ds_io_r_getprimdominfo("", rdata, 0, &r_u) ) + if ( !ds_io_r_getprimdominfo("", &r_u, rdata, 0) ) return False; return True; } -#endif /******************************************************************* stub functions for unimplemented RPC @@ -70,12 +67,8 @@ static BOOL api_dsrole_stub( pipes_struct *p ) array of \PIPE\lsass (new windows 2000 UUID) operations ********************************************************************/ static struct api_struct api_lsa_ds_cmds[] = { - { "DS_NOP", DS_NOP, api_dsrole_stub } - -#if 0 /* disabled due to breakage with viewing domain users and groups - on a Samba PDC from win2k clients --jerry CIFS 2003 */ + { "DS_NOP", DS_NOP, api_dsrole_stub }, { "DS_GETPRIMDOMINFO", DS_GETPRIMDOMINFO, api_dsrole_get_primary_dominfo } -#endif }; diff --git a/source3/rpc_server/srv_lsa_ds_nt.c b/source3/rpc_server/srv_lsa_ds_nt.c index b410af8ded..844a20eed4 100644 --- a/source3/rpc_server/srv_lsa_ds_nt.c +++ b/source3/rpc_server/srv_lsa_ds_nt.c @@ -46,49 +46,54 @@ static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN return NT_STATUS_NO_MEMORY; } - get_mydnsdomname(dnsdomain); - strlower_m(dnsdomain); - switch ( lp_server_role() ) { case ROLE_STANDALONE: basic->machine_role = DSROLE_STANDALONE_SRV; + basic->netbios_ptr = 1; + netbios_domain = get_global_sam_name(); break; case ROLE_DOMAIN_MEMBER: + basic->netbios_ptr = 1; + netbios_domain = lp_workgroup(); basic->machine_role = DSROLE_DOMAIN_MEMBER_SRV; break; case ROLE_DOMAIN_BDC: + basic->netbios_ptr = 1; + netbios_domain = get_global_sam_name(); basic->machine_role = DSROLE_BDC; - basic->flags = DSROLE_PRIMARY_DS_RUNNING|DSROLE_PRIMARY_DS_MIXED_MODE; - if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) ) - basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT; break; case ROLE_DOMAIN_PDC: + basic->netbios_ptr = 1; + netbios_domain = get_global_sam_name(); basic->machine_role = DSROLE_PDC; - basic->flags = DSROLE_PRIMARY_DS_RUNNING|DSROLE_PRIMARY_DS_MIXED_MODE; - if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) ) - basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT; break; } - basic->unknown = 0x6173; /* seen on the wire; maybe padding */ - /* always set netbios name */ - basic->netbios_ptr = 1; - netbios_domain = get_global_sam_name(); - init_unistr2( &basic->netbios_domain, netbios_domain, UNI_FLAGS_NONE); + init_unistr2( &basic->netbios_domain, netbios_domain, UNI_STR_TERMINATE); - basic->dnsname_ptr = 1; - init_unistr2( &basic->dns_domain, dnsdomain, UNI_FLAGS_NONE); - basic->forestname_ptr = 1; - init_unistr2( &basic->forest_domain, dnsdomain, UNI_FLAGS_NONE); - + if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) ) + basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT; /* fill in some additional fields if we are a member of an AD domain */ - if ( lp_security() == SEC_ADS ) { - /* TODO */ - ;; + if ( lp_security() == SEC_ADS ) { + fstrcpy( dnsdomain, lp_realm() ); + strlower_m( dnsdomain ); + + basic->dnsname_ptr = 1; + init_unistr2( &basic->dns_domain, dnsdomain, UNI_STR_TERMINATE); + basic->forestname_ptr = 1; + init_unistr2( &basic->forest_domain, dnsdomain, UNI_STR_TERMINATE); + } else { + get_mydnsdomname(dnsdomain); + strlower_m(dnsdomain); + + basic->dnsname_ptr = 1; + init_unistr2( &basic->dns_domain, dnsdomain, UNI_FLAGS_NONE); + basic->forestname_ptr = 1; + init_unistr2( &basic->forest_domain, dnsdomain, UNI_FLAGS_NONE); } *info = basic; -- cgit From d1103534ba70cfda457165a2d80071e9b2bcd9c5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 7 Apr 2007 19:35:13 +0000 Subject: r22126: Fix a bogus uninitialized variable warning (This used to be commit 3be234effacd370dbdae11f6fcfddfe37d0623b3) --- source3/rpc_server/srv_lsa_ds_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_ds_nt.c b/source3/rpc_server/srv_lsa_ds_nt.c index 844a20eed4..f387bec9b6 100644 --- a/source3/rpc_server/srv_lsa_ds_nt.c +++ b/source3/rpc_server/srv_lsa_ds_nt.c @@ -36,7 +36,7 @@ static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN_INFO_BASIC **info) { DSROLE_PRIMARY_DOMAIN_INFO_BASIC *basic; - const char *netbios_domain; + const char *netbios_domain = ""; fstring dnsdomain; DEBUG(10,("fill_dsrole_dominfo_basic: enter\n")); -- cgit From 70806db06adb1dafd4de8728bb7b367b84f3740a Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Tue, 24 Apr 2007 15:56:02 +0000 Subject: r22504: Fix bug Jerry found during his tutorial. Sorry :-( Allows authorized users (e.g. BUILTIN\Administrators members) to set attributes on an account, particularly "user cannot change password". add become_root() around updating attributes, after checking that access has been granted. (This used to be commit b1ab360519a1f67f50446ca8599e5b7aa58e7db3) --- source3/rpc_server/srv_samr_nt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c743e68530..be73b33265 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -724,7 +724,12 @@ NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_ return NT_STATUS_ACCESS_DENIED; } - status = pdb_update_sam_account(sampass); + status = access_check_samr_function(acc_granted, SA_RIGHT_USER_SET_ATTRIBUTES, "_samr_set_sec_obj"); + if NT_STATUS_IS_OK(status) { + become_root(); + status = pdb_update_sam_account(sampass); + unbecome_root(); + } TALLOC_FREE(sampass); -- cgit From f4affb4382d4895589d0eceda765ae5bdc1df855 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Tue, 24 Apr 2007 18:01:46 +0000 Subject: r22505: Fix build (This used to be commit cc38ffb9a45b008ab7bbc3299610bd0dfec13aa9) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index be73b33265..a128757ad0 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -725,7 +725,7 @@ NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_ } status = access_check_samr_function(acc_granted, SA_RIGHT_USER_SET_ATTRIBUTES, "_samr_set_sec_obj"); - if NT_STATUS_IS_OK(status) { + if (NT_STATUS_IS_OK(status)) { become_root(); status = pdb_update_sam_account(sampass); unbecome_root(); -- cgit From 12ba88574bf91bdcc4447bfc3d429b799064bfd9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 27 Apr 2007 23:18:41 +0000 Subject: r22542: Move over to using the _strict varients of the talloc calls. No functional changes. Looks bigger than it is :-). Jeremy. (This used to be commit f6fa3080fee1b20df9f1968500840a88cf0ee592) --- source3/rpc_server/srv_echo_nt.c | 2 +- source3/rpc_server/srv_samr_nt.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 2 +- source3/rpc_server/srv_srvsvc_nt.c | 36 ++++++++++++++++++------------------ 4 files changed, 21 insertions(+), 21 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_echo_nt.c b/source3/rpc_server/srv_echo_nt.c index eb095f6bfe..58ab51e2b0 100644 --- a/source3/rpc_server/srv_echo_nt.c +++ b/source3/rpc_server/srv_echo_nt.c @@ -120,7 +120,7 @@ void _echo_TestEnum(pipes_struct *p, struct echo_TestEnum *r) void _echo_TestSurrounding(pipes_struct *p, struct echo_TestSurrounding *r) { r->out.data->x *= 2; - r->out.data->surrounding = talloc_zero_array(p->mem_ctx, uint16_t, r->in.data->x); + r->out.data->surrounding = TALLOC_ZERO_ARRAY(p->mem_ctx, uint16_t, r->in.data->x); } uint16 _echo_TestDoublePointer(pipes_struct *p, struct echo_TestDoublePointer *r) diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a128757ad0..80b1b93a50 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -854,7 +854,7 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_entries); if (sam == NULL || uni_name == NULL) { - DEBUG(0, ("make_user_sam_entry_list: talloc_zero failed!\n")); + DEBUG(0, ("make_user_sam_entry_list: TALLOC_ZERO failed!\n")); return NT_STATUS_NO_MEMORY; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3e1c1a2408..beb3b5aef0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -9504,7 +9504,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ if ( data_len ) { if ( !(enum_values[i].data = (uint8 *)TALLOC_MEMDUP(p->mem_ctx, regval_data_p(val), data_len)) ) { - DEBUG(0,("talloc_memdup failed to allocate memory [data_len=%d] for data!\n", + DEBUG(0,("TALLOC_MEMDUP failed to allocate memory [data_len=%d] for data!\n", data_len )); result = WERR_NOMEM; goto done; diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 615f5e1b07..8f68bf36a1 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -544,61 +544,61 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, switch (info_level) { case 0: - if (!(ctr->ctr0 = talloc_zero( + if (!(ctr->ctr0 = TALLOC_ZERO_P( p->mem_ctx, struct srvsvc_NetShareCtr0))) { goto done; } break; case 1: - if (!(ctr->ctr1 = talloc_zero( + if (!(ctr->ctr1 = TALLOC_ZERO_P( p->mem_ctx, struct srvsvc_NetShareCtr1))) { goto done; } break; case 2: - if (!(ctr->ctr2 = talloc_zero( + if (!(ctr->ctr2 = TALLOC_ZERO_P( p->mem_ctx, struct srvsvc_NetShareCtr2))) { goto done; } break; case 501: - if (!(ctr->ctr501 = talloc_zero( + if (!(ctr->ctr501 = TALLOC_ZERO_P( p->mem_ctx, struct srvsvc_NetShareCtr501))) { goto done; } break; case 502: - if (!(ctr->ctr502 = talloc_zero( + if (!(ctr->ctr502 = TALLOC_ZERO_P( p->mem_ctx, struct srvsvc_NetShareCtr502))) { goto done; } break; case 1004: - if (!(ctr->ctr1004 = talloc_zero( + if (!(ctr->ctr1004 = TALLOC_ZERO_P( p->mem_ctx, struct srvsvc_NetShareCtr1004))) { goto done; } break; case 1005: - if (!(ctr->ctr1005 = talloc_zero( + if (!(ctr->ctr1005 = TALLOC_ZERO_P( p->mem_ctx, struct srvsvc_NetShareCtr1005))) { goto done; } break; case 1006: - if (!(ctr->ctr1006 = talloc_zero( + if (!(ctr->ctr1006 = TALLOC_ZERO_P( p->mem_ctx, struct srvsvc_NetShareCtr1006))) { goto done; } break; case 1007: - if (!(ctr->ctr1007 = talloc_zero( + if (!(ctr->ctr1007 = TALLOC_ZERO_P( p->mem_ctx, struct srvsvc_NetShareCtr1007))) { goto done; } break; case 1501: - if (!(ctr->ctr1501 = talloc_zero( + if (!(ctr->ctr1501 = TALLOC_ZERO_P( p->mem_ctx, struct srvsvc_NetShareCtr1501))) { goto done; } @@ -781,7 +781,7 @@ static void init_srv_sess_info_0(pipes_struct *p, struct srvsvc_NetSessCtr0 *ss0 DEBUG(5,("init_srv_sess_0_ss0\n")); - ss0->array = talloc_array(p->mem_ctx, struct srvsvc_NetSessInfo0, *stot); + ss0->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetSessInfo0, *stot); if (snum) { for (; (*snum) < (*stot); (*snum)++) { @@ -861,7 +861,7 @@ static void init_srv_sess_info_1(pipes_struct *p, struct srvsvc_NetSessCtr1 *ss1 (*stot) = list_sessions(&session_list); - ss1->array = talloc_array(p->mem_ctx, struct srvsvc_NetSessInfo1, *stot); + ss1->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetSessInfo1, *stot); for (; (*snum) < (*stot); (*snum)++) { uint32 num_files; @@ -954,7 +954,7 @@ static void init_srv_conn_info_0(pipes_struct *p, struct srvsvc_NetConnCtr0 *ss0 DEBUG(5,("init_srv_conn_0_ss0\n")); if (snum) { - ss0->array = talloc_array(p->mem_ctx, struct srvsvc_NetConnInfo0, *stot); + ss0->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetConnInfo0, *stot); for (; (*snum) < (*stot); (*snum)++) { ss0->array[num_entries].conn_id = (*stot); @@ -996,7 +996,7 @@ static void init_srv_conn_info_1(pipes_struct *p, struct srvsvc_NetConnCtr1 *ss1 DEBUG(5,("init_srv_conn_1_ss1\n")); if (snum) { - ss1->array = talloc_array(p->mem_ctx, struct srvsvc_NetConnInfo1, *stot); + ss1->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetConnInfo1, *stot); for (; (*snum) < (*stot); (*snum)++) { ss1->array[num_entries].conn_id = (*stot); ss1->array[num_entries].conn_type = 0x3; @@ -1067,7 +1067,7 @@ static WERROR net_file_enum_3(pipes_struct *p, union srvsvc_NetFileCtr *ctr, uin (b) active pipes (c) open directories and files */ - ctr->ctr3 = talloc_zero(p->mem_ctx, struct srvsvc_NetFileCtr3); + ctr->ctr3 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetFileCtr3); status = net_enum_files( ctx, &ctr->ctr3->array, num_entries, resume_hnd ); if ( !W_ERROR_IS_OK(status)) @@ -1121,7 +1121,7 @@ WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, struct srvsvc_NetSrvGetInfo *r) here, as most of it is made up. */ case 102: - r->out.info->info102 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo102); + r->out.info->info102 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetSrvInfo102); r->out.info->info102->platform_id = 500; r->out.info->info102->version_major = lp_major_announce_version(); @@ -1138,7 +1138,7 @@ WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, struct srvsvc_NetSrvGetInfo *r) r->out.info->info102->comment = lp_serverstring(); break; case 101: - r->out.info->info101 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo101); + r->out.info->info101 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetSrvInfo101); r->out.info->info101->platform_id = 500; r->out.info->info101->server_name = global_myname(); r->out.info->info101->version_major = lp_major_announce_version(); @@ -1147,7 +1147,7 @@ WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, struct srvsvc_NetSrvGetInfo *r) r->out.info->info101->comment = lp_serverstring(); break; case 100: - r->out.info->info100 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo100); + r->out.info->info100 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetSrvInfo100); r->out.info->info100->platform_id = 500; r->out.info->info100->server_name = global_myname(); break; -- cgit From e26dee48f079f429690584aa2666f498e08e6810 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 28 Apr 2007 18:16:33 +0000 Subject: r22561: Fix a memleak in lanman.c: Nobody would free the session_list. Volker (This used to be commit 5d428400f77399b7fc30fb2a0fb10f0c74b96458) --- source3/rpc_server/srv_srvsvc_nt.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 8f68bf36a1..bdd8f68d51 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -769,13 +769,12 @@ static void init_srv_sess_info_0(pipes_struct *p, struct srvsvc_NetSessCtr0 *ss0 { struct sessionid *session_list; uint32 num_entries = 0; - (*stot) = list_sessions(&session_list); + (*stot) = list_sessions(p->mem_ctx, &session_list); if (ss0 == NULL) { if (snum) { (*snum) = 0; } - SAFE_FREE(session_list); return; } @@ -799,7 +798,6 @@ static void init_srv_sess_info_0(pipes_struct *p, struct srvsvc_NetSessCtr0 *ss0 ss0->array = NULL; ss0->count = 0; } - SAFE_FREE(session_list); } /******************************************************************* @@ -859,7 +857,7 @@ static void init_srv_sess_info_1(pipes_struct *p, struct srvsvc_NetSessCtr1 *ss1 return; } - (*stot) = list_sessions(&session_list); + (*stot) = list_sessions(p->mem_ctx, &session_list); ss1->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetSessInfo1, *stot); @@ -900,8 +898,6 @@ static void init_srv_sess_info_1(pipes_struct *p, struct srvsvc_NetSessCtr1 *ss1 if ((*snum) >= (*stot)) { (*snum) = 0; } - - SAFE_FREE(session_list); } /******************************************************************* @@ -1222,7 +1218,7 @@ WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r) memmove(machine, &machine[1], strlen(machine)); } - num_sessions = list_sessions(&session_list); + num_sessions = list_sessions(p->mem_ctx, &session_list); DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); @@ -1248,10 +1244,7 @@ WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r) DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); - done: - SAFE_FREE(session_list); - return status; } -- cgit From 71aa8a1ec2fe17761335381db5b38bd410147cac Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 29 Apr 2007 19:20:48 +0000 Subject: r22573: Fix old bug mixing free() and talloc_free() when the add_sid_to_array_XX code was moved from malloc to talloc. Found running valgrind and rpcclient. Needs merging for 3.0.25 final. Jeremy. (This used to be commit 8af56dbd00045049ea3c5022822bbaeeecbd9661) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 76ec38af6f..2343e3eedb 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1502,7 +1502,7 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU (*sids).ptr_sid[j] = 1; } - SAFE_FREE(sid_list); + talloc_free(sid_list); init_lsa_r_enum_accounts(r_u, num_entries); -- cgit From 08a730e2ef8df7325f59c288fca9c61b56454642 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 29 Apr 2007 19:54:26 +0000 Subject: r22574: Fix reply when we have no dfs shares. Jeremy. (This used to be commit f95bf093f9303131618b1de8f9b783ba19644bb3) --- source3/rpc_server/srv_dfs_nt.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 56c1ce00ab..d114a07994 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -211,11 +211,14 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *mem_ctx, struct junction_map* j, s dfs3->num_stores = j->referral_count; /* also enumerate the stores */ - dfs3->stores = TALLOC_ARRAY(mem_ctx, struct dfs_StorageInfo, j->referral_count); - if (!dfs3->stores) - return False; - - memset(dfs3->stores, '\0', j->referral_count * sizeof(struct dfs_StorageInfo)); + if (j->referral_count) { + dfs3->stores = TALLOC_ARRAY(mem_ctx, struct dfs_StorageInfo, j->referral_count); + if (!dfs3->stores) + return False; + memset(dfs3->stores, '\0', j->referral_count * sizeof(struct dfs_StorageInfo)); + } else { + dfs3->stores = NULL; + } for(ii=0;iireferral_count;ii++) { char* p; @@ -262,20 +265,32 @@ WERROR _dfs_Enum(pipes_struct *p, struct dfs_Enum *r) /* Create the return array */ switch (r->in.level) { case 1: - if ((r->out.info->e.info1->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info1, num_jn)) == NULL) { - return WERR_NOMEM; + if (num_jn) { + if ((r->out.info->e.info1->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info1, num_jn)) == NULL) { + return WERR_NOMEM; + } + } else { + r->out.info->e.info1->s = NULL; } r->out.info->e.info1->count = num_jn; break; case 2: - if ((r->out.info->e.info2->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info2, num_jn)) == NULL) { - return WERR_NOMEM; + if (num_jn) { + if ((r->out.info->e.info2->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info2, num_jn)) == NULL) { + return WERR_NOMEM; + } + } else { + r->out.info->e.info2->s = NULL; } r->out.info->e.info2->count = num_jn; break; case 3: - if ((r->out.info->e.info3->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info3, num_jn)) == NULL) { - return WERR_NOMEM; + if (num_jn) { + if ((r->out.info->e.info3->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info3, num_jn)) == NULL) { + return WERR_NOMEM; + } + } else { + r->out.info->e.info3->s = NULL; } r->out.info->e.info3->count = num_jn; break; @@ -301,7 +316,7 @@ WERROR _dfs_Enum(pipes_struct *p, struct dfs_Enum *r) return WERR_OK; } - + WERROR _dfs_GetInfo(pipes_struct *p, struct dfs_GetInfo *r) { int consumedcnt = sizeof(pstring); -- cgit From 6b605a9cd783451072e0bb9f63eb0e29d7969cd4 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 30 Apr 2007 00:53:17 +0000 Subject: r22586: Add a modified version of Simo's patch. Jeremy. (This used to be commit 18f47f999d28af56e205cd20d10c72ff6f0a3846) --- source3/rpc_server/srv_samr_nt.c | 41 +++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 80b1b93a50..8f7bfd6b01 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -949,6 +949,7 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, if (num_account == 0) { DEBUG(5, ("_samr_enum_dom_users: enumeration handle over " "total entries\n")); + init_samr_r_enum_dom_users(r_u, q_u->start_idx, 0); return NT_STATUS_OK; } @@ -1708,7 +1709,7 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK UNIHDR *hdr_name = NULL; UNISTR2 *uni_name = NULL; DOM_SID pol_sid; - int num_rids = q_u->num_rids1; + int num_rids = (int)q_u->num_rids1; uint32 acc_granted; int i; @@ -1726,12 +1727,18 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK return NT_STATUS_UNSUCCESSFUL; } - names = TALLOC_ZERO_ARRAY(p->mem_ctx, const char *, num_rids); - attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, enum lsa_SidType, num_rids); - wire_attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_rids); + if (num_rids) { + names = TALLOC_ZERO_ARRAY(p->mem_ctx, const char *, num_rids); + attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, enum lsa_SidType, num_rids); + wire_attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_rids); - if ((num_rids != 0) && ((names == NULL) || (attrs == NULL) || (wire_attrs==NULL))) - return NT_STATUS_NO_MEMORY; + if ((names == NULL) || (attrs == NULL) || (wire_attrs==NULL)) + return NT_STATUS_NO_MEMORY; + } else { + names = NULL; + attrs = NULL; + wire_attrs = NULL; + } become_root(); /* lookup_sid can require root privs */ r_u->status = pdb_lookup_rids(&pol_sid, num_rids, q_u->rid, @@ -3803,10 +3810,14 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, !sid_check_is_builtin(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - members = TALLOC_ARRAY(p->mem_ctx, DOM_SID, q_u->num_sids1); + if (q_u->num_sids1) { + members = TALLOC_ARRAY(p->mem_ctx, DOM_SID, q_u->num_sids1); - if (members == NULL) - return NT_STATUS_NO_MEMORY; + if (members == NULL) + return NT_STATUS_NO_MEMORY; + } else { + members = NULL; + } for (i=0; inum_sids1; i++) sid_copy(&members[i], &q_u->sid[i].sid); @@ -3864,10 +3875,14 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ return status; } - sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_sids); - if (num_sids!=0 && sid == NULL) { - SAFE_FREE(sids); - return NT_STATUS_NO_MEMORY; + if (num_sids) { + sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_sids); + if (sid == NULL) { + SAFE_FREE(sids); + return NT_STATUS_NO_MEMORY; + } + } else { + sid = NULL; } for (i = 0; i < num_sids; i++) { -- cgit From 1e362c0e7fff603cffa32863a5b07ecbc50f8a2d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 30 Apr 2007 01:17:34 +0000 Subject: r22587: Ensure TALLOC_ZERO_ARRAY is consistent. Jeremy. (This used to be commit c3df5d08dd6a983f9d53dc6628a50e571d322e8d) --- source3/rpc_server/srv_lsa_nt.c | 85 +++++++++++++++++++++++++++---------- source3/rpc_server/srv_samr_nt.c | 12 ++++-- source3/rpc_server/srv_spoolss_nt.c | 5 +-- 3 files changed, 72 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 2343e3eedb..a85f0548bf 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1066,7 +1066,18 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP } ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries); + if (!ref) { + return NT_STATUS_NO_MEMORY; + } + + if (num_entries) { + rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries); + if (!rids) { + return NT_STATUS_NO_MEMORY; + } + } else { + rids = NULL; + } if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { r_u->status = NT_STATUS_INVALID_HANDLE; @@ -1079,9 +1090,6 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP goto done; } - if (!ref || !rids) - return NT_STATUS_NO_MEMORY; - /* set up the LSA Lookup RIDs response */ become_root(); /* lookup_name can require root privs */ r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries, @@ -1128,14 +1136,23 @@ NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOO } ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries); - rids2 = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries); - - if ((ref == NULL) || (rids == NULL) || (rids2 == NULL)) { + if (ref == NULL) { r_u->status = NT_STATUS_NO_MEMORY; return NT_STATUS_NO_MEMORY; } + if (num_entries) { + rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries); + rids2 = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries); + if ((rids == NULL) || (rids2 == NULL)) { + r_u->status = NT_STATUS_NO_MEMORY; + return NT_STATUS_NO_MEMORY; + } + } else { + rids = NULL; + rids2 = NULL; + } + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { r_u->status = NT_STATUS_INVALID_HANDLE; goto done; @@ -1200,7 +1217,17 @@ NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOO } ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries); + if (ref == NULL) { + return NT_STATUS_NO_MEMORY; + } + if (num_entries) { + trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries); + if (!trans_sids) { + return NT_STATUS_NO_MEMORY; + } + } else { + trans_sids = NULL; + } if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { r_u->status = NT_STATUS_INVALID_HANDLE; @@ -1213,10 +1240,6 @@ NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOO goto done; } - if (!ref || !trans_sids) { - return NT_STATUS_NO_MEMORY; - } - /* set up the LSA Lookup SIDs response */ become_root(); /* lookup_name can require root privs */ r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries, @@ -1268,12 +1291,19 @@ NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOO } ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries); - - if (!ref || !trans_sids) { + if (!ref) { return NT_STATUS_NO_MEMORY; } + if (num_entries) { + trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries); + if (!trans_sids) { + return NT_STATUS_NO_MEMORY; + } + } else { + trans_sids = NULL; + } + /* set up the LSA Lookup SIDs response */ become_root(); /* lookup_name can require root privs */ r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries, @@ -1384,8 +1414,12 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - if ( !(entries = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_PRIV_ENTRY, num_privs )) ) - return NT_STATUS_NO_MEMORY; + if (num_privs) { + if ( !(entries = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_PRIV_ENTRY, num_privs )) ) + return NT_STATUS_NO_MEMORY; + } else { + entries = NULL; + } for (i = 0; i < num_privs; i++) { if( i < enum_context) { @@ -1489,12 +1523,17 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU if (q_u->enum_context >= num_entries) return NT_STATUS_NO_MORE_ENTRIES; - sids->ptr_sid = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_entries-q_u->enum_context); - sids->sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_entries-q_u->enum_context); + if (num_entries-q_u->enum_context) { + sids->ptr_sid = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_entries-q_u->enum_context); + sids->sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_entries-q_u->enum_context); - if (sids->ptr_sid==NULL || sids->sid==NULL) { - SAFE_FREE(sid_list); - return NT_STATUS_NO_MEMORY; + if (sids->ptr_sid==NULL || sids->sid==NULL) { + SAFE_FREE(sid_list); + return NT_STATUS_NO_MEMORY; + } + } else { + sids->ptr_sid = NULL; + sids->sid = NULL; } for (i = q_u->enum_context, j = 0; i < num_entries; i++, j++) { diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 8f7bfd6b01..1b9a8c375b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3939,10 +3939,14 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ if (!NT_STATUS_IS_OK(result)) return result; - attr=TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_members); - - if ((num_members!=0) && (attr==NULL)) - return NT_STATUS_NO_MEMORY; + if (num_members) { + attr=TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_members); + if (attr == NULL) { + return NT_STATUS_NO_MEMORY; + } + } else { + attr = NULL; + } for (i=0; i Date: Mon, 30 Apr 2007 01:34:28 +0000 Subject: r22588: Make all uses of TALLOC_MEMDUP consistent. Jeremy. (This used to be commit 8ad13718af0ba1fcb10a6f1631b1ed3cb8d11175) --- source3/rpc_server/srv_spoolss_nt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 08c3a46133..abe944322e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1416,11 +1416,15 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode) return NULL; } - d->dev_private = (uint8 *)TALLOC_MEMDUP(ctx, devmode->dev_private, + if (devmode->driverextra) { + d->dev_private = (uint8 *)TALLOC_MEMDUP(ctx, devmode->dev_private, devmode->driverextra); - if (!d->dev_private) { - return NULL; - } + if (!d->dev_private) { + return NULL; + } + } else { + d->dev_private = NULL; + } return d; } -- cgit From 879081236d634c6483ac17a563171ad30f3af53b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 30 Apr 2007 04:16:56 +0000 Subject: r22593: Finish doing the same for raw TALLOC. Jeremy. (This used to be commit aef3c262b724d1283187e732833519c4e6fb088c) --- source3/rpc_server/srv_spoolss_nt.c | 281 ++++++++++++++++++++++-------------- 1 file changed, 172 insertions(+), 109 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index abe944322e..5a19f2de20 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -723,15 +723,18 @@ static void notify_system_time(struct spoolss_notify_msg *msg, } data->notify_data.data.length = prs_offset(&ps); - data->notify_data.data.string = (uint16 *) - TALLOC(mem_ctx, prs_offset(&ps)); - if (!data->notify_data.data.string) { - prs_mem_free(&ps); - return; + if (prs_offset(&ps)) { + data->notify_data.data.string = (uint16 *) + TALLOC(mem_ctx, prs_offset(&ps)); + if (!data->notify_data.data.string) { + prs_mem_free(&ps); + return; + } + prs_copy_all_data_out((char *)data->notify_data.data.string, &ps); + } else { + data->notify_data.data.string = NULL; } - prs_copy_all_data_out((char *)data->notify_data.data.string, &ps); - prs_mem_free(&ps); } @@ -2708,14 +2711,17 @@ void spoolss_notify_server_name(int snum, len = rpcstr_push(temp, printer->info_2->servername, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } + if (len) { + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } - memcpy(data->notify_data.data.string, temp, len); + memcpy(data->notify_data.data.string, temp, len); + } else { + data->notify_data.data.string = NULL; + } } /******************************************************************* @@ -2743,14 +2749,16 @@ void spoolss_notify_printer_name(int snum, len = rpcstr_push(temp, p, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; + if (len) { + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + memcpy(data->notify_data.data.string, temp, len); + } else { + data->notify_data.data.string = NULL; } - - memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* @@ -2769,14 +2777,17 @@ void spoolss_notify_share_name(int snum, len = rpcstr_push(temp, lp_servicename(snum), sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; + if (len) { + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } + memcpy(data->notify_data.data.string, temp, len); + } else { + data->notify_data.data.string = NULL; } - memcpy(data->notify_data.data.string, temp, len); } /******************************************************************* @@ -2797,14 +2808,18 @@ void spoolss_notify_port_name(int snum, len = rpcstr_push(temp, printer->info_2->portname, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); + if (len) { + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } - memcpy(data->notify_data.data.string, temp, len); + memcpy(data->notify_data.data.string, temp, len); + } else { + data->notify_data.data.string = NULL; + } } /******************************************************************* @@ -2824,14 +2839,18 @@ void spoolss_notify_driver_name(int snum, len = rpcstr_push(temp, printer->info_2->drivername, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); + if (len) { + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } - memcpy(data->notify_data.data.string, temp, len); + memcpy(data->notify_data.data.string, temp, len); + } else { + data->notify_data.data.string = NULL; + } } /******************************************************************* @@ -2853,14 +2872,18 @@ void spoolss_notify_comment(int snum, len = rpcstr_push(temp, printer->info_2->comment, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); + if (len) { + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } - memcpy(data->notify_data.data.string, temp, len); + memcpy(data->notify_data.data.string, temp, len); + } else { + data->notify_data.data.string = NULL; + } } /******************************************************************* @@ -2880,14 +2903,18 @@ void spoolss_notify_location(int snum, len = rpcstr_push(temp, printer->info_2->location,sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); + if (len) { + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } - memcpy(data->notify_data.data.string, temp, len); + memcpy(data->notify_data.data.string, temp, len); + } else { + data->notify_data.data.string = NULL; + } } /******************************************************************* @@ -2922,14 +2949,18 @@ void spoolss_notify_sepfile(int snum, len = rpcstr_push(temp, printer->info_2->sepfile, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); + if (len) { + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } - memcpy(data->notify_data.data.string, temp, len); + memcpy(data->notify_data.data.string, temp, len); + } else { + data->notify_data.data.string = NULL; + } } /******************************************************************* @@ -2949,14 +2980,18 @@ void spoolss_notify_print_processor(int snum, len = rpcstr_push(temp, printer->info_2->printprocessor, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); + if (len) { + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } - memcpy(data->notify_data.data.string, temp, len); + memcpy(data->notify_data.data.string, temp, len); + } else { + data->notify_data.data.string = NULL; + } } /******************************************************************* @@ -2976,14 +3011,18 @@ void spoolss_notify_parameters(int snum, len = rpcstr_push(temp, printer->info_2->parameters, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); + if (len) { + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } - memcpy(data->notify_data.data.string, temp, len); + memcpy(data->notify_data.data.string, temp, len); + } else { + data->notify_data.data.string = NULL; + } } /******************************************************************* @@ -3003,14 +3042,18 @@ void spoolss_notify_datatype(int snum, len = rpcstr_push(temp, printer->info_2->datatype, sizeof(pstring)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); + if (len) { + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } - memcpy(data->notify_data.data.string, temp, len); + memcpy(data->notify_data.data.string, temp, len); + } else { + data->notify_data.data.string = NULL; + } } /******************************************************************* @@ -3163,14 +3206,18 @@ static void spoolss_notify_username(int snum, len = rpcstr_push(temp, queue->fs_user, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); + if (len) { + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } - memcpy(data->notify_data.data.string, temp, len); + memcpy(data->notify_data.data.string, temp, len); + } else { + data->notify_data.data.string = NULL; + } } /******************************************************************* @@ -3203,14 +3250,18 @@ static void spoolss_notify_job_name(int snum, len = rpcstr_push(temp, queue->fs_file, sizeof(temp)-2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); + if (len) { + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } - memcpy(data->notify_data.data.string, temp, len); + memcpy(data->notify_data.data.string, temp, len); + } else { + data->notify_data.data.string = NULL; + } } /******************************************************************* @@ -3253,14 +3304,18 @@ static void spoolss_notify_job_status_string(int snum, len = rpcstr_push(temp, p, sizeof(temp) - 2, STR_TERMINATE); data->notify_data.data.length = len; - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); + if (len) { + data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } + if (!data->notify_data.data.string) { + data->notify_data.data.length = 0; + return; + } - memcpy(data->notify_data.data.string, temp, len); + memcpy(data->notify_data.data.string, temp, len); + } else { + data->notify_data.data.string = NULL; + } } /******************************************************************* @@ -8119,14 +8174,18 @@ WERROR _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) - { - result = WERR_NOMEM; - goto done; + if (in_value_len) { + if((*out_value=(uint16 *)TALLOC_ZERO(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL) + { + result = WERR_NOMEM; + goto done; + } + *out_value_len = (uint32)rpcstr_push((char *)*out_value, "", in_value_len, 0); + } else { + *out_value=NULL; + *out_value_len = 0; } - *out_value_len = (uint32)rpcstr_push((char *)*out_value, "", in_value_len, 0); - /* the data is counted in bytes */ *out_max_data_len = in_data_len; @@ -8155,13 +8214,18 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S /* name */ *out_max_value_len=(in_value_len/sizeof(uint16)); - if ( (*out_value = (uint16 *)TALLOC_ZERO(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL ) - { - result = WERR_NOMEM; - goto done; - } + if (in_value_len) { + if ( (*out_value = (uint16 *)TALLOC_ZERO(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL ) + { + result = WERR_NOMEM; + goto done; + } - *out_value_len = (uint32)rpcstr_push((char *)*out_value, regval_name(val), (size_t)in_value_len, 0); + *out_value_len = (uint32)rpcstr_push((char *)*out_value, regval_name(val), (size_t)in_value_len, 0); + } else { + *out_value = NULL; + *out_value_len = 0; + } /* type */ @@ -8176,7 +8240,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S goto done; } data_len = regval_size(val); - if ( *data_out ) + if ( *data_out && data_len ) memcpy( *data_out, regval_data_p(val), data_len ); *out_data_len = data_len; } @@ -9117,10 +9181,9 @@ done: status = WERR_NOMEM; goto done; } - } - else { + } else { *data = NULL; - } + } } if ( printer ) -- cgit From f1d8c4da23049cf0115666f8d97dac251395de76 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 May 2007 22:01:26 +0000 Subject: r22675: Simo's patch for 0 size allocation. Still need to examine parse_misc.c fix. Jeremy. (This used to be commit 80d981265cd3bc9d73c5da3c514ec736e2dfa73a) --- source3/rpc_server/srv_lsa_nt.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index a85f0548bf..bde1ef81da 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -825,7 +825,11 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, *pp_mapped_count = 0; *pp_ref = NULL; *pp_names = NULL; - + + if (num_sids == 0) { + return NT_STATUS_OK; + } + names = TALLOC_ZERO_P(p->mem_ctx, LSA_TRANS_NAME_ENUM2); sids = TALLOC_ARRAY(p->mem_ctx, const DOM_SID *, num_sids); ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); @@ -845,12 +849,10 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, return status; } - if (num_sids > 0) { - names->name = TALLOC_ARRAY(names, LSA_TRANS_NAME2, num_sids); - names->uni_name = TALLOC_ARRAY(names, UNISTR2, num_sids); - if ((names->name == NULL) || (names->uni_name == NULL)) { - return NT_STATUS_NO_MEMORY; - } + names->name = TALLOC_ARRAY(names, LSA_TRANS_NAME2, num_sids); + names->uni_name = TALLOC_ARRAY(names, UNISTR2, num_sids); + if ((names->name == NULL) || (names->uni_name == NULL)) { + return NT_STATUS_NO_MEMORY; } for (i=0; i Date: Mon, 7 May 2007 09:35:35 +0000 Subject: r22736: Start to merge the low-hanging fruit from the now 7000-line cluster patch. This changes "struct process_id" to "struct server_id", keeping both is just too much hassle. No functional change (I hope ;-)) Volker (This used to be commit 0ad4b1226c9d91b72136310d3bbb640d2c5d67b8) --- source3/rpc_server/srv_spoolss_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5a19f2de20..7e46541b94 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1109,7 +1109,7 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, voi Receive a notify2 message list ********************************************************************/ -static void receive_notify2_message_list(int msg_type, struct process_id src, +static void receive_notify2_message_list(int msg_type, struct server_id src, void *msg, size_t len, void *private_data) { @@ -1223,7 +1223,7 @@ static BOOL srv_spoolss_drv_upgrade_printer(char* drivername) over all printers, upgrading ones as necessary **********************************************************************/ -void do_drv_upgrade_printer(int msg_type, struct process_id src, +void do_drv_upgrade_printer(int msg_type, struct server_id src, void *buf, size_t len, void *private_data) { fstring drivername; @@ -1321,7 +1321,7 @@ static BOOL srv_spoolss_reset_printerdata(char* drivername) over all printers, resetting printer data as neessary **********************************************************************/ -void reset_all_printerdata(int msg_type, struct process_id src, +void reset_all_printerdata(int msg_type, struct server_id src, void *buf, size_t len, void *private_data) { fstring drivername; -- cgit From 76ce309234adbe0a6a56b849a91714cab148c4a7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 7 May 2007 15:31:12 +0000 Subject: r22751: Next step for the cluster merge: sessionid.tdb should contain a 'struct server_id' instead of a 'uint32 pid' (This used to be commit be7bac55c37676a8137c59a22dfb2e4c4821ac21) --- source3/rpc_server/srv_srvsvc_nt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index bdd8f68d51..2365f7ece3 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -43,7 +43,7 @@ struct file_enum_count { }; struct sess_file_count { - pid_t pid; + struct server_id pid; uid_t uid; int count; }; @@ -809,7 +809,7 @@ static void sess_file_fn( const struct share_mode_entry *e, { struct sess_file_count *sess = (struct sess_file_count *)private_data; - if ( (procid_to_pid(&e->pid) == sess->pid) && (sess->uid == e->uid) ) { + if ( procid_equal(&e->pid, &sess->pid) && (sess->uid == e->uid) ) { sess->count++; } @@ -819,7 +819,7 @@ static void sess_file_fn( const struct share_mode_entry *e, /******************************************************************* ********************************************************************/ -static int net_count_files( uid_t uid, pid_t pid ) +static int net_count_files( uid_t uid, struct server_id pid ) { struct sess_file_count s_file_cnt; @@ -1237,7 +1237,7 @@ WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r) if ((strequal(session_list[snum].username, r->in.user) || r->in.user[0] == '\0' ) && strequal(session_list[snum].remote_machine, machine)) { - if (NT_STATUS_IS_OK(message_send_pid(pid_to_procid(session_list[snum].pid), MSG_SHUTDOWN, NULL, 0, False))) + if (NT_STATUS_IS_OK(message_send_pid(session_list[snum].pid, MSG_SHUTDOWN, NULL, 0, False))) status = WERR_OK; } } -- cgit From 4aa44f7475e03dcc596f6a13fffffda7268074a1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 8 May 2007 13:44:36 +0000 Subject: r22761: This introduces lib/conn_tdb.c with two main functions: connections_traverse and connections_forall. This centralizes all the routines that did individual tdb_open("connections.tdb") and direct tdb_traverse. Volker (This used to be commit e43e94cda1ad8876b3cb5d1129080b57fa6ec214) --- source3/rpc_server/srv_netlog_nt.c | 16 +--------------- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- source3/rpc_server/srv_srvsvc_nt.c | 21 ++++++++------------- 3 files changed, 11 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 0c12cb3b7c..e110f39289 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -75,22 +75,8 @@ Send a message to smbd to do a sam synchronisation static void send_sync_message(void) { - TDB_CONTEXT *tdb; - - tdb = tdb_open_log(lock_path("connections.tdb"), 0, - TDB_DEFAULT, O_RDONLY, 0); - - if (!tdb) { - DEBUG(3, ("send_sync_message(): failed to open connections " - "database\n")); - return; - } - DEBUG(3, ("sending sam synchronisation message\n")); - - message_send_all(tdb, MSG_SMB_SAM_SYNC, NULL, 0, False, NULL); - - tdb_close(tdb); + message_send_all(MSG_SMB_SAM_SYNC, NULL, 0, False, NULL); } /************************************************************************* diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7e46541b94..a4edeb2cfd 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -311,7 +311,7 @@ WERROR delete_printer_hook( NT_USER_TOKEN *token, const char *sharename ) if ( (ret = smbrun(command, NULL)) == 0 ) { /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + message_send_all(MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); } if ( is_print_op ) @@ -6253,7 +6253,7 @@ BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) if ( (ret = smbrun(command, &fd)) == 0 ) { /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + message_send_all(MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); } if ( is_print_op ) diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 2365f7ece3..59e86e4912 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -104,27 +104,22 @@ static WERROR net_enum_pipes( TALLOC_CTX *ctx, struct srvsvc_NetFileInfo3 **info uint32 *count, uint32 *resume ) { struct file_enum_count fenum; - TDB_CONTEXT *conn_tdb = conn_tdb_ctx(); - if ( !conn_tdb ) { - DEBUG(0,("net_enum_pipes: Failed to retrieve the connections tdb handle!\n")); - return WERR_ACCESS_DENIED; - } - fenum.ctx = ctx; fenum.info = *info; fenum.count = *count; - if (tdb_traverse(conn_tdb, pipe_enum_fn, &fenum) == -1) { - DEBUG(0,("net_enum_pipes: traverse of connections.tdb failed with error %s.\n", - tdb_errorstr(conn_tdb) )); + if (connections_traverse(pipe_enum_fn, &fenum) == -1) { + DEBUG(0,("net_enum_pipes: traverse of connections.tdb " + "failed\n")); return WERR_NOMEM; } *info = fenum.info; *count = fenum.count; - return WERR_OK;} + return WERR_OK; +} /******************************************************************* ********************************************************************/ @@ -1421,7 +1416,7 @@ static WERROR add_share(const char *share_name, const char *path, if ( (ret = smbrun(command, NULL)) == 0 ) { /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, + message_send_all(MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); } @@ -1517,7 +1512,7 @@ static WERROR delete_share(const char *sharename, if ( (ret = smbrun(command, NULL)) == 0 ) { /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, + message_send_all(MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); } @@ -1575,7 +1570,7 @@ static WERROR change_share(const char *share_name, const char *path, if ( (ret = smbrun(command, NULL)) == 0 ) { /* Tell everyone we updated smb.conf. */ - message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, + message_send_all(MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); } -- cgit From 16ae8eff937c1344192a3afa84ff1eb14de5d46d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 9 May 2007 11:39:55 +0000 Subject: r22766: Merge from 3_0: r22412 | obnox | 2007-04-20 14:23:36 +0200 (Fr, 20 Apr 2007) | 5 lines Add a "deletelocalgroup" subcommand to net sam. Thanks to Karolin Seeger . (This used to be commit fb6ac8a5b247a961963a9b6a95cd6608c5b53d09) --- source3/rpc_server/srv_samr_nt.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1b9a8c375b..b392f289a8 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1354,7 +1354,7 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM DOM_SID sid; struct acct_info info; uint32 acc_granted; - BOOL ret; + NTSTATUS status; r_u->status = NT_STATUS_OK; @@ -1368,11 +1368,11 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM } become_root(); - ret = pdb_get_aliasinfo(&sid, &info); + status = pdb_get_aliasinfo(&sid, &info); unbecome_root(); - if ( !ret ) - return NT_STATUS_NO_SUCH_ALIAS; + if ( !NT_STATUS_IS_OK(status)) + return status; if ( !(r_u->ctr = TALLOC_ZERO_P( p->mem_ctx, ALIAS_INFO_CTR )) ) return NT_STATUS_NO_MEMORY; @@ -4301,7 +4301,7 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S uint32 acc_granted; SE_PRIV se_rights; BOOL can_add_accounts; - BOOL ret; + NTSTATUS status; DISP_INFO *disp_info = NULL; DEBUG(5, ("_samr_delete_dom_alias: %d\n", __LINE__)); @@ -4340,15 +4340,15 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S become_root(); /* Have passdb delete the alias */ - ret = pdb_delete_alias(&alias_sid); + status = pdb_delete_alias(&alias_sid); if ( can_add_accounts ) unbecome_root(); /******** END SeAddUsers BLOCK *********/ - if ( !ret ) - return NT_STATUS_ACCESS_DENIED; + if ( !NT_STATUS_IS_OK(status)) + return status; if (!close_policy_hnd(p, &q_u->alias_pol)) return NT_STATUS_OBJECT_NAME_INVALID; @@ -4693,8 +4693,8 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ struct acct_info info; ALIAS_INFO_CTR *ctr; uint32 acc_granted; - BOOL ret; BOOL can_mod_accounts; + NTSTATUS status; DISP_INFO *disp_info = NULL; if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid, &acc_granted, &disp_info)) @@ -4709,18 +4709,16 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ /* get the current group information */ become_root(); - ret = pdb_get_aliasinfo( &group_sid, &info ); + status = pdb_get_aliasinfo( &group_sid, &info ); unbecome_root(); - if ( !ret ) { - return NT_STATUS_NO_SUCH_ALIAS; - } + if ( !NT_STATUS_IS_OK(status)) + return status; switch (ctr->level) { case 2: { fstring group_name, acct_name; - NTSTATUS status; /* We currently do not support renaming groups in the the BUILTIN domain. Refer to util_builtin.c to understand @@ -4776,18 +4774,17 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ if ( can_mod_accounts ) become_root(); - ret = pdb_set_aliasinfo( &group_sid, &info ); + status = pdb_set_aliasinfo( &group_sid, &info ); if ( can_mod_accounts ) unbecome_root(); /******** End SeAddUsers BLOCK *********/ - if (ret) { + if (NT_STATUS_IS_OK(status)) force_flush_samr_cache(disp_info); - } - return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; + return status; } /********************************************************************* -- cgit From a0f9db7a169886914b4e5323c61e127011a2d16b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 9 May 2007 11:40:48 +0000 Subject: r22767: Argl. Typed in 'svn ci' in the wrong branch. Revert. (This used to be commit 2c5b951eba509e826a29775db992aca474476484) --- source3/rpc_server/srv_samr_nt.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b392f289a8..1b9a8c375b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1354,7 +1354,7 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM DOM_SID sid; struct acct_info info; uint32 acc_granted; - NTSTATUS status; + BOOL ret; r_u->status = NT_STATUS_OK; @@ -1368,11 +1368,11 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM } become_root(); - status = pdb_get_aliasinfo(&sid, &info); + ret = pdb_get_aliasinfo(&sid, &info); unbecome_root(); - if ( !NT_STATUS_IS_OK(status)) - return status; + if ( !ret ) + return NT_STATUS_NO_SUCH_ALIAS; if ( !(r_u->ctr = TALLOC_ZERO_P( p->mem_ctx, ALIAS_INFO_CTR )) ) return NT_STATUS_NO_MEMORY; @@ -4301,7 +4301,7 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S uint32 acc_granted; SE_PRIV se_rights; BOOL can_add_accounts; - NTSTATUS status; + BOOL ret; DISP_INFO *disp_info = NULL; DEBUG(5, ("_samr_delete_dom_alias: %d\n", __LINE__)); @@ -4340,15 +4340,15 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S become_root(); /* Have passdb delete the alias */ - status = pdb_delete_alias(&alias_sid); + ret = pdb_delete_alias(&alias_sid); if ( can_add_accounts ) unbecome_root(); /******** END SeAddUsers BLOCK *********/ - if ( !NT_STATUS_IS_OK(status)) - return status; + if ( !ret ) + return NT_STATUS_ACCESS_DENIED; if (!close_policy_hnd(p, &q_u->alias_pol)) return NT_STATUS_OBJECT_NAME_INVALID; @@ -4693,8 +4693,8 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ struct acct_info info; ALIAS_INFO_CTR *ctr; uint32 acc_granted; + BOOL ret; BOOL can_mod_accounts; - NTSTATUS status; DISP_INFO *disp_info = NULL; if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid, &acc_granted, &disp_info)) @@ -4709,16 +4709,18 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ /* get the current group information */ become_root(); - status = pdb_get_aliasinfo( &group_sid, &info ); + ret = pdb_get_aliasinfo( &group_sid, &info ); unbecome_root(); - if ( !NT_STATUS_IS_OK(status)) - return status; + if ( !ret ) { + return NT_STATUS_NO_SUCH_ALIAS; + } switch (ctr->level) { case 2: { fstring group_name, acct_name; + NTSTATUS status; /* We currently do not support renaming groups in the the BUILTIN domain. Refer to util_builtin.c to understand @@ -4774,17 +4776,18 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ if ( can_mod_accounts ) become_root(); - status = pdb_set_aliasinfo( &group_sid, &info ); + ret = pdb_set_aliasinfo( &group_sid, &info ); if ( can_mod_accounts ) unbecome_root(); /******** End SeAddUsers BLOCK *********/ - if (NT_STATUS_IS_OK(status)) + if (ret) { force_flush_samr_cache(disp_info); + } - return status; + return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; } /********************************************************************* -- cgit From 9e30a76c04d0da0bc14f7a0605db7ad51e5cfcd9 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 11 May 2007 08:46:54 +0000 Subject: r22786: Some cleanup by Karolin Seeger: Remove unused pdb_find_alias, and change return values of some alias-releated pdb functions from BOOL to NTSTATUS Thanks :-) (This used to be commit 590d2164b3a33250410338771e160f6ebd1aa89d) --- source3/rpc_server/srv_samr_nt.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1b9a8c375b..b392f289a8 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1354,7 +1354,7 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM DOM_SID sid; struct acct_info info; uint32 acc_granted; - BOOL ret; + NTSTATUS status; r_u->status = NT_STATUS_OK; @@ -1368,11 +1368,11 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM } become_root(); - ret = pdb_get_aliasinfo(&sid, &info); + status = pdb_get_aliasinfo(&sid, &info); unbecome_root(); - if ( !ret ) - return NT_STATUS_NO_SUCH_ALIAS; + if ( !NT_STATUS_IS_OK(status)) + return status; if ( !(r_u->ctr = TALLOC_ZERO_P( p->mem_ctx, ALIAS_INFO_CTR )) ) return NT_STATUS_NO_MEMORY; @@ -4301,7 +4301,7 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S uint32 acc_granted; SE_PRIV se_rights; BOOL can_add_accounts; - BOOL ret; + NTSTATUS status; DISP_INFO *disp_info = NULL; DEBUG(5, ("_samr_delete_dom_alias: %d\n", __LINE__)); @@ -4340,15 +4340,15 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S become_root(); /* Have passdb delete the alias */ - ret = pdb_delete_alias(&alias_sid); + status = pdb_delete_alias(&alias_sid); if ( can_add_accounts ) unbecome_root(); /******** END SeAddUsers BLOCK *********/ - if ( !ret ) - return NT_STATUS_ACCESS_DENIED; + if ( !NT_STATUS_IS_OK(status)) + return status; if (!close_policy_hnd(p, &q_u->alias_pol)) return NT_STATUS_OBJECT_NAME_INVALID; @@ -4693,8 +4693,8 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ struct acct_info info; ALIAS_INFO_CTR *ctr; uint32 acc_granted; - BOOL ret; BOOL can_mod_accounts; + NTSTATUS status; DISP_INFO *disp_info = NULL; if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid, &acc_granted, &disp_info)) @@ -4709,18 +4709,16 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ /* get the current group information */ become_root(); - ret = pdb_get_aliasinfo( &group_sid, &info ); + status = pdb_get_aliasinfo( &group_sid, &info ); unbecome_root(); - if ( !ret ) { - return NT_STATUS_NO_SUCH_ALIAS; - } + if ( !NT_STATUS_IS_OK(status)) + return status; switch (ctr->level) { case 2: { fstring group_name, acct_name; - NTSTATUS status; /* We currently do not support renaming groups in the the BUILTIN domain. Refer to util_builtin.c to understand @@ -4776,18 +4774,17 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ if ( can_mod_accounts ) become_root(); - ret = pdb_set_aliasinfo( &group_sid, &info ); + status = pdb_set_aliasinfo( &group_sid, &info ); if ( can_mod_accounts ) unbecome_root(); /******** End SeAddUsers BLOCK *********/ - if (ret) { + if (NT_STATUS_IS_OK(status)) force_flush_samr_cache(disp_info); - } - return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; + return status; } /********************************************************************* -- cgit From b4a7b7a8889737e2891fc1176feabd4ce47f2737 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 14 May 2007 12:16:20 +0000 Subject: r22844: Introduce const DATA_BLOB data_blob_null = { NULL, 0, NULL }; and replace all data_blob(NULL, 0) calls. (This used to be commit 3d3d61687ef00181f4f04e001d42181d93ac931e) --- source3/rpc_server/srv_srvsvc_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 59e86e4912..d0f2aa500f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2048,7 +2048,7 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecur /* Null password is ok - we are already an authenticated user... */ - null_pw = data_blob(NULL, 0); + null_pw = data_blob_null; become_root(); conn = make_connection(r->in.share, null_pw, "A:", p->pipe_user.vuid, &nt_status); @@ -2153,7 +2153,7 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecur ZERO_STRUCT(st); /* Null password is ok - we are already an authenticated user... */ - null_pw = data_blob(NULL, 0); + null_pw = data_blob_null; become_root(); conn = make_connection(r->in.share, null_pw, "A:", p->pipe_user.vuid, &nt_status); -- cgit From fb99bbe67597555109ebd65613a5aab395b43499 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 15 May 2007 10:50:44 +0000 Subject: r22895: Convert some more calls from message_send_buf to messaging_send_buf (This used to be commit c8b98273406242a89a7e5d1fb5d79120ebe5822a) --- source3/rpc_server/srv_spoolss_nt.c | 10 ++++++---- source3/rpc_server/srv_srvsvc_nt.c | 7 ++++++- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a4edeb2cfd..cbc44a224a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1212,8 +1212,9 @@ static BOOL srv_spoolss_drv_upgrade_printer(char* drivername) DEBUG(10,("srv_spoolss_drv_upgrade_printer: Sending message about driver upgrade [%s]\n", drivername)); - message_send_pid(pid_to_procid(sys_getpid()), - MSG_PRINTER_DRVUPGRADE, drivername, len+1, False); + messaging_send_buf(smbd_messaging_context(), procid_self(), + MSG_PRINTER_DRVUPGRADE, + (uint8 *)drivername, len+1); return True; } @@ -1310,8 +1311,9 @@ static BOOL srv_spoolss_reset_printerdata(char* drivername) DEBUG(10,("srv_spoolss_reset_printerdata: Sending message about resetting printerdata [%s]\n", drivername)); - message_send_pid(pid_to_procid(sys_getpid()), - MSG_PRINTERDATA_INIT_RESET, drivername, len+1, False); + messaging_send_buf(smbd_messaging_context(), procid_self(), + MSG_PRINTERDATA_INIT_RESET, + (uint8 *)drivername, len+1); return True; } diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index d0f2aa500f..bb60f57a14 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1231,8 +1231,13 @@ WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r) if ((strequal(session_list[snum].username, r->in.user) || r->in.user[0] == '\0' ) && strequal(session_list[snum].remote_machine, machine)) { + NTSTATUS ntstat; + + ntstat = messaging_send(smbd_messaging_context(), + session_list[snum].pid, + MSG_SHUTDOWN, &data_blob_null); - if (NT_STATUS_IS_OK(message_send_pid(session_list[snum].pid, MSG_SHUTDOWN, NULL, 0, False))) + if (NT_STATUS_IS_OK(ntstat)) status = WERR_OK; } } -- cgit From 8c3f8e5697f29f1a9829298e0561ff7305b62082 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 15 May 2007 15:49:55 +0000 Subject: r22911: Pass a messaging_context to message_send_all (This used to be commit cc92ce665dcfe9054d09429219883b18a4cab090) --- source3/rpc_server/srv_netlog_nt.c | 3 ++- source3/rpc_server/srv_spoolss_nt.c | 6 ++++-- source3/rpc_server/srv_srvsvc_nt.c | 9 ++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index e110f39289..4dd04c0288 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -76,7 +76,8 @@ Send a message to smbd to do a sam synchronisation static void send_sync_message(void) { DEBUG(3, ("sending sam synchronisation message\n")); - message_send_all(MSG_SMB_SAM_SYNC, NULL, 0, False, NULL); + message_send_all(smbd_messaging_context(), MSG_SMB_SAM_SYNC, NULL, 0, + False, NULL); } /************************************************************************* diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cbc44a224a..e2dd773c04 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -311,7 +311,8 @@ WERROR delete_printer_hook( NT_USER_TOKEN *token, const char *sharename ) if ( (ret = smbrun(command, NULL)) == 0 ) { /* Tell everyone we updated smb.conf. */ - message_send_all(MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + message_send_all(smbd_messaging_context(), + MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); } if ( is_print_op ) @@ -6255,7 +6256,8 @@ BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) if ( (ret = smbrun(command, &fd)) == 0 ) { /* Tell everyone we updated smb.conf. */ - message_send_all(MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + message_send_all(smbd_messaging_context(), + MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); } if ( is_print_op ) diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index bb60f57a14..cf3268d44d 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1421,7 +1421,8 @@ static WERROR add_share(const char *share_name, const char *path, if ( (ret = smbrun(command, NULL)) == 0 ) { /* Tell everyone we updated smb.conf. */ - message_send_all(MSG_SMB_CONF_UPDATED, + message_send_all(smbd_messaging_context(), + MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); } @@ -1517,7 +1518,8 @@ static WERROR delete_share(const char *sharename, if ( (ret = smbrun(command, NULL)) == 0 ) { /* Tell everyone we updated smb.conf. */ - message_send_all(MSG_SMB_CONF_UPDATED, + message_send_all(smbd_messaging_context(), + MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); } @@ -1575,7 +1577,8 @@ static WERROR change_share(const char *share_name, const char *path, if ( (ret = smbrun(command, NULL)) == 0 ) { /* Tell everyone we updated smb.conf. */ - message_send_all(MSG_SMB_CONF_UPDATED, + message_send_all(smbd_messaging_context(), + MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); } -- cgit From e95942ed84fef4dd34c380d59145d3e182b01702 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 16 May 2007 20:56:39 +0000 Subject: r22954: More messaging_register (This used to be commit 9b8df24107ffe3016031e5257c5680689f061886) --- source3/rpc_server/srv_spoolss_nt.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index e2dd773c04..49782dca43 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1225,15 +1225,19 @@ static BOOL srv_spoolss_drv_upgrade_printer(char* drivername) over all printers, upgrading ones as necessary **********************************************************************/ -void do_drv_upgrade_printer(int msg_type, struct server_id src, - void *buf, size_t len, void *private_data) +void do_drv_upgrade_printer(struct messaging_context *msg, + void *private_data, + uint32_t msg_type, + struct server_id server_id, + DATA_BLOB *data) { fstring drivername; int snum; int n_services = lp_numservices(); + size_t len; - len = MIN(len,sizeof(drivername)-1); - strncpy(drivername, (const char *)buf, len); + len = MIN(data->length,sizeof(drivername)-1); + strncpy(drivername, (const char *)data->data, len); DEBUG(10,("do_drv_upgrade_printer: Got message for new driver [%s]\n", drivername )); @@ -1324,15 +1328,19 @@ static BOOL srv_spoolss_reset_printerdata(char* drivername) over all printers, resetting printer data as neessary **********************************************************************/ -void reset_all_printerdata(int msg_type, struct server_id src, - void *buf, size_t len, void *private_data) +void reset_all_printerdata(struct messaging_context *msg, + void *private_data, + uint32_t msg_type, + struct server_id server_id, + DATA_BLOB *data) { fstring drivername; int snum; int n_services = lp_numservices(); + size_t len; - len = MIN( len, sizeof(drivername)-1 ); - strncpy( drivername, (const char *)buf, len ); + len = MIN( data->length, sizeof(drivername)-1 ); + strncpy( drivername, (const char *)data->data, len ); DEBUG(10,("reset_all_printerdata: Got message for new driver [%s]\n", drivername )); -- cgit From 4a50c674629c6ee0f01ab16aa1561c5acc17c5e2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 17 May 2007 19:16:27 +0000 Subject: r22975: BUG 4616: Don't return a dns or forest name when replying to the DsDGetPrimaryRoleInfo() and configured for security = domain. (This used to be commit 55ba4a04d0efe2ae7b0d945648b2db801ff9e9f1) --- source3/rpc_server/srv_lsa_ds_nt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_ds_nt.c b/source3/rpc_server/srv_lsa_ds_nt.c index f387bec9b6..17543a38ef 100644 --- a/source3/rpc_server/srv_lsa_ds_nt.c +++ b/source3/rpc_server/srv_lsa_ds_nt.c @@ -84,16 +84,16 @@ static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN basic->dnsname_ptr = 1; init_unistr2( &basic->dns_domain, dnsdomain, UNI_STR_TERMINATE); + + /* FIXME!! We really should fill in the correct forest + name. Should get this information from winbindd. */ basic->forestname_ptr = 1; init_unistr2( &basic->forest_domain, dnsdomain, UNI_STR_TERMINATE); } else { - get_mydnsdomname(dnsdomain); - strlower_m(dnsdomain); - - basic->dnsname_ptr = 1; - init_unistr2( &basic->dns_domain, dnsdomain, UNI_FLAGS_NONE); - basic->forestname_ptr = 1; - init_unistr2( &basic->forest_domain, dnsdomain, UNI_FLAGS_NONE); + /* security = domain should not fill in the dns or + forest name */ + basic->dnsname_ptr = 0; + basic->forestname_ptr = 0; } *info = basic; -- cgit From 4d5f58c2b945e7a2263ba42749f73c7ba72ab3c7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 May 2007 21:53:28 +0000 Subject: r23015: Make message_(de)register static to messages.c (This used to be commit a8082a3c7c3d1e68c27fc3bf42f3d44402cc6f9f) --- source3/rpc_server/srv_spoolss_nt.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 49782dca43..890d2e0885 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -166,7 +166,8 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle) cli_shutdown( notify_cli_pipe->cli ); notify_cli_pipe = NULL; /* The above call shuts downn the pipe also. */ - message_deregister(MSG_PRINTER_NOTIFY2); + messaging_deregister(smbd_messaging_context(), + MSG_PRINTER_NOTIFY2, NULL); /* Tell the connections db we're no longer interested in * printer notify messages. */ @@ -1110,19 +1111,21 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, voi Receive a notify2 message list ********************************************************************/ -static void receive_notify2_message_list(int msg_type, struct server_id src, - void *msg, size_t len, - void *private_data) +static void receive_notify2_message_list(struct messaging_context *msg, + void *private_data, + uint32_t msg_type, + struct server_id server_id, + DATA_BLOB *data) { size_t msg_count, i; - char *buf = (char *)msg; + char *buf = (char *)data->data; char *msg_ptr; size_t msg_len; SPOOLSS_NOTIFY_MSG notify; SPOOLSS_NOTIFY_MSG_CTR messages; int num_groups; - if (len < 4) { + if (data->length < 4) { DEBUG(0,("receive_notify2_message_list: bad message format (len < 4)!\n")); return; } @@ -1152,7 +1155,7 @@ static void receive_notify2_message_list(int msg_type, struct server_id src, for ( i=0; i len) { + if (msg_ptr + 4 - buf > data->length) { DEBUG(0,("receive_notify2_message_list: bad message format (len > buf_size) !\n")); return; } @@ -1160,7 +1163,7 @@ static void receive_notify2_message_list(int msg_type, struct server_id src, msg_len = IVAL(msg_ptr,0); msg_ptr += 4; - if (msg_ptr + msg_len - buf > len) { + if (msg_ptr + msg_len - buf > data->length) { DEBUG(0,("receive_notify2_message_list: bad message format (bad len) !\n")); return; } @@ -2616,8 +2619,9 @@ static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, if ( !spoolss_connect_to_client( ¬ify_cli_pipe, client_ip, unix_printer )) return False; - message_register(MSG_PRINTER_NOTIFY2, - receive_notify2_message_list, NULL); + messaging_register(smbd_messaging_context(), NULL, + MSG_PRINTER_NOTIFY2, + receive_notify2_message_list); /* Tell the connections db we're now interested in printer * notify messages. */ register_message_flags( True, FLAG_MSG_PRINT_NOTIFY ); -- cgit From ac3f08ddbe0b484375624db0e35999a8584b57f4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 May 2007 22:17:13 +0000 Subject: r23055: Rewrite messages.c to use auto-generated marshalling in the tdb. I'm doing this because for the clustering the marshalling is needed in more than one place, so I wanted a decent routine to marshall a message_rec struct which was not there before. Tridge, this seems about the same speed as it used to be before, the librpc/ndr overhead in my tests was under the noise. Volker (This used to be commit eaefd00563173dfabb7716c5695ac0a2f7139bb6) --- source3/rpc_server/srv_netlog_nt.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- source3/rpc_server/srv_srvsvc_nt.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 4dd04c0288..2bb872874b 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -77,7 +77,7 @@ static void send_sync_message(void) { DEBUG(3, ("sending sam synchronisation message\n")); message_send_all(smbd_messaging_context(), MSG_SMB_SAM_SYNC, NULL, 0, - False, NULL); + NULL); } /************************************************************************* diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 890d2e0885..2047e13df3 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -313,7 +313,7 @@ WERROR delete_printer_hook( NT_USER_TOKEN *token, const char *sharename ) if ( (ret = smbrun(command, NULL)) == 0 ) { /* Tell everyone we updated smb.conf. */ message_send_all(smbd_messaging_context(), - MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + MSG_SMB_CONF_UPDATED, NULL, 0, NULL); } if ( is_print_op ) @@ -6269,7 +6269,7 @@ BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) if ( (ret = smbrun(command, &fd)) == 0 ) { /* Tell everyone we updated smb.conf. */ message_send_all(smbd_messaging_context(), - MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL); + MSG_SMB_CONF_UPDATED, NULL, 0, NULL); } if ( is_print_op ) diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index cf3268d44d..df7cd06b67 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1423,7 +1423,7 @@ static WERROR add_share(const char *share_name, const char *path, /* Tell everyone we updated smb.conf. */ message_send_all(smbd_messaging_context(), MSG_SMB_CONF_UPDATED, - NULL, 0, False, NULL); + NULL, 0, NULL); } if ( is_disk_op ) @@ -1520,7 +1520,7 @@ static WERROR delete_share(const char *sharename, /* Tell everyone we updated smb.conf. */ message_send_all(smbd_messaging_context(), MSG_SMB_CONF_UPDATED, - NULL, 0, False, NULL); + NULL, 0, NULL); } if ( is_disk_op ) @@ -1579,7 +1579,7 @@ static WERROR change_share(const char *share_name, const char *path, /* Tell everyone we updated smb.conf. */ message_send_all(smbd_messaging_context(), MSG_SMB_CONF_UPDATED, - NULL, 0, False, NULL); + NULL, 0, NULL); } if ( is_disk_op ) -- cgit From 054bf2fc8bd8ac62e16ec04001c0a4a8409d0e1d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 28 May 2007 11:38:42 +0000 Subject: r23171: Convert connections.tdb to dbwrap (This used to be commit 80a1f43825063bbbda896175d99700ede5a4757a) --- source3/rpc_server/srv_srvsvc_nt.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index df7cd06b67..06c733fe49 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -52,15 +52,15 @@ struct sess_file_count { Count the entries belonging to a service in the connection db. ****************************************************************************/ -static int pipe_enum_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *p) +static int pipe_enum_fn( struct db_record *rec, void *p) { struct pipe_open_rec prec; struct file_enum_count *fenum = (struct file_enum_count *)p; - if (dbuf.dsize != sizeof(struct pipe_open_rec)) + if (rec->value.dsize != sizeof(struct pipe_open_rec)) return 0; - memcpy(&prec, dbuf.dptr, sizeof(struct pipe_open_rec)); + memcpy(&prec, rec->value.dptr, sizeof(struct pipe_open_rec)); if ( process_exists(prec.pid) ) { struct srvsvc_NetFileInfo3 *f; @@ -124,14 +124,12 @@ static WERROR net_enum_pipes( TALLOC_CTX *ctx, struct srvsvc_NetFileInfo3 **info /******************************************************************* ********************************************************************/ -/* global needed to make use of the share_mode_forall() callback */ -static struct file_enum_count f_enum_cnt; - static void enum_file_fn( const struct share_mode_entry *e, const char *sharepath, const char *fname, - void *dummy ) + void *private_data ) { - struct file_enum_count *fenum = &f_enum_cnt; + struct file_enum_count *fenum = + (struct file_enum_count *)&private_data; /* If the pid was not found delete the entry from connections.tdb */ @@ -199,11 +197,13 @@ static void enum_file_fn( const struct share_mode_entry *e, static WERROR net_enum_files( TALLOC_CTX *ctx, struct srvsvc_NetFileInfo3 **info, uint32 *count, uint32 *resume ) { + struct file_enum_count f_enum_cnt; + f_enum_cnt.ctx = ctx; f_enum_cnt.count = *count; f_enum_cnt.info = *info; - share_mode_forall( enum_file_fn, NULL ); + share_mode_forall( enum_file_fn, (void *)&f_enum_cnt ); *info = f_enum_cnt.info; *count = f_enum_cnt.count; -- cgit From e8156439f24137b5418baad20a7f00f6949cfe29 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 29 May 2007 09:30:34 +0000 Subject: r23183: Check in a change made by Tridge: This replaces the internal explicit dev/ino file id representation by a "struct file_id". This is necessary as cluster file systems and NFS don't necessarily assign the same device number to the shared file system. With this structure in place we can now easily add different schemes to map a file to a unique 64-bit device node. Jeremy, you might note that I did not change the external interface of smb_share_modes.c. Volker (This used to be commit 9b10dbbd5de8813fc15ebbb6be9b18010ffe8139) --- source3/rpc_server/srv_srvsvc_nt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 06c733fe49..7132f92c93 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -152,8 +152,7 @@ static void enum_file_fn( const struct share_mode_entry *e, /* need to count the number of locks on a file */ ZERO_STRUCT( fsp ); - fsp.dev = e->dev; - fsp.inode = e->inode; + fsp.file_id = e->id; if ( (brl = brl_get_locks_readonly(NULL,&fsp)) != NULL ) { num_locks = brl->num_locks; -- cgit From e6e577b845db9530aa95d696d9f4f7d31a2b4140 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 30 May 2007 21:43:48 +0000 Subject: r23248: Merge echo pipe implementation chanegs from SAMBA_3_0_26 just to stay in sink. This was more or less just for me to play with. (This used to be commit 6c4b85cce0f947771fd9aa93451c53adb1795e3f) --- source3/rpc_server/srv_echo_nt.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_echo_nt.c b/source3/rpc_server/srv_echo_nt.c index 58ab51e2b0..08d54ceba4 100644 --- a/source3/rpc_server/srv_echo_nt.c +++ b/source3/rpc_server/srv_echo_nt.c @@ -1,8 +1,9 @@ /* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines for rpcecho - * Copyright (C) Tim Potter 2003. - * Copyright (C) Jelmer Vernooij 2006. + * Copyright (C) Tim Potter 2003 + * Copyright (C) Jelmer Vernooij 2006 + * Copyright (C) Gerald (Jerry) Carter 2007 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,9 +32,9 @@ /* Add one to the input and return it */ -void _echo_AddOne(pipes_struct *p, struct echo_AddOne *r) +void _echo_AddOne(pipes_struct *p, struct echo_AddOne *r ) { - DEBUG(10, ("_echo_add_one\n")); + DEBUG(10, ("_echo_AddOne\n")); *r->out.out_data = r->in.in_data + 1; } @@ -42,18 +43,26 @@ void _echo_AddOne(pipes_struct *p, struct echo_AddOne *r) void _echo_EchoData(pipes_struct *p, struct echo_EchoData *r) { - DEBUG(10, ("_echo_data\n")); + DEBUG(10, ("_echo_EchoData\n")); - memcpy(r->out.out_data, r->in.in_data, r->in.len); + if ( r->in.len == 0 ) { + r->out.out_data = NULL; + return; + } + + r->out.out_data = TALLOC(p->mem_ctx, r->in.len); + memcpy( r->out.out_data, r->in.in_data, r->in.len ); + return; } /* Sink an array of data */ void _echo_SinkData(pipes_struct *p, struct echo_SinkData *r) { - DEBUG(10, ("_sink_data\n")); + DEBUG(10, ("_echo_SinkData\n")); /* My that was some yummy data! */ + return; } /* Source an array of data */ @@ -62,10 +71,20 @@ void _echo_SourceData(pipes_struct *p, struct echo_SourceData *r) { uint32 i; - DEBUG(10, ("_source_data\n")); + DEBUG(10, ("_echo_SourceData\n")); + + if ( r->in.len == 0 ) { + r->out.data = NULL; + return; + } + + r->out.data = TALLOC(p->mem_ctx, r->in.len ); - for (i = 0; i < r->in.len; i++) + for (i = 0; i < r->in.len; i++ ) { r->out.data[i] = i & 0xff; + } + + return; } void _echo_TestCall(pipes_struct *p, struct echo_TestCall *r) -- cgit From d99f4f004ca46e4c0f2e60a231a14708a128f0f2 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 31 May 2007 17:24:30 +0000 Subject: r23271: merge service control pidl change for CloseServiceHandle() from SAMBA_3_0_26 (This used to be commit 0b1bc3521fac52f3164b6cc9e053abc3ceabf5e7) --- source3/rpc_server/srv_svcctl.c | 45 ++++--- source3/rpc_server/srv_svcctl_nt.c | 265 ++++++++++++++++++++++++++++++++++++- 2 files changed, 287 insertions(+), 23 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 74ae3aaa16..e36df7ac93 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -1,7 +1,7 @@ /* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines - * Copyright (C) Gerald Carter 2005. + * Copyright (C) Gerald Carter 2005 - 2007 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,28 +23,30 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -/******************************************************************* - ********************************************************************/ - -static BOOL api_svcctl_close_service(pipes_struct *p) +static BOOL proxy_svcctl_call(pipes_struct *p, uint8 opnum) { - SVCCTL_Q_CLOSE_SERVICE q_u; - SVCCTL_R_CLOSE_SERVICE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; + struct api_struct *fns; + int n_fns; - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); + svcctl_get_pipe_fns(&fns, &n_fns); - if(!svcctl_io_q_close_service("", &q_u, data, 0)) + if (opnum >= n_fns) return False; - r_u.status = _svcctl_close_service(p, &q_u, &r_u); + if (fns[opnum].opnum != opnum) { + smb_panic("SVCCTL function table not sorted\n"); + } - if(!svcctl_io_r_close_service("", &r_u, rdata, 0)) - return False; + return fns[opnum].fn(p); +} - return True; + +/******************************************************************* + ********************************************************************/ + +static BOOL api_svcctl_close_service(pipes_struct *p) +{ + return proxy_svcctl_call( p, DCERPC_SVCCTL_CLOSESERVICEHANDLE ); } /******************************************************************* @@ -432,14 +434,15 @@ static struct api_struct api_svcctl_cmds[] = }; -void svcctl_get_pipe_fns( struct api_struct **fns, int *n_fns ) +void svcctl2_get_pipe_fns( struct api_struct **fns, int *n_fns ) { - *fns = api_svcctl_cmds; + *fns = api_svcctl_cmds; *n_fns = sizeof(api_svcctl_cmds) / sizeof(struct api_struct); } -NTSTATUS rpc_svcctl_init(void) +NTSTATUS rpc_svcctl2_init(void) { - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "svcctl", "ntsvcs", api_svcctl_cmds, - sizeof(api_svcctl_cmds) / sizeof(struct api_struct)); + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, + "svcctl", "ntsvcs", api_svcctl_cmds, + sizeof(api_svcctl_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 0b985f83dc..433abf06a8 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -318,9 +318,12 @@ WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_ /******************************************************************** ********************************************************************/ -WERROR _svcctl_close_service(pipes_struct *p, SVCCTL_Q_CLOSE_SERVICE *q_u, SVCCTL_R_CLOSE_SERVICE *r_u) +WERROR _svcctl_CloseServiceHandle(pipes_struct *p, struct svcctl_CloseServiceHandle *r) { - return close_policy_hnd( p, &q_u->handle ) ? WERR_OK : WERR_BADFID; + if ( !close_policy_hnd( p, r->in.handle ) ) + return WERR_BADFID; + + return WERR_OK; } /******************************************************************** @@ -871,3 +874,261 @@ WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, } +WERROR _svcctl_ControlService(pipes_struct *p, struct svcctl_ControlService *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_DeleteService(pipes_struct *p, struct svcctl_DeleteService *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_LockServiceDatabase(pipes_struct *p, struct svcctl_LockServiceDatabase *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_QueryServiceObjectSecurity(pipes_struct *p, struct svcctl_QueryServiceObjectSecurity *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_SetServiceObjectSecurity(pipes_struct *p, struct svcctl_SetServiceObjectSecurity *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_QueryServiceStatus(pipes_struct *p, struct svcctl_QueryServiceStatus *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_SetServiceStatus(pipes_struct *p, struct svcctl_SetServiceStatus *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_UnlockServiceDatabase(pipes_struct *p, struct svcctl_UnlockServiceDatabase *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_NotifyBootConfigStatus(pipes_struct *p, struct svcctl_NotifyBootConfigStatus *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_SCSetServiceBitsW(pipes_struct *p, struct svcctl_SCSetServiceBitsW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_ChangeServiceConfigW(pipes_struct *p, struct svcctl_ChangeServiceConfigW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_CreateServiceW(pipes_struct *p, struct svcctl_CreateServiceW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_EnumDependentServicesW(pipes_struct *p, struct svcctl_EnumDependentServicesW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_EnumServicesStatusW(pipes_struct *p, struct svcctl_EnumServicesStatusW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_OpenSCManagerW(pipes_struct *p, struct svcctl_OpenSCManagerW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_OpenServiceW(pipes_struct *p, struct svcctl_OpenServiceW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_QueryServiceConfigW(pipes_struct *p, struct svcctl_QueryServiceConfigW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_QueryServiceLockStatusW(pipes_struct *p, struct svcctl_QueryServiceLockStatusW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_StartServiceW(pipes_struct *p, struct svcctl_StartServiceW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_GetServiceDisplayNameW(pipes_struct *p, struct svcctl_GetServiceDisplayNameW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_GetServiceKeyNameW(pipes_struct *p, struct svcctl_GetServiceKeyNameW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_SCSetServiceBitsA(pipes_struct *p, struct svcctl_SCSetServiceBitsA *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_ChangeServiceConfigA(pipes_struct *p, struct svcctl_ChangeServiceConfigA *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_CreateServiceA(pipes_struct *p, struct svcctl_CreateServiceA *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_EnumDependentServicesA(pipes_struct *p, struct svcctl_EnumDependentServicesA *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_EnumServicesStatusA(pipes_struct *p, struct svcctl_EnumServicesStatusA *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_OpenSCManagerA(pipes_struct *p, struct svcctl_OpenSCManagerA *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_OpenServiceA(pipes_struct *p, struct svcctl_OpenServiceA *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_QueryServiceConfigA(pipes_struct *p, struct svcctl_QueryServiceConfigA *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_QueryServiceLockStatusA(pipes_struct *p, struct svcctl_QueryServiceLockStatusA *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_StartServiceA(pipes_struct *p, struct svcctl_StartServiceA *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_GetServiceDisplayNameA(pipes_struct *p, struct svcctl_GetServiceDisplayNameA *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_GetServiceKeyNameA(pipes_struct *p, struct svcctl_GetServiceKeyNameA *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_GetCurrentGroupeStateW(pipes_struct *p, struct svcctl_GetCurrentGroupeStateW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_EnumServiceGroupW(pipes_struct *p, struct svcctl_EnumServiceGroupW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_ChangeServiceConfig2A(pipes_struct *p, struct svcctl_ChangeServiceConfig2A *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_ChangeServiceConfig2W(pipes_struct *p, struct svcctl_ChangeServiceConfig2W *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_QueryServiceConfig2A(pipes_struct *p, struct svcctl_QueryServiceConfig2A *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_QueryServiceConfig2W(pipes_struct *p, struct svcctl_QueryServiceConfig2W *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_QueryServiceStatusEx(pipes_struct *p, struct svcctl_QueryServiceStatusEx *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _EnumServicesStatusExA(pipes_struct *p, struct EnumServicesStatusExA *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _EnumServicesStatusExW(pipes_struct *p, struct EnumServicesStatusExW *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _svcctl_SCSendTSMessage(pipes_struct *p, struct svcctl_SCSendTSMessage *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + -- cgit From 97a164ba96d48a81d5e24dda6b866a4d78ea1a78 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 31 May 2007 17:59:04 +0000 Subject: r23274: merge CloseEventlog() pidl conversion from 3.0.26 && fix a few init call renames for svcctl in the previous commit (This used to be commit ebcae48ec10fefa74efcc3563cff50e3b9c2388c) --- source3/rpc_server/srv_eventlog.c | 46 ++++++----- source3/rpc_server/srv_eventlog_nt.c | 145 ++++++++++++++++++++++++++++++++++- source3/rpc_server/srv_pipe.c | 4 +- 3 files changed, 165 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c index ae15d43f4b..1492e67109 100644 --- a/source3/rpc_server/srv_eventlog.c +++ b/source3/rpc_server/srv_eventlog.c @@ -1,7 +1,8 @@ /* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines - * Copyright (C) Marcin Krzysztof Porwit 2005. + * Copyright (C) Marcin Krzysztof Porwit 2005. + * Copyright (C) Gerald Carter 2005 - 2007 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +24,23 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +static BOOL proxy_eventlog_call(pipes_struct *p, uint8 opnum) +{ + struct api_struct *fns; + int n_fns; + + eventlog_get_pipe_fns(&fns, &n_fns); + + if (opnum >= n_fns) + return False; + + if (fns[opnum].opnum != opnum) { + smb_panic("EVENTLOG function table not sorted\n"); + } + + return fns[opnum].fn(p); +} + static BOOL api_eventlog_open_eventlog(pipes_struct *p) { EVENTLOG_Q_OPEN_EVENTLOG q_u; @@ -50,27 +68,7 @@ static BOOL api_eventlog_open_eventlog(pipes_struct *p) static BOOL api_eventlog_close_eventlog(pipes_struct *p) { - EVENTLOG_Q_CLOSE_EVENTLOG q_u; - EVENTLOG_R_CLOSE_EVENTLOG r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!(eventlog_io_q_close_eventlog("", &q_u, data, 0))) { - DEBUG(0, ("eventlog_io_q_close_eventlog: unable to unmarshall EVENTLOG_Q_CLOSE_EVENTLOG.\n")); - return False; - } - - r_u.status = _eventlog_close_eventlog(p, &q_u, &r_u); - - if (!(eventlog_io_r_close_eventlog("", &r_u, rdata, 0))) { - DEBUG(0, ("eventlog_io_r_close_eventlog: unable to marshall EVENTLOG_R_CLOSE_EVENTLOG.\n")); - return False; - } - - return True; + return proxy_eventlog_call( p, DCERPC_EVENTLOG_CLOSEEVENTLOG ); } static BOOL api_eventlog_get_num_records(pipes_struct *p) @@ -186,14 +184,14 @@ struct api_struct api_eventlog_cmds[] = {"EVENTLOG_CLEAREVENTLOG", EVENTLOG_CLEAREVENTLOG, api_eventlog_clear_eventlog } }; -NTSTATUS rpc_eventlog_init(void) +NTSTATUS rpc_eventlog2_init(void) { return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "eventlog", "eventlog", api_eventlog_cmds, sizeof(api_eventlog_cmds)/sizeof(struct api_struct)); } -void eventlog_get_pipe_fns(struct api_struct **fns, int *n_fns) +void eventlog2_get_pipe_fns(struct api_struct **fns, int *n_fns) { *fns = api_eventlog_cmds; *n_fns = sizeof(api_eventlog_cmds) / sizeof(struct api_struct); diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 753772642a..85990055dd 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -658,11 +658,9 @@ NTSTATUS _eventlog_clear_eventlog( pipes_struct * p, /******************************************************************** ********************************************************************/ -NTSTATUS _eventlog_close_eventlog( pipes_struct * p, - EVENTLOG_Q_CLOSE_EVENTLOG * q_u, - EVENTLOG_R_CLOSE_EVENTLOG * r_u ) +NTSTATUS _eventlog_CloseEventLog( pipes_struct * p, struct eventlog_CloseEventLog *r ) { - return elog_close( p, &q_u->handle ); + return elog_close( p, r->in.handle ); } /******************************************************************** @@ -801,3 +799,142 @@ NTSTATUS _eventlog_get_num_records( pipes_struct * p, return NT_STATUS_OK; } + +NTSTATUS _eventlog_ClearEventLogW(pipes_struct *p, struct eventlog_ClearEventLogW *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_BackupEventLogW(pipes_struct *p, struct eventlog_BackupEventLogW *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_DeregisterEventSource(pipes_struct *p, struct eventlog_DeregisterEventSource *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_GetNumRecords(pipes_struct *p, struct eventlog_GetNumRecords *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_GetOldestRecord(pipes_struct *p, struct eventlog_GetOldestRecord *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_ChangeNotify(pipes_struct *p, struct eventlog_ChangeNotify *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_OpenEventLogW(pipes_struct *p, struct eventlog_OpenEventLogW *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_RegisterEventSourceW(pipes_struct *p, struct eventlog_RegisterEventSourceW *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_OpenBackupEventLogW(pipes_struct *p, struct eventlog_OpenBackupEventLogW *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_ReadEventLogW(pipes_struct *p, struct eventlog_ReadEventLogW *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_ReportEventW(pipes_struct *p, struct eventlog_ReportEventW *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_ClearEventLogA(pipes_struct *p, struct eventlog_ClearEventLogA *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_BackupEventLogA(pipes_struct *p, struct eventlog_BackupEventLogA *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_OpenEventLogA(pipes_struct *p, struct eventlog_OpenEventLogA *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_RegisterEventSourceA(pipes_struct *p, struct eventlog_RegisterEventSourceA *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_OpenBackupEventLogA(pipes_struct *p, struct eventlog_OpenBackupEventLogA *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_ReadEventLogA(pipes_struct *p, struct eventlog_ReadEventLogA *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_ReportEventA(pipes_struct *p, struct eventlog_ReportEventA *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_RegisterClusterSvc(pipes_struct *p, struct eventlog_RegisterClusterSvc *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_DeregisterClusterSvc(pipes_struct *p, struct eventlog_DeregisterClusterSvc *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_WriteClusterEvents(pipes_struct *p, struct eventlog_WriteClusterEvents *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_GetLogIntormation(pipes_struct *p, struct eventlog_GetLogIntormation *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS _eventlog_FlushEventLog(pipes_struct *p, struct eventlog_FlushEventLog *r) +{ + p->rng_fault_state = True; + return NT_STATUS_NOT_IMPLEMENTED; +} + diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 83c059d36c..8aab80db72 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2380,10 +2380,10 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) netdfs_get_pipe_fns( &cmds, &n_cmds ); break; case PI_SVCCTL: - svcctl_get_pipe_fns( &cmds, &n_cmds ); + svcctl2_get_pipe_fns( &cmds, &n_cmds ); break; case PI_EVENTLOG: - eventlog_get_pipe_fns( &cmds, &n_cmds ); + eventlog2_get_pipe_fns( &cmds, &n_cmds ); break; case PI_UNIXINFO: unixinfo_get_pipe_fns( &cmds, &n_cmds ); -- cgit From 2e6deee0208aba89fb3ecc7ead62d867e4da20ea Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 9 Jun 2007 00:13:07 +0000 Subject: r23400: Fix lsa crash bug #4683. The "names" enum struct in a lookup_sidX reply isn't optional - like the lookup_sidX query it needs to be defined in the struct. All this will go away with PIDL (thank goodness....). Jerry - I think this is a showstopper to be merged for 3.0.25b. I'll be watching the build farm to see if anything broke. Jeremy. (This used to be commit 9300b92f7a51eb80fdc039d8dad23ea9ce82aa8f) --- source3/rpc_server/srv_lsa_nt.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index bde1ef81da..f9b86d0c67 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -380,12 +380,10 @@ static void init_reply_lookup_names4(LSA_R_LOOKUP_NAMES4 *r_l, static void init_reply_lookup_sids2(LSA_R_LOOKUP_SIDS2 *r_l, DOM_R_REF *ref, - LSA_TRANS_NAME_ENUM2 *names, uint32 mapped_count) { r_l->ptr_dom_ref = ref ? 1 : 0; r_l->dom_ref = ref; - r_l->names = names; r_l->mapped_count = mapped_count; } @@ -395,12 +393,10 @@ static void init_reply_lookup_sids2(LSA_R_LOOKUP_SIDS2 *r_l, static void init_reply_lookup_sids3(LSA_R_LOOKUP_SIDS3 *r_l, DOM_R_REF *ref, - LSA_TRANS_NAME_ENUM2 *names, uint32 mapped_count) { r_l->ptr_dom_ref = ref ? 1 : 0; r_l->dom_ref = ref; - r_l->names = names; r_l->mapped_count = mapped_count; } @@ -414,11 +410,7 @@ static NTSTATUS init_reply_lookup_sids(TALLOC_CTX *mem_ctx, LSA_TRANS_NAME_ENUM2 *names, uint32 mapped_count) { - LSA_TRANS_NAME_ENUM *oldnames = TALLOC_ZERO_P(mem_ctx, LSA_TRANS_NAME_ENUM); - - if (!oldnames) { - return NT_STATUS_NO_MEMORY; - } + LSA_TRANS_NAME_ENUM *oldnames = &r_l->names; oldnames->num_entries = names->num_entries; oldnames->ptr_trans_names = names->ptr_trans_names; @@ -442,7 +434,6 @@ static NTSTATUS init_reply_lookup_sids(TALLOC_CTX *mem_ctx, r_l->ptr_dom_ref = ref ? 1 : 0; r_l->dom_ref = ref; - r_l->names = oldnames; r_l->mapped_count = mapped_count; return NT_STATUS_OK; } @@ -810,13 +801,12 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, int num_sids, /* input */ const DOM_SID2 *sid, /* input */ DOM_R_REF **pp_ref, /* output */ - LSA_TRANS_NAME_ENUM2 **pp_names, /* output */ + LSA_TRANS_NAME_ENUM2 *names, /* input/output */ uint32 *pp_mapped_count) { NTSTATUS status; int i; const DOM_SID **sids = NULL; - LSA_TRANS_NAME_ENUM2 *names = NULL; DOM_R_REF *ref = NULL; uint32 mapped_count = 0; struct lsa_dom_info *dom_infos = NULL; @@ -824,17 +814,16 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, *pp_mapped_count = 0; *pp_ref = NULL; - *pp_names = NULL; + ZERO_STRUCTP(names); if (num_sids == 0) { return NT_STATUS_OK; } - names = TALLOC_ZERO_P(p->mem_ctx, LSA_TRANS_NAME_ENUM2); sids = TALLOC_ARRAY(p->mem_ctx, const DOM_SID *, num_sids); ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - if (sids == NULL || names == NULL || ref == NULL) { + if (sids == NULL || ref == NULL) { return NT_STATUS_NO_MEMORY; } @@ -907,7 +896,6 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, *pp_mapped_count = mapped_count; *pp_ref = ref; - *pp_names = names; return status; } @@ -924,7 +912,7 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, int num_sids = q_u->sids.num_entries; uint32 mapped_count = 0; DOM_R_REF *ref = NULL; - LSA_TRANS_NAME_ENUM2 *names = NULL; + LSA_TRANS_NAME_ENUM2 names; NTSTATUS status; if ((q_u->level < 1) || (q_u->level > 6)) { @@ -956,7 +944,7 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, /* Convert from LSA_TRANS_NAME_ENUM2 to LSA_TRANS_NAME_ENUM */ - status = init_reply_lookup_sids(p->mem_ctx, r_u, ref, names, mapped_count); + status = init_reply_lookup_sids(p->mem_ctx, r_u, ref, &names, mapped_count); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -975,7 +963,6 @@ NTSTATUS _lsa_lookup_sids2(pipes_struct *p, int num_sids = q_u->sids.num_entries; uint32 mapped_count = 0; DOM_R_REF *ref = NULL; - LSA_TRANS_NAME_ENUM2 *names = NULL; if ((q_u->level < 1) || (q_u->level > 6)) { return NT_STATUS_INVALID_PARAMETER; @@ -1001,10 +988,10 @@ NTSTATUS _lsa_lookup_sids2(pipes_struct *p, num_sids, q_u->sids.sid, &ref, - &names, + &r_u->names, &mapped_count); - init_reply_lookup_sids2(r_u, ref, names, mapped_count); + init_reply_lookup_sids2(r_u, ref, mapped_count); return r_u->status; } @@ -1022,7 +1009,6 @@ NTSTATUS _lsa_lookup_sids3(pipes_struct *p, { uint32 mapped_count = 0; DOM_R_REF *ref; - LSA_TRANS_NAME_ENUM2 *names; if ((q_u->level < 1) || (q_u->level > 6)) { return NT_STATUS_INVALID_PARAMETER; @@ -1031,15 +1017,14 @@ NTSTATUS _lsa_lookup_sids3(pipes_struct *p, r_u->status = NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED; ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - names = TALLOC_ZERO_P(p->mem_ctx, LSA_TRANS_NAME_ENUM2); - if ((ref == NULL) || (names == NULL)) { + if (ref == NULL) { /* We would segfault later on in lsa_io_r_lookup_sids3 anyway, * so do a planned exit here. We NEEEED pidl! */ smb_panic("talloc failed"); } - init_reply_lookup_sids3(r_u, ref, names, mapped_count); + init_reply_lookup_sids3(r_u, ref, mapped_count); return r_u->status; } -- cgit From f461e53e7a493b15c53c97a5e1210cab5b069282 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 9 Jun 2007 00:27:28 +0000 Subject: r23402: Got bitten by a talloc hierarchy. Make sure we alloc off the pipe ctx now ->names is part of the containing struct. Jeremy. (This used to be commit 02fd43490212e9ff8f784ce4d33d64566d58fd82) --- source3/rpc_server/srv_lsa_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f9b86d0c67..0d29df72bf 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -420,7 +420,7 @@ static NTSTATUS init_reply_lookup_sids(TALLOC_CTX *mem_ctx, if (names->num_entries) { int i; - oldnames->name = TALLOC_ARRAY(oldnames, LSA_TRANS_NAME, names->num_entries); + oldnames->name = TALLOC_ARRAY(mem_ctx, LSA_TRANS_NAME, names->num_entries); if (!oldnames->name) { return NT_STATUS_NO_MEMORY; @@ -838,8 +838,8 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, return status; } - names->name = TALLOC_ARRAY(names, LSA_TRANS_NAME2, num_sids); - names->uni_name = TALLOC_ARRAY(names, UNISTR2, num_sids); + names->name = TALLOC_ARRAY(p->mem_ctx, LSA_TRANS_NAME2, num_sids); + names->uni_name = TALLOC_ARRAY(p->mem_ctx, UNISTR2, num_sids); if ((names->name == NULL) || (names->uni_name == NULL)) { return NT_STATUS_NO_MEMORY; } -- cgit From 9af7b35db01b26c858afea925c4b6b0aaaefb667 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 12 Jun 2007 11:54:25 +0000 Subject: r23432: Remove superfluous comment. (A relict from regkey_open_internal days.) Michael (This used to be commit 4025cbc2024acf36e96d7236225b439dbd3e4df0) --- source3/rpc_server/srv_winreg_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 9e712173ab..4398d94235 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -73,8 +73,6 @@ static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, WERROR result = WERR_OK; struct registry_key *key; - /* now do the internal open */ - if (parent == NULL) { result = reg_openhive(NULL, subkeyname, access_desired, p->pipe_user.nt_user_token, &key); -- cgit From 5d14172c1579ba3224a81e3dae8ef9a393237005 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 12 Jun 2007 12:01:52 +0000 Subject: r23433: remove superfluous semicolon. (This used to be commit b8269f454338c8b20b90451f3866fc193871e9af) --- source3/rpc_server/srv_winreg_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 4398d94235..76ccc846b7 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -90,7 +90,7 @@ static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, return WERR_BADFILE; } - return WERR_OK;; + return WERR_OK; } /******************************************************************* -- cgit From 4a6aaabe6f45171ada79f6d51e2e12296c1086ab Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 12 Jun 2007 12:35:24 +0000 Subject: r23434: Coorect a comment. (This used to be commit c9f38fa30e9b784a56f08d0ab4765e9c7a42aa7d) --- source3/rpc_server/srv_winreg_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 76ccc846b7..f0bce7e931 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -31,7 +31,7 @@ static struct generic_mapping reg_generic_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; /****************************************************************** - free() function for struct regkey_info + free() function for struct registry_key *****************************************************************/ static void free_regkey(void *ptr) -- cgit From b1ce226af8b61ad7e3c37860a59c6715012e738b Mon Sep 17 00:00:00 2001 From: James Peach Date: Fri, 15 Jun 2007 21:58:49 +0000 Subject: r23510: Tidy calls to smb_panic by removing trailing newlines. Print the failed expression in SMB_ASSERT. (This used to be commit 171dc060e2a576d724eed1ca65636bdafffd7713) --- source3/rpc_server/srv_lsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 0269e75e4e..f41cbdcc4a 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -41,7 +41,7 @@ static BOOL proxy_lsa_call(pipes_struct *p, uint8 opnum) return False; if (fns[opnum].opnum != opnum) { - smb_panic("LSA function table not sorted\n"); + smb_panic("LSA function table not sorted"); } return fns[opnum].fn(p); -- cgit From d1d2157153d7a4b3e7918bcc91c50445bf9a6771 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 22 Jun 2007 19:33:46 +0000 Subject: r23591: Fix bug #4725. Don't crash when no eventlogs specified. Needs merging for 3.0.25b. Jeremy. (This used to be commit ae239fec6faa79018c818506b391b829ccd685f8) --- source3/rpc_server/srv_eventlog_nt.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 85990055dd..c8be6a9b34 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -123,6 +123,10 @@ static BOOL elog_validate_logname( const char *name ) int i; const char **elogs = lp_eventlog_list(); + if (!elogs) { + return False; + } + for ( i=0; elogs[i]; i++ ) { if ( strequal( name, elogs[i] ) ) return True; -- cgit From 9c3db7adf3efb7e485ac0a7301f31a1ab6338435 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Tue, 26 Jun 2007 20:09:41 +0000 Subject: r23616: Fix bugzilla #4719: must change password is not set from usrmgr.exe. This was only affecting the newer versions of usrmgr.exe, because they use a user_info_25 struct. The password is getting set separately inside that code, so the password last set time was getting set from the password change logic. We also were not parsing a number of fields (like logon hours) from the user_info_25. That should also be fixed. (This used to be commit afabd68b6ae874aceba708dc36808ed007ad496c) --- source3/rpc_server/srv_samr_nt.c | 9 ++++++++ source3/rpc_server/srv_samr_util.c | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b392f289a8..e28fc59136 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3357,11 +3357,17 @@ static BOOL set_user_info_pw(uint8 *pass, struct samu *pwd) uint32 len; pstring plaintext_buf; uint32 acct_ctrl; + time_t last_set_time; + enum pdb_value_state last_set_state; DEBUG(5, ("Attempting administrator password change for user %s\n", pdb_get_username(pwd))); acct_ctrl = pdb_get_acct_ctrl(pwd); + /* we need to know if it's expired, because this is an admin change, not a + user change, so it's still expired when we're done */ + last_set_state = pdb_get_init_flags(pwd, PDB_PASSLASTSET); + last_set_time = pdb_get_pass_last_set_time(pwd); ZERO_STRUCT(plaintext_buf); @@ -3404,6 +3410,9 @@ static BOOL set_user_info_pw(uint8 *pass, struct samu *pwd) ZERO_STRUCT(plaintext_buf); + /* restore last set time as this is an admin change, not a user pw change */ + pdb_set_pass_last_set_time (pwd, last_set_time, last_set_state); + DEBUG(5,("set_user_info_pw: pdb_update_pwd()\n")); /* update the SAMBA password */ diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 8acc1785ef..42ad462ee7 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -670,4 +670,47 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); } } + + if (from->fields_present & ACCT_LOGON_HOURS) { + DEBUG(15,("INFO_25 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); + if (from->logon_divs != pdb_get_logon_divs(to)) { + pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); + } + + DEBUG(15,("INFO_25 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); + if (from->logon_hrs.len != pdb_get_hours_len(to)) { + pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED); + } + + DEBUG(15,("INFO_25 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); + /* Fix me: only update if it changes --metze */ + pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); + } + + if (from->fields_present & ACCT_BAD_PWD_COUNT) { + DEBUG(10,("INFO_25 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count)); + if (from->bad_password_count != pdb_get_bad_password_count(to)) { + pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED); + } + } + + if (from->fields_present & ACCT_NUM_LOGONS) { + DEBUG(10,("INFO_25 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count)); + if (from->logon_count != pdb_get_logon_count(to)) { + pdb_set_logon_count(to, from->logon_count, PDB_CHANGED); + } + } + + /* If the must change flag is set, the last set time goes to zero. + the must change and can change fields also do, but they are + calculated from policy, not set from the wire */ + + if (from->fields_present & ACCT_EXPIRED_FLAG) { + DEBUG(10,("INFO_25 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); + if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) { + pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); + } else { + pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED); + } + } } -- cgit From a0ac7a7f4c0290787cdadb5866272cee2bd61b8a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 26 Jun 2007 22:49:10 +0000 Subject: r23620: Convert set_nt_acl to return NTSTATUS. Also fix the chown return to correctly return NT_STATUS_INVALID_OWNER if it should be disallowed. Matches better what W2K3R3 does. NFSv4 ACL module owners, please examine these changes. Jeremy. (This used to be commit fc6899a5506b272f8cd5f5837ca13300b4e69a5f) --- source3/rpc_server/srv_srvsvc_nt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 7132f92c93..0573599a81 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2147,7 +2147,6 @@ error_exit: WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecurity *r) { - BOOL ret; DATA_BLOB null_pw; files_struct *fsp = NULL; SMB_STRUCT_STAT st; @@ -2215,9 +2214,9 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecur } } - ret = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, r->in.securityinformation, r->in.sd_buf.sd); + nt_status = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, r->in.securityinformation, r->in.sd_buf.sd); - if (ret == False) { + if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", r->in.file)); status = WERR_ACCESS_DENIED; goto error_exit; -- cgit From 6eb18630f789d4188e299a5d60e796161e2996ad Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Jun 2007 09:23:50 +0000 Subject: r23623: Fix rpcclient and rpc_server with new DFS idl. Guenther (This used to be commit bffe33dd261fdcf9ef8f9f232c15559661843c7c) --- source3/rpc_server/srv_dfs_nt.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index d114a07994..eb159bdc64 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -32,10 +32,11 @@ void _dfs_GetManagerVersion(pipes_struct *p, struct dfs_GetManagerVersion *r) { - if(lp_host_msdfs()) - *r->out.exist_flag = 1; - else - *r->out.exist_flag = 0; + if (lp_host_msdfs()) { + *r->out.version = DFS_MANAGER_VERSION_NT4; + } else { + *r->out.version = 0; + } } WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) @@ -109,22 +110,22 @@ WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) return WERR_ACCESS_DENIED; } - if (r->in.server && r->in.share) { - pstrcpy(altpath, r->in.server); + if (r->in.servername && r->in.sharename) { + pstrcpy(altpath, r->in.servername); pstrcat(altpath, "\\"); - pstrcat(altpath, r->in.share); + pstrcat(altpath, r->in.sharename); strlower_m(altpath); } DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n", - r->in.path, r->in.server, r->in.share)); + r->in.dfs_entry_path, r->in.servername, r->in.sharename)); - if(!NT_STATUS_IS_OK(get_referred_path(p->mem_ctx, r->in.path, &jn, &consumedcnt, &self_ref))) { + if(!NT_STATUS_IS_OK(get_referred_path(p->mem_ctx, r->in.dfs_entry_path, &jn, &consumedcnt, &self_ref))) { return WERR_DFS_NO_SUCH_VOL; } /* if no server-share pair given, remove the msdfs link completely */ - if(!r->in.server && !r->in.share) { + if(!r->in.servername && !r->in.sharename) { if(!remove_msdfs_link(&jn)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; @@ -324,11 +325,11 @@ WERROR _dfs_GetInfo(pipes_struct *p, struct dfs_GetInfo *r) BOOL self_ref = False; BOOL ret; - if(!create_junction(r->in.path, &jn)) + if(!create_junction(r->in.dfs_entry_path, &jn)) return WERR_DFS_NO_SUCH_SERVER; /* The following call can change the cwd. */ - if(!NT_STATUS_IS_OK(get_referred_path(p->mem_ctx, r->in.path, &jn, &consumedcnt, &self_ref)) || consumedcnt < strlen(r->in.path)) { + if(!NT_STATUS_IS_OK(get_referred_path(p->mem_ctx, r->in.dfs_entry_path, &jn, &consumedcnt, &self_ref)) || consumedcnt < strlen(r->in.dfs_entry_path)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; } -- cgit From 255b807802f627451835c1525dd7dfee869833ee Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 27 Jun 2007 16:52:36 +0000 Subject: r23633: Fix a couple of crash bugs pointed out by Volker caused by an old change from a pstring to a char* and still trying use pstrcpy(). (This used to be commit 21dc46a2bad6fee720f0f591e1051aa7675c77c8) --- source3/rpc_server/srv_winreg_nt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index f0bce7e931..1fa61c27ca 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -661,7 +661,12 @@ static WERROR reg_load_tree( REGF_FILE *regfile, const char *topkeypath, topkeypath )); return WERR_BADFILE; } - pstrcpy( registry_key.name, topkeypath ); + + registry_key.name = talloc_strdup( regfile->mem_ctx, topkeypath ); + if ( !registry_key.name ) { + DEBUG(0,("reg_load_tree: Talloc failed for reg_key.name!\n")); + return WERR_NOMEM; + } /* now start parsing the values and subkeys */ -- cgit From f9df7787e6b1fec9404451eb2220dc34baf5e4a3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 29 Jun 2007 17:40:37 +0000 Subject: r23661: Another static pstring (This used to be commit d4256ae5588fddc62bf90082d24140e327a54c8c) --- source3/rpc_server/srv_ntsvcs_nt.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index 79259174fd..6164217a65 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -27,13 +27,9 @@ /******************************************************************** ********************************************************************/ -static char* get_device_path( const char *device ) +static char* get_device_path(TALLOC_CTX *mem_ctx, const char *device ) { - static pstring path; - - pstr_sprintf( path, "ROOT\\Legacy_%s\\0000", device ); - - return path; + return talloc_asprintf(mem_ctx, "ROOT\\Legacy_%s\\0000", device); } /******************************************************************** @@ -52,16 +48,21 @@ WERROR _ntsvcs_get_version( pipes_struct *p, NTSVCS_Q_GET_VERSION *q_u, NTSVCS_R WERROR _ntsvcs_get_device_list_size( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST_SIZE *q_u, NTSVCS_R_GET_DEVICE_LIST_SIZE *r_u ) { fstring device; - const char *devicepath; + char *devicepath; if ( !q_u->devicename ) return WERR_ACCESS_DENIED; rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0); - devicepath = get_device_path( device ); + + if (!(devicepath = get_device_path(p->mem_ctx, device))) { + return WERR_NOMEM; + } r_u->size = strlen(devicepath) + 2; + TALLOC_FREE(devicepath); + return WERR_OK; } @@ -72,17 +73,21 @@ WERROR _ntsvcs_get_device_list_size( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST_S WERROR _ntsvcs_get_device_list( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST *q_u, NTSVCS_R_GET_DEVICE_LIST *r_u ) { fstring device; - const char *devicepath; + char *devicepath; if ( !q_u->devicename ) return WERR_ACCESS_DENIED; rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0); - devicepath = get_device_path( device ); + + if (!(devicepath = get_device_path(p->mem_ctx, device))) { + return WERR_NOMEM; + } /* This has to be DOUBLE NULL terminated */ init_unistr2( &r_u->devicepath, devicepath, UNI_STR_DBLTERMINATE ); + TALLOC_FREE(devicepath); r_u->needed = r_u->devicepath.uni_str_len; return WERR_OK; -- cgit From 824b3f82acd09315a68cc7f66a6bbab4f50f6eb7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 4 Jul 2007 22:28:04 +0000 Subject: r23709: C++ warnings (This used to be commit 2d5e3322d6ecd00c0e936ee64483e63a3ad87c0b) --- source3/rpc_server/srv_echo_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_echo_nt.c b/source3/rpc_server/srv_echo_nt.c index 08d54ceba4..426cd2fded 100644 --- a/source3/rpc_server/srv_echo_nt.c +++ b/source3/rpc_server/srv_echo_nt.c @@ -50,7 +50,7 @@ void _echo_EchoData(pipes_struct *p, struct echo_EchoData *r) return; } - r->out.out_data = TALLOC(p->mem_ctx, r->in.len); + r->out.out_data = TALLOC_ARRAY(p->mem_ctx, uint8, r->in.len); memcpy( r->out.out_data, r->in.in_data, r->in.len ); return; } @@ -78,7 +78,7 @@ void _echo_SourceData(pipes_struct *p, struct echo_SourceData *r) return; } - r->out.data = TALLOC(p->mem_ctx, r->in.len ); + r->out.data = TALLOC_ARRAY(p->mem_ctx, uint8, r->in.len ); for (i = 0; i < r->in.len; i++ ) { r->out.data[i] = i & 0xff; -- cgit From 0bc56a2e5ffd0e65e4770e10c80d9fec02950b36 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 5 Jul 2007 16:26:27 +0000 Subject: r23724: Reduce access to the global inbuf a tiny bit. Add a struct smb_request that contains some of the fields from the SMB header, removing the need to access inbuf directly. This right now is used only in the open file code & friends, and creating that header is only done when needed. This needs more work, but it is a start. Jeremy, I'm only checking this into 3_0, please review before I merge it to _26. Volker (This used to be commit ca988f4e79e977160d82e86486972afd15d4acf5) --- source3/rpc_server/srv_srvsvc_nt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 0573599a81..1d370d3847 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2089,11 +2089,11 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecur goto error_exit; } - nt_status = open_file_stat(conn, r->in.file, &st, &fsp); + nt_status = open_file_stat(conn, NULL, r->in.file, &st, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { /* Perhaps it is a directory */ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) - nt_status = open_directory(conn, r->in.file, &st, + nt_status = open_directory(conn, NULL, r->in.file, &st, READ_CONTROL_ACCESS, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, @@ -2194,12 +2194,12 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecur } - nt_status = open_file_stat(conn, r->in.file, &st, &fsp); + nt_status = open_file_stat(conn, NULL, r->in.file, &st, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { /* Perhaps it is a directory */ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) - nt_status = open_directory(conn, r->in.file, &st, + nt_status = open_directory(conn, NULL, r->in.file, &st, FILE_READ_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, -- cgit From 65f7a9d084ec455a0c8a504c978e49b56e37af32 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 9 Jul 2007 08:04:43 +0000 Subject: r23758: Fix Coverity id 385 (This used to be commit 4d9f627cc8081307da3f84f784602533bd20c1e6) --- source3/rpc_server/srv_spoolss_nt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 2047e13df3..464ca36f3c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7490,8 +7490,13 @@ WERROR enumports_hook( int *count, char ***lines ) /* if no hook then just fill in the default port */ if ( !*cmd ) { - qlines = SMB_MALLOC_ARRAY( char*, 2 ); - qlines[0] = SMB_STRDUP( SAMBA_PRINTER_PORT_NAME ); + if (!(qlines = SMB_MALLOC_ARRAY( char*, 2 ))) { + return WERR_NOMEM; + } + if (!(qlines[0] = SMB_STRDUP( SAMBA_PRINTER_PORT_NAME ))) { + SAFE_FREE(qlines); + return WERR_NOMEM; + } qlines[1] = NULL; numlines = 1; } -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/rpc_server/srv_dfs_nt.c | 2 +- source3/rpc_server/srv_echo_nt.c | 2 +- source3/rpc_server/srv_epmapper_nt.c | 2 +- source3/rpc_server/srv_eventlog.c | 2 +- source3/rpc_server/srv_eventlog_lib.c | 2 +- source3/rpc_server/srv_eventlog_nt.c | 2 +- source3/rpc_server/srv_initshutdown_nt.c | 2 +- source3/rpc_server/srv_lsa.c | 2 +- source3/rpc_server/srv_lsa_ds.c | 2 +- source3/rpc_server/srv_lsa_ds_nt.c | 2 +- source3/rpc_server/srv_lsa_hnd.c | 2 +- source3/rpc_server/srv_lsa_nt.c | 2 +- source3/rpc_server/srv_netlog.c | 2 +- source3/rpc_server/srv_netlog_nt.c | 2 +- source3/rpc_server/srv_ntsvcs.c | 2 +- source3/rpc_server/srv_ntsvcs_nt.c | 2 +- source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_pipe_hnd.c | 2 +- source3/rpc_server/srv_samr.c | 2 +- source3/rpc_server/srv_samr_nt.c | 2 +- source3/rpc_server/srv_samr_util.c | 2 +- source3/rpc_server/srv_spoolss.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 2 +- source3/rpc_server/srv_srvsvc_nt.c | 2 +- source3/rpc_server/srv_svcctl.c | 2 +- source3/rpc_server/srv_svcctl_nt.c | 2 +- source3/rpc_server/srv_unixinfo_nt.c | 2 +- source3/rpc_server/srv_util.c | 2 +- source3/rpc_server/srv_winreg_nt.c | 2 +- source3/rpc_server/srv_wkssvc_nt.c | 2 +- 30 files changed, 30 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index eb159bdc64..e00ea88015 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -7,7 +7,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_echo_nt.c b/source3/rpc_server/srv_echo_nt.c index 426cd2fded..155fe14516 100644 --- a/source3/rpc_server/srv_echo_nt.c +++ b/source3/rpc_server/srv_echo_nt.c @@ -7,7 +7,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_epmapper_nt.c b/source3/rpc_server/srv_epmapper_nt.c index 77a06124db..67aaa0793d 100644 --- a/source3/rpc_server/srv_epmapper_nt.c +++ b/source3/rpc_server/srv_epmapper_nt.c @@ -5,7 +5,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c index 1492e67109..a1acf1f25f 100644 --- a/source3/rpc_server/srv_eventlog.c +++ b/source3/rpc_server/srv_eventlog.c @@ -6,7 +6,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index c780cf910c..7061df650f 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -7,7 +7,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index c8be6a9b34..76e8760d6d 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -7,7 +7,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_initshutdown_nt.c b/source3/rpc_server/srv_initshutdown_nt.c index cd84f72058..1d3d67f4ef 100644 --- a/source3/rpc_server/srv_initshutdown_nt.c +++ b/source3/rpc_server/srv_initshutdown_nt.c @@ -6,7 +6,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index f41cbdcc4a..157f819a37 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -10,7 +10,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_lsa_ds.c b/source3/rpc_server/srv_lsa_ds.c index db741a1b64..3c1a952d3a 100644 --- a/source3/rpc_server/srv_lsa_ds.c +++ b/source3/rpc_server/srv_lsa_ds.c @@ -5,7 +5,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_lsa_ds_nt.c b/source3/rpc_server/srv_lsa_ds_nt.c index 17543a38ef..9fcf05fe67 100644 --- a/source3/rpc_server/srv_lsa_ds_nt.c +++ b/source3/rpc_server/srv_lsa_ds_nt.c @@ -9,7 +9,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index a95415c9ce..ba0ba3d9c7 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -7,7 +7,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 0d29df72bf..7452b8996a 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -13,7 +13,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 78ffb2e9f1..a195468c84 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -9,7 +9,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 2bb872874b..7544d666c6 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -9,7 +9,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index 48910dbee2..ec6231b1b2 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -5,7 +5,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index 6164217a65..9bc1c3b52a 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -6,7 +6,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 8aab80db72..3ab628959d 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -5,7 +5,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index d65696668e..fc90256232 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -7,7 +7,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index ff6136a643..f9d75fff37 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -14,7 +14,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e28fc59136..ed165e56b0 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -14,7 +14,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 42ad462ee7..87f088c0ef 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -9,7 +9,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index c9ff9697e0..2f58fe39b8 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -10,7 +10,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 464ca36f3c..94bc0f80aa 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -10,7 +10,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 1d370d3847..ce5c37ca0d 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -9,7 +9,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index e36df7ac93..006f58e793 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -5,7 +5,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 433abf06a8..a8009cf71f 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -9,7 +9,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_unixinfo_nt.c b/source3/rpc_server/srv_unixinfo_nt.c index 565d96e1fc..868f8e130a 100644 --- a/source3/rpc_server/srv_unixinfo_nt.c +++ b/source3/rpc_server/srv_unixinfo_nt.c @@ -5,7 +5,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index 924e08cc23..a209bb1da4 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -8,7 +8,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 1fa61c27ca..76517c181c 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -6,7 +6,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 1a827b265b..51080fbd0f 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -7,7 +7,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/rpc_server/srv_samr_util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 87f088c0ef..7bac25e611 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -18,8 +18,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 153cfb9c83534b09f15cc16205d7adb19b394928 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 05:23:25 +0000 Subject: r23801: The FSF has moved around a lot. This fixes their Mass Ave address. (This used to be commit 87c91e4362c51819032bfbebbb273c52e203b227) --- source3/rpc_server/srv_dfs_nt.c | 3 +-- source3/rpc_server/srv_echo_nt.c | 3 +-- source3/rpc_server/srv_epmapper_nt.c | 3 +-- source3/rpc_server/srv_eventlog.c | 3 +-- source3/rpc_server/srv_eventlog_lib.c | 3 +-- source3/rpc_server/srv_eventlog_nt.c | 3 +-- source3/rpc_server/srv_initshutdown_nt.c | 3 +-- source3/rpc_server/srv_lsa.c | 3 +-- source3/rpc_server/srv_lsa_ds.c | 3 +-- source3/rpc_server/srv_lsa_ds_nt.c | 3 +-- source3/rpc_server/srv_lsa_hnd.c | 3 +-- source3/rpc_server/srv_lsa_nt.c | 3 +-- source3/rpc_server/srv_netlog.c | 3 +-- source3/rpc_server/srv_netlog_nt.c | 3 +-- source3/rpc_server/srv_ntsvcs.c | 3 +-- source3/rpc_server/srv_ntsvcs_nt.c | 3 +-- source3/rpc_server/srv_pipe.c | 3 +-- source3/rpc_server/srv_pipe_hnd.c | 3 +-- source3/rpc_server/srv_samr.c | 3 +-- source3/rpc_server/srv_samr_nt.c | 3 +-- source3/rpc_server/srv_spoolss.c | 3 +-- source3/rpc_server/srv_spoolss_nt.c | 3 +-- source3/rpc_server/srv_srvsvc_nt.c | 3 +-- source3/rpc_server/srv_svcctl.c | 3 +-- source3/rpc_server/srv_svcctl_nt.c | 3 +-- source3/rpc_server/srv_unixinfo_nt.c | 3 +-- source3/rpc_server/srv_util.c | 3 +-- source3/rpc_server/srv_winreg_nt.c | 3 +-- source3/rpc_server/srv_wkssvc_nt.c | 3 +-- 29 files changed, 29 insertions(+), 58 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index e00ea88015..468a3c4996 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -16,8 +16,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* This is the implementation of the dfs pipe. */ diff --git a/source3/rpc_server/srv_echo_nt.c b/source3/rpc_server/srv_echo_nt.c index 155fe14516..58c59aa506 100644 --- a/source3/rpc_server/srv_echo_nt.c +++ b/source3/rpc_server/srv_echo_nt.c @@ -16,8 +16,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* This is the interface to the rpcecho pipe. */ diff --git a/source3/rpc_server/srv_epmapper_nt.c b/source3/rpc_server/srv_epmapper_nt.c index 67aaa0793d..405769072b 100644 --- a/source3/rpc_server/srv_epmapper_nt.c +++ b/source3/rpc_server/srv_epmapper_nt.c @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* This is the implementation of the dfs pipe. */ diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c index a1acf1f25f..34914dc9d2 100644 --- a/source3/rpc_server/srv_eventlog.c +++ b/source3/rpc_server/srv_eventlog.c @@ -15,8 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ #include "includes.h" diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 7061df650f..f21e983eb7 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -16,8 +16,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ #include "includes.h" diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 76e8760d6d..32940b3417 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -16,8 +16,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ #include "includes.h" diff --git a/source3/rpc_server/srv_initshutdown_nt.c b/source3/rpc_server/srv_initshutdown_nt.c index 1d3d67f4ef..f7d299830d 100644 --- a/source3/rpc_server/srv_initshutdown_nt.c +++ b/source3/rpc_server/srv_initshutdown_nt.c @@ -15,8 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* Implementation of registry functions. */ diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 157f819a37..571d3484fb 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -19,8 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* This is the interface to the lsa server code. */ diff --git a/source3/rpc_server/srv_lsa_ds.c b/source3/rpc_server/srv_lsa_ds.c index 3c1a952d3a..52fd06cd51 100644 --- a/source3/rpc_server/srv_lsa_ds.c +++ b/source3/rpc_server/srv_lsa_ds.c @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* This is the interface for the registry functions. */ diff --git a/source3/rpc_server/srv_lsa_ds_nt.c b/source3/rpc_server/srv_lsa_ds_nt.c index 9fcf05fe67..994b3cccca 100644 --- a/source3/rpc_server/srv_lsa_ds_nt.c +++ b/source3/rpc_server/srv_lsa_ds_nt.c @@ -18,8 +18,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* Implementation of registry functions. */ diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index ba0ba3d9c7..7250da7d0c 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -16,8 +16,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ #include "includes.h" diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 7452b8996a..1f9c245723 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -22,8 +22,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* This is the implementation of the lsa server code. */ diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index a195468c84..3f2dbe6747 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -18,8 +18,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* This is the interface to the netlogon pipe. */ diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 7544d666c6..3f1b0916df 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -18,8 +18,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* This is the implementation of the netlogon pipe. */ diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index ec6231b1b2..9d4c02500f 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ #include "includes.h" diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index 9bc1c3b52a..16c74c5d6d 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -15,8 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ #include "includes.h" diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 3ab628959d..7493aaddb9 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* this module apparently provides an implementation of DCE/RPC over a diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index fc90256232..c4c028fd4b 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -16,8 +16,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ #include "includes.h" diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index f9d75fff37..d717bb6bb8 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -23,8 +23,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ed165e56b0..e95fd0c7f9 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -23,8 +23,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 2f58fe39b8..32e0c6e4ed 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -19,8 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ #include "includes.h" diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 94bc0f80aa..f8e109fb34 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -19,8 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* Since the SPOOLSS rpc routines are basically DOS 16-bit calls wrapped diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index ce5c37ca0d..ed32f6a765 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -18,8 +18,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* This is the implementation of the srvsvc pipe. */ diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 006f58e793..cc8de13562 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ #include "includes.h" diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index a8009cf71f..6d807f3ee8 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -18,8 +18,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ #include "includes.h" diff --git a/source3/rpc_server/srv_unixinfo_nt.c b/source3/rpc_server/srv_unixinfo_nt.c index 868f8e130a..e9680247ae 100644 --- a/source3/rpc_server/srv_unixinfo_nt.c +++ b/source3/rpc_server/srv_unixinfo_nt.c @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* This is the interface to the rpcunixinfo pipe. */ diff --git a/source3/rpc_server/srv_util.c b/source3/rpc_server/srv_util.c index a209bb1da4..d4804b98ad 100644 --- a/source3/rpc_server/srv_util.c +++ b/source3/rpc_server/srv_util.c @@ -17,8 +17,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* this module apparently provides an implementation of DCE/RPC over a diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 76517c181c..fe3295e7e9 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -15,8 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* Implementation of registry functions. */ diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 51080fbd0f..417ce8e761 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -16,8 +16,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * along with this program; if not, see . */ /* This is the implementation of the wks interface. */ -- cgit From ece86db24cd82b086de69e9681de4fb1f391cc2e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 22 Jul 2007 13:51:39 +0000 Subject: r23991: Some const (This used to be commit 804be77e4695eb923048948dbc6e223967fdef94) --- source3/rpc_server/srv_pipe_hnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index c4c028fd4b..52518fc714 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1246,7 +1246,7 @@ static BOOL close_internal_rpc_pipe_hnd(void *np_conn) Find an rpc pipe given a pipe handle in a buffer and an offset. ****************************************************************************/ -smb_np_struct *get_rpc_pipe_p(char *buf, int where) +smb_np_struct *get_rpc_pipe_p(const char *buf, int where) { int pnum = SVAL(buf,where); -- cgit From bfbd75653581ab21ce3f26b006c00389b7939bd7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 31 Jul 2007 13:14:07 +0000 Subject: r24106: Pass fnum instead of buf/offset into get_rpc_pipe_p (This used to be commit eb353412c60fc21a31530d9678505470ffbf11ce) --- source3/rpc_server/srv_pipe_hnd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 52518fc714..5dd28af8ab 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1246,10 +1246,8 @@ static BOOL close_internal_rpc_pipe_hnd(void *np_conn) Find an rpc pipe given a pipe handle in a buffer and an offset. ****************************************************************************/ -smb_np_struct *get_rpc_pipe_p(const char *buf, int where) +smb_np_struct *get_rpc_pipe_p(uint16 pnum) { - int pnum = SVAL(buf,where); - if (chain_p) { return chain_p; } -- cgit From d7b7ef4a3375cd3302fbab4c208e3dddc4e4a037 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 4 Aug 2007 10:18:33 +0000 Subject: r24165: Fix Coverity ID 369. This was not really a bug I think, but this change cleans up the code a bit. (This used to be commit 59b4914df3ecc97a1c629e8c7a066aed8e8d9226) --- source3/rpc_server/srv_lsa_nt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 1f9c245723..40d5005c4f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1517,16 +1517,16 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU SAFE_FREE(sid_list); return NT_STATUS_NO_MEMORY; } + + for (i = q_u->enum_context, j = 0; i < num_entries; i++, j++) { + init_dom_sid2(&(*sids).sid[j], &sid_list[i]); + (*sids).ptr_sid[j] = 1; + } } else { sids->ptr_sid = NULL; sids->sid = NULL; } - for (i = q_u->enum_context, j = 0; i < num_entries; i++, j++) { - init_dom_sid2(&(*sids).sid[j], &sid_list[i]); - (*sids).ptr_sid[j] = 1; - } - talloc_free(sid_list); init_lsa_r_enum_accounts(r_u, num_entries); -- cgit From 22b30d2a372bc9a018c592991a6478dc963e670d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 10 Aug 2007 20:03:31 +0000 Subject: r24316: Fix an uninitialized read Jerry, please check this! Thanks, Volker (This used to be commit db1b89072c3f214c3cb4be844cd7b417e5361615) --- source3/rpc_server/srv_spoolss_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f8e109fb34..b50e1e7558 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2275,6 +2275,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint *type = REG_DWORD; if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) ) return WERR_NOMEM; + SIVAL(*data, 0, 0x00); *needed = 0x4; return WERR_OK; } -- cgit From 8da26d3f96ac66e3f0be8aaec209867d3f285e49 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 19 Aug 2007 22:10:11 +0000 Subject: r24561: merge from SAMBA_4_0: rename some DCERPC_ prefixes into NDR_ metze (This used to be commit 8f07b8ab658ae3d63487ca5fb20065318cdd9d0e) --- source3/rpc_server/srv_eventlog.c | 2 +- source3/rpc_server/srv_lsa.c | 12 ++++++------ source3/rpc_server/srv_svcctl.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c index 34914dc9d2..fcba6a1268 100644 --- a/source3/rpc_server/srv_eventlog.c +++ b/source3/rpc_server/srv_eventlog.c @@ -67,7 +67,7 @@ static BOOL api_eventlog_open_eventlog(pipes_struct *p) static BOOL api_eventlog_close_eventlog(pipes_struct *p) { - return proxy_eventlog_call( p, DCERPC_EVENTLOG_CLOSEEVENTLOG ); + return proxy_eventlog_call( p, NDR_EVENTLOG_CLOSEEVENTLOG ); } static BOOL api_eventlog_get_num_records(pipes_struct *p) diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 571d3484fb..484e964068 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -234,7 +234,7 @@ static BOOL api_lsa_lookup_names(pipes_struct *p) static BOOL api_lsa_close(pipes_struct *p) { - return proxy_lsa_call(p, DCERPC_LSA_CLOSE); + return proxy_lsa_call(p, NDR_LSA_CLOSE); } /*************************************************************************** @@ -243,7 +243,7 @@ static BOOL api_lsa_close(pipes_struct *p) static BOOL api_lsa_open_secret(pipes_struct *p) { - return proxy_lsa_call(p, DCERPC_LSA_OPENSECRET); + return proxy_lsa_call(p, NDR_LSA_OPENSECRET); } /*************************************************************************** @@ -745,7 +745,7 @@ static BOOL api_lsa_lookup_priv_value(pipes_struct *p) static BOOL api_lsa_open_trust_dom(pipes_struct *p) { - return proxy_lsa_call(p, DCERPC_LSA_OPENTRUSTEDDOMAIN); + return proxy_lsa_call(p, NDR_LSA_OPENTRUSTEDDOMAIN); } /*************************************************************************** @@ -753,7 +753,7 @@ static BOOL api_lsa_open_trust_dom(pipes_struct *p) static BOOL api_lsa_create_trust_dom(pipes_struct *p) { - return proxy_lsa_call(p, DCERPC_LSA_CREATETRUSTEDDOMAIN); + return proxy_lsa_call(p, NDR_LSA_CREATETRUSTEDDOMAIN); } /*************************************************************************** @@ -761,7 +761,7 @@ static BOOL api_lsa_create_trust_dom(pipes_struct *p) static BOOL api_lsa_create_secret(pipes_struct *p) { - return proxy_lsa_call(p, DCERPC_LSA_CREATESECRET); + return proxy_lsa_call(p, NDR_LSA_CREATESECRET); } /*************************************************************************** @@ -769,7 +769,7 @@ static BOOL api_lsa_create_secret(pipes_struct *p) static BOOL api_lsa_set_secret(pipes_struct *p) { - return proxy_lsa_call(p, DCERPC_LSA_SETSECRET); + return proxy_lsa_call(p, NDR_LSA_SETSECRET); } /*************************************************************************** diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index cc8de13562..fcaf37e8ee 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -45,7 +45,7 @@ static BOOL proxy_svcctl_call(pipes_struct *p, uint8 opnum) static BOOL api_svcctl_close_service(pipes_struct *p) { - return proxy_svcctl_call( p, DCERPC_SVCCTL_CLOSESERVICEHANDLE ); + return proxy_svcctl_call( p, NDR_SVCCTL_CLOSESERVICEHANDLE ); } /******************************************************************* -- cgit From 929e1d99209e20a9c2c95c8bdfc8eaa37b2c2291 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 30 Aug 2007 19:48:31 +0000 Subject: r24809: Consolidate the use of temporary talloc contexts. This adds the two functions talloc_stackframe() and talloc_tos(). * When a new talloc stackframe is allocated with talloc_stackframe(), then * the TALLOC_CTX returned with talloc_tos() is reset to that new * frame. Whenever that stack frame is TALLOC_FREE()'ed, then the reverse * happens: The previous talloc_tos() is restored. * * This API is designed to be robust in the sense that if someone forgets to * TALLOC_FREE() a stackframe, then the next outer one correctly cleans up and * resets the talloc_tos(). The original motivation for this patch was to get rid of the sid_string_static & friends buffers. Explicitly passing talloc context everywhere clutters code too much for my taste, so an implicit talloc_tos() is introduced here. Many of these static buffers are replaced by a single static pointer. The intended use would thus be that low-level functions can rather freely push stuff to talloc_tos, the upper layers clean up by freeing the stackframe. The more of these stackframes are used and correctly freed the more exact the memory cleanup happens. This patch removes the main_loop_talloc_ctx, tmp_talloc_ctx and lp_talloc_ctx (did I forget any?) So, never do a tmp_ctx = talloc_init("foo"); anymore, instead, use tmp_ctx = talloc_stackframe() :-) Volker (This used to be commit 6585ea2cb7f417e14540495b9c7380fe9c8c717b) --- source3/rpc_server/srv_pipe.c | 4 ++-- source3/rpc_server/srv_spoolss_nt.c | 6 +++--- source3/rpc_server/srv_srvsvc_nt.c | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 7493aaddb9..fefdb529b2 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2240,9 +2240,9 @@ BOOL api_pipe_request(pipes_struct *p) pipe_fns = find_pipe_fns_by_context(p->contexts, p->hdr_req.context_id); if ( pipe_fns ) { - set_current_rpc_talloc(p->mem_ctx); + TALLOC_CTX *frame = talloc_stackframe(); ret = api_rpcTNP(p, p->name, pipe_fns->cmds, pipe_fns->n_cmds); - set_current_rpc_talloc(NULL); + TALLOC_FREE(frame); } else { DEBUG(0,("api_pipe_request: No rpc function table associated with context [%d] on pipe [%s]\n", diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b50e1e7558..600eb2f688 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -389,7 +389,7 @@ static BOOL get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number, DEBUG(4,("short name:%s\n", Printer->sharename)); *number = print_queue_snum(Printer->sharename); if ((*number != -1) && (params != NULL)) { - *params = get_share_params(tmp_talloc_ctx(), + *params = get_share_params(talloc_tos(), Printer->sharename); if (*params == NULL) { return False; @@ -4257,7 +4257,7 @@ static BOOL construct_printer_info_2(Printer_entry *print_hnd, /* don't use talloc_steal() here unless you do a deep steal of all the SEC_DESC members */ - printer->secdesc = dup_sec_desc( get_talloc_ctx(), + printer->secdesc = dup_sec_desc( talloc_tos(), ntprinter->info_2->secdesc_buf->sd ); } @@ -4297,7 +4297,7 @@ static BOOL construct_printer_info_3(Printer_entry *print_hnd, /* don't use talloc_steal() here unless you do a deep steal of all the SEC_DESC members */ - printer->secdesc = dup_sec_desc( get_talloc_ctx(), + printer->secdesc = dup_sec_desc( talloc_tos(), ntprinter->info_2->secdesc_buf->sd ); } diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index ed32f6a765..22eaac51a7 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1049,7 +1049,6 @@ static WERROR init_srv_conn_info_ctr(pipes_struct *p, union srvsvc_NetConnCtr *c static WERROR net_file_enum_3(pipes_struct *p, union srvsvc_NetFileCtr *ctr, uint32 *resume_hnd, uint32 *num_entries ) { - TALLOC_CTX *ctx = get_talloc_ctx(); WERROR status; /* TODO -- Windows enumerates @@ -1058,11 +1057,11 @@ static WERROR net_file_enum_3(pipes_struct *p, union srvsvc_NetFileCtr *ctr, uin ctr->ctr3 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetFileCtr3); - status = net_enum_files( ctx, &ctr->ctr3->array, num_entries, resume_hnd ); + status = net_enum_files(p->mem_ctx, &ctr->ctr3->array, num_entries, resume_hnd ); if ( !W_ERROR_IS_OK(status)) return status; - status = net_enum_pipes( ctx, &ctr->ctr3->array, num_entries, resume_hnd ); + status = net_enum_pipes(p->mem_ctx, &ctr->ctr3->array, num_entries, resume_hnd ); if ( !W_ERROR_IS_OK(status)) return status; -- cgit From 132ee3990af5d31573978f5a3abf43db2303880b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 7 Sep 2007 20:57:01 +0000 Subject: r25009: Large patch discussed with Volker. Move unix_convert to a talloc-based interface. More development will come on top of this. Remove the "mangled map" parameter. Jeremy. (This used to be commit dee8beba7a92b8a3f68bbcc59fd0a827f68c7736) --- source3/rpc_server/srv_srvsvc_nt.c | 42 ++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 22eaac51a7..4be519a9a3 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2047,7 +2047,7 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecur connection_struct *conn = NULL; BOOL became_user = False; WERROR status = WERR_OK; - pstring tmp_file; + char *tmp_file = NULL; ZERO_STRUCT(st); @@ -2072,26 +2072,29 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecur } became_user = True; - pstrcpy(tmp_file, r->in.file); - nt_status = unix_convert(conn, tmp_file, False, NULL, &st); + if (!r->in.file) { + status = WERR_INVALID_PARAM; + goto error_exit; + } + nt_status = unix_convert(conn, r->in.file, False, &tmp_file, NULL, &st); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", r->in.file)); status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = check_name(conn, r->in.file); + nt_status = check_name(conn, tmp_file); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", r->in.file)); + DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", tmp_file)); status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = open_file_stat(conn, NULL, r->in.file, &st, &fsp); + nt_status = open_file_stat(conn, NULL, tmp_file, &st, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { /* Perhaps it is a directory */ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) - nt_status = open_directory(conn, NULL, r->in.file, &st, + nt_status = open_directory(conn, NULL, tmp_file, &st, READ_CONTROL_ACCESS, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, @@ -2100,7 +2103,7 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecur NULL, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", r->in.file)); + DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", tmp_file)); status = WERR_ACCESS_DENIED; goto error_exit; } @@ -2109,7 +2112,7 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecur sd_size = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION), &psd); if (sd_size == 0) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", r->in.file)); + DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", tmp_file)); status = WERR_ACCESS_DENIED; goto error_exit; } @@ -2152,7 +2155,7 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecur connection_struct *conn = NULL; BOOL became_user = False; WERROR status = WERR_OK; - pstring tmp_file; + char *tmp_file = NULL; ZERO_STRUCT(st); @@ -2176,28 +2179,31 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecur } became_user = True; - pstrcpy(tmp_file, r->in.file); - nt_status = unix_convert(conn, tmp_file, False, NULL, &st); + if (!r->in.file) { + status = WERR_INVALID_PARAM; + goto error_exit; + } + nt_status = unix_convert(conn, r->in.file, False, &tmp_file, NULL, &st); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", r->in.file)); status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = check_name(conn, r->in.file); + nt_status = check_name(conn, tmp_file); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", r->in.file)); + DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", tmp_file)); status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = open_file_stat(conn, NULL, r->in.file, &st, &fsp); + nt_status = open_file_stat(conn, NULL, tmp_file, &st, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { /* Perhaps it is a directory */ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) - nt_status = open_directory(conn, NULL, r->in.file, &st, + nt_status = open_directory(conn, NULL, tmp_file, &st, FILE_READ_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, @@ -2206,7 +2212,7 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecur NULL, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", r->in.file)); + DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", tmp_file)); status = WERR_ACCESS_DENIED; goto error_exit; } @@ -2215,7 +2221,7 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecur nt_status = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, r->in.securityinformation, r->in.sd_buf.sd); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", r->in.file)); + DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", tmp_file)); status = WERR_ACCESS_DENIED; goto error_exit; } -- cgit From fe6644fb5a6097d5e16e2c7667fb49dee1fa94ae Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 8 Sep 2007 05:35:10 +0000 Subject: r25023: Coverity #455. Not actually a bug, but this clarifies the code a lot. Jeremy. (This used to be commit 5ba12eefbed209a8a6b474da479efd190f91638e) --- source3/rpc_server/srv_pipe_hnd.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 5dd28af8ab..fac3df453a 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1033,6 +1033,7 @@ static ssize_t read_from_internal_pipe(void *np_conn, char *data, size_t n, if(n > RPC_MAX_PDU_FRAG_LEN) { 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, RPC_MAX_PDU_FRAG_LEN )); + n = RPC_MAX_PDU_FRAG_LEN; } /* -- cgit From 351eb37a2555ce474ee02758f2f2cfee33d4d434 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 11 Sep 2007 18:31:29 +0000 Subject: r25102: Rewrite msdfs code to use talloced filenames. Passes make test and make valgrindtest. Final step will be to change srvstr_get_path() to return talloced memory in the major codepaths. Jeremy. (This used to be commit cf6b6f9c3a38b68d2671c753f412772344506742) --- source3/rpc_server/srv_dfs_nt.c | 208 ++++++++++++++++++++++++---------------- 1 file changed, 125 insertions(+), 83 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 468a3c4996..1ce81a76f9 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -1,20 +1,20 @@ -/* +/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines for Dfs * Copyright (C) Shirish Kalele 2000. - * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Jeremy Allison 2001-2007. * Copyright (C) Jelmer Vernooij 2005-2006. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ @@ -40,53 +40,68 @@ void _dfs_GetManagerVersion(pipes_struct *p, struct dfs_GetManagerVersion *r) WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) { - struct junction_map jn; - struct referral* old_referral_list = NULL; + struct junction_map *jn = NULL; + struct referral *old_referral_list = NULL; BOOL self_ref = False; int consumedcnt = 0; BOOL exists = False; - - pstring altpath; + char *altpath = NULL; + NTSTATUS status; + TALLOC_CTX *ctx = talloc_tos(); if (p->pipe_user.ut.uid != 0) { DEBUG(10,("_dfs_add: uid != 0. Access denied.\n")); return WERR_ACCESS_DENIED; } + jn = TALLOC_ZERO_P(ctx, struct junction_map); + if (!jn) { + return WERR_NOMEM; + } + DEBUG(5,("init_reply_dfs_add: Request to add %s -> %s\\%s.\n", r->in.path, r->in.server, r->in.share)); - pstrcpy(altpath, r->in.server); - pstrcat(altpath, "\\"); - pstrcat(altpath, r->in.share); + altpath = talloc_asprintf(ctx, "%s\\%s", + r->in.server, + r->in.share); + if (!altpath) { + return WERR_NOMEM; + } /* The following call can change the cwd. */ - if(NT_STATUS_IS_OK(get_referred_path(p->mem_ctx, r->in.path, &jn, &consumedcnt, &self_ref))) { - exists = True; - jn.referral_count += 1; - old_referral_list = jn.referral_list; - } else { - jn.referral_count = 1; + status = get_referred_path(ctx, r->in.path, jn, + &consumedcnt, &self_ref); + if(!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); } + exists = True; + jn->referral_count += 1; + old_referral_list = jn->referral_list; + vfs_ChDir(p->conn,p->conn->connectpath); - jn.referral_list = TALLOC_ARRAY(p->mem_ctx, struct referral, jn.referral_count); - if(jn.referral_list == NULL) { + if (jn->referral_count < 1) { + return WERR_NOMEM; + } + + jn->referral_list = TALLOC_ARRAY(ctx, struct referral, jn->referral_count); + if(jn->referral_list == NULL) { DEBUG(0,("init_reply_dfs_add: talloc failed for referral list!\n")); return WERR_DFS_INTERNAL_ERROR; } - if(old_referral_list) { - memcpy(jn.referral_list, old_referral_list, sizeof(struct referral)*jn.referral_count-1); + if(old_referral_list && jn->referral_list) { + memcpy(jn->referral_list, old_referral_list, + sizeof(struct referral)*jn->referral_count-1); } - - jn.referral_list[jn.referral_count-1].proximity = 0; - jn.referral_list[jn.referral_count-1].ttl = REFERRAL_TTL; - pstrcpy(jn.referral_list[jn.referral_count-1].alternate_path, altpath); - - if(!create_msdfs_link(&jn, exists)) { + jn->referral_list[jn->referral_count-1].proximity = 0; + jn->referral_list[jn->referral_count-1].ttl = REFERRAL_TTL; + jn->referral_list[jn->referral_count-1].alternate_path = altpath; + + if(!create_msdfs_link(jn, exists)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_CANT_CREATE_JUNCT; } @@ -97,35 +112,43 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) { - struct junction_map jn; + struct junction_map *jn = NULL; BOOL self_ref = False; int consumedcnt = 0; BOOL found = False; - - pstring altpath; + TALLOC_CTX *ctx = talloc_tos(); + char *altpath = NULL; if (p->pipe_user.ut.uid != 0) { DEBUG(10,("_dfs_remove: uid != 0. Access denied.\n")); return WERR_ACCESS_DENIED; } + jn = TALLOC_ZERO_P(ctx, struct junction_map); + if (!jn) { + return WERR_NOMEM; + } + if (r->in.servername && r->in.sharename) { - pstrcpy(altpath, r->in.servername); - pstrcat(altpath, "\\"); - pstrcat(altpath, r->in.sharename); + altpath = talloc_asprintf(ctx, "%s\\%s", + r->in.servername, + r->in.sharename); strlower_m(altpath); + if (!altpath) { + return WERR_NOMEM; + } + DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n", + r->in.dfs_entry_path, r->in.servername, r->in.sharename)); } - DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n", - r->in.dfs_entry_path, r->in.servername, r->in.sharename)); - - if(!NT_STATUS_IS_OK(get_referred_path(p->mem_ctx, r->in.dfs_entry_path, &jn, &consumedcnt, &self_ref))) { + if(!NT_STATUS_IS_OK(get_referred_path(ctx, r->in.dfs_entry_path, jn, + &consumedcnt, &self_ref))) { return WERR_DFS_NO_SUCH_VOL; } /* if no server-share pair given, remove the msdfs link completely */ if(!r->in.servername && !r->in.sharename) { - if(!remove_msdfs_link(&jn)) { + if(!remove_msdfs_link(jn)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; } @@ -133,14 +156,17 @@ WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) } else { 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;ireferral_count)); + for(i=0;ireferral_count;i++) { + char *refpath = talloc_strdup(ctx, + jn->referral_list[i].alternate_path); + if (!refpath) { + return WERR_NOMEM; + } trim_char(refpath, '\\', '\\'); DEBUG(10,("_dfs_remove: refpath: .%s.\n", refpath)); if(strequal(refpath, altpath)) { - *(jn.referral_list[i].alternate_path)='\0'; + *(jn->referral_list[i].alternate_path)='\0'; DEBUG(10,("_dfs_remove: Removal request matches referral %s\n", refpath)); found = True; @@ -152,13 +178,13 @@ WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) } /* Only one referral, remove it */ - if(jn.referral_count == 1) { - if(!remove_msdfs_link(&jn)) { + if(jn->referral_count == 1) { + if(!remove_msdfs_link(jn)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; } } else { - if(!create_msdfs_link(&jn, True)) { + if(!create_msdfs_link(jn, True)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_CANT_CREATE_JUNCT; } @@ -169,10 +195,10 @@ WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) return WERR_OK; } -static BOOL init_reply_dfs_info_1(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info1* dfs1) +static BOOL init_reply_dfs_info_1(TALLOC_CTX *mem_ctx, struct junction_map* j,struct dfs_Info1* dfs1) { - dfs1->path = talloc_asprintf(mem_ctx, - "\\\\%s\\%s\\%s", global_myname(), + dfs1->path = talloc_asprintf(mem_ctx, + "\\\\%s\\%s\\%s", global_myname(), j->service_name, j->volume_name); if (dfs1->path == NULL) return False; @@ -183,7 +209,7 @@ static BOOL init_reply_dfs_info_1(TALLOC_CTX *mem_ctx, struct junction_map* j, s static BOOL init_reply_dfs_info_2(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info2* dfs2) { - dfs2->path = talloc_asprintf(mem_ctx, + dfs2->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s\\%s", global_myname(), j->service_name, j->volume_name); if (dfs2->path == NULL) return False; @@ -209,7 +235,7 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *mem_ctx, struct junction_map* j, s dfs3->comment = talloc_strdup(mem_ctx, j->comment); dfs3->state = 1; dfs3->num_stores = j->referral_count; - + /* also enumerate the stores */ if (j->referral_count) { dfs3->stores = TALLOC_ARRAY(mem_ctx, struct dfs_StorageInfo, j->referral_count); @@ -221,12 +247,15 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *mem_ctx, struct junction_map* j, s } for(ii=0;iireferral_count;ii++) { - char* p; - pstring path; - struct dfs_StorageInfo* stor = &(dfs3->stores[ii]); + char* p; + char *path = NULL; + struct dfs_StorageInfo* stor = &(dfs3->stores[ii]); struct referral* ref = &(j->referral_list[ii]); - - pstrcpy(path, ref->alternate_path); + + path = talloc_strdup(mem_ctx, ref->alternate_path); + if (!path) { + return False; + } trim_char(path,'\\','\0'); p = strrchr_m(path,'\\'); if(p==NULL) { @@ -248,16 +277,20 @@ static BOOL init_reply_dfs_info_100(TALLOC_CTX *mem_ctx, struct junction_map* j, return True; } - WERROR _dfs_Enum(pipes_struct *p, struct dfs_Enum *r) { - struct junction_map jn[MAX_MSDFS_JUNCTIONS]; - int num_jn = 0; - int i; - - num_jn = enum_msdfs_links(p->mem_ctx, jn, ARRAY_SIZE(jn)); + struct junction_map *jn = NULL; + size_t num_jn = 0; + size_t i; + TALLOC_CTX *ctx = talloc_tos(); + + jn = enum_msdfs_links(ctx, &num_jn); + if (!jn || num_jn == 0) { + num_jn = 0; + jn = NULL; + } vfs_ChDir(p->conn,p->conn->connectpath); - + DEBUG(5,("_dfs_Enum: %d junctions found in Dfs, doing level %d\n", num_jn, r->in.level)); *r->out.total = num_jn; @@ -266,7 +299,7 @@ WERROR _dfs_Enum(pipes_struct *p, struct dfs_Enum *r) switch (r->in.level) { case 1: if (num_jn) { - if ((r->out.info->e.info1->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info1, num_jn)) == NULL) { + if ((r->out.info->e.info1->s = TALLOC_ARRAY(ctx, struct dfs_Info1, num_jn)) == NULL) { return WERR_NOMEM; } } else { @@ -276,7 +309,7 @@ WERROR _dfs_Enum(pipes_struct *p, struct dfs_Enum *r) break; case 2: if (num_jn) { - if ((r->out.info->e.info2->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info2, num_jn)) == NULL) { + if ((r->out.info->e.info2->s = TALLOC_ARRAY(ctx, struct dfs_Info2, num_jn)) == NULL) { return WERR_NOMEM; } } else { @@ -286,7 +319,7 @@ WERROR _dfs_Enum(pipes_struct *p, struct dfs_Enum *r) break; case 3: if (num_jn) { - if ((r->out.info->e.info3->s = TALLOC_ARRAY(p->mem_ctx, struct dfs_Info3, num_jn)) == NULL) { + if ((r->out.info->e.info3->s = TALLOC_ARRAY(ctx, struct dfs_Info3, num_jn)) == NULL) { return WERR_NOMEM; } } else { @@ -300,35 +333,44 @@ WERROR _dfs_Enum(pipes_struct *p, struct dfs_Enum *r) for (i = 0; i < num_jn; i++) { switch (r->in.level) { - case 1: - init_reply_dfs_info_1(p->mem_ctx, &jn[i], &r->out.info->e.info1->s[i]); + case 1: + init_reply_dfs_info_1(ctx, &jn[i], &r->out.info->e.info1->s[i]); break; case 2: - init_reply_dfs_info_2(p->mem_ctx, &jn[i], &r->out.info->e.info2->s[i]); + init_reply_dfs_info_2(ctx, &jn[i], &r->out.info->e.info2->s[i]); break; case 3: - init_reply_dfs_info_3(p->mem_ctx, &jn[i], &r->out.info->e.info3->s[i]); + init_reply_dfs_info_3(ctx, &jn[i], &r->out.info->e.info3->s[i]); break; default: return WERR_INVALID_PARAM; } } - + return WERR_OK; } WERROR _dfs_GetInfo(pipes_struct *p, struct dfs_GetInfo *r) { - int consumedcnt = sizeof(pstring); - struct junction_map jn; + int consumedcnt = strlen(r->in.dfs_entry_path); + struct junction_map *jn = NULL; BOOL self_ref = False; + TALLOC_CTX *ctx = talloc_tos(); BOOL ret; - if(!create_junction(r->in.dfs_entry_path, &jn)) + jn = TALLOC_ZERO_P(ctx, struct junction_map); + if (!jn) { + return WERR_NOMEM; + } + + if(!create_junction(ctx, r->in.dfs_entry_path, jn)) { return WERR_DFS_NO_SUCH_SERVER; - + } + /* The following call can change the cwd. */ - if(!NT_STATUS_IS_OK(get_referred_path(p->mem_ctx, r->in.dfs_entry_path, &jn, &consumedcnt, &self_ref)) || consumedcnt < strlen(r->in.dfs_entry_path)) { + if(!NT_STATUS_IS_OK(get_referred_path(ctx, r->in.dfs_entry_path, + jn, &consumedcnt, &self_ref)) || + consumedcnt < strlen(r->in.dfs_entry_path)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; } @@ -336,18 +378,18 @@ WERROR _dfs_GetInfo(pipes_struct *p, struct dfs_GetInfo *r) vfs_ChDir(p->conn,p->conn->connectpath); switch (r->in.level) { - case 1: ret = init_reply_dfs_info_1(p->mem_ctx, &jn, r->out.info->info1); break; - case 2: ret = init_reply_dfs_info_2(p->mem_ctx, &jn, r->out.info->info2); break; - case 3: ret = init_reply_dfs_info_3(p->mem_ctx, &jn, r->out.info->info3); break; - case 100: ret = init_reply_dfs_info_100(p->mem_ctx, &jn, r->out.info->info100); break; + case 1: ret = init_reply_dfs_info_1(ctx, jn, r->out.info->info1); break; + case 2: ret = init_reply_dfs_info_2(ctx, jn, r->out.info->info2); break; + case 3: ret = init_reply_dfs_info_3(ctx, jn, r->out.info->info3); break; + case 100: ret = init_reply_dfs_info_100(ctx, jn, r->out.info->info100); break; default: r->out.info->info1 = NULL; return WERR_INVALID_PARAM; } - if (!ret) + if (!ret) return WERR_INVALID_PARAM; - + return WERR_OK; } -- cgit From d5c9d87946263b5f3e3c072aa99e8ac6a6c728b9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 12 Sep 2007 23:50:21 +0000 Subject: r25118: More pstring elimination. Jeremy. (This used to be commit 7632f8fb4003657591778d2b55f546d1737859d1) --- source3/rpc_server/srv_pipe_hnd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index fac3df453a..0dd3ee82a7 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -65,7 +65,7 @@ static ssize_t read_from_internal_pipe(void *np_conn, char *data, size_t n, BOOL *is_data_outstanding); static ssize_t write_to_internal_pipe(void *np_conn, char *data, size_t n); static BOOL close_internal_rpc_pipe_hnd(void *np_conn); -static void *make_internal_rpc_pipe_p(char *pipe_name, +static void *make_internal_rpc_pipe_p(const char *pipe_name, connection_struct *conn, uint16 vuid); /**************************************************************************** @@ -167,7 +167,7 @@ static BOOL pipe_init_outgoing_data(pipes_struct *p) Find first available pipe slot. ****************************************************************************/ -smb_np_struct *open_rpc_pipe_p(char *pipe_name, +smb_np_struct *open_rpc_pipe_p(const char *pipe_name, connection_struct *conn, uint16 vuid) { int i; @@ -275,7 +275,7 @@ smb_np_struct *open_rpc_pipe_p(char *pipe_name, Make an internal namedpipes structure ****************************************************************************/ -static void *make_internal_rpc_pipe_p(char *pipe_name, +static void *make_internal_rpc_pipe_p(const char *pipe_name, connection_struct *conn, uint16 vuid) { pipes_struct *p; -- cgit From ad26e7c4a3355e40d262a26c8cc89b09aee1c776 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 13 Sep 2007 00:29:25 +0000 Subject: r25119: Fix a couple of warnings. Jeremy. (This used to be commit 0e655ac94653128566a8764ea804f37c4c7b300f) --- source3/rpc_server/srv_dfs_nt.c | 3 ++- source3/rpc_server/srv_lsa_hnd.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 1ce81a76f9..37a9725828 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -291,7 +291,8 @@ WERROR _dfs_Enum(pipes_struct *p, struct dfs_Enum *r) } vfs_ChDir(p->conn,p->conn->connectpath); - DEBUG(5,("_dfs_Enum: %d junctions found in Dfs, doing level %d\n", num_jn, r->in.level)); + DEBUG(5,("_dfs_Enum: %u junctions found in Dfs, doing level %d\n", + (unsigned int)num_jn, r->in.level)); *r->out.total = num_jn; diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 7250da7d0c..45b4fb9a5c 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -44,7 +44,7 @@ static BOOL is_samr_lsa_pipe(const char *pipe_name) pipes of the same name. ****************************************************************************/ -BOOL init_pipe_handle_list(pipes_struct *p, char *pipe_name) +BOOL init_pipe_handle_list(pipes_struct *p, const char *pipe_name) { pipes_struct *plist = get_first_internal_pipe(); struct handle_list *hl = NULL; -- cgit From eacd3140573d1122a3785823e4003bfc6352c431 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 13 Sep 2007 22:08:59 +0000 Subject: r25138: More pstring elimination. Add a TALLOC_CTX parameter to unix_convert(). Jeremy. (This used to be commit 39c211a702e91c34c1a5a689e1b0c4530ea8a1ac) --- source3/rpc_server/srv_srvsvc_nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 4be519a9a3..5a3a78ef89 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2048,6 +2048,7 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecur BOOL became_user = False; WERROR status = WERR_OK; char *tmp_file = NULL; + TALLOC_CTX *ctx = talloc_tos(); ZERO_STRUCT(st); @@ -2076,7 +2077,7 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecur status = WERR_INVALID_PARAM; goto error_exit; } - nt_status = unix_convert(conn, r->in.file, False, &tmp_file, NULL, &st); + nt_status = unix_convert(ctx, conn, r->in.file, False, &tmp_file, NULL, &st); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", r->in.file)); status = WERR_ACCESS_DENIED; @@ -2156,6 +2157,7 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecur BOOL became_user = False; WERROR status = WERR_OK; char *tmp_file = NULL; + TALLOC_CTX *ctx = talloc_tos(); ZERO_STRUCT(st); @@ -2183,7 +2185,7 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecur status = WERR_INVALID_PARAM; goto error_exit; } - nt_status = unix_convert(conn, r->in.file, False, &tmp_file, NULL, &st); + nt_status = unix_convert(ctx, conn, r->in.file, False, &tmp_file, NULL, &st); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", r->in.file)); status = WERR_ACCESS_DENIED; -- cgit From c97fe37ea3d92a631e8da17c21dafae1db15e97b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 21 Sep 2007 14:37:35 +0000 Subject: r25294: Tidy up callers of unistr2_to_ascii() to pass sizeof(target_area) to the maxeln parameter instead of sizeof(target_area) - 1 (or even sizeof(fstring) - 1 in some places. I hope these were really all there were. Michael (This used to be commit 9a28be220df622322857dfe102fa35e108f932dc) --- source3/rpc_server/srv_samr_nt.c | 10 +++---- source3/rpc_server/srv_spoolss_nt.c | 54 ++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e95fd0c7f9..950a186e03 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4470,7 +4470,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; - unistr2_to_ascii(name, &q_u->uni_acct_desc, sizeof(name)-1); + unistr2_to_ascii(name, &q_u->uni_acct_desc, sizeof(name)); se_priv_copy( &se_rights, &se_add_users ); can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); @@ -4659,10 +4659,10 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ switch (ctr->switch_value1) { case 1: - unistr2_to_ascii(map.comment, &(ctr->group.info1.uni_acct_desc), sizeof(map.comment)-1); + unistr2_to_ascii(map.comment, &(ctr->group.info1.uni_acct_desc), sizeof(map.comment)); break; case 4: - unistr2_to_ascii(map.comment, &(ctr->group.info4.uni_acct_desc), sizeof(map.comment)-1); + unistr2_to_ascii(map.comment, &(ctr->group.info4.uni_acct_desc), sizeof(map.comment)); break; default: return NT_STATUS_INVALID_INFO_CLASS; @@ -4743,7 +4743,7 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ return NT_STATUS_INVALID_PARAMETER; unistr2_to_ascii( acct_name, ctr->alias.info2.name.string, - sizeof(acct_name)-1 ); + sizeof(acct_name)); /* If the name is the same just reply "ok". Yes this doesn't allow you to change the case of a group name. */ @@ -4766,7 +4766,7 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ if ( ctr->alias.info3.description.string ) { unistr2_to_ascii( info.acct_desc, ctr->alias.info3.description.string, - sizeof(info.acct_desc)-1 ); + sizeof(info.acct_desc)); } else fstrcpy( info.acct_desc, "" ); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 600eb2f688..f573d3fdc6 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1549,7 +1549,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* some sanity check because you can open a printer or a print server */ /* aka: \\server\printer or \\server */ - unistr2_to_ascii(name, q_u->printername, sizeof(name)-1); + unistr2_to_ascii(name, q_u->printername, sizeof(name)); DEBUGADD(3,("checking name: %s\n",name)); @@ -1997,8 +1997,8 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER return WERR_ACCESS_DENIED; } - unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)-1 ); - unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)-1 ); + unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)); + unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)); /* check that we have a valid driver name first */ @@ -2092,8 +2092,8 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV return WERR_ACCESS_DENIED; } - unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)-1 ); - unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)-1 ); + unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)); + unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)); /* check that we have a valid driver name first */ if ((version=get_version_id(arch)) == -1) { @@ -2470,7 +2470,7 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO goto done; } - unistr2_to_ascii(value, valuename, sizeof(value)-1); + unistr2_to_ascii(value, valuename, sizeof(value)); if ( Printer->printer_type == SPLHND_SERVER ) status = getprinterdata_printer_server( p->mem_ctx, value, type, data, needed, *out_size ); @@ -2688,7 +2688,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE Printer->notify.option=dup_spool_notify_option(option); unistr2_to_ascii(Printer->notify.localmachine, localmachine, - sizeof(Printer->notify.localmachine)-1); + sizeof(Printer->notify.localmachine)); /* Connect to the client machine and send a ReplyOpenPrinter */ @@ -4804,7 +4804,7 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ * Level 5: same as Level 2 */ - unistr2_to_ascii(name, servername, sizeof(name)-1); + unistr2_to_ascii(name, servername, sizeof(name)); strupper_m(name); switch (level) { @@ -5788,7 +5788,7 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ *serverminorversion = 0; fstrcpy(servername, get_server_name( printer )); - unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); + unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)); if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; @@ -7215,8 +7215,8 @@ WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS *needed = 0; *returned = 0; - unistr2_to_ascii(architecture, &q_u->environment, sizeof(architecture)-1); - unistr2_to_ascii(servername, &q_u->name, sizeof(servername)-1); + unistr2_to_ascii(architecture, &q_u->environment, sizeof(architecture)); + unistr2_to_ascii(servername, &q_u->name, sizeof(servername)); if ( !is_myname_or_ipaddr( servername ) ) return WERR_UNKNOWN_PRINTER_DRIVER; @@ -7388,7 +7388,7 @@ WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * rpcbuf_move(q_u->buffer, &r_u->buffer); buffer = r_u->buffer; - unistr2_to_ascii(form_name, uni_formname, sizeof(form_name)-1); + unistr2_to_ascii(form_name, uni_formname, sizeof(form_name)); DEBUG(4,("_spoolss_getform\n")); DEBUGADD(5,("Offered buffer size [%d]\n", offered)); @@ -8004,8 +8004,8 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen DRIVER_DIRECTORY_1 *info=NULL; WERROR result = WERR_OK; - unistr2_to_ascii(servername, name, sizeof(servername)-1); - unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1); + unistr2_to_ascii(servername, name, sizeof(servername)); + unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)); /* check for beginning double '\'s and that the server long enough */ @@ -8322,7 +8322,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP if (!W_ERROR_IS_OK(status)) return status; - unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); + unistr2_to_ascii(valuename, value, sizeof(valuename)); /* * When client side code sets a magic printer data key, detect it and save @@ -8414,7 +8414,7 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ if (!W_ERROR_IS_OK(status)) return status; - unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); + unistr2_to_ascii(valuename, value, sizeof(valuename)); status = delete_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, valuename ); @@ -9136,8 +9136,8 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, DEBUG(4,("_spoolss_getprinterdataex\n")); - unistr2_to_ascii(keyname, &q_u->keyname, sizeof(keyname) - 1); - unistr2_to_ascii(valuename, &q_u->valuename, sizeof(valuename) - 1); + unistr2_to_ascii(keyname, &q_u->keyname, sizeof(keyname)); + unistr2_to_ascii(valuename, &q_u->valuename, sizeof(valuename)); DEBUG(10, ("_spoolss_getprinterdataex: key => [%s], value => [%s]\n", keyname, valuename)); @@ -9268,8 +9268,8 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, if (!W_ERROR_IS_OK(status)) return status; - unistr2_to_ascii( valuename, &q_u->value, sizeof(valuename) - 1); - unistr2_to_ascii( keyname, &q_u->key, sizeof(keyname) - 1); + unistr2_to_ascii( valuename, &q_u->value, sizeof(valuename)); + unistr2_to_ascii( keyname, &q_u->key, sizeof(keyname)); /* check for OID in valuename */ @@ -9346,8 +9346,8 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX if (!W_ERROR_IS_OK(status)) return status; - unistr2_to_ascii( valuename, value, sizeof(valuename)-1 ); - unistr2_to_ascii( keyname, key, sizeof(keyname)-1 ); + unistr2_to_ascii(valuename, value, sizeof(valuename)); + unistr2_to_ascii(keyname, key, sizeof(keyname)); status = delete_printer_dataex( printer, keyname, valuename ); @@ -9395,7 +9395,7 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO /* get the list of subkey names */ - unistr2_to_ascii( key, &q_u->key, sizeof(key)-1 ); + unistr2_to_ascii(key, &q_u->key, sizeof(key)); data = printer->info_2->data; num_keys = get_printer_subkeys( data, key, &keynames ); @@ -9470,7 +9470,7 @@ WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, /* delete the key and all subneys */ - unistr2_to_ascii(key, &q_u->keyname, sizeof(key) - 1); + unistr2_to_ascii(key, &q_u->keyname, sizeof(key)); status = delete_all_printer_data( printer->info_2, key ); @@ -9521,7 +9521,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ * --jerry */ - unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); + unistr2_to_ascii(key, &q_u->key, sizeof(key)); if ( !strlen(key) ) { result = WERR_INVALID_PARAM; goto done; @@ -9541,7 +9541,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ p_data = printer->info_2->data; - unistr2_to_ascii(key, &q_u->key, sizeof(key) - 1); + unistr2_to_ascii(key, &q_u->key, sizeof(key)); if ( (key_index = lookup_printerkey( p_data, key)) == -1 ) { DEBUG(10,("_spoolss_enumprinterdataex: Unknown keyname [%s]\n", key)); @@ -9658,7 +9658,7 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, PRINTPROCESSOR_DIRECTORY_1 *info=NULL; WERROR result = WERR_OK; - unistr2_to_ascii(long_archi, environment, sizeof(long_archi)-1); + unistr2_to_ascii(long_archi, environment, sizeof(long_archi)); if (!get_short_archi(long_archi)) return WERR_INVALID_ENVIRONMENT; -- cgit From 7fc3a0663c022a8dc86e166a5037620c01148392 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 27 Sep 2007 22:55:11 +0000 Subject: r25389: Fix crash bug using DFS info struct uninitialized. Jeremy. (This used to be commit 993bd0995eadc134378e691ccd796074dc475741) --- source3/rpc_server/srv_dfs_nt.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 37a9725828..6ed5dbd3b5 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -379,10 +379,34 @@ WERROR _dfs_GetInfo(pipes_struct *p, struct dfs_GetInfo *r) vfs_ChDir(p->conn,p->conn->connectpath); switch (r->in.level) { - case 1: ret = init_reply_dfs_info_1(ctx, jn, r->out.info->info1); break; - case 2: ret = init_reply_dfs_info_2(ctx, jn, r->out.info->info2); break; - case 3: ret = init_reply_dfs_info_3(ctx, jn, r->out.info->info3); break; - case 100: ret = init_reply_dfs_info_100(ctx, jn, r->out.info->info100); break; + case 1: + r->out.info->info1 = TALLOC_ZERO_P(ctx,struct dfs_Info1); + if (!r->out.info->info1) { + return WERR_NOMEM; + } + ret = init_reply_dfs_info_1(ctx, jn, r->out.info->info1); + break; + case 2: + r->out.info->info2 = TALLOC_ZERO_P(ctx,struct dfs_Info2); + if (!r->out.info->info2) { + return WERR_NOMEM; + } + ret = init_reply_dfs_info_2(ctx, jn, r->out.info->info2); + break; + case 3: + r->out.info->info3 = TALLOC_ZERO_P(ctx,struct dfs_Info3); + if (!r->out.info->info3) { + return WERR_NOMEM; + } + ret = init_reply_dfs_info_3(ctx, jn, r->out.info->info3); + break; + case 100: + r->out.info->info100 = TALLOC_ZERO_P(ctx,struct dfs_Info100); + if (!r->out.info->info100) { + return WERR_NOMEM; + } + ret = init_reply_dfs_info_100(ctx, jn, r->out.info->info100); + break; default: r->out.info->info1 = NULL; return WERR_INVALID_PARAM; -- cgit From 3665d6d9d54f0f52fcf1ad68ca7e126d7343d4fd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 3 Oct 2007 12:51:36 +0000 Subject: r25480: Fix a segfault (This used to be commit 7e72a3046d5c318247d1e69b51bcb74e897e3eae) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 5a3a78ef89..d89fe65274 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -128,7 +128,7 @@ static void enum_file_fn( const struct share_mode_entry *e, void *private_data ) { struct file_enum_count *fenum = - (struct file_enum_count *)&private_data; + (struct file_enum_count *)private_data; /* If the pid was not found delete the entry from connections.tdb */ -- cgit From 105d2a67eadc009031ebc163a5cf30594303806f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 3 Oct 2007 13:13:02 +0000 Subject: r25482: Slightly simplify logic Instead of one big if-branch for if (process_exists(..)) return if (!process_exists(..)) (This used to be commit 3acc00132c97b36e026162ae11a23953269dfbed) --- source3/rpc_server/srv_srvsvc_nt.c | 96 +++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index d89fe65274..cc0968a544 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -129,64 +129,64 @@ static void enum_file_fn( const struct share_mode_entry *e, { struct file_enum_count *fenum = (struct file_enum_count *)private_data; + + struct srvsvc_NetFileInfo3 *f; + int i = fenum->count; + files_struct fsp; + struct byte_range_lock *brl; + int num_locks = 0; + pstring fullpath; + uint32 permissions; /* If the pid was not found delete the entry from connections.tdb */ - if ( process_exists(e->pid) ) { - struct srvsvc_NetFileInfo3 *f; - int i = fenum->count; - files_struct fsp; - struct byte_range_lock *brl; - int num_locks = 0; - pstring fullpath; - uint32 permissions; + if (!process_exists(e->pid)) { + return; + } - f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, struct srvsvc_NetFileInfo3, i+1 ); - if ( !f ) { - DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); - return; - } - fenum->info = f; + f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, + struct srvsvc_NetFileInfo3, i+1 ); + if ( !f ) { + DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); + return; + } + fenum->info = f; - /* need to count the number of locks on a file */ + /* need to count the number of locks on a file */ - ZERO_STRUCT( fsp ); - fsp.file_id = e->id; + ZERO_STRUCT( fsp ); + fsp.file_id = e->id; - if ( (brl = brl_get_locks_readonly(NULL,&fsp)) != NULL ) { - num_locks = brl->num_locks; - TALLOC_FREE( brl ); - } + if ( (brl = brl_get_locks_readonly(NULL,&fsp)) != NULL ) { + num_locks = brl->num_locks; + TALLOC_FREE( brl ); + } - if ( strcmp( fname, "." ) == 0 ) { - pstr_sprintf( fullpath, "C:%s", sharepath ); - } else { - pstr_sprintf( fullpath, "C:%s/%s", sharepath, fname ); - } - string_replace( fullpath, '/', '\\' ); + if ( strcmp( fname, "." ) == 0 ) { + pstr_sprintf( fullpath, "C:%s", sharepath ); + } else { + pstr_sprintf( fullpath, "C:%s/%s", sharepath, fname ); + } + string_replace( fullpath, '/', '\\' ); - /* mask out create (what ever that is) */ - permissions = e->share_access & (FILE_READ_DATA|FILE_WRITE_DATA); - - fenum->info[i].fid = e->share_file_id; - fenum->info[i].permissions = permissions; - fenum->info[i].num_locks = num_locks; - if (!(fenum->info[i].user = talloc_strdup( - fenum->ctx, uidtoname(e->uid)))) { - /* There's not much we can do here. */ - fenum->info[i].user = ""; - } - if (!(fenum->info[i].path = talloc_strdup( - fenum->ctx, fullpath))) { - /* There's not much we can do here. */ - fenum->info[i].path = ""; - } - - fenum->count++; + /* mask out create (what ever that is) */ + permissions = e->share_access & (FILE_READ_DATA|FILE_WRITE_DATA); + + fenum->info[i].fid = e->share_file_id; + fenum->info[i].permissions = permissions; + fenum->info[i].num_locks = num_locks; + if (!(fenum->info[i].user = talloc_strdup( + fenum->ctx, uidtoname(e->uid)))) { + /* There's not much we can do here. */ + fenum->info[i].user = ""; + } + if (!(fenum->info[i].path = talloc_strdup( + fenum->ctx, fullpath))) { + /* There's not much we can do here. */ + fenum->info[i].path = ""; } - - return; - + + fenum->count++; } /******************************************************************* -- cgit From 5d552214e69acbf9863624f4eed6ae57b7bf1f14 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 3 Oct 2007 18:37:57 +0000 Subject: r25484: Fix srvsrc_NetFileEnum listing only for one user (This used to be commit 9e1f513916d8836914580806580c4f8c38e5f2be) --- source3/rpc_server/srv_srvsvc_nt.c | 94 +++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 37 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index cc0968a544..503ecc1d1c 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -37,6 +37,7 @@ extern userdom_struct current_user_info; struct file_enum_count { TALLOC_CTX *ctx; + const char *username; uint32 count; struct srvsvc_NetFileInfo3 *info; }; @@ -55,56 +56,64 @@ static int pipe_enum_fn( struct db_record *rec, void *p) { struct pipe_open_rec prec; struct file_enum_count *fenum = (struct file_enum_count *)p; + struct srvsvc_NetFileInfo3 *f; + int i = fenum->count; + pstring fullpath; + const char *username; if (rec->value.dsize != sizeof(struct pipe_open_rec)) return 0; memcpy(&prec, rec->value.dptr, sizeof(struct pipe_open_rec)); - if ( process_exists(prec.pid) ) { - struct srvsvc_NetFileInfo3 *f; - int i = fenum->count; - pstring fullpath; + if ( !process_exists(prec.pid) ) { + return 0; + } + + username = uidtoname(prec.uid); + + if ((fenum->username != NULL) + && !strequal(username, fenum->username)) { + return 0; + } - snprintf( fullpath, sizeof(fullpath), "\\PIPE\\%s", prec.name ); + snprintf( fullpath, sizeof(fullpath), "\\PIPE\\%s", prec.name ); - f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, struct srvsvc_NetFileInfo3, i+1 ); - if ( !f ) { - DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); - return 1; - } + f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, + struct srvsvc_NetFileInfo3, i+1 ); + if ( !f ) { + DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); + return 1; + } - fenum->info = f; + fenum->info = f; - fenum->info[i].fid = (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum); - fenum->info[i].permissions = (FILE_READ_DATA|FILE_WRITE_DATA); - fenum->info[i].num_locks = 0; - if (!(fenum->info[i].user = talloc_strdup( - fenum->ctx, uidtoname(prec.uid)))) { - /* There's not much we can do here. */ - fenum->info[i].user = ""; - } - if (!(fenum->info[i].path = talloc_strdup( - fenum->ctx, fullpath))) { - /* There's not much we can do here. */ - fenum->info[i].path = ""; - } - - fenum->count++; + fenum->info[i].fid = (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum); + fenum->info[i].permissions = (FILE_READ_DATA|FILE_WRITE_DATA); + fenum->info[i].num_locks = 0; + fenum->info[i].user = talloc_move(fenum->ctx, &username); + if (!(fenum->info[i].path = talloc_strdup( + fenum->ctx, fullpath))) { + /* There's not much we can do here. */ + fenum->info[i].path = ""; } + fenum->count++; + return 0; } /******************************************************************* ********************************************************************/ -static WERROR net_enum_pipes( TALLOC_CTX *ctx, struct srvsvc_NetFileInfo3 **info, +static WERROR net_enum_pipes( TALLOC_CTX *ctx, const char *username, + struct srvsvc_NetFileInfo3 **info, uint32 *count, uint32 *resume ) { struct file_enum_count fenum; fenum.ctx = ctx; + fenum.username = username; fenum.info = *info; fenum.count = *count; @@ -137,12 +146,20 @@ static void enum_file_fn( const struct share_mode_entry *e, int num_locks = 0; pstring fullpath; uint32 permissions; + const char *username; /* If the pid was not found delete the entry from connections.tdb */ if (!process_exists(e->pid)) { return; } + + username = uidtoname(e->uid); + + if ((fenum->username != NULL) + && !strequal(username, fenum->username)) { + return; + } f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, struct srvsvc_NetFileInfo3, i+1 ); @@ -175,11 +192,7 @@ static void enum_file_fn( const struct share_mode_entry *e, fenum->info[i].fid = e->share_file_id; fenum->info[i].permissions = permissions; fenum->info[i].num_locks = num_locks; - if (!(fenum->info[i].user = talloc_strdup( - fenum->ctx, uidtoname(e->uid)))) { - /* There's not much we can do here. */ - fenum->info[i].user = ""; - } + fenum->info[i].user = talloc_move(fenum->ctx, &username); if (!(fenum->info[i].path = talloc_strdup( fenum->ctx, fullpath))) { /* There's not much we can do here. */ @@ -192,12 +205,14 @@ static void enum_file_fn( const struct share_mode_entry *e, /******************************************************************* ********************************************************************/ -static WERROR net_enum_files( TALLOC_CTX *ctx, struct srvsvc_NetFileInfo3 **info, +static WERROR net_enum_files( TALLOC_CTX *ctx, const char *username, + struct srvsvc_NetFileInfo3 **info, uint32 *count, uint32 *resume ) { struct file_enum_count f_enum_cnt; f_enum_cnt.ctx = ctx; + f_enum_cnt.username = username; f_enum_cnt.count = *count; f_enum_cnt.info = *info; @@ -1047,7 +1062,9 @@ static WERROR init_srv_conn_info_ctr(pipes_struct *p, union srvsvc_NetConnCtr *c makes a SRV_R_NET_FILE_ENUM structure. ********************************************************************/ -static WERROR net_file_enum_3(pipes_struct *p, union srvsvc_NetFileCtr *ctr, uint32 *resume_hnd, uint32 *num_entries ) +static WERROR net_file_enum_3(pipes_struct *p, union srvsvc_NetFileCtr *ctr, + uint32 *resume_hnd, const char *username, + uint32 *num_entries ) { WERROR status; @@ -1057,11 +1074,13 @@ static WERROR net_file_enum_3(pipes_struct *p, union srvsvc_NetFileCtr *ctr, uin ctr->ctr3 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetFileCtr3); - status = net_enum_files(p->mem_ctx, &ctr->ctr3->array, num_entries, resume_hnd ); + status = net_enum_files(p->mem_ctx, username, &ctr->ctr3->array, + num_entries, resume_hnd ); if ( !W_ERROR_IS_OK(status)) return status; - status = net_enum_pipes(p->mem_ctx, &ctr->ctr3->array, num_entries, resume_hnd ); + status = net_enum_pipes(p->mem_ctx, username, &ctr->ctr3->array, + num_entries, resume_hnd ); if ( !W_ERROR_IS_OK(status)) return status; @@ -1077,7 +1096,8 @@ WERROR _srvsvc_NetFileEnum(pipes_struct *p, struct srvsvc_NetFileEnum *r) { switch ( *r->in.level ) { case 3: - return net_file_enum_3(p, r->in.ctr, r->in.resume_handle, r->out.totalentries ); + return net_file_enum_3(p, r->in.ctr, r->in.resume_handle, + r->in.user, r->out.totalentries ); default: return WERR_UNKNOWN_LEVEL; } -- cgit From 0ebab65706e7e2ef82d8af81225db05a5f78b5c4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 5 Oct 2007 21:41:17 +0000 Subject: r25534: Apply some const Why? It moves these structs from the data into the text segment, so they will never been copy-on-write copied. Not much, but as in German you say "Kleinvieh macht auch Mist...." (This used to be commit 0141e64ad4972232de867137064d0dae62da22ee) --- source3/rpc_server/srv_lsa_nt.c | 2 +- source3/rpc_server/srv_samr_nt.c | 14 +++++++------- source3/rpc_server/srv_spoolss_nt.c | 2 +- source3/rpc_server/srv_srvsvc_nt.c | 2 +- source3/rpc_server/srv_svcctl_nt.c | 4 ++-- source3/rpc_server/srv_winreg_nt.c | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 40d5005c4f..4bd6a634d8 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -39,7 +39,7 @@ struct lsa_info { uint32 access; }; -struct generic_mapping lsa_generic_mapping = { +const struct generic_mapping lsa_generic_mapping = { POLICY_READ, POLICY_WRITE, POLICY_EXECUTE, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 950a186e03..bec288730a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -72,32 +72,32 @@ struct samr_info { TALLOC_CTX *mem_ctx; }; -static struct generic_mapping sam_generic_mapping = { +static const struct generic_mapping sam_generic_mapping = { GENERIC_RIGHTS_SAM_READ, GENERIC_RIGHTS_SAM_WRITE, GENERIC_RIGHTS_SAM_EXECUTE, GENERIC_RIGHTS_SAM_ALL_ACCESS}; -static struct generic_mapping dom_generic_mapping = { +static const struct generic_mapping dom_generic_mapping = { GENERIC_RIGHTS_DOMAIN_READ, GENERIC_RIGHTS_DOMAIN_WRITE, GENERIC_RIGHTS_DOMAIN_EXECUTE, GENERIC_RIGHTS_DOMAIN_ALL_ACCESS}; -static struct generic_mapping usr_generic_mapping = { +static const struct generic_mapping usr_generic_mapping = { GENERIC_RIGHTS_USER_READ, GENERIC_RIGHTS_USER_WRITE, GENERIC_RIGHTS_USER_EXECUTE, GENERIC_RIGHTS_USER_ALL_ACCESS}; -static struct generic_mapping usr_nopwchange_generic_mapping = { +static const struct generic_mapping usr_nopwchange_generic_mapping = { GENERIC_RIGHTS_USER_READ, GENERIC_RIGHTS_USER_WRITE, GENERIC_RIGHTS_USER_EXECUTE & ~SA_RIGHT_USER_CHANGE_PASSWORD, GENERIC_RIGHTS_USER_ALL_ACCESS}; -static struct generic_mapping grp_generic_mapping = { +static const struct generic_mapping grp_generic_mapping = { GENERIC_RIGHTS_GROUP_READ, GENERIC_RIGHTS_GROUP_WRITE, GENERIC_RIGHTS_GROUP_EXECUTE, GENERIC_RIGHTS_GROUP_ALL_ACCESS}; -static struct generic_mapping ali_generic_mapping = { +static const struct generic_mapping ali_generic_mapping = { GENERIC_RIGHTS_ALIAS_READ, GENERIC_RIGHTS_ALIAS_WRITE, GENERIC_RIGHTS_ALIAS_EXECUTE, @@ -107,7 +107,7 @@ static struct generic_mapping ali_generic_mapping = { *******************************************************************/ static NTSTATUS make_samr_object_sd( TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd_size, - struct generic_mapping *map, + const struct generic_mapping *map, DOM_SID *sid, uint32 sid_access ) { DOM_SID domadmin_sid; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f573d3fdc6..d5795cca25 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -63,7 +63,7 @@ static uint32 smb_connections=0; /* in printing/nt_printing.c */ -extern STANDARD_MAPPING printer_std_mapping, printserver_std_mapping; +extern struct standard_mapping printer_std_mapping, printserver_std_mapping; /* API table for Xcv Monitor functions */ diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 503ecc1d1c..321ff83156 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -27,7 +27,7 @@ #define MAX_SERVER_DISK_ENTRIES 15 -extern struct generic_mapping file_generic_mapping; +extern const struct generic_mapping file_generic_mapping; extern userdom_struct current_user_info; #undef DBGC_CLASS diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 6d807f3ee8..dba209eb07 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -49,9 +49,9 @@ extern SERVICE_CONTROL_OPS wins_svc_ops; struct service_control_op *svcctl_ops; -static struct generic_mapping scm_generic_map = +static const struct generic_mapping scm_generic_map = { SC_MANAGER_READ_ACCESS, SC_MANAGER_WRITE_ACCESS, SC_MANAGER_EXECUTE_ACCESS, SC_MANAGER_ALL_ACCESS }; -static struct generic_mapping svc_generic_map = +static const struct generic_mapping svc_generic_map = { SERVICE_READ_ACCESS, SERVICE_WRITE_ACCESS, SERVICE_EXECUTE_ACCESS, SERVICE_ALL_ACCESS }; diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index fe3295e7e9..2d6ff7454a 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -26,7 +26,7 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -static struct generic_mapping reg_generic_map = +static const struct generic_mapping reg_generic_map = { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; /****************************************************************** -- cgit From b5535567c11552ed675ecc489d440558f91f1d1d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 7 Oct 2007 17:58:48 +0000 Subject: r25564: Pass sharename to delete_share_security() (This used to be commit d100bfffe2a503b8820889faedc6ed57100ca7af) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 321ff83156..2af4c79002 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1994,7 +1994,7 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, struct srvsvc_NetShareDel *r) } /* Delete the SD in the database. */ - delete_share_security(params); + delete_share_security(lp_servicename(params->service)); lp_killservice(params->service); -- cgit From e5a951325a6cac8567af3a66de6d2df577508ae4 Mon Sep 17 00:00:00 2001 From: "Gerald (Jerry) Carter" Date: Wed, 10 Oct 2007 15:34:30 -0500 Subject: [GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch. (This used to be commit 5c6c8e1fe93f340005110a7833946191659d88ab) --- source3/rpc_server/srv_echo_nt.c | 52 +- source3/rpc_server/srv_epmapper_nt.c | 70 -- source3/rpc_server/srv_lsa_nt.c | 67 +- source3/rpc_server/srv_pipe.c | 111 +- source3/rpc_server/srv_pipe_hnd.c | 2 + source3/rpc_server/srv_samr.c | 2 +- source3/rpc_server/srv_spoolss_nt.c | 261 ++-- source3/rpc_server/srv_srvsvc.c | 616 ++++++++++ source3/rpc_server/srv_srvsvc_nt.c | 2178 +++++++++++++++++----------------- source3/rpc_server/srv_svcctl_nt.c | 2 +- source3/rpc_server/srv_unixinfo_nt.c | 130 -- 11 files changed, 1902 insertions(+), 1589 deletions(-) delete mode 100644 source3/rpc_server/srv_epmapper_nt.c create mode 100644 source3/rpc_server/srv_srvsvc.c delete mode 100644 source3/rpc_server/srv_unixinfo_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_echo_nt.c b/source3/rpc_server/srv_echo_nt.c index 58c59aa506..1179a162b0 100644 --- a/source3/rpc_server/srv_echo_nt.c +++ b/source3/rpc_server/srv_echo_nt.c @@ -35,7 +35,7 @@ void _echo_AddOne(pipes_struct *p, struct echo_AddOne *r ) { DEBUG(10, ("_echo_AddOne\n")); - *r->out.out_data = r->in.in_data + 1; + *r->out.out_data = r->in.in_data + 1; } /* Echo back an array of data */ @@ -88,66 +88,38 @@ void _echo_SourceData(pipes_struct *p, struct echo_SourceData *r) void _echo_TestCall(pipes_struct *p, struct echo_TestCall *r) { - *r->out.s2 = talloc_strdup(p->mem_ctx, r->in.s1); + p->rng_fault_state = True; + return; } NTSTATUS _echo_TestCall2(pipes_struct *p, struct echo_TestCall2 *r) { - switch (r->in.level) { - case 1: - r->out.info->info1.v = 10; - break; - case 2: - r->out.info->info2.v = 20; - break; - case 3: - r->out.info->info3.v = 30; - break; - case 4: - r->out.info->info4.v = 40; - break; - case 5: - r->out.info->info5.v1 = 50; - r->out.info->info5.v2 = 60; - break; - case 6: - r->out.info->info6.v1 = 70; - r->out.info->info6.info1.v= 80; - break; - case 7: - r->out.info->info7.v1 = 80; - r->out.info->info7.info4.v = 90; - break; - default: - return NT_STATUS_INVALID_LEVEL; - } - + p->rng_fault_state = True; return NT_STATUS_OK; } uint32 _echo_TestSleep(pipes_struct *p, struct echo_TestSleep *r) { - sleep(r->in.seconds); - return r->in.seconds; + p->rng_fault_state = True; + return 0; } void _echo_TestEnum(pipes_struct *p, struct echo_TestEnum *r) { + p->rng_fault_state = True; + return; } void _echo_TestSurrounding(pipes_struct *p, struct echo_TestSurrounding *r) { - r->out.data->x *= 2; - r->out.data->surrounding = TALLOC_ZERO_ARRAY(p->mem_ctx, uint16_t, r->in.data->x); + p->rng_fault_state = True; + return; } uint16 _echo_TestDoublePointer(pipes_struct *p, struct echo_TestDoublePointer *r) { - if (!*r->in.data) - return 0; - if (!**r->in.data) - return 0; - return ***r->in.data; + p->rng_fault_state = True; + return 0; } #endif /* DEVELOPER */ diff --git a/source3/rpc_server/srv_epmapper_nt.c b/source3/rpc_server/srv_epmapper_nt.c deleted file mode 100644 index 405769072b..0000000000 --- a/source3/rpc_server/srv_epmapper_nt.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines for the endpoint mapper - * Copyright (C) Jelmer Vernooij 2007. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ - -/* This is the implementation of the dfs pipe. */ - -#include "includes.h" - -uint32 _epm_MapAuth(pipes_struct *p, struct epm_MapAuth *r) -{ - /* FIXME */ - return 0; -} - -uint32 _epm_MgmtDelete(pipes_struct *p, struct epm_MgmtDelete *r) -{ - /* FIXME */ - return 0; -} - -uint32 _epm_InqObject(pipes_struct *p, struct epm_InqObject *r) -{ - /* FIXME */ - return 0; -} - -uint32 _epm_LookupHandleFree(pipes_struct *p, struct epm_LookupHandleFree *r) -{ - /* FIXME */ - return 0; -} - -uint32 _epm_Map(pipes_struct *p, struct epm_Map *r) -{ - /* FIXME */ - return 0; -} - -uint32 _epm_Lookup(pipes_struct *p, struct epm_Lookup *r) -{ - /* FIXME */ - return 0; -} - -uint32 _epm_Delete(pipes_struct *p, struct epm_Delete *r) -{ - /* FIXME */ - return 0; -} - -uint32 _epm_Insert(pipes_struct *p, struct epm_Insert *r) -{ - /* FIXME */ - return 0; -} diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 4bd6a634d8..c513d8489c 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -996,33 +996,41 @@ NTSTATUS _lsa_lookup_sids2(pipes_struct *p, /*************************************************************************** _lsa_lookup_sida3 - - Before someone actually re-activates this, please present a sniff showing - this call against some Windows server. I (vl) could not make it work against - w2k3 at all. ***************************************************************************/ NTSTATUS _lsa_lookup_sids3(pipes_struct *p, LSA_Q_LOOKUP_SIDS3 *q_u, LSA_R_LOOKUP_SIDS3 *r_u) { + int num_sids = q_u->sids.num_entries; uint32 mapped_count = 0; - DOM_R_REF *ref; + DOM_R_REF *ref = NULL; if ((q_u->level < 1) || (q_u->level > 6)) { return NT_STATUS_INVALID_PARAMETER; } - r_u->status = NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED; - - ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); + /* No policy handle on this call. Restrict to crypto connections. */ + if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) { + DEBUG(0,("_lsa_lookup_sids3: client %s not using schannel for netlogon\n", + get_remote_machine_name() )); + return NT_STATUS_INVALID_PARAMETER; + } - if (ref == NULL) { - /* We would segfault later on in lsa_io_r_lookup_sids3 anyway, - * so do a planned exit here. We NEEEED pidl! */ - smb_panic("talloc failed"); + if (num_sids > MAX_LOOKUP_SIDS) { + DEBUG(5,("_lsa_lookup_sids3: limit of %d exceeded, requested %d\n", + MAX_LOOKUP_SIDS, num_sids)); + return NT_STATUS_NONE_MAPPED; } + r_u->status = _lsa_lookup_sids_internal(p, + q_u->level, + num_sids, + q_u->sids.sid, + &ref, + &r_u->names, + &mapped_count); + init_reply_lookup_sids3(r_u, ref, mapped_count); return r_u->status; } @@ -1537,26 +1545,14 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u) { - const char *username, *domname; + fstring username, domname; user_struct *vuser = get_valid_user_struct(p->vuid); if (vuser == NULL) return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; - - if (vuser->guest) { - /* - * I'm 99% sure this is not the right place to do this, - * global_sid_Anonymous should probably be put into the token - * instead of the guest id -- vl - */ - if (!lookup_sid(p->mem_ctx, &global_sid_Anonymous, - &domname, &username, NULL)) { - return NT_STATUS_NO_MEMORY; - } - } else { - username = vuser->user.smb_name; - domname = vuser->user.domain; - } + + fstrcpy(username, vuser->user.smb_name); + fstrcpy(domname, vuser->user.domain); r_u->ptr_user_name = 1; init_unistr2(&r_u->uni2_user_name, username, UNI_STR_TERMINATE); @@ -1592,23 +1588,17 @@ NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CR * I don't know if it's the right one. not documented. * but guessed with rpcclient. */ - if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) { - DEBUG(10, ("_lsa_create_account: No POLICY_GET_PRIVATE_INFORMATION access right!\n")); + if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - } /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { - DEBUG(10, ("_lsa_create_account: The use is not a Domain Admin, deny access!\n")); + if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) return NT_STATUS_ACCESS_DENIED; - } - if ( is_privileged_sid( &q_u->sid.sid ) ) { - DEBUG(10, ("_lsa_create_account: Policy account already exists!\n")); + if ( is_privileged_sid( &q_u->sid.sid ) ) return NT_STATUS_OBJECT_NAME_COLLISION; - } /* associate the user/group SID with the (unique) handle. */ @@ -1623,7 +1613,6 @@ NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CR if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - DEBUG(10, ("_lsa_create_account: call privileges code to create an account\n")); return privilege_create_account( &info->sid ); } @@ -1718,7 +1707,7 @@ NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA return NT_STATUS_INVALID_HANDLE; if (!lookup_sid(p->mem_ctx, &info->sid, NULL, NULL, NULL)) - return NT_STATUS_OK; + return NT_STATUS_ACCESS_DENIED; /* 0x01 -> Log on locally diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index fefdb529b2..72ce72fb28 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -45,11 +45,6 @@ static void free_pipe_ntlmssp_auth_data(struct pipe_auth_data *auth) auth->a_u.auth_ntlmssp_state = NULL; } -static DATA_BLOB generic_session_key(void) -{ - return data_blob("SystemLibraryDTC", 16); -} - /******************************************************************* Generate the next PDU to be returned from the data in p->rdata. Handle NTLMSSP. @@ -614,6 +609,16 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) ZERO_STRUCT(reply); + memset(p->user_name, '\0', sizeof(p->user_name)); + memset(p->pipe_user_name, '\0', sizeof(p->pipe_user_name)); + memset(p->domain, '\0', sizeof(p->domain)); + memset(p->wks, '\0', sizeof(p->wks)); + + /* Set up for non-authenticated user. */ + TALLOC_FREE(p->pipe_user.nt_user_token); + p->pipe_user.ut.ngroups = 0; + SAFE_FREE( p->pipe_user.ut.groups); + /* this has to be done as root in order to verify the password */ become_root(); status = auth_ntlmssp_update(a, *p_resp_blob, &reply); @@ -626,12 +631,6 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) return False; } - if (a->server_info->ptok == NULL) { - DEBUG(1,("Error: Authmodule failed to provide nt_user_token\n")); - p->pipe_user.nt_user_token = NULL; - return False; - } - /* Finally - if the pipe negotiated integrity (sign) or privacy (seal) ensure the underlying NTLMSSP flags are also set. If not we should refuse the bind. */ @@ -653,9 +652,13 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) } } + fstrcpy(p->user_name, a->ntlmssp_state->user); + fstrcpy(p->pipe_user_name, a->server_info->unix_name); + fstrcpy(p->domain, a->ntlmssp_state->domain); + fstrcpy(p->wks, a->ntlmssp_state->workstation); + DEBUG(5,("pipe_ntlmssp_verify_final: OK: user: %s domain: %s workstation: %s\n", - a->ntlmssp_state->user, a->ntlmssp_state->domain, - a->ntlmssp_state->workstation)); + p->user_name, p->domain, p->wks)); /* * Store the UNIX credential data (uid/gid pair) in the pipe structure. @@ -665,40 +668,30 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) p->pipe_user.ut.gid = a->server_info->gid; /* - * We're an authenticated bind over smb, so the session key needs to - * be set to "SystemLibraryDTC". Weird, but this is what Windows - * does. See the RPC-SAMBA3SESSIONKEY. + * Copy the session key from the ntlmssp state. */ data_blob_free(&p->session_key); - p->session_key = generic_session_key(); + p->session_key = data_blob(a->ntlmssp_state->session_key.data, a->ntlmssp_state->session_key.length); if (!p->session_key.data) { return False; } p->pipe_user.ut.ngroups = a->server_info->n_groups; if (p->pipe_user.ut.ngroups) { - if (!(p->pipe_user.ut.groups = (gid_t *) - memdup(a->server_info->groups, - sizeof(gid_t) * p->pipe_user.ut.ngroups))) { - DEBUG(0,("pipe_ntlmssp_verify_final: failed to memdup group list to p->pipe_user.groups\n")); - data_blob_free(&p->session_key); + if (!(p->pipe_user.ut.groups = (gid_t *)memdup(a->server_info->groups, + sizeof(gid_t) * p->pipe_user.ut.ngroups))) { + DEBUG(0,("failed to memdup group list to p->pipe_user.groups\n")); return False; } } - if (!a->server_info->ptok) { - DEBUG(1,("pipe_ntlmssp_verify_final: Error: Authmodule failed to provide nt_user_token\n")); - data_blob_free(&p->session_key); - SAFE_FREE(p->pipe_user.ut.groups); - return False; - } - - p->pipe_user.nt_user_token = dup_nt_token(NULL, a->server_info->ptok); - if (!p->pipe_user.nt_user_token) { - DEBUG(1,("pipe_ntlmssp_verify_final: dup_nt_token failed.\n")); - data_blob_free(&p->session_key); - SAFE_FREE(p->pipe_user.ut.groups); + if (a->server_info->ptok) { + p->pipe_user.nt_user_token = + dup_nt_token(NULL, a->server_info->ptok); + } else { + DEBUG(1,("Error: Authmodule failed to provide nt_user_token\n")); + p->pipe_user.nt_user_token = NULL; return False; } @@ -1358,21 +1351,8 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, * JRA. Should we also copy the schannel session key into the pipe session key p->session_key * here ? We do that for NTLMSSP, but the session key is already set up from the vuser * struct of the person who opened the pipe. I need to test this further. JRA. - * - * VL. As we are mapping this to guest set the generic key - * "SystemLibraryDTC" key here. It's a bit difficult to test against - * W2k3, as it does not allow schannel binds against SAMR and LSA - * anymore. */ - data_blob_free(&p->session_key); - p->session_key = generic_session_key(); - if (p->session_key.data == NULL) { - DEBUG(0, ("pipe_schannel_auth_bind: Could not alloc session" - " key\n")); - return False; - } - init_rpc_hdr_auth(&auth_info, RPC_SCHANNEL_AUTH_TYPE, pauth_info->auth_level, RPC_HDR_AUTH_LEN, 1); if(!smb_io_rpc_hdr_auth("", &auth_info, pout_auth, 0)) { DEBUG(0,("pipe_schannel_auth_bind: marshalling of RPC_HDR_AUTH failed.\n")); @@ -1401,12 +1381,6 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, p->auth.auth_data_free_func = NULL; p->auth.auth_type = PIPE_AUTH_TYPE_SCHANNEL; - if (!set_current_user_guest(&p->pipe_user)) { - DEBUG(1, ("pipe_schannel_auth_bind: Could not set guest " - "token\n")); - return False; - } - p->pipe_bound = True; return True; @@ -2171,6 +2145,23 @@ BOOL api_pipe_schannel_process(pipes_struct *p, prs_struct *rpc_in, uint32 *p_ss return True; } +/**************************************************************************** + Return a user struct for a pipe user. +****************************************************************************/ + +struct current_user *get_current_user(struct current_user *user, pipes_struct *p) +{ + if (p->pipe_bound && + (p->auth.auth_type == PIPE_AUTH_TYPE_NTLMSSP || + (p->auth.auth_type == PIPE_AUTH_TYPE_SPNEGO_NTLMSSP))) { + memcpy(user, &p->pipe_user, sizeof(struct current_user)); + } else { + memcpy(user, ¤t_user, sizeof(struct current_user)); + } + + return user; +} + /**************************************************************************** Find the set of RPC functions associated with this context_id ****************************************************************************/ @@ -2225,7 +2216,9 @@ BOOL api_pipe_request(pipes_struct *p) BOOL changed_user = False; PIPE_RPC_FNS *pipe_fns; - if (p->pipe_bound) { + if (p->pipe_bound && + ((p->auth.auth_type == PIPE_AUTH_TYPE_NTLMSSP) || + (p->auth.auth_type == PIPE_AUTH_TYPE_SPNEGO_NTLMSSP))) { if(!become_authenticated_pipe_user(p)) { prs_mem_free(&p->out_data.rdata); return False; @@ -2364,7 +2357,7 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) netlog_get_pipe_fns( &cmds, &n_cmds ); break; case PI_SRVSVC: - srvsvc_get_pipe_fns( &cmds, &n_cmds ); + srvsvc2_get_pipe_fns( &cmds, &n_cmds ); break; case PI_WKSSVC: wkssvc_get_pipe_fns( &cmds, &n_cmds ); @@ -2381,12 +2374,9 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) case PI_SVCCTL: svcctl2_get_pipe_fns( &cmds, &n_cmds ); break; - case PI_EVENTLOG: + case PI_EVENTLOG: eventlog2_get_pipe_fns( &cmds, &n_cmds ); break; - case PI_UNIXINFO: - unixinfo_get_pipe_fns( &cmds, &n_cmds ); - break; case PI_NTSVCS: ntsvcs_get_pipe_fns( &cmds, &n_cmds ); break; @@ -2395,9 +2385,6 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) rpcecho_get_pipe_fns( &cmds, &n_cmds ); break; #endif - case PI_EPMAPPER: - epmapper_get_pipe_fns( &cmds, &n_cmds ); - break; default: DEBUG(0,("get_pipe_fns: Unknown pipe index! [%d]\n", idx)); } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 0dd3ee82a7..91814979c5 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -350,6 +350,8 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, /* Store the session key and NT_TOKEN */ if (vuser) { p->session_key = data_blob(vuser->session_key.data, vuser->session_key.length); + p->pipe_user.nt_user_token = dup_nt_token( + NULL, vuser->nt_user_token); } /* diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index d717bb6bb8..bdc082f647 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1530,8 +1530,8 @@ static struct api_struct api_samr_cmds [] = {"SAMR_QUERY_DOMAIN_INFO" , SAMR_QUERY_DOMAIN_INFO, api_samr_query_domain_info}, {"SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, {"SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, - {"SAMR_QUERY_DISPINFO2" , SAMR_QUERY_DISPINFO2 , api_samr_query_dispinfo }, {"SAMR_QUERY_DISPINFO3" , SAMR_QUERY_DISPINFO3 , api_samr_query_dispinfo }, + {"SAMR_QUERY_DISPINFO4" , SAMR_QUERY_DISPINFO4 , api_samr_query_dispinfo }, {"SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, {"SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d5795cca25..11827c223b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -328,7 +328,7 @@ WERROR delete_printer_hook( NT_USER_TOKEN *token, const char *sharename ) /* go ahead and re-read the services immediately */ reload_services( False ); - if ( share_defined( sharename ) ) + if ( lp_servicenumber( sharename ) < 0 ) return WERR_ACCESS_DENIED; return WERR_OK; @@ -388,13 +388,6 @@ static BOOL get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number, case SPLHND_PRINTER: DEBUG(4,("short name:%s\n", Printer->sharename)); *number = print_queue_snum(Printer->sharename); - if ((*number != -1) && (params != NULL)) { - *params = get_share_params(talloc_tos(), - Printer->sharename); - if (*params == NULL) { - return False; - } - } return (*number != -1); case SPLHND_SERVER: return False; @@ -3953,9 +3946,7 @@ done: * fill a printer_info_0 struct ********************************************************************/ -static BOOL construct_printer_info_0(Printer_entry *print_hnd, - PRINTER_INFO_0 *printer, - const struct share_params *params) +static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *printer, int snum) { pstring chaine; int count; @@ -3966,15 +3957,14 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd, time_t setuptime; print_status_struct status; - if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, - lp_const_servicename(params->service)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; - count = print_queue_length(params->service, &status); + count = print_queue_length(snum, &status); /* check if we already have a counter for this printer */ for(session_counter = counter_list; session_counter; session_counter = session_counter->next) { - if (session_counter->snum == params->service) + if (session_counter->snum == snum) break; } @@ -3985,7 +3975,7 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd, return False; } ZERO_STRUCTP(session_counter); - session_counter->snum=params->service; + session_counter->snum=snum; session_counter->counter=0; DLIST_ADD(counter_list, session_counter); } @@ -4061,25 +4051,21 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd, * construct_printer_info_1 * fill a printer_info_1 struct ********************************************************************/ -static BOOL construct_printer_info_1(Printer_entry *print_hnd, uint32 flags, - PRINTER_INFO_1 *printer, - const struct share_params *params) +static BOOL construct_printer_info_1(Printer_entry *print_hnd, uint32 flags, PRINTER_INFO_1 *printer, int snum) { pstring chaine; pstring chaine2; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; - if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, - lp_const_servicename(params->service)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; printer->flags=flags; if (*ntprinter->info_2->comment == '\0') { - init_unistr(&printer->comment, lp_comment(params->service)); + init_unistr(&printer->comment, lp_comment(snum)); slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s", ntprinter->info_2->printername, - ntprinter->info_2->drivername, - lp_comment(params->service)); + ntprinter->info_2->drivername, lp_comment(snum)); } else { init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ @@ -4170,7 +4156,7 @@ DEVICEMODE *construct_dev_mode(const char *servicename) DEBUGADD(8,("getting printer characteristics\n")); - if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, servicename))) + if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, servicename))) return NULL; if ( !printer->info_2->devmode ) { @@ -4203,29 +4189,26 @@ done: * fill a printer_info_2 struct ********************************************************************/ -static BOOL construct_printer_info_2(Printer_entry *print_hnd, - PRINTER_INFO_2 *printer, - const struct share_params *params) +static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *printer, int snum) { int count; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; print_status_struct status; - if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, - lp_const_servicename(params->service)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; - count = print_queue_length(params->service, &status); + count = print_queue_length(snum, &status); init_unistr(&printer->servername, ntprinter->info_2->servername); /* servername*/ init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/ - init_unistr(&printer->sharename, lp_servicename(params->service)); /* sharename */ + init_unistr(&printer->sharename, lp_servicename(snum)); /* sharename */ init_unistr(&printer->portname, ntprinter->info_2->portname); /* port */ init_unistr(&printer->drivername, ntprinter->info_2->drivername); /* drivername */ if (*ntprinter->info_2->comment == '\0') - init_unistr(&printer->comment, lp_comment(params->service)); /* comment */ + init_unistr(&printer->comment, lp_comment(snum)); /* comment */ else init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ @@ -4246,7 +4229,7 @@ static BOOL construct_printer_info_2(Printer_entry *print_hnd, printer->averageppm = ntprinter->info_2->averageppm; /* average pages per minute */ if ( !(printer->devmode = construct_dev_mode( - lp_const_servicename(params->service))) ) + lp_const_servicename(snum))) ) DEBUG(8, ("Returning NULL Devicemode!\n")); printer->secdesc = NULL; @@ -4271,15 +4254,12 @@ static BOOL construct_printer_info_2(Printer_entry *print_hnd, * fill a printer_info_3 struct ********************************************************************/ -static BOOL construct_printer_info_3(Printer_entry *print_hnd, - PRINTER_INFO_3 **pp_printer, - const struct share_params *params) +static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 **pp_printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; PRINTER_INFO_3 *printer = NULL; - if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, - lp_const_servicename(params->service)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; *pp_printer = NULL; @@ -4312,14 +4292,11 @@ static BOOL construct_printer_info_3(Printer_entry *print_hnd, * fill a printer_info_4 struct ********************************************************************/ -static BOOL construct_printer_info_4(Printer_entry *print_hnd, - PRINTER_INFO_4 *printer, - const struct share_params *params) +static BOOL construct_printer_info_4(Printer_entry *print_hnd, PRINTER_INFO_4 *printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; - if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, - lp_const_servicename(params->service)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/ @@ -4335,14 +4312,11 @@ static BOOL construct_printer_info_4(Printer_entry *print_hnd, * fill a printer_info_5 struct ********************************************************************/ -static BOOL construct_printer_info_5(Printer_entry *print_hnd, - PRINTER_INFO_5 *printer, - const struct share_params *params) +static BOOL construct_printer_info_5(Printer_entry *print_hnd, PRINTER_INFO_5 *printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; - if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, - lp_const_servicename(params->service)))) + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; init_unistr(&printer->printername, ntprinter->info_2->printername); @@ -4366,17 +4340,17 @@ static BOOL construct_printer_info_5(Printer_entry *print_hnd, static BOOL construct_printer_info_6(Printer_entry *print_hnd, PRINTER_INFO_6 *printer, - const struct share_params *params) + int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; int count; print_status_struct status; if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, - lp_const_servicename(params->service)))) + lp_const_servicename(snum)))) return False; - count = print_queue_length(params->service, &status); + count = print_queue_length(snum, &status); printer->status = nt_printq_status(status.status); @@ -4390,14 +4364,12 @@ static BOOL construct_printer_info_6(Printer_entry *print_hnd, * fill a printer_info_7 struct ********************************************************************/ -static BOOL construct_printer_info_7(Printer_entry *print_hnd, - PRINTER_INFO_7 *printer, - const struct share_params *params) +static BOOL construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *printer, int snum) { char *guid_str = NULL; struct GUID guid; - if (is_printer_published(print_hnd, params->service, &guid)) { + if (is_printer_published(print_hnd, snum, &guid)) { asprintf(&guid_str, "{%s}", smb_uuid_string_static(guid)); strupper_m(guid_str); init_unistr(&printer->guid, guid_str); @@ -4416,45 +4388,31 @@ static BOOL construct_printer_info_7(Printer_entry *print_hnd, static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { + int snum; int i; - struct share_iterator *shares; - struct share_params *printer; + int n_services=lp_numservices(); PRINTER_INFO_1 *printers=NULL; + PRINTER_INFO_1 current_prt; WERROR result = WERR_OK; DEBUG(4,("enum_all_printers_info_1\n")); - if (!(shares = share_list_all(NULL))) { - DEBUG(5, ("Could not list printers\n")); - return WERR_ACCESS_DENIED; - } + for (snum=0; snumservice))); - - if (!construct_printer_info_1(NULL, flags, ¤t_prt, - printer)) { - continue; - } + if (construct_printer_info_1(NULL, flags, ¤t_prt, snum)) { + if((printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_1, *returned +1)) == NULL) { + DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n")); + *returned=0; + return WERR_NOMEM; + } + DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned)); - if((printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_1, - *returned +1)) == NULL) { - DEBUG(2,("enum_all_printers_info_1: failed to enlarge " - "printers buffer!\n")); - *returned=0; - TALLOC_FREE(shares); - return WERR_NOMEM; + memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_1)); + (*returned)++; + } } - DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", - *returned)); - - memcpy(&printers[*returned], ¤t_prt, - sizeof(PRINTER_INFO_1)); - (*returned)++; - TALLOC_FREE(printer); } /* check the required size. */ @@ -4479,7 +4437,6 @@ out: /* clear memory */ SAFE_FREE(printers); - TALLOC_FREE(shares); if ( !W_ERROR_IS_OK(result) ) *returned = 0; @@ -4617,45 +4574,33 @@ static WERROR enum_all_printers_info_1_network(fstring name, RPC_BUFFER *buffer, static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { + int snum; int i; - struct share_iterator *shares; - struct share_params *printer; + int n_services=lp_numservices(); PRINTER_INFO_2 *printers=NULL; + PRINTER_INFO_2 current_prt; WERROR result = WERR_OK; *returned = 0; - if (!(shares = share_list_all(NULL))) { - DEBUG(5, ("Could not list printers\n")); - return WERR_ACCESS_DENIED; - } + for (snum=0; snumservice))); + memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_2)); - if (!construct_printer_info_2(NULL, ¤t_prt, - printer)) { - continue; - } - if ( !(printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_2, - *returned +1)) ) { - DEBUG(2,("enum_all_printers_info_2: failed to enlarge " - "printers buffer!\n")); - *returned = 0; - TALLOC_FREE(shares); - return WERR_NOMEM; + (*returned)++; + } } - - DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", - *returned + 1)); - - memcpy(&printers[*returned], ¤t_prt, - sizeof(PRINTER_INFO_2)); - (*returned)++; - TALLOC_FREE(printer); } /* check the required size. */ @@ -4683,7 +4628,6 @@ out: free_devmode(printers[i].devmode); SAFE_FREE(printers); - TALLOC_FREE(shares); if ( !W_ERROR_IS_OK(result) ) *returned = 0; @@ -4824,10 +4768,7 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_0(Printer_entry *print_hnd, - const struct share_params *params, - RPC_BUFFER *buffer, uint32 offered, - uint32 *needed) +static WERROR getprinter_level_0(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_0 *printer=NULL; WERROR result = WERR_OK; @@ -4835,7 +4776,7 @@ static WERROR getprinter_level_0(Printer_entry *print_hnd, if((printer=SMB_MALLOC_P(PRINTER_INFO_0)) == NULL) return WERR_NOMEM; - construct_printer_info_0(print_hnd, printer, params); + construct_printer_info_0(print_hnd, printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_0(printer); @@ -4864,10 +4805,7 @@ out: /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_1(Printer_entry *print_hnd, - const struct share_params *params, - RPC_BUFFER *buffer, uint32 offered, - uint32 *needed) +static WERROR getprinter_level_1(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_1 *printer=NULL; WERROR result = WERR_OK; @@ -4875,8 +4813,7 @@ static WERROR getprinter_level_1(Printer_entry *print_hnd, if((printer=SMB_MALLOC_P(PRINTER_INFO_1)) == NULL) return WERR_NOMEM; - construct_printer_info_1(print_hnd, PRINTER_ENUM_ICON8, printer, - params); + construct_printer_info_1(print_hnd, PRINTER_ENUM_ICON8, printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_1(printer); @@ -4904,10 +4841,7 @@ out: /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_2(Printer_entry *print_hnd, - const struct share_params *params, - RPC_BUFFER *buffer, uint32 offered, - uint32 *needed) +static WERROR getprinter_level_2(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_2 *printer=NULL; WERROR result = WERR_OK; @@ -4915,7 +4849,7 @@ static WERROR getprinter_level_2(Printer_entry *print_hnd, if((printer=SMB_MALLOC_P(PRINTER_INFO_2))==NULL) return WERR_NOMEM; - construct_printer_info_2(print_hnd, printer, params); + construct_printer_info_2(print_hnd, printer, snum); /* check the required size. */ *needed += spoolss_size_printer_info_2(printer); @@ -4944,15 +4878,12 @@ out: /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_3(Printer_entry *print_hnd, - const struct share_params *params, - RPC_BUFFER *buffer, uint32 offered, - uint32 *needed) +static WERROR getprinter_level_3(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_3 *printer=NULL; WERROR result = WERR_OK; - if (!construct_printer_info_3(print_hnd, &printer, params)) + if (!construct_printer_info_3(print_hnd, &printer, snum)) return WERR_NOMEM; /* check the required size. */ @@ -4981,10 +4912,7 @@ out: /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_4(Printer_entry *print_hnd, - const struct share_params *params, - RPC_BUFFER *buffer, uint32 offered, - uint32 *needed) +static WERROR getprinter_level_4(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_4 *printer=NULL; WERROR result = WERR_OK; @@ -4992,7 +4920,7 @@ static WERROR getprinter_level_4(Printer_entry *print_hnd, if((printer=SMB_MALLOC_P(PRINTER_INFO_4))==NULL) return WERR_NOMEM; - if (!construct_printer_info_4(print_hnd, printer, params)) { + if (!construct_printer_info_4(print_hnd, printer, snum)) { SAFE_FREE(printer); return WERR_NOMEM; } @@ -5023,10 +4951,7 @@ out: /**************************************************************************** ****************************************************************************/ -static WERROR getprinter_level_5(Printer_entry *print_hnd, - const struct share_params *params, - RPC_BUFFER *buffer, uint32 offered, - uint32 *needed) +static WERROR getprinter_level_5(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_5 *printer=NULL; WERROR result = WERR_OK; @@ -5034,7 +4959,7 @@ static WERROR getprinter_level_5(Printer_entry *print_hnd, if((printer=SMB_MALLOC_P(PRINTER_INFO_5))==NULL) return WERR_NOMEM; - if (!construct_printer_info_5(print_hnd, printer, params)) { + if (!construct_printer_info_5(print_hnd, printer, snum)) { free_printer_info_5(printer); return WERR_NOMEM; } @@ -5063,7 +4988,7 @@ out: } static WERROR getprinter_level_6(Printer_entry *print_hnd, - const struct share_params *params, + int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { @@ -5074,7 +4999,7 @@ static WERROR getprinter_level_6(Printer_entry *print_hnd, return WERR_NOMEM; } - if (!construct_printer_info_6(print_hnd, printer, params)) { + if (!construct_printer_info_6(print_hnd, printer, snum)) { free_printer_info_6(printer); return WERR_NOMEM; } @@ -5102,10 +5027,7 @@ out: return result; } -static WERROR getprinter_level_7(Printer_entry *print_hnd, - const struct share_params *params, - RPC_BUFFER *buffer, uint32 offered, - uint32 *needed) +static WERROR getprinter_level_7(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { PRINTER_INFO_7 *printer=NULL; WERROR result = WERR_OK; @@ -5113,7 +5035,7 @@ static WERROR getprinter_level_7(Printer_entry *print_hnd, if((printer=SMB_MALLOC_P(PRINTER_INFO_7))==NULL) return WERR_NOMEM; - if (!construct_printer_info_7(print_hnd, printer, params)) + if (!construct_printer_info_7(print_hnd, printer, snum)) return WERR_NOMEM; /* check the required size. */ @@ -5151,7 +5073,6 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); - struct share_params *params; int snum; @@ -5166,34 +5087,26 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET *needed=0; - if (!get_printer_snum(p, handle, &snum, ¶ms)) + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; switch (level) { case 0: - return getprinter_level_0(Printer, params, buffer, offered, - needed); + return getprinter_level_0(Printer, snum, buffer, offered, needed); case 1: - return getprinter_level_1(Printer, params, buffer, offered, - needed); + return getprinter_level_1(Printer, snum, buffer, offered, needed); case 2: - return getprinter_level_2(Printer, params, buffer, offered, - needed); + return getprinter_level_2(Printer, snum, buffer, offered, needed); case 3: - return getprinter_level_3(Printer, params, buffer, offered, - needed); + return getprinter_level_3(Printer, snum, buffer, offered, needed); case 4: - return getprinter_level_4(Printer, params, buffer, offered, - needed); + return getprinter_level_4(Printer, snum, buffer, offered, needed); case 5: - return getprinter_level_5(Printer, params, buffer, offered, - needed); - case 6: - return getprinter_level_6(Printer, params, buffer, offered, - needed); + return getprinter_level_5(Printer, snum, buffer, offered, needed); + case 6: + return getprinter_level_6(Printer, snum, buffer, offered, needed); case 7: - return getprinter_level_7(Printer, params, buffer, offered, - needed); + return getprinter_level_7(Printer, snum, buffer, offered, needed); } return WERR_UNKNOWN_LEVEL; } diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c new file mode 100644 index 0000000000..92ed7274cc --- /dev/null +++ b/source3/rpc_server/srv_srvsvc.c @@ -0,0 +1,616 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997, + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, + * Copyright (C) Paul Ashton 1997, + * Copyright (C) Jeremy Allison 2001, + * Copyright (C) Jim McDonough 2003. + * Copyright (C) Gera;d (Jerry) Carter 2006. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +/* This is the interface to the srvsvc pipe. */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +static BOOL proxy_srvsvc_call(pipes_struct *p, uint8 opnum) +{ + struct api_struct *fns; + int n_fns; + + lsarpc_get_pipe_fns(&fns, &n_fns); + + if (opnum >= n_fns) + return False; + + if (fns[opnum].opnum != opnum) { + smb_panic("LSA function table not sorted\n"); + } + + return fns[opnum].fn(p); +} + +/******************************************************************* + api_srv_net_srv_get_info +********************************************************************/ + +static BOOL api_srv_net_srv_get_info(pipes_struct *p) +{ + SRV_Q_NET_SRV_GET_INFO q_u; + SRV_R_NET_SRV_GET_INFO r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the net server get info */ + if (!srv_io_q_net_srv_get_info("", &q_u, data, 0)) + return False; + + r_u.status = _srv_net_srv_get_info(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if (!srv_io_r_net_srv_get_info("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + api_srv_net_srv_get_info +********************************************************************/ + +static BOOL api_srv_net_srv_set_info(pipes_struct *p) +{ + SRV_Q_NET_SRV_SET_INFO q_u; + SRV_R_NET_SRV_SET_INFO r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the net server set info */ + if (!srv_io_q_net_srv_set_info("", &q_u, data, 0)) + return False; + + r_u.status = _srv_net_srv_set_info(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if (!srv_io_r_net_srv_set_info("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + api_srv_net_file_enum +********************************************************************/ + +static BOOL api_srv_net_file_enum(pipes_struct *p) +{ + SRV_Q_NET_FILE_ENUM q_u; + SRV_R_NET_FILE_ENUM r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the net file enum */ + if (!srv_io_q_net_file_enum("", &q_u, data, 0)) + return False; + + r_u.status = _srv_net_file_enum(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!srv_io_r_net_file_enum("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + api_srv_net_conn_enum +********************************************************************/ + +static BOOL api_srv_net_conn_enum(pipes_struct *p) +{ + SRV_Q_NET_CONN_ENUM q_u; + SRV_R_NET_CONN_ENUM r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the net server get enum */ + if (!srv_io_q_net_conn_enum("", &q_u, data, 0)) + return False; + + r_u.status = _srv_net_conn_enum(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if (!srv_io_r_net_conn_enum("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + Enumerate sessions. +********************************************************************/ + +static BOOL api_srv_net_sess_enum(pipes_struct *p) +{ + SRV_Q_NET_SESS_ENUM q_u; + SRV_R_NET_SESS_ENUM r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the net server get enum */ + if (!srv_io_q_net_sess_enum("", &q_u, data, 0)) + return False; + + /* construct reply. always indicate success */ + r_u.status = _srv_net_sess_enum(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if (!srv_io_r_net_sess_enum("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + Delete session. +********************************************************************/ + +static BOOL api_srv_net_sess_del(pipes_struct *p) +{ + SRV_Q_NET_SESS_DEL q_u; + SRV_R_NET_SESS_DEL r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the net server get enum */ + if (!srv_io_q_net_sess_del("", &q_u, data, 0)) + return False; + + /* construct reply. always indicate success */ + r_u.status = _srv_net_sess_del(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if (!srv_io_r_net_sess_del("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + RPC to enumerate shares. +********************************************************************/ + +static BOOL api_srv_net_share_enum_all(pipes_struct *p) +{ + SRV_Q_NET_SHARE_ENUM q_u; + SRV_R_NET_SHARE_ENUM r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server get enum. */ + if(!srv_io_q_net_share_enum("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_share_enum_all: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n")); + return False; + } + + r_u.status = _srv_net_share_enum_all(p, &q_u, &r_u); + + if (!srv_io_r_net_share_enum("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_enum_all: Failed to marshall SRV_R_NET_SHARE_ENUM.\n")); + return False; + } + + return True; +} + +/******************************************************************* + RPC to enumerate shares. +********************************************************************/ + +static BOOL api_srv_net_share_enum(pipes_struct *p) +{ + SRV_Q_NET_SHARE_ENUM q_u; + SRV_R_NET_SHARE_ENUM r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server get enum. */ + if(!srv_io_q_net_share_enum("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_share_enum: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n")); + return False; + } + + r_u.status = _srv_net_share_enum(p, &q_u, &r_u); + + if (!srv_io_r_net_share_enum("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_enum: Failed to marshall SRV_R_NET_SHARE_ENUM.\n")); + return False; + } + + return True; +} + +/******************************************************************* + RPC to return share information. +********************************************************************/ + +static BOOL api_srv_net_share_get_info(pipes_struct *p) +{ + SRV_Q_NET_SHARE_GET_INFO q_u; + SRV_R_NET_SHARE_GET_INFO r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server get info. */ + if(!srv_io_q_net_share_get_info("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_share_get_info: Failed to unmarshall SRV_Q_NET_SHARE_GET_INFO.\n")); + return False; + } + + r_u.status = _srv_net_share_get_info(p, &q_u, &r_u); + + if(!srv_io_r_net_share_get_info("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_get_info: Failed to marshall SRV_R_NET_SHARE_GET_INFO.\n")); + return False; + } + + return True; +} + +/******************************************************************* + RPC to set share information. +********************************************************************/ + +static BOOL api_srv_net_share_set_info(pipes_struct *p) +{ + SRV_Q_NET_SHARE_SET_INFO q_u; + SRV_R_NET_SHARE_SET_INFO r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server set info. */ + if(!srv_io_q_net_share_set_info("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_share_set_info: Failed to unmarshall SRV_Q_NET_SHARE_SET_INFO.\n")); + return False; + } + + r_u.status = _srv_net_share_set_info(p, &q_u, &r_u); + + if(!srv_io_r_net_share_set_info("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_set_info: Failed to marshall SRV_R_NET_SHARE_SET_INFO.\n")); + return False; + } + + return True; +} + +/******************************************************************* + RPC to add share information. +********************************************************************/ + +static BOOL api_srv_net_share_add(pipes_struct *p) +{ + SRV_Q_NET_SHARE_ADD q_u; + SRV_R_NET_SHARE_ADD r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server add info. */ + if(!srv_io_q_net_share_add("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_share_add: Failed to unmarshall SRV_Q_NET_SHARE_ADD.\n")); + return False; + } + + r_u.status = _srv_net_share_add(p, &q_u, &r_u); + + if(!srv_io_r_net_share_add("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_add: Failed to marshall SRV_R_NET_SHARE_ADD.\n")); + return False; + } + + return True; +} + +/******************************************************************* + RPC to delete share information. +********************************************************************/ + +static BOOL api_srv_net_share_del(pipes_struct *p) +{ + SRV_Q_NET_SHARE_DEL q_u; + SRV_R_NET_SHARE_DEL r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server del info. */ + if(!srv_io_q_net_share_del("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_share_del: Failed to unmarshall SRV_Q_NET_SHARE_DEL.\n")); + return False; + } + + r_u.status = _srv_net_share_del(p, &q_u, &r_u); + + if(!srv_io_r_net_share_del("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_del: Failed to marshall SRV_R_NET_SHARE_DEL.\n")); + return False; + } + + return True; +} + +/******************************************************************* + RPC to delete share information. +********************************************************************/ + +static BOOL api_srv_net_share_del_sticky(pipes_struct *p) +{ + SRV_Q_NET_SHARE_DEL q_u; + SRV_R_NET_SHARE_DEL r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server del info. */ + if(!srv_io_q_net_share_del("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_share_del_sticky: Failed to unmarshall SRV_Q_NET_SHARE_DEL.\n")); + return False; + } + + r_u.status = _srv_net_share_del_sticky(p, &q_u, &r_u); + + if(!srv_io_r_net_share_del("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_share_del_sticky: Failed to marshall SRV_R_NET_SHARE_DEL.\n")); + return False; + } + + return True; +} + +/******************************************************************* + api_srv_net_remote_tod +********************************************************************/ + +static BOOL api_srv_net_remote_tod(pipes_struct *p) +{ + SRV_Q_NET_REMOTE_TOD q_u; + SRV_R_NET_REMOTE_TOD r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the net server get enum */ + if(!srv_io_q_net_remote_tod("", &q_u, data, 0)) + return False; + + r_u.status = _srv_net_remote_tod(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if(!srv_io_r_net_remote_tod("", &r_u, rdata, 0)) + return False; + + return True; +} + +/******************************************************************* + RPC to enumerate disks available on a server e.g. C:, D: ... +*******************************************************************/ + +static BOOL api_srv_net_disk_enum(pipes_struct *p) +{ + SRV_Q_NET_DISK_ENUM q_u; + SRV_R_NET_DISK_ENUM r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server disk enum. */ + if(!srv_io_q_net_disk_enum("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_disk_enum: Failed to unmarshall SRV_Q_NET_DISK_ENUM.\n")); + return False; + } + + r_u.status = _srv_net_disk_enum(p, &q_u, &r_u); + + if(!srv_io_r_net_disk_enum("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_disk_enum: Failed to marshall SRV_R_NET_DISK_ENUM.\n")); + return False; + } + + return True; +} + +/******************************************************************* + NetValidateName (opnum 0x21) +*******************************************************************/ + +static BOOL api_srv_net_name_validate(pipes_struct *p) +{ + SRV_Q_NET_NAME_VALIDATE q_u; + SRV_R_NET_NAME_VALIDATE r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net server disk enum. */ + if(!srv_io_q_net_name_validate("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_name_validate: Failed to unmarshall SRV_Q_NET_NAME_VALIDATE.\n")); + return False; + } + + r_u.status = _srv_net_name_validate(p, &q_u, &r_u); + + if(!srv_io_r_net_name_validate("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_name_validate: Failed to marshall SRV_R_NET_NAME_VALIDATE.\n")); + return False; + } + + return True; +} + +/******************************************************************* + NetFileQuerySecdesc (opnum 0x27) +*******************************************************************/ + +static BOOL api_srv_net_file_query_secdesc(pipes_struct *p) +{ + SRV_Q_NET_FILE_QUERY_SECDESC q_u; + SRV_R_NET_FILE_QUERY_SECDESC r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net file get info from Win9x */ + if(!srv_io_q_net_file_query_secdesc("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_file_query_secdesc: Failed to unmarshall SRV_Q_NET_FILE_QUERY_SECDESC.\n")); + return False; + } + + r_u.status = _srv_net_file_query_secdesc(p, &q_u, &r_u); + + if(!srv_io_r_net_file_query_secdesc("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_file_query_secdesc: Failed to marshall SRV_R_NET_FILE_QUERY_SECDESC.\n")); + return False; + } + + return True; +} + +/******************************************************************* + NetFileSetSecdesc (opnum 0x28) +*******************************************************************/ + +static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) +{ + SRV_Q_NET_FILE_SET_SECDESC q_u; + SRV_R_NET_FILE_SET_SECDESC r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* Unmarshall the net file set info from Win9x */ + if(!srv_io_q_net_file_set_secdesc("", &q_u, data, 0)) { + DEBUG(0,("api_srv_net_file_set_secdesc: Failed to unmarshall SRV_Q_NET_FILE_SET_SECDESC.\n")); + return False; + } + + r_u.status = _srv_net_file_set_secdesc(p, &q_u, &r_u); + + if(!srv_io_r_net_file_set_secdesc("", &r_u, rdata, 0)) { + DEBUG(0,("api_srv_net_file_set_secdesc: Failed to marshall SRV_R_NET_FILE_SET_SECDESC.\n")); + return False; + } + + return True; +} + +/******************************************************************* +*******************************************************************/ + +static BOOL api_srv_net_file_close(pipes_struct *p) +{ + return proxy_srvsvc_call( p, NDR_SRVSVC_NETFILECLOSE ); +} + +/******************************************************************* +\PIPE\srvsvc commands +********************************************************************/ + +static struct api_struct api_srv_cmds[] = +{ + { "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum }, + { "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum }, + { "SRV_NET_SESS_DEL" , SRV_NET_SESS_DEL , api_srv_net_sess_del }, + { "SRV_NET_SHARE_ENUM_ALL" , SRV_NET_SHARE_ENUM_ALL , api_srv_net_share_enum_all }, + { "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum }, + { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, + { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del }, + { "SRV_NET_SHARE_DEL_STICKY" , SRV_NET_SHARE_DEL_STICKY , api_srv_net_share_del_sticky }, + { "SRV_NET_SHARE_GET_INFO" , SRV_NET_SHARE_GET_INFO , api_srv_net_share_get_info }, + { "SRV_NET_SHARE_SET_INFO" , SRV_NET_SHARE_SET_INFO , api_srv_net_share_set_info }, + { "SRV_NET_FILE_ENUM" , SRV_NET_FILE_ENUM , api_srv_net_file_enum }, + { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, + { "SRV_NET_SRV_SET_INFO" , SRV_NET_SRV_SET_INFO , api_srv_net_srv_set_info }, + { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, + { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, + { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate }, + { "SRV_NET_FILE_QUERY_SECDESC", SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc }, + { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc }, + { "SRV_NET_FILE_CLOSE" , SRV_NET_FILE_CLOSE , api_srv_net_file_close } +}; + +void srvsvc2_get_pipe_fns( struct api_struct **fns, int *n_fns ) +{ + *fns = api_srv_cmds; + *n_fns = sizeof(api_srv_cmds) / sizeof(struct api_struct); +} + + +NTSTATUS rpc_srvsvc2_init(void) +{ + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "srvsvc", "ntsvcs", api_srv_cmds, + sizeof(api_srv_cmds) / sizeof(struct api_struct)); +} diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 2af4c79002..f23d6dfcb9 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -5,7 +5,6 @@ * Copyright (C) Jeremy Allison 2001. * Copyright (C) Nigel Williams 2001. * Copyright (C) Gerald (Jerry) Carter 2006. - * Copyright (C) Jelmer Vernooij 2006. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,10 +24,7 @@ #include "includes.h" -#define MAX_SERVER_DISK_ENTRIES 15 - extern const struct generic_mapping file_generic_mapping; -extern userdom_struct current_user_info; #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV @@ -38,8 +34,8 @@ extern userdom_struct current_user_info; struct file_enum_count { TALLOC_CTX *ctx; const char *username; - uint32 count; - struct srvsvc_NetFileInfo3 *info; + int count; + FILE_INFO_3 *info; }; struct sess_file_count { @@ -56,7 +52,7 @@ static int pipe_enum_fn( struct db_record *rec, void *p) { struct pipe_open_rec prec; struct file_enum_count *fenum = (struct file_enum_count *)p; - struct srvsvc_NetFileInfo3 *f; + FILE_INFO_3 *f; int i = fenum->count; pstring fullpath; const char *username; @@ -79,25 +75,19 @@ static int pipe_enum_fn( struct db_record *rec, void *p) snprintf( fullpath, sizeof(fullpath), "\\PIPE\\%s", prec.name ); - f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, - struct srvsvc_NetFileInfo3, i+1 ); + f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 ); if ( !f ) { DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); return 1; } - fenum->info = f; - fenum->info[i].fid = (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum); - fenum->info[i].permissions = (FILE_READ_DATA|FILE_WRITE_DATA); - fenum->info[i].num_locks = 0; - fenum->info[i].user = talloc_move(fenum->ctx, &username); - if (!(fenum->info[i].path = talloc_strdup( - fenum->ctx, fullpath))) { - /* There's not much we can do here. */ - fenum->info[i].path = ""; - } - + init_srv_file_info3( + &fenum->info[i], + (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum), + (FILE_READ_DATA|FILE_WRITE_DATA), + 0, username, fullpath); + fenum->count++; return 0; @@ -107,15 +97,15 @@ static int pipe_enum_fn( struct db_record *rec, void *p) ********************************************************************/ static WERROR net_enum_pipes( TALLOC_CTX *ctx, const char *username, - struct srvsvc_NetFileInfo3 **info, - uint32 *count, uint32 *resume ) + FILE_INFO_3 **info, + uint32 *count, uint32 resume ) { struct file_enum_count fenum; - + fenum.ctx = ctx; fenum.username = username; - fenum.info = *info; fenum.count = *count; + fenum.info = *info; if (connections_traverse(pipe_enum_fn, &fenum) == -1) { DEBUG(0,("net_enum_pipes: traverse of connections.tdb " @@ -136,10 +126,10 @@ static void enum_file_fn( const struct share_mode_entry *e, const char *sharepath, const char *fname, void *private_data ) { - struct file_enum_count *fenum = - (struct file_enum_count *)private_data; + struct file_enum_count *fenum = + (struct file_enum_count *)private_data; - struct srvsvc_NetFileInfo3 *f; + FILE_INFO_3 *f; int i = fenum->count; files_struct fsp; struct byte_range_lock *brl; @@ -150,7 +140,7 @@ static void enum_file_fn( const struct share_mode_entry *e, /* If the pid was not found delete the entry from connections.tdb */ - if (!process_exists(e->pid)) { + if ( !process_exists(e->pid) ) { return; } @@ -161,8 +151,7 @@ static void enum_file_fn( const struct share_mode_entry *e, return; } - f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, - struct srvsvc_NetFileInfo3, i+1 ); + f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 ); if ( !f ) { DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); return; @@ -174,7 +163,7 @@ static void enum_file_fn( const struct share_mode_entry *e, ZERO_STRUCT( fsp ); fsp.file_id = e->id; - if ( (brl = brl_get_locks_readonly(NULL,&fsp)) != NULL ) { + if ( (brl = brl_get_locks(NULL,&fsp)) != NULL ) { num_locks = brl->num_locks; TALLOC_FREE( brl ); } @@ -189,15 +178,13 @@ static void enum_file_fn( const struct share_mode_entry *e, /* mask out create (what ever that is) */ permissions = e->share_access & (FILE_READ_DATA|FILE_WRITE_DATA); - fenum->info[i].fid = e->share_file_id; - fenum->info[i].permissions = permissions; - fenum->info[i].num_locks = num_locks; - fenum->info[i].user = talloc_move(fenum->ctx, &username); - if (!(fenum->info[i].path = talloc_strdup( - fenum->ctx, fullpath))) { - /* There's not much we can do here. */ - fenum->info[i].path = ""; - } + /* now fill in the FILE_INFO_3 struct */ + init_srv_file_info3( &fenum->info[i], + e->share_file_id, + permissions, + num_locks, + username, + fullpath ); fenum->count++; } @@ -206,8 +193,8 @@ static void enum_file_fn( const struct share_mode_entry *e, ********************************************************************/ static WERROR net_enum_files( TALLOC_CTX *ctx, const char *username, - struct srvsvc_NetFileInfo3 **info, - uint32 *count, uint32 *resume ) + FILE_INFO_3 **info, + uint32 *count, uint32 resume ) { struct file_enum_count f_enum_cnt; @@ -225,19 +212,19 @@ static WERROR net_enum_files( TALLOC_CTX *ctx, const char *username, } /******************************************************************* - Utility function to get the 'type' of a share from a share definition. + Utility function to get the 'type' of a share from an snum. ********************************************************************/ -static uint32 get_share_type(const struct share_params *params) +static uint32 get_share_type(int snum) { - char *net_name = lp_servicename(params->service); + char *net_name = lp_servicename(snum); int len_net_name = strlen(net_name); /* work out the share type */ uint32 type = STYPE_DISKTREE; - if (lp_print_ok(params->service)) + if (lp_print_ok(snum)) type = STYPE_PRINTQ; - if (strequal(lp_fstype(params->service), "IPC")) + if (strequal(lp_fstype(snum), "IPC")) type = STYPE_IPC; if (net_name[len_net_name-1] == '$') type |= STYPE_HIDDEN; @@ -249,70 +236,65 @@ static uint32 get_share_type(const struct share_params *params) Fill in a share info level 0 structure. ********************************************************************/ -static void init_srv_share_info_0(pipes_struct *p, struct srvsvc_NetShareInfo0 *sh0, - const struct share_params *params) +static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int snum) { - sh0->name = lp_servicename(params->service); + pstring net_name; + + pstrcpy(net_name, lp_servicename(snum)); + + init_srv_share_info0(&sh0->info_0, net_name); + init_srv_share_info0_str(&sh0->info_0_str, net_name); } /******************************************************************* Fill in a share info level 1 structure. ********************************************************************/ -static void init_srv_share_info_1(pipes_struct *p, struct srvsvc_NetShareInfo1 *sh1, - const struct share_params *params) +static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum) { - connection_struct *conn = p->conn; + pstring remark; - sh1->comment = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), - conn->user, conn->connectpath, conn->gid, - get_current_username(), - current_user_info.domain, - lp_comment(params->service)); + char *net_name = lp_servicename(snum); + pstrcpy(remark, lp_comment(snum)); + standard_sub_conn(p->conn, remark,sizeof(remark)); - sh1->name = lp_servicename(params->service); - sh1->type = get_share_type(params); + init_srv_share_info1(&sh1->info_1, net_name, get_share_type(snum), remark); + init_srv_share_info1_str(&sh1->info_1_str, net_name, remark); } /******************************************************************* Fill in a share info level 2 structure. ********************************************************************/ -static void init_srv_share_info_2(pipes_struct *p, struct srvsvc_NetShareInfo2 *sh2, - const struct share_params *params) +static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int snum) { - connection_struct *conn = p->conn; - char *remark; - char *path; - int max_connections = lp_max_connections(params->service); + pstring remark; + pstring path; + pstring passwd; + int max_connections = lp_max_connections(snum); uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff; int count = 0; - char *net_name = lp_servicename(params->service); + char *net_name = lp_servicename(snum); - remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), - conn->user, conn->connectpath, conn->gid, - get_current_username(), - current_user_info.domain, - lp_comment(params->service)); - path = talloc_asprintf(p->mem_ctx, "C:%s", - lp_pathname(params->service)); + pstrcpy(remark, lp_comment(snum)); + standard_sub_conn(p->conn, remark,sizeof(remark)); + pstrcpy(path, "C:"); + pstrcat(path, lp_pathname(snum)); /* - * Change / to \\ so that win2k will see it as a valid path. This was - * added to enable use of browsing in win2k add share dialog. + * Change / to \\ so that win2k will see it as a valid path. This was added to + * enable use of browsing in win2k add share dialog. */ string_replace(path, '/', '\\'); + pstrcpy(passwd, ""); + count = count_current_connections( net_name, False ); - sh2->name = net_name; - sh2->type = get_share_type(params); - sh2->comment = remark; - sh2->permissions = 0; - sh2->max_users = max_uses; - sh2->current_users = count; - sh2->path = path; - sh2->password = ""; + init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum), + remark, 0, max_uses, count, path, passwd); + + init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); } /******************************************************************* @@ -344,40 +326,28 @@ static void map_generic_share_sd_bits(SEC_DESC *psd) Fill in a share info level 501 structure. ********************************************************************/ -static void init_srv_share_info_501(pipes_struct *p, struct srvsvc_NetShareInfo501 *sh501, - const struct share_params *params) +static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum) { - connection_struct *conn = p->conn; - char *remark; - const char *net_name = lp_servicename(params->service); + pstring remark; - remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), - conn->user, conn->connectpath, conn->gid, - get_current_username(), - current_user_info.domain, - lp_comment(params->service)); + const char *net_name = lp_servicename(snum); + pstrcpy(remark, lp_comment(snum)); + standard_sub_conn(p->conn, remark, sizeof(remark)); - - sh501->name = net_name; - sh501->type = get_share_type(params); - sh501->comment = remark; - sh501->csc_policy = (lp_csc_policy(params->service) << 4); + init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), remark, (lp_csc_policy(snum) << 4)); + init_srv_share_info501_str(&sh501->info_501_str, net_name, remark); } /******************************************************************* Fill in a share info level 502 structure. ********************************************************************/ -static void init_srv_share_info_502(pipes_struct *p, struct srvsvc_NetShareInfo502 *sh502, - const struct share_params *params) +static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, int snum) { - int max_connections = lp_max_connections(params->service); - uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff; - connection_struct *conn = p->conn; - int count; - char *net_name; - char *remark; - char *path; + pstring net_name; + pstring remark; + pstring path; + pstring passwd; SEC_DESC *sd; size_t sd_size; TALLOC_CTX *ctx = p->mem_ctx; @@ -385,112 +355,87 @@ static void init_srv_share_info_502(pipes_struct *p, struct srvsvc_NetShareInfo5 ZERO_STRUCTP(sh502); - net_name = lp_servicename(params->service); - count = count_current_connections( net_name, False ); - - remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), - conn->user, conn->connectpath, conn->gid, - get_current_username(), - current_user_info.domain, - lp_comment(params->service)); - - path = talloc_asprintf(p->mem_ctx, "C:%s", - lp_pathname(params->service)); + pstrcpy(net_name, lp_servicename(snum)); + pstrcpy(remark, lp_comment(snum)); + standard_sub_conn(p->conn, remark,sizeof(remark)); + pstrcpy(path, "C:"); + pstrcat(path, lp_pathname(snum)); /* - * Change / to \\ so that win2k will see it as a valid path. This was - * added to enable use of browsing in win2k add share dialog. + * Change / to \\ so that win2k will see it as a valid path. This was added to + * enable use of browsing in win2k add share dialog. */ string_replace(path, '/', '\\'); - sd = get_share_security(ctx, lp_servicename(params->service), - &sd_size); + pstrcpy(passwd, ""); + + sd = get_share_security(ctx, lp_servicename(snum), &sd_size); - sh502->name = net_name; - sh502->type = get_share_type(params); - sh502->comment = remark; - sh502->path = path; - sh502->password = ""; - sh502->sd = sd; - sh502->permissions = 0; - sh502->max_users = max_uses; - sh502->current_users = count; - sh502->unknown = 1; + init_srv_share_info502(&sh502->info_502, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size); + init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, path, passwd, sd, sd_size); } /*************************************************************************** Fill in a share info level 1004 structure. ***************************************************************************/ -static void init_srv_share_info_1004(pipes_struct *p, - struct srvsvc_NetShareInfo1004* sh1004, - const struct share_params *params) +static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh1004, int snum) { - connection_struct *conn = p->conn; - char *remark; + pstring remark; - remark = talloc_sub_advanced(p->mem_ctx, lp_servicename(SNUM(conn)), - conn->user, conn->connectpath, conn->gid, - get_current_username(), - current_user_info.domain, - lp_comment(params->service)); + pstrcpy(remark, lp_comment(snum)); + standard_sub_conn(p->conn, remark, sizeof(remark)); ZERO_STRUCTP(sh1004); - - sh1004->comment = remark; + + init_srv_share_info1004(&sh1004->info_1004, remark); + init_srv_share_info1004_str(&sh1004->info_1004_str, remark); } /*************************************************************************** Fill in a share info level 1005 structure. ***************************************************************************/ -static void init_srv_share_info_1005(pipes_struct *p, - struct srvsvc_NetShareInfo1005* sh1005, - const struct share_params *params) +static void init_srv_share_info_1005(pipes_struct *p, SRV_SHARE_INFO_1005* sh1005, int snum) { - sh1005->dfs_flags = 0; + sh1005->share_info_flags = 0; - if(lp_host_msdfs() && lp_msdfs_root(params->service)) - sh1005->dfs_flags |= + if(lp_host_msdfs() && lp_msdfs_root(snum)) + sh1005->share_info_flags |= SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT; - sh1005->dfs_flags |= - lp_csc_policy(params->service) << SHARE_1005_CSC_POLICY_SHIFT; + sh1005->share_info_flags |= + lp_csc_policy(snum) << SHARE_1005_CSC_POLICY_SHIFT; } /*************************************************************************** Fill in a share info level 1006 structure. ***************************************************************************/ -static void init_srv_share_info_1006(pipes_struct *p, - struct srvsvc_NetShareInfo1006* sh1006, - const struct share_params *params) +static void init_srv_share_info_1006(pipes_struct *p, SRV_SHARE_INFO_1006* sh1006, int snum) { - sh1006->max_users = -1; + sh1006->max_uses = -1; } /*************************************************************************** Fill in a share info level 1007 structure. ***************************************************************************/ -static void init_srv_share_info_1007(pipes_struct *p, - struct srvsvc_NetShareInfo1007* sh1007, - const struct share_params *params) +static void init_srv_share_info_1007(pipes_struct *p, SRV_SHARE_INFO_1007* sh1007, int snum) { + pstring alternate_directory_name = ""; uint32 flags = 0; ZERO_STRUCTP(sh1007); - sh1007->flags = flags; - sh1007->alternate_directory_name = ""; + init_srv_share_info1007(&sh1007->info_1007, flags, alternate_directory_name); + init_srv_share_info1007_str(&sh1007->info_1007_str, alternate_directory_name); } /******************************************************************* Fill in a share info level 1501 structure. ********************************************************************/ -static void init_srv_share_info_1501(pipes_struct *p, - struct sec_desc_buf *sh1501, - const struct share_params *params) +static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh1501, int snum) { SEC_DESC *sd; size_t sd_size; @@ -498,282 +443,350 @@ static void init_srv_share_info_1501(pipes_struct *p, ZERO_STRUCTP(sh1501); - sd = get_share_security(ctx, lp_servicename(params->service), - &sd_size); + sd = get_share_security(ctx, lp_servicename(snum), &sd_size); - sh1501->sd = sd; + sh1501->sdb = make_sec_desc_buf(p->mem_ctx, sd_size, sd); } /******************************************************************* True if it ends in '$'. ********************************************************************/ -static BOOL is_hidden_share(const struct share_params *params) +static BOOL is_hidden_share(int snum) { - const char *net_name = lp_servicename(params->service); + const char *net_name = lp_servicename(snum); - return (net_name[strlen(net_name) - 1] == '$'); + return (net_name[strlen(net_name) - 1] == '$') ? True : False; } /******************************************************************* Fill in a share info structure. ********************************************************************/ -static WERROR init_srv_share_info_ctr(pipes_struct *p, - union srvsvc_NetShareCtr *ctr, - uint32 info_level, uint32 *resume_hnd, - uint32 *total_entries, BOOL all_shares) +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 = 0; + int snum; TALLOC_CTX *ctx = p->mem_ctx; - struct share_iterator *shares; - struct share_params *share; - WERROR result = WERR_NOMEM; DEBUG(5,("init_srv_share_info_ctr\n")); - ZERO_STRUCTP(ctr); + ZERO_STRUCTPN(ctr); - if (resume_hnd) { - *resume_hnd = 0; - } + ctr->info_level = ctr->switch_value = info_level; + *resume_hnd = 0; /* Ensure all the usershares are loaded. */ become_root(); - load_usershare_shares(); + num_services = load_usershare_shares(); load_registry_shares(); unbecome_root(); - *total_entries = 0; - - if (!(shares = share_list_all(ctx))) { - DEBUG(5, ("Could not list shares\n")); - return WERR_ACCESS_DENIED; + /* Count the number of entries. */ + for (snum = 0; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) + num_entries++; } + *total_entries = num_entries; + ctr->num_entries2 = ctr->num_entries = num_entries; + ctr->ptr_share_info = ctr->ptr_entries = 1; + + if (!num_entries) + return True; + switch (info_level) { case 0: - if (!(ctr->ctr0 = TALLOC_ZERO_P( - p->mem_ctx, struct srvsvc_NetShareCtr0))) { - goto done; + { + SRV_SHARE_INFO_0 *info0 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_0, num_entries); + int i = 0; + + if (!info0) { + return False; } + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_0(p, &info0[i++], snum); + } + } + + ctr->share.info0 = info0; break; + + } + case 1: - if (!(ctr->ctr1 = TALLOC_ZERO_P( - p->mem_ctx, struct srvsvc_NetShareCtr1))) { - goto done; + { + SRV_SHARE_INFO_1 *info1 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1, num_entries); + int i = 0; + + if (!info1) { + return False; + } + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1(p, &info1[i++], snum); + } } + + ctr->share.info1 = info1; break; + } + case 2: - if (!(ctr->ctr2 = TALLOC_ZERO_P( - p->mem_ctx, struct srvsvc_NetShareCtr2))) { - goto done; + { + SRV_SHARE_INFO_2 *info2 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_2, num_entries); + int i = 0; + + if (!info2) { + return False; } + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_2(p, &info2[i++], snum); + } + } + + ctr->share.info2 = info2; break; + } + case 501: - if (!(ctr->ctr501 = TALLOC_ZERO_P( - p->mem_ctx, struct srvsvc_NetShareCtr501))) { - goto done; + { + SRV_SHARE_INFO_501 *info501 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_501, num_entries); + int i = 0; + + if (!info501) { + return False; + } + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_501(p, &info501[i++], snum); + } } + + ctr->share.info501 = info501; break; + } + case 502: - if (!(ctr->ctr502 = TALLOC_ZERO_P( - p->mem_ctx, struct srvsvc_NetShareCtr502))) { - goto done; + { + SRV_SHARE_INFO_502 *info502 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_502, num_entries); + int i = 0; + + if (!info502) { + return False; } + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_502(p, &info502[i++], snum); + } + } + + ctr->share.info502 = info502; break; + } + + /* here for completeness but not currently used with enum (1004 - 1501)*/ + case 1004: - if (!(ctr->ctr1004 = TALLOC_ZERO_P( - p->mem_ctx, struct srvsvc_NetShareCtr1004))) { - goto done; + { + SRV_SHARE_INFO_1004 *info1004 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1004, num_entries); + int i = 0; + + if (!info1004) { + return False; + } + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1004(p, &info1004[i++], snum); + } } + + ctr->share.info1004 = info1004; break; + } + case 1005: - if (!(ctr->ctr1005 = TALLOC_ZERO_P( - p->mem_ctx, struct srvsvc_NetShareCtr1005))) { - goto done; + { + SRV_SHARE_INFO_1005 *info1005 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1005, num_entries); + int i = 0; + + if (!info1005) { + return False; } + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1005(p, &info1005[i++], snum); + } + } + + ctr->share.info1005 = info1005; break; + } + case 1006: - if (!(ctr->ctr1006 = TALLOC_ZERO_P( - p->mem_ctx, struct srvsvc_NetShareCtr1006))) { - goto done; + { + SRV_SHARE_INFO_1006 *info1006 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1006, num_entries); + int i = 0; + + if (!info1006) { + return False; } + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1006(p, &info1006[i++], snum); + } + } + + ctr->share.info1006 = info1006; break; + } + case 1007: - if (!(ctr->ctr1007 = TALLOC_ZERO_P( - p->mem_ctx, struct srvsvc_NetShareCtr1007))) { - goto done; + { + SRV_SHARE_INFO_1007 *info1007 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1007, num_entries); + int i = 0; + + if (!info1007) { + return False; + } + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1007(p, &info1007[i++], snum); + } } + + ctr->share.info1007 = info1007; break; + } + case 1501: - if (!(ctr->ctr1501 = TALLOC_ZERO_P( - p->mem_ctx, struct srvsvc_NetShareCtr1501))) { - goto done; + { + SRV_SHARE_INFO_1501 *info1501 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1501, num_entries); + int i = 0; + + if (!info1501) { + return False; } + + for (snum = *resume_hnd; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + init_srv_share_info_1501(p, &info1501[i++], snum); + } + } + + ctr->share.info1501 = info1501; break; + } default: - DEBUG(5,("init_srv_share_info_ctr: unsupported switch " - "value %d\n", info_level)); - return WERR_UNKNOWN_LEVEL; + DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level)); + return False; } - while ((share = next_share(shares)) != NULL) { - if (!lp_browseable(share->service)) { - continue; - } - if (!all_shares && is_hidden_share(share)) { - continue; - } + return True; +} +/******************************************************************* + Inits a SRV_R_NET_SHARE_ENUM structure. +********************************************************************/ + +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(p, &r_n->ctr, info_level, + &resume_hnd, &r_n->total_entries, all)) { + r_n->status = WERR_OK; + } else { + r_n->status = WERR_UNKNOWN_LEVEL; + } + + init_enum_hnd(&r_n->enum_hnd, resume_hnd); +} + +/******************************************************************* + Inits a SRV_R_NET_SHARE_GET_INFO structure. +********************************************************************/ + +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) +{ + WERROR status = WERR_OK; + int snum; + + DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__)); + + r_n->info.switch_value = info_level; + + snum = find_service(share_name); + + if (snum >= 0) { switch (info_level) { case 0: - { - struct srvsvc_NetShareInfo0 i; - init_srv_share_info_0(p, &i, share); - ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo0, i, - &ctr->ctr0->array, &ctr->ctr0->count); - if (ctr->ctr0->array == NULL) { - return WERR_NOMEM; - } - *total_entries = ctr->ctr0->count; + init_srv_share_info_0(p, &r_n->info.share.info0, snum); break; - } - case 1: - { - struct srvsvc_NetShareInfo1 i; - init_srv_share_info_1(p, &i, share); - ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1, i, - &ctr->ctr1->array, &ctr->ctr1->count); - if (ctr->ctr1->array == NULL) { - return WERR_NOMEM; - } - *total_entries = ctr->ctr1->count; + init_srv_share_info_1(p, &r_n->info.share.info1, snum); break; - } - case 2: - { - struct srvsvc_NetShareInfo2 i; - init_srv_share_info_2(p, &i, share); - ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo2, i, - &ctr->ctr2->array, &ctr->ctr2->count); - if (ctr->ctr2->array == NULL) { - return WERR_NOMEM; - } - *total_entries = ctr->ctr2->count; + init_srv_share_info_2(p, &r_n->info.share.info2, snum); break; - } - case 501: - { - struct srvsvc_NetShareInfo501 i; - init_srv_share_info_501(p, &i, share); - ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo501, i, - &ctr->ctr501->array, &ctr->ctr501->count); - if (ctr->ctr501->array == NULL) { - return WERR_NOMEM; - } - *total_entries = ctr->ctr501->count; + init_srv_share_info_501(p, &r_n->info.share.info501, snum); break; - } - case 502: - { - struct srvsvc_NetShareInfo502 i; - init_srv_share_info_502(p, &i, share); - ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo502, i, - &ctr->ctr502->array, &ctr->ctr502->count); - if (ctr->ctr502->array == NULL) { - return WERR_NOMEM; - } - *total_entries = ctr->ctr502->count; + init_srv_share_info_502(p, &r_n->info.share.info502, snum); break; - } - /* here for completeness but not currently used with enum - * (1004 - 1501)*/ - + /* here for completeness */ case 1004: - { - struct srvsvc_NetShareInfo1004 i; - init_srv_share_info_1004(p, &i, share); - ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1004, i, - &ctr->ctr1004->array, &ctr->ctr1004->count); - if (ctr->ctr1004->array == NULL) { - return WERR_NOMEM; - } - *total_entries = ctr->ctr1004->count; + init_srv_share_info_1004(p, &r_n->info.share.info1004, snum); break; - } - case 1005: - { - struct srvsvc_NetShareInfo1005 i; - init_srv_share_info_1005(p, &i, share); - ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1005, i, - &ctr->ctr1005->array, &ctr->ctr1005->count); - if (ctr->ctr1005->array == NULL) { - return WERR_NOMEM; - } - *total_entries = ctr->ctr1005->count; + init_srv_share_info_1005(p, &r_n->info.share.info1005, snum); break; - } + /* here for completeness 1006 - 1501 */ case 1006: - { - struct srvsvc_NetShareInfo1006 i; - init_srv_share_info_1006(p, &i, share); - ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1006, i, - &ctr->ctr1006->array, &ctr->ctr1006->count); - if (ctr->ctr1006->array == NULL) { - return WERR_NOMEM; - } - *total_entries = ctr->ctr1006->count; + init_srv_share_info_1006(p, &r_n->info.share.info1006, snum); break; - } - case 1007: - { - struct srvsvc_NetShareInfo1007 i; - init_srv_share_info_1007(p, &i, share); - ADD_TO_ARRAY(ctx, struct srvsvc_NetShareInfo1007, i, - &ctr->ctr1007->array, &ctr->ctr1007->count); - if (ctr->ctr1007->array == NULL) { - return WERR_NOMEM; - } - *total_entries = ctr->ctr1007->count; + init_srv_share_info_1007(p, &r_n->info.share.info1007, snum); break; - } - case 1501: - { - struct sec_desc_buf i; - init_srv_share_info_1501(p, &i, share); - ADD_TO_ARRAY(ctx, struct sec_desc_buf, i, - &ctr->ctr1501->array, &ctr->ctr1501->count); - if (ctr->ctr1501->array == NULL) { - return WERR_NOMEM; - } - *total_entries = ctr->ctr1501->count; + init_srv_share_info_1501(p, &r_n->info.share.info1501, snum); + break; + default: + DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level)); + status = WERR_UNKNOWN_LEVEL; break; } - } - - TALLOC_FREE(share); + } else { + status = WERR_INVALID_NAME; } - result = WERR_OK; - done: - TALLOC_FREE(shares); - return result; + r_n->info.ptr_share_ctr = W_ERROR_IS_OK(status) ? 1 : 0; + r_n->status = status; } /******************************************************************* fill in a sess info level 0 structure. ********************************************************************/ -static void init_srv_sess_info_0(pipes_struct *p, struct srvsvc_NetSessCtr0 *ss0, uint32 *snum, uint32 *stot) +static void init_srv_sess_info_0(pipes_struct *p, SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot) { struct sessionid *session_list; uint32 num_entries = 0; @@ -788,34 +801,37 @@ static void init_srv_sess_info_0(pipes_struct *p, struct srvsvc_NetSessCtr0 *ss0 DEBUG(5,("init_srv_sess_0_ss0\n")); - ss0->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetSessInfo0, *stot); - if (snum) { - for (; (*snum) < (*stot); (*snum)++) { - ss0->array[num_entries].client = session_list[(*snum)].remote_machine; + for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { + init_srv_sess_info0( &ss0->info_0[num_entries], session_list[(*snum)].remote_machine); num_entries++; } - ss0->count = num_entries; + ss0->num_entries_read = num_entries; + ss0->ptr_sess_info = num_entries > 0 ? 1 : 0; + ss0->num_entries_read2 = num_entries; if ((*snum) >= (*stot)) { (*snum) = 0; } } else { - ss0->array = NULL; - ss0->count = 0; + ss0->num_entries_read = 0; + ss0->ptr_sess_info = 0; + ss0->num_entries_read2 = 0; } } /******************************************************************* ********************************************************************/ +/* global needed to make use of the share_mode_forall() callback */ +static struct sess_file_count s_file_cnt; + static void sess_file_fn( const struct share_mode_entry *e, - const char *sharepath, const char *fname, - void *private_data ) + const char *sharepath, const char *fname, void *state ) { - struct sess_file_count *sess = (struct sess_file_count *)private_data; + struct sess_file_count *sess = &s_file_cnt; if ( procid_equal(&e->pid, &sess->pid) && (sess->uid == e->uid) ) { sess->count++; @@ -829,13 +845,11 @@ static void sess_file_fn( const struct share_mode_entry *e, static int net_count_files( uid_t uid, struct server_id pid ) { - struct sess_file_count s_file_cnt; - s_file_cnt.count = 0; s_file_cnt.uid = uid; s_file_cnt.pid = pid; - share_mode_forall( sess_file_fn, (void *)&s_file_cnt ); + share_mode_forall( sess_file_fn, NULL ); return s_file_cnt.count; } @@ -844,15 +858,16 @@ static int net_count_files( uid_t uid, struct server_id pid ) fill in a sess info level 1 structure. ********************************************************************/ -static void init_srv_sess_info_1(pipes_struct *p, struct srvsvc_NetSessCtr1 *ss1, uint32 *snum, uint32 *stot) +static void init_srv_sess_info_1(pipes_struct *p, SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot) { struct sessionid *session_list; uint32 num_entries = 0; time_t now = time(NULL); if ( !snum ) { - ss1->count = 0; - ss1->array = NULL; + ss1->num_entries_read = 0; + ss1->ptr_sess_info = 0; + ss1->num_entries_read2 = 0; (*stot) = 0; @@ -860,16 +875,14 @@ static void init_srv_sess_info_1(pipes_struct *p, struct srvsvc_NetSessCtr1 *ss1 } if (ss1 == NULL) { - if (snum != NULL) - (*snum) = 0; + (*snum) = 0; return; } (*stot) = list_sessions(p->mem_ctx, &session_list); - - ss1->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetSessInfo1, *stot); - for (; (*snum) < (*stot); (*snum)++) { + + for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { uint32 num_files; uint32 connect_time; struct passwd *pw = sys_getpwnam(session_list[*snum].username); @@ -885,54 +898,52 @@ static void init_srv_sess_info_1(pipes_struct *p, struct srvsvc_NetSessCtr1 *ss1 num_files = net_count_files(pw->pw_uid, session_list[*snum].pid); guest = strequal( session_list[*snum].username, lp_guestaccount() ); - if (!(ss1->array[num_entries].client = talloc_strdup( - ss1->array, session_list[*snum].remote_machine))) { - ss1->array[num_entries].client = ""; - } - if (!(ss1->array[num_entries].user = talloc_strdup( - ss1->array, session_list[*snum].username))) { - ss1->array[num_entries].user = ""; - } - ss1->array[num_entries].num_open = num_files; - ss1->array[num_entries].time = connect_time; - ss1->array[num_entries].idle_time = 0; - ss1->array[num_entries].user_flags = guest; - + init_srv_sess_info1( &ss1->info_1[num_entries], + session_list[*snum].remote_machine, + session_list[*snum].username, + num_files, + connect_time, + 0, + guest); num_entries++; } - ss1->count = num_entries; + ss1->num_entries_read = num_entries; + ss1->ptr_sess_info = num_entries > 0 ? 1 : 0; + ss1->num_entries_read2 = num_entries; if ((*snum) >= (*stot)) { (*snum) = 0; } + } /******************************************************************* makes a SRV_R_NET_SESS_ENUM structure. ********************************************************************/ -static WERROR init_srv_sess_info_ctr(pipes_struct *p, union srvsvc_NetSessCtr *ctr, +static WERROR init_srv_sess_info_ctr(pipes_struct *p, SRV_SESS_INFO_CTR *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { WERROR status = WERR_OK; DEBUG(5,("init_srv_sess_info_ctr: %d\n", __LINE__)); + ctr->switch_value = switch_value; + switch (switch_value) { case 0: - ctr->ctr0 = talloc(p->mem_ctx, struct srvsvc_NetSessCtr0); - init_srv_sess_info_0(p, ctr->ctr0, resume_hnd, total_entries); + init_srv_sess_info_0(p, &(ctr->sess.info0), resume_hnd, total_entries); + ctr->ptr_sess_ctr = 1; break; case 1: - ctr->ctr1 = talloc(p->mem_ctx, struct srvsvc_NetSessCtr1); - init_srv_sess_info_1(p, ctr->ctr1, resume_hnd, total_entries); + init_srv_sess_info_1(p, &(ctr->sess.info1), resume_hnd, total_entries); + ctr->ptr_sess_ctr = 1; break; default: DEBUG(5,("init_srv_sess_info_ctr: unsupported switch value %d\n", switch_value)); - if (resume_hnd != NULL) - (*resume_hnd) = 0; + (*resume_hnd) = 0; (*total_entries) = 0; - ctr->ctr0 = NULL; + ctr->ptr_sess_ctr = 0; status = WERR_UNKNOWN_LEVEL; break; } @@ -940,43 +951,66 @@ static WERROR init_srv_sess_info_ctr(pipes_struct *p, union srvsvc_NetSessCtr *c return status; } +/******************************************************************* + makes a SRV_R_NET_SESS_ENUM structure. +********************************************************************/ + +static void init_srv_r_net_sess_enum(pipes_struct *p, SRV_R_NET_SESS_ENUM *r_n, + uint32 resume_hnd, int sess_level, int switch_value) +{ + DEBUG(5,("init_srv_r_net_sess_enum: %d\n", __LINE__)); + + r_n->sess_level = sess_level; + + if (sess_level == -1) + r_n->status = WERR_UNKNOWN_LEVEL; + else + r_n->status = init_srv_sess_info_ctr(p, r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); + + if (!W_ERROR_IS_OK(r_n->status)) + resume_hnd = 0; + + init_enum_hnd(&r_n->enum_hnd, resume_hnd); +} + /******************************************************************* fill in a conn info level 0 structure. ********************************************************************/ -static void init_srv_conn_info_0(pipes_struct *p, struct srvsvc_NetConnCtr0 *ss0, uint32 *snum, uint32 *stot) +static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *stot) { uint32 num_entries = 0; (*stot) = 1; if (ss0 == NULL) { - if (snum != NULL) - (*snum) = 0; + (*snum) = 0; return; } DEBUG(5,("init_srv_conn_0_ss0\n")); if (snum) { - ss0->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetConnInfo0, *stot); - for (; (*snum) < (*stot); (*snum)++) { + for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) { - ss0->array[num_entries].conn_id = (*stot); + init_srv_conn_info0(&ss0->info_0[num_entries], (*stot)); /* move on to creating next connection */ /* move on to creating next conn */ num_entries++; } - ss0->count = num_entries; + ss0->num_entries_read = num_entries; + ss0->ptr_conn_info = num_entries > 0 ? 1 : 0; + ss0->num_entries_read2 = num_entries; if ((*snum) >= (*stot)) { (*snum) = 0; } } else { - ss0->array = NULL; - ss0->count = 0; + ss0->num_entries_read = 0; + ss0->ptr_conn_info = 0; + ss0->num_entries_read2 = 0; (*stot) = 0; } @@ -986,44 +1020,55 @@ static void init_srv_conn_info_0(pipes_struct *p, struct srvsvc_NetConnCtr0 *ss0 fill in a conn info level 1 structure. ********************************************************************/ -static void init_srv_conn_info_1(pipes_struct *p, struct srvsvc_NetConnCtr1 *ss1, uint32 *snum, uint32 *stot) +static void init_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1, + uint32 id, uint32 type, + uint32 num_opens, uint32 num_users, uint32 open_time, + const char *usr_name, const char *net_name) +{ + init_srv_conn_info1(se1 , id, type, num_opens, num_users, open_time, usr_name, net_name); + init_srv_conn_info1_str(str1, usr_name, net_name); +} + +/******************************************************************* + fill in a conn info level 1 structure. + ********************************************************************/ + +static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *stot) { uint32 num_entries = 0; (*stot) = 1; if (ss1 == NULL) { - if (snum != NULL) - (*snum) = 0; + (*snum) = 0; return; } DEBUG(5,("init_srv_conn_1_ss1\n")); if (snum) { - ss1->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetConnInfo1, *stot); - for (; (*snum) < (*stot); (*snum)++) { - ss1->array[num_entries].conn_id = (*stot); - ss1->array[num_entries].conn_type = 0x3; - ss1->array[num_entries].num_open = 1; - ss1->array[num_entries].num_users = 1; - ss1->array[num_entries].conn_time = 3; - ss1->array[num_entries].user = "dummy_user"; - ss1->array[num_entries].share = "IPC$"; + for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) { + init_srv_conn_1_info(&ss1->info_1[num_entries], + &ss1->info_1_str[num_entries], + (*stot), 0x3, 1, 1, 3,"dummy_user", "IPC$"); /* move on to creating next connection */ /* move on to creating next conn */ num_entries++; } - ss1->count = num_entries; + ss1->num_entries_read = num_entries; + ss1->ptr_conn_info = num_entries > 0 ? 1 : 0; + ss1->num_entries_read2 = num_entries; + if ((*snum) >= (*stot)) { (*snum) = 0; } } else { - ss1->count = 0; - ss1->array = NULL; + ss1->num_entries_read = 0; + ss1->ptr_conn_info = 0; + ss1->num_entries_read2 = 0; (*stot) = 0; } @@ -1033,24 +1078,28 @@ static void init_srv_conn_info_1(pipes_struct *p, struct srvsvc_NetConnCtr1 *ss1 makes a SRV_R_NET_CONN_ENUM structure. ********************************************************************/ -static WERROR init_srv_conn_info_ctr(pipes_struct *p, union srvsvc_NetConnCtr *ctr, +static WERROR init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, int switch_value, uint32 *resume_hnd, uint32 *total_entries) { WERROR status = WERR_OK; DEBUG(5,("init_srv_conn_info_ctr: %d\n", __LINE__)); + ctr->switch_value = switch_value; + switch (switch_value) { case 0: - init_srv_conn_info_0(p, ctr->ctr0, resume_hnd, total_entries); + init_srv_conn_info_0(&ctr->conn.info0, resume_hnd, total_entries); + ctr->ptr_conn_ctr = 1; break; case 1: - init_srv_conn_info_1(p, ctr->ctr1, resume_hnd, total_entries); + init_srv_conn_info_1(&ctr->conn.info1, resume_hnd, total_entries); + ctr->ptr_conn_ctr = 1; break; default: DEBUG(5,("init_srv_conn_info_ctr: unsupported switch value %d\n", switch_value)); - ctr->ctr0 = NULL; - (*resume_hnd) = 0; + (*resume_hnd = 0); (*total_entries) = 0; + ctr->ptr_conn_ctr = 0; status = WERR_UNKNOWN_LEVEL; break; } @@ -1058,46 +1107,84 @@ static WERROR init_srv_conn_info_ctr(pipes_struct *p, union srvsvc_NetConnCtr *c return status; } +/******************************************************************* + makes a SRV_R_NET_CONN_ENUM structure. +********************************************************************/ + +static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, + uint32 resume_hnd, int conn_level, int switch_value) +{ + DEBUG(5,("init_srv_r_net_conn_enum: %d\n", __LINE__)); + + r_n->conn_level = conn_level; + if (conn_level == -1) + r_n->status = WERR_UNKNOWN_LEVEL; + else + r_n->status = init_srv_conn_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); + + if (!W_ERROR_IS_OK(r_n->status)) + resume_hnd = 0; + + init_enum_hnd(&r_n->enum_hnd, resume_hnd); +} + /******************************************************************* makes a SRV_R_NET_FILE_ENUM structure. ********************************************************************/ -static WERROR net_file_enum_3(pipes_struct *p, union srvsvc_NetFileCtr *ctr, - uint32 *resume_hnd, const char *username, - uint32 *num_entries ) +static WERROR net_file_enum_3( const char *username, SRV_R_NET_FILE_ENUM *r, + uint32 resume_hnd ) { - WERROR status; + TALLOC_CTX *ctx = talloc_tos(); + SRV_FILE_INFO_CTR *ctr = &r->ctr; /* TODO -- Windows enumerates (b) active pipes (c) open directories and files */ - ctr->ctr3 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetFileCtr3); - - status = net_enum_files(p->mem_ctx, username, &ctr->ctr3->array, - num_entries, resume_hnd ); - if ( !W_ERROR_IS_OK(status)) - return status; + r->status = net_enum_files( ctx, username, &ctr->file.info3, + &ctr->num_entries, resume_hnd ); + if ( !W_ERROR_IS_OK(r->status)) + goto done; - status = net_enum_pipes(p->mem_ctx, username, &ctr->ctr3->array, - num_entries, resume_hnd ); - if ( !W_ERROR_IS_OK(status)) - return status; - - ctr->ctr3->count = *num_entries; + r->status = net_enum_pipes( ctx, username, &ctr->file.info3, + &ctr->num_entries, resume_hnd ); + if ( !W_ERROR_IS_OK(r->status)) + goto done; - return WERR_OK; + r->level = ctr->level = 3; + r->total_entries = ctr->num_entries; + /* ctr->num_entries = r->total_entries - resume_hnd; */ + ctr->num_entries2 = ctr->num_entries; + ctr->ptr_file_info = 1; + + r->status = WERR_OK; + +done: + if ( ctr->num_entries > 0 ) + ctr->ptr_entries = 1; + + init_enum_hnd(&r->enum_hnd, 0); + + return r->status; } /******************************************************************* *******************************************************************/ -WERROR _srvsvc_NetFileEnum(pipes_struct *p, struct srvsvc_NetFileEnum *r) +WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) { - switch ( *r->in.level ) { - case 3: - return net_file_enum_3(p, r->in.ctr, r->in.resume_handle, - r->in.user, r->out.totalentries ); + switch ( q_u->level ) { + case 3: { + char *username; + if (!(username = rpcstr_pull_unistr2_talloc( + p->mem_ctx, q_u->username))) { + return WERR_NOMEM; + } + + return net_file_enum_3(username, r_u, + get_enum_hnd(&q_u->enum_hnd)); + } default: return WERR_UNKNOWN_LEVEL; } @@ -1109,11 +1196,15 @@ WERROR _srvsvc_NetFileEnum(pipes_struct *p, struct srvsvc_NetFileEnum *r) net server get info ********************************************************************/ -WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, struct srvsvc_NetSrvGetInfo *r) +WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R_NET_SRV_GET_INFO *r_u) { WERROR status = WERR_OK; + SRV_INFO_CTR *ctr = TALLOC_P(p->mem_ctx, SRV_INFO_CTR); - ZERO_STRUCTP(r->out.info); + if (!ctr) + return WERR_NOMEM; + + ZERO_STRUCTP(ctr); DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); @@ -1122,108 +1213,133 @@ WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, struct srvsvc_NetSrvGetInfo *r) return WERR_ACCESS_DENIED; } - switch (r->in.level) { + switch (q_u->switch_value) { /* Technically level 102 should only be available to Administrators but there isn't anything super-secret here, as most of it is made up. */ case 102: - r->out.info->info102 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetSrvInfo102); - - r->out.info->info102->platform_id = 500; - r->out.info->info102->version_major = lp_major_announce_version(); - r->out.info->info102->version_minor = lp_minor_announce_version(); - r->out.info->info102->server_name = global_myname(); - r->out.info->info102->server_type = lp_default_server_announce(); - r->out.info->info102->userpath = "C:\\"; - r->out.info->info102->licenses = 10000; - r->out.info->info102->anndelta = 3000; - r->out.info->info102->disc = 0xf; - r->out.info->info102->users = 0xffffffff; - r->out.info->info102->hidden = 0; - r->out.info->info102->announce = 240; - r->out.info->info102->comment = lp_serverstring(); + init_srv_info_102(&ctr->srv.sv102, + 500, global_myname(), + string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), + lp_major_announce_version(), lp_minor_announce_version(), + lp_default_server_announce(), + 0xffffffff, /* users */ + 0xf, /* disc */ + 0, /* hidden */ + 240, /* announce */ + 3000, /* announce delta */ + 100000, /* licenses */ + "c:\\"); /* user path */ break; case 101: - r->out.info->info101 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetSrvInfo101); - r->out.info->info101->platform_id = 500; - r->out.info->info101->server_name = global_myname(); - r->out.info->info101->version_major = lp_major_announce_version(); - r->out.info->info101->version_minor = lp_minor_announce_version(); - r->out.info->info101->server_type = lp_default_server_announce(); - r->out.info->info101->comment = lp_serverstring(); + init_srv_info_101(&ctr->srv.sv101, + 500, global_myname(), + lp_major_announce_version(), lp_minor_announce_version(), + lp_default_server_announce(), + string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); break; case 100: - r->out.info->info100 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetSrvInfo100); - r->out.info->info100->platform_id = 500; - r->out.info->info100->server_name = global_myname(); + init_srv_info_100(&ctr->srv.sv100, 500, global_myname()); break; default: - return WERR_UNKNOWN_LEVEL; + status = WERR_UNKNOWN_LEVEL; break; } + /* set up the net server get info structure */ + init_srv_r_net_srv_get_info(r_u, q_u->switch_value, ctr, status); + DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); - return status; + return r_u->status; } /******************************************************************* net server set info ********************************************************************/ -WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, struct srvsvc_NetSrvSetInfo *r) +WERROR _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R_NET_SRV_SET_INFO *r_u) { + WERROR status = WERR_OK; + + DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__)); + /* Set up the net server set info structure. */ - if (r->out.parm_error) { - *r->out.parm_error = 0; - } - return WERR_OK; + + init_srv_r_net_srv_set_info(r_u, 0x0, status); + + DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__)); + + return r_u->status; } /******************************************************************* net conn enum ********************************************************************/ -WERROR _srvsvc_NetConnEnum(pipes_struct *p, struct srvsvc_NetConnEnum *r) +WERROR _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_CONN_ENUM *r_u) { DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); - ZERO_STRUCTP(r->out.ctr); + r_u->ctr = TALLOC_P(p->mem_ctx, SRV_CONN_INFO_CTR); + if (!r_u->ctr) + return WERR_NOMEM; + + ZERO_STRUCTP(r_u->ctr); /* set up the */ - return init_srv_conn_info_ctr(p, r->out.ctr, *r->in.level, r->in.resume_handle, r->out.totalentries); + init_srv_r_net_conn_enum(r_u, + get_enum_hnd(&q_u->enum_hnd), + q_u->conn_level, + q_u->ctr->switch_value); + + DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); + + return r_u->status; } /******************************************************************* net sess enum ********************************************************************/ -WERROR _srvsvc_NetSessEnum(pipes_struct *p, struct srvsvc_NetSessEnum *r) +WERROR _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_SESS_ENUM *r_u) { DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__)); - ZERO_STRUCTP(r->out.ctr); + r_u->ctr = TALLOC_P(p->mem_ctx, SRV_SESS_INFO_CTR); + if (!r_u->ctr) + return WERR_NOMEM; + + ZERO_STRUCTP(r_u->ctr); /* set up the */ - return init_srv_sess_info_ctr(p, r->out.ctr, - *r->in.level, - r->in.resume_handle, - r->out.totalentries); + init_srv_r_net_sess_enum(p, r_u, + get_enum_hnd(&q_u->enum_hnd), + q_u->sess_level, + q_u->ctr->switch_value); + + DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__)); + + return r_u->status; } /******************************************************************* net sess del ********************************************************************/ -WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r) +WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SESS_DEL *r_u) { struct sessionid *session_list; + struct current_user user; int num_sessions, snum; - WERROR status; + fstring username; + fstring machine; + BOOL not_root = False; - char *machine = talloc_strdup(p->mem_ctx, r->in.server_unc); + rpcstr_pull_unistr2_fstring(username, &q_u->uni_user_name); + rpcstr_pull_unistr2_fstring(machine, &q_u->uni_cli_name); /* strip leading backslashes if any */ while (machine[0] == '\\') { @@ -1234,11 +1350,13 @@ WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r) DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); - status = WERR_ACCESS_DENIED; + r_u->status = WERR_ACCESS_DENIED; + + get_current_user(&user, p); /* fail out now if you are not root or not a domain admin */ - if ((p->pipe_user.ut.uid != sec_initial_uid()) && + if ((user.ut.uid != sec_initial_uid()) && ( ! nt_token_check_domain_rid(p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS))) { goto done; @@ -1246,30 +1364,41 @@ WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r) for (snum = 0; snum < num_sessions; snum++) { - if ((strequal(session_list[snum].username, r->in.user) || r->in.user[0] == '\0' ) && - strequal(session_list[snum].remote_machine, machine)) { + if ((strequal(session_list[snum].username, username) || username[0] == '\0' ) && + strequal(session_list[snum].remote_machine, machine)) { + NTSTATUS ntstat; + + if (user.ut.uid != sec_initial_uid()) { + not_root = True; + become_root(); + } ntstat = messaging_send(smbd_messaging_context(), session_list[snum].pid, MSG_SHUTDOWN, &data_blob_null); - + if (NT_STATUS_IS_OK(ntstat)) - status = WERR_OK; + r_u->status = WERR_OK; + + if (not_root) + unbecome_root(); } } DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); + done: - return status; + + return r_u->status; } /******************************************************************* Net share enum all. ********************************************************************/ -WERROR _srvsvc_NetShareEnumAll(pipes_struct *p, struct srvsvc_NetShareEnumAll *r) +WERROR _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) { DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); @@ -1279,15 +1408,20 @@ WERROR _srvsvc_NetShareEnumAll(pipes_struct *p, struct srvsvc_NetShareEnumAll *r } /* Create the list of shares for the response. */ - return init_srv_share_info_ctr(p, r->out.ctr, *r->in.level, - r->in.resume_handle, r->out.totalentries, True); + init_srv_r_net_share_enum(p, r_u, + q_u->ctr.info_level, + get_enum_hnd(&q_u->enum_hnd), True); + + DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); + + return r_u->status; } /******************************************************************* Net share enum. ********************************************************************/ -WERROR _srvsvc_NetShareEnum(pipes_struct *p, struct srvsvc_NetShareEnum *r) +WERROR _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) { DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); @@ -1297,80 +1431,32 @@ WERROR _srvsvc_NetShareEnum(pipes_struct *p, struct srvsvc_NetShareEnum *r) } /* Create the list of shares for the response. */ - return init_srv_share_info_ctr(p, r->out.ctr, *r->in.level, - r->in.resume_handle, r->out.totalentries, False); + init_srv_r_net_share_enum(p, r_u, + q_u->ctr.info_level, + get_enum_hnd(&q_u->enum_hnd), False); + + DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); + + return r_u->status; } /******************************************************************* Net share get info. ********************************************************************/ -WERROR _srvsvc_NetShareGetInfo(pipes_struct *p, struct srvsvc_NetShareGetInfo *r) +WERROR _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, SRV_R_NET_SHARE_GET_INFO *r_u) { - const struct share_params *params; + fstring share_name; - params = get_share_params(p->mem_ctx, r->in.share_name); + DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); - if (params != NULL) { - switch (r->in.level) { - case 0: - r->out.info->info0 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo0); - init_srv_share_info_0(p, r->out.info->info0, params); - break; - case 1: - r->out.info->info1 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1); - init_srv_share_info_1(p, r->out.info->info1, params); - break; - case 2: - r->out.info->info2 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo2); - init_srv_share_info_2(p, r->out.info->info2, params); - break; - case 501: - r->out.info->info501 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo501); - init_srv_share_info_501(p, r->out.info->info501, params); - break; - case 502: - r->out.info->info502 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo502); - init_srv_share_info_502(p, r->out.info->info502, params); - break; + /* 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, r_u, share_name, q_u->info_level); - /* here for completeness */ - case 1004: - r->out.info->info1004 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1004); - init_srv_share_info_1004(p, r->out.info->info1004, params); - break; - case 1005: - r->out.info->info1005 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1005); - init_srv_share_info_1005(p, r->out.info->info1005, params); - break; + DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); - /* here for completeness 1006 - 1501 */ - case 1006: - r->out.info->info1006 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1006); - init_srv_share_info_1006(p, r->out.info->info1006, - params); - break; - case 1007: - r->out.info->info1007 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo1007); - init_srv_share_info_1007(p, r->out.info->info1007, - params); - break; - case 1501: - r->out.info->info1501 = talloc(p->mem_ctx, struct sec_desc_buf); - init_srv_share_info_1501(p, r->out.info->info1501, - params); - break; - default: - DEBUG(5,("init_srv_net_share_get_info: unsupported " - "switch value %d\n", r->in.level)); - return WERR_UNKNOWN_LEVEL; - break; - } - } else { - return WERR_INVALID_NAME; - } - - return WERR_OK; + return r_u->status; } /******************************************************************* @@ -1378,314 +1464,59 @@ WERROR _srvsvc_NetShareGetInfo(pipes_struct *p, struct srvsvc_NetShareGetInfo *r ********************************************************************/ char *valid_share_pathname(char *dos_pathname) -{ - char *ptr; - - /* Convert any '\' paths to '/' */ - unix_format(dos_pathname); - unix_clean_name(dos_pathname); - - /* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */ - ptr = dos_pathname; - if (strlen(dos_pathname) > 2 && ptr[1] == ':' && ptr[0] != '/') - ptr += 2; - - /* Only absolute paths allowed. */ - if (*ptr != '/') - return NULL; - - return ptr; -} - -static void setval_helper(struct registry_key *key, const char *name, - const char *value, WERROR *err) -{ - struct registry_value val; - - if (!W_ERROR_IS_OK(*err)) { - return; - } - - ZERO_STRUCT(val); - val.type = REG_SZ; - val.v.sz.str = CONST_DISCARD(char *, value); - val.v.sz.len = strlen(value)+1; - - *err = reg_setvalue(key, name, &val); -} - -static WERROR add_share(const char *share_name, const char *path, - const char *comment, uint32 max_connections, - const struct nt_user_token *token, - BOOL is_disk_op) -{ - if (lp_add_share_cmd() && *lp_add_share_cmd()) { - char *command; - int ret; - - if (asprintf(&command, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", - lp_add_share_cmd(), dyn_CONFIGFILE, share_name, - path, comment, max_connections) == -1) { - return WERR_NOMEM; - } - - DEBUG(10,("add_share: Running [%s]\n", command )); - - /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ - - if ( is_disk_op ) - become_root(); - - if ( (ret = smbrun(command, NULL)) == 0 ) { - /* Tell everyone we updated smb.conf. */ - message_send_all(smbd_messaging_context(), - MSG_SMB_CONF_UPDATED, - NULL, 0, NULL); - } - - if ( is_disk_op ) - unbecome_root(); - - /********* END SeDiskOperatorPrivilege BLOCK *********/ - - DEBUG(3,("_srv_net_share_add: Running [%s] returned (%d)\n", - command, ret )); - - /* - * No fallback to registry shares, the user did define a add - * share command, so fail here. - */ - - SAFE_FREE(command); - return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; - } - - if (lp_registry_shares()) { - char *keyname; - struct registry_key *key; - enum winreg_CreateAction action; - WERROR err; - TALLOC_CTX *mem_ctx; - - if (!(keyname = talloc_asprintf(NULL, "%s\\%s", KEY_SMBCONF, - share_name))) { - return WERR_NOMEM; - } - - mem_ctx = (TALLOC_CTX *)keyname; - - err = reg_create_path(mem_ctx, keyname, REG_KEY_WRITE, - is_disk_op ? get_root_nt_token():token, - &action, &key); - - if (action != REG_CREATED_NEW_KEY) { - err = WERR_ALREADY_EXISTS; - } - - if (!W_ERROR_IS_OK(err)) { - TALLOC_FREE(mem_ctx); - return err; - } - - setval_helper(key, "path", path, &err); - if ((comment != NULL) && (comment[0] != '\0')) { - setval_helper(key, "comment", comment, &err); - } - if (max_connections != 0) { - char tmp[16]; - snprintf(tmp, sizeof(tmp), "%d", max_connections); - setval_helper(key, "max connections", tmp, &err); - } - - if (!W_ERROR_IS_OK(err)) { - /* - * Hmmmm. We'd need transactions on the registry to - * get this right.... - */ - reg_delete_path(is_disk_op ? get_root_nt_token():token, - keyname); - } - TALLOC_FREE(mem_ctx); - return err; - } - - return WERR_ACCESS_DENIED; -} - -static WERROR delete_share(const char *sharename, - const struct nt_user_token *token, - BOOL is_disk_op) -{ - if (lp_delete_share_cmd() && *lp_delete_share_cmd()) { - char *command; - int ret; - - if (asprintf(&command, "%s \"%s\" \"%s\"", - lp_delete_share_cmd(), dyn_CONFIGFILE, - sharename)) { - return WERR_NOMEM; - } - - DEBUG(10,("delete_share: Running [%s]\n", command )); - - /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ - - if ( is_disk_op ) - become_root(); - - if ( (ret = smbrun(command, NULL)) == 0 ) { - /* Tell everyone we updated smb.conf. */ - message_send_all(smbd_messaging_context(), - MSG_SMB_CONF_UPDATED, - NULL, 0, NULL); - } - - if ( is_disk_op ) - unbecome_root(); - - /********* END SeDiskOperatorPrivilege BLOCK *********/ - - SAFE_FREE(command); - - DEBUG(3,("_srv_net_share_del: Running [%s] returned (%d)\n", - command, ret )); - return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; - } - - if (lp_registry_shares()) { - char *keyname; - WERROR err; - - if (asprintf(&keyname, "%s\\%s", KEY_SMBCONF, - sharename) == -1) { - return WERR_NOMEM; - } - - err = reg_delete_path(is_disk_op ? get_root_nt_token():token, - keyname); - SAFE_FREE(keyname); - return err; - } - - return WERR_ACCESS_DENIED; -} - -static WERROR change_share(const char *share_name, const char *path, - const char *comment, uint32 max_connections, - const struct nt_user_token *token, - BOOL is_disk_op) -{ - if (lp_change_share_cmd() && *lp_change_share_cmd()) { - char *command; - int ret; - - if (asprintf(&command, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", - lp_change_share_cmd(), dyn_CONFIGFILE, share_name, - path, comment, max_connections) == -1) { - return WERR_NOMEM; - } - - DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command)); - - /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ - - if ( is_disk_op ) - become_root(); - - if ( (ret = smbrun(command, NULL)) == 0 ) { - /* Tell everyone we updated smb.conf. */ - message_send_all(smbd_messaging_context(), - MSG_SMB_CONF_UPDATED, - NULL, 0, NULL); - } - - if ( is_disk_op ) - unbecome_root(); - - /********* END SeDiskOperatorPrivilege BLOCK *********/ - - DEBUG(3,("_srv_net_share_set_info: Running [%s] returned " - "(%d)\n", command, ret )); - - SAFE_FREE(command); - - return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; - } - - if (lp_registry_shares()) { - char *keyname; - struct registry_key *key; - WERROR err; - TALLOC_CTX *mem_ctx; - - if (!(keyname = talloc_asprintf(NULL, "%s\\%s", KEY_SMBCONF, - share_name))) { - return WERR_NOMEM; - } - - mem_ctx = (TALLOC_CTX *)keyname; - - err = reg_open_path(mem_ctx, keyname, REG_KEY_WRITE, - is_disk_op ? get_root_nt_token():token, - &key); - if (!W_ERROR_IS_OK(err)) { - TALLOC_FREE(mem_ctx); - return err; - } - - setval_helper(key, "path", path, &err); +{ + char *ptr; - reg_deletevalue(key, "comment"); - if ((comment != NULL) && (comment[0] != '\0')) { - setval_helper(key, "comment", comment, &err); - } + /* Convert any '\' paths to '/' */ + unix_format(dos_pathname); + unix_clean_name(dos_pathname); - reg_deletevalue(key, "max connections"); - if (max_connections != 0) { - char tmp[16]; - snprintf(tmp, sizeof(tmp), "%d", max_connections); - setval_helper(key, "max connections", tmp, &err); - } + /* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */ + ptr = dos_pathname; + if (strlen(dos_pathname) > 2 && ptr[1] == ':' && ptr[0] != '/') + ptr += 2; - TALLOC_FREE(mem_ctx); - return err; - } + /* Only absolute paths allowed. */ + if (*ptr != '/') + return NULL; - return WERR_ACCESS_DENIED; + return ptr; } /******************************************************************* Net share set info. Modify share details. ********************************************************************/ -WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r) +WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) { - pstring comment; + struct current_user user; + pstring command; + fstring share_name; + fstring comment; pstring pathname; int type; int snum; + int ret; char *path; SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op = False; int max_connections = 0; - fstring tmp_share_name; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); - if (r->out.parm_error) { - *r->out.parm_error = 0; - } + unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); - if ( strequal(r->in.share_name,"IPC$") - || ( lp_enable_asu_support() && strequal(r->in.share_name,"ADMIN$") ) - || strequal(r->in.share_name,"global") ) + r_u->parm_error = 0; + + if ( strequal(share_name,"IPC$") + || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) + || strequal(share_name,"global") ) { return WERR_ACCESS_DENIED; } - fstrcpy(tmp_share_name, r->in.share_name); - snum = find_service(tmp_share_name); + snum = find_service(share_name); /* Does this share exist ? */ if (snum < 0) @@ -1695,39 +1526,47 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r if (lp_print_ok(snum)) return WERR_ACCESS_DENIED; - is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, - &se_diskop ); + get_current_user(&user,p); + + is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); /* fail out now if you are not root and not a disk op */ - if ( p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op ) + if ( user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; - switch (r->in.level) { + switch (q_u->info_level) { case 1: pstrcpy(pathname, lp_pathname(snum)); - pstrcpy(comment, r->in.info.info1->comment); - type = r->in.info.info1->type; + unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); + type = q_u->info.share.info2.info_2.type; psd = NULL; break; case 2: - pstrcpy(comment, r->in.info.info2->comment); - pstrcpy(pathname, r->in.info.info2->path); - type = r->in.info.info2->type; - max_connections = (r->in.info.info2->max_users == 0xffffffff) ? - 0 : r->in.info.info2->max_users; + unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); + unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(pathname)); + type = q_u->info.share.info2.info_2.type; + max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; psd = NULL; break; +#if 0 + /* not supported on set but here for completeness */ + case 501: + unistr2_to_ascii(comment, &q_u->info.share.info501.info_501_str.uni_remark, sizeof(comment)); + type = q_u->info.share.info501.info_501.type; + psd = NULL; + break; +#endif case 502: - pstrcpy(comment, r->in.info.info502->comment); - pstrcpy(pathname, r->in.info.info502->path); - type = r->in.info.info502->type; - psd = r->in.info.info502->sd; + unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(comment)); + unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(pathname)); + type = q_u->info.share.info502.info_502.type; + psd = q_u->info.share.info502.info_502_str.sd; map_generic_share_sd_bits(psd); break; case 1004: pstrcpy(pathname, lp_pathname(snum)); - pstrcpy(comment, r->in.info.info1004->comment); + unistr2_to_ascii(comment, &q_u->info.share.info1004.info_1004_str.uni_remark, sizeof(comment)); type = STYPE_DISKTREE; break; case 1005: @@ -1735,14 +1574,12 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r user, so we must compare it to see if it's what is set in smb.conf, so that we can contine other ops like setting ACLs on a share */ - if (((r->in.info.info1005->dfs_flags & + if (((q_u->info.share.info1005.share_info_flags & SHARE_1005_CSC_POLICY_MASK) >> SHARE_1005_CSC_POLICY_SHIFT) == lp_csc_policy(snum)) return WERR_OK; else { - DEBUG(3, ("_srv_net_share_set_info: client is trying " - "to change csc policy from the network; " - "must be done with smb.conf\n")); + DEBUG(3, ("_srv_net_share_set_info: client is trying to change csc policy from the network; must be done with smb.conf\n")); return WERR_ACCESS_DENIED; } case 1006: @@ -1750,14 +1587,13 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r return WERR_ACCESS_DENIED; case 1501: pstrcpy(pathname, lp_pathname(snum)); - pstrcpy(comment, lp_comment(snum)); - psd = r->in.info.info1501->sd; + fstrcpy(comment, lp_comment(snum)); + psd = q_u->info.share.info1501.sdb->sd; map_generic_share_sd_bits(psd); type = STYPE_DISKTREE; break; default: - DEBUG(5,("_srv_net_share_set_info: unsupported switch value " - "%d\n", r->in.level)); + DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", q_u->info_level)); return WERR_UNKNOWN_LEVEL; } @@ -1769,29 +1605,52 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r if (!(path = valid_share_pathname( pathname ))) return WERR_OBJECT_PATH_INVALID; - /* Ensure share name, pathname and comment don't contain '"' - * characters. */ - string_replace(tmp_share_name, '"', ' '); + /* Ensure share name, pathname and comment don't contain '"' characters. */ + string_replace(share_name, '"', ' '); string_replace(path, '"', ' '); string_replace(comment, '"', ' '); DEBUG(10,("_srv_net_share_set_info: change share command = %s\n", - lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" )); + lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" )); /* Only call modify function if something changed. */ - if (strcmp(path, lp_pathname(snum)) - || strcmp(comment, lp_comment(snum)) - || (lp_max_connections(snum) != max_connections) ) { - WERROR err; + if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) + || (lp_max_connections(snum) != max_connections) ) + { + if (!lp_change_share_cmd() || !*lp_change_share_cmd()) { + DEBUG(10,("_srv_net_share_set_info: No change share command\n")); + return WERR_ACCESS_DENIED; + } - err = change_share(tmp_share_name, path, comment, - max_connections, p->pipe_user.nt_user_token, - is_disk_op); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", + lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment, max_connections ); - if (!W_ERROR_IS_OK(err)) { - return err; + DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command )); + + /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ + + if ( is_disk_op ) + become_root(); + + if ( (ret = smbrun(command, NULL)) == 0 ) { + /* Tell everyone we updated smb.conf. */ + message_send_all(smbd_messaging_context(), + MSG_SMB_CONF_UPDATED, NULL, 0, + NULL); } + + if ( is_disk_op ) + unbecome_root(); + + /********* END SeDiskOperatorPrivilege BLOCK *********/ + + DEBUG(3,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret )); + + if ( ret != 0 ) + return WERR_ACCESS_DENIED; + } else { + DEBUG(10,("_srv_net_share_set_info: No change to share name (%s)\n", share_name )); } /* Replace SD if changed. */ @@ -1799,15 +1658,12 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r SEC_DESC *old_sd; size_t sd_size; - old_sd = get_share_security(p->mem_ctx, lp_servicename(snum), - &sd_size); + old_sd = get_share_security(p->mem_ctx, lp_servicename(snum), &sd_size); if (old_sd && !sec_desc_equal(old_sd, psd)) { - if (!set_share_security(r->in.share_name, psd)) { - DEBUG(0,("_srv_net_share_set_info: Failed to " - "change security info in share %s.\n", - r->in.share_name )); - } + if (!set_share_security(share_name, psd)) + DEBUG(0,("_srv_net_share_set_info: Failed to change security info in share %s.\n", + share_name )); } } @@ -1816,38 +1672,44 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r return WERR_OK; } - /******************************************************************* Net share add. Call 'add_share_command "sharename" "pathname" "comment" "max connections = " ********************************************************************/ -WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r) +WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) { - pstring share_name; - pstring comment; + struct current_user user; + pstring command; + fstring share_name; + fstring comment; pstring pathname; - char *path; int type; + int snum; + int ret; + char *path; SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op; - uint32 max_connections = 0; - WERROR err; + int max_connections = 0; DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); - if (r->out.parm_error) { - *r->out.parm_error = 0; - } + r_u->parm_error = 0; + + get_current_user(&user,p); - is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, - &se_diskop ); + is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); - if (p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op ) + if (user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; - switch (r->in.level) { + if (!lp_add_share_cmd() || !*lp_add_share_cmd()) { + DEBUG(10,("_srv_net_share_add: No add share command\n")); + return WERR_ACCESS_DENIED; + } + + switch (q_u->info_level) { case 0: /* No path. Not enough info in a level 0 to do anything. */ return WERR_ACCESS_DENIED; @@ -1855,27 +1717,25 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r) /* Not enough info in a level 1 to do anything. */ return WERR_ACCESS_DENIED; case 2: - pstrcpy(share_name, r->in.info.info2->name); - pstrcpy(comment, r->in.info.info2->comment); - pstrcpy(pathname, r->in.info.info2->path); - max_connections = (r->in.info.info2->max_users == 0xffffffff) ? - 0 : r->in.info.info2->max_users; - type = r->in.info.info2->type; + 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)); + unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name)); + max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; + type = q_u->info.share.info2.info_2.type; break; case 501: /* No path. Not enough info in a level 501 to do anything. */ return WERR_ACCESS_DENIED; case 502: - pstrcpy(share_name, r->in.info.info502->name); - pstrcpy(comment, r->in.info.info502->comment); - pstrcpy(pathname, r->in.info.info502->path); - type = r->in.info.info502->type; - psd = r->in.info.info502->sd; + unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name)); + unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name)); + unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name)); + type = q_u->info.share.info502.info_502.type; + psd = q_u->info.share.info502.info_502_str.sd; map_generic_share_sd_bits(psd); break; - /* none of the following contain share names. NetShareAdd - * does not have a separate parameter for the share name */ + /* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */ case 1004: case 1005: @@ -1886,30 +1746,28 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r) /* DFS only level. */ return WERR_ACCESS_DENIED; default: - DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", - r->in.level)); + DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", q_u->info_level)); return WERR_UNKNOWN_LEVEL; } /* check for invalid share names */ - if ( !validate_net_name( share_name, INVALID_SHARENAME_CHARS, - sizeof(share_name) ) ) { - DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", - share_name)); + if ( !validate_net_name( share_name, INVALID_SHARENAME_CHARS, sizeof(share_name) ) ) { + DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", share_name)); return WERR_INVALID_NAME; } if ( strequal(share_name,"IPC$") || strequal(share_name,"global") - || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) ) + || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) ) { return WERR_ACCESS_DENIED; } - if (get_share_params(p->mem_ctx, share_name) != NULL) { - /* Share already exists. */ + snum = find_service(share_name); + + /* Share already exists. */ + if (snum >= 0) return WERR_ALREADY_EXISTS; - } /* We can only add disk shares. */ if (type != STYPE_DISKTREE) @@ -1919,24 +1777,45 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r) if (!(path = valid_share_pathname( pathname ))) return WERR_OBJECT_PATH_INVALID; - /* Ensure share name, pathname and comment don't contain '"' - * characters. */ - + /* Ensure share name, pathname and comment don't contain '"' characters. */ string_replace(share_name, '"', ' '); string_replace(path, '"', ' '); string_replace(comment, '"', ' '); - err = add_share(share_name, path, comment, max_connections, - p->pipe_user.nt_user_token, is_disk_op); + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", + lp_add_share_cmd(), + dyn_CONFIGFILE, + share_name, + path, + comment, + max_connections); + + DEBUG(10,("_srv_net_share_add: Running [%s]\n", command )); + + /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ + + if ( is_disk_op ) + become_root(); - if (!W_ERROR_IS_OK(err)) { - return err; + if ( (ret = smbrun(command, NULL)) == 0 ) { + /* Tell everyone we updated smb.conf. */ + message_send_all(smbd_messaging_context(), + MSG_SMB_CONF_UPDATED, NULL, 0, NULL); } + if ( is_disk_op ) + unbecome_root(); + + /********* END SeDiskOperatorPrivilege BLOCK *********/ + + DEBUG(3,("_srv_net_share_add: Running [%s] returned (%d)\n", command, ret )); + + if ( ret != 0 ) + return WERR_ACCESS_DENIED; + if (psd) { if (!set_share_security(share_name, psd)) { - DEBUG(0,("_srv_net_share_add: Failed to add security " - "info to share %s.\n", share_name )); + DEBUG(0,("_srv_net_share_add: Failed to add security info to share %s.\n", share_name )); } } @@ -1956,43 +1835,76 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r) a parameter. ********************************************************************/ -WERROR _srvsvc_NetShareDel(pipes_struct *p, struct srvsvc_NetShareDel *r) +WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) { - struct share_params *params; + struct current_user user; + pstring command; + fstring share_name; + int ret; + int snum; SE_PRIV se_diskop = SE_DISK_OPERATOR; BOOL is_disk_op; - WERROR err; + struct share_params *params; DEBUG(5,("_srv_net_share_del: %d\n", __LINE__)); - if ( strequal(r->in.share_name, "IPC$") - || ( lp_enable_asu_support() && strequal(r->in.share_name,"ADMIN$") ) - || strequal(r->in.share_name, "global") ) + unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); + + if ( strequal(share_name,"IPC$") + || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) + || strequal(share_name,"global") ) { return WERR_ACCESS_DENIED; } - if (!(params = get_share_params(p->mem_ctx, r->in.share_name))) { - return WERR_NO_SUCH_SHARE; - } + if (!(params = get_share_params(p->mem_ctx, share_name))) { + return WERR_NO_SUCH_SHARE; + } + + snum = find_service(share_name); /* No change to printer shares. */ - if (lp_print_ok(params->service)) + if (lp_print_ok(snum)) return WERR_ACCESS_DENIED; - is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, - &se_diskop ); + get_current_user(&user,p); + + is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); + + if (user.ut.uid != sec_initial_uid() && !is_disk_op ) + return WERR_ACCESS_DENIED; - if (p->pipe_user.ut.uid != sec_initial_uid() && !is_disk_op ) + if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) { + DEBUG(10,("_srv_net_share_del: No delete share command\n")); return WERR_ACCESS_DENIED; + } + + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", + lp_delete_share_cmd(), dyn_CONFIGFILE, lp_servicename(snum)); + + DEBUG(10,("_srv_net_share_del: Running [%s]\n", command )); - err = delete_share(lp_servicename(params->service), - p->pipe_user.nt_user_token, is_disk_op); + /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ + + if ( is_disk_op ) + become_root(); - if (!W_ERROR_IS_OK(err)) { - return err; + if ( (ret = smbrun(command, NULL)) == 0 ) { + /* Tell everyone we updated smb.conf. */ + message_send_all(smbd_messaging_context(), + MSG_SMB_CONF_UPDATED, NULL, 0, NULL); } + if ( is_disk_op ) + unbecome_root(); + + /********* END SeDiskOperatorPrivilege BLOCK *********/ + + DEBUG(3,("_srv_net_share_del: Running [%s] returned (%d)\n", command, ret )); + + if ( ret != 0 ) + return WERR_ACCESS_DENIED; + /* Delete the SD in the database. */ delete_share_security(lp_servicename(params->service)); @@ -2001,28 +1913,22 @@ WERROR _srvsvc_NetShareDel(pipes_struct *p, struct srvsvc_NetShareDel *r) return WERR_OK; } -WERROR _srvsvc_NetShareDelSticky(pipes_struct *p, struct srvsvc_NetShareDelSticky *r) +WERROR _srv_net_share_del_sticky(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) { - struct srvsvc_NetShareDel s; - DEBUG(5,("_srv_net_share_del_stick: %d\n", __LINE__)); - s.in.server_unc = r->in.server_unc; - s.in.share_name = r->in.share_name; - s.in.reserved = r->in.reserved; - - return _srvsvc_NetShareDel(p, &s); + return _srv_net_share_del(p, q_u, r_u); } /******************************************************************* time of day ********************************************************************/ -WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, struct srvsvc_NetRemoteTOD *r) +WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET_REMOTE_TOD *r_u) { + TIME_OF_DAY_INFO *tod; struct tm *t; time_t unixdate = time(NULL); - WERROR status = WERR_OK; /* We do this call first as if we do it *after* the gmtime call it overwrites the pointed-to values. JRA */ @@ -2031,91 +1937,106 @@ WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, struct srvsvc_NetRemoteTOD *r) DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); + if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, TIME_OF_DAY_INFO)) ) + return WERR_NOMEM; + + r_u->tod = tod; + r_u->ptr_srv_tod = 0x1; + r_u->status = WERR_OK; + + DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); + t = gmtime(&unixdate); /* set up the */ - r->out.info->elapsed = unixdate; - r->out.info->msecs = 0; - r->out.info->hours = t->tm_hour; - r->out.info->mins = t->tm_min; - r->out.info->secs = t->tm_sec; - r->out.info->hunds = 0; - r->out.info->timezone = zone; - r->out.info->tinterval = 10000; - r->out.info->day = t->tm_mday; - r->out.info->month = t->tm_mon + 1; - r->out.info->year = 1900+t->tm_year; - r->out.info->weekday = t->tm_wday; + init_time_of_day_info(tod, + unixdate, + 0, + t->tm_hour, + t->tm_min, + t->tm_sec, + 0, + zone, + 10000, + t->tm_mday, + t->tm_mon + 1, + 1900+t->tm_year, + t->tm_wday); DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); - return status; + return r_u->status; } /*********************************************************************************** Win9x NT tools get security descriptor. ***********************************************************************************/ -WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecurity *r) +WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC *q_u, + SRV_R_NET_FILE_QUERY_SECDESC *r_u) { SEC_DESC *psd = NULL; size_t sd_size; DATA_BLOB null_pw; + pstring filename_in; + char *filename = NULL; + pstring qualname; files_struct *fsp = NULL; SMB_STRUCT_STAT st; NTSTATUS nt_status; + struct current_user user; connection_struct *conn = NULL; - BOOL became_user = False; - WERROR status = WERR_OK; - char *tmp_file = NULL; + BOOL became_user = False; TALLOC_CTX *ctx = talloc_tos(); ZERO_STRUCT(st); + r_u->status = WERR_OK; + + unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); /* Null password is ok - we are already an authenticated user... */ null_pw = data_blob_null; + get_current_user(&user, p); + become_root(); - conn = make_connection(r->in.share, null_pw, "A:", p->pipe_user.vuid, &nt_status); + conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", r->in.share)); - status = ntstatus_to_werror(nt_status); + DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", qualname)); + r_u->status = ntstatus_to_werror(nt_status); goto error_exit; } if (!become_user(conn, conn->vuid)) { DEBUG(0,("_srv_net_file_query_secdesc: Can't become connected user!\n")); - status = WERR_ACCESS_DENIED; + r_u->status = WERR_ACCESS_DENIED; goto error_exit; } became_user = True; - if (!r->in.file) { - status = WERR_INVALID_PARAM; - goto error_exit; - } - nt_status = unix_convert(ctx, conn, r->in.file, False, &tmp_file, NULL, &st); + unistr2_to_ascii(filename_in, &q_u->uni_file_name, sizeof(filename_in)); + nt_status = unix_convert(ctx, conn, filename_in, False, &filename, NULL, &st); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", r->in.file)); - status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", filename)); + r_u->status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = check_name(conn, tmp_file); + nt_status = check_name(conn, filename); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", tmp_file)); - status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", filename)); + r_u->status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = open_file_stat(conn, NULL, tmp_file, &st, &fsp); - if (!NT_STATUS_IS_OK(nt_status)) { + nt_status = open_file_stat(conn, NULL, filename, &st, &fsp); + if ( !NT_STATUS_IS_OK(nt_status)) { /* Perhaps it is a directory */ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) - nt_status = open_directory(conn, NULL, tmp_file, &st, + nt_status = open_directory(conn, NULL, filename, &st, READ_CONTROL_ACCESS, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, @@ -2124,8 +2045,8 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecur NULL, &fsp); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", tmp_file)); - status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); + r_u->status = ntstatus_to_werror(nt_status); goto error_exit; } } @@ -2133,20 +2054,23 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecur sd_size = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION), &psd); if (sd_size == 0) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", tmp_file)); - status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", filename)); + r_u->status = WERR_ACCESS_DENIED; goto error_exit; } - r->out.sd_buf->sd_size= sd_size; - r->out.sd_buf->sd = psd; + r_u->ptr_response = 1; + r_u->size_response = sd_size; + r_u->ptr_secdesc = 1; + r_u->size_secdesc = sd_size; + r_u->sec_desc = psd; psd->dacl->revision = (uint16) NT4_ACL_REVISION; close_file(fsp, NORMAL_CLOSE); unbecome_user(); - close_cnum(conn, p->pipe_user.vuid); - return status; + close_cnum(conn, user.vuid); + return r_u->status; error_exit: @@ -2158,74 +2082,80 @@ error_exit: unbecome_user(); if (conn) - close_cnum(conn, p->pipe_user.vuid); + close_cnum(conn, user.vuid); - return status; + return r_u->status; } /*********************************************************************************** Win9x NT tools set security descriptor. ***********************************************************************************/ -WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecurity *r) +WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_u, + SRV_R_NET_FILE_SET_SECDESC *r_u) { + pstring filename_in; + char *filename = NULL; + pstring qualname; DATA_BLOB null_pw; files_struct *fsp = NULL; SMB_STRUCT_STAT st; NTSTATUS nt_status; + struct current_user user; connection_struct *conn = NULL; BOOL became_user = False; - WERROR status = WERR_OK; - char *tmp_file = NULL; TALLOC_CTX *ctx = talloc_tos(); ZERO_STRUCT(st); + r_u->status = WERR_OK; + + unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); + /* Null password is ok - we are already an authenticated user... */ null_pw = data_blob_null; + get_current_user(&user, p); + become_root(); - conn = make_connection(r->in.share, null_pw, "A:", p->pipe_user.vuid, &nt_status); + conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status); unbecome_root(); if (conn == NULL) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", r->in.share)); - status = ntstatus_to_werror(nt_status); + DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", qualname)); + r_u->status = ntstatus_to_werror(nt_status); goto error_exit; } if (!become_user(conn, conn->vuid)) { DEBUG(0,("_srv_net_file_set_secdesc: Can't become connected user!\n")); - status = WERR_ACCESS_DENIED; + r_u->status = WERR_ACCESS_DENIED; goto error_exit; } became_user = True; - if (!r->in.file) { - status = WERR_INVALID_PARAM; - goto error_exit; - } - nt_status = unix_convert(ctx, conn, r->in.file, False, &tmp_file, NULL, &st); + unistr2_to_ascii(filename_in, &q_u->uni_file_name, sizeof(filename_in)); + nt_status = unix_convert(ctx, conn, filename, False, &filename, NULL, &st); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", r->in.file)); - status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", filename)); + r_u->status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = check_name(conn, tmp_file); + nt_status = check_name(conn, filename); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", tmp_file)); - status = WERR_ACCESS_DENIED; + DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", filename)); + r_u->status = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = open_file_stat(conn, NULL, tmp_file, &st, &fsp); + nt_status = open_file_stat(conn, NULL, filename, &st, &fsp); - if (!NT_STATUS_IS_OK(nt_status)) { + if ( !NT_STATUS_IS_OK(nt_status) ) { /* Perhaps it is a directory */ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) - nt_status = open_directory(conn, NULL, tmp_file, &st, + nt_status = open_directory(conn, NULL, filename, &st, FILE_READ_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, @@ -2233,25 +2163,25 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecur FILE_ATTRIBUTE_DIRECTORY, NULL, &fsp); - if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", tmp_file)); - status = WERR_ACCESS_DENIED; + if ( !NT_STATUS_IS_OK(nt_status) ) { + DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename)); + r_u->status = ntstatus_to_werror(nt_status); goto error_exit; } } - nt_status = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, r->in.securityinformation, r->in.sd_buf.sd); + nt_status = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, q_u->sec_info, q_u->sec_desc); - if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", tmp_file)); - status = WERR_ACCESS_DENIED; + if (!NT_STATUS_IS_OK(nt_status) ) { + DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", filename)); + r_u->status = WERR_ACCESS_DENIED; goto error_exit; } close_file(fsp, NORMAL_CLOSE); unbecome_user(); - close_cnum(conn, p->pipe_user.vuid); - return status; + close_cnum(conn, user.vuid); + return r_u->status; error_exit: @@ -2264,10 +2194,10 @@ error_exit: } if (conn) { - close_cnum(conn, p->pipe_user.vuid); + close_cnum(conn, user.vuid); } - return status; + return r_u->status; } /*********************************************************************************** @@ -2316,68 +2246,59 @@ static const char *next_server_disk_enum(uint32 *resume) return disk; } -WERROR _srvsvc_NetDiskEnum(pipes_struct *p, struct srvsvc_NetDiskEnum *r) +WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_DISK_ENUM *r_u) { uint32 i; const char *disk_name; + TALLOC_CTX *ctx = p->mem_ctx; + uint32 resume=get_enum_hnd(&q_u->enum_hnd); - WERROR status = WERR_OK; + r_u->status=WERR_OK; - *r->out.totalentries = init_server_disk_enum(r->in.resume_handle); - r->out.info->count = 0; + r_u->total_entries = init_server_disk_enum(&resume); - if(!(r->out.info->disks = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetDiskInfo0, MAX_SERVER_DISK_ENTRIES))) { + r_u->disk_enum_ctr.unknown = 0; + + if(!(r_u->disk_enum_ctr.disk_info = TALLOC_ARRAY(ctx, DISK_INFO, MAX_SERVER_DISK_ENTRIES))) { return WERR_NOMEM; } - /*allow one struct srvsvc_NetDiskInfo0 for null terminator*/ + r_u->disk_enum_ctr.disk_info_ptr = r_u->disk_enum_ctr.disk_info ? 1 : 0; + + /*allow one DISK_INFO for null terminator*/ - for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(r->in.resume_handle)); i++) { + for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(&resume)); i++) { - r->out.info->count++; - (*r->out.totalentries)++; + r_u->disk_enum_ctr.entries_read++; /*copy disk name into a unicode string*/ - r->out.info->disks[i].disk = disk_name; + init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name); } /* add a terminating null string. Is this there if there is more data to come? */ - r->out.info->count++; - (*r->out.totalentries)++; + r_u->disk_enum_ctr.entries_read++; - r->out.info->disks[i].disk = ""; + init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, ""); - return status; + init_enum_hnd(&r_u->enum_hnd, resume); + + return r_u->status; } /******************************************************************** ********************************************************************/ -WERROR _srvsvc_NetNameValidate(pipes_struct *p, struct srvsvc_NetNameValidate *r) +WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV_R_NET_NAME_VALIDATE *r_u) { - int len; - - if ((r->in.flags != 0x0) && (r->in.flags != 0x80000000)) { - return WERR_INVALID_PARAM; - } + fstring sharename; - switch ( r->in.name_type ) { + switch ( q_u->type ) { case 0x9: - len = strlen_m(r->in.name); - - if ((r->in.flags == 0x0) && (len > 81)) { - DEBUG(5,("_srv_net_name_validate: share name too long (%s > 81 chars)\n", r->in.name)); - return WERR_INVALID_NAME; - } - if ((r->in.flags == 0x80000000) && (len > 13)) { - DEBUG(5,("_srv_net_name_validate: share name too long (%s > 13 chars)\n", r->in.name)); - return WERR_INVALID_NAME; - } - - if ( ! validate_net_name( r->in.name, INVALID_SHARENAME_CHARS, sizeof(r->in.name) ) ) { - DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", r->in.name)); + rpcstr_pull(sharename, q_u->sharename.buffer, sizeof(sharename), q_u->sharename.uni_str_len*2, 0); + if ( !validate_net_name( sharename, INVALID_SHARENAME_CHARS, sizeof(sharename) ) ) { + DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", sharename)); return WERR_INVALID_NAME; } break; @@ -2398,6 +2319,10 @@ WERROR _srvsvc_NetFileClose(pipes_struct *p, struct srvsvc_NetFileClose *r) return WERR_ACCESS_DENIED; } + +/******************************************************************** +********************************************************************/ + WERROR _srvsvc_NetCharDevEnum(pipes_struct *p, struct srvsvc_NetCharDevEnum *r) { p->rng_fault_state = True; @@ -2446,18 +2371,96 @@ WERROR _srvsvc_NetCharDevQPurgeSelf(pipes_struct *p, struct srvsvc_NetCharDevQPu return WERR_NOT_SUPPORTED; } +WERROR _srvsvc_NetConnEnum(pipes_struct *p, struct srvsvc_NetConnEnum *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetFileEnum(pipes_struct *p, struct srvsvc_NetFileEnum *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + WERROR _srvsvc_NetFileGetInfo(pipes_struct *p, struct srvsvc_NetFileGetInfo *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } +WERROR _srvsvc_NetSessEnum(pipes_struct *p, struct srvsvc_NetSessEnum *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetShareEnumAll(pipes_struct *p, struct srvsvc_NetShareEnumAll *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetShareGetInfo(pipes_struct *p, struct srvsvc_NetShareGetInfo *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetShareDel(pipes_struct *p, struct srvsvc_NetShareDel *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetShareDelSticky(pipes_struct *p, struct srvsvc_NetShareDelSticky *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + WERROR _srvsvc_NetShareCheck(pipes_struct *p, struct srvsvc_NetShareCheck *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } +WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, struct srvsvc_NetSrvGetInfo *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, struct srvsvc_NetSrvSetInfo *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetDiskEnum(pipes_struct *p, struct srvsvc_NetDiskEnum *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + WERROR _srvsvc_NetServerStatisticsGet(pipes_struct *p, struct srvsvc_NetServerStatisticsGet *r) { p->rng_fault_state = True; @@ -2482,6 +2485,12 @@ WERROR _srvsvc_NetTransportDel(pipes_struct *p, struct srvsvc_NetTransportDel *r return WERR_NOT_SUPPORTED; } +WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, struct srvsvc_NetRemoteTOD *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + WERROR _srvsvc_NetSetServiceBits(pipes_struct *p, struct srvsvc_NetSetServiceBits *r) { p->rng_fault_state = True; @@ -2506,6 +2515,12 @@ WERROR _srvsvc_NetPathCompare(pipes_struct *p, struct srvsvc_NetPathCompare *r) return WERR_NOT_SUPPORTED; } +WERROR _srvsvc_NetNameValidate(pipes_struct *p, struct srvsvc_NetNameValidate *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + WERROR _srvsvc_NETRPRNAMECANONICALIZE(pipes_struct *p, struct srvsvc_NETRPRNAMECANONICALIZE *r) { p->rng_fault_state = True; @@ -2518,6 +2533,12 @@ WERROR _srvsvc_NetPRNameCompare(pipes_struct *p, struct srvsvc_NetPRNameCompare return WERR_NOT_SUPPORTED; } +WERROR _srvsvc_NetShareEnum(pipes_struct *p, struct srvsvc_NetShareEnum *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + WERROR _srvsvc_NetShareDelStart(pipes_struct *p, struct srvsvc_NetShareDelStart *r) { p->rng_fault_state = True; @@ -2530,6 +2551,18 @@ WERROR _srvsvc_NetShareDelCommit(pipes_struct *p, struct srvsvc_NetShareDelCommi return WERR_NOT_SUPPORTED; } +WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecurity *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + +WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecurity *r) +{ + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; +} + WERROR _srvsvc_NetServerTransportAddEx(pipes_struct *p, struct srvsvc_NetServerTransportAddEx *r) { p->rng_fault_state = True; @@ -2560,7 +2593,7 @@ WERROR _srvsvc_NETRDFSDELETELOCALPARTITION(pipes_struct *p, struct srvsvc_NETRDF return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRDFSSETLOCALVOLUMESTATE(pipes_struct *p, struct srvsvc_NETRDFSSETLOCALVOLUMESTATE *R) +WERROR _srvsvc_NETRDFSSETLOCALVOLUMESTATE(pipes_struct *p, struct srvsvc_NETRDFSSETLOCALVOLUMESTATE *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; @@ -2584,26 +2617,27 @@ WERROR _srvsvc_NETRDFSDELETEEXITPOINT(pipes_struct *p, struct srvsvc_NETRDFSDELE return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRSERVERTRANSPORTDELEX(pipes_struct *p, struct srvsvc_NETRSERVERTRANSPORTDELEX *r) +WERROR _srvsvc_NETRDFSMODIFYPREFIX(pipes_struct *p, struct srvsvc_NETRDFSMODIFYPREFIX *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRDFSMANAGERREPORTSITEINFO(pipes_struct *p, struct srvsvc_NETRDFSMANAGERREPORTSITEINFO *r) +WERROR _srvsvc_NETRDFSFIXLOCALVOLUME(pipes_struct *p, struct srvsvc_NETRDFSFIXLOCALVOLUME *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRDFSMODIFYPREFIX(pipes_struct *p, struct srvsvc_NETRDFSMODIFYPREFIX *r) +WERROR _srvsvc_NETRDFSMANAGERREPORTSITEINFO(pipes_struct *p, struct srvsvc_NETRDFSMANAGERREPORTSITEINFO *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NETRDFSFIXLOCALVOLUME(pipes_struct *p, struct srvsvc_NETRDFSFIXLOCALVOLUME *r) +WERROR _srvsvc_NETRSERVERTRANSPORTDELEX(pipes_struct *p, struct srvsvc_NETRSERVERTRANSPORTDELEX *r) { p->rng_fault_state = True; return WERR_NOT_SUPPORTED; } + diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index dba209eb07..c868f94f76 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -626,7 +626,7 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG the client from showing the "Start" button (if of course the services are not running */ - if ( strequal( name, "NETLOGON" ) && ( !share_defined(name) ) ) + if ( strequal( name, "NETLOGON" ) && ( lp_servicenumber(name) == -1 ) ) config->start_type = SVCCTL_DISABLED; else if ( strequal( name, "WINS" ) && ( !lp_wins_support() )) config->start_type = SVCCTL_DISABLED; diff --git a/source3/rpc_server/srv_unixinfo_nt.c b/source3/rpc_server/srv_unixinfo_nt.c deleted file mode 100644 index e9680247ae..0000000000 --- a/source3/rpc_server/srv_unixinfo_nt.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines for unixinfo-pipe - * Copyright (C) Volker Lendecke 2005 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ - -/* This is the interface to the rpcunixinfo pipe. */ - -#include "includes.h" -#include "nterr.h" - - - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -/* Map a sid to a uid */ - -NTSTATUS _unixinfo_SidToUid(pipes_struct *p, struct unixinfo_SidToUid *r) -{ - uid_t real_uid; - NTSTATUS status; - *r->out.uid = 0; - - status = sid_to_uid(&r->in.sid, &real_uid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; - if (NT_STATUS_IS_OK(status)) - *r->out.uid = real_uid; - - return status; -} - -/* Map a uid to a sid */ - -NTSTATUS _unixinfo_UidToSid(pipes_struct *p, struct unixinfo_UidToSid *r) -{ - NTSTATUS status = NT_STATUS_NO_SUCH_USER; - - uid_to_sid(r->out.sid, (uid_t)r->in.uid); - status = NT_STATUS_OK; - - return status; -} - -/* Map a sid to a gid */ - -NTSTATUS _unixinfo_SidToGid(pipes_struct *p, struct unixinfo_SidToGid *r) -{ - gid_t real_gid; - NTSTATUS status; - - *r->out.gid = 0; - - status = sid_to_gid(&r->in.sid, &real_gid) ? NT_STATUS_OK : NT_STATUS_NONE_MAPPED; - if (NT_STATUS_IS_OK(status)) - *r->out.gid = real_gid; - - return status; -} - -/* Map a gid to a sid */ - -NTSTATUS _unixinfo_GidToSid(pipes_struct *p, struct unixinfo_GidToSid *r) -{ - NTSTATUS status = NT_STATUS_NO_SUCH_GROUP; - - gid_to_sid(r->out.sid, (gid_t)r->in.gid); - status = NT_STATUS_OK; - - return status; -} - -/* Get unix struct passwd information */ - -NTSTATUS _unixinfo_GetPWUid(pipes_struct *p, struct unixinfo_GetPWUid *r) -{ - int i; - NTSTATUS status; - - if (*r->in.count > 1023) - return NT_STATUS_INVALID_PARAMETER; - - status = NT_STATUS_OK; - - for (i=0; i<*r->in.count; i++) { - struct passwd *pw; - char *homedir, *shell; - ssize_t len1, len2; - - r->out.infos[i].status = NT_STATUS_NO_SUCH_USER; - r->out.infos[i].homedir = ""; - r->out.infos[i].shell = ""; - - pw = getpwuid(r->in.uids[i]); - - if (pw == NULL) { - DEBUG(10, ("Did not find uid %lld\n", - (long long int)r->in.uids[i])); - continue; - } - - len1 = push_utf8_talloc(p->mem_ctx, &homedir, pw->pw_dir); - len2 = push_utf8_talloc(p->mem_ctx, &shell, pw->pw_shell); - - if ((len1 < 0) || (len2 < 0) || (homedir == NULL) || - (shell == NULL)) { - DEBUG(3, ("push_utf8_talloc failed\n")); - r->out.infos[i].status = NT_STATUS_NO_MEMORY; - continue; - } - - r->out.infos[i].status = NT_STATUS_OK; - r->out.infos[i].homedir = homedir; - r->out.infos[i].shell = shell; - } - - return status; -} -- cgit From 8e54530b52fd256137740107e9fdf000f00a7a30 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 10 Oct 2007 18:25:16 -0700 Subject: Add start of IPv6 implementation. Currently most of this is avoiding IPv6 in winbindd, but moves most of the socket functions that were wrongly in lib/util.c into lib/util_sock.c and provides generic IPv4/6 independent versions of most things. Still lots of work to do, but now I can see how I'll fix the access check code. Nasty part that remains is the name resolution code which is used to returning arrays of in_addr structs. Jeremy. (This used to be commit 3f6bd0e1ec5cc6670f3d08f76fc2cd94c9cd1a08) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 11827c223b..1bed2bf095 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2534,13 +2534,13 @@ static BOOL spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, struct cli_state *the_cli; struct in_addr rm_addr; - if ( is_zero_ip(*client_ip) ) { + if ( is_zero_ip_v4(*client_ip) ) { if ( !resolve_name( remote_machine, &rm_addr, 0x20) ) { DEBUG(2,("spoolss_connect_to_client: Can't resolve address for %s\n", remote_machine)); return False; } - if ( ismyip( rm_addr )) { + if ( ismyip_v4( rm_addr )) { DEBUG(0,("spoolss_connect_to_client: Machine %s is one of our addresses. Cannot add to ourselves.\n", remote_machine)); return False; } -- cgit From e405187b0daf53c32a3defd7f582ca94e214e859 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Jul 2006 17:55:01 +0000 Subject: r17064: lsa_GetUserName needs to return the name for S-1-5-7 on an anonymous login. Found that because I want to play around with setsharesecurity, for this I need the "whoami" call figuring out the SID of the currently connected user. Not activating this test yet until the build farm has picked up the new samba4 revision. Volker (cherry picked from commit 5cfe482841b77208b68376f9e2b8a4a62271f7c9) (This used to be commit 15935bad1d756d3896f0687108e60ca10a35a936) --- source3/rpc_server/srv_lsa_nt.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c513d8489c..ea2bc0fa7b 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1545,14 +1545,26 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u) { - fstring username, domname; + const char *username, *domname; user_struct *vuser = get_valid_user_struct(p->vuid); if (vuser == NULL) return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; - - fstrcpy(username, vuser->user.smb_name); - fstrcpy(domname, vuser->user.domain); + + if (vuser->guest) { + /* + * I'm 99% sure this is not the right place to do this, + * global_sid_Anonymous should probably be put into the token + * instead of the guest id -- vl + */ + if (!lookup_sid(p->mem_ctx, &global_sid_Anonymous, + &domname, &username, NULL)) { + return NT_STATUS_NO_MEMORY; + } + } else { + username = vuser->user.smb_name; + domname = vuser->user.domain; + } r_u->ptr_user_name = 1; init_unistr2(&r_u->uni2_user_name, username, UNI_STR_TERMINATE); -- cgit From 7ed90852c5aae0f3dc71b07f22a5f983985c2086 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 5 Jun 2006 20:38:21 +0000 Subject: r16050: Set the session key "SystemLibraryDTC" on ntlmssp binds. We only do INTEGRITY and PRIVACY, so no other cases to take care of so far... Andrew B., if you have time, could you take a look? This makes us survive the RPC-SAMBA3SESSIONKEY test. Volker (cherry picked from commit 25cc1e7ff15675b70001d1cb8d8584880650dd2e) (This used to be commit b4746009735bf66b2578b884973c505b0363a79d) --- source3/rpc_server/srv_pipe.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 72ce72fb28..c213ec556a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -45,6 +45,11 @@ static void free_pipe_ntlmssp_auth_data(struct pipe_auth_data *auth) auth->a_u.auth_ntlmssp_state = NULL; } +static DATA_BLOB generic_session_key(void) +{ + return data_blob("SystemLibraryDTC", 16); +} + /******************************************************************* Generate the next PDU to be returned from the data in p->rdata. Handle NTLMSSP. @@ -668,11 +673,13 @@ static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) p->pipe_user.ut.gid = a->server_info->gid; /* - * Copy the session key from the ntlmssp state. + * We're an authenticated bind over smbd, so the session key needs to + * be set to "SystemLibraryDTC". Weird, but this is what Windows + * does. See the RPC-SAMBA3SESSIONKEY. */ data_blob_free(&p->session_key); - p->session_key = data_blob(a->ntlmssp_state->session_key.data, a->ntlmssp_state->session_key.length); + p->session_key = generic_session_key(); if (!p->session_key.data) { return False; } @@ -1351,8 +1358,21 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, * JRA. Should we also copy the schannel session key into the pipe session key p->session_key * here ? We do that for NTLMSSP, but the session key is already set up from the vuser * struct of the person who opened the pipe. I need to test this further. JRA. + * + * VL. As we are mapping this to guest set the generic key + * "SystemLibraryDTC" key here. It's a bit difficult to test against + * W2k3, as it does not allow schannel binds against SAMR and LSA + * anymore. */ + data_blob_free(&p->session_key); + p->session_key = generic_session_key(); + if (p->session_key.data == NULL) { + DEBUG(0, ("pipe_schannel_auth_bind: Could not alloc session" + " key\n")); + return False; + } + init_rpc_hdr_auth(&auth_info, RPC_SCHANNEL_AUTH_TYPE, pauth_info->auth_level, RPC_HDR_AUTH_LEN, 1); if(!smb_io_rpc_hdr_auth("", &auth_info, pout_auth, 0)) { DEBUG(0,("pipe_schannel_auth_bind: marshalling of RPC_HDR_AUTH failed.\n")); -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/rpc_server/srv_dfs_nt.c | 20 +++---- source3/rpc_server/srv_eventlog.c | 14 ++--- source3/rpc_server/srv_eventlog_lib.c | 14 ++--- source3/rpc_server/srv_eventlog_nt.c | 14 ++--- source3/rpc_server/srv_lsa.c | 72 +++++++++++------------ source3/rpc_server/srv_lsa_ds.c | 4 +- source3/rpc_server/srv_lsa_hnd.c | 12 ++-- source3/rpc_server/srv_netlog.c | 22 +++---- source3/rpc_server/srv_netlog_nt.c | 10 ++-- source3/rpc_server/srv_ntsvcs.c | 14 ++--- source3/rpc_server/srv_pipe.c | 52 ++++++++--------- source3/rpc_server/srv_pipe_hnd.c | 26 ++++----- source3/rpc_server/srv_samr.c | 96 +++++++++++++++---------------- source3/rpc_server/srv_samr_nt.c | 86 ++++++++++++++-------------- source3/rpc_server/srv_spoolss.c | 104 +++++++++++++++++----------------- source3/rpc_server/srv_spoolss_nt.c | 80 +++++++++++++------------- source3/rpc_server/srv_srvsvc.c | 40 ++++++------- source3/rpc_server/srv_srvsvc_nt.c | 22 +++---- source3/rpc_server/srv_svcctl.c | 34 +++++------ source3/rpc_server/srv_svcctl_nt.c | 2 +- source3/rpc_server/srv_winreg_nt.c | 10 ++-- 21 files changed, 374 insertions(+), 374 deletions(-) mode change 100755 => 100644 source3/rpc_server/srv_spoolss.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 6ed5dbd3b5..8a1cdedb4f 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -42,9 +42,9 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) { struct junction_map *jn = NULL; struct referral *old_referral_list = NULL; - BOOL self_ref = False; + bool self_ref = False; int consumedcnt = 0; - BOOL exists = False; + bool exists = False; char *altpath = NULL; NTSTATUS status; TALLOC_CTX *ctx = talloc_tos(); @@ -113,9 +113,9 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) { struct junction_map *jn = NULL; - BOOL self_ref = False; + bool self_ref = False; int consumedcnt = 0; - BOOL found = False; + bool found = False; TALLOC_CTX *ctx = talloc_tos(); char *altpath = NULL; @@ -195,7 +195,7 @@ WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) return WERR_OK; } -static BOOL init_reply_dfs_info_1(TALLOC_CTX *mem_ctx, struct junction_map* j,struct dfs_Info1* dfs1) +static bool init_reply_dfs_info_1(TALLOC_CTX *mem_ctx, struct junction_map* j,struct dfs_Info1* dfs1) { dfs1->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s\\%s", global_myname(), @@ -207,7 +207,7 @@ static BOOL init_reply_dfs_info_1(TALLOC_CTX *mem_ctx, struct junction_map* j,st return True; } -static BOOL init_reply_dfs_info_2(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info2* dfs2) +static bool init_reply_dfs_info_2(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info2* dfs2) { dfs2->path = talloc_asprintf(mem_ctx, "\\\\%s\\%s\\%s", global_myname(), j->service_name, j->volume_name); @@ -219,7 +219,7 @@ static BOOL init_reply_dfs_info_2(TALLOC_CTX *mem_ctx, struct junction_map* j, s return True; } -static BOOL init_reply_dfs_info_3(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info3* dfs3) +static bool init_reply_dfs_info_3(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info3* dfs3) { int ii; if (j->volume_name[0] == '\0') @@ -271,7 +271,7 @@ static BOOL init_reply_dfs_info_3(TALLOC_CTX *mem_ctx, struct junction_map* j, s return True; } -static BOOL init_reply_dfs_info_100(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info100* dfs100) +static bool init_reply_dfs_info_100(TALLOC_CTX *mem_ctx, struct junction_map* j, struct dfs_Info100* dfs100) { dfs100->comment = talloc_strdup(mem_ctx, j->comment); return True; @@ -355,9 +355,9 @@ WERROR _dfs_GetInfo(pipes_struct *p, struct dfs_GetInfo *r) { int consumedcnt = strlen(r->in.dfs_entry_path); struct junction_map *jn = NULL; - BOOL self_ref = False; + bool self_ref = False; TALLOC_CTX *ctx = talloc_tos(); - BOOL ret; + bool ret; jn = TALLOC_ZERO_P(ctx, struct junction_map); if (!jn) { diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c index fcba6a1268..516ea134f2 100644 --- a/source3/rpc_server/srv_eventlog.c +++ b/source3/rpc_server/srv_eventlog.c @@ -23,7 +23,7 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -static BOOL proxy_eventlog_call(pipes_struct *p, uint8 opnum) +static bool proxy_eventlog_call(pipes_struct *p, uint8 opnum) { struct api_struct *fns; int n_fns; @@ -40,7 +40,7 @@ static BOOL proxy_eventlog_call(pipes_struct *p, uint8 opnum) return fns[opnum].fn(p); } -static BOOL api_eventlog_open_eventlog(pipes_struct *p) +static bool api_eventlog_open_eventlog(pipes_struct *p) { EVENTLOG_Q_OPEN_EVENTLOG q_u; EVENTLOG_R_OPEN_EVENTLOG r_u; @@ -65,12 +65,12 @@ static BOOL api_eventlog_open_eventlog(pipes_struct *p) return True; } -static BOOL api_eventlog_close_eventlog(pipes_struct *p) +static bool api_eventlog_close_eventlog(pipes_struct *p) { return proxy_eventlog_call( p, NDR_EVENTLOG_CLOSEEVENTLOG ); } -static BOOL api_eventlog_get_num_records(pipes_struct *p) +static bool api_eventlog_get_num_records(pipes_struct *p) { EVENTLOG_Q_GET_NUM_RECORDS q_u; EVENTLOG_R_GET_NUM_RECORDS r_u; @@ -95,7 +95,7 @@ static BOOL api_eventlog_get_num_records(pipes_struct *p) return True; } -static BOOL api_eventlog_get_oldest_entry(pipes_struct *p) +static bool api_eventlog_get_oldest_entry(pipes_struct *p) { EVENTLOG_Q_GET_OLDEST_ENTRY q_u; EVENTLOG_R_GET_OLDEST_ENTRY r_u; @@ -120,7 +120,7 @@ static BOOL api_eventlog_get_oldest_entry(pipes_struct *p) return True; } -static BOOL api_eventlog_read_eventlog(pipes_struct *p) +static bool api_eventlog_read_eventlog(pipes_struct *p) { EVENTLOG_Q_READ_EVENTLOG q_u; EVENTLOG_R_READ_EVENTLOG r_u; @@ -145,7 +145,7 @@ static BOOL api_eventlog_read_eventlog(pipes_struct *p) return True; } -static BOOL api_eventlog_clear_eventlog(pipes_struct *p) +static bool api_eventlog_clear_eventlog(pipes_struct *p) { EVENTLOG_Q_CLEAR_EVENTLOG q_u; EVENTLOG_R_CLEAR_EVENTLOG r_u; diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index f21e983eb7..3f06f0f39f 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -141,8 +141,8 @@ int elog_tdb_size( TDB_CONTEXT * tdb, int *MaxSize, int *Retention ) return True if we made enough room to accommodate needed bytes ********************************************************************/ -BOOL make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, - BOOL whack_by_date ) +bool make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, + bool whack_by_date ) { int start_record, i, new_start; int end_record; @@ -247,7 +247,7 @@ BOOL make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, calculate how many bytes we need to remove ********************************************************************/ -BOOL prune_eventlog( TDB_CONTEXT * tdb ) +bool prune_eventlog( TDB_CONTEXT * tdb ) { int MaxSize, Retention, CalcdSize; @@ -272,7 +272,7 @@ BOOL prune_eventlog( TDB_CONTEXT * tdb ) /******************************************************************** ********************************************************************/ -BOOL can_write_to_eventlog( TDB_CONTEXT * tdb, int32 needed ) +bool can_write_to_eventlog( TDB_CONTEXT * tdb, int32 needed ) { int calcd_size; int MaxSize, Retention; @@ -315,7 +315,7 @@ BOOL can_write_to_eventlog( TDB_CONTEXT * tdb, int32 needed ) /******************************************************************* *******************************************************************/ -ELOG_TDB *elog_open_tdb( char *logname, BOOL force_clear ) +ELOG_TDB *elog_open_tdb( char *logname, bool force_clear ) { TDB_CONTEXT *tdb = NULL; uint32 vers_id; @@ -412,7 +412,7 @@ ELOG_TDB *elog_open_tdb( char *logname, BOOL force_clear ) Wrapper to handle reference counts to the tdb *******************************************************************/ -int elog_close_tdb( ELOG_TDB *etdb, BOOL force_close ) +int elog_close_tdb( ELOG_TDB *etdb, bool force_close ) { TDB_CONTEXT *tdb; @@ -591,7 +591,7 @@ void fixup_eventlog_entry( Eventlog_entry * ee ) going in. ********************************************************************/ -BOOL parse_logentry( char *line, Eventlog_entry * entry, BOOL * eor ) +bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor ) { char *start = NULL, *stop = NULL; pstring temp; diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 32940b3417..d86da9054c 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -67,11 +67,11 @@ static EVENTLOG_INFO *find_eventlog_info_by_hnd( pipes_struct * p, /******************************************************************** ********************************************************************/ -static BOOL elog_check_access( EVENTLOG_INFO *info, NT_USER_TOKEN *token ) +static bool elog_check_access( EVENTLOG_INFO *info, NT_USER_TOKEN *token ) { char *tdbname = elog_tdbname( info->logname ); SEC_DESC *sec_desc; - BOOL ret; + bool ret; NTSTATUS ntstatus; if ( !tdbname ) @@ -117,7 +117,7 @@ static BOOL elog_check_access( EVENTLOG_INFO *info, NT_USER_TOKEN *token ) /******************************************************************** ********************************************************************/ -static BOOL elog_validate_logname( const char *name ) +static bool elog_validate_logname( const char *name ) { int i; const char **elogs = lp_eventlog_list(); @@ -137,7 +137,7 @@ static BOOL elog_validate_logname( const char *name ) /******************************************************************** ********************************************************************/ -static BOOL get_num_records_hook( EVENTLOG_INFO * info ) +static bool get_num_records_hook( EVENTLOG_INFO * info ) { int next_record; int oldest_record; @@ -167,7 +167,7 @@ static BOOL get_num_records_hook( EVENTLOG_INFO * info ) /******************************************************************** ********************************************************************/ -static BOOL get_oldest_entry_hook( EVENTLOG_INFO * info ) +static bool get_oldest_entry_hook( EVENTLOG_INFO * info ) { /* it's the same thing */ return get_num_records_hook( info ); @@ -385,7 +385,7 @@ static Eventlog_entry *get_eventlog_record( prs_struct * ps, TDB_CONTEXT * tdb, since it uses the table to find the tdb handle ********************************************************************/ -static BOOL sync_eventlog_params( EVENTLOG_INFO *info ) +static bool sync_eventlog_params( EVENTLOG_INFO *info ) { pstring path; uint32 uiMaxSize; @@ -543,7 +543,7 @@ static Eventlog_entry *read_package_entry( prs_struct * ps, /******************************************************************** ********************************************************************/ -static BOOL add_record_to_resp( EVENTLOG_R_READ_EVENTLOG * r_u, +static bool add_record_to_resp( EVENTLOG_R_READ_EVENTLOG * r_u, Eventlog_entry * ee_new ) { Eventlog_entry *insert_point; diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 484e964068..b433ac2c8f 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -29,7 +29,7 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -static BOOL proxy_lsa_call(pipes_struct *p, uint8 opnum) +static bool proxy_lsa_call(pipes_struct *p, uint8 opnum) { struct api_struct *fns; int n_fns; @@ -50,7 +50,7 @@ static BOOL proxy_lsa_call(pipes_struct *p, uint8 opnum) api_lsa_open_policy2 ***************************************************************************/ -static BOOL api_lsa_open_policy2(pipes_struct *p) +static bool api_lsa_open_policy2(pipes_struct *p) { LSA_Q_OPEN_POL2 q_u; LSA_R_OPEN_POL2 r_u; @@ -81,7 +81,7 @@ static BOOL api_lsa_open_policy2(pipes_struct *p) api_lsa_open_policy ***************************************************************************/ -static BOOL api_lsa_open_policy(pipes_struct *p) +static bool api_lsa_open_policy(pipes_struct *p) { LSA_Q_OPEN_POL q_u; LSA_R_OPEN_POL r_u; @@ -112,7 +112,7 @@ static BOOL api_lsa_open_policy(pipes_struct *p) api_lsa_enum_trust_dom ***************************************************************************/ -static BOOL api_lsa_enum_trust_dom(pipes_struct *p) +static bool api_lsa_enum_trust_dom(pipes_struct *p) { LSA_Q_ENUM_TRUST_DOM q_u; LSA_R_ENUM_TRUST_DOM r_u; @@ -140,7 +140,7 @@ static BOOL api_lsa_enum_trust_dom(pipes_struct *p) api_lsa_query_info ***************************************************************************/ -static BOOL api_lsa_query_info(pipes_struct *p) +static bool api_lsa_query_info(pipes_struct *p) { LSA_Q_QUERY_INFO q_u; LSA_R_QUERY_INFO r_u; @@ -171,7 +171,7 @@ static BOOL api_lsa_query_info(pipes_struct *p) api_lsa_lookup_sids ***************************************************************************/ -static BOOL api_lsa_lookup_sids(pipes_struct *p) +static bool api_lsa_lookup_sids(pipes_struct *p) { LSA_Q_LOOKUP_SIDS q_u; LSA_R_LOOKUP_SIDS r_u; @@ -201,7 +201,7 @@ static BOOL api_lsa_lookup_sids(pipes_struct *p) api_lsa_lookup_names ***************************************************************************/ -static BOOL api_lsa_lookup_names(pipes_struct *p) +static bool api_lsa_lookup_names(pipes_struct *p) { LSA_Q_LOOKUP_NAMES q_u; LSA_R_LOOKUP_NAMES r_u; @@ -232,7 +232,7 @@ static BOOL api_lsa_lookup_names(pipes_struct *p) api_lsa_close. ***************************************************************************/ -static BOOL api_lsa_close(pipes_struct *p) +static bool api_lsa_close(pipes_struct *p) { return proxy_lsa_call(p, NDR_LSA_CLOSE); } @@ -241,7 +241,7 @@ static BOOL api_lsa_close(pipes_struct *p) api_lsa_open_secret. ***************************************************************************/ -static BOOL api_lsa_open_secret(pipes_struct *p) +static bool api_lsa_open_secret(pipes_struct *p) { return proxy_lsa_call(p, NDR_LSA_OPENSECRET); } @@ -250,7 +250,7 @@ static BOOL api_lsa_open_secret(pipes_struct *p) api_lsa_open_secret. ***************************************************************************/ -static BOOL api_lsa_enum_privs(pipes_struct *p) +static bool api_lsa_enum_privs(pipes_struct *p) { LSA_Q_ENUM_PRIVS q_u; LSA_R_ENUM_PRIVS r_u; @@ -280,7 +280,7 @@ static BOOL api_lsa_enum_privs(pipes_struct *p) api_lsa_open_secret. ***************************************************************************/ -static BOOL api_lsa_priv_get_dispname(pipes_struct *p) +static bool api_lsa_priv_get_dispname(pipes_struct *p) { LSA_Q_PRIV_GET_DISPNAME q_u; LSA_R_PRIV_GET_DISPNAME r_u; @@ -310,7 +310,7 @@ static BOOL api_lsa_priv_get_dispname(pipes_struct *p) api_lsa_open_secret. ***************************************************************************/ -static BOOL api_lsa_enum_accounts(pipes_struct *p) +static bool api_lsa_enum_accounts(pipes_struct *p) { LSA_Q_ENUM_ACCOUNTS q_u; LSA_R_ENUM_ACCOUNTS r_u; @@ -340,7 +340,7 @@ static BOOL api_lsa_enum_accounts(pipes_struct *p) api_lsa_UNK_GET_CONNUSER ***************************************************************************/ -static BOOL api_lsa_unk_get_connuser(pipes_struct *p) +static bool api_lsa_unk_get_connuser(pipes_struct *p) { LSA_Q_UNK_GET_CONNUSER q_u; LSA_R_UNK_GET_CONNUSER r_u; @@ -371,7 +371,7 @@ static BOOL api_lsa_unk_get_connuser(pipes_struct *p) api_lsa_create_user ***************************************************************************/ -static BOOL api_lsa_create_account(pipes_struct *p) +static bool api_lsa_create_account(pipes_struct *p) { LSA_Q_CREATEACCOUNT q_u; LSA_R_CREATEACCOUNT r_u; @@ -402,7 +402,7 @@ static BOOL api_lsa_create_account(pipes_struct *p) api_lsa_open_user ***************************************************************************/ -static BOOL api_lsa_open_account(pipes_struct *p) +static bool api_lsa_open_account(pipes_struct *p) { LSA_Q_OPENACCOUNT q_u; LSA_R_OPENACCOUNT r_u; @@ -433,7 +433,7 @@ static BOOL api_lsa_open_account(pipes_struct *p) api_lsa_get_privs ***************************************************************************/ -static BOOL api_lsa_enum_privsaccount(pipes_struct *p) +static bool api_lsa_enum_privsaccount(pipes_struct *p) { LSA_Q_ENUMPRIVSACCOUNT q_u; LSA_R_ENUMPRIVSACCOUNT r_u; @@ -464,7 +464,7 @@ static BOOL api_lsa_enum_privsaccount(pipes_struct *p) api_lsa_getsystemaccount ***************************************************************************/ -static BOOL api_lsa_getsystemaccount(pipes_struct *p) +static bool api_lsa_getsystemaccount(pipes_struct *p) { LSA_Q_GETSYSTEMACCOUNT q_u; LSA_R_GETSYSTEMACCOUNT r_u; @@ -496,7 +496,7 @@ static BOOL api_lsa_getsystemaccount(pipes_struct *p) api_lsa_setsystemaccount ***************************************************************************/ -static BOOL api_lsa_setsystemaccount(pipes_struct *p) +static bool api_lsa_setsystemaccount(pipes_struct *p) { LSA_Q_SETSYSTEMACCOUNT q_u; LSA_R_SETSYSTEMACCOUNT r_u; @@ -527,7 +527,7 @@ static BOOL api_lsa_setsystemaccount(pipes_struct *p) api_lsa_addprivs ***************************************************************************/ -static BOOL api_lsa_addprivs(pipes_struct *p) +static bool api_lsa_addprivs(pipes_struct *p) { LSA_Q_ADDPRIVS q_u; LSA_R_ADDPRIVS r_u; @@ -558,7 +558,7 @@ static BOOL api_lsa_addprivs(pipes_struct *p) api_lsa_removeprivs ***************************************************************************/ -static BOOL api_lsa_removeprivs(pipes_struct *p) +static bool api_lsa_removeprivs(pipes_struct *p) { LSA_Q_REMOVEPRIVS q_u; LSA_R_REMOVEPRIVS r_u; @@ -589,7 +589,7 @@ static BOOL api_lsa_removeprivs(pipes_struct *p) api_lsa_query_secobj ***************************************************************************/ -static BOOL api_lsa_query_secobj(pipes_struct *p) +static bool api_lsa_query_secobj(pipes_struct *p) { LSA_Q_QUERY_SEC_OBJ q_u; LSA_R_QUERY_SEC_OBJ r_u; @@ -620,7 +620,7 @@ static BOOL api_lsa_query_secobj(pipes_struct *p) api_lsa_add_acct_rights ***************************************************************************/ -static BOOL api_lsa_add_acct_rights(pipes_struct *p) +static bool api_lsa_add_acct_rights(pipes_struct *p) { LSA_Q_ADD_ACCT_RIGHTS q_u; LSA_R_ADD_ACCT_RIGHTS r_u; @@ -651,7 +651,7 @@ static BOOL api_lsa_add_acct_rights(pipes_struct *p) api_lsa_remove_acct_rights ***************************************************************************/ -static BOOL api_lsa_remove_acct_rights(pipes_struct *p) +static bool api_lsa_remove_acct_rights(pipes_struct *p) { LSA_Q_REMOVE_ACCT_RIGHTS q_u; LSA_R_REMOVE_ACCT_RIGHTS r_u; @@ -682,7 +682,7 @@ static BOOL api_lsa_remove_acct_rights(pipes_struct *p) api_lsa_enum_acct_rights ***************************************************************************/ -static BOOL api_lsa_enum_acct_rights(pipes_struct *p) +static bool api_lsa_enum_acct_rights(pipes_struct *p) { LSA_Q_ENUM_ACCT_RIGHTS q_u; LSA_R_ENUM_ACCT_RIGHTS r_u; @@ -713,7 +713,7 @@ static BOOL api_lsa_enum_acct_rights(pipes_struct *p) api_lsa_lookup_priv_value ***************************************************************************/ -static BOOL api_lsa_lookup_priv_value(pipes_struct *p) +static bool api_lsa_lookup_priv_value(pipes_struct *p) { LSA_Q_LOOKUP_PRIV_VALUE q_u; LSA_R_LOOKUP_PRIV_VALUE r_u; @@ -743,7 +743,7 @@ static BOOL api_lsa_lookup_priv_value(pipes_struct *p) /*************************************************************************** ***************************************************************************/ -static BOOL api_lsa_open_trust_dom(pipes_struct *p) +static bool api_lsa_open_trust_dom(pipes_struct *p) { return proxy_lsa_call(p, NDR_LSA_OPENTRUSTEDDOMAIN); } @@ -751,7 +751,7 @@ static BOOL api_lsa_open_trust_dom(pipes_struct *p) /*************************************************************************** ***************************************************************************/ -static BOOL api_lsa_create_trust_dom(pipes_struct *p) +static bool api_lsa_create_trust_dom(pipes_struct *p) { return proxy_lsa_call(p, NDR_LSA_CREATETRUSTEDDOMAIN); } @@ -759,7 +759,7 @@ static BOOL api_lsa_create_trust_dom(pipes_struct *p) /*************************************************************************** ***************************************************************************/ -static BOOL api_lsa_create_secret(pipes_struct *p) +static bool api_lsa_create_secret(pipes_struct *p) { return proxy_lsa_call(p, NDR_LSA_CREATESECRET); } @@ -767,7 +767,7 @@ static BOOL api_lsa_create_secret(pipes_struct *p) /*************************************************************************** ***************************************************************************/ -static BOOL api_lsa_set_secret(pipes_struct *p) +static bool api_lsa_set_secret(pipes_struct *p) { return proxy_lsa_call(p, NDR_LSA_SETSECRET); } @@ -775,7 +775,7 @@ static BOOL api_lsa_set_secret(pipes_struct *p) /*************************************************************************** ***************************************************************************/ -static BOOL api_lsa_delete_object(pipes_struct *p) +static bool api_lsa_delete_object(pipes_struct *p) { LSA_Q_DELETE_OBJECT q_u; LSA_R_DELETE_OBJECT r_u; @@ -806,7 +806,7 @@ static BOOL api_lsa_delete_object(pipes_struct *p) api_lsa_lookup_sids2 ***************************************************************************/ -static BOOL api_lsa_lookup_sids2(pipes_struct *p) +static bool api_lsa_lookup_sids2(pipes_struct *p) { LSA_Q_LOOKUP_SIDS2 q_u; LSA_R_LOOKUP_SIDS2 r_u; @@ -836,7 +836,7 @@ static BOOL api_lsa_lookup_sids2(pipes_struct *p) api_lsa_lookup_sids3 ***************************************************************************/ -static BOOL api_lsa_lookup_sids3(pipes_struct *p) +static bool api_lsa_lookup_sids3(pipes_struct *p) { LSA_Q_LOOKUP_SIDS3 q_u; LSA_R_LOOKUP_SIDS3 r_u; @@ -866,7 +866,7 @@ static BOOL api_lsa_lookup_sids3(pipes_struct *p) api_lsa_lookup_names2 ***************************************************************************/ -static BOOL api_lsa_lookup_names2(pipes_struct *p) +static bool api_lsa_lookup_names2(pipes_struct *p) { LSA_Q_LOOKUP_NAMES2 q_u; LSA_R_LOOKUP_NAMES2 r_u; @@ -897,7 +897,7 @@ static BOOL api_lsa_lookup_names2(pipes_struct *p) api_lsa_lookup_names3 ***************************************************************************/ -static BOOL api_lsa_lookup_names3(pipes_struct *p) +static bool api_lsa_lookup_names3(pipes_struct *p) { LSA_Q_LOOKUP_NAMES3 q_u; LSA_R_LOOKUP_NAMES3 r_u; @@ -928,7 +928,7 @@ static BOOL api_lsa_lookup_names3(pipes_struct *p) api_lsa_lookup_names4 ***************************************************************************/ -static BOOL api_lsa_lookup_names4(pipes_struct *p) +static bool api_lsa_lookup_names4(pipes_struct *p) { LSA_Q_LOOKUP_NAMES4 q_u; LSA_R_LOOKUP_NAMES4 r_u; @@ -961,7 +961,7 @@ static BOOL api_lsa_lookup_names4(pipes_struct *p) api_lsa_query_info2 ***************************************************************************/ -static BOOL api_lsa_query_info2(pipes_struct *p) +static bool api_lsa_query_info2(pipes_struct *p) { LSA_Q_QUERY_INFO2 q_u; LSA_R_QUERY_INFO2 r_u; diff --git a/source3/rpc_server/srv_lsa_ds.c b/source3/rpc_server/srv_lsa_ds.c index 52fd06cd51..55baa40261 100644 --- a/source3/rpc_server/srv_lsa_ds.c +++ b/source3/rpc_server/srv_lsa_ds.c @@ -27,7 +27,7 @@ /******************************************************************* ********************************************************************/ -static BOOL api_dsrole_get_primary_dominfo(pipes_struct *p) +static bool api_dsrole_get_primary_dominfo(pipes_struct *p) { DS_Q_GETPRIMDOMINFO q_u; DS_R_GETPRIMDOMINFO r_u; @@ -54,7 +54,7 @@ static BOOL api_dsrole_get_primary_dominfo(pipes_struct *p) stub functions for unimplemented RPC *******************************************************************/ -static BOOL api_dsrole_stub( pipes_struct *p ) +static bool api_dsrole_stub( pipes_struct *p ) { DEBUG(0,("api_dsrole_stub: Hmmm....didn't know this RPC existed...\n")); diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 45b4fb9a5c..fa63c8091e 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -34,7 +34,7 @@ pipe is open. JRA. ****************************************************************************/ -static BOOL is_samr_lsa_pipe(const char *pipe_name) +static bool is_samr_lsa_pipe(const char *pipe_name) { return (strstr(pipe_name, "samr") || strstr(pipe_name, "lsa")); } @@ -44,7 +44,7 @@ static BOOL is_samr_lsa_pipe(const char *pipe_name) pipes of the same name. ****************************************************************************/ -BOOL init_pipe_handle_list(pipes_struct *p, const char *pipe_name) +bool init_pipe_handle_list(pipes_struct *p, const char *pipe_name) { pipes_struct *plist = get_first_internal_pipe(); struct handle_list *hl = NULL; @@ -98,7 +98,7 @@ BOOL init_pipe_handle_list(pipes_struct *p, const char *pipe_name) find first available policy slot. creates a policy handle for you. ****************************************************************************/ -BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *), void *data_ptr) +bool create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *), void *data_ptr) { static uint32 pol_hnd_low = 0; static uint32 pol_hnd_high = 0; @@ -184,7 +184,7 @@ static struct policy *find_policy_by_hnd_internal(pipes_struct *p, POLICY_HND *h find policy by handle ****************************************************************************/ -BOOL find_policy_by_hnd(pipes_struct *p, POLICY_HND *hnd, void **data_p) +bool find_policy_by_hnd(pipes_struct *p, POLICY_HND *hnd, void **data_p) { return find_policy_by_hnd_internal(p, hnd, data_p) == NULL ? False : True; } @@ -193,7 +193,7 @@ BOOL find_policy_by_hnd(pipes_struct *p, POLICY_HND *hnd, void **data_p) Close a policy. ****************************************************************************/ -BOOL close_policy_hnd(pipes_struct *p, POLICY_HND *hnd) +bool close_policy_hnd(pipes_struct *p, POLICY_HND *hnd) { struct policy *pol = find_policy_by_hnd_internal(p, hnd, NULL); @@ -249,7 +249,7 @@ will be checking a security descriptor to determine whether a user token has enough access to access the pipe. ********************************************************************/ -BOOL pipe_access_check(pipes_struct *p) +bool pipe_access_check(pipes_struct *p) { /* Don't let anonymous users access this RPC if restrict anonymous > 0 */ diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 3f2dbe6747..6d9859a9ae 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -32,7 +32,7 @@ api_net_req_chal: *************************************************************************/ -static BOOL api_net_req_chal(pipes_struct *p) +static bool api_net_req_chal(pipes_struct *p) { NET_Q_REQ_CHAL q_u; NET_R_REQ_CHAL r_u; @@ -63,7 +63,7 @@ static BOOL api_net_req_chal(pipes_struct *p) api_net_auth: *************************************************************************/ -static BOOL api_net_auth(pipes_struct *p) +static bool api_net_auth(pipes_struct *p) { NET_Q_AUTH q_u; NET_R_AUTH r_u; @@ -94,7 +94,7 @@ static BOOL api_net_auth(pipes_struct *p) api_net_auth_2: *************************************************************************/ -static BOOL api_net_auth_2(pipes_struct *p) +static bool api_net_auth_2(pipes_struct *p) { NET_Q_AUTH_2 q_u; NET_R_AUTH_2 r_u; @@ -125,7 +125,7 @@ static BOOL api_net_auth_2(pipes_struct *p) api_net_srv_pwset: *************************************************************************/ -static BOOL api_net_srv_pwset(pipes_struct *p) +static bool api_net_srv_pwset(pipes_struct *p) { NET_Q_SRV_PWSET q_u; NET_R_SRV_PWSET r_u; @@ -156,7 +156,7 @@ static BOOL api_net_srv_pwset(pipes_struct *p) api_net_sam_logoff: *************************************************************************/ -static BOOL api_net_sam_logoff(pipes_struct *p) +static bool api_net_sam_logoff(pipes_struct *p) { NET_Q_SAM_LOGOFF q_u; NET_R_SAM_LOGOFF r_u; @@ -186,7 +186,7 @@ static BOOL api_net_sam_logoff(pipes_struct *p) api_net_sam_logon: *************************************************************************/ -static BOOL api_net_sam_logon(pipes_struct *p) +static bool api_net_sam_logon(pipes_struct *p) { NET_Q_SAM_LOGON q_u; NET_R_SAM_LOGON r_u; @@ -216,7 +216,7 @@ static BOOL api_net_sam_logon(pipes_struct *p) api_net_trust_dom_list: *************************************************************************/ -static BOOL api_net_trust_dom_list(pipes_struct *p) +static bool api_net_trust_dom_list(pipes_struct *p) { NET_Q_TRUST_DOM_LIST q_u; NET_R_TRUST_DOM_LIST r_u; @@ -248,7 +248,7 @@ static BOOL api_net_trust_dom_list(pipes_struct *p) api_net_logon_ctrl2: *************************************************************************/ -static BOOL api_net_logon_ctrl2(pipes_struct *p) +static bool api_net_logon_ctrl2(pipes_struct *p) { NET_Q_LOGON_CTRL2 q_u; NET_R_LOGON_CTRL2 r_u; @@ -279,7 +279,7 @@ static BOOL api_net_logon_ctrl2(pipes_struct *p) api_net_logon_ctrl: *************************************************************************/ -static BOOL api_net_logon_ctrl(pipes_struct *p) +static bool api_net_logon_ctrl(pipes_struct *p) { NET_Q_LOGON_CTRL q_u; NET_R_LOGON_CTRL r_u; @@ -309,7 +309,7 @@ static BOOL api_net_logon_ctrl(pipes_struct *p) api_net_sam_logon_ex: *************************************************************************/ -static BOOL api_net_sam_logon_ex(pipes_struct *p) +static bool api_net_sam_logon_ex(pipes_struct *p) { NET_Q_SAM_LOGON_EX q_u; NET_R_SAM_LOGON_EX r_u; @@ -341,7 +341,7 @@ static BOOL api_net_sam_logon_ex(pipes_struct *p) *************************************************************************/ #if 0 /* JERRY */ -static BOOL api_ds_enum_dom_trusts(pipes_struct *p) +static bool api_ds_enum_dom_trusts(pipes_struct *p) { DS_Q_ENUM_DOM_TRUSTS q_u; DS_R_ENUM_DOM_TRUSTS r_u; diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 3f1b0916df..b651fdaac3 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -194,7 +194,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) { struct samu *sampass = NULL; const uint8 *pass; - BOOL ret; + bool ret; uint32 acct_ctrl; #if 0 @@ -498,7 +498,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * { fstring remote_machine; struct samu *sampass=NULL; - BOOL ret = False; + bool ret = False; unsigned char pwd[16]; int i; uint32 acct_ctrl; @@ -654,7 +654,7 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF if (!p->dc) { /* Restore the saved state of the netlogon creds. */ - BOOL ret; + bool ret; become_root(); ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, @@ -728,7 +728,7 @@ static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, static NTSTATUS _net_sam_logon_internal(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_u, - BOOL process_creds) + bool process_creds) { NTSTATUS status = NT_STATUS_OK; NET_USER_INFO_3 *usr_info = NULL; @@ -784,7 +784,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (!p->dc) { /* Restore the saved state of the netlogon creds. */ - BOOL ret; + bool ret; become_root(); ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index 9d4c02500f..b3e93ac459 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -25,7 +25,7 @@ /******************************************************************* ********************************************************************/ -static BOOL api_ntsvcs_get_version(pipes_struct *p) +static bool api_ntsvcs_get_version(pipes_struct *p) { NTSVCS_Q_GET_VERSION q_u; NTSVCS_R_GET_VERSION r_u; @@ -49,7 +49,7 @@ static BOOL api_ntsvcs_get_version(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_ntsvcs_get_device_list_size(pipes_struct *p) +static bool api_ntsvcs_get_device_list_size(pipes_struct *p) { NTSVCS_Q_GET_DEVICE_LIST_SIZE q_u; NTSVCS_R_GET_DEVICE_LIST_SIZE r_u; @@ -73,7 +73,7 @@ static BOOL api_ntsvcs_get_device_list_size(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_ntsvcs_get_device_list(pipes_struct *p) +static bool api_ntsvcs_get_device_list(pipes_struct *p) { NTSVCS_Q_GET_DEVICE_LIST q_u; NTSVCS_R_GET_DEVICE_LIST r_u; @@ -97,7 +97,7 @@ static BOOL api_ntsvcs_get_device_list(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_ntsvcs_validate_device_instance(pipes_struct *p) +static bool api_ntsvcs_validate_device_instance(pipes_struct *p) { NTSVCS_Q_VALIDATE_DEVICE_INSTANCE q_u; NTSVCS_R_VALIDATE_DEVICE_INSTANCE r_u; @@ -121,7 +121,7 @@ static BOOL api_ntsvcs_validate_device_instance(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_ntsvcs_get_device_reg_property(pipes_struct *p) +static bool api_ntsvcs_get_device_reg_property(pipes_struct *p) { NTSVCS_Q_GET_DEVICE_REG_PROPERTY q_u; NTSVCS_R_GET_DEVICE_REG_PROPERTY r_u; @@ -145,7 +145,7 @@ static BOOL api_ntsvcs_get_device_reg_property(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_ntsvcs_get_hw_profile_info(pipes_struct *p) +static bool api_ntsvcs_get_hw_profile_info(pipes_struct *p) { NTSVCS_Q_GET_HW_PROFILE_INFO q_u; NTSVCS_R_GET_HW_PROFILE_INFO r_u; @@ -169,7 +169,7 @@ static BOOL api_ntsvcs_get_hw_profile_info(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_ntsvcs_hw_profile_flags(pipes_struct *p) +static bool api_ntsvcs_hw_profile_flags(pipes_struct *p) { NTSVCS_Q_HW_PROFILE_FLAGS q_u; NTSVCS_R_HW_PROFILE_FLAGS r_u; diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index c213ec556a..49ffcf13a6 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -55,7 +55,7 @@ static DATA_BLOB generic_session_key(void) Handle NTLMSSP. ********************************************************************/ -static BOOL create_next_pdu_ntlmssp(pipes_struct *p) +static bool create_next_pdu_ntlmssp(pipes_struct *p) { RPC_HDR_RESP hdr_resp; uint32 ss_padding_len = 0; @@ -272,7 +272,7 @@ static BOOL create_next_pdu_ntlmssp(pipes_struct *p) Return an schannel authenticated fragment. ********************************************************************/ -static BOOL create_next_pdu_schannel(pipes_struct *p) +static bool create_next_pdu_schannel(pipes_struct *p) { RPC_HDR_RESP hdr_resp; uint32 ss_padding_len = 0; @@ -450,7 +450,7 @@ static BOOL create_next_pdu_schannel(pipes_struct *p) No authentication done. ********************************************************************/ -static BOOL create_next_pdu_noauth(pipes_struct *p) +static bool create_next_pdu_noauth(pipes_struct *p) { RPC_HDR_RESP hdr_resp; uint32 data_len; @@ -571,7 +571,7 @@ static BOOL create_next_pdu_noauth(pipes_struct *p) Generate the next PDU to be returned from the data in p->rdata. ********************************************************************/ -BOOL create_next_pdu(pipes_struct *p) +bool create_next_pdu(pipes_struct *p) { switch(p->auth.auth_level) { case PIPE_AUTH_LEVEL_NONE: @@ -604,7 +604,7 @@ BOOL create_next_pdu(pipes_struct *p) the pipe struct. *******************************************************************/ -static BOOL pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) +static bool pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) { DATA_BLOB reply; NTSTATUS status; @@ -725,7 +725,7 @@ static int rpc_lookup_size; This is the "stage3" NTLMSSP response after a bind request and reply. *******************************************************************/ -BOOL api_pipe_bind_auth3(pipes_struct *p, prs_struct *rpc_in_p) +bool api_pipe_bind_auth3(pipes_struct *p, prs_struct *rpc_in_p) { RPC_HDR_AUTH auth_info; uint32 pad; @@ -797,7 +797,7 @@ BOOL api_pipe_bind_auth3(pipes_struct *p, prs_struct *rpc_in_p) Marshall a bind_nak pdu. *******************************************************************/ -static BOOL setup_bind_nak(pipes_struct *p) +static bool setup_bind_nak(pipes_struct *p) { prs_struct outgoing_rpc; RPC_HDR nak_hdr; @@ -859,7 +859,7 @@ static BOOL setup_bind_nak(pipes_struct *p) Marshall a fault pdu. *******************************************************************/ -BOOL setup_fault_pdu(pipes_struct *p, NTSTATUS status) +bool setup_fault_pdu(pipes_struct *p, NTSTATUS status) { prs_struct outgoing_pdu; RPC_HDR fault_hdr; @@ -930,7 +930,7 @@ BOOL setup_fault_pdu(pipes_struct *p, NTSTATUS status) We should probably check the auth-verifier here. *******************************************************************/ -BOOL setup_cancel_ack_reply(pipes_struct *p, prs_struct *rpc_in_p) +bool setup_cancel_ack_reply(pipes_struct *p, prs_struct *rpc_in_p) { prs_struct outgoing_pdu; RPC_HDR ack_reply_hdr; @@ -978,7 +978,7 @@ BOOL setup_cancel_ack_reply(pipes_struct *p, prs_struct *rpc_in_p) Used to reject unknown binds from Win2k. *******************************************************************/ -BOOL check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, +bool check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, RPC_IFACE* transfer, uint32 context_id) { char *pipe_name = p->name; @@ -1089,7 +1089,7 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *s Handle a SPNEGO krb5 bind auth. *******************************************************************/ -static BOOL pipe_spnego_auth_bind_kerberos(pipes_struct *p, prs_struct *rpc_in_p, RPC_HDR_AUTH *pauth_info, +static bool pipe_spnego_auth_bind_kerberos(pipes_struct *p, prs_struct *rpc_in_p, RPC_HDR_AUTH *pauth_info, DATA_BLOB *psecblob, prs_struct *pout_auth) { return False; @@ -1099,7 +1099,7 @@ static BOOL pipe_spnego_auth_bind_kerberos(pipes_struct *p, prs_struct *rpc_in_p Handle the first part of a SPNEGO bind auth. *******************************************************************/ -static BOOL pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_p, +static bool pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_p, RPC_HDR_AUTH *pauth_info, prs_struct *pout_auth) { DATA_BLOB blob; @@ -1109,7 +1109,7 @@ static BOOL pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_ char *OIDs[ASN1_MAX_OIDS]; int i; NTSTATUS status; - BOOL got_kerberos_mechanism = False; + bool got_kerberos_mechanism = False; AUTH_NTLMSSP_STATE *a = NULL; RPC_HDR_AUTH auth_info; @@ -1147,7 +1147,7 @@ static BOOL pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_ DEBUG(3,("pipe_spnego_auth_bind_negotiate: Got secblob of size %lu\n", (unsigned long)secblob.length)); if ( got_kerberos_mechanism && ((lp_security()==SEC_ADS) || lp_use_kerberos_keytab()) ) { - BOOL ret = pipe_spnego_auth_bind_kerberos(p, rpc_in_p, pauth_info, &secblob, pout_auth); + bool ret = pipe_spnego_auth_bind_kerberos(p, rpc_in_p, pauth_info, &secblob, pout_auth); data_blob_free(&secblob); data_blob_free(&blob); return ret; @@ -1220,7 +1220,7 @@ static BOOL pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_ Handle the second part of a SPNEGO bind auth. *******************************************************************/ -static BOOL pipe_spnego_auth_bind_continue(pipes_struct *p, prs_struct *rpc_in_p, +static bool pipe_spnego_auth_bind_continue(pipes_struct *p, prs_struct *rpc_in_p, RPC_HDR_AUTH *pauth_info, prs_struct *pout_auth) { RPC_HDR_AUTH auth_info; @@ -1310,13 +1310,13 @@ static BOOL pipe_spnego_auth_bind_continue(pipes_struct *p, prs_struct *rpc_in_p Handle an schannel bind auth. *******************************************************************/ -static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, +static bool pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, RPC_HDR_AUTH *pauth_info, prs_struct *pout_auth) { RPC_HDR_AUTH auth_info; RPC_AUTH_SCHANNEL_NEG neg; RPC_AUTH_VERIFIER auth_verifier; - BOOL ret; + bool ret; struct dcinfo *pdcinfo; uint32 flags; @@ -1410,7 +1410,7 @@ static BOOL pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, Handle an NTLMSSP bind auth. *******************************************************************/ -static BOOL pipe_ntlmssp_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, +static bool pipe_ntlmssp_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, RPC_HDR_AUTH *pauth_info, prs_struct *pout_auth) { RPC_HDR_AUTH auth_info; @@ -1491,7 +1491,7 @@ static BOOL pipe_ntlmssp_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, Respond to a pipe bind request. *******************************************************************/ -BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) +bool api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) { RPC_HDR_BA hdr_ba; RPC_HDR_RB hdr_rb; @@ -1771,7 +1771,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) SPNEGO calls. ****************************************************************************/ -BOOL api_pipe_alter_context(pipes_struct *p, prs_struct *rpc_in_p) +bool api_pipe_alter_context(pipes_struct *p, prs_struct *rpc_in_p) { RPC_HDR_BA hdr_ba; RPC_HDR_RB hdr_rb; @@ -1962,7 +1962,7 @@ BOOL api_pipe_alter_context(pipes_struct *p, prs_struct *rpc_in_p) Deal with NTLMSSP sign & seal processing on an RPC request. ****************************************************************************/ -BOOL api_pipe_ntlmssp_auth_process(pipes_struct *p, prs_struct *rpc_in, +bool api_pipe_ntlmssp_auth_process(pipes_struct *p, prs_struct *rpc_in, uint32 *p_ss_padding_len, NTSTATUS *pstatus) { RPC_HDR_AUTH auth_info; @@ -2078,7 +2078,7 @@ BOOL api_pipe_ntlmssp_auth_process(pipes_struct *p, prs_struct *rpc_in, Deal with schannel processing on an RPC request. ****************************************************************************/ -BOOL api_pipe_schannel_process(pipes_struct *p, prs_struct *rpc_in, uint32 *p_ss_padding_len) +bool api_pipe_schannel_process(pipes_struct *p, prs_struct *rpc_in, uint32 *p_ss_padding_len) { uint32 data_len; uint32 auth_len; @@ -2230,10 +2230,10 @@ void free_pipe_rpc_context( PIPE_RPC_FNS *list ) before doing the call. ****************************************************************************/ -BOOL api_pipe_request(pipes_struct *p) +bool api_pipe_request(pipes_struct *p) { - BOOL ret = False; - BOOL changed_user = False; + bool ret = False; + bool changed_user = False; PIPE_RPC_FNS *pipe_fns; if (p->pipe_bound && @@ -2273,7 +2273,7 @@ BOOL api_pipe_request(pipes_struct *p) Calls the underlying RPC function for a named pipe. ********************************************************************/ -BOOL api_rpcTNP(pipes_struct *p, const char *rpc_name, +bool api_rpcTNP(pipes_struct *p, const char *rpc_name, const struct api_struct *api_rpc_cmds, int n_cmds) { int fn_num; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 91814979c5..c3197c3f0d 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -62,9 +62,9 @@ static struct bitmap *bmap; */ static ssize_t read_from_internal_pipe(void *np_conn, char *data, size_t n, - BOOL *is_data_outstanding); + bool *is_data_outstanding); static ssize_t write_to_internal_pipe(void *np_conn, char *data, size_t n); -static BOOL close_internal_rpc_pipe_hnd(void *np_conn); +static bool close_internal_rpc_pipe_hnd(void *np_conn); static void *make_internal_rpc_pipe_p(const char *pipe_name, connection_struct *conn, uint16 vuid); @@ -137,7 +137,7 @@ void init_rpc_pipe_hnd(void) Initialise an outgoing packet. ****************************************************************************/ -static BOOL pipe_init_outgoing_data(pipes_struct *p) +static bool pipe_init_outgoing_data(pipes_struct *p) { output_data *o_data = &p->out_data; @@ -173,7 +173,7 @@ smb_np_struct *open_rpc_pipe_p(const char *pipe_name, int i; smb_np_struct *p, *p_it; static int next_pipe; - BOOL is_spoolss_pipe = False; + bool is_spoolss_pipe = False; DEBUG(4,("Open pipe requested %s (pipes_open=%d)\n", pipe_name, pipes_open)); @@ -540,7 +540,7 @@ static void free_pipe_context(pipes_struct *p) appends the data into the complete stream if the LAST flag is not set. ****************************************************************************/ -static BOOL process_request_pdu(pipes_struct *p, prs_struct *rpc_in_p) +static bool process_request_pdu(pipes_struct *p, prs_struct *rpc_in_p) { uint32 ss_padding_len = 0; size_t data_len = p->hdr.frag_len - RPC_HEADER_LEN - RPC_HDR_REQ_LEN - @@ -629,7 +629,7 @@ static BOOL process_request_pdu(pipes_struct *p, prs_struct *rpc_in_p) } if(p->hdr.flags & RPC_FLG_LAST) { - BOOL ret = False; + bool ret = False; /* * Ok - we finally have a complete RPC stream. * Call the rpc command to process it. @@ -692,7 +692,7 @@ static void process_complete_pdu(pipes_struct *p) prs_struct rpc_in; size_t data_len = p->in_data.pdu_received_len - RPC_HEADER_LEN; char *data_p = (char *)&p->in_data.current_in_pdu[RPC_HEADER_LEN]; - BOOL reply = False; + bool reply = False; if(p->fault_state) { DEBUG(10,("process_complete_pdu: pipe %s in fault state.\n", @@ -984,7 +984,7 @@ static ssize_t write_to_internal_pipe(void *np_conn, char *data, size_t n) ****************************************************************************/ ssize_t read_from_pipe(smb_np_struct *p, char *data, size_t n, - BOOL *is_data_outstanding) + bool *is_data_outstanding) { if (!p || !p->open) { DEBUG(0,("read_from_pipe: pipe not open\n")); @@ -1008,7 +1008,7 @@ ssize_t read_from_pipe(smb_np_struct *p, char *data, size_t n, ****************************************************************************/ static ssize_t read_from_internal_pipe(void *np_conn, char *data, size_t n, - BOOL *is_data_outstanding) + bool *is_data_outstanding) { pipes_struct *p = (pipes_struct*)np_conn; uint32 pdu_remaining = 0; @@ -1102,7 +1102,7 @@ returning %d bytes.\n", p->name, (unsigned int)p->out_data.current_pdu_len, Wait device state on a pipe. Exactly what this is for is unknown... ****************************************************************************/ -BOOL wait_rpc_pipe_hnd_state(smb_np_struct *p, uint16 priority) +bool wait_rpc_pipe_hnd_state(smb_np_struct *p, uint16 priority) { if (p == NULL) { return False; @@ -1127,7 +1127,7 @@ BOOL wait_rpc_pipe_hnd_state(smb_np_struct *p, uint16 priority) Set device state on a pipe. Exactly what this is for is unknown... ****************************************************************************/ -BOOL set_rpc_pipe_hnd_state(smb_np_struct *p, uint16 device_state) +bool set_rpc_pipe_hnd_state(smb_np_struct *p, uint16 device_state) { if (p == NULL) { return False; @@ -1152,7 +1152,7 @@ BOOL set_rpc_pipe_hnd_state(smb_np_struct *p, uint16 device_state) Close an rpc pipe. ****************************************************************************/ -BOOL close_rpc_pipe_hnd(smb_np_struct *p) +bool close_rpc_pipe_hnd(smb_np_struct *p) { if (!p) { DEBUG(0,("Invalid pipe in close_rpc_pipe_hnd\n")); @@ -1204,7 +1204,7 @@ void pipe_close_conn(connection_struct *conn) Close an rpc pipe. ****************************************************************************/ -static BOOL close_internal_rpc_pipe_hnd(void *np_conn) +static bool close_internal_rpc_pipe_hnd(void *np_conn) { pipes_struct *p = (pipes_struct *)np_conn; if (!p) { diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index bdc082f647..a1deac083d 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -39,7 +39,7 @@ api_samr_close_hnd ********************************************************************/ -static BOOL api_samr_close_hnd(pipes_struct *p) +static bool api_samr_close_hnd(pipes_struct *p) { SAMR_Q_CLOSE_HND q_u; SAMR_R_CLOSE_HND r_u; @@ -69,7 +69,7 @@ static BOOL api_samr_close_hnd(pipes_struct *p) api_samr_open_domain ********************************************************************/ -static BOOL api_samr_open_domain(pipes_struct *p) +static bool api_samr_open_domain(pipes_struct *p) { SAMR_Q_OPEN_DOMAIN q_u; SAMR_R_OPEN_DOMAIN r_u; @@ -100,7 +100,7 @@ static BOOL api_samr_open_domain(pipes_struct *p) api_samr_get_usrdom_pwinfo ********************************************************************/ -static BOOL api_samr_get_usrdom_pwinfo(pipes_struct *p) +static bool api_samr_get_usrdom_pwinfo(pipes_struct *p) { SAMR_Q_GET_USRDOM_PWINFO q_u; SAMR_R_GET_USRDOM_PWINFO r_u; @@ -130,7 +130,7 @@ static BOOL api_samr_get_usrdom_pwinfo(pipes_struct *p) api_samr_set_sec_obj ********************************************************************/ -static BOOL api_samr_set_sec_obj(pipes_struct *p) +static bool api_samr_set_sec_obj(pipes_struct *p) { SAMR_Q_SET_SEC_OBJ q_u; SAMR_R_SET_SEC_OBJ r_u; @@ -160,7 +160,7 @@ static BOOL api_samr_set_sec_obj(pipes_struct *p) api_samr_query_sec_obj ********************************************************************/ -static BOOL api_samr_query_sec_obj(pipes_struct *p) +static bool api_samr_query_sec_obj(pipes_struct *p) { SAMR_Q_QUERY_SEC_OBJ q_u; SAMR_R_QUERY_SEC_OBJ r_u; @@ -190,7 +190,7 @@ static BOOL api_samr_query_sec_obj(pipes_struct *p) api_samr_enum_dom_users ********************************************************************/ -static BOOL api_samr_enum_dom_users(pipes_struct *p) +static bool api_samr_enum_dom_users(pipes_struct *p) { SAMR_Q_ENUM_DOM_USERS q_u; SAMR_R_ENUM_DOM_USERS r_u; @@ -221,7 +221,7 @@ static BOOL api_samr_enum_dom_users(pipes_struct *p) api_samr_enum_dom_groups ********************************************************************/ -static BOOL api_samr_enum_dom_groups(pipes_struct *p) +static bool api_samr_enum_dom_groups(pipes_struct *p) { SAMR_Q_ENUM_DOM_GROUPS q_u; SAMR_R_ENUM_DOM_GROUPS r_u; @@ -252,7 +252,7 @@ static BOOL api_samr_enum_dom_groups(pipes_struct *p) api_samr_enum_dom_aliases ********************************************************************/ -static BOOL api_samr_enum_dom_aliases(pipes_struct *p) +static bool api_samr_enum_dom_aliases(pipes_struct *p) { SAMR_Q_ENUM_DOM_ALIASES q_u; SAMR_R_ENUM_DOM_ALIASES r_u; @@ -283,7 +283,7 @@ static BOOL api_samr_enum_dom_aliases(pipes_struct *p) api_samr_query_dispinfo ********************************************************************/ -static BOOL api_samr_query_dispinfo(pipes_struct *p) +static bool api_samr_query_dispinfo(pipes_struct *p) { SAMR_Q_QUERY_DISPINFO q_u; SAMR_R_QUERY_DISPINFO r_u; @@ -313,7 +313,7 @@ static BOOL api_samr_query_dispinfo(pipes_struct *p) api_samr_query_aliasinfo ********************************************************************/ -static BOOL api_samr_query_aliasinfo(pipes_struct *p) +static bool api_samr_query_aliasinfo(pipes_struct *p) { SAMR_Q_QUERY_ALIASINFO q_u; SAMR_R_QUERY_ALIASINFO r_u; @@ -344,7 +344,7 @@ static BOOL api_samr_query_aliasinfo(pipes_struct *p) api_samr_lookup_names ********************************************************************/ -static BOOL api_samr_lookup_names(pipes_struct *p) +static bool api_samr_lookup_names(pipes_struct *p) { SAMR_Q_LOOKUP_NAMES q_u; SAMR_R_LOOKUP_NAMES r_u; @@ -375,7 +375,7 @@ static BOOL api_samr_lookup_names(pipes_struct *p) api_samr_chgpasswd_user ********************************************************************/ -static BOOL api_samr_chgpasswd_user(pipes_struct *p) +static bool api_samr_chgpasswd_user(pipes_struct *p) { SAMR_Q_CHGPASSWD_USER q_u; SAMR_R_CHGPASSWD_USER r_u; @@ -406,7 +406,7 @@ static BOOL api_samr_chgpasswd_user(pipes_struct *p) api_samr_lookup_rids ********************************************************************/ -static BOOL api_samr_lookup_rids(pipes_struct *p) +static bool api_samr_lookup_rids(pipes_struct *p) { SAMR_Q_LOOKUP_RIDS q_u; SAMR_R_LOOKUP_RIDS r_u; @@ -437,7 +437,7 @@ static BOOL api_samr_lookup_rids(pipes_struct *p) api_samr_open_user ********************************************************************/ -static BOOL api_samr_open_user(pipes_struct *p) +static bool api_samr_open_user(pipes_struct *p) { SAMR_Q_OPEN_USER q_u; SAMR_R_OPEN_USER r_u; @@ -467,7 +467,7 @@ static BOOL api_samr_open_user(pipes_struct *p) api_samr_query_userinfo ********************************************************************/ -static BOOL api_samr_query_userinfo(pipes_struct *p) +static bool api_samr_query_userinfo(pipes_struct *p) { SAMR_Q_QUERY_USERINFO q_u; SAMR_R_QUERY_USERINFO r_u; @@ -497,7 +497,7 @@ static BOOL api_samr_query_userinfo(pipes_struct *p) api_samr_query_usergroups ********************************************************************/ -static BOOL api_samr_query_usergroups(pipes_struct *p) +static bool api_samr_query_usergroups(pipes_struct *p) { SAMR_Q_QUERY_USERGROUPS q_u; SAMR_R_QUERY_USERGROUPS r_u; @@ -527,7 +527,7 @@ static BOOL api_samr_query_usergroups(pipes_struct *p) api_samr_query_domain_info ********************************************************************/ -static BOOL api_samr_query_domain_info(pipes_struct *p) +static bool api_samr_query_domain_info(pipes_struct *p) { SAMR_Q_QUERY_DOMAIN_INFO q_u; SAMR_R_QUERY_DOMAIN_INFO r_u; @@ -557,7 +557,7 @@ static BOOL api_samr_query_domain_info(pipes_struct *p) api_samr_create_user ********************************************************************/ -static BOOL api_samr_create_user(pipes_struct *p) +static bool api_samr_create_user(pipes_struct *p) { prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -589,7 +589,7 @@ static BOOL api_samr_create_user(pipes_struct *p) api_samr_connect_anon ********************************************************************/ -static BOOL api_samr_connect_anon(pipes_struct *p) +static bool api_samr_connect_anon(pipes_struct *p) { SAMR_Q_CONNECT_ANON q_u; SAMR_R_CONNECT_ANON r_u; @@ -620,7 +620,7 @@ static BOOL api_samr_connect_anon(pipes_struct *p) api_samr_connect ********************************************************************/ -static BOOL api_samr_connect(pipes_struct *p) +static bool api_samr_connect(pipes_struct *p) { SAMR_Q_CONNECT q_u; SAMR_R_CONNECT r_u; @@ -651,7 +651,7 @@ static BOOL api_samr_connect(pipes_struct *p) api_samr_connect4 ********************************************************************/ -static BOOL api_samr_connect4(pipes_struct *p) +static bool api_samr_connect4(pipes_struct *p) { SAMR_Q_CONNECT4 q_u; SAMR_R_CONNECT4 r_u; @@ -682,7 +682,7 @@ static BOOL api_samr_connect4(pipes_struct *p) api_samr_chgpasswd_user3 ********************************************************************/ -static BOOL api_samr_chgpasswd_user3(pipes_struct *p) +static bool api_samr_chgpasswd_user3(pipes_struct *p) { SAMR_Q_CHGPASSWD_USER3 q_u; SAMR_R_CHGPASSWD_USER3 r_u; @@ -713,7 +713,7 @@ static BOOL api_samr_chgpasswd_user3(pipes_struct *p) api_samr_connect5 ********************************************************************/ -static BOOL api_samr_connect5(pipes_struct *p) +static bool api_samr_connect5(pipes_struct *p) { SAMR_Q_CONNECT5 q_u; SAMR_R_CONNECT5 r_u; @@ -744,7 +744,7 @@ static BOOL api_samr_connect5(pipes_struct *p) api_samr_lookup_domain **********************************************************************/ -static BOOL api_samr_lookup_domain(pipes_struct *p) +static bool api_samr_lookup_domain(pipes_struct *p) { SAMR_Q_LOOKUP_DOMAIN q_u; SAMR_R_LOOKUP_DOMAIN r_u; @@ -773,7 +773,7 @@ static BOOL api_samr_lookup_domain(pipes_struct *p) api_samr_enum_domains **********************************************************************/ -static BOOL api_samr_enum_domains(pipes_struct *p) +static bool api_samr_enum_domains(pipes_struct *p) { SAMR_Q_ENUM_DOMAINS q_u; SAMR_R_ENUM_DOMAINS r_u; @@ -802,7 +802,7 @@ static BOOL api_samr_enum_domains(pipes_struct *p) api_samr_open_alias ********************************************************************/ -static BOOL api_samr_open_alias(pipes_struct *p) +static bool api_samr_open_alias(pipes_struct *p) { SAMR_Q_OPEN_ALIAS q_u; SAMR_R_OPEN_ALIAS r_u; @@ -833,7 +833,7 @@ static BOOL api_samr_open_alias(pipes_struct *p) api_samr_set_userinfo ********************************************************************/ -static BOOL api_samr_set_userinfo(pipes_struct *p) +static bool api_samr_set_userinfo(pipes_struct *p) { SAMR_Q_SET_USERINFO q_u; SAMR_R_SET_USERINFO r_u; @@ -868,7 +868,7 @@ static BOOL api_samr_set_userinfo(pipes_struct *p) api_samr_set_userinfo2 ********************************************************************/ -static BOOL api_samr_set_userinfo2(pipes_struct *p) +static bool api_samr_set_userinfo2(pipes_struct *p) { SAMR_Q_SET_USERINFO2 q_u; SAMR_R_SET_USERINFO2 r_u; @@ -898,7 +898,7 @@ static BOOL api_samr_set_userinfo2(pipes_struct *p) api_samr_query_useraliases ********************************************************************/ -static BOOL api_samr_query_useraliases(pipes_struct *p) +static bool api_samr_query_useraliases(pipes_struct *p) { SAMR_Q_QUERY_USERALIASES q_u; SAMR_R_QUERY_USERALIASES r_u; @@ -928,7 +928,7 @@ static BOOL api_samr_query_useraliases(pipes_struct *p) api_samr_query_aliasmem ********************************************************************/ -static BOOL api_samr_query_aliasmem(pipes_struct *p) +static bool api_samr_query_aliasmem(pipes_struct *p) { SAMR_Q_QUERY_ALIASMEM q_u; SAMR_R_QUERY_ALIASMEM r_u; @@ -958,7 +958,7 @@ static BOOL api_samr_query_aliasmem(pipes_struct *p) api_samr_query_groupmem ********************************************************************/ -static BOOL api_samr_query_groupmem(pipes_struct *p) +static bool api_samr_query_groupmem(pipes_struct *p) { SAMR_Q_QUERY_GROUPMEM q_u; SAMR_R_QUERY_GROUPMEM r_u; @@ -988,7 +988,7 @@ static BOOL api_samr_query_groupmem(pipes_struct *p) api_samr_add_aliasmem ********************************************************************/ -static BOOL api_samr_add_aliasmem(pipes_struct *p) +static bool api_samr_add_aliasmem(pipes_struct *p) { SAMR_Q_ADD_ALIASMEM q_u; SAMR_R_ADD_ALIASMEM r_u; @@ -1018,7 +1018,7 @@ static BOOL api_samr_add_aliasmem(pipes_struct *p) api_samr_del_aliasmem ********************************************************************/ -static BOOL api_samr_del_aliasmem(pipes_struct *p) +static bool api_samr_del_aliasmem(pipes_struct *p) { SAMR_Q_DEL_ALIASMEM q_u; SAMR_R_DEL_ALIASMEM r_u; @@ -1048,7 +1048,7 @@ static BOOL api_samr_del_aliasmem(pipes_struct *p) api_samr_add_groupmem ********************************************************************/ -static BOOL api_samr_add_groupmem(pipes_struct *p) +static bool api_samr_add_groupmem(pipes_struct *p) { SAMR_Q_ADD_GROUPMEM q_u; SAMR_R_ADD_GROUPMEM r_u; @@ -1078,7 +1078,7 @@ static BOOL api_samr_add_groupmem(pipes_struct *p) api_samr_del_groupmem ********************************************************************/ -static BOOL api_samr_del_groupmem(pipes_struct *p) +static bool api_samr_del_groupmem(pipes_struct *p) { SAMR_Q_DEL_GROUPMEM q_u; SAMR_R_DEL_GROUPMEM r_u; @@ -1108,7 +1108,7 @@ static BOOL api_samr_del_groupmem(pipes_struct *p) api_samr_delete_dom_user ********************************************************************/ -static BOOL api_samr_delete_dom_user(pipes_struct *p) +static bool api_samr_delete_dom_user(pipes_struct *p) { SAMR_Q_DELETE_DOM_USER q_u; SAMR_R_DELETE_DOM_USER r_u; @@ -1138,7 +1138,7 @@ static BOOL api_samr_delete_dom_user(pipes_struct *p) api_samr_delete_dom_group ********************************************************************/ -static BOOL api_samr_delete_dom_group(pipes_struct *p) +static bool api_samr_delete_dom_group(pipes_struct *p) { SAMR_Q_DELETE_DOM_GROUP q_u; SAMR_R_DELETE_DOM_GROUP r_u; @@ -1168,7 +1168,7 @@ static BOOL api_samr_delete_dom_group(pipes_struct *p) api_samr_delete_dom_alias ********************************************************************/ -static BOOL api_samr_delete_dom_alias(pipes_struct *p) +static bool api_samr_delete_dom_alias(pipes_struct *p) { SAMR_Q_DELETE_DOM_ALIAS q_u; SAMR_R_DELETE_DOM_ALIAS r_u; @@ -1198,7 +1198,7 @@ static BOOL api_samr_delete_dom_alias(pipes_struct *p) api_samr_create_dom_group ********************************************************************/ -static BOOL api_samr_create_dom_group(pipes_struct *p) +static bool api_samr_create_dom_group(pipes_struct *p) { SAMR_Q_CREATE_DOM_GROUP q_u; SAMR_R_CREATE_DOM_GROUP r_u; @@ -1228,7 +1228,7 @@ static BOOL api_samr_create_dom_group(pipes_struct *p) api_samr_create_dom_alias ********************************************************************/ -static BOOL api_samr_create_dom_alias(pipes_struct *p) +static bool api_samr_create_dom_alias(pipes_struct *p) { SAMR_Q_CREATE_DOM_ALIAS q_u; SAMR_R_CREATE_DOM_ALIAS r_u; @@ -1258,7 +1258,7 @@ static BOOL api_samr_create_dom_alias(pipes_struct *p) api_samr_query_groupinfo ********************************************************************/ -static BOOL api_samr_query_groupinfo(pipes_struct *p) +static bool api_samr_query_groupinfo(pipes_struct *p) { SAMR_Q_QUERY_GROUPINFO q_u; SAMR_R_QUERY_GROUPINFO r_u; @@ -1288,7 +1288,7 @@ static BOOL api_samr_query_groupinfo(pipes_struct *p) api_samr_set_groupinfo ********************************************************************/ -static BOOL api_samr_set_groupinfo(pipes_struct *p) +static bool api_samr_set_groupinfo(pipes_struct *p) { SAMR_Q_SET_GROUPINFO q_u; SAMR_R_SET_GROUPINFO r_u; @@ -1318,7 +1318,7 @@ static BOOL api_samr_set_groupinfo(pipes_struct *p) api_samr_set_aliasinfo ********************************************************************/ -static BOOL api_samr_set_aliasinfo(pipes_struct *p) +static bool api_samr_set_aliasinfo(pipes_struct *p) { SAMR_Q_SET_ALIASINFO q_u; SAMR_R_SET_ALIASINFO r_u; @@ -1348,7 +1348,7 @@ static BOOL api_samr_set_aliasinfo(pipes_struct *p) api_samr_get_dom_pwinfo ********************************************************************/ -static BOOL api_samr_get_dom_pwinfo(pipes_struct *p) +static bool api_samr_get_dom_pwinfo(pipes_struct *p) { SAMR_Q_GET_DOM_PWINFO q_u; SAMR_R_GET_DOM_PWINFO r_u; @@ -1378,7 +1378,7 @@ static BOOL api_samr_get_dom_pwinfo(pipes_struct *p) api_samr_open_group ********************************************************************/ -static BOOL api_samr_open_group(pipes_struct *p) +static bool api_samr_open_group(pipes_struct *p) { SAMR_Q_OPEN_GROUP q_u; SAMR_R_OPEN_GROUP r_u; @@ -1408,7 +1408,7 @@ static BOOL api_samr_open_group(pipes_struct *p) api_samr_remove_sid_foreign_domain ********************************************************************/ -static BOOL api_samr_remove_sid_foreign_domain(pipes_struct *p) +static bool api_samr_remove_sid_foreign_domain(pipes_struct *p) { SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN q_u; SAMR_R_REMOVE_SID_FOREIGN_DOMAIN r_u; @@ -1438,7 +1438,7 @@ static BOOL api_samr_remove_sid_foreign_domain(pipes_struct *p) api_samr_query_dom_info2 ********************************************************************/ -static BOOL api_samr_query_domain_info2(pipes_struct *p) +static bool api_samr_query_domain_info2(pipes_struct *p) { SAMR_Q_QUERY_DOMAIN_INFO2 q_u; SAMR_R_QUERY_DOMAIN_INFO2 r_u; @@ -1468,7 +1468,7 @@ static BOOL api_samr_query_domain_info2(pipes_struct *p) api_samr_set_dom_info ********************************************************************/ -static BOOL api_samr_set_dom_info(pipes_struct *p) +static bool api_samr_set_dom_info(pipes_struct *p) { SAMR_Q_SET_DOMAIN_INFO q_u; SAMR_R_SET_DOMAIN_INFO r_u; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index bec288730a..9aabaf08ca 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -46,7 +46,7 @@ typedef struct disp_info { DOM_SID sid; /* identify which domain this is. */ - BOOL builtin_domain; /* Quick flag to check if this is the builtin domain. */ + bool builtin_domain; /* Quick flag to check if this is the builtin domain. */ struct pdb_search *users; /* querydispinfo 1 and 4 */ struct pdb_search *machines; /* querydispinfo 2 */ struct pdb_search *groups; /* querydispinfo 3 and 5, enumgroups */ @@ -65,7 +65,7 @@ typedef struct disp_info { struct samr_info { /* for use by the \PIPE\samr policy */ DOM_SID sid; - BOOL builtin_domain; /* Quick flag to check if this is the builtin domain. */ + bool builtin_domain; /* Quick flag to check if this is the builtin domain. */ uint32 status; /* some sort of flag. best to record it. comes from opnum 0x39 */ uint32 acc_granted; DISP_INFO *disp_info; @@ -651,7 +651,7 @@ NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, /******************************************************************* ********************************************************************/ -static BOOL get_lsa_policy_samr_sid( pipes_struct *p, POLICY_HND *pol, +static bool get_lsa_policy_samr_sid( pipes_struct *p, POLICY_HND *pol, DOM_SID *sid, uint32 *acc_granted, DISP_INFO **ppdisp_info) { @@ -682,7 +682,7 @@ NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_ DOM_SID pol_sid; uint32 acc_granted, i; SEC_ACL *dacl; - BOOL ret; + bool ret; struct samu *sampass=NULL; NTSTATUS status; @@ -738,10 +738,10 @@ NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_ /******************************************************************* build correct perms based on policies and password times for _samr_query_sec_obj *******************************************************************/ -static BOOL check_change_pw_access(TALLOC_CTX *mem_ctx, DOM_SID *user_sid) +static bool check_change_pw_access(TALLOC_CTX *mem_ctx, DOM_SID *user_sid) { struct samu *sampass=NULL; - BOOL ret; + bool ret; if ( !(sampass = samu_new( mem_ctx )) ) { DEBUG(0,("No memory!\n")); @@ -1663,7 +1663,7 @@ NTSTATUS _samr_chgpasswd_user3(pipes_struct *p, SAMR_Q_CHGPASSWD_USER3 *q_u, SAM makes a SAMR_R_LOOKUP_RIDS structure. ********************************************************************/ -static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, +static bool make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, const char **names, UNIHDR **pp_hdr_name, UNISTR2 **pp_uni_name) { @@ -1779,7 +1779,7 @@ NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USE uint32 acc_granted; uint32 des_access = q_u->access_mask; size_t sd_size; - BOOL ret; + bool ret; NTSTATUS nt_status; SE_PRIV se_rights; @@ -1850,7 +1850,7 @@ NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USE static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_SID *user_sid) { struct samu *smbpass=NULL; - BOOL ret; + bool ret; if ( !(smbpass = samu_new( mem_ctx )) ) { return NT_STATUS_NO_MEMORY; @@ -1881,7 +1881,7 @@ static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_S static NTSTATUS get_user_info_9(TALLOC_CTX *mem_ctx, SAM_USER_INFO_9 * id9, DOM_SID *user_sid) { struct samu *smbpass=NULL; - BOOL ret; + bool ret; if ( !(smbpass = samu_new( mem_ctx )) ) { return NT_STATUS_NO_MEMORY; @@ -1913,7 +1913,7 @@ static NTSTATUS get_user_info_9(TALLOC_CTX *mem_ctx, SAM_USER_INFO_9 * id9, DOM_ static NTSTATUS get_user_info_16(TALLOC_CTX *mem_ctx, SAM_USER_INFO_16 *id16, DOM_SID *user_sid) { struct samu *smbpass=NULL; - BOOL ret; + bool ret; if ( !(smbpass = samu_new( mem_ctx )) ) { return NT_STATUS_NO_MEMORY; @@ -1947,7 +1947,7 @@ static NTSTATUS get_user_info_16(TALLOC_CTX *mem_ctx, SAM_USER_INFO_16 *id16, DO static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_INFO_18 * id18, DOM_SID *user_sid) { struct samu *smbpass=NULL; - BOOL ret; + bool ret; if (p->auth.auth_type != PIPE_AUTH_TYPE_NTLMSSP || p->auth.auth_type != PIPE_AUTH_TYPE_SPNEGO_NTLMSSP) { return NT_STATUS_ACCESS_DENIED; @@ -1995,7 +1995,7 @@ static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, SAM_USER_INFO_20 *id20, DOM_SID *user_sid) { struct samu *sampass=NULL; - BOOL ret; + bool ret; if ( !(sampass = samu_new( mem_ctx )) ) { return NT_STATUS_NO_MEMORY; @@ -2030,7 +2030,7 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, DOM_SID *user_sid, DOM_SID *domain_sid) { struct samu *sampass=NULL; - BOOL ret; + bool ret; NTSTATUS nt_status; if ( !(sampass = samu_new( mem_ctx )) ) { @@ -2174,9 +2174,9 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S gid_t *unix_gids; size_t i, num_gids; uint32 acc_granted; - BOOL ret; + bool ret; NTSTATUS result; - BOOL success = False; + bool success = False; /* * from the SID in the request: @@ -2486,7 +2486,7 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, static NTSTATUS can_create(TALLOC_CTX *mem_ctx, const char *new_name) { enum lsa_SidType type; - BOOL result; + bool result; DEBUG(10, ("Checking whether [%s] can be created\n", new_name)); @@ -2537,7 +2537,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, size_t sd_size; /* check this, when giving away 'add computer to domain' privs */ uint32 des_access = GENERIC_RIGHTS_USER_ALL_ACCESS; - BOOL can_add_account = False; + bool can_add_account = False; SE_PRIV se_rights; DISP_INFO *disp_info = NULL; @@ -2908,7 +2908,7 @@ NTSTATUS _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_ makes a SAMR_R_ENUM_DOMAINS structure. ********************************************************************/ -static BOOL make_enum_domains(TALLOC_CTX *ctx, SAM_ENTRY **pp_sam, +static bool make_enum_domains(TALLOC_CTX *ctx, SAM_ENTRY **pp_sam, UNISTR2 **pp_uni_name, uint32 num_sam_entries, fstring doms[]) { uint32 i; @@ -3028,7 +3028,7 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A { /* Check we actually have the requested alias */ enum lsa_SidType type; - BOOL result; + bool result; gid_t gid; become_root(); @@ -3105,7 +3105,7 @@ static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx, set_user_info_16 ********************************************************************/ -static BOOL set_user_info_16(const SAM_USER_INFO_16 *id16, struct samu *pwd) +static bool set_user_info_16(const SAM_USER_INFO_16 *id16, struct samu *pwd) { if (id16 == NULL) { DEBUG(5, ("set_user_info_16: NULL id16\n")); @@ -3133,7 +3133,7 @@ static BOOL set_user_info_16(const SAM_USER_INFO_16 *id16, struct samu *pwd) set_user_info_18 ********************************************************************/ -static BOOL set_user_info_18(SAM_USER_INFO_18 *id18, struct samu *pwd) +static bool set_user_info_18(SAM_USER_INFO_18 *id18, struct samu *pwd) { if (id18 == NULL) { @@ -3168,7 +3168,7 @@ static BOOL set_user_info_18(SAM_USER_INFO_18 *id18, struct samu *pwd) set_user_info_20 ********************************************************************/ -static BOOL set_user_info_20(SAM_USER_INFO_20 *id20, struct samu *pwd) +static bool set_user_info_20(SAM_USER_INFO_20 *id20, struct samu *pwd) { if (id20 == NULL) { DEBUG(5, ("set_user_info_20: NULL id20\n")); @@ -3351,7 +3351,7 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, set_user_info_pw ********************************************************************/ -static BOOL set_user_info_pw(uint8 *pass, struct samu *pwd) +static bool set_user_info_pw(uint8 *pass, struct samu *pwd) { uint32 len; pstring plaintext_buf; @@ -3481,8 +3481,8 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE SAM_USERINFO_CTR *ctr = q_u->ctr; uint32 acc_granted; uint32 acc_required; - BOOL ret; - BOOL has_enough_rights = False; + bool ret; + bool has_enough_rights = False; uint32 acb_info; DISP_INFO *disp_info = NULL; @@ -3651,8 +3651,8 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ uint16 switch_value = q_u->switch_value; uint32 acc_granted; uint32 acc_required; - BOOL ret; - BOOL has_enough_rights = False; + bool ret; + bool has_enough_rights = False; uint32 acb_info; DISP_INFO *disp_info = NULL; @@ -3973,7 +3973,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD DOM_SID alias_sid; uint32 acc_granted; SE_PRIV se_rights; - BOOL can_add_accounts; + bool can_add_accounts; NTSTATUS ret; DISP_INFO *disp_info = NULL; @@ -4018,7 +4018,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE DOM_SID alias_sid; uint32 acc_granted; SE_PRIV se_rights; - BOOL can_add_accounts; + bool can_add_accounts; NTSTATUS ret; DISP_INFO *disp_info = NULL; @@ -4065,7 +4065,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD uint32 group_rid; uint32 acc_granted; SE_PRIV se_rights; - BOOL can_add_accounts; + bool can_add_accounts; DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ @@ -4113,7 +4113,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE uint32 group_rid; uint32 acc_granted; SE_PRIV se_rights; - BOOL can_add_accounts; + bool can_add_accounts; DISP_INFO *disp_info = NULL; /* @@ -4164,10 +4164,10 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM DOM_SID user_sid; struct samu *sam_pass=NULL; uint32 acc_granted; - BOOL can_add_accounts; + bool can_add_accounts; uint32 acb_info; DISP_INFO *disp_info = NULL; - BOOL ret; + bool ret; DEBUG(5, ("_samr_delete_dom_user: %d\n", __LINE__)); @@ -4248,7 +4248,7 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S uint32 group_rid; uint32 acc_granted; SE_PRIV se_rights; - BOOL can_add_accounts; + bool can_add_accounts; DISP_INFO *disp_info = NULL; DEBUG(5, ("samr_delete_dom_group: %d\n", __LINE__)); @@ -4308,7 +4308,7 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S DOM_SID alias_sid; uint32 acc_granted; SE_PRIV se_rights; - BOOL can_add_accounts; + bool can_add_accounts; NTSTATUS status; DISP_INFO *disp_info = NULL; @@ -4378,7 +4378,7 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S struct samr_info *info; uint32 acc_granted; SE_PRIV se_rights; - BOOL can_add_accounts; + bool can_add_accounts; DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ @@ -4456,7 +4456,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S gid_t gid; NTSTATUS result; SE_PRIV se_rights; - BOOL can_add_accounts; + bool can_add_accounts; DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ @@ -4543,7 +4543,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM GROUP_MAP map; GROUP_INFO_CTR *ctr; uint32 acc_granted; - BOOL ret; + bool ret; if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; @@ -4638,8 +4638,8 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ GROUP_INFO_CTR *ctr; uint32 acc_granted; NTSTATUS ret; - BOOL result; - BOOL can_mod_accounts; + bool result; + bool can_mod_accounts; DISP_INFO *disp_info = NULL; if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, &disp_info)) @@ -4701,7 +4701,7 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ struct acct_info info; ALIAS_INFO_CTR *ctr; uint32 acc_granted; - BOOL can_mod_accounts; + bool can_mod_accounts; NTSTATUS status; DISP_INFO *disp_info = NULL; @@ -4832,7 +4832,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G size_t sd_size; NTSTATUS status; fstring sid_string; - BOOL ret; + bool ret; SE_PRIV se_rights; if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid, &acc_granted, NULL)) diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c old mode 100755 new mode 100644 index 32e0c6e4ed..7802fe447e --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -31,7 +31,7 @@ * api_spoolss_open_printer_ex (rarely seen - older call) ********************************************************************/ -static BOOL api_spoolss_open_printer(pipes_struct *p) +static bool api_spoolss_open_printer(pipes_struct *p) { SPOOL_Q_OPEN_PRINTER q_u; SPOOL_R_OPEN_PRINTER r_u; @@ -61,7 +61,7 @@ static BOOL api_spoolss_open_printer(pipes_struct *p) * api_spoolss_open_printer_ex ********************************************************************/ -static BOOL api_spoolss_open_printer_ex(pipes_struct *p) +static bool api_spoolss_open_printer_ex(pipes_struct *p) { SPOOL_Q_OPEN_PRINTER_EX q_u; SPOOL_R_OPEN_PRINTER_EX r_u; @@ -92,7 +92,7 @@ static BOOL api_spoolss_open_printer_ex(pipes_struct *p) * called from the spoolss dispatcher ********************************************************************/ -static BOOL api_spoolss_getprinterdata(pipes_struct *p) +static bool api_spoolss_getprinterdata(pipes_struct *p) { SPOOL_Q_GETPRINTERDATA q_u; SPOOL_R_GETPRINTERDATA r_u; @@ -124,7 +124,7 @@ static BOOL api_spoolss_getprinterdata(pipes_struct *p) * called from the spoolss dispatcher ********************************************************************/ -static BOOL api_spoolss_deleteprinterdata(pipes_struct *p) +static bool api_spoolss_deleteprinterdata(pipes_struct *p) { SPOOL_Q_DELETEPRINTERDATA q_u; SPOOL_R_DELETEPRINTERDATA r_u; @@ -156,7 +156,7 @@ static BOOL api_spoolss_deleteprinterdata(pipes_struct *p) * called from the spoolss dispatcher ********************************************************************/ -static BOOL api_spoolss_closeprinter(pipes_struct *p) +static bool api_spoolss_closeprinter(pipes_struct *p) { SPOOL_Q_CLOSEPRINTER q_u; SPOOL_R_CLOSEPRINTER r_u; @@ -187,7 +187,7 @@ static BOOL api_spoolss_closeprinter(pipes_struct *p) * called from the spoolss dispatcher ********************************************************************/ -static BOOL api_spoolss_abortprinter(pipes_struct *p) +static bool api_spoolss_abortprinter(pipes_struct *p) { SPOOL_Q_ABORTPRINTER q_u; SPOOL_R_ABORTPRINTER r_u; @@ -218,7 +218,7 @@ static BOOL api_spoolss_abortprinter(pipes_struct *p) * called from the spoolss dispatcher ********************************************************************/ -static BOOL api_spoolss_deleteprinter(pipes_struct *p) +static bool api_spoolss_deleteprinter(pipes_struct *p) { SPOOL_Q_DELETEPRINTER q_u; SPOOL_R_DELETEPRINTER r_u; @@ -250,7 +250,7 @@ static BOOL api_spoolss_deleteprinter(pipes_struct *p) * called from the spoolss dispatcher ********************************************************************/ -static BOOL api_spoolss_deleteprinterdriver(pipes_struct *p) +static bool api_spoolss_deleteprinterdriver(pipes_struct *p) { SPOOL_Q_DELETEPRINTERDRIVER q_u; SPOOL_R_DELETEPRINTERDRIVER r_u; @@ -281,7 +281,7 @@ static BOOL api_spoolss_deleteprinterdriver(pipes_struct *p) * ReplyFindFirstPrinterChangeNotifyEx ********************************************************************/ -static BOOL api_spoolss_rffpcnex(pipes_struct *p) +static bool api_spoolss_rffpcnex(pipes_struct *p) { SPOOL_Q_RFFPCNEX q_u; SPOOL_R_RFFPCNEX r_u; @@ -318,7 +318,7 @@ static BOOL api_spoolss_rffpcnex(pipes_struct *p) * JRA. ********************************************************************/ -static BOOL api_spoolss_rfnpcnex(pipes_struct *p) +static bool api_spoolss_rfnpcnex(pipes_struct *p) { SPOOL_Q_RFNPCNEX q_u; SPOOL_R_RFNPCNEX r_u; @@ -353,7 +353,7 @@ static BOOL api_spoolss_rfnpcnex(pipes_struct *p) * ********************************************************************/ -static BOOL api_spoolss_enumprinters(pipes_struct *p) +static bool api_spoolss_enumprinters(pipes_struct *p) { SPOOL_Q_ENUMPRINTERS q_u; SPOOL_R_ENUMPRINTERS r_u; @@ -384,7 +384,7 @@ static BOOL api_spoolss_enumprinters(pipes_struct *p) * ********************************************************************/ -static BOOL api_spoolss_getprinter(pipes_struct *p) +static bool api_spoolss_getprinter(pipes_struct *p) { SPOOL_Q_GETPRINTER q_u; SPOOL_R_GETPRINTER r_u; @@ -415,7 +415,7 @@ static BOOL api_spoolss_getprinter(pipes_struct *p) * ********************************************************************/ -static BOOL api_spoolss_getprinterdriver2(pipes_struct *p) +static bool api_spoolss_getprinterdriver2(pipes_struct *p) { SPOOL_Q_GETPRINTERDRIVER2 q_u; SPOOL_R_GETPRINTERDRIVER2 r_u; @@ -446,7 +446,7 @@ static BOOL api_spoolss_getprinterdriver2(pipes_struct *p) * ********************************************************************/ -static BOOL api_spoolss_startpageprinter(pipes_struct *p) +static bool api_spoolss_startpageprinter(pipes_struct *p) { SPOOL_Q_STARTPAGEPRINTER q_u; SPOOL_R_STARTPAGEPRINTER r_u; @@ -477,7 +477,7 @@ static BOOL api_spoolss_startpageprinter(pipes_struct *p) * ********************************************************************/ -static BOOL api_spoolss_endpageprinter(pipes_struct *p) +static bool api_spoolss_endpageprinter(pipes_struct *p) { SPOOL_Q_ENDPAGEPRINTER q_u; SPOOL_R_ENDPAGEPRINTER r_u; @@ -505,7 +505,7 @@ static BOOL api_spoolss_endpageprinter(pipes_struct *p) /******************************************************************** ********************************************************************/ -static BOOL api_spoolss_startdocprinter(pipes_struct *p) +static bool api_spoolss_startdocprinter(pipes_struct *p) { SPOOL_Q_STARTDOCPRINTER q_u; SPOOL_R_STARTDOCPRINTER r_u; @@ -533,7 +533,7 @@ static BOOL api_spoolss_startdocprinter(pipes_struct *p) /******************************************************************** ********************************************************************/ -static BOOL api_spoolss_enddocprinter(pipes_struct *p) +static bool api_spoolss_enddocprinter(pipes_struct *p) { SPOOL_Q_ENDDOCPRINTER q_u; SPOOL_R_ENDDOCPRINTER r_u; @@ -561,7 +561,7 @@ static BOOL api_spoolss_enddocprinter(pipes_struct *p) /******************************************************************** ********************************************************************/ -static BOOL api_spoolss_writeprinter(pipes_struct *p) +static bool api_spoolss_writeprinter(pipes_struct *p) { SPOOL_Q_WRITEPRINTER q_u; SPOOL_R_WRITEPRINTER r_u; @@ -590,7 +590,7 @@ static BOOL api_spoolss_writeprinter(pipes_struct *p) ****************************************************************************/ -static BOOL api_spoolss_setprinter(pipes_struct *p) +static bool api_spoolss_setprinter(pipes_struct *p) { SPOOL_Q_SETPRINTER q_u; SPOOL_R_SETPRINTER r_u; @@ -618,7 +618,7 @@ static BOOL api_spoolss_setprinter(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_fcpn(pipes_struct *p) +static bool api_spoolss_fcpn(pipes_struct *p) { SPOOL_Q_FCPN q_u; SPOOL_R_FCPN r_u; @@ -646,7 +646,7 @@ static BOOL api_spoolss_fcpn(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addjob(pipes_struct *p) +static bool api_spoolss_addjob(pipes_struct *p) { SPOOL_Q_ADDJOB q_u; SPOOL_R_ADDJOB r_u; @@ -674,7 +674,7 @@ static BOOL api_spoolss_addjob(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumjobs(pipes_struct *p) +static bool api_spoolss_enumjobs(pipes_struct *p) { SPOOL_Q_ENUMJOBS q_u; SPOOL_R_ENUMJOBS r_u; @@ -702,7 +702,7 @@ static BOOL api_spoolss_enumjobs(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_schedulejob(pipes_struct *p) +static bool api_spoolss_schedulejob(pipes_struct *p) { SPOOL_Q_SCHEDULEJOB q_u; SPOOL_R_SCHEDULEJOB r_u; @@ -730,7 +730,7 @@ static BOOL api_spoolss_schedulejob(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_setjob(pipes_struct *p) +static bool api_spoolss_setjob(pipes_struct *p) { SPOOL_Q_SETJOB q_u; SPOOL_R_SETJOB r_u; @@ -758,7 +758,7 @@ static BOOL api_spoolss_setjob(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p) +static bool api_spoolss_enumprinterdrivers(pipes_struct *p) { SPOOL_Q_ENUMPRINTERDRIVERS q_u; SPOOL_R_ENUMPRINTERDRIVERS r_u; @@ -786,7 +786,7 @@ static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_getform(pipes_struct *p) +static bool api_spoolss_getform(pipes_struct *p) { SPOOL_Q_GETFORM q_u; SPOOL_R_GETFORM r_u; @@ -814,7 +814,7 @@ static BOOL api_spoolss_getform(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumforms(pipes_struct *p) +static bool api_spoolss_enumforms(pipes_struct *p) { SPOOL_Q_ENUMFORMS q_u; SPOOL_R_ENUMFORMS r_u; @@ -842,7 +842,7 @@ static BOOL api_spoolss_enumforms(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumports(pipes_struct *p) +static bool api_spoolss_enumports(pipes_struct *p) { SPOOL_Q_ENUMPORTS q_u; SPOOL_R_ENUMPORTS r_u; @@ -870,7 +870,7 @@ static BOOL api_spoolss_enumports(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addprinterex(pipes_struct *p) +static bool api_spoolss_addprinterex(pipes_struct *p) { SPOOL_Q_ADDPRINTEREX q_u; SPOOL_R_ADDPRINTEREX r_u; @@ -898,7 +898,7 @@ static BOOL api_spoolss_addprinterex(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addprinterdriver(pipes_struct *p) +static bool api_spoolss_addprinterdriver(pipes_struct *p) { SPOOL_Q_ADDPRINTERDRIVER q_u; SPOOL_R_ADDPRINTERDRIVER r_u; @@ -935,7 +935,7 @@ static BOOL api_spoolss_addprinterdriver(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_getprinterdriverdirectory(pipes_struct *p) +static bool api_spoolss_getprinterdriverdirectory(pipes_struct *p) { SPOOL_Q_GETPRINTERDRIVERDIR q_u; SPOOL_R_GETPRINTERDRIVERDIR r_u; @@ -963,7 +963,7 @@ static BOOL api_spoolss_getprinterdriverdirectory(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprinterdata(pipes_struct *p) +static bool api_spoolss_enumprinterdata(pipes_struct *p) { SPOOL_Q_ENUMPRINTERDATA q_u; SPOOL_R_ENUMPRINTERDATA r_u; @@ -991,7 +991,7 @@ static BOOL api_spoolss_enumprinterdata(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_setprinterdata(pipes_struct *p) +static bool api_spoolss_setprinterdata(pipes_struct *p) { SPOOL_Q_SETPRINTERDATA q_u; SPOOL_R_SETPRINTERDATA r_u; @@ -1018,7 +1018,7 @@ static BOOL api_spoolss_setprinterdata(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_reset_printer(pipes_struct *p) +static bool api_spoolss_reset_printer(pipes_struct *p) { SPOOL_Q_RESETPRINTER q_u; SPOOL_R_RESETPRINTER r_u; @@ -1045,7 +1045,7 @@ static BOOL api_spoolss_reset_printer(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addform(pipes_struct *p) +static bool api_spoolss_addform(pipes_struct *p) { SPOOL_Q_ADDFORM q_u; SPOOL_R_ADDFORM r_u; @@ -1073,7 +1073,7 @@ static BOOL api_spoolss_addform(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_deleteform(pipes_struct *p) +static bool api_spoolss_deleteform(pipes_struct *p) { SPOOL_Q_DELETEFORM q_u; SPOOL_R_DELETEFORM r_u; @@ -1101,7 +1101,7 @@ static BOOL api_spoolss_deleteform(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_setform(pipes_struct *p) +static bool api_spoolss_setform(pipes_struct *p) { SPOOL_Q_SETFORM q_u; SPOOL_R_SETFORM r_u; @@ -1129,7 +1129,7 @@ static BOOL api_spoolss_setform(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprintprocessors(pipes_struct *p) +static bool api_spoolss_enumprintprocessors(pipes_struct *p) { SPOOL_Q_ENUMPRINTPROCESSORS q_u; SPOOL_R_ENUMPRINTPROCESSORS r_u; @@ -1157,7 +1157,7 @@ static BOOL api_spoolss_enumprintprocessors(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addprintprocessor(pipes_struct *p) +static bool api_spoolss_addprintprocessor(pipes_struct *p) { SPOOL_Q_ADDPRINTPROCESSOR q_u; SPOOL_R_ADDPRINTPROCESSOR r_u; @@ -1189,7 +1189,7 @@ static BOOL api_spoolss_addprintprocessor(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprintprocdatatypes(pipes_struct *p) +static bool api_spoolss_enumprintprocdatatypes(pipes_struct *p) { SPOOL_Q_ENUMPRINTPROCDATATYPES q_u; SPOOL_R_ENUMPRINTPROCDATATYPES r_u; @@ -1217,7 +1217,7 @@ static BOOL api_spoolss_enumprintprocdatatypes(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprintmonitors(pipes_struct *p) +static bool api_spoolss_enumprintmonitors(pipes_struct *p) { SPOOL_Q_ENUMPRINTMONITORS q_u; SPOOL_R_ENUMPRINTMONITORS r_u; @@ -1245,7 +1245,7 @@ static BOOL api_spoolss_enumprintmonitors(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_getjob(pipes_struct *p) +static bool api_spoolss_getjob(pipes_struct *p) { SPOOL_Q_GETJOB q_u; SPOOL_R_GETJOB r_u; @@ -1276,7 +1276,7 @@ static BOOL api_spoolss_getjob(pipes_struct *p) * called from the spoolss dispatcher ********************************************************************/ -static BOOL api_spoolss_getprinterdataex(pipes_struct *p) +static bool api_spoolss_getprinterdataex(pipes_struct *p) { SPOOL_Q_GETPRINTERDATAEX q_u; SPOOL_R_GETPRINTERDATAEX r_u; @@ -1305,7 +1305,7 @@ static BOOL api_spoolss_getprinterdataex(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_setprinterdataex(pipes_struct *p) +static bool api_spoolss_setprinterdataex(pipes_struct *p) { SPOOL_Q_SETPRINTERDATAEX q_u; SPOOL_R_SETPRINTERDATAEX r_u; @@ -1334,7 +1334,7 @@ static BOOL api_spoolss_setprinterdataex(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprinterkey(pipes_struct *p) +static bool api_spoolss_enumprinterkey(pipes_struct *p) { SPOOL_Q_ENUMPRINTERKEY q_u; SPOOL_R_ENUMPRINTERKEY r_u; @@ -1362,7 +1362,7 @@ static BOOL api_spoolss_enumprinterkey(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_enumprinterdataex(pipes_struct *p) +static bool api_spoolss_enumprinterdataex(pipes_struct *p) { SPOOL_Q_ENUMPRINTERDATAEX q_u; SPOOL_R_ENUMPRINTERDATAEX r_u; @@ -1390,7 +1390,7 @@ static BOOL api_spoolss_enumprinterdataex(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_getprintprocessordirectory(pipes_struct *p) +static bool api_spoolss_getprintprocessordirectory(pipes_struct *p) { SPOOL_Q_GETPRINTPROCESSORDIRECTORY q_u; SPOOL_R_GETPRINTPROCESSORDIRECTORY r_u; @@ -1418,7 +1418,7 @@ static BOOL api_spoolss_getprintprocessordirectory(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_deleteprinterdataex(pipes_struct *p) +static bool api_spoolss_deleteprinterdataex(pipes_struct *p) { SPOOL_Q_DELETEPRINTERDATAEX q_u; SPOOL_R_DELETEPRINTERDATAEX r_u; @@ -1446,7 +1446,7 @@ static BOOL api_spoolss_deleteprinterdataex(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_deleteprinterkey(pipes_struct *p) +static bool api_spoolss_deleteprinterkey(pipes_struct *p) { SPOOL_Q_DELETEPRINTERKEY q_u; SPOOL_R_DELETEPRINTERKEY r_u; @@ -1474,7 +1474,7 @@ static BOOL api_spoolss_deleteprinterkey(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_addprinterdriverex(pipes_struct *p) +static bool api_spoolss_addprinterdriverex(pipes_struct *p) { SPOOL_Q_ADDPRINTERDRIVEREX q_u; SPOOL_R_ADDPRINTERDRIVEREX r_u; @@ -1511,7 +1511,7 @@ static BOOL api_spoolss_addprinterdriverex(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_deleteprinterdriverex(pipes_struct *p) +static bool api_spoolss_deleteprinterdriverex(pipes_struct *p) { SPOOL_Q_DELETEPRINTERDRIVEREX q_u; SPOOL_R_DELETEPRINTERDRIVEREX r_u; @@ -1539,7 +1539,7 @@ static BOOL api_spoolss_deleteprinterdriverex(pipes_struct *p) /**************************************************************************** ****************************************************************************/ -static BOOL api_spoolss_xcvdataport(pipes_struct *p) +static bool api_spoolss_xcvdataport(pipes_struct *p) { SPOOL_Q_XCVDATAPORT q_u; SPOOL_R_XCVDATAPORT r_u; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 1bed2bf095..658ed99400 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -267,7 +267,7 @@ static Printer_entry *find_printer_index_by_hnd(pipes_struct *p, POLICY_HND *hnd Close printer index by handle. ****************************************************************************/ -static BOOL close_printer_handle(pipes_struct *p, POLICY_HND *hnd) +static bool close_printer_handle(pipes_struct *p, POLICY_HND *hnd) { Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); @@ -290,7 +290,7 @@ WERROR delete_printer_hook( NT_USER_TOKEN *token, const char *sharename ) pstring command; int ret; SE_PRIV se_printop = SE_PRINT_OPERATOR; - BOOL is_print_op = False; + bool is_print_op = False; /* can't fail if we don't try */ @@ -374,7 +374,7 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) Return the snum of a printer corresponding to an handle. ****************************************************************************/ -static BOOL get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number, +static bool get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number, struct share_params **params) { Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); @@ -401,7 +401,7 @@ static BOOL get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number, Check if it's \\server or \\server\printer ****************************************************************************/ -static BOOL set_printer_hnd_printertype(Printer_entry *Printer, char *handlename) +static bool set_printer_hnd_printertype(Printer_entry *Printer, char *handlename) { DEBUG(3,("Setting printer type=%s\n", handlename)); @@ -431,14 +431,14 @@ static BOOL set_printer_hnd_printertype(Printer_entry *Printer, char *handlename XcvDataPort() interface. ****************************************************************************/ -static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) +static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename) { int snum; int n_services=lp_numservices(); char *aprinter, *printername; const char *servername; fstring sname; - BOOL found=False; + bool found=False; NT_PRINTER_INFO_LEVEL *printer = NULL; WERROR result; @@ -558,7 +558,7 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename) Find first available printer slot. creates a printer handle for you. ****************************************************************************/ -static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint32 access_granted) +static bool open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint32 access_granted) { Printer_entry *new_printer; @@ -607,13 +607,13 @@ static BOOL open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3 given by (notify_type, notify_field). **************************************************************************/ -static BOOL is_monitoring_event_flags(uint32 flags, uint16 notify_type, +static bool is_monitoring_event_flags(uint32 flags, uint16 notify_type, uint16 notify_field) { return True; } -static BOOL is_monitoring_event(Printer_entry *p, uint16 notify_type, +static bool is_monitoring_event(Printer_entry *p, uint16 notify_type, uint16 notify_field) { SPOOL_NOTIFY_OPTION *option = p->notify.option; @@ -1062,7 +1062,7 @@ done: /*********************************************************************** **********************************************************************/ -static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, void *buf, size_t len ) +static bool notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, void *buf, size_t len ) { uint32 tv_sec, tv_usec; @@ -1198,7 +1198,7 @@ static void receive_notify2_message_list(struct messaging_context *msg, driver ********************************************************************/ -static BOOL srv_spoolss_drv_upgrade_printer(char* drivername) +static bool srv_spoolss_drv_upgrade_printer(char* drivername) { int len = strlen(drivername); @@ -1301,7 +1301,7 @@ void update_monitored_printq_cache( void ) driver ********************************************************************/ -static BOOL srv_spoolss_reset_printerdata(char* drivername) +static bool srv_spoolss_reset_printerdata(char* drivername) { int len = strlen(drivername); @@ -1741,10 +1741,10 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /**************************************************************************** ****************************************************************************/ -static BOOL convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni, +static bool convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni, NT_PRINTER_INFO_LEVEL *printer, uint32 level) { - BOOL ret; + bool ret; switch (level) { case 2: @@ -1769,10 +1769,10 @@ static BOOL convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni, return False; } -static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *uni, +static bool convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *uni, NT_PRINTER_DRIVER_INFO_LEVEL *printer, uint32 level) { - BOOL result = True; + bool result = True; switch (level) { case 3: @@ -1792,7 +1792,7 @@ static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *u return result; } -BOOL convert_devicemode(const char *printername, const DEVICEMODE *devmode, +bool convert_devicemode(const char *printername, const DEVICEMODE *devmode, NT_DEVICEMODE **pp_nt_devmode) { NT_DEVICEMODE *nt_devmode = *pp_nt_devmode; @@ -2069,7 +2069,7 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV NT_PRINTER_DRIVER_INFO_LEVEL info_win2k; int version; uint32 flags = q_u->delete_flags; - BOOL delete_files; + bool delete_files; WERROR status; WERROR status_win2k = WERR_ACCESS_DENIED; SE_PRIV se_printop = SE_PRINT_OPERATOR; @@ -2527,7 +2527,7 @@ done: Connect to the client machine. **********************************************************/ -static BOOL spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, +static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, struct in_addr *client_ip, const char *remote_machine) { NTSTATUS ret; @@ -2594,7 +2594,7 @@ static BOOL spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, Connect to the client. ****************************************************************************/ -static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, +static bool srv_spoolss_replyopenprinter(int snum, const char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle, struct in_addr *client_ip) { @@ -3564,7 +3564,7 @@ static uint32 type_of_notify_info_data(uint16 type, uint16 field) /**************************************************************************** ****************************************************************************/ -static BOOL search_notify(uint16 type, uint16 field, int *value) +static bool search_notify(uint16 type, uint16 field, int *value) { int i; @@ -3601,7 +3601,7 @@ void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 * ********************************************************************/ -static BOOL construct_notify_printer_info(Printer_entry *print_hnd, SPOOL_NOTIFY_INFO *info, int +static bool construct_notify_printer_info(Printer_entry *print_hnd, SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id, TALLOC_CTX *mem_ctx) @@ -3660,7 +3660,7 @@ static BOOL construct_notify_printer_info(Printer_entry *print_hnd, SPOOL_NOTIFY * ********************************************************************/ -static BOOL construct_notify_jobs_info(print_queue_struct *queue, +static bool construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, NT_PRINTER_INFO_LEVEL *printer, int snum, SPOOL_NOTIFY_OPTION_TYPE @@ -3946,7 +3946,7 @@ done: * fill a printer_info_0 struct ********************************************************************/ -static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *printer, int snum) +static bool construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *printer, int snum) { pstring chaine; int count; @@ -4051,7 +4051,7 @@ static BOOL construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p * construct_printer_info_1 * fill a printer_info_1 struct ********************************************************************/ -static BOOL construct_printer_info_1(Printer_entry *print_hnd, uint32 flags, PRINTER_INFO_1 *printer, int snum) +static bool construct_printer_info_1(Printer_entry *print_hnd, uint32 flags, PRINTER_INFO_1 *printer, int snum) { pstring chaine; pstring chaine2; @@ -4102,7 +4102,7 @@ static void free_dev_mode(DEVICEMODE *dev) should be valid upon entry ****************************************************************************/ -static BOOL convert_nt_devicemode( DEVICEMODE *devmode, NT_DEVICEMODE *ntdevmode ) +static bool convert_nt_devicemode( DEVICEMODE *devmode, NT_DEVICEMODE *ntdevmode ) { if ( !devmode || !ntdevmode ) return False; @@ -4189,7 +4189,7 @@ done: * fill a printer_info_2 struct ********************************************************************/ -static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *printer, int snum) +static bool construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *printer, int snum) { int count; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; @@ -4254,7 +4254,7 @@ static BOOL construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *p * fill a printer_info_3 struct ********************************************************************/ -static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 **pp_printer, int snum) +static bool construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 **pp_printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; PRINTER_INFO_3 *printer = NULL; @@ -4292,7 +4292,7 @@ static BOOL construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 ** * fill a printer_info_4 struct ********************************************************************/ -static BOOL construct_printer_info_4(Printer_entry *print_hnd, PRINTER_INFO_4 *printer, int snum) +static bool construct_printer_info_4(Printer_entry *print_hnd, PRINTER_INFO_4 *printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; @@ -4312,7 +4312,7 @@ static BOOL construct_printer_info_4(Printer_entry *print_hnd, PRINTER_INFO_4 *p * fill a printer_info_5 struct ********************************************************************/ -static BOOL construct_printer_info_5(Printer_entry *print_hnd, PRINTER_INFO_5 *printer, int snum) +static bool construct_printer_info_5(Printer_entry *print_hnd, PRINTER_INFO_5 *printer, int snum) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; @@ -4338,7 +4338,7 @@ static BOOL construct_printer_info_5(Printer_entry *print_hnd, PRINTER_INFO_5 *p * fill a printer_info_6 struct ********************************************************************/ -static BOOL construct_printer_info_6(Printer_entry *print_hnd, +static bool construct_printer_info_6(Printer_entry *print_hnd, PRINTER_INFO_6 *printer, int snum) { @@ -4364,7 +4364,7 @@ static BOOL construct_printer_info_6(Printer_entry *print_hnd, * fill a printer_info_7 struct ********************************************************************/ -static BOOL construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *printer, int snum) +static bool construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *printer, int snum) { char *guid_str = NULL; struct GUID guid; @@ -6057,7 +6057,7 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, _spoolss_open_printer_ex(). ********************************************************************/ -static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) +static bool check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) { fstring printername; const char *p; @@ -6109,7 +6109,7 @@ WERROR add_port_hook(NT_USER_TOKEN *token, const char *portname, const char *uri int ret; int fd; SE_PRIV se_printop = SE_PRINT_OPERATOR; - BOOL is_print_op = False; + bool is_print_op = False; if ( !*cmd ) { return WERR_ACCESS_DENIED; @@ -6148,7 +6148,7 @@ WERROR add_port_hook(NT_USER_TOKEN *token, const char *portname, const char *uri /**************************************************************************** ****************************************************************************/ -BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) +bool add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) { char *cmd = lp_addprinter_cmd(); char **qlines; @@ -6158,7 +6158,7 @@ BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) int fd; fstring remote_machine = "%m"; SE_PRIV se_printop = SE_PRINT_OPERATOR; - BOOL is_print_op = False; + bool is_print_op = False; standard_sub_basic(current_user_info.smb_name, current_user_info.domain, @@ -6574,7 +6574,7 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, const print_queue_struct *queu /**************************************************************************** ****************************************************************************/ -static BOOL fill_job_info_2(JOB_INFO_2 *job_info, const print_queue_struct *queue, +static bool fill_job_info_2(JOB_INFO_2 *job_info, const print_queue_struct *queue, int position, int snum, const NT_PRINTER_INFO_LEVEL *ntprinter, DEVICEMODE *devmode) @@ -7286,7 +7286,7 @@ WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * nt_forms_struct *list=NULL; nt_forms_struct builtin_form; - BOOL foundBuiltin; + bool foundBuiltin; FORM_1 form_1; fstring form_name; int buffer_size=0; @@ -8843,7 +8843,7 @@ static WERROR getjob_level_1(print_queue_struct **queue, int count, int snum, uint32 *needed) { int i=0; - BOOL found=False; + bool found=False; JOB_INFO_1 *info_1=NULL; WERROR result = WERR_OK; @@ -8895,7 +8895,7 @@ static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, uint32 *needed) { int i = 0; - BOOL found = False; + bool found = False; JOB_INFO_2 *info_2; WERROR result; DEVICEMODE *devmode = NULL; diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 92ed7274cc..25e652c1fd 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -29,7 +29,7 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -static BOOL proxy_srvsvc_call(pipes_struct *p, uint8 opnum) +static bool proxy_srvsvc_call(pipes_struct *p, uint8 opnum) { struct api_struct *fns; int n_fns; @@ -50,7 +50,7 @@ static BOOL proxy_srvsvc_call(pipes_struct *p, uint8 opnum) api_srv_net_srv_get_info ********************************************************************/ -static BOOL api_srv_net_srv_get_info(pipes_struct *p) +static bool api_srv_net_srv_get_info(pipes_struct *p) { SRV_Q_NET_SRV_GET_INFO q_u; SRV_R_NET_SRV_GET_INFO r_u; @@ -77,7 +77,7 @@ static BOOL api_srv_net_srv_get_info(pipes_struct *p) api_srv_net_srv_get_info ********************************************************************/ -static BOOL api_srv_net_srv_set_info(pipes_struct *p) +static bool api_srv_net_srv_set_info(pipes_struct *p) { SRV_Q_NET_SRV_SET_INFO q_u; SRV_R_NET_SRV_SET_INFO r_u; @@ -104,7 +104,7 @@ static BOOL api_srv_net_srv_set_info(pipes_struct *p) api_srv_net_file_enum ********************************************************************/ -static BOOL api_srv_net_file_enum(pipes_struct *p) +static bool api_srv_net_file_enum(pipes_struct *p) { SRV_Q_NET_FILE_ENUM q_u; SRV_R_NET_FILE_ENUM r_u; @@ -131,7 +131,7 @@ static BOOL api_srv_net_file_enum(pipes_struct *p) api_srv_net_conn_enum ********************************************************************/ -static BOOL api_srv_net_conn_enum(pipes_struct *p) +static bool api_srv_net_conn_enum(pipes_struct *p) { SRV_Q_NET_CONN_ENUM q_u; SRV_R_NET_CONN_ENUM r_u; @@ -158,7 +158,7 @@ static BOOL api_srv_net_conn_enum(pipes_struct *p) Enumerate sessions. ********************************************************************/ -static BOOL api_srv_net_sess_enum(pipes_struct *p) +static bool api_srv_net_sess_enum(pipes_struct *p) { SRV_Q_NET_SESS_ENUM q_u; SRV_R_NET_SESS_ENUM r_u; @@ -186,7 +186,7 @@ static BOOL api_srv_net_sess_enum(pipes_struct *p) Delete session. ********************************************************************/ -static BOOL api_srv_net_sess_del(pipes_struct *p) +static bool api_srv_net_sess_del(pipes_struct *p) { SRV_Q_NET_SESS_DEL q_u; SRV_R_NET_SESS_DEL r_u; @@ -214,7 +214,7 @@ static BOOL api_srv_net_sess_del(pipes_struct *p) RPC to enumerate shares. ********************************************************************/ -static BOOL api_srv_net_share_enum_all(pipes_struct *p) +static bool api_srv_net_share_enum_all(pipes_struct *p) { SRV_Q_NET_SHARE_ENUM q_u; SRV_R_NET_SHARE_ENUM r_u; @@ -244,7 +244,7 @@ static BOOL api_srv_net_share_enum_all(pipes_struct *p) RPC to enumerate shares. ********************************************************************/ -static BOOL api_srv_net_share_enum(pipes_struct *p) +static bool api_srv_net_share_enum(pipes_struct *p) { SRV_Q_NET_SHARE_ENUM q_u; SRV_R_NET_SHARE_ENUM r_u; @@ -274,7 +274,7 @@ static BOOL api_srv_net_share_enum(pipes_struct *p) RPC to return share information. ********************************************************************/ -static BOOL api_srv_net_share_get_info(pipes_struct *p) +static bool api_srv_net_share_get_info(pipes_struct *p) { SRV_Q_NET_SHARE_GET_INFO q_u; SRV_R_NET_SHARE_GET_INFO r_u; @@ -304,7 +304,7 @@ static BOOL api_srv_net_share_get_info(pipes_struct *p) RPC to set share information. ********************************************************************/ -static BOOL api_srv_net_share_set_info(pipes_struct *p) +static bool api_srv_net_share_set_info(pipes_struct *p) { SRV_Q_NET_SHARE_SET_INFO q_u; SRV_R_NET_SHARE_SET_INFO r_u; @@ -334,7 +334,7 @@ static BOOL api_srv_net_share_set_info(pipes_struct *p) RPC to add share information. ********************************************************************/ -static BOOL api_srv_net_share_add(pipes_struct *p) +static bool api_srv_net_share_add(pipes_struct *p) { SRV_Q_NET_SHARE_ADD q_u; SRV_R_NET_SHARE_ADD r_u; @@ -364,7 +364,7 @@ static BOOL api_srv_net_share_add(pipes_struct *p) RPC to delete share information. ********************************************************************/ -static BOOL api_srv_net_share_del(pipes_struct *p) +static bool api_srv_net_share_del(pipes_struct *p) { SRV_Q_NET_SHARE_DEL q_u; SRV_R_NET_SHARE_DEL r_u; @@ -394,7 +394,7 @@ static BOOL api_srv_net_share_del(pipes_struct *p) RPC to delete share information. ********************************************************************/ -static BOOL api_srv_net_share_del_sticky(pipes_struct *p) +static bool api_srv_net_share_del_sticky(pipes_struct *p) { SRV_Q_NET_SHARE_DEL q_u; SRV_R_NET_SHARE_DEL r_u; @@ -424,7 +424,7 @@ static BOOL api_srv_net_share_del_sticky(pipes_struct *p) api_srv_net_remote_tod ********************************************************************/ -static BOOL api_srv_net_remote_tod(pipes_struct *p) +static bool api_srv_net_remote_tod(pipes_struct *p) { SRV_Q_NET_REMOTE_TOD q_u; SRV_R_NET_REMOTE_TOD r_u; @@ -451,7 +451,7 @@ static BOOL api_srv_net_remote_tod(pipes_struct *p) RPC to enumerate disks available on a server e.g. C:, D: ... *******************************************************************/ -static BOOL api_srv_net_disk_enum(pipes_struct *p) +static bool api_srv_net_disk_enum(pipes_struct *p) { SRV_Q_NET_DISK_ENUM q_u; SRV_R_NET_DISK_ENUM r_u; @@ -481,7 +481,7 @@ static BOOL api_srv_net_disk_enum(pipes_struct *p) NetValidateName (opnum 0x21) *******************************************************************/ -static BOOL api_srv_net_name_validate(pipes_struct *p) +static bool api_srv_net_name_validate(pipes_struct *p) { SRV_Q_NET_NAME_VALIDATE q_u; SRV_R_NET_NAME_VALIDATE r_u; @@ -511,7 +511,7 @@ static BOOL api_srv_net_name_validate(pipes_struct *p) NetFileQuerySecdesc (opnum 0x27) *******************************************************************/ -static BOOL api_srv_net_file_query_secdesc(pipes_struct *p) +static bool api_srv_net_file_query_secdesc(pipes_struct *p) { SRV_Q_NET_FILE_QUERY_SECDESC q_u; SRV_R_NET_FILE_QUERY_SECDESC r_u; @@ -541,7 +541,7 @@ static BOOL api_srv_net_file_query_secdesc(pipes_struct *p) NetFileSetSecdesc (opnum 0x28) *******************************************************************/ -static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) +static bool api_srv_net_file_set_secdesc(pipes_struct *p) { SRV_Q_NET_FILE_SET_SECDESC q_u; SRV_R_NET_FILE_SET_SECDESC r_u; @@ -570,7 +570,7 @@ static BOOL api_srv_net_file_set_secdesc(pipes_struct *p) /******************************************************************* *******************************************************************/ -static BOOL api_srv_net_file_close(pipes_struct *p) +static bool api_srv_net_file_close(pipes_struct *p) { return proxy_srvsvc_call( p, NDR_SRVSVC_NETFILECLOSE ); } diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index f23d6dfcb9..27bc807367 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -452,7 +452,7 @@ static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh150 True if it ends in '$'. ********************************************************************/ -static BOOL is_hidden_share(int snum) +static bool is_hidden_share(int snum) { const char *net_name = lp_servicename(snum); @@ -463,8 +463,8 @@ static BOOL is_hidden_share(int snum) Fill in a share info structure. ********************************************************************/ -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) +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 = 0; @@ -703,7 +703,7 @@ static BOOL init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, ********************************************************************/ 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) + uint32 info_level, uint32 resume_hnd, bool all) { DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__)); @@ -886,7 +886,7 @@ static void init_srv_sess_info_1(pipes_struct *p, SRV_SESS_INFO_1 *ss1, uint32 * uint32 num_files; uint32 connect_time; struct passwd *pw = sys_getpwnam(session_list[*snum].username); - BOOL guest; + bool guest; if ( !pw ) { DEBUG(10,("init_srv_sess_info_1: failed to find owner: %s\n", @@ -1336,7 +1336,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES int num_sessions, snum; fstring username; fstring machine; - BOOL not_root = False; + bool not_root = False; rpcstr_pull_unistr2_fstring(username, &q_u->uni_user_name); rpcstr_pull_unistr2_fstring(machine, &q_u->uni_cli_name); @@ -1500,7 +1500,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S char *path; SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; - BOOL is_disk_op = False; + bool is_disk_op = False; int max_connections = 0; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); @@ -1690,7 +1690,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S char *path; SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; - BOOL is_disk_op; + bool is_disk_op; int max_connections = 0; DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); @@ -1843,7 +1843,7 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S int ret; int snum; SE_PRIV se_diskop = SE_DISK_OPERATOR; - BOOL is_disk_op; + bool is_disk_op; struct share_params *params; DEBUG(5,("_srv_net_share_del: %d\n", __LINE__)); @@ -1986,7 +1986,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC NTSTATUS nt_status; struct current_user user; connection_struct *conn = NULL; - BOOL became_user = False; + bool became_user = False; TALLOC_CTX *ctx = talloc_tos(); ZERO_STRUCT(st); @@ -2103,7 +2103,7 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ NTSTATUS nt_status; struct current_user user; connection_struct *conn = NULL; - BOOL became_user = False; + bool became_user = False; TALLOC_CTX *ctx = talloc_tos(); ZERO_STRUCT(st); diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index fcaf37e8ee..ce81a24202 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -22,7 +22,7 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -static BOOL proxy_svcctl_call(pipes_struct *p, uint8 opnum) +static bool proxy_svcctl_call(pipes_struct *p, uint8 opnum) { struct api_struct *fns; int n_fns; @@ -43,7 +43,7 @@ static BOOL proxy_svcctl_call(pipes_struct *p, uint8 opnum) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_close_service(pipes_struct *p) +static bool api_svcctl_close_service(pipes_struct *p) { return proxy_svcctl_call( p, NDR_SVCCTL_CLOSESERVICEHANDLE ); } @@ -51,7 +51,7 @@ static BOOL api_svcctl_close_service(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_open_scmanager(pipes_struct *p) +static bool api_svcctl_open_scmanager(pipes_struct *p) { SVCCTL_Q_OPEN_SCMANAGER q_u; SVCCTL_R_OPEN_SCMANAGER r_u; @@ -75,7 +75,7 @@ static BOOL api_svcctl_open_scmanager(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_open_service(pipes_struct *p) +static bool api_svcctl_open_service(pipes_struct *p) { SVCCTL_Q_OPEN_SERVICE q_u; SVCCTL_R_OPEN_SERVICE r_u; @@ -99,7 +99,7 @@ static BOOL api_svcctl_open_service(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_get_display_name(pipes_struct *p) +static bool api_svcctl_get_display_name(pipes_struct *p) { SVCCTL_Q_GET_DISPLAY_NAME q_u; SVCCTL_R_GET_DISPLAY_NAME r_u; @@ -123,7 +123,7 @@ static BOOL api_svcctl_get_display_name(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_query_status(pipes_struct *p) +static bool api_svcctl_query_status(pipes_struct *p) { SVCCTL_Q_QUERY_STATUS q_u; SVCCTL_R_QUERY_STATUS r_u; @@ -147,7 +147,7 @@ static BOOL api_svcctl_query_status(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_enum_services_status(pipes_struct *p) +static bool api_svcctl_enum_services_status(pipes_struct *p) { SVCCTL_Q_ENUM_SERVICES_STATUS q_u; SVCCTL_R_ENUM_SERVICES_STATUS r_u; @@ -170,7 +170,7 @@ static BOOL api_svcctl_enum_services_status(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_query_service_status_ex(pipes_struct *p) +static bool api_svcctl_query_service_status_ex(pipes_struct *p) { SVCCTL_Q_QUERY_SERVICE_STATUSEX q_u; SVCCTL_R_QUERY_SERVICE_STATUSEX r_u; @@ -193,7 +193,7 @@ static BOOL api_svcctl_query_service_status_ex(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_enum_dependent_services(pipes_struct *p) +static bool api_svcctl_enum_dependent_services(pipes_struct *p) { SVCCTL_Q_ENUM_DEPENDENT_SERVICES q_u; SVCCTL_R_ENUM_DEPENDENT_SERVICES r_u; @@ -217,7 +217,7 @@ static BOOL api_svcctl_enum_dependent_services(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_start_service(pipes_struct *p) +static bool api_svcctl_start_service(pipes_struct *p) { SVCCTL_Q_START_SERVICE q_u; SVCCTL_R_START_SERVICE r_u; @@ -241,7 +241,7 @@ static BOOL api_svcctl_start_service(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_control_service(pipes_struct *p) +static bool api_svcctl_control_service(pipes_struct *p) { SVCCTL_Q_CONTROL_SERVICE q_u; SVCCTL_R_CONTROL_SERVICE r_u; @@ -265,7 +265,7 @@ static BOOL api_svcctl_control_service(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_query_service_config(pipes_struct *p) +static bool api_svcctl_query_service_config(pipes_struct *p) { SVCCTL_Q_QUERY_SERVICE_CONFIG q_u; SVCCTL_R_QUERY_SERVICE_CONFIG r_u; @@ -289,7 +289,7 @@ static BOOL api_svcctl_query_service_config(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_query_service_config2(pipes_struct *p) +static bool api_svcctl_query_service_config2(pipes_struct *p) { SVCCTL_Q_QUERY_SERVICE_CONFIG2 q_u; SVCCTL_R_QUERY_SERVICE_CONFIG2 r_u; @@ -313,7 +313,7 @@ static BOOL api_svcctl_query_service_config2(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_lock_service_db(pipes_struct *p) +static bool api_svcctl_lock_service_db(pipes_struct *p) { SVCCTL_Q_LOCK_SERVICE_DB q_u; SVCCTL_R_LOCK_SERVICE_DB r_u; @@ -338,7 +338,7 @@ static BOOL api_svcctl_lock_service_db(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_unlock_service_db(pipes_struct *p) +static bool api_svcctl_unlock_service_db(pipes_struct *p) { SVCCTL_Q_UNLOCK_SERVICE_DB q_u; SVCCTL_R_UNLOCK_SERVICE_DB r_u; @@ -362,7 +362,7 @@ static BOOL api_svcctl_unlock_service_db(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_query_security_sec(pipes_struct *p) +static bool api_svcctl_query_security_sec(pipes_struct *p) { SVCCTL_Q_QUERY_SERVICE_SEC q_u; SVCCTL_R_QUERY_SERVICE_SEC r_u; @@ -386,7 +386,7 @@ static BOOL api_svcctl_query_security_sec(pipes_struct *p) /******************************************************************* ********************************************************************/ -static BOOL api_svcctl_set_security_sec(pipes_struct *p) +static bool api_svcctl_set_security_sec(pipes_struct *p) { SVCCTL_Q_SET_SERVICE_SEC q_u; SVCCTL_R_SET_SERVICE_SEC r_u; diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index c868f94f76..a6a9c855aa 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -58,7 +58,7 @@ static const struct generic_mapping svc_generic_map = /******************************************************************** ********************************************************************/ -BOOL init_service_op_table( void ) +bool init_service_op_table( void ) { const char **service_list = lp_svcctl_list(); int num_services = SVCCTL_NUM_INTERNAL_SERVICES + str_list_count( service_list ); diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 2d6ff7454a..ce34211420 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -97,7 +97,7 @@ static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd, Note that P should be valid & hnd should already have space *******************************************************************/ -static BOOL close_registry_key(pipes_struct *p, POLICY_HND *hnd) +static bool close_registry_key(pipes_struct *p, POLICY_HND *hnd) { struct registry_key *regkey = find_regkey_by_hnd(p, hnd); @@ -228,8 +228,8 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct winreg_QueryValue *r) uint32_t outbuf_size; DATA_BLOB val_blob; - BOOL free_buf = False; - BOOL free_prs = False; + bool free_buf = False; + bool free_prs = False; if ( !regkey ) return WERR_BADFID; @@ -502,7 +502,7 @@ WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, struct winreg_InitiateS fstring reboot; fstring f; int ret; - BOOL can_shutdown; + bool can_shutdown; pstrcpy(shutdown_script, lp_shutdown_script()); @@ -567,7 +567,7 @@ WERROR _winreg_AbortSystemShutdown(pipes_struct *p, struct winreg_AbortSystemShu { pstring abort_shutdown_script; int ret; - BOOL can_shutdown; + bool can_shutdown; pstrcpy(abort_shutdown_script, lp_abort_shutdown_script()); -- cgit From 23f6c371c992de211e10b7ae9cd46de3ec672143 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 19 Oct 2007 22:42:28 +0200 Subject: Streamline logic, reducing the amount of indentation. Michael (This used to be commit aae3d04e30a0e6f21f661da3dc6a2835d31ce964) --- source3/rpc_server/srv_srvsvc_nt.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 27bc807367..55c30c5315 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2033,22 +2033,21 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC } nt_status = open_file_stat(conn, NULL, filename, &st, &fsp); - if ( !NT_STATUS_IS_OK(nt_status)) { - /* Perhaps it is a directory */ - if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) - nt_status = open_directory(conn, NULL, filename, &st, - READ_CONTROL_ACCESS, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_OPEN, - 0, - FILE_ATTRIBUTE_DIRECTORY, - NULL, &fsp); - - if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); - r_u->status = ntstatus_to_werror(nt_status); - goto error_exit; - } + /* Perhaps it is a directory */ + if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) { + nt_status = open_directory(conn, NULL, filename, &st, + READ_CONTROL_ACCESS, + FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_OPEN, + 0, + FILE_ATTRIBUTE_DIRECTORY, + NULL, &fsp); + } + + if (!NT_STATUS_IS_OK(nt_status)) { + DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); + r_u->status = ntstatus_to_werror(nt_status); + goto error_exit; } sd_size = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION), &psd); -- cgit From f88b7a076be74a29a3bf876b4e2705f4a1ecf42b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 24 Oct 2007 14:16:54 -0700 Subject: This is a large patch (sorry). Migrate from struct in_addr to struct sockaddr_storage in most places that matter (ie. not the nmbd and NetBIOS lookups). This passes make test on an IPv4 box, but I'll have to do more work/testing on IPv6 enabled boxes. This should now give us a framework for testing and finishing the IPv6 migration. It's at the state where someone with a working IPv6 setup should (theorecically) be able to type : smbclient //ipv6-address/share and have it work. Jeremy. (This used to be commit 98e154c3125d5732c37a72d74b0eb5cd7b6155fd) --- source3/rpc_server/srv_netlog_nt.c | 6 +++--- source3/rpc_server/srv_spoolss_nt.c | 30 ++++++++++++++++++------------ 2 files changed, 21 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index b651fdaac3..13c0f38b74 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -90,7 +90,7 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C uint32 logon_attempts = 0x0; uint32 tc_status; fstring servername, domain, dc_name, dc_name2; - struct in_addr dc_ip; + struct sockaddr_storage dc_ss; /* this should be \\global_myname() */ unistr2_to_ascii(servername, &q_u->uni_server_name, sizeof(servername)); @@ -107,7 +107,7 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C if ( !is_trusted_domain( domain ) ) break; - if ( !get_dc_name( domain, NULL, dc_name2, &dc_ip ) ) { + if ( !get_dc_name( domain, NULL, dc_name2, &dc_ss ) ) { tc_status = ERROR_NO_LOGON_SERVERS; break; } @@ -124,7 +124,7 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C if ( !is_trusted_domain( domain ) ) break; - if ( !get_dc_name( domain, NULL, dc_name2, &dc_ip ) ) { + if ( !get_dc_name( domain, NULL, dc_name2, &dc_ss ) ) { tc_status = ERROR_NO_LOGON_SERVERS; break; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 658ed99400..aba56c2d05 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2528,26 +2528,28 @@ done: **********************************************************/ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, - struct in_addr *client_ip, const char *remote_machine) + struct sockaddr_storage *client_ss, const char *remote_machine) { NTSTATUS ret; struct cli_state *the_cli; - struct in_addr rm_addr; + struct sockaddr_storage rm_addr; - if ( is_zero_ip_v4(*client_ip) ) { + if ( is_zero_addr(client_ss) ) { if ( !resolve_name( remote_machine, &rm_addr, 0x20) ) { DEBUG(2,("spoolss_connect_to_client: Can't resolve address for %s\n", remote_machine)); return False; } - if ( ismyip_v4( rm_addr )) { + if (ismyaddr(&rm_addr)) { DEBUG(0,("spoolss_connect_to_client: Machine %s is one of our addresses. Cannot add to ourselves.\n", remote_machine)); return False; } } else { - rm_addr.s_addr = client_ip->s_addr; + char addr[INET6_ADDRSTRLEN]; + rm_addr = *client_ss; + print_sockaddr(addr, sizeof(addr), &rm_addr); DEBUG(5,("spoolss_connect_to_client: Using address %s (no name resolution necessary)\n", - inet_ntoa(*client_ip) )); + addr)); } /* setup the connection */ @@ -2596,7 +2598,7 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, static bool srv_spoolss_replyopenprinter(int snum, const char *printer, uint32 localprinter, uint32 type, - POLICY_HND *handle, struct in_addr *client_ip) + POLICY_HND *handle, struct sockaddr_storage *client_ss) { WERROR result; @@ -2609,7 +2611,7 @@ static bool srv_spoolss_replyopenprinter(int snum, const char *printer, fstrcpy(unix_printer, printer+2); /* the +2 is to strip the leading 2 backslashs */ - if ( !spoolss_connect_to_client( ¬ify_cli_pipe, client_ip, unix_printer )) + if ( !spoolss_connect_to_client( ¬ify_cli_pipe, client_ss, unix_printer )) return False; messaging_register(smbd_messaging_context(), NULL, @@ -2660,7 +2662,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE uint32 printerlocal = q_u->printerlocal; int snum = -1; SPOOL_NOTIFY_OPTION *option = q_u->option; - struct in_addr client_ip; + struct sockaddr_storage client_ss; /* store the notify value in the printer struct */ @@ -2690,12 +2692,16 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE else if ( (Printer->printer_type == SPLHND_PRINTER) && !get_printer_snum(p, handle, &snum, NULL) ) return WERR_BADFID; - - client_ip.s_addr = inet_addr(p->conn->client_address); + + if (!interpret_string_addr(&client_ss, + p->conn->client_address, + AI_NUMERICHOST)) { + return WERR_SERVER_UNAVAILABLE; + } if(!srv_spoolss_replyopenprinter(snum, Printer->notify.localmachine, Printer->notify.printerlocal, 1, - &Printer->notify.client_hnd, &client_ip)) + &Printer->notify.client_hnd, &client_ss)) return WERR_SERVER_UNAVAILABLE; Printer->notify.client_connected=True; -- cgit From 88ee61625a5de5e443d14c54eab91a90d87cda85 Mon Sep 17 00:00:00 2001 From: "Gerald (Jerry) Carter" Date: Thu, 1 Nov 2007 15:53:44 -0400 Subject: Patch 2 of 3 from Debian Samba packagers: The point is doing the following associations: - non discardable state data (all TDB files that may need to be backed up) go to statedir - shared data (codepage stuff) go to codepagedir The patch *does not change* the default location for these directories. So, there is no behaviour change when applying it. The main change is for samba developers who have to think when dealing with files that previously pertained to libdir whether they: - go in statedir - go in codepagedir - stay in libdir (This used to be commit d6cdbfd875bb2653e831d314726c3240beb0a96b) --- source3/rpc_server/srv_eventlog_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 3f06f0f39f..00afe5b05c 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -66,7 +66,7 @@ char *elog_tdbname( const char *name ) { fstring path; char *tdb_fullpath; - char *eventlogdir = lock_path( "eventlog" ); + char *eventlogdir = state_path( "eventlog" ); pstr_sprintf( path, "%s/%s.tdb", eventlogdir, name ); strlower_m( path ); @@ -348,7 +348,7 @@ ELOG_TDB *elog_open_tdb( char *logname, bool force_clear ) /* make sure that the eventlog dir exists */ - eventlogdir = lock_path( "eventlog" ); + eventlogdir = state_path( "eventlog" ); if ( !directory_exist( eventlogdir, NULL ) ) mkdir( eventlogdir, 0755 ); -- cgit From 6658165d5e9cd186fea74e1581091233e8990e9b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Nov 2007 18:15:45 -0700 Subject: Stop get_peer_addr() and client_addr() from using global statics. Part of my library cleanups. Jeremy. (This used to be commit e848506c858bd16706c1d7f6b4b032005512b8ac) --- source3/rpc_server/srv_netlog_nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 13c0f38b74..6de8cd7572 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -196,8 +196,10 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) const uint8 *pass; bool ret; uint32 acct_ctrl; - + #if 0 + char addr[INET6_ADDRSTRLEN]; + /* * Currently this code is redundent as we already have a filter * by hostname list. What this code really needs to do is to @@ -208,7 +210,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) */ if (!allow_access(lp_domain_hostsdeny(), lp_domain_hostsallow(), - client_name(), client_addr())) + client_name(), client_addr(addr))) { DEBUG(0,("get_md4pw: Workstation %s denied access to domain\n", mach_acct)); return False; -- cgit From 25074433f412c4dd2531fd268d51be8753ddc11b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Nov 2007 18:41:26 -0700 Subject: I can't get away without a 'length' arg. :-). Jeremy. (This used to be commit 95d01279a5def709d0a5d5ae7224d6286006d120) --- source3/rpc_server/srv_netlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 6de8cd7572..f876ee976d 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -210,7 +210,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) */ if (!allow_access(lp_domain_hostsdeny(), lp_domain_hostsallow(), - client_name(), client_addr(addr))) + client_name(), client_addr(addr,sizeof(addr)))) { DEBUG(0,("get_md4pw: Workstation %s denied access to domain\n", mach_acct)); return False; -- cgit From 5b0b4f23ef5fec3d1ad518237f973d4e014b5766 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 3 Nov 2007 23:20:10 -0700 Subject: Remove most of the remaining globals out of lib/util_sock.c. I have a plan for dealing with the remaining..... Watch this space. Jeremy. (This used to be commit 963fc7685212689f02b3adcc05b4273ee5c382d4) --- source3/rpc_server/srv_netlog_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index f876ee976d..b6ae104d1c 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -210,8 +210,8 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) */ if (!allow_access(lp_domain_hostsdeny(), lp_domain_hostsallow(), - client_name(), client_addr(addr,sizeof(addr)))) - { + client_name(get_client_fd()), + client_addr(get_client_fd(),addr,sizeof(addr)))) { DEBUG(0,("get_md4pw: Workstation %s denied access to domain\n", mach_acct)); return False; } -- cgit From 4c3040a4e8f484256b1c660ee0544b1b964c785f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 1 Nov 2007 17:49:31 +0100 Subject: pstring removal (This used to be commit f5468d2c9abad41cb1e9d9b9ec6a1b56564961a4) --- source3/rpc_server/srv_lsa_hnd.c | 7 ++++--- source3/rpc_server/srv_wkssvc_nt.c | 23 ++++++++--------------- 2 files changed, 12 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index fa63c8091e..a8341e677b 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -53,9 +53,10 @@ bool init_pipe_handle_list(pipes_struct *p, const char *pipe_name) if (strequal( plist->name, pipe_name) || (is_samr_lsa_pipe(plist->name) && is_samr_lsa_pipe(pipe_name))) { if (!plist->pipe_handles) { - pstring msg; - slprintf(msg, sizeof(msg)-1, "init_pipe_handles: NULL pipe_handle pointer in pipe %s", - pipe_name ); + char *msg; + asprintf(&msg, "init_pipe_handles: NULL " + "pipe_handle pointer in pipe %s", + pipe_name); smb_panic(msg); } hl = plist->pipe_handles; diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 417ce8e761..11ca8915a2 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -27,26 +27,19 @@ #define DBGC_CLASS DBGC_RPC_SRV /******************************************************************* - Fill in the valiues for the struct wkssvc_NetWkstaInfo100. + Fill in the values for the struct wkssvc_NetWkstaInfo100. ********************************************************************/ static void create_wks_info_100(struct wkssvc_NetWkstaInfo100 *info100) { - pstring my_name; - pstring domain; + info100->platform_id = 0x000001f4; /* unknown */ + info100->version_major = lp_major_announce_version(); + info100->version_minor = lp_minor_announce_version(); - pstrcpy (my_name, global_myname()); - strupper_m(my_name); - - pstrcpy (domain, lp_workgroup()); - strupper_m(domain); - - info100->platform_id = 0x000001f4; /* unknown */ - info100->version_major = lp_major_announce_version(); - info100->version_minor = lp_minor_announce_version(); - - info100->server_name = talloc_strdup( info100, my_name ); - info100->domain_name = talloc_strdup( info100, domain ); + info100->server_name = talloc_strdup( + info100, strupper_static(global_myname())); + info100->domain_name = talloc_strdup( + info100, strupper_static(lp_workgroup())); return; } -- cgit From d40e47db4b5da41c8604a2058f3a0b0a82164f08 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 8 Nov 2007 17:25:45 -0800 Subject: Remove more fstring/pstring bad useage. Go talloc ! Jeremy. (This used to be commit 2a0173743d2cf615d52278f3dd87cc804abe2d16) --- source3/rpc_server/srv_lsa_nt.c | 8 +++++--- source3/rpc_server/srv_spoolss_nt.c | 12 ++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index ea2bc0fa7b..5c2e1b6f01 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1927,10 +1927,12 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I /* ugly temp hack for these next two */ /* This should be a 'netbios domain -> DNS domain' mapping */ - dnsdomname[0] = '\0'; - get_mydnsdomname(dnsdomname); + dnsdomname = get_mydnsdomname(p->mem_ctx); + if (!dnsdomname) { + return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; + } strlower_m(dnsdomname); - + dns_name = dnsdomname; forest_name = dnsdomname; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index aba56c2d05..fe7a12940e 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2401,20 +2401,20 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint return WERR_OK; } - if (!StrCaseCmp(value, "DNSMachineName")) { - pstring hostname; - - if (!get_mydnsfullname(hostname)) + if (!StrCaseCmp(value, "DNSMachineName")) { + const char *hostname = get_mydnsfullname(); + + if (!hostname) return WERR_BADFILE; *type = REG_SZ; - *needed = 2*(strlen(hostname)+1); + *needed = 2*(strlen(hostname)+1); if((*data = (uint8 *)TALLOC(ctx, (*needed > in_size) ? *needed:in_size )) == NULL) return WERR_NOMEM; memset(*data, 0, (*needed > in_size) ? *needed:in_size); for (i=0; i Date: Thu, 8 Nov 2007 17:58:55 -0800 Subject: Fix case where we have no dns domain name. Return a talloc of "". Jeremy. (This used to be commit ab8934844a8ae08657769ce1787c32f14a7eb745) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 5c2e1b6f01..20655082a5 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1928,7 +1928,7 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I /* This should be a 'netbios domain -> DNS domain' mapping */ dnsdomname = get_mydnsdomname(p->mem_ctx); - if (!dnsdomname) { + if (!dnsdomname || !*dnsdomname) { return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; } strlower_m(dnsdomname); -- cgit From 62b97b01561e332d3b566c4f70cc2601e2d7fcac Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 28 Oct 2007 19:15:08 +0100 Subject: Make base64_encode_data_blob return a talloced string (This used to be commit 5f205ab48d8ac3b7af573ea0be1ce095ab835448) --- source3/rpc_server/srv_samr_util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 7bac25e611..f7e20797a7 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -58,7 +58,7 @@ void copy_id20_to_sam_passwd(struct samu *to, SAM_USER_INFO_20 *from) if (STRING_CHANGED_NC(old_string,new_string)) pdb_set_munged_dial(to , new_string, PDB_CHANGED); - SAFE_FREE(new_string); + TALLOC_FREE(new_string); } } @@ -201,7 +201,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) if (STRING_CHANGED_NC(old_string,newstr)) pdb_set_munged_dial(to , newstr, PDB_CHANGED); - SAFE_FREE(newstr); + TALLOC_FREE(newstr); } if (from->fields_present & ACCT_RID) { @@ -425,7 +425,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) if (STRING_CHANGED_NC(old_string, newstr)) pdb_set_munged_dial(to , newstr, PDB_CHANGED); - SAFE_FREE(newstr); + TALLOC_FREE(newstr); } if (from->fields_present & ACCT_RID) { @@ -637,7 +637,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) if (STRING_CHANGED_NC(old_string,newstr)) pdb_set_munged_dial(to , newstr, PDB_CHANGED); - SAFE_FREE(newstr); + TALLOC_FREE(newstr); } if (from->fields_present & ACCT_RID) { -- cgit From 79266500cd3f84c74b2f89ceeb15c23cedacc2b5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 12 Nov 2007 15:02:50 -0800 Subject: Remove all pstrings from smbd/chgpasswd.c. Jeremy. (This used to be commit eaf14c701b08e9eff5b94bf57af68cb29142d7fc) --- source3/rpc_server/srv_samr_nt.c | 58 ++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 26 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9aabaf08ca..3cc8f01d2c 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3275,33 +3275,37 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, struct samu *pwd) { - pstring plaintext_buf; - uint32 len; + char *plaintext_buf = NULL; + uint32 len = 0; uint16 acct_ctrl; NTSTATUS status; - + if (id23 == NULL) { DEBUG(5, ("set_user_info_23: NULL id23\n")); return NT_STATUS_INVALID_PARAMETER; } - + DEBUG(5, ("Attempting administrator password change (level 23) for user %s\n", pdb_get_username(pwd))); acct_ctrl = pdb_get_acct_ctrl(pwd); - if (!decode_pw_buffer(id23->pass, plaintext_buf, 256, &len, STR_UNICODE)) { + if (!decode_pw_buffer(mem_ctx, + id23->pass, + &plaintext_buf, + &len, + STR_UNICODE)) { TALLOC_FREE(pwd); return NT_STATUS_INVALID_PARAMETER; } - + if (!pdb_set_plaintext_passwd (pwd, plaintext_buf)) { TALLOC_FREE(pwd); return NT_STATUS_ACCESS_DENIED; } - + copy_id23_to_sam_passwd(pwd, id23); - + /* if it's a trust account, don't update /etc/passwd */ if ( ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || ( (acct_ctrl & ACB_WSTRUST) == ACB_WSTRUST) || @@ -3320,16 +3324,16 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, if ((passwd = Get_Pwnam(pdb_get_username(pwd))) == NULL) { DEBUG(1, ("chgpasswd: Username does not exist in system !?!\n")); } - + if(!chgpasswd(pdb_get_username(pwd), passwd, "", plaintext_buf, True)) { TALLOC_FREE(pwd); return NT_STATUS_ACCESS_DENIED; } } } - - ZERO_STRUCT(plaintext_buf); - + + memset(plaintext_buf, '\0', strlen(plaintext_buf)); + if (IS_SAM_CHANGED(pwd, PDB_GROUPSID) && (!NT_STATUS_IS_OK(status = pdb_set_unix_primary_group(mem_ctx, pwd)))) { @@ -3341,7 +3345,7 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, TALLOC_FREE(pwd); return status; } - + TALLOC_FREE(pwd); return NT_STATUS_OK; @@ -3353,12 +3357,12 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, static bool set_user_info_pw(uint8 *pass, struct samu *pwd) { - uint32 len; - pstring plaintext_buf; + uint32 len = 0; + char *plaintext_buf = NULL; uint32 acct_ctrl; time_t last_set_time; enum pdb_value_state last_set_state; - + DEBUG(5, ("Attempting administrator password change for user %s\n", pdb_get_username(pwd))); @@ -3368,9 +3372,11 @@ static bool set_user_info_pw(uint8 *pass, struct samu *pwd) last_set_state = pdb_get_init_flags(pwd, PDB_PASSLASTSET); last_set_time = pdb_get_pass_last_set_time(pwd); - ZERO_STRUCT(plaintext_buf); - - if (!decode_pw_buffer(pass, plaintext_buf, 256, &len, STR_UNICODE)) { + if (!decode_pw_buffer(talloc_tos(), + pass, + &plaintext_buf, + &len, + STR_UNICODE)) { TALLOC_FREE(pwd); return False; } @@ -3379,7 +3385,7 @@ static bool set_user_info_pw(uint8 *pass, struct samu *pwd) TALLOC_FREE(pwd); return False; } - + /* if it's a trust account, don't update /etc/passwd */ if ( ( (acct_ctrl & ACB_DOMTRUST) == ACB_DOMTRUST ) || ( (acct_ctrl & ACB_WSTRUST) == ACB_WSTRUST) || @@ -3399,21 +3405,21 @@ static bool set_user_info_pw(uint8 *pass, struct samu *pwd) if ((passwd = Get_Pwnam(pdb_get_username(pwd))) == NULL) { DEBUG(1, ("chgpasswd: Username does not exist in system !?!\n")); } - + if(!chgpasswd(pdb_get_username(pwd), passwd, "", plaintext_buf, True)) { TALLOC_FREE(pwd); return False; } } } - - ZERO_STRUCT(plaintext_buf); - + + memset(plaintext_buf, '\0', strlen(plaintext_buf)); + /* restore last set time as this is an admin change, not a user pw change */ pdb_set_pass_last_set_time (pwd, last_set_time, last_set_state); - + DEBUG(5,("set_user_info_pw: pdb_update_pwd()\n")); - + /* update the SAMBA password */ if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) { TALLOC_FREE(pwd); -- cgit From 15953b82eb3b49d736b4b835b1d0d3cf0da0bff8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 13 Oct 2007 21:06:49 +0200 Subject: Make [f]get_nt_acl return NTSTATUS (This used to be commit dcbe1bf942d017a3cd5084c6ef605a13912f795b) --- source3/rpc_server/srv_srvsvc_nt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 55c30c5315..5a3c451cde 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2050,14 +2050,19 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC goto error_exit; } - sd_size = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION), &psd); + nt_status = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, + (OWNER_SECURITY_INFORMATION + |GROUP_SECURITY_INFORMATION + |DACL_SECURITY_INFORMATION), &psd); - if (sd_size == 0) { + if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + r_u->status = ntstatus_to_werror(nt_status); goto error_exit; } + sd_size = sec_desc_size(psd); + r_u->ptr_response = 1; r_u->size_response = sd_size; r_u->ptr_secdesc = 1; -- cgit From 68be9a820059ee96dd26c527efd7c14e679d3f2c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 15 Nov 2007 14:19:52 -0800 Subject: More pstring removal. This one was tricky. I had to add one horror (pstring_clean_name()) which will have to remain until I've removed all pstrings from the client code. Jeremy. (This used to be commit 1ea3ac80146b83c2522b69e7747c823366a2b47d) --- source3/rpc_server/srv_srvsvc_nt.c | 21 +++++++++++++-------- source3/rpc_server/srv_winreg_nt.c | 27 ++++++++++++++------------- 2 files changed, 27 insertions(+), 21 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 5a3c451cde..51dffb8904 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1463,17 +1463,22 @@ WERROR _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, S Check a given DOS pathname is valid for a share. ********************************************************************/ -char *valid_share_pathname(char *dos_pathname) +char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname) { - char *ptr; + char *ptr = talloc_strdup(ctx, dos_pathname); + if (!ptr) { + return NULL; + } /* Convert any '\' paths to '/' */ - unix_format(dos_pathname); - unix_clean_name(dos_pathname); + unix_format(ptr); + ptr = unix_clean_name(talloc_tos(), ptr); + if (!ptr) { + return NULL; + } /* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */ - ptr = dos_pathname; - if (strlen(dos_pathname) > 2 && ptr[1] == ':' && ptr[0] != '/') + if (strlen(ptr) > 2 && ptr[1] == ':' && ptr[0] != '/') ptr += 2; /* Only absolute paths allowed. */ @@ -1602,7 +1607,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return WERR_ACCESS_DENIED; /* Check if the pathname is valid. */ - if (!(path = valid_share_pathname( pathname ))) + if (!(path = valid_share_pathname(p->mem_ctx, pathname ))) return WERR_OBJECT_PATH_INVALID; /* Ensure share name, pathname and comment don't contain '"' characters. */ @@ -1774,7 +1779,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S return WERR_ACCESS_DENIED; /* Check if the pathname is valid. */ - if (!(path = valid_share_pathname( pathname ))) + if (!(path = valid_share_pathname(p->mem_ctx, pathname ))) return WERR_OBJECT_PATH_INVALID; /* Ensure share name, pathname and comment don't contain '"' characters. */ diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index ce34211420..4b268dda19 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -580,17 +580,16 @@ WERROR _winreg_AbortSystemShutdown(pipes_struct *p, struct winreg_AbortSystemShu if ( can_shutdown ) become_root(); - + ret = smbrun( abort_shutdown_script, NULL ); - + if ( can_shutdown ) unbecome_root(); - + /********** END SeRemoteShutdownPrivilege BLOCK **********/ DEBUG(3,("_reg_abort_shutdown: Running the command `%s' gave %d\n", abort_shutdown_script, ret)); - return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; } @@ -605,19 +604,19 @@ static int validate_reg_filename( pstring fname ) int snum; pstring share_path; pstring unix_fname; - + /* convert to a unix path, stripping the C:\ along the way */ - - if ( !(p = valid_share_pathname( fname ) )) + + if ( !(p = valid_share_pathname(NULL, fname))) return -1; /* has to exist within a valid file share */ - + for ( snum=0; snum Date: Sun, 25 Nov 2007 10:10:52 +0100 Subject: Remove some statics (This used to be commit 1fab16ffb888cd4ec18e52d9da33976a67a5d104) --- source3/rpc_server/srv_spoolss_nt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index fe7a12940e..d49731272f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4376,7 +4376,8 @@ static bool construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *p struct GUID guid; if (is_printer_published(print_hnd, snum, &guid)) { - asprintf(&guid_str, "{%s}", smb_uuid_string_static(guid)); + asprintf(&guid_str, "{%s}", + smb_uuid_string(talloc_tos(), guid)); strupper_m(guid_str); init_unistr(&printer->guid, guid_str); printer->action = SPOOL_DS_PUBLISH; -- cgit From 3a452a15b7185dd4023c7dc8d44004c962f39d98 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Nov 2007 11:22:58 -0800 Subject: Remove pstring from everything in rpc_server except srv_spoolss_nt.c and srv_srvsvc_nt.c. They're next :-). Jeremy. (This used to be commit 55b4f9d003b036af69085f7b64e0df08c5ba440d) --- source3/rpc_server/srv_eventlog_lib.c | 151 ++++++++++---------- source3/rpc_server/srv_eventlog_nt.c | 162 +++++++++++++-------- source3/rpc_server/srv_netlog_nt.c | 27 ++-- source3/rpc_server/srv_samr_util.c | 3 +- source3/rpc_server/srv_srvsvc_nt.c | 2 +- source3/rpc_server/srv_svcctl_nt.c | 25 ++-- source3/rpc_server/srv_winreg_nt.c | 256 +++++++++++++++++++--------------- 7 files changed, 358 insertions(+), 268 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 00afe5b05c..b9648283e1 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -62,17 +62,16 @@ TDB_CONTEXT *elog_init_tdb( char *tdbfilename ) and size. Caller must free memory. ********************************************************************/ -char *elog_tdbname( const char *name ) +char *elog_tdbname(TALLOC_CTX *ctx, const char *name ) { - fstring path; - char *tdb_fullpath; - char *eventlogdir = state_path( "eventlog" ); - - pstr_sprintf( path, "%s/%s.tdb", eventlogdir, name ); - strlower_m( path ); - tdb_fullpath = SMB_STRDUP( path ); - - return tdb_fullpath; + char *path = talloc_asprintf(ctx, "%s/%s.tdb", + state_path("eventlog"), + name); + if (!path) { + return NULL; + } + strlower_m(path); + return path; } @@ -320,13 +319,13 @@ ELOG_TDB *elog_open_tdb( char *logname, bool force_clear ) TDB_CONTEXT *tdb = NULL; uint32 vers_id; ELOG_TDB *ptr; - char *tdbfilename; - pstring tdbpath; + char *tdbpath = NULL; ELOG_TDB *tdb_node = NULL; char *eventlogdir; + TALLOC_CTX *ctx = talloc_tos(); /* first see if we have an open context */ - + for ( ptr=open_elog_list; ptr; ptr=ptr->next ) { if ( strequal( ptr->name, logname ) ) { ptr->ref_count++; @@ -345,27 +344,28 @@ ELOG_TDB *elog_open_tdb( char *logname, bool force_clear ) return ptr; } } - + /* make sure that the eventlog dir exists */ - + eventlogdir = state_path( "eventlog" ); if ( !directory_exist( eventlogdir, NULL ) ) - mkdir( eventlogdir, 0755 ); - + mkdir( eventlogdir, 0755 ); + /* get the path on disk */ - - tdbfilename = elog_tdbname( logname ); - pstrcpy( tdbpath, tdbfilename ); - SAFE_FREE( tdbfilename ); - DEBUG(7,("elog_open_tdb: Opening %s...(force_clear == %s)\n", + tdbpath = elog_tdbname(ctx, logname); + if (!tdbpath) { + return NULL; + } + + DEBUG(7,("elog_open_tdb: Opening %s...(force_clear == %s)\n", tdbpath, force_clear?"True":"False" )); - + /* the tdb wasn't already open or this is a forced clear open */ if ( !force_clear ) { - tdb = tdb_open_log( tdbpath, 0, TDB_DEFAULT, O_RDWR , 0 ); + tdb = tdb_open_log( tdbpath, 0, TDB_DEFAULT, O_RDWR , 0 ); if ( tdb ) { vers_id = tdb_fetch_int32( tdb, EVT_VERSION ); @@ -593,9 +593,8 @@ void fixup_eventlog_entry( Eventlog_entry * ee ) bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor ) { + TALLOC_CTX *ctx = talloc_tos(); char *start = NULL, *stop = NULL; - pstring temp; - int temp_len = 0; start = line; @@ -661,62 +660,69 @@ bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor ) } else if ( 0 == strncmp( start, "USL", stop - start ) ) { entry->record.user_sid_length = atoi( stop + 1 ); } else if ( 0 == strncmp( start, "SRC", stop - start ) ) { - memset( temp, 0, sizeof( temp ) ); stop++; while ( isspace( stop[0] ) ) { stop++; } - temp_len = strlen( stop ); - strncpy( temp, stop, temp_len ); - rpcstr_push( ( void * ) ( entry->data_record.source_name ), - temp, sizeof( entry->data_record.source_name ), - STR_TERMINATE ); - entry->data_record.source_name_len = - ( strlen_w( entry->data_record.source_name ) * 2 ) + - 2; + entry->data_record.source_name_len = rpcstr_push_talloc(ctx, + &entry->data_record.source_name, + stop); + if (entry->data_record.source_name_len == (size_t)-1 || + entry->data_record.source_name == NULL) { + return false; + } } else if ( 0 == strncmp( start, "SRN", stop - start ) ) { - memset( temp, 0, sizeof( temp ) ); stop++; while ( isspace( stop[0] ) ) { stop++; } - temp_len = strlen( stop ); - strncpy( temp, stop, temp_len ); - rpcstr_push( ( void * ) ( entry->data_record.computer_name ), - temp, sizeof( entry->data_record.computer_name ), - STR_TERMINATE ); - entry->data_record.computer_name_len = - ( strlen_w( entry->data_record.computer_name ) * 2 ) + - 2; + entry->data_record.computer_name_len = rpcstr_push_talloc(ctx, + &entry->data_record.computer_name, + stop); + if (entry->data_record.computer_name_len == (size_t)-1 || + entry->data_record.computer_name == NULL) { + return false; + } } else if ( 0 == strncmp( start, "SID", stop - start ) ) { - memset( temp, 0, sizeof( temp ) ); stop++; while ( isspace( stop[0] ) ) { stop++; } - temp_len = strlen( stop ); - strncpy( temp, stop, temp_len ); - rpcstr_push( ( void * ) ( entry->data_record.sid ), temp, - sizeof( entry->data_record.sid ), - STR_TERMINATE ); - entry->record.user_sid_length = - ( strlen_w( entry->data_record.sid ) * 2 ) + 2; + entry->record.user_sid_length = rpcstr_push_talloc(ctx, + &entry->data_record.sid, + stop); + if (entry->record.user_sid_length == (size_t)-1 || + entry->data_record.sid == NULL) { + return false; + } } else if ( 0 == strncmp( start, "STR", stop - start ) ) { + smb_ucs2_t *temp = NULL; + size_t tmp_len; + uint32_t old_len; /* skip past initial ":" */ stop++; /* now skip any other leading whitespace */ - while ( isspace( stop[0] ) ) { + while ( isspace(stop[0])) { stop++; } - temp_len = strlen( stop ); - memset( temp, 0, sizeof( temp ) ); - strncpy( temp, stop, temp_len ); - rpcstr_push( ( void * ) ( entry->data_record.strings + - ( entry->data_record.strings_len / 2 ) ), - temp, - sizeof( entry->data_record.strings ) - - ( entry->data_record.strings_len / 2 ), STR_TERMINATE ); - entry->data_record.strings_len += ( temp_len * 2 ) + 2; + tmp_len = rpcstr_push_talloc(ctx, + &temp, + stop); + if (tmp_len == (size_t)-1 || !temp) { + return false; + } + old_len = entry->data_record.strings_len; + entry->data_record.strings = (smb_ucs2_t *)TALLOC_REALLOC_ARRAY(ctx, + entry->data_record.strings, + char, + old_len + tmp_len); + if (!entry->data_record.strings) { + return false; + } + memcpy(entry->data_record.strings + old_len, + temp, + tmp_len); + entry->data_record.strings_len += tmp_len; entry->record.num_strings++; } else if ( 0 == strncmp( start, "DAT", stop - start ) ) { /* skip past initial ":" */ @@ -725,25 +731,18 @@ bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor ) while ( isspace( stop[0] ) ) { stop++; } - entry->data_record.user_data_len = strlen( stop ); - memset( entry->data_record.user_data, 0, - sizeof( entry->data_record.user_data ) ); - if ( entry->data_record.user_data_len > 0 ) { - /* copy no more than the first 1024 bytes */ - if ( entry->data_record.user_data_len > - sizeof( entry->data_record.user_data ) ) - entry->data_record.user_data_len = - sizeof( entry->data_record. - user_data ); - memcpy( entry->data_record.user_data, stop, - entry->data_record.user_data_len ); + entry->data_record.user_data_len = strlen(stop); + entry->data_record.user_data = talloc_strdup(ctx, + stop); + if (!entry->data_record.user_data) { + return false; } } else { /* some other eventlog entry -- not implemented, so dropping on the floor */ DEBUG( 10, ( "Unknown entry [%s]. Ignoring.\n", line ) ); /* For now return true so that we can keep on parsing this mess. Eventually we will return False here. */ - return True; + return true; } - return True; + return true; } diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index d86da9054c..cd06be1984 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -69,7 +69,7 @@ static EVENTLOG_INFO *find_eventlog_info_by_hnd( pipes_struct * p, static bool elog_check_access( EVENTLOG_INFO *info, NT_USER_TOKEN *token ) { - char *tdbname = elog_tdbname( info->logname ); + char *tdbname = elog_tdbname(talloc_tos(), info->logname ); SEC_DESC *sec_desc; bool ret; NTSTATUS ntstatus; @@ -280,22 +280,28 @@ static int elog_size( EVENTLOG_INFO *info ) } /******************************************************************** - For the given tdb, get the next eventlog record into the passed + For the given tdb, get the next eventlog record into the passed Eventlog_entry. returns NULL if it can't get the record for some reason. ********************************************************************/ -static Eventlog_entry *get_eventlog_record( prs_struct * ps, TDB_CONTEXT * tdb, - int recno, Eventlog_entry * ee ) +static Eventlog_entry *get_eventlog_record(prs_struct *ps, + TDB_CONTEXT *tdb, + int recno) { + Eventlog_entry *ee = NULL; TDB_DATA ret, key; int srecno; int reclen; int len; - pstring *wpsource, *wpcomputer, *wpsid, *wpstrs, *puserdata; + char *wpsource = NULL; + char *wpcomputer = NULL; + char *wpsid = NULL; + char *wpstrs = NULL; + char *puserdata = NULL; - key.dsize = sizeof( int32 ); + key.dsize = sizeof(int32); srecno = recno; key.dptr = ( uint8 * ) &srecno; @@ -316,10 +322,11 @@ static Eventlog_entry *get_eventlog_record( prs_struct * ps, TDB_CONTEXT * tdb, if ( !len ) return NULL; - /* ee = PRS_ALLOC_MEM(ps, Eventlog_entry, 1); */ - - if ( !ee ) + ee = TALLOC_ARRAY(ps->mem_ctx, Eventlog_entry, 1); + if (!ee) { return NULL; + } + ZERO_STRUCTP(ee); len = tdb_unpack( ret.dptr, ret.dsize, "ddddddwwwwddddddBBdBBBd", &ee->record.length, &ee->record.reserved1, @@ -347,36 +354,67 @@ static Eventlog_entry *get_eventlog_record( prs_struct * ps, TDB_CONTEXT * tdb, /* have to do the following because the tdb_unpack allocs a buff, stuffs a pointer to the buff into it's 2nd argment for 'B' */ - if ( wpcomputer ) - memcpy( ee->data_record.computer_name, wpcomputer, - ee->data_record.computer_name_len ); - if ( wpsource ) - memcpy( ee->data_record.source_name, wpsource, - ee->data_record.source_name_len ); - - if ( wpsid ) - memcpy( ee->data_record.sid, wpsid, - ee->record.user_sid_length ); - if ( wpstrs ) - memcpy( ee->data_record.strings, wpstrs, - ee->data_record.strings_len ); - - /* note that userdata is a pstring */ - if ( puserdata ) - memcpy( ee->data_record.user_data, puserdata, - ee->data_record.user_data_len ); - - SAFE_FREE( wpcomputer ); - SAFE_FREE( wpsource ); - SAFE_FREE( wpsid ); - SAFE_FREE( wpstrs ); - SAFE_FREE( puserdata ); + if (wpcomputer) { + ee->data_record.computer_name = TALLOC_MEMDUP(ee, + wpcomputer, + ee->data_record.computer_name_len); + if (!ee->data_record.computer_name) { + TALLOC_FREE(ee); + goto out; + } + } + if (wpsource) { + ee->data_record.source_name = TALLOC_MEMDUP(ee, + wpsource, + ee->data_record.source_name_len); + if (!ee->data_record.source_name) { + TALLOC_FREE(ee); + goto out; + } + } + + if (wpsid) { + ee->data_record.sid = TALLOC_MEMDUP(ee, + wpsid, + ee->record.user_sid_length); + if (!ee->data_record.sid) { + TALLOC_FREE(ee); + goto out; + } + } + if (wpstrs) { + ee->data_record.strings = TALLOC_MEMDUP(ee, + wpstrs, + ee->data_record.strings_len); + if (!ee->data_record.strings) { + TALLOC_FREE(ee); + goto out; + } + } + + if (puserdata) { + ee->data_record.user_data = TALLOC_MEMDUP(ee, + puserdata, + ee->data_record.user_data_len); + if (!ee->data_record.user_data) { + TALLOC_FREE(ee); + goto out; + } + } + + out: + + SAFE_FREE(wpcomputer); + SAFE_FREE(wpsource); + SAFE_FREE(wpsid); + SAFE_FREE(wpstrs); + SAFE_FREE(puserdata); DEBUG( 10, ( "get_eventlog_record: read back %d\n", len ) ); DEBUG( 10, ( "get_eventlog_record: computer_name %d is ", ee->data_record.computer_name_len ) ); - SAFE_FREE( ret.dptr ); + SAFE_FREE(ret.dptr); return ee; } @@ -387,7 +425,7 @@ static Eventlog_entry *get_eventlog_record( prs_struct * ps, TDB_CONTEXT * tdb, static bool sync_eventlog_params( EVENTLOG_INFO *info ) { - pstring path; + char *path = NULL; uint32 uiMaxSize; uint32 uiRetention; REGISTRY_KEY *keyinfo; @@ -395,6 +433,7 @@ static bool sync_eventlog_params( EVENTLOG_INFO *info ) REGVAL_CTR *values; WERROR wresult; char *elogname = info->logname; + TALLOC_CTX *ctx = talloc_tos(); DEBUG( 4, ( "sync_eventlog_params with %s\n", elogname ) ); @@ -412,7 +451,10 @@ static bool sync_eventlog_params( EVENTLOG_INFO *info ) to use the same fetch/store api that we use in srv_reg_nt.c */ - pstr_sprintf( path, "%s/%s", KEY_EVENTLOG, elogname ); + path = talloc_asprintf(ctx, "%s/%s", KEY_EVENTLOG, elogname ); + if (!path) { + return false; + } wresult = regkey_open_internal( NULL, &keyinfo, path, get_root_nt_token( ), REG_KEY_READ ); @@ -624,16 +666,20 @@ NTSTATUS _eventlog_clear_eventlog( pipes_struct * p, EVENTLOG_R_CLEAR_EVENTLOG * r_u ) { EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); - pstring backup_file_name; + char *backup_file_name = NULL; if ( !info ) return NT_STATUS_INVALID_HANDLE; - pstrcpy( backup_file_name, "" ); - if ( q_u->backupfile.string ) { - rpcstr_pull( backup_file_name, q_u->backupfile.string->buffer, - sizeof( backup_file_name ), - q_u->backupfile.string->uni_str_len * 2, 0 ); + if (q_u->backupfile.string) { + size_t len = rpcstr_pull_talloc(p->mem_ctx, + &backup_file_name, + q_u->backupfile.string->buffer, + q_u->backupfile.string->uni_str_len * 2, + 0 ); + if (len == (size_t)-1 || !backup_file_name) { + return NT_STATUS_INVALID_PARAMETER; + } DEBUG(8,( "_eventlog_clear_eventlog: Using [%s] as the backup " "file name for log [%s].", @@ -647,7 +693,7 @@ NTSTATUS _eventlog_clear_eventlog( pipes_struct * p, /* Force a close and reopen */ - elog_close_tdb( info->etdb, True ); + elog_close_tdb( info->etdb, True ); become_root(); info->etdb = elog_open_tdb( info->logname, True ); unbecome_root(); @@ -674,7 +720,7 @@ NTSTATUS _eventlog_read_eventlog( pipes_struct * p, EVENTLOG_R_READ_EVENTLOG * r_u ) { EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); - Eventlog_entry entry, *ee_new; + Eventlog_entry *entry = NULL, *ee_new = NULL; uint32 num_records_read = 0; prs_struct *ps; int bytes_left, record_number; @@ -689,9 +735,9 @@ NTSTATUS _eventlog_read_eventlog( pipes_struct * p, bytes_left = q_u->max_read_size; - if ( !info->etdb ) + if ( !info->etdb ) return NT_STATUS_ACCESS_DENIED; - + /* check for valid flags. Can't use the sequential and seek flags together */ elog_read_type = q_u->flags & (EVENTLOG_SEQUENTIAL_READ|EVENTLOG_SEEK_READ); @@ -708,37 +754,39 @@ NTSTATUS _eventlog_read_eventlog( pipes_struct * p, if ( elog_read_type & EVENTLOG_SEQUENTIAL_READ ) record_number = info->current_record; - else + else record_number = q_u->offset; while ( bytes_left > 0 ) { /* assume that when the record fetch fails, that we are done */ - if ( !get_eventlog_record ( ps, ELOG_TDB_CTX(info->etdb), record_number, &entry ) ) + entry = get_eventlog_record (ps, ELOG_TDB_CTX(info->etdb), record_number); + if (!entry) { break; + } DEBUG( 8, ( "Retrieved record %d\n", record_number ) ); - + /* Now see if there is enough room to add */ - if ( !(ee_new = read_package_entry( ps, q_u, r_u,&entry )) ) + if ( !(ee_new = read_package_entry( ps, q_u, r_u, entry )) ) return NT_STATUS_NO_MEMORY; if ( r_u->num_bytes_in_resp + ee_new->record.length > q_u->max_read_size ) { r_u->bytes_in_next_record = ee_new->record.length; /* response would be too big to fit in client-size buffer */ - + bytes_left = 0; break; } - + add_record_to_resp( r_u, ee_new ); bytes_left -= ee_new->record.length; - ZERO_STRUCT( entry ); + TALLOC_FREE(entry); num_records_read = r_u->num_records - num_records_read; - + DEBUG( 10, ( "_eventlog_read_eventlog: read [%d] records for a total " "of [%d] records using [%d] bytes out of a max of [%d].\n", num_records_read, r_u->num_records, @@ -749,13 +797,13 @@ NTSTATUS _eventlog_read_eventlog( pipes_struct * p, record_number++; else record_number--; - + /* update the eventlog record pointer */ - + info->current_record = record_number; } - /* crazy by WinXP uses NT_STATUS_BUFFER_TOO_SMALL to + /* crazy by WinXP uses NT_STATUS_BUFFER_TOO_SMALL to say when there are no more records */ return (num_records_read ? NT_STATUS_OK : NT_STATUS_BUFFER_TOO_SMALL); diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index b6ae104d1c..29c60e07b5 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -948,16 +948,16 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, /* 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. */ - + { DOM_GID *gids = NULL; const DOM_SID *user_sid = NULL; const DOM_SID *group_sid = NULL; DOM_SID domain_sid; - uint32 user_rid, group_rid; + uint32 user_rid, group_rid; int num_gids = 0; - pstring my_name; + const char *my_name; fstring user_sid_string; fstring group_sid_string; unsigned char user_session_key[16]; @@ -985,19 +985,18 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, DEBUG(1, ("_net_sam_logon: user %s\\%s has user sid " "%s\n but group sid %s.\n" "The conflicting domain portions are not " - "supported for NETLOGON calls\n", + "supported for NETLOGON calls\n", pdb_get_domain(sampw), pdb_get_username(sampw), sid_to_string(user_sid_string, user_sid), sid_to_string(group_sid_string, group_sid))); return NT_STATUS_UNSUCCESSFUL; } - - + if(server_info->login_server) { - pstrcpy(my_name, server_info->login_server); + my_name = server_info->login_server; } else { - pstrcpy(my_name, global_myname()); + my_name = global_myname(); } status = nt_token_to_group_list(p->mem_ctx, &domain_sid, @@ -1011,7 +1010,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (server_info->user_session_key.length) { memcpy(user_session_key, - server_info->user_session_key.data, + server_info->user_session_key.data, MIN(sizeof(user_session_key), server_info->user_session_key.length)); if (process_creds) { @@ -1029,7 +1028,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, } if (server_info->lm_session_key.length) { memcpy(lm_session_key, - server_info->lm_session_key.data, + server_info->lm_session_key.data, MIN(sizeof(lm_session_key), server_info->lm_session_key.length)); if (process_creds) { @@ -1045,10 +1044,10 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, SamOEMhash(lm_session_key, pipe_session_key, 16); memset(pipe_session_key, '\0', 16); } - - init_net_user_info3(p->mem_ctx, usr_info, + + init_net_user_info3(p->mem_ctx, usr_info, user_rid, - group_rid, + group_rid, pdb_get_username(sampw), pdb_get_fullname(sampw), pdb_get_homedir(sampw), @@ -1071,7 +1070,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, server_info->lm_session_key.length ? lm_session_key : NULL, my_name , /* char *logon_srv */ pdb_get_domain(sampw), - &domain_sid); /* DOM_SID *dom_sid */ + &domain_sid); /* DOM_SID *dom_sid */ ZERO_STRUCT(user_session_key); ZERO_STRUCT(lm_session_key); } diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index f7e20797a7..bde7936343 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -235,7 +235,8 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_LOGON_HOURS) { - pstring oldstr, newstr; + char oldstr[44]; /* hours strings are 42 bytes. */ + char newstr[44]; DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); if (from->logon_divs != pdb_get_logon_divs(to)) { pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 51dffb8904..9788eb5bcc 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1472,7 +1472,7 @@ char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname) } /* Convert any '\' paths to '/' */ unix_format(ptr); - ptr = unix_clean_name(talloc_tos(), ptr); + ptr = unix_clean_name(ctx, ptr); if (!ptr) { return NULL; } diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index a6a9c855aa..7d81033264 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -288,29 +288,34 @@ WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_ SEC_DESC *sec_desc; uint32 access_granted = 0; NTSTATUS status; - pstring service; - - rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); - + char *service = NULL; + size_t ret = rpcstr_pull_talloc(p->mem_ctx, + &service, + q_u->servicename.buffer, + q_u->servicename.uni_str_len*2, + 0); + + if (ret == (size_t)-1 || !service) { + return WERR_NOMEM; + } DEBUG(5, ("_svcctl_open_service: Attempting to open Service [%s], \n", service)); - /* based on my tests you can open a service if you have a valid scm handle */ - + if ( !find_service_info_by_hnd( p, &q_u->handle ) ) return WERR_BADFID; - + /* perform access checks. Use the root token in order to ensure that we retrieve the security descriptor */ - + if ( !(sec_desc = svcctl_get_secdesc( p->mem_ctx, service, get_root_nt_token() )) ) return WERR_NOMEM; - + se_map_generic( &q_u->access, &svc_generic_map ); status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); if ( !NT_STATUS_IS_OK(status) ) return ntstatus_to_werror( status ); - + return create_open_service_handle( p, &r_u->handle, SVC_HANDLE_IS_SERVICE, service, access_granted ); } diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 4b268dda19..631386c078 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -494,21 +494,23 @@ WERROR _winreg_InitiateSystemShutdown(pipes_struct *p, struct winreg_InitiateSys WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, struct winreg_InitiateSystemShutdownEx *r) { - pstring shutdown_script; + char *shutdown_script = NULL; char *msg = NULL; - pstring chkmsg; + char *chkmsg = NULL; fstring str_timeout; fstring str_reason; fstring reboot; fstring f; int ret; bool can_shutdown; - - pstrcpy(shutdown_script, lp_shutdown_script()); - - if ( !*shutdown_script ) + shutdown_script = talloc_strdup(p->mem_ctx, lp_shutdown_script()); + if (!shutdown_script) { + return WERR_NOMEM; + } + if (!*shutdown_script) { return WERR_ACCESS_DENIED; + } /* pull the message string and perform necessary sanity checks on it */ @@ -518,66 +520,86 @@ WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, struct winreg_InitiateS if ( (msg = talloc_strdup(p->mem_ctx, r->in.message->name->name )) == NULL ) { return WERR_NOMEM; } - alpha_strcpy (chkmsg, msg, NULL, sizeof(chkmsg)); - } - + chkmsg = TALLOC_ARRAY(p->mem_ctx, char, strlen(msg)+1); + if (!chkmsg) { + return WERR_NOMEM; + } + alpha_strcpy(chkmsg, msg, NULL, strlen(msg)+1); + } + fstr_sprintf(str_timeout, "%d", r->in.timeout); fstr_sprintf(reboot, r->in.reboot ? SHUTDOWN_R_STRING : ""); fstr_sprintf(f, r->in.force_apps ? SHUTDOWN_F_STRING : ""); fstr_sprintf(str_reason, "%d", r->in.reason ); - all_string_sub( shutdown_script, "%z", chkmsg, sizeof(shutdown_script) ); - all_string_sub( shutdown_script, "%t", str_timeout, sizeof(shutdown_script) ); - all_string_sub( shutdown_script, "%r", reboot, sizeof(shutdown_script) ); - all_string_sub( shutdown_script, "%f", f, sizeof(shutdown_script) ); - all_string_sub( shutdown_script, "%x", str_reason, sizeof(shutdown_script) ); + shutdown_script = talloc_all_string_sub(p->mem_ctx, + shutdown_script, "%z", chkmsg ? chkmsg : ""); + if (!shutdown_script) { + return WERR_NOMEM; + } + shutdown_script = talloc_all_string_sub(p->mem_ctx, + shutdown_script, "%t", str_timeout); + if (!shutdown_script) { + return WERR_NOMEM; + } + shutdown_script = talloc_all_string_sub(p->mem_ctx, + shutdown_script, "%r", reboot); + if (!shutdown_script) { + return WERR_NOMEM; + } + shutdown_script = talloc_all_string_sub(p->mem_ctx, + shutdown_script, "%f", f); + if (!shutdown_script) { + return WERR_NOMEM; + } + shutdown_script = talloc_all_string_sub(p->mem_ctx, + shutdown_script, "%x", str_reason); + if (!shutdown_script) { + return WERR_NOMEM; + } can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_remote_shutdown ); - + /* IF someone has privs, run the shutdown script as root. OTHERWISE run it as not root Take the error return from the script and provide it as the Windows return code. */ - + /********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/ - - if ( can_shutdown ) + + if ( can_shutdown ) become_root(); ret = smbrun( shutdown_script, NULL ); - + if ( can_shutdown ) unbecome_root(); /********** END SeRemoteShutdownPrivilege BLOCK **********/ - + DEBUG(3,("_reg_shutdown_ex: Running the command `%s' gave %d\n", shutdown_script, ret)); - return (ret == 0) ? WERR_OK : WERR_ACCESS_DENIED; } - - - /******************************************************************* reg_abort_shutdwon ********************************************************************/ WERROR _winreg_AbortSystemShutdown(pipes_struct *p, struct winreg_AbortSystemShutdown *r) { - pstring abort_shutdown_script; + const char *abort_shutdown_script; int ret; bool can_shutdown; - pstrcpy(abort_shutdown_script, lp_abort_shutdown_script()); + abort_shutdown_script = lp_abort_shutdown_script(); - if ( !*abort_shutdown_script ) + if (!*abort_shutdown_script) return WERR_ACCESS_DENIED; - + can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_remote_shutdown ); - + /********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/ - + if ( can_shutdown ) become_root(); @@ -597,49 +619,45 @@ WERROR _winreg_AbortSystemShutdown(pipes_struct *p, struct winreg_AbortSystemShu /******************************************************************* ********************************************************************/ -static int validate_reg_filename( pstring fname ) +static int validate_reg_filename(TALLOC_CTX *ctx, char **pp_fname ) { - char *p; + char *p = NULL; int num_services = lp_numservices(); - int snum; - pstring share_path; - pstring unix_fname; + int snum = -1; + const char *share_path; + char *fname = *pp_fname; /* convert to a unix path, stripping the C:\ along the way */ - if ( !(p = valid_share_pathname(NULL, fname))) + if (!(p = valid_share_pathname(ctx, fname))) { return -1; + } /* has to exist within a valid file share */ - for ( snum=0; snummem_ctx, REGSUBKEY_CTR )) ) return WERR_NOMEM; - + if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) return WERR_NOMEM; /* copy values into the REGVAL_CTR */ - + for ( i=0; inum_values; i++ ) { regval_ctr_addvalue( values, key->values[i].valuename, key->values[i].type, (char*)key->values[i].data, (key->values[i].data_size & ~VK_DATA_IN_OFFSET) ); } /* copy subkeys into the REGSUBKEY_CTR */ - + key->subkey_index = 0; while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { regsubkey_ctr_addkey( subkeys, subkey->keyname ); } - + /* write this key and values out */ - - if ( !store_reg_values( ®istry_key, values ) + + if ( !store_reg_values( ®istry_key, values ) || !store_reg_keys( ®istry_key, subkeys ) ) { DEBUG(0,("reg_load_tree: Failed to load %s!\n", topkeypath)); result = WERR_REG_IO_FAILURE; } - + TALLOC_FREE( subkeys ); - + if ( !W_ERROR_IS_OK(result) ) return result; - + /* now continue to load each subkey registry tree */ key->subkey_index = 0; while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { - pstr_sprintf( path, "%s%s%s", topkeypath, "\\", subkey->keyname ); + path = talloc_asprintf(regfile->mem_ctx, + "%s\\%s", + topkeypath, + subkey->keyname); + if (!path) { + return WERR_NOMEM; + } result = reg_load_tree( regfile, path, subkey ); if ( !W_ERROR_IS_OK(result) ) break; @@ -741,13 +765,13 @@ static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) regfio_close( regfile ); return WERR_REG_FILE_INVALID; } - + result = reg_load_tree( regfile, krecord->name, rootkey ); - + /* cleanup */ - + regfio_close( regfile ); - + return result; } @@ -757,28 +781,31 @@ static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) WERROR _winreg_RestoreKey(pipes_struct *p, struct winreg_RestoreKey *r) { struct registry_key *regkey = find_regkey_by_hnd( p, r->in.handle ); - pstring fname; + char *fname = NULL; int snum; - + if ( !regkey ) - return WERR_BADFID; + return WERR_BADFID; if ( !r->in.filename || !r->in.filename->name ) return WERR_INVALID_PARAM; - pstrcpy( fname, r->in.filename->name ); + fname - talloc_strdup(p->mem_ctx, r->in.filename->name); + if (!fname) { + return WERR_NOMEM; + } DEBUG(8,("_winreg_RestoreKey: verifying restore of key [%s] from " "\"%s\"\n", regkey->key->name, fname)); - if ( (snum = validate_reg_filename( fname )) == -1 ) + if ((snum = validate_reg_filename(p->mem_ctx, &fname)) == -1) return WERR_OBJECT_PATH_INVALID; - + /* user must posses SeRestorePrivilege for this this proceed */ - + if ( !user_has_privileges( p->pipe_user.nt_user_token, &se_restore ) ) return WERR_ACCESS_DENIED; - + DEBUG(2,("_winreg_RestoreKey: Restoring [%s] from %s in share %s\n", regkey->key->name, fname, lp_servicename(snum) )); @@ -795,30 +822,33 @@ static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, REGVAL_CTR *values; REGSUBKEY_CTR *subkeys; int i, num_subkeys; - pstring key_tmp; + char *key_tmp = NULL; char *keyname, *parentpath; - pstring subkeypath; + char *subkeypath = NULL; char *subkeyname; REGISTRY_KEY registry_key; WERROR result = WERR_OK; - - if ( !regfile ) + + if (!regfile) return WERR_GENERAL_FAILURE; - - if ( !keypath ) + + if (!keypath) return WERR_OBJECT_PATH_INVALID; - + /* split up the registry key path */ - - pstrcpy( key_tmp, keypath ); - if ( !reg_split_key( key_tmp, &parentpath, &keyname ) ) + + key_tmp = talloc_strdup(regfile->mem_ctx, keypath); + if (!key_tmp) { + return WERR_NOMEM; + } + if (!reg_split_key( key_tmp, &parentpath, &keyname ) ) return WERR_OBJECT_PATH_INVALID; if ( !keyname ) keyname = parentpath; /* we need a REGISTRY_KEY object here to enumerate subkeys and values */ - + ZERO_STRUCT( registry_key ); if ( (registry_key.name = talloc_strdup(regfile->mem_ctx, keypath)) == NULL ) @@ -828,8 +858,8 @@ static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, return WERR_BADFILE; /* lookup the values and subkeys */ - - if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) + + if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) return WERR_NOMEM; if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) @@ -839,7 +869,7 @@ static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, fetch_reg_values( ®istry_key, values ); /* write out this key */ - + if ( !(key = regfio_write_key( regfile, keyname, values, subkeys, sec_desc, parent )) ) { result = WERR_CAN_NOT_COMPLETE; goto done; @@ -850,7 +880,12 @@ static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, num_subkeys = regsubkey_ctr_numkeys( subkeys ); for ( i=0; imem_ctx, + "%s\\%s", keypath, subkeyname); + if (!subkeypath) { + result = WERR_NOMEM; + goto done; + } result = reg_write_tree( regfile, subkeypath, key, sec_desc ); if ( !W_ERROR_IS_OK(result) ) goto done; @@ -915,26 +950,26 @@ static WERROR backup_registry_key ( REGISTRY_KEY *krecord, const char *fname ) SEC_DESC *sd = NULL; /* open the registry file....fail if the file already exists */ - + if ( !(regfile = regfio_open( fname, (O_RDWR|O_CREAT|O_EXCL), (S_IREAD|S_IWRITE) )) ) { - DEBUG(0,("backup_registry_key: failed to open \"%s\" (%s)\n", + DEBUG(0,("backup_registry_key: failed to open \"%s\" (%s)\n", fname, strerror(errno) )); return ( ntstatus_to_werror(map_nt_error_from_unix( errno )) ); } - + if ( !W_ERROR_IS_OK(result = make_default_reg_sd( regfile->mem_ctx, &sd )) ) { regfio_close( regfile ); return result; } - + /* write the registry tree to the file */ - + result = reg_write_tree( regfile, krecord->name, NULL, sd ); - + /* cleanup */ - + regfio_close( regfile ); - + return result; } @@ -944,26 +979,29 @@ static WERROR backup_registry_key ( REGISTRY_KEY *krecord, const char *fname ) WERROR _winreg_SaveKey(pipes_struct *p, struct winreg_SaveKey *r) { struct registry_key *regkey = find_regkey_by_hnd( p, r->in.handle ); - pstring fname; - int snum; - + char *fname = NULL; + int snum = -1; + if ( !regkey ) - return WERR_BADFID; + return WERR_BADFID; if ( !r->in.filename || !r->in.filename->name ) return WERR_INVALID_PARAM; - pstrcpy( fname, r->in.filename->name ); + fname = talloc_strdup(p->mem_ctx, r->in.filename->name); + if (!fname) { + return WERR_NOMEM; + } DEBUG(8,("_winreg_SaveKey: verifying backup of key [%s] to \"%s\"\n", regkey->key->name, fname)); - - if ( (snum = validate_reg_filename( fname )) == -1 ) + + if ((snum = validate_reg_filename(p->mem_ctx, &fname)) == -1 ) return WERR_OBJECT_PATH_INVALID; - + DEBUG(2,("_winreg_SaveKey: Saving [%s] to %s in share %s\n", regkey->key->name, fname, lp_servicename(snum) )); - + return backup_registry_key( regkey->key, fname ); } -- cgit From f642ae837507e755d5949a61ea5ad70c7b334385 Mon Sep 17 00:00:00 2001 From: Guenther Deschner Date: Tue, 27 Nov 2007 21:53:41 +0100 Subject: fix a obscure compiler warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Jeremy, I have never seen this warning before: "warning: comparison is always false due to limited range of data type". Guenther - -- Günther Deschner GPG-ID: 8EE11688 Red Hat gdeschner@redhat.com Samba Team gd@samba.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFHTIOOSOk3aI7hFogRArxMAJwP0ktE96tHcwn9nXG6AOqonpeDgQCgm/zi 54B6HJZvx6zdUTMFFNWqUb0= =kUJa -----END PGP SIGNATURE----- >From 6a4935ee455adc1251fce2759f97d35f303bd40e Mon Sep 17 00:00:00 2001 From: =?utf-8?q?G=C3=BCnther=20Deschner?= Date: Tue, 27 Nov 2007 21:48:39 +0100 Subject: [PATCH] Getting rid of "comparison is always false due to limited range of data type" warning. Guenther (This used to be commit 951202913956e113841585f7372e8db8f9aeb76a) --- source3/rpc_server/srv_eventlog_lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index b9648283e1..4e996ee19b 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -667,7 +667,7 @@ bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor ) entry->data_record.source_name_len = rpcstr_push_talloc(ctx, &entry->data_record.source_name, stop); - if (entry->data_record.source_name_len == (size_t)-1 || + if (entry->data_record.source_name_len == (uint32_t)-1 || entry->data_record.source_name == NULL) { return false; } @@ -679,7 +679,7 @@ bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor ) entry->data_record.computer_name_len = rpcstr_push_talloc(ctx, &entry->data_record.computer_name, stop); - if (entry->data_record.computer_name_len == (size_t)-1 || + if (entry->data_record.computer_name_len == (uint32_t)-1 || entry->data_record.computer_name == NULL) { return false; } @@ -691,7 +691,7 @@ bool parse_logentry( char *line, Eventlog_entry * entry, bool * eor ) entry->record.user_sid_length = rpcstr_push_talloc(ctx, &entry->data_record.sid, stop); - if (entry->record.user_sid_length == (size_t)-1 || + if (entry->record.user_sid_length == (uint32_t)-1 || entry->data_record.sid == NULL) { return false; } -- cgit From 6b6655edd90850d09c7711fc3b9fe98271e3e625 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Nov 2007 14:35:30 -0800 Subject: Remove pstrings from everything except srv_spoolss_nt.c. Jeremy. (This used to be commit 0002a9e96b0ef78316295a6eb94ff29b64e2f988) --- source3/rpc_server/srv_srvsvc_nt.c | 510 +++++++++++++++++++++++-------------- 1 file changed, 315 insertions(+), 195 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 9788eb5bcc..b034e7cbd3 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -54,14 +54,14 @@ static int pipe_enum_fn( struct db_record *rec, void *p) struct file_enum_count *fenum = (struct file_enum_count *)p; FILE_INFO_3 *f; int i = fenum->count; - pstring fullpath; + char *fullpath = NULL; const char *username; - + if (rec->value.dsize != sizeof(struct pipe_open_rec)) return 0; memcpy(&prec, rec->value.dptr, sizeof(struct pipe_open_rec)); - + if ( !process_exists(prec.pid) ) { return 0; } @@ -72,22 +72,26 @@ static int pipe_enum_fn( struct db_record *rec, void *p) && !strequal(username, fenum->username)) { return 0; } - - snprintf( fullpath, sizeof(fullpath), "\\PIPE\\%s", prec.name ); - + + fullpath = talloc_asprintf(fenum->ctx, "\\PIPE\\%s", prec.name ); + if (!fullpath) { + return 1; + } + f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 ); if ( !f ) { DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); return 1; } fenum->info = f; - + init_srv_file_info3( - &fenum->info[i], + &fenum->info[i], (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum), - (FILE_READ_DATA|FILE_WRITE_DATA), + (FILE_READ_DATA|FILE_WRITE_DATA), 0, username, fullpath); - + + TALLOC_FREE(fullpath); fenum->count++; return 0; @@ -112,17 +116,17 @@ static WERROR net_enum_pipes( TALLOC_CTX *ctx, const char *username, "failed\n")); return WERR_NOMEM; } - + *info = fenum.info; *count = fenum.count; - + return WERR_OK; } /******************************************************************* ********************************************************************/ -static void enum_file_fn( const struct share_mode_entry *e, +static void enum_file_fn( const struct share_mode_entry *e, const char *sharepath, const char *fname, void *private_data ) { @@ -134,10 +138,10 @@ static void enum_file_fn( const struct share_mode_entry *e, files_struct fsp; struct byte_range_lock *brl; int num_locks = 0; - pstring fullpath; + char *fullpath = NULL; uint32 permissions; const char *username; - + /* If the pid was not found delete the entry from connections.tdb */ if ( !process_exists(e->pid) ) { @@ -150,7 +154,7 @@ static void enum_file_fn( const struct share_mode_entry *e, && !strequal(username, fenum->username)) { return; } - + f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 ); if ( !f ) { DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); @@ -159,33 +163,38 @@ static void enum_file_fn( const struct share_mode_entry *e, fenum->info = f; /* need to count the number of locks on a file */ - - ZERO_STRUCT( fsp ); + + ZERO_STRUCT( fsp ); fsp.file_id = e->id; - + if ( (brl = brl_get_locks(NULL,&fsp)) != NULL ) { num_locks = brl->num_locks; - TALLOC_FREE( brl ); + TALLOC_FREE(brl); } - + if ( strcmp( fname, "." ) == 0 ) { - pstr_sprintf( fullpath, "C:%s", sharepath ); + fullpath = talloc_asprintf(fenum->ctx, "C:%s", sharepath ); } else { - pstr_sprintf( fullpath, "C:%s/%s", sharepath, fname ); + fullpath = talloc_asprintf(fenum->ctx, "C:%s/%s", + sharepath, fname ); + } + if (!fullpath) { + return; } string_replace( fullpath, '/', '\\' ); - + /* mask out create (what ever that is) */ permissions = e->share_access & (FILE_READ_DATA|FILE_WRITE_DATA); /* now fill in the FILE_INFO_3 struct */ - init_srv_file_info3( &fenum->info[i], + init_srv_file_info3( &fenum->info[i], e->share_file_id, permissions, num_locks, username, fullpath ); - + + TALLOC_FREE(fullpath); fenum->count++; } @@ -214,11 +223,11 @@ static WERROR net_enum_files( TALLOC_CTX *ctx, const char *username, /******************************************************************* Utility function to get the 'type' of a share from an snum. ********************************************************************/ -static uint32 get_share_type(int snum) +static uint32 get_share_type(int snum) { char *net_name = lp_servicename(snum); int len_net_name = strlen(net_name); - + /* work out the share type */ uint32 type = STYPE_DISKTREE; @@ -231,16 +240,14 @@ static uint32 get_share_type(int snum) return type; } - + /******************************************************************* Fill in a share info level 0 structure. ********************************************************************/ static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int snum) { - pstring net_name; - - pstrcpy(net_name, lp_servicename(snum)); + const char *net_name = lp_servicename(snum); init_srv_share_info0(&sh0->info_0, net_name); init_srv_share_info0_str(&sh0->info_0_str, net_name); @@ -252,14 +259,22 @@ static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int sn static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum) { - pstring remark; - char *net_name = lp_servicename(snum); - pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark,sizeof(remark)); + char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum)); - init_srv_share_info1(&sh1->info_1, net_name, get_share_type(snum), remark); - init_srv_share_info1_str(&sh1->info_1_str, net_name, remark); + if (remark) { + remark = standard_sub_conn(p->mem_ctx, + p->conn, + remark); + } + + init_srv_share_info1(&sh1->info_1, + net_name, + get_share_type(snum), + remark ? remark: ""); + init_srv_share_info1_str(&sh1->info_1_str, + net_name, + remark ? remark: ""); } /******************************************************************* @@ -268,33 +283,48 @@ static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int sn static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int snum) { - pstring remark; - pstring path; - pstring passwd; + char *remark = NULL; + char *path = NULL; int max_connections = lp_max_connections(snum); uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff; int count = 0; char *net_name = lp_servicename(snum); - - pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark,sizeof(remark)); - pstrcpy(path, "C:"); - pstrcat(path, lp_pathname(snum)); - /* - * Change / to \\ so that win2k will see it as a valid path. This was added to - * enable use of browsing in win2k add share dialog. - */ + remark = talloc_strdup(p->mem_ctx, lp_comment(snum)); + if (remark) { + remark = standard_sub_conn(p->mem_ctx, + p->conn, + remark); + } + path = talloc_asprintf(p->mem_ctx, + "C:%s", lp_pathname(snum)); - string_replace(path, '/', '\\'); + if (path) { + /* + * Change / to \\ so that win2k will see it as a valid path. + * This was added to enable use of browsing in win2k add + * share dialog. + */ - pstrcpy(passwd, ""); + string_replace(path, '/', '\\'); + } - count = count_current_connections( net_name, False ); - init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum), - remark, 0, max_uses, count, path, passwd); + count = count_current_connections(net_name, false); + init_srv_share_info2(&sh2->info_2, + net_name, + get_share_type(snum), + remark ? remark : "", + 0, + max_uses, + count, + path ? path : "", + ""); - init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd); + init_srv_share_info2_str(&sh2->info_2_str, + net_name, + remark ? remark : "", + path ? path : "", + ""); } /******************************************************************* @@ -319,7 +349,7 @@ static void map_generic_share_sd_bits(SEC_DESC *psd) se_map_generic(&psa->access_mask, &file_generic_mapping); psa->access_mask |= orig_mask; - } + } } /******************************************************************* @@ -328,14 +358,17 @@ static void map_generic_share_sd_bits(SEC_DESC *psd) static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum) { - pstring remark; - const char *net_name = lp_servicename(snum); - pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark, sizeof(remark)); + char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum)); + + if (remark) { + remark = standard_sub_conn(p->mem_ctx, p->conn, remark); + } - init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), remark, (lp_csc_policy(snum) << 4)); - init_srv_share_info501_str(&sh501->info_501_str, net_name, remark); + init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), + remark ? remark : "", (lp_csc_policy(snum) << 4)); + init_srv_share_info501_str(&sh501->info_501_str, + net_name, remark ? remark : ""); } /******************************************************************* @@ -344,36 +377,47 @@ static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, int snum) { - pstring net_name; - pstring remark; - pstring path; - pstring passwd; - SEC_DESC *sd; - size_t sd_size; + const char *net_name = lp_servicename(snum); + char *path = NULL; + SEC_DESC *sd = NULL; + size_t sd_size = 0; TALLOC_CTX *ctx = p->mem_ctx; - + char *remark = talloc_strdup(ctx, lp_comment(snum));; ZERO_STRUCTP(sh502); - pstrcpy(net_name, lp_servicename(snum)); - pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark,sizeof(remark)); - pstrcpy(path, "C:"); - pstrcat(path, lp_pathname(snum)); - - /* - * Change / to \\ so that win2k will see it as a valid path. This was added to - * enable use of browsing in win2k add share dialog. - */ - - string_replace(path, '/', '\\'); - - pstrcpy(passwd, ""); + if (remark) { + remark = standard_sub_conn(ctx, p->conn, remark); + } + path = talloc_asprintf(ctx, "C:%s", lp_pathname(snum)); + if (path) { + /* + * Change / to \\ so that win2k will see it as a valid path. This was added to + * enable use of browsing in win2k add share dialog. + */ + string_replace(path, '/', '\\'); + } sd = get_share_security(ctx, lp_servicename(snum), &sd_size); - init_srv_share_info502(&sh502->info_502, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size); - init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, path, passwd, sd, sd_size); + init_srv_share_info502(&sh502->info_502, + net_name, + get_share_type(snum), + remark ? remark : "", + 0, + 0xffffffff, + 1, + path ? path : "", + "", + sd, + sd_size); + init_srv_share_info502_str(&sh502->info_502_str, + net_name, + remark ? remark : "", + path ? path : "", + "", + sd, + sd_size); } /*************************************************************************** @@ -382,15 +426,17 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh1004, int snum) { - pstring remark; + char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum)); - pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark, sizeof(remark)); + if (remark) { + remark = standard_sub_conn(p->mem_ctx, p->conn, remark); + } ZERO_STRUCTP(sh1004); - - init_srv_share_info1004(&sh1004->info_1004, remark); - init_srv_share_info1004_str(&sh1004->info_1004_str, remark); + + init_srv_share_info1004(&sh1004->info_1004, remark ? remark : ""); + init_srv_share_info1004_str(&sh1004->info_1004_str, + remark ? remark : ""); } /*************************************************************************** @@ -402,9 +448,9 @@ static void init_srv_share_info_1005(pipes_struct *p, SRV_SHARE_INFO_1005* sh100 sh1005->share_info_flags = 0; if(lp_host_msdfs() && lp_msdfs_root(snum)) - sh1005->share_info_flags |= + sh1005->share_info_flags |= SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT; - sh1005->share_info_flags |= + sh1005->share_info_flags |= lp_csc_policy(snum) << SHARE_1005_CSC_POLICY_SHIFT; } /*************************************************************************** @@ -422,13 +468,12 @@ static void init_srv_share_info_1006(pipes_struct *p, SRV_SHARE_INFO_1006* sh100 static void init_srv_share_info_1007(pipes_struct *p, SRV_SHARE_INFO_1007* sh1007, int snum) { - pstring alternate_directory_name = ""; uint32 flags = 0; ZERO_STRUCTP(sh1007); - - init_srv_share_info1007(&sh1007->info_1007, flags, alternate_directory_name); - init_srv_share_info1007_str(&sh1007->info_1007_str, alternate_directory_name); + + init_srv_share_info1007(&sh1007->info_1007, flags, ""); + init_srv_share_info1007_str(&sh1007->info_1007_str, ""); } /******************************************************************* @@ -1465,8 +1510,13 @@ WERROR _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, S char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname) { - char *ptr = talloc_strdup(ctx, dos_pathname); + char *ptr = NULL; + + if (!dos_pathname) { + return NULL; + } + ptr = talloc_strdup(ctx, dos_pathname); if (!ptr) { return NULL; } @@ -1495,26 +1545,30 @@ char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname) WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) { struct current_user user; - pstring command; - fstring share_name; - fstring comment; - pstring pathname; + char *command = NULL; + char *share_name = NULL; + char *comment = NULL; + char *pathname = NULL; int type; int snum; int ret; - char *path; + char *path = NULL; SEC_DESC *psd = NULL; SE_PRIV se_diskop = SE_DISK_OPERATOR; bool is_disk_op = False; int max_connections = 0; + TALLOC_CTX *ctx = p->mem_ctx; DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); - unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); + share_name = unistr2_to_ascii_talloc(ctx, &q_u->uni_share_name); + if (!share_name) { + return WERR_NET_NAME_NOT_FOUND; + } r_u->parm_error = 0; - if ( strequal(share_name,"IPC$") + if ( strequal(share_name,"IPC$") || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) || strequal(share_name,"global") ) { @@ -1534,22 +1588,25 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S get_current_user(&user,p); is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); - + /* fail out now if you are not root and not a disk op */ - + if ( user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; switch (q_u->info_level) { case 1: - pstrcpy(pathname, lp_pathname(snum)); - unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); + pathname = talloc_strdup(ctx, lp_pathname(snum)); + comment = unistr2_to_ascii_talloc(ctx, + &q_u->info.share.info2.info_2_str.uni_remark); type = q_u->info.share.info2.info_2.type; psd = NULL; break; case 2: - unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment)); - unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(pathname)); + comment = unistr2_to_ascii_talloc(ctx, + &q_u->info.share.info2.info_2_str.uni_remark); + pathname = unistr2_to_ascii_talloc(ctx, + &q_u->info.share.info2.info_2_str.uni_path); type = q_u->info.share.info2.info_2.type; max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; psd = NULL; @@ -1563,15 +1620,18 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S break; #endif case 502: - unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(comment)); - unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(pathname)); + comment = unistr2_to_ascii_talloc(ctx, + &q_u->info.share.info502.info_502_str.uni_remark); + pathname = unistr2_to_ascii_talloc(ctx, + &q_u->info.share.info502.info_502_str.uni_path); type = q_u->info.share.info502.info_502.type; psd = q_u->info.share.info502.info_502_str.sd; map_generic_share_sd_bits(psd); break; case 1004: - pstrcpy(pathname, lp_pathname(snum)); - unistr2_to_ascii(comment, &q_u->info.share.info1004.info_1004_str.uni_remark, sizeof(comment)); + pathname = talloc_strdup(ctx, lp_pathname(snum)); + comment = unistr2_to_ascii_talloc(ctx, + &q_u->info.share.info1004.info_1004_str.uni_remark); type = STYPE_DISKTREE; break; case 1005: @@ -1591,8 +1651,8 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S case 1007: return WERR_ACCESS_DENIED; case 1501: - pstrcpy(pathname, lp_pathname(snum)); - fstrcpy(comment, lp_comment(snum)); + pathname = talloc_strdup(ctx, lp_pathname(snum)); + comment = talloc_strdup(ctx, lp_comment(snum)); psd = q_u->info.share.info1501.sdb->sd; map_generic_share_sd_bits(psd); type = STYPE_DISKTREE; @@ -1605,7 +1665,7 @@ WERROR _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 WERR_ACCESS_DENIED; - + /* Check if the pathname is valid. */ if (!(path = valid_share_pathname(p->mem_ctx, pathname ))) return WERR_OBJECT_PATH_INVALID; @@ -1613,45 +1673,57 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S /* Ensure share name, pathname and comment don't contain '"' characters. */ string_replace(share_name, '"', ' '); string_replace(path, '"', ' '); - string_replace(comment, '"', ' '); + if (comment) { + string_replace(comment, '"', ' '); + } DEBUG(10,("_srv_net_share_set_info: change share command = %s\n", lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" )); /* Only call modify function if something changed. */ - - if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) - || (lp_max_connections(snum) != max_connections) ) - { + + if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) + || (lp_max_connections(snum) != max_connections)) { if (!lp_change_share_cmd() || !*lp_change_share_cmd()) { DEBUG(10,("_srv_net_share_set_info: No change share command\n")); return WERR_ACCESS_DENIED; } - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", - lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment, max_connections ); + command = talloc_asprintf(p->mem_ctx, + "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", + lp_change_share_cmd(), + dyn_CONFIGFILE, + share_name, + path, + comment ? comment : "", + max_connections); + if (!command) { + return WERR_NOMEM; + } DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command )); - + /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ - - if ( is_disk_op ) + + if (is_disk_op) become_root(); - + if ( (ret = smbrun(command, NULL)) == 0 ) { /* Tell everyone we updated smb.conf. */ message_send_all(smbd_messaging_context(), MSG_SMB_CONF_UPDATED, NULL, 0, NULL); } - + if ( is_disk_op ) unbecome_root(); - + /********* END SeDiskOperatorPrivilege BLOCK *********/ DEBUG(3,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret )); - + + TALLOC_FREE(command); + if ( ret != 0 ) return WERR_ACCESS_DENIED; } else { @@ -1671,24 +1743,24 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S share_name )); } } - + DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); return WERR_OK; } /******************************************************************* - Net share add. Call 'add_share_command "sharename" "pathname" + Net share add. Call 'add_share_command "sharename" "pathname" "comment" "max connections = " ********************************************************************/ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) { struct current_user user; - pstring command; - fstring share_name; - fstring comment; - pstring pathname; + char *command = NULL; + char *share_name = NULL; + char *comment = NULL; + char *pathname = NULL; int type; int snum; int ret; @@ -1697,6 +1769,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S SE_PRIV se_diskop = SE_DISK_OPERATOR; bool is_disk_op; int max_connections = 0; + TALLOC_CTX *ctx = p->mem_ctx; DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); @@ -1706,14 +1779,14 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); - if (user.ut.uid != sec_initial_uid() && !is_disk_op ) + if (user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; if (!lp_add_share_cmd() || !*lp_add_share_cmd()) { DEBUG(10,("_srv_net_share_add: No add share command\n")); return WERR_ACCESS_DENIED; } - + switch (q_u->info_level) { case 0: /* No path. Not enough info in a level 0 to do anything. */ @@ -1722,9 +1795,12 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S /* Not enough info in a level 1 to do anything. */ return WERR_ACCESS_DENIED; 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)); - unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name)); + share_name = unistr2_to_ascii_talloc(ctx, + &q_u->info.share.info2.info_2_str.uni_netname); + comment = unistr2_to_ascii_talloc(ctx, + &q_u->info.share.info2.info_2_str.uni_remark); + pathname = unistr2_to_ascii_talloc(ctx, + &q_u->info.share.info2.info_2_str.uni_path); max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; type = q_u->info.share.info2.info_2.type; break; @@ -1732,9 +1808,12 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S /* No path. Not enough info in a level 501 to do anything. */ return WERR_ACCESS_DENIED; case 502: - unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name)); - unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name)); - unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name)); + share_name = unistr2_to_ascii_talloc(ctx, + &q_u->info.share.info502.info_502_str.uni_netname); + comment = unistr2_to_ascii_talloc(ctx, + &q_u->info.share.info502.info_502_str.uni_remark); + pathname = unistr2_to_ascii_talloc(ctx, + &q_u->info.share.info502.info_502_str.uni_path); type = q_u->info.share.info502.info_502.type; psd = q_u->info.share.info502.info_502_str.sd; map_generic_share_sd_bits(psd); @@ -1757,48 +1836,60 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S /* check for invalid share names */ - if ( !validate_net_name( share_name, INVALID_SHARENAME_CHARS, sizeof(share_name) ) ) { - DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", share_name)); + if (!share_name || !validate_net_name(share_name, + INVALID_SHARENAME_CHARS, + strlen(share_name))) { + DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", + share_name ? share_name : "")); return WERR_INVALID_NAME; } - if ( strequal(share_name,"IPC$") || strequal(share_name,"global") - || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) ) - { + if (strequal(share_name,"IPC$") || strequal(share_name,"global") + || (lp_enable_asu_support() && + strequal(share_name,"ADMIN$"))) { return WERR_ACCESS_DENIED; } snum = find_service(share_name); /* Share already exists. */ - if (snum >= 0) + if (snum >= 0) { return WERR_ALREADY_EXISTS; + } /* We can only add disk shares. */ - if (type != STYPE_DISKTREE) + if (type != STYPE_DISKTREE) { return WERR_ACCESS_DENIED; - + } + /* Check if the pathname is valid. */ - if (!(path = valid_share_pathname(p->mem_ctx, pathname ))) + if (!(path = valid_share_pathname(p->mem_ctx, pathname))) { return WERR_OBJECT_PATH_INVALID; + } /* Ensure share name, pathname and comment don't contain '"' characters. */ string_replace(share_name, '"', ' '); string_replace(path, '"', ' '); - string_replace(comment, '"', ' '); - - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", - lp_add_share_cmd(), - dyn_CONFIGFILE, - share_name, - path, - comment, + if (comment) { + string_replace(comment, '"', ' '); + } + + command = talloc_asprintf(ctx, + "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", + lp_add_share_cmd(), + dyn_CONFIGFILE, + share_name, + path, + comment ? comment : "", max_connections); - + if (!command) { + return WERR_NOMEM; + } + DEBUG(10,("_srv_net_share_add: Running [%s]\n", command )); - + /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ - + if ( is_disk_op ) become_root(); @@ -1810,11 +1901,13 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S if ( is_disk_op ) unbecome_root(); - + /********* END SeDiskOperatorPrivilege BLOCK *********/ DEBUG(3,("_srv_net_share_add: Running [%s] returned (%d)\n", command, ret )); + TALLOC_FREE(command); + if ( ret != 0 ) return WERR_ACCESS_DENIED; @@ -1843,29 +1936,33 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) { struct current_user user; - pstring command; - fstring share_name; + char *command = NULL; + char *share_name = NULL; int ret; int snum; SE_PRIV se_diskop = SE_DISK_OPERATOR; bool is_disk_op; - struct share_params *params; + struct share_params *params; + TALLOC_CTX *ctx = p->mem_ctx; DEBUG(5,("_srv_net_share_del: %d\n", __LINE__)); - unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name)); + share_name = unistr2_to_ascii_talloc(ctx, &q_u->uni_share_name); - if ( strequal(share_name,"IPC$") + if (!share_name) { + return WERR_NET_NAME_NOT_FOUND; + } + if ( strequal(share_name,"IPC$") || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) || strequal(share_name,"global") ) { return WERR_ACCESS_DENIED; } - if (!(params = get_share_params(p->mem_ctx, share_name))) { - return WERR_NO_SUCH_SHARE; - } - + if (!(params = get_share_params(p->mem_ctx, share_name))) { + return WERR_NO_SUCH_SHARE; + } + snum = find_service(share_name); /* No change to printer shares. */ @@ -1876,21 +1973,27 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); - if (user.ut.uid != sec_initial_uid() && !is_disk_op ) + if (user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) { DEBUG(10,("_srv_net_share_del: No delete share command\n")); return WERR_ACCESS_DENIED; } - - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", - lp_delete_share_cmd(), dyn_CONFIGFILE, lp_servicename(snum)); + + command = talloc_asprintf(ctx, + "%s \"%s\" \"%s\"", + lp_delete_share_cmd(), + dyn_CONFIGFILE, + lp_servicename(snum)); + if (!command) { + return WERR_NOMEM; + } DEBUG(10,("_srv_net_share_del: Running [%s]\n", command )); /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ - + if ( is_disk_op ) become_root(); @@ -1902,7 +2005,7 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S if ( is_disk_op ) unbecome_root(); - + /********* END SeDiskOperatorPrivilege BLOCK *********/ DEBUG(3,("_srv_net_share_del: Running [%s] returned (%d)\n", command, ret )); @@ -1983,22 +2086,26 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC SEC_DESC *psd = NULL; size_t sd_size; DATA_BLOB null_pw; - pstring filename_in; + char *filename_in = NULL; char *filename = NULL; - pstring qualname; + char *qualname = NULL; files_struct *fsp = NULL; SMB_STRUCT_STAT st; NTSTATUS nt_status; struct current_user user; connection_struct *conn = NULL; bool became_user = False; - TALLOC_CTX *ctx = talloc_tos(); + TALLOC_CTX *ctx = p->mem_ctx; ZERO_STRUCT(st); r_u->status = WERR_OK; - unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); + qualname = unistr2_to_ascii_talloc(ctx, &q_u->uni_qual_name); + if (!qualname) { + r_u->status = WERR_ACCESS_DENIED; + goto error_exit; + } /* Null password is ok - we are already an authenticated user... */ null_pw = data_blob_null; @@ -2022,7 +2129,12 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC } became_user = True; - unistr2_to_ascii(filename_in, &q_u->uni_file_name, sizeof(filename_in)); + filename_in = unistr2_to_ascii_talloc(ctx, &q_u->uni_file_name); + if (!filename_in) { + r_u->status = WERR_ACCESS_DENIED; + goto error_exit; + } + nt_status = unix_convert(ctx, conn, filename_in, False, &filename, NULL, &st); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", filename)); @@ -2090,7 +2202,7 @@ error_exit: if (became_user) unbecome_user(); - if (conn) + if (conn) close_cnum(conn, user.vuid); return r_u->status; @@ -2103,9 +2215,9 @@ error_exit: WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_u, SRV_R_NET_FILE_SET_SECDESC *r_u) { - pstring filename_in; + char *filename_in = NULL; char *filename = NULL; - pstring qualname; + char *qualname = NULL; DATA_BLOB null_pw; files_struct *fsp = NULL; SMB_STRUCT_STAT st; @@ -2113,13 +2225,17 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ struct current_user user; connection_struct *conn = NULL; bool became_user = False; - TALLOC_CTX *ctx = talloc_tos(); + TALLOC_CTX *ctx = p->mem_ctx; ZERO_STRUCT(st); r_u->status = WERR_OK; - unistr2_to_ascii(qualname, &q_u->uni_qual_name, sizeof(qualname)); + qualname = unistr2_to_ascii_talloc(ctx, &q_u->uni_qual_name); + if (!qualname) { + r_u->status = WERR_ACCESS_DENIED; + goto error_exit; + } /* Null password is ok - we are already an authenticated user... */ null_pw = data_blob_null; @@ -2143,7 +2259,12 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ } became_user = True; - unistr2_to_ascii(filename_in, &q_u->uni_file_name, sizeof(filename_in)); + filename_in= unistr2_to_ascii_talloc(ctx, &q_u->uni_file_name); + if (!filename_in) { + r_u->status = WERR_ACCESS_DENIED; + goto error_exit; + } + nt_status = unix_convert(ctx, conn, filename, False, &filename, NULL, &st); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", filename)); @@ -2158,7 +2279,6 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ goto error_exit; } - nt_status = open_file_stat(conn, NULL, filename, &st, &fsp); if ( !NT_STATUS_IS_OK(nt_status) ) { -- cgit From 2cda3e78445da8f53f8358ae38892ab799c3dd3a Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Nov 2007 17:48:59 -0800 Subject: Whitespace cleanup. Jeremy. (This used to be commit 3052172d2bfe9d787777525e90816394aac2dd54) --- source3/rpc_server/srv_spoolss_nt.c | 2072 +++++++++++++++++------------------ 1 file changed, 1035 insertions(+), 1037 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d49731272f..f18c120a9f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -50,7 +50,7 @@ static Printer_entry *printers_list; typedef struct _counter_printer_0 { struct _counter_printer_0 *next; struct _counter_printer_0 *prev; - + int snum; uint32 counter; } counter_printer_0; @@ -139,7 +139,7 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle) { WERROR result; - /* + /* * Tell the specific printing tdb we no longer want messages for this printer * by deregistering our PID. */ @@ -154,7 +154,7 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle) } result = rpccli_spoolss_reply_close_printer(notify_cli_pipe, notify_cli_pipe->cli->mem_ctx, handle); - + if (!W_ERROR_IS_OK(result)) DEBUG(0,("srv_spoolss_replycloseprinter: reply_close_printer failed [%s].\n", dos_errstr(result))); @@ -206,10 +206,10 @@ static void free_printer_entry(void *ptr) free_spool_notify_option(&Printer->notify.option); Printer->notify.option=NULL; Printer->notify.client_connected=False; - + free_nt_devicemode( &Printer->nt_devmode ); free_a_printer( &Printer->printer_info, 2 ); - + talloc_destroy( Printer->ctx ); /* Remove from the internal list. */ @@ -279,7 +279,7 @@ static bool close_printer_handle(pipes_struct *p, POLICY_HND *hnd) close_policy_hnd(p, hnd); return True; -} +} /**************************************************************************** Delete a printer given a handle. @@ -291,46 +291,46 @@ WERROR delete_printer_hook( NT_USER_TOKEN *token, const char *sharename ) int ret; SE_PRIV se_printop = SE_PRINT_OPERATOR; bool is_print_op = False; - + /* can't fail if we don't try */ - + if ( !*cmd ) return WERR_OK; - + pstr_sprintf(command, "%s \"%s\"", cmd, sharename); if ( token ) is_print_op = user_has_privileges( token, &se_printop ); - + DEBUG(10,("Running [%s]\n", command)); /********** BEGIN SePrintOperatorPrivlege BLOCK **********/ - + if ( is_print_op ) become_root(); - + if ( (ret = smbrun(command, NULL)) == 0 ) { /* Tell everyone we updated smb.conf. */ message_send_all(smbd_messaging_context(), MSG_SMB_CONF_UPDATED, NULL, 0, NULL); } - + if ( is_print_op ) unbecome_root(); /********** END SePrintOperatorPrivlege BLOCK **********/ - + DEBUGADD(10,("returned [%d]\n", ret)); - if (ret != 0) + if (ret != 0) return WERR_BADFID; /* What to return here? */ /* go ahead and re-read the services immediately */ reload_services( False ); - + if ( lp_servicenumber( sharename ) < 0 ) return WERR_ACCESS_DENIED; - + return WERR_OK; } @@ -347,7 +347,7 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) return WERR_BADFID; } - /* + /* * It turns out that Windows allows delete printer on a handle * opened by an admin user, then used on a pipe handle created * by an anonymous user..... but they're working on security.... riiight ! @@ -358,10 +358,10 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) DEBUG(3, ("delete_printer_handle: denied by handle\n")); return WERR_ACCESS_DENIED; } - - /* this does not need a become root since the access check has been + + /* this does not need a become root since the access check has been done on the handle already */ - + if (del_a_printer( Printer->sharename ) != 0) { DEBUG(3,("Error deleting printer %s\n", Printer->sharename)); return WERR_BADFID; @@ -378,15 +378,15 @@ static bool get_printer_snum(pipes_struct *p, POLICY_HND *hnd, int *number, struct share_params **params) { Printer_entry *Printer = find_printer_index_by_hnd(p, hnd); - + if (!Printer) { DEBUG(2,("get_printer_snum: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(hnd))); return False; } - + switch (Printer->printer_type) { - case SPLHND_PRINTER: - DEBUG(4,("short name:%s\n", Printer->sharename)); + case SPLHND_PRINTER: + DEBUG(4,("short name:%s\n", Printer->sharename)); *number = print_queue_snum(Printer->sharename); return (*number != -1); case SPLHND_SERVER: @@ -413,7 +413,7 @@ static bool set_printer_hnd_printertype(Printer_entry *Printer, char *handlename /* it's a print server */ if (*handlename=='\\' && *(handlename+1)=='\\' && !strchr_m(handlename+2, '\\')) { DEBUGADD(4,("Printer is a print server\n")); - Printer->printer_type = SPLHND_SERVER; + Printer->printer_type = SPLHND_SERVER; } /* it's a printer (set_printer_hnd_name() will handle port monitors */ else { @@ -425,9 +425,9 @@ static bool set_printer_hnd_printertype(Printer_entry *Printer, char *handlename } /**************************************************************************** - Set printer handle name.. Accept names like \\server, \\server\printer, + Set printer handle name.. Accept names like \\server, \\server\printer, \\server\SHARE, & "\\server\,XcvMonitor Standard TCP/IP Port" See - the MSDN docs regarding OpenPrinter() for details on the XcvData() and + the MSDN docs regarding OpenPrinter() for details on the XcvData() and XcvDataPort() interface. ****************************************************************************/ @@ -441,7 +441,7 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename) bool found=False; NT_PRINTER_INFO_LEVEL *printer = NULL; WERROR result; - + DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename, (unsigned long)strlen(handlename))); aprinter = handlename; @@ -455,14 +455,14 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename) else { servername = ""; } - + /* save the servername to fill in replies on this handle */ - + if ( !is_myname_or_ipaddr( servername ) ) return False; fstrcpy( Printer->servername, servername ); - + if ( Printer->printer_type == SPLHND_SERVER ) return True; @@ -470,9 +470,9 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename) return False; DEBUGADD(5, ("searching for [%s]\n", aprinter )); - + /* check for the Port Monitor Interface */ - + if ( strequal( aprinter, SPL_XCV_MONITOR_TCPMON ) ) { Printer->printer_type = SPLHND_PORTMON_TCP; fstrcpy(sname, SPL_XCV_MONITOR_TCPMON); @@ -484,12 +484,12 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename) found = True; } - /* Search all sharenames first as this is easier than pulling + /* Search all sharenames first as this is easier than pulling the printer_info_2 off of disk. Don't use find_service() since that calls out to map_username() */ - + /* do another loop to look for printernames */ - + for (snum=0; !found && snuminfo_2->printername[2], '\\')) ) { DEBUG(0,("set_printer_hnd_name: info2->printername in wrong format! [%s]\n", @@ -526,17 +526,17 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename) free_a_printer( &printer, 2); continue; } - + printername++; - + if ( strequal(printername, aprinter) ) { free_a_printer( &printer, 2); found = True; break; } - + DEBUGADD(10, ("printername: %s\n", printername)); - + free_a_printer( &printer, 2); } @@ -546,7 +546,7 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename) DEBUGADD(4,("Printer not found\n")); return False; } - + DEBUGADD(4,("set_printer_hnd_name: Printer found: %s -> %s\n", aprinter, sname)); fstrcpy(Printer->sharename, sname); @@ -568,28 +568,28 @@ static bool open_printer_hnd(pipes_struct *p, POLICY_HND *hnd, char *name, uint3 return False; ZERO_STRUCTP(new_printer); - + if (!create_policy_hnd(p, hnd, free_printer_entry, new_printer)) { SAFE_FREE(new_printer); return False; } - + /* Add to the internal list. */ DLIST_ADD(printers_list, new_printer); - + new_printer->notify.option=NULL; - + if ( !(new_printer->ctx = talloc_init("Printer Entry [%p]", hnd)) ) { DEBUG(0,("open_printer_hnd: talloc_init() failed!\n")); close_printer_handle(p, hnd); return False; } - + if (!set_printer_hnd_printertype(new_printer, name)) { close_printer_handle(p, hnd); return False; } - + if (!set_printer_hnd_name(new_printer, name)) { close_printer_handle(p, hnd); return False; @@ -619,10 +619,10 @@ static bool is_monitoring_event(Printer_entry *p, uint16 notify_type, SPOOL_NOTIFY_OPTION *option = p->notify.option; uint32 i, j; - /* + /* * Flags should always be zero when the change notify * is registered by the client's spooler. A user Win32 app - * might use the flags though instead of the NOTIFY_OPTION_INFO + * might use the flags though instead of the NOTIFY_OPTION_INFO * --jerry */ @@ -635,24 +635,24 @@ static bool is_monitoring_event(Printer_entry *p, uint16 notify_type, p->notify.flags, notify_type, notify_field); for (i = 0; i < option->count; i++) { - + /* Check match for notify_type */ - + if (option->ctr.type[i].type != notify_type) continue; /* Check match for field */ - + for (j = 0; j < option->ctr.type[i].count; j++) { if (option->ctr.type[i].fields[j] == notify_field) { return True; } } } - + DEBUG(10, ("Open handle for \\\\%s\\%s is not monitoring 0x%02x/0x%02x\n", p->servername, p->sharename, notify_type, notify_field)); - + return False; } @@ -671,7 +671,7 @@ static void notify_string(struct spoolss_notify_msg *msg, TALLOC_CTX *mem_ctx) { UNISTR2 unistr; - + /* The length of the message includes the trailing \0 */ init_unistr2(&unistr, msg->notify.data, UNI_STR_TERMINATE); @@ -683,7 +683,7 @@ static void notify_string(struct spoolss_notify_msg *msg, data->notify_data.data.length = 0; return; } - + memcpy(data->notify_data.data.string, unistr.buffer, msg->len * 2); } @@ -791,21 +791,21 @@ static struct notify2_message_table job_notify_table[] = { /*********************************************************************** Allocate talloc context for container object **********************************************************************/ - + static void notify_msg_ctr_init( SPOOLSS_NOTIFY_MSG_CTR *ctr ) { if ( !ctr ) return; ctr->ctx = talloc_init("notify_msg_ctr_init %p", ctr); - + return; } /*********************************************************************** release all allocated memory and zero out structure **********************************************************************/ - + static void notify_msg_ctr_destroy( SPOOLSS_NOTIFY_MSG_CTR *ctr ) { if ( !ctr ) @@ -813,34 +813,34 @@ static void notify_msg_ctr_destroy( SPOOLSS_NOTIFY_MSG_CTR *ctr ) if ( ctr->ctx ) talloc_destroy(ctr->ctx); - + ZERO_STRUCTP(ctr); - + return; } /*********************************************************************** **********************************************************************/ - + static TALLOC_CTX* notify_ctr_getctx( SPOOLSS_NOTIFY_MSG_CTR *ctr ) { if ( !ctr ) return NULL; - + return ctr->ctx; } /*********************************************************************** **********************************************************************/ - + static SPOOLSS_NOTIFY_MSG_GROUP* notify_ctr_getgroup( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) { if ( !ctr || !ctr->msg_groups ) return NULL; - + if ( idx >= ctr->num_groups ) return NULL; - + return &ctr->msg_groups[idx]; } @@ -848,38 +848,38 @@ static SPOOLSS_NOTIFY_MSG_GROUP* notify_ctr_getgroup( SPOOLSS_NOTIFY_MSG_CTR *ct /*********************************************************************** How many groups of change messages do we have ? **********************************************************************/ - + static int notify_msg_ctr_numgroups( SPOOLSS_NOTIFY_MSG_CTR *ctr ) { if ( !ctr ) return 0; - + return ctr->num_groups; } /*********************************************************************** Add a SPOOLSS_NOTIFY_MSG_CTR to the correct group **********************************************************************/ - + static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MSG *msg ) { SPOOLSS_NOTIFY_MSG_GROUP *groups = NULL; SPOOLSS_NOTIFY_MSG_GROUP *msg_grp = NULL; SPOOLSS_NOTIFY_MSG *msg_list = NULL; int i, new_slot; - + if ( !ctr || !msg ) return 0; - + /* loop over all groups looking for a matching printer name */ - + for ( i=0; inum_groups; i++ ) { if ( strcmp(ctr->msg_groups[i].printername, msg->printer) == 0 ) break; } - + /* add a new group? */ - + if ( i == ctr->num_groups ) { ctr->num_groups++; @@ -890,37 +890,37 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS ctr->msg_groups = groups; /* clear the new entry and set the printer name */ - + ZERO_STRUCT( ctr->msg_groups[ctr->num_groups-1] ); fstrcpy( ctr->msg_groups[ctr->num_groups-1].printername, msg->printer ); } - + /* add the change messages; 'i' is the correct index now regardless */ - + msg_grp = &ctr->msg_groups[i]; - + msg_grp->num_msgs++; - + if ( !(msg_list = TALLOC_REALLOC_ARRAY( ctr->ctx, msg_grp->msgs, SPOOLSS_NOTIFY_MSG, msg_grp->num_msgs )) ) { DEBUG(0,("notify_msg_ctr_addmsg: talloc_realloc() failed for new message [%d]!\n", msg_grp->num_msgs)); return 0; } msg_grp->msgs = msg_list; - + new_slot = msg_grp->num_msgs-1; memcpy( &msg_grp->msgs[new_slot], msg, sizeof(SPOOLSS_NOTIFY_MSG) ); - + /* need to allocate own copy of data */ - - if ( msg->len != 0 ) + + if ( msg->len != 0 ) msg_grp->msgs[new_slot].notify.data = (char *) TALLOC_MEMDUP( ctr->ctx, msg->notify.data, msg->len ); - + return ctr->num_groups; } /*********************************************************************** - Send a change notication message on all handles which have a call + Send a change notication message on all handles which have a call back registered **********************************************************************/ @@ -931,23 +931,23 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) SPOOLSS_NOTIFY_MSG_GROUP *msg_group = notify_ctr_getgroup( ctr, idx ); SPOOLSS_NOTIFY_MSG *messages; int sending_msg_count; - + if ( !msg_group ) { DEBUG(5,("send_notify2_changes() called with no msg group!\n")); return; } - + messages = msg_group->msgs; - + if ( !messages ) { DEBUG(5,("send_notify2_changes() called with no messages!\n")); return; } - + DEBUG(8,("send_notify2_changes: Enter...[%s]\n", msg_group->printername)); - + /* loop over all printers */ - + for (p = printers_list; p; p = p->next) { SPOOL_NOTIFY_INFO_DATA *data; uint32 data_len = 0; @@ -961,7 +961,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) DEBUG(10,("Client connected! [\\\\%s\\%s]\n", p->servername, p->sharename)); - /* For this printer? Print servers always receive + /* For this printer? Print servers always receive notifications. */ if ( ( p->printer_type == SPLHND_PRINTER ) && @@ -969,40 +969,40 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) continue; DEBUG(10,("Our printer\n")); - + /* allocate the max entries possible */ - + data = TALLOC_ARRAY( mem_ctx, SPOOL_NOTIFY_INFO_DATA, msg_group->num_msgs); if (!data) { return; } ZERO_STRUCTP(data); - + /* build the array of change notifications */ - + sending_msg_count = 0; - + for ( i=0; inum_msgs; i++ ) { SPOOLSS_NOTIFY_MSG *msg = &messages[i]; - + /* Are we monitoring this event? */ if (!is_monitoring_event(p, msg->type, msg->field)) continue; sending_msg_count++; - - + + DEBUG(10,("process_notify2_message: Sending message type [0x%x] field [0x%2x] for printer [%s]\n", msg->type, msg->field, p->sharename)); - /* - * if the is a printer notification handle and not a job notification + /* + * if the is a printer notification handle and not a job notification * type, then set the id to 0. Other wise just use what was specified - * in the message. + * in the message. * - * When registering change notification on a print server handle + * When registering change notification on a print server handle * we always need to send back the id (snum) matching the printer * for which the change took place. For change notify registered * on a printer handle, this does not matter and the id should be 0. @@ -1034,7 +1034,7 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) if ( printer_notify_table[msg->field].fn ) printer_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); break; - + case JOB_NOTIFY_TYPE: if ( job_notify_table[msg->field].fn ) job_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx); @@ -1049,11 +1049,11 @@ static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx ) } if ( sending_msg_count ) { - rpccli_spoolss_rrpcn( notify_cli_pipe, mem_ctx, &p->notify.client_hnd, + rpccli_spoolss_rrpcn( notify_cli_pipe, mem_ctx, &p->notify.client_hnd, data_len, data, p->notify.change, 0 ); } } - + done: DEBUG(8,("send_notify2_changes: Exit...\n")); return; @@ -1072,7 +1072,7 @@ static bool notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, voi offset += tdb_unpack((uint8 *)buf + offset, len - offset, "f", msg->printer); - + offset += tdb_unpack((uint8 *)buf + offset, len - offset, "ddddddd", &tv_sec, &tv_usec, &msg->type, &msg->field, &msg->id, &msg->len, &msg->flags); @@ -1081,7 +1081,7 @@ static bool notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, voi tdb_unpack((uint8 *)buf + offset, len - offset, "dd", &msg->notify.value[0], &msg->notify.value[1]); else - tdb_unpack((uint8 *)buf + offset, len - offset, "B", + tdb_unpack((uint8 *)buf + offset, len - offset, "B", &msg->len, &msg->notify.data); DEBUG(3, ("notify2_unpack_msg: got NOTIFY2 message for printer %s, jobid %u type %d, field 0x%02x, flags 0x%04x\n", @@ -1121,7 +1121,7 @@ static void receive_notify2_message_list(struct messaging_context *msg, DEBUG(0,("receive_notify2_message_list: bad message format (len < 4)!\n")); return; } - + msg_count = IVAL(buf, 0); msg_ptr = buf + 4; @@ -1133,17 +1133,17 @@ static void receive_notify2_message_list(struct messaging_context *msg, } /* initialize the container */ - + ZERO_STRUCT( messages ); notify_msg_ctr_init( &messages ); - - /* + + /* * build message groups for each printer identified * in a change_notify msg. Remember that a PCN message * includes the handle returned for the srv_spoolss_replyopenprinter() * call. Therefore messages are grouped according to printer handle. */ - + for ( i=0; ilength,sizeof(drivername)-1); strncpy(drivername, (const char *)data->data, len); - + DEBUG(10,("do_drv_upgrade_printer: Got message for new driver [%s]\n", drivername )); /* Iterate the printer list */ - + for (snum=0; snuminfo_2 && !strcmp(drivername, printer->info_2->drivername)) + + if (printer && printer->info_2 && !strcmp(drivername, printer->info_2->drivername)) { DEBUG(6,("Updating printer [%s]\n", printer->info_2->printername)); - + /* all we care about currently is the change_id */ - + result = mod_a_printer(printer, 2); if (!W_ERROR_IS_OK(result)) { - DEBUG(3,("do_drv_upgrade_printer: mod_a_printer() failed with status [%s]\n", + DEBUG(3,("do_drv_upgrade_printer: mod_a_printer() failed with status [%s]\n", dos_errstr(result))); } } - - free_a_printer(&printer, 2); + + free_a_printer(&printer, 2); } } - - /* all done */ + + /* all done */ } /******************************************************************** - Update the cache for all printq's with a registered client + Update the cache for all printq's with a registered client connection ********************************************************************/ @@ -1278,21 +1278,21 @@ void update_monitored_printq_cache( void ) { Printer_entry *printer = printers_list; int snum; - - /* loop through all printers and update the cache where + + /* loop through all printers and update the cache where client_connected == True */ - while ( printer ) + while ( printer ) { - if ( (printer->printer_type == SPLHND_PRINTER) - && printer->notify.client_connected ) + if ( (printer->printer_type == SPLHND_PRINTER) + && printer->notify.client_connected ) { snum = print_queue_snum(printer->sharename); print_queue_status( snum, NULL, NULL ); } - + printer = printer->next; } - + return; } /******************************************************************** @@ -1300,17 +1300,17 @@ void update_monitored_printq_cache( void ) so we can upgrade the information for each printer bound to this driver ********************************************************************/ - + static bool srv_spoolss_reset_printerdata(char* drivername) { int len = strlen(drivername); - + if (!len) return False; DEBUG(10,("srv_spoolss_reset_printerdata: Sending message about resetting printerdata [%s]\n", drivername)); - + messaging_send_buf(smbd_messaging_context(), procid_self(), MSG_PRINTERDATA_INIT_RESET, (uint8 *)drivername, len+1); @@ -1320,9 +1320,9 @@ static bool srv_spoolss_reset_printerdata(char* drivername) /********************************************************************** callback to receive a MSG_PRINTERDATA_INIT_RESET message and interate - over all printers, resetting printer data as neessary + over all printers, resetting printer data as neessary **********************************************************************/ - + void reset_all_printerdata(struct messaging_context *msg, void *private_data, uint32_t msg_type, @@ -1333,52 +1333,52 @@ void reset_all_printerdata(struct messaging_context *msg, int snum; int n_services = lp_numservices(); size_t len; - + len = MIN( data->length, sizeof(drivername)-1 ); strncpy( drivername, (const char *)data->data, len ); - + DEBUG(10,("reset_all_printerdata: Got message for new driver [%s]\n", drivername )); /* Iterate the printer list */ - + for ( snum=0; snuminfo_2 && !strcmp(drivername, printer->info_2->drivername) ) + + if ( printer && printer->info_2 && !strcmp(drivername, printer->info_2->drivername) ) { DEBUG(6,("reset_all_printerdata: Updating printer [%s]\n", printer->info_2->printername)); - + if ( !set_driver_init(printer, 2) ) { DEBUG(5,("reset_all_printerdata: Error resetting printer data for printer [%s], driver [%s]!\n", printer->info_2->printername, printer->info_2->drivername)); - } - + } + result = mod_a_printer( printer, 2 ); if ( !W_ERROR_IS_OK(result) ) { - DEBUG(3,("reset_all_printerdata: mod_a_printer() failed! (%s)\n", + DEBUG(3,("reset_all_printerdata: mod_a_printer() failed! (%s)\n", get_dos_error_msg(result))); } } - + free_a_printer( &printer, 2 ); } } - - /* all done */ - + + /* all done */ + return; } @@ -1393,17 +1393,17 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode) if (!devmode) return NULL; - + DEBUG (8,("dup_devmode\n")); - + /* bulk copy first */ - + d = (DEVICEMODE *)TALLOC_MEMDUP(ctx, devmode, sizeof(DEVICEMODE)); if (!d) return NULL; - + /* dup the pointer members separately */ - + len = unistrlen(devmode->devicename.buffer); if (len != -1) { d->devicename.buffer = TALLOC_ARRAY(ctx, uint16, len); @@ -1413,7 +1413,7 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode) if (unistrcpy(d->devicename.buffer, devmode->devicename.buffer) != len) return NULL; } - + len = unistrlen(devmode->formname.buffer); if (len != -1) { @@ -1430,7 +1430,7 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode) devmode->driverextra); if (!d->dev_private) { return NULL; - } + } } else { d->dev_private = NULL; } @@ -1441,12 +1441,12 @@ static void copy_devmode_ctr(TALLOC_CTX *ctx, DEVMODE_CTR *new_ctr, DEVMODE_CTR { if (!new_ctr || !ctr) return; - + DEBUG(8,("copy_devmode_ctr\n")); - + new_ctr->size = ctr->size; new_ctr->devmode_ptr = ctr->devmode_ptr; - + if(ctr->devmode_ptr) new_ctr->devmode = dup_devicemode(ctx, ctr->devmode); } @@ -1455,21 +1455,21 @@ static void copy_printer_default(TALLOC_CTX *ctx, PRINTER_DEFAULT *new_def, PRIN { if (!new_def || !def) return; - + DEBUG(8,("copy_printer_defaults\n")); - + new_def->datatype_ptr = def->datatype_ptr; - + if (def->datatype_ptr) copy_unistr2(&new_def->datatype, &def->datatype); - + copy_devmode_ctr(ctx, &new_def->devmode_cont, &def->devmode_cont); - + new_def->access_required = def->access_required; } /******************************************************************** - * Convert a SPOOL_Q_OPEN_PRINTER structure to a + * Convert a SPOOL_Q_OPEN_PRINTER structure to a * SPOOL_Q_OPEN_PRINTER_EX structure ********************************************************************/ @@ -1479,14 +1479,14 @@ static WERROR convert_to_openprinterex(TALLOC_CTX *ctx, SPOOL_Q_OPEN_PRINTER_EX return WERR_OK; DEBUG(8,("convert_to_openprinterex\n")); - + if ( q_u->printername ) { q_u_ex->printername = TALLOC_ZERO_P( ctx, UNISTR2 ); if (q_u_ex->printername == NULL) return WERR_NOMEM; copy_unistr2(q_u_ex->printername, q_u->printername); } - + copy_printer_default(ctx, &q_u_ex->printer_default, &q_u->printer_default); return WERR_OK; @@ -1502,25 +1502,25 @@ WERROR _spoolss_open_printer(pipes_struct *p, SPOOL_Q_OPEN_PRINTER *q_u, SPOOL_R { SPOOL_Q_OPEN_PRINTER_EX q_u_ex; SPOOL_R_OPEN_PRINTER_EX r_u_ex; - + if (!q_u || !r_u) return WERR_NOMEM; - + ZERO_STRUCT(q_u_ex); ZERO_STRUCT(r_u_ex); - + /* convert the OpenPrinter() call to OpenPrinterEx() */ - + r_u_ex.status = convert_to_openprinterex(p->mem_ctx, &q_u_ex, q_u); if (!W_ERROR_IS_OK(r_u_ex.status)) return r_u_ex.status; - + r_u_ex.status = _spoolss_open_printer_ex(p, &q_u_ex, &r_u_ex); - + /* convert back to OpenPrinter() */ - + memcpy(r_u, &r_u_ex, sizeof(*r_u)); - + return r_u->status; } @@ -1548,7 +1548,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, if (!open_printer_hnd(p, handle, name, 0)) return WERR_INVALID_PRINTER_NAME; - + Printer=find_printer_index_by_hnd(p, handle); if ( !Printer ) { DEBUG(0,(" _spoolss_open_printer_ex: logic error. Can't find printer " @@ -1572,16 +1572,16 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, * * Note: this test needs code to check access rights here too. Jeremy * could you look at this? - * + * * Second case: the user is opening a printer: * NT doesn't let us connect to a printer if the connecting user * doesn't have print permission. - * + * * Third case: user is opening a Port Monitor * access checks same as opening a handle to the print server. */ - switch (Printer->printer_type ) + switch (Printer->printer_type ) { case SPLHND_SERVER: case SPLHND_PORTMON_TCP: @@ -1591,10 +1591,10 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, snum = -1; /* Map standard access rights to object specific access rights */ - - se_map_standard(&printer_default->access_required, + + se_map_standard(&printer_default->access_required, &printserver_std_mapping); - + /* Deny any object specific bits that don't apply to print servers (i.e printer and job specific bits) */ @@ -1609,7 +1609,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* Allow admin access */ - if ( printer_default->access_required & SERVER_ACCESS_ADMINISTER ) + if ( printer_default->access_required & SERVER_ACCESS_ADMINISTER ) { SE_PRIV se_printop = SE_PRINT_OPERATOR; @@ -1620,7 +1620,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege, and not a printer admin, then fail */ - + if ((p->pipe_user.ut.uid != 0) && !user_has_privileges(p->pipe_user.nt_user_token, &se_printop ) && @@ -1631,7 +1631,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, close_printer_handle(p, handle); return WERR_ACCESS_DENIED; } - + printer_default->access_required = SERVER_ACCESS_ADMINISTER; } else @@ -1639,9 +1639,9 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, printer_default->access_required = SERVER_ACCESS_ENUMERATE; } - DEBUG(4,("Setting print server access = %s\n", (printer_default->access_required == SERVER_ACCESS_ADMINISTER) + DEBUG(4,("Setting print server access = %s\n", (printer_default->access_required == SERVER_ACCESS_ADMINISTER) ? "SERVER_ACCESS_ADMINISTER" : "SERVER_ACCESS_ENUMERATE" )); - + /* We fall through to return WERR_OK */ break; @@ -1655,7 +1655,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, } se_map_standard(&printer_default->access_required, &printer_std_mapping); - + /* map an empty access mask to the minimum access mask */ if (printer_default->access_required == 0x0) printer_default->access_required = PRINTER_ACCESS_USE; @@ -1663,18 +1663,18 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* * 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 + * will keep NT clients happy --jerry */ - - if (lp_use_client_driver(snum) + + if (lp_use_client_driver(snum) && (printer_default->access_required & PRINTER_ACCESS_ADMINISTER)) { printer_default->access_required = PRINTER_ACCESS_USE; } /* check smb.conf parameters and the the sec_desc */ - - if ( !check_access(smbd_server_fd(), lp_hostsallow(snum), lp_hostsdeny(snum)) ) { + + if ( !check_access(smbd_server_fd(), lp_hostsallow(snum), lp_hostsdeny(snum)) ) { DEBUG(3, ("access DENIED (hosts allow/deny) for printer open\n")); return WERR_ACCESS_DENIED; } @@ -1699,7 +1699,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, else printer_default->access_required = PRINTER_ACCESS_USE; - DEBUG(4,("Setting printer access = %s\n", (printer_default->access_required == PRINTER_ACCESS_ADMINISTER) + DEBUG(4,("Setting printer access = %s\n", (printer_default->access_required == PRINTER_ACCESS_ADMINISTER) ? "PRINTER_ACCESS_ADMINISTER" : "PRINTER_ACCESS_USE" )); break; @@ -1708,26 +1708,26 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, /* sanity check to prevent programmer error */ return WERR_BADFID; } - + Printer->access_granted = printer_default->access_required; - - /* + + /* * If the client sent a devmode in the OpenPrinter() call, then * save it here in case we get a job submission on this handle */ - + if ( (Printer->printer_type != SPLHND_SERVER) && q_u->printer_default.devmode_cont.devmode_ptr ) - { + { convert_devicemode( Printer->sharename, q_u->printer_default.devmode_cont.devmode, &Printer->nt_devmode ); } #if 0 /* JERRY -- I'm doubtful this is really effective */ - /* HACK ALERT!!! Sleep for 1/3 of a second to try trigger a LAN/WAN + /* HACK ALERT!!! Sleep for 1/3 of a second to try trigger a LAN/WAN optimization in Windows 2000 clients --jerry */ - if ( (printer_default->access_required == PRINTER_ACCESS_ADMINISTER) + if ( (printer_default->access_required == PRINTER_ACCESS_ADMINISTER) && (RA_WIN2K == get_remote_arch()) ) { DEBUG(10,("_spoolss_open_printer_ex: Enabling LAN/WAN hack for Win2k clients.\n")); @@ -1748,8 +1748,8 @@ static bool convert_printer_info(const SPOOL_PRINTER_INFO_LEVEL *uni, switch (level) { case 2: - /* allocate memory if needed. Messy because - convert_printer_info is used to update an existing + /* allocate memory if needed. Messy because + convert_printer_info is used to update an existing printer or build a new one */ if ( !printer->info_2 ) { @@ -1801,7 +1801,7 @@ bool convert_devicemode(const char *printername, const DEVICEMODE *devmode, * Ensure nt_devmode is a valid pointer * as we will be overwriting it. */ - + if (nt_devmode == NULL) { DEBUG(5, ("convert_devicemode: allocating a generic devmode\n")); if ((nt_devmode = construct_nt_devicemode(printername)) == NULL) @@ -1875,7 +1875,7 @@ static WERROR _spoolss_enddocprinter_internal(pipes_struct *p, POLICY_HND *handl DEBUG(2,("_spoolss_enddocprinter_internal: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle))); return WERR_BADFID; } - + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; @@ -1900,9 +1900,9 @@ WERROR _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL_R _spoolss_enddocprinter_internal(p, handle); /* print job was not closed */ if (!close_printer_handle(p, handle)) - return WERR_BADFID; - - /* clear the returned printer handle. Observed behavior + return WERR_BADFID; + + /* clear the returned printer handle. Observed behavior from Win2k server. Don't think this really matters. Previous code just copied the value of the closed handle. --jerry */ @@ -1944,23 +1944,23 @@ static int get_version_id (char * arch) { int i; struct table_node archi_table[]= { - + {"Windows 4.0", "WIN40", 0 }, {"Windows NT x86", "W32X86", 2 }, - {"Windows NT R4000", "W32MIPS", 2 }, + {"Windows NT R4000", "W32MIPS", 2 }, {"Windows NT Alpha_AXP", "W32ALPHA", 2 }, {"Windows NT PowerPC", "W32PPC", 2 }, {"Windows IA64", "IA64", 3 }, {"Windows x64", "x64", 3 }, {NULL, "", -1 } }; - + for (i=0; archi_table[i].long_archi != NULL; i++) { if (strcmp(arch, archi_table[i].long_archi) == 0) return (archi_table[i].version); } - + return -1; } @@ -1977,34 +1977,34 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER int version; WERROR status; WERROR status_win2k = WERR_ACCESS_DENIED; - SE_PRIV se_printop = SE_PRINT_OPERATOR; - + SE_PRIV se_printop = SE_PRINT_OPERATOR; + /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege, and not a printer admin, then fail */ - - if ( (p->pipe_user.ut.uid != 0) - && !user_has_privileges(p->pipe_user.nt_user_token, &se_printop ) - && !token_contains_name_in_list( uidtoname(p->pipe_user.ut.uid), - NULL, p->pipe_user.nt_user_token, lp_printer_admin(-1)) ) + + if ( (p->pipe_user.ut.uid != 0) + && !user_has_privileges(p->pipe_user.nt_user_token, &se_printop ) + && !token_contains_name_in_list( uidtoname(p->pipe_user.ut.uid), + NULL, p->pipe_user.nt_user_token, lp_printer_admin(-1)) ) { return WERR_ACCESS_DENIED; } unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)); unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)); - + /* check that we have a valid driver name first */ - - if ((version=get_version_id(arch)) == -1) + + if ((version=get_version_id(arch)) == -1) return WERR_INVALID_ENVIRONMENT; - + ZERO_STRUCT(info); ZERO_STRUCT(info_win2k); - - if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) + + if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) { /* try for Win2k driver if "Windows NT x86" */ - + if ( version == 2 ) { version = 3; if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) { @@ -2017,24 +2017,24 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER status = WERR_UNKNOWN_PRINTER_DRIVER; goto done; } - + } - + if (printer_driver_in_use(info.info_3)) { status = WERR_PRINTER_DRIVER_IN_USE; goto done; } - + if ( version == 2 ) - { + { if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3, driver, arch, 3))) { /* if we get to here, we now have 2 driver info structures to remove */ /* remove the Win2k driver first*/ - + status_win2k = delete_printer_driver(info_win2k.info_3, &p->pipe_user, 3, False ); free_a_printer_driver( info_win2k, 3 ); - + /* this should not have failed---if it did, report to client */ if ( !W_ERROR_IS_OK(status_win2k) ) { @@ -2043,14 +2043,14 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER } } } - + status = delete_printer_driver(info.info_3, &p->pipe_user, version, False); - + /* if at least one of the deletes succeeded return OK */ - + if ( W_ERROR_IS_OK(status) || W_ERROR_IS_OK(status_win2k) ) status = WERR_OK; - + done: free_a_printer_driver( info, 3 ); @@ -2072,19 +2072,19 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV bool delete_files; WERROR status; WERROR status_win2k = WERR_ACCESS_DENIED; - SE_PRIV se_printop = SE_PRINT_OPERATOR; - + SE_PRIV se_printop = SE_PRINT_OPERATOR; + /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege, and not a printer admin, then fail */ - - if ( (p->pipe_user.ut.uid != 0) - && !user_has_privileges(p->pipe_user.nt_user_token, &se_printop ) - && !token_contains_name_in_list( uidtoname(p->pipe_user.ut.uid), - NULL, p->pipe_user.nt_user_token, lp_printer_admin(-1)) ) + + if ( (p->pipe_user.ut.uid != 0) + && !user_has_privileges(p->pipe_user.nt_user_token, &se_printop ) + && !token_contains_name_in_list( uidtoname(p->pipe_user.ut.uid), + NULL, p->pipe_user.nt_user_token, lp_printer_admin(-1)) ) { return WERR_ACCESS_DENIED; } - + unistr2_to_ascii(driver, &q_u->driver, sizeof(driver)); unistr2_to_ascii(arch, &q_u->arch, sizeof(arch)); @@ -2093,84 +2093,84 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV /* this is what NT returns */ return WERR_INVALID_ENVIRONMENT; } - + if ( flags & DPD_DELETE_SPECIFIC_VERSION ) version = q_u->version; - + ZERO_STRUCT(info); ZERO_STRUCT(info_win2k); - + status = get_a_printer_driver(&info, 3, driver, arch, version); - - if ( !W_ERROR_IS_OK(status) ) + + if ( !W_ERROR_IS_OK(status) ) { - /* - * if the client asked for a specific version, + /* + * if the client asked for a specific version, * or this is something other than Windows NT x86, - * then we've failed + * then we've failed */ - + if ( (flags&DPD_DELETE_SPECIFIC_VERSION) || (version !=2) ) goto done; - + /* try for Win2k driver if "Windows NT x86" */ - + version = 3; if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) { status = WERR_UNKNOWN_PRINTER_DRIVER; goto done; } } - + if ( printer_driver_in_use(info.info_3) ) { status = WERR_PRINTER_DRIVER_IN_USE; goto done; } - - /* - * we have a couple of cases to consider. + + /* + * we have a couple of cases to consider. * (1) Are any files in use? If so and DPD_DELTE_ALL_FILE is set, - * then the delete should fail if **any** files overlap with - * other drivers + * then the delete should fail if **any** files overlap with + * other drivers * (2) If DPD_DELTE_UNUSED_FILES is sert, then delete all - * non-overlapping files + * non-overlapping files * (3) If neither DPD_DELTE_ALL_FILE nor DPD_DELTE_ALL_FILES * is set, the do not delete any files * Refer to MSDN docs on DeletePrinterDriverEx() for details. */ - + delete_files = flags & (DPD_DELETE_ALL_FILES|DPD_DELETE_UNUSED_FILES); - + /* fail if any files are in use and DPD_DELETE_ALL_FILES is set */ - + if ( delete_files && printer_driver_files_in_use(info.info_3) & (flags&DPD_DELETE_ALL_FILES) ) { /* no idea of the correct error here */ - status = WERR_ACCESS_DENIED; + status = WERR_ACCESS_DENIED; goto done; } - + /* also check for W32X86/3 if necessary; maybe we already have? */ - + if ( (version == 2) && ((flags&DPD_DELETE_SPECIFIC_VERSION) != DPD_DELETE_SPECIFIC_VERSION) ) { - if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3, driver, arch, 3))) + if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3, driver, arch, 3))) { - + if ( delete_files && printer_driver_files_in_use(info_win2k.info_3) & (flags&DPD_DELETE_ALL_FILES) ) { /* no idea of the correct error here */ free_a_printer_driver( info_win2k, 3 ); - status = WERR_ACCESS_DENIED; + status = WERR_ACCESS_DENIED; goto done; } - + /* if we get to here, we now have 2 driver info structures to remove */ /* remove the Win2k driver first*/ - + status_win2k = delete_printer_driver(info_win2k.info_3, &p->pipe_user, 3, delete_files); free_a_printer_driver( info_win2k, 3 ); - + /* this should not have failed---if it did, report to client */ - + if ( !W_ERROR_IS_OK(status_win2k) ) goto done; } @@ -2182,7 +2182,7 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV status = WERR_OK; done: free_a_printer_driver( info, 3 ); - + return status; } @@ -2191,28 +2191,28 @@ done: Internal routine for retreiving printerdata ***************************************************************************/ -static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printer, - const char *key, const char *value, uint32 *type, uint8 **data, +static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printer, + const char *key, const char *value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size ) { REGISTRY_VALUE *val; uint32 size; int data_len; - + if ( !(val = get_printer_data( printer->info_2, key, value)) ) return WERR_BADFILE; - + *type = regval_type( val ); DEBUG(5,("get_printer_dataex: allocating %d\n", in_size)); size = regval_size( val ); - + /* copy the min(in_size, len) */ - + if ( in_size ) { data_len = (size > in_size) ? in_size : size*sizeof(uint8); - + /* special case for 0 length values */ if ( data_len ) { if ( (*data = (uint8 *)TALLOC_MEMDUP(ctx, regval_data_p(val), data_len)) == NULL ) @@ -2227,7 +2227,7 @@ static WERROR get_printer_dataex( TALLOC_CTX *ctx, NT_PRINTER_INFO_LEVEL *printe *data = NULL; *needed = size; - + DEBUG(5,("get_printer_dataex: copy done\n")); return WERR_OK; @@ -2246,7 +2246,7 @@ static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char Internal routine for storing printerdata ***************************************************************************/ -WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value, +WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value, uint32 type, uint8 *data, int real_len ) { /* the registry objects enforce uniqueness based on value name */ @@ -2259,11 +2259,11 @@ WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, cons ********************************************************************/ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint32 *type, uint8 **data, uint32 *needed, uint32 in_size) -{ +{ int i; - + DEBUG(8,("getprinterdata_printer_server:%s\n", value)); - + if (!StrCaseCmp(value, "W3SvcInstalled")) { *type = REG_DWORD; if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) ) @@ -2278,7 +2278,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) ) return WERR_NOMEM; SIVAL(*data, 0, 0x00); - *needed = 0x4; + *needed = 0x4; return WERR_OK; } @@ -2288,7 +2288,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint return WERR_NOMEM; /* formally was 0x1b */ SIVAL(*data, 0, 0x0); - *needed = 0x4; + *needed = 0x4; return WERR_OK; } @@ -2315,7 +2315,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint SIVAL(*data, 0, 2); else SIVAL(*data, 0, 3); - + *needed = 0x4; return WERR_OK; } @@ -2347,9 +2347,9 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint SIVAL(*data, 4, 5); /* Windows 2000 == 5.0 */ SIVAL(*data, 8, 0); SIVAL(*data, 12, 2195); /* build */ - + /* leave extra string empty */ - + return WERR_OK; } @@ -2357,30 +2357,30 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "DefaultSpoolDirectory")) { const char *string="C:\\PRINTERS"; *type = REG_SZ; - *needed = 2*(strlen(string)+1); + *needed = 2*(strlen(string)+1); if((*data = (uint8 *)TALLOC(ctx, (*needed > in_size) ? *needed:in_size )) == NULL) return WERR_NOMEM; memset(*data, 0, (*needed > in_size) ? *needed:in_size); - + /* it's done by hand ready to go on the wire */ for (i=0; i in_size) ? *needed:in_size )) == NULL) return WERR_NOMEM; memset(*data, 0, (*needed > in_size) ? *needed:in_size); for (i=0; iprinter_type == SPLHND_SERVER ) status = getprinterdata_printer_server( p->mem_ctx, value, type, data, needed, *out_size ); else @@ -2496,30 +2496,30 @@ WERROR _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPO if (*needed > *out_size) status = WERR_MORE_DATA; - + done: - if ( !W_ERROR_IS_OK(status) ) + if ( !W_ERROR_IS_OK(status) ) { DEBUG(5, ("error %d: allocating %d\n", W_ERROR_V(status),*out_size)); - + /* reply this param doesn't exist */ - + if ( *out_size ) { if((*data=(uint8 *)TALLOC_ZERO_ARRAY(p->mem_ctx, uint8, *out_size)) == NULL) { - if ( printer ) + if ( printer ) free_a_printer( &printer, 2 ); return WERR_NOMEM; - } + } } else { *data = NULL; } } - + /* cleanup & exit */ if ( printer ) free_a_printer( &printer, 2 ); - + return status; } @@ -2554,7 +2554,7 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, /* setup the connection */ - ret = cli_full_connection( &the_cli, global_myname(), remote_machine, + ret = cli_full_connection( &the_cli, global_myname(), remote_machine, &rm_addr, 0, "IPC$", "IPC", "", /* username */ "", /* domain */ @@ -2562,17 +2562,17 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, 0, lp_client_signing(), NULL ); if ( !NT_STATUS_IS_OK( ret ) ) { - DEBUG(2,("spoolss_connect_to_client: connection to [%s] failed!\n", + DEBUG(2,("spoolss_connect_to_client: connection to [%s] failed!\n", remote_machine )); return False; - } - + } + if ( the_cli->protocol != PROTOCOL_NT1 ) { DEBUG(0,("spoolss_connect_to_client: machine %s didn't negotiate NT protocol.\n", remote_machine)); cli_shutdown(the_cli); return False; } - + /* * Ok - we have an anonymous connection to the IPC$ share. * Now start the NT Domain stuff :-). @@ -2583,7 +2583,7 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, remote_machine, nt_errstr(ret))); cli_shutdown(the_cli); return False; - } + } /* make sure to save the cli_state pointer. Keep its own talloc_ctx */ @@ -2596,8 +2596,8 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, Connect to the client. ****************************************************************************/ -static bool srv_spoolss_replyopenprinter(int snum, const char *printer, - uint32 localprinter, uint32 type, +static bool srv_spoolss_replyopenprinter(int snum, const char *printer, + uint32 localprinter, uint32 type, POLICY_HND *handle, struct sockaddr_storage *client_ss) { WERROR result; @@ -2613,7 +2613,7 @@ static bool srv_spoolss_replyopenprinter(int snum, const char *printer, if ( !spoolss_connect_to_client( ¬ify_cli_pipe, client_ss, unix_printer )) return False; - + messaging_register(smbd_messaging_context(), NULL, MSG_PRINTER_NOTIFY2, receive_notify2_message_list); @@ -2622,7 +2622,7 @@ static bool srv_spoolss_replyopenprinter(int snum, const char *printer, register_message_flags( True, FLAG_MSG_PRINT_NOTIFY ); } - /* + /* * Tell the specific printing tdb we want messages for this printer * by registering our PID. */ @@ -2632,14 +2632,14 @@ static bool srv_spoolss_replyopenprinter(int snum, const char *printer, smb_connections++; - result = rpccli_spoolss_reply_open_printer(notify_cli_pipe, notify_cli_pipe->cli->mem_ctx, printer, localprinter, + result = rpccli_spoolss_reply_open_printer(notify_cli_pipe, notify_cli_pipe->cli->mem_ctx, printer, localprinter, type, handle); - + if (!W_ERROR_IS_OK(result)) DEBUG(5,("srv_spoolss_reply_open_printer: Client RPC returned [%s]\n", dos_errstr(result))); - return (W_ERROR_IS_OK(result)); + return (W_ERROR_IS_OK(result)); } /******************************************************************** @@ -2647,7 +2647,7 @@ static bool srv_spoolss_replyopenprinter(int snum, const char *printer, * ReplyFindFirstPrinterChangeNotifyEx * * before replying OK: status=0 a rpc call is made to the workstation - * asking ReplyOpenPrinter + * asking ReplyOpenPrinter * * in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe * called from api_spoolss_rffpcnex @@ -2682,7 +2682,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE Printer->notify.option=dup_spool_notify_option(option); - unistr2_to_ascii(Printer->notify.localmachine, localmachine, + unistr2_to_ascii(Printer->notify.localmachine, localmachine, sizeof(Printer->notify.localmachine)); /* Connect to the client machine and send a ReplyOpenPrinter */ @@ -2713,11 +2713,11 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE * fill a notify_info_data with the servername ********************************************************************/ -void spoolss_notify_server_name(int snum, - SPOOL_NOTIFY_INFO_DATA *data, +void spoolss_notify_server_name(int snum, + SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx) { pstring temp; uint32 len; @@ -2731,7 +2731,7 @@ void spoolss_notify_server_name(int snum, data->notify_data.data.length = 0; return; } - + memcpy(data->notify_data.data.string, temp, len); } else { data->notify_data.data.string = NULL; @@ -2742,15 +2742,15 @@ void spoolss_notify_server_name(int snum, * fill a notify_info_data with the printername (not including the servername). ********************************************************************/ -void spoolss_notify_printer_name(int snum, - SPOOL_NOTIFY_INFO_DATA *data, +void spoolss_notify_printer_name(int snum, + SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { pstring temp; uint32 len; - + /* the notify name should not contain the \\server\ part */ char *p = strrchr(printer->info_2->printername, '\\'); @@ -2779,8 +2779,8 @@ void spoolss_notify_printer_name(int snum, * fill a notify_info_data with the servicename ********************************************************************/ -void spoolss_notify_share_name(int snum, - SPOOL_NOTIFY_INFO_DATA *data, +void spoolss_notify_share_name(int snum, + SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) @@ -2801,15 +2801,15 @@ void spoolss_notify_share_name(int snum, } else { data->notify_data.data.string = NULL; } - + } /******************************************************************* * fill a notify_info_data with the port name ********************************************************************/ -void spoolss_notify_port_name(int snum, - SPOOL_NOTIFY_INFO_DATA *data, +void spoolss_notify_port_name(int snum, + SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) @@ -2824,12 +2824,12 @@ void spoolss_notify_port_name(int snum, data->notify_data.data.length = len; if (len) { data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - + if (!data->notify_data.data.string) { data->notify_data.data.length = 0; return; } - + memcpy(data->notify_data.data.string, temp, len); } else { data->notify_data.data.string = NULL; @@ -2841,7 +2841,7 @@ void spoolss_notify_port_name(int snum, * but it doesn't exist, have to see what to do ********************************************************************/ -void spoolss_notify_driver_name(int snum, +void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -2855,12 +2855,12 @@ void spoolss_notify_driver_name(int snum, data->notify_data.data.length = len; if (len) { data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - + if (!data->notify_data.data.string) { data->notify_data.data.length = 0; return; } - + memcpy(data->notify_data.data.string, temp, len); } else { data->notify_data.data.string = NULL; @@ -2871,7 +2871,7 @@ void spoolss_notify_driver_name(int snum, * fill a notify_info_data with the comment ********************************************************************/ -void spoolss_notify_comment(int snum, +void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -2888,12 +2888,12 @@ void spoolss_notify_comment(int snum, data->notify_data.data.length = len; if (len) { data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - + if (!data->notify_data.data.string) { data->notify_data.data.length = 0; return; } - + memcpy(data->notify_data.data.string, temp, len); } else { data->notify_data.data.string = NULL; @@ -2905,7 +2905,7 @@ void spoolss_notify_comment(int snum, * location = "Room 1, floor 2, building 3" ********************************************************************/ -void spoolss_notify_location(int snum, +void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -2919,12 +2919,12 @@ void spoolss_notify_location(int snum, data->notify_data.data.length = len; if (len) { data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - + if (!data->notify_data.data.string) { data->notify_data.data.length = 0; return; } - + memcpy(data->notify_data.data.string, temp, len); } else { data->notify_data.data.string = NULL; @@ -2936,7 +2936,7 @@ void spoolss_notify_location(int snum, * jfm:xxxx don't to it for know but that's a real problem !!! ********************************************************************/ -static void spoolss_notify_devmode(int snum, +static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -2951,8 +2951,8 @@ static void spoolss_notify_devmode(int snum, * fill a notify_info_data with the separator file name ********************************************************************/ -void spoolss_notify_sepfile(int snum, - SPOOL_NOTIFY_INFO_DATA *data, +void spoolss_notify_sepfile(int snum, + SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) @@ -2965,12 +2965,12 @@ void spoolss_notify_sepfile(int snum, data->notify_data.data.length = len; if (len) { data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - + if (!data->notify_data.data.string) { data->notify_data.data.length = 0; return; } - + memcpy(data->notify_data.data.string, temp, len); } else { data->notify_data.data.string = NULL; @@ -2982,7 +2982,7 @@ void spoolss_notify_sepfile(int snum, * jfm:xxxx return always winprint to indicate we don't do anything to it ********************************************************************/ -void spoolss_notify_print_processor(int snum, +void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -2996,12 +2996,12 @@ void spoolss_notify_print_processor(int snum, data->notify_data.data.length = len; if (len) { data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - + if (!data->notify_data.data.string) { data->notify_data.data.length = 0; return; } - + memcpy(data->notify_data.data.string, temp, len); } else { data->notify_data.data.string = NULL; @@ -3013,7 +3013,7 @@ void spoolss_notify_print_processor(int snum, * jfm:xxxx send an empty string ********************************************************************/ -void spoolss_notify_parameters(int snum, +void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3027,12 +3027,12 @@ void spoolss_notify_parameters(int snum, data->notify_data.data.length = len; if (len) { data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - + if (!data->notify_data.data.string) { data->notify_data.data.length = 0; return; } - + memcpy(data->notify_data.data.string, temp, len); } else { data->notify_data.data.string = NULL; @@ -3044,7 +3044,7 @@ void spoolss_notify_parameters(int snum, * jfm:xxxx always send RAW as data type ********************************************************************/ -void spoolss_notify_datatype(int snum, +void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3058,12 +3058,12 @@ void spoolss_notify_datatype(int snum, data->notify_data.data.length = len; if (len) { data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - + if (!data->notify_data.data.string) { data->notify_data.data.length = 0; return; } - + memcpy(data->notify_data.data.string, temp, len); } else { data->notify_data.data.string = NULL; @@ -3076,7 +3076,7 @@ void spoolss_notify_datatype(int snum, * have to implement security before ! ********************************************************************/ -static void spoolss_notify_security_desc(int snum, +static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3091,7 +3091,7 @@ static void spoolss_notify_security_desc(int snum, * jfm:xxxx a samba printer is always shared ********************************************************************/ -void spoolss_notify_attributes(int snum, +void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3105,7 +3105,7 @@ void spoolss_notify_attributes(int snum, * fill a notify_info_data with the priority ********************************************************************/ -static void spoolss_notify_priority(int snum, +static void spoolss_notify_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3119,7 +3119,7 @@ static void spoolss_notify_priority(int snum, * fill a notify_info_data with the default priority ********************************************************************/ -static void spoolss_notify_default_priority(int snum, +static void spoolss_notify_default_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3133,7 +3133,7 @@ static void spoolss_notify_default_priority(int snum, * fill a notify_info_data with the start time ********************************************************************/ -static void spoolss_notify_start_time(int snum, +static void spoolss_notify_start_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3147,7 +3147,7 @@ static void spoolss_notify_start_time(int snum, * fill a notify_info_data with the until time ********************************************************************/ -static void spoolss_notify_until_time(int snum, +static void spoolss_notify_until_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3161,7 +3161,7 @@ static void spoolss_notify_until_time(int snum, * fill a notify_info_data with the status ********************************************************************/ -static void spoolss_notify_status(int snum, +static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3178,10 +3178,10 @@ static void spoolss_notify_status(int snum, * fill a notify_info_data with the number of jobs queued ********************************************************************/ -void spoolss_notify_cjobs(int snum, +void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, - NT_PRINTER_INFO_LEVEL *printer, + NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { data->notify_data.value[0] = print_queue_length(snum, NULL); @@ -3192,7 +3192,7 @@ void spoolss_notify_cjobs(int snum, * fill a notify_info_data with the average ppm ********************************************************************/ -static void spoolss_notify_average_ppm(int snum, +static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3208,7 +3208,7 @@ static void spoolss_notify_average_ppm(int snum, * fill a notify_info_data with username ********************************************************************/ -static void spoolss_notify_username(int snum, +static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3222,12 +3222,12 @@ static void spoolss_notify_username(int snum, data->notify_data.data.length = len; if (len) { data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - + if (!data->notify_data.data.string) { data->notify_data.data.length = 0; return; } - + memcpy(data->notify_data.data.string, temp, len); } else { data->notify_data.data.string = NULL; @@ -3238,7 +3238,7 @@ static void spoolss_notify_username(int snum, * fill a notify_info_data with job status ********************************************************************/ -static void spoolss_notify_job_status(int snum, +static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3252,7 +3252,7 @@ static void spoolss_notify_job_status(int snum, * fill a notify_info_data with job name ********************************************************************/ -static void spoolss_notify_job_name(int snum, +static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3266,12 +3266,12 @@ static void spoolss_notify_job_name(int snum, data->notify_data.data.length = len; if (len) { data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - + if (!data->notify_data.data.string) { data->notify_data.data.length = 0; return; } - + memcpy(data->notify_data.data.string, temp, len); } else { data->notify_data.data.string = NULL; @@ -3282,10 +3282,10 @@ static void spoolss_notify_job_name(int snum, * fill a notify_info_data with job status ********************************************************************/ -static void spoolss_notify_job_status_string(int snum, +static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, - NT_PRINTER_INFO_LEVEL *printer, + NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { /* @@ -3320,12 +3320,12 @@ static void spoolss_notify_job_status_string(int snum, data->notify_data.data.length = len; if (len) { data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - + if (!data->notify_data.data.string) { data->notify_data.data.length = 0; return; } - + memcpy(data->notify_data.data.string, temp, len); } else { data->notify_data.data.string = NULL; @@ -3336,7 +3336,7 @@ static void spoolss_notify_job_status_string(int snum, * fill a notify_info_data with job time ********************************************************************/ -static void spoolss_notify_job_time(int snum, +static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3350,7 +3350,7 @@ static void spoolss_notify_job_time(int snum, * fill a notify_info_data with job size ********************************************************************/ -static void spoolss_notify_job_size(int snum, +static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3390,7 +3390,7 @@ static void spoolss_notify_pages_printed(int snum, Fill a notify_info_data with job position. ********************************************************************/ -static void spoolss_notify_job_position(int snum, +static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3404,7 +3404,7 @@ static void spoolss_notify_job_position(int snum, Fill a notify_info_data with submitted time. ********************************************************************/ -static void spoolss_notify_submitted_time(int snum, +static void spoolss_notify_submitted_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, @@ -3426,11 +3426,11 @@ static void spoolss_notify_submitted_time(int snum, data->notify_data.data.length = 0; return; } - + make_systemtime(&st, t); /* - * Systemtime must be linearized as a set of UINT16's. + * Systemtime must be linearized as a set of UINT16's. * Fix from Benjamin (Bj) Kuit bj@it.uts.edu.au */ @@ -3538,7 +3538,7 @@ static uint32 size_of_notify_info_data(uint16 type, uint16 field) case NOTIFY_POINTER: return 4; - + case NOTIFY_SECDESC: return 5; } @@ -3571,7 +3571,7 @@ static uint32 type_of_notify_info_data(uint16 type, uint16 field) ****************************************************************************/ static bool search_notify(uint16 type, uint16 field, int *value) -{ +{ int i; for (i = 0; notify_info_data_table[i].type != PRINT_TABLE_END; i++) { @@ -3582,8 +3582,8 @@ static bool search_notify(uint16 type, uint16 field, int *value) return True; } } - - return False; + + return False; } /**************************************************************************** @@ -3610,7 +3610,7 @@ void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type, uint16 static bool construct_notify_printer_info(Printer_entry *print_hnd, SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx) { int field_num,j; uint16 type; @@ -3625,13 +3625,13 @@ static bool construct_notify_printer_info(Printer_entry *print_hnd, SPOOL_NOTIFY DEBUG(4,("construct_notify_printer_info: Notify type: [%s], number of notify info: [%d] on printer: [%s]\n", (option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"), option_type->count, lp_servicename(snum))); - + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &printer, 2, lp_const_servicename(snum)))) return False; for(field_num=0; field_numcount; field_num++) { field = option_type->fields[field_num]; - + DEBUG(4,("construct_notify_printer_info: notify [%d]: type [%x], field [%x]\n", field_num, type, field)); if (!search_notify(type, field, &j) ) @@ -3671,16 +3671,16 @@ static bool construct_notify_jobs_info(print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id, - TALLOC_CTX *mem_ctx) + TALLOC_CTX *mem_ctx) { int field_num,j; uint16 type; uint16 field; SPOOL_NOTIFY_INFO_DATA *current_data; - + DEBUG(4,("construct_notify_jobs_info\n")); - + type = option_type->type; DEBUGADD(4,("Notify type: [%s], number of notify info: [%d]\n", @@ -3739,7 +3739,7 @@ static bool construct_notify_jobs_info(print_queue_struct *queue, * ********************************************************************/ -static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, +static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, TALLOC_CTX *mem_ctx) { @@ -3751,7 +3751,7 @@ static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY_OPTION_TYPE *option_type; DEBUG(4,("printserver_notify_info\n")); - + if (!Printer) return WERR_BADFID; @@ -3760,7 +3760,7 @@ static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, info->data=NULL; info->count=0; - /* a bug in xp sp2 rc2 causes it to send a fnpcn request without + /* a bug in xp sp2 rc2 causes it to send a fnpcn request without sending a ffpcn() request first */ if ( !option ) @@ -3768,18 +3768,18 @@ static WERROR printserver_notify_info(pipes_struct *p, POLICY_HND *hnd, for (i=0; icount; i++) { option_type=&(option->ctr.type[i]); - + if (option_type->type!=PRINTER_NOTIFY_TYPE) continue; - + for (snum=0; snumversion:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); DEBUGADD(1,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); - + for (i=0; icount; i++) { DEBUGADD(1,("[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\n", i, info->data[i].type, info->data[i].field, info->data[i].reserved, info->data[i].id, info->data[i].size, info->data[i].enc_type)); } #endif - + return WERR_OK; } @@ -3816,7 +3816,7 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY int count,j; print_queue_struct *queue=NULL; print_status_struct status; - + DEBUG(4,("printer_notify_info\n")); if (!Printer) @@ -3828,7 +3828,7 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY info->data=NULL; info->count=0; - /* a bug in xp sp2 rc2 causes it to send a fnpcn request without + /* a bug in xp sp2 rc2 causes it to send a fnpcn request without sending a ffpcn() request first */ if ( !option ) @@ -3838,15 +3838,15 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY for (i=0; icount; i++) { option_type=&option->ctr.type[i]; - + switch ( option_type->type ) { case PRINTER_NOTIFY_TYPE: - if(construct_notify_printer_info(Printer, info, snum, + if(construct_notify_printer_info(Printer, info, snum, option_type, id, - mem_ctx)) + mem_ctx)) id--; break; - + case JOB_NOTIFY_TYPE: { NT_PRINTER_INFO_LEVEL *printer = NULL; @@ -3860,18 +3860,18 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY printer, snum, option_type, queue[j].job, - mem_ctx); + mem_ctx); } free_a_printer(&printer, 2); - + done: SAFE_FREE(queue); break; } } } - + /* * Debugging information, don't delete. */ @@ -3879,7 +3879,7 @@ static WERROR printer_notify_info(pipes_struct *p, POLICY_HND *hnd, SPOOL_NOTIFY DEBUG(1,("dumping the NOTIFY_INFO\n")); DEBUGADD(1,("info->version:[%d], info->flags:[%d], info->count:[%d]\n", info->version, info->flags, info->count)); DEBUGADD(1,("num\ttype\tfield\tres\tid\tsize\tenc_type\n")); - + for (i=0; icount; i++) { DEBUGADD(1,("[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\t[%d]\n", i, info->data[i].type, info->data[i].field, info->data[i].reserved, @@ -3913,13 +3913,13 @@ WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN DEBUG(4,("Printer type %x\n",Printer->printer_type)); /* - * We are now using the change value, and + * We are now using the change value, and * I should check for PRINTER_NOTIFY_OPTIONS_REFRESH but as * I don't have a global notification system, I'm sending back all the * informations even when _NOTHING_ has changed. */ - /* We need to keep track of the change value to send back in + /* We need to keep track of the change value to send back in RRPCN replies otherwise our updates are ignored. */ Printer->notify.fnpcn = True; @@ -3930,19 +3930,19 @@ WERROR _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCN } /* just ignore the SPOOL_NOTIFY_OPTION */ - + switch (Printer->printer_type) { case SPLHND_SERVER: result = printserver_notify_info(p, handle, info, p->mem_ctx); break; - + case SPLHND_PRINTER: result = printer_notify_info(p, handle, info, p->mem_ctx); break; } - + Printer->notify.fnpcn = False; - + done: return result; } @@ -3962,13 +3962,13 @@ static bool construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p struct tm *t; time_t setuptime; print_status_struct status; - + if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; count = print_queue_length(snum, &status); - /* check if we already have a counter for this printer */ + /* check if we already have a counter for this printer */ for(session_counter = counter_list; session_counter; session_counter = session_counter->next) { if (session_counter->snum == snum) break; @@ -3985,23 +3985,23 @@ static bool construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p session_counter->counter=0; DLIST_ADD(counter_list, session_counter); } - + /* increment it */ session_counter->counter++; - + /* JFM: * the global_counter should be stored in a TDB as it's common to all the clients * and should be zeroed on samba startup */ global_counter=session_counter->counter; - + pstrcpy(chaine,ntprinter->info_2->printername); init_unistr(&printer->printername, chaine); - + slprintf(chaine,sizeof(chaine)-1,"\\\\%s", get_server_name(print_hnd)); init_unistr(&printer->servername, chaine); - + printer->cjobs = count; printer->total_jobs = 0; printer->total_bytes = 0; @@ -4020,11 +4020,11 @@ static bool construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p printer->global_counter = global_counter; printer->total_pages = 0; - + /* in 2.2 we reported ourselves as 0x0004 and 0x0565 */ printer->major_version = 0x0005; /* NT 5 */ printer->build_version = 0x0893; /* build 2195 */ - + printer->unknown7 = 0x1; printer->unknown8 = 0x0; printer->unknown9 = 0x0; @@ -4048,9 +4048,9 @@ static bool construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p printer->unknown27 = 0; printer->unknown28 = 0; printer->unknown29 = 0; - + free_a_printer(&ntprinter,2); - return (True); + return (True); } /******************************************************************** @@ -4078,12 +4078,12 @@ static bool construct_printer_info_1(Printer_entry *print_hnd, uint32 flags, PRI slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s", ntprinter->info_2->printername, ntprinter->info_2->drivername, ntprinter->info_2->comment); } - + slprintf(chaine2,sizeof(chaine)-1,"%s", ntprinter->info_2->printername); init_unistr(&printer->description, chaine); - init_unistr(&printer->name, chaine2); - + init_unistr(&printer->name, chaine2); + free_a_printer(&ntprinter,2); return True; @@ -4099,12 +4099,12 @@ static void free_dev_mode(DEVICEMODE *dev) return; SAFE_FREE(dev->dev_private); - SAFE_FREE(dev); + SAFE_FREE(dev); } /**************************************************************************** - Convert an NT_DEVICEMODE to a DEVICEMODE structure. Both pointers + Convert an NT_DEVICEMODE to a DEVICEMODE structure. Both pointers should be valid upon entry ****************************************************************************/ @@ -4112,7 +4112,7 @@ static bool convert_nt_devicemode( DEVICEMODE *devmode, NT_DEVICEMODE *ntdevmode { if ( !devmode || !ntdevmode ) return False; - + init_unistr(&devmode->devicename, ntdevmode->devicename); init_unistr(&devmode->formname, ntdevmode->formname); @@ -4122,8 +4122,8 @@ static bool convert_nt_devicemode( DEVICEMODE *devmode, NT_DEVICEMODE *ntdevmode devmode->size = ntdevmode->size; devmode->driverextra = ntdevmode->driverextra; devmode->fields = ntdevmode->fields; - - devmode->orientation = ntdevmode->orientation; + + devmode->orientation = ntdevmode->orientation; devmode->papersize = ntdevmode->papersize; devmode->paperlength = ntdevmode->paperlength; devmode->paperwidth = ntdevmode->paperwidth; @@ -4145,7 +4145,7 @@ static bool convert_nt_devicemode( DEVICEMODE *devmode, NT_DEVICEMODE *ntdevmode if ((devmode->dev_private=(uint8 *)memdup(ntdevmode->nt_dev_private, ntdevmode->driverextra)) == NULL) return False; } - + return True; } @@ -4157,12 +4157,12 @@ DEVICEMODE *construct_dev_mode(const char *servicename) { NT_PRINTER_INFO_LEVEL *printer = NULL; DEVICEMODE *devmode = NULL; - + DEBUG(7,("construct_dev_mode\n")); - + DEBUGADD(8,("getting printer characteristics\n")); - if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, servicename))) + if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, servicename))) return NULL; if ( !printer->info_2->devmode ) { @@ -4175,8 +4175,8 @@ DEVICEMODE *construct_dev_mode(const char *servicename) goto done; } - ZERO_STRUCTP(devmode); - + ZERO_STRUCTP(devmode); + DEBUGADD(8,("loading DEVICEMODE\n")); if ( !convert_nt_devicemode( devmode, printer->info_2->devmode ) ) { @@ -4204,46 +4204,46 @@ static bool construct_printer_info_2(Printer_entry *print_hnd, PRINTER_INFO_2 *p if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; - + count = print_queue_length(snum, &status); init_unistr(&printer->servername, ntprinter->info_2->servername); /* servername*/ init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/ init_unistr(&printer->sharename, lp_servicename(snum)); /* sharename */ - init_unistr(&printer->portname, ntprinter->info_2->portname); /* port */ + init_unistr(&printer->portname, ntprinter->info_2->portname); /* port */ init_unistr(&printer->drivername, ntprinter->info_2->drivername); /* drivername */ if (*ntprinter->info_2->comment == '\0') - init_unistr(&printer->comment, lp_comment(snum)); /* comment */ + init_unistr(&printer->comment, lp_comment(snum)); /* comment */ else init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ - init_unistr(&printer->location, ntprinter->info_2->location); /* location */ + init_unistr(&printer->location, ntprinter->info_2->location); /* location */ init_unistr(&printer->sepfile, ntprinter->info_2->sepfile); /* separator file */ init_unistr(&printer->printprocessor, ntprinter->info_2->printprocessor);/* print processor */ - init_unistr(&printer->datatype, ntprinter->info_2->datatype); /* datatype */ - init_unistr(&printer->parameters, ntprinter->info_2->parameters); /* parameters (of print processor) */ + init_unistr(&printer->datatype, ntprinter->info_2->datatype); /* datatype */ + init_unistr(&printer->parameters, ntprinter->info_2->parameters); /* parameters (of print processor) */ printer->attributes = ntprinter->info_2->attributes; - printer->priority = ntprinter->info_2->priority; /* priority */ + printer->priority = ntprinter->info_2->priority; /* priority */ printer->defaultpriority = ntprinter->info_2->default_priority; /* default priority */ printer->starttime = ntprinter->info_2->starttime; /* starttime */ printer->untiltime = ntprinter->info_2->untiltime; /* untiltime */ printer->status = nt_printq_status(status.status); /* status */ printer->cjobs = count; /* jobs */ printer->averageppm = ntprinter->info_2->averageppm; /* average pages per minute */ - + if ( !(printer->devmode = construct_dev_mode( lp_const_servicename(snum))) ) DEBUG(8, ("Returning NULL Devicemode!\n")); printer->secdesc = NULL; - if ( ntprinter->info_2->secdesc_buf - && ntprinter->info_2->secdesc_buf->sd_size != 0 ) + if ( ntprinter->info_2->secdesc_buf + && ntprinter->info_2->secdesc_buf->sd_size != 0 ) { - /* don't use talloc_steal() here unless you do a deep steal of all + /* don't use talloc_steal() here unless you do a deep steal of all the SEC_DESC members */ printer->secdesc = dup_sec_desc( talloc_tos(), @@ -4276,11 +4276,11 @@ static bool construct_printer_info_3(Printer_entry *print_hnd, PRINTER_INFO_3 ** } ZERO_STRUCTP(printer); - + /* These are the components of the SD we are returning. */ if (ntprinter->info_2->secdesc_buf && ntprinter->info_2->secdesc_buf->sd_size != 0) { - /* don't use talloc_steal() here unless you do a deep steal of all + /* don't use talloc_steal() here unless you do a deep steal of all the SEC_DESC members */ printer->secdesc = dup_sec_desc( talloc_tos(), @@ -4304,7 +4304,7 @@ static bool construct_printer_info_4(Printer_entry *print_hnd, PRINTER_INFO_4 *p if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; - + init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/ init_unistr(&printer->servername, ntprinter->info_2->servername); /* servername*/ printer->attributes = ntprinter->info_2->attributes; @@ -4324,9 +4324,9 @@ static bool construct_printer_info_5(Printer_entry *print_hnd, PRINTER_INFO_5 *p if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; - + init_unistr(&printer->printername, ntprinter->info_2->printername); - init_unistr(&printer->portname, ntprinter->info_2->portname); + init_unistr(&printer->portname, ntprinter->info_2->portname); printer->attributes = ntprinter->info_2->attributes; /* these two are not used by NT+ according to MSDN */ @@ -4359,7 +4359,7 @@ static bool construct_printer_info_6(Printer_entry *print_hnd, count = print_queue_length(snum, &status); printer->status = nt_printq_status(status.status); - + free_a_printer(&ntprinter, 2); return True; @@ -4373,8 +4373,8 @@ static bool construct_printer_info_6(Printer_entry *print_hnd, static bool construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *printer, int snum) { char *guid_str = NULL; - struct GUID guid; - + struct GUID guid; + if (is_printer_published(print_hnd, snum, &guid)) { asprintf(&guid_str, "{%s}", smb_uuid_string(talloc_tos(), guid)); @@ -4401,8 +4401,8 @@ static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32 PRINTER_INFO_1 *printers=NULL; PRINTER_INFO_1 current_prt; WERROR result = WERR_OK; - - DEBUG(4,("enum_all_printers_info_1\n")); + + DEBUG(4,("enum_all_printers_info_1\n")); for (snum=0; snumdescription, desc); - init_unistr(&printer->name, printername); + init_unistr(&printer->name, printername); init_unistr(&printer->comment, comment); printer->flags=PRINTER_ENUM_ICON3|PRINTER_ENUM_CONTAINER; - - /* check the required size. */ + + /* check the required size. */ *needed += spoolss_size_printer_info_1(printer); if (*needed > offered) { @@ -4532,7 +4532,7 @@ static WERROR enum_all_printers_info_1_remote(fstring name, RPC_BUFFER *buffer, } /* fill the buffer with the structures */ - smb_io_printer_info_1("", buffer, printer, 0); + smb_io_printer_info_1("", buffer, printer, 0); out: /* clear memory */ @@ -4554,15 +4554,15 @@ static WERROR enum_all_printers_info_1_network(fstring name, RPC_BUFFER *buffer, { char *s = name; - DEBUG(4,("enum_all_printers_info_1_network\n")); - + DEBUG(4,("enum_all_printers_info_1_network\n")); + /* If we respond to a enum_printers level 1 on our name with flags set to PRINTER_ENUM_REMOTE with a list of printers then these printers incorrectly appear in the APW browse list. Specifically the printers for the server appear at the workgroup level where all the other servers in the domain are listed. Windows responds to this call with a - WERR_CAN_NOT_COMPLETE so we should do the same. */ + WERR_CAN_NOT_COMPLETE so we should do the same. */ if (name[0] == '\\' && name[1] == '\\') s = name + 2; @@ -4593,7 +4593,7 @@ static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint3 for (snum=0; snum offered) { result = WERR_INSUFFICIENT_BUFFER; goto out; @@ -4626,12 +4626,12 @@ static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint3 /* fill the buffer with the structures */ for (i=0; i<*returned; i++) - smb_io_printer_info_2("", buffer, &(printers[i]), 0); - + smb_io_printer_info_2("", buffer, &(printers[i]), 0); + out: /* clear memory */ - for (i=0; i<*returned; i++) + for (i=0; i<*returned; i++) free_devmode(printers[i].devmode); SAFE_FREE(printers); @@ -4727,7 +4727,7 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ uint32 *returned = &r_u->returned; fstring name; - + /* that's an [in out] buffer */ if (!q_u->buffer && (offered!=0)) { @@ -4741,7 +4741,7 @@ WERROR _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_ *needed=0; *returned=0; - + /* * Level 1: * flags==PRINTER_ENUM_NAME @@ -4784,8 +4784,8 @@ static WERROR getprinter_level_0(Printer_entry *print_hnd, int snum, RPC_BUFFER return WERR_NOMEM; construct_printer_info_0(print_hnd, printer, snum); - - /* check the required size. */ + + /* check the required size. */ *needed += spoolss_size_printer_info_0(printer); if (*needed > offered) { @@ -4799,8 +4799,8 @@ static WERROR getprinter_level_0(Printer_entry *print_hnd, int snum, RPC_BUFFER } /* fill the buffer with the structures */ - smb_io_printer_info_0("", buffer, printer, 0); - + smb_io_printer_info_0("", buffer, printer, 0); + out: /* clear memory */ @@ -4821,8 +4821,8 @@ static WERROR getprinter_level_1(Printer_entry *print_hnd, int snum, RPC_BUFFER return WERR_NOMEM; construct_printer_info_1(print_hnd, PRINTER_ENUM_ICON8, printer, snum); - - /* check the required size. */ + + /* check the required size. */ *needed += spoolss_size_printer_info_1(printer); if (*needed > offered) { @@ -4836,13 +4836,13 @@ static WERROR getprinter_level_1(Printer_entry *print_hnd, int snum, RPC_BUFFER } /* fill the buffer with the structures */ - smb_io_printer_info_1("", buffer, printer, 0); - + smb_io_printer_info_1("", buffer, printer, 0); + out: /* clear memory */ SAFE_FREE(printer); - return result; + return result; } /**************************************************************************** @@ -4855,12 +4855,12 @@ static WERROR getprinter_level_2(Printer_entry *print_hnd, int snum, RPC_BUFFER if((printer=SMB_MALLOC_P(PRINTER_INFO_2))==NULL) return WERR_NOMEM; - + construct_printer_info_2(print_hnd, printer, snum); - - /* check the required size. */ + + /* check the required size. */ *needed += spoolss_size_printer_info_2(printer); - + if (*needed > offered) { result = WERR_INSUFFICIENT_BUFFER; goto out; @@ -4872,14 +4872,14 @@ static WERROR getprinter_level_2(Printer_entry *print_hnd, int snum, RPC_BUFFER } /* fill the buffer with the structures */ - if (!smb_io_printer_info_2("", buffer, printer, 0)) + if (!smb_io_printer_info_2("", buffer, printer, 0)) result = WERR_NOMEM; - + out: /* clear memory */ free_printer_info_2(printer); - return result; + return result; } /**************************************************************************** @@ -4892,8 +4892,8 @@ static WERROR getprinter_level_3(Printer_entry *print_hnd, int snum, RPC_BUFFER if (!construct_printer_info_3(print_hnd, &printer, snum)) return WERR_NOMEM; - - /* check the required size. */ + + /* check the required size. */ *needed += spoolss_size_printer_info_3(printer); if (*needed > offered) { @@ -4907,13 +4907,13 @@ static WERROR getprinter_level_3(Printer_entry *print_hnd, int snum, RPC_BUFFER } /* fill the buffer with the structures */ - smb_io_printer_info_3("", buffer, printer, 0); - + smb_io_printer_info_3("", buffer, printer, 0); + out: /* clear memory */ free_printer_info_3(printer); - - return result; + + return result; } /**************************************************************************** @@ -4931,8 +4931,8 @@ static WERROR getprinter_level_4(Printer_entry *print_hnd, int snum, RPC_BUFFER SAFE_FREE(printer); return WERR_NOMEM; } - - /* check the required size. */ + + /* check the required size. */ *needed += spoolss_size_printer_info_4(printer); if (*needed > offered) { @@ -4946,13 +4946,13 @@ static WERROR getprinter_level_4(Printer_entry *print_hnd, int snum, RPC_BUFFER } /* fill the buffer with the structures */ - smb_io_printer_info_4("", buffer, printer, 0); - + smb_io_printer_info_4("", buffer, printer, 0); + out: /* clear memory */ free_printer_info_4(printer); - - return result; + + return result; } /**************************************************************************** @@ -4970,8 +4970,8 @@ static WERROR getprinter_level_5(Printer_entry *print_hnd, int snum, RPC_BUFFER free_printer_info_5(printer); return WERR_NOMEM; } - - /* check the required size. */ + + /* check the required size. */ *needed += spoolss_size_printer_info_5(printer); if (*needed > offered) { @@ -4985,13 +4985,13 @@ static WERROR getprinter_level_5(Printer_entry *print_hnd, int snum, RPC_BUFFER } /* fill the buffer with the structures */ - smb_io_printer_info_5("", buffer, printer, 0); - + smb_io_printer_info_5("", buffer, printer, 0); + out: /* clear memory */ free_printer_info_5(printer); - - return result; + + return result; } static WERROR getprinter_level_6(Printer_entry *print_hnd, @@ -5025,13 +5025,13 @@ static WERROR getprinter_level_6(Printer_entry *print_hnd, } /* fill the buffer with the structures */ - smb_io_printer_info_6("", buffer, printer, 0); - + smb_io_printer_info_6("", buffer, printer, 0); + out: /* clear memory */ free_printer_info_6(printer); - - return result; + + return result; } static WERROR getprinter_level_7(Printer_entry *print_hnd, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) @@ -5044,8 +5044,8 @@ static WERROR getprinter_level_7(Printer_entry *print_hnd, int snum, RPC_BUFFER if (!construct_printer_info_7(print_hnd, printer, snum)) return WERR_NOMEM; - - /* check the required size. */ + + /* check the required size. */ *needed += spoolss_size_printer_info_7(printer); if (*needed > offered) { @@ -5060,13 +5060,13 @@ static WERROR getprinter_level_7(Printer_entry *print_hnd, int snum, RPC_BUFFER } /* fill the buffer with the structures */ - smb_io_printer_info_7("", buffer, printer, 0); - + smb_io_printer_info_7("", buffer, printer, 0); + out: /* clear memory */ free_printer_info_7(printer); - - return result; + + return result; } /**************************************************************************** @@ -5102,22 +5102,22 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET return getprinter_level_0(Printer, snum, buffer, offered, needed); case 1: return getprinter_level_1(Printer, snum, buffer, offered, needed); - case 2: + case 2: return getprinter_level_2(Printer, snum, buffer, offered, needed); - case 3: + case 3: return getprinter_level_3(Printer, snum, buffer, offered, needed); - case 4: + case 4: return getprinter_level_4(Printer, snum, buffer, offered, needed); - case 5: + case 5: return getprinter_level_5(Printer, snum, buffer, offered, needed); - case 6: + case 6: return getprinter_level_6(Printer, snum, buffer, offered, needed); case 7: return getprinter_level_7(Printer, snum, buffer, offered, needed); } return WERR_UNKNOWN_LEVEL; -} - +} + /******************************************************************** * fill a DRIVER_INFO_1 struct ********************************************************************/ @@ -5132,7 +5132,7 @@ static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_IN ********************************************************************/ static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fstring servername, fstring architecture, uint32 version) -{ +{ NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -5179,10 +5179,10 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->datafile, temp ); } else init_unistr( &info->datafile, "" ); - + if (strlen(driver.info_3->configfile)) { slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); - init_unistr( &info->configfile, temp ); + init_unistr( &info->configfile, temp ); } else init_unistr( &info->configfile, "" ); } @@ -5231,52 +5231,52 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, const c DEBUG(6,("init_unistr_array\n")); *uni_array=NULL; - while (True) + while (True) { if ( !char_array ) v = ""; - else + else { v = char_array[i]; - if (!v) + if (!v) v = ""; /* hack to handle null lists */ } - - /* hack to allow this to be used in places other than when generating + + /* hack to allow this to be used in places other than when generating the list of dependent files */ - + if ( servername ) slprintf( line, sizeof(line)-1, "\\\\%s%s", servername, v ); else pstrcpy( line, v ); - + DEBUGADD(6,("%d:%s:%lu\n", i, line, (unsigned long)strlen(line))); /* add one extra unit16 for the second terminating NULL */ - + if ( (*uni_array=SMB_REALLOC_ARRAY(*uni_array, uint16, j+1+strlen(line)+2)) == NULL ) { DEBUG(2,("init_unistr_array: Realloc error\n" )); return 0; } - if ( !strlen(v) ) + if ( !strlen(v) ) break; - + j += (rpcstr_push((*uni_array+j), line, sizeof(uint16)*strlen(line)+2, STR_TERMINATE) / sizeof(uint16)); i++; } - + if (*uni_array) { /* special case for ""; we need to add both NULL's here */ if (!j) - (*uni_array)[j++]=0x0000; + (*uni_array)[j++]=0x0000; (*uni_array)[j]=0x0000; } - + DEBUGADD(6,("last one:done\n")); /* return size of array in uint16's */ - + return j+1; } @@ -5293,15 +5293,15 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN info->version=driver.info_3->cversion; - init_unistr( &info->name, driver.info_3->name ); + init_unistr( &info->name, driver.info_3->name ); init_unistr( &info->architecture, driver.info_3->environment ); if (strlen(driver.info_3->driverpath)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); init_unistr( &info->driverpath, temp ); } else init_unistr( &info->driverpath, "" ); - + if (strlen(driver.info_3->datafile)) { slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); init_unistr( &info->datafile, temp ); @@ -5310,7 +5310,7 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN if (strlen(driver.info_3->configfile)) { slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); - init_unistr( &info->configfile, temp ); + init_unistr( &info->configfile, temp ); } else init_unistr( &info->configfile, "" ); @@ -5333,7 +5333,7 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN ********************************************************************/ static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fstring servername, fstring architecture, uint32 version) -{ +{ NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; WERROR status; @@ -5344,13 +5344,13 @@ static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst if (!W_ERROR_IS_OK(status)) return WERR_INVALID_PRINTER_NAME; - status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); + status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); DEBUG(8,("construct_printer_driver_info_3: status: %s\n", dos_errstr(status))); #if 0 /* JERRY */ - /* - * I put this code in during testing. Helpful when commenting out the + /* + * I put this code in during testing. Helpful when commenting out the * support for DRIVER_INFO_6 in regards to win2k. Not needed in general * as win2k always queries the driver using an infor level of 6. * I've left it in (but ifdef'd out) because I'll probably @@ -5364,7 +5364,7 @@ static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst if (version == 3) { /* Yes - try again with a WinNT driver. */ version = 2; - status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); + status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); DEBUG(8,("construct_printer_driver_info_3: status: %s\n", dos_errstr(status))); } #endif @@ -5373,11 +5373,11 @@ static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst free_a_printer(&printer,2); return WERR_UNKNOWN_PRINTER_DRIVER; } - + #if 0 /* JERRY */ } #endif - + fill_printer_driver_info_3(info, driver, servername); @@ -5401,11 +5401,11 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN info->version=driver.info_3->cversion; - init_unistr( &info->name, driver.info_3->name ); + init_unistr( &info->name, driver.info_3->name ); init_unistr( &info->architecture, driver.info_3->environment ); if (strlen(driver.info_3->driverpath)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); init_unistr( &info->driverpath, temp ); } else init_unistr( &info->driverpath, "" ); @@ -5418,7 +5418,7 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN if (strlen(driver.info_3->configfile)) { slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); - init_unistr( &info->configfile, temp ); + init_unistr( &info->configfile, temp ); } else init_unistr( &info->configfile, "" ); @@ -5427,7 +5427,7 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->helpfile, temp ); } else init_unistr( &info->helpfile, "" ); - + init_unistr( &info->monitorname, driver.info_3->monitorname ); init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype ); @@ -5454,27 +5454,27 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN * fill a printer_info_6 struct ********************************************************************/ -static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, +static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fstring servername, fstring architecture, uint32 version) -{ +{ NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; WERROR status; - + ZERO_STRUCT(driver); status=get_a_printer(NULL, &printer, 2, lp_const_servicename(snum) ); - + DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status))); - + if (!W_ERROR_IS_OK(status)) return WERR_INVALID_PRINTER_NAME; status = get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); - + DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status))); - - if (!W_ERROR_IS_OK(status)) + + if (!W_ERROR_IS_OK(status)) { /* * Is this a W2k client ? @@ -5487,7 +5487,7 @@ static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, /* Yes - try again with a WinNT driver. */ version = 2; - status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); + status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status))); if (!W_ERROR_IS_OK(status)) { free_a_printer(&printer,2); @@ -5526,15 +5526,15 @@ static WERROR getprinterdriver2_level1(fstring servername, fstring architecture, { DRIVER_INFO_1 *info=NULL; WERROR result; - + if((info=SMB_MALLOC_P(DRIVER_INFO_1)) == NULL) return WERR_NOMEM; - + result = construct_printer_driver_info_1(info, snum, servername, architecture, version); - if (!W_ERROR_IS_OK(result)) + if (!W_ERROR_IS_OK(result)) goto out; - /* check the required size. */ + /* check the required size. */ *needed += spoolss_size_printer_driver_info_1(info); if (*needed > offered) { @@ -5548,7 +5548,7 @@ static WERROR getprinterdriver2_level1(fstring servername, fstring architecture, } /* fill the buffer with the structures */ - smb_io_printer_driver_info_1("", buffer, info, 0); + smb_io_printer_driver_info_1("", buffer, info, 0); out: /* clear memory */ @@ -5564,29 +5564,29 @@ static WERROR getprinterdriver2_level2(fstring servername, fstring architecture, { DRIVER_INFO_2 *info=NULL; WERROR result; - + if((info=SMB_MALLOC_P(DRIVER_INFO_2)) == NULL) return WERR_NOMEM; - + result = construct_printer_driver_info_2(info, snum, servername, architecture, version); - if (!W_ERROR_IS_OK(result)) + if (!W_ERROR_IS_OK(result)) goto out; - /* check the required size. */ + /* check the required size. */ *needed += spoolss_size_printer_driver_info_2(info); if (*needed > offered) { result = WERR_INSUFFICIENT_BUFFER; goto out; } - + if (!rpcbuf_alloc_size(buffer, *needed)) { result = WERR_NOMEM; goto out; } /* fill the buffer with the structures */ - smb_io_printer_driver_info_2("", buffer, info, 0); + smb_io_printer_driver_info_2("", buffer, info, 0); out: /* clear memory */ @@ -5609,7 +5609,7 @@ static WERROR getprinterdriver2_level3(fstring servername, fstring architecture, if (!W_ERROR_IS_OK(result)) goto out; - /* check the required size. */ + /* check the required size. */ *needed += spoolss_size_printer_driver_info_3(&info); if (*needed > offered) { @@ -5642,17 +5642,17 @@ static WERROR getprinterdriver2_level6(fstring servername, fstring architecture, ZERO_STRUCT(info); result = construct_printer_driver_info_6(&info, snum, servername, architecture, version); - if (!W_ERROR_IS_OK(result)) + if (!W_ERROR_IS_OK(result)) goto out; - /* check the required size. */ + /* check the required size. */ *needed += spoolss_size_printer_driver_info_6(&info); if (*needed > offered) { result = WERR_INSUFFICIENT_BUFFER; goto out; } - + if (!rpcbuf_alloc_size(buffer, *needed)) { result = WERR_NOMEM; goto out; @@ -5723,8 +5723,8 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ case 6: return getprinterdriver2_level6(servername, architecture, clientmajorversion, snum, buffer, offered, needed); #if 0 /* JERRY */ - case 101: - /* apparently this call is the equivalent of + case 101: + /* apparently this call is the equivalent of EnumPrinterDataEx() for the DsDriver key */ break; #endif @@ -5765,7 +5765,7 @@ WERROR _spoolss_endpageprinter(pipes_struct *p, SPOOL_Q_ENDPAGEPRINTER *q_u, SPO DEBUG(2,("_spoolss_endpageprinter: Invalid handle (%s:%u:%u).\n",OUR_HANDLE(handle))); return WERR_BADFID; } - + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; @@ -5805,22 +5805,22 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S * * So I add checks like in NT Server ... */ - + if (info_1->p_datatype != 0) { unistr2_to_ascii(datatype, &info_1->datatype, sizeof(datatype)); if (strcmp(datatype, "RAW") != 0) { (*jobid)=0; return WERR_INVALID_DATATYPE; - } - } - + } + } + /* get the share number of the printer */ if (!get_printer_snum(p, handle, &snum, NULL)) { return WERR_BADFID; } unistr2_to_ascii(jobname, &info_1->docname, sizeof(jobname)); - + Printer->jobid = print_job_start(&p->pipe_user, snum, jobname, Printer->nt_devmode); /* An error occured in print_job_start() so return an appropriate @@ -5829,7 +5829,7 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S if (Printer->jobid == -1) { return map_werror_from_unix(errno); } - + Printer->document_started=True; (*jobid) = Printer->jobid; @@ -5860,7 +5860,7 @@ WERROR _spoolss_writeprinter(pipes_struct *p, SPOOL_Q_WRITEPRINTER *q_u, SPOOL_R uint32 *buffer_written = &q_u->buffer_size2; int snum; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - + if (!Printer) { DEBUG(2,("_spoolss_writeprinter: Invalid handle (%s:%u:%u)\n",OUR_HANDLE(handle))); r_u->buffer_written = q_u->buffer_size2; @@ -5942,17 +5942,17 @@ WERROR _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R Printer_entry *Printer = find_printer_index_by_hnd(p, handle); int snum; WERROR errcode = WERR_OK; - + if (!Printer) { DEBUG(2,("_spoolss_abortprinter: Invalid handle (%s:%u:%u)\n",OUR_HANDLE(handle))); return WERR_BADFID; } - + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; - - print_job_delete( &p->pipe_user, snum, Printer->jobid, &errcode ); - + + print_job_delete( &p->pipe_user, snum, Printer->jobid, &errcode ); + return errcode; } @@ -5978,7 +5978,7 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, result = WERR_BADFID; goto done; } - + if (!secdesc_ctr) { DEBUG(10,("update_printer_sec: secdesc_ctr is NULL !\n")); result = WERR_INVALID_PARAM; @@ -6006,7 +6006,7 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, int i; the_acl = old_secdesc_ctr->sd->dacl; - DEBUG(10, ("old_secdesc_ctr for %s has %d aces:\n", + DEBUG(10, ("old_secdesc_ctr for %s has %d aces:\n", PRINTERNAME(snum), the_acl->num_aces)); for (i = 0; i < the_acl->num_aces; i++) { @@ -6014,22 +6014,22 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, sid_to_string(sid_str, &the_acl->aces[i].trustee); - DEBUG(10, ("%s 0x%08x\n", sid_str, + DEBUG(10, ("%s 0x%08x\n", sid_str, the_acl->aces[i].access_mask)); } the_acl = secdesc_ctr->sd->dacl; if (the_acl) { - DEBUG(10, ("secdesc_ctr for %s has %d aces:\n", + DEBUG(10, ("secdesc_ctr for %s has %d aces:\n", PRINTERNAME(snum), the_acl->num_aces)); for (i = 0; i < the_acl->num_aces; i++) { fstring sid_str; - + sid_to_string(sid_str, &the_acl->aces[i].trustee); - - DEBUG(10, ("%s 0x%08x\n", sid_str, + + DEBUG(10, ("%s 0x%08x\n", sid_str, the_acl->aces[i].access_mask)); } } else { @@ -6058,9 +6058,9 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, /******************************************************************** Canonicalize printer info from a client - ATTN: It does not matter what we set the servername to hear - since we do the necessary work in get_a_printer() to set it to - the correct value based on what the client sent in the + ATTN: It does not matter what we set the servername to hear + since we do the necessary work in get_a_printer() to set it to + the correct value based on what the client sent in the _spoolss_open_printer_ex(). ********************************************************************/ @@ -6068,16 +6068,16 @@ static bool check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) { fstring printername; const char *p; - + DEBUG(5,("check_printer_ok: servername=%s printername=%s sharename=%s " "portname=%s drivername=%s comment=%s location=%s\n", - info->servername, info->printername, info->sharename, + info->servername, info->printername, info->sharename, info->portname, info->drivername, info->comment, info->location)); /* we force some elements to "correct" values */ slprintf(info->servername, sizeof(info->servername)-1, "\\\\%s", global_myname()); fstrcpy(info->sharename, lp_servicename(snum)); - + /* check to see if we allow printername != sharename */ if ( lp_force_printername(snum) ) { @@ -6086,23 +6086,23 @@ static bool check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) } else { /* make sure printername is in \\server\printername format */ - + fstrcpy( printername, info->printername ); p = printername; if ( printername[0] == '\\' && printername[1] == '\\' ) { if ( (p = strchr_m( &printername[2], '\\' )) != NULL ) p++; } - + slprintf(info->printername, sizeof(info->printername)-1, "\\\\%s\\%s", global_myname(), p ); } info->attributes |= PRINTER_ATTRIBUTE_SAMBA; info->attributes &= ~PRINTER_ATTRIBUTE_NOT_SAMBA; - - - + + + return True; } @@ -6121,7 +6121,7 @@ WERROR add_port_hook(NT_USER_TOKEN *token, const char *portname, const char *uri if ( !*cmd ) { return WERR_ACCESS_DENIED; } - + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", cmd, portname, uri ); if ( token ) @@ -6133,7 +6133,7 @@ WERROR add_port_hook(NT_USER_TOKEN *token, const char *portname, const char *uri if ( is_print_op ) become_root(); - + ret = smbrun(command, &fd); if ( is_print_op ) @@ -6148,7 +6148,7 @@ WERROR add_port_hook(NT_USER_TOKEN *token, const char *portname, const char *uri close(fd); return WERR_ACCESS_DENIED; } - + return WERR_OK; } @@ -6170,7 +6170,7 @@ bool add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) standard_sub_basic(current_user_info.smb_name, current_user_info.domain, remote_machine,sizeof(remote_machine)); - + slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", cmd, printer->info_2->printername, printer->info_2->sharename, printer->info_2->portname, printer->info_2->drivername, @@ -6185,7 +6185,7 @@ bool add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) if ( is_print_op ) become_root(); - + if ( (ret = smbrun(command, &fd)) == 0 ) { /* Tell everyone we updated smb.conf. */ message_send_all(smbd_messaging_context(), @@ -6296,7 +6296,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, goto done; } - /* FIXME!!! If the driver has changed we really should verify that + /* FIXME!!! If the driver has changed we really should verify that it is installed before doing much else --jerry */ /* Check calling user has permission to update printer description */ @@ -6309,8 +6309,8 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, /* Call addprinter hook */ /* Check changes to see if this is really needed */ - - if ( *lp_addprinter_cmd() + + if ( *lp_addprinter_cmd() && (!strequal(printer->info_2->drivername, old_printer->info_2->drivername) || !strequal(printer->info_2->comment, old_printer->info_2->comment) || !strequal(printer->info_2->portname, old_printer->info_2->portname) @@ -6323,7 +6323,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, goto done; } } - + /* * When a *new* driver is bound to a printer, the drivername is used to * lookup previously saved driver initialization info, which is then @@ -6331,21 +6331,21 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, */ if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)) { - if (!set_driver_init(printer, 2)) + if (!set_driver_init(printer, 2)) { DEBUG(5,("update_printer: Error restoring driver initialization data for driver [%s]!\n", printer->info_2->drivername)); } - + DEBUG(10,("update_printer: changing driver [%s]! Sending event!\n", printer->info_2->drivername)); - + notify_printer_driver(snum, printer->info_2->drivername); } - /* - * flag which changes actually occured. This is a small subset of - * all the possible changes. We also have to update things in the + /* + * flag which changes actually occured. This is a small subset of + * all the possible changes. We also have to update things in the * DsSpooler key. */ @@ -6367,12 +6367,12 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, if (!strequal(printer->info_2->printername, old_printer->info_2->printername)) { char *pname; - + if ( (pname = strchr_m( printer->info_2->printername+2, '\\' )) != NULL ) pname++; else pname = printer->info_2->printername; - + init_unistr2( &buffer, pname, UNI_STR_TERMINATE); set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "printerName", @@ -6380,7 +6380,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, notify_printer_printername( snum, pname ); } - + if (!strequal(printer->info_2->portname, old_printer->info_2->portname)) { init_unistr2( &buffer, printer->info_2->portname, UNI_STR_TERMINATE); set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "portName", @@ -6396,10 +6396,10 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, notify_printer_location(snum, printer->info_2->location); } - + /* here we need to update some more DsSpooler keys */ /* uNCName, serverName, shortServerName */ - + init_unistr2( &buffer, global_myname(), UNI_STR_TERMINATE); set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "serverName", REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 ); @@ -6446,9 +6446,9 @@ static WERROR publish_or_unpublish_printer(pipes_struct *p, POLICY_HND *handle, if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; - + nt_printer_publish(Printer, snum, info7->action); - + return WERR_OK; #else return WERR_UNKNOWN_LEVEL; @@ -6468,19 +6468,19 @@ WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET WERROR result; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - + if (!Printer) { DEBUG(2,("_spoolss_setprinter: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle))); return WERR_BADFID; } - /* check the level */ + /* check the level */ switch (level) { case 0: return control_printer(handle, command, p); case 2: result = update_printer(p, handle, level, info, devmode_ctr.devmode); - if (!W_ERROR_IS_OK(result)) + if (!W_ERROR_IS_OK(result)) return result; if (secdesc_ctr) result = update_printer_sec(handle, level, info, p, secdesc_ctr); @@ -6502,7 +6502,7 @@ WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u) { POLICY_HND *handle = &q_u->handle; Printer_entry *Printer= find_printer_index_by_hnd(p, handle); - + if (!Printer) { DEBUG(2,("_spoolss_fcpn: Invalid handle (%s:%u:%u)\n", OUR_HANDLE(handle))); return WERR_BADFID; @@ -6555,14 +6555,14 @@ WERROR _spoolss_addjob(pipes_struct *p, SPOOL_Q_ADDJOB *q_u, SPOOL_R_ADDJOB *r_u ****************************************************************************/ static void fill_job_info_1(JOB_INFO_1 *job_info, const print_queue_struct *queue, - int position, int snum, + int position, int snum, const NT_PRINTER_INFO_LEVEL *ntprinter) { struct tm *t; - + t=gmtime(&queue->time); - job_info->jobid=queue->job; + job_info->jobid=queue->job; init_unistr(&job_info->printername, lp_servicename(snum)); init_unistr(&job_info->machinename, ntprinter->info_2->servername); init_unistr(&job_info->username, queue->fs_user); @@ -6582,7 +6582,7 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, const print_queue_struct *queu ****************************************************************************/ static bool fill_job_info_2(JOB_INFO_2 *job_info, const print_queue_struct *queue, - int position, int snum, + int position, int snum, const NT_PRINTER_INFO_LEVEL *ntprinter, DEVICEMODE *devmode) { @@ -6591,9 +6591,9 @@ static bool fill_job_info_2(JOB_INFO_2 *job_info, const print_queue_struct *queu t=gmtime(&queue->time); job_info->jobid=queue->job; - + init_unistr(&job_info->printername, ntprinter->info_2->printername); - + init_unistr(&job_info->machinename, ntprinter->info_2->servername); init_unistr(&job_info->username, queue->fs_user); init_unistr(&job_info->document, queue->fs_file); @@ -6603,7 +6603,7 @@ static bool fill_job_info_2(JOB_INFO_2 *job_info, const print_queue_struct *queu init_unistr(&job_info->parameters, ""); init_unistr(&job_info->drivername, ntprinter->info_2->drivername); init_unistr(&job_info->text_status, ""); - + /* and here the security descriptor */ job_info->status=nt_printj_status(queue->status); @@ -6634,17 +6634,17 @@ static WERROR enumjobs_level1(const print_queue_struct *queue, int snum, JOB_INFO_1 *info; int i; WERROR result = WERR_OK; - + info=SMB_MALLOC_ARRAY(JOB_INFO_1,*returned); if (info==NULL) { *returned=0; return WERR_NOMEM; } - + for (i=0; i<*returned; i++) fill_job_info_1( &info[i], &queue[i], i, snum, ntprinter ); - /* check the required size. */ + /* check the required size. */ for (i=0; i<*returned; i++) (*needed) += spoolss_size_job_info_1(&info[i]); @@ -6660,7 +6660,7 @@ static WERROR enumjobs_level1(const print_queue_struct *queue, int snum, /* fill the buffer with the structures */ for (i=0; i<*returned; i++) - smb_io_job_info_1("", buffer, &info[i], 0); + smb_io_job_info_1("", buffer, &info[i], 0); out: /* clear memory */ @@ -6685,20 +6685,20 @@ static WERROR enumjobs_level2(const print_queue_struct *queue, int snum, int i; WERROR result = WERR_OK; DEVICEMODE *devmode = NULL; - + if ( !(info = SMB_MALLOC_ARRAY(JOB_INFO_2,*returned)) ) { *returned=0; return WERR_NOMEM; } - + /* this should not be a failure condition if the devmode is NULL */ - + devmode = construct_dev_mode(lp_const_servicename(snum)); for (i=0; i<*returned; i++) fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter, devmode); - /* check the required size. */ + /* check the required size. */ for (i=0; i<*returned; i++) (*needed) += spoolss_size_job_info_2(&info[i]); @@ -6714,7 +6714,7 @@ static WERROR enumjobs_level2(const print_queue_struct *queue, int snum, /* fill the buffer with the structures */ for (i=0; i<*returned; i++) - smb_io_job_info_2("", buffer, &info[i], 0); + smb_io_job_info_2("", buffer, &info[i], 0); out: free_devmode(devmode); @@ -6732,7 +6732,7 @@ out: ****************************************************************************/ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJOBS *r_u) -{ +{ POLICY_HND *handle = &q_u->handle; uint32 level = q_u->level; RPC_BUFFER *buffer = NULL; @@ -6760,14 +6760,14 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO *returned=0; /* lookup the printer snum and tdb entry */ - + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; wret = get_a_printer(NULL, &ntprinter, 2, lp_servicename(snum)); if ( !W_ERROR_IS_OK(wret) ) return wret; - + *returned = print_queue_status(snum, &queue, &prt_status); DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); @@ -6789,7 +6789,7 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO wret = WERR_UNKNOWN_LEVEL; break; } - + SAFE_FREE(queue); free_a_printer( &ntprinter, 2 ); return wret; @@ -6814,7 +6814,7 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u int snum; WERROR errcode = WERR_BADFUNC; - + if (!get_printer_snum(p, handle, &snum, NULL)) { return WERR_BADFID; } @@ -6833,7 +6833,7 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u case JOB_CONTROL_PAUSE: if (print_job_pause(&p->pipe_user, snum, jobid, &errcode)) { errcode = WERR_OK; - } + } break; case JOB_CONTROL_RESTART: case JOB_CONTROL_RESUME: @@ -6886,21 +6886,21 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture WERROR status; DEBUGADD(5,("\tdriver: [%s]\n", list[i])); ZERO_STRUCT(driver); - status = get_a_printer_driver(&driver, 3, list[i], + status = get_a_printer_driver(&driver, 3, list[i], architecture, version); if (!W_ERROR_IS_OK(status)) { SAFE_FREE(list); SAFE_FREE(driver_info_1); return status; } - fill_printer_driver_info_1(&driver_info_1[*returned+i], driver, servername, architecture ); + fill_printer_driver_info_1(&driver_info_1[*returned+i], driver, servername, architecture ); free_a_printer_driver(driver, 3); - } + } *returned+=ndrivers; SAFE_FREE(list); } - + /* check the required size. */ for (i=0; i<*returned; i++) { DEBUGADD(6,("adding driver [%d]'s size\n",i)); @@ -6913,7 +6913,7 @@ static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture } if (!rpcbuf_alloc_size(buffer, *needed)) { - result = WERR_NOMEM; + result = WERR_NOMEM; goto out; } @@ -6965,27 +6965,27 @@ static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture return WERR_NOMEM; } } - + for (i=0; ibuffer; DEBUG(4,("_spoolss_enumprinterdrivers\n")); - + *needed = 0; *returned = 0; @@ -7165,9 +7165,9 @@ static void fill_form_1(FORM_1 *form, nt_forms_struct *list) form->left=list->left; form->top=list->top; form->right=list->right; - form->bottom=list->bottom; + form->bottom=list->bottom; } - + /**************************************************************************** ****************************************************************************/ @@ -7225,14 +7225,14 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF DEBUGADD(6,("Filling form number [%d]\n",i)); fill_form_1(&forms_1[i], &builtinlist[i]); } - + SAFE_FREE(builtinlist); for (; i<*numofforms; i++) { DEBUGADD(6,("Filling form number [%d]\n",i)); fill_form_1(&forms_1[i], &list[i-numbuiltinforms]); } - + SAFE_FREE(list); /* check the required size. */ @@ -7245,14 +7245,14 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF buffer_size += spoolss_size_form_1(&forms_1[i]); } - *needed=buffer_size; - + *needed=buffer_size; + if (*needed > offered) { SAFE_FREE(forms_1); *numofforms=0; return WERR_INSUFFICIENT_BUFFER; } - + if (!rpcbuf_alloc_size(buffer, buffer_size)){ SAFE_FREE(forms_1); *numofforms=0; @@ -7272,7 +7272,7 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF SAFE_FREE(forms_1); return WERR_OK; - + default: SAFE_FREE(list); SAFE_FREE(builtinlist); @@ -7340,7 +7340,7 @@ WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * break; } } - + SAFE_FREE(list); if (i == numofforms) { return WERR_BADFID; @@ -7349,8 +7349,8 @@ WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * /* check the required size. */ *needed=spoolss_size_form_1(&form_1); - - if (*needed > offered) + + if (*needed > offered) return WERR_INSUFFICIENT_BUFFER; if (!rpcbuf_alloc_size(buffer, buffer_size)) @@ -7361,7 +7361,7 @@ WERROR _spoolss_getform(pipes_struct *p, SPOOL_Q_GETFORM *q_u, SPOOL_R_GETFORM * smb_io_form_1("", buffer, &form_1, 0); return WERR_OK; - + default: SAFE_FREE(list); return WERR_UNKNOWN_LEVEL; @@ -7377,7 +7377,7 @@ static void fill_port_1(PORT_INFO_1 *port, const char *name) } /**************************************************************************** - TODO: This probably needs distinguish between TCP/IP and Local ports + TODO: This probably needs distinguish between TCP/IP and Local ports somehow. ****************************************************************************/ @@ -7387,7 +7387,7 @@ static void fill_port_2(PORT_INFO_2 *port, const char *name) init_unistr(&port->monitor_name, "Local Monitor"); init_unistr(&port->description, SPL_LOCAL_PORT ); port->port_type=PORT_TYPE_WRITE; - port->reserved=0x0; + port->reserved=0x0; } @@ -7408,7 +7408,7 @@ WERROR enumports_hook( int *count, char ***lines ) *lines = NULL; /* if no hook then just fill in the default port */ - + if ( !*cmd ) { if (!(qlines = SMB_MALLOC_ARRAY( char*, 2 ))) { return WERR_NOMEM; @@ -7422,7 +7422,7 @@ WERROR enumports_hook( int *count, char ***lines ) } else { /* we have a valid enumport command */ - + slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 1); DEBUG(10,("Running [%s]\n", command)); @@ -7440,7 +7440,7 @@ WERROR enumports_hook( int *count, char ***lines ) DEBUGADD(10,("Lines returned = [%d]\n", numlines)); close(fd); } - + *count = numlines; *lines = qlines; @@ -7464,10 +7464,10 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need file_lines_free(qlines); return result; } - + if(numlines) { if((ports=SMB_MALLOC_ARRAY( PORT_INFO_1, numlines )) == NULL) { - DEBUG(10,("Returning WERR_NOMEM [%s]\n", + DEBUG(10,("Returning WERR_NOMEM [%s]\n", dos_errstr(WERR_NOMEM))); file_lines_free(qlines); return WERR_NOMEM; @@ -7487,7 +7487,7 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need DEBUGADD(6,("adding port [%d]'s size\n", i)); *needed += spoolss_size_port_info_1(&ports[i]); } - + if (*needed > offered) { result = WERR_INSUFFICIENT_BUFFER; goto out; @@ -7530,7 +7530,7 @@ static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *need file_lines_free(qlines); return result; } - + if(numlines) { if((ports=SMB_MALLOC_ARRAY( PORT_INFO_2, numlines)) == NULL) { file_lines_free(qlines); @@ -7552,7 +7552,7 @@ static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *need DEBUGADD(6,("adding port [%d]'s size\n", i)); *needed += spoolss_size_port_info_2(&ports[i]); } - + if (*needed > offered) { result = WERR_INSUFFICIENT_BUFFER; goto out; @@ -7600,10 +7600,10 @@ WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUM buffer = r_u->buffer; DEBUG(4,("_spoolss_enumports\n")); - + *returned=0; *needed=0; - + switch (level) { case 1: return enumports_level_1(buffer, offered, needed, returned); @@ -7642,12 +7642,12 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ /* check to see if the printer already exists */ if ((snum = print_queue_snum(printer->info_2->sharename)) != -1) { - DEBUG(5, ("spoolss_addprinterex_level_2: Attempted to add a printer named [%s] when one already existed!\n", + DEBUG(5, ("spoolss_addprinterex_level_2: Attempted to add a printer named [%s] when one already existed!\n", printer->info_2->sharename)); free_a_printer(&printer, 2); return WERR_PRINTER_ALREADY_EXISTS; } - + /* FIXME!!! smbd should check to see if the driver is installed before trying to add a printer like this --jerry */ @@ -7663,13 +7663,13 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ printer->info_2->sharename )); } - /* use our primary netbios name since get_a_printer() will convert + /* use our primary netbios name since get_a_printer() will convert it to what the client expects on a case by case basis */ slprintf(name, sizeof(name)-1, "\\\\%s\\%s", global_myname(), printer->info_2->sharename); - + if ((snum = print_queue_snum(printer->info_2->sharename)) == -1) { free_a_printer(&printer,2); return WERR_ACCESS_DENIED; @@ -7678,9 +7678,9 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ /* 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 WERR_ACCESS_DENIED; + return WERR_ACCESS_DENIED; } - + /* * Do sanity check on the requested changes for Samba. */ @@ -7692,7 +7692,7 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ /* * When a printer is created, the drivername bound to the printer is used - * to lookup previously saved driver initialization info, which is then + * to lookup previously saved driver initialization info, which is then * bound to the new printer, simulating what happens in the Windows arch. */ @@ -7700,7 +7700,7 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ { set_driver_init(printer, 2); } - else + else { /* A valid devmode was included, convert and link it */ @@ -7793,13 +7793,13 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, goto done; } - /* + /* * I think this is where he DrvUpgradePrinter() hook would be * be called in a driver's interface DLL on a Windows NT 4.0/2k * server. Right now, we just need to send ourselves a message - * to update each printer bound to this driver. --jerry + * to update each printer bound to this driver. --jerry */ - + if (!srv_spoolss_drv_upgrade_printer(driver_name)) { DEBUG(0,("_spoolss_addprinterdriver: Failed to send message about upgrading driver [%s]!\n", driver_name)); @@ -7825,11 +7825,11 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, /* * 9x printer driver - never delete init data */ - case 0: + case 0: DEBUG(10,("_spoolss_addprinterdriver: init data not deleted for 9x driver [%s]\n", driver_name)); break; - + /* * Nt or 2k (compatiblity mode) printer driver - only delete init data if * there is no 2k/Xp driver init data for this driver name. @@ -7849,7 +7849,7 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, * a 2k/Xp driver was found, don't delete init data because Nt driver will use it. */ free_a_printer_driver(driver1,3); - DEBUG(10,("_spoolss_addprinterdriver: init data not deleted for Nt driver [%s]\n", + DEBUG(10,("_spoolss_addprinterdriver: init data not deleted for Nt driver [%s]\n", driver_name)); } } @@ -7858,7 +7858,7 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, /* * 2k or Xp printer driver - always delete init data */ - case 3: + case 3: if (!del_driver_init(driver_name)) DEBUG(6,("_spoolss_addprinterdriver: del_driver_init(%s) 2k/Xp failed!\n", driver_name)); break; @@ -7868,7 +7868,7 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, break; } - + done: free_a_printer_driver(driver, level); return err; @@ -7882,15 +7882,15 @@ WERROR _spoolss_addprinterdriverex(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVEREX * { SPOOL_Q_ADDPRINTERDRIVER q_u_local; SPOOL_R_ADDPRINTERDRIVER r_u_local; - - /* + + /* * we only support the semantics of AddPrinterDriver() * i.e. only copy files that are newer than existing ones */ - + if ( q_u->copy_flags != APD_COPY_NEW_FILES ) return WERR_ACCESS_DENIED; - + ZERO_STRUCT(q_u_local); ZERO_STRUCT(r_u_local); @@ -7899,7 +7899,7 @@ WERROR _spoolss_addprinterdriverex(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVEREX * copy_unistr2(&q_u_local.server_name, &q_u->server_name); q_u_local.level = q_u->level; memcpy( &q_u_local.info, &q_u->info, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL) ); - + return _spoolss_addprinterdriver( p, &q_u_local, &r_u_local ); } @@ -7919,7 +7919,7 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen pstring path; pstring long_archi; fstring servername; - char *pservername; + char *pservername; const char *short_archi; DRIVER_DIRECTORY_1 *info=NULL; WERROR result = WERR_OK; @@ -7933,8 +7933,8 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen pservername = servername; if ( *pservername == '\\' && strlen(servername)>2 ) { pservername += 2; - } - + } + if ( !is_myname_or_ipaddr( pservername ) ) return WERR_INVALID_PARAM; @@ -7949,7 +7949,7 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen DEBUG(4,("printer driver directory: [%s]\n", path)); fill_driverdir_1(info, path); - + *needed += spoolss_size_driverdir_info_1(info); if (*needed > offered) { @@ -7966,7 +7966,7 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen out: SAFE_FREE(info); - + return result; } @@ -8002,7 +8002,7 @@ WERROR _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRI return WERR_UNKNOWN_LEVEL; } } - + /**************************************************************************** ****************************************************************************/ @@ -8021,7 +8021,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S uint32 *out_data_len = &r_u->realdatasize; NT_PRINTER_INFO_LEVEL *printer = NULL; - + uint32 biggest_valuesize; uint32 biggest_datasize; uint32 data_len; @@ -8032,7 +8032,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S NT_PRINTER_DATA *p_data; int i, key_index, num_values; int name_length; - + *out_type = 0; *out_max_data_len = 0; @@ -8048,12 +8048,12 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S if (!get_printer_snum(p,handle, &snum, NULL)) return WERR_BADFID; - + result = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(result)) return result; - - p_data = printer->info_2->data; + + p_data = printer->info_2->data; key_index = lookup_printerkey( p_data, SPOOL_PRINTERDATA_KEY ); result = WERR_OK; @@ -8063,34 +8063,34 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S * * cf: MSDN EnumPrinterData remark section */ - - if ( !in_value_len && !in_data_len && (key_index != -1) ) + + if ( !in_value_len && !in_data_len && (key_index != -1) ) { DEBUGADD(6,("Activating NT mega-hack to find sizes\n")); biggest_valuesize = 0; biggest_datasize = 0; - + num_values = regval_ctr_numvals( p_data->keys[key_index].values ); - + for ( i=0; ikeys[key_index].values, i ); - + name_length = strlen(val->valuename); - if ( strlen(val->valuename) > biggest_valuesize ) + if ( strlen(val->valuename) > biggest_valuesize ) biggest_valuesize = name_length; - + if ( val->size > biggest_datasize ) biggest_datasize = val->size; - - DEBUG(6,("current values: [%d], [%d]\n", biggest_valuesize, + + DEBUG(6,("current values: [%d], [%d]\n", biggest_valuesize, biggest_datasize)); } - /* the value is an UNICODE string but real_value_size is the length + /* the value is an UNICODE string but real_value_size is the length in bytes including the trailing 0 */ - + *out_value_len = 2 * (1+biggest_valuesize); *out_data_len = biggest_datasize; @@ -8098,23 +8098,23 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S goto done; } - + /* * the value len is wrong in NT sp3 * that's the number of bytes not the number of unicode chars */ - + if ( key_index != -1 ) val = regval_ctr_specific_value( p_data->keys[key_index].values, idx ); - if ( !val ) + if ( !val ) { /* out_value should default to "" or else NT4 has problems unmarshalling the response */ *out_max_value_len=(in_value_len/sizeof(uint16)); - + if (in_value_len) { if((*out_value=(uint16 *)TALLOC_ZERO(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL) { @@ -8128,12 +8128,12 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S } /* the data is counted in bytes */ - + *out_max_data_len = in_data_len; *out_data_len = in_data_len; - + /* only allocate when given a non-zero data_len */ - + if ( in_data_len && ((*data_out=(uint8 *)TALLOC_ZERO(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) ) { result = WERR_NOMEM; @@ -8142,7 +8142,7 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S result = WERR_NO_MORE_ITEMS; } - else + else { /* * the value is: @@ -8152,16 +8152,16 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S * * take a pause *before* coding not *during* coding */ - + /* name */ *out_max_value_len=(in_value_len/sizeof(uint16)); if (in_value_len) { - if ( (*out_value = (uint16 *)TALLOC_ZERO(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL ) + if ( (*out_value = (uint16 *)TALLOC_ZERO(p->mem_ctx, in_value_len*sizeof(uint8))) == NULL ) { result = WERR_NOMEM; goto done; } - + *out_value_len = (uint32)rpcstr_push((char *)*out_value, regval_name(val), (size_t)in_value_len, 0); } else { *out_value = NULL; @@ -8169,13 +8169,13 @@ WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, S } /* type */ - + *out_type = regval_type( val ); /* data - counted in bytes */ *out_max_data_len = in_data_len; - if ( in_data_len && (*data_out = (uint8 *)TALLOC_ZERO(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) + if ( in_data_len && (*data_out = (uint8 *)TALLOC_ZERO(p->mem_ctx, in_data_len*sizeof(uint8))) == NULL) { result = WERR_NOMEM; goto done; @@ -8207,7 +8207,7 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP WERROR status = WERR_OK; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); fstring valuename; - + DEBUG(5,("spoolss_setprinterdata\n")); if (!Printer) { @@ -8223,15 +8223,15 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP if (!get_printer_snum(p,handle, &snum, NULL)) return WERR_BADFID; - /* - * Access check : NT returns "access denied" if you make a + /* + * 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 (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { DEBUG(3, ("_spoolss_setprinterdata: change denied by handle access permissions\n")); status = WERR_ACCESS_DENIED; @@ -8243,22 +8243,22 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP return status; unistr2_to_ascii(valuename, value, sizeof(valuename)); - + /* * 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 ( (type == REG_BINARY) && strequal( valuename, PHANTOM_DEVMODE_KEY)) + if ( (type == REG_BINARY) && strequal( valuename, PHANTOM_DEVMODE_KEY)) { /* Set devmode and printer initialization info */ status = save_driver_init( printer, 2, data, real_len ); - + srv_spoolss_reset_printerdata( printer->info_2->drivername ); } - else + else { - status = set_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, valuename, + status = set_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, valuename, type, data, real_len ); if ( W_ERROR_IS_OK(status) ) status = mod_a_printer(printer, 2); @@ -8278,7 +8278,7 @@ WERROR _spoolss_resetprinter(pipes_struct *p, SPOOL_Q_RESETPRINTER *q_u, SPOOL_R POLICY_HND *handle = &q_u->handle; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); int snum; - + DEBUG(5,("_spoolss_resetprinter\n")); /* @@ -8286,7 +8286,7 @@ WERROR _spoolss_resetprinter(pipes_struct *p, SPOOL_Q_RESETPRINTER *q_u, SPOOL_R * This call really doesn't mean anything to us because we only * support RAW printing. --jerry */ - + if (!Printer) { DEBUG(2,("_spoolss_resetprinter: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; @@ -8296,7 +8296,7 @@ WERROR _spoolss_resetprinter(pipes_struct *p, SPOOL_Q_RESETPRINTER *q_u, SPOOL_R return WERR_BADFID; - /* blindly return success */ + /* blindly return success */ return WERR_OK; } @@ -8314,9 +8314,9 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ WERROR status = WERR_OK; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); pstring valuename; - + DEBUG(5,("spoolss_deleteprinterdata\n")); - + if (!Printer) { DEBUG(2,("_spoolss_deleteprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; @@ -8337,7 +8337,7 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ unistr2_to_ascii(valuename, value, sizeof(valuename)); status = delete_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, valuename ); - + if ( W_ERROR_IS_OK(status) ) mod_a_printer( printer, 2 ); @@ -8368,15 +8368,15 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM DEBUG(2,("_spoolss_addform: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } - - + + /* forms can be added on printer of on the print server handle */ - + if ( Printer->printer_type == SPLHND_PRINTER ) { if (!get_printer_snum(p,handle, &snum, NULL)) return WERR_BADFID; - + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) goto done; @@ -8387,30 +8387,30 @@ WERROR _spoolss_addform( pipes_struct *p, SPOOL_Q_ADDFORM *q_u, SPOOL_R_ADDFORM status = WERR_ACCESS_DENIED; goto done; } - + /* can't add if builtin */ - + if (get_a_builtin_ntform(&form->name,&tmpForm)) { status = WERR_ALREADY_EXISTS; goto done; } count = get_ntforms(&list); - + if(!add_a_form(&list, form, &count)) { status = WERR_NOMEM; goto done; } - + write_ntforms(&list, count); - + /* * ChangeID must always be set if this is a printer */ - + if ( Printer->printer_type == SPLHND_PRINTER ) status = mod_a_printer(printer, 2); - + done: if ( printer ) free_a_printer(&printer, 2); @@ -8442,12 +8442,12 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE } /* forms can be deleted on printer of on the print server handle */ - + if ( Printer->printer_type == SPLHND_PRINTER ) { if (!get_printer_snum(p,handle, &snum, NULL)) return WERR_BADFID; - + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) goto done; @@ -8460,24 +8460,24 @@ WERROR _spoolss_deleteform( pipes_struct *p, SPOOL_Q_DELETEFORM *q_u, SPOOL_R_DE } /* can't delete if builtin */ - + if (get_a_builtin_ntform(form_name,&tmpForm)) { status = WERR_INVALID_PARAM; goto done; } count = get_ntforms(&list); - + if ( !delete_a_form(&list, form_name, &count, &status )) goto done; /* * ChangeID must always be set if this is a printer */ - + if ( Printer->printer_type == SPLHND_PRINTER ) status = mod_a_printer(printer, 2); - + done: if ( printer ) free_a_printer(&printer, 2); @@ -8510,12 +8510,12 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * } /* forms can be modified on printer of on the print server handle */ - + if ( Printer->printer_type == SPLHND_PRINTER ) { if (!get_printer_snum(p,handle, &snum, NULL)) return WERR_BADFID; - + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) goto done; @@ -8540,11 +8540,11 @@ WERROR _spoolss_setform(pipes_struct *p, SPOOL_Q_SETFORM *q_u, SPOOL_R_SETFORM * /* * ChangeID must always be set if this is a printer */ - + if ( Printer->printer_type == SPLHND_PRINTER ) status = mod_a_printer(printer, 2); - - + + done: if ( printer ) free_a_printer(&printer, 2); @@ -8561,12 +8561,12 @@ static WERROR enumprintprocessors_level_1(RPC_BUFFER *buffer, uint32 offered, ui { PRINTPROCESSOR_1 *info_1=NULL; WERROR result = WERR_OK; - + if((info_1 = SMB_MALLOC_P(PRINTPROCESSOR_1)) == NULL) return WERR_NOMEM; (*returned) = 0x1; - + init_unistr(&info_1->name, "winprint"); *needed += spoolss_size_printprocessor_info_1(info_1); @@ -8620,10 +8620,10 @@ WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS * Just reply with "winprint", to keep NT happy * and I can use my nice printer checker. */ - + *returned=0; *needed=0; - + switch (level) { case 1: return enumprintprocessors_level_1(buffer, offered, needed, returned); @@ -8640,12 +8640,12 @@ static WERROR enumprintprocdatatypes_level_1(RPC_BUFFER *buffer, uint32 offered, { PRINTPROCDATATYPE_1 *info_1=NULL; WERROR result = WERR_OK; - + if((info_1 = SMB_MALLOC_P(PRINTPROCDATATYPE_1)) == NULL) return WERR_NOMEM; (*returned) = 0x1; - + init_unistr(&info_1->name, "RAW"); *needed += spoolss_size_printprocdatatype_info_1(info_1); @@ -8692,10 +8692,10 @@ WERROR _spoolss_enumprintprocdatatypes(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCDAT buffer = r_u->buffer; DEBUG(5,("_spoolss_enumprintprocdatatypes\n")); - + *returned=0; *needed=0; - + switch (level) { case 1: return enumprintprocdatatypes_level_1(buffer, offered, needed, returned); @@ -8713,19 +8713,19 @@ static WERROR enumprintmonitors_level_1(RPC_BUFFER *buffer, uint32 offered, uint PRINTMONITOR_1 *info_1; WERROR result = WERR_OK; int i; - + if((info_1 = SMB_MALLOC_ARRAY(PRINTMONITOR_1, 2)) == NULL) return WERR_NOMEM; *returned = 2; - - init_unistr(&(info_1[0].name), SPL_LOCAL_PORT ); + + init_unistr(&(info_1[0].name), SPL_LOCAL_PORT ); init_unistr(&(info_1[1].name), SPL_TCPIP_PORT ); for ( i=0; i<*returned; i++ ) { *needed += spoolss_size_printmonitor_info_1(&info_1[i]); } - + if (*needed > offered) { result = WERR_INSUFFICIENT_BUFFER; goto out; @@ -8758,16 +8758,16 @@ static WERROR enumprintmonitors_level_2(RPC_BUFFER *buffer, uint32 offered, uint PRINTMONITOR_2 *info_2; WERROR result = WERR_OK; int i; - + if((info_2 = SMB_MALLOC_ARRAY(PRINTMONITOR_2, 2)) == NULL) return WERR_NOMEM; *returned = 2; - + init_unistr( &(info_2[0].name), SPL_LOCAL_PORT ); init_unistr( &(info_2[0].environment), "Windows NT X86" ); init_unistr( &(info_2[0].dll_name), "localmon.dll" ); - + init_unistr( &(info_2[1].name), SPL_TCPIP_PORT ); init_unistr( &(info_2[1].environment), "Windows NT X86" ); init_unistr( &(info_2[1].dll_name), "tcpmon.dll" ); @@ -8775,7 +8775,7 @@ static WERROR enumprintmonitors_level_2(RPC_BUFFER *buffer, uint32 offered, uint for ( i=0; i<*returned; i++ ) { *needed += spoolss_size_printmonitor_info_2(&info_2[i]); } - + if (*needed > offered) { result = WERR_INSUFFICIENT_BUFFER; goto out; @@ -8795,7 +8795,7 @@ out: if ( !W_ERROR_IS_OK(result) ) *returned = 0; - + return result; } @@ -8827,10 +8827,10 @@ WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_ * Just reply with "Local Port", to keep NT happy * and I can use my nice printer checker. */ - + *returned=0; *needed=0; - + switch (level) { case 1: return enumprintmonitors_level_1(buffer, offered, needed, returned); @@ -8846,7 +8846,7 @@ WERROR _spoolss_enumprintmonitors(pipes_struct *p, SPOOL_Q_ENUMPRINTMONITORS *q_ static WERROR getjob_level_1(print_queue_struct **queue, int count, int snum, NT_PRINTER_INFO_LEVEL *ntprinter, - uint32 jobid, RPC_BUFFER *buffer, uint32 offered, + uint32 jobid, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { int i=0; @@ -8859,20 +8859,20 @@ static WERROR getjob_level_1(print_queue_struct **queue, int count, int snum, if (info_1 == NULL) { return WERR_NOMEM; } - - for (i=0; i offered) { @@ -8896,9 +8896,9 @@ out: /**************************************************************************** ****************************************************************************/ -static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, +static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, NT_PRINTER_INFO_LEVEL *ntprinter, - uint32 jobid, RPC_BUFFER *buffer, uint32 offered, + uint32 jobid, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { int i = 0; @@ -8913,25 +8913,25 @@ static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, ZERO_STRUCTP(info_2); - for ( i=0; i offered) { @@ -8958,7 +8958,7 @@ static WERROR getjob_level_2(print_queue_struct **queue, int count, int snum, smb_io_job_info_2("", buffer, info_2, 0); result = WERR_OK; - + done: /* Cleanup allocated memory */ @@ -8996,44 +8996,44 @@ WERROR _spoolss_getjob( pipes_struct *p, SPOOL_Q_GETJOB *q_u, SPOOL_R_GETJOB *r_ buffer = r_u->buffer; DEBUG(5,("spoolss_getjob\n")); - + *needed = 0; - + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; - + wstatus = get_a_printer(NULL, &ntprinter, 2, lp_servicename(snum)); if ( !W_ERROR_IS_OK(wstatus) ) return wstatus; - + count = print_queue_status(snum, &queue, &prt_status); - + DEBUGADD(4,("count:[%d], prt_status:[%d], [%s]\n", count, prt_status.status, prt_status.message)); - + switch ( level ) { case 1: - wstatus = getjob_level_1(&queue, count, snum, ntprinter, jobid, + wstatus = getjob_level_1(&queue, count, snum, ntprinter, jobid, buffer, offered, needed); break; case 2: - wstatus = getjob_level_2(&queue, count, snum, ntprinter, jobid, + wstatus = getjob_level_2(&queue, count, snum, ntprinter, jobid, buffer, offered, needed); break; default: wstatus = WERR_UNKNOWN_LEVEL; break; } - + SAFE_FREE(queue); free_a_printer( &ntprinter, 2 ); - + return wstatus; } /******************************************************************** spoolss_getprinterdataex - + From MSDN documentation of GetPrinterDataEx: pass request to GetPrinterData if key is "PrinterDriverData". ********************************************************************/ @@ -9047,9 +9047,9 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, uint8 **data = &r_u->data; uint32 *needed = &r_u->needed; fstring keyname, valuename; - + Printer_entry *Printer = find_printer_index_by_hnd(p, handle); - + NT_PRINTER_INFO_LEVEL *printer = NULL; int snum = 0; WERROR status = WERR_OK; @@ -9058,12 +9058,12 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, unistr2_to_ascii(keyname, &q_u->keyname, sizeof(keyname)); unistr2_to_ascii(valuename, &q_u->valuename, sizeof(valuename)); - - DEBUG(10, ("_spoolss_getprinterdataex: key => [%s], value => [%s]\n", + + DEBUG(10, ("_spoolss_getprinterdataex: key => [%s], value => [%s]\n", keyname, valuename)); /* in case of problem, return some default values */ - + *needed = 0; *type = 0; *out_size = in_size; @@ -9081,7 +9081,7 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, status = WERR_INVALID_PARAM; goto done; } - + if ( !get_printer_snum(p,handle, &snum, NULL) ) return WERR_BADFID; @@ -9094,29 +9094,29 @@ WERROR _spoolss_getprinterdataex(pipes_struct *p, SPOOL_Q_GETPRINTERDATAEX *q_u, status = WERR_INVALID_PARAM; goto done; } - + if ( lookup_printerkey( printer->info_2->data, keyname ) == -1 ) { DEBUG(4,("_spoolss_getprinterdataex: Invalid keyname [%s]\n", keyname )); free_a_printer( &printer, 2 ); status = WERR_BADFILE; goto done; } - + /* When given a new keyname, we should just create it */ status = get_printer_dataex( p->mem_ctx, printer, keyname, valuename, type, data, needed, in_size ); - + if (*needed > *out_size) status = WERR_MORE_DATA; done: - if ( !W_ERROR_IS_OK(status) ) + if ( !W_ERROR_IS_OK(status) ) { DEBUG(5, ("error: allocating %d\n", *out_size)); - + /* reply this param doesn't exist */ - - if ( *out_size ) + + if ( *out_size ) { if( (*data=(uint8 *)TALLOC_ZERO(p->mem_ctx, *out_size*sizeof(uint8))) == NULL ) { status = WERR_NOMEM; @@ -9126,10 +9126,10 @@ done: *data = NULL; } } - + if ( printer ) free_a_printer( &printer, 2 ); - + return status; } @@ -9139,7 +9139,7 @@ done: WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, SPOOL_R_SETPRINTERDATAEX *r_u) { - POLICY_HND *handle = &q_u->handle; + POLICY_HND *handle = &q_u->handle; uint32 type = q_u->type; uint8 *data = q_u->data; uint32 real_len = q_u->real_len; @@ -9151,7 +9151,7 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, fstring valuename; fstring keyname; char *oid_string; - + DEBUG(4,("_spoolss_setprinterdataex\n")); /* From MSDN documentation of SetPrinterDataEx: pass request to @@ -9170,15 +9170,15 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, if ( !get_printer_snum(p,handle, &snum, NULL) ) return WERR_BADFID; - /* - * Access check : NT returns "access denied" if you make a + /* + * 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 (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) + if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) { DEBUG(3, ("_spoolss_setprinterdataex: change denied by handle access permissions\n")); return WERR_ACCESS_DENIED; @@ -9190,9 +9190,9 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, unistr2_to_ascii( valuename, &q_u->value, sizeof(valuename)); unistr2_to_ascii( keyname, &q_u->key, sizeof(keyname)); - + /* check for OID in valuename */ - + if ( (oid_string = strchr( valuename, ',' )) != NULL ) { *oid_string = '\0'; @@ -9200,31 +9200,31 @@ WERROR _spoolss_setprinterdataex(pipes_struct *p, SPOOL_Q_SETPRINTERDATAEX *q_u, } /* save the registry data */ - - status = set_printer_dataex( printer, keyname, valuename, type, data, real_len ); - + + status = set_printer_dataex( printer, keyname, valuename, type, data, real_len ); + if ( W_ERROR_IS_OK(status) ) { /* save the OID if one was specified */ if ( oid_string ) { fstrcat( keyname, "\\" ); fstrcat( keyname, SPOOL_OID_KEY ); - - /* - * I'm not checking the status here on purpose. Don't know - * if this is right, but I'm returning the status from the - * previous set_printer_dataex() call. I have no idea if + + /* + * I'm not checking the status here on purpose. Don't know + * if this is right, but I'm returning the status from the + * previous set_printer_dataex() call. I have no idea if * this is right. --jerry */ - - set_printer_dataex( printer, keyname, valuename, + + set_printer_dataex( printer, keyname, valuename, REG_SZ, (uint8 *)oid_string, strlen(oid_string)+1 ); } - + status = mod_a_printer(printer, 2); } - + free_a_printer(&printer, 2); return status; @@ -9246,9 +9246,9 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX WERROR status = WERR_OK; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); pstring valuename, keyname; - + DEBUG(5,("spoolss_deleteprinterdataex\n")); - + if (!Printer) { DEBUG(2,("_spoolss_deleteprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; @@ -9273,7 +9273,7 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX if ( W_ERROR_IS_OK(status) ) mod_a_printer( printer, 2 ); - + free_a_printer(&printer, 2); return status; @@ -9297,8 +9297,8 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO NT_PRINTER_INFO_LEVEL *printer = NULL; int snum = 0; WERROR status = WERR_BADFILE; - - + + DEBUG(4,("_spoolss_enumprinterkey\n")); if (!Printer) { @@ -9312,9 +9312,9 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; - + /* get the list of subkey names */ - + unistr2_to_ascii(key, &q_u->key, sizeof(key)); data = printer->info_2->data; @@ -9338,16 +9338,16 @@ WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPO status = WERR_NOMEM; goto done; } - + status = WERR_OK; - if ( q_u->size < r_u->needed ) + if ( q_u->size < r_u->needed ) status = WERR_MORE_DATA; done: free_a_printer( &printer, 2 ); SAFE_FREE( keynames ); - + return status; } @@ -9363,19 +9363,19 @@ WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, NT_PRINTER_INFO_LEVEL *printer = NULL; int snum=0; WERROR status; - + DEBUG(5,("spoolss_deleteprinterkey\n")); - + if (!Printer) { DEBUG(2,("_spoolss_deleteprinterkey: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); return WERR_BADFID; } /* if keyname == NULL, return error */ - + if ( !q_u->keyname.buffer ) return WERR_INVALID_PARAM; - + if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; @@ -9387,18 +9387,18 @@ WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; - + /* delete the key and all subneys */ - + unistr2_to_ascii(key, &q_u->keyname, sizeof(key)); - - status = delete_all_printer_data( printer->info_2, key ); + + status = delete_all_printer_data( printer->info_2, key ); if ( W_ERROR_IS_OK(status) ) status = mod_a_printer(printer, 2); - + free_a_printer( &printer, 2 ); - + return status; } @@ -9409,9 +9409,9 @@ WERROR _spoolss_deleteprinterkey(pipes_struct *p, SPOOL_Q_DELETEPRINTERKEY *q_u, WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_u, SPOOL_R_ENUMPRINTERDATAEX *r_u) { - POLICY_HND *handle = &q_u->handle; + POLICY_HND *handle = &q_u->handle; uint32 in_size = q_u->size; - uint32 num_entries, + uint32 num_entries, needed; NT_PRINTER_INFO_LEVEL *printer = NULL; PRINTER_ENUM_VALUES *enum_values = NULL; @@ -9425,7 +9425,7 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ REGISTRY_VALUE *val; char *value_name; uint32 data_len; - + DEBUG(4,("_spoolss_enumprinterdataex\n")); @@ -9434,13 +9434,13 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ return WERR_BADFID; } - /* - * first check for a keyname of NULL or "". Win2k seems to send + /* + * first check for a keyname of NULL or "". Win2k seems to send * this a lot and we should send back WERR_INVALID_PARAM * no need to spend time looking up the printer in this case. * --jerry */ - + unistr2_to_ascii(key, &q_u->key, sizeof(key)); if ( !strlen(key) ) { result = WERR_INVALID_PARAM; @@ -9448,19 +9448,19 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ } /* get the printer off of disk */ - + if (!get_printer_snum(p,handle, &snum, NULL)) return WERR_BADFID; - + ZERO_STRUCT(printer); result = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(result)) return result; - + /* now look for a match on the key name */ - + p_data = printer->info_2->data; - + unistr2_to_ascii(key, &q_u->key, sizeof(key)); if ( (key_index = lookup_printerkey( p_data, key)) == -1 ) { @@ -9468,12 +9468,12 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ result = WERR_INVALID_PARAM; goto done; } - + result = WERR_OK; needed = 0; - + /* allocate the memory for the array of pointers -- if necessary */ - + num_entries = regval_ctr_numvals( p_data->keys[key_index].values ); if ( num_entries ) { @@ -9487,31 +9487,31 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ memset( enum_values, 0x0, num_entries*sizeof(PRINTER_ENUM_VALUES) ); } - - /* - * loop through all params and build the array to pass - * back to the client + + /* + * loop through all params and build the array to pass + * back to the client */ - + for ( i=0; ikeys[key_index].values, i ); DEBUG(10,("retrieved value number [%d] [%s]\n", i, regval_name(val) )); /* copy the data */ - + value_name = regval_name( val ); init_unistr( &enum_values[i].valuename, value_name ); enum_values[i].value_len = (strlen(value_name)+1) * 2; enum_values[i].type = regval_type( val ); - + data_len = regval_size( val ); if ( data_len ) { - if ( !(enum_values[i].data = (uint8 *)TALLOC_MEMDUP(p->mem_ctx, regval_data_p(val), data_len)) ) + if ( !(enum_values[i].data = (uint8 *)TALLOC_MEMDUP(p->mem_ctx, regval_data_p(val), data_len)) ) { - DEBUG(0,("TALLOC_MEMDUP failed to allocate memory [data_len=%d] for data!\n", + DEBUG(0,("TALLOC_MEMDUP failed to allocate memory [data_len=%d] for data!\n", data_len )); result = WERR_NOMEM; goto done; @@ -9520,12 +9520,12 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ enum_values[i].data_len = data_len; /* keep track of the size of the array in bytes */ - + needed += spoolss_size_printer_enum_values(&enum_values[i]); } - + /* housekeeping information in the reply */ - + /* Fix from Martin Zielinski - ensure * the hand marshalled container size is a multiple * of 4 bytes for RPC alignment. @@ -9542,17 +9542,17 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ result = WERR_MORE_DATA; goto done; } - + /* copy data into the reply */ - + r_u->ctr.size = r_u->needed; r_u->ctr.size_of_array = r_u->returned; r_u->ctr.values = enum_values; - - - -done: + + + +done: if ( printer ) free_a_printer(&printer, 2); @@ -9567,10 +9567,10 @@ static void fill_printprocessordirectory_1(PRINTPROCESSOR_DIRECTORY_1 *info, cha init_unistr(&info->name, name); } -static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, - UNISTR2 *environment, - RPC_BUFFER *buffer, - uint32 offered, +static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, + UNISTR2 *environment, + RPC_BUFFER *buffer, + uint32 offered, uint32 *needed) { pstring path; @@ -9589,7 +9589,7 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, pstrcpy(path, "C:\\WINNT\\System32\\spool\\PRTPROCS\\W32X86"); fill_printprocessordirectory_1(info, path); - + *needed += spoolss_size_printprocessordirectory_info_1(info); if (*needed > offered) { @@ -9606,7 +9606,7 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, out: SAFE_FREE(info); - + return result; } @@ -9628,7 +9628,7 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC buffer = r_u->buffer; DEBUG(5,("_spoolss_getprintprocessordirectory\n")); - + *needed=0; switch(level) { @@ -9647,21 +9647,21 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC Streams the monitor UI DLL name in UNICODE *******************************************************************/ -static WERROR xcvtcp_monitorui( NT_USER_TOKEN *token, RPC_BUFFER *in, +static WERROR xcvtcp_monitorui( NT_USER_TOKEN *token, RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed ) { const char *dllname = "tcpmonui.dll"; - + *needed = (strlen(dllname)+1) * 2; - + if ( rpcbuf_get_size(out) < *needed ) { - return WERR_INSUFFICIENT_BUFFER; + return WERR_INSUFFICIENT_BUFFER; } - + if ( !make_monitorui_buf( out, dllname ) ) { return WERR_NOMEM; } - + return WERR_OK; } @@ -9669,7 +9669,7 @@ static WERROR xcvtcp_monitorui( NT_USER_TOKEN *token, RPC_BUFFER *in, Create a new TCP/IP port *******************************************************************/ -static WERROR xcvtcp_addport( NT_USER_TOKEN *token, RPC_BUFFER *in, +static WERROR xcvtcp_addport( NT_USER_TOKEN *token, RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed ) { NT_PORT_DATA_1 port1; @@ -9693,7 +9693,7 @@ static WERROR xcvtcp_addport( NT_USER_TOKEN *token, RPC_BUFFER *in, case PORT_PROTOCOL_LPR: pstr_sprintf( device_uri, "lpr://%s/%s", port1.hostaddr, port1.queue ); break; - + default: return WERR_UNKNOWN_PORT; } @@ -9710,19 +9710,19 @@ struct xcv_api_table xcvtcp_cmds[] = { { NULL, NULL } }; -static WERROR process_xcvtcp_command( NT_USER_TOKEN *token, const char *command, - RPC_BUFFER *inbuf, RPC_BUFFER *outbuf, +static WERROR process_xcvtcp_command( NT_USER_TOKEN *token, const char *command, + RPC_BUFFER *inbuf, RPC_BUFFER *outbuf, uint32 *needed ) { int i; - + DEBUG(10,("process_xcvtcp_command: Received command \"%s\"\n", command)); - + for ( i=0; xcvtcp_cmds[i].name; i++ ) { if ( strcmp( command, xcvtcp_cmds[i].name ) == 0 ) return xcvtcp_cmds[i].fn( token, inbuf, outbuf, needed ); } - + return WERR_BADFUNC; } @@ -9730,21 +9730,21 @@ static WERROR process_xcvtcp_command( NT_USER_TOKEN *token, const char *command, *******************************************************************/ #if 0 /* don't support management using the "Local Port" monitor */ -static WERROR xcvlocal_monitorui( NT_USER_TOKEN *token, RPC_BUFFER *in, +static WERROR xcvlocal_monitorui( NT_USER_TOKEN *token, RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed ) { const char *dllname = "localui.dll"; - + *needed = (strlen(dllname)+1) * 2; - + if ( rpcbuf_get_size(out) < *needed ) { - return WERR_INSUFFICIENT_BUFFER; + return WERR_INSUFFICIENT_BUFFER; } - + if ( !make_monitorui_buf( out, dllname )) { return WERR_NOMEM; } - + return WERR_OK; } @@ -9766,12 +9766,12 @@ struct xcv_api_table xcvlocal_cmds[] = { /******************************************************************* *******************************************************************/ -static WERROR process_xcvlocal_command( NT_USER_TOKEN *token, const char *command, - RPC_BUFFER *inbuf, RPC_BUFFER *outbuf, +static WERROR process_xcvlocal_command( NT_USER_TOKEN *token, const char *command, + RPC_BUFFER *inbuf, RPC_BUFFER *outbuf, uint32 *needed ) { int i; - + DEBUG(10,("process_xcvlocal_command: Received command \"%s\"\n", command)); for ( i=0; xcvlocal_cmds[i].name; i++ ) { @@ -9785,7 +9785,7 @@ static WERROR process_xcvlocal_command( NT_USER_TOKEN *token, const char *comman *******************************************************************/ WERROR _spoolss_xcvdataport(pipes_struct *p, SPOOL_Q_XCVDATAPORT *q_u, SPOOL_R_XCVDATAPORT *r_u) -{ +{ Printer_entry *Printer = find_printer_index_by_hnd(p, &q_u->handle); fstring command; @@ -9795,39 +9795,37 @@ WERROR _spoolss_xcvdataport(pipes_struct *p, SPOOL_Q_XCVDATAPORT *q_u, SPOOL_R_X } /* Has to be a handle to the TCP/IP port monitor */ - + if ( !(Printer->printer_type & (SPLHND_PORTMON_LOCAL|SPLHND_PORTMON_TCP)) ) { DEBUG(2,("_spoolss_xcvdataport: Call only valid for Port Monitors\n")); return WERR_BADFID; } - + /* requires administrative access to the server */ - + if ( !(Printer->access_granted & SERVER_ACCESS_ADMINISTER) ) { DEBUG(2,("_spoolss_xcvdataport: denied by handle permissions.\n")); return WERR_ACCESS_DENIED; } - /* Get the command name. There's numerous commands supported by the + /* Get the command name. There's numerous commands supported by the TCPMON interface. */ - - rpcstr_pull(command, q_u->dataname.buffer, sizeof(command), + + rpcstr_pull(command, q_u->dataname.buffer, sizeof(command), q_u->dataname.uni_str_len*2, 0); - + /* Allocate the outgoing buffer */ - + rpcbuf_init( &r_u->outdata, q_u->offered, p->mem_ctx ); - + switch ( Printer->printer_type ) { case SPLHND_PORTMON_TCP: - return process_xcvtcp_command( p->pipe_user.nt_user_token, command, + return process_xcvtcp_command( p->pipe_user.nt_user_token, command, &q_u->indata, &r_u->outdata, &r_u->needed ); case SPLHND_PORTMON_LOCAL: - return process_xcvlocal_command( p->pipe_user.nt_user_token, command, + return process_xcvlocal_command( p->pipe_user.nt_user_token, command, &q_u->indata, &r_u->outdata, &r_u->needed ); } return WERR_INVALID_PRINT_MONITOR; } - - -- cgit From 93bfb6ca542e1e99ae7ae93fca94a0e33d99bca5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Nov 2007 17:50:39 -0800 Subject: Fix old cut-and-paste bug where the wrong field was being written to. Jerry please check. Jeremy. (This used to be commit 6a556fd73ac8c247c15df664f7910f8688abfdbc) --- source3/rpc_server/srv_spoolss_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f18c120a9f..a6f3bfba17 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1417,8 +1417,8 @@ static DEVICEMODE* dup_devicemode(TALLOC_CTX *ctx, DEVICEMODE *devmode) len = unistrlen(devmode->formname.buffer); if (len != -1) { - d->devicename.buffer = TALLOC_ARRAY(ctx, uint16, len); - if (!d->devicename.buffer) { + d->formname.buffer = TALLOC_ARRAY(ctx, uint16, len); + if (!d->formname.buffer) { return NULL; } if (unistrcpy(d->formname.buffer, devmode->formname.buffer) != len) -- cgit From 0bc4ff7b287e2cd6f7b225861d6c3fda9347adfc Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Nov 2007 19:05:08 -0800 Subject: Remove pstring from srv_spoolss_nt.c. All gone from rpc_server/*.c Jeremy. (This used to be commit b5a2a1e3f82a0d319fc9a1d76f5166150680f4d4) --- source3/rpc_server/srv_spoolss_nt.c | 538 ++++++++++++++++++++---------------- 1 file changed, 306 insertions(+), 232 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a6f3bfba17..b01f10b71d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -284,10 +284,11 @@ static bool close_printer_handle(pipes_struct *p, POLICY_HND *hnd) /**************************************************************************** Delete a printer given a handle. ****************************************************************************/ -WERROR delete_printer_hook( NT_USER_TOKEN *token, const char *sharename ) + +WERROR delete_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *sharename ) { char *cmd = lp_deleteprinter_cmd(); - pstring command; + char *command = NULL; int ret; SE_PRIV se_printop = SE_PRINT_OPERATOR; bool is_print_op = False; @@ -297,8 +298,12 @@ WERROR delete_printer_hook( NT_USER_TOKEN *token, const char *sharename ) if ( !*cmd ) return WERR_OK; - pstr_sprintf(command, "%s \"%s\"", cmd, sharename); - + command = talloc_asprintf(ctx, + "%s \"%s\"", + cmd, sharename); + if (!command) { + return WERR_NOMEM; + } if ( token ) is_print_op = user_has_privileges( token, &se_printop ); @@ -322,6 +327,8 @@ WERROR delete_printer_hook( NT_USER_TOKEN *token, const char *sharename ) DEBUGADD(10,("returned [%d]\n", ret)); + TALLOC_FREE(command); + if (ret != 0) return WERR_BADFID; /* What to return here? */ @@ -367,7 +374,7 @@ static WERROR delete_printer_handle(pipes_struct *p, POLICY_HND *hnd) return WERR_BADFID; } - return delete_printer_hook( p->pipe_user.nt_user_token, Printer->sharename ); + return delete_printer_hook(p->mem_ctx, p->pipe_user.nt_user_token, Printer->sharename ); } /**************************************************************************** @@ -2719,20 +2726,17 @@ void spoolss_notify_server_name(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - pstring temp; + smb_ucs2_t *temp = NULL; uint32 len; - len = rpcstr_push(temp, printer->info_2->servername, sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, printer->info_2->servername); + if (len == (uint32)-1) { + len = 0; + } data->notify_data.data.length = len; if (len) { - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } - - memcpy(data->notify_data.data.string, temp, len); + data->notify_data.data.string = (uint16 *)temp; } else { data->notify_data.data.string = NULL; } @@ -2748,7 +2752,7 @@ void spoolss_notify_printer_name(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - pstring temp; + smb_ucs2_t *temp = NULL; uint32 len; /* the notify name should not contain the \\server\ part */ @@ -2760,16 +2764,14 @@ void spoolss_notify_printer_name(int snum, p++; } - len = rpcstr_push(temp, p, sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, p); + if (len == (uint32)-1) { + len = 0; + } data->notify_data.data.length = len; if (len) { - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } - memcpy(data->notify_data.data.string, temp, len); + data->notify_data.data.string = (uint16 *)temp; } else { data->notify_data.data.string = NULL; } @@ -2785,19 +2787,17 @@ void spoolss_notify_share_name(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - pstring temp; + smb_ucs2_t *temp = NULL; uint32 len; - len = rpcstr_push(temp, lp_servicename(snum), sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, lp_servicename(snum)); + if (len == (uint32)-1) { + len = 0; + } data->notify_data.data.length = len; if (len) { - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } - memcpy(data->notify_data.data.string, temp, len); + data->notify_data.data.string = (uint16 *)temp; } else { data->notify_data.data.string = NULL; } @@ -2814,23 +2814,19 @@ void spoolss_notify_port_name(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - pstring temp; + smb_ucs2_t *temp = NULL; uint32 len; /* even if it's strange, that's consistant in all the code */ - len = rpcstr_push(temp, printer->info_2->portname, sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, printer->info_2->portname); + if (len == (uint32)-1) { + len = 0; + } data->notify_data.data.length = len; if (len) { - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } - - memcpy(data->notify_data.data.string, temp, len); + data->notify_data.data.string = (uint16 *)temp; } else { data->notify_data.data.string = NULL; } @@ -2847,21 +2843,17 @@ void spoolss_notify_driver_name(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - pstring temp; + smb_ucs2_t *temp = NULL; uint32 len; - len = rpcstr_push(temp, printer->info_2->drivername, sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, printer->info_2->drivername); + if (len == (uint32)-1) { + len = 0; + } data->notify_data.data.length = len; if (len) { - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } - - memcpy(data->notify_data.data.string, temp, len); + data->notify_data.data.string = (uint16 *)temp; } else { data->notify_data.data.string = NULL; } @@ -2877,24 +2869,20 @@ void spoolss_notify_comment(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - pstring temp; + smb_ucs2_t *temp = NULL; uint32 len; if (*printer->info_2->comment == '\0') - len = rpcstr_push(temp, lp_comment(snum), sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, lp_comment(snum)); else - len = rpcstr_push(temp, printer->info_2->comment, sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, printer->info_2->comment); + if (len == (uint32)-1) { + len = 0; + } data->notify_data.data.length = len; if (len) { - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } - - memcpy(data->notify_data.data.string, temp, len); + data->notify_data.data.string = (uint16 *)temp; } else { data->notify_data.data.string = NULL; } @@ -2911,21 +2899,17 @@ void spoolss_notify_location(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - pstring temp; + smb_ucs2_t *temp = NULL; uint32 len; - len = rpcstr_push(temp, printer->info_2->location,sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, printer->info_2->location); + if (len == (uint32)-1) { + len = 0; + } data->notify_data.data.length = len; if (len) { - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } - - memcpy(data->notify_data.data.string, temp, len); + data->notify_data.data.string = (uint16 *)temp; } else { data->notify_data.data.string = NULL; } @@ -2957,21 +2941,17 @@ void spoolss_notify_sepfile(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - pstring temp; + smb_ucs2_t *temp = NULL; uint32 len; - len = rpcstr_push(temp, printer->info_2->sepfile, sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, printer->info_2->sepfile); + if (len == (uint32)-1) { + len = 0; + } data->notify_data.data.length = len; if (len) { - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } - - memcpy(data->notify_data.data.string, temp, len); + data->notify_data.data.string = (uint16 *)temp; } else { data->notify_data.data.string = NULL; } @@ -2988,21 +2968,17 @@ void spoolss_notify_print_processor(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - pstring temp; + smb_ucs2_t *temp = NULL; uint32 len; - len = rpcstr_push(temp, printer->info_2->printprocessor, sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, printer->info_2->printprocessor); + if (len == (uint32)-1) { + len = 0; + } data->notify_data.data.length = len; if (len) { - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } - - memcpy(data->notify_data.data.string, temp, len); + data->notify_data.data.string = (uint16 *)temp; } else { data->notify_data.data.string = NULL; } @@ -3019,21 +2995,17 @@ void spoolss_notify_parameters(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - pstring temp; + smb_ucs2_t *temp = NULL; uint32 len; - len = rpcstr_push(temp, printer->info_2->parameters, sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, printer->info_2->parameters); + if (len == (uint32)-1) { + len = 0; + } data->notify_data.data.length = len; if (len) { - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } - - memcpy(data->notify_data.data.string, temp, len); + data->notify_data.data.string = (uint16 *)temp; } else { data->notify_data.data.string = NULL; } @@ -3050,21 +3022,17 @@ void spoolss_notify_datatype(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - pstring temp; + smb_ucs2_t *temp = NULL; uint32 len; - len = rpcstr_push(temp, printer->info_2->datatype, sizeof(pstring)-2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, printer->info_2->datatype); + if (len == (uint32)-1) { + len = 0; + } data->notify_data.data.length = len; if (len) { - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } - - memcpy(data->notify_data.data.string, temp, len); + data->notify_data.data.string = (uint16 *)temp; } else { data->notify_data.data.string = NULL; } @@ -3214,21 +3182,17 @@ static void spoolss_notify_username(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - pstring temp; + smb_ucs2_t *temp = NULL; uint32 len; - len = rpcstr_push(temp, queue->fs_user, sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, queue->fs_user); + if (len == (uint32)-1) { + len = 0; + } data->notify_data.data.length = len; if (len) { - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } - - memcpy(data->notify_data.data.string, temp, len); + data->notify_data.data.string = (uint16 *)temp; } else { data->notify_data.data.string = NULL; } @@ -3258,21 +3222,17 @@ static void spoolss_notify_job_name(int snum, NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx) { - pstring temp; + smb_ucs2_t *temp = NULL; uint32 len; - len = rpcstr_push(temp, queue->fs_file, sizeof(temp)-2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, queue->fs_file); + if (len == (uint32)-1) { + len = 0; + } data->notify_data.data.length = len; if (len) { - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } - - memcpy(data->notify_data.data.string, temp, len); + data->notify_data.data.string = (uint16 *)temp; } else { data->notify_data.data.string = NULL; } @@ -3293,7 +3253,7 @@ static void spoolss_notify_job_status_string(int snum, */ const char *p = ""; - pstring temp; + smb_ucs2_t *temp = NULL; uint32 len; #if 0 /* NO LONGER NEEDED - JRA. 02/22/2001 */ @@ -3315,18 +3275,14 @@ static void spoolss_notify_job_status_string(int snum, } #endif /* NO LONGER NEEDED. */ - len = rpcstr_push(temp, p, sizeof(temp) - 2, STR_TERMINATE); + len = rpcstr_push_talloc(mem_ctx, &temp, p); + if (len == (uint32)-1) { + len = 0; + } data->notify_data.data.length = len; if (len) { - data->notify_data.data.string = (uint16 *)TALLOC(mem_ctx, len); - - if (!data->notify_data.data.string) { - data->notify_data.data.length = 0; - return; - } - - memcpy(data->notify_data.data.string, temp, len); + data->notify_data.data.string = (uint16 *)temp; } else { data->notify_data.data.string = NULL; } @@ -3954,7 +3910,7 @@ done: static bool construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *printer, int snum) { - pstring chaine; + char *chaine = NULL; int count; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; counter_printer_0 *session_counter; @@ -3962,10 +3918,19 @@ static bool construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p struct tm *t; time_t setuptime; print_status_struct status; + TALLOC_CTX *ctx = talloc_tos(); if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) return False; + init_unistr(&printer->printername, ntprinter->info_2->printername); + + chaine = talloc_asprintf(ctx, "\\\\%s", get_server_name(print_hnd)); + if (!chaine) { + free_a_printer(&ntprinter,2); + return false; + } + count = print_queue_length(snum, &status); /* check if we already have a counter for this printer */ @@ -3974,6 +3939,8 @@ static bool construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p break; } + init_unistr(&printer->servername, chaine); + /* it's the first time, add it to the list */ if (session_counter==NULL) { if((session_counter=SMB_MALLOC_P(counter_printer_0)) == NULL) { @@ -3994,14 +3961,6 @@ static bool construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p * and should be zeroed on samba startup */ global_counter=session_counter->counter; - - pstrcpy(chaine,ntprinter->info_2->printername); - - init_unistr(&printer->printername, chaine); - - slprintf(chaine,sizeof(chaine)-1,"\\\\%s", get_server_name(print_hnd)); - init_unistr(&printer->servername, chaine); - printer->cjobs = count; printer->total_jobs = 0; printer->total_bytes = 0; @@ -4059,30 +4018,35 @@ static bool construct_printer_info_0(Printer_entry *print_hnd, PRINTER_INFO_0 *p ********************************************************************/ static bool construct_printer_info_1(Printer_entry *print_hnd, uint32 flags, PRINTER_INFO_1 *printer, int snum) { - pstring chaine; - pstring chaine2; + char *chaine = NULL; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; + TALLOC_CTX *ctx = talloc_tos(); if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &ntprinter, 2, lp_const_servicename(snum)))) - return False; + return false; printer->flags=flags; if (*ntprinter->info_2->comment == '\0') { init_unistr(&printer->comment, lp_comment(snum)); - slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s", ntprinter->info_2->printername, - ntprinter->info_2->drivername, lp_comment(snum)); + chaine = talloc_asprintf(ctx, + "%s,%s,%s", ntprinter->info_2->printername, + ntprinter->info_2->drivername, lp_comment(snum)); } else { init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */ - slprintf(chaine,sizeof(chaine)-1,"%s,%s,%s", ntprinter->info_2->printername, - ntprinter->info_2->drivername, ntprinter->info_2->comment); + chaine = talloc_asprintf(ctx, + "%s,%s,%s", ntprinter->info_2->printername, + ntprinter->info_2->drivername, ntprinter->info_2->comment); } - slprintf(chaine2,sizeof(chaine)-1,"%s", ntprinter->info_2->printername); + if (!chaine) { + free_a_printer(&ntprinter,2); + return false; + } init_unistr(&printer->description, chaine); - init_unistr(&printer->name, chaine2); + init_unistr(&printer->name, ntprinter->info_2->printername); free_a_printer(&ntprinter,2); @@ -5160,7 +5124,8 @@ static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fst static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) { - pstring temp; + TALLOC_CTX *ctx = talloc_tos(); + char *temp = NULL; info->version=driver.info_3->cversion; @@ -5168,20 +5133,32 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->architecture, driver.info_3->environment ); - if (strlen(driver.info_3->driverpath)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + if (strlen(driver.info_3->driverpath)) { + temp = talloc_asprintf(ctx, + "\\\\%s%s", + servername, + driver.info_3->driverpath); init_unistr( &info->driverpath, temp ); - } else - init_unistr( &info->driverpath, "" ); + } else { + init_unistr( &info->driverpath, "" ); + } + TALLOC_FREE(temp); if (strlen(driver.info_3->datafile)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); + temp = talloc_asprintf(ctx, + "\\\\%s%s", + servername, + driver.info_3->datafile); init_unistr( &info->datafile, temp ); } else init_unistr( &info->datafile, "" ); + TALLOC_FREE(temp); if (strlen(driver.info_3->configfile)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); + temp = talloc_asprintf(ctx, + "\\\\%s%s", + servername, + driver.info_3->configfile); init_unistr( &info->configfile, temp ); } else init_unistr( &info->configfile, "" ); @@ -5226,17 +5203,16 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, const c int i=0; int j=0; const char *v; - pstring line; + char *line = NULL; + TALLOC_CTX *ctx = talloc_tos(); DEBUG(6,("init_unistr_array\n")); *uni_array=NULL; - while (True) - { - if ( !char_array ) + while (true) { + if ( !char_array ) { v = ""; - else - { + } else { v = char_array[i]; if (!v) v = ""; /* hack to handle null lists */ @@ -5244,12 +5220,21 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, const c /* hack to allow this to be used in places other than when generating the list of dependent files */ - - if ( servername ) - slprintf( line, sizeof(line)-1, "\\\\%s%s", servername, v ); - else - pstrcpy( line, v ); + TALLOC_FREE(line); + if ( servername ) { + line = talloc_asprintf(ctx, + "\\\\%s%s", + servername, + v); + } else { + line = talloc_strdup(ctx, v); + } + + if (!line) { + SAFE_FREE(*uni_array); + return 0; + } DEBUGADD(6,("%d:%s:%lu\n", i, line, (unsigned long)strlen(line))); /* add one extra unit16 for the second terminating NULL */ @@ -5287,7 +5272,8 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, const c static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) { - pstring temp; + char *temp = NULL; + TALLOC_CTX *ctx = talloc_tos(); ZERO_STRUCTP(info); @@ -5297,29 +5283,45 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->architecture, driver.info_3->environment ); if (strlen(driver.info_3->driverpath)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + temp = talloc_asprintf(ctx, + "\\\\%s%s", + servername, + driver.info_3->driverpath); init_unistr( &info->driverpath, temp ); } else init_unistr( &info->driverpath, "" ); + TALLOC_FREE(temp); if (strlen(driver.info_3->datafile)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); + temp = talloc_asprintf(ctx, + "\\\\%s%s", + servername, + driver.info_3->datafile); init_unistr( &info->datafile, temp ); } else init_unistr( &info->datafile, "" ); + TALLOC_FREE(temp); if (strlen(driver.info_3->configfile)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); + temp = talloc_asprintf(ctx, + "\\\\%s%s", + servername, + driver.info_3->configfile); init_unistr( &info->configfile, temp ); } else init_unistr( &info->configfile, "" ); + TALLOC_FREE(temp); if (strlen(driver.info_3->helpfile)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile); + temp = talloc_asprintf(ctx, + "\\\\%s%s", + servername, + driver.info_3->helpfile); init_unistr( &info->helpfile, temp ); } else init_unistr( &info->helpfile, "" ); + TALLOC_FREE(temp); init_unistr( &info->monitorname, driver.info_3->monitorname ); init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype ); @@ -5393,8 +5395,9 @@ static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) { - pstring temp; + char *temp = NULL; fstring nullstr; + TALLOC_CTX *ctx = talloc_tos(); ZERO_STRUCTP(info); memset(&nullstr, '\0', sizeof(fstring)); @@ -5405,29 +5408,45 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->architecture, driver.info_3->environment ); if (strlen(driver.info_3->driverpath)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->driverpath); + temp = talloc_asprintf(ctx, + "\\\\%s%s", + servername, + driver.info_3->driverpath); init_unistr( &info->driverpath, temp ); } else init_unistr( &info->driverpath, "" ); + TALLOC_FREE(temp); if (strlen(driver.info_3->datafile)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->datafile); + temp = talloc_asprintf(ctx, + "\\\\%s%s", + servername, + driver.info_3->datafile); init_unistr( &info->datafile, temp ); } else init_unistr( &info->datafile, "" ); + TALLOC_FREE(temp); if (strlen(driver.info_3->configfile)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->configfile); + temp = talloc_asprintf(ctx, + "\\\\%s%s", + servername, + driver.info_3->configfile); init_unistr( &info->configfile, temp ); } else init_unistr( &info->configfile, "" ); + TALLOC_FREE(temp); if (strlen(driver.info_3->helpfile)) { - slprintf(temp, sizeof(temp)-1, "\\\\%s%s", servername, driver.info_3->helpfile); + temp = talloc_asprintf(ctx, + "\\\\%s%s", + servername, + driver.info_3->helpfile); init_unistr( &info->helpfile, temp ); } else init_unistr( &info->helpfile, "" ); + TALLOC_FREE(temp); init_unistr( &info->monitorname, driver.info_3->monitorname ); init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype ); @@ -5786,10 +5805,10 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S POLICY_HND *handle = &q_u->handle; DOC_INFO *docinfo = &q_u->doc_info_container.docinfo; uint32 *jobid = &r_u->jobid; - + TALLOC_CTX *ctx = p->mem_ctx; DOC_INFO_1 *info_1 = &docinfo->doc_info_1; int snum; - pstring jobname; + char *jobname = NULL; fstring datatype; Printer_entry *Printer = find_printer_index_by_hnd(p, handle); @@ -5819,7 +5838,7 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S return WERR_BADFID; } - unistr2_to_ascii(jobname, &info_1->docname, sizeof(jobname)); + jobname = unistr2_to_ascii_talloc(ctx, &info_1->docname); Printer->jobid = print_job_start(&p->pipe_user, snum, jobname, Printer->nt_devmode); @@ -6109,10 +6128,10 @@ static bool check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum) /**************************************************************************** ****************************************************************************/ -WERROR add_port_hook(NT_USER_TOKEN *token, const char *portname, const char *uri ) +WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname, const char *uri ) { char *cmd = lp_addport_cmd(); - pstring command; + char *command = NULL; int ret; int fd; SE_PRIV se_printop = SE_PRINT_OPERATOR; @@ -6122,7 +6141,11 @@ WERROR add_port_hook(NT_USER_TOKEN *token, const char *portname, const char *uri return WERR_ACCESS_DENIED; } - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\"", cmd, portname, uri ); + command = talloc_asprintf(ctx, + "%s \"%s\" \"%s\"", cmd, portname, uri ); + if (!command) { + return WERR_NOMEM; + } if ( token ) is_print_op = user_has_privileges( token, &se_printop ); @@ -6143,6 +6166,8 @@ WERROR add_port_hook(NT_USER_TOKEN *token, const char *portname, const char *uri DEBUGADD(10,("returned [%d]\n", ret)); + TALLOC_FREE(command); + if ( ret != 0 ) { if (fd != -1) close(fd); @@ -6155,26 +6180,37 @@ WERROR add_port_hook(NT_USER_TOKEN *token, const char *portname, const char *uri /**************************************************************************** ****************************************************************************/ -bool add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) +bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) { char *cmd = lp_addprinter_cmd(); char **qlines; - pstring command; + char *command = NULL; int numlines; int ret; int fd; - fstring remote_machine = "%m"; SE_PRIV se_printop = SE_PRINT_OPERATOR; bool is_print_op = False; + char *remote_machine = talloc_strdup(ctx, "%m"); - standard_sub_basic(current_user_info.smb_name, - current_user_info.domain, - remote_machine,sizeof(remote_machine)); + if (!remote_machine) { + return false; + } + remote_machine = talloc_sub_basic(ctx, + current_user_info.smb_name, + current_user_info.domain, + remote_machine); + if (!remote_machine) { + return false; + } - slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", + command = talloc_asprintf(ctx, + "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"", cmd, printer->info_2->printername, printer->info_2->sharename, printer->info_2->portname, printer->info_2->drivername, printer->info_2->location, printer->info_2->comment, remote_machine); + if (!command) { + return false; + } if ( token ) is_print_op = user_has_privileges( token, &se_printop ); @@ -6199,6 +6235,9 @@ bool add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer) DEBUGADD(10,("returned [%d]\n", ret)); + TALLOC_FREE(command); + TALLOC_FREE(remote_machine); + if ( ret != 0 ) { if (fd != -1) close(fd); @@ -6318,7 +6357,7 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, { /* add_printer_hook() will call reload_services() */ - if ( !add_printer_hook(p->pipe_user.nt_user_token, printer) ) { + if ( !add_printer_hook(p->mem_ctx, p->pipe_user.nt_user_token, printer) ) { result = WERR_ACCESS_DENIED; goto done; } @@ -7395,11 +7434,11 @@ static void fill_port_2(PORT_INFO_2 *port, const char *name) wrapper around the enumer ports command ****************************************************************************/ -WERROR enumports_hook( int *count, char ***lines ) +WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines ) { char *cmd = lp_enumports_cmd(); - char **qlines; - pstring command; + char **qlines = NULL; + char *command = NULL; int numlines; int ret; int fd; @@ -7423,11 +7462,15 @@ WERROR enumports_hook( int *count, char ***lines ) else { /* we have a valid enumport command */ - slprintf(command, sizeof(command)-1, "%s \"%d\"", cmd, 1); + command = talloc_asprintf(ctx, "%s \"%d\"", cmd, 1); + if (!command) { + return WERR_NOMEM; + } DEBUG(10,("Running [%s]\n", command)); ret = smbrun(command, &fd); DEBUG(10,("Returned [%d]\n", ret)); + TALLOC_FREE(command); if (ret != 0) { if (fd != -1) { close(fd); @@ -7459,7 +7502,7 @@ static WERROR enumports_level_1(RPC_BUFFER *buffer, uint32 offered, uint32 *need char **qlines = NULL; int numlines = 0; - result = enumports_hook( &numlines, &qlines ); + result = enumports_hook(talloc_tos(), &numlines, &qlines ); if (!W_ERROR_IS_OK(result)) { file_lines_free(qlines); return result; @@ -7525,7 +7568,7 @@ static WERROR enumports_level_2(RPC_BUFFER *buffer, uint32 offered, uint32 *need char **qlines = NULL; int numlines = 0; - result = enumports_hook( &numlines, &qlines ); + result = enumports_hook(talloc_tos(), &numlines, &qlines ); if ( !W_ERROR_IS_OK(result)) { file_lines_free(qlines); return result; @@ -7652,7 +7695,7 @@ static WERROR spoolss_addprinterex_level_2( pipes_struct *p, const UNISTR2 *uni_ trying to add a printer like this --jerry */ if (*lp_addprinter_cmd() ) { - if ( !add_printer_hook(p->pipe_user.nt_user_token, printer) ) { + if ( !add_printer_hook(p->mem_ctx, p->pipe_user.nt_user_token, printer) ) { free_a_printer(&printer,2); return WERR_ACCESS_DENIED; } @@ -7916,16 +7959,23 @@ static void fill_driverdir_1(DRIVER_DIRECTORY_1 *info, char *name) static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environment, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { - pstring path; - pstring long_archi; - fstring servername; - char *pservername; + char *path = NULL; + char *long_archi = NULL; + char *servername = NULL; + char *pservername = NULL; const char *short_archi; DRIVER_DIRECTORY_1 *info=NULL; WERROR result = WERR_OK; + TALLOC_CTX *ctx = talloc_tos(); - unistr2_to_ascii(servername, name, sizeof(servername)); - unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)); + servername = unistr2_to_ascii_talloc(ctx, name); + if (!servername) { + return WERR_NOMEM; + } + long_archi = unistr2_to_ascii_talloc(ctx, uni_environment); + if (!long_archi) { + return WERR_NOMEM; + } /* check for beginning double '\'s and that the server long enough */ @@ -7944,7 +7994,12 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen if((info=SMB_MALLOC_P(DRIVER_DIRECTORY_1)) == NULL) return WERR_NOMEM; - slprintf(path, sizeof(path)-1, "\\\\%s\\print$\\%s", pservername, short_archi); + path = talloc_asprintf(ctx, + "\\\\%s\\print$\\%s", pservername, short_archi); + if (!path) { + result = WERR_NOMEM; + goto out; + } DEBUG(4,("printer driver directory: [%s]\n", path)); @@ -8313,7 +8368,8 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ int snum=0; WERROR status = WERR_OK; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); - pstring valuename; + char *valuename = NULL; + TALLOC_CTX *ctx = p->mem_ctx; DEBUG(5,("spoolss_deleteprinterdata\n")); @@ -8334,7 +8390,11 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ if (!W_ERROR_IS_OK(status)) return status; - unistr2_to_ascii(valuename, value, sizeof(valuename)); + valuename = unistr2_to_ascii_talloc(ctx, value); + if (!valuename) { + free_a_printer(&printer, 2); + return WERR_NOMEM; + } status = delete_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, valuename ); @@ -8342,6 +8402,7 @@ WERROR _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_ mod_a_printer( printer, 2 ); free_a_printer(&printer, 2); + TALLOC_FREE(valuename); return status; } @@ -9245,7 +9306,9 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX int snum=0; WERROR status = WERR_OK; Printer_entry *Printer=find_printer_index_by_hnd(p, handle); - pstring valuename, keyname; + char *valuename = NULL; + char *keyname = NULL; + TALLOC_CTX *ctx = p->mem_ctx; DEBUG(5,("spoolss_deleteprinterdataex\n")); @@ -9262,13 +9325,16 @@ WERROR _spoolss_deleteprinterdataex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATAEX return WERR_ACCESS_DENIED; } + valuename = unistr2_to_ascii_talloc(ctx, value); + keyname = unistr2_to_ascii_talloc(ctx, key); + if (!valuename || !keyname) { + return WERR_NOMEM; + } + status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); if (!W_ERROR_IS_OK(status)) return status; - unistr2_to_ascii(valuename, value, sizeof(valuename)); - unistr2_to_ascii(keyname, key, sizeof(keyname)); - status = delete_printer_dataex( printer, keyname, valuename ); if ( W_ERROR_IS_OK(status) ) @@ -9562,7 +9628,7 @@ done: /**************************************************************************** ****************************************************************************/ -static void fill_printprocessordirectory_1(PRINTPROCESSOR_DIRECTORY_1 *info, char *name) +static void fill_printprocessordirectory_1(PRINTPROCESSOR_DIRECTORY_1 *info, const char *name) { init_unistr(&info->name, name); } @@ -9573,12 +9639,15 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, uint32 offered, uint32 *needed) { - pstring path; - pstring long_archi; + char *long_archi = NULL; PRINTPROCESSOR_DIRECTORY_1 *info=NULL; WERROR result = WERR_OK; + TALLOC_CTX *ctx = talloc_tos(); - unistr2_to_ascii(long_archi, environment, sizeof(long_archi)); + long_archi = unistr2_to_ascii_talloc(ctx, environment); + if (!long_archi) { + return WERR_NOMEM; + } if (!get_short_archi(long_archi)) return WERR_INVALID_ENVIRONMENT; @@ -9586,9 +9655,7 @@ static WERROR getprintprocessordirectory_level_1(UNISTR2 *name, if((info=SMB_MALLOC_P(PRINTPROCESSOR_DIRECTORY_1)) == NULL) return WERR_NOMEM; - pstrcpy(path, "C:\\WINNT\\System32\\spool\\PRTPROCS\\W32X86"); - - fill_printprocessordirectory_1(info, path); + fill_printprocessordirectory_1(info, "C:\\WINNT\\System32\\spool\\PRTPROCS\\W32X86"); *needed += spoolss_size_printprocessordirectory_info_1(info); @@ -9673,7 +9740,8 @@ static WERROR xcvtcp_addport( NT_USER_TOKEN *token, RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed ) { NT_PORT_DATA_1 port1; - pstring device_uri; + TALLOC_CTX *ctx = talloc_tos(); + char *device_uri = NULL; ZERO_STRUCT( port1 ); @@ -9687,18 +9755,24 @@ static WERROR xcvtcp_addport( NT_USER_TOKEN *token, RPC_BUFFER *in, switch ( port1.protocol ) { case PORT_PROTOCOL_DIRECT: - pstr_sprintf( device_uri, "socket://%s:%d/", port1.hostaddr, port1.port ); + device_uri = talloc_asprintf(ctx, + "socket://%s:%d/", port1.hostaddr, port1.port ); break; case PORT_PROTOCOL_LPR: - pstr_sprintf( device_uri, "lpr://%s/%s", port1.hostaddr, port1.queue ); + device_uri = talloc_asprintf(ctx, + "lpr://%s/%s", port1.hostaddr, port1.queue ); break; default: return WERR_UNKNOWN_PORT; } - return add_port_hook( token, port1.name, device_uri ); + if (!device_uri) { + return WERR_NOMEM; + } + + return add_port_hook(ctx, token, port1.name, device_uri ); } /******************************************************************* -- cgit From 9c8bd95acffa79578d08fa1d4d5c06533ced315e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Nov 2007 23:00:11 -0800 Subject: Fixed obvious typo. Jeremy. (This used to be commit 9755c5311416f17bac0a848d027cafb3fd487618) --- source3/rpc_server/srv_winreg_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 631386c078..873224085c 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -790,7 +790,7 @@ WERROR _winreg_RestoreKey(pipes_struct *p, struct winreg_RestoreKey *r) if ( !r->in.filename || !r->in.filename->name ) return WERR_INVALID_PARAM; - fname - talloc_strdup(p->mem_ctx, r->in.filename->name); + fname = talloc_strdup(p->mem_ctx, r->in.filename->name); if (!fname) { return WERR_NOMEM; } -- cgit From d2cf97aeba14a4d336fb57b01f19bd5a08dcb003 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 29 Nov 2007 13:24:54 -0800 Subject: Remove the explicit TALLOC_CTX * from cli_struct. Make us very explicit about how long a talloc ctx should last. Jeremy. (This used to be commit ba9e2be2b5a59684e854609f9d82ea1633448c62) --- source3/rpc_server/srv_spoolss_nt.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index b01f10b71d..a17a8ebf26 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -153,7 +153,9 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle) return; } - result = rpccli_spoolss_reply_close_printer(notify_cli_pipe, notify_cli_pipe->cli->mem_ctx, handle); + result = rpccli_spoolss_reply_close_printer(notify_cli_pipe, + talloc_tos(), + handle); if (!W_ERROR_IS_OK(result)) DEBUG(0,("srv_spoolss_replycloseprinter: reply_close_printer failed [%s].\n", @@ -2639,8 +2641,12 @@ static bool srv_spoolss_replyopenprinter(int snum, const char *printer, smb_connections++; - result = rpccli_spoolss_reply_open_printer(notify_cli_pipe, notify_cli_pipe->cli->mem_ctx, printer, localprinter, - type, handle); + result = rpccli_spoolss_reply_open_printer(notify_cli_pipe, + talloc_tos(), + printer, + localprinter, + type, + handle); if (!W_ERROR_IS_OK(result)) DEBUG(5,("srv_spoolss_reply_open_printer: Client RPC returned [%s]\n", -- cgit From 7557964bee3c868181fd74e9448833fbfc95426d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 30 Nov 2007 01:44:44 +0100 Subject: Merge recent wkssvc changes from samba4. Guenther (This used to be commit 7539fb4c840a9b4429f347cebbda9c631746267a) --- source3/rpc_server/srv_wkssvc_nt.c | 54 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 11ca8915a2..70cf80c20a 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -48,7 +48,7 @@ static void create_wks_info_100(struct wkssvc_NetWkstaInfo100 *info100) only supports info level 100 at the moment. ********************************************************************/ -WERROR _wkssvc_NetWkstaGetInfo( pipes_struct *p, struct wkssvc_NetWkstaGetInfo *r) +WERROR _wkssvc_NetWkstaGetInfo(pipes_struct *p, struct wkssvc_NetWkstaGetInfo *r) { struct wkssvc_NetWkstaInfo100 *wks100 = NULL; @@ -72,7 +72,7 @@ WERROR _wkssvc_NetWkstaGetInfo( pipes_struct *p, struct wkssvc_NetWkstaGetInfo * /******************************************************************** ********************************************************************/ -WERROR _wkssvc_NetWkstaSetInfo( pipes_struct *p, struct wkssvc_NetWkstaSetInfo *r) +WERROR _wkssvc_NetWkstaSetInfo(pipes_struct *p, struct wkssvc_NetWkstaSetInfo *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -82,7 +82,7 @@ WERROR _wkssvc_NetWkstaSetInfo( pipes_struct *p, struct wkssvc_NetWkstaSetInfo * /******************************************************************** ********************************************************************/ -WERROR _wkssvc_NetWkstaEnumUsers( pipes_struct *p, struct wkssvc_NetWkstaEnumUsers *r) +WERROR _wkssvc_NetWkstaEnumUsers(pipes_struct *p, struct wkssvc_NetWkstaEnumUsers *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -92,7 +92,7 @@ WERROR _wkssvc_NetWkstaEnumUsers( pipes_struct *p, struct wkssvc_NetWkstaEnumUse /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRWKSTAUSERGETINFO( pipes_struct *p, struct WKSSVC_NETRWKSTAUSERGETINFO *r ) +WERROR _wkssvc_NetrWkstaUserGetInfo(pipes_struct *p, struct wkssvc_NetrWkstaUserGetInfo *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -102,7 +102,7 @@ WERROR _WKSSVC_NETRWKSTAUSERGETINFO( pipes_struct *p, struct WKSSVC_NETRWKSTAUSE /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRWKSTAUSERSETINFO( pipes_struct *p, struct WKSSVC_NETRWKSTAUSERSETINFO *r ) +WERROR _wkssvc_NetrWkstaUserSetInfo(pipes_struct *p, struct wkssvc_NetrWkstaUserSetInfo *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -112,7 +112,7 @@ WERROR _WKSSVC_NETRWKSTAUSERSETINFO( pipes_struct *p, struct WKSSVC_NETRWKSTAUSE /******************************************************************** ********************************************************************/ -WERROR _wkssvc_NetWkstaTransportEnum( pipes_struct *p, struct wkssvc_NetWkstaTransportEnum *r) +WERROR _wkssvc_NetWkstaTransportEnum(pipes_struct *p, struct wkssvc_NetWkstaTransportEnum *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -122,7 +122,7 @@ WERROR _wkssvc_NetWkstaTransportEnum( pipes_struct *p, struct wkssvc_NetWkstaTra /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRWKSTATRANSPORTADD( pipes_struct *p, struct WKSSVC_NETRWKSTATRANSPORTADD *r ) +WERROR _wkssvc_NetrWkstaTransportAdd(pipes_struct *p, struct wkssvc_NetrWkstaTransportAdd *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -132,7 +132,7 @@ WERROR _WKSSVC_NETRWKSTATRANSPORTADD( pipes_struct *p, struct WKSSVC_NETRWKSTATR /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRWKSTATRANSPORTDEL( pipes_struct *p, struct WKSSVC_NETRWKSTATRANSPORTDEL *r ) +WERROR _wkssvc_NetrWkstaTransportDel(pipes_struct *p, struct wkssvc_NetrWkstaTransportDel *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -142,7 +142,7 @@ WERROR _WKSSVC_NETRWKSTATRANSPORTDEL( pipes_struct *p, struct WKSSVC_NETRWKSTATR /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRUSEADD( pipes_struct *p, struct WKSSVC_NETRUSEADD *r ) +WERROR _wkssvc_NetrUseAdd(pipes_struct *p, struct wkssvc_NetrUseAdd *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -152,7 +152,7 @@ WERROR _WKSSVC_NETRUSEADD( pipes_struct *p, struct WKSSVC_NETRUSEADD *r ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRUSEGETINFO( pipes_struct *p, struct WKSSVC_NETRUSEGETINFO *r ) +WERROR _wkssvc_NetrUseGetInfo(pipes_struct *p, struct wkssvc_NetrUseGetInfo *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -162,7 +162,7 @@ WERROR _WKSSVC_NETRUSEGETINFO( pipes_struct *p, struct WKSSVC_NETRUSEGETINFO *r /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRUSEDEL( pipes_struct *p, struct WKSSVC_NETRUSEDEL *r ) +WERROR _wkssvc_NetrUseDel(pipes_struct *p, struct wkssvc_NetrUseDel *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -172,7 +172,7 @@ WERROR _WKSSVC_NETRUSEDEL( pipes_struct *p, struct WKSSVC_NETRUSEDEL *r ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRUSEENUM( pipes_struct *p, struct WKSSVC_NETRUSEENUM *r ) +WERROR _wkssvc_NetrUseEnum(pipes_struct *p, struct wkssvc_NetrUseEnum *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -182,7 +182,7 @@ WERROR _WKSSVC_NETRUSEENUM( pipes_struct *p, struct WKSSVC_NETRUSEENUM *r ) /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRMESSAGEBUFFERSEND( pipes_struct *p, struct WKSSVC_NETRMESSAGEBUFFERSEND *r ) +WERROR _wkssvc_NetrMessageBufferSend(pipes_struct *p, struct wkssvc_NetrMessageBufferSend *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -192,7 +192,7 @@ WERROR _WKSSVC_NETRMESSAGEBUFFERSEND( pipes_struct *p, struct WKSSVC_NETRMESSAGE /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRWORKSTATIONSTATISTICSGET( pipes_struct *p, struct WKSSVC_NETRWORKSTATIONSTATISTICSGET *r ) +WERROR _wkssvc_NetrWorkstationStatisticsGet(pipes_struct *p, struct wkssvc_NetrWorkstationStatisticsGet *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -202,7 +202,7 @@ WERROR _WKSSVC_NETRWORKSTATIONSTATISTICSGET( pipes_struct *p, struct WKSSVC_NETR /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRLOGONDOMAINNAMEADD( pipes_struct *p, struct WKSSVC_NETRLOGONDOMAINNAMEADD *r ) +WERROR _wkssvc_NetrLogonDomainNameAdd(pipes_struct *p, struct wkssvc_NetrLogonDomainNameAdd *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -212,7 +212,7 @@ WERROR _WKSSVC_NETRLOGONDOMAINNAMEADD( pipes_struct *p, struct WKSSVC_NETRLOGOND /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRLOGONDOMAINNAMEDEL( pipes_struct *p, struct WKSSVC_NETRLOGONDOMAINNAMEDEL *r ) +WERROR _wkssvc_NetrLogonDomainNameDel(pipes_struct *p, struct wkssvc_NetrLogonDomainNameDel *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -222,7 +222,7 @@ WERROR _WKSSVC_NETRLOGONDOMAINNAMEDEL( pipes_struct *p, struct WKSSVC_NETRLOGOND /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRJOINDOMAIN( pipes_struct *p, struct WKSSVC_NETRJOINDOMAIN *r ) +WERROR _wkssvc_NetrJoinDomain(pipes_struct *p, struct wkssvc_NetrJoinDomain *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -232,7 +232,7 @@ WERROR _WKSSVC_NETRJOINDOMAIN( pipes_struct *p, struct WKSSVC_NETRJOINDOMAIN *r /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRUNJOINDOMAIN( pipes_struct *p, struct WKSSVC_NETRUNJOINDOMAIN *r ) +WERROR _wkssvc_NetrUnjoinDomain(pipes_struct *p, struct wkssvc_NetrUnjoinDomain *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -242,7 +242,7 @@ WERROR _WKSSVC_NETRUNJOINDOMAIN( pipes_struct *p, struct WKSSVC_NETRUNJOINDOMAIN /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRRENAMEMACHINEINDOMAIN( pipes_struct *p, struct WKSSVC_NETRRENAMEMACHINEINDOMAIN *r ) +WERROR _wkssvc_NetrRenameMachineInDomain(pipes_struct *p, struct wkssvc_NetrRenameMachineInDomain *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -252,7 +252,7 @@ WERROR _WKSSVC_NETRRENAMEMACHINEINDOMAIN( pipes_struct *p, struct WKSSVC_NETRREN /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRVALIDATENAME( pipes_struct *p, struct WKSSVC_NETRVALIDATENAME *r ) +WERROR _wkssvc_NetrValidateName(pipes_struct *p, struct wkssvc_NetrValidateName *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -262,7 +262,7 @@ WERROR _WKSSVC_NETRVALIDATENAME( pipes_struct *p, struct WKSSVC_NETRVALIDATENAME /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRGETJOININFORMATION( pipes_struct *p, struct WKSSVC_NETRGETJOININFORMATION *r ) +WERROR _wkssvc_NetrGetJoinInformation(pipes_struct *p, struct wkssvc_NetrGetJoinInformation *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -272,7 +272,7 @@ WERROR _WKSSVC_NETRGETJOININFORMATION( pipes_struct *p, struct WKSSVC_NETRGETJOI /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRGETJOINABLEOUS( pipes_struct *p, struct WKSSVC_NETRGETJOINABLEOUS *r ) +WERROR _wkssvc_NetrGetJoinableOus(pipes_struct *p, struct wkssvc_NetrGetJoinableOus *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -312,7 +312,7 @@ WERROR _wkssvc_NetrRenameMachineInDomain2(pipes_struct *p, struct wkssvc_NetrRen /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRVALIDATENAME2( pipes_struct *p, struct WKSSVC_NETRVALIDATENAME2 *r ) +WERROR _wkssvc_NetrValidateName2(pipes_struct *p, struct wkssvc_NetrValidateName2 *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -322,7 +322,7 @@ WERROR _WKSSVC_NETRVALIDATENAME2( pipes_struct *p, struct WKSSVC_NETRVALIDATENAM /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRGETJOINABLEOUS2( pipes_struct *p, struct WKSSVC_NETRGETJOINABLEOUS2 *r ) +WERROR _wkssvc_NetrGetJoinableOus2(pipes_struct *p, struct wkssvc_NetrGetJoinableOus2 *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -332,7 +332,7 @@ WERROR _WKSSVC_NETRGETJOINABLEOUS2( pipes_struct *p, struct WKSSVC_NETRGETJOINAB /******************************************************************** ********************************************************************/ -WERROR _wkssvc_NetrAddAlternateComputerName(pipes_struct *p, struct wkssvc_NetrAddAlternateComputerName *r ) +WERROR _wkssvc_NetrAddAlternateComputerName(pipes_struct *p, struct wkssvc_NetrAddAlternateComputerName *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -352,7 +352,7 @@ WERROR _wkssvc_NetrRemoveAlternateComputerName(pipes_struct *p, struct wkssvc_Ne /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRSETPRIMARYCOMPUTERNAME( pipes_struct *p, struct WKSSVC_NETRSETPRIMARYCOMPUTERNAME *r ) +WERROR _wkssvc_NetrSetPrimaryComputername(pipes_struct *p, struct wkssvc_NetrSetPrimaryComputername *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; @@ -362,7 +362,7 @@ WERROR _WKSSVC_NETRSETPRIMARYCOMPUTERNAME( pipes_struct *p, struct WKSSVC_NETRSE /******************************************************************** ********************************************************************/ -WERROR _WKSSVC_NETRENUMERATECOMPUTERNAMES( pipes_struct *p, struct WKSSVC_NETRENUMERATECOMPUTERNAMES *r ) +WERROR _wkssvc_NetrEnumerateComputerNames(pipes_struct *p, struct wkssvc_NetrEnumerateComputerNames *r) { /* FIXME: Add implementation code here */ p->rng_fault_state = True; -- cgit From bbf2cb6da994ac73dd7ea26d81f724aa04b5a3cb Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 1 Dec 2007 11:43:12 +0100 Subject: Fix some C++ warnings (This used to be commit 156c7f10bb63a610f85b52242cfd1b67bfa73c29) --- source3/rpc_server/srv_eventlog_nt.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index cd06be1984..3c9c835bad 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -355,18 +355,16 @@ static Eventlog_entry *get_eventlog_record(prs_struct *ps, into it's 2nd argment for 'B' */ if (wpcomputer) { - ee->data_record.computer_name = TALLOC_MEMDUP(ee, - wpcomputer, - ee->data_record.computer_name_len); + ee->data_record.computer_name = (smb_ucs2_t *)TALLOC_MEMDUP( + ee, wpcomputer, ee->data_record.computer_name_len); if (!ee->data_record.computer_name) { TALLOC_FREE(ee); goto out; } } if (wpsource) { - ee->data_record.source_name = TALLOC_MEMDUP(ee, - wpsource, - ee->data_record.source_name_len); + ee->data_record.source_name = (smb_ucs2_t *)TALLOC_MEMDUP( + ee, wpsource, ee->data_record.source_name_len); if (!ee->data_record.source_name) { TALLOC_FREE(ee); goto out; @@ -374,18 +372,16 @@ static Eventlog_entry *get_eventlog_record(prs_struct *ps, } if (wpsid) { - ee->data_record.sid = TALLOC_MEMDUP(ee, - wpsid, - ee->record.user_sid_length); + ee->data_record.sid = (smb_ucs2_t *)TALLOC_MEMDUP( + ee, wpsid, ee->record.user_sid_length); if (!ee->data_record.sid) { TALLOC_FREE(ee); goto out; } } if (wpstrs) { - ee->data_record.strings = TALLOC_MEMDUP(ee, - wpstrs, - ee->data_record.strings_len); + ee->data_record.strings = (smb_ucs2_t *)TALLOC_MEMDUP( + ee, wpstrs, ee->data_record.strings_len); if (!ee->data_record.strings) { TALLOC_FREE(ee); goto out; @@ -393,9 +389,8 @@ static Eventlog_entry *get_eventlog_record(prs_struct *ps, } if (puserdata) { - ee->data_record.user_data = TALLOC_MEMDUP(ee, - puserdata, - ee->data_record.user_data_len); + ee->data_record.user_data = (char *)TALLOC_MEMDUP( + ee, puserdata, ee->data_record.user_data_len); if (!ee->data_record.user_data) { TALLOC_FREE(ee); goto out; -- cgit From 78c6ee0090f4122bc25baaacb5546517ad4b7bc6 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 24 Nov 2007 17:27:54 +0100 Subject: Remove some globals (This used to be commit 31d0a846db08d845e6cdfd85def4ac1c34031e02) --- source3/rpc_server/srv_wkssvc_nt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 70cf80c20a..1e43b5ae99 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -36,10 +36,10 @@ static void create_wks_info_100(struct wkssvc_NetWkstaInfo100 *info100) info100->version_major = lp_major_announce_version(); info100->version_minor = lp_minor_announce_version(); - info100->server_name = talloc_strdup( - info100, strupper_static(global_myname())); - info100->domain_name = talloc_strdup( - info100, strupper_static(lp_workgroup())); + info100->server_name = talloc_asprintf_strupper_m( + info100, "%s", global_myname()); + info100->domain_name = talloc_asprintf_strupper_m( + info100, "%s", lp_workgroup()); return; } -- cgit From 6bec071408c80a85dc2a7830d2cf4c48157b5187 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 9 Dec 2007 19:46:06 +0100 Subject: Don't copy the rpc function pointers This actually shows up in a valgrind massif run with 4.1% of allocated memory. I don't see why we would have to make a copy here. Metze? (This used to be commit 616d6b97e594a846e9b3ac4cbe48538d649462e9) --- source3/rpc_server/srv_pipe.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 49ffcf13a6..5ede0c93f4 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -714,7 +714,7 @@ struct rpc_table { const char *clnt; const char *srv; } pipe; - struct api_struct *cmds; + const struct api_struct *cmds; int n_cmds; }; @@ -1075,12 +1075,8 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *s ZERO_STRUCTP(rpc_entry); rpc_entry->pipe.clnt = SMB_STRDUP(clnt); rpc_entry->pipe.srv = SMB_STRDUP(srv); - rpc_entry->cmds = SMB_REALLOC_ARRAY(rpc_entry->cmds, struct api_struct, rpc_entry->n_cmds + size); - if (!rpc_entry->cmds) { - return NT_STATUS_NO_MEMORY; - } - memcpy(rpc_entry->cmds + rpc_entry->n_cmds, cmds, size * sizeof(struct api_struct)); - rpc_entry->n_cmds += size; + rpc_entry->cmds = cmds; + rpc_entry->n_cmds = size; return NT_STATUS_OK; } -- cgit From 7faee02d0d351c5c039e8f1be7e82ce3a93cbe96 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Dec 2007 11:30:37 -0800 Subject: Remove the char[1024] strings from dynconfig. Replace them with malloc'ing accessor functions. Should save a lot of static space :-). Jeremy. (This used to be commit 52dc5eaef2106015b3a8b659e818bdb15ad94b05) --- source3/rpc_server/srv_srvsvc_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index b034e7cbd3..125ccb4752 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1692,7 +1692,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S command = talloc_asprintf(p->mem_ctx, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", lp_change_share_cmd(), - dyn_CONFIGFILE, + get_dyn_CONFIGFILE(), share_name, path, comment ? comment : "", @@ -1877,7 +1877,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S command = talloc_asprintf(ctx, "%s \"%s\" \"%s\" \"%s\" \"%s\" %d", lp_add_share_cmd(), - dyn_CONFIGFILE, + get_dyn_CONFIGFILE(), share_name, path, comment ? comment : "", @@ -1984,7 +1984,7 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S command = talloc_asprintf(ctx, "%s \"%s\" \"%s\"", lp_delete_share_cmd(), - dyn_CONFIGFILE, + get_dyn_CONFIGFILE(), lp_servicename(snum)); if (!command) { return WERR_NOMEM; -- cgit From 6dd89174ecef8b68774924de8b94a24c73ea4f44 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Dec 2007 12:11:45 -0800 Subject: Fix return values for invalid printers. Found by kblin spoolss test. Jeremy. (This used to be commit bb8c044d425cf62b76e487103c8fb0b6cd4c83c2) --- source3/rpc_server/srv_spoolss_nt.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a17a8ebf26..c1e422657b 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1530,6 +1530,13 @@ WERROR _spoolss_open_printer(pipes_struct *p, SPOOL_Q_OPEN_PRINTER *q_u, SPOOL_R memcpy(r_u, &r_u_ex, sizeof(*r_u)); + if (W_ERROR_EQUAL(r_u->status, WERR_INVALID_PARAM)) { + /* OpenPrinterEx returns this for a bad + * printer name. We must return WERR_INVALID_PRINTER_NAME + * instead. + */ + r_u->status = WERR_INVALID_PRINTER_NAME; + } return r_u->status; } @@ -1545,8 +1552,9 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, int snum; Printer_entry *Printer=NULL; - if ( !q_u->printername ) - return WERR_INVALID_PRINTER_NAME; + if (!q_u->printername) { + return WERR_INVALID_PARAM; + } /* some sanity check because you can open a printer or a print server */ /* aka: \\server\printer or \\server */ @@ -1555,15 +1563,16 @@ WERROR _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, 0)) - return WERR_INVALID_PRINTER_NAME; + if (!open_printer_hnd(p, handle, name, 0)) { + return WERR_INVALID_PARAM; + } Printer=find_printer_index_by_hnd(p, handle); if ( !Printer ) { DEBUG(0,(" _spoolss_open_printer_ex: logic error. Can't find printer " "handle we created for printer %s\n", name )); close_printer_handle(p,handle); - return WERR_INVALID_PRINTER_NAME; + return WERR_INVALID_PARAM; } /* -- cgit From 951466000c05cd9824c3a6361be707bf55a23550 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 12 Dec 2007 18:03:20 +0100 Subject: Fix for bug #4801: Correctly implement lsa lookup levels for lookupnames. This is a first patch aimed at fixing bug #4801. It is still incomplete in that winbindd does not walk the the trusted domains to lookup unqualified names here. Apart from that this fix should be pretty much complete. Michael (This used to be commit dd320c0924ce393a89b1cab020fd5cffc5b80380) --- source3/rpc_server/srv_lsa_nt.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 20655082a5..c5f0c7b6ab 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1035,6 +1035,31 @@ NTSTATUS _lsa_lookup_sids3(pipes_struct *p, return r_u->status; } +static int lsa_lookup_level_to_flags(uint16 level) +{ + int flags; + + switch (level) { + case 1: + flags = LOOKUP_NAME_ALL; + break; + case 2: + flags = LOOKUP_NAME_DOMAIN|LOOKUP_NAME_REMOTE|LOOKUP_NAME_ISOLATED; + break; + case 3: + flags = LOOKUP_NAME_DOMAIN|LOOKUP_NAME_ISOLATED; + break; + case 4: + case 5: + case 6: + default: + flags = LOOKUP_NAME_NONE; + break; + } + + return flags; +} + /*************************************************************************** lsa_reply_lookup_names ***************************************************************************/ @@ -1054,10 +1079,7 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries)); } - /* Probably the lookup_level is some sort of bitmask. */ - if (q_u->lookup_level == 1) { - flags = LOOKUP_NAME_ALL; - } + flags = lsa_lookup_level_to_flags(q_u->lookup_level); ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); if (!ref) { @@ -1123,11 +1145,8 @@ NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOO num_entries = MAX_LOOKUP_SIDS; DEBUG(5,("_lsa_lookup_names2: truncating name lookup list to %d\n", num_entries)); } - - /* Probably the lookup_level is some sort of bitmask. */ - if (q_u->lookup_level == 1) { - flags = LOOKUP_NAME_ALL; - } + + flags = lsa_lookup_level_to_flags(q_u->lookup_level); ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); if (ref == NULL) { -- cgit From adc31b9235f70d06d2739b38867dc0fadb33d082 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 14 Dec 2007 07:47:07 +0100 Subject: Revert "Fix for bug #4801: Correctly implement lsa lookup levels for lookupnames." As it breaks all tests which try to join a new machine account. So more testing is needed... metze This reverts commit dd320c0924ce393a89b1cab020fd5cffc5b80380. (This used to be commit cccb80b7b7980fbe1298ce266375e51bacb4a425) --- source3/rpc_server/srv_lsa_nt.c | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c5f0c7b6ab..20655082a5 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1035,31 +1035,6 @@ NTSTATUS _lsa_lookup_sids3(pipes_struct *p, return r_u->status; } -static int lsa_lookup_level_to_flags(uint16 level) -{ - int flags; - - switch (level) { - case 1: - flags = LOOKUP_NAME_ALL; - break; - case 2: - flags = LOOKUP_NAME_DOMAIN|LOOKUP_NAME_REMOTE|LOOKUP_NAME_ISOLATED; - break; - case 3: - flags = LOOKUP_NAME_DOMAIN|LOOKUP_NAME_ISOLATED; - break; - case 4: - case 5: - case 6: - default: - flags = LOOKUP_NAME_NONE; - break; - } - - return flags; -} - /*************************************************************************** lsa_reply_lookup_names ***************************************************************************/ @@ -1079,7 +1054,10 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries)); } - flags = lsa_lookup_level_to_flags(q_u->lookup_level); + /* Probably the lookup_level is some sort of bitmask. */ + if (q_u->lookup_level == 1) { + flags = LOOKUP_NAME_ALL; + } ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); if (!ref) { @@ -1145,8 +1123,11 @@ NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOO num_entries = MAX_LOOKUP_SIDS; DEBUG(5,("_lsa_lookup_names2: truncating name lookup list to %d\n", num_entries)); } - - flags = lsa_lookup_level_to_flags(q_u->lookup_level); + + /* Probably the lookup_level is some sort of bitmask. */ + if (q_u->lookup_level == 1) { + flags = LOOKUP_NAME_ALL; + } ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); if (ref == NULL) { -- cgit From 900288a2b86abd247f9eb4cd15dc5617a17cfef1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Dec 2007 21:11:36 +0100 Subject: Replace sid_string_static by sid_string_dbg in DEBUGs (This used to be commit bb35e794ec129805e874ceba882bcc1e84791a09) --- source3/rpc_server/srv_lsa_nt.c | 13 ++--- source3/rpc_server/srv_netlog_nt.c | 6 +-- source3/rpc_server/srv_samr_nt.c | 99 +++++++++++++++++++------------------ source3/rpc_server/srv_spoolss_nt.c | 14 ++---- 4 files changed, 65 insertions(+), 67 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 20655082a5..43e4648fa8 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1692,8 +1692,9 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, prs_struct *ps, LSA_Q_ENUMPRIVS if ( se_priv_to_privilege_set( &privileges, &mask ) ) { - DEBUG(10,("_lsa_enum_privsaccount: %s has %d privileges\n", - sid_string_static(&info->sid), privileges.count)); + DEBUG(10,("_lsa_enum_privsaccount: %s has %d privileges\n", + sid_string_dbg(&info->sid), + privileges.count)); r_u->status = init_lsa_r_enum_privsaccount(ps->mem_ctx, r_u, privileges.set, privileges.count, 0); } @@ -1791,7 +1792,7 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u if ( !grant_privilege( &info->sid, &mask ) ) { DEBUG(3,("_lsa_addprivs: grant_privilege(%s) failed!\n", - sid_string_static(&info->sid) )); + sid_string_dbg(&info->sid) )); DEBUG(3,("Privilege mask:\n")); dump_se_priv( DBGC_ALL, 3, &mask ); return NT_STATUS_NO_SUCH_PRIVILEGE; @@ -1830,7 +1831,7 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP if ( !revoke_privilege( &info->sid, &mask ) ) { DEBUG(3,("_lsa_removeprivs: revoke_privilege(%s) failed!\n", - sid_string_static(&info->sid) )); + sid_string_dbg(&info->sid) )); DEBUG(3,("Privilege mask:\n")); dump_se_priv( DBGC_ALL, 3, &mask ); return NT_STATUS_NO_SUCH_PRIVILEGE; @@ -2105,8 +2106,8 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA if ( se_priv_to_privilege_set( &privileges, &mask ) ) { - DEBUG(10,("_lsa_enum_acct_rights: %s has %d privileges\n", - sid_string_static(&sid), privileges.count)); + DEBUG(10,("_lsa_enum_acct_rights: %s has %d privileges\n", + sid_string_dbg(&sid), privileges.count)); r_u->status = init_r_enum_acct_rights( r_u, &privileges ); } diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 29c60e07b5..218ce73444 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -958,8 +958,6 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, int num_gids = 0; const char *my_name; - fstring user_sid_string; - fstring group_sid_string; unsigned char user_session_key[16]; unsigned char lm_session_key[16]; unsigned char pipe_session_key[16]; @@ -988,8 +986,8 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, "supported for NETLOGON calls\n", pdb_get_domain(sampw), pdb_get_username(sampw), - sid_to_string(user_sid_string, user_sid), - sid_to_string(group_sid_string, group_sid))); + sid_string_dbg(user_sid), + sid_string_dbg(group_sid))); return NT_STATUS_UNSUCCESSFUL; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 3cc8f01d2c..d013ec8f03 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -347,7 +347,7 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) static void free_samr_cache(DISP_INFO *disp_info) { DEBUG(10, ("free_samr_cache: deleting cache for SID %s\n", - sid_string_static(&disp_info->sid))); + sid_string_dbg(&disp_info->sid))); /* We need to become root here because the paged search might have to * tell the LDAP server we're not interested in the rest anymore. */ @@ -431,8 +431,7 @@ static void set_disp_info_cache_timeout(DISP_INFO *disp_info, time_t secs_fromno TALLOC_FREE(disp_info->cache_timeout_event); DEBUG(10,("set_disp_info_cache_timeout: caching enumeration for " - "SID %s for %u seconds\n", - sid_string_static(&disp_info->sid), + "SID %s for %u seconds\n", sid_string_dbg(&disp_info->sid), (unsigned int)secs_fromnow )); disp_info->cache_timeout_event = event_add_timed( @@ -702,7 +701,7 @@ NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_ unbecome_root(); if (!ret) { - DEBUG(4, ("User %s not found\n", sid_string_static(&pol_sid))); + DEBUG(4, ("User %s not found\n", sid_string_dbg(&pol_sid))); TALLOC_FREE(sampass); return NT_STATUS_INVALID_HANDLE; } @@ -753,7 +752,7 @@ static bool check_change_pw_access(TALLOC_CTX *mem_ctx, DOM_SID *user_sid) unbecome_root(); if (ret == False) { - DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); + DEBUG(4,("User %s not found\n", sid_string_dbg(user_sid))); TALLOC_FREE(sampass); return False; } @@ -776,7 +775,6 @@ static bool check_change_pw_access(TALLOC_CTX *mem_ctx, DOM_SID *user_sid) NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_QUERY_SEC_OBJ *r_u) { DOM_SID pol_sid; - fstring str_sid; SEC_DESC * psd = NULL; uint32 acc_granted; size_t sd_size; @@ -787,7 +785,8 @@ NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &pol_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - DEBUG(10,("_samr_query_sec_obj: querying security on SID: %s\n", sid_to_string(str_sid, &pol_sid))); + DEBUG(10,("_samr_query_sec_obj: querying security on SID: %s\n", + sid_string_dbg(&pol_sid))); /* Check what typ of SID is beeing queried (e.g Domain SID, User SID, Group SID) */ @@ -797,18 +796,21 @@ NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_ r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); } else if (sid_equal(&pol_sid,get_global_sam_sid())) { /* check if it is our domain SID */ - DEBUG(5,("_samr_query_sec_obj: querying security on Domain with SID: %s\n", sid_to_string(str_sid, &pol_sid))); + DEBUG(5,("_samr_query_sec_obj: querying security on Domain " + "with SID: %s\n", sid_string_dbg(&pol_sid))); r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0); } else if (sid_equal(&pol_sid,&global_sid_Builtin)) { /* check if it is the Builtin Domain */ /* TODO: Builtin probably needs a different SD with restricted write access*/ - DEBUG(5,("_samr_query_sec_obj: querying security on Builtin Domain with SID: %s\n", sid_to_string(str_sid, &pol_sid))); + DEBUG(5,("_samr_query_sec_obj: querying security on Builtin " + "Domain with SID: %s\n", sid_string_dbg(&pol_sid))); r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0); } else if (sid_check_is_in_our_domain(&pol_sid) || sid_check_is_in_builtin(&pol_sid)) { /* TODO: different SDs have to be generated for aliases groups and users. Currently all three get a default user SD */ - DEBUG(10,("_samr_query_sec_obj: querying security on Object with SID: %s\n", sid_to_string(str_sid, &pol_sid))); + DEBUG(10,("_samr_query_sec_obj: querying security on Object " + "with SID: %s\n", sid_string_dbg(&pol_sid))); if (check_change_pw_access(p->mem_ctx, &pol_sid)) { r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, &pol_sid, SAMR_USR_RIGHTS_WRITE_PW); @@ -1101,7 +1103,7 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S return r_u->status; DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", - sid_string_static(&info->sid))); + sid_string_dbg(&info->sid))); become_root(); @@ -1466,7 +1468,6 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO int i; int num_rids = q_u->num_names2; DOM_SID pol_sid; - fstring sid_str; uint32 acc_granted; r_u->status = NT_STATUS_OK; @@ -1490,7 +1491,8 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO DEBUG(5,("_samr_lookup_names: truncating entries to %d\n", num_rids)); } - DEBUG(5,("_samr_lookup_names: looking name on SID %s\n", sid_to_string(sid_str, &pol_sid))); + DEBUG(5,("_samr_lookup_names: looking name on SID %s\n", + sid_string_dbg(&pol_sid))); for (i = 0; i < num_rids; i++) { fstring name; @@ -1861,7 +1863,7 @@ static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_S unbecome_root(); if ( !ret ) { - DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); + DEBUG(4,("User %s not found\n", sid_string_dbg(user_sid))); return NT_STATUS_NO_SUCH_USER; } @@ -1892,7 +1894,7 @@ static NTSTATUS get_user_info_9(TALLOC_CTX *mem_ctx, SAM_USER_INFO_9 * id9, DOM_ unbecome_root(); if (ret==False) { - DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); + DEBUG(4,("User %s not found\n", sid_string_dbg(user_sid))); return NT_STATUS_NO_SUCH_USER; } @@ -1924,7 +1926,7 @@ static NTSTATUS get_user_info_16(TALLOC_CTX *mem_ctx, SAM_USER_INFO_16 *id16, DO unbecome_root(); if (ret==False) { - DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); + DEBUG(4,("User %s not found\n", sid_string_dbg(user_sid))); return NT_STATUS_NO_SUCH_USER; } @@ -1968,7 +1970,7 @@ static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_ ret = pdb_getsampwsid(smbpass, user_sid); if (ret == False) { - DEBUG(4, ("User %s not found\n", sid_string_static(user_sid))); + DEBUG(4, ("User %s not found\n", sid_string_dbg(user_sid))); TALLOC_FREE(smbpass); return (geteuid() == (uid_t)0) ? NT_STATUS_NO_SUCH_USER : NT_STATUS_ACCESS_DENIED; } @@ -2006,7 +2008,7 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, SAM_USER_INFO_20 *id20, DO unbecome_root(); if (ret == False) { - DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); + DEBUG(4,("User %s not found\n", sid_string_dbg(user_sid))); return NT_STATUS_NO_SUCH_USER; } @@ -2042,7 +2044,7 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, unbecome_root(); if (ret == False) { - DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); + DEBUG(4,("User %s not found\n", sid_string_dbg(user_sid))); return NT_STATUS_NO_SUCH_USER; } @@ -2082,7 +2084,8 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ if (!sid_check_is_in_our_domain(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - DEBUG(5,("_samr_query_userinfo: sid:%s\n", sid_string_static(&info->sid))); + DEBUG(5,("_samr_query_userinfo: sid:%s\n", + sid_string_dbg(&info->sid))); ctr = TALLOC_ZERO_P(p->mem_ctx, SAM_USERINFO_CTR); if (!ctr) @@ -2215,7 +2218,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S if (!ret) { DEBUG(10, ("pdb_getsampwsid failed for %s\n", - sid_string_static(&sid))); + sid_string_dbg(&sid))); return NT_STATUS_NO_SUCH_USER; } @@ -2234,13 +2237,13 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S if (!NT_STATUS_IS_OK(result)) { DEBUG(10, ("pdb_enum_group_memberships failed for %s\n", - sid_string_static(&sid))); + sid_string_dbg(&sid))); return result; } if ( !success ) { DEBUG(5, ("Group sid %s for user %s not in our domain\n", - sid_string_static(pdb_get_group_sid(sam_pass)), + sid_string_dbg(pdb_get_group_sid(sam_pass)), pdb_get_username(sam_pass))); TALLOC_FREE(sam_pass); return NT_STATUS_INTERNAL_DB_CORRUPTION; @@ -2259,7 +2262,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S if (!sid_peek_check_rid(get_global_sam_sid(), &(sids[i]), &dom_gid.g_rid)) { DEBUG(10, ("Found sid %s not in our domain\n", - sid_string_static(&sids[i]))); + sid_string_dbg(&sids[i]))); continue; } @@ -2897,7 +2900,8 @@ NTSTATUS _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_ } } - DEBUG(2,("Returning domain sid for domain %s -> %s\n", domain_name, sid_string_static(&sid))); + DEBUG(2,("Returning domain sid for domain %s -> %s\n", domain_name, + sid_string_dbg(&sid))); init_samr_r_lookup_domain(r_u, &sid, r_u->status); @@ -3523,7 +3527,8 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE return r_u->status; } - DEBUG(5, ("_samr_set_userinfo: sid:%s, level:%d\n", sid_string_static(&sid), switch_value)); + DEBUG(5, ("_samr_set_userinfo: sid:%s, level:%d\n", + sid_string_dbg(&sid), switch_value)); if (ctr == NULL) { DEBUG(5, ("_samr_set_userinfo: NULL info level\n")); @@ -3683,7 +3688,8 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ return r_u->status; } - DEBUG(5, ("samr_reply_set_userinfo2: sid:%s\n", sid_string_static(&sid))); + DEBUG(5, ("samr_reply_set_userinfo2: sid:%s\n", + sid_string_dbg(&sid))); if (ctr == NULL) { DEBUG(5, ("samr_reply_set_userinfo2: NULL info level\n")); @@ -3879,7 +3885,7 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ return r_u->status; } - DEBUG(10, ("sid is %s\n", sid_string_static(&alias_sid))); + DEBUG(10, ("sid is %s\n", sid_string_dbg(&alias_sid))); become_root(); status = pdb_enum_aliasmem(&alias_sid, &sids, &num_sids); @@ -3917,7 +3923,6 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_QUERY_GROUPMEM *r_u) { DOM_SID group_sid; - fstring group_sid_str; size_t i, num_members; uint32 *rid=NULL; @@ -3935,11 +3940,11 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ return r_u->status; } - sid_to_string(group_sid_str, &group_sid); - DEBUG(10, ("sid is %s\n", group_sid_str)); + DEBUG(10, ("sid is %s\n", sid_string_dbg(&group_sid))); if (!sid_check_is_in_our_domain(&group_sid)) { - DEBUG(3, ("sid %s is not in our domain\n", group_sid_str)); + DEBUG(3, ("sid %s is not in our domain\n", + sid_string_dbg(&group_sid))); return NT_STATUS_NO_SUCH_GROUP; } @@ -3991,7 +3996,7 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD return r_u->status; } - DEBUG(10, ("sid is %s\n", sid_string_static(&alias_sid))); + DEBUG(10, ("sid is %s\n", sid_string_dbg(&alias_sid))); se_priv_copy( &se_rights, &se_add_users ); can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); @@ -4037,7 +4042,7 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE } DEBUG(10, ("_samr_del_aliasmem:sid is %s\n", - sid_string_static(&alias_sid))); + sid_string_dbg(&alias_sid))); se_priv_copy( &se_rights, &se_add_users ); can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); @@ -4082,7 +4087,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD return r_u->status; } - DEBUG(10, ("sid is %s\n", sid_string_static(&group_sid))); + DEBUG(10, ("sid is %s\n", sid_string_dbg(&group_sid))); if (!sid_peek_check_rid(get_global_sam_sid(), &group_sid, &group_rid)) { @@ -4199,7 +4204,7 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM if( !ret ) { DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n", - sid_string_static(&user_sid))); + sid_string_dbg(&user_sid))); TALLOC_FREE(sam_pass); return NT_STATUS_NO_SUCH_USER; } @@ -4267,7 +4272,7 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S return r_u->status; } - DEBUG(10, ("sid is %s\n", sid_string_static(&group_sid))); + DEBUG(10, ("sid is %s\n", sid_string_dbg(&group_sid))); if (!sid_peek_check_rid(get_global_sam_sid(), &group_sid, &group_rid)) { @@ -4292,7 +4297,7 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S if ( !NT_STATUS_IS_OK(r_u->status) ) { DEBUG(5,("_samr_delete_dom_group: Failed to delete mapping " "entry for group %s: %s\n", - sid_string_static(&group_sid), + sid_string_dbg(&group_sid), nt_errstr(r_u->status))); return r_u->status; } @@ -4332,7 +4337,7 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S return r_u->status; } - DEBUG(10, ("sid is %s\n", sid_string_static(&alias_sid))); + DEBUG(10, ("sid is %s\n", sid_string_dbg(&alias_sid))); /* Don't let Windows delete builtin groups */ @@ -4907,12 +4912,12 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, DISP_INFO *disp_info = NULL; sid_copy( &delete_sid, &q_u->sid.sid ); - + DEBUG(5,("_samr_remove_sid_foreign_domain: removing SID [%s]\n", - sid_string_static(&delete_sid))); - + sid_string_dbg(&delete_sid))); + /* Find the policy handle. Open a policy on it. */ - + if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &domain_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; @@ -4923,8 +4928,8 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, if (!NT_STATUS_IS_OK(result)) return result; - DEBUG(8, ("_samr_remove_sid_foreign_domain:sid is %s\n", - sid_string_static(&domain_sid))); + DEBUG(8, ("_samr_remove_sid_foreign_domain:sid is %s\n", + sid_string_dbg(&domain_sid))); /* we can only delete a user from a group since we don't have nested groups anyways. So in the latter case, just say OK */ @@ -4943,8 +4948,8 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, if (!sid_check_is_builtin(&domain_sid)) { DEBUG(1,("_samr_remove_sid_foreign_domain: domain_sid = %s, " "global_sam_sid() = %s\n", - sid_string_static(&domain_sid), - sid_string_static(get_global_sam_sid()))); + sid_string_dbg(&domain_sid), + sid_string_dbg(get_global_sam_sid()))); DEBUGADD(1,("please report to samba-technical@samba.org!\n")); return NT_STATUS_OK; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index c1e422657b..3758c8fd63 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6044,11 +6044,8 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, PRINTERNAME(snum), the_acl->num_aces)); for (i = 0; i < the_acl->num_aces; i++) { - fstring sid_str; - - sid_to_string(sid_str, &the_acl->aces[i].trustee); - - DEBUG(10, ("%s 0x%08x\n", sid_str, + DEBUG(10, ("%s 0x%08x\n", sid_string_dbg( + &the_acl->aces[i].trustee), the_acl->aces[i].access_mask)); } @@ -6059,11 +6056,8 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, PRINTERNAME(snum), the_acl->num_aces)); for (i = 0; i < the_acl->num_aces; i++) { - fstring sid_str; - - sid_to_string(sid_str, &the_acl->aces[i].trustee); - - DEBUG(10, ("%s 0x%08x\n", sid_str, + DEBUG(10, ("%s 0x%08x\n", sid_string_dbg( + &the_acl->aces[i].trustee), the_acl->aces[i].access_mask)); } } else { -- cgit From 14ef4cdec1ab6be55c97d0f32780cbddbcdde218 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Dec 2007 22:00:39 +0100 Subject: Replace sid_string_static with sid_to_string This adds 28 fstrings on the stack, but I think an fstring on the stack is still far better than a static one. (This used to be commit c7c885078be8fd3024c186044ac28275d7609679) --- source3/rpc_server/srv_lsa_nt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 43e4648fa8..02f7f090a4 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -861,6 +861,7 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, struct lsa_name_info *name = &name_infos[i]; if (name->type == SID_NAME_UNKNOWN) { + fstring tmp; name->dom_idx = -1; /* Unknown sids should return the string * representation of the SID. Windows 2003 behaves @@ -869,7 +870,8 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, * SID. We (Jerry/VL) could not figure out which the * hard cases are, so leave it with the SID. */ name->name = talloc_asprintf(p->mem_ctx, "%s", - sid_string_static(sids[i])); + sid_to_string(tmp, + sids[i])); if (name->name == NULL) { return NT_STATUS_NO_MEMORY; } -- cgit From 2e07c2ade89f4ff281c61f74cb88e09990cf5f46 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 15 Dec 2007 22:47:30 +0100 Subject: s/sid_to_string/sid_to_fstring/ least surprise for callers (This used to be commit eb523ba77697346a365589101aac379febecd546) --- source3/rpc_server/srv_lsa_nt.c | 4 ++-- source3/rpc_server/srv_samr_nt.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 02f7f090a4..a1ddc8e6c8 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -870,8 +870,8 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, * SID. We (Jerry/VL) could not figure out which the * hard cases are, so leave it with the SID. */ name->name = talloc_asprintf(p->mem_ctx, "%s", - sid_to_string(tmp, - sids[i])); + sid_to_fstring(tmp, + sids[i])); if (name->name == NULL) { return NT_STATUS_NO_MEMORY; } diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d013ec8f03..1af41228a7 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -315,7 +315,7 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) TALLOC_CTX *mem_ctx; if (psid) { - sid_to_string(sid_str, psid); + sid_to_fstring(sid_str, psid); } else { fstrcpy(sid_str,"(NULL)"); } @@ -4875,7 +4875,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G sid_copy(&info_sid, get_global_sam_sid()); sid_append_rid(&info_sid, q_u->rid_group); - sid_to_string(sid_string, &info_sid); + sid_to_fstring(sid_string, &info_sid); if ((info = get_samr_info_by_sid(&info_sid)) == NULL) return NT_STATUS_NO_MEMORY; -- cgit From a9b6deaa05942e4ffbfa3ee32a6ab65b866cc66d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 16 Dec 2007 12:57:06 +0100 Subject: Remove unused code (This used to be commit fcd45ad6fb8d89bf6106fbed101060dbe422661a) --- source3/rpc_server/srv_pipe_hnd.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index c3197c3f0d..969c9ecda3 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -68,20 +68,6 @@ static bool close_internal_rpc_pipe_hnd(void *np_conn); static void *make_internal_rpc_pipe_p(const char *pipe_name, connection_struct *conn, uint16 vuid); -/**************************************************************************** - Pipe iterator functions. -****************************************************************************/ - -smb_np_struct *get_first_pipe(void) -{ - return Pipes; -} - -smb_np_struct *get_next_pipe(smb_np_struct *p) -{ - return p->next; -} - /**************************************************************************** Internal Pipe iterator functions. ****************************************************************************/ -- cgit From 02dd1f7f4c4f6e1f91bd651ccdde9b2bb3fcef81 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 16 Dec 2007 12:58:07 +0100 Subject: Make smb_np_struct talloc'ed Convert "name" from string to a talloc'ed char * (This used to be commit e82069f921b3a22295db91e092c22c459ccd7215) --- source3/rpc_server/srv_pipe_hnd.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 969c9ecda3..95ce496ba6 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -195,14 +195,21 @@ smb_np_struct *open_rpc_pipe_p(const char *pipe_name, DEBUG(5,("open_rpc_pipe_p: name %s pnum=%x\n", p->name, p->pnum)); } - p = SMB_MALLOC_P(smb_np_struct); + p = talloc(NULL, smb_np_struct); if (!p) { - DEBUG(0,("ERROR! no memory for pipes_struct!\n")); + DEBUG(0,("ERROR! no memory for smb_np_struct!\n")); return NULL; } ZERO_STRUCTP(p); + p->name = talloc_strdup(p, pipe_name); + if (p->name == NULL) { + TALLOC_FREE(p); + DEBUG(0,("ERROR! no memory for pipe name!\n")); + return NULL; + } + /* add a dso mechanism instead of this, here */ p->namedpipe_create = make_internal_rpc_pipe_p; @@ -241,9 +248,7 @@ smb_np_struct *open_rpc_pipe_p(const char *pipe_name, p->vuid = vuid; p->max_trans_reply = 0; - - fstrcpy(p->name, pipe_name); - + DEBUG(4,("Opened pipe %s with handle %x (pipes_open=%d)\n", pipe_name, i, pipes_open)); @@ -1163,9 +1168,7 @@ bool close_rpc_pipe_hnd(smb_np_struct *p) "pipe from open db.\n", p->name)); } - ZERO_STRUCTP(p); - - SAFE_FREE(p); + TALLOC_FREE(p); return True; } -- cgit From 4c8a7082880e1c7ffff32f2567bc768d908a3699 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 17 Dec 2007 11:32:21 +0100 Subject: Fix flags in call of lookup_name() in srv_samr_nt.c: can_create(). Use LOOKUP_NAME_LOCAL instead of LOOKUP_NAME_ISOLATED. Michael (This used to be commit 1d4e0ad1142c61de402c925306f02f5de2c872f6) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1af41228a7..cc4b4f330f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2494,9 +2494,9 @@ static NTSTATUS can_create(TALLOC_CTX *mem_ctx, const char *new_name) DEBUG(10, ("Checking whether [%s] can be created\n", new_name)); become_root(); - /* Lookup in our local databases (only LOOKUP_NAME_ISOLATED set) + /* Lookup in our local databases (LOOKUP_NAME_REMOTE not set) * whether the name already exists */ - result = lookup_name(mem_ctx, new_name, LOOKUP_NAME_ISOLATED, + result = lookup_name(mem_ctx, new_name, LOOKUP_NAME_LOCAL, NULL, NULL, NULL, &type); unbecome_root(); -- cgit From 81327b1613819ad875cc9271c280a5afab039545 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 12 Dec 2007 18:03:20 +0100 Subject: Fix for bug #4801: Correctly implement lsa lookup levels for lookupnames. This patch is still incomplete in that winbindd does not walk the the trusted domains to lookup unqualified names here. Apart from that this fix should be pretty much complete. Michael (This used to be commit f7efc0eca9426e63b751c07a90265a12bb39cf95) --- source3/rpc_server/srv_lsa_nt.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index a1ddc8e6c8..a289196f5f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1037,6 +1037,31 @@ NTSTATUS _lsa_lookup_sids3(pipes_struct *p, return r_u->status; } +static int lsa_lookup_level_to_flags(uint16 level) +{ + int flags; + + switch (level) { + case 1: + flags = LOOKUP_NAME_ALL; + break; + case 2: + flags = LOOKUP_NAME_DOMAIN|LOOKUP_NAME_REMOTE|LOOKUP_NAME_ISOLATED; + break; + case 3: + flags = LOOKUP_NAME_DOMAIN|LOOKUP_NAME_ISOLATED; + break; + case 4: + case 5: + case 6: + default: + flags = LOOKUP_NAME_NONE; + break; + } + + return flags; +} + /*************************************************************************** lsa_reply_lookup_names ***************************************************************************/ @@ -1056,10 +1081,7 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries)); } - /* Probably the lookup_level is some sort of bitmask. */ - if (q_u->lookup_level == 1) { - flags = LOOKUP_NAME_ALL; - } + flags = lsa_lookup_level_to_flags(q_u->lookup_level); ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); if (!ref) { @@ -1125,11 +1147,8 @@ NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOO num_entries = MAX_LOOKUP_SIDS; DEBUG(5,("_lsa_lookup_names2: truncating name lookup list to %d\n", num_entries)); } - - /* Probably the lookup_level is some sort of bitmask. */ - if (q_u->lookup_level == 1) { - flags = LOOKUP_NAME_ALL; - } + + flags = lsa_lookup_level_to_flags(q_u->lookup_level); ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); if (ref == NULL) { -- cgit From e3efe7cd7e11be5a78ddce9a49316b516ab81ba3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 17 Dec 2007 18:00:43 -0800 Subject: More static fstring elimination. Jeremy. (This used to be commit b4dfec09e89428cac9b21a94ce4d24e60d4a54f4) --- source3/rpc_server/srv_svcctl_nt.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 7d81033264..5316d399b9 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -346,8 +346,8 @@ WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); - display_name = svcctl_lookup_dispname( service, p->pipe_user.nt_user_token ); - init_svcctl_r_get_display_name( r_u, display_name ); + display_name = svcctl_lookup_dispname(p->mem_ctx, service, p->pipe_user.nt_user_token ); + init_svcctl_r_get_display_name( r_u, display_name ? display_name : ""); return WERR_OK; } @@ -394,8 +394,8 @@ static int enumerate_status( TALLOC_CTX *ctx, ENUM_SERVICES_STATUS **status, NT_ for ( i=0; iservice_status( svcctl_ops[i].name, &st[i].status ); } @@ -688,16 +688,16 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO { SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); uint32 buffer_size; - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) - return WERR_BADFID; - + return WERR_BADFID; + if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_CONFIG) ) return WERR_ACCESS_DENIED; - - /* we have to set the outgoing buffer size to the same as the + + /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); @@ -708,12 +708,12 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO { SERVICE_DESCRIPTION desc_buf; const char *description; - - description = svcctl_lookup_description( info->name, p->pipe_user.nt_user_token ); - + + description = svcctl_lookup_description(p->mem_ctx, info->name, p->pipe_user.nt_user_token ); + ZERO_STRUCTP( &desc_buf ); - init_service_description_buffer( &desc_buf, description ); + init_service_description_buffer( &desc_buf, description ? description : ""); svcctl_io_service_description( "", &desc_buf, &r_u->buffer, 0 ); buffer_size = svcctl_sizeof_service_description( &desc_buf ); @@ -737,7 +737,7 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO default: return WERR_UNKNOWN_LEVEL; } - + buffer_size += buffer_size % 4; r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size; -- cgit From e518e19bc0000019f131354f55e9f5b55f6a2c5e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 19 Dec 2007 15:02:59 +0100 Subject: Remove Get_Pwnam and its associated static variable All callers are replaced by Get_Pwnam_alloc (This used to be commit 735f59315497113aebadcf9ad387e3dbfffa284a) --- source3/rpc_server/srv_samr_nt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index cc4b4f330f..1d69cb320e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3325,7 +3325,8 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, return NT_STATUS_ACCESS_DENIED; } - if ((passwd = Get_Pwnam(pdb_get_username(pwd))) == NULL) { + passwd = Get_Pwnam_alloc(pwd, pdb_get_username(pwd)); + if (passwd == NULL) { DEBUG(1, ("chgpasswd: Username does not exist in system !?!\n")); } @@ -3333,6 +3334,7 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, TALLOC_FREE(pwd); return NT_STATUS_ACCESS_DENIED; } + TALLOC_FREE(passwd); } } @@ -3406,7 +3408,8 @@ static bool set_user_info_pw(uint8 *pass, struct samu *pwd) return False; } - if ((passwd = Get_Pwnam(pdb_get_username(pwd))) == NULL) { + passwd = Get_Pwnam_alloc(pwd, pdb_get_username(pwd)); + if (passwd == NULL) { DEBUG(1, ("chgpasswd: Username does not exist in system !?!\n")); } @@ -3414,6 +3417,7 @@ static bool set_user_info_pw(uint8 *pass, struct samu *pwd) TALLOC_FREE(pwd); return False; } + TALLOC_FREE(passwd); } } -- cgit From 233eb0e560acb26f8706fd3ab96d4c6379458414 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 5 Dec 2007 09:53:10 +0100 Subject: Change the prototype of the vfs function get_nt_acl(). Up to now, get_nt_acl() took a files_struct pointer (fsp) and a file name. All the underlying functions should need and now do need (after the previous preparatory work), is a connection_struct and a file name. The connection_struct is already there in the vfs_handle passed to the vfs functions. So the files_struct argument can be eliminated. This eliminates the need of calling open_file_stat in a couple of places to produce the fsp needed. Michael (This used to be commit b5f600fab53c9d159a958c59795db3ba4a8acc63) --- source3/rpc_server/srv_srvsvc_nt.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 125ccb4752..43f57a0109 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2089,7 +2089,6 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC char *filename_in = NULL; char *filename = NULL; char *qualname = NULL; - files_struct *fsp = NULL; SMB_STRUCT_STAT st; NTSTATUS nt_status; struct current_user user; @@ -2149,25 +2148,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC goto error_exit; } - nt_status = open_file_stat(conn, NULL, filename, &st, &fsp); - /* Perhaps it is a directory */ - if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) { - nt_status = open_directory(conn, NULL, filename, &st, - READ_CONTROL_ACCESS, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_OPEN, - 0, - FILE_ATTRIBUTE_DIRECTORY, - NULL, &fsp); - } - - if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to open file %s\n", filename)); - r_u->status = ntstatus_to_werror(nt_status); - goto error_exit; - } - - nt_status = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, + nt_status = SMB_VFS_GET_NT_ACL(conn, filename, (OWNER_SECURITY_INFORMATION |GROUP_SECURITY_INFORMATION |DACL_SECURITY_INFORMATION), &psd); @@ -2188,17 +2169,12 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC psd->dacl->revision = (uint16) NT4_ACL_REVISION; - close_file(fsp, NORMAL_CLOSE); unbecome_user(); close_cnum(conn, user.vuid); return r_u->status; error_exit: - if(fsp) { - close_file(fsp, NORMAL_CLOSE); - } - if (became_user) unbecome_user(); -- cgit From addf598cde41d17ad4cf497a64b9a2b27e4028c5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 20 Dec 2007 22:17:16 +0100 Subject: Some C++ warnings (This used to be commit 5ab82d4f574f2a2e2761e9e414c66a70aeffb05d) --- source3/rpc_server/srv_dfs_nt.c | 2 +- source3/rpc_server/srv_srvsvc_nt.c | 2 +- source3/rpc_server/srv_winreg_nt.c | 2 +- source3/rpc_server/srv_wkssvc_nt.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 8a1cdedb4f..690ddd60d6 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -34,7 +34,7 @@ void _dfs_GetManagerVersion(pipes_struct *p, struct dfs_GetManagerVersion *r) if (lp_host_msdfs()) { *r->out.version = DFS_MANAGER_VERSION_NT4; } else { - *r->out.version = 0; + *r->out.version = (enum dfs_ManagerVersion)0; } } diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 43f57a0109..3cc2472116 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2167,7 +2167,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC r_u->size_secdesc = sd_size; r_u->sec_desc = psd; - psd->dacl->revision = (uint16) NT4_ACL_REVISION; + psd->dacl->revision = NT4_ACL_REVISION; unbecome_user(); close_cnum(conn, user.vuid); diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 873224085c..7dd5268088 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -234,7 +234,7 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct winreg_QueryValue *r) if ( !regkey ) return WERR_BADFID; - *r->out.value_length = *r->out.type = 0; + *r->out.value_length = *r->out.type = REG_NONE; DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->key->name)); DEBUG(7,("_reg_info: policy key type = [%08x]\n", regkey->key->type)); diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 1e43b5ae99..d9d2df344a 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -32,7 +32,7 @@ static void create_wks_info_100(struct wkssvc_NetWkstaInfo100 *info100) { - info100->platform_id = 0x000001f4; /* unknown */ + info100->platform_id = PLATFORM_ID_NT; /* unknown */ info100->version_major = lp_major_announce_version(); info100->version_minor = lp_minor_announce_version(); -- cgit From 99b86e4a266b99634f6a65015f6df115c421d3e5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 20 Dec 2007 22:27:01 +0100 Subject: Some C++ fixes (This used to be commit 5c392c4c6e277a24d0d477902dc7856b2b46ee53) --- source3/rpc_server/srv_lsa_nt.c | 4 +++- source3/rpc_server/srv_samr_nt.c | 4 +++- source3/rpc_server/srv_svcctl_nt.c | 4 +++- source3/rpc_server/srv_winreg_nt.c | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index a289196f5f..1b78772a79 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -463,7 +463,9 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s if((psa = make_sec_acl(mem_ctx, NT4_ACL_REVISION, 3, ace)) == NULL) return NT_STATUS_NO_MEMORY; - if((*sd = make_sec_desc(mem_ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, &adm_sid, NULL, NULL, psa, sd_size)) == NULL) + if((*sd = make_sec_desc(mem_ctx, SECURITY_DESCRIPTOR_REVISION_1, + SEC_DESC_SELF_RELATIVE, &adm_sid, NULL, NULL, + psa, sd_size)) == NULL) return NT_STATUS_NO_MEMORY; return NT_STATUS_OK; diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 1d69cb320e..01ce932afa 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -149,7 +149,9 @@ static NTSTATUS make_samr_object_sd( TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) == NULL) return NT_STATUS_NO_MEMORY; - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, psa, sd_size)) == NULL) + if ((*psd = make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1, + SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, + psa, sd_size)) == NULL) return NT_STATUS_NO_MEMORY; return NT_STATUS_OK; diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 5316d399b9..3f5cf03abb 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -162,7 +162,9 @@ static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx ) if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) return NULL; - if ( !(sd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, acl, &sd_size)) ) + if ( !(sd = make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1, + SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL, + acl, &sd_size)) ) return NULL; return sd; diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 7dd5268088..74ee94cf75 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -934,7 +934,9 @@ static WERROR make_default_reg_sd( TALLOC_CTX *ctx, SEC_DESC **psd ) if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 2, ace)) == NULL) return WERR_NOMEM; - if ((*psd = make_sec_desc(ctx, SEC_DESC_REVISION, SEC_DESC_SELF_RELATIVE, &owner_sid, NULL, NULL, psa, &sd_size)) == NULL) + if ((*psd = make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1, + SEC_DESC_SELF_RELATIVE, &owner_sid, NULL, + NULL, psa, &sd_size)) == NULL) return WERR_NOMEM; return WERR_OK; -- cgit From 5799dcdfed85c6e0d481b6ce5a6ddead576763e9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 12 Dec 2007 16:12:14 +0100 Subject: Add _wkssvc_NetrJoinDomain2() server. Guenther (This used to be commit 9b0423e7d918b7b3837ca4ebf997edd80d4da6de) --- source3/rpc_server/srv_wkssvc_nt.c | 69 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index d9d2df344a..e60dca61c7 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -22,6 +22,8 @@ /* This is the implementation of the wks interface. */ #include "includes.h" +#include "libnet/libnet_join.h" +#include "libnet/libnet_proto.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV @@ -284,9 +286,70 @@ WERROR _wkssvc_NetrGetJoinableOus(pipes_struct *p, struct wkssvc_NetrGetJoinable WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r) { - /* FIXME: Add implementation code here */ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + struct libnet_JoinCtx *j = NULL; + char *pwd = NULL; + char *admin_domain = NULL; + char *admin_account = NULL; + WERROR werr; + NTSTATUS status; + struct nt_user_token *token = p->pipe_user.nt_user_token; + struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + + if (!r->in.domain_name) { + return WERR_INVALID_PARAM; + } + + if (!user_has_privileges(token, &se_machine_account) && + !nt_token_check_domain_rid(token, DOMAIN_GROUP_RID_ADMINS) && + !nt_token_check_domain_rid(token, BUILTIN_ALIAS_RID_ADMINS)) { + return WERR_ACCESS_DENIED; + } + + werr = decode_wkssvc_join_password_buffer(p->mem_ctx, + r->in.encrypted_password, + &p->session_key, + &pwd); + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + + werr = libnet_init_JoinCtx(p->mem_ctx, &j); + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + + split_domain_user(p->mem_ctx, + r->in.admin_account, + &admin_domain, + &admin_account); + + status = DsGetDcName(p->mem_ctx, + NULL, + r->in.domain_name, + NULL, + NULL, + DS_DIRECTORY_SERVICE_REQUIRED | + DS_WRITABLE_REQUIRED | + DS_RETURN_DNS_NAME, + &info); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + j->in.server_name = info->domain_controller_name; + j->in.domain_name = r->in.domain_name; + j->in.account_ou = r->in.account_ou; + j->in.join_flags = r->in.join_flags; + + j->in.admin_account = admin_account; + j->in.password = pwd; + j->in.modify_config = true; + + become_root(); + werr = libnet_Join(p->mem_ctx, j); + unbecome_root(); + + return werr; } /******************************************************************** -- cgit From cdb51f3bc31892e80e5a34204b427660edbd7e63 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 21 Dec 2007 16:44:52 +0100 Subject: Deactive remote join code server side until some last issues are resolved. Guenther (This used to be commit 1489870f05695a929902264eb9b95eab886bdaa6) --- source3/rpc_server/srv_wkssvc_nt.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index e60dca61c7..b30a7f8792 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -286,6 +286,7 @@ WERROR _wkssvc_NetrGetJoinableOus(pipes_struct *p, struct wkssvc_NetrGetJoinable WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r) { +#if 0 struct libnet_JoinCtx *j = NULL; char *pwd = NULL; char *admin_domain = NULL; @@ -350,6 +351,9 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r unbecome_root(); return werr; +#endif + p->rng_fault_state = True; + return WERR_NOT_SUPPORTED; } /******************************************************************** -- cgit From e9b8eb14468c37e772476f6d32188d6e85c2083c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 27 Dec 2007 21:30:15 +0100 Subject: Remove a silly static (This used to be commit ef75dcc9ffda85d77c8f22d0db702efbf8e642ed) --- source3/rpc_server/srv_srvsvc_nt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 3cc2472116..842a28c776 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -870,13 +870,11 @@ static void init_srv_sess_info_0(pipes_struct *p, SRV_SESS_INFO_0 *ss0, uint32 * /******************************************************************* ********************************************************************/ -/* global needed to make use of the share_mode_forall() callback */ -static struct sess_file_count s_file_cnt; - static void sess_file_fn( const struct share_mode_entry *e, - const char *sharepath, const char *fname, void *state ) + const char *sharepath, const char *fname, + void *data ) { - struct sess_file_count *sess = &s_file_cnt; + struct sess_file_count *sess = (struct sess_file_count *)data; if ( procid_equal(&e->pid, &sess->pid) && (sess->uid == e->uid) ) { sess->count++; @@ -890,11 +888,13 @@ static void sess_file_fn( const struct share_mode_entry *e, static int net_count_files( uid_t uid, struct server_id pid ) { + struct sess_file_count s_file_cnt; + s_file_cnt.count = 0; s_file_cnt.uid = uid; s_file_cnt.pid = pid; - share_mode_forall( sess_file_fn, NULL ); + share_mode_forall( sess_file_fn, &s_file_cnt ); return s_file_cnt.count; } -- cgit From 7cbdb48475b0340154fad60cb4b7cc53dc2bbcfd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 29 Dec 2007 23:00:49 +0100 Subject: Remove tiny code duplication ndr_size_security_descriptor does the same as sec_desc_size (This used to be commit bc3bd7a8e7c6e9e27acb195c86abb92c0f53112f) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- source3/rpc_server/srv_svcctl_nt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 842a28c776..01e5cf2cda 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2159,7 +2159,7 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC goto error_exit; } - sd_size = sec_desc_size(psd); + sd_size = ndr_size_security_descriptor(psd, 0); r_u->ptr_response = 1; r_u->size_response = sd_size; diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 3f5cf03abb..ac45d8bf75 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -813,7 +813,7 @@ WERROR _svcctl_query_service_sec( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_SEC *q if ( !(sec_desc = svcctl_get_secdesc( p->mem_ctx, info->name, get_root_nt_token() )) ) return WERR_NOMEM; - r_u->needed = sec_desc_size( sec_desc ); + r_u->needed = ndr_size_security_descriptor( sec_desc, 0 ); if ( r_u->needed > q_u->buffer_size ) { ZERO_STRUCTP( &r_u->buffer ); -- cgit From 5ddb2abf7611a93960056075ea56f992329c3678 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 6 Jan 2008 16:15:45 +0100 Subject: Some more talloc_tos() (This used to be commit 444e35e7df1f13fc285183da8fb41b30ad99a3fa) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 01e5cf2cda..1b877ee5b4 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -167,7 +167,7 @@ static void enum_file_fn( const struct share_mode_entry *e, ZERO_STRUCT( fsp ); fsp.file_id = e->id; - if ( (brl = brl_get_locks(NULL,&fsp)) != NULL ) { + if ( (brl = brl_get_locks(talloc_tos(), &fsp)) != NULL ) { num_locks = brl->num_locks; TALLOC_FREE(brl); } -- cgit From d9ee831d0ee7a950a7c8095182f1174026a56ad9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 11 Jan 2008 22:47:25 -0800 Subject: Fix CID 524 - reference before allocation fail null check. Jeremy. (This used to be commit a5cd3c9b65538588a6c982c6d20022e7476cf3de) --- source3/rpc_server/srv_dfs_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 690ddd60d6..29538a304f 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -133,10 +133,10 @@ WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) altpath = talloc_asprintf(ctx, "%s\\%s", r->in.servername, r->in.sharename); - strlower_m(altpath); if (!altpath) { return WERR_NOMEM; } + strlower_m(altpath); DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n", r->in.dfs_entry_path, r->in.servername, r->in.sharename)); } -- cgit From 58d2f1ff81ce6af8337824427a88f6d035488edb Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 13 Jan 2008 12:52:25 +0100 Subject: Fix Compiler warnings by including the proper header. Michael (This used to be commit edaf52a301a38824c8beb30c49fba27c8fb0461a) --- source3/rpc_server/srv_wkssvc_nt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index b30a7f8792..849ec9c4eb 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -22,8 +22,7 @@ /* This is the implementation of the wks interface. */ #include "includes.h" -#include "libnet/libnet_join.h" -#include "libnet/libnet_proto.h" +#include "libnet/libnet.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -- cgit From 41c72bd80465122d836fe19a784982bf5cb82cdd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 16 Jan 2008 11:02:52 +0100 Subject: Fix (non-activated) _wkssvc_NetrJoinDomain2 server code. Guenther (This used to be commit dea64a0d886919dfd5bcc550cb36deabe4ec010d) --- source3/rpc_server/srv_wkssvc_nt.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 849ec9c4eb..de2e33732d 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -287,7 +287,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r { #if 0 struct libnet_JoinCtx *j = NULL; - char *pwd = NULL; + char *cleartext_pwd = NULL; char *admin_domain = NULL; char *admin_account = NULL; WERROR werr; @@ -308,12 +308,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r werr = decode_wkssvc_join_password_buffer(p->mem_ctx, r->in.encrypted_password, &p->session_key, - &pwd); - if (!W_ERROR_IS_OK(werr)) { - return werr; - } - - werr = libnet_init_JoinCtx(p->mem_ctx, &j); + &cleartext_pwd); if (!W_ERROR_IS_OK(werr)) { return werr; } @@ -323,7 +318,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r &admin_domain, &admin_account); - status = DsGetDcName(p->mem_ctx, + status = dsgetdcname(p->mem_ctx, NULL, r->in.domain_name, NULL, @@ -336,14 +331,18 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r return ntstatus_to_werror(status); } - j->in.server_name = info->domain_controller_name; + werr = libnet_init_JoinCtx(p->mem_ctx, &j); + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + + j->in.dc_name = info->domain_controller_name; j->in.domain_name = r->in.domain_name; j->in.account_ou = r->in.account_ou; j->in.join_flags = r->in.join_flags; - - j->in.admin_account = admin_account; - j->in.password = pwd; - j->in.modify_config = true; + j->in.admin_account = admin_account; + j->in.admin_password = cleartext_pwd; + j->in.modify_config = true; become_root(); werr = libnet_Join(p->mem_ctx, j); -- cgit From 587a2dbf8d000640109c2b36a924cd4c2694897f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 16 Jan 2008 16:31:49 +0100 Subject: Merge lsarpc.idl from samba4 and rerun make idl. Guenther (This used to be commit d9c8a2271d5d4ff845f1fe5986a2c63d79c41415) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 1b78772a79..20cafbd0af 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -2583,7 +2583,7 @@ NTSTATUS _lsa_LSARUNREGISTERAUDITEVENT(pipes_struct *p, struct lsa_LSARUNREGISTE return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LSARQUERYFORESTTRUSTINFORMATION(pipes_struct *p, struct lsa_LSARQUERYFORESTTRUSTINFORMATION *r) +NTSTATUS _lsa_lsaRQueryForestTrustInformation(pipes_struct *p, struct lsa_lsaRQueryForestTrustInformation *r) { p->rng_fault_state = True; return NT_STATUS_NOT_IMPLEMENTED; -- cgit From 00f3df3c131ac6054e1a8d0565cd87ab8a49265b Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 17 Jan 2008 01:47:00 +0100 Subject: Convert sync_eventlog_params() to use reg_api instead of reg_frontend. This is a step towards untangling the registry. All places should use reg_api.c, reg_frontend should actually more appropriately be named reg_backend_dispatcher and hidden from callers. :-) Michael (This used to be commit 92e95fe58500dc8bf89bb43c1d65559702363767) --- source3/rpc_server/srv_eventlog_nt.c | 46 ++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 3c9c835bad..0ea34e54ad 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -423,12 +423,12 @@ static bool sync_eventlog_params( EVENTLOG_INFO *info ) char *path = NULL; uint32 uiMaxSize; uint32 uiRetention; - REGISTRY_KEY *keyinfo; - REGISTRY_VALUE *val; - REGVAL_CTR *values; + struct registry_key *key; + struct registry_value *value; WERROR wresult; char *elogname = info->logname; TALLOC_CTX *ctx = talloc_tos(); + bool ret = false; DEBUG( 4, ( "sync_eventlog_params with %s\n", elogname ) ); @@ -451,36 +451,42 @@ static bool sync_eventlog_params( EVENTLOG_INFO *info ) return false; } - wresult = regkey_open_internal( NULL, &keyinfo, path, - get_root_nt_token( ), REG_KEY_READ ); + wresult = reg_open_path(ctx, path, REG_KEY_READ, get_root_nt_token(), + &key); if ( !W_ERROR_IS_OK( wresult ) ) { DEBUG( 4, ( "sync_eventlog_params: Failed to open key [%s] (%s)\n", path, dos_errstr( wresult ) ) ); - return False; + return false; } - if ( !( values = TALLOC_ZERO_P( keyinfo, REGVAL_CTR ) ) ) { - TALLOC_FREE( keyinfo ); - DEBUG( 0, ( "control_eventlog_hook: talloc() failed!\n" ) ); - - return False; + wresult = reg_queryvalue(key, key, "Retention", &value); + if (!W_ERROR_IS_OK(wresult)) { + DEBUG(4, ("Failed to query value \"Retention\": %s\n", + dos_errstr(wresult))); + ret = false; + goto done; } - fetch_reg_values( keyinfo, values ); - - if ( ( val = regval_ctr_getvalue( values, "Retention" ) ) != NULL ) - uiRetention = IVAL( regval_data_p( val ), 0 ); + uiRetention = value->v.dword; - if ( ( val = regval_ctr_getvalue( values, "MaxSize" ) ) != NULL ) - uiMaxSize = IVAL( regval_data_p( val ), 0 ); - - TALLOC_FREE( keyinfo ); + wresult = reg_queryvalue(key, key, "MaxSize", &value); + if (!W_ERROR_IS_OK(wresult)) { + DEBUG(4, ("Failed to query value \"MaxSize\": %s\n", + dos_errstr(wresult))); + ret = false; + goto done; + } + uiMaxSize = value->v.dword; tdb_store_int32( ELOG_TDB_CTX(info->etdb), EVT_MAXSIZE, uiMaxSize ); tdb_store_int32( ELOG_TDB_CTX(info->etdb), EVT_RETENTION, uiRetention ); - return True; + ret = true; + +done: + TALLOC_FREE(ctx); + return true; } /******************************************************************** -- cgit From 7bfdcbcfdca7c554060808d9b526f6f2fd7472fa Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 17 Jan 2008 11:06:32 +0100 Subject: Use reg_[gs]etkeysecurity() instead of regkey_[gs]et_secdes(). Rationale: Use reg_api instead of backend functions. Michael (This used to be commit f986a708be15dd9b9fc28b9862f64f2d0f94accc) --- source3/rpc_server/srv_winreg_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 74ee94cf75..939bf723d2 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -1115,7 +1115,7 @@ WERROR _winreg_GetKeySecurity(pipes_struct *p, struct winreg_GetKeySecurity *r) if ( !(key->key->access_granted & STD_RIGHT_READ_CONTROL_ACCESS) ) return WERR_ACCESS_DENIED; - err = regkey_get_secdesc(p->mem_ctx, key->key, &secdesc); + err = reg_getkeysecurity(p->mem_ctx, key, &secdesc); if (!W_ERROR_IS_OK(err)) { return err; } @@ -1161,7 +1161,7 @@ WERROR _winreg_SetKeySecurity(pipes_struct *p, struct winreg_SetKeySecurity *r) return err; } - return regkey_set_secdesc(key->key, secdesc); + return reg_setkeysecurity(key, secdesc); } /******************************************************************* -- cgit From 32a8e740785147256c008730a69ae6d60a294884 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 17 Jan 2008 11:22:01 +0100 Subject: Add a reg_getversion() function to reg_api and use it in srv_winreg_nt.c. Michael (This used to be commit 903223b160eef6ba6ff19a8bfef19e5fe7008631) --- source3/rpc_server/srv_winreg_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 939bf723d2..92c178042f 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -370,9 +370,7 @@ WERROR _winreg_GetVersion(pipes_struct *p, struct winreg_GetVersion *r) if ( !regkey ) return WERR_BADFID; - *r->out.version = 0x00000005; /* Windows 2000 registry API version */ - - return WERR_OK; + return reg_getversion(r->out.version); } -- cgit From a92eb76688600efbf4a4056c2543f348e2fee8aa Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 17 Jan 2008 10:24:34 +0100 Subject: Finally enable pidl generated SAMR & NETLOGON headers and clients. Guenther (This used to be commit f7100156a7df7ac3ae84e45a47153b38d9375215) --- source3/rpc_server/srv_netlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 218ce73444..904ee17f51 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -1062,7 +1062,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, 0, /* bad_pw_count */ num_gids, /* uint32 num_groups */ gids , /* DOM_GID *gids */ - LOGON_EXTRA_SIDS, /* uint32 user_flgs (?) */ + NETLOGON_EXTRA_SIDS, /* uint32 user_flgs (?) */ pdb_get_acct_ctrl(sampw), server_info->user_session_key.length ? user_session_key : NULL, server_info->lm_session_key.length ? lm_session_key : NULL, -- cgit From 805caafd44cbc5fff49711b1a15fb64cc99f3ad3 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Sat, 19 Jan 2008 02:12:35 +0100 Subject: util_str: Don't return memory from talloc_tos(), use mem_ctx instead. (This used to be commit ab0ee6e9a6a9eee317228f0c2bde254ad9a59b85) --- source3/rpc_server/srv_samr_util.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index bde7936343..c8f732153c 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -44,16 +44,16 @@ void copy_id20_to_sam_passwd(struct samu *to, SAM_USER_INFO_20 *from) char *new_string; DATA_BLOB mung; - if (from == NULL || to == NULL) + if (from == NULL || to == NULL) return; - + if (from->hdr_munged_dial.buffer) { old_string = pdb_get_munged_dial(to); mung.length = from->hdr_munged_dial.uni_str_len; mung.data = (uint8 *) from->uni_munged_dial.buffer; mung.free = NULL; new_string = (mung.length == 0) ? - NULL : base64_encode_data_blob(mung); + NULL : base64_encode_data_blob(talloc_tos(), mung); DEBUG(10,("INFO_20 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED_NC(old_string,new_string)) pdb_set_munged_dial(to , new_string, PDB_CHANGED); @@ -196,7 +196,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) mung.data = (uint8 *) from->uni_munged_dial.buffer; mung.free = NULL; newstr = (mung.length == 0) ? - NULL : base64_encode_data_blob(mung); + NULL : base64_encode_data_blob(talloc_tos(), mung); DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); if (STRING_CHANGED_NC(old_string,newstr)) pdb_set_munged_dial(to , newstr, PDB_CHANGED); @@ -421,7 +421,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) mung.data = (uint8 *) from->uni_munged_dial.buffer; mung.free = NULL; newstr = (mung.length == 0) ? - NULL : base64_encode_data_blob(mung); + NULL : base64_encode_data_blob(talloc_tos(), mung); DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); if (STRING_CHANGED_NC(old_string, newstr)) pdb_set_munged_dial(to , newstr, PDB_CHANGED); @@ -633,7 +633,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) mung.data = (uint8 *) from->uni_munged_dial.buffer; mung.free = NULL; newstr = (mung.length == 0) ? - NULL : base64_encode_data_blob(mung); + NULL : base64_encode_data_blob(talloc_tos(), mung); DEBUG(10,("INFO_25 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); if (STRING_CHANGED_NC(old_string,newstr)) pdb_set_munged_dial(to , newstr, PDB_CHANGED); -- cgit From 05ff7fd46e19d9c1aab8524495c9b926290927c7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 25 Jan 2008 13:26:10 +0100 Subject: Use generated DSSETUP client & server rpc functions and remove the hand-written ones. Guenther (This used to be commit d5ebfccebb1f1b56b45673a506fcdb414103c43b) --- source3/rpc_server/srv_dssetup_nt.c | 220 ++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_lsa_ds.c | 85 -------------- source3/rpc_server/srv_lsa_ds_nt.c | 130 --------------------- source3/rpc_server/srv_pipe.c | 4 +- 4 files changed, 222 insertions(+), 217 deletions(-) create mode 100644 source3/rpc_server/srv_dssetup_nt.c delete mode 100644 source3/rpc_server/srv_lsa_ds.c delete mode 100644 source3/rpc_server/srv_lsa_ds_nt.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dssetup_nt.c b/source3/rpc_server/srv_dssetup_nt.c new file mode 100644 index 0000000000..ea535a3375 --- /dev/null +++ b/source3/rpc_server/srv_dssetup_nt.c @@ -0,0 +1,220 @@ +/* + * Unix SMB/CIFS implementation. + * RPC Pipe client / server routines + * Copyright (C) Andrew Tridgell 1992-1997. + * Copyright (C) Luke Kenneth Casson Leighton 1996-1997. + * Copyright (C) Paul Ashton 1997. + * Copyright (C) Jeremy Allison 2001. + * Copyright (C) Gerald Carter 2002. + * Copyright (C) Guenther Deschner 2008. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include "includes.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_RPC_SRV + +/******************************************************************** + Fill in a dssetup_DsRolePrimaryDomInfoBasic structure + ********************************************************************/ + +static WERROR fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, + struct dssetup_DsRolePrimaryDomInfoBasic **info) +{ + struct dssetup_DsRolePrimaryDomInfoBasic *basic = NULL; + fstring dnsdomain; + + DEBUG(10,("fill_dsrole_dominfo_basic: enter\n")); + + basic = TALLOC_ZERO_P(ctx, struct dssetup_DsRolePrimaryDomInfoBasic); + if (!basic) { + DEBUG(0,("fill_dsrole_dominfo_basic: out of memory\n")); + return WERR_NOMEM; + } + + switch (lp_server_role()) { + case ROLE_STANDALONE: + basic->role = DS_ROLE_STANDALONE_SERVER; + basic->domain = get_global_sam_name(); + break; + case ROLE_DOMAIN_MEMBER: + basic->role = DS_ROLE_MEMBER_SERVER; + basic->domain = lp_workgroup(); + break; + case ROLE_DOMAIN_BDC: + basic->role = DS_ROLE_BACKUP_DC; + basic->domain = get_global_sam_name(); + break; + case ROLE_DOMAIN_PDC: + basic->role = DS_ROLE_PRIMARY_DC; + basic->domain = get_global_sam_name(); + break; + } + + if (secrets_fetch_domain_guid(lp_workgroup(), &basic->domain_guid)) { + basic->flags |= DS_ROLE_PRIMARY_DOMAIN_GUID_PRESENT; + } + + /* fill in some additional fields if we are a member of an AD domain */ + + if (lp_security() == SEC_ADS) { + fstrcpy(dnsdomain, lp_realm()); + strlower_m(dnsdomain); + basic->dns_domain = dnsdomain; + + /* FIXME!! We really should fill in the correct forest + name. Should get this information from winbindd. */ + basic->forest = dnsdomain; + } else { + /* security = domain should not fill in the dns or + forest name */ + basic->dns_domain = NULL; + basic->forest = NULL; + } + + *info = basic; + + return WERR_OK; +} + +/******************************************************************** + Implement the _dssetup_DsRoleGetPrimaryDomainInformation() call + ********************************************************************/ + +WERROR _dssetup_DsRoleGetPrimaryDomainInformation(pipes_struct *p, + struct dssetup_DsRoleGetPrimaryDomainInformation *r) +{ + WERROR werr = WERR_OK; + + switch (r->in.level) { + + case DS_ROLE_BASIC_INFORMATION: { + struct dssetup_DsRolePrimaryDomInfoBasic *basic = NULL; + werr = fill_dsrole_dominfo_basic(p->mem_ctx, &basic); + if (W_ERROR_IS_OK(werr)) { + r->out.info->basic = *basic; + } + break; + } + default: + DEBUG(0,("_dssetup_DsRoleGetPrimaryDomainInformation: " + "Unknown info level [%d]!\n", r->in.level)); + werr = WERR_UNKNOWN_LEVEL; + } + + return werr; +} + +/**************************************************************** +****************************************************************/ + +WERROR _dssetup_DsRoleDnsNameToFlatName(pipes_struct *p, + struct dssetup_DsRoleDnsNameToFlatName *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _dssetup_DsRoleDcAsDc(pipes_struct *p, + struct dssetup_DsRoleDcAsDc *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _dssetup_DsRoleDcAsReplica(pipes_struct *p, + struct dssetup_DsRoleDcAsReplica *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _dssetup_DsRoleDemoteDc(pipes_struct *p, + struct dssetup_DsRoleDemoteDc *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _dssetup_DsRoleGetDcOperationProgress(pipes_struct *p, + struct dssetup_DsRoleGetDcOperationProgress *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _dssetup_DsRoleGetDcOperationResults(pipes_struct *p, + struct dssetup_DsRoleGetDcOperationResults *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _dssetup_DsRoleCancel(pipes_struct *p, + struct dssetup_DsRoleCancel *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _dssetup_DsRoleServerSaveStateForUpgrade(pipes_struct *p, + struct dssetup_DsRoleServerSaveStateForUpgrade *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _dssetup_DsRoleUpgradeDownlevelServer(pipes_struct *p, + struct dssetup_DsRoleUpgradeDownlevelServer *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _dssetup_DsRoleAbortDownlevelServerUpgrade(pipes_struct *p, + struct dssetup_DsRoleAbortDownlevelServerUpgrade *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + diff --git a/source3/rpc_server/srv_lsa_ds.c b/source3/rpc_server/srv_lsa_ds.c deleted file mode 100644 index 55baa40261..0000000000 --- a/source3/rpc_server/srv_lsa_ds.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Gerald Carter 2003 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ - -/* This is the interface for the registry functions. */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -/******************************************************************* - ********************************************************************/ - -static bool api_dsrole_get_primary_dominfo(pipes_struct *p) -{ - DS_Q_GETPRIMDOMINFO q_u; - DS_R_GETPRIMDOMINFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the request */ - if ( !ds_io_q_getprimdominfo("", &q_u, data, 0) ) - return False; - - /* construct reply. */ - r_u.status = _dsrole_get_primary_dominfo( p, &q_u, &r_u ); - - if ( !ds_io_r_getprimdominfo("", &r_u, rdata, 0) ) - return False; - - return True; -} - -/******************************************************************* - stub functions for unimplemented RPC -*******************************************************************/ - -static bool api_dsrole_stub( pipes_struct *p ) -{ - DEBUG(0,("api_dsrole_stub: Hmmm....didn't know this RPC existed...\n")); - - return False; -} - - -/******************************************************************* - array of \PIPE\lsass (new windows 2000 UUID) operations -********************************************************************/ -static struct api_struct api_lsa_ds_cmds[] = { - { "DS_NOP", DS_NOP, api_dsrole_stub }, - { "DS_GETPRIMDOMINFO", DS_GETPRIMDOMINFO, api_dsrole_get_primary_dominfo } - -}; - -void lsa_ds_get_pipe_fns( struct api_struct **fns, int *n_fns ) -{ - *fns = api_lsa_ds_cmds; - *n_fns = sizeof(api_lsa_ds_cmds) / sizeof(struct api_struct); -} - - -NTSTATUS rpc_lsa_ds_init(void) -{ - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "lsa_ds", "lsa_ds", api_lsa_ds_cmds, - sizeof(api_lsa_ds_cmds) / sizeof(struct api_struct)); -} diff --git a/source3/rpc_server/srv_lsa_ds_nt.c b/source3/rpc_server/srv_lsa_ds_nt.c deleted file mode 100644 index 994b3cccca..0000000000 --- a/source3/rpc_server/srv_lsa_ds_nt.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997. - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997. - * Copyright (C) Paul Ashton 1997. - * Copyright (C) Jeremy Allison 2001. - * Copyright (C) Gerald Carter 2002. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ - -/* Implementation of registry functions. */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -/******************************************************************** - Fill in a DS_DOMINFO_CTR structure - ********************************************************************/ - -static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN_INFO_BASIC **info) -{ - DSROLE_PRIMARY_DOMAIN_INFO_BASIC *basic; - const char *netbios_domain = ""; - fstring dnsdomain; - - DEBUG(10,("fill_dsrole_dominfo_basic: enter\n")); - - if ( !(basic = TALLOC_ZERO_P(ctx, DSROLE_PRIMARY_DOMAIN_INFO_BASIC)) ) { - DEBUG(0,("fill_dsrole_dominfo_basic: FATAL error! talloc_xero() failed\n")); - return NT_STATUS_NO_MEMORY; - } - - switch ( lp_server_role() ) { - case ROLE_STANDALONE: - basic->machine_role = DSROLE_STANDALONE_SRV; - basic->netbios_ptr = 1; - netbios_domain = get_global_sam_name(); - break; - case ROLE_DOMAIN_MEMBER: - basic->netbios_ptr = 1; - netbios_domain = lp_workgroup(); - basic->machine_role = DSROLE_DOMAIN_MEMBER_SRV; - break; - case ROLE_DOMAIN_BDC: - basic->netbios_ptr = 1; - netbios_domain = get_global_sam_name(); - basic->machine_role = DSROLE_BDC; - break; - case ROLE_DOMAIN_PDC: - basic->netbios_ptr = 1; - netbios_domain = get_global_sam_name(); - basic->machine_role = DSROLE_PDC; - break; - } - - /* always set netbios name */ - - init_unistr2( &basic->netbios_domain, netbios_domain, UNI_STR_TERMINATE); - - if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) ) - basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT; - - /* fill in some additional fields if we are a member of an AD domain */ - - if ( lp_security() == SEC_ADS ) { - fstrcpy( dnsdomain, lp_realm() ); - strlower_m( dnsdomain ); - - basic->dnsname_ptr = 1; - init_unistr2( &basic->dns_domain, dnsdomain, UNI_STR_TERMINATE); - - /* FIXME!! We really should fill in the correct forest - name. Should get this information from winbindd. */ - basic->forestname_ptr = 1; - init_unistr2( &basic->forest_domain, dnsdomain, UNI_STR_TERMINATE); - } else { - /* security = domain should not fill in the dns or - forest name */ - basic->dnsname_ptr = 0; - basic->forestname_ptr = 0; - } - - *info = basic; - - return NT_STATUS_OK; -} - -/******************************************************************** - Implement the DsroleGetPrimaryDomainInfo() call - ********************************************************************/ - -NTSTATUS _dsrole_get_primary_dominfo(pipes_struct *p, DS_Q_GETPRIMDOMINFO *q_u, DS_R_GETPRIMDOMINFO *r_u) -{ - NTSTATUS result = NT_STATUS_OK; - uint32 level = q_u->level; - - switch ( level ) { - - case DsRolePrimaryDomainInfoBasic: - r_u->level = DsRolePrimaryDomainInfoBasic; - r_u->ptr = 1; - result = fill_dsrole_dominfo_basic( p->mem_ctx, &r_u->info.basic ); - break; - - default: - DEBUG(0,("_dsrole_get_primary_dominfo: Unsupported info level [%d]!\n", - level)); - result = NT_STATUS_INVALID_LEVEL; - } - - return result; -} - - - diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 5ede0c93f4..06694a2701 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2363,8 +2363,8 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) case PI_LSARPC: lsa_get_pipe_fns( &cmds, &n_cmds ); break; - case PI_LSARPC_DS: - lsa_ds_get_pipe_fns( &cmds, &n_cmds ); + case PI_DSSETUP: + dssetup_get_pipe_fns( &cmds, &n_cmds ); break; case PI_SAMR: samr_get_pipe_fns( &cmds, &n_cmds ); -- cgit From 5ab43ae0d8e66a1fd4c877089df52282367be7dd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 26 Jan 2008 01:39:33 +0100 Subject: Eliminate remote tree of dsgetdcname (which will happen in libnetapi then). Guenther (This used to be commit fd490d236b1fb73a75c457b75128c9b98719418f) --- source3/rpc_server/srv_wkssvc_nt.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index de2e33732d..e0103e6b58 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -319,7 +319,6 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r &admin_account); status = dsgetdcname(p->mem_ctx, - NULL, r->in.domain_name, NULL, NULL, -- cgit From 1a7583dd0b34d5276ee36b69fe7b8d37a701c408 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 29 Jan 2008 15:51:19 +0100 Subject: Remove unused rpc_ds marshalling code that is unused now. Guenther (This used to be commit 153253e14f82fc7078e9cc6f12409e6eda7ee7cb) --- source3/rpc_server/srv_netlog.c | 40 -------------------------------------- source3/rpc_server/srv_netlog_nt.c | 2 +- 2 files changed, 1 insertion(+), 41 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 6d9859a9ae..30ef02bee8 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -335,43 +335,6 @@ static bool api_net_sam_logon_ex(pipes_struct *p) return True; } - -/************************************************************************* - api_ds_enum_dom_trusts: - *************************************************************************/ - -#if 0 /* JERRY */ -static bool api_ds_enum_dom_trusts(pipes_struct *p) -{ - DS_Q_ENUM_DOM_TRUSTS q_u; - DS_R_ENUM_DOM_TRUSTS r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - DEBUG(6,("api_ds_enum_dom_trusts\n")); - - if ( !ds_io_q_enum_domain_trusts("", data, 0, &q_u) ) { - DEBUG(0,("api_ds_enum_domain_trusts: Failed to unmarshall DS_Q_ENUM_DOM_TRUSTS.\n")); - return False; - } - - r_u.status = _ds_enum_dom_trusts(p, &q_u, &r_u); - - if ( !ds_io_r_enum_domain_trusts("", rdata, 0, &r_u) ) { - DEBUG(0,("api_ds_enum_domain_trusts: Failed to marshall DS_R_ENUM_DOM_TRUSTS.\n")); - return False; - } - - DEBUG(6,("api_ds_enum_dom_trusts\n")); - - return True; -} -#endif /* JERRY */ - /******************************************************************* array of \PIPE\NETLOGON operations ********************************************************************/ @@ -387,9 +350,6 @@ static struct api_struct api_net_cmds [] = { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl }, { "NET_SAMLOGON_EX" , NET_SAMLOGON_EX , api_net_sam_logon_ex }, -#if 0 /* JERRY */ - { "DS_ENUM_DOM_TRUSTS", DS_ENUM_DOM_TRUSTS, api_ds_enum_dom_trusts } -#endif /* JERRY */ }; void netlog_get_pipe_fns( struct api_struct **fns, int *n_fns ) diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 904ee17f51..5003af8ce7 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -1130,7 +1130,7 @@ NTSTATUS _net_sam_logon_ex(pipes_struct *p, NET_Q_SAM_LOGON_EX *q_u, NET_R_SAM_L _ds_enum_dom_trusts *************************************************************************/ #if 0 /* JERRY -- not correct */ -NTSTATUS _ds_enum_dom_trusts(pipes_struct *p, DS_Q_ENUM_DOM_TRUSTS *q_u, + NTSTATUS _ds_enum_dom_trusts(pipes_struct *p, DS_Q_ENUM_DOM_TRUSTS *q_u, DS_R_ENUM_DOM_TRUSTS *r_u) { NTSTATUS status = NT_STATUS_OK; -- cgit From 5dcc7f7e614fabb75b989baa064c359cef5f902e Mon Sep 17 00:00:00 2001 From: "Gerald W. Carter" Date: Tue, 29 Jan 2008 15:06:59 -0600 Subject: Fix a return value from sync_eventlog_params() (patch from Volker) (This used to be commit 77085f1a58666ac4314924d18c87d4add0553dba) --- source3/rpc_server/srv_eventlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 0ea34e54ad..7af8219a3e 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -486,7 +486,7 @@ static bool sync_eventlog_params( EVENTLOG_INFO *info ) done: TALLOC_FREE(ctx); - return true; + return ret; } /******************************************************************** -- cgit From cb9029dbf5b4ba5034499eb7dd8e5dd456e0abfe Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jan 2008 16:46:46 +0100 Subject: Fix a memleak (This used to be commit 252c3130697d1b7fd34a5225d83cef4f32e663b2) --- source3/rpc_server/srv_eventlog_lib.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 4e996ee19b..1d902fe215 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -148,7 +148,6 @@ bool make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, int nbytes, reclen, len, Retention, MaxSize; int tresv1, trecnum, timegen, timewr; TDB_DATA key, ret; - TALLOC_CTX *mem_ctx = NULL; time_t current_time, exp_time; /* discard some eventlogs */ @@ -156,10 +155,7 @@ bool make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, /* read eventlogs from oldest_entry -- there can't be any discontinuity in recnos, although records not necessarily guaranteed to have successive times */ /* */ - mem_ctx = talloc_init( "make_way_for_eventlogs" ); /* Homage to BPG */ - if ( mem_ctx == NULL ) - return False; /* can't allocate memory indicates bigger problems */ /* lock */ tdb_lock_bystring_with_timeout( the_tdb, EVT_NEXT_RECORD, 1 ); /* read */ -- cgit From c0aa988e83c16ac7fe9d1a9d6cb51fa989aab1e9 Mon Sep 17 00:00:00 2001 From: "Gerald W. Carter" Date: Tue, 29 Jan 2008 15:08:37 -0600 Subject: Make make_way_for_eventlogs() static (This used to be commit cb6531965b2baab320123d4301ab851c6e22aa58) --- source3/rpc_server/srv_eventlog_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 1d902fe215..269e2f318e 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -140,8 +140,8 @@ int elog_tdb_size( TDB_CONTEXT * tdb, int *MaxSize, int *Retention ) return True if we made enough room to accommodate needed bytes ********************************************************************/ -bool make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, - bool whack_by_date ) +static bool make_way_for_eventlogs( TDB_CONTEXT * the_tdb, int32 needed, + bool whack_by_date ) { int start_record, i, new_start; int end_record; -- cgit From 3d507a2fcab9da3d9ba928fbe1d30f2642ab4e93 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 30 Jan 2008 12:53:09 +0100 Subject: Let _samr_Close() use pidl generated server code. Guenther (This used to be commit 2df3408079fc382d00d01a0b82b0b8e1ffeba6e4) --- source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_samr.c | 40 +-- source3/rpc_server/srv_samr_nt.c | 686 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 698 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 06694a2701..8c7c43f686 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2367,7 +2367,7 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) dssetup_get_pipe_fns( &cmds, &n_cmds ); break; case PI_SAMR: - samr_get_pipe_fns( &cmds, &n_cmds ); + samr2_get_pipe_fns( &cmds, &n_cmds ); break; case PI_NETLOGON: netlog_get_pipe_fns( &cmds, &n_cmds ); diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index a1deac083d..e2ffdefcd6 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -36,33 +36,33 @@ #define DBGC_CLASS DBGC_RPC_SRV /******************************************************************* - api_samr_close_hnd ********************************************************************/ -static bool api_samr_close_hnd(pipes_struct *p) +static bool proxy_samr_call(pipes_struct *p, uint8 opnum) { - SAMR_Q_CLOSE_HND q_u; - SAMR_R_CLOSE_HND r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; + struct api_struct *fns; + int n_fns; - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); + samr_get_pipe_fns(&fns, &n_fns); - if(!samr_io_q_close_hnd("", &q_u, data, 0)) { - DEBUG(0,("api_samr_close_hnd: unable to unmarshall SAMR_Q_CLOSE_HND.\n")); - return False; + if (opnum >= n_fns) { + return false; } - r_u.status = _samr_close_hnd(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_close_hnd("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_close_hnd: unable to marshall SAMR_R_CLOSE_HND.\n")); - return False; + if (fns[opnum].opnum != opnum) { + smb_panic("SAMR function table not sorted"); } - return True; + return fns[opnum].fn(p); +} + +/******************************************************************* + api_samr_close_hnd + ********************************************************************/ + +static bool api_samr_close_hnd(pipes_struct *p) +{ + return proxy_samr_call(p, NDR_SAMR_CLOSE); } /******************************************************************* @@ -1557,14 +1557,14 @@ static struct api_struct api_samr_cmds [] = {"SAMR_CONNECT5" , SAMR_CONNECT5 , api_samr_connect5 } }; -void samr_get_pipe_fns( struct api_struct **fns, int *n_fns ) +void samr2_get_pipe_fns( struct api_struct **fns, int *n_fns ) { *fns = api_samr_cmds; *n_fns = sizeof(api_samr_cmds) / sizeof(struct api_struct); } -NTSTATUS rpc_samr_init(void) +NTSTATUS rpc_samr2_init(void) { return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "samr", "lsass", api_samr_cmds, sizeof(api_samr_cmds) / sizeof(struct api_struct)); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 01ce932afa..e80327367b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -543,20 +543,18 @@ static uint32 count_sam_aliases(struct disp_info *info) } /******************************************************************* - _samr_close_hnd + _samr_Close ********************************************************************/ -NTSTATUS _samr_close_hnd(pipes_struct *p, SAMR_Q_CLOSE_HND *q_u, SAMR_R_CLOSE_HND *r_u) +NTSTATUS _samr_Close(pipes_struct *p, struct samr_Close *r) { - r_u->status = NT_STATUS_OK; - - /* close the policy handle */ - if (!close_policy_hnd(p, &q_u->pol)) - return NT_STATUS_OBJECT_NAME_INVALID; + if (!close_policy_hnd(p, r->in.handle)) { + return NT_STATUS_INVALID_HANDLE; + } - DEBUG(5,("samr_reply_close_hnd: %d\n", __LINE__)); + ZERO_STRUCT(r->out.handle); - return r_u->status; + return NT_STATUS_OK; } /******************************************************************* @@ -5059,3 +5057,673 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R return r_u->status; } + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_Connect(pipes_struct *p, + struct samr_Connect *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_SetSecurity(pipes_struct *p, + struct samr_SetSecurity *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_QuerySecurity(pipes_struct *p, + struct samr_QuerySecurity *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_Shutdown(pipes_struct *p, + struct samr_Shutdown *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_LookupDomain(pipes_struct *p, + struct samr_LookupDomain *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_EnumDomains(pipes_struct *p, + struct samr_EnumDomains *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_OpenDomain(pipes_struct *p, + struct samr_OpenDomain *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_QueryDomainInfo(pipes_struct *p, + struct samr_QueryDomainInfo *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_SetDomainInfo(pipes_struct *p, + struct samr_SetDomainInfo *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_CreateDomainGroup(pipes_struct *p, + struct samr_CreateDomainGroup *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_EnumDomainGroups(pipes_struct *p, + struct samr_EnumDomainGroups *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_CreateUser(pipes_struct *p, + struct samr_CreateUser *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_EnumDomainUsers(pipes_struct *p, + struct samr_EnumDomainUsers *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_CreateDomAlias(pipes_struct *p, + struct samr_CreateDomAlias *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_EnumDomainAliases(pipes_struct *p, + struct samr_EnumDomainAliases *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_GetAliasMembership(pipes_struct *p, + struct samr_GetAliasMembership *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_LookupNames(pipes_struct *p, + struct samr_LookupNames *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_LookupRids(pipes_struct *p, + struct samr_LookupRids *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_OpenGroup(pipes_struct *p, + struct samr_OpenGroup *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_QueryGroupInfo(pipes_struct *p, + struct samr_QueryGroupInfo *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_SetGroupInfo(pipes_struct *p, + struct samr_SetGroupInfo *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_AddGroupMember(pipes_struct *p, + struct samr_AddGroupMember *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_DeleteDomainGroup(pipes_struct *p, + struct samr_DeleteDomainGroup *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_DeleteGroupMember(pipes_struct *p, + struct samr_DeleteGroupMember *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_QueryGroupMember(pipes_struct *p, + struct samr_QueryGroupMember *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_SetMemberAttributesOfGroup(pipes_struct *p, + struct samr_SetMemberAttributesOfGroup *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_OpenAlias(pipes_struct *p, + struct samr_OpenAlias *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_QueryAliasInfo(pipes_struct *p, + struct samr_QueryAliasInfo *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_SetAliasInfo(pipes_struct *p, + struct samr_SetAliasInfo *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_DeleteDomAlias(pipes_struct *p, + struct samr_DeleteDomAlias *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_AddAliasMember(pipes_struct *p, + struct samr_AddAliasMember *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_DeleteAliasMember(pipes_struct *p, + struct samr_DeleteAliasMember *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_GetMembersInAlias(pipes_struct *p, + struct samr_GetMembersInAlias *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_OpenUser(pipes_struct *p, + struct samr_OpenUser *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_DeleteUser(pipes_struct *p, + struct samr_DeleteUser *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_QueryUserInfo(pipes_struct *p, + struct samr_QueryUserInfo *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_SetUserInfo(pipes_struct *p, + struct samr_SetUserInfo *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_ChangePasswordUser(pipes_struct *p, + struct samr_ChangePasswordUser *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_GetGroupsForUser(pipes_struct *p, + struct samr_GetGroupsForUser *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p, + struct samr_QueryDisplayInfo *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p, + struct samr_GetDisplayEnumerationIndex *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_TestPrivateFunctionsDomain(pipes_struct *p, + struct samr_TestPrivateFunctionsDomain *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_TestPrivateFunctionsUser(pipes_struct *p, + struct samr_TestPrivateFunctionsUser *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_GetUserPwInfo(pipes_struct *p, + struct samr_GetUserPwInfo *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_RemoveMemberFromForeignDomain(pipes_struct *p, + struct samr_RemoveMemberFromForeignDomain *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_QueryDomainInfo2(pipes_struct *p, + struct samr_QueryDomainInfo2 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_QueryUserInfo2(pipes_struct *p, + struct samr_QueryUserInfo2 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_QueryDisplayInfo2(pipes_struct *p, + struct samr_QueryDisplayInfo2 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_GetDisplayEnumerationIndex2(pipes_struct *p, + struct samr_GetDisplayEnumerationIndex2 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_CreateUser2(pipes_struct *p, + struct samr_CreateUser2 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_QueryDisplayInfo3(pipes_struct *p, + struct samr_QueryDisplayInfo3 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_AddMultipleMembersToAlias(pipes_struct *p, + struct samr_AddMultipleMembersToAlias *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_RemoveMultipleMembersFromAlias(pipes_struct *p, + struct samr_RemoveMultipleMembersFromAlias *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_OemChangePasswordUser2(pipes_struct *p, + struct samr_OemChangePasswordUser2 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_ChangePasswordUser2(pipes_struct *p, + struct samr_ChangePasswordUser2 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_GetDomPwInfo(pipes_struct *p, + struct samr_GetDomPwInfo *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_Connect2(pipes_struct *p, + struct samr_Connect2 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_SetUserInfo2(pipes_struct *p, + struct samr_SetUserInfo2 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_SetBootKeyInformation(pipes_struct *p, + struct samr_SetBootKeyInformation *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_GetBootKeyInformation(pipes_struct *p, + struct samr_GetBootKeyInformation *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_Connect3(pipes_struct *p, + struct samr_Connect3 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_Connect4(pipes_struct *p, + struct samr_Connect4 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_ChangePasswordUser3(pipes_struct *p, + struct samr_ChangePasswordUser3 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_Connect5(pipes_struct *p, + struct samr_Connect5 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_RidToSid(pipes_struct *p, + struct samr_RidToSid *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_SetDsrmPassword(pipes_struct *p, + struct samr_SetDsrmPassword *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _samr_ValidatePassword(pipes_struct *p, + struct samr_ValidatePassword *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} -- cgit From 8dc7fe774e8e913e464b7661caf669145d5ff2f7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 31 Jan 2008 01:23:49 +0100 Subject: Cleanup status codes inside _net_logon_ctrl2() reply structs. Guenther (This used to be commit 1acb9daf809acab15bc390f6598814549b88368c) --- source3/rpc_server/srv_netlog_nt.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 5003af8ce7..fd90e88015 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -42,14 +42,6 @@ static void init_net_r_req_chal(NET_R_REQ_CHAL *r_c, r_c->status = status; } -/************************************************************************* - error messages cropping up when using nltest.exe... - *************************************************************************/ - -#define ERROR_NO_SUCH_DOMAIN 0x54b -#define ERROR_NO_LOGON_SERVERS 0x51f -#define NO_ERROR 0x0 - /************************************************************************* net_reply_logon_ctrl: *************************************************************************/ @@ -97,7 +89,7 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C r_u->status = NT_STATUS_OK; - tc_status = ERROR_NO_SUCH_DOMAIN; + tc_status = W_ERROR_V(WERR_NO_SUCH_DOMAIN); fstrcpy( dc_name, "" ); switch ( q_u->function_code ) { @@ -108,13 +100,13 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C break; if ( !get_dc_name( domain, NULL, dc_name2, &dc_ss ) ) { - tc_status = ERROR_NO_LOGON_SERVERS; + tc_status = W_ERROR_V(WERR_NO_LOGON_SERVERS); break; } fstr_sprintf( dc_name, "\\\\%s", dc_name2 ); - tc_status = NO_ERROR; + tc_status = W_ERROR_V(WERR_OK); break; @@ -125,13 +117,13 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C break; if ( !get_dc_name( domain, NULL, dc_name2, &dc_ss ) ) { - tc_status = ERROR_NO_LOGON_SERVERS; + tc_status = W_ERROR_V(WERR_NO_LOGON_SERVERS); break; } fstr_sprintf( dc_name, "\\\\%s", dc_name2 ); - tc_status = NO_ERROR; + tc_status = W_ERROR_V(WERR_OK); break; -- cgit From 2e2fa2c66ed8cd1ada68bc22ff257490495a29f0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 30 Jan 2008 21:55:03 +0100 Subject: Use pidl for samr_GetDomPwInfo() server-side. Guenther (This used to be commit 60fe8ade74d24d49f0fed0aae360a3b00edcd2b4) --- source3/rpc_server/srv_samr.c | 23 +---------------------- source3/rpc_server/srv_samr_nt.c | 25 ++++++++----------------- 2 files changed, 9 insertions(+), 39 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index e2ffdefcd6..c05d126c4c 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1350,28 +1350,7 @@ static bool api_samr_set_aliasinfo(pipes_struct *p) static bool api_samr_get_dom_pwinfo(pipes_struct *p) { - SAMR_Q_GET_DOM_PWINFO q_u; - SAMR_R_GET_DOM_PWINFO r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_get_dom_pwinfo("", &q_u, data, 0)) { - DEBUG(0,("api_samr_get_dom_pwinfo: unable to unmarshall SAMR_Q_GET_DOM_PWINFO.\n")); - return False; - } - - r_u.status = _samr_get_dom_pwinfo(p, &q_u, &r_u); - - if (!samr_io_r_get_dom_pwinfo("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_get_dom_pwinfo: unable to marshall SAMR_R_GET_DOM_PWINFO.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_GETDOMPWINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e80327367b..986fe9a62e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4810,23 +4810,24 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ return status; } -/********************************************************************* - _samr_get_dom_pwinfo -*********************************************************************/ +/**************************************************************** + _samr_GetDomPwInfo +****************************************************************/ -NTSTATUS _samr_get_dom_pwinfo(pipes_struct *p, SAMR_Q_GET_DOM_PWINFO *q_u, SAMR_R_GET_DOM_PWINFO *r_u) +NTSTATUS _samr_GetDomPwInfo(pipes_struct *p, + struct samr_GetDomPwInfo *r) { /* Perform access check. Since this rpc does not require a policy handle it will not be caught by the access checks on SAMR_CONNECT or SAMR_CONNECT_ANON. */ if (!pipe_access_check(p)) { - DEBUG(3, ("access denied to samr_get_dom_pwinfo\n")); - r_u->status = NT_STATUS_ACCESS_DENIED; - return r_u->status; + DEBUG(3, ("access denied to _samr_GetDomPwInfo\n")); + return NT_STATUS_ACCESS_DENIED; } /* Actually, returning zeros here works quite well :-). */ + ZERO_STRUCTP(r->out.info); return NT_STATUS_OK; } @@ -5611,16 +5612,6 @@ NTSTATUS _samr_ChangePasswordUser2(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_GetDomPwInfo(pipes_struct *p, - struct samr_GetDomPwInfo *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_Connect2(pipes_struct *p, struct samr_Connect2 *r) { -- cgit From 09454362cf75ecb7db58560604b567611e89d5ef Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 31 Jan 2008 00:38:12 +0100 Subject: Enable build of pidl generated netlogon server. Guenther (This used to be commit cb0fad1c97e1b590791fc0661f8ada1cdaa69318) --- source3/rpc_server/srv_netlog_nt.c | 472 +++++++++++++++++++++++++++++++++++++ 1 file changed, 472 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index fd90e88015..3a7075ecd6 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -1136,3 +1136,475 @@ NTSTATUS _net_sam_logon_ex(pipes_struct *p, NET_Q_SAM_LOGON_EX *q_u, NET_R_SAM_L return status; } #endif /* JERRY */ + + +/**************************************************************** +****************************************************************/ + +WERROR _netr_LogonUasLogon(pipes_struct *p, + struct netr_LogonUasLogon *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_LogonUasLogoff(pipes_struct *p, + struct netr_LogonUasLogoff *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_LogonSamLogon(pipes_struct *p, + struct netr_LogonSamLogon *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_LogonSamLogoff(pipes_struct *p, + struct netr_LogonSamLogoff *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_ServerReqChallenge(pipes_struct *p, + struct netr_ServerReqChallenge *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, + struct netr_ServerAuthenticate *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_ServerPasswordSet(pipes_struct *p, + struct netr_ServerPasswordSet *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_DatabaseDeltas(pipes_struct *p, + struct netr_DatabaseDeltas *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_DatabaseSync(pipes_struct *p, + struct netr_DatabaseSync *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_AccountDeltas(pipes_struct *p, + struct netr_AccountDeltas *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_AccountSync(pipes_struct *p, + struct netr_AccountSync *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_LogonControl(pipes_struct *p, + struct netr_LogonControl *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_GetDcName(pipes_struct *p, + struct netr_GetDcName *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_GetAnyDCName(pipes_struct *p, + struct netr_GetAnyDCName *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_LogonControl2(pipes_struct *p, + struct netr_LogonControl2 *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p, + struct netr_ServerAuthenticate2 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_DatabaseSync2(pipes_struct *p, + struct netr_DatabaseSync2 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_DatabaseRedo(pipes_struct *p, + struct netr_DatabaseRedo *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_LogonControl2Ex(pipes_struct *p, + struct netr_LogonControl2Ex *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_NetrEnumerateTrustedDomains(pipes_struct *p, + struct netr_NetrEnumerateTrustedDomains *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_DsRGetDCName(pipes_struct *p, + struct netr_DsRGetDCName *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_NETRLOGONDUMMYROUTINE1(pipes_struct *p, + struct netr_NETRLOGONDUMMYROUTINE1 *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_NETRLOGONSETSERVICEBITS(pipes_struct *p, + struct netr_NETRLOGONSETSERVICEBITS *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_LogonGetTrustRid(pipes_struct *p, + struct netr_LogonGetTrustRid *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_NETRLOGONCOMPUTESERVERDIGEST(pipes_struct *p, + struct netr_NETRLOGONCOMPUTESERVERDIGEST *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_NETRLOGONCOMPUTECLIENTDIGEST(pipes_struct *p, + struct netr_NETRLOGONCOMPUTECLIENTDIGEST *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_ServerAuthenticate3(pipes_struct *p, + struct netr_ServerAuthenticate3 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_DsRGetDCNameEx(pipes_struct *p, + struct netr_DsRGetDCNameEx *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_DsRGetSiteName(pipes_struct *p, + struct netr_DsRGetSiteName *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_LogonGetDomainInfo(pipes_struct *p, + struct netr_LogonGetDomainInfo *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_ServerPasswordSet2(pipes_struct *p, + struct netr_ServerPasswordSet2 *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_ServerPasswordGet(pipes_struct *p, + struct netr_ServerPasswordGet *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_NETRLOGONSENDTOSAM(pipes_struct *p, + struct netr_NETRLOGONSENDTOSAM *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_DsRAddressToSitenamesW(pipes_struct *p, + struct netr_DsRAddressToSitenamesW *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_DsRGetDCNameEx2(pipes_struct *p, + struct netr_DsRGetDCNameEx2 *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN(pipes_struct *p, + struct netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_NetrEnumerateTrustedDomainsEx(pipes_struct *p, + struct netr_NetrEnumerateTrustedDomainsEx *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_DsRAddressToSitenamesExW(pipes_struct *p, + struct netr_DsRAddressToSitenamesExW *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_DsrGetDcSiteCoverageW(pipes_struct *p, + struct netr_DsrGetDcSiteCoverageW *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_LogonSamLogonEx(pipes_struct *p, + struct netr_LogonSamLogonEx *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_DsrEnumerateDomainTrusts(pipes_struct *p, + struct netr_DsrEnumerateDomainTrusts *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_DsrDeregisterDNSHostRecords(pipes_struct *p, + struct netr_DsrDeregisterDNSHostRecords *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_ServerTrustPasswordsGet(pipes_struct *p, + struct netr_ServerTrustPasswordsGet *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_DsRGetForestTrustInformation(pipes_struct *p, + struct netr_DsRGetForestTrustInformation *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_GetForestTrustInformation(pipes_struct *p, + struct netr_GetForestTrustInformation *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +NTSTATUS _netr_LogonSamLogonWithFlags(pipes_struct *p, + struct netr_LogonSamLogonWithFlags *r) +{ + p->rng_fault_state = true; + return NT_STATUS_NOT_IMPLEMENTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _netr_NETRSERVERGETTRUSTINFO(pipes_struct *p, + struct netr_NETRSERVERGETTRUSTINFO *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + -- cgit From 8d8d955b98039d48e1aca6396bbdbc11d9141c21 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 31 Jan 2008 14:24:33 +0100 Subject: Fix _samr_Close(). A good example that work in this area needs very careful testing :) Guenther (This used to be commit 7d369906ec37caebaa4e2097874997fa257f1a31) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 986fe9a62e..cf5e1a9ead 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -552,7 +552,7 @@ NTSTATUS _samr_Close(pipes_struct *p, struct samr_Close *r) return NT_STATUS_INVALID_HANDLE; } - ZERO_STRUCT(r->out.handle); + ZERO_STRUCTP(r->out.handle); return NT_STATUS_OK; } -- cgit From fd15e9dd1c784220f8666083e2fa0bb9c75e7755 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Feb 2008 00:23:50 +0100 Subject: Use pidl for _samr_OpenDomain(). Guenther (This used to be commit 15801832ecd59bdb35ed33696944fe5beb08bf3f) --- source3/rpc_server/srv_samr.c | 24 +----------------------- source3/rpc_server/srv_samr_nt.c | 37 +++++++++++++------------------------ 2 files changed, 14 insertions(+), 47 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index c05d126c4c..9319d422da 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -71,29 +71,7 @@ static bool api_samr_close_hnd(pipes_struct *p) static bool api_samr_open_domain(pipes_struct *p) { - SAMR_Q_OPEN_DOMAIN q_u; - SAMR_R_OPEN_DOMAIN r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!samr_io_q_open_domain("", &q_u, data, 0)) { - DEBUG(0,("api_samr_open_domain: unable to unmarshall SAMR_Q_OPEN_DOMAIN.\n")); - return False; - } - - r_u.status = _samr_open_domain(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_open_domain("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_open_domain: unable to marshall SAMR_R_OPEN_DOMAIN.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_OPENDOMAIN); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index cf5e1a9ead..05c0cc69cf 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -558,28 +558,27 @@ NTSTATUS _samr_Close(pipes_struct *p, struct samr_Close *r) } /******************************************************************* - samr_reply_open_domain + _samr_OpenDomain ********************************************************************/ -NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN_DOMAIN *r_u) +NTSTATUS _samr_OpenDomain(pipes_struct *p, + struct samr_OpenDomain *r) { struct samr_info *info; SEC_DESC *psd = NULL; uint32 acc_granted; - uint32 des_access = q_u->flags; + uint32 des_access = r->in.access_mask; NTSTATUS status; size_t sd_size; SE_PRIV se_rights; - r_u->status = NT_STATUS_OK; - /* find the connection policy handle. */ - if ( !find_policy_by_hnd(p, &q_u->pol, (void**)(void *)&info) ) + if ( !find_policy_by_hnd(p, r->in.connect_handle, (void**)(void *)&info) ) return NT_STATUS_INVALID_HANDLE; status = access_check_samr_function( info->acc_granted, - SA_RIGHT_SAM_OPEN_DOMAIN, "_samr_open_domain" ); + SA_RIGHT_SAM_OPEN_DOMAIN, "_samr_OpenDomain" ); if ( !NT_STATUS_IS_OK(status) ) return status; @@ -594,28 +593,28 @@ NTSTATUS _samr_open_domain(pipes_struct *p, SAMR_Q_OPEN_DOMAIN *q_u, SAMR_R_OPEN status = access_check_samr_object( psd, p->pipe_user.nt_user_token, &se_rights, GENERIC_RIGHTS_DOMAIN_WRITE, des_access, - &acc_granted, "_samr_open_domain" ); + &acc_granted, "_samr_OpenDomain" ); if ( !NT_STATUS_IS_OK(status) ) return status; - if (!sid_check_is_domain(&q_u->dom_sid.sid) && - !sid_check_is_builtin(&q_u->dom_sid.sid)) { + if (!sid_check_is_domain(r->in.sid) && + !sid_check_is_builtin(r->in.sid)) { return NT_STATUS_NO_SUCH_DOMAIN; } /* associate the domain SID with the (unique) handle. */ - if ((info = get_samr_info_by_sid(&q_u->dom_sid.sid))==NULL) + if ((info = get_samr_info_by_sid(r->in.sid))==NULL) return NT_STATUS_NO_MEMORY; info->acc_granted = acc_granted; /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->domain_pol, free_samr_info, (void *)info)) + if (!create_policy_hnd(p, r->out.domain_handle, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - DEBUG(5,("samr_open_domain: %d\n", __LINE__)); + DEBUG(5,("_samr_OpenDomain: %d\n", __LINE__)); - return r_u->status; + return NT_STATUS_OK; } /******************************************************************* @@ -5122,16 +5121,6 @@ NTSTATUS _samr_EnumDomains(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_OpenDomain(pipes_struct *p, - struct samr_OpenDomain *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_QueryDomainInfo(pipes_struct *p, struct samr_QueryDomainInfo *r) { -- cgit From 645559990f03c4ca702c472f9344343e78b4385f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Feb 2008 00:39:06 +0100 Subject: Use pidl for _samr_OpenUser(). Guenther (This used to be commit ea3a096bcdc42fd4a86be5df3e8f9745e99970ff) --- source3/rpc_server/srv_samr.c | 23 +---------------------- source3/rpc_server/srv_samr_nt.c | 33 +++++++++++---------------------- 2 files changed, 12 insertions(+), 44 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 9319d422da..0627a07397 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -417,28 +417,7 @@ static bool api_samr_lookup_rids(pipes_struct *p) static bool api_samr_open_user(pipes_struct *p) { - SAMR_Q_OPEN_USER q_u; - SAMR_R_OPEN_USER r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!samr_io_q_open_user("", &q_u, data, 0)) { - DEBUG(0,("api_samr_open_user: unable to unmarshall SAMR_Q_OPEN_USER.\n")); - return False; - } - - r_u.status = _samr_open_user(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_open_user("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_open_user: unable to marshall SAMR_R_OPEN_USER.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_OPENUSER); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 05c0cc69cf..b677876270 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1766,33 +1766,32 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK } /******************************************************************* - _samr_open_user. Safe - gives out no passwd info. - ********************************************************************/ + _samr_OpenUser +********************************************************************/ -NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USER *r_u) +NTSTATUS _samr_OpenUser(pipes_struct *p, + struct samr_OpenUser *r) { struct samu *sampass=NULL; DOM_SID sid; - POLICY_HND domain_pol = q_u->domain_pol; - POLICY_HND *user_pol = &r_u->user_pol; + POLICY_HND domain_pol = *r->in.domain_handle; + POLICY_HND *user_pol = r->out.user_handle; struct samr_info *info = NULL; SEC_DESC *psd = NULL; uint32 acc_granted; - uint32 des_access = q_u->access_mask; + uint32 des_access = r->in.access_mask; size_t sd_size; bool ret; NTSTATUS nt_status; SE_PRIV se_rights; - r_u->status = NT_STATUS_OK; - /* find the domain policy handle and get domain SID / access bits in the domain policy. */ if ( !get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted, NULL) ) return NT_STATUS_INVALID_HANDLE; nt_status = access_check_samr_function( acc_granted, - SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_user" ); + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenUser" ); if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; @@ -1803,7 +1802,7 @@ NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USE /* append the user's RID to it */ - if (!sid_append_rid(&sid, q_u->user_rid)) + if (!sid_append_rid(&sid, r->in.rid)) return NT_STATUS_NO_SUCH_USER; /* check if access can be granted as requested by client. */ @@ -1816,7 +1815,7 @@ NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USE nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, &se_rights, GENERIC_RIGHTS_USER_WRITE, des_access, - &acc_granted, "_samr_open_user"); + &acc_granted, "_samr_OpenUser"); if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; @@ -1841,7 +1840,7 @@ NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USE if (!create_policy_hnd(p, user_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - return r_u->status; + return NT_STATUS_OK; } /************************************************************************* @@ -5381,16 +5380,6 @@ NTSTATUS _samr_GetMembersInAlias(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_OpenUser(pipes_struct *p, - struct samr_OpenUser *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_DeleteUser(pipes_struct *p, struct samr_DeleteUser *r) { -- cgit From ecaa48925f166f9b3295dc95edba23faf4df50f6 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Feb 2008 00:48:40 +0100 Subject: Use pidl for _samr_OpenAlias(). Guenther (This used to be commit 1a98282d2c61e45645c68941631eb0499baa4cbb) --- source3/rpc_server/srv_samr.c | 24 +----------------------- source3/rpc_server/srv_samr_nt.c | 31 ++++++++++--------------------- 2 files changed, 11 insertions(+), 44 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 0627a07397..b1c7349c31 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -761,29 +761,7 @@ static bool api_samr_enum_domains(pipes_struct *p) static bool api_samr_open_alias(pipes_struct *p) { - SAMR_Q_OPEN_ALIAS q_u; - SAMR_R_OPEN_ALIAS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the samr open policy */ - if(!samr_io_q_open_alias("", &q_u, data, 0)) { - DEBUG(0,("api_samr_open_alias: Unable to unmarshall SAMR_Q_OPEN_ALIAS.\n")); - return False; - } - - r_u.status=_samr_open_alias(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_open_alias("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_open_alias: Unable to marshall SAMR_R_OPEN_ALIAS.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_OPENALIAS); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b677876270..e5e22d2b57 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2977,32 +2977,31 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN } /******************************************************************* - api_samr_open_alias + _samr_OpenAlias ********************************************************************/ -NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_ALIAS *r_u) +NTSTATUS _samr_OpenAlias(pipes_struct *p, + struct samr_OpenAlias *r) { DOM_SID sid; - POLICY_HND domain_pol = q_u->dom_pol; - uint32 alias_rid = q_u->rid_alias; - POLICY_HND *alias_pol = &r_u->pol; + POLICY_HND domain_pol = *r->in.domain_handle; + uint32 alias_rid = r->in.rid; + POLICY_HND *alias_pol = r->out.alias_handle; struct samr_info *info = NULL; SEC_DESC *psd = NULL; uint32 acc_granted; - uint32 des_access = q_u->access_mask; + uint32 des_access = r->in.access_mask; size_t sd_size; NTSTATUS status; SE_PRIV se_rights; - r_u->status = NT_STATUS_OK; - /* find the domain policy and get the SID / access bits stored in the domain policy */ if ( !get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted, NULL) ) return NT_STATUS_INVALID_HANDLE; status = access_check_samr_function(acc_granted, - SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_alias"); + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenAlias"); if ( !NT_STATUS_IS_OK(status) ) return status; @@ -3022,7 +3021,7 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A status = access_check_samr_object(psd, p->pipe_user.nt_user_token, &se_rights, GENERIC_RIGHTS_ALIAS_WRITE, des_access, - &acc_granted, "_samr_open_alias"); + &acc_granted, "_samr_OpenAlias"); if ( !NT_STATUS_IS_OK(status) ) return status; @@ -3059,7 +3058,7 @@ NTSTATUS _samr_open_alias(pipes_struct *p, SAMR_Q_OPEN_ALIAS *q_u, SAMR_R_OPEN_A if (!create_policy_hnd(p, alias_pol, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - return r_u->status; + return NT_STATUS_OK; } /******************************************************************* @@ -5310,16 +5309,6 @@ NTSTATUS _samr_SetMemberAttributesOfGroup(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_OpenAlias(pipes_struct *p, - struct samr_OpenAlias *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_QueryAliasInfo(pipes_struct *p, struct samr_QueryAliasInfo *r) { -- cgit From 846c3a30016444850a1fb24d5fccd6345e8a60a0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Feb 2008 00:49:32 +0100 Subject: Use pidl for _samr_OpenGroup(). Guenther (This used to be commit e74ad425ff3a139fa12c0320e4a292dcb0991888) --- source3/rpc_server/srv_samr.c | 23 +---------------------- source3/rpc_server/srv_samr_nt.c | 30 +++++++++++------------------- 2 files changed, 12 insertions(+), 41 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index b1c7349c31..447865eb15 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1294,28 +1294,7 @@ static bool api_samr_get_dom_pwinfo(pipes_struct *p) static bool api_samr_open_group(pipes_struct *p) { - SAMR_Q_OPEN_GROUP q_u; - SAMR_R_OPEN_GROUP r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_open_group("", &q_u, data, 0)) { - DEBUG(0,("api_samr_open_group: unable to unmarshall SAMR_Q_OPEN_GROUP.\n")); - return False; - } - - r_u.status = _samr_open_group(p, &q_u, &r_u); - - if (!samr_io_r_open_group("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_open_group: unable to marshall SAMR_R_OPEN_GROUP.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_OPENGROUP); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e5e22d2b57..2fd1c98be8 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4830,10 +4830,12 @@ NTSTATUS _samr_GetDomPwInfo(pipes_struct *p, } /********************************************************************* - _samr_open_group + _samr_OpenGroup *********************************************************************/ -NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_GROUP *r_u) +NTSTATUS _samr_OpenGroup(pipes_struct *p, + struct samr_OpenGroup *r) + { DOM_SID sid; DOM_SID info_sid; @@ -4841,18 +4843,18 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G struct samr_info *info; SEC_DESC *psd = NULL; uint32 acc_granted; - uint32 des_access = q_u->access_mask; + uint32 des_access = r->in.access_mask; size_t sd_size; NTSTATUS status; fstring sid_string; bool ret; SE_PRIV se_rights; - if (!get_lsa_policy_samr_sid(p, &q_u->domain_pol, &sid, &acc_granted, NULL)) + if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; status = access_check_samr_function(acc_granted, - SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_open_group"); + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenGroup"); if ( !NT_STATUS_IS_OK(status) ) return status; @@ -4865,7 +4867,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G status = access_check_samr_object(psd, p->pipe_user.nt_user_token, &se_rights, GENERIC_RIGHTS_GROUP_WRITE, des_access, - &acc_granted, "_samr_open_group"); + &acc_granted, "_samr_OpenGroup"); if ( !NT_STATUS_IS_OK(status) ) return status; @@ -4876,7 +4878,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G return NT_STATUS_ACCESS_DENIED; sid_copy(&info_sid, get_global_sam_sid()); - sid_append_rid(&info_sid, q_u->rid_group); + sid_append_rid(&info_sid, r->in.rid); sid_to_fstring(sid_string, &info_sid); if ((info = get_samr_info_by_sid(&info_sid)) == NULL) @@ -4884,7 +4886,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G info->acc_granted = acc_granted; - DEBUG(10, ("_samr_open_group:Opening SID: %s\n", sid_string)); + DEBUG(10, ("_samr_OpenGroup:Opening SID: %s\n", sid_string)); /* check if that group really exists */ become_root(); @@ -4894,7 +4896,7 @@ NTSTATUS _samr_open_group(pipes_struct *p, SAMR_Q_OPEN_GROUP *q_u, SAMR_R_OPEN_G return NT_STATUS_NO_SUCH_GROUP; /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->pol, free_samr_info, (void *)info)) + if (!create_policy_hnd(p, r->out.group_handle, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; return NT_STATUS_OK; @@ -5229,16 +5231,6 @@ NTSTATUS _samr_LookupRids(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_OpenGroup(pipes_struct *p, - struct samr_OpenGroup *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_QueryGroupInfo(pipes_struct *p, struct samr_QueryGroupInfo *r) { -- cgit From 145ff9a4b4a8240b4214b866d7412d4a125a8ab6 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Feb 2008 01:30:50 +0100 Subject: Use pidl for _samr_DeleteUser(). Guenther (This used to be commit 86827e374469421e2204598712225fb19d4af64b) --- source3/rpc_server/srv_samr.c | 23 +---------------------- source3/rpc_server/srv_samr_nt.c | 39 ++++++++++++++++----------------------- 2 files changed, 17 insertions(+), 45 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 447865eb15..b3a54700a4 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1045,28 +1045,7 @@ static bool api_samr_del_groupmem(pipes_struct *p) static bool api_samr_delete_dom_user(pipes_struct *p) { - SAMR_Q_DELETE_DOM_USER q_u; - SAMR_R_DELETE_DOM_USER r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_delete_dom_user("", &q_u, data, 0)) { - DEBUG(0,("api_samr_delete_dom_user: unable to unmarshall SAMR_Q_DELETE_DOM_USER.\n")); - return False; - } - - r_u.status = _samr_delete_dom_user(p, &q_u, &r_u); - - if (!samr_io_r_delete_dom_user("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_delete_dom_user: unable to marshall SAMR_R_DELETE_DOM_USER.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_DELETEUSER); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2fd1c98be8..e464066d23 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4168,11 +4168,13 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE } /********************************************************************* - _samr_delete_dom_user + _samr_DeleteUser *********************************************************************/ -NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAMR_R_DELETE_DOM_USER *r_u ) +NTSTATUS _samr_DeleteUser(pipes_struct *p, + struct samr_DeleteUser *r) { + NTSTATUS status; DOM_SID user_sid; struct samu *sam_pass=NULL; uint32 acc_granted; @@ -4181,14 +4183,15 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM DISP_INFO *disp_info = NULL; bool ret; - DEBUG(5, ("_samr_delete_dom_user: %d\n", __LINE__)); + DEBUG(5, ("_samr_DeleteUser: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &user_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.user_handle, &user_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_user"))) { - return r_u->status; + status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_DeleteUser"); + if (!NT_STATUS_IS_OK(status)) { + return status; } if (!sid_check_is_in_our_domain(&user_sid)) @@ -4204,7 +4207,7 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM unbecome_root(); if( !ret ) { - DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n", + DEBUG(5,("_samr_DeleteUser: User %s doesn't exist.\n", sid_string_dbg(&user_sid))); TALLOC_FREE(sam_pass); return NT_STATUS_NO_SUCH_USER; @@ -4224,25 +4227,25 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM if ( can_add_accounts ) become_root(); - r_u->status = pdb_delete_user(p->mem_ctx, sam_pass); + status = pdb_delete_user(p->mem_ctx, sam_pass); if ( can_add_accounts ) unbecome_root(); /******** END SeAddUsers BLOCK *********/ - if ( !NT_STATUS_IS_OK(r_u->status) ) { - DEBUG(5,("_samr_delete_dom_user: Failed to delete entry for " + if ( !NT_STATUS_IS_OK(status) ) { + DEBUG(5,("_samr_DeleteUser: Failed to delete entry for " "user %s: %s.\n", pdb_get_username(sam_pass), - nt_errstr(r_u->status))); + nt_errstr(status))); TALLOC_FREE(sam_pass); - return r_u->status; + return status; } TALLOC_FREE(sam_pass); - if (!close_policy_hnd(p, &q_u->user_pol)) + if (!close_policy_hnd(p, r->in.user_handle)) return NT_STATUS_OBJECT_NAME_INVALID; force_flush_samr_cache(disp_info); @@ -5361,16 +5364,6 @@ NTSTATUS _samr_GetMembersInAlias(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_DeleteUser(pipes_struct *p, - struct samr_DeleteUser *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_QueryUserInfo(pipes_struct *p, struct samr_QueryUserInfo *r) { -- cgit From b36ad1d59b07456b300775f51914af3183aac428 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Feb 2008 01:31:45 +0100 Subject: Use pidl for _samr_DeleteDomainGroup(). Guenther (This used to be commit b8bf051bdda221dda15598e16bb8dbec68bc7df7) --- source3/rpc_server/srv_samr.c | 23 +---------------------- source3/rpc_server/srv_samr_nt.c | 39 ++++++++++++++++----------------------- 2 files changed, 17 insertions(+), 45 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index b3a54700a4..5d69886445 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1054,28 +1054,7 @@ static bool api_samr_delete_dom_user(pipes_struct *p) static bool api_samr_delete_dom_group(pipes_struct *p) { - SAMR_Q_DELETE_DOM_GROUP q_u; - SAMR_R_DELETE_DOM_GROUP r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_delete_dom_group("", &q_u, data, 0)) { - DEBUG(0,("api_samr_delete_dom_group: unable to unmarshall SAMR_Q_DELETE_DOM_GROUP.\n")); - return False; - } - - r_u.status = _samr_delete_dom_group(p, &q_u, &r_u); - - if (!samr_io_r_delete_dom_group("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_delete_dom_group: unable to marshall SAMR_R_DELETE_DOM_GROUP.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_DELETEDOMAINGROUP); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e464066d23..23c289a3ed 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4254,11 +4254,13 @@ NTSTATUS _samr_DeleteUser(pipes_struct *p, } /********************************************************************* - _samr_delete_dom_group + _samr_DeleteDomainGroup *********************************************************************/ -NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, SAMR_R_DELETE_DOM_GROUP *r_u) +NTSTATUS _samr_DeleteDomainGroup(pipes_struct *p, + struct samr_DeleteDomainGroup *r) { + NTSTATUS status; DOM_SID group_sid; uint32 group_rid; uint32 acc_granted; @@ -4266,14 +4268,15 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S bool can_add_accounts; DISP_INFO *disp_info = NULL; - DEBUG(5, ("samr_delete_dom_group: %d\n", __LINE__)); + DEBUG(5, ("samr_DeleteDomainGroup: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_group"))) { - return r_u->status; + + status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_DeleteDomainGroup"); + if (!NT_STATUS_IS_OK(status)) { + return status; } DEBUG(10, ("sid is %s\n", sid_string_dbg(&group_sid))); @@ -4291,22 +4294,22 @@ NTSTATUS _samr_delete_dom_group(pipes_struct *p, SAMR_Q_DELETE_DOM_GROUP *q_u, S if ( can_add_accounts ) become_root(); - r_u->status = pdb_delete_dom_group(p->mem_ctx, group_rid); + status = pdb_delete_dom_group(p->mem_ctx, group_rid); if ( can_add_accounts ) unbecome_root(); /******** END SeAddUsers BLOCK *********/ - if ( !NT_STATUS_IS_OK(r_u->status) ) { - DEBUG(5,("_samr_delete_dom_group: Failed to delete mapping " + if ( !NT_STATUS_IS_OK(status) ) { + DEBUG(5,("_samr_DeleteDomainGroup: Failed to delete mapping " "entry for group %s: %s\n", sid_string_dbg(&group_sid), - nt_errstr(r_u->status))); - return r_u->status; + nt_errstr(status))); + return status; } - if (!close_policy_hnd(p, &q_u->group_pol)) + if (!close_policy_hnd(p, r->in.group_handle)) return NT_STATUS_OBJECT_NAME_INVALID; force_flush_samr_cache(disp_info); @@ -5264,16 +5267,6 @@ NTSTATUS _samr_AddGroupMember(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_DeleteDomainGroup(pipes_struct *p, - struct samr_DeleteDomainGroup *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_DeleteGroupMember(pipes_struct *p, struct samr_DeleteGroupMember *r) { -- cgit From 1921a6d67e704ac009695885e6954596e278a681 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Feb 2008 01:32:18 +0100 Subject: Use pidl for _samr_DeleteDomAlias(). Guenther (This used to be commit 31d5a3aaa42c18319fd751aba65f435348b1e83e) --- source3/rpc_server/srv_samr.c | 23 +---------------------- source3/rpc_server/srv_samr_nt.c | 28 ++++++++++------------------ 2 files changed, 11 insertions(+), 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 5d69886445..4d5f841aa2 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1063,28 +1063,7 @@ static bool api_samr_delete_dom_group(pipes_struct *p) static bool api_samr_delete_dom_alias(pipes_struct *p) { - SAMR_Q_DELETE_DOM_ALIAS q_u; - SAMR_R_DELETE_DOM_ALIAS r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_delete_dom_alias("", &q_u, data, 0)) { - DEBUG(0,("api_samr_delete_dom_alias: unable to unmarshall SAMR_Q_DELETE_DOM_ALIAS.\n")); - return False; - } - - r_u.status = _samr_delete_dom_alias(p, &q_u, &r_u); - - if (!samr_io_r_delete_dom_alias("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_delete_dom_alias: unable to marshall SAMR_R_DELETE_DOM_ALIAS.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_DELETEDOMALIAS); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 23c289a3ed..23a0185ebb 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4318,10 +4318,11 @@ NTSTATUS _samr_DeleteDomainGroup(pipes_struct *p, } /********************************************************************* - _samr_delete_dom_alias + _samr_DeleteDomAlias *********************************************************************/ -NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, SAMR_R_DELETE_DOM_ALIAS *r_u) +NTSTATUS _samr_DeleteDomAlias(pipes_struct *p, + struct samr_DeleteDomAlias *r) { DOM_SID alias_sid; uint32 acc_granted; @@ -4330,18 +4331,19 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S NTSTATUS status; DISP_INFO *disp_info = NULL; - DEBUG(5, ("_samr_delete_dom_alias: %d\n", __LINE__)); + DEBUG(5, ("_samr_DeleteDomAlias: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; /* copy the handle to the outgoing reply */ - memcpy( &r_u->pol, &q_u->alias_pol, sizeof(r_u->pol) ); + memcpy(r->out.alias_handle, r->in.alias_handle, sizeof(r->out.alias_handle)); - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_delete_dom_alias"))) { - return r_u->status; + status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_DeleteDomAlias"); + if (!NT_STATUS_IS_OK(status)) { + return status; } DEBUG(10, ("sid is %s\n", sid_string_dbg(&alias_sid))); @@ -4376,7 +4378,7 @@ NTSTATUS _samr_delete_dom_alias(pipes_struct *p, SAMR_Q_DELETE_DOM_ALIAS *q_u, S if ( !NT_STATUS_IS_OK(status)) return status; - if (!close_policy_hnd(p, &q_u->alias_pol)) + if (!close_policy_hnd(p, r->in.alias_handle)) return NT_STATUS_OBJECT_NAME_INVALID; force_flush_samr_cache(disp_info); @@ -5317,16 +5319,6 @@ NTSTATUS _samr_SetAliasInfo(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_DeleteDomAlias(pipes_struct *p, - struct samr_DeleteDomAlias *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_AddAliasMember(pipes_struct *p, struct samr_AddAliasMember *r) { -- cgit From 3e67d648a1d164b67cf390ae33e83fc9362e3179 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Feb 2008 14:48:42 +0100 Subject: Use pidl for _samr_CreateDomAlias(). Guenther (This used to be commit 622d529c45aaa6d8ddd3a38a2fa4fc5e1ad53fe9) --- source3/rpc_server/srv_samr.c | 23 +---------------------- source3/rpc_server/srv_samr_nt.c | 32 ++++++++++++-------------------- 2 files changed, 13 insertions(+), 42 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 4d5f841aa2..1ab8a318b2 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1102,28 +1102,7 @@ static bool api_samr_create_dom_group(pipes_struct *p) static bool api_samr_create_dom_alias(pipes_struct *p) { - SAMR_Q_CREATE_DOM_ALIAS q_u; - SAMR_R_CREATE_DOM_ALIAS r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_create_dom_alias("", &q_u, data, 0)) { - DEBUG(0,("api_samr_create_dom_alias: unable to unmarshall SAMR_Q_CREATE_DOM_ALIAS.\n")); - return False; - } - - r_u.status = _samr_create_dom_alias(p, &q_u, &r_u); - - if (!samr_io_r_create_dom_alias("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_create_dom_alias: unable to marshall SAMR_R_CREATE_DOM_ALIAS.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_CREATEDOMALIAS); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 23a0185ebb..650e59d116 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4463,14 +4463,15 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S } /********************************************************************* - _samr_create_dom_alias + _samr_CreateDomAlias *********************************************************************/ -NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, SAMR_R_CREATE_DOM_ALIAS *r_u) +NTSTATUS _samr_CreateDomAlias(pipes_struct *p, + struct samr_CreateDomAlias *r) { DOM_SID dom_sid; DOM_SID info_sid; - fstring name; + const char *name = NULL; struct samr_info *info; uint32 acc_granted; gid_t gid; @@ -4480,17 +4481,18 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &dom_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &dom_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_ALIAS, "_samr_create_alias"))) { - return r_u->status; + result = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_ALIAS, "_samr_CreateDomAlias"); + if (!NT_STATUS_IS_OK(result)) { + return result; } if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; - unistr2_to_ascii(name, &q_u->uni_acct_desc, sizeof(name)); + name = r->in.alias_name->string; se_priv_copy( &se_rights, &se_add_users ); can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); @@ -4506,7 +4508,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S become_root(); /* Have passdb create the alias */ - result = pdb_create_alias(name, &r_u->rid); + result = pdb_create_alias(name, r->out.rid); if ( can_add_accounts ) unbecome_root(); @@ -4520,7 +4522,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S } sid_copy(&info_sid, get_global_sam_sid()); - sid_append_rid(&info_sid, r_u->rid); + sid_append_rid(&info_sid, *r->out.rid); if (!sid_to_gid(&info_sid, &gid)) { DEBUG(10, ("Could not find alias just created\n")); @@ -4542,7 +4544,7 @@ NTSTATUS _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, S info->acc_granted = GENERIC_RIGHTS_ALIAS_ALL_ACCESS; /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->alias_pol, free_samr_info, (void *)info)) + if (!create_policy_hnd(p, r->out.alias_handle, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; force_flush_samr_cache(disp_info); @@ -5189,16 +5191,6 @@ NTSTATUS _samr_EnumDomainUsers(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_CreateDomAlias(pipes_struct *p, - struct samr_CreateDomAlias *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_EnumDomainAliases(pipes_struct *p, struct samr_EnumDomainAliases *r) { -- cgit From 6e74a5dba33f8be671fddce367ef341c9c2fe6bc Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Feb 2008 14:49:23 +0100 Subject: Use pidl for _samr_CreateDomainGroup(). Guenther (This used to be commit c53bfd74251398924a1fae0fd8d9020dba958ba1) --- source3/rpc_server/srv_samr.c | 23 +--------------------- source3/rpc_server/srv_samr_nt.c | 42 +++++++++++++++++----------------------- 2 files changed, 19 insertions(+), 46 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 1ab8a318b2..b7d322884a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1072,28 +1072,7 @@ static bool api_samr_delete_dom_alias(pipes_struct *p) static bool api_samr_create_dom_group(pipes_struct *p) { - SAMR_Q_CREATE_DOM_GROUP q_u; - SAMR_R_CREATE_DOM_GROUP r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_create_dom_group("", &q_u, data, 0)) { - DEBUG(0,("api_samr_create_dom_group: unable to unmarshall SAMR_Q_CREATE_DOM_GROUP.\n")); - return False; - } - - r_u.status = _samr_create_dom_group(p, &q_u, &r_u); - - if (!samr_io_r_create_dom_group("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_create_dom_group: unable to marshall SAMR_R_CREATE_DOM_GROUP.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_CREATEDOMAINGROUP); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 650e59d116..690f76ee72 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4387,11 +4387,14 @@ NTSTATUS _samr_DeleteDomAlias(pipes_struct *p, } /********************************************************************* - _samr_create_dom_group + _samr_CreateDomainGroup *********************************************************************/ -NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, SAMR_R_CREATE_DOM_GROUP *r_u) +NTSTATUS _samr_CreateDomainGroup(pipes_struct *p, + struct samr_CreateDomainGroup *r) + { + NTSTATUS status; DOM_SID dom_sid; DOM_SID info_sid; const char *name; @@ -4402,24 +4405,25 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &dom_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &dom_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_GROUP, "_samr_create_dom_group"))) { - return r_u->status; + status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_GROUP, "_samr_CreateDomainGroup"); + if (!NT_STATUS_IS_OK(status)) { + return status; } if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; - name = rpcstr_pull_unistr2_talloc(p->mem_ctx, &q_u->uni_acct_desc); + name = r->in.name->string; if (name == NULL) { return NT_STATUS_NO_MEMORY; } - r_u->status = can_create(p->mem_ctx, name); - if (!NT_STATUS_IS_OK(r_u->status)) { - return r_u->status; + status = can_create(p->mem_ctx, name); + if (!NT_STATUS_IS_OK(status)) { + return status; } se_priv_copy( &se_rights, &se_add_users ); @@ -4432,7 +4436,7 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S /* check that we successfully create the UNIX group */ - r_u->status = pdb_create_dom_group(p->mem_ctx, name, &r_u->rid); + status = pdb_create_dom_group(p->mem_ctx, name, r->out.rid); if ( can_add_accounts ) unbecome_root(); @@ -4441,10 +4445,10 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S /* check if we should bail out here */ - if ( !NT_STATUS_IS_OK(r_u->status) ) - return r_u->status; + if ( !NT_STATUS_IS_OK(status) ) + return status; - sid_compose(&info_sid, get_global_sam_sid(), r_u->rid); + sid_compose(&info_sid, get_global_sam_sid(), *r->out.rid); if ((info = get_samr_info_by_sid(&info_sid)) == NULL) return NT_STATUS_NO_MEMORY; @@ -4454,7 +4458,7 @@ NTSTATUS _samr_create_dom_group(pipes_struct *p, SAMR_Q_CREATE_DOM_GROUP *q_u, S info->acc_granted = GENERIC_RIGHTS_GROUP_ALL_ACCESS; /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->pol, free_samr_info, (void *)info)) + if (!create_policy_hnd(p, r->out.group_handle, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; force_flush_samr_cache(disp_info); @@ -5151,16 +5155,6 @@ NTSTATUS _samr_SetDomainInfo(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_CreateDomainGroup(pipes_struct *p, - struct samr_CreateDomainGroup *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_EnumDomainGroups(pipes_struct *p, struct samr_EnumDomainGroups *r) { -- cgit From f0438acfda7ae28a68d20be3cd05cdaeff9ac82b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Feb 2008 14:50:33 +0100 Subject: Use pidl for _samr_CreateUser2(). Guenther (This used to be commit 36f52b631c013f885ed25ea741a52f763d27198b) --- source3/rpc_server/srv_samr.c | 25 +------------------------ source3/rpc_server/srv_samr_nt.c | 40 ++++++++++++++-------------------------- 2 files changed, 15 insertions(+), 50 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index b7d322884a..f2e6f79d8c 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -516,30 +516,7 @@ static bool api_samr_query_domain_info(pipes_struct *p) static bool api_samr_create_user(pipes_struct *p) { - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - SAMR_Q_CREATE_USER q_u; - SAMR_R_CREATE_USER r_u; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the samr create user */ - if (!samr_io_q_create_user("", &q_u, data, 0)) { - DEBUG(0,("api_samr_create_user: Unable to unmarshall SAMR_Q_CREATE_USER.\n")); - return False; - } - - r_u.status=_samr_create_user(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_create_user("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_create_user: Unable to marshall SAMR_R_CREATE_USER.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_CREATEUSER2); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 690f76ee72..3f2022c9ed 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2518,19 +2518,17 @@ static NTSTATUS can_create(TALLOC_CTX *mem_ctx, const char *new_name) } /******************************************************************* - _samr_create_user - Create an account, can be either a normal user or a machine. - This funcion will need to be updated for bdc/domain trusts. + _samr_CreateUser2 ********************************************************************/ -NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, - SAMR_R_CREATE_USER *r_u) +NTSTATUS _samr_CreateUser2(pipes_struct *p, + struct samr_CreateUser2 *r) { - char *account; + const char *account = NULL; DOM_SID sid; - POLICY_HND dom_pol = q_u->domain_pol; - uint16 acb_info = q_u->acb_info; - POLICY_HND *user_pol = &r_u->user_pol; + POLICY_HND dom_pol = *r->in.domain_handle; + uint32_t acb_info = r->in.acct_flags; + POLICY_HND *user_pol = r->out.user_handle; struct samr_info *info = NULL; NTSTATUS nt_status; uint32 acc_granted; @@ -2549,7 +2547,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, nt_status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_USER, - "_samr_create_user"); + "_samr_CreateUser2"); if (!NT_STATUS_IS_OK(nt_status)) { return nt_status; } @@ -2561,7 +2559,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, return NT_STATUS_INVALID_PARAMETER; } - account = rpcstr_pull_unistr2_talloc(p->mem_ctx, &q_u->uni_name); + account = r->in.account_name->string; if (account == NULL) { return NT_STATUS_NO_MEMORY; } @@ -2600,7 +2598,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, } } - DEBUG(5, ("_samr_create_user: %s can add this account : %s\n", + DEBUG(5, ("_samr_CreateUser2: %s can add this account : %s\n", uidtoname(p->pipe_user.ut.uid), can_add_account ? "True":"False" )); @@ -2610,7 +2608,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, become_root(); nt_status = pdb_create_user(p->mem_ctx, account, acb_info, - &r_u->user_rid); + r->out.rid); if ( can_add_account ) unbecome_root(); @@ -2624,7 +2622,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, /* Get the user's SID */ - sid_compose(&sid, get_global_sam_sid(), r_u->user_rid); + sid_compose(&sid, get_global_sam_sid(), *r->out.rid); make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, &sid, SAMR_USR_RIGHTS_WRITE_PW); @@ -2632,7 +2630,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, &se_rights, GENERIC_RIGHTS_USER_WRITE, des_access, - &acc_granted, "_samr_create_user"); + &acc_granted, "_samr_CreateUser2"); if ( !NT_STATUS_IS_OK(nt_status) ) { return nt_status; @@ -2655,7 +2653,7 @@ NTSTATUS _samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, /* After a "set" ensure we have no cached display info. */ force_flush_samr_cache(info->disp_info); - r_u->access_granted = acc_granted; + *r->out.access_granted = acc_granted; return NT_STATUS_OK; } @@ -5475,16 +5473,6 @@ NTSTATUS _samr_GetDisplayEnumerationIndex2(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_CreateUser2(pipes_struct *p, - struct samr_CreateUser2 *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_QueryDisplayInfo3(pipes_struct *p, struct samr_QueryDisplayInfo3 *r) { -- cgit From e7a82edd3557ce0da11c56231bf3f51b3e686061 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Feb 2008 23:06:43 +0100 Subject: Use pidl for _samr_ChangePasswordUser2(). Guenther (This used to be commit a142fe21e386233af658024b5a194eee0bc5c4ba) --- source3/rpc_server/srv_samr.c | 24 +----------------------- source3/rpc_server/srv_samr_nt.c | 36 ++++++++++++------------------------ 2 files changed, 13 insertions(+), 47 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index f2e6f79d8c..38bbda3f3a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -355,29 +355,7 @@ static bool api_samr_lookup_names(pipes_struct *p) static bool api_samr_chgpasswd_user(pipes_struct *p) { - SAMR_Q_CHGPASSWD_USER q_u; - SAMR_R_CHGPASSWD_USER r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* change password request */ - if (!samr_io_q_chgpasswd_user("", &q_u, data, 0)) { - DEBUG(0,("api_samr_chgpasswd_user: Failed to unmarshall SAMR_Q_CHGPASSWD_USER.\n")); - return False; - } - - r_u.status = _samr_chgpasswd_user(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_chgpasswd_user("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_chgpasswd_user: Failed to marshall SAMR_R_CHGPASSWD_USER.\n" )); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_CHANGEPASSWORDUSER2); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 3f2022c9ed..2ccb202aed 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1529,22 +1529,22 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO } /******************************************************************* - _samr_chgpasswd_user + _samr_ChangePasswordUser2 ********************************************************************/ +NTSTATUS _samr_ChangePasswordUser2(pipes_struct *p, + struct samr_ChangePasswordUser2 *r) -NTSTATUS _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_R_CHGPASSWD_USER *r_u) { + NTSTATUS status; fstring user_name; fstring wks; - DEBUG(5,("_samr_chgpasswd_user: %d\n", __LINE__)); + DEBUG(5,("_samr_ChangePasswordUser2: %d\n", __LINE__)); - r_u->status = NT_STATUS_OK; + fstrcpy(user_name, r->in.account->string); + fstrcpy(wks, r->in.server->string); - rpcstr_pull(user_name, q_u->uni_user_name.buffer, sizeof(user_name), q_u->uni_user_name.uni_str_len*2, 0); - rpcstr_pull(wks, q_u->uni_dest_host.buffer, sizeof(wks), q_u->uni_dest_host.uni_str_len*2,0); - - DEBUG(5,("samr_chgpasswd_user: user: %s wks: %s\n", user_name, wks)); + DEBUG(5,("_samr_ChangePasswordUser2: user: %s wks: %s\n", user_name, wks)); /* * Pass the user through the NT -> unix user mapping @@ -1558,14 +1558,12 @@ NTSTATUS _samr_chgpasswd_user(pipes_struct *p, SAMR_Q_CHGPASSWD_USER *q_u, SAMR_ * is case insensitive. */ - r_u->status = pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, - q_u->nt_newpass.pass, q_u->nt_oldhash.hash, NULL); - - init_samr_r_chgpasswd_user(r_u, r_u->status); + status = pass_oem_change(user_name, r->in.lm_password->data, r->in.lm_verifier->hash, + r->in.nt_password->data, r->in.nt_verifier->hash, NULL); - DEBUG(5,("_samr_chgpasswd_user: %d\n", __LINE__)); + DEBUG(5,("_samr_ChangePasswordUser2: %d\n", __LINE__)); - return r_u->status; + return status; } /******************************************************************* @@ -5513,16 +5511,6 @@ NTSTATUS _samr_OemChangePasswordUser2(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_ChangePasswordUser2(pipes_struct *p, - struct samr_ChangePasswordUser2 *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_Connect2(pipes_struct *p, struct samr_Connect2 *r) { -- cgit From f965f324f599e50e701c91f1c45c70499ee5f037 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Feb 2008 17:28:01 +0100 Subject: Use pidl for _samr_QuerySecurity(). Guenther (This used to be commit c61cba97268f198ad7e25acc3cb0b166e897299d) --- source3/rpc_server/srv_samr.c | 23 +------------------- source3/rpc_server/srv_samr_nt.c | 47 +++++++++++++++------------------------- 2 files changed, 18 insertions(+), 52 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 38bbda3f3a..463181e16c 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -140,28 +140,7 @@ static bool api_samr_set_sec_obj(pipes_struct *p) static bool api_samr_query_sec_obj(pipes_struct *p) { - SAMR_Q_QUERY_SEC_OBJ q_u; - SAMR_R_QUERY_SEC_OBJ r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!samr_io_q_query_sec_obj("", &q_u, data, 0)) { - DEBUG(0,("api_samr_query_sec_obj: unable to unmarshall SAMR_Q_QUERY_SEC_OBJ.\n")); - return False; - } - - r_u.status = _samr_query_sec_obj(p, &q_u, &r_u); - - if(!samr_io_r_query_sec_obj("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_query_sec_obj: unable to marshall SAMR_R_QUERY_SEC_OBJ.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_QUERYSECURITY); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2ccb202aed..e688b6ae7f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -768,66 +768,63 @@ static bool check_change_pw_access(TALLOC_CTX *mem_ctx, DOM_SID *user_sid) /******************************************************************* - _samr_query_sec_obj + _samr_QuerySecurity ********************************************************************/ -NTSTATUS _samr_query_sec_obj(pipes_struct *p, SAMR_Q_QUERY_SEC_OBJ *q_u, SAMR_R_QUERY_SEC_OBJ *r_u) +NTSTATUS _samr_QuerySecurity(pipes_struct *p, + struct samr_QuerySecurity *r) { + NTSTATUS status; DOM_SID pol_sid; SEC_DESC * psd = NULL; uint32 acc_granted; size_t sd_size; - r_u->status = NT_STATUS_OK; - /* Get the SID. */ - if (!get_lsa_policy_samr_sid(p, &q_u->user_pol, &pol_sid, &acc_granted, NULL)) + if (!get_lsa_policy_samr_sid(p, r->in.handle, &pol_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - DEBUG(10,("_samr_query_sec_obj: querying security on SID: %s\n", + DEBUG(10,("_samr_QuerySecurity: querying security on SID: %s\n", sid_string_dbg(&pol_sid))); /* Check what typ of SID is beeing queried (e.g Domain SID, User SID, Group SID) */ /* To query the security of the SAM it self an invalid SID with S-0-0 is passed to this function */ if (pol_sid.sid_rev_num == 0) { - DEBUG(5,("_samr_query_sec_obj: querying security on SAM\n")); - r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); + DEBUG(5,("_samr_QuerySecurity: querying security on SAM\n")); + status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); } else if (sid_equal(&pol_sid,get_global_sam_sid())) { /* check if it is our domain SID */ - DEBUG(5,("_samr_query_sec_obj: querying security on Domain " + DEBUG(5,("_samr_QuerySecurity: querying security on Domain " "with SID: %s\n", sid_string_dbg(&pol_sid))); - r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0); + status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0); } else if (sid_equal(&pol_sid,&global_sid_Builtin)) { /* check if it is the Builtin Domain */ /* TODO: Builtin probably needs a different SD with restricted write access*/ - DEBUG(5,("_samr_query_sec_obj: querying security on Builtin " + DEBUG(5,("_samr_QuerySecurity: querying security on Builtin " "Domain with SID: %s\n", sid_string_dbg(&pol_sid))); - r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0); + status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0); } else if (sid_check_is_in_our_domain(&pol_sid) || sid_check_is_in_builtin(&pol_sid)) { /* TODO: different SDs have to be generated for aliases groups and users. Currently all three get a default user SD */ - DEBUG(10,("_samr_query_sec_obj: querying security on Object " + DEBUG(10,("_samr_QuerySecurity: querying security on Object " "with SID: %s\n", sid_string_dbg(&pol_sid))); if (check_change_pw_access(p->mem_ctx, &pol_sid)) { - r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, + status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, &pol_sid, SAMR_USR_RIGHTS_WRITE_PW); } else { - r_u->status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_nopwchange_generic_mapping, + status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_nopwchange_generic_mapping, &pol_sid, SAMR_USR_RIGHTS_CANT_WRITE_PW); } } else { return NT_STATUS_OBJECT_TYPE_MISMATCH; } - if ((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL) + if ((*r->out.sdbuf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL) return NT_STATUS_NO_MEMORY; - if (NT_STATUS_IS_OK(r_u->status)) - r_u->ptr = 1; - - return r_u->status; + return status; } /******************************************************************* @@ -5091,16 +5088,6 @@ NTSTATUS _samr_SetSecurity(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_QuerySecurity(pipes_struct *p, - struct samr_QuerySecurity *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_Shutdown(pipes_struct *p, struct samr_Shutdown *r) { -- cgit From 65172ba6b8efd6757c392d0957876d5d81f04348 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 1 Feb 2008 17:29:03 +0100 Subject: Use pidl for _samr_SetSecurity(). Guenther (This used to be commit 6bfd76002f083f07b3d9d5c1f16e67614e7eb972) --- source3/rpc_server/srv_samr.c | 23 +---------------------- source3/rpc_server/srv_samr_nt.c | 23 ++++++----------------- 2 files changed, 7 insertions(+), 39 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 463181e16c..94f7c6f153 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -110,28 +110,7 @@ static bool api_samr_get_usrdom_pwinfo(pipes_struct *p) static bool api_samr_set_sec_obj(pipes_struct *p) { - SAMR_Q_SET_SEC_OBJ q_u; - SAMR_R_SET_SEC_OBJ r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!samr_io_q_set_sec_obj("", &q_u, data, 0)) { - DEBUG(0,("api_samr_set_sec_obj: unable to unmarshall SAMR_Q_SET_SEC_OBJ.\n")); - return False; - } - - r_u.status = _samr_set_sec_obj(p, &q_u, &r_u); - - if(!samr_io_r_set_sec_obj("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_set_sec_obj: unable to marshall SAMR_R_SET_SEC_OBJ.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_SETSECURITY); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e688b6ae7f..c51aa39042 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -672,10 +672,11 @@ static bool get_lsa_policy_samr_sid( pipes_struct *p, POLICY_HND *pol, } /******************************************************************* - _samr_set_sec_obj + _samr_SetSecurity ********************************************************************/ -NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_SEC_OBJ *r_u) +NTSTATUS _samr_SetSecurity(pipes_struct *p, + struct samr_SetSecurity *r) { DOM_SID pol_sid; uint32 acc_granted, i; @@ -684,9 +685,7 @@ NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_ struct samu *sampass=NULL; NTSTATUS status; - r_u->status = NT_STATUS_OK; - - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid, &acc_granted, NULL)) + if (!get_lsa_policy_samr_sid(p, r->in.handle, &pol_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; if (!(sampass = samu_new( p->mem_ctx))) { @@ -705,7 +704,7 @@ NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_ return NT_STATUS_INVALID_HANDLE; } - dacl = q_u->buf->sd->dacl; + dacl = r->in.sdbuf->sd->dacl; for (i=0; i < dacl->num_aces; i++) { if (sid_equal(&pol_sid, &dacl->aces[i].trustee)) { ret = pdb_set_pass_can_change(sampass, @@ -721,7 +720,7 @@ NTSTATUS _samr_set_sec_obj(pipes_struct *p, SAMR_Q_SET_SEC_OBJ *q_u, SAMR_R_SET_ return NT_STATUS_ACCESS_DENIED; } - status = access_check_samr_function(acc_granted, SA_RIGHT_USER_SET_ATTRIBUTES, "_samr_set_sec_obj"); + status = access_check_samr_function(acc_granted, SA_RIGHT_USER_SET_ATTRIBUTES, "_samr_SetSecurity"); if (NT_STATUS_IS_OK(status)) { become_root(); status = pdb_update_sam_account(sampass); @@ -5078,16 +5077,6 @@ NTSTATUS _samr_Connect(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_SetSecurity(pipes_struct *p, - struct samr_SetSecurity *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_Shutdown(pipes_struct *p, struct samr_Shutdown *r) { -- cgit From 72d0deddc46a12363f930596e1823105caad5f24 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 10:10:12 +0100 Subject: Use pidl for _eventlog_GetNumRecords(). Guenther (This used to be commit af30a6373e7d85df4bb99e153588498938ddc368) --- source3/rpc_server/srv_eventlog.c | 22 +--------------------- source3/rpc_server/srv_eventlog_nt.c | 16 +++++----------- 2 files changed, 6 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c index 516ea134f2..96261b5635 100644 --- a/source3/rpc_server/srv_eventlog.c +++ b/source3/rpc_server/srv_eventlog.c @@ -72,27 +72,7 @@ static bool api_eventlog_close_eventlog(pipes_struct *p) static bool api_eventlog_get_num_records(pipes_struct *p) { - EVENTLOG_Q_GET_NUM_RECORDS q_u; - EVENTLOG_R_GET_NUM_RECORDS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!(eventlog_io_q_get_num_records("", &q_u, data, 0))) { - DEBUG(0, ("eventlog_io_q_get_num_records: unable to unmarshall EVENTLOG_Q_GET_NUM_RECORDS.\n")); - return False; - } - - r_u.status = _eventlog_get_num_records(p, &q_u, &r_u); - - if (!(eventlog_io_r_get_num_records("", &r_u, rdata, 0))) { - DEBUG(0, ("eventlog_io_r_get_num_records: unable to marshall EVENTLOG_R_GET_NUM_RECORDS.\n")); - return False; - } - - return True; + return proxy_eventlog_call(p, NDR_EVENTLOG_GETNUMRECORDS); } static bool api_eventlog_get_oldest_entry(pipes_struct *p) diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 7af8219a3e..2cc7d021ca 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -832,13 +832,13 @@ NTSTATUS _eventlog_get_oldest_entry( pipes_struct * p, } /******************************************************************** +_eventlog_GetNumRecords ********************************************************************/ -NTSTATUS _eventlog_get_num_records( pipes_struct * p, - EVENTLOG_Q_GET_NUM_RECORDS * q_u, - EVENTLOG_R_GET_NUM_RECORDS * r_u ) +NTSTATUS _eventlog_GetNumRecords(pipes_struct *p, + struct eventlog_GetNumRecords *r) { - EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); + EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, r->in.handle ); if (info == NULL) { return NT_STATUS_INVALID_HANDLE; @@ -847,7 +847,7 @@ NTSTATUS _eventlog_get_num_records( pipes_struct * p, if ( !( get_num_records_hook( info ) ) ) return NT_STATUS_ACCESS_DENIED; - r_u->num_records = info->num_records; + *r->out.number = info->num_records; return NT_STATUS_OK; } @@ -870,12 +870,6 @@ NTSTATUS _eventlog_DeregisterEventSource(pipes_struct *p, struct eventlog_Deregi return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _eventlog_GetNumRecords(pipes_struct *p, struct eventlog_GetNumRecords *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _eventlog_GetOldestRecord(pipes_struct *p, struct eventlog_GetOldestRecord *r) { p->rng_fault_state = True; -- cgit From 8d20f3f9995219ed9459b6c96a2c1285a2b9c204 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 10:44:51 +0100 Subject: Use pidl for _eventlog_GetOldestRecord(). Guenther (This used to be commit a6a5d99f5206dc4b94f3d0ecceb5198d66afdf41) --- source3/rpc_server/srv_eventlog.c | 22 +--------------------- source3/rpc_server/srv_eventlog_nt.c | 16 +++++----------- 2 files changed, 6 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c index 96261b5635..c64f97d9b5 100644 --- a/source3/rpc_server/srv_eventlog.c +++ b/source3/rpc_server/srv_eventlog.c @@ -77,27 +77,7 @@ static bool api_eventlog_get_num_records(pipes_struct *p) static bool api_eventlog_get_oldest_entry(pipes_struct *p) { - EVENTLOG_Q_GET_OLDEST_ENTRY q_u; - EVENTLOG_R_GET_OLDEST_ENTRY r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!(eventlog_io_q_get_oldest_entry("", &q_u, data, 0))) { - DEBUG(0, ("eventlog_io_q_get_oldest_entry: unable to unmarshall EVENTLOG_Q_GET_OLDEST_ENTRY.\n")); - return False; - } - - r_u.status = _eventlog_get_oldest_entry(p, &q_u, &r_u); - - if (!(eventlog_io_r_get_oldest_entry("", &r_u, rdata, 0))) { - DEBUG(0, ("eventlog_io_r_get_oldest_entry: unable to marshall EVENTLOG_R_GET_OLDEST_ENTRY.\n")); - return False; - } - - return True; + return proxy_eventlog_call(p, NDR_EVENTLOG_GETOLDESTRECORD); } static bool api_eventlog_read_eventlog(pipes_struct *p) diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 2cc7d021ca..423f3e55cb 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -811,13 +811,13 @@ NTSTATUS _eventlog_read_eventlog( pipes_struct * p, } /******************************************************************** + _eventlog_GetOldestRecord ********************************************************************/ -NTSTATUS _eventlog_get_oldest_entry( pipes_struct * p, - EVENTLOG_Q_GET_OLDEST_ENTRY * q_u, - EVENTLOG_R_GET_OLDEST_ENTRY * r_u ) +NTSTATUS _eventlog_GetOldestRecord(pipes_struct *p, + struct eventlog_GetOldestRecord *r) { - EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); + EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, r->in.handle ); if (info == NULL) { return NT_STATUS_INVALID_HANDLE; @@ -826,7 +826,7 @@ NTSTATUS _eventlog_get_oldest_entry( pipes_struct * p, if ( !( get_oldest_entry_hook( info ) ) ) return NT_STATUS_ACCESS_DENIED; - r_u->oldest_entry = info->oldest_entry; + *r->out.oldest_entry = info->oldest_entry; return NT_STATUS_OK; } @@ -870,12 +870,6 @@ NTSTATUS _eventlog_DeregisterEventSource(pipes_struct *p, struct eventlog_Deregi return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _eventlog_GetOldestRecord(pipes_struct *p, struct eventlog_GetOldestRecord *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _eventlog_ChangeNotify(pipes_struct *p, struct eventlog_ChangeNotify *r) { p->rng_fault_state = True; -- cgit From 48d2990d8c9bfb0037ee2b5386271398ee1492be Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 10:53:59 +0100 Subject: Use pidl for _eventlog_ClearEventLogW(). Guenther (This used to be commit 70a4ba798cdd3b4daa01c2f6aa693de34288c8b9) --- source3/rpc_server/srv_eventlog.c | 22 +--------------------- source3/rpc_server/srv_eventlog_nt.c | 28 ++++++++-------------------- 2 files changed, 9 insertions(+), 41 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c index c64f97d9b5..38a9baa80d 100644 --- a/source3/rpc_server/srv_eventlog.c +++ b/source3/rpc_server/srv_eventlog.c @@ -107,27 +107,7 @@ static bool api_eventlog_read_eventlog(pipes_struct *p) static bool api_eventlog_clear_eventlog(pipes_struct *p) { - EVENTLOG_Q_CLEAR_EVENTLOG q_u; - EVENTLOG_R_CLEAR_EVENTLOG r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!(eventlog_io_q_clear_eventlog("", &q_u, data, 0))) { - DEBUG(0, ("eventlog_io_q_clear_eventlog: unable to unmarshall EVENTLOG_Q_CLEAR_EVENTLOG.\n")); - return False; - } - - r_u.status = _eventlog_clear_eventlog(p, &q_u, &r_u); - - if (!(eventlog_io_r_clear_eventlog("", &r_u, rdata, 0))) { - DEBUG(0, ("eventlog_io_q_clear_eventlog: unable to marshall EVENTLOG_Q_CLEAR_EVENTLOG.\n")); - return False; - } - - return True; + return proxy_eventlog_call(p, NDR_EVENTLOG_CLEAREVENTLOGW); } /* diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 423f3e55cb..9250c0fa4f 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -659,28 +659,22 @@ NTSTATUS _eventlog_open_eventlog( pipes_struct * p, } /******************************************************************** + _eventlog_ClearEventLogW This call still needs some work ********************************************************************/ -NTSTATUS _eventlog_clear_eventlog( pipes_struct * p, - EVENTLOG_Q_CLEAR_EVENTLOG * q_u, - EVENTLOG_R_CLEAR_EVENTLOG * r_u ) +NTSTATUS _eventlog_ClearEventLogW(pipes_struct *p, + struct eventlog_ClearEventLogW *r) { - EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, &q_u->handle ); - char *backup_file_name = NULL; + EVENTLOG_INFO *info = find_eventlog_info_by_hnd( p, r->in.handle ); + const char *backup_file_name = NULL; if ( !info ) return NT_STATUS_INVALID_HANDLE; - if (q_u->backupfile.string) { - size_t len = rpcstr_pull_talloc(p->mem_ctx, - &backup_file_name, - q_u->backupfile.string->buffer, - q_u->backupfile.string->uni_str_len * 2, - 0 ); - if (len == (size_t)-1 || !backup_file_name) { - return NT_STATUS_INVALID_PARAMETER; - } + if (r->in.backupfile && r->in.backupfile->string) { + + backup_file_name = r->in.backupfile->string; DEBUG(8,( "_eventlog_clear_eventlog: Using [%s] as the backup " "file name for log [%s].", @@ -852,12 +846,6 @@ NTSTATUS _eventlog_GetNumRecords(pipes_struct *p, return NT_STATUS_OK; } -NTSTATUS _eventlog_ClearEventLogW(pipes_struct *p, struct eventlog_ClearEventLogW *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _eventlog_BackupEventLogW(pipes_struct *p, struct eventlog_BackupEventLogW *r) { p->rng_fault_state = True; -- cgit From 221a2a9a5f974fd428e83753af1b70f37332e184 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 10:55:14 +0100 Subject: Copy inline comment for _eventlog_ClearEventLogW() from rpc_parse to rpc_server. Guenther (This used to be commit 26eadadbf628f4d3aa4cd0ab4b55d47dc79c80ba) --- source3/rpc_server/srv_eventlog_nt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 9250c0fa4f..1d9925a555 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -662,6 +662,19 @@ NTSTATUS _eventlog_open_eventlog( pipes_struct * p, _eventlog_ClearEventLogW This call still needs some work ********************************************************************/ +/** The windows client seems to be doing something funny with the file name + A call like + ClearEventLog(handle, "backup_file") + on the client side will result in the backup file name looking like this on the + server side: + \??\${CWD of client}\backup_file + If an absolute path gets specified, such as + ClearEventLog(handle, "C:\\temp\\backup_file") + then it is still mangled by the client into this: + \??\C:\temp\backup_file + when it is on the wire. + I'm not sure where the \?? is coming from, or why the ${CWD} of the client process + would be added in given that the backup file gets written on the server side. */ NTSTATUS _eventlog_ClearEventLogW(pipes_struct *p, struct eventlog_ClearEventLogW *r) -- cgit From 5ab6d66f13c9c11e4757f8d0a476b94116d74069 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 11:10:18 +0100 Subject: Use pidl for _eventlog_OpenEventLogW(). Guenther (This used to be commit ef293be6cb95225f10e8062b3089dc1bbe5fd013) --- source3/rpc_server/srv_eventlog.c | 22 +--------------------- source3/rpc_server/srv_eventlog_nt.c | 35 ++++++++++++----------------------- 2 files changed, 13 insertions(+), 44 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c index 38a9baa80d..5679a6acb6 100644 --- a/source3/rpc_server/srv_eventlog.c +++ b/source3/rpc_server/srv_eventlog.c @@ -42,27 +42,7 @@ static bool proxy_eventlog_call(pipes_struct *p, uint8 opnum) static bool api_eventlog_open_eventlog(pipes_struct *p) { - EVENTLOG_Q_OPEN_EVENTLOG q_u; - EVENTLOG_R_OPEN_EVENTLOG r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!(eventlog_io_q_open_eventlog("", &q_u, data, 0))) { - DEBUG(0, ("eventlog_io_q_open_eventlog: unable to unmarshall EVENTLOG_Q_OPEN_EVENTLOG.\n")); - return False; - } - - r_u.status = _eventlog_open_eventlog(p, &q_u, &r_u); - - if (!(eventlog_io_r_open_eventlog("", &r_u, rdata, 0))) { - DEBUG(0, ("eventlog_io_r_open_eventlog: unable to marshall EVENTLOG_R_OPEN_EVENTLOG.\n")); - return False; - } - - return True; + return proxy_eventlog_call(p, NDR_EVENTLOG_OPENEVENTLOGW); } static bool api_eventlog_close_eventlog(pipes_struct *p) diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 1d9925a555..06697153b8 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -610,28 +610,23 @@ static bool add_record_to_resp( EVENTLOG_R_READ_EVENTLOG * r_u, } /******************************************************************** + _eventlog_OpenEventLogW ********************************************************************/ -NTSTATUS _eventlog_open_eventlog( pipes_struct * p, - EVENTLOG_Q_OPEN_EVENTLOG * q_u, - EVENTLOG_R_OPEN_EVENTLOG * r_u ) +NTSTATUS _eventlog_OpenEventLogW(pipes_struct *p, + struct eventlog_OpenEventLogW *r) { - fstring servername, logname; + const char *servername = ""; + const char *logname = ""; EVENTLOG_INFO *info; NTSTATUS result; - fstrcpy( servername, "" ); - if ( q_u->servername.string ) { - rpcstr_pull( servername, q_u->servername.string->buffer, - sizeof( servername ), - q_u->servername.string->uni_str_len * 2, 0 ); + if (r->in.servername->string) { + servername = r->in.servername->string; } - fstrcpy( logname, "" ); - if ( q_u->logname.string ) { - rpcstr_pull( logname, q_u->logname.string->buffer, - sizeof( logname ), - q_u->logname.string->uni_str_len * 2, 0 ); + if (r->in.logname->string) { + logname = r->in.logname->string; } DEBUG( 10,("_eventlog_open_eventlog: Server [%s], Log [%s]\n", @@ -640,13 +635,13 @@ NTSTATUS _eventlog_open_eventlog( pipes_struct * p, /* according to MSDN, if the logfile cannot be found, we should default to the "Application" log */ - if ( !NT_STATUS_IS_OK( result = elog_open( p, logname, &r_u->handle )) ) + if ( !NT_STATUS_IS_OK( result = elog_open( p, logname, r->out.handle )) ) return result; - if ( !(info = find_eventlog_info_by_hnd( p, &r_u->handle )) ) { + if ( !(info = find_eventlog_info_by_hnd( p, r->out.handle )) ) { DEBUG(0,("_eventlog_open_eventlog: eventlog (%s) opened but unable to find handle!\n", logname )); - elog_close( p, &r_u->handle ); + elog_close( p, r->out.handle ); return NT_STATUS_INVALID_HANDLE; } @@ -877,12 +872,6 @@ NTSTATUS _eventlog_ChangeNotify(pipes_struct *p, struct eventlog_ChangeNotify *r return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _eventlog_OpenEventLogW(pipes_struct *p, struct eventlog_OpenEventLogW *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _eventlog_RegisterEventSourceW(pipes_struct *p, struct eventlog_RegisterEventSourceW *r) { p->rng_fault_state = True; -- cgit From a31829ffcd7e768484122094a3bde60fb6d1f44e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 11:33:06 +0100 Subject: Remove unused arguments in read_package_entry() in the eventlog rpc server. Guenther (This used to be commit c2e786d4e2cb53b5a8be45278f221acaa7f5122a) --- source3/rpc_server/srv_eventlog_nt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_nt.c b/source3/rpc_server/srv_eventlog_nt.c index 06697153b8..0e2bcf4126 100644 --- a/source3/rpc_server/srv_eventlog_nt.c +++ b/source3/rpc_server/srv_eventlog_nt.c @@ -493,8 +493,6 @@ done: ********************************************************************/ static Eventlog_entry *read_package_entry( prs_struct * ps, - EVENTLOG_Q_READ_EVENTLOG * q_u, - EVENTLOG_R_READ_EVENTLOG * r_u, Eventlog_entry * entry ) { uint8 *offset; @@ -773,7 +771,7 @@ NTSTATUS _eventlog_read_eventlog( pipes_struct * p, /* Now see if there is enough room to add */ - if ( !(ee_new = read_package_entry( ps, q_u, r_u, entry )) ) + if ( !(ee_new = read_package_entry( ps, entry )) ) return NT_STATUS_NO_MEMORY; if ( r_u->num_bytes_in_resp + ee_new->record.length > q_u->max_read_size ) { -- cgit From 2730ce999707be0e2308c07568fe38e3a07df41f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 16:17:20 +0100 Subject: Use pidl for _samr_Connect(). Guenther (This used to be commit 79c3aa6588c6d79a2127153dc0bcc75ecc468de8) --- source3/rpc_server/srv_samr.c | 24 +----------------------- source3/rpc_server/srv_samr_nt.c | 30 ++++++++---------------------- 2 files changed, 9 insertions(+), 45 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 94f7c6f153..5fb16fe14a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -461,29 +461,7 @@ static bool api_samr_create_user(pipes_struct *p) static bool api_samr_connect_anon(pipes_struct *p) { - SAMR_Q_CONNECT_ANON q_u; - SAMR_R_CONNECT_ANON r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the samr open policy */ - if(!samr_io_q_connect_anon("", &q_u, data, 0)) { - DEBUG(0,("api_samr_connect_anon: unable to unmarshall SAMR_Q_CONNECT_ANON.\n")); - return False; - } - - r_u.status = _samr_connect_anon(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_connect_anon("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_connect_anon: unable to marshall SAMR_R_CONNECT_ANON.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_CONNECT); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c51aa39042..b4eab90996 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2653,26 +2653,24 @@ NTSTATUS _samr_CreateUser2(pipes_struct *p, } /******************************************************************* - samr_reply_connect_anon + _samr_Connect ********************************************************************/ -NTSTATUS _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CONNECT_ANON *r_u) +NTSTATUS _samr_Connect(pipes_struct *p, + struct samr_Connect *r) { struct samr_info *info = NULL; - uint32 des_access = q_u->access_mask; + uint32 des_access = r->in.access_mask; /* Access check */ if (!pipe_access_check(p)) { - DEBUG(3, ("access denied to samr_connect_anon\n")); - r_u->status = NT_STATUS_ACCESS_DENIED; - return r_u->status; + DEBUG(3, ("access denied to _samr_Connect\n")); + return NT_STATUS_ACCESS_DENIED; } /* set up the SAMR connect_anon response */ - r_u->status = NT_STATUS_OK; - /* associate the user's SID with the new handle. */ if ((info = get_samr_info_by_sid(NULL)) == NULL) return NT_STATUS_NO_MEMORY; @@ -2688,14 +2686,12 @@ NTSTATUS _samr_connect_anon(pipes_struct *p, SAMR_Q_CONNECT_ANON *q_u, SAMR_R_CO se_map_generic( &des_access, &sam_generic_mapping ); info->acc_granted = des_access & (SA_RIGHT_SAM_ENUM_DOMAINS|SA_RIGHT_SAM_OPEN_DOMAIN); - - info->status = q_u->unknown_0; /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) + if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - return r_u->status; + return NT_STATUS_OK; } /******************************************************************* @@ -5067,16 +5063,6 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R /**************************************************************** ****************************************************************/ -NTSTATUS _samr_Connect(pipes_struct *p, - struct samr_Connect *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_Shutdown(pipes_struct *p, struct samr_Shutdown *r) { -- cgit From 390746afeac135e29801ed16cad80553fcdd5c78 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 16:23:46 +0100 Subject: Use pidl for _samr_Connect2(). Guenther (This used to be commit 35a691c2595883a7f15d039839de11798b9a7ceb) --- source3/rpc_server/srv_samr.c | 24 +----------------------- source3/rpc_server/srv_samr_nt.c | 36 ++++++++++++------------------------ 2 files changed, 13 insertions(+), 47 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 5fb16fe14a..5e83687ad3 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -470,29 +470,7 @@ static bool api_samr_connect_anon(pipes_struct *p) static bool api_samr_connect(pipes_struct *p) { - SAMR_Q_CONNECT q_u; - SAMR_R_CONNECT r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the samr open policy */ - if(!samr_io_q_connect("", &q_u, data, 0)) { - DEBUG(0,("api_samr_connect: unable to unmarshall SAMR_Q_CONNECT.\n")); - return False; - } - - r_u.status = _samr_connect(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_connect("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_connect: unable to marshall SAMR_R_CONNECT.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_CONNECT2); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b4eab90996..d69e2d1cdc 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2695,54 +2695,52 @@ NTSTATUS _samr_Connect(pipes_struct *p, } /******************************************************************* - samr_reply_connect + _samr_Connect2 ********************************************************************/ -NTSTATUS _samr_connect(pipes_struct *p, SAMR_Q_CONNECT *q_u, SAMR_R_CONNECT *r_u) +NTSTATUS _samr_Connect2(pipes_struct *p, + struct samr_Connect2 *r) { struct samr_info *info = NULL; SEC_DESC *psd = NULL; uint32 acc_granted; - uint32 des_access = q_u->access_mask; + uint32 des_access = r->in.access_mask; NTSTATUS nt_status; size_t sd_size; - DEBUG(5,("_samr_connect: %d\n", __LINE__)); + DEBUG(5,("_samr_Connect2: %d\n", __LINE__)); /* Access check */ if (!pipe_access_check(p)) { - DEBUG(3, ("access denied to samr_connect\n")); - r_u->status = NT_STATUS_ACCESS_DENIED; - return r_u->status; + DEBUG(3, ("access denied to _samr_Connect2\n")); + return NT_STATUS_ACCESS_DENIED; } make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); se_map_generic(&des_access, &sam_generic_mapping); nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, - NULL, 0, des_access, &acc_granted, "_samr_connect"); + NULL, 0, des_access, &acc_granted, "_samr_Connect2"); if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; - r_u->status = NT_STATUS_OK; - /* associate the user's SID and access granted with the new handle. */ if ((info = get_samr_info_by_sid(NULL)) == NULL) return NT_STATUS_NO_MEMORY; info->acc_granted = acc_granted; - info->status = q_u->access_mask; + info->status = r->in.access_mask; /* this looks so wrong... - gd */ /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) + if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - DEBUG(5,("_samr_connect: %d\n", __LINE__)); + DEBUG(5,("_samr_Connect2: %d\n", __LINE__)); - return r_u->status; + return nt_status; } /******************************************************************* @@ -5473,16 +5471,6 @@ NTSTATUS _samr_OemChangePasswordUser2(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_Connect2(pipes_struct *p, - struct samr_Connect2 *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_SetUserInfo2(pipes_struct *p, struct samr_SetUserInfo2 *r) { -- cgit From 867edaa33f7fb152447712bc405380ad6669781b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 16:35:32 +0100 Subject: Use pidl for _samr_Connect4(). Guenther (This used to be commit ceb3b6a0a3ed15c04bdb518a28167531403cc928) --- source3/rpc_server/srv_samr.c | 24 +----------------------- source3/rpc_server/srv_samr_nt.c | 36 ++++++++++++------------------------ 2 files changed, 13 insertions(+), 47 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 5e83687ad3..73a1228b68 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -479,29 +479,7 @@ static bool api_samr_connect(pipes_struct *p) static bool api_samr_connect4(pipes_struct *p) { - SAMR_Q_CONNECT4 q_u; - SAMR_R_CONNECT4 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the samr open policy */ - if(!samr_io_q_connect4("", &q_u, data, 0)) { - DEBUG(0,("api_samr_connect4: unable to unmarshall SAMR_Q_CONNECT4.\n")); - return False; - } - - r_u.status = _samr_connect4(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_connect4("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_connect4: unable to marshall SAMR_R_CONNECT4.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_CONNECT4); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d69e2d1cdc..3531001a58 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2744,54 +2744,52 @@ NTSTATUS _samr_Connect2(pipes_struct *p, } /******************************************************************* - samr_connect4 + _samr_Connect4 ********************************************************************/ -NTSTATUS _samr_connect4(pipes_struct *p, SAMR_Q_CONNECT4 *q_u, SAMR_R_CONNECT4 *r_u) +NTSTATUS _samr_Connect4(pipes_struct *p, + struct samr_Connect4 *r) { struct samr_info *info = NULL; SEC_DESC *psd = NULL; uint32 acc_granted; - uint32 des_access = q_u->access_mask; + uint32 des_access = r->in.access_mask; NTSTATUS nt_status; size_t sd_size; - DEBUG(5,("_samr_connect4: %d\n", __LINE__)); + DEBUG(5,("_samr_Connect4: %d\n", __LINE__)); /* Access check */ if (!pipe_access_check(p)) { - DEBUG(3, ("access denied to samr_connect4\n")); - r_u->status = NT_STATUS_ACCESS_DENIED; - return r_u->status; + DEBUG(3, ("access denied to samr_Connect4\n")); + return NT_STATUS_ACCESS_DENIED; } make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); se_map_generic(&des_access, &sam_generic_mapping); nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, - NULL, 0, des_access, &acc_granted, "_samr_connect4"); + NULL, 0, des_access, &acc_granted, "_samr_Connect4"); if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; - r_u->status = NT_STATUS_OK; - /* associate the user's SID and access granted with the new handle. */ if ((info = get_samr_info_by_sid(NULL)) == NULL) return NT_STATUS_NO_MEMORY; info->acc_granted = acc_granted; - info->status = q_u->access_mask; + info->status = r->in.access_mask; /* ??? */ /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->connect_pol, free_samr_info, (void *)info)) + if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - DEBUG(5,("_samr_connect: %d\n", __LINE__)); + DEBUG(5,("_samr_Connect4: %d\n", __LINE__)); - return r_u->status; + return NT_STATUS_OK; } /******************************************************************* @@ -5511,16 +5509,6 @@ NTSTATUS _samr_Connect3(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_Connect4(pipes_struct *p, - struct samr_Connect4 *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_ChangePasswordUser3(pipes_struct *p, struct samr_ChangePasswordUser3 *r) { -- cgit From e1e8ab30f712d389a353cf32cbf8cf1083360b2a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 17:10:16 +0100 Subject: Use pidl for _samr_Connect5(). Guenther (This used to be commit ca233bfe0e5350cb699312e4937c6bd1cb43f7c1) --- source3/rpc_server/srv_samr.c | 24 +-------------------- source3/rpc_server/srv_samr_nt.c | 45 ++++++++++++++++------------------------ 2 files changed, 19 insertions(+), 50 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 73a1228b68..dd162c7479 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -519,29 +519,7 @@ static bool api_samr_chgpasswd_user3(pipes_struct *p) static bool api_samr_connect5(pipes_struct *p) { - SAMR_Q_CONNECT5 q_u; - SAMR_R_CONNECT5 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the samr open policy */ - if(!samr_io_q_connect5("", &q_u, data, 0)) { - DEBUG(0,("api_samr_connect5: unable to unmarshall SAMR_Q_CONNECT5.\n")); - return False; - } - - r_u.status = _samr_connect5(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_connect5("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_connect5: unable to marshall SAMR_R_CONNECT5.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_CONNECT5); } /********************************************************************** diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 3531001a58..4e0487f7ff 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2793,37 +2793,34 @@ NTSTATUS _samr_Connect4(pipes_struct *p, } /******************************************************************* - samr_connect5 + _samr_Connect5 ********************************************************************/ -NTSTATUS _samr_connect5(pipes_struct *p, SAMR_Q_CONNECT5 *q_u, SAMR_R_CONNECT5 *r_u) +NTSTATUS _samr_Connect5(pipes_struct *p, + struct samr_Connect5 *r) { struct samr_info *info = NULL; SEC_DESC *psd = NULL; uint32 acc_granted; - uint32 des_access = q_u->access_mask; + uint32 des_access = r->in.access_mask; NTSTATUS nt_status; - POLICY_HND pol; size_t sd_size; + struct samr_ConnectInfo1 info1; - - DEBUG(5,("_samr_connect5: %d\n", __LINE__)); - - ZERO_STRUCTP(r_u); + DEBUG(5,("_samr_Connect5: %d\n", __LINE__)); /* Access check */ if (!pipe_access_check(p)) { - DEBUG(3, ("access denied to samr_connect5\n")); - r_u->status = NT_STATUS_ACCESS_DENIED; - return r_u->status; + DEBUG(3, ("access denied to samr_Connect5\n")); + return NT_STATUS_ACCESS_DENIED; } make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); se_map_generic(&des_access, &sam_generic_mapping); nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, - NULL, 0, des_access, &acc_granted, "_samr_connect5"); + NULL, 0, des_access, &acc_granted, "_samr_Connect5"); if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; @@ -2833,17 +2830,21 @@ NTSTATUS _samr_connect5(pipes_struct *p, SAMR_Q_CONNECT5 *q_u, SAMR_R_CONNECT5 * return NT_STATUS_NO_MEMORY; info->acc_granted = acc_granted; - info->status = q_u->access_mask; + info->status = r->in.access_mask; /* ??? */ /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &pol, free_samr_info, (void *)info)) + if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; - DEBUG(5,("_samr_connect: %d\n", __LINE__)); + DEBUG(5,("_samr_Connect5: %d\n", __LINE__)); - init_samr_r_connect5(r_u, &pol, NT_STATUS_OK); + info1.unknown1 = 3; + info1.unknown2 = 0; - return r_u->status; + *r->out.level_out = 1; + r->out.info_out->info1 = info1; + + return NT_STATUS_OK; } /********************************************************************** @@ -5519,16 +5520,6 @@ NTSTATUS _samr_ChangePasswordUser3(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_Connect5(pipes_struct *p, - struct samr_Connect5 *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_RidToSid(pipes_struct *p, struct samr_RidToSid *r) { -- cgit From 4906b5037d09beceee67a455177269215c140206 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 18:09:35 +0100 Subject: Use pidl for _samr_DeleteGroupMember(). Guenther (This used to be commit 94d6536809266ea3a12cd255fb7f2f7a70c42da3) --- source3/rpc_server/srv_samr.c | 23 +---------------------- source3/rpc_server/srv_samr_nt.c | 30 ++++++++++++------------------ 2 files changed, 13 insertions(+), 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index dd162c7479..ddefa569cf 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -840,28 +840,7 @@ static bool api_samr_add_groupmem(pipes_struct *p) static bool api_samr_del_groupmem(pipes_struct *p) { - SAMR_Q_DEL_GROUPMEM q_u; - SAMR_R_DEL_GROUPMEM r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_del_groupmem("", &q_u, data, 0)) { - DEBUG(0,("api_samr_del_groupmem: unable to unmarshall SAMR_Q_DEL_GROUPMEM.\n")); - return False; - } - - r_u.status = _samr_del_groupmem(p, &q_u, &r_u); - - if (!samr_io_r_del_groupmem("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_del_groupmem: unable to marshall SAMR_R_DEL_GROUPMEM.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_DELETEGROUPMEMBER); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 4e0487f7ff..e394dc1d57 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4101,11 +4101,14 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD } /********************************************************************* - _samr_del_groupmem + _samr_DeleteGroupMember *********************************************************************/ -NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DEL_GROUPMEM *r_u) +NTSTATUS _samr_DeleteGroupMember(pipes_struct *p, + struct samr_DeleteGroupMember *r) + { + NTSTATUS status; DOM_SID group_sid; uint32 group_rid; uint32 acc_granted; @@ -4114,17 +4117,18 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE DISP_INFO *disp_info = NULL; /* - * delete the group member named q_u->rid + * delete the group member named r->in.rid * who is a member of the sid associated with the handle * the rid is a user's rid as the group is a domain group. */ /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_REMOVE_MEMBER, "_samr_del_groupmem"))) { - return r_u->status; + status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_REMOVE_MEMBER, "_samr_DeleteGroupMember"); + if (!NT_STATUS_IS_OK(status)) { + return status; } if (!sid_peek_check_rid(get_global_sam_sid(), &group_sid, @@ -4140,7 +4144,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE if ( can_add_accounts ) become_root(); - r_u->status = pdb_del_groupmem(p->mem_ctx, group_rid, q_u->rid); + status = pdb_del_groupmem(p->mem_ctx, group_rid, r->in.rid); if ( can_add_accounts ) unbecome_root(); @@ -4149,7 +4153,7 @@ NTSTATUS _samr_del_groupmem(pipes_struct *p, SAMR_Q_DEL_GROUPMEM *q_u, SAMR_R_DE force_flush_samr_cache(disp_info); - return r_u->status; + return status; } /********************************************************************* @@ -5210,16 +5214,6 @@ NTSTATUS _samr_AddGroupMember(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_DeleteGroupMember(pipes_struct *p, - struct samr_DeleteGroupMember *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_QueryGroupMember(pipes_struct *p, struct samr_QueryGroupMember *r) { -- cgit From 062820eaee624ac1c02e695d26b5ad4a0b0f66d9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 18:36:44 +0100 Subject: Use pidl for _samr_AddGroupMember(). Guenther (This used to be commit 4f923d970eac5841d1f67dbb8fc0c1dd1fda95a3) --- source3/rpc_server/srv_samr.c | 23 +---------------------- source3/rpc_server/srv_samr_nt.c | 31 ++++++++++++------------------- 2 files changed, 13 insertions(+), 41 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index ddefa569cf..15cbf4cb61 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -810,28 +810,7 @@ static bool api_samr_del_aliasmem(pipes_struct *p) static bool api_samr_add_groupmem(pipes_struct *p) { - SAMR_Q_ADD_GROUPMEM q_u; - SAMR_R_ADD_GROUPMEM r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_add_groupmem("", &q_u, data, 0)) { - DEBUG(0,("api_samr_add_groupmem: unable to unmarshall SAMR_Q_ADD_GROUPMEM.\n")); - return False; - } - - r_u.status = _samr_add_groupmem(p, &q_u, &r_u); - - if (!samr_io_r_add_groupmem("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_add_groupmem: unable to marshall SAMR_R_ADD_GROUPMEM.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_ADDGROUPMEMBER); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e394dc1d57..95c31ebc8b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4053,11 +4053,13 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE } /********************************************************************* - _samr_add_groupmem + _samr_AddGroupMember *********************************************************************/ -NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_ADD_GROUPMEM *r_u) +NTSTATUS _samr_AddGroupMember(pipes_struct *p, + struct samr_AddGroupMember *r) { + NTSTATUS status; DOM_SID group_sid; uint32 group_rid; uint32 acc_granted; @@ -4066,11 +4068,12 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_ADD_MEMBER, "_samr_add_groupmem"))) { - return r_u->status; + + status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_ADD_MEMBER, "_samr_AddGroupMember"); + if (!NT_STATUS_IS_OK(status)) { + return status; } DEBUG(10, ("sid is %s\n", sid_string_dbg(&group_sid))); @@ -4088,8 +4091,8 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD if ( can_add_accounts ) become_root(); - r_u->status = pdb_add_groupmem(p->mem_ctx, group_rid, q_u->rid); - + status = pdb_add_groupmem(p->mem_ctx, group_rid, r->in.rid); + if ( can_add_accounts ) unbecome_root(); @@ -4097,7 +4100,7 @@ NTSTATUS _samr_add_groupmem(pipes_struct *p, SAMR_Q_ADD_GROUPMEM *q_u, SAMR_R_AD force_flush_samr_cache(disp_info); - return r_u->status; + return status; } /********************************************************************* @@ -5204,16 +5207,6 @@ NTSTATUS _samr_SetGroupInfo(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_AddGroupMember(pipes_struct *p, - struct samr_AddGroupMember *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_QueryGroupMember(pipes_struct *p, struct samr_QueryGroupMember *r) { -- cgit From c6eddfee89891e0d37031e5bf50a66e31b7db67d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 21:00:16 +0100 Subject: Use pidl for _lsa_OpenPolicy(). Guenther (This used to be commit b6b226e6365477f855de1e549ef32df452838031) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 15 +++++---------- 2 files changed, 6 insertions(+), 33 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index b433ac2c8f..7a5eca4e0f 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -83,29 +83,7 @@ api_lsa_open_policy static bool api_lsa_open_policy(pipes_struct *p) { - LSA_Q_OPEN_POL q_u; - LSA_R_OPEN_POL r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the server, object attributes and desired access flag...*/ - if(!lsa_io_q_open_pol("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_open_policy: unable to unmarshall LSA_Q_OPEN_POL.\n")); - return False; - } - - r_u.status = _lsa_open_policy(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_open_pol("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_open_policy: unable to marshall LSA_R_OPEN_POL.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_OPENPOLICY); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 20cafbd0af..6c2bf200a0 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -565,15 +565,16 @@ NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL } /*************************************************************************** - _lsa_open_policy + _lsa_OpenPolicy ***************************************************************************/ -NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL *r_u) +NTSTATUS _lsa_OpenPolicy(pipes_struct *p, + struct lsa_OpenPolicy *r) { struct lsa_info *info; SEC_DESC *psd = NULL; size_t sd_size; - uint32 des_access=q_u->des_access; + uint32 des_access= r->in.access_mask; uint32 acc_granted; NTSTATUS status; @@ -603,7 +604,7 @@ NTSTATUS _lsa_open_policy(pipes_struct *p, LSA_Q_OPEN_POL *q_u, LSA_R_OPEN_POL * info->access = acc_granted; /* set up the LSA QUERY INFO response */ - if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info)) + if (!create_policy_hnd(p, r->out.handle, free_lsa_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; return NT_STATUS_OK; @@ -2211,12 +2212,6 @@ NTSTATUS _lsa_ChangePassword(pipes_struct *p, struct lsa_ChangePassword *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_OpenPolicy(pipes_struct *p, struct lsa_OpenPolicy *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, struct lsa_QueryInfoPolicy *r) { p->rng_fault_state = True; -- cgit From 6a77f8d2d9333b33d4721a8b4043b5f58a9c0bb4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 21:00:38 +0100 Subject: Use pidl for _lsa_OpenPolicy2(). Guenther (This used to be commit fc29364abe10d3ec249602cb3437e50294f5de76) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 15 +++++---------- 2 files changed, 6 insertions(+), 33 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 7a5eca4e0f..5084bf915c 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -52,29 +52,7 @@ static bool proxy_lsa_call(pipes_struct *p, uint8 opnum) static bool api_lsa_open_policy2(pipes_struct *p) { - LSA_Q_OPEN_POL2 q_u; - LSA_R_OPEN_POL2 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the server, object attributes and desired access flag...*/ - if(!lsa_io_q_open_pol2("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_open_policy2: unable to unmarshall LSA_Q_OPEN_POL2.\n")); - return False; - } - - r_u.status = _lsa_open_policy2(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_open_pol2("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_open_policy2: unable to marshall LSA_R_OPEN_POL2.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_OPENPOLICY2); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 6c2bf200a0..076e7aabed 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -516,15 +516,16 @@ static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, /*************************************************************************** - _lsa_open_policy2. + _lsa_OpenPolicy2 ***************************************************************************/ -NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL2 *r_u) +NTSTATUS _lsa_OpenPolicy2(pipes_struct *p, + struct lsa_OpenPolicy2 *r) { struct lsa_info *info; SEC_DESC *psd = NULL; size_t sd_size; - uint32 des_access=q_u->des_access; + uint32 des_access = r->in.access_mask; uint32 acc_granted; NTSTATUS status; @@ -558,7 +559,7 @@ NTSTATUS _lsa_open_policy2(pipes_struct *p, LSA_Q_OPEN_POL2 *q_u, LSA_R_OPEN_POL info->access = acc_granted; /* set up the LSA QUERY INFO response */ - if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info)) + if (!create_policy_hnd(p, r->out.handle, free_lsa_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; return NT_STATUS_OK; @@ -2404,12 +2405,6 @@ NTSTATUS _lsa_RetrievePrivateData(pipes_struct *p, struct lsa_RetrievePrivateDat return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_OpenPolicy2(pipes_struct *p, struct lsa_OpenPolicy2 *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_GetUserName(pipes_struct *p, struct lsa_GetUserName *r) { p->rng_fault_state = True; -- cgit From a64cd55101ca69d7d8855964cb2b8864e039cac3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 21:13:19 +0100 Subject: Use pidl for _lsa_QuerySecurity(). Guenther (This used to be commit 6b2f205844b1e2af4c74247fed13d6e383319067) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 25 ++++++++----------------- 2 files changed, 9 insertions(+), 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 5084bf915c..94fc9b806a 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -547,29 +547,7 @@ static bool api_lsa_removeprivs(pipes_struct *p) static bool api_lsa_query_secobj(pipes_struct *p) { - LSA_Q_QUERY_SEC_OBJ q_u; - LSA_R_QUERY_SEC_OBJ r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_query_sec_obj("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_query_secobj: failed to unmarshall LSA_Q_QUERY_SEC_OBJ.\n")); - return False; - } - - r_u.status = _lsa_query_secobj(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_query_sec_obj("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_query_secobj: Failed to marshall LSA_R_QUERY_SEC_OBJ.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_QUERYSECURITY); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 076e7aabed..0799d2ddf6 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1866,20 +1866,19 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP } /*************************************************************************** - For a given SID, remove some privileges. + _lsa_QuerySecurity ***************************************************************************/ -NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUERY_SEC_OBJ *r_u) +NTSTATUS _lsa_QuerySecurity(pipes_struct *p, + struct lsa_QuerySecurity *r) { struct lsa_info *handle=NULL; SEC_DESC *psd = NULL; size_t sd_size; NTSTATUS status; - r_u->status = NT_STATUS_OK; - /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ @@ -1887,7 +1886,7 @@ NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUER return NT_STATUS_ACCESS_DENIED; - switch (q_u->sec_info) { + switch (r->in.sec_info) { case 1: /* SD contains only the owner */ @@ -1896,7 +1895,7 @@ NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUER return NT_STATUS_NO_MEMORY; - if((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL) + if((*r->out.sdbuf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL) return NT_STATUS_NO_MEMORY; break; case 4: @@ -1906,16 +1905,14 @@ NTSTATUS _lsa_query_secobj(pipes_struct *p, LSA_Q_QUERY_SEC_OBJ *q_u, LSA_R_QUER if(!NT_STATUS_IS_OK(status)) return NT_STATUS_NO_MEMORY; - if((r_u->buf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL) + if((*r->out.sdbuf = make_sec_desc_buf(p->mem_ctx, sd_size, psd)) == NULL) return NT_STATUS_NO_MEMORY; break; default: return NT_STATUS_INVALID_LEVEL; } - r_u->ptr=1; - - return r_u->status; + return status; } #if 0 /* AD DC work in ongoing in Samba 4 */ @@ -2195,12 +2192,6 @@ NTSTATUS _lsa_EnumPrivs(pipes_struct *p, struct lsa_EnumPrivs *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_QuerySecurity(pipes_struct *p, struct lsa_QuerySecurity *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_SetSecObj(pipes_struct *p, struct lsa_SetSecObj *r) { p->rng_fault_state = True; -- cgit From d04f1416ea6521745d84d066b5b304f8446b9248 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 22:05:48 +0100 Subject: Use pidl for (dummy) _lsa_DeleteObject(). Guenther (This used to be commit 81e2e3a288fb40bf4ba1b83adf459a0cf6f02ed2) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 10 +++------- 2 files changed, 4 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 94fc9b806a..bbd5ff2098 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -711,29 +711,7 @@ static bool api_lsa_set_secret(pipes_struct *p) static bool api_lsa_delete_object(pipes_struct *p) { - LSA_Q_DELETE_OBJECT q_u; - LSA_R_DELETE_OBJECT r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_delete_object("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_delete_object: failed to unmarshall LSA_Q_DELETE_OBJECT.\n")); - return False; - } - - r_u.status = _lsa_delete_object(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_delete_object("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_delete_object: Failed to marshall LSA_R_DELETE_OBJECT.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_DELETEOBJECT); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 0799d2ddf6..e4a44af3d7 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1396,9 +1396,11 @@ NTSTATUS _lsa_SetSecret(pipes_struct *p, struct lsa_SetSecret *r) } /*************************************************************************** + _lsa_DeleteObject ***************************************************************************/ -NTSTATUS _lsa_delete_object(pipes_struct *p, LSA_Q_DELETE_OBJECT *q_u, LSA_R_DELETE_OBJECT *r_u) +NTSTATUS _lsa_DeleteObject(pipes_struct *p, + struct lsa_DeleteObject *r) { return NT_STATUS_ACCESS_DENIED; } @@ -2336,12 +2338,6 @@ NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p, struct lsa_LookupPrivDispla return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_DeleteObject(pipes_struct *p, struct lsa_DeleteObject *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_EnumAccountsWithUserRight(pipes_struct *p, struct lsa_EnumAccountsWithUserRight *r) { p->rng_fault_state = True; -- cgit From b04a5e09f7b50e5b9c589e43c5df91f4913e3ab0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 22:53:03 +0100 Subject: Use pidl for _samr_GetUserPwInfo(). Guenther (This used to be commit 4e7236c10e5a1cbea2e961e196729603c66f37d6) --- source3/rpc_server/srv_samr.c | 23 +---------------------- source3/rpc_server/srv_samr_nt.c | 27 ++++++++------------------- 2 files changed, 9 insertions(+), 41 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 15cbf4cb61..211b9cd661 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -80,28 +80,7 @@ static bool api_samr_open_domain(pipes_struct *p) static bool api_samr_get_usrdom_pwinfo(pipes_struct *p) { - SAMR_Q_GET_USRDOM_PWINFO q_u; - SAMR_R_GET_USRDOM_PWINFO r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!samr_io_q_get_usrdom_pwinfo("", &q_u, data, 0)) { - DEBUG(0,("api_samr_get_usrdom_pwinfo: unable to unmarshall SAMR_Q_GET_USRDOM_PWINFO.\n")); - return False; - } - - r_u.status = _samr_get_usrdom_pwinfo(p, &q_u, &r_u); - - if(!samr_io_r_get_usrdom_pwinfo("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_get_usrdom_pwinfo: unable to marshall SAMR_R_GET_USRDOM_PWINFO.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_GETUSERPWINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 95c31ebc8b..bb83bda3da 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -618,32 +618,31 @@ NTSTATUS _samr_OpenDomain(pipes_struct *p, } /******************************************************************* - _samr_get_usrdom_pwinfo + _samr_GetUserPwInfo ********************************************************************/ -NTSTATUS _samr_get_usrdom_pwinfo(pipes_struct *p, SAMR_Q_GET_USRDOM_PWINFO *q_u, SAMR_R_GET_USRDOM_PWINFO *r_u) +NTSTATUS _samr_GetUserPwInfo(pipes_struct *p, + struct samr_GetUserPwInfo *r) { struct samr_info *info = NULL; - 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 **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.user_handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; if (!sid_check_is_in_our_domain(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - init_samr_r_get_usrdom_pwinfo(r_u, NT_STATUS_OK); + ZERO_STRUCTP(r->out.info); - DEBUG(5,("_samr_get_usrdom_pwinfo: %d\n", __LINE__)); + DEBUG(5,("_samr_GetUserPwInfo: %d\n", __LINE__)); - /* + /* * NT sometimes return NT_STATUS_ACCESS_DENIED * I don't know yet why. */ - return r_u->status; + return NT_STATUS_OK; } /******************************************************************* @@ -5357,16 +5356,6 @@ NTSTATUS _samr_TestPrivateFunctionsUser(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_GetUserPwInfo(pipes_struct *p, - struct samr_GetUserPwInfo *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_RemoveMemberFromForeignDomain(pipes_struct *p, struct samr_RemoveMemberFromForeignDomain *r) { -- cgit From 0bdb2d42bba0c7b88a71bf9f049bed21c050eab7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 23:27:22 +0100 Subject: Use pidl for _samr_DeleteAliasMember(). Guenther (This used to be commit 51f5bcfd39b169866a13bb5b7878f99dc2b89462) --- source3/rpc_server/srv_samr.c | 23 +---------------------- source3/rpc_server/srv_samr_nt.c | 30 +++++++++++------------------- 2 files changed, 12 insertions(+), 41 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 211b9cd661..84bcff687f 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -759,28 +759,7 @@ static bool api_samr_add_aliasmem(pipes_struct *p) static bool api_samr_del_aliasmem(pipes_struct *p) { - SAMR_Q_DEL_ALIASMEM q_u; - SAMR_R_DEL_ALIASMEM r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_del_aliasmem("", &q_u, data, 0)) { - DEBUG(0,("api_samr_del_aliasmem: unable to unmarshall SAMR_Q_DEL_ALIASMEM.\n")); - return False; - } - - r_u.status = _samr_del_aliasmem(p, &q_u, &r_u); - - if (!samr_io_r_del_aliasmem("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_del_aliasmem: unable to marshall SAMR_R_DEL_ALIASMEM.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_DELETEALIASMEMBER); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index bb83bda3da..e748d677c4 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4006,24 +4006,26 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD } /********************************************************************* - _samr_del_aliasmem + _samr_DeleteAliasMember *********************************************************************/ -NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DEL_ALIASMEM *r_u) +NTSTATUS _samr_DeleteAliasMember(pipes_struct *p, + struct samr_DeleteAliasMember *r) { DOM_SID alias_sid; uint32 acc_granted; SE_PRIV se_rights; bool can_add_accounts; - NTSTATUS ret; + NTSTATUS status; DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_REMOVE_MEMBER, "_samr_del_aliasmem"))) { - return r_u->status; + status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_REMOVE_MEMBER, "_samr_DeleteAliasMember"); + if (!NT_STATUS_IS_OK(status)) { + return status; } DEBUG(10, ("_samr_del_aliasmem:sid is %s\n", @@ -4037,18 +4039,18 @@ NTSTATUS _samr_del_aliasmem(pipes_struct *p, SAMR_Q_DEL_ALIASMEM *q_u, SAMR_R_DE if ( can_add_accounts ) become_root(); - ret = pdb_del_aliasmem(&alias_sid, &q_u->sid.sid); + status = pdb_del_aliasmem(&alias_sid, r->in.sid); if ( can_add_accounts ) unbecome_root(); /******** END SeAddUsers BLOCK *********/ - if (NT_STATUS_IS_OK(ret)) { + if (NT_STATUS_IS_OK(status)) { force_flush_samr_cache(disp_info); } - return ret; + return status; } /********************************************************************* @@ -5256,16 +5258,6 @@ NTSTATUS _samr_AddAliasMember(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_DeleteAliasMember(pipes_struct *p, - struct samr_DeleteAliasMember *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_GetMembersInAlias(pipes_struct *p, struct samr_GetMembersInAlias *r) { -- cgit From 5bae7a4bec9f4e2f71edb881847ed98597b4637a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 4 Feb 2008 23:40:19 +0100 Subject: Use pidl for _samr_AddAliasMember(). Guenther (This used to be commit 98d8482bae0c9500ab4a1f6c07acd327b894af66) --- source3/rpc_server/srv_samr.c | 23 +---------------------- source3/rpc_server/srv_samr_nt.c | 34 +++++++++++++--------------------- 2 files changed, 14 insertions(+), 43 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 84bcff687f..fc5edcc7f6 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -729,28 +729,7 @@ static bool api_samr_query_groupmem(pipes_struct *p) static bool api_samr_add_aliasmem(pipes_struct *p) { - SAMR_Q_ADD_ALIASMEM q_u; - SAMR_R_ADD_ALIASMEM r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_add_aliasmem("", &q_u, data, 0)) { - DEBUG(0,("api_samr_add_aliasmem: unable to unmarshall SAMR_Q_ADD_ALIASMEM.\n")); - return False; - } - - r_u.status = _samr_add_aliasmem(p, &q_u, &r_u); - - if (!samr_io_r_add_aliasmem("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_add_aliasmem: unable to marshall SAMR_R_ADD_ALIASMEM.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_ADDALIASMEMBER); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e748d677c4..c62fc7829f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3961,26 +3961,28 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ } /********************************************************************* - _samr_add_aliasmem + _samr_AddAliasMember *********************************************************************/ -NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_ADD_ALIASMEM *r_u) +NTSTATUS _samr_AddAliasMember(pipes_struct *p, + struct samr_AddAliasMember *r) { DOM_SID alias_sid; uint32 acc_granted; SE_PRIV se_rights; bool can_add_accounts; - NTSTATUS ret; + NTSTATUS status; DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_ADD_MEMBER, "_samr_add_aliasmem"))) { - return r_u->status; + + status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_ADD_MEMBER, "_samr_AddAliasMember"); + if (!NT_STATUS_IS_OK(status)) { + return status; } - + DEBUG(10, ("sid is %s\n", sid_string_dbg(&alias_sid))); se_priv_copy( &se_rights, &se_add_users ); @@ -3991,18 +3993,18 @@ NTSTATUS _samr_add_aliasmem(pipes_struct *p, SAMR_Q_ADD_ALIASMEM *q_u, SAMR_R_AD if ( can_add_accounts ) become_root(); - ret = pdb_add_aliasmem(&alias_sid, &q_u->sid.sid); + status = pdb_add_aliasmem(&alias_sid, r->in.sid); if ( can_add_accounts ) unbecome_root(); /******** END SeAddUsers BLOCK *********/ - if (NT_STATUS_IS_OK(ret)) { + if (NT_STATUS_IS_OK(status)) { force_flush_samr_cache(disp_info); } - return ret; + return status; } /********************************************************************* @@ -5248,16 +5250,6 @@ NTSTATUS _samr_SetAliasInfo(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_AddAliasMember(pipes_struct *p, - struct samr_AddAliasMember *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_GetMembersInAlias(pipes_struct *p, struct samr_GetMembersInAlias *r) { -- cgit From 5bec586b424d2325bd76683a821629b5635c69f1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 5 Feb 2008 00:29:11 +0100 Subject: Use pidl for _samr_GetMembersInAlias(). Guenther (This used to be commit f6db8a51c8858e48567a819f18a7215e7ad8f6b4) --- source3/rpc_server/srv_samr.c | 23 +----------------- source3/rpc_server/srv_samr_nt.c | 50 ++++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 50 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index fc5edcc7f6..012503b3e7 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -669,28 +669,7 @@ static bool api_samr_query_useraliases(pipes_struct *p) static bool api_samr_query_aliasmem(pipes_struct *p) { - SAMR_Q_QUERY_ALIASMEM q_u; - SAMR_R_QUERY_ALIASMEM r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_query_aliasmem("", &q_u, data, 0)) { - DEBUG(0,("api_samr_query_aliasmem: unable to unmarshall SAMR_Q_QUERY_ALIASMEM.\n")); - return False; - } - - r_u.status = _samr_query_aliasmem(p, &q_u, &r_u); - - if (!samr_io_r_query_aliasmem("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_query_aliasmem: unable to marshall SAMR_R_QUERY_ALIASMEM.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_GETMEMBERSINALIAS); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index c62fc7829f..08df3c6e07 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3846,34 +3846,35 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, } /********************************************************************* - _samr_query_aliasmem + _samr_GetMembersInAlias *********************************************************************/ -NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_QUERY_ALIASMEM *r_u) +NTSTATUS _samr_GetMembersInAlias(pipes_struct *p, + struct samr_GetMembersInAlias *r) { NTSTATUS status; size_t i; size_t num_sids = 0; - DOM_SID2 *sid; - DOM_SID *sids=NULL; + struct lsa_SidPtr *sids = NULL; + DOM_SID *pdb_sids = NULL; DOM_SID alias_sid; uint32 acc_granted; /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &alias_sid, &acc_granted, NULL)) + if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - - if (!NT_STATUS_IS_OK(r_u->status = - access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_GET_MEMBERS, "_samr_query_aliasmem"))) { - return r_u->status; + + status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_GET_MEMBERS, "_samr_GetMembersInAlias"); + if (!NT_STATUS_IS_OK(status)) { + return status; } DEBUG(10, ("sid is %s\n", sid_string_dbg(&alias_sid))); become_root(); - status = pdb_enum_aliasmem(&alias_sid, &sids, &num_sids); + status = pdb_enum_aliasmem(&alias_sid, &pdb_sids, &num_sids); unbecome_root(); if (!NT_STATUS_IS_OK(status)) { @@ -3881,22 +3882,25 @@ NTSTATUS _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_ } if (num_sids) { - sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_sids); - if (sid == NULL) { - SAFE_FREE(sids); + sids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_SidPtr, num_sids); + if (sids == NULL) { + TALLOC_FREE(pdb_sids); return NT_STATUS_NO_MEMORY; } - } else { - sid = NULL; } for (i = 0; i < num_sids; i++) { - init_dom_sid2(&sid[i], &sids[i]); + sids[i].sid = sid_dup_talloc(p->mem_ctx, &pdb_sids[i]); + if (!sids[i].sid) { + TALLOC_FREE(pdb_sids); + return NT_STATUS_NO_MEMORY; + } } - init_samr_r_query_aliasmem(r_u, num_sids, sid, NT_STATUS_OK); + r->out.sids->num_sids = num_sids; + r->out.sids->sids = sids; - TALLOC_FREE(sids); + TALLOC_FREE(pdb_sids); return NT_STATUS_OK; } @@ -5250,16 +5254,6 @@ NTSTATUS _samr_SetAliasInfo(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_GetMembersInAlias(pipes_struct *p, - struct samr_GetMembersInAlias *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_QueryUserInfo(pipes_struct *p, struct samr_QueryUserInfo *r) { -- cgit From 1dbfc38b28d44fe8f6e66b6c95db813bd577be29 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 5 Feb 2008 01:29:49 +0100 Subject: Use pidl for _samr_LookupDomain(). Guenther (This used to be commit 9bc106ba56d3a965a5fcd76ce18ccd30baa06eb4) --- source3/rpc_server/srv_samr.c | 22 +---------------- source3/rpc_server/srv_samr_nt.c | 53 +++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 51 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 012503b3e7..8c71e5ea1e 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -507,27 +507,7 @@ static bool api_samr_connect5(pipes_struct *p) static bool api_samr_lookup_domain(pipes_struct *p) { - SAMR_Q_LOOKUP_DOMAIN q_u; - SAMR_R_LOOKUP_DOMAIN r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!samr_io_q_lookup_domain("", &q_u, data, 0)) { - DEBUG(0,("api_samr_lookup_domain: Unable to unmarshall SAMR_Q_LOOKUP_DOMAIN.\n")); - return False; - } - - r_u.status = _samr_lookup_domain(p, &q_u, &r_u); - - if(!samr_io_r_lookup_domain("", &r_u, rdata, 0)){ - DEBUG(0,("api_samr_lookup_domain: Unable to marshall SAMR_R_LOOKUP_DOMAIN.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_LOOKUPDOMAIN); } /********************************************************************** diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 08df3c6e07..10a32675e2 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2847,47 +2847,50 @@ NTSTATUS _samr_Connect5(pipes_struct *p, } /********************************************************************** - api_samr_lookup_domain + _samr_LookupDomain **********************************************************************/ - -NTSTATUS _samr_lookup_domain(pipes_struct *p, SAMR_Q_LOOKUP_DOMAIN *q_u, SAMR_R_LOOKUP_DOMAIN *r_u) +NTSTATUS _samr_LookupDomain(pipes_struct *p, + struct samr_LookupDomain *r) { + NTSTATUS status = NT_STATUS_OK; struct samr_info *info; - fstring domain_name; - DOM_SID sid; - - r_u->status = NT_STATUS_OK; + const char *domain_name; + DOM_SID *sid = NULL; - if (!find_policy_by_hnd(p, &q_u->connect_pol, (void**)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.connect_handle, (void**)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* win9x user manager likes to use SA_RIGHT_SAM_ENUM_DOMAINS here. Reverted that change so we will work with RAS servers again */ - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, - SA_RIGHT_SAM_OPEN_DOMAIN, "_samr_lookup_domain"))) - { - return r_u->status; + status = access_check_samr_function(info->acc_granted, + SA_RIGHT_SAM_OPEN_DOMAIN, + "_samr_LookupDomain"); + if (!NT_STATUS_IS_OK(status)) { + return status; } - rpcstr_pull(domain_name, q_u->uni_domain.buffer, sizeof(domain_name), q_u->uni_domain.uni_str_len*2, 0); + domain_name = r->in.domain_name->string; - ZERO_STRUCT(sid); + sid = TALLOC_ZERO_P(p->mem_ctx, struct dom_sid2); + if (!sid) { + return NT_STATUS_NO_MEMORY; + } if (strequal(domain_name, builtin_domain_name())) { - sid_copy(&sid, &global_sid_Builtin); + sid_copy(sid, &global_sid_Builtin); } else { - if (!secrets_fetch_domain_sid(domain_name, &sid)) { - r_u->status = NT_STATUS_NO_SUCH_DOMAIN; + if (!secrets_fetch_domain_sid(domain_name, sid)) { + status = NT_STATUS_NO_SUCH_DOMAIN; } } DEBUG(2,("Returning domain sid for domain %s -> %s\n", domain_name, - sid_string_dbg(&sid))); + sid_string_dbg(sid))); - init_samr_r_lookup_domain(r_u, &sid, r_u->status); + *r->out.sid = sid; - return r_u->status; + return status; } /****************************************************************** @@ -5084,16 +5087,6 @@ NTSTATUS _samr_Shutdown(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_LookupDomain(pipes_struct *p, - struct samr_LookupDomain *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_EnumDomains(pipes_struct *p, struct samr_EnumDomains *r) { -- cgit From f3d5f695646ef498889405c3b49c6b220df9d004 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 5 Feb 2008 02:04:56 +0100 Subject: Use pidl for _samr_GetAliasMembership(). Guenther (This used to be commit b573f677239fbf176468796bb05c4b43dce47262) --- source3/rpc_server/srv_samr.c | 23 +-------------------- source3/rpc_server/srv_samr_nt.c | 44 ++++++++++++++++------------------------ 2 files changed, 18 insertions(+), 49 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 8c71e5ea1e..6375d6dbd3 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -619,28 +619,7 @@ static bool api_samr_set_userinfo2(pipes_struct *p) static bool api_samr_query_useraliases(pipes_struct *p) { - SAMR_Q_QUERY_USERALIASES q_u; - SAMR_R_QUERY_USERALIASES r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_query_useraliases("", &q_u, data, 0)) { - DEBUG(0,("api_samr_query_useraliases: Unable to unmarshall SAMR_Q_QUERY_USERALIASES.\n")); - return False; - } - - r_u.status = _samr_query_useraliases(p, &q_u, &r_u); - - if (! samr_io_r_query_useraliases("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_query_useraliases: Unable to nmarshall SAMR_R_QUERY_USERALIASES.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_GETALIASMEMBERSHIP); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 10a32675e2..2f852702b2 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3781,10 +3781,11 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ } /********************************************************************* - _samr_query_aliasmem + _samr_GetAliasMembership *********************************************************************/ -NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, SAMR_R_QUERY_USERALIASES *r_u) +NTSTATUS _samr_GetAliasMembership(pipes_struct *p, + struct samr_GetAliasMembership *r) { size_t num_alias_rids; uint32 *alias_rids; @@ -3796,17 +3797,15 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, DOM_SID *members; - r_u->status = NT_STATUS_OK; - - DEBUG(5,("_samr_query_useraliases: %d\n", __LINE__)); + DEBUG(5,("_samr_GetAliasMembership: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.domain_handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - - ntstatus1 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_LOOKUP_ALIAS_BY_MEM, "_samr_query_useraliases"); - ntstatus2 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_query_useraliases"); - + + ntstatus1 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_LOOKUP_ALIAS_BY_MEM, "_samr_GetAliasMembership"); + ntstatus2 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_GetAliasMembership"); + if (!NT_STATUS_IS_OK(ntstatus1) || !NT_STATUS_IS_OK(ntstatus2)) { if (!(NT_STATUS_EQUAL(ntstatus1,NT_STATUS_ACCESS_DENIED) && NT_STATUS_IS_OK(ntstatus2)) && !(NT_STATUS_EQUAL(ntstatus1,NT_STATUS_ACCESS_DENIED) && NT_STATUS_IS_OK(ntstatus1))) { @@ -3818,8 +3817,8 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, !sid_check_is_builtin(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - if (q_u->num_sids1) { - members = TALLOC_ARRAY(p->mem_ctx, DOM_SID, q_u->num_sids1); + if (r->in.sids->num_sids) { + members = TALLOC_ARRAY(p->mem_ctx, DOM_SID, r->in.sids->num_sids); if (members == NULL) return NT_STATUS_NO_MEMORY; @@ -3827,15 +3826,15 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, members = NULL; } - for (i=0; inum_sids1; i++) - sid_copy(&members[i], &q_u->sid[i].sid); + for (i=0; iin.sids->num_sids; i++) + sid_copy(&members[i], r->in.sids->sids[i].sid); alias_rids = NULL; num_alias_rids = 0; become_root(); ntstatus1 = pdb_enum_alias_memberships(p->mem_ctx, &info->sid, members, - q_u->num_sids1, + r->in.sids->num_sids, &alias_rids, &num_alias_rids); unbecome_root(); @@ -3843,8 +3842,9 @@ NTSTATUS _samr_query_useraliases(pipes_struct *p, SAMR_Q_QUERY_USERALIASES *q_u, return ntstatus1; } - init_samr_r_query_useraliases(r_u, num_alias_rids, alias_rids, - NT_STATUS_OK); + r->out.rids->count = num_alias_rids; + r->out.rids->ids = alias_rids; + return NT_STATUS_OK; } @@ -5157,16 +5157,6 @@ NTSTATUS _samr_EnumDomainAliases(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_GetAliasMembership(pipes_struct *p, - struct samr_GetAliasMembership *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_LookupNames(pipes_struct *p, struct samr_LookupNames *r) { -- cgit From 01a9964e8220edbc5be618408e83b4fad27792e4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 5 Feb 2008 03:17:12 +0100 Subject: Use idl for _samr_QueryGroupMember(). Guenther (This used to be commit 4b068954671143a7c94884e169f1d0ba420dccb7) --- source3/rpc_server/srv_samr.c | 23 +------------------- source3/rpc_server/srv_samr_nt.c | 46 +++++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 44 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 6375d6dbd3..d41d828e41 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -637,28 +637,7 @@ static bool api_samr_query_aliasmem(pipes_struct *p) static bool api_samr_query_groupmem(pipes_struct *p) { - SAMR_Q_QUERY_GROUPMEM q_u; - SAMR_R_QUERY_GROUPMEM r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_query_groupmem("", &q_u, data, 0)) { - DEBUG(0,("api_samr_query_groupmem: unable to unmarshall SAMR_Q_QUERY_GROUPMEM.\n")); - return False; - } - - r_u.status = _samr_query_groupmem(p, &q_u, &r_u); - - if (!samr_io_r_query_groupmem("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_query_groupmem: unable to marshall SAMR_R_QUERY_GROUPMEM.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_QUERYGROUPMEMBER); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 2f852702b2..0c9547edc1 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3909,10 +3909,11 @@ NTSTATUS _samr_GetMembersInAlias(pipes_struct *p, } /********************************************************************* - _samr_query_groupmem + _samr_QueryGroupMember *********************************************************************/ -NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_QUERY_GROUPMEM *r_u) +NTSTATUS _samr_QueryGroupMember(pipes_struct *p, + struct samr_QueryGroupMember *r) { DOM_SID group_sid; size_t i, num_members; @@ -3922,16 +3923,23 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ uint32 acc_granted; - NTSTATUS result; + NTSTATUS status; + struct samr_RidTypeArray *rids = NULL; + + rids = TALLOC_ZERO_P(p->mem_ctx, struct samr_RidTypeArray); + if (!rids) { + return NT_STATUS_NO_MEMORY; + } /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->group_pol, &group_sid, &acc_granted, NULL)) + if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_GET_MEMBERS, "_samr_query_groupmem"))) { - return r_u->status; + + status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_GET_MEMBERS, "_samr_QueryGroupMember"); + if (!NT_STATUS_IS_OK(status)) { + return status; } - + DEBUG(10, ("sid is %s\n", sid_string_dbg(&group_sid))); if (!sid_check_is_in_our_domain(&group_sid)) { @@ -3943,12 +3951,12 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ DEBUG(10, ("lookup on Domain SID\n")); become_root(); - result = pdb_enum_group_members(p->mem_ctx, &group_sid, + status = pdb_enum_group_members(p->mem_ctx, &group_sid, &rid, &num_members); unbecome_root(); - if (!NT_STATUS_IS_OK(result)) - return result; + if (!NT_STATUS_IS_OK(status)) + return status; if (num_members) { attr=TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_members); @@ -3962,7 +3970,11 @@ NTSTATUS _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_ for (i=0; icount = num_members; + rids->types = attr; + rids->rids = rid; + + *r->out.rids = rids; return NT_STATUS_OK; } @@ -5197,16 +5209,6 @@ NTSTATUS _samr_SetGroupInfo(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_QueryGroupMember(pipes_struct *p, - struct samr_QueryGroupMember *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_SetMemberAttributesOfGroup(pipes_struct *p, struct samr_SetMemberAttributesOfGroup *r) { -- cgit From f9447d248faec8d80df13c0d8ea6caf7dc40b2dd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 5 Feb 2008 12:54:19 +0100 Subject: Remove trailing while space, just couldn't resist. No code change. Guenther (This used to be commit efb6d24e97e489e44991091b10196b6ac582485b) --- source3/rpc_server/srv_samr.c | 30 +- source3/rpc_server/srv_samr_nt.c | 652 +++++++++++++++++++-------------------- 2 files changed, 341 insertions(+), 341 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index d41d828e41..bc7fd0e175 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1,4 +1,4 @@ -/* +/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, @@ -7,21 +7,21 @@ * Copyright (C) Marc Jacobsen 1999, * Copyright (C) Jean François Micouleau 1998-2001, * Copyright (C) Jim McDonough 2002-2003. - * - * Split into interface and implementation modules by, + * + * Split into interface and implementation modules by, * * Copyright (C) Jeremy Allison 2001. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ @@ -173,7 +173,7 @@ static bool api_samr_enum_dom_aliases(pipes_struct *p) SAMR_R_ENUM_DOM_ALIASES r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -251,7 +251,7 @@ static bool api_samr_query_aliasinfo(pipes_struct *p) DEBUG(0,("api_samr_query_aliasinfo: unable to marshall SAMR_R_QUERY_ALIASINFO.\n")); return False; } - + return True; } @@ -520,7 +520,7 @@ static bool api_samr_enum_domains(pipes_struct *p) SAMR_R_ENUM_DOMAINS r_u; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; - + ZERO_STRUCT(q_u); ZERO_STRUCT(r_u); @@ -535,7 +535,7 @@ static bool api_samr_enum_domains(pipes_struct *p) DEBUG(0,("api_samr_enum_domains: Unable to marshall SAMR_R_ENUM_DOMAINS.\n")); return False; } - + return True; } @@ -930,7 +930,7 @@ static struct api_struct api_samr_cmds [] = {"SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon }, {"SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains }, {"SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users }, - + {"SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, {"SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, {"SAMR_QUERY_USERALIASES" , SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, @@ -940,7 +940,7 @@ static struct api_struct api_samr_cmds [] = {"SAMR_DEL_ALIASMEM" , SAMR_DEL_ALIASMEM , api_samr_del_aliasmem }, {"SAMR_ADD_GROUPMEM" , SAMR_ADD_GROUPMEM , api_samr_add_groupmem }, {"SAMR_DEL_GROUPMEM" , SAMR_DEL_GROUPMEM , api_samr_del_groupmem }, - + {"SAMR_DELETE_DOM_USER" , SAMR_DELETE_DOM_USER , api_samr_delete_dom_user }, {"SAMR_DELETE_DOM_GROUP" , SAMR_DELETE_DOM_GROUP , api_samr_delete_dom_group }, {"SAMR_DELETE_DOM_ALIAS" , SAMR_DELETE_DOM_ALIAS , api_samr_delete_dom_alias }, @@ -951,13 +951,13 @@ static struct api_struct api_samr_cmds [] = {"SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, {"SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo }, {"SAMR_SET_USERINFO2" , SAMR_SET_USERINFO2 , api_samr_set_userinfo2 }, - + {"SAMR_QUERY_DOMAIN_INFO" , SAMR_QUERY_DOMAIN_INFO, api_samr_query_domain_info}, {"SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, {"SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, {"SAMR_QUERY_DISPINFO3" , SAMR_QUERY_DISPINFO3 , api_samr_query_dispinfo }, {"SAMR_QUERY_DISPINFO4" , SAMR_QUERY_DISPINFO4 , api_samr_query_dispinfo }, - + {"SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, {"SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, {"SAMR_SET_GROUPINFO" , SAMR_SET_GROUPINFO , api_samr_set_groupinfo }, @@ -971,7 +971,7 @@ static struct api_struct api_samr_cmds [] = {"SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, {"SAMR_REMOVE_SID_FOREIGN_DOMAIN" , SAMR_REMOVE_SID_FOREIGN_DOMAIN , api_samr_remove_sid_foreign_domain }, {"SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, - + {"SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, {"SAMR_SET_SEC_OBJECT" , SAMR_SET_SEC_OBJECT , api_samr_set_sec_obj }, {"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 0c9547edc1..586d2225e2 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -125,12 +125,12 @@ static NTSTATUS make_samr_object_sd( TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd /* add Full Access 'BUILTIN\Administrators' and 'BUILTIN\Account Operators */ init_sec_access(&mask, map->generic_all); - + init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); init_sec_ace(&ace[i++], &global_sid_Builtin_Account_Operators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); /* Add Full Access for Domain Admins if we are a DC */ - + if ( IS_DC ) { sid_copy( &domadmin_sid, get_global_sam_sid() ); sid_append_rid( &domadmin_sid, DOMAIN_GROUP_RID_ADMINS ); @@ -162,57 +162,57 @@ static NTSTATUS make_samr_object_sd( TALLOC_CTX *ctx, SEC_DESC **psd, size_t *sd level of access for further checks. ********************************************************************/ -static NTSTATUS access_check_samr_object( SEC_DESC *psd, NT_USER_TOKEN *token, +static NTSTATUS access_check_samr_object( SEC_DESC *psd, NT_USER_TOKEN *token, SE_PRIV *rights, uint32 rights_mask, - uint32 des_access, uint32 *acc_granted, + uint32 des_access, uint32 *acc_granted, const char *debug ) { NTSTATUS status = NT_STATUS_ACCESS_DENIED; uint32 saved_mask = 0; - /* check privileges; certain SAM access bits should be overridden - by privileges (mostly having to do with creating/modifying/deleting + /* check privileges; certain SAM access bits should be overridden + by privileges (mostly having to do with creating/modifying/deleting users and groups) */ - + if ( rights && user_has_any_privilege( token, rights ) ) { - + saved_mask = (des_access & rights_mask); des_access &= ~saved_mask; - + DEBUG(4,("access_check_samr_object: user rights access mask [0x%x]\n", rights_mask)); } - - + + /* check the security descriptor first */ - + if ( se_access_check(psd, token, des_access, acc_granted, &status) ) goto done; - + /* give root a free pass */ - + if ( geteuid() == sec_initial_uid() ) { - + DEBUG(4,("%s: ACCESS should be DENIED (requested: %#010x)\n", debug, des_access)); DEBUGADD(4,("but overritten by euid == sec_initial_uid()\n")); - + *acc_granted = des_access; - + status = NT_STATUS_OK; goto done; } - - + + done: - /* add in any bits saved during the privilege check (only + /* add in any bits saved during the privilege check (only matters is status is ok) */ - + *acc_granted |= rights_mask; - DEBUG(4,("%s: access %s (requested: 0x%08x, granted: 0x%08x)\n", - debug, NT_STATUS_IS_OK(status) ? "GRANTED" : "DENIED", + DEBUG(4,("%s: access %s (requested: 0x%08x, granted: 0x%08x)\n", + debug, NT_STATUS_IS_OK(status) ? "GRANTED" : "DENIED", des_access, *acc_granted)); - + return status; } @@ -222,28 +222,28 @@ done: static NTSTATUS access_check_samr_function(uint32 acc_granted, uint32 acc_required, const char *debug) { - DEBUG(5,("%s: access check ((granted: %#010x; required: %#010x)\n", + DEBUG(5,("%s: access check ((granted: %#010x; required: %#010x)\n", debug, acc_granted, acc_required)); /* check the security descriptor first */ - + if ( (acc_granted&acc_required) == acc_required ) return NT_STATUS_OK; - + /* give root a free pass */ if (geteuid() == sec_initial_uid()) { - + DEBUG(4,("%s: ACCESS should be DENIED (granted: %#010x; required: %#010x)\n", debug, acc_granted, acc_required)); DEBUGADD(4,("but overwritten by euid == 0\n")); - + return NT_STATUS_OK; } - - DEBUG(2,("%s: ACCESS DENIED (granted: %#010x; required: %#010x)\n", + + DEBUG(2,("%s: ACCESS DENIED (granted: %#010x; required: %#010x)\n", debug, acc_granted, acc_required)); - + return NT_STATUS_ACCESS_DENIED; } @@ -278,7 +278,7 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid) /* There are two cases to consider here: 1) The SID is a domain SID and we look for an equality match, or - 2) This is an account SID and so we return the DISP_INFO* for our + 2) This is an account SID and so we return the DISP_INFO* for our domain */ if (psid == NULL) { @@ -293,7 +293,7 @@ static DISP_INFO *get_samr_dispinfo_by_sid(DOM_SID *psid) return &builtin_dispinfo; } - + if (sid_check_is_domain(psid) || sid_check_is_in_our_domain(psid)) { /* * Necessary only once, but it does not really hurt. @@ -315,7 +315,7 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid) struct samr_info *info; fstring sid_str; TALLOC_CTX *mem_ctx; - + if (psid) { sid_to_fstring(sid_str, psid); } else { @@ -465,7 +465,7 @@ static void force_flush_samr_cache(DISP_INFO *disp_info) static void samr_clear_sam_passwd(struct samu *sam_pass) { - + if (!sam_pass) return; @@ -573,28 +573,28 @@ NTSTATUS _samr_OpenDomain(pipes_struct *p, SE_PRIV se_rights; /* find the connection policy handle. */ - + if ( !find_policy_by_hnd(p, r->in.connect_handle, (void**)(void *)&info) ) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function( info->acc_granted, + status = access_check_samr_function( info->acc_granted, SA_RIGHT_SAM_OPEN_DOMAIN, "_samr_OpenDomain" ); - + if ( !NT_STATUS_IS_OK(status) ) return status; /*check if access can be granted as requested by client. */ - + make_samr_object_sd( p->mem_ctx, &psd, &sd_size, &dom_generic_mapping, NULL, 0 ); se_map_generic( &des_access, &dom_generic_mapping ); - + se_priv_copy( &se_rights, &se_machine_account ); se_priv_add( &se_rights, &se_add_users ); - status = access_check_samr_object( psd, p->pipe_user.nt_user_token, - &se_rights, GENERIC_RIGHTS_DOMAIN_WRITE, des_access, + status = access_check_samr_object( psd, p->pipe_user.nt_user_token, + &se_rights, GENERIC_RIGHTS_DOMAIN_WRITE, des_access, &acc_granted, "_samr_OpenDomain" ); - + if ( !NT_STATUS_IS_OK(status) ) return status; @@ -648,7 +648,7 @@ NTSTATUS _samr_GetUserPwInfo(pipes_struct *p, /******************************************************************* ********************************************************************/ -static bool get_lsa_policy_samr_sid( pipes_struct *p, POLICY_HND *pol, +static bool get_lsa_policy_samr_sid( pipes_struct *p, POLICY_HND *pol, DOM_SID *sid, uint32 *acc_granted, DISP_INFO **ppdisp_info) { @@ -706,9 +706,9 @@ NTSTATUS _samr_SetSecurity(pipes_struct *p, dacl = r->in.sdbuf->sd->dacl; for (i=0; i < dacl->num_aces; i++) { if (sid_equal(&pol_sid, &dacl->aces[i].trustee)) { - ret = pdb_set_pass_can_change(sampass, - (dacl->aces[i].access_mask & - SA_RIGHT_USER_CHANGE_PASSWORD) ? + ret = pdb_set_pass_can_change(sampass, + (dacl->aces[i].access_mask & + SA_RIGHT_USER_CHANGE_PASSWORD) ? True: False); break; } @@ -791,7 +791,7 @@ NTSTATUS _samr_QuerySecurity(pipes_struct *p, if (pol_sid.sid_rev_num == 0) { DEBUG(5,("_samr_QuerySecurity: querying security on SAM\n")); status = make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); - } else if (sid_equal(&pol_sid,get_global_sam_sid())) { + } else if (sid_equal(&pol_sid,get_global_sam_sid())) { /* check if it is our domain SID */ DEBUG(5,("_samr_QuerySecurity: querying security on Domain " "with SID: %s\n", sid_string_dbg(&pol_sid))); @@ -837,7 +837,7 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, uint32 i; SAM_ENTRY *sam; UNISTR2 *uni_name; - + *sam_pp = NULL; *uni_name_pp = NULL; @@ -880,7 +880,7 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, samr_reply_enum_dom_users ********************************************************************/ -NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, +NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, SAMR_R_ENUM_DOM_USERS *r_u) { struct samr_info *info = NULL; @@ -890,19 +890,19 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, int max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K; uint32 max_entries = max_sam_entries; struct samr_displayentry *entries = NULL; - + r_u->status = NT_STATUS_OK; /* find the policy handle. open a policy on it. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, - SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, + SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_enum_dom_users"))) { return r_u->status; } - + DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); if (info->builtin_domain) { @@ -949,7 +949,7 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, } r_u->status = make_user_sam_entry_list(p->mem_ctx, &r_u->sam, - &r_u->uni_acct_name, + &r_u->uni_acct_name, num_account, enum_context, entries); @@ -1062,7 +1062,7 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM num_groups = pdb_search_entries(info->disp_info->groups, q_u->start_idx, MAX_SAM_ENTRIES, &groups); unbecome_root(); - + /* Ensure we cache this enumeration. */ set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); @@ -1112,7 +1112,7 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S num_aliases = pdb_search_entries(info->disp_info->aliases, q_u->start_idx, MAX_SAM_ENTRIES, &aliases); unbecome_root(); - + /* Ensure we cache this enumeration. */ set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); @@ -1131,12 +1131,12 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S samr_reply_query_dispinfo ********************************************************************/ -NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, +NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, SAMR_R_QUERY_DISPINFO *r_u) { struct samr_info *info = NULL; uint32 struct_size=0x20; /* W2K always reply that, client doesn't care */ - + uint32 max_entries=q_u->max_entries; uint32 enum_context=q_u->start_idx; uint32 max_size=q_u->max_size; @@ -1158,7 +1158,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, /* * calculate how many entries we will return. - * based on + * based on * - the number of entries the client asked * - our limit on that * - the starting point (enumeration context) @@ -1202,7 +1202,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, * return */ temp_size=max_entries*struct_size; - + if (temp_size>max_size) { max_entries=MIN((max_size/struct_size),max_entries);; DEBUG(5, ("samr_reply_query_dispinfo: buffer size limits to " @@ -1365,11 +1365,11 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM become_root(); status = pdb_get_aliasinfo(&sid, &info); unbecome_root(); - + if ( !NT_STATUS_IS_OK(status)) return status; - if ( !(r_u->ctr = TALLOC_ZERO_P( p->mem_ctx, ALIAS_INFO_CTR )) ) + if ( !(r_u->ctr = TALLOC_ZERO_P( p->mem_ctx, ALIAS_INFO_CTR )) ) return NT_STATUS_NO_MEMORY; @@ -1475,7 +1475,7 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO init_samr_r_lookup_names(p->mem_ctx, r_u, 0, NULL, NULL, NT_STATUS_OBJECT_TYPE_MISMATCH); return r_u->status; } - + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, 0, "_samr_lookup_names"))) { /* Don't know the acc_bits yet */ return r_u->status; } @@ -1487,7 +1487,7 @@ NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LO DEBUG(5,("_samr_lookup_names: looking name on SID %s\n", sid_string_dbg(&pol_sid))); - + for (i = 0; i < num_rids; i++) { fstring name; int ret; @@ -1545,11 +1545,11 @@ NTSTATUS _samr_ChangePasswordUser2(pipes_struct *p, * Pass the user through the NT -> unix user mapping * function. */ - + (void)map_username(user_name); - + /* - * UNIX username case mangling not required, pass_oem_change + * UNIX username case mangling not required, pass_oem_change * is case insensitive. */ @@ -1584,18 +1584,18 @@ NTSTATUS _samr_chgpasswd_user3(pipes_struct *p, SAMR_Q_CHGPASSWD_USER3 *q_u, SAM * Pass the user through the NT -> unix user mapping * function. */ - + (void)map_username(user_name); - + /* - * UNIX username case mangling not required, pass_oem_change + * UNIX username case mangling not required, pass_oem_change * is case insensitive. */ r_u->status = pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, q_u->nt_newpass.pass, q_u->nt_oldhash.hash, &reject_reason); - if (NT_STATUS_EQUAL(r_u->status, NT_STATUS_PASSWORD_RESTRICTION) || + if (NT_STATUS_EQUAL(r_u->status, NT_STATUS_PASSWORD_RESTRICTION) || NT_STATUS_EQUAL(r_u->status, NT_STATUS_ACCOUNT_RESTRICTION)) { uint32 min_pass_len,pass_hist,password_properties; @@ -1634,18 +1634,18 @@ NTSTATUS _samr_chgpasswd_user3(pipes_struct *p, SAMR_Q_CHGPASSWD_USER3 *q_u, SAM u_min_age = account_policy_temp; /* !AS ROOT */ - + unbecome_root(); unix_to_nt_time_abs(&nt_expire, u_expire); unix_to_nt_time_abs(&nt_min_age, u_min_age); - init_unk_info1(info, (uint16)min_pass_len, (uint16)pass_hist, + init_unk_info1(info, (uint16)min_pass_len, (uint16)pass_hist, password_properties, nt_expire, nt_min_age); reject->reject_reason = reject_reason; } - + init_samr_r_chgpasswd_user3(r_u, r_u->status, reject, info); DEBUG(5,("_samr_chgpasswd_user3: %d\n", __LINE__)); @@ -1779,13 +1779,13 @@ NTSTATUS _samr_OpenUser(pipes_struct *p, SE_PRIV se_rights; /* find the domain policy handle and get domain SID / access bits in the domain policy. */ - + if ( !get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted, NULL) ) return NT_STATUS_INVALID_HANDLE; - - nt_status = access_check_samr_function( acc_granted, + + nt_status = access_check_samr_function( acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenUser" ); - + if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; @@ -1794,22 +1794,22 @@ NTSTATUS _samr_OpenUser(pipes_struct *p, } /* append the user's RID to it */ - + if (!sid_append_rid(&sid, r->in.rid)) return NT_STATUS_NO_SUCH_USER; - + /* check if access can be granted as requested by client. */ - + make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, &sid, SAMR_USR_RIGHTS_WRITE_PW); se_map_generic(&des_access, &usr_generic_mapping); - + se_priv_copy( &se_rights, &se_machine_account ); se_priv_add( &se_rights, &se_add_users ); - - nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, - &se_rights, GENERIC_RIGHTS_USER_WRITE, des_access, + + nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, + &se_rights, GENERIC_RIGHTS_USER_WRITE, des_access, &acc_granted, "_samr_OpenUser"); - + if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; @@ -1848,7 +1848,7 @@ static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_S if ( !(smbpass = samu_new( mem_ctx )) ) { return NT_STATUS_NO_MEMORY; } - + become_root(); ret = pdb_getsampwsid(smbpass, user_sid); unbecome_root(); @@ -1934,7 +1934,7 @@ static NTSTATUS get_user_info_16(TALLOC_CTX *mem_ctx, SAM_USER_INFO_16 *id16, DO /************************************************************************* get_user_info_18. OK - this is the killer as it gives out password info. Ensure that this is only allowed on an encrypted connection with a root - user. JRA. + user. JRA. *************************************************************************/ static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_INFO_18 * id18, DOM_SID *user_sid) @@ -1975,7 +1975,7 @@ static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_ ZERO_STRUCTP(id18); init_sam_user_info18(id18, pdb_get_lanman_passwd(smbpass), pdb_get_nt_passwd(smbpass)); - + TALLOC_FREE(smbpass); return NT_STATUS_OK; @@ -2009,7 +2009,7 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, SAM_USER_INFO_20 *id20, DO ZERO_STRUCTP(id20); init_sam_user_info20A(id20, sampass); - + TALLOC_FREE(sampass); return NT_STATUS_OK; @@ -2019,7 +2019,7 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, SAM_USER_INFO_20 *id20, DO get_user_info_21 *************************************************************************/ -static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, +static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, DOM_SID *user_sid, DOM_SID *domain_sid) { struct samu *sampass=NULL; @@ -2045,7 +2045,7 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, ZERO_STRUCTP(id21); nt_status = init_sam_user_info21A(id21, sampass, domain_sid); - + TALLOC_FREE(sampass); return nt_status; @@ -2061,7 +2061,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ struct samr_info *info = NULL; DOM_SID domain_sid; uint32 rid; - + r_u->status=NT_STATUS_OK; /* search for the handle */ @@ -2123,7 +2123,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ if (!NT_STATUS_IS_OK(r_u->status = get_user_info_18(p, p->mem_ctx, ctr->info.id18, &info->sid))) return r_u->status; break; - + case 20: ctr->info.id20 = TALLOC_ZERO_P(p->mem_ctx,SAM_USER_INFO_20); if (ctr->info.id20 == NULL) @@ -2136,7 +2136,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ ctr->info.id21 = TALLOC_ZERO_P(p->mem_ctx,SAM_USER_INFO_21); if (ctr->info.id21 == NULL) return NT_STATUS_NO_MEMORY; - if (!NT_STATUS_IS_OK(r_u->status = get_user_info_21(p->mem_ctx, ctr->info.id21, + if (!NT_STATUS_IS_OK(r_u->status = get_user_info_21(p->mem_ctx, ctr->info.id21, &info->sid, &domain_sid))) return r_u->status; break; @@ -2148,7 +2148,7 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ init_samr_r_query_userinfo(r_u, ctr, r_u->status); DEBUG(5,("_samr_query_userinfo: %d\n", __LINE__)); - + return r_u->status; } @@ -2191,7 +2191,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S /* find the policy handle. open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_USER_GET_GROUPS, "_samr_query_usergroups"))) { return r_u->status; } @@ -2220,7 +2220,7 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S result = pdb_enum_group_memberships(p->mem_ctx, sam_pass, &sids, &unix_gids, &num_groups); if ( NT_STATUS_IS_OK(result) ) { - success = sid_peek_check_rid(get_global_sam_sid(), + success = sid_peek_check_rid(get_global_sam_sid(), pdb_get_group_sid(sam_pass), &primary_group_rid); } @@ -2266,12 +2266,12 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S ADD_TO_ARRAY(p->mem_ctx, DOM_GID, dom_gid, &gids, &num_gids); } - + /* construct the response. lkclXXXX: gids are not copied! */ init_samr_r_query_usergroups(r_u, num_gids, gids, r_u->status); - + DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__)); - + return r_u->status; } @@ -2279,8 +2279,8 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S _samr_query_domain_info ********************************************************************/ -NTSTATUS _samr_query_domain_info(pipes_struct *p, - SAMR_Q_QUERY_DOMAIN_INFO *q_u, +NTSTATUS _samr_query_domain_info(pipes_struct *p, + SAMR_Q_QUERY_DOMAIN_INFO *q_u, SAMR_R_QUERY_DOMAIN_INFO *r_u) { struct samr_info *info = NULL; @@ -2309,17 +2309,17 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, ZERO_STRUCTP(ctr); r_u->status = NT_STATUS_OK; - + DEBUG(5,("_samr_query_domain_info: %d\n", __LINE__)); - + /* find the policy handle. open a policy on it. */ if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)(void *)&info)) { return NT_STATUS_INVALID_HANDLE; } - + switch (q_u->switch_value) { case 0x01: - + become_root(); /* AS ROOT !!! */ @@ -2340,13 +2340,13 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, u_min_age = account_policy_temp; /* !AS ROOT */ - + unbecome_root(); unix_to_nt_time_abs(&nt_expire, u_expire); unix_to_nt_time_abs(&nt_min_age, u_min_age); - init_unk_info1(&ctr->info.inf1, (uint16)min_pass_len, (uint16)pass_hist, + init_unk_info1(&ctr->info.inf1, (uint16)min_pass_len, (uint16)pass_hist, password_properties, nt_expire, nt_min_age); break; case 0x02: @@ -2368,14 +2368,14 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, seq_num = time(NULL); /* !AS ROOT */ - + unbecome_root(); server_role = ROLE_DOMAIN_PDC; if (lp_server_role() == ROLE_DOMAIN_BDC) server_role = ROLE_DOMAIN_BDC; - init_unk_info2(&ctr->info.inf2, lp_serverstring(), lp_workgroup(), global_myname(), seq_num, + init_unk_info2(&ctr->info.inf2, lp_serverstring(), lp_workgroup(), global_myname(), seq_num, num_users, num_groups, num_aliases, nt_logout, server_role); break; case 0x03: @@ -2391,11 +2391,11 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, } /* !AS ROOT */ - + unbecome_root(); unix_to_nt_time_abs(&nt_logout, u_logout); - + init_unk_info3(&ctr->info.inf3, nt_logout); break; case 0x04: @@ -2428,7 +2428,7 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, } /* !AS ROOT */ - + unbecome_root(); init_unk_info8(&ctr->info.inf8, (uint32) seq_num); @@ -2452,23 +2452,23 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, lockout = account_policy_temp; /* !AS ROOT */ - + unbecome_root(); unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); unix_to_nt_time_abs(&nt_reset_time, u_reset_time); - + init_unk_info12(&ctr->info.inf12, nt_lock_duration, nt_reset_time, (uint16)lockout); break; default: return NT_STATUS_INVALID_INFO_CLASS; } - + init_samr_r_query_domain_info(r_u, q_u->switch_value, ctr, NT_STATUS_OK); - + DEBUG(5,("_samr_query_domain_info: %d\n", __LINE__)); - + return r_u->status; } @@ -2546,8 +2546,8 @@ NTSTATUS _samr_CreateUser2(pipes_struct *p, } if (!(acb_info == ACB_NORMAL || acb_info == ACB_DOMTRUST || - acb_info == ACB_WSTRUST || acb_info == ACB_SVRTRUST)) { - /* Match Win2k, and return NT_STATUS_INVALID_PARAMETER if + acb_info == ACB_WSTRUST || acb_info == ACB_SVRTRUST)) { + /* Match Win2k, and return NT_STATUS_INVALID_PARAMETER if this parameter is not an account type */ return NT_STATUS_INVALID_PARAMETER; } @@ -2563,14 +2563,14 @@ NTSTATUS _samr_CreateUser2(pipes_struct *p, } /* determine which user right we need to check based on the acb_info */ - + if ( acb_info & ACB_WSTRUST ) { se_priv_copy( &se_rights, &se_machine_account ); can_add_account = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); - } - /* usrmgr.exe (and net rpc trustdom grant) creates a normal user + } + /* usrmgr.exe (and net rpc trustdom grant) creates a normal user account for domain trusts and changes the ACB flags later */ else if ( acb_info & ACB_NORMAL && (account[strlen(account)-1] != '$') ) @@ -2578,7 +2578,7 @@ NTSTATUS _samr_CreateUser2(pipes_struct *p, se_priv_copy( &se_rights, &se_add_users ); can_add_account = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); - } + } else /* implicit assumption of a BDC or domain trust account here * (we already check the flags earlier) */ { @@ -2590,11 +2590,11 @@ NTSTATUS _samr_CreateUser2(pipes_struct *p, DOMAIN_GROUP_RID_ADMINS ); } } - + DEBUG(5, ("_samr_CreateUser2: %s can add this account : %s\n", uidtoname(p->pipe_user.ut.uid), can_add_account ? "True":"False" )); - + /********** BEGIN Admin BLOCK **********/ if ( can_add_account ) @@ -2607,24 +2607,24 @@ NTSTATUS _samr_CreateUser2(pipes_struct *p, unbecome_root(); /********** END Admin BLOCK **********/ - + /* now check for failure */ - + if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; - + /* Get the user's SID */ sid_compose(&sid, get_global_sam_sid(), *r->out.rid); - + make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &usr_generic_mapping, &sid, SAMR_USR_RIGHTS_WRITE_PW); se_map_generic(&des_access, &usr_generic_mapping); - - nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, - &se_rights, GENERIC_RIGHTS_USER_WRITE, des_access, + + nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, + &se_rights, GENERIC_RIGHTS_USER_WRITE, des_access, &acc_granted, "_samr_CreateUser2"); - + if ( !NT_STATUS_IS_OK(nt_status) ) { return nt_status; } @@ -2675,9 +2675,9 @@ NTSTATUS _samr_Connect(pipes_struct *p, return NT_STATUS_NO_MEMORY; /* don't give away the farm but this is probably ok. The SA_RIGHT_SAM_ENUM_DOMAINS - was observed from a win98 client trying to enumerate users (when configured + was observed from a win98 client trying to enumerate users (when configured user level access control on shares) --jerry */ - + if (des_access == MAXIMUM_ALLOWED_ACCESS) { /* Map to max possible knowing we're filtered below. */ des_access = GENERIC_ALL_ACCESS; @@ -2719,11 +2719,11 @@ NTSTATUS _samr_Connect2(pipes_struct *p, make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); se_map_generic(&des_access, &sam_generic_mapping); - - nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, + + nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, NULL, 0, des_access, &acc_granted, "_samr_Connect2"); - - if ( !NT_STATUS_IS_OK(nt_status) ) + + if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; /* associate the user's SID and access granted with the new handle. */ @@ -2768,11 +2768,11 @@ NTSTATUS _samr_Connect4(pipes_struct *p, make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); se_map_generic(&des_access, &sam_generic_mapping); - - nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, + + nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, NULL, 0, des_access, &acc_granted, "_samr_Connect4"); - - if ( !NT_STATUS_IS_OK(nt_status) ) + + if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; /* associate the user's SID and access granted with the new handle. */ @@ -2817,11 +2817,11 @@ NTSTATUS _samr_Connect5(pipes_struct *p, make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0); se_map_generic(&des_access, &sam_generic_mapping); - - nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, + + nt_status = access_check_samr_object(psd, p->pipe_user.nt_user_token, NULL, 0, des_access, &acc_granted, "_samr_Connect5"); - - if ( !NT_STATUS_IS_OK(nt_status) ) + + if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; /* associate the user's SID and access granted with the new handle. */ @@ -2860,7 +2860,7 @@ NTSTATUS _samr_LookupDomain(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.connect_handle, (void**)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - /* win9x user manager likes to use SA_RIGHT_SAM_ENUM_DOMAINS here. + /* win9x user manager likes to use SA_RIGHT_SAM_ENUM_DOMAINS here. Reverted that change so we will work with RAS servers again */ status = access_check_samr_function(info->acc_granted, @@ -2941,10 +2941,10 @@ NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_EN const char *name; r_u->status = NT_STATUS_OK; - + if (!find_policy_by_hnd(p, &q_u->pol, (void**)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_SAM_ENUM_DOMAINS, "_samr_enum_domains"))) { return r_u->status; } @@ -2983,33 +2983,33 @@ NTSTATUS _samr_OpenAlias(pipes_struct *p, SE_PRIV se_rights; /* find the domain policy and get the SID / access bits stored in the domain policy */ - + if ( !get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted, NULL) ) return NT_STATUS_INVALID_HANDLE; - - status = access_check_samr_function(acc_granted, + + status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenAlias"); - - if ( !NT_STATUS_IS_OK(status) ) + + if ( !NT_STATUS_IS_OK(status) ) return status; /* append the alias' RID to it */ - + if (!sid_append_rid(&sid, alias_rid)) return NT_STATUS_NO_SUCH_ALIAS; - + /*check if access can be granted as requested by client. */ - + make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &ali_generic_mapping, NULL, 0); se_map_generic(&des_access,&ali_generic_mapping); - + se_priv_copy( &se_rights, &se_add_users ); - - - status = access_check_samr_object(psd, p->pipe_user.nt_user_token, - &se_rights, GENERIC_RIGHTS_ALIAS_WRITE, des_access, + + + status = access_check_samr_object(psd, p->pipe_user.nt_user_token, + &se_rights, GENERIC_RIGHTS_ALIAS_WRITE, des_access, &acc_granted, "_samr_OpenAlias"); - + if ( !NT_STATUS_IS_OK(status) ) return status; @@ -3028,7 +3028,7 @@ NTSTATUS _samr_OpenAlias(pipes_struct *p, } /* make sure there is a mapping */ - + if ( !sid_to_gid( &sid, &gid ) ) { return NT_STATUS_NO_SUCH_ALIAS; } @@ -3038,7 +3038,7 @@ NTSTATUS _samr_OpenAlias(pipes_struct *p, /* associate the alias SID with the new handle. */ if ((info = get_samr_info_by_sid(&sid)) == NULL) return NT_STATUS_NO_MEMORY; - + info->acc_granted = acc_granted; /* get a (unique) handle. open a policy on it. */ @@ -3070,7 +3070,7 @@ static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx, } /* check to see if the new username already exists. Note: we can't - reliably lock all backends, so there is potentially the + reliably lock all backends, so there is potentially the possibility that a user can be created in between this check and the rename. The rename should fail, but may not get the exact same failure status code. I think this is small enough @@ -3100,7 +3100,7 @@ static bool set_user_info_16(const SAM_USER_INFO_16 *id16, struct samu *pwd) TALLOC_FREE(pwd); return False; } - + /* FIX ME: check if the value is really changed --metze */ if (!pdb_set_acct_ctrl(pwd, id16->acb_info, PDB_CHANGED)) { TALLOC_FREE(pwd); @@ -3129,7 +3129,7 @@ static bool set_user_info_18(SAM_USER_INFO_18 *id18, struct samu *pwd) TALLOC_FREE(pwd); return False; } - + if (!pdb_set_lanman_passwd (pwd, id18->lm_pwd, PDB_CHANGED)) { TALLOC_FREE(pwd); return False; @@ -3140,9 +3140,9 @@ static bool set_user_info_18(SAM_USER_INFO_18 *id18, struct samu *pwd) } if (!pdb_set_pass_last_set_time (pwd, time(NULL), PDB_CHANGED)) { TALLOC_FREE(pwd); - return False; + return False; } - + if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) { TALLOC_FREE(pwd); return False; @@ -3162,7 +3162,7 @@ static bool set_user_info_20(SAM_USER_INFO_20 *id20, struct samu *pwd) DEBUG(5, ("set_user_info_20: NULL id20\n")); return False; } - + copy_id20_to_sam_passwd(pwd, id20); /* write the change out */ @@ -3184,21 +3184,21 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, { fstring new_name; NTSTATUS status; - + if (id21 == NULL) { DEBUG(5, ("set_user_info_21: NULL id21\n")); return NT_STATUS_INVALID_PARAMETER; } /* we need to separately check for an account rename first */ - - if (rpcstr_pull(new_name, id21->uni_user_name.buffer, - sizeof(new_name), id21->uni_user_name.uni_str_len*2, 0) - && (!strequal(new_name, pdb_get_username(pwd)))) + + if (rpcstr_pull(new_name, id21->uni_user_name.buffer, + sizeof(new_name), id21->uni_user_name.uni_str_len*2, 0) + && (!strequal(new_name, pdb_get_username(pwd)))) { /* check to see if the new username already exists. Note: we can't - reliably lock all backends, so there is potentially the + reliably lock all backends, so there is potentially the possibility that a user can be created in between this check and the rename. The rename should fail, but may not get the exact same failure status code. I think this is small enough @@ -3214,35 +3214,35 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, status = pdb_rename_sam_account(pwd, new_name); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("set_user_info_21: failed to rename account: %s\n", + DEBUG(0,("set_user_info_21: failed to rename account: %s\n", nt_errstr(status))); TALLOC_FREE(pwd); return status; } - /* set the new username so that later + /* set the new username so that later functions can work on the new account */ pdb_set_username(pwd, new_name, PDB_SET); } copy_id21_to_sam_passwd(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 */ - + if ( IS_SAM_CHANGED(pwd, PDB_GROUPSID) ) { status = pdb_set_unix_primary_group(mem_ctx, pwd); if ( !NT_STATUS_IS_OK(status) ) { return status; } } - + /* Don't worry about writing out the user account since the - primary group SID is generated solely from the user's Unix + primary group SID is generated solely from the user's Unix primary group. */ /* write the change out */ @@ -3431,14 +3431,14 @@ static NTSTATUS set_user_info_25(TALLOC_CTX *mem_ctx, SAM_USER_INFO_25 *id25, struct samu *pwd) { NTSTATUS status; - + if (id25 == NULL) { DEBUG(5, ("set_user_info_25: NULL id25\n")); return NT_STATUS_INVALID_PARAMETER; } copy_id25_to_sam_passwd(pwd, id25); - + /* write the change out */ if(!NT_STATUS_IS_OK(status = pdb_update_sam_account(pwd))) { TALLOC_FREE(pwd); @@ -3459,7 +3459,7 @@ static NTSTATUS set_user_info_25(TALLOC_CTX *mem_ctx, SAM_USER_INFO_25 *id25, return status; } } - + /* WARNING: No TALLOC_FREE(pwd), we are about to set the password * hereafter! */ @@ -3492,13 +3492,13 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - /* This is tricky. A WinXP domain join sets + /* This is tricky. A WinXP domain join sets (SA_RIGHT_USER_SET_PASSWORD|SA_RIGHT_USER_SET_ATTRIBUTES|SA_RIGHT_USER_ACCT_FLAGS_EXPIRY) - The MMC lusrmgr plugin includes these perms and more in the SamrOpenUser(). But the - standard Win32 API calls just ask for SA_RIGHT_USER_SET_PASSWORD in the SamrOpenUser(). - This should be enough for levels 18, 24, 25,& 26. Info level 23 can set more so + The MMC lusrmgr plugin includes these perms and more in the SamrOpenUser(). But the + standard Win32 API calls just ask for SA_RIGHT_USER_SET_PASSWORD in the SamrOpenUser(). + This should be enough for levels 18, 24, 25,& 26. Info level 23 can set more so we'll use the set from the WinXP join as the basis. */ - + switch (switch_value) { case 18: case 24: @@ -3510,7 +3510,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE acc_required = SA_RIGHT_USER_SET_PASSWORD | SA_RIGHT_USER_SET_ATTRIBUTES | SA_RIGHT_USER_ACCT_FLAGS_EXPIRY; break; } - + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo"))) { return r_u->status; } @@ -3522,25 +3522,25 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE DEBUG(5, ("_samr_set_userinfo: NULL info level\n")); return NT_STATUS_INVALID_INFO_CLASS; } - + if ( !(pwd = samu_new( NULL )) ) { return NT_STATUS_NO_MEMORY; } - + become_root(); ret = pdb_getsampwsid(pwd, &sid); unbecome_root(); - + if ( !ret ) { TALLOC_FREE(pwd); return NT_STATUS_NO_SUCH_USER; } - + /* deal with machine password changes differently from userinfo changes */ /* check to see if we have the sufficient rights */ - + acb_info = pdb_get_acct_ctrl(pwd); - if ( acb_info & ACB_WSTRUST ) + if ( acb_info & ACB_WSTRUST ) has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_machine_account); else if ( acb_info & ACB_NORMAL ) has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users ); @@ -3548,16 +3548,16 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE if ( lp_enable_privileges() ) has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); } - + DEBUG(5, ("_samr_set_userinfo: %s does%s possess sufficient rights\n", uidtoname(p->pipe_user.ut.uid), has_enough_rights ? "" : " not")); /* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */ - - if ( has_enough_rights ) - become_root(); - + + if ( has_enough_rights ) + become_root(); + /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { @@ -3624,10 +3624,10 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE } done: - - if ( has_enough_rights ) + + if ( has_enough_rights ) unbecome_root(); - + /* ================ END SeMachineAccountPrivilege BLOCK ================ */ if (NT_STATUS_IS_OK(r_u->status)) { @@ -3663,7 +3663,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - + #if 0 /* this really should be applied on a per info level basis --jerry */ /* observed when joining XP client to Samba domain */ @@ -3671,7 +3671,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ #else acc_required = SA_RIGHT_USER_SET_ATTRIBUTES; #endif - + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo2"))) { return r_u->status; } @@ -3693,14 +3693,14 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ become_root(); ret = pdb_getsampwsid(pwd, &sid); unbecome_root(); - + if ( !ret ) { TALLOC_FREE(pwd); return NT_STATUS_NO_SUCH_USER; } - + acb_info = pdb_get_acct_ctrl(pwd); - if ( acb_info & ACB_WSTRUST ) + if ( acb_info & ACB_WSTRUST ) has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_machine_account); else if ( acb_info & ACB_NORMAL ) has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users ); @@ -3708,18 +3708,18 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ if ( lp_enable_privileges() ) has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); } - + DEBUG(5, ("_samr_set_userinfo2: %s does%s possess sufficient rights\n", uidtoname(p->pipe_user.ut.uid), has_enough_rights ? "" : " not")); /* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */ - - if ( has_enough_rights ) - become_root(); - + + if ( has_enough_rights ) + become_root(); + /* ok! user info levels (lots: see MSDEV help), off we go... */ - + switch (switch_value) { case 7: r_u->status = set_user_info_7(p->mem_ctx, @@ -3768,9 +3768,9 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ r_u->status = NT_STATUS_INVALID_INFO_CLASS; } - if ( has_enough_rights ) + if ( has_enough_rights ) unbecome_root(); - + /* ================ END SeMachineAccountPrivilege BLOCK ================ */ if (NT_STATUS_IS_OK(r_u->status)) { @@ -3791,7 +3791,7 @@ NTSTATUS _samr_GetAliasMembership(pipes_struct *p, uint32 *alias_rids; struct samr_info *info = NULL; size_t i; - + NTSTATUS ntstatus1; NTSTATUS ntstatus2; @@ -3811,7 +3811,7 @@ NTSTATUS _samr_GetAliasMembership(pipes_struct *p, !(NT_STATUS_EQUAL(ntstatus1,NT_STATUS_ACCESS_DENIED) && NT_STATUS_IS_OK(ntstatus1))) { return (NT_STATUS_IS_OK(ntstatus1)) ? ntstatus2 : ntstatus1; } - } + } if (!sid_check_is_domain(&info->sid) && !sid_check_is_builtin(&info->sid)) @@ -3932,7 +3932,7 @@ NTSTATUS _samr_QueryGroupMember(pipes_struct *p, } /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, NULL)) + if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_GET_MEMBERS, "_samr_QueryGroupMember"); @@ -3966,7 +3966,7 @@ NTSTATUS _samr_QueryGroupMember(pipes_struct *p, } else { attr = NULL; } - + for (i=0; ipipe_user.nt_user_token, &se_rights ); /******** BEGIN SeAddUsers BLOCK *********/ - + if ( can_add_accounts ) become_root(); - + status = pdb_add_aliasmem(&alias_sid, r->in.sid); - + if ( can_add_accounts ) unbecome_root(); - + /******** END SeAddUsers BLOCK *********/ - + if (NT_STATUS_IS_OK(status)) { force_flush_samr_cache(disp_info); } @@ -4041,14 +4041,14 @@ NTSTATUS _samr_DeleteAliasMember(pipes_struct *p, DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - + status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_REMOVE_MEMBER, "_samr_DeleteAliasMember"); if (!NT_STATUS_IS_OK(status)) { return status; } - + DEBUG(10, ("_samr_del_aliasmem:sid is %s\n", sid_string_dbg(&alias_sid))); @@ -4056,17 +4056,17 @@ NTSTATUS _samr_DeleteAliasMember(pipes_struct *p, can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); /******** BEGIN SeAddUsers BLOCK *********/ - + if ( can_add_accounts ) become_root(); status = pdb_del_aliasmem(&alias_sid, r->in.sid); - + if ( can_add_accounts ) unbecome_root(); - + /******** END SeAddUsers BLOCK *********/ - + if (NT_STATUS_IS_OK(status)) { force_flush_samr_cache(disp_info); } @@ -4109,7 +4109,7 @@ NTSTATUS _samr_AddGroupMember(pipes_struct *p, can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); /******** BEGIN SeAddUsers BLOCK *********/ - + if ( can_add_accounts ) become_root(); @@ -4117,9 +4117,9 @@ NTSTATUS _samr_AddGroupMember(pipes_struct *p, if ( can_add_accounts ) unbecome_root(); - + /******** END SeAddUsers BLOCK *********/ - + force_flush_samr_cache(disp_info); return status; @@ -4148,9 +4148,9 @@ NTSTATUS _samr_DeleteGroupMember(pipes_struct *p, */ /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - + status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_REMOVE_MEMBER, "_samr_DeleteGroupMember"); if (!NT_STATUS_IS_OK(status)) { return status; @@ -4165,17 +4165,17 @@ NTSTATUS _samr_DeleteGroupMember(pipes_struct *p, can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); /******** BEGIN SeAddUsers BLOCK *********/ - + if ( can_add_accounts ) become_root(); - + status = pdb_del_groupmem(p->mem_ctx, group_rid, r->in.rid); if ( can_add_accounts ) unbecome_root(); - + /******** END SeAddUsers BLOCK *********/ - + force_flush_samr_cache(disp_info); return status; @@ -4200,14 +4200,14 @@ NTSTATUS _samr_DeleteUser(pipes_struct *p, DEBUG(5, ("_samr_DeleteUser: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, r->in.user_handle, &user_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.user_handle, &user_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - + status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_DeleteUser"); if (!NT_STATUS_IS_OK(status)) { return status; } - + if (!sid_check_is_in_our_domain(&user_sid)) return NT_STATUS_CANNOT_DELETE; @@ -4221,12 +4221,12 @@ NTSTATUS _samr_DeleteUser(pipes_struct *p, unbecome_root(); if( !ret ) { - DEBUG(5,("_samr_DeleteUser: User %s doesn't exist.\n", + DEBUG(5,("_samr_DeleteUser: User %s doesn't exist.\n", sid_string_dbg(&user_sid))); TALLOC_FREE(sam_pass); return NT_STATUS_NO_SUCH_USER; } - + acb_info = pdb_get_acct_ctrl(sam_pass); /* For machine accounts it's the SeMachineAccountPrivilege that counts. */ @@ -4234,10 +4234,10 @@ NTSTATUS _samr_DeleteUser(pipes_struct *p, can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_machine_account ); } else { can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users ); - } + } /******** BEGIN SeAddUsers BLOCK *********/ - + if ( can_add_accounts ) become_root(); @@ -4245,9 +4245,9 @@ NTSTATUS _samr_DeleteUser(pipes_struct *p, if ( can_add_accounts ) unbecome_root(); - + /******** END SeAddUsers BLOCK *********/ - + if ( !NT_STATUS_IS_OK(status) ) { DEBUG(5,("_samr_DeleteUser: Failed to delete entry for " "user %s: %s.\n", pdb_get_username(sam_pass), @@ -4285,7 +4285,7 @@ NTSTATUS _samr_DeleteDomainGroup(pipes_struct *p, DEBUG(5, ("samr_DeleteDomainGroup: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_DeleteDomainGroup"); @@ -4304,7 +4304,7 @@ NTSTATUS _samr_DeleteDomainGroup(pipes_struct *p, can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); /******** BEGIN SeAddUsers BLOCK *********/ - + if ( can_add_accounts ) become_root(); @@ -4312,9 +4312,9 @@ NTSTATUS _samr_DeleteDomainGroup(pipes_struct *p, if ( can_add_accounts ) unbecome_root(); - + /******** END SeAddUsers BLOCK *********/ - + if ( !NT_STATUS_IS_OK(status) ) { DEBUG(5,("_samr_DeleteDomainGroup: Failed to delete mapping " "entry for group %s: %s\n", @@ -4322,7 +4322,7 @@ NTSTATUS _samr_DeleteDomainGroup(pipes_struct *p, nt_errstr(status))); return status; } - + if (!close_policy_hnd(p, r->in.group_handle)) return NT_STATUS_OBJECT_NAME_INVALID; @@ -4348,9 +4348,9 @@ NTSTATUS _samr_DeleteDomAlias(pipes_struct *p, DEBUG(5, ("_samr_DeleteDomAlias: %d\n", __LINE__)); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - + /* copy the handle to the outgoing reply */ memcpy(r->out.alias_handle, r->in.alias_handle, sizeof(r->out.alias_handle)); @@ -4370,23 +4370,23 @@ NTSTATUS _samr_DeleteDomAlias(pipes_struct *p, if (!sid_check_is_in_our_domain(&alias_sid)) return NT_STATUS_NO_SUCH_ALIAS; - + DEBUG(10, ("lookup on Local SID\n")); se_priv_copy( &se_rights, &se_add_users ); can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); /******** BEGIN SeAddUsers BLOCK *********/ - + if ( can_add_accounts ) become_root(); /* Have passdb delete the alias */ status = pdb_delete_alias(&alias_sid); - + if ( can_add_accounts ) unbecome_root(); - + /******** END SeAddUsers BLOCK *********/ if ( !NT_STATUS_IS_OK(status)) @@ -4419,14 +4419,14 @@ NTSTATUS _samr_CreateDomainGroup(pipes_struct *p, DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &dom_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &dom_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - + status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_GROUP, "_samr_CreateDomainGroup"); if (!NT_STATUS_IS_OK(status)) { return status; } - + if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; @@ -4444,26 +4444,26 @@ NTSTATUS _samr_CreateDomainGroup(pipes_struct *p, can_add_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_rights ); /******** BEGIN SeAddUsers BLOCK *********/ - + if ( can_add_accounts ) become_root(); - + /* check that we successfully create the UNIX group */ - + status = pdb_create_dom_group(p->mem_ctx, name, r->out.rid); if ( can_add_accounts ) unbecome_root(); - + /******** END SeAddUsers BLOCK *********/ - + /* check if we should bail out here */ - + if ( !NT_STATUS_IS_OK(status) ) return status; sid_compose(&info_sid, get_global_sam_sid(), *r->out.rid); - + if ((info = get_samr_info_by_sid(&info_sid)) == NULL) return NT_STATUS_NO_MEMORY; @@ -4499,14 +4499,14 @@ NTSTATUS _samr_CreateDomAlias(pipes_struct *p, DISP_INFO *disp_info = NULL; /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &dom_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &dom_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - + result = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_ALIAS, "_samr_CreateDomAlias"); if (!NT_STATUS_IS_OK(result)) { return result; } - + if (!sid_equal(&dom_sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; @@ -4521,7 +4521,7 @@ NTSTATUS _samr_CreateDomAlias(pipes_struct *p, } /******** BEGIN SeAddUsers BLOCK *********/ - + if ( can_add_accounts ) become_root(); @@ -4530,7 +4530,7 @@ NTSTATUS _samr_CreateDomAlias(pipes_struct *p, if ( can_add_accounts ) unbecome_root(); - + /******** END SeAddUsers BLOCK *********/ if (!NT_STATUS_IS_OK(result)) { @@ -4585,13 +4585,13 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM uint32 acc_granted; bool ret; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, NULL)) + if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_LOOKUP_INFO, "_samr_query_groupinfo"))) { return r_u->status; } - + become_root(); ret = get_domain_group_from_sid(group_sid, &map); unbecome_root(); @@ -4613,7 +4613,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM r_u->status = pdb_enum_group_members( p->mem_ctx, &group_sid, &members, &num_members); unbecome_root(); - + if (!NT_STATUS_IS_OK(r_u->status)) { return r_u->status; } @@ -4647,7 +4647,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM r_u->status = pdb_enum_group_members( p->mem_ctx, &group_sid, &members, &num_members); unbecome_root(); - + if (!NT_STATUS_IS_OK(r_u->status)) { return r_u->status; } @@ -4667,7 +4667,7 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM /********************************************************************* _samr_set_groupinfo - + update a domain group's comment. *********************************************************************/ @@ -4684,7 +4684,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_SET_INFO, "_samr_set_groupinfo"))) { return r_u->status; } @@ -4694,7 +4694,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ unbecome_root(); if (!result) return NT_STATUS_NO_SUCH_GROUP; - + ctr=q_u->ctr; switch (ctr->switch_value1) { @@ -4714,7 +4714,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ if ( can_mod_accounts ) become_root(); - + ret = pdb_update_group_mapping_entry(&map); if ( can_mod_accounts ) @@ -4731,7 +4731,7 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ /********************************************************************* _samr_set_aliasinfo - + update an alias's comment. *********************************************************************/ @@ -4747,11 +4747,11 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - + if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_SET_INFO, "_samr_set_aliasinfo"))) { return r_u->status; } - + ctr=&q_u->ctr; /* get the current group information */ @@ -4769,7 +4769,7 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ fstring group_name, acct_name; /* We currently do not support renaming groups in the - the BUILTIN domain. Refer to util_builtin.c to understand + the BUILTIN domain. Refer to util_builtin.c to understand why. The eventually needs to be fixed to be like Windows where you can rename builtin groups, just not delete them */ @@ -4779,10 +4779,10 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ /* There has to be a valid name (and it has to be different) */ - if ( !ctr->alias.info2.name.string ) + if ( !ctr->alias.info2.name.string ) return NT_STATUS_INVALID_PARAMETER; - unistr2_to_ascii( acct_name, ctr->alias.info2.name.string, + unistr2_to_ascii( acct_name, ctr->alias.info2.name.string, sizeof(acct_name)); /* If the name is the same just reply "ok". Yes this @@ -4793,19 +4793,19 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ fstrcpy( info.acct_name, acct_name ); - /* make sure the name doesn't already exist as a user + /* make sure the name doesn't already exist as a user or local group */ fstr_sprintf( group_name, "%s\\%s", global_myname(), info.acct_name ); status = can_create( p->mem_ctx, group_name ); - if ( !NT_STATUS_IS_OK( status ) ) + if ( !NT_STATUS_IS_OK( status ) ) return status; break; } case 3: if ( ctr->alias.info3.description.string ) { - unistr2_to_ascii( info.acct_desc, - ctr->alias.info3.description.string, + unistr2_to_ascii( info.acct_desc, + ctr->alias.info3.description.string, sizeof(info.acct_desc)); } else @@ -4878,30 +4878,30 @@ NTSTATUS _samr_OpenGroup(pipes_struct *p, bool ret; SE_PRIV se_rights; - if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &sid, &acc_granted, NULL)) + if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - - status = access_check_samr_function(acc_granted, + + status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenGroup"); - + if ( !NT_STATUS_IS_OK(status) ) return status; - + /*check if access can be granted as requested by client. */ make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &grp_generic_mapping, NULL, 0); se_map_generic(&des_access,&grp_generic_mapping); se_priv_copy( &se_rights, &se_add_users ); - status = access_check_samr_object(psd, p->pipe_user.nt_user_token, - &se_rights, GENERIC_RIGHTS_GROUP_WRITE, des_access, + status = access_check_samr_object(psd, p->pipe_user.nt_user_token, + &se_rights, GENERIC_RIGHTS_GROUP_WRITE, des_access, &acc_granted, "_samr_OpenGroup"); - - if ( !NT_STATUS_IS_OK(status) ) + + if ( !NT_STATUS_IS_OK(status) ) return status; /* this should not be hard-coded like this */ - + if (!sid_equal(&sid, get_global_sam_sid())) return NT_STATUS_ACCESS_DENIED; @@ -4911,7 +4911,7 @@ NTSTATUS _samr_OpenGroup(pipes_struct *p, if ((info = get_samr_info_by_sid(&info_sid)) == NULL) return NT_STATUS_NO_MEMORY; - + info->acc_granted = acc_granted; DEBUG(10, ("_samr_OpenGroup:Opening SID: %s\n", sid_string)); @@ -4934,8 +4934,8 @@ NTSTATUS _samr_OpenGroup(pipes_struct *p, _samr_remove_sid_foreign_domain *********************************************************************/ -NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, - SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN *q_u, +NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, + SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN *q_u, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN *r_u) { DOM_SID delete_sid, domain_sid; @@ -4951,19 +4951,19 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, /* Find the policy handle. Open a policy on it. */ if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &domain_sid, - &acc_granted, &disp_info)) + &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - - result = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, + + result = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_remove_sid_foreign_domain"); - - if (!NT_STATUS_IS_OK(result)) + + if (!NT_STATUS_IS_OK(result)) return result; - + DEBUG(8, ("_samr_remove_sid_foreign_domain:sid is %s\n", sid_string_dbg(&domain_sid))); - /* we can only delete a user from a group since we don't have + /* we can only delete a user from a group since we don't have nested groups anyways. So in the latter case, just say OK */ /* TODO: The above comment nowadays is bogus. Since we have nested @@ -5045,7 +5045,7 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R case 0x01: u_expire=nt_time_to_unix_abs(&q_u->ctr->info.inf1.expire); u_min_age=nt_time_to_unix_abs(&q_u->ctr->info.inf1.min_passwordage); - + pdb_set_account_policy(AP_MIN_PASSWORD_LEN, (uint32)q_u->ctr->info.inf1.min_length_password); pdb_set_account_policy(AP_PASSWORD_HISTORY, (uint32)q_u->ctr->info.inf1.password_history); pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)q_u->ctr->info.inf1.password_properties); @@ -5070,7 +5070,7 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R u_lock_duration /= 60; u_reset_time=nt_time_to_unix_abs(&q_u->ctr->info.inf12.reset_count)/60; - + pdb_set_account_policy(AP_LOCK_ACCOUNT_DURATION, (int)u_lock_duration); pdb_set_account_policy(AP_RESET_COUNT_TIME, (int)u_reset_time); pdb_set_account_policy(AP_BAD_ATTEMPT_LOCKOUT, (uint32)q_u->ctr->info.inf12.bad_attempt_lockout); -- cgit From ca772c8b18db3bbe0ef6ff9be0c29d3ac732fbe7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 5 Feb 2008 11:16:58 +0100 Subject: Use pidl for _samr_RemoveMemberFromForeignDomain(). Guenther (This used to be commit ab344dea9689ffc191110de0eca0d43b7221f7ee) --- source3/rpc_server/srv_samr.c | 23 +---------------------- source3/rpc_server/srv_samr_nt.c | 29 +++++++++-------------------- 2 files changed, 10 insertions(+), 42 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index bc7fd0e175..e6207c812a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -835,28 +835,7 @@ static bool api_samr_open_group(pipes_struct *p) static bool api_samr_remove_sid_foreign_domain(pipes_struct *p) { - SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN q_u; - SAMR_R_REMOVE_SID_FOREIGN_DOMAIN r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_remove_sid_foreign_domain("", &q_u, data, 0)) { - DEBUG(0,("api_samr_remove_sid_foreign_domain: unable to unmarshall SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN.\n")); - return False; - } - - r_u.status = _samr_remove_sid_foreign_domain(p, &q_u, &r_u); - - if (!samr_io_r_remove_sid_foreign_domain("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_remove_sid_foreign_domain: unable to marshall SAMR_R_REMOVE_SID_FOREIGN_DOMAIN.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_REMOVEMEMBERFROMFOREIGNDOMAIN); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 586d2225e2..e321d75626 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4931,36 +4931,35 @@ NTSTATUS _samr_OpenGroup(pipes_struct *p, } /********************************************************************* - _samr_remove_sid_foreign_domain + _samr_RemoveMemberFromForeignDomain *********************************************************************/ -NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, - SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN *q_u, - SAMR_R_REMOVE_SID_FOREIGN_DOMAIN *r_u) +NTSTATUS _samr_RemoveMemberFromForeignDomain(pipes_struct *p, + struct samr_RemoveMemberFromForeignDomain *r) { DOM_SID delete_sid, domain_sid; uint32 acc_granted; NTSTATUS result; DISP_INFO *disp_info = NULL; - sid_copy( &delete_sid, &q_u->sid.sid ); + sid_copy( &delete_sid, r->in.sid ); - DEBUG(5,("_samr_remove_sid_foreign_domain: removing SID [%s]\n", + DEBUG(5,("_samr_RemoveMemberFromForeignDomain: removing SID [%s]\n", sid_string_dbg(&delete_sid))); /* Find the policy handle. Open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->dom_pol, &domain_sid, + if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &domain_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; result = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, - "_samr_remove_sid_foreign_domain"); + "_samr_RemoveMemberFromForeignDomain"); if (!NT_STATUS_IS_OK(result)) return result; - DEBUG(8, ("_samr_remove_sid_foreign_domain:sid is %s\n", + DEBUG(8, ("_samr_RemoveMemberFromForeignDomain: sid is %s\n", sid_string_dbg(&domain_sid))); /* we can only delete a user from a group since we don't have @@ -4978,7 +4977,7 @@ NTSTATUS _samr_remove_sid_foreign_domain(pipes_struct *p, * other cases. */ if (!sid_check_is_builtin(&domain_sid)) { - DEBUG(1,("_samr_remove_sid_foreign_domain: domain_sid = %s, " + DEBUG(1,("_samr_RemoveMemberFromForeignDomain: domain_sid = %s, " "global_sam_sid() = %s\n", sid_string_dbg(&domain_sid), sid_string_dbg(get_global_sam_sid()))); @@ -5319,16 +5318,6 @@ NTSTATUS _samr_TestPrivateFunctionsUser(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_RemoveMemberFromForeignDomain(pipes_struct *p, - struct samr_RemoveMemberFromForeignDomain *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_QueryDomainInfo2(pipes_struct *p, struct samr_QueryDomainInfo2 *r) { -- cgit From 4a8010012a59b1771665290d53e4c966a231507b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 5 Feb 2008 13:38:48 +0100 Subject: Fix _samr_Connect5(). Yes we do pretend to be > w2k all the time :) Guenther (This used to be commit a407feb65301408f91a346ca9c01c511f95556c9) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e321d75626..ff50f5d225 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2837,7 +2837,7 @@ NTSTATUS _samr_Connect5(pipes_struct *p, DEBUG(5,("_samr_Connect5: %d\n", __LINE__)); - info1.unknown1 = 3; + info1.client_version = SAMR_CONNECT_AFTER_W2K; info1.unknown2 = 0; *r->out.level_out = 1; -- cgit From 3028c76fb57352148b7bd8f1f9dd3c34cf1f7c06 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 5 Feb 2008 15:03:54 +0100 Subject: Use pidl for _samr_QueryDomainInfo() and _samr_QueryDomainInfo2(). Guenther (This used to be commit 1ac767b0d8b42d2f804b0a7e93e5e859f9c25aae) --- source3/rpc_server/srv_samr.c | 46 +------------ source3/rpc_server/srv_samr_nt.c | 144 ++++++++++++++++++++------------------- 2 files changed, 76 insertions(+), 114 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index e6207c812a..2508ed40cc 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -401,28 +401,7 @@ static bool api_samr_query_usergroups(pipes_struct *p) static bool api_samr_query_domain_info(pipes_struct *p) { - SAMR_Q_QUERY_DOMAIN_INFO q_u; - SAMR_R_QUERY_DOMAIN_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!samr_io_q_query_domain_info("", &q_u, data, 0)) { - DEBUG(0,("api_samr_query_domain_info: unable to unmarshall SAMR_Q_QUERY_DOMAIN_INFO.\n")); - return False; - } - - r_u.status = _samr_query_domain_info(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_query_domain_info("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_query_domain_info: unable to marshall SAMR_R_QUERY_DOMAIN_INFO.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_QUERYDOMAININFO); } /******************************************************************* @@ -844,28 +823,7 @@ static bool api_samr_remove_sid_foreign_domain(pipes_struct *p) static bool api_samr_query_domain_info2(pipes_struct *p) { - SAMR_Q_QUERY_DOMAIN_INFO2 q_u; - SAMR_R_QUERY_DOMAIN_INFO2 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!samr_io_q_query_domain_info2("", &q_u, data, 0)) { - DEBUG(0,("api_samr_query_domain_info2: unable to unmarshall SAMR_Q_QUERY_DOMAIN_INFO2.\n")); - return False; - } - - r_u.status = _samr_query_domain_info2(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_query_domain_info2("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_query_domain_info2: unable to marshall SAMR_R_QUERY_DOMAIN_INFO2.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_QUERYDOMAININFO2); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ff50f5d225..16b706453f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2276,15 +2276,18 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S } /******************************************************************* - _samr_query_domain_info + samr_QueryDomainInfo_internal ********************************************************************/ -NTSTATUS _samr_query_domain_info(pipes_struct *p, - SAMR_Q_QUERY_DOMAIN_INFO *q_u, - SAMR_R_QUERY_DOMAIN_INFO *r_u) +static NTSTATUS samr_QueryDomainInfo_internal(const char *fn_name, + pipes_struct *p, + struct policy_handle *handle, + uint32_t level, + union samr_DomainInfo **dom_info_ptr) { + NTSTATUS status = NT_STATUS_OK; struct samr_info *info = NULL; - SAM_UNK_CTR *ctr; + union samr_DomainInfo *dom_info; uint32 min_pass_len,pass_hist,password_properties; time_t u_expire, u_min_age; NTTIME nt_expire, nt_min_age; @@ -2302,22 +2305,21 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, uint32 num_users=0, num_groups=0, num_aliases=0; - if ((ctr = TALLOC_ZERO_P(p->mem_ctx, SAM_UNK_CTR)) == NULL) { + DEBUG(5,("%s: %d\n", fn_name, __LINE__)); + + dom_info = TALLOC_ZERO_P(p->mem_ctx, union samr_DomainInfo); + if (!dom_info) { return NT_STATUS_NO_MEMORY; } - ZERO_STRUCTP(ctr); - - r_u->status = NT_STATUS_OK; - - DEBUG(5,("_samr_query_domain_info: %d\n", __LINE__)); + *dom_info_ptr = dom_info; /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)(void *)&info)) { + if (!find_policy_by_hnd(p, handle, (void **)(void *)&info)) { return NT_STATUS_INVALID_HANDLE; } - switch (q_u->switch_value) { + switch (level) { case 0x01: become_root(); @@ -2346,8 +2348,12 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, unix_to_nt_time_abs(&nt_expire, u_expire); unix_to_nt_time_abs(&nt_min_age, u_min_age); - init_unk_info1(&ctr->info.inf1, (uint16)min_pass_len, (uint16)pass_hist, - password_properties, nt_expire, nt_min_age); + init_samr_DomInfo1(&dom_info->info1, + (uint16)min_pass_len, + (uint16)pass_hist, + password_properties, + nt_expire, + nt_min_age); break; case 0x02: @@ -2375,8 +2381,18 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, if (lp_server_role() == ROLE_DOMAIN_BDC) server_role = ROLE_DOMAIN_BDC; - init_unk_info2(&ctr->info.inf2, lp_serverstring(), lp_workgroup(), global_myname(), seq_num, - num_users, num_groups, num_aliases, nt_logout, server_role); + init_samr_DomInfo2(&dom_info->info2, + nt_logout, + lp_serverstring(), + lp_workgroup(), + global_myname(), + seq_num, + 1, + server_role, + 1, + num_users, + num_groups, + num_aliases); break; case 0x03: @@ -2396,26 +2412,32 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, unix_to_nt_time_abs(&nt_logout, u_logout); - init_unk_info3(&ctr->info.inf3, nt_logout); + init_samr_DomInfo3(&dom_info->info3, + nt_logout); + break; case 0x04: - init_unk_info4(&ctr->info.inf4, lp_serverstring()); + init_samr_DomInfo4(&dom_info->info4, + lp_serverstring()); break; case 0x05: - init_unk_info5(&ctr->info.inf5, get_global_sam_name()); + init_samr_DomInfo5(&dom_info->info5, + get_global_sam_name()); break; case 0x06: /* NT returns its own name when a PDC. win2k and later * only the name of the PDC if itself is a BDC (samba4 * idl) */ - init_unk_info6(&ctr->info.inf6, global_myname()); + init_samr_DomInfo6(&dom_info->info6, + global_myname()); break; case 0x07: server_role = ROLE_DOMAIN_PDC; if (lp_server_role() == ROLE_DOMAIN_BDC) server_role = ROLE_DOMAIN_BDC; - init_unk_info7(&ctr->info.inf7, server_role); + init_samr_DomInfo7(&dom_info->info7, + server_role); break; case 0x08: @@ -2431,7 +2453,9 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, unbecome_root(); - init_unk_info8(&ctr->info.inf8, (uint32) seq_num); + init_samr_DomInfo8(&dom_info->info8, + seq_num, + 0); break; case 0x0c: @@ -2458,18 +2482,32 @@ NTSTATUS _samr_query_domain_info(pipes_struct *p, unix_to_nt_time_abs(&nt_lock_duration, u_lock_duration); unix_to_nt_time_abs(&nt_reset_time, u_reset_time); - init_unk_info12(&ctr->info.inf12, nt_lock_duration, nt_reset_time, (uint16)lockout); + init_samr_DomInfo12(&dom_info->info12, + nt_lock_duration, + nt_reset_time, + (uint16)lockout); break; default: return NT_STATUS_INVALID_INFO_CLASS; - } + } + DEBUG(5,("%s: %d\n", fn_name, __LINE__)); - init_samr_r_query_domain_info(r_u, q_u->switch_value, ctr, NT_STATUS_OK); + return status; +} - DEBUG(5,("_samr_query_domain_info: %d\n", __LINE__)); +/******************************************************************* + _samr_QueryDomainInfo + ********************************************************************/ - return r_u->status; +NTSTATUS _samr_QueryDomainInfo(pipes_struct *p, + struct samr_QueryDomainInfo *r) +{ + return samr_QueryDomainInfo_internal("_samr_QueryDomainInfo", + p, + r->in.domain_handle, + r->in.level, + r->out.info); } /* W2k3 seems to use the same check for all 3 objects that can be created via @@ -4993,31 +5031,17 @@ NTSTATUS _samr_RemoveMemberFromForeignDomain(pipes_struct *p, } /******************************************************************* - _samr_query_domain_info2 + _samr_QueryDomainInfo2 ********************************************************************/ -NTSTATUS _samr_query_domain_info2(pipes_struct *p, - SAMR_Q_QUERY_DOMAIN_INFO2 *q_u, - SAMR_R_QUERY_DOMAIN_INFO2 *r_u) +NTSTATUS _samr_QueryDomainInfo2(pipes_struct *p, + struct samr_QueryDomainInfo2 *r) { - SAMR_Q_QUERY_DOMAIN_INFO q; - SAMR_R_QUERY_DOMAIN_INFO r; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); - - DEBUG(5,("_samr_query_domain_info2: %d\n", __LINE__)); - - q.domain_pol = q_u->domain_pol; - q.switch_value = q_u->switch_value; - - r_u->status = _samr_query_domain_info(p, &q, &r); - - r_u->ptr_0 = r.ptr_0; - r_u->switch_value = r.switch_value; - r_u->ctr = r.ctr; - - return r_u->status; + return samr_QueryDomainInfo_internal("_samr_QueryDomainInfo2", + p, + r->in.domain_handle, + r->in.level, + r->out.info); } /******************************************************************* @@ -5108,16 +5132,6 @@ NTSTATUS _samr_EnumDomains(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_QueryDomainInfo(pipes_struct *p, - struct samr_QueryDomainInfo *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_SetDomainInfo(pipes_struct *p, struct samr_SetDomainInfo *r) { @@ -5318,16 +5332,6 @@ NTSTATUS _samr_TestPrivateFunctionsUser(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_QueryDomainInfo2(pipes_struct *p, - struct samr_QueryDomainInfo2 *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_QueryUserInfo2(pipes_struct *p, struct samr_QueryUserInfo2 *r) { -- cgit From 3dbbb4a6a04652a1d1dd4d76af58f6c7852d7c44 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 5 Feb 2008 15:08:31 +0100 Subject: Use pidl for _samr_SetDomainInfo(). Guenther (This used to be commit 370973c101a59546bb50dcc82ae4419da2119279) --- source3/rpc_server/srv_samr.c | 23 +----------------- source3/rpc_server/srv_samr_nt.c | 50 +++++++++++++++------------------------- 2 files changed, 19 insertions(+), 54 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 2508ed40cc..1d6c1a354a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -832,28 +832,7 @@ static bool api_samr_query_domain_info2(pipes_struct *p) static bool api_samr_set_dom_info(pipes_struct *p) { - SAMR_Q_SET_DOMAIN_INFO q_u; - SAMR_R_SET_DOMAIN_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!samr_io_q_set_domain_info("", &q_u, data, 0)) { - DEBUG(0,("api_samr_set_dom_info: unable to unmarshall SAMR_Q_SET_DOMAIN_INFO.\n")); - return False; - } - - r_u.status = _samr_set_dom_info(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_set_domain_info("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_set_dom_info: unable to marshall SAMR_R_SET_DOMAIN_INFO.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_SETDOMAININFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 16b706453f..652f66cf61 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -5045,40 +5045,38 @@ NTSTATUS _samr_QueryDomainInfo2(pipes_struct *p, } /******************************************************************* - _samr_set_dom_info + _samr_SetDomainInfo ********************************************************************/ -NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R_SET_DOMAIN_INFO *r_u) +NTSTATUS _samr_SetDomainInfo(pipes_struct *p, + struct samr_SetDomainInfo *r) { time_t u_expire, u_min_age; time_t u_logout; time_t u_lock_duration, u_reset_time; - r_u->status = NT_STATUS_OK; - - DEBUG(5,("_samr_set_dom_info: %d\n", __LINE__)); + DEBUG(5,("_samr_SetDomainInfo: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->domain_pol, NULL)) + if (!find_policy_by_hnd(p, r->in.domain_handle, NULL)) return NT_STATUS_INVALID_HANDLE; - DEBUG(5,("_samr_set_dom_info: switch_value: %d\n", q_u->switch_value)); + DEBUG(5,("_samr_SetDomainInfo: level: %d\n", r->in.level)); - switch (q_u->switch_value) { + switch (r->in.level) { case 0x01: - u_expire=nt_time_to_unix_abs(&q_u->ctr->info.inf1.expire); - u_min_age=nt_time_to_unix_abs(&q_u->ctr->info.inf1.min_passwordage); - - pdb_set_account_policy(AP_MIN_PASSWORD_LEN, (uint32)q_u->ctr->info.inf1.min_length_password); - pdb_set_account_policy(AP_PASSWORD_HISTORY, (uint32)q_u->ctr->info.inf1.password_history); - pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)q_u->ctr->info.inf1.password_properties); + u_expire=nt_time_to_unix_abs((NTTIME *)&r->in.info->info1.max_password_age); + u_min_age=nt_time_to_unix_abs((NTTIME *)&r->in.info->info1.min_password_age); + pdb_set_account_policy(AP_MIN_PASSWORD_LEN, (uint32)r->in.info->info1.min_password_length); + pdb_set_account_policy(AP_PASSWORD_HISTORY, (uint32)r->in.info->info1.password_history_length); + pdb_set_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, (uint32)r->in.info->info1.password_properties); pdb_set_account_policy(AP_MAX_PASSWORD_AGE, (int)u_expire); pdb_set_account_policy(AP_MIN_PASSWORD_AGE, (int)u_min_age); break; case 0x02: break; case 0x03: - u_logout=nt_time_to_unix_abs(&q_u->ctr->info.inf3.logout); + u_logout=nt_time_to_unix_abs((NTTIME *)&r->in.info->info3.force_logoff_time); pdb_set_account_policy(AP_TIME_TO_LOGOUT, (int)u_logout); break; case 0x05: @@ -5088,25 +5086,23 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R case 0x07: break; case 0x0c: - u_lock_duration=nt_time_to_unix_abs(&q_u->ctr->info.inf12.duration); + u_lock_duration=nt_time_to_unix_abs((NTTIME *)&r->in.info->info12.lockout_duration); if (u_lock_duration != -1) u_lock_duration /= 60; - u_reset_time=nt_time_to_unix_abs(&q_u->ctr->info.inf12.reset_count)/60; + u_reset_time=nt_time_to_unix_abs((NTTIME *)&r->in.info->info12.lockout_window)/60; pdb_set_account_policy(AP_LOCK_ACCOUNT_DURATION, (int)u_lock_duration); pdb_set_account_policy(AP_RESET_COUNT_TIME, (int)u_reset_time); - pdb_set_account_policy(AP_BAD_ATTEMPT_LOCKOUT, (uint32)q_u->ctr->info.inf12.bad_attempt_lockout); + pdb_set_account_policy(AP_BAD_ATTEMPT_LOCKOUT, (uint32)r->in.info->info12.lockout_threshold); break; default: return NT_STATUS_INVALID_INFO_CLASS; } - init_samr_r_set_domain_info(r_u, NT_STATUS_OK); - - DEBUG(5,("_samr_set_dom_info: %d\n", __LINE__)); + DEBUG(5,("_samr_SetDomainInfo: %d\n", __LINE__)); - return r_u->status; + return NT_STATUS_OK; } /**************************************************************** @@ -5132,16 +5128,6 @@ NTSTATUS _samr_EnumDomains(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_SetDomainInfo(pipes_struct *p, - struct samr_SetDomainInfo *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_EnumDomainGroups(pipes_struct *p, struct samr_EnumDomainGroups *r) { -- cgit From 1b35cc2e08e3e4fc4e29dc333387db9945cabba8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 5 Feb 2008 18:44:30 +0100 Subject: Use pidl for _samr_ChangePasswordUser3(). Guenther (This used to be commit 07c28f308624207c0c8a75d2f1783aa1d1aae05a) --- source3/rpc_server/srv_samr.c | 24 +------------ source3/rpc_server/srv_samr_nt.c | 76 ++++++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 58 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 1d6c1a354a..a547f0acd1 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -446,29 +446,7 @@ static bool api_samr_connect4(pipes_struct *p) static bool api_samr_chgpasswd_user3(pipes_struct *p) { - SAMR_Q_CHGPASSWD_USER3 q_u; - SAMR_R_CHGPASSWD_USER3 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* change password request */ - if (!samr_io_q_chgpasswd_user3("", &q_u, data, 0)) { - DEBUG(0,("api_samr_chgpasswd_user3: Failed to unmarshall SAMR_Q_CHGPASSWD_USER3.\n")); - return False; - } - - r_u.status = _samr_chgpasswd_user3(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_chgpasswd_user3("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_chgpasswd_user3: Failed to marshall SAMR_R_CHGPASSWD_USER3.\n" )); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_CHANGEPASSWORDUSER3); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 652f66cf61..bb957c632f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1562,23 +1562,27 @@ NTSTATUS _samr_ChangePasswordUser2(pipes_struct *p, } /******************************************************************* - _samr_chgpasswd_user3 + _samr_ChangePasswordUser3 ********************************************************************/ -NTSTATUS _samr_chgpasswd_user3(pipes_struct *p, SAMR_Q_CHGPASSWD_USER3 *q_u, SAMR_R_CHGPASSWD_USER3 *r_u) +NTSTATUS _samr_ChangePasswordUser3(pipes_struct *p, + struct samr_ChangePasswordUser3 *r) { + NTSTATUS status; fstring user_name; - fstring wks; + const char *wks = NULL; uint32 reject_reason; - SAM_UNK_INFO_1 *info = NULL; - SAMR_CHANGE_REJECT *reject = NULL; + struct samr_DomInfo1 *dominfo = NULL; + struct samr_ChangeReject *reject = NULL; - DEBUG(5,("_samr_chgpasswd_user3: %d\n", __LINE__)); + DEBUG(5,("_samr_ChangePasswordUser3: %d\n", __LINE__)); - rpcstr_pull(user_name, q_u->uni_user_name.buffer, sizeof(user_name), q_u->uni_user_name.uni_str_len*2, 0); - rpcstr_pull(wks, q_u->uni_dest_host.buffer, sizeof(wks), q_u->uni_dest_host.uni_str_len*2,0); + fstrcpy(user_name, r->in.account->string); + if (r->in.server && r->in.server->string) { + wks = r->in.server->string; + } - DEBUG(5,("_samr_chgpasswd_user3: user: %s wks: %s\n", user_name, wks)); + DEBUG(5,("_samr_ChangePasswordUser3: user: %s wks: %s\n", user_name, wks)); /* * Pass the user through the NT -> unix user mapping @@ -1592,28 +1596,31 @@ NTSTATUS _samr_chgpasswd_user3(pipes_struct *p, SAMR_Q_CHGPASSWD_USER3 *q_u, SAM * is case insensitive. */ - r_u->status = pass_oem_change(user_name, q_u->lm_newpass.pass, q_u->lm_oldhash.hash, - q_u->nt_newpass.pass, q_u->nt_oldhash.hash, &reject_reason); + status = pass_oem_change(user_name, + r->in.lm_password->data, + r->in.lm_verifier->hash, + r->in.nt_password->data, + r->in.nt_verifier->hash, + &reject_reason); - if (NT_STATUS_EQUAL(r_u->status, NT_STATUS_PASSWORD_RESTRICTION) || - NT_STATUS_EQUAL(r_u->status, NT_STATUS_ACCOUNT_RESTRICTION)) { + if (NT_STATUS_EQUAL(status, NT_STATUS_PASSWORD_RESTRICTION) || + NT_STATUS_EQUAL(status, NT_STATUS_ACCOUNT_RESTRICTION)) { uint32 min_pass_len,pass_hist,password_properties; time_t u_expire, u_min_age; NTTIME nt_expire, nt_min_age; uint32 account_policy_temp; - if ((info = TALLOC_ZERO_P(p->mem_ctx, SAM_UNK_INFO_1)) == NULL) { + dominfo = TALLOC_ZERO_P(p->mem_ctx, struct samr_DomInfo1); + if (!dominfo) { return NT_STATUS_NO_MEMORY; } - if ((reject = TALLOC_ZERO_P(p->mem_ctx, SAMR_CHANGE_REJECT)) == NULL) { + reject = TALLOC_ZERO_P(p->mem_ctx, struct samr_ChangeReject); + if (!reject) { return NT_STATUS_NO_MEMORY; } - ZERO_STRUCTP(info); - ZERO_STRUCTP(reject); - become_root(); /* AS ROOT !!! */ @@ -1640,17 +1647,26 @@ NTSTATUS _samr_chgpasswd_user3(pipes_struct *p, SAMR_Q_CHGPASSWD_USER3 *q_u, SAM unix_to_nt_time_abs(&nt_expire, u_expire); unix_to_nt_time_abs(&nt_min_age, u_min_age); - init_unk_info1(info, (uint16)min_pass_len, (uint16)pass_hist, - password_properties, nt_expire, nt_min_age); + if (lp_check_password_script() && *lp_check_password_script()) { + password_properties |= DOMAIN_PASSWORD_COMPLEX; + } - reject->reject_reason = reject_reason; - } + init_samr_DomInfo1(dominfo, + min_pass_len, + pass_hist, + password_properties, + u_expire, + u_min_age); - init_samr_r_chgpasswd_user3(r_u, r_u->status, reject, info); + reject->reason = reject_reason; - DEBUG(5,("_samr_chgpasswd_user3: %d\n", __LINE__)); + *r->out.dominfo = dominfo; + *r->out.reject = reject; + } - return r_u->status; + DEBUG(5,("_samr_ChangePasswordUser3: %d\n", __LINE__)); + + return status; } /******************************************************************* @@ -5428,16 +5444,6 @@ NTSTATUS _samr_Connect3(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_ChangePasswordUser3(pipes_struct *p, - struct samr_ChangePasswordUser3 *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_RidToSid(pipes_struct *p, struct samr_RidToSid *r) { -- cgit From c56cb9d0dc84264e0d887d01afb0c28320d70454 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 6 Feb 2008 12:53:43 +0100 Subject: Use pidl for _samr_SetAliasInfo(). Guenther (This used to be commit f483797c688ee1a5c5f7e183cdf7c1b700b7db31) --- source3/rpc_server/srv_samr.c | 23 +--------------- source3/rpc_server/srv_samr_nt.c | 57 +++++++++++++++------------------------- 2 files changed, 22 insertions(+), 58 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index a547f0acd1..a38e9461c4 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -744,28 +744,7 @@ static bool api_samr_set_groupinfo(pipes_struct *p) static bool api_samr_set_aliasinfo(pipes_struct *p) { - SAMR_Q_SET_ALIASINFO q_u; - SAMR_R_SET_ALIASINFO r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_set_aliasinfo("", &q_u, data, 0)) { - DEBUG(0,("api_samr_set_aliasinfo: unable to unmarshall SAMR_Q_SET_ALIASINFO.\n")); - return False; - } - - r_u.status = _samr_set_aliasinfo(p, &q_u, &r_u); - - if (!samr_io_r_set_aliasinfo("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_set_aliasinfo: unable to marshall SAMR_R_SET_ALIASINFO.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_SETALIASINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index bb957c632f..a06977eed7 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4784,30 +4784,29 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ } /********************************************************************* - _samr_set_aliasinfo - - update an alias's comment. + _samr_SetAliasInfo *********************************************************************/ -NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_SET_ALIASINFO *r_u) +NTSTATUS _samr_SetAliasInfo(pipes_struct *p, + struct samr_SetAliasInfo *r) { DOM_SID group_sid; struct acct_info info; - ALIAS_INFO_CTR *ctr; uint32 acc_granted; bool can_mod_accounts; NTSTATUS status; DISP_INFO *disp_info = NULL; - if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_SET_INFO, "_samr_set_aliasinfo"))) { - return r_u->status; + status = access_check_samr_function(acc_granted, + SA_RIGHT_ALIAS_SET_INFO, + "_samr_SetAliasInfo"); + if (!NT_STATUS_IS_OK(status)) { + return status; } - ctr=&q_u->ctr; - /* get the current group information */ become_root(); @@ -4817,10 +4816,10 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ if ( !NT_STATUS_IS_OK(status)) return status; - switch (ctr->level) { - case 2: + switch (r->in.level) { + case ALIASINFONAME: { - fstring group_name, acct_name; + fstring group_name; /* We currently do not support renaming groups in the the BUILTIN domain. Refer to util_builtin.c to understand @@ -4833,19 +4832,16 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ /* There has to be a valid name (and it has to be different) */ - if ( !ctr->alias.info2.name.string ) + if ( !r->in.info->name.string ) return NT_STATUS_INVALID_PARAMETER; - unistr2_to_ascii( acct_name, ctr->alias.info2.name.string, - sizeof(acct_name)); - /* If the name is the same just reply "ok". Yes this doesn't allow you to change the case of a group name. */ - if ( strequal( acct_name, info.acct_name ) ) + if ( strequal( r->in.info->name.string, info.acct_name ) ) return NT_STATUS_OK; - fstrcpy( info.acct_name, acct_name ); + fstrcpy( info.acct_name, r->in.info->name.string); /* make sure the name doesn't already exist as a user or local group */ @@ -4856,14 +4852,13 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ return status; break; } - case 3: - if ( ctr->alias.info3.description.string ) { - unistr2_to_ascii( info.acct_desc, - ctr->alias.info3.description.string, - sizeof(info.acct_desc)); - } - else + case ALIASINFODESCRIPTION: + if (r->in.info->description.string) { + fstrcpy(info.acct_desc, + r->in.info->description.string); + } else { fstrcpy( info.acct_desc, "" ); + } break; default: return NT_STATUS_INVALID_INFO_CLASS; @@ -5244,16 +5239,6 @@ NTSTATUS _samr_QueryAliasInfo(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_SetAliasInfo(pipes_struct *p, - struct samr_SetAliasInfo *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_QueryUserInfo(pipes_struct *p, struct samr_QueryUserInfo *r) { -- cgit From cdb5f49849270b2e1f687fd5cfcbc1461dfd2672 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 6 Feb 2008 12:57:59 +0100 Subject: Use pidl for _samr_SetGroupInfo(). Guenther (This used to be commit a576d9e80dffb15e29c3bf4da225bbe34f77053c) --- source3/rpc_server/srv_samr.c | 23 +------------------ source3/rpc_server/srv_samr_nt.c | 49 ++++++++++++++++------------------------ 2 files changed, 20 insertions(+), 52 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index a38e9461c4..2fea3c17b0 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -714,28 +714,7 @@ static bool api_samr_query_groupinfo(pipes_struct *p) static bool api_samr_set_groupinfo(pipes_struct *p) { - SAMR_Q_SET_GROUPINFO q_u; - SAMR_R_SET_GROUPINFO r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_set_groupinfo("", &q_u, data, 0)) { - DEBUG(0,("api_samr_set_groupinfo: unable to unmarshall SAMR_Q_SET_GROUPINFO.\n")); - return False; - } - - r_u.status = _samr_set_groupinfo(p, &q_u, &r_u); - - if (!samr_io_r_set_groupinfo("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_set_groupinfo: unable to marshall SAMR_R_SET_GROUPINFO.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_SETGROUPINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a06977eed7..092624d29e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4720,43 +4720,42 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM } /********************************************************************* - _samr_set_groupinfo - - update a domain group's comment. + _samr_SetGroupInfo *********************************************************************/ -NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_SET_GROUPINFO *r_u) +NTSTATUS _samr_SetGroupInfo(pipes_struct *p, + struct samr_SetGroupInfo *r) { DOM_SID group_sid; GROUP_MAP map; - GROUP_INFO_CTR *ctr; uint32 acc_granted; - NTSTATUS ret; - bool result; + NTSTATUS status; + bool ret; bool can_mod_accounts; DISP_INFO *disp_info = NULL; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_SET_INFO, "_samr_set_groupinfo"))) { - return r_u->status; + status = access_check_samr_function(acc_granted, + SA_RIGHT_GROUP_SET_INFO, + "_samr_SetGroupInfo"); + if (!NT_STATUS_IS_OK(status)) { + return status; } become_root(); - result = get_domain_group_from_sid(group_sid, &map); + ret = get_domain_group_from_sid(group_sid, &map); unbecome_root(); - if (!result) + if (!ret) return NT_STATUS_NO_SUCH_GROUP; - ctr=q_u->ctr; - - switch (ctr->switch_value1) { + switch (r->in.level) { case 1: - unistr2_to_ascii(map.comment, &(ctr->group.info1.uni_acct_desc), sizeof(map.comment)); + fstrcpy(map.comment, r->in.info->all.description.string); break; case 4: - unistr2_to_ascii(map.comment, &(ctr->group.info4.uni_acct_desc), sizeof(map.comment)); + fstrcpy(map.comment, r->in.info->description.string); break; default: return NT_STATUS_INVALID_INFO_CLASS; @@ -4769,18 +4768,18 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ if ( can_mod_accounts ) become_root(); - ret = pdb_update_group_mapping_entry(&map); + status = pdb_update_group_mapping_entry(&map); if ( can_mod_accounts ) unbecome_root(); /******** End SeAddUsers BLOCK *********/ - if (NT_STATUS_IS_OK(ret)) { + if (NT_STATUS_IS_OK(status)) { force_flush_samr_cache(disp_info); } - return ret; + return status; } /********************************************************************* @@ -5209,16 +5208,6 @@ NTSTATUS _samr_QueryGroupInfo(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_SetGroupInfo(pipes_struct *p, - struct samr_SetGroupInfo *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_SetMemberAttributesOfGroup(pipes_struct *p, struct samr_SetMemberAttributesOfGroup *r) { -- cgit From f7ad51084c87e5063e231c9bf024a354349d6a21 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 7 Feb 2008 13:14:40 +0100 Subject: Use pidl for _samr_QueryAliasInfo(). Guenther (This used to be commit 62dacea87ad2323870e5356a348d1d192b3fa888) --- source3/rpc_server/srv_samr.c | 24 +-------------- source3/rpc_server/srv_samr_nt.c | 63 ++++++++++++++++++++++------------------ 2 files changed, 35 insertions(+), 52 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 2fea3c17b0..70fe85d6c7 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -230,29 +230,7 @@ static bool api_samr_query_dispinfo(pipes_struct *p) static bool api_samr_query_aliasinfo(pipes_struct *p) { - SAMR_Q_QUERY_ALIASINFO q_u; - SAMR_R_QUERY_ALIASINFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the samr open */ - if(!samr_io_q_query_aliasinfo("", &q_u, data, 0)) { - DEBUG(0,("api_samr_query_aliasinfo: unable to unmarshall SAMR_Q_QUERY_ALIASINFO.\n")); - return False; - } - - r_u.status = _samr_query_aliasinfo(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_query_aliasinfo("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_query_aliasinfo: unable to marshall SAMR_R_QUERY_ALIASINFO.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_QUERYALIASINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 092624d29e..836ff3574f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1341,25 +1341,36 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, } /******************************************************************* - samr_reply_query_aliasinfo + _samr_QueryAliasInfo ********************************************************************/ -NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAMR_R_QUERY_ALIASINFO *r_u) +NTSTATUS _samr_QueryAliasInfo(pipes_struct *p, + struct samr_QueryAliasInfo *r) { DOM_SID sid; struct acct_info info; uint32 acc_granted; NTSTATUS status; + union samr_AliasInfo *alias_info = NULL; + const char *alias_name = NULL; + const char *alias_description = NULL; - r_u->status = NT_STATUS_OK; + DEBUG(5,("_samr_QueryAliasInfo: %d\n", __LINE__)); - DEBUG(5,("_samr_query_aliasinfo: %d\n", __LINE__)); + alias_info = TALLOC_ZERO_P(p->mem_ctx, union samr_AliasInfo); + if (!alias_info) { + return NT_STATUS_NO_MEMORY; + } /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted, NULL)) + if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_LOOKUP_INFO, "_samr_query_aliasinfo"))) { - return r_u->status; + + status = access_check_samr_function(acc_granted, + SA_RIGHT_ALIAS_LOOKUP_INFO, + "_samr_QueryAliasInfo"); + if (!NT_STATUS_IS_OK(status)) { + return status; } become_root(); @@ -1369,26 +1380,30 @@ NTSTATUS _samr_query_aliasinfo(pipes_struct *p, SAMR_Q_QUERY_ALIASINFO *q_u, SAM if ( !NT_STATUS_IS_OK(status)) return status; - if ( !(r_u->ctr = TALLOC_ZERO_P( p->mem_ctx, ALIAS_INFO_CTR )) ) - return NT_STATUS_NO_MEMORY; - + /* FIXME: info contains fstrings */ + alias_name = talloc_strdup(r, info.acct_name); + alias_description = talloc_strdup(r, info.acct_desc); - switch (q_u->level ) { - case 1: - r_u->ctr->level = 1; - init_samr_alias_info1(&r_u->ctr->alias.info1, info.acct_name, 1, info.acct_desc); + switch (r->in.level) { + case ALIASINFOALL: + init_samr_alias_info1(&alias_info->all, + alias_name, + 1, + alias_description); break; - case 3: - r_u->ctr->level = 3; - init_samr_alias_info3(&r_u->ctr->alias.info3, info.acct_desc); + case ALIASINFODESCRIPTION: + init_samr_alias_info3(&alias_info->description, + alias_description); break; default: return NT_STATUS_INVALID_INFO_CLASS; } - DEBUG(5,("_samr_query_aliasinfo: %d\n", __LINE__)); + *r->out.info = alias_info; - return r_u->status; + DEBUG(5,("_samr_QueryAliasInfo: %d\n", __LINE__)); + + return NT_STATUS_OK; } #if 0 @@ -5218,16 +5233,6 @@ NTSTATUS _samr_SetMemberAttributesOfGroup(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_QueryAliasInfo(pipes_struct *p, - struct samr_QueryAliasInfo *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_QueryUserInfo(pipes_struct *p, struct samr_QueryUserInfo *r) { -- cgit From 28124ad6670df42b5312d99838250191295f40d2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 7 Feb 2008 13:58:53 +0100 Subject: Use pidl for _samr_QueryGroupInfo(). Guenther (This used to be commit e80852426972fbf9996561aabdde7ed7b2c78b39) --- source3/rpc_server/srv_samr.c | 23 +--------- source3/rpc_server/srv_samr_nt.c | 91 +++++++++++++++++++++------------------- 2 files changed, 49 insertions(+), 65 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 70fe85d6c7..d5666e741d 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -662,28 +662,7 @@ static bool api_samr_create_dom_alias(pipes_struct *p) static bool api_samr_query_groupinfo(pipes_struct *p) { - SAMR_Q_QUERY_GROUPINFO q_u; - SAMR_R_QUERY_GROUPINFO r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_query_groupinfo("", &q_u, data, 0)) { - DEBUG(0,("api_samr_query_groupinfo: unable to unmarshall SAMR_Q_QUERY_GROUPINFO.\n")); - return False; - } - - r_u.status = _samr_query_groupinfo(p, &q_u, &r_u); - - if (!samr_io_r_query_groupinfo("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_query_groupinfo: unable to marshall SAMR_R_QUERY_GROUPINFO.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_QUERYGROUPINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 836ff3574f..5081565a5a 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4640,25 +4640,32 @@ NTSTATUS _samr_CreateDomAlias(pipes_struct *p, } /********************************************************************* - _samr_query_groupinfo - -sends the name/comment pair of a domain group -level 1 send also the number of users of that group + _samr_QueryGroupInfo *********************************************************************/ -NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAMR_R_QUERY_GROUPINFO *r_u) +NTSTATUS _samr_QueryGroupInfo(pipes_struct *p, + struct samr_QueryGroupInfo *r) { + NTSTATUS status; DOM_SID group_sid; GROUP_MAP map; - GROUP_INFO_CTR *ctr; + union samr_GroupInfo *info = NULL; uint32 acc_granted; bool ret; + uint32_t attributes = SE_GROUP_MANDATORY | + SE_GROUP_ENABLED_BY_DEFAULT | + SE_GROUP_ENABLED; + const char *group_name = NULL; + const char *group_description = NULL; - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted, NULL)) + if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_LOOKUP_INFO, "_samr_query_groupinfo"))) { - return r_u->status; + status = access_check_samr_function(acc_granted, + SA_RIGHT_GROUP_LOOKUP_INFO, + "_samr_QueryGroupInfo"); + if (!NT_STATUS_IS_OK(status)) { + return status; } become_root(); @@ -4667,41 +4674,47 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM if (!ret) return NT_STATUS_INVALID_HANDLE; - ctr=TALLOC_ZERO_P(p->mem_ctx, GROUP_INFO_CTR); - if (ctr==NULL) + /* FIXME: map contains fstrings */ + group_name = talloc_strdup(r, map.nt_name); + group_description = talloc_strdup(r, map.comment); + + info = TALLOC_ZERO_P(p->mem_ctx, union samr_GroupInfo); + if (!info) { return NT_STATUS_NO_MEMORY; + } - switch (q_u->switch_level) { + switch (r->in.level) { case 1: { uint32 *members; size_t num_members; - ctr->switch_value1 = 1; - become_root(); - r_u->status = pdb_enum_group_members( + status = pdb_enum_group_members( p->mem_ctx, &group_sid, &members, &num_members); unbecome_root(); - if (!NT_STATUS_IS_OK(r_u->status)) { - return r_u->status; + if (!NT_STATUS_IS_OK(status)) { + return status; } - init_samr_group_info1(&ctr->group.info1, map.nt_name, - map.comment, num_members); + init_samr_group_info1(&info->all, + group_name, + attributes, + num_members, + group_description); break; } case 2: - ctr->switch_value1 = 2; - init_samr_group_info2(&ctr->group.info2, map.nt_name); + init_samr_group_info2(&info->name, + group_name); break; case 3: - ctr->switch_value1 = 3; - init_samr_group_info3(&ctr->group.info3); + init_samr_group_info3(&info->attributes, + attributes); break; case 4: - ctr->switch_value1 = 4; - init_samr_group_info4(&ctr->group.info4, map.comment); + init_samr_group_info4(&info->description, + group_description); break; case 5: { /* @@ -4709,27 +4722,29 @@ NTSTATUS _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAM size_t num_members; */ - ctr->switch_value1 = 5; - /* become_root(); - r_u->status = pdb_enum_group_members( + status = pdb_enum_group_members( p->mem_ctx, &group_sid, &members, &num_members); unbecome_root(); - if (!NT_STATUS_IS_OK(r_u->status)) { - return r_u->status; + if (!NT_STATUS_IS_OK(status)) { + return status; } */ - init_samr_group_info5(&ctr->group.info5, map.nt_name, - map.comment, 0 /* num_members */); /* in w2k3 this is always 0 */ + init_samr_group_info5(&info->all2, + group_name, + attributes, + 0, /* num_members - in w2k3 this is always 0 */ + group_description); + break; } default: return NT_STATUS_INVALID_INFO_CLASS; } - init_samr_r_query_groupinfo(r_u, ctr, NT_STATUS_OK); + *r->out.info = info; return NT_STATUS_OK; } @@ -5213,16 +5228,6 @@ NTSTATUS _samr_LookupRids(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_QueryGroupInfo(pipes_struct *p, - struct samr_QueryGroupInfo *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_SetMemberAttributesOfGroup(pipes_struct *p, struct samr_SetMemberAttributesOfGroup *r) { -- cgit From cce7e93d842833e7f44254d80de59cc35e8f2af7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 6 Feb 2008 16:06:04 +0100 Subject: Use pidl for _samr_GetGroupsForUser(). Guenther (This used to be commit 3a3feb376116b4ebc5be7b149c187b49bc6b390d) --- source3/rpc_server/srv_samr.c | 23 +-------------- source3/rpc_server/srv_samr_nt.c | 61 ++++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 52 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index d5666e741d..e3ac2e42d5 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -349,28 +349,7 @@ static bool api_samr_query_userinfo(pipes_struct *p) static bool api_samr_query_usergroups(pipes_struct *p) { - SAMR_Q_QUERY_USERGROUPS q_u; - SAMR_R_QUERY_USERGROUPS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!samr_io_q_query_usergroups("", &q_u, data, 0)) { - DEBUG(0,("api_samr_query_usergroups: unable to unmarshall SAMR_Q_QUERY_USERGROUPS.\n")); - return False; - } - - r_u.status = _samr_query_usergroups(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_query_usergroups("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_query_usergroups: unable to marshall SAMR_R_QUERY_USERGROUPS.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_GETGROUPSFORUSER); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 5081565a5a..36860f9182 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2184,16 +2184,17 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ } /******************************************************************* - samr_reply_query_usergroups + _samr_GetGroupsForUser ********************************************************************/ -NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, SAMR_R_QUERY_USERGROUPS *r_u) +NTSTATUS _samr_GetGroupsForUser(pipes_struct *p, + struct samr_GetGroupsForUser *r) { struct samu *sam_pass=NULL; DOM_SID sid; DOM_SID *sids; - DOM_GID dom_gid; - DOM_GID *gids = NULL; + struct samr_RidWithAttribute dom_gid; + struct samr_RidWithAttribute *gids = NULL; uint32 primary_group_rid; size_t num_groups = 0; gid_t *unix_gids; @@ -2203,6 +2204,8 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S NTSTATUS result; bool success = False; + struct samr_RidWithAttributeArray *rids = NULL; + /* * from the SID in the request: * we should send back the list of DOMAIN GROUPS @@ -2215,16 +2218,22 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S * JFM, 12/2/2001 */ - r_u->status = NT_STATUS_OK; + DEBUG(5,("_samr_GetGroupsForUser: %d\n", __LINE__)); - DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__)); + rids = TALLOC_ZERO_P(p->mem_ctx, struct samr_RidWithAttributeArray); + if (!rids) { + return NT_STATUS_NO_MEMORY; + } /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &sid, &acc_granted, NULL)) + if (!get_lsa_policy_samr_sid(p, r->in.user_handle, &sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, SA_RIGHT_USER_GET_GROUPS, "_samr_query_usergroups"))) { - return r_u->status; + result = access_check_samr_function(acc_granted, + SA_RIGHT_USER_GET_GROUPS, + "_samr_GetGroupsForUser"); + if (!NT_STATUS_IS_OK(result)) { + return result; } if (!sid_check_is_in_our_domain(&sid)) @@ -2274,36 +2283,38 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S gids = NULL; num_gids = 0; - dom_gid.attr = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT| - SE_GROUP_ENABLED); - dom_gid.g_rid = primary_group_rid; - ADD_TO_ARRAY(p->mem_ctx, DOM_GID, dom_gid, &gids, &num_gids); + dom_gid.attributes = (SE_GROUP_MANDATORY|SE_GROUP_ENABLED_BY_DEFAULT| + SE_GROUP_ENABLED); + dom_gid.rid = primary_group_rid; + ADD_TO_ARRAY(p->mem_ctx, struct samr_RidWithAttribute, dom_gid, &gids, &num_gids); for (i=0; imem_ctx, DOM_GID, dom_gid, &gids, &num_gids); + ADD_TO_ARRAY(p->mem_ctx, struct samr_RidWithAttribute, dom_gid, &gids, &num_gids); } - /* construct the response. lkclXXXX: gids are not copied! */ - init_samr_r_query_usergroups(r_u, num_gids, gids, r_u->status); + rids->count = num_gids; + rids->rids = gids; - DEBUG(5,("_samr_query_usergroups: %d\n", __LINE__)); + *r->out.rids = rids; - return r_u->status; + DEBUG(5,("_samr_GetGroupsForUser: %d\n", __LINE__)); + + return result; } /******************************************************************* @@ -5268,16 +5279,6 @@ NTSTATUS _samr_ChangePasswordUser(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_GetGroupsForUser(pipes_struct *p, - struct samr_GetGroupsForUser *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p, struct samr_QueryDisplayInfo *r) { -- cgit From ca790c96d2240004b9e90dbf0889d7e08ddfa03e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 7 Feb 2008 14:40:39 +0100 Subject: Remove trailing whitespace in samr client and server. Guenther (This used to be commit 0b630db298a863ca5e38c9ee7b0202a58c51c6d1) --- source3/rpc_server/srv_samr_util.c | 100 ++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index c8f732153c..0b7cbbed4a 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -1,22 +1,22 @@ -/* +/* Unix SMB/CIFS implementation. SAMR Pipe utility functions. - + Copyright (C) Luke Kenneth Casson Leighton 1996-1998 Copyright (C) Gerald (Jerry) Carter 2000-2001 Copyright (C) Andrew Bartlett 2001-2002 Copyright (C) Stefan (metze) Metzmacher 2002 - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -72,14 +72,14 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) const char *old_string, *new_string; DATA_BLOB mung; - if (from == NULL || to == NULL) + if (from == NULL || to == NULL) return; if (from->fields_present & ACCT_LAST_LOGON) { unix_time=nt_time_to_unix(from->logon_time); stored_time = pdb_get_logon_time(to); DEBUG(10,("INFO_21 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + if (stored_time != unix_time) pdb_set_logon_time(to, unix_time, PDB_CHANGED); } @@ -87,7 +87,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) unix_time=nt_time_to_unix(from->logoff_time); stored_time = pdb_get_logoff_time(to); DEBUG(10,("INFO_21 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + if (stored_time != unix_time) pdb_set_logoff_time(to, unix_time, PDB_CHANGED); } @@ -95,15 +95,15 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) unix_time=nt_time_to_unix(from->kickoff_time); stored_time = pdb_get_kickoff_time(to); DEBUG(10,("INFO_21 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + if (stored_time != unix_time) pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); - } + } if (from->fields_present & ACCT_LAST_PWD_CHANGE) { unix_time=nt_time_to_unix(from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); DEBUG(10,("INFO_21 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + if (stored_time != unix_time) pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); } @@ -124,7 +124,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) if (STRING_CHANGED) pdb_set_fullname(to , new_string, PDB_CHANGED); } - + if ((from->fields_present & ACCT_HOME_DIR) && (from->hdr_home_dir.buffer)) { old_string = pdb_get_homedir(to); @@ -160,7 +160,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) if (STRING_CHANGED) pdb_set_profile_path(to , new_string, PDB_CHANGED); } - + if ((from->fields_present & ACCT_DESCRIPTION) && (from->hdr_acct_desc.buffer)) { old_string = pdb_get_acct_desc(to); @@ -169,7 +169,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) if (STRING_CHANGED) pdb_set_acct_desc(to , new_string, PDB_CHANGED); } - + if ((from->fields_present & ACCT_WORKSTATIONS) && (from->hdr_workstations.buffer)) { old_string = pdb_get_workstations(to); @@ -187,7 +187,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) if (STRING_CHANGED) pdb_set_comment(to, new_string, PDB_CHANGED); } - + if ((from->fields_present & ACCT_CALLBACK) && (from->hdr_munged_dial.buffer)) { char *newstr; @@ -203,7 +203,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) TALLOC_FREE(newstr); } - + if (from->fields_present & ACCT_RID) { if (from->user_rid == 0) { DEBUG(10, ("INFO_21: Asked to set User RID to 0 !? Skipping change!\n")); @@ -211,7 +211,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); } } - + if (from->fields_present & ACCT_PRIMARY_GID) { if (from->group_rid == 0) { DEBUG(10, ("INFO_21: Asked to set Group RID to 0 !? Skipping change!\n")); @@ -220,7 +220,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); } } - + if (from->fields_present & ACCT_FLAGS) { DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); if (from->acb_info != pdb_get_acct_ctrl(to)) { @@ -270,13 +270,13 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } /* If the must change flag is set, the last set time goes to zero. - the must change and can change fields also do, but they are + the must change and can change fields also do, but they are calculated from policy, not set from the wire */ if (from->fields_present & ACCT_EXPIRED_FLAG) { DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) { - pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); + pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); } else { pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED); } @@ -296,14 +296,14 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) const char *old_string, *new_string; DATA_BLOB mung; - if (from == NULL || to == NULL) + if (from == NULL || to == NULL) return; if (from->fields_present & ACCT_LAST_LOGON) { unix_time=nt_time_to_unix(from->logon_time); stored_time = pdb_get_logon_time(to); DEBUG(10,("INFO_23 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + if (stored_time != unix_time) pdb_set_logon_time(to, unix_time, PDB_CHANGED); } @@ -311,23 +311,23 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) unix_time=nt_time_to_unix(from->logoff_time); stored_time = pdb_get_logoff_time(to); DEBUG(10,("INFO_23 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + if (stored_time != unix_time) pdb_set_logoff_time(to, unix_time, PDB_CHANGED); } - + if (from->fields_present & ACCT_EXPIRY) { unix_time=nt_time_to_unix(from->kickoff_time); stored_time = pdb_get_kickoff_time(to); DEBUG(10,("INFO_23 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + if (stored_time != unix_time) pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); - } + } if (from->fields_present & ACCT_LAST_PWD_CHANGE) { unix_time=nt_time_to_unix(from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); DEBUG(10,("INFO_23 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + if (stored_time != unix_time) pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); } @@ -349,7 +349,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) if (STRING_CHANGED) pdb_set_fullname(to , new_string, PDB_CHANGED); } - + if ((from->fields_present & ACCT_HOME_DIR) && (from->hdr_home_dir.buffer)) { old_string = pdb_get_homedir(to); @@ -385,7 +385,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) if (STRING_CHANGED) pdb_set_profile_path(to , new_string, PDB_CHANGED); } - + if ((from->fields_present & ACCT_DESCRIPTION) && (from->hdr_acct_desc.buffer)) { old_string = pdb_get_acct_desc(to); @@ -394,7 +394,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) if (STRING_CHANGED) pdb_set_acct_desc(to , new_string, PDB_CHANGED); } - + if ((from->fields_present & ACCT_WORKSTATIONS) && (from->hdr_workstations.buffer)) { old_string = pdb_get_workstations(to); @@ -412,7 +412,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) if (STRING_CHANGED) pdb_set_comment(to , new_string, PDB_CHANGED); } - + if ((from->fields_present & ACCT_CALLBACK) && (from->hdr_munged_dial.buffer)) { char *newstr; @@ -428,7 +428,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) TALLOC_FREE(newstr); } - + if (from->fields_present & ACCT_RID) { if (from->user_rid == 0) { DEBUG(10, ("INFO_23: Asked to set User RID to 0 !? Skipping change!\n")); @@ -445,7 +445,7 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); } } - + if (from->fields_present & ACCT_FLAGS) { DEBUG(10,("INFO_23 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); if (from->acb_info != pdb_get_acct_ctrl(to)) { @@ -484,13 +484,13 @@ void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) } /* If the must change flag is set, the last set time goes to zero. - the must change and can change fields also do, but they are + the must change and can change fields also do, but they are calculated from policy, not set from the wire */ if (from->fields_present & ACCT_EXPIRED_FLAG) { DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) { - pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); + pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); } else { pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED); } @@ -509,14 +509,14 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) const char *old_string, *new_string; DATA_BLOB mung; - if (from == NULL || to == NULL) + if (from == NULL || to == NULL) return; if (from->fields_present & ACCT_LAST_LOGON) { unix_time=nt_time_to_unix(from->logon_time); stored_time = pdb_get_logon_time(to); DEBUG(10,("INFO_25 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + if (stored_time != unix_time) pdb_set_logon_time(to, unix_time, PDB_CHANGED); } @@ -524,7 +524,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) unix_time=nt_time_to_unix(from->logoff_time); stored_time = pdb_get_logoff_time(to); DEBUG(10,("INFO_25 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + if (stored_time != unix_time) pdb_set_logoff_time(to, unix_time, PDB_CHANGED); } @@ -532,15 +532,15 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) unix_time=nt_time_to_unix(from->kickoff_time); stored_time = pdb_get_kickoff_time(to); DEBUG(10,("INFO_25 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + if (stored_time != unix_time) pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); - } + } if (from->fields_present & ACCT_LAST_PWD_CHANGE) { unix_time=nt_time_to_unix(from->pass_last_set_time); stored_time = pdb_get_pass_last_set_time(to); DEBUG(10,("INFO_25 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + if (stored_time != unix_time) pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); } @@ -561,7 +561,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) if (STRING_CHANGED) pdb_set_fullname(to , new_string, PDB_CHANGED); } - + if ((from->fields_present & ACCT_HOME_DIR) && (from->hdr_home_dir.buffer)) { old_string = pdb_get_homedir(to); @@ -597,7 +597,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) if (STRING_CHANGED) pdb_set_profile_path(to , new_string, PDB_CHANGED); } - + if ((from->fields_present & ACCT_DESCRIPTION) && (from->hdr_acct_desc.buffer)) { old_string = pdb_get_acct_desc(to); @@ -606,7 +606,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) if (STRING_CHANGED) pdb_set_acct_desc(to , new_string, PDB_CHANGED); } - + if ((from->fields_present & ACCT_WORKSTATIONS) && (from->hdr_workstations.buffer)) { old_string = pdb_get_workstations(to); @@ -624,7 +624,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) if (STRING_CHANGED) pdb_set_comment(to , new_string, PDB_CHANGED); } - + if ((from->fields_present & ACCT_CALLBACK) && (from->hdr_munged_dial.buffer)) { char *newstr; @@ -640,7 +640,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) TALLOC_FREE(newstr); } - + if (from->fields_present & ACCT_RID) { if (from->user_rid == 0) { DEBUG(10, ("INFO_25: Asked to set User RID to 0 !? Skipping change!\n")); @@ -648,7 +648,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) DEBUG(10,("INFO_25 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); } } - + if (from->fields_present & ACCT_PRIMARY_GID) { if (from->group_rid == 0) { DEBUG(10, ("INFO_25: Asked to set Group RID to 0 !? Skipping change!\n")); @@ -657,7 +657,7 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); } } - + if (from->fields_present & ACCT_FLAGS) { DEBUG(10,("INFO_25 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); if (from->acb_info != pdb_get_acct_ctrl(to)) { @@ -702,13 +702,13 @@ void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) } /* If the must change flag is set, the last set time goes to zero. - the must change and can change fields also do, but they are + the must change and can change fields also do, but they are calculated from policy, not set from the wire */ if (from->fields_present & ACCT_EXPIRED_FLAG) { DEBUG(10,("INFO_25 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) { - pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); + pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); } else { pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED); } -- cgit From f27a5561aa95051ef4ccffd661601c242281e450 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 7 Feb 2008 17:57:20 +0100 Subject: Use pidl for _samr_QueryDisplayInfo(). Guenther (This used to be commit b6d1283121359091683ea4d5e834a7139d891930) --- source3/rpc_server/srv_samr.c | 23 +---------- source3/rpc_server/srv_samr_nt.c | 87 +++++++++++++++++----------------------- 2 files changed, 37 insertions(+), 73 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index e3ac2e42d5..76cbb22f9f 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -200,28 +200,7 @@ static bool api_samr_enum_dom_aliases(pipes_struct *p) static bool api_samr_query_dispinfo(pipes_struct *p) { - SAMR_Q_QUERY_DISPINFO q_u; - SAMR_R_QUERY_DISPINFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!samr_io_q_query_dispinfo("", &q_u, data, 0)) { - DEBUG(0,("api_samr_query_dispinfo: unable to unmarshall SAMR_Q_QUERY_DISPINFO.\n")); - return False; - } - - r_u.status = _samr_query_dispinfo(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_query_dispinfo("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_query_dispinfo: unable to marshall SAMR_R_QUERY_DISPINFO.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_QUERYDISPLAYINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 36860f9182..f7af95a2bf 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1128,20 +1128,22 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S } /******************************************************************* - samr_reply_query_dispinfo + _samr_QueryDisplayInfo ********************************************************************/ -NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, - SAMR_R_QUERY_DISPINFO *r_u) +NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p, + struct samr_QueryDisplayInfo *r) { + NTSTATUS status; struct samr_info *info = NULL; uint32 struct_size=0x20; /* W2K always reply that, client doesn't care */ - uint32 max_entries=q_u->max_entries; - uint32 enum_context=q_u->start_idx; - uint32 max_size=q_u->max_size; + uint32 max_entries = r->in.max_entries; + uint32 enum_context = r->in.start_idx; + uint32 max_size = r->in.buf_size; + + union samr_DispInfo *disp_info = r->out.info; - SAM_DISPINFO_CTR *ctr; uint32 temp_size=0, total_data_size=0; NTSTATUS disp_ret = NT_STATUS_UNSUCCESSFUL; uint32 num_account = 0; @@ -1149,11 +1151,10 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, int max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K; struct samr_displayentry *entries = NULL; - DEBUG(5, ("samr_reply_query_dispinfo: %d\n", __LINE__)); - r_u->status = NT_STATUS_UNSUCCESSFUL; + DEBUG(5,("_samr_QueryDisplayInfo: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.domain_handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* @@ -1184,15 +1185,15 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, * JFM, 12/20/2001 */ - if ((q_u->switch_level < 1) || (q_u->switch_level > 5)) { - DEBUG(0,("_samr_query_dispinfo: Unknown info level (%u)\n", - (unsigned int)q_u->switch_level )); + if ((r->in.level < 1) || (r->in.level > 5)) { + DEBUG(0,("_samr_QueryDisplayInfo: Unknown info level (%u)\n", + (unsigned int)r->in.level )); return NT_STATUS_INVALID_INFO_CLASS; } /* first limit the number of entries we will return */ if(max_entries > max_sam_entries) { - DEBUG(5, ("samr_reply_query_dispinfo: client requested %d " + DEBUG(5, ("_samr_QueryDisplayInfo: client requested %d " "entries, limiting to %d\n", max_entries, max_sam_entries)); max_entries = max_sam_entries; @@ -1205,20 +1206,15 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, if (temp_size>max_size) { max_entries=MIN((max_size/struct_size),max_entries);; - DEBUG(5, ("samr_reply_query_dispinfo: buffer size limits to " + DEBUG(5, ("_samr_QueryDisplayInfo: buffer size limits to " "only %d entries\n", max_entries)); } - if (!(ctr = TALLOC_ZERO_P(p->mem_ctx,SAM_DISPINFO_CTR))) - return NT_STATUS_NO_MEMORY; - - ZERO_STRUCTP(ctr); - become_root(); /* THe following done as ROOT. Don't return without unbecome_root(). */ - switch (q_u->switch_level) { + switch (r->in.level) { case 0x1: case 0x4: if (info->disp_info->users == NULL) { @@ -1227,10 +1223,10 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, unbecome_root(); return NT_STATUS_ACCESS_DENIED; } - DEBUG(10,("samr_reply_query_dispinfo: starting user enumeration at index %u\n", + DEBUG(10,("_samr_QueryDisplayInfo: starting user enumeration at index %u\n", (unsigned int)enum_context )); } else { - DEBUG(10,("samr_reply_query_dispinfo: using cached user enumeration at index %u\n", + DEBUG(10,("_samr_QueryDisplayInfo: using cached user enumeration at index %u\n", (unsigned int)enum_context )); } @@ -1246,10 +1242,10 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, unbecome_root(); return NT_STATUS_ACCESS_DENIED; } - DEBUG(10,("samr_reply_query_dispinfo: starting machine enumeration at index %u\n", + DEBUG(10,("_samr_QueryDisplayInfo: starting machine enumeration at index %u\n", (unsigned int)enum_context )); } else { - DEBUG(10,("samr_reply_query_dispinfo: using cached machine enumeration at index %u\n", + DEBUG(10,("_samr_QueryDisplayInfo: using cached machine enumeration at index %u\n", (unsigned int)enum_context )); } @@ -1265,10 +1261,10 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, unbecome_root(); return NT_STATUS_ACCESS_DENIED; } - DEBUG(10,("samr_reply_query_dispinfo: starting group enumeration at index %u\n", + DEBUG(10,("_samr_QueryDisplayInfo: starting group enumeration at index %u\n", (unsigned int)enum_context )); } else { - DEBUG(10,("samr_reply_query_dispinfo: using cached group enumeration at index %u\n", + DEBUG(10,("_samr_QueryDisplayInfo: using cached group enumeration at index %u\n", (unsigned int)enum_context )); } @@ -1283,30 +1279,31 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, } unbecome_root(); + /* Now create reply structure */ - switch (q_u->switch_level) { + switch (r->in.level) { case 0x1: - disp_ret = init_sam_dispinfo_1(p->mem_ctx, &ctr->sam.info1, + disp_ret = init_sam_dispinfo_1(p->mem_ctx, &disp_info->info1, num_account, enum_context, entries); break; case 0x2: - disp_ret = init_sam_dispinfo_2(p->mem_ctx, &ctr->sam.info2, + disp_ret = init_sam_dispinfo_2(p->mem_ctx, &disp_info->info2, num_account, enum_context, entries); break; case 0x3: - disp_ret = init_sam_dispinfo_3(p->mem_ctx, &ctr->sam.info3, + disp_ret = init_sam_dispinfo_3(p->mem_ctx, &disp_info->info3, num_account, enum_context, entries); break; case 0x4: - disp_ret = init_sam_dispinfo_4(p->mem_ctx, &ctr->sam.info4, + disp_ret = init_sam_dispinfo_4(p->mem_ctx, &disp_info->info4, num_account, enum_context, entries); break; case 0x5: - disp_ret = init_sam_dispinfo_5(p->mem_ctx, &ctr->sam.info5, + disp_ret = init_sam_dispinfo_5(p->mem_ctx, &disp_info->info5, num_account, enum_context, entries); break; @@ -1322,22 +1319,20 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u, total_data_size=num_account*struct_size; if (num_account) { - r_u->status = STATUS_MORE_ENTRIES; + status = STATUS_MORE_ENTRIES; } else { - r_u->status = NT_STATUS_OK; + status = NT_STATUS_OK; } /* Ensure we cache this enumeration. */ set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); - DEBUG(5, ("_samr_query_dispinfo: %d\n", __LINE__)); - - init_samr_r_query_dispinfo(r_u, num_account, total_data_size, - temp_size, q_u->switch_level, ctr, - r_u->status); + DEBUG(5, ("_samr_QueryDisplayInfo: %d\n", __LINE__)); - return r_u->status; + *r->out.total_size = total_data_size; + *r->out.returned_size = temp_size; + return status; } /******************************************************************* @@ -5279,16 +5274,6 @@ NTSTATUS _samr_ChangePasswordUser(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p, - struct samr_QueryDisplayInfo *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p, struct samr_GetDisplayEnumerationIndex *r) { -- cgit From 7daee37868867b895c3e455c85aac5ff127edaef Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 01:13:50 +0100 Subject: Use pidl for _lsa_QueryInfoPolicy(). Guenther (This used to be commit 1b931e9145910a74b9e9661a9255cd79e434ffea) --- source3/rpc_server/srv_lsa.c | 24 +------- source3/rpc_server/srv_lsa_nt.c | 131 +++++++++++++++++++--------------------- 2 files changed, 62 insertions(+), 93 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index bbd5ff2098..fd5d81548c 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -98,29 +98,7 @@ static bool api_lsa_enum_trust_dom(pipes_struct *p) static bool api_lsa_query_info(pipes_struct *p) { - LSA_Q_QUERY_INFO q_u; - LSA_R_QUERY_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_query("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_query_info: failed to unmarshall LSA_Q_QUERY_INFO.\n")); - return False; - } - - r_u.status = _lsa_query_info(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_query("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_query_info: failed to marshall LSA_R_QUERY_INFO.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_QUERYINFOPOLICY); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index e4a44af3d7..9f0d448364 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -46,6 +46,16 @@ const struct generic_mapping lsa_generic_mapping = { POLICY_ALL_ACCESS }; +/******************************************************************* + inits a structure. +********************************************************************/ + +static void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s) +{ + name->string = s; +} + + /******************************************************************* Function to free the per handle data. ********************************************************************/ @@ -58,47 +68,27 @@ static void free_lsa_info(void *ptr) } /*************************************************************************** -Init dom_query + initialize a lsa_DomainInfo structure. ***************************************************************************/ -static void init_dom_query_3(DOM_QUERY_3 *d_q, const char *dom_name, DOM_SID *dom_sid) +static void init_dom_query_3(struct lsa_DomainInfo *r, + const char *name, + DOM_SID *sid) { - d_q->buffer_dom_name = (dom_name != NULL) ? 1 : 0; /* domain buffer pointer */ - d_q->buffer_dom_sid = (dom_sid != NULL) ? 1 : 0; /* domain sid pointer */ - - /* this string is supposed to be non-null terminated. */ - /* But the maxlen in this UNISTR2 must include the terminating null. */ - init_unistr2(&d_q->uni_domain_name, dom_name, UNI_BROKEN_NON_NULL); - - /* - * I'm not sure why this really odd combination of length - * values works, but it does appear to. I need to look at - * this *much* more closely - but at the moment leave alone - * until it's understood. This allows a W2k client to join - * a domain with both odd and even length names... JRA. - */ - - /* - * IMPORTANT NOTE !!!! - * The two fields below probably are reversed in meaning, ie. - * the first field is probably the str_len, the second the max - * len. Both are measured in bytes anyway. - */ - - d_q->uni_dom_str_len = d_q->uni_domain_name.uni_max_len * 2; - d_q->uni_dom_max_len = d_q->uni_domain_name.uni_str_len * 2; - - if (dom_sid != NULL) - init_dom_sid2(&d_q->dom_sid, dom_sid); + init_lsa_StringLarge(&r->name, name); + r->sid = sid; } /*************************************************************************** -Init dom_query + initialize a lsa_DomainInfo structure. ***************************************************************************/ -static void init_dom_query_5(DOM_QUERY_5 *d_q, const char *dom_name, DOM_SID *dom_sid) +static void init_dom_query_5(struct lsa_DomainInfo *r, + const char *name, + DOM_SID *sid) { - init_dom_query_3(d_q, dom_name, dom_sid); + init_lsa_StringLarge(&r->name, name); + r->sid = sid; } /*************************************************************************** @@ -674,49 +664,57 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, } /*************************************************************************** - _lsa_query_info. See the POLICY_INFOMATION_CLASS docs at msdn. + _lsa_QueryInfoPolicy ***************************************************************************/ -NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INFO *r_u) +NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, + struct lsa_QueryInfoPolicy *r) { + NTSTATUS status = NT_STATUS_OK; struct lsa_info *handle; - LSA_INFO_CTR *ctr = &r_u->ctr; DOM_SID domain_sid; const char *name; DOM_SID *sid = NULL; + union lsa_PolicyInformation *info = NULL; - r_u->status = NT_STATUS_OK; - - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; - switch (q_u->info_class) { + info = TALLOC_ZERO_P(p->mem_ctx, union lsa_PolicyInformation); + if (!info) { + return NT_STATUS_NO_MEMORY; + } + + switch (r->in.level) { case 0x02: { uint32 policy_def = LSA_AUDIT_POLICY_ALL; - + /* check if the user have enough rights */ if (!(handle->access & POLICY_VIEW_AUDIT_INFORMATION)) { - DEBUG(10,("_lsa_query_info: insufficient access rights\n")); + DEBUG(10,("_lsa_QueryInfoPolicy: insufficient access rights\n")); return NT_STATUS_ACCESS_DENIED; } /* fake info: We audit everything. ;) */ - ctr->info.id2.ptr = 1; - ctr->info.id2.auditing_enabled = True; - ctr->info.id2.count1 = ctr->info.id2.count2 = LSA_AUDIT_NUM_CATEGORIES; - if ((ctr->info.id2.auditsettings = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, LSA_AUDIT_NUM_CATEGORIES)) == NULL) + info->audit_events.auditing_mode = true; + info->audit_events.count = LSA_AUDIT_NUM_CATEGORIES; + info->audit_events.settings = TALLOC_ZERO_ARRAY(p->mem_ctx, + enum lsa_PolicyAuditPolicy, + info->audit_events.count); + if (!info->audit_events.settings) { return NT_STATUS_NO_MEMORY; + } - ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_ACCOUNT_MANAGEMENT] = policy_def; - ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_FILE_AND_OBJECT_ACCESS] = policy_def; - ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_LOGON] = policy_def; - ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_PROCCESS_TRACKING] = policy_def; - ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_SECURITY_POLICY_CHANGES] = policy_def; - ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_SYSTEM] = policy_def; - ctr->info.id2.auditsettings[LSA_AUDIT_CATEGORY_USE_OF_USER_RIGHTS] = policy_def; + info->audit_events.settings[LSA_AUDIT_CATEGORY_ACCOUNT_MANAGEMENT] = policy_def; + info->audit_events.settings[LSA_AUDIT_CATEGORY_FILE_AND_OBJECT_ACCESS] = policy_def; + info->audit_events.settings[LSA_AUDIT_CATEGORY_LOGON] = policy_def; + info->audit_events.settings[LSA_AUDIT_CATEGORY_PROCCESS_TRACKING] = policy_def; + info->audit_events.settings[LSA_AUDIT_CATEGORY_SECURITY_POLICY_CHANGES] = policy_def; + info->audit_events.settings[LSA_AUDIT_CATEGORY_SYSTEM] = policy_def; + info->audit_events.settings[LSA_AUDIT_CATEGORY_USE_OF_USER_RIGHTS] = policy_def; break; } @@ -747,7 +745,7 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; } - init_dom_query_3(&r_u->ctr.info.id3, name, sid); + init_dom_query_3(&info->domain, name, sid); break; case 0x05: /* check if the user have enough rights */ @@ -757,7 +755,8 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF /* Request PolicyAccountDomainInformation. */ name = get_global_sam_name(); sid = get_global_sam_sid(); - init_dom_query_5(&r_u->ctr.info.id5, name, sid); + + init_dom_query_5(&info->account_domain, name, sid); break; case 0x06: /* check if the user have enough rights */ @@ -770,29 +769,27 @@ NTSTATUS _lsa_query_info(pipes_struct *p, LSA_Q_QUERY_INFO *q_u, LSA_R_QUERY_INF * only a BDC is a backup controller * of the domain, it controls. */ - ctr->info.id6.server_role = 2; + info->role.role = 2; break; default: /* * any other role is a primary * of the domain, it controls. */ - ctr->info.id6.server_role = 3; - break; + info->role.role = 3; + break; } break; default: - DEBUG(0,("_lsa_query_info: unknown info level in Lsa Query: %d\n", q_u->info_class)); - r_u->status = NT_STATUS_INVALID_INFO_CLASS; + DEBUG(0,("_lsa_QueryInfoPolicy: unknown info level in Lsa Query: %d\n", + r->in.level)); + status = NT_STATUS_INVALID_INFO_CLASS; break; } - if (NT_STATUS_IS_OK(r_u->status)) { - r_u->dom_ptr = 0x22000000; /* bizarre */ - ctr->info_class = q_u->info_class; - } + *r->out.info = info; - return r_u->status; + return status; } /*************************************************************************** @@ -2206,12 +2203,6 @@ NTSTATUS _lsa_ChangePassword(pipes_struct *p, struct lsa_ChangePassword *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, struct lsa_QueryInfoPolicy *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_SetInfoPolicy(pipes_struct *p, struct lsa_SetInfoPolicy *r) { p->rng_fault_state = True; -- cgit From b13277ed4e59c64f1c3c15109c85a8967c6260fe Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 01:56:09 +0100 Subject: Remove unused marshalling for LSA_QUERY_INFO2. Guenther (This used to be commit 0fac016d9d0018c983576d5cc8c3e06f40360b73) --- source3/rpc_server/srv_lsa_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 9f0d448364..61b9d19fa1 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1919,7 +1919,7 @@ NTSTATUS _lsa_QuerySecurity(pipes_struct *p, /*************************************************************************** ***************************************************************************/ -NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_INFO2 *r_u) + NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_INFO2 *r_u) { struct lsa_info *handle; const char *nb_name; -- cgit From d69a0b9f14b02c42d08c60dd50ba2da611a31d02 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 6 Feb 2008 21:29:17 +0100 Subject: Use pidl for _samr_LookupRids(). Guenther (This used to be commit fe3a02d44c4051ef84a182bdeb4130548d98db38) --- source3/rpc_server/srv_samr.c | 24 +--------- source3/rpc_server/srv_samr_nt.c | 95 ++++++++++++++++++++-------------------- 2 files changed, 49 insertions(+), 70 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 76cbb22f9f..d88033056a 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -258,29 +258,7 @@ static bool api_samr_chgpasswd_user(pipes_struct *p) static bool api_samr_lookup_rids(pipes_struct *p) { - SAMR_Q_LOOKUP_RIDS q_u; - SAMR_R_LOOKUP_RIDS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the samr lookup names */ - if(!samr_io_q_lookup_rids("", &q_u, data, 0)) { - DEBUG(0,("api_samr_lookup_rids: unable to unmarshall SAMR_Q_LOOKUP_RIDS.\n")); - return False; - } - - r_u.status = _samr_lookup_rids(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_lookup_rids("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_lookup_rids: unable to marshall SAMR_R_LOOKUP_RIDS.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_LOOKUPRIDS); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f7af95a2bf..6d3bca8ab9 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -103,6 +103,15 @@ static const struct generic_mapping ali_generic_mapping = { GENERIC_RIGHTS_ALIAS_EXECUTE, GENERIC_RIGHTS_ALIAS_ALL_ACCESS}; +/******************************************************************* + inits a structure. +********************************************************************/ + +static void init_lsa_String(struct lsa_String *name, const char *s) +{ + name->string = s; +} + /******************************************************************* *******************************************************************/ @@ -1684,60 +1693,54 @@ makes a SAMR_R_LOOKUP_RIDS structure. ********************************************************************/ static bool make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names, - const char **names, UNIHDR **pp_hdr_name, - UNISTR2 **pp_uni_name) + const char **names, + struct lsa_String **lsa_name_array_p) { - uint32 i; - UNIHDR *hdr_name=NULL; - UNISTR2 *uni_name=NULL; + struct lsa_String *lsa_name_array = NULL; + uint32_t i; - *pp_uni_name = NULL; - *pp_hdr_name = NULL; + *lsa_name_array_p = NULL; if (num_names != 0) { - hdr_name = TALLOC_ZERO_ARRAY(ctx, UNIHDR, num_names); - if (hdr_name == NULL) - return False; - - uni_name = TALLOC_ZERO_ARRAY(ctx,UNISTR2, num_names); - if (uni_name == NULL) - return False; + lsa_name_array = TALLOC_ZERO_ARRAY(ctx, struct lsa_String, num_names); + if (!lsa_name_array) { + return false; + } } for (i = 0; i < num_names; i++) { DEBUG(10, ("names[%d]:%s\n", i, names[i] && *names[i] ? names[i] : "")); - init_unistr2(&uni_name[i], names[i], UNI_FLAGS_NONE); - init_uni_hdr(&hdr_name[i], &uni_name[i]); + init_lsa_String(&lsa_name_array[i], names[i]); } - *pp_uni_name = uni_name; - *pp_hdr_name = hdr_name; + *lsa_name_array_p = lsa_name_array; - return True; + return true; } /******************************************************************* - _samr_lookup_rids + _samr_LookupRids ********************************************************************/ -NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOKUP_RIDS *r_u) +NTSTATUS _samr_LookupRids(pipes_struct *p, + struct samr_LookupRids *r) { + NTSTATUS status; const char **names; enum lsa_SidType *attrs = NULL; uint32 *wire_attrs = NULL; - UNIHDR *hdr_name = NULL; - UNISTR2 *uni_name = NULL; DOM_SID pol_sid; - int num_rids = (int)q_u->num_rids1; + int num_rids = (int)r->in.num_rids; uint32 acc_granted; int i; + struct lsa_Strings names_array; + struct samr_Ids types_array; + struct lsa_String *lsa_names = NULL; - r_u->status = NT_STATUS_OK; - - DEBUG(5,("_samr_lookup_rids: %d\n", __LINE__)); + DEBUG(5,("_samr_LookupRids: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid, &acc_granted, NULL)) + if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &pol_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; if (num_rids > 1000) { @@ -1760,28 +1763,36 @@ NTSTATUS _samr_lookup_rids(pipes_struct *p, SAMR_Q_LOOKUP_RIDS *q_u, SAMR_R_LOOK } become_root(); /* lookup_sid can require root privs */ - r_u->status = pdb_lookup_rids(&pol_sid, num_rids, q_u->rid, - names, attrs); + status = pdb_lookup_rids(&pol_sid, num_rids, r->in.rids, + names, attrs); unbecome_root(); - if ( NT_STATUS_EQUAL(r_u->status, NT_STATUS_NONE_MAPPED) && (num_rids == 0) ) { - r_u->status = NT_STATUS_OK; + if (NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED) && (num_rids == 0)) { + status = NT_STATUS_OK; } - if(!make_samr_lookup_rids(p->mem_ctx, num_rids, names, - &hdr_name, &uni_name)) + if (!make_samr_lookup_rids(p->mem_ctx, num_rids, names, + &lsa_names)) { return NT_STATUS_NO_MEMORY; + } /* Convert from enum lsa_SidType to uint32 for wire format. */ for (i = 0; i < num_rids; i++) { wire_attrs[i] = (uint32)attrs[i]; } - init_samr_r_lookup_rids(r_u, num_rids, hdr_name, uni_name, wire_attrs); + names_array.count = num_rids; + names_array.names = lsa_names; - DEBUG(5,("_samr_lookup_rids: %d\n", __LINE__)); + types_array.count = num_rids; + types_array.ids = wire_attrs; - return r_u->status; + *r->out.names = names_array; + *r->out.types = types_array; + + DEBUG(5,("_samr_LookupRids: %d\n", __LINE__)); + + return status; } /******************************************************************* @@ -5224,16 +5235,6 @@ NTSTATUS _samr_LookupNames(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_LookupRids(pipes_struct *p, - struct samr_LookupRids *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_SetMemberAttributesOfGroup(pipes_struct *p, struct samr_SetMemberAttributesOfGroup *r) { -- cgit From fddbd6ec1cfda5d77c5c11d6f165b8ac5bff039e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 13:29:01 +0100 Subject: Use pidl for _samr_LookupNames(). Guenther (This used to be commit 325bf05592c4d2e7c760de64f8869a44f7315ce9) --- source3/rpc_server/srv_samr.c | 24 +------------ source3/rpc_server/srv_samr_nt.c | 73 +++++++++++++++++++--------------------- 2 files changed, 35 insertions(+), 62 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index d88033056a..2321d56b77 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -218,29 +218,7 @@ static bool api_samr_query_aliasinfo(pipes_struct *p) static bool api_samr_lookup_names(pipes_struct *p) { - SAMR_Q_LOOKUP_NAMES q_u; - SAMR_R_LOOKUP_NAMES r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the samr lookup names */ - if(!samr_io_q_lookup_names("", &q_u, data, 0)) { - DEBUG(0,("api_samr_lookup_names: unable to unmarshall SAMR_Q_LOOKUP_NAMES.\n")); - return False; - } - - r_u.status = _samr_lookup_names(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_lookup_names("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_lookup_names: unable to marshall SAMR_R_LOOKUP_NAMES.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_LOOKUPNAMES); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6d3bca8ab9..9ed7014bff 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1471,75 +1471,80 @@ NTSTATUS _samr_QueryAliasInfo(pipes_struct *p, #endif /******************************************************************* - _samr_lookup_names + _samr_LookupNames ********************************************************************/ -NTSTATUS _samr_lookup_names(pipes_struct *p, SAMR_Q_LOOKUP_NAMES *q_u, SAMR_R_LOOKUP_NAMES *r_u) +NTSTATUS _samr_LookupNames(pipes_struct *p, + struct samr_LookupNames *r) { + NTSTATUS status; uint32 rid[MAX_SAM_ENTRIES]; enum lsa_SidType type[MAX_SAM_ENTRIES]; int i; - int num_rids = q_u->num_names2; + int num_rids = r->in.num_names; DOM_SID pol_sid; uint32 acc_granted; + struct samr_Ids rids, types; - r_u->status = NT_STATUS_OK; - - DEBUG(5,("_samr_lookup_names: %d\n", __LINE__)); + DEBUG(5,("_samr_LookupNames: %d\n", __LINE__)); ZERO_ARRAY(rid); ZERO_ARRAY(type); - if (!get_lsa_policy_samr_sid(p, &q_u->pol, &pol_sid, &acc_granted, NULL)) { - init_samr_r_lookup_names(p->mem_ctx, r_u, 0, NULL, NULL, NT_STATUS_OBJECT_TYPE_MISMATCH); - return r_u->status; + if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &pol_sid, &acc_granted, NULL)) { + return NT_STATUS_OBJECT_TYPE_MISMATCH; } - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, 0, "_samr_lookup_names"))) { /* Don't know the acc_bits yet */ - return r_u->status; + status = access_check_samr_function(acc_granted, + 0, /* Don't know the acc_bits yet */ + "_samr_LookupNames"); + if (!NT_STATUS_IS_OK(status)) { + return status; } if (num_rids > MAX_SAM_ENTRIES) { num_rids = MAX_SAM_ENTRIES; - DEBUG(5,("_samr_lookup_names: truncating entries to %d\n", num_rids)); + DEBUG(5,("_samr_LookupNames: truncating entries to %d\n", num_rids)); } - DEBUG(5,("_samr_lookup_names: looking name on SID %s\n", + DEBUG(5,("_samr_LookupNames: looking name on SID %s\n", sid_string_dbg(&pol_sid))); for (i = 0; i < num_rids; i++) { - fstring name; - int ret; - r_u->status = NT_STATUS_NONE_MAPPED; + status = NT_STATUS_NONE_MAPPED; type[i] = SID_NAME_UNKNOWN; - rid [i] = 0xffffffff; - - ret = rpcstr_pull(name, q_u->uni_name[i].buffer, sizeof(name), q_u->uni_name[i].uni_str_len*2, 0); - - if (ret <= 0) { - continue; - } + rid[i] = 0xffffffff; if (sid_check_is_builtin(&pol_sid)) { - if (lookup_builtin_name(name, &rid[i])) { + if (lookup_builtin_name(r->in.names[i].string, + &rid[i])) + { type[i] = SID_NAME_ALIAS; } } else { - lookup_global_sam_name(name, 0, &rid[i], &type[i]); + lookup_global_sam_name(r->in.names[i].string, 0, + &rid[i], &type[i]); } if (type[i] != SID_NAME_UNKNOWN) { - r_u->status = NT_STATUS_OK; + status = NT_STATUS_OK; } } - init_samr_r_lookup_names(p->mem_ctx, r_u, num_rids, rid, type, r_u->status); + rids.count = num_rids; + rids.ids = rid; - DEBUG(5,("_samr_lookup_names: %d\n", __LINE__)); + types.count = num_rids; + types.ids = type; - return r_u->status; + *r->out.rids = rids; + *r->out.types = types; + + DEBUG(5,("_samr_LookupNames: %d\n", __LINE__)); + + return status; } /******************************************************************* @@ -5225,16 +5230,6 @@ NTSTATUS _samr_EnumDomainAliases(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_LookupNames(pipes_struct *p, - struct samr_LookupNames *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_SetMemberAttributesOfGroup(pipes_struct *p, struct samr_SetMemberAttributesOfGroup *r) { -- cgit From 7643300a92d61a3b8d8a64d2ba94f3a37a426c6a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 6 Feb 2008 18:58:11 +0100 Subject: Use pidl for _lsa_CreateAccount(). Guenther (This used to be commit d71f56a293d67971c45ee44219752a55fb21f8be) --- source3/rpc_server/srv_lsa.c | 25 ++----------------------- source3/rpc_server/srv_lsa_nt.c | 21 ++++++++------------- 2 files changed, 10 insertions(+), 36 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index fd5d81548c..5811d8535b 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -307,29 +307,7 @@ static bool api_lsa_unk_get_connuser(pipes_struct *p) static bool api_lsa_create_account(pipes_struct *p) { - LSA_Q_CREATEACCOUNT q_u; - LSA_R_CREATEACCOUNT r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_create_account("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_create_account: failed to unmarshall LSA_Q_CREATEACCOUNT.\n")); - return False; - } - - r_u.status = _lsa_create_account(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_create_account("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_create_account: Failed to marshall LSA_R_CREATEACCOUNT.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_CREATEACCOUNT); } /*************************************************************************** @@ -943,6 +921,7 @@ static int count_fns(void) return funcs; } + void lsa_get_pipe_fns( struct api_struct **fns, int *n_fns ) { *fns = api_lsa_cmds; diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 61b9d19fa1..c197f20bfe 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1606,16 +1606,17 @@ NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA } /*************************************************************************** - Lsa Create Account + _lsa_CreateAccount ***************************************************************************/ -NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CREATEACCOUNT *r_u) +NTSTATUS _lsa_CreateAccount(pipes_struct *p, + struct lsa_CreateAccount *r) { struct lsa_info *handle; struct lsa_info *info; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ @@ -1633,7 +1634,7 @@ NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CR if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) return NT_STATUS_ACCESS_DENIED; - if ( is_privileged_sid( &q_u->sid.sid ) ) + if ( is_privileged_sid( r->in.sid ) ) return NT_STATUS_OBJECT_NAME_COLLISION; /* associate the user/group SID with the (unique) handle. */ @@ -1642,11 +1643,11 @@ NTSTATUS _lsa_create_account(pipes_struct *p, LSA_Q_CREATEACCOUNT *q_u, LSA_R_CR return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(info); - info->sid = q_u->sid.sid; - info->access = q_u->access; + info->sid = *r->in.sid; + info->access = r->in.access_mask; /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info)) + if (!create_policy_hnd(p, *r->out.acct_handle, free_lsa_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; return privilege_create_account( &info->sid ); @@ -2215,12 +2216,6 @@ NTSTATUS _lsa_ClearAuditLog(pipes_struct *p, struct lsa_ClearAuditLog *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_CreateAccount(pipes_struct *p, struct lsa_CreateAccount *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_EnumAccounts(pipes_struct *p, struct lsa_EnumAccounts *r) { p->rng_fault_state = True; -- cgit From 02abf612c8d7d6c9672df1f8ce02659737dc9254 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 6 Feb 2008 19:19:29 +0100 Subject: Use pidl for _lsa_OpenAccount(). Guenther (This used to be commit e1968880a88ad2a56c5fef7d416646dcb96965ef) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 19 +++++++------------ 2 files changed, 8 insertions(+), 35 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 5811d8535b..739508869e 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -316,29 +316,7 @@ static bool api_lsa_create_account(pipes_struct *p) static bool api_lsa_open_account(pipes_struct *p) { - LSA_Q_OPENACCOUNT q_u; - LSA_R_OPENACCOUNT r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_open_account("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_open_account: failed to unmarshall LSA_Q_OPENACCOUNT.\n")); - return False; - } - - r_u.status = _lsa_open_account(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_open_account("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_open_account: Failed to marshall LSA_R_OPENACCOUNT.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_OPENACCOUNT); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c197f20bfe..7b4de95ed6 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1655,16 +1655,17 @@ NTSTATUS _lsa_CreateAccount(pipes_struct *p, /*************************************************************************** - Lsa Open Account + _lsa_OpenAccount ***************************************************************************/ -NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENACCOUNT *r_u) +NTSTATUS _lsa_OpenAccount(pipes_struct *p, + struct lsa_OpenAccount *r) { struct lsa_info *handle; struct lsa_info *info; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ @@ -1686,11 +1687,11 @@ NTSTATUS _lsa_open_account(pipes_struct *p, LSA_Q_OPENACCOUNT *q_u, LSA_R_OPENAC return NT_STATUS_NO_MEMORY; ZERO_STRUCTP(info); - info->sid = q_u->sid.sid; - info->access = q_u->access; + info->sid = *r->in.sid; + info->access = r->in.access_mask; /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, &r_u->pol, free_lsa_info, (void *)info)) + if (!create_policy_hnd(p, *r->out.acct_handle, free_lsa_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; return NT_STATUS_OK; @@ -2240,12 +2241,6 @@ NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_OpenAccount(pipes_struct *p, struct lsa_OpenAccount *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_EnumPrivsAccount(pipes_struct *p, struct lsa_EnumPrivsAccount *r) { p->rng_fault_state = True; -- cgit From 9049db8ffb88508e73849d3c40ac93907c58fb80 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 18:32:05 +0100 Subject: Use pidl for _lsa_SetSystemAccessAccount(). Guenther (This used to be commit 478612b79d11fa1ad3bf16e317d63c2a00e1957a) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 12 +++--------- 2 files changed, 4 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 739508869e..057c8f691c 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -388,29 +388,7 @@ static bool api_lsa_getsystemaccount(pipes_struct *p) static bool api_lsa_setsystemaccount(pipes_struct *p) { - LSA_Q_SETSYSTEMACCOUNT q_u; - LSA_R_SETSYSTEMACCOUNT r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_setsystemaccount("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_setsystemaccount: failed to unmarshall LSA_Q_SETSYSTEMACCOUNT.\n")); - return False; - } - - r_u.status = _lsa_setsystemaccount(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_setsystemaccount("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_setsystemaccount: Failed to marshall LSA_R_SETSYSTEMACCOUNT.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_SETSYSTEMACCESSACCOUNT); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 7b4de95ed6..dd1ee3d357 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1766,14 +1766,14 @@ NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA update the systemaccount information ***************************************************************************/ -NTSTATUS _lsa_setsystemaccount(pipes_struct *p, LSA_Q_SETSYSTEMACCOUNT *q_u, LSA_R_SETSYSTEMACCOUNT *r_u) +NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p, + struct lsa_SetSystemAccessAccount *r) { struct lsa_info *info=NULL; GROUP_MAP map; - r_u->status = NT_STATUS_OK; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is a Domain Admin since @@ -2277,12 +2277,6 @@ NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p, struct lsa_GetSystemAccess return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p, struct lsa_SetSystemAccessAccount *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_QueryTrustedDomainInfo(pipes_struct *p, struct lsa_QueryTrustedDomainInfo *r) { p->rng_fault_state = True; -- cgit From 3dab928081bf80cb88fa4a56352ae063a5f82a43 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 18:54:02 +0100 Subject: Use pidl for _lsa_GetSystemAccessAccount(). Guenther (This used to be commit aaf662a724f1bae5333666caf8b2fbe908f13992) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 15 +++++---------- 2 files changed, 6 insertions(+), 33 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 057c8f691c..24bc65c51a 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -356,29 +356,7 @@ static bool api_lsa_enum_privsaccount(pipes_struct *p) static bool api_lsa_getsystemaccount(pipes_struct *p) { - LSA_Q_GETSYSTEMACCOUNT q_u; - LSA_R_GETSYSTEMACCOUNT r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_getsystemaccount("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_getsystemaccount: failed to unmarshall LSA_Q_GETSYSTEMACCOUNT.\n")); - return False; - } - - r_u.status = _lsa_getsystemaccount(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_getsystemaccount("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_getsystemaccount: Failed to marshall LSA_R_GETSYSTEMACCOUNT.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_GETSYSTEMACCESSACCOUNT); } diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index dd1ee3d357..247a52df46 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1733,16 +1733,17 @@ NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, prs_struct *ps, LSA_Q_ENUMPRIVS } /*************************************************************************** - + _lsa_GetSystemAccessAccount ***************************************************************************/ -NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA_R_GETSYSTEMACCOUNT *r_u) +NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p, + struct lsa_GetSystemAccessAccount *r) { struct lsa_info *info=NULL; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; if (!lookup_sid(p->mem_ctx, &info->sid, NULL, NULL, NULL)) @@ -1757,7 +1758,7 @@ NTSTATUS _lsa_getsystemaccount(pipes_struct *p, LSA_Q_GETSYSTEMACCOUNT *q_u, LSA they can be ORed together */ - r_u->access = PR_LOG_ON_LOCALLY | PR_ACCESS_FROM_NETWORK; + *r->out.access_mask = PR_LOG_ON_LOCALLY | PR_ACCESS_FROM_NETWORK; return NT_STATUS_OK; } @@ -2271,12 +2272,6 @@ NTSTATUS _lsa_SetQuotasForAccount(pipes_struct *p, struct lsa_SetQuotasForAccoun return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p, struct lsa_GetSystemAccessAccount *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_QueryTrustedDomainInfo(pipes_struct *p, struct lsa_QueryTrustedDomainInfo *r) { p->rng_fault_state = True; -- cgit From f621c1a9ab2344cd8548c676e1e15d6d04915b82 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 19:42:23 +0100 Subject: Pure cosmetics, breaking some very long lines. Guenther (This used to be commit 25c030136f62e48471acc0492907ac44e4316e19) --- source3/rpc_server/srv_samr_nt.c | 88 ++++++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 25 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 9ed7014bff..4c242dc323 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -586,8 +586,9 @@ NTSTATUS _samr_OpenDomain(pipes_struct *p, if ( !find_policy_by_hnd(p, r->in.connect_handle, (void**)(void *)&info) ) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function( info->acc_granted, - SA_RIGHT_SAM_OPEN_DOMAIN, "_samr_OpenDomain" ); + status = access_check_samr_function(info->acc_granted, + SA_RIGHT_SAM_OPEN_DOMAIN, + "_samr_OpenDomain" ); if ( !NT_STATUS_IS_OK(status) ) return status; @@ -728,7 +729,9 @@ NTSTATUS _samr_SetSecurity(pipes_struct *p, return NT_STATUS_ACCESS_DENIED; } - status = access_check_samr_function(acc_granted, SA_RIGHT_USER_SET_ATTRIBUTES, "_samr_SetSecurity"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_USER_SET_ATTRIBUTES, + "_samr_SetSecurity"); if (NT_STATUS_IS_OK(status)) { become_root(); status = pdb_update_sam_account(sampass); @@ -1550,9 +1553,9 @@ NTSTATUS _samr_LookupNames(pipes_struct *p, /******************************************************************* _samr_ChangePasswordUser2 ********************************************************************/ + NTSTATUS _samr_ChangePasswordUser2(pipes_struct *p, struct samr_ChangePasswordUser2 *r) - { NTSTATUS status; fstring user_name; @@ -1577,8 +1580,12 @@ NTSTATUS _samr_ChangePasswordUser2(pipes_struct *p, * is case insensitive. */ - status = pass_oem_change(user_name, r->in.lm_password->data, r->in.lm_verifier->hash, - r->in.nt_password->data, r->in.nt_verifier->hash, NULL); + status = pass_oem_change(user_name, + r->in.lm_password->data, + r->in.lm_verifier->hash, + r->in.nt_password->data, + r->in.nt_verifier->hash, + NULL); DEBUG(5,("_samr_ChangePasswordUser2: %d\n", __LINE__)); @@ -1825,8 +1832,9 @@ NTSTATUS _samr_OpenUser(pipes_struct *p, if ( !get_lsa_policy_samr_sid(p, &domain_pol, &sid, &acc_granted, NULL) ) return NT_STATUS_INVALID_HANDLE; - nt_status = access_check_samr_function( acc_granted, - SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenUser" ); + nt_status = access_check_samr_function(acc_granted, + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, + "_samr_OpenUser" ); if ( !NT_STATUS_IS_OK(nt_status) ) return nt_status; @@ -2940,6 +2948,7 @@ NTSTATUS _samr_Connect5(pipes_struct *p, /********************************************************************** _samr_LookupDomain **********************************************************************/ + NTSTATUS _samr_LookupDomain(pipes_struct *p, struct samr_LookupDomain *r) { @@ -3079,7 +3088,8 @@ NTSTATUS _samr_OpenAlias(pipes_struct *p, return NT_STATUS_INVALID_HANDLE; status = access_check_samr_function(acc_granted, - SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenAlias"); + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, + "_samr_OpenAlias"); if ( !NT_STATUS_IS_OK(status) ) return status; @@ -3894,8 +3904,12 @@ NTSTATUS _samr_GetAliasMembership(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.domain_handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - ntstatus1 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_LOOKUP_ALIAS_BY_MEM, "_samr_GetAliasMembership"); - ntstatus2 = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_GetAliasMembership"); + ntstatus1 = access_check_samr_function(info->acc_granted, + SA_RIGHT_DOMAIN_LOOKUP_ALIAS_BY_MEM, + "_samr_GetAliasMembership"); + ntstatus2 = access_check_samr_function(info->acc_granted, + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, + "_samr_GetAliasMembership"); if (!NT_STATUS_IS_OK(ntstatus1) || !NT_STATUS_IS_OK(ntstatus2)) { if (!(NT_STATUS_EQUAL(ntstatus1,NT_STATUS_ACCESS_DENIED) && NT_STATUS_IS_OK(ntstatus2)) && @@ -3960,7 +3974,9 @@ NTSTATUS _samr_GetMembersInAlias(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_GET_MEMBERS, "_samr_GetMembersInAlias"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_ALIAS_GET_MEMBERS, + "_samr_GetMembersInAlias"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4026,7 +4042,9 @@ NTSTATUS _samr_QueryGroupMember(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, NULL)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_GET_MEMBERS, "_samr_QueryGroupMember"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_GROUP_GET_MEMBERS, + "_samr_QueryGroupMember"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4088,7 +4106,9 @@ NTSTATUS _samr_AddAliasMember(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_ADD_MEMBER, "_samr_AddAliasMember"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_ALIAS_ADD_MEMBER, + "_samr_AddAliasMember"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4135,7 +4155,9 @@ NTSTATUS _samr_DeleteAliasMember(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.alias_handle, &alias_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, SA_RIGHT_ALIAS_REMOVE_MEMBER, "_samr_DeleteAliasMember"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_ALIAS_REMOVE_MEMBER, + "_samr_DeleteAliasMember"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4184,7 +4206,9 @@ NTSTATUS _samr_AddGroupMember(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_ADD_MEMBER, "_samr_AddGroupMember"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_GROUP_ADD_MEMBER, + "_samr_AddGroupMember"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4242,7 +4266,9 @@ NTSTATUS _samr_DeleteGroupMember(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, SA_RIGHT_GROUP_REMOVE_MEMBER, "_samr_DeleteGroupMember"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_GROUP_REMOVE_MEMBER, + "_samr_DeleteGroupMember"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4294,7 +4320,9 @@ NTSTATUS _samr_DeleteUser(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.user_handle, &user_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_DeleteUser"); + status = access_check_samr_function(acc_granted, + STD_RIGHT_DELETE_ACCESS, + "_samr_DeleteUser"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4379,7 +4407,9 @@ NTSTATUS _samr_DeleteDomainGroup(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.group_handle, &group_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_DeleteDomainGroup"); + status = access_check_samr_function(acc_granted, + STD_RIGHT_DELETE_ACCESS, + "_samr_DeleteDomainGroup"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4446,7 +4476,9 @@ NTSTATUS _samr_DeleteDomAlias(pipes_struct *p, memcpy(r->out.alias_handle, r->in.alias_handle, sizeof(r->out.alias_handle)); - status = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, "_samr_DeleteDomAlias"); + status = access_check_samr_function(acc_granted, + STD_RIGHT_DELETE_ACCESS, + "_samr_DeleteDomAlias"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4513,7 +4545,9 @@ NTSTATUS _samr_CreateDomainGroup(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &dom_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_GROUP, "_samr_CreateDomainGroup"); + status = access_check_samr_function(acc_granted, + SA_RIGHT_DOMAIN_CREATE_GROUP, + "_samr_CreateDomainGroup"); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -4593,7 +4627,9 @@ NTSTATUS _samr_CreateDomAlias(pipes_struct *p, if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &dom_sid, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - result = access_check_samr_function(acc_granted, SA_RIGHT_DOMAIN_CREATE_ALIAS, "_samr_CreateDomAlias"); + result = access_check_samr_function(acc_granted, + SA_RIGHT_DOMAIN_CREATE_ALIAS, + "_samr_CreateDomAlias"); if (!NT_STATUS_IS_OK(result)) { return result; } @@ -4982,7 +5018,8 @@ NTSTATUS _samr_OpenGroup(pipes_struct *p, return NT_STATUS_INVALID_HANDLE; status = access_check_samr_function(acc_granted, - SA_RIGHT_DOMAIN_OPEN_ACCOUNT, "_samr_OpenGroup"); + SA_RIGHT_DOMAIN_OPEN_ACCOUNT, + "_samr_OpenGroup"); if ( !NT_STATUS_IS_OK(status) ) return status; @@ -5053,8 +5090,9 @@ NTSTATUS _samr_RemoveMemberFromForeignDomain(pipes_struct *p, &acc_granted, &disp_info)) return NT_STATUS_INVALID_HANDLE; - result = access_check_samr_function(acc_granted, STD_RIGHT_DELETE_ACCESS, - "_samr_RemoveMemberFromForeignDomain"); + result = access_check_samr_function(acc_granted, + STD_RIGHT_DELETE_ACCESS, + "_samr_RemoveMemberFromForeignDomain"); if (!NT_STATUS_IS_OK(result)) return result; -- cgit From da3e2d4c2797a9ea43312ba7bdb5bc9710c94004 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 9 Feb 2008 01:33:47 +0100 Subject: Testing revealed some errors, reverting some of the lsa changes. Guenther (This used to be commit ac1e4f1eb2c046def4fa30ab0bd98c49add8e8c8) --- source3/rpc_server/srv_lsa_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 247a52df46..6e25a64236 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1647,7 +1647,7 @@ NTSTATUS _lsa_CreateAccount(pipes_struct *p, info->access = r->in.access_mask; /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, *r->out.acct_handle, free_lsa_info, (void *)info)) + if (!create_policy_hnd(p, r->out.acct_handle, free_lsa_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; return privilege_create_account( &info->sid ); @@ -1691,7 +1691,7 @@ NTSTATUS _lsa_OpenAccount(pipes_struct *p, info->access = r->in.access_mask; /* get a (unique) handle. open a policy on it. */ - if (!create_policy_hnd(p, *r->out.acct_handle, free_lsa_info, (void *)info)) + if (!create_policy_hnd(p, r->out.acct_handle, free_lsa_info, (void *)info)) return NT_STATUS_OBJECT_NAME_NOT_FOUND; return NT_STATUS_OK; -- cgit From 67536ed68fa184496c1a27dc3bd7ff6a2720f0ef Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 9 Feb 2008 01:55:49 +0100 Subject: Use pidl for _samr_EnumDomains(). Guenther (This used to be commit 2d5e2abc2715acaddd2d05c9d0b634a3595143f1) --- source3/rpc_server/srv_samr.c | 22 +-------- source3/rpc_server/srv_samr_nt.c | 98 ++++++++++++++-------------------------- 2 files changed, 35 insertions(+), 85 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 2321d56b77..771c1e3341 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -365,27 +365,7 @@ static bool api_samr_lookup_domain(pipes_struct *p) static bool api_samr_enum_domains(pipes_struct *p) { - SAMR_Q_ENUM_DOMAINS q_u; - SAMR_R_ENUM_DOMAINS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!samr_io_q_enum_domains("", &q_u, data, 0)) { - DEBUG(0,("api_samr_enum_domains: Unable to unmarshall SAMR_Q_ENUM_DOMAINS.\n")); - return False; - } - - r_u.status = _samr_enum_domains(p, &q_u, &r_u); - - if(!samr_io_r_enum_domains("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_enum_domains: Unable to marshall SAMR_R_ENUM_DOMAINS.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_ENUMDOMAINS); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 4c242dc323..6619e0651e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2993,74 +2993,54 @@ NTSTATUS _samr_LookupDomain(pipes_struct *p, return status; } -/****************************************************************** -makes a SAMR_R_ENUM_DOMAINS structure. -********************************************************************/ - -static bool make_enum_domains(TALLOC_CTX *ctx, SAM_ENTRY **pp_sam, - UNISTR2 **pp_uni_name, uint32 num_sam_entries, fstring doms[]) -{ - uint32 i; - SAM_ENTRY *sam; - UNISTR2 *uni_name; - - DEBUG(5, ("make_enum_domains\n")); - - *pp_sam = NULL; - *pp_uni_name = NULL; - - if (num_sam_entries == 0) - return True; - - sam = TALLOC_ZERO_ARRAY(ctx, SAM_ENTRY, num_sam_entries); - uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_sam_entries); - - if (sam == NULL || uni_name == NULL) - return False; - - for (i = 0; i < num_sam_entries; i++) { - init_unistr2(&uni_name[i], doms[i], UNI_FLAGS_NONE); - init_sam_entry(&sam[i], &uni_name[i], 0); - } - - *pp_sam = sam; - *pp_uni_name = uni_name; - - return True; -} - /********************************************************************** - api_samr_enum_domains + _samr_EnumDomains **********************************************************************/ -NTSTATUS _samr_enum_domains(pipes_struct *p, SAMR_Q_ENUM_DOMAINS *q_u, SAMR_R_ENUM_DOMAINS *r_u) +NTSTATUS _samr_EnumDomains(pipes_struct *p, + struct samr_EnumDomains *r) { + NTSTATUS status; struct samr_info *info; - uint32 num_entries = 2; - fstring dom[2]; - const char *name; - - r_u->status = NT_STATUS_OK; + uint32_t num_entries = 2; + struct samr_SamEntry *entry_array = NULL; + struct samr_SamArray *sam; - if (!find_policy_by_hnd(p, &q_u->pol, (void**)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.connect_handle, (void**)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, SA_RIGHT_SAM_ENUM_DOMAINS, "_samr_enum_domains"))) { - return r_u->status; + status = access_check_samr_function(info->acc_granted, + SA_RIGHT_SAM_ENUM_DOMAINS, + "_samr_EnumDomains"); + if (!NT_STATUS_IS_OK(status)) { + return status; } - name = get_global_sam_name(); - - fstrcpy(dom[0],name); - strupper_m(dom[0]); - fstrcpy(dom[1],"Builtin"); + sam = TALLOC_ZERO_P(p->mem_ctx, struct samr_SamArray); + if (!sam) { + return NT_STATUS_NO_MEMORY; + } - if (!make_enum_domains(p->mem_ctx, &r_u->sam, &r_u->uni_dom_name, num_entries, dom)) + entry_array = TALLOC_ZERO_ARRAY(p->mem_ctx, + struct samr_SamEntry, + num_entries); + if (!entry_array) { return NT_STATUS_NO_MEMORY; + } - init_samr_r_enum_domains(r_u, q_u->start_idx + num_entries, num_entries); + entry_array[0].idx = 0; + init_lsa_String(&entry_array[0].name, get_global_sam_name()); - return r_u->status; + entry_array[1].idx = 1; + init_lsa_String(&entry_array[1].name, "Builtin"); + + sam->count = num_entries; + sam->entries = entry_array; + + *r->out.sam = sam; + *r->out.num_entries = num_entries; + + return status; } /******************************************************************* @@ -5218,16 +5198,6 @@ NTSTATUS _samr_Shutdown(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_EnumDomains(pipes_struct *p, - struct samr_EnumDomains *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_EnumDomainGroups(pipes_struct *p, struct samr_EnumDomainGroups *r) { -- cgit From e1bd9c30b0eb442b3ccd178bd488d9e75679acfb Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Feb 2008 10:19:54 +0100 Subject: Use pidl for _lsa_EnumPrivs(). Guenther (This used to be commit 62944007315c1744e2d2db7db593bc72af4b643b) --- source3/rpc_server/srv_lsa.c | 23 +------------------ source3/rpc_server/srv_lsa_nt.c | 49 ++++++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 47 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 24bc65c51a..d24929b3af 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -186,28 +186,7 @@ static bool api_lsa_open_secret(pipes_struct *p) static bool api_lsa_enum_privs(pipes_struct *p) { - LSA_Q_ENUM_PRIVS q_u; - LSA_R_ENUM_PRIVS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_enum_privs("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_enum_privs: failed to unmarshall LSA_Q_ENUM_PRIVS.\n")); - return False; - } - - r_u.status = _lsa_enum_privs(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_enum_privs("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_enum_privs: Failed to marshall LSA_R_ENUM_PRIVS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_ENUMPRIVS); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 6e25a64236..60414a9372 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1403,16 +1403,17 @@ NTSTATUS _lsa_DeleteObject(pipes_struct *p, } /*************************************************************************** -_lsa_enum_privs. + _lsa_EnumPrivs ***************************************************************************/ -NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIVS *r_u) +NTSTATUS _lsa_EnumPrivs(pipes_struct *p, + struct lsa_EnumPrivs *r) { struct lsa_info *handle; uint32 i; - uint32 enum_context = q_u->enum_context; + uint32 enum_context = *r->in.resume_handle; int num_privs = count_all_privileges(); - LSA_PRIV_ENTRY *entries = NULL; + struct lsa_PrivEntry *entries = NULL; LUID_ATTR luid; /* remember that the enum_context starts at 0 and not 1 */ @@ -1423,7 +1424,7 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV DEBUG(10,("_lsa_enum_privs: enum_context:%d total entries:%d\n", enum_context, num_privs)); - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights @@ -1433,33 +1434,37 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV return NT_STATUS_ACCESS_DENIED; if (num_privs) { - if ( !(entries = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_PRIV_ENTRY, num_privs )) ) + entries = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_PrivEntry, num_privs); + if (!entries) { return NT_STATUS_NO_MEMORY; + } } else { entries = NULL; } for (i = 0; i < num_privs; i++) { if( i < enum_context) { - init_unistr2(&entries[i].name, NULL, UNI_FLAGS_NONE); - init_uni_hdr(&entries[i].hdr_name, &entries[i].name); - - entries[i].luid_low = 0; - entries[i].luid_high = 0; + + init_lsa_StringLarge(&entries[i].name, NULL); + + entries[i].luid.low = 0; + entries[i].luid.high = 0; } else { - init_unistr2(&entries[i].name, privs[i].name, UNI_FLAGS_NONE); - init_uni_hdr(&entries[i].hdr_name, &entries[i].name); - + + init_lsa_StringLarge(&entries[i].name, privs[i].name); + luid = get_privilege_luid( &privs[i].se_priv ); - - entries[i].luid_low = luid.luid.low; - entries[i].luid_high = luid.luid.high; + + entries[i].luid.low = luid.luid.low; + entries[i].luid.high = luid.luid.high; } } enum_context = num_privs; - - init_lsa_r_enum_privs(r_u, enum_context, num_privs, entries); + + *r->out.resume_handle = enum_context; + r->out.privs->count = num_privs; + r->out.privs->privs = entries; return NT_STATUS_OK; } @@ -2188,12 +2193,6 @@ NTSTATUS _lsa_Delete(pipes_struct *p, struct lsa_Delete *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumPrivs(pipes_struct *p, struct lsa_EnumPrivs *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_SetSecObj(pipes_struct *p, struct lsa_SetSecObj *r) { p->rng_fault_state = True; -- cgit From 419ab84b0188b81025d66637415047cc87986792 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Feb 2008 11:57:29 +0100 Subject: Use pidl for _lsa_LookupPrivDisplayName(). Guenther (This used to be commit c86640320199898cc5e3040bc3339db683e98da8) --- source3/rpc_server/srv_lsa.c | 23 +------------------ source3/rpc_server/srv_lsa_nt.c | 51 ++++++++++++++++++----------------------- 2 files changed, 23 insertions(+), 51 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index d24929b3af..9f3dd9031c 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -195,28 +195,7 @@ static bool api_lsa_enum_privs(pipes_struct *p) static bool api_lsa_priv_get_dispname(pipes_struct *p) { - LSA_Q_PRIV_GET_DISPNAME q_u; - LSA_R_PRIV_GET_DISPNAME r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_priv_get_dispname("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_priv_get_dispname: failed to unmarshall LSA_Q_PRIV_GET_DISPNAME.\n")); - return False; - } - - r_u.status = _lsa_priv_get_dispname(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_priv_get_dispname("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_priv_get_dispname: Failed to marshall LSA_R_PRIV_GET_DISPNAME.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPPRIVDISPLAYNAME); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 60414a9372..bb87422bf9 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1470,16 +1470,17 @@ NTSTATUS _lsa_EnumPrivs(pipes_struct *p, } /*************************************************************************** -_lsa_priv_get_dispname. + _lsa_LookupPrivDisplayName ***************************************************************************/ -NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, LSA_R_PRIV_GET_DISPNAME *r_u) +NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p, + struct lsa_LookupPrivDisplayName *r) { struct lsa_info *handle; - fstring name_asc; const char *description; + struct lsa_StringLarge *lsa_name; - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ @@ -1490,29 +1491,27 @@ NTSTATUS _lsa_priv_get_dispname(pipes_struct *p, LSA_Q_PRIV_GET_DISPNAME *q_u, L if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - unistr2_to_ascii(name_asc, &q_u->name, sizeof(name_asc)); + DEBUG(10,("_lsa_LookupPrivDisplayName: name = %s\n", r->in.name->string)); - DEBUG(10,("_lsa_priv_get_dispname: name = %s\n", name_asc)); + description = get_privilege_dispname(r->in.name->string); + if (!description) { + DEBUG(10,("_lsa_LookupPrivDisplayName: doesn't exist\n")); + return NT_STATUS_NO_SUCH_PRIVILEGE; + } - description = get_privilege_dispname( name_asc ); - - if ( description ) { - DEBUG(10,("_lsa_priv_get_dispname: display name = %s\n", description)); - - init_unistr2(&r_u->desc, description, UNI_FLAGS_NONE); - init_uni_hdr(&r_u->hdr_desc, &r_u->desc); + DEBUG(10,("_lsa_LookupPrivDisplayName: display name = %s\n", description)); - r_u->ptr_info = 0xdeadbeef; - r_u->lang_id = q_u->lang_id; - - return NT_STATUS_OK; - } else { - DEBUG(10,("_lsa_priv_get_dispname: doesn't exist\n")); - - r_u->ptr_info = 0; - - return NT_STATUS_NO_SUCH_PRIVILEGE; + lsa_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_StringLarge); + if (!lsa_name) { + return NT_STATUS_NO_MEMORY; } + + init_lsa_StringLarge(lsa_name, description); + + *r->out.returned_language_id = r->in.language_id; + *r->out.disp_name = lsa_name; + + return NT_STATUS_OK; } /*************************************************************************** @@ -2301,12 +2300,6 @@ NTSTATUS _lsa_LookupPrivName(pipes_struct *p, struct lsa_LookupPrivName *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p, struct lsa_LookupPrivDisplayName *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_EnumAccountsWithUserRight(pipes_struct *p, struct lsa_EnumAccountsWithUserRight *r) { p->rng_fault_state = True; -- cgit From e917a8a94a985154e86b792924246cdfcc527e0a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Feb 2008 20:29:31 +0100 Subject: Use pidl for _lsa_GetUserName(). Guenther (This used to be commit b24cf05dcad5696a7b948c93de9e995c2b53e80f) --- source3/rpc_server/srv_lsa.c | 24 +-------------------- source3/rpc_server/srv_lsa_nt.c | 48 ++++++++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 43 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 9f3dd9031c..9865a70e72 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -234,29 +234,7 @@ static bool api_lsa_enum_accounts(pipes_struct *p) static bool api_lsa_unk_get_connuser(pipes_struct *p) { - LSA_Q_UNK_GET_CONNUSER q_u; - LSA_R_UNK_GET_CONNUSER r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_unk_get_connuser("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_unk_get_connuser: failed to unmarshall LSA_Q_UNK_GET_CONNUSER.\n")); - return False; - } - - r_u.status = _lsa_unk_get_connuser(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_unk_get_connuser("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_unk_get_connuser: Failed to marshall LSA_R_UNK_GET_CONNUSER.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_GETUSERNAME); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index bb87422bf9..769dd8ad57 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -55,6 +55,10 @@ static void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s) name->string = s; } +static void init_lsa_String(struct lsa_String *name, const char *s) +{ + name->string = s; +} /******************************************************************* Function to free the per handle data. @@ -1570,12 +1574,18 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU return NT_STATUS_OK; } +/*************************************************************************** + _lsa_GetUserName + ***************************************************************************/ -NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u) +NTSTATUS _lsa_GetUserName(pipes_struct *p, + struct lsa_GetUserName *r) { const char *username, *domname; user_struct *vuser = get_valid_user_struct(p->vuid); - + struct lsa_String *account_name = NULL; + struct lsa_String *authority_name = NULL; + if (vuser == NULL) return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; @@ -1593,20 +1603,24 @@ NTSTATUS _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA username = vuser->user.smb_name; domname = vuser->user.domain; } - - r_u->ptr_user_name = 1; - init_unistr2(&r_u->uni2_user_name, username, UNI_STR_TERMINATE); - init_uni_hdr(&r_u->hdr_user_name, &r_u->uni2_user_name); - r_u->unk1 = 1; - - r_u->ptr_dom_name = 1; - init_unistr2(&r_u->uni2_dom_name, domname, UNI_STR_TERMINATE); - init_uni_hdr(&r_u->hdr_dom_name, &r_u->uni2_dom_name); + account_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_String); + if (!account_name) { + return NT_STATUS_NO_MEMORY; + } - r_u->status = NT_STATUS_OK; - - return r_u->status; + authority_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_String); + if (!authority_name) { + return NT_STATUS_NO_MEMORY; + } + + init_lsa_String(account_name, username); + init_lsa_String(authority_name, domname); + + *r->out.account_name = account_name; + *r->out.authority_name = authority_name; + + return NT_STATUS_OK; } /*************************************************************************** @@ -2354,12 +2368,6 @@ NTSTATUS _lsa_RetrievePrivateData(pipes_struct *p, struct lsa_RetrievePrivateDat return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_GetUserName(pipes_struct *p, struct lsa_GetUserName *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_QueryInfoPolicy2(pipes_struct *p, struct lsa_QueryInfoPolicy2 *r) { p->rng_fault_state = True; -- cgit From 6bb6af65abfced64576d990b5f734d61130b3d77 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Feb 2008 21:09:21 +0100 Subject: Use pidl for _samr_SetUserInfo and _samr_SetUserInfo2. Guenther (This used to be commit d148ffbc955aa62e42ab480e41d3a9b8c63117cd) --- source3/rpc_server/srv_samr.c | 51 +--- source3/rpc_server/srv_samr_nt.c | 239 +++++++++-------- source3/rpc_server/srv_samr_util.c | 514 ++++--------------------------------- 3 files changed, 174 insertions(+), 630 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 771c1e3341..8d626fced9 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -383,33 +383,7 @@ static bool api_samr_open_alias(pipes_struct *p) static bool api_samr_set_userinfo(pipes_struct *p) { - SAMR_Q_SET_USERINFO q_u; - SAMR_R_SET_USERINFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_set_userinfo("", &q_u, data, 0)) { - DEBUG(0,("api_samr_set_userinfo: Unable to unmarshall SAMR_Q_SET_USERINFO.\n")); - /* Fix for W2K SP2 */ - /* what is that status-code ? - gd */ - if (q_u.switch_value == 0x1a) { - setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG)); - return True; - } - return False; - } - - r_u.status = _samr_set_userinfo(p, &q_u, &r_u); - - if(!samr_io_r_set_userinfo("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_set_userinfo: Unable to marshall SAMR_R_SET_USERINFO.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_SETUSERINFO); } /******************************************************************* @@ -418,28 +392,7 @@ static bool api_samr_set_userinfo(pipes_struct *p) static bool api_samr_set_userinfo2(pipes_struct *p) { - SAMR_Q_SET_USERINFO2 q_u; - SAMR_R_SET_USERINFO2 r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if (!samr_io_q_set_userinfo2("", &q_u, data, 0)) { - DEBUG(0,("api_samr_set_userinfo2: Unable to unmarshall SAMR_Q_SET_USERINFO2.\n")); - return False; - } - - r_u.status = _samr_set_userinfo2(p, &q_u, &r_u); - - if(!samr_io_r_set_userinfo2("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_set_userinfo2: Unable to marshall SAMR_R_SET_USERINFO2.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_SETUSERINFO2); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6619e0651e..cb5bfe5440 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3132,10 +3132,11 @@ NTSTATUS _samr_OpenAlias(pipes_struct *p, /******************************************************************* set_user_info_7 ********************************************************************/ + static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx, - const SAM_USER_INFO_7 *id7, struct samu *pwd) + struct samr_UserInfo7 *id7, + struct samu *pwd) { - fstring new_name; NTSTATUS rc; if (id7 == NULL) { @@ -3144,7 +3145,7 @@ static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx, return NT_STATUS_ACCESS_DENIED; } - if(!rpcstr_pull(new_name, id7->uni_name.buffer, sizeof(new_name), id7->uni_name.uni_str_len*2, 0)) { + if (!id7->account_name.string) { DEBUG(5, ("set_user_info_7: failed to get new username\n")); TALLOC_FREE(pwd); return NT_STATUS_ACCESS_DENIED; @@ -3159,12 +3160,12 @@ static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx, simply that the rename fails with a slightly different status code (like UNSUCCESSFUL instead of ALREADY_EXISTS). */ - rc = can_create(mem_ctx, new_name); + rc = can_create(mem_ctx, id7->account_name.string); if (!NT_STATUS_IS_OK(rc)) { return rc; } - rc = pdb_rename_sam_account(pwd, new_name); + rc = pdb_rename_sam_account(pwd, id7->account_name.string); TALLOC_FREE(pwd); return rc; @@ -3174,7 +3175,8 @@ static NTSTATUS set_user_info_7(TALLOC_CTX *mem_ctx, set_user_info_16 ********************************************************************/ -static bool set_user_info_16(const SAM_USER_INFO_16 *id16, struct samu *pwd) +static bool set_user_info_16(struct samr_UserInfo16 *id16, + struct samu *pwd) { if (id16 == NULL) { DEBUG(5, ("set_user_info_16: NULL id16\n")); @@ -3183,7 +3185,7 @@ static bool set_user_info_16(const SAM_USER_INFO_16 *id16, struct samu *pwd) } /* FIX ME: check if the value is really changed --metze */ - if (!pdb_set_acct_ctrl(pwd, id16->acb_info, PDB_CHANGED)) { + if (!pdb_set_acct_ctrl(pwd, id16->acct_flags, PDB_CHANGED)) { TALLOC_FREE(pwd); return False; } @@ -3202,20 +3204,20 @@ static bool set_user_info_16(const SAM_USER_INFO_16 *id16, struct samu *pwd) set_user_info_18 ********************************************************************/ -static bool set_user_info_18(SAM_USER_INFO_18 *id18, struct samu *pwd) +static bool set_user_info_18(struct samr_UserInfo18 *id18, + struct samu *pwd) { - if (id18 == NULL) { DEBUG(2, ("set_user_info_18: id18 is NULL\n")); TALLOC_FREE(pwd); return False; } - if (!pdb_set_lanman_passwd (pwd, id18->lm_pwd, PDB_CHANGED)) { + if (!pdb_set_lanman_passwd (pwd, id18->lm_pwd.hash, PDB_CHANGED)) { TALLOC_FREE(pwd); return False; } - if (!pdb_set_nt_passwd (pwd, id18->nt_pwd, PDB_CHANGED)) { + if (!pdb_set_nt_passwd (pwd, id18->nt_pwd.hash, PDB_CHANGED)) { TALLOC_FREE(pwd); return False; } @@ -3237,7 +3239,8 @@ static bool set_user_info_18(SAM_USER_INFO_18 *id18, struct samu *pwd) set_user_info_20 ********************************************************************/ -static bool set_user_info_20(SAM_USER_INFO_20 *id20, struct samu *pwd) +static bool set_user_info_20(struct samr_UserInfo20 *id20, + struct samu *pwd) { if (id20 == NULL) { DEBUG(5, ("set_user_info_20: NULL id20\n")); @@ -3256,14 +3259,15 @@ static bool set_user_info_20(SAM_USER_INFO_20 *id20, struct samu *pwd) return True; } + /******************************************************************* set_user_info_21 ********************************************************************/ -static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, +static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, + struct samr_UserInfo21 *id21, struct samu *pwd) { - fstring new_name; NTSTATUS status; if (id21 == NULL) { @@ -3273,9 +3277,8 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, /* we need to separately check for an account rename first */ - if (rpcstr_pull(new_name, id21->uni_user_name.buffer, - sizeof(new_name), id21->uni_user_name.uni_str_len*2, 0) - && (!strequal(new_name, pdb_get_username(pwd)))) + if (id21->account_name.string && + (!strequal(id21->account_name.string, pdb_get_username(pwd)))) { /* check to see if the new username already exists. Note: we can't @@ -3287,12 +3290,12 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, simply that the rename fails with a slightly different status code (like UNSUCCESSFUL instead of ALREADY_EXISTS). */ - status = can_create(mem_ctx, new_name); + status = can_create(mem_ctx, id21->account_name.string); if (!NT_STATUS_IS_OK(status)) { return status; } - status = pdb_rename_sam_account(pwd, new_name); + status = pdb_rename_sam_account(pwd, id21->account_name.string); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("set_user_info_21: failed to rename account: %s\n", @@ -3303,7 +3306,7 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, /* set the new username so that later functions can work on the new account */ - pdb_set_username(pwd, new_name, PDB_SET); + pdb_set_username(pwd, id21->account_name.string, PDB_SET); } copy_id21_to_sam_passwd(pwd, id21); @@ -3341,7 +3344,8 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, set_user_info_23 ********************************************************************/ -static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, +static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, + struct samr_UserInfo23 *id23, struct samu *pwd) { char *plaintext_buf = NULL; @@ -3360,7 +3364,7 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, SAM_USER_INFO_23 *id23, acct_ctrl = pdb_get_acct_ctrl(pwd); if (!decode_pw_buffer(mem_ctx, - id23->pass, + id23->password.data, &plaintext_buf, &len, STR_UNICODE)) { @@ -3508,7 +3512,8 @@ static bool set_user_info_pw(uint8 *pass, struct samu *pwd) set_user_info_25 ********************************************************************/ -static NTSTATUS set_user_info_25(TALLOC_CTX *mem_ctx, SAM_USER_INFO_25 *id25, +static NTSTATUS set_user_info_25(TALLOC_CTX *mem_ctx, + struct samr_UserInfo25 *id25, struct samu *pwd) { NTSTATUS status; @@ -3548,16 +3553,18 @@ static NTSTATUS set_user_info_25(TALLOC_CTX *mem_ctx, SAM_USER_INFO_25 *id25, } /******************************************************************* - samr_reply_set_userinfo + _samr_SetUserInfo ********************************************************************/ -NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SET_USERINFO *r_u) +NTSTATUS _samr_SetUserInfo(pipes_struct *p, + struct samr_SetUserInfo *r) { + NTSTATUS status; struct samu *pwd = NULL; DOM_SID sid; - POLICY_HND *pol = &q_u->pol; - uint16 switch_value = q_u->switch_value; - SAM_USERINFO_CTR *ctr = q_u->ctr; + POLICY_HND *pol = r->in.user_handle; + uint16 switch_value = r->in.level; + union samr_UserInfo *info = r->in.info; uint32 acc_granted; uint32 acc_required; bool ret; @@ -3565,9 +3572,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE uint32 acb_info; DISP_INFO *disp_info = NULL; - DEBUG(5, ("_samr_set_userinfo: %d\n", __LINE__)); - - r_u->status = NT_STATUS_OK; + DEBUG(5, ("_samr_SetUserInfo: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info)) @@ -3592,15 +3597,18 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE break; } - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo"))) { - return r_u->status; + status = access_check_samr_function(acc_granted, + acc_required, + "_samr_SetUserInfo"); + if (!NT_STATUS_IS_OK(status)) { + return status; } - DEBUG(5, ("_samr_set_userinfo: sid:%s, level:%d\n", + DEBUG(5, ("_samr_SetUserInfo: sid:%s, level:%d\n", sid_string_dbg(&sid), switch_value)); - if (ctr == NULL) { - DEBUG(5, ("_samr_set_userinfo: NULL info level\n")); + if (info == NULL) { + DEBUG(5, ("_samr_SetUserInfo: NULL info level\n")); return NT_STATUS_INVALID_INFO_CLASS; } @@ -3630,7 +3638,7 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); } - DEBUG(5, ("_samr_set_userinfo: %s does%s possess sufficient rights\n", + DEBUG(5, ("_samr_SetUserInfo: %s does%s possess sufficient rights\n", uidtoname(p->pipe_user.ut.uid), has_enough_rights ? "" : " not")); @@ -3643,65 +3651,67 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE switch (switch_value) { case 18: - if (!set_user_info_18(ctr->info.id18, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_18(&info->info18, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; case 24: if (!p->session_key.length) { - r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + status = NT_STATUS_NO_USER_SESSION_KEY; } - SamOEMhashBlob(ctr->info.id24->pass, 516, &p->session_key); + SamOEMhashBlob(info->info24.password.data, + 516, + &p->session_key); - dump_data(100, ctr->info.id24->pass, 516); + dump_data(100, info->info24.password.data, 516); - if (!set_user_info_pw(ctr->info.id24->pass, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_pw(info->info24.password.data, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; case 25: if (!p->session_key.length) { - r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + status = NT_STATUS_NO_USER_SESSION_KEY; } - encode_or_decode_arc4_passwd_buffer(ctr->info.id25->pass, &p->session_key); + encode_or_decode_arc4_passwd_buffer(info->info25.password.data, &p->session_key); - dump_data(100, ctr->info.id25->pass, 532); + dump_data(100, info->info25.password.data, 532); - r_u->status = set_user_info_25(p->mem_ctx, - ctr->info.id25, pwd); - if (!NT_STATUS_IS_OK(r_u->status)) { + status = set_user_info_25(p->mem_ctx, + &info->info25, pwd); + if (!NT_STATUS_IS_OK(status)) { goto done; } - if (!set_user_info_pw(ctr->info.id25->pass, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_pw(info->info25.password.data, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; case 26: if (!p->session_key.length) { - r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + status = NT_STATUS_NO_USER_SESSION_KEY; } - encode_or_decode_arc4_passwd_buffer(ctr->info.id26->pass, &p->session_key); + encode_or_decode_arc4_passwd_buffer(info->info26.password.data, &p->session_key); - dump_data(100, ctr->info.id26->pass, 516); + dump_data(100, info->info26.password.data, 516); - if (!set_user_info_pw(ctr->info.id26->pass, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_pw(info->info26.password.data, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; case 23: if (!p->session_key.length) { - r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + status = NT_STATUS_NO_USER_SESSION_KEY; } - SamOEMhashBlob(ctr->info.id23->pass, 516, &p->session_key); + SamOEMhashBlob(info->info23.password.data, 516, &p->session_key); - dump_data(100, ctr->info.id23->pass, 516); + dump_data(100, info->info23.password.data, 516); - r_u->status = set_user_info_23(p->mem_ctx, - ctr->info.id23, pwd); + status = set_user_info_23(p->mem_ctx, + &info->info23, pwd); break; default: - r_u->status = NT_STATUS_INVALID_INFO_CLASS; + status = NT_STATUS_INVALID_INFO_CLASS; } done: @@ -3711,24 +3721,26 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE /* ================ END SeMachineAccountPrivilege BLOCK ================ */ - if (NT_STATUS_IS_OK(r_u->status)) { + if (NT_STATUS_IS_OK(status)) { force_flush_samr_cache(disp_info); } - return r_u->status; + return status; } /******************************************************************* - samr_reply_set_userinfo2 + _samr_SetUserInfo2 ********************************************************************/ -NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_SET_USERINFO2 *r_u) +NTSTATUS _samr_SetUserInfo2(pipes_struct *p, + struct samr_SetUserInfo2 *r) { + NTSTATUS status; struct samu *pwd = NULL; DOM_SID sid; - SAM_USERINFO_CTR *ctr = q_u->ctr; - POLICY_HND *pol = &q_u->pol; - uint16 switch_value = q_u->switch_value; + union samr_UserInfo *info = r->in.info; + POLICY_HND *pol = r->in.user_handle; + uint16 switch_value = r->in.level; uint32 acc_granted; uint32 acc_required; bool ret; @@ -3736,9 +3748,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ uint32 acb_info; DISP_INFO *disp_info = NULL; - DEBUG(5, ("samr_reply_set_userinfo2: %d\n", __LINE__)); - - r_u->status = NT_STATUS_OK; + DEBUG(5, ("_samr_SetUserInfo2: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info)) @@ -3753,20 +3763,21 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ acc_required = SA_RIGHT_USER_SET_ATTRIBUTES; #endif - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(acc_granted, acc_required, "_samr_set_userinfo2"))) { - return r_u->status; + status = access_check_samr_function(acc_granted, + acc_required, + "_samr_SetUserInfo2"); + if (!NT_STATUS_IS_OK(status)) { + return status; } - DEBUG(5, ("samr_reply_set_userinfo2: sid:%s\n", + DEBUG(5,("_samr_SetUserInfo2: sid:%s\n", sid_string_dbg(&sid))); - if (ctr == NULL) { - DEBUG(5, ("samr_reply_set_userinfo2: NULL info level\n")); + if (info == NULL) { + DEBUG(5,("_samr_SetUserInfo2: NULL info level\n")); return NT_STATUS_INVALID_INFO_CLASS; } - switch_value=ctr->switch_value; - if ( !(pwd = samu_new( NULL )) ) { return NT_STATUS_NO_MEMORY; } @@ -3790,7 +3801,7 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); } - DEBUG(5, ("_samr_set_userinfo2: %s does%s possess sufficient rights\n", + DEBUG(5, ("_samr_SetUserInfo2: %s does%s possess sufficient rights\n", uidtoname(p->pipe_user.ut.uid), has_enough_rights ? "" : " not")); @@ -3803,50 +3814,50 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ switch (switch_value) { case 7: - r_u->status = set_user_info_7(p->mem_ctx, - ctr->info.id7, pwd); + status = set_user_info_7(p->mem_ctx, + &info->info7, pwd); break; case 16: - if (!set_user_info_16(ctr->info.id16, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_16(&info->info16, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; case 18: /* Used by AS/U JRA. */ - if (!set_user_info_18(ctr->info.id18, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_18(&info->info18, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; case 20: - if (!set_user_info_20(ctr->info.id20, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_20(&info->info20, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; case 21: - r_u->status = set_user_info_21(p->mem_ctx, - ctr->info.id21, pwd); + status = set_user_info_21(p->mem_ctx, + &info->info21, pwd); break; case 23: if (!p->session_key.length) { - r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + status = NT_STATUS_NO_USER_SESSION_KEY; } - SamOEMhashBlob(ctr->info.id23->pass, 516, &p->session_key); + SamOEMhashBlob(info->info23.password.data, 516, &p->session_key); - dump_data(100, ctr->info.id23->pass, 516); + dump_data(100, info->info23.password.data, 516); - r_u->status = set_user_info_23(p->mem_ctx, - ctr->info.id23, pwd); + status = set_user_info_23(p->mem_ctx, + &info->info23, pwd); break; case 26: if (!p->session_key.length) { - r_u->status = NT_STATUS_NO_USER_SESSION_KEY; + status = NT_STATUS_NO_USER_SESSION_KEY; } - encode_or_decode_arc4_passwd_buffer(ctr->info.id26->pass, &p->session_key); + encode_or_decode_arc4_passwd_buffer(info->info26.password.data, &p->session_key); - dump_data(100, ctr->info.id26->pass, 516); + dump_data(100, info->info26.password.data, 516); - if (!set_user_info_pw(ctr->info.id26->pass, pwd)) - r_u->status = NT_STATUS_ACCESS_DENIED; + if (!set_user_info_pw(info->info26.password.data, pwd)) + status = NT_STATUS_ACCESS_DENIED; break; default: - r_u->status = NT_STATUS_INVALID_INFO_CLASS; + status = NT_STATUS_INVALID_INFO_CLASS; } if ( has_enough_rights ) @@ -3854,11 +3865,11 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_ /* ================ END SeMachineAccountPrivilege BLOCK ================ */ - if (NT_STATUS_IS_OK(r_u->status)) { + if (NT_STATUS_IS_OK(status)) { force_flush_samr_cache(disp_info); } - return r_u->status; + return status; } /********************************************************************* @@ -5258,16 +5269,6 @@ NTSTATUS _samr_QueryUserInfo(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_SetUserInfo(pipes_struct *p, - struct samr_SetUserInfo *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_ChangePasswordUser(pipes_struct *p, struct samr_ChangePasswordUser *r) { @@ -5378,16 +5379,6 @@ NTSTATUS _samr_OemChangePasswordUser2(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_SetUserInfo2(pipes_struct *p, - struct samr_SetUserInfo2 *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_SetBootKeyInformation(pipes_struct *p, struct samr_SetBootKeyInformation *r) { diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 0b7cbbed4a..a6c0e7b448 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -35,10 +35,11 @@ ((s1) && (s2) && (strcmp((s1), (s2)) != 0)) /************************************************************* - Copies a SAM_USER_INFO_20 to a struct samu + Copies a struct samr_UserInfo20 to a struct samu **************************************************************/ -void copy_id20_to_sam_passwd(struct samu *to, SAM_USER_INFO_20 *from) +void copy_id20_to_sam_passwd(struct samu *to, + struct samr_UserInfo20 *from) { const char *old_string; char *new_string; @@ -47,6 +48,7 @@ void copy_id20_to_sam_passwd(struct samu *to, SAM_USER_INFO_20 *from) if (from == NULL || to == NULL) return; +#if 0 if (from->hdr_munged_dial.buffer) { old_string = pdb_get_munged_dial(to); mung.length = from->hdr_munged_dial.uni_str_len; @@ -60,13 +62,15 @@ void copy_id20_to_sam_passwd(struct samu *to, SAM_USER_INFO_20 *from) TALLOC_FREE(new_string); } +#endif } /************************************************************* - Copies a SAM_USER_INFO_21 to a struct samu + Copies a struct samr_UserInfo21 to a struct samu **************************************************************/ -void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) +void copy_id21_to_sam_passwd(struct samu *to, + struct samr_UserInfo21 *from) { time_t unix_time, stored_time; const char *old_string, *new_string; @@ -76,7 +80,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) return; if (from->fields_present & ACCT_LAST_LOGON) { - unix_time=nt_time_to_unix(from->logon_time); + unix_time=nt_time_to_unix(from->last_logon); stored_time = pdb_get_logon_time(to); DEBUG(10,("INFO_21 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -84,7 +88,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_LAST_LOGOFF) { - unix_time=nt_time_to_unix(from->logoff_time); + unix_time=nt_time_to_unix(from->last_logoff); stored_time = pdb_get_logoff_time(to); DEBUG(10,("INFO_21 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -92,7 +96,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_EXPIRY) { - unix_time=nt_time_to_unix(from->kickoff_time); + unix_time=nt_time_to_unix(from->acct_expiry); stored_time = pdb_get_kickoff_time(to); DEBUG(10,("INFO_21 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -100,7 +104,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_LAST_PWD_CHANGE) { - unix_time=nt_time_to_unix(from->pass_last_set_time); + unix_time=nt_time_to_unix(from->last_password_change); stored_time = pdb_get_pass_last_set_time(to); DEBUG(10,("INFO_21 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) @@ -108,86 +112,87 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if ((from->fields_present & ACCT_USERNAME) && - (from->hdr_user_name.buffer)) { + (from->account_name.string)) { old_string = pdb_get_username(to); - new_string = unistr2_static(&from->uni_user_name); + new_string = from->account_name.string; DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); if (STRING_CHANGED) pdb_set_username(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_FULL_NAME) && - (from->hdr_full_name.buffer)) { + (from->full_name.string)) { old_string = pdb_get_fullname(to); - new_string = unistr2_static(&from->uni_full_name); + new_string = from->full_name.string; DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_fullname(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_HOME_DIR) && - (from->hdr_home_dir.buffer)) { + (from->home_directory.string)) { old_string = pdb_get_homedir(to); - new_string = unistr2_static(&from->uni_home_dir); + new_string = from->home_directory.string; DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_homedir(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_HOME_DRIVE) && - (from->hdr_dir_drive.buffer)) { + (from->home_drive.string)) { old_string = pdb_get_dir_drive(to); - new_string = unistr2_static(&from->uni_dir_drive); + new_string = from->home_drive.string; DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_dir_drive(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_LOGON_SCRIPT) && - (from->hdr_logon_script.buffer)) { + (from->logon_script.string)) { old_string = pdb_get_logon_script(to); - new_string = unistr2_static(&from->uni_logon_script); + new_string = from->logon_script.string; DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_logon_script(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_PROFILE) && - (from->hdr_profile_path.buffer)) { + (from->profile_path.string)) { old_string = pdb_get_profile_path(to); - new_string = unistr2_static(&from->uni_profile_path); + new_string = from->profile_path.string; DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_profile_path(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_DESCRIPTION) && - (from->hdr_acct_desc.buffer)) { + (from->description.string)) { old_string = pdb_get_acct_desc(to); - new_string = unistr2_static(&from->uni_acct_desc); + new_string = from->description.string; DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); if (STRING_CHANGED) pdb_set_acct_desc(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_WORKSTATIONS) && - (from->hdr_workstations.buffer)) { + (from->workstations.string)) { old_string = pdb_get_workstations(to); - new_string = unistr2_static(&from->uni_workstations); + new_string = from->workstations.string; DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_workstations(to , new_string, PDB_CHANGED); } if ((from->fields_present & ACCT_COMMENT) && - (from->hdr_comment.buffer)) { + (from->comment.string)) { old_string = pdb_get_comment(to); - new_string = unistr2_static(&from->uni_comment); + new_string = from->comment.string; DEBUG(10,("INFO_21 UNI_COMMENT: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED) pdb_set_comment(to, new_string, PDB_CHANGED); } - +#if 0 + /* FIXME GD */ if ((from->fields_present & ACCT_CALLBACK) && (from->hdr_munged_dial.buffer)) { char *newstr; @@ -203,37 +208,37 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) TALLOC_FREE(newstr); } - +#endif if (from->fields_present & ACCT_RID) { - if (from->user_rid == 0) { + if (from->rid == 0) { DEBUG(10, ("INFO_21: Asked to set User RID to 0 !? Skipping change!\n")); - } else if (from->user_rid != pdb_get_user_rid(to)) { - DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); + } else if (from->rid != pdb_get_user_rid(to)) { + DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->rid)); } } if (from->fields_present & ACCT_PRIMARY_GID) { - if (from->group_rid == 0) { + if (from->primary_gid == 0) { DEBUG(10, ("INFO_21: Asked to set Group RID to 0 !? Skipping change!\n")); - } else if (from->group_rid != pdb_get_group_rid(to)) { - DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); - pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); + } else if (from->primary_gid != pdb_get_group_rid(to)) { + DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->primary_gid)); + pdb_set_group_sid_from_rid(to, from->primary_gid, PDB_CHANGED); } } if (from->fields_present & ACCT_FLAGS) { - DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); - if (from->acb_info != pdb_get_acct_ctrl(to)) { - if (!(from->acb_info & ACB_AUTOLOCK) && (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) { + DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acct_flags)); + if (from->acct_flags != pdb_get_acct_ctrl(to)) { + if (!(from->acct_flags & ACB_AUTOLOCK) && (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) { /* We're unlocking a previously locked user. Reset bad password counts. Patch from Jianliang Lu. */ pdb_set_bad_password_count(to, 0, PDB_CHANGED); pdb_set_bad_password_time(to, 0, PDB_CHANGED); } - pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); + pdb_set_acct_ctrl(to, from->acct_flags, PDB_CHANGED); } } - +#if 0 if (from->fields_present & ACCT_LOGON_HOURS) { char oldstr[44]; /* hours strings are 42 bytes. */ char newstr[44]; @@ -254,7 +259,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); } } - +#endif if (from->fields_present & ACCT_BAD_PWD_COUNT) { DEBUG(10,("INFO_21 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count)); if (from->bad_password_count != pdb_get_bad_password_count(to)) { @@ -263,7 +268,7 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) } if (from->fields_present & ACCT_NUM_LOGONS) { - DEBUG(10,("INFO_21 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count)); + DEBUG(10,("INFO_21 LOGON_COUNT: %08X -> %08X\n", pdb_get_logon_count(to), from->logon_count)); if (from->logon_count != pdb_get_logon_count(to)) { pdb_set_logon_count(to, from->logon_count, PDB_CHANGED); } @@ -274,443 +279,38 @@ void copy_id21_to_sam_passwd(struct samu *to, SAM_USER_INFO_21 *from) calculated from policy, not set from the wire */ if (from->fields_present & ACCT_EXPIRED_FLAG) { - DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); - if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) { + DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n", from->password_expired)); + if (from->password_expired == PASS_MUST_CHANGE_AT_NEXT_LOGON) { pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); } else { pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED); } } - - DEBUG(10,("INFO_21 PADDING_2: %02X\n",from->padding2)); } /************************************************************* - Copies a SAM_USER_INFO_23 to a struct samu + Copies a struct samr_UserInfo23 to a struct samu **************************************************************/ -void copy_id23_to_sam_passwd(struct samu *to, SAM_USER_INFO_23 *from) +void copy_id23_to_sam_passwd(struct samu *to, + struct samr_UserInfo23 *from) { - time_t unix_time, stored_time; - const char *old_string, *new_string; - DATA_BLOB mung; - if (from == NULL || to == NULL) return; - if (from->fields_present & ACCT_LAST_LOGON) { - unix_time=nt_time_to_unix(from->logon_time); - stored_time = pdb_get_logon_time(to); - DEBUG(10,("INFO_23 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) - pdb_set_logon_time(to, unix_time, PDB_CHANGED); - } - - if (from->fields_present & ACCT_LAST_LOGOFF) { - unix_time=nt_time_to_unix(from->logoff_time); - stored_time = pdb_get_logoff_time(to); - DEBUG(10,("INFO_23 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) - pdb_set_logoff_time(to, unix_time, PDB_CHANGED); - } - - if (from->fields_present & ACCT_EXPIRY) { - unix_time=nt_time_to_unix(from->kickoff_time); - stored_time = pdb_get_kickoff_time(to); - DEBUG(10,("INFO_23 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) - pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); - } - - if (from->fields_present & ACCT_LAST_PWD_CHANGE) { - unix_time=nt_time_to_unix(from->pass_last_set_time); - stored_time = pdb_get_pass_last_set_time(to); - DEBUG(10,("INFO_23 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) - pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); - } - - /* Backend should check this for sanity */ - if ((from->fields_present & ACCT_USERNAME) && - (from->hdr_user_name.buffer)) { - old_string = pdb_get_username(to); - new_string = unistr2_static(&from->uni_user_name); - DEBUG(10,("INFO_23 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); - if (STRING_CHANGED) - pdb_set_username(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_FULL_NAME) && - (from->hdr_full_name.buffer)) { - old_string = pdb_get_fullname(to); - new_string = unistr2_static(&from->uni_full_name); - DEBUG(10,("INFO_23 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_fullname(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_HOME_DIR) && - (from->hdr_home_dir.buffer)) { - old_string = pdb_get_homedir(to); - new_string = unistr2_static(&from->uni_home_dir); - DEBUG(10,("INFO_23 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); - if (STRING_CHANGED) - pdb_set_homedir(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_HOME_DRIVE) && - (from->hdr_dir_drive.buffer)) { - old_string = pdb_get_dir_drive(to); - new_string = unistr2_static(&from->uni_dir_drive); - DEBUG(10,("INFO_23 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); - if (STRING_CHANGED) - pdb_set_dir_drive(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_LOGON_SCRIPT) && - (from->hdr_logon_script.buffer)) { - old_string = pdb_get_logon_script(to); - new_string = unistr2_static(&from->uni_logon_script); - DEBUG(10,("INFO_23 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); - if (STRING_CHANGED) - pdb_set_logon_script(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_PROFILE) && - (from->hdr_profile_path.buffer)) { - old_string = pdb_get_profile_path(to); - new_string = unistr2_static(&from->uni_profile_path); - DEBUG(10,("INFO_23 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_profile_path(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_DESCRIPTION) && - (from->hdr_acct_desc.buffer)) { - old_string = pdb_get_acct_desc(to); - new_string = unistr2_static(&from->uni_acct_desc); - DEBUG(10,("INFO_23 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); - if (STRING_CHANGED) - pdb_set_acct_desc(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_WORKSTATIONS) && - (from->hdr_workstations.buffer)) { - old_string = pdb_get_workstations(to); - new_string = unistr2_static(&from->uni_workstations); - DEBUG(10,("INFO_23 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_workstations(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_COMMENT) && - (from->hdr_comment.buffer)) { - old_string = pdb_get_comment(to); - new_string = unistr2_static(&from->uni_comment); - DEBUG(10,("INFO_23 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_comment(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_CALLBACK) && - (from->hdr_munged_dial.buffer)) { - char *newstr; - old_string = pdb_get_munged_dial(to); - mung.length = from->hdr_munged_dial.uni_str_len; - mung.data = (uint8 *) from->uni_munged_dial.buffer; - mung.free = NULL; - newstr = (mung.length == 0) ? - NULL : base64_encode_data_blob(talloc_tos(), mung); - DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); - if (STRING_CHANGED_NC(old_string, newstr)) - pdb_set_munged_dial(to , newstr, PDB_CHANGED); - - TALLOC_FREE(newstr); - } - - if (from->fields_present & ACCT_RID) { - if (from->user_rid == 0) { - DEBUG(10, ("INFO_23: Asked to set User RID to 0 !? Skipping change!\n")); - } else if (from->user_rid != pdb_get_user_rid(to)) { - DEBUG(10,("INFO_23 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); - } - } - - if (from->fields_present & ACCT_PRIMARY_GID) { - if (from->group_rid == 0) { - DEBUG(10, ("INFO_23: Asked to set Group RID to 0 !? Skipping change!\n")); - } else if (from->group_rid != pdb_get_group_rid(to)) { - DEBUG(10,("INFO_23 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); - pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); - } - } - - if (from->fields_present & ACCT_FLAGS) { - DEBUG(10,("INFO_23 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); - if (from->acb_info != pdb_get_acct_ctrl(to)) { - pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); - } - } - - if (from->fields_present & ACCT_LOGON_HOURS) { - DEBUG(15,("INFO_23 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); - if (from->logon_divs != pdb_get_logon_divs(to)) { - pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); - } - - DEBUG(15,("INFO_23 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); - if (from->logon_hrs.len != pdb_get_hours_len(to)) { - pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED); - } - - DEBUG(15,("INFO_23 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); - /* Fix me: only update if it changes --metze */ - pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); - } - - if (from->fields_present & ACCT_BAD_PWD_COUNT) { - DEBUG(10,("INFO_23 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count)); - if (from->bad_password_count != pdb_get_bad_password_count(to)) { - pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED); - } - } - - if (from->fields_present & ACCT_NUM_LOGONS) { - DEBUG(10,("INFO_23 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count)); - if (from->logon_count != pdb_get_logon_count(to)) { - pdb_set_logon_count(to, from->logon_count, PDB_CHANGED); - } - } - - /* If the must change flag is set, the last set time goes to zero. - the must change and can change fields also do, but they are - calculated from policy, not set from the wire */ - - if (from->fields_present & ACCT_EXPIRED_FLAG) { - DEBUG(10,("INFO_23 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); - if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) { - pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); - } else { - pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED); - } - } - - DEBUG(10,("INFO_23 PADDING_2: %02X\n",from->padding2)); + copy_id21_to_sam_passwd(to, &from->info); } /************************************************************* - Copies a SAM_USER_INFO_25 to a struct samu + Copies a struct samr_UserInfo25 to a struct samu **************************************************************/ -void copy_id25_to_sam_passwd(struct samu *to, SAM_USER_INFO_25 *from) +void copy_id25_to_sam_passwd(struct samu *to, + struct samr_UserInfo25 *from) { - time_t unix_time, stored_time; - const char *old_string, *new_string; - DATA_BLOB mung; - if (from == NULL || to == NULL) return; - if (from->fields_present & ACCT_LAST_LOGON) { - unix_time=nt_time_to_unix(from->logon_time); - stored_time = pdb_get_logon_time(to); - DEBUG(10,("INFO_25 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) - pdb_set_logon_time(to, unix_time, PDB_CHANGED); - } - - if (from->fields_present & ACCT_LAST_LOGOFF) { - unix_time=nt_time_to_unix(from->logoff_time); - stored_time = pdb_get_logoff_time(to); - DEBUG(10,("INFO_25 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) - pdb_set_logoff_time(to, unix_time, PDB_CHANGED); - } - - if (from->fields_present & ACCT_EXPIRY) { - unix_time=nt_time_to_unix(from->kickoff_time); - stored_time = pdb_get_kickoff_time(to); - DEBUG(10,("INFO_25 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) - pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); - } - - if (from->fields_present & ACCT_LAST_PWD_CHANGE) { - unix_time=nt_time_to_unix(from->pass_last_set_time); - stored_time = pdb_get_pass_last_set_time(to); - DEBUG(10,("INFO_25 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) - pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_USERNAME) && - (from->hdr_user_name.buffer)) { - old_string = pdb_get_username(to); - new_string = unistr2_static(&from->uni_user_name); - DEBUG(10,("INFO_25 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); - if (STRING_CHANGED) - pdb_set_username(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_FULL_NAME) && - (from->hdr_full_name.buffer)) { - old_string = pdb_get_fullname(to); - new_string = unistr2_static(&from->uni_full_name); - DEBUG(10,("INFO_25 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_fullname(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_HOME_DIR) && - (from->hdr_home_dir.buffer)) { - old_string = pdb_get_homedir(to); - new_string = unistr2_static(&from->uni_home_dir); - DEBUG(10,("INFO_25 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); - if (STRING_CHANGED) - pdb_set_homedir(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_HOME_DRIVE) && - (from->hdr_dir_drive.buffer)) { - old_string = pdb_get_dir_drive(to); - new_string = unistr2_static(&from->uni_dir_drive); - DEBUG(10,("INFO_25 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); - if (STRING_CHANGED) - pdb_set_dir_drive(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_LOGON_SCRIPT) && - (from->hdr_logon_script.buffer)) { - old_string = pdb_get_logon_script(to); - new_string = unistr2_static(&from->uni_logon_script); - DEBUG(10,("INFO_25 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); - if (STRING_CHANGED) - pdb_set_logon_script(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_PROFILE) && - (from->hdr_profile_path.buffer)) { - old_string = pdb_get_profile_path(to); - new_string = unistr2_static(&from->uni_profile_path); - DEBUG(10,("INFO_25 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_profile_path(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_DESCRIPTION) && - (from->hdr_acct_desc.buffer)) { - old_string = pdb_get_acct_desc(to); - new_string = unistr2_static(&from->uni_acct_desc); - DEBUG(10,("INFO_25 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); - if (STRING_CHANGED) - pdb_set_acct_desc(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_WORKSTATIONS) && - (from->hdr_workstations.buffer)) { - old_string = pdb_get_workstations(to); - new_string = unistr2_static(&from->uni_workstations); - DEBUG(10,("INFO_25 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_workstations(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_COMMENT) && - (from->hdr_comment.buffer)) { - old_string = pdb_get_comment(to); - new_string = unistr2_static(&from->uni_comment); - DEBUG(10,("INFO_25 UNI_UNKNOWN_STR: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED) - pdb_set_comment(to , new_string, PDB_CHANGED); - } - - if ((from->fields_present & ACCT_CALLBACK) && - (from->hdr_munged_dial.buffer)) { - char *newstr; - old_string = pdb_get_munged_dial(to); - mung.length = from->hdr_munged_dial.uni_str_len; - mung.data = (uint8 *) from->uni_munged_dial.buffer; - mung.free = NULL; - newstr = (mung.length == 0) ? - NULL : base64_encode_data_blob(talloc_tos(), mung); - DEBUG(10,("INFO_25 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); - if (STRING_CHANGED_NC(old_string,newstr)) - pdb_set_munged_dial(to , newstr, PDB_CHANGED); - - TALLOC_FREE(newstr); - } - - if (from->fields_present & ACCT_RID) { - if (from->user_rid == 0) { - DEBUG(10, ("INFO_25: Asked to set User RID to 0 !? Skipping change!\n")); - } else if (from->user_rid != pdb_get_user_rid(to)) { - DEBUG(10,("INFO_25 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->user_rid)); - } - } - - if (from->fields_present & ACCT_PRIMARY_GID) { - if (from->group_rid == 0) { - DEBUG(10, ("INFO_25: Asked to set Group RID to 0 !? Skipping change!\n")); - } else if (from->group_rid != pdb_get_group_rid(to)) { - DEBUG(10,("INFO_25 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->group_rid)); - pdb_set_group_sid_from_rid(to, from->group_rid, PDB_CHANGED); - } - } - - if (from->fields_present & ACCT_FLAGS) { - DEBUG(10,("INFO_25 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acb_info)); - if (from->acb_info != pdb_get_acct_ctrl(to)) { - if (!(from->acb_info & ACB_AUTOLOCK) && (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) { - /* We're unlocking a previously locked user. Reset bad password counts. - Patch from Jianliang Lu. */ - pdb_set_bad_password_count(to, 0, PDB_CHANGED); - pdb_set_bad_password_time(to, 0, PDB_CHANGED); - } - pdb_set_acct_ctrl(to, from->acb_info, PDB_CHANGED); - } - } - - if (from->fields_present & ACCT_LOGON_HOURS) { - DEBUG(15,("INFO_25 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); - if (from->logon_divs != pdb_get_logon_divs(to)) { - pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); - } - - DEBUG(15,("INFO_25 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); - if (from->logon_hrs.len != pdb_get_hours_len(to)) { - pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED); - } - - DEBUG(15,("INFO_25 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); - /* Fix me: only update if it changes --metze */ - pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); - } - - if (from->fields_present & ACCT_BAD_PWD_COUNT) { - DEBUG(10,("INFO_25 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count)); - if (from->bad_password_count != pdb_get_bad_password_count(to)) { - pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED); - } - } - - if (from->fields_present & ACCT_NUM_LOGONS) { - DEBUG(10,("INFO_25 LOGON_COUNT: %08X -> %08X\n",pdb_get_logon_count(to),from->logon_count)); - if (from->logon_count != pdb_get_logon_count(to)) { - pdb_set_logon_count(to, from->logon_count, PDB_CHANGED); - } - } - - /* If the must change flag is set, the last set time goes to zero. - the must change and can change fields also do, but they are - calculated from policy, not set from the wire */ - - if (from->fields_present & ACCT_EXPIRED_FLAG) { - DEBUG(10,("INFO_25 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n",from->passmustchange)); - if (from->passmustchange == PASS_MUST_CHANGE_AT_NEXT_LOGON) { - pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); - } else { - pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED); - } - } + copy_id21_to_sam_passwd(to, &from->info); } -- cgit From 326477e522b99eaa2b6bd636582d4fece6906d62 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Feb 2008 22:47:49 +0100 Subject: Allow to set correct info level log prefix in duplicates of copy_id21_to_sam_passwd. Guenther (This used to be commit 118e166c003a931884c662423e1e280a5be3eb48) --- source3/rpc_server/srv_samr_nt.c | 2 +- source3/rpc_server/srv_samr_util.c | 76 ++++++++++++++++++++++---------------- 2 files changed, 45 insertions(+), 33 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index cb5bfe5440..6efea1a754 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3309,7 +3309,7 @@ static NTSTATUS set_user_info_21(TALLOC_CTX *mem_ctx, pdb_set_username(pwd, id21->account_name.string, PDB_SET); } - copy_id21_to_sam_passwd(pwd, id21); + copy_id21_to_sam_passwd("INFO_21", pwd, id21); /* * The funny part about the previous two calls is diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index a6c0e7b448..1d759aac22 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -69,20 +69,29 @@ void copy_id20_to_sam_passwd(struct samu *to, Copies a struct samr_UserInfo21 to a struct samu **************************************************************/ -void copy_id21_to_sam_passwd(struct samu *to, +void copy_id21_to_sam_passwd(const char *log_prefix, + struct samu *to, struct samr_UserInfo21 *from) { time_t unix_time, stored_time; const char *old_string, *new_string; DATA_BLOB mung; + const char *l; - if (from == NULL || to == NULL) + if (from == NULL || to == NULL) { return; + } + + if (log_prefix) { + l = log_prefix; + } else { + l = "INFO_21"; + } if (from->fields_present & ACCT_LAST_LOGON) { unix_time=nt_time_to_unix(from->last_logon); stored_time = pdb_get_logon_time(to); - DEBUG(10,("INFO_21 LOGON_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + DEBUG(10,("%s LOGON_TIME: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) pdb_set_logon_time(to, unix_time, PDB_CHANGED); } @@ -90,7 +99,7 @@ void copy_id21_to_sam_passwd(struct samu *to, if (from->fields_present & ACCT_LAST_LOGOFF) { unix_time=nt_time_to_unix(from->last_logoff); stored_time = pdb_get_logoff_time(to); - DEBUG(10,("INFO_21 LOGOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + DEBUG(10,("%s LOGOFF_TIME: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) pdb_set_logoff_time(to, unix_time, PDB_CHANGED); } @@ -98,7 +107,7 @@ void copy_id21_to_sam_passwd(struct samu *to, if (from->fields_present & ACCT_EXPIRY) { unix_time=nt_time_to_unix(from->acct_expiry); stored_time = pdb_get_kickoff_time(to); - DEBUG(10,("INFO_21 KICKOFF_TIME: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + DEBUG(10,("%s KICKOFF_TIME: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); } @@ -106,7 +115,7 @@ void copy_id21_to_sam_passwd(struct samu *to, if (from->fields_present & ACCT_LAST_PWD_CHANGE) { unix_time=nt_time_to_unix(from->last_password_change); stored_time = pdb_get_pass_last_set_time(to); - DEBUG(10,("INFO_21 PASS_LAST_SET: %lu -> %lu\n",(long unsigned int)stored_time, (long unsigned int)unix_time)); + DEBUG(10,("%s PASS_LAST_SET: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); } @@ -115,7 +124,7 @@ void copy_id21_to_sam_passwd(struct samu *to, (from->account_name.string)) { old_string = pdb_get_username(to); new_string = from->account_name.string; - DEBUG(10,("INFO_21 UNI_USER_NAME: %s -> %s\n", old_string, new_string)); + DEBUG(10,("%s UNI_USER_NAME: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_username(to , new_string, PDB_CHANGED); } @@ -124,7 +133,7 @@ void copy_id21_to_sam_passwd(struct samu *to, (from->full_name.string)) { old_string = pdb_get_fullname(to); new_string = from->full_name.string; - DEBUG(10,("INFO_21 UNI_FULL_NAME: %s -> %s\n",old_string, new_string)); + DEBUG(10,("%s UNI_FULL_NAME: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_fullname(to , new_string, PDB_CHANGED); } @@ -133,7 +142,7 @@ void copy_id21_to_sam_passwd(struct samu *to, (from->home_directory.string)) { old_string = pdb_get_homedir(to); new_string = from->home_directory.string; - DEBUG(10,("INFO_21 UNI_HOME_DIR: %s -> %s\n",old_string,new_string)); + DEBUG(10,("%s UNI_HOME_DIR: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_homedir(to , new_string, PDB_CHANGED); } @@ -142,7 +151,7 @@ void copy_id21_to_sam_passwd(struct samu *to, (from->home_drive.string)) { old_string = pdb_get_dir_drive(to); new_string = from->home_drive.string; - DEBUG(10,("INFO_21 UNI_DIR_DRIVE: %s -> %s\n",old_string,new_string)); + DEBUG(10,("%s UNI_DIR_DRIVE: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_dir_drive(to , new_string, PDB_CHANGED); } @@ -151,7 +160,7 @@ void copy_id21_to_sam_passwd(struct samu *to, (from->logon_script.string)) { old_string = pdb_get_logon_script(to); new_string = from->logon_script.string; - DEBUG(10,("INFO_21 UNI_LOGON_SCRIPT: %s -> %s\n",old_string,new_string)); + DEBUG(10,("%s UNI_LOGON_SCRIPT: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_logon_script(to , new_string, PDB_CHANGED); } @@ -160,7 +169,7 @@ void copy_id21_to_sam_passwd(struct samu *to, (from->profile_path.string)) { old_string = pdb_get_profile_path(to); new_string = from->profile_path.string; - DEBUG(10,("INFO_21 UNI_PROFILE_PATH: %s -> %s\n",old_string, new_string)); + DEBUG(10,("%s UNI_PROFILE_PATH: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_profile_path(to , new_string, PDB_CHANGED); } @@ -169,7 +178,7 @@ void copy_id21_to_sam_passwd(struct samu *to, (from->description.string)) { old_string = pdb_get_acct_desc(to); new_string = from->description.string; - DEBUG(10,("INFO_21 UNI_ACCT_DESC: %s -> %s\n",old_string,new_string)); + DEBUG(10,("%s UNI_ACCT_DESC: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_acct_desc(to , new_string, PDB_CHANGED); } @@ -178,7 +187,7 @@ void copy_id21_to_sam_passwd(struct samu *to, (from->workstations.string)) { old_string = pdb_get_workstations(to); new_string = from->workstations.string; - DEBUG(10,("INFO_21 UNI_WORKSTATIONS: %s -> %s\n",old_string, new_string)); + DEBUG(10,("%s UNI_WORKSTATIONS: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_workstations(to , new_string, PDB_CHANGED); } @@ -187,7 +196,7 @@ void copy_id21_to_sam_passwd(struct samu *to, (from->comment.string)) { old_string = pdb_get_comment(to); new_string = from->comment.string; - DEBUG(10,("INFO_21 UNI_COMMENT: %s -> %s\n",old_string, new_string)); + DEBUG(10,("%s UNI_COMMENT: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_comment(to, new_string, PDB_CHANGED); } @@ -202,7 +211,7 @@ void copy_id21_to_sam_passwd(struct samu *to, mung.free = NULL; newstr = (mung.length == 0) ? NULL : base64_encode_data_blob(talloc_tos(), mung); - DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr)); + DEBUG(10,("%s UNI_MUNGED_DIAL: %s -> %s\n", l, old_string, newstr)); if (STRING_CHANGED_NC(old_string,newstr)) pdb_set_munged_dial(to , newstr, PDB_CHANGED); @@ -211,23 +220,23 @@ void copy_id21_to_sam_passwd(struct samu *to, #endif if (from->fields_present & ACCT_RID) { if (from->rid == 0) { - DEBUG(10, ("INFO_21: Asked to set User RID to 0 !? Skipping change!\n")); + DEBUG(10, ("%s: Asked to set User RID to 0 !? Skipping change!\n", l)); } else if (from->rid != pdb_get_user_rid(to)) { - DEBUG(10,("INFO_21 USER_RID: %u -> %u NOT UPDATED!\n",pdb_get_user_rid(to),from->rid)); + DEBUG(10,("%s USER_RID: %u -> %u NOT UPDATED!\n", l, pdb_get_user_rid(to), from->rid)); } } if (from->fields_present & ACCT_PRIMARY_GID) { if (from->primary_gid == 0) { - DEBUG(10, ("INFO_21: Asked to set Group RID to 0 !? Skipping change!\n")); + DEBUG(10, ("%s: Asked to set Group RID to 0 !? Skipping change!\n", l)); } else if (from->primary_gid != pdb_get_group_rid(to)) { - DEBUG(10,("INFO_21 GROUP_RID: %u -> %u\n",pdb_get_group_rid(to),from->primary_gid)); + DEBUG(10,("%s GROUP_RID: %u -> %u\n", l, pdb_get_group_rid(to), from->primary_gid)); pdb_set_group_sid_from_rid(to, from->primary_gid, PDB_CHANGED); } } if (from->fields_present & ACCT_FLAGS) { - DEBUG(10,("INFO_21 ACCT_CTRL: %08X -> %08X\n",pdb_get_acct_ctrl(to),from->acct_flags)); + DEBUG(10,("%s ACCT_CTRL: %08X -> %08X\n", l, pdb_get_acct_ctrl(to), from->acct_flags)); if (from->acct_flags != pdb_get_acct_ctrl(to)) { if (!(from->acct_flags & ACB_AUTOLOCK) && (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) { /* We're unlocking a previously locked user. Reset bad password counts. @@ -238,37 +247,39 @@ void copy_id21_to_sam_passwd(struct samu *to, pdb_set_acct_ctrl(to, from->acct_flags, PDB_CHANGED); } } -#if 0 + +// LOGON_HRS +// struct samr_LogonHours logon_hours; if (from->fields_present & ACCT_LOGON_HOURS) { char oldstr[44]; /* hours strings are 42 bytes. */ char newstr[44]; - DEBUG(15,("INFO_21 LOGON_DIVS: %08X -> %08X\n",pdb_get_logon_divs(to),from->logon_divs)); + DEBUG(15,("%s LOGON_DIVS: %08X -> %08X\n", l, pdb_get_logon_divs(to), from->logon_divs)); if (from->logon_divs != pdb_get_logon_divs(to)) { pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); } - DEBUG(15,("INFO_21 LOGON_HRS.LEN: %08X -> %08X\n",pdb_get_hours_len(to),from->logon_hrs.len)); + DEBUG(15,("%s LOGON_HRS.LEN: %08X -> %08X\n", l, pdb_get_hours_len(to), from->logon_hrs.len)); if (from->logon_hrs.len != pdb_get_hours_len(to)) { pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED); } - DEBUG(15,("INFO_21 LOGON_HRS.HOURS: %s -> %s\n",pdb_get_hours(to),from->logon_hrs.hours)); + DEBUG(15,("%s LOGON_HRS.HOURS: %s -> %s\n", l, pdb_get_hours(to), from->logon_hrs.hours)); pdb_sethexhours(oldstr, pdb_get_hours(to)); pdb_sethexhours(newstr, from->logon_hrs.hours); if (!strequal(oldstr, newstr)) { pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); } } -#endif + if (from->fields_present & ACCT_BAD_PWD_COUNT) { - DEBUG(10,("INFO_21 BAD_PASSWORD_COUNT: %08X -> %08X\n",pdb_get_bad_password_count(to),from->bad_password_count)); + DEBUG(10,("%s BAD_PASSWORD_COUNT: %08X -> %08X\n", l, pdb_get_bad_password_count(to), from->bad_password_count)); if (from->bad_password_count != pdb_get_bad_password_count(to)) { pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED); } } if (from->fields_present & ACCT_NUM_LOGONS) { - DEBUG(10,("INFO_21 LOGON_COUNT: %08X -> %08X\n", pdb_get_logon_count(to), from->logon_count)); + DEBUG(10,("%s LOGON_COUNT: %08X -> %08X\n", l, pdb_get_logon_count(to), from->logon_count)); if (from->logon_count != pdb_get_logon_count(to)) { pdb_set_logon_count(to, from->logon_count, PDB_CHANGED); } @@ -279,7 +290,7 @@ void copy_id21_to_sam_passwd(struct samu *to, calculated from policy, not set from the wire */ if (from->fields_present & ACCT_EXPIRED_FLAG) { - DEBUG(10,("INFO_21 PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n", from->password_expired)); + DEBUG(10,("%s PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n", l, from->password_expired)); if (from->password_expired == PASS_MUST_CHANGE_AT_NEXT_LOGON) { pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); } else { @@ -299,7 +310,7 @@ void copy_id23_to_sam_passwd(struct samu *to, if (from == NULL || to == NULL) return; - copy_id21_to_sam_passwd(to, &from->info); + copy_id21_to_sam_passwd("INFO 23", to, &from->info); } /************************************************************* @@ -309,8 +320,9 @@ void copy_id23_to_sam_passwd(struct samu *to, void copy_id25_to_sam_passwd(struct samu *to, struct samr_UserInfo25 *from) { - if (from == NULL || to == NULL) + if (from == NULL || to == NULL) { return; + } - copy_id21_to_sam_passwd(to, &from->info); + copy_id21_to_sam_passwd("INFO_25", to, &from->info); } -- cgit From f0e8c5d4c2ebb897472f8bc516f1f78a6b8159dc Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Feb 2008 23:06:05 +0100 Subject: Use SAMR_FIELDS for fields_present in rpc_server/srv_samr_util.c. Guenther (This used to be commit 16199c26948ee3b501c051ef530d1b167cbb6196) --- source3/rpc_server/srv_samr_util.c | 86 +++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 42 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 1d759aac22..7707438b67 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -88,121 +88,121 @@ void copy_id21_to_sam_passwd(const char *log_prefix, l = "INFO_21"; } - if (from->fields_present & ACCT_LAST_LOGON) { + if (from->fields_present & SAMR_FIELD_LAST_LOGON) { unix_time=nt_time_to_unix(from->last_logon); stored_time = pdb_get_logon_time(to); - DEBUG(10,("%s LOGON_TIME: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); + DEBUG(10,("%s SAMR_FIELD_LAST_LOGON: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) pdb_set_logon_time(to, unix_time, PDB_CHANGED); } - if (from->fields_present & ACCT_LAST_LOGOFF) { + if (from->fields_present & SAMR_FIELD_LAST_LOGOFF) { unix_time=nt_time_to_unix(from->last_logoff); stored_time = pdb_get_logoff_time(to); - DEBUG(10,("%s LOGOFF_TIME: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); + DEBUG(10,("%s SAMR_FIELD_LAST_LOGOFF: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) pdb_set_logoff_time(to, unix_time, PDB_CHANGED); } - if (from->fields_present & ACCT_EXPIRY) { + if (from->fields_present & SAMR_FIELD_ACCT_EXPIRY) { unix_time=nt_time_to_unix(from->acct_expiry); stored_time = pdb_get_kickoff_time(to); - DEBUG(10,("%s KICKOFF_TIME: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); + DEBUG(10,("%s SAMR_FIELD_ACCT_EXPIRY: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); } - if (from->fields_present & ACCT_LAST_PWD_CHANGE) { + if (from->fields_present & SAMR_FIELD_LAST_PWD_CHANGE) { unix_time=nt_time_to_unix(from->last_password_change); stored_time = pdb_get_pass_last_set_time(to); - DEBUG(10,("%s PASS_LAST_SET: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); + DEBUG(10,("%s SAMR_FIELD_LAST_PWD_CHANGE: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); if (stored_time != unix_time) pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); } - if ((from->fields_present & ACCT_USERNAME) && + if ((from->fields_present & SAMR_FIELD_ACCOUNT_NAME) && (from->account_name.string)) { old_string = pdb_get_username(to); new_string = from->account_name.string; - DEBUG(10,("%s UNI_USER_NAME: %s -> %s\n", l, old_string, new_string)); + DEBUG(10,("%s SAMR_FIELD_ACCOUNT_NAME: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_username(to , new_string, PDB_CHANGED); } - if ((from->fields_present & ACCT_FULL_NAME) && + if ((from->fields_present & SAMR_FIELD_FULL_NAME) && (from->full_name.string)) { old_string = pdb_get_fullname(to); new_string = from->full_name.string; - DEBUG(10,("%s UNI_FULL_NAME: %s -> %s\n", l, old_string, new_string)); + DEBUG(10,("%s SAMR_FIELD_FULL_NAME: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_fullname(to , new_string, PDB_CHANGED); } - if ((from->fields_present & ACCT_HOME_DIR) && + if ((from->fields_present & SAMR_FIELD_HOME_DIRECTORY) && (from->home_directory.string)) { old_string = pdb_get_homedir(to); new_string = from->home_directory.string; - DEBUG(10,("%s UNI_HOME_DIR: %s -> %s\n", l, old_string, new_string)); + DEBUG(10,("%s SAMR_FIELD_HOME_DIRECTORY: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_homedir(to , new_string, PDB_CHANGED); } - if ((from->fields_present & ACCT_HOME_DRIVE) && + if ((from->fields_present & SAMR_FIELD_HOME_DRIVE) && (from->home_drive.string)) { old_string = pdb_get_dir_drive(to); new_string = from->home_drive.string; - DEBUG(10,("%s UNI_DIR_DRIVE: %s -> %s\n", l, old_string, new_string)); + DEBUG(10,("%s SAMR_FIELD_HOME_DRIVE: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_dir_drive(to , new_string, PDB_CHANGED); } - if ((from->fields_present & ACCT_LOGON_SCRIPT) && + if ((from->fields_present & SAMR_FIELD_LOGON_SCRIPT) && (from->logon_script.string)) { old_string = pdb_get_logon_script(to); new_string = from->logon_script.string; - DEBUG(10,("%s UNI_LOGON_SCRIPT: %s -> %s\n", l, old_string, new_string)); + DEBUG(10,("%s SAMR_FIELD_LOGON_SCRIPT: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_logon_script(to , new_string, PDB_CHANGED); } - if ((from->fields_present & ACCT_PROFILE) && + if ((from->fields_present & SAMR_FIELD_PROFILE_PATH) && (from->profile_path.string)) { old_string = pdb_get_profile_path(to); new_string = from->profile_path.string; - DEBUG(10,("%s UNI_PROFILE_PATH: %s -> %s\n", l, old_string, new_string)); + DEBUG(10,("%s SAMR_FIELD_PROFILE_PATH: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_profile_path(to , new_string, PDB_CHANGED); } - if ((from->fields_present & ACCT_DESCRIPTION) && + if ((from->fields_present & SAMR_FIELD_DESCRIPTION) && (from->description.string)) { old_string = pdb_get_acct_desc(to); new_string = from->description.string; - DEBUG(10,("%s UNI_ACCT_DESC: %s -> %s\n", l, old_string, new_string)); + DEBUG(10,("%s SAMR_FIELD_DESCRIPTION: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_acct_desc(to , new_string, PDB_CHANGED); } - if ((from->fields_present & ACCT_WORKSTATIONS) && + if ((from->fields_present & SAMR_FIELD_WORKSTATIONS) && (from->workstations.string)) { old_string = pdb_get_workstations(to); new_string = from->workstations.string; - DEBUG(10,("%s UNI_WORKSTATIONS: %s -> %s\n", l, old_string, new_string)); + DEBUG(10,("%s SAMR_FIELD_WORKSTATIONS: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_workstations(to , new_string, PDB_CHANGED); } - if ((from->fields_present & ACCT_COMMENT) && + if ((from->fields_present & SAMR_FIELD_COMMENT) && (from->comment.string)) { old_string = pdb_get_comment(to); new_string = from->comment.string; - DEBUG(10,("%s UNI_COMMENT: %s -> %s\n", l, old_string, new_string)); + DEBUG(10,("%s SAMR_FIELD_COMMENT: %s -> %s\n", l, old_string, new_string)); if (STRING_CHANGED) pdb_set_comment(to, new_string, PDB_CHANGED); } #if 0 /* FIXME GD */ - if ((from->fields_present & ACCT_CALLBACK) && + if ((from->fields_present & SAMR_FIELD_PARAMETERS) && (from->hdr_munged_dial.buffer)) { char *newstr; old_string = pdb_get_munged_dial(to); @@ -211,32 +211,32 @@ void copy_id21_to_sam_passwd(const char *log_prefix, mung.free = NULL; newstr = (mung.length == 0) ? NULL : base64_encode_data_blob(talloc_tos(), mung); - DEBUG(10,("%s UNI_MUNGED_DIAL: %s -> %s\n", l, old_string, newstr)); + DEBUG(10,("%s SAMR_FIELD_PARAMETERS: %s -> %s\n", l, old_string, newstr)); if (STRING_CHANGED_NC(old_string,newstr)) pdb_set_munged_dial(to , newstr, PDB_CHANGED); TALLOC_FREE(newstr); } #endif - if (from->fields_present & ACCT_RID) { + if (from->fields_present & SAMR_FIELD_RID) { if (from->rid == 0) { DEBUG(10, ("%s: Asked to set User RID to 0 !? Skipping change!\n", l)); } else if (from->rid != pdb_get_user_rid(to)) { - DEBUG(10,("%s USER_RID: %u -> %u NOT UPDATED!\n", l, pdb_get_user_rid(to), from->rid)); + DEBUG(10,("%s SAMR_FIELD_RID: %u -> %u NOT UPDATED!\n", l, pdb_get_user_rid(to), from->rid)); } } - if (from->fields_present & ACCT_PRIMARY_GID) { + if (from->fields_present & SAMR_FIELD_PRIMARY_GID) { if (from->primary_gid == 0) { DEBUG(10, ("%s: Asked to set Group RID to 0 !? Skipping change!\n", l)); } else if (from->primary_gid != pdb_get_group_rid(to)) { - DEBUG(10,("%s GROUP_RID: %u -> %u\n", l, pdb_get_group_rid(to), from->primary_gid)); + DEBUG(10,("%s SAMR_FIELD_PRIMARY_GID: %u -> %u\n", l, pdb_get_group_rid(to), from->primary_gid)); pdb_set_group_sid_from_rid(to, from->primary_gid, PDB_CHANGED); } } - if (from->fields_present & ACCT_FLAGS) { - DEBUG(10,("%s ACCT_CTRL: %08X -> %08X\n", l, pdb_get_acct_ctrl(to), from->acct_flags)); + if (from->fields_present & SAMR_FIELD_ACCT_FLAGS) { + DEBUG(10,("%s SAMR_FIELD_ACCT_FLAGS: %08X -> %08X\n", l, pdb_get_acct_ctrl(to), from->acct_flags)); if (from->acct_flags != pdb_get_acct_ctrl(to)) { if (!(from->acct_flags & ACB_AUTOLOCK) && (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) { /* We're unlocking a previously locked user. Reset bad password counts. @@ -247,7 +247,9 @@ void copy_id21_to_sam_passwd(const char *log_prefix, pdb_set_acct_ctrl(to, from->acct_flags, PDB_CHANGED); } } - + DEBUG(15,("%s LOGON_DIVS: %08X -> %08X\n", l, pdb_get_logon_divs(to), + from->logon_hours.units_per_week)); +#if 0 // LOGON_HRS // struct samr_LogonHours logon_hours; if (from->fields_present & ACCT_LOGON_HOURS) { @@ -270,16 +272,16 @@ void copy_id21_to_sam_passwd(const char *log_prefix, pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); } } - - if (from->fields_present & ACCT_BAD_PWD_COUNT) { - DEBUG(10,("%s BAD_PASSWORD_COUNT: %08X -> %08X\n", l, pdb_get_bad_password_count(to), from->bad_password_count)); +#endif + if (from->fields_present & SAMR_FIELD_BAD_PWD_COUNT) { + DEBUG(10,("%s SAMR_FIELD_BAD_PWD_COUNT: %08X -> %08X\n", l, pdb_get_bad_password_count(to), from->bad_password_count)); if (from->bad_password_count != pdb_get_bad_password_count(to)) { pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED); } } - if (from->fields_present & ACCT_NUM_LOGONS) { - DEBUG(10,("%s LOGON_COUNT: %08X -> %08X\n", l, pdb_get_logon_count(to), from->logon_count)); + if (from->fields_present & SAMR_FIELD_NUM_LOGONS) { + DEBUG(10,("%s SAMR_FIELD_NUM_LOGONS: %08X -> %08X\n", l, pdb_get_logon_count(to), from->logon_count)); if (from->logon_count != pdb_get_logon_count(to)) { pdb_set_logon_count(to, from->logon_count, PDB_CHANGED); } @@ -289,8 +291,8 @@ void copy_id21_to_sam_passwd(const char *log_prefix, the must change and can change fields also do, but they are calculated from policy, not set from the wire */ - if (from->fields_present & ACCT_EXPIRED_FLAG) { - DEBUG(10,("%s PASS_MUST_CHANGE_AT_NEXT_LOGON: %02X\n", l, from->password_expired)); + if (from->fields_present & SAMR_FIELD_EXPIRED_FLAG) { + DEBUG(10,("%s SAMR_FIELD_EXPIRED_FLAG: %02X\n", l, from->password_expired)); if (from->password_expired == PASS_MUST_CHANGE_AT_NEXT_LOGON) { pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); } else { -- cgit From 14ee7be97b618478076cef768090cacf491d8442 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Feb 2008 23:17:45 +0100 Subject: Fix SAMR_FIELD_LOGON_HOURS handling in rpc_server/srv_samr_util.c. Guenther (This used to be commit ed89daec1d170128047f157d7a9314ae83a21733) --- source3/rpc_server/srv_samr_util.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 7707438b67..6c43e455bc 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -247,32 +247,28 @@ void copy_id21_to_sam_passwd(const char *log_prefix, pdb_set_acct_ctrl(to, from->acct_flags, PDB_CHANGED); } } - DEBUG(15,("%s LOGON_DIVS: %08X -> %08X\n", l, pdb_get_logon_divs(to), - from->logon_hours.units_per_week)); -#if 0 -// LOGON_HRS -// struct samr_LogonHours logon_hours; - if (from->fields_present & ACCT_LOGON_HOURS) { + + if (from->fields_present & SAMR_FIELD_LOGON_HOURS) { char oldstr[44]; /* hours strings are 42 bytes. */ char newstr[44]; - DEBUG(15,("%s LOGON_DIVS: %08X -> %08X\n", l, pdb_get_logon_divs(to), from->logon_divs)); - if (from->logon_divs != pdb_get_logon_divs(to)) { - pdb_set_logon_divs(to, from->logon_divs, PDB_CHANGED); + DEBUG(15,("%s SAMR_FIELD_LOGON_HOURS (units_per_week): %08X -> %08X\n", l, pdb_get_logon_divs(to), from->logon_hours.units_per_week)); + if (from->logon_hours.units_per_week != pdb_get_logon_divs(to)) { + pdb_set_logon_divs(to, from->logon_hours.units_per_week, PDB_CHANGED); } - DEBUG(15,("%s LOGON_HRS.LEN: %08X -> %08X\n", l, pdb_get_hours_len(to), from->logon_hrs.len)); - if (from->logon_hrs.len != pdb_get_hours_len(to)) { - pdb_set_hours_len(to, from->logon_hrs.len, PDB_CHANGED); + DEBUG(15,("%s SAMR_FIELD_LOGON_HOURS (units_per_week/8): %08X -> %08X\n", l, pdb_get_hours_len(to), from->logon_hours.units_per_week/8)); + if (from->logon_hours.units_per_week/8 != pdb_get_hours_len(to)) { + pdb_set_hours_len(to, from->logon_hours.units_per_week/8, PDB_CHANGED); } - DEBUG(15,("%s LOGON_HRS.HOURS: %s -> %s\n", l, pdb_get_hours(to), from->logon_hrs.hours)); + DEBUG(15,("%s SAMR_FIELD_LOGON_HOURS (bits): %s -> %s\n", l, pdb_get_hours(to), from->logon_hours.bits)); pdb_sethexhours(oldstr, pdb_get_hours(to)); - pdb_sethexhours(newstr, from->logon_hrs.hours); + pdb_sethexhours(newstr, from->logon_hours.bits); if (!strequal(oldstr, newstr)) { - pdb_set_hours(to, from->logon_hrs.hours, PDB_CHANGED); + pdb_set_hours(to, from->logon_hours.bits, PDB_CHANGED); } } -#endif + if (from->fields_present & SAMR_FIELD_BAD_PWD_COUNT) { DEBUG(10,("%s SAMR_FIELD_BAD_PWD_COUNT: %08X -> %08X\n", l, pdb_get_bad_password_count(to), from->bad_password_count)); if (from->bad_password_count != pdb_get_bad_password_count(to)) { -- cgit From f0149d23d206675304d879d60c491da3497ef3b9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Feb 2008 23:28:01 +0100 Subject: Fix SAMR_FIELD_PARAMETERS handling in rpc_server/srv_samr_util.c. Guenther (This used to be commit ef7c74401c71a238944cb1a9bbd448a4693339bf) --- source3/rpc_server/srv_samr_util.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 6c43e455bc..cc08d5337b 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -45,24 +45,23 @@ void copy_id20_to_sam_passwd(struct samu *to, char *new_string; DATA_BLOB mung; - if (from == NULL || to == NULL) + if (from == NULL || to == NULL) { return; + } -#if 0 - if (from->hdr_munged_dial.buffer) { + if (from->parameters.string) { old_string = pdb_get_munged_dial(to); - mung.length = from->hdr_munged_dial.uni_str_len; - mung.data = (uint8 *) from->uni_munged_dial.buffer; + mung.length = from->parameters.length; + mung.data = (uint8_t *)from->parameters.string; mung.free = NULL; new_string = (mung.length == 0) ? NULL : base64_encode_data_blob(talloc_tos(), mung); - DEBUG(10,("INFO_20 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string)); + DEBUG(10,("INFO_20 PARAMETERS: %s -> %s\n",old_string, new_string)); if (STRING_CHANGED_NC(old_string,new_string)) pdb_set_munged_dial(to , new_string, PDB_CHANGED); TALLOC_FREE(new_string); } -#endif } /************************************************************* @@ -200,14 +199,13 @@ void copy_id21_to_sam_passwd(const char *log_prefix, if (STRING_CHANGED) pdb_set_comment(to, new_string, PDB_CHANGED); } -#if 0 - /* FIXME GD */ + if ((from->fields_present & SAMR_FIELD_PARAMETERS) && - (from->hdr_munged_dial.buffer)) { + (from->parameters.string)) { char *newstr; old_string = pdb_get_munged_dial(to); - mung.length = from->hdr_munged_dial.uni_str_len; - mung.data = (uint8 *) from->uni_munged_dial.buffer; + mung.length = from->parameters.length; + mung.data = (uint8_t *)from->parameters.string; mung.free = NULL; newstr = (mung.length == 0) ? NULL : base64_encode_data_blob(talloc_tos(), mung); @@ -217,7 +215,7 @@ void copy_id21_to_sam_passwd(const char *log_prefix, TALLOC_FREE(newstr); } -#endif + if (from->fields_present & SAMR_FIELD_RID) { if (from->rid == 0) { DEBUG(10, ("%s: Asked to set User RID to 0 !? Skipping change!\n", l)); -- cgit From fff3f99b5ab53d489b0cccf1b14a2e0725272b5b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 12 Feb 2008 03:15:03 +0100 Subject: Use pidl for _samr_EnumDomainGroups() and _samr_EnumDomainAliases(). Guenther (This used to be commit 327cdb05af80a884517e7baf97300da0a635a451) --- source3/rpc_server/srv_samr.c | 48 +------------ source3/rpc_server/srv_samr_nt.c | 147 ++++++++++++++++++++------------------- 2 files changed, 78 insertions(+), 117 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index 8d626fced9..af46469e06 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -138,29 +138,7 @@ static bool api_samr_enum_dom_users(pipes_struct *p) static bool api_samr_enum_dom_groups(pipes_struct *p) { - SAMR_Q_ENUM_DOM_GROUPS q_u; - SAMR_R_ENUM_DOM_GROUPS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the samr open */ - if(!samr_io_q_enum_dom_groups("", &q_u, data, 0)) { - DEBUG(0,("api_samr_enum_dom_groups: unable to unmarshall SAMR_Q_ENUM_DOM_GROUPS.\n")); - return False; - } - - r_u.status = _samr_enum_dom_groups(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_enum_dom_groups("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_enum_dom_groups: unable to marshall SAMR_R_ENUM_DOM_GROUPS.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_ENUMDOMAINGROUPS); } /******************************************************************* @@ -169,29 +147,7 @@ static bool api_samr_enum_dom_groups(pipes_struct *p) static bool api_samr_enum_dom_aliases(pipes_struct *p) { - SAMR_Q_ENUM_DOM_ALIASES q_u; - SAMR_R_ENUM_DOM_ALIASES r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the samr open */ - if(!samr_io_q_enum_dom_aliases("", &q_u, data, 0)) { - DEBUG(0,("api_samr_enum_dom_aliases: unable to unmarshall SAMR_Q_ENUM_DOM_ALIASES.\n")); - return False; - } - - r_u.status = _samr_enum_dom_aliases(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_enum_dom_aliases("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_enum_dom_aliases: unable to marshall SAMR_R_ENUM_DOM_ALIASES.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_ENUMDOMAINALIASES); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 6efea1a754..e458fce6de 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -991,26 +991,22 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, makes a SAM_ENTRY / UNISTR2* structure from a group list. ********************************************************************/ -static void make_group_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, - UNISTR2 **uni_name_pp, - uint32 num_sam_entries, +static void make_group_sam_entry_list(TALLOC_CTX *ctx, + struct samr_SamEntry **sam_pp, + uint32_t num_sam_entries, struct samr_displayentry *entries) { - uint32 i; - SAM_ENTRY *sam; - UNISTR2 *uni_name; + struct samr_SamEntry *sam; + uint32_t i; *sam_pp = NULL; - *uni_name_pp = NULL; - if (num_sam_entries == 0) + if (num_sam_entries == 0) { return; + } - sam = TALLOC_ZERO_ARRAY(ctx, SAM_ENTRY, num_sam_entries); - uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_sam_entries); - - if (sam == NULL || uni_name == NULL) { - DEBUG(0, ("NULL pointers in SAMR_R_QUERY_DISPINFO\n")); + sam = TALLOC_ZERO_ARRAY(ctx, struct samr_SamEntry, num_sam_entries); + if (sam == NULL) { return; } @@ -1018,44 +1014,50 @@ static void make_group_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, /* * JRA. I think this should include the null. TNG does not. */ - init_unistr2(&uni_name[i], entries[i].account_name, - UNI_STR_TERMINATE); - init_sam_entry(&sam[i], &uni_name[i], entries[i].rid); + init_lsa_String(&sam[i].name, entries[i].account_name); + sam[i].idx = entries[i].rid; } *sam_pp = sam; - *uni_name_pp = uni_name; } /******************************************************************* - samr_reply_enum_dom_groups + _samr_EnumDomainGroups ********************************************************************/ -NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAMR_R_ENUM_DOM_GROUPS *r_u) +NTSTATUS _samr_EnumDomainGroups(pipes_struct *p, + struct samr_EnumDomainGroups *r) { + NTSTATUS status; struct samr_info *info = NULL; struct samr_displayentry *groups; uint32 num_groups; - - r_u->status = NT_STATUS_OK; + struct samr_SamArray *samr_array = NULL; + struct samr_SamEntry *samr_entries = NULL; /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.domain_handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - r_u->status = access_check_samr_function(info->acc_granted, - SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, - "_samr_enum_dom_groups"); - if (!NT_STATUS_IS_OK(r_u->status)) - return r_u->status; + status = access_check_samr_function(info->acc_granted, + SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, + "_samr_EnumDomainGroups"); + if (!NT_STATUS_IS_OK(status)) { + return status; + } - DEBUG(5,("samr_reply_enum_dom_groups: %d\n", __LINE__)); + DEBUG(5,("_samr_EnumDomainGroups: %d\n", __LINE__)); if (info->builtin_domain) { /* No groups in builtin. */ - init_samr_r_enum_dom_groups(r_u, q_u->start_idx, 0); - DEBUG(5,("_samr_enum_dom_users: No groups in BUILTIN\n")); - return r_u->status; + *r->out.resume_handle = *r->in.resume_handle; + DEBUG(5,("_samr_EnumDomainGroups: No groups in BUILTIN\n")); + return status; + } + + samr_array = TALLOC_ZERO_P(p->mem_ctx, struct samr_SamArray); + if (!samr_array) { + return NT_STATUS_NO_MEMORY; } /* the domain group array is being allocated in the function below */ @@ -1071,46 +1073,64 @@ NTSTATUS _samr_enum_dom_groups(pipes_struct *p, SAMR_Q_ENUM_DOM_GROUPS *q_u, SAM } } - num_groups = pdb_search_entries(info->disp_info->groups, q_u->start_idx, + num_groups = pdb_search_entries(info->disp_info->groups, + *r->in.resume_handle, MAX_SAM_ENTRIES, &groups); unbecome_root(); /* Ensure we cache this enumeration. */ set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); - make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, + make_group_sam_entry_list(p->mem_ctx, &samr_entries, num_groups, groups); - init_samr_r_enum_dom_groups(r_u, q_u->start_idx, num_groups); + samr_array->count = num_groups; + samr_array->entries = samr_entries; - DEBUG(5,("samr_enum_dom_groups: %d\n", __LINE__)); + *r->out.sam = samr_array; + *r->out.num_entries = num_groups; + /* this was missing, IMHO: + *r->out.resume_handle = num_groups + *r->in.resume_handle; + */ - return r_u->status; + DEBUG(5,("_samr_EnumDomainGroups: %d\n", __LINE__)); + + return status; } /******************************************************************* - samr_reply_enum_dom_aliases + _samr_EnumDomainAliases ********************************************************************/ -NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, SAMR_R_ENUM_DOM_ALIASES *r_u) +NTSTATUS _samr_EnumDomainAliases(pipes_struct *p, + struct samr_EnumDomainAliases *r) { + NTSTATUS status; struct samr_info *info; struct samr_displayentry *aliases; uint32 num_aliases = 0; + struct samr_SamArray *samr_array = NULL; + struct samr_SamEntry *samr_entries = NULL; /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.domain_handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - r_u->status = access_check_samr_function(info->acc_granted, - SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, - "_samr_enum_dom_aliases"); - if (!NT_STATUS_IS_OK(r_u->status)) - return r_u->status; + status = access_check_samr_function(info->acc_granted, + SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, + "_samr_EnumDomainAliases"); + if (!NT_STATUS_IS_OK(status)) { + return status; + } - DEBUG(5,("samr_reply_enum_dom_aliases: sid %s\n", + DEBUG(5,("_samr_EnumDomainAliases: sid %s\n", sid_string_dbg(&info->sid))); + samr_array = TALLOC_ZERO_P(p->mem_ctx, struct samr_SamArray); + if (!samr_array) { + return NT_STATUS_NO_MEMORY; + } + become_root(); if (info->disp_info->aliases == NULL) { @@ -1121,22 +1141,27 @@ NTSTATUS _samr_enum_dom_aliases(pipes_struct *p, SAMR_Q_ENUM_DOM_ALIASES *q_u, S } } - num_aliases = pdb_search_entries(info->disp_info->aliases, q_u->start_idx, + num_aliases = pdb_search_entries(info->disp_info->aliases, + *r->in.resume_handle, MAX_SAM_ENTRIES, &aliases); unbecome_root(); /* Ensure we cache this enumeration. */ set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); - make_group_sam_entry_list(p->mem_ctx, &r_u->sam, &r_u->uni_grp_name, + make_group_sam_entry_list(p->mem_ctx, &samr_entries, num_aliases, aliases); - init_samr_r_enum_dom_aliases(r_u, q_u->start_idx + num_aliases, - num_aliases); + DEBUG(5,("_samr_EnumDomainAliases: %d\n", __LINE__)); - DEBUG(5,("samr_enum_dom_aliases: %d\n", __LINE__)); + samr_array->count = num_aliases; + samr_array->entries = samr_entries; - return r_u->status; + *r->out.sam = samr_array; + *r->out.num_entries = num_aliases; + *r->out.resume_handle = num_aliases + *r->in.resume_handle; + + return status; } /******************************************************************* @@ -5209,16 +5234,6 @@ NTSTATUS _samr_Shutdown(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_EnumDomainGroups(pipes_struct *p, - struct samr_EnumDomainGroups *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_CreateUser(pipes_struct *p, struct samr_CreateUser *r) { @@ -5239,16 +5254,6 @@ NTSTATUS _samr_EnumDomainUsers(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_EnumDomainAliases(pipes_struct *p, - struct samr_EnumDomainAliases *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_SetMemberAttributesOfGroup(pipes_struct *p, struct samr_SetMemberAttributesOfGroup *r) { -- cgit From 8b02303c904b9a5e342094325448d28cbe9ed5b4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 12 Feb 2008 03:33:41 +0100 Subject: Use pidl for _samr_EnumDomainUsers(). Guenther (This used to be commit 54e884add2c5c836e78dfdd247dd93d754b70178) --- source3/rpc_server/srv_samr.c | 24 +------- source3/rpc_server/srv_samr_nt.c | 121 +++++++++++++++++++-------------------- 2 files changed, 60 insertions(+), 85 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index af46469e06..d25ca3a178 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -107,29 +107,7 @@ static bool api_samr_query_sec_obj(pipes_struct *p) static bool api_samr_enum_dom_users(pipes_struct *p) { - SAMR_Q_ENUM_DOM_USERS q_u; - SAMR_R_ENUM_DOM_USERS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the samr open */ - if(!samr_io_q_enum_dom_users("", &q_u, data, 0)) { - DEBUG(0,("api_samr_enum_dom_users: unable to unmarshall SAMR_Q_ENUM_DOM_USERS.\n")); - return False; - } - - r_u.status = _samr_enum_dom_users(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_enum_dom_users("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_enum_dom_users: unable to marshall SAMR_R_ENUM_DOM_USERS.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_ENUMDOMAINUSERS); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e458fce6de..fb01357f67 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -841,32 +841,29 @@ NTSTATUS _samr_QuerySecurity(pipes_struct *p, makes a SAM_ENTRY / UNISTR2* structure from a user list. ********************************************************************/ -static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, - UNISTR2 **uni_name_pp, - uint32 num_entries, uint32 start_idx, +static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, + struct samr_SamEntry **sam_pp, + uint32_t num_entries, + uint32_t start_idx, struct samr_displayentry *entries) { - uint32 i; - SAM_ENTRY *sam; - UNISTR2 *uni_name; + uint32_t i; + struct samr_SamEntry *sam; *sam_pp = NULL; - *uni_name_pp = NULL; - if (num_entries == 0) + if (num_entries == 0) { return NT_STATUS_OK; + } - sam = TALLOC_ZERO_ARRAY(ctx, SAM_ENTRY, num_entries); - - uni_name = TALLOC_ZERO_ARRAY(ctx, UNISTR2, num_entries); - - if (sam == NULL || uni_name == NULL) { + sam = TALLOC_ZERO_ARRAY(ctx, struct samr_SamEntry, num_entries); + if (sam == NULL) { DEBUG(0, ("make_user_sam_entry_list: TALLOC_ZERO failed!\n")); return NT_STATUS_NO_MEMORY; } for (i = 0; i < num_entries; i++) { - UNISTR2 uni_temp_name; +#if 0 /* * usrmgr expects a non-NULL terminated string with * trust relationships @@ -878,50 +875,57 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, SAM_ENTRY **sam_pp, init_unistr2(&uni_temp_name, entries[i].account_name, UNI_STR_TERMINATE); } - - init_sam_entry(&sam[i], &uni_temp_name, entries[i].rid); - copy_unistr2(&uni_name[i], &uni_temp_name); +#endif + init_lsa_String(&sam[i].name, entries[i].account_name); + sam[i].idx = entries[i].rid; } *sam_pp = sam; - *uni_name_pp = uni_name; + return NT_STATUS_OK; } /******************************************************************* - samr_reply_enum_dom_users + _samr_EnumDomainUsers ********************************************************************/ -NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, - SAMR_R_ENUM_DOM_USERS *r_u) +NTSTATUS _samr_EnumDomainUsers(pipes_struct *p, + struct samr_EnumDomainUsers *r) { + NTSTATUS status; struct samr_info *info = NULL; int num_account; - uint32 enum_context=q_u->start_idx; + uint32 enum_context = *r->in.resume_handle; enum remote_arch_types ra_type = get_remote_arch(); int max_sam_entries = (ra_type == RA_WIN95) ? MAX_SAM_ENTRIES_W95 : MAX_SAM_ENTRIES_W2K; uint32 max_entries = max_sam_entries; struct samr_displayentry *entries = NULL; - - r_u->status = NT_STATUS_OK; + struct samr_SamArray *samr_array = NULL; + struct samr_SamEntry *samr_entries = NULL; /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.domain_handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - if (!NT_STATUS_IS_OK(r_u->status = access_check_samr_function(info->acc_granted, - SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, - "_samr_enum_dom_users"))) { - return r_u->status; + status = access_check_samr_function(info->acc_granted, + SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, + "_samr_EnumDomainUsers"); + if (!NT_STATUS_IS_OK(status)) { + return status; } - DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); + DEBUG(5,("_samr_EnumDomainUsers: %d\n", __LINE__)); if (info->builtin_domain) { /* No users in builtin. */ - init_samr_r_enum_dom_users(r_u, q_u->start_idx, 0); - DEBUG(5,("_samr_enum_dom_users: No users in BUILTIN\n")); - return r_u->status; + *r->out.resume_handle = *r->in.resume_handle; + DEBUG(5,("_samr_EnumDomainUsers: No users in BUILTIN\n")); + return status; + } + + samr_array = TALLOC_ZERO_P(p->mem_ctx, struct samr_SamArray); + if (!samr_array) { + return NT_STATUS_NO_MEMORY; } become_root(); @@ -929,14 +933,14 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, /* AS ROOT !!!! */ if ((info->disp_info->enum_users != NULL) && - (info->disp_info->enum_acb_mask != q_u->acb_mask)) { + (info->disp_info->enum_acb_mask != r->in.acct_flags)) { pdb_search_destroy(info->disp_info->enum_users); info->disp_info->enum_users = NULL; } if (info->disp_info->enum_users == NULL) { - info->disp_info->enum_users = pdb_search_users(q_u->acb_mask); - info->disp_info->enum_acb_mask = q_u->acb_mask; + info->disp_info->enum_users = pdb_search_users(r->in.acct_flags); + info->disp_info->enum_acb_mask = r->in.acct_flags; } if (info->disp_info->enum_users == NULL) { @@ -954,37 +958,40 @@ NTSTATUS _samr_enum_dom_users(pipes_struct *p, SAMR_Q_ENUM_DOM_USERS *q_u, unbecome_root(); if (num_account == 0) { - DEBUG(5, ("_samr_enum_dom_users: enumeration handle over " + DEBUG(5, ("_samr_EnumDomainUsers: enumeration handle over " "total entries\n")); - init_samr_r_enum_dom_users(r_u, q_u->start_idx, 0); + *r->out.resume_handle = *r->in.resume_handle; return NT_STATUS_OK; } - r_u->status = make_user_sam_entry_list(p->mem_ctx, &r_u->sam, - &r_u->uni_acct_name, - num_account, enum_context, - entries); - - if (!NT_STATUS_IS_OK(r_u->status)) - return r_u->status; + status = make_user_sam_entry_list(p->mem_ctx, &samr_entries, + num_account, enum_context, + entries); + if (!NT_STATUS_IS_OK(status)) { + return status; + } if (max_entries <= num_account) { - r_u->status = STATUS_MORE_ENTRIES; + status = STATUS_MORE_ENTRIES; } else { - r_u->status = NT_STATUS_OK; + status = NT_STATUS_OK; } /* Ensure we cache this enumeration. */ set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); - DEBUG(5, ("_samr_enum_dom_users: %d\n", __LINE__)); + DEBUG(5, ("_samr_EnumDomainUsers: %d\n", __LINE__)); + + samr_array->count = num_account; + samr_array->entries = samr_entries; - init_samr_r_enum_dom_users(r_u, q_u->start_idx + num_account, - num_account); + *r->out.resume_handle = *r->in.resume_handle + num_account; + *r->out.sam = samr_array; + *r->out.num_entries = num_account; - DEBUG(5,("_samr_enum_dom_users: %d\n", __LINE__)); + DEBUG(5,("_samr_EnumDomainUsers: %d\n", __LINE__)); - return r_u->status; + return status; } /******************************************************************* @@ -5244,16 +5251,6 @@ NTSTATUS _samr_CreateUser(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_EnumDomainUsers(pipes_struct *p, - struct samr_EnumDomainUsers *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_SetMemberAttributesOfGroup(pipes_struct *p, struct samr_SetMemberAttributesOfGroup *r) { -- cgit From 50019747fc44e0181309e36ee260fbf67ac3ce08 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 12 Feb 2008 10:07:50 +0100 Subject: Cosmetics: remove new whitespace, sorry. Guenther (This used to be commit d82b66b96958bb0696ad316326bb2f1ac4102801) --- source3/rpc_server/srv_samr_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index fb01357f67..e493496720 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -907,11 +907,11 @@ NTSTATUS _samr_EnumDomainUsers(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.domain_handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - status = access_check_samr_function(info->acc_granted, + status = access_check_samr_function(info->acc_granted, SA_RIGHT_DOMAIN_ENUM_ACCOUNTS, "_samr_EnumDomainUsers"); if (!NT_STATUS_IS_OK(status)) { - return status; + return status; } DEBUG(5,("_samr_EnumDomainUsers: %d\n", __LINE__)); -- cgit From 6aa84ad8c5a535fc45cc9014fdc36867b6c76be9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 12 Feb 2008 12:16:02 +0100 Subject: Move some samr init functions around (to allow easier identification of new calls). Guenther (This used to be commit c51c126049bd251a04dfae7ca6c3d0d3f823a503) --- source3/rpc_server/srv_samr_nt.c | 237 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 222 insertions(+), 15 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e493496720..e87d43dec4 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1171,6 +1171,213 @@ NTSTATUS _samr_EnumDomainAliases(pipes_struct *p, return status; } +/******************************************************************* + inits a structure. +********************************************************************/ + +static void init_lsa_AsciiString(struct lsa_AsciiString *name, const char *s) +{ + name->string = s; +} + +/******************************************************************* + inits a samr_DispInfoGeneral structure. +********************************************************************/ + +static NTSTATUS init_samr_dispinfo_1(TALLOC_CTX *ctx, + struct samr_DispInfoGeneral *r, + uint32_t num_entries, + uint32_t start_idx, + struct samr_displayentry *entries) +{ + uint32 i; + + DEBUG(10, ("init_samr_dispinfo_1: num_entries: %d\n", num_entries)); + + if (num_entries == 0) { + return NT_STATUS_OK; + } + + r->count = num_entries; + + r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryGeneral, num_entries); + if (!r->entries) { + return NT_STATUS_NO_MEMORY; + } + + for (i = 0; i < num_entries ; i++) { + + init_lsa_String(&r->entries[i].account_name, + entries[i].account_name); + + init_lsa_String(&r->entries[i].description, + entries[i].description); + + init_lsa_String(&r->entries[i].full_name, + entries[i].fullname); + + r->entries[i].rid = entries[i].rid; + r->entries[i].acct_flags = entries[i].acct_flags; + r->entries[i].idx = start_idx+i+1; + } + + return NT_STATUS_OK; +} + +/******************************************************************* + inits a samr_DispInfoFull structure. +********************************************************************/ + +static NTSTATUS init_samr_dispinfo_2(TALLOC_CTX *ctx, + struct samr_DispInfoFull *r, + uint32_t num_entries, + uint32_t start_idx, + struct samr_displayentry *entries) +{ + uint32_t i; + + DEBUG(10, ("init_samr_dispinfo_2: num_entries: %d\n", num_entries)); + + if (num_entries == 0) { + return NT_STATUS_OK; + } + + r->count = num_entries; + + r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryFull, num_entries); + if (!r->entries) { + return NT_STATUS_NO_MEMORY; + } + + for (i = 0; i < num_entries ; i++) { + + init_lsa_String(&r->entries[i].account_name, + entries[i].account_name); + + init_lsa_String(&r->entries[i].description, + entries[i].description); + + r->entries[i].rid = entries[i].rid; + r->entries[i].acct_flags = entries[i].acct_flags; + r->entries[i].idx = start_idx+i+1; + } + + return NT_STATUS_OK; +} + +/******************************************************************* + inits a samr_DispInfoFullGroups structure. +********************************************************************/ + +static NTSTATUS init_samr_dispinfo_3(TALLOC_CTX *ctx, + struct samr_DispInfoFullGroups *r, + uint32_t num_entries, + uint32_t start_idx, + struct samr_displayentry *entries) +{ + uint32_t i; + + DEBUG(5, ("init_samr_dispinfo_3: num_entries: %d\n", num_entries)); + + if (num_entries == 0) { + return NT_STATUS_OK; + } + + r->count = num_entries; + + r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryFullGroup, num_entries); + if (!r->entries) { + return NT_STATUS_NO_MEMORY; + } + + for (i = 0; i < num_entries ; i++) { + + init_lsa_String(&r->entries[i].account_name, + entries[i].account_name); + + init_lsa_String(&r->entries[i].description, + entries[i].description); + + r->entries[i].rid = entries[i].rid; + r->entries[i].acct_flags = entries[i].acct_flags; + r->entries[i].idx = start_idx+i+1; + } + + return NT_STATUS_OK; +} + +/******************************************************************* + inits a samr_DispInfoAscii structure. +********************************************************************/ + +static NTSTATUS init_samr_dispinfo_4(TALLOC_CTX *ctx, + struct samr_DispInfoAscii *r, + uint32_t num_entries, + uint32_t start_idx, + struct samr_displayentry *entries) +{ + uint32_t i; + + DEBUG(5, ("init_samr_dispinfo_4: num_entries: %d\n", num_entries)); + + if (num_entries == 0) { + return NT_STATUS_OK; + } + + r->count = num_entries; + + r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryAscii, num_entries); + if (!r->entries) { + return NT_STATUS_NO_MEMORY; + } + + for (i = 0; i < num_entries ; i++) { + + init_lsa_AsciiString(&r->entries[i].account_name, + entries[i].account_name); + + r->entries[i].idx = start_idx+i+1; + } + + return NT_STATUS_OK; +} + +/******************************************************************* + inits a samr_DispInfoAscii structure. +********************************************************************/ + +static NTSTATUS init_samr_dispinfo_5(TALLOC_CTX *ctx, + struct samr_DispInfoAscii *r, + uint32_t num_entries, + uint32_t start_idx, + struct samr_displayentry *entries) +{ + uint32_t i; + + DEBUG(5, ("init_samr_dispinfo_5: num_entries: %d\n", num_entries)); + + if (num_entries == 0) { + return NT_STATUS_OK; + } + + r->count = num_entries; + + r->entries = TALLOC_ZERO_ARRAY(ctx, struct samr_DispEntryAscii, num_entries); + if (!r->entries) { + return NT_STATUS_NO_MEMORY; + } + + for (i = 0; i < num_entries ; i++) { + + init_lsa_AsciiString(&r->entries[i].account_name, + entries[i].account_name); + + r->entries[i].idx = start_idx+i+1; + } + + return NT_STATUS_OK; +} + /******************************************************************* _samr_QueryDisplayInfo ********************************************************************/ @@ -1327,29 +1534,29 @@ NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p, /* Now create reply structure */ switch (r->in.level) { case 0x1: - disp_ret = init_sam_dispinfo_1(p->mem_ctx, &disp_info->info1, - num_account, enum_context, - entries); + disp_ret = init_samr_dispinfo_1(p->mem_ctx, &disp_info->info1, + num_account, enum_context, + entries); break; case 0x2: - disp_ret = init_sam_dispinfo_2(p->mem_ctx, &disp_info->info2, - num_account, enum_context, - entries); + disp_ret = init_samr_dispinfo_2(p->mem_ctx, &disp_info->info2, + num_account, enum_context, + entries); break; case 0x3: - disp_ret = init_sam_dispinfo_3(p->mem_ctx, &disp_info->info3, - num_account, enum_context, - entries); + disp_ret = init_samr_dispinfo_3(p->mem_ctx, &disp_info->info3, + num_account, enum_context, + entries); break; case 0x4: - disp_ret = init_sam_dispinfo_4(p->mem_ctx, &disp_info->info4, - num_account, enum_context, - entries); + disp_ret = init_samr_dispinfo_4(p->mem_ctx, &disp_info->info4, + num_account, enum_context, + entries); break; case 0x5: - disp_ret = init_sam_dispinfo_5(p->mem_ctx, &disp_info->info5, - num_account, enum_context, - entries); + disp_ret = init_samr_dispinfo_5(p->mem_ctx, &disp_info->info5, + num_account, enum_context, + entries); break; default: smb_panic("info class changed"); -- cgit From 4867e1ff93cae13b6d03bf0a0526c5655100a098 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 12 Feb 2008 02:10:40 +0100 Subject: Merge _samr_SetUserInfo and _samr_SetUserInfo2 into one call. Guenther (This used to be commit 8ee7dfad2e3a40e378398ea20158d3c7e7168cba) --- source3/rpc_server/srv_samr_nt.c | 287 +++++++++++++++------------------------ 1 file changed, 107 insertions(+), 180 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index e87d43dec4..412aa9df91 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3792,30 +3792,33 @@ static NTSTATUS set_user_info_25(TALLOC_CTX *mem_ctx, } /******************************************************************* - _samr_SetUserInfo + samr_SetUserInfo_internal ********************************************************************/ -NTSTATUS _samr_SetUserInfo(pipes_struct *p, - struct samr_SetUserInfo *r) +static NTSTATUS samr_SetUserInfo_internal(const char *fn_name, + pipes_struct *p, + struct policy_handle *user_handle, + uint16_t level, + union samr_UserInfo *info) { NTSTATUS status; struct samu *pwd = NULL; DOM_SID sid; - POLICY_HND *pol = r->in.user_handle; - uint16 switch_value = r->in.level; - union samr_UserInfo *info = r->in.info; - uint32 acc_granted; - uint32 acc_required; + POLICY_HND *pol = user_handle; + uint16_t switch_value = level; + uint32_t acc_granted; + uint32_t acc_required; bool ret; bool has_enough_rights = False; - uint32 acb_info; + uint32_t acb_info; DISP_INFO *disp_info = NULL; - DEBUG(5, ("_samr_SetUserInfo: %d\n", __LINE__)); + DEBUG(5,("%s: %d\n", fn_name, __LINE__)); /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info)) + if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info)) { return NT_STATUS_INVALID_HANDLE; + } /* This is tricky. A WinXP domain join sets (SA_RIGHT_USER_SET_PASSWORD|SA_RIGHT_USER_SET_ATTRIBUTES|SA_RIGHT_USER_ACCT_FLAGS_EXPIRY) @@ -3832,26 +3835,28 @@ NTSTATUS _samr_SetUserInfo(pipes_struct *p, acc_required = SA_RIGHT_USER_SET_PASSWORD; break; default: - acc_required = SA_RIGHT_USER_SET_PASSWORD | SA_RIGHT_USER_SET_ATTRIBUTES | SA_RIGHT_USER_ACCT_FLAGS_EXPIRY; + acc_required = SA_RIGHT_USER_SET_PASSWORD | + SA_RIGHT_USER_SET_ATTRIBUTES | + SA_RIGHT_USER_ACCT_FLAGS_EXPIRY; break; } status = access_check_samr_function(acc_granted, acc_required, - "_samr_SetUserInfo"); + fn_name); if (!NT_STATUS_IS_OK(status)) { return status; } - DEBUG(5, ("_samr_SetUserInfo: sid:%s, level:%d\n", - sid_string_dbg(&sid), switch_value)); + DEBUG(5, ("%s: sid:%s, level:%d\n", + fn_name, sid_string_dbg(&sid), switch_value)); if (info == NULL) { - DEBUG(5, ("_samr_SetUserInfo: NULL info level\n")); + DEBUG(5, ("%s: NULL info level\n", fn_name)); return NT_STATUS_INVALID_INFO_CLASS; } - if ( !(pwd = samu_new( NULL )) ) { + if (!(pwd = samu_new(NULL))) { return NT_STATUS_NO_MEMORY; } @@ -3859,7 +3864,7 @@ NTSTATUS _samr_SetUserInfo(pipes_struct *p, ret = pdb_getsampwsid(pwd, &sid); unbecome_root(); - if ( !ret ) { + if (!ret) { TALLOC_FREE(pwd); return NT_STATUS_NO_SUCH_USER; } @@ -3868,30 +3873,74 @@ NTSTATUS _samr_SetUserInfo(pipes_struct *p, /* check to see if we have the sufficient rights */ acb_info = pdb_get_acct_ctrl(pwd); - if ( acb_info & ACB_WSTRUST ) - has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_machine_account); - else if ( acb_info & ACB_NORMAL ) - has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users ); - else if ( acb_info & (ACB_SVRTRUST|ACB_DOMTRUST) ) { - if ( lp_enable_privileges() ) - has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); + if (acb_info & ACB_WSTRUST) + has_enough_rights = user_has_privileges(p->pipe_user.nt_user_token, + &se_machine_account); + else if (acb_info & ACB_NORMAL) + has_enough_rights = user_has_privileges(p->pipe_user.nt_user_token, + &se_add_users); + else if (acb_info & (ACB_SVRTRUST|ACB_DOMTRUST)) { + if (lp_enable_privileges()) { + has_enough_rights = nt_token_check_domain_rid(p->pipe_user.nt_user_token, + DOMAIN_GROUP_RID_ADMINS); + } } - DEBUG(5, ("_samr_SetUserInfo: %s does%s possess sufficient rights\n", + DEBUG(5, ("%s: %s does%s possess sufficient rights\n", + fn_name, uidtoname(p->pipe_user.ut.uid), has_enough_rights ? "" : " not")); /* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */ - if ( has_enough_rights ) + if (has_enough_rights) { become_root(); + } /* ok! user info levels (lots: see MSDEV help), off we go... */ switch (switch_value) { + + case 7: + status = set_user_info_7(p->mem_ctx, + &info->info7, pwd); + break; + + case 16: + if (!set_user_info_16(&info->info16, pwd)) { + status = NT_STATUS_ACCESS_DENIED; + } + break; + case 18: - if (!set_user_info_18(&info->info18, pwd)) + /* Used by AS/U JRA. */ + if (!set_user_info_18(&info->info18, pwd)) { status = NT_STATUS_ACCESS_DENIED; + } + break; + + case 20: + if (!set_user_info_20(&info->info20, pwd)) { + status = NT_STATUS_ACCESS_DENIED; + } + break; + + case 21: + status = set_user_info_21(p->mem_ctx, + &info->info21, pwd); + break; + + case 23: + if (!p->session_key.length) { + status = NT_STATUS_NO_USER_SESSION_KEY; + } + SamOEMhashBlob(info->info23.password.data, 516, + &p->session_key); + + dump_data(100, info->info23.password.data, 516); + + status = set_user_info_23(p->mem_ctx, + &info->info23, pwd); break; case 24: @@ -3904,15 +3953,17 @@ NTSTATUS _samr_SetUserInfo(pipes_struct *p, dump_data(100, info->info24.password.data, 516); - if (!set_user_info_pw(info->info24.password.data, pwd)) + if (!set_user_info_pw(info->info24.password.data, pwd)) { status = NT_STATUS_ACCESS_DENIED; + } break; case 25: if (!p->session_key.length) { status = NT_STATUS_NO_USER_SESSION_KEY; } - encode_or_decode_arc4_passwd_buffer(info->info25.password.data, &p->session_key); + encode_or_decode_arc4_passwd_buffer(info->info25.password.data, + &p->session_key); dump_data(100, info->info25.password.data, 532); @@ -3921,32 +3972,23 @@ NTSTATUS _samr_SetUserInfo(pipes_struct *p, if (!NT_STATUS_IS_OK(status)) { goto done; } - if (!set_user_info_pw(info->info25.password.data, pwd)) + if (!set_user_info_pw(info->info25.password.data, pwd)) { status = NT_STATUS_ACCESS_DENIED; + } break; case 26: if (!p->session_key.length) { status = NT_STATUS_NO_USER_SESSION_KEY; } - encode_or_decode_arc4_passwd_buffer(info->info26.password.data, &p->session_key); + encode_or_decode_arc4_passwd_buffer(info->info26.password.data, + &p->session_key); dump_data(100, info->info26.password.data, 516); - if (!set_user_info_pw(info->info26.password.data, pwd)) + if (!set_user_info_pw(info->info26.password.data, pwd)) { status = NT_STATUS_ACCESS_DENIED; - break; - - case 23: - if (!p->session_key.length) { - status = NT_STATUS_NO_USER_SESSION_KEY; } - SamOEMhashBlob(info->info23.password.data, 516, &p->session_key); - - dump_data(100, info->info23.password.data, 516); - - status = set_user_info_23(p->mem_ctx, - &info->info23, pwd); break; default: @@ -3955,8 +3997,9 @@ NTSTATUS _samr_SetUserInfo(pipes_struct *p, done: - if ( has_enough_rights ) + if (has_enough_rights) { unbecome_root(); + } /* ================ END SeMachineAccountPrivilege BLOCK ================ */ @@ -3967,6 +4010,20 @@ NTSTATUS _samr_SetUserInfo(pipes_struct *p, return status; } +/******************************************************************* + _samr_SetUserInfo + ********************************************************************/ + +NTSTATUS _samr_SetUserInfo(pipes_struct *p, + struct samr_SetUserInfo *r) +{ + return samr_SetUserInfo_internal("_samr_SetUserInfo", + p, + r->in.user_handle, + r->in.level, + r->in.info); +} + /******************************************************************* _samr_SetUserInfo2 ********************************************************************/ @@ -3974,141 +4031,11 @@ NTSTATUS _samr_SetUserInfo(pipes_struct *p, NTSTATUS _samr_SetUserInfo2(pipes_struct *p, struct samr_SetUserInfo2 *r) { - NTSTATUS status; - struct samu *pwd = NULL; - DOM_SID sid; - union samr_UserInfo *info = r->in.info; - POLICY_HND *pol = r->in.user_handle; - uint16 switch_value = r->in.level; - uint32 acc_granted; - uint32 acc_required; - bool ret; - bool has_enough_rights = False; - uint32 acb_info; - DISP_INFO *disp_info = NULL; - - DEBUG(5, ("_samr_SetUserInfo2: %d\n", __LINE__)); - - /* find the policy handle. open a policy on it. */ - if (!get_lsa_policy_samr_sid(p, pol, &sid, &acc_granted, &disp_info)) - return NT_STATUS_INVALID_HANDLE; - - -#if 0 /* this really should be applied on a per info level basis --jerry */ - - /* observed when joining XP client to Samba domain */ - acc_required = SA_RIGHT_USER_SET_PASSWORD | SA_RIGHT_USER_SET_ATTRIBUTES | SA_RIGHT_USER_ACCT_FLAGS_EXPIRY; -#else - acc_required = SA_RIGHT_USER_SET_ATTRIBUTES; -#endif - - status = access_check_samr_function(acc_granted, - acc_required, - "_samr_SetUserInfo2"); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - DEBUG(5,("_samr_SetUserInfo2: sid:%s\n", - sid_string_dbg(&sid))); - - if (info == NULL) { - DEBUG(5,("_samr_SetUserInfo2: NULL info level\n")); - return NT_STATUS_INVALID_INFO_CLASS; - } - - if ( !(pwd = samu_new( NULL )) ) { - return NT_STATUS_NO_MEMORY; - } - - become_root(); - ret = pdb_getsampwsid(pwd, &sid); - unbecome_root(); - - if ( !ret ) { - TALLOC_FREE(pwd); - return NT_STATUS_NO_SUCH_USER; - } - - acb_info = pdb_get_acct_ctrl(pwd); - if ( acb_info & ACB_WSTRUST ) - has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_machine_account); - else if ( acb_info & ACB_NORMAL ) - has_enough_rights = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users ); - else if ( acb_info & (ACB_SVRTRUST|ACB_DOMTRUST) ) { - if ( lp_enable_privileges() ) - has_enough_rights = nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ); - } - - DEBUG(5, ("_samr_SetUserInfo2: %s does%s possess sufficient rights\n", - uidtoname(p->pipe_user.ut.uid), - has_enough_rights ? "" : " not")); - - /* ================ BEGIN SeMachineAccountPrivilege BLOCK ================ */ - - if ( has_enough_rights ) - become_root(); - - /* ok! user info levels (lots: see MSDEV help), off we go... */ - - switch (switch_value) { - case 7: - status = set_user_info_7(p->mem_ctx, - &info->info7, pwd); - break; - case 16: - if (!set_user_info_16(&info->info16, pwd)) - status = NT_STATUS_ACCESS_DENIED; - break; - case 18: - /* Used by AS/U JRA. */ - if (!set_user_info_18(&info->info18, pwd)) - status = NT_STATUS_ACCESS_DENIED; - break; - case 20: - if (!set_user_info_20(&info->info20, pwd)) - status = NT_STATUS_ACCESS_DENIED; - break; - case 21: - status = set_user_info_21(p->mem_ctx, - &info->info21, pwd); - break; - case 23: - if (!p->session_key.length) { - status = NT_STATUS_NO_USER_SESSION_KEY; - } - SamOEMhashBlob(info->info23.password.data, 516, &p->session_key); - - dump_data(100, info->info23.password.data, 516); - - status = set_user_info_23(p->mem_ctx, - &info->info23, pwd); - break; - case 26: - if (!p->session_key.length) { - status = NT_STATUS_NO_USER_SESSION_KEY; - } - encode_or_decode_arc4_passwd_buffer(info->info26.password.data, &p->session_key); - - dump_data(100, info->info26.password.data, 516); - - if (!set_user_info_pw(info->info26.password.data, pwd)) - status = NT_STATUS_ACCESS_DENIED; - break; - default: - status = NT_STATUS_INVALID_INFO_CLASS; - } - - if ( has_enough_rights ) - unbecome_root(); - - /* ================ END SeMachineAccountPrivilege BLOCK ================ */ - - if (NT_STATUS_IS_OK(status)) { - force_flush_samr_cache(disp_info); - } - - return status; + return samr_SetUserInfo_internal("_samr_SetUserInfo2", + p, + r->in.user_handle, + r->in.level, + r->in.info); } /********************************************************************* -- cgit From 4974200f308229f8d7d1637ef9a33bcd921e138f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 12 Feb 2008 12:58:47 +0100 Subject: Use pidl for _samr_QueryUserInfo. Guenther (This used to be commit 53dc913b2d01aeea2a7490c5ef1292e6c6eff5e7) --- source3/rpc_server/srv_samr.c | 23 +-- source3/rpc_server/srv_samr_nt.c | 341 ++++++++++++++++++++++++++++----------- 2 files changed, 248 insertions(+), 116 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index d25ca3a178..f7cc7eec10 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -188,28 +188,7 @@ static bool api_samr_open_user(pipes_struct *p) static bool api_samr_query_userinfo(pipes_struct *p) { - SAMR_Q_QUERY_USERINFO q_u; - SAMR_R_QUERY_USERINFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!samr_io_q_query_userinfo("", &q_u, data, 0)){ - DEBUG(0,("api_samr_query_userinfo: unable to unmarshall SAMR_Q_QUERY_USERINFO.\n")); - return False; - } - - r_u.status = _samr_query_userinfo(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!samr_io_r_query_userinfo("", &r_u, rdata, 0)) { - DEBUG(0,("api_samr_query_userinfo: unable to marshall SAMR_R_QUERY_USERINFO.\n")); - return False; - } - - return True; + return proxy_samr_call(p, NDR_SAMR_QUERYUSERINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 412aa9df91..ac10754493 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2129,10 +2129,15 @@ NTSTATUS _samr_OpenUser(pipes_struct *p, get_user_info_7. Safe. Only gives out account_name. *************************************************************************/ -static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_SID *user_sid) +static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, + struct samr_UserInfo7 *r, + DOM_SID *user_sid) { struct samu *smbpass=NULL; bool ret; + const char *account_name = NULL; + + ZERO_STRUCTP(r); if ( !(smbpass = samu_new( mem_ctx )) ) { return NT_STATUS_NO_MEMORY; @@ -2147,12 +2152,16 @@ static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_S return NT_STATUS_NO_SUCH_USER; } - DEBUG(3,("User:[%s]\n", pdb_get_username(smbpass) )); + account_name = talloc_strdup(mem_ctx, pdb_get_username(smbpass)); + if (!account_name) { + TALLOC_FREE(smbpass); + return NT_STATUS_NO_MEMORY; + } + TALLOC_FREE(smbpass); - ZERO_STRUCTP(id7); - init_sam_user_info7(id7, pdb_get_username(smbpass) ); + DEBUG(3,("User:[%s]\n", account_name)); - TALLOC_FREE(smbpass); + init_samr_user_info7(r, account_name); return NT_STATUS_OK; } @@ -2160,11 +2169,16 @@ static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_S /************************************************************************* get_user_info_9. Only gives out primary group SID. *************************************************************************/ -static NTSTATUS get_user_info_9(TALLOC_CTX *mem_ctx, SAM_USER_INFO_9 * id9, DOM_SID *user_sid) + +static NTSTATUS get_user_info_9(TALLOC_CTX *mem_ctx, + struct samr_UserInfo9 *r, + DOM_SID *user_sid) { struct samu *smbpass=NULL; bool ret; + ZERO_STRUCTP(r); + if ( !(smbpass = samu_new( mem_ctx )) ) { return NT_STATUS_NO_MEMORY; } @@ -2175,13 +2189,13 @@ static NTSTATUS get_user_info_9(TALLOC_CTX *mem_ctx, SAM_USER_INFO_9 * id9, DOM_ if (ret==False) { DEBUG(4,("User %s not found\n", sid_string_dbg(user_sid))); + TALLOC_FREE(smbpass); return NT_STATUS_NO_SUCH_USER; } DEBUG(3,("User:[%s]\n", pdb_get_username(smbpass) )); - ZERO_STRUCTP(id9); - init_sam_user_info9(id9, pdb_get_group_rid(smbpass) ); + init_samr_user_info9(r, pdb_get_group_rid(smbpass)); TALLOC_FREE(smbpass); @@ -2192,11 +2206,15 @@ static NTSTATUS get_user_info_9(TALLOC_CTX *mem_ctx, SAM_USER_INFO_9 * id9, DOM_ get_user_info_16. Safe. Only gives out acb bits. *************************************************************************/ -static NTSTATUS get_user_info_16(TALLOC_CTX *mem_ctx, SAM_USER_INFO_16 *id16, DOM_SID *user_sid) +static NTSTATUS get_user_info_16(TALLOC_CTX *mem_ctx, + struct samr_UserInfo16 *r, + DOM_SID *user_sid) { struct samu *smbpass=NULL; bool ret; + ZERO_STRUCTP(r); + if ( !(smbpass = samu_new( mem_ctx )) ) { return NT_STATUS_NO_MEMORY; } @@ -2207,13 +2225,13 @@ static NTSTATUS get_user_info_16(TALLOC_CTX *mem_ctx, SAM_USER_INFO_16 *id16, DO if (ret==False) { DEBUG(4,("User %s not found\n", sid_string_dbg(user_sid))); + TALLOC_FREE(smbpass); return NT_STATUS_NO_SUCH_USER; } DEBUG(3,("User:[%s]\n", pdb_get_username(smbpass) )); - ZERO_STRUCTP(id16); - init_sam_user_info16(id16, pdb_get_acct_ctrl(smbpass) ); + init_samr_user_info16(r, pdb_get_acct_ctrl(smbpass)); TALLOC_FREE(smbpass); @@ -2226,11 +2244,16 @@ static NTSTATUS get_user_info_16(TALLOC_CTX *mem_ctx, SAM_USER_INFO_16 *id16, DO user. JRA. *************************************************************************/ -static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_INFO_18 * id18, DOM_SID *user_sid) +static NTSTATUS get_user_info_18(pipes_struct *p, + TALLOC_CTX *mem_ctx, + struct samr_UserInfo18 *r, + DOM_SID *user_sid) { struct samu *smbpass=NULL; bool ret; + ZERO_STRUCTP(r); + if (p->auth.auth_type != PIPE_AUTH_TYPE_NTLMSSP || p->auth.auth_type != PIPE_AUTH_TYPE_SPNEGO_NTLMSSP) { return NT_STATUS_ACCESS_DENIED; } @@ -2262,8 +2285,8 @@ static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_ return NT_STATUS_ACCOUNT_DISABLED; } - ZERO_STRUCTP(id18); - init_sam_user_info18(id18, pdb_get_lanman_passwd(smbpass), pdb_get_nt_passwd(smbpass)); + init_samr_user_info18(r, pdb_get_lanman_passwd(smbpass), + pdb_get_nt_passwd(smbpass)); TALLOC_FREE(smbpass); @@ -2274,10 +2297,17 @@ static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_ get_user_info_20 *************************************************************************/ -static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, SAM_USER_INFO_20 *id20, DOM_SID *user_sid) +static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, + struct samr_UserInfo20 *r, + DOM_SID *user_sid) { struct samu *sampass=NULL; bool ret; + const char *munged_dial = NULL; + const char *munged_dial_decoded = NULL; + DATA_BLOB blob; + + ZERO_STRUCTP(r); if ( !(sampass = samu_new( mem_ctx )) ) { return NT_STATUS_NO_MEMORY; @@ -2289,72 +2319,219 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, SAM_USER_INFO_20 *id20, DO if (ret == False) { DEBUG(4,("User %s not found\n", sid_string_dbg(user_sid))); + TALLOC_FREE(sampass); return NT_STATUS_NO_SUCH_USER; } + munged_dial = pdb_get_munged_dial(sampass); + samr_clear_sam_passwd(sampass); DEBUG(3,("User:[%s]\n", pdb_get_username(sampass) )); - ZERO_STRUCTP(id20); - init_sam_user_info20A(id20, sampass); + if (munged_dial) { + blob = base64_decode_data_blob(munged_dial); + munged_dial_decoded = talloc_strndup(mem_ctx, + (const char *)blob.data, + blob.length); + data_blob_free(&blob); + if (!munged_dial_decoded) { + TALLOC_FREE(sampass); + return NT_STATUS_NO_MEMORY; + } + } + +#if 0 + init_unistr2_from_datablob(&usr->uni_munged_dial, &blob); + init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial); + data_blob_free(&blob); +#endif + init_samr_user_info20(r, munged_dial_decoded); TALLOC_FREE(sampass); return NT_STATUS_OK; } + /************************************************************************* get_user_info_21 *************************************************************************/ -static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21, - DOM_SID *user_sid, DOM_SID *domain_sid) +static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, + struct samr_UserInfo21 *r, + DOM_SID *user_sid, + DOM_SID *domain_sid) { - struct samu *sampass=NULL; + struct samu *pw = NULL; bool ret; - NTSTATUS nt_status; - - if ( !(sampass = samu_new( mem_ctx )) ) { + const DOM_SID *sid_user, *sid_group; + uint32_t rid, primary_gid; + NTTIME last_logon, last_logoff, last_password_change, + acct_expiry, allow_password_change, force_password_change; + time_t must_change_time; + uint8_t password_expired; + const char *account_name, *full_name, *home_directory, *home_drive, + *logon_script, *profile_path, *description, + *workstations, *comment, *parameters; + struct samr_LogonHours logon_hours; + const char *munged_dial = NULL; + DATA_BLOB blob; + + ZERO_STRUCTP(r); + + if (!(pw = samu_new(mem_ctx))) { return NT_STATUS_NO_MEMORY; } become_root(); - ret = pdb_getsampwsid(sampass, user_sid); + ret = pdb_getsampwsid(pw, user_sid); unbecome_root(); if (ret == False) { DEBUG(4,("User %s not found\n", sid_string_dbg(user_sid))); + TALLOC_FREE(pw); return NT_STATUS_NO_SUCH_USER; } - samr_clear_sam_passwd(sampass); + samr_clear_sam_passwd(pw); - DEBUG(3,("User:[%s]\n", pdb_get_username(sampass) )); + DEBUG(3,("User:[%s]\n", pdb_get_username(pw))); - ZERO_STRUCTP(id21); - nt_status = init_sam_user_info21A(id21, sampass, domain_sid); + sid_user = pdb_get_user_sid(pw); - TALLOC_FREE(sampass); + if (!sid_peek_check_rid(domain_sid, sid_user, &rid)) { + DEBUG(0, ("get_user_info_21: User %s has SID %s, \nwhich conflicts with " + "the domain sid %s. Failing operation.\n", + pdb_get_username(pw), sid_string_dbg(sid_user), + sid_string_dbg(domain_sid))); + TALLOC_FREE(pw); + return NT_STATUS_UNSUCCESSFUL; + } - return nt_status; + become_root(); + sid_group = pdb_get_group_sid(pw); + unbecome_root(); + + if (!sid_peek_check_rid(domain_sid, sid_group, &primary_gid)) { + DEBUG(0, ("get_user_info_21: User %s has Primary Group SID %s, \n" + "which conflicts with the domain sid %s. Failing operation.\n", + pdb_get_username(pw), sid_string_dbg(sid_group), + sid_string_dbg(domain_sid))); + TALLOC_FREE(pw); + return NT_STATUS_UNSUCCESSFUL; + } + + unix_to_nt_time(&last_logon, pdb_get_logon_time(pw)); + unix_to_nt_time(&last_logoff, pdb_get_logoff_time(pw)); + unix_to_nt_time(&acct_expiry, pdb_get_kickoff_time(pw)); + unix_to_nt_time(&last_password_change, pdb_get_pass_last_set_time(pw)); + unix_to_nt_time(&allow_password_change, pdb_get_pass_can_change_time(pw)); + + must_change_time = pdb_get_pass_must_change_time(pw); + if (must_change_time == get_time_t_max()) { + unix_to_nt_time_abs(&force_password_change, must_change_time); + } else { + unix_to_nt_time(&force_password_change, must_change_time); + } + + if (pdb_get_pass_must_change_time(pw) == 0) { + password_expired = PASS_MUST_CHANGE_AT_NEXT_LOGON; + } else { + password_expired = 0; + } + + munged_dial = pdb_get_munged_dial(pw); + if (munged_dial) { + blob = base64_decode_data_blob(munged_dial); + parameters = talloc_strndup(mem_ctx, (const char *)blob.data, blob.length); + data_blob_free(&blob); + if (!parameters) { + TALLOC_FREE(pw); + return NT_STATUS_NO_MEMORY; + } + } + + + account_name = talloc_strdup(mem_ctx, pdb_get_username(pw)); + full_name = talloc_strdup(mem_ctx, pdb_get_fullname(pw)); + home_directory = talloc_strdup(mem_ctx, pdb_get_homedir(pw)); + home_drive = talloc_strdup(mem_ctx, pdb_get_dir_drive(pw)); + logon_script = talloc_strdup(mem_ctx, pdb_get_logon_script(pw)); + profile_path = talloc_strdup(mem_ctx, pdb_get_profile_path(pw)); + description = talloc_strdup(mem_ctx, pdb_get_acct_desc(pw)); + workstations = talloc_strdup(mem_ctx, pdb_get_workstations(pw)); + comment = talloc_strdup(mem_ctx, pdb_get_comment(pw)); + + logon_hours = get_logon_hours_from_pdb(mem_ctx, pw); +#if 0 + + /* + Look at a user on a real NT4 PDC with usrmgr, press + 'ok'. Then you will see that fields_present is set to + 0x08f827fa. Look at the user immediately after that again, + and you will see that 0x00fffff is returned. This solves + the problem that you get access denied after having looked + at the user. + -- Volker + */ + +#if 0 + init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob); + init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial); + data_blob_free(&munged_dial_blob); +#endif +#endif + + init_samr_user_info21(r, + last_logon, + last_logoff, + last_password_change, + acct_expiry, + allow_password_change, + force_password_change, + account_name, + full_name, + home_directory, + home_drive, + logon_script, + profile_path, + description, + workstations, + comment, + parameters, + rid, + primary_gid, + pdb_get_acct_ctrl(pw), + pdb_build_fields_present(pw), + logon_hours, + pdb_get_bad_password_count(pw), + pdb_get_logon_count(pw), + 0, //country_code, + 0, //code_page, + 0, //nt_password_set, + 0, //lm_password_set, + password_expired); + TALLOC_FREE(pw); + + return NT_STATUS_OK; } /******************************************************************* - _samr_query_userinfo + _samr_QueryUserInfo ********************************************************************/ -NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_R_QUERY_USERINFO *r_u) +NTSTATUS _samr_QueryUserInfo(pipes_struct *p, + struct samr_QueryUserInfo *r) { - SAM_USERINFO_CTR *ctr; + NTSTATUS status; + union samr_UserInfo *user_info = NULL; struct samr_info *info = NULL; DOM_SID domain_sid; uint32 rid; - r_u->status=NT_STATUS_OK; - /* search for the handle */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.user_handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; domain_sid = info->sid; @@ -2364,81 +2541,67 @@ NTSTATUS _samr_query_userinfo(pipes_struct *p, SAMR_Q_QUERY_USERINFO *q_u, SAMR_ if (!sid_check_is_in_our_domain(&info->sid)) return NT_STATUS_OBJECT_TYPE_MISMATCH; - DEBUG(5,("_samr_query_userinfo: sid:%s\n", + DEBUG(5,("_samr_QueryUserInfo: sid:%s\n", sid_string_dbg(&info->sid))); - ctr = TALLOC_ZERO_P(p->mem_ctx, SAM_USERINFO_CTR); - if (!ctr) + user_info = TALLOC_ZERO_P(p->mem_ctx, union samr_UserInfo); + if (!user_info) { return NT_STATUS_NO_MEMORY; + } - ZERO_STRUCTP(ctr); - - /* ok! user info levels (lots: see MSDEV help), off we go... */ - ctr->switch_value = q_u->switch_value; - - DEBUG(5,("_samr_query_userinfo: user info level: %d\n", q_u->switch_value)); + DEBUG(5,("_samr_QueryUserInfo: user info level: %d\n", r->in.level)); - switch (q_u->switch_value) { + switch (r->in.level) { case 7: - ctr->info.id7 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_7); - if (ctr->info.id7 == NULL) - return NT_STATUS_NO_MEMORY; - - if (!NT_STATUS_IS_OK(r_u->status = get_user_info_7(p->mem_ctx, ctr->info.id7, &info->sid))) - return r_u->status; + status = get_user_info_7(p->mem_ctx, &user_info->info7, &info->sid); + if (!NT_STATUS_IS_OK(status)) { + return status; + } break; case 9: - ctr->info.id9 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_9); - if (ctr->info.id9 == NULL) - return NT_STATUS_NO_MEMORY; - - if (!NT_STATUS_IS_OK(r_u->status = get_user_info_9(p->mem_ctx, ctr->info.id9, &info->sid))) - return r_u->status; + status = get_user_info_9(p->mem_ctx, &user_info->info9, &info->sid); + if (!NT_STATUS_IS_OK(status)) { + return status; + } break; case 16: - ctr->info.id16 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_16); - if (ctr->info.id16 == NULL) - return NT_STATUS_NO_MEMORY; - - if (!NT_STATUS_IS_OK(r_u->status = get_user_info_16(p->mem_ctx, ctr->info.id16, &info->sid))) - return r_u->status; + status = get_user_info_16(p->mem_ctx, &user_info->info16, &info->sid); + if (!NT_STATUS_IS_OK(status)) { + return status; + } break; case 18: - ctr->info.id18 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_18); - if (ctr->info.id18 == NULL) - return NT_STATUS_NO_MEMORY; - - if (!NT_STATUS_IS_OK(r_u->status = get_user_info_18(p, p->mem_ctx, ctr->info.id18, &info->sid))) - return r_u->status; + status = get_user_info_18(p, p->mem_ctx, &user_info->info18, &info->sid); + if (!NT_STATUS_IS_OK(status)) { + return status; + } break; case 20: - ctr->info.id20 = TALLOC_ZERO_P(p->mem_ctx,SAM_USER_INFO_20); - if (ctr->info.id20 == NULL) - return NT_STATUS_NO_MEMORY; - if (!NT_STATUS_IS_OK(r_u->status = get_user_info_20(p->mem_ctx, ctr->info.id20, &info->sid))) - return r_u->status; + status = get_user_info_20(p->mem_ctx, &user_info->info20, &info->sid); + if (!NT_STATUS_IS_OK(status)) { + return status; + } break; case 21: - ctr->info.id21 = TALLOC_ZERO_P(p->mem_ctx,SAM_USER_INFO_21); - if (ctr->info.id21 == NULL) - return NT_STATUS_NO_MEMORY; - if (!NT_STATUS_IS_OK(r_u->status = get_user_info_21(p->mem_ctx, ctr->info.id21, - &info->sid, &domain_sid))) - return r_u->status; + status = get_user_info_21(p->mem_ctx, &user_info->info21, + &info->sid, &domain_sid); + if (!NT_STATUS_IS_OK(status)) { + return status; + } break; default: return NT_STATUS_INVALID_INFO_CLASS; } - init_samr_r_query_userinfo(r_u, ctr, r_u->status); + *r->out.info = user_info; - DEBUG(5,("_samr_query_userinfo: %d\n", __LINE__)); + DEBUG(5,("_samr_QueryUserInfo: %d\n", __LINE__)); - return r_u->status; + return status; } /******************************************************************* @@ -5395,16 +5558,6 @@ NTSTATUS _samr_SetMemberAttributesOfGroup(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_QueryUserInfo(pipes_struct *p, - struct samr_QueryUserInfo *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_ChangePasswordUser(pipes_struct *p, struct samr_ChangePasswordUser *r) { -- cgit From 80d20d8e54cd3bddf9011d0281a8d6bcdffc369c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 12 Feb 2008 14:26:10 +0100 Subject: w00t! SAMR server-side conversion to pidl is finished. Guenther (This used to be commit c6d9650930510982ef4e4759272dba573fc81067) --- source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_samr.c | 565 ------------------------------------------ 2 files changed, 1 insertion(+), 566 deletions(-) delete mode 100644 source3/rpc_server/srv_samr.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 8c7c43f686..06694a2701 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2367,7 +2367,7 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) dssetup_get_pipe_fns( &cmds, &n_cmds ); break; case PI_SAMR: - samr2_get_pipe_fns( &cmds, &n_cmds ); + samr_get_pipe_fns( &cmds, &n_cmds ); break; case PI_NETLOGON: netlog_get_pipe_fns( &cmds, &n_cmds ); diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c deleted file mode 100644 index f7cc7eec10..0000000000 --- a/source3/rpc_server/srv_samr.c +++ /dev/null @@ -1,565 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997, - * Copyright (C) Marc Jacobsen 1999, - * Copyright (C) Jean François Micouleau 1998-2001, - * Copyright (C) Jim McDonough 2002-2003. - * - * Split into interface and implementation modules by, - * - * Copyright (C) Jeremy Allison 2001. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ - -/* - * This is the interface to the SAMR code. - */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -/******************************************************************* - ********************************************************************/ - -static bool proxy_samr_call(pipes_struct *p, uint8 opnum) -{ - struct api_struct *fns; - int n_fns; - - samr_get_pipe_fns(&fns, &n_fns); - - if (opnum >= n_fns) { - return false; - } - - if (fns[opnum].opnum != opnum) { - smb_panic("SAMR function table not sorted"); - } - - return fns[opnum].fn(p); -} - -/******************************************************************* - api_samr_close_hnd - ********************************************************************/ - -static bool api_samr_close_hnd(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_CLOSE); -} - -/******************************************************************* - api_samr_open_domain - ********************************************************************/ - -static bool api_samr_open_domain(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_OPENDOMAIN); -} - -/******************************************************************* - api_samr_get_usrdom_pwinfo - ********************************************************************/ - -static bool api_samr_get_usrdom_pwinfo(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_GETUSERPWINFO); -} - -/******************************************************************* - api_samr_set_sec_obj - ********************************************************************/ - -static bool api_samr_set_sec_obj(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_SETSECURITY); -} - -/******************************************************************* - api_samr_query_sec_obj - ********************************************************************/ - -static bool api_samr_query_sec_obj(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_QUERYSECURITY); -} - -/******************************************************************* - api_samr_enum_dom_users - ********************************************************************/ - -static bool api_samr_enum_dom_users(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_ENUMDOMAINUSERS); -} - -/******************************************************************* - api_samr_enum_dom_groups - ********************************************************************/ - -static bool api_samr_enum_dom_groups(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_ENUMDOMAINGROUPS); -} - -/******************************************************************* - api_samr_enum_dom_aliases - ********************************************************************/ - -static bool api_samr_enum_dom_aliases(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_ENUMDOMAINALIASES); -} - -/******************************************************************* - api_samr_query_dispinfo - ********************************************************************/ - -static bool api_samr_query_dispinfo(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_QUERYDISPLAYINFO); -} - -/******************************************************************* - api_samr_query_aliasinfo - ********************************************************************/ - -static bool api_samr_query_aliasinfo(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_QUERYALIASINFO); -} - -/******************************************************************* - api_samr_lookup_names - ********************************************************************/ - -static bool api_samr_lookup_names(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_LOOKUPNAMES); -} - -/******************************************************************* - api_samr_chgpasswd_user - ********************************************************************/ - -static bool api_samr_chgpasswd_user(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_CHANGEPASSWORDUSER2); -} - -/******************************************************************* - api_samr_lookup_rids - ********************************************************************/ - -static bool api_samr_lookup_rids(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_LOOKUPRIDS); -} - -/******************************************************************* - api_samr_open_user - ********************************************************************/ - -static bool api_samr_open_user(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_OPENUSER); -} - -/******************************************************************* - api_samr_query_userinfo - ********************************************************************/ - -static bool api_samr_query_userinfo(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_QUERYUSERINFO); -} - -/******************************************************************* - api_samr_query_usergroups - ********************************************************************/ - -static bool api_samr_query_usergroups(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_GETGROUPSFORUSER); -} - -/******************************************************************* - api_samr_query_domain_info - ********************************************************************/ - -static bool api_samr_query_domain_info(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_QUERYDOMAININFO); -} - -/******************************************************************* - api_samr_create_user - ********************************************************************/ - -static bool api_samr_create_user(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_CREATEUSER2); -} - -/******************************************************************* - api_samr_connect_anon - ********************************************************************/ - -static bool api_samr_connect_anon(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_CONNECT); -} - -/******************************************************************* - api_samr_connect - ********************************************************************/ - -static bool api_samr_connect(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_CONNECT2); -} - -/******************************************************************* - api_samr_connect4 - ********************************************************************/ - -static bool api_samr_connect4(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_CONNECT4); -} - -/******************************************************************* - api_samr_chgpasswd_user3 - ********************************************************************/ - -static bool api_samr_chgpasswd_user3(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_CHANGEPASSWORDUSER3); -} - -/******************************************************************* - api_samr_connect5 - ********************************************************************/ - -static bool api_samr_connect5(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_CONNECT5); -} - -/********************************************************************** - api_samr_lookup_domain - **********************************************************************/ - -static bool api_samr_lookup_domain(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_LOOKUPDOMAIN); -} - -/********************************************************************** - api_samr_enum_domains - **********************************************************************/ - -static bool api_samr_enum_domains(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_ENUMDOMAINS); -} - -/******************************************************************* - api_samr_open_alias - ********************************************************************/ - -static bool api_samr_open_alias(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_OPENALIAS); -} - -/******************************************************************* - api_samr_set_userinfo - ********************************************************************/ - -static bool api_samr_set_userinfo(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_SETUSERINFO); -} - -/******************************************************************* - api_samr_set_userinfo2 - ********************************************************************/ - -static bool api_samr_set_userinfo2(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_SETUSERINFO2); -} - -/******************************************************************* - api_samr_query_useraliases - ********************************************************************/ - -static bool api_samr_query_useraliases(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_GETALIASMEMBERSHIP); -} - -/******************************************************************* - api_samr_query_aliasmem - ********************************************************************/ - -static bool api_samr_query_aliasmem(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_GETMEMBERSINALIAS); -} - -/******************************************************************* - api_samr_query_groupmem - ********************************************************************/ - -static bool api_samr_query_groupmem(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_QUERYGROUPMEMBER); -} - -/******************************************************************* - api_samr_add_aliasmem - ********************************************************************/ - -static bool api_samr_add_aliasmem(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_ADDALIASMEMBER); -} - -/******************************************************************* - api_samr_del_aliasmem - ********************************************************************/ - -static bool api_samr_del_aliasmem(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_DELETEALIASMEMBER); -} - -/******************************************************************* - api_samr_add_groupmem - ********************************************************************/ - -static bool api_samr_add_groupmem(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_ADDGROUPMEMBER); -} - -/******************************************************************* - api_samr_del_groupmem - ********************************************************************/ - -static bool api_samr_del_groupmem(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_DELETEGROUPMEMBER); -} - -/******************************************************************* - api_samr_delete_dom_user - ********************************************************************/ - -static bool api_samr_delete_dom_user(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_DELETEUSER); -} - -/******************************************************************* - api_samr_delete_dom_group - ********************************************************************/ - -static bool api_samr_delete_dom_group(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_DELETEDOMAINGROUP); -} - -/******************************************************************* - api_samr_delete_dom_alias - ********************************************************************/ - -static bool api_samr_delete_dom_alias(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_DELETEDOMALIAS); -} - -/******************************************************************* - api_samr_create_dom_group - ********************************************************************/ - -static bool api_samr_create_dom_group(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_CREATEDOMAINGROUP); -} - -/******************************************************************* - api_samr_create_dom_alias - ********************************************************************/ - -static bool api_samr_create_dom_alias(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_CREATEDOMALIAS); -} - -/******************************************************************* - api_samr_query_groupinfo - ********************************************************************/ - -static bool api_samr_query_groupinfo(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_QUERYGROUPINFO); -} - -/******************************************************************* - api_samr_set_groupinfo - ********************************************************************/ - -static bool api_samr_set_groupinfo(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_SETGROUPINFO); -} - -/******************************************************************* - api_samr_set_aliasinfo - ********************************************************************/ - -static bool api_samr_set_aliasinfo(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_SETALIASINFO); -} - -/******************************************************************* - api_samr_get_dom_pwinfo - ********************************************************************/ - -static bool api_samr_get_dom_pwinfo(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_GETDOMPWINFO); -} - -/******************************************************************* - api_samr_open_group - ********************************************************************/ - -static bool api_samr_open_group(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_OPENGROUP); -} - -/******************************************************************* - api_samr_remove_sid_foreign_domain - ********************************************************************/ - -static bool api_samr_remove_sid_foreign_domain(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_REMOVEMEMBERFROMFOREIGNDOMAIN); -} - -/******************************************************************* - api_samr_query_dom_info2 - ********************************************************************/ - -static bool api_samr_query_domain_info2(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_QUERYDOMAININFO2); -} - -/******************************************************************* - api_samr_set_dom_info - ********************************************************************/ - -static bool api_samr_set_dom_info(pipes_struct *p) -{ - return proxy_samr_call(p, NDR_SAMR_SETDOMAININFO); -} - -/******************************************************************* - array of \PIPE\samr operations - ********************************************************************/ - -static struct api_struct api_samr_cmds [] = -{ - {"SAMR_CLOSE_HND" , SAMR_CLOSE_HND , api_samr_close_hnd }, - {"SAMR_CONNECT" , SAMR_CONNECT , api_samr_connect }, - {"SAMR_CONNECT_ANON" , SAMR_CONNECT_ANON , api_samr_connect_anon }, - {"SAMR_ENUM_DOMAINS" , SAMR_ENUM_DOMAINS , api_samr_enum_domains }, - {"SAMR_ENUM_DOM_USERS" , SAMR_ENUM_DOM_USERS , api_samr_enum_dom_users }, - - {"SAMR_ENUM_DOM_GROUPS" , SAMR_ENUM_DOM_GROUPS , api_samr_enum_dom_groups }, - {"SAMR_ENUM_DOM_ALIASES" , SAMR_ENUM_DOM_ALIASES , api_samr_enum_dom_aliases }, - {"SAMR_QUERY_USERALIASES" , SAMR_QUERY_USERALIASES, api_samr_query_useraliases}, - {"SAMR_QUERY_ALIASMEM" , SAMR_QUERY_ALIASMEM , api_samr_query_aliasmem }, - {"SAMR_QUERY_GROUPMEM" , SAMR_QUERY_GROUPMEM , api_samr_query_groupmem }, - {"SAMR_ADD_ALIASMEM" , SAMR_ADD_ALIASMEM , api_samr_add_aliasmem }, - {"SAMR_DEL_ALIASMEM" , SAMR_DEL_ALIASMEM , api_samr_del_aliasmem }, - {"SAMR_ADD_GROUPMEM" , SAMR_ADD_GROUPMEM , api_samr_add_groupmem }, - {"SAMR_DEL_GROUPMEM" , SAMR_DEL_GROUPMEM , api_samr_del_groupmem }, - - {"SAMR_DELETE_DOM_USER" , SAMR_DELETE_DOM_USER , api_samr_delete_dom_user }, - {"SAMR_DELETE_DOM_GROUP" , SAMR_DELETE_DOM_GROUP , api_samr_delete_dom_group }, - {"SAMR_DELETE_DOM_ALIAS" , SAMR_DELETE_DOM_ALIAS , api_samr_delete_dom_alias }, - {"SAMR_CREATE_DOM_GROUP" , SAMR_CREATE_DOM_GROUP , api_samr_create_dom_group }, - {"SAMR_CREATE_DOM_ALIAS" , SAMR_CREATE_DOM_ALIAS , api_samr_create_dom_alias }, - {"SAMR_LOOKUP_NAMES" , SAMR_LOOKUP_NAMES , api_samr_lookup_names }, - {"SAMR_OPEN_USER" , SAMR_OPEN_USER , api_samr_open_user }, - {"SAMR_QUERY_USERINFO" , SAMR_QUERY_USERINFO , api_samr_query_userinfo }, - {"SAMR_SET_USERINFO" , SAMR_SET_USERINFO , api_samr_set_userinfo }, - {"SAMR_SET_USERINFO2" , SAMR_SET_USERINFO2 , api_samr_set_userinfo2 }, - - {"SAMR_QUERY_DOMAIN_INFO" , SAMR_QUERY_DOMAIN_INFO, api_samr_query_domain_info}, - {"SAMR_QUERY_USERGROUPS" , SAMR_QUERY_USERGROUPS , api_samr_query_usergroups }, - {"SAMR_QUERY_DISPINFO" , SAMR_QUERY_DISPINFO , api_samr_query_dispinfo }, - {"SAMR_QUERY_DISPINFO3" , SAMR_QUERY_DISPINFO3 , api_samr_query_dispinfo }, - {"SAMR_QUERY_DISPINFO4" , SAMR_QUERY_DISPINFO4 , api_samr_query_dispinfo }, - - {"SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo }, - {"SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo }, - {"SAMR_SET_GROUPINFO" , SAMR_SET_GROUPINFO , api_samr_set_groupinfo }, - {"SAMR_SET_ALIASINFO" , SAMR_SET_ALIASINFO , api_samr_set_aliasinfo }, - {"SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user }, - {"SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids }, - {"SAMR_GET_DOM_PWINFO" , SAMR_GET_DOM_PWINFO , api_samr_get_dom_pwinfo }, - {"SAMR_CHGPASSWD_USER" , SAMR_CHGPASSWD_USER , api_samr_chgpasswd_user }, - {"SAMR_OPEN_ALIAS" , SAMR_OPEN_ALIAS , api_samr_open_alias }, - {"SAMR_OPEN_GROUP" , SAMR_OPEN_GROUP , api_samr_open_group }, - {"SAMR_OPEN_DOMAIN" , SAMR_OPEN_DOMAIN , api_samr_open_domain }, - {"SAMR_REMOVE_SID_FOREIGN_DOMAIN" , SAMR_REMOVE_SID_FOREIGN_DOMAIN , api_samr_remove_sid_foreign_domain }, - {"SAMR_LOOKUP_DOMAIN" , SAMR_LOOKUP_DOMAIN , api_samr_lookup_domain }, - - {"SAMR_QUERY_SEC_OBJECT" , SAMR_QUERY_SEC_OBJECT , api_samr_query_sec_obj }, - {"SAMR_SET_SEC_OBJECT" , SAMR_SET_SEC_OBJECT , api_samr_set_sec_obj }, - {"SAMR_GET_USRDOM_PWINFO" , SAMR_GET_USRDOM_PWINFO, api_samr_get_usrdom_pwinfo}, - {"SAMR_QUERY_DOMAIN_INFO2", SAMR_QUERY_DOMAIN_INFO2, api_samr_query_domain_info2}, - {"SAMR_SET_DOMAIN_INFO" , SAMR_SET_DOMAIN_INFO , api_samr_set_dom_info }, - {"SAMR_CONNECT4" , SAMR_CONNECT4 , api_samr_connect4 }, - {"SAMR_CHGPASSWD_USER3" , SAMR_CHGPASSWD_USER3 , api_samr_chgpasswd_user3 }, - {"SAMR_CONNECT5" , SAMR_CONNECT5 , api_samr_connect5 } -}; - -void samr2_get_pipe_fns( struct api_struct **fns, int *n_fns ) -{ - *fns = api_samr_cmds; - *n_fns = sizeof(api_samr_cmds) / sizeof(struct api_struct); -} - - -NTSTATUS rpc_samr2_init(void) -{ - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "samr", "lsass", api_samr_cmds, - sizeof(api_samr_cmds) / sizeof(struct api_struct)); -} -- cgit From befc71c942c044c9edc31d166f7b2ad6630fdb7c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 12 Feb 2008 16:39:02 +0100 Subject: Re-add support for samr_QueryDisplayInfo2/samr_QueryDisplayInfo3. (This used to be commit cac740d87f729c1b48654ef4f51f37a81e8a0d54) --- source3/rpc_server/srv_samr_nt.c | 64 +++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index ac10754493..3e88f24ea2 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1586,6 +1586,50 @@ NTSTATUS _samr_QueryDisplayInfo(pipes_struct *p, return status; } +/**************************************************************** + _samr_QueryDisplayInfo2 +****************************************************************/ + +NTSTATUS _samr_QueryDisplayInfo2(pipes_struct *p, + struct samr_QueryDisplayInfo2 *r) +{ + struct samr_QueryDisplayInfo q; + + q.in.domain_handle = r->in.domain_handle; + q.in.level = r->in.level; + q.in.start_idx = r->in.start_idx; + q.in.max_entries = r->in.max_entries; + q.in.buf_size = r->in.buf_size; + + q.out.total_size = r->out.total_size; + q.out.returned_size = r->out.returned_size; + q.out.info = r->out.info; + + return _samr_QueryDisplayInfo(p, &q); +} + +/**************************************************************** + _samr_QueryDisplayInfo3 +****************************************************************/ + +NTSTATUS _samr_QueryDisplayInfo3(pipes_struct *p, + struct samr_QueryDisplayInfo3 *r) +{ + struct samr_QueryDisplayInfo q; + + q.in.domain_handle = r->in.domain_handle; + q.in.level = r->in.level; + q.in.start_idx = r->in.start_idx; + q.in.max_entries = r->in.max_entries; + q.in.buf_size = r->in.buf_size; + + q.out.total_size = r->out.total_size; + q.out.returned_size = r->out.returned_size; + q.out.info = r->out.info; + + return _samr_QueryDisplayInfo(p, &q); +} + /******************************************************************* _samr_QueryAliasInfo ********************************************************************/ @@ -5608,16 +5652,6 @@ NTSTATUS _samr_QueryUserInfo2(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_QueryDisplayInfo2(pipes_struct *p, - struct samr_QueryDisplayInfo2 *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_GetDisplayEnumerationIndex2(pipes_struct *p, struct samr_GetDisplayEnumerationIndex2 *r) { @@ -5628,16 +5662,6 @@ NTSTATUS _samr_GetDisplayEnumerationIndex2(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_QueryDisplayInfo3(pipes_struct *p, - struct samr_QueryDisplayInfo3 *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_AddMultipleMembersToAlias(pipes_struct *p, struct samr_AddMultipleMembersToAlias *r) { -- cgit From e2b3aad8174daede0248ce96df624e575867cfd8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 12 Feb 2008 22:05:39 +0100 Subject: Collect all init_lsa_string varients in one place. Guenther (This used to be commit f4581e9f4482566fba9436d5ae058b8d840fa394) --- source3/rpc_server/srv_lsa_nt.c | 14 -------------- source3/rpc_server/srv_samr_nt.c | 18 ------------------ 2 files changed, 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 769dd8ad57..8041424627 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -46,20 +46,6 @@ const struct generic_mapping lsa_generic_mapping = { POLICY_ALL_ACCESS }; -/******************************************************************* - inits a structure. -********************************************************************/ - -static void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s) -{ - name->string = s; -} - -static void init_lsa_String(struct lsa_String *name, const char *s) -{ - name->string = s; -} - /******************************************************************* Function to free the per handle data. ********************************************************************/ diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 3e88f24ea2..3637560a7f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -103,15 +103,6 @@ static const struct generic_mapping ali_generic_mapping = { GENERIC_RIGHTS_ALIAS_EXECUTE, GENERIC_RIGHTS_ALIAS_ALL_ACCESS}; -/******************************************************************* - inits a structure. -********************************************************************/ - -static void init_lsa_String(struct lsa_String *name, const char *s) -{ - name->string = s; -} - /******************************************************************* *******************************************************************/ @@ -1171,15 +1162,6 @@ NTSTATUS _samr_EnumDomainAliases(pipes_struct *p, return status; } -/******************************************************************* - inits a structure. -********************************************************************/ - -static void init_lsa_AsciiString(struct lsa_AsciiString *name, const char *s) -{ - name->string = s; -} - /******************************************************************* inits a samr_DispInfoGeneral structure. ********************************************************************/ -- cgit From f57c67b8f3e75a9aa50c24ff892b12b530de6a38 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 00:02:21 +0100 Subject: Use pidl for _lsa_EnumTrustDom() Guenther (This used to be commit 1f45079907d03116b48b55d616281ed4359a66d8) --- source3/rpc_server/srv_lsa.c | 21 +---------------- source3/rpc_server/srv_lsa_nt.c | 52 ++++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 42 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 9865a70e72..f48a397f1d 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -70,26 +70,7 @@ static bool api_lsa_open_policy(pipes_struct *p) static bool api_lsa_enum_trust_dom(pipes_struct *p) { - LSA_Q_ENUM_TRUST_DOM q_u; - LSA_R_ENUM_TRUST_DOM r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the enum trust domain context etc. */ - if(!lsa_io_q_enum_trust_dom("", &q_u, data, 0)) - return False; - - /* get required trusted domains information */ - r_u.status = _lsa_enum_trust_dom(p, &q_u, &r_u); - - /* prepare the response */ - if(!lsa_io_r_enum_trust_dom("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_lsa_call(p, NDR_LSA_ENUMTRUSTDOM); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 8041424627..3cf83962ee 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -592,16 +592,18 @@ NTSTATUS _lsa_OpenPolicy(pipes_struct *p, } /*************************************************************************** - _lsa_enum_trust_dom - this needs fixing to do more than return NULL ! JRA. + _lsa_EnumTrustDom - this needs fixing to do more than return NULL ! JRA. ufff, done :) mimir ***************************************************************************/ -NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, - LSA_R_ENUM_TRUST_DOM *r_u) +NTSTATUS _lsa_EnumTrustDom(pipes_struct *p, + struct lsa_EnumTrustDom *r) { struct lsa_info *info; uint32 next_idx; struct trustdom_info **domains; + struct lsa_DomainInfo *lsa_domains = NULL; + int i; /* * preferred length is set to 5 as a "our" preferred length @@ -610,12 +612,12 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, * it needs further investigation how to optimally choose this value */ uint32 max_num_domains = - q_u->preferred_len < 5 ? q_u->preferred_len : 10; + r->in.max_size < 5 ? r->in.max_size : 10; uint32 num_domains; NTSTATUS nt_status; uint32 num_thistime; - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ @@ -628,29 +630,41 @@ NTSTATUS _lsa_enum_trust_dom(pipes_struct *p, LSA_Q_ENUM_TRUST_DOM *q_u, return nt_status; } - if (q_u->enum_context < num_domains) { + if (*r->in.resume_handle < num_domains) { num_thistime = MIN(num_domains, max_num_domains); - r_u->status = STATUS_MORE_ENTRIES; + nt_status = STATUS_MORE_ENTRIES; - if (q_u->enum_context + num_thistime > num_domains) { - num_thistime = num_domains - q_u->enum_context; - r_u->status = NT_STATUS_OK; + if (*r->in.resume_handle + num_thistime > num_domains) { + num_thistime = num_domains - *r->in.resume_handle; + nt_status = NT_STATUS_OK; } - next_idx = q_u->enum_context + num_thistime; + next_idx = *r->in.resume_handle + num_thistime; } else { num_thistime = 0; next_idx = 0xffffffff; - r_u->status = NT_STATUS_NO_MORE_ENTRIES; + nt_status = NT_STATUS_NO_MORE_ENTRIES; } - + /* set up the lsa_enum_trust_dom response */ - init_r_enum_trust_dom(p->mem_ctx, r_u, next_idx, - num_thistime, domains+q_u->enum_context); + lsa_domains = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_DomainInfo, + num_thistime); + if (!lsa_domains) { + return NT_STATUS_NO_MEMORY; + } - return r_u->status; + for (i=0; iname); + lsa_domains[i].sid = &domains[i]->sid; + } + + *r->out.resume_handle = next_idx; + r->out.domains->count = num_thistime; + r->out.domains->domains = lsa_domains; + + return nt_status; } /*************************************************************************** @@ -2222,12 +2236,6 @@ NTSTATUS _lsa_EnumAccounts(pipes_struct *p, struct lsa_EnumAccounts *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumTrustDom(pipes_struct *p, struct lsa_EnumTrustDom *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_LookupNames(pipes_struct *p, struct lsa_LookupNames *r) { p->rng_fault_state = True; -- cgit From a6997bb2ffbca8f38d40f2631066c23b0472e13c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 12 Feb 2008 17:21:17 -0800 Subject: Prevent "parameters" being used without initialization. Jeremy. (This used to be commit f0195e937d5d42a8d92e9d861199538fd44a3c9b) --- source3/rpc_server/srv_samr_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 3637560a7f..0db74c2a1b 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2476,6 +2476,8 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, TALLOC_FREE(pw); return NT_STATUS_NO_MEMORY; } + } else { + parameters = NULL; } -- cgit From b462e92b2a3703d9caa7121edeb52253f18b2c0c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 12 Feb 2008 23:30:44 +0100 Subject: Some minor, cosmetic cleanup in srv_samr_util.c. Guenther (This used to be commit cd5bf3449adee7537ae6ca4e3b398e99d34555fd) --- source3/rpc_server/srv_samr_util.c | 166 ++++++++++++++++++++++++------------- 1 file changed, 108 insertions(+), 58 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index cc08d5337b..364adbc0de 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -56,9 +56,11 @@ void copy_id20_to_sam_passwd(struct samu *to, mung.free = NULL; new_string = (mung.length == 0) ? NULL : base64_encode_data_blob(talloc_tos(), mung); - DEBUG(10,("INFO_20 PARAMETERS: %s -> %s\n",old_string, new_string)); - if (STRING_CHANGED_NC(old_string,new_string)) - pdb_set_munged_dial(to , new_string, PDB_CHANGED); + DEBUG(10,("INFO_20 PARAMETERS: %s -> %s\n", + old_string, new_string)); + if (STRING_CHANGED_NC(old_string,new_string)) { + pdb_set_munged_dial(to, new_string, PDB_CHANGED); + } TALLOC_FREE(new_string); } @@ -88,116 +90,146 @@ void copy_id21_to_sam_passwd(const char *log_prefix, } if (from->fields_present & SAMR_FIELD_LAST_LOGON) { - unix_time=nt_time_to_unix(from->last_logon); + unix_time = nt_time_to_unix(from->last_logon); stored_time = pdb_get_logon_time(to); - DEBUG(10,("%s SAMR_FIELD_LAST_LOGON: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + DEBUG(10,("%s SAMR_FIELD_LAST_LOGON: %lu -> %lu\n", l, + (long unsigned int)stored_time, + (long unsigned int)unix_time)); + if (stored_time != unix_time) { pdb_set_logon_time(to, unix_time, PDB_CHANGED); + } } if (from->fields_present & SAMR_FIELD_LAST_LOGOFF) { - unix_time=nt_time_to_unix(from->last_logoff); + unix_time = nt_time_to_unix(from->last_logoff); stored_time = pdb_get_logoff_time(to); - DEBUG(10,("%s SAMR_FIELD_LAST_LOGOFF: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + DEBUG(10,("%s SAMR_FIELD_LAST_LOGOFF: %lu -> %lu\n", l, + (long unsigned int)stored_time, + (long unsigned int)unix_time)); + if (stored_time != unix_time) { pdb_set_logoff_time(to, unix_time, PDB_CHANGED); + } } if (from->fields_present & SAMR_FIELD_ACCT_EXPIRY) { - unix_time=nt_time_to_unix(from->acct_expiry); + unix_time = nt_time_to_unix(from->acct_expiry); stored_time = pdb_get_kickoff_time(to); - DEBUG(10,("%s SAMR_FIELD_ACCT_EXPIRY: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + DEBUG(10,("%s SAMR_FIELD_ACCT_EXPIRY: %lu -> %lu\n", l, + (long unsigned int)stored_time, + (long unsigned int)unix_time)); + if (stored_time != unix_time) { pdb_set_kickoff_time(to, unix_time , PDB_CHANGED); + } } if (from->fields_present & SAMR_FIELD_LAST_PWD_CHANGE) { - unix_time=nt_time_to_unix(from->last_password_change); + unix_time = nt_time_to_unix(from->last_password_change); stored_time = pdb_get_pass_last_set_time(to); - DEBUG(10,("%s SAMR_FIELD_LAST_PWD_CHANGE: %lu -> %lu\n", l, (long unsigned int)stored_time, (long unsigned int)unix_time)); - if (stored_time != unix_time) + DEBUG(10,("%s SAMR_FIELD_LAST_PWD_CHANGE: %lu -> %lu\n", l, + (long unsigned int)stored_time, + (long unsigned int)unix_time)); + if (stored_time != unix_time) { pdb_set_pass_last_set_time(to, unix_time, PDB_CHANGED); + } } if ((from->fields_present & SAMR_FIELD_ACCOUNT_NAME) && (from->account_name.string)) { old_string = pdb_get_username(to); new_string = from->account_name.string; - DEBUG(10,("%s SAMR_FIELD_ACCOUNT_NAME: %s -> %s\n", l, old_string, new_string)); - if (STRING_CHANGED) - pdb_set_username(to , new_string, PDB_CHANGED); + DEBUG(10,("%s SAMR_FIELD_ACCOUNT_NAME: %s -> %s\n", l, + old_string, new_string)); + if (STRING_CHANGED) { + pdb_set_username(to, new_string, PDB_CHANGED); + } } if ((from->fields_present & SAMR_FIELD_FULL_NAME) && (from->full_name.string)) { old_string = pdb_get_fullname(to); new_string = from->full_name.string; - DEBUG(10,("%s SAMR_FIELD_FULL_NAME: %s -> %s\n", l, old_string, new_string)); - if (STRING_CHANGED) - pdb_set_fullname(to , new_string, PDB_CHANGED); + DEBUG(10,("%s SAMR_FIELD_FULL_NAME: %s -> %s\n", l, + old_string, new_string)); + if (STRING_CHANGED) { + pdb_set_fullname(to, new_string, PDB_CHANGED); + } } if ((from->fields_present & SAMR_FIELD_HOME_DIRECTORY) && (from->home_directory.string)) { old_string = pdb_get_homedir(to); new_string = from->home_directory.string; - DEBUG(10,("%s SAMR_FIELD_HOME_DIRECTORY: %s -> %s\n", l, old_string, new_string)); - if (STRING_CHANGED) - pdb_set_homedir(to , new_string, PDB_CHANGED); + DEBUG(10,("%s SAMR_FIELD_HOME_DIRECTORY: %s -> %s\n", l, + old_string, new_string)); + if (STRING_CHANGED) { + pdb_set_homedir(to, new_string, PDB_CHANGED); + } } if ((from->fields_present & SAMR_FIELD_HOME_DRIVE) && (from->home_drive.string)) { old_string = pdb_get_dir_drive(to); new_string = from->home_drive.string; - DEBUG(10,("%s SAMR_FIELD_HOME_DRIVE: %s -> %s\n", l, old_string, new_string)); - if (STRING_CHANGED) - pdb_set_dir_drive(to , new_string, PDB_CHANGED); + DEBUG(10,("%s SAMR_FIELD_HOME_DRIVE: %s -> %s\n", l, + old_string, new_string)); + if (STRING_CHANGED) { + pdb_set_dir_drive(to, new_string, PDB_CHANGED); + } } if ((from->fields_present & SAMR_FIELD_LOGON_SCRIPT) && (from->logon_script.string)) { old_string = pdb_get_logon_script(to); new_string = from->logon_script.string; - DEBUG(10,("%s SAMR_FIELD_LOGON_SCRIPT: %s -> %s\n", l, old_string, new_string)); - if (STRING_CHANGED) + DEBUG(10,("%s SAMR_FIELD_LOGON_SCRIPT: %s -> %s\n", l, + old_string, new_string)); + if (STRING_CHANGED) { pdb_set_logon_script(to , new_string, PDB_CHANGED); + } } if ((from->fields_present & SAMR_FIELD_PROFILE_PATH) && (from->profile_path.string)) { old_string = pdb_get_profile_path(to); new_string = from->profile_path.string; - DEBUG(10,("%s SAMR_FIELD_PROFILE_PATH: %s -> %s\n", l, old_string, new_string)); - if (STRING_CHANGED) + DEBUG(10,("%s SAMR_FIELD_PROFILE_PATH: %s -> %s\n", l, + old_string, new_string)); + if (STRING_CHANGED) { pdb_set_profile_path(to , new_string, PDB_CHANGED); + } } if ((from->fields_present & SAMR_FIELD_DESCRIPTION) && (from->description.string)) { old_string = pdb_get_acct_desc(to); new_string = from->description.string; - DEBUG(10,("%s SAMR_FIELD_DESCRIPTION: %s -> %s\n", l, old_string, new_string)); - if (STRING_CHANGED) - pdb_set_acct_desc(to , new_string, PDB_CHANGED); + DEBUG(10,("%s SAMR_FIELD_DESCRIPTION: %s -> %s\n", l, + old_string, new_string)); + if (STRING_CHANGED) { + pdb_set_acct_desc(to, new_string, PDB_CHANGED); + } } if ((from->fields_present & SAMR_FIELD_WORKSTATIONS) && (from->workstations.string)) { old_string = pdb_get_workstations(to); new_string = from->workstations.string; - DEBUG(10,("%s SAMR_FIELD_WORKSTATIONS: %s -> %s\n", l, old_string, new_string)); - if (STRING_CHANGED) + DEBUG(10,("%s SAMR_FIELD_WORKSTATIONS: %s -> %s\n", l, + old_string, new_string)); + if (STRING_CHANGED) { pdb_set_workstations(to , new_string, PDB_CHANGED); + } } if ((from->fields_present & SAMR_FIELD_COMMENT) && (from->comment.string)) { old_string = pdb_get_comment(to); new_string = from->comment.string; - DEBUG(10,("%s SAMR_FIELD_COMMENT: %s -> %s\n", l, old_string, new_string)); - if (STRING_CHANGED) + DEBUG(10,("%s SAMR_FIELD_COMMENT: %s -> %s\n", l, + old_string, new_string)); + if (STRING_CHANGED) { pdb_set_comment(to, new_string, PDB_CHANGED); + } } if ((from->fields_present & SAMR_FIELD_PARAMETERS) && @@ -209,34 +241,41 @@ void copy_id21_to_sam_passwd(const char *log_prefix, mung.free = NULL; newstr = (mung.length == 0) ? NULL : base64_encode_data_blob(talloc_tos(), mung); - DEBUG(10,("%s SAMR_FIELD_PARAMETERS: %s -> %s\n", l, old_string, newstr)); - if (STRING_CHANGED_NC(old_string,newstr)) - pdb_set_munged_dial(to , newstr, PDB_CHANGED); + DEBUG(10,("%s SAMR_FIELD_PARAMETERS: %s -> %s\n", l, + old_string, newstr)); + if (STRING_CHANGED_NC(old_string,newstr)) { + pdb_set_munged_dial(to, newstr, PDB_CHANGED); + } TALLOC_FREE(newstr); } if (from->fields_present & SAMR_FIELD_RID) { if (from->rid == 0) { - DEBUG(10, ("%s: Asked to set User RID to 0 !? Skipping change!\n", l)); + DEBUG(10,("%s: Asked to set User RID to 0 !? Skipping change!\n", l)); } else if (from->rid != pdb_get_user_rid(to)) { - DEBUG(10,("%s SAMR_FIELD_RID: %u -> %u NOT UPDATED!\n", l, pdb_get_user_rid(to), from->rid)); + DEBUG(10,("%s SAMR_FIELD_RID: %u -> %u NOT UPDATED!\n", l, + pdb_get_user_rid(to), from->rid)); } } if (from->fields_present & SAMR_FIELD_PRIMARY_GID) { if (from->primary_gid == 0) { - DEBUG(10, ("%s: Asked to set Group RID to 0 !? Skipping change!\n", l)); + DEBUG(10,("%s: Asked to set Group RID to 0 !? Skipping change!\n", l)); } else if (from->primary_gid != pdb_get_group_rid(to)) { - DEBUG(10,("%s SAMR_FIELD_PRIMARY_GID: %u -> %u\n", l, pdb_get_group_rid(to), from->primary_gid)); - pdb_set_group_sid_from_rid(to, from->primary_gid, PDB_CHANGED); + DEBUG(10,("%s SAMR_FIELD_PRIMARY_GID: %u -> %u\n", l, + pdb_get_group_rid(to), from->primary_gid)); + pdb_set_group_sid_from_rid(to, + from->primary_gid, PDB_CHANGED); } } if (from->fields_present & SAMR_FIELD_ACCT_FLAGS) { - DEBUG(10,("%s SAMR_FIELD_ACCT_FLAGS: %08X -> %08X\n", l, pdb_get_acct_ctrl(to), from->acct_flags)); + DEBUG(10,("%s SAMR_FIELD_ACCT_FLAGS: %08X -> %08X\n", l, + pdb_get_acct_ctrl(to), from->acct_flags)); if (from->acct_flags != pdb_get_acct_ctrl(to)) { - if (!(from->acct_flags & ACB_AUTOLOCK) && (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) { + if (!(from->acct_flags & ACB_AUTOLOCK) && + (pdb_get_acct_ctrl(to) & ACB_AUTOLOCK)) { /* We're unlocking a previously locked user. Reset bad password counts. Patch from Jianliang Lu. */ pdb_set_bad_password_count(to, 0, PDB_CHANGED); @@ -249,17 +288,23 @@ void copy_id21_to_sam_passwd(const char *log_prefix, if (from->fields_present & SAMR_FIELD_LOGON_HOURS) { char oldstr[44]; /* hours strings are 42 bytes. */ char newstr[44]; - DEBUG(15,("%s SAMR_FIELD_LOGON_HOURS (units_per_week): %08X -> %08X\n", l, pdb_get_logon_divs(to), from->logon_hours.units_per_week)); + DEBUG(15,("%s SAMR_FIELD_LOGON_HOURS (units_per_week): %08X -> %08X\n", l, + pdb_get_logon_divs(to), from->logon_hours.units_per_week)); if (from->logon_hours.units_per_week != pdb_get_logon_divs(to)) { - pdb_set_logon_divs(to, from->logon_hours.units_per_week, PDB_CHANGED); + pdb_set_logon_divs(to, + from->logon_hours.units_per_week, PDB_CHANGED); } - DEBUG(15,("%s SAMR_FIELD_LOGON_HOURS (units_per_week/8): %08X -> %08X\n", l, pdb_get_hours_len(to), from->logon_hours.units_per_week/8)); + DEBUG(15,("%s SAMR_FIELD_LOGON_HOURS (units_per_week/8): %08X -> %08X\n", l, + pdb_get_hours_len(to), + from->logon_hours.units_per_week/8)); if (from->logon_hours.units_per_week/8 != pdb_get_hours_len(to)) { - pdb_set_hours_len(to, from->logon_hours.units_per_week/8, PDB_CHANGED); + pdb_set_hours_len(to, + from->logon_hours.units_per_week/8, PDB_CHANGED); } - DEBUG(15,("%s SAMR_FIELD_LOGON_HOURS (bits): %s -> %s\n", l, pdb_get_hours(to), from->logon_hours.bits)); + DEBUG(15,("%s SAMR_FIELD_LOGON_HOURS (bits): %s -> %s\n", l, + pdb_get_hours(to), from->logon_hours.bits)); pdb_sethexhours(oldstr, pdb_get_hours(to)); pdb_sethexhours(newstr, from->logon_hours.bits); if (!strequal(oldstr, newstr)) { @@ -268,14 +313,17 @@ void copy_id21_to_sam_passwd(const char *log_prefix, } if (from->fields_present & SAMR_FIELD_BAD_PWD_COUNT) { - DEBUG(10,("%s SAMR_FIELD_BAD_PWD_COUNT: %08X -> %08X\n", l, pdb_get_bad_password_count(to), from->bad_password_count)); + DEBUG(10,("%s SAMR_FIELD_BAD_PWD_COUNT: %08X -> %08X\n", l, + pdb_get_bad_password_count(to), from->bad_password_count)); if (from->bad_password_count != pdb_get_bad_password_count(to)) { - pdb_set_bad_password_count(to, from->bad_password_count, PDB_CHANGED); + pdb_set_bad_password_count(to, + from->bad_password_count, PDB_CHANGED); } } if (from->fields_present & SAMR_FIELD_NUM_LOGONS) { - DEBUG(10,("%s SAMR_FIELD_NUM_LOGONS: %08X -> %08X\n", l, pdb_get_logon_count(to), from->logon_count)); + DEBUG(10,("%s SAMR_FIELD_NUM_LOGONS: %08X -> %08X\n", l, + pdb_get_logon_count(to), from->logon_count)); if (from->logon_count != pdb_get_logon_count(to)) { pdb_set_logon_count(to, from->logon_count, PDB_CHANGED); } @@ -286,7 +334,8 @@ void copy_id21_to_sam_passwd(const char *log_prefix, calculated from policy, not set from the wire */ if (from->fields_present & SAMR_FIELD_EXPIRED_FLAG) { - DEBUG(10,("%s SAMR_FIELD_EXPIRED_FLAG: %02X\n", l, from->password_expired)); + DEBUG(10,("%s SAMR_FIELD_EXPIRED_FLAG: %02X\n", l, + from->password_expired)); if (from->password_expired == PASS_MUST_CHANGE_AT_NEXT_LOGON) { pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); } else { @@ -303,8 +352,9 @@ void copy_id21_to_sam_passwd(const char *log_prefix, void copy_id23_to_sam_passwd(struct samu *to, struct samr_UserInfo23 *from) { - if (from == NULL || to == NULL) + if (from == NULL || to == NULL) { return; + } copy_id21_to_sam_passwd("INFO 23", to, &from->info); } -- cgit From 3b45ebb1b7dd384b4adc7c9ab6102ce543f643f2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 10:23:45 +0100 Subject: Use pidl for _netr_NetrEnumerateTrustedDomains(). This call is completely broken. For now, just make sure that we return the exact same data as before the conversion to pidl. Guenther (This used to be commit 243bdaeea7900ab6a65edfda877e8c225ec7b213) --- source3/rpc_server/srv_netlog.c | 46 ++++++++++++++++++-------------------- source3/rpc_server/srv_netlog_nt.c | 32 ++++++++++++-------------- 2 files changed, 36 insertions(+), 42 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 30ef02bee8..4f0a0142e5 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -28,6 +28,27 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +/******************************************************************* + ********************************************************************/ + +static bool proxy_netr_call(pipes_struct *p, uint8 opnum) +{ + struct api_struct *fns; + int n_fns; + + netlogon_get_pipe_fns(&fns, &n_fns); + + if (opnum >= n_fns) { + return false; + } + + if (fns[opnum].opnum != opnum) { + smb_panic("NETLOGON function table not sorted"); + } + + return fns[opnum].fn(p); +} + /************************************************************************* api_net_req_chal: *************************************************************************/ @@ -218,30 +239,7 @@ static bool api_net_sam_logon(pipes_struct *p) static bool api_net_trust_dom_list(pipes_struct *p) { - NET_Q_TRUST_DOM_LIST q_u; - NET_R_TRUST_DOM_LIST r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the lsa trusted domain list query... */ - if(!net_io_q_trust_dom("", &q_u, data, 0)) { - DEBUG(0,("api_net_trust_dom_list: Failed to unmarshall NET_Q_TRUST_DOM_LIST.\n")); - return False; - } - - /* construct reply. */ - r_u.status = _net_trust_dom_list(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_trust_dom("", &r_u, rdata, 0)) { - DEBUG(0,("net_reply_trust_dom_list: Failed to marshall NET_R_TRUST_DOM_LIST.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_NETRENUMERATETRUSTEDDOMAINS); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 3a7075ecd6..528a33915a 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -145,22 +145,28 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C } /************************************************************************* - net_reply_trust_dom_list: + _netr_NetrEnumerateTrustedDomains *************************************************************************/ -NTSTATUS _net_trust_dom_list(pipes_struct *p, NET_Q_TRUST_DOM_LIST *q_u, NET_R_TRUST_DOM_LIST *r_u) +WERROR _netr_NetrEnumerateTrustedDomains(pipes_struct *p, + struct netr_NetrEnumerateTrustedDomains *r) { - const char *trusted_domain = "test_domain"; - uint32 num_trust_domains = 1; + struct netr_Blob trusted_domains_blob; + DATA_BLOB blob; - DEBUG(6,("_net_trust_dom_list: %d\n", __LINE__)); + DEBUG(6,("_netr_NetrEnumerateTrustedDomains: %d\n", __LINE__)); /* set up the Trusted Domain List response */ - init_r_trust_dom(r_u, num_trust_domains, trusted_domain); - DEBUG(6,("_net_trust_dom_list: %d\n", __LINE__)); + blob = data_blob_talloc_zero(p->mem_ctx, 2); + trusted_domains_blob.data = blob.data; + trusted_domains_blob.length = blob.length; - return r_u->status; + DEBUG(6,("_netr_NetrEnumerateTrustedDomains: %d\n", __LINE__)); + + *r->out.trusted_domains_blob = trusted_domains_blob; + + return WERR_OK; } /*********************************************************************************** @@ -1331,16 +1337,6 @@ WERROR _netr_LogonControl2Ex(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _netr_NetrEnumerateTrustedDomains(pipes_struct *p, - struct netr_NetrEnumerateTrustedDomains *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _netr_DsRGetDCName(pipes_struct *p, struct netr_DsRGetDCName *r) { -- cgit From abba82ef5b81f065169bf0ec78494b525354cc26 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 11:56:24 +0100 Subject: Use pidl for _netr_LogonControl. Guenther (This used to be commit ec4947525e0881bfcde661f906ccd1f66fe54f5a) --- source3/rpc_server/srv_netlog.c | 23 +-------------------- source3/rpc_server/srv_netlog_nt.c | 41 ++++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 41 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 4f0a0142e5..7faf63205e 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -279,28 +279,7 @@ static bool api_net_logon_ctrl2(pipes_struct *p) static bool api_net_logon_ctrl(pipes_struct *p) { - NET_Q_LOGON_CTRL q_u; - NET_R_LOGON_CTRL r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the lsa netlogon ctrl query... */ - if(!net_io_q_logon_ctrl("", &q_u, data, 0)) { - DEBUG(0,("api_net_logon_ctrl: Failed to unmarshall NET_Q_LOGON_CTRL.\n")); - return False; - } - - r_u.status = _net_logon_ctrl(p, &q_u, &r_u); - - if(!net_io_r_logon_ctrl("", &r_u, rdata, 0)) { - DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_LOGONCONTROL); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 528a33915a..b59ad62169 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -43,21 +43,34 @@ static void init_net_r_req_chal(NET_R_REQ_CHAL *r_c, } /************************************************************************* - net_reply_logon_ctrl: + _netr_LogonControl *************************************************************************/ -NTSTATUS _net_logon_ctrl(pipes_struct *p, NET_Q_LOGON_CTRL *q_u, - NET_R_LOGON_CTRL *r_u) +WERROR _netr_LogonControl(pipes_struct *p, + struct netr_LogonControl *r) { - uint32 flags = 0x0; - uint32 pdc_connection_status = 0x00; /* Maybe a win32 error code? */ - + struct netr_NETLOGON_INFO_1 *info1; + uint32_t flags = 0x0; + uint32_t pdc_connection_status = W_ERROR_V(WERR_OK); + /* Setup the Logon Control response */ - init_net_r_logon_ctrl(r_u, q_u->query_level, flags, - pdc_connection_status); + switch (r->in.level) { + case 1: + info1 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_1); + if (!info1) { + return WERR_NOMEM; + } + info1->flags = flags; + info1->pdc_connection_status = pdc_connection_status; - return r_u->status; + r->out.info->info1 = info1; + break; + default: + return WERR_UNKNOWN_LEVEL; + } + + return WERR_OK; } /**************************************************************************** @@ -1257,16 +1270,6 @@ NTSTATUS _netr_AccountSync(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _netr_LogonControl(pipes_struct *p, - struct netr_LogonControl *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _netr_GetDcName(pipes_struct *p, struct netr_GetDcName *r) { -- cgit From b94093173d9831935b7526ad0e8a93b791d7957a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 12:24:56 +0100 Subject: Pure cosmetics: remove trailing whitespace in netlogon server. Guenther (This used to be commit 983ac0a6762b52945a784ccbc371f4df99a0a52b) --- source3/rpc_server/srv_netlog_nt.c | 138 ++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 69 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index b59ad62169..d9fcbeb285 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -1,4 +1,4 @@ -/* +/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, @@ -11,12 +11,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ @@ -101,54 +101,54 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C unistr2_to_ascii(servername, &q_u->uni_server_name, sizeof(servername)); r_u->status = NT_STATUS_OK; - + tc_status = W_ERROR_V(WERR_NO_SUCH_DOMAIN); fstrcpy( dc_name, "" ); - + switch ( q_u->function_code ) { case NETLOGON_CONTROL_TC_QUERY: unistr2_to_ascii(domain, &q_u->info.info6.domain, sizeof(domain)); - + if ( !is_trusted_domain( domain ) ) break; - + if ( !get_dc_name( domain, NULL, dc_name2, &dc_ss ) ) { tc_status = W_ERROR_V(WERR_NO_LOGON_SERVERS); break; } fstr_sprintf( dc_name, "\\\\%s", dc_name2 ); - + tc_status = W_ERROR_V(WERR_OK); - + break; - + case NETLOGON_CONTROL_REDISCOVER: unistr2_to_ascii(domain, &q_u->info.info6.domain, sizeof(domain)); - + if ( !is_trusted_domain( domain ) ) break; - + if ( !get_dc_name( domain, NULL, dc_name2, &dc_ss ) ) { tc_status = W_ERROR_V(WERR_NO_LOGON_SERVERS); break; } fstr_sprintf( dc_name, "\\\\%s", dc_name2 ); - + tc_status = W_ERROR_V(WERR_OK); - + break; - + default: /* no idea what this should be */ DEBUG(0,("_net_logon_ctrl2: unimplemented function level [%d]\n", q_u->function_code)); } - + /* prepare the response */ - - init_net_r_logon_ctrl2( r_u, q_u->query_level, flags, + + init_net_r_logon_ctrl2( r_u, q_u->query_level, flags, pdc_connection_status, logon_attempts, tc_status, dc_name ); if (lp_server_role() == ROLE_DOMAIN_BDC) @@ -187,7 +187,7 @@ WERROR _netr_NetrEnumerateTrustedDomains(pipes_struct *p, ***********************************************************************************/ static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, - DOM_CRED *srv_cred, NTSTATUS status) + DOM_CRED *srv_cred, NTSTATUS status) { DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); @@ -207,13 +207,13 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) const uint8 *pass; bool ret; uint32 acct_ctrl; - + #if 0 char addr[INET6_ADDRSTRLEN]; /* * Currently this code is redundent as we already have a filter - * by hostname list. What this code really needs to do is to + * by hostname list. What this code really needs to do is to * get a hosts allowed/hosts denied list from the SAM database * on a per user basis, and make the access decision there. * I will leave this code here for now as a reminder to implement @@ -236,7 +236,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) become_root(); ret = pdb_getsampwnam(sampass, mach_acct); unbecome_root(); - + if (!ret) { DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct)); TALLOC_FREE(sampass); @@ -252,7 +252,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) if (!(acct_ctrl & ACB_SVRTRUST) && !(acct_ctrl & ACB_WSTRUST) && - !(acct_ctrl & ACB_DOMTRUST)) + !(acct_ctrl & ACB_DOMTRUST)) { DEBUG(0,("get_md4pw: Workstation %s: account is not a trust account\n", mach_acct)); TALLOC_FREE(sampass); @@ -298,9 +298,9 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) dump_data(5, (uint8 *)md4pw, 16); TALLOC_FREE(sampass); - + return NT_STATUS_OK; - + } @@ -330,10 +330,10 @@ NTSTATUS _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u /* Create a server challenge for the client */ /* Set this to a random value. */ generate_random_buffer(p->dc->srv_chal.data, 8); - + /* set up the LSA REQUEST CHALLENGE response */ init_net_r_req_chal(r_u, &p->dc->srv_chal, NT_STATUS_OK); - + p->dc->challenge_sent = True; return NT_STATUS_OK; @@ -385,7 +385,7 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) &p->dc->clnt_chal, /* Stored client chal. */ &p->dc->srv_chal, /* Stored server chal. */ p->dc->mach_pw, - &srv_chal_out); + &srv_chal_out); /* Check client credentials are valid. */ if (!creds_server_check(p->dc, &q_u->clnt_chal)) { @@ -468,7 +468,7 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) &p->dc->clnt_chal, /* Stored client chal. */ &p->dc->srv_chal, /* Stored server chal. */ p->dc->mach_pw, - &srv_chal_out); + &srv_chal_out); /* Check client credentials are valid. */ if (!creds_server_check(p->dc, &q_u->clnt_chal)) { @@ -551,7 +551,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * DEBUG(3,("_net_srv_pwset: Server Password Set by remote machine:[%s] on account [%s]\n", remote_machine, p->dc->mach_acct)); - + /* Step the creds chain forward. */ if (!creds_server_step(p->dc, &q_u->clnt_id.cred, &cred_out)) { DEBUG(2,("_net_srv_pwset: creds_server_step failed. Rejecting auth " @@ -579,7 +579,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * } /* Ensure the account exists and is a machine account. */ - + acct_ctrl = pdb_get_acct_ctrl(sampass); if (!(acct_ctrl & ACB_WSTRUST || @@ -588,7 +588,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * TALLOC_FREE(sampass); return NT_STATUS_NO_SUCH_USER; } - + if (pdb_get_acct_ctrl(sampass) & ACB_DISABLED) { TALLOC_FREE(sampass); return NT_STATUS_ACCOUNT_DISABLED; @@ -605,7 +605,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * old_pw = pdb_get_nt_passwd(sampass); if (old_pw && memcmp(pwd, old_pw, 16) == 0) { - /* Avoid backend modificiations and other fun if the + /* Avoid backend modificiations and other fun if the client changed the password to the *same thing* */ ret = True; @@ -616,18 +616,18 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * TALLOC_FREE(sampass); return NT_STATUS_NO_MEMORY; } - + if (!pdb_set_nt_passwd(sampass, pwd, PDB_CHANGED)) { TALLOC_FREE(sampass); return NT_STATUS_NO_MEMORY; } - + if (!pdb_set_pass_last_set_time(sampass, time(NULL), PDB_CHANGED)) { TALLOC_FREE(sampass); /* Not quite sure what this one qualifies as, but this will do */ - return NT_STATUS_UNSUCCESSFUL; + return NT_STATUS_UNSUCCESSFUL; } - + become_root(); r_u->status = pdb_update_sam_account(sampass); unbecome_root(); @@ -712,7 +712,7 @@ static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, const DOM_SID *domain_sid, size_t num_sids, const DOM_SID *sids, - int *numgroups, DOM_GID **pgids) + int *numgroups, DOM_GID **pgids) { int i; @@ -754,7 +754,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, auth_serversupplied_info *server_info = NULL; struct samu *sampw; struct auth_context *auth_context = NULL; - + if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { /* 'server schannel = yes' should enforce use of schannel, the client did offer it in auth2, but @@ -781,7 +781,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, /* We handle the return of USER_INFO_2 instead of 3 in the parse return. Sucks, I know... */ r_u->switch_value = q_u->validation_level; /* indicates type of validation user info */ r_u->buffer_creds = 1; /* Ensure we always return server creds. */ - + if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; @@ -835,14 +835,14 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, uni_samlogon_domain = &ctr->auth.id1.uni_domain_name; uni_samlogon_workstation = &ctr->auth.id1.uni_wksta_name; - + DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); break; case NET_LOGON_TYPE: uni_samlogon_user = &ctr->auth.id2.uni_user_name; uni_samlogon_domain = &ctr->auth.id2.uni_domain_name; uni_samlogon_workstation = &ctr->auth.id2.uni_wksta_name; - + DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); break; default: @@ -857,16 +857,16 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain)); fstrcpy(current_user_info.smb_name, nt_username); sub_set_smb_name(nt_username); - + DEBUG(5,("Attempting validation level %d for unmapped username %s.\n", q_u->sam_id.ctr->switch_value, nt_username)); status = NT_STATUS_OK; - + switch (ctr->switch_value) { case NET_LOGON_TYPE: { const char *wksname = nt_workstation; - + if (!NT_STATUS_IS_OK(status = make_auth_context_fixed(&auth_context, ctr->auth.id2.lm_chal))) { return status; } @@ -878,8 +878,8 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (*wksname == '\\') wksname++; /* Standard challenge/response authenticaion */ - if (!make_user_info_netlogon_network(&user_info, - nt_username, nt_domain, + if (!make_user_info_netlogon_network(&user_info, + nt_username, nt_domain, wksname, ctr->auth.id2.param_ctrl, ctr->auth.id2.lm_chal_resp.buffer, @@ -887,7 +887,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, ctr->auth.id2.nt_chal_resp.buffer, ctr->auth.id2.nt_chal_resp.str_str_len)) { status = NT_STATUS_NO_MEMORY; - } + } break; } case INTERACTIVE_LOGON_TYPE: @@ -897,20 +897,20 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, on */ { const uint8 *chal; - + if (!NT_STATUS_IS_OK(status = make_auth_context_subsystem(&auth_context))) { return status; } - + chal = auth_context->get_ntlm_challenge(auth_context); - if (!make_user_info_netlogon_interactive(&user_info, - nt_username, nt_domain, - nt_workstation, + if (!make_user_info_netlogon_interactive(&user_info, + nt_username, nt_domain, + nt_workstation, ctr->auth.id1.param_ctrl, chal, - ctr->auth.id1.lm_owf.data, - ctr->auth.id1.nt_owf.data, + ctr->auth.id1.lm_owf.data, + ctr->auth.id1.nt_owf.data, p->dc->sess_key)) { status = NT_STATUS_NO_MEMORY; } @@ -920,26 +920,26 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, DEBUG(2,("SAM Logon: unsupported switch value\n")); return NT_STATUS_INVALID_INFO_CLASS; } /* end switch */ - + if ( NT_STATUS_IS_OK(status) ) { - status = auth_context->check_ntlm_password(auth_context, + status = auth_context->check_ntlm_password(auth_context, user_info, &server_info); } - (auth_context->free)(&auth_context); + (auth_context->free)(&auth_context); free_user_info(&user_info); - - DEBUG(5, ("_net_sam_logon: check_password returned status %s\n", + + DEBUG(5, ("_net_sam_logon: check_password returned status %s\n", nt_errstr(status))); /* Check account and password */ - + if (!NT_STATUS_IS_OK(status)) { - /* If we don't know what this domain is, we need to - indicate that we are not authoritative. This - allows the client to decide if it needs to try + /* If we don't know what this domain is, we need to + indicate that we are not authoritative. This + allows the client to decide if it needs to try a local user. Fix by jpjanosi@us.ibm.com, #2976 */ - if ( NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER) + if ( NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER) && !strequal(nt_domain, get_global_sam_name()) && !is_trusted_domain(nt_domain) ) r_u->auth_resp = 0; /* We are not authoritative */ @@ -1095,7 +1095,7 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON * { return _net_sam_logon_internal(p, q_u, r_u, True); } - + /************************************************************************* _net_sam_logon_ex - no credential chaining. Map into net sam logon. *************************************************************************/ @@ -1146,10 +1146,10 @@ NTSTATUS _net_sam_logon_ex(pipes_struct *p, NET_Q_SAM_LOGON_EX *q_u, NET_R_SAM_L { NTSTATUS status = NT_STATUS_OK; - /* TODO: According to MSDN, the can only be executed against a + /* TODO: According to MSDN, the can only be executed against a DC or domain member running Windows 2000 or later. Need - to test against a standalone 2k server and see what it - does. A windows 2000 DC includes its own domain in the + to test against a standalone 2k server and see what it + does. A windows 2000 DC includes its own domain in the list. --jerry */ return status; -- cgit From 4140f3213d678fa998d1cf6e6f1eaf4d5be7903a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 14:08:59 +0100 Subject: Use pidl for _netr_ServerReqChallenge. Guenther (This used to be commit ef424319410b7a29ecdfefca53b7e9704beb6139) --- source3/rpc_server/srv_netlog.c | 24 +----------------------- source3/rpc_server/srv_netlog_nt.c | 34 ++++++++++++---------------------- 2 files changed, 13 insertions(+), 45 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 7faf63205e..1b23cd835a 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -55,29 +55,7 @@ static bool proxy_netr_call(pipes_struct *p, uint8 opnum) static bool api_net_req_chal(pipes_struct *p) { - NET_Q_REQ_CHAL q_u; - NET_R_REQ_CHAL r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the challenge... */ - if(!net_io_q_req_chal("", &q_u, data, 0)) { - DEBUG(0,("api_net_req_chal: Failed to unmarshall NET_Q_REQ_CHAL.\n")); - return False; - } - - r_u.status = _net_req_chal(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_req_chal("", &r_u, rdata, 0)) { - DEBUG(0,("api_net_req_chal: Failed to marshall NET_R_REQ_CHAL.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_SERVERREQCHALLENGE); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index d9fcbeb285..acf694b128 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -34,12 +34,12 @@ extern userdom_struct current_user_info; init_net_r_req_chal: *************************************************************************/ -static void init_net_r_req_chal(NET_R_REQ_CHAL *r_c, - DOM_CHAL *srv_chal, NTSTATUS status) +static void init_net_r_req_chal(struct netr_Credential *r, + DOM_CHAL *srv_chal) { DEBUG(6,("init_net_r_req_chal: %d\n", __LINE__)); - memcpy(r_c->srv_chal.data, srv_chal->data, sizeof(srv_chal->data)); - r_c->status = status; + + memcpy(r->data, srv_chal->data, sizeof(r->data)); } /************************************************************************* @@ -305,10 +305,11 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) } /************************************************************************* - _net_req_chal + _netr_ServerReqChallenge *************************************************************************/ -NTSTATUS _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u) +NTSTATUS _netr_ServerReqChallenge(pipes_struct *p, + struct netr_ServerReqChallenge *r) { if (!p->dc) { p->dc = TALLOC_ZERO_P(p->pipe_state_mem_ctx, struct dcinfo); @@ -316,23 +317,22 @@ NTSTATUS _net_req_chal(pipes_struct *p, NET_Q_REQ_CHAL *q_u, NET_R_REQ_CHAL *r_u return NT_STATUS_NO_MEMORY; } } else { - DEBUG(10,("_net_req_chal: new challenge requested. Clearing old state.\n")); + DEBUG(10,("_netr_ServerReqChallenge: new challenge requested. Clearing old state.\n")); ZERO_STRUCTP(p->dc); } - rpcstr_pull(p->dc->remote_machine, - q_u->uni_logon_clnt.buffer, - sizeof(fstring),q_u->uni_logon_clnt.uni_str_len*2,0); + fstrcpy(p->dc->remote_machine, r->in.computer_name); /* Save the client challenge to the server. */ - memcpy(p->dc->clnt_chal.data, q_u->clnt_chal.data, sizeof(q_u->clnt_chal.data)); + memcpy(p->dc->clnt_chal.data, r->in.credentials->data, + sizeof(r->in.credentials->data)); /* Create a server challenge for the client */ /* Set this to a random value. */ generate_random_buffer(p->dc->srv_chal.data, 8); /* set up the LSA REQUEST CHALLENGE response */ - init_net_r_req_chal(r_u, &p->dc->srv_chal, NT_STATUS_OK); + init_net_r_req_chal(r->out.credentials, &p->dc->srv_chal); p->dc->challenge_sent = True; @@ -1200,16 +1200,6 @@ NTSTATUS _netr_LogonSamLogoff(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _netr_ServerReqChallenge(pipes_struct *p, - struct netr_ServerReqChallenge *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, struct netr_ServerAuthenticate *r) { -- cgit From 3722208ddff6386ff93d8445337442569710ff23 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 22:55:44 +0100 Subject: Add some netr_NETLOGON_INFO init functions. Guenther (This used to be commit f0c66688588a4e62c4a250b0d21a0fe14bbc5099) --- source3/rpc_server/srv_netlog_nt.c | 46 +++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index acf694b128..2c52ba87af 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -42,6 +42,46 @@ static void init_net_r_req_chal(struct netr_Credential *r, memcpy(r->data, srv_chal->data, sizeof(r->data)); } +/******************************************************************* + Inits a netr_NETLOGON_INFO_1 structure. +********************************************************************/ + +static void init_netlogon_info1(struct netr_NETLOGON_INFO_1 *r, + uint32_t flags, + uint32_t pdc_connection_status) +{ + r->flags = flags; + r->pdc_connection_status = pdc_connection_status; +} + +/******************************************************************* + Inits a netr_NETLOGON_INFO_2 structure. +********************************************************************/ + +static void init_netlogon_info2(struct netr_NETLOGON_INFO_2 *r, + uint32_t flags, + uint32_t pdc_connection_status, + const char *trusted_dc_name, + uint32_t tc_connection_status) +{ + r->flags = flags; + r->pdc_connection_status = pdc_connection_status; + r->trusted_dc_name = trusted_dc_name; + r->tc_connection_status = tc_connection_status; +} + +/******************************************************************* + Inits a netr_NETLOGON_INFO_3 structure. +********************************************************************/ + +static void init_netlogon_info3(struct netr_NETLOGON_INFO_3 *r, + uint32_t flags, + uint32_t logon_attempts) +{ + r->flags = flags; + r->logon_attempts = logon_attempts; +} + /************************************************************************* _netr_LogonControl *************************************************************************/ @@ -61,9 +101,9 @@ WERROR _netr_LogonControl(pipes_struct *p, if (!info1) { return WERR_NOMEM; } - info1->flags = flags; - info1->pdc_connection_status = pdc_connection_status; - + init_netlogon_info1(info1, + flags, + pdc_connection_status); r->out.info->info1 = info1; break; default: -- cgit From 7acdc9e8d6a6311983e1d3f19047293e47f92722 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 13 Feb 2008 23:06:09 +0100 Subject: Use pidl for _netr_LogonControl2. Guenther (This used to be commit 4bd02aa6cdfdfd8f3b678fc81a0a1bd70cef9a67) --- source3/rpc_server/srv_netlog.c | 24 +----------- source3/rpc_server/srv_netlog_nt.c | 77 +++++++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 50 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 1b23cd835a..791752c5d0 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -226,29 +226,7 @@ static bool api_net_trust_dom_list(pipes_struct *p) static bool api_net_logon_ctrl2(pipes_struct *p) { - NET_Q_LOGON_CTRL2 q_u; - NET_R_LOGON_CTRL2 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - - /* grab the lsa netlogon ctrl2 query... */ - if(!net_io_q_logon_ctrl2("", &q_u, data, 0)) { - DEBUG(0,("api_net_logon_ctrl2: Failed to unmarshall NET_Q_LOGON_CTRL2.\n")); - return False; - } - - r_u.status = _net_logon_ctrl2(p, &q_u, &r_u); - - if(!net_io_r_logon_ctrl2("", &r_u, rdata, 0)) { - DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL2.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_LOGONCONTROL2); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 2c52ba87af..3cfab7843d 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -125,29 +125,29 @@ static void send_sync_message(void) } /************************************************************************* - net_reply_logon_ctrl2: + _netr_LogonControl2 *************************************************************************/ -NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_CTRL2 *r_u) +WERROR _netr_LogonControl2(pipes_struct *p, + struct netr_LogonControl2 *r) { uint32 flags = 0x0; uint32 pdc_connection_status = 0x0; uint32 logon_attempts = 0x0; uint32 tc_status; - fstring servername, domain, dc_name, dc_name2; + fstring dc_name, dc_name2; struct sockaddr_storage dc_ss; - - /* this should be \\global_myname() */ - unistr2_to_ascii(servername, &q_u->uni_server_name, sizeof(servername)); - - r_u->status = NT_STATUS_OK; + const char *domain = NULL; + struct netr_NETLOGON_INFO_1 *info1; + struct netr_NETLOGON_INFO_2 *info2; + struct netr_NETLOGON_INFO_3 *info3; tc_status = W_ERROR_V(WERR_NO_SUCH_DOMAIN); fstrcpy( dc_name, "" ); - switch ( q_u->function_code ) { + switch (r->in.function_code) { case NETLOGON_CONTROL_TC_QUERY: - unistr2_to_ascii(domain, &q_u->info.info6.domain, sizeof(domain)); + domain = r->in.data->domain; if ( !is_trusted_domain( domain ) ) break; @@ -164,7 +164,7 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C break; case NETLOGON_CONTROL_REDISCOVER: - unistr2_to_ascii(domain, &q_u->info.info6.domain, sizeof(domain)); + domain = r->in.data->domain; if ( !is_trusted_domain( domain ) ) break; @@ -182,19 +182,52 @@ NTSTATUS _net_logon_ctrl2(pipes_struct *p, NET_Q_LOGON_CTRL2 *q_u, NET_R_LOGON_C default: /* no idea what this should be */ - DEBUG(0,("_net_logon_ctrl2: unimplemented function level [%d]\n", - q_u->function_code)); + DEBUG(0,("_netr_LogonControl2: unimplemented function level [%d]\n", + r->in.function_code)); + return WERR_UNKNOWN_LEVEL; } /* prepare the response */ - init_net_r_logon_ctrl2( r_u, q_u->query_level, flags, - pdc_connection_status, logon_attempts, tc_status, dc_name ); + switch (r->in.level) { + case 1: + info1 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_1); + W_ERROR_HAVE_NO_MEMORY(info1); - if (lp_server_role() == ROLE_DOMAIN_BDC) + init_netlogon_info1(info1, + flags, + pdc_connection_status); + r->out.query->info1 = info1; + break; + case 2: + info2 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_2); + W_ERROR_HAVE_NO_MEMORY(info2); + + init_netlogon_info2(info2, + flags, + pdc_connection_status, + dc_name, + tc_status); + r->out.query->info2 = info2; + break; + case 3: + info3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_NETLOGON_INFO_3); + W_ERROR_HAVE_NO_MEMORY(info3); + + init_netlogon_info3(info3, + flags, + logon_attempts); + r->out.query->info3 = info3; + break; + default: + return WERR_UNKNOWN_LEVEL; + } + + if (lp_server_role() == ROLE_DOMAIN_BDC) { send_sync_message(); + } - return r_u->status; + return WERR_OK; } /************************************************************************* @@ -1320,16 +1353,6 @@ WERROR _netr_GetAnyDCName(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _netr_LogonControl2(pipes_struct *p, - struct netr_LogonControl2 *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p, struct netr_ServerAuthenticate2 *r) { -- cgit From 0460295c1fe1c3103bbe03d6ca5a8028d79f1704 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:16:03 +0100 Subject: Use pidl for _lsa_EnumAccounts. Guenther (This used to be commit 07e5138ad960bce8569ea593ca9a1b4fbf2b1048) --- source3/rpc_server/srv_lsa.c | 23 +------------------ source3/rpc_server/srv_lsa_nt.c | 50 ++++++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 48 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index f48a397f1d..a3fe00cced 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -185,28 +185,7 @@ static bool api_lsa_priv_get_dispname(pipes_struct *p) static bool api_lsa_enum_accounts(pipes_struct *p) { - LSA_Q_ENUM_ACCOUNTS q_u; - LSA_R_ENUM_ACCOUNTS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_enum_accounts("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_enum_accounts: failed to unmarshall LSA_Q_ENUM_ACCOUNTS.\n")); - return False; - } - - r_u.status = _lsa_enum_accounts(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_enum_accounts("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_enum_accounts: Failed to marshall LSA_R_ENUM_ACCOUNTS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_ENUMACCOUNTS); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 3cf83962ee..097b50504f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1519,18 +1519,19 @@ NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p, } /*************************************************************************** -_lsa_enum_accounts. + _lsa_EnumAccounts ***************************************************************************/ -NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENUM_ACCOUNTS *r_u) +NTSTATUS _lsa_EnumAccounts(pipes_struct *p, + struct lsa_EnumAccounts *r) { struct lsa_info *handle; DOM_SID *sid_list; int i, j, num_entries; - LSA_SID_ENUM *sids=&r_u->sids; - NTSTATUS ret; + NTSTATUS status; + struct lsa_SidPtr *sids = NULL; - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) @@ -1542,34 +1543,37 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU /* The only way we can currently find out all the SIDs that have been privileged is to scan all privileges */ - if (!NT_STATUS_IS_OK(ret = privilege_enumerate_accounts(&sid_list, &num_entries))) { - return ret; + status = privilege_enumerate_accounts(&sid_list, &num_entries); + if (!NT_STATUS_IS_OK(status)) { + return status; } - if (q_u->enum_context >= num_entries) + if (*r->in.resume_handle >= num_entries) { return NT_STATUS_NO_MORE_ENTRIES; + } - if (num_entries-q_u->enum_context) { - sids->ptr_sid = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_entries-q_u->enum_context); - sids->sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_entries-q_u->enum_context); - - if (sids->ptr_sid==NULL || sids->sid==NULL) { + if (num_entries - *r->in.resume_handle) { + sids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_SidPtr, + num_entries - *r->in.resume_handle); + if (!sids) { SAFE_FREE(sid_list); return NT_STATUS_NO_MEMORY; } - for (i = q_u->enum_context, j = 0; i < num_entries; i++, j++) { - init_dom_sid2(&(*sids).sid[j], &sid_list[i]); - (*sids).ptr_sid[j] = 1; + for (i = *r->in.resume_handle, j = 0; i < num_entries; i++, j++) { + sids[j].sid = sid_dup_talloc(p->mem_ctx, &sid_list[i]); + if (!sids[j].sid) { + SAFE_FREE(sid_list); + return NT_STATUS_NO_MEMORY; + } } - } else { - sids->ptr_sid = NULL; - sids->sid = NULL; } talloc_free(sid_list); - init_lsa_r_enum_accounts(r_u, num_entries); + *r->out.resume_handle = num_entries; + r->out.sids->num_sids = num_entries; + r->out.sids->sids = sids; return NT_STATUS_OK; } @@ -2230,12 +2234,6 @@ NTSTATUS _lsa_ClearAuditLog(pipes_struct *p, struct lsa_ClearAuditLog *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumAccounts(pipes_struct *p, struct lsa_EnumAccounts *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_LookupNames(pipes_struct *p, struct lsa_LookupNames *r) { p->rng_fault_state = True; -- cgit From d69d58664c7bc2a2815b4e7c5a6d61646a5bf0ff Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:53:42 +0100 Subject: Fix typo. Guenther (This used to be commit 4e3357ac3a1b0adac1744a71f997e3442e0e4209) --- source3/rpc_server/srv_lsa_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 097b50504f..275f3d9cb4 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1424,10 +1424,10 @@ NTSTATUS _lsa_EnumPrivs(pipes_struct *p, if ( enum_context >= num_privs ) return NT_STATUS_NO_MORE_ENTRIES; - - DEBUG(10,("_lsa_enum_privs: enum_context:%d total entries:%d\n", + + DEBUG(10,("_lsa_EnumPrivs: enum_context:%d total entries:%d\n", enum_context, num_privs)); - + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; -- cgit From 4583389f9323cc6b405b6d54125ee2d7e21707b8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:53:00 +0100 Subject: Use pidl for _lsa_EnumPrivsAccount(). Guenther (This used to be commit d7655932a7cb436f1ee44e443882e2f06d598aa0) --- source3/rpc_server/srv_lsa.c | 24 +------------------ source3/rpc_server/srv_lsa_nt.c | 53 ++++++++++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 37 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index a3fe00cced..60a3bd3671 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -221,29 +221,7 @@ static bool api_lsa_open_account(pipes_struct *p) static bool api_lsa_enum_privsaccount(pipes_struct *p) { - LSA_Q_ENUMPRIVSACCOUNT q_u; - LSA_R_ENUMPRIVSACCOUNT r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_enum_privsaccount("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_enum_privsaccount: failed to unmarshall LSA_Q_ENUMPRIVSACCOUNT.\n")); - return False; - } - - r_u.status = _lsa_enum_privsaccount(p, rdata, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_enum_privsaccount("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_enum_privsaccount: Failed to marshall LSA_R_ENUMPRIVSACCOUNT.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_ENUMPRIVSACCOUNT); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 275f3d9cb4..4e2884ccdb 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1720,38 +1720,69 @@ NTSTATUS _lsa_OpenAccount(pipes_struct *p, } /*************************************************************************** + _lsa_EnumPrivsAccount For a given SID, enumerate all the privilege this account has. ***************************************************************************/ -NTSTATUS _lsa_enum_privsaccount(pipes_struct *p, prs_struct *ps, LSA_Q_ENUMPRIVSACCOUNT *q_u, LSA_R_ENUMPRIVSACCOUNT *r_u) +NTSTATUS _lsa_EnumPrivsAccount(pipes_struct *p, + struct lsa_EnumPrivsAccount *r) { + NTSTATUS status = NT_STATUS_OK; struct lsa_info *info=NULL; SE_PRIV mask; PRIVILEGE_SET privileges; + struct lsa_PrivilegeSet *priv_set = NULL; + struct lsa_LUIDAttribute *luid_attrs = NULL; + int i; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - if ( !get_privileges_for_sids( &mask, &info->sid, 1 ) ) + if ( !get_privileges_for_sids( &mask, &info->sid, 1 ) ) return NT_STATUS_OBJECT_NAME_NOT_FOUND; privilege_set_init( &privileges ); if ( se_priv_to_privilege_set( &privileges, &mask ) ) { - DEBUG(10,("_lsa_enum_privsaccount: %s has %d privileges\n", + DEBUG(10,("_lsa_EnumPrivsAccount: %s has %d privileges\n", sid_string_dbg(&info->sid), privileges.count)); - r_u->status = init_lsa_r_enum_privsaccount(ps->mem_ctx, r_u, privileges.set, privileges.count, 0); + priv_set = TALLOC_ZERO_P(p->mem_ctx, struct lsa_PrivilegeSet); + if (!priv_set) { + status = NT_STATUS_NO_MEMORY; + goto done; + } + + luid_attrs = TALLOC_ZERO_ARRAY(p->mem_ctx, + struct lsa_LUIDAttribute, + privileges.count); + if (!luid_attrs) { + status = NT_STATUS_NO_MEMORY; + goto done; + } + + for (i=0; icount = privileges.count; + priv_set->unknown = 0; + priv_set->set = luid_attrs; + + *r->out.privs = priv_set; + } else { + status = NT_STATUS_NO_SUCH_PRIVILEGE; } - else - r_u->status = NT_STATUS_NO_SUCH_PRIVILEGE; + done: privilege_set_free( &privileges ); - return r_u->status; + return status; } /*************************************************************************** @@ -2246,12 +2277,6 @@ NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumPrivsAccount(pipes_struct *p, struct lsa_EnumPrivsAccount *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_AddPrivilegesToAccount(pipes_struct *p, struct lsa_AddPrivilegesToAccount *r) { p->rng_fault_state = True; -- cgit From d0ae7cfb6fb3ed85d87334ce42ed7d3ce84a91a0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 13:12:28 +0100 Subject: Remove white space. Guenther (This used to be commit a33ed085094b200e153939cb1b02e567f07b1e50) --- source3/rpc_server/srv_lsa_nt.c | 120 ++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 4e2884ccdb..ef09b28dde 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -15,12 +15,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ @@ -467,7 +467,7 @@ static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, r_l->hdr_nb_dom_name.uni_max_len += 2; r_l->uni_nb_dom_name.uni_max_len += 1; } - + if (dns_name && *dns_name) { init_unistr2(&r_l->uni_dns_dom_name, dns_name, UNI_FLAGS_NONE); init_uni_hdr(&r_l->hdr_dns_dom_name, &r_l->uni_dns_dom_name); @@ -486,7 +486,7 @@ static void init_dns_dom_info(LSA_DNS_DOM_INFO *r_l, const char *nb_name, if (dom_guid) { memcpy(&r_l->dom_guid, dom_guid, sizeof(struct GUID)); } - + if (dom_sid) { r_l->ptr_dom_sid = 1; init_dom_sid2(&r_l->dom_sid, dom_sid); @@ -874,7 +874,7 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, * RID as 8 bytes hex, in others it returns the full * SID. We (Jerry/VL) could not figure out which the * hard cases are, so leave it with the SID. */ - name->name = talloc_asprintf(p->mem_ctx, "%s", + name->name = talloc_asprintf(p->mem_ctx, "%s", sid_to_fstring(tmp, sids[i])); if (name->name == NULL) { @@ -942,7 +942,7 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, r_u->status = _lsa_lookup_sids_internal(p, q_u->level, - num_sids, + num_sids, q_u->sids.sid, &ref, &names, @@ -991,7 +991,7 @@ NTSTATUS _lsa_lookup_sids2(pipes_struct *p, r_u->status = _lsa_lookup_sids_internal(p, q_u->level, - num_sids, + num_sids, q_u->sids.sid, &ref, &r_u->names, @@ -1032,7 +1032,7 @@ NTSTATUS _lsa_lookup_sids3(pipes_struct *p, r_u->status = _lsa_lookup_sids_internal(p, q_u->level, - num_sids, + num_sids, q_u->sids.sid, &ref, &r_u->names, @@ -1085,7 +1085,7 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP num_entries = MAX_LOOKUP_SIDS; DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries)); } - + flags = lsa_lookup_level_to_flags(q_u->lookup_level); ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); @@ -1230,7 +1230,7 @@ NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOO num_entries = MAX_LOOKUP_SIDS; DEBUG(5,("_lsa_lookup_names3: truncating name lookup list to %d\n", num_entries)); } - + /* Probably the lookup_level is some sort of bitmask. */ if (q_u->lookup_level == 1) { flags = LOOKUP_NAME_ALL; @@ -1297,7 +1297,7 @@ NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOO num_entries = MAX_LOOKUP_SIDS; DEBUG(5,("_lsa_lookup_names4: truncating name lookup list to %d\n", num_entries)); } - + /* Probably the lookup_level is some sort of bitmask. */ if (q_u->lookup_level == 1) { flags = LOOKUP_NAME_ALL; @@ -1650,17 +1650,17 @@ NTSTATUS _lsa_CreateAccount(pipes_struct *p, if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) return NT_STATUS_ACCESS_DENIED; - /* check to see if the pipe_user is a Domain Admin since + /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - + if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) return NT_STATUS_ACCESS_DENIED; - + if ( is_privileged_sid( r->in.sid ) ) return NT_STATUS_OBJECT_NAME_COLLISION; /* associate the user/group SID with the (unique) handle. */ - + if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL) return NT_STATUS_NO_MEMORY; @@ -1807,7 +1807,7 @@ NTSTATUS _lsa_GetSystemAccessAccount(pipes_struct *p, 0x02 -> Access this computer from network 0x04 -> Log on as a batch job 0x10 -> Log on as a service - + they can be ORed together */ @@ -1830,9 +1830,9 @@ NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - /* check to see if the pipe_user is a Domain Admin since + /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - + if ( !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) return NT_STATUS_ACCESS_DENIED; @@ -1855,11 +1855,11 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - - /* check to see if the pipe_user is root or a Domain Admin since + + /* check to see if the pipe_user is root or a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - - if ( p->pipe_user.ut.uid != sec_initial_uid() + + if ( p->pipe_user.ut.uid != sec_initial_uid() && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { return NT_STATUS_ACCESS_DENIED; @@ -1895,11 +1895,11 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - /* check to see if the pipe_user is root or a Domain Admin since + /* check to see if the pipe_user is root or a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - + if ( p->pipe_user.ut.uid != sec_initial_uid() - && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { return NT_STATUS_ACCESS_DENIED; } @@ -2020,7 +2020,7 @@ NTSTATUS _lsa_QuerySecurity(pipes_struct *p, default: return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; } - init_dns_dom_info(&r_u->info.dns_dom_info, nb_name, dns_name, + init_dns_dom_info(&r_u->info.dns_dom_info, nb_name, dns_name, forest_name,&guid,sid); break; default: @@ -2048,33 +2048,33 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R DOM_SID sid; fstring privname; UNISTR4_ARRAY *uni_privnames = q_u->rights; - + /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - - /* check to see if the pipe_user is a Domain Admin since + + /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - + if ( p->pipe_user.ut.uid != sec_initial_uid() - && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) + && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { return NT_STATUS_ACCESS_DENIED; } /* according to an NT4 PDC, you can add privileges to SIDs even without call_lsa_create_account() first. And you can use any arbitrary SID. */ - + sid_copy( &sid, &q_u->sid.sid ); - + /* just a little sanity check */ - + if ( q_u->count != uni_privnames->count ) { DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n")); - return NT_STATUS_INVALID_HANDLE; + return NT_STATUS_INVALID_HANDLE; } - + for ( i=0; icount; i++ ) { UNISTR4 *uni4_str = &uni_privnames->strings[i]; @@ -2084,7 +2084,7 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R continue; rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE ); - + if ( !grant_privilege_by_name( &sid, privname ) ) { DEBUG(2,("_lsa_add_acct_rights: Failed to add privilege [%s]\n", privname )); return NT_STATUS_NO_SUCH_PRIVILEGE; @@ -2104,15 +2104,15 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, DOM_SID sid; fstring privname; UNISTR4_ARRAY *uni_privnames = q_u->rights; - + /* find the connection policy handle. */ if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - - /* check to see if the pipe_user is a Domain Admin since + + /* check to see if the pipe_user is a Domain Admin since account_pol.tdb was already opened as root, this is all we have */ - + if ( p->pipe_user.ut.uid != sec_initial_uid() && !nt_token_check_domain_rid( p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS ) ) { @@ -2122,19 +2122,19 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, sid_copy( &sid, &q_u->sid.sid ); if ( q_u->removeall ) { - if ( !revoke_all_privileges( &sid ) ) + if ( !revoke_all_privileges( &sid ) ) return NT_STATUS_ACCESS_DENIED; - + return NT_STATUS_OK; } - + /* just a little sanity check */ - + if ( q_u->count != uni_privnames->count ) { DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n")); - return NT_STATUS_INVALID_HANDLE; + return NT_STATUS_INVALID_HANDLE; } - + for ( i=0; icount; i++ ) { UNISTR4 *uni4_str = &uni_privnames->strings[i]; @@ -2144,7 +2144,7 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, continue; rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE ); - + if ( !revoke_privilege_by_name( &sid, privname ) ) { DEBUG(2,("_lsa_remove_acct_rights: Failed to revoke privilege [%s]\n", privname )); return NT_STATUS_NO_SUCH_PRIVILEGE; @@ -2164,18 +2164,18 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA DOM_SID sid; PRIVILEGE_SET privileges; SE_PRIV mask; - + /* find the connection policy handle. */ - + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - + /* according to an NT4 PDC, you can add privileges to SIDs even without call_lsa_create_account() first. And you can use any arbitrary SID. */ - + sid_copy( &sid, &q_u->sid.sid ); - + if ( !get_privileges_for_sids( &mask, &sid, 1 ) ) return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2188,7 +2188,7 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA r_u->status = init_r_enum_acct_rights( r_u, &privileges ); } - else + else r_u->status = NT_STATUS_NO_SUCH_PRIVILEGE; privilege_set_free( &privileges ); @@ -2206,14 +2206,14 @@ NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, L fstring name; LUID_ATTR priv_luid; SE_PRIV mask; - + /* find the connection policy handle. */ - + if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - + unistr2_to_ascii(name, &q_u->privname.unistring, sizeof(name)); - + DEBUG(10,("_lsa_lookup_priv_value: name = %s\n", name)); if ( !se_priv_from_name( name, &mask ) ) @@ -2223,7 +2223,7 @@ NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, L r_u->luid.low = priv_luid.luid.low; r_u->luid.high = priv_luid.luid.high; - + return NT_STATUS_OK; } @@ -2233,7 +2233,7 @@ NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, L * From here on the server routines are just dummy ones to make smbd link with * librpc/gen_ndr/srv_lsa.c. These routines are actually never called, we are * pulling the server stubs across one by one. - */ + */ NTSTATUS _lsa_Delete(pipes_struct *p, struct lsa_Delete *r) { -- cgit From a63b27bec0da21b319133ade40303b4dce46412a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 13:25:42 +0100 Subject: Use pidl for _lsa_LookupPrivValue(). Guenther (This used to be commit 87dc2471d1c2a5be17604399d4f684193a6bba38) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 37 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 60a3bd3671..c4ca22f401 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -413,29 +413,7 @@ static bool api_lsa_enum_acct_rights(pipes_struct *p) static bool api_lsa_lookup_priv_value(pipes_struct *p) { - LSA_Q_LOOKUP_PRIV_VALUE q_u; - LSA_R_LOOKUP_PRIV_VALUE r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_lookup_priv_value("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_priv_value: failed to unmarshall LSA_Q_LOOKUP_PRIV_VALUE .\n")); - return False; - } - - r_u.status = _lsa_lookup_priv_value(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_lookup_priv_value("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_priv_value: Failed to marshall LSA_R_LOOKUP_PRIV_VALUE.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPPRIVVALUE); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index ef09b28dde..a8f6e15e23 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -2198,21 +2198,23 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA /*************************************************************************** + _lsa_LookupPrivValue ***************************************************************************/ -NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, LSA_R_LOOKUP_PRIV_VALUE *r_u) +NTSTATUS _lsa_LookupPrivValue(pipes_struct *p, + struct lsa_LookupPrivValue *r) { struct lsa_info *info = NULL; - fstring name; + const char *name = NULL; LUID_ATTR priv_luid; SE_PRIV mask; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - unistr2_to_ascii(name, &q_u->privname.unistring, sizeof(name)); + name = r->in.name->string; DEBUG(10,("_lsa_lookup_priv_value: name = %s\n", name)); @@ -2221,14 +2223,12 @@ NTSTATUS _lsa_lookup_priv_value(pipes_struct *p, LSA_Q_LOOKUP_PRIV_VALUE *q_u, L priv_luid = get_privilege_luid( &mask ); - r_u->luid.low = priv_luid.luid.low; - r_u->luid.high = priv_luid.luid.high; - + r->out.luid->low = priv_luid.luid.low; + r->out.luid->high = priv_luid.luid.high; return NT_STATUS_OK; } - /* * From here on the server routines are just dummy ones to make smbd link with * librpc/gen_ndr/srv_lsa.c. These routines are actually never called, we are @@ -2319,12 +2319,6 @@ NTSTATUS _lsa_QuerySecret(pipes_struct *p, struct lsa_QuerySecret *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupPrivValue(pipes_struct *p, struct lsa_LookupPrivValue *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_LookupPrivName(pipes_struct *p, struct lsa_LookupPrivName *r) { p->rng_fault_state = True; -- cgit From 08f019d973f7c71be7b402d5f32922a18381a3cf Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 13:50:32 +0100 Subject: Use pidl for _lsa_AddPrivilegesToAccount and _lsa_RemovePrivilegesFromAccount. Guenther (This used to be commit 0c9904864b5c3b893f99abdebb18d9624aa0f560) --- source3/rpc_server/srv_lsa.c | 48 ++--------------------------------------- source3/rpc_server/srv_lsa_nt.c | 37 ++++++++++++------------------- 2 files changed, 16 insertions(+), 69 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index c4ca22f401..ff274473d6 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -249,29 +249,7 @@ static bool api_lsa_setsystemaccount(pipes_struct *p) static bool api_lsa_addprivs(pipes_struct *p) { - LSA_Q_ADDPRIVS q_u; - LSA_R_ADDPRIVS r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_addprivs("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_addprivs: failed to unmarshall LSA_Q_ADDPRIVS.\n")); - return False; - } - - r_u.status = _lsa_addprivs(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_addprivs("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_addprivs: Failed to marshall LSA_R_ADDPRIVS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_ADDPRIVILEGESTOACCOUNT); } /*************************************************************************** @@ -280,29 +258,7 @@ static bool api_lsa_addprivs(pipes_struct *p) static bool api_lsa_removeprivs(pipes_struct *p) { - LSA_Q_REMOVEPRIVS q_u; - LSA_R_REMOVEPRIVS r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_removeprivs("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_removeprivs: failed to unmarshall LSA_Q_REMOVEPRIVS.\n")); - return False; - } - - r_u.status = _lsa_removeprivs(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_removeprivs("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_removeprivs: Failed to marshall LSA_R_REMOVEPRIVS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_REMOVEPRIVILEGESFROMACCOUNT); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index a8f6e15e23..10842a1ada 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1843,17 +1843,19 @@ NTSTATUS _lsa_SetSystemAccessAccount(pipes_struct *p, } /*************************************************************************** + _lsa_AddPrivilegesToAccount For a given SID, add some privileges. ***************************************************************************/ -NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u) +NTSTATUS _lsa_AddPrivilegesToAccount(pipes_struct *p, + struct lsa_AddPrivilegesToAccount *r) { struct lsa_info *info = NULL; SE_PRIV mask; - PRIVILEGE_SET *set = NULL; + struct lsa_PrivilegeSet *set = NULL; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is root or a Domain Admin since @@ -1865,13 +1867,12 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u return NT_STATUS_ACCESS_DENIED; } - set = &q_u->set; - + set = r->in.privs; if ( !privilege_set_to_se_priv( &mask, set ) ) return NT_STATUS_NO_SUCH_PRIVILEGE; if ( !grant_privilege( &info->sid, &mask ) ) { - DEBUG(3,("_lsa_addprivs: grant_privilege(%s) failed!\n", + DEBUG(3,("_lsa_AddPrivilegesToAccount: grant_privilege(%s) failed!\n", sid_string_dbg(&info->sid) )); DEBUG(3,("Privilege mask:\n")); dump_se_priv( DBGC_ALL, 3, &mask ); @@ -1882,17 +1883,19 @@ NTSTATUS _lsa_addprivs(pipes_struct *p, LSA_Q_ADDPRIVS *q_u, LSA_R_ADDPRIVS *r_u } /*************************************************************************** + _lsa_RemovePrivilegesFromAccount For a given SID, remove some privileges. ***************************************************************************/ -NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEPRIVS *r_u) +NTSTATUS _lsa_RemovePrivilegesFromAccount(pipes_struct *p, + struct lsa_RemovePrivilegesFromAccount *r) { struct lsa_info *info = NULL; SE_PRIV mask; - PRIVILEGE_SET *set = NULL; + struct lsa_PrivilegeSet *set = NULL; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is root or a Domain Admin since @@ -1904,13 +1907,13 @@ NTSTATUS _lsa_removeprivs(pipes_struct *p, LSA_Q_REMOVEPRIVS *q_u, LSA_R_REMOVEP return NT_STATUS_ACCESS_DENIED; } - set = &q_u->set; + set = r->in.privs; if ( !privilege_set_to_se_priv( &mask, set ) ) return NT_STATUS_NO_SUCH_PRIVILEGE; if ( !revoke_privilege( &info->sid, &mask ) ) { - DEBUG(3,("_lsa_removeprivs: revoke_privilege(%s) failed!\n", + DEBUG(3,("_lsa_RemovePrivilegesFromAccount: revoke_privilege(%s) failed!\n", sid_string_dbg(&info->sid) )); DEBUG(3,("Privilege mask:\n")); dump_se_priv( DBGC_ALL, 3, &mask ); @@ -2277,18 +2280,6 @@ NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_AddPrivilegesToAccount(pipes_struct *p, struct lsa_AddPrivilegesToAccount *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - -NTSTATUS _lsa_RemovePrivilegesFromAccount(pipes_struct *p, struct lsa_RemovePrivilegesFromAccount *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_GetQuotasForAccount(pipes_struct *p, struct lsa_GetQuotasForAccount *r) { p->rng_fault_state = True; -- cgit From b9bc1ac1b92f993a71f6eb64b15f486538bf50d7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 14:21:49 +0100 Subject: Use pidl for _lsa_AddAccountRights(). Guenther (This used to be commit 253cf1523871f2218e9e59b0a01f47b8bc745ac9) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 34 ++++++++++------------------------ 2 files changed, 11 insertions(+), 47 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index ff274473d6..33686e575f 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -276,29 +276,7 @@ static bool api_lsa_query_secobj(pipes_struct *p) static bool api_lsa_add_acct_rights(pipes_struct *p) { - LSA_Q_ADD_ACCT_RIGHTS q_u; - LSA_R_ADD_ACCT_RIGHTS r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_add_acct_rights("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_add_acct_rights: failed to unmarshall LSA_Q_ADD_ACCT_RIGHTS.\n")); - return False; - } - - r_u.status = _lsa_add_acct_rights(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_add_acct_rights("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_add_acct_rights: Failed to marshall LSA_R_ADD_ACCT_RIGHTS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_ADDACCOUNTRIGHTS); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 10842a1ada..0be72c5d75 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -2042,19 +2042,18 @@ NTSTATUS _lsa_QuerySecurity(pipes_struct *p, #endif /* AD DC work in ongoing in Samba 4 */ /*************************************************************************** + _lsa_AddAccountRights ***************************************************************************/ -NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R_ADD_ACCT_RIGHTS *r_u) +NTSTATUS _lsa_AddAccountRights(pipes_struct *p, + struct lsa_AddAccountRights *r) { struct lsa_info *info = NULL; int i = 0; DOM_SID sid; - fstring privname; - UNISTR4_ARRAY *uni_privnames = q_u->rights; - /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is a Domain Admin since @@ -2069,27 +2068,20 @@ NTSTATUS _lsa_add_acct_rights(pipes_struct *p, LSA_Q_ADD_ACCT_RIGHTS *q_u, LSA_R /* according to an NT4 PDC, you can add privileges to SIDs even without call_lsa_create_account() first. And you can use any arbitrary SID. */ - sid_copy( &sid, &q_u->sid.sid ); + sid_copy( &sid, r->in.sid ); - /* just a little sanity check */ - - if ( q_u->count != uni_privnames->count ) { - DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n")); - return NT_STATUS_INVALID_HANDLE; - } + for ( i=0; i < r->in.rights->count; i++ ) { - for ( i=0; icount; i++ ) { - UNISTR4 *uni4_str = &uni_privnames->strings[i]; + const char *privname = r->in.rights->names[i].string; /* only try to add non-null strings */ - if ( !uni4_str->string ) + if ( !privname ) continue; - rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE ); - if ( !grant_privilege_by_name( &sid, privname ) ) { - DEBUG(2,("_lsa_add_acct_rights: Failed to add privilege [%s]\n", privname )); + DEBUG(2,("_lsa_AddAccountRights: Failed to add privilege [%s]\n", + privname )); return NT_STATUS_NO_SUCH_PRIVILEGE; } } @@ -2328,12 +2320,6 @@ NTSTATUS _lsa_EnumAccountRights(pipes_struct *p, struct lsa_EnumAccountRights *r return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_AddAccountRights(pipes_struct *p, struct lsa_AddAccountRights *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p, struct lsa_RemoveAccountRights *r) { p->rng_fault_state = True; -- cgit From 41b574783d4bdb86ee5c4a826d85705786948843 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 15:02:31 +0100 Subject: Use pidl for _lsa_EnumAccountRights(). Guenther (This used to be commit cb6a84712cf91d104206356f0ac256a071868d66) --- source3/rpc_server/srv_lsa.c | 24 +-------------- source3/rpc_server/srv_lsa_nt.c | 67 +++++++++++++++++++++++++++++++---------- 2 files changed, 52 insertions(+), 39 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 33686e575f..14cf0b3cc9 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -316,29 +316,7 @@ static bool api_lsa_remove_acct_rights(pipes_struct *p) static bool api_lsa_enum_acct_rights(pipes_struct *p) { - LSA_Q_ENUM_ACCT_RIGHTS q_u; - LSA_R_ENUM_ACCT_RIGHTS r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_enum_acct_rights("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_enum_acct_rights: failed to unmarshall LSA_Q_ENUM_ACCT_RIGHTS.\n")); - return False; - } - - r_u.status = _lsa_enum_acct_rights(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_enum_acct_rights("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_enum_acct_rights: Failed to marshall LSA_R_ENUM_ACCT_RIGHTS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_ENUMACCOUNTRIGHTS); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 0be72c5d75..a709877d6e 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -2149,27 +2149,69 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, return NT_STATUS_OK; } +/******************************************************************* +********************************************************************/ + +static NTSTATUS init_lsa_right_set(TALLOC_CTX *mem_ctx, + struct lsa_RightSet *r, + PRIVILEGE_SET *privileges) +{ + uint32 i; + const char *privname; + const char **privname_array = NULL; + int num_priv = 0; + + for (i=0; icount; i++) { + + privname = luid_to_privilege_name(&privileges->set[i].luid); + if (privname) { + if (!add_string_to_array(mem_ctx, privname, + &privname_array, &num_priv)) { + return NT_STATUS_NO_MEMORY; + } + } + } + + if (num_priv) { + + r->names = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_StringLarge, + num_priv); + if (!r->names) { + return NT_STATUS_NO_MEMORY; + } + + for (i=0; inames[i], privname_array[i]); + } + + r->count = num_priv; + } + + return NT_STATUS_OK; +} /*************************************************************************** + _lsa_EnumAccountRights ***************************************************************************/ -NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA_R_ENUM_ACCT_RIGHTS *r_u) +NTSTATUS _lsa_EnumAccountRights(pipes_struct *p, + struct lsa_EnumAccountRights *r) { + NTSTATUS status; struct lsa_info *info = NULL; DOM_SID sid; PRIVILEGE_SET privileges; SE_PRIV mask; - /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* according to an NT4 PDC, you can add privileges to SIDs even without call_lsa_create_account() first. And you can use any arbitrary SID. */ - sid_copy( &sid, &q_u->sid.sid ); + sid_copy( &sid, r->in.sid ); if ( !get_privileges_for_sids( &mask, &sid, 1 ) ) return NT_STATUS_OBJECT_NAME_NOT_FOUND; @@ -2178,20 +2220,19 @@ NTSTATUS _lsa_enum_acct_rights(pipes_struct *p, LSA_Q_ENUM_ACCT_RIGHTS *q_u, LSA if ( se_priv_to_privilege_set( &privileges, &mask ) ) { - DEBUG(10,("_lsa_enum_acct_rights: %s has %d privileges\n", + DEBUG(10,("_lsa_EnumAccountRights: %s has %d privileges\n", sid_string_dbg(&sid), privileges.count)); - r_u->status = init_r_enum_acct_rights( r_u, &privileges ); + status = init_lsa_right_set(p->mem_ctx, r->out.rights, &privileges); + } else { + status = NT_STATUS_NO_SUCH_PRIVILEGE; } - else - r_u->status = NT_STATUS_NO_SUCH_PRIVILEGE; privilege_set_free( &privileges ); - return r_u->status; + return status; } - /*************************************************************************** _lsa_LookupPrivValue ***************************************************************************/ @@ -2314,12 +2355,6 @@ NTSTATUS _lsa_EnumAccountsWithUserRight(pipes_struct *p, struct lsa_EnumAccounts return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_EnumAccountRights(pipes_struct *p, struct lsa_EnumAccountRights *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p, struct lsa_RemoveAccountRights *r) { p->rng_fault_state = True; -- cgit From 10462a5a795fe357c6487a85fedcb23adf8ab886 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 15:20:18 +0100 Subject: Use pidl for _lsa_RemoveAccountRights. Guenther (This used to be commit 39f8508f5d978a936779fdfd51b90fec4faa4301) --- source3/rpc_server/srv_lsa.c | 24 +----------------------- source3/rpc_server/srv_lsa_nt.c | 37 ++++++++++++------------------------- 2 files changed, 13 insertions(+), 48 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index 14cf0b3cc9..dfb3323873 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -285,29 +285,7 @@ static bool api_lsa_add_acct_rights(pipes_struct *p) static bool api_lsa_remove_acct_rights(pipes_struct *p) { - LSA_Q_REMOVE_ACCT_RIGHTS q_u; - LSA_R_REMOVE_ACCT_RIGHTS r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_remove_acct_rights("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_remove_acct_rights: failed to unmarshall LSA_Q_REMOVE_ACCT_RIGHTS.\n")); - return False; - } - - r_u.status = _lsa_remove_acct_rights(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_remove_acct_rights("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_remove_acct_rights: Failed to marshall LSA_R_REMOVE_ACCT_RIGHTS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_REMOVEACCOUNTRIGHTS); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index a709877d6e..027277e8d9 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -2090,19 +2090,19 @@ NTSTATUS _lsa_AddAccountRights(pipes_struct *p, } /*************************************************************************** + _lsa_RemoveAccountRights ***************************************************************************/ -NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, LSA_R_REMOVE_ACCT_RIGHTS *r_u) +NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p, + struct lsa_RemoveAccountRights *r) { struct lsa_info *info = NULL; int i = 0; DOM_SID sid; - fstring privname; - UNISTR4_ARRAY *uni_privnames = q_u->rights; - + const char *privname = NULL; /* find the connection policy handle. */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; /* check to see if the pipe_user is a Domain Admin since @@ -2114,34 +2114,27 @@ NTSTATUS _lsa_remove_acct_rights(pipes_struct *p, LSA_Q_REMOVE_ACCT_RIGHTS *q_u, return NT_STATUS_ACCESS_DENIED; } - sid_copy( &sid, &q_u->sid.sid ); + sid_copy( &sid, r->in.sid ); - if ( q_u->removeall ) { + if ( r->in.remove_all ) { if ( !revoke_all_privileges( &sid ) ) return NT_STATUS_ACCESS_DENIED; return NT_STATUS_OK; } - /* just a little sanity check */ - - if ( q_u->count != uni_privnames->count ) { - DEBUG(0,("_lsa_add_acct_rights: count != number of UNISTR2 elements!\n")); - return NT_STATUS_INVALID_HANDLE; - } + for ( i=0; i < r->in.rights->count; i++ ) { - for ( i=0; icount; i++ ) { - UNISTR4 *uni4_str = &uni_privnames->strings[i]; + privname = r->in.rights->names[i].string; /* only try to add non-null strings */ - if ( !uni4_str->string ) + if ( !privname ) continue; - rpcstr_pull( privname, uni4_str->string->buffer, sizeof(privname), -1, STR_TERMINATE ); - if ( !revoke_privilege_by_name( &sid, privname ) ) { - DEBUG(2,("_lsa_remove_acct_rights: Failed to revoke privilege [%s]\n", privname )); + DEBUG(2,("_lsa_RemoveAccountRights: Failed to revoke privilege [%s]\n", + privname )); return NT_STATUS_NO_SUCH_PRIVILEGE; } } @@ -2355,12 +2348,6 @@ NTSTATUS _lsa_EnumAccountsWithUserRight(pipes_struct *p, struct lsa_EnumAccounts return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_RemoveAccountRights(pipes_struct *p, struct lsa_RemoveAccountRights *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_QueryTrustedDomainInfoBySid(pipes_struct *p, struct lsa_QueryTrustedDomainInfoBySid *r) { p->rng_fault_state = True; -- cgit From ba9499e8dcdebda06ff1a3a38ad601011151410e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 14 Feb 2008 18:08:23 -0800 Subject: Currently we don't SPNEGO negotiate back to NTLMSSP. Note this. Jeremy. (This used to be commit 67768fc71f9bd7ff3d61acc50360356b524ae923) --- source3/rpc_server/srv_pipe.c | 55 +++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 06694a2701..a671f89238 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1105,7 +1105,7 @@ static bool pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_ char *OIDs[ASN1_MAX_OIDS]; int i; NTSTATUS status; - bool got_kerberos_mechanism = False; + bool got_kerberos_mechanism = false; AUTH_NTLMSSP_STATE *a = NULL; RPC_HDR_AUTH auth_info; @@ -1133,7 +1133,7 @@ static bool pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_ } if (strcmp(OID_KERBEROS5, OIDs[0]) == 0 || strcmp(OID_KERBEROS5_OLD, OIDs[0]) == 0) { - got_kerberos_mechanism = True; + got_kerberos_mechanism = true; } for (i=0;OIDs[i];i++) { @@ -1154,27 +1154,38 @@ static bool pipe_spnego_auth_bind_negotiate(pipes_struct *p, prs_struct *rpc_in_ free_pipe_ntlmssp_auth_data(&p->auth); } - /* Initialize the NTLM engine. */ - status = auth_ntlmssp_start(&a); - if (!NT_STATUS_IS_OK(status)) { - goto err; - } + if (!got_kerberos_mechanism) { + /* Initialize the NTLM engine. */ + status = auth_ntlmssp_start(&a); + if (!NT_STATUS_IS_OK(status)) { + goto err; + } - /* - * Pass the first security blob of data to it. - * This can return an error or NT_STATUS_MORE_PROCESSING_REQUIRED - * which means we need another packet to complete the bind. - */ + /* + * Pass the first security blob of data to it. + * This can return an error or NT_STATUS_MORE_PROCESSING_REQUIRED + * which means we need another packet to complete the bind. + */ - status = auth_ntlmssp_update(a, secblob, &chal); + status = auth_ntlmssp_update(a, secblob, &chal); - if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { - DEBUG(3,("pipe_spnego_auth_bind_negotiate: auth_ntlmssp_update failed.\n")); - goto err; - } + if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { + DEBUG(3,("pipe_spnego_auth_bind_negotiate: auth_ntlmssp_update failed.\n")); + goto err; + } - /* Generate the response blob we need for step 2 of the bind. */ - response = spnego_gen_auth_response(&chal, status, OID_NTLMSSP); + /* Generate the response blob we need for step 2 of the bind. */ + response = spnego_gen_auth_response(&chal, status, OID_NTLMSSP); + } else { + /* + * SPNEGO negotiate down to NTLMSSP. The subsequent + * code to process follow-up packets is not complete + * yet. JRA. + */ + response = spnego_gen_auth_response(NULL, + NT_STATUS_MORE_PROCESSING_REQUIRED, + OID_NTLMSSP); + } /* Copy the blob into the pout_auth parse struct */ init_rpc_hdr_auth(&auth_info, RPC_SPNEGO_AUTH_TYPE, pauth_info->auth_level, RPC_HDR_AUTH_LEN, 1); @@ -1231,6 +1242,10 @@ static bool pipe_spnego_auth_bind_continue(pipes_struct *p, prs_struct *rpc_in_p ZERO_STRUCT(auth_reply); ZERO_STRUCT(response); + /* + * NB. If we've negotiated down from krb5 to NTLMSSP we'll currently + * fail here as 'a' == NULL. + */ if (p->auth.auth_type != PIPE_AUTH_TYPE_SPNEGO_NTLMSSP || !a) { DEBUG(0,("pipe_spnego_auth_bind_continue: not in NTLMSSP auth state.\n")); goto err; @@ -1259,7 +1274,7 @@ static bool pipe_spnego_auth_bind_continue(pipes_struct *p, prs_struct *rpc_in_p * The following call actually checks the challenge/response data. * for correctness against the given DOMAIN\user name. */ - + if (!pipe_ntlmssp_verify_final(p, &auth_blob)) { goto err; } -- cgit From c720a0e228bd157b8c743f8b98cc63817650d364 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 15:14:20 +0100 Subject: Move implementation of _winreg_SaveKey() from srv_winreg_nt.c to reg_api.c This gives a new function reg_savekey() and hides a piece of the backend code from srv_winreg_nt.c. One step towards using reg_api throughout samba code. Michael (This used to be commit bf6340d00dd631fdc909c20632250977a3a112c4) --- source3/rpc_server/srv_winreg_nt.c | 171 +------------------------------------ 1 file changed, 1 insertion(+), 170 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 92c178042f..c6447b4556 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -26,9 +26,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV -static const struct generic_mapping reg_generic_map = - { REG_KEY_READ, REG_KEY_WRITE, REG_KEY_EXECUTE, REG_KEY_ALL }; - /****************************************************************** free() function for struct registry_key *****************************************************************/ @@ -810,172 +807,6 @@ WERROR _winreg_RestoreKey(pipes_struct *p, struct winreg_RestoreKey *r) return restore_registry_key( regkey->key, fname ); } -/******************************************************************** -********************************************************************/ - -static WERROR reg_write_tree( REGF_FILE *regfile, const char *keypath, - REGF_NK_REC *parent, SEC_DESC *sec_desc ) -{ - REGF_NK_REC *key; - REGVAL_CTR *values; - REGSUBKEY_CTR *subkeys; - int i, num_subkeys; - char *key_tmp = NULL; - char *keyname, *parentpath; - char *subkeypath = NULL; - char *subkeyname; - REGISTRY_KEY registry_key; - WERROR result = WERR_OK; - - if (!regfile) - return WERR_GENERAL_FAILURE; - - if (!keypath) - return WERR_OBJECT_PATH_INVALID; - - /* split up the registry key path */ - - key_tmp = talloc_strdup(regfile->mem_ctx, keypath); - if (!key_tmp) { - return WERR_NOMEM; - } - if (!reg_split_key( key_tmp, &parentpath, &keyname ) ) - return WERR_OBJECT_PATH_INVALID; - - if ( !keyname ) - keyname = parentpath; - - /* we need a REGISTRY_KEY object here to enumerate subkeys and values */ - - ZERO_STRUCT( registry_key ); - - if ( (registry_key.name = talloc_strdup(regfile->mem_ctx, keypath)) == NULL ) - return WERR_NOMEM; - - if ( (registry_key.hook = reghook_cache_find( registry_key.name )) == NULL ) - return WERR_BADFILE; - - /* lookup the values and subkeys */ - - if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) - return WERR_NOMEM; - - if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) - return WERR_NOMEM; - - fetch_reg_keys( ®istry_key, subkeys ); - fetch_reg_values( ®istry_key, values ); - - /* write out this key */ - - if ( !(key = regfio_write_key( regfile, keyname, values, subkeys, sec_desc, parent )) ) { - result = WERR_CAN_NOT_COMPLETE; - goto done; - } - - /* write each one of the subkeys out */ - - num_subkeys = regsubkey_ctr_numkeys( subkeys ); - for ( i=0; imem_ctx, - "%s\\%s", keypath, subkeyname); - if (!subkeypath) { - result = WERR_NOMEM; - goto done; - } - result = reg_write_tree( regfile, subkeypath, key, sec_desc ); - if ( !W_ERROR_IS_OK(result) ) - goto done; - } - - DEBUG(6,("reg_write_tree: wrote key [%s]\n", keypath )); - -done: - TALLOC_FREE( subkeys ); - TALLOC_FREE( registry_key.name ); - - return result; -} - -/******************************************************************* - ********************************************************************/ - -static WERROR make_default_reg_sd( TALLOC_CTX *ctx, SEC_DESC **psd ) -{ - DOM_SID adm_sid, owner_sid; - SEC_ACE ace[2]; /* at most 2 entries */ - SEC_ACCESS mask; - SEC_ACL *psa = NULL; - size_t sd_size; - - /* set the owner to BUILTIN\Administrator */ - - sid_copy(&owner_sid, &global_sid_Builtin); - sid_append_rid(&owner_sid, DOMAIN_USER_RID_ADMIN ); - - - /* basic access for Everyone */ - - init_sec_access(&mask, reg_generic_map.generic_execute | reg_generic_map.generic_read ); - init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /* add Full Access 'BUILTIN\Administrators' */ - - init_sec_access(&mask, reg_generic_map.generic_all); - sid_copy(&adm_sid, &global_sid_Builtin); - sid_append_rid(&adm_sid, BUILTIN_ALIAS_RID_ADMINS); - init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - /* create the security descriptor */ - - if ((psa = make_sec_acl(ctx, NT4_ACL_REVISION, 2, ace)) == NULL) - return WERR_NOMEM; - - if ((*psd = make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1, - SEC_DESC_SELF_RELATIVE, &owner_sid, NULL, - NULL, psa, &sd_size)) == NULL) - return WERR_NOMEM; - - return WERR_OK; -} - -/******************************************************************* - ********************************************************************/ - -static WERROR backup_registry_key ( REGISTRY_KEY *krecord, const char *fname ) -{ - REGF_FILE *regfile; - WERROR result; - SEC_DESC *sd = NULL; - - /* open the registry file....fail if the file already exists */ - - if ( !(regfile = regfio_open( fname, (O_RDWR|O_CREAT|O_EXCL), (S_IREAD|S_IWRITE) )) ) { - DEBUG(0,("backup_registry_key: failed to open \"%s\" (%s)\n", - fname, strerror(errno) )); - return ( ntstatus_to_werror(map_nt_error_from_unix( errno )) ); - } - - if ( !W_ERROR_IS_OK(result = make_default_reg_sd( regfile->mem_ctx, &sd )) ) { - regfio_close( regfile ); - return result; - } - - /* write the registry tree to the file */ - - result = reg_write_tree( regfile, krecord->name, NULL, sd ); - - /* cleanup */ - - regfio_close( regfile ); - - return result; -} - -/******************************************************************* - ********************************************************************/ - WERROR _winreg_SaveKey(pipes_struct *p, struct winreg_SaveKey *r) { struct registry_key *regkey = find_regkey_by_hnd( p, r->in.handle ); @@ -1002,7 +833,7 @@ WERROR _winreg_SaveKey(pipes_struct *p, struct winreg_SaveKey *r) DEBUG(2,("_winreg_SaveKey: Saving [%s] to %s in share %s\n", regkey->key->name, fname, lp_servicename(snum) )); - return backup_registry_key( regkey->key, fname ); + return reg_savekey(regkey, fname); } /******************************************************************* -- cgit From 355faf2e3d0aa83401c63e70a5aff9c9f5466195 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 15 Feb 2008 15:31:31 +0100 Subject: Move the implementation of _winreg_RestoreKey to reg_api.c This removes the internals of reg_api from srv_winreg_nt.c entirely, only reg_api is used there, now. This enlarges the dependencies of reg_api somewhat now since it adds regfio. But this can be separated out later. The current goal is to achieve a complete use of reg_api. Michael (This used to be commit 2222acbac955cd6d5bd48d1ce5cf4b4c7c067093) --- source3/rpc_server/srv_winreg_nt.c | 122 +------------------------------------ 1 file changed, 1 insertion(+), 121 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index c6447b4556..5d18419c75 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -21,7 +21,6 @@ /* Implementation of registry functions. */ #include "includes.h" -#include "regfio.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV @@ -651,125 +650,6 @@ static int validate_reg_filename(TALLOC_CTX *ctx, char **pp_fname ) return (snum < num_services) ? snum : -1; } -/******************************************************************* - Note: topkeypat is the *full* path that this *key will be - loaded into (including the name of the key) - ********************************************************************/ - -static WERROR reg_load_tree( REGF_FILE *regfile, const char *topkeypath, - REGF_NK_REC *key ) -{ - REGF_NK_REC *subkey; - REGISTRY_KEY registry_key; - REGVAL_CTR *values; - REGSUBKEY_CTR *subkeys; - int i; - char *path = NULL; - WERROR result = WERR_OK; - - /* initialize the REGISTRY_KEY structure */ - - if ( !(registry_key.hook = reghook_cache_find(topkeypath)) ) { - DEBUG(0,("reg_load_tree: Failed to assigned a REGISTRY_HOOK to [%s]\n", - topkeypath )); - return WERR_BADFILE; - } - - registry_key.name = talloc_strdup( regfile->mem_ctx, topkeypath ); - if ( !registry_key.name ) { - DEBUG(0,("reg_load_tree: Talloc failed for reg_key.name!\n")); - return WERR_NOMEM; - } - - /* now start parsing the values and subkeys */ - - if ( !(subkeys = TALLOC_ZERO_P( regfile->mem_ctx, REGSUBKEY_CTR )) ) - return WERR_NOMEM; - - if ( !(values = TALLOC_ZERO_P( subkeys, REGVAL_CTR )) ) - return WERR_NOMEM; - - /* copy values into the REGVAL_CTR */ - - for ( i=0; inum_values; i++ ) { - regval_ctr_addvalue( values, key->values[i].valuename, key->values[i].type, - (char*)key->values[i].data, (key->values[i].data_size & ~VK_DATA_IN_OFFSET) ); - } - - /* copy subkeys into the REGSUBKEY_CTR */ - - key->subkey_index = 0; - while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { - regsubkey_ctr_addkey( subkeys, subkey->keyname ); - } - - /* write this key and values out */ - - if ( !store_reg_values( ®istry_key, values ) - || !store_reg_keys( ®istry_key, subkeys ) ) - { - DEBUG(0,("reg_load_tree: Failed to load %s!\n", topkeypath)); - result = WERR_REG_IO_FAILURE; - } - - TALLOC_FREE( subkeys ); - - if ( !W_ERROR_IS_OK(result) ) - return result; - - /* now continue to load each subkey registry tree */ - - key->subkey_index = 0; - while ( (subkey = regfio_fetch_subkey( regfile, key )) ) { - path = talloc_asprintf(regfile->mem_ctx, - "%s\\%s", - topkeypath, - subkey->keyname); - if (!path) { - return WERR_NOMEM; - } - result = reg_load_tree( regfile, path, subkey ); - if ( !W_ERROR_IS_OK(result) ) - break; - } - - return result; -} - -/******************************************************************* - ********************************************************************/ - -static WERROR restore_registry_key ( REGISTRY_KEY *krecord, const char *fname ) -{ - REGF_FILE *regfile; - REGF_NK_REC *rootkey; - WERROR result; - - /* open the registry file....fail if the file already exists */ - - if ( !(regfile = regfio_open( fname, (O_RDONLY), 0 )) ) { - DEBUG(0,("restore_registry_key: failed to open \"%s\" (%s)\n", - fname, strerror(errno) )); - return ( ntstatus_to_werror(map_nt_error_from_unix( errno )) ); - } - - /* get the rootkey from the regf file and then load the tree - via recursive calls */ - - if ( !(rootkey = regfio_rootkey( regfile )) ) { - regfio_close( regfile ); - return WERR_REG_FILE_INVALID; - } - - result = reg_load_tree( regfile, krecord->name, rootkey ); - - /* cleanup */ - - regfio_close( regfile ); - - return result; -} - /******************************************************************* ********************************************************************/ @@ -804,7 +684,7 @@ WERROR _winreg_RestoreKey(pipes_struct *p, struct winreg_RestoreKey *r) DEBUG(2,("_winreg_RestoreKey: Restoring [%s] from %s in share %s\n", regkey->key->name, fname, lp_servicename(snum) )); - return restore_registry_key( regkey->key, fname ); + return reg_restorekey(regkey, fname); } WERROR _winreg_SaveKey(pipes_struct *p, struct winreg_SaveKey *r) -- cgit From 4f0b904538b376ed117fc23b6e34fbed37141437 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 21:13:50 +0100 Subject: Use pidl for _netr_ServerPasswordSet(). Guenther (This used to be commit 85b7489dd2e8181ee48caa8273020885a08bbb74) --- source3/rpc_server/srv_netlog.c | 24 +--------------- source3/rpc_server/srv_netlog_nt.c | 58 ++++++++++++-------------------------- 2 files changed, 19 insertions(+), 63 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 791752c5d0..60688d201d 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -126,29 +126,7 @@ static bool api_net_auth_2(pipes_struct *p) static bool api_net_srv_pwset(pipes_struct *p) { - NET_Q_SRV_PWSET q_u; - NET_R_SRV_PWSET r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the challenge and encrypted password ... */ - if(!net_io_q_srv_pwset("", &q_u, data, 0)) { - DEBUG(0,("api_net_srv_pwset: Failed to unmarshall NET_Q_SRV_PWSET.\n")); - return False; - } - - r_u.status = _net_srv_pwset(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_srv_pwset("", &r_u, rdata, 0)) { - DEBUG(0,("api_net_srv_pwset: Failed to marshall NET_R_SRV_PWSET.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_SERVERPASSWORDSET); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 3cfab7843d..bb346650f2 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -255,21 +255,6 @@ WERROR _netr_NetrEnumerateTrustedDomains(pipes_struct *p, return WERR_OK; } -/*********************************************************************************** - init_net_r_srv_pwset: - ***********************************************************************************/ - -static void init_net_r_srv_pwset(NET_R_SRV_PWSET *r_s, - DOM_CRED *srv_cred, NTSTATUS status) -{ - DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); - - memcpy(&r_s->srv_cred, srv_cred, sizeof(r_s->srv_cred)); - r_s->status = status; - - DEBUG(5,("init_net_r_srv_pwset: %d\n", __LINE__)); -} - /****************************************************************** gets a machine password entry. checks access rights of the host. ******************************************************************/ @@ -577,31 +562,32 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) } /************************************************************************* - _net_srv_pwset + _netr_ServerPasswordSet *************************************************************************/ -NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *r_u) +NTSTATUS _netr_ServerPasswordSet(pipes_struct *p, + struct netr_ServerPasswordSet *r) { + NTSTATUS status = NT_STATUS_OK; fstring remote_machine; struct samu *sampass=NULL; bool ret = False; unsigned char pwd[16]; int i; uint32 acct_ctrl; - DOM_CRED cred_out; + struct netr_Authenticator cred_out; const uchar *old_pw; - DEBUG(5,("_net_srv_pwset: %d\n", __LINE__)); + DEBUG(5,("_netr_ServerPasswordSet: %d\n", __LINE__)); /* We need the remote machine name for the creds lookup. */ - rpcstr_pull(remote_machine,q_u->clnt_id.login.uni_comp_name.buffer, - sizeof(remote_machine),q_u->clnt_id.login.uni_comp_name.uni_str_len*2,0); + fstrcpy(remote_machine, r->in.computer_name); if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { /* 'server schannel = yes' should enforce use of schannel, the client did offer it in auth2, but obviously did not use it. */ - DEBUG(0,("_net_srv_pwset: client %s not using schannel for netlogon\n", + DEBUG(0,("_netr_ServerPasswordSet: client %s not using schannel for netlogon\n", remote_machine )); return NT_STATUS_ACCESS_DENIED; } @@ -622,12 +608,12 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * return NT_STATUS_INVALID_HANDLE; } - DEBUG(3,("_net_srv_pwset: Server Password Set by remote machine:[%s] on account [%s]\n", + DEBUG(3,("_netr_ServerPasswordSet: Server Password Set by remote machine:[%s] on account [%s]\n", remote_machine, p->dc->mach_acct)); /* Step the creds chain forward. */ - if (!creds_server_step(p->dc, &q_u->clnt_id.cred, &cred_out)) { - DEBUG(2,("_net_srv_pwset: creds_server_step failed. Rejecting auth " + if (!netlogon_creds_server_step(p->dc, r->in.credential, &cred_out)) { + DEBUG(2,("_netr_ServerPasswordSet: netlogon_creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", remote_machine, p->dc->mach_acct )); return NT_STATUS_INVALID_PARAMETER; @@ -668,9 +654,9 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * } /* Woah - what does this to to the credential chain ? JRA */ - cred_hash3( pwd, q_u->pwd, p->dc->sess_key, 0); + cred_hash3(pwd, r->in.new_password->hash, p->dc->sess_key, 0); - DEBUG(100,("Server password set : new given value was :\n")); + DEBUG(100,("_netr_ServerPasswordSet: new given value was :\n")); for(i = 0; i < sizeof(pwd); i++) DEBUG(100,("%02X ", pwd[i])); DEBUG(100,("\n")); @@ -702,15 +688,17 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET * } become_root(); - r_u->status = pdb_update_sam_account(sampass); + status = pdb_update_sam_account(sampass); unbecome_root(); } /* set up the LSA Server Password Set response */ - init_net_r_srv_pwset(r_u, &cred_out, r_u->status); + + memcpy(r->out.return_authenticator, &cred_out, + sizeof(r->out.return_authenticator)); TALLOC_FREE(sampass); - return r_u->status; + return status; } /************************************************************************* @@ -1283,16 +1271,6 @@ NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _netr_ServerPasswordSet(pipes_struct *p, - struct netr_ServerPasswordSet *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _netr_DatabaseDeltas(pipes_struct *p, struct netr_DatabaseDeltas *r) { -- cgit From 55b2292abace1d12b04fb47a61daab26923f887c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 21:24:39 +0100 Subject: Use pidl for _netr_ServerAuthenticate(). Guenther (This used to be commit 943386c5dd601f5c8cf85bfcb08f731dd5a6437d) --- source3/rpc_server/srv_netlog.c | 24 +-------------- source3/rpc_server/srv_netlog_nt.c | 62 ++++++++++++++------------------------ 2 files changed, 23 insertions(+), 63 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 60688d201d..7f67fe51f0 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -64,29 +64,7 @@ static bool api_net_req_chal(pipes_struct *p) static bool api_net_auth(pipes_struct *p) { - NET_Q_AUTH q_u; - NET_R_AUTH r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the challenge... */ - if(!net_io_q_auth("", &q_u, data, 0)) { - DEBUG(0,("api_net_auth: Failed to unmarshall NET_Q_AUTH.\n")); - return False; - } - - r_u.status = _net_auth(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_auth("", &r_u, rdata, 0)) { - DEBUG(0,("api_net_auth: Failed to marshall NET_R_AUTH.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_SERVERAUTHENTICATE); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index bb346650f2..2b4921921f 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -259,7 +259,7 @@ WERROR _netr_NetrEnumerateTrustedDomains(pipes_struct *p, gets a machine password entry. checks access rights of the host. ******************************************************************/ -static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type) +static NTSTATUS get_md4pw(char *md4pw, const char *mach_acct, uint16 sec_chan_type) { struct samu *sampass = NULL; const uint8 *pass; @@ -398,41 +398,30 @@ NTSTATUS _netr_ServerReqChallenge(pipes_struct *p, } /************************************************************************* - init_net_r_auth: + _netr_ServerAuthenticate + Create the initial credentials. *************************************************************************/ -static void init_net_r_auth(NET_R_AUTH *r_a, DOM_CHAL *resp_cred, NTSTATUS status) -{ - memcpy(r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); - r_a->status = status; -} - -/************************************************************************* - _net_auth. Create the initial credentials. - *************************************************************************/ - -NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) +NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, + struct netr_ServerAuthenticate *r) { NTSTATUS status; - fstring mach_acct; - fstring remote_machine; DOM_CHAL srv_chal_out; if (!p->dc || !p->dc->challenge_sent) { return NT_STATUS_ACCESS_DENIED; } - rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring), - q_u->clnt_id.uni_acct_name.uni_str_len*2,0); - rpcstr_pull(remote_machine, q_u->clnt_id.uni_comp_name.buffer,sizeof(fstring), - q_u->clnt_id.uni_comp_name.uni_str_len*2,0); - - status = get_md4pw((char *)p->dc->mach_pw, mach_acct, q_u->clnt_id.sec_chan); + status = get_md4pw((char *)p->dc->mach_pw, + r->in.account_name, + r->in.secure_channel_type); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("_net_auth: creds_server_check failed. Failed to " + DEBUG(0,("_netr_ServerAuthenticate: get_md4pw failed. Failed to " "get password for machine account %s " "from client %s: %s\n", - mach_acct, remote_machine, nt_errstr(status) )); + r->in.account_name, + r->in.computer_name, + nt_errstr(status) )); /* always return NT_STATUS_ACCESS_DENIED */ return NT_STATUS_ACCESS_DENIED; } @@ -446,22 +435,25 @@ NTSTATUS _net_auth(pipes_struct *p, NET_Q_AUTH *q_u, NET_R_AUTH *r_u) &srv_chal_out); /* Check client credentials are valid. */ - if (!creds_server_check(p->dc, &q_u->clnt_chal)) { - DEBUG(0,("_net_auth: creds_server_check failed. Rejecting auth " + if (!netlogon_creds_server_check(p->dc, r->in.credentials)) { + DEBUG(0,("_netr_ServerAuthenticate: netlogon_creds_server_check failed. Rejecting auth " "request from client %s machine account %s\n", - remote_machine, mach_acct )); + r->in.computer_name, + r->in.account_name)); return NT_STATUS_ACCESS_DENIED; } - fstrcpy(p->dc->mach_acct, mach_acct); - fstrcpy(p->dc->remote_machine, remote_machine); + fstrcpy(p->dc->mach_acct, r->in.account_name); + fstrcpy(p->dc->remote_machine, r->in.computer_name); p->dc->authenticated = True; /* set up the LSA AUTH response */ /* Return the server credentials. */ - init_net_r_auth(r_u, &srv_chal_out, NT_STATUS_OK); - return r_u->status; + memcpy(r->out.credentials->data, &srv_chal_out.data, + sizeof(r->out.credentials->data)); + + return NT_STATUS_OK; } /************************************************************************* @@ -1261,16 +1253,6 @@ NTSTATUS _netr_LogonSamLogoff(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, - struct netr_ServerAuthenticate *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _netr_DatabaseDeltas(pipes_struct *p, struct netr_DatabaseDeltas *r) { -- cgit From c9f1f3d5ff07224e0da3df759215e7680893812e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 21:41:16 +0100 Subject: Use pidl for _netr_ServerAuthenticate2(). Guenther (This used to be commit 5d81cc136bcd8f53bedea6de5380b1147862c391) --- source3/rpc_server/srv_netlog.c | 24 +---------- source3/rpc_server/srv_netlog_nt.c | 88 ++++++++++++++------------------------ 2 files changed, 34 insertions(+), 78 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 7f67fe51f0..719cdff41c 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -73,29 +73,7 @@ static bool api_net_auth(pipes_struct *p) static bool api_net_auth_2(pipes_struct *p) { - NET_Q_AUTH_2 q_u; - NET_R_AUTH_2 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the challenge... */ - if(!net_io_q_auth_2("", &q_u, data, 0)) { - DEBUG(0,("api_net_auth_2: Failed to unmarshall NET_Q_AUTH_2.\n")); - return False; - } - - r_u.status = _net_auth_2(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_auth_2("", &r_u, rdata, 0)) { - DEBUG(0,("api_net_auth_2: Failed to marshall NET_R_AUTH_2.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_SERVERAUTHENTICATE2); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 2b4921921f..c11ada2461 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -457,63 +457,48 @@ NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, } /************************************************************************* - init_net_r_auth_2: + _netr_ServerAuthenticate2 *************************************************************************/ -static void init_net_r_auth_2(NET_R_AUTH_2 *r_a, - DOM_CHAL *resp_cred, NEG_FLAGS *flgs, NTSTATUS status) -{ - memcpy(r_a->srv_chal.data, resp_cred->data, sizeof(resp_cred->data)); - memcpy(&r_a->srv_flgs, flgs, sizeof(r_a->srv_flgs)); - r_a->status = status; -} - -/************************************************************************* - _net_auth_2 - *************************************************************************/ - -NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) +NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p, + struct netr_ServerAuthenticate2 *r) { NTSTATUS status; - NEG_FLAGS srv_flgs; - fstring mach_acct; - fstring remote_machine; + uint32_t srv_flgs; DOM_CHAL srv_chal_out; - rpcstr_pull(mach_acct, q_u->clnt_id.uni_acct_name.buffer,sizeof(fstring), - q_u->clnt_id.uni_acct_name.uni_str_len*2,0); - - /* We use this as the key to store the creds. */ - rpcstr_pull(remote_machine, q_u->clnt_id.uni_comp_name.buffer,sizeof(fstring), - q_u->clnt_id.uni_comp_name.uni_str_len*2,0); + /* We use this as the key to store the creds: */ + /* r->in.computer_name */ if (!p->dc || !p->dc->challenge_sent) { - DEBUG(0,("_net_auth2: no challenge sent to client %s\n", - remote_machine )); + DEBUG(0,("_netr_ServerAuthenticate2: no challenge sent to client %s\n", + r->in.computer_name)); return NT_STATUS_ACCESS_DENIED; } - if ( (lp_server_schannel() == True) && - ((q_u->clnt_flgs.neg_flags & NETLOGON_NEG_SCHANNEL) == 0) ) { + if ( (lp_server_schannel() == true) && + ((*r->in.negotiate_flags & NETLOGON_NEG_SCHANNEL) == 0) ) { /* schannel must be used, but client did not offer it. */ - DEBUG(0,("_net_auth2: schannel required but client failed " + DEBUG(0,("_netr_ServerAuthenticate2: schannel required but client failed " "to offer it. Client was %s\n", - mach_acct )); + r->in.account_name)); return NT_STATUS_ACCESS_DENIED; } - status = get_md4pw((char *)p->dc->mach_pw, mach_acct, q_u->clnt_id.sec_chan); + status = get_md4pw((char *)p->dc->mach_pw, + r->in.account_name, + r->in.secure_channel_type); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("_net_auth2: failed to get machine password for " + DEBUG(0,("_netr_ServerAuthenticate2: failed to get machine password for " "account %s: %s\n", - mach_acct, nt_errstr(status) )); + r->in.account_name, nt_errstr(status) )); /* always return NT_STATUS_ACCESS_DENIED */ return NT_STATUS_ACCESS_DENIED; } /* From the client / server challenges and md4 password, generate sess key */ - creds_server_init(q_u->clnt_flgs.neg_flags, + creds_server_init(*r->in.negotiate_flags, p->dc, &p->dc->clnt_chal, /* Stored client chal. */ &p->dc->srv_chal, /* Stored server chal. */ @@ -521,24 +506,27 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) &srv_chal_out); /* Check client credentials are valid. */ - if (!creds_server_check(p->dc, &q_u->clnt_chal)) { - DEBUG(0,("_net_auth2: creds_server_check failed. Rejecting auth " + if (!netlogon_creds_server_check(p->dc, r->in.credentials)) { + DEBUG(0,("_netr_ServerAuthenticate2: netlogon_creds_server_check failed. Rejecting auth " "request from client %s machine account %s\n", - remote_machine, mach_acct )); + r->in.computer_name, + r->in.account_name)); return NT_STATUS_ACCESS_DENIED; } - srv_flgs.neg_flags = 0x000001ff; + srv_flgs = 0x000001ff; - if (lp_server_schannel() != False) { - srv_flgs.neg_flags |= NETLOGON_NEG_SCHANNEL; + if (lp_server_schannel() != false) { + srv_flgs |= NETLOGON_NEG_SCHANNEL; } /* set up the LSA AUTH 2 response */ - init_net_r_auth_2(r_u, &srv_chal_out, &srv_flgs, NT_STATUS_OK); + memcpy(r->out.credentials->data, &srv_chal_out.data, + sizeof(r->out.credentials->data)); + *r->out.negotiate_flags = srv_flgs; - fstrcpy(p->dc->mach_acct, mach_acct); - fstrcpy(p->dc->remote_machine, remote_machine); + fstrcpy(p->dc->mach_acct, r->in.account_name); + fstrcpy(p->dc->remote_machine, r->in.computer_name); fstrcpy(p->dc->domain, lp_workgroup() ); p->dc->authenticated = True; @@ -546,11 +534,11 @@ NTSTATUS _net_auth_2(pipes_struct *p, NET_Q_AUTH_2 *q_u, NET_R_AUTH_2 *r_u) /* Store off the state so we can continue after client disconnect. */ become_root(); secrets_store_schannel_session_info(p->mem_ctx, - remote_machine, - p->dc); + r->in.computer_name, + p->dc); unbecome_root(); - return r_u->status; + return NT_STATUS_OK; } /************************************************************************* @@ -1313,16 +1301,6 @@ WERROR _netr_GetAnyDCName(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p, - struct netr_ServerAuthenticate2 *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _netr_DatabaseSync2(pipes_struct *p, struct netr_DatabaseSync2 *r) { -- cgit From 5bce07977a18cd6bfd4714030707d3b2643cd840 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 21:46:42 +0100 Subject: Use pidl for _netr_LogonSamLogoff(). Guenther (This used to be commit a9683cbf4352ce331156f40b24a481fc87854b50) --- source3/rpc_server/srv_netlog.c | 23 +------------------- source3/rpc_server/srv_netlog_nt.c | 43 +++++++++++++------------------------- 2 files changed, 15 insertions(+), 51 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 719cdff41c..0e386c0de3 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -91,28 +91,7 @@ static bool api_net_srv_pwset(pipes_struct *p) static bool api_net_sam_logoff(pipes_struct *p) { - NET_Q_SAM_LOGOFF q_u; - NET_R_SAM_LOGOFF r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!net_io_q_sam_logoff("", &q_u, data, 0)) { - DEBUG(0,("api_net_sam_logoff: Failed to unmarshall NET_Q_SAM_LOGOFF.\n")); - return False; - } - - r_u.status = _net_sam_logoff(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_sam_logoff("", &r_u, rdata, 0)) { - DEBUG(0,("api_net_sam_logoff: Failed to marshall NET_R_SAM_LOGOFF.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_LOGONSAMLOGOFF); } /************************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index c11ada2461..30066dc58f 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -682,18 +682,17 @@ NTSTATUS _netr_ServerPasswordSet(pipes_struct *p, } /************************************************************************* - _net_sam_logoff: + _netr_LogonSamLogoff *************************************************************************/ -NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOFF *r_u) +NTSTATUS _netr_LogonSamLogoff(pipes_struct *p, + struct netr_LogonSamLogoff *r) { - fstring remote_machine; - if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { /* 'server schannel = yes' should enforce use of schannel, the client did offer it in auth2, but obviously did not use it. */ - DEBUG(0,("_net_sam_logoff: client %s not using schannel for netlogon\n", + DEBUG(0,("_netr_LogonSamLogoff: client %s not using schannel for netlogon\n", get_remote_machine_name() )); return NT_STATUS_ACCESS_DENIED; } @@ -702,9 +701,8 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; - /* Get the remote machine name for the creds store. */ - rpcstr_pull(remote_machine,q_u->sam_id.client.login.uni_comp_name.buffer, - sizeof(remote_machine),q_u->sam_id.client.login.uni_comp_name.uni_str_len*2,0); + /* Using the remote machine name for the creds store: */ + /* r->in.computer_name */ if (!p->dc) { /* Restore the saved state of the netlogon creds. */ @@ -712,8 +710,8 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF become_root(); ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, - remote_machine, - &p->dc); + r->in.computer_name, + &p->dc); unbecome_root(); if (!ret) { return NT_STATUS_INVALID_HANDLE; @@ -724,25 +722,22 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF return NT_STATUS_INVALID_HANDLE; } - r_u->buffer_creds = 1; /* yes, we have valid server credentials */ - /* checks and updates credentials. creates reply credentials */ - if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { - DEBUG(2,("_net_sam_logoff: creds_server_step failed. Rejecting auth " + if (!netlogon_creds_server_step(p->dc, r->in.credential, r->out.return_authenticator)) { + DEBUG(2,("_netr_LogonSamLogoff: netlogon_creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", - remote_machine, p->dc->mach_acct )); + r->in.computer_name, p->dc->mach_acct )); return NT_STATUS_INVALID_PARAMETER; } /* We must store the creds state after an update. */ become_root(); secrets_store_schannel_session_info(p->pipe_state_mem_ctx, - remote_machine, - p->dc); + r->in.computer_name, + p->dc); unbecome_root(); - r_u->status = NT_STATUS_OK; - return r_u->status; + return NT_STATUS_OK; } /******************************************************************* @@ -1231,16 +1226,6 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _netr_LogonSamLogoff(pipes_struct *p, - struct netr_LogonSamLogoff *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _netr_DatabaseDeltas(pipes_struct *p, struct netr_DatabaseDeltas *r) { -- cgit From ea1443efff60cbcaa0548bcc547ef3e5c35a178e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 23:36:31 +0100 Subject: Fix the netlogon rpc_server build. Guenther (This used to be commit 47806386e5cb12919615bb3075c9ed613efa4fdb) --- source3/rpc_server/srv_netlog_nt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 30066dc58f..3e15d38043 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -390,7 +390,7 @@ NTSTATUS _netr_ServerReqChallenge(pipes_struct *p, generate_random_buffer(p->dc->srv_chal.data, 8); /* set up the LSA REQUEST CHALLENGE response */ - init_net_r_req_chal(r->out.credentials, &p->dc->srv_chal); + init_net_r_req_chal(r->out.return_credentials, &p->dc->srv_chal); p->dc->challenge_sent = True; @@ -450,8 +450,8 @@ NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, /* set up the LSA AUTH response */ /* Return the server credentials. */ - memcpy(r->out.credentials->data, &srv_chal_out.data, - sizeof(r->out.credentials->data)); + memcpy(r->out.return_credentials->data, &srv_chal_out.data, + sizeof(r->out.return_credentials->data)); return NT_STATUS_OK; } @@ -521,8 +521,8 @@ NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p, } /* set up the LSA AUTH 2 response */ - memcpy(r->out.credentials->data, &srv_chal_out.data, - sizeof(r->out.credentials->data)); + memcpy(r->out.return_credentials->data, &srv_chal_out.data, + sizeof(r->out.return_credentials->data)); *r->out.negotiate_flags = srv_flgs; fstrcpy(p->dc->mach_acct, r->in.account_name); -- cgit From 3f24ef18481417fd7d52856b3d68bec099a7b643 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 15 Feb 2008 23:57:19 +0100 Subject: Replace DOM_CHAL with "struct netr_Credential" where we can right now. This allows to remove some more old netlogon client calls. Guenther (This used to be commit c0b1a876583230a5130f5df1965d6c742961bcdc) --- source3/rpc_server/srv_netlog_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 3e15d38043..017c4fe046 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -35,7 +35,7 @@ extern userdom_struct current_user_info; *************************************************************************/ static void init_net_r_req_chal(struct netr_Credential *r, - DOM_CHAL *srv_chal) + struct netr_Credential *srv_chal) { DEBUG(6,("init_net_r_req_chal: %d\n", __LINE__)); @@ -406,7 +406,7 @@ NTSTATUS _netr_ServerAuthenticate(pipes_struct *p, struct netr_ServerAuthenticate *r) { NTSTATUS status; - DOM_CHAL srv_chal_out; + struct netr_Credential srv_chal_out; if (!p->dc || !p->dc->challenge_sent) { return NT_STATUS_ACCESS_DENIED; @@ -465,7 +465,7 @@ NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p, { NTSTATUS status; uint32_t srv_flgs; - DOM_CHAL srv_chal_out; + struct netr_Credential srv_chal_out; /* We use this as the key to store the creds: */ /* r->in.computer_name */ -- cgit From 185842df528c9d39489f5ad629aa3b02b660f909 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 13:28:03 +0100 Subject: Use pidl for _netr_LogonSamLogon() and _netr_LogonSamLogonEx(). Guenther (This used to be commit 0d0b93995399bba0acf891fab107fd93ecec321f) --- source3/rpc_server/srv_netlog.c | 46 +----- source3/rpc_server/srv_netlog_nt.c | 291 ++++++++++++++++++------------------- 2 files changed, 147 insertions(+), 190 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c index 0e386c0de3..ea9408a2cf 100644 --- a/source3/rpc_server/srv_netlog.c +++ b/source3/rpc_server/srv_netlog.c @@ -100,28 +100,7 @@ static bool api_net_sam_logoff(pipes_struct *p) static bool api_net_sam_logon(pipes_struct *p) { - NET_Q_SAM_LOGON q_u; - NET_R_SAM_LOGON r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!net_io_q_sam_logon("", &q_u, data, 0)) { - DEBUG(0, ("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n")); - return False; - } - - r_u.status = _net_sam_logon(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_sam_logon("", &r_u, rdata, 0)) { - DEBUG(0,("api_net_sam_logon: Failed to marshall NET_R_SAM_LOGON.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_LOGONSAMLOGON); } /************************************************************************* @@ -157,28 +136,7 @@ static bool api_net_logon_ctrl(pipes_struct *p) static bool api_net_sam_logon_ex(pipes_struct *p) { - NET_Q_SAM_LOGON_EX q_u; - NET_R_SAM_LOGON_EX r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!net_io_q_sam_logon_ex("", &q_u, data, 0)) { - DEBUG(0, ("api_net_sam_logon_ex: Failed to unmarshall NET_Q_SAM_LOGON_EX.\n")); - return False; - } - - r_u.status = _net_sam_logon_ex(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!net_io_r_sam_logon_ex("", &r_u, rdata, 0)) { - DEBUG(0,("api_net_sam_logon_ex: Failed to marshall NET_R_SAM_LOGON_EX.\n")); - return False; - } - - return True; + return proxy_netr_call(p, NDR_NETR_LOGONSAMLOGONEX); } /******************************************************************* diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 017c4fe046..c64e5b8d10 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -771,52 +771,53 @@ static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, } /************************************************************************* - _net_sam_logon + _netr_LogonSamLogon *************************************************************************/ -static NTSTATUS _net_sam_logon_internal(pipes_struct *p, - NET_Q_SAM_LOGON *q_u, - NET_R_SAM_LOGON *r_u, - bool process_creds) +NTSTATUS _netr_LogonSamLogon(pipes_struct *p, + struct netr_LogonSamLogon *r) { NTSTATUS status = NT_STATUS_OK; - NET_USER_INFO_3 *usr_info = NULL; - NET_ID_INFO_CTR *ctr = q_u->sam_id.ctr; - UNISTR2 *uni_samlogon_user = NULL; - UNISTR2 *uni_samlogon_domain = NULL; - UNISTR2 *uni_samlogon_workstation = NULL; + struct netr_SamInfo3 *sam3 = NULL; + union netr_LogonLevel *logon = r->in.logon; fstring nt_username, nt_domain, nt_workstation; auth_usersupplied_info *user_info = NULL; auth_serversupplied_info *server_info = NULL; struct samu *sampw; struct auth_context *auth_context = NULL; + bool process_creds = true; + + switch (p->hdr_req.opnum) { + case NDR_NETR_LOGONSAMLOGON: + process_creds = true; + break; + case NDR_NETR_LOGONSAMLOGONEX: + default: + process_creds = false; + } if ( (lp_server_schannel() == True) && (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) ) { /* 'server schannel = yes' should enforce use of schannel, the client did offer it in auth2, but obviously did not use it. */ - DEBUG(0,("_net_sam_logon_internal: client %s not using schannel for netlogon\n", + DEBUG(0,("_netr_LogonSamLogon: client %s not using schannel for netlogon\n", get_remote_machine_name() )); return NT_STATUS_ACCESS_DENIED; } - usr_info = TALLOC_P(p->mem_ctx, NET_USER_INFO_3); - if (!usr_info) { + sam3 = TALLOC_ZERO_P(p->mem_ctx, struct netr_SamInfo3); + if (!sam3) { return NT_STATUS_NO_MEMORY; } - ZERO_STRUCTP(usr_info); - /* store the user information, if there is any. */ - r_u->user = usr_info; - r_u->auth_resp = 1; /* authoritative response */ - if (q_u->validation_level != 2 && q_u->validation_level != 3) { - DEBUG(0,("_net_sam_logon: bad validation_level value %d.\n", (int)q_u->validation_level )); + r->out.validation->sam3 = sam3; + *r->out.authoritative = true; /* authoritative response */ + if (r->in.validation_level != 2 && r->in.validation_level != 3) { + DEBUG(0,("_netr_LogonSamLogon: bad validation_level value %d.\n", + (int)r->in.validation_level)); return NT_STATUS_ACCESS_DENIED; } - /* We handle the return of USER_INFO_2 instead of 3 in the parse return. Sucks, I know... */ - r_u->switch_value = q_u->validation_level; /* indicates type of validation user info */ - r_u->buffer_creds = 1; /* Ensure we always return server creds. */ if (!get_valid_user_struct(p->vuid)) return NT_STATUS_NO_SUCH_USER; @@ -828,8 +829,8 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, /* Note this is the remote machine this request is coming from (member server), not neccessarily the workstation name the user is logging onto. */ - rpcstr_pull(remote_machine,q_u->sam_id.client.login.uni_comp_name.buffer, - sizeof(remote_machine),q_u->sam_id.client.login.uni_comp_name.uni_str_len*2,0); + + fstrcpy(remote_machine, r->in.computer_name); if (!p->dc) { /* Restore the saved state of the netlogon creds. */ @@ -850,8 +851,8 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, } /* checks and updates credentials. creates reply credentials */ - if (!creds_server_step(p->dc, &q_u->sam_id.client.cred, &r_u->srv_creds)) { - DEBUG(2,("_net_sam_logon: creds_server_step failed. Rejecting auth " + if (!netlogon_creds_server_step(p->dc, r->in.credential, r->out.return_authenticator)) { + DEBUG(2,("_netr_LogonSamLogon: creds_server_step failed. Rejecting auth " "request from client %s machine account %s\n", remote_machine, p->dc->mach_acct )); return NT_STATUS_INVALID_PARAMETER; @@ -865,19 +866,24 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, unbecome_root(); } - switch (q_u->sam_id.logon_level) { + switch (r->in.logon_level) { case INTERACTIVE_LOGON_TYPE: - uni_samlogon_user = &ctr->auth.id1.uni_user_name; - uni_samlogon_domain = &ctr->auth.id1.uni_domain_name; - - uni_samlogon_workstation = &ctr->auth.id1.uni_wksta_name; + fstrcpy(nt_username, + logon->password->identity_info.account_name.string); + fstrcpy(nt_domain, + logon->password->identity_info.domain_name.string); + fstrcpy(nt_workstation, + logon->password->identity_info.workstation.string); DEBUG(3,("SAM Logon (Interactive). Domain:[%s]. ", lp_workgroup())); break; case NET_LOGON_TYPE: - uni_samlogon_user = &ctr->auth.id2.uni_user_name; - uni_samlogon_domain = &ctr->auth.id2.uni_domain_name; - uni_samlogon_workstation = &ctr->auth.id2.uni_wksta_name; + fstrcpy(nt_username, + logon->network->identity_info.account_name.string); + fstrcpy(nt_domain, + logon->network->identity_info.domain_name.string); + fstrcpy(nt_workstation, + logon->network->identity_info.workstation.string); DEBUG(3,("SAM Logon (Network). Domain:[%s]. ", lp_workgroup())); break; @@ -886,24 +892,23 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, return NT_STATUS_INVALID_INFO_CLASS; } /* end switch */ - rpcstr_pull(nt_username,uni_samlogon_user->buffer,sizeof(nt_username),uni_samlogon_user->uni_str_len*2,0); - rpcstr_pull(nt_domain,uni_samlogon_domain->buffer,sizeof(nt_domain),uni_samlogon_domain->uni_str_len*2,0); - rpcstr_pull(nt_workstation,uni_samlogon_workstation->buffer,sizeof(nt_workstation),uni_samlogon_workstation->uni_str_len*2,0); - DEBUG(3,("User:[%s@%s] Requested Domain:[%s]\n", nt_username, nt_workstation, nt_domain)); fstrcpy(current_user_info.smb_name, nt_username); sub_set_smb_name(nt_username); - DEBUG(5,("Attempting validation level %d for unmapped username %s.\n", q_u->sam_id.ctr->switch_value, nt_username)); + DEBUG(5,("Attempting validation level %d for unmapped username %s.\n", + r->in.validation_level, nt_username)); status = NT_STATUS_OK; - switch (ctr->switch_value) { + switch (r->in.logon_level) { case NET_LOGON_TYPE: { const char *wksname = nt_workstation; - if (!NT_STATUS_IS_OK(status = make_auth_context_fixed(&auth_context, ctr->auth.id2.lm_chal))) { + status = make_auth_context_fixed(&auth_context, + logon->network->challenge); + if (!NT_STATUS_IS_OK(status)) { return status; } @@ -917,11 +922,11 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (!make_user_info_netlogon_network(&user_info, nt_username, nt_domain, wksname, - ctr->auth.id2.param_ctrl, - ctr->auth.id2.lm_chal_resp.buffer, - ctr->auth.id2.lm_chal_resp.str_str_len, - ctr->auth.id2.nt_chal_resp.buffer, - ctr->auth.id2.nt_chal_resp.str_str_len)) { + logon->network->identity_info.parameter_control, + logon->network->lm.data, + logon->network->lm.length, + logon->network->nt.data, + logon->network->nt.length)) { status = NT_STATUS_NO_MEMORY; } break; @@ -943,10 +948,10 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (!make_user_info_netlogon_interactive(&user_info, nt_username, nt_domain, nt_workstation, - ctr->auth.id1.param_ctrl, + logon->password->identity_info.parameter_control, chal, - ctr->auth.id1.lm_owf.data, - ctr->auth.id1.nt_owf.data, + logon->password->lmpassword.hash, + logon->password->ntpassword.hash, p->dc->sess_key)) { status = NT_STATUS_NO_MEMORY; } @@ -965,7 +970,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, (auth_context->free)(&auth_context); free_user_info(&user_info); - DEBUG(5, ("_net_sam_logon: check_password returned status %s\n", + DEBUG(5,("_netr_LogonSamLogon: check_password returned status %s\n", nt_errstr(status))); /* Check account and password */ @@ -978,7 +983,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if ( NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_USER) && !strequal(nt_domain, get_global_sam_name()) && !is_trusted_domain(nt_domain) ) - r_u->auth_resp = 0; /* We are not authoritative */ + *r->out.authoritative = false; /* We are not authoritative */ TALLOC_FREE(server_info); return status; @@ -986,7 +991,7 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, if (server_info->guest) { /* We don't like guest domain logons... */ - DEBUG(5,("_net_sam_logon: Attempted domain logon as GUEST " + DEBUG(5,("_netr_LogonSamLogon: Attempted domain logon as GUEST " "denied.\n")); TALLOC_FREE(server_info); return NT_STATUS_LOGON_FAILURE; @@ -1005,29 +1010,40 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, int num_gids = 0; const char *my_name; - unsigned char user_session_key[16]; - unsigned char lm_session_key[16]; + + struct netr_UserSessionKey user_session_key; + struct netr_LMSessionKey lm_session_key; unsigned char pipe_session_key[16]; - sampw = server_info->sam_account; + NTTIME last_logon, last_logoff, acct_expiry, last_password_change; + NTTIME allow_password_change, force_password_change; + struct samr_RidWithAttributeArray groups; + int i; + struct dom_sid2 *sid = NULL; - /* set up pointer indicating user/password failed to be - * found */ - usr_info->ptr_user_info = 0; + ZERO_STRUCT(user_session_key); + ZERO_STRUCT(lm_session_key); + + sampw = server_info->sam_account; user_sid = pdb_get_user_sid(sampw); group_sid = pdb_get_group_sid(sampw); if ((user_sid == NULL) || (group_sid == NULL)) { - DEBUG(1, ("_net_sam_logon: User without group or user SID\n")); + DEBUG(1, ("_netr_LogonSamLogon: User without group or user SID\n")); return NT_STATUS_UNSUCCESSFUL; } sid_copy(&domain_sid, user_sid); sid_split_rid(&domain_sid, &user_rid); + sid = sid_dup_talloc(p->mem_ctx, &domain_sid); + if (!sid) { + return NT_STATUS_NO_MEMORY; + } + if (!sid_peek_check_rid(&domain_sid, group_sid, &group_rid)) { - DEBUG(1, ("_net_sam_logon: user %s\\%s has user sid " + DEBUG(1, ("_netr_LogonSamLogon: user %s\\%s has user sid " "%s\n but group sid %s.\n" "The conflicting domain portions are not " "supported for NETLOGON calls\n", @@ -1054,9 +1070,9 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, } if (server_info->user_session_key.length) { - memcpy(user_session_key, + memcpy(user_session_key.key, server_info->user_session_key.data, - MIN(sizeof(user_session_key), + MIN(sizeof(user_session_key.key), server_info->user_session_key.length)); if (process_creds) { /* Get the pipe session key from the creds. */ @@ -1068,13 +1084,13 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, } memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16); } - SamOEMhash(user_session_key, pipe_session_key, 16); + SamOEMhash(user_session_key.key, pipe_session_key, 16); memset(pipe_session_key, '\0', 16); } if (server_info->lm_session_key.length) { - memcpy(lm_session_key, + memcpy(lm_session_key.key, server_info->lm_session_key.data, - MIN(sizeof(lm_session_key), + MIN(sizeof(lm_session_key.key), server_info->lm_session_key.length)); if (process_creds) { /* Get the pipe session key from the creds. */ @@ -1086,36 +1102,56 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, } memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16); } - SamOEMhash(lm_session_key, pipe_session_key, 16); + SamOEMhash(lm_session_key.key, pipe_session_key, 16); memset(pipe_session_key, '\0', 16); } - init_net_user_info3(p->mem_ctx, usr_info, - user_rid, - group_rid, - pdb_get_username(sampw), - pdb_get_fullname(sampw), - pdb_get_homedir(sampw), - pdb_get_dir_drive(sampw), - pdb_get_logon_script(sampw), - pdb_get_profile_path(sampw), - pdb_get_logon_time(sampw), - get_time_t_max(), - get_time_t_max(), - pdb_get_pass_last_set_time(sampw), - pdb_get_pass_can_change_time(sampw), - pdb_get_pass_must_change_time(sampw), - 0, /* logon_count */ - 0, /* bad_pw_count */ - num_gids, /* uint32 num_groups */ - gids , /* DOM_GID *gids */ - NETLOGON_EXTRA_SIDS, /* uint32 user_flgs (?) */ - pdb_get_acct_ctrl(sampw), - server_info->user_session_key.length ? user_session_key : NULL, - server_info->lm_session_key.length ? lm_session_key : NULL, - my_name , /* char *logon_srv */ - pdb_get_domain(sampw), - &domain_sid); /* DOM_SID *dom_sid */ + groups.count = num_gids; + groups.rids = TALLOC_ARRAY(p->mem_ctx, struct samr_RidWithAttribute, + groups.count); + if (!groups.rids) { + return NT_STATUS_NO_MEMORY; + } + + for (i=0; i < groups.count; i++) { + groups.rids[i].rid = gids[i].g_rid; + groups.rids[i].attributes = gids[i].attr; + } + + unix_to_nt_time(&last_logon, pdb_get_logon_time(sampw)); + unix_to_nt_time(&last_logoff, get_time_t_max()); + unix_to_nt_time(&acct_expiry, get_time_t_max()); + unix_to_nt_time(&last_password_change, pdb_get_pass_last_set_time(sampw)); + unix_to_nt_time(&allow_password_change, pdb_get_pass_can_change_time(sampw)); + unix_to_nt_time(&force_password_change, pdb_get_pass_must_change_time(sampw)); + + init_netr_SamInfo3(sam3, + last_logon, + last_logoff, + acct_expiry, + last_password_change, + allow_password_change, + force_password_change, + talloc_strdup(p->mem_ctx, pdb_get_username(sampw)), + talloc_strdup(p->mem_ctx, pdb_get_fullname(sampw)), + talloc_strdup(p->mem_ctx, pdb_get_logon_script(sampw)), + talloc_strdup(p->mem_ctx, pdb_get_profile_path(sampw)), + talloc_strdup(p->mem_ctx, pdb_get_homedir(sampw)), + talloc_strdup(p->mem_ctx, pdb_get_dir_drive(sampw)), + 0, /* logon_count */ + 0, /* bad_password_count */ + user_rid, + group_rid, + groups, + NETLOGON_EXTRA_SIDS, + user_session_key, + my_name, + talloc_strdup(p->mem_ctx, pdb_get_domain(sampw)), + sid, + lm_session_key, + pdb_get_acct_ctrl(sampw), + 0, /* sidcount */ + NULL); /* struct netr_SidAttr *sids */ ZERO_STRUCT(user_session_key); ZERO_STRUCT(lm_session_key); } @@ -1124,25 +1160,14 @@ static NTSTATUS _net_sam_logon_internal(pipes_struct *p, } /************************************************************************* - _net_sam_logon + _netr_LogonSamLogonEx + - no credential chaining. Map into net sam logon. *************************************************************************/ -NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *r_u) -{ - return _net_sam_logon_internal(p, q_u, r_u, True); -} - -/************************************************************************* - _net_sam_logon_ex - no credential chaining. Map into net sam logon. - *************************************************************************/ - -NTSTATUS _net_sam_logon_ex(pipes_struct *p, NET_Q_SAM_LOGON_EX *q_u, NET_R_SAM_LOGON_EX *r_u) +NTSTATUS _netr_LogonSamLogonEx(pipes_struct *p, + struct netr_LogonSamLogonEx *r) { - NET_Q_SAM_LOGON q; - NET_R_SAM_LOGON r; - - ZERO_STRUCT(q); - ZERO_STRUCT(r); + struct netr_LogonSamLogon q; /* Only allow this if the pipe is protected. */ if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) { @@ -1151,26 +1176,20 @@ NTSTATUS _net_sam_logon_ex(pipes_struct *p, NET_Q_SAM_LOGON_EX *q_u, NET_R_SAM_L return NT_STATUS_INVALID_PARAMETER; } - /* Map a NET_Q_SAM_LOGON_EX to NET_Q_SAM_LOGON. */ - q.validation_level = q_u->validation_level; - - /* Map a DOM_SAM_INFO_EX into a DOM_SAM_INFO with no creds. */ - q.sam_id.client.login = q_u->sam_id.client; - q.sam_id.logon_level = q_u->sam_id.logon_level; - q.sam_id.ctr = q_u->sam_id.ctr; - - r_u->status = _net_sam_logon_internal(p, &q, &r, False); + q.in.server_name = r->in.server_name; + q.in.computer_name = r->in.computer_name; + q.in.logon_level = r->in.logon_level; + q.in.logon = r->in.logon; + q.in.validation_level = r->in.validation_level; + /* we do not handle the flags */ + /* = r->in.flags; */ - if (!NT_STATUS_IS_OK(r_u->status)) { - return r_u->status; - } + q.out.validation = r->out.validation; + q.out.authoritative = r->out.authoritative; + /* we do not handle the flags */ + /* = r->out.flags; */ - /* Map the NET_R_SAM_LOGON to NET_R_SAM_LOGON_EX. */ - r_u->switch_value = r.switch_value; - r_u->user = r.user; - r_u->auth_resp = r.auth_resp; - r_u->flags = 0; /* FIXME ! */ - return r_u->status; + return _netr_LogonSamLogon(p, &q); } /************************************************************************* @@ -1216,16 +1235,6 @@ WERROR _netr_LogonUasLogoff(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _netr_LogonSamLogon(pipes_struct *p, - struct netr_LogonSamLogon *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _netr_DatabaseDeltas(pipes_struct *p, struct netr_DatabaseDeltas *r) { @@ -1506,16 +1515,6 @@ WERROR _netr_DsrGetDcSiteCoverageW(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _netr_LogonSamLogonEx(pipes_struct *p, - struct netr_LogonSamLogonEx *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _netr_DsrEnumerateDomainTrusts(pipes_struct *p, struct netr_DsrEnumerateDomainTrusts *r) { -- cgit From b4989afbab6e795c08bda37e500898d86a943b94 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 16 Feb 2008 13:42:12 +0100 Subject: YES! NETLOGON rpc server side migration to pidl finished. Guenther (This used to be commit 7845a0d9a8f938c1be888ab2d9aa6c35d6f1dbad) --- source3/rpc_server/srv_netlog.c | 169 ---------------------------------------- source3/rpc_server/srv_pipe.c | 2 +- 2 files changed, 1 insertion(+), 170 deletions(-) delete mode 100644 source3/rpc_server/srv_netlog.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog.c b/source3/rpc_server/srv_netlog.c deleted file mode 100644 index ea9408a2cf..0000000000 --- a/source3/rpc_server/srv_netlog.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997, - * Copyright (C) Jeremy Allison 1998-2001, - * Copyright (C) Jim McDonough 2003. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ - -/* This is the interface to the netlogon pipe. */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -/******************************************************************* - ********************************************************************/ - -static bool proxy_netr_call(pipes_struct *p, uint8 opnum) -{ - struct api_struct *fns; - int n_fns; - - netlogon_get_pipe_fns(&fns, &n_fns); - - if (opnum >= n_fns) { - return false; - } - - if (fns[opnum].opnum != opnum) { - smb_panic("NETLOGON function table not sorted"); - } - - return fns[opnum].fn(p); -} - -/************************************************************************* - api_net_req_chal: - *************************************************************************/ - -static bool api_net_req_chal(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_SERVERREQCHALLENGE); -} - -/************************************************************************* - api_net_auth: - *************************************************************************/ - -static bool api_net_auth(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_SERVERAUTHENTICATE); -} - -/************************************************************************* - api_net_auth_2: - *************************************************************************/ - -static bool api_net_auth_2(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_SERVERAUTHENTICATE2); -} - -/************************************************************************* - api_net_srv_pwset: - *************************************************************************/ - -static bool api_net_srv_pwset(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_SERVERPASSWORDSET); -} - -/************************************************************************* - api_net_sam_logoff: - *************************************************************************/ - -static bool api_net_sam_logoff(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_LOGONSAMLOGOFF); -} - -/************************************************************************* - api_net_sam_logon: - *************************************************************************/ - -static bool api_net_sam_logon(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_LOGONSAMLOGON); -} - -/************************************************************************* - api_net_trust_dom_list: - *************************************************************************/ - -static bool api_net_trust_dom_list(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_NETRENUMERATETRUSTEDDOMAINS); -} - -/************************************************************************* - api_net_logon_ctrl2: - *************************************************************************/ - -static bool api_net_logon_ctrl2(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_LOGONCONTROL2); -} - -/************************************************************************* - api_net_logon_ctrl: - *************************************************************************/ - -static bool api_net_logon_ctrl(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_LOGONCONTROL); -} - -/************************************************************************* - api_net_sam_logon_ex: - *************************************************************************/ - -static bool api_net_sam_logon_ex(pipes_struct *p) -{ - return proxy_netr_call(p, NDR_NETR_LOGONSAMLOGONEX); -} - -/******************************************************************* - array of \PIPE\NETLOGON operations - ********************************************************************/ -static struct api_struct api_net_cmds [] = - { - { "NET_REQCHAL" , NET_REQCHAL , api_net_req_chal }, - { "NET_AUTH" , NET_AUTH , api_net_auth }, - { "NET_AUTH2" , NET_AUTH2 , api_net_auth_2 }, - { "NET_SRVPWSET" , NET_SRVPWSET , api_net_srv_pwset }, - { "NET_SAMLOGON" , NET_SAMLOGON , api_net_sam_logon }, - { "NET_SAMLOGOFF" , NET_SAMLOGOFF , api_net_sam_logoff }, - { "NET_LOGON_CTRL2" , NET_LOGON_CTRL2 , api_net_logon_ctrl2 }, - { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list }, - { "NET_LOGON_CTRL" , NET_LOGON_CTRL , api_net_logon_ctrl }, - { "NET_SAMLOGON_EX" , NET_SAMLOGON_EX , api_net_sam_logon_ex }, - }; - -void netlog_get_pipe_fns( struct api_struct **fns, int *n_fns ) -{ - *fns = api_net_cmds; - *n_fns = sizeof(api_net_cmds) / sizeof(struct api_struct); -} - -NTSTATUS rpc_net_init(void) -{ - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "NETLOGON", "lsass", api_net_cmds, - sizeof(api_net_cmds) / sizeof(struct api_struct)); -} diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index a671f89238..de9f22da1d 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2385,7 +2385,7 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) samr_get_pipe_fns( &cmds, &n_cmds ); break; case PI_NETLOGON: - netlog_get_pipe_fns( &cmds, &n_cmds ); + netlogon_get_pipe_fns( &cmds, &n_cmds ); break; case PI_SRVSVC: srvsvc2_get_pipe_fns( &cmds, &n_cmds ); -- cgit From d8fcfb161540d3cb6d64f04b82dbf9590c1d5c9b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:03:22 +0100 Subject: Build the generated ntsvcs server (not at all useable yet). Guenther (This used to be commit acce1092d90db1f90265de44fd340d7df73e4e0e) --- source3/rpc_server/srv_ntsvcs.c | 25 +- source3/rpc_server/srv_ntsvcs_nt.c | 650 +++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_pipe.c | 2 +- 3 files changed, 674 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index b3e93ac459..0734a60b4d 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -22,6 +22,27 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +/******************************************************************* + ********************************************************************/ + +static bool proxy_ntsvcs_call(pipes_struct *p, uint8_t opnum) +{ + struct api_struct *fns; + int n_fns; + + ntsvcs_get_pipe_fns(&fns, &n_fns); + + if (opnum >= n_fns) { + return false; + } + + if (fns[opnum].opnum != opnum) { + smb_panic("NTSVCS function table not sorted"); + } + + return fns[opnum].fn(p); +} + /******************************************************************* ********************************************************************/ @@ -206,13 +227,13 @@ static struct api_struct api_ntsvcs_cmds[] = }; -void ntsvcs_get_pipe_fns( struct api_struct **fns, int *n_fns ) +void ntsvcs2_get_pipe_fns( struct api_struct **fns, int *n_fns ) { *fns = api_ntsvcs_cmds; *n_fns = sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct); } -NTSTATUS rpc_ntsvcs_init(void) +NTSTATUS rpc_ntsvcs2_init(void) { return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "ntsvcs", "ntsvcs", api_ntsvcs_cmds, sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct)); diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index 16c74c5d6d..c7ca0df097 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -174,3 +174,653 @@ WERROR _ntsvcs_hw_profile_flags( pipes_struct *p, NTSVCS_Q_HW_PROFILE_FLAGS *q_u return WERR_OK; } +/**************************************************************** +****************************************************************/ + +WERROR _PNP_Disconnect(pipes_struct *p, + struct PNP_Disconnect *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_Connect(pipes_struct *p, + struct PNP_Connect *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetVersion(pipes_struct *p, + struct PNP_GetVersion *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetGlobalState(pipes_struct *p, + struct PNP_GetGlobalState *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_InitDetection(pipes_struct *p, + struct PNP_InitDetection *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_ReportLogOn(pipes_struct *p, + struct PNP_ReportLogOn *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_ValidateDeviceInstance(pipes_struct *p, + struct PNP_ValidateDeviceInstance *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetRootDeviceInstance(pipes_struct *p, + struct PNP_GetRootDeviceInstance *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetRelatedDeviceInstance(pipes_struct *p, + struct PNP_GetRelatedDeviceInstance *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_EnumerateSubKeys(pipes_struct *p, + struct PNP_EnumerateSubKeys *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetDeviceList(pipes_struct *p, + struct PNP_GetDeviceList *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetDeviceListSize(pipes_struct *p, + struct PNP_GetDeviceListSize *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetDepth(pipes_struct *p, + struct PNP_GetDepth *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetDeviceRegProp(pipes_struct *p, + struct PNP_GetDeviceRegProp *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_SetDeviceRegProp(pipes_struct *p, + struct PNP_SetDeviceRegProp *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetClassInstance(pipes_struct *p, + struct PNP_GetClassInstance *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_CreateKey(pipes_struct *p, + struct PNP_CreateKey *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_DeleteRegistryKey(pipes_struct *p, + struct PNP_DeleteRegistryKey *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetClassCount(pipes_struct *p, + struct PNP_GetClassCount *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetClassName(pipes_struct *p, + struct PNP_GetClassName *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_DeleteClassKey(pipes_struct *p, + struct PNP_DeleteClassKey *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetInterfaceDeviceAlias(pipes_struct *p, + struct PNP_GetInterfaceDeviceAlias *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetInterfaceDeviceList(pipes_struct *p, + struct PNP_GetInterfaceDeviceList *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetInterfaceDeviceListSize(pipes_struct *p, + struct PNP_GetInterfaceDeviceListSize *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_RegisterDeviceClassAssociation(pipes_struct *p, + struct PNP_RegisterDeviceClassAssociation *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_UnregisterDeviceClassAssociation(pipes_struct *p, + struct PNP_UnregisterDeviceClassAssociation *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetClassRegProp(pipes_struct *p, + struct PNP_GetClassRegProp *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_SetClassRegProp(pipes_struct *p, + struct PNP_SetClassRegProp *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_CreateDevInst(pipes_struct *p, + struct PNP_CreateDevInst *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_DeviceInstanceAction(pipes_struct *p, + struct PNP_DeviceInstanceAction *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetDeviceStatus(pipes_struct *p, + struct PNP_GetDeviceStatus *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_SetDeviceProblem(pipes_struct *p, + struct PNP_SetDeviceProblem *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_DisableDevInst(pipes_struct *p, + struct PNP_DisableDevInst *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_UninstallDevInst(pipes_struct *p, + struct PNP_UninstallDevInst *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_AddID(pipes_struct *p, + struct PNP_AddID *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_RegisterDriver(pipes_struct *p, + struct PNP_RegisterDriver *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_QueryRemove(pipes_struct *p, + struct PNP_QueryRemove *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_RequestDeviceEject(pipes_struct *p, + struct PNP_RequestDeviceEject *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_IsDockStationPresent(pipes_struct *p, + struct PNP_IsDockStationPresent *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_RequestEjectPC(pipes_struct *p, + struct PNP_RequestEjectPC *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_HwProfFlags(pipes_struct *p, + struct PNP_HwProfFlags *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetHwProfInfo(pipes_struct *p, + struct PNP_GetHwProfInfo *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_AddEmptyLogConf(pipes_struct *p, + struct PNP_AddEmptyLogConf *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_FreeLogConf(pipes_struct *p, + struct PNP_FreeLogConf *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetFirstLogConf(pipes_struct *p, + struct PNP_GetFirstLogConf *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetNextLogConf(pipes_struct *p, + struct PNP_GetNextLogConf *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetLogConfPriority(pipes_struct *p, + struct PNP_GetLogConfPriority *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_AddResDes(pipes_struct *p, + struct PNP_AddResDes *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_FreeResDes(pipes_struct *p, + struct PNP_FreeResDes *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetNextResDes(pipes_struct *p, + struct PNP_GetNextResDes *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetResDesData(pipes_struct *p, + struct PNP_GetResDesData *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetResDesDataSize(pipes_struct *p, + struct PNP_GetResDesDataSize *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_ModifyResDes(pipes_struct *p, + struct PNP_ModifyResDes *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_DetectResourceLimit(pipes_struct *p, + struct PNP_DetectResourceLimit *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_QueryResConfList(pipes_struct *p, + struct PNP_QueryResConfList *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_SetHwProf(pipes_struct *p, + struct PNP_SetHwProf *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_QueryArbitratorFreeData(pipes_struct *p, + struct PNP_QueryArbitratorFreeData *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_QueryArbitratorFreeSize(pipes_struct *p, + struct PNP_QueryArbitratorFreeSize *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_RunDetection(pipes_struct *p, + struct PNP_RunDetection *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_RegisterNotification(pipes_struct *p, + struct PNP_RegisterNotification *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_UnregisterNotification(pipes_struct *p, + struct PNP_UnregisterNotification *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetCustomDevProp(pipes_struct *p, + struct PNP_GetCustomDevProp *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetVersionInternal(pipes_struct *p, + struct PNP_GetVersionInternal *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetBlockedDriverInfo(pipes_struct *p, + struct PNP_GetBlockedDriverInfo *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + +/**************************************************************** +****************************************************************/ + +WERROR _PNP_GetServerSideDeviceInstallFlags(pipes_struct *p, + struct PNP_GetServerSideDeviceInstallFlags *r) +{ + p->rng_fault_state = true; + return WERR_NOT_SUPPORTED; +} + diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index de9f22da1d..a7a7f9a389 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2409,7 +2409,7 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) eventlog2_get_pipe_fns( &cmds, &n_cmds ); break; case PI_NTSVCS: - ntsvcs_get_pipe_fns( &cmds, &n_cmds ); + ntsvcs2_get_pipe_fns( &cmds, &n_cmds ); break; #ifdef DEVELOPER case PI_RPCECHO: -- cgit From 3758f06d0f56a1ff86073e91c584e0153d53fd9e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:17:51 +0100 Subject: Use pidl for _PNP_GetVersion(). Guenther (This used to be commit 5300ff01b9098ccd78cb38b4d6abc85b2d340a55) --- source3/rpc_server/srv_ntsvcs.c | 18 +----------------- source3/rpc_server/srv_ntsvcs_nt.c | 17 ++++------------- 2 files changed, 5 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index 0734a60b4d..ec65919646 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -48,23 +48,7 @@ static bool proxy_ntsvcs_call(pipes_struct *p, uint8_t opnum) static bool api_ntsvcs_get_version(pipes_struct *p) { - NTSVCS_Q_GET_VERSION q_u; - NTSVCS_R_GET_VERSION r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!ntsvcs_io_q_get_version("", &q_u, data, 0)) - return False; - - r_u.status = _ntsvcs_get_version(p, &q_u, &r_u); - - if(!ntsvcs_io_r_get_version("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_ntsvcs_call(p, NDR_PNP_GETVERSION); } /******************************************************************* diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index c7ca0df097..0cf2e5cc19 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -34,10 +34,11 @@ static char* get_device_path(TALLOC_CTX *mem_ctx, const char *device ) /******************************************************************** ********************************************************************/ -WERROR _ntsvcs_get_version( pipes_struct *p, NTSVCS_Q_GET_VERSION *q_u, NTSVCS_R_GET_VERSION *r_u ) +WERROR _PNP_GetVersion(pipes_struct *p, + struct PNP_GetVersion *r) { - r_u->version = 0x00000400; /* no idea what this means */ - + *r->out.version = 0x0400; /* no idea what this means */ + return WERR_OK; } @@ -197,16 +198,6 @@ WERROR _PNP_Connect(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _PNP_GetVersion(pipes_struct *p, - struct PNP_GetVersion *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _PNP_GetGlobalState(pipes_struct *p, struct PNP_GetGlobalState *r) { -- cgit From 45c6af356ee071f65ce98a7c88ddcd2393c907b1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 17 Feb 2008 23:42:20 +0100 Subject: Use pidl for _PNP_ValidateDeviceInstance(). Guenther (This used to be commit 7973a103aa91497807cb0e3bf19dba172ae613b8) --- source3/rpc_server/srv_ntsvcs.c | 18 +----------------- source3/rpc_server/srv_ntsvcs_nt.c | 13 ++----------- 2 files changed, 3 insertions(+), 28 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index ec65919646..cd2248926c 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -104,23 +104,7 @@ static bool api_ntsvcs_get_device_list(pipes_struct *p) static bool api_ntsvcs_validate_device_instance(pipes_struct *p) { - NTSVCS_Q_VALIDATE_DEVICE_INSTANCE q_u; - NTSVCS_R_VALIDATE_DEVICE_INSTANCE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!ntsvcs_io_q_validate_device_instance("", &q_u, data, 0)) - return False; - - r_u.status = _ntsvcs_validate_device_instance(p, &q_u, &r_u); - - if(!ntsvcs_io_r_validate_device_instance("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_ntsvcs_call(p, NDR_PNP_VALIDATEDEVICEINSTANCE); } /******************************************************************* diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index 0cf2e5cc19..b6e0126fa6 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -144,7 +144,8 @@ WERROR _ntsvcs_get_device_reg_property( pipes_struct *p, NTSVCS_Q_GET_DEVICE_REG /******************************************************************** ********************************************************************/ -WERROR _ntsvcs_validate_device_instance( pipes_struct *p, NTSVCS_Q_VALIDATE_DEVICE_INSTANCE *q_u, NTSVCS_R_VALIDATE_DEVICE_INSTANCE *r_u ) +WERROR _PNP_ValidateDeviceInstance(pipes_struct *p, + struct PNP_ValidateDeviceInstance *r) { /* whatever dude */ return WERR_OK; @@ -228,16 +229,6 @@ WERROR _PNP_ReportLogOn(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _PNP_ValidateDeviceInstance(pipes_struct *p, - struct PNP_ValidateDeviceInstance *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _PNP_GetRootDeviceInstance(pipes_struct *p, struct PNP_GetRootDeviceInstance *r) { -- cgit From 3df6eedccfb1faeb778c4761594a6347bbf0b4b3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 00:21:56 +0100 Subject: Use pidl for _PNP_GetDeviceListSize(). Guenther (This used to be commit da6636577dbbdabd248ea87a07819c5e63577f86) --- source3/rpc_server/srv_ntsvcs.c | 18 +----------------- source3/rpc_server/srv_ntsvcs_nt.c | 23 ++++++----------------- 2 files changed, 7 insertions(+), 34 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index cd2248926c..73d4b4f4ed 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -56,23 +56,7 @@ static bool api_ntsvcs_get_version(pipes_struct *p) static bool api_ntsvcs_get_device_list_size(pipes_struct *p) { - NTSVCS_Q_GET_DEVICE_LIST_SIZE q_u; - NTSVCS_R_GET_DEVICE_LIST_SIZE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!ntsvcs_io_q_get_device_list_size("", &q_u, data, 0)) - return False; - - r_u.status = _ntsvcs_get_device_list_size(p, &q_u, &r_u); - - if(!ntsvcs_io_r_get_device_list_size("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_ntsvcs_call(p, NDR_PNP_GETDEVICELISTSIZE); } /******************************************************************* diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index b6e0126fa6..76bc24e7ba 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -45,21 +45,20 @@ WERROR _PNP_GetVersion(pipes_struct *p, /******************************************************************** ********************************************************************/ -WERROR _ntsvcs_get_device_list_size( pipes_struct *p, NTSVCS_Q_GET_DEVICE_LIST_SIZE *q_u, NTSVCS_R_GET_DEVICE_LIST_SIZE *r_u ) +WERROR _PNP_GetDeviceListSize(pipes_struct *p, + struct PNP_GetDeviceListSize *r) { - fstring device; char *devicepath; - if ( !q_u->devicename ) + if (!r->in.devicename) { return WERR_ACCESS_DENIED; + } - rpcstr_pull(device, q_u->devicename->buffer, sizeof(device), q_u->devicename->uni_str_len*2, 0); - - if (!(devicepath = get_device_path(p->mem_ctx, device))) { + if (!(devicepath = get_device_path(p->mem_ctx, r->in.devicename))) { return WERR_NOMEM; } - r_u->size = strlen(devicepath) + 2; + *r->out.size = strlen(devicepath) + 2; TALLOC_FREE(devicepath); @@ -269,16 +268,6 @@ WERROR _PNP_GetDeviceList(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _PNP_GetDeviceListSize(pipes_struct *p, - struct PNP_GetDeviceListSize *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _PNP_GetDepth(pipes_struct *p, struct PNP_GetDepth *r) { -- cgit From 1ce176c2b905b30c14ecde53e0898c343fe96cf9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 01:09:34 +0100 Subject: Use pidl for _PNP_HwProfFlags(). Guenther (This used to be commit b30d812b30b5a5b286db68fc94b09fff38db5306) --- source3/rpc_server/srv_ntsvcs.c | 18 +----------------- source3/rpc_server/srv_ntsvcs_nt.c | 17 ++++------------- 2 files changed, 5 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index 73d4b4f4ed..31d7408df0 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -144,23 +144,7 @@ static bool api_ntsvcs_get_hw_profile_info(pipes_struct *p) static bool api_ntsvcs_hw_profile_flags(pipes_struct *p) { - NTSVCS_Q_HW_PROFILE_FLAGS q_u; - NTSVCS_R_HW_PROFILE_FLAGS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!ntsvcs_io_q_hw_profile_flags("", &q_u, data, 0)) - return False; - - r_u.status = _ntsvcs_hw_profile_flags(p, &q_u, &r_u); - - if(!ntsvcs_io_r_hw_profile_flags("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_ntsvcs_call(p, NDR_PNP_HWPROFFLAGS); } /******************************************************************* diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index 76bc24e7ba..3215f73f79 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -168,10 +168,11 @@ WERROR _ntsvcs_get_hw_profile_info( pipes_struct *p, NTSVCS_Q_GET_HW_PROFILE_INF /******************************************************************** ********************************************************************/ -WERROR _ntsvcs_hw_profile_flags( pipes_struct *p, NTSVCS_Q_HW_PROFILE_FLAGS *q_u, NTSVCS_R_HW_PROFILE_FLAGS *r_u ) -{ +WERROR _PNP_HwProfFlags(pipes_struct *p, + struct PNP_HwProfFlags *r) +{ /* just nod your head */ - + return WERR_OK; } @@ -548,16 +549,6 @@ WERROR _PNP_RequestEjectPC(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _PNP_HwProfFlags(pipes_struct *p, - struct PNP_HwProfFlags *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _PNP_GetHwProfInfo(pipes_struct *p, struct PNP_GetHwProfInfo *r) { -- cgit From 6dfca8485dd6f8cfa1f6079c092f45ac79f5b86c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 01:32:29 +0100 Subject: Use pidl for _PNP_GetHwProfInfo(). Guenther (This used to be commit 7b7ce50e4bd8bc1ac94e882acf412e69b652f7d0) --- source3/rpc_server/srv_ntsvcs.c | 18 +----------------- source3/rpc_server/srv_ntsvcs_nt.c | 16 +++------------- 2 files changed, 4 insertions(+), 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index 31d7408df0..12fffc3e96 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -120,23 +120,7 @@ static bool api_ntsvcs_get_device_reg_property(pipes_struct *p) static bool api_ntsvcs_get_hw_profile_info(pipes_struct *p) { - NTSVCS_Q_GET_HW_PROFILE_INFO q_u; - NTSVCS_R_GET_HW_PROFILE_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!ntsvcs_io_q_get_hw_profile_info("", &q_u, data, 0)) - return False; - - r_u.status = _ntsvcs_get_hw_profile_info(p, &q_u, &r_u); - - if(!ntsvcs_io_r_get_hw_profile_info("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_ntsvcs_call(p, NDR_PNP_GETHWPROFINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index 3215f73f79..11ea5d0cd1 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -153,12 +153,12 @@ WERROR _PNP_ValidateDeviceInstance(pipes_struct *p, /******************************************************************** ********************************************************************/ -WERROR _ntsvcs_get_hw_profile_info( pipes_struct *p, NTSVCS_Q_GET_HW_PROFILE_INFO *q_u, NTSVCS_R_GET_HW_PROFILE_INFO *r_u ) +WERROR _PNP_GetHwProfInfo(pipes_struct *p, + struct PNP_GetHwProfInfo *r) { /* steal the incoming buffer */ - r_u->buffer_size = q_u->buffer_size; - r_u->buffer = q_u->buffer; + r->out.info = r->in.info; /* Take the 5th Ammentment */ @@ -549,16 +549,6 @@ WERROR _PNP_RequestEjectPC(pipes_struct *p, /**************************************************************** ****************************************************************/ -WERROR _PNP_GetHwProfInfo(pipes_struct *p, - struct PNP_GetHwProfInfo *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** -****************************************************************/ - WERROR _PNP_AddEmptyLogConf(pipes_struct *p, struct PNP_AddEmptyLogConf *r) { -- cgit From 2cd374db8d53cf9727da6c99a7fc48f4dd09fd4b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 18 Feb 2008 10:21:17 +1100 Subject: Replace C++-style comments with C. (This used to be commit a1d07469236c06b65f14a59a27d7f7abcb106b5e) --- source3/rpc_server/srv_samr_nt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 0db74c2a1b..df7bb9b206 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2535,10 +2535,10 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, logon_hours, pdb_get_bad_password_count(pw), pdb_get_logon_count(pw), - 0, //country_code, - 0, //code_page, - 0, //nt_password_set, - 0, //lm_password_set, + 0, /* country_code */ + 0, /* code_page */ + 0, /* nt_password_set */ + 0, /* lm_password_set */ password_expired); TALLOC_FREE(pw); -- cgit From 50e31b9346a1d191a959e493a1e4f0f6fdc582b8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 11:48:51 +0100 Subject: Remove whitespace, no code changes. Guenther (This used to be commit d752d52f1a4b75d7d4934da66566bc62e14caf27) --- source3/rpc_server/srv_svcctl_nt.c | 322 ++++++++++++++++++------------------- 1 file changed, 161 insertions(+), 161 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index ac45d8bf75..11b7ab6ca2 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -1,22 +1,22 @@ -/* +/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * * Copyright (C) Marcin Krzysztof Porwit 2005. - * + * * Largely Rewritten (Again) by: * Copyright (C) Gerald (Jerry) Carter 2005. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ @@ -63,42 +63,42 @@ bool init_service_op_table( void ) const char **service_list = lp_svcctl_list(); int num_services = SVCCTL_NUM_INTERNAL_SERVICES + str_list_count( service_list ); int i; - + if ( !(svcctl_ops = TALLOC_ARRAY( NULL, struct service_control_op, num_services+1)) ) { DEBUG(0,("init_service_op_table: talloc() failed!\n")); return False; } /* services listed in smb.conf get the rc.init interface */ - + for ( i=0; service_list && service_list[i]; i++ ) { svcctl_ops[i].name = talloc_strdup( svcctl_ops, service_list[i] ); svcctl_ops[i].ops = &rcinit_svc_ops; } - + /* add builtin services */ - + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "Spooler" ); svcctl_ops[i].ops = &spoolss_svc_ops; i++; - + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "NETLOGON" ); svcctl_ops[i].ops = &netlogon_svc_ops; i++; - + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "RemoteRegistry" ); svcctl_ops[i].ops = &winreg_svc_ops; i++; - + svcctl_ops[i].name = talloc_strdup( svcctl_ops, "WINS" ); svcctl_ops[i].ops = &wins_svc_ops; i++; - + /* NULL terminate the array */ - + svcctl_ops[i].name = NULL; svcctl_ops[i].ops = NULL; - + return True; } @@ -119,7 +119,7 @@ static struct service_control_op* find_service_by_name( const char *name ) /******************************************************************** ********************************************************************/ -static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, +static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, uint32 access_desired, uint32 *access_granted ) { NTSTATUS result; @@ -128,7 +128,7 @@ static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, DEBUG(5,("svcctl_access_check: using root's token\n")); token = get_root_nt_token(); } - + se_access_check( sec_desc, token, access_desired, access_granted, &result ); return result; @@ -139,7 +139,7 @@ static NTSTATUS svcctl_access_check( SEC_DESC *sec_desc, NT_USER_TOKEN *token, static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx ) { - SEC_ACE ace[2]; + SEC_ACE ace[2]; SEC_ACCESS mask; size_t i = 0; SEC_DESC *sd; @@ -147,18 +147,18 @@ static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx ) size_t sd_size; /* basic access for Everyone */ - + init_sec_access(&mask, SC_MANAGER_READ_ACCESS ); init_sec_ace(&ace[i++], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - + /* Full Access 'BUILTIN\Administrators' */ - + init_sec_access(&mask,SC_MANAGER_ALL_ACCESS ); init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); - - + + /* create the security descriptor */ - + if ( !(acl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace)) ) return NULL; @@ -173,7 +173,7 @@ static SEC_DESC* construct_scm_sd( TALLOC_CTX *ctx ) /****************************************************************** free() function for REGISTRY_KEY *****************************************************************/ - + static void free_service_handle_info(void *ptr) { TALLOC_FREE( ptr ); @@ -197,21 +197,21 @@ static SERVICE_INFO *find_service_info_by_hnd(pipes_struct *p, POLICY_HND *hnd) /****************************************************************** *****************************************************************/ - + static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, uint32 type, const char *service, uint32 access_granted ) { SERVICE_INFO *info = NULL; WERROR result = WERR_OK; struct service_control_op *s_op; - + if ( !(info = TALLOC_ZERO_P( NULL, SERVICE_INFO )) ) return WERR_NOMEM; /* the Service Manager has a NULL name */ - + info->type = SVC_HANDLE_IS_SCM; - + switch ( type ) { case SVC_HANDLE_IS_SCM: info->type = SVC_HANDLE_IS_SCM; @@ -220,17 +220,17 @@ static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, u case SVC_HANDLE_IS_DBLOCK: info->type = SVC_HANDLE_IS_DBLOCK; break; - + case SVC_HANDLE_IS_SERVICE: info->type = SVC_HANDLE_IS_SERVICE; - + /* lookup the SERVICE_CONTROL_OPS */ if ( !(s_op = find_service_by_name( service )) ) { result = WERR_NO_SUCH_SERVICE; goto done; } - + info->ops = s_op->ops; if ( !(info->name = talloc_strdup( info, s_op->name )) ) { @@ -244,15 +244,15 @@ static WERROR create_open_service_handle( pipes_struct *p, POLICY_HND *handle, u goto done; } - info->access_granted = access_granted; - + info->access_granted = access_granted; + /* store the SERVICE_INFO and create an open handle */ - + if ( !create_policy_hnd( p, handle, free_service_handle_info, info ) ) { result = WERR_ACCESS_DENIED; goto done; } - + done: if ( !W_ERROR_IS_OK(result) ) free_service_handle_info( info ); @@ -268,17 +268,17 @@ WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVC SEC_DESC *sec_desc; uint32 access_granted = 0; NTSTATUS status; - + /* perform access checks */ - + if ( !(sec_desc = construct_scm_sd( p->mem_ctx )) ) return WERR_NOMEM; - + se_map_generic( &q_u->access, &scm_generic_map ); status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); if ( !NT_STATUS_IS_OK(status) ) return ntstatus_to_werror( status ); - + return create_open_service_handle( p, &r_u->handle, SVC_HANDLE_IS_SCM, NULL, access_granted ); } @@ -307,7 +307,7 @@ WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_ if ( !find_service_info_by_hnd( p, &q_u->handle ) ) return WERR_BADFID; - /* perform access checks. Use the root token in order to ensure that we + /* perform access checks. Use the root token in order to ensure that we retrieve the security descriptor */ if ( !(sec_desc = svcctl_get_secdesc( p->mem_ctx, service, get_root_nt_token() )) ) @@ -329,7 +329,7 @@ WERROR _svcctl_CloseServiceHandle(pipes_struct *p, struct svcctl_CloseServiceHan if ( !close_policy_hnd( p, r->in.handle ) ) return WERR_BADFID; - return WERR_OK; + return WERR_OK; } /******************************************************************** @@ -340,14 +340,14 @@ WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, fstring service; const char *display_name; SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); - + /* can only use an SCM handle here */ - + if ( !info || (info->type != SVC_HANDLE_IS_SCM) ) return WERR_BADFID; - + rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); - + display_name = svcctl_lookup_dispname(p->mem_ctx, service, p->pipe_user.nt_user_token ); init_svcctl_r_get_display_name( r_u, display_name ? display_name : ""); @@ -360,15 +360,15 @@ WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_R_QUERY_STATUS *r_u) { SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) return WERR_BADFID; - + if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_STATUS) ) return WERR_ACCESS_DENIED; - + /* try the service specific status call */ return info->ops->service_status( info->name, &r_u->svc_status ); @@ -383,7 +383,7 @@ static int enumerate_status( TALLOC_CTX *ctx, ENUM_SERVICES_STATUS **status, NT_ int i; ENUM_SERVICES_STATUS *st; const char *display_name; - + /* just count */ while ( svcctl_ops[num_services].name ) num_services++; @@ -392,16 +392,16 @@ static int enumerate_status( TALLOC_CTX *ctx, ENUM_SERVICES_STATUS **status, NT_ DEBUG(0,("enumerate_status: talloc() failed!\n")); return -1; } - + for ( i=0; iservice_status( svcctl_ops[i].name, &st[i].status ); } - + *status = st; return num_services; @@ -419,12 +419,12 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT WERROR result = WERR_OK; SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); NT_USER_TOKEN *token = p->pipe_user.nt_user_token; - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SCM) ) return WERR_BADFID; - + if ( !(info->access_granted & SC_RIGHT_MGR_ENUMERATE_SERVICE) ) { return WERR_ACCESS_DENIED; } @@ -469,15 +469,15 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCTL_R_START_SERVICE *r_u) { SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) return WERR_BADFID; - + if ( !(info->access_granted & SC_RIGHT_SVC_START) ) return WERR_ACCESS_DENIED; - + return info->ops->start_service( info->name ); } @@ -487,28 +487,28 @@ WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCT WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, SVCCTL_R_CONTROL_SERVICE *r_u) { SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); - + /* perform access checks */ - + if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) - return WERR_BADFID; - + return WERR_BADFID; + switch ( q_u->control ) { case SVCCTL_CONTROL_STOP: if ( !(info->access_granted & SC_RIGHT_SVC_STOP) ) return WERR_ACCESS_DENIED; - + return info->ops->stop_service( info->name, &r_u->svc_status ); - + case SVCCTL_CONTROL_INTERROGATE: if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_STATUS) ) return WERR_ACCESS_DENIED; - + return info->ops->service_status( info->name, &r_u->svc_status ); } - + /* default control action */ - + return WERR_ACCESS_DENIED; } @@ -518,22 +518,22 @@ WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, S WERROR _svcctl_enum_dependent_services( pipes_struct *p, SVCCTL_Q_ENUM_DEPENDENT_SERVICES *q_u, SVCCTL_R_ENUM_DEPENDENT_SERVICES *r_u ) { SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) - return WERR_BADFID; - + return WERR_BADFID; + if ( !(info->access_granted & SC_RIGHT_SVC_ENUMERATE_DEPENDENTS) ) return WERR_ACCESS_DENIED; - - /* we have to set the outgoing buffer size to the same as the + + /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); - + r_u->needed = q_u->buffer_size; - + /* no dependent services...basically a stub function */ r_u->returned = 0; @@ -547,21 +547,21 @@ WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_ { SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); uint32 buffer_size; - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) - return WERR_BADFID; - + return WERR_BADFID; + if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_STATUS) ) return WERR_ACCESS_DENIED; - /* we have to set the outgoing buffer size to the same as the + /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure) */ rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); r_u->needed = q_u->buffer_size; - + switch ( q_u->level ) { case SVC_STATUS_PROCESS_INFO: { @@ -576,18 +576,18 @@ WERROR _svcctl_query_service_status_ex( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_ buffer_size = sizeof(SERVICE_STATUS_PROCESS); break; } - + default: - return WERR_UNKNOWN_LEVEL; + return WERR_UNKNOWN_LEVEL; } - + buffer_size += buffer_size % 4; r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size; - if (buffer_size > q_u->buffer_size ) + if (buffer_size > q_u->buffer_size ) return WERR_MORE_DATA; - + return WERR_OK; } @@ -600,12 +600,12 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG REGISTRY_VALUE *val; /* retrieve the registry values for this service */ - + if ( !(values = svcctl_fetch_regvalues( name, token )) ) return WERR_REG_CORRUPT; - + /* now fill in the individual values */ - + config->displayname = TALLOC_ZERO_P( ctx, UNISTR2 ); if ( (val = regval_ctr_getvalue( values, "DisplayName" )) != NULL ) init_unistr2( config->displayname, regval_sz( val ), UNI_STR_TERMINATE ); @@ -613,23 +613,23 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG init_unistr2( config->displayname, name, UNI_STR_TERMINATE ); if ( (val = regval_ctr_getvalue( values, "ObjectName" )) != NULL ) { - config->startname = TALLOC_ZERO_P( ctx, UNISTR2 ); + config->startname = TALLOC_ZERO_P( ctx, UNISTR2 ); init_unistr2( config->startname, regval_sz( val ), UNI_STR_TERMINATE ); } - + if ( (val = regval_ctr_getvalue( values, "ImagePath" )) != NULL ) { - config->executablepath = TALLOC_ZERO_P( ctx, UNISTR2 ); + config->executablepath = TALLOC_ZERO_P( ctx, UNISTR2 ); init_unistr2( config->executablepath, regval_sz( val ), UNI_STR_TERMINATE ); } /* a few hard coded values */ /* loadordergroup and dependencies are empty */ - + config->tag_id = 0x00000000; /* unassigned loadorder group */ config->service_type = SVCCTL_WIN32_OWN_PROC; config->error_control = SVCCTL_SVC_ERROR_NORMAL; - /* set the start type. NetLogon and WINS are disabled to prevent + /* set the start type. NetLogon and WINS are disabled to prevent the client from showing the "Start" button (if of course the services are not running */ @@ -639,7 +639,7 @@ static WERROR fill_svc_config( TALLOC_CTX *ctx, const char *name, SERVICE_CONFIG config->start_type = SVCCTL_DISABLED; else config->start_type = SVCCTL_DEMAND_START; - + TALLOC_FREE( values ); @@ -654,24 +654,24 @@ WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CON SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); uint32 buffer_size; WERROR wresult; - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) - return WERR_BADFID; - + return WERR_BADFID; + if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_CONFIG) ) return WERR_ACCESS_DENIED; - /* we have to set the outgoing buffer size to the same as the + /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ r_u->needed = q_u->buffer_size; - + wresult = fill_svc_config( p->mem_ctx, info->name, &r_u->config, p->pipe_user.nt_user_token ); if ( !W_ERROR_IS_OK(wresult) ) return wresult; - + buffer_size = svcctl_sizeof_service_config( &r_u->config ); r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size; @@ -679,7 +679,7 @@ WERROR _svcctl_query_service_config( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CON ZERO_STRUCTP( &r_u->config ); return WERR_INSUFFICIENT_BUFFER; } - + return WERR_OK; } @@ -755,17 +755,17 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO WERROR _svcctl_lock_service_db( pipes_struct *p, SVCCTL_Q_LOCK_SERVICE_DB *q_u, SVCCTL_R_LOCK_SERVICE_DB *r_u ) { SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); - + /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SCM) ) - return WERR_BADFID; - + return WERR_BADFID; + if ( !(info->access_granted & SC_RIGHT_MGR_LOCK) ) return WERR_ACCESS_DENIED; /* Just open a handle. Doesn't actually lock anything */ - + return create_open_service_handle( p, &r_u->h_lock, SVC_HANDLE_IS_DBLOCK, NULL, 0 ); ; } @@ -779,8 +779,8 @@ WERROR _svcctl_unlock_service_db( pipes_struct *p, SVCCTL_Q_UNLOCK_SERVICE_DB *q if ( !info || (info->type != SVC_HANDLE_IS_DBLOCK) ) - return WERR_BADFID; - + return WERR_BADFID; + return close_policy_hnd( p, &q_u->h_lock) ? WERR_OK : WERR_BADFID; } @@ -796,7 +796,7 @@ WERROR _svcctl_query_service_sec( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_SEC *q /* only support the SCM and individual services */ if ( !info || !(info->type & (SVC_HANDLE_IS_SERVICE|SVC_HANDLE_IS_SCM)) ) - return WERR_BADFID; + return WERR_BADFID; /* check access reights (according to MSDN) */ @@ -824,7 +824,7 @@ WERROR _svcctl_query_service_sec( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_SEC *q if ( !sec_io_desc("", &sec_desc, &r_u->buffer.prs, 0 ) ) return WERR_NOMEM; - + return WERR_OK; } @@ -843,37 +843,37 @@ WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, /* can't set the security de4scriptor on the ServiceControlManager */ if ( info->type == SVC_HANDLE_IS_SCM ) - return WERR_ACCESS_DENIED; + return WERR_ACCESS_DENIED; /* check the access on the open handle */ - + switch ( q_u->security_flags ) { case DACL_SECURITY_INFORMATION: required_access = STD_RIGHT_WRITE_DAC_ACCESS; break; - + case OWNER_SECURITY_INFORMATION: case GROUP_SECURITY_INFORMATION: required_access = STD_RIGHT_WRITE_OWNER_ACCESS; break; - + case SACL_SECURITY_INFORMATION: return WERR_INVALID_PARAM; default: return WERR_INVALID_PARAM; } - + if ( !(info->access_granted & required_access) ) return WERR_ACCESS_DENIED; - + /* read the security descfriptor */ - + if ( !sec_io_desc("", &sec_desc, &q_u->buffer.prs, 0 ) ) return WERR_NOMEM; - + /* store the new SD */ - if ( !svcctl_set_secdesc( p->mem_ctx, info->name, sec_desc, p->pipe_user.nt_user_token ) ) + if ( !svcctl_set_secdesc( p->mem_ctx, info->name, sec_desc, p->pipe_user.nt_user_token ) ) return WERR_ACCESS_DENIED; return WERR_OK; @@ -883,258 +883,258 @@ WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, WERROR _svcctl_ControlService(pipes_struct *p, struct svcctl_ControlService *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_DeleteService(pipes_struct *p, struct svcctl_DeleteService *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_LockServiceDatabase(pipes_struct *p, struct svcctl_LockServiceDatabase *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceObjectSecurity(pipes_struct *p, struct svcctl_QueryServiceObjectSecurity *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_SetServiceObjectSecurity(pipes_struct *p, struct svcctl_SetServiceObjectSecurity *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceStatus(pipes_struct *p, struct svcctl_QueryServiceStatus *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_SetServiceStatus(pipes_struct *p, struct svcctl_SetServiceStatus *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_UnlockServiceDatabase(pipes_struct *p, struct svcctl_UnlockServiceDatabase *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_NotifyBootConfigStatus(pipes_struct *p, struct svcctl_NotifyBootConfigStatus *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_SCSetServiceBitsW(pipes_struct *p, struct svcctl_SCSetServiceBitsW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_ChangeServiceConfigW(pipes_struct *p, struct svcctl_ChangeServiceConfigW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_CreateServiceW(pipes_struct *p, struct svcctl_CreateServiceW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_EnumDependentServicesW(pipes_struct *p, struct svcctl_EnumDependentServicesW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_EnumServicesStatusW(pipes_struct *p, struct svcctl_EnumServicesStatusW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_OpenSCManagerW(pipes_struct *p, struct svcctl_OpenSCManagerW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_OpenServiceW(pipes_struct *p, struct svcctl_OpenServiceW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceConfigW(pipes_struct *p, struct svcctl_QueryServiceConfigW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceLockStatusW(pipes_struct *p, struct svcctl_QueryServiceLockStatusW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_StartServiceW(pipes_struct *p, struct svcctl_StartServiceW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_GetServiceDisplayNameW(pipes_struct *p, struct svcctl_GetServiceDisplayNameW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_GetServiceKeyNameW(pipes_struct *p, struct svcctl_GetServiceKeyNameW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_SCSetServiceBitsA(pipes_struct *p, struct svcctl_SCSetServiceBitsA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_ChangeServiceConfigA(pipes_struct *p, struct svcctl_ChangeServiceConfigA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_CreateServiceA(pipes_struct *p, struct svcctl_CreateServiceA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_EnumDependentServicesA(pipes_struct *p, struct svcctl_EnumDependentServicesA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_EnumServicesStatusA(pipes_struct *p, struct svcctl_EnumServicesStatusA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_OpenSCManagerA(pipes_struct *p, struct svcctl_OpenSCManagerA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_OpenServiceA(pipes_struct *p, struct svcctl_OpenServiceA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceConfigA(pipes_struct *p, struct svcctl_QueryServiceConfigA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceLockStatusA(pipes_struct *p, struct svcctl_QueryServiceLockStatusA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_StartServiceA(pipes_struct *p, struct svcctl_StartServiceA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_GetServiceDisplayNameA(pipes_struct *p, struct svcctl_GetServiceDisplayNameA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_GetServiceKeyNameA(pipes_struct *p, struct svcctl_GetServiceKeyNameA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_GetCurrentGroupeStateW(pipes_struct *p, struct svcctl_GetCurrentGroupeStateW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_EnumServiceGroupW(pipes_struct *p, struct svcctl_EnumServiceGroupW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_ChangeServiceConfig2A(pipes_struct *p, struct svcctl_ChangeServiceConfig2A *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_ChangeServiceConfig2W(pipes_struct *p, struct svcctl_ChangeServiceConfig2W *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceConfig2A(pipes_struct *p, struct svcctl_QueryServiceConfig2A *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceConfig2W(pipes_struct *p, struct svcctl_QueryServiceConfig2W *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_QueryServiceStatusEx(pipes_struct *p, struct svcctl_QueryServiceStatusEx *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _EnumServicesStatusExA(pipes_struct *p, struct EnumServicesStatusExA *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _EnumServicesStatusExW(pipes_struct *p, struct EnumServicesStatusExW *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } WERROR _svcctl_SCSendTSMessage(pipes_struct *p, struct svcctl_SCSendTSMessage *r) { p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + return WERR_NOT_SUPPORTED; } -- cgit From 357bf008121f7cb8609b10d37501151adb34bd28 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 11:55:31 +0100 Subject: Use pidl for _svcctl_OpenSCManagerW(). Guenther (This used to be commit 1131e914df9c69b046f335999b7b62063e92fb9d) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 15 +++++---------- 2 files changed, 6 insertions(+), 27 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index ce81a24202..ba939ac11a 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -53,23 +53,7 @@ static bool api_svcctl_close_service(pipes_struct *p) static bool api_svcctl_open_scmanager(pipes_struct *p) { - SVCCTL_Q_OPEN_SCMANAGER q_u; - SVCCTL_R_OPEN_SCMANAGER r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_open_scmanager("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_open_scmanager(p, &q_u, &r_u); - - if(!svcctl_io_r_open_scmanager("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_OPENSCMANAGERW); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 11b7ab6ca2..459def11c7 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -263,7 +263,8 @@ done: /******************************************************************** ********************************************************************/ -WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVCCTL_R_OPEN_SCMANAGER *r_u) +WERROR _svcctl_OpenSCManagerW(pipes_struct *p, + struct svcctl_OpenSCManagerW *r) { SEC_DESC *sec_desc; uint32 access_granted = 0; @@ -274,12 +275,12 @@ WERROR _svcctl_open_scmanager(pipes_struct *p, SVCCTL_Q_OPEN_SCMANAGER *q_u, SVC if ( !(sec_desc = construct_scm_sd( p->mem_ctx )) ) return WERR_NOMEM; - se_map_generic( &q_u->access, &scm_generic_map ); - status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); + se_map_generic( &r->in.access_mask, &scm_generic_map ); + status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, r->in.access_mask, &access_granted ); if ( !NT_STATUS_IS_OK(status) ) return ntstatus_to_werror( status ); - return create_open_service_handle( p, &r_u->handle, SVC_HANDLE_IS_SCM, NULL, access_granted ); + return create_open_service_handle( p, r->out.handle, SVC_HANDLE_IS_SCM, NULL, access_granted ); } /******************************************************************** @@ -964,12 +965,6 @@ WERROR _svcctl_EnumServicesStatusW(pipes_struct *p, struct svcctl_EnumServicesSt return WERR_NOT_SUPPORTED; } -WERROR _svcctl_OpenSCManagerW(pipes_struct *p, struct svcctl_OpenSCManagerW *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_OpenServiceW(pipes_struct *p, struct svcctl_OpenServiceW *r) { p->rng_fault_state = True; -- cgit From 5943ff68e7838be67148b1c0eef91f3c1ab66230 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 12:55:35 +0100 Subject: Use pidl for _svcctl_OpenServiceW(). Note that this call did and still does panic in registry access. Michael has an idea how to fix this. Guenther (This used to be commit b2fa41072ddd2aba000a33eb32ccee408d8304db) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 32 ++++++++++++-------------------- 2 files changed, 13 insertions(+), 37 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index ba939ac11a..a134df8597 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -61,23 +61,7 @@ static bool api_svcctl_open_scmanager(pipes_struct *p) static bool api_svcctl_open_service(pipes_struct *p) { - SVCCTL_Q_OPEN_SERVICE q_u; - SVCCTL_R_OPEN_SERVICE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_open_service("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_open_service(p, &q_u, &r_u); - - if(!svcctl_io_r_open_service("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_OPENSERVICEW); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 459def11c7..40f3584e3e 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -284,28 +284,26 @@ WERROR _svcctl_OpenSCManagerW(pipes_struct *p, } /******************************************************************** + _svcctl_OpenServiceW ********************************************************************/ -WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_R_OPEN_SERVICE *r_u) +WERROR _svcctl_OpenServiceW(pipes_struct *p, + struct svcctl_OpenServiceW *r) { SEC_DESC *sec_desc; uint32 access_granted = 0; NTSTATUS status; - char *service = NULL; - size_t ret = rpcstr_pull_talloc(p->mem_ctx, - &service, - q_u->servicename.buffer, - q_u->servicename.uni_str_len*2, - 0); - - if (ret == (size_t)-1 || !service) { + const char *service = NULL; + + service = r->in.ServiceName; + if (!service) { return WERR_NOMEM; } - DEBUG(5, ("_svcctl_open_service: Attempting to open Service [%s], \n", service)); + DEBUG(5, ("_svcctl_OpenServiceW: Attempting to open Service [%s], \n", service)); /* based on my tests you can open a service if you have a valid scm handle */ - if ( !find_service_info_by_hnd( p, &q_u->handle ) ) + if ( !find_service_info_by_hnd( p, r->in.scmanager_handle) ) return WERR_BADFID; /* perform access checks. Use the root token in order to ensure that we @@ -314,12 +312,12 @@ WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_ if ( !(sec_desc = svcctl_get_secdesc( p->mem_ctx, service, get_root_nt_token() )) ) return WERR_NOMEM; - se_map_generic( &q_u->access, &svc_generic_map ); - status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, q_u->access, &access_granted ); + se_map_generic( &r->in.access_mask, &svc_generic_map ); + status = svcctl_access_check( sec_desc, p->pipe_user.nt_user_token, r->in.access_mask, &access_granted ); if ( !NT_STATUS_IS_OK(status) ) return ntstatus_to_werror( status ); - return create_open_service_handle( p, &r_u->handle, SVC_HANDLE_IS_SERVICE, service, access_granted ); + return create_open_service_handle( p, r->out.handle, SVC_HANDLE_IS_SERVICE, service, access_granted ); } /******************************************************************** @@ -965,12 +963,6 @@ WERROR _svcctl_EnumServicesStatusW(pipes_struct *p, struct svcctl_EnumServicesSt return WERR_NOT_SUPPORTED; } -WERROR _svcctl_OpenServiceW(pipes_struct *p, struct svcctl_OpenServiceW *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_QueryServiceConfigW(pipes_struct *p, struct svcctl_QueryServiceConfigW *r) { p->rng_fault_state = True; -- cgit From 1c298d59a670f1c1ccf7c492b5a29dc8bb15ed0c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 13:43:12 +0100 Subject: Use pidl for _svcctl_GetServiceDisplayNameW(). Guenther (This used to be commit 2746e88c5c4a9e859356d5c53106eba0c2cd7cbe) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 28 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index a134df8597..84c986dbfb 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -69,23 +69,7 @@ static bool api_svcctl_open_service(pipes_struct *p) static bool api_svcctl_get_display_name(pipes_struct *p) { - SVCCTL_Q_GET_DISPLAY_NAME q_u; - SVCCTL_R_GET_DISPLAY_NAME r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_get_display_name("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_get_display_name(p, &q_u, &r_u); - - if(!svcctl_io_r_get_display_name("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_GETSERVICEDISPLAYNAMEW); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 40f3584e3e..bdd0f4ffe3 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -332,23 +332,30 @@ WERROR _svcctl_CloseServiceHandle(pipes_struct *p, struct svcctl_CloseServiceHan } /******************************************************************** + _svcctl_GetServiceDisplayNameW ********************************************************************/ -WERROR _svcctl_get_display_name(pipes_struct *p, SVCCTL_Q_GET_DISPLAY_NAME *q_u, SVCCTL_R_GET_DISPLAY_NAME *r_u) +WERROR _svcctl_GetServiceDisplayNameW(pipes_struct *p, + struct svcctl_GetServiceDisplayNameW *r) { - fstring service; + const char *service; const char *display_name; - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); /* can only use an SCM handle here */ if ( !info || (info->type != SVC_HANDLE_IS_SCM) ) return WERR_BADFID; - rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0); + service = r->in.service_name; display_name = svcctl_lookup_dispname(p->mem_ctx, service, p->pipe_user.nt_user_token ); - init_svcctl_r_get_display_name( r_u, display_name ? display_name : ""); + if (!display_name) { + display_name = ""; + } + + *r->out.display_name = display_name; + *r->out.display_name_length = strlen(display_name); return WERR_OK; } @@ -981,12 +988,6 @@ WERROR _svcctl_StartServiceW(pipes_struct *p, struct svcctl_StartServiceW *r) return WERR_NOT_SUPPORTED; } -WERROR _svcctl_GetServiceDisplayNameW(pipes_struct *p, struct svcctl_GetServiceDisplayNameW *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_GetServiceKeyNameW(pipes_struct *p, struct svcctl_GetServiceKeyNameW *r) { p->rng_fault_state = True; -- cgit From 0349835b3439a2321c30220340aef44a5f13c719 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 14:40:34 +0100 Subject: Use pidl for _lsa_LookupNames() and _lsa_LookupNames2(). Hopefully I didn't screw this up. Please check :) Guenther (This used to be commit 01b733f10c1645668f2aea2841bbdc64b4bd5c51) --- source3/rpc_server/srv_lsa.c | 48 +-------- source3/rpc_server/srv_lsa_nt.c | 230 +++++++++++++++++++++------------------- 2 files changed, 123 insertions(+), 155 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index dfb3323873..dd4afcab52 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -118,29 +118,7 @@ static bool api_lsa_lookup_sids(pipes_struct *p) static bool api_lsa_lookup_names(pipes_struct *p) { - LSA_Q_LOOKUP_NAMES q_u; - LSA_R_LOOKUP_NAMES r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_names("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_names: failed to unmarshall LSA_Q_LOOKUP_NAMES.\n")); - return False; - } - - r_u.status = _lsa_lookup_names(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_lookup_names("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_names: Failed to marshall LSA_R_LOOKUP_NAMES.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES); } /*************************************************************************** @@ -412,29 +390,7 @@ static bool api_lsa_lookup_sids3(pipes_struct *p) static bool api_lsa_lookup_names2(pipes_struct *p) { - LSA_Q_LOOKUP_NAMES2 q_u; - LSA_R_LOOKUP_NAMES2 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_names2("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_names2: failed to unmarshall LSA_Q_LOOKUP_NAMES2.\n")); - return False; - } - - r_u.status = _lsa_lookup_names2(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_lookup_names2("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_names2: Failed to marshall LSA_R_LOOKUP_NAMES2.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES2); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 027277e8d9..6cf26e7eb2 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -46,6 +46,51 @@ const struct generic_mapping lsa_generic_mapping = { POLICY_ALL_ACCESS }; +/*************************************************************************** + init_lsa_ref_domain_list - adds a domain if it's not already in, returns the index. +***************************************************************************/ + +static int init_lsa_ref_domain_list(TALLOC_CTX *mem_ctx, + struct lsa_RefDomainList *ref, + const char *dom_name, + DOM_SID *dom_sid) +{ + int num = 0; + + if (dom_name != NULL) { + for (num = 0; num < ref->count; num++) { + if (sid_equal(dom_sid, ref->domains[num].sid)) { + return num; + } + } + } else { + num = ref->count; + } + + if (num >= MAX_REF_DOMAINS) { + /* index not found, already at maximum domain limit */ + return -1; + } + + ref->count = num + 1; + ref->max_size = MAX_REF_DOMAINS; + + ref->domains = TALLOC_REALLOC_ARRAY(mem_ctx, ref->domains, + struct lsa_DomainInfo, ref->count); + if (!ref->domains) { + return -1; + } + + init_lsa_StringLarge(&ref->domains[num].name, dom_name); + ref->domains[num].sid = sid_dup_talloc(mem_ctx, dom_sid); + if (!ref->domains[num].sid) { + return -1; + } + + return num; +} + + /******************************************************************* Function to free the per handle data. ********************************************************************/ @@ -123,12 +168,12 @@ static int init_dom_ref(DOM_R_REF *ref, const char *dom_name, DOM_SID *dom_sid) ***************************************************************************/ static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx, - DOM_R_REF *ref, - DOM_RID *prid, - uint32 num_entries, - const UNISTR2 *name, - int flags, - uint32 *pmapped_count) + struct lsa_RefDomainList *ref, + struct lsa_TranslatedSid *prid, + uint32_t num_entries, + struct lsa_String *name, + int flags, + uint32_t *pmapped_count) { uint32 mapped_count, i; @@ -141,15 +186,14 @@ static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx, DOM_SID sid; uint32 rid; int dom_idx; - char *full_name; + const char *full_name; const char *domain; enum lsa_SidType type = SID_NAME_UNKNOWN; /* Split name into domain and user component */ - full_name = rpcstr_pull_unistr2_talloc(mem_ctx, &name[i]); + full_name = name[i].string; if (full_name == NULL) { - DEBUG(0, ("pull_ucs2_talloc failed\n")); return NT_STATUS_NO_MEMORY; } @@ -182,11 +226,11 @@ static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx, if (type != SID_NAME_UNKNOWN) { sid_split_rid(&sid, &rid); - dom_idx = init_dom_ref(ref, domain, &sid); + dom_idx = init_lsa_ref_domain_list(mem_ctx, ref, domain, &sid); mapped_count++; } - init_dom_rid(&prid[i], rid, type, dom_idx); + init_lsa_translated_sid(&prid[i], type, rid, dom_idx); } *pmapped_count = mapped_count; @@ -1068,33 +1112,37 @@ static int lsa_lookup_level_to_flags(uint16 level) } /*************************************************************************** -lsa_reply_lookup_names + _lsa_LookupNames ***************************************************************************/ -NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP_NAMES *r_u) +NTSTATUS _lsa_LookupNames(pipes_struct *p, + struct lsa_LookupNames *r) { + NTSTATUS status = NT_STATUS_NONE_MAPPED; struct lsa_info *handle; - UNISTR2 *names = q_u->uni_name; - uint32 num_entries = q_u->num_entries; - DOM_R_REF *ref; - DOM_RID *rids; + struct lsa_String *names = r->in.names; + uint32 num_entries = r->in.num_names; + struct lsa_RefDomainList *domains = NULL; + struct lsa_TranslatedSid *rids = NULL; uint32 mapped_count = 0; int flags = 0; if (num_entries > MAX_LOOKUP_SIDS) { num_entries = MAX_LOOKUP_SIDS; - DEBUG(5,("_lsa_lookup_names: truncating name lookup list to %d\n", num_entries)); + DEBUG(5,("_lsa_LookupNames: truncating name lookup list to %d\n", + num_entries)); } - flags = lsa_lookup_level_to_flags(q_u->lookup_level); + flags = lsa_lookup_level_to_flags(r->in.level); - ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - if (!ref) { + domains = TALLOC_ZERO_P(p->mem_ctx, struct lsa_RefDomainList); + if (!domains) { return NT_STATUS_NO_MEMORY; } if (num_entries) { - rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries); + rids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_TranslatedSid, + num_entries); if (!rids) { return NT_STATUS_NO_MEMORY; } @@ -1102,114 +1150,90 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP rids = NULL; } - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { - r_u->status = NT_STATUS_INVALID_HANDLE; + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) { + status = NT_STATUS_INVALID_HANDLE; goto done; } /* check if the user have enough rights */ if (!(handle->access & POLICY_LOOKUP_NAMES)) { - r_u->status = NT_STATUS_ACCESS_DENIED; + status = NT_STATUS_ACCESS_DENIED; goto done; } /* set up the LSA Lookup RIDs response */ become_root(); /* lookup_name can require root privs */ - r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries, - names, flags, &mapped_count); + status = lookup_lsa_rids(p->mem_ctx, domains, rids, num_entries, + names, flags, &mapped_count); unbecome_root(); done: - if (NT_STATUS_IS_OK(r_u->status) && (num_entries != 0) ) { - if (mapped_count == 0) - r_u->status = NT_STATUS_NONE_MAPPED; - else if (mapped_count != num_entries) - r_u->status = STATUS_SOME_UNMAPPED; + if (NT_STATUS_IS_OK(status) && (num_entries != 0) ) { + if (mapped_count == 0) { + status = NT_STATUS_NONE_MAPPED; + } else if (mapped_count != num_entries) { + status = STATUS_SOME_UNMAPPED; + } } - init_reply_lookup_names(r_u, ref, num_entries, rids, mapped_count); - return r_u->status; + *r->out.count = num_entries; + *r->out.domains = domains; + r->out.sids->sids = rids; + r->out.sids->count = mapped_count; + + return status; } /*************************************************************************** -lsa_reply_lookup_names2 + _lsa_LookupNames2 ***************************************************************************/ -NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOOKUP_NAMES2 *r_u) +NTSTATUS _lsa_LookupNames2(pipes_struct *p, + struct lsa_LookupNames2 *r) { - struct lsa_info *handle; - UNISTR2 *names = q_u->uni_name; - uint32 num_entries = q_u->num_entries; - DOM_R_REF *ref; - DOM_RID *rids; - DOM_RID2 *rids2; - int i; - uint32 mapped_count = 0; - int flags = 0; - - if (num_entries > MAX_LOOKUP_SIDS) { - num_entries = MAX_LOOKUP_SIDS; - DEBUG(5,("_lsa_lookup_names2: truncating name lookup list to %d\n", num_entries)); - } - - flags = lsa_lookup_level_to_flags(q_u->lookup_level); + NTSTATUS status; + struct lsa_LookupNames q; + struct lsa_TransSidArray2 *sid_array2 = r->in.sids; + struct lsa_TransSidArray *sid_array = NULL; + uint32_t i; - ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - if (ref == NULL) { - r_u->status = NT_STATUS_NO_MEMORY; + sid_array = TALLOC_ZERO_P(p->mem_ctx, struct lsa_TransSidArray); + if (!sid_array) { return NT_STATUS_NO_MEMORY; } - if (num_entries) { - rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries); - rids2 = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries); - if ((rids == NULL) || (rids2 == NULL)) { - r_u->status = NT_STATUS_NO_MEMORY; - return NT_STATUS_NO_MEMORY; - } - } else { - rids = NULL; - rids2 = NULL; - } + q.in.handle = r->in.handle; + q.in.num_names = r->in.num_names; + q.in.names = r->in.names; + q.in.level = r->in.level; + q.in.sids = sid_array; + q.in.count = r->in.count; + /* we do not know what this is for */ + /* = r->in.unknown1; */ + /* = r->in.unknown2; */ - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { - r_u->status = NT_STATUS_INVALID_HANDLE; - goto done; - } + q.out.domains = r->out.domains; + q.out.sids = sid_array; + q.out.count = r->out.count; - /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { - r_u->status = NT_STATUS_ACCESS_DENIED; - goto done; - } + status = _lsa_LookupNames(p, &q); - /* set up the LSA Lookup RIDs response */ - become_root(); /* lookup_name can require root privs */ - r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries, - names, flags, &mapped_count); - unbecome_root(); - -done: - - if (NT_STATUS_IS_OK(r_u->status)) { - if (mapped_count == 0) { - r_u->status = NT_STATUS_NONE_MAPPED; - } else if (mapped_count != num_entries) { - r_u->status = STATUS_SOME_UNMAPPED; - } + sid_array2->sids = TALLOC_ARRAY(p->mem_ctx, struct lsa_TranslatedSid2, sid_array->count); + if (!sid_array2->sids) { + return NT_STATUS_NO_MEMORY; } - /* Convert the rids array to rids2. */ - for (i = 0; i < num_entries; i++) { - rids2[i].type = rids[i].type; - rids2[i].rid = rids[i].rid; - rids2[i].rid_idx = rids[i].rid_idx; - rids2[i].unknown = 0; + for (i=0; icount; i++) { + sid_array2->sids[i].sid_type = sid_array->sids[i].sid_type; + sid_array2->sids[i].rid = sid_array->sids[i].rid; + sid_array2->sids[i].sid_index = sid_array->sids[i].sid_index; + sid_array2->sids[i].unknown = 0; } - init_reply_lookup_names2(r_u, ref, num_entries, rids2, mapped_count); - return r_u->status; + r->out.sids = sid_array2; + + return status; } /*************************************************************************** @@ -2294,12 +2318,6 @@ NTSTATUS _lsa_ClearAuditLog(pipes_struct *p, struct lsa_ClearAuditLog *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupNames(pipes_struct *p, struct lsa_LookupNames *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r) { p->rng_fault_state = True; @@ -2450,12 +2468,6 @@ NTSTATUS _lsa_LookupSids2(pipes_struct *p, struct lsa_LookupSids2 *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupNames2(pipes_struct *p, struct lsa_LookupNames2 *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_CreateTrustedDomainEx2(pipes_struct *p, struct lsa_CreateTrustedDomainEx2 *r) { p->rng_fault_state = True; -- cgit From 326196b51a9e72e531abd3081b40d85ea0b8aa0b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 16:57:02 +0100 Subject: Use pidl for _lsa_LookupNames3 and _lsa_LookupNames4. Guenther (This used to be commit 4e310a19f12ba7034f33247dca0a9e7a10aa98b7) --- source3/rpc_server/srv_lsa.c | 48 +---------- source3/rpc_server/srv_lsa_nt.c | 176 +++++++++++++++++----------------------- 2 files changed, 77 insertions(+), 147 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index dd4afcab52..c5c7ade1a4 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -399,29 +399,7 @@ static bool api_lsa_lookup_names2(pipes_struct *p) static bool api_lsa_lookup_names3(pipes_struct *p) { - LSA_Q_LOOKUP_NAMES3 q_u; - LSA_R_LOOKUP_NAMES3 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_names3("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_names3: failed to unmarshall LSA_Q_LOOKUP_NAMES3.\n")); - return False; - } - - r_u.status = _lsa_lookup_names3(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_lookup_names3("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_names3: Failed to marshall LSA_R_LOOKUP_NAMES3.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES3); } /*************************************************************************** @@ -430,29 +408,7 @@ static bool api_lsa_lookup_names3(pipes_struct *p) static bool api_lsa_lookup_names4(pipes_struct *p) { - LSA_Q_LOOKUP_NAMES4 q_u; - LSA_R_LOOKUP_NAMES4 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_names4("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_names4: failed to unmarshall LSA_Q_LOOKUP_NAMES4.\n")); - return False; - } - - r_u.status = _lsa_lookup_names4(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!lsa_io_r_lookup_names4("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_names4: Failed to marshall LSA_R_LOOKUP_NAMES4.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES4); } #if 0 /* AD DC work in ongoing in Samba 4 */ diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 6cf26e7eb2..5a3ed28e88 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -242,12 +242,12 @@ static NTSTATUS lookup_lsa_rids(TALLOC_CTX *mem_ctx, ***************************************************************************/ static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, - DOM_R_REF *ref, - LSA_TRANSLATED_SID3 *trans_sids, - uint32 num_entries, - const UNISTR2 *name, - int flags, - uint32 *pmapped_count) + struct lsa_RefDomainList *ref, + struct lsa_TranslatedSid3 *trans_sids, + uint32_t num_entries, + struct lsa_String *name, + int flags, + uint32 *pmapped_count) { uint32 mapped_count, i; @@ -260,15 +260,14 @@ static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, DOM_SID sid; uint32 rid; int dom_idx; - char *full_name; + const char *full_name; const char *domain; enum lsa_SidType type = SID_NAME_UNKNOWN; /* Split name into domain and user component */ - full_name = rpcstr_pull_unistr2_talloc(mem_ctx, &name[i]); + full_name = name[i].string; if (full_name == NULL) { - DEBUG(0, ("pull_ucs2_talloc failed\n")); return NT_STATUS_NO_MEMORY; } @@ -303,18 +302,14 @@ static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, DOM_SID domain_sid; sid_copy(&domain_sid, &sid); sid_split_rid(&domain_sid, &rid); - dom_idx = init_dom_ref(ref, domain, &domain_sid); + dom_idx = init_lsa_ref_domain_list(mem_ctx, ref, domain, &domain_sid); mapped_count++; } - /* Initialize the LSA_TRANSLATED_SID3 return. */ + /* Initialize the lsa_TranslatedSid3 return. */ trans_sids[i].sid_type = type; - trans_sids[i].sid2 = TALLOC_P(mem_ctx, DOM_SID2); - if (trans_sids[i].sid2 == NULL) { - return NT_STATUS_NO_MEMORY; - } - init_dom_sid2(trans_sids[i].sid2, &sid); - trans_sids[i].sid_idx = dom_idx; + trans_sids[i].sid = sid_dup_talloc(mem_ctx, &sid); + trans_sids[i].sid_index = dom_idx; } *pmapped_count = mapped_count; @@ -1237,35 +1232,49 @@ NTSTATUS _lsa_LookupNames2(pipes_struct *p, } /*************************************************************************** -lsa_reply_lookup_names3. + _lsa_LookupNames3 ***************************************************************************/ -NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOOKUP_NAMES3 *r_u) +NTSTATUS _lsa_LookupNames3(pipes_struct *p, + struct lsa_LookupNames3 *r) { + NTSTATUS status; struct lsa_info *handle; - UNISTR2 *names = q_u->uni_name; - uint32 num_entries = q_u->num_entries; - DOM_R_REF *ref = NULL; - LSA_TRANSLATED_SID3 *trans_sids = NULL; + struct lsa_String *names = r->in.names; + uint32 num_entries = r->in.num_names; + struct lsa_RefDomainList *domains = NULL; + struct lsa_TranslatedSid3 *trans_sids = NULL; uint32 mapped_count = 0; int flags = 0; + bool check_policy = true; + + switch (p->hdr_req.opnum) { + case NDR_LSA_LOOKUPNAMES4: + check_policy = false; + break; + case NDR_LSA_LOOKUPNAMES3: + default: + check_policy = true; + } if (num_entries > MAX_LOOKUP_SIDS) { num_entries = MAX_LOOKUP_SIDS; - DEBUG(5,("_lsa_lookup_names3: truncating name lookup list to %d\n", num_entries)); + DEBUG(5,("_lsa_LookupNames3: truncating name lookup list to %d\n", num_entries)); } /* Probably the lookup_level is some sort of bitmask. */ - if (q_u->lookup_level == 1) { + if (r->in.level == 1) { flags = LOOKUP_NAME_ALL; } - ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - if (ref == NULL) { + domains = TALLOC_ZERO_P(p->mem_ctx, struct lsa_RefDomainList); + if (!domains) { return NT_STATUS_NO_MEMORY; } + if (num_entries) { - trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries); + trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, struct lsa_TranslatedSid3, + num_entries); if (!trans_sids) { return NT_STATUS_NO_MEMORY; } @@ -1273,59 +1282,52 @@ NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOO trans_sids = NULL; } - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { - r_u->status = NT_STATUS_INVALID_HANDLE; - goto done; - } + if (check_policy) { - /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { - r_u->status = NT_STATUS_ACCESS_DENIED; - goto done; + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) { + status = NT_STATUS_INVALID_HANDLE; + goto done; + } + + /* check if the user have enough rights */ + if (!(handle->access & POLICY_LOOKUP_NAMES)) { + status = NT_STATUS_ACCESS_DENIED; + goto done; + } } /* set up the LSA Lookup SIDs response */ become_root(); /* lookup_name can require root privs */ - r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries, - names, flags, &mapped_count); + status = lookup_lsa_sids(p->mem_ctx, domains, trans_sids, num_entries, + names, flags, &mapped_count); unbecome_root(); done: - if (NT_STATUS_IS_OK(r_u->status)) { + if (NT_STATUS_IS_OK(status)) { if (mapped_count == 0) { - r_u->status = NT_STATUS_NONE_MAPPED; + status = NT_STATUS_NONE_MAPPED; } else if (mapped_count != num_entries) { - r_u->status = STATUS_SOME_UNMAPPED; + status = STATUS_SOME_UNMAPPED; } } - init_reply_lookup_names3(r_u, ref, num_entries, trans_sids, mapped_count); - return r_u->status; + *r->out.count = num_entries; + *r->out.domains = domains; + r->out.sids->sids = trans_sids; + r->out.sids->count = mapped_count; + + return status; } /*************************************************************************** -lsa_reply_lookup_names4. + _lsa_LookupNames4 ***************************************************************************/ -NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOOKUP_NAMES4 *r_u) +NTSTATUS _lsa_LookupNames4(pipes_struct *p, + struct lsa_LookupNames4 *r) { - UNISTR2 *names = q_u->uni_name; - uint32 num_entries = q_u->num_entries; - DOM_R_REF *ref = NULL; - LSA_TRANSLATED_SID3 *trans_sids = NULL; - uint32 mapped_count = 0; - int flags = 0; - - if (num_entries > MAX_LOOKUP_SIDS) { - num_entries = MAX_LOOKUP_SIDS; - DEBUG(5,("_lsa_lookup_names4: truncating name lookup list to %d\n", num_entries)); - } - - /* Probably the lookup_level is some sort of bitmask. */ - if (q_u->lookup_level == 1) { - flags = LOOKUP_NAME_ALL; - } + struct lsa_LookupNames3 q; /* No policy handle on this call. Restrict to crypto connections. */ if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) { @@ -1334,36 +1336,20 @@ NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOO return NT_STATUS_INVALID_PARAMETER; } - ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); - if (!ref) { - return NT_STATUS_NO_MEMORY; - } - - if (num_entries) { - trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries); - if (!trans_sids) { - return NT_STATUS_NO_MEMORY; - } - } else { - trans_sids = NULL; - } - - /* set up the LSA Lookup SIDs response */ - become_root(); /* lookup_name can require root privs */ - r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries, - names, flags, &mapped_count); - unbecome_root(); + q.in.handle = NULL; + q.in.num_names = r->in.num_names; + q.in.names = r->in.names; + q.in.level = r->in.level; + q.in.unknown1 = r->in.unknown1; + q.in.unknown2 = r->in.unknown2; + q.in.sids = r->in.sids; + q.in.count = r->in.count; - if (NT_STATUS_IS_OK(r_u->status)) { - if (mapped_count == 0) { - r_u->status = NT_STATUS_NONE_MAPPED; - } else if (mapped_count != num_entries) { - r_u->status = STATUS_SOME_UNMAPPED; - } - } + q.out.domains = r->out.domains; + q.out.sids = r->out.sids; + q.out.count = r->out.count; - init_reply_lookup_names4(r_u, ref, num_entries, trans_sids, mapped_count); - return r_u->status; + return _lsa_LookupNames3(p, &q); } /*************************************************************************** @@ -2522,12 +2508,6 @@ NTSTATUS _lsa_CREDRPROFILELOADED(pipes_struct *p, struct lsa_CREDRPROFILELOADED return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupNames3(pipes_struct *p, struct lsa_LookupNames3 *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_CREDRGETSESSIONTYPES(pipes_struct *p, struct lsa_CREDRGETSESSIONTYPES *r) { p->rng_fault_state = True; @@ -2576,12 +2556,6 @@ NTSTATUS _lsa_LookupSids3(pipes_struct *p, struct lsa_LookupSids3 *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupNames4(pipes_struct *p, struct lsa_LookupNames4 *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_LSAROPENPOLICYSCE(pipes_struct *p, struct lsa_LSAROPENPOLICYSCE *r) { p->rng_fault_state = True; -- cgit From 196d84ad6814ca2d4ffd9a51a5ac0bcd608c7445 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 18 Feb 2008 17:04:50 +0100 Subject: Remove unused marshalling for LSA_LOOKUP_NAMES/2/3/4 Guenther (This used to be commit 6458ef3977b60f24b87eb88cf870a9f23929ca85) --- source3/rpc_server/srv_lsa_nt.c | 76 ----------------------------------------- 1 file changed, 76 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 5a3ed28e88..73238a5f6f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -316,82 +316,6 @@ static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } -/*************************************************************************** - init_reply_lookup_names - ***************************************************************************/ - -static void init_reply_lookup_names(LSA_R_LOOKUP_NAMES *r_l, - DOM_R_REF *ref, uint32 num_entries, - DOM_RID *rid, uint32 mapped_count) -{ - r_l->ptr_dom_ref = 1; - r_l->dom_ref = ref; - - r_l->num_entries = num_entries; - r_l->ptr_entries = 1; - r_l->num_entries2 = num_entries; - r_l->dom_rid = rid; - - r_l->mapped_count = mapped_count; -} - -/*************************************************************************** - init_reply_lookup_names2 - ***************************************************************************/ - -static void init_reply_lookup_names2(LSA_R_LOOKUP_NAMES2 *r_l, - DOM_R_REF *ref, uint32 num_entries, - DOM_RID2 *rid, uint32 mapped_count) -{ - r_l->ptr_dom_ref = 1; - r_l->dom_ref = ref; - - r_l->num_entries = num_entries; - r_l->ptr_entries = 1; - r_l->num_entries2 = num_entries; - r_l->dom_rid = rid; - - r_l->mapped_count = mapped_count; -} - -/*************************************************************************** - init_reply_lookup_names3 - ***************************************************************************/ - -static void init_reply_lookup_names3(LSA_R_LOOKUP_NAMES3 *r_l, - DOM_R_REF *ref, uint32 num_entries, - LSA_TRANSLATED_SID3 *trans_sids, uint32 mapped_count) -{ - r_l->ptr_dom_ref = 1; - r_l->dom_ref = ref; - - r_l->num_entries = num_entries; - r_l->ptr_entries = 1; - r_l->num_entries2 = num_entries; - r_l->trans_sids = trans_sids; - - r_l->mapped_count = mapped_count; -} - -/*************************************************************************** - init_reply_lookup_names4 - ***************************************************************************/ - -static void init_reply_lookup_names4(LSA_R_LOOKUP_NAMES4 *r_l, - DOM_R_REF *ref, uint32 num_entries, - LSA_TRANSLATED_SID3 *trans_sids, uint32 mapped_count) -{ - r_l->ptr_dom_ref = 1; - r_l->dom_ref = ref; - - r_l->num_entries = num_entries; - r_l->ptr_entries = 1; - r_l->num_entries2 = num_entries; - r_l->trans_sids = trans_sids; - - r_l->mapped_count = mapped_count; -} - /*************************************************************************** Init_reply_lookup_sids. ***************************************************************************/ -- cgit From d31806dffe111dc78968ec32d5165a21e87ad508 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 18 Feb 2008 17:48:19 +0100 Subject: Fix a comment. REGISTRY_KEY has vanished from srv_winreg_nt.c (It is reg_api time) Michael (This used to be commit d94998e46ba0faac3fa625e8292d452ad52b8e55) --- source3/rpc_server/srv_winreg_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 5d18419c75..7ff93e0b07 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -36,7 +36,7 @@ static void free_regkey(void *ptr) } /****************************************************************** - Find a registry key handle and return a REGISTRY_KEY + Find a registry key handle and return a struct registry_key * *****************************************************************/ static struct registry_key *find_regkey_by_hnd(pipes_struct *p, -- cgit From 2a501a0760a7f1377cf1acf6594f8ba7b6fa07f0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 01:01:15 +0100 Subject: Use pidl for _lsa_LookupSids, _lsa_LookupSids2 and _lsa_LookupSids3. Guenther (This used to be commit b1609801e4443a3efbc29873477ad335d0241be4) --- source3/rpc_server/srv_lsa.c | 69 +----------- source3/rpc_server/srv_lsa_nt.c | 229 +++++++++++++++++++++------------------- 2 files changed, 121 insertions(+), 177 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c index c5c7ade1a4..3f292c2158 100644 --- a/source3/rpc_server/srv_lsa.c +++ b/source3/rpc_server/srv_lsa.c @@ -88,28 +88,7 @@ static bool api_lsa_query_info(pipes_struct *p) static bool api_lsa_lookup_sids(pipes_struct *p) { - LSA_Q_LOOKUP_SIDS q_u; - LSA_R_LOOKUP_SIDS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_sids("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_sids: failed to unmarshall LSA_Q_LOOKUP_SIDS.\n")); - return False; - } - - r_u.status = _lsa_lookup_sids(p, &q_u, &r_u); - - if(!lsa_io_r_lookup_sids("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_sids: Failed to marshall LSA_R_LOOKUP_SIDS.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPSIDS); } /*************************************************************************** @@ -330,28 +309,7 @@ static bool api_lsa_delete_object(pipes_struct *p) static bool api_lsa_lookup_sids2(pipes_struct *p) { - LSA_Q_LOOKUP_SIDS2 q_u; - LSA_R_LOOKUP_SIDS2 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_sids2("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_sids2: failed to unmarshall LSA_Q_LOOKUP_SIDS2.\n")); - return False; - } - - r_u.status = _lsa_lookup_sids2(p, &q_u, &r_u); - - if(!lsa_io_r_lookup_sids2("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_sids2: Failed to marshall LSA_R_LOOKUP_SIDS2.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPSIDS2); } /*************************************************************************** @@ -360,28 +318,7 @@ static bool api_lsa_lookup_sids2(pipes_struct *p) static bool api_lsa_lookup_sids3(pipes_struct *p) { - LSA_Q_LOOKUP_SIDS3 q_u; - LSA_R_LOOKUP_SIDS3 r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the info class and policy handle */ - if(!lsa_io_q_lookup_sids3("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_lookup_sids3: failed to unmarshall LSA_Q_LOOKUP_SIDS3.\n")); - return False; - } - - r_u.status = _lsa_lookup_sids3(p, &q_u, &r_u); - - if(!lsa_io_r_lookup_sids3("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_lookup_sids3: Failed to marshall LSA_R_LOOKUP_SIDS3.\n")); - return False; - } - - return True; + return proxy_lsa_call(p, NDR_LSA_LOOKUPSIDS3); } /*************************************************************************** diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 73238a5f6f..a216eaa730 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -764,38 +764,40 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, ***************************************************************************/ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, - uint16 level, /* input */ - int num_sids, /* input */ - const DOM_SID2 *sid, /* input */ - DOM_R_REF **pp_ref, /* output */ - LSA_TRANS_NAME_ENUM2 *names, /* input/output */ - uint32 *pp_mapped_count) + TALLOC_CTX *mem_ctx, + uint16_t level, /* input */ + int num_sids, /* input */ + struct lsa_SidPtr *sid, /* input */ + struct lsa_RefDomainList **pp_ref, /* input/output */ + struct lsa_TranslatedName2 **pp_names,/* input/output */ + uint32_t *pp_mapped_count) /* input/output */ { NTSTATUS status; int i; const DOM_SID **sids = NULL; - DOM_R_REF *ref = NULL; + struct lsa_RefDomainList *ref = NULL; uint32 mapped_count = 0; struct lsa_dom_info *dom_infos = NULL; struct lsa_name_info *name_infos = NULL; + struct lsa_TranslatedName2 *names = NULL; *pp_mapped_count = 0; + *pp_names = NULL; *pp_ref = NULL; - ZERO_STRUCTP(names); if (num_sids == 0) { return NT_STATUS_OK; } sids = TALLOC_ARRAY(p->mem_ctx, const DOM_SID *, num_sids); - ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF); + ref = TALLOC_ZERO_P(p->mem_ctx, struct lsa_RefDomainList); if (sids == NULL || ref == NULL) { return NT_STATUS_NO_MEMORY; } for (i=0; imem_ctx, num_sids, sids, level, @@ -805,9 +807,8 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, return status; } - names->name = TALLOC_ARRAY(p->mem_ctx, LSA_TRANS_NAME2, num_sids); - names->uni_name = TALLOC_ARRAY(p->mem_ctx, UNISTR2, num_sids); - if ((names->name == NULL) || (names->uni_name == NULL)) { + names = TALLOC_ARRAY(p->mem_ctx, struct lsa_TranslatedName2, num_sids); + if (names == NULL) { return NT_STATUS_NO_MEMORY; } @@ -817,8 +818,9 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, break; } - if (init_dom_ref(ref, dom_infos[i].name, - &dom_infos[i].sid) != i) { + if (init_lsa_ref_domain_list(mem_ctx, ref, + dom_infos[i].name, + &dom_infos[i].sid) != i) { DEBUG(0, ("Domain %s mentioned twice??\n", dom_infos[i].name)); return NT_STATUS_INTERNAL_ERROR; @@ -846,13 +848,10 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, } else { mapped_count += 1; } - init_lsa_trans_name2(&names->name[i], &names->uni_name[i], - name->type, name->name, name->dom_idx); - } - names->num_entries = num_sids; - names->ptr_trans_names = 1; - names->num_entries2 = num_sids; + init_lsa_translated_name2(&names[i], name->type, + name->name, name->dom_idx, 0); + } status = NT_STATUS_NONE_MAPPED; if (mapped_count > 0) { @@ -864,31 +863,33 @@ static NTSTATUS _lsa_lookup_sids_internal(pipes_struct *p, num_sids, mapped_count, nt_errstr(status))); *pp_mapped_count = mapped_count; + *pp_names = names; *pp_ref = ref; return status; } /*************************************************************************** - _lsa_lookup_sids + _lsa_LookupSids ***************************************************************************/ -NTSTATUS _lsa_lookup_sids(pipes_struct *p, - LSA_Q_LOOKUP_SIDS *q_u, - LSA_R_LOOKUP_SIDS *r_u) +NTSTATUS _lsa_LookupSids(pipes_struct *p, + struct lsa_LookupSids *r) { + NTSTATUS status; struct lsa_info *handle; - int num_sids = q_u->sids.num_entries; + int num_sids = r->in.sids->num_sids; uint32 mapped_count = 0; - DOM_R_REF *ref = NULL; - LSA_TRANS_NAME_ENUM2 names; - NTSTATUS status; + struct lsa_RefDomainList *domains = NULL; + struct lsa_TranslatedName *names_out = NULL; + struct lsa_TranslatedName2 *names = NULL; + int i; - if ((q_u->level < 1) || (q_u->level > 6)) { + if ((r->in.level < 1) || (r->in.level > 6)) { return NT_STATUS_INVALID_PARAMETER; } - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) { return NT_STATUS_INVALID_HANDLE; } @@ -898,113 +899,137 @@ NTSTATUS _lsa_lookup_sids(pipes_struct *p, } if (num_sids > MAX_LOOKUP_SIDS) { - DEBUG(5,("_lsa_lookup_sids: limit of %d exceeded, requested %d\n", + DEBUG(5,("_lsa_LookupSids: limit of %d exceeded, requested %d\n", MAX_LOOKUP_SIDS, num_sids)); return NT_STATUS_NONE_MAPPED; } - r_u->status = _lsa_lookup_sids_internal(p, - q_u->level, - num_sids, - q_u->sids.sid, - &ref, - &names, - &mapped_count); + status = _lsa_lookup_sids_internal(p, + p->mem_ctx, + r->in.level, + num_sids, + r->in.sids->sids, + &domains, + &names, + &mapped_count); - /* Convert from LSA_TRANS_NAME_ENUM2 to LSA_TRANS_NAME_ENUM */ + /* Convert from lsa_TranslatedName2 to lsa_TranslatedName */ + names_out = TALLOC_ARRAY(p->mem_ctx, struct lsa_TranslatedName, + num_sids); + if (!names_out) { + return NT_STATUS_NO_MEMORY; + } - status = init_reply_lookup_sids(p->mem_ctx, r_u, ref, &names, mapped_count); - if (!NT_STATUS_IS_OK(status)) { - return status; + for (i=0; istatus; + + *r->out.domains = domains; + r->out.names->count = num_sids; + r->out.names->names = names_out; + *r->out.count = mapped_count; + + return status; } /*************************************************************************** - _lsa_lookup_sids2 + _lsa_LookupSids2 ***************************************************************************/ -NTSTATUS _lsa_lookup_sids2(pipes_struct *p, - LSA_Q_LOOKUP_SIDS2 *q_u, - LSA_R_LOOKUP_SIDS2 *r_u) +NTSTATUS _lsa_LookupSids2(pipes_struct *p, + struct lsa_LookupSids2 *r) { + NTSTATUS status; struct lsa_info *handle; - int num_sids = q_u->sids.num_entries; + int num_sids = r->in.sids->num_sids; uint32 mapped_count = 0; - DOM_R_REF *ref = NULL; + struct lsa_RefDomainList *domains = NULL; + struct lsa_TranslatedName2 *names = NULL; + bool check_policy = true; - if ((q_u->level < 1) || (q_u->level > 6)) { - return NT_STATUS_INVALID_PARAMETER; + switch (p->hdr_req.opnum) { + case NDR_LSA_LOOKUPSIDS3: + check_policy = false; + break; + case NDR_LSA_LOOKUPSIDS2: + default: + check_policy = true; } - if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) { - return NT_STATUS_INVALID_HANDLE; + if ((r->in.level < 1) || (r->in.level > 6)) { + return NT_STATUS_INVALID_PARAMETER; } - /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { - return NT_STATUS_ACCESS_DENIED; + if (check_policy) { + if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) { + return NT_STATUS_INVALID_HANDLE; + } + + /* check if the user have enough rights */ + if (!(handle->access & POLICY_LOOKUP_NAMES)) { + return NT_STATUS_ACCESS_DENIED; + } } if (num_sids > MAX_LOOKUP_SIDS) { - DEBUG(5,("_lsa_lookup_sids2: limit of %d exceeded, requested %d\n", + DEBUG(5,("_lsa_LookupSids2: limit of %d exceeded, requested %d\n", MAX_LOOKUP_SIDS, num_sids)); return NT_STATUS_NONE_MAPPED; } - r_u->status = _lsa_lookup_sids_internal(p, - q_u->level, - num_sids, - q_u->sids.sid, - &ref, - &r_u->names, - &mapped_count); + status = _lsa_lookup_sids_internal(p, + p->mem_ctx, + r->in.level, + num_sids, + r->in.sids->sids, + &domains, + &names, + &mapped_count); - init_reply_lookup_sids2(r_u, ref, mapped_count); - return r_u->status; + *r->out.domains = domains; + r->out.names->count = num_sids; + r->out.names->names = names; + *r->out.count = mapped_count; + + return status; } /*************************************************************************** - _lsa_lookup_sida3 + _lsa_LookupSids3 ***************************************************************************/ -NTSTATUS _lsa_lookup_sids3(pipes_struct *p, - LSA_Q_LOOKUP_SIDS3 *q_u, - LSA_R_LOOKUP_SIDS3 *r_u) +NTSTATUS _lsa_LookupSids3(pipes_struct *p, + struct lsa_LookupSids3 *r) { - int num_sids = q_u->sids.num_entries; - uint32 mapped_count = 0; - DOM_R_REF *ref = NULL; - - if ((q_u->level < 1) || (q_u->level > 6)) { - return NT_STATUS_INVALID_PARAMETER; - } + struct lsa_LookupSids2 q; /* No policy handle on this call. Restrict to crypto connections. */ if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) { - DEBUG(0,("_lsa_lookup_sids3: client %s not using schannel for netlogon\n", + DEBUG(0,("_lsa_LookupSids3: client %s not using schannel for netlogon\n", get_remote_machine_name() )); return NT_STATUS_INVALID_PARAMETER; } - if (num_sids > MAX_LOOKUP_SIDS) { - DEBUG(5,("_lsa_lookup_sids3: limit of %d exceeded, requested %d\n", - MAX_LOOKUP_SIDS, num_sids)); - return NT_STATUS_NONE_MAPPED; - } + q.in.handle = NULL; + q.in.sids = r->in.sids; + q.in.level = r->in.level; + q.in.unknown1 = r->in.unknown1; + q.in.unknown2 = r->in.unknown2; + q.in.names = r->in.names; + q.in.count = r->in.count; - r_u->status = _lsa_lookup_sids_internal(p, - q_u->level, - num_sids, - q_u->sids.sid, - &ref, - &r_u->names, - &mapped_count); + q.out.domains = r->out.domains; + q.out.names = r->out.names; + q.out.count = r->out.count; - init_reply_lookup_sids3(r_u, ref, mapped_count); - return r_u->status; + return _lsa_LookupSids2(p, &q); } +/*************************************************************************** + ***************************************************************************/ + static int lsa_lookup_level_to_flags(uint16 level) { int flags; @@ -2228,12 +2253,6 @@ NTSTATUS _lsa_ClearAuditLog(pipes_struct *p, struct lsa_ClearAuditLog *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupSids(pipes_struct *p, struct lsa_LookupSids *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_GetQuotasForAccount(pipes_struct *p, struct lsa_GetQuotasForAccount *r) { p->rng_fault_state = True; @@ -2372,12 +2391,6 @@ NTSTATUS _lsa_TestCall(pipes_struct *p, struct lsa_TestCall *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupSids2(pipes_struct *p, struct lsa_LookupSids2 *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_CreateTrustedDomainEx2(pipes_struct *p, struct lsa_CreateTrustedDomainEx2 *r) { p->rng_fault_state = True; @@ -2474,12 +2487,6 @@ NTSTATUS _lsa_CREDRRENAME(pipes_struct *p, struct lsa_CREDRRENAME *r) return NT_STATUS_NOT_IMPLEMENTED; } -NTSTATUS _lsa_LookupSids3(pipes_struct *p, struct lsa_LookupSids3 *r) -{ - p->rng_fault_state = True; - return NT_STATUS_NOT_IMPLEMENTED; -} - NTSTATUS _lsa_LSAROPENPOLICYSCE(pipes_struct *p, struct lsa_LSAROPENPOLICYSCE *r) { p->rng_fault_state = True; -- cgit From 8db780ac8fc30df1e20e70d83a49365b74a10e0a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 01:16:00 +0100 Subject: Yippie! LSARPC server-side migration to pidl finished. Guenther (This used to be commit aa7023b88d3161897b9616d950c2a99624d81931) --- source3/rpc_server/srv_lsa.c | 463 ------------------------------------------ source3/rpc_server/srv_pipe.c | 2 +- 2 files changed, 1 insertion(+), 464 deletions(-) delete mode 100644 source3/rpc_server/srv_lsa.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa.c b/source3/rpc_server/srv_lsa.c deleted file mode 100644 index 3f292c2158..0000000000 --- a/source3/rpc_server/srv_lsa.c +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997, - * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Jim McDonough 2002-2003. - * Copyright (C) Gerald (Jerry) Carter 2005 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ - -/* This is the interface to the lsa server code. */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -static bool proxy_lsa_call(pipes_struct *p, uint8 opnum) -{ - struct api_struct *fns; - int n_fns; - - lsarpc_get_pipe_fns(&fns, &n_fns); - - if (opnum >= n_fns) - return False; - - if (fns[opnum].opnum != opnum) { - smb_panic("LSA function table not sorted"); - } - - return fns[opnum].fn(p); -} - -/*************************************************************************** - api_lsa_open_policy2 - ***************************************************************************/ - -static bool api_lsa_open_policy2(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_OPENPOLICY2); -} - -/*************************************************************************** -api_lsa_open_policy - ***************************************************************************/ - -static bool api_lsa_open_policy(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_OPENPOLICY); -} - -/*************************************************************************** - api_lsa_enum_trust_dom - ***************************************************************************/ - -static bool api_lsa_enum_trust_dom(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_ENUMTRUSTDOM); -} - -/*************************************************************************** - api_lsa_query_info - ***************************************************************************/ - -static bool api_lsa_query_info(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_QUERYINFOPOLICY); -} - -/*************************************************************************** - api_lsa_lookup_sids - ***************************************************************************/ - -static bool api_lsa_lookup_sids(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPSIDS); -} - -/*************************************************************************** - api_lsa_lookup_names - ***************************************************************************/ - -static bool api_lsa_lookup_names(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES); -} - -/*************************************************************************** - api_lsa_close. - ***************************************************************************/ - -static bool api_lsa_close(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_CLOSE); -} - -/*************************************************************************** - api_lsa_open_secret. - ***************************************************************************/ - -static bool api_lsa_open_secret(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_OPENSECRET); -} - -/*************************************************************************** - api_lsa_open_secret. - ***************************************************************************/ - -static bool api_lsa_enum_privs(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_ENUMPRIVS); -} - -/*************************************************************************** - api_lsa_open_secret. - ***************************************************************************/ - -static bool api_lsa_priv_get_dispname(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPPRIVDISPLAYNAME); -} - -/*************************************************************************** - api_lsa_open_secret. - ***************************************************************************/ - -static bool api_lsa_enum_accounts(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_ENUMACCOUNTS); -} - -/*************************************************************************** - api_lsa_UNK_GET_CONNUSER - ***************************************************************************/ - -static bool api_lsa_unk_get_connuser(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_GETUSERNAME); -} - -/*************************************************************************** - api_lsa_create_user - ***************************************************************************/ - -static bool api_lsa_create_account(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_CREATEACCOUNT); -} - -/*************************************************************************** - api_lsa_open_user - ***************************************************************************/ - -static bool api_lsa_open_account(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_OPENACCOUNT); -} - -/*************************************************************************** - api_lsa_get_privs - ***************************************************************************/ - -static bool api_lsa_enum_privsaccount(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_ENUMPRIVSACCOUNT); -} - -/*************************************************************************** - api_lsa_getsystemaccount - ***************************************************************************/ - -static bool api_lsa_getsystemaccount(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_GETSYSTEMACCESSACCOUNT); -} - - -/*************************************************************************** - api_lsa_setsystemaccount - ***************************************************************************/ - -static bool api_lsa_setsystemaccount(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_SETSYSTEMACCESSACCOUNT); -} - -/*************************************************************************** - api_lsa_addprivs - ***************************************************************************/ - -static bool api_lsa_addprivs(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_ADDPRIVILEGESTOACCOUNT); -} - -/*************************************************************************** - api_lsa_removeprivs - ***************************************************************************/ - -static bool api_lsa_removeprivs(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_REMOVEPRIVILEGESFROMACCOUNT); -} - -/*************************************************************************** - api_lsa_query_secobj - ***************************************************************************/ - -static bool api_lsa_query_secobj(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_QUERYSECURITY); -} - -/*************************************************************************** - api_lsa_add_acct_rights - ***************************************************************************/ - -static bool api_lsa_add_acct_rights(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_ADDACCOUNTRIGHTS); -} - -/*************************************************************************** - api_lsa_remove_acct_rights - ***************************************************************************/ - -static bool api_lsa_remove_acct_rights(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_REMOVEACCOUNTRIGHTS); -} - -/*************************************************************************** - api_lsa_enum_acct_rights - ***************************************************************************/ - -static bool api_lsa_enum_acct_rights(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_ENUMACCOUNTRIGHTS); -} - -/*************************************************************************** - api_lsa_lookup_priv_value - ***************************************************************************/ - -static bool api_lsa_lookup_priv_value(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPPRIVVALUE); -} - -/*************************************************************************** - ***************************************************************************/ - -static bool api_lsa_open_trust_dom(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_OPENTRUSTEDDOMAIN); -} - -/*************************************************************************** - ***************************************************************************/ - -static bool api_lsa_create_trust_dom(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_CREATETRUSTEDDOMAIN); -} - -/*************************************************************************** - ***************************************************************************/ - -static bool api_lsa_create_secret(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_CREATESECRET); -} - -/*************************************************************************** - ***************************************************************************/ - -static bool api_lsa_set_secret(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_SETSECRET); -} - -/*************************************************************************** - ***************************************************************************/ - -static bool api_lsa_delete_object(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_DELETEOBJECT); -} - -/*************************************************************************** - api_lsa_lookup_sids2 - ***************************************************************************/ - -static bool api_lsa_lookup_sids2(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPSIDS2); -} - -/*************************************************************************** - api_lsa_lookup_sids3 - ***************************************************************************/ - -static bool api_lsa_lookup_sids3(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPSIDS3); -} - -/*************************************************************************** - api_lsa_lookup_names2 - ***************************************************************************/ - -static bool api_lsa_lookup_names2(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES2); -} - -/*************************************************************************** - api_lsa_lookup_names3 - ***************************************************************************/ - -static bool api_lsa_lookup_names3(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES3); -} - -/*************************************************************************** - api_lsa_lookup_names4 - ***************************************************************************/ - -static bool api_lsa_lookup_names4(pipes_struct *p) -{ - return proxy_lsa_call(p, NDR_LSA_LOOKUPNAMES4); -} - -#if 0 /* AD DC work in ongoing in Samba 4 */ - -/*************************************************************************** - api_lsa_query_info2 - ***************************************************************************/ - -static bool api_lsa_query_info2(pipes_struct *p) -{ - LSA_Q_QUERY_INFO2 q_u; - LSA_R_QUERY_INFO2 r_u; - - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!lsa_io_q_query_info2("", &q_u, data, 0)) { - DEBUG(0,("api_lsa_query_info2: failed to unmarshall LSA_Q_QUERY_INFO2.\n")); - return False; - } - - r_u.status = _lsa_query_info2(p, &q_u, &r_u); - - if (!lsa_io_r_query_info2("", &r_u, rdata, 0)) { - DEBUG(0,("api_lsa_query_info2: failed to marshall LSA_R_QUERY_INFO2.\n")); - return False; - } - - return True; -} -#endif /* AD DC work in ongoing in Samba 4 */ - -/*************************************************************************** - \PIPE\ntlsa commands - ***************************************************************************/ - -static struct api_struct api_lsa_cmds[] = -{ - { "LSA_OPENPOLICY2" , LSA_OPENPOLICY2 , api_lsa_open_policy2 }, - { "LSA_OPENPOLICY" , LSA_OPENPOLICY , api_lsa_open_policy }, - { "LSA_QUERYINFOPOLICY" , LSA_QUERYINFOPOLICY , api_lsa_query_info }, - { "LSA_ENUMTRUSTDOM" , LSA_ENUMTRUSTDOM , api_lsa_enum_trust_dom }, - { "LSA_CLOSE" , LSA_CLOSE , api_lsa_close }, - { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret }, - { "LSA_LOOKUPSIDS" , LSA_LOOKUPSIDS , api_lsa_lookup_sids }, - { "LSA_LOOKUPNAMES" , LSA_LOOKUPNAMES , api_lsa_lookup_names }, - { "LSA_ENUM_PRIVS" , LSA_ENUM_PRIVS , api_lsa_enum_privs }, - { "LSA_PRIV_GET_DISPNAME",LSA_PRIV_GET_DISPNAME,api_lsa_priv_get_dispname}, - { "LSA_ENUM_ACCOUNTS" , LSA_ENUM_ACCOUNTS , api_lsa_enum_accounts }, - { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser }, - { "LSA_CREATEACCOUNT" , LSA_CREATEACCOUNT , api_lsa_create_account }, - { "LSA_OPENACCOUNT" , LSA_OPENACCOUNT , api_lsa_open_account }, - { "LSA_ENUMPRIVSACCOUNT", LSA_ENUMPRIVSACCOUNT, api_lsa_enum_privsaccount}, - { "LSA_GETSYSTEMACCOUNT", LSA_GETSYSTEMACCOUNT, api_lsa_getsystemaccount }, - { "LSA_SETSYSTEMACCOUNT", LSA_SETSYSTEMACCOUNT, api_lsa_setsystemaccount }, - { "LSA_ADDPRIVS" , LSA_ADDPRIVS , api_lsa_addprivs }, - { "LSA_REMOVEPRIVS" , LSA_REMOVEPRIVS , api_lsa_removeprivs }, - { "LSA_ADDACCTRIGHTS" , LSA_ADDACCTRIGHTS , api_lsa_add_acct_rights }, - { "LSA_REMOVEACCTRIGHTS", LSA_REMOVEACCTRIGHTS, api_lsa_remove_acct_rights }, - { "LSA_ENUMACCTRIGHTS" , LSA_ENUMACCTRIGHTS , api_lsa_enum_acct_rights }, - { "LSA_QUERYSECOBJ" , LSA_QUERYSECOBJ , api_lsa_query_secobj }, - { "LSA_LOOKUPPRIVVALUE" , LSA_LOOKUPPRIVVALUE , api_lsa_lookup_priv_value }, - { "LSA_OPENTRUSTDOM" , LSA_OPENTRUSTDOM , api_lsa_open_trust_dom }, - { "LSA_OPENSECRET" , LSA_OPENSECRET , api_lsa_open_secret }, - { "LSA_CREATETRUSTDOM" , LSA_CREATETRUSTDOM , api_lsa_create_trust_dom }, - { "LSA_CREATSECRET" , LSA_CREATESECRET , api_lsa_create_secret }, - { "LSA_SETSECRET" , LSA_SETSECRET , api_lsa_set_secret }, - { "LSA_DELETEOBJECT" , LSA_DELETEOBJECT , api_lsa_delete_object }, - { "LSA_LOOKUPSIDS2" , LSA_LOOKUPSIDS2 , api_lsa_lookup_sids2 }, - { "LSA_LOOKUPNAMES2" , LSA_LOOKUPNAMES2 , api_lsa_lookup_names2 }, - { "LSA_LOOKUPNAMES3" , LSA_LOOKUPNAMES3 , api_lsa_lookup_names3 }, - { "LSA_LOOKUPSIDS3" , LSA_LOOKUPSIDS3 , api_lsa_lookup_sids3 }, - { "LSA_LOOKUPNAMES4" , LSA_LOOKUPNAMES4 , api_lsa_lookup_names4 } -#if 0 /* AD DC work in ongoing in Samba 4 */ - /* be careful of the adding of new RPC's. See commentrs below about - ADS DC capabilities */ - { "LSA_QUERYINFO2" , LSA_QUERYINFO2 , api_lsa_query_info2 } -#endif /* AD DC work in ongoing in Samba 4 */ -}; - -static int count_fns(void) -{ - int funcs = sizeof(api_lsa_cmds) / sizeof(struct api_struct); - -#if 0 /* AD DC work is on going in Samba 4 */ - /* - * NOTE: Certain calls can not be enabled if we aren't an ADS DC. Make sure - * these calls are always last and that you decrement by the amount of calls - * to disable. - */ - if (!(SEC_ADS == lp_security() && ROLE_DOMAIN_PDC == lp_server_role())) { - funcs -= 1; - } -#endif /* AD DC work in ongoing in Samba 4 */ - - return funcs; -} - -void lsa_get_pipe_fns( struct api_struct **fns, int *n_fns ) -{ - *fns = api_lsa_cmds; - *n_fns = count_fns(); -} - - -NTSTATUS rpc_lsa_init(void) -{ - int funcs = count_fns(); - - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "lsarpc", "lsass", api_lsa_cmds, - funcs); -} diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index a7a7f9a389..4d066a6b7a 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2376,7 +2376,7 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) switch ( idx ) { case PI_LSARPC: - lsa_get_pipe_fns( &cmds, &n_cmds ); + lsarpc_get_pipe_fns( &cmds, &n_cmds ); break; case PI_DSSETUP: dssetup_get_pipe_fns( &cmds, &n_cmds ); -- cgit From d48f36819fe825de58f1e4feaab14a811ad53421 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 01:19:44 +0100 Subject: Remove unused marshalling for LSA_LOOKUP_SIDS/2/3. This also removes parse_lsa.c entirely. Guenther (This used to be commit f802ba035c95e63c5a6ff9f2fb484d62341cd1a7) --- source3/rpc_server/srv_lsa_nt.c | 101 ---------------------------------------- 1 file changed, 101 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index a216eaa730..f43258d5e5 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -126,43 +126,6 @@ static void init_dom_query_5(struct lsa_DomainInfo *r, r->sid = sid; } -/*************************************************************************** - init_dom_ref - adds a domain if it's not already in, returns the index. -***************************************************************************/ - -static int init_dom_ref(DOM_R_REF *ref, const char *dom_name, DOM_SID *dom_sid) -{ - int num = 0; - - if (dom_name != NULL) { - for (num = 0; num < ref->num_ref_doms_1; num++) { - if (sid_equal(dom_sid, &ref->ref_dom[num].ref_dom.sid)) - return num; - } - } else { - num = ref->num_ref_doms_1; - } - - if (num >= MAX_REF_DOMAINS) { - /* index not found, already at maximum domain limit */ - return -1; - } - - ref->num_ref_doms_1 = num+1; - ref->ptr_ref_dom = 1; - ref->max_entries = MAX_REF_DOMAINS; - ref->num_ref_doms_2 = num+1; - - ref->hdr_ref_dom[num].ptr_dom_sid = 1; /* dom sid cannot be NULL. */ - - init_unistr2(&ref->ref_dom[num].uni_dom_name, dom_name, UNI_FLAGS_NONE); - init_uni_hdr(&ref->hdr_ref_dom[num].hdr_dom_name, &ref->ref_dom[num].uni_dom_name); - - init_dom_sid2(&ref->ref_dom[num].ref_dom, dom_sid ); - - return num; -} - /*************************************************************************** lookup_lsa_rids. Must be called as root for lookup_name to work. ***************************************************************************/ @@ -316,70 +279,6 @@ static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, return NT_STATUS_OK; } -/*************************************************************************** - Init_reply_lookup_sids. - ***************************************************************************/ - -static void init_reply_lookup_sids2(LSA_R_LOOKUP_SIDS2 *r_l, - DOM_R_REF *ref, - uint32 mapped_count) -{ - r_l->ptr_dom_ref = ref ? 1 : 0; - r_l->dom_ref = ref; - r_l->mapped_count = mapped_count; -} - -/*************************************************************************** - Init_reply_lookup_sids. - ***************************************************************************/ - -static void init_reply_lookup_sids3(LSA_R_LOOKUP_SIDS3 *r_l, - DOM_R_REF *ref, - uint32 mapped_count) -{ - r_l->ptr_dom_ref = ref ? 1 : 0; - r_l->dom_ref = ref; - r_l->mapped_count = mapped_count; -} - -/*************************************************************************** - Init_reply_lookup_sids. - ***************************************************************************/ - -static NTSTATUS init_reply_lookup_sids(TALLOC_CTX *mem_ctx, - LSA_R_LOOKUP_SIDS *r_l, - DOM_R_REF *ref, - LSA_TRANS_NAME_ENUM2 *names, - uint32 mapped_count) -{ - LSA_TRANS_NAME_ENUM *oldnames = &r_l->names; - - oldnames->num_entries = names->num_entries; - oldnames->ptr_trans_names = names->ptr_trans_names; - oldnames->num_entries2 = names->num_entries2; - oldnames->uni_name = names->uni_name; - - if (names->num_entries) { - int i; - - oldnames->name = TALLOC_ARRAY(mem_ctx, LSA_TRANS_NAME, names->num_entries); - - if (!oldnames->name) { - return NT_STATUS_NO_MEMORY; - } - for (i = 0; i < names->num_entries; i++) { - oldnames->name[i].sid_name_use = names->name[i].sid_name_use; - oldnames->name[i].hdr_name = names->name[i].hdr_name; - oldnames->name[i].domain_idx = names->name[i].domain_idx; - } - } - - r_l->ptr_dom_ref = ref ? 1 : 0; - r_l->dom_ref = ref; - r_l->mapped_count = mapped_count; - return NT_STATUS_OK; -} - static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *sd_size) { DOM_SID local_adm_sid; -- cgit From f8b0242ca03b99186010f95378410e1acde3e8b0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:28:46 +0100 Subject: Use pidl for _svcctl_StartServiceW(). Guenther (This used to be commit d95998ffd321eccf19f7de671eed2c741038b81e) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 12 ++++-------- 2 files changed, 5 insertions(+), 25 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 84c986dbfb..5f55593f6d 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -171,23 +171,7 @@ static bool api_svcctl_enum_dependent_services(pipes_struct *p) static bool api_svcctl_start_service(pipes_struct *p) { - SVCCTL_Q_START_SERVICE q_u; - SVCCTL_R_START_SERVICE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_start_service("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_start_service(p, &q_u, &r_u); - - if(!svcctl_io_r_start_service("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_STARTSERVICEW); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index bdd0f4ffe3..06637e4339 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -470,11 +470,13 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT } /******************************************************************** + _svcctl_StartServiceW ********************************************************************/ -WERROR _svcctl_start_service(pipes_struct *p, SVCCTL_Q_START_SERVICE *q_u, SVCCTL_R_START_SERVICE *r_u) +WERROR _svcctl_StartServiceW(pipes_struct *p, + struct svcctl_StartServiceW *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); /* perform access checks */ @@ -982,12 +984,6 @@ WERROR _svcctl_QueryServiceLockStatusW(pipes_struct *p, struct svcctl_QueryServi return WERR_NOT_SUPPORTED; } -WERROR _svcctl_StartServiceW(pipes_struct *p, struct svcctl_StartServiceW *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_GetServiceKeyNameW(pipes_struct *p, struct svcctl_GetServiceKeyNameW *r) { p->rng_fault_state = True; -- cgit From e87216972a01ac233e383674555b2a1ff5dfbaab Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:35:03 +0100 Subject: Use pidl for _svcctl_ControlService(). Guenther (This used to be commit 4797ca0bd5dc922f6ba5ebb93bf65ceee09a678e) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 20 +++++++++----------- 2 files changed, 10 insertions(+), 28 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 5f55593f6d..dd3a42235d 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -179,23 +179,7 @@ static bool api_svcctl_start_service(pipes_struct *p) static bool api_svcctl_control_service(pipes_struct *p) { - SVCCTL_Q_CONTROL_SERVICE q_u; - SVCCTL_R_CONTROL_SERVICE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_control_service("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_control_service(p, &q_u, &r_u); - - if(!svcctl_io_r_control_service("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_CONTROLSERVICE); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 06637e4339..e8969c70ac 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -490,29 +490,33 @@ WERROR _svcctl_StartServiceW(pipes_struct *p, } /******************************************************************** + _svcctl_ControlService ********************************************************************/ -WERROR _svcctl_control_service(pipes_struct *p, SVCCTL_Q_CONTROL_SERVICE *q_u, SVCCTL_R_CONTROL_SERVICE *r_u) +WERROR _svcctl_ControlService(pipes_struct *p, + struct svcctl_ControlService *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); /* perform access checks */ if ( !info || (info->type != SVC_HANDLE_IS_SERVICE) ) return WERR_BADFID; - switch ( q_u->control ) { + switch ( r->in.control ) { case SVCCTL_CONTROL_STOP: if ( !(info->access_granted & SC_RIGHT_SVC_STOP) ) return WERR_ACCESS_DENIED; - return info->ops->stop_service( info->name, &r_u->svc_status ); + return info->ops->stop_service( info->name, + r->out.service_status ); case SVCCTL_CONTROL_INTERROGATE: if ( !(info->access_granted & SC_RIGHT_SVC_QUERY_STATUS) ) return WERR_ACCESS_DENIED; - return info->ops->service_status( info->name, &r_u->svc_status ); + return info->ops->service_status( info->name, + r->out.service_status ); } /* default control action */ @@ -888,12 +892,6 @@ WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, } -WERROR _svcctl_ControlService(pipes_struct *p, struct svcctl_ControlService *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_DeleteService(pipes_struct *p, struct svcctl_DeleteService *r) { p->rng_fault_state = True; -- cgit From 4421e0d1470b82cdf7988a6c6d2ac67c8ea6c753 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:41:05 +0100 Subject: Use pidl for _svcctl_QueryServiceStatus(). Guenther (This used to be commit 5453d97ef4967755ef0c903dd665325d50845028) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 14 +++++--------- 2 files changed, 6 insertions(+), 26 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index dd3a42235d..3b9960c647 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -77,23 +77,7 @@ static bool api_svcctl_get_display_name(pipes_struct *p) static bool api_svcctl_query_status(pipes_struct *p) { - SVCCTL_Q_QUERY_STATUS q_u; - SVCCTL_R_QUERY_STATUS r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_query_status("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_query_status(p, &q_u, &r_u); - - if(!svcctl_io_r_query_status("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_QUERYSERVICESTATUS); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index e8969c70ac..9baf2d5110 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -361,11 +361,13 @@ WERROR _svcctl_GetServiceDisplayNameW(pipes_struct *p, } /******************************************************************** + _svcctl_QueryServiceStatus ********************************************************************/ -WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_R_QUERY_STATUS *r_u) +WERROR _svcctl_QueryServiceStatus(pipes_struct *p, + struct svcctl_QueryServiceStatus *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); /* perform access checks */ @@ -377,7 +379,7 @@ WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_ /* try the service specific status call */ - return info->ops->service_status( info->name, &r_u->svc_status ); + return info->ops->service_status( info->name, r->out.service_status ); } /******************************************************************** @@ -916,12 +918,6 @@ WERROR _svcctl_SetServiceObjectSecurity(pipes_struct *p, struct svcctl_SetServic return WERR_NOT_SUPPORTED; } -WERROR _svcctl_QueryServiceStatus(pipes_struct *p, struct svcctl_QueryServiceStatus *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_SetServiceStatus(pipes_struct *p, struct svcctl_SetServiceStatus *r) { p->rng_fault_state = True; -- cgit From e0860ccc824c336103a1e57c9e43c27936265769 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:47:05 +0100 Subject: Use pidl for _svcctl_LockServiceDatabase(). Guenther (This used to be commit 939da2eb58ea8cfa637ec63b254755d77702da45) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 15 +++++---------- 2 files changed, 6 insertions(+), 27 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 3b9960c647..4689e38dea 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -219,23 +219,7 @@ static bool api_svcctl_query_service_config2(pipes_struct *p) static bool api_svcctl_lock_service_db(pipes_struct *p) { - SVCCTL_Q_LOCK_SERVICE_DB q_u; - SVCCTL_R_LOCK_SERVICE_DB r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_lock_service_db("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_lock_service_db(p, &q_u, &r_u); - - if(!svcctl_io_r_lock_service_db("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_LOCKSERVICEDATABASE); } diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 9baf2d5110..96eafe4215 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -764,11 +764,13 @@ WERROR _svcctl_query_service_config2( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_CO } /******************************************************************** + _svcctl_LockServiceDatabase ********************************************************************/ -WERROR _svcctl_lock_service_db( pipes_struct *p, SVCCTL_Q_LOCK_SERVICE_DB *q_u, SVCCTL_R_LOCK_SERVICE_DB *r_u ) +WERROR _svcctl_LockServiceDatabase(pipes_struct *p, + struct svcctl_LockServiceDatabase *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); /* perform access checks */ @@ -780,8 +782,7 @@ WERROR _svcctl_lock_service_db( pipes_struct *p, SVCCTL_Q_LOCK_SERVICE_DB *q_u, /* Just open a handle. Doesn't actually lock anything */ - return create_open_service_handle( p, &r_u->h_lock, SVC_HANDLE_IS_DBLOCK, NULL, 0 ); -; + return create_open_service_handle( p, r->out.lock, SVC_HANDLE_IS_DBLOCK, NULL, 0 ); } /******************************************************************** @@ -900,12 +901,6 @@ WERROR _svcctl_DeleteService(pipes_struct *p, struct svcctl_DeleteService *r) return WERR_NOT_SUPPORTED; } -WERROR _svcctl_LockServiceDatabase(pipes_struct *p, struct svcctl_LockServiceDatabase *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_QueryServiceObjectSecurity(pipes_struct *p, struct svcctl_QueryServiceObjectSecurity *r) { p->rng_fault_state = True; -- cgit From 5894d5e99a23a1a700ef5319bcfe822b125ccbb0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 19 Feb 2008 02:50:01 +0100 Subject: Use pidl for _svcctl_UnlockServiceDatabase(). Guenther (This used to be commit 300bf76a79bfa0a9cf55505fd1e928aba9fec171) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 14 +++++--------- 2 files changed, 6 insertions(+), 26 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 4689e38dea..565c93fa77 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -228,23 +228,7 @@ static bool api_svcctl_lock_service_db(pipes_struct *p) static bool api_svcctl_unlock_service_db(pipes_struct *p) { - SVCCTL_Q_UNLOCK_SERVICE_DB q_u; - SVCCTL_R_UNLOCK_SERVICE_DB r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_unlock_service_db("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_unlock_service_db(p, &q_u, &r_u); - - if(!svcctl_io_r_unlock_service_db("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_UNLOCKSERVICEDATABASE); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 96eafe4215..53154ef0c9 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -786,17 +786,19 @@ WERROR _svcctl_LockServiceDatabase(pipes_struct *p, } /******************************************************************** + _svcctl_UnlockServiceDatabase ********************************************************************/ -WERROR _svcctl_unlock_service_db( pipes_struct *p, SVCCTL_Q_UNLOCK_SERVICE_DB *q_u, SVCCTL_R_UNLOCK_SERVICE_DB *r_u ) +WERROR _svcctl_UnlockServiceDatabase(pipes_struct *p, + struct svcctl_UnlockServiceDatabase *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->h_lock ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.lock ); if ( !info || (info->type != SVC_HANDLE_IS_DBLOCK) ) return WERR_BADFID; - return close_policy_hnd( p, &q_u->h_lock) ? WERR_OK : WERR_BADFID; + return close_policy_hnd( p, r->out.lock) ? WERR_OK : WERR_BADFID; } /******************************************************************** @@ -919,12 +921,6 @@ WERROR _svcctl_SetServiceStatus(pipes_struct *p, struct svcctl_SetServiceStatus return WERR_NOT_SUPPORTED; } -WERROR _svcctl_UnlockServiceDatabase(pipes_struct *p, struct svcctl_UnlockServiceDatabase *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_NotifyBootConfigStatus(pipes_struct *p, struct svcctl_NotifyBootConfigStatus *r) { p->rng_fault_state = True; -- cgit From d85c517b45b8feb8469f7073d770e7fedc818259 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 22 Feb 2008 17:35:53 +0100 Subject: Add variable to define if a share should be hidden. If you create a share on a Windows machine called foo$ then this share is of the type STYPE_DISKTREE. So it is possible to administrate this kind of share. Tested on Windows NT and 2003. In samba we assume that if a share with a $ at the end must be of the type STYPE_DISKTREE_HIDDEN. This is wrong, so we need a variable in the config to define if the share should be hidden or not. (This used to be commit a3da677bf0faed56e6731ee96708a7847a61d118) --- source3/rpc_server/srv_srvsvc_nt.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 1b877ee5b4..f0680a89e5 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -225,9 +225,6 @@ static WERROR net_enum_files( TALLOC_CTX *ctx, const char *username, ********************************************************************/ static uint32 get_share_type(int snum) { - char *net_name = lp_servicename(snum); - int len_net_name = strlen(net_name); - /* work out the share type */ uint32 type = STYPE_DISKTREE; @@ -235,7 +232,7 @@ static uint32 get_share_type(int snum) type = STYPE_PRINTQ; if (strequal(lp_fstype(snum), "IPC")) type = STYPE_IPC; - if (net_name[len_net_name-1] == '$') + if (lp_hidden(snum)) type |= STYPE_HIDDEN; return type; -- cgit From 2d01ec2c390f8dd753600f22cefb17e7b8916ffd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 15:49:31 +0100 Subject: Use new LSA_POLICY defines in lsa rpc server code and other places. Guenther (This used to be commit 58cca9faf9db506bd2f6eab4a99ef85153797ab2) --- source3/rpc_server/srv_lsa_nt.c | 48 ++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index f43258d5e5..ec9da32874 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -40,10 +40,10 @@ struct lsa_info { }; const struct generic_mapping lsa_generic_mapping = { - POLICY_READ, - POLICY_WRITE, - POLICY_EXECUTE, - POLICY_ALL_ACCESS + LSA_POLICY_READ, + LSA_POLICY_WRITE, + LSA_POLICY_EXECUTE, + LSA_POLICY_ALL_ACCESS }; /*************************************************************************** @@ -289,17 +289,17 @@ static NTSTATUS lsa_get_generic_sd(TALLOC_CTX *mem_ctx, SEC_DESC **sd, size_t *s SEC_ACL *psa = NULL; - init_sec_access(&mask, POLICY_EXECUTE); + init_sec_access(&mask, LSA_POLICY_EXECUTE); init_sec_ace(&ace[0], &global_sid_World, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); sid_copy(&adm_sid, get_global_sam_sid()); sid_append_rid(&adm_sid, DOMAIN_GROUP_RID_ADMINS); - init_sec_access(&mask, POLICY_ALL_ACCESS); + init_sec_access(&mask, LSA_POLICY_ALL_ACCESS); init_sec_ace(&ace[1], &adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); sid_copy(&local_adm_sid, &global_sid_Builtin); sid_append_rid(&local_adm_sid, BUILTIN_ALIAS_RID_ADMINS); - init_sec_access(&mask, POLICY_ALL_ACCESS); + init_sec_access(&mask, LSA_POLICY_ALL_ACCESS); init_sec_ace(&ace[2], &local_adm_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, mask, 0); if((psa = make_sec_acl(mem_ctx, NT4_ACL_REVISION, 3, ace)) == NULL) @@ -390,7 +390,7 @@ NTSTATUS _lsa_OpenPolicy2(pipes_struct *p, /* This is needed for lsa_open_account and rpcclient .... :-) */ if (p->pipe_user.ut.uid == sec_initial_uid()) - acc_granted = POLICY_ALL_ACCESS; + acc_granted = LSA_POLICY_ALL_ACCESS; /* associate the domain SID with the (unique) handle. */ if ((info = SMB_MALLOC_P(struct lsa_info)) == NULL) @@ -483,7 +483,7 @@ NTSTATUS _lsa_EnumTrustDom(pipes_struct *p, return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ - if (!(info->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(info->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; nt_status = pdb_enum_trusteddoms(p->mem_ctx, &num_domains, &domains); @@ -558,7 +558,7 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, uint32 policy_def = LSA_AUDIT_POLICY_ALL; /* check if the user have enough rights */ - if (!(handle->access & POLICY_VIEW_AUDIT_INFORMATION)) { + if (!(handle->access & LSA_POLICY_VIEW_AUDIT_INFORMATION)) { DEBUG(10,("_lsa_QueryInfoPolicy: insufficient access rights\n")); return NT_STATUS_ACCESS_DENIED; } @@ -586,7 +586,7 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, } case 0x03: /* check if the user have enough rights */ - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; /* Request PolicyPrimaryDomainInformation. */ @@ -615,7 +615,7 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, break; case 0x05: /* check if the user have enough rights */ - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; /* Request PolicyAccountDomainInformation. */ @@ -626,7 +626,7 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, break; case 0x06: /* check if the user have enough rights */ - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; switch (lp_server_role()) { @@ -793,7 +793,7 @@ NTSTATUS _lsa_LookupSids(pipes_struct *p, } /* check if the user has enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { + if (!(handle->access & LSA_POLICY_LOOKUP_NAMES)) { return NT_STATUS_ACCESS_DENIED; } @@ -867,7 +867,7 @@ NTSTATUS _lsa_LookupSids2(pipes_struct *p, } /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { + if (!(handle->access & LSA_POLICY_LOOKUP_NAMES)) { return NT_STATUS_ACCESS_DENIED; } } @@ -999,7 +999,7 @@ NTSTATUS _lsa_LookupNames(pipes_struct *p, } /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { + if (!(handle->access & LSA_POLICY_LOOKUP_NAMES)) { status = NT_STATUS_ACCESS_DENIED; goto done; } @@ -1138,7 +1138,7 @@ NTSTATUS _lsa_LookupNames3(pipes_struct *p, } /* check if the user have enough rights */ - if (!(handle->access & POLICY_LOOKUP_NAMES)) { + if (!(handle->access & LSA_POLICY_LOOKUP_NAMES)) { status = NT_STATUS_ACCESS_DENIED; goto done; } @@ -1292,7 +1292,7 @@ NTSTATUS _lsa_EnumPrivs(pipes_struct *p, /* check if the user have enough rights I don't know if it's the right one. not documented. */ - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; if (num_privs) { @@ -1350,7 +1350,7 @@ NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p, /* * I don't know if it's the right one. not documented. */ - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; DEBUG(10,("_lsa_LookupPrivDisplayName: name = %s\n", r->in.name->string)); @@ -1392,7 +1392,7 @@ NTSTATUS _lsa_EnumAccounts(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; sid_list = NULL; @@ -1505,7 +1505,7 @@ NTSTATUS _lsa_CreateAccount(pipes_struct *p, * I don't know if it's the right one. not documented. * but guessed with rpcclient. */ - if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) + if (!(handle->access & LSA_POLICY_GET_PRIVATE_INFORMATION)) return NT_STATUS_ACCESS_DENIED; /* check to see if the pipe_user is a Domain Admin since @@ -1554,7 +1554,7 @@ NTSTATUS _lsa_OpenAccount(pipes_struct *p, * I don't know if it's the right one. not documented. * but guessed with rpcclient. */ - if (!(handle->access & POLICY_GET_PRIVATE_INFORMATION)) + if (!(handle->access & LSA_POLICY_GET_PRIVATE_INFORMATION)) return NT_STATUS_ACCESS_DENIED; /* TODO: Fis the parsing routine before reenabling this check! */ @@ -1798,7 +1798,7 @@ NTSTATUS _lsa_QuerySecurity(pipes_struct *p, return NT_STATUS_INVALID_HANDLE; /* check if the user have enough rights */ - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; @@ -1855,7 +1855,7 @@ NTSTATUS _lsa_QuerySecurity(pipes_struct *p, switch (q_u->info_class) { case 0x0c: /* check if the user have enough rights */ - if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION)) + if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; /* Request PolicyPrimaryDomainInformation. */ -- cgit From ec790d039779c2a920911bbcdc6969f792e86ab1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 16:14:27 +0100 Subject: Move LSA_AUDIT_NUM_CATEGORIES defines to lsa rpc_server. Guenther (This used to be commit 9e7d32e28ce40ff158f3705354e8673f99b462bc) --- source3/rpc_server/srv_lsa_nt.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index ec9da32874..788fdb3661 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -529,6 +529,10 @@ NTSTATUS _lsa_EnumTrustDom(pipes_struct *p, return nt_status; } +#define LSA_AUDIT_NUM_CATEGORIES_NT4 7 +#define LSA_AUDIT_NUM_CATEGORIES_WIN2K 9 +#define LSA_AUDIT_NUM_CATEGORIES LSA_AUDIT_NUM_CATEGORIES_NT4 + /*************************************************************************** _lsa_QueryInfoPolicy ***************************************************************************/ -- cgit From d61831dcd414e0279dfd576a8c85a83a37bf2699 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 16:52:39 +0100 Subject: Move MAX_SAM_ENTRIES defines to samr rpc_server and to samr.idl. Guenther (This used to be commit 6c6455157317049d65a9012f4e339b7e86fb0af6) --- source3/rpc_server/srv_samr_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index df7bb9b206..8289440d6e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -876,6 +876,8 @@ static NTSTATUS make_user_sam_entry_list(TALLOC_CTX *ctx, return NT_STATUS_OK; } +#define MAX_SAM_ENTRIES MAX_SAM_ENTRIES_W2K + /******************************************************************* _samr_EnumDomainUsers ********************************************************************/ -- cgit From 583aa074a9525e08d2d14696ca27f0a636bbf6a5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 18:49:17 +0100 Subject: Cosmetics: make check_bind_req() debug statements a little nicer. Guenther (This used to be commit 997a0a4a12d97595ff4df963601cf2c24d612972) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 4d066a6b7a..19c8db0533 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -993,7 +993,7 @@ bool check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, /* we have to check all now since win2k introduced a new UUID on the lsaprpc pipe */ for ( i=0; pipe_names[i].client_pipe; i++ ) { - DEBUG(10,("checking %s\n", pipe_names[i].client_pipe)); + DEBUGADD(10,("checking %s\n", pipe_names[i].client_pipe)); if ( strequal(pipe_names[i].client_pipe, pname) && (abstract->version == pipe_names[i].abstr_syntax.version) && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(struct GUID)) == 0) -- cgit From 7269a504fdd06fbbe24c2df8e084b41382d71269 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 19:38:48 +0100 Subject: Add my copyright. Guenther (This used to be commit d078a8757182d84dfd3307a2e1b751cf173aaa97) --- source3/rpc_server/srv_lsa_nt.c | 1 + source3/rpc_server/srv_netlog_nt.c | 1 + source3/rpc_server/srv_samr_nt.c | 1 + source3/rpc_server/srv_samr_util.c | 1 + 4 files changed, 4 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 788fdb3661..1333d656d4 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -10,6 +10,7 @@ * Copyright (C) Simo Sorce 2003. * Copyright (C) Gerald (Jerry) Carter 2005. * Copyright (C) Volker Lendecke 2005. + * Copyright (C) Guenther Deschner 2008. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index c64e5b8d10..5b26f55845 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -6,6 +6,7 @@ * Copyright (C) Paul Ashton 1997. * Copyright (C) Jeremy Allison 1998-2001. * Copyright (C) Andrew Bartlett 2001. + * Copyright (C) Guenther Deschner 2008. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 8289440d6e..f8b953904f 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -11,6 +11,7 @@ * Copyright (C) Gerald (Jerry) Carter 2003-2004, * Copyright (C) Simo Sorce 2003. * Copyright (C) Volker Lendecke 2005. + * Copyright (C) Guenther Deschner 2008. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 364adbc0de..688d72064f 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -6,6 +6,7 @@ Copyright (C) Gerald (Jerry) Carter 2000-2001 Copyright (C) Andrew Bartlett 2001-2002 Copyright (C) Stefan (metze) Metzmacher 2002 + Copyright (C) Guenther Deschner 2008 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -- cgit From fac7193cd21c678e1fd5fef1582b712405032931 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 00:05:23 +0100 Subject: Use pidl for _svcctl_QueryServiceObjectSecurity(). Guenther (This used to be commit 7c1d30f3dca068d7a3b6ec138d1d01141f0386c2) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 565c93fa77..2c594ace8c 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -236,23 +236,7 @@ static bool api_svcctl_unlock_service_db(pipes_struct *p) static bool api_svcctl_query_security_sec(pipes_struct *p) { - SVCCTL_Q_QUERY_SERVICE_SEC q_u; - SVCCTL_R_QUERY_SERVICE_SEC r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_query_service_sec("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_query_service_sec(p, &q_u, &r_u); - - if(!svcctl_io_r_query_service_sec("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_QUERYSERVICEOBJECTSECURITY); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 53154ef0c9..2672647c1d 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -802,12 +802,17 @@ WERROR _svcctl_UnlockServiceDatabase(pipes_struct *p, } /******************************************************************** + _svcctl_QueryServiceObjectSecurity ********************************************************************/ -WERROR _svcctl_query_service_sec( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_SEC *q_u, SVCCTL_R_QUERY_SERVICE_SEC *r_u ) +WERROR _svcctl_QueryServiceObjectSecurity(pipes_struct *p, + struct svcctl_QueryServiceObjectSecurity *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); SEC_DESC *sec_desc; + NTSTATUS status; + uint8_t *buffer = NULL; + size_t len = 0; /* only support the SCM and individual services */ @@ -822,7 +827,7 @@ WERROR _svcctl_query_service_sec( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_SEC *q /* TODO: handle something besides DACL_SECURITY_INFORMATION */ - if ( (q_u->security_flags & DACL_SECURITY_INFORMATION) != DACL_SECURITY_INFORMATION ) + if ( (r->in.security_flags & DACL_SECURITY_INFORMATION) != DACL_SECURITY_INFORMATION ) return WERR_INVALID_PARAM; /* lookup the security descriptor and marshall it up for a reply */ @@ -830,17 +835,20 @@ WERROR _svcctl_query_service_sec( pipes_struct *p, SVCCTL_Q_QUERY_SERVICE_SEC *q if ( !(sec_desc = svcctl_get_secdesc( p->mem_ctx, info->name, get_root_nt_token() )) ) return WERR_NOMEM; - r_u->needed = ndr_size_security_descriptor( sec_desc, 0 ); + *r->out.needed = ndr_size_security_descriptor( sec_desc, 0 ); - if ( r_u->needed > q_u->buffer_size ) { - ZERO_STRUCTP( &r_u->buffer ); + if ( *r->out.needed > r->in.buffer_size ) { + ZERO_STRUCTP( &r->out.buffer ); return WERR_INSUFFICIENT_BUFFER; } - rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); + status = marshall_sec_desc(p->mem_ctx, sec_desc, &buffer, &len); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } - if ( !sec_io_desc("", &sec_desc, &r_u->buffer.prs, 0 ) ) - return WERR_NOMEM; + *r->out.needed = len; + r->out.buffer = buffer; return WERR_OK; } @@ -903,12 +911,6 @@ WERROR _svcctl_DeleteService(pipes_struct *p, struct svcctl_DeleteService *r) return WERR_NOT_SUPPORTED; } -WERROR _svcctl_QueryServiceObjectSecurity(pipes_struct *p, struct svcctl_QueryServiceObjectSecurity *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_SetServiceObjectSecurity(pipes_struct *p, struct svcctl_SetServiceObjectSecurity *r) { p->rng_fault_state = True; -- cgit From c86cbd736957b6d5f3c3f648ce07c593fd60af99 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 00:33:06 +0100 Subject: Use pidl for _svcctl_SetServiceObjectSecurity(). Guenther (This used to be commit 19048ab4ad1b262536efae5b8b8b4411ec088921) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 28 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 2c594ace8c..5e125145d6 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -244,23 +244,7 @@ static bool api_svcctl_query_security_sec(pipes_struct *p) static bool api_svcctl_set_security_sec(pipes_struct *p) { - SVCCTL_Q_SET_SERVICE_SEC q_u; - SVCCTL_R_SET_SERVICE_SEC r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_set_service_sec("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_set_service_sec(p, &q_u, &r_u); - - if(!svcctl_io_r_set_service_sec("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_SETSERVICEOBJECTSECURITY); } diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 2672647c1d..73d09b1bbb 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -854,13 +854,16 @@ WERROR _svcctl_QueryServiceObjectSecurity(pipes_struct *p, } /******************************************************************** + _svcctl_SetServiceObjectSecurity ********************************************************************/ -WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, SVCCTL_R_SET_SERVICE_SEC *r_u ) +WERROR _svcctl_SetServiceObjectSecurity(pipes_struct *p, + struct svcctl_SetServiceObjectSecurity *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.handle ); SEC_DESC *sec_desc = NULL; uint32 required_access; + NTSTATUS status; if ( !info || !(info->type & (SVC_HANDLE_IS_SERVICE|SVC_HANDLE_IS_SCM)) ) return WERR_BADFID; @@ -872,7 +875,7 @@ WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, /* check the access on the open handle */ - switch ( q_u->security_flags ) { + switch ( r->in.security_flags ) { case DACL_SECURITY_INFORMATION: required_access = STD_RIGHT_WRITE_DAC_ACCESS; break; @@ -893,8 +896,12 @@ WERROR _svcctl_set_service_sec( pipes_struct *p, SVCCTL_Q_SET_SERVICE_SEC *q_u, /* read the security descfriptor */ - if ( !sec_io_desc("", &sec_desc, &q_u->buffer.prs, 0 ) ) - return WERR_NOMEM; + status = unmarshall_sec_desc(p->mem_ctx, + r->in.buffer, r->in.buffer_size, + &sec_desc); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } /* store the new SD */ @@ -911,12 +918,6 @@ WERROR _svcctl_DeleteService(pipes_struct *p, struct svcctl_DeleteService *r) return WERR_NOT_SUPPORTED; } -WERROR _svcctl_SetServiceObjectSecurity(pipes_struct *p, struct svcctl_SetServiceObjectSecurity *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_SetServiceStatus(pipes_struct *p, struct svcctl_SetServiceStatus *r) { p->rng_fault_state = True; -- cgit From b2ed9341ee309acf2cb6f81bff4bc9243bf21d55 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 10:14:26 +0100 Subject: Fix segfault in _srv_net_file_enum. Guenther (This used to be commit 6523a051ded9f7b433fcce2d4c4a5f186b5a28f6) --- source3/rpc_server/srv_srvsvc_nt.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index f0680a89e5..37bd204f75 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1216,17 +1216,20 @@ done: WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) { + const char *username = NULL; + switch ( q_u->level ) { - case 3: { - char *username; - if (!(username = rpcstr_pull_unistr2_talloc( - p->mem_ctx, q_u->username))) { - return WERR_NOMEM; + case 3: + if (q_u->username) { + username = rpcstr_pull_unistr2_talloc( + p->mem_ctx, q_u->username); + if (!username) { + return WERR_NOMEM; + } } return net_file_enum_3(username, r_u, get_enum_hnd(&q_u->enum_hnd)); - } default: return WERR_UNKNOWN_LEVEL; } -- cgit From b9ca5bf0a12f40030bbbe6a5c881cc4a035ed68d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 12:51:45 +0100 Subject: Fix one dsgetdcname call in wkssvc rpc server. Guenther (This used to be commit a69b918784b037aa17d2dd88a33bd99930631c9b) --- source3/rpc_server/srv_wkssvc_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index e0103e6b58..43bd20d2d7 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -293,7 +293,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r WERROR werr; NTSTATUS status; struct nt_user_token *token = p->pipe_user.nt_user_token; - struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; + struct netr_DsRGetDCNameInfo *info = NULL; if (!r->in.domain_name) { return WERR_INVALID_PARAM; @@ -335,7 +335,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r return werr; } - j->in.dc_name = info->domain_controller_name; + j->in.dc_name = info->dc_unc; j->in.domain_name = r->in.domain_name; j->in.account_ou = r->in.account_ou; j->in.join_flags = r->in.join_flags; -- cgit From 781e1ab4a1d9c5fe581034d42c9c597cd5d7be4d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 20:01:32 +0100 Subject: Re-enable _wkssvc_NetrJoinDomain2 remote join implementation now that we are ready for it. "netdom join SAMBAHOST" from a windows workstation nicely demonstrates it. Guenther (This used to be commit 3bcaa3582a101abc17f7c21128e01024af877577) --- source3/rpc_server/srv_wkssvc_nt.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 43bd20d2d7..e559248ef8 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -281,11 +281,12 @@ WERROR _wkssvc_NetrGetJoinableOus(pipes_struct *p, struct wkssvc_NetrGetJoinable } /******************************************************************** + _wkssvc_NetrJoinDomain2 ********************************************************************/ -WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r) +WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, + struct wkssvc_NetrJoinDomain2 *r) { -#if 0 struct libnet_JoinCtx *j = NULL; char *cleartext_pwd = NULL; char *admin_domain = NULL; @@ -302,6 +303,8 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r if (!user_has_privileges(token, &se_machine_account) && !nt_token_check_domain_rid(token, DOMAIN_GROUP_RID_ADMINS) && !nt_token_check_domain_rid(token, BUILTIN_ALIAS_RID_ADMINS)) { + DEBUG(5,("_wkssvc_NetrJoinDomain2: account doesn't have " + "sufficient privileges\n")); return WERR_ACCESS_DENIED; } @@ -341,16 +344,20 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, struct wkssvc_NetrJoinDomain2 *r j->in.join_flags = r->in.join_flags; j->in.admin_account = admin_account; j->in.admin_password = cleartext_pwd; - j->in.modify_config = true; + j->in.debug = true; become_root(); werr = libnet_Join(p->mem_ctx, j); unbecome_root(); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(5,("_wkssvc_NetrJoinDomain2: libnet_Join gave %s\n", + j->out.error_string ? j->out.error_string : + dos_errstr(werr))); + } + + TALLOC_FREE(j); return werr; -#endif - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; } /******************************************************************** -- cgit From 37bca2ea57e2f2f13a9ab59d6fcd8f27052f65ef Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 21:55:01 +0100 Subject: While we are at it: add _wkssvc_NetrUnjoinDomain2 implementation. This can be tested with e.g. "netdom remove SAMBAHOST" from windows. Guenther (This used to be commit 53121e62ea32ff3a984533dca044b67cf5b2c55b) --- source3/rpc_server/srv_wkssvc_nt.c | 68 +++++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index e559248ef8..6d03009d00 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -361,13 +361,73 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, } /******************************************************************** + _wkssvc_NetrUnjoinDomain2 ********************************************************************/ -WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, struct wkssvc_NetrUnjoinDomain2 *r) +WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, + struct wkssvc_NetrUnjoinDomain2 *r) { - /* FIXME: Add implementation code here */ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; + struct libnet_UnjoinCtx *u = NULL; + char *cleartext_pwd = NULL; + char *admin_domain = NULL; + char *admin_account = NULL; + WERROR werr; + NTSTATUS status; + struct nt_user_token *token = p->pipe_user.nt_user_token; + struct netr_DsRGetDCNameInfo *info = NULL; + + if (!user_has_privileges(token, &se_machine_account) && + !nt_token_check_domain_rid(token, DOMAIN_GROUP_RID_ADMINS) && + !nt_token_check_domain_rid(token, BUILTIN_ALIAS_RID_ADMINS)) { + DEBUG(5,("_wkssvc_NetrUnjoinDomain2: account doesn't have " + "sufficient privileges\n")); + return WERR_ACCESS_DENIED; + } + + werr = decode_wkssvc_join_password_buffer(p->mem_ctx, + r->in.encrypted_password, + &p->session_key, + &cleartext_pwd); + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + + split_domain_user(p->mem_ctx, + r->in.account, + &admin_domain, + &admin_account); + + status = dsgetdcname(p->mem_ctx, + lp_realm(), + NULL, + NULL, + DS_DIRECTORY_SERVICE_REQUIRED | + DS_WRITABLE_REQUIRED | + DS_RETURN_DNS_NAME, + &info); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + werr = libnet_init_UnjoinCtx(p->mem_ctx, &u); + if (!W_ERROR_IS_OK(werr)) { + return werr; + } + + u->in.dc_name = info->dc_unc; + u->in.domain_name = lp_realm(); + u->in.unjoin_flags = r->in.unjoin_flags | + WKSSVC_JOIN_FLAGS_JOIN_TYPE; + u->in.admin_account = admin_account; + u->in.admin_password = cleartext_pwd; + u->in.debug = true; + + become_root(); + werr = libnet_Unjoin(p->mem_ctx, u); + unbecome_root(); + + TALLOC_FREE(u); + return werr; } /******************************************************************** -- cgit From 700438dbbd45c8e097a74b98a56a0c97e241fa34 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 28 Feb 2008 23:37:47 +0100 Subject: Fix samr querydispinfo w.r.t. lsa_AsciiStringLarge. Thanks metze for the fix. Guenther (This used to be commit dcffb885bc5d16e795b71d95e0790d3d7d70cf3c) --- source3/rpc_server/srv_samr_nt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f8b953904f..f38a8fcfc0 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1318,8 +1318,8 @@ static NTSTATUS init_samr_dispinfo_4(TALLOC_CTX *ctx, for (i = 0; i < num_entries ; i++) { - init_lsa_AsciiString(&r->entries[i].account_name, - entries[i].account_name); + init_lsa_AsciiStringLarge(&r->entries[i].account_name, + entries[i].account_name); r->entries[i].idx = start_idx+i+1; } @@ -1354,8 +1354,8 @@ static NTSTATUS init_samr_dispinfo_5(TALLOC_CTX *ctx, for (i = 0; i < num_entries ; i++) { - init_lsa_AsciiString(&r->entries[i].account_name, - entries[i].account_name); + init_lsa_AsciiStringLarge(&r->entries[i].account_name, + entries[i].account_name); r->entries[i].idx = start_idx+i+1; } -- cgit From 1751b533f00ca75082b452ca9922c2c8f277be4b Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 28 Feb 2008 14:06:11 +0100 Subject: Rename the 'hidden' variable to 'administrative share'. (This used to be commit eff3d3bad5a8860b99375cc0be9dc24f3679e416) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 37bd204f75..8a25b6cfd5 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -232,7 +232,7 @@ static uint32 get_share_type(int snum) type = STYPE_PRINTQ; if (strequal(lp_fstype(snum), "IPC")) type = STYPE_IPC; - if (lp_hidden(snum)) + if (lp_administrative_share(snum)) type |= STYPE_HIDDEN; return type; -- cgit From 4aa0bfc9853fd0b6d2882c40c53d20e65fe2fa48 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 3 Mar 2008 18:12:26 +0100 Subject: Zero out the out policy handler in lsa_Close ... after a REALLY long session staring at sniffs we can now join XP to v3-2-test again... Apparently not doing this makes XP keep an internal handle to LSA open which confuses the hell out of it. Karolin, this needs to be in v3-2-stable :-) Volker (This used to be commit 2c42fc21d8bede226e411623aecd69038477373b) --- source3/rpc_server/srv_lsa_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 1333d656d4..ce3fd1a44f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1216,6 +1216,7 @@ NTSTATUS _lsa_Close(pipes_struct *p, struct lsa_Close *r) } close_policy_hnd(p, r->in.handle); + ZERO_STRUCTP(r->out.handle); return NT_STATUS_OK; } -- cgit From b2729f4e2dae9bf6dd74555ac1b3b0c2f420c5bf Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 11:06:02 +0100 Subject: Zero more structs initially in LSA rpc server. Guenther (This used to be commit d7ce643285276790a65faff76666498595a508d7) --- source3/rpc_server/srv_lsa_nt.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index ce3fd1a44f..c2502141e5 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -82,6 +82,8 @@ static int init_lsa_ref_domain_list(TALLOC_CTX *mem_ctx, return -1; } + ZERO_STRUCT(ref->domains[num]); + init_lsa_StringLarge(&ref->domains[num].name, dom_name); ref->domains[num].sid = sid_dup_talloc(mem_ctx, dom_sid); if (!ref->domains[num].sid) { @@ -228,6 +230,8 @@ static NTSTATUS lookup_lsa_sids(TALLOC_CTX *mem_ctx, const char *domain; enum lsa_SidType type = SID_NAME_UNKNOWN; + ZERO_STRUCT(sid); + /* Split name into domain and user component */ full_name = name[i].string; -- cgit From 33322a7ced16e4b4325a813b4143833954882745 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 12:46:15 +0100 Subject: Fix lsa_QueryInfoPolicy: make proper talloc copies of the sids. Guenther (This used to be commit b9441232d66d78e66464be6c9748a023681ce6ca) --- source3/rpc_server/srv_lsa_nt.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c2502141e5..c03630d6f9 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -603,15 +603,22 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, case ROLE_DOMAIN_PDC: case ROLE_DOMAIN_BDC: name = get_global_sam_name(); - sid = get_global_sam_sid(); + sid = sid_dup_talloc(p->mem_ctx, get_global_sam_sid()); + if (!sid) { + return NT_STATUS_NO_MEMORY; + } break; case ROLE_DOMAIN_MEMBER: name = lp_workgroup(); /* We need to return the Domain SID here. */ - if (secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) - sid = &domain_sid; - else + if (secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) { + sid = sid_dup_talloc(p->mem_ctx, &domain_sid); + if (!sid) { + return NT_STATUS_NO_MEMORY; + } + } else { return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; + } break; case ROLE_STANDALONE: name = lp_workgroup(); -- cgit From 253dc4d728cb27dc53bf072dcd4e0efa896ab7d2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 13:16:02 +0100 Subject: Fix counter mismatch in lsa_LookupNames server. Guenther (This used to be commit 80fd085c34befd38d33cf6e59080a2a36016a92d) --- source3/rpc_server/srv_lsa_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index c03630d6f9..b3275f27a3 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1036,10 +1036,10 @@ done: } } - *r->out.count = num_entries; + *r->out.count = mapped_count; *r->out.domains = domains; r->out.sids->sids = rids; - r->out.sids->count = mapped_count; + r->out.sids->count = num_entries; return status; } -- cgit From 7c95f53b686e5a3eb291534ae9cdc5939ef2ac66 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 13:19:38 +0100 Subject: Fix counter mismatch in lsa_LookupNames3 server. Guenther (This used to be commit e052d6f2c82a644986e5d99f640310d71cd5c396) --- source3/rpc_server/srv_lsa_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index b3275f27a3..20c910e46d 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1176,10 +1176,10 @@ done: } } - *r->out.count = num_entries; + *r->out.count = mapped_count; *r->out.domains = domains; r->out.sids->sids = trans_sids; - r->out.sids->count = mapped_count; + r->out.sids->count = num_entries; return status; } -- cgit From ae45a74ddc3053405cf515ea276f82c674672de2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 22:54:14 +0100 Subject: Fix proxy_srvsvc_call(). Wow, this must have been broken a long time already. Guenther (This used to be commit 821762e5ab32a2fbea7c41f1d2c2ea8589daa1d3) --- source3/rpc_server/srv_srvsvc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 25e652c1fd..22fcaffb4e 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -34,13 +34,13 @@ static bool proxy_srvsvc_call(pipes_struct *p, uint8 opnum) struct api_struct *fns; int n_fns; - lsarpc_get_pipe_fns(&fns, &n_fns); + srvsvc_get_pipe_fns(&fns, &n_fns); if (opnum >= n_fns) return False; if (fns[opnum].opnum != opnum) { - smb_panic("LSA function table not sorted\n"); + smb_panic("SRVSVC function table not sorted\n"); } return fns[opnum].fn(p); -- cgit From d89877070e9ae3e3cc2690fd4ffb683d6e44f982 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 21:46:09 +0100 Subject: Whitespace cleanup in srvsvc server. Guenther (This used to be commit 3c0a3f8de742678b56f6b998a014105c05400666) --- source3/rpc_server/srv_srvsvc_nt.c | 100 ++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 8a25b6cfd5..880c808bd5 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1,21 +1,21 @@ -/* +/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Jeremy Allison 2001. * Copyright (C) Nigel Williams 2001. * Copyright (C) Gerald (Jerry) Carter 2006. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ @@ -101,11 +101,11 @@ static int pipe_enum_fn( struct db_record *rec, void *p) ********************************************************************/ static WERROR net_enum_pipes( TALLOC_CTX *ctx, const char *username, - FILE_INFO_3 **info, + FILE_INFO_3 **info, uint32 *count, uint32 resume ) { struct file_enum_count fenum; - + fenum.ctx = ctx; fenum.username = username; fenum.count = *count; @@ -202,7 +202,7 @@ static void enum_file_fn( const struct share_mode_entry *e, ********************************************************************/ static WERROR net_enum_files( TALLOC_CTX *ctx, const char *username, - FILE_INFO_3 **info, + FILE_INFO_3 **info, uint32 *count, uint32 resume ) { struct file_enum_count f_enum_cnt; @@ -211,12 +211,12 @@ static WERROR net_enum_files( TALLOC_CTX *ctx, const char *username, f_enum_cnt.username = username; f_enum_cnt.count = *count; f_enum_cnt.info = *info; - + share_mode_forall( enum_file_fn, (void *)&f_enum_cnt ); - + *info = f_enum_cnt.info; *count = f_enum_cnt.count; - + return WERR_OK; } @@ -602,7 +602,7 @@ static bool init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, { SRV_SHARE_INFO_501 *info501 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_501, num_entries); int i = 0; - + if (!info501) { return False; } @@ -612,7 +612,7 @@ static bool init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, init_srv_share_info_501(p, &info501[i++], snum); } } - + ctr->share.info501 = info501; break; } @@ -637,7 +637,7 @@ static bool init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, } /* here for completeness but not currently used with enum (1004 - 1501)*/ - + case 1004: { SRV_SHARE_INFO_1004 *info1004 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1004, num_entries); @@ -745,7 +745,7 @@ static bool init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, ********************************************************************/ 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) + uint32 info_level, uint32 resume_hnd, bool all) { DEBUG(5,("init_srv_r_net_share_enum: %d\n", __LINE__)); @@ -852,7 +852,7 @@ static void init_srv_sess_info_0(pipes_struct *p, SRV_SESS_INFO_0 *ss0, uint32 * ss0->num_entries_read = num_entries; ss0->ptr_sess_info = num_entries > 0 ? 1 : 0; ss0->num_entries_read2 = num_entries; - + if ((*snum) >= (*stot)) { (*snum) = 0; } @@ -867,16 +867,16 @@ static void init_srv_sess_info_0(pipes_struct *p, SRV_SESS_INFO_0 *ss0, uint32 * /******************************************************************* ********************************************************************/ -static void sess_file_fn( const struct share_mode_entry *e, +static void sess_file_fn( const struct share_mode_entry *e, const char *sharepath, const char *fname, void *data ) { struct sess_file_count *sess = (struct sess_file_count *)data; - + if ( procid_equal(&e->pid, &sess->pid) && (sess->uid == e->uid) ) { sess->count++; } - + return; } @@ -890,9 +890,9 @@ static int net_count_files( uid_t uid, struct server_id pid ) s_file_cnt.count = 0; s_file_cnt.uid = uid; s_file_cnt.pid = pid; - + share_mode_forall( sess_file_fn, &s_file_cnt ); - + return s_file_cnt.count; } @@ -910,42 +910,42 @@ static void init_srv_sess_info_1(pipes_struct *p, SRV_SESS_INFO_1 *ss1, uint32 * ss1->num_entries_read = 0; ss1->ptr_sess_info = 0; ss1->num_entries_read2 = 0; - + (*stot) = 0; return; } - + if (ss1 == NULL) { (*snum) = 0; return; } (*stot) = list_sessions(p->mem_ctx, &session_list); - + for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { uint32 num_files; uint32 connect_time; struct passwd *pw = sys_getpwnam(session_list[*snum].username); bool guest; - + if ( !pw ) { DEBUG(10,("init_srv_sess_info_1: failed to find owner: %s\n", session_list[*snum].username)); continue; } - + connect_time = (uint32)(now - session_list[*snum].connect_start); num_files = net_count_files(pw->pw_uid, session_list[*snum].pid); guest = strequal( session_list[*snum].username, lp_guestaccount() ); - - init_srv_sess_info1( &ss1->info_1[num_entries], + + init_srv_sess_info1( &ss1->info_1[num_entries], session_list[*snum].remote_machine, - session_list[*snum].username, + session_list[*snum].username, num_files, connect_time, - 0, + 0, guest); num_entries++; } @@ -953,7 +953,7 @@ static void init_srv_sess_info_1(pipes_struct *p, SRV_SESS_INFO_1 *ss1, uint32 * ss1->num_entries_read = num_entries; ss1->ptr_sess_info = num_entries > 0 ? 1 : 0; ss1->num_entries_read2 = num_entries; - + if ((*snum) >= (*stot)) { (*snum) = 0; } @@ -998,7 +998,7 @@ static WERROR init_srv_sess_info_ctr(pipes_struct *p, SRV_SESS_INFO_CTR *ctr, ********************************************************************/ static void init_srv_r_net_sess_enum(pipes_struct *p, SRV_R_NET_SESS_ENUM *r_n, - uint32 resume_hnd, int sess_level, int switch_value) + uint32 resume_hnd, int sess_level, int switch_value) { DEBUG(5,("init_srv_r_net_sess_enum: %d\n", __LINE__)); @@ -1044,7 +1044,7 @@ static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *sto ss0->num_entries_read = num_entries; ss0->ptr_conn_info = num_entries > 0 ? 1 : 0; ss0->num_entries_read2 = num_entries; - + if ((*snum) >= (*stot)) { (*snum) = 0; } @@ -1101,7 +1101,7 @@ static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto ss1->num_entries_read = num_entries; ss1->ptr_conn_info = num_entries > 0 ? 1 : 0; ss1->num_entries_read2 = num_entries; - + if ((*snum) >= (*stot)) { (*snum) = 0; @@ -1111,7 +1111,7 @@ static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *sto ss1->num_entries_read = 0; ss1->ptr_conn_info = 0; ss1->num_entries_read2 = 0; - + (*stot) = 0; } } @@ -1154,7 +1154,7 @@ static WERROR init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, ********************************************************************/ static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, - uint32 resume_hnd, int conn_level, int switch_value) + uint32 resume_hnd, int conn_level, int switch_value) { DEBUG(5,("init_srv_r_net_conn_enum: %d\n", __LINE__)); @@ -1180,7 +1180,7 @@ static WERROR net_file_enum_3( const char *username, SRV_R_NET_FILE_ENUM *r, TALLOC_CTX *ctx = talloc_tos(); SRV_FILE_INFO_CTR *ctr = &r->ctr; - /* TODO -- Windows enumerates + /* TODO -- Windows enumerates (b) active pipes (c) open directories and files */ @@ -1188,12 +1188,12 @@ static WERROR net_file_enum_3( const char *username, SRV_R_NET_FILE_ENUM *r, &ctr->num_entries, resume_hnd ); if ( !W_ERROR_IS_OK(r->status)) goto done; - + r->status = net_enum_pipes( ctx, username, &ctr->file.info3, &ctr->num_entries, resume_hnd ); if ( !W_ERROR_IS_OK(r->status)) goto done; - + r->level = ctr->level = 3; r->total_entries = ctr->num_entries; /* ctr->num_entries = r->total_entries - resume_hnd; */ @@ -1203,7 +1203,7 @@ static WERROR net_file_enum_3( const char *username, SRV_R_NET_FILE_ENUM *r, r->status = WERR_OK; done: - if ( ctr->num_entries > 0 ) + if ( ctr->num_entries > 0 ) ctr->ptr_entries = 1; init_enum_hnd(&r->enum_hnd, 0); @@ -1233,7 +1233,7 @@ WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_F default: return WERR_UNKNOWN_LEVEL; } - + return WERR_OK; } @@ -1266,7 +1266,7 @@ WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R case 102: init_srv_info_102(&ctr->srv.sv102, - 500, global_myname(), + 500, global_myname(), string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), lp_major_announce_version(), lp_minor_announce_version(), lp_default_server_announce(), @@ -1401,7 +1401,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES /* fail out now if you are not root or not a domain admin */ - if ((user.ut.uid != sec_initial_uid()) && + if ((user.ut.uid != sec_initial_uid()) && ( ! nt_token_check_domain_rid(p->pipe_user.nt_user_token, DOMAIN_GROUP_RID_ADMINS))) { goto done; @@ -1413,7 +1413,7 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES strequal(session_list[snum].remote_machine, machine)) { NTSTATUS ntstat; - + if (user.ut.uid != sec_initial_uid()) { not_root = True; become_root(); @@ -1422,11 +1422,11 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES ntstat = messaging_send(smbd_messaging_context(), session_list[snum].pid, MSG_SHUTDOWN, &data_blob_null); - + if (NT_STATUS_IS_OK(ntstat)) r_u->status = WERR_OK; - if (not_root) + if (not_root) unbecome_root(); } } @@ -1720,7 +1720,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S /********* END SeDiskOperatorPrivilege BLOCK *********/ - DEBUG(3,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret )); + DEBUG(3,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret )); TALLOC_FREE(command); @@ -1819,7 +1819,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S map_generic_share_sd_bits(psd); break; - /* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */ + /* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */ case 1004: case 1005: @@ -2070,7 +2070,7 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET t->tm_mon + 1, 1900+t->tm_year, t->tm_wday); - + DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); return r_u->status; @@ -2362,7 +2362,7 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D r_u->total_entries = init_server_disk_enum(&resume); - r_u->disk_enum_ctr.unknown = 0; + r_u->disk_enum_ctr.unknown = 0; if(!(r_u->disk_enum_ctr.disk_info = TALLOC_ARRAY(ctx, DISK_INFO, MAX_SERVER_DISK_ENTRIES))) { return WERR_NOMEM; @@ -2378,7 +2378,7 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D /*copy disk name into a unicode string*/ - init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name); + init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name); } /* add a terminating null string. Is this there if there is more data to come? */ -- cgit From 2c3dc9baa57d32c48cc58f16abae20fe763fd06f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 23:07:45 +0100 Subject: Use pidl for _srvsvc_NetSrvGetInfo(). Guenther (This used to be commit 34caa41fa6d44165b470508261c2bde124fc4955) --- source3/rpc_server/srv_srvsvc.c | 20 +------ source3/rpc_server/srv_srvsvc_nt.c | 106 ++++++++++++++++++++++--------------- 2 files changed, 64 insertions(+), 62 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 22fcaffb4e..0e97ee3460 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -52,25 +52,7 @@ static bool proxy_srvsvc_call(pipes_struct *p, uint8 opnum) static bool api_srv_net_srv_get_info(pipes_struct *p) { - SRV_Q_NET_SRV_GET_INFO q_u; - SRV_R_NET_SRV_GET_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server get info */ - if (!srv_io_q_net_srv_get_info("", &q_u, data, 0)) - return False; - - r_u.status = _srv_net_srv_get_info(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if (!srv_io_r_net_srv_get_info("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSRVGETINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 880c808bd5..ddb7e120d9 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1238,67 +1238,93 @@ WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_F } /******************************************************************* -net server get info + _srvsvc_NetSrvGetInfo ********************************************************************/ -WERROR _srv_net_srv_get_info(pipes_struct *p, SRV_Q_NET_SRV_GET_INFO *q_u, SRV_R_NET_SRV_GET_INFO *r_u) +WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, + struct srvsvc_NetSrvGetInfo *r) { WERROR status = WERR_OK; - SRV_INFO_CTR *ctr = TALLOC_P(p->mem_ctx, SRV_INFO_CTR); - if (!ctr) - return WERR_NOMEM; - - ZERO_STRUCTP(ctr); - - DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetSrvGetInfo: %d\n", __LINE__)); if (!pipe_access_check(p)) { - DEBUG(3, ("access denied to srv_net_srv_get_info\n")); + DEBUG(3, ("access denied to _srvsvc_NetSrvGetInfo\n")); return WERR_ACCESS_DENIED; } - switch (q_u->switch_value) { + switch (r->in.level) { /* Technically level 102 should only be available to Administrators but there isn't anything super-secret here, as most of it is made up. */ - case 102: - init_srv_info_102(&ctr->srv.sv102, - 500, global_myname(), - string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), - lp_major_announce_version(), lp_minor_announce_version(), - lp_default_server_announce(), - 0xffffffff, /* users */ - 0xf, /* disc */ - 0, /* hidden */ - 240, /* announce */ - 3000, /* announce delta */ - 100000, /* licenses */ - "c:\\"); /* user path */ + case 102: { + struct srvsvc_NetSrvInfo102 *info102; + + info102 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo102); + if (!info102) { + return WERR_NOMEM; + } + + init_srvsvc_NetSrvInfo102(info102, + PLATFORM_ID_NT, + global_myname(), + lp_major_announce_version(), + lp_minor_announce_version(), + lp_default_server_announce(), + string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), + 0xffffffff, /* users */ + 0xf, /* disc */ + 0, /* hidden */ + 240, /* announce */ + 3000, /* announce delta */ + 100000, /* licenses */ + "c:\\"); /* user path */ + r->out.info->info102 = info102; break; - case 101: - init_srv_info_101(&ctr->srv.sv101, - 500, global_myname(), - lp_major_announce_version(), lp_minor_announce_version(), - lp_default_server_announce(), - string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); + } + case 101: { + struct srvsvc_NetSrvInfo101 *info101; + + info101 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo101); + if (!info101) { + return WERR_NOMEM; + } + + init_srvsvc_NetSrvInfo101(info101, + PLATFORM_ID_NT, + global_myname(), + lp_major_announce_version(), + lp_minor_announce_version(), + lp_default_server_announce(), + string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH)); + r->out.info->info101 = info101; break; - case 100: - init_srv_info_100(&ctr->srv.sv100, 500, global_myname()); + } + case 100: { + struct srvsvc_NetSrvInfo100 *info100; + + info100 = TALLOC_P(p->mem_ctx, struct srvsvc_NetSrvInfo100); + if (!info100) { + return WERR_NOMEM; + } + + init_srvsvc_NetSrvInfo100(info100, + PLATFORM_ID_NT, + global_myname()); + r->out.info->info100 = info100; + break; + } default: status = WERR_UNKNOWN_LEVEL; break; } - /* set up the net server get info structure */ - init_srv_r_net_srv_get_info(r_u, q_u->switch_value, ctr, status); - - DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetSrvGetInfo: %d\n", __LINE__)); - return r_u->status; + return status; } /******************************************************************* @@ -2548,12 +2574,6 @@ WERROR _srvsvc_NetShareCheck(pipes_struct *p, struct srvsvc_NetShareCheck *r) return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, struct srvsvc_NetSrvGetInfo *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, struct srvsvc_NetSrvSetInfo *r) { p->rng_fault_state = True; -- cgit From eb44792a22f6889edcaa0760ab4ca86e9313122f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 4 Mar 2008 23:40:25 +0100 Subject: Use pidl for _srvsvc_NetSrvSetInfo(). Guenther (This used to be commit 75b0bbf790da44c45c679c374dbe09f288f3fb8c) --- source3/rpc_server/srv_srvsvc.c | 20 +------------------- source3/rpc_server/srv_srvsvc_nt.c | 19 ++++++------------- 2 files changed, 7 insertions(+), 32 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 0e97ee3460..a7e7be4a04 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -61,25 +61,7 @@ static bool api_srv_net_srv_get_info(pipes_struct *p) static bool api_srv_net_srv_set_info(pipes_struct *p) { - SRV_Q_NET_SRV_SET_INFO q_u; - SRV_R_NET_SRV_SET_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server set info */ - if (!srv_io_q_net_srv_set_info("", &q_u, data, 0)) - return False; - - r_u.status = _srv_net_srv_set_info(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if (!srv_io_r_net_srv_set_info("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSRVSETINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index ddb7e120d9..a3c9248ad2 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1328,22 +1328,21 @@ WERROR _srvsvc_NetSrvGetInfo(pipes_struct *p, } /******************************************************************* -net server set info + _srvsvc_NetSrvSetInfo ********************************************************************/ -WERROR _srv_net_srv_set_info(pipes_struct *p, SRV_Q_NET_SRV_SET_INFO *q_u, SRV_R_NET_SRV_SET_INFO *r_u) +WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, + struct srvsvc_NetSrvSetInfo *r) { WERROR status = WERR_OK; - DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetSrvSetInfo: %d\n", __LINE__)); /* Set up the net server set info structure. */ - init_srv_r_net_srv_set_info(r_u, 0x0, status); + DEBUG(5,("_srvsvc_NetSrvSetInfo: %d\n", __LINE__)); - DEBUG(5,("srv_net_srv_set_info: %d\n", __LINE__)); - - return r_u->status; + return status; } /******************************************************************* @@ -2574,12 +2573,6 @@ WERROR _srvsvc_NetShareCheck(pipes_struct *p, struct srvsvc_NetShareCheck *r) return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, struct srvsvc_NetSrvSetInfo *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetDiskEnum(pipes_struct *p, struct srvsvc_NetDiskEnum *r) { p->rng_fault_state = True; -- cgit From c6c67005a820fd20afd0674d9b8f529450f0e1ae Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 01:26:39 +0100 Subject: Use pidl for _srvsvc_NetShareSetInfo(). Guenther (This used to be commit 9bfa77edc68a887972b609bfb0aee8bbbc89ce04) --- source3/rpc_server/srv_srvsvc.c | 23 +---------- source3/rpc_server/srv_srvsvc_nt.c | 82 ++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 66 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index a7e7be4a04..0d50bccef0 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -270,28 +270,7 @@ static bool api_srv_net_share_get_info(pipes_struct *p) static bool api_srv_net_share_set_info(pipes_struct *p) { - SRV_Q_NET_SHARE_SET_INFO q_u; - SRV_R_NET_SHARE_SET_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server set info. */ - if(!srv_io_q_net_share_set_info("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_set_info: Failed to unmarshall SRV_Q_NET_SHARE_SET_INFO.\n")); - return False; - } - - r_u.status = _srv_net_share_set_info(p, &q_u, &r_u); - - if(!srv_io_r_net_share_set_info("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_set_info: Failed to marshall SRV_R_NET_SHARE_SET_INFO.\n")); - return False; - } - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHARESETINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index a3c9248ad2..75c262a7a6 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1564,16 +1564,17 @@ char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname) } /******************************************************************* - Net share set info. Modify share details. + _srvsvc_NetShareSetInfo. Modify share details. ********************************************************************/ -WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, SRV_R_NET_SHARE_SET_INFO *r_u) +WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, + struct srvsvc_NetShareSetInfo *r) { struct current_user user; char *command = NULL; char *share_name = NULL; char *comment = NULL; - char *pathname = NULL; + const char *pathname = NULL; int type; int snum; int ret; @@ -1583,15 +1584,16 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S bool is_disk_op = False; int max_connections = 0; TALLOC_CTX *ctx = p->mem_ctx; + union srvsvc_NetShareInfo *info = r->in.info; - DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetShareSetInfo: %d\n", __LINE__)); - share_name = unistr2_to_ascii_talloc(ctx, &q_u->uni_share_name); + share_name = talloc_strdup(p->mem_ctx, r->in.share_name); if (!share_name) { - return WERR_NET_NAME_NOT_FOUND; + return WERR_NOMEM; } - r_u->parm_error = 0; + *r->out.parm_error = 0; if ( strequal(share_name,"IPC$") || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) @@ -1619,44 +1621,39 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if ( user.ut.uid != sec_initial_uid() && !is_disk_op ) return WERR_ACCESS_DENIED; - switch (q_u->info_level) { + switch (r->in.level) { case 1: pathname = talloc_strdup(ctx, lp_pathname(snum)); - comment = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info2.info_2_str.uni_remark); - type = q_u->info.share.info2.info_2.type; + comment = talloc_strdup(ctx, info->info2->comment); + type = info->info2->type; psd = NULL; break; case 2: - comment = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info2.info_2_str.uni_remark); - pathname = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info2.info_2_str.uni_path); - type = q_u->info.share.info2.info_2.type; - max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; + comment = talloc_strdup(ctx, info->info2->comment); + pathname = info->info2->path; + type = info->info2->type; + max_connections = (info->info2->max_users == 0xffffffff) ? + 0 : info->info2->max_users; psd = NULL; break; #if 0 /* not supported on set but here for completeness */ case 501: - unistr2_to_ascii(comment, &q_u->info.share.info501.info_501_str.uni_remark, sizeof(comment)); - type = q_u->info.share.info501.info_501.type; + comment = talloc_strdup(ctx, info->info501->comment); + type = info->info501->type; psd = NULL; break; #endif case 502: - comment = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info502.info_502_str.uni_remark); - pathname = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info502.info_502_str.uni_path); - type = q_u->info.share.info502.info_502.type; - psd = q_u->info.share.info502.info_502_str.sd; + comment = talloc_strdup(ctx, info->info502->comment); + pathname = info->info502->path; + type = info->info502->type; + psd = info->info502->sd; map_generic_share_sd_bits(psd); break; case 1004: pathname = talloc_strdup(ctx, lp_pathname(snum)); - comment = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info1004.info_1004_str.uni_remark); + comment = talloc_strdup(ctx, info->info1004->comment); type = STYPE_DISKTREE; break; case 1005: @@ -1664,12 +1661,12 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S user, so we must compare it to see if it's what is set in smb.conf, so that we can contine other ops like setting ACLs on a share */ - if (((q_u->info.share.info1005.share_info_flags & + if (((info->info1005->dfs_flags & SHARE_1005_CSC_POLICY_MASK) >> SHARE_1005_CSC_POLICY_SHIFT) == lp_csc_policy(snum)) return WERR_OK; else { - DEBUG(3, ("_srv_net_share_set_info: client is trying to change csc policy from the network; must be done with smb.conf\n")); + DEBUG(3, ("_srvsvc_NetShareSetInfo: client is trying to change csc policy from the network; must be done with smb.conf\n")); return WERR_ACCESS_DENIED; } case 1006: @@ -1678,12 +1675,13 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S case 1501: pathname = talloc_strdup(ctx, lp_pathname(snum)); comment = talloc_strdup(ctx, lp_comment(snum)); - psd = q_u->info.share.info1501.sdb->sd; + psd = info->info1501->sd; map_generic_share_sd_bits(psd); type = STYPE_DISKTREE; break; default: - DEBUG(5,("_srv_net_share_set_info: unsupported switch value %d\n", q_u->info_level)); + DEBUG(5,("_srvsvc_NetShareSetInfo: unsupported switch value %d\n", + r->in.level)); return WERR_UNKNOWN_LEVEL; } @@ -1702,7 +1700,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S string_replace(comment, '"', ' '); } - DEBUG(10,("_srv_net_share_set_info: change share command = %s\n", + DEBUG(10,("_srvsvc_NetShareSetInfo: change share command = %s\n", lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" )); /* Only call modify function if something changed. */ @@ -1710,7 +1708,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) || (lp_max_connections(snum) != max_connections)) { if (!lp_change_share_cmd() || !*lp_change_share_cmd()) { - DEBUG(10,("_srv_net_share_set_info: No change share command\n")); + DEBUG(10,("_srvsvc_NetShareSetInfo: No change share command\n")); return WERR_ACCESS_DENIED; } @@ -1726,7 +1724,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S return WERR_NOMEM; } - DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command )); + DEBUG(10,("_srvsvc_NetShareSetInfo: Running [%s]\n", command )); /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ @@ -1745,14 +1743,16 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S /********* END SeDiskOperatorPrivilege BLOCK *********/ - DEBUG(3,("_srv_net_share_set_info: Running [%s] returned (%d)\n", command, ret )); + DEBUG(3,("_srvsvc_NetShareSetInfo: Running [%s] returned (%d)\n", + command, ret )); TALLOC_FREE(command); if ( ret != 0 ) return WERR_ACCESS_DENIED; } else { - DEBUG(10,("_srv_net_share_set_info: No change to share name (%s)\n", share_name )); + DEBUG(10,("_srvsvc_NetShareSetInfo: No change to share name (%s)\n", + share_name )); } /* Replace SD if changed. */ @@ -1764,12 +1764,12 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S if (old_sd && !sec_desc_equal(old_sd, psd)) { if (!set_share_security(share_name, psd)) - DEBUG(0,("_srv_net_share_set_info: Failed to change security info in share %s.\n", + DEBUG(0,("_srvsvc_NetShareSetInfo: Failed to change security info in share %s.\n", share_name )); } } - DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetShareSetInfo: %d\n", __LINE__)); return WERR_OK; } @@ -2549,12 +2549,6 @@ WERROR _srvsvc_NetShareGetInfo(pipes_struct *p, struct srvsvc_NetShareGetInfo *r return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, struct srvsvc_NetShareSetInfo *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetShareDel(pipes_struct *p, struct srvsvc_NetShareDel *r) { p->rng_fault_state = True; -- cgit From 78b20443c587d303aa33f594c746c38e2689004d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 5 Mar 2008 10:34:45 +0100 Subject: Use pidl for _srvsvc_NetRemoteTOD(). Guenther (This used to be commit 2b4e0f0593c6378cdac4811ded830ca694afac9e) --- source3/rpc_server/srv_srvsvc.c | 20 +------------- source3/rpc_server/srv_srvsvc_nt.c | 55 +++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 50 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 0d50bccef0..41fc39baf7 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -369,25 +369,7 @@ static bool api_srv_net_share_del_sticky(pipes_struct *p) static bool api_srv_net_remote_tod(pipes_struct *p) { - SRV_Q_NET_REMOTE_TOD q_u; - SRV_R_NET_REMOTE_TOD r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server get enum */ - if(!srv_io_q_net_remote_tod("", &q_u, data, 0)) - return False; - - r_u.status = _srv_net_remote_tod(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!srv_io_r_net_remote_tod("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETREMOTETOD); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 75c262a7a6..4efea33738 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2054,12 +2054,13 @@ WERROR _srv_net_share_del_sticky(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_ } /******************************************************************* -time of day + _srvsvc_NetRemoteTOD ********************************************************************/ -WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET_REMOTE_TOD *r_u) +WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, + struct srvsvc_NetRemoteTOD *r) { - TIME_OF_DAY_INFO *tod; + struct srvsvc_NetRemoteTODInfo *tod; struct tm *t; time_t unixdate = time(NULL); @@ -2068,37 +2069,35 @@ WERROR _srv_net_remote_tod(pipes_struct *p, SRV_Q_NET_REMOTE_TOD *q_u, SRV_R_NET uint32 zone = get_time_zone(unixdate)/60; - DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__)); - if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, TIME_OF_DAY_INFO)) ) + if ( !(tod = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetRemoteTODInfo)) ) return WERR_NOMEM; - r_u->tod = tod; - r_u->ptr_srv_tod = 0x1; - r_u->status = WERR_OK; + *r->out.info = tod; - DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__)); t = gmtime(&unixdate); /* set up the */ - init_time_of_day_info(tod, - unixdate, - 0, - t->tm_hour, - t->tm_min, - t->tm_sec, - 0, - zone, - 10000, - t->tm_mday, - t->tm_mon + 1, - 1900+t->tm_year, - t->tm_wday); - - DEBUG(5,("_srv_net_remote_tod: %d\n", __LINE__)); + init_srvsvc_NetRemoteTODInfo(tod, + unixdate, + 0, + t->tm_hour, + t->tm_min, + t->tm_sec, + 0, + zone, + 10000, + t->tm_mday, + t->tm_mon + 1, + 1900+t->tm_year, + t->tm_wday); - return r_u->status; + DEBUG(5,("_srvsvc_NetRemoteTOD: %d\n", __LINE__)); + + return WERR_OK; } /*********************************************************************************** @@ -2597,12 +2596,6 @@ WERROR _srvsvc_NetTransportDel(pipes_struct *p, struct srvsvc_NetTransportDel *r return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, struct srvsvc_NetRemoteTOD *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetSetServiceBits(pipes_struct *p, struct srvsvc_NetSetServiceBits *r) { p->rng_fault_state = True; -- cgit From 932c287a406048759fa1ac4bf86e29d96991ded1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 5 Mar 2008 17:20:01 +0100 Subject: Fix Coverity ID 565 This would crash safely (This used to be commit 0f14357c86aee9a76ffbb45ea6419f4cc4106d62) --- source3/rpc_server/srv_winreg_nt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 7ff93e0b07..c76bc19d9c 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -508,8 +508,6 @@ WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, struct winreg_InitiateS /* pull the message string and perform necessary sanity checks on it */ - chkmsg[0] = '\0'; - if ( r->in.message && r->in.message->name && r->in.message->name->name ) { if ( (msg = talloc_strdup(p->mem_ctx, r->in.message->name->name )) == NULL ) { return WERR_NOMEM; -- cgit From ffd88c35db3c01c9d6c433e9ee4cda80d85b6527 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 6 Mar 2008 20:44:28 +0100 Subject: Fix _dssetup_DsRoleGetPrimaryDomainInformation(). Guenther (This used to be commit 5eb7b7a9db4bda40660df5ab67bfea99e75716f9) --- source3/rpc_server/srv_dssetup_nt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dssetup_nt.c b/source3/rpc_server/srv_dssetup_nt.c index ea535a3375..2b18e6b2ae 100644 --- a/source3/rpc_server/srv_dssetup_nt.c +++ b/source3/rpc_server/srv_dssetup_nt.c @@ -35,7 +35,7 @@ static WERROR fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, struct dssetup_DsRolePrimaryDomInfoBasic **info) { struct dssetup_DsRolePrimaryDomInfoBasic *basic = NULL; - fstring dnsdomain; + char *dnsdomain = NULL; DEBUG(10,("fill_dsrole_dominfo_basic: enter\n")); @@ -71,7 +71,10 @@ static WERROR fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, /* fill in some additional fields if we are a member of an AD domain */ if (lp_security() == SEC_ADS) { - fstrcpy(dnsdomain, lp_realm()); + dnsdomain = talloc_strdup(ctx, lp_realm()); + if (!dnsdomain) { + return WERR_NOMEM; + } strlower_m(dnsdomain); basic->dns_domain = dnsdomain; -- cgit From 3279d3110f1f4aaf6c26b304e20dfbe4c2daf4ee Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 6 Mar 2008 23:23:08 +0100 Subject: Fix debug statement (missing \n). Guenther (This used to be commit 5895b973a4e7067535aff6e0c9a7273e332dee1a) --- source3/rpc_server/srv_svcctl_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 73d09b1bbb..3962626e27 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -188,7 +188,7 @@ static SERVICE_INFO *find_service_info_by_hnd(pipes_struct *p, POLICY_HND *hnd) SERVICE_INFO *service_info = NULL; if( !find_policy_by_hnd( p, hnd, (void **)(void *)&service_info) ) { - DEBUG(2,("find_service_info_by_hnd: handle not found")); + DEBUG(2,("find_service_info_by_hnd: handle not found\n")); return NULL; } -- cgit From 7b75317989e8a5fc46130151f94543009626203b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 7 Mar 2008 16:19:43 +0100 Subject: Use pidl for _srvsvc_NetShareGetInfo, _srvsvc_NetShareEnum and srvsvc_NetShareEnumAll. Fixing resume handling while we are there. Guenther (This used to be commit 128637bdd7c37ca166a7d478b33b00c39f0ede62) --- source3/rpc_server/srv_srvsvc.c | 69 +---- source3/rpc_server/srv_srvsvc_nt.c | 599 ++++++++++++++++--------------------- 2 files changed, 269 insertions(+), 399 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 41fc39baf7..39548c5af3 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -180,28 +180,7 @@ static bool api_srv_net_sess_del(pipes_struct *p) static bool api_srv_net_share_enum_all(pipes_struct *p) { - SRV_Q_NET_SHARE_ENUM q_u; - SRV_R_NET_SHARE_ENUM r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server get enum. */ - if(!srv_io_q_net_share_enum("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_enum_all: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n")); - return False; - } - - r_u.status = _srv_net_share_enum_all(p, &q_u, &r_u); - - if (!srv_io_r_net_share_enum("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_enum_all: Failed to marshall SRV_R_NET_SHARE_ENUM.\n")); - return False; - } - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHAREENUMALL); } /******************************************************************* @@ -210,28 +189,7 @@ static bool api_srv_net_share_enum_all(pipes_struct *p) static bool api_srv_net_share_enum(pipes_struct *p) { - SRV_Q_NET_SHARE_ENUM q_u; - SRV_R_NET_SHARE_ENUM r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server get enum. */ - if(!srv_io_q_net_share_enum("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_enum: Failed to unmarshall SRV_Q_NET_SHARE_ENUM.\n")); - return False; - } - - r_u.status = _srv_net_share_enum(p, &q_u, &r_u); - - if (!srv_io_r_net_share_enum("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_enum: Failed to marshall SRV_R_NET_SHARE_ENUM.\n")); - return False; - } - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHAREENUM); } /******************************************************************* @@ -240,28 +198,7 @@ static bool api_srv_net_share_enum(pipes_struct *p) static bool api_srv_net_share_get_info(pipes_struct *p) { - SRV_Q_NET_SHARE_GET_INFO q_u; - SRV_R_NET_SHARE_GET_INFO r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server get info. */ - if(!srv_io_q_net_share_get_info("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_get_info: Failed to unmarshall SRV_Q_NET_SHARE_GET_INFO.\n")); - return False; - } - - r_u.status = _srv_net_share_get_info(p, &q_u, &r_u); - - if(!srv_io_r_net_share_get_info("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_get_info: Failed to marshall SRV_R_NET_SHARE_GET_INFO.\n")); - return False; - } - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHAREGETINFO); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 4efea33738..3c5d1e4154 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -242,19 +242,18 @@ static uint32 get_share_type(int snum) Fill in a share info level 0 structure. ********************************************************************/ -static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int snum) +static void init_srv_share_info_0(pipes_struct *p, struct srvsvc_NetShareInfo0 *r, int snum) { const char *net_name = lp_servicename(snum); - init_srv_share_info0(&sh0->info_0, net_name); - init_srv_share_info0_str(&sh0->info_0_str, net_name); + init_srvsvc_NetShareInfo0(r, net_name); } /******************************************************************* Fill in a share info level 1 structure. ********************************************************************/ -static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum) +static void init_srv_share_info_1(pipes_struct *p, struct srvsvc_NetShareInfo1 *r, int snum) { char *net_name = lp_servicename(snum); char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum)); @@ -265,20 +264,16 @@ static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int sn remark); } - init_srv_share_info1(&sh1->info_1, - net_name, - get_share_type(snum), - remark ? remark: ""); - init_srv_share_info1_str(&sh1->info_1_str, - net_name, - remark ? remark: ""); + init_srvsvc_NetShareInfo1(r, net_name, + get_share_type(snum), + remark ? remark : ""); } /******************************************************************* Fill in a share info level 2 structure. ********************************************************************/ -static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int snum) +static void init_srv_share_info_2(pipes_struct *p, struct srvsvc_NetShareInfo2 *r, int snum) { char *remark = NULL; char *path = NULL; @@ -307,21 +302,15 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int sn } count = count_current_connections(net_name, false); - init_srv_share_info2(&sh2->info_2, - net_name, - get_share_type(snum), - remark ? remark : "", - 0, - max_uses, - count, - path ? path : "", - ""); - - init_srv_share_info2_str(&sh2->info_2_str, - net_name, - remark ? remark : "", - path ? path : "", - ""); + + init_srvsvc_NetShareInfo2(r, net_name, + get_share_type(snum), + remark ? remark : "", + 0, + max_uses, + count, + path ? path : "", + ""); } /******************************************************************* @@ -353,7 +342,7 @@ static void map_generic_share_sd_bits(SEC_DESC *psd) Fill in a share info level 501 structure. ********************************************************************/ -static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum) +static void init_srv_share_info_501(pipes_struct *p, struct srvsvc_NetShareInfo501 *r, int snum) { const char *net_name = lp_servicename(snum); char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum)); @@ -362,17 +351,17 @@ static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, remark = standard_sub_conn(p->mem_ctx, p->conn, remark); } - init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), - remark ? remark : "", (lp_csc_policy(snum) << 4)); - init_srv_share_info501_str(&sh501->info_501_str, - net_name, remark ? remark : ""); + init_srvsvc_NetShareInfo501(r, net_name, + get_share_type(snum), + remark ? remark : "", + (lp_csc_policy(snum) << 4)); } /******************************************************************* Fill in a share info level 502 structure. ********************************************************************/ -static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, int snum) +static void init_srv_share_info_502(pipes_struct *p, struct srvsvc_NetShareInfo502 *r, int snum) { const char *net_name = lp_servicename(snum); char *path = NULL; @@ -381,8 +370,6 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, TALLOC_CTX *ctx = p->mem_ctx; char *remark = talloc_strdup(ctx, lp_comment(snum));; - ZERO_STRUCTP(sh502); - if (remark) { remark = standard_sub_conn(ctx, p->conn, remark); } @@ -397,31 +384,23 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, sd = get_share_security(ctx, lp_servicename(snum), &sd_size); - init_srv_share_info502(&sh502->info_502, - net_name, - get_share_type(snum), - remark ? remark : "", - 0, - 0xffffffff, - 1, - path ? path : "", - "", - sd, - sd_size); - init_srv_share_info502_str(&sh502->info_502_str, - net_name, - remark ? remark : "", - path ? path : "", - "", - sd, - sd_size); + init_srvsvc_NetShareInfo502(r, net_name, + get_share_type(snum), + remark ? remark : "", + 0, + 0xffffffff, + 1, + path ? path : "", + "", + 0, + sd); } /*************************************************************************** Fill in a share info level 1004 structure. ***************************************************************************/ -static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh1004, int snum) +static void init_srv_share_info_1004(pipes_struct *p, struct srvsvc_NetShareInfo1004 *r, int snum) { char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum)); @@ -429,65 +408,59 @@ static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh100 remark = standard_sub_conn(p->mem_ctx, p->conn, remark); } - ZERO_STRUCTP(sh1004); - - init_srv_share_info1004(&sh1004->info_1004, remark ? remark : ""); - init_srv_share_info1004_str(&sh1004->info_1004_str, - remark ? remark : ""); + init_srvsvc_NetShareInfo1004(r, remark ? remark : ""); } /*************************************************************************** Fill in a share info level 1005 structure. ***************************************************************************/ -static void init_srv_share_info_1005(pipes_struct *p, SRV_SHARE_INFO_1005* sh1005, int snum) +static void init_srv_share_info_1005(pipes_struct *p, struct srvsvc_NetShareInfo1005 *r, int snum) { - sh1005->share_info_flags = 0; + uint32_t dfs_flags = 0; + + if (lp_host_msdfs() && lp_msdfs_root(snum)) { + dfs_flags |= SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT; + } - if(lp_host_msdfs() && lp_msdfs_root(snum)) - sh1005->share_info_flags |= - SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT; - sh1005->share_info_flags |= - lp_csc_policy(snum) << SHARE_1005_CSC_POLICY_SHIFT; + dfs_flags |= lp_csc_policy(snum) << SHARE_1005_CSC_POLICY_SHIFT; + + init_srvsvc_NetShareInfo1005(r, dfs_flags); } + /*************************************************************************** Fill in a share info level 1006 structure. ***************************************************************************/ -static void init_srv_share_info_1006(pipes_struct *p, SRV_SHARE_INFO_1006* sh1006, int snum) +static void init_srv_share_info_1006(pipes_struct *p, struct srvsvc_NetShareInfo1006 *r, int snum) { - sh1006->max_uses = -1; + init_srvsvc_NetShareInfo1006(r, 0xffffffff); } /*************************************************************************** Fill in a share info level 1007 structure. ***************************************************************************/ -static void init_srv_share_info_1007(pipes_struct *p, SRV_SHARE_INFO_1007* sh1007, int snum) +static void init_srv_share_info_1007(pipes_struct *p, struct srvsvc_NetShareInfo1007 *r, int snum) { uint32 flags = 0; - ZERO_STRUCTP(sh1007); - - init_srv_share_info1007(&sh1007->info_1007, flags, ""); - init_srv_share_info1007_str(&sh1007->info_1007_str, ""); + init_srvsvc_NetShareInfo1007(r, flags, ""); } /******************************************************************* Fill in a share info level 1501 structure. ********************************************************************/ -static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh1501, int snum) +static void init_srv_share_info_1501(pipes_struct *p, struct sec_desc_buf *r, int snum) { SEC_DESC *sd; size_t sd_size; TALLOC_CTX *ctx = p->mem_ctx; - ZERO_STRUCTP(sh1501); - sd = get_share_security(ctx, lp_servicename(snum), &sd_size); - sh1501->sdb = make_sec_desc_buf(p->mem_ctx, sd_size, sd); + r = make_sec_desc_buf(p->mem_ctx, sd_size, sd); } /******************************************************************* @@ -505,21 +478,24 @@ static bool is_hidden_share(int snum) Fill in a share info structure. ********************************************************************/ -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) +static WERROR init_srv_share_info_ctr(pipes_struct *p, + struct srvsvc_NetShareInfoCtr *info_ctr, + uint32_t *resume_handle_p, + uint32_t *total_entries, + bool all_shares) { int num_entries = 0; + int alloc_entries = 0; int num_services = 0; int snum; TALLOC_CTX *ctx = p->mem_ctx; + int i = 0; + int valid_share_count = 0; + union srvsvc_NetShareCtr ctr; + uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0; DEBUG(5,("init_srv_share_info_ctr\n")); - ZERO_STRUCTPN(ctr); - - ctr->info_level = ctr->switch_value = info_level; - *resume_hnd = 0; - /* Ensure all the usershares are loaded. */ become_root(); num_services = load_usershare_shares(); @@ -528,300 +504,202 @@ static bool init_srv_share_info_ctr(pipes_struct *p, SRV_SHARE_INFO_CTR *ctr, /* Count the number of entries. */ for (snum = 0; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { num_entries++; + } } - *total_entries = num_entries; - ctr->num_entries2 = ctr->num_entries = num_entries; - ctr->ptr_share_info = ctr->ptr_entries = 1; - - if (!num_entries) - return True; + if (!num_entries || (resume_handle >= num_entries)) { + return WERR_OK; + } - switch (info_level) { + /* Calculate alloc entries. */ + alloc_entries = num_entries - resume_handle; + switch (info_ctr->level) { case 0: - { - SRV_SHARE_INFO_0 *info0 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_0, num_entries); - int i = 0; + ctr.ctr0 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr0); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr0); - if (!info0) { - return False; - } + ctr.ctr0->count = alloc_entries; + ctr.ctr0->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo0, alloc_entries); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr0->array); - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_0(p, &info0[i++], snum); + for (snum = 0; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) && + (resume_handle <= (i + valid_share_count++)) ) { + init_srv_share_info_0(p, &ctr.ctr0->array[i++], snum); } } - ctr->share.info0 = info0; break; - } - case 1: - { - SRV_SHARE_INFO_1 *info1 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1, num_entries); - int i = 0; + ctr.ctr1 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr1); - if (!info1) { - return False; - } + ctr.ctr1->count = alloc_entries; + ctr.ctr1->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1, alloc_entries); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr1->array); - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_1(p, &info1[i++], snum); + for (snum = 0; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) && + (resume_handle <= (i + valid_share_count++)) ) { + init_srv_share_info_1(p, &ctr.ctr1->array[i++], snum); } } - ctr->share.info1 = info1; break; - } case 2: - { - SRV_SHARE_INFO_2 *info2 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_2, num_entries); - int i = 0; + ctr.ctr2 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr2); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr2); - if (!info2) { - return False; - } + ctr.ctr2->count = alloc_entries; + ctr.ctr2->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo2, alloc_entries); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr2->array); - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_2(p, &info2[i++], snum); + for (snum = 0; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) && + (resume_handle <= (i + valid_share_count++)) ) { + init_srv_share_info_2(p, &ctr.ctr2->array[i++], snum); } } - ctr->share.info2 = info2; break; - } case 501: - { - SRV_SHARE_INFO_501 *info501 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_501, num_entries); - int i = 0; + ctr.ctr501 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr501); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr501); - if (!info501) { - return False; - } + ctr.ctr501->count = alloc_entries; + ctr.ctr501->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo501, alloc_entries); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr501->array); - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_501(p, &info501[i++], snum); + for (snum = 0; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) && + (resume_handle <= (i + valid_share_count++)) ) { + init_srv_share_info_501(p, &ctr.ctr501->array[i++], snum); } } - ctr->share.info501 = info501; break; - } case 502: - { - SRV_SHARE_INFO_502 *info502 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_502, num_entries); - int i = 0; + ctr.ctr502 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr502); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr502); - if (!info502) { - return False; - } + ctr.ctr502->count = alloc_entries; + ctr.ctr502->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo502, alloc_entries); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr502->array); - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_502(p, &info502[i++], snum); + for (snum = 0; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) && + (resume_handle <= (i + valid_share_count++)) ) { + init_srv_share_info_502(p, &ctr.ctr502->array[i++], snum); } } - ctr->share.info502 = info502; break; - } - - /* here for completeness but not currently used with enum (1004 - 1501)*/ case 1004: - { - SRV_SHARE_INFO_1004 *info1004 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1004, num_entries); - int i = 0; + ctr.ctr1004 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1004); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr1004); - if (!info1004) { - return False; - } + ctr.ctr1004->count = alloc_entries; + ctr.ctr1004->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1004, alloc_entries); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr1004->array); - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_1004(p, &info1004[i++], snum); + for (snum = 0; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) && + (resume_handle <= (i + valid_share_count++)) ) { + init_srv_share_info_1004(p, &ctr.ctr1004->array[i++], snum); } } - ctr->share.info1004 = info1004; break; - } case 1005: - { - SRV_SHARE_INFO_1005 *info1005 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1005, num_entries); - int i = 0; + ctr.ctr1005 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1005); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr1005); - if (!info1005) { - return False; - } + ctr.ctr1005->count = alloc_entries; + ctr.ctr1005->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1005, alloc_entries); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr1005->array); - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_1005(p, &info1005[i++], snum); + for (snum = 0; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) && + (resume_handle <= (i + valid_share_count++)) ) { + init_srv_share_info_1005(p, &ctr.ctr1005->array[i++], snum); } } - ctr->share.info1005 = info1005; break; - } case 1006: - { - SRV_SHARE_INFO_1006 *info1006 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1006, num_entries); - int i = 0; + ctr.ctr1006 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1006); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr1006); - if (!info1006) { - return False; - } + ctr.ctr1006->count = alloc_entries; + ctr.ctr1006->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1006, alloc_entries); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr1006->array); - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_1006(p, &info1006[i++], snum); + for (snum = 0; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) && + (resume_handle <= (i + valid_share_count++)) ) { + init_srv_share_info_1006(p, &ctr.ctr1006->array[i++], snum); } } - ctr->share.info1006 = info1006; break; - } case 1007: - { - SRV_SHARE_INFO_1007 *info1007 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1007, num_entries); - int i = 0; + ctr.ctr1007 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1007); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr1007); - if (!info1007) { - return False; - } + ctr.ctr1007->count = alloc_entries; + ctr.ctr1007->array = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetShareInfo1007, alloc_entries); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr1007->array); - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_1007(p, &info1007[i++], snum); + for (snum = 0; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) && + (resume_handle <= (i + valid_share_count++)) ) { + init_srv_share_info_1007(p, &ctr.ctr1007->array[i++], snum); } } - ctr->share.info1007 = info1007; break; - } case 1501: - { - SRV_SHARE_INFO_1501 *info1501 = TALLOC_ARRAY(ctx, SRV_SHARE_INFO_1501, num_entries); - int i = 0; + ctr.ctr1501 = TALLOC_ZERO_P(ctx, struct srvsvc_NetShareCtr1501); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr1501); - if (!info1501) { - return False; - } + ctr.ctr1501->count = alloc_entries; + ctr.ctr1501->array = TALLOC_ZERO_ARRAY(ctx, struct sec_desc_buf, alloc_entries); + W_ERROR_HAVE_NO_MEMORY(ctr.ctr1501->array); - for (snum = *resume_hnd; snum < num_services; snum++) { - if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { - init_srv_share_info_1501(p, &info1501[i++], snum); + for (snum = 0; snum < num_services; snum++) { + if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) && + (resume_handle <= (i + valid_share_count++)) ) { + init_srv_share_info_1501(p, &ctr.ctr1501->array[i++], snum); } } - ctr->share.info1501 = info1501; break; - } + default: - DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level)); - return False; + DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", + info_ctr->level)); + return WERR_UNKNOWN_LEVEL; } - return True; -} - -/******************************************************************* - Inits a SRV_R_NET_SHARE_ENUM structure. -********************************************************************/ - -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(p, &r_n->ctr, info_level, - &resume_hnd, &r_n->total_entries, all)) { - r_n->status = WERR_OK; - } else { - r_n->status = WERR_UNKNOWN_LEVEL; + *total_entries = alloc_entries; + if (resume_handle_p) { + *resume_handle_p = num_entries; } - init_enum_hnd(&r_n->enum_hnd, resume_hnd); -} + info_ctr->ctr = ctr; -/******************************************************************* - Inits a SRV_R_NET_SHARE_GET_INFO structure. -********************************************************************/ - -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) -{ - WERROR status = WERR_OK; - int snum; - - DEBUG(5,("init_srv_r_net_share_get_info: %d\n", __LINE__)); - - r_n->info.switch_value = info_level; - - snum = find_service(share_name); - - if (snum >= 0) { - switch (info_level) { - case 0: - init_srv_share_info_0(p, &r_n->info.share.info0, snum); - break; - case 1: - init_srv_share_info_1(p, &r_n->info.share.info1, snum); - break; - case 2: - init_srv_share_info_2(p, &r_n->info.share.info2, snum); - break; - case 501: - init_srv_share_info_501(p, &r_n->info.share.info501, snum); - break; - case 502: - init_srv_share_info_502(p, &r_n->info.share.info502, snum); - break; - - /* here for completeness */ - case 1004: - init_srv_share_info_1004(p, &r_n->info.share.info1004, snum); - break; - case 1005: - init_srv_share_info_1005(p, &r_n->info.share.info1005, snum); - break; - - /* here for completeness 1006 - 1501 */ - case 1006: - init_srv_share_info_1006(p, &r_n->info.share.info1006, snum); - break; - case 1007: - init_srv_share_info_1007(p, &r_n->info.share.info1007, snum); - break; - case 1501: - init_srv_share_info_1501(p, &r_n->info.share.info1501, snum); - break; - default: - DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level)); - status = WERR_UNKNOWN_LEVEL; - break; - } - } else { - status = WERR_INVALID_NAME; - } - - r_n->info.ptr_share_ctr = W_ERROR_IS_OK(status) ? 1 : 0; - r_n->status = status; + return WERR_OK; } /******************************************************************* @@ -1465,68 +1343,141 @@ done: } /******************************************************************* - Net share enum all. + _srvsvc_NetShareEnumAll ********************************************************************/ -WERROR _srv_net_share_enum_all(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) +WERROR _srvsvc_NetShareEnumAll(pipes_struct *p, + struct srvsvc_NetShareEnumAll *r) { - DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); + WERROR werr; + + DEBUG(5,("_srvsvc_NetShareEnumAll: %d\n", __LINE__)); if (!pipe_access_check(p)) { - DEBUG(3, ("access denied to srv_net_share_enum_all\n")); + DEBUG(3, ("access denied to _srvsvc_NetShareEnumAll\n")); return WERR_ACCESS_DENIED; } /* Create the list of shares for the response. */ - init_srv_r_net_share_enum(p, r_u, - q_u->ctr.info_level, - get_enum_hnd(&q_u->enum_hnd), True); + werr = init_srv_share_info_ctr(p, + r->in.info_ctr, + r->in.resume_handle, + r->out.totalentries, + true); - DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetShareEnumAll: %d\n", __LINE__)); - return r_u->status; + return werr; } /******************************************************************* - Net share enum. + _srvsvc_NetShareEnum ********************************************************************/ -WERROR _srv_net_share_enum(pipes_struct *p, SRV_Q_NET_SHARE_ENUM *q_u, SRV_R_NET_SHARE_ENUM *r_u) +WERROR _srvsvc_NetShareEnum(pipes_struct *p, + struct srvsvc_NetShareEnum *r) { - DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); + WERROR werr; + + DEBUG(5,("_srvsvc_NetShareEnum: %d\n", __LINE__)); if (!pipe_access_check(p)) { - DEBUG(3, ("access denied to srv_net_share_enum\n")); + DEBUG(3, ("access denied to _srvsvc_NetShareEnum\n")); return WERR_ACCESS_DENIED; } /* Create the list of shares for the response. */ - init_srv_r_net_share_enum(p, r_u, - q_u->ctr.info_level, - get_enum_hnd(&q_u->enum_hnd), False); + werr = init_srv_share_info_ctr(p, + r->in.info_ctr, + r->in.resume_handle, + r->out.totalentries, + false); - DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetShareEnum: %d\n", __LINE__)); - return r_u->status; + return werr; } /******************************************************************* - Net share get info. + _srvsvc_NetShareGetInfo ********************************************************************/ -WERROR _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, SRV_R_NET_SHARE_GET_INFO *r_u) +WERROR _srvsvc_NetShareGetInfo(pipes_struct *p, + struct srvsvc_NetShareGetInfo *r) { + WERROR status = WERR_OK; fstring share_name; + int snum; + union srvsvc_NetShareInfo *info = r->out.info; - DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetShareGetInfo: %d\n", __LINE__)); - /* 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, r_u, share_name, q_u->info_level); + fstrcpy(share_name, r->in.share_name); - DEBUG(5,("_srv_net_share_get_info: %d\n", __LINE__)); + snum = find_service(share_name); + if (snum < 0) { + return WERR_INVALID_NAME; + } - return r_u->status; + switch (r->in.level) { + case 0: + info->info0 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo0); + W_ERROR_HAVE_NO_MEMORY(info->info0); + init_srv_share_info_0(p, info->info0, snum); + break; + case 1: + info->info1 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1); + W_ERROR_HAVE_NO_MEMORY(info->info1); + init_srv_share_info_1(p, info->info1, snum); + break; + case 2: + info->info2 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo2); + W_ERROR_HAVE_NO_MEMORY(info->info2); + init_srv_share_info_2(p, info->info2, snum); + break; + case 501: + info->info501 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo501); + W_ERROR_HAVE_NO_MEMORY(info->info501); + init_srv_share_info_501(p, info->info501, snum); + break; + case 502: + info->info502 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo502); + W_ERROR_HAVE_NO_MEMORY(info->info502); + init_srv_share_info_502(p, info->info502, snum); + break; + case 1004: + info->info1004 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1004); + W_ERROR_HAVE_NO_MEMORY(info->info1004); + init_srv_share_info_1004(p, info->info1004, snum); + break; + case 1005: + info->info1005 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1005); + W_ERROR_HAVE_NO_MEMORY(info->info1005); + init_srv_share_info_1005(p, info->info1005, snum); + break; + case 1006: + info->info1006 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1006); + W_ERROR_HAVE_NO_MEMORY(info->info1006); + init_srv_share_info_1006(p, info->info1006, snum); + break; + case 1007: + info->info1007 = TALLOC_P(p->mem_ctx, struct srvsvc_NetShareInfo1007); + W_ERROR_HAVE_NO_MEMORY(info->info1007); + init_srv_share_info_1007(p, info->info1007, snum); + break; + case 1501: + init_srv_share_info_1501(p, info->info1501, snum); + break; + default: + DEBUG(5,("_srvsvc_NetShareGetInfo: unsupported switch value %d\n", + r->in.level)); + status = WERR_UNKNOWN_LEVEL; + break; + } + + DEBUG(5,("_srvsvc_NetShareGetInfo: %d\n", __LINE__)); + + return status; } /******************************************************************* @@ -2536,18 +2487,6 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r) return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetShareEnumAll(pipes_struct *p, struct srvsvc_NetShareEnumAll *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - -WERROR _srvsvc_NetShareGetInfo(pipes_struct *p, struct srvsvc_NetShareGetInfo *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetShareDel(pipes_struct *p, struct srvsvc_NetShareDel *r) { p->rng_fault_state = True; @@ -2638,12 +2577,6 @@ WERROR _srvsvc_NetPRNameCompare(pipes_struct *p, struct srvsvc_NetPRNameCompare return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetShareEnum(pipes_struct *p, struct srvsvc_NetShareEnum *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetShareDelStart(pipes_struct *p, struct srvsvc_NetShareDelStart *r) { p->rng_fault_state = True; -- cgit From ad3a1b8475bc850578f0ee6a71747b204066340e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 7 Mar 2008 23:26:00 +0100 Subject: Use pidl for _srvsvc_NetShareDel and _srvsvc_NetShareDelSticky. Guenther (This used to be commit 73b6587493d9a987a691ece495db9f42ce562efe) --- source3/rpc_server/srv_srvsvc.c | 46 ++------------------------------------ source3/rpc_server/srv_srvsvc_nt.c | 46 +++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 67 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 39548c5af3..875cda50f9 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -246,28 +246,7 @@ static bool api_srv_net_share_add(pipes_struct *p) static bool api_srv_net_share_del(pipes_struct *p) { - SRV_Q_NET_SHARE_DEL q_u; - SRV_R_NET_SHARE_DEL r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server del info. */ - if(!srv_io_q_net_share_del("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_del: Failed to unmarshall SRV_Q_NET_SHARE_DEL.\n")); - return False; - } - - r_u.status = _srv_net_share_del(p, &q_u, &r_u); - - if(!srv_io_r_net_share_del("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_del: Failed to marshall SRV_R_NET_SHARE_DEL.\n")); - return False; - } - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHAREDEL); } /******************************************************************* @@ -276,28 +255,7 @@ static bool api_srv_net_share_del(pipes_struct *p) static bool api_srv_net_share_del_sticky(pipes_struct *p) { - SRV_Q_NET_SHARE_DEL q_u; - SRV_R_NET_SHARE_DEL r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server del info. */ - if(!srv_io_q_net_share_del("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_del_sticky: Failed to unmarshall SRV_Q_NET_SHARE_DEL.\n")); - return False; - } - - r_u.status = _srv_net_share_del_sticky(p, &q_u, &r_u); - - if(!srv_io_r_net_share_del("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_del_sticky: Failed to marshall SRV_R_NET_SHARE_DEL.\n")); - return False; - } - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHAREDELSTICKY); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 3c5d1e4154..a6cf06caa7 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1905,11 +1905,13 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S } /******************************************************************* - Net share delete. Call "delete share command" with the share name as + _srvsvc_NetShareDel + Call "delete share command" with the share name as a parameter. ********************************************************************/ -WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) +WERROR _srvsvc_NetShareDel(pipes_struct *p, + struct srvsvc_NetShareDel *r) { struct current_user user; char *command = NULL; @@ -1921,10 +1923,9 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S struct share_params *params; TALLOC_CTX *ctx = p->mem_ctx; - DEBUG(5,("_srv_net_share_del: %d\n", __LINE__)); - - share_name = unistr2_to_ascii_talloc(ctx, &q_u->uni_share_name); + DEBUG(5,("_srvsvc_NetShareDel: %d\n", __LINE__)); + share_name = talloc_strdup(p->mem_ctx, r->in.share_name); if (!share_name) { return WERR_NET_NAME_NOT_FOUND; } @@ -1953,7 +1954,7 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S return WERR_ACCESS_DENIED; if (!lp_delete_share_cmd() || !*lp_delete_share_cmd()) { - DEBUG(10,("_srv_net_share_del: No delete share command\n")); + DEBUG(10,("_srvsvc_NetShareDel: No delete share command\n")); return WERR_ACCESS_DENIED; } @@ -1966,7 +1967,7 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S return WERR_NOMEM; } - DEBUG(10,("_srv_net_share_del: Running [%s]\n", command )); + DEBUG(10,("_srvsvc_NetShareDel: Running [%s]\n", command )); /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ @@ -1984,7 +1985,7 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S /********* END SeDiskOperatorPrivilege BLOCK *********/ - DEBUG(3,("_srv_net_share_del: Running [%s] returned (%d)\n", command, ret )); + DEBUG(3,("_srvsvc_NetShareDel: Running [%s] returned (%d)\n", command, ret )); if ( ret != 0 ) return WERR_ACCESS_DENIED; @@ -1997,11 +1998,22 @@ WERROR _srv_net_share_del(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_S return WERR_OK; } -WERROR _srv_net_share_del_sticky(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u) +/******************************************************************* + _srvsvc_NetShareDelSticky +********************************************************************/ + +WERROR _srvsvc_NetShareDelSticky(pipes_struct *p, + struct srvsvc_NetShareDelSticky *r) { - DEBUG(5,("_srv_net_share_del_stick: %d\n", __LINE__)); + struct srvsvc_NetShareDel q; - return _srv_net_share_del(p, q_u, r_u); + DEBUG(5,("_srvsvc_NetShareDelSticky: %d\n", __LINE__)); + + q.in.server_unc = r->in.server_unc; + q.in.share_name = r->in.share_name; + q.in.reserved = r->in.reserved; + + return _srvsvc_NetShareDel(p, &q); } /******************************************************************* @@ -2487,18 +2499,6 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r) return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetShareDel(pipes_struct *p, struct srvsvc_NetShareDel *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - -WERROR _srvsvc_NetShareDelSticky(pipes_struct *p, struct srvsvc_NetShareDelSticky *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetShareCheck(pipes_struct *p, struct srvsvc_NetShareCheck *r) { p->rng_fault_state = True; -- cgit From 9beec265bcc81261bd220b78396cc42e6ee5eb5d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 7 Mar 2008 23:40:00 +0100 Subject: Use pidl for _srvsvc_NetNameValidate. Guenther (This used to be commit 2e1df306785296979ea064006402254e318e946b) --- source3/rpc_server/srv_srvsvc.c | 25 ++----------------------- source3/rpc_server/srv_srvsvc_nt.c | 23 +++++++++-------------- 2 files changed, 11 insertions(+), 37 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 875cda50f9..8853295608 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -301,30 +301,9 @@ static bool api_srv_net_disk_enum(pipes_struct *p) NetValidateName (opnum 0x21) *******************************************************************/ -static bool api_srv_net_name_validate(pipes_struct *p) +static bool api_srv_net_name_validate(pipes_struct *p) { - SRV_Q_NET_NAME_VALIDATE q_u; - SRV_R_NET_NAME_VALIDATE r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server disk enum. */ - if(!srv_io_q_net_name_validate("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_name_validate: Failed to unmarshall SRV_Q_NET_NAME_VALIDATE.\n")); - return False; - } - - r_u.status = _srv_net_name_validate(p, &q_u, &r_u); - - if(!srv_io_r_net_name_validate("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_name_validate: Failed to marshall SRV_R_NET_NAME_VALIDATE.\n")); - return False; - } - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETNAMEVALIDATE); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index a6cf06caa7..a64691c635 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2380,17 +2380,19 @@ WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_D } /******************************************************************** + _srvsvc_NetNameValidate ********************************************************************/ -WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV_R_NET_NAME_VALIDATE *r_u) +WERROR _srvsvc_NetNameValidate(pipes_struct *p, + struct srvsvc_NetNameValidate *r) { - fstring sharename; - - switch ( q_u->type ) { + switch (r->in.name_type) { case 0x9: - rpcstr_pull(sharename, q_u->sharename.buffer, sizeof(sharename), q_u->sharename.uni_str_len*2, 0); - if ( !validate_net_name( sharename, INVALID_SHARENAME_CHARS, sizeof(sharename) ) ) { - DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", sharename)); + if (!validate_net_name(r->in.name, INVALID_SHARENAME_CHARS, + strlen_m(r->in.name))) + { + DEBUG(5,("_srvsvc_NetNameValidate: Bad sharename \"%s\"\n", + r->in.name)); return WERR_INVALID_NAME; } break; @@ -2402,7 +2404,6 @@ WERROR _srv_net_name_validate(pipes_struct *p, SRV_Q_NET_NAME_VALIDATE *q_u, SRV return WERR_OK; } - /******************************************************************** ********************************************************************/ @@ -2559,12 +2560,6 @@ WERROR _srvsvc_NetPathCompare(pipes_struct *p, struct srvsvc_NetPathCompare *r) return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetNameValidate(pipes_struct *p, struct srvsvc_NetNameValidate *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NETRPRNAMECANONICALIZE(pipes_struct *p, struct srvsvc_NETRPRNAMECANONICALIZE *r) { p->rng_fault_state = True; -- cgit From 45c91e7d754592f32108113d9fc395bd16e3b227 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 8 Mar 2008 00:22:44 +0100 Subject: Use pidl for _srvsvc_NetShareAdd. Guenther (This used to be commit fd3e7728181e7a208706e477905173bec44c982e) --- source3/rpc_server/srv_srvsvc.c | 23 +------------ source3/rpc_server/srv_srvsvc_nt.c | 66 ++++++++++++++++++-------------------- 2 files changed, 33 insertions(+), 56 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 8853295608..1873bcb578 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -216,28 +216,7 @@ static bool api_srv_net_share_set_info(pipes_struct *p) static bool api_srv_net_share_add(pipes_struct *p) { - SRV_Q_NET_SHARE_ADD q_u; - SRV_R_NET_SHARE_ADD r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server add info. */ - if(!srv_io_q_net_share_add("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_share_add: Failed to unmarshall SRV_Q_NET_SHARE_ADD.\n")); - return False; - } - - r_u.status = _srv_net_share_add(p, &q_u, &r_u); - - if(!srv_io_r_net_share_add("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_share_add: Failed to marshall SRV_R_NET_SHARE_ADD.\n")); - return False; - } - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHAREADD); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index a64691c635..d45ebb26e6 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1726,11 +1726,13 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, } /******************************************************************* - Net share add. Call 'add_share_command "sharename" "pathname" + _srvsvc_NetShareAdd. + Call 'add_share_command "sharename" "pathname" "comment" "max connections = " ********************************************************************/ -WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_SHARE_ADD *r_u) +WERROR _srvsvc_NetShareAdd(pipes_struct *p, + struct srvsvc_NetShareAdd *r) { struct current_user user; char *command = NULL; @@ -1747,9 +1749,9 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S int max_connections = 0; TALLOC_CTX *ctx = p->mem_ctx; - DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetShareAdd: %d\n", __LINE__)); - r_u->parm_error = 0; + *r->out.parm_error = 0; get_current_user(&user,p); @@ -1759,11 +1761,11 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S return WERR_ACCESS_DENIED; if (!lp_add_share_cmd() || !*lp_add_share_cmd()) { - DEBUG(10,("_srv_net_share_add: No add share command\n")); + DEBUG(10,("_srvsvc_NetShareAdd: No add share command\n")); return WERR_ACCESS_DENIED; } - switch (q_u->info_level) { + switch (r->in.level) { case 0: /* No path. Not enough info in a level 0 to do anything. */ return WERR_ACCESS_DENIED; @@ -1771,27 +1773,24 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S /* Not enough info in a level 1 to do anything. */ return WERR_ACCESS_DENIED; case 2: - share_name = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info2.info_2_str.uni_netname); - comment = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info2.info_2_str.uni_remark); - pathname = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info2.info_2_str.uni_path); - max_connections = (q_u->info.share.info2.info_2.max_uses == 0xffffffff) ? 0 : q_u->info.share.info2.info_2.max_uses; - type = q_u->info.share.info2.info_2.type; + share_name = talloc_strdup(ctx, r->in.info->info2->name); + comment = talloc_strdup(ctx, r->in.info->info2->comment); + pathname = talloc_strdup(ctx, r->in.info->info2->path); + max_connections = (r->in.info->info2->max_users == 0xffffffff) ? + 0 : r->in.info->info2->max_users; + type = r->in.info->info2->type; break; case 501: /* No path. Not enough info in a level 501 to do anything. */ return WERR_ACCESS_DENIED; case 502: - share_name = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info502.info_502_str.uni_netname); - comment = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info502.info_502_str.uni_remark); - pathname = unistr2_to_ascii_talloc(ctx, - &q_u->info.share.info502.info_502_str.uni_path); - type = q_u->info.share.info502.info_502.type; - psd = q_u->info.share.info502.info_502_str.sd; + share_name = talloc_strdup(ctx, r->in.info->info502->name); + comment = talloc_strdup(ctx, r->in.info->info502->comment); + pathname = talloc_strdup(ctx, r->in.info->info502->path); + max_connections = (r->in.info->info502->max_users == 0xffffffff) ? + 0 : r->in.info->info502->max_users; + type = r->in.info->info502->type; + psd = r->in.info->info502->sd; map_generic_share_sd_bits(psd); break; @@ -1806,7 +1805,8 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S /* DFS only level. */ return WERR_ACCESS_DENIED; default: - DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", q_u->info_level)); + DEBUG(5,("_srvsvc_NetShareAdd: unsupported switch value %d\n", + r->in.level)); return WERR_UNKNOWN_LEVEL; } @@ -1815,7 +1815,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S if (!share_name || !validate_net_name(share_name, INVALID_SHARENAME_CHARS, strlen(share_name))) { - DEBUG(5,("_srv_net_name_validate: Bad sharename \"%s\"\n", + DEBUG(5,("_srvsvc_NetShareAdd: Bad sharename \"%s\"\n", share_name ? share_name : "")); return WERR_INVALID_NAME; } @@ -1862,13 +1862,15 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S return WERR_NOMEM; } - DEBUG(10,("_srv_net_share_add: Running [%s]\n", command )); + DEBUG(10,("_srvsvc_NetShareAdd: Running [%s]\n", command )); /********* BEGIN SeDiskOperatorPrivilege BLOCK *********/ if ( is_disk_op ) become_root(); + /* FIXME: use libnetconf here - gd */ + if ( (ret = smbrun(command, NULL)) == 0 ) { /* Tell everyone we updated smb.conf. */ message_send_all(smbd_messaging_context(), @@ -1880,7 +1882,8 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S /********* END SeDiskOperatorPrivilege BLOCK *********/ - DEBUG(3,("_srv_net_share_add: Running [%s] returned (%d)\n", command, ret )); + DEBUG(3,("_srvsvc_NetShareAdd: Running [%s] returned (%d)\n", + command, ret )); TALLOC_FREE(command); @@ -1889,7 +1892,8 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S if (psd) { if (!set_share_security(share_name, psd)) { - DEBUG(0,("_srv_net_share_add: Failed to add security info to share %s.\n", share_name )); + DEBUG(0,("_srvsvc_NetShareAdd: Failed to add security info to share %s.\n", + share_name )); } } @@ -1899,7 +1903,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S * from the client. JRA. */ - DEBUG(5,("_srv_net_share_add: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetShareAdd: %d\n", __LINE__)); return WERR_OK; } @@ -2494,12 +2498,6 @@ WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r) return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetShareAdd(pipes_struct *p, struct srvsvc_NetShareAdd *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetShareCheck(pipes_struct *p, struct srvsvc_NetShareCheck *r) { p->rng_fault_state = True; -- cgit From 3102609c4bf18c547ad2171b313e620647a718bf Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 8 Mar 2008 00:42:40 +0100 Subject: Use pidl for _srvsvc_NetSetFileSecurity. Guenther (This used to be commit 64a121c147c825259a06a8cd8de85ec31dd5b4a4) --- source3/rpc_server/srv_srvsvc.c | 23 +--------------- source3/rpc_server/srv_srvsvc_nt.c | 54 ++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 50 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 1873bcb578..a53803c986 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -321,28 +321,7 @@ static bool api_srv_net_file_query_secdesc(pipes_struct *p) static bool api_srv_net_file_set_secdesc(pipes_struct *p) { - SRV_Q_NET_FILE_SET_SECDESC q_u; - SRV_R_NET_FILE_SET_SECDESC r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net file set info from Win9x */ - if(!srv_io_q_net_file_set_secdesc("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_file_set_secdesc: Failed to unmarshall SRV_Q_NET_FILE_SET_SECDESC.\n")); - return False; - } - - r_u.status = _srv_net_file_set_secdesc(p, &q_u, &r_u); - - if(!srv_io_r_net_file_set_secdesc("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_file_set_secdesc: Failed to marshall SRV_R_NET_FILE_SET_SECDESC.\n")); - return False; - } - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSETFILESECURITY); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index d45ebb26e6..276ae8e243 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2176,11 +2176,12 @@ error_exit: } /*********************************************************************************** + _srvsvc_NetSetFileSecurity Win9x NT tools set security descriptor. ***********************************************************************************/ -WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_u, - SRV_R_NET_FILE_SET_SECDESC *r_u) +WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, + struct srvsvc_NetSetFileSecurity *r) { char *filename_in = NULL; char *filename = NULL; @@ -2189,6 +2190,7 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ files_struct *fsp = NULL; SMB_STRUCT_STAT st; NTSTATUS nt_status; + WERROR werr; struct current_user user; connection_struct *conn = NULL; bool became_user = False; @@ -2196,11 +2198,11 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ ZERO_STRUCT(st); - r_u->status = WERR_OK; + werr = WERR_OK; - qualname = unistr2_to_ascii_talloc(ctx, &q_u->uni_qual_name); + qualname = talloc_strdup(ctx, r->in.share); if (!qualname) { - r_u->status = WERR_ACCESS_DENIED; + werr = WERR_ACCESS_DENIED; goto error_exit; } @@ -2214,35 +2216,35 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ unbecome_root(); if (conn == NULL) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to connect to %s\n", qualname)); - r_u->status = ntstatus_to_werror(nt_status); + DEBUG(3,("_srvsvc_NetSetFileSecurity: Unable to connect to %s\n", qualname)); + werr = ntstatus_to_werror(nt_status); 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 = WERR_ACCESS_DENIED; + DEBUG(0,("_srvsvc_NetSetFileSecurity: Can't become connected user!\n")); + werr = WERR_ACCESS_DENIED; goto error_exit; } became_user = True; - filename_in= unistr2_to_ascii_talloc(ctx, &q_u->uni_file_name); + filename_in = talloc_strdup(ctx, r->in.file); if (!filename_in) { - r_u->status = WERR_ACCESS_DENIED; + werr = WERR_ACCESS_DENIED; goto error_exit; } nt_status = unix_convert(ctx, conn, filename, False, &filename, NULL, &st); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_set_secdesc: bad pathname %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srvsvc_NetSetFileSecurity: bad pathname %s\n", filename)); + werr = WERR_ACCESS_DENIED; goto error_exit; } nt_status = check_name(conn, filename); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_set_secdesc: can't access %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srvsvc_NetSetFileSecurity: can't access %s\n", filename)); + werr = WERR_ACCESS_DENIED; goto error_exit; } @@ -2260,24 +2262,26 @@ WERROR _srv_net_file_set_secdesc(pipes_struct *p, SRV_Q_NET_FILE_SET_SECDESC *q_ NULL, &fsp); if ( !NT_STATUS_IS_OK(nt_status) ) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to open file %s\n", filename)); - r_u->status = ntstatus_to_werror(nt_status); + DEBUG(3,("_srvsvc_NetSetFileSecurity: Unable to open file %s\n", filename)); + werr = ntstatus_to_werror(nt_status); goto error_exit; } } - nt_status = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, q_u->sec_info, q_u->sec_desc); + nt_status = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, + r->in.securityinformation, + r->in.sd_buf->sd); if (!NT_STATUS_IS_OK(nt_status) ) { - DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srvsvc_NetSetFileSecurity: Unable to set NT ACL on file %s\n", filename)); + werr = WERR_ACCESS_DENIED; goto error_exit; } close_file(fsp, NORMAL_CLOSE); unbecome_user(); close_cnum(conn, user.vuid); - return r_u->status; + return werr; error_exit: @@ -2293,7 +2297,7 @@ error_exit: close_cnum(conn, user.vuid); } - return r_u->status; + return werr; } /*********************************************************************************** @@ -2588,12 +2592,6 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecur return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecurity *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetServerTransportAddEx(pipes_struct *p, struct srvsvc_NetServerTransportAddEx *r) { p->rng_fault_state = True; -- cgit From fa58ebd8f7c5a14a11b36d0497904e944a23d24f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 8 Mar 2008 00:57:52 +0100 Subject: Use pidl for _srvsvc_NetGetFileSecurity. Guenther (This used to be commit 8b016efeb0bb4cd5d91928952a258fce1b6f97d0) --- source3/rpc_server/srv_srvsvc.c | 23 +------------ source3/rpc_server/srv_srvsvc_nt.c | 66 +++++++++++++++++++++----------------- 2 files changed, 37 insertions(+), 52 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index a53803c986..5351f93346 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -291,28 +291,7 @@ static bool api_srv_net_name_validate(pipes_struct *p) static bool api_srv_net_file_query_secdesc(pipes_struct *p) { - SRV_Q_NET_FILE_QUERY_SECDESC q_u; - SRV_R_NET_FILE_QUERY_SECDESC r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net file get info from Win9x */ - if(!srv_io_q_net_file_query_secdesc("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_file_query_secdesc: Failed to unmarshall SRV_Q_NET_FILE_QUERY_SECDESC.\n")); - return False; - } - - r_u.status = _srv_net_file_query_secdesc(p, &q_u, &r_u); - - if(!srv_io_r_net_file_query_secdesc("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_file_query_secdesc: Failed to marshall SRV_R_NET_FILE_QUERY_SECDESC.\n")); - return False; - } - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETGETFILESECURITY); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 276ae8e243..0d4addde14 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2068,11 +2068,12 @@ WERROR _srvsvc_NetRemoteTOD(pipes_struct *p, } /*********************************************************************************** + _srvsvc_NetGetFileSecurity Win9x NT tools get security descriptor. ***********************************************************************************/ -WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC *q_u, - SRV_R_NET_FILE_QUERY_SECDESC *r_u) +WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, + struct srvsvc_NetGetFileSecurity *r) { SEC_DESC *psd = NULL; size_t sd_size; @@ -2082,18 +2083,20 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC char *qualname = NULL; SMB_STRUCT_STAT st; NTSTATUS nt_status; + WERROR werr; struct current_user user; connection_struct *conn = NULL; bool became_user = False; TALLOC_CTX *ctx = p->mem_ctx; + struct sec_desc_buf *sd_buf; ZERO_STRUCT(st); - r_u->status = WERR_OK; + werr = WERR_OK; - qualname = unistr2_to_ascii_talloc(ctx, &q_u->uni_qual_name); + qualname = talloc_strdup(ctx, r->in.share); if (!qualname) { - r_u->status = WERR_ACCESS_DENIED; + werr = WERR_ACCESS_DENIED; goto error_exit; } @@ -2107,35 +2110,38 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC unbecome_root(); if (conn == NULL) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to connect to %s\n", qualname)); - r_u->status = ntstatus_to_werror(nt_status); + DEBUG(3,("_srvsvc_NetGetFileSecurity: Unable to connect to %s\n", + qualname)); + werr = ntstatus_to_werror(nt_status); goto error_exit; } if (!become_user(conn, conn->vuid)) { - DEBUG(0,("_srv_net_file_query_secdesc: Can't become connected user!\n")); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(0,("_srvsvc_NetGetFileSecurity: Can't become connected user!\n")); + werr = WERR_ACCESS_DENIED; goto error_exit; } became_user = True; - filename_in = unistr2_to_ascii_talloc(ctx, &q_u->uni_file_name); + filename_in = talloc_strdup(ctx, r->in.file); if (!filename_in) { - r_u->status = WERR_ACCESS_DENIED; + werr = WERR_ACCESS_DENIED; goto error_exit; } nt_status = unix_convert(ctx, conn, filename_in, False, &filename, NULL, &st); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: bad pathname %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srvsvc_NetGetFileSecurity: bad pathname %s\n", + filename)); + werr = WERR_ACCESS_DENIED; goto error_exit; } nt_status = check_name(conn, filename); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: can't access %s\n", filename)); - r_u->status = WERR_ACCESS_DENIED; + DEBUG(3,("_srvsvc_NetGetFileSecurity: can't access %s\n", + filename)); + werr = WERR_ACCESS_DENIED; goto error_exit; } @@ -2145,24 +2151,30 @@ WERROR _srv_net_file_query_secdesc(pipes_struct *p, SRV_Q_NET_FILE_QUERY_SECDESC |DACL_SECURITY_INFORMATION), &psd); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", filename)); - r_u->status = ntstatus_to_werror(nt_status); + DEBUG(3,("_srvsvc_NetGetFileSecurity: Unable to get NT ACL for file %s\n", + filename)); + werr = ntstatus_to_werror(nt_status); goto error_exit; } sd_size = ndr_size_security_descriptor(psd, 0); - r_u->ptr_response = 1; - r_u->size_response = sd_size; - r_u->ptr_secdesc = 1; - r_u->size_secdesc = sd_size; - r_u->sec_desc = psd; + sd_buf = TALLOC_ZERO_P(ctx, struct sec_desc_buf); + if (!sd_buf) { + werr = WERR_NOMEM; + goto error_exit; + } + + sd_buf->sd_size = sd_size; + sd_buf->sd = psd; + + *r->out.sd_buf = sd_buf; psd->dacl->revision = NT4_ACL_REVISION; unbecome_user(); close_cnum(conn, user.vuid); - return r_u->status; + return werr; error_exit: @@ -2172,7 +2184,7 @@ error_exit: if (conn) close_cnum(conn, user.vuid); - return r_u->status; + return werr; } /*********************************************************************************** @@ -2586,12 +2598,6 @@ WERROR _srvsvc_NetShareDelCommit(pipes_struct *p, struct srvsvc_NetShareDelCommi return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, struct srvsvc_NetGetFileSecurity *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetServerTransportAddEx(pipes_struct *p, struct srvsvc_NetServerTransportAddEx *r) { p->rng_fault_state = True; -- cgit From ca354276ca491a413c8dfc30e9c093e71dc2e9d3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sun, 9 Mar 2008 18:01:52 +0100 Subject: Use pidl for _srvsvc_NetSessDel(). Guenther (This used to be commit 8a10bc13aee7c34f466fa69773694be97f0e7d85) --- source3/rpc_server/srv_srvsvc.c | 21 +-------------------- source3/rpc_server/srv_srvsvc_nt.c | 35 +++++++++++++++-------------------- 2 files changed, 16 insertions(+), 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 5351f93346..7579e109d4 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -152,26 +152,7 @@ static bool api_srv_net_sess_enum(pipes_struct *p) static bool api_srv_net_sess_del(pipes_struct *p) { - SRV_Q_NET_SESS_DEL q_u; - SRV_R_NET_SESS_DEL r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server get enum */ - if (!srv_io_q_net_sess_del("", &q_u, data, 0)) - return False; - - /* construct reply. always indicate success */ - r_u.status = _srv_net_sess_del(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if (!srv_io_r_net_sess_del("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSESSDEL); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 0d4addde14..7c2efc946d 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1274,31 +1274,33 @@ WERROR _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_S } /******************************************************************* -net sess del + _srvsvc_NetSessDel ********************************************************************/ -WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SESS_DEL *r_u) +WERROR _srvsvc_NetSessDel(pipes_struct *p, + struct srvsvc_NetSessDel *r) { struct sessionid *session_list; struct current_user user; int num_sessions, snum; - fstring username; - fstring machine; + const char *username; + const char *machine; bool not_root = False; + WERROR werr; - rpcstr_pull_unistr2_fstring(username, &q_u->uni_user_name); - rpcstr_pull_unistr2_fstring(machine, &q_u->uni_cli_name); + username = r->in.user; + machine = r->in.client; /* strip leading backslashes if any */ - while (machine[0] == '\\') { - memmove(machine, &machine[1], strlen(machine)); + if (machine && machine[0] == '\\' && machine[1] == '\\') { + machine += 2; } num_sessions = list_sessions(p->mem_ctx, &session_list); - DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetSessDel: %d\n", __LINE__)); - r_u->status = WERR_ACCESS_DENIED; + werr = WERR_ACCESS_DENIED; get_current_user(&user, p); @@ -1327,19 +1329,18 @@ WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SES MSG_SHUTDOWN, &data_blob_null); if (NT_STATUS_IS_OK(ntstat)) - r_u->status = WERR_OK; + werr = WERR_OK; if (not_root) unbecome_root(); } } - DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); - + DEBUG(5,("_srvsvc_NetSessDel: %d\n", __LINE__)); done: - return r_u->status; + return werr; } /******************************************************************* @@ -2508,12 +2509,6 @@ WERROR _srvsvc_NetSessEnum(pipes_struct *p, struct srvsvc_NetSessEnum *r) return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetSessDel(pipes_struct *p, struct srvsvc_NetSessDel *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetShareCheck(pipes_struct *p, struct srvsvc_NetShareCheck *r) { p->rng_fault_state = True; -- cgit From b960bc265b51c6e3627895bfd1375da9c6579252 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 11 Mar 2008 10:48:52 +0100 Subject: Use pidl for _srvsvc_NetDiskEnum. Guenther (This used to be commit 933d546f86b48bfd9f84045ec21efc1c362b4d93) --- source3/rpc_server/srv_srvsvc.c | 25 ++------------------ source3/rpc_server/srv_srvsvc_nt.c | 48 +++++++++++++++++++------------------- 2 files changed, 26 insertions(+), 47 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 7579e109d4..96bc3735b4 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -231,30 +231,9 @@ static bool api_srv_net_remote_tod(pipes_struct *p) RPC to enumerate disks available on a server e.g. C:, D: ... *******************************************************************/ -static bool api_srv_net_disk_enum(pipes_struct *p) +static bool api_srv_net_disk_enum(pipes_struct *p) { - SRV_Q_NET_DISK_ENUM q_u; - SRV_R_NET_DISK_ENUM r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* Unmarshall the net server disk enum. */ - if(!srv_io_q_net_disk_enum("", &q_u, data, 0)) { - DEBUG(0,("api_srv_net_disk_enum: Failed to unmarshall SRV_Q_NET_DISK_ENUM.\n")); - return False; - } - - r_u.status = _srv_net_disk_enum(p, &q_u, &r_u); - - if(!srv_io_r_net_disk_enum("", &r_u, rdata, 0)) { - DEBUG(0,("api_srv_net_disk_enum: Failed to marshall SRV_R_NET_DISK_ENUM.\n")); - return False; - } - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETDISKENUM); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 7c2efc946d..eb304aa60c 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2359,45 +2359,51 @@ static const char *next_server_disk_enum(uint32 *resume) return disk; } -WERROR _srv_net_disk_enum(pipes_struct *p, SRV_Q_NET_DISK_ENUM *q_u, SRV_R_NET_DISK_ENUM *r_u) +/******************************************************************** + _srvsvc_NetDiskEnum +********************************************************************/ + +WERROR _srvsvc_NetDiskEnum(pipes_struct *p, + struct srvsvc_NetDiskEnum *r) { uint32 i; const char *disk_name; TALLOC_CTX *ctx = p->mem_ctx; - uint32 resume=get_enum_hnd(&q_u->enum_hnd); - - r_u->status=WERR_OK; - - r_u->total_entries = init_server_disk_enum(&resume); + WERROR werr; + uint32_t resume = r->in.resume_handle ? *r->in.resume_handle : 0; - r_u->disk_enum_ctr.unknown = 0; + werr = WERR_OK; - if(!(r_u->disk_enum_ctr.disk_info = TALLOC_ARRAY(ctx, DISK_INFO, MAX_SERVER_DISK_ENTRIES))) { - return WERR_NOMEM; - } + *r->out.totalentries = init_server_disk_enum(&resume); - r_u->disk_enum_ctr.disk_info_ptr = r_u->disk_enum_ctr.disk_info ? 1 : 0; + r->out.info->disks = TALLOC_ZERO_ARRAY(ctx, struct srvsvc_NetDiskInfo0, + MAX_SERVER_DISK_ENTRIES); + W_ERROR_HAVE_NO_MEMORY(r->out.info->disks); - /*allow one DISK_INFO for null terminator*/ + /*allow one struct srvsvc_NetDiskInfo0 for null terminator*/ for(i = 0; i < MAX_SERVER_DISK_ENTRIES -1 && (disk_name = next_server_disk_enum(&resume)); i++) { - r_u->disk_enum_ctr.entries_read++; + r->out.info->count++; /*copy disk name into a unicode string*/ - init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name); + r->out.info->disks[i].disk = talloc_strdup(ctx, disk_name); + W_ERROR_HAVE_NO_MEMORY(r->out.info->disks[i].disk); } /* add a terminating null string. Is this there if there is more data to come? */ - r_u->disk_enum_ctr.entries_read++; + r->out.info->count++; - init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, ""); + r->out.info->disks[i].disk = talloc_strdup(ctx, ""); + W_ERROR_HAVE_NO_MEMORY(r->out.info->disks[i].disk); - init_enum_hnd(&r_u->enum_hnd, resume); + if (r->out.resume_handle) { + *r->out.resume_handle = resume; + } - return r_u->status; + return werr; } /******************************************************************** @@ -2515,12 +2521,6 @@ WERROR _srvsvc_NetShareCheck(pipes_struct *p, struct srvsvc_NetShareCheck *r) return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetDiskEnum(pipes_struct *p, struct srvsvc_NetDiskEnum *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetServerStatisticsGet(pipes_struct *p, struct srvsvc_NetServerStatisticsGet *r) { p->rng_fault_state = True; -- cgit From 2a40d670410823de807224ce175d3ec89a7006b3 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 11 Mar 2008 11:30:55 +0100 Subject: Trying to fix resume_handling for srvsvc_NetShareEnumAll. Guenther (This used to be commit 874a0ffd7dbd993230c00c503ec6b27fbffb7745) --- source3/rpc_server/srv_srvsvc_nt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index eb304aa60c..6421efdf8f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -694,7 +694,11 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, *total_entries = alloc_entries; if (resume_handle_p) { - *resume_handle_p = num_entries; + if (all_shares) { + *resume_handle_p = (num_entries == 0) ? *resume_handle_p : 0; + } else { + *resume_handle_p = num_entries; + } } info_ctr->ctr = ctr; -- cgit From b371db93bba1fd1753966a7270f0d6936d5863f2 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 12 Mar 2008 02:10:35 +0100 Subject: init_srv_share_info_ctr: Add debug messages. Michael (This used to be commit 8b2cc36ffcb3bccb760ec7cb0a22558eab56070d) --- source3/rpc_server/srv_srvsvc_nt.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 6421efdf8f..2658e5a37a 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -505,7 +505,10 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, /* Count the number of entries. */ for (snum = 0; snum < num_services; snum++) { if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) { + DEBUG(10, ("counting service %s\n", lp_servicename(snum))); num_entries++; + } else { + DEBUG(10, ("NOT counting service %s\n", lp_servicename(snum))); } } -- cgit From 16f4e059f79373ddfe293b1ba9ab7dd4cb466042 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 12 Mar 2008 02:12:11 +0100 Subject: init_srv_share_info_ctr: fix counting of services. The number of services was recorded too early leading to registry shares not showing up in browse lists. Guenther - please check. Michael (This used to be commit 737e470e02d1233fda51e903f27955e45427e95a) --- source3/rpc_server/srv_srvsvc_nt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 2658e5a37a..56d3159949 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -498,8 +498,9 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, /* Ensure all the usershares are loaded. */ become_root(); - num_services = load_usershare_shares(); + load_usershare_shares(); load_registry_shares(); + num_services = lp_numservices(); unbecome_root(); /* Count the number of entries. */ -- cgit From e06aa46b9fab1e107fea8f6453fb13deffa91e96 Mon Sep 17 00:00:00 2001 From: Marc VanHeyningen Date: Fri, 14 Mar 2008 14:26:28 -0800 Subject: Coverity fixes (This used to be commit 3fc85d22590550f0539215d020e4411bf5b14363) --- source3/rpc_server/srv_pipe.c | 16 ++++++++-------- source3/rpc_server/srv_pipe_hnd.c | 6 +++--- source3/rpc_server/srv_spoolss_nt.c | 6 +++++- source3/rpc_server/srv_winreg_nt.c | 6 ++++-- 4 files changed, 20 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 19c8db0533..6c1b65b858 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -151,7 +151,7 @@ static bool create_next_pdu_ntlmssp(pipes_struct *p) * data. */ - prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL); + prs_init_empty( &outgoing_pdu, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* Store the header in the data stream. */ @@ -358,7 +358,7 @@ static bool create_next_pdu_schannel(pipes_struct *p) * data. */ - prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL); + prs_init_empty( &outgoing_pdu, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* Store the header in the data stream. */ @@ -531,7 +531,7 @@ static bool create_next_pdu_noauth(pipes_struct *p) * data. */ - prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL); + prs_init_empty( &outgoing_pdu, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* Store the header in the data stream. */ @@ -812,7 +812,7 @@ static bool setup_bind_nak(pipes_struct *p) * header and are never sending more than one PDU here. */ - prs_init( &outgoing_rpc, 0, p->mem_ctx, MARSHALL); + prs_init_empty( &outgoing_rpc, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* @@ -875,7 +875,7 @@ bool setup_fault_pdu(pipes_struct *p, NTSTATUS status) * header and are never sending more than one PDU here. */ - prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL); + prs_init_empty( &outgoing_pdu, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* @@ -944,7 +944,7 @@ bool setup_cancel_ack_reply(pipes_struct *p, prs_struct *rpc_in_p) * header and are never sending more than one PDU here. */ - prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL); + prs_init_empty( &outgoing_pdu, p->mem_ctx, MARSHALL); prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False); /* @@ -1522,7 +1522,7 @@ bool api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) return setup_bind_nak(p); } - prs_init( &outgoing_rpc, 0, p->mem_ctx, MARSHALL); + prs_init_empty( &outgoing_rpc, p->mem_ctx, MARSHALL); /* * Marshall directly into the outgoing PDU space. We @@ -1794,7 +1794,7 @@ bool api_pipe_alter_context(pipes_struct *p, prs_struct *rpc_in_p) prs_struct outgoing_rpc; int auth_len = 0; - prs_init( &outgoing_rpc, 0, p->mem_ctx, MARSHALL); + prs_init_empty( &outgoing_rpc, p->mem_ctx, MARSHALL); /* * Marshall directly into the outgoing PDU space. We diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 95ce496ba6..45f649d0ce 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -348,7 +348,7 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, /* * Initialize the outgoing RPC data buffer with no memory. */ - prs_init(&p->out_data.rdata, 0, p->mem_ctx, MARSHALL); + prs_init_empty(&p->out_data.rdata, p->mem_ctx, MARSHALL); fstrcpy(p->name, pipe_name); @@ -408,7 +408,7 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p) return -1; } - prs_init( &rpc_in, 0, p->mem_ctx, UNMARSHALL); + prs_init_empty( &rpc_in, p->mem_ctx, UNMARSHALL); prs_set_endian_data( &rpc_in, p->endian); prs_give_memory( &rpc_in, (char *)&p->in_data.current_in_pdu[0], @@ -693,7 +693,7 @@ static void process_complete_pdu(pipes_struct *p) return; } - prs_init( &rpc_in, 0, p->mem_ctx, UNMARSHALL); + prs_init_empty( &rpc_in, p->mem_ctx, UNMARSHALL); /* * Ensure we're using the corrent endianness for both the diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 3758c8fd63..403beb6782 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6033,7 +6033,11 @@ static WERROR update_printer_sec(POLICY_HND *handle, uint32 level, /* NT seems to like setting the security descriptor even though nothing may have actually changed. */ - nt_printing_getsec(p->mem_ctx, Printer->sharename, &old_secdesc_ctr); + if ( !nt_printing_getsec(p->mem_ctx, Printer->sharename, &old_secdesc_ctr)) { + DEBUG(2,("update_printer_sec: nt_printing_getsec() failed\n")); + result = WERR_BADFID; + goto done; + } if (DEBUGLEVEL >= 10) { SEC_ACL *the_acl; diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index c76bc19d9c..6e076ea372 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -239,7 +239,8 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct winreg_QueryValue *r) if(regkey->key->type == REG_KEY_HKPD) { if(strequal(r->in.value_name.name, "Global")) { - prs_init(&prs_hkpd, *r->in.data_size, p->mem_ctx, MARSHALL); + if (!prs_init(&prs_hkpd, *r->in.data_size, p->mem_ctx, MARSHALL)) + return WERR_NOMEM; status = reg_perfcount_get_hkpd( &prs_hkpd, *r->in.data_size, &outbuf_size, NULL); outbuf = (uint8_t *)prs_hkpd.data_p; @@ -260,7 +261,8 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct winreg_QueryValue *r) else if(isdigit(r->in.value_name.name[0])) { /* we probably have a request for a specific object * here */ - prs_init(&prs_hkpd, *r->in.data_size, p->mem_ctx, MARSHALL); + if (!prs_init(&prs_hkpd, *r->in.data_size, p->mem_ctx, MARSHALL)) + return WERR_NOMEM; status = reg_perfcount_get_hkpd( &prs_hkpd, *r->in.data_size, &outbuf_size, r->in.value_name.name); -- cgit From 63a6acdfa84253ce602b2a6050093752d69f4771 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 19 Mar 2008 01:25:59 +0100 Subject: Use pidl for _srvsvc_NetFileEnum. Guenther (This used to be commit 6c6700ed7148b73b2ce52fc00020c7e253a577d3) --- source3/rpc_server/srv_srvsvc_nt.c | 169 ++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 98 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 56d3159949..053f57ec36 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -34,8 +34,7 @@ extern const struct generic_mapping file_generic_mapping; struct file_enum_count { TALLOC_CTX *ctx; const char *username; - int count; - FILE_INFO_3 *info; + struct srvsvc_NetFileCtr3 *ctr3; }; struct sess_file_count { @@ -52,8 +51,8 @@ static int pipe_enum_fn( struct db_record *rec, void *p) { struct pipe_open_rec prec; struct file_enum_count *fenum = (struct file_enum_count *)p; - FILE_INFO_3 *f; - int i = fenum->count; + struct srvsvc_NetFileInfo3 *f; + int i = fenum->ctr3->count; char *fullpath = NULL; const char *username; @@ -78,21 +77,22 @@ static int pipe_enum_fn( struct db_record *rec, void *p) return 1; } - f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 ); + f = TALLOC_REALLOC_ARRAY(fenum->ctx, fenum->ctr3->array, + struct srvsvc_NetFileInfo3, i+1); if ( !f ) { DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); return 1; } - fenum->info = f; + fenum->ctr3->array = f; - init_srv_file_info3( - &fenum->info[i], - (uint32)((procid_to_pid(&prec.pid)<<16) & prec.pnum), - (FILE_READ_DATA|FILE_WRITE_DATA), - 0, username, fullpath); + init_srvsvc_NetFileInfo3(&fenum->ctr3->array[i], + (uint32_t)((procid_to_pid(&prec.pid)<<16) & prec.pnum), + (FILE_READ_DATA|FILE_WRITE_DATA), + 0, + fullpath, + username); - TALLOC_FREE(fullpath); - fenum->count++; + fenum->ctr3->count++; return 0; } @@ -100,16 +100,16 @@ static int pipe_enum_fn( struct db_record *rec, void *p) /******************************************************************* ********************************************************************/ -static WERROR net_enum_pipes( TALLOC_CTX *ctx, const char *username, - FILE_INFO_3 **info, - uint32 *count, uint32 resume ) +static WERROR net_enum_pipes(TALLOC_CTX *ctx, + const char *username, + struct srvsvc_NetFileCtr3 **ctr3, + uint32_t resume ) { struct file_enum_count fenum; fenum.ctx = ctx; fenum.username = username; - fenum.count = *count; - fenum.info = *info; + fenum.ctr3 = *ctr3; if (connections_traverse(pipe_enum_fn, &fenum) == -1) { DEBUG(0,("net_enum_pipes: traverse of connections.tdb " @@ -117,8 +117,7 @@ static WERROR net_enum_pipes( TALLOC_CTX *ctx, const char *username, return WERR_NOMEM; } - *info = fenum.info; - *count = fenum.count; + *ctr3 = fenum.ctr3; return WERR_OK; } @@ -133,8 +132,8 @@ static void enum_file_fn( const struct share_mode_entry *e, struct file_enum_count *fenum = (struct file_enum_count *)private_data; - FILE_INFO_3 *f; - int i = fenum->count; + struct srvsvc_NetFileInfo3 *f; + int i = fenum->ctr3->count; files_struct fsp; struct byte_range_lock *brl; int num_locks = 0; @@ -155,12 +154,13 @@ static void enum_file_fn( const struct share_mode_entry *e, return; } - f = TALLOC_REALLOC_ARRAY( fenum->ctx, fenum->info, FILE_INFO_3, i+1 ); + f = TALLOC_REALLOC_ARRAY(fenum->ctx, fenum->ctr3->array, + struct srvsvc_NetFileInfo3, i+1); if ( !f ) { DEBUG(0,("conn_enum_fn: realloc failed for %d items\n", i+1)); return; } - fenum->info = f; + fenum->ctr3->array = f; /* need to count the number of locks on a file */ @@ -186,36 +186,33 @@ static void enum_file_fn( const struct share_mode_entry *e, /* mask out create (what ever that is) */ permissions = e->share_access & (FILE_READ_DATA|FILE_WRITE_DATA); - /* now fill in the FILE_INFO_3 struct */ - init_srv_file_info3( &fenum->info[i], - e->share_file_id, - permissions, - num_locks, - username, - fullpath ); - - TALLOC_FREE(fullpath); - fenum->count++; + /* now fill in the srvsvc_NetFileInfo3 struct */ + init_srvsvc_NetFileInfo3(&fenum->ctr3->array[i], + e->share_file_id, + permissions, + num_locks, + username, + fullpath); + fenum->ctr3->count++; } /******************************************************************* ********************************************************************/ -static WERROR net_enum_files( TALLOC_CTX *ctx, const char *username, - FILE_INFO_3 **info, - uint32 *count, uint32 resume ) +static WERROR net_enum_files(TALLOC_CTX *ctx, + const char *username, + struct srvsvc_NetFileCtr3 **ctr3, + uint32_t resume) { struct file_enum_count f_enum_cnt; f_enum_cnt.ctx = ctx; f_enum_cnt.username = username; - f_enum_cnt.count = *count; - f_enum_cnt.info = *info; + f_enum_cnt.ctr3 = *ctr3; share_mode_forall( enum_file_fn, (void *)&f_enum_cnt ); - *info = f_enum_cnt.info; - *count = f_enum_cnt.count; + *ctr3 = f_enum_cnt.ctr3; return WERR_OK; } @@ -1057,70 +1054,52 @@ static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, } /******************************************************************* - makes a SRV_R_NET_FILE_ENUM structure. -********************************************************************/ + _srvsvc_NetFileEnum +*******************************************************************/ -static WERROR net_file_enum_3( const char *username, SRV_R_NET_FILE_ENUM *r, - uint32 resume_hnd ) +WERROR _srvsvc_NetFileEnum(pipes_struct *p, + struct srvsvc_NetFileEnum *r) { - TALLOC_CTX *ctx = talloc_tos(); - SRV_FILE_INFO_CTR *ctr = &r->ctr; + TALLOC_CTX *ctx = NULL; + struct srvsvc_NetFileCtr3 *ctr3; + uint32_t resume_hnd = 0; + WERROR werr; + + switch (r->in.info_ctr->level) { + case 3: + break; + default: + return WERR_UNKNOWN_LEVEL; + } + + ctx = talloc_tos(); + ctr3 = r->in.info_ctr->ctr.ctr3; + if (!ctr3) { + goto done; + } /* TODO -- Windows enumerates (b) active pipes (c) open directories and files */ - r->status = net_enum_files( ctx, username, &ctr->file.info3, - &ctr->num_entries, resume_hnd ); - if ( !W_ERROR_IS_OK(r->status)) + werr = net_enum_files(ctx, r->in.user, &ctr3, resume_hnd); + if (!W_ERROR_IS_OK(werr)) { goto done; + } - r->status = net_enum_pipes( ctx, username, &ctr->file.info3, - &ctr->num_entries, resume_hnd ); - if ( !W_ERROR_IS_OK(r->status)) + werr = net_enum_pipes(ctx, r->in.user, &ctr3, resume_hnd); + if (!W_ERROR_IS_OK(werr)) { goto done; + } - r->level = ctr->level = 3; - r->total_entries = ctr->num_entries; - /* ctr->num_entries = r->total_entries - resume_hnd; */ - ctr->num_entries2 = ctr->num_entries; - ctr->ptr_file_info = 1; - - r->status = WERR_OK; - -done: - if ( ctr->num_entries > 0 ) - ctr->ptr_entries = 1; - - init_enum_hnd(&r->enum_hnd, 0); - - return r->status; -} - -/******************************************************************* -*******************************************************************/ - -WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u) -{ - const char *username = NULL; - - switch ( q_u->level ) { - case 3: - if (q_u->username) { - username = rpcstr_pull_unistr2_talloc( - p->mem_ctx, q_u->username); - if (!username) { - return WERR_NOMEM; - } - } + *r->out.totalentries = ctr3->count; + r->out.info_ctr->ctr.ctr3->array = ctr3->array; + r->out.info_ctr->ctr.ctr3->count = ctr3->count; - return net_file_enum_3(username, r_u, - get_enum_hnd(&q_u->enum_hnd)); - default: - return WERR_UNKNOWN_LEVEL; - } + werr = WERR_OK; - return WERR_OK; + done: + return werr; } /******************************************************************* @@ -2505,12 +2484,6 @@ WERROR _srvsvc_NetConnEnum(pipes_struct *p, struct srvsvc_NetConnEnum *r) return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetFileEnum(pipes_struct *p, struct srvsvc_NetFileEnum *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetFileGetInfo(pipes_struct *p, struct srvsvc_NetFileGetInfo *r) { p->rng_fault_state = True; -- cgit From 56c97115ec83880768a3bead2d44ae4f1de03e34 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 19 Mar 2008 02:47:22 +0100 Subject: Fix the build (by calling NDR_SRVSVC_NETFILEENUM). Guenther (This used to be commit 3b1f3d8a6ce9b8860aca07d9960bc8488296aecd) --- source3/rpc_server/srv_srvsvc.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 96bc3735b4..e33ccce2d3 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -70,25 +70,7 @@ static bool api_srv_net_srv_set_info(pipes_struct *p) static bool api_srv_net_file_enum(pipes_struct *p) { - SRV_Q_NET_FILE_ENUM q_u; - SRV_R_NET_FILE_ENUM r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net file enum */ - if (!srv_io_q_net_file_enum("", &q_u, data, 0)) - return False; - - r_u.status = _srv_net_file_enum(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if(!srv_io_r_net_file_enum("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETFILEENUM); } /******************************************************************* -- cgit From 1a65f16843d4127573da522078200b272ee67d30 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 20 Mar 2008 01:38:23 +0100 Subject: Use pidl for _svcctl_EnumDependentServicesW(). Guenther (This used to be commit 988291a9c07c055213f8979ebe75bb392811008d) --- source3/rpc_server/srv_svcctl.c | 18 +----------------- source3/rpc_server/srv_svcctl_nt.c | 19 +++++++------------ 2 files changed, 8 insertions(+), 29 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index 5e125145d6..e3ff2cc8a0 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -131,23 +131,7 @@ static bool api_svcctl_query_service_status_ex(pipes_struct *p) static bool api_svcctl_enum_dependent_services(pipes_struct *p) { - SVCCTL_Q_ENUM_DEPENDENT_SERVICES q_u; - SVCCTL_R_ENUM_DEPENDENT_SERVICES r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!svcctl_io_q_enum_dependent_services("", &q_u, data, 0)) - return False; - - r_u.status = _svcctl_enum_dependent_services(p, &q_u, &r_u); - - if(!svcctl_io_r_enum_dependent_services("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_svcctl_call(p, NDR_SVCCTL_ENUMDEPENDENTSERVICESW); } /******************************************************************* diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index 3962626e27..c117d46fde 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -527,11 +527,13 @@ WERROR _svcctl_ControlService(pipes_struct *p, } /******************************************************************** + _svcctl_EnumDependentServicesW ********************************************************************/ -WERROR _svcctl_enum_dependent_services( pipes_struct *p, SVCCTL_Q_ENUM_DEPENDENT_SERVICES *q_u, SVCCTL_R_ENUM_DEPENDENT_SERVICES *r_u ) +WERROR _svcctl_EnumDependentServicesW(pipes_struct *p, + struct svcctl_EnumDependentServicesW *r) { - SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle ); + SERVICE_INFO *info = find_service_info_by_hnd( p, r->in.service ); /* perform access checks */ @@ -543,13 +545,12 @@ WERROR _svcctl_enum_dependent_services( pipes_struct *p, SVCCTL_Q_ENUM_DEPENDENT /* we have to set the outgoing buffer size to the same as the incoming buffer size (even in the case of failure */ + /* this is done in the autogenerated server already - gd */ - rpcbuf_init( &r_u->buffer, q_u->buffer_size, p->mem_ctx ); - - r_u->needed = q_u->buffer_size; + *r->out.bytes_needed = r->in.buf_size; /* no dependent services...basically a stub function */ - r_u->returned = 0; + *r->out.services_returned = 0; return WERR_OK; } @@ -948,12 +949,6 @@ WERROR _svcctl_CreateServiceW(pipes_struct *p, struct svcctl_CreateServiceW *r) return WERR_NOT_SUPPORTED; } -WERROR _svcctl_EnumDependentServicesW(pipes_struct *p, struct svcctl_EnumDependentServicesW *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _svcctl_EnumServicesStatusW(pipes_struct *p, struct svcctl_EnumServicesStatusW *r) { p->rng_fault_state = True; -- cgit From 5346641c1c3d5f665a684f7250f82955869ef9a9 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 20 Mar 2008 16:15:38 +0100 Subject: Fix an uninitialized variable warning (This used to be commit 4cc09ec40609484c973361a0cc0f05bfaef1738e) --- source3/rpc_server/srv_srvsvc_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 053f57ec36..15c7d710d0 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1075,6 +1075,7 @@ WERROR _srvsvc_NetFileEnum(pipes_struct *p, ctx = talloc_tos(); ctr3 = r->in.info_ctr->ctr.ctr3; if (!ctr3) { + werr = WERR_INVALID_PARAM; goto done; } -- cgit From dd80c452a2fd794823f1ccb6a391bb78681213f4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 20 Mar 2008 21:58:39 +0100 Subject: A level 25 setuserinfo does change the pwdlastset (This used to be commit f65cb5d4b51e2e7b9b16b73e47cd2a8d55d5d4b0) --- source3/rpc_server/srv_samr_nt.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f38a8fcfc0..eeb3e400dd 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -3863,7 +3863,8 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx, set_user_info_pw ********************************************************************/ -static bool set_user_info_pw(uint8 *pass, struct samu *pwd) +static bool set_user_info_pw(uint8 *pass, struct samu *pwd, + int level) { uint32 len = 0; char *plaintext_buf = NULL; @@ -3925,8 +3926,20 @@ static bool set_user_info_pw(uint8 *pass, struct samu *pwd) memset(plaintext_buf, '\0', strlen(plaintext_buf)); - /* restore last set time as this is an admin change, not a user pw change */ - pdb_set_pass_last_set_time (pwd, last_set_time, last_set_state); + /* + * A level 25 change does reset the pwdlastset field, a level 24 + * change does not. I know this is probably not the full story, but + * it is needed to make XP join LDAP correctly, without it the later + * auth2 check can fail with PWD_MUST_CHANGE. + */ + if (level != 25) { + /* + * restore last set time as this is an admin change, not a + * user pw change + */ + pdb_set_pass_last_set_time (pwd, last_set_time, + last_set_state); + } DEBUG(5,("set_user_info_pw: pdb_update_pwd()\n")); @@ -4147,7 +4160,8 @@ static NTSTATUS samr_SetUserInfo_internal(const char *fn_name, dump_data(100, info->info24.password.data, 516); - if (!set_user_info_pw(info->info24.password.data, pwd)) { + if (!set_user_info_pw(info->info24.password.data, pwd, + switch_value)) { status = NT_STATUS_ACCESS_DENIED; } break; @@ -4166,7 +4180,8 @@ static NTSTATUS samr_SetUserInfo_internal(const char *fn_name, if (!NT_STATUS_IS_OK(status)) { goto done; } - if (!set_user_info_pw(info->info25.password.data, pwd)) { + if (!set_user_info_pw(info->info25.password.data, pwd, + switch_value)) { status = NT_STATUS_ACCESS_DENIED; } break; @@ -4180,7 +4195,8 @@ static NTSTATUS samr_SetUserInfo_internal(const char *fn_name, dump_data(100, info->info26.password.data, 516); - if (!set_user_info_pw(info->info26.password.data, pwd)) { + if (!set_user_info_pw(info->info26.password.data, pwd, + switch_value)) { status = NT_STATUS_ACCESS_DENIED; } break; -- cgit From a6bbefa1cbe1b996106cabcefefe446ffd22bdc0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 21 Mar 2008 01:58:43 +0100 Subject: Use pidl for _srvsvc_NetConnEnum(). Guenther (This used to be commit b8714e03e70070b5dfb1a0b15b191dfac0634c44) --- source3/rpc_server/srv_srvsvc.c | 20 +--- source3/rpc_server/srv_srvsvc_nt.c | 231 +++++++++++++++---------------------- 2 files changed, 97 insertions(+), 154 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index e33ccce2d3..9c27f13c4c 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -79,25 +79,7 @@ static bool api_srv_net_file_enum(pipes_struct *p) static bool api_srv_net_conn_enum(pipes_struct *p) { - SRV_Q_NET_CONN_ENUM q_u; - SRV_R_NET_CONN_ENUM r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server get enum */ - if (!srv_io_q_net_conn_enum("", &q_u, data, 0)) - return False; - - r_u.status = _srv_net_conn_enum(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if (!srv_io_r_net_conn_enum("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETCONNENUM); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 15c7d710d0..5478a73534 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -902,155 +902,116 @@ static void init_srv_r_net_sess_enum(pipes_struct *p, SRV_R_NET_SESS_ENUM *r_n, fill in a conn info level 0 structure. ********************************************************************/ -static void init_srv_conn_info_0(SRV_CONN_INFO_0 *ss0, uint32 *snum, uint32 *stot) +static WERROR init_srv_conn_info_0(struct srvsvc_NetConnCtr0 *ctr0, + uint32_t *resume_handle_p, + uint32_t *total_entries) { - uint32 num_entries = 0; - (*stot) = 1; + uint32_t num_entries = 0; + uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0; - if (ss0 == NULL) { - (*snum) = 0; - return; + DEBUG(5,("init_srv_conn_info_0\n")); + + if (ctr0 == NULL) { + if (resume_handle_p) { + *resume_handle_p = 0; + } + return WERR_OK; } - DEBUG(5,("init_srv_conn_0_ss0\n")); + *total_entries = 1; - if (snum) { - for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) { + ZERO_STRUCTP(ctr0); - init_srv_conn_info0(&ss0->info_0[num_entries], (*stot)); + for (; resume_handle < *total_entries && num_entries < MAX_CONN_ENTRIES; resume_handle++) { - /* move on to creating next connection */ - /* move on to creating next conn */ - num_entries++; + ctr0->array = TALLOC_REALLOC_ARRAY(talloc_tos(), + ctr0->array, + struct srvsvc_NetConnInfo0, + num_entries+1); + if (!ctr0->array) { + return WERR_NOMEM; } - ss0->num_entries_read = num_entries; - ss0->ptr_conn_info = num_entries > 0 ? 1 : 0; - ss0->num_entries_read2 = num_entries; + init_srvsvc_NetConnInfo0(&ctr0->array[num_entries], + (*total_entries)); - if ((*snum) >= (*stot)) { - (*snum) = 0; - } + /* move on to creating next connection */ + num_entries++; + } - } else { - ss0->num_entries_read = 0; - ss0->ptr_conn_info = 0; - ss0->num_entries_read2 = 0; + ctr0->count = num_entries; + *total_entries = num_entries; - (*stot) = 0; + if (resume_handle_p) { + if (*resume_handle_p >= *total_entries) { + *resume_handle_p = 0; + } else { + *resume_handle_p = resume_handle; + } } -} - -/******************************************************************* - fill in a conn info level 1 structure. - ********************************************************************/ -static void init_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1, - uint32 id, uint32 type, - uint32 num_opens, uint32 num_users, uint32 open_time, - const char *usr_name, const char *net_name) -{ - init_srv_conn_info1(se1 , id, type, num_opens, num_users, open_time, usr_name, net_name); - init_srv_conn_info1_str(str1, usr_name, net_name); + return WERR_OK; } /******************************************************************* fill in a conn info level 1 structure. ********************************************************************/ -static void init_srv_conn_info_1(SRV_CONN_INFO_1 *ss1, uint32 *snum, uint32 *stot) +static WERROR init_srv_conn_info_1(struct srvsvc_NetConnCtr1 *ctr1, + uint32_t *resume_handle_p, + uint32_t *total_entries) { - uint32 num_entries = 0; - (*stot) = 1; - - if (ss1 == NULL) { - (*snum) = 0; - return; - } - - DEBUG(5,("init_srv_conn_1_ss1\n")); + uint32_t num_entries = 0; + uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0; - if (snum) { - for (; (*snum) < (*stot) && num_entries < MAX_CONN_ENTRIES; (*snum)++) { - init_srv_conn_1_info(&ss1->info_1[num_entries], - &ss1->info_1_str[num_entries], - (*stot), 0x3, 1, 1, 3,"dummy_user", "IPC$"); + DEBUG(5,("init_srv_conn_info_1\n")); - /* move on to creating next connection */ - /* move on to creating next conn */ - num_entries++; + if (ctr1 == NULL) { + if (resume_handle_p) { + *resume_handle_p = 0; } + return WERR_OK; + } - ss1->num_entries_read = num_entries; - ss1->ptr_conn_info = num_entries > 0 ? 1 : 0; - ss1->num_entries_read2 = num_entries; + *total_entries = 1; + ZERO_STRUCTP(ctr1); - if ((*snum) >= (*stot)) { - (*snum) = 0; + for (; (resume_handle < *total_entries) && num_entries < MAX_CONN_ENTRIES; resume_handle++) { + + ctr1->array = TALLOC_REALLOC_ARRAY(talloc_tos(), + ctr1->array, + struct srvsvc_NetConnInfo1, + num_entries+1); + if (!ctr1->array) { + return WERR_NOMEM; } - } else { - ss1->num_entries_read = 0; - ss1->ptr_conn_info = 0; - ss1->num_entries_read2 = 0; + init_srvsvc_NetConnInfo1(&ctr1->array[num_entries], + (*total_entries), + 0x3, + 1, + 1, + 3, + "dummy_user", + "IPC$"); - (*stot) = 0; + /* move on to creating next connection */ + num_entries++; } -} - -/******************************************************************* - makes a SRV_R_NET_CONN_ENUM structure. -********************************************************************/ -static WERROR init_srv_conn_info_ctr(SRV_CONN_INFO_CTR *ctr, - int switch_value, uint32 *resume_hnd, uint32 *total_entries) -{ - WERROR status = WERR_OK; - DEBUG(5,("init_srv_conn_info_ctr: %d\n", __LINE__)); + ctr1->count = num_entries; + *total_entries = num_entries; - ctr->switch_value = switch_value; - - switch (switch_value) { - case 0: - init_srv_conn_info_0(&ctr->conn.info0, resume_hnd, total_entries); - ctr->ptr_conn_ctr = 1; - break; - case 1: - init_srv_conn_info_1(&ctr->conn.info1, resume_hnd, total_entries); - ctr->ptr_conn_ctr = 1; - break; - default: - DEBUG(5,("init_srv_conn_info_ctr: unsupported switch value %d\n", switch_value)); - (*resume_hnd = 0); - (*total_entries) = 0; - ctr->ptr_conn_ctr = 0; - status = WERR_UNKNOWN_LEVEL; - break; + if (resume_handle_p) { + if (*resume_handle_p >= *total_entries) { + *resume_handle_p = 0; + } else { + *resume_handle_p = resume_handle; + } } - return status; -} - -/******************************************************************* - makes a SRV_R_NET_CONN_ENUM structure. -********************************************************************/ - -static void init_srv_r_net_conn_enum(SRV_R_NET_CONN_ENUM *r_n, - uint32 resume_hnd, int conn_level, int switch_value) -{ - DEBUG(5,("init_srv_r_net_conn_enum: %d\n", __LINE__)); - - r_n->conn_level = conn_level; - if (conn_level == -1) - r_n->status = WERR_UNKNOWN_LEVEL; - else - r_n->status = init_srv_conn_info_ctr(r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); - - if (!W_ERROR_IS_OK(r_n->status)) - resume_hnd = 0; - - init_enum_hnd(&r_n->enum_hnd, resume_hnd); + return WERR_OK; } /******************************************************************* @@ -1212,28 +1173,34 @@ WERROR _srvsvc_NetSrvSetInfo(pipes_struct *p, } /******************************************************************* -net conn enum + _srvsvc_NetConnEnum ********************************************************************/ -WERROR _srv_net_conn_enum(pipes_struct *p, SRV_Q_NET_CONN_ENUM *q_u, SRV_R_NET_CONN_ENUM *r_u) +WERROR _srvsvc_NetConnEnum(pipes_struct *p, + struct srvsvc_NetConnEnum *r) { - DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); - - r_u->ctr = TALLOC_P(p->mem_ctx, SRV_CONN_INFO_CTR); - if (!r_u->ctr) - return WERR_NOMEM; + WERROR werr; - ZERO_STRUCTP(r_u->ctr); + DEBUG(5,("_srvsvc_NetConnEnum: %d\n", __LINE__)); - /* set up the */ - init_srv_r_net_conn_enum(r_u, - get_enum_hnd(&q_u->enum_hnd), - q_u->conn_level, - q_u->ctr->switch_value); + switch (r->in.info_ctr->level) { + case 0: + werr = init_srv_conn_info_0(r->in.info_ctr->ctr.ctr0, + r->in.resume_handle, + r->out.totalentries); + break; + case 1: + werr = init_srv_conn_info_1(r->in.info_ctr->ctr.ctr1, + r->in.resume_handle, + r->out.totalentries); + break; + default: + return WERR_UNKNOWN_LEVEL; + } - DEBUG(5,("srv_net_conn_enum: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetConnEnum: %d\n", __LINE__)); - return r_u->status; + return werr; } /******************************************************************* @@ -2479,12 +2446,6 @@ WERROR _srvsvc_NetCharDevQPurgeSelf(pipes_struct *p, struct srvsvc_NetCharDevQPu return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetConnEnum(pipes_struct *p, struct srvsvc_NetConnEnum *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetFileGetInfo(pipes_struct *p, struct srvsvc_NetFileGetInfo *r) { p->rng_fault_state = True; -- cgit From 08213f706ed600efc6afa5f4bb2cb7e603ee193e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 21 Mar 2008 03:51:37 +0100 Subject: Use pidl for _srvsvc_NetSessEnum(). Guenther (This used to be commit 5d14938b14f8e59608771b1899fd473d63f3bde1) --- source3/rpc_server/srv_srvsvc.c | 21 +--- source3/rpc_server/srv_srvsvc_nt.c | 228 ++++++++++++++++--------------------- 2 files changed, 96 insertions(+), 153 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 9c27f13c4c..3a7340c0fa 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -88,26 +88,7 @@ static bool api_srv_net_conn_enum(pipes_struct *p) static bool api_srv_net_sess_enum(pipes_struct *p) { - SRV_Q_NET_SESS_ENUM q_u; - SRV_R_NET_SESS_ENUM r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - /* grab the net server get enum */ - if (!srv_io_q_net_sess_enum("", &q_u, data, 0)) - return False; - - /* construct reply. always indicate success */ - r_u.status = _srv_net_sess_enum(p, &q_u, &r_u); - - /* store the response in the SMB stream */ - if (!srv_io_r_net_sess_enum("", &r_u, rdata, 0)) - return False; - - return True; + return proxy_srvsvc_call(p, NDR_SRVSVC_NETSESSENUM); } /******************************************************************* diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 5478a73534..c8f21b76bb 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -711,40 +711,49 @@ static WERROR init_srv_share_info_ctr(pipes_struct *p, fill in a sess info level 0 structure. ********************************************************************/ -static void init_srv_sess_info_0(pipes_struct *p, SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot) +static WERROR init_srv_sess_info_0(pipes_struct *p, + struct srvsvc_NetSessCtr0 *ctr0, + uint32_t *resume_handle_p, + uint32_t *total_entries) { struct sessionid *session_list; - uint32 num_entries = 0; - (*stot) = list_sessions(p->mem_ctx, &session_list); + uint32_t num_entries = 0; + uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0; + *total_entries = list_sessions(p->mem_ctx, &session_list); - if (ss0 == NULL) { - if (snum) { - (*snum) = 0; + DEBUG(5,("init_srv_sess_info_0\n")); + + if (ctr0 == NULL) { + if (resume_handle_p) { + *resume_handle_p = 0; } - return; + return WERR_OK; } - DEBUG(5,("init_srv_sess_0_ss0\n")); + for (; resume_handle < *total_entries && num_entries < MAX_SESS_ENTRIES; resume_handle++) { - if (snum) { - for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { - init_srv_sess_info0( &ss0->info_0[num_entries], session_list[(*snum)].remote_machine); - num_entries++; - } + ctr0->array = TALLOC_REALLOC_ARRAY(p->mem_ctx, + ctr0->array, + struct srvsvc_NetSessInfo0, + num_entries+1); + W_ERROR_HAVE_NO_MEMORY(ctr0->array); - ss0->num_entries_read = num_entries; - ss0->ptr_sess_info = num_entries > 0 ? 1 : 0; - ss0->num_entries_read2 = num_entries; + init_srvsvc_NetSessInfo0(&ctr0->array[num_entries], + session_list[resume_handle].remote_machine); + num_entries++; + } - if ((*snum) >= (*stot)) { - (*snum) = 0; - } + ctr0->count = num_entries; - } else { - ss0->num_entries_read = 0; - ss0->ptr_sess_info = 0; - ss0->num_entries_read2 = 0; + if (resume_handle_p) { + if (*resume_handle_p >= *total_entries) { + *resume_handle_p = 0; + } else { + *resume_handle_p = resume_handle; + } } + + return WERR_OK; } /******************************************************************* @@ -783,119 +792,70 @@ static int net_count_files( uid_t uid, struct server_id pid ) fill in a sess info level 1 structure. ********************************************************************/ -static void init_srv_sess_info_1(pipes_struct *p, SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot) +static WERROR init_srv_sess_info_1(pipes_struct *p, + struct srvsvc_NetSessCtr1 *ctr1, + uint32_t *resume_handle_p, + uint32_t *total_entries) { struct sessionid *session_list; - uint32 num_entries = 0; + uint32_t num_entries = 0; time_t now = time(NULL); + uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0; - if ( !snum ) { - ss1->num_entries_read = 0; - ss1->ptr_sess_info = 0; - ss1->num_entries_read2 = 0; - - (*stot) = 0; - - return; - } + ZERO_STRUCTP(ctr1); - if (ss1 == NULL) { - (*snum) = 0; - return; + if (ctr1 == NULL) { + if (resume_handle_p) { + *resume_handle_p = 0; + } + return WERR_OK; } - (*stot) = list_sessions(p->mem_ctx, &session_list); + *total_entries = list_sessions(p->mem_ctx, &session_list); - - for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) { + for (; resume_handle < *total_entries && num_entries < MAX_SESS_ENTRIES; resume_handle++) { uint32 num_files; uint32 connect_time; - struct passwd *pw = sys_getpwnam(session_list[*snum].username); + struct passwd *pw = sys_getpwnam(session_list[resume_handle].username); bool guest; if ( !pw ) { DEBUG(10,("init_srv_sess_info_1: failed to find owner: %s\n", - session_list[*snum].username)); + session_list[resume_handle].username)); continue; } - connect_time = (uint32)(now - session_list[*snum].connect_start); - num_files = net_count_files(pw->pw_uid, session_list[*snum].pid); - guest = strequal( session_list[*snum].username, lp_guestaccount() ); + connect_time = (uint32_t)(now - session_list[resume_handle].connect_start); + num_files = net_count_files(pw->pw_uid, session_list[resume_handle].pid); + guest = strequal( session_list[resume_handle].username, lp_guestaccount() ); - init_srv_sess_info1( &ss1->info_1[num_entries], - session_list[*snum].remote_machine, - session_list[*snum].username, - num_files, - connect_time, - 0, - guest); + ctr1->array = TALLOC_REALLOC_ARRAY(p->mem_ctx, + ctr1->array, + struct srvsvc_NetSessInfo1, + num_entries+1); + W_ERROR_HAVE_NO_MEMORY(ctr1->array); + + init_srvsvc_NetSessInfo1(&ctr1->array[num_entries], + session_list[resume_handle].remote_machine, + session_list[resume_handle].username, + num_files, + connect_time, + 0, + guest); num_entries++; } - ss1->num_entries_read = num_entries; - ss1->ptr_sess_info = num_entries > 0 ? 1 : 0; - ss1->num_entries_read2 = num_entries; - - if ((*snum) >= (*stot)) { - (*snum) = 0; - } - -} - -/******************************************************************* - makes a SRV_R_NET_SESS_ENUM structure. -********************************************************************/ - -static WERROR init_srv_sess_info_ctr(pipes_struct *p, SRV_SESS_INFO_CTR *ctr, - int switch_value, uint32 *resume_hnd, uint32 *total_entries) -{ - WERROR status = WERR_OK; - DEBUG(5,("init_srv_sess_info_ctr: %d\n", __LINE__)); - - ctr->switch_value = switch_value; + ctr1->count = num_entries; - switch (switch_value) { - case 0: - init_srv_sess_info_0(p, &(ctr->sess.info0), resume_hnd, total_entries); - ctr->ptr_sess_ctr = 1; - break; - case 1: - init_srv_sess_info_1(p, &(ctr->sess.info1), resume_hnd, total_entries); - ctr->ptr_sess_ctr = 1; - break; - default: - DEBUG(5,("init_srv_sess_info_ctr: unsupported switch value %d\n", switch_value)); - (*resume_hnd) = 0; - (*total_entries) = 0; - ctr->ptr_sess_ctr = 0; - status = WERR_UNKNOWN_LEVEL; - break; + if (resume_handle_p) { + if (*resume_handle_p >= *total_entries) { + *resume_handle_p = 0; + } else { + *resume_handle_p = resume_handle; + } } - return status; -} - -/******************************************************************* - makes a SRV_R_NET_SESS_ENUM structure. -********************************************************************/ - -static void init_srv_r_net_sess_enum(pipes_struct *p, SRV_R_NET_SESS_ENUM *r_n, - uint32 resume_hnd, int sess_level, int switch_value) -{ - DEBUG(5,("init_srv_r_net_sess_enum: %d\n", __LINE__)); - - r_n->sess_level = sess_level; - - if (sess_level == -1) - r_n->status = WERR_UNKNOWN_LEVEL; - else - r_n->status = init_srv_sess_info_ctr(p, r_n->ctr, switch_value, &resume_hnd, &r_n->total_entries); - - if (!W_ERROR_IS_OK(r_n->status)) - resume_hnd = 0; - - init_enum_hnd(&r_n->enum_hnd, resume_hnd); + return WERR_OK; } /******************************************************************* @@ -1204,28 +1164,36 @@ WERROR _srvsvc_NetConnEnum(pipes_struct *p, } /******************************************************************* -net sess enum + _srvsvc_NetSessEnum ********************************************************************/ -WERROR _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_SESS_ENUM *r_u) +WERROR _srvsvc_NetSessEnum(pipes_struct *p, + struct srvsvc_NetSessEnum *r) { - DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__)); - - r_u->ctr = TALLOC_P(p->mem_ctx, SRV_SESS_INFO_CTR); - if (!r_u->ctr) - return WERR_NOMEM; + WERROR werr; - ZERO_STRUCTP(r_u->ctr); + DEBUG(5,("_srvsvc_NetSessEnum: %d\n", __LINE__)); - /* set up the */ - init_srv_r_net_sess_enum(p, r_u, - get_enum_hnd(&q_u->enum_hnd), - q_u->sess_level, - q_u->ctr->switch_value); + switch (r->in.info_ctr->level) { + case 0: + werr = init_srv_sess_info_0(p, + r->in.info_ctr->ctr.ctr0, + r->in.resume_handle, + r->out.totalentries); + break; + case 1: + werr = init_srv_sess_info_1(p, + r->in.info_ctr->ctr.ctr1, + r->in.resume_handle, + r->out.totalentries); + break; + default: + return WERR_UNKNOWN_LEVEL; + } - DEBUG(5,("_srv_net_sess_enum: %d\n", __LINE__)); + DEBUG(5,("_srvsvc_NetSessEnum: %d\n", __LINE__)); - return r_u->status; + return werr; } /******************************************************************* @@ -2452,12 +2420,6 @@ WERROR _srvsvc_NetFileGetInfo(pipes_struct *p, struct srvsvc_NetFileGetInfo *r) return WERR_NOT_SUPPORTED; } -WERROR _srvsvc_NetSessEnum(pipes_struct *p, struct srvsvc_NetSessEnum *r) -{ - p->rng_fault_state = True; - return WERR_NOT_SUPPORTED; -} - WERROR _srvsvc_NetShareCheck(pipes_struct *p, struct srvsvc_NetShareCheck *r) { p->rng_fault_state = True; -- cgit From 1dc52e8fbf1d9e56ff7fdcd1c637e21e6b23e456 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 21 Mar 2008 03:56:54 +0100 Subject: Move MAX.*ENTRY definitions out of old rpc srvsvc parsing code. Guenther (This used to be commit 4e36657275caa77bc9712fe627aeb6fe4aefc151) --- source3/rpc_server/srv_srvsvc_nt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index c8f21b76bb..adbe3f684b 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -29,6 +29,21 @@ extern const struct generic_mapping file_generic_mapping; #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +#define MAX_SERVER_DISK_ENTRIES 15 + +/***************************/ + +/* oops - this is going to take up a *massive* amount of stack. */ +/* the UNISTR2s already have 1024 uint16 chars in them... */ + +#define MAX_SESS_ENTRIES 32 + +/***************************/ + +/* oops - this is going to take up a *massive* amount of stack. */ +/* the UNISTR2s already have 1024 uint16 chars in them... */ +#define MAX_CONN_ENTRIES 32 + /* Use for enumerating connections, pipes, & files */ struct file_enum_count { -- cgit From 5fdf4b8f4ae41bc44cdbfa6ac82d857c3dd955c1 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 21 Mar 2008 04:12:52 +0100 Subject: Remove remaining old srvsvc client and server rpc code entirely. Guenther (This used to be commit a5f0186f70abe8dba650265219e69ce5ca2fb642) --- source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_srvsvc.c | 257 ---------------------------------------- 2 files changed, 1 insertion(+), 258 deletions(-) delete mode 100644 source3/rpc_server/srv_srvsvc.c (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 6c1b65b858..f33ee88aec 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2388,7 +2388,7 @@ void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) netlogon_get_pipe_fns( &cmds, &n_cmds ); break; case PI_SRVSVC: - srvsvc2_get_pipe_fns( &cmds, &n_cmds ); + srvsvc_get_pipe_fns( &cmds, &n_cmds ); break; case PI_WKSSVC: wkssvc_get_pipe_fns( &cmds, &n_cmds ); diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c deleted file mode 100644 index 3a7340c0fa..0000000000 --- a/source3/rpc_server/srv_srvsvc.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1997, - * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, - * Copyright (C) Paul Ashton 1997, - * Copyright (C) Jeremy Allison 2001, - * Copyright (C) Jim McDonough 2003. - * Copyright (C) Gera;d (Jerry) Carter 2006. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ - -/* This is the interface to the srvsvc pipe. */ - -#include "includes.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_SRV - -static bool proxy_srvsvc_call(pipes_struct *p, uint8 opnum) -{ - struct api_struct *fns; - int n_fns; - - srvsvc_get_pipe_fns(&fns, &n_fns); - - if (opnum >= n_fns) - return False; - - if (fns[opnum].opnum != opnum) { - smb_panic("SRVSVC function table not sorted\n"); - } - - return fns[opnum].fn(p); -} - -/******************************************************************* - api_srv_net_srv_get_info -********************************************************************/ - -static bool api_srv_net_srv_get_info(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETSRVGETINFO); -} - -/******************************************************************* - api_srv_net_srv_get_info -********************************************************************/ - -static bool api_srv_net_srv_set_info(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETSRVSETINFO); -} - -/******************************************************************* - api_srv_net_file_enum -********************************************************************/ - -static bool api_srv_net_file_enum(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETFILEENUM); -} - -/******************************************************************* - api_srv_net_conn_enum -********************************************************************/ - -static bool api_srv_net_conn_enum(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETCONNENUM); -} - -/******************************************************************* - Enumerate sessions. -********************************************************************/ - -static bool api_srv_net_sess_enum(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETSESSENUM); -} - -/******************************************************************* - Delete session. -********************************************************************/ - -static bool api_srv_net_sess_del(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETSESSDEL); -} - -/******************************************************************* - RPC to enumerate shares. -********************************************************************/ - -static bool api_srv_net_share_enum_all(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHAREENUMALL); -} - -/******************************************************************* - RPC to enumerate shares. -********************************************************************/ - -static bool api_srv_net_share_enum(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHAREENUM); -} - -/******************************************************************* - RPC to return share information. -********************************************************************/ - -static bool api_srv_net_share_get_info(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHAREGETINFO); -} - -/******************************************************************* - RPC to set share information. -********************************************************************/ - -static bool api_srv_net_share_set_info(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHARESETINFO); -} - -/******************************************************************* - RPC to add share information. -********************************************************************/ - -static bool api_srv_net_share_add(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHAREADD); -} - -/******************************************************************* - RPC to delete share information. -********************************************************************/ - -static bool api_srv_net_share_del(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHAREDEL); -} - -/******************************************************************* - RPC to delete share information. -********************************************************************/ - -static bool api_srv_net_share_del_sticky(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETSHAREDELSTICKY); -} - -/******************************************************************* - api_srv_net_remote_tod -********************************************************************/ - -static bool api_srv_net_remote_tod(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETREMOTETOD); -} - -/******************************************************************* - RPC to enumerate disks available on a server e.g. C:, D: ... -*******************************************************************/ - -static bool api_srv_net_disk_enum(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETDISKENUM); -} - -/******************************************************************* - NetValidateName (opnum 0x21) -*******************************************************************/ - -static bool api_srv_net_name_validate(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETNAMEVALIDATE); -} - -/******************************************************************* - NetFileQuerySecdesc (opnum 0x27) -*******************************************************************/ - -static bool api_srv_net_file_query_secdesc(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETGETFILESECURITY); -} - -/******************************************************************* - NetFileSetSecdesc (opnum 0x28) -*******************************************************************/ - -static bool api_srv_net_file_set_secdesc(pipes_struct *p) -{ - return proxy_srvsvc_call(p, NDR_SRVSVC_NETSETFILESECURITY); -} - -/******************************************************************* -*******************************************************************/ - -static bool api_srv_net_file_close(pipes_struct *p) -{ - return proxy_srvsvc_call( p, NDR_SRVSVC_NETFILECLOSE ); -} - -/******************************************************************* -\PIPE\srvsvc commands -********************************************************************/ - -static struct api_struct api_srv_cmds[] = -{ - { "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum }, - { "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum }, - { "SRV_NET_SESS_DEL" , SRV_NET_SESS_DEL , api_srv_net_sess_del }, - { "SRV_NET_SHARE_ENUM_ALL" , SRV_NET_SHARE_ENUM_ALL , api_srv_net_share_enum_all }, - { "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum }, - { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, - { "SRV_NET_SHARE_DEL" , SRV_NET_SHARE_DEL , api_srv_net_share_del }, - { "SRV_NET_SHARE_DEL_STICKY" , SRV_NET_SHARE_DEL_STICKY , api_srv_net_share_del_sticky }, - { "SRV_NET_SHARE_GET_INFO" , SRV_NET_SHARE_GET_INFO , api_srv_net_share_get_info }, - { "SRV_NET_SHARE_SET_INFO" , SRV_NET_SHARE_SET_INFO , api_srv_net_share_set_info }, - { "SRV_NET_FILE_ENUM" , SRV_NET_FILE_ENUM , api_srv_net_file_enum }, - { "SRV_NET_SRV_GET_INFO" , SRV_NET_SRV_GET_INFO , api_srv_net_srv_get_info }, - { "SRV_NET_SRV_SET_INFO" , SRV_NET_SRV_SET_INFO , api_srv_net_srv_set_info }, - { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, - { "SRV_NET_DISK_ENUM" , SRV_NET_DISK_ENUM , api_srv_net_disk_enum }, - { "SRV_NET_NAME_VALIDATE" , SRV_NET_NAME_VALIDATE , api_srv_net_name_validate }, - { "SRV_NET_FILE_QUERY_SECDESC", SRV_NET_FILE_QUERY_SECDESC, api_srv_net_file_query_secdesc }, - { "SRV_NET_FILE_SET_SECDESC" , SRV_NET_FILE_SET_SECDESC , api_srv_net_file_set_secdesc }, - { "SRV_NET_FILE_CLOSE" , SRV_NET_FILE_CLOSE , api_srv_net_file_close } -}; - -void srvsvc2_get_pipe_fns( struct api_struct **fns, int *n_fns ) -{ - *fns = api_srv_cmds; - *n_fns = sizeof(api_srv_cmds) / sizeof(struct api_struct); -} - - -NTSTATUS rpc_srvsvc2_init(void) -{ - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "srvsvc", "ntsvcs", api_srv_cmds, - sizeof(api_srv_cmds) / sizeof(struct api_struct)); -} -- cgit From 7c8e66210d1c327fad0378f3ed215809e02bb0cd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 21 Mar 2008 04:13:49 +0100 Subject: Add my copyright. Guenther (This used to be commit 4689057f63599ebaf9ce658ca3b3168b2bbe531f) --- source3/rpc_server/srv_srvsvc_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index adbe3f684b..a89a99646b 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -5,6 +5,7 @@ * Copyright (C) Jeremy Allison 2001. * Copyright (C) Nigel Williams 2001. * Copyright (C) Gerald (Jerry) Carter 2006. + * Copyright (C) Guenther Deschner 2008. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- cgit From 35cab4a8c27b3471557bbbd04d8bcf49dfec51c0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 21 Mar 2008 10:28:33 +0100 Subject: Fix Coverity ID 548 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Günther, please check -- in all infolevels we do a comment=talloc_strdup Thanks, Volker (This used to be commit e2021c5b5710768968ae724220eb1e3f47c9e639) --- source3/rpc_server/srv_srvsvc_nt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index a89a99646b..8359511939 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1580,6 +1580,10 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, if (type != STYPE_DISKTREE) return WERR_ACCESS_DENIED; + if (comment == NULL) { + return WERR_NOMEM; + } + /* Check if the pathname is valid. */ if (!(path = valid_share_pathname(p->mem_ctx, pathname ))) return WERR_OBJECT_PATH_INVALID; @@ -1587,9 +1591,7 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, /* Ensure share name, pathname and comment don't contain '"' characters. */ string_replace(share_name, '"', ' '); string_replace(path, '"', ' '); - if (comment) { - string_replace(comment, '"', ' '); - } + string_replace(comment, '"', ' '); DEBUG(10,("_srvsvc_NetShareSetInfo: change share command = %s\n", lp_change_share_cmd() ? lp_change_share_cmd() : "NULL" )); -- cgit From bc7a0a9198a6bc26e1ddc7e5f1e52c97a07029a0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 23 Mar 2008 15:58:09 +0100 Subject: Fix Coverity ID 432 (This used to be commit 7070c77ee2a9c3c9ff1b3c7b93008b13b80ac02b) --- source3/rpc_server/srv_eventlog_lib.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c index 269e2f318e..e232a30078 100644 --- a/source3/rpc_server/srv_eventlog_lib.c +++ b/source3/rpc_server/srv_eventlog_lib.c @@ -464,8 +464,6 @@ int write_eventlog_tdb( TDB_CONTEXT * the_tdb, Eventlog_entry * ee ) if ( mem_ctx == NULL ) return 0; - if ( !ee ) - return 0; /* discard any entries that have bogus time, which usually indicates a bogus entry as well. */ if ( ee->record.time_generated == 0 ) return 0; -- cgit From e9ba13bc67576aa70694ce54ca70aef4375ebe13 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 23 Mar 2008 19:43:36 +0100 Subject: Fix Coverity ID 514 Not exactly an uninitialized variable, but having Coverity figure out that we're only UNMARSHALLING here is probably asking for a bit too much. (This used to be commit 07a9f7daa83c94afefe0d81db4812135121862c2) --- source3/rpc_server/srv_pipe.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index f33ee88aec..05cdb65a83 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1593,6 +1593,8 @@ bool api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) } } + ZERO_STRUCT(hdr_rb); + /* decode the bind request */ if(!smb_io_rpc_hdr_rb("", &hdr_rb, rpc_in_p, 0)) { DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_RB struct.\n")); -- cgit From 055224640b6e0804b99f0c2d7f6747079ed4f364 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 25 Mar 2008 10:11:47 +0100 Subject: Fix _winreg_QueryValue(). Guenther (This used to be commit b217dd674e22b6a7cc492f1a84a37ddc4ddca663) --- source3/rpc_server/srv_winreg_nt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 6e076ea372..bf28ba6f84 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -238,7 +238,7 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct winreg_QueryValue *r) /* Handle QueryValue calls on HKEY_PERFORMANCE_DATA */ if(regkey->key->type == REG_KEY_HKPD) { - if(strequal(r->in.value_name.name, "Global")) { + if (strequal(r->in.value_name->name, "Global")) { if (!prs_init(&prs_hkpd, *r->in.data_size, p->mem_ctx, MARSHALL)) return WERR_NOMEM; status = reg_perfcount_get_hkpd( @@ -246,32 +246,32 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct winreg_QueryValue *r) outbuf = (uint8_t *)prs_hkpd.data_p; free_prs = True; } - else if(strequal(r->in.value_name.name, "Counter 009")) { + else if (strequal(r->in.value_name->name, "Counter 009")) { outbuf_size = reg_perfcount_get_counter_names( reg_perfcount_get_base_index(), (char **)(void *)&outbuf); free_buf = True; } - else if(strequal(r->in.value_name.name, "Explain 009")) { + else if (strequal(r->in.value_name->name, "Explain 009")) { outbuf_size = reg_perfcount_get_counter_help( reg_perfcount_get_base_index(), (char **)(void *)&outbuf); free_buf = True; } - else if(isdigit(r->in.value_name.name[0])) { + else if (isdigit(r->in.value_name->name[0])) { /* we probably have a request for a specific object * here */ if (!prs_init(&prs_hkpd, *r->in.data_size, p->mem_ctx, MARSHALL)) return WERR_NOMEM; status = reg_perfcount_get_hkpd( &prs_hkpd, *r->in.data_size, &outbuf_size, - r->in.value_name.name); + r->in.value_name->name); outbuf = (uint8_t *)prs_hkpd.data_p; free_prs = True; } else { DEBUG(3,("Unsupported key name [%s] for HKPD.\n", - r->in.value_name.name)); + r->in.value_name->name)); return WERR_BADFILE; } @@ -280,7 +280,7 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct winreg_QueryValue *r) else { struct registry_value *val; - status = reg_queryvalue(p->mem_ctx, regkey, r->in.value_name.name, + status = reg_queryvalue(p->mem_ctx, regkey, r->in.value_name->name, &val); if (!W_ERROR_IS_OK(status)) { if (r->out.data_size) { -- cgit From f4e1e23e2fb1239036e9035fdf26ac694fbd0b0b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 26 Mar 2008 11:45:28 +0100 Subject: Strip whitespace in ntsvcs rpc server. Guenther (This used to be commit 0c7af8bc136f45484eab3c36b761046f88653b93) --- source3/rpc_server/srv_ntsvcs_nt.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_ntsvcs_nt.c b/source3/rpc_server/srv_ntsvcs_nt.c index 11ea5d0cd1..268da52896 100644 --- a/source3/rpc_server/srv_ntsvcs_nt.c +++ b/source3/rpc_server/srv_ntsvcs_nt.c @@ -1,19 +1,19 @@ -/* +/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * * Copyright (C) Gerald (Jerry) Carter 2005. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ @@ -106,24 +106,24 @@ WERROR _ntsvcs_get_device_reg_property( pipes_struct *p, NTSVCS_Q_GET_DEVICE_REG switch( q_u->property ) { case DEV_REGPROP_DESC: - /* just parse the service name from the device path and then + /* just parse the service name from the device path and then lookup the display name */ if ( !(ptr = strrchr_m( devicepath, '\\' )) ) - return WERR_GENERAL_FAILURE; + return WERR_GENERAL_FAILURE; *ptr = '\0'; - + if ( !(ptr = strrchr_m( devicepath, '_' )) ) - return WERR_GENERAL_FAILURE; + return WERR_GENERAL_FAILURE; ptr++; - + if ( !(values = svcctl_fetch_regvalues( ptr, p->pipe_user.nt_user_token )) ) - return WERR_GENERAL_FAILURE; - + return WERR_GENERAL_FAILURE; + if ( !(val = regval_ctr_getvalue( values, "DisplayName" )) ) { TALLOC_FREE( values ); return WERR_GENERAL_FAILURE; } - + r_u->unknown1 = 0x1; /* always 1...tested using a remove device manager connection */ r_u->size = reg_init_regval_buffer( &r_u->value, val ); r_u->needed = r_u->size; @@ -131,7 +131,7 @@ WERROR _ntsvcs_get_device_reg_property( pipes_struct *p, NTSVCS_Q_GET_DEVICE_REG TALLOC_FREE(values); break; - + default: r_u->unknown1 = 0x00437c98; return WERR_CM_NO_SUCH_VALUE; -- cgit From 63b49e1f6e166f9a884fed810294bdc3f0b8c0d2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 26 Mar 2008 19:18:08 +0100 Subject: Fix _netr_LogonControl2(). Return talloced dcname. Guenther (This used to be commit 42971b71acec9c9fd94011c06d41702dac6b4f87) --- source3/rpc_server/srv_netlog_nt.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 5b26f55845..f4967dc548 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -136,7 +136,8 @@ WERROR _netr_LogonControl2(pipes_struct *p, uint32 pdc_connection_status = 0x0; uint32 logon_attempts = 0x0; uint32 tc_status; - fstring dc_name, dc_name2; + fstring dc_name2; + const char *dc_name = NULL; struct sockaddr_storage dc_ss; const char *domain = NULL; struct netr_NETLOGON_INFO_1 *info1; @@ -144,7 +145,6 @@ WERROR _netr_LogonControl2(pipes_struct *p, struct netr_NETLOGON_INFO_3 *info3; tc_status = W_ERROR_V(WERR_NO_SUCH_DOMAIN); - fstrcpy( dc_name, "" ); switch (r->in.function_code) { case NETLOGON_CONTROL_TC_QUERY: @@ -158,7 +158,10 @@ WERROR _netr_LogonControl2(pipes_struct *p, break; } - fstr_sprintf( dc_name, "\\\\%s", dc_name2 ); + dc_name = talloc_asprintf(p->mem_ctx, "\\\\%s", dc_name2); + if (!dc_name) { + return WERR_NOMEM; + } tc_status = W_ERROR_V(WERR_OK); @@ -175,7 +178,10 @@ WERROR _netr_LogonControl2(pipes_struct *p, break; } - fstr_sprintf( dc_name, "\\\\%s", dc_name2 ); + dc_name = talloc_asprintf(p->mem_ctx, "\\\\%s", dc_name2); + if (!dc_name) { + return WERR_NOMEM; + } tc_status = W_ERROR_V(WERR_OK); -- cgit From b1198fc9fdc086f025ee05f3b2a382947d037b68 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 27 Mar 2008 13:03:12 +0100 Subject: Fix samlogon rpc client & server. Guenther (This used to be commit 0aaf975560dce3b4e58ab71687c3412c0c2a72cf) --- source3/rpc_server/srv_netlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index f4967dc548..4664e8d1ba 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -786,7 +786,7 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p, { NTSTATUS status = NT_STATUS_OK; struct netr_SamInfo3 *sam3 = NULL; - union netr_LogonLevel *logon = r->in.logon; + union netr_LogonInfo *logon = r->in.logon; fstring nt_username, nt_domain, nt_workstation; auth_usersupplied_info *user_info = NULL; auth_serversupplied_info *server_info = NULL; -- cgit From 4c17fce8dc615d9b9dc50cebe63d5b5054936a3c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 27 Mar 2008 22:55:20 +0100 Subject: Make sure to zero the returned handle in _svcctl_CloseServiceHandle(). Guenther (This used to be commit 84a079af490cb135dd557091932ea079e1d7ff5b) --- source3/rpc_server/srv_svcctl_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_svcctl_nt.c b/source3/rpc_server/srv_svcctl_nt.c index c117d46fde..6bb538a311 100644 --- a/source3/rpc_server/srv_svcctl_nt.c +++ b/source3/rpc_server/srv_svcctl_nt.c @@ -328,6 +328,8 @@ WERROR _svcctl_CloseServiceHandle(pipes_struct *p, struct svcctl_CloseServiceHan if ( !close_policy_hnd( p, r->in.handle ) ) return WERR_BADFID; + ZERO_STRUCTP(r->out.handle); + return WERR_OK; } -- cgit From ed27b352effb87e4394f73decd30eaebf26b36a9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 28 Mar 2008 13:53:33 +0100 Subject: Let libnetjoin find the dc in wkssvc NetrJoinDomain2/UnjoinDomain2. Guenther (This used to be commit 9e7d673ac44f500863bcbd0198452adc7c5027f9) --- source3/rpc_server/srv_wkssvc_nt.c | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 6d03009d00..f864aad86a 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -292,9 +292,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, char *admin_domain = NULL; char *admin_account = NULL; WERROR werr; - NTSTATUS status; struct nt_user_token *token = p->pipe_user.nt_user_token; - struct netr_DsRGetDCNameInfo *info = NULL; if (!r->in.domain_name) { return WERR_INVALID_PARAM; @@ -321,24 +319,11 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, &admin_domain, &admin_account); - status = dsgetdcname(p->mem_ctx, - r->in.domain_name, - NULL, - NULL, - DS_DIRECTORY_SERVICE_REQUIRED | - DS_WRITABLE_REQUIRED | - DS_RETURN_DNS_NAME, - &info); - if (!NT_STATUS_IS_OK(status)) { - return ntstatus_to_werror(status); - } - werr = libnet_init_JoinCtx(p->mem_ctx, &j); if (!W_ERROR_IS_OK(werr)) { return werr; } - j->in.dc_name = info->dc_unc; j->in.domain_name = r->in.domain_name; j->in.account_ou = r->in.account_ou; j->in.join_flags = r->in.join_flags; @@ -372,9 +357,7 @@ WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, char *admin_domain = NULL; char *admin_account = NULL; WERROR werr; - NTSTATUS status; struct nt_user_token *token = p->pipe_user.nt_user_token; - struct netr_DsRGetDCNameInfo *info = NULL; if (!user_has_privileges(token, &se_machine_account) && !nt_token_check_domain_rid(token, DOMAIN_GROUP_RID_ADMINS) && @@ -397,24 +380,11 @@ WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, &admin_domain, &admin_account); - status = dsgetdcname(p->mem_ctx, - lp_realm(), - NULL, - NULL, - DS_DIRECTORY_SERVICE_REQUIRED | - DS_WRITABLE_REQUIRED | - DS_RETURN_DNS_NAME, - &info); - if (!NT_STATUS_IS_OK(status)) { - return ntstatus_to_werror(status); - } - werr = libnet_init_UnjoinCtx(p->mem_ctx, &u); if (!W_ERROR_IS_OK(werr)) { return werr; } - u->in.dc_name = info->dc_unc; u->in.domain_name = lp_realm(); u->in.unjoin_flags = r->in.unjoin_flags | WKSSVC_JOIN_FLAGS_JOIN_TYPE; -- cgit From cc2f5fd1b5aa7e7a7277557edfd4b94b0d10661d Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 28 Mar 2008 15:39:52 +0100 Subject: srv_winreg: add a debug message to _winreg_CreateKey(). Michael (This used to be commit 971f6749ed23523f6eafe5136f6d4c920c20aec4) --- source3/rpc_server/srv_winreg_nt.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index bf28ba6f84..7b74871104 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -740,6 +740,9 @@ WERROR _winreg_CreateKey( pipes_struct *p, struct winreg_CreateKey *r) if ( !parent ) return WERR_BADFID; + DEBUG(10, ("_winreg_CreateKey called with parent key '%s' and " + "subkey name '%s'\n", parent->key->name, r->in.name.name)); + result = reg_createkey(NULL, parent, r->in.name.name, r->in.access_mask, &new_key, r->out.action_taken); if (!W_ERROR_IS_OK(result)) { -- cgit From 921bdec52d449a23fc58b726489d7ffce58cd9e8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 28 Mar 2008 23:39:57 +0100 Subject: Add some paranoia fixes for _wkssvc_NetrJoinDomain2/UnjoinDomain2. Guenther (This used to be commit 72101a7d0868b19a413b17f8142637f92c6cdad5) --- source3/rpc_server/srv_wkssvc_nt.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index f864aad86a..32d315f96f 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -4,7 +4,8 @@ * * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Gerald (Jerry) Carter 2006. - * + * Copyright (C) Guenther Deschner 2007-2008. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or @@ -298,6 +299,10 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, return WERR_INVALID_PARAM; } + if (!r->in.admin_account || !r->in.encrypted_password) { + return WERR_INVALID_PARAM; + } + if (!user_has_privileges(token, &se_machine_account) && !nt_token_check_domain_rid(token, DOMAIN_GROUP_RID_ADMINS) && !nt_token_check_domain_rid(token, BUILTIN_ALIAS_RID_ADMINS)) { @@ -306,6 +311,11 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, return WERR_ACCESS_DENIED; } + if ((r->in.join_flags & WKSSVC_JOIN_FLAGS_MACHINE_PWD_PASSED) || + (r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_UNSECURE)) { + return WERR_NOT_SUPPORTED; + } + werr = decode_wkssvc_join_password_buffer(p->mem_ctx, r->in.encrypted_password, &p->session_key, @@ -336,7 +346,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, unbecome_root(); if (!W_ERROR_IS_OK(werr)) { - DEBUG(5,("_wkssvc_NetrJoinDomain2: libnet_Join gave %s\n", + DEBUG(5,("_wkssvc_NetrJoinDomain2: libnet_Join failed with: %s\n", j->out.error_string ? j->out.error_string : dos_errstr(werr))); } @@ -359,6 +369,10 @@ WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, WERROR werr; struct nt_user_token *token = p->pipe_user.nt_user_token; + if (!r->in.account || !r->in.encrypted_password) { + return WERR_INVALID_PARAM; + } + if (!user_has_privileges(token, &se_machine_account) && !nt_token_check_domain_rid(token, DOMAIN_GROUP_RID_ADMINS) && !nt_token_check_domain_rid(token, BUILTIN_ALIAS_RID_ADMINS)) { @@ -396,6 +410,12 @@ WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, werr = libnet_Unjoin(p->mem_ctx, u); unbecome_root(); + if (!W_ERROR_IS_OK(werr)) { + DEBUG(5,("_wkssvc_NetrUnjoinDomain2: libnet_Unjoin failed with: %s\n", + u->out.error_string ? u->out.error_string : + dos_errstr(werr))); + } + TALLOC_FREE(u); return werr; } -- cgit From e8775623bdf40dab976c4540771e5078d632fe01 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 31 Mar 2008 20:40:16 +0200 Subject: Add init_samr_parameters_string(). Guenther (This used to be commit 8f6f0d1601cb93af51f8d493382cd707c3eb0cdf) --- source3/rpc_server/srv_samr_nt.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index eeb3e400dd..034392ed21 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2154,6 +2154,41 @@ NTSTATUS _samr_OpenUser(pipes_struct *p, return NT_STATUS_OK; } +/************************************************************************* + *************************************************************************/ + +static NTSTATUS init_samr_parameters_string(TALLOC_CTX *mem_ctx, + DATA_BLOB *blob, + struct lsa_BinaryString **_r) +{ + struct lsa_BinaryString *r; + + if (!blob || !_r) { + return NT_STATUS_INVALID_PARAMETER; + } + + r = TALLOC_ZERO_P(mem_ctx, struct lsa_BinaryString); + if (!r) { + return NT_STATUS_NO_MEMORY; + } + + r->array = TALLOC_ZERO_ARRAY(mem_ctx, uint16_t, blob->length/2); + if (!r->array) { + return NT_STATUS_NO_MEMORY; + } + memcpy(r->array, blob->data, blob->length); + r->size = blob->length; + r->length = blob->length; + + if (!r->array) { + return NT_STATUS_NO_MEMORY; + } + + *_r = r; + + return NT_STATUS_OK; +} + /************************************************************************* get_user_info_7. Safe. Only gives out account_name. *************************************************************************/ -- cgit From 4369c14a66060021259308d1c42372e75455953f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 31 Mar 2008 20:43:18 +0200 Subject: Re-add support for the samr parameters string. (dialin settings, terminal server settings, etc.) Guenther (This used to be commit c4f248df8e34c6a028bf8d789fe9763b0ea063fe) --- source3/rpc_server/srv_samr_nt.c | 51 ++++++++++++++++---------------------- source3/rpc_server/srv_samr_util.c | 17 ++++++------- 2 files changed, 30 insertions(+), 38 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 034392ed21..0f4a5b9ae1 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2368,8 +2368,9 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, struct samu *sampass=NULL; bool ret; const char *munged_dial = NULL; - const char *munged_dial_decoded = NULL; DATA_BLOB blob; + NTSTATUS status; + struct lsa_BinaryString *parameters = NULL; ZERO_STRUCTP(r); @@ -2391,28 +2392,23 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, samr_clear_sam_passwd(sampass); - DEBUG(3,("User:[%s]\n", pdb_get_username(sampass) )); + DEBUG(3,("User:[%s] has [%s] (length: %d)\n", pdb_get_username(sampass), + munged_dial, strlen(munged_dial))); if (munged_dial) { blob = base64_decode_data_blob(munged_dial); - munged_dial_decoded = talloc_strndup(mem_ctx, - (const char *)blob.data, - blob.length); - data_blob_free(&blob); - if (!munged_dial_decoded) { - TALLOC_FREE(sampass); - return NT_STATUS_NO_MEMORY; - } + } else { + blob = data_blob_string_const(""); } -#if 0 - init_unistr2_from_datablob(&usr->uni_munged_dial, &blob); - init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial); + status = init_samr_parameters_string(mem_ctx, &blob, ¶meters); data_blob_free(&blob); -#endif - init_samr_user_info20(r, munged_dial_decoded); - TALLOC_FREE(sampass); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + init_samr_user_info20(r, parameters); return NT_STATUS_OK; } @@ -2427,6 +2423,7 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, DOM_SID *user_sid, DOM_SID *domain_sid) { + NTSTATUS status; struct samu *pw = NULL; bool ret; const DOM_SID *sid_user, *sid_group; @@ -2437,8 +2434,9 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, uint8_t password_expired; const char *account_name, *full_name, *home_directory, *home_drive, *logon_script, *profile_path, *description, - *workstations, *comment, *parameters; + *workstations, *comment; struct samr_LogonHours logon_hours; + struct lsa_BinaryString *parameters = NULL; const char *munged_dial = NULL; DATA_BLOB blob; @@ -2508,16 +2506,16 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, munged_dial = pdb_get_munged_dial(pw); if (munged_dial) { blob = base64_decode_data_blob(munged_dial); - parameters = talloc_strndup(mem_ctx, (const char *)blob.data, blob.length); - data_blob_free(&blob); - if (!parameters) { - TALLOC_FREE(pw); - return NT_STATUS_NO_MEMORY; - } } else { - parameters = NULL; + blob = data_blob_string_const(""); } + status = init_samr_parameters_string(mem_ctx, &blob, ¶meters); + data_blob_free(&blob); + if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(pw); + return status; + } account_name = talloc_strdup(mem_ctx, pdb_get_username(pw)); full_name = talloc_strdup(mem_ctx, pdb_get_fullname(pw)); @@ -2542,11 +2540,6 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, -- Volker */ -#if 0 - init_unistr2_from_datablob(&usr->uni_munged_dial, &munged_dial_blob); - init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial); - data_blob_free(&munged_dial_blob); -#endif #endif init_samr_user_info21(r, diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 688d72064f..74daf46e84 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -50,11 +50,10 @@ void copy_id20_to_sam_passwd(struct samu *to, return; } - if (from->parameters.string) { + if (from->parameters.array) { old_string = pdb_get_munged_dial(to); - mung.length = from->parameters.length; - mung.data = (uint8_t *)from->parameters.string; - mung.free = NULL; + mung = data_blob_const(from->parameters.array, + from->parameters.length); new_string = (mung.length == 0) ? NULL : base64_encode_data_blob(talloc_tos(), mung); DEBUG(10,("INFO_20 PARAMETERS: %s -> %s\n", @@ -77,7 +76,6 @@ void copy_id21_to_sam_passwd(const char *log_prefix, { time_t unix_time, stored_time; const char *old_string, *new_string; - DATA_BLOB mung; const char *l; if (from == NULL || to == NULL) { @@ -234,12 +232,13 @@ void copy_id21_to_sam_passwd(const char *log_prefix, } if ((from->fields_present & SAMR_FIELD_PARAMETERS) && - (from->parameters.string)) { + (from->parameters.array)) { char *newstr; + DATA_BLOB mung; old_string = pdb_get_munged_dial(to); - mung.length = from->parameters.length; - mung.data = (uint8_t *)from->parameters.string; - mung.free = NULL; + + mung = data_blob_const(from->parameters.array, + from->parameters.length); newstr = (mung.length == 0) ? NULL : base64_encode_data_blob(talloc_tos(), mung); DEBUG(10,("%s SAMR_FIELD_PARAMETERS: %s -> %s\n", l, -- cgit From dbe34cf0aeaeb66d3d505845b2b2c4ec5572741a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 31 Mar 2008 22:49:03 +0200 Subject: Fix _srvsvc_NetShareSetInfo. Guenther (This used to be commit 2fd90b62d7e61fa0c23f8f41e9f12fc16f29a8b1) --- source3/rpc_server/srv_srvsvc_nt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 8359511939..6d7561ed5f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1484,7 +1484,9 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, return WERR_NOMEM; } - *r->out.parm_error = 0; + if (r->out.parm_error) { + *r->out.parm_error = 0; + } if ( strequal(share_name,"IPC$") || ( lp_enable_asu_support() && strequal(share_name,"ADMIN$") ) @@ -1515,8 +1517,8 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, switch (r->in.level) { case 1: pathname = talloc_strdup(ctx, lp_pathname(snum)); - comment = talloc_strdup(ctx, info->info2->comment); - type = info->info2->type; + comment = talloc_strdup(ctx, info->info1->comment); + type = info->info1->type; psd = NULL; break; case 2: -- cgit From 9afc225b377c29a851150af2fddfb26050cbf4a9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 31 Mar 2008 23:51:34 +0200 Subject: Fix SRVSVC ShareInfo max_users handling server side. Guenther (This used to be commit b4d944e724f7ae2a97ba788b185aba7b7308b475) --- source3/rpc_server/srv_srvsvc_nt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 6d7561ed5f..57b42af4e5 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -291,7 +291,7 @@ static void init_srv_share_info_2(pipes_struct *p, struct srvsvc_NetShareInfo2 * char *remark = NULL; char *path = NULL; int max_connections = lp_max_connections(snum); - uint32 max_uses = max_connections!=0 ? max_connections : 0xffffffff; + uint32_t max_uses = max_connections!=0 ? max_connections : (uint32_t)-1; int count = 0; char *net_name = lp_servicename(snum); @@ -401,7 +401,7 @@ static void init_srv_share_info_502(pipes_struct *p, struct srvsvc_NetShareInfo5 get_share_type(snum), remark ? remark : "", 0, - 0xffffffff, + (uint32_t)-1, 1, path ? path : "", "", @@ -447,7 +447,7 @@ static void init_srv_share_info_1005(pipes_struct *p, struct srvsvc_NetShareInfo static void init_srv_share_info_1006(pipes_struct *p, struct srvsvc_NetShareInfo1006 *r, int snum) { - init_srvsvc_NetShareInfo1006(r, 0xffffffff); + init_srvsvc_NetShareInfo1006(r, (uint32_t)-1); } /*************************************************************************** @@ -1525,7 +1525,7 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, comment = talloc_strdup(ctx, info->info2->comment); pathname = info->info2->path; type = info->info2->type; - max_connections = (info->info2->max_users == 0xffffffff) ? + max_connections = (info->info2->max_users == (uint32_t)-1) ? 0 : info->info2->max_users; psd = NULL; break; @@ -1720,7 +1720,7 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, share_name = talloc_strdup(ctx, r->in.info->info2->name); comment = talloc_strdup(ctx, r->in.info->info2->comment); pathname = talloc_strdup(ctx, r->in.info->info2->path); - max_connections = (r->in.info->info2->max_users == 0xffffffff) ? + max_connections = (r->in.info->info2->max_users == (uint32_t)-1) ? 0 : r->in.info->info2->max_users; type = r->in.info->info2->type; break; @@ -1731,7 +1731,7 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, share_name = talloc_strdup(ctx, r->in.info->info502->name); comment = talloc_strdup(ctx, r->in.info->info502->comment); pathname = talloc_strdup(ctx, r->in.info->info502->path); - max_connections = (r->in.info->info502->max_users == 0xffffffff) ? + max_connections = (r->in.info->info502->max_users == (uint32_t)-1) ? 0 : r->in.info->info502->max_users; type = r->in.info->info502->type; psd = r->in.info->info502->sd; -- cgit From a3991c9ef40b221ecd36344d65e723e357d8b3c7 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 1 Apr 2008 00:02:48 +0200 Subject: Fix SRVSVC ShareInfo level 502 server side handling. Guenther (This used to be commit 776facabf6f09f643d6dc526aa83f8db517465f9) --- source3/rpc_server/srv_srvsvc_nt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 57b42af4e5..7188360f69 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -379,6 +379,7 @@ static void init_srv_share_info_502(pipes_struct *p, struct srvsvc_NetShareInfo5 const char *net_name = lp_servicename(snum); char *path = NULL; SEC_DESC *sd = NULL; + struct sec_desc_buf *sd_buf = NULL; size_t sd_size = 0; TALLOC_CTX *ctx = p->mem_ctx; char *remark = talloc_strdup(ctx, lp_comment(snum));; @@ -397,6 +398,8 @@ static void init_srv_share_info_502(pipes_struct *p, struct srvsvc_NetShareInfo5 sd = get_share_security(ctx, lp_servicename(snum), &sd_size); + sd_buf = make_sec_desc_buf(p->mem_ctx, sd_size, sd); + init_srvsvc_NetShareInfo502(r, net_name, get_share_type(snum), remark ? remark : "", @@ -405,8 +408,7 @@ static void init_srv_share_info_502(pipes_struct *p, struct srvsvc_NetShareInfo5 1, path ? path : "", "", - 0, - sd); + sd_buf); } /*************************************************************************** @@ -1541,7 +1543,7 @@ WERROR _srvsvc_NetShareSetInfo(pipes_struct *p, comment = talloc_strdup(ctx, info->info502->comment); pathname = info->info502->path; type = info->info502->type; - psd = info->info502->sd; + psd = info->info502->sd_buf.sd; map_generic_share_sd_bits(psd); break; case 1004: @@ -1734,7 +1736,7 @@ WERROR _srvsvc_NetShareAdd(pipes_struct *p, max_connections = (r->in.info->info502->max_users == (uint32_t)-1) ? 0 : r->in.info->info502->max_users; type = r->in.info->info502->type; - psd = r->in.info->info502->sd; + psd = r->in.info->info502->sd_buf.sd; map_generic_share_sd_bits(psd); break; -- cgit From edcbb657deea1fd177bd66bd1bc653e15b1b99d9 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 1 Apr 2008 00:14:00 +0200 Subject: Fix build warning. Guenther (This used to be commit c40522cfe97c4e5eedccc9c56f47f9d4a8bcdaaf) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 0f4a5b9ae1..62632d08c5 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -2393,7 +2393,7 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, samr_clear_sam_passwd(sampass); DEBUG(3,("User:[%s] has [%s] (length: %d)\n", pdb_get_username(sampass), - munged_dial, strlen(munged_dial))); + munged_dial, (int)strlen(munged_dial))); if (munged_dial) { blob = base64_decode_data_blob(munged_dial); -- cgit From 40d16fa275888b0dbb5894d484966c858187997c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 4 Apr 2008 11:14:09 -0700 Subject: Fix bug #5372. With a large CUPS installation with a remote server, contacting the server when searching for a name for the location and comment fields can take so much time the client times out. When searching for a name we don't use these fields anyway, so add a function get_a_printer_search() which doesn't contact the CUPS server. Jeremy. (This used to be commit 92d9f20852d5384e92a93dd0b051034718840ca8) --- source3/rpc_server/srv_spoolss_nt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 403beb6782..7788e763fa 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -521,7 +521,13 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename) fstrcpy(sname, lp_servicename(snum)); printer = NULL; - result = get_a_printer( NULL, &printer, 2, sname ); + + /* This call doesn't fill in the location or comment from + * a CUPS server for efficiency with large numbers of printers. + * JRA. + */ + + result = get_a_printer_search( NULL, &printer, 2, sname ); if ( !W_ERROR_IS_OK(result) ) { DEBUG(0,("set_printer_hnd_name: failed to lookup printer [%s] -- result [%s]\n", sname, dos_errstr(result))); -- cgit From 8c9d6322dea2243e9bc15032af399264c6678c1b Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 4 Apr 2008 11:59:32 +0200 Subject: Fix _samr_GetDomPwInfo (to return more then zeros). Guenther (This used to be commit 1cde9579f10ab8c43c25dfd6e5c658c7653f9a37) --- source3/rpc_server/srv_samr_nt.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 62632d08c5..bcb4acbf15 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -5373,6 +5373,9 @@ NTSTATUS _samr_SetAliasInfo(pipes_struct *p, NTSTATUS _samr_GetDomPwInfo(pipes_struct *p, struct samr_GetDomPwInfo *r) { + uint32_t min_password_length = 0; + uint32_t password_properties = 0; + /* Perform access check. Since this rpc does not require a policy handle it will not be caught by the access checks on SAMR_CONNECT or SAMR_CONNECT_ANON. */ @@ -5382,8 +5385,19 @@ NTSTATUS _samr_GetDomPwInfo(pipes_struct *p, return NT_STATUS_ACCESS_DENIED; } - /* Actually, returning zeros here works quite well :-). */ - ZERO_STRUCTP(r->out.info); + become_root(); + pdb_get_account_policy(AP_MIN_PASSWORD_LEN, + &min_password_length); + pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, + &password_properties); + unbecome_root(); + + if (lp_check_password_script() && *lp_check_password_script()) { + password_properties |= DOMAIN_PASSWORD_COMPLEX; + } + + r->out.info->min_password_length = min_password_length; + r->out.info->password_properties = password_properties; return NT_STATUS_OK; } -- cgit From 833729125093b884a528057b0aa03891efb9e9b5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 4 Apr 2008 12:00:26 +0200 Subject: Fix _samr_GetUserPwInfo() (to return more then just zeros). Guenther (This used to be commit 624371ce32a7c0816963745059e743e5b3e92e2a) --- source3/rpc_server/srv_samr_nt.c | 53 ++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index bcb4acbf15..0d9dd554c6 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -627,22 +627,59 @@ NTSTATUS _samr_GetUserPwInfo(pipes_struct *p, struct samr_GetUserPwInfo *r) { struct samr_info *info = NULL; + enum lsa_SidType sid_type; + uint32_t min_password_length = 0; + uint32_t password_properties = 0; + bool ret = false; + NTSTATUS status; + + DEBUG(5,("_samr_GetUserPwInfo: %d\n", __LINE__)); /* find the policy handle. open a policy on it. */ - if (!find_policy_by_hnd(p, r->in.user_handle, (void **)(void *)&info)) + if (!find_policy_by_hnd(p, r->in.user_handle, (void **)(void *)&info)) { return NT_STATUS_INVALID_HANDLE; + } - if (!sid_check_is_in_our_domain(&info->sid)) + status = access_check_samr_function(info->acc_granted, + SAMR_USER_ACCESS_GET_ATTRIBUTES, + "_samr_GetUserPwInfo" ); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + if (!sid_check_is_in_our_domain(&info->sid)) { return NT_STATUS_OBJECT_TYPE_MISMATCH; + } + + become_root(); + ret = lookup_sid(p->mem_ctx, &info->sid, NULL, NULL, &sid_type); + unbecome_root(); + if (ret == false) { + return NT_STATUS_NO_SUCH_USER; + } - ZERO_STRUCTP(r->out.info); + switch (sid_type) { + case SID_NAME_USER: + become_root(); + pdb_get_account_policy(AP_MIN_PASSWORD_LEN, + &min_password_length); + pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, + &password_properties); + unbecome_root(); - DEBUG(5,("_samr_GetUserPwInfo: %d\n", __LINE__)); + if (lp_check_password_script() && *lp_check_password_script()) { + password_properties |= DOMAIN_PASSWORD_COMPLEX; + } - /* - * NT sometimes return NT_STATUS_ACCESS_DENIED - * I don't know yet why. - */ + break; + default: + break; + } + + r->out.info->min_password_length = min_password_length; + r->out.info->password_properties = password_properties; + + DEBUG(5,("_samr_GetUserPwInfo: %d\n", __LINE__)); return NT_STATUS_OK; } -- cgit From c751386bb8d797dcb714fac19e6d4b161e3d81d0 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 11 Apr 2008 22:20:32 +0200 Subject: Remove some write-only fstrings (This used to be commit aacb07b1b0f674b8cb92347ef4b4dd1e7808dde8) --- source3/rpc_server/srv_pipe.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 05cdb65a83..4ac9f7a6f4 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -614,11 +614,6 @@ static bool pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) ZERO_STRUCT(reply); - memset(p->user_name, '\0', sizeof(p->user_name)); - memset(p->pipe_user_name, '\0', sizeof(p->pipe_user_name)); - memset(p->domain, '\0', sizeof(p->domain)); - memset(p->wks, '\0', sizeof(p->wks)); - /* Set up for non-authenticated user. */ TALLOC_FREE(p->pipe_user.nt_user_token); p->pipe_user.ut.ngroups = 0; @@ -656,14 +651,10 @@ static bool pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) return False; } } - - fstrcpy(p->user_name, a->ntlmssp_state->user); - fstrcpy(p->pipe_user_name, a->server_info->unix_name); - fstrcpy(p->domain, a->ntlmssp_state->domain); - fstrcpy(p->wks, a->ntlmssp_state->workstation); - DEBUG(5,("pipe_ntlmssp_verify_final: OK: user: %s domain: %s workstation: %s\n", - p->user_name, p->domain, p->wks)); + DEBUG(5, ("pipe_ntlmssp_verify_final: OK: user: %s domain: %s " + "workstation: %s\n", a->ntlmssp_state->user, + a->ntlmssp_state->domain, a->ntlmssp_state->workstation)); /* * Store the UNIX credential data (uid/gid pair) in the pipe structure. -- cgit From e23911b0c30ef6dced054dac3518a99691a7c917 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 14 Apr 2008 14:46:30 +0200 Subject: WKSSVC: In _wkssvc_NetrJoinDomain2, do modify the local configuration if enabled. Guenther (This used to be commit 260efafb8fb6527eb0a182f9a6bfed8239dd8315) --- source3/rpc_server/srv_wkssvc_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 32d315f96f..71f1960a67 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -340,6 +340,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, j->in.admin_account = admin_account; j->in.admin_password = cleartext_pwd; j->in.debug = true; + j->in.modify_config = lp_config_backend_is_registry(); become_root(); werr = libnet_Join(p->mem_ctx, j); -- cgit From 28fd4f6fcb101fc0274c43611a59d22072fb7891 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 15 Apr 2008 20:26:52 +0200 Subject: Reconcile ndr_syntax_id used by pidl-generated code and Samba3's RFC_IFACE. (This used to be commit 7bea00dca1ee08ef731dfa73110ef9c190a29919) --- source3/rpc_server/srv_pipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 4ac9f7a6f4..3fe9c7f2ec 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -986,9 +986,9 @@ bool check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, for ( i=0; pipe_names[i].client_pipe; i++ ) { DEBUGADD(10,("checking %s\n", pipe_names[i].client_pipe)); if ( strequal(pipe_names[i].client_pipe, pname) - && (abstract->version == pipe_names[i].abstr_syntax.version) + && (abstract->if_version == pipe_names[i].abstr_syntax.if_version) && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(struct GUID)) == 0) - && (transfer->version == pipe_names[i].trans_syntax.version) + && (transfer->if_version == pipe_names[i].trans_syntax.if_version) && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(struct GUID)) == 0) ) { struct api_struct *fns = NULL; int n_fns = 0; -- cgit From 189c0153e02bcab5769227ae362c81fa6f4a91e2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 16 Apr 2008 23:59:43 +0200 Subject: NetrUnjoinDomain2: Honor registry config to try config changes. Guenther (This used to be commit b42304c299224238a0247e0e1561eb2ad3217b96) --- source3/rpc_server/srv_wkssvc_nt.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 71f1960a67..3c006fd655 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -406,6 +406,7 @@ WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, u->in.admin_account = admin_account; u->in.admin_password = cleartext_pwd; u->in.debug = true; + u->in.modify_config = lp_config_backend_is_registry(); become_root(); werr = libnet_Unjoin(p->mem_ctx, u); -- cgit From a4c60b2696962c7f83e033e00d97e4b1dacc05c9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 17 Apr 2008 17:44:40 +0200 Subject: rpc_parse: Use UUIDs from librpc/gen_ndr/ when possible to reduce duplication. (This used to be commit 428654b473ba44b2f5340eefef0d4fcd51aff558) --- source3/rpc_server/srv_pipe.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 3fe9c7f2ec..52e4fdfd5b 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -986,10 +986,10 @@ bool check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, for ( i=0; pipe_names[i].client_pipe; i++ ) { DEBUGADD(10,("checking %s\n", pipe_names[i].client_pipe)); if ( strequal(pipe_names[i].client_pipe, pname) - && (abstract->if_version == pipe_names[i].abstr_syntax.if_version) - && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax.uuid, sizeof(struct GUID)) == 0) - && (transfer->if_version == pipe_names[i].trans_syntax.if_version) - && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax.uuid, sizeof(struct GUID)) == 0) ) { + && (abstract->if_version == pipe_names[i].abstr_syntax->if_version) + && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax->uuid, sizeof(struct GUID)) == 0) + && (transfer->if_version == pipe_names[i].trans_syntax->if_version) + && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax->uuid, sizeof(struct GUID)) == 0) ) { struct api_struct *fns = NULL; int n_fns = 0; PIPE_RPC_FNS *context_fns; -- cgit From 0c17878e2189431fcb7d63c4ddd0f4647ba411b9 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Apr 2008 14:02:21 +0200 Subject: Remove a redundant reference to rpc_pipe_state->cli from srv_spoolss This assignment is done in cli_rpc_pipe_open called from cli_rpc_pipe_open_noauth already. (This used to be commit 7331c4c2781bf7904942c119f1a8de8eda00ae7e) --- source3/rpc_server/srv_spoolss_nt.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 7788e763fa..722ad54951 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2609,10 +2609,6 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, return False; } - /* make sure to save the cli_state pointer. Keep its own talloc_ctx */ - - (*pp_pipe)->cli = the_cli; - return True; } -- cgit From b9cc05506273e5ce3398a5912b9c9e5989717480 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Apr 2008 14:05:25 +0200 Subject: Introduce rpc_pipe_np_smb_conn() This abstracts away all references to rpc_pipe_client->cli, the only reference is now in cli_pipe.c. (This used to be commit c56e1c08cef107ff33a34346ceeca3475a102b19) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 722ad54951..4c5fcf5341 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -164,7 +164,7 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle) /* if it's the last connection, deconnect the IPC$ share */ if (smb_connections==1) { - cli_shutdown( notify_cli_pipe->cli ); + cli_shutdown( rpc_pipe_np_smb_conn(notify_cli_pipe) ); notify_cli_pipe = NULL; /* The above call shuts downn the pipe also. */ messaging_deregister(smbd_messaging_context(), -- cgit From 189eb93b73c4ff0737b702a0682727f5a22bcc38 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 24 Apr 2008 14:04:47 -0700 Subject: The first of Martin Zielinski Vista printing patches. Jerry will test and should get into 3.2 final (and the next 3.0.x release). Jeremy. (This used to be commit 3fc1ab210b8772ee9f867499c0b1a7bb4bcdd285) --- source3/rpc_server/srv_spoolss_nt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4c5fcf5341..a7b477e17d 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -9626,13 +9626,16 @@ WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_ /* copy data into the reply */ - r_u->ctr.size = r_u->needed; + /* mz: Vista x64 returns 0x6f7 (The stub received bad data), if the + response buffer size is != the offered buffer size + + r_u->ctr.size = r_u->needed; + */ + r_u->ctr.size = in_size; r_u->ctr.size_of_array = r_u->returned; r_u->ctr.values = enum_values; - - done: if ( printer ) free_a_printer(&printer, 2); -- cgit From 7a6f33e3d8e3913edfd6ed86d5119ad18c407c65 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 29 Apr 2008 20:13:22 +0200 Subject: _netr_LogonSamLogon: fix lm session key length. Thanks Volker for pointing this out. Guenther (This used to be commit 7ccca9a004c7a4794781cbd7c703c53a0481bd51) --- source3/rpc_server/srv_netlog_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 4664e8d1ba..203f5382a8 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -1109,7 +1109,7 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p, } memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16); } - SamOEMhash(lm_session_key.key, pipe_session_key, 16); + SamOEMhash(lm_session_key.key, pipe_session_key, 8); memset(pipe_session_key, '\0', 16); } -- cgit From b430b382202858a6c52c1cacbb91910b2dd7e16c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 2 May 2008 17:22:10 -0700 Subject: Remove the "stat_open()" function, flag, and all associated code. It was only being (correctly) used in the can_read/can_write checks for hide unreadable/unwritable and this is more properly done using the functions in smbd/file_access.c. Preparing to do NT access checks on all file access. Jeremy. (This used to be commit 6bfb06ad95963ae2acb67c4694a98282d3b29faa) --- source3/rpc_server/srv_srvsvc_nt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 7188360f69..1b578cc9f8 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2206,13 +2206,20 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, goto error_exit; } - nt_status = open_file_stat(conn, NULL, filename, &st, &fsp); + nt_status = open_file_ntcreate(conn, NULL, filename, &st, + FILE_WRITE_ATTRIBUTES, + FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_OPEN, + 0, + FILE_ATTRIBUTE_NORMAL, + INTERNAL_OPEN_ONLY, + NULL, &fsp); if ( !NT_STATUS_IS_OK(nt_status) ) { /* Perhaps it is a directory */ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) nt_status = open_directory(conn, NULL, filename, &st, - FILE_READ_ATTRIBUTES, + FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0, -- cgit From bb3755968f5e953340edfb0b71997dddc11badb9 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 29 Apr 2008 13:35:00 +0200 Subject: Remove "nt_user_token" from "struct user_struct" (This used to be commit 51d5d512f28eadc74eced43e5e7f4e5bdff3ff69) --- source3/rpc_server/srv_pipe_hnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 45f649d0ce..9224774380 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -342,7 +342,7 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, if (vuser) { p->session_key = data_blob(vuser->session_key.data, vuser->session_key.length); p->pipe_user.nt_user_token = dup_nt_token( - NULL, vuser->nt_user_token); + NULL, vuser->server_info->ptok); } /* -- cgit From 71ff1ba2deddf8fa12b034518e92e0a461871388 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 29 Apr 2008 13:45:58 +0200 Subject: Remove "guest" from "struct user_struct" (This used to be commit 570a6b80feb5b0dc23213ba936c721e766cd4818) --- source3/rpc_server/srv_lsa_hnd.c | 2 +- source3/rpc_server/srv_lsa_nt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index a8341e677b..78b891e071 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -268,7 +268,7 @@ bool pipe_access_check(pipes_struct *p) return False; } - if (user->guest) { + if (user->server_info->guest) { return False; } } diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 20c910e46d..8bc377b97e 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1468,7 +1468,7 @@ NTSTATUS _lsa_GetUserName(pipes_struct *p, if (vuser == NULL) return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; - if (vuser->guest) { + if (vuser->server_info->guest) { /* * I'm 99% sure this is not the right place to do this, * global_sid_Anonymous should probably be put into the token -- cgit From 82d2f07dae5d69fc1635a4ed326a2af6632d8a97 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 30 Apr 2008 14:26:16 +0200 Subject: Remove "session_key" from "struct user_struct" This one took a bit -- I hope I covered all data paths (This used to be commit 74c88a44422f88d6e2f2cdbfdfa0bafe0dbe06c4) --- source3/rpc_server/srv_pipe_hnd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 9224774380..1d62199ad8 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -340,7 +340,9 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, /* Store the session key and NT_TOKEN */ if (vuser) { - p->session_key = data_blob(vuser->session_key.data, vuser->session_key.length); + p->session_key = data_blob( + vuser->server_info->user_session_key.data, + vuser->server_info->user_session_key.length); p->pipe_user.nt_user_token = dup_nt_token( NULL, vuser->server_info->ptok); } -- cgit From bec1dfab27be3db888eeb451b4547f16e08e93c3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 30 Apr 2008 17:42:39 +0200 Subject: Remove "userdom_struct user" from "struct user_struct" (This used to be commit 420de035237bb08bc470c9eb820f3da2edaa6805) --- source3/rpc_server/srv_lsa_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 8bc377b97e..7c33bd0d4f 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1479,8 +1479,8 @@ NTSTATUS _lsa_GetUserName(pipes_struct *p, return NT_STATUS_NO_MEMORY; } } else { - username = vuser->user.smb_name; - domname = vuser->user.domain; + username = vuser->server_info->sanitized_username; + domname = pdb_get_domain(vuser->server_info->sam_account); } account_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_String); -- cgit From 1409ed60e2176e16fdd65b79ca502d9da6f11a74 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 6 May 2008 15:06:12 +0200 Subject: Fix a memleak in construct_printer_info_7() Also fix a "ignoring asprintf result" warning (This used to be commit 64d21f39636019d6a17f84efc6fb9e61e67a235e) --- source3/rpc_server/srv_spoolss_nt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index a7b477e17d..0e98a39426 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4357,10 +4357,13 @@ static bool construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *p struct GUID guid; if (is_printer_published(print_hnd, snum, &guid)) { - asprintf(&guid_str, "{%s}", - smb_uuid_string(talloc_tos(), guid)); + if (asprintf(&guid_str, "{%s}", + smb_uuid_string(talloc_tos(), guid)) == -1) { + return false; + } strupper_m(guid_str); init_unistr(&printer->guid, guid_str); + SAFE_FREE(guid_str); printer->action = SPOOL_DS_PUBLISH; } else { init_unistr(&printer->guid, ""); -- cgit From 00b2cdf75e9bea25034440054b4acd91a179c86d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 8 May 2008 18:09:07 -0700 Subject: Yay ! Remove a VFS entry. Removed the set_nt_acl() call, this can only be done via fset_nt_acl() using an open file/directory handle. I'd like to do the same with get_nt_acl() but am concerned about efficiency problems with "hide unreadable/hide unwritable" when doing a directory listing (this would mean opening every file in the dir on list). Moving closer to rationalizing the ACL model and maybe moving the POSIX calls into a posix_acl VFS module rather than having them as first class citizens of the VFS. Jeremy. (This used to be commit f487f742cb903a06fbf2be006ddc9ce9063339ed) --- source3/rpc_server/srv_srvsvc_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 1b578cc9f8..18c6f4de53 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2233,7 +2233,7 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, } } - nt_status = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, + nt_status = SMB_VFS_FSET_NT_ACL(fsp, r->in.securityinformation, r->in.sd_buf->sd); -- cgit From 67c644aa591c051cfe1e3f3536186ecf0b4449f2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 8 May 2008 18:32:22 +0200 Subject: dsgetdcname: use existing messaging_context if possible. Guenther (This used to be commit 7889516a384c155a9045aad4409c041fddd0d98d) --- source3/rpc_server/srv_wkssvc_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 3c006fd655..3c64abfcdf 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -341,6 +341,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, j->in.admin_password = cleartext_pwd; j->in.debug = true; j->in.modify_config = lp_config_backend_is_registry(); + j->in.msg_ctx = smbd_messaging_context(); become_root(); werr = libnet_Join(p->mem_ctx, j); @@ -407,6 +408,7 @@ WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, u->in.admin_password = cleartext_pwd; u->in.debug = true; u->in.modify_config = lp_config_backend_is_registry(); + u->in.msg_ctx = smbd_messaging_context(); become_root(); werr = libnet_Unjoin(p->mem_ctx, u); -- cgit From 3f76504d92e0bde89472e569acd64494729778a5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 9 May 2008 11:14:45 -0700 Subject: Remove a couple of uses of SMB_VFS_GET_NT_ACL(), use SMB_VFS_FGET_NT_ACL instead. I'd like to ultimately remove SMB_VFS_GET_NT_ACL. Jeremy. (This used to be commit 4221937b68e2414295279b27c5f12a80f826ed4b) --- source3/rpc_server/srv_srvsvc_nt.c | 55 +++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 18c6f4de53..947ad46568 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2029,20 +2029,18 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, char *qualname = NULL; SMB_STRUCT_STAT st; NTSTATUS nt_status; - WERROR werr; + WERROR werr = WERR_ACCESS_DENIED; struct current_user user; connection_struct *conn = NULL; bool became_user = False; TALLOC_CTX *ctx = p->mem_ctx; - struct sec_desc_buf *sd_buf; + struct sec_desc_buf *sd_buf = NULL; + files_struct *fsp = NULL; ZERO_STRUCT(st); - werr = WERR_OK; - qualname = talloc_strdup(ctx, r->in.share); if (!qualname) { - werr = WERR_ACCESS_DENIED; goto error_exit; } @@ -2064,14 +2062,12 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, if (!become_user(conn, conn->vuid)) { DEBUG(0,("_srvsvc_NetGetFileSecurity: Can't become connected user!\n")); - werr = WERR_ACCESS_DENIED; goto error_exit; } became_user = True; filename_in = talloc_strdup(ctx, r->in.file); if (!filename_in) { - werr = WERR_ACCESS_DENIED; goto error_exit; } @@ -2079,7 +2075,6 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srvsvc_NetGetFileSecurity: bad pathname %s\n", filename)); - werr = WERR_ACCESS_DENIED; goto error_exit; } @@ -2087,11 +2082,37 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srvsvc_NetGetFileSecurity: can't access %s\n", filename)); - werr = WERR_ACCESS_DENIED; goto error_exit; } - nt_status = SMB_VFS_GET_NT_ACL(conn, filename, + if (!(S_ISDIR(st.st_mode))) { + nt_status = open_file_ntcreate(conn, NULL, filename, &st, + FILE_READ_ATTRIBUTES, + FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_OPEN, + 0, + FILE_ATTRIBUTE_NORMAL, + 0, + NULL, &fsp); + + } else { + nt_status = open_directory(conn, NULL, filename, &st, + FILE_READ_ATTRIBUTES, + FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_OPEN, + 0, + FILE_ATTRIBUTE_DIRECTORY, + NULL, &fsp); + } + + if (!NT_STATUS_IS_OK(nt_status)) { + DEBUG(3,("_srvsvc_NetGetFileSecurity: can't open %s\n", + filename)); + werr = ntstatus_to_werror(nt_status); + goto error_exit; + } + + nt_status = SMB_VFS_FGET_NT_ACL(fsp, (OWNER_SECURITY_INFORMATION |GROUP_SECURITY_INFORMATION |DACL_SECURITY_INFORMATION), &psd); @@ -2118,17 +2139,25 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, psd->dacl->revision = NT4_ACL_REVISION; + close_file(fsp, NORMAL_CLOSE); + unbecome_user(); close_cnum(conn, user.vuid); - return werr; + return WERR_OK; error_exit: - if (became_user) + if(fsp) { + close_file(fsp, NORMAL_CLOSE); + } + + if (became_user) { unbecome_user(); + } - if (conn) + if (conn) { close_cnum(conn, user.vuid); + } return werr; } -- cgit From 08971abdad82ce6b57a85ce77a8cb7906b0dab2f Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 16 May 2008 13:24:15 +0200 Subject: Fix Bug #5461 and implement a very basic _samr_GetDisplayEnumerationIndex(). Citrix PM cannot use a Samba DC when having more then 900 groups as citrix insists on calling _samr_GetDisplayEnumerationIndex() after receiving the first 900 groups via _samr_QueryDisplayInfo() to get the continuation index. Guenther (This used to be commit 1c4adc8dda68eae9839bdff843aadf8c98dd9e87) --- source3/rpc_server/srv_samr_nt.c | 159 ++++++++++++++++++++++++++++++++++----- 1 file changed, 139 insertions(+), 20 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 0d9dd554c6..f28c771d3e 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -5651,6 +5651,145 @@ NTSTATUS _samr_SetDomainInfo(pipes_struct *p, return NT_STATUS_OK; } +/**************************************************************** + _samr_GetDisplayEnumerationIndex +****************************************************************/ + +NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p, + struct samr_GetDisplayEnumerationIndex *r) +{ + struct samr_info *info = NULL; + uint32_t max_entries = (uint32_t) -1; + uint32_t enum_context = 0; + int i; + uint32_t num_account = 0; + struct samr_displayentry *entries = NULL; + + DEBUG(5,("_samr_GetDisplayEnumerationIndex: %d\n", __LINE__)); + + /* find the policy handle. open a policy on it. */ + if (!find_policy_by_hnd(p, r->in.domain_handle, (void **)(void *)&info)) { + return NT_STATUS_INVALID_HANDLE; + } + + if ((r->in.level < 1) || (r->in.level > 3)) { + DEBUG(0,("_samr_GetDisplayEnumerationIndex: " + "Unknown info level (%u)\n", + r->in.level)); + return NT_STATUS_INVALID_INFO_CLASS; + } + + become_root(); + + /* The following done as ROOT. Don't return without unbecome_root(). */ + + switch (r->in.level) { + case 1: + if (info->disp_info->users == NULL) { + info->disp_info->users = pdb_search_users(ACB_NORMAL); + if (info->disp_info->users == NULL) { + unbecome_root(); + return NT_STATUS_ACCESS_DENIED; + } + DEBUG(10,("_samr_GetDisplayEnumerationIndex: " + "starting user enumeration at index %u\n", + (unsigned int)enum_context)); + } else { + DEBUG(10,("_samr_GetDisplayEnumerationIndex: " + "using cached user enumeration at index %u\n", + (unsigned int)enum_context)); + } + num_account = pdb_search_entries(info->disp_info->users, + enum_context, max_entries, + &entries); + break; + case 2: + if (info->disp_info->machines == NULL) { + info->disp_info->machines = + pdb_search_users(ACB_WSTRUST|ACB_SVRTRUST); + if (info->disp_info->machines == NULL) { + unbecome_root(); + return NT_STATUS_ACCESS_DENIED; + } + DEBUG(10,("_samr_GetDisplayEnumerationIndex: " + "starting machine enumeration at index %u\n", + (unsigned int)enum_context)); + } else { + DEBUG(10,("_samr_GetDisplayEnumerationIndex: " + "using cached machine enumeration at index %u\n", + (unsigned int)enum_context)); + } + num_account = pdb_search_entries(info->disp_info->machines, + enum_context, max_entries, + &entries); + break; + case 3: + if (info->disp_info->groups == NULL) { + info->disp_info->groups = pdb_search_groups(); + if (info->disp_info->groups == NULL) { + unbecome_root(); + return NT_STATUS_ACCESS_DENIED; + } + DEBUG(10,("_samr_GetDisplayEnumerationIndex: " + "starting group enumeration at index %u\n", + (unsigned int)enum_context)); + } else { + DEBUG(10,("_samr_GetDisplayEnumerationIndex: " + "using cached group enumeration at index %u\n", + (unsigned int)enum_context)); + } + num_account = pdb_search_entries(info->disp_info->groups, + enum_context, max_entries, + &entries); + break; + default: + unbecome_root(); + smb_panic("info class changed"); + break; + } + + unbecome_root(); + + /* Ensure we cache this enumeration. */ + set_disp_info_cache_timeout(info->disp_info, DISP_INFO_CACHE_TIMEOUT); + + DEBUG(10,("_samr_GetDisplayEnumerationIndex: looking for :%s\n", + r->in.name->string)); + + for (i=0; iin.name->string)) { + DEBUG(10,("_samr_GetDisplayEnumerationIndex: " + "found %s at idx %d\n", + r->in.name->string, i)); + *r->out.idx = i; + return NT_STATUS_OK; + } + } + + /* assuming account_name lives at the very end */ + *r->out.idx = num_account; + + return NT_STATUS_NO_MORE_ENTRIES; +} + +/**************************************************************** + _samr_GetDisplayEnumerationIndex2 +****************************************************************/ + +NTSTATUS _samr_GetDisplayEnumerationIndex2(pipes_struct *p, + struct samr_GetDisplayEnumerationIndex2 *r) +{ + struct samr_GetDisplayEnumerationIndex q; + + q.in.domain_handle = r->in.domain_handle; + q.in.level = r->in.level; + q.in.name = r->in.name; + + q.out.idx = r->out.idx; + + return _samr_GetDisplayEnumerationIndex(p, &q); +} + /**************************************************************** ****************************************************************/ @@ -5694,16 +5833,6 @@ NTSTATUS _samr_ChangePasswordUser(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_GetDisplayEnumerationIndex(pipes_struct *p, - struct samr_GetDisplayEnumerationIndex *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_TestPrivateFunctionsDomain(pipes_struct *p, struct samr_TestPrivateFunctionsDomain *r) { @@ -5734,16 +5863,6 @@ NTSTATUS _samr_QueryUserInfo2(pipes_struct *p, /**************************************************************** ****************************************************************/ -NTSTATUS _samr_GetDisplayEnumerationIndex2(pipes_struct *p, - struct samr_GetDisplayEnumerationIndex2 *r) -{ - p->rng_fault_state = true; - return NT_STATUS_NOT_IMPLEMENTED; -} - -/**************************************************************** -****************************************************************/ - NTSTATUS _samr_AddMultipleMembersToAlias(pipes_struct *p, struct samr_AddMultipleMembersToAlias *r) { -- cgit From 968a00655557ceedbb4b2438778ff8818b52c3b2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 17 May 2008 22:44:35 +0200 Subject: Factor out generation of an info3 struct from a serversupplied_info (This used to be commit e60faccc1bdd2b80e039ec8c93683be10752f937) --- source3/rpc_server/srv_netlog_nt.c | 195 +++---------------------------------- 1 file changed, 12 insertions(+), 183 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 203f5382a8..863c62acc4 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -747,36 +747,6 @@ NTSTATUS _netr_LogonSamLogoff(pipes_struct *p, return NT_STATUS_OK; } -/******************************************************************* - gets a domain user's groups from their already-calculated NT_USER_TOKEN - ********************************************************************/ - -static NTSTATUS nt_token_to_group_list(TALLOC_CTX *mem_ctx, - const DOM_SID *domain_sid, - size_t num_sids, - const DOM_SID *sids, - int *numgroups, DOM_GID **pgids) -{ - int i; - - *numgroups=0; - *pgids = NULL; - - for (i=0; ihdr_req.opnum) { @@ -1008,160 +978,19 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p, the SAM Local Security Authority should record that the user is logged in to the domain. */ - { - DOM_GID *gids = NULL; - const DOM_SID *user_sid = NULL; - const DOM_SID *group_sid = NULL; - DOM_SID domain_sid; - uint32 user_rid, group_rid; - - int num_gids = 0; - const char *my_name; - - struct netr_UserSessionKey user_session_key; - struct netr_LMSessionKey lm_session_key; - unsigned char pipe_session_key[16]; - - NTTIME last_logon, last_logoff, acct_expiry, last_password_change; - NTTIME allow_password_change, force_password_change; - struct samr_RidWithAttributeArray groups; - int i; - struct dom_sid2 *sid = NULL; - - ZERO_STRUCT(user_session_key); - ZERO_STRUCT(lm_session_key); - - sampw = server_info->sam_account; - - user_sid = pdb_get_user_sid(sampw); - group_sid = pdb_get_group_sid(sampw); - - if ((user_sid == NULL) || (group_sid == NULL)) { - DEBUG(1, ("_netr_LogonSamLogon: User without group or user SID\n")); - return NT_STATUS_UNSUCCESSFUL; - } - - sid_copy(&domain_sid, user_sid); - sid_split_rid(&domain_sid, &user_rid); - - sid = sid_dup_talloc(p->mem_ctx, &domain_sid); - if (!sid) { - return NT_STATUS_NO_MEMORY; - } - - if (!sid_peek_check_rid(&domain_sid, group_sid, &group_rid)) { - DEBUG(1, ("_netr_LogonSamLogon: user %s\\%s has user sid " - "%s\n but group sid %s.\n" - "The conflicting domain portions are not " - "supported for NETLOGON calls\n", - pdb_get_domain(sampw), - pdb_get_username(sampw), - sid_string_dbg(user_sid), - sid_string_dbg(group_sid))); - return NT_STATUS_UNSUCCESSFUL; - } - - if(server_info->login_server) { - my_name = server_info->login_server; - } else { - my_name = global_myname(); - } - - status = nt_token_to_group_list(p->mem_ctx, &domain_sid, - server_info->num_sids, - server_info->sids, - &num_gids, &gids); - - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - if (server_info->user_session_key.length) { - memcpy(user_session_key.key, - server_info->user_session_key.data, - MIN(sizeof(user_session_key.key), - server_info->user_session_key.length)); - if (process_creds) { - /* Get the pipe session key from the creds. */ - memcpy(pipe_session_key, p->dc->sess_key, 16); - } else { - /* Get the pipe session key from the schannel. */ - if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL || p->auth.a_u.schannel_auth == NULL) { - return NT_STATUS_INVALID_HANDLE; - } - memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16); - } - SamOEMhash(user_session_key.key, pipe_session_key, 16); - memset(pipe_session_key, '\0', 16); - } - if (server_info->lm_session_key.length) { - memcpy(lm_session_key.key, - server_info->lm_session_key.data, - MIN(sizeof(lm_session_key.key), - server_info->lm_session_key.length)); - if (process_creds) { - /* Get the pipe session key from the creds. */ - memcpy(pipe_session_key, p->dc->sess_key, 16); - } else { - /* Get the pipe session key from the schannel. */ - if (p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL || p->auth.a_u.schannel_auth == NULL) { - return NT_STATUS_INVALID_HANDLE; - } - memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16); - } - SamOEMhash(lm_session_key.key, pipe_session_key, 8); - memset(pipe_session_key, '\0', 16); - } - - groups.count = num_gids; - groups.rids = TALLOC_ARRAY(p->mem_ctx, struct samr_RidWithAttribute, - groups.count); - if (!groups.rids) { - return NT_STATUS_NO_MEMORY; - } - - for (i=0; i < groups.count; i++) { - groups.rids[i].rid = gids[i].g_rid; - groups.rids[i].attributes = gids[i].attr; + if (process_creds) { + /* Get the pipe session key from the creds. */ + memcpy(pipe_session_key, p->dc->sess_key, 16); + } else { + /* Get the pipe session key from the schannel. */ + if ((p->auth.auth_type != PIPE_AUTH_TYPE_SCHANNEL) + || (p->auth.a_u.schannel_auth == NULL)) { + return NT_STATUS_INVALID_HANDLE; } - - unix_to_nt_time(&last_logon, pdb_get_logon_time(sampw)); - unix_to_nt_time(&last_logoff, get_time_t_max()); - unix_to_nt_time(&acct_expiry, get_time_t_max()); - unix_to_nt_time(&last_password_change, pdb_get_pass_last_set_time(sampw)); - unix_to_nt_time(&allow_password_change, pdb_get_pass_can_change_time(sampw)); - unix_to_nt_time(&force_password_change, pdb_get_pass_must_change_time(sampw)); - - init_netr_SamInfo3(sam3, - last_logon, - last_logoff, - acct_expiry, - last_password_change, - allow_password_change, - force_password_change, - talloc_strdup(p->mem_ctx, pdb_get_username(sampw)), - talloc_strdup(p->mem_ctx, pdb_get_fullname(sampw)), - talloc_strdup(p->mem_ctx, pdb_get_logon_script(sampw)), - talloc_strdup(p->mem_ctx, pdb_get_profile_path(sampw)), - talloc_strdup(p->mem_ctx, pdb_get_homedir(sampw)), - talloc_strdup(p->mem_ctx, pdb_get_dir_drive(sampw)), - 0, /* logon_count */ - 0, /* bad_password_count */ - user_rid, - group_rid, - groups, - NETLOGON_EXTRA_SIDS, - user_session_key, - my_name, - talloc_strdup(p->mem_ctx, pdb_get_domain(sampw)), - sid, - lm_session_key, - pdb_get_acct_ctrl(sampw), - 0, /* sidcount */ - NULL); /* struct netr_SidAttr *sids */ - ZERO_STRUCT(user_session_key); - ZERO_STRUCT(lm_session_key); + memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16); } + + status = serverinfo_to_SamInfo3(server_info, pipe_session_key, sam3); TALLOC_FREE(server_info); return status; } -- cgit From 6a286a7bf4375038ad4dffe0a436a1a743f6aad6 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 20 May 2008 17:29:40 +0200 Subject: Fix a valgrind error in _samr_LookupNames (cherry picked from commit fb0a25d59ddd28ea1d5af33ec7d9f817fac3fb9d) (This used to be commit 89f87efa2394e99802ca23307e712fc5820a5fc6) --- source3/rpc_server/srv_samr_nt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index f28c771d3e..42431bd482 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1786,8 +1786,8 @@ NTSTATUS _samr_LookupNames(pipes_struct *p, struct samr_LookupNames *r) { NTSTATUS status; - uint32 rid[MAX_SAM_ENTRIES]; - enum lsa_SidType type[MAX_SAM_ENTRIES]; + uint32 *rid; + enum lsa_SidType *type; int i; int num_rids = r->in.num_names; DOM_SID pol_sid; @@ -1796,9 +1796,6 @@ NTSTATUS _samr_LookupNames(pipes_struct *p, DEBUG(5,("_samr_LookupNames: %d\n", __LINE__)); - ZERO_ARRAY(rid); - ZERO_ARRAY(type); - if (!get_lsa_policy_samr_sid(p, r->in.domain_handle, &pol_sid, &acc_granted, NULL)) { return NT_STATUS_OBJECT_TYPE_MISMATCH; } @@ -1815,6 +1812,12 @@ NTSTATUS _samr_LookupNames(pipes_struct *p, DEBUG(5,("_samr_LookupNames: truncating entries to %d\n", num_rids)); } + rid = talloc_array(p->mem_ctx, uint32, num_rids); + NT_STATUS_HAVE_NO_MEMORY(rid); + + type = talloc_array(p->mem_ctx, enum lsa_SidType, num_rids); + NT_STATUS_HAVE_NO_MEMORY(rid); + DEBUG(5,("_samr_LookupNames: looking name on SID %s\n", sid_string_dbg(&pol_sid))); -- cgit From 7aa839bba0b4ae408f87a29e4e3a48607bfee275 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 20 May 2008 17:48:39 +0200 Subject: Fix typo. Guenther (cherry picked from commit d3dd7ea5a77414c0d802668ab5bfbe3487b66926) (This used to be commit 68d6b0053f3ce63747bc26a2bebb1fb0b46c8ca0) --- source3/rpc_server/srv_samr_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index 42431bd482..a89e00f1ec 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -1816,7 +1816,7 @@ NTSTATUS _samr_LookupNames(pipes_struct *p, NT_STATUS_HAVE_NO_MEMORY(rid); type = talloc_array(p->mem_ctx, enum lsa_SidType, num_rids); - NT_STATUS_HAVE_NO_MEMORY(rid); + NT_STATUS_HAVE_NO_MEMORY(type); DEBUG(5,("_samr_LookupNames: looking name on SID %s\n", sid_string_dbg(&pol_sid))); -- cgit From 537dc11bf4825472178a64837838ac17111a85f3 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 May 2008 14:28:13 -0700 Subject: Fix 2 bugs with displaying open file state. Firstly the IDL is documented incorrectly in the MS-DOCS. Username and path need to be reversed (yes I will raise this with MS). Secondly, we need to check access_mask for the permissions, not share_access (share_access are the deny modes). Jeremy. (This used to be commit bdaad19f90e991aba2afccfa13afbbfe2ac7baaf) --- source3/rpc_server/srv_srvsvc_nt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 947ad46568..5e17693bfa 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -105,8 +105,8 @@ static int pipe_enum_fn( struct db_record *rec, void *p) (uint32_t)((procid_to_pid(&prec.pid)<<16) & prec.pnum), (FILE_READ_DATA|FILE_WRITE_DATA), 0, - fullpath, - username); + username, + fullpath); fenum->ctr3->count++; @@ -200,7 +200,7 @@ static void enum_file_fn( const struct share_mode_entry *e, string_replace( fullpath, '/', '\\' ); /* mask out create (what ever that is) */ - permissions = e->share_access & (FILE_READ_DATA|FILE_WRITE_DATA); + permissions = e->access_mask & (FILE_READ_DATA|FILE_WRITE_DATA); /* now fill in the srvsvc_NetFileInfo3 struct */ init_srvsvc_NetFileInfo3(&fenum->ctr3->array[i], -- cgit From ac65ed4aad4f2d6b59c721a3e2eead6996df4069 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 May 2008 14:36:09 -0700 Subject: Arggh. Got the path/user the wrong way around. IDL is correct :-). Jeremy. (This used to be commit 2281274480d8cf9e773874301dbbc7bf06346901) --- source3/rpc_server/srv_srvsvc_nt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 5e17693bfa..ebbc39c304 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -105,8 +105,8 @@ static int pipe_enum_fn( struct db_record *rec, void *p) (uint32_t)((procid_to_pid(&prec.pid)<<16) & prec.pnum), (FILE_READ_DATA|FILE_WRITE_DATA), 0, - username, - fullpath); + fullpath, + username); fenum->ctr3->count++; @@ -207,8 +207,8 @@ static void enum_file_fn( const struct share_mode_entry *e, e->share_file_id, permissions, num_locks, - username, - fullpath); + fullpath, + username); fenum->ctr3->count++; } -- cgit From 8c926ed0ea2522cd8a3a69890cdf692a9c8fb23f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 May 2008 16:19:26 -0700 Subject: Arggh. Got the path/user the wrong way around. IDL is correct :-). Jeremy. (This used to be commit 1078b5c53ae9d6f9532eecebf9cf4a1712200b7e) --- source3/rpc_server/srv_srvsvc_nt.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index ebbc39c304..9ffe9a569f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -32,19 +32,6 @@ extern const struct generic_mapping file_generic_mapping; #define MAX_SERVER_DISK_ENTRIES 15 -/***************************/ - -/* oops - this is going to take up a *massive* amount of stack. */ -/* the UNISTR2s already have 1024 uint16 chars in them... */ - -#define MAX_SESS_ENTRIES 32 - -/***************************/ - -/* oops - this is going to take up a *massive* amount of stack. */ -/* the UNISTR2s already have 1024 uint16 chars in them... */ -#define MAX_CONN_ENTRIES 32 - /* Use for enumerating connections, pipes, & files */ struct file_enum_count { @@ -102,7 +89,7 @@ static int pipe_enum_fn( struct db_record *rec, void *p) fenum->ctr3->array = f; init_srvsvc_NetFileInfo3(&fenum->ctr3->array[i], - (uint32_t)((procid_to_pid(&prec.pid)<<16) & prec.pnum), + (((uint32_t)(procid_to_pid(&prec.pid))<<16) | prec.pnum), (FILE_READ_DATA|FILE_WRITE_DATA), 0, fullpath, @@ -204,7 +191,7 @@ static void enum_file_fn( const struct share_mode_entry *e, /* now fill in the srvsvc_NetFileInfo3 struct */ init_srvsvc_NetFileInfo3(&fenum->ctr3->array[i], - e->share_file_id, + (((uint32_t)(procid_to_pid(&e->pid))<<16) | e->share_file_id), permissions, num_locks, fullpath, @@ -748,7 +735,7 @@ static WERROR init_srv_sess_info_0(pipes_struct *p, return WERR_OK; } - for (; resume_handle < *total_entries && num_entries < MAX_SESS_ENTRIES; resume_handle++) { + for (; resume_handle < *total_entries; resume_handle++) { ctr0->array = TALLOC_REALLOC_ARRAY(p->mem_ctx, ctr0->array, @@ -831,7 +818,7 @@ static WERROR init_srv_sess_info_1(pipes_struct *p, *total_entries = list_sessions(p->mem_ctx, &session_list); - for (; resume_handle < *total_entries && num_entries < MAX_SESS_ENTRIES; resume_handle++) { + for (; resume_handle < *total_entries; resume_handle++) { uint32 num_files; uint32 connect_time; struct passwd *pw = sys_getpwnam(session_list[resume_handle].username); @@ -900,7 +887,7 @@ static WERROR init_srv_conn_info_0(struct srvsvc_NetConnCtr0 *ctr0, ZERO_STRUCTP(ctr0); - for (; resume_handle < *total_entries && num_entries < MAX_CONN_ENTRIES; resume_handle++) { + for (; resume_handle < *total_entries; resume_handle++) { ctr0->array = TALLOC_REALLOC_ARRAY(talloc_tos(), ctr0->array, @@ -955,7 +942,7 @@ static WERROR init_srv_conn_info_1(struct srvsvc_NetConnCtr1 *ctr1, ZERO_STRUCTP(ctr1); - for (; (resume_handle < *total_entries) && num_entries < MAX_CONN_ENTRIES; resume_handle++) { + for (; resume_handle < *total_entries; resume_handle++) { ctr1->array = TALLOC_REALLOC_ARRAY(talloc_tos(), ctr1->array, -- cgit From 508d0310e7ce990deaba890e5e64eee7f0b4abbb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 May 2008 16:20:25 -0700 Subject: Revert "Arggh. Got the path/user the wrong way around. IDL is correct :-)." This reverts commit 1078b5c53ae9d6f9532eecebf9cf4a1712200b7e. This message doesn't match the actual change. (This used to be commit a65abb49cf8d291c7deb659912c0df34ec37da02) --- source3/rpc_server/srv_srvsvc_nt.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 9ffe9a569f..ebbc39c304 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -32,6 +32,19 @@ extern const struct generic_mapping file_generic_mapping; #define MAX_SERVER_DISK_ENTRIES 15 +/***************************/ + +/* oops - this is going to take up a *massive* amount of stack. */ +/* the UNISTR2s already have 1024 uint16 chars in them... */ + +#define MAX_SESS_ENTRIES 32 + +/***************************/ + +/* oops - this is going to take up a *massive* amount of stack. */ +/* the UNISTR2s already have 1024 uint16 chars in them... */ +#define MAX_CONN_ENTRIES 32 + /* Use for enumerating connections, pipes, & files */ struct file_enum_count { @@ -89,7 +102,7 @@ static int pipe_enum_fn( struct db_record *rec, void *p) fenum->ctr3->array = f; init_srvsvc_NetFileInfo3(&fenum->ctr3->array[i], - (((uint32_t)(procid_to_pid(&prec.pid))<<16) | prec.pnum), + (uint32_t)((procid_to_pid(&prec.pid)<<16) & prec.pnum), (FILE_READ_DATA|FILE_WRITE_DATA), 0, fullpath, @@ -191,7 +204,7 @@ static void enum_file_fn( const struct share_mode_entry *e, /* now fill in the srvsvc_NetFileInfo3 struct */ init_srvsvc_NetFileInfo3(&fenum->ctr3->array[i], - (((uint32_t)(procid_to_pid(&e->pid))<<16) | e->share_file_id), + e->share_file_id, permissions, num_locks, fullpath, @@ -735,7 +748,7 @@ static WERROR init_srv_sess_info_0(pipes_struct *p, return WERR_OK; } - for (; resume_handle < *total_entries; resume_handle++) { + for (; resume_handle < *total_entries && num_entries < MAX_SESS_ENTRIES; resume_handle++) { ctr0->array = TALLOC_REALLOC_ARRAY(p->mem_ctx, ctr0->array, @@ -818,7 +831,7 @@ static WERROR init_srv_sess_info_1(pipes_struct *p, *total_entries = list_sessions(p->mem_ctx, &session_list); - for (; resume_handle < *total_entries; resume_handle++) { + for (; resume_handle < *total_entries && num_entries < MAX_SESS_ENTRIES; resume_handle++) { uint32 num_files; uint32 connect_time; struct passwd *pw = sys_getpwnam(session_list[resume_handle].username); @@ -887,7 +900,7 @@ static WERROR init_srv_conn_info_0(struct srvsvc_NetConnCtr0 *ctr0, ZERO_STRUCTP(ctr0); - for (; resume_handle < *total_entries; resume_handle++) { + for (; resume_handle < *total_entries && num_entries < MAX_CONN_ENTRIES; resume_handle++) { ctr0->array = TALLOC_REALLOC_ARRAY(talloc_tos(), ctr0->array, @@ -942,7 +955,7 @@ static WERROR init_srv_conn_info_1(struct srvsvc_NetConnCtr1 *ctr1, ZERO_STRUCTP(ctr1); - for (; resume_handle < *total_entries; resume_handle++) { + for (; (resume_handle < *total_entries) && num_entries < MAX_CONN_ENTRIES; resume_handle++) { ctr1->array = TALLOC_REALLOC_ARRAY(talloc_tos(), ctr1->array, -- cgit From d83931cb6e809b22eba5f1a8df1312cee9d4b19c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 May 2008 16:23:07 -0700 Subject: Remove MAX_SESS_ENTRIES and MAX_CONN_ENTRIES limits as they are no longer needed now we have IDL marshalling. Change the calculation of the 32-bit fileid we return to a Windows client. We can't just use the generation count as it starts at zero for every smbd - and this command must enumerate all files open across all smbds. We'd really like combination of process-id + dev + inode + generation count to be unique, but as we can't fit that into 32 bits just use 16 bits of pid + generation count. Jeremy. (This used to be commit 8b926d5a93d04b828990057ae6f1e090764305c1) --- source3/rpc_server/srv_srvsvc_nt.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index ebbc39c304..9ffe9a569f 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -32,19 +32,6 @@ extern const struct generic_mapping file_generic_mapping; #define MAX_SERVER_DISK_ENTRIES 15 -/***************************/ - -/* oops - this is going to take up a *massive* amount of stack. */ -/* the UNISTR2s already have 1024 uint16 chars in them... */ - -#define MAX_SESS_ENTRIES 32 - -/***************************/ - -/* oops - this is going to take up a *massive* amount of stack. */ -/* the UNISTR2s already have 1024 uint16 chars in them... */ -#define MAX_CONN_ENTRIES 32 - /* Use for enumerating connections, pipes, & files */ struct file_enum_count { @@ -102,7 +89,7 @@ static int pipe_enum_fn( struct db_record *rec, void *p) fenum->ctr3->array = f; init_srvsvc_NetFileInfo3(&fenum->ctr3->array[i], - (uint32_t)((procid_to_pid(&prec.pid)<<16) & prec.pnum), + (((uint32_t)(procid_to_pid(&prec.pid))<<16) | prec.pnum), (FILE_READ_DATA|FILE_WRITE_DATA), 0, fullpath, @@ -204,7 +191,7 @@ static void enum_file_fn( const struct share_mode_entry *e, /* now fill in the srvsvc_NetFileInfo3 struct */ init_srvsvc_NetFileInfo3(&fenum->ctr3->array[i], - e->share_file_id, + (((uint32_t)(procid_to_pid(&e->pid))<<16) | e->share_file_id), permissions, num_locks, fullpath, @@ -748,7 +735,7 @@ static WERROR init_srv_sess_info_0(pipes_struct *p, return WERR_OK; } - for (; resume_handle < *total_entries && num_entries < MAX_SESS_ENTRIES; resume_handle++) { + for (; resume_handle < *total_entries; resume_handle++) { ctr0->array = TALLOC_REALLOC_ARRAY(p->mem_ctx, ctr0->array, @@ -831,7 +818,7 @@ static WERROR init_srv_sess_info_1(pipes_struct *p, *total_entries = list_sessions(p->mem_ctx, &session_list); - for (; resume_handle < *total_entries && num_entries < MAX_SESS_ENTRIES; resume_handle++) { + for (; resume_handle < *total_entries; resume_handle++) { uint32 num_files; uint32 connect_time; struct passwd *pw = sys_getpwnam(session_list[resume_handle].username); @@ -900,7 +887,7 @@ static WERROR init_srv_conn_info_0(struct srvsvc_NetConnCtr0 *ctr0, ZERO_STRUCTP(ctr0); - for (; resume_handle < *total_entries && num_entries < MAX_CONN_ENTRIES; resume_handle++) { + for (; resume_handle < *total_entries; resume_handle++) { ctr0->array = TALLOC_REALLOC_ARRAY(talloc_tos(), ctr0->array, @@ -955,7 +942,7 @@ static WERROR init_srv_conn_info_1(struct srvsvc_NetConnCtr1 *ctr1, ZERO_STRUCTP(ctr1); - for (; (resume_handle < *total_entries) && num_entries < MAX_CONN_ENTRIES; resume_handle++) { + for (; resume_handle < *total_entries; resume_handle++) { ctr1->array = TALLOC_REALLOC_ARRAY(talloc_tos(), ctr1->array, -- cgit From 320fadd8fc600262d26ea417a92d395aeb16ef57 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 11 May 2008 01:03:45 +0200 Subject: Remove the reference to current_user_info from share_access.c This required to pass around the domain a bit (This used to be commit 17b0db20d28d1b737c5e86b78106657e8ca5ce9c) --- source3/rpc_server/srv_spoolss_nt.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 0e98a39426..06b3d4a07a 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1649,7 +1649,8 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, !user_has_privileges(p->pipe_user.nt_user_token, &se_printop ) && !token_contains_name_in_list( - uidtoname(p->pipe_user.ut.uid), NULL, + uidtoname(p->pipe_user.ut.uid), + NULL, NULL, p->pipe_user.nt_user_token, lp_printer_admin(snum))) { close_printer_handle(p, handle); @@ -1703,7 +1704,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, return WERR_ACCESS_DENIED; } - if (!user_ok_token(uidtoname(p->pipe_user.ut.uid), + if (!user_ok_token(uidtoname(p->pipe_user.ut.uid), NULL, p->pipe_user.nt_user_token, snum) || !print_access_check(&p->pipe_user, snum, printer_default->access_required)) { @@ -2008,8 +2009,10 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER if ( (p->pipe_user.ut.uid != 0) && !user_has_privileges(p->pipe_user.nt_user_token, &se_printop ) - && !token_contains_name_in_list( uidtoname(p->pipe_user.ut.uid), - NULL, p->pipe_user.nt_user_token, lp_printer_admin(-1)) ) + && !token_contains_name_in_list( + uidtoname(p->pipe_user.ut.uid), NULL, + NULL, p->pipe_user.nt_user_token, + lp_printer_admin(-1)) ) { return WERR_ACCESS_DENIED; } @@ -2103,8 +2106,9 @@ WERROR _spoolss_deleteprinterdriverex(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIV if ( (p->pipe_user.ut.uid != 0) && !user_has_privileges(p->pipe_user.nt_user_token, &se_printop ) - && !token_contains_name_in_list( uidtoname(p->pipe_user.ut.uid), - NULL, p->pipe_user.nt_user_token, lp_printer_admin(-1)) ) + && !token_contains_name_in_list( + uidtoname(p->pipe_user.ut.uid), NULL, NULL, + p->pipe_user.nt_user_token, lp_printer_admin(-1)) ) { return WERR_ACCESS_DENIED; } -- cgit From 6811dc3fc236e62f042e43efa500cc55346c29d6 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 May 2008 11:23:59 -0700 Subject: Allow server manager to close open files selected by id. Jeremy. (This used to be commit 7eeed8bb41059ec2bddedb6a71deddeec7f33af2) --- source3/rpc_server/srv_srvsvc_nt.c | 57 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 9ffe9a569f..6f7b232071 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2399,14 +2399,67 @@ WERROR _srvsvc_NetNameValidate(pipes_struct *p, return WERR_OK; } +/******************************************************************* +********************************************************************/ + +static void enum_file_close_fn( const struct share_mode_entry *e, + const char *sharepath, const char *fname, + void *private_data ) +{ + char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE]; + struct srvsvc_NetFileClose *r = + (struct srvsvc_NetFileClose *)private_data; + uint32_t fid = (((uint32_t)(procid_to_pid(&e->pid))<<16) | e->share_file_id); + + if (fid != r->in.fid) { + return; /* Not this file. */ + } + + if (!process_exists(e->pid) ) { + return; + } + + /* Ok - send the close message. */ + DEBUG(10,("enum_file_close_fn: request to close file %s, %s\n", + sharepath, + share_mode_str(talloc_tos(), 0, e) )); + + share_mode_entry_to_message(msg, e); + + r->out.result = ntstatus_to_werror( + messaging_send_buf(smbd_messaging_context(), + e->pid, MSG_SMB_CLOSE_FILE, + (uint8 *)msg, + MSG_SMB_SHARE_MODE_ENTRY_SIZE)); +} + /******************************************************************** + Close a file given a 32-bit file id. ********************************************************************/ WERROR _srvsvc_NetFileClose(pipes_struct *p, struct srvsvc_NetFileClose *r) { - return WERR_ACCESS_DENIED; -} + struct current_user user; + SE_PRIV se_diskop = SE_DISK_OPERATOR; + bool is_disk_op; + + DEBUG(5,("_srvsvc_NetFileClose: %d\n", __LINE__)); + + get_current_user(&user,p); + is_disk_op = user_has_privileges( p->pipe_user.nt_user_token, &se_diskop ); + + if (user.ut.uid != sec_initial_uid() && !is_disk_op) { + return WERR_ACCESS_DENIED; + } + + /* enum_file_close_fn sends the close message to + * the relevent smbd process. */ + + r->out.result = WERR_BADFILE; + share_mode_forall( enum_file_close_fn, (void *)r); + return r->out.result; +} /******************************************************************** ********************************************************************/ -- cgit From 13b2f59383c117033605df77935a67c7cc1c8da1 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Mon, 9 Jun 2008 11:45:39 -0400 Subject: Don't reset password last set time just because the expired flag is set to 0. If the account wasn't expired but autolocked, using "net user /dom /active:y" would clear this, incorrectly setting the current time as the new "password last set" time. (This used to be commit 0f292d70f698b8ae885005b5704a96476e876571) --- source3/rpc_server/srv_samr_util.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c index 74daf46e84..ef588aed1a 100644 --- a/source3/rpc_server/srv_samr_util.c +++ b/source3/rpc_server/srv_samr_util.c @@ -339,7 +339,15 @@ void copy_id21_to_sam_passwd(const char *log_prefix, if (from->password_expired == PASS_MUST_CHANGE_AT_NEXT_LOGON) { pdb_set_pass_last_set_time(to, 0, PDB_CHANGED); } else { - pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED); + /* A subtlety here: some windows commands will + clear the expired flag even though it's not + set, and we don't want to reset the time + in these caess. "net user /dom /active:y" + for example, to clear an autolocked acct. + We must check to see if it's expired first. jmcd */ + stored_time = pdb_get_pass_last_set_time(to); + if (stored_time == 0) + pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED); } } } -- cgit From c404c8950d4c4a5ab56e5a1b7b895403cfa0ea18 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 13 Jun 2008 15:30:08 +0200 Subject: Fix a crash in _winreg_QueryValue Coverity ID 474, value_length and type are both unique, not ref pointers and can thus be NULL. Karolin, please merge this to -stable. Thanks, Volker (cherry picked from commit 999533c0ccced59141d8baff5bc248d63e2a966f) (This used to be commit 7e07ec68f15908a998f83d615a1b4d1349935a54) --- source3/rpc_server/srv_winreg_nt.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 7b74871104..84bcf0bf89 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -230,6 +230,10 @@ WERROR _winreg_QueryValue(pipes_struct *p, struct winreg_QueryValue *r) if ( !regkey ) return WERR_BADFID; + if ((r->out.value_length == NULL) || (r->out.type == NULL)) { + return WERR_INVALID_PARAM; + } + *r->out.value_length = *r->out.type = REG_NONE; DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->key->name)); -- cgit From fdcf760d1c3bd83570f55972930226ecbc5e028b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 16 Jun 2008 13:27:16 +0200 Subject: Fix bug 5500 -- thanks to mathion at thorrovydeti.com for reporting (cherry picked from commit 996c3ce6f0dbe79b0679ae30afd873c24fe5b1eb) (This used to be commit 1f86c7a2a19e66948c9b51572d3c078b6e03ef52) --- source3/rpc_server/srv_lsa_nt.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 7c33bd0d4f..7be139d372 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -491,7 +491,9 @@ NTSTATUS _lsa_EnumTrustDom(pipes_struct *p, if (!(info->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; + become_root(); nt_status = pdb_enum_trusteddoms(p->mem_ctx, &num_domains, &domains); + unbecome_root(); if (!NT_STATUS_IS_OK(nt_status)) { return nt_status; -- cgit From 40f5eab5eb515937e1b23cf6762b77c194d29b9d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 19 Jun 2008 16:54:12 +0200 Subject: Wrap the unix token info in a unix_user_token in auth_serversupplied_info No functional change, this is a preparation for more current_user ref removal (This used to be commit dcaedf345e62ab74ea87f0a3fa1e3199c75c5445) --- source3/rpc_server/srv_pipe.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 52e4fdfd5b..dcc4cd448f 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -660,8 +660,8 @@ static bool pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) * Store the UNIX credential data (uid/gid pair) in the pipe structure. */ - p->pipe_user.ut.uid = a->server_info->uid; - p->pipe_user.ut.gid = a->server_info->gid; + p->pipe_user.ut.uid = a->server_info->utok.uid; + p->pipe_user.ut.gid = a->server_info->utok.gid; /* * We're an authenticated bind over smbd, so the session key needs to @@ -675,10 +675,11 @@ static bool pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) return False; } - p->pipe_user.ut.ngroups = a->server_info->n_groups; + p->pipe_user.ut.ngroups = a->server_info->utok.ngroups; if (p->pipe_user.ut.ngroups) { - if (!(p->pipe_user.ut.groups = (gid_t *)memdup(a->server_info->groups, - sizeof(gid_t) * p->pipe_user.ut.ngroups))) { + if (!(p->pipe_user.ut.groups = (gid_t *)memdup( + a->server_info->utok.groups, + sizeof(gid_t) * p->pipe_user.ut.ngroups))) { DEBUG(0,("failed to memdup group list to p->pipe_user.groups\n")); return False; } -- cgit From c203de0e3a6f5b2254bc5c308cf87e6a7b67cad8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 20 Jun 2008 16:22:32 +0200 Subject: Fix a SAFE_FREE/TALLOC_FREE mixup (This used to be commit b39852f51313059899630ba63509fee904ba3613) --- source3/rpc_server/srv_pipe_hnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 1d62199ad8..2e03d01c93 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -221,7 +221,7 @@ smb_np_struct *open_rpc_pipe_p(const char *pipe_name, if (p->np_state == NULL) { DEBUG(0,("open_rpc_pipe_p: make_internal_rpc_pipe_p failed.\n")); - SAFE_FREE(p); + TALLOC_FREE(p); return NULL; } -- cgit From df905a5d77037eaffe5f52edd26409152b740068 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 20 Jun 2008 16:22:49 +0200 Subject: Make pipes_struct its own talloc ctx (This used to be commit 829b1ad4697f2f1ea008377d591456722dccd025) --- source3/rpc_server/srv_netlog_nt.c | 29 ++++++++++------------------- source3/rpc_server/srv_pipe.c | 2 +- source3/rpc_server/srv_pipe_hnd.c | 25 +++++-------------------- 3 files changed, 16 insertions(+), 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 863c62acc4..a0812283d6 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -377,7 +377,7 @@ NTSTATUS _netr_ServerReqChallenge(pipes_struct *p, struct netr_ServerReqChallenge *r) { if (!p->dc) { - p->dc = TALLOC_ZERO_P(p->pipe_state_mem_ctx, struct dcinfo); + p->dc = TALLOC_ZERO_P(p, struct dcinfo); if (!p->dc) { return NT_STATUS_NO_MEMORY; } @@ -582,9 +582,8 @@ NTSTATUS _netr_ServerPasswordSet(pipes_struct *p, if (!p->dc) { /* Restore the saved state of the netlogon creds. */ become_root(); - ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, - remote_machine, - &p->dc); + ret = secrets_restore_schannel_session_info(p, remote_machine, + &p->dc); unbecome_root(); if (!ret) { return NT_STATUS_INVALID_HANDLE; @@ -613,9 +612,7 @@ NTSTATUS _netr_ServerPasswordSet(pipes_struct *p, } become_root(); - secrets_store_schannel_session_info(p->pipe_state_mem_ctx, - remote_machine, - p->dc); + secrets_store_schannel_session_info(p, remote_machine, p->dc); ret = pdb_getsampwnam(sampass, p->dc->mach_acct); unbecome_root(); @@ -716,9 +713,8 @@ NTSTATUS _netr_LogonSamLogoff(pipes_struct *p, bool ret; become_root(); - ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, - r->in.computer_name, - &p->dc); + ret = secrets_restore_schannel_session_info( + p, r->in.computer_name, &p->dc); unbecome_root(); if (!ret) { return NT_STATUS_INVALID_HANDLE; @@ -739,9 +735,7 @@ NTSTATUS _netr_LogonSamLogoff(pipes_struct *p, /* We must store the creds state after an update. */ become_root(); - secrets_store_schannel_session_info(p->pipe_state_mem_ctx, - r->in.computer_name, - p->dc); + secrets_store_schannel_session_info(p, r->in.computer_name, p->dc); unbecome_root(); return NT_STATUS_OK; @@ -814,9 +808,8 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p, bool ret; become_root(); - ret = secrets_restore_schannel_session_info(p->pipe_state_mem_ctx, - remote_machine, - &p->dc); + ret = secrets_restore_schannel_session_info( + p, remote_machine, &p->dc); unbecome_root(); if (!ret) { return NT_STATUS_INVALID_HANDLE; @@ -837,9 +830,7 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p, /* We must store the creds state after an update. */ become_root(); - secrets_store_schannel_session_info(p->pipe_state_mem_ctx, - remote_machine, - p->dc); + secrets_store_schannel_session_info(p, remote_machine, p->dc); unbecome_root(); } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index dcc4cd448f..0987a420d5 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1343,7 +1343,7 @@ static bool pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, return False; } - p->auth.a_u.schannel_auth = TALLOC_P(p->pipe_state_mem_ctx, struct schannel_auth_struct); + p->auth.a_u.schannel_auth = talloc(p, struct schannel_auth_struct); if (!p->auth.a_u.schannel_auth) { TALLOC_FREE(pdcinfo); return False; diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 2e03d01c93..22903aacba 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -279,33 +279,23 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, return NULL; } - p = SMB_MALLOC_P(pipes_struct); + p = TALLOC_ZERO_P(NULL, pipes_struct); if (!p) { DEBUG(0,("ERROR! no memory for pipes_struct!\n")); return NULL; } - ZERO_STRUCTP(p); - if ((p->mem_ctx = talloc_init("pipe %s %p", pipe_name, p)) == NULL) { DEBUG(0,("open_rpc_pipe_p: talloc_init failed.\n")); - SAFE_FREE(p); - return NULL; - } - - if ((p->pipe_state_mem_ctx = talloc_init("pipe_state %s %p", pipe_name, p)) == NULL) { - DEBUG(0,("open_rpc_pipe_p: talloc_init failed.\n")); - talloc_destroy(p->mem_ctx); - SAFE_FREE(p); + TALLOC_FREE(p); return NULL; } if (!init_pipe_handle_list(p, pipe_name)) { DEBUG(0,("open_rpc_pipe_p: init_pipe_handles failed.\n")); talloc_destroy(p->mem_ctx); - talloc_destroy(p->pipe_state_mem_ctx); - SAFE_FREE(p); + TALLOC_FREE(p); return NULL; } @@ -319,9 +309,8 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, if(!prs_init(&p->in_data.data, RPC_MAX_PDU_FRAG_LEN, p->mem_ctx, MARSHALL)) { DEBUG(0,("open_rpc_pipe_p: malloc fail for in_data struct.\n")); talloc_destroy(p->mem_ctx); - talloc_destroy(p->pipe_state_mem_ctx); close_policy_by_pipe(p); - SAFE_FREE(p); + TALLOC_FREE(p); return NULL; } @@ -1214,10 +1203,6 @@ static bool close_internal_rpc_pipe_hnd(void *np_conn) talloc_destroy(p->mem_ctx); } - if (p->pipe_state_mem_ctx) { - talloc_destroy(p->pipe_state_mem_ctx); - } - free_pipe_rpc_context( p->contexts ); /* Free the handles database. */ @@ -1231,7 +1216,7 @@ static bool close_internal_rpc_pipe_hnd(void *np_conn) ZERO_STRUCTP(p); - SAFE_FREE(p); + TALLOC_FREE(p); return True; } -- cgit From 19654e232cc3b761931259aa587af24d7313781b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 22 Jun 2008 20:27:20 +0200 Subject: Check for sec_initial_uid() instead of uid==0 in dfs management (This used to be commit 948607f16112f6529f3a54cd6bbe978e8a600bc8) --- source3/rpc_server/srv_dfs_nt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 29538a304f..974523dded 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -49,7 +49,7 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) NTSTATUS status; TALLOC_CTX *ctx = talloc_tos(); - if (p->pipe_user.ut.uid != 0) { + if (p->pipe_user.ut.uid != sec_initial_uid()) { DEBUG(10,("_dfs_add: uid != 0. Access denied.\n")); return WERR_ACCESS_DENIED; } @@ -119,7 +119,7 @@ WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) TALLOC_CTX *ctx = talloc_tos(); char *altpath = NULL; - if (p->pipe_user.ut.uid != 0) { + if (p->pipe_user.ut.uid != sec_initial_uid()) { DEBUG(10,("_dfs_remove: uid != 0. Access denied.\n")); return WERR_ACCESS_DENIED; } -- cgit From 13ebf889b39e0b71f1f98198b0d003f5461d42a6 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 22 Jun 2008 20:33:28 +0200 Subject: Remove the "exists" parameter from create_msdfs_link Jeremy, setting "exists" to True in _dfs_Add prevented the initial creation of a new symlink for me, because the SMB_VFS_UNLINK failed. This also exists in 3.2. I only check it into 3.3 as I would like you to look at it first. Thanks, Volker (This used to be commit f58b098a4172949018e84c4d0c722d6eb9bba514) --- source3/rpc_server/srv_dfs_nt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 974523dded..72b8236fb9 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -44,7 +44,6 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) struct referral *old_referral_list = NULL; bool self_ref = False; int consumedcnt = 0; - bool exists = False; char *altpath = NULL; NTSTATUS status; TALLOC_CTX *ctx = talloc_tos(); @@ -76,7 +75,6 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) return ntstatus_to_werror(status); } - exists = True; jn->referral_count += 1; old_referral_list = jn->referral_list; @@ -101,7 +99,7 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) jn->referral_list[jn->referral_count-1].ttl = REFERRAL_TTL; jn->referral_list[jn->referral_count-1].alternate_path = altpath; - if(!create_msdfs_link(jn, exists)) { + if(!create_msdfs_link(jn)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_CANT_CREATE_JUNCT; } @@ -184,7 +182,7 @@ WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) return WERR_DFS_NO_SUCH_VOL; } } else { - if(!create_msdfs_link(jn, True)) { + if(!create_msdfs_link(jn)) { vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_CANT_CREATE_JUNCT; } -- cgit From 344941bb49d91e6b382196c347e5259e133f506d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 22 Jun 2008 22:19:10 +0200 Subject: Move the responsibility to keep the cwd from srv_dfs_nt to msdfs.c (This used to be commit 7db382588ac90fe250b72cf4cd07afb39fcae7c0) --- source3/rpc_server/srv_dfs_nt.c | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_dfs_nt.c b/source3/rpc_server/srv_dfs_nt.c index 72b8236fb9..661d262dc4 100644 --- a/source3/rpc_server/srv_dfs_nt.c +++ b/source3/rpc_server/srv_dfs_nt.c @@ -78,8 +78,6 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) jn->referral_count += 1; old_referral_list = jn->referral_list; - vfs_ChDir(p->conn,p->conn->connectpath); - if (jn->referral_count < 1) { return WERR_NOMEM; } @@ -100,10 +98,8 @@ WERROR _dfs_Add(pipes_struct *p, struct dfs_Add *r) jn->referral_list[jn->referral_count-1].alternate_path = altpath; if(!create_msdfs_link(jn)) { - vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_CANT_CREATE_JUNCT; } - vfs_ChDir(p->conn,p->conn->connectpath); return WERR_OK; } @@ -147,10 +143,8 @@ WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) /* if no server-share pair given, remove the msdfs link completely */ if(!r->in.servername && !r->in.sharename) { if(!remove_msdfs_link(jn)) { - vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; } - vfs_ChDir(p->conn,p->conn->connectpath); } else { int i=0; /* compare each referral in the list with the one to remove */ @@ -178,16 +172,13 @@ WERROR _dfs_Remove(pipes_struct *p, struct dfs_Remove *r) /* Only one referral, remove it */ if(jn->referral_count == 1) { if(!remove_msdfs_link(jn)) { - vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; } } else { if(!create_msdfs_link(jn)) { - vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_CANT_CREATE_JUNCT; } } - vfs_ChDir(p->conn,p->conn->connectpath); } return WERR_OK; @@ -287,7 +278,6 @@ WERROR _dfs_Enum(pipes_struct *p, struct dfs_Enum *r) num_jn = 0; jn = NULL; } - vfs_ChDir(p->conn,p->conn->connectpath); DEBUG(5,("_dfs_Enum: %u junctions found in Dfs, doing level %d\n", (unsigned int)num_jn, r->in.level)); @@ -370,12 +360,9 @@ WERROR _dfs_GetInfo(pipes_struct *p, struct dfs_GetInfo *r) if(!NT_STATUS_IS_OK(get_referred_path(ctx, r->in.dfs_entry_path, jn, &consumedcnt, &self_ref)) || consumedcnt < strlen(r->in.dfs_entry_path)) { - vfs_ChDir(p->conn,p->conn->connectpath); return WERR_DFS_NO_SUCH_VOL; } - vfs_ChDir(p->conn,p->conn->connectpath); - switch (r->in.level) { case 1: r->out.info->info1 = TALLOC_ZERO_P(ctx,struct dfs_Info1); -- cgit From c5401a2a46da9a7523f4363be14805eb893ea0f4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 23 Jun 2008 08:33:04 +0200 Subject: Correct calculation of "remark" in srv_srvsvc_nt.c Very likely the client is not interested in the values for the IPC$ share :-) (This used to be commit 40ca5764cf4310769c002b8cb6041fe2af4e6d0b) --- source3/rpc_server/srv_srvsvc_nt.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 6f7b232071..57f2fe7f65 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -259,9 +259,11 @@ static void init_srv_share_info_1(pipes_struct *p, struct srvsvc_NetShareInfo1 * char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum)); if (remark) { - remark = standard_sub_conn(p->mem_ctx, - p->conn, - remark); + remark = talloc_sub_advanced( + p->mem_ctx, lp_servicename(snum), + get_current_username(), lp_pathname(snum), + p->pipe_user.ut.uid, get_current_username(), + "", remark); } init_srvsvc_NetShareInfo1(r, net_name, @@ -284,9 +286,11 @@ static void init_srv_share_info_2(pipes_struct *p, struct srvsvc_NetShareInfo2 * remark = talloc_strdup(p->mem_ctx, lp_comment(snum)); if (remark) { - remark = standard_sub_conn(p->mem_ctx, - p->conn, - remark); + remark = talloc_sub_advanced( + p->mem_ctx, lp_servicename(snum), + get_current_username(), lp_pathname(snum), + p->pipe_user.ut.uid, get_current_username(), + "", remark); } path = talloc_asprintf(p->mem_ctx, "C:%s", lp_pathname(snum)); @@ -348,7 +352,11 @@ static void init_srv_share_info_501(pipes_struct *p, struct srvsvc_NetShareInfo5 char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum)); if (remark) { - remark = standard_sub_conn(p->mem_ctx, p->conn, remark); + remark = talloc_sub_advanced( + p->mem_ctx, lp_servicename(snum), + get_current_username(), lp_pathname(snum), + p->pipe_user.ut.uid, get_current_username(), + "", remark); } init_srvsvc_NetShareInfo501(r, net_name, @@ -372,7 +380,11 @@ static void init_srv_share_info_502(pipes_struct *p, struct srvsvc_NetShareInfo5 char *remark = talloc_strdup(ctx, lp_comment(snum));; if (remark) { - remark = standard_sub_conn(ctx, p->conn, remark); + remark = talloc_sub_advanced( + p->mem_ctx, lp_servicename(snum), + get_current_username(), lp_pathname(snum), + p->pipe_user.ut.uid, get_current_username(), + "", remark); } path = talloc_asprintf(ctx, "C:%s", lp_pathname(snum)); if (path) { @@ -407,7 +419,11 @@ static void init_srv_share_info_1004(pipes_struct *p, struct srvsvc_NetShareInfo char *remark = talloc_strdup(p->mem_ctx, lp_comment(snum)); if (remark) { - remark = standard_sub_conn(p->mem_ctx, p->conn, remark); + remark = talloc_sub_advanced( + p->mem_ctx, lp_servicename(snum), + get_current_username(), lp_pathname(snum), + p->pipe_user.ut.uid, get_current_username(), + "", remark); } init_srvsvc_NetShareInfo1004(r, remark ? remark : ""); -- cgit From 9ff4001245d718515cb90036659109e23833e5fe Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 23 Jun 2008 08:38:27 +0200 Subject: Remove "conn" from pipes_struct For spoolss, we need the client's IP address (This used to be commit 64a4dfaa826cf9319ef3f5c65023352bf8af539e) --- source3/rpc_server/srv_pipe_hnd.c | 3 ++- source3/rpc_server/srv_spoolss_nt.c | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 22903aacba..1feed1550c 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -316,7 +316,8 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, DLIST_ADD(InternalPipes, p); - p->conn = conn; + memcpy(p->client_address, conn->client_address, + sizeof(p->client_address)); p->vuid = vuid; diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 06b3d4a07a..eaf563eaa9 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2721,9 +2721,8 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE !get_printer_snum(p, handle, &snum, NULL) ) return WERR_BADFID; - if (!interpret_string_addr(&client_ss, - p->conn->client_address, - AI_NUMERICHOST)) { + if (!interpret_string_addr(&client_ss, p->client_address, + AI_NUMERICHOST)) { return WERR_SERVER_UNAVAILABLE; } -- cgit From d331624fdfe9fc72f1da7fd01c59a1a20cf1c7d7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 24 Jun 2008 14:18:55 +0200 Subject: Add server_info to pipes_struct (This used to be commit d621867bb8767e1c4236d28dd9294a61db6cbb10) --- source3/rpc_server/srv_pipe.c | 10 ++++++++++ source3/rpc_server/srv_pipe_hnd.c | 9 +++++++++ 2 files changed, 19 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 0987a420d5..04d18d51c9 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -694,6 +694,16 @@ static bool pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) return False; } + TALLOC_FREE(p->server_info); + + p->server_info = copy_serverinfo(p, a->server_info); + if (p->server_info == NULL) { + DEBUG(0, ("copy_serverinfo failed\n")); + return false; + } + + server_info_set_session_key(p->server_info, p->session_key); + return True; } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 1feed1550c..9a57a1bdb3 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -314,6 +314,15 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, return NULL; } + p->server_info = copy_serverinfo(p, conn->server_info); + if (p->server_info == NULL) { + DEBUG(0, ("open_rpc_pipe_p: copy_serverinfo failed\n")); + talloc_destroy(p->mem_ctx); + close_policy_by_pipe(p); + TALLOC_FREE(p); + return NULL; + } + DLIST_ADD(InternalPipes, p); memcpy(p->client_address, conn->client_address, -- cgit From cebbb2d84a8ab365f36d7e30177418a44fddb9e5 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 24 Jun 2008 14:25:23 +0200 Subject: Fix typo (This used to be commit 41d2daeaa5a87da82a0debc4c9cfe14976215bd8) --- source3/rpc_server/srv_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 04d18d51c9..cac48db7ee 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -664,7 +664,7 @@ static bool pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) p->pipe_user.ut.gid = a->server_info->utok.gid; /* - * We're an authenticated bind over smbd, so the session key needs to + * We're an authenticated bind over smb, so the session key needs to * be set to "SystemLibraryDTC". Weird, but this is what Windows * does. See the RPC-SAMBA3SESSIONKEY. */ -- cgit From 747a5809528cffc40f46d7e27a96ce0c559056b4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 24 Jun 2008 14:33:31 +0200 Subject: Now that we have p->server_info, use p->server_info->user_session_key (This used to be commit aefad64e3a5c86d2f988d47e6215ed2085b8fc47) --- source3/rpc_server/srv_pipe.c | 47 +++++++++++++++++++++++--------------- source3/rpc_server/srv_pipe_hnd.c | 4 ---- source3/rpc_server/srv_samr_nt.c | 22 ++++++++++-------- source3/rpc_server/srv_wkssvc_nt.c | 14 +++++------- 4 files changed, 47 insertions(+), 40 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index cac48db7ee..80e2b2f9a9 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -606,9 +606,10 @@ bool create_next_pdu(pipes_struct *p) static bool pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) { - DATA_BLOB reply; + DATA_BLOB session_key, reply; NTSTATUS status; AUTH_NTLMSSP_STATE *a = p->auth.a_u.auth_ntlmssp_state; + bool ret; DEBUG(5,("pipe_ntlmssp_verify_final: pipe %s checking user details\n", p->name)); @@ -663,18 +664,6 @@ static bool pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) p->pipe_user.ut.uid = a->server_info->utok.uid; p->pipe_user.ut.gid = a->server_info->utok.gid; - /* - * We're an authenticated bind over smb, so the session key needs to - * be set to "SystemLibraryDTC". Weird, but this is what Windows - * does. See the RPC-SAMBA3SESSIONKEY. - */ - - data_blob_free(&p->session_key); - p->session_key = generic_session_key(); - if (!p->session_key.data) { - return False; - } - p->pipe_user.ut.ngroups = a->server_info->utok.ngroups; if (p->pipe_user.ut.ngroups) { if (!(p->pipe_user.ut.groups = (gid_t *)memdup( @@ -702,7 +691,20 @@ static bool pipe_ntlmssp_verify_final(pipes_struct *p, DATA_BLOB *p_resp_blob) return false; } - server_info_set_session_key(p->server_info, p->session_key); + /* + * We're an authenticated bind over smb, so the session key needs to + * be set to "SystemLibraryDTC". Weird, but this is what Windows + * does. See the RPC-SAMBA3SESSIONKEY. + */ + + session_key = generic_session_key(); + if (session_key.data == NULL) { + return False; + } + + ret = server_info_set_session_key(p->server_info, session_key); + + data_blob_free(&session_key); return True; } @@ -1332,6 +1334,7 @@ static bool pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, bool ret; struct dcinfo *pdcinfo; uint32 flags; + DATA_BLOB session_key; if (!smb_io_rpc_auth_schannel_neg("", &neg, rpc_in_p, 0)) { DEBUG(0,("pipe_schannel_auth_bind: Could not unmarshal SCHANNEL auth neg\n")); @@ -1378,12 +1381,20 @@ static bool pipe_schannel_auth_bind(pipes_struct *p, prs_struct *rpc_in_p, * anymore. */ - data_blob_free(&p->session_key); - p->session_key = generic_session_key(); - if (p->session_key.data == NULL) { + session_key = generic_session_key(); + if (session_key.data == NULL) { DEBUG(0, ("pipe_schannel_auth_bind: Could not alloc session" " key\n")); - return False; + return false; + } + + ret = server_info_set_session_key(p->server_info, session_key); + + data_blob_free(&session_key); + + if (!ret) { + DEBUG(0, ("server_info_set_session_key failed\n")); + return false; } init_rpc_hdr_auth(&auth_info, RPC_SCHANNEL_AUTH_TYPE, pauth_info->auth_level, RPC_HDR_AUTH_LEN, 1); diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 9a57a1bdb3..f2b2919f43 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -339,9 +339,6 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, /* Store the session key and NT_TOKEN */ if (vuser) { - p->session_key = data_blob( - vuser->server_info->user_session_key.data, - vuser->server_info->user_session_key.length); p->pipe_user.nt_user_token = dup_nt_token( NULL, vuser->server_info->ptok); } @@ -1219,7 +1216,6 @@ static bool close_internal_rpc_pipe_hnd(void *np_conn) close_policy_by_pipe(p); TALLOC_FREE(p->pipe_user.nt_user_token); - data_blob_free(&p->session_key); SAFE_FREE(p->pipe_user.ut.groups); DLIST_REMOVE(InternalPipes, p); diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index a89e00f1ec..1b1e98c049 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -4206,11 +4206,11 @@ static NTSTATUS samr_SetUserInfo_internal(const char *fn_name, break; case 23: - if (!p->session_key.length) { + if (!p->server_info->user_session_key.length) { status = NT_STATUS_NO_USER_SESSION_KEY; } SamOEMhashBlob(info->info23.password.data, 516, - &p->session_key); + &p->server_info->user_session_key); dump_data(100, info->info23.password.data, 516); @@ -4219,12 +4219,12 @@ static NTSTATUS samr_SetUserInfo_internal(const char *fn_name, break; case 24: - if (!p->session_key.length) { + if (!p->server_info->user_session_key.length) { status = NT_STATUS_NO_USER_SESSION_KEY; } SamOEMhashBlob(info->info24.password.data, 516, - &p->session_key); + &p->server_info->user_session_key); dump_data(100, info->info24.password.data, 516); @@ -4235,11 +4235,12 @@ static NTSTATUS samr_SetUserInfo_internal(const char *fn_name, break; case 25: - if (!p->session_key.length) { + if (!p->server_info->user_session_key.length) { status = NT_STATUS_NO_USER_SESSION_KEY; } - encode_or_decode_arc4_passwd_buffer(info->info25.password.data, - &p->session_key); + encode_or_decode_arc4_passwd_buffer( + info->info25.password.data, + &p->server_info->user_session_key); dump_data(100, info->info25.password.data, 532); @@ -4255,11 +4256,12 @@ static NTSTATUS samr_SetUserInfo_internal(const char *fn_name, break; case 26: - if (!p->session_key.length) { + if (!p->server_info->user_session_key.length) { status = NT_STATUS_NO_USER_SESSION_KEY; } - encode_or_decode_arc4_passwd_buffer(info->info26.password.data, - &p->session_key); + encode_or_decode_arc4_passwd_buffer( + info->info26.password.data, + &p->server_info->user_session_key); dump_data(100, info->info26.password.data, 516); diff --git a/source3/rpc_server/srv_wkssvc_nt.c b/source3/rpc_server/srv_wkssvc_nt.c index 3c64abfcdf..c96439cc1a 100644 --- a/source3/rpc_server/srv_wkssvc_nt.c +++ b/source3/rpc_server/srv_wkssvc_nt.c @@ -316,10 +316,9 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p, return WERR_NOT_SUPPORTED; } - werr = decode_wkssvc_join_password_buffer(p->mem_ctx, - r->in.encrypted_password, - &p->session_key, - &cleartext_pwd); + werr = decode_wkssvc_join_password_buffer( + p->mem_ctx, r->in.encrypted_password, + &p->server_info->user_session_key, &cleartext_pwd); if (!W_ERROR_IS_OK(werr)) { return werr; } @@ -383,10 +382,9 @@ WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p, return WERR_ACCESS_DENIED; } - werr = decode_wkssvc_join_password_buffer(p->mem_ctx, - r->in.encrypted_password, - &p->session_key, - &cleartext_pwd); + werr = decode_wkssvc_join_password_buffer( + p->mem_ctx, r->in.encrypted_password, + &p->server_info->user_session_key, &cleartext_pwd); if (!W_ERROR_IS_OK(werr)) { return werr; } -- cgit From 8a9881c30b97671719f5859d54e7d66b1f08f2ef Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 24 Jun 2008 15:21:46 +0200 Subject: Remove a check on p->vuid in _netr_LogonSamLogon/off This is in preparation of removing p->vuid completely. I don't think this check here makes any sort of sense, it only proves that the user having done the session setup on its way to the schannel bind (ususally anonymous) did not do a logoff in between. But this would have been caught way before this in reply_pipe_write_and_X. (This used to be commit fbc00460f8deaa57bfbf16b12d29acec56578b63) --- source3/rpc_server/srv_netlog_nt.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index a0812283d6..7ece482d75 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -702,9 +702,6 @@ NTSTATUS _netr_LogonSamLogoff(pipes_struct *p, } - if (!get_valid_user_struct(p->vuid)) - return NT_STATUS_NO_SUCH_USER; - /* Using the remote machine name for the creds store: */ /* r->in.computer_name */ @@ -790,9 +787,6 @@ NTSTATUS _netr_LogonSamLogon(pipes_struct *p, return NT_STATUS_ACCESS_DENIED; } - if (!get_valid_user_struct(p->vuid)) - return NT_STATUS_NO_SUCH_USER; - if (process_creds) { fstring remote_machine; -- cgit From aa02c3fcd580a9e53b87d885fb87fb71f138bb7d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 24 Jun 2008 15:24:08 +0200 Subject: Remove p->vuid The users can use p->server_info. Now pipes_struct is decoupled from the SMB transport. (This used to be commit d4cf5a131919530317cd457006b4df5af2c69fa7) --- source3/rpc_server/srv_lsa_hnd.c | 8 +------- source3/rpc_server/srv_lsa_nt.c | 10 +++------- source3/rpc_server/srv_pipe_hnd.c | 6 ++---- 3 files changed, 6 insertions(+), 18 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index 78b891e071..377ed505b4 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -256,19 +256,13 @@ bool pipe_access_check(pipes_struct *p) anonymous > 0 */ if (lp_restrict_anonymous() > 0) { - user_struct *user = get_valid_user_struct(p->vuid); /* schannel, so we must be ok */ if (p->pipe_bound && (p->auth.auth_type == PIPE_AUTH_TYPE_SCHANNEL)) { return True; } - if (!user) { - DEBUG(3, ("invalid vuid %d\n", p->vuid)); - return False; - } - - if (user->server_info->guest) { + if (p->server_info->guest) { return False; } } diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 7be139d372..95e10ac28e 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -1463,14 +1463,10 @@ NTSTATUS _lsa_GetUserName(pipes_struct *p, struct lsa_GetUserName *r) { const char *username, *domname; - user_struct *vuser = get_valid_user_struct(p->vuid); struct lsa_String *account_name = NULL; struct lsa_String *authority_name = NULL; - if (vuser == NULL) - return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; - - if (vuser->server_info->guest) { + if (p->server_info->guest) { /* * I'm 99% sure this is not the right place to do this, * global_sid_Anonymous should probably be put into the token @@ -1481,8 +1477,8 @@ NTSTATUS _lsa_GetUserName(pipes_struct *p, return NT_STATUS_NO_MEMORY; } } else { - username = vuser->server_info->sanitized_username; - domname = pdb_get_domain(vuser->server_info->sam_account); + username = p->server_info->sanitized_username; + domname = pdb_get_domain(p->server_info->sam_account); } account_name = TALLOC_ZERO_P(p->mem_ctx, struct lsa_String); diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index f2b2919f43..c0b525c06b 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -328,8 +328,6 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, memcpy(p->client_address, conn->client_address, sizeof(p->client_address)); - p->vuid = vuid; - p->endian = RPC_LITTLE_ENDIAN; ZERO_STRUCT(p->pipe_user); @@ -366,8 +364,8 @@ static void set_incoming_fault(pipes_struct *p) p->in_data.pdu_needed_len = 0; p->in_data.pdu_received_len = 0; p->fault_state = True; - DEBUG(10,("set_incoming_fault: Setting fault state on pipe %s : vuid = 0x%x\n", - p->name, p->vuid )); + DEBUG(10, ("set_incoming_fault: Setting fault state on pipe %s\n", + p->name)); } /**************************************************************************** -- cgit From a3c0be63256b7db6325d8dcb599497e8e7905f08 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 24 Jun 2008 16:03:28 +0200 Subject: Change print_access_check to take auth_serversupplied_info instead of current_user Reason: This is the main user of p->current_user which I would like to remove (This used to be commit fd43059b3dfa8cdac9814de1c76f963ba5de9bcb) --- source3/rpc_server/srv_spoolss_nt.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index eaf563eaa9..d58b16c206 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1706,7 +1706,7 @@ WERROR _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, if (!user_ok_token(uidtoname(p->pipe_user.ut.uid), NULL, p->pipe_user.nt_user_token, snum) || - !print_access_check(&p->pipe_user, snum, + !print_access_check(p->server_info, snum, printer_default->access_required)) { DEBUG(3, ("access DENIED for printer open\n")); close_printer_handle(p, handle); @@ -5863,7 +5863,8 @@ WERROR _spoolss_startdocprinter(pipes_struct *p, SPOOL_Q_STARTDOCPRINTER *q_u, S jobname = unistr2_to_ascii_talloc(ctx, &info_1->docname); - Printer->jobid = print_job_start(&p->pipe_user, snum, jobname, Printer->nt_devmode); + Printer->jobid = print_job_start(p->server_info, snum, jobname, + Printer->nt_devmode); /* An error occured in print_job_start() so return an appropriate NT error code. */ @@ -5950,18 +5951,18 @@ static WERROR control_printer(POLICY_HND *handle, uint32 command, switch (command) { case PRINTER_CONTROL_PAUSE: - if (print_queue_pause(&p->pipe_user, snum, &errcode)) { + if (print_queue_pause(p->server_info, snum, &errcode)) { errcode = WERR_OK; } break; case PRINTER_CONTROL_RESUME: case PRINTER_CONTROL_UNPAUSE: - if (print_queue_resume(&p->pipe_user, snum, &errcode)) { + if (print_queue_resume(p->server_info, snum, &errcode)) { errcode = WERR_OK; } break; case PRINTER_CONTROL_PURGE: - if (print_queue_purge(&p->pipe_user, snum, &errcode)) { + if (print_queue_purge(p->server_info, snum, &errcode)) { errcode = WERR_OK; } break; @@ -5993,7 +5994,7 @@ WERROR _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R if (!get_printer_snum(p, handle, &snum, NULL)) return WERR_BADFID; - print_job_delete( &p->pipe_user, snum, Printer->jobid, &errcode ); + print_job_delete(p->server_info, snum, Printer->jobid, &errcode ); return errcode; } @@ -6886,18 +6887,18 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u switch (command) { case JOB_CONTROL_CANCEL: case JOB_CONTROL_DELETE: - if (print_job_delete(&p->pipe_user, snum, jobid, &errcode)) { + if (print_job_delete(p->server_info, snum, jobid, &errcode)) { errcode = WERR_OK; } break; case JOB_CONTROL_PAUSE: - if (print_job_pause(&p->pipe_user, snum, jobid, &errcode)) { + if (print_job_pause(p->server_info, snum, jobid, &errcode)) { errcode = WERR_OK; } break; case JOB_CONTROL_RESTART: case JOB_CONTROL_RESUME: - if (print_job_resume(&p->pipe_user, snum, jobid, &errcode)) { + if (print_job_resume(p->server_info, snum, jobid, &errcode)) { errcode = WERR_OK; } break; -- cgit From 8fffa902e06a1ce1f5ca20aab911eed6321f4055 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 26 Jun 2008 16:51:45 +0200 Subject: Fix valgrind errors in _spoolss_addprinterdriver Jerry, this was dropped as part of your SVN r15309 (037f9f83). Can you please check? Thanks, Volker (cherry picked from commit 5aa2411f0b3720b790439359a2dadb23008e936e) (This used to be commit 8e7effd58f7790d6e71e38c990f6cb05456e47e1) --- source3/rpc_server/srv_spoolss_nt.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index d58b16c206..cb784a6539 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -7858,6 +7858,17 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, goto done; } + switch(level) { + case 3: + fstrcpy(driver_name, + driver.info_3->name ? driver.info_3->name : ""); + break; + case 6: + fstrcpy(driver_name, + driver.info_6->name ? driver.info_6->name : ""); + break; + } + /* * I think this is where he DrvUpgradePrinter() hook would be * be called in a driver's interface DLL on a Windows NT 4.0/2k -- cgit From 7b3541f39bda595631188787fca989365478ef33 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 28 Jun 2008 16:09:34 +0200 Subject: Fix a file descriptor leak in add_port_hook This was probably cut&paste from add_printer_hook which further down has the unconditional close(fd). In add_port_hook() we're not interested in the output of 'addport command', so don't create the out fd. (cherry picked from commit 0c5ca2127ac6e3c71e369242376d27429c3aee5e) (This used to be commit 9fe09398b79ae7c5e78182112a8cd2c9b5f99ad3) --- source3/rpc_server/srv_spoolss_nt.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index cb784a6539..72ceb1d517 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6155,7 +6155,6 @@ WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname char *cmd = lp_addport_cmd(); char *command = NULL; int ret; - int fd; SE_PRIV se_printop = SE_PRINT_OPERATOR; bool is_print_op = False; @@ -6179,7 +6178,7 @@ WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname if ( is_print_op ) become_root(); - ret = smbrun(command, &fd); + ret = smbrun(command, NULL); if ( is_print_op ) unbecome_root(); @@ -6191,8 +6190,6 @@ WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname TALLOC_FREE(command); if ( ret != 0 ) { - if (fd != -1) - close(fd); return WERR_ACCESS_DENIED; } -- cgit From 7cd752bce353923ed10a47670bc4e184f0aa6b8c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 2 Jul 2008 16:11:59 -0700 Subject: Canonicalize servername in the printer functions to remove leading '\\' characters. Ensure we always return consistent names. Jeremy. (This used to be commit fc2178b04743d2f94be7b489b793fc67826557ac) --- source3/rpc_server/srv_spoolss_nt.c | 113 +++++++++++++++++++----------------- 1 file changed, 59 insertions(+), 54 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 72ceb1d517..ca2574f984 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -72,6 +72,18 @@ struct xcv_api_table { WERROR(*fn) (NT_USER_TOKEN *token, RPC_BUFFER *in, RPC_BUFFER *out, uint32 *needed); }; +/******************************************************************** + * Canonicalize servername. + ********************************************************************/ + +static const char *canon_servername(const char *servername) +{ + const char *pservername = servername; + while (*pservername == '\\') { + pservername++; + } + return pservername; +} /* translate between internal status numbers and NT status numbers */ static int nt_printj_status(int v) @@ -455,13 +467,12 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename) aprinter = handlename; if ( *handlename == '\\' ) { - servername = handlename + 2; - if ( (aprinter = strchr_m( handlename+2, '\\' )) != NULL ) { + servername = canon_servername(handlename); + if ( (aprinter = strchr_m( servername, '\\' )) != NULL ) { *aprinter = '\0'; aprinter++; } - } - else { + } else { servername = ""; } @@ -4660,20 +4671,16 @@ static WERROR enumprinters_level1( uint32 flags, fstring name, * handle enumeration of printers at level 2 ********************************************************************/ -static WERROR enumprinters_level2( uint32 flags, fstring servername, +static WERROR enumprinters_level2( uint32 flags, const char *servername, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - char *s = servername; - if (flags & PRINTER_ENUM_LOCAL) { return enum_all_printers_info_2(buffer, offered, needed, returned); } if (flags & PRINTER_ENUM_NAME) { - if ((servername[0] == '\\') && (servername[1] == '\\')) - s = servername + 2; - if (is_myname_or_ipaddr(s)) + if (is_myname_or_ipaddr(canon_servername(servername))) return enum_all_printers_info_2(buffer, offered, needed, returned); else return WERR_INVALID_NAME; @@ -4689,7 +4696,7 @@ static WERROR enumprinters_level2( uint32 flags, fstring servername, * handle enumeration of printers at level 5 ********************************************************************/ -static WERROR enumprinters_level5( uint32 flags, fstring servername, +static WERROR enumprinters_level5( uint32 flags, const char *servername, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { @@ -5109,7 +5116,7 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET * fill a DRIVER_INFO_1 struct ********************************************************************/ -static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername, fstring architecture) +static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, const char *servername, fstring architecture) { init_unistr( &info->name, driver.info_3->name); } @@ -5118,7 +5125,7 @@ static void fill_printer_driver_info_1(DRIVER_INFO_1 *info, NT_PRINTER_DRIVER_IN * construct_printer_driver_info_1 ********************************************************************/ -static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fstring servername, fstring architecture, uint32 version) +static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, const char *servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -5145,21 +5152,21 @@ static WERROR construct_printer_driver_info_1(DRIVER_INFO_1 *info, int snum, fst * fill a printer_info_2 struct ********************************************************************/ -static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) +static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, const char *servername) { TALLOC_CTX *ctx = talloc_tos(); char *temp = NULL; + const char *cservername = canon_servername(servername); info->version=driver.info_3->cversion; init_unistr( &info->name, driver.info_3->name ); init_unistr( &info->architecture, driver.info_3->environment ); - if (strlen(driver.info_3->driverpath)) { temp = talloc_asprintf(ctx, "\\\\%s%s", - servername, + cservername, driver.info_3->driverpath); init_unistr( &info->driverpath, temp ); } else { @@ -5170,7 +5177,7 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_IN if (strlen(driver.info_3->datafile)) { temp = talloc_asprintf(ctx, "\\\\%s%s", - servername, + cservername, driver.info_3->datafile); init_unistr( &info->datafile, temp ); } else @@ -5180,7 +5187,7 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_IN if (strlen(driver.info_3->configfile)) { temp = talloc_asprintf(ctx, "\\\\%s%s", - servername, + cservername, driver.info_3->configfile); init_unistr( &info->configfile, temp ); } else @@ -5192,7 +5199,7 @@ static void fill_printer_driver_info_2(DRIVER_INFO_2 *info, NT_PRINTER_DRIVER_IN * fill a printer_info_2 struct ********************************************************************/ -static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, fstring servername, fstring architecture, uint32 version) +static WERROR construct_printer_driver_info_2(DRIVER_INFO_2 *info, int snum, const char *servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -5248,7 +5255,7 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, const c if ( servername ) { line = talloc_asprintf(ctx, "\\\\%s%s", - servername, + canon_servername(servername), v); } else { line = talloc_strdup(ctx, v); @@ -5293,10 +5300,11 @@ static uint32 init_unistr_array(uint16 **uni_array, fstring *char_array, const c * fill a printer_info_3 struct ********************************************************************/ -static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) +static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, const char *servername) { char *temp = NULL; TALLOC_CTX *ctx = talloc_tos(); + const char *cservername = canon_servername(servername); ZERO_STRUCTP(info); @@ -5308,7 +5316,7 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN if (strlen(driver.info_3->driverpath)) { temp = talloc_asprintf(ctx, "\\\\%s%s", - servername, + cservername, driver.info_3->driverpath); init_unistr( &info->driverpath, temp ); } else @@ -5318,7 +5326,7 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN if (strlen(driver.info_3->datafile)) { temp = talloc_asprintf(ctx, "\\\\%s%s", - servername, + cservername, driver.info_3->datafile); init_unistr( &info->datafile, temp ); } else @@ -5328,7 +5336,7 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN if (strlen(driver.info_3->configfile)) { temp = talloc_asprintf(ctx, "\\\\%s%s", - servername, + cservername, driver.info_3->configfile); init_unistr( &info->configfile, temp ); } else @@ -5338,7 +5346,7 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN if (strlen(driver.info_3->helpfile)) { temp = talloc_asprintf(ctx, "\\\\%s%s", - servername, + cservername, driver.info_3->helpfile); init_unistr( &info->helpfile, temp ); } else @@ -5349,7 +5357,7 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype ); info->dependentfiles=NULL; - init_unistr_array(&info->dependentfiles, driver.info_3->dependentfiles, servername); + init_unistr_array(&info->dependentfiles, driver.info_3->dependentfiles, cservername); } /******************************************************************** @@ -5357,7 +5365,7 @@ static void fill_printer_driver_info_3(DRIVER_INFO_3 *info, NT_PRINTER_DRIVER_IN * fill a printer_info_3 struct ********************************************************************/ -static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fstring servername, fstring architecture, uint32 version) +static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, const char *servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -5416,11 +5424,12 @@ static WERROR construct_printer_driver_info_3(DRIVER_INFO_3 *info, int snum, fst * fill a printer_info_6 struct - we know that driver is really level 3. This sucks. JRA. ********************************************************************/ -static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, fstring servername) +static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_INFO_LEVEL driver, const char *servername) { char *temp = NULL; fstring nullstr; TALLOC_CTX *ctx = talloc_tos(); + const char *cservername = canon_servername(servername); ZERO_STRUCTP(info); memset(&nullstr, '\0', sizeof(fstring)); @@ -5433,7 +5442,7 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN if (strlen(driver.info_3->driverpath)) { temp = talloc_asprintf(ctx, "\\\\%s%s", - servername, + cservername, driver.info_3->driverpath); init_unistr( &info->driverpath, temp ); } else @@ -5443,7 +5452,7 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN if (strlen(driver.info_3->datafile)) { temp = talloc_asprintf(ctx, "\\\\%s%s", - servername, + cservername, driver.info_3->datafile); init_unistr( &info->datafile, temp ); } else @@ -5453,7 +5462,7 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN if (strlen(driver.info_3->configfile)) { temp = talloc_asprintf(ctx, "\\\\%s%s", - servername, + cservername, driver.info_3->configfile); init_unistr( &info->configfile, temp ); } else @@ -5463,7 +5472,7 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN if (strlen(driver.info_3->helpfile)) { temp = talloc_asprintf(ctx, "\\\\%s%s", - servername, + cservername, driver.info_3->helpfile); init_unistr( &info->helpfile, temp ); } else @@ -5497,7 +5506,7 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN ********************************************************************/ static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, - fstring servername, fstring architecture, uint32 version) + const char *servername, fstring architecture, uint32 version) { NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_DRIVER_INFO_LEVEL driver; @@ -5564,7 +5573,7 @@ static void free_printer_driver_info_6(DRIVER_INFO_6 *info) /**************************************************************************** ****************************************************************************/ -static WERROR getprinterdriver2_level1(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinterdriver2_level1(const char *servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_1 *info=NULL; WERROR result; @@ -5602,7 +5611,7 @@ out: /**************************************************************************** ****************************************************************************/ -static WERROR getprinterdriver2_level2(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinterdriver2_level2(const char *servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_2 *info=NULL; WERROR result; @@ -5640,7 +5649,7 @@ out: /**************************************************************************** ****************************************************************************/ -static WERROR getprinterdriver2_level3(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinterdriver2_level3(const char *servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_3 info; WERROR result; @@ -5676,7 +5685,7 @@ out: /**************************************************************************** ****************************************************************************/ -static WERROR getprinterdriver2_level6(fstring servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) +static WERROR getprinterdriver2_level6(const char *servername, fstring architecture, uint32 version, int snum, RPC_BUFFER *buffer, uint32 offered, uint32 *needed) { DRIVER_INFO_6 info; WERROR result; @@ -6910,7 +6919,7 @@ WERROR _spoolss_setjob(pipes_struct *p, SPOOL_Q_SETJOB *q_u, SPOOL_R_SETJOB *r_u Enumerates all printer drivers at level 1. ****************************************************************************/ -static WERROR enumprinterdrivers_level1(fstring servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprinterdrivers_level1(const char *servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; int ndrivers; @@ -6994,7 +7003,7 @@ out: Enumerates all printer drivers at level 2. ****************************************************************************/ -static WERROR enumprinterdrivers_level2(fstring servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprinterdrivers_level2(const char *servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; int ndrivers; @@ -7079,7 +7088,7 @@ out: Enumerates all printer drivers at level 3. ****************************************************************************/ -static WERROR enumprinterdrivers_level3(fstring servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) +static WERROR enumprinterdrivers_level3(const char *servername, fstring architecture, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int i; int ndrivers; @@ -7175,7 +7184,7 @@ WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS uint32 offered = q_u->offered; uint32 *needed = &r_u->needed; uint32 *returned = &r_u->returned; - + const char *cservername; fstring servername; fstring architecture; @@ -7196,16 +7205,18 @@ WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS unistr2_to_ascii(architecture, &q_u->environment, sizeof(architecture)); unistr2_to_ascii(servername, &q_u->name, sizeof(servername)); - if ( !is_myname_or_ipaddr( servername ) ) + cservername = canon_servername(servername); + + if (!is_myname_or_ipaddr(cservername)) return WERR_UNKNOWN_PRINTER_DRIVER; switch (level) { case 1: - return enumprinterdrivers_level1(servername, architecture, buffer, offered, needed, returned); + return enumprinterdrivers_level1(cservername, architecture, buffer, offered, needed, returned); case 2: - return enumprinterdrivers_level2(servername, architecture, buffer, offered, needed, returned); + return enumprinterdrivers_level2(cservername, architecture, buffer, offered, needed, returned); case 3: - return enumprinterdrivers_level3(servername, architecture, buffer, offered, needed, returned); + return enumprinterdrivers_level3(cservername, architecture, buffer, offered, needed, returned); default: return WERR_UNKNOWN_LEVEL; } @@ -7992,7 +8003,7 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen char *path = NULL; char *long_archi = NULL; char *servername = NULL; - char *pservername = NULL; + const char *pservername = NULL; const char *short_archi; DRIVER_DIRECTORY_1 *info=NULL; WERROR result = WERR_OK; @@ -8007,15 +8018,9 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen return WERR_NOMEM; } - /* check for beginning double '\'s and that the server - long enough */ - - pservername = servername; - if ( *pservername == '\\' && strlen(servername)>2 ) { - pservername += 2; - } + pservername = canon_servername(servername); - if ( !is_myname_or_ipaddr( pservername ) ) + if ( !is_myname_or_ipaddr(pservername)) return WERR_INVALID_PARAM; if (!(short_archi = get_short_archi(long_archi))) -- cgit From 1bd72938176fc49c7fedd499e4860da0c78a871b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 16 Jul 2008 22:08:59 +0200 Subject: In api_pipe_bind_req(), decode the bind request before checking the pipe (This used to be commit 8be41382ed9bb4fb44a1846fff2c7652388e4f28) --- source3/rpc_server/srv_pipe.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 80e2b2f9a9..f8ec4bfc91 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1565,6 +1565,16 @@ bool api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) DEBUG(5,("api_pipe_bind_req: decode request. %d\n", __LINE__)); + ZERO_STRUCT(hdr_rb); + + /* decode the bind request */ + + if(!smb_io_rpc_hdr_rb("", &hdr_rb, rpc_in_p, 0)) { + DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_RB " + "struct.\n")); + goto err_exit; + } + /* * Try and find the correct pipe name to ensure * that this is a pipe name we support. @@ -1606,14 +1616,6 @@ bool api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) } } - ZERO_STRUCT(hdr_rb); - - /* decode the bind request */ - if(!smb_io_rpc_hdr_rb("", &hdr_rb, rpc_in_p, 0)) { - DEBUG(0,("api_pipe_bind_req: unable to unmarshall RPC_HDR_RB struct.\n")); - goto err_exit; - } - /* name has to be \PIPE\xxxxx */ fstrcpy(ack_pipe_name, "\\PIPE\\"); fstrcat(ack_pipe_name, p->pipe_srv_name); -- cgit From e0f3ea2cbeb61cb02be85d2b315948985bac27a8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 12 Jul 2008 23:17:23 +0200 Subject: In api_pipe_bind_req(), check for the iface id, not the pipe name This requires to store the rpc_interface in "struct rpc_table" (This used to be commit 654f8de8497aff29f9b1f1822b6a8e734ff329e0) --- source3/rpc_server/srv_eventlog.c | 3 ++- source3/rpc_server/srv_ntsvcs.c | 5 ++++- source3/rpc_server/srv_pipe.c | 17 ++++++++++++++--- source3/rpc_server/srv_spoolss.c | 13 ++++++++++++- source3/rpc_server/srv_svcctl.c | 4 +++- 5 files changed, 35 insertions(+), 7 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_eventlog.c b/source3/rpc_server/srv_eventlog.c index 5679a6acb6..da761c905e 100644 --- a/source3/rpc_server/srv_eventlog.c +++ b/source3/rpc_server/srv_eventlog.c @@ -106,7 +106,8 @@ struct api_struct api_eventlog_cmds[] = NTSTATUS rpc_eventlog2_init(void) { return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, - "eventlog", "eventlog", api_eventlog_cmds, + "eventlog", "eventlog", &ndr_table_eventlog.syntax_id, + api_eventlog_cmds, sizeof(api_eventlog_cmds)/sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_ntsvcs.c b/source3/rpc_server/srv_ntsvcs.c index 12fffc3e96..100d577010 100644 --- a/source3/rpc_server/srv_ntsvcs.c +++ b/source3/rpc_server/srv_ntsvcs.c @@ -155,6 +155,9 @@ void ntsvcs2_get_pipe_fns( struct api_struct **fns, int *n_fns ) NTSTATUS rpc_ntsvcs2_init(void) { - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "ntsvcs", "ntsvcs", api_ntsvcs_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, + "ntsvcs", "ntsvcs", + &ndr_table_ntsvcs.syntax_id, + api_ntsvcs_cmds, sizeof(api_ntsvcs_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index f8ec4bfc91..48e6646c75 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -718,6 +718,7 @@ struct rpc_table { const char *clnt; const char *srv; } pipe; + struct ndr_syntax_id rpc_interface; const struct api_struct *cmds; int n_cmds; }; @@ -1039,7 +1040,10 @@ bool check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, Register commands to an RPC pipe *******************************************************************/ -NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *srv, const struct api_struct *cmds, int size) +NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, + const char *srv, + const struct ndr_syntax_id *interface, + const struct api_struct *cmds, int size) { struct rpc_table *rpc_entry; @@ -1079,6 +1083,7 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, const char *s ZERO_STRUCTP(rpc_entry); rpc_entry->pipe.clnt = SMB_STRDUP(clnt); rpc_entry->pipe.srv = SMB_STRDUP(srv); + rpc_entry->rpc_interface = *interface; rpc_entry->cmds = cmds; rpc_entry->n_cmds = size; @@ -1575,16 +1580,22 @@ bool api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) goto err_exit; } + if (hdr_rb.num_contexts == 0) { + DEBUG(0, ("api_pipe_bind_req: no rpc contexts around\n")); + goto err_exit; + } + /* * Try and find the correct pipe name to ensure * that this is a pipe name we support. */ - for (i = 0; i < rpc_lookup_size; i++) { - if (strequal(rpc_lookup[i].pipe.clnt, p->name)) { + if (ndr_syntax_id_equal(&rpc_lookup[i].rpc_interface, + &hdr_rb.rpc_context[0].abstract)) { DEBUG(3, ("api_pipe_bind_req: \\PIPE\\%s -> \\PIPE\\%s\n", rpc_lookup[i].pipe.clnt, rpc_lookup[i].pipe.srv)); + fstrcpy(p->name, rpc_lookup[i].pipe.clnt); fstrcpy(p->pipe_srv_name, rpc_lookup[i].pipe.srv); break; } diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 7802fe447e..4744b90263 100644 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1630,8 +1630,19 @@ void spoolss_get_pipe_fns( struct api_struct **fns, int *n_fns ) *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct); } +static const struct ndr_syntax_id syntax_spoolss = { + { + 0x12345678, 0x1234, 0xabcd, + { 0xef, 0x00 }, + { 0x01, 0x23, + 0x45, 0x67, 0x89, 0xab } + }, 0x01 +}; + NTSTATUS rpc_spoolss_init(void) { - return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "spoolss", "spoolss", api_spoolss_cmds, + return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, + "spoolss", "spoolss", &syntax_spoolss, + api_spoolss_cmds, sizeof(api_spoolss_cmds) / sizeof(struct api_struct)); } diff --git a/source3/rpc_server/srv_svcctl.c b/source3/rpc_server/srv_svcctl.c index e3ff2cc8a0..483fb8e1e9 100644 --- a/source3/rpc_server/srv_svcctl.c +++ b/source3/rpc_server/srv_svcctl.c @@ -266,6 +266,8 @@ void svcctl2_get_pipe_fns( struct api_struct **fns, int *n_fns ) NTSTATUS rpc_svcctl2_init(void) { return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, - "svcctl", "ntsvcs", api_svcctl_cmds, + "svcctl", "ntsvcs", + &ndr_table_svcctl.syntax_id, + api_svcctl_cmds, sizeof(api_svcctl_cmds) / sizeof(struct api_struct)); } -- cgit From bcb652451b6360b0de595c13961b11134097f3bb Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 16 Jul 2008 00:03:49 +0200 Subject: Simplify the RPC servers: remove get_pipe_fns The per-server xxx_get_pipe_fns functions can go once all the RPC servers are converted (This used to be commit 6aa2391cbe1cbda8269ded767117f53d83b243e1) --- source3/rpc_server/srv_pipe.c | 122 +++++++++--------------------------------- 1 file changed, 25 insertions(+), 97 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 48e6646c75..fa8fffa350 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -29,7 +29,6 @@ #include "includes.h" -extern struct pipe_id_info pipe_names[]; extern struct current_user current_user; #undef DBGC_CLASS @@ -986,53 +985,42 @@ bool setup_cancel_ack_reply(pipes_struct *p, prs_struct *rpc_in_p) bool check_bind_req(struct pipes_struct *p, RPC_IFACE* abstract, RPC_IFACE* transfer, uint32 context_id) { - char *pipe_name = p->name; int i=0; - fstring pname; - - fstrcpy(pname,"\\PIPE\\"); - fstrcat(pname,pipe_name); + struct pipe_rpc_fns *context_fns; - DEBUG(3,("check_bind_req for %s\n", pname)); + DEBUG(3,("check_bind_req for %s\n", p->name)); /* we have to check all now since win2k introduced a new UUID on the lsaprpc pipe */ - - for ( i=0; pipe_names[i].client_pipe; i++ ) { - DEBUGADD(10,("checking %s\n", pipe_names[i].client_pipe)); - if ( strequal(pipe_names[i].client_pipe, pname) - && (abstract->if_version == pipe_names[i].abstr_syntax->if_version) - && (memcmp(&abstract->uuid, &pipe_names[i].abstr_syntax->uuid, sizeof(struct GUID)) == 0) - && (transfer->if_version == pipe_names[i].trans_syntax->if_version) - && (memcmp(&transfer->uuid, &pipe_names[i].trans_syntax->uuid, sizeof(struct GUID)) == 0) ) { - struct api_struct *fns = NULL; - int n_fns = 0; - PIPE_RPC_FNS *context_fns; - - if ( !(context_fns = SMB_MALLOC_P(PIPE_RPC_FNS)) ) { - DEBUG(0,("check_bind_req: malloc() failed!\n")); - return False; - } - - /* save the RPC function table associated with this bind */ - - get_pipe_fns(i, &fns, &n_fns); - - context_fns->cmds = fns; - context_fns->n_cmds = n_fns; - context_fns->context_id = context_id; - - /* add to the list of open contexts */ - - DLIST_ADD( p->contexts, context_fns ); - + + for (i=0; iname) + && ndr_syntax_id_equal( + abstract, &rpc_lookup[i].rpc_interface) + && ndr_syntax_id_equal( + transfer, &ndr_transfer_syntax)) { break; } } - if(pipe_names[i].client_pipe == NULL) { + if (i == rpc_lookup_size) { + return false; + } + + context_fns = SMB_MALLOC_P(struct pipe_rpc_fns); + if (context_fns == NULL) { + DEBUG(0,("check_bind_req: malloc() failed!\n")); return False; } + context_fns->cmds = rpc_lookup[i].cmds; + context_fns->n_cmds = rpc_lookup[i].n_cmds; + context_fns->context_id = context_id; + + /* add to the list of open contexts */ + + DLIST_ADD( p->contexts, context_fns ); + return True; } @@ -2393,63 +2381,3 @@ bool api_rpcTNP(pipes_struct *p, const char *rpc_name, return True; } - -/******************************************************************* -*******************************************************************/ - -void get_pipe_fns( int idx, struct api_struct **fns, int *n_fns ) -{ - struct api_struct *cmds = NULL; - int n_cmds = 0; - - switch ( idx ) { - case PI_LSARPC: - lsarpc_get_pipe_fns( &cmds, &n_cmds ); - break; - case PI_DSSETUP: - dssetup_get_pipe_fns( &cmds, &n_cmds ); - break; - case PI_SAMR: - samr_get_pipe_fns( &cmds, &n_cmds ); - break; - case PI_NETLOGON: - netlogon_get_pipe_fns( &cmds, &n_cmds ); - break; - case PI_SRVSVC: - srvsvc_get_pipe_fns( &cmds, &n_cmds ); - break; - case PI_WKSSVC: - wkssvc_get_pipe_fns( &cmds, &n_cmds ); - break; - case PI_WINREG: - winreg_get_pipe_fns( &cmds, &n_cmds ); - break; - case PI_SPOOLSS: - spoolss_get_pipe_fns( &cmds, &n_cmds ); - break; - case PI_NETDFS: - netdfs_get_pipe_fns( &cmds, &n_cmds ); - break; - case PI_SVCCTL: - svcctl2_get_pipe_fns( &cmds, &n_cmds ); - break; - case PI_EVENTLOG: - eventlog2_get_pipe_fns( &cmds, &n_cmds ); - break; - case PI_NTSVCS: - ntsvcs2_get_pipe_fns( &cmds, &n_cmds ); - break; -#ifdef DEVELOPER - case PI_RPCECHO: - rpcecho_get_pipe_fns( &cmds, &n_cmds ); - break; -#endif - default: - DEBUG(0,("get_pipe_fns: Unknown pipe index! [%d]\n", idx)); - } - - *fns = cmds; - *n_fns = n_cmds; - - return; -} -- cgit From bce33f8b826161a838f8791835ca22a47f7803a5 Mon Sep 17 00:00:00 2001 From: Karolin Seeger Date: Fri, 18 Jul 2008 15:31:36 +0200 Subject: Fix typos. the user have -> has Karolin (This used to be commit 1ee2ad1051e6076709ef8ed2f45bebff10b0c3cf) --- source3/rpc_server/srv_lsa_nt.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 95e10ac28e..94517f3478 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/rpc_server/srv_lsa_nt.c @@ -487,7 +487,7 @@ NTSTATUS _lsa_EnumTrustDom(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&info)) return NT_STATUS_INVALID_HANDLE; - /* check if the user have enough rights */ + /* check if the user has enough rights */ if (!(info->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; @@ -568,7 +568,7 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, uint32 policy_def = LSA_AUDIT_POLICY_ALL; - /* check if the user have enough rights */ + /* check if the user has enough rights */ if (!(handle->access & LSA_POLICY_VIEW_AUDIT_INFORMATION)) { DEBUG(10,("_lsa_QueryInfoPolicy: insufficient access rights\n")); return NT_STATUS_ACCESS_DENIED; @@ -596,7 +596,7 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, break; } case 0x03: - /* check if the user have enough rights */ + /* check if the user has enough rights */ if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; @@ -632,7 +632,7 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, init_dom_query_3(&info->domain, name, sid); break; case 0x05: - /* check if the user have enough rights */ + /* check if the user has enough rights */ if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; @@ -643,7 +643,7 @@ NTSTATUS _lsa_QueryInfoPolicy(pipes_struct *p, init_dom_query_5(&info->account_domain, name, sid); break; case 0x06: - /* check if the user have enough rights */ + /* check if the user has enough rights */ if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; @@ -884,7 +884,7 @@ NTSTATUS _lsa_LookupSids2(pipes_struct *p, return NT_STATUS_INVALID_HANDLE; } - /* check if the user have enough rights */ + /* check if the user has enough rights */ if (!(handle->access & LSA_POLICY_LOOKUP_NAMES)) { return NT_STATUS_ACCESS_DENIED; } @@ -1016,7 +1016,7 @@ NTSTATUS _lsa_LookupNames(pipes_struct *p, goto done; } - /* check if the user have enough rights */ + /* check if the user has enough rights */ if (!(handle->access & LSA_POLICY_LOOKUP_NAMES)) { status = NT_STATUS_ACCESS_DENIED; goto done; @@ -1155,7 +1155,7 @@ NTSTATUS _lsa_LookupNames3(pipes_struct *p, goto done; } - /* check if the user have enough rights */ + /* check if the user has enough rights */ if (!(handle->access & LSA_POLICY_LOOKUP_NAMES)) { status = NT_STATUS_ACCESS_DENIED; goto done; @@ -1308,7 +1308,7 @@ NTSTATUS _lsa_EnumPrivs(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; - /* check if the user have enough rights + /* check if the user has enough rights I don't know if it's the right one. not documented. */ if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) @@ -1364,7 +1364,7 @@ NTSTATUS _lsa_LookupPrivDisplayName(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; - /* check if the user have enough rights */ + /* check if the user has enough rights */ /* * I don't know if it's the right one. not documented. @@ -1514,7 +1514,7 @@ NTSTATUS _lsa_CreateAccount(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; - /* check if the user have enough rights */ + /* check if the user has enough rights */ /* * I don't know if it's the right one. not documented. @@ -1563,7 +1563,7 @@ NTSTATUS _lsa_OpenAccount(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; - /* check if the user have enough rights */ + /* check if the user has enough rights */ /* * I don't know if it's the right one. not documented. @@ -1812,7 +1812,7 @@ NTSTATUS _lsa_QuerySecurity(pipes_struct *p, if (!find_policy_by_hnd(p, r->in.handle, (void **)(void *)&handle)) return NT_STATUS_INVALID_HANDLE; - /* check if the user have enough rights */ + /* check if the user has enough rights */ if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; @@ -1869,7 +1869,7 @@ NTSTATUS _lsa_QuerySecurity(pipes_struct *p, switch (q_u->info_class) { case 0x0c: - /* check if the user have enough rights */ + /* check if the user has enough rights */ if (!(handle->access & LSA_POLICY_VIEW_LOCAL_INFORMATION)) return NT_STATUS_ACCESS_DENIED; -- cgit From 2e7cb1a5ccf8ae513a432cef9ccebfcebe4241ac Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 19 Jul 2008 20:27:56 +0200 Subject: Introduce is_known_pipename This scans the list of pipes registered via rpc_pipe_register_commands instead of using static tables. (This used to be commit 283e6039989adea1c8921b3600b410cb67b6492a) --- source3/rpc_server/srv_pipe.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index fa8fffa350..7b066d3830 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -1078,6 +1078,39 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt, return NT_STATUS_OK; } +/** + * Is a named pipe known? + * @param[in] cli_filename The pipe name requested by the client + * @result Do we want to serve this? + */ +bool is_known_pipename(const char *cli_filename) +{ + const char *pipename = cli_filename; + int i; + + if (strnequal(pipename, "\\PIPE\\", 6)) { + pipename += 5; + } + + if (*pipename == '\\') { + pipename += 1; + } + + if (lp_disable_spoolss() && strequal(pipename, "spoolss")) { + DEBUG(10, ("refusing spoolss access\n")); + return false; + } + + for (i=0; i Date: Sun, 20 Jul 2008 11:04:31 +0200 Subject: Refactoring: Change calling conventions for cli_rpc_pipe_open_noauth Pass in ndr_syntax_id instead of pipe_idx, return NTSTATUS (This used to be commit 9abc9dc4dc13bd3e42f98eff64eacf24b51f5779) --- source3/rpc_server/srv_spoolss.c | 9 --------- source3/rpc_server/srv_spoolss_nt.c | 3 ++- 2 files changed, 2 insertions(+), 10 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index 4744b90263..22b3a7607e 100644 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -1630,15 +1630,6 @@ void spoolss_get_pipe_fns( struct api_struct **fns, int *n_fns ) *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct); } -static const struct ndr_syntax_id syntax_spoolss = { - { - 0x12345678, 0x1234, 0xabcd, - { 0xef, 0x00 }, - { 0x01, 0x23, - 0x45, 0x67, 0x89, 0xab } - }, 0x01 -}; - NTSTATUS rpc_spoolss_init(void) { return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ca2574f984..f80240042c 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2617,7 +2617,8 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, * Now start the NT Domain stuff :-). */ - if ( !(*pp_pipe = cli_rpc_pipe_open_noauth(the_cli, PI_SPOOLSS, &ret)) ) { + ret = cli_rpc_pipe_open_noauth(the_cli, &syntax_spoolss, pp_pipe); + if (!NT_STATUS_IS_OK(ret)) { DEBUG(2,("spoolss_connect_to_client: unable to open the spoolss pipe on machine %s. Error was : %s.\n", remote_machine, nt_errstr(ret))); cli_shutdown(the_cli); -- cgit From 863a6aa07e543e30f2075a597129f6c39222beef Mon Sep 17 00:00:00 2001 From: Zach Loafman Date: Thu, 3 Jul 2008 12:21:33 -0700 Subject: Fix warnings on FreeBSD-based platforms Fix two shadowed declaration warnings on FreeBSD-based platform: 'reboot' is a 4.0BSD syscall in unistd.h and 'tcp_seq' is a typedef in netinet/tcp.h. (This used to be commit 14d2a4da1da38d6f69c63505d35990322f253e5d) --- source3/rpc_server/srv_initshutdown_nt.c | 4 ++-- source3/rpc_server/srv_winreg_nt.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_initshutdown_nt.c b/source3/rpc_server/srv_initshutdown_nt.c index f7d299830d..8b3ef52293 100644 --- a/source3/rpc_server/srv_initshutdown_nt.c +++ b/source3/rpc_server/srv_initshutdown_nt.c @@ -37,7 +37,7 @@ WERROR _initshutdown_Init(pipes_struct *p, struct initshutdown_Init *r) s.in.message = r->in.message; s.in.timeout = r->in.timeout; s.in.force_apps = r->in.force_apps; - s.in.reboot = r->in.reboot; + s.in.do_reboot = r->in.do_reboot; s.in.reason = 0; /* thunk down to _winreg_InitiateSystemShutdownEx() @@ -56,7 +56,7 @@ WERROR _initshutdown_InitEx(pipes_struct *p, struct initshutdown_InitEx *r) s.in.message = r->in.message; s.in.timeout = r->in.timeout; s.in.force_apps = r->in.force_apps; - s.in.reboot = r->in.reboot; + s.in.do_reboot = r->in.do_reboot; s.in.reason = r->in.reason; return _winreg_InitiateSystemShutdownEx( p, &s); diff --git a/source3/rpc_server/srv_winreg_nt.c b/source3/rpc_server/srv_winreg_nt.c index 84bcf0bf89..3991c5ae02 100644 --- a/source3/rpc_server/srv_winreg_nt.c +++ b/source3/rpc_server/srv_winreg_nt.c @@ -475,7 +475,7 @@ WERROR _winreg_InitiateSystemShutdown(pipes_struct *p, struct winreg_InitiateSys s.in.message = r->in.message; s.in.timeout = r->in.timeout; s.in.force_apps = r->in.force_apps; - s.in.reboot = r->in.reboot; + s.in.do_reboot = r->in.do_reboot; s.in.reason = 0; /* thunk down to _winreg_InitiateSystemShutdownEx() @@ -499,7 +499,7 @@ WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, struct winreg_InitiateS char *chkmsg = NULL; fstring str_timeout; fstring str_reason; - fstring reboot; + fstring do_reboot; fstring f; int ret; bool can_shutdown; @@ -526,7 +526,7 @@ WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, struct winreg_InitiateS } fstr_sprintf(str_timeout, "%d", r->in.timeout); - fstr_sprintf(reboot, r->in.reboot ? SHUTDOWN_R_STRING : ""); + fstr_sprintf(do_reboot, r->in.do_reboot ? SHUTDOWN_R_STRING : ""); fstr_sprintf(f, r->in.force_apps ? SHUTDOWN_F_STRING : ""); fstr_sprintf(str_reason, "%d", r->in.reason ); @@ -541,7 +541,7 @@ WERROR _winreg_InitiateSystemShutdownEx(pipes_struct *p, struct winreg_InitiateS return WERR_NOMEM; } shutdown_script = talloc_all_string_sub(p->mem_ctx, - shutdown_script, "%r", reboot); + shutdown_script, "%r", do_reboot); if (!shutdown_script) { return WERR_NOMEM; } -- cgit From 042600cbac2856b88b29b5589caebed9d699a8a3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 26 Jul 2008 11:25:24 +0200 Subject: Make api_rpcTNP static to srv_pipe.c (This used to be commit 256c93a8b3d4d9a4e52a656c91b89a043a087066) --- source3/rpc_server/srv_pipe.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 7b066d3830..be7d3db444 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -2284,6 +2284,9 @@ void free_pipe_rpc_context( PIPE_RPC_FNS *list ) return; } +static bool api_rpcTNP(pipes_struct *p, const char *rpc_name, + const struct api_struct *api_rpc_cmds, int n_cmds); + /**************************************************************************** Find the correct RPC function to call for this request. If the pipe is authenticated then become the correct UNIX user @@ -2333,8 +2336,8 @@ bool api_pipe_request(pipes_struct *p) Calls the underlying RPC function for a named pipe. ********************************************************************/ -bool api_rpcTNP(pipes_struct *p, const char *rpc_name, - const struct api_struct *api_rpc_cmds, int n_cmds) +static bool api_rpcTNP(pipes_struct *p, const char *rpc_name, + const struct api_struct *api_rpc_cmds, int n_cmds) { int fn_num; fstring name; -- cgit From 1ee37bc9c3d3a4aefc50efc90db42b81f51bcd03 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 12 Jul 2008 12:20:08 +0200 Subject: Refactor make_internal_rpc_pipe_p: connection_struct is not needed (This used to be commit defcf0eecfb8eb035d9ca80530720b9e6873f6c7) --- source3/rpc_server/srv_pipe_hnd.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index c0b525c06b..aa5bd5394a 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -65,8 +65,6 @@ static ssize_t read_from_internal_pipe(void *np_conn, char *data, size_t n, bool *is_data_outstanding); static ssize_t write_to_internal_pipe(void *np_conn, char *data, size_t n); static bool close_internal_rpc_pipe_hnd(void *np_conn); -static void *make_internal_rpc_pipe_p(const char *pipe_name, - connection_struct *conn, uint16 vuid); /**************************************************************************** Internal Pipe iterator functions. @@ -217,7 +215,8 @@ smb_np_struct *open_rpc_pipe_p(const char *pipe_name, p->namedpipe_write = write_to_internal_pipe; p->namedpipe_close = close_internal_rpc_pipe_hnd; - p->np_state = p->namedpipe_create(pipe_name, conn, vuid); + p->np_state = p->namedpipe_create(pipe_name, conn->client_address, + conn->server_info, vuid); if (p->np_state == NULL) { DEBUG(0,("open_rpc_pipe_p: make_internal_rpc_pipe_p failed.\n")); @@ -266,19 +265,15 @@ smb_np_struct *open_rpc_pipe_p(const char *pipe_name, Make an internal namedpipes structure ****************************************************************************/ -static void *make_internal_rpc_pipe_p(const char *pipe_name, - connection_struct *conn, uint16 vuid) +struct pipes_struct *make_internal_rpc_pipe_p(const char *pipe_name, + const char *client_address, + struct auth_serversupplied_info *server_info, + uint16_t vuid) { pipes_struct *p; - user_struct *vuser = get_valid_user_struct(vuid); DEBUG(4,("Create pipe requested %s\n", pipe_name)); - if (!vuser && vuid != UID_FIELD_INVALID) { - DEBUG(0,("ERROR! vuid %d did not map to a valid vuser struct!\n", vuid)); - return NULL; - } - p = TALLOC_ZERO_P(NULL, pipes_struct); if (!p) { @@ -314,7 +309,7 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, return NULL; } - p->server_info = copy_serverinfo(p, conn->server_info); + p->server_info = copy_serverinfo(p, server_info); if (p->server_info == NULL) { DEBUG(0, ("open_rpc_pipe_p: copy_serverinfo failed\n")); talloc_destroy(p->mem_ctx); @@ -325,21 +320,16 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, DLIST_ADD(InternalPipes, p); - memcpy(p->client_address, conn->client_address, - sizeof(p->client_address)); + memcpy(p->client_address, client_address, sizeof(p->client_address)); p->endian = RPC_LITTLE_ENDIAN; ZERO_STRUCT(p->pipe_user); + p->pipe_user.vuid = vuid; p->pipe_user.ut.uid = (uid_t)-1; p->pipe_user.ut.gid = (gid_t)-1; - - /* Store the session key and NT_TOKEN */ - if (vuser) { - p->pipe_user.nt_user_token = dup_nt_token( - NULL, vuser->server_info->ptok); - } + p->pipe_user.nt_user_token = dup_nt_token(NULL, server_info->ptok); /* * Initialize the outgoing RPC data buffer with no memory. @@ -351,7 +341,7 @@ static void *make_internal_rpc_pipe_p(const char *pipe_name, DEBUG(4,("Created internal pipe %s (pipes_open=%d)\n", pipe_name, pipes_open)); - return (void*)p; + return p; } /**************************************************************************** -- cgit From a803f0a9204fc917668b68ca67ff02e8f9ed0262 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 12 Jul 2008 12:25:42 +0200 Subject: Refactoring: Make close_internal_rpc_pipe_hnd a talloc destructor (This used to be commit 10b47a0c2cfd62489428518112da82f73a52b7bc) --- source3/rpc_server/srv_pipe_hnd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index aa5bd5394a..2e77b5b903 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -64,7 +64,7 @@ static struct bitmap *bmap; static ssize_t read_from_internal_pipe(void *np_conn, char *data, size_t n, bool *is_data_outstanding); static ssize_t write_to_internal_pipe(void *np_conn, char *data, size_t n); -static bool close_internal_rpc_pipe_hnd(void *np_conn); +static int close_internal_rpc_pipe_hnd(struct pipes_struct *pipe); /**************************************************************************** Internal Pipe iterator functions. @@ -213,7 +213,6 @@ smb_np_struct *open_rpc_pipe_p(const char *pipe_name, p->namedpipe_create = make_internal_rpc_pipe_p; p->namedpipe_read = read_from_internal_pipe; p->namedpipe_write = write_to_internal_pipe; - p->namedpipe_close = close_internal_rpc_pipe_hnd; p->np_state = p->namedpipe_create(pipe_name, conn->client_address, conn->server_info, vuid); @@ -341,6 +340,8 @@ struct pipes_struct *make_internal_rpc_pipe_p(const char *pipe_name, DEBUG(4,("Created internal pipe %s (pipes_open=%d)\n", pipe_name, pipes_open)); + talloc_set_destructor(p, close_internal_rpc_pipe_hnd); + return p; } @@ -1136,7 +1137,7 @@ bool close_rpc_pipe_hnd(smb_np_struct *p) return False; } - p->namedpipe_close(p->np_state); + TALLOC_FREE(p->np_state); bitmap_clear(bmap, p->pnum - pipe_handle_offset); @@ -1179,9 +1180,8 @@ void pipe_close_conn(connection_struct *conn) Close an rpc pipe. ****************************************************************************/ -static bool close_internal_rpc_pipe_hnd(void *np_conn) +static int close_internal_rpc_pipe_hnd(struct pipes_struct *p) { - pipes_struct *p = (pipes_struct *)np_conn; if (!p) { DEBUG(0,("Invalid pipe in close_internal_rpc_pipe_hnd\n")); return False; -- cgit From 33cbe2f88ce411718db1d37a0e2f9d19e931e383 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 12 Jul 2008 12:56:00 +0200 Subject: make read/write to internal pipes available externally (This used to be commit e11b5cb1e061caf4c3793fb402ca6bee95a8f26c) --- source3/rpc_server/srv_pipe_hnd.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index 2e77b5b903..bc6d180199 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -61,9 +61,6 @@ static struct bitmap *bmap; * system _anyway_. so that's the next step... */ -static ssize_t read_from_internal_pipe(void *np_conn, char *data, size_t n, - bool *is_data_outstanding); -static ssize_t write_to_internal_pipe(void *np_conn, char *data, size_t n); static int close_internal_rpc_pipe_hnd(struct pipes_struct *pipe); /**************************************************************************** @@ -925,9 +922,8 @@ ssize_t write_to_pipe(smb_np_struct *p, char *data, size_t n) Accepts incoming data on an internal rpc pipe. ****************************************************************************/ -static ssize_t write_to_internal_pipe(void *np_conn, char *data, size_t n) +ssize_t write_to_internal_pipe(struct pipes_struct *p, char *data, size_t n) { - pipes_struct *p = (pipes_struct*)np_conn; size_t data_left = n; while(data_left) { @@ -985,10 +981,9 @@ ssize_t read_from_pipe(smb_np_struct *p, char *data, size_t n, have been prepared into arrays of headers + data stream sections. ****************************************************************************/ -static ssize_t read_from_internal_pipe(void *np_conn, char *data, size_t n, - bool *is_data_outstanding) +ssize_t read_from_internal_pipe(struct pipes_struct *p, char *data, size_t n, + bool *is_data_outstanding) { - pipes_struct *p = (pipes_struct*)np_conn; uint32 pdu_remaining = 0; ssize_t data_returned = 0; -- cgit From 2646fce6338216372af6f6b3198995adfbad90dd Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 27 Jul 2008 17:59:15 +0200 Subject: Fix srvsvc_Net[Get|Set]FileSecurity There were two bugs in those routines: They did not send INTERNAL_OPEN_ONLY to open_file_ntcreate() and they did not chdir, so the file could never be found. While there I decided to remove the become_root() calls and call create_file() instead of the lower-level routines. (This used to be commit 669771738422776f8c81086ffea4924b62d72957) --- source3/rpc_server/srv_srvsvc_nt.c | 242 +++++++++++++------------------------ 1 file changed, 87 insertions(+), 155 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 57f2fe7f65..bb9c3687fb 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -2026,91 +2026,59 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, { SEC_DESC *psd = NULL; size_t sd_size; - DATA_BLOB null_pw; - char *filename_in = NULL; - char *filename = NULL; - char *qualname = NULL; + fstring servicename; SMB_STRUCT_STAT st; NTSTATUS nt_status; - WERROR werr = WERR_ACCESS_DENIED; - struct current_user user; + WERROR werr; connection_struct *conn = NULL; - bool became_user = False; - TALLOC_CTX *ctx = p->mem_ctx; struct sec_desc_buf *sd_buf = NULL; files_struct *fsp = NULL; + int snum; + char *oldcwd = NULL; ZERO_STRUCT(st); - qualname = talloc_strdup(ctx, r->in.share); - if (!qualname) { - goto error_exit; - } - - /* Null password is ok - we are already an authenticated user... */ - null_pw = data_blob_null; - - get_current_user(&user, p); - - become_root(); - conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status); - unbecome_root(); - - if (conn == NULL) { - DEBUG(3,("_srvsvc_NetGetFileSecurity: Unable to connect to %s\n", - qualname)); - werr = ntstatus_to_werror(nt_status); - goto error_exit; - } - - if (!become_user(conn, conn->vuid)) { - DEBUG(0,("_srvsvc_NetGetFileSecurity: Can't become connected user!\n")); - goto error_exit; - } - became_user = True; - - filename_in = talloc_strdup(ctx, r->in.file); - if (!filename_in) { - goto error_exit; - } + fstrcpy(servicename, r->in.share); - nt_status = unix_convert(ctx, conn, filename_in, False, &filename, NULL, &st); - if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srvsvc_NetGetFileSecurity: bad pathname %s\n", - filename)); + snum = find_service(servicename); + if (snum == -1) { + DEBUG(10, ("Could not find service %s\n", servicename)); + werr = WERR_NET_NAME_NOT_FOUND; goto error_exit; } - nt_status = check_name(conn, filename); + nt_status = create_conn_struct(talloc_tos(), &conn, snum, + lp_pathname(snum), &oldcwd); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srvsvc_NetGetFileSecurity: can't access %s\n", - filename)); + DEBUG(10, ("create_conn_struct failed: %s\n", + nt_errstr(nt_status))); + werr = ntstatus_to_werror(nt_status); goto error_exit; } - if (!(S_ISDIR(st.st_mode))) { - nt_status = open_file_ntcreate(conn, NULL, filename, &st, - FILE_READ_ATTRIBUTES, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_OPEN, - 0, - FILE_ATTRIBUTE_NORMAL, - 0, - NULL, &fsp); - - } else { - nt_status = open_directory(conn, NULL, filename, &st, - FILE_READ_ATTRIBUTES, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_OPEN, - 0, - FILE_ATTRIBUTE_DIRECTORY, - NULL, &fsp); - } + conn->server_info = p->server_info; + + nt_status = create_file( + conn, /* conn */ + NULL, /* req */ + 0, /* root_dir_fid */ + r->in.file, /* fname */ + FILE_READ_ATTRIBUTES, /* access_mask */ + FILE_SHARE_READ|FILE_SHARE_WRITE, /* share_access */ + FILE_OPEN, /* create_disposition*/ + 0, /* create_options */ + 0, /* file_attributes */ + INTERNAL_OPEN_ONLY, /* oplock_request */ + 0, /* allocation_size */ + NULL, /* sd */ + NULL, /* ea_list */ + &fsp, /* result */ + NULL, /* pinfo */ + NULL); /* psbuf */ if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srvsvc_NetGetFileSecurity: can't open %s\n", - filename)); + r->in.file)); werr = ntstatus_to_werror(nt_status); goto error_exit; } @@ -2121,15 +2089,15 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, |DACL_SECURITY_INFORMATION), &psd); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srvsvc_NetGetFileSecurity: Unable to get NT ACL for file %s\n", - filename)); + DEBUG(3,("_srvsvc_NetGetFileSecurity: Unable to get NT ACL " + "for file %s\n", r->in.file)); werr = ntstatus_to_werror(nt_status); goto error_exit; } sd_size = ndr_size_security_descriptor(psd, 0); - sd_buf = TALLOC_ZERO_P(ctx, struct sec_desc_buf); + sd_buf = TALLOC_ZERO_P(p->mem_ctx, struct sec_desc_buf); if (!sd_buf) { werr = WERR_NOMEM; goto error_exit; @@ -2143,23 +2111,22 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p, psd->dacl->revision = NT4_ACL_REVISION; close_file(fsp, NORMAL_CLOSE); - - unbecome_user(); - close_cnum(conn, user.vuid); + vfs_ChDir(conn, oldcwd); + conn_free_internal(conn); return WERR_OK; error_exit: - if(fsp) { + if (fsp) { close_file(fsp, NORMAL_CLOSE); } - if (became_user) { - unbecome_user(); + if (oldcwd) { + vfs_ChDir(conn, oldcwd); } if (conn) { - close_cnum(conn, user.vuid); + conn_free_internal(conn); } return werr; @@ -2173,125 +2140,90 @@ error_exit: WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecurity *r) { - char *filename_in = NULL; - char *filename = NULL; - char *qualname = NULL; - DATA_BLOB null_pw; + fstring servicename; files_struct *fsp = NULL; SMB_STRUCT_STAT st; NTSTATUS nt_status; WERROR werr; - struct current_user user; connection_struct *conn = NULL; - bool became_user = False; - TALLOC_CTX *ctx = p->mem_ctx; + int snum; + char *oldcwd = NULL; ZERO_STRUCT(st); - werr = WERR_OK; + fstrcpy(servicename, r->in.share); - qualname = talloc_strdup(ctx, r->in.share); - if (!qualname) { - werr = WERR_ACCESS_DENIED; + snum = find_service(servicename); + if (snum == -1) { + DEBUG(10, ("Could not find service %s\n", servicename)); + werr = WERR_NET_NAME_NOT_FOUND; goto error_exit; } - /* Null password is ok - we are already an authenticated user... */ - null_pw = data_blob_null; - - get_current_user(&user, p); - - become_root(); - conn = make_connection(qualname, null_pw, "A:", user.vuid, &nt_status); - unbecome_root(); - - if (conn == NULL) { - DEBUG(3,("_srvsvc_NetSetFileSecurity: Unable to connect to %s\n", qualname)); + nt_status = create_conn_struct(talloc_tos(), &conn, snum, + lp_pathname(snum), &oldcwd); + if (!NT_STATUS_IS_OK(nt_status)) { + DEBUG(10, ("create_conn_struct failed: %s\n", + nt_errstr(nt_status))); werr = ntstatus_to_werror(nt_status); goto error_exit; } - if (!become_user(conn, conn->vuid)) { - DEBUG(0,("_srvsvc_NetSetFileSecurity: Can't become connected user!\n")); - werr = WERR_ACCESS_DENIED; - goto error_exit; - } - became_user = True; + conn->server_info = p->server_info; + + nt_status = create_file( + conn, /* conn */ + NULL, /* req */ + 0, /* root_dir_fid */ + r->in.file, /* fname */ + FILE_WRITE_ATTRIBUTES, /* access_mask */ + FILE_SHARE_READ|FILE_SHARE_WRITE, /* share_access */ + FILE_OPEN, /* create_disposition*/ + 0, /* create_options */ + 0, /* file_attributes */ + INTERNAL_OPEN_ONLY, /* oplock_request */ + 0, /* allocation_size */ + NULL, /* sd */ + NULL, /* ea_list */ + &fsp, /* result */ + NULL, /* pinfo */ + NULL); /* psbuf */ - filename_in = talloc_strdup(ctx, r->in.file); - if (!filename_in) { - werr = WERR_ACCESS_DENIED; - goto error_exit; - } - - nt_status = unix_convert(ctx, conn, filename, False, &filename, NULL, &st); - if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srvsvc_NetSetFileSecurity: bad pathname %s\n", filename)); - werr = WERR_ACCESS_DENIED; - goto error_exit; - } - - nt_status = check_name(conn, filename); if (!NT_STATUS_IS_OK(nt_status)) { - DEBUG(3,("_srvsvc_NetSetFileSecurity: can't access %s\n", filename)); - werr = WERR_ACCESS_DENIED; + DEBUG(3,("_srvsvc_NetSetFileSecurity: can't open %s\n", + r->in.file)); + werr = ntstatus_to_werror(nt_status); goto error_exit; } - nt_status = open_file_ntcreate(conn, NULL, filename, &st, - FILE_WRITE_ATTRIBUTES, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_OPEN, - 0, - FILE_ATTRIBUTE_NORMAL, - INTERNAL_OPEN_ONLY, - NULL, &fsp); - - if ( !NT_STATUS_IS_OK(nt_status) ) { - /* Perhaps it is a directory */ - if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY)) - nt_status = open_directory(conn, NULL, filename, &st, - FILE_WRITE_ATTRIBUTES, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_OPEN, - 0, - FILE_ATTRIBUTE_DIRECTORY, - NULL, &fsp); - - if ( !NT_STATUS_IS_OK(nt_status) ) { - DEBUG(3,("_srvsvc_NetSetFileSecurity: Unable to open file %s\n", filename)); - werr = ntstatus_to_werror(nt_status); - goto error_exit; - } - } - nt_status = SMB_VFS_FSET_NT_ACL(fsp, r->in.securityinformation, r->in.sd_buf->sd); if (!NT_STATUS_IS_OK(nt_status) ) { - DEBUG(3,("_srvsvc_NetSetFileSecurity: Unable to set NT ACL on file %s\n", filename)); + DEBUG(3,("_srvsvc_NetSetFileSecurity: Unable to set NT ACL " + "on file %s\n", r->in.share)); werr = WERR_ACCESS_DENIED; goto error_exit; } close_file(fsp, NORMAL_CLOSE); - unbecome_user(); - close_cnum(conn, user.vuid); - return werr; + vfs_ChDir(conn, oldcwd); + conn_free_internal(conn); + return WERR_OK; error_exit: - if(fsp) { + if (fsp) { close_file(fsp, NORMAL_CLOSE); } - if (became_user) { - unbecome_user(); + if (oldcwd) { + vfs_ChDir(conn, oldcwd); } if (conn) { - close_cnum(conn, user.vuid); + conn_free_internal(conn); } return werr; -- cgit From e29e81624ef03e262c525aa209c076b0b12963b7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 30 Jul 2008 15:01:33 -0700 Subject: Fix duplicate gloabl warning. Jeremy. (This used to be commit 6da33797b0549a2da7dc0fa7ee21dc5e8a6b1459) --- source3/rpc_server/srv_pipe_hnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index bc6d180199..3968d41168 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -61,7 +61,7 @@ static struct bitmap *bmap; * system _anyway_. so that's the next step... */ -static int close_internal_rpc_pipe_hnd(struct pipes_struct *pipe); +static int close_internal_rpc_pipe_hnd(struct pipes_struct *p); /**************************************************************************** Internal Pipe iterator functions. -- cgit From 40b133eb88600049d1aed403540d441c7f23c5b9 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 13 Aug 2008 16:52:53 -0700 Subject: Fix coverity CID: 594. Resource leak on error path. Jeremy. (This used to be commit 1f38b9963c4ec0d73da496a72ba4ee74d8d581c9) --- source3/rpc_server/srv_spoolss_nt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index f80240042c..635898a9d5 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5037,8 +5037,10 @@ static WERROR getprinter_level_7(Printer_entry *print_hnd, int snum, RPC_BUFFER if((printer=SMB_MALLOC_P(PRINTER_INFO_7))==NULL) return WERR_NOMEM; - if (!construct_printer_info_7(print_hnd, printer, snum)) - return WERR_NOMEM; + if (!construct_printer_info_7(print_hnd, printer, snum)) { + result = WERR_NOMEM; + goto out; + } /* check the required size. */ *needed += spoolss_size_printer_info_7(printer); -- cgit From efbb8c189dbb04526c250c218847fcb337ee729a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 22 Aug 2008 00:20:46 +0200 Subject: rpc_server: make it a little more obvious what flags we send to a client. Guenther (This used to be commit f3791e03ab09cadb1f54e32e67f4dfb3cf42e708) --- source3/rpc_server/srv_netlog_nt.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_netlog_nt.c b/source3/rpc_server/srv_netlog_nt.c index 7ece482d75..4e211cfb81 100644 --- a/source3/rpc_server/srv_netlog_nt.c +++ b/source3/rpc_server/srv_netlog_nt.c @@ -521,7 +521,16 @@ NTSTATUS _netr_ServerAuthenticate2(pipes_struct *p, return NT_STATUS_ACCESS_DENIED; } - srv_flgs = 0x000001ff; + /* 0x000001ff */ + srv_flgs = NETLOGON_NEG_ACCOUNT_LOCKOUT | + NETLOGON_NEG_PERSISTENT_SAMREPL | + NETLOGON_NEG_ARCFOUR | + NETLOGON_NEG_PROMOTION_COUNT | + NETLOGON_NEG_CHANGELOG_BDC | + NETLOGON_NEG_FULL_SYNC_REPL | + NETLOGON_NEG_MULTIPLE_SIDS | + NETLOGON_NEG_REDO | + NETLOGON_NEG_PASSWORD_CHANGE_REFUSAL; if (lp_server_schannel() != false) { srv_flgs |= NETLOGON_NEG_SCHANNEL; -- cgit